net/bnxt: switch CFA code to dynamic mbuf field
authorThomas Monjalon <thomas@monjalon.net>
Sun, 25 Oct 2020 22:41:16 +0000 (23:41 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Sat, 31 Oct 2020 15:13:11 +0000 (16:13 +0100)
The CFA code from mark was stored in the deprecated mbuf field udata64.
It is moved to a dynamic field in order to allow removal of udata64.

Note: the new field has 32 bits, smaller than udata64.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
drivers/net/bnxt/bnxt_ethdev.c
drivers/net/bnxt/bnxt_rxr.c
drivers/net/bnxt/bnxt_rxr.h
drivers/net/bnxt/rte_pmd_bnxt.h

index 1c7d1b7..f1350d3 100644 (file)
@@ -31,6 +31,7 @@
 #include "bnxt_nvm_defs.h"
 #include "bnxt_tf_common.h"
 #include "ulp_flow_db.h"
+#include "rte_pmd_bnxt.h"
 
 #define DRV_MODULE_NAME                "bnxt"
 static const char bnxt_version[] =
@@ -163,6 +164,8 @@ static const char *const bnxt_dev_args[] = {
  */
 #define BNXT_DEVARG_REP_FC_F2R_INVALID(rep_fc_f2r)     ((rep_fc_f2r) > 1)
 
+int bnxt_cfa_code_dynfield_offset = -1;
+
 /*
  * max_num_kflows must be >= 32
  * and must be a power-of-2 supported value
@@ -6021,6 +6024,22 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev, void *params __rte_unused)
            pci_dev->id.device_id == BROADCOM_DEV_ID_58802_VF)
                bp->flags |= BNXT_FLAG_STINGRAY;
 
+       if (BNXT_TRUFLOW_EN(bp)) {
+               /* extra mbuf field is required to store CFA code from mark */
+               static const struct rte_mbuf_dynfield bnxt_cfa_code_dynfield_desc = {
+                       .name = RTE_PMD_BNXT_CFA_CODE_DYNFIELD_NAME,
+                       .size = sizeof(bnxt_cfa_code_dynfield_t),
+                       .align = __alignof__(bnxt_cfa_code_dynfield_t),
+               };
+               bnxt_cfa_code_dynfield_offset =
+                       rte_mbuf_dynfield_register(&bnxt_cfa_code_dynfield_desc);
+               if (bnxt_cfa_code_dynfield_offset < 0) {
+                       PMD_DRV_LOG(ERR,
+                           "Failed to register mbuf field for TruFlow mark\n");
+                       return -rte_errno;
+               }
+       }
+
        rc = bnxt_init_board(eth_dev);
        if (rc) {
                PMD_DRV_LOG(ERR,
index 039217f..2645ed6 100644 (file)
@@ -606,7 +606,7 @@ bnxt_ulp_set_mark_in_mbuf(struct bnxt *bp, struct rx_pkt_cmpl_hi *rxcmp1,
                        return mark_id;
                /* Got the mark, write it to the mbuf and return */
                mbuf->hash.fdir.hi = mark_id;
-               mbuf->udata64 = (cfa_code & 0xffffffffull) << 32;
+               *bnxt_cfa_code_dynfield(mbuf) = cfa_code & 0xffffffffull;
                mbuf->hash.fdir.id = rxcmp1->cfa_code;
                mbuf->ol_flags |= PKT_RX_FDIR | PKT_RX_FDIR_ID;
                return mark_id;
index b874e54..f9e60d0 100644 (file)
@@ -95,6 +95,16 @@ void bnxt_set_mark_in_mbuf(struct bnxt *bp,
                           struct rx_pkt_cmpl_hi *rxcmp1,
                           struct rte_mbuf *mbuf);
 
+typedef uint32_t bnxt_cfa_code_dynfield_t;
+extern int bnxt_cfa_code_dynfield_offset;
+
+static inline bnxt_cfa_code_dynfield_t *
+bnxt_cfa_code_dynfield(struct rte_mbuf *mbuf)
+{
+       return RTE_MBUF_DYNFIELD(mbuf,
+               bnxt_cfa_code_dynfield_offset, bnxt_cfa_code_dynfield_t *);
+}
+
 #define BNXT_RX_META_CFA_CODE_SHIFT            19
 #define BNXT_CFA_CODE_META_SHIFT               16
 #define BNXT_RX_META_CFA_CODE_INT_ACT_REC_BIT  0x8000000
index 81d0d0e..f538b65 100644 (file)
@@ -9,6 +9,9 @@
 #include <rte_ethdev.h>
 #include <rte_ether.h>
 
+/** mbuf dynamic field where CFA code is stored */
+#define RTE_PMD_BNXT_CFA_CODE_DYNFIELD_NAME "rte_net_bnxt_dynfield_cfa_code"
+
 /*
  * Response sent back to the caller after callback
  */