From patchwork Tue Aug 6 14:50:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vamsi Krishna X-Patchwork-Id: 142958 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 C277E4574E; Tue, 6 Aug 2024 16:50:49 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 913DE40614; Tue, 6 Aug 2024 16:50:49 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 0150C409FA for ; Tue, 6 Aug 2024 16:50:47 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 476EVWQo012496 for ; Tue, 6 Aug 2024 07:50:47 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=pfpt0220; bh=Uz+mJEb5FbgmMBCOw1GZc/+ FeVINL2zzelzkPfz8x/E=; b=il1RqdzuRmFyhG+RWpvQ+epjQu6+rsOo7CRSXfR Fgk4CDpT6h480Xu6PuVDyMUivwJ+4rfwyIQ0Ir1aLfzoT0V+v482cyrte1t5fsX5 soSF70P7pLCs9G9mNrFv1qG4ivT/NwJFhxodqnhclBfZYZ6r+Hc9WEXhvdV4tV4O Y2mdQxRwMbnDr9OG9bVWW+tpr5fJCRJdyS1pfPjEP254VZ+z097n7mzmU6DE7Rsa 1cEqSKp10fwxZh2OfsYbrZT8I59YAUNzw25xwJdJPs4JxeVHPMiF5SEJuAoJyCoH nuCYPpRxm56oXoL/TFyeRD4Ox2gLzlv7eHWjgOX/t2qjEAQ== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 40unnjg36d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 06 Aug 2024 07:50:47 -0700 (PDT) Received: from DC6WP-EXCH02.marvell.com (10.76.176.209) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 6 Aug 2024 07:50:46 -0700 Received: from maili.marvell.com (10.69.176.80) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Tue, 6 Aug 2024 07:50:46 -0700 Received: from localhost.localdomain (unknown [10.28.36.156]) by maili.marvell.com (Postfix) with ESMTP id EABEF3F7070; Tue, 6 Aug 2024 07:50:44 -0700 (PDT) From: Vamsi Attunuru To: CC: , Vamsi Attunuru Subject: [PATCH] net/octeon_ep: extend mailbox functionality Date: Tue, 6 Aug 2024 07:50:38 -0700 Message-ID: <20240806145038.467033-1-vattunuru@marvell.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Proofpoint-GUID: QHbQG09ZWBkMU2BmBkPwLxU6nnoW_Swu X-Proofpoint-ORIG-GUID: QHbQG09ZWBkMU2BmBkPwLxU6nnoW_Swu X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-06_12,2024-08-06_01,2024-05-17_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 Patch extends mbox functionality to handle pf to vf mbox messages and also updates current mbox version to V3. As part of PF FLR notify event, event handler invokes device removal event callback to tear down the driver. Signed-off-by: Vamsi Attunuru --- drivers/net/octeon_ep/cnxk_ep_vf.h | 5 ++ drivers/net/octeon_ep/otx_ep_ethdev.c | 4 +- drivers/net/octeon_ep/otx_ep_mbox.c | 70 +++++++++++++++++++++++++-- drivers/net/octeon_ep/otx_ep_mbox.h | 11 ++++- 4 files changed, 82 insertions(+), 8 deletions(-) diff --git a/drivers/net/octeon_ep/cnxk_ep_vf.h b/drivers/net/octeon_ep/cnxk_ep_vf.h index 41d8fbbb3a..8981dd7e86 100644 --- a/drivers/net/octeon_ep/cnxk_ep_vf.h +++ b/drivers/net/octeon_ep/cnxk_ep_vf.h @@ -134,6 +134,9 @@ #define CNXK_EP_R_MBOX_VF_PF_DATA(ring) \ (CNXK_EP_R_MBOX_VF_PF_DATA_START + ((ring) * CNXK_EP_RING_OFFSET)) +#define CNXK_EP_R_MBOX_PF_VF_DATA(ring) \ + (CNXK_EP_R_MBOX_PF_VF_DATA_START + ((ring) * CNXK_EP_RING_OFFSET)) + #define CNXK_EP_R_MBOX_PF_VF_INT(ring) \ (CNXK_EP_R_MBOX_PF_VF_INT_START + ((ring) * CNXK_EP_RING_OFFSET)) @@ -195,5 +198,7 @@ struct cnxk_ep_instr_32B { #define CNXK_EP_OQ_ISM_OFFSET(queue) (RTE_CACHE_LINE_SIZE * (queue)) #define CNXK_EP_ISM_EN (0x1) #define CNXK_EP_ISM_MSIX_DIS (0x2) +#define CNXK_EP_MBOX_INTR (0x1) +#define CNXK_EP_MBOX_ENAB (0x2) #endif /*_CNXK_EP_VF_H_ */ diff --git a/drivers/net/octeon_ep/otx_ep_ethdev.c b/drivers/net/octeon_ep/otx_ep_ethdev.c index 46211361a0..196ed69123 100644 --- a/drivers/net/octeon_ep/otx_ep_ethdev.c +++ b/drivers/net/octeon_ep/otx_ep_ethdev.c @@ -656,6 +656,7 @@ otx_ep_dev_close(struct rte_eth_dev *eth_dev) otx_epvf = OTX_EP_DEV(eth_dev); otx_ep_mbox_send_dev_exit(eth_dev); + otx_ep_mbox_uninit(eth_dev); otx_epvf->fn_list.disable_io_queues(otx_epvf); num_queues = otx_epvf->nb_rx_queues; for (q_no = 0; q_no < num_queues; q_no++) { @@ -725,6 +726,7 @@ otx_ep_eth_dev_uninit(struct rte_eth_dev *eth_dev) return 0; } + otx_ep_mbox_uninit(eth_dev); eth_dev->dev_ops = NULL; eth_dev->rx_pkt_burst = NULL; eth_dev->tx_pkt_burst = NULL; @@ -826,7 +828,7 @@ otx_ep_eth_dev_init(struct rte_eth_dev *eth_dev) return -EINVAL; } - if (otx_ep_mbox_version_check(eth_dev)) + if (otx_ep_mbox_init(eth_dev)) return -EINVAL; if (otx_ep_eth_dev_query_set_vf_mac(eth_dev, diff --git a/drivers/net/octeon_ep/otx_ep_mbox.c b/drivers/net/octeon_ep/otx_ep_mbox.c index 4118645dc7..0474419599 100644 --- a/drivers/net/octeon_ep/otx_ep_mbox.c +++ b/drivers/net/octeon_ep/otx_ep_mbox.c @@ -17,7 +17,10 @@ * with new command and it's version info. */ static uint32_t otx_ep_cmd_versions[OTX_EP_MBOX_CMD_MAX] = { - [0 ... OTX_EP_MBOX_CMD_DEV_REMOVE] = OTX_EP_MBOX_VERSION_V1 + [0 ... OTX_EP_MBOX_CMD_DEV_REMOVE] = OTX_EP_MBOX_VERSION_V1, + [OTX_EP_MBOX_CMD_GET_FW_INFO ... OTX_EP_MBOX_NOTIF_LINK_STATUS] = OTX_EP_MBOX_VERSION_V2, + [OTX_EP_MBOX_NOTIF_PF_FLR] = OTX_EP_MBOX_VERSION_V3 + }; static int @@ -288,10 +291,9 @@ otx_ep_mbox_get_max_pkt_len(struct rte_eth_dev *eth_dev) return rsp.s_get_mtu.mtu; } -int otx_ep_mbox_version_check(struct rte_eth_dev *eth_dev) +static void +otx_ep_mbox_version_check(struct otx_ep_device *otx_ep) { - struct otx_ep_device *otx_ep = - (struct otx_ep_device *)(eth_dev)->data->dev_private; union otx_ep_mbox_word cmd; union otx_ep_mbox_word rsp; int ret; @@ -312,15 +314,73 @@ int otx_ep_mbox_version_check(struct rte_eth_dev *eth_dev) if (ret == OTX_EP_MBOX_CMD_STATUS_NACK || rsp.s_version.version == 0) { otx_ep_dbg("VF Mbox version fallback to base version from:%u\n", (uint32_t)cmd.s_version.version); - return 0; + return; } otx_ep->mbox_neg_ver = (uint32_t)rsp.s_version.version; otx_ep_dbg("VF Mbox version:%u Negotiated VF version with PF:%u\n", (uint32_t)cmd.s_version.version, (uint32_t)rsp.s_version.version); +} + +static void +otx_ep_mbox_intr_handler(void *param) +{ + struct rte_eth_dev *eth_dev = (struct rte_eth_dev *)param; + struct otx_ep_device *otx_ep = (struct otx_ep_device *)eth_dev->data->dev_private; + struct rte_pci_device *pdev = RTE_ETH_DEV_TO_PCI(eth_dev); + union otx_ep_mbox_word mbox_cmd; + + if (otx2_read64(otx_ep->hw_addr + CNXK_EP_R_MBOX_PF_VF_INT(0)) & CNXK_EP_MBOX_INTR) { + mbox_cmd.u64 = otx2_read64(otx_ep->hw_addr + CNXK_EP_R_MBOX_PF_VF_DATA(0)); + otx2_write64(CNXK_EP_MBOX_ENAB | CNXK_EP_MBOX_INTR, + otx_ep->hw_addr + CNXK_EP_R_MBOX_PF_VF_INT(0)); + if (mbox_cmd.s.opcode == OTX_EP_MBOX_NOTIF_PF_FLR) { + rte_spinlock_lock(&otx_ep->mbox_lock); + mbox_cmd.s.type = OTX_EP_MBOX_TYPE_RSP_ACK; + otx2_write64(mbox_cmd.u64, otx_ep->hw_addr + CNXK_EP_R_MBOX_PF_VF_DATA(0)); + rte_spinlock_unlock(&otx_ep->mbox_lock); + rte_dev_event_callback_process(pdev->name, RTE_DEV_EVENT_REMOVE); + } else { + otx_ep_err("Invalid mbox opcode"); + } + } +} + +int +otx_ep_mbox_init(struct rte_eth_dev *eth_dev) +{ + struct otx_ep_device *otx_ep = (struct otx_ep_device *)eth_dev->data->dev_private; + struct rte_pci_device *pdev = RTE_ETH_DEV_TO_PCI(eth_dev); + + otx_ep_mbox_version_check(otx_ep); + + rte_intr_callback_register(pdev->intr_handle, otx_ep_mbox_intr_handler, (void *)eth_dev); + + if (rte_intr_enable(pdev->intr_handle)) { + otx_ep_err("rte_intr_enable failed"); + return -1; + } + + /* Enable pf-vf mbox interrupt & clear the status */ + otx2_write64(CNXK_EP_MBOX_ENAB | CNXK_EP_MBOX_INTR, + otx_ep->hw_addr + CNXK_EP_R_MBOX_PF_VF_INT(0)); + return 0; } +void +otx_ep_mbox_uninit(struct rte_eth_dev *eth_dev) +{ + struct otx_ep_device *otx_ep = (struct otx_ep_device *)eth_dev->data->dev_private; + struct rte_pci_device *pdev = RTE_ETH_DEV_TO_PCI(eth_dev); + + otx2_write64(0, otx_ep->hw_addr + CNXK_EP_R_MBOX_PF_VF_INT(0)); + + rte_intr_disable(pdev->intr_handle); + + rte_intr_callback_unregister(pdev->intr_handle, otx_ep_mbox_intr_handler, (void *)eth_dev); +} + int otx_ep_mbox_send_dev_exit(struct rte_eth_dev *eth_dev) { struct otx_ep_device *otx_ep = diff --git a/drivers/net/octeon_ep/otx_ep_mbox.h b/drivers/net/octeon_ep/otx_ep_mbox.h index a3fc15cca7..ec96e4edc5 100644 --- a/drivers/net/octeon_ep/otx_ep_mbox.h +++ b/drivers/net/octeon_ep/otx_ep_mbox.h @@ -11,9 +11,11 @@ enum octep_pfvf_mbox_version { OTX_EP_MBOX_VERSION_V0, OTX_EP_MBOX_VERSION_V1, + OTX_EP_MBOX_VERSION_V2, + OTX_EP_MBOX_VERSION_V3, }; -#define OTX_EP_MBOX_VERSION_CURRENT OTX_EP_MBOX_VERSION_V1 +#define OTX_EP_MBOX_VERSION_CURRENT OTX_EP_MBOX_VERSION_V3 enum otx_ep_mbox_opcode { OTX_EP_MBOX_CMD_VERSION, @@ -27,6 +29,10 @@ enum otx_ep_mbox_opcode { OTX_EP_MBOX_CMD_GET_LINK_STATUS, OTX_EP_MBOX_CMD_GET_MTU, OTX_EP_MBOX_CMD_DEV_REMOVE, + OTX_EP_MBOX_CMD_GET_FW_INFO, + OTX_EP_MBOX_CMD_SET_OFFLOADS, + OTX_EP_MBOX_NOTIF_LINK_STATUS, + OTX_EP_MBOX_NOTIF_PF_FLR, OTX_EP_MBOX_CMD_MAX, }; @@ -165,6 +171,7 @@ int otx_ep_mbox_get_link_info(struct rte_eth_dev *eth_dev, struct rte_eth_link * void otx_ep_mbox_enable_interrupt(struct otx_ep_device *otx_ep); void otx_ep_mbox_disable_interrupt(struct otx_ep_device *otx_ep); int otx_ep_mbox_get_max_pkt_len(struct rte_eth_dev *eth_dev); -int otx_ep_mbox_version_check(struct rte_eth_dev *eth_dev); int otx_ep_mbox_send_dev_exit(struct rte_eth_dev *eth_dev); +int otx_ep_mbox_init(struct rte_eth_dev *eth_dev); +void otx_ep_mbox_uninit(struct rte_eth_dev *eth_dev); #endif