From 2c809af8a83a4be0fb2af626a6178b9cd8069c3e Mon Sep 17 00:00:00 2001 From: Harman Kalra Date: Fri, 30 Jul 2021 21:38:29 +0530 Subject: [PATCH] net/cnxk: add callback to get link status Adding a new callback for reading the link status. PF can read its link status and can forward the same to VF once it comes up. Signed-off-by: Harman Kalra Acked-by: Jerin Jacob --- drivers/net/cnxk/cnxk_ethdev.c | 9 +++++++++ drivers/net/cnxk/cnxk_ethdev.h | 2 ++ drivers/net/cnxk/cnxk_link.c | 23 +++++++++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/drivers/net/cnxk/cnxk_ethdev.c b/drivers/net/cnxk/cnxk_ethdev.c index 0e3652ed51..7152dcd002 100644 --- a/drivers/net/cnxk/cnxk_ethdev.c +++ b/drivers/net/cnxk/cnxk_ethdev.c @@ -1314,6 +1314,10 @@ cnxk_eth_dev_init(struct rte_eth_dev *eth_dev) /* Register up msg callbacks */ roc_nix_mac_link_cb_register(nix, cnxk_eth_dev_link_status_cb); + /* Register up msg callbacks */ + roc_nix_mac_link_info_get_cb_register(nix, + cnxk_eth_dev_link_status_get_cb); + dev->eth_dev = eth_dev; dev->configured = 0; dev->ptype_disable = 0; @@ -1415,6 +1419,11 @@ cnxk_eth_dev_uninit(struct rte_eth_dev *eth_dev, bool reset) /* Disable link status events */ roc_nix_mac_link_event_start_stop(nix, false); + /* Unregister the link update op, this is required to stop VFs from + * receiving link status updates on exit path. + */ + roc_nix_mac_link_cb_unregister(nix); + /* Free up SQs */ for (i = 0; i < eth_dev->data->nb_tx_queues; i++) { dev_ops->tx_queue_release(eth_dev->data->tx_queues[i]); diff --git a/drivers/net/cnxk/cnxk_ethdev.h b/drivers/net/cnxk/cnxk_ethdev.h index 2528b3cdaa..27920c84f2 100644 --- a/drivers/net/cnxk/cnxk_ethdev.h +++ b/drivers/net/cnxk/cnxk_ethdev.h @@ -349,6 +349,8 @@ int cnxk_nix_rss_hash_conf_get(struct rte_eth_dev *eth_dev, void cnxk_nix_toggle_flag_link_cfg(struct cnxk_eth_dev *dev, bool set); void cnxk_eth_dev_link_status_cb(struct roc_nix *nix, struct roc_nix_link_info *link); +void cnxk_eth_dev_link_status_get_cb(struct roc_nix *nix, + struct roc_nix_link_info *link); int cnxk_nix_link_update(struct rte_eth_dev *eth_dev, int wait_to_complete); int cnxk_nix_queue_stats_mapping(struct rte_eth_dev *dev, uint16_t queue_id, uint8_t stat_idx, uint8_t is_rx); diff --git a/drivers/net/cnxk/cnxk_link.c b/drivers/net/cnxk/cnxk_link.c index 3fdbdba495..6a70801675 100644 --- a/drivers/net/cnxk/cnxk_link.c +++ b/drivers/net/cnxk/cnxk_link.c @@ -45,6 +45,29 @@ nix_link_status_print(struct rte_eth_dev *eth_dev, struct rte_eth_link *link) plt_info("Port %d: Link Down", (int)(eth_dev->data->port_id)); } +void +cnxk_eth_dev_link_status_get_cb(struct roc_nix *nix, + struct roc_nix_link_info *link) +{ + struct cnxk_eth_dev *dev = (struct cnxk_eth_dev *)nix; + struct rte_eth_link eth_link; + struct rte_eth_dev *eth_dev; + + if (!link || !nix) + return; + + eth_dev = dev->eth_dev; + if (!eth_dev) + return; + + rte_eth_linkstatus_get(eth_dev, ð_link); + + link->status = eth_link.link_status; + link->speed = eth_link.link_speed; + link->autoneg = eth_link.link_autoneg; + link->full_duplex = eth_link.link_duplex; +} + void cnxk_eth_dev_link_status_cb(struct roc_nix *nix, struct roc_nix_link_info *link) { -- 2.20.1