From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 447ADA04FF; Tue, 24 May 2022 10:43:21 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 65DB640A84; Tue, 24 May 2022 10:43:06 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 02F44400D6 for ; Tue, 24 May 2022 10:43:04 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24NNBIlg022495 for ; Tue, 24 May 2022 01:43:04 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0220; bh=MpklmOCr7cpkj6CvGuX5hRCoWeZ54mhgRd89qqFDxlU=; b=DTZyMs2K8OSSW0IUwIGp741oq7SKt+uN18nUwN2uknLVFHpDP4cRd+WzgCM8f8LgnJtc AHummkx/D8PY5TwLsSHFFWReHG5OOMM5RgM8+jUSKbyRteDNNiYojq6+VEIZsYXTyp0A ktCEOPMzDvaqcfX/ipgCFu7wHErGA3DKqbZtWO250jJBvQeiuB89yEYrFtbsicdgAxlD 2P3v/nN6XUDmLDLiXVf3WjoznWBiyn/lXhZnI1OZnaFxRrAsOoRIfBtedTWOluOZSIyr IHqE0lXv5o1ckC2OUm8zcdnYAOkxBCMBYO0TEygj2eiTYCignfEBs1NgYzv9NateXSWf 3w== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3g8kqjhrub-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Tue, 24 May 2022 01:43:04 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 24 May 2022 01:43:02 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 24 May 2022 01:43:01 -0700 Received: from localhost.localdomain (unknown [10.29.52.211]) by maili.marvell.com (Postfix) with ESMTP id 9F1823F709F; Tue, 24 May 2022 01:43:00 -0700 (PDT) From: Harman Kalra To: , Jerin Jacob , Maciej Czekaj CC: Hanumanth Pothula Subject: [PATCH v3 05/11] net/thunderx: implement polling of link state change Date: Tue, 24 May 2022 14:12:29 +0530 Message-ID: <20220524084235.17796-5-hkalra@marvell.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20220524084235.17796-1-hkalra@marvell.com> References: <20220517173941.189330-2-hkalra@marvell.com> <20220524084235.17796-1-hkalra@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-ORIG-GUID: 90W3NYG8iwniZ5KjJPLBYOGFQLq8go07 X-Proofpoint-GUID: 90W3NYG8iwniZ5KjJPLBYOGFQLq8go07 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-24_06,2022-05-23_01,2022-02-23_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Hanumanth Pothula 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 --- drivers/net/thunderx/base/nicvf_mbox.c | 9 ++++++++ drivers/net/thunderx/base/nicvf_mbox.h | 1 + drivers/net/thunderx/nicvf_ethdev.c | 32 ++++++++++++++------------ drivers/net/thunderx/nicvf_ethdev.h | 10 ++++---- 4 files changed, 33 insertions(+), 19 deletions(-) diff --git a/drivers/net/thunderx/base/nicvf_mbox.c b/drivers/net/thunderx/base/nicvf_mbox.c index d7209c0083..281027ccce 100644 --- a/drivers/net/thunderx/base/nicvf_mbox.c +++ b/drivers/net/thunderx/base/nicvf_mbox.c @@ -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); +} diff --git a/drivers/net/thunderx/base/nicvf_mbox.h b/drivers/net/thunderx/base/nicvf_mbox.h index d0b294362c..490bed206b 100644 --- a/drivers/net/thunderx/base/nicvf_mbox.h +++ b/drivers/net/thunderx/base/nicvf_mbox.h @@ -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__ */ diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c index fc334cf734..addbd53735 100644 --- a/drivers/net/thunderx/nicvf_ethdev.c +++ b/drivers/net/thunderx/nicvf_ethdev.c @@ -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; diff --git a/drivers/net/thunderx/nicvf_ethdev.h b/drivers/net/thunderx/nicvf_ethdev.h index cb474e26b8..a947b55fd4 100644 --- a/drivers/net/thunderx/nicvf_ethdev.h +++ b/drivers/net/thunderx/nicvf_ethdev.h @@ -10,10 +10,12 @@ #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 | \ -- 2.18.0