1*c1d14583SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause 2*c1d14583SBruce Richardson * Copyright(c) 2019 Intel Corporation 3*c1d14583SBruce Richardson */ 4*c1d14583SBruce Richardson 5*c1d14583SBruce Richardson #ifndef _ICE_RXTX_VEC_COMMON_H_ 6*c1d14583SBruce Richardson #define _ICE_RXTX_VEC_COMMON_H_ 7*c1d14583SBruce Richardson 8*c1d14583SBruce Richardson #include "ice_rxtx.h" 9*c1d14583SBruce Richardson 10*c1d14583SBruce Richardson static inline uint16_t 11*c1d14583SBruce Richardson ice_rx_reassemble_packets(struct ice_rx_queue *rxq, struct rte_mbuf **rx_bufs, 12*c1d14583SBruce Richardson uint16_t nb_bufs, uint8_t *split_flags) 13*c1d14583SBruce Richardson { 14*c1d14583SBruce Richardson struct rte_mbuf *pkts[ICE_VPMD_RX_BURST] = {0}; /*finished pkts*/ 15*c1d14583SBruce Richardson struct rte_mbuf *start = rxq->pkt_first_seg; 16*c1d14583SBruce Richardson struct rte_mbuf *end = rxq->pkt_last_seg; 17*c1d14583SBruce Richardson unsigned int pkt_idx, buf_idx; 18*c1d14583SBruce Richardson 19*c1d14583SBruce Richardson for (buf_idx = 0, pkt_idx = 0; buf_idx < nb_bufs; buf_idx++) { 20*c1d14583SBruce Richardson if (end) { 21*c1d14583SBruce Richardson /* processing a split packet */ 22*c1d14583SBruce Richardson end->next = rx_bufs[buf_idx]; 23*c1d14583SBruce Richardson rx_bufs[buf_idx]->data_len += rxq->crc_len; 24*c1d14583SBruce Richardson 25*c1d14583SBruce Richardson start->nb_segs++; 26*c1d14583SBruce Richardson start->pkt_len += rx_bufs[buf_idx]->data_len; 27*c1d14583SBruce Richardson end = end->next; 28*c1d14583SBruce Richardson 29*c1d14583SBruce Richardson if (!split_flags[buf_idx]) { 30*c1d14583SBruce Richardson /* it's the last packet of the set */ 31*c1d14583SBruce Richardson start->hash = end->hash; 32*c1d14583SBruce Richardson start->vlan_tci = end->vlan_tci; 33*c1d14583SBruce Richardson start->ol_flags = end->ol_flags; 34*c1d14583SBruce Richardson /* we need to strip crc for the whole packet */ 35*c1d14583SBruce Richardson start->pkt_len -= rxq->crc_len; 36*c1d14583SBruce Richardson if (end->data_len > rxq->crc_len) { 37*c1d14583SBruce Richardson end->data_len -= rxq->crc_len; 38*c1d14583SBruce Richardson } else { 39*c1d14583SBruce Richardson /* free up last mbuf */ 40*c1d14583SBruce Richardson struct rte_mbuf *secondlast = start; 41*c1d14583SBruce Richardson 42*c1d14583SBruce Richardson start->nb_segs--; 43*c1d14583SBruce Richardson while (secondlast->next != end) 44*c1d14583SBruce Richardson secondlast = secondlast->next; 45*c1d14583SBruce Richardson secondlast->data_len -= (rxq->crc_len - 46*c1d14583SBruce Richardson end->data_len); 47*c1d14583SBruce Richardson secondlast->next = NULL; 48*c1d14583SBruce Richardson rte_pktmbuf_free_seg(end); 49*c1d14583SBruce Richardson } 50*c1d14583SBruce Richardson pkts[pkt_idx++] = start; 51*c1d14583SBruce Richardson start = NULL; 52*c1d14583SBruce Richardson end = NULL; 53*c1d14583SBruce Richardson } 54*c1d14583SBruce Richardson } else { 55*c1d14583SBruce Richardson /* not processing a split packet */ 56*c1d14583SBruce Richardson if (!split_flags[buf_idx]) { 57*c1d14583SBruce Richardson /* not a split packet, save and skip */ 58*c1d14583SBruce Richardson pkts[pkt_idx++] = rx_bufs[buf_idx]; 59*c1d14583SBruce Richardson continue; 60*c1d14583SBruce Richardson } 61*c1d14583SBruce Richardson start = rx_bufs[buf_idx]; 62*c1d14583SBruce Richardson end = start; 63*c1d14583SBruce Richardson rx_bufs[buf_idx]->data_len += rxq->crc_len; 64*c1d14583SBruce Richardson rx_bufs[buf_idx]->pkt_len += rxq->crc_len; 65*c1d14583SBruce Richardson } 66*c1d14583SBruce Richardson } 67*c1d14583SBruce Richardson 68*c1d14583SBruce Richardson /* save the partial packet for next time */ 69*c1d14583SBruce Richardson rxq->pkt_first_seg = start; 70*c1d14583SBruce Richardson rxq->pkt_last_seg = end; 71*c1d14583SBruce Richardson memcpy(rx_bufs, pkts, pkt_idx * (sizeof(*pkts))); 72*c1d14583SBruce Richardson return pkt_idx; 73*c1d14583SBruce Richardson } 74*c1d14583SBruce Richardson 75*c1d14583SBruce Richardson static __rte_always_inline int 76*c1d14583SBruce Richardson ice_tx_free_bufs_vec(struct ice_tx_queue *txq) 77*c1d14583SBruce Richardson { 78*c1d14583SBruce Richardson struct ice_tx_entry *txep; 79*c1d14583SBruce Richardson uint32_t n; 80*c1d14583SBruce Richardson uint32_t i; 81*c1d14583SBruce Richardson int nb_free = 0; 82*c1d14583SBruce Richardson struct rte_mbuf *m, *free[ICE_TX_MAX_FREE_BUF_SZ]; 83*c1d14583SBruce Richardson 84*c1d14583SBruce Richardson /* check DD bits on threshold descriptor */ 85*c1d14583SBruce Richardson if ((txq->tx_ring[txq->tx_next_dd].cmd_type_offset_bsz & 86*c1d14583SBruce Richardson rte_cpu_to_le_64(ICE_TXD_QW1_DTYPE_M)) != 87*c1d14583SBruce Richardson rte_cpu_to_le_64(ICE_TX_DESC_DTYPE_DESC_DONE)) 88*c1d14583SBruce Richardson return 0; 89*c1d14583SBruce Richardson 90*c1d14583SBruce Richardson n = txq->tx_rs_thresh; 91*c1d14583SBruce Richardson 92*c1d14583SBruce Richardson /* first buffer to free from S/W ring is at index 93*c1d14583SBruce Richardson * tx_next_dd - (tx_rs_thresh-1) 94*c1d14583SBruce Richardson */ 95*c1d14583SBruce Richardson txep = &txq->sw_ring[txq->tx_next_dd - (n - 1)]; 96*c1d14583SBruce Richardson m = rte_pktmbuf_prefree_seg(txep[0].mbuf); 97*c1d14583SBruce Richardson if (likely(m)) { 98*c1d14583SBruce Richardson free[0] = m; 99*c1d14583SBruce Richardson nb_free = 1; 100*c1d14583SBruce Richardson for (i = 1; i < n; i++) { 101*c1d14583SBruce Richardson m = rte_pktmbuf_prefree_seg(txep[i].mbuf); 102*c1d14583SBruce Richardson if (likely(m)) { 103*c1d14583SBruce Richardson if (likely(m->pool == free[0]->pool)) { 104*c1d14583SBruce Richardson free[nb_free++] = m; 105*c1d14583SBruce Richardson } else { 106*c1d14583SBruce Richardson rte_mempool_put_bulk(free[0]->pool, 107*c1d14583SBruce Richardson (void *)free, 108*c1d14583SBruce Richardson nb_free); 109*c1d14583SBruce Richardson free[0] = m; 110*c1d14583SBruce Richardson nb_free = 1; 111*c1d14583SBruce Richardson } 112*c1d14583SBruce Richardson } 113*c1d14583SBruce Richardson } 114*c1d14583SBruce Richardson rte_mempool_put_bulk(free[0]->pool, (void **)free, nb_free); 115*c1d14583SBruce Richardson } else { 116*c1d14583SBruce Richardson for (i = 1; i < n; i++) { 117*c1d14583SBruce Richardson m = rte_pktmbuf_prefree_seg(txep[i].mbuf); 118*c1d14583SBruce Richardson if (m) 119*c1d14583SBruce Richardson rte_mempool_put(m->pool, m); 120*c1d14583SBruce Richardson } 121*c1d14583SBruce Richardson } 122*c1d14583SBruce Richardson 123*c1d14583SBruce Richardson /* buffers were freed, update counters */ 124*c1d14583SBruce Richardson txq->nb_tx_free = (uint16_t)(txq->nb_tx_free + txq->tx_rs_thresh); 125*c1d14583SBruce Richardson txq->tx_next_dd = (uint16_t)(txq->tx_next_dd + txq->tx_rs_thresh); 126*c1d14583SBruce Richardson if (txq->tx_next_dd >= txq->nb_tx_desc) 127*c1d14583SBruce Richardson txq->tx_next_dd = (uint16_t)(txq->tx_rs_thresh - 1); 128*c1d14583SBruce Richardson 129*c1d14583SBruce Richardson return txq->tx_rs_thresh; 130*c1d14583SBruce Richardson } 131*c1d14583SBruce Richardson 132*c1d14583SBruce Richardson static __rte_always_inline void 133*c1d14583SBruce Richardson ice_tx_backlog_entry(struct ice_tx_entry *txep, 134*c1d14583SBruce Richardson struct rte_mbuf **tx_pkts, uint16_t nb_pkts) 135*c1d14583SBruce Richardson { 136*c1d14583SBruce Richardson int i; 137*c1d14583SBruce Richardson 138*c1d14583SBruce Richardson for (i = 0; i < (int)nb_pkts; ++i) 139*c1d14583SBruce Richardson txep[i].mbuf = tx_pkts[i]; 140*c1d14583SBruce Richardson } 141*c1d14583SBruce Richardson 142*c1d14583SBruce Richardson static inline void 143*c1d14583SBruce Richardson _ice_rx_queue_release_mbufs_vec(struct ice_rx_queue *rxq) 144*c1d14583SBruce Richardson { 145*c1d14583SBruce Richardson const unsigned int mask = rxq->nb_rx_desc - 1; 146*c1d14583SBruce Richardson unsigned int i; 147*c1d14583SBruce Richardson 148*c1d14583SBruce Richardson if (unlikely(!rxq->sw_ring)) { 149*c1d14583SBruce Richardson PMD_DRV_LOG(DEBUG, "sw_ring is NULL"); 150*c1d14583SBruce Richardson return; 151*c1d14583SBruce Richardson } 152*c1d14583SBruce Richardson 153*c1d14583SBruce Richardson if (rxq->rxrearm_nb >= rxq->nb_rx_desc) 154*c1d14583SBruce Richardson return; 155*c1d14583SBruce Richardson 156*c1d14583SBruce Richardson /* free all mbufs that are valid in the ring */ 157*c1d14583SBruce Richardson if (rxq->rxrearm_nb == 0) { 158*c1d14583SBruce Richardson for (i = 0; i < rxq->nb_rx_desc; i++) { 159*c1d14583SBruce Richardson if (rxq->sw_ring[i].mbuf) 160*c1d14583SBruce Richardson rte_pktmbuf_free_seg(rxq->sw_ring[i].mbuf); 161*c1d14583SBruce Richardson } 162*c1d14583SBruce Richardson } else { 163*c1d14583SBruce Richardson for (i = rxq->rx_tail; 164*c1d14583SBruce Richardson i != rxq->rxrearm_start; 165*c1d14583SBruce Richardson i = (i + 1) & mask) { 166*c1d14583SBruce Richardson if (rxq->sw_ring[i].mbuf) 167*c1d14583SBruce Richardson rte_pktmbuf_free_seg(rxq->sw_ring[i].mbuf); 168*c1d14583SBruce Richardson } 169*c1d14583SBruce Richardson } 170*c1d14583SBruce Richardson 171*c1d14583SBruce Richardson rxq->rxrearm_nb = rxq->nb_rx_desc; 172*c1d14583SBruce Richardson 173*c1d14583SBruce Richardson /* set all entries to NULL */ 174*c1d14583SBruce Richardson memset(rxq->sw_ring, 0, sizeof(rxq->sw_ring[0]) * rxq->nb_rx_desc); 175*c1d14583SBruce Richardson } 176*c1d14583SBruce Richardson 177*c1d14583SBruce Richardson static inline void 178*c1d14583SBruce Richardson _ice_tx_queue_release_mbufs_vec(struct ice_tx_queue *txq) 179*c1d14583SBruce Richardson { 180*c1d14583SBruce Richardson uint16_t i; 181*c1d14583SBruce Richardson 182*c1d14583SBruce Richardson if (unlikely(!txq || !txq->sw_ring)) { 183*c1d14583SBruce Richardson PMD_DRV_LOG(DEBUG, "Pointer to rxq or sw_ring is NULL"); 184*c1d14583SBruce Richardson return; 185*c1d14583SBruce Richardson } 186*c1d14583SBruce Richardson 187*c1d14583SBruce Richardson /** 188*c1d14583SBruce Richardson * vPMD tx will not set sw_ring's mbuf to NULL after free, 189*c1d14583SBruce Richardson * so need to free remains more carefully. 190*c1d14583SBruce Richardson */ 191*c1d14583SBruce Richardson i = txq->tx_next_dd - txq->tx_rs_thresh + 1; 192*c1d14583SBruce Richardson 193*c1d14583SBruce Richardson #ifdef __AVX512VL__ 194*c1d14583SBruce Richardson struct rte_eth_dev *dev = &rte_eth_devices[txq->vsi->adapter->pf.dev_data->port_id]; 195*c1d14583SBruce Richardson 196*c1d14583SBruce Richardson if (dev->tx_pkt_burst == ice_xmit_pkts_vec_avx512 || 197*c1d14583SBruce Richardson dev->tx_pkt_burst == ice_xmit_pkts_vec_avx512_offload) { 198*c1d14583SBruce Richardson struct ice_vec_tx_entry *swr = (void *)txq->sw_ring; 199*c1d14583SBruce Richardson 200*c1d14583SBruce Richardson if (txq->tx_tail < i) { 201*c1d14583SBruce Richardson for (; i < txq->nb_tx_desc; i++) { 202*c1d14583SBruce Richardson rte_pktmbuf_free_seg(swr[i].mbuf); 203*c1d14583SBruce Richardson swr[i].mbuf = NULL; 204*c1d14583SBruce Richardson } 205*c1d14583SBruce Richardson i = 0; 206*c1d14583SBruce Richardson } 207*c1d14583SBruce Richardson for (; i < txq->tx_tail; i++) { 208*c1d14583SBruce Richardson rte_pktmbuf_free_seg(swr[i].mbuf); 209*c1d14583SBruce Richardson swr[i].mbuf = NULL; 210*c1d14583SBruce Richardson } 211*c1d14583SBruce Richardson } else 212*c1d14583SBruce Richardson #endif 213*c1d14583SBruce Richardson { 214*c1d14583SBruce Richardson if (txq->tx_tail < i) { 215*c1d14583SBruce Richardson for (; i < txq->nb_tx_desc; i++) { 216*c1d14583SBruce Richardson rte_pktmbuf_free_seg(txq->sw_ring[i].mbuf); 217*c1d14583SBruce Richardson txq->sw_ring[i].mbuf = NULL; 218*c1d14583SBruce Richardson } 219*c1d14583SBruce Richardson i = 0; 220*c1d14583SBruce Richardson } 221*c1d14583SBruce Richardson for (; i < txq->tx_tail; i++) { 222*c1d14583SBruce Richardson rte_pktmbuf_free_seg(txq->sw_ring[i].mbuf); 223*c1d14583SBruce Richardson txq->sw_ring[i].mbuf = NULL; 224*c1d14583SBruce Richardson } 225*c1d14583SBruce Richardson } 226*c1d14583SBruce Richardson } 227*c1d14583SBruce Richardson 228*c1d14583SBruce Richardson static inline int 229*c1d14583SBruce Richardson ice_rxq_vec_setup_default(struct ice_rx_queue *rxq) 230*c1d14583SBruce Richardson { 231*c1d14583SBruce Richardson uintptr_t p; 232*c1d14583SBruce Richardson struct rte_mbuf mb_def = { .buf_addr = 0 }; /* zeroed mbuf */ 233*c1d14583SBruce Richardson 234*c1d14583SBruce Richardson mb_def.nb_segs = 1; 235*c1d14583SBruce Richardson mb_def.data_off = RTE_PKTMBUF_HEADROOM; 236*c1d14583SBruce Richardson mb_def.port = rxq->port_id; 237*c1d14583SBruce Richardson rte_mbuf_refcnt_set(&mb_def, 1); 238*c1d14583SBruce Richardson 239*c1d14583SBruce Richardson /* prevent compiler reordering: rearm_data covers previous fields */ 240*c1d14583SBruce Richardson rte_compiler_barrier(); 241*c1d14583SBruce Richardson p = (uintptr_t)&mb_def.rearm_data; 242*c1d14583SBruce Richardson rxq->mbuf_initializer = *(uint64_t *)p; 243*c1d14583SBruce Richardson return 0; 244*c1d14583SBruce Richardson } 245*c1d14583SBruce Richardson 246*c1d14583SBruce Richardson #define ICE_TX_NO_VECTOR_FLAGS ( \ 247*c1d14583SBruce Richardson RTE_ETH_TX_OFFLOAD_MULTI_SEGS | \ 248*c1d14583SBruce Richardson RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM | \ 249*c1d14583SBruce Richardson RTE_ETH_TX_OFFLOAD_TCP_TSO | \ 250*c1d14583SBruce Richardson RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO | \ 251*c1d14583SBruce Richardson RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO | \ 252*c1d14583SBruce Richardson RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO | \ 253*c1d14583SBruce Richardson RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO | \ 254*c1d14583SBruce Richardson RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) 255*c1d14583SBruce Richardson 256*c1d14583SBruce Richardson #define ICE_TX_VECTOR_OFFLOAD ( \ 257*c1d14583SBruce Richardson RTE_ETH_TX_OFFLOAD_VLAN_INSERT | \ 258*c1d14583SBruce Richardson RTE_ETH_TX_OFFLOAD_QINQ_INSERT | \ 259*c1d14583SBruce Richardson RTE_ETH_TX_OFFLOAD_IPV4_CKSUM | \ 260*c1d14583SBruce Richardson RTE_ETH_TX_OFFLOAD_SCTP_CKSUM | \ 261*c1d14583SBruce Richardson RTE_ETH_TX_OFFLOAD_UDP_CKSUM | \ 262*c1d14583SBruce Richardson RTE_ETH_TX_OFFLOAD_TCP_CKSUM) 263*c1d14583SBruce Richardson 264*c1d14583SBruce Richardson #define ICE_RX_VECTOR_OFFLOAD ( \ 265*c1d14583SBruce Richardson RTE_ETH_RX_OFFLOAD_CHECKSUM | \ 266*c1d14583SBruce Richardson RTE_ETH_RX_OFFLOAD_SCTP_CKSUM | \ 267*c1d14583SBruce Richardson RTE_ETH_RX_OFFLOAD_VLAN | \ 268*c1d14583SBruce Richardson RTE_ETH_RX_OFFLOAD_RSS_HASH) 269*c1d14583SBruce Richardson 270*c1d14583SBruce Richardson #define ICE_VECTOR_PATH 0 271*c1d14583SBruce Richardson #define ICE_VECTOR_OFFLOAD_PATH 1 272*c1d14583SBruce Richardson 273*c1d14583SBruce Richardson static inline int 274*c1d14583SBruce Richardson ice_rx_vec_queue_default(struct ice_rx_queue *rxq) 275*c1d14583SBruce Richardson { 276*c1d14583SBruce Richardson if (!rxq) 277*c1d14583SBruce Richardson return -1; 278*c1d14583SBruce Richardson 279*c1d14583SBruce Richardson if (!rte_is_power_of_2(rxq->nb_rx_desc)) 280*c1d14583SBruce Richardson return -1; 281*c1d14583SBruce Richardson 282*c1d14583SBruce Richardson if (rxq->rx_free_thresh < ICE_VPMD_RX_BURST) 283*c1d14583SBruce Richardson return -1; 284*c1d14583SBruce Richardson 285*c1d14583SBruce Richardson if (rxq->nb_rx_desc % rxq->rx_free_thresh) 286*c1d14583SBruce Richardson return -1; 287*c1d14583SBruce Richardson 288*c1d14583SBruce Richardson if (rxq->proto_xtr != PROTO_XTR_NONE) 289*c1d14583SBruce Richardson return -1; 290*c1d14583SBruce Richardson 291*c1d14583SBruce Richardson if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) 292*c1d14583SBruce Richardson return -1; 293*c1d14583SBruce Richardson 294*c1d14583SBruce Richardson if (rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) 295*c1d14583SBruce Richardson return -1; 296*c1d14583SBruce Richardson 297*c1d14583SBruce Richardson if (rxq->offloads & ICE_RX_VECTOR_OFFLOAD) 298*c1d14583SBruce Richardson return ICE_VECTOR_OFFLOAD_PATH; 299*c1d14583SBruce Richardson 300*c1d14583SBruce Richardson return ICE_VECTOR_PATH; 301*c1d14583SBruce Richardson } 302*c1d14583SBruce Richardson 303*c1d14583SBruce Richardson static inline int 304*c1d14583SBruce Richardson ice_tx_vec_queue_default(struct ice_tx_queue *txq) 305*c1d14583SBruce Richardson { 306*c1d14583SBruce Richardson if (!txq) 307*c1d14583SBruce Richardson return -1; 308*c1d14583SBruce Richardson 309*c1d14583SBruce Richardson if (txq->tx_rs_thresh < ICE_VPMD_TX_BURST || 310*c1d14583SBruce Richardson txq->tx_rs_thresh > ICE_TX_MAX_FREE_BUF_SZ) 311*c1d14583SBruce Richardson return -1; 312*c1d14583SBruce Richardson 313*c1d14583SBruce Richardson if (txq->offloads & ICE_TX_NO_VECTOR_FLAGS) 314*c1d14583SBruce Richardson return -1; 315*c1d14583SBruce Richardson 316*c1d14583SBruce Richardson if (txq->offloads & ICE_TX_VECTOR_OFFLOAD) 317*c1d14583SBruce Richardson return ICE_VECTOR_OFFLOAD_PATH; 318*c1d14583SBruce Richardson 319*c1d14583SBruce Richardson return ICE_VECTOR_PATH; 320*c1d14583SBruce Richardson } 321*c1d14583SBruce Richardson 322*c1d14583SBruce Richardson static inline int 323*c1d14583SBruce Richardson ice_rx_vec_dev_check_default(struct rte_eth_dev *dev) 324*c1d14583SBruce Richardson { 325*c1d14583SBruce Richardson int i; 326*c1d14583SBruce Richardson struct ice_rx_queue *rxq; 327*c1d14583SBruce Richardson int ret = 0; 328*c1d14583SBruce Richardson int result = 0; 329*c1d14583SBruce Richardson 330*c1d14583SBruce Richardson for (i = 0; i < dev->data->nb_rx_queues; i++) { 331*c1d14583SBruce Richardson rxq = dev->data->rx_queues[i]; 332*c1d14583SBruce Richardson ret = (ice_rx_vec_queue_default(rxq)); 333*c1d14583SBruce Richardson if (ret < 0) 334*c1d14583SBruce Richardson return -1; 335*c1d14583SBruce Richardson if (ret == ICE_VECTOR_OFFLOAD_PATH) 336*c1d14583SBruce Richardson result = ret; 337*c1d14583SBruce Richardson } 338*c1d14583SBruce Richardson 339*c1d14583SBruce Richardson return result; 340*c1d14583SBruce Richardson } 341*c1d14583SBruce Richardson 342*c1d14583SBruce Richardson static inline int 343*c1d14583SBruce Richardson ice_tx_vec_dev_check_default(struct rte_eth_dev *dev) 344*c1d14583SBruce Richardson { 345*c1d14583SBruce Richardson int i; 346*c1d14583SBruce Richardson struct ice_tx_queue *txq; 347*c1d14583SBruce Richardson int ret = 0; 348*c1d14583SBruce Richardson int result = 0; 349*c1d14583SBruce Richardson 350*c1d14583SBruce Richardson for (i = 0; i < dev->data->nb_tx_queues; i++) { 351*c1d14583SBruce Richardson txq = dev->data->tx_queues[i]; 352*c1d14583SBruce Richardson ret = ice_tx_vec_queue_default(txq); 353*c1d14583SBruce Richardson if (ret < 0) 354*c1d14583SBruce Richardson return -1; 355*c1d14583SBruce Richardson if (ret == ICE_VECTOR_OFFLOAD_PATH) 356*c1d14583SBruce Richardson result = ret; 357*c1d14583SBruce Richardson } 358*c1d14583SBruce Richardson 359*c1d14583SBruce Richardson return result; 360*c1d14583SBruce Richardson } 361*c1d14583SBruce Richardson 362*c1d14583SBruce Richardson static inline void 363*c1d14583SBruce Richardson ice_txd_enable_offload(struct rte_mbuf *tx_pkt, 364*c1d14583SBruce Richardson uint64_t *txd_hi) 365*c1d14583SBruce Richardson { 366*c1d14583SBruce Richardson uint64_t ol_flags = tx_pkt->ol_flags; 367*c1d14583SBruce Richardson uint32_t td_cmd = 0; 368*c1d14583SBruce Richardson uint32_t td_offset = 0; 369*c1d14583SBruce Richardson 370*c1d14583SBruce Richardson /* Tx Checksum Offload */ 371*c1d14583SBruce Richardson /* SET MACLEN */ 372*c1d14583SBruce Richardson td_offset |= (tx_pkt->l2_len >> 1) << 373*c1d14583SBruce Richardson ICE_TX_DESC_LEN_MACLEN_S; 374*c1d14583SBruce Richardson 375*c1d14583SBruce Richardson /* Enable L3 checksum offload */ 376*c1d14583SBruce Richardson if (ol_flags & RTE_MBUF_F_TX_IP_CKSUM) { 377*c1d14583SBruce Richardson td_cmd |= ICE_TX_DESC_CMD_IIPT_IPV4_CSUM; 378*c1d14583SBruce Richardson td_offset |= (tx_pkt->l3_len >> 2) << 379*c1d14583SBruce Richardson ICE_TX_DESC_LEN_IPLEN_S; 380*c1d14583SBruce Richardson } else if (ol_flags & RTE_MBUF_F_TX_IPV4) { 381*c1d14583SBruce Richardson td_cmd |= ICE_TX_DESC_CMD_IIPT_IPV4; 382*c1d14583SBruce Richardson td_offset |= (tx_pkt->l3_len >> 2) << 383*c1d14583SBruce Richardson ICE_TX_DESC_LEN_IPLEN_S; 384*c1d14583SBruce Richardson } else if (ol_flags & RTE_MBUF_F_TX_IPV6) { 385*c1d14583SBruce Richardson td_cmd |= ICE_TX_DESC_CMD_IIPT_IPV6; 386*c1d14583SBruce Richardson td_offset |= (tx_pkt->l3_len >> 2) << 387*c1d14583SBruce Richardson ICE_TX_DESC_LEN_IPLEN_S; 388*c1d14583SBruce Richardson } 389*c1d14583SBruce Richardson 390*c1d14583SBruce Richardson /* Enable L4 checksum offloads */ 391*c1d14583SBruce Richardson switch (ol_flags & RTE_MBUF_F_TX_L4_MASK) { 392*c1d14583SBruce Richardson case RTE_MBUF_F_TX_TCP_CKSUM: 393*c1d14583SBruce Richardson td_cmd |= ICE_TX_DESC_CMD_L4T_EOFT_TCP; 394*c1d14583SBruce Richardson td_offset |= (sizeof(struct rte_tcp_hdr) >> 2) << 395*c1d14583SBruce Richardson ICE_TX_DESC_LEN_L4_LEN_S; 396*c1d14583SBruce Richardson break; 397*c1d14583SBruce Richardson case RTE_MBUF_F_TX_SCTP_CKSUM: 398*c1d14583SBruce Richardson td_cmd |= ICE_TX_DESC_CMD_L4T_EOFT_SCTP; 399*c1d14583SBruce Richardson td_offset |= (sizeof(struct rte_sctp_hdr) >> 2) << 400*c1d14583SBruce Richardson ICE_TX_DESC_LEN_L4_LEN_S; 401*c1d14583SBruce Richardson break; 402*c1d14583SBruce Richardson case RTE_MBUF_F_TX_UDP_CKSUM: 403*c1d14583SBruce Richardson td_cmd |= ICE_TX_DESC_CMD_L4T_EOFT_UDP; 404*c1d14583SBruce Richardson td_offset |= (sizeof(struct rte_udp_hdr) >> 2) << 405*c1d14583SBruce Richardson ICE_TX_DESC_LEN_L4_LEN_S; 406*c1d14583SBruce Richardson break; 407*c1d14583SBruce Richardson default: 408*c1d14583SBruce Richardson break; 409*c1d14583SBruce Richardson } 410*c1d14583SBruce Richardson 411*c1d14583SBruce Richardson *txd_hi |= ((uint64_t)td_offset) << ICE_TXD_QW1_OFFSET_S; 412*c1d14583SBruce Richardson 413*c1d14583SBruce Richardson /* Tx VLAN/QINQ insertion Offload */ 414*c1d14583SBruce Richardson if (ol_flags & (RTE_MBUF_F_TX_VLAN | RTE_MBUF_F_TX_QINQ)) { 415*c1d14583SBruce Richardson td_cmd |= ICE_TX_DESC_CMD_IL2TAG1; 416*c1d14583SBruce Richardson *txd_hi |= ((uint64_t)tx_pkt->vlan_tci << 417*c1d14583SBruce Richardson ICE_TXD_QW1_L2TAG1_S); 418*c1d14583SBruce Richardson } 419*c1d14583SBruce Richardson 420*c1d14583SBruce Richardson *txd_hi |= ((uint64_t)td_cmd) << ICE_TXD_QW1_CMD_S; 421*c1d14583SBruce Richardson } 422*c1d14583SBruce Richardson #endif 423