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 6CE02A04B5; Sat, 3 Oct 2020 00:47:58 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B159A1C1D9; Sat, 3 Oct 2020 00:47:56 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id DF62D1C120 for ; Sat, 3 Oct 2020 00:47:53 +0200 (CEST) IronPort-SDR: kjiBXl67wk1JttmTNV/uDjsxV7hmgzQnaDiAdiANjXfvz88vnG99/3Qsw4dt6XxY9WLZctK0Mi oU3bLCjDYHsA== X-IronPort-AV: E=McAfee;i="6000,8403,9762"; a="142494457" X-IronPort-AV: E=Sophos;i="5.77,329,1596524400"; d="scan'208";a="142494457" 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:51 -0700 IronPort-SDR: P3GUzLmUk6MsEYv0oANqFwGUYoqUz436JiNw1K7Y78SoST7jVnT9MptuAc+1dUZ1/y3q95cLtw mDkVndmNJeZQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,329,1596524400"; d="scan'208";a="340154923" 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:50 -0700 From: Ferruh Yigit To: Bruce Richardson Cc: dev@dpdk.org Date: Fri, 2 Oct 2020 23:47:47 +0100 Message-Id: <20201002224748.1532530-1-ferruh.yigit@intel.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 1/2] net/ring: refactor to reduce indentation in probe 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" No functional change. Signed-off-by: Ferruh Yigit --- drivers/net/ring/rte_eth_ring.c | 137 +++++++++++++++----------------- 1 file changed, 66 insertions(+), 71 deletions(-) diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c index 83c5502123..6d3deaa81a 100644 --- a/drivers/net/ring/rte_eth_ring.c +++ b/drivers/net/ring/rte_eth_ring.c @@ -598,85 +598,80 @@ rte_pmd_ring_probe(struct rte_vdev_device *dev) PMD_LOG(INFO, "Initializing pmd_ring for %s", name); if (params == NULL || params[0] == '\0') { - ret = eth_dev_ring_create(name, dev, rte_socket_id(), DEV_CREATE, - ð_dev); + ret = eth_dev_ring_create(name, dev, rte_socket_id(), + DEV_CREATE, ð_dev); if (ret == -1) { - PMD_LOG(INFO, - "Attach to pmd_ring for %s", name); + PMD_LOG(INFO, "Attach to pmd_ring for %s", name); ret = eth_dev_ring_create(name, dev, rte_socket_id(), - DEV_ATTACH, ð_dev); + DEV_ATTACH, ð_dev); } - } else { - kvlist = rte_kvargs_parse(params, valid_arguments); - if (!kvlist) { - PMD_LOG(INFO, - "Ignoring unsupported parameters when creatingrings-backed ethernet device"); + return ret; + } + + kvlist = rte_kvargs_parse(params, valid_arguments); + if (!kvlist) { + PMD_LOG(INFO, + "Ignoring unsupported parameters when creatingrings-backed ethernet device"); + ret = eth_dev_ring_create(name, dev, rte_socket_id(), + DEV_CREATE, ð_dev); + if (ret == -1) { + PMD_LOG(INFO, "Attach to pmd_ring for %s", name); ret = eth_dev_ring_create(name, dev, rte_socket_id(), - DEV_CREATE, ð_dev); - if (ret == -1) { - PMD_LOG(INFO, - "Attach to pmd_ring for %s", - name); - ret = eth_dev_ring_create(name, dev, rte_socket_id(), - DEV_ATTACH, ð_dev); - } - - return ret; + DEV_ATTACH, ð_dev); } - if (rte_kvargs_count(kvlist, ETH_RING_INTERNAL_ARG) == 1) { - ret = rte_kvargs_process(kvlist, ETH_RING_INTERNAL_ARG, - parse_internal_args, - &internal_args); - if (ret < 0) - goto out_free; - - ret = do_eth_dev_ring_create(name, dev, - internal_args->rx_queues, - internal_args->nb_rx_queues, - internal_args->tx_queues, - internal_args->nb_tx_queues, - internal_args->numa_node, - DEV_ATTACH, + return ret; + } + + if (rte_kvargs_count(kvlist, ETH_RING_INTERNAL_ARG) == 1) { + ret = rte_kvargs_process(kvlist, ETH_RING_INTERNAL_ARG, + parse_internal_args, + &internal_args); + if (ret < 0) + goto out_free; + + ret = do_eth_dev_ring_create(name, dev, + internal_args->rx_queues, + internal_args->nb_rx_queues, + internal_args->tx_queues, + internal_args->nb_tx_queues, + internal_args->numa_node, + DEV_ATTACH, + ð_dev); + if (ret >= 0) + ret = 0; + goto out_free; + } + + ret = rte_kvargs_count(kvlist, ETH_RING_NUMA_NODE_ACTION_ARG); + info = rte_zmalloc("struct node_action_list", + sizeof(struct node_action_list) + + (sizeof(struct node_action_pair) * ret), + 0); + if (!info) + goto out_free; + + info->total = ret; + info->list = (struct node_action_pair *)(info + 1); + + 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 >= 0) - ret = 0; - } else { - ret = rte_kvargs_count(kvlist, ETH_RING_NUMA_NODE_ACTION_ARG); - info = rte_zmalloc("struct node_action_list", - sizeof(struct node_action_list) + - (sizeof(struct node_action_pair) * ret), - 0); - if (!info) - goto out_free; - - info->total = ret; - info->list = (struct node_action_pair *)(info + 1); - - 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); - } - } + 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); } } -- 2.26.2