From patchwork Tue Jun 22 20:05:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harman Kalra X-Patchwork-Id: 94684 X-Patchwork-Delegate: jerinj@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 99366A0548; Tue, 22 Jun 2021 22:06:19 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 24A044003F; Tue, 22 Jun 2021 22:06:19 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 162FD4003E for ; Tue, 22 Jun 2021 22:06:16 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 15MK1S6l001976 for ; Tue, 22 Jun 2021 13:06:16 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=pfpt0220; bh=div95r1xZw8wQ7cE4seRgnaN0Bum2Q8NApqzYMLFqPw=; b=bAV8Z1krk++KNzj48phLqLgDys0ihCJUhP6ei1w2GR2ppSfxpJE3ZtAC+dTEoxJ8U0Du JFlB2D3k2qBjPsTfNVdkyDcH+e1Ao8qkp2bLpt6+ssWQXlgCeVxjmRCknrayERIIxnzm eV6xKu44fv1EJleds/9Exsq9X/dHQxB3mZAjTzNcZzElKEAe96ZGVAAgCp0eJl49JxD7 qeoOnFaSgOg/0f7yFHDIbEx2hCCnBtfuMSN6SZyo8qVzbN+jqr32gIIQ2FpYuUoxULmJ qIdTKjOXfZZ5WQMZbwbaODGd7qlDetYrAcpN/9dIdRwzCFEKkVKL3MjPtzSyvnQt1Cgz 5g== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com with ESMTP id 39b91hbqd8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Tue, 22 Jun 2021 13:06:15 -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, 22 Jun 2021 13:06:14 -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.18 via Frontend Transport; Tue, 22 Jun 2021 13:06:14 -0700 Received: from localhost.localdomain (unknown [10.29.52.211]) by maili.marvell.com (Postfix) with ESMTP id 372C65B6925; Tue, 22 Jun 2021 13:06:12 -0700 (PDT) From: Harman Kalra To: Jerin Jacob , Nithin Dabilpuram CC: , Harman Kalra Date: Wed, 23 Jun 2021 01:35:53 +0530 Message-ID: <20210622200554.1544-1-hkalra@marvell.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: PGzNtFZJ2HEydMsnioLiOIPr3hRL0mG_ X-Proofpoint-GUID: PGzNtFZJ2HEydMsnioLiOIPr3hRL0mG_ X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-06-22_13:2021-06-22, 2021-06-22 signatures=0 Subject: [dpdk-dev] [PATCH 1/2] common/octeontx2: send link event to VF 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 Sender: "dev" Currently link event is only sent to the PF by AF as soon as it comes up, or in case of any physical change in link. PF will broadcast these link events to all its VFs as soon as it receives it. But no event is sent when a new VF comes up, hence it will not have the link status. Adding support for sending link status to the VF once it comes up successfully. Signed-off-by: Harman Kalra --- drivers/common/octeontx2/otx2_dev.c | 26 ++++++++++++++++++++++++++ drivers/common/octeontx2/otx2_dev.h | 10 +++++++--- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/drivers/common/octeontx2/otx2_dev.c b/drivers/common/octeontx2/otx2_dev.c index 6a84df2344..1485e2b357 100644 --- a/drivers/common/octeontx2/otx2_dev.c +++ b/drivers/common/octeontx2/otx2_dev.c @@ -163,6 +163,32 @@ af_pf_wait_msg(struct otx2_dev *dev, uint16_t vf, int num_msg) rsp->rc = msg->rc; rsp->pcifunc = msg->pcifunc; + /* Whenever a PF comes up, AF sends the link status to it but + * when VF comes up no such event is sent to respective VF. + * Using MBOX_MSG_NIX_LF_START_RX response from AF for the + * purpose and send the link status of PF to VF. + */ + if (msg->id == MBOX_MSG_NIX_LF_START_RX) { + /* Send link status to VF */ + struct cgx_link_user_info linfo; + struct mbox_msghdr *vf_msg; + + /* Get the link status */ + if (dev->ops && dev->ops->link_status_get) + dev->ops->link_status_get(dev, &linfo); + + /* Prepare the message to be sent */ + vf_msg = otx2_mbox_alloc_msg(&dev->mbox_vfpf_up, vf, + size); + otx2_mbox_req_init(MBOX_MSG_CGX_LINK_EVENT, vf_msg); + memcpy((uint8_t *)vf_msg + sizeof(struct mbox_msghdr), + &linfo, sizeof(struct cgx_link_user_info)); + + vf_msg->rc = msg->rc; + vf_msg->pcifunc = msg->pcifunc; + /* Send to VF */ + otx2_mbox_msg_send(&dev->mbox_vfpf_up, vf); + } offset = mbox->rx_start + msg->next_msgoff; } rte_spinlock_unlock(&mdev->mbox_lock); diff --git a/drivers/common/octeontx2/otx2_dev.h b/drivers/common/octeontx2/otx2_dev.h index cd4fe517db..be0faacc6a 100644 --- a/drivers/common/octeontx2/otx2_dev.h +++ b/drivers/common/octeontx2/otx2_dev.h @@ -57,15 +57,19 @@ struct otx2_dev; -/* Link status callback */ -typedef void (*otx2_link_status_t)(struct otx2_dev *dev, +/* Link status update callback */ +typedef void (*otx2_link_status_update_t)(struct otx2_dev *dev, struct cgx_link_user_info *link); /* PTP info callback */ typedef int (*otx2_ptp_info_t)(struct otx2_dev *dev, bool ptp_en); +/* Link status get callback */ +typedef void (*otx2_link_status_get_t)(struct otx2_dev *dev, + struct cgx_link_user_info *link); struct otx2_dev_ops { - otx2_link_status_t link_status_update; + otx2_link_status_update_t link_status_update; otx2_ptp_info_t ptp_info_update; + otx2_link_status_get_t link_status_get; }; #define OTX2_DEV \ From patchwork Tue Jun 22 20:05:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harman Kalra X-Patchwork-Id: 94685 X-Patchwork-Delegate: jerinj@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 48FC8A0548; Tue, 22 Jun 2021 22:06:26 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2F65840DDD; Tue, 22 Jun 2021 22:06:26 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id B148C40DDA for ; Tue, 22 Jun 2021 22:06:24 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 15MK1TVh001994 for ; Tue, 22 Jun 2021 13:06:23 -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=dzmNyJwqvyV4hJPWEfe+Em1DWd6KusvAi3TPRBrvqZg=; b=HKoBImFTqPTTa3B+snwHiB/jTW9mD5pkEHAAxRTV4WKCkoKZlH05KmLMrpLpZ+nuhb1D j1/a02JSN9jMFMsMqxuET2n7UkLDiWNvyySp2W92sfZKmGnTvPgGlE0L5rK4qevaGY/N cUXDbes1yhx0Q9K0lXuft2Z1r3+1jcoYSnsMFwa9qxvPHFqdp+HQPGBIBfeqqQOj1SPw J3KJdwqclGrFg2dZt6B3S0etedkD/90i62kJrrGg8mu3QxY4aNZ/ftcAtZiNQ3aP5LY8 MRpTEgodcr+UKVoJzgrrb0kdG6cropXarudyX9dqpwfJPkOnq/qUGtsr6XACN+4zu3yN Hw== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com with ESMTP id 39b91hbqdx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Tue, 22 Jun 2021 13:06:23 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 22 Jun 2021 13:06:22 -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.18 via Frontend Transport; Tue, 22 Jun 2021 13:06:22 -0700 Received: from localhost.localdomain (unknown [10.29.52.211]) by maili.marvell.com (Postfix) with ESMTP id C77B95B6925; Tue, 22 Jun 2021 13:06:20 -0700 (PDT) From: Harman Kalra To: Jerin Jacob , Nithin Dabilpuram , Kiran Kumar K CC: , Harman Kalra Date: Wed, 23 Jun 2021 01:35:54 +0530 Message-ID: <20210622200554.1544-2-hkalra@marvell.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210622200554.1544-1-hkalra@marvell.com> References: <20210622200554.1544-1-hkalra@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: oNPJcqzFG4LnRxQSukKA1O9bONQ_Hl7n X-Proofpoint-GUID: oNPJcqzFG4LnRxQSukKA1O9bONQ_Hl7n X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-06-22_13:2021-06-22, 2021-06-22 signatures=0 Subject: [dpdk-dev] [PATCH 2/2] net/octeontx2: callback for getting link status 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 Sender: "dev" Adding a new callback for reading the link status. PF can read it's link status and can forward the same to VF once it comes up. Signed-off-by: Harman Kalra --- drivers/net/octeontx2/otx2_ethdev.c | 8 +++++++- drivers/net/octeontx2/otx2_ethdev.h | 2 ++ drivers/net/octeontx2/otx2_link.c | 23 +++++++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/net/octeontx2/otx2_ethdev.c b/drivers/net/octeontx2/otx2_ethdev.c index 0834de0cb1..471fa34da1 100644 --- a/drivers/net/octeontx2/otx2_ethdev.c +++ b/drivers/net/octeontx2/otx2_ethdev.c @@ -42,7 +42,8 @@ nix_get_tx_offload_capa(struct otx2_eth_dev *dev) static const struct otx2_dev_ops otx2_dev_ops = { .link_status_update = otx2_eth_dev_link_status_update, - .ptp_info_update = otx2_eth_dev_ptp_info_update + .ptp_info_update = otx2_eth_dev_ptp_info_update, + .link_status_get = otx2_eth_dev_link_status_get }; static int @@ -2625,6 +2626,11 @@ otx2_eth_dev_uninit(struct rte_eth_dev *eth_dev, bool mbox_close) nix_cgx_stop_link_event(dev); + /* Unregister the dev ops, this is required to stop VFs from + * receiving link status updates on exit path. + */ + dev->ops = NULL; + /* Free up SQs */ for (i = 0; i < eth_dev->data->nb_tx_queues; i++) { otx2_nix_tx_queue_release(eth_dev->data->tx_queues[i]); diff --git a/drivers/net/octeontx2/otx2_ethdev.h b/drivers/net/octeontx2/otx2_ethdev.h index ac50da7b18..08f9a2a7bc 100644 --- a/drivers/net/octeontx2/otx2_ethdev.h +++ b/drivers/net/octeontx2/otx2_ethdev.h @@ -453,6 +453,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); +void otx2_eth_dev_link_status_get(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); int otx2_apply_link_speed(struct rte_eth_dev *eth_dev); diff --git a/drivers/net/octeontx2/otx2_link.c b/drivers/net/octeontx2/otx2_link.c index a79b997376..5378e5c3b9 100644 --- a/drivers/net/octeontx2/otx2_link.c +++ b/drivers/net/octeontx2/otx2_link.c @@ -47,6 +47,29 @@ nix_link_status_print(struct rte_eth_dev *eth_dev, struct rte_eth_link *link) otx2_info("Port %d: Link Down", (int)(eth_dev->data->port_id)); } +void +otx2_eth_dev_link_status_get(struct otx2_dev *dev, + struct cgx_link_user_info *link) +{ + struct otx2_eth_dev *otx2_dev = (struct otx2_eth_dev *)dev; + struct rte_eth_link eth_link; + struct rte_eth_dev *eth_dev; + + if (!link || !dev) + return; + + eth_dev = otx2_dev->eth_dev; + if (!eth_dev) + return; + + rte_eth_linkstatus_get(eth_dev, ð_link); + + link->link_up = eth_link.link_status; + link->speed = eth_link.link_speed; + link->an = eth_link.link_autoneg; + link->full_duplex = eth_link.link_duplex; +} + void otx2_eth_dev_link_status_update(struct otx2_dev *dev, struct cgx_link_user_info *link)