net/ice: use relaxed and remove duplicate barrier
[dpdk.git] / drivers / net / ice / ice_rxtx.c
index ae20e1e..8785cf8 100644 (file)
                PKT_TX_TCP_SEG |                 \
                PKT_TX_OUTER_IP_CKSUM)
 
+static inline uint8_t
+ice_rxdid_to_proto_xtr_type(uint8_t rxdid)
+{
+       static uint8_t xtr_map[] = {
+               [ICE_RXDID_COMMS_AUX_VLAN]      = PROTO_XTR_VLAN,
+               [ICE_RXDID_COMMS_AUX_IPV4]      = PROTO_XTR_IPV4,
+               [ICE_RXDID_COMMS_AUX_IPV6]      = PROTO_XTR_IPV6,
+               [ICE_RXDID_COMMS_AUX_IPV6_FLOW] = PROTO_XTR_IPV6_FLOW,
+               [ICE_RXDID_COMMS_AUX_TCP]       = PROTO_XTR_TCP,
+       };
+
+       return rxdid < RTE_DIM(xtr_map) ? xtr_map[rxdid] : PROTO_XTR_NONE;
+}
+
+static inline uint8_t
+ice_proto_xtr_type_to_rxdid(uint8_t xtr_type)
+{
+       static uint8_t rxdid_map[] = {
+               [PROTO_XTR_NONE]      = ICE_RXDID_COMMS_GENERIC,
+               [PROTO_XTR_VLAN]      = ICE_RXDID_COMMS_AUX_VLAN,
+               [PROTO_XTR_IPV4]      = ICE_RXDID_COMMS_AUX_IPV4,
+               [PROTO_XTR_IPV6]      = ICE_RXDID_COMMS_AUX_IPV6,
+               [PROTO_XTR_IPV6_FLOW] = ICE_RXDID_COMMS_AUX_IPV6_FLOW,
+               [PROTO_XTR_TCP]       = ICE_RXDID_COMMS_AUX_TCP,
+       };
+
+       return xtr_type < RTE_DIM(rxdid_map) ?
+                               rxdid_map[xtr_type] : ICE_RXDID_COMMS_GENERIC;
+}
 
 static enum ice_status
 ice_program_hw_rx_queue(struct ice_rx_queue *rxq)
@@ -84,6 +113,11 @@ ice_program_hw_rx_queue(struct ice_rx_queue *rxq)
        rx_ctx.showiv = 0;
        rx_ctx.crcstrip = (rxq->crc_len == 0) ? 1 : 0;
 
+       rxdid = ice_proto_xtr_type_to_rxdid(rxq->proto_xtr);
+
+       PMD_DRV_LOG(DEBUG, "Port (%u) - Rx queue (%u) is set with RXDID : %u",
+                   rxq->port_id, rxq->queue_id, rxdid);
+
        /* Enable Flexible Descriptors in the queue context which
         * allows this driver to select a specific receive descriptor format
         */
@@ -136,7 +170,7 @@ ice_alloc_rx_queue_mbufs(struct ice_rx_queue *rxq)
        uint16_t i;
 
        for (i = 0; i < rxq->nb_rx_desc; i++) {
-               volatile union ice_rx_desc *rxd;
+               volatile union ice_rx_flex_desc *rxd;
                struct rte_mbuf *mbuf = rte_mbuf_raw_alloc(rxq->mp);
 
                if (unlikely(!mbuf)) {
@@ -311,7 +345,7 @@ ice_reset_rx_queue(struct ice_rx_queue *rxq)
 #endif /* RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC */
                len = rxq->nb_rx_desc;
 
-       for (i = 0; i < len * sizeof(union ice_rx_desc); i++)
+       for (i = 0; i < len * sizeof(union ice_rx_flex_desc); i++)
                ((volatile char *)rxq->rx_ring)[i] = 0;
 
 #ifdef RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC
@@ -368,8 +402,6 @@ ice_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
                return -ENOMEM;
        }
 
-       rte_wmb();
-
        /* Init the RX tail register. */
        ICE_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
 
@@ -641,6 +673,8 @@ ice_rx_queue_setup(struct rte_eth_dev *dev,
        rxq->drop_en = rx_conf->rx_drop_en;
        rxq->vsi = vsi;
        rxq->rx_deferred_start = rx_conf->rx_deferred_start;
+       rxq->proto_xtr = pf->proto_xtr != NULL ?
+                        pf->proto_xtr[queue_idx] : PROTO_XTR_NONE;
 
        /* Allocate the maximun number of RX ring hardware descriptor. */
        len = ICE_MAX_RING_DESC;
@@ -654,7 +688,7 @@ ice_rx_queue_setup(struct rte_eth_dev *dev,
 #endif
 
        /* Allocate the maximum number of RX ring hardware descriptor. */
-       ring_size = sizeof(union ice_rx_desc) * len;
+       ring_size = sizeof(union ice_rx_flex_desc) * len;
        ring_size = RTE_ALIGN(ring_size, ICE_DMA_MEM_ALIGN);
        rz = rte_eth_dma_zone_reserve(dev, "rx_ring", queue_idx,
                                      ring_size, ICE_RING_BASE_ALIGN,
@@ -971,7 +1005,7 @@ ice_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id)
        uint16_t desc = 0;
 
        rxq = dev->data->rx_queues[rx_queue_id];
-       rxdp = (volatile union ice_rx_flex_desc *)&rxq->rx_ring[rxq->rx_tail];
+       rxdp = &rxq->rx_ring[rxq->rx_tail];
        while ((desc < rxq->nb_rx_desc) &&
               rte_le_to_cpu_16(rxdp->wb.status_error0) &
               (1 << ICE_RX_FLEX_DESC_STATUS0_DD_S)) {
@@ -983,8 +1017,7 @@ ice_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id)
                desc += ICE_RXQ_SCAN_INTERVAL;
                rxdp += ICE_RXQ_SCAN_INTERVAL;
                if (rxq->rx_tail + desc >= rxq->nb_rx_desc)
-                       rxdp = (volatile union ice_rx_flex_desc *)
-                               &(rxq->rx_ring[rxq->rx_tail +
+                       rxdp = &(rxq->rx_ring[rxq->rx_tail +
                                 desc - rxq->nb_rx_desc]);
        }
 
@@ -1062,6 +1095,10 @@ ice_rxd_to_vlan_tci(struct rte_mbuf *mb, volatile union ice_rx_flex_desc *rxdp)
                   mb->vlan_tci, mb->vlan_tci_outer);
 }
 
+#define ICE_RX_PROTO_XTR_VALID \
+       ((1 << ICE_RX_FLEX_DESC_STATUS1_XTRMD4_VALID_S) | \
+        (1 << ICE_RX_FLEX_DESC_STATUS1_XTRMD5_VALID_S))
+
 static inline void
 ice_rxd_to_pkt_fields(struct rte_mbuf *mb,
                      volatile union ice_rx_flex_desc *rxdp)
@@ -1075,6 +1112,26 @@ ice_rxd_to_pkt_fields(struct rte_mbuf *mb,
                mb->ol_flags |= PKT_RX_RSS_HASH;
                mb->hash.rss = rte_le_to_cpu_32(desc->rss_hash);
        }
+
+#ifndef RTE_LIBRTE_ICE_16BYTE_RX_DESC
+       init_proto_xtr_flds(mb);
+
+       stat_err = rte_le_to_cpu_16(desc->status_error1);
+       if (stat_err & ICE_RX_PROTO_XTR_VALID) {
+               struct proto_xtr_flds *xtr = get_proto_xtr_flds(mb);
+
+               if (stat_err & (1 << ICE_RX_FLEX_DESC_STATUS1_XTRMD4_VALID_S))
+                       xtr->u.raw.data0 =
+                               rte_le_to_cpu_16(desc->flex_ts.flex.aux0);
+
+               if (stat_err & (1 << ICE_RX_FLEX_DESC_STATUS1_XTRMD5_VALID_S))
+                       xtr->u.raw.data1 =
+                               rte_le_to_cpu_16(desc->flex_ts.flex.aux1);
+
+               xtr->type = ice_rxdid_to_proto_xtr_type(desc->rxdid);
+               xtr->magic = PROTO_XTR_MAGIC_ID;
+       }
+#endif
 }
 
 #ifdef RTE_LIBRTE_ICE_RX_ALLOW_BULK_ALLOC
@@ -1095,7 +1152,7 @@ ice_rx_scan_hw_ring(struct ice_rx_queue *rxq)
        uint64_t pkt_flags = 0;
        uint32_t *ptype_tbl = rxq->vsi->adapter->ptype_tbl;
 
-       rxdp = (volatile union ice_rx_flex_desc *)&rxq->rx_ring[rxq->rx_tail];
+       rxdp = &rxq->rx_ring[rxq->rx_tail];
        rxep = &rxq->sw_ring[rxq->rx_tail];
 
        stat_err0 = rte_le_to_cpu_16(rxdp->wb.status_error0);
@@ -1180,7 +1237,7 @@ ice_rx_fill_from_stage(struct ice_rx_queue *rxq,
 static inline int
 ice_rx_alloc_bufs(struct ice_rx_queue *rxq)
 {
-       volatile union ice_rx_desc *rxdp;
+       volatile union ice_rx_flex_desc *rxdp;
        struct ice_rx_entry *rxep;
        struct rte_mbuf *mb;
        uint16_t alloc_idx, i;
@@ -1216,7 +1273,6 @@ ice_rx_alloc_bufs(struct ice_rx_queue *rxq)
        }
 
        /* Update rx tail regsiter */
-       rte_wmb();
        ICE_PCI_REG_WRITE(rxq->qrx_tail, rxq->rx_free_trigger);
 
        rxq->rx_free_trigger =
@@ -1315,7 +1371,7 @@ ice_recv_scattered_pkts(void *rx_queue,
                        uint16_t nb_pkts)
 {
        struct ice_rx_queue *rxq = rx_queue;
-       volatile union ice_rx_desc *rx_ring = rxq->rx_ring;
+       volatile union ice_rx_flex_desc *rx_ring = rxq->rx_ring;
        volatile union ice_rx_flex_desc *rxdp;
        union ice_rx_flex_desc rxd;
        struct ice_rx_entry *sw_ring = rxq->sw_ring;
@@ -1335,7 +1391,7 @@ ice_recv_scattered_pkts(void *rx_queue,
        struct rte_eth_dev *dev;
 
        while (nb_rx < nb_pkts) {
-               rxdp = (volatile union ice_rx_flex_desc *)&rx_ring[rx_id];
+               rxdp = &rx_ring[rx_id];
                rx_stat_err0 = rte_le_to_cpu_16(rxdp->wb.status_error0);
 
                /* Check the DD bit first */
@@ -1547,7 +1603,7 @@ ice_rx_descriptor_status(void *rx_queue, uint16_t offset)
        if (desc >= rxq->nb_rx_desc)
                desc -= rxq->nb_rx_desc;
 
-       rxdp = (volatile union ice_rx_flex_desc *)&rxq->rx_ring[desc];
+       rxdp = &rxq->rx_ring[desc];
        if (rte_le_to_cpu_16(rxdp->wb.status_error0) &
            (1 << ICE_RX_FLEX_DESC_STATUS0_DD_S))
                return RTE_ETH_RX_DESC_DONE;
@@ -1634,7 +1690,7 @@ ice_recv_pkts(void *rx_queue,
              uint16_t nb_pkts)
 {
        struct ice_rx_queue *rxq = rx_queue;
-       volatile union ice_rx_desc *rx_ring = rxq->rx_ring;
+       volatile union ice_rx_flex_desc *rx_ring = rxq->rx_ring;
        volatile union ice_rx_flex_desc *rxdp;
        union ice_rx_flex_desc rxd;
        struct ice_rx_entry *sw_ring = rxq->sw_ring;
@@ -1652,7 +1708,7 @@ ice_recv_pkts(void *rx_queue,
        struct rte_eth_dev *dev;
 
        while (nb_rx < nb_pkts) {
-               rxdp = (volatile union ice_rx_flex_desc *)&rx_ring[rx_id];
+               rxdp = &rx_ring[rx_id];
                rx_stat_err0 = rte_le_to_cpu_16(rxdp->wb.status_error0);
 
                /* Check the DD bit first */
@@ -2118,8 +2174,6 @@ ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
                                         ICE_TXD_QW1_CMD_S);
        }
 end_of_tx:
-       rte_wmb();
-
        /* update Tail register */
        ICE_PCI_REG_WRITE(txq->qtx_tail, tx_id);
        txq->tx_tail = tx_id;
@@ -2275,7 +2329,6 @@ tx_xmit_pkts(struct ice_tx_queue *txq,
                txq->tx_tail = 0;
 
        /* Update the tx tail register */
-       rte_wmb();
        ICE_PCI_REG_WRITE(txq->qtx_tail, txq->tx_tail);
 
        return nb_pkts;