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 6825BA0546; Tue, 6 Apr 2021 13:45:01 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E97EC14100E; Tue, 6 Apr 2021 13:42:49 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 011FC140E3B for ; Tue, 6 Apr 2021 13:42:47 +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 136Bdw7k008331 for ; Tue, 6 Apr 2021 04:42:47 -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=0uHEb36YNy2INPZF6vhDzBoxsprsSGt3k4taxI9GlsQ=; b=aqU6VyZn8kimUCgMUFIg78dhbMvn9wwUc7kaVmyxj09vE83pzjXexBJmSC6f+UhrruZt IPPt1afjMy3QTqcHI3kJy+3gEDEJvzUcE91QOs1ProylzGINaunIX3M6SypQt/XfKkPU kT/S2jE5WT/8wfR92yud4qzNYUK9T5VnZODT6pM+5bONZgTIn5nejLMscKXv0nsjAQw6 1r8tm/ap9O5TFPtUdNr1zZEqs+Rt0fz4xyMtvva0/4VZrBgfr/WPhgrX+Kc9BkYYiaq7 3OiND3wWBgkT/rf5viwjsXhw73C3tU4IgCM1VJrtQ60VeLFJgLkGTW7oAbWDAvFrD858 yg== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com with ESMTP id 37r72p2dr2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Tue, 06 Apr 2021 04:42:46 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 6 Apr 2021 04:42:45 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 6 Apr 2021 04:42:45 -0700 Received: from hyd1588t430.marvell.com (unknown [10.29.52.204]) by maili.marvell.com (Postfix) with ESMTP id 8F25F3F703F; Tue, 6 Apr 2021 04:42:42 -0700 (PDT) From: Nithin Dabilpuram To: CC: , , , , , , Date: Tue, 6 Apr 2021 17:11:01 +0530 Message-ID: <20210406114131.25874-23-ndabilpuram@marvell.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20210406114131.25874-1-ndabilpuram@marvell.com> References: <20210305133918.8005-1-ndabilpuram@marvell.com> <20210406114131.25874-1-ndabilpuram@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-GUID: 5ECJvjGoAQUbXtyiqvqfxwSWR9qeABBZ X-Proofpoint-ORIG-GUID: 5ECJvjGoAQUbXtyiqvqfxwSWR9qeABBZ X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369, 18.0.761 definitions=2021-04-06_02:2021-04-01, 2021-04-06 signatures=0 Subject: [dpdk-dev] [PATCH v4 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 b9da55b..f216d4a 100644 --- a/drivers/common/cnxk/meson.build +++ b/drivers/common/cnxk/meson.build @@ -18,6 +18,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 66e0bfa..638f827 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..87d083e --- /dev/null +++ b/drivers/common/cnxk/roc_nix_mcast.c @@ -0,0 +1,98 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2021 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..c0666c8 --- /dev/null +++ b/drivers/common/cnxk/roc_nix_npc.c @@ -0,0 +1,103 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2021 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 1f41a88..bc6c988 100644 --- a/drivers/common/cnxk/version.map +++ b/drivers/common/cnxk/version.map @@ -45,6 +45,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