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 4DE4545BB0; Wed, 23 Oct 2024 14:03:38 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 35EB942E64; Wed, 23 Oct 2024 14:00:42 +0200 (CEST) Received: from inva021.nxp.com (inva021.nxp.com [92.121.34.21]) by mails.dpdk.org (Postfix) with ESMTP id 8E522427AF for ; Wed, 23 Oct 2024 14:00:10 +0200 (CEST) Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 6DBE6202569; Wed, 23 Oct 2024 14:00:10 +0200 (CEST) Received: from aprdc01srsp001v.ap-rdc01.nxp.com (aprdc01srsp001v.ap-rdc01.nxp.com [165.114.16.16]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 3EB8220255D; Wed, 23 Oct 2024 14:00:10 +0200 (CEST) Received: from lsv03379.swis.in-blr01.nxp.com (lsv03379.swis.in-blr01.nxp.com [92.120.147.188]) by aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id A9CBA183DC04; Wed, 23 Oct 2024 20:00:09 +0800 (+08) From: vanshika.shukla@nxp.com To: dev@dpdk.org, Hemant Agrawal , Sachin Saxena Cc: Jun Yang , Vanshika Shukla Subject: [v5 31/42] net/dpaa2: check if Soft parser is loaded Date: Wed, 23 Oct 2024 17:29:44 +0530 Message-Id: <20241023115955.1207617-32-vanshika.shukla@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241023115955.1207617-1-vanshika.shukla@nxp.com> References: <20241022191256.516818-1-vanshika.shukla@nxp.com> <20241023115955.1207617-1-vanshika.shukla@nxp.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Virus-Scanned: ClamAV using ClamSMTP 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 From: Jun Yang Access sp instruction area to check if sp is loaded. Signed-off-by: Jun Yang Signed-off-by: Vanshika Shukla --- drivers/net/dpaa2/dpaa2_ethdev.c | 4 ++ drivers/net/dpaa2/dpaa2_ethdev.h | 2 + drivers/net/dpaa2/dpaa2_flow.c | 88 ++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+) diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c index 187b648799..da0ea57ed2 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.c +++ b/drivers/net/dpaa2/dpaa2_ethdev.c @@ -2861,6 +2861,10 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev) return ret; } } + + ret = dpaa2_soft_parser_loaded(); + if (ret > 0) + DPAA2_PMD_INFO("soft parser is loaded"); DPAA2_PMD_INFO("%s: netdev created, connected to %s", eth_dev->data->name, dpaa2_dev->ep_name); diff --git a/drivers/net/dpaa2/dpaa2_ethdev.h b/drivers/net/dpaa2/dpaa2_ethdev.h index eaa653d266..db918725a7 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.h +++ b/drivers/net/dpaa2/dpaa2_ethdev.h @@ -479,6 +479,8 @@ int dpaa2_timesync_read_tx_timestamp(struct rte_eth_dev *dev, int dpaa2_dev_recycle_config(struct rte_eth_dev *eth_dev); int dpaa2_dev_recycle_deconfig(struct rte_eth_dev *eth_dev); +int dpaa2_soft_parser_loaded(void); + int dpaa2_dev_recycle_qp_setup(struct rte_dpaa2_device *dpaa2_dev, uint16_t qidx, uint64_t cntx, eth_rx_burst_t tx_lpbk, eth_tx_burst_t rx_lpbk, diff --git a/drivers/net/dpaa2/dpaa2_flow.c b/drivers/net/dpaa2/dpaa2_flow.c index c7c3681005..58ea0f578f 100644 --- a/drivers/net/dpaa2/dpaa2_flow.c +++ b/drivers/net/dpaa2/dpaa2_flow.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -24,6 +25,7 @@ static char *dpaa2_flow_control_log; static uint16_t dpaa2_flow_miss_flow_id; /* Default miss flow id is 0. */ +static int dpaa2_sp_loaded = -1; enum dpaa2_flow_entry_size { DPAA2_FLOW_ENTRY_MIN_SIZE = (DPNI_MAX_KEY_SIZE / 2), @@ -397,6 +399,92 @@ dpaa2_flow_fs_entry_log(const char *log_info, DPAA2_FLOW_DUMP("\r\n"); } +/** For LX2160A, LS2088A and LS1088A*/ +#define WRIOP_CCSR_BASE 0x8b80000 +#define WRIOP_CCSR_CTLU_OFFSET 0 +#define WRIOP_CCSR_CTLU_PARSER_OFFSET 0 +#define WRIOP_CCSR_CTLU_PARSER_INGRESS_OFFSET 0 + +#define WRIOP_INGRESS_PARSER_PHY \ + (WRIOP_CCSR_BASE + WRIOP_CCSR_CTLU_OFFSET + \ + WRIOP_CCSR_CTLU_PARSER_OFFSET + \ + WRIOP_CCSR_CTLU_PARSER_INGRESS_OFFSET) + +struct dpaa2_parser_ccsr { + uint32_t psr_cfg; + uint32_t psr_idle; + uint32_t psr_pclm; + uint8_t psr_ver_min; + uint8_t psr_ver_maj; + uint8_t psr_id1_l; + uint8_t psr_id1_h; + uint32_t psr_rev2; + uint8_t rsv[0x2c]; + uint8_t sp_ins[4032]; +}; + +int +dpaa2_soft_parser_loaded(void) +{ + int fd, i, ret = 0; + struct dpaa2_parser_ccsr *parser_ccsr = NULL; + + dpaa2_flow_control_log = getenv("DPAA2_FLOW_CONTROL_LOG"); + + if (dpaa2_sp_loaded >= 0) + return dpaa2_sp_loaded; + + fd = open("/dev/mem", O_RDWR | O_SYNC); + if (fd < 0) { + DPAA2_PMD_ERR("open \"/dev/mem\" ERROR(%d)", fd); + ret = fd; + goto exit; + } + + parser_ccsr = mmap(NULL, sizeof(struct dpaa2_parser_ccsr), + PROT_READ | PROT_WRITE, MAP_SHARED, fd, + WRIOP_INGRESS_PARSER_PHY); + if (!parser_ccsr) { + DPAA2_PMD_ERR("Map 0x%" PRIx64 "(size=0x%x) failed", + (uint64_t)WRIOP_INGRESS_PARSER_PHY, + (uint32_t)sizeof(struct dpaa2_parser_ccsr)); + ret = -ENOBUFS; + goto exit; + } + + DPAA2_PMD_INFO("Parser ID:0x%02x%02x, Rev:major(%02x), minor(%02x)", + parser_ccsr->psr_id1_h, parser_ccsr->psr_id1_l, + parser_ccsr->psr_ver_maj, parser_ccsr->psr_ver_min); + + if (dpaa2_flow_control_log) { + for (i = 0; i < 64; i++) { + DPAA2_FLOW_DUMP("%02x ", + parser_ccsr->sp_ins[i]); + if (!((i + 1) % 16)) + DPAA2_FLOW_DUMP("\r\n"); + } + } + + for (i = 0; i < 16; i++) { + if (parser_ccsr->sp_ins[i]) { + dpaa2_sp_loaded = 1; + break; + } + } + if (dpaa2_sp_loaded < 0) + dpaa2_sp_loaded = 0; + + ret = dpaa2_sp_loaded; + +exit: + if (parser_ccsr) + munmap(parser_ccsr, sizeof(struct dpaa2_parser_ccsr)); + if (fd >= 0) + close(fd); + + return ret; +} + static int dpaa2_flow_ip_address_extract(enum net_prot prot, uint32_t field) -- 2.25.1