]> git.droids-corp.org - dpdk.git/commitdiff
net/thunderx: support polling of link state change
authorHanumanth Pothula <hpothula@marvell.com>
Tue, 24 May 2022 08:42:29 +0000 (14:12 +0530)
committerJerin Jacob <jerinj@marvell.com>
Mon, 13 Jun 2022 07:29:24 +0000 (09:29 +0200)
Moving the logic of link polling to VF from PF. Now VF
is supposed to poll for the link status, rather PF alerting
VF about any link change.

Signed-off-by: Hanumanth Pothula <hpothula@marvell.com>
drivers/net/thunderx/base/nicvf_mbox.c
drivers/net/thunderx/base/nicvf_mbox.h
drivers/net/thunderx/nicvf_ethdev.c
drivers/net/thunderx/nicvf_ethdev.h

index d7209c0083f9d95e2e9b75c4df2a986258733e72..281027cccee86e981f8dbf4a8b5aa8fd371ab9bd 100644 (file)
@@ -440,3 +440,12 @@ nicvf_mbox_cfg_done(struct nicvf *nic)
        mbx.msg.msg = NIC_MBOX_MSG_CFG_DONE;
        nicvf_mbox_send_async_msg_to_pf(nic, &mbx);
 }
+
+void
+nicvf_mbox_link_change(struct nicvf *nic)
+{
+       struct nic_mbx mbx = { .msg = { 0 } };
+
+       mbx.msg.msg = NIC_MBOX_MSG_BGX_LINK_CHANGE;
+       nicvf_mbox_send_async_msg_to_pf(nic, &mbx);
+}
index d0b294362cc859012654b1b3c24d725174e831e9..490bed206b779a503af3409a0cfcbe55539d4b1b 100644 (file)
@@ -222,5 +222,6 @@ int nicvf_mbox_reset_stat_counters(struct nicvf *nic, uint16_t rx_stat_mask,
 int nicvf_mbox_set_link_up_down(struct nicvf *nic, bool enable);
 void nicvf_mbox_shutdown(struct nicvf *nic);
 void nicvf_mbox_cfg_done(struct nicvf *nic);
+void nicvf_mbox_link_change(struct nicvf *nic);
 
 #endif /* __THUNDERX_NICVF_MBOX__ */
index fc334cf734ef60e5427c65bf5dceca7049b196f3..addbd537350a223656140ef7a6f2f36bd7faccb1 100644 (file)
@@ -71,6 +71,9 @@ nicvf_link_status_update(struct nicvf *nic,
        link->link_autoneg = RTE_ETH_LINK_AUTONEG;
 }
 
+/*Poll for link status change by sending NIC_MBOX_MSG_BGX_LINK_CHANGE msg
+ * periodically to PF.
+ */
 static void
 nicvf_interrupt(void *arg)
 {
@@ -78,7 +81,10 @@ nicvf_interrupt(void *arg)
        struct nicvf *nic = nicvf_pmd_priv(dev);
        struct rte_eth_link link;
 
-       if (nicvf_reg_poll_interrupts(nic) == NIC_MBOX_MSG_BGX_LINK_CHANGE) {
+       rte_eth_linkstatus_get(dev, &link);
+
+       nicvf_mbox_link_change(nic);
+       if (nic->link_up != link.link_status) {
                if (dev->data->dev_conf.intr_conf.lsc) {
                        nicvf_link_status_update(nic, &link);
                        rte_eth_linkstatus_set(dev, &link);
@@ -89,7 +95,7 @@ nicvf_interrupt(void *arg)
                }
        }
 
-       rte_eal_alarm_set(NICVF_INTR_POLL_INTERVAL_MS * 1000,
+       rte_eal_alarm_set(NICVF_INTR_LINK_POLL_INTERVAL_MS * 1000,
                                nicvf_interrupt, dev);
 }
 
@@ -1841,7 +1847,6 @@ nicvf_vf_stop(struct rte_eth_dev *dev, struct nicvf *nic, bool cleanup)
 static int
 nicvf_dev_close(struct rte_eth_dev *dev)
 {
-       size_t i;
        struct nicvf *nic = nicvf_pmd_priv(dev);
 
        PMD_INIT_FUNC_TRACE();
@@ -1850,13 +1855,7 @@ nicvf_dev_close(struct rte_eth_dev *dev)
 
        nicvf_dev_stop_cleanup(dev, true);
        nicvf_periodic_alarm_stop(nicvf_interrupt, dev);
-
-       for (i = 0; i < nic->sqs_count; i++) {
-               if (!nic->snicvf[i])
-                       continue;
-
-               nicvf_periodic_alarm_stop(nicvf_vf_interrupt, nic->snicvf[i]);
-       }
+       nicvf_periodic_alarm_stop(nicvf_vf_interrupt, nic);
 
        rte_intr_instance_free(nic->intr_handle);
 
@@ -2169,6 +2168,14 @@ nicvf_eth_dev_init(struct rte_eth_dev *eth_dev)
 
        nicvf_disable_all_interrupts(nic);
 
+       /* To read mbox messages */
+       ret = nicvf_periodic_alarm_start(nicvf_vf_interrupt, nic);
+       if (ret) {
+               PMD_INIT_LOG(ERR, "Failed to start period alarm");
+               goto fail;
+       }
+
+       /* To poll link status change*/
        ret = nicvf_periodic_alarm_start(nicvf_interrupt, eth_dev);
        if (ret) {
                PMD_INIT_LOG(ERR, "Failed to start period alarm");
@@ -2203,11 +2210,6 @@ nicvf_eth_dev_init(struct rte_eth_dev *eth_dev)
                eth_dev->data->dev_private = NULL;
 
                nicvf_periodic_alarm_stop(nicvf_interrupt, eth_dev);
-               ret = nicvf_periodic_alarm_start(nicvf_vf_interrupt, nic);
-               if (ret) {
-                       PMD_INIT_LOG(ERR, "Failed to start period alarm");
-                       goto fail;
-               }
 
                /* Detach port by returning positive error number */
                return ENOTSUP;
index cb474e26b81eb22d8bfa8835e963d71b3c6e5d5e..a947b55fd4708a74bbc9bd6b396470c928234ecd 100644 (file)
 #define THUNDERX_NICVF_PMD_VERSION      "2.0"
 #define THUNDERX_REG_BYTES             8
 
-#define NICVF_INTR_POLL_INTERVAL_MS    50
-#define NICVF_HALF_DUPLEX              0x00
-#define NICVF_FULL_DUPLEX              0x01
-#define NICVF_UNKNOWN_DUPLEX           0xff
+#define NICVF_INTR_POLL_INTERVAL_MS            50
+/* Poll for link state for every 2 sec */
+#define NICVF_INTR_LINK_POLL_INTERVAL_MS       2000
+#define NICVF_HALF_DUPLEX                      0x00
+#define NICVF_FULL_DUPLEX                      0x01
+#define NICVF_UNKNOWN_DUPLEX                   0xff
 
 #define NICVF_RSS_OFFLOAD_PASS1 ( \
        RTE_ETH_RSS_PORT | \