[2/4] net/nfp: add interface to check representor

Message ID 20240210104214.1248772-3-chaoyong.he@corigine.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series add support of partial offload |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Chaoyong He Feb. 10, 2024, 10:42 a.m. UTC
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(-)
  

Comments

Ferruh Yigit Feb. 12, 2024, 4:24 p.m. UTC | #1
On 2/10/2024 10:42 AM, Chaoyong He wrote:
> 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>

<...>

> @@ -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);
> +}
> +
>

There is similar need for other drivers too,
can you please add this as API for drivers (ethdev_driver.h), update
existing usage in other drivers, and use it in your driver?
  
Chaoyong He Feb. 17, 2024, 1:31 a.m. UTC | #2
> On 2/10/2024 10:42 AM, Chaoyong He wrote:
> > 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>
> 
> <...>
> 
> > @@ -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);
> > +}
> > +
> >
> 
> There is similar need for other drivers too,
> can you please add this as API for drivers (ethdev_driver.h), update
> existing usage in other drivers, and use it in your driver?

Okay, will do in next version patch, thanks.
  

Patch

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)