LCOV - code coverage report
Current view: top level - drivers/net/intel/ice - ice_rxtx.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 1712 0.0 %
Date: 2025-06-01 17:49:23 Functions: 0 65 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 946 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2018 Intel Corporation
       3                 :            :  */
       4                 :            : 
       5                 :            : #include <ethdev_driver.h>
       6                 :            : #include <rte_net.h>
       7                 :            : #include <rte_vect.h>
       8                 :            : 
       9                 :            : #include "ice_rxtx.h"
      10                 :            : #include "ice_rxtx_vec_common.h"
      11                 :            : 
      12                 :            : #define ICE_TX_CKSUM_OFFLOAD_MASK (RTE_MBUF_F_TX_IP_CKSUM |              \
      13                 :            :                 RTE_MBUF_F_TX_L4_MASK |          \
      14                 :            :                 RTE_MBUF_F_TX_TCP_SEG |          \
      15                 :            :                 RTE_MBUF_F_TX_UDP_SEG |          \
      16                 :            :                 RTE_MBUF_F_TX_OUTER_IP_CKSUM)
      17                 :            : 
      18                 :            : /**
      19                 :            :  * The mbuf dynamic field pointer for protocol extraction metadata.
      20                 :            :  */
      21                 :            : #define ICE_DYNF_PROTO_XTR_METADATA(m, n) \
      22                 :            :         RTE_MBUF_DYNFIELD((m), (n), uint32_t *)
      23                 :            : 
      24                 :            : static int
      25                 :          0 : ice_monitor_callback(const uint64_t value,
      26                 :            :                 const uint64_t arg[RTE_POWER_MONITOR_OPAQUE_SZ] __rte_unused)
      27                 :            : {
      28                 :            :         const uint64_t m = rte_cpu_to_le_16(1 << ICE_RX_FLEX_DESC_STATUS0_DD_S);
      29                 :            :         /*
      30                 :            :          * we expect the DD bit to be set to 1 if this descriptor was already
      31                 :            :          * written to.
      32                 :            :          */
      33         [ #  # ]:          0 :         return (value & m) == m ? -1 : 0;
      34                 :            : }
      35                 :            : 
      36                 :            : int
      37                 :          0 : ice_get_monitor_addr(void *rx_queue, struct rte_power_monitor_cond *pmc)
      38                 :            : {
      39                 :            :         volatile union ice_rx_flex_desc *rxdp;
      40                 :            :         struct ice_rx_queue *rxq = rx_queue;
      41                 :            :         uint16_t desc;
      42                 :            : 
      43                 :          0 :         desc = rxq->rx_tail;
      44                 :          0 :         rxdp = &rxq->rx_ring[desc];
      45                 :            :         /* watch for changes in status bit */
      46                 :          0 :         pmc->addr = &rxdp->wb.status_error0;
      47                 :            : 
      48                 :            :         /* comparison callback */
      49                 :          0 :         pmc->fn = ice_monitor_callback;
      50                 :            : 
      51                 :            :         /* register is 16-bit */
      52                 :          0 :         pmc->size = sizeof(uint16_t);
      53                 :            : 
      54                 :          0 :         return 0;
      55                 :            : }
      56                 :            : 
      57                 :            : 
      58                 :            : static inline uint8_t
      59                 :            : ice_proto_xtr_type_to_rxdid(uint8_t xtr_type)
      60                 :            : {
      61                 :            :         static uint8_t rxdid_map[] = {
      62                 :            :                 [PROTO_XTR_NONE]      = ICE_RXDID_COMMS_OVS,
      63                 :            :                 [PROTO_XTR_VLAN]      = ICE_RXDID_COMMS_AUX_VLAN,
      64                 :            :                 [PROTO_XTR_IPV4]      = ICE_RXDID_COMMS_AUX_IPV4,
      65                 :            :                 [PROTO_XTR_IPV6]      = ICE_RXDID_COMMS_AUX_IPV6,
      66                 :            :                 [PROTO_XTR_IPV6_FLOW] = ICE_RXDID_COMMS_AUX_IPV6_FLOW,
      67                 :            :                 [PROTO_XTR_TCP]       = ICE_RXDID_COMMS_AUX_TCP,
      68                 :            :                 [PROTO_XTR_IP_OFFSET] = ICE_RXDID_COMMS_AUX_IP_OFFSET,
      69                 :            :         };
      70                 :            : 
      71                 :            :         return xtr_type < RTE_DIM(rxdid_map) ?
      72                 :          0 :                                 rxdid_map[xtr_type] : ICE_RXDID_COMMS_OVS;
      73                 :            : }
      74                 :            : 
      75                 :            : static inline void
      76                 :          0 : ice_rxd_to_pkt_fields_by_comms_generic(__rte_unused struct ice_rx_queue *rxq,
      77                 :            :                                        struct rte_mbuf *mb,
      78                 :            :                                        volatile union ice_rx_flex_desc *rxdp)
      79                 :            : {
      80                 :            :         volatile struct ice_32b_rx_flex_desc_comms *desc =
      81                 :            :                         (volatile struct ice_32b_rx_flex_desc_comms *)rxdp;
      82                 :          0 :         uint16_t stat_err = rte_le_to_cpu_16(desc->status_error0);
      83                 :            : 
      84         [ #  # ]:          0 :         if (likely(stat_err & (1 << ICE_RX_FLEX_DESC_STATUS0_RSS_VALID_S))) {
      85                 :          0 :                 mb->ol_flags |= RTE_MBUF_F_RX_RSS_HASH;
      86                 :          0 :                 mb->hash.rss = rte_le_to_cpu_32(desc->rss_hash);
      87                 :            :         }
      88                 :            : 
      89                 :            : #ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC
      90         [ #  # ]:          0 :         if (desc->flow_id != 0xFFFFFFFF) {
      91                 :          0 :                 mb->ol_flags |= RTE_MBUF_F_RX_FDIR | RTE_MBUF_F_RX_FDIR_ID;
      92                 :          0 :                 mb->hash.fdir.hi = rte_le_to_cpu_32(desc->flow_id);
      93                 :            :         }
      94                 :            : #endif
      95                 :          0 : }
      96                 :            : 
      97                 :            : static inline void
      98                 :          0 : ice_rxd_to_pkt_fields_by_comms_ovs(__rte_unused struct ice_rx_queue *rxq,
      99                 :            :                                    struct rte_mbuf *mb,
     100                 :            :                                    volatile union ice_rx_flex_desc *rxdp)
     101                 :            : {
     102                 :            :         volatile struct ice_32b_rx_flex_desc_comms_ovs *desc =
     103                 :            :                         (volatile struct ice_32b_rx_flex_desc_comms_ovs *)rxdp;
     104                 :            : #ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC
     105                 :            :         uint16_t stat_err;
     106                 :            : #endif
     107                 :            : 
     108         [ #  # ]:          0 :         if (desc->flow_id != 0xFFFFFFFF) {
     109                 :          0 :                 mb->ol_flags |= RTE_MBUF_F_RX_FDIR | RTE_MBUF_F_RX_FDIR_ID;
     110                 :          0 :                 mb->hash.fdir.hi = rte_le_to_cpu_32(desc->flow_id);
     111                 :            :         }
     112                 :            : 
     113                 :            : #ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC
     114                 :          0 :         stat_err = rte_le_to_cpu_16(desc->status_error0);
     115         [ #  # ]:          0 :         if (likely(stat_err & (1 << ICE_RX_FLEX_DESC_STATUS0_RSS_VALID_S))) {
     116                 :          0 :                 mb->ol_flags |= RTE_MBUF_F_RX_RSS_HASH;
     117                 :          0 :                 mb->hash.rss = rte_le_to_cpu_32(desc->rss_hash);
     118                 :            :         }
     119                 :            : #endif
     120                 :          0 : }
     121                 :            : 
     122                 :            : static inline void
     123                 :          0 : ice_rxd_to_pkt_fields_by_comms_aux_v1(struct ice_rx_queue *rxq,
     124                 :            :                                       struct rte_mbuf *mb,
     125                 :            :                                       volatile union ice_rx_flex_desc *rxdp)
     126                 :            : {
     127                 :            :         volatile struct ice_32b_rx_flex_desc_comms *desc =
     128                 :            :                         (volatile struct ice_32b_rx_flex_desc_comms *)rxdp;
     129                 :            :         uint16_t stat_err;
     130                 :            : 
     131                 :          0 :         stat_err = rte_le_to_cpu_16(desc->status_error0);
     132         [ #  # ]:          0 :         if (likely(stat_err & (1 << ICE_RX_FLEX_DESC_STATUS0_RSS_VALID_S))) {
     133                 :          0 :                 mb->ol_flags |= RTE_MBUF_F_RX_RSS_HASH;
     134                 :          0 :                 mb->hash.rss = rte_le_to_cpu_32(desc->rss_hash);
     135                 :            :         }
     136                 :            : 
     137                 :            : #ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC
     138         [ #  # ]:          0 :         if (desc->flow_id != 0xFFFFFFFF) {
     139                 :          0 :                 mb->ol_flags |= RTE_MBUF_F_RX_FDIR | RTE_MBUF_F_RX_FDIR_ID;
     140                 :          0 :                 mb->hash.fdir.hi = rte_le_to_cpu_32(desc->flow_id);
     141                 :            :         }
     142                 :            : 
     143         [ #  # ]:          0 :         if (rxq->xtr_ol_flag) {
     144                 :            :                 uint32_t metadata = 0;
     145                 :            : 
     146                 :          0 :                 stat_err = rte_le_to_cpu_16(desc->status_error1);
     147                 :            : 
     148         [ #  # ]:          0 :                 if (stat_err & (1 << ICE_RX_FLEX_DESC_STATUS1_XTRMD4_VALID_S))
     149                 :          0 :                         metadata = rte_le_to_cpu_16(desc->flex_ts.flex.aux0);
     150                 :            : 
     151         [ #  # ]:          0 :                 if (stat_err & (1 << ICE_RX_FLEX_DESC_STATUS1_XTRMD5_VALID_S))
     152                 :          0 :                         metadata |=
     153                 :          0 :                                 rte_le_to_cpu_16(desc->flex_ts.flex.aux1) << 16;
     154                 :            : 
     155         [ #  # ]:          0 :                 if (metadata) {
     156                 :          0 :                         mb->ol_flags |= rxq->xtr_ol_flag;
     157                 :            : 
     158                 :          0 :                         *ICE_DYNF_PROTO_XTR_METADATA(mb, rxq->xtr_field_offs) = metadata;
     159                 :            :                 }
     160                 :            :         }
     161                 :            : #else
     162                 :            :         RTE_SET_USED(rxq);
     163                 :            : #endif
     164                 :          0 : }
     165                 :            : 
     166                 :            : static inline void
     167                 :          0 : ice_rxd_to_pkt_fields_by_comms_aux_v2(struct ice_rx_queue *rxq,
     168                 :            :                                       struct rte_mbuf *mb,
     169                 :            :                                       volatile union ice_rx_flex_desc *rxdp)
     170                 :            : {
     171                 :            :         volatile struct ice_32b_rx_flex_desc_comms *desc =
     172                 :            :                         (volatile struct ice_32b_rx_flex_desc_comms *)rxdp;
     173                 :            :         uint16_t stat_err;
     174                 :            : 
     175                 :          0 :         stat_err = rte_le_to_cpu_16(desc->status_error0);
     176         [ #  # ]:          0 :         if (likely(stat_err & (1 << ICE_RX_FLEX_DESC_STATUS0_RSS_VALID_S))) {
     177                 :          0 :                 mb->ol_flags |= RTE_MBUF_F_RX_RSS_HASH;
     178                 :          0 :                 mb->hash.rss = rte_le_to_cpu_32(desc->rss_hash);
     179                 :            :         }
     180                 :            : 
     181                 :            : #ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC
     182         [ #  # ]:          0 :         if (desc->flow_id != 0xFFFFFFFF) {
     183                 :          0 :                 mb->ol_flags |= RTE_MBUF_F_RX_FDIR | RTE_MBUF_F_RX_FDIR_ID;
     184                 :          0 :                 mb->hash.fdir.hi = rte_le_to_cpu_32(desc->flow_id);
     185                 :            :         }
     186                 :            : 
     187         [ #  # ]:          0 :         if (rxq->xtr_ol_flag) {
     188                 :            :                 uint32_t metadata = 0;
     189                 :            : 
     190         [ #  # ]:          0 :                 if (desc->flex_ts.flex.aux0 != 0xFFFF)
     191                 :          0 :                         metadata = rte_le_to_cpu_16(desc->flex_ts.flex.aux0);
     192         [ #  # ]:          0 :                 else if (desc->flex_ts.flex.aux1 != 0xFFFF)
     193                 :          0 :                         metadata = rte_le_to_cpu_16(desc->flex_ts.flex.aux1);
     194                 :            : 
     195         [ #  # ]:          0 :                 if (metadata) {
     196                 :          0 :                         mb->ol_flags |= rxq->xtr_ol_flag;
     197                 :            : 
     198                 :          0 :                         *ICE_DYNF_PROTO_XTR_METADATA(mb, rxq->xtr_field_offs) = metadata;
     199                 :            :                 }
     200                 :            :         }
     201                 :            : #else
     202                 :            :         RTE_SET_USED(rxq);
     203                 :            : #endif
     204                 :          0 : }
     205                 :            : 
     206                 :            : static const ice_rxd_to_pkt_fields_t rxd_to_pkt_fields_ops[] = {
     207                 :            :         [ICE_RXDID_COMMS_AUX_VLAN] = ice_rxd_to_pkt_fields_by_comms_aux_v1,
     208                 :            :         [ICE_RXDID_COMMS_AUX_IPV4] = ice_rxd_to_pkt_fields_by_comms_aux_v1,
     209                 :            :         [ICE_RXDID_COMMS_AUX_IPV6] = ice_rxd_to_pkt_fields_by_comms_aux_v1,
     210                 :            :         [ICE_RXDID_COMMS_AUX_IPV6_FLOW] = ice_rxd_to_pkt_fields_by_comms_aux_v1,
     211                 :            :         [ICE_RXDID_COMMS_AUX_TCP] = ice_rxd_to_pkt_fields_by_comms_aux_v1,
     212                 :            :         [ICE_RXDID_COMMS_AUX_IP_OFFSET] = ice_rxd_to_pkt_fields_by_comms_aux_v2,
     213                 :            :         [ICE_RXDID_COMMS_GENERIC] = ice_rxd_to_pkt_fields_by_comms_generic,
     214                 :            :         [ICE_RXDID_COMMS_OVS] = ice_rxd_to_pkt_fields_by_comms_ovs,
     215                 :            : };
     216                 :            : 
     217                 :            : void
     218                 :          0 : ice_select_rxd_to_pkt_fields_handler(struct ice_rx_queue *rxq, uint32_t rxdid)
     219                 :            : {
     220                 :          0 :         rxq->rxdid = rxdid;
     221                 :            : 
     222         [ #  # ]:          0 :         switch (rxdid) {
     223                 :            :         case ICE_RXDID_COMMS_AUX_VLAN:
     224                 :            :         case ICE_RXDID_COMMS_AUX_IPV4:
     225                 :            :         case ICE_RXDID_COMMS_AUX_IPV6:
     226                 :            :         case ICE_RXDID_COMMS_AUX_IPV6_FLOW:
     227                 :            :         case ICE_RXDID_COMMS_AUX_TCP:
     228                 :            :         case ICE_RXDID_COMMS_AUX_IP_OFFSET:
     229                 :            :                 break;
     230                 :            :         case ICE_RXDID_COMMS_GENERIC:
     231                 :            :                 /* fallthrough */
     232                 :            :         case ICE_RXDID_COMMS_OVS:
     233                 :            :                 break;
     234                 :            : 
     235                 :          0 :         default:
     236                 :            :                 /* update this according to the RXDID for PROTO_XTR_NONE */
     237                 :          0 :                 rxq->rxdid = ICE_RXDID_COMMS_OVS;
     238                 :          0 :                 break;
     239                 :            :         }
     240                 :            : 
     241         [ #  # ]:          0 :         if (rxq->xtr_field_offs == -1)
     242                 :          0 :                 rxq->xtr_ol_flag = 0;
     243                 :          0 : }
     244                 :            : 
     245                 :            : static int
     246                 :          0 : ice_program_hw_rx_queue(struct ice_rx_queue *rxq)
     247                 :            : {
     248                 :          0 :         struct ice_vsi *vsi = rxq->vsi;
     249                 :          0 :         struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
     250                 :            :         struct ice_pf *pf = ICE_VSI_TO_PF(vsi);
     251                 :          0 :         struct rte_eth_dev_data *dev_data = rxq->vsi->adapter->pf.dev_data;
     252                 :            :         struct ice_rlan_ctx rx_ctx;
     253                 :            :         uint16_t buf_size;
     254                 :            :         uint32_t rxdid = ICE_RXDID_COMMS_OVS;
     255                 :            :         uint32_t regval;
     256                 :            :         struct ice_adapter *ad = rxq->vsi->adapter;
     257                 :          0 :         uint32_t frame_size = dev_data->mtu + ICE_ETH_OVERHEAD;
     258                 :            :         int err;
     259                 :            : 
     260                 :            :         /* Set buffer size as the head split is disabled. */
     261         [ #  # ]:          0 :         buf_size = (uint16_t)(rte_pktmbuf_data_room_size(rxq->mp) -
     262                 :            :                               RTE_PKTMBUF_HEADROOM);
     263                 :          0 :         rxq->rx_buf_len = RTE_ALIGN_FLOOR(buf_size, (1 << ICE_RLAN_CTX_DBUF_S));
     264                 :          0 :         rxq->rx_buf_len = RTE_MIN(rxq->rx_buf_len, ICE_RX_MAX_DATA_BUF_SIZE);
     265                 :          0 :         rxq->max_pkt_len =
     266                 :          0 :                 RTE_MIN((uint32_t)ICE_SUPPORT_CHAIN_NUM * rxq->rx_buf_len,
     267                 :            :                         frame_size);
     268                 :            : 
     269         [ #  # ]:          0 :         if (rxq->max_pkt_len <= RTE_ETHER_MIN_LEN ||
     270                 :            :             rxq->max_pkt_len > ICE_FRAME_SIZE_MAX) {
     271                 :          0 :                 PMD_DRV_LOG(ERR, "maximum packet length must "
     272                 :            :                             "be larger than %u and smaller than %u",
     273                 :            :                             (uint32_t)RTE_ETHER_MIN_LEN,
     274                 :            :                             (uint32_t)ICE_FRAME_SIZE_MAX);
     275                 :          0 :                 return -EINVAL;
     276                 :            :         }
     277                 :            : 
     278   [ #  #  #  # ]:          0 :         if (rxq->ts_flag == 0 && (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)) {
     279                 :            :                 /* Register mbuf field and flag for Rx timestamp */
     280                 :          0 :                 err = rte_mbuf_dyn_rx_timestamp_register(
     281                 :            :                                 &rxq->ts_offset,
     282                 :            :                                 &rxq->ts_flag);
     283         [ #  # ]:          0 :                 if (err) {
     284                 :          0 :                         PMD_DRV_LOG(ERR,
     285                 :            :                                 "Cannot register mbuf field/flag for timestamp");
     286                 :          0 :                         return -EINVAL;
     287                 :            :                 }
     288                 :            :         }
     289                 :            : 
     290                 :            :         memset(&rx_ctx, 0, sizeof(rx_ctx));
     291                 :            : 
     292         [ #  # ]:          0 :         if (rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) {
     293                 :            :                 uint32_t proto_hdr;
     294                 :          0 :                 proto_hdr = rxq->rxseg[0].proto_hdr;
     295                 :            : 
     296         [ #  # ]:          0 :                 if (proto_hdr == RTE_PTYPE_UNKNOWN) {
     297                 :          0 :                         PMD_DRV_LOG(ERR, "Buffer split protocol must be configured");
     298                 :          0 :                         return -EINVAL;
     299                 :            :                 }
     300                 :            : 
     301      [ #  #  # ]:          0 :                 switch (proto_hdr & RTE_PTYPE_L4_MASK) {
     302                 :          0 :                 case RTE_PTYPE_L4_TCP:
     303                 :            :                 case RTE_PTYPE_L4_UDP:
     304                 :          0 :                         rx_ctx.dtype = ICE_RX_DTYPE_HEADER_SPLIT;
     305                 :          0 :                         rx_ctx.hsplit_0 = ICE_RLAN_RX_HSPLIT_0_SPLIT_TCP_UDP;
     306                 :          0 :                         goto set_hsplit_finish;
     307                 :          0 :                 case RTE_PTYPE_L4_SCTP:
     308                 :          0 :                         rx_ctx.dtype = ICE_RX_DTYPE_HEADER_SPLIT;
     309                 :          0 :                         rx_ctx.hsplit_0 = ICE_RLAN_RX_HSPLIT_0_SPLIT_SCTP;
     310                 :          0 :                         goto set_hsplit_finish;
     311                 :            :                 }
     312                 :            : 
     313         [ #  # ]:          0 :                 switch (proto_hdr & RTE_PTYPE_L3_MASK) {
     314                 :          0 :                 case RTE_PTYPE_L3_IPV4_EXT_UNKNOWN:
     315                 :            :                 case RTE_PTYPE_L3_IPV6_EXT_UNKNOWN:
     316                 :          0 :                         rx_ctx.dtype = ICE_RX_DTYPE_HEADER_SPLIT;
     317                 :          0 :                         rx_ctx.hsplit_0 = ICE_RLAN_RX_HSPLIT_0_SPLIT_IP;
     318                 :          0 :                         goto set_hsplit_finish;
     319                 :            :                 }
     320                 :            : 
     321         [ #  # ]:          0 :                 switch (proto_hdr & RTE_PTYPE_L2_MASK) {
     322                 :          0 :                 case RTE_PTYPE_L2_ETHER:
     323                 :          0 :                         rx_ctx.dtype = ICE_RX_DTYPE_HEADER_SPLIT;
     324                 :          0 :                         rx_ctx.hsplit_0 = ICE_RLAN_RX_HSPLIT_0_SPLIT_L2;
     325                 :          0 :                         rx_ctx.hsplit_1 = ICE_RLAN_RX_HSPLIT_1_SPLIT_L2;
     326                 :          0 :                         goto set_hsplit_finish;
     327                 :            :                 }
     328                 :            : 
     329      [ #  #  # ]:          0 :                 switch (proto_hdr & RTE_PTYPE_INNER_L4_MASK) {
     330                 :          0 :                 case RTE_PTYPE_INNER_L4_TCP:
     331                 :            :                 case RTE_PTYPE_INNER_L4_UDP:
     332                 :          0 :                         rx_ctx.dtype = ICE_RX_DTYPE_HEADER_SPLIT;
     333                 :          0 :                         rx_ctx.hsplit_0 = ICE_RLAN_RX_HSPLIT_0_SPLIT_TCP_UDP;
     334                 :          0 :                         goto set_hsplit_finish;
     335                 :          0 :                 case RTE_PTYPE_INNER_L4_SCTP:
     336                 :          0 :                         rx_ctx.dtype = ICE_RX_DTYPE_HEADER_SPLIT;
     337                 :          0 :                         rx_ctx.hsplit_0 = ICE_RLAN_RX_HSPLIT_0_SPLIT_SCTP;
     338                 :          0 :                         goto set_hsplit_finish;
     339                 :            :                 }
     340                 :            : 
     341         [ #  # ]:          0 :                 switch (proto_hdr & RTE_PTYPE_INNER_L3_MASK) {
     342                 :          0 :                 case RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN:
     343                 :            :                 case RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN:
     344                 :          0 :                         rx_ctx.dtype = ICE_RX_DTYPE_HEADER_SPLIT;
     345                 :          0 :                         rx_ctx.hsplit_0 = ICE_RLAN_RX_HSPLIT_0_SPLIT_IP;
     346                 :          0 :                         goto set_hsplit_finish;
     347                 :            :                 }
     348                 :            : 
     349         [ #  # ]:          0 :                 switch (proto_hdr & RTE_PTYPE_INNER_L2_MASK) {
     350                 :          0 :                 case RTE_PTYPE_INNER_L2_ETHER:
     351                 :          0 :                         rx_ctx.dtype = ICE_RX_DTYPE_HEADER_SPLIT;
     352                 :          0 :                         rx_ctx.hsplit_0 = ICE_RLAN_RX_HSPLIT_0_SPLIT_L2;
     353                 :          0 :                         goto set_hsplit_finish;
     354                 :            :                 }
     355                 :            : 
     356         [ #  # ]:          0 :                 switch (proto_hdr & RTE_PTYPE_TUNNEL_MASK) {
     357                 :          0 :                 case RTE_PTYPE_TUNNEL_GRENAT:
     358                 :          0 :                         rx_ctx.dtype = ICE_RX_DTYPE_HEADER_SPLIT;
     359                 :          0 :                         rx_ctx.hsplit_1 = ICE_RLAN_RX_HSPLIT_1_SPLIT_ALWAYS;
     360                 :          0 :                         goto set_hsplit_finish;
     361                 :            :                 }
     362                 :            : 
     363                 :          0 :                 PMD_DRV_LOG(ERR, "Buffer split protocol is not supported");
     364                 :          0 :                 return -EINVAL;
     365                 :            : 
     366                 :          0 : set_hsplit_finish:
     367                 :          0 :                 rxq->rx_hdr_len = ICE_RX_HDR_BUF_SIZE;
     368                 :            :         } else {
     369                 :          0 :                 rxq->rx_hdr_len = 0;
     370                 :            :                 rx_ctx.dtype = 0; /* No Protocol Based Buffer Split mode */
     371                 :            :         }
     372                 :            : 
     373                 :          0 :         rx_ctx.base = rxq->rx_ring_dma / ICE_QUEUE_BASE_ADDR_UNIT;
     374                 :          0 :         rx_ctx.qlen = rxq->nb_rx_desc;
     375                 :          0 :         rx_ctx.dbuf = rxq->rx_buf_len >> ICE_RLAN_CTX_DBUF_S;
     376                 :          0 :         rx_ctx.hbuf = rxq->rx_hdr_len >> ICE_RLAN_CTX_HBUF_S;
     377                 :            : #ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC
     378                 :          0 :         rx_ctx.dsize = 1; /* 32B descriptors */
     379                 :            : #endif
     380                 :          0 :         rx_ctx.rxmax = rxq->max_pkt_len;
     381                 :            :         /* TPH: Transaction Layer Packet (TLP) processing hints */
     382                 :          0 :         rx_ctx.tphrdesc_ena = 1;
     383                 :          0 :         rx_ctx.tphwdesc_ena = 1;
     384                 :          0 :         rx_ctx.tphdata_ena = 1;
     385                 :          0 :         rx_ctx.tphhead_ena = 1;
     386                 :            :         /* Low Receive Queue Threshold defined in 64 descriptors units.
     387                 :            :          * When the number of free descriptors goes below the lrxqthresh,
     388                 :            :          * an immediate interrupt is triggered.
     389                 :            :          */
     390                 :          0 :         rx_ctx.lrxqthresh = 2;
     391                 :            :         /*default use 32 byte descriptor, vlan tag extract to L2TAG2(1st)*/
     392                 :          0 :         rx_ctx.l2tsel = 1;
     393                 :            :         rx_ctx.showiv = 0;
     394                 :          0 :         rx_ctx.crcstrip = (rxq->crc_len == 0) ? 1 : 0;
     395                 :            : 
     396         [ #  # ]:          0 :         rxdid = ice_proto_xtr_type_to_rxdid(rxq->proto_xtr);
     397                 :            : 
     398                 :          0 :         PMD_DRV_LOG(DEBUG, "Port (%u) - Rx queue (%u) is set with RXDID : %u",
     399                 :            :                     rxq->port_id, rxq->queue_id, rxdid);
     400                 :            : 
     401         [ #  # ]:          0 :         if (!(pf->supported_rxdid & RTE_BIT64(rxdid))) {
     402                 :          0 :                 PMD_DRV_LOG(ERR, "currently package doesn't support RXDID (%u)",
     403                 :            :                             rxdid);
     404                 :          0 :                 return -EINVAL;
     405                 :            :         }
     406                 :            : 
     407                 :          0 :         rxq->rxdid = rxdid;
     408                 :            : 
     409                 :            :         /* Enable Flexible Descriptors in the queue context which
     410                 :            :          * allows this driver to select a specific receive descriptor format
     411                 :            :          */
     412                 :          0 :         regval = (rxdid << QRXFLXP_CNTXT_RXDID_IDX_S) &
     413                 :            :                 QRXFLXP_CNTXT_RXDID_IDX_M;
     414                 :            : 
     415                 :            :         /* increasing context priority to pick up profile ID;
     416                 :            :          * default is 0x01; setting to 0x03 to ensure profile
     417                 :            :          * is programming if prev context is of same priority
     418                 :            :          */
     419                 :          0 :         regval |= (0x03 << QRXFLXP_CNTXT_RXDID_PRIO_S) &
     420                 :            :                 QRXFLXP_CNTXT_RXDID_PRIO_M;
     421                 :            : 
     422   [ #  #  #  # ]:          0 :         if (ad->ptp_ena || rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)
     423                 :          0 :                 regval |= QRXFLXP_CNTXT_TS_M;
     424                 :            : 
     425                 :          0 :         ICE_WRITE_REG(hw, QRXFLXP_CNTXT(rxq->reg_idx), regval);
     426                 :            : 
     427                 :          0 :         err = ice_clear_rxq_ctx(hw, rxq->reg_idx);
     428         [ #  # ]:          0 :         if (err) {
     429                 :          0 :                 PMD_DRV_LOG(ERR, "Failed to clear Lan Rx queue (%u) context",
     430                 :            :                             rxq->queue_id);
     431                 :          0 :                 return -EINVAL;
     432                 :            :         }
     433                 :          0 :         err = ice_write_rxq_ctx(hw, &rx_ctx, rxq->reg_idx);
     434         [ #  # ]:          0 :         if (err) {
     435                 :          0 :                 PMD_DRV_LOG(ERR, "Failed to write Lan Rx queue (%u) context",
     436                 :            :                             rxq->queue_id);
     437                 :          0 :                 return -EINVAL;
     438                 :            :         }
     439                 :            : 
     440                 :            :         /* Check if scattered RX needs to be used. */
     441         [ #  # ]:          0 :         if (frame_size > buf_size)
     442                 :          0 :                 dev_data->scattered_rx = 1;
     443                 :            : 
     444                 :          0 :         rxq->qrx_tail = hw->hw_addr + QRX_TAIL(rxq->reg_idx);
     445                 :            : 
     446                 :            :         /* Init the Rx tail register*/
     447                 :          0 :         ICE_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
     448                 :            : 
     449                 :          0 :         return 0;
     450                 :            : }
     451                 :            : 
     452                 :            : /* Allocate mbufs for all descriptors in rx queue */
     453                 :            : static int
     454                 :          0 : ice_alloc_rx_queue_mbufs(struct ice_rx_queue *rxq)
     455                 :            : {
     456                 :          0 :         struct ice_rx_entry *rxe = rxq->sw_ring;
     457                 :            :         uint64_t dma_addr;
     458                 :            :         uint16_t i;
     459                 :            : 
     460         [ #  # ]:          0 :         for (i = 0; i < rxq->nb_rx_desc; i++) {
     461                 :            :                 volatile union ice_rx_flex_desc *rxd;
     462                 :          0 :                 rxd = &rxq->rx_ring[i];
     463                 :          0 :                 struct rte_mbuf *mbuf = rte_mbuf_raw_alloc(rxq->mp);
     464                 :            : 
     465         [ #  # ]:          0 :                 if (unlikely(!mbuf)) {
     466                 :          0 :                         PMD_DRV_LOG(ERR, "Failed to allocate mbuf for RX");
     467                 :          0 :                         return -ENOMEM;
     468                 :            :                 }
     469                 :            : 
     470                 :          0 :                 mbuf->data_off = RTE_PKTMBUF_HEADROOM;
     471                 :          0 :                 mbuf->nb_segs = 1;
     472         [ #  # ]:          0 :                 mbuf->port = rxq->port_id;
     473                 :            : 
     474                 :            :                 dma_addr =
     475                 :            :                         rte_cpu_to_le_64(rte_mbuf_data_iova_default(mbuf));
     476                 :            : 
     477         [ #  # ]:          0 :                 if (!(rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)) {
     478                 :            :                         rte_mbuf_refcnt_set(mbuf, 1);
     479                 :          0 :                         mbuf->next = NULL;
     480                 :          0 :                         rxd->read.hdr_addr = 0;
     481                 :          0 :                         rxd->read.pkt_addr = dma_addr;
     482                 :            :                 } else {
     483                 :            :                         struct rte_mbuf *mbuf_pay;
     484                 :          0 :                         mbuf_pay = rte_mbuf_raw_alloc(rxq->rxseg[1].mp);
     485         [ #  # ]:          0 :                         if (unlikely(!mbuf_pay)) {
     486                 :          0 :                                 rte_pktmbuf_free(mbuf);
     487                 :          0 :                                 PMD_DRV_LOG(ERR, "Failed to allocate payload mbuf for RX");
     488                 :          0 :                                 return -ENOMEM;
     489                 :            :                         }
     490                 :            : 
     491                 :          0 :                         mbuf_pay->next = NULL;
     492                 :          0 :                         mbuf_pay->data_off = RTE_PKTMBUF_HEADROOM;
     493                 :          0 :                         mbuf_pay->nb_segs = 1;
     494                 :          0 :                         mbuf_pay->port = rxq->port_id;
     495                 :          0 :                         mbuf->next = mbuf_pay;
     496                 :            : 
     497                 :          0 :                         rxd->read.hdr_addr = dma_addr;
     498                 :            :                         /* The LS bit should be set to zero regardless of
     499                 :            :                          * buffer split enablement.
     500                 :            :                          */
     501                 :          0 :                         rxd->read.pkt_addr = rte_cpu_to_le_64(rte_mbuf_data_iova_default(mbuf_pay));
     502                 :            :                 }
     503                 :            : 
     504                 :            : #ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC
     505                 :          0 :                 rxd->read.rsvd1 = 0;
     506                 :          0 :                 rxd->read.rsvd2 = 0;
     507                 :            : #endif
     508                 :          0 :                 rxe[i].mbuf = mbuf;
     509                 :            :         }
     510                 :            : 
     511                 :            :         return 0;
     512                 :            : }
     513                 :            : 
     514                 :            : /* Free all mbufs for descriptors in rx queue */
     515                 :            : static void
     516                 :          0 : _ice_rx_queue_release_mbufs(struct ice_rx_queue *rxq)
     517                 :            : {
     518                 :            :         uint16_t i;
     519                 :            : 
     520   [ #  #  #  # ]:          0 :         if (!rxq || !rxq->sw_ring) {
     521                 :          0 :                 PMD_DRV_LOG(DEBUG, "Pointer to sw_ring is NULL");
     522                 :          0 :                 return;
     523                 :            :         }
     524                 :            : 
     525         [ #  # ]:          0 :         for (i = 0; i < rxq->nb_rx_desc; i++) {
     526         [ #  # ]:          0 :                 if (rxq->sw_ring[i].mbuf) {
     527                 :          0 :                         rte_pktmbuf_free(rxq->sw_ring[i].mbuf);
     528                 :          0 :                         rxq->sw_ring[i].mbuf = NULL;
     529                 :            :                 }
     530                 :            :         }
     531         [ #  # ]:          0 :         if (rxq->rx_nb_avail == 0)
     532                 :            :                 return;
     533         [ #  # ]:          0 :         for (i = 0; i < rxq->rx_nb_avail; i++)
     534                 :          0 :                 rte_pktmbuf_free(rxq->rx_stage[rxq->rx_next_avail + i]);
     535                 :            : 
     536                 :          0 :         rxq->rx_nb_avail = 0;
     537                 :            : }
     538                 :            : 
     539                 :            : /* turn on or off rx queue
     540                 :            :  * @q_idx: queue index in pf scope
     541                 :            :  * @on: turn on or off the queue
     542                 :            :  */
     543                 :            : static int
     544                 :          0 : ice_switch_rx_queue(struct ice_hw *hw, uint16_t q_idx, bool on)
     545                 :            : {
     546                 :            :         uint32_t reg;
     547                 :            :         uint16_t j;
     548                 :            : 
     549                 :            :         /* QRX_CTRL = QRX_ENA */
     550                 :          0 :         reg = ICE_READ_REG(hw, QRX_CTRL(q_idx));
     551                 :            : 
     552         [ #  # ]:          0 :         if (on) {
     553         [ #  # ]:          0 :                 if (reg & QRX_CTRL_QENA_STAT_M)
     554                 :            :                         return 0; /* Already on, skip */
     555                 :          0 :                 reg |= QRX_CTRL_QENA_REQ_M;
     556                 :            :         } else {
     557         [ #  # ]:          0 :                 if (!(reg & QRX_CTRL_QENA_STAT_M))
     558                 :            :                         return 0; /* Already off, skip */
     559                 :          0 :                 reg &= ~QRX_CTRL_QENA_REQ_M;
     560                 :            :         }
     561                 :            : 
     562                 :            :         /* Write the register */
     563                 :          0 :         ICE_WRITE_REG(hw, QRX_CTRL(q_idx), reg);
     564                 :            :         /* Check the result. It is said that QENA_STAT
     565                 :            :          * follows the QENA_REQ not more than 10 use.
     566                 :            :          * TODO: need to change the wait counter later
     567                 :            :          */
     568         [ #  # ]:          0 :         for (j = 0; j < ICE_CHK_Q_ENA_COUNT; j++) {
     569                 :          0 :                 rte_delay_us(ICE_CHK_Q_ENA_INTERVAL_US);
     570                 :          0 :                 reg = ICE_READ_REG(hw, QRX_CTRL(q_idx));
     571         [ #  # ]:          0 :                 if (on) {
     572         [ #  # ]:          0 :                         if ((reg & QRX_CTRL_QENA_REQ_M) &&
     573                 :            :                             (reg & QRX_CTRL_QENA_STAT_M))
     574                 :            :                                 break;
     575                 :            :                 } else {
     576         [ #  # ]:          0 :                         if (!(reg & QRX_CTRL_QENA_REQ_M) &&
     577                 :            :                             !(reg & QRX_CTRL_QENA_STAT_M))
     578                 :            :                                 break;
     579                 :            :                 }
     580                 :            :         }
     581                 :            : 
     582                 :            :         /* Check if it is timeout */
     583         [ #  # ]:          0 :         if (j >= ICE_CHK_Q_ENA_COUNT) {
     584         [ #  # ]:          0 :                 PMD_DRV_LOG(ERR, "Failed to %s rx queue[%u]",
     585                 :            :                             (on ? "enable" : "disable"), q_idx);
     586                 :          0 :                 return -ETIMEDOUT;
     587                 :            :         }
     588                 :            : 
     589                 :            :         return 0;
     590                 :            : }
     591                 :            : 
     592                 :            : static inline int
     593                 :          0 : ice_check_rx_burst_bulk_alloc_preconditions(struct ice_rx_queue *rxq)
     594                 :            : {
     595                 :            :         int ret = 0;
     596                 :            : 
     597         [ #  # ]:          0 :         if (!(rxq->rx_free_thresh >= ICE_RX_MAX_BURST)) {
     598                 :          0 :                 PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions: "
     599                 :            :                              "rxq->rx_free_thresh=%d, "
     600                 :            :                              "ICE_RX_MAX_BURST=%d",
     601                 :            :                              rxq->rx_free_thresh, ICE_RX_MAX_BURST);
     602                 :            :                 ret = -EINVAL;
     603         [ #  # ]:          0 :         } else if (!(rxq->rx_free_thresh < rxq->nb_rx_desc)) {
     604                 :          0 :                 PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions: "
     605                 :            :                              "rxq->rx_free_thresh=%d, "
     606                 :            :                              "rxq->nb_rx_desc=%d",
     607                 :            :                              rxq->rx_free_thresh, rxq->nb_rx_desc);
     608                 :            :                 ret = -EINVAL;
     609         [ #  # ]:          0 :         } else if (rxq->nb_rx_desc % rxq->rx_free_thresh != 0) {
     610                 :          0 :                 PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions: "
     611                 :            :                              "rxq->nb_rx_desc=%d, "
     612                 :            :                              "rxq->rx_free_thresh=%d",
     613                 :            :                              rxq->nb_rx_desc, rxq->rx_free_thresh);
     614                 :            :                 ret = -EINVAL;
     615                 :            :         }
     616                 :            : 
     617                 :          0 :         return ret;
     618                 :            : }
     619                 :            : 
     620                 :            : /* reset fields in ice_rx_queue back to default */
     621                 :            : static void
     622                 :          0 : ice_reset_rx_queue(struct ice_rx_queue *rxq)
     623                 :            : {
     624                 :            :         unsigned int i;
     625                 :            :         uint16_t len;
     626                 :            : 
     627         [ #  # ]:          0 :         if (!rxq) {
     628                 :          0 :                 PMD_DRV_LOG(DEBUG, "Pointer to rxq is NULL");
     629                 :          0 :                 return;
     630                 :            :         }
     631                 :            : 
     632                 :          0 :         len = (uint16_t)(rxq->nb_rx_desc + ICE_RX_MAX_BURST);
     633                 :            : 
     634         [ #  # ]:          0 :         for (i = 0; i < len * sizeof(union ice_rx_flex_desc); i++)
     635                 :          0 :                 ((volatile char *)rxq->rx_ring)[i] = 0;
     636                 :            : 
     637                 :          0 :         memset(&rxq->fake_mbuf, 0x0, sizeof(rxq->fake_mbuf));
     638         [ #  # ]:          0 :         for (i = 0; i < ICE_RX_MAX_BURST; ++i)
     639                 :          0 :                 rxq->sw_ring[rxq->nb_rx_desc + i].mbuf = &rxq->fake_mbuf;
     640                 :            : 
     641                 :          0 :         rxq->rx_nb_avail = 0;
     642                 :          0 :         rxq->rx_next_avail = 0;
     643                 :          0 :         rxq->rx_free_trigger = (uint16_t)(rxq->rx_free_thresh - 1);
     644                 :            : 
     645                 :          0 :         rxq->rx_tail = 0;
     646                 :          0 :         rxq->nb_rx_hold = 0;
     647                 :          0 :         rxq->pkt_first_seg = NULL;
     648                 :          0 :         rxq->pkt_last_seg = NULL;
     649                 :            : 
     650                 :          0 :         rxq->rxrearm_start = 0;
     651                 :          0 :         rxq->rxrearm_nb = 0;
     652                 :            : }
     653                 :            : 
     654                 :            : int
     655                 :          0 : ice_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
     656                 :            : {
     657                 :            :         struct ice_rx_queue *rxq;
     658                 :            :         int err;
     659                 :          0 :         struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
     660                 :            : 
     661                 :          0 :         PMD_INIT_FUNC_TRACE();
     662                 :            : 
     663         [ #  # ]:          0 :         if (rx_queue_id >= dev->data->nb_rx_queues) {
     664                 :          0 :                 PMD_DRV_LOG(ERR, "RX queue %u is out of range %u",
     665                 :            :                             rx_queue_id, dev->data->nb_rx_queues);
     666                 :          0 :                 return -EINVAL;
     667                 :            :         }
     668                 :            : 
     669                 :          0 :         rxq = dev->data->rx_queues[rx_queue_id];
     670   [ #  #  #  # ]:          0 :         if (!rxq || !rxq->q_set) {
     671                 :          0 :                 PMD_DRV_LOG(ERR, "RX queue %u not available or setup",
     672                 :            :                             rx_queue_id);
     673                 :          0 :                 return -EINVAL;
     674                 :            :         }
     675                 :            : 
     676         [ #  # ]:          0 :         if (dev->data->rx_queue_state[rx_queue_id] ==
     677                 :            :                 RTE_ETH_QUEUE_STATE_STARTED)
     678                 :            :                 return 0;
     679                 :            : 
     680         [ #  # ]:          0 :         if (dev->data->dev_conf.rxmode.offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)
     681                 :          0 :                 rxq->offloads |= RTE_ETH_RX_OFFLOAD_TIMESTAMP;
     682                 :          0 :         err = ice_program_hw_rx_queue(rxq);
     683         [ #  # ]:          0 :         if (err) {
     684                 :          0 :                 PMD_DRV_LOG(ERR, "fail to program RX queue %u",
     685                 :            :                             rx_queue_id);
     686                 :          0 :                 return -EIO;
     687                 :            :         }
     688                 :            : 
     689                 :          0 :         err = ice_alloc_rx_queue_mbufs(rxq);
     690         [ #  # ]:          0 :         if (err) {
     691                 :          0 :                 PMD_DRV_LOG(ERR, "Failed to allocate RX queue mbuf");
     692                 :          0 :                 return -ENOMEM;
     693                 :            :         }
     694                 :            : 
     695                 :            :         /* Init the RX tail register. */
     696                 :          0 :         ICE_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
     697                 :            : 
     698                 :          0 :         err = ice_switch_rx_queue(hw, rxq->reg_idx, true);
     699         [ #  # ]:          0 :         if (err) {
     700                 :          0 :                 PMD_DRV_LOG(ERR, "Failed to switch RX queue %u on",
     701                 :            :                             rx_queue_id);
     702                 :            : 
     703                 :          0 :                 rxq->rx_rel_mbufs(rxq);
     704                 :          0 :                 ice_reset_rx_queue(rxq);
     705                 :          0 :                 return -EINVAL;
     706                 :            :         }
     707                 :            : 
     708                 :          0 :         dev->data->rx_queue_state[rx_queue_id] =
     709                 :            :                 RTE_ETH_QUEUE_STATE_STARTED;
     710                 :            : 
     711                 :          0 :         return 0;
     712                 :            : }
     713                 :            : 
     714                 :            : int
     715                 :          0 : ice_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
     716                 :            : {
     717                 :            :         struct ice_rx_queue *rxq;
     718                 :            :         int err;
     719                 :          0 :         struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
     720                 :            : 
     721         [ #  # ]:          0 :         if (rx_queue_id < dev->data->nb_rx_queues) {
     722                 :          0 :                 rxq = dev->data->rx_queues[rx_queue_id];
     723                 :            : 
     724         [ #  # ]:          0 :                 if (dev->data->rx_queue_state[rx_queue_id] ==
     725                 :            :                         RTE_ETH_QUEUE_STATE_STOPPED)
     726                 :            :                         return 0;
     727                 :            : 
     728                 :          0 :                 err = ice_switch_rx_queue(hw, rxq->reg_idx, false);
     729         [ #  # ]:          0 :                 if (err) {
     730                 :          0 :                         PMD_DRV_LOG(ERR, "Failed to switch RX queue %u off",
     731                 :            :                                     rx_queue_id);
     732                 :          0 :                         return -EINVAL;
     733                 :            :                 }
     734                 :          0 :                 rxq->rx_rel_mbufs(rxq);
     735                 :          0 :                 ice_reset_rx_queue(rxq);
     736                 :          0 :                 dev->data->rx_queue_state[rx_queue_id] =
     737                 :            :                         RTE_ETH_QUEUE_STATE_STOPPED;
     738                 :            :         }
     739                 :            : 
     740                 :            :         return 0;
     741                 :            : }
     742                 :            : 
     743                 :            : int
     744                 :          0 : ice_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
     745                 :            : {
     746                 :            :         struct ci_tx_queue *txq;
     747                 :            :         int err;
     748                 :            :         struct ice_vsi *vsi;
     749                 :            :         struct ice_hw *hw;
     750                 :            :         struct ice_pf *pf;
     751                 :            :         struct ice_aqc_add_tx_qgrp *txq_elem;
     752                 :            :         struct ice_tlan_ctx tx_ctx;
     753                 :            :         int buf_len;
     754                 :          0 :         struct ice_adapter *ad = ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
     755                 :            : 
     756                 :          0 :         PMD_INIT_FUNC_TRACE();
     757                 :            : 
     758         [ #  # ]:          0 :         if (tx_queue_id >= dev->data->nb_tx_queues) {
     759                 :          0 :                 PMD_DRV_LOG(ERR, "TX queue %u is out of range %u",
     760                 :            :                             tx_queue_id, dev->data->nb_tx_queues);
     761                 :          0 :                 return -EINVAL;
     762                 :            :         }
     763                 :            : 
     764                 :          0 :         txq = dev->data->tx_queues[tx_queue_id];
     765   [ #  #  #  # ]:          0 :         if (!txq || !txq->q_set) {
     766                 :          0 :                 PMD_DRV_LOG(ERR, "TX queue %u is not available or setup",
     767                 :            :                             tx_queue_id);
     768                 :          0 :                 return -EINVAL;
     769                 :            :         }
     770                 :            : 
     771         [ #  # ]:          0 :         if (dev->data->tx_queue_state[tx_queue_id] ==
     772                 :            :                 RTE_ETH_QUEUE_STATE_STARTED)
     773                 :            :                 return 0;
     774                 :            : 
     775                 :            :         buf_len = ice_struct_size(txq_elem, txqs, 1);
     776                 :          0 :         txq_elem = ice_malloc(hw, buf_len);
     777         [ #  # ]:          0 :         if (!txq_elem)
     778                 :            :                 return -ENOMEM;
     779                 :            : 
     780                 :          0 :         vsi = txq->ice_vsi;
     781                 :          0 :         hw = ICE_VSI_TO_HW(vsi);
     782                 :          0 :         pf = ICE_VSI_TO_PF(vsi);
     783                 :            : 
     784                 :            :         memset(&tx_ctx, 0, sizeof(tx_ctx));
     785                 :          0 :         txq_elem->num_txqs = 1;
     786                 :          0 :         txq_elem->txqs[0].txq_id = rte_cpu_to_le_16(txq->reg_idx);
     787                 :            : 
     788                 :          0 :         tx_ctx.base = txq->tx_ring_dma / ICE_QUEUE_BASE_ADDR_UNIT;
     789                 :          0 :         tx_ctx.qlen = txq->nb_tx_desc;
     790                 :          0 :         tx_ctx.pf_num = hw->pf_id;
     791                 :          0 :         tx_ctx.vmvf_type = ICE_TLAN_CTX_VMVF_TYPE_PF;
     792                 :          0 :         tx_ctx.src_vsi = vsi->vsi_id;
     793                 :          0 :         tx_ctx.port_num = hw->port_info->lport;
     794                 :          0 :         tx_ctx.tso_ena = 1; /* tso enable */
     795                 :          0 :         tx_ctx.tso_qnum = txq->reg_idx; /* index for tso state structure */
     796                 :          0 :         tx_ctx.legacy_int = 1; /* Legacy or Advanced Host Interface */
     797                 :          0 :         tx_ctx.tsyn_ena = 1;
     798                 :            : 
     799                 :          0 :         ice_set_ctx(hw, (uint8_t *)&tx_ctx, txq_elem->txqs[0].txq_ctx,
     800                 :            :                     ice_tlan_ctx_info);
     801                 :            : 
     802                 :          0 :         txq->qtx_tail = hw->hw_addr + QTX_COMM_DBELL(txq->reg_idx);
     803                 :            : 
     804                 :            :         /* Init the Tx tail register*/
     805                 :            :         ICE_PCI_REG_WRITE(txq->qtx_tail, 0);
     806                 :            : 
     807                 :            :         /* Fix me, we assume TC always 0 here */
     808                 :          0 :         err = ice_ena_vsi_txq(hw->port_info, vsi->idx, 0, tx_queue_id, 1,
     809                 :            :                         txq_elem, buf_len, NULL);
     810         [ #  # ]:          0 :         if (err) {
     811                 :          0 :                 PMD_DRV_LOG(ERR, "Failed to add lan txq");
     812                 :          0 :                 rte_free(txq_elem);
     813                 :          0 :                 return -EIO;
     814                 :            :         }
     815                 :            :         /* store the schedule node id */
     816                 :          0 :         txq->q_teid = txq_elem->txqs[0].q_teid;
     817                 :            : 
     818                 :            :         /* move the queue to correct position in hierarchy, if explicit hierarchy configured */
     819         [ #  # ]:          0 :         if (pf->tm_conf.committed)
     820         [ #  # ]:          0 :                 if (ice_tm_setup_txq_node(pf, hw, tx_queue_id, txq->q_teid) != 0) {
     821                 :          0 :                         PMD_DRV_LOG(ERR, "Failed to set up txq traffic management node");
     822                 :          0 :                         rte_free(txq_elem);
     823                 :          0 :                         return -EIO;
     824                 :            :                 }
     825                 :            : 
     826                 :            :         /* record what kind of descriptor cleanup we need on teardown */
     827                 :          0 :         txq->vector_tx = ad->tx_vec_allowed;
     828                 :            : 
     829                 :          0 :         dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
     830                 :            : 
     831                 :          0 :         rte_free(txq_elem);
     832                 :          0 :         return 0;
     833                 :            : }
     834                 :            : 
     835                 :            : static int
     836                 :          0 : ice_fdir_program_hw_rx_queue(struct ice_rx_queue *rxq)
     837                 :            : {
     838                 :          0 :         struct ice_vsi *vsi = rxq->vsi;
     839                 :          0 :         struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
     840                 :            :         uint32_t rxdid = ICE_RXDID_LEGACY_1;
     841                 :            :         struct ice_rlan_ctx rx_ctx;
     842                 :            :         uint32_t regval;
     843                 :            :         int err;
     844                 :            : 
     845                 :          0 :         rxq->rx_hdr_len = 0;
     846                 :          0 :         rxq->rx_buf_len = 1024;
     847                 :            : 
     848                 :            :         memset(&rx_ctx, 0, sizeof(rx_ctx));
     849                 :            : 
     850                 :          0 :         rx_ctx.base = rxq->rx_ring_dma / ICE_QUEUE_BASE_ADDR_UNIT;
     851                 :          0 :         rx_ctx.qlen = rxq->nb_rx_desc;
     852                 :          0 :         rx_ctx.dbuf = rxq->rx_buf_len >> ICE_RLAN_CTX_DBUF_S;
     853                 :            :         rx_ctx.hbuf = rxq->rx_hdr_len >> ICE_RLAN_CTX_HBUF_S;
     854                 :            :         rx_ctx.dtype = 0; /* No Buffer Split mode */
     855                 :          0 :         rx_ctx.dsize = 1; /* 32B descriptors */
     856                 :          0 :         rx_ctx.rxmax = ICE_ETH_MAX_LEN;
     857                 :            :         /* TPH: Transaction Layer Packet (TLP) processing hints */
     858                 :          0 :         rx_ctx.tphrdesc_ena = 1;
     859                 :          0 :         rx_ctx.tphwdesc_ena = 1;
     860                 :          0 :         rx_ctx.tphdata_ena = 1;
     861                 :          0 :         rx_ctx.tphhead_ena = 1;
     862                 :            :         /* Low Receive Queue Threshold defined in 64 descriptors units.
     863                 :            :          * When the number of free descriptors goes below the lrxqthresh,
     864                 :            :          * an immediate interrupt is triggered.
     865                 :            :          */
     866                 :          0 :         rx_ctx.lrxqthresh = 2;
     867                 :            :         /*default use 32 byte descriptor, vlan tag extract to L2TAG2(1st)*/
     868                 :          0 :         rx_ctx.l2tsel = 1;
     869                 :            :         rx_ctx.showiv = 0;
     870                 :          0 :         rx_ctx.crcstrip = (rxq->crc_len == 0) ? 1 : 0;
     871                 :            : 
     872                 :            :         /* Enable Flexible Descriptors in the queue context which
     873                 :            :          * allows this driver to select a specific receive descriptor format
     874                 :            :          */
     875                 :            :         regval = (rxdid << QRXFLXP_CNTXT_RXDID_IDX_S) &
     876                 :            :                 QRXFLXP_CNTXT_RXDID_IDX_M;
     877                 :            : 
     878                 :            :         /* increasing context priority to pick up profile ID;
     879                 :            :          * default is 0x01; setting to 0x03 to ensure profile
     880                 :            :          * is programming if prev context is of same priority
     881                 :            :          */
     882                 :            :         regval |= (0x03 << QRXFLXP_CNTXT_RXDID_PRIO_S) &
     883                 :            :                 QRXFLXP_CNTXT_RXDID_PRIO_M;
     884                 :            : 
     885                 :          0 :         ICE_WRITE_REG(hw, QRXFLXP_CNTXT(rxq->reg_idx), regval);
     886                 :            : 
     887                 :          0 :         err = ice_clear_rxq_ctx(hw, rxq->reg_idx);
     888         [ #  # ]:          0 :         if (err) {
     889                 :          0 :                 PMD_DRV_LOG(ERR, "Failed to clear Lan Rx queue (%u) context",
     890                 :            :                             rxq->queue_id);
     891                 :          0 :                 return -EINVAL;
     892                 :            :         }
     893                 :          0 :         err = ice_write_rxq_ctx(hw, &rx_ctx, rxq->reg_idx);
     894         [ #  # ]:          0 :         if (err) {
     895                 :          0 :                 PMD_DRV_LOG(ERR, "Failed to write Lan Rx queue (%u) context",
     896                 :            :                             rxq->queue_id);
     897                 :          0 :                 return -EINVAL;
     898                 :            :         }
     899                 :            : 
     900                 :          0 :         rxq->qrx_tail = hw->hw_addr + QRX_TAIL(rxq->reg_idx);
     901                 :            : 
     902                 :            :         /* Init the Rx tail register*/
     903                 :          0 :         ICE_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
     904                 :            : 
     905                 :          0 :         return 0;
     906                 :            : }
     907                 :            : 
     908                 :            : int
     909                 :          0 : ice_fdir_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
     910                 :            : {
     911                 :            :         struct ice_rx_queue *rxq;
     912                 :            :         int err;
     913                 :          0 :         struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
     914                 :            :         struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
     915                 :            : 
     916                 :          0 :         PMD_INIT_FUNC_TRACE();
     917                 :            : 
     918                 :          0 :         rxq = pf->fdir.rxq;
     919   [ #  #  #  # ]:          0 :         if (!rxq || !rxq->q_set) {
     920                 :          0 :                 PMD_DRV_LOG(ERR, "FDIR RX queue %u not available or setup",
     921                 :            :                             rx_queue_id);
     922                 :          0 :                 return -EINVAL;
     923                 :            :         }
     924                 :            : 
     925                 :          0 :         err = ice_fdir_program_hw_rx_queue(rxq);
     926         [ #  # ]:          0 :         if (err) {
     927                 :          0 :                 PMD_DRV_LOG(ERR, "fail to program FDIR RX queue %u",
     928                 :            :                             rx_queue_id);
     929                 :          0 :                 return -EIO;
     930                 :            :         }
     931                 :            : 
     932                 :            :         /* Init the RX tail register. */
     933                 :          0 :         ICE_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
     934                 :            : 
     935                 :          0 :         err = ice_switch_rx_queue(hw, rxq->reg_idx, true);
     936         [ #  # ]:          0 :         if (err) {
     937                 :          0 :                 PMD_DRV_LOG(ERR, "Failed to switch FDIR RX queue %u on",
     938                 :            :                             rx_queue_id);
     939                 :            : 
     940                 :          0 :                 ice_reset_rx_queue(rxq);
     941                 :          0 :                 return -EINVAL;
     942                 :            :         }
     943                 :            : 
     944                 :            :         return 0;
     945                 :            : }
     946                 :            : 
     947                 :            : int
     948                 :          0 : ice_fdir_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
     949                 :            : {
     950                 :          0 :         struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
     951                 :            :         struct ci_tx_queue *txq;
     952                 :            :         int err;
     953                 :            :         struct ice_vsi *vsi;
     954                 :            :         struct ice_hw *hw;
     955                 :            :         struct ice_aqc_add_tx_qgrp *txq_elem;
     956                 :            :         struct ice_tlan_ctx tx_ctx;
     957                 :            :         int buf_len;
     958                 :            : 
     959                 :          0 :         PMD_INIT_FUNC_TRACE();
     960                 :            : 
     961                 :          0 :         txq = pf->fdir.txq;
     962   [ #  #  #  # ]:          0 :         if (!txq || !txq->q_set) {
     963                 :          0 :                 PMD_DRV_LOG(ERR, "FDIR TX queue %u is not available or setup",
     964                 :            :                             tx_queue_id);
     965                 :          0 :                 return -EINVAL;
     966                 :            :         }
     967                 :            : 
     968                 :            :         buf_len = ice_struct_size(txq_elem, txqs, 1);
     969                 :          0 :         txq_elem = ice_malloc(hw, buf_len);
     970         [ #  # ]:          0 :         if (!txq_elem)
     971                 :            :                 return -ENOMEM;
     972                 :            : 
     973                 :          0 :         vsi = txq->ice_vsi;
     974                 :          0 :         hw = ICE_VSI_TO_HW(vsi);
     975                 :            : 
     976                 :            :         memset(&tx_ctx, 0, sizeof(tx_ctx));
     977                 :          0 :         txq_elem->num_txqs = 1;
     978                 :          0 :         txq_elem->txqs[0].txq_id = rte_cpu_to_le_16(txq->reg_idx);
     979                 :            : 
     980                 :          0 :         tx_ctx.base = txq->tx_ring_dma / ICE_QUEUE_BASE_ADDR_UNIT;
     981                 :          0 :         tx_ctx.qlen = txq->nb_tx_desc;
     982                 :          0 :         tx_ctx.pf_num = hw->pf_id;
     983                 :          0 :         tx_ctx.vmvf_type = ICE_TLAN_CTX_VMVF_TYPE_PF;
     984                 :          0 :         tx_ctx.src_vsi = vsi->vsi_id;
     985                 :          0 :         tx_ctx.port_num = hw->port_info->lport;
     986                 :          0 :         tx_ctx.tso_ena = 1; /* tso enable */
     987                 :          0 :         tx_ctx.tso_qnum = txq->reg_idx; /* index for tso state structure */
     988                 :          0 :         tx_ctx.legacy_int = 1; /* Legacy or Advanced Host Interface */
     989                 :            : 
     990                 :          0 :         ice_set_ctx(hw, (uint8_t *)&tx_ctx, txq_elem->txqs[0].txq_ctx,
     991                 :            :                     ice_tlan_ctx_info);
     992                 :            : 
     993                 :          0 :         txq->qtx_tail = hw->hw_addr + QTX_COMM_DBELL(txq->reg_idx);
     994                 :            : 
     995                 :            :         /* Init the Tx tail register*/
     996                 :            :         ICE_PCI_REG_WRITE(txq->qtx_tail, 0);
     997                 :            : 
     998                 :            :         /* Fix me, we assume TC always 0 here */
     999                 :          0 :         err = ice_ena_vsi_txq(hw->port_info, vsi->idx, 0, tx_queue_id, 1,
    1000                 :            :                               txq_elem, buf_len, NULL);
    1001         [ #  # ]:          0 :         if (err) {
    1002                 :          0 :                 PMD_DRV_LOG(ERR, "Failed to add FDIR txq");
    1003                 :          0 :                 rte_free(txq_elem);
    1004                 :          0 :                 return -EIO;
    1005                 :            :         }
    1006                 :            :         /* store the schedule node id */
    1007                 :          0 :         txq->q_teid = txq_elem->txqs[0].q_teid;
    1008                 :            : 
    1009                 :          0 :         rte_free(txq_elem);
    1010                 :          0 :         return 0;
    1011                 :            : }
    1012                 :            : 
    1013                 :            : static void
    1014                 :          0 : ice_reset_tx_queue(struct ci_tx_queue *txq)
    1015                 :            : {
    1016                 :            :         struct ci_tx_entry *txe;
    1017                 :            :         uint16_t i, prev, size;
    1018                 :            : 
    1019         [ #  # ]:          0 :         if (!txq) {
    1020                 :          0 :                 PMD_DRV_LOG(DEBUG, "Pointer to txq is NULL");
    1021                 :          0 :                 return;
    1022                 :            :         }
    1023                 :            : 
    1024                 :          0 :         txe = txq->sw_ring;
    1025                 :          0 :         size = sizeof(struct ice_tx_desc) * txq->nb_tx_desc;
    1026         [ #  # ]:          0 :         for (i = 0; i < size; i++)
    1027                 :          0 :                 ((volatile char *)txq->ice_tx_ring)[i] = 0;
    1028                 :            : 
    1029                 :          0 :         prev = (uint16_t)(txq->nb_tx_desc - 1);
    1030         [ #  # ]:          0 :         for (i = 0; i < txq->nb_tx_desc; i++) {
    1031                 :          0 :                 volatile struct ice_tx_desc *txd = &txq->ice_tx_ring[i];
    1032                 :            : 
    1033                 :          0 :                 txd->cmd_type_offset_bsz =
    1034                 :            :                         rte_cpu_to_le_64(ICE_TX_DESC_DTYPE_DESC_DONE);
    1035                 :          0 :                 txe[i].mbuf =  NULL;
    1036                 :          0 :                 txe[i].last_id = i;
    1037                 :          0 :                 txe[prev].next_id = i;
    1038                 :            :                 prev = i;
    1039                 :            :         }
    1040                 :            : 
    1041                 :          0 :         txq->tx_next_dd = (uint16_t)(txq->tx_rs_thresh - 1);
    1042                 :          0 :         txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1);
    1043                 :            : 
    1044                 :          0 :         txq->tx_tail = 0;
    1045                 :          0 :         txq->nb_tx_used = 0;
    1046                 :            : 
    1047                 :          0 :         txq->last_desc_cleaned = (uint16_t)(txq->nb_tx_desc - 1);
    1048                 :          0 :         txq->nb_tx_free = (uint16_t)(txq->nb_tx_desc - 1);
    1049                 :            : }
    1050                 :            : 
    1051                 :            : int
    1052                 :          0 : ice_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
    1053                 :            : {
    1054                 :            :         struct ci_tx_queue *txq;
    1055                 :          0 :         struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
    1056                 :            :         struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
    1057                 :          0 :         struct ice_vsi *vsi = pf->main_vsi;
    1058                 :            :         uint16_t q_ids[1];
    1059                 :            :         uint32_t q_teids[1];
    1060                 :          0 :         uint16_t q_handle = tx_queue_id;
    1061                 :            :         int status;
    1062                 :            : 
    1063         [ #  # ]:          0 :         if (tx_queue_id >= dev->data->nb_tx_queues) {
    1064                 :          0 :                 PMD_DRV_LOG(ERR, "TX queue %u is out of range %u",
    1065                 :            :                             tx_queue_id, dev->data->nb_tx_queues);
    1066                 :          0 :                 return -EINVAL;
    1067                 :            :         }
    1068                 :            : 
    1069                 :          0 :         txq = dev->data->tx_queues[tx_queue_id];
    1070         [ #  # ]:          0 :         if (!txq) {
    1071                 :          0 :                 PMD_DRV_LOG(ERR, "TX queue %u is not available",
    1072                 :            :                             tx_queue_id);
    1073                 :          0 :                 return -EINVAL;
    1074                 :            :         }
    1075                 :            : 
    1076         [ #  # ]:          0 :         if (dev->data->tx_queue_state[tx_queue_id] ==
    1077                 :            :                 RTE_ETH_QUEUE_STATE_STOPPED)
    1078                 :            :                 return 0;
    1079                 :            : 
    1080                 :          0 :         q_ids[0] = txq->reg_idx;
    1081                 :          0 :         q_teids[0] = txq->q_teid;
    1082                 :            : 
    1083                 :            :         /* Fix me, we assume TC always 0 here */
    1084                 :          0 :         status = ice_dis_vsi_txq(hw->port_info, vsi->idx, 0, 1, &q_handle,
    1085                 :            :                                 q_ids, q_teids, ICE_NO_RESET, 0, NULL);
    1086         [ #  # ]:          0 :         if (status != ICE_SUCCESS) {
    1087                 :          0 :                 PMD_DRV_LOG(DEBUG, "Failed to disable Lan Tx queue");
    1088                 :          0 :                 return -EINVAL;
    1089                 :            :         }
    1090                 :            : 
    1091                 :          0 :         ci_txq_release_all_mbufs(txq, false);
    1092                 :          0 :         ice_reset_tx_queue(txq);
    1093                 :          0 :         dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
    1094                 :            : 
    1095                 :          0 :         return 0;
    1096                 :            : }
    1097                 :            : 
    1098                 :            : int
    1099                 :          0 : ice_fdir_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
    1100                 :            : {
    1101                 :            :         struct ice_rx_queue *rxq;
    1102                 :            :         int err;
    1103                 :          0 :         struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
    1104                 :            :         struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
    1105                 :            : 
    1106                 :          0 :         rxq = pf->fdir.rxq;
    1107                 :            : 
    1108                 :          0 :         err = ice_switch_rx_queue(hw, rxq->reg_idx, false);
    1109         [ #  # ]:          0 :         if (err) {
    1110                 :          0 :                 PMD_DRV_LOG(ERR, "Failed to switch FDIR RX queue %u off",
    1111                 :            :                             rx_queue_id);
    1112                 :          0 :                 return -EINVAL;
    1113                 :            :         }
    1114                 :          0 :         rxq->rx_rel_mbufs(rxq);
    1115                 :            : 
    1116                 :          0 :         return 0;
    1117                 :            : }
    1118                 :            : 
    1119                 :            : int
    1120                 :          0 : ice_fdir_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
    1121                 :            : {
    1122                 :            :         struct ci_tx_queue *txq;
    1123                 :          0 :         struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
    1124                 :            :         struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
    1125                 :            :         struct ice_vsi *vsi = pf->main_vsi;
    1126                 :            :         uint16_t q_ids[1];
    1127                 :            :         uint32_t q_teids[1];
    1128                 :          0 :         uint16_t q_handle = tx_queue_id;
    1129                 :            :         int status;
    1130                 :            : 
    1131                 :          0 :         txq = pf->fdir.txq;
    1132         [ #  # ]:          0 :         if (!txq) {
    1133                 :          0 :                 PMD_DRV_LOG(ERR, "TX queue %u is not available",
    1134                 :            :                             tx_queue_id);
    1135                 :          0 :                 return -EINVAL;
    1136                 :            :         }
    1137         [ #  # ]:          0 :         if (txq->qtx_tail == NULL) {
    1138                 :          0 :                 PMD_DRV_LOG(INFO, "TX queue %u not started", tx_queue_id);
    1139                 :          0 :                 return 0;
    1140                 :            :         }
    1141                 :          0 :         vsi = txq->ice_vsi;
    1142                 :            : 
    1143                 :          0 :         q_ids[0] = txq->reg_idx;
    1144                 :          0 :         q_teids[0] = txq->q_teid;
    1145                 :            : 
    1146                 :            :         /* Fix me, we assume TC always 0 here */
    1147                 :          0 :         status = ice_dis_vsi_txq(hw->port_info, vsi->idx, 0, 1, &q_handle,
    1148                 :            :                                  q_ids, q_teids, ICE_NO_RESET, 0, NULL);
    1149         [ #  # ]:          0 :         if (status != ICE_SUCCESS) {
    1150                 :          0 :                 PMD_DRV_LOG(DEBUG, "Failed to disable Lan Tx queue");
    1151                 :          0 :                 return -EINVAL;
    1152                 :            :         }
    1153                 :            : 
    1154                 :          0 :         ci_txq_release_all_mbufs(txq, false);
    1155                 :          0 :         txq->qtx_tail = NULL;
    1156                 :            : 
    1157                 :          0 :         return 0;
    1158                 :            : }
    1159                 :            : 
    1160                 :            : int
    1161                 :          0 : ice_rx_queue_setup(struct rte_eth_dev *dev,
    1162                 :            :                    uint16_t queue_idx,
    1163                 :            :                    uint16_t nb_desc,
    1164                 :            :                    unsigned int socket_id,
    1165                 :            :                    const struct rte_eth_rxconf *rx_conf,
    1166                 :            :                    struct rte_mempool *mp)
    1167                 :            : {
    1168                 :          0 :         struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
    1169                 :            :         struct ice_adapter *ad =
    1170                 :            :                 ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
    1171                 :          0 :         struct ice_vsi *vsi = pf->main_vsi;
    1172                 :            :         struct ice_rx_queue *rxq;
    1173                 :            :         const struct rte_memzone *rz;
    1174                 :            :         uint32_t ring_size, tlen;
    1175                 :            :         uint16_t len;
    1176                 :            :         int use_def_burst_func = 1;
    1177                 :            :         uint64_t offloads;
    1178                 :          0 :         uint16_t n_seg = rx_conf->rx_nseg;
    1179                 :            :         uint16_t i;
    1180                 :            : 
    1181         [ #  # ]:          0 :         if (nb_desc % ICE_ALIGN_RING_DESC != 0 ||
    1182         [ #  # ]:          0 :             nb_desc > ICE_MAX_RING_DESC ||
    1183                 :            :             nb_desc < ICE_MIN_RING_DESC) {
    1184                 :          0 :                 PMD_INIT_LOG(ERR, "Number (%u) of receive descriptors is "
    1185                 :            :                              "invalid", nb_desc);
    1186                 :          0 :                 return -EINVAL;
    1187                 :            :         }
    1188                 :            : 
    1189                 :          0 :         offloads = rx_conf->offloads | dev->data->dev_conf.rxmode.offloads;
    1190                 :            : 
    1191         [ #  # ]:          0 :         if (mp)
    1192                 :            :                 n_seg = 1;
    1193                 :            : 
    1194   [ #  #  #  # ]:          0 :         if (n_seg > 1 && !(offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)) {
    1195                 :          0 :                 PMD_INIT_LOG(ERR, "port %u queue index %u split offload not configured",
    1196                 :            :                                 dev->data->port_id, queue_idx);
    1197                 :          0 :                 return -EINVAL;
    1198                 :            :         }
    1199                 :            : 
    1200                 :            :         /* Free memory if needed */
    1201         [ #  # ]:          0 :         if (dev->data->rx_queues[queue_idx]) {
    1202                 :          0 :                 ice_rx_queue_release(dev->data->rx_queues[queue_idx]);
    1203                 :          0 :                 dev->data->rx_queues[queue_idx] = NULL;
    1204                 :            :         }
    1205                 :            : 
    1206                 :            :         /* Allocate the rx queue data structure */
    1207                 :          0 :         rxq = rte_zmalloc_socket(NULL,
    1208                 :            :                                  sizeof(struct ice_rx_queue),
    1209                 :            :                                  RTE_CACHE_LINE_SIZE,
    1210                 :            :                                  socket_id);
    1211                 :            : 
    1212         [ #  # ]:          0 :         if (!rxq) {
    1213                 :          0 :                 PMD_INIT_LOG(ERR, "Failed to allocate memory for "
    1214                 :            :                              "rx queue data structure");
    1215                 :          0 :                 return -ENOMEM;
    1216                 :            :         }
    1217                 :            : 
    1218                 :          0 :         rxq->rxseg_nb = n_seg;
    1219         [ #  # ]:          0 :         if (n_seg > 1) {
    1220         [ #  # ]:          0 :                 for (i = 0; i < n_seg; i++)
    1221                 :          0 :                         memcpy(&rxq->rxseg[i], &rx_conf->rx_seg[i].split,
    1222                 :            :                                 sizeof(struct rte_eth_rxseg_split));
    1223                 :            : 
    1224                 :          0 :                 rxq->mp = rxq->rxseg[0].mp;
    1225                 :            :         } else {
    1226                 :          0 :                 rxq->mp = mp;
    1227                 :            :         }
    1228                 :            : 
    1229                 :          0 :         rxq->nb_rx_desc = nb_desc;
    1230                 :          0 :         rxq->rx_free_thresh = rx_conf->rx_free_thresh;
    1231                 :          0 :         rxq->queue_id = queue_idx;
    1232                 :          0 :         rxq->offloads = offloads;
    1233                 :            : 
    1234                 :          0 :         rxq->reg_idx = vsi->base_queue + queue_idx;
    1235                 :          0 :         rxq->port_id = dev->data->port_id;
    1236         [ #  # ]:          0 :         if (dev->data->dev_conf.rxmode.offloads & RTE_ETH_RX_OFFLOAD_KEEP_CRC)
    1237                 :          0 :                 rxq->crc_len = RTE_ETHER_CRC_LEN;
    1238                 :            :         else
    1239                 :          0 :                 rxq->crc_len = 0;
    1240                 :            : 
    1241                 :          0 :         rxq->drop_en = rx_conf->rx_drop_en;
    1242                 :          0 :         rxq->vsi = vsi;
    1243                 :          0 :         rxq->rx_deferred_start = rx_conf->rx_deferred_start;
    1244         [ #  # ]:          0 :         rxq->proto_xtr = pf->proto_xtr != NULL ?
    1245                 :          0 :                          pf->proto_xtr[queue_idx] : PROTO_XTR_NONE;
    1246         [ #  # ]:          0 :         if (rxq->proto_xtr != PROTO_XTR_NONE &&
    1247         [ #  # ]:          0 :                         ad->devargs.xtr_flag_offs[rxq->proto_xtr] != 0xff)
    1248                 :          0 :                 rxq->xtr_ol_flag = 1ULL << ad->devargs.xtr_flag_offs[rxq->proto_xtr];
    1249                 :          0 :         rxq->xtr_field_offs = ad->devargs.xtr_field_offs;
    1250                 :            : 
    1251                 :            :         /* Allocate the maximum number of RX ring hardware descriptor. */
    1252                 :            :         len = ICE_MAX_RING_DESC;
    1253                 :            : 
    1254                 :            :         /**
    1255                 :            :          * Allocating a little more memory because vectorized/bulk_alloc Rx
    1256                 :            :          * functions doesn't check boundaries each time.
    1257                 :            :          */
    1258                 :            :         len += ICE_RX_MAX_BURST;
    1259                 :            : 
    1260                 :            :         /* Allocate the maximum number of RX ring hardware descriptor. */
    1261                 :            :         ring_size = sizeof(union ice_rx_flex_desc) * len;
    1262                 :            :         ring_size = RTE_ALIGN(ring_size, ICE_DMA_MEM_ALIGN);
    1263                 :          0 :         rz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx,
    1264                 :            :                                       ring_size, ICE_RING_BASE_ALIGN,
    1265                 :            :                                       socket_id);
    1266         [ #  # ]:          0 :         if (!rz) {
    1267                 :          0 :                 ice_rx_queue_release(rxq);
    1268                 :          0 :                 PMD_INIT_LOG(ERR, "Failed to reserve DMA memory for RX");
    1269                 :          0 :                 return -ENOMEM;
    1270                 :            :         }
    1271                 :            : 
    1272                 :          0 :         rxq->mz = rz;
    1273                 :            :         /* Zero all the descriptors in the ring. */
    1274         [ #  # ]:          0 :         memset(rz->addr, 0, ring_size);
    1275                 :            : 
    1276                 :          0 :         rxq->rx_ring_dma = rz->iova;
    1277                 :          0 :         rxq->rx_ring = rz->addr;
    1278                 :            : 
    1279                 :            :         /* always reserve more for bulk alloc */
    1280                 :          0 :         len = (uint16_t)(nb_desc + ICE_RX_MAX_BURST);
    1281                 :            : 
    1282                 :            :         /* allocate extra entries for SW split buffer */
    1283                 :          0 :         tlen = ((rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) != 0) ?
    1284         [ #  # ]:          0 :                 rxq->rx_free_thresh : 0;
    1285                 :          0 :         tlen += len;
    1286                 :            : 
    1287                 :            :         /* Allocate the software ring. */
    1288                 :          0 :         rxq->sw_ring = rte_zmalloc_socket(NULL,
    1289                 :            :                                           sizeof(struct ice_rx_entry) * tlen,
    1290                 :            :                                           RTE_CACHE_LINE_SIZE,
    1291                 :            :                                           socket_id);
    1292         [ #  # ]:          0 :         if (!rxq->sw_ring) {
    1293                 :          0 :                 ice_rx_queue_release(rxq);
    1294                 :          0 :                 PMD_INIT_LOG(ERR, "Failed to allocate memory for SW ring");
    1295                 :          0 :                 return -ENOMEM;
    1296                 :            :         }
    1297                 :            : 
    1298         [ #  # ]:          0 :         rxq->sw_split_buf = (tlen == len) ? NULL : rxq->sw_ring + len;
    1299                 :            : 
    1300                 :          0 :         ice_reset_rx_queue(rxq);
    1301                 :          0 :         rxq->q_set = true;
    1302                 :          0 :         dev->data->rx_queues[queue_idx] = rxq;
    1303                 :          0 :         rxq->rx_rel_mbufs = _ice_rx_queue_release_mbufs;
    1304                 :            : 
    1305                 :          0 :         use_def_burst_func = ice_check_rx_burst_bulk_alloc_preconditions(rxq);
    1306                 :            : 
    1307         [ #  # ]:          0 :         if (!use_def_burst_func) {
    1308                 :          0 :                 PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions are "
    1309                 :            :                              "satisfied. Rx Burst Bulk Alloc function will be "
    1310                 :            :                              "used on port=%d, queue=%d.",
    1311                 :            :                              rxq->port_id, rxq->queue_id);
    1312                 :            :         } else {
    1313                 :          0 :                 PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions are "
    1314                 :            :                              "not satisfied, Scattered Rx is requested. "
    1315                 :            :                              "on port=%d, queue=%d.",
    1316                 :            :                              rxq->port_id, rxq->queue_id);
    1317                 :          0 :                 ad->rx_bulk_alloc_allowed = false;
    1318                 :            :         }
    1319                 :            : 
    1320                 :            :         return 0;
    1321                 :            : }
    1322                 :            : 
    1323                 :            : void
    1324                 :          0 : ice_rx_queue_release(void *rxq)
    1325                 :            : {
    1326                 :            :         struct ice_rx_queue *q = (struct ice_rx_queue *)rxq;
    1327                 :            : 
    1328         [ #  # ]:          0 :         if (!q) {
    1329                 :          0 :                 PMD_DRV_LOG(DEBUG, "Pointer to rxq is NULL");
    1330                 :          0 :                 return;
    1331                 :            :         }
    1332                 :            : 
    1333         [ #  # ]:          0 :         if (q->rx_rel_mbufs != NULL)
    1334                 :          0 :                 q->rx_rel_mbufs(q);
    1335                 :          0 :         rte_free(q->sw_ring);
    1336                 :          0 :         rte_memzone_free(q->mz);
    1337                 :          0 :         rte_free(q);
    1338                 :            : }
    1339                 :            : 
    1340                 :            : int
    1341                 :          0 : ice_tx_queue_setup(struct rte_eth_dev *dev,
    1342                 :            :                    uint16_t queue_idx,
    1343                 :            :                    uint16_t nb_desc,
    1344                 :            :                    unsigned int socket_id,
    1345                 :            :                    const struct rte_eth_txconf *tx_conf)
    1346                 :            : {
    1347                 :          0 :         struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
    1348                 :          0 :         struct ice_vsi *vsi = pf->main_vsi;
    1349                 :            :         struct ci_tx_queue *txq;
    1350                 :            :         const struct rte_memzone *tz;
    1351                 :            :         uint32_t ring_size;
    1352                 :            :         uint16_t tx_rs_thresh, tx_free_thresh;
    1353                 :            :         uint64_t offloads;
    1354                 :            : 
    1355                 :          0 :         offloads = tx_conf->offloads | dev->data->dev_conf.txmode.offloads;
    1356                 :            : 
    1357         [ #  # ]:          0 :         if (nb_desc % ICE_ALIGN_RING_DESC != 0 ||
    1358         [ #  # ]:          0 :             nb_desc > ICE_MAX_RING_DESC ||
    1359                 :            :             nb_desc < ICE_MIN_RING_DESC) {
    1360                 :          0 :                 PMD_INIT_LOG(ERR, "Number (%u) of transmit descriptors is "
    1361                 :            :                              "invalid", nb_desc);
    1362                 :          0 :                 return -EINVAL;
    1363                 :            :         }
    1364                 :            : 
    1365                 :            :         /**
    1366                 :            :          * The following two parameters control the setting of the RS bit on
    1367                 :            :          * transmit descriptors. TX descriptors will have their RS bit set
    1368                 :            :          * after txq->tx_rs_thresh descriptors have been used. The TX
    1369                 :            :          * descriptor ring will be cleaned after txq->tx_free_thresh
    1370                 :            :          * descriptors are used or if the number of descriptors required to
    1371                 :            :          * transmit a packet is greater than the number of free TX descriptors.
    1372                 :            :          *
    1373                 :            :          * The following constraints must be satisfied:
    1374                 :            :          *  - tx_rs_thresh must be greater than 0.
    1375                 :            :          *  - tx_rs_thresh must be less than the size of the ring minus 2.
    1376                 :            :          *  - tx_rs_thresh must be less than or equal to tx_free_thresh.
    1377                 :            :          *  - tx_rs_thresh must be a divisor of the ring size.
    1378                 :            :          *  - tx_free_thresh must be greater than 0.
    1379                 :            :          *  - tx_free_thresh must be less than the size of the ring minus 3.
    1380                 :            :          *  - tx_free_thresh + tx_rs_thresh must not exceed nb_desc.
    1381                 :            :          *
    1382                 :            :          * One descriptor in the TX ring is used as a sentinel to avoid a H/W
    1383                 :            :          * race condition, hence the maximum threshold constraints. When set
    1384                 :            :          * to zero use default values.
    1385                 :            :          */
    1386         [ #  # ]:          0 :         tx_free_thresh = (uint16_t)(tx_conf->tx_free_thresh ?
    1387                 :            :                                     tx_conf->tx_free_thresh :
    1388                 :            :                                     ICE_DEFAULT_TX_FREE_THRESH);
    1389                 :            :         /* force tx_rs_thresh to adapt an aggressive tx_free_thresh */
    1390                 :          0 :         tx_rs_thresh =
    1391         [ #  # ]:          0 :                 (ICE_DEFAULT_TX_RSBIT_THRESH + tx_free_thresh > nb_desc) ?
    1392                 :            :                         nb_desc - tx_free_thresh : ICE_DEFAULT_TX_RSBIT_THRESH;
    1393         [ #  # ]:          0 :         if (tx_conf->tx_rs_thresh)
    1394                 :            :                 tx_rs_thresh = tx_conf->tx_rs_thresh;
    1395         [ #  # ]:          0 :         if (tx_rs_thresh + tx_free_thresh > nb_desc) {
    1396                 :          0 :                 PMD_INIT_LOG(ERR, "tx_rs_thresh + tx_free_thresh must not "
    1397                 :            :                                 "exceed nb_desc. (tx_rs_thresh=%u "
    1398                 :            :                                 "tx_free_thresh=%u nb_desc=%u port = %d queue=%d)",
    1399                 :            :                                 (unsigned int)tx_rs_thresh,
    1400                 :            :                                 (unsigned int)tx_free_thresh,
    1401                 :            :                                 (unsigned int)nb_desc,
    1402                 :            :                                 (int)dev->data->port_id,
    1403                 :            :                                 (int)queue_idx);
    1404                 :          0 :                 return -EINVAL;
    1405                 :            :         }
    1406         [ #  # ]:          0 :         if (tx_rs_thresh >= (nb_desc - 2)) {
    1407                 :          0 :                 PMD_INIT_LOG(ERR, "tx_rs_thresh must be less than the "
    1408                 :            :                              "number of TX descriptors minus 2. "
    1409                 :            :                              "(tx_rs_thresh=%u port=%d queue=%d)",
    1410                 :            :                              (unsigned int)tx_rs_thresh,
    1411                 :            :                              (int)dev->data->port_id,
    1412                 :            :                              (int)queue_idx);
    1413                 :          0 :                 return -EINVAL;
    1414                 :            :         }
    1415         [ #  # ]:          0 :         if (tx_free_thresh >= (nb_desc - 3)) {
    1416                 :          0 :                 PMD_INIT_LOG(ERR, "tx_rs_thresh must be less than the "
    1417                 :            :                              "tx_free_thresh must be less than the "
    1418                 :            :                              "number of TX descriptors minus 3. "
    1419                 :            :                              "(tx_free_thresh=%u port=%d queue=%d)",
    1420                 :            :                              (unsigned int)tx_free_thresh,
    1421                 :            :                              (int)dev->data->port_id,
    1422                 :            :                              (int)queue_idx);
    1423                 :          0 :                 return -EINVAL;
    1424                 :            :         }
    1425         [ #  # ]:          0 :         if (tx_rs_thresh > tx_free_thresh) {
    1426                 :          0 :                 PMD_INIT_LOG(ERR, "tx_rs_thresh must be less than or "
    1427                 :            :                              "equal to tx_free_thresh. (tx_free_thresh=%u"
    1428                 :            :                              " tx_rs_thresh=%u port=%d queue=%d)",
    1429                 :            :                              (unsigned int)tx_free_thresh,
    1430                 :            :                              (unsigned int)tx_rs_thresh,
    1431                 :            :                              (int)dev->data->port_id,
    1432                 :            :                              (int)queue_idx);
    1433                 :          0 :                 return -EINVAL;
    1434                 :            :         }
    1435         [ #  # ]:          0 :         if ((nb_desc % tx_rs_thresh) != 0) {
    1436                 :          0 :                 PMD_INIT_LOG(ERR, "tx_rs_thresh must be a divisor of the "
    1437                 :            :                              "number of TX descriptors. (tx_rs_thresh=%u"
    1438                 :            :                              " port=%d queue=%d)",
    1439                 :            :                              (unsigned int)tx_rs_thresh,
    1440                 :            :                              (int)dev->data->port_id,
    1441                 :            :                              (int)queue_idx);
    1442                 :          0 :                 return -EINVAL;
    1443                 :            :         }
    1444   [ #  #  #  # ]:          0 :         if (tx_rs_thresh > 1 && tx_conf->tx_thresh.wthresh != 0) {
    1445                 :          0 :                 PMD_INIT_LOG(ERR, "TX WTHRESH must be set to 0 if "
    1446                 :            :                              "tx_rs_thresh is greater than 1. "
    1447                 :            :                              "(tx_rs_thresh=%u port=%d queue=%d)",
    1448                 :            :                              (unsigned int)tx_rs_thresh,
    1449                 :            :                              (int)dev->data->port_id,
    1450                 :            :                              (int)queue_idx);
    1451                 :          0 :                 return -EINVAL;
    1452                 :            :         }
    1453                 :            : 
    1454                 :            :         /* Free memory if needed. */
    1455         [ #  # ]:          0 :         if (dev->data->tx_queues[queue_idx]) {
    1456                 :          0 :                 ice_tx_queue_release(dev->data->tx_queues[queue_idx]);
    1457                 :          0 :                 dev->data->tx_queues[queue_idx] = NULL;
    1458                 :            :         }
    1459                 :            : 
    1460                 :            :         /* Allocate the TX queue data structure. */
    1461                 :          0 :         txq = rte_zmalloc_socket(NULL,
    1462                 :            :                                  sizeof(struct ci_tx_queue),
    1463                 :            :                                  RTE_CACHE_LINE_SIZE,
    1464                 :            :                                  socket_id);
    1465         [ #  # ]:          0 :         if (!txq) {
    1466                 :          0 :                 PMD_INIT_LOG(ERR, "Failed to allocate memory for "
    1467                 :            :                              "tx queue structure");
    1468                 :          0 :                 return -ENOMEM;
    1469                 :            :         }
    1470                 :            : 
    1471                 :            :         /* Allocate TX hardware ring descriptors. */
    1472                 :            :         ring_size = sizeof(struct ice_tx_desc) * ICE_MAX_RING_DESC;
    1473                 :            :         ring_size = RTE_ALIGN(ring_size, ICE_DMA_MEM_ALIGN);
    1474                 :          0 :         tz = rte_eth_dma_zone_reserve(dev, "ice_tx_ring", queue_idx,
    1475                 :            :                                       ring_size, ICE_RING_BASE_ALIGN,
    1476                 :            :                                       socket_id);
    1477         [ #  # ]:          0 :         if (!tz) {
    1478                 :          0 :                 ice_tx_queue_release(txq);
    1479                 :          0 :                 PMD_INIT_LOG(ERR, "Failed to reserve DMA memory for TX");
    1480                 :          0 :                 return -ENOMEM;
    1481                 :            :         }
    1482                 :            : 
    1483                 :          0 :         txq->mz = tz;
    1484                 :          0 :         txq->nb_tx_desc = nb_desc;
    1485                 :          0 :         txq->tx_rs_thresh = tx_rs_thresh;
    1486                 :          0 :         txq->tx_free_thresh = tx_free_thresh;
    1487                 :          0 :         txq->queue_id = queue_idx;
    1488                 :            : 
    1489                 :          0 :         txq->reg_idx = vsi->base_queue + queue_idx;
    1490                 :          0 :         txq->port_id = dev->data->port_id;
    1491                 :          0 :         txq->offloads = offloads;
    1492                 :          0 :         txq->ice_vsi = vsi;
    1493                 :          0 :         txq->tx_deferred_start = tx_conf->tx_deferred_start;
    1494                 :            : 
    1495                 :          0 :         txq->tx_ring_dma = tz->iova;
    1496                 :          0 :         txq->ice_tx_ring = tz->addr;
    1497                 :            : 
    1498                 :            :         /* Allocate software ring */
    1499                 :          0 :         txq->sw_ring =
    1500                 :          0 :                 rte_zmalloc_socket(NULL,
    1501                 :            :                                    sizeof(struct ci_tx_entry) * nb_desc,
    1502                 :            :                                    RTE_CACHE_LINE_SIZE,
    1503                 :            :                                    socket_id);
    1504         [ #  # ]:          0 :         if (!txq->sw_ring) {
    1505                 :          0 :                 ice_tx_queue_release(txq);
    1506                 :          0 :                 PMD_INIT_LOG(ERR, "Failed to allocate memory for SW TX ring");
    1507                 :          0 :                 return -ENOMEM;
    1508                 :            :         }
    1509                 :            : 
    1510                 :          0 :         ice_reset_tx_queue(txq);
    1511                 :          0 :         txq->q_set = true;
    1512                 :          0 :         dev->data->tx_queues[queue_idx] = txq;
    1513                 :          0 :         ice_set_tx_function_flag(dev, txq);
    1514                 :            : 
    1515                 :          0 :         return 0;
    1516                 :            : }
    1517                 :            : 
    1518                 :            : void
    1519                 :          0 : ice_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
    1520                 :            : {
    1521                 :          0 :         ice_rx_queue_release(dev->data->rx_queues[qid]);
    1522                 :          0 : }
    1523                 :            : 
    1524                 :            : void
    1525                 :          0 : ice_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
    1526                 :            : {
    1527                 :          0 :         ice_tx_queue_release(dev->data->tx_queues[qid]);
    1528                 :          0 : }
    1529                 :            : 
    1530                 :            : void
    1531                 :          0 : ice_tx_queue_release(void *txq)
    1532                 :            : {
    1533                 :            :         struct ci_tx_queue *q = (struct ci_tx_queue *)txq;
    1534                 :            : 
    1535         [ #  # ]:          0 :         if (!q) {
    1536                 :          0 :                 PMD_DRV_LOG(DEBUG, "Pointer to TX queue is NULL");
    1537                 :          0 :                 return;
    1538                 :            :         }
    1539                 :            : 
    1540                 :          0 :         ci_txq_release_all_mbufs(q, false);
    1541                 :          0 :         rte_free(q->sw_ring);
    1542                 :          0 :         rte_memzone_free(q->mz);
    1543                 :          0 :         rte_free(q);
    1544                 :            : }
    1545                 :            : 
    1546                 :            : void
    1547                 :          0 : ice_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
    1548                 :            :                  struct rte_eth_rxq_info *qinfo)
    1549                 :            : {
    1550                 :            :         struct ice_rx_queue *rxq;
    1551                 :            : 
    1552                 :          0 :         rxq = dev->data->rx_queues[queue_id];
    1553                 :            : 
    1554                 :          0 :         qinfo->mp = rxq->mp;
    1555                 :          0 :         qinfo->scattered_rx = dev->data->scattered_rx;
    1556                 :          0 :         qinfo->nb_desc = rxq->nb_rx_desc;
    1557                 :            : 
    1558                 :          0 :         qinfo->conf.rx_free_thresh = rxq->rx_free_thresh;
    1559                 :          0 :         qinfo->conf.rx_drop_en = rxq->drop_en;
    1560                 :          0 :         qinfo->conf.rx_deferred_start = rxq->rx_deferred_start;
    1561                 :          0 : }
    1562                 :            : 
    1563                 :            : void
    1564                 :          0 : ice_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
    1565                 :            :                  struct rte_eth_txq_info *qinfo)
    1566                 :            : {
    1567                 :            :         struct ci_tx_queue *txq;
    1568                 :            : 
    1569                 :          0 :         txq = dev->data->tx_queues[queue_id];
    1570                 :            : 
    1571                 :          0 :         qinfo->nb_desc = txq->nb_tx_desc;
    1572                 :            : 
    1573                 :          0 :         qinfo->conf.tx_thresh.pthresh = ICE_DEFAULT_TX_PTHRESH;
    1574                 :          0 :         qinfo->conf.tx_thresh.hthresh = ICE_DEFAULT_TX_HTHRESH;
    1575                 :          0 :         qinfo->conf.tx_thresh.wthresh = ICE_DEFAULT_TX_WTHRESH;
    1576                 :            : 
    1577                 :          0 :         qinfo->conf.tx_free_thresh = txq->tx_free_thresh;
    1578                 :          0 :         qinfo->conf.tx_rs_thresh = txq->tx_rs_thresh;
    1579                 :          0 :         qinfo->conf.offloads = txq->offloads;
    1580                 :          0 :         qinfo->conf.tx_deferred_start = txq->tx_deferred_start;
    1581                 :          0 : }
    1582                 :            : 
    1583                 :            : uint32_t
    1584                 :          0 : ice_rx_queue_count(void *rx_queue)
    1585                 :            : {
    1586                 :            : #define ICE_RXQ_SCAN_INTERVAL 4
    1587                 :            :         volatile union ice_rx_flex_desc *rxdp;
    1588                 :            :         struct ice_rx_queue *rxq;
    1589                 :            :         uint16_t desc = 0;
    1590                 :            : 
    1591                 :            :         rxq = rx_queue;
    1592                 :          0 :         rxdp = &rxq->rx_ring[rxq->rx_tail];
    1593         [ #  # ]:          0 :         while ((desc < rxq->nb_rx_desc) &&
    1594         [ #  # ]:          0 :                rte_le_to_cpu_16(rxdp->wb.status_error0) &
    1595                 :            :                (1 << ICE_RX_FLEX_DESC_STATUS0_DD_S)) {
    1596                 :            :                 /**
    1597                 :            :                  * Check the DD bit of a rx descriptor of each 4 in a group,
    1598                 :            :                  * to avoid checking too frequently and downgrading performance
    1599                 :            :                  * too much.
    1600                 :            :                  */
    1601                 :          0 :                 desc += ICE_RXQ_SCAN_INTERVAL;
    1602                 :          0 :                 rxdp += ICE_RXQ_SCAN_INTERVAL;
    1603         [ #  # ]:          0 :                 if (rxq->rx_tail + desc >= rxq->nb_rx_desc)
    1604                 :          0 :                         rxdp = &(rxq->rx_ring[rxq->rx_tail +
    1605                 :          0 :                                  desc - rxq->nb_rx_desc]);
    1606                 :            :         }
    1607                 :            : 
    1608                 :          0 :         return desc;
    1609                 :            : }
    1610                 :            : 
    1611                 :            : #define ICE_RX_FLEX_ERR0_BITS   \
    1612                 :            :         ((1 << ICE_RX_FLEX_DESC_STATUS0_HBO_S) |  \
    1613                 :            :          (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_IPE_S) |     \
    1614                 :            :          (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_L4E_S) |     \
    1615                 :            :          (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_EIPE_S) |    \
    1616                 :            :          (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_EUDPE_S) |   \
    1617                 :            :          (1 << ICE_RX_FLEX_DESC_STATUS0_RXE_S))
    1618                 :            : 
    1619                 :            : /* Rx L3/L4 checksum */
    1620                 :            : static inline uint64_t
    1621                 :          0 : ice_rxd_error_to_pkt_flags(uint16_t stat_err0)
    1622                 :            : {
    1623                 :            :         uint64_t flags = 0;
    1624                 :            : 
    1625                 :            :         /* check if HW has decoded the packet and checksum */
    1626         [ #  # ]:          0 :         if (unlikely(!(stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_L3L4P_S))))
    1627                 :            :                 return 0;
    1628                 :            : 
    1629         [ #  # ]:          0 :         if (likely(!(stat_err0 & ICE_RX_FLEX_ERR0_BITS))) {
    1630                 :            :                 flags |= (RTE_MBUF_F_RX_IP_CKSUM_GOOD |
    1631                 :            :                           RTE_MBUF_F_RX_L4_CKSUM_GOOD |
    1632                 :            :                           RTE_MBUF_F_RX_OUTER_L4_CKSUM_GOOD);
    1633                 :            :                 return flags;
    1634                 :            :         }
    1635                 :            : 
    1636         [ #  # ]:          0 :         if (unlikely(stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_IPE_S)))
    1637                 :            :                 flags |= RTE_MBUF_F_RX_IP_CKSUM_BAD;
    1638                 :            :         else
    1639                 :            :                 flags |= RTE_MBUF_F_RX_IP_CKSUM_GOOD;
    1640                 :            : 
    1641         [ #  # ]:          0 :         if (unlikely(stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_L4E_S)))
    1642                 :          0 :                 flags |= RTE_MBUF_F_RX_L4_CKSUM_BAD;
    1643                 :            :         else
    1644                 :          0 :                 flags |= RTE_MBUF_F_RX_L4_CKSUM_GOOD;
    1645                 :            : 
    1646         [ #  # ]:          0 :         if (unlikely(stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_EIPE_S)))
    1647                 :          0 :                 flags |= RTE_MBUF_F_RX_OUTER_IP_CKSUM_BAD;
    1648                 :            : 
    1649         [ #  # ]:          0 :         if (unlikely(stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_XSUM_EUDPE_S)))
    1650                 :          0 :                 flags |= RTE_MBUF_F_RX_OUTER_L4_CKSUM_BAD;
    1651                 :            :         else
    1652                 :          0 :                 flags |= RTE_MBUF_F_RX_OUTER_L4_CKSUM_GOOD;
    1653                 :            : 
    1654                 :            :         return flags;
    1655                 :            : }
    1656                 :            : 
    1657                 :            : static inline void
    1658                 :            : ice_rxd_to_vlan_tci(struct rte_mbuf *mb, volatile union ice_rx_flex_desc *rxdp)
    1659                 :            : {
    1660                 :          0 :         if (rte_le_to_cpu_16(rxdp->wb.status_error0) &
    1661                 :            :             (1 << ICE_RX_FLEX_DESC_STATUS0_L2TAG1P_S)) {
    1662                 :          0 :                 mb->ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
    1663                 :          0 :                 mb->vlan_tci =
    1664                 :          0 :                         rte_le_to_cpu_16(rxdp->wb.l2tag1);
    1665                 :            :                 PMD_RX_LOG(DEBUG, "Descriptor l2tag1: %u",
    1666                 :            :                            rte_le_to_cpu_16(rxdp->wb.l2tag1));
    1667                 :            :         } else {
    1668                 :          0 :                 mb->vlan_tci = 0;
    1669                 :            :         }
    1670                 :            : 
    1671                 :            : #ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC
    1672   [ #  #  #  #  :          0 :         if (rte_le_to_cpu_16(rxdp->wb.status_error1) &
                   #  # ]
    1673                 :            :             (1 << ICE_RX_FLEX_DESC_STATUS1_L2TAG2P_S)) {
    1674                 :          0 :                 mb->ol_flags |= RTE_MBUF_F_RX_QINQ_STRIPPED | RTE_MBUF_F_RX_QINQ |
    1675                 :            :                                 RTE_MBUF_F_RX_VLAN_STRIPPED | RTE_MBUF_F_RX_VLAN;
    1676                 :          0 :                 mb->vlan_tci_outer = mb->vlan_tci;
    1677                 :          0 :                 mb->vlan_tci = rte_le_to_cpu_16(rxdp->wb.l2tag2_2nd);
    1678                 :            :                 PMD_RX_LOG(DEBUG, "Descriptor l2tag2_1: %u, l2tag2_2: %u",
    1679                 :            :                            rte_le_to_cpu_16(rxdp->wb.l2tag2_1st),
    1680                 :            :                            rte_le_to_cpu_16(rxdp->wb.l2tag2_2nd));
    1681                 :            :         } else {
    1682                 :          0 :                 mb->vlan_tci_outer = 0;
    1683                 :            :         }
    1684                 :            : #endif
    1685                 :            :         PMD_RX_LOG(DEBUG, "Mbuf vlan_tci: %u, vlan_tci_outer: %u",
    1686                 :            :                    mb->vlan_tci, mb->vlan_tci_outer);
    1687                 :            : }
    1688                 :            : 
    1689                 :            : #define ICE_LOOK_AHEAD 8
    1690                 :            : #if (ICE_LOOK_AHEAD != 8)
    1691                 :            : #error "PMD ICE: ICE_LOOK_AHEAD must be 8\n"
    1692                 :            : #endif
    1693                 :            : 
    1694                 :            : #define ICE_PTP_TS_VALID 0x1
    1695                 :            : 
    1696                 :            : static inline int
    1697                 :          0 : ice_rx_scan_hw_ring(struct ice_rx_queue *rxq)
    1698                 :            : {
    1699                 :            :         volatile union ice_rx_flex_desc *rxdp;
    1700                 :            :         struct ice_rx_entry *rxep;
    1701                 :            :         struct rte_mbuf *mb;
    1702                 :            :         uint16_t stat_err0;
    1703                 :            :         uint16_t pkt_len, hdr_len;
    1704                 :            :         int32_t s[ICE_LOOK_AHEAD], nb_dd;
    1705                 :            :         int32_t i, j, nb_rx = 0;
    1706                 :            :         uint64_t pkt_flags = 0;
    1707                 :          0 :         uint32_t *ptype_tbl = rxq->vsi->adapter->ptype_tbl;
    1708                 :            : #ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC
    1709                 :            :         bool is_tsinit = false;
    1710                 :            :         uint64_t ts_ns;
    1711                 :            :         struct ice_vsi *vsi = rxq->vsi;
    1712                 :          0 :         struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
    1713                 :            :         struct ice_adapter *ad = rxq->vsi->adapter;
    1714                 :            : #endif
    1715                 :          0 :         rxdp = &rxq->rx_ring[rxq->rx_tail];
    1716                 :          0 :         rxep = &rxq->sw_ring[rxq->rx_tail];
    1717                 :            : 
    1718                 :          0 :         stat_err0 = rte_le_to_cpu_16(rxdp->wb.status_error0);
    1719                 :            : 
    1720                 :            :         /* Make sure there is at least 1 packet to receive */
    1721         [ #  # ]:          0 :         if (!(stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_DD_S)))
    1722                 :            :                 return 0;
    1723                 :            : 
    1724                 :            : #ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC
    1725         [ #  # ]:          0 :         if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) {
    1726                 :          0 :                 uint64_t sw_cur_time = rte_get_timer_cycles() / (rte_get_timer_hz() / 1000);
    1727                 :            : 
    1728         [ #  # ]:          0 :                 if (unlikely(sw_cur_time - rxq->hw_time_update > 4))
    1729                 :            :                         is_tsinit = 1;
    1730                 :            :         }
    1731                 :            : #endif
    1732                 :            : 
    1733                 :            :         /**
    1734                 :            :          * Scan LOOK_AHEAD descriptors at a time to determine which
    1735                 :            :          * descriptors reference packets that are ready to be received.
    1736                 :            :          */
    1737         [ #  # ]:          0 :         for (i = 0; i < ICE_RX_MAX_BURST; i += ICE_LOOK_AHEAD,
    1738                 :          0 :              rxdp += ICE_LOOK_AHEAD, rxep += ICE_LOOK_AHEAD) {
    1739                 :            :                 /* Read desc statuses backwards to avoid race condition */
    1740         [ #  # ]:          0 :                 for (j = ICE_LOOK_AHEAD - 1; j >= 0; j--)
    1741                 :          0 :                         s[j] = rte_le_to_cpu_16(rxdp[j].wb.status_error0);
    1742                 :            : 
    1743                 :          0 :                 rte_smp_rmb();
    1744                 :            : 
    1745                 :            :                 /* Compute how many status bits were set */
    1746         [ #  # ]:          0 :                 for (j = 0, nb_dd = 0; j < ICE_LOOK_AHEAD; j++)
    1747                 :          0 :                         nb_dd += s[j] & (1 << ICE_RX_FLEX_DESC_STATUS0_DD_S);
    1748                 :            : 
    1749                 :          0 :                 nb_rx += nb_dd;
    1750                 :            : 
    1751                 :            :                 /* Translate descriptor info to mbuf parameters */
    1752         [ #  # ]:          0 :                 for (j = 0; j < nb_dd; j++) {
    1753                 :          0 :                         mb = rxep[j].mbuf;
    1754                 :          0 :                         pkt_len = (rte_le_to_cpu_16(rxdp[j].wb.pkt_len) &
    1755                 :          0 :                                    ICE_RX_FLX_DESC_PKT_LEN_M) - rxq->crc_len;
    1756                 :            :                         mb->data_len = pkt_len;
    1757                 :          0 :                         mb->pkt_len = pkt_len;
    1758                 :            : 
    1759         [ #  # ]:          0 :                         if (!(rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)) {
    1760                 :          0 :                                 pkt_len = (rte_le_to_cpu_16(rxdp[j].wb.pkt_len) &
    1761                 :            :                                         ICE_RX_FLX_DESC_PKT_LEN_M) - rxq->crc_len;
    1762                 :          0 :                                 mb->data_len = pkt_len;
    1763                 :          0 :                                 mb->pkt_len = pkt_len;
    1764                 :            :                         } else {
    1765                 :          0 :                                 mb->nb_segs = (uint16_t)(mb->nb_segs + mb->next->nb_segs);
    1766                 :          0 :                                 mb->next->next = NULL;
    1767                 :          0 :                                 hdr_len = rte_le_to_cpu_16(rxdp[j].wb.hdr_len_sph_flex_flags1) &
    1768                 :            :                                                 ICE_RX_FLEX_DESC_HEADER_LEN_M;
    1769                 :          0 :                                 pkt_len = (rte_le_to_cpu_16(rxdp[j].wb.pkt_len) &
    1770                 :            :                                         ICE_RX_FLX_DESC_PKT_LEN_M) - rxq->crc_len;
    1771                 :          0 :                                 mb->data_len = hdr_len;
    1772                 :          0 :                                 mb->pkt_len = hdr_len + pkt_len;
    1773                 :          0 :                                 mb->next->data_len = pkt_len;
    1774                 :            : #ifdef RTE_ETHDEV_DEBUG_RX
    1775                 :            :                                 rte_pktmbuf_dump(stdout, mb, rte_pktmbuf_pkt_len(mb));
    1776                 :            : #endif
    1777                 :            :                         }
    1778                 :            : 
    1779                 :          0 :                         mb->ol_flags = 0;
    1780                 :          0 :                         stat_err0 = rte_le_to_cpu_16(rxdp[j].wb.status_error0);
    1781                 :          0 :                         pkt_flags = ice_rxd_error_to_pkt_flags(stat_err0);
    1782                 :          0 :                         mb->packet_type = ptype_tbl[ICE_RX_FLEX_DESC_PTYPE_M &
    1783         [ #  # ]:          0 :                                 rte_le_to_cpu_16(rxdp[j].wb.ptype_flex_flags0)];
    1784                 :            :                         ice_rxd_to_vlan_tci(mb, &rxdp[j]);
    1785                 :          0 :                         rxd_to_pkt_fields_ops[rxq->rxdid](rxq, mb, &rxdp[j]);
    1786                 :            : #ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC
    1787         [ #  # ]:          0 :                         if (rxq->ts_flag > 0 &&
    1788         [ #  # ]:          0 :                             (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)) {
    1789                 :          0 :                                 rxq->time_high =
    1790                 :          0 :                                 rte_le_to_cpu_32(rxdp[j].wb.flex_ts.ts_high);
    1791         [ #  # ]:          0 :                                 if (unlikely(is_tsinit)) {
    1792                 :          0 :                                         ts_ns = ice_tstamp_convert_32b_64b(hw, ad, 1,
    1793                 :            :                                                                            rxq->time_high);
    1794                 :          0 :                                         rxq->hw_time_low = (uint32_t)ts_ns;
    1795                 :          0 :                                         rxq->hw_time_high = (uint32_t)(ts_ns >> 32);
    1796                 :            :                                         is_tsinit = false;
    1797                 :            :                                 } else {
    1798         [ #  # ]:          0 :                                         if (rxq->time_high < rxq->hw_time_low)
    1799                 :          0 :                                                 rxq->hw_time_high += 1;
    1800                 :          0 :                                         ts_ns = (uint64_t)rxq->hw_time_high << 32 | rxq->time_high;
    1801                 :          0 :                                         rxq->hw_time_low = rxq->time_high;
    1802                 :            :                                 }
    1803                 :          0 :                                 rxq->hw_time_update = rte_get_timer_cycles() /
    1804                 :          0 :                                                      (rte_get_timer_hz() / 1000);
    1805                 :          0 :                                 *RTE_MBUF_DYNFIELD(mb,
    1806                 :            :                                                    rxq->ts_offset,
    1807                 :          0 :                                                    rte_mbuf_timestamp_t *) = ts_ns;
    1808                 :          0 :                                 pkt_flags |= rxq->ts_flag;
    1809                 :            :                         }
    1810                 :            : 
    1811   [ #  #  #  # ]:          0 :                         if (ad->ptp_ena && ((mb->packet_type &
    1812                 :            :                             RTE_PTYPE_L2_MASK) == RTE_PTYPE_L2_ETHER_TIMESYNC)) {
    1813                 :          0 :                                 rxq->time_high =
    1814                 :          0 :                                    rte_le_to_cpu_32(rxdp[j].wb.flex_ts.ts_high);
    1815                 :          0 :                                 mb->timesync = rxq->queue_id;
    1816                 :          0 :                                 pkt_flags |= RTE_MBUF_F_RX_IEEE1588_PTP;
    1817         [ #  # ]:          0 :                                 if (rxdp[j].wb.time_stamp_low &
    1818                 :            :                                     ICE_PTP_TS_VALID)
    1819                 :          0 :                                         pkt_flags |=
    1820                 :            :                                                 RTE_MBUF_F_RX_IEEE1588_TMST;
    1821                 :            :                         }
    1822                 :            : #endif
    1823                 :          0 :                         mb->ol_flags |= pkt_flags;
    1824                 :            :                 }
    1825                 :            : 
    1826         [ #  # ]:          0 :                 for (j = 0; j < ICE_LOOK_AHEAD; j++)
    1827                 :          0 :                         rxq->rx_stage[i + j] = rxep[j].mbuf;
    1828                 :            : 
    1829         [ #  # ]:          0 :                 if (nb_dd != ICE_LOOK_AHEAD)
    1830                 :            :                         break;
    1831                 :            :         }
    1832                 :            : 
    1833                 :            :         /* Clear software ring entries */
    1834         [ #  # ]:          0 :         for (i = 0; i < nb_rx; i++)
    1835                 :          0 :                 rxq->sw_ring[rxq->rx_tail + i].mbuf = NULL;
    1836                 :            : 
    1837                 :            :         PMD_RX_LOG(DEBUG, "ice_rx_scan_hw_ring: "
    1838                 :            :                    "port_id=%u, queue_id=%u, nb_rx=%d",
    1839                 :            :                    rxq->port_id, rxq->queue_id, nb_rx);
    1840                 :            : 
    1841                 :            :         return nb_rx;
    1842                 :            : }
    1843                 :            : 
    1844                 :            : static inline uint16_t
    1845                 :            : ice_rx_fill_from_stage(struct ice_rx_queue *rxq,
    1846                 :            :                        struct rte_mbuf **rx_pkts,
    1847                 :            :                        uint16_t nb_pkts)
    1848                 :            : {
    1849                 :            :         uint16_t i;
    1850                 :          0 :         struct rte_mbuf **stage = &rxq->rx_stage[rxq->rx_next_avail];
    1851                 :            : 
    1852                 :          0 :         nb_pkts = (uint16_t)RTE_MIN(nb_pkts, rxq->rx_nb_avail);
    1853                 :            : 
    1854   [ #  #  #  # ]:          0 :         for (i = 0; i < nb_pkts; i++)
    1855                 :          0 :                 rx_pkts[i] = stage[i];
    1856                 :            : 
    1857                 :          0 :         rxq->rx_nb_avail = (uint16_t)(rxq->rx_nb_avail - nb_pkts);
    1858                 :          0 :         rxq->rx_next_avail = (uint16_t)(rxq->rx_next_avail + nb_pkts);
    1859                 :            : 
    1860                 :            :         return nb_pkts;
    1861                 :            : }
    1862                 :            : 
    1863                 :            : static inline int
    1864                 :          0 : ice_rx_alloc_bufs(struct ice_rx_queue *rxq)
    1865                 :            : {
    1866                 :            :         volatile union ice_rx_flex_desc *rxdp;
    1867                 :            :         struct ice_rx_entry *rxep;
    1868                 :            :         struct rte_mbuf *mb;
    1869                 :            :         uint16_t alloc_idx, i;
    1870                 :            :         uint64_t dma_addr;
    1871                 :            :         int diag, diag_pay;
    1872                 :            :         uint64_t pay_addr;
    1873                 :            : 
    1874                 :            :         /* Allocate buffers in bulk */
    1875                 :          0 :         alloc_idx = (uint16_t)(rxq->rx_free_trigger -
    1876                 :          0 :                                (rxq->rx_free_thresh - 1));
    1877                 :          0 :         rxep = &rxq->sw_ring[alloc_idx];
    1878         [ #  # ]:          0 :         diag = rte_mempool_get_bulk(rxq->mp, (void *)rxep,
    1879                 :            :                                     rxq->rx_free_thresh);
    1880         [ #  # ]:          0 :         if (unlikely(diag != 0)) {
    1881                 :            :                 PMD_RX_LOG(ERR, "Failed to get mbufs in bulk");
    1882                 :            :                 return -ENOMEM;
    1883                 :            :         }
    1884                 :            : 
    1885         [ #  # ]:          0 :         if (rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) {
    1886                 :          0 :                 diag_pay = rte_mempool_get_bulk(rxq->rxseg[1].mp,
    1887         [ #  # ]:          0 :                                 (void *)rxq->sw_split_buf, rxq->rx_free_thresh);
    1888         [ #  # ]:          0 :                 if (unlikely(diag_pay != 0)) {
    1889                 :          0 :                         rte_mempool_put_bulk(rxq->mp, (void *)rxep,
    1890         [ #  # ]:          0 :                                     rxq->rx_free_thresh);
    1891                 :            :                         PMD_RX_LOG(ERR, "Failed to get payload mbufs in bulk");
    1892                 :          0 :                         return -ENOMEM;
    1893                 :            :                 }
    1894                 :            :         }
    1895                 :            : 
    1896                 :          0 :         rxdp = &rxq->rx_ring[alloc_idx];
    1897         [ #  # ]:          0 :         for (i = 0; i < rxq->rx_free_thresh; i++) {
    1898         [ #  # ]:          0 :                 if (likely(i < (rxq->rx_free_thresh - 1)))
    1899                 :            :                         /* Prefetch next mbuf */
    1900                 :          0 :                         rte_prefetch0(rxep[i + 1].mbuf);
    1901                 :            : 
    1902         [ #  # ]:          0 :                 mb = rxep[i].mbuf;
    1903                 :            :                 rte_mbuf_refcnt_set(mb, 1);
    1904                 :          0 :                 mb->data_off = RTE_PKTMBUF_HEADROOM;
    1905                 :          0 :                 mb->nb_segs = 1;
    1906         [ #  # ]:          0 :                 mb->port = rxq->port_id;
    1907                 :            :                 dma_addr = rte_cpu_to_le_64(rte_mbuf_data_iova_default(mb));
    1908                 :            : 
    1909         [ #  # ]:          0 :                 if (!(rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)) {
    1910                 :          0 :                         mb->next = NULL;
    1911                 :          0 :                         rxdp[i].read.hdr_addr = 0;
    1912                 :          0 :                         rxdp[i].read.pkt_addr = dma_addr;
    1913                 :            :                 } else {
    1914                 :          0 :                         mb->next = rxq->sw_split_buf[i].mbuf;
    1915                 :            :                         pay_addr = rte_cpu_to_le_64(rte_mbuf_data_iova_default(mb->next));
    1916                 :          0 :                         rxdp[i].read.hdr_addr = dma_addr;
    1917                 :          0 :                         rxdp[i].read.pkt_addr = pay_addr;
    1918                 :            :                 }
    1919                 :            :         }
    1920                 :            : 
    1921                 :            :         /* Update Rx tail register */
    1922                 :          0 :         ICE_PCI_REG_WRITE(rxq->qrx_tail, rxq->rx_free_trigger);
    1923                 :            : 
    1924                 :          0 :         rxq->rx_free_trigger =
    1925                 :          0 :                 (uint16_t)(rxq->rx_free_trigger + rxq->rx_free_thresh);
    1926         [ #  # ]:          0 :         if (rxq->rx_free_trigger >= rxq->nb_rx_desc)
    1927                 :          0 :                 rxq->rx_free_trigger = (uint16_t)(rxq->rx_free_thresh - 1);
    1928                 :            : 
    1929                 :            :         return 0;
    1930                 :            : }
    1931                 :            : 
    1932                 :            : static inline uint16_t
    1933                 :          0 : rx_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
    1934                 :            : {
    1935                 :            :         struct ice_rx_queue *rxq = (struct ice_rx_queue *)rx_queue;
    1936                 :            :         uint16_t nb_rx = 0;
    1937                 :            : 
    1938         [ #  # ]:          0 :         if (!nb_pkts)
    1939                 :            :                 return 0;
    1940                 :            : 
    1941         [ #  # ]:          0 :         if (rxq->rx_nb_avail)
    1942                 :          0 :                 return ice_rx_fill_from_stage(rxq, rx_pkts, nb_pkts);
    1943                 :            : 
    1944                 :          0 :         nb_rx = (uint16_t)ice_rx_scan_hw_ring(rxq);
    1945                 :          0 :         rxq->rx_next_avail = 0;
    1946                 :          0 :         rxq->rx_nb_avail = nb_rx;
    1947                 :          0 :         rxq->rx_tail = (uint16_t)(rxq->rx_tail + nb_rx);
    1948                 :            : 
    1949         [ #  # ]:          0 :         if (rxq->rx_tail > rxq->rx_free_trigger) {
    1950         [ #  # ]:          0 :                 if (ice_rx_alloc_bufs(rxq) != 0) {
    1951                 :            :                         uint16_t i, j;
    1952                 :            : 
    1953                 :          0 :                         rxq->vsi->adapter->pf.dev_data->rx_mbuf_alloc_failed +=
    1954                 :          0 :                                 rxq->rx_free_thresh;
    1955                 :            :                         PMD_RX_LOG(DEBUG, "Rx mbuf alloc failed for "
    1956                 :            :                                    "port_id=%u, queue_id=%u",
    1957                 :            :                                    rxq->port_id, rxq->queue_id);
    1958                 :          0 :                         rxq->rx_nb_avail = 0;
    1959                 :          0 :                         rxq->rx_tail = (uint16_t)(rxq->rx_tail - nb_rx);
    1960         [ #  # ]:          0 :                         for (i = 0, j = rxq->rx_tail; i < nb_rx; i++, j++)
    1961                 :          0 :                                 rxq->sw_ring[j].mbuf = rxq->rx_stage[i];
    1962                 :            : 
    1963                 :            :                         return 0;
    1964                 :            :                 }
    1965                 :            :         }
    1966                 :            : 
    1967         [ #  # ]:          0 :         if (rxq->rx_tail >= rxq->nb_rx_desc)
    1968                 :          0 :                 rxq->rx_tail = 0;
    1969                 :            : 
    1970         [ #  # ]:          0 :         if (rxq->rx_nb_avail)
    1971                 :          0 :                 return ice_rx_fill_from_stage(rxq, rx_pkts, nb_pkts);
    1972                 :            : 
    1973                 :            :         return 0;
    1974                 :            : }
    1975                 :            : 
    1976                 :            : static uint16_t
    1977                 :          0 : ice_recv_pkts_bulk_alloc(void *rx_queue,
    1978                 :            :                          struct rte_mbuf **rx_pkts,
    1979                 :            :                          uint16_t nb_pkts)
    1980                 :            : {
    1981                 :            :         uint16_t nb_rx = 0;
    1982                 :            :         uint16_t n;
    1983                 :            :         uint16_t count;
    1984                 :            : 
    1985         [ #  # ]:          0 :         if (unlikely(nb_pkts == 0))
    1986                 :            :                 return nb_rx;
    1987                 :            : 
    1988         [ #  # ]:          0 :         if (likely(nb_pkts <= ICE_RX_MAX_BURST))
    1989                 :          0 :                 return rx_recv_pkts(rx_queue, rx_pkts, nb_pkts);
    1990                 :            : 
    1991         [ #  # ]:          0 :         while (nb_pkts) {
    1992                 :          0 :                 n = RTE_MIN(nb_pkts, ICE_RX_MAX_BURST);
    1993                 :          0 :                 count = rx_recv_pkts(rx_queue, &rx_pkts[nb_rx], n);
    1994                 :          0 :                 nb_rx = (uint16_t)(nb_rx + count);
    1995                 :          0 :                 nb_pkts = (uint16_t)(nb_pkts - count);
    1996         [ #  # ]:          0 :                 if (count < n)
    1997                 :            :                         break;
    1998                 :            :         }
    1999                 :            : 
    2000                 :            :         return nb_rx;
    2001                 :            : }
    2002                 :            : 
    2003                 :            : static uint16_t
    2004                 :          0 : ice_recv_scattered_pkts(void *rx_queue,
    2005                 :            :                         struct rte_mbuf **rx_pkts,
    2006                 :            :                         uint16_t nb_pkts)
    2007                 :            : {
    2008                 :            :         struct ice_rx_queue *rxq = rx_queue;
    2009                 :          0 :         volatile union ice_rx_flex_desc *rx_ring = rxq->rx_ring;
    2010                 :            :         volatile union ice_rx_flex_desc *rxdp;
    2011                 :            :         union ice_rx_flex_desc rxd;
    2012                 :          0 :         struct ice_rx_entry *sw_ring = rxq->sw_ring;
    2013                 :            :         struct ice_rx_entry *rxe;
    2014                 :          0 :         struct rte_mbuf *first_seg = rxq->pkt_first_seg;
    2015                 :          0 :         struct rte_mbuf *last_seg = rxq->pkt_last_seg;
    2016                 :            :         struct rte_mbuf *nmb; /* new allocated mbuf */
    2017                 :            :         struct rte_mbuf *rxm; /* pointer to store old mbuf in SW ring */
    2018                 :          0 :         uint16_t rx_id = rxq->rx_tail;
    2019                 :            :         uint16_t nb_rx = 0;
    2020                 :            :         uint16_t nb_hold = 0;
    2021                 :            :         uint16_t rx_packet_len;
    2022                 :            :         uint16_t rx_stat_err0;
    2023                 :            :         uint64_t dma_addr;
    2024                 :            :         uint64_t pkt_flags;
    2025                 :          0 :         uint32_t *ptype_tbl = rxq->vsi->adapter->ptype_tbl;
    2026                 :            : #ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC
    2027                 :            :         bool is_tsinit = false;
    2028                 :            :         uint64_t ts_ns;
    2029                 :            :         struct ice_vsi *vsi = rxq->vsi;
    2030                 :          0 :         struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
    2031                 :            :         struct ice_adapter *ad = rxq->vsi->adapter;
    2032                 :            : 
    2033         [ #  # ]:          0 :         if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) {
    2034                 :          0 :                 uint64_t sw_cur_time = rte_get_timer_cycles() / (rte_get_timer_hz() / 1000);
    2035                 :            : 
    2036         [ #  # ]:          0 :                 if (unlikely(sw_cur_time - rxq->hw_time_update > 4))
    2037                 :            :                         is_tsinit = true;
    2038                 :            :         }
    2039                 :            : #endif
    2040                 :            : 
    2041         [ #  # ]:          0 :         while (nb_rx < nb_pkts) {
    2042                 :          0 :                 rxdp = &rx_ring[rx_id];
    2043                 :          0 :                 rx_stat_err0 = rte_le_to_cpu_16(rxdp->wb.status_error0);
    2044                 :            : 
    2045                 :            :                 /* Check the DD bit first */
    2046         [ #  # ]:          0 :                 if (!(rx_stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_DD_S)))
    2047                 :            :                         break;
    2048                 :            : 
    2049                 :            :                 /* allocate mbuf */
    2050                 :          0 :                 nmb = rte_mbuf_raw_alloc(rxq->mp);
    2051         [ #  # ]:          0 :                 if (unlikely(!nmb)) {
    2052                 :          0 :                         rxq->vsi->adapter->pf.dev_data->rx_mbuf_alloc_failed++;
    2053                 :          0 :                         break;
    2054                 :            :                 }
    2055                 :          0 :                 rxd = *rxdp; /* copy descriptor in ring to temp variable*/
    2056                 :            : 
    2057                 :          0 :                 nb_hold++;
    2058                 :          0 :                 rxe = &sw_ring[rx_id]; /* get corresponding mbuf in SW ring */
    2059                 :          0 :                 rx_id++;
    2060         [ #  # ]:          0 :                 if (unlikely(rx_id == rxq->nb_rx_desc))
    2061                 :            :                         rx_id = 0;
    2062                 :            : 
    2063                 :            :                 /* Prefetch next mbuf */
    2064                 :          0 :                 rte_prefetch0(sw_ring[rx_id].mbuf);
    2065                 :            : 
    2066                 :            :                 /**
    2067                 :            :                  * When next RX descriptor is on a cache line boundary,
    2068                 :            :                  * prefetch the next 4 RX descriptors and next 8 pointers
    2069                 :            :                  * to mbufs.
    2070                 :            :                  */
    2071         [ #  # ]:          0 :                 if ((rx_id & 0x3) == 0) {
    2072                 :          0 :                         rte_prefetch0(&rx_ring[rx_id]);
    2073                 :            :                         rte_prefetch0(&sw_ring[rx_id]);
    2074                 :            :                 }
    2075                 :            : 
    2076                 :          0 :                 rxm = rxe->mbuf;
    2077         [ #  # ]:          0 :                 rxe->mbuf = nmb;
    2078                 :            :                 dma_addr =
    2079                 :            :                         rte_cpu_to_le_64(rte_mbuf_data_iova_default(nmb));
    2080                 :            : 
    2081                 :            :                 /* Set data buffer address and data length of the mbuf */
    2082                 :          0 :                 rxdp->read.hdr_addr = 0;
    2083                 :          0 :                 rxdp->read.pkt_addr = dma_addr;
    2084                 :          0 :                 rx_packet_len = rte_le_to_cpu_16(rxd.wb.pkt_len) &
    2085                 :            :                                 ICE_RX_FLX_DESC_PKT_LEN_M;
    2086                 :          0 :                 rxm->data_len = rx_packet_len;
    2087                 :          0 :                 rxm->data_off = RTE_PKTMBUF_HEADROOM;
    2088                 :            : 
    2089                 :            :                 /**
    2090                 :            :                  * If this is the first buffer of the received packet, set the
    2091                 :            :                  * pointer to the first mbuf of the packet and initialize its
    2092                 :            :                  * context. Otherwise, update the total length and the number
    2093                 :            :                  * of segments of the current scattered packet, and update the
    2094                 :            :                  * pointer to the last mbuf of the current packet.
    2095                 :            :                  */
    2096         [ #  # ]:          0 :                 if (!first_seg) {
    2097                 :            :                         first_seg = rxm;
    2098                 :          0 :                         first_seg->nb_segs = 1;
    2099                 :          0 :                         first_seg->pkt_len = rx_packet_len;
    2100                 :            :                 } else {
    2101                 :          0 :                         first_seg->pkt_len =
    2102                 :          0 :                                 (uint16_t)(first_seg->pkt_len +
    2103                 :            :                                            rx_packet_len);
    2104                 :          0 :                         first_seg->nb_segs++;
    2105                 :          0 :                         last_seg->next = rxm;
    2106                 :            :                 }
    2107                 :            : 
    2108                 :            :                 /**
    2109                 :            :                  * If this is not the last buffer of the received packet,
    2110                 :            :                  * update the pointer to the last mbuf of the current scattered
    2111                 :            :                  * packet and continue to parse the RX ring.
    2112                 :            :                  */
    2113         [ #  # ]:          0 :                 if (!(rx_stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_EOF_S))) {
    2114                 :            :                         last_seg = rxm;
    2115                 :          0 :                         continue;
    2116                 :            :                 }
    2117                 :            : 
    2118                 :            :                 /**
    2119                 :            :                  * This is the last buffer of the received packet. If the CRC
    2120                 :            :                  * is not stripped by the hardware:
    2121                 :            :                  *  - Subtract the CRC length from the total packet length.
    2122                 :            :                  *  - If the last buffer only contains the whole CRC or a part
    2123                 :            :                  *  of it, free the mbuf associated to the last buffer. If part
    2124                 :            :                  *  of the CRC is also contained in the previous mbuf, subtract
    2125                 :            :                  *  the length of that CRC part from the data length of the
    2126                 :            :                  *  previous mbuf.
    2127                 :            :                  */
    2128                 :          0 :                 rxm->next = NULL;
    2129         [ #  # ]:          0 :                 if (unlikely(rxq->crc_len > 0)) {
    2130                 :          0 :                         first_seg->pkt_len -= RTE_ETHER_CRC_LEN;
    2131         [ #  # ]:          0 :                         if (rx_packet_len <= RTE_ETHER_CRC_LEN) {
    2132                 :            :                                 rte_pktmbuf_free_seg(rxm);
    2133                 :          0 :                                 first_seg->nb_segs--;
    2134                 :          0 :                                 last_seg->data_len =
    2135                 :          0 :                                         (uint16_t)(last_seg->data_len -
    2136                 :            :                                         (RTE_ETHER_CRC_LEN - rx_packet_len));
    2137                 :          0 :                                 last_seg->next = NULL;
    2138                 :            :                         } else
    2139                 :          0 :                                 rxm->data_len = (uint16_t)(rx_packet_len -
    2140                 :            :                                                            RTE_ETHER_CRC_LEN);
    2141         [ #  # ]:          0 :                 } else if (rx_packet_len == 0) {
    2142                 :            :                         rte_pktmbuf_free_seg(rxm);
    2143                 :          0 :                         first_seg->nb_segs--;
    2144                 :          0 :                         last_seg->next = NULL;
    2145                 :            :                 }
    2146                 :            : 
    2147                 :          0 :                 first_seg->port = rxq->port_id;
    2148                 :          0 :                 first_seg->ol_flags = 0;
    2149                 :          0 :                 first_seg->packet_type = ptype_tbl[ICE_RX_FLEX_DESC_PTYPE_M &
    2150         [ #  # ]:          0 :                         rte_le_to_cpu_16(rxd.wb.ptype_flex_flags0)];
    2151                 :            :                 ice_rxd_to_vlan_tci(first_seg, &rxd);
    2152                 :          0 :                 rxd_to_pkt_fields_ops[rxq->rxdid](rxq, first_seg, &rxd);
    2153                 :          0 :                 pkt_flags = ice_rxd_error_to_pkt_flags(rx_stat_err0);
    2154                 :            : #ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC
    2155         [ #  # ]:          0 :                 if (rxq->ts_flag > 0 &&
    2156         [ #  # ]:          0 :                     (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)) {
    2157                 :          0 :                         rxq->time_high =
    2158                 :          0 :                            rte_le_to_cpu_32(rxd.wb.flex_ts.ts_high);
    2159         [ #  # ]:          0 :                         if (unlikely(is_tsinit)) {
    2160                 :          0 :                                 ts_ns = ice_tstamp_convert_32b_64b(hw, ad, 1, rxq->time_high);
    2161                 :          0 :                                 rxq->hw_time_low = (uint32_t)ts_ns;
    2162                 :          0 :                                 rxq->hw_time_high = (uint32_t)(ts_ns >> 32);
    2163                 :            :                                 is_tsinit = false;
    2164                 :            :                         } else {
    2165         [ #  # ]:          0 :                                 if (rxq->time_high < rxq->hw_time_low)
    2166                 :          0 :                                         rxq->hw_time_high += 1;
    2167                 :          0 :                                 ts_ns = (uint64_t)rxq->hw_time_high << 32 | rxq->time_high;
    2168                 :          0 :                                 rxq->hw_time_low = rxq->time_high;
    2169                 :            :                         }
    2170                 :          0 :                         rxq->hw_time_update = rte_get_timer_cycles() /
    2171                 :          0 :                                              (rte_get_timer_hz() / 1000);
    2172                 :          0 :                         *RTE_MBUF_DYNFIELD(first_seg,
    2173                 :            :                                            (rxq->ts_offset),
    2174                 :          0 :                                            rte_mbuf_timestamp_t *) = ts_ns;
    2175                 :          0 :                         pkt_flags |= rxq->ts_flag;
    2176                 :            :                 }
    2177                 :            : 
    2178   [ #  #  #  # ]:          0 :                 if (ad->ptp_ena && ((first_seg->packet_type & RTE_PTYPE_L2_MASK)
    2179                 :            :                     == RTE_PTYPE_L2_ETHER_TIMESYNC)) {
    2180                 :          0 :                         rxq->time_high =
    2181                 :          0 :                            rte_le_to_cpu_32(rxd.wb.flex_ts.ts_high);
    2182                 :          0 :                         first_seg->timesync = rxq->queue_id;
    2183                 :          0 :                         pkt_flags |= RTE_MBUF_F_RX_IEEE1588_PTP;
    2184                 :            :                 }
    2185                 :            : #endif
    2186                 :          0 :                 first_seg->ol_flags |= pkt_flags;
    2187                 :            :                 /* Prefetch data of first segment, if configured to do so. */
    2188                 :          0 :                 rte_prefetch0(RTE_PTR_ADD(first_seg->buf_addr,
    2189                 :            :                                           first_seg->data_off));
    2190                 :          0 :                 rx_pkts[nb_rx++] = first_seg;
    2191                 :            :                 first_seg = NULL;
    2192                 :            :         }
    2193                 :            : 
    2194                 :            :         /* Record index of the next RX descriptor to probe. */
    2195                 :          0 :         rxq->rx_tail = rx_id;
    2196                 :          0 :         rxq->pkt_first_seg = first_seg;
    2197                 :          0 :         rxq->pkt_last_seg = last_seg;
    2198                 :            : 
    2199                 :            :         /**
    2200                 :            :          * If the number of free RX descriptors is greater than the RX free
    2201                 :            :          * threshold of the queue, advance the Receive Descriptor Tail (RDT)
    2202                 :            :          * register. Update the RDT with the value of the last processed RX
    2203                 :            :          * descriptor minus 1, to guarantee that the RDT register is never
    2204                 :            :          * equal to the RDH register, which creates a "full" ring situation
    2205                 :            :          * from the hardware point of view.
    2206                 :            :          */
    2207                 :          0 :         nb_hold = (uint16_t)(nb_hold + rxq->nb_rx_hold);
    2208         [ #  # ]:          0 :         if (nb_hold > rxq->rx_free_thresh) {
    2209         [ #  # ]:          0 :                 rx_id = (uint16_t)(rx_id == 0 ?
    2210                 :          0 :                                    (rxq->nb_rx_desc - 1) : (rx_id - 1));
    2211                 :            :                 /* write TAIL register */
    2212                 :          0 :                 ICE_PCI_REG_WC_WRITE(rxq->qrx_tail, rx_id);
    2213                 :            :                 nb_hold = 0;
    2214                 :            :         }
    2215                 :          0 :         rxq->nb_rx_hold = nb_hold;
    2216                 :            : 
    2217                 :            :         /* return received packet in the burst */
    2218                 :          0 :         return nb_rx;
    2219                 :            : }
    2220                 :            : 
    2221                 :            : const uint32_t *
    2222                 :          0 : ice_dev_supported_ptypes_get(struct rte_eth_dev *dev, size_t *no_of_elements)
    2223                 :            : {
    2224                 :          0 :         struct ice_adapter *ad =
    2225                 :          0 :                 ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
    2226                 :            :         const uint32_t *ptypes;
    2227                 :            : 
    2228                 :            :         static const uint32_t ptypes_os[] = {
    2229                 :            :                 /* refers to ice_get_default_pkt_type() */
    2230                 :            :                 RTE_PTYPE_L2_ETHER,
    2231                 :            :                 RTE_PTYPE_L2_ETHER_TIMESYNC,
    2232                 :            :                 RTE_PTYPE_L2_ETHER_LLDP,
    2233                 :            :                 RTE_PTYPE_L2_ETHER_ARP,
    2234                 :            :                 RTE_PTYPE_L3_IPV4_EXT_UNKNOWN,
    2235                 :            :                 RTE_PTYPE_L3_IPV6_EXT_UNKNOWN,
    2236                 :            :                 RTE_PTYPE_L4_FRAG,
    2237                 :            :                 RTE_PTYPE_L4_ICMP,
    2238                 :            :                 RTE_PTYPE_L4_NONFRAG,
    2239                 :            :                 RTE_PTYPE_L4_SCTP,
    2240                 :            :                 RTE_PTYPE_L4_TCP,
    2241                 :            :                 RTE_PTYPE_L4_UDP,
    2242                 :            :                 RTE_PTYPE_TUNNEL_GRENAT,
    2243                 :            :                 RTE_PTYPE_TUNNEL_IP,
    2244                 :            :                 RTE_PTYPE_INNER_L2_ETHER,
    2245                 :            :                 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN,
    2246                 :            :                 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN,
    2247                 :            :                 RTE_PTYPE_INNER_L4_FRAG,
    2248                 :            :                 RTE_PTYPE_INNER_L4_ICMP,
    2249                 :            :                 RTE_PTYPE_INNER_L4_NONFRAG,
    2250                 :            :                 RTE_PTYPE_INNER_L4_SCTP,
    2251                 :            :                 RTE_PTYPE_INNER_L4_TCP,
    2252                 :            :                 RTE_PTYPE_INNER_L4_UDP,
    2253                 :            :         };
    2254                 :            : 
    2255                 :            :         static const uint32_t ptypes_comms[] = {
    2256                 :            :                 /* refers to ice_get_default_pkt_type() */
    2257                 :            :                 RTE_PTYPE_L2_ETHER,
    2258                 :            :                 RTE_PTYPE_L2_ETHER_TIMESYNC,
    2259                 :            :                 RTE_PTYPE_L2_ETHER_LLDP,
    2260                 :            :                 RTE_PTYPE_L2_ETHER_ARP,
    2261                 :            :                 RTE_PTYPE_L3_IPV4_EXT_UNKNOWN,
    2262                 :            :                 RTE_PTYPE_L3_IPV6_EXT_UNKNOWN,
    2263                 :            :                 RTE_PTYPE_L4_FRAG,
    2264                 :            :                 RTE_PTYPE_L4_ICMP,
    2265                 :            :                 RTE_PTYPE_L4_NONFRAG,
    2266                 :            :                 RTE_PTYPE_L4_SCTP,
    2267                 :            :                 RTE_PTYPE_L4_TCP,
    2268                 :            :                 RTE_PTYPE_L4_UDP,
    2269                 :            :                 RTE_PTYPE_TUNNEL_GRENAT,
    2270                 :            :                 RTE_PTYPE_TUNNEL_IP,
    2271                 :            :                 RTE_PTYPE_INNER_L2_ETHER,
    2272                 :            :                 RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN,
    2273                 :            :                 RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN,
    2274                 :            :                 RTE_PTYPE_INNER_L4_FRAG,
    2275                 :            :                 RTE_PTYPE_INNER_L4_ICMP,
    2276                 :            :                 RTE_PTYPE_INNER_L4_NONFRAG,
    2277                 :            :                 RTE_PTYPE_INNER_L4_SCTP,
    2278                 :            :                 RTE_PTYPE_INNER_L4_TCP,
    2279                 :            :                 RTE_PTYPE_INNER_L4_UDP,
    2280                 :            :                 RTE_PTYPE_TUNNEL_GTPC,
    2281                 :            :                 RTE_PTYPE_TUNNEL_GTPU,
    2282                 :            :                 RTE_PTYPE_L2_ETHER_PPPOE,
    2283                 :            :         };
    2284                 :            : 
    2285         [ #  # ]:          0 :         if (ad->active_pkg_type == ICE_PKG_TYPE_COMMS) {
    2286                 :          0 :                 *no_of_elements = RTE_DIM(ptypes_comms);
    2287                 :            :                 ptypes = ptypes_comms;
    2288                 :            :         } else {
    2289                 :          0 :                 *no_of_elements = RTE_DIM(ptypes_os);
    2290                 :            :                 ptypes = ptypes_os;
    2291                 :            :         }
    2292                 :            : 
    2293   [ #  #  #  # ]:          0 :         if (dev->rx_pkt_burst == ice_recv_pkts ||
    2294         [ #  # ]:          0 :             dev->rx_pkt_burst == ice_recv_pkts_bulk_alloc ||
    2295                 :            :             dev->rx_pkt_burst == ice_recv_scattered_pkts)
    2296                 :            :                 return ptypes;
    2297                 :            : 
    2298                 :            : #ifdef RTE_ARCH_X86
    2299   [ #  #  #  # ]:          0 :         if (dev->rx_pkt_burst == ice_recv_pkts_vec ||
    2300         [ #  # ]:          0 :             dev->rx_pkt_burst == ice_recv_scattered_pkts_vec ||
    2301                 :            : #ifdef CC_AVX512_SUPPORT
    2302         [ #  # ]:          0 :             dev->rx_pkt_burst == ice_recv_pkts_vec_avx512 ||
    2303         [ #  # ]:          0 :             dev->rx_pkt_burst == ice_recv_pkts_vec_avx512_offload ||
    2304         [ #  # ]:          0 :             dev->rx_pkt_burst == ice_recv_scattered_pkts_vec_avx512 ||
    2305         [ #  # ]:          0 :             dev->rx_pkt_burst == ice_recv_scattered_pkts_vec_avx512_offload ||
    2306                 :            : #endif
    2307         [ #  # ]:          0 :             dev->rx_pkt_burst == ice_recv_pkts_vec_avx2 ||
    2308         [ #  # ]:          0 :             dev->rx_pkt_burst == ice_recv_pkts_vec_avx2_offload ||
    2309         [ #  # ]:          0 :             dev->rx_pkt_burst == ice_recv_scattered_pkts_vec_avx2 ||
    2310                 :            :             dev->rx_pkt_burst == ice_recv_scattered_pkts_vec_avx2_offload)
    2311                 :          0 :                 return ptypes;
    2312                 :            : #endif
    2313                 :            : 
    2314                 :            :         return NULL;
    2315                 :            : }
    2316                 :            : 
    2317                 :            : int
    2318                 :          0 : ice_rx_descriptor_status(void *rx_queue, uint16_t offset)
    2319                 :            : {
    2320                 :            :         volatile union ice_rx_flex_desc *rxdp;
    2321                 :            :         struct ice_rx_queue *rxq = rx_queue;
    2322                 :            :         uint32_t desc;
    2323                 :            : 
    2324         [ #  # ]:          0 :         if (unlikely(offset >= rxq->nb_rx_desc))
    2325                 :            :                 return -EINVAL;
    2326                 :            : 
    2327         [ #  # ]:          0 :         if (offset >= rxq->nb_rx_desc - rxq->nb_rx_hold)
    2328                 :            :                 return RTE_ETH_RX_DESC_UNAVAIL;
    2329                 :            : 
    2330                 :          0 :         desc = rxq->rx_tail + offset;
    2331         [ #  # ]:          0 :         if (desc >= rxq->nb_rx_desc)
    2332                 :          0 :                 desc -= rxq->nb_rx_desc;
    2333                 :            : 
    2334                 :          0 :         rxdp = &rxq->rx_ring[desc];
    2335         [ #  # ]:          0 :         if (rte_le_to_cpu_16(rxdp->wb.status_error0) &
    2336                 :            :             (1 << ICE_RX_FLEX_DESC_STATUS0_DD_S))
    2337                 :          0 :                 return RTE_ETH_RX_DESC_DONE;
    2338                 :            : 
    2339                 :            :         return RTE_ETH_RX_DESC_AVAIL;
    2340                 :            : }
    2341                 :            : 
    2342                 :            : int
    2343                 :          0 : ice_tx_descriptor_status(void *tx_queue, uint16_t offset)
    2344                 :            : {
    2345                 :            :         struct ci_tx_queue *txq = tx_queue;
    2346                 :            :         volatile uint64_t *status;
    2347                 :            :         uint64_t mask, expect;
    2348                 :            :         uint32_t desc;
    2349                 :            : 
    2350         [ #  # ]:          0 :         if (unlikely(offset >= txq->nb_tx_desc))
    2351                 :            :                 return -EINVAL;
    2352                 :            : 
    2353                 :          0 :         desc = txq->tx_tail + offset;
    2354                 :            :         /* go to next desc that has the RS bit */
    2355                 :          0 :         desc = ((desc + txq->tx_rs_thresh - 1) / txq->tx_rs_thresh) *
    2356                 :            :                 txq->tx_rs_thresh;
    2357         [ #  # ]:          0 :         if (desc >= txq->nb_tx_desc) {
    2358                 :          0 :                 desc -= txq->nb_tx_desc;
    2359         [ #  # ]:          0 :                 if (desc >= txq->nb_tx_desc)
    2360                 :          0 :                         desc -= txq->nb_tx_desc;
    2361                 :            :         }
    2362                 :            : 
    2363                 :          0 :         status = &txq->ice_tx_ring[desc].cmd_type_offset_bsz;
    2364                 :            :         mask = rte_cpu_to_le_64(ICE_TXD_QW1_DTYPE_M);
    2365                 :            :         expect = rte_cpu_to_le_64(ICE_TX_DESC_DTYPE_DESC_DONE <<
    2366                 :            :                                   ICE_TXD_QW1_DTYPE_S);
    2367         [ #  # ]:          0 :         if ((*status & mask) == expect)
    2368                 :          0 :                 return RTE_ETH_TX_DESC_DONE;
    2369                 :            : 
    2370                 :            :         return RTE_ETH_TX_DESC_FULL;
    2371                 :            : }
    2372                 :            : 
    2373                 :            : void
    2374                 :          0 : ice_free_queues(struct rte_eth_dev *dev)
    2375                 :            : {
    2376                 :            :         uint16_t i;
    2377                 :            : 
    2378                 :          0 :         PMD_INIT_FUNC_TRACE();
    2379                 :            : 
    2380         [ #  # ]:          0 :         for (i = 0; i < dev->data->nb_rx_queues; i++) {
    2381         [ #  # ]:          0 :                 if (!dev->data->rx_queues[i])
    2382                 :          0 :                         continue;
    2383                 :          0 :                 ice_rx_queue_release(dev->data->rx_queues[i]);
    2384                 :          0 :                 dev->data->rx_queues[i] = NULL;
    2385                 :            :         }
    2386                 :          0 :         dev->data->nb_rx_queues = 0;
    2387                 :            : 
    2388         [ #  # ]:          0 :         for (i = 0; i < dev->data->nb_tx_queues; i++) {
    2389         [ #  # ]:          0 :                 if (!dev->data->tx_queues[i])
    2390                 :          0 :                         continue;
    2391                 :          0 :                 ice_tx_queue_release(dev->data->tx_queues[i]);
    2392                 :          0 :                 dev->data->tx_queues[i] = NULL;
    2393                 :            :         }
    2394                 :          0 :         dev->data->nb_tx_queues = 0;
    2395                 :          0 : }
    2396                 :            : 
    2397                 :            : #define ICE_FDIR_NUM_TX_DESC  ICE_MIN_RING_DESC
    2398                 :            : #define ICE_FDIR_NUM_RX_DESC  ICE_MIN_RING_DESC
    2399                 :            : 
    2400                 :            : int
    2401                 :          0 : ice_fdir_setup_tx_resources(struct ice_pf *pf)
    2402                 :            : {
    2403                 :            :         struct ci_tx_queue *txq;
    2404                 :            :         const struct rte_memzone *tz = NULL;
    2405                 :            :         uint32_t ring_size;
    2406                 :            :         struct rte_eth_dev *dev;
    2407                 :            : 
    2408         [ #  # ]:          0 :         if (!pf) {
    2409                 :          0 :                 PMD_DRV_LOG(ERR, "PF is not available");
    2410                 :          0 :                 return -EINVAL;
    2411                 :            :         }
    2412                 :            : 
    2413                 :          0 :         dev = &rte_eth_devices[pf->adapter->pf.dev_data->port_id];
    2414                 :            : 
    2415                 :            :         /* Allocate the TX queue data structure. */
    2416                 :          0 :         txq = rte_zmalloc_socket("ice fdir tx queue",
    2417                 :            :                                  sizeof(struct ci_tx_queue),
    2418                 :            :                                  RTE_CACHE_LINE_SIZE,
    2419                 :            :                                  SOCKET_ID_ANY);
    2420         [ #  # ]:          0 :         if (!txq) {
    2421                 :          0 :                 PMD_DRV_LOG(ERR, "Failed to allocate memory for "
    2422                 :            :                             "tx queue structure.");
    2423                 :          0 :                 return -ENOMEM;
    2424                 :            :         }
    2425                 :            : 
    2426                 :            :         /* Allocate TX hardware ring descriptors. */
    2427                 :            :         ring_size = sizeof(struct ice_tx_desc) * ICE_FDIR_NUM_TX_DESC;
    2428                 :            :         ring_size = RTE_ALIGN(ring_size, ICE_DMA_MEM_ALIGN);
    2429                 :            : 
    2430                 :          0 :         tz = rte_eth_dma_zone_reserve(dev, "fdir_tx_ring",
    2431                 :            :                                       ICE_FDIR_QUEUE_ID, ring_size,
    2432                 :            :                                       ICE_RING_BASE_ALIGN, SOCKET_ID_ANY);
    2433         [ #  # ]:          0 :         if (!tz) {
    2434                 :          0 :                 ice_tx_queue_release(txq);
    2435                 :          0 :                 PMD_DRV_LOG(ERR, "Failed to reserve DMA memory for TX.");
    2436                 :          0 :                 return -ENOMEM;
    2437                 :            :         }
    2438                 :            : 
    2439                 :          0 :         txq->mz = tz;
    2440                 :          0 :         txq->nb_tx_desc = ICE_FDIR_NUM_TX_DESC;
    2441                 :          0 :         txq->queue_id = ICE_FDIR_QUEUE_ID;
    2442                 :          0 :         txq->reg_idx = pf->fdir.fdir_vsi->base_queue;
    2443                 :          0 :         txq->ice_vsi = pf->fdir.fdir_vsi;
    2444                 :            : 
    2445                 :          0 :         txq->tx_ring_dma = tz->iova;
    2446                 :          0 :         txq->ice_tx_ring = (struct ice_tx_desc *)tz->addr;
    2447                 :            :         /*
    2448                 :            :          * don't need to allocate software ring and reset for the fdir
    2449                 :            :          * program queue just set the queue has been configured.
    2450                 :            :          */
    2451                 :          0 :         txq->q_set = true;
    2452                 :          0 :         pf->fdir.txq = txq;
    2453                 :            : 
    2454                 :            : 
    2455                 :          0 :         return ICE_SUCCESS;
    2456                 :            : }
    2457                 :            : 
    2458                 :            : int
    2459                 :          0 : ice_fdir_setup_rx_resources(struct ice_pf *pf)
    2460                 :            : {
    2461                 :            :         struct ice_rx_queue *rxq;
    2462                 :            :         const struct rte_memzone *rz = NULL;
    2463                 :            :         uint32_t ring_size;
    2464                 :            :         struct rte_eth_dev *dev;
    2465                 :            : 
    2466         [ #  # ]:          0 :         if (!pf) {
    2467                 :          0 :                 PMD_DRV_LOG(ERR, "PF is not available");
    2468                 :          0 :                 return -EINVAL;
    2469                 :            :         }
    2470                 :            : 
    2471                 :          0 :         dev = &rte_eth_devices[pf->adapter->pf.dev_data->port_id];
    2472                 :            : 
    2473                 :            :         /* Allocate the RX queue data structure. */
    2474                 :          0 :         rxq = rte_zmalloc_socket("ice fdir rx queue",
    2475                 :            :                                  sizeof(struct ice_rx_queue),
    2476                 :            :                                  RTE_CACHE_LINE_SIZE,
    2477                 :            :                                  SOCKET_ID_ANY);
    2478         [ #  # ]:          0 :         if (!rxq) {
    2479                 :          0 :                 PMD_DRV_LOG(ERR, "Failed to allocate memory for "
    2480                 :            :                             "rx queue structure.");
    2481                 :          0 :                 return -ENOMEM;
    2482                 :            :         }
    2483                 :            : 
    2484                 :            :         /* Allocate RX hardware ring descriptors. */
    2485                 :            :         ring_size = sizeof(union ice_32byte_rx_desc) * ICE_FDIR_NUM_RX_DESC;
    2486                 :            :         ring_size = RTE_ALIGN(ring_size, ICE_DMA_MEM_ALIGN);
    2487                 :            : 
    2488                 :          0 :         rz = rte_eth_dma_zone_reserve(dev, "fdir_rx_ring",
    2489                 :            :                                       ICE_FDIR_QUEUE_ID, ring_size,
    2490                 :            :                                       ICE_RING_BASE_ALIGN, SOCKET_ID_ANY);
    2491         [ #  # ]:          0 :         if (!rz) {
    2492                 :          0 :                 ice_rx_queue_release(rxq);
    2493                 :          0 :                 PMD_DRV_LOG(ERR, "Failed to reserve DMA memory for RX.");
    2494                 :          0 :                 return -ENOMEM;
    2495                 :            :         }
    2496                 :            : 
    2497                 :          0 :         rxq->mz = rz;
    2498                 :          0 :         rxq->nb_rx_desc = ICE_FDIR_NUM_RX_DESC;
    2499                 :          0 :         rxq->queue_id = ICE_FDIR_QUEUE_ID;
    2500                 :          0 :         rxq->reg_idx = pf->fdir.fdir_vsi->base_queue;
    2501                 :          0 :         rxq->vsi = pf->fdir.fdir_vsi;
    2502                 :            : 
    2503                 :          0 :         rxq->rx_ring_dma = rz->iova;
    2504                 :          0 :         memset(rz->addr, 0, ICE_FDIR_NUM_RX_DESC *
    2505                 :            :                sizeof(union ice_32byte_rx_desc));
    2506                 :          0 :         rxq->rx_ring = (union ice_rx_flex_desc *)rz->addr;
    2507                 :            : 
    2508                 :            :         /*
    2509                 :            :          * Don't need to allocate software ring and reset for the fdir
    2510                 :            :          * rx queue, just set the queue has been configured.
    2511                 :            :          */
    2512                 :          0 :         rxq->q_set = true;
    2513                 :          0 :         pf->fdir.rxq = rxq;
    2514                 :            : 
    2515                 :          0 :         rxq->rx_rel_mbufs = _ice_rx_queue_release_mbufs;
    2516                 :            : 
    2517                 :          0 :         return ICE_SUCCESS;
    2518                 :            : }
    2519                 :            : 
    2520                 :            : uint16_t
    2521                 :          0 : ice_recv_pkts(void *rx_queue,
    2522                 :            :               struct rte_mbuf **rx_pkts,
    2523                 :            :               uint16_t nb_pkts)
    2524                 :            : {
    2525                 :            :         struct ice_rx_queue *rxq = rx_queue;
    2526                 :          0 :         volatile union ice_rx_flex_desc *rx_ring = rxq->rx_ring;
    2527                 :            :         volatile union ice_rx_flex_desc *rxdp;
    2528                 :            :         union ice_rx_flex_desc rxd;
    2529                 :          0 :         struct ice_rx_entry *sw_ring = rxq->sw_ring;
    2530                 :            :         struct ice_rx_entry *rxe;
    2531                 :            :         struct rte_mbuf *nmb; /* new allocated mbuf */
    2532                 :            :         struct rte_mbuf *nmb_pay; /* new allocated payload mbuf */
    2533                 :            :         struct rte_mbuf *rxm; /* pointer to store old mbuf in SW ring */
    2534                 :          0 :         uint16_t rx_id = rxq->rx_tail;
    2535                 :            :         uint16_t nb_rx = 0;
    2536                 :            :         uint16_t nb_hold = 0;
    2537                 :            :         uint16_t rx_packet_len;
    2538                 :            :         uint16_t rx_header_len;
    2539                 :            :         uint16_t rx_stat_err0;
    2540                 :            :         uint64_t dma_addr;
    2541                 :            :         uint64_t pkt_flags;
    2542                 :          0 :         uint32_t *ptype_tbl = rxq->vsi->adapter->ptype_tbl;
    2543                 :            : #ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC
    2544                 :            :         bool is_tsinit = false;
    2545                 :            :         uint64_t ts_ns;
    2546                 :            :         struct ice_vsi *vsi = rxq->vsi;
    2547                 :          0 :         struct ice_hw *hw = ICE_VSI_TO_HW(vsi);
    2548                 :            :         struct ice_adapter *ad = rxq->vsi->adapter;
    2549                 :            : 
    2550         [ #  # ]:          0 :         if (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP) {
    2551                 :          0 :                 uint64_t sw_cur_time = rte_get_timer_cycles() / (rte_get_timer_hz() / 1000);
    2552                 :            : 
    2553         [ #  # ]:          0 :                 if (unlikely(sw_cur_time - rxq->hw_time_update > 4))
    2554                 :            :                         is_tsinit = 1;
    2555                 :            :         }
    2556                 :            : #endif
    2557                 :            : 
    2558         [ #  # ]:          0 :         while (nb_rx < nb_pkts) {
    2559                 :          0 :                 rxdp = &rx_ring[rx_id];
    2560                 :          0 :                 rx_stat_err0 = rte_le_to_cpu_16(rxdp->wb.status_error0);
    2561                 :            : 
    2562                 :            :                 /* Check the DD bit first */
    2563         [ #  # ]:          0 :                 if (!(rx_stat_err0 & (1 << ICE_RX_FLEX_DESC_STATUS0_DD_S)))
    2564                 :            :                         break;
    2565                 :            : 
    2566                 :            :                 /* allocate header mbuf */
    2567                 :          0 :                 nmb = rte_mbuf_raw_alloc(rxq->mp);
    2568         [ #  # ]:          0 :                 if (unlikely(!nmb)) {
    2569                 :          0 :                         rxq->vsi->adapter->pf.dev_data->rx_mbuf_alloc_failed++;
    2570                 :          0 :                         break;
    2571                 :            :                 }
    2572                 :            : 
    2573                 :          0 :                 rxd = *rxdp; /* copy descriptor in ring to temp variable*/
    2574                 :            : 
    2575                 :          0 :                 nb_hold++;
    2576                 :          0 :                 rxe = &sw_ring[rx_id]; /* get corresponding mbuf in SW ring */
    2577                 :          0 :                 rx_id++;
    2578         [ #  # ]:          0 :                 if (unlikely(rx_id == rxq->nb_rx_desc))
    2579                 :            :                         rx_id = 0;
    2580                 :          0 :                 rxm = rxe->mbuf;
    2581         [ #  # ]:          0 :                 rxe->mbuf = nmb;
    2582                 :            :                 dma_addr =
    2583                 :            :                         rte_cpu_to_le_64(rte_mbuf_data_iova_default(nmb));
    2584                 :            : 
    2585         [ #  # ]:          0 :                 if (!(rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)) {
    2586                 :            :                         /**
    2587                 :            :                          * fill the read format of descriptor with physic address in
    2588                 :            :                          * new allocated mbuf: nmb
    2589                 :            :                          */
    2590                 :          0 :                         rxdp->read.hdr_addr = 0;
    2591                 :          0 :                         rxdp->read.pkt_addr = dma_addr;
    2592                 :            :                 } else {
    2593                 :            :                         /* allocate payload mbuf */
    2594                 :          0 :                         nmb_pay = rte_mbuf_raw_alloc(rxq->rxseg[1].mp);
    2595         [ #  # ]:          0 :                         if (unlikely(!nmb_pay)) {
    2596                 :          0 :                                 rxq->vsi->adapter->pf.dev_data->rx_mbuf_alloc_failed++;
    2597                 :          0 :                                 rxe->mbuf = NULL;
    2598                 :            :                                 nb_hold--;
    2599         [ #  # ]:          0 :                                 if (unlikely(rx_id == 0))
    2600                 :          0 :                                         rx_id = rxq->nb_rx_desc;
    2601                 :            : 
    2602                 :          0 :                                 rx_id--;
    2603                 :          0 :                                 rte_pktmbuf_free(nmb);
    2604                 :          0 :                                 break;
    2605                 :            :                         }
    2606                 :            : 
    2607                 :          0 :                         nmb->next = nmb_pay;
    2608                 :          0 :                         nmb_pay->next = NULL;
    2609                 :            : 
    2610                 :            :                         /**
    2611                 :            :                          * fill the read format of descriptor with physic address in
    2612                 :            :                          * new allocated mbuf: nmb
    2613                 :            :                          */
    2614                 :          0 :                         rxdp->read.hdr_addr = dma_addr;
    2615                 :          0 :                         rxdp->read.pkt_addr = rte_cpu_to_le_64(rte_mbuf_data_iova_default(nmb_pay));
    2616                 :            :                 }
    2617                 :            : 
    2618                 :            :                 /* fill old mbuf with received descriptor: rxd */
    2619                 :          0 :                 rxm->data_off = RTE_PKTMBUF_HEADROOM;
    2620                 :          0 :                 rte_prefetch0(RTE_PTR_ADD(rxm->buf_addr, RTE_PKTMBUF_HEADROOM));
    2621         [ #  # ]:          0 :                 if (!(rxq->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)) {
    2622                 :          0 :                         rxm->nb_segs = 1;
    2623                 :          0 :                         rxm->next = NULL;
    2624                 :            :                         /* calculate rx_packet_len of the received pkt */
    2625                 :          0 :                         rx_packet_len = (rte_le_to_cpu_16(rxd.wb.pkt_len) &
    2626                 :          0 :                                         ICE_RX_FLX_DESC_PKT_LEN_M) - rxq->crc_len;
    2627                 :          0 :                         rxm->data_len = rx_packet_len;
    2628                 :          0 :                         rxm->pkt_len = rx_packet_len;
    2629                 :            :                 } else {
    2630                 :          0 :                         rxm->nb_segs = (uint16_t)(rxm->nb_segs + rxm->next->nb_segs);
    2631                 :          0 :                         rxm->next->next = NULL;
    2632                 :            :                         /* calculate rx_packet_len of the received pkt */
    2633                 :          0 :                         rx_header_len = rte_le_to_cpu_16(rxd.wb.hdr_len_sph_flex_flags1) &
    2634                 :            :                                         ICE_RX_FLEX_DESC_HEADER_LEN_M;
    2635                 :          0 :                         rx_packet_len = (rte_le_to_cpu_16(rxd.wb.pkt_len) &
    2636                 :          0 :                                         ICE_RX_FLX_DESC_PKT_LEN_M) - rxq->crc_len;
    2637                 :          0 :                         rxm->data_len = rx_header_len;
    2638                 :          0 :                         rxm->pkt_len = rx_header_len + rx_packet_len;
    2639                 :          0 :                         rxm->next->data_len = rx_packet_len;
    2640                 :            : 
    2641                 :            : #ifdef RTE_ETHDEV_DEBUG_RX
    2642                 :            :                         rte_pktmbuf_dump(stdout, rxm, rte_pktmbuf_pkt_len(rxm));
    2643                 :            : #endif
    2644                 :            :                 }
    2645                 :            : 
    2646                 :          0 :                 rxm->port = rxq->port_id;
    2647                 :          0 :                 rxm->packet_type = ptype_tbl[ICE_RX_FLEX_DESC_PTYPE_M &
    2648         [ #  # ]:          0 :                         rte_le_to_cpu_16(rxd.wb.ptype_flex_flags0)];
    2649                 :            :                 ice_rxd_to_vlan_tci(rxm, &rxd);
    2650                 :          0 :                 rxd_to_pkt_fields_ops[rxq->rxdid](rxq, rxm, &rxd);
    2651                 :          0 :                 pkt_flags = ice_rxd_error_to_pkt_flags(rx_stat_err0);
    2652                 :            : #ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC
    2653         [ #  # ]:          0 :                 if (rxq->ts_flag > 0 &&
    2654         [ #  # ]:          0 :                     (rxq->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)) {
    2655                 :          0 :                         rxq->time_high =
    2656                 :          0 :                            rte_le_to_cpu_32(rxd.wb.flex_ts.ts_high);
    2657         [ #  # ]:          0 :                         if (unlikely(is_tsinit)) {
    2658                 :          0 :                                 ts_ns = ice_tstamp_convert_32b_64b(hw, ad, 1, rxq->time_high);
    2659                 :          0 :                                 rxq->hw_time_low = (uint32_t)ts_ns;
    2660                 :          0 :                                 rxq->hw_time_high = (uint32_t)(ts_ns >> 32);
    2661                 :            :                                 is_tsinit = false;
    2662                 :            :                         } else {
    2663         [ #  # ]:          0 :                                 if (rxq->time_high < rxq->hw_time_low)
    2664                 :          0 :                                         rxq->hw_time_high += 1;
    2665                 :          0 :                                 ts_ns = (uint64_t)rxq->hw_time_high << 32 | rxq->time_high;
    2666                 :          0 :                                 rxq->hw_time_low = rxq->time_high;
    2667                 :            :                         }
    2668                 :          0 :                         rxq->hw_time_update = rte_get_timer_cycles() /
    2669                 :          0 :                                              (rte_get_timer_hz() / 1000);
    2670                 :          0 :                         *RTE_MBUF_DYNFIELD(rxm,
    2671                 :            :                                            (rxq->ts_offset),
    2672                 :          0 :                                            rte_mbuf_timestamp_t *) = ts_ns;
    2673                 :          0 :                         pkt_flags |= rxq->ts_flag;
    2674                 :            :                 }
    2675                 :            : 
    2676   [ #  #  #  # ]:          0 :                 if (ad->ptp_ena && ((rxm->packet_type & RTE_PTYPE_L2_MASK) ==
    2677                 :            :                     RTE_PTYPE_L2_ETHER_TIMESYNC)) {
    2678                 :          0 :                         rxq->time_high =
    2679                 :          0 :                            rte_le_to_cpu_32(rxd.wb.flex_ts.ts_high);
    2680                 :          0 :                         rxm->timesync = rxq->queue_id;
    2681                 :          0 :                         pkt_flags |= RTE_MBUF_F_RX_IEEE1588_PTP;
    2682                 :            :                 }
    2683                 :            : #endif
    2684                 :          0 :                 rxm->ol_flags |= pkt_flags;
    2685                 :            :                 /* copy old mbuf to rx_pkts */
    2686                 :          0 :                 rx_pkts[nb_rx++] = rxm;
    2687                 :            :         }
    2688                 :            : 
    2689                 :          0 :         rxq->rx_tail = rx_id;
    2690                 :            :         /**
    2691                 :            :          * If the number of free RX descriptors is greater than the RX free
    2692                 :            :          * threshold of the queue, advance the receive tail register of queue.
    2693                 :            :          * Update that register with the value of the last processed RX
    2694                 :            :          * descriptor minus 1.
    2695                 :            :          */
    2696                 :          0 :         nb_hold = (uint16_t)(nb_hold + rxq->nb_rx_hold);
    2697         [ #  # ]:          0 :         if (nb_hold > rxq->rx_free_thresh) {
    2698         [ #  # ]:          0 :                 rx_id = (uint16_t)(rx_id == 0 ?
    2699                 :          0 :                                    (rxq->nb_rx_desc - 1) : (rx_id - 1));
    2700                 :            :                 /* write TAIL register */
    2701                 :          0 :                 ICE_PCI_REG_WC_WRITE(rxq->qrx_tail, rx_id);
    2702                 :            :                 nb_hold = 0;
    2703                 :            :         }
    2704                 :          0 :         rxq->nb_rx_hold = nb_hold;
    2705                 :            : 
    2706                 :            :         /* return received packet in the burst */
    2707                 :          0 :         return nb_rx;
    2708                 :            : }
    2709                 :            : 
    2710                 :            : static inline void
    2711                 :          0 : ice_parse_tunneling_params(uint64_t ol_flags,
    2712                 :            :                             union ice_tx_offload tx_offload,
    2713                 :            :                             uint32_t *cd_tunneling)
    2714                 :            : {
    2715                 :            :         /* EIPT: External (outer) IP header type */
    2716         [ #  # ]:          0 :         if (ol_flags & RTE_MBUF_F_TX_OUTER_IP_CKSUM)
    2717                 :          0 :                 *cd_tunneling |= ICE_TX_CTX_EIPT_IPV4;
    2718         [ #  # ]:          0 :         else if (ol_flags & RTE_MBUF_F_TX_OUTER_IPV4)
    2719                 :          0 :                 *cd_tunneling |= ICE_TX_CTX_EIPT_IPV4_NO_CSUM;
    2720         [ #  # ]:          0 :         else if (ol_flags & RTE_MBUF_F_TX_OUTER_IPV6)
    2721                 :          0 :                 *cd_tunneling |= ICE_TX_CTX_EIPT_IPV6;
    2722                 :            : 
    2723                 :            :         /* EIPLEN: External (outer) IP header length, in DWords */
    2724                 :          0 :         *cd_tunneling |= (tx_offload.outer_l3_len >> 2) <<
    2725                 :            :                 ICE_TXD_CTX_QW0_EIPLEN_S;
    2726                 :            : 
    2727                 :            :         /* L4TUNT: L4 Tunneling Type */
    2728   [ #  #  #  # ]:          0 :         switch (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK) {
    2729                 :            :         case RTE_MBUF_F_TX_TUNNEL_IPIP:
    2730                 :            :                 /* for non UDP / GRE tunneling, set to 00b */
    2731                 :            :                 break;
    2732                 :          0 :         case RTE_MBUF_F_TX_TUNNEL_VXLAN:
    2733                 :            :         case RTE_MBUF_F_TX_TUNNEL_VXLAN_GPE:
    2734                 :            :         case RTE_MBUF_F_TX_TUNNEL_GTP:
    2735                 :            :         case RTE_MBUF_F_TX_TUNNEL_GENEVE:
    2736                 :          0 :                 *cd_tunneling |= ICE_TXD_CTX_UDP_TUNNELING;
    2737                 :          0 :                 break;
    2738                 :          0 :         case RTE_MBUF_F_TX_TUNNEL_GRE:
    2739                 :          0 :                 *cd_tunneling |= ICE_TXD_CTX_GRE_TUNNELING;
    2740                 :          0 :                 break;
    2741                 :            :         default:
    2742                 :            :                 PMD_TX_LOG(ERR, "Tunnel type not supported");
    2743                 :            :                 return;
    2744                 :            :         }
    2745                 :            : 
    2746                 :            :         /* L4TUNLEN: L4 Tunneling Length, in Words
    2747                 :            :          *
    2748                 :            :          * We depend on app to set rte_mbuf.l2_len correctly.
    2749                 :            :          * For IP in GRE it should be set to the length of the GRE
    2750                 :            :          * header;
    2751                 :            :          * For MAC in GRE or MAC in UDP it should be set to the length
    2752                 :            :          * of the GRE or UDP headers plus the inner MAC up to including
    2753                 :            :          * its last Ethertype.
    2754                 :            :          * If MPLS labels exists, it should include them as well.
    2755                 :            :          */
    2756                 :          0 :         *cd_tunneling |= (tx_offload.l2_len >> 1) <<
    2757                 :            :                 ICE_TXD_CTX_QW0_NATLEN_S;
    2758                 :            : 
    2759                 :            :         /**
    2760                 :            :          * Calculate the tunneling UDP checksum.
    2761                 :            :          * Shall be set only if L4TUNT = 01b and EIPT is not zero
    2762                 :            :          */
    2763   [ #  #  #  # ]:          0 :         if ((*cd_tunneling & ICE_TXD_CTX_QW0_EIPT_M) &&
    2764                 :          0 :                         (*cd_tunneling & ICE_TXD_CTX_UDP_TUNNELING) &&
    2765         [ #  # ]:          0 :                         (ol_flags & RTE_MBUF_F_TX_OUTER_UDP_CKSUM))
    2766                 :          0 :                 *cd_tunneling |= ICE_TXD_CTX_QW0_L4T_CS_M;
    2767                 :            : }
    2768                 :            : 
    2769                 :            : static inline void
    2770                 :          0 : ice_txd_enable_checksum(uint64_t ol_flags,
    2771                 :            :                         uint32_t *td_cmd,
    2772                 :            :                         uint32_t *td_offset,
    2773                 :            :                         union ice_tx_offload tx_offload)
    2774                 :            : {
    2775                 :            :         /* Set MACLEN */
    2776         [ #  # ]:          0 :         if (!(ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK))
    2777                 :          0 :                 *td_offset |= (tx_offload.l2_len >> 1)
    2778                 :          0 :                         << ICE_TX_DESC_LEN_MACLEN_S;
    2779                 :            : 
    2780                 :            :         /* Enable L3 checksum offloads */
    2781         [ #  # ]:          0 :         if (ol_flags & RTE_MBUF_F_TX_IP_CKSUM) {
    2782                 :          0 :                 *td_cmd |= ICE_TX_DESC_CMD_IIPT_IPV4_CSUM;
    2783                 :          0 :                 *td_offset |= (tx_offload.l3_len >> 2) <<
    2784                 :            :                         ICE_TX_DESC_LEN_IPLEN_S;
    2785         [ #  # ]:          0 :         } else if (ol_flags & RTE_MBUF_F_TX_IPV4) {
    2786                 :          0 :                 *td_cmd |= ICE_TX_DESC_CMD_IIPT_IPV4;
    2787                 :          0 :                 *td_offset |= (tx_offload.l3_len >> 2) <<
    2788                 :            :                         ICE_TX_DESC_LEN_IPLEN_S;
    2789         [ #  # ]:          0 :         } else if (ol_flags & RTE_MBUF_F_TX_IPV6) {
    2790                 :          0 :                 *td_cmd |= ICE_TX_DESC_CMD_IIPT_IPV6;
    2791                 :          0 :                 *td_offset |= (tx_offload.l3_len >> 2) <<
    2792                 :            :                         ICE_TX_DESC_LEN_IPLEN_S;
    2793                 :            :         }
    2794                 :            : 
    2795         [ #  # ]:          0 :         if (ol_flags & RTE_MBUF_F_TX_TCP_SEG) {
    2796                 :          0 :                 *td_cmd |= ICE_TX_DESC_CMD_L4T_EOFT_TCP;
    2797                 :          0 :                 *td_offset |= (tx_offload.l4_len >> 2) <<
    2798                 :            :                               ICE_TX_DESC_LEN_L4_LEN_S;
    2799                 :          0 :                 return;
    2800                 :            :         }
    2801                 :            : 
    2802         [ #  # ]:          0 :         if (ol_flags & RTE_MBUF_F_TX_UDP_SEG) {
    2803                 :          0 :                 *td_cmd |= ICE_TX_DESC_CMD_L4T_EOFT_UDP;
    2804                 :          0 :                 *td_offset |= (tx_offload.l4_len >> 2) <<
    2805                 :            :                               ICE_TX_DESC_LEN_L4_LEN_S;
    2806                 :          0 :                 return;
    2807                 :            :         }
    2808                 :            : 
    2809                 :            :         /* Enable L4 checksum offloads */
    2810   [ #  #  #  # ]:          0 :         switch (ol_flags & RTE_MBUF_F_TX_L4_MASK) {
    2811                 :          0 :         case RTE_MBUF_F_TX_TCP_CKSUM:
    2812                 :          0 :                 *td_cmd |= ICE_TX_DESC_CMD_L4T_EOFT_TCP;
    2813                 :          0 :                 *td_offset |= (sizeof(struct rte_tcp_hdr) >> 2) <<
    2814                 :            :                               ICE_TX_DESC_LEN_L4_LEN_S;
    2815                 :          0 :                 break;
    2816                 :          0 :         case RTE_MBUF_F_TX_SCTP_CKSUM:
    2817                 :          0 :                 *td_cmd |= ICE_TX_DESC_CMD_L4T_EOFT_SCTP;
    2818                 :          0 :                 *td_offset |= (sizeof(struct rte_sctp_hdr) >> 2) <<
    2819                 :            :                               ICE_TX_DESC_LEN_L4_LEN_S;
    2820                 :          0 :                 break;
    2821                 :          0 :         case RTE_MBUF_F_TX_UDP_CKSUM:
    2822                 :          0 :                 *td_cmd |= ICE_TX_DESC_CMD_L4T_EOFT_UDP;
    2823                 :          0 :                 *td_offset |= (sizeof(struct rte_udp_hdr) >> 2) <<
    2824                 :            :                               ICE_TX_DESC_LEN_L4_LEN_S;
    2825                 :          0 :                 break;
    2826                 :            :         default:
    2827                 :            :                 break;
    2828                 :            :         }
    2829                 :            : }
    2830                 :            : 
    2831                 :            : static inline int
    2832                 :          0 : ice_xmit_cleanup(struct ci_tx_queue *txq)
    2833                 :            : {
    2834                 :          0 :         struct ci_tx_entry *sw_ring = txq->sw_ring;
    2835                 :          0 :         volatile struct ice_tx_desc *txd = txq->ice_tx_ring;
    2836                 :          0 :         uint16_t last_desc_cleaned = txq->last_desc_cleaned;
    2837                 :          0 :         uint16_t nb_tx_desc = txq->nb_tx_desc;
    2838                 :            :         uint16_t desc_to_clean_to;
    2839                 :            :         uint16_t nb_tx_to_clean;
    2840                 :            : 
    2841                 :            :         /* Determine the last descriptor needing to be cleaned */
    2842                 :          0 :         desc_to_clean_to = (uint16_t)(last_desc_cleaned + txq->tx_rs_thresh);
    2843         [ #  # ]:          0 :         if (desc_to_clean_to >= nb_tx_desc)
    2844                 :          0 :                 desc_to_clean_to = (uint16_t)(desc_to_clean_to - nb_tx_desc);
    2845                 :            : 
    2846                 :            :         /* Check to make sure the last descriptor to clean is done */
    2847                 :          0 :         desc_to_clean_to = sw_ring[desc_to_clean_to].last_id;
    2848         [ #  # ]:          0 :         if (!(txd[desc_to_clean_to].cmd_type_offset_bsz &
    2849                 :            :             rte_cpu_to_le_64(ICE_TX_DESC_DTYPE_DESC_DONE))) {
    2850                 :            :                 PMD_TX_LOG(DEBUG, "TX descriptor %4u is not done "
    2851                 :            :                            "(port=%d queue=%d) value=0x%"PRIx64,
    2852                 :            :                            desc_to_clean_to,
    2853                 :            :                            txq->port_id, txq->queue_id,
    2854                 :            :                            txd[desc_to_clean_to].cmd_type_offset_bsz);
    2855                 :            :                 /* Failed to clean any descriptors */
    2856                 :            :                 return -1;
    2857                 :            :         }
    2858                 :            : 
    2859                 :            :         /* Figure out how many descriptors will be cleaned */
    2860         [ #  # ]:          0 :         if (last_desc_cleaned > desc_to_clean_to)
    2861                 :          0 :                 nb_tx_to_clean = (uint16_t)((nb_tx_desc - last_desc_cleaned) +
    2862                 :            :                                             desc_to_clean_to);
    2863                 :            :         else
    2864                 :          0 :                 nb_tx_to_clean = (uint16_t)(desc_to_clean_to -
    2865                 :            :                                             last_desc_cleaned);
    2866                 :            : 
    2867                 :            :         /* The last descriptor to clean is done, so that means all the
    2868                 :            :          * descriptors from the last descriptor that was cleaned
    2869                 :            :          * up to the last descriptor with the RS bit set
    2870                 :            :          * are done. Only reset the threshold descriptor.
    2871                 :            :          */
    2872                 :          0 :         txd[desc_to_clean_to].cmd_type_offset_bsz = 0;
    2873                 :            : 
    2874                 :            :         /* Update the txq to reflect the last descriptor that was cleaned */
    2875                 :          0 :         txq->last_desc_cleaned = desc_to_clean_to;
    2876                 :          0 :         txq->nb_tx_free = (uint16_t)(txq->nb_tx_free + nb_tx_to_clean);
    2877                 :            : 
    2878                 :          0 :         return 0;
    2879                 :            : }
    2880                 :            : 
    2881                 :            : /* Construct the tx flags */
    2882                 :            : static inline uint64_t
    2883                 :            : ice_build_ctob(uint32_t td_cmd,
    2884                 :            :                uint32_t td_offset,
    2885                 :            :                uint16_t size,
    2886                 :            :                uint32_t td_tag)
    2887                 :            : {
    2888                 :          0 :         return rte_cpu_to_le_64(ICE_TX_DESC_DTYPE_DATA |
    2889                 :            :                                 ((uint64_t)td_cmd << ICE_TXD_QW1_CMD_S) |
    2890                 :            :                                 ((uint64_t)td_offset << ICE_TXD_QW1_OFFSET_S) |
    2891                 :            :                                 ((uint64_t)size << ICE_TXD_QW1_TX_BUF_SZ_S) |
    2892                 :            :                                 ((uint64_t)td_tag << ICE_TXD_QW1_L2TAG1_S));
    2893                 :            : }
    2894                 :            : 
    2895                 :            : /* Check if the context descriptor is needed for TX offloading */
    2896                 :            : static inline uint16_t
    2897                 :            : ice_calc_context_desc(uint64_t flags)
    2898                 :            : {
    2899                 :            :         static uint64_t mask = RTE_MBUF_F_TX_TCP_SEG |
    2900                 :            :                 RTE_MBUF_F_TX_UDP_SEG |
    2901                 :            :                 RTE_MBUF_F_TX_QINQ |
    2902                 :            :                 RTE_MBUF_F_TX_OUTER_IP_CKSUM |
    2903                 :            :                 RTE_MBUF_F_TX_TUNNEL_MASK |
    2904                 :            :                 RTE_MBUF_F_TX_IEEE1588_TMST;
    2905                 :            : 
    2906                 :          0 :         return (flags & mask) ? 1 : 0;
    2907                 :            : }
    2908                 :            : 
    2909                 :            : /* set ice TSO context descriptor */
    2910                 :            : static inline uint64_t
    2911                 :            : ice_set_tso_ctx(struct rte_mbuf *mbuf, union ice_tx_offload tx_offload)
    2912                 :            : {
    2913                 :            :         uint64_t ctx_desc = 0;
    2914                 :            :         uint32_t cd_cmd, hdr_len, cd_tso_len;
    2915                 :            : 
    2916         [ #  # ]:          0 :         if (!tx_offload.l4_len) {
    2917                 :            :                 PMD_TX_LOG(DEBUG, "L4 length set to 0");
    2918                 :            :                 return ctx_desc;
    2919                 :            :         }
    2920                 :            : 
    2921                 :          0 :         hdr_len = tx_offload.l2_len + tx_offload.l3_len + tx_offload.l4_len;
    2922                 :          0 :         hdr_len += (mbuf->ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK) ?
    2923         [ #  # ]:          0 :                    tx_offload.outer_l2_len + tx_offload.outer_l3_len : 0;
    2924                 :            : 
    2925                 :            :         cd_cmd = ICE_TX_CTX_DESC_TSO;
    2926                 :          0 :         cd_tso_len = mbuf->pkt_len - hdr_len;
    2927                 :          0 :         ctx_desc |= ((uint64_t)cd_cmd << ICE_TXD_CTX_QW1_CMD_S) |
    2928                 :          0 :                     ((uint64_t)cd_tso_len << ICE_TXD_CTX_QW1_TSO_LEN_S) |
    2929                 :          0 :                     ((uint64_t)mbuf->tso_segsz << ICE_TXD_CTX_QW1_MSS_S);
    2930                 :            : 
    2931                 :          0 :         return ctx_desc;
    2932                 :            : }
    2933                 :            : 
    2934                 :            : /* HW requires that TX buffer size ranges from 1B up to (16K-1)B. */
    2935                 :            : #define ICE_MAX_DATA_PER_TXD \
    2936                 :            :         (ICE_TXD_QW1_TX_BUF_SZ_M >> ICE_TXD_QW1_TX_BUF_SZ_S)
    2937                 :            : /* Calculate the number of TX descriptors needed for each pkt */
    2938                 :            : static inline uint16_t
    2939                 :            : ice_calc_pkt_desc(struct rte_mbuf *tx_pkt)
    2940                 :            : {
    2941                 :            :         struct rte_mbuf *txd = tx_pkt;
    2942                 :            :         uint16_t count = 0;
    2943                 :            : 
    2944         [ #  # ]:          0 :         while (txd != NULL) {
    2945                 :          0 :                 count += DIV_ROUND_UP(txd->data_len, ICE_MAX_DATA_PER_TXD);
    2946                 :          0 :                 txd = txd->next;
    2947                 :            :         }
    2948                 :            : 
    2949                 :            :         return count;
    2950                 :            : }
    2951                 :            : 
    2952                 :            : uint16_t
    2953                 :          0 : ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
    2954                 :            : {
    2955                 :            :         struct ci_tx_queue *txq;
    2956                 :            :         volatile struct ice_tx_desc *ice_tx_ring;
    2957                 :            :         volatile struct ice_tx_desc *txd;
    2958                 :            :         struct ci_tx_entry *sw_ring;
    2959                 :            :         struct ci_tx_entry *txe, *txn;
    2960                 :            :         struct rte_mbuf *tx_pkt;
    2961                 :            :         struct rte_mbuf *m_seg;
    2962                 :            :         uint32_t cd_tunneling_params;
    2963                 :            :         uint16_t tx_id;
    2964                 :            :         uint16_t nb_tx;
    2965                 :            :         uint16_t nb_used;
    2966                 :            :         uint16_t nb_ctx;
    2967                 :          0 :         uint32_t td_cmd = 0;
    2968                 :          0 :         uint32_t td_offset = 0;
    2969                 :            :         uint32_t td_tag = 0;
    2970                 :            :         uint16_t tx_last;
    2971                 :            :         uint16_t slen;
    2972                 :            :         uint64_t buf_dma_addr;
    2973                 :            :         uint64_t ol_flags;
    2974                 :          0 :         union ice_tx_offload tx_offload = {0};
    2975                 :            : 
    2976                 :            :         txq = tx_queue;
    2977                 :          0 :         sw_ring = txq->sw_ring;
    2978                 :          0 :         ice_tx_ring = txq->ice_tx_ring;
    2979                 :          0 :         tx_id = txq->tx_tail;
    2980                 :          0 :         txe = &sw_ring[tx_id];
    2981                 :            : 
    2982                 :            :         /* Check if the descriptor ring needs to be cleaned. */
    2983         [ #  # ]:          0 :         if (txq->nb_tx_free < txq->tx_free_thresh)
    2984                 :          0 :                 (void)ice_xmit_cleanup(txq);
    2985                 :            : 
    2986         [ #  # ]:          0 :         for (nb_tx = 0; nb_tx < nb_pkts; nb_tx++) {
    2987                 :          0 :                 tx_pkt = *tx_pkts++;
    2988                 :            : 
    2989                 :          0 :                 td_cmd = 0;
    2990                 :            :                 td_tag = 0;
    2991                 :          0 :                 td_offset = 0;
    2992                 :          0 :                 ol_flags = tx_pkt->ol_flags;
    2993                 :          0 :                 tx_offload.l2_len = tx_pkt->l2_len;
    2994                 :          0 :                 tx_offload.l3_len = tx_pkt->l3_len;
    2995                 :          0 :                 tx_offload.outer_l2_len = tx_pkt->outer_l2_len;
    2996                 :          0 :                 tx_offload.outer_l3_len = tx_pkt->outer_l3_len;
    2997                 :          0 :                 tx_offload.l4_len = tx_pkt->l4_len;
    2998                 :          0 :                 tx_offload.tso_segsz = tx_pkt->tso_segsz;
    2999                 :            :                 /* Calculate the number of context descriptors needed. */
    3000                 :            :                 nb_ctx = ice_calc_context_desc(ol_flags);
    3001                 :            : 
    3002                 :            :                 /* The number of descriptors that must be allocated for
    3003                 :            :                  * a packet equals to the number of the segments of that
    3004                 :            :                  * packet plus the number of context descriptor if needed.
    3005                 :            :                  * Recalculate the needed tx descs when TSO enabled in case
    3006                 :            :                  * the mbuf data size exceeds max data size that hw allows
    3007                 :            :                  * per tx desc.
    3008                 :            :                  */
    3009         [ #  # ]:          0 :                 if (ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG))
    3010                 :          0 :                         nb_used = (uint16_t)(ice_calc_pkt_desc(tx_pkt) +
    3011                 :            :                                              nb_ctx);
    3012                 :            :                 else
    3013                 :          0 :                         nb_used = (uint16_t)(tx_pkt->nb_segs + nb_ctx);
    3014                 :          0 :                 tx_last = (uint16_t)(tx_id + nb_used - 1);
    3015                 :            : 
    3016                 :            :                 /* Circular ring */
    3017         [ #  # ]:          0 :                 if (tx_last >= txq->nb_tx_desc)
    3018                 :          0 :                         tx_last = (uint16_t)(tx_last - txq->nb_tx_desc);
    3019                 :            : 
    3020         [ #  # ]:          0 :                 if (nb_used > txq->nb_tx_free) {
    3021         [ #  # ]:          0 :                         if (ice_xmit_cleanup(txq) != 0) {
    3022         [ #  # ]:          0 :                                 if (nb_tx == 0)
    3023                 :            :                                         return 0;
    3024                 :          0 :                                 goto end_of_tx;
    3025                 :            :                         }
    3026         [ #  # ]:          0 :                         if (unlikely(nb_used > txq->tx_rs_thresh)) {
    3027         [ #  # ]:          0 :                                 while (nb_used > txq->nb_tx_free) {
    3028         [ #  # ]:          0 :                                         if (ice_xmit_cleanup(txq) != 0) {
    3029         [ #  # ]:          0 :                                                 if (nb_tx == 0)
    3030                 :            :                                                         return 0;
    3031                 :          0 :                                                 goto end_of_tx;
    3032                 :            :                                         }
    3033                 :            :                                 }
    3034                 :            :                         }
    3035                 :            :                 }
    3036                 :            : 
    3037                 :            :                 /* Descriptor based VLAN insertion */
    3038         [ #  # ]:          0 :                 if (ol_flags & (RTE_MBUF_F_TX_VLAN | RTE_MBUF_F_TX_QINQ)) {
    3039                 :          0 :                         td_cmd |= ICE_TX_DESC_CMD_IL2TAG1;
    3040                 :          0 :                         td_tag = tx_pkt->vlan_tci;
    3041                 :            :                 }
    3042                 :            : 
    3043                 :            :                 /* Fill in tunneling parameters if necessary */
    3044                 :          0 :                 cd_tunneling_params = 0;
    3045         [ #  # ]:          0 :                 if (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK) {
    3046                 :          0 :                         td_offset |= (tx_offload.outer_l2_len >> 1)
    3047                 :          0 :                                 << ICE_TX_DESC_LEN_MACLEN_S;
    3048                 :          0 :                         ice_parse_tunneling_params(ol_flags, tx_offload,
    3049                 :            :                                                    &cd_tunneling_params);
    3050                 :            :                 }
    3051                 :            : 
    3052                 :            :                 /* Enable checksum offloading */
    3053         [ #  # ]:          0 :                 if (ol_flags & ICE_TX_CKSUM_OFFLOAD_MASK)
    3054                 :          0 :                         ice_txd_enable_checksum(ol_flags, &td_cmd,
    3055                 :            :                                                 &td_offset, tx_offload);
    3056                 :            : 
    3057         [ #  # ]:          0 :                 if (nb_ctx) {
    3058                 :            :                         /* Setup TX context descriptor if required */
    3059                 :          0 :                         volatile struct ice_tx_ctx_desc *ctx_txd =
    3060                 :            :                                 (volatile struct ice_tx_ctx_desc *)
    3061                 :          0 :                                         &ice_tx_ring[tx_id];
    3062                 :            :                         uint16_t cd_l2tag2 = 0;
    3063                 :            :                         uint64_t cd_type_cmd_tso_mss = ICE_TX_DESC_DTYPE_CTX;
    3064                 :            : 
    3065                 :          0 :                         txn = &sw_ring[txe->next_id];
    3066         [ #  # ]:          0 :                         RTE_MBUF_PREFETCH_TO_FREE(txn->mbuf);
    3067         [ #  # ]:          0 :                         if (txe->mbuf) {
    3068                 :            :                                 rte_pktmbuf_free_seg(txe->mbuf);
    3069                 :          0 :                                 txe->mbuf = NULL;
    3070                 :            :                         }
    3071                 :            : 
    3072         [ #  # ]:          0 :                         if (ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG))
    3073                 :          0 :                                 cd_type_cmd_tso_mss |=
    3074                 :            :                                         ice_set_tso_ctx(tx_pkt, tx_offload);
    3075         [ #  # ]:          0 :                         else if (ol_flags & RTE_MBUF_F_TX_IEEE1588_TMST)
    3076                 :          0 :                                 cd_type_cmd_tso_mss |=
    3077                 :            :                                         ((uint64_t)ICE_TX_CTX_DESC_TSYN <<
    3078                 :            :                                         ICE_TXD_CTX_QW1_CMD_S) |
    3079                 :          0 :                                          (((uint64_t)txq->ice_vsi->adapter->ptp_tx_index <<
    3080                 :            :                                          ICE_TXD_CTX_QW1_TSYN_S) & ICE_TXD_CTX_QW1_TSYN_M);
    3081                 :            : 
    3082                 :          0 :                         ctx_txd->tunneling_params =
    3083                 :            :                                 rte_cpu_to_le_32(cd_tunneling_params);
    3084                 :            : 
    3085                 :            :                         /* TX context descriptor based double VLAN insert */
    3086         [ #  # ]:          0 :                         if (ol_flags & RTE_MBUF_F_TX_QINQ) {
    3087                 :          0 :                                 cd_l2tag2 = tx_pkt->vlan_tci_outer;
    3088                 :          0 :                                 cd_type_cmd_tso_mss |=
    3089                 :            :                                         ((uint64_t)ICE_TX_CTX_DESC_IL2TAG2 <<
    3090                 :            :                                          ICE_TXD_CTX_QW1_CMD_S);
    3091                 :            :                         }
    3092                 :          0 :                         ctx_txd->l2tag2 = rte_cpu_to_le_16(cd_l2tag2);
    3093                 :          0 :                         ctx_txd->qw1 =
    3094                 :            :                                 rte_cpu_to_le_64(cd_type_cmd_tso_mss);
    3095                 :            : 
    3096                 :          0 :                         txe->last_id = tx_last;
    3097                 :          0 :                         tx_id = txe->next_id;
    3098                 :            :                         txe = txn;
    3099                 :            :                 }
    3100                 :            :                 m_seg = tx_pkt;
    3101                 :            : 
    3102                 :            :                 do {
    3103                 :          0 :                         txd = &ice_tx_ring[tx_id];
    3104                 :          0 :                         txn = &sw_ring[txe->next_id];
    3105                 :            : 
    3106         [ #  # ]:          0 :                         if (txe->mbuf)
    3107                 :            :                                 rte_pktmbuf_free_seg(txe->mbuf);
    3108                 :          0 :                         txe->mbuf = m_seg;
    3109                 :            : 
    3110                 :            :                         /* Setup TX Descriptor */
    3111                 :          0 :                         slen = m_seg->data_len;
    3112                 :            :                         buf_dma_addr = rte_mbuf_data_iova(m_seg);
    3113                 :            : 
    3114         [ #  # ]:          0 :                         while ((ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG)) &&
    3115         [ #  # ]:          0 :                                 unlikely(slen > ICE_MAX_DATA_PER_TXD)) {
    3116                 :          0 :                                 txd->buf_addr = rte_cpu_to_le_64(buf_dma_addr);
    3117                 :          0 :                                 txd->cmd_type_offset_bsz =
    3118                 :          0 :                                 rte_cpu_to_le_64(ICE_TX_DESC_DTYPE_DATA |
    3119                 :            :                                 ((uint64_t)td_cmd << ICE_TXD_QW1_CMD_S) |
    3120                 :            :                                 ((uint64_t)td_offset << ICE_TXD_QW1_OFFSET_S) |
    3121                 :            :                                 ((uint64_t)ICE_MAX_DATA_PER_TXD <<
    3122                 :            :                                  ICE_TXD_QW1_TX_BUF_SZ_S) |
    3123                 :            :                                 ((uint64_t)td_tag << ICE_TXD_QW1_L2TAG1_S));
    3124                 :            : 
    3125                 :          0 :                                 buf_dma_addr += ICE_MAX_DATA_PER_TXD;
    3126                 :          0 :                                 slen -= ICE_MAX_DATA_PER_TXD;
    3127                 :            : 
    3128                 :          0 :                                 txe->last_id = tx_last;
    3129                 :          0 :                                 tx_id = txe->next_id;
    3130                 :            :                                 txe = txn;
    3131                 :          0 :                                 txd = &ice_tx_ring[tx_id];
    3132                 :          0 :                                 txn = &sw_ring[txe->next_id];
    3133                 :            :                         }
    3134                 :            : 
    3135                 :          0 :                         txd->buf_addr = rte_cpu_to_le_64(buf_dma_addr);
    3136                 :          0 :                         txd->cmd_type_offset_bsz =
    3137                 :          0 :                                 rte_cpu_to_le_64(ICE_TX_DESC_DTYPE_DATA |
    3138                 :            :                                 ((uint64_t)td_cmd << ICE_TXD_QW1_CMD_S) |
    3139                 :            :                                 ((uint64_t)td_offset << ICE_TXD_QW1_OFFSET_S) |
    3140                 :            :                                 ((uint64_t)slen << ICE_TXD_QW1_TX_BUF_SZ_S) |
    3141                 :            :                                 ((uint64_t)td_tag << ICE_TXD_QW1_L2TAG1_S));
    3142                 :            : 
    3143                 :          0 :                         txe->last_id = tx_last;
    3144                 :          0 :                         tx_id = txe->next_id;
    3145                 :            :                         txe = txn;
    3146                 :          0 :                         m_seg = m_seg->next;
    3147         [ #  # ]:          0 :                 } while (m_seg);
    3148                 :            : 
    3149                 :            :                 /* fill the last descriptor with End of Packet (EOP) bit */
    3150                 :          0 :                 td_cmd |= ICE_TX_DESC_CMD_EOP;
    3151                 :          0 :                 txq->nb_tx_used = (uint16_t)(txq->nb_tx_used + nb_used);
    3152                 :          0 :                 txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_used);
    3153                 :            : 
    3154                 :            :                 /* set RS bit on the last descriptor of one packet */
    3155         [ #  # ]:          0 :                 if (txq->nb_tx_used >= txq->tx_rs_thresh) {
    3156                 :            :                         PMD_TX_LOG(DEBUG,
    3157                 :            :                                    "Setting RS bit on TXD id="
    3158                 :            :                                    "%4u (port=%d queue=%d)",
    3159                 :            :                                    tx_last, txq->port_id, txq->queue_id);
    3160                 :            : 
    3161                 :          0 :                         td_cmd |= ICE_TX_DESC_CMD_RS;
    3162                 :            : 
    3163                 :            :                         /* Update txq RS bit counters */
    3164                 :          0 :                         txq->nb_tx_used = 0;
    3165                 :            :                 }
    3166                 :          0 :                 txd->cmd_type_offset_bsz |=
    3167                 :          0 :                         rte_cpu_to_le_64(((uint64_t)td_cmd) <<
    3168                 :            :                                          ICE_TXD_QW1_CMD_S);
    3169                 :            :         }
    3170                 :          0 : end_of_tx:
    3171                 :            :         /* update Tail register */
    3172                 :          0 :         ICE_PCI_REG_WRITE(txq->qtx_tail, tx_id);
    3173                 :          0 :         txq->tx_tail = tx_id;
    3174                 :            : 
    3175                 :          0 :         return nb_tx;
    3176                 :            : }
    3177                 :            : 
    3178                 :            : static __rte_always_inline int
    3179                 :            : ice_tx_free_bufs(struct ci_tx_queue *txq)
    3180                 :            : {
    3181                 :            :         struct ci_tx_entry *txep;
    3182                 :            :         uint16_t i;
    3183                 :            : 
    3184   [ #  #  #  # ]:          0 :         if ((txq->ice_tx_ring[txq->tx_next_dd].cmd_type_offset_bsz &
    3185                 :            :              rte_cpu_to_le_64(ICE_TXD_QW1_DTYPE_M)) !=
    3186                 :            :             rte_cpu_to_le_64(ICE_TX_DESC_DTYPE_DESC_DONE))
    3187                 :            :                 return 0;
    3188                 :            : 
    3189                 :          0 :         txep = &txq->sw_ring[txq->tx_next_dd - (txq->tx_rs_thresh - 1)];
    3190                 :            : 
    3191   [ #  #  #  # ]:          0 :         for (i = 0; i < txq->tx_rs_thresh; i++)
    3192                 :          0 :                 rte_prefetch0((txep + i)->mbuf);
    3193                 :            : 
    3194   [ #  #  #  # ]:          0 :         if (txq->offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) {
    3195   [ #  #  #  # ]:          0 :                 for (i = 0; i < txq->tx_rs_thresh; ++i, ++txep) {
    3196   [ #  #  #  # ]:          0 :                         rte_mempool_put(txep->mbuf->pool, txep->mbuf);
    3197                 :          0 :                         txep->mbuf = NULL;
    3198                 :            :                 }
    3199                 :            :         } else {
    3200   [ #  #  #  # ]:          0 :                 for (i = 0; i < txq->tx_rs_thresh; ++i, ++txep) {
    3201                 :          0 :                         rte_pktmbuf_free_seg(txep->mbuf);
    3202                 :          0 :                         txep->mbuf = NULL;
    3203                 :            :                 }
    3204                 :            :         }
    3205                 :            : 
    3206                 :          0 :         txq->nb_tx_free = (uint16_t)(txq->nb_tx_free + txq->tx_rs_thresh);
    3207                 :          0 :         txq->tx_next_dd = (uint16_t)(txq->tx_next_dd + txq->tx_rs_thresh);
    3208   [ #  #  #  # ]:          0 :         if (txq->tx_next_dd >= txq->nb_tx_desc)
    3209                 :          0 :                 txq->tx_next_dd = (uint16_t)(txq->tx_rs_thresh - 1);
    3210                 :            : 
    3211                 :          0 :         return txq->tx_rs_thresh;
    3212                 :            : }
    3213                 :            : 
    3214                 :            : static int
    3215                 :          0 : ice_tx_done_cleanup_full(struct ci_tx_queue *txq,
    3216                 :            :                         uint32_t free_cnt)
    3217                 :            : {
    3218                 :          0 :         struct ci_tx_entry *swr_ring = txq->sw_ring;
    3219                 :            :         uint16_t i, tx_last, tx_id;
    3220                 :            :         uint16_t nb_tx_free_last;
    3221                 :            :         uint16_t nb_tx_to_clean;
    3222                 :            :         uint32_t pkt_cnt;
    3223                 :            : 
    3224                 :            :         /* Start free mbuf from the next of tx_tail */
    3225                 :          0 :         tx_last = txq->tx_tail;
    3226                 :          0 :         tx_id  = swr_ring[tx_last].next_id;
    3227                 :            : 
    3228   [ #  #  #  # ]:          0 :         if (txq->nb_tx_free == 0 && ice_xmit_cleanup(txq))
    3229                 :            :                 return 0;
    3230                 :            : 
    3231                 :          0 :         nb_tx_to_clean = txq->nb_tx_free;
    3232                 :            :         nb_tx_free_last = txq->nb_tx_free;
    3233         [ #  # ]:          0 :         if (!free_cnt)
    3234                 :          0 :                 free_cnt = txq->nb_tx_desc;
    3235                 :            : 
    3236                 :            :         /* Loop through swr_ring to count the amount of
    3237                 :            :          * freeable mubfs and packets.
    3238                 :            :          */
    3239         [ #  # ]:          0 :         for (pkt_cnt = 0; pkt_cnt < free_cnt; ) {
    3240                 :          0 :                 for (i = 0; i < nb_tx_to_clean &&
    3241   [ #  #  #  # ]:          0 :                         pkt_cnt < free_cnt &&
    3242                 :          0 :                         tx_id != tx_last; i++) {
    3243         [ #  # ]:          0 :                         if (swr_ring[tx_id].mbuf != NULL) {
    3244                 :            :                                 rte_pktmbuf_free_seg(swr_ring[tx_id].mbuf);
    3245                 :          0 :                                 swr_ring[tx_id].mbuf = NULL;
    3246                 :            : 
    3247                 :            :                                 /*
    3248                 :            :                                  * last segment in the packet,
    3249                 :            :                                  * increment packet count
    3250                 :            :                                  */
    3251                 :          0 :                                 pkt_cnt += (swr_ring[tx_id].last_id == tx_id);
    3252                 :            :                         }
    3253                 :            : 
    3254                 :          0 :                         tx_id = swr_ring[tx_id].next_id;
    3255                 :            :                 }
    3256                 :            : 
    3257                 :          0 :                 if (txq->tx_rs_thresh > txq->nb_tx_desc -
    3258   [ #  #  #  # ]:          0 :                         txq->nb_tx_free || tx_id == tx_last)
    3259                 :            :                         break;
    3260                 :            : 
    3261         [ #  # ]:          0 :                 if (pkt_cnt < free_cnt) {
    3262         [ #  # ]:          0 :                         if (ice_xmit_cleanup(txq))
    3263                 :            :                                 break;
    3264                 :            : 
    3265                 :          0 :                         nb_tx_to_clean = txq->nb_tx_free - nb_tx_free_last;
    3266                 :            :                         nb_tx_free_last = txq->nb_tx_free;
    3267                 :            :                 }
    3268                 :            :         }
    3269                 :            : 
    3270                 :          0 :         return (int)pkt_cnt;
    3271                 :            : }
    3272                 :            : 
    3273                 :            : #ifdef RTE_ARCH_X86
    3274                 :            : static int
    3275                 :            : ice_tx_done_cleanup_vec(struct ci_tx_queue *txq __rte_unused,
    3276                 :            :                         uint32_t free_cnt __rte_unused)
    3277                 :            : {
    3278                 :            :         return -ENOTSUP;
    3279                 :            : }
    3280                 :            : #endif
    3281                 :            : 
    3282                 :            : static int
    3283                 :          0 : ice_tx_done_cleanup_simple(struct ci_tx_queue *txq,
    3284                 :            :                         uint32_t free_cnt)
    3285                 :            : {
    3286                 :            :         int i, n, cnt;
    3287                 :            : 
    3288   [ #  #  #  # ]:          0 :         if (free_cnt == 0 || free_cnt > txq->nb_tx_desc)
    3289                 :          0 :                 free_cnt = txq->nb_tx_desc;
    3290                 :            : 
    3291                 :          0 :         cnt = free_cnt - free_cnt % txq->tx_rs_thresh;
    3292                 :            : 
    3293         [ #  # ]:          0 :         for (i = 0; i < cnt; i += n) {
    3294         [ #  # ]:          0 :                 if (txq->nb_tx_desc - txq->nb_tx_free < txq->tx_rs_thresh)
    3295                 :            :                         break;
    3296                 :            : 
    3297                 :            :                 n = ice_tx_free_bufs(txq);
    3298                 :            : 
    3299         [ #  # ]:          0 :                 if (n == 0)
    3300                 :            :                         break;
    3301                 :            :         }
    3302                 :            : 
    3303                 :          0 :         return i;
    3304                 :            : }
    3305                 :            : 
    3306                 :            : int
    3307                 :          0 : ice_tx_done_cleanup(void *txq, uint32_t free_cnt)
    3308                 :            : {
    3309                 :            :         struct ci_tx_queue *q = (struct ci_tx_queue *)txq;
    3310                 :          0 :         struct rte_eth_dev *dev = &rte_eth_devices[q->port_id];
    3311                 :          0 :         struct ice_adapter *ad =
    3312                 :          0 :                 ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
    3313                 :            : 
    3314                 :            : #ifdef RTE_ARCH_X86
    3315         [ #  # ]:          0 :         if (ad->tx_vec_allowed)
    3316                 :            :                 return ice_tx_done_cleanup_vec(q, free_cnt);
    3317                 :            : #endif
    3318         [ #  # ]:          0 :         if (ad->tx_simple_allowed)
    3319                 :          0 :                 return ice_tx_done_cleanup_simple(q, free_cnt);
    3320                 :            :         else
    3321                 :          0 :                 return ice_tx_done_cleanup_full(q, free_cnt);
    3322                 :            : }
    3323                 :            : 
    3324                 :            : /* Populate 4 descriptors with data from 4 mbufs */
    3325                 :            : static inline void
    3326                 :            : tx4(volatile struct ice_tx_desc *txdp, struct rte_mbuf **pkts)
    3327                 :            : {
    3328                 :            :         uint64_t dma_addr;
    3329                 :            :         uint32_t i;
    3330                 :            : 
    3331         [ #  # ]:          0 :         for (i = 0; i < 4; i++, txdp++, pkts++) {
    3332                 :          0 :                 dma_addr = rte_mbuf_data_iova(*pkts);
    3333                 :          0 :                 txdp->buf_addr = rte_cpu_to_le_64(dma_addr);
    3334                 :          0 :                 txdp->cmd_type_offset_bsz =
    3335                 :            :                         ice_build_ctob((uint32_t)ICE_TD_CMD, 0,
    3336                 :          0 :                                        (*pkts)->data_len, 0);
    3337                 :            :         }
    3338                 :            : }
    3339                 :            : 
    3340                 :            : /* Populate 1 descriptor with data from 1 mbuf */
    3341                 :            : static inline void
    3342                 :            : tx1(volatile struct ice_tx_desc *txdp, struct rte_mbuf **pkts)
    3343                 :            : {
    3344                 :            :         uint64_t dma_addr;
    3345                 :            : 
    3346                 :            :         dma_addr = rte_mbuf_data_iova(*pkts);
    3347                 :          0 :         txdp->buf_addr = rte_cpu_to_le_64(dma_addr);
    3348                 :          0 :         txdp->cmd_type_offset_bsz =
    3349                 :            :                 ice_build_ctob((uint32_t)ICE_TD_CMD, 0,
    3350                 :          0 :                                (*pkts)->data_len, 0);
    3351                 :            : }
    3352                 :            : 
    3353                 :            : static inline void
    3354                 :          0 : ice_tx_fill_hw_ring(struct ci_tx_queue *txq, struct rte_mbuf **pkts,
    3355                 :            :                     uint16_t nb_pkts)
    3356                 :            : {
    3357                 :          0 :         volatile struct ice_tx_desc *txdp = &txq->ice_tx_ring[txq->tx_tail];
    3358                 :          0 :         struct ci_tx_entry *txep = &txq->sw_ring[txq->tx_tail];
    3359                 :            :         const int N_PER_LOOP = 4;
    3360                 :            :         const int N_PER_LOOP_MASK = N_PER_LOOP - 1;
    3361                 :            :         int mainpart, leftover;
    3362                 :            :         int i, j;
    3363                 :            : 
    3364                 :            :         /**
    3365                 :            :          * Process most of the packets in chunks of N pkts.  Any
    3366                 :            :          * leftover packets will get processed one at a time.
    3367                 :            :          */
    3368                 :          0 :         mainpart = nb_pkts & ((uint32_t)~N_PER_LOOP_MASK);
    3369                 :          0 :         leftover = nb_pkts & ((uint32_t)N_PER_LOOP_MASK);
    3370         [ #  # ]:          0 :         for (i = 0; i < mainpart; i += N_PER_LOOP) {
    3371                 :            :                 /* Copy N mbuf pointers to the S/W ring */
    3372         [ #  # ]:          0 :                 for (j = 0; j < N_PER_LOOP; ++j)
    3373                 :          0 :                         (txep + i + j)->mbuf = *(pkts + i + j);
    3374                 :          0 :                 tx4(txdp + i, pkts + i);
    3375                 :            :         }
    3376                 :            : 
    3377         [ #  # ]:          0 :         if (unlikely(leftover > 0)) {
    3378         [ #  # ]:          0 :                 for (i = 0; i < leftover; ++i) {
    3379                 :          0 :                         (txep + mainpart + i)->mbuf = *(pkts + mainpart + i);
    3380                 :          0 :                         tx1(txdp + mainpart + i, pkts + mainpart + i);
    3381                 :            :                 }
    3382                 :            :         }
    3383                 :          0 : }
    3384                 :            : 
    3385                 :            : static inline uint16_t
    3386                 :          0 : tx_xmit_pkts(struct ci_tx_queue *txq,
    3387                 :            :              struct rte_mbuf **tx_pkts,
    3388                 :            :              uint16_t nb_pkts)
    3389                 :            : {
    3390                 :          0 :         volatile struct ice_tx_desc *txr = txq->ice_tx_ring;
    3391                 :            :         uint16_t n = 0;
    3392                 :            : 
    3393                 :            :         /**
    3394                 :            :          * Begin scanning the H/W ring for done descriptors when the number
    3395                 :            :          * of available descriptors drops below tx_free_thresh. For each done
    3396                 :            :          * descriptor, free the associated buffer.
    3397                 :            :          */
    3398         [ #  # ]:          0 :         if (txq->nb_tx_free < txq->tx_free_thresh)
    3399                 :            :                 ice_tx_free_bufs(txq);
    3400                 :            : 
    3401                 :            :         /* Use available descriptor only */
    3402                 :          0 :         nb_pkts = (uint16_t)RTE_MIN(txq->nb_tx_free, nb_pkts);
    3403         [ #  # ]:          0 :         if (unlikely(!nb_pkts))
    3404                 :            :                 return 0;
    3405                 :            : 
    3406                 :          0 :         txq->nb_tx_free = (uint16_t)(txq->nb_tx_free - nb_pkts);
    3407         [ #  # ]:          0 :         if ((txq->tx_tail + nb_pkts) > txq->nb_tx_desc) {
    3408                 :          0 :                 n = (uint16_t)(txq->nb_tx_desc - txq->tx_tail);
    3409                 :          0 :                 ice_tx_fill_hw_ring(txq, tx_pkts, n);
    3410                 :          0 :                 txr[txq->tx_next_rs].cmd_type_offset_bsz |=
    3411                 :            :                         rte_cpu_to_le_64(((uint64_t)ICE_TX_DESC_CMD_RS) <<
    3412                 :            :                                          ICE_TXD_QW1_CMD_S);
    3413                 :          0 :                 txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1);
    3414                 :          0 :                 txq->tx_tail = 0;
    3415                 :            :         }
    3416                 :            : 
    3417                 :            :         /* Fill hardware descriptor ring with mbuf data */
    3418                 :          0 :         ice_tx_fill_hw_ring(txq, tx_pkts + n, (uint16_t)(nb_pkts - n));
    3419                 :          0 :         txq->tx_tail = (uint16_t)(txq->tx_tail + (nb_pkts - n));
    3420                 :            : 
    3421                 :            :         /* Determine if RS bit needs to be set */
    3422         [ #  # ]:          0 :         if (txq->tx_tail > txq->tx_next_rs) {
    3423                 :          0 :                 txr[txq->tx_next_rs].cmd_type_offset_bsz |=
    3424                 :            :                         rte_cpu_to_le_64(((uint64_t)ICE_TX_DESC_CMD_RS) <<
    3425                 :            :                                          ICE_TXD_QW1_CMD_S);
    3426                 :          0 :                 txq->tx_next_rs =
    3427                 :          0 :                         (uint16_t)(txq->tx_next_rs + txq->tx_rs_thresh);
    3428         [ #  # ]:          0 :                 if (txq->tx_next_rs >= txq->nb_tx_desc)
    3429                 :          0 :                         txq->tx_next_rs = (uint16_t)(txq->tx_rs_thresh - 1);
    3430                 :            :         }
    3431                 :            : 
    3432         [ #  # ]:          0 :         if (txq->tx_tail >= txq->nb_tx_desc)
    3433                 :          0 :                 txq->tx_tail = 0;
    3434                 :            : 
    3435                 :            :         /* Update the tx tail register */
    3436                 :          0 :         ICE_PCI_REG_WC_WRITE(txq->qtx_tail, txq->tx_tail);
    3437                 :            : 
    3438                 :            :         return nb_pkts;
    3439                 :            : }
    3440                 :            : 
    3441                 :            : static uint16_t
    3442                 :          0 : ice_xmit_pkts_simple(void *tx_queue,
    3443                 :            :                      struct rte_mbuf **tx_pkts,
    3444                 :            :                      uint16_t nb_pkts)
    3445                 :            : {
    3446                 :            :         uint16_t nb_tx = 0;
    3447                 :            : 
    3448         [ #  # ]:          0 :         if (likely(nb_pkts <= ICE_TX_MAX_BURST))
    3449                 :          0 :                 return tx_xmit_pkts((struct ci_tx_queue *)tx_queue,
    3450                 :            :                                     tx_pkts, nb_pkts);
    3451                 :            : 
    3452         [ #  # ]:          0 :         while (nb_pkts) {
    3453                 :          0 :                 uint16_t ret, num = (uint16_t)RTE_MIN(nb_pkts,
    3454                 :            :                                                       ICE_TX_MAX_BURST);
    3455                 :            : 
    3456                 :          0 :                 ret = tx_xmit_pkts((struct ci_tx_queue *)tx_queue,
    3457                 :          0 :                                    &tx_pkts[nb_tx], num);
    3458                 :          0 :                 nb_tx = (uint16_t)(nb_tx + ret);
    3459                 :          0 :                 nb_pkts = (uint16_t)(nb_pkts - ret);
    3460         [ #  # ]:          0 :                 if (ret < num)
    3461                 :            :                         break;
    3462                 :            :         }
    3463                 :            : 
    3464                 :            :         return nb_tx;
    3465                 :            : }
    3466                 :            : 
    3467                 :            : void __rte_cold
    3468                 :          0 : ice_set_rx_function(struct rte_eth_dev *dev)
    3469                 :            : {
    3470                 :          0 :         PMD_INIT_FUNC_TRACE();
    3471                 :          0 :         struct ice_adapter *ad =
    3472                 :          0 :                 ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
    3473                 :            : #ifdef RTE_ARCH_X86
    3474                 :            :         struct ice_rx_queue *rxq;
    3475                 :            :         int i;
    3476                 :            :         int rx_check_ret = -1;
    3477                 :            : 
    3478         [ #  # ]:          0 :         if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
    3479                 :          0 :                 ad->rx_use_avx512 = false;
    3480                 :          0 :                 ad->rx_use_avx2 = false;
    3481                 :          0 :                 rx_check_ret = ice_rx_vec_dev_check(dev);
    3482         [ #  # ]:          0 :                 if (ad->ptp_ena)
    3483                 :            :                         rx_check_ret = -1;
    3484                 :          0 :                 ad->rx_vec_offload_support =
    3485                 :          0 :                                 (rx_check_ret == ICE_VECTOR_OFFLOAD_PATH);
    3486   [ #  #  #  #  :          0 :                 if (rx_check_ret >= 0 && ad->rx_bulk_alloc_allowed &&
                   #  # ]
    3487                 :          0 :                     rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128) {
    3488                 :          0 :                         ad->rx_vec_allowed = true;
    3489         [ #  # ]:          0 :                         for (i = 0; i < dev->data->nb_rx_queues; i++) {
    3490                 :          0 :                                 rxq = dev->data->rx_queues[i];
    3491   [ #  #  #  # ]:          0 :                                 if (rxq && ice_rxq_vec_setup(rxq)) {
    3492                 :          0 :                                         ad->rx_vec_allowed = false;
    3493                 :          0 :                                         break;
    3494                 :            :                                 }
    3495                 :            :                         }
    3496                 :            : 
    3497   [ #  #  #  # ]:          0 :                         if (rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_512 &&
    3498         [ #  # ]:          0 :                         rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1 &&
    3499                 :          0 :                         rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512BW) == 1)
    3500                 :            : #ifdef CC_AVX512_SUPPORT
    3501                 :          0 :                                 ad->rx_use_avx512 = true;
    3502                 :            : #else
    3503                 :            :                         PMD_DRV_LOG(NOTICE,
    3504                 :            :                                 "AVX512 is not supported in build env");
    3505                 :            : #endif
    3506   [ #  #  #  # ]:          0 :                         if (!ad->rx_use_avx512 &&
    3507         [ #  # ]:          0 :                         (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2) == 1 ||
    3508         [ #  # ]:          0 :                         rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1) &&
    3509                 :          0 :                         rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_256)
    3510                 :          0 :                                 ad->rx_use_avx2 = true;
    3511                 :            : 
    3512                 :            :                 } else {
    3513                 :          0 :                         ad->rx_vec_allowed = false;
    3514                 :            :                 }
    3515                 :            :         }
    3516                 :            : 
    3517         [ #  # ]:          0 :         if (ad->rx_vec_allowed) {
    3518         [ #  # ]:          0 :                 if (dev->data->scattered_rx) {
    3519         [ #  # ]:          0 :                         if (ad->rx_use_avx512) {
    3520                 :            : #ifdef CC_AVX512_SUPPORT
    3521         [ #  # ]:          0 :                                 if (ad->rx_vec_offload_support) {
    3522                 :          0 :                                         PMD_DRV_LOG(NOTICE,
    3523                 :            :                                                 "Using AVX512 OFFLOAD Vector Scattered Rx (port %d).",
    3524                 :            :                                                 dev->data->port_id);
    3525                 :          0 :                                         dev->rx_pkt_burst =
    3526                 :            :                                                 ice_recv_scattered_pkts_vec_avx512_offload;
    3527                 :            :                                 } else {
    3528                 :          0 :                                         PMD_DRV_LOG(NOTICE,
    3529                 :            :                                                 "Using AVX512 Vector Scattered Rx (port %d).",
    3530                 :            :                                                 dev->data->port_id);
    3531                 :          0 :                                         dev->rx_pkt_burst =
    3532                 :            :                                                 ice_recv_scattered_pkts_vec_avx512;
    3533                 :            :                                 }
    3534                 :            : #endif
    3535         [ #  # ]:          0 :                         } else if (ad->rx_use_avx2) {
    3536         [ #  # ]:          0 :                                 if (ad->rx_vec_offload_support) {
    3537                 :          0 :                                         PMD_DRV_LOG(NOTICE,
    3538                 :            :                                                     "Using AVX2 OFFLOAD Vector Scattered Rx (port %d).",
    3539                 :            :                                                     dev->data->port_id);
    3540                 :          0 :                                         dev->rx_pkt_burst =
    3541                 :            :                                                 ice_recv_scattered_pkts_vec_avx2_offload;
    3542                 :            :                                 } else {
    3543                 :          0 :                                         PMD_DRV_LOG(NOTICE,
    3544                 :            :                                                     "Using AVX2 Vector Scattered Rx (port %d).",
    3545                 :            :                                                     dev->data->port_id);
    3546                 :          0 :                                         dev->rx_pkt_burst =
    3547                 :            :                                                 ice_recv_scattered_pkts_vec_avx2;
    3548                 :            :                                 }
    3549                 :            :                         } else {
    3550                 :          0 :                                 PMD_DRV_LOG(DEBUG,
    3551                 :            :                                         "Using Vector Scattered Rx (port %d).",
    3552                 :            :                                         dev->data->port_id);
    3553                 :          0 :                                 dev->rx_pkt_burst = ice_recv_scattered_pkts_vec;
    3554                 :            :                         }
    3555                 :            :                 } else {
    3556         [ #  # ]:          0 :                         if (ad->rx_use_avx512) {
    3557                 :            : #ifdef CC_AVX512_SUPPORT
    3558         [ #  # ]:          0 :                                 if (ad->rx_vec_offload_support) {
    3559                 :          0 :                                         PMD_DRV_LOG(NOTICE,
    3560                 :            :                                                 "Using AVX512 OFFLOAD Vector Rx (port %d).",
    3561                 :            :                                                 dev->data->port_id);
    3562                 :          0 :                                         dev->rx_pkt_burst =
    3563                 :            :                                                 ice_recv_pkts_vec_avx512_offload;
    3564                 :            :                                 } else {
    3565                 :          0 :                                         PMD_DRV_LOG(NOTICE,
    3566                 :            :                                                 "Using AVX512 Vector Rx (port %d).",
    3567                 :            :                                                 dev->data->port_id);
    3568                 :          0 :                                         dev->rx_pkt_burst =
    3569                 :            :                                                 ice_recv_pkts_vec_avx512;
    3570                 :            :                                 }
    3571                 :            : #endif
    3572         [ #  # ]:          0 :                         } else if (ad->rx_use_avx2) {
    3573         [ #  # ]:          0 :                                 if (ad->rx_vec_offload_support) {
    3574                 :          0 :                                         PMD_DRV_LOG(NOTICE,
    3575                 :            :                                                     "Using AVX2 OFFLOAD Vector Rx (port %d).",
    3576                 :            :                                                     dev->data->port_id);
    3577                 :          0 :                                         dev->rx_pkt_burst =
    3578                 :            :                                                 ice_recv_pkts_vec_avx2_offload;
    3579                 :            :                                 } else {
    3580                 :          0 :                                         PMD_DRV_LOG(NOTICE,
    3581                 :            :                                                     "Using AVX2 Vector Rx (port %d).",
    3582                 :            :                                                     dev->data->port_id);
    3583                 :          0 :                                         dev->rx_pkt_burst =
    3584                 :            :                                                 ice_recv_pkts_vec_avx2;
    3585                 :            :                                 }
    3586                 :            :                         } else {
    3587                 :          0 :                                 PMD_DRV_LOG(DEBUG,
    3588                 :            :                                         "Using Vector Rx (port %d).",
    3589                 :            :                                         dev->data->port_id);
    3590                 :          0 :                                 dev->rx_pkt_burst = ice_recv_pkts_vec;
    3591                 :            :                         }
    3592                 :            :                 }
    3593                 :          0 :                 return;
    3594                 :            :         }
    3595                 :            : 
    3596                 :            : #endif
    3597                 :            : 
    3598         [ #  # ]:          0 :         if (dev->data->scattered_rx) {
    3599                 :            :                 /* Set the non-LRO scattered function */
    3600                 :          0 :                 PMD_INIT_LOG(DEBUG,
    3601                 :            :                              "Using a Scattered function on port %d.",
    3602                 :            :                              dev->data->port_id);
    3603                 :          0 :                 dev->rx_pkt_burst = ice_recv_scattered_pkts;
    3604         [ #  # ]:          0 :         } else if (ad->rx_bulk_alloc_allowed) {
    3605                 :          0 :                 PMD_INIT_LOG(DEBUG,
    3606                 :            :                              "Rx Burst Bulk Alloc Preconditions are "
    3607                 :            :                              "satisfied. Rx Burst Bulk Alloc function "
    3608                 :            :                              "will be used on port %d.",
    3609                 :            :                              dev->data->port_id);
    3610                 :          0 :                 dev->rx_pkt_burst = ice_recv_pkts_bulk_alloc;
    3611                 :            :         } else {
    3612                 :          0 :                 PMD_INIT_LOG(DEBUG,
    3613                 :            :                              "Rx Burst Bulk Alloc Preconditions are not "
    3614                 :            :                              "satisfied, Normal Rx will be used on port %d.",
    3615                 :            :                              dev->data->port_id);
    3616                 :          0 :                 dev->rx_pkt_burst = ice_recv_pkts;
    3617                 :            :         }
    3618                 :            : }
    3619                 :            : 
    3620                 :            : static const struct {
    3621                 :            :         eth_rx_burst_t pkt_burst;
    3622                 :            :         const char *info;
    3623                 :            : } ice_rx_burst_infos[] = {
    3624                 :            :         { ice_recv_scattered_pkts,          "Scalar Scattered" },
    3625                 :            :         { ice_recv_pkts_bulk_alloc,         "Scalar Bulk Alloc" },
    3626                 :            :         { ice_recv_pkts,                    "Scalar" },
    3627                 :            : #ifdef RTE_ARCH_X86
    3628                 :            : #ifdef CC_AVX512_SUPPORT
    3629                 :            :         { ice_recv_scattered_pkts_vec_avx512, "Vector AVX512 Scattered" },
    3630                 :            :         { ice_recv_scattered_pkts_vec_avx512_offload, "Offload Vector AVX512 Scattered" },
    3631                 :            :         { ice_recv_pkts_vec_avx512,           "Vector AVX512" },
    3632                 :            :         { ice_recv_pkts_vec_avx512_offload,   "Offload Vector AVX512" },
    3633                 :            : #endif
    3634                 :            :         { ice_recv_scattered_pkts_vec_avx2, "Vector AVX2 Scattered" },
    3635                 :            :         { ice_recv_scattered_pkts_vec_avx2_offload, "Offload Vector AVX2 Scattered" },
    3636                 :            :         { ice_recv_pkts_vec_avx2,           "Vector AVX2" },
    3637                 :            :         { ice_recv_pkts_vec_avx2_offload,   "Offload Vector AVX2" },
    3638                 :            :         { ice_recv_scattered_pkts_vec,      "Vector SSE Scattered" },
    3639                 :            :         { ice_recv_pkts_vec,                "Vector SSE" },
    3640                 :            : #endif
    3641                 :            : };
    3642                 :            : 
    3643                 :            : int
    3644                 :          0 : ice_rx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
    3645                 :            :                       struct rte_eth_burst_mode *mode)
    3646                 :            : {
    3647                 :          0 :         eth_rx_burst_t pkt_burst = dev->rx_pkt_burst;
    3648                 :            :         int ret = -EINVAL;
    3649                 :            :         unsigned int i;
    3650                 :            : 
    3651         [ #  # ]:          0 :         for (i = 0; i < RTE_DIM(ice_rx_burst_infos); ++i) {
    3652         [ #  # ]:          0 :                 if (pkt_burst == ice_rx_burst_infos[i].pkt_burst) {
    3653                 :          0 :                         snprintf(mode->info, sizeof(mode->info), "%s",
    3654                 :          0 :                                  ice_rx_burst_infos[i].info);
    3655                 :            :                         ret = 0;
    3656                 :          0 :                         break;
    3657                 :            :                 }
    3658                 :            :         }
    3659                 :            : 
    3660                 :          0 :         return ret;
    3661                 :            : }
    3662                 :            : 
    3663                 :            : void __rte_cold
    3664                 :          0 : ice_set_tx_function_flag(struct rte_eth_dev *dev, struct ci_tx_queue *txq)
    3665                 :            : {
    3666                 :          0 :         struct ice_adapter *ad =
    3667                 :          0 :                 ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
    3668                 :            : 
    3669                 :            :         /* Use a simple Tx queue if possible (only fast free is allowed) */
    3670                 :          0 :         ad->tx_simple_allowed =
    3671                 :          0 :                 (txq->offloads ==
    3672         [ #  # ]:          0 :                 (txq->offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE) &&
    3673         [ #  # ]:          0 :                 txq->tx_rs_thresh >= ICE_TX_MAX_BURST);
    3674                 :            : 
    3675         [ #  # ]:          0 :         if (ad->tx_simple_allowed)
    3676                 :          0 :                 PMD_INIT_LOG(DEBUG, "Simple Tx can be enabled on Tx queue %u.",
    3677                 :            :                              txq->queue_id);
    3678                 :            :         else
    3679                 :          0 :                 PMD_INIT_LOG(DEBUG,
    3680                 :            :                              "Simple Tx can NOT be enabled on Tx queue %u.",
    3681                 :            :                              txq->queue_id);
    3682                 :          0 : }
    3683                 :            : 
    3684                 :            : /*********************************************************************
    3685                 :            :  *
    3686                 :            :  *  TX prep functions
    3687                 :            :  *
    3688                 :            :  **********************************************************************/
    3689                 :            : /* The default values of TSO MSS */
    3690                 :            : #define ICE_MIN_TSO_MSS            64
    3691                 :            : #define ICE_MAX_TSO_MSS            9728
    3692                 :            : #define ICE_MAX_TSO_FRAME_SIZE     262144
    3693                 :            : 
    3694                 :            : /*Check for empty mbuf*/
    3695                 :            : static inline uint16_t
    3696                 :            : ice_check_empty_mbuf(struct rte_mbuf *tx_pkt)
    3697                 :            : {
    3698                 :            :         struct rte_mbuf *txd = tx_pkt;
    3699                 :            : 
    3700         [ #  # ]:          0 :         while (txd != NULL) {
    3701         [ #  # ]:          0 :                 if (txd->data_len == 0)
    3702                 :            :                         return -1;
    3703                 :          0 :                 txd = txd->next;
    3704                 :            :         }
    3705                 :            : 
    3706                 :            :         return 0;
    3707                 :            : }
    3708                 :            : 
    3709                 :            : /* Tx mbuf check */
    3710                 :            : static uint16_t
    3711                 :          0 : ice_xmit_pkts_check(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
    3712                 :            : {
    3713                 :            :         struct ci_tx_queue *txq = tx_queue;
    3714                 :            :         uint16_t idx;
    3715                 :            :         struct rte_mbuf *mb;
    3716                 :            :         bool pkt_error = false;
    3717                 :            :         uint16_t good_pkts = nb_pkts;
    3718                 :          0 :         const char *reason = NULL;
    3719                 :          0 :         struct ice_adapter *adapter = txq->ice_vsi->adapter;
    3720                 :            :         uint64_t ol_flags;
    3721                 :            : 
    3722         [ #  # ]:          0 :         for (idx = 0; idx < nb_pkts; idx++) {
    3723                 :          0 :                 mb = tx_pkts[idx];
    3724                 :          0 :                 ol_flags = mb->ol_flags;
    3725                 :            : 
    3726   [ #  #  #  # ]:          0 :                 if ((adapter->devargs.mbuf_check & ICE_MBUF_CHECK_F_TX_MBUF) &&
    3727                 :          0 :                     (rte_mbuf_check(mb, 1, &reason) != 0)) {
    3728                 :            :                         PMD_TX_LOG(ERR, "INVALID mbuf: %s", reason);
    3729                 :            :                         pkt_error = true;
    3730                 :            :                         break;
    3731                 :            :                 }
    3732                 :            : 
    3733         [ #  # ]:          0 :                 if ((adapter->devargs.mbuf_check & ICE_MBUF_CHECK_F_TX_SIZE) &&
    3734   [ #  #  #  # ]:          0 :                     (mb->data_len > mb->pkt_len ||
    3735         [ #  # ]:          0 :                      mb->data_len < ICE_TX_MIN_PKT_LEN ||
    3736                 :            :                      mb->data_len > ICE_FRAME_SIZE_MAX)) {
    3737                 :            :                         PMD_TX_LOG(ERR, "INVALID mbuf: data_len (%u) is out of range, reasonable range (%d - %d)",
    3738                 :            :                                 mb->data_len, ICE_TX_MIN_PKT_LEN, ICE_FRAME_SIZE_MAX);
    3739                 :            :                         pkt_error = true;
    3740                 :            :                         break;
    3741                 :            :                 }
    3742                 :            : 
    3743         [ #  # ]:          0 :                 if (adapter->devargs.mbuf_check & ICE_MBUF_CHECK_F_TX_SEGMENT) {
    3744         [ #  # ]:          0 :                         if (!(ol_flags & RTE_MBUF_F_TX_TCP_SEG)) {
    3745                 :            :                                 /**
    3746                 :            :                                  * No TSO case: nb->segs, pkt_len to not exceed
    3747                 :            :                                  * the limites.
    3748                 :            :                                  */
    3749         [ #  # ]:          0 :                                 if (mb->nb_segs > ICE_TX_MTU_SEG_MAX) {
    3750                 :            :                                         PMD_TX_LOG(ERR, "INVALID mbuf: nb_segs (%d) exceeds HW limit, maximum allowed value is %d",
    3751                 :            :                                                 mb->nb_segs, ICE_TX_MTU_SEG_MAX);
    3752                 :            :                                         pkt_error = true;
    3753                 :            :                                         break;
    3754                 :            :                                 }
    3755         [ #  # ]:          0 :                                 if (mb->pkt_len > ICE_FRAME_SIZE_MAX) {
    3756                 :            :                                         PMD_TX_LOG(ERR, "INVALID mbuf: pkt_len (%d) exceeds HW limit, maximum allowed value is %d",
    3757                 :            :                                                 mb->nb_segs, ICE_FRAME_SIZE_MAX);
    3758                 :            :                                         pkt_error = true;
    3759                 :            :                                         break;
    3760                 :            :                                 }
    3761                 :            :                         } else if (ol_flags & RTE_MBUF_F_TX_TCP_SEG) {
    3762                 :            :                                 /** TSO case: tso_segsz, nb_segs, pkt_len not exceed
    3763                 :            :                                  * the limits.
    3764                 :            :                                  */
    3765         [ #  # ]:          0 :                                 if (mb->tso_segsz < ICE_MIN_TSO_MSS ||
    3766                 :            :                                     mb->tso_segsz > ICE_MAX_TSO_MSS) {
    3767                 :            :                                         /**
    3768                 :            :                                          * MSS outside the range are considered malicious
    3769                 :            :                                          */
    3770                 :            :                                         PMD_TX_LOG(ERR, "INVALID mbuf: tso_segsz (%u) is out of range, reasonable range (%d - %u)",
    3771                 :            :                                                 mb->tso_segsz, ICE_MIN_TSO_MSS, ICE_MAX_TSO_MSS);
    3772                 :            :                                         pkt_error = true;
    3773                 :            :                                         break;
    3774                 :            :                                 }
    3775         [ #  # ]:          0 :                                 if (mb->nb_segs > ((struct ci_tx_queue *)tx_queue)->nb_tx_desc) {
    3776                 :            :                                         PMD_TX_LOG(ERR, "INVALID mbuf: nb_segs out of ring length");
    3777                 :            :                                         pkt_error = true;
    3778                 :            :                                         break;
    3779                 :            :                                 }
    3780                 :            :                         }
    3781                 :            :                 }
    3782                 :            : 
    3783         [ #  # ]:          0 :                 if (adapter->devargs.mbuf_check & ICE_MBUF_CHECK_F_TX_OFFLOAD) {
    3784         [ #  # ]:          0 :                         if (ol_flags & ICE_TX_OFFLOAD_NOTSUP_MASK) {
    3785                 :            :                                 PMD_TX_LOG(ERR, "INVALID mbuf: TX offload is not supported");
    3786                 :            :                                 pkt_error = true;
    3787                 :            :                                 break;
    3788                 :            :                         }
    3789                 :            : 
    3790         [ #  # ]:          0 :                         if (!rte_validate_tx_offload(mb)) {
    3791                 :            :                                 PMD_TX_LOG(ERR, "INVALID mbuf: TX offload setup error");
    3792                 :            :                                 pkt_error = true;
    3793                 :            :                                 break;
    3794                 :            :                         }
    3795                 :            :                 }
    3796                 :            :         }
    3797                 :            : 
    3798         [ #  # ]:          0 :         if (pkt_error) {
    3799                 :          0 :                 txq->mbuf_errors++;
    3800                 :            :                 good_pkts = idx;
    3801         [ #  # ]:          0 :                 if (good_pkts == 0)
    3802                 :            :                         return 0;
    3803                 :            :         }
    3804                 :            : 
    3805                 :          0 :         return adapter->tx_pkt_burst(tx_queue, tx_pkts, good_pkts);
    3806                 :            : }
    3807                 :            : 
    3808                 :            : uint16_t
    3809                 :          0 : ice_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
    3810                 :            :               uint16_t nb_pkts)
    3811                 :            : {
    3812                 :            :         int i, ret;
    3813                 :            :         uint64_t ol_flags;
    3814                 :            :         struct rte_mbuf *m;
    3815                 :            : 
    3816         [ #  # ]:          0 :         for (i = 0; i < nb_pkts; i++) {
    3817                 :          0 :                 m = tx_pkts[i];
    3818                 :          0 :                 ol_flags = m->ol_flags;
    3819                 :            : 
    3820         [ #  # ]:          0 :                 if (!(ol_flags & RTE_MBUF_F_TX_TCP_SEG) &&
    3821                 :            :                     /**
    3822                 :            :                      * No TSO case: nb->segs, pkt_len to not exceed
    3823                 :            :                      * the limites.
    3824                 :            :                      */
    3825         [ #  # ]:          0 :                     (m->nb_segs > ICE_TX_MTU_SEG_MAX ||
    3826         [ #  # ]:          0 :                      m->pkt_len > ICE_FRAME_SIZE_MAX)) {
    3827                 :          0 :                         rte_errno = EINVAL;
    3828                 :          0 :                         return i;
    3829         [ #  # ]:          0 :                 } else if (ol_flags & RTE_MBUF_F_TX_TCP_SEG &&
    3830                 :            :                     /** TSO case: tso_segsz, nb_segs, pkt_len not exceed
    3831                 :            :                      * the limits.
    3832                 :            :                      */
    3833         [ #  # ]:          0 :                     (m->tso_segsz < ICE_MIN_TSO_MSS ||
    3834                 :          0 :                      m->tso_segsz > ICE_MAX_TSO_MSS ||
    3835                 :          0 :                      m->nb_segs >
    3836         [ #  # ]:          0 :                         ((struct ci_tx_queue *)tx_queue)->nb_tx_desc ||
    3837         [ #  # ]:          0 :                      m->pkt_len > ICE_MAX_TSO_FRAME_SIZE)) {
    3838                 :            :                         /**
    3839                 :            :                          * MSS outside the range are considered malicious
    3840                 :            :                          */
    3841                 :          0 :                         rte_errno = EINVAL;
    3842                 :          0 :                         return i;
    3843                 :            :                 }
    3844                 :            : 
    3845         [ #  # ]:          0 :                 if (m->pkt_len < ICE_TX_MIN_PKT_LEN) {
    3846                 :          0 :                         rte_errno = EINVAL;
    3847                 :          0 :                         return i;
    3848                 :            :                 }
    3849                 :            : 
    3850                 :            : #ifdef RTE_ETHDEV_DEBUG_TX
    3851                 :            :                 ret = rte_validate_tx_offload(m);
    3852                 :            :                 if (ret != 0) {
    3853                 :            :                         rte_errno = -ret;
    3854                 :            :                         return i;
    3855                 :            :                 }
    3856                 :            : #endif
    3857                 :            :                 ret = rte_net_intel_cksum_prepare(m);
    3858         [ #  # ]:          0 :                 if (ret != 0) {
    3859                 :          0 :                         rte_errno = -ret;
    3860                 :          0 :                         return i;
    3861                 :            :                 }
    3862                 :            : 
    3863         [ #  # ]:          0 :                 if (ice_check_empty_mbuf(m) != 0) {
    3864                 :          0 :                         rte_errno = EINVAL;
    3865                 :          0 :                         return i;
    3866                 :            :                 }
    3867                 :            :         }
    3868                 :          0 :         return i;
    3869                 :            : }
    3870                 :            : 
    3871                 :            : void __rte_cold
    3872                 :          0 : ice_set_tx_function(struct rte_eth_dev *dev)
    3873                 :            : {
    3874                 :          0 :         struct ice_adapter *ad =
    3875                 :          0 :                 ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
    3876                 :          0 :         int mbuf_check = ad->devargs.mbuf_check;
    3877                 :            : #ifdef RTE_ARCH_X86
    3878                 :            :         struct ci_tx_queue *txq;
    3879                 :            :         int i;
    3880                 :            :         int tx_check_ret = -1;
    3881                 :            : 
    3882         [ #  # ]:          0 :         if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
    3883                 :          0 :                 ad->tx_use_avx2 = false;
    3884                 :          0 :                 ad->tx_use_avx512 = false;
    3885                 :          0 :                 tx_check_ret = ice_tx_vec_dev_check(dev);
    3886   [ #  #  #  # ]:          0 :                 if (tx_check_ret >= 0 &&
    3887                 :          0 :                     rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128) {
    3888                 :          0 :                         ad->tx_vec_allowed = true;
    3889                 :            : 
    3890   [ #  #  #  # ]:          0 :                         if (rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_512 &&
    3891         [ #  # ]:          0 :                         rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1 &&
    3892                 :          0 :                         rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512BW) == 1)
    3893                 :            : #ifdef CC_AVX512_SUPPORT
    3894                 :          0 :                                 ad->tx_use_avx512 = true;
    3895                 :            : #else
    3896                 :            :                         PMD_DRV_LOG(NOTICE,
    3897                 :            :                                 "AVX512 is not supported in build env");
    3898                 :            : #endif
    3899   [ #  #  #  # ]:          0 :                         if (!ad->tx_use_avx512 &&
    3900         [ #  # ]:          0 :                                 (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2) == 1 ||
    3901         [ #  # ]:          0 :                                 rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1) &&
    3902                 :          0 :                                 rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_256)
    3903                 :          0 :                                 ad->tx_use_avx2 = true;
    3904                 :            : 
    3905   [ #  #  #  #  :          0 :                         if (!ad->tx_use_avx2 && !ad->tx_use_avx512 &&
                   #  # ]
    3906                 :            :                                 tx_check_ret == ICE_VECTOR_OFFLOAD_PATH)
    3907                 :          0 :                                 ad->tx_vec_allowed = false;
    3908                 :            : 
    3909         [ #  # ]:          0 :                         if (ad->tx_vec_allowed) {
    3910         [ #  # ]:          0 :                                 for (i = 0; i < dev->data->nb_tx_queues; i++) {
    3911                 :          0 :                                         txq = dev->data->tx_queues[i];
    3912   [ #  #  #  # ]:          0 :                                         if (txq && ice_txq_vec_setup(txq)) {
    3913                 :          0 :                                                 ad->tx_vec_allowed = false;
    3914                 :          0 :                                                 break;
    3915                 :            :                                         }
    3916                 :            :                                 }
    3917                 :            :                         }
    3918                 :            :                 } else {
    3919                 :          0 :                         ad->tx_vec_allowed = false;
    3920                 :            :                 }
    3921                 :            :         }
    3922                 :            : 
    3923         [ #  # ]:          0 :         if (ad->tx_vec_allowed) {
    3924                 :          0 :                 dev->tx_pkt_prepare = NULL;
    3925         [ #  # ]:          0 :                 if (ad->tx_use_avx512) {
    3926                 :            : #ifdef CC_AVX512_SUPPORT
    3927         [ #  # ]:          0 :                         if (tx_check_ret == ICE_VECTOR_OFFLOAD_PATH) {
    3928                 :          0 :                                 PMD_DRV_LOG(NOTICE,
    3929                 :            :                                             "Using AVX512 OFFLOAD Vector Tx (port %d).",
    3930                 :            :                                             dev->data->port_id);
    3931                 :          0 :                                 dev->tx_pkt_burst =
    3932                 :            :                                         ice_xmit_pkts_vec_avx512_offload;
    3933                 :          0 :                                 dev->tx_pkt_prepare = ice_prep_pkts;
    3934                 :            :                         } else {
    3935                 :          0 :                                 PMD_DRV_LOG(NOTICE,
    3936                 :            :                                             "Using AVX512 Vector Tx (port %d).",
    3937                 :            :                                             dev->data->port_id);
    3938                 :          0 :                                 dev->tx_pkt_burst = ice_xmit_pkts_vec_avx512;
    3939                 :            :                         }
    3940                 :            : #endif
    3941                 :            :                 } else {
    3942         [ #  # ]:          0 :                         if (tx_check_ret == ICE_VECTOR_OFFLOAD_PATH) {
    3943                 :          0 :                                 PMD_DRV_LOG(NOTICE,
    3944                 :            :                                             "Using AVX2 OFFLOAD Vector Tx (port %d).",
    3945                 :            :                                             dev->data->port_id);
    3946                 :          0 :                                 dev->tx_pkt_burst =
    3947                 :            :                                         ice_xmit_pkts_vec_avx2_offload;
    3948                 :          0 :                                 dev->tx_pkt_prepare = ice_prep_pkts;
    3949                 :            :                         } else {
    3950         [ #  # ]:          0 :                                 PMD_DRV_LOG(DEBUG, "Using %sVector Tx (port %d).",
    3951                 :            :                                             ad->tx_use_avx2 ? "avx2 " : "",
    3952                 :            :                                             dev->data->port_id);
    3953                 :          0 :                                 dev->tx_pkt_burst = ad->tx_use_avx2 ?
    3954         [ #  # ]:          0 :                                                     ice_xmit_pkts_vec_avx2 :
    3955                 :            :                                                     ice_xmit_pkts_vec;
    3956                 :            :                         }
    3957                 :            :                 }
    3958                 :            : 
    3959         [ #  # ]:          0 :                 if (mbuf_check) {
    3960                 :          0 :                         ad->tx_pkt_burst = dev->tx_pkt_burst;
    3961                 :          0 :                         dev->tx_pkt_burst = ice_xmit_pkts_check;
    3962                 :            :                 }
    3963                 :          0 :                 return;
    3964                 :            :         }
    3965                 :            : #endif
    3966                 :            : 
    3967         [ #  # ]:          0 :         if (ad->tx_simple_allowed) {
    3968                 :          0 :                 PMD_INIT_LOG(DEBUG, "Simple tx finally be used.");
    3969                 :          0 :                 dev->tx_pkt_burst = ice_xmit_pkts_simple;
    3970                 :          0 :                 dev->tx_pkt_prepare = NULL;
    3971                 :            :         } else {
    3972                 :          0 :                 PMD_INIT_LOG(DEBUG, "Normal tx finally be used.");
    3973                 :          0 :                 dev->tx_pkt_burst = ice_xmit_pkts;
    3974                 :          0 :                 dev->tx_pkt_prepare = ice_prep_pkts;
    3975                 :            :         }
    3976                 :            : 
    3977         [ #  # ]:          0 :         if (mbuf_check) {
    3978                 :          0 :                 ad->tx_pkt_burst = dev->tx_pkt_burst;
    3979                 :          0 :                 dev->tx_pkt_burst = ice_xmit_pkts_check;
    3980                 :            :         }
    3981                 :            : }
    3982                 :            : 
    3983                 :            : static const struct {
    3984                 :            :         eth_tx_burst_t pkt_burst;
    3985                 :            :         const char *info;
    3986                 :            : } ice_tx_burst_infos[] = {
    3987                 :            :         { ice_xmit_pkts_simple,   "Scalar Simple" },
    3988                 :            :         { ice_xmit_pkts,          "Scalar" },
    3989                 :            : #ifdef RTE_ARCH_X86
    3990                 :            : #ifdef CC_AVX512_SUPPORT
    3991                 :            :         { ice_xmit_pkts_vec_avx512, "Vector AVX512" },
    3992                 :            :         { ice_xmit_pkts_vec_avx512_offload, "Offload Vector AVX512" },
    3993                 :            : #endif
    3994                 :            :         { ice_xmit_pkts_vec_avx2,         "Vector AVX2" },
    3995                 :            :         { ice_xmit_pkts_vec_avx2_offload, "Offload Vector AVX2" },
    3996                 :            :         { ice_xmit_pkts_vec,              "Vector SSE" },
    3997                 :            : #endif
    3998                 :            : };
    3999                 :            : 
    4000                 :            : int
    4001                 :          0 : ice_tx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
    4002                 :            :                       struct rte_eth_burst_mode *mode)
    4003                 :            : {
    4004                 :          0 :         eth_tx_burst_t pkt_burst = dev->tx_pkt_burst;
    4005                 :            :         int ret = -EINVAL;
    4006                 :            :         unsigned int i;
    4007                 :            : 
    4008         [ #  # ]:          0 :         for (i = 0; i < RTE_DIM(ice_tx_burst_infos); ++i) {
    4009         [ #  # ]:          0 :                 if (pkt_burst == ice_tx_burst_infos[i].pkt_burst) {
    4010                 :          0 :                         snprintf(mode->info, sizeof(mode->info), "%s",
    4011                 :          0 :                                  ice_tx_burst_infos[i].info);
    4012                 :            :                         ret = 0;
    4013                 :          0 :                         break;
    4014                 :            :                 }
    4015                 :            :         }
    4016                 :            : 
    4017                 :          0 :         return ret;
    4018                 :            : }
    4019                 :            : 
    4020                 :            : /* For each value it means, datasheet of hardware can tell more details
    4021                 :            :  *
    4022                 :            :  * @note: fix ice_dev_supported_ptypes_get() if any change here.
    4023                 :            :  */
    4024                 :            : static inline uint32_t
    4025                 :            : ice_get_default_pkt_type(uint16_t ptype)
    4026                 :            : {
    4027                 :            :         static const alignas(RTE_CACHE_LINE_SIZE) uint32_t type_table[ICE_MAX_PKT_TYPE] = {
    4028                 :            :                 /* L2 types */
    4029                 :            :                 /* [0] reserved */
    4030                 :            :                 [1] = RTE_PTYPE_L2_ETHER,
    4031                 :            :                 [2] = RTE_PTYPE_L2_ETHER_TIMESYNC,
    4032                 :            :                 /* [3] - [5] reserved */
    4033                 :            :                 [6] = RTE_PTYPE_L2_ETHER_LLDP,
    4034                 :            :                 /* [7] - [10] reserved */
    4035                 :            :                 [11] = RTE_PTYPE_L2_ETHER_ARP,
    4036                 :            :                 /* [12] - [21] reserved */
    4037                 :            : 
    4038                 :            :                 /* Non tunneled IPv4 */
    4039                 :            :                 [22] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4040                 :            :                        RTE_PTYPE_L4_FRAG,
    4041                 :            :                 [23] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4042                 :            :                        RTE_PTYPE_L4_NONFRAG,
    4043                 :            :                 [24] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4044                 :            :                        RTE_PTYPE_L4_UDP,
    4045                 :            :                 /* [25] reserved */
    4046                 :            :                 [26] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4047                 :            :                        RTE_PTYPE_L4_TCP,
    4048                 :            :                 [27] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4049                 :            :                        RTE_PTYPE_L4_SCTP,
    4050                 :            :                 [28] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4051                 :            :                        RTE_PTYPE_L4_ICMP,
    4052                 :            : 
    4053                 :            :                 /* IPv4 --> IPv4 */
    4054                 :            :                 [29] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4055                 :            :                        RTE_PTYPE_TUNNEL_IP |
    4056                 :            :                        RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4057                 :            :                        RTE_PTYPE_INNER_L4_FRAG,
    4058                 :            :                 [30] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4059                 :            :                        RTE_PTYPE_TUNNEL_IP |
    4060                 :            :                        RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4061                 :            :                        RTE_PTYPE_INNER_L4_NONFRAG,
    4062                 :            :                 [31] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4063                 :            :                        RTE_PTYPE_TUNNEL_IP |
    4064                 :            :                        RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4065                 :            :                        RTE_PTYPE_INNER_L4_UDP,
    4066                 :            :                 /* [32] reserved */
    4067                 :            :                 [33] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4068                 :            :                        RTE_PTYPE_TUNNEL_IP |
    4069                 :            :                        RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4070                 :            :                        RTE_PTYPE_INNER_L4_TCP,
    4071                 :            :                 [34] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4072                 :            :                        RTE_PTYPE_TUNNEL_IP |
    4073                 :            :                        RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4074                 :            :                        RTE_PTYPE_INNER_L4_SCTP,
    4075                 :            :                 [35] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4076                 :            :                        RTE_PTYPE_TUNNEL_IP |
    4077                 :            :                        RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4078                 :            :                        RTE_PTYPE_INNER_L4_ICMP,
    4079                 :            : 
    4080                 :            :                 /* IPv4 --> IPv6 */
    4081                 :            :                 [36] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4082                 :            :                        RTE_PTYPE_TUNNEL_IP |
    4083                 :            :                        RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4084                 :            :                        RTE_PTYPE_INNER_L4_FRAG,
    4085                 :            :                 [37] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4086                 :            :                        RTE_PTYPE_TUNNEL_IP |
    4087                 :            :                        RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4088                 :            :                        RTE_PTYPE_INNER_L4_NONFRAG,
    4089                 :            :                 [38] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4090                 :            :                        RTE_PTYPE_TUNNEL_IP |
    4091                 :            :                        RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4092                 :            :                        RTE_PTYPE_INNER_L4_UDP,
    4093                 :            :                 /* [39] reserved */
    4094                 :            :                 [40] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4095                 :            :                        RTE_PTYPE_TUNNEL_IP |
    4096                 :            :                        RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4097                 :            :                        RTE_PTYPE_INNER_L4_TCP,
    4098                 :            :                 [41] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4099                 :            :                        RTE_PTYPE_TUNNEL_IP |
    4100                 :            :                        RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4101                 :            :                        RTE_PTYPE_INNER_L4_SCTP,
    4102                 :            :                 [42] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4103                 :            :                        RTE_PTYPE_TUNNEL_IP |
    4104                 :            :                        RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4105                 :            :                        RTE_PTYPE_INNER_L4_ICMP,
    4106                 :            : 
    4107                 :            :                 /* IPv4 --> GRE/Teredo/VXLAN */
    4108                 :            :                 [43] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4109                 :            :                        RTE_PTYPE_TUNNEL_GRENAT,
    4110                 :            : 
    4111                 :            :                 /* IPv4 --> GRE/Teredo/VXLAN --> IPv4 */
    4112                 :            :                 [44] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4113                 :            :                        RTE_PTYPE_TUNNEL_GRENAT |
    4114                 :            :                        RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4115                 :            :                        RTE_PTYPE_INNER_L4_FRAG,
    4116                 :            :                 [45] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4117                 :            :                        RTE_PTYPE_TUNNEL_GRENAT |
    4118                 :            :                        RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4119                 :            :                        RTE_PTYPE_INNER_L4_NONFRAG,
    4120                 :            :                 [46] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4121                 :            :                        RTE_PTYPE_TUNNEL_GRENAT |
    4122                 :            :                        RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4123                 :            :                        RTE_PTYPE_INNER_L4_UDP,
    4124                 :            :                 /* [47] reserved */
    4125                 :            :                 [48] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4126                 :            :                        RTE_PTYPE_TUNNEL_GRENAT |
    4127                 :            :                        RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4128                 :            :                        RTE_PTYPE_INNER_L4_TCP,
    4129                 :            :                 [49] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4130                 :            :                        RTE_PTYPE_TUNNEL_GRENAT |
    4131                 :            :                        RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4132                 :            :                        RTE_PTYPE_INNER_L4_SCTP,
    4133                 :            :                 [50] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4134                 :            :                        RTE_PTYPE_TUNNEL_GRENAT |
    4135                 :            :                        RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4136                 :            :                        RTE_PTYPE_INNER_L4_ICMP,
    4137                 :            : 
    4138                 :            :                 /* IPv4 --> GRE/Teredo/VXLAN --> IPv6 */
    4139                 :            :                 [51] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4140                 :            :                        RTE_PTYPE_TUNNEL_GRENAT |
    4141                 :            :                        RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4142                 :            :                        RTE_PTYPE_INNER_L4_FRAG,
    4143                 :            :                 [52] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4144                 :            :                        RTE_PTYPE_TUNNEL_GRENAT |
    4145                 :            :                        RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4146                 :            :                        RTE_PTYPE_INNER_L4_NONFRAG,
    4147                 :            :                 [53] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4148                 :            :                        RTE_PTYPE_TUNNEL_GRENAT |
    4149                 :            :                        RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4150                 :            :                        RTE_PTYPE_INNER_L4_UDP,
    4151                 :            :                 /* [54] reserved */
    4152                 :            :                 [55] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4153                 :            :                        RTE_PTYPE_TUNNEL_GRENAT |
    4154                 :            :                        RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4155                 :            :                        RTE_PTYPE_INNER_L4_TCP,
    4156                 :            :                 [56] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4157                 :            :                        RTE_PTYPE_TUNNEL_GRENAT |
    4158                 :            :                        RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4159                 :            :                        RTE_PTYPE_INNER_L4_SCTP,
    4160                 :            :                 [57] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4161                 :            :                        RTE_PTYPE_TUNNEL_GRENAT |
    4162                 :            :                        RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4163                 :            :                        RTE_PTYPE_INNER_L4_ICMP,
    4164                 :            : 
    4165                 :            :                 /* IPv4 --> GRE/Teredo/VXLAN --> MAC */
    4166                 :            :                 [58] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4167                 :            :                        RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER,
    4168                 :            : 
    4169                 :            :                 /* IPv4 --> GRE/Teredo/VXLAN --> MAC --> IPv4 */
    4170                 :            :                 [59] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4171                 :            :                        RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
    4172                 :            :                        RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4173                 :            :                        RTE_PTYPE_INNER_L4_FRAG,
    4174                 :            :                 [60] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4175                 :            :                        RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
    4176                 :            :                        RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4177                 :            :                        RTE_PTYPE_INNER_L4_NONFRAG,
    4178                 :            :                 [61] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4179                 :            :                        RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
    4180                 :            :                        RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4181                 :            :                        RTE_PTYPE_INNER_L4_UDP,
    4182                 :            :                 /* [62] reserved */
    4183                 :            :                 [63] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4184                 :            :                        RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
    4185                 :            :                        RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4186                 :            :                        RTE_PTYPE_INNER_L4_TCP,
    4187                 :            :                 [64] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4188                 :            :                        RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
    4189                 :            :                        RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4190                 :            :                        RTE_PTYPE_INNER_L4_SCTP,
    4191                 :            :                 [65] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4192                 :            :                        RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
    4193                 :            :                        RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4194                 :            :                        RTE_PTYPE_INNER_L4_ICMP,
    4195                 :            : 
    4196                 :            :                 /* IPv4 --> GRE/Teredo/VXLAN --> MAC --> IPv6 */
    4197                 :            :                 [66] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4198                 :            :                        RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
    4199                 :            :                        RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4200                 :            :                        RTE_PTYPE_INNER_L4_FRAG,
    4201                 :            :                 [67] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4202                 :            :                        RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
    4203                 :            :                        RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4204                 :            :                        RTE_PTYPE_INNER_L4_NONFRAG,
    4205                 :            :                 [68] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4206                 :            :                        RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
    4207                 :            :                        RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4208                 :            :                        RTE_PTYPE_INNER_L4_UDP,
    4209                 :            :                 /* [69] reserved */
    4210                 :            :                 [70] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4211                 :            :                        RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
    4212                 :            :                        RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4213                 :            :                        RTE_PTYPE_INNER_L4_TCP,
    4214                 :            :                 [71] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4215                 :            :                        RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
    4216                 :            :                        RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4217                 :            :                        RTE_PTYPE_INNER_L4_SCTP,
    4218                 :            :                 [72] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4219                 :            :                        RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
    4220                 :            :                        RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4221                 :            :                        RTE_PTYPE_INNER_L4_ICMP,
    4222                 :            :                 /* [73] - [87] reserved */
    4223                 :            : 
    4224                 :            :                 /* Non tunneled IPv6 */
    4225                 :            :                 [88] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4226                 :            :                        RTE_PTYPE_L4_FRAG,
    4227                 :            :                 [89] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4228                 :            :                        RTE_PTYPE_L4_NONFRAG,
    4229                 :            :                 [90] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4230                 :            :                        RTE_PTYPE_L4_UDP,
    4231                 :            :                 /* [91] reserved */
    4232                 :            :                 [92] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4233                 :            :                        RTE_PTYPE_L4_TCP,
    4234                 :            :                 [93] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4235                 :            :                        RTE_PTYPE_L4_SCTP,
    4236                 :            :                 [94] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4237                 :            :                        RTE_PTYPE_L4_ICMP,
    4238                 :            : 
    4239                 :            :                 /* IPv6 --> IPv4 */
    4240                 :            :                 [95] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4241                 :            :                        RTE_PTYPE_TUNNEL_IP |
    4242                 :            :                        RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4243                 :            :                        RTE_PTYPE_INNER_L4_FRAG,
    4244                 :            :                 [96] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4245                 :            :                        RTE_PTYPE_TUNNEL_IP |
    4246                 :            :                        RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4247                 :            :                        RTE_PTYPE_INNER_L4_NONFRAG,
    4248                 :            :                 [97] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4249                 :            :                        RTE_PTYPE_TUNNEL_IP |
    4250                 :            :                        RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4251                 :            :                        RTE_PTYPE_INNER_L4_UDP,
    4252                 :            :                 /* [98] reserved */
    4253                 :            :                 [99] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4254                 :            :                        RTE_PTYPE_TUNNEL_IP |
    4255                 :            :                        RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4256                 :            :                        RTE_PTYPE_INNER_L4_TCP,
    4257                 :            :                 [100] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4258                 :            :                         RTE_PTYPE_TUNNEL_IP |
    4259                 :            :                         RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4260                 :            :                         RTE_PTYPE_INNER_L4_SCTP,
    4261                 :            :                 [101] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4262                 :            :                         RTE_PTYPE_TUNNEL_IP |
    4263                 :            :                         RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4264                 :            :                         RTE_PTYPE_INNER_L4_ICMP,
    4265                 :            : 
    4266                 :            :                 /* IPv6 --> IPv6 */
    4267                 :            :                 [102] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4268                 :            :                         RTE_PTYPE_TUNNEL_IP |
    4269                 :            :                         RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4270                 :            :                         RTE_PTYPE_INNER_L4_FRAG,
    4271                 :            :                 [103] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4272                 :            :                         RTE_PTYPE_TUNNEL_IP |
    4273                 :            :                         RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4274                 :            :                         RTE_PTYPE_INNER_L4_NONFRAG,
    4275                 :            :                 [104] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4276                 :            :                         RTE_PTYPE_TUNNEL_IP |
    4277                 :            :                         RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4278                 :            :                         RTE_PTYPE_INNER_L4_UDP,
    4279                 :            :                 /* [105] reserved */
    4280                 :            :                 [106] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4281                 :            :                         RTE_PTYPE_TUNNEL_IP |
    4282                 :            :                         RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4283                 :            :                         RTE_PTYPE_INNER_L4_TCP,
    4284                 :            :                 [107] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4285                 :            :                         RTE_PTYPE_TUNNEL_IP |
    4286                 :            :                         RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4287                 :            :                         RTE_PTYPE_INNER_L4_SCTP,
    4288                 :            :                 [108] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4289                 :            :                         RTE_PTYPE_TUNNEL_IP |
    4290                 :            :                         RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4291                 :            :                         RTE_PTYPE_INNER_L4_ICMP,
    4292                 :            : 
    4293                 :            :                 /* IPv6 --> GRE/Teredo/VXLAN */
    4294                 :            :                 [109] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4295                 :            :                         RTE_PTYPE_TUNNEL_GRENAT,
    4296                 :            : 
    4297                 :            :                 /* IPv6 --> GRE/Teredo/VXLAN --> IPv4 */
    4298                 :            :                 [110] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4299                 :            :                         RTE_PTYPE_TUNNEL_GRENAT |
    4300                 :            :                         RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4301                 :            :                         RTE_PTYPE_INNER_L4_FRAG,
    4302                 :            :                 [111] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4303                 :            :                         RTE_PTYPE_TUNNEL_GRENAT |
    4304                 :            :                         RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4305                 :            :                         RTE_PTYPE_INNER_L4_NONFRAG,
    4306                 :            :                 [112] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4307                 :            :                         RTE_PTYPE_TUNNEL_GRENAT |
    4308                 :            :                         RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4309                 :            :                         RTE_PTYPE_INNER_L4_UDP,
    4310                 :            :                 /* [113] reserved */
    4311                 :            :                 [114] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4312                 :            :                         RTE_PTYPE_TUNNEL_GRENAT |
    4313                 :            :                         RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4314                 :            :                         RTE_PTYPE_INNER_L4_TCP,
    4315                 :            :                 [115] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4316                 :            :                         RTE_PTYPE_TUNNEL_GRENAT |
    4317                 :            :                         RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4318                 :            :                         RTE_PTYPE_INNER_L4_SCTP,
    4319                 :            :                 [116] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4320                 :            :                         RTE_PTYPE_TUNNEL_GRENAT |
    4321                 :            :                         RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4322                 :            :                         RTE_PTYPE_INNER_L4_ICMP,
    4323                 :            : 
    4324                 :            :                 /* IPv6 --> GRE/Teredo/VXLAN --> IPv6 */
    4325                 :            :                 [117] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4326                 :            :                         RTE_PTYPE_TUNNEL_GRENAT |
    4327                 :            :                         RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4328                 :            :                         RTE_PTYPE_INNER_L4_FRAG,
    4329                 :            :                 [118] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4330                 :            :                         RTE_PTYPE_TUNNEL_GRENAT |
    4331                 :            :                         RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4332                 :            :                         RTE_PTYPE_INNER_L4_NONFRAG,
    4333                 :            :                 [119] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4334                 :            :                         RTE_PTYPE_TUNNEL_GRENAT |
    4335                 :            :                         RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4336                 :            :                         RTE_PTYPE_INNER_L4_UDP,
    4337                 :            :                 /* [120] reserved */
    4338                 :            :                 [121] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4339                 :            :                         RTE_PTYPE_TUNNEL_GRENAT |
    4340                 :            :                         RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4341                 :            :                         RTE_PTYPE_INNER_L4_TCP,
    4342                 :            :                 [122] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4343                 :            :                         RTE_PTYPE_TUNNEL_GRENAT |
    4344                 :            :                         RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4345                 :            :                         RTE_PTYPE_INNER_L4_SCTP,
    4346                 :            :                 [123] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4347                 :            :                         RTE_PTYPE_TUNNEL_GRENAT |
    4348                 :            :                         RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4349                 :            :                         RTE_PTYPE_INNER_L4_ICMP,
    4350                 :            : 
    4351                 :            :                 /* IPv6 --> GRE/Teredo/VXLAN --> MAC */
    4352                 :            :                 [124] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4353                 :            :                         RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER,
    4354                 :            : 
    4355                 :            :                 /* IPv6 --> GRE/Teredo/VXLAN --> MAC --> IPv4 */
    4356                 :            :                 [125] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4357                 :            :                         RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
    4358                 :            :                         RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4359                 :            :                         RTE_PTYPE_INNER_L4_FRAG,
    4360                 :            :                 [126] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4361                 :            :                         RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
    4362                 :            :                         RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4363                 :            :                         RTE_PTYPE_INNER_L4_NONFRAG,
    4364                 :            :                 [127] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4365                 :            :                         RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
    4366                 :            :                         RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4367                 :            :                         RTE_PTYPE_INNER_L4_UDP,
    4368                 :            :                 /* [128] reserved */
    4369                 :            :                 [129] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4370                 :            :                         RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
    4371                 :            :                         RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4372                 :            :                         RTE_PTYPE_INNER_L4_TCP,
    4373                 :            :                 [130] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4374                 :            :                         RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
    4375                 :            :                         RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4376                 :            :                         RTE_PTYPE_INNER_L4_SCTP,
    4377                 :            :                 [131] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4378                 :            :                         RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
    4379                 :            :                         RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4380                 :            :                         RTE_PTYPE_INNER_L4_ICMP,
    4381                 :            : 
    4382                 :            :                 /* IPv6 --> GRE/Teredo/VXLAN --> MAC --> IPv6 */
    4383                 :            :                 [132] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4384                 :            :                         RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
    4385                 :            :                         RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4386                 :            :                         RTE_PTYPE_INNER_L4_FRAG,
    4387                 :            :                 [133] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4388                 :            :                         RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
    4389                 :            :                         RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4390                 :            :                         RTE_PTYPE_INNER_L4_NONFRAG,
    4391                 :            :                 [134] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4392                 :            :                         RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
    4393                 :            :                         RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4394                 :            :                         RTE_PTYPE_INNER_L4_UDP,
    4395                 :            :                 /* [135] reserved */
    4396                 :            :                 [136] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4397                 :            :                         RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
    4398                 :            :                         RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4399                 :            :                         RTE_PTYPE_INNER_L4_TCP,
    4400                 :            :                 [137] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4401                 :            :                         RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
    4402                 :            :                         RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4403                 :            :                         RTE_PTYPE_INNER_L4_SCTP,
    4404                 :            :                 [138] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4405                 :            :                         RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER |
    4406                 :            :                         RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4407                 :            :                         RTE_PTYPE_INNER_L4_ICMP,
    4408                 :            :                 /* [139] - [299] reserved */
    4409                 :            : 
    4410                 :            :                 /* PPPoE */
    4411                 :            :                 [300] = RTE_PTYPE_L2_ETHER_PPPOE,
    4412                 :            :                 [301] = RTE_PTYPE_L2_ETHER_PPPOE,
    4413                 :            : 
    4414                 :            :                 /* PPPoE --> IPv4 */
    4415                 :            :                 [302] = RTE_PTYPE_L2_ETHER_PPPOE |
    4416                 :            :                         RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4417                 :            :                         RTE_PTYPE_L4_FRAG,
    4418                 :            :                 [303] = RTE_PTYPE_L2_ETHER_PPPOE |
    4419                 :            :                         RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4420                 :            :                         RTE_PTYPE_L4_NONFRAG,
    4421                 :            :                 [304] = RTE_PTYPE_L2_ETHER_PPPOE |
    4422                 :            :                         RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4423                 :            :                         RTE_PTYPE_L4_UDP,
    4424                 :            :                 [305] = RTE_PTYPE_L2_ETHER_PPPOE |
    4425                 :            :                         RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4426                 :            :                         RTE_PTYPE_L4_TCP,
    4427                 :            :                 [306] = RTE_PTYPE_L2_ETHER_PPPOE |
    4428                 :            :                         RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4429                 :            :                         RTE_PTYPE_L4_SCTP,
    4430                 :            :                 [307] = RTE_PTYPE_L2_ETHER_PPPOE |
    4431                 :            :                         RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4432                 :            :                         RTE_PTYPE_L4_ICMP,
    4433                 :            : 
    4434                 :            :                 /* PPPoE --> IPv6 */
    4435                 :            :                 [308] = RTE_PTYPE_L2_ETHER_PPPOE |
    4436                 :            :                         RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4437                 :            :                         RTE_PTYPE_L4_FRAG,
    4438                 :            :                 [309] = RTE_PTYPE_L2_ETHER_PPPOE |
    4439                 :            :                         RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4440                 :            :                         RTE_PTYPE_L4_NONFRAG,
    4441                 :            :                 [310] = RTE_PTYPE_L2_ETHER_PPPOE |
    4442                 :            :                         RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4443                 :            :                         RTE_PTYPE_L4_UDP,
    4444                 :            :                 [311] = RTE_PTYPE_L2_ETHER_PPPOE |
    4445                 :            :                         RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4446                 :            :                         RTE_PTYPE_L4_TCP,
    4447                 :            :                 [312] = RTE_PTYPE_L2_ETHER_PPPOE |
    4448                 :            :                         RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4449                 :            :                         RTE_PTYPE_L4_SCTP,
    4450                 :            :                 [313] = RTE_PTYPE_L2_ETHER_PPPOE |
    4451                 :            :                         RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4452                 :            :                         RTE_PTYPE_L4_ICMP,
    4453                 :            :                 /* [314] - [324] reserved */
    4454                 :            : 
    4455                 :            :                 /* IPv4/IPv6 --> GTPC/GTPU */
    4456                 :            :                 [325] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4457                 :            :                         RTE_PTYPE_TUNNEL_GTPC,
    4458                 :            :                 [326] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4459                 :            :                         RTE_PTYPE_TUNNEL_GTPC,
    4460                 :            :                 [327] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4461                 :            :                         RTE_PTYPE_TUNNEL_GTPC,
    4462                 :            :                 [328] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4463                 :            :                         RTE_PTYPE_TUNNEL_GTPC,
    4464                 :            :                 [329] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4465                 :            :                         RTE_PTYPE_TUNNEL_GTPU,
    4466                 :            :                 [330] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4467                 :            :                         RTE_PTYPE_TUNNEL_GTPU,
    4468                 :            : 
    4469                 :            :                 /* IPv4 --> GTPU --> IPv4 */
    4470                 :            :                 [331] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4471                 :            :                         RTE_PTYPE_TUNNEL_GTPU |
    4472                 :            :                         RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4473                 :            :                         RTE_PTYPE_INNER_L4_FRAG,
    4474                 :            :                 [332] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4475                 :            :                         RTE_PTYPE_TUNNEL_GTPU |
    4476                 :            :                         RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4477                 :            :                         RTE_PTYPE_INNER_L4_NONFRAG,
    4478                 :            :                 [333] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4479                 :            :                         RTE_PTYPE_TUNNEL_GTPU |
    4480                 :            :                         RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4481                 :            :                         RTE_PTYPE_INNER_L4_UDP,
    4482                 :            :                 [334] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4483                 :            :                         RTE_PTYPE_TUNNEL_GTPU |
    4484                 :            :                         RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4485                 :            :                         RTE_PTYPE_INNER_L4_TCP,
    4486                 :            :                 [335] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4487                 :            :                         RTE_PTYPE_TUNNEL_GTPU |
    4488                 :            :                         RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4489                 :            :                         RTE_PTYPE_INNER_L4_ICMP,
    4490                 :            : 
    4491                 :            :                 /* IPv6 --> GTPU --> IPv4 */
    4492                 :            :                 [336] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4493                 :            :                         RTE_PTYPE_TUNNEL_GTPU |
    4494                 :            :                         RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4495                 :            :                         RTE_PTYPE_INNER_L4_FRAG,
    4496                 :            :                 [337] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4497                 :            :                         RTE_PTYPE_TUNNEL_GTPU |
    4498                 :            :                         RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4499                 :            :                         RTE_PTYPE_INNER_L4_NONFRAG,
    4500                 :            :                 [338] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4501                 :            :                         RTE_PTYPE_TUNNEL_GTPU |
    4502                 :            :                         RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4503                 :            :                         RTE_PTYPE_INNER_L4_UDP,
    4504                 :            :                 [339] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4505                 :            :                         RTE_PTYPE_TUNNEL_GTPU |
    4506                 :            :                         RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4507                 :            :                         RTE_PTYPE_INNER_L4_TCP,
    4508                 :            :                 [340] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4509                 :            :                         RTE_PTYPE_TUNNEL_GTPU |
    4510                 :            :                         RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN |
    4511                 :            :                         RTE_PTYPE_INNER_L4_ICMP,
    4512                 :            : 
    4513                 :            :                 /* IPv4 --> GTPU --> IPv6 */
    4514                 :            :                 [341] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4515                 :            :                         RTE_PTYPE_TUNNEL_GTPU |
    4516                 :            :                         RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4517                 :            :                         RTE_PTYPE_INNER_L4_FRAG,
    4518                 :            :                 [342] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4519                 :            :                         RTE_PTYPE_TUNNEL_GTPU |
    4520                 :            :                         RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4521                 :            :                         RTE_PTYPE_INNER_L4_NONFRAG,
    4522                 :            :                 [343] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4523                 :            :                         RTE_PTYPE_TUNNEL_GTPU |
    4524                 :            :                         RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4525                 :            :                         RTE_PTYPE_INNER_L4_UDP,
    4526                 :            :                 [344] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4527                 :            :                         RTE_PTYPE_TUNNEL_GTPU |
    4528                 :            :                         RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4529                 :            :                         RTE_PTYPE_INNER_L4_TCP,
    4530                 :            :                 [345] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4531                 :            :                         RTE_PTYPE_TUNNEL_GTPU |
    4532                 :            :                         RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4533                 :            :                         RTE_PTYPE_INNER_L4_ICMP,
    4534                 :            : 
    4535                 :            :                 /* IPv6 --> GTPU --> IPv6 */
    4536                 :            :                 [346] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4537                 :            :                         RTE_PTYPE_TUNNEL_GTPU |
    4538                 :            :                         RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4539                 :            :                         RTE_PTYPE_INNER_L4_FRAG,
    4540                 :            :                 [347] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4541                 :            :                         RTE_PTYPE_TUNNEL_GTPU |
    4542                 :            :                         RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4543                 :            :                         RTE_PTYPE_INNER_L4_NONFRAG,
    4544                 :            :                 [348] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4545                 :            :                         RTE_PTYPE_TUNNEL_GTPU |
    4546                 :            :                         RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4547                 :            :                         RTE_PTYPE_INNER_L4_UDP,
    4548                 :            :                 [349] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4549                 :            :                         RTE_PTYPE_TUNNEL_GTPU |
    4550                 :            :                         RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4551                 :            :                         RTE_PTYPE_INNER_L4_TCP,
    4552                 :            :                 [350] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4553                 :            :                         RTE_PTYPE_TUNNEL_GTPU |
    4554                 :            :                         RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN |
    4555                 :            :                         RTE_PTYPE_INNER_L4_ICMP,
    4556                 :            : 
    4557                 :            :                 /* IPv4 --> UDP ECPRI */
    4558                 :            :                 [372] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4559                 :            :                         RTE_PTYPE_L4_UDP,
    4560                 :            :                 [373] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4561                 :            :                         RTE_PTYPE_L4_UDP,
    4562                 :            :                 [374] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4563                 :            :                         RTE_PTYPE_L4_UDP,
    4564                 :            :                 [375] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4565                 :            :                         RTE_PTYPE_L4_UDP,
    4566                 :            :                 [376] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4567                 :            :                         RTE_PTYPE_L4_UDP,
    4568                 :            :                 [377] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4569                 :            :                         RTE_PTYPE_L4_UDP,
    4570                 :            :                 [378] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4571                 :            :                         RTE_PTYPE_L4_UDP,
    4572                 :            :                 [379] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4573                 :            :                         RTE_PTYPE_L4_UDP,
    4574                 :            :                 [380] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4575                 :            :                         RTE_PTYPE_L4_UDP,
    4576                 :            :                 [381] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN |
    4577                 :            :                         RTE_PTYPE_L4_UDP,
    4578                 :            : 
    4579                 :            :                 /* IPV6 --> UDP ECPRI */
    4580                 :            :                 [382] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4581                 :            :                         RTE_PTYPE_L4_UDP,
    4582                 :            :                 [383] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4583                 :            :                         RTE_PTYPE_L4_UDP,
    4584                 :            :                 [384] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4585                 :            :                         RTE_PTYPE_L4_UDP,
    4586                 :            :                 [385] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4587                 :            :                         RTE_PTYPE_L4_UDP,
    4588                 :            :                 [386] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4589                 :            :                         RTE_PTYPE_L4_UDP,
    4590                 :            :                 [387] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4591                 :            :                         RTE_PTYPE_L4_UDP,
    4592                 :            :                 [388] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4593                 :            :                         RTE_PTYPE_L4_UDP,
    4594                 :            :                 [389] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4595                 :            :                         RTE_PTYPE_L4_UDP,
    4596                 :            :                 [390] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4597                 :            :                         RTE_PTYPE_L4_UDP,
    4598                 :            :                 [391] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN |
    4599                 :            :                         RTE_PTYPE_L4_UDP,
    4600                 :            :                 /* All others reserved */
    4601                 :            :         };
    4602                 :            : 
    4603                 :          0 :         return type_table[ptype];
    4604                 :            : }
    4605                 :            : 
    4606                 :            : void __rte_cold
    4607                 :          0 : ice_set_default_ptype_table(struct rte_eth_dev *dev)
    4608                 :            : {
    4609                 :          0 :         struct ice_adapter *ad =
    4610                 :          0 :                 ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
    4611                 :            :         int i;
    4612                 :            : 
    4613         [ #  # ]:          0 :         for (i = 0; i < ICE_MAX_PKT_TYPE; i++)
    4614                 :          0 :                 ad->ptype_tbl[i] = ice_get_default_pkt_type(i);
    4615                 :          0 : }
    4616                 :            : 
    4617                 :            : #define ICE_RX_PROG_STATUS_DESC_WB_QW1_PROGID_S 1
    4618                 :            : #define ICE_RX_PROG_STATUS_DESC_WB_QW1_PROGID_M \
    4619                 :            :                         (0x3UL << ICE_RX_PROG_STATUS_DESC_WB_QW1_PROGID_S)
    4620                 :            : #define ICE_RX_PROG_STATUS_DESC_WB_QW1_PROG_ADD 0
    4621                 :            : #define ICE_RX_PROG_STATUS_DESC_WB_QW1_PROG_DEL 0x1
    4622                 :            : 
    4623                 :            : #define ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_S   4
    4624                 :            : #define ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_M   \
    4625                 :            :         (1 << ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_S)
    4626                 :            : #define ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_PROF_S      5
    4627                 :            : #define ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_PROF_M      \
    4628                 :            :         (1 << ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_PROF_S)
    4629                 :            : 
    4630                 :            : /*
    4631                 :            :  * check the programming status descriptor in rx queue.
    4632                 :            :  * done after Programming Flow Director is programmed on
    4633                 :            :  * tx queue
    4634                 :            :  */
    4635                 :            : static inline int
    4636                 :          0 : ice_check_fdir_programming_status(struct ice_rx_queue *rxq)
    4637                 :            : {
    4638                 :            :         volatile union ice_32byte_rx_desc *rxdp;
    4639                 :            :         uint64_t qword1;
    4640                 :            :         uint32_t rx_status;
    4641                 :            :         uint32_t error;
    4642                 :            :         uint32_t id;
    4643                 :            :         int ret = -EAGAIN;
    4644                 :            : 
    4645                 :          0 :         rxdp = (volatile union ice_32byte_rx_desc *)
    4646                 :          0 :                 (&rxq->rx_ring[rxq->rx_tail]);
    4647                 :          0 :         qword1 = rte_le_to_cpu_64(rxdp->wb.qword1.status_error_len);
    4648                 :            :         rx_status = (qword1 & ICE_RXD_QW1_STATUS_M)
    4649                 :          0 :                         >> ICE_RXD_QW1_STATUS_S;
    4650                 :            : 
    4651         [ #  # ]:          0 :         if (rx_status & (1 << ICE_RX_DESC_STATUS_DD_S)) {
    4652                 :            :                 ret = 0;
    4653                 :          0 :                 error = (qword1 & ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_M) >>
    4654                 :            :                         ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_S;
    4655                 :          0 :                 id = (qword1 & ICE_RX_PROG_STATUS_DESC_WB_QW1_PROGID_M) >>
    4656                 :            :                         ICE_RX_PROG_STATUS_DESC_WB_QW1_PROGID_S;
    4657         [ #  # ]:          0 :                 if (error) {
    4658         [ #  # ]:          0 :                         if (id == ICE_RX_PROG_STATUS_DESC_WB_QW1_PROG_ADD)
    4659                 :          0 :                                 PMD_DRV_LOG(ERR, "Failed to add FDIR rule.");
    4660         [ #  # ]:          0 :                         else if (id == ICE_RX_PROG_STATUS_DESC_WB_QW1_PROG_DEL)
    4661                 :          0 :                                 PMD_DRV_LOG(ERR, "Failed to remove FDIR rule.");
    4662                 :            :                         ret = -EINVAL;
    4663                 :          0 :                         goto err;
    4664                 :            :                 }
    4665                 :          0 :                 error = (qword1 & ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_PROF_M) >>
    4666                 :            :                         ICE_RX_PROG_STATUS_DESC_WB_QW1_FAIL_PROF_S;
    4667         [ #  # ]:          0 :                 if (error) {
    4668                 :          0 :                         PMD_DRV_LOG(ERR, "Failed to create FDIR profile.");
    4669                 :            :                         ret = -EINVAL;
    4670                 :            :                 }
    4671                 :          0 : err:
    4672                 :          0 :                 rxdp->wb.qword1.status_error_len = 0;
    4673                 :          0 :                 rxq->rx_tail++;
    4674         [ #  # ]:          0 :                 if (unlikely(rxq->rx_tail == rxq->nb_rx_desc))
    4675                 :          0 :                         rxq->rx_tail = 0;
    4676         [ #  # ]:          0 :                 if (rxq->rx_tail == 0)
    4677                 :          0 :                         ICE_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
    4678                 :            :                 else
    4679                 :          0 :                         ICE_PCI_REG_WRITE(rxq->qrx_tail, rxq->rx_tail - 1);
    4680                 :            :         }
    4681                 :            : 
    4682                 :          0 :         return ret;
    4683                 :            : }
    4684                 :            : 
    4685                 :            : #define ICE_FDIR_MAX_WAIT_US 10000
    4686                 :            : 
    4687                 :            : int
    4688                 :          0 : ice_fdir_programming(struct ice_pf *pf, struct ice_fltr_desc *fdir_desc)
    4689                 :            : {
    4690                 :          0 :         struct ci_tx_queue *txq = pf->fdir.txq;
    4691                 :          0 :         struct ice_rx_queue *rxq = pf->fdir.rxq;
    4692                 :            :         volatile struct ice_fltr_desc *fdirdp;
    4693                 :            :         volatile struct ice_tx_desc *txdp;
    4694                 :            :         uint32_t td_cmd;
    4695                 :            :         uint16_t i;
    4696                 :            : 
    4697                 :          0 :         fdirdp = (volatile struct ice_fltr_desc *)
    4698                 :          0 :                 (&txq->ice_tx_ring[txq->tx_tail]);
    4699                 :          0 :         fdirdp->qidx_compq_space_stat = fdir_desc->qidx_compq_space_stat;
    4700                 :          0 :         fdirdp->dtype_cmd_vsi_fdid = fdir_desc->dtype_cmd_vsi_fdid;
    4701                 :            : 
    4702                 :          0 :         txdp = &txq->ice_tx_ring[txq->tx_tail + 1];
    4703                 :          0 :         txdp->buf_addr = rte_cpu_to_le_64(pf->fdir.dma_addr);
    4704                 :            :         td_cmd = ICE_TX_DESC_CMD_EOP |
    4705                 :            :                 ICE_TX_DESC_CMD_RS  |
    4706                 :            :                 ICE_TX_DESC_CMD_DUMMY;
    4707                 :            : 
    4708                 :          0 :         txdp->cmd_type_offset_bsz =
    4709                 :            :                 ice_build_ctob(td_cmd, 0, ICE_FDIR_PKT_LEN, 0);
    4710                 :            : 
    4711                 :          0 :         txq->tx_tail += 2;
    4712         [ #  # ]:          0 :         if (txq->tx_tail >= txq->nb_tx_desc)
    4713                 :          0 :                 txq->tx_tail = 0;
    4714                 :            :         /* Update the tx tail register */
    4715                 :          0 :         ICE_PCI_REG_WRITE(txq->qtx_tail, txq->tx_tail);
    4716         [ #  # ]:          0 :         for (i = 0; i < ICE_FDIR_MAX_WAIT_US; i++) {
    4717         [ #  # ]:          0 :                 if ((txdp->cmd_type_offset_bsz &
    4718                 :            :                      rte_cpu_to_le_64(ICE_TXD_QW1_DTYPE_M)) ==
    4719                 :            :                     rte_cpu_to_le_64(ICE_TX_DESC_DTYPE_DESC_DONE))
    4720                 :            :                         break;
    4721                 :          0 :                 rte_delay_us(1);
    4722                 :            :         }
    4723         [ #  # ]:          0 :         if (i >= ICE_FDIR_MAX_WAIT_US) {
    4724                 :          0 :                 PMD_DRV_LOG(ERR,
    4725                 :            :                             "Failed to program FDIR filter: time out to get DD on tx queue.");
    4726                 :          0 :                 return -ETIMEDOUT;
    4727                 :            :         }
    4728                 :            : 
    4729         [ #  # ]:          0 :         for (; i < ICE_FDIR_MAX_WAIT_US; i++) {
    4730                 :            :                 int ret;
    4731                 :            : 
    4732                 :          0 :                 ret = ice_check_fdir_programming_status(rxq);
    4733         [ #  # ]:          0 :                 if (ret == -EAGAIN)
    4734                 :          0 :                         rte_delay_us(1);
    4735                 :            :                 else
    4736                 :          0 :                         return ret;
    4737                 :            :         }
    4738                 :            : 
    4739                 :          0 :         PMD_DRV_LOG(ERR,
    4740                 :            :                     "Failed to program FDIR filter: programming status reported.");
    4741                 :          0 :         return -ETIMEDOUT;
    4742                 :            : 
    4743                 :            : 
    4744                 :            : }

Generated by: LCOV version 1.14