From: Qi Zhang <qi.z.zhang@intel.com>
To: qiming.yang@intel.com
Cc: junfeng.guo@intel.com, dev@dpdk.org, Qi Zhang <qi.z.zhang@intel.com>
Subject: [dpdk-dev] [PATCH 11/20] net/ice/base: add parser runtime skeleton
Date: Fri, 17 Sep 2021 19:02:33 +0800 [thread overview]
Message-ID: <20210917110242.3127658-12-qi.z.zhang@intel.com> (raw)
In-Reply-To: <20210917110242.3127658-1-qi.z.zhang@intel.com>
Add parser runtime data struct ice_parser_rt.
Add below APIs for parser runtime preparation:
ice_parser_rt_reset
ice_parser_rt_pkt_buf_set
Add below API skeleton for parser runtime execution:
ice_parser_rt_execute
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
---
drivers/net/ice/base/ice_parser.c | 39 +++++++++++
drivers/net/ice/base/ice_parser.h | 24 +++++++
drivers/net/ice/base/ice_parser_rt.c | 98 ++++++++++++++++++++++++++++
drivers/net/ice/base/ice_parser_rt.h | 28 ++++++++
drivers/net/ice/base/meson.build | 1 +
5 files changed, 190 insertions(+)
create mode 100644 drivers/net/ice/base/ice_parser_rt.c
create mode 100644 drivers/net/ice/base/ice_parser_rt.h
diff --git a/drivers/net/ice/base/ice_parser.c b/drivers/net/ice/base/ice_parser.c
index 0b79b62e04..a0c5c9989d 100644
--- a/drivers/net/ice/base/ice_parser.c
+++ b/drivers/net/ice/base/ice_parser.c
@@ -167,6 +167,8 @@ enum ice_status ice_parser_create(struct ice_hw *hw, struct ice_parser **psr)
struct ice_parser *p;
p = (struct ice_parser *)ice_malloc(hw, sizeof(struct ice_parser));
+ p->hw = hw;
+ p->rt.psr = p;
if (!p)
return ICE_ERR_NO_MEMORY;
@@ -301,3 +303,40 @@ void ice_parser_destroy(struct ice_parser *psr)
ice_free(psr->hw, psr);
}
+
+/**
+ * ice_parser_run - parse on a packet in binary and return the result
+ * @psr: pointer to a parser instance
+ * @pkt_buf: packet data
+ * @pkt_len: packet length
+ * @rslt: input/output parameter to save parser result.
+ */
+enum ice_status ice_parser_run(struct ice_parser *psr, const u8 *pkt_buf,
+ int pkt_len, struct ice_parser_result *rslt)
+{
+ ice_parser_rt_reset(&psr->rt);
+ ice_parser_rt_pktbuf_set(&psr->rt, pkt_buf, pkt_len);
+
+ return ice_parser_rt_execute(&psr->rt, rslt);
+}
+
+/**
+ * ice_parser_result_dump - dump a parser result info
+ * @hw: pointer to the hardware structure
+ * @rslt: parser result info to dump
+ */
+void ice_parser_result_dump(struct ice_hw *hw, struct ice_parser_result *rslt)
+{
+ int i;
+
+ ice_info(hw, "ptype = %d\n", rslt->ptype);
+ for (i = 0; i < rslt->po_num; i++)
+ ice_info(hw, "proto = %d, offset = %d\n",
+ rslt->po[i].proto_id, rslt->po[i].offset);
+
+ ice_info(hw, "flags_psr = 0x%016" PRIx64 "\n", rslt->flags_psr);
+ ice_info(hw, "flags_pkt = 0x%016" PRIx64 "\n", rslt->flags_pkt);
+ ice_info(hw, "flags_sw = 0x%04x\n", rslt->flags_sw);
+ ice_info(hw, "flags_fd = 0x%04x\n", rslt->flags_fd);
+ ice_info(hw, "flags_rss = 0x%04x\n", rslt->flags_rss);
+}
diff --git a/drivers/net/ice/base/ice_parser.h b/drivers/net/ice/base/ice_parser.h
index 89cd714fbd..3a307e0344 100644
--- a/drivers/net/ice/base/ice_parser.h
+++ b/drivers/net/ice/base/ice_parser.h
@@ -14,6 +14,7 @@
#include "ice_proto_grp.h"
#include "ice_flg_rd.h"
#include "ice_xlt_kb.h"
+#include "ice_parser_rt.h"
struct ice_parser {
struct ice_hw *hw; /* pointer to the hardware structure */
@@ -50,8 +51,31 @@ struct ice_parser {
struct ice_xlt_kb *xlt_kb_fd;
/* load data from section ICE_SID_XLT_KEY_BUILDER_RSS */
struct ice_xlt_kb *xlt_kb_rss;
+ struct ice_parser_rt rt; /* parser runtime */
};
enum ice_status ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
void ice_parser_destroy(struct ice_parser *psr);
+
+struct ice_parser_proto_off {
+ u8 proto_id; /* hardware protocol ID */
+ u16 offset; /* offset where the protocol header start */
+};
+
+struct ice_parser_result {
+ u16 ptype; /* 16 bits hardware PTYPE */
+ /* protocol and header offset pairs */
+ struct ice_parser_proto_off po[16];
+ int po_num; /* number of pairs must <= 16 */
+ u64 flags_psr; /* 64 bits parser flags */
+ u64 flags_pkt; /* 64 bits packet flags */
+ u16 flags_sw; /* 16 bits key builder flag for SW */
+ u16 flags_acl; /* 16 bits key builder flag for ACL */
+ u16 flags_fd; /* 16 bits key builder flag for FD */
+ u16 flags_rss; /* 16 bits key builder flag for RSS */
+};
+
+enum ice_status ice_parser_run(struct ice_parser *psr, const u8 *pkt_buf,
+ int pkt_len, struct ice_parser_result *rslt);
+void ice_parser_result_dump(struct ice_hw *hw, struct ice_parser_result *rslt);
#endif /* _ICE_PARSER_H_ */
diff --git a/drivers/net/ice/base/ice_parser_rt.c b/drivers/net/ice/base/ice_parser_rt.c
new file mode 100644
index 0000000000..d62d0170e5
--- /dev/null
+++ b/drivers/net/ice/base/ice_parser_rt.c
@@ -0,0 +1,98 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2001-2021 Intel Corporation
+ */
+
+#include "ice_common.h"
+
+#define GPR_HB_IDX 64
+#define GPR_ERR_IDX 84
+#define GPR_FLG_IDX 104
+#define GPR_TSR_IDX 108
+#define GPR_NN_IDX 109
+#define GPR_HO_IDX 110
+#define GPR_NP_IDX 111
+
+static void _rt_tsr_set(struct ice_parser_rt *rt, u16 tsr)
+{
+ rt->gpr[GPR_TSR_IDX] = tsr;
+}
+
+static void _rt_ho_set(struct ice_parser_rt *rt, u16 ho)
+{
+ rt->gpr[GPR_HO_IDX] = ho;
+ ice_memcpy(&rt->gpr[GPR_HB_IDX], &rt->pkt_buf[ho], 32,
+ ICE_NONDMA_TO_NONDMA);
+}
+
+static void _rt_np_set(struct ice_parser_rt *rt, u16 pc)
+{
+ rt->gpr[GPR_NP_IDX] = pc;
+}
+
+static void _rt_nn_set(struct ice_parser_rt *rt, u16 node)
+{
+ rt->gpr[GPR_NN_IDX] = node;
+}
+
+static void _rt_flag_set(struct ice_parser_rt *rt, int idx)
+{
+ int y = idx / 16;
+ int x = idx % 16;
+
+ rt->gpr[GPR_FLG_IDX + y] |= (u16)(1 << x);
+}
+
+/**
+ * ice_parser_rt_reset - reset the parser runtime
+ * @rt: pointer to the parser runtime
+ */
+void ice_parser_rt_reset(struct ice_parser_rt *rt)
+{
+ struct ice_parser *psr = rt->psr;
+ struct ice_metainit_item *mi = &psr->mi_table[0];
+ int i;
+
+ ice_memset(rt, 0, sizeof(*rt), ICE_NONDMA_MEM);
+
+ _rt_tsr_set(rt, mi->tsr);
+ _rt_ho_set(rt, mi->ho);
+ _rt_np_set(rt, mi->pc);
+ _rt_nn_set(rt, mi->pg_rn);
+
+ for (i = 0; i < 64; i++) {
+ if ((mi->flags & (1ul << i)) != 0ul)
+ _rt_flag_set(rt, i);
+ }
+
+ rt->psr = psr;
+}
+
+/**
+ * ice_parser_rt_pktbuf_set - set a packet into parser runtime
+ * @rt: pointer to the parser runtime
+ * @pkt_buf: buffer with packet data
+ * @pkt_len: packet buffer length
+ */
+void ice_parser_rt_pktbuf_set(struct ice_parser_rt *rt, const u8 *pkt_buf,
+ int pkt_len)
+{
+ int len = min(ICE_PARSER_MAX_PKT_LEN, pkt_len);
+ u16 ho = rt->gpr[GPR_HO_IDX];
+
+ ice_memcpy(rt->pkt_buf, pkt_buf, len, ICE_NONDMA_TO_NONDMA);
+ rt->pkt_len = pkt_len;
+
+ ice_memcpy(&rt->gpr[GPR_HB_IDX], &rt->pkt_buf[ho], 32,
+ ICE_NONDMA_TO_NONDMA);
+}
+
+/**
+ * ice_parser_rt_execute - parser execution routine
+ * @rt: pointer to the parser runtime
+ * @rslt: input/output parameter to save parser result
+ */
+enum ice_status ice_parser_rt_execute(struct ice_parser_rt *rt,
+ struct ice_parser_result *rslt)
+{
+ return ICE_ERR_NOT_IMPL;
+}
diff --git a/drivers/net/ice/base/ice_parser_rt.h b/drivers/net/ice/base/ice_parser_rt.h
new file mode 100644
index 0000000000..32fa7f6579
--- /dev/null
+++ b/drivers/net/ice/base/ice_parser_rt.h
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2001-2021 Intel Corporation
+ */
+
+#ifndef _ICE_PARSER_RT_H_
+#define _ICE_PARSER_RT_H_
+
+struct ice_parser_ctx;
+
+#define ICE_PARSER_MAX_PKT_LEN 504
+#define ICE_PARSER_GPR_NUM 128
+
+struct ice_parser_rt {
+ struct ice_parser *psr;
+ u16 gpr[ICE_PARSER_GPR_NUM];
+ u8 pkt_buf[ICE_PARSER_MAX_PKT_LEN + 32];
+ u16 pkt_len;
+ u16 po;
+};
+
+void ice_parser_rt_reset(struct ice_parser_rt *rt);
+void ice_parser_rt_pktbuf_set(struct ice_parser_rt *rt, const u8 *pkt_buf,
+ int pkt_len);
+
+struct ice_parser_result;
+enum ice_status ice_parser_rt_execute(struct ice_parser_rt *rt,
+ struct ice_parser_result *rslt);
+#endif /* _ICE_PARSER_RT_H_ */
diff --git a/drivers/net/ice/base/meson.build b/drivers/net/ice/base/meson.build
index 35f2ac2312..c4fd1b96c6 100644
--- a/drivers/net/ice/base/meson.build
+++ b/drivers/net/ice/base/meson.build
@@ -25,6 +25,7 @@ sources = [
'ice_proto_grp.c',
'ice_flg_rd.c',
'ice_xlt_kb.c',
+ 'ice_parser_rt.c',
]
error_cflags = [
--
2.26.2
next prev parent reply other threads:[~2021-09-17 11:01 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-17 11:02 [dpdk-dev] [PATCH 00/20] ice/base: add parser module Qi Zhang
2021-09-17 11:02 ` [dpdk-dev] [PATCH 01/20] net/ice/base: add parser create and destroy skeleton Qi Zhang
2021-09-17 11:02 ` [dpdk-dev] [PATCH 02/20] net/ice/base: init imem table for parser Qi Zhang
2021-09-17 11:02 ` [dpdk-dev] [PATCH 03/20] net/ice/base: init metainit " Qi Zhang
2021-09-17 11:02 ` [dpdk-dev] [PATCH 04/20] net/ice/base: init parse graph cam " Qi Zhang
2021-09-17 11:02 ` [dpdk-dev] [PATCH 05/20] net/ice/base: init boost TCAM " Qi Zhang
2021-09-17 11:02 ` [dpdk-dev] [PATCH 06/20] net/ice/base: init ptype marker " Qi Zhang
2021-09-17 11:02 ` [dpdk-dev] [PATCH 07/20] net/ice/base: init marker group " Qi Zhang
2021-09-17 11:02 ` [dpdk-dev] [PATCH 08/20] net/ice/base: init protocol " Qi Zhang
2021-09-17 11:02 ` [dpdk-dev] [PATCH 09/20] net/ice/base: init flag redirect " Qi Zhang
2021-09-17 11:02 ` [dpdk-dev] [PATCH 10/20] net/ice/base: init XLT key builder " Qi Zhang
2021-09-17 11:02 ` Qi Zhang [this message]
2021-09-17 11:02 ` [dpdk-dev] [PATCH 12/20] net/ice/base: add helper function for boost TCAM match Qi Zhang
2021-09-17 11:02 ` [dpdk-dev] [PATCH 13/20] net/ice/base: add helper functions for parse graph key matching Qi Zhang
2021-09-17 11:02 ` [dpdk-dev] [PATCH 14/20] net/ice/base: add helper function for ptype markers match Qi Zhang
2021-09-17 11:02 ` [dpdk-dev] [PATCH 15/20] net/ice/base: add helper function to redirect flags Qi Zhang
2021-09-17 11:02 ` [dpdk-dev] [PATCH 16/20] net/ice/base: add helper function to aggregate flags Qi Zhang
2021-09-17 11:02 ` [dpdk-dev] [PATCH 17/20] net/ice/base: add parser execution main loop Qi Zhang
2021-09-17 11:02 ` [dpdk-dev] [PATCH 18/20] net/ice/base: support double VLAN mode configure for parser Qi Zhang
2021-09-17 11:02 ` [dpdk-dev] [PATCH 19/20] net/ice/base: add tunnel port support " Qi Zhang
2021-09-17 11:02 ` [dpdk-dev] [PATCH 20/20] net/ice/base: add API for parser profile initialization Qi Zhang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210917110242.3127658-12-qi.z.zhang@intel.com \
--to=qi.z.zhang@intel.com \
--cc=dev@dpdk.org \
--cc=junfeng.guo@intel.com \
--cc=qiming.yang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).