From patchwork Mon Sep 18 14:36:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xueming Li X-Patchwork-Id: 28850 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 49AA11B1B9; Mon, 18 Sep 2017 16:40:44 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 938B01B1B0 for ; Mon, 18 Sep 2017 16:40:40 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@mellanox.com) with ESMTPS (AES256-SHA encrypted); 18 Sep 2017 17:40:36 +0300 Received: from dev-r630-06.mtbc.labs.mlnx (dev-r630-06.mtbc.labs.mlnx [10.12.205.180]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id v8IEeRit015498; Mon, 18 Sep 2017 17:40:35 +0300 Received: from dev-r630-06.mtbc.labs.mlnx (localhost [127.0.0.1]) by dev-r630-06.mtbc.labs.mlnx (8.14.7/8.14.7) with ESMTP id v8IEaVCq177484; Mon, 18 Sep 2017 22:36:31 +0800 Received: (from xuemingl@localhost) by dev-r630-06.mtbc.labs.mlnx (8.14.7/8.14.7/Submit) id v8IEaVLf177483; Mon, 18 Sep 2017 22:36:31 +0800 From: Xueming Li To: Nelio Laranjeiro , Adrien Mazarguil Cc: Xueming Li , dev@dpdk.org Date: Mon, 18 Sep 2017 22:36:18 +0800 Message-Id: <20170918143619.177422-6-xuemingl@mellanox.com> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170918143619.177422-1-xuemingl@mellanox.com> References: <20170918143619.177422-1-xuemingl@mellanox.com> In-Reply-To: <20170824140341.95471-1-xuemingl@mellanox.com> References: <20170824140341.95471-1-xuemingl@mellanox.com> Subject: [dpdk-dev] [PATCH v3 5/6] net/mlx5: add operations for secondary process X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add operations that are safe for secondary processes: * (x)stats * device info get * rx/tx descriptor status Signed-off-by: Xueming Li Acked-by: Nelio Laranjeiro --- drivers/net/mlx5/mlx5.c | 16 +++++++++++++++- drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_ethdev.c | 11 +++++------ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index e124a14..76e92a5 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -303,6 +303,18 @@ struct mlx5_args { .rx_queue_intr_disable = mlx5_rx_intr_disable, }; + +static const struct eth_dev_ops mlx5_dev_sec_ops = { + .stats_get = mlx5_stats_get, + .stats_reset = mlx5_stats_reset, + .xstats_get = mlx5_xstats_get, + .xstats_reset = mlx5_xstats_reset, + .xstats_get_names = mlx5_xstats_get_names, + .dev_infos_get = mlx5_dev_infos_get, + .rx_descriptor_status = mlx5_rx_descriptor_status, + .tx_descriptor_status = mlx5_tx_descriptor_status, +}; + static struct { struct rte_pci_addr pci_addr; /* associated PCI address */ uint32_t ports; /* physical ports bitfield. */ @@ -640,7 +652,7 @@ struct mlx5_args { goto error; } eth_dev->device = &pci_dev->device; - eth_dev->dev_ops = NULL; + eth_dev->dev_ops = &mlx5_dev_sec_ops; priv = eth_dev->data->dev_private; /* Receive command fd from primary process */ err = priv_socket_connect(priv); @@ -707,6 +719,8 @@ struct mlx5_args { } priv->ctx = ctx; + strncpy(priv->ibdev_path, priv->ctx->device->ibdev_path, + sizeof(priv->ibdev_path)); priv->device_attr = device_attr; priv->port = port; priv->pd = pd; diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 1ce02e8..928aeb6 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -91,6 +91,7 @@ struct priv { struct ibv_context *ctx; /* Verbs context. */ struct ibv_device_attr_ex device_attr; /* Device properties. */ struct ibv_pd *pd; /* Protection Domain. */ + char ibdev_path[IBV_SYSFS_PATH_MAX]; /* IB device path for secondary */ /* * MAC addresses array and configuration bit-field. * An extra entry that cannot be modified by the DPDK is reserved diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c index 46c3013..8f3ff89 100644 --- a/drivers/net/mlx5/mlx5_ethdev.c +++ b/drivers/net/mlx5/mlx5_ethdev.c @@ -165,7 +165,7 @@ struct priv * char match[IF_NAMESIZE] = ""; { - MKSTR(path, "%s/device/net", priv->ctx->device->ibdev_path); + MKSTR(path, "%s/device/net", priv->ibdev_path); dir = opendir(path); if (dir == NULL) @@ -183,7 +183,7 @@ struct priv * continue; MKSTR(path, "%s/device/net/%s/%s", - priv->ctx->device->ibdev_path, name, + priv->ibdev_path, name, (dev_type ? "dev_id" : "dev_port")); file = fopen(path, "rb"); @@ -271,11 +271,11 @@ struct priv * if (priv_is_ib_cntr(entry)) { MKSTR(path, "%s/ports/1/hw_counters/%s", - priv->ctx->device->ibdev_path, entry); + priv->ibdev_path, entry); file = fopen(path, "rb"); } else { MKSTR(path, "%s/device/net/%s/%s", - priv->ctx->device->ibdev_path, ifname, entry); + priv->ibdev_path, ifname, entry); file = fopen(path, "rb"); } if (file == NULL) @@ -318,8 +318,7 @@ struct priv * if (priv_get_ifname(priv, &ifname)) return -1; - MKSTR(path, "%s/device/net/%s/%s", priv->ctx->device->ibdev_path, - ifname, entry); + MKSTR(path, "%s/device/net/%s/%s", priv->ibdev_path, ifname, entry); file = fopen(path, "wb"); if (file == NULL)