[2/4] net/nfp: add interface to check representor
Checks
Commit Message
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
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?
> 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.
@@ -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;
@@ -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;
}
@@ -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);
@@ -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)