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 CF6AA43036; Fri, 11 Aug 2023 18:35:12 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5B36343260; Fri, 11 Aug 2023 18:35:09 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 264FD40E03 for ; Fri, 11 Aug 2023 18:35:07 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 37BDcIHC011977 for ; Fri, 11 Aug 2023 09:35:06 -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=IZgoVWCM0NOFOxdNquLRTMSrIm0uOU7iZgVi4//FMx8=; b=fmLjvFRqy0y7I9ptbgfNk4crSXmFK4Qts5a2cDObJEOc5A9yowNXfSOdTXQtN9v3l+Ae rT01ivbETUCCwHsukOQUWHhuRM57vk/LH7o6RGDzAnD6aixezplGnBlk9eC1QtaDwWVt 1WTmsyCixK2/s5qoBR2YAoEXnTiFYc3g1ACNYpKuyHTIxpSWo5JUg8QVPzVhsOhxgdFm 77latReSiq0VRsdxrOAWpoD1cAeMILVt4NYUg5mhzVpG6zry7L0awVyjIeAI+ngegxyX /Paq7jjQZqHFgHzu50AC6ASYO7Fwn+abE+ppVnAIjK8xo2ndG0dJWVL3IxSUqc5lbajP ew== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3sd8ya2qs5-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Fri, 11 Aug 2023 09:35:06 -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.48; Fri, 11 Aug 2023 09:35:04 -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.48 via Frontend Transport; Fri, 11 Aug 2023 09:35:04 -0700 Received: from localhost.localdomain (unknown [10.29.52.211]) by maili.marvell.com (Postfix) with ESMTP id 445723F7099; Fri, 11 Aug 2023 09:35:02 -0700 (PDT) From: Harman Kalra To: , Nithin Dabilpuram , "Kiran Kumar K" , Sunil Kumar Kori , Satha Rao CC: , Harman Kalra Subject: [PATCH 4/9] net/cnxk: callbacks for representor state Date: Fri, 11 Aug 2023 22:04:14 +0530 Message-ID: <20230811163419.165790-5-hkalra@marvell.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230811163419.165790-1-hkalra@marvell.com> References: <20230811163419.165790-1-hkalra@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-ORIG-GUID: 8-D_wV6nhYQyF49lEz0uJtGkTQ6Lj3N8 X-Proofpoint-GUID: 8-D_wV6nhYQyF49lEz0uJtGkTQ6Lj3N8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-11_08,2023-08-10_01,2023-05-22_02 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 Implementing the callbacks for processing representor state. Three operations currently supported: - set a representor to be active if its VF is enabled and set it appropriate pf func value. - check if the VF which sent a mbox has a representor - clear representor state if its VF goes down. Signed-off-by: Harman Kalra --- drivers/net/cnxk/cnxk_rep.c | 65 +++++++++++++++++++++++++++++++++++++ drivers/net/cnxk/cnxk_rep.h | 4 +++ 2 files changed, 69 insertions(+) diff --git a/drivers/net/cnxk/cnxk_rep.c b/drivers/net/cnxk/cnxk_rep.c index ebefc34ac8..4dd564058c 100644 --- a/drivers/net/cnxk/cnxk_rep.c +++ b/drivers/net/cnxk/cnxk_rep.c @@ -39,6 +39,7 @@ cnxk_rep_dev_remove(struct rte_eth_dev *pf_ethdev) struct cnxk_eth_dev *pf_dev = cnxk_eth_pmd_priv(pf_ethdev); int rc = 0; + roc_nix_process_rep_state_cb_unregister(&pf_dev->nix); rc = rte_eth_switch_domain_free(pf_dev->switch_domain_id); if (rc) plt_err("Failed to alloc switch domain: %d", rc); @@ -183,6 +184,63 @@ cnxk_rep_dev_init(struct rte_eth_dev *eth_dev, void *params) return 0; } +static int +cnxk_process_representor_status(void *roc_nix, uint16_t pf_func, uint8_t op) +{ + struct cnxk_eth_dev *pf_dev = (struct cnxk_eth_dev *)roc_nix; + struct cnxk_rep_dev *rep_dev = NULL; + struct rte_eth_dev *rep_eth_dev; + uint16_t match = 0, func_val; + bool is_vf_active; + int i, rc = 0; + + if (!pf_dev) { + plt_err("Failed to get PF ethdev handle"); + return -1; + } + + switch (op) { + case 0: /* update pffunc of vf being represented */ + match = 0; + func_val = pf_func; + is_vf_active = true; + break; + case 1: /* check if any representor is representing pffunc */ + match = pf_func; + func_val = pf_func; + is_vf_active = true; + break; + case 2: /* vf is going down, reset rep state */ + match = pf_func; + func_val = 0; + is_vf_active = false; + break; + default: + plt_err("Invalid op received %d pf_func %x", op, pf_func); + return -1; + }; + + for (i = 0; i < pf_dev->num_reps; i++) { + rep_eth_dev = pf_dev->rep_info[i].rep_eth_dev; + if (!rep_eth_dev) { + plt_err("Failed to get rep ethdev handle"); + return -1; + } + + rep_dev = cnxk_rep_pmd_priv(rep_eth_dev); + if (rep_dev->pf_func == match) { + plt_base_dbg("Representor port %d op %d match %d func_val %d vf_active %d", + i, op, match, func_val, is_vf_active); + rep_dev->pf_func = func_val; + rep_dev->is_vf_active = is_vf_active; + rc = 1; + break; + } + } + + return rc; +} + int cnxk_rep_dev_probe(struct rte_pci_device *pci_dev, struct rte_eth_dev *pf_ethdev, struct rte_eth_devargs *eth_da) @@ -256,6 +314,13 @@ cnxk_rep_dev_probe(struct rte_pci_device *pci_dev, struct rte_eth_dev *pf_ethdev pf_dev->num_reps++; } + /* Register up msg callbacks for processing representor information */ + if (roc_nix_process_rep_state_cb_register(&pf_dev->nix, cnxk_process_representor_status)) { + plt_err("Failed to register callback for representor status"); + rc = -EINVAL; + goto err; + } + return 0; err: return rc; diff --git a/drivers/net/cnxk/cnxk_rep.h b/drivers/net/cnxk/cnxk_rep.h index 24adb9649b..e3fc717a58 100644 --- a/drivers/net/cnxk/cnxk_rep.h +++ b/drivers/net/cnxk/cnxk_rep.h @@ -17,6 +17,10 @@ struct cnxk_rep_dev { uint16_t vf_id; uint16_t switch_domain_id; struct rte_eth_dev *parent_dev; + struct rte_mempool *ctrl_chan_pool; + uint16_t rep_xport_vdev; + bool is_vf_active; + uint16_t pf_func; uint8_t mac_addr[RTE_ETHER_ADDR_LEN]; }; -- 2.18.0