From patchwork Tue Feb 27 19:15:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harman Kalra X-Patchwork-Id: 137384 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 5709D43C06; Tue, 27 Feb 2024 20:17:31 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 519B142F45; Tue, 27 Feb 2024 20:16:54 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 3718040150 for ; Tue, 27 Feb 2024 20:16:51 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41RFgbCs005488 for ; Tue, 27 Feb 2024 11:16:50 -0800 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=fcWlQZX+nm3UrPPZfNUYJ 5805wrBRNJvdvWb+Y+VbZY=; b=RUs/g/dUu4rA9X/qDZeY6yw4xciKqy6XEMurQ IjcfM1QQjRfq7287w+8o2xOwx2rqS0XXdG8e/LHhsEYH88vi0nh0pRHVVF1XECA/ 2y7InfBkzGiDaDTStAVjW7NbbWf6Qt++KUh8k2nbNltrFZXmQHbZNrcxbgAKnw5S cz3aR2EpCbXaRP1VJYJ+H635xbFoMW50GvTRFYLWPEyGozvObRzx6R9xPu5CJKBm Kt9nBOqyqibrX5mPcfadCzWBESJDhYmTvG+RITrSReaOWEFh/H3umDWVr4SXCzCP ZYOv39w/F9yA2Xbwxv7hPxHxfM9o7ZoJ//TyE9CWQ5FY97OYg== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3whjm694nd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 27 Feb 2024 11:16:50 -0800 (PST) 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.1258.12; Tue, 27 Feb 2024 11:16:37 -0800 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.1258.12 via Frontend Transport; Tue, 27 Feb 2024 11:16:37 -0800 Received: from localhost.localdomain (unknown [10.29.52.211]) by maili.marvell.com (Postfix) with ESMTP id DAE7A3F719D; Tue, 27 Feb 2024 11:16:34 -0800 (PST) From: Harman Kalra To: Nithin Dabilpuram , Kiran Kumar K , Sunil Kumar Kori , Satha Rao , Harman Kalra CC: Subject: [PATCH v4 11/23] common/cnxk: representee notification callback Date: Wed, 28 Feb 2024 00:45:38 +0530 Message-ID: <20240227191550.137687-12-hkalra@marvell.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20240227191550.137687-1-hkalra@marvell.com> References: <20230811163419.165790-1-hkalra@marvell.com> <20240227191550.137687-1-hkalra@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: G8abTdBwJrCcNcrsKdOUvt5uiyGqxk9a X-Proofpoint-GUID: G8abTdBwJrCcNcrsKdOUvt5uiyGqxk9a X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-27_06,2024-02-27_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 Setting up a callback which gets invoked every time a representee comes up or goes down. Later this callback gets handled by network counterpart. Signed-off-by: Harman Kalra --- drivers/common/cnxk/roc_dev.c | 70 ++++++++++++++++++++++++++++++ drivers/common/cnxk/roc_dev_priv.h | 3 ++ drivers/common/cnxk/roc_eswitch.c | 23 ++++++++++ drivers/common/cnxk/roc_eswitch.h | 31 +++++++++++++ drivers/common/cnxk/roc_mbox.c | 2 + drivers/common/cnxk/roc_mbox.h | 19 +++++++- drivers/common/cnxk/version.map | 2 + 7 files changed, 149 insertions(+), 1 deletion(-) diff --git a/drivers/common/cnxk/roc_dev.c b/drivers/common/cnxk/roc_dev.c index 084343c3b4..75fc94e64a 100644 --- a/drivers/common/cnxk/roc_dev.c +++ b/drivers/common/cnxk/roc_dev.c @@ -537,6 +537,75 @@ pf_vf_mbox_send_up_msg(struct dev *dev, void *rec_msg) } } +static int +mbox_up_handler_rep_repte_notify(struct dev *dev, struct rep_repte_req *req, struct msg_rsp *rsp) +{ + struct roc_eswitch_repte_notify_msg *notify_msg; + int rc = 0; + + plt_base_dbg("pf:%d/vf:%d msg id 0x%x (%s) from: pf:%d/vf:%d", dev_get_pf(dev->pf_func), + dev_get_vf(dev->pf_func), req->hdr.id, mbox_id2name(req->hdr.id), + dev_get_pf(req->hdr.pcifunc), dev_get_vf(req->hdr.pcifunc)); + + plt_base_dbg("repte pcifunc %x, enable %d", req->repte_pcifunc, req->enable); + if (dev->ops && dev->ops->repte_notify) { + notify_msg = plt_zmalloc(sizeof(struct roc_eswitch_repte_notify_msg), 0); + if (!notify_msg) { + plt_err("Failed to allocate memory"); + rc = -ENOMEM; + goto fail; + } + notify_msg->type = ROC_ESWITCH_REPTE_STATE; + notify_msg->state.hw_func = req->repte_pcifunc; + notify_msg->state.enable = req->enable; + + rc = dev->ops->repte_notify(dev->roc_nix, (void *)notify_msg); + if (rc < 0) + plt_err("Failed to sent new representee %x notification to %s", + req->repte_pcifunc, (req->enable == true) ? "enable" : "disable"); + + plt_free(notify_msg); + } +fail: + rsp->hdr.rc = rc; + return rc; +} + +static int +mbox_up_handler_rep_set_mtu(struct dev *dev, struct rep_mtu *req, struct msg_rsp *rsp) +{ + struct roc_eswitch_repte_notify_msg *notify_msg; + int rc = 0; + + plt_base_dbg("pf:%d/vf:%d msg id 0x%x (%s) from: pf:%d/vf:%d", dev_get_pf(dev->pf_func), + dev_get_vf(dev->pf_func), req->hdr.id, mbox_id2name(req->hdr.id), + dev_get_pf(req->hdr.pcifunc), dev_get_vf(req->hdr.pcifunc)); + + plt_base_dbg("rep pcifunc %x, rep id %d mtu %d", req->rep_pcifunc, req->rep_id, req->mtu); + if (dev->ops && dev->ops->repte_notify) { + notify_msg = plt_zmalloc(sizeof(struct roc_eswitch_repte_notify_msg), 0); + if (!notify_msg) { + plt_err("Failed to allocate memory"); + rc = -ENOMEM; + goto fail; + } + notify_msg->type = ROC_ESWITCH_REPTE_MTU; + notify_msg->mtu.hw_func = req->rep_pcifunc; + notify_msg->mtu.rep_id = req->rep_id; + notify_msg->mtu.mtu = req->mtu; + + rc = dev->ops->repte_notify(dev->roc_nix, (void *)notify_msg); + if (rc < 0) + plt_err("Failed to send new mtu notification for representee %x ", + req->rep_pcifunc); + + plt_free(notify_msg); + } +fail: + rsp->hdr.rc = rc; + return rc; +} + static int mbox_up_handler_mcs_intr_notify(struct dev *dev, struct mcs_intr_info *info, struct msg_rsp *rsp) { @@ -711,6 +780,7 @@ mbox_process_msgs_up(struct dev *dev, struct mbox_msghdr *req) } MBOX_UP_CGX_MESSAGES MBOX_UP_MCS_MESSAGES + MBOX_UP_REP_MESSAGES #undef M } diff --git a/drivers/common/cnxk/roc_dev_priv.h b/drivers/common/cnxk/roc_dev_priv.h index 5b2c5096f8..50e12cbf17 100644 --- a/drivers/common/cnxk/roc_dev_priv.h +++ b/drivers/common/cnxk/roc_dev_priv.h @@ -36,12 +36,15 @@ typedef void (*q_err_cb_t)(void *roc_nix, void *data); /* Link status get callback */ typedef void (*link_status_get_t)(void *roc_nix, struct cgx_link_user_info *link); +/* Representee notification callback */ +typedef int (*repte_notify_t)(void *roc_nix, void *notify_msg); struct dev_ops { link_info_t link_status_update; ptp_info_t ptp_info_update; link_status_get_t link_status_get; q_err_cb_t q_err_cb; + repte_notify_t repte_notify; }; #define dev_is_vf(dev) ((dev)->hwcap & DEV_HWCAP_F_VF) diff --git a/drivers/common/cnxk/roc_eswitch.c b/drivers/common/cnxk/roc_eswitch.c index 020a891a32..14819bad75 100644 --- a/drivers/common/cnxk/roc_eswitch.c +++ b/drivers/common/cnxk/roc_eswitch.c @@ -319,3 +319,26 @@ roc_eswitch_nix_vlan_tpid_set(struct roc_nix *roc_nix, uint32_t type, uint16_t t return rc; } + +int +roc_eswitch_nix_process_repte_notify_cb_register(struct roc_nix *roc_nix, + process_repte_notify_t proc_repte_nt) +{ + struct nix *nix = roc_nix_to_nix_priv(roc_nix); + struct dev *dev = &nix->dev; + + if (proc_repte_nt == NULL) + return NIX_ERR_PARAM; + + dev->ops->repte_notify = (repte_notify_t)proc_repte_nt; + return 0; +} + +void +roc_eswitch_nix_process_repte_notify_cb_unregister(struct roc_nix *roc_nix) +{ + struct nix *nix = roc_nix_to_nix_priv(roc_nix); + struct dev *dev = &nix->dev; + + dev->ops->repte_notify = NULL; +} diff --git a/drivers/common/cnxk/roc_eswitch.h b/drivers/common/cnxk/roc_eswitch.h index 34b75d10ac..e0df0038d4 100644 --- a/drivers/common/cnxk/roc_eswitch.h +++ b/drivers/common/cnxk/roc_eswitch.h @@ -8,6 +8,34 @@ #define ROC_ESWITCH_VLAN_TPID 0x8100 #define ROC_ESWITCH_LBK_CHAN 63 +typedef enum roc_eswitch_repte_notify_msg_type { + ROC_ESWITCH_REPTE_STATE = 0, + ROC_ESWITCH_REPTE_MTU, +} roc_eswitch_repte_notify_msg_type_t; + +struct roc_eswitch_repte_state { + bool enable; + uint16_t hw_func; +}; + +struct roc_eswitch_repte_mtu { + uint16_t mtu; + uint16_t rep_id; + uint16_t hw_func; +}; + +struct roc_eswitch_repte_notify_msg { + roc_eswitch_repte_notify_msg_type_t type; + union { + struct roc_eswitch_repte_state state; + struct roc_eswitch_repte_mtu mtu; + }; +}; + +/* Process representee notification callback */ +typedef int (*process_repte_notify_t)(void *roc_nix, + struct roc_eswitch_repte_notify_msg *notify_msg); + /* NPC */ int __roc_api roc_eswitch_npc_mcam_rx_rule(struct roc_npc *roc_npc, struct roc_npc_flow *flow, uint16_t pcifunc, uint16_t vlan_tci, @@ -23,4 +51,7 @@ int __roc_api roc_eswitch_npc_rss_action_configure(struct roc_npc *roc_npc, /* NIX */ int __roc_api roc_eswitch_nix_vlan_tpid_set(struct roc_nix *nix, uint32_t type, uint16_t tpid, bool is_vf); +int __roc_api roc_eswitch_nix_process_repte_notify_cb_register(struct roc_nix *roc_nix, + process_repte_notify_t proc_repte_nt); +void __roc_api roc_eswitch_nix_process_repte_notify_cb_unregister(struct roc_nix *roc_nix); #endif /* __ROC_ESWITCH_H__ */ diff --git a/drivers/common/cnxk/roc_mbox.c b/drivers/common/cnxk/roc_mbox.c index 7b734fcd24..10cdbc4d13 100644 --- a/drivers/common/cnxk/roc_mbox.c +++ b/drivers/common/cnxk/roc_mbox.c @@ -499,6 +499,7 @@ mbox_id2name(uint16_t id) return #_name; MBOX_MESSAGES MBOX_UP_CGX_MESSAGES + MBOX_UP_REP_MESSAGES #undef M } } @@ -514,6 +515,7 @@ mbox_id2size(uint16_t id) return sizeof(struct _req_type); MBOX_MESSAGES MBOX_UP_CGX_MESSAGES + MBOX_UP_REP_MESSAGES #undef M } } diff --git a/drivers/common/cnxk/roc_mbox.h b/drivers/common/cnxk/roc_mbox.h index 6df8176f5f..ea09dcc2cf 100644 --- a/drivers/common/cnxk/roc_mbox.h +++ b/drivers/common/cnxk/roc_mbox.h @@ -357,9 +357,13 @@ struct mbox_msghdr { #define MBOX_UP_MCS_MESSAGES M(MCS_INTR_NOTIFY, 0xE00, mcs_intr_notify, mcs_intr_info, msg_rsp) +#define MBOX_UP_REP_MESSAGES \ +M(REP_REPTE_NOTIFY, 0xEF1, rep_repte_notify, rep_repte_req, msg_rsp) \ +M(REP_SET_MTU, 0xEF2, rep_set_mtu, rep_mtu, msg_rsp) + enum { #define M(_name, _id, _1, _2, _3) MBOX_MSG_##_name = _id, - MBOX_MESSAGES MBOX_UP_CGX_MESSAGES MBOX_UP_MCS_MESSAGES + MBOX_MESSAGES MBOX_UP_CGX_MESSAGES MBOX_UP_MCS_MESSAGES MBOX_UP_REP_MESSAGES #undef M }; @@ -2799,4 +2803,17 @@ struct nix_spi_to_sa_delete_req { uint16_t __io hash_index; uint8_t __io way; }; + +struct rep_repte_req { + struct mbox_msghdr hdr; + uint16_t __io repte_pcifunc; + bool __io enable; +}; + +struct rep_mtu { + struct mbox_msghdr hdr; + uint16_t __io rep_pcifunc; + uint16_t __io rep_id; + uint16_t __io mtu; +}; #endif /* __ROC_MBOX_H__ */ diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map index 2ee54c52d7..ebf615f26e 100644 --- a/drivers/common/cnxk/version.map +++ b/drivers/common/cnxk/version.map @@ -91,6 +91,8 @@ INTERNAL { roc_dpi_disable; roc_dpi_enable; roc_error_msg_get; + roc_eswitch_nix_process_repte_notify_cb_register; + roc_eswitch_nix_process_repte_notify_cb_unregister; roc_eswitch_nix_vlan_tpid_set; roc_eswitch_npc_mcam_delete_rule; roc_eswitch_npc_mcam_rx_rule;