From patchwork Thu Apr 1 12:37:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nithin Dabilpuram X-Patchwork-Id: 90394 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 7BB6BA0548; Thu, 1 Apr 2021 14:42:01 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 24F00141228; Thu, 1 Apr 2021 14:39:45 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 9B399141226 for ; Thu, 1 Apr 2021 14:39:43 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 131CPLXb019083 for ; Thu, 1 Apr 2021 05:39:43 -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=Txq0v2SzSj0CQumyu1ihTWORWEHtikNlwekbDnEiKnE=; b=IxIjQONkoM1cgAbrh+PmIUOysz8RpRBW2V2mKHMsKcpm4IaiYwsUb3AC1I5WsoY3rWO7 cRwlehC1vKsQyMG1t8MRXRU0QzJz1hFsUirpAFUBwWGSLI4w2y1ITi317ja+fHr8YqU6 QfmX6ZGjmQklOvBG1OpTqj54U4OCR/gNLwnh1TJwN50fSlXmb6VNpDFp07//nx+CwBPT vSp0VHiimkqajUgoh3hOG8XPOCpO1LsaY/JdVR3FMvrUZ4xGtoFAmOIMMc6hrIigyiul zW7uNhB53xrJv11tmzC/S/FSTRUBu8a1pktahTOgYJnPSPfQNIk//cIGZu9ReXt44UFq ug== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com with ESMTP id 37n28jje2n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 01 Apr 2021 05:39:43 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 1 Apr 2021 05:39:40 -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; Thu, 1 Apr 2021 05:39:40 -0700 Received: from hyd1588t430.marvell.com (unknown [10.29.52.204]) by maili.marvell.com (Postfix) with ESMTP id 75A823F703F; Thu, 1 Apr 2021 05:39:38 -0700 (PDT) From: Nithin Dabilpuram To: CC: , , , , , , Date: Thu, 1 Apr 2021 18:07:47 +0530 Message-ID: <20210401123817.14348-23-ndabilpuram@marvell.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20210401123817.14348-1-ndabilpuram@marvell.com> References: <20210305133918.8005-1-ndabilpuram@marvell.com> <20210401123817.14348-1-ndabilpuram@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: tV6dXv0IUT2_T-XvUhFLpdkUtWguAhHk X-Proofpoint-ORIG-GUID: tV6dXv0IUT2_T-XvUhFLpdkUtWguAhHk X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369, 18.0.761 definitions=2021-04-01_05:2021-03-31, 2021-04-01 signatures=0 Subject: [dpdk-dev] [PATCH v3 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 79500cc..2ca6368 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;