From: Junfeng Guo <junfeng.guo@intel•com>
To: intel-wired-lan@lists•osuosl.org
Cc: netdev@vger•kernel.org, anthony.l.nguyen@intel•com,
jesse.brandeburg@intel•com, qi.z.zhang@intel•com,
ivecera@redhat•com, sridhar.samudrala@intel•com,
horms@kernel•org, Junfeng Guo <junfeng.guo@intel•com>
Subject: [PATCH iwl-next v7 10/15] ice: add parser runtime skeleton
Date: Wed, 23 Aug 2023 17:31:53 +0800 [thread overview]
Message-ID: <20230823093158.782802-11-junfeng.guo@intel.com> (raw)
In-Reply-To: <20230823093158.782802-1-junfeng.guo@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: Junfeng Guo <junfeng.guo@intel•com>
---
drivers/net/ethernet/intel/ice/ice_common.h | 2 +
drivers/net/ethernet/intel/ice/ice_parser.c | 40 ++++++++
drivers/net/ethernet/intel/ice/ice_parser.h | 28 ++++++
.../net/ethernet/intel/ice/ice_parser_rt.c | 92 +++++++++++++++++++
.../net/ethernet/intel/ice/ice_parser_rt.h | 40 ++++++++
5 files changed, 202 insertions(+)
create mode 100644 drivers/net/ethernet/intel/ice/ice_parser_rt.c
create mode 100644 drivers/net/ethernet/intel/ice/ice_parser_rt.h
diff --git a/drivers/net/ethernet/intel/ice/ice_common.h b/drivers/net/ethernet/intel/ice/ice_common.h
index 528dde976373..f1d95b644a4e 100644
--- a/drivers/net/ethernet/intel/ice/ice_common.h
+++ b/drivers/net/ethernet/intel/ice/ice_common.h
@@ -20,6 +20,8 @@
#define ICE_SQ_SEND_DELAY_TIME_MS 10
#define ICE_SQ_SEND_MAX_EXECUTE 3
+#define ICE_ERR_NOT_IMPL -1
+
int ice_init_hw(struct ice_hw *hw);
void ice_deinit_hw(struct ice_hw *hw);
int ice_check_reset(struct ice_hw *hw);
diff --git a/drivers/net/ethernet/intel/ice/ice_parser.c b/drivers/net/ethernet/intel/ice/ice_parser.c
index 6499bb774667..1bd1417e32c6 100644
--- a/drivers/net/ethernet/intel/ice/ice_parser.c
+++ b/drivers/net/ethernet/intel/ice/ice_parser.c
@@ -156,6 +156,7 @@ int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr)
return -ENOMEM;
p->hw = hw;
+ p->rt.psr = p;
p->imem_table = ice_imem_table_get(hw);
if (!p->imem_table) {
@@ -285,3 +286,42 @@ void ice_parser_destroy(struct ice_parser *psr)
devm_kfree(ice_hw_to_dev(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.
+ */
+int 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;
+
+ dev_info(ice_hw_to_dev(hw), "ptype = %d\n", rslt->ptype);
+ for (i = 0; i < rslt->po_num; i++)
+ dev_info(ice_hw_to_dev(hw), "proto = %d, offset = %d\n",
+ rslt->po[i].proto_id, rslt->po[i].offset);
+
+ dev_info(ice_hw_to_dev(hw), "flags_psr = 0x%016llx\n",
+ (unsigned long long)rslt->flags_psr);
+ dev_info(ice_hw_to_dev(hw), "flags_pkt = 0x%016llx\n",
+ (unsigned long long)rslt->flags_pkt);
+ dev_info(ice_hw_to_dev(hw), "flags_sw = 0x%04x\n", rslt->flags_sw);
+ dev_info(ice_hw_to_dev(hw), "flags_fd = 0x%04x\n", rslt->flags_fd);
+ dev_info(ice_hw_to_dev(hw), "flags_rss = 0x%04x\n", rslt->flags_rss);
+}
diff --git a/drivers/net/ethernet/intel/ice/ice_parser.h b/drivers/net/ethernet/intel/ice/ice_parser.h
index ca71ef4f50f5..5f98f3031294 100644
--- a/drivers/net/ethernet/intel/ice/ice_parser.h
+++ b/drivers/net/ethernet/intel/ice/ice_parser.h
@@ -13,6 +13,7 @@
#include "ice_proto_grp.h"
#include "ice_flg_rd.h"
#include "ice_xlt_kb.h"
+#include "ice_parser_rt.h"
#define ICE_SEC_DATA_OFFSET 4
#define ICE_SID_RXPARSER_IMEM_ENTRY_SIZE 48
@@ -30,6 +31,8 @@
#define ICE_SEC_LBL_DATA_OFFSET 2
#define ICE_SID_LBL_ENTRY_SIZE 66
+#define ICE_PARSER_PROTO_OFF_PAIR_SIZE 16
+
struct ice_parser {
struct ice_hw *hw; /* pointer to the hardware structure */
@@ -65,8 +68,33 @@ 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 */
};
int 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 from the start of the protocol header */
+};
+
+#define ICE_PARSER_FLAG_PSR_SIZE 8
+
+struct ice_parser_result {
+ u16 ptype; /* 16 bits hardware PTYPE */
+ /* array of protocol and header offset pairs */
+ struct ice_parser_proto_off po[ICE_PARSER_PROTO_OFF_PAIR_SIZE];
+ int po_num; /* # of protocol-offset 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 */
+};
+
+int 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/ethernet/intel/ice/ice_parser_rt.c b/drivers/net/ethernet/intel/ice/ice_parser_rt.c
new file mode 100644
index 000000000000..a6644f4b3324
--- /dev/null
+++ b/drivers/net/ethernet/intel/ice/ice_parser_rt.c
@@ -0,0 +1,92 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) 2023 Intel Corporation */
+
+#include "ice_common.h"
+
+static void _ice_rt_tsr_set(struct ice_parser_rt *rt, u16 tsr)
+{
+ rt->gpr[ICE_GPR_TSR_IDX] = tsr;
+}
+
+static void _ice_rt_ho_set(struct ice_parser_rt *rt, u16 ho)
+{
+ rt->gpr[ICE_GPR_HO_IDX] = ho;
+ memcpy(&rt->gpr[ICE_GPR_HV_IDX], &rt->pkt_buf[ho], ICE_GPR_HV_SIZE);
+}
+
+static void _ice_rt_np_set(struct ice_parser_rt *rt, u16 pc)
+{
+ rt->gpr[ICE_GPR_NP_IDX] = pc;
+}
+
+static void _ice_rt_nn_set(struct ice_parser_rt *rt, u16 node)
+{
+ rt->gpr[ICE_GPR_NN_IDX] = node;
+}
+
+static void _ice_rt_flag_set(struct ice_parser_rt *rt, int idx, bool val)
+{
+ int y = idx / ICE_GPR_FLG_SIZE;
+ int x = idx % ICE_GPR_FLG_SIZE;
+
+ if (val)
+ rt->gpr[ICE_GPR_FLG_IDX + y] |= (u16)BIT(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;
+
+ memset(rt, 0, sizeof(*rt));
+
+ /* TSR: TCAM Search Register */
+ _ice_rt_tsr_set(rt, mi->tsr);
+ /* HO: Next Parsing Cycle Header Offset */
+ _ice_rt_ho_set(rt, mi->ho);
+ /* NP: Next Parsing Cycle */
+ _ice_rt_np_set(rt, mi->pc);
+ /* NN: Next Parsing Cycle Node ID */
+ _ice_rt_nn_set(rt, mi->pg_rn);
+
+ rt->psr = psr;
+
+ for (i = 0; i < ICE_PARSER_FLG_NUM; i++) {
+ if ((mi->flags & BIT(i)) != 0ul)
+ _ice_rt_flag_set(rt, i, true);
+ }
+}
+
+/**
+ * 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[ICE_GPR_HO_IDX];
+
+ memcpy(rt->pkt_buf, pkt_buf, len);
+ rt->pkt_len = pkt_len;
+
+ memcpy(&rt->gpr[ICE_GPR_HV_IDX], &rt->pkt_buf[ho], ICE_GPR_HV_SIZE);
+}
+
+/**
+ * ice_parser_rt_execute - parser execution routine
+ * @rt: pointer to the parser runtime
+ * @rslt: input/output parameter to save parser result
+ */
+int ice_parser_rt_execute(struct ice_parser_rt *rt,
+ struct ice_parser_result *rslt)
+{
+ return ICE_ERR_NOT_IMPL;
+}
diff --git a/drivers/net/ethernet/intel/ice/ice_parser_rt.h b/drivers/net/ethernet/intel/ice/ice_parser_rt.h
new file mode 100644
index 000000000000..9356950aa0f0
--- /dev/null
+++ b/drivers/net/ethernet/intel/ice/ice_parser_rt.h
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2023 Intel Corporation */
+
+#ifndef _ICE_PARSER_RT_H_
+#define _ICE_PARSER_RT_H_
+
+#define ICE_GPR_HV_IDX 64
+#define ICE_GPR_HV_SIZE 32
+#define ICE_GPR_ERR_IDX 84
+#define ICE_GPR_FLG_IDX 104
+#define ICE_GPR_FLG_SIZE 16
+
+#define ICE_GPR_TSR_IDX 108
+#define ICE_GPR_NN_IDX 109
+#define ICE_GPR_HO_IDX 110
+#define ICE_GPR_NP_IDX 111
+
+struct ice_parser_ctx;
+
+#define ICE_PARSER_MAX_PKT_LEN 504
+#define ICE_PARSER_PKT_REV 32
+#define ICE_PARSER_GPR_NUM 128
+#define ICE_PARSER_FLG_NUM 64
+
+struct ice_parser_rt {
+ struct ice_parser *psr;
+ u16 gpr[ICE_PARSER_GPR_NUM];
+ u8 pkt_buf[ICE_PARSER_MAX_PKT_LEN + ICE_PARSER_PKT_REV];
+ 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;
+int ice_parser_rt_execute(struct ice_parser_rt *rt,
+ struct ice_parser_result *rslt);
+#endif /* _ICE_PARSER_RT_H_ */
--
2.25.1
next prev parent reply other threads:[~2023-08-23 9:32 UTC|newest]
Thread overview: 76+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20230605054641.2865142-1-junfeng.guo@intel.com>
2023-08-21 2:38 ` [PATCH iwl-next v5 00/15] Introduce the Parser Library Junfeng Guo
2023-08-21 2:38 ` [PATCH iwl-next v5 01/15] ice: add parser create and destroy skeleton Junfeng Guo
2023-08-21 7:20 ` Simon Horman
2023-08-21 7:30 ` Simon Horman
2023-08-21 7:34 ` Guo, Junfeng
2023-08-21 14:47 ` Simon Horman
2023-08-22 2:47 ` Guo, Junfeng
2023-08-21 2:38 ` [PATCH iwl-next v5 02/15] ice: init imem table for parser Junfeng Guo
2023-08-21 2:38 ` [PATCH iwl-next v5 03/15] ice: init metainit " Junfeng Guo
2023-08-21 2:38 ` [PATCH iwl-next v5 04/15] ice: init parse graph cam tables " Junfeng Guo
2023-08-21 2:38 ` [PATCH iwl-next v5 05/15] ice: init boost tcam and label " Junfeng Guo
2023-08-21 2:38 ` [PATCH iwl-next v5 06/15] ice: init ptype marker tcam table " Junfeng Guo
2023-08-21 2:38 ` [PATCH iwl-next v5 07/15] ice: init marker and protocol group tables " Junfeng Guo
2023-08-21 2:38 ` [PATCH iwl-next v5 08/15] ice: init flag redirect table " Junfeng Guo
2023-08-21 2:38 ` [PATCH iwl-next v5 09/15] ice: init XLT key builder " Junfeng Guo
2023-08-21 2:38 ` [PATCH iwl-next v5 10/15] ice: add parser runtime skeleton Junfeng Guo
2023-08-21 2:38 ` [PATCH iwl-next v5 11/15] ice: add internal help functions Junfeng Guo
2023-08-21 2:38 ` [PATCH iwl-next v5 12/15] ice: add parser execution main loop Junfeng Guo
2023-08-21 2:38 ` [PATCH iwl-next v5 13/15] ice: support double vlan mode configure for parser Junfeng Guo
2023-08-21 2:38 ` [PATCH iwl-next v5 14/15] ice: add tunnel port support " Junfeng Guo
2023-08-21 2:38 ` [PATCH iwl-next v5 15/15] ice: add API for parser profile initialization Junfeng Guo
2023-08-21 6:46 ` [EXT] [PATCH iwl-next v5 00/15] Introduce the Parser Library Subbaraya Sundeep Bhatta
2023-08-21 7:15 ` Guo, Junfeng
2023-08-21 8:14 ` [PATCH iwl-next v6 " Junfeng Guo
2023-08-21 8:14 ` [PATCH iwl-next v6 01/15] ice: add parser create and destroy skeleton Junfeng Guo
2023-08-21 8:14 ` [PATCH iwl-next v6 02/15] ice: init imem table for parser Junfeng Guo
2023-08-21 8:14 ` [PATCH iwl-next v6 03/15] ice: init metainit " Junfeng Guo
2023-08-21 8:14 ` [PATCH iwl-next v6 04/15] ice: init parse graph cam tables " Junfeng Guo
2023-08-21 8:14 ` [PATCH iwl-next v6 05/15] ice: init boost tcam and label " Junfeng Guo
2023-08-21 8:14 ` [PATCH iwl-next v6 06/15] ice: init ptype marker tcam table " Junfeng Guo
2023-08-21 8:14 ` [PATCH iwl-next v6 07/15] ice: init marker and protocol group tables " Junfeng Guo
2023-08-21 8:14 ` [PATCH iwl-next v6 08/15] ice: init flag redirect table " Junfeng Guo
2023-08-21 8:14 ` [PATCH iwl-next v6 09/15] ice: init XLT key builder " Junfeng Guo
2023-08-21 8:14 ` [PATCH iwl-next v6 10/15] ice: add parser runtime skeleton Junfeng Guo
2023-08-21 8:14 ` [PATCH iwl-next v6 11/15] ice: add internal help functions Junfeng Guo
2023-08-21 8:14 ` [PATCH iwl-next v6 12/15] ice: add parser execution main loop Junfeng Guo
2023-08-21 8:14 ` [PATCH iwl-next v6 13/15] ice: support double vlan mode configure for parser Junfeng Guo
2023-08-21 8:14 ` [PATCH iwl-next v6 14/15] ice: add tunnel port support " Junfeng Guo
2023-08-21 8:14 ` [PATCH iwl-next v6 15/15] ice: add API for parser profile initialization Junfeng Guo
2023-08-23 9:31 ` [PATCH iwl-next v7 00/15] Introduce the Parser Library Junfeng Guo
2023-08-23 9:31 ` [PATCH iwl-next v7 01/15] ice: add parser create and destroy skeleton Junfeng Guo
2023-08-23 9:31 ` [PATCH iwl-next v7 02/15] ice: init imem table for parser Junfeng Guo
2023-08-23 9:31 ` [PATCH iwl-next v7 03/15] ice: init metainit " Junfeng Guo
2023-08-23 9:31 ` [PATCH iwl-next v7 04/15] ice: init parse graph cam tables " Junfeng Guo
2023-08-23 9:31 ` [PATCH iwl-next v7 05/15] ice: init boost tcam and label " Junfeng Guo
2023-08-23 9:31 ` [PATCH iwl-next v7 06/15] ice: init ptype marker tcam table " Junfeng Guo
2023-08-23 9:31 ` [PATCH iwl-next v7 07/15] ice: init marker and protocol group tables " Junfeng Guo
2023-08-23 9:31 ` [PATCH iwl-next v7 08/15] ice: init flag redirect table " Junfeng Guo
2023-08-23 9:31 ` [PATCH iwl-next v7 09/15] ice: init XLT key builder " Junfeng Guo
2023-08-23 9:31 ` Junfeng Guo [this message]
2023-08-23 9:31 ` [PATCH iwl-next v7 11/15] ice: add internal help functions Junfeng Guo
2023-08-23 9:31 ` [PATCH iwl-next v7 12/15] ice: add parser execution main loop Junfeng Guo
2023-08-23 9:31 ` [PATCH iwl-next v7 13/15] ice: support double vlan mode configure for parser Junfeng Guo
2023-08-23 9:31 ` [PATCH iwl-next v7 14/15] ice: add tunnel port support " Junfeng Guo
2023-08-23 9:31 ` [PATCH iwl-next v7 15/15] ice: add API for parser profile initialization Junfeng Guo
2023-08-24 7:54 ` [PATCH iwl-next v8 00/15] Introduce the Parser Library Junfeng Guo
2023-08-24 7:54 ` [PATCH iwl-next v8 01/15] ice: add parser create and destroy skeleton Junfeng Guo
2023-08-24 7:54 ` [PATCH iwl-next v8 02/15] ice: init imem table for parser Junfeng Guo
2023-08-28 9:55 ` Ivan Vecera
2023-08-24 7:54 ` [PATCH iwl-next v8 03/15] ice: init metainit " Junfeng Guo
2023-08-24 7:54 ` [PATCH iwl-next v8 04/15] ice: init parse graph cam tables " Junfeng Guo
2023-08-24 7:54 ` [PATCH iwl-next v8 05/15] ice: init boost tcam and label " Junfeng Guo
2023-08-24 7:54 ` [PATCH iwl-next v8 06/15] ice: init ptype marker tcam table " Junfeng Guo
2023-08-24 7:54 ` [PATCH iwl-next v8 07/15] ice: init marker and protocol group tables " Junfeng Guo
2023-08-24 7:54 ` [PATCH iwl-next v8 08/15] ice: init flag redirect table " Junfeng Guo
2023-08-24 7:54 ` [PATCH iwl-next v8 09/15] ice: init XLT key builder " Junfeng Guo
2023-08-24 7:54 ` [PATCH iwl-next v8 10/15] ice: add parser runtime skeleton Junfeng Guo
2023-08-24 7:54 ` [PATCH iwl-next v8 11/15] ice: add internal help functions Junfeng Guo
2023-08-24 7:54 ` [PATCH iwl-next v8 12/15] ice: add parser execution main loop Junfeng Guo
2023-08-24 15:39 ` Simon Horman
2023-08-24 7:54 ` [PATCH iwl-next v8 13/15] ice: support double vlan mode configure for parser Junfeng Guo
2023-08-24 7:54 ` [PATCH iwl-next v8 14/15] ice: add tunnel port support " Junfeng Guo
2023-08-24 7:55 ` [PATCH iwl-next v8 15/15] ice: add API for parser profile initialization Junfeng Guo
2023-08-24 15:20 ` [PATCH iwl-next v8 00/15] Introduce the Parser Library Jakub Kicinski
2023-08-25 10:52 ` Alexander Lobakin
2023-08-26 0:23 ` Jakub Kicinski
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=20230823093158.782802-11-junfeng.guo@intel.com \
--to=junfeng.guo@intel$(echo .)com \
--cc=anthony.l.nguyen@intel$(echo .)com \
--cc=horms@kernel$(echo .)org \
--cc=intel-wired-lan@lists$(echo .)osuosl.org \
--cc=ivecera@redhat$(echo .)com \
--cc=jesse.brandeburg@intel$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
--cc=qi.z.zhang@intel$(echo .)com \
--cc=sridhar.samudrala@intel$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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