net/bnxt: support host memory based TruFlow
authorVenkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Wed, 15 Apr 2020 08:18:52 +0000 (13:48 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 21 Apr 2020 11:57:08 +0000 (13:57 +0200)
This feature can be enabled by passing
"-w 0000:0d:00.0,host-based-truflow=1” to the DPDK application.

Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
drivers/net/bnxt/bnxt.h
drivers/net/bnxt/bnxt_ethdev.c

index f6a45f4..7dc55b1 100644 (file)
@@ -685,7 +685,9 @@ struct bnxt {
 #define        BNXT_SVIF_INVALID       0xFFFF
        uint16_t                func_svif;
        uint16_t                port_svif;
-       struct tf               tfp;
+
+       struct tf               tfp;
+       uint8_t                 truflow;
 };
 
 int bnxt_mtu_set_op(struct rte_eth_dev *eth_dev, uint16_t new_mtu);
index 57ed90f..c4bbf1d 100644 (file)
@@ -12,6 +12,7 @@
 #include <rte_malloc.h>
 #include <rte_cycles.h>
 #include <rte_alarm.h>
+#include <rte_kvargs.h>
 
 #include "bnxt.h"
 #include "bnxt_filter.h"
@@ -126,6 +127,18 @@ static const struct rte_pci_id bnxt_pci_id_map[] = {
                                     DEV_RX_OFFLOAD_SCATTER | \
                                     DEV_RX_OFFLOAD_RSS_HASH)
 
+#define BNXT_DEVARG_TRUFLOW    "host-based-truflow"
+static const char *const bnxt_dev_args[] = {
+       BNXT_DEVARG_TRUFLOW,
+       NULL
+};
+
+/*
+ * truflow == false to disable the feature
+ * truflow == true to enable the feature
+ */
+#define        BNXT_DEVARG_TRUFLOW_INVALID(truflow)    ((truflow) > 1)
+
 static int bnxt_vlan_offload_set_op(struct rte_eth_dev *dev, int mask);
 static void bnxt_print_link_info(struct rte_eth_dev *eth_dev);
 static int bnxt_dev_uninit(struct rte_eth_dev *eth_dev);
@@ -4853,6 +4866,63 @@ static int bnxt_init_resources(struct bnxt *bp, bool reconfig_dev)
        return 0;
 }
 
+static int
+bnxt_parse_devarg_truflow(__rte_unused const char *key,
+                         const char *value, void *opaque_arg)
+{
+       struct bnxt *bp = opaque_arg;
+       unsigned long truflow;
+       char *end = NULL;
+
+       if (!value || !opaque_arg) {
+               PMD_DRV_LOG(ERR,
+                           "Invalid parameter passed to truflow devargs.\n");
+               return -EINVAL;
+       }
+
+       truflow = strtoul(value, &end, 10);
+       if (end == NULL || *end != '\0' ||
+           (truflow == ULONG_MAX && errno == ERANGE)) {
+               PMD_DRV_LOG(ERR,
+                           "Invalid parameter passed to truflow devargs.\n");
+               return -EINVAL;
+       }
+
+       if (BNXT_DEVARG_TRUFLOW_INVALID(truflow)) {
+               PMD_DRV_LOG(ERR,
+                           "Invalid value passed to truflow devargs.\n");
+               return -EINVAL;
+       }
+
+       bp->truflow = truflow;
+       if (bp->truflow)
+               PMD_DRV_LOG(INFO, "Host-based truflow feature enabled.\n");
+
+       return 0;
+}
+
+static void
+bnxt_parse_dev_args(struct bnxt *bp, struct rte_devargs *devargs)
+{
+       struct rte_kvargs *kvlist;
+
+       if (devargs == NULL)
+               return;
+
+       kvlist = rte_kvargs_parse(devargs->args, bnxt_dev_args);
+       if (kvlist == NULL)
+               return;
+
+       /*
+        * Handler for "truflow" devarg.
+        * Invoked as for ex: "-w 0000:00:0d.0,host-based-truflow=1”
+        */
+       rte_kvargs_process(kvlist, BNXT_DEVARG_TRUFLOW,
+                          bnxt_parse_devarg_truflow, bp);
+
+       rte_kvargs_free(kvlist);
+}
+
 static int
 bnxt_dev_init(struct rte_eth_dev *eth_dev)
 {
@@ -4879,6 +4949,9 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
 
        bp = eth_dev->data->dev_private;
 
+       /* Parse dev arguments passed on when starting the DPDK application. */
+       bnxt_parse_dev_args(bp, pci_dev->device.devargs);
+
        bp->flags &= ~BNXT_FLAG_RX_VECTOR_PKT_MODE;
 
        if (bnxt_vf_pciid(pci_dev->id.device_id))