From patchwork Mon Mar 2 17:36:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ferruh Yigit X-Patchwork-Id: 66192 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 24366A056A; Mon, 2 Mar 2020 18:36:54 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5A0071BFF2; Mon, 2 Mar 2020 18:36:53 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id AEB1023D; Mon, 2 Mar 2020 18:36:51 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Mar 2020 09:36:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,507,1574150400"; d="scan'208";a="228535133" Received: from silpixa00399752.ir.intel.com (HELO silpixa00399752.ger.corp.intel.com) ([10.237.222.180]) by orsmga007.jf.intel.com with ESMTP; 02 Mar 2020 09:36:48 -0800 From: Ferruh Yigit To: dev@dpdk.org, Tetsuya Mukawa , Yasufumi Ogawa Cc: Ferruh Yigit , stable@dpdk.org Date: Mon, 2 Mar 2020 17:36:40 +0000 Message-Id: <20200302173646.54984-1-ferruh.yigit@intel.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 1/6] net/null: fix secondary burst function selection 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" Secondary process uses the primary process device and while setting the Rx/Tx functions it uses the device arguments from the secondary process instead of the primary ones. This may cause primary and secondary process use different Rx/Tx functions unintentionally. Fixes: bccc77a6a74a ("net/null: fix multi-process Rx and Tx") Cc: stable@dpdk.org Signed-off-by: Ferruh Yigit --- Cc: yasufum.o@gmail.com --- drivers/net/null/rte_eth_null.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c index 025b73acb..87a29b853 100644 --- a/drivers/net/null/rte_eth_null.c +++ b/drivers/net/null/rte_eth_null.c @@ -584,6 +584,7 @@ rte_pmd_null_probe(struct rte_vdev_device *dev) PMD_LOG(INFO, "Initializing pmd_null for %s", name); if (rte_eal_process_type() == RTE_PROC_SECONDARY) { + struct pmd_internals *internals; eth_dev = rte_eth_dev_attach_secondary(name); if (!eth_dev) { PMD_LOG(ERR, "Failed to probe %s", name); @@ -592,7 +593,8 @@ rte_pmd_null_probe(struct rte_vdev_device *dev) /* TODO: request info from primary to set up Rx and Tx */ eth_dev->dev_ops = &ops; eth_dev->device = &dev->device; - if (packet_copy) { + internals = eth_dev->data->dev_private; + if (internals->packet_copy) { eth_dev->rx_pkt_burst = eth_null_copy_rx; eth_dev->tx_pkt_burst = eth_null_copy_tx; } else { From patchwork Mon Mar 2 17:36:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ferruh Yigit X-Patchwork-Id: 66193 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6D609A056A; Mon, 2 Mar 2020 18:37:02 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D1D681C00D; Mon, 2 Mar 2020 18:36:54 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 08E7C23D for ; Mon, 2 Mar 2020 18:36:52 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Mar 2020 09:36:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,507,1574150400"; d="scan'208";a="228535149" Received: from silpixa00399752.ir.intel.com (HELO silpixa00399752.ger.corp.intel.com) ([10.237.222.180]) by orsmga007.jf.intel.com with ESMTP; 02 Mar 2020 09:36:51 -0800 From: Ferruh Yigit To: dev@dpdk.org, John McNamara , Marko Kovacevic Cc: Ferruh Yigit Date: Mon, 2 Mar 2020 17:36:41 +0000 Message-Id: <20200302173646.54984-2-ferruh.yigit@intel.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200302173646.54984-1-ferruh.yigit@intel.com> References: <20200302173646.54984-1-ferruh.yigit@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 2/6] doc: add net null PMD guide 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" Net null PMD was missing documentation, adding it. Signed-off-by: Ferruh Yigit --- doc/guides/nics/index.rst | 1 + doc/guides/nics/null.rst | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 doc/guides/nics/null.rst diff --git a/doc/guides/nics/index.rst b/doc/guides/nics/index.rst index 6d88028ef..2b78fcfee 100644 --- a/doc/guides/nics/index.rst +++ b/doc/guides/nics/index.rst @@ -46,6 +46,7 @@ Network Interface Controller Drivers netvsc nfb nfp + null octeontx octeontx2 pfe diff --git a/doc/guides/nics/null.rst b/doc/guides/nics/null.rst new file mode 100644 index 000000000..405edf07b --- /dev/null +++ b/doc/guides/nics/null.rst @@ -0,0 +1,39 @@ +.. SPDX-License-Identifier: BSD-3-Clause + Copyright(c) 2020 Intel Corporation. + +NULL Poll Mode Driver +===================== + +NULL PMD is a simple virtual driver mainly for testing. It always returns success for all packets for Rx/Tx. + +On Rx it returns requested number of empty packets (all zero). On Tx it just frees all sent packets. + + +Usage +----- + +.. code-block:: console + + $RTE_TARGET/app/testpmd -l 0-3 -n 4 --vdev net_null0 --vdev net_null1 -- -i + + +Runtime Config Options +---------------------- + +- ``copy`` [optional, default disabled] + + It copies data of the packet before Rx/Tx. For Rx it uses another empty dummy mbuf for this. + +.. code-block:: console + + $RTE_TARGET/app/testpmd -l 0-3 -n 4 --vdev "net_null0,copy=1" -- -i + +- ``size`` [optional, default=64 bytes] + + Custom packet length value to use.r + If ``copy`` is enabled, this is the length of copy operation. + +.. code-block:: console + + $RTE_TARGET/app/testpmd -l 0-3 -n 4 --vdev "net_null0,size=256" -- -i + From patchwork Mon Mar 2 17:36:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ferruh Yigit X-Patchwork-Id: 66194 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4C92FA056A; Mon, 2 Mar 2020 18:37:11 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 27A581C01B; Mon, 2 Mar 2020 18:36:57 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id BE5D41C012; Mon, 2 Mar 2020 18:36:55 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Mar 2020 09:36:55 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,507,1574150400"; d="scan'208";a="228535165" Received: from silpixa00399752.ir.intel.com (HELO silpixa00399752.ger.corp.intel.com) ([10.237.222.180]) by orsmga007.jf.intel.com with ESMTP; 02 Mar 2020 09:36:53 -0800 From: Ferruh Yigit To: dev@dpdk.org, Tetsuya Mukawa , Bernard Iremonger Cc: Ferruh Yigit , stable@dpdk.org, mukawa@igel.co.jp Date: Mon, 2 Mar 2020 17:36:42 +0000 Message-Id: <20200302173646.54984-3-ferruh.yigit@intel.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200302173646.54984-1-ferruh.yigit@intel.com> References: <20200302173646.54984-1-ferruh.yigit@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 3/6] net/null: remove redundant check 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" There is no need to check if the argument exist or not, `rte_kvargs_process` returns success if the argument is not provided at all. Fixes: c743e50c475f ("null: new poll mode driver") Cc: stable@dpdk.org Signed-off-by: Ferruh Yigit --- Cc: mukawa@igel.co.jp --- drivers/net/null/rte_eth_null.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c index 87a29b853..beedd5f4b 100644 --- a/drivers/net/null/rte_eth_null.c +++ b/drivers/net/null/rte_eth_null.c @@ -610,23 +610,18 @@ rte_pmd_null_probe(struct rte_vdev_device *dev) if (kvlist == NULL) return -1; - if (rte_kvargs_count(kvlist, ETH_NULL_PACKET_SIZE_ARG) == 1) { - - ret = rte_kvargs_process(kvlist, - ETH_NULL_PACKET_SIZE_ARG, - &get_packet_size_arg, &packet_size); - if (ret < 0) - goto free_kvlist; - } - - if (rte_kvargs_count(kvlist, ETH_NULL_PACKET_COPY_ARG) == 1) { - - ret = rte_kvargs_process(kvlist, - ETH_NULL_PACKET_COPY_ARG, - &get_packet_copy_arg, &packet_copy); - if (ret < 0) - goto free_kvlist; - } + ret = rte_kvargs_process(kvlist, + ETH_NULL_PACKET_SIZE_ARG, + &get_packet_size_arg, &packet_size); + if (ret < 0) + goto free_kvlist; + + + ret = rte_kvargs_process(kvlist, + ETH_NULL_PACKET_COPY_ARG, + &get_packet_copy_arg, &packet_copy); + if (ret < 0) + goto free_kvlist; } PMD_LOG(INFO, "Configure pmd_null: packet size is %d, " From patchwork Mon Mar 2 17:36:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ferruh Yigit X-Patchwork-Id: 66195 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 428D1A056A; Mon, 2 Mar 2020 18:37:20 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AEB921C02C; Mon, 2 Mar 2020 18:36:59 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id F3D331C022 for ; Mon, 2 Mar 2020 18:36:57 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Mar 2020 09:36:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,507,1574150400"; d="scan'208";a="228535175" Received: from silpixa00399752.ir.intel.com (HELO silpixa00399752.ger.corp.intel.com) ([10.237.222.180]) by orsmga007.jf.intel.com with ESMTP; 02 Mar 2020 09:36:56 -0800 From: Ferruh Yigit To: dev@dpdk.org, Tetsuya Mukawa Cc: Ferruh Yigit Date: Mon, 2 Mar 2020 17:36:43 +0000 Message-Id: <20200302173646.54984-4-ferruh.yigit@intel.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200302173646.54984-1-ferruh.yigit@intel.com> References: <20200302173646.54984-1-ferruh.yigit@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 4/6] net/null: prefer unsigned int 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" Prefer 'unsigned int' storage type keyword against 'unsigned', this also silence the checkpatch warnings. Signed-off-by: Ferruh Yigit --- drivers/net/null/rte_eth_null.c | 46 ++++++++++++++++----------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c index beedd5f4b..7fa3b9e45 100644 --- a/drivers/net/null/rte_eth_null.c +++ b/drivers/net/null/rte_eth_null.c @@ -15,8 +15,8 @@ #define ETH_NULL_PACKET_SIZE_ARG "size" #define ETH_NULL_PACKET_COPY_ARG "copy" -static unsigned default_packet_size = 64; -static unsigned default_packet_copy; +static unsigned int default_packet_size = 64; +static unsigned int default_packet_copy; static const char *valid_arguments[] = { ETH_NULL_PACKET_SIZE_ARG, @@ -37,8 +37,8 @@ struct null_queue { }; struct pmd_internals { - unsigned packet_size; - unsigned packet_copy; + unsigned int packet_size; + unsigned int packet_copy; uint16_t port_id; struct null_queue rx_null_queues[RTE_MAX_QUEUES_PER_PORT]; @@ -74,7 +74,7 @@ eth_null_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) { int i; struct null_queue *h = q; - unsigned packet_size; + unsigned int packet_size; if ((q == NULL) || (bufs == NULL)) return 0; @@ -99,7 +99,7 @@ eth_null_copy_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) { int i; struct null_queue *h = q; - unsigned packet_size; + unsigned int packet_size; if ((q == NULL) || (bufs == NULL)) return 0; @@ -143,7 +143,7 @@ eth_null_copy_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) { int i; struct null_queue *h = q; - unsigned packet_size; + unsigned int packet_size; if ((q == NULL) || (bufs == NULL)) return 0; @@ -194,7 +194,7 @@ eth_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id, { struct rte_mbuf *dummy_packet; struct pmd_internals *internals; - unsigned packet_size; + unsigned int packet_size; if ((dev == NULL) || (mb_pool == NULL)) return -EINVAL; @@ -228,7 +228,7 @@ eth_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id, { struct rte_mbuf *dummy_packet; struct pmd_internals *internals; - unsigned packet_size; + unsigned int packet_size; if (dev == NULL) return -EINVAL; @@ -283,7 +283,7 @@ eth_dev_info(struct rte_eth_dev *dev, static int eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *igb_stats) { - unsigned i, num_stats; + unsigned int i, num_stats; unsigned long rx_total = 0, tx_total = 0; const struct pmd_internals *internal; @@ -291,7 +291,7 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *igb_stats) return -EINVAL; internal = dev->data->dev_private; - num_stats = RTE_MIN((unsigned)RTE_ETHDEV_QUEUE_STAT_CNTRS, + num_stats = RTE_MIN((unsigned int)RTE_ETHDEV_QUEUE_STAT_CNTRS, RTE_MIN(dev->data->nb_rx_queues, RTE_DIM(internal->rx_null_queues))); for (i = 0; i < num_stats; i++) { @@ -300,7 +300,7 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *igb_stats) rx_total += igb_stats->q_ipackets[i]; } - num_stats = RTE_MIN((unsigned)RTE_ETHDEV_QUEUE_STAT_CNTRS, + num_stats = RTE_MIN((unsigned int)RTE_ETHDEV_QUEUE_STAT_CNTRS, RTE_MIN(dev->data->nb_tx_queues, RTE_DIM(internal->tx_null_queues))); for (i = 0; i < num_stats; i++) { @@ -318,7 +318,7 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *igb_stats) static int eth_stats_reset(struct rte_eth_dev *dev) { - unsigned i; + unsigned int i; struct pmd_internals *internal; if (dev == NULL) @@ -463,11 +463,11 @@ static const struct eth_dev_ops ops = { static int eth_dev_null_create(struct rte_vdev_device *dev, - unsigned packet_size, - unsigned packet_copy) + unsigned int packet_size, + unsigned int packet_copy) { - const unsigned nb_rx_queues = 1; - const unsigned nb_tx_queues = 1; + const unsigned int nb_rx_queues = 1; + const unsigned int nb_tx_queues = 1; struct rte_eth_dev_data *data; struct pmd_internals *internals = NULL; struct rte_eth_dev *eth_dev = NULL; @@ -537,12 +537,12 @@ get_packet_size_arg(const char *key __rte_unused, const char *value, void *extra_args) { const char *a = value; - unsigned *packet_size = extra_args; + unsigned int *packet_size = extra_args; if ((value == NULL) || (extra_args == NULL)) return -EINVAL; - *packet_size = (unsigned)strtoul(a, NULL, 0); + *packet_size = (unsigned int)strtoul(a, NULL, 0); if (*packet_size == UINT_MAX) return -1; @@ -554,12 +554,12 @@ get_packet_copy_arg(const char *key __rte_unused, const char *value, void *extra_args) { const char *a = value; - unsigned *packet_copy = extra_args; + unsigned int *packet_copy = extra_args; if ((value == NULL) || (extra_args == NULL)) return -EINVAL; - *packet_copy = (unsigned)strtoul(a, NULL, 0); + *packet_copy = (unsigned int)strtoul(a, NULL, 0); if (*packet_copy == UINT_MAX) return -1; @@ -570,8 +570,8 @@ static int rte_pmd_null_probe(struct rte_vdev_device *dev) { const char *name, *params; - unsigned packet_size = default_packet_size; - unsigned packet_copy = default_packet_copy; + unsigned int packet_size = default_packet_size; + unsigned int packet_copy = default_packet_copy; struct rte_kvargs *kvlist = NULL; struct rte_eth_dev *eth_dev; int ret; From patchwork Mon Mar 2 17:36:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ferruh Yigit X-Patchwork-Id: 66196 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 41DF3A056A; Mon, 2 Mar 2020 18:37:29 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2BF7B1C001; Mon, 2 Mar 2020 18:37:02 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 33DEB1C022 for ; Mon, 2 Mar 2020 18:37:00 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Mar 2020 09:36:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,507,1574150400"; d="scan'208";a="228535181" Received: from silpixa00399752.ir.intel.com (HELO silpixa00399752.ger.corp.intel.com) ([10.237.222.180]) by orsmga007.jf.intel.com with ESMTP; 02 Mar 2020 09:36:58 -0800 From: Ferruh Yigit To: dev@dpdk.org, Tetsuya Mukawa Cc: Ferruh Yigit Date: Mon, 2 Mar 2020 17:36:44 +0000 Message-Id: <20200302173646.54984-5-ferruh.yigit@intel.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200302173646.54984-1-ferruh.yigit@intel.com> References: <20200302173646.54984-1-ferruh.yigit@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 5/6] net/null: group device arguments 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" Group device argument to the struct, to increase code readability. Signed-off-by: Ferruh Yigit --- drivers/net/null/rte_eth_null.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c index 7fa3b9e45..2c08ebf8c 100644 --- a/drivers/net/null/rte_eth_null.c +++ b/drivers/net/null/rte_eth_null.c @@ -36,6 +36,11 @@ struct null_queue { rte_atomic64_t tx_pkts; }; +struct pmd_options { + unsigned int packet_copy; + unsigned int packet_size; +}; + struct pmd_internals { unsigned int packet_size; unsigned int packet_copy; @@ -462,9 +467,7 @@ static const struct eth_dev_ops ops = { }; static int -eth_dev_null_create(struct rte_vdev_device *dev, - unsigned int packet_size, - unsigned int packet_copy) +eth_dev_null_create(struct rte_vdev_device *dev, struct pmd_options *args) { const unsigned int nb_rx_queues = 1; const unsigned int nb_tx_queues = 1; @@ -499,8 +502,8 @@ eth_dev_null_create(struct rte_vdev_device *dev, * so the nulls are local per-process */ internals = eth_dev->data->dev_private; - internals->packet_size = packet_size; - internals->packet_copy = packet_copy; + internals->packet_size = args->packet_size; + internals->packet_copy = args->packet_copy; internals->port_id = eth_dev->data->port_id; rte_eth_random_addr(internals->eth_addr.addr_bytes); @@ -520,7 +523,7 @@ eth_dev_null_create(struct rte_vdev_device *dev, eth_dev->dev_ops = &ops; /* finally assign rx and tx ops */ - if (packet_copy) { + if (internals->packet_copy) { eth_dev->rx_pkt_burst = eth_null_copy_rx; eth_dev->tx_pkt_burst = eth_null_copy_tx; } else { @@ -570,8 +573,10 @@ static int rte_pmd_null_probe(struct rte_vdev_device *dev) { const char *name, *params; - unsigned int packet_size = default_packet_size; - unsigned int packet_copy = default_packet_copy; + struct pmd_options args = { + .packet_copy = default_packet_copy, + .packet_size = default_packet_size, + }; struct rte_kvargs *kvlist = NULL; struct rte_eth_dev *eth_dev; int ret; @@ -612,23 +617,23 @@ rte_pmd_null_probe(struct rte_vdev_device *dev) ret = rte_kvargs_process(kvlist, ETH_NULL_PACKET_SIZE_ARG, - &get_packet_size_arg, &packet_size); + &get_packet_size_arg, &args.packet_size); if (ret < 0) goto free_kvlist; ret = rte_kvargs_process(kvlist, ETH_NULL_PACKET_COPY_ARG, - &get_packet_copy_arg, &packet_copy); + &get_packet_copy_arg, &args.packet_copy); if (ret < 0) goto free_kvlist; } PMD_LOG(INFO, "Configure pmd_null: packet size is %d, " - "packet copy is %s", packet_size, - packet_copy ? "enabled" : "disabled"); + "packet copy is %s", args.packet_size, + args.packet_copy ? "enabled" : "disabled"); - ret = eth_dev_null_create(dev, packet_size, packet_copy); + ret = eth_dev_null_create(dev, &args); free_kvlist: if (kvlist) From patchwork Mon Mar 2 17:36:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ferruh Yigit X-Patchwork-Id: 66197 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9D1A5A056A; Mon, 2 Mar 2020 18:37:40 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E9CFE1C002; Mon, 2 Mar 2020 18:37:04 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id E0A9F1C044 for ; Mon, 2 Mar 2020 18:37:02 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Mar 2020 09:37:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,507,1574150400"; d="scan'208";a="228535194" Received: from silpixa00399752.ir.intel.com (HELO silpixa00399752.ger.corp.intel.com) ([10.237.222.180]) by orsmga007.jf.intel.com with ESMTP; 02 Mar 2020 09:37:00 -0800 From: Ferruh Yigit To: dev@dpdk.org, John McNamara , Marko Kovacevic , Tetsuya Mukawa Cc: Ferruh Yigit Date: Mon, 2 Mar 2020 17:36:45 +0000 Message-Id: <20200302173646.54984-6-ferruh.yigit@intel.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200302173646.54984-1-ferruh.yigit@intel.com> References: <20200302173646.54984-1-ferruh.yigit@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 6/6] net/null: add argument for no Rx 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 an new device argument 'no-rx', which will prevent PMD receiving packets. This is useful for testing when a PMD is needed only to send packets to. Signed-off-by: Ferruh Yigit --- doc/guides/nics/null.rst | 4 +++ drivers/net/null/rte_eth_null.c | 55 ++++++++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/doc/guides/nics/null.rst b/doc/guides/nics/null.rst index 405edf07b..c68d0d605 100644 --- a/doc/guides/nics/null.rst +++ b/doc/guides/nics/null.rst @@ -37,3 +37,7 @@ Runtime Config Options $RTE_TARGET/app/testpmd -l 0-3 -n 4 --vdev "net_null0,size=256" -- -i +- ``no-rx`` [optional, default disabled] + + Makes PMD more like ``/dev/null``. On Rx no packets received, on Tx all packets are freed. + This option can't co-exist with ``copy`` option. diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c index 2c08ebf8c..11258ccea 100644 --- a/drivers/net/null/rte_eth_null.c +++ b/drivers/net/null/rte_eth_null.c @@ -14,13 +14,16 @@ #define ETH_NULL_PACKET_SIZE_ARG "size" #define ETH_NULL_PACKET_COPY_ARG "copy" +#define ETH_NULL_PACKET_NO_RX_ARG "no-rx" static unsigned int default_packet_size = 64; static unsigned int default_packet_copy; +static unsigned int default_no_rx; static const char *valid_arguments[] = { ETH_NULL_PACKET_SIZE_ARG, ETH_NULL_PACKET_COPY_ARG, + ETH_NULL_PACKET_NO_RX_ARG, NULL }; @@ -39,11 +42,13 @@ struct null_queue { struct pmd_options { unsigned int packet_copy; unsigned int packet_size; + unsigned int no_rx; }; struct pmd_internals { unsigned int packet_size; unsigned int packet_copy; + unsigned int no_rx; uint16_t port_id; struct null_queue rx_null_queues[RTE_MAX_QUEUES_PER_PORT]; @@ -126,6 +131,13 @@ eth_null_copy_rx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) return i; } +static uint16_t +eth_null_no_rx(void *q __rte_unused, struct rte_mbuf **bufs __rte_unused, + uint16_t nb_bufs __rte_unused) +{ + return 0; +} + static uint16_t eth_null_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs) { @@ -504,6 +516,7 @@ eth_dev_null_create(struct rte_vdev_device *dev, struct pmd_options *args) internals = eth_dev->data->dev_private; internals->packet_size = args->packet_size; internals->packet_copy = args->packet_copy; + internals->no_rx = args->no_rx; internals->port_id = eth_dev->data->port_id; rte_eth_random_addr(internals->eth_addr.addr_bytes); @@ -526,6 +539,9 @@ eth_dev_null_create(struct rte_vdev_device *dev, struct pmd_options *args) if (internals->packet_copy) { eth_dev->rx_pkt_burst = eth_null_copy_rx; eth_dev->tx_pkt_burst = eth_null_copy_tx; + } else if (internals->no_rx) { + eth_dev->rx_pkt_burst = eth_null_no_rx; + eth_dev->tx_pkt_burst = eth_null_tx; } else { eth_dev->rx_pkt_burst = eth_null_rx; eth_dev->tx_pkt_burst = eth_null_tx; @@ -569,6 +585,24 @@ get_packet_copy_arg(const char *key __rte_unused, return 0; } +static int +get_packet_no_rx_arg(const char *key __rte_unused, + const char *value, void *extra_args) +{ + const char *a = value; + unsigned int no_rx; + + if (value == NULL || extra_args == NULL) + return -EINVAL; + + no_rx = (unsigned int)strtoul(a, NULL, 0); + if (no_rx != 0 && no_rx != 1) + return -1; + + *(unsigned int *)extra_args = no_rx; + return 0; +} + static int rte_pmd_null_probe(struct rte_vdev_device *dev) { @@ -576,6 +610,7 @@ rte_pmd_null_probe(struct rte_vdev_device *dev) struct pmd_options args = { .packet_copy = default_packet_copy, .packet_size = default_packet_size, + .no_rx = default_no_rx, }; struct rte_kvargs *kvlist = NULL; struct rte_eth_dev *eth_dev; @@ -602,6 +637,9 @@ rte_pmd_null_probe(struct rte_vdev_device *dev) if (internals->packet_copy) { eth_dev->rx_pkt_burst = eth_null_copy_rx; eth_dev->tx_pkt_burst = eth_null_copy_tx; + } else if (internals->no_rx) { + eth_dev->rx_pkt_burst = eth_null_no_rx; + eth_dev->tx_pkt_burst = eth_null_tx; } else { eth_dev->rx_pkt_burst = eth_null_rx; eth_dev->tx_pkt_burst = eth_null_tx; @@ -627,6 +665,20 @@ rte_pmd_null_probe(struct rte_vdev_device *dev) &get_packet_copy_arg, &args.packet_copy); if (ret < 0) goto free_kvlist; + + ret = rte_kvargs_process(kvlist, + ETH_NULL_PACKET_NO_RX_ARG, + &get_packet_no_rx_arg, &args.no_rx); + if (ret < 0) + goto free_kvlist; + + if (args.no_rx && args.packet_copy) { + PMD_LOG(ERR, + "Both %s and %s arguments at the same time not supported", + ETH_NULL_PACKET_COPY_ARG, + ETH_NULL_PACKET_NO_RX_ARG); + goto free_kvlist; + } } PMD_LOG(INFO, "Configure pmd_null: packet size is %d, " @@ -675,7 +727,8 @@ RTE_PMD_REGISTER_VDEV(net_null, pmd_null_drv); RTE_PMD_REGISTER_ALIAS(net_null, eth_null); RTE_PMD_REGISTER_PARAM_STRING(net_null, "size= " - "copy="); + "copy= " + ETH_NULL_PACKET_NO_RX_ARG "=0|1"); RTE_INIT(eth_null_init_log) {