net/octeontx: add packet type parsing support
authorJerin Jacob <jerin.jacob@caviumnetworks.com>
Sun, 8 Oct 2017 12:44:28 +0000 (18:14 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Thu, 12 Oct 2017 00:36:58 +0000 (01:36 +0100)
Mark packet type parsing in features.

Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
Signed-off-by: Santosh Shukla <santosh.shukla@caviumnetworks.com>
doc/guides/nics/features/octeontx.ini
drivers/net/octeontx/octeontx_ethdev.c
drivers/net/octeontx/octeontx_rxtx.c

index cf9167d..c92d5aa 100644 (file)
@@ -12,6 +12,7 @@ Jumbo frame          = Y
 Promiscuous mode     = Y
 Unicast MAC filter   = P
 CRC offload          = Y
+Packet type parsing  = Y
 Basic stats          = Y
 Linux VFIO           = Y
 ARMv8                = Y
index 100ac60..706cf88 100644 (file)
@@ -47,6 +47,7 @@
 #include <rte_vdev.h>
 
 #include "octeontx_ethdev.h"
+#include "octeontx_rxtx.h"
 #include "octeontx_logs.h"
 
 struct octeontx_vdev_init_params {
@@ -840,6 +841,26 @@ octeontx_dev_rx_queue_release(void *rxq)
        rte_free(rxq);
 }
 
+static const uint32_t *
+octeontx_dev_supported_ptypes_get(struct rte_eth_dev *dev)
+{
+       static const uint32_t ptypes[] = {
+               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_FRAG,
+               RTE_PTYPE_UNKNOWN
+       };
+
+       if (dev->rx_pkt_burst == octeontx_recv_pkts)
+               return ptypes;
+
+       return NULL;
+}
+
 /* Initialize and register driver with DPDK Application */
 static const struct eth_dev_ops octeontx_dev_ops = {
        .dev_configure           = octeontx_dev_configure,
@@ -856,6 +877,7 @@ static const struct eth_dev_ops octeontx_dev_ops = {
        .tx_queue_release        = octeontx_dev_tx_queue_release,
        .rx_queue_setup          = octeontx_dev_rx_queue_setup,
        .rx_queue_release        = octeontx_dev_rx_queue_release,
+       .dev_supported_ptypes_get = octeontx_dev_supported_ptypes_get,
 };
 
 /* Create Ethdev interface per BGX LMAC ports */
index 05f0036..0b15833 100644 (file)
 #include "octeontx_rxtx.h"
 #include "octeontx_logs.h"
 
+/* Packet type table */
+#define PTYPE_SIZE     OCCTX_PKI_LTYPE_LAST
+
+static const uint32_t __rte_cache_aligned
+ptype_table[PTYPE_SIZE][PTYPE_SIZE][PTYPE_SIZE] = {
+       [LC_NONE][LE_NONE][LF_NONE] = RTE_PTYPE_UNKNOWN,
+       [LC_NONE][LE_NONE][LF_IPSEC_ESP] = RTE_PTYPE_UNKNOWN,
+       [LC_NONE][LE_NONE][LF_IPFRAG] = RTE_PTYPE_L4_FRAG,
+       [LC_NONE][LE_NONE][LF_IPCOMP] = RTE_PTYPE_UNKNOWN,
+       [LC_NONE][LE_NONE][LF_TCP] = RTE_PTYPE_L4_TCP,
+       [LC_NONE][LE_NONE][LF_UDP] = RTE_PTYPE_L4_UDP,
+       [LC_NONE][LE_NONE][LF_GRE] = RTE_PTYPE_TUNNEL_GRE,
+       [LC_NONE][LE_NONE][LF_UDP_GENEVE] = RTE_PTYPE_TUNNEL_GENEVE,
+       [LC_NONE][LE_NONE][LF_UDP_VXLAN] = RTE_PTYPE_TUNNEL_VXLAN,
+       [LC_NONE][LE_NONE][LF_NVGRE] = RTE_PTYPE_TUNNEL_NVGRE,
+
+       [LC_IPV4][LE_NONE][LF_NONE] = RTE_PTYPE_L3_IPV4 | RTE_PTYPE_UNKNOWN,
+       [LC_IPV4][LE_NONE][LF_IPSEC_ESP] =
+                               RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L3_IPV4,
+       [LC_IPV4][LE_NONE][LF_IPFRAG] = RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_FRAG,
+       [LC_IPV4][LE_NONE][LF_IPCOMP] = RTE_PTYPE_L3_IPV4 | RTE_PTYPE_UNKNOWN,
+       [LC_IPV4][LE_NONE][LF_TCP] = RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_TCP,
+       [LC_IPV4][LE_NONE][LF_UDP] = RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_UDP,
+       [LC_IPV4][LE_NONE][LF_GRE] = RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_GRE,
+       [LC_IPV4][LE_NONE][LF_UDP_GENEVE] =
+                               RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_GENEVE,
+       [LC_IPV4][LE_NONE][LF_UDP_VXLAN] =
+                               RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_VXLAN,
+       [LC_IPV4][LE_NONE][LF_NVGRE] =
+                               RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_NVGRE,
+
+       [LC_IPV4_OPT][LE_NONE][LF_NONE] =
+                               RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_UNKNOWN,
+       [LC_IPV4_OPT][LE_NONE][LF_IPSEC_ESP] =
+                               RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_L3_IPV4,
+       [LC_IPV4_OPT][LE_NONE][LF_IPFRAG] =
+                               RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_L4_FRAG,
+       [LC_IPV4_OPT][LE_NONE][LF_IPCOMP] =
+                               RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_UNKNOWN,
+       [LC_IPV4_OPT][LE_NONE][LF_TCP] =
+                               RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_L4_TCP,
+       [LC_IPV4_OPT][LE_NONE][LF_UDP] =
+                               RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_L4_UDP,
+       [LC_IPV4_OPT][LE_NONE][LF_GRE] =
+                               RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_TUNNEL_GRE,
+       [LC_IPV4_OPT][LE_NONE][LF_UDP_GENEVE] =
+                               RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_TUNNEL_GENEVE,
+       [LC_IPV4_OPT][LE_NONE][LF_UDP_VXLAN] =
+                               RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_TUNNEL_VXLAN,
+       [LC_IPV4_OPT][LE_NONE][LF_NVGRE] =
+                               RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_TUNNEL_NVGRE,
+
+       [LC_IPV6][LE_NONE][LF_NONE] = RTE_PTYPE_L3_IPV6 | RTE_PTYPE_UNKNOWN,
+       [LC_IPV6][LE_NONE][LF_IPSEC_ESP] =
+                               RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L3_IPV4,
+       [LC_IPV6][LE_NONE][LF_IPFRAG] = RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_FRAG,
+       [LC_IPV6][LE_NONE][LF_IPCOMP] = RTE_PTYPE_L3_IPV6 | RTE_PTYPE_UNKNOWN,
+       [LC_IPV6][LE_NONE][LF_TCP] = RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_TCP,
+       [LC_IPV6][LE_NONE][LF_UDP] = RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_UDP,
+       [LC_IPV6][LE_NONE][LF_GRE] = RTE_PTYPE_L3_IPV6 | RTE_PTYPE_TUNNEL_GRE,
+       [LC_IPV6][LE_NONE][LF_UDP_GENEVE] =
+                               RTE_PTYPE_L3_IPV6 | RTE_PTYPE_TUNNEL_GENEVE,
+       [LC_IPV6][LE_NONE][LF_UDP_VXLAN] =
+                               RTE_PTYPE_L3_IPV6 | RTE_PTYPE_TUNNEL_VXLAN,
+       [LC_IPV6][LE_NONE][LF_NVGRE] =
+                               RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_NVGRE,
+       [LC_IPV6_OPT][LE_NONE][LF_NONE] =
+                               RTE_PTYPE_L3_IPV6_EXT | RTE_PTYPE_UNKNOWN,
+       [LC_IPV6_OPT][LE_NONE][LF_IPSEC_ESP] =
+                               RTE_PTYPE_L3_IPV6_EXT | RTE_PTYPE_L3_IPV4,
+       [LC_IPV6_OPT][LE_NONE][LF_IPFRAG] =
+                               RTE_PTYPE_L3_IPV6_EXT | RTE_PTYPE_L4_FRAG,
+       [LC_IPV6_OPT][LE_NONE][LF_IPCOMP] =
+                               RTE_PTYPE_L3_IPV6_EXT | RTE_PTYPE_UNKNOWN,
+       [LC_IPV6_OPT][LE_NONE][LF_TCP] =
+                               RTE_PTYPE_L3_IPV6_EXT | RTE_PTYPE_L4_TCP,
+       [LC_IPV6_OPT][LE_NONE][LF_UDP] =
+                               RTE_PTYPE_L3_IPV6_EXT | RTE_PTYPE_L4_UDP,
+       [LC_IPV6_OPT][LE_NONE][LF_GRE] =
+                               RTE_PTYPE_L3_IPV6_EXT | RTE_PTYPE_TUNNEL_GRE,
+       [LC_IPV6_OPT][LE_NONE][LF_UDP_GENEVE] =
+                               RTE_PTYPE_L3_IPV6_EXT | RTE_PTYPE_TUNNEL_GENEVE,
+       [LC_IPV6_OPT][LE_NONE][LF_UDP_VXLAN] =
+                               RTE_PTYPE_L3_IPV6_EXT | RTE_PTYPE_TUNNEL_VXLAN,
+       [LC_IPV6_OPT][LE_NONE][LF_NVGRE] =
+                               RTE_PTYPE_L3_IPV6_EXT | RTE_PTYPE_TUNNEL_NVGRE,
+
+};
+
 static __rte_always_inline uint16_t __hot
 __octeontx_xmit_pkts(void *lmtline_va, void *ioreg_va, int64_t *fc_status_va,
                        struct rte_mbuf *tx_pkt)
@@ -128,6 +217,8 @@ octeontx_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
                /* Get mbuf from wqe */
                mbuf = (struct rte_mbuf *)((uintptr_t)wqe -
                                                OCTTX_PACKET_WQE_SKIP);
+               mbuf->packet_type =
+               ptype_table[wqe->s.w2.lcty][wqe->s.w2.lety][wqe->s.w2.lfty];
                mbuf->data_off = RTE_PTR_DIFF(wqe->s.w3.addr, mbuf->buf_addr);
                mbuf->pkt_len = wqe->s.w1.len;
                mbuf->data_len = mbuf->pkt_len;