From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 63006A04B5; Sat, 3 Oct 2020 00:48:16 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1B1D31D58B; Sat, 3 Oct 2020 00:47:58 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 49BEB1C1D9 for ; Sat, 3 Oct 2020 00:47:55 +0200 (CEST) IronPort-SDR: qqlGJdQjluZrFbRW2Qs9v5DAaNDKI2celrsUT8/iQeYlgjpMeTAZLZV2l1/ICP/6LXZz4IBJXP 2XepPtT3Ycww== X-IronPort-AV: E=McAfee;i="6000,8403,9762"; a="142494465" X-IronPort-AV: E=Sophos;i="5.77,329,1596524400"; d="scan'208";a="142494465" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Oct 2020 15:47:53 -0700 IronPort-SDR: 5LYZmecSMEHofA200UPrezz1Nat9lByYGmFhyRxLrSDmBywHpij6f+hyzFtFWRkB5cyw4M4XSw 0TJ60Jv23slg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,329,1596524400"; d="scan'208";a="340154931" Received: from silpixa00399752.ir.intel.com (HELO silpixa00399752.ger.corp.intel.com) ([10.237.222.180]) by fmsmga004.fm.intel.com with ESMTP; 02 Oct 2020 15:47:52 -0700 From: Ferruh Yigit To: Bruce Richardson Cc: dev@dpdk.org Date: Fri, 2 Oct 2020 23:47:48 +0100 Message-Id: <20201002224748.1532530-2-ferruh.yigit@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201002224748.1532530-1-ferruh.yigit@intel.com> References: <20201002224748.1532530-1-ferruh.yigit@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 2/2] net/ring: prevent nodeaction arg create multiple ethdev 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" PMD accepts multiple 'nodeaction' arguments per vdev, for each instance of the devarg an ethdev is created. Like: "--vdev net_ring0,nodeaction=r1:0:CREATE,nodeaction=r2:0:CREATE" allocates two ethdevs. Here ethdev names will be 'r1' and 'r2' respectively (each ethdev with hardcoded number of queues). If multiple ring ethdev is required, this can already be achieved by providing multiple '--vdev'. This patch updates the multiple 'nodeaction' arguments behavior, it now creates single ethdev per a '--vdev' and each 'nodeaction' argument used to define a queue of the ethdev. Number of 'nodeaction' argument defines number of the queues in device. Like for above sample: "--vdev net_ring0,nodeaction=r1:0:CREATE,nodeaction=r2:0:CREATE", creates an ethdev named 'net_ring0' with two queues from newly created rings. Ring names are 'r1' and 'r2'. For ethdev device 'node' and 'action' values are used from first instance of the 'nodeaction' argument. The behavior of the single 'nodeaction' argument behavior is slightly changed, it now allocates (create or attach) single queue, instead of hardcoded number of queues as done before. The behavior without 'nodeaction' argument, "--vdev net_ring0", has not been changed at all. This also allows following, which was broken before: "--vdev net_ring0,nodeaction=r1:0:CREATE,nodeaction=r2:0:CREATE \ --vdev net_ring1,nodeaction=r1:0:ATTACH,nodeaction=r2:0:ATTACH" Signed-off-by: Ferruh Yigit --- drivers/net/ring/rte_eth_ring.c | 53 +++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 13 deletions(-) diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c index 6d3deaa81a..fd02c06c56 100644 --- a/drivers/net/ring/rte_eth_ring.c +++ b/drivers/net/ring/rte_eth_ring.c @@ -495,6 +495,38 @@ struct node_action_list { struct node_action_pair *list; }; +static int +eth_dev_ring_create_nodeaction(const char *name, + struct rte_vdev_device *vdev, + const unsigned int numa_node, + enum dev_action action, + struct rte_eth_dev **eth_dev, + struct node_action_list *info) +{ + struct rte_ring *rxtx[RTE_PMD_RING_MAX_RX_RINGS]; + unsigned int num_rings; + unsigned int i; + + num_rings = info->total; + + for (i = 0; i < num_rings; i++) { + if (action == DEV_CREATE) + rxtx[i] = rte_ring_create(info->list[i].name, 1024, + numa_node, + RING_F_SP_ENQ|RING_F_SC_DEQ); + else + rxtx[i] = rte_ring_lookup(info->list[i].name); + if (rxtx[i] == NULL) + return -1; + } + + if (do_eth_dev_ring_create(name, vdev, rxtx, num_rings, rxtx, + num_rings, numa_node, action, eth_dev) < 0) + return -1; + + return 0; +} + static int parse_kvlist(const char *key __rte_unused, const char *value, void *data) { @@ -657,22 +689,17 @@ rte_pmd_ring_probe(struct rte_vdev_device *dev) ret = rte_kvargs_process(kvlist, ETH_RING_NUMA_NODE_ACTION_ARG, parse_kvlist, info); - if (ret < 0) goto out_free; - for (info->count = 0; info->count < info->total; info->count++) { - ret = eth_dev_ring_create(info->list[info->count].name, dev, - info->list[info->count].node, - info->list[info->count].action, - ð_dev); - if ((ret == -1) && (info->list[info->count].action == DEV_CREATE)) { - PMD_LOG(INFO, "Attach to pmd_ring for %s", name); - ret = eth_dev_ring_create(name, dev, - info->list[info->count].node, - DEV_ATTACH, - ð_dev); - } + ret = eth_dev_ring_create_nodeaction(name, dev, + info->list[0].node, + info->list[0].action, ð_dev, info); + if ((ret == -1) && (info->list[0].action == DEV_CREATE)) { + PMD_LOG(INFO, "Attach to pmd_ring for %s", name); + ret = eth_dev_ring_create_nodeaction(name, dev, + info->list[0].node, + DEV_ATTACH, ð_dev, info); } out_free: -- 2.26.2