net/octeontx2: add link status operations
authorVamsi Attunuru <vattunuru@marvell.com>
Wed, 3 Jul 2019 08:31:50 +0000 (14:01 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Thu, 4 Jul 2019 23:52:02 +0000 (01:52 +0200)
Add support for setting the link up and down.

Signed-off-by: Vamsi Attunuru <vattunuru@marvell.com>
Signed-off-by: Nithin Dabilpuram <ndabilpuram@marvell.com>
drivers/net/octeontx2/otx2_ethdev.c
drivers/net/octeontx2/otx2_ethdev.h
drivers/net/octeontx2/otx2_link.c

index b5b5e63..156e7d3 100644 (file)
@@ -1572,6 +1572,8 @@ static const struct eth_dev_ops otx2_eth_dev_ops = {
        .tx_queue_stop            = otx2_nix_tx_queue_stop,
        .rx_queue_start           = otx2_nix_rx_queue_start,
        .rx_queue_stop            = otx2_nix_rx_queue_stop,
+       .dev_set_link_up          = otx2_nix_dev_set_link_up,
+       .dev_set_link_down        = otx2_nix_dev_set_link_down,
        .dev_supported_ptypes_get = otx2_nix_supported_ptypes_get,
        .dev_reset                = otx2_nix_dev_reset,
        .stats_get                = otx2_nix_dev_stats_get,
index f6905db..863d487 100644 (file)
@@ -389,6 +389,8 @@ void otx2_nix_toggle_flag_link_cfg(struct otx2_eth_dev *dev, bool set);
 int otx2_nix_link_update(struct rte_eth_dev *eth_dev, int wait_to_complete);
 void otx2_eth_dev_link_status_update(struct otx2_dev *dev,
                                     struct cgx_link_user_info *link);
+int otx2_nix_dev_set_link_up(struct rte_eth_dev *eth_dev);
+int otx2_nix_dev_set_link_down(struct rte_eth_dev *eth_dev);
 
 /* IRQ */
 int otx2_nix_register_irqs(struct rte_eth_dev *eth_dev);
index 228a0cd..8fcbdc9 100644 (file)
@@ -106,3 +106,52 @@ otx2_nix_link_update(struct rte_eth_dev *eth_dev, int wait_to_complete)
 
        return rte_eth_linkstatus_set(eth_dev, &link);
 }
+
+static int
+nix_dev_set_link_state(struct rte_eth_dev *eth_dev, uint8_t enable)
+{
+       struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev);
+       struct otx2_mbox *mbox = dev->mbox;
+       struct cgx_set_link_state_msg *req;
+
+       req = otx2_mbox_alloc_msg_cgx_set_link_state(mbox);
+       req->enable = enable;
+       return otx2_mbox_process(mbox);
+}
+
+int
+otx2_nix_dev_set_link_up(struct rte_eth_dev *eth_dev)
+{
+       struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev);
+       int rc, i;
+
+       if (otx2_dev_is_vf(dev))
+               return -ENOTSUP;
+
+       rc = nix_dev_set_link_state(eth_dev, 1);
+       if (rc)
+               goto done;
+
+       /* Start tx queues  */
+       for (i = 0; i < eth_dev->data->nb_tx_queues; i++)
+               otx2_nix_tx_queue_start(eth_dev, i);
+
+done:
+       return rc;
+}
+
+int
+otx2_nix_dev_set_link_down(struct rte_eth_dev *eth_dev)
+{
+       struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev);
+       int i;
+
+       if (otx2_dev_is_vf(dev))
+               return -ENOTSUP;
+
+       /* Stop tx queues  */
+       for (i = 0; i < eth_dev->data->nb_tx_queues; i++)
+               otx2_nix_tx_queue_stop(eth_dev, i);
+
+       return nix_dev_set_link_state(eth_dev, 0);
+}