net/cnxk: add callback to get link status
authorHarman Kalra <hkalra@marvell.com>
Fri, 30 Jul 2021 16:08:29 +0000 (21:38 +0530)
committerJerin Jacob <jerinj@marvell.com>
Thu, 16 Sep 2021 14:29:47 +0000 (16:29 +0200)
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 <hkalra@marvell.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
drivers/net/cnxk/cnxk_ethdev.c
drivers/net/cnxk/cnxk_ethdev.h
drivers/net/cnxk/cnxk_link.c

index 0e3652e..7152dcd 100644 (file)
@@ -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]);
index 2528b3c..27920c8 100644 (file)
@@ -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);
index 3fdbdba..6a70801 100644 (file)
@@ -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)
 {