Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause 2 : : * Copyright(c) 2023 Intel Corporation 3 : : */ 4 : : 5 : : #ifndef _CPFL_RXTX_VEC_COMMON_H_ 6 : : #define _CPFL_RXTX_VEC_COMMON_H_ 7 : : #include <stdint.h> 8 : : #include <ethdev_driver.h> 9 : : #include <rte_malloc.h> 10 : : 11 : : #include "cpfl_ethdev.h" 12 : : #include "cpfl_rxtx.h" 13 : : 14 : : #ifndef __INTEL_COMPILER 15 : : #pragma GCC diagnostic ignored "-Wcast-qual" 16 : : #endif 17 : : 18 : : #define CPFL_SCALAR_PATH 0 19 : : #define CPFL_VECTOR_PATH 1 20 : : #define CPFL_RX_NO_VECTOR_FLAGS ( \ 21 : : RTE_ETH_RX_OFFLOAD_IPV4_CKSUM | \ 22 : : RTE_ETH_RX_OFFLOAD_UDP_CKSUM | \ 23 : : RTE_ETH_RX_OFFLOAD_TCP_CKSUM | \ 24 : : RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM | \ 25 : : RTE_ETH_RX_OFFLOAD_TIMESTAMP) 26 : : #define CPFL_TX_NO_VECTOR_FLAGS ( \ 27 : : RTE_ETH_TX_OFFLOAD_TCP_TSO | \ 28 : : RTE_ETH_TX_OFFLOAD_MULTI_SEGS | \ 29 : : RTE_ETH_TX_OFFLOAD_IPV4_CKSUM | \ 30 : : RTE_ETH_TX_OFFLOAD_SCTP_CKSUM | \ 31 : : RTE_ETH_TX_OFFLOAD_UDP_CKSUM | \ 32 : : RTE_ETH_TX_OFFLOAD_TCP_CKSUM) 33 : : 34 : : static inline int 35 : 0 : cpfl_rx_vec_queue_default(struct idpf_rx_queue *rxq) 36 : : { 37 [ # # ]: 0 : if (rxq == NULL) 38 : : return CPFL_SCALAR_PATH; 39 : : 40 [ # # ]: 0 : if (rte_is_power_of_2(rxq->nb_rx_desc) == 0) 41 : : return CPFL_SCALAR_PATH; 42 : : 43 [ # # ]: 0 : if (rxq->rx_free_thresh < IDPF_VPMD_RX_MAX_BURST) 44 : : return CPFL_SCALAR_PATH; 45 : : 46 [ # # ]: 0 : if ((rxq->nb_rx_desc % rxq->rx_free_thresh) != 0) 47 : : return CPFL_SCALAR_PATH; 48 : : 49 [ # # ]: 0 : if ((rxq->offloads & CPFL_RX_NO_VECTOR_FLAGS) != 0) 50 : 0 : return CPFL_SCALAR_PATH; 51 : : 52 : : return CPFL_VECTOR_PATH; 53 : : } 54 : : 55 : : static inline int 56 : : cpfl_tx_vec_queue_default(struct idpf_tx_queue *txq) 57 : : { 58 : : if (txq == NULL) 59 : : return CPFL_SCALAR_PATH; 60 : : 61 [ # # # # ]: 0 : if (txq->rs_thresh < IDPF_VPMD_TX_MAX_BURST || 62 : : (txq->rs_thresh & 3) != 0) 63 : : return CPFL_SCALAR_PATH; 64 : : 65 [ # # ]: 0 : if ((txq->offloads & CPFL_TX_NO_VECTOR_FLAGS) != 0) 66 : : return CPFL_SCALAR_PATH; 67 : : 68 : : return CPFL_VECTOR_PATH; 69 : : } 70 : : 71 : : static inline int 72 : : cpfl_rx_splitq_vec_default(struct idpf_rx_queue *rxq) 73 : : { 74 [ # # ]: 0 : if (rxq->bufq2->rx_buf_len < rxq->max_pkt_len) 75 : 0 : return CPFL_SCALAR_PATH; 76 : : 77 : : return CPFL_VECTOR_PATH; 78 : : } 79 : : 80 : : static inline int 81 : 0 : cpfl_rx_vec_dev_check_default(struct rte_eth_dev *dev) 82 : : { 83 : 0 : struct cpfl_vport *cpfl_vport = dev->data->dev_private; 84 : : struct idpf_vport *vport = &cpfl_vport->base; 85 : : struct cpfl_rx_queue *cpfl_rxq; 86 : : int i, default_ret, splitq_ret, ret = CPFL_SCALAR_PATH; 87 : : 88 [ # # ]: 0 : if (dev->data->scattered_rx) 89 : : return CPFL_SCALAR_PATH; 90 : : 91 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) { 92 : 0 : cpfl_rxq = dev->data->rx_queues[i]; 93 : 0 : default_ret = cpfl_rx_vec_queue_default(&cpfl_rxq->base); 94 [ # # ]: 0 : if (vport->rxq_model == VIRTCHNL2_QUEUE_MODEL_SPLIT) { 95 [ # # ]: 0 : if (cpfl_rxq->hairpin_info.hairpin_q) 96 : 0 : continue; 97 : : splitq_ret = cpfl_rx_splitq_vec_default(&cpfl_rxq->base); 98 : 0 : ret = splitq_ret && default_ret; 99 : : } else { 100 : : ret = default_ret; 101 : : } 102 [ # # ]: 0 : if (ret == CPFL_SCALAR_PATH) 103 : : return CPFL_SCALAR_PATH; 104 : : } 105 : : 106 : : return CPFL_VECTOR_PATH; 107 : : } 108 : : 109 : : static inline int 110 : 0 : cpfl_tx_vec_dev_check_default(struct rte_eth_dev *dev) 111 : : { 112 : : int i; 113 : : struct cpfl_tx_queue *cpfl_txq; 114 : : int ret = 0; 115 : : 116 [ # # ]: 0 : for (i = 0; i < dev->data->nb_tx_queues; i++) { 117 : 0 : cpfl_txq = dev->data->tx_queues[i]; 118 [ # # ]: 0 : if (cpfl_txq->hairpin_info.hairpin_q) 119 : 0 : continue; 120 : : ret = cpfl_tx_vec_queue_default(&cpfl_txq->base); 121 : : if (ret == CPFL_SCALAR_PATH) 122 : : return CPFL_SCALAR_PATH; 123 : : } 124 : : 125 : : return CPFL_VECTOR_PATH; 126 : : } 127 : : 128 : : #endif /*_CPFL_RXTX_VEC_COMMON_H_*/