From: "Wei Hu (Xavier)" <huwei013@chinasoftinc.com>
To: <dev@dpdk.org>, <stephen@networkplumber.org>,
<ferruh.yigit@intel.com>, <kalesh-anakkur.purayil@broadcom.com>,
<andrew.rybchenko@oktetlabs.ru>
Cc: <xavier.huwei@huawei.com>
Subject: [dpdk-dev] [PATCH v5 1/3] ethdev: extract checking queue id into common functions
Date: Tue, 13 Oct 2020 19:50:53 +0800 [thread overview]
Message-ID: <20201013115055.34295-2-huwei013@chinasoftinc.com> (raw)
In-Reply-To: <20201013115055.34295-1-huwei013@chinasoftinc.com>
From: "Wei Hu (Xavier)" <xavier.huwei@huawei.com>
This patch extact checking rx_queue_id or tx_queue_id into two separate
common functions named eth_dev_validate_rx_queue and
eth_dev_validate_tx_queue.
Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
---
v4 -> v5:
1. remove inline.
2. add 'const' to dev to highlight that it changes nothing.
3. RX -> Rx, TX -> Tx.
4. log port ID in the error branch.
5. 'if (ret)' -> 'if (ret != 0)'
6. split the original patch into three separate patches.
v3 -> v4:
1. dropping the 'rte_' prefix from the funcitons names.
2. get "struct rte_eth_dev *dev" as parameter and drop the port_id
validation in the function named eth_dev_validate_rx_queue and
eth_dev_validate_tx_queue.
3. replace "setupped" with "setup" in the commit log and titile.
v2 -> v3:
don't break lines in format strings.
v1 -> v2:
1. replace %"PRIu16" with %u.
2. extact two common functions which validate RXQ/TXQ ids and
whether it has been set up or not.
---
lib/librte_ethdev/rte_ethdev.c | 66 ++++++++++++++++++++++++++++++++----------
1 file changed, 50 insertions(+), 16 deletions(-)
diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index 892c246..11e54d9 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -877,10 +877,43 @@ rte_eth_dev_rx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues)
return 0;
}
+static int
+eth_dev_validate_rx_queue(const struct rte_eth_dev *dev, uint16_t rx_queue_id)
+{
+ uint16_t port_id;
+
+ if (rx_queue_id >= dev->data->nb_rx_queues) {
+ port_id = dev->data->port_id;
+ RTE_ETHDEV_LOG(ERR,
+ "Invalid Rx queue_id=%u of device with port_id=%u\n",
+ rx_queue_id, port_id);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int
+eth_dev_validate_tx_queue(const struct rte_eth_dev *dev, uint16_t tx_queue_id)
+{
+ uint16_t port_id;
+
+ if (tx_queue_id >= dev->data->nb_tx_queues) {
+ port_id = dev->data->port_id;
+ RTE_ETHDEV_LOG(ERR,
+ "Invalid Tx queue_id=%u of device with port_id=%u\n",
+ tx_queue_id, port_id);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
int
rte_eth_dev_rx_queue_start(uint16_t port_id, uint16_t rx_queue_id)
{
struct rte_eth_dev *dev;
+ int ret;
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
@@ -892,10 +925,9 @@ rte_eth_dev_rx_queue_start(uint16_t port_id, uint16_t rx_queue_id)
return -EINVAL;
}
- if (rx_queue_id >= dev->data->nb_rx_queues) {
- RTE_ETHDEV_LOG(ERR, "Invalid RX queue_id=%u\n", rx_queue_id);
- return -EINVAL;
- }
+ ret = eth_dev_validate_rx_queue(dev, rx_queue_id);
+ if (ret != 0)
+ return ret;
RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_start, -ENOTSUP);
@@ -922,14 +954,15 @@ int
rte_eth_dev_rx_queue_stop(uint16_t port_id, uint16_t rx_queue_id)
{
struct rte_eth_dev *dev;
+ int ret;
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
dev = &rte_eth_devices[port_id];
- if (rx_queue_id >= dev->data->nb_rx_queues) {
- RTE_ETHDEV_LOG(ERR, "Invalid RX queue_id=%u\n", rx_queue_id);
- return -EINVAL;
- }
+
+ ret = eth_dev_validate_rx_queue(dev, rx_queue_id);
+ if (ret != 0)
+ return ret;
RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_stop, -ENOTSUP);
@@ -955,6 +988,7 @@ int
rte_eth_dev_tx_queue_start(uint16_t port_id, uint16_t tx_queue_id)
{
struct rte_eth_dev *dev;
+ int ret;
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
@@ -966,10 +1000,9 @@ rte_eth_dev_tx_queue_start(uint16_t port_id, uint16_t tx_queue_id)
return -EINVAL;
}
- if (tx_queue_id >= dev->data->nb_tx_queues) {
- RTE_ETHDEV_LOG(ERR, "Invalid TX queue_id=%u\n", tx_queue_id);
- return -EINVAL;
- }
+ ret = eth_dev_validate_tx_queue(dev, tx_queue_id);
+ if (ret != 0)
+ return ret;
RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_start, -ENOTSUP);
@@ -994,14 +1027,15 @@ int
rte_eth_dev_tx_queue_stop(uint16_t port_id, uint16_t tx_queue_id)
{
struct rte_eth_dev *dev;
+ int ret;
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
dev = &rte_eth_devices[port_id];
- if (tx_queue_id >= dev->data->nb_tx_queues) {
- RTE_ETHDEV_LOG(ERR, "Invalid TX queue_id=%u\n", tx_queue_id);
- return -EINVAL;
- }
+
+ ret = eth_dev_validate_tx_queue(dev, tx_queue_id);
+ if (ret != 0)
+ return ret;
RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_queue_stop, -ENOTSUP);
--
2.9.5
next prev parent reply other threads:[~2020-10-13 11:51 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-10 7:12 [dpdk-dev] [PATCH] ethdev: check if queue setupped in queue-related APIs Wei Hu (Xavier)
2020-10-10 15:24 ` Stephen Hemminger
2020-10-12 3:21 ` Wei Hu (Xavier)
2020-10-10 16:38 ` Kalesh Anakkur Purayil
2020-10-12 3:22 ` Wei Hu (Xavier)
2020-10-12 3:19 ` [dpdk-dev] [PATCH v2] " Wei Hu (Xavier)
2020-10-12 6:29 ` Stephen Hemminger
2020-10-12 7:32 ` [dpdk-dev] [PATCH v3] " Wei Hu (Xavier)
2020-10-12 15:12 ` Ferruh Yigit
2020-10-12 15:15 ` Stephen Hemminger
2020-10-13 2:41 ` [dpdk-dev] [PATCH v4] ethdev: check if queue setup " Wei Hu (Xavier)
2020-10-13 4:28 ` Kalesh Anakkur Purayil
2020-10-13 8:08 ` Andrew Rybchenko
2020-10-13 11:50 ` [dpdk-dev] [PATCH v5 0/3] check queue id " Wei Hu (Xavier)
2020-10-13 11:50 ` Wei Hu (Xavier) [this message]
2020-10-13 12:49 ` [dpdk-dev] [PATCH v5 1/3] ethdev: extract checking queue id into common functions Andrew Rybchenko
2020-10-13 11:50 ` [dpdk-dev] [PATCH v5 2/3] ethdev: check if queue setup in queue-related APIs Wei Hu (Xavier)
2020-10-13 11:50 ` [dpdk-dev] [PATCH v5 3/3] ethdev: check queue id in Rx interrupt control routine Wei Hu (Xavier)
2020-10-13 13:17 ` [dpdk-dev] [PATCH v5 0/3] check queue id in queue-related APIs Ferruh Yigit
2020-10-13 14:13 ` Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201013115055.34295-2-huwei013@chinasoftinc.com \
--to=huwei013@chinasoftinc.com \
--cc=andrew.rybchenko@oktetlabs.ru \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
--cc=kalesh-anakkur.purayil@broadcom.com \
--cc=stephen@networkplumber.org \
--cc=xavier.huwei@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).