Skip to content

Commit

Permalink
net/nfp: fix VF link speed problem
Browse files Browse the repository at this point in the history
The previous logic does not update the 'rte_eth_device' link status
when the port link status changed, which cause the firmware won't be
notified by the PMD.
Furthermore, the physical representor port should also notify firmware
its current speed with multi-pf firmware.

Fix these problems by modify the related logic, also add needed helper
function at the same time.

Fixes: eae7dad ("net/nfp: update link status reporting")
Cc: stable@dpdk.org

Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
  • Loading branch information
wulong2022 authored and shemminger committed Dec 19, 2024
1 parent 6dae1df commit 94ad302
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
14 changes: 14 additions & 0 deletions drivers/net/nfp/flower/nfp_flower_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,8 @@ nfp_flower_cmsg_port_mod_rx(struct nfp_net_hw_priv *hw_priv,
{
uint32_t port;
uint32_t index;
uint16_t link_status;
struct rte_eth_dev *eth_dev;
struct nfp_flower_representor *repr;
struct nfp_flower_cmsg_port_mod *msg;
struct nfp_app_fw_flower *app_fw_flower;
Expand Down Expand Up @@ -456,11 +458,23 @@ nfp_flower_cmsg_port_mod_rx(struct nfp_net_hw_priv *hw_priv,
}

repr->link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX;

link_status = repr->link.link_status;
if ((msg->info & NFP_FLOWER_CMSG_PORT_MOD_INFO_LINK) != 0)
repr->link.link_status = RTE_ETH_LINK_UP;
else
repr->link.link_status = RTE_ETH_LINK_DOWN;

if (link_status != repr->link.link_status) {
eth_dev = rte_eth_dev_get_by_name(repr->name);
if (eth_dev == NULL) {
PMD_DRV_LOG(ERR, "Can not get 'eth_dev' by name %s.", repr->name);
return -EINVAL;
}

nfp_flower_repr_link_update(eth_dev, 0);
}

return 0;
}

Expand Down
19 changes: 17 additions & 2 deletions drivers/net/nfp/flower/nfp_flower_representor.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,21 @@ struct nfp_repr_init {
struct nfp_net_hw_priv *hw_priv;
};

bool
nfp_flower_repr_is_pf(struct rte_eth_dev *dev)
{
struct nfp_net_hw_priv *hw_priv;
struct nfp_flower_representor *repr;

hw_priv = dev->process_private;
repr = dev->data->dev_private;

if (hw_priv->pf_dev->multi_pf.enabled)
return repr->repr_type == NFP_REPR_TYPE_PHYS_PORT;
else
return repr->repr_type == NFP_REPR_TYPE_PF;
}

static int
nfp_repr_get_eeprom_len(struct rte_eth_dev *dev)
{
Expand Down Expand Up @@ -112,7 +127,7 @@ nfp_flower_repr_led_off(struct rte_eth_dev *dev)
return nfp_net_led_off(dev);
}

static int
int
nfp_flower_repr_link_update(struct rte_eth_dev *dev,
__rte_unused int wait_to_complete)
{
Expand All @@ -125,7 +140,7 @@ nfp_flower_repr_link_update(struct rte_eth_dev *dev,

ret = nfp_net_link_update_common(dev, link, link->link_status);

if (repr->repr_type == NFP_REPR_TYPE_PF)
if (nfp_flower_repr_is_pf(dev))
nfp_net_notify_port_speed(repr->app_fw_flower->pf_hw, link);

return ret;
Expand Down
3 changes: 3 additions & 0 deletions drivers/net/nfp/flower/nfp_flower_representor.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,8 @@ int nfp_flower_repr_create(struct nfp_app_fw_flower *app_fw_flower,
bool nfp_flower_repr_is_vf(struct nfp_flower_representor *repr);
bool nfp_flower_repr_is_phy(struct nfp_flower_representor *repr);
int nfp_flower_repr_stats_reset(struct rte_eth_dev *ethdev);
int nfp_flower_repr_link_update(struct rte_eth_dev *dev,
__rte_unused int wait_to_complete);
bool nfp_flower_repr_is_pf(struct rte_eth_dev *dev);

#endif /* __NFP_FLOWER_REPRESENTOR_H__ */
11 changes: 10 additions & 1 deletion drivers/net/nfp/nfp_net_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,15 @@ static const uint32_t nfp_net_link_speed_nfp2rte[] = {
[NFP_NET_CFG_STS_LINK_RATE_100G] = RTE_ETH_SPEED_NUM_100G,
};

static bool
nfp_net_is_pf(struct rte_eth_dev *dev)
{
if (rte_eth_dev_is_repr(dev))
return nfp_flower_repr_is_pf(dev);

return ((struct nfp_net_hw_priv *)dev->process_private)->is_pf;
}

static size_t
nfp_net_link_speed_rte2nfp(uint32_t speed)
{
Expand Down Expand Up @@ -826,7 +835,7 @@ nfp_net_link_update_common(struct rte_eth_dev *dev,

hw_priv = dev->process_private;
if (link->link_status == RTE_ETH_LINK_UP) {
if (hw_priv->is_pf)
if (nfp_net_is_pf(dev))
nfp_net_pf_speed_update(dev, hw_priv, link);
else
nfp_net_vf_speed_update(link, link_status);
Expand Down

0 comments on commit 94ad302

Please sign in to comment.