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 99E59A0547; Fri, 5 Mar 2021 14:43:40 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 990DD22A3D2; Fri, 5 Mar 2021 14:40:38 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 963D722A3D5 for ; Fri, 5 Mar 2021 14:40:37 +0100 (CET) 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 125DUoCN018454 for ; Fri, 5 Mar 2021 05:40:36 -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=7NkZluPMYVjaCvs+v5oUUTbbX3L04uwa0K/FHpR/h6c=; b=NchE61delwziFgskF9XwIMlBddyOOyGjWg4BiDyx60lfdAKU91on7sQkIL8prtimTUnn yX5gv3Qe/yIIuEKS1LhReebh3HwZPQpafnMcnVaStSxRK9n3Hn62JydFiTOFxclSHTr2 lL1D7I3u+/0ZFEBzl2THZ+aX959lpKRQSRqGJhzeHOJLuFox4/LMAMKXhwpQWGDGTvBp mz+a/8ju+WaF/rscII2UeUfpvk8M4Wce1eUWYuT5M+Nt8v7jw1G43MkTPOtb+s0Gl36Z +jXodE3/R2RyzKtShmBTL2szSfRkOW++t+0HItuNuCeYkl8dUqqqZQXBc2vSY1I2OpV+ Sg== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com with ESMTP id 372s2umrnr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Fri, 05 Mar 2021 05:40:36 -0800 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.2; Fri, 5 Mar 2021 05:40:35 -0800 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.2 via Frontend Transport; Fri, 5 Mar 2021 05:40:35 -0800 Received: from hyd1588t430.marvell.com (unknown [10.29.52.204]) by maili.marvell.com (Postfix) with ESMTP id 7F8853F7043; Fri, 5 Mar 2021 05:40:32 -0800 (PST) From: Nithin Dabilpuram To: CC: , , , , , , Date: Fri, 5 Mar 2021 19:08:48 +0530 Message-ID: <20210305133918.8005-23-ndabilpuram@marvell.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20210305133918.8005-1-ndabilpuram@marvell.com> References: <20210305133918.8005-1-ndabilpuram@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369, 18.0.761 definitions=2021-03-05_08:2021-03-03, 2021-03-05 signatures=0 Subject: [dpdk-dev] [PATCH 22/52] common/cnxk: add nix specific npc operations 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" From: Sunil Kumar Kori Add NIX specific NPC operations such as NPC mac address get/set, mcast entry add/delete, promiscuous mode enable/disable etc. Signed-off-by: Sunil Kumar Kori --- drivers/common/cnxk/meson.build | 2 + drivers/common/cnxk/roc_nix.h | 25 +++++++++ drivers/common/cnxk/roc_nix_mcast.c | 98 ++++++++++++++++++++++++++++++++++ drivers/common/cnxk/roc_nix_npc.c | 103 ++++++++++++++++++++++++++++++++++++ drivers/common/cnxk/version.map | 9 ++++ 5 files changed, 237 insertions(+) create mode 100644 drivers/common/cnxk/roc_nix_mcast.c create mode 100644 drivers/common/cnxk/roc_nix_npc.c diff --git a/drivers/common/cnxk/meson.build b/drivers/common/cnxk/meson.build index 21d9ad3..bde5728 100644 --- a/drivers/common/cnxk/meson.build +++ b/drivers/common/cnxk/meson.build @@ -19,6 +19,8 @@ sources = files('roc_dev.c', 'roc_nix.c', 'roc_nix_irq.c', 'roc_nix_mac.c', + 'roc_nix_mcast.c', + 'roc_nix_npc.c', 'roc_nix_queue.c', 'roc_npa.c', 'roc_npa_debug.c', diff --git a/drivers/common/cnxk/roc_nix.h b/drivers/common/cnxk/roc_nix.h index a2910b8..ccb31be 100644 --- a/drivers/common/cnxk/roc_nix.h +++ b/drivers/common/cnxk/roc_nix.h @@ -193,6 +193,18 @@ int __roc_api roc_nix_mac_link_cb_register(struct roc_nix *roc_nix, link_status_t link_update); void __roc_api roc_nix_mac_link_cb_unregister(struct roc_nix *roc_nix); +/* NPC */ +int __roc_api roc_nix_npc_promisc_ena_dis(struct roc_nix *roc_nix, int enable); + +int __roc_api roc_nix_npc_mac_addr_set(struct roc_nix *roc_nix, uint8_t addr[]); + +int __roc_api roc_nix_npc_mac_addr_get(struct roc_nix *roc_nix, uint8_t *addr); + +int __roc_api roc_nix_npc_rx_ena_dis(struct roc_nix *roc_nix, bool enable); + +int __roc_api roc_nix_npc_mcast_config(struct roc_nix *roc_nix, + bool mcast_enable, bool prom_enable); + /* Queue */ int __roc_api roc_nix_rq_init(struct roc_nix *roc_nix, struct roc_nix_rq *rq, bool ena); @@ -205,4 +217,17 @@ int __roc_api roc_nix_cq_fini(struct roc_nix_cq *cq); int __roc_api roc_nix_sq_init(struct roc_nix *roc_nix, struct roc_nix_sq *sq); int __roc_api roc_nix_sq_fini(struct roc_nix_sq *sq); +/* MCAST*/ +int __roc_api roc_nix_mcast_mcam_entry_alloc(struct roc_nix *roc_nix, + uint16_t nb_entries, + uint8_t priority, + uint16_t index[]); +int __roc_api roc_nix_mcast_mcam_entry_free(struct roc_nix *roc_nix, + uint32_t index); +int __roc_api roc_nix_mcast_mcam_entry_write(struct roc_nix *roc_nix, + struct mcam_entry *entry, + uint32_t index, uint8_t intf, + uint64_t action); +int __roc_api roc_nix_mcast_mcam_entry_ena_dis(struct roc_nix *roc_nix, + uint32_t index, bool enable); #endif /* _ROC_NIX_H_ */ diff --git a/drivers/common/cnxk/roc_nix_mcast.c b/drivers/common/cnxk/roc_nix_mcast.c new file mode 100644 index 0000000..51576cf --- /dev/null +++ b/drivers/common/cnxk/roc_nix_mcast.c @@ -0,0 +1,98 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2019 Marvell. + */ + +#include "roc_api.h" +#include "roc_priv.h" + +static inline struct mbox * +get_mbox(struct roc_nix *roc_nix) +{ + struct nix *nix = roc_nix_to_nix_priv(roc_nix); + struct dev *dev = &nix->dev; + + return dev->mbox; +} + +int +roc_nix_mcast_mcam_entry_alloc(struct roc_nix *roc_nix, uint16_t nb_entries, + uint8_t priority, uint16_t index[]) +{ + struct mbox *mbox = get_mbox(roc_nix); + struct npc_mcam_alloc_entry_req *req; + struct npc_mcam_alloc_entry_rsp *rsp; + int rc = -ENOSPC, i; + + req = mbox_alloc_msg_npc_mcam_alloc_entry(mbox); + if (req == NULL) + return rc; + req->priority = priority; + req->count = nb_entries; + + rc = mbox_process_msg(mbox, (void *)&rsp); + if (rc) + return rc; + + for (i = 0; i < rsp->count; i++) + index[i] = rsp->entry_list[i]; + + return rsp->count; +} + +int +roc_nix_mcast_mcam_entry_free(struct roc_nix *roc_nix, uint32_t index) +{ + struct mbox *mbox = get_mbox(roc_nix); + struct npc_mcam_free_entry_req *req; + int rc = -ENOSPC; + + req = mbox_alloc_msg_npc_mcam_free_entry(mbox); + if (req == NULL) + return rc; + req->entry = index; + + return mbox_process_msg(mbox, NULL); +} + +int +roc_nix_mcast_mcam_entry_write(struct roc_nix *roc_nix, + struct mcam_entry *entry, uint32_t index, + uint8_t intf, uint64_t action) +{ + struct mbox *mbox = get_mbox(roc_nix); + struct npc_mcam_write_entry_req *req; + int rc = -ENOSPC; + + req = mbox_alloc_msg_npc_mcam_write_entry(mbox); + if (req == NULL) + return rc; + req->entry = index; + req->intf = intf; + req->enable_entry = true; + mbox_memcpy(&req->entry_data, entry, sizeof(struct mcam_entry)); + req->entry_data.action = action; + + return mbox_process(mbox); +} + +int +roc_nix_mcast_mcam_entry_ena_dis(struct roc_nix *roc_nix, uint32_t index, + bool enable) +{ + struct npc_mcam_ena_dis_entry_req *req; + struct mbox *mbox = get_mbox(roc_nix); + int rc = -ENOSPC; + + if (enable) { + req = mbox_alloc_msg_npc_mcam_ena_entry(mbox); + if (req == NULL) + return rc; + } else { + req = mbox_alloc_msg_npc_mcam_dis_entry(mbox); + if (req == NULL) + return rc; + } + + req->entry = index; + return mbox_process(mbox); +} diff --git a/drivers/common/cnxk/roc_nix_npc.c b/drivers/common/cnxk/roc_nix_npc.c new file mode 100644 index 0000000..6efb19d --- /dev/null +++ b/drivers/common/cnxk/roc_nix_npc.c @@ -0,0 +1,103 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2020 Marvell. + */ + +#include "roc_api.h" +#include "roc_priv.h" + +static inline struct mbox * +get_mbox(struct roc_nix *roc_nix) +{ + struct nix *nix = roc_nix_to_nix_priv(roc_nix); + struct dev *dev = &nix->dev; + + return dev->mbox; +} + +int +roc_nix_npc_promisc_ena_dis(struct roc_nix *roc_nix, int enable) +{ + struct mbox *mbox = get_mbox(roc_nix); + struct nix_rx_mode *req; + int rc = -ENOSPC; + + if (roc_nix_is_vf_or_sdp(roc_nix)) + return NIX_ERR_PARAM; + + req = mbox_alloc_msg_nix_set_rx_mode(mbox); + if (req == NULL) + return rc; + + if (enable) + req->mode = NIX_RX_MODE_UCAST | NIX_RX_MODE_PROMISC; + + return mbox_process(mbox); +} + +int +roc_nix_npc_mac_addr_set(struct roc_nix *roc_nix, uint8_t addr[]) +{ + struct mbox *mbox = get_mbox(roc_nix); + struct nix_set_mac_addr *req; + + req = mbox_alloc_msg_nix_set_mac_addr(mbox); + mbox_memcpy(req->mac_addr, addr, PLT_ETHER_ADDR_LEN); + return mbox_process(mbox); +} + +int +roc_nix_npc_mac_addr_get(struct roc_nix *roc_nix, uint8_t *addr) +{ + struct mbox *mbox = get_mbox(roc_nix); + struct nix_get_mac_addr_rsp *rsp; + int rc; + + mbox_alloc_msg_nix_get_mac_addr(mbox); + rc = mbox_process_msg(mbox, (void *)&rsp); + if (rc) + return rc; + + mbox_memcpy(addr, rsp->mac_addr, PLT_ETHER_ADDR_LEN); + return 0; +} + +int +roc_nix_npc_rx_ena_dis(struct roc_nix *roc_nix, bool enable) +{ + struct mbox *mbox = get_mbox(roc_nix); + int rc; + + if (enable) + mbox_alloc_msg_nix_lf_start_rx(mbox); + else + mbox_alloc_msg_nix_lf_stop_rx(mbox); + + rc = mbox_process(mbox); + if (!rc) + roc_nix->io_enabled = enable; + return rc; +} + +int +roc_nix_npc_mcast_config(struct roc_nix *roc_nix, bool mcast_enable, + bool prom_enable) + +{ + struct mbox *mbox = get_mbox(roc_nix); + struct nix_rx_mode *req; + int rc = -ENOSPC; + + if (roc_nix_is_vf_or_sdp(roc_nix)) + return 0; + + req = mbox_alloc_msg_nix_set_rx_mode(mbox); + if (req == NULL) + return rc; + + if (mcast_enable) + req->mode = NIX_RX_MODE_ALLMULTI; + else if (prom_enable) + req->mode = NIX_RX_MODE_PROMISC; + + return mbox_process(mbox); +} diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map index 4d63514..0649b01 100644 --- a/drivers/common/cnxk/version.map +++ b/drivers/common/cnxk/version.map @@ -46,6 +46,15 @@ INTERNAL { roc_nix_mac_promisc_mode_enable; roc_nix_mac_rxtx_start_stop; roc_nix_max_pkt_len; + roc_nix_mcast_mcam_entry_alloc; + roc_nix_mcast_mcam_entry_ena_dis; + roc_nix_mcast_mcam_entry_free; + roc_nix_mcast_mcam_entry_write; + roc_nix_npc_mac_addr_get; + roc_nix_npc_mac_addr_set; + roc_nix_npc_promisc_ena_dis; + roc_nix_npc_rx_ena_dis; + roc_nix_npc_mcast_config; roc_nix_ras_intr_ena_dis; roc_nix_register_cq_irqs; roc_nix_register_queue_irqs; -- 2.8.4