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

Generated by: LCOV version 1.14