Adding a new callback for reading the link status. PF can read it's
link status and can forward the same to VF once it comes up.

Signed-off-by: Harman Kalra <hka...@marvell.com>
---
 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 4eead03905..4caf26303f 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, &eth_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.18.0

Reply via email to