DPDK patches and discussions
 help / color / mirror / Atom feed
From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, Long Wu <long.wu@corigine.com>,
	Chaoyong He <chaoyong.he@corigine.com>,
	Peng Zhang <peng.zhang@corigine.com>
Subject: [PATCH 2/4] net/nfp: add interface to check representor
Date: Sat, 10 Feb 2024 18:42:11 +0800	[thread overview]
Message-ID: <20240210104214.1248772-3-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20240210104214.1248772-1-chaoyong.he@corigine.com>

From: Long Wu <long.wu@corigine.com>

Add a interface to check if a device is a representor.

Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/net/nfp/flower/nfp_flower_flow.c |  2 +-
 drivers/net/nfp/nfp_mtr.c                |  2 +-
 drivers/net/nfp/nfp_net_common.c         | 10 ++++++++--
 drivers/net/nfp/nfp_net_common.h         |  1 +
 4 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index 8667f8e901..07833fdbdb 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -4348,7 +4348,7 @@ int
 nfp_flow_ops_get(struct rte_eth_dev *dev,
 		const struct rte_flow_ops **ops)
 {
-	if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) == 0) {
+	if (!nfp_net_dev_is_repr(dev)) {
 		*ops = NULL;
 		PMD_DRV_LOG(ERR, "Port is not a representor.");
 		return -EINVAL;
diff --git a/drivers/net/nfp/nfp_mtr.c b/drivers/net/nfp/nfp_mtr.c
index 255977ec22..11da5c07ed 100644
--- a/drivers/net/nfp/nfp_mtr.c
+++ b/drivers/net/nfp/nfp_mtr.c
@@ -1066,7 +1066,7 @@ static const struct rte_mtr_ops nfp_mtr_ops = {
 int
 nfp_net_mtr_ops_get(struct rte_eth_dev *dev, void *arg)
 {
-	if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) == 0) {
+	if (!nfp_net_dev_is_repr(dev)) {
 		PMD_DRV_LOG(ERR, "Port is not a representor");
 		return -EINVAL;
 	}
diff --git a/drivers/net/nfp/nfp_net_common.c b/drivers/net/nfp/nfp_net_common.c
index 72c9a41b00..7a0b0c9973 100644
--- a/drivers/net/nfp/nfp_net_common.c
+++ b/drivers/net/nfp/nfp_net_common.c
@@ -156,6 +156,12 @@ static const uint32_t nfp_net_link_speed_nfp2rte[] = {
 	[NFP_NET_CFG_STS_LINK_RATE_100G]        = RTE_ETH_SPEED_NUM_100G,
 };
 
+bool
+nfp_net_dev_is_repr(const struct rte_eth_dev *eth_dev)
+{
+	return ((eth_dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0);
+}
+
 static uint16_t
 nfp_net_link_speed_rte2nfp(uint16_t speed)
 {
@@ -241,7 +247,7 @@ nfp_net_get_hw(const struct rte_eth_dev *dev)
 {
 	struct nfp_net_hw *hw;
 
-	if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0) {
+	if (nfp_net_dev_is_repr(dev)) {
 		struct nfp_flower_representor *repr;
 		repr = dev->data->dev_private;
 		hw = repr->app_fw_flower->pf_hw;
@@ -2139,7 +2145,7 @@ nfp_net_firmware_version_get(struct rte_eth_dev *dev,
 
 	hw = nfp_net_get_hw(dev);
 
-	if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0) {
+	if (nfp_net_dev_is_repr(dev)) {
 		snprintf(vnic_version, FW_VER_LEN, "%d.%d.%d.%d",
 			hw->ver.extend, hw->ver.class,
 			hw->ver.major, hw->ver.minor);
diff --git a/drivers/net/nfp/nfp_net_common.h b/drivers/net/nfp/nfp_net_common.h
index e374739022..1d96b0e9d1 100644
--- a/drivers/net/nfp/nfp_net_common.h
+++ b/drivers/net/nfp/nfp_net_common.h
@@ -307,6 +307,7 @@ int nfp_net_fec_get(struct rte_eth_dev *dev,
 		uint32_t *fec_capa);
 int nfp_net_fec_set(struct rte_eth_dev *dev,
 		uint32_t fec_capa);
+bool nfp_net_dev_is_repr(const struct rte_eth_dev *eth_dev);
 
 #define NFP_PRIV_TO_APP_FW_NIC(app_fw_priv)\
 	((struct nfp_app_fw_nic *)app_fw_priv)
-- 
2.39.1


  parent reply	other threads:[~2024-02-10 10:42 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-10 10:42 [PATCH 0/4] add support of partial offload Chaoyong He
2024-02-10 10:42 ` [PATCH 1/4] net/nfp: support MARK flow action Chaoyong He
2024-02-10 10:42 ` Chaoyong He [this message]
2024-02-12 16:24   ` [PATCH 2/4] net/nfp: add interface to check representor Ferruh Yigit
2024-02-17  1:31     ` Chaoyong He
2024-02-10 10:42 ` [PATCH 3/4] net/nfp: representor adds RSS configuration Chaoyong He
2024-02-10 10:42 ` [PATCH 4/4] net/nfp: support RSS flow action Chaoyong He
2024-02-12 10:10 ` [PATCH 0/4] add support of partial offload David Marchand
2024-02-17  1:31   ` Chaoyong He
2024-02-23  2:42 ` [PATCH v2 0/4] add support of MARK and RSS flow action Chaoyong He
2024-02-23  2:42   ` [PATCH v2 1/4] ethdev: add function to check representor port Chaoyong He
2024-02-23  9:29     ` Ferruh Yigit
2024-02-23  2:42   ` [PATCH v2 2/4] net/nfp: support MARK flow action Chaoyong He
2024-02-23  2:42   ` [PATCH v2 3/4] net/nfp: add representor RSS configuration Chaoyong He
2024-02-23  2:42   ` [PATCH v2 4/4] net/nfp: support RSS flow action Chaoyong He
2024-02-26  1:44   ` [PATCH v3 0/4] add support of MARK and " Chaoyong He
2024-02-26  1:44     ` [PATCH v3 1/4] ethdev: add function to check representor port Chaoyong He
2024-02-26 14:31       ` Ferruh Yigit
2024-02-26  1:44     ` [PATCH v3 2/4] net/nfp: support MARK flow action Chaoyong He
2024-02-26  1:44     ` [PATCH v3 3/4] net/nfp: add representor RSS configuration Chaoyong He
2024-02-26  1:45     ` [PATCH v3 4/4] net/nfp: support RSS flow action Chaoyong He
2024-02-26 14:31     ` [PATCH v3 0/4] add support of MARK and " 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=20240210104214.1248772-3-chaoyong.he@corigine.com \
    --to=chaoyong.he@corigine.com \
    --cc=dev@dpdk.org \
    --cc=long.wu@corigine.com \
    --cc=oss-drivers@corigine.com \
    --cc=peng.zhang@corigine.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).