net/cnxk: support link up/down operations
authorSunil Kumar Kori <skori@marvell.com>
Wed, 23 Jun 2021 04:46:39 +0000 (10:16 +0530)
committerJerin Jacob <jerinj@marvell.com>
Tue, 29 Jun 2021 22:53:18 +0000 (00:53 +0200)
Patch implements link up/down ethdev operations for
cn9k and cn10k platform.

Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
drivers/net/cnxk/cnxk_ethdev.c
drivers/net/cnxk/cnxk_ethdev.h
drivers/net/cnxk/cnxk_ethdev_ops.c

index abca49b..a18d1d5 100644 (file)
@@ -975,7 +975,7 @@ fail_configure:
        return rc;
 }
 
-static int
+int
 cnxk_nix_tx_queue_start(struct rte_eth_dev *eth_dev, uint16_t qid)
 {
        struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
@@ -1189,6 +1189,8 @@ struct eth_dev_ops cnxk_eth_dev_ops = {
        .tx_burst_mode_get = cnxk_nix_tx_burst_mode_get,
        .flow_ctrl_get = cnxk_nix_flow_ctrl_get,
        .flow_ctrl_set = cnxk_nix_flow_ctrl_set,
+       .dev_set_link_up = cnxk_nix_set_link_up,
+       .dev_set_link_down = cnxk_nix_set_link_down,
 };
 
 static int
index e788a42..5e982f9 100644 (file)
@@ -251,6 +251,9 @@ int cnxk_nix_flow_ctrl_set(struct rte_eth_dev *eth_dev,
                           struct rte_eth_fc_conf *fc_conf);
 int cnxk_nix_flow_ctrl_get(struct rte_eth_dev *eth_dev,
                           struct rte_eth_fc_conf *fc_conf);
+int cnxk_nix_set_link_up(struct rte_eth_dev *eth_dev);
+int cnxk_nix_set_link_down(struct rte_eth_dev *eth_dev);
+
 int cnxk_nix_configure(struct rte_eth_dev *eth_dev);
 int cnxk_nix_tx_queue_setup(struct rte_eth_dev *eth_dev, uint16_t qid,
                            uint16_t nb_desc, uint16_t fp_tx_q_sz,
@@ -259,6 +262,7 @@ int cnxk_nix_rx_queue_setup(struct rte_eth_dev *eth_dev, uint16_t qid,
                            uint16_t nb_desc, uint16_t fp_rx_q_sz,
                            const struct rte_eth_rxconf *rx_conf,
                            struct rte_mempool *mp);
+int cnxk_nix_tx_queue_start(struct rte_eth_dev *eth_dev, uint16_t qid);
 int cnxk_nix_tx_queue_stop(struct rte_eth_dev *eth_dev, uint16_t qid);
 int cnxk_nix_dev_start(struct rte_eth_dev *eth_dev);
 
index 97c5428..c8da129 100644 (file)
@@ -512,3 +512,50 @@ cnxk_nix_allmulticast_disable(struct rte_eth_dev *eth_dev)
        return roc_nix_npc_mcast_config(&dev->nix, false,
                                        eth_dev->data->promiscuous);
 }
+
+int
+cnxk_nix_set_link_up(struct rte_eth_dev *eth_dev)
+{
+       struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
+       struct roc_nix *nix = &dev->nix;
+       int rc, i;
+
+       if (roc_nix_is_vf_or_sdp(nix))
+               return -ENOTSUP;
+
+       rc = roc_nix_mac_link_state_set(nix, true);
+       if (rc)
+               goto exit;
+
+       /* Start tx queues  */
+       for (i = 0; i < eth_dev->data->nb_tx_queues; i++) {
+               rc = cnxk_nix_tx_queue_start(eth_dev, i);
+               if (rc)
+                       goto exit;
+       }
+
+exit:
+       return rc;
+}
+
+int
+cnxk_nix_set_link_down(struct rte_eth_dev *eth_dev)
+{
+       struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
+       struct roc_nix *nix = &dev->nix;
+       int rc, i;
+
+       if (roc_nix_is_vf_or_sdp(nix))
+               return -ENOTSUP;
+
+       /* Stop tx queues  */
+       for (i = 0; i < eth_dev->data->nb_tx_queues; i++) {
+               rc = cnxk_nix_tx_queue_stop(eth_dev, i);
+               if (rc)
+                       goto exit;
+       }
+
+       rc = roc_nix_mac_link_state_set(nix, false);
+exit:
+       return rc;
+}