Use mbuf dynfield1 array in Prox 53/72853/2
authorHeinrich Kuhn <heinrich.kuhn@corigine.com>
Wed, 18 Aug 2021 14:58:46 +0000 (16:58 +0200)
committerLuc Provoost <luc.provoost@intel.com>
Mon, 13 Sep 2021 10:05:54 +0000 (10:05 +0000)
The udata64 field in the rte_mbuf struct has been removed to make more
space for the dynfield1 array. Prox used the udata64 field for various
use cases. From DPDK v20.11 and beyond use the dynfield1 field in the
rte_mbuf struct for the same functionality.

Signed-off-by: Heinrich Kuhn <heinrich.kuhn@corigine.com>
Signed-off-by: Simon Horman <simon.horman@corigine.com>
Change-Id: I0c2ba2f24bf5649ae809a54a9b0f9d6bebdd7056

VNFs/DPPD-PROX/handle_dump.c
VNFs/DPPD-PROX/handle_nsh.c
VNFs/DPPD-PROX/handle_qinq_decap4.c
VNFs/DPPD-PROX/handle_tsc.c

index 29a46fe..8fbc514 100644 (file)
@@ -42,7 +42,12 @@ static uint16_t buffer_packets(struct task_dump *task, struct rte_mbuf **mbufs,
                return 0;
 
        for (j = 0; j < n_pkts && task->n_mbufs < task->n_pkts; ++j) {
+#if RTE_VERSION >= RTE_VERSION_NUM(20,11,0,0)
+               uint64_t rdtsc = rte_rdtsc();
+               memcpy(&mbufs[j]->dynfield1[0], &rdtsc, sizeof(rdtsc));
+#else
                mbufs[j]->udata64 = rte_rdtsc();
+#endif
                task->mbufs[task->n_mbufs++] = mbufs[j];
        }
 
@@ -93,10 +98,20 @@ static void stop(struct task_base *tbase)
        pcap_dump_handle = pcap_dump_open(handle, task->pcap_file);
 
        if (task->n_mbufs) {
+#if RTE_VERSION >= RTE_VERSION_NUM(20,11,0,0)
+               memcpy(&beg, &task->mbufs[0]->dynfield1[0], sizeof(beg));
+#else
                beg = task->mbufs[0]->udata64;
+#endif
        }
        for (uint32_t j = 0; j < task->n_mbufs; ++j) {
+#if RTE_VERSION >= RTE_VERSION_NUM(20,11,0,0)
+               uint64_t mbufs_beg;
+               memcpy(&mbufs_beg, &task->mbufs[j]->dynfield1[0], sizeof(mbufs_beg));
+               tsc = mbufs_beg - beg;
+#else
                tsc = task->mbufs[j]->udata64 - beg;
+#endif
                header.len = rte_pktmbuf_pkt_len(task->mbufs[j]);
                header.caplen = header.len;
                tsc_to_tv(&header.ts, tsc);
index ba2d14f..a1df22f 100644 (file)
@@ -68,26 +68,43 @@ static inline uint8_t handle_decap_nsh(__attribute__((unused)) struct task_decap
                mbuf->data_len = (uint16_t)(mbuf->data_len - hdr_len);
                mbuf->data_off += hdr_len;
                mbuf->pkt_len = (uint32_t)(mbuf->pkt_len - hdr_len);
+#if RTE_VERSION >= RTE_VERSION_NUM(20,11,0,0)
+               /* save length of header in the dynfield1 of rte_mbuf */
+               mbuf->dynfield1[0] = hdr_len;
+#else
                /* save length of header in reserved 16bits of rte_mbuf */
                mbuf->udata64 = hdr_len;
+#endif
        }
        else {
                if (mbuf->data_len < VXLAN_GPE_HDR_SZ) {
+#if RTE_VERSION >= RTE_VERSION_NUM(20,11,0,0)
+                       mbuf->dynfield1[0] = 0;
+#else
                        mbuf->udata64 = 0;
+#endif
                        return 0;
                }
 
                /* check the UDP destination port */
                udp_hdr = (prox_rte_udp_hdr *)(((unsigned char *)eth_hdr) + sizeof(prox_rte_ether_hdr) + sizeof(prox_rte_ipv4_hdr));
                if (udp_hdr->dst_port != VXLAN_GPE_NSH_TYPE) {
+#if RTE_VERSION >= RTE_VERSION_NUM(20,11,0,0)
+                       mbuf->dynfield1[0] = 0;
+#else
                        mbuf->udata64 = 0;
+#endif
                        return 0;
                }
 
                /* check the Next Protocol field in VxLAN-GPE header */
                vxlan_gpe_hdr = (prox_rte_vxlan_gpe_hdr *)(((unsigned char *)eth_hdr) + sizeof(prox_rte_ether_hdr) + sizeof(prox_rte_ipv4_hdr) + sizeof(prox_rte_udp_hdr));
                if (vxlan_gpe_hdr->proto != VXLAN_GPE_NP) {
+#if RTE_VERSION >= RTE_VERSION_NUM(20,11,0,0)
+                       mbuf->dynfield1[0] = 0;
+#else
                        mbuf->udata64 = 0;
+#endif
                        return 0;
                }
 
@@ -97,8 +114,13 @@ static inline uint8_t handle_decap_nsh(__attribute__((unused)) struct task_decap
                mbuf->data_len = (uint16_t)(mbuf->data_len - hdr_len);
                mbuf->data_off += hdr_len;
                mbuf->pkt_len  = (uint32_t)(mbuf->pkt_len - hdr_len);
+#if RTE_VERSION >= RTE_VERSION_NUM(20,11,0,0)
+               /* save length of header in the dynfield1 of rte_mbuf */
+               mbuf->dynfield1[0] = hdr_len;
+#else
                /* save length of header in reserved 16bits of rte_mbuf */
                mbuf->udata64 = hdr_len;
+#endif
        }
 
        return 0;
@@ -143,14 +165,26 @@ static inline uint8_t handle_encap_nsh(__attribute__((unused)) struct task_encap
 
        if (mbuf == NULL)
                return 0;
+#if RTE_VERSION >= RTE_VERSION_NUM(20,11,0,0)
+       if (mbuf->dynfield1[0] == 0)
+#else
        if (mbuf->udata64 == 0)
+#endif
                return 0;
 
+#if RTE_VERSION >= RTE_VERSION_NUM(20,11,0,0)
+       /* use header length saved in dynfields1 of rte_mbuf to
+          "encapsulate" transport + NSH header by moving packet pointer */
+       mbuf->data_len = (uint16_t)(mbuf->data_len + mbuf->dynfield1[0]);
+       mbuf->data_off -= mbuf->dynfield1[0];
+       mbuf->pkt_len  = (uint32_t)(mbuf->pkt_len + mbuf->dynfield1[0]);
+#else
        /* use header length saved in reserved 16bits of rte_mbuf to
           "encapsulate" transport + NSH header by moving packet pointer */
        mbuf->data_len = (uint16_t)(mbuf->data_len + mbuf->udata64);
        mbuf->data_off -= mbuf->udata64;
        mbuf->pkt_len  = (uint32_t)(mbuf->pkt_len + mbuf->udata64);
+#endif
 
        eth_hdr = rte_pktmbuf_mtod(mbuf, prox_rte_ether_hdr *);
        if (eth_hdr->ether_type == ETHER_NSH_TYPE) {
index 94efbb1..d74e622 100644 (file)
@@ -183,6 +183,10 @@ __attribute__((cold)) static void handle_error(struct rte_mbuf *mbuf)
 
        svlan = rte_be_to_cpu_16(svlan & 0xFF0F);
        cvlan = rte_be_to_cpu_16(cvlan & 0xFF0F);
+#if RTE_VERSION >= RTE_VERSION_NUM(20,11,0,0)
+       plogx_err("Can't convert key %016lx qinq %d|%d (%x|%x) to gre_id, rss=%x flags=%lx, status_err_len=%x, L2Tag=%d type=%d\n",
+                 key, svlan, cvlan, svlan, cvlan, mbuf->hash.rss, mbuf->ol_flags, mbuf->dynfield1[0], mbuf->vlan_tci_outer, mbuf->packet_type);
+#else
 #if RTE_VERSION >= RTE_VERSION_NUM(2,1,0,0)
        plogx_err("Can't convert key %016lx qinq %d|%d (%x|%x) to gre_id, rss=%x flags=%lx, status_err_len=%lx, L2Tag=%d type=%d\n",
                  key, svlan, cvlan, svlan, cvlan, mbuf->hash.rss, mbuf->ol_flags, mbuf->udata64, mbuf->vlan_tci_outer, mbuf->packet_type);
@@ -195,6 +199,7 @@ __attribute__((cold)) static void handle_error(struct rte_mbuf *mbuf)
                  key, svlan, cvlan, svlan, cvlan, mbuf->ol_flags, mbuf->reserved);
 #endif
 #endif
+#endif
 #else
        plogx_err("Can't convert ip %x to gre_id\n", rte_bswap32(packet->ipv4_hdr.src_addr));
 #endif
index 245fe7a..da0afea 100644 (file)
@@ -31,7 +31,11 @@ static int handle_bulk_tsc(struct task_base *tbase, struct rte_mbuf **mbufs, uin
        const uint64_t rx_tsc = rte_rdtsc();
 
        for (uint16_t j = 0; j < n_pkts; ++j)
+#if RTE_VERSION >= RTE_VERSION_NUM(20,11,0,0)
+               memcpy(&mbufs[j]->dynfield1[0], &rx_tsc, sizeof(rx_tsc));
+#else
                mbufs[j]->udata64 = rx_tsc;
+#endif
 
        return task->base.tx_pkt(&task->base, mbufs, n_pkts, NULL);
 }