Signed-off-by: Hemant Agrawal <hemant.agra...@nxp.com>
Signed-off-by: Shreyansh Jain <shreyansh.j...@nxp.com>
---
 doc/guides/nics/features/dpaa.ini |  1 +
 drivers/net/dpaa/dpaa_ethdev.c    | 22 ++++++++++++
 drivers/net/dpaa/dpaa_rxtx.c      | 75 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 98 insertions(+)

diff --git a/doc/guides/nics/features/dpaa.ini 
b/doc/guides/nics/features/dpaa.ini
index 916e5dc..4c81294 100644
--- a/doc/guides/nics/features/dpaa.ini
+++ b/doc/guides/nics/features/dpaa.ini
@@ -14,6 +14,7 @@ Unicast MAC filter   = Y
 RSS hash             = Y
 L3 checksum offload  = Y
 L4 checksum offload  = Y
+Packet type parsing  = Y
 Basic stats          = Y
 ARMv8                = Y
 Usage doc            = Y
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 856b229..8204ab7 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -112,6 +112,27 @@ dpaa_eth_dev_configure(struct rte_eth_dev *dev)
        return 0;
 }
 
+static const uint32_t *
+dpaa_supported_ptypes_get(struct rte_eth_dev *dev)
+{
+       static const uint32_t ptypes[] = {
+               /*todo -= add more types */
+               RTE_PTYPE_L2_ETHER,
+               RTE_PTYPE_L3_IPV4,
+               RTE_PTYPE_L3_IPV4_EXT,
+               RTE_PTYPE_L3_IPV6,
+               RTE_PTYPE_L3_IPV6_EXT,
+               RTE_PTYPE_L4_TCP,
+               RTE_PTYPE_L4_UDP,
+               RTE_PTYPE_L4_SCTP
+       };
+
+       PMD_INIT_FUNC_TRACE();
+
+       if (dev->rx_pkt_burst == dpaa_eth_queue_rx)
+               return ptypes;
+       return NULL;
+}
 
 static int dpaa_eth_dev_start(struct rte_eth_dev *dev)
 {
@@ -394,6 +415,7 @@ static struct eth_dev_ops dpaa_devops = {
        .dev_stop                 = dpaa_eth_dev_stop,
        .dev_close                = dpaa_eth_dev_close,
        .dev_infos_get            = dpaa_eth_dev_info,
+       .dev_supported_ptypes_get = dpaa_supported_ptypes_get,
 
        .rx_queue_setup           = dpaa_eth_rx_queue_setup,
        .tx_queue_setup           = dpaa_eth_tx_queue_setup,
diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c
index b1d39b6..7bb1077 100644
--- a/drivers/net/dpaa/dpaa_rxtx.c
+++ b/drivers/net/dpaa/dpaa_rxtx.c
@@ -85,6 +85,80 @@
                (_fd)->bpid = _bpid; \
        } while (0)
 
+
+static inline void dpaa_eth_packet_info(struct rte_mbuf *m,
+                                       uint64_t fd_virt_addr)
+{
+       struct annotations_t *annot = GET_ANNOTATIONS(fd_virt_addr);
+       uint64_t prs = *((uint64_t *)(&annot->parse)) & DPAA_PARSE_MASK;
+
+       PMD_RX_LOG(DEBUG, " Parsing mbuf: %p with annotations: %p", m, annot);
+
+       switch (prs) {
+       case DPAA_PKT_TYPE_NONE:
+               m->packet_type = 0;
+               break;
+       case DPAA_PKT_TYPE_ETHER:
+               m->packet_type = RTE_PTYPE_L2_ETHER;
+               break;
+       case DPAA_PKT_TYPE_IPV4:
+               m->packet_type = RTE_PTYPE_L2_ETHER |
+                       RTE_PTYPE_L3_IPV4;
+               break;
+       case DPAA_PKT_TYPE_IPV6:
+               m->packet_type = RTE_PTYPE_L2_ETHER |
+                       RTE_PTYPE_L3_IPV6;
+               break;
+       case DPAA_PKT_TYPE_IPV4_EXT:
+               m->packet_type = RTE_PTYPE_L2_ETHER |
+                       RTE_PTYPE_L3_IPV4_EXT;
+               break;
+       case DPAA_PKT_TYPE_IPV6_EXT:
+               m->packet_type = RTE_PTYPE_L2_ETHER |
+                       RTE_PTYPE_L3_IPV6_EXT;
+               break;
+       case DPAA_PKT_TYPE_IPV4_TCP:
+               m->packet_type = RTE_PTYPE_L2_ETHER |
+                       RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_TCP;
+               break;
+       case DPAA_PKT_TYPE_IPV6_TCP:
+               m->packet_type = RTE_PTYPE_L2_ETHER |
+                       RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_TCP;
+               break;
+       case DPAA_PKT_TYPE_IPV4_UDP:
+               m->packet_type = RTE_PTYPE_L2_ETHER |
+                       RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_UDP;
+               break;
+       case DPAA_PKT_TYPE_IPV6_UDP:
+               m->packet_type = RTE_PTYPE_L2_ETHER |
+                       RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_UDP;
+               break;
+       case DPAA_PKT_TYPE_IPV4_SCTP:
+               m->packet_type = RTE_PTYPE_L2_ETHER |
+                       RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_SCTP;
+               break;
+       case DPAA_PKT_TYPE_IPV6_SCTP:
+               m->packet_type = RTE_PTYPE_L2_ETHER |
+                       RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_SCTP;
+               break;
+       /* More switch cases can be added */
+       default:
+               break;
+       }
+
+       m->tx_offload = annot->parse.ip_off[0];
+       m->tx_offload |= (annot->parse.l4_off - annot->parse.ip_off[0])
+                                       << DPAA_PKT_L3_LEN_SHIFT;
+
+       /* Set the hash values */
+       m->hash.rss = (uint32_t)(rte_be_to_cpu_64(annot->hash));
+       m->ol_flags = PKT_RX_RSS_HASH;
+
+       /* Check if Vlan is present */
+       if (prs & DPAA_PARSE_VLAN_MASK)
+               m->ol_flags |= PKT_RX_VLAN_PKT;
+}
+
 static inline void dpaa_checksum(struct rte_mbuf *mbuf)
 {
        struct ether_hdr *eth_hdr = rte_pktmbuf_mtod(mbuf, struct ether_hdr *);
@@ -193,6 +267,7 @@ static inline struct rte_mbuf *dpaa_eth_fd_to_mbuf(struct 
qm_fd *fd,
        mbuf->ol_flags = 0;
        mbuf->next = NULL;
        rte_mbuf_refcnt_set(mbuf, 1);
+       dpaa_eth_packet_info(mbuf, (uint64_t)mbuf->buf_addr);
 
        return mbuf;
 }
-- 
2.7.4

Reply via email to