net/bnxt: use new API to get IOVA address
[dpdk.git] / drivers / net / bnxt / bnxt_rxr.c
index 3216a6d..89114cc 100644 (file)
@@ -65,17 +65,17 @@ static inline int bnxt_alloc_rx_data(struct bnxt_rx_queue *rxq,
 {
        struct rx_prod_pkt_bd *rxbd = &rxr->rx_desc_ring[prod];
        struct bnxt_sw_rx_bd *rx_buf = &rxr->rx_buf_ring[prod];
-       struct rte_mbuf *data;
+       struct rte_mbuf *mbuf;
 
-       data = __bnxt_alloc_rx_data(rxq->mb_pool);
-       if (!data) {
+       mbuf = __bnxt_alloc_rx_data(rxq->mb_pool);
+       if (!mbuf) {
                rte_atomic64_inc(&rxq->bp->rx_mbuf_alloc_fail);
                return -ENOMEM;
        }
 
-       rx_buf->mbuf = data;
+       rx_buf->mbuf = mbuf;
 
-       rxbd->addr = rte_cpu_to_le_64(RTE_MBUF_DATA_DMA_ADDR(rx_buf->mbuf));
+       rxbd->addr = rte_cpu_to_le_64(rte_mbuf_data_iova(mbuf));
 
        return 0;
 }
@@ -86,10 +86,10 @@ static inline int bnxt_alloc_ag_data(struct bnxt_rx_queue *rxq,
 {
        struct rx_prod_pkt_bd *rxbd = &rxr->ag_desc_ring[prod];
        struct bnxt_sw_rx_bd *rx_buf = &rxr->ag_buf_ring[prod];
-       struct rte_mbuf *data;
+       struct rte_mbuf *mbuf;
 
-       data = __bnxt_alloc_rx_data(rxq->mb_pool);
-       if (!data) {
+       mbuf = __bnxt_alloc_rx_data(rxq->mb_pool);
+       if (!mbuf) {
                rte_atomic64_inc(&rxq->bp->rx_mbuf_alloc_fail);
                return -ENOMEM;
        }
@@ -100,9 +100,9 @@ static inline int bnxt_alloc_ag_data(struct bnxt_rx_queue *rxq,
                RTE_LOG(ERR, PMD, "Jumbo Frame. rx_buf is NULL\n");
 
 
-       rx_buf->mbuf = data;
+       rx_buf->mbuf = mbuf;
 
-       rxbd->addr = rte_cpu_to_le_64(RTE_MBUF_DATA_DMA_ADDR(rx_buf->mbuf));
+       rxbd->addr = rte_cpu_to_le_64(rte_mbuf_data_iova(mbuf));
 
        return 0;
 }
@@ -123,7 +123,7 @@ static inline void bnxt_reuse_rx_mbuf(struct bnxt_rx_ring_info *rxr,
 
        prod_bd = &rxr->rx_desc_ring[prod];
 
-       prod_bd->addr = rte_cpu_to_le_64(RTE_MBUF_DATA_DMA_ADDR(mbuf));
+       prod_bd->addr = rte_cpu_to_le_64(rte_mbuf_data_iova(mbuf));
 
        rxr->rx_prod = prod;
 }
@@ -199,7 +199,7 @@ static void bnxt_tpa_start(struct bnxt_rx_queue *rxq,
        if (tpa_start1->flags2 &
            rte_cpu_to_le_32(RX_TPA_START_CMPL_FLAGS2_META_FORMAT_VLAN)) {
                mbuf->vlan_tci = rte_le_to_cpu_32(tpa_start1->metadata);
-               mbuf->ol_flags |= PKT_RX_VLAN_PKT;
+               mbuf->ol_flags |= PKT_RX_VLAN;
        }
        if (likely(tpa_start1->flags2 &
                   rte_cpu_to_le_32(RX_TPA_START_CMPL_FLAGS2_L4_CS_CALC)))
@@ -335,6 +335,48 @@ static inline struct rte_mbuf *bnxt_tpa_end(
        return mbuf;
 }
 
+static uint32_t
+bnxt_parse_pkt_type(struct rx_pkt_cmpl *rxcmp, struct rx_pkt_cmpl_hi *rxcmp1)
+{
+       uint32_t pkt_type = 0;
+       uint32_t t_ipcs = 0, ip = 0, ip6 = 0;
+       uint32_t tcp = 0, udp = 0, icmp = 0;
+       uint32_t vlan = 0;
+
+       vlan = !!(rxcmp1->flags2 &
+               rte_cpu_to_le_32(RX_PKT_CMPL_FLAGS2_META_FORMAT_VLAN));
+       t_ipcs = !!(rxcmp1->flags2 &
+               rte_cpu_to_le_32(RX_PKT_CMPL_FLAGS2_T_IP_CS_CALC));
+       ip6 = !!(rxcmp1->flags2 &
+                rte_cpu_to_le_32(RX_PKT_CMPL_FLAGS2_IP_TYPE));
+       icmp = !!(rxcmp->flags_type &
+                 rte_cpu_to_le_16(RX_PKT_CMPL_FLAGS_ITYPE_ICMP));
+       tcp = !!(rxcmp->flags_type &
+                rte_cpu_to_le_16(RX_PKT_CMPL_FLAGS_ITYPE_TCP));
+       udp = !!(rxcmp->flags_type &
+                rte_cpu_to_le_16(RX_PKT_CMPL_FLAGS_ITYPE_UDP));
+       ip = !!(rxcmp->flags_type &
+               rte_cpu_to_le_16(RX_PKT_CMPL_FLAGS_ITYPE_IP));
+
+       pkt_type |= ((ip || tcp || udp || icmp) && !t_ipcs && !ip6) ?
+               RTE_PTYPE_L3_IPV4_EXT_UNKNOWN : 0;
+       pkt_type |= ((ip || tcp || udp || icmp) && !t_ipcs && ip6) ?
+               RTE_PTYPE_L3_IPV6_EXT_UNKNOWN : 0;
+       pkt_type |= (!t_ipcs &&  icmp) ? RTE_PTYPE_L4_ICMP : 0;
+       pkt_type |= (!t_ipcs &&  udp) ? RTE_PTYPE_L4_UDP : 0;
+       pkt_type |= (!t_ipcs &&  tcp) ? RTE_PTYPE_L4_TCP : 0;
+       pkt_type |= ((ip || tcp || udp || icmp) && t_ipcs && !ip6) ?
+               RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN : 0;
+       pkt_type |= ((ip || tcp || udp || icmp) && t_ipcs && ip6) ?
+               RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN : 0;
+       pkt_type |= (t_ipcs &&  icmp) ? RTE_PTYPE_INNER_L4_ICMP : 0;
+       pkt_type |= (t_ipcs &&  udp) ? RTE_PTYPE_INNER_L4_UDP : 0;
+       pkt_type |= (t_ipcs &&  tcp) ? RTE_PTYPE_INNER_L4_TCP : 0;
+       pkt_type |= vlan ? RTE_PTYPE_L2_ETHER_VLAN : 0;
+
+       return pkt_type;
+}
+
 static int bnxt_rx_pkt(struct rte_mbuf **rx_pkt,
                            struct bnxt_rx_queue *rxq, uint32_t *raw_cons)
 {
@@ -368,12 +410,12 @@ static int bnxt_rx_pkt(struct rte_mbuf **rx_pkt,
                                cpr->valid);
 
        cmp_type = CMP_TYPE(rxcmp);
-       if (cmp_type == RX_PKT_CMPL_TYPE_RX_L2_TPA_START) {
+       if (cmp_type == RX_TPA_START_CMPL_TYPE_RX_TPA_START) {
                bnxt_tpa_start(rxq, (struct rx_tpa_start_cmpl *)rxcmp,
                               (struct rx_tpa_start_cmpl_hi *)rxcmp1);
                rc = -EINVAL; /* Continue w/o new mbuf */
                goto next_rx;
-       } else if (cmp_type == RX_PKT_CMPL_TYPE_RX_L2_TPA_END) {
+       } else if (cmp_type == RX_TPA_END_CMPL_TYPE_RX_TPA_END) {
                mbuf = bnxt_tpa_end(rxq, &tmp_raw_cons,
                                   (struct rx_tpa_end_cmpl *)rxcmp,
                                   (struct rx_tpa_end_cmpl_hi *)rxcmp1);
@@ -395,11 +437,11 @@ static int bnxt_rx_pkt(struct rte_mbuf **rx_pkt,
 
        cons = rxcmp->opaque;
        mbuf = bnxt_consume_rx_buf(rxr, cons);
-       rte_prefetch0(mbuf);
-
        if (mbuf == NULL)
                return -EBUSY;
 
+       rte_prefetch0(mbuf);
+
        mbuf->nb_segs = 1;
        mbuf->next = NULL;
        mbuf->pkt_len = rxcmp->len;
@@ -414,6 +456,10 @@ static int bnxt_rx_pkt(struct rte_mbuf **rx_pkt,
                mbuf->ol_flags |= PKT_RX_FDIR | PKT_RX_FDIR_ID;
        }
 
+       if ((rxcmp->flags_type & rte_cpu_to_le_16(RX_PKT_CMPL_FLAGS_MASK)) ==
+            RX_PKT_CMPL_FLAGS_ITYPE_PTP_W_TIMESTAMP)
+               mbuf->ol_flags |= PKT_RX_IEEE1588_PTP;
+
        if (agg_buf)
                bnxt_rx_pages(rxq, mbuf, &tmp_raw_cons, agg_buf);
 
@@ -422,7 +468,7 @@ static int bnxt_rx_pkt(struct rte_mbuf **rx_pkt,
                        (RX_PKT_CMPL_METADATA_VID_MASK |
                        RX_PKT_CMPL_METADATA_DE |
                        RX_PKT_CMPL_METADATA_PRI_MASK);
-               mbuf->ol_flags |= PKT_RX_VLAN_PKT;
+               mbuf->ol_flags |= PKT_RX_VLAN;
        }
 
        if (likely(RX_CMP_IP_CS_OK(rxcmp1)))
@@ -435,6 +481,7 @@ static int bnxt_rx_pkt(struct rte_mbuf **rx_pkt,
        else
                mbuf->ol_flags |= PKT_RX_L4_CKSUM_NONE;
 
+       mbuf->packet_type = bnxt_parse_pkt_type(rxcmp, rxcmp1);
 
 #ifdef BNXT_DEBUG
        if (rxcmp1->errors_v2 & RX_CMP_L2_ERRORS) {