[dpdk-dev,v2,3/4] net/mlx4: net bus support

Message ID d08ce4cbebe7420d10842a8ba56348d174478fda.1496877142.git.gaetan.rivet@6wind.com (mailing list archive)
State Rejected, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Gaëtan Rivet June 8, 2017, 12:01 a.m. UTC
  Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/net/mlx4/mlx4.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
  

Patch

diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
index b9554d5..9dfff5f 100644
--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c
@@ -62,6 +62,7 @@ 
 #include <rte_ethdev.h>
 #include <rte_ethdev_pci.h>
 #include <rte_dev.h>
+#include <rte_bus_net.h>
 #include <rte_mbuf.h>
 #include <rte_errno.h>
 #include <rte_mempool.h>
@@ -6302,3 +6303,37 @@  RTE_PMD_EXPORT_NAME(net_mlx4, __COUNTER__);
 RTE_PMD_REGISTER_PCI_TABLE(net_mlx4, mlx4_pci_id_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_mlx4,
 	"* ib_uverbs & mlx4_en & mlx4_core & mlx4_ib");
+
+static int
+mlx4_net_pci_xfrm(const struct rte_devargs *src,
+		  struct rte_devargs *dst)
+{
+	char buf[32] = "";
+	size_t arglen;
+	int ret;
+
+	ret = rte_bus_net_pci_loc(src->name, buf, sizeof(buf));
+	if (ret)
+		return ret;
+	snprintf(dst->name, sizeof(dst->name), "%s", buf);
+	memset(buf, 0, sizeof(buf));
+	ret = rte_bus_net_path_read(buf, sizeof(buf),
+				    "/sys/class/net/%s/dev_port", src->name);
+	if (ret)
+		return ret;
+	arglen = snprintf(NULL, 0, "port=%s,%s", buf, src->args) + 1;
+	dst->args = calloc(1, arglen);
+	if (dst->args == NULL)
+		return -ENOMEM;
+	snprintf(dst->args, arglen, "port=%s,%s", buf, src->args);
+	return 0;
+}
+
+static struct rte_net_driver mlx4_net_driver = {
+	.driver = {
+		.name = MLX4_DRIVER_NAME,
+	},
+	.kmod = "mlx4_core",
+	.xfrm = mlx4_net_pci_xfrm,
+};
+RTE_PMD_REGISTER_NET(mlx4, mlx4_net_driver);