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 BD7DAA00C2; Mon, 23 May 2022 18:11:41 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BFC7D42B6D; Mon, 23 May 2022 18:11:24 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 28B8E41611 for ; Mon, 23 May 2022 18:11:23 +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 24N9xGcV010407 for ; Mon, 23 May 2022 09:11:22 -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=IY+i6o6e1q+BEtxXTtXg3TnrF3GRBn3p7lZmprWxl4nt5gMOTYG+INqH/FwKOJI+tHWT lgp5TIbj+lWS0+pk9ysaX/QVJrKWwAANt5T2yYsZa8zc8ZLQXgtYNLebBjxj4zYi7Wqe F3FndcL6AIB3IgRi0Lmr5jDRh82kPBCmvFkBq5+N+tqnK2G2DbYCV88uSFYeh0rswzOk e6GqwpguOHoO2TcPsj3ivfdNMaJiny2NpCnMXDXENU9ay1Mv0NHMl5edAqivBV7WylcX gOsa48hYBs0WwgW75flFbCJTAs5Y41DughdgVoZ07lX5WSIOjdS9piqKTi9L8I0l/Vjp TQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3g6wepet9m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Mon, 23 May 2022 09:11:22 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 23 May 2022 09:11:20 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Mon, 23 May 2022 09:11:20 -0700 Received: from localhost.localdomain (unknown [10.29.52.211]) by maili.marvell.com (Postfix) with ESMTP id 5018E3F70A5; Mon, 23 May 2022 09:11:19 -0700 (PDT) From: Harman Kalra To: , Jerin Jacob , Maciej Czekaj CC: Hanumanth Pothula Subject: [PATCH v2 05/11] net/thunderx: implement polling of link state change Date: Mon, 23 May 2022 21:40:54 +0530 Message-ID: <20220523161100.86280-5-hkalra@marvell.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20220523161100.86280-1-hkalra@marvell.com> References: <20220517173941.189330-2-hkalra@marvell.com> <20220523161100.86280-1-hkalra@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-GUID: OlFJdt2V2IqH1xHY59j43w-K6VS5pyuB X-Proofpoint-ORIG-GUID: OlFJdt2V2IqH1xHY59j43w-K6VS5pyuB 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-23_07,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