Skip to contentSkip to conversation

Introduce the Parser Library

PATCH Superseded Junfeng Guo 8 participants 152 messages Jun 5, 2023 – Aug 28, 2023 Page 1 of 3

Subsystems (3)

v2 of 9 Superseded Latest is v9 →

lore
Share & tools
lore
#0 lore raw

v2 cover Introduce the Parser Library

Current software architecture for flow filtering offloading limited the capability of Intel® Ethernet 800 Series Dynamic Device Personalization (DDP) Package. The flow filtering offloading in the driver is enabled based on the naming parsers, each flow pattern is represented by a protocol header stack. And there are multiple layers (e.g., virtchnl) to maintain their own enum/macro/structure to represent a protocol header (IP, TCP, UDP ...), thus the extra parsers to verify if a pattern is supported by hardware or not as well as the extra converters that to translate represents between different layers. Every time a new protocol/field is requested to be supported, the corresponding logic for the parsers and the converters needs to be modified accordingly. Thus, huge & redundant efforts are required to support the increasing flow filtering offloading features, especially for the tunnel types flow filtering.

This patch set provides a way for applications to send down training packets & masks (in binary) to the driver. Then these binary data would be used by the driver to generate certain data that are needed to create a filter rule in the filtering stage of switch/RSS/FDIR.

Note that the impact of a malicious rule in the raw packet filter is limited to performance rather than functionality. It may affect the performance of the workload, similar to other limitations in FDIR/RSS on AVF. For example, there is no resource boundary for VF FDIR/RSS rules, so one malicious VF could potentially make other VFs inefficient in offloading.

The parser library is expected to include boundary checks to prevent critical errors such as infinite loops or segmentation faults. However, only implementing and validating the parser emulator in a sandbox environment (like ebpf) presents a challenge.

The idea is to make the driver be able to learn from the DDP package directly to understand how the hardware parser works (i.e., the Parser Library), so that it can process on the raw training packet (in binary) directly and create the filter rule accordingly.

Based on this Parser Library, the raw flow filtering of switch/RSS/FDIR could be enabled to allow new flow filtering offloading features to be supported without any driver changes (only need to update the DDP package).

v2:
Fix build warnings.
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

Junfeng Guo (15):
ice: add parser create and destroy skeleton
ice: init imem table for parser
ice: init metainit table for parser
ice: init parse graph cam table for parser
ice: init boost tcam table for parser
ice: init ptype marker tcam table for parser
ice: init marker and protocol group table for parser
ice: init flag redirect table for parser
ice: init XLT key builder for parser
ice: add parser runtime skeleton
ice: add internal help functions
ice: add parser execution main loop
ice: support double vlan mode configure for parser
ice: add tunnel port support for parser
ice: add API for parser profile initialization

 drivers/net/ethernet/intel/ice/Makefile       |  11 +
 drivers/net/ethernet/intel/ice/ice_bst_tcam.c | 297 ++++++
 drivers/net/ethernet/intel/ice/ice_bst_tcam.h |  34 +
 drivers/net/ethernet/intel/ice/ice_common.h   |   1 +
 drivers/net/ethernet/intel/ice/ice_ddp.c      |  10 +-
 drivers/net/ethernet/intel/ice/ice_ddp.h      |  14 +
 drivers/net/ethernet/intel/ice/ice_flg_rd.c   |  75 ++
 drivers/net/ethernet/intel/ice/ice_flg_rd.h   |  16 +
 drivers/net/ethernet/intel/ice/ice_imem.c     | 250 +++++
 drivers/net/ethernet/intel/ice/ice_imem.h     | 108 +++
 drivers/net/ethernet/intel/ice/ice_metainit.c | 155 ++++
 drivers/net/ethernet/intel/ice/ice_metainit.h |  45 +
 drivers/net/ethernet/intel/ice/ice_mk_grp.c   |  54 ++
 drivers/net/ethernet/intel/ice/ice_mk_grp.h   |  14 +
 drivers/net/ethernet/intel/ice/ice_parser.c   | 563 ++++++++++++
 drivers/net/ethernet/intel/ice/ice_parser.h   | 112 +++
 .../net/ethernet/intel/ice/ice_parser_rt.c    | 866 ++++++++++++++++++
 .../net/ethernet/intel/ice/ice_parser_rt.h    |  47 +
 .../net/ethernet/intel/ice/ice_parser_util.h  |  35 +
 drivers/net/ethernet/intel/ice/ice_pg_cam.c   | 376 ++++++++
 drivers/net/ethernet/intel/ice/ice_pg_cam.h   |  73 ++
 .../net/ethernet/intel/ice/ice_proto_grp.c    | 105 +++
 .../net/ethernet/intel/ice/ice_proto_grp.h    |  23 +
 drivers/net/ethernet/intel/ice/ice_ptype_mk.c |  75 ++
 drivers/net/ethernet/intel/ice/ice_ptype_mk.h |  20 +
 drivers/net/ethernet/intel/ice/ice_tmatch.h   |  43 +
 drivers/net/ethernet/intel/ice/ice_type.h     |   1 +
 drivers/net/ethernet/intel/ice/ice_xlt_kb.c   | 218 +++++
 drivers/net/ethernet/intel/ice/ice_xlt_kb.h   |  33 +
 29 files changed, 3669 insertions(+), 5 deletions(-)
 create mode 100644 drivers/net/ethernet/intel/ice/ice_bst_tcam.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_bst_tcam.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_flg_rd.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_flg_rd.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_imem.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_imem.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_metainit.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_metainit.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_mk_grp.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_mk_grp.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_parser.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_parser.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_parser_rt.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_parser_rt.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_parser_util.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_pg_cam.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_pg_cam.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_proto_grp.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_proto_grp.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_ptype_mk.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_ptype_mk.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_tmatch.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_xlt_kb.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_xlt_kb.h
Signature · 6 lines
2.25.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
#1 lore raw

PATCH v2 1/15 ice: add parser create and destroy skeleton

Add new parser module which can parse a packet in binary and generate information like ptype, protocol/offset pairs and flags which can be used to feed the FXP profile creation directly.

The patch added skeleton of the create and destroy APIs:
ice_parser_create
ice_parser_destroy

---
 drivers/net/ethernet/intel/ice/ice_common.h |  1 +
 drivers/net/ethernet/intel/ice/ice_ddp.c    | 10 +++---
 drivers/net/ethernet/intel/ice/ice_ddp.h    | 13 ++++++++
 drivers/net/ethernet/intel/ice/ice_parser.c | 34 +++++++++++++++++++++
 drivers/net/ethernet/intel/ice/ice_parser.h | 13 ++++++++
 5 files changed, 66 insertions(+), 5 deletions(-)
 create mode 100644 drivers/net/ethernet/intel/ice/ice_parser.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_parser.h
drivers/net/ethernet/intel/ice/ice_common.h +1 -0
index 8ba5f935a092..4052227d5791 100644
@@ -9,6 +9,7 @@
 #include "ice_type.h"
 #include "ice_nvm.h"
 #include "ice_flex_pipe.h"
+#include "ice_parser.h"
 #include <linux/avf/virtchnl.h>
 #include "ice_switch.h"
 #include "ice_fdir.h"
drivers/net/ethernet/intel/ice/ice_ddp.c +5 -5
index d71ed210f9c4..3bdf03b9ee71 100644
@@ -288,11 +288,11 @@ void *ice_pkg_enum_section(struct ice_seg *ice_seg, struct ice_pkg_enum *state,
  * indicates a base offset of 10, and the index for the entry is 2, then
  * section handler function should set the offset to 10 + 2 = 12.
  */
-static void *ice_pkg_enum_entry(struct ice_seg *ice_seg,
-				struct ice_pkg_enum *state, u32 sect_type,
-				u32 *offset,
-				void *(*handler)(u32 sect_type, void *section,
-						 u32 index, u32 *offset))
+void *ice_pkg_enum_entry(struct ice_seg *ice_seg,
+			 struct ice_pkg_enum *state, u32 sect_type,
+			 u32 *offset,
+			 void *(*handler)(u32 sect_type, void *section,
+					  u32 index, u32 *offset))
 {
 	void *entry;
 
drivers/net/ethernet/intel/ice/ice_ddp.h +13 -0
index 37eadb3d27a8..da5dfeed3b1f 100644
@@ -238,10 +238,18 @@ struct ice_meta_sect {
 #define ICE_SID_CDID_KEY_BUILDER_RSS 47
 #define ICE_SID_CDID_REDIR_RSS 48
 
+#define ICE_SID_RXPARSER_CAM		50
+#define ICE_SID_RXPARSER_NOMATCH_CAM	51
+#define ICE_SID_RXPARSER_IMEM		52
 #define ICE_SID_RXPARSER_MARKER_PTYPE 55
 #define ICE_SID_RXPARSER_BOOST_TCAM 56
+#define ICE_SID_RXPARSER_PROTO_GRP	57
 #define ICE_SID_RXPARSER_METADATA_INIT 58
+#define ICE_SID_TXPARSER_NOMATCH_CAM	61
 #define ICE_SID_TXPARSER_BOOST_TCAM 66
+#define ICE_SID_RXPARSER_MARKER_GRP	72
+#define ICE_SID_RXPARSER_PG_SPILL	76
+#define ICE_SID_RXPARSER_NOMATCH_SPILL	78
 
 #define ICE_SID_XLT0_PE 80
 #define ICE_SID_XLT_KEY_BUILDER_PE 81
@@ -437,6 +445,11 @@ int ice_update_pkg(struct ice_hw *hw, struct ice_buf *bufs, u32 count);
 
 int ice_pkg_buf_reserve_section(struct ice_buf_build *bld, u16 count);
 u16 ice_pkg_buf_get_active_sections(struct ice_buf_build *bld);
+void *
+ice_pkg_enum_entry(struct ice_seg *ice_seg, struct ice_pkg_enum *state,
+		   u32 sect_type, u32 *offset,
+		   void *(*handler)(u32 sect_type, void *section,
+				    u32 index, u32 *offset));
 void *ice_pkg_enum_section(struct ice_seg *ice_seg, struct ice_pkg_enum *state,
 			   u32 sect_type);
 
drivers/net/ethernet/intel/ice/ice_parser.c new file +34 -0
new file mode 100644
index 000000000000..692ad26ec551
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#include "ice_common.h"
+
+/**
+ * ice_parser_create - create a parser instance
+ * @hw: pointer to the hardware structure
+ * @psr: output parameter for a new parser instance be created
+ */
+int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr)
+{
+	struct ice_parser *p;
+
+	p = devm_kzalloc(ice_hw_to_dev(hw), sizeof(struct ice_parser),
+			 GFP_KERNEL);
+	if (!p)
+		return -ENOMEM;
+
+	p->hw = hw;
+	p->rt.psr = p;
+
+	*psr = p;
+	return 0;
+}
+
+/**
+ * ice_parser_destroy - destroy a parser instance
+ * @psr: pointer to a parser instance
+ */
+void ice_parser_destroy(struct ice_parser *psr)
+{
+	devm_kfree(ice_hw_to_dev(psr->hw), psr);
+}
drivers/net/ethernet/intel/ice/ice_parser.h new file +13 -0
new file mode 100644
index 000000000000..c6cd74c6e434
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#ifndef _ICE_PARSER_H_
+#define _ICE_PARSER_H_
+
+struct ice_parser {
+	struct ice_hw *hw; /* pointer to the hardware structure */
+};
+
+int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
+void ice_parser_destroy(struct ice_parser *psr);
+#endif /* _ICE_PARSER_H_ */
Signature · 6 lines
2.25.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
#2 lore raw

PATCH v2 2/15 ice: init imem table for parser

In reply to Junfeng Guo

Parse DDP section ICE_SID_RXPARSER_IMEM into an arrary of struct ice_imem_item.

---
 drivers/net/ethernet/intel/ice/ice_imem.c     | 250 ++++++++++++++++++
 drivers/net/ethernet/intel/ice/ice_imem.h     | 108 ++++++++
 drivers/net/ethernet/intel/ice/ice_parser.c   | 102 +++++++
 drivers/net/ethernet/intel/ice/ice_parser.h   |   3 +
 .../net/ethernet/intel/ice/ice_parser_util.h  |  24 ++
 drivers/net/ethernet/intel/ice/ice_type.h     |   1 +
 6 files changed, 488 insertions(+)
 create mode 100644 drivers/net/ethernet/intel/ice/ice_imem.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_imem.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_parser_util.h
drivers/net/ethernet/intel/ice/ice_imem.c new file +250 -0
new file mode 100644
index 000000000000..2bd48f080326
@@ -0,0 +1,250 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#include "ice_common.h"
+#include "ice_parser_util.h"
+
+#define ICE_IMEM_TABLE_SIZE 192
+
+static void _imem_bst_bm_dump(struct ice_hw *hw, struct ice_bst_main *bm)
+{
+	dev_info(ice_hw_to_dev(hw), "boost main:\n");
+	dev_info(ice_hw_to_dev(hw), "\tal0 = %d\n", bm->al0);
+	dev_info(ice_hw_to_dev(hw), "\tal1 = %d\n", bm->al1);
+	dev_info(ice_hw_to_dev(hw), "\tal2 = %d\n", bm->al2);
+	dev_info(ice_hw_to_dev(hw), "\tpg = %d\n", bm->pg);
+}
+
+static void _imem_bst_kb_dump(struct ice_hw *hw, struct ice_bst_keybuilder *kb)
+{
+	dev_info(ice_hw_to_dev(hw), "boost key builder:\n");
+	dev_info(ice_hw_to_dev(hw), "\tpriority = %d\n", kb->priority);
+	dev_info(ice_hw_to_dev(hw), "\ttsr_ctrl = %d\n", kb->tsr_ctrl);
+}
+
+static void _imem_np_kb_dump(struct ice_hw *hw, struct ice_np_keybuilder *kb)
+{
+	dev_info(ice_hw_to_dev(hw), "next proto key builder:\n");
+	dev_info(ice_hw_to_dev(hw), "\tops = %d\n", kb->ops);
+	dev_info(ice_hw_to_dev(hw), "\tstart_or_reg0 = %d\n",
+		 kb->start_or_reg0);
+	dev_info(ice_hw_to_dev(hw), "\tlen_or_reg1 = %d\n", kb->len_or_reg1);
+}
+
+static void _imem_pg_kb_dump(struct ice_hw *hw, struct ice_pg_keybuilder *kb)
+{
+	dev_info(ice_hw_to_dev(hw), "parse graph key builder:\n");
+	dev_info(ice_hw_to_dev(hw), "\tflag0_ena = %d\n", kb->flag0_ena);
+	dev_info(ice_hw_to_dev(hw), "\tflag1_ena = %d\n", kb->flag1_ena);
+	dev_info(ice_hw_to_dev(hw), "\tflag2_ena = %d\n", kb->flag2_ena);
+	dev_info(ice_hw_to_dev(hw), "\tflag3_ena = %d\n", kb->flag3_ena);
+	dev_info(ice_hw_to_dev(hw), "\tflag0_idx = %d\n", kb->flag0_idx);
+	dev_info(ice_hw_to_dev(hw), "\tflag1_idx = %d\n", kb->flag1_idx);
+	dev_info(ice_hw_to_dev(hw), "\tflag2_idx = %d\n", kb->flag2_idx);
+	dev_info(ice_hw_to_dev(hw), "\tflag3_idx = %d\n", kb->flag3_idx);
+	dev_info(ice_hw_to_dev(hw), "\talu_reg_idx = %d\n", kb->alu_reg_idx);
+}
+
+static void _imem_alu_dump(struct ice_hw *hw, struct ice_alu *alu, int index)
+{
+	dev_info(ice_hw_to_dev(hw), "alu%d:\n", index);
+	dev_info(ice_hw_to_dev(hw), "\topc = %d\n", alu->opc);
+	dev_info(ice_hw_to_dev(hw), "\tsrc_start = %d\n", alu->src_start);
+	dev_info(ice_hw_to_dev(hw), "\tsrc_len = %d\n", alu->src_len);
+	dev_info(ice_hw_to_dev(hw), "\tshift_xlate_select = %d\n",
+		 alu->shift_xlate_select);
+	dev_info(ice_hw_to_dev(hw), "\tshift_xlate_key = %d\n",
+		 alu->shift_xlate_key);
+	dev_info(ice_hw_to_dev(hw), "\tsrc_reg_id = %d\n", alu->src_reg_id);
+	dev_info(ice_hw_to_dev(hw), "\tdst_reg_id = %d\n", alu->dst_reg_id);
+	dev_info(ice_hw_to_dev(hw), "\tinc0 = %d\n", alu->inc0);
+	dev_info(ice_hw_to_dev(hw), "\tinc1 = %d\n", alu->inc1);
+	dev_info(ice_hw_to_dev(hw), "\tproto_offset_opc = %d\n",
+		 alu->proto_offset_opc);
+	dev_info(ice_hw_to_dev(hw), "\tproto_offset = %d\n",
+		 alu->proto_offset);
+	dev_info(ice_hw_to_dev(hw), "\tbranch_addr = %d\n", alu->branch_addr);
+	dev_info(ice_hw_to_dev(hw), "\timm = %d\n", alu->imm);
+	dev_info(ice_hw_to_dev(hw), "\tdst_start = %d\n", alu->dst_start);
+	dev_info(ice_hw_to_dev(hw), "\tdst_len = %d\n", alu->dst_len);
+	dev_info(ice_hw_to_dev(hw), "\tflags_extr_imm = %d\n",
+		 alu->flags_extr_imm);
+	dev_info(ice_hw_to_dev(hw), "\tflags_start_imm= %d\n",
+		 alu->flags_start_imm);
+}
+
+/**
+ * ice_imem_dump - dump an imem item info
+ * @hw: pointer to the hardware structure
+ * @item: imem item to dump
+ */
+void ice_imem_dump(struct ice_hw *hw, struct ice_imem_item *item)
+{
+	dev_info(ice_hw_to_dev(hw), "index = %d\n", item->idx);
+	_imem_bst_bm_dump(hw, &item->b_m);
+	_imem_bst_kb_dump(hw, &item->b_kb);
+	dev_info(ice_hw_to_dev(hw), "pg priority = %d\n", item->pg);
+	_imem_np_kb_dump(hw, &item->np_kb);
+	_imem_pg_kb_dump(hw, &item->pg_kb);
+	_imem_alu_dump(hw, &item->alu0, 0);
+	_imem_alu_dump(hw, &item->alu1, 1);
+	_imem_alu_dump(hw, &item->alu2, 2);
+}
+
+/** The function parses a 4 bits Boost Main with below format:
+ *  BIT 0: ALU 0 (bm->alu0)
+ *  BIT 1: ALU 1 (bm->alu1)
+ *  BIT 2: ALU 2 (bm->alu2)
+ *  BIT 3: Parge Graph (bm->pg)
+ */
+static void _imem_bm_init(struct ice_bst_main *bm, u8 data)
+{
+	bm->al0 = (data & 0x1) != 0;
+	bm->al1 = (data & 0x2) != 0;
+	bm->al2 = (data & 0x4) != 0;
+	bm->pg = (data & 0x8) != 0;
+}
+
+/** The function parses a 10 bits Boost Main Build with below format:
+ *  BIT 0-7:	Priority (bkb->priority)
+ *  BIT 8:	TSR Control (bkb->tsr_ctrl)
+ *  BIT 9:	Reserved
+ */
+static void _imem_bkb_init(struct ice_bst_keybuilder *bkb, u16 data)
+{
+	bkb->priority = (u8)(data & 0xff);
+	bkb->tsr_ctrl = (data & 0x100) != 0;
+}
+
+/** The function parses a 18 bits Next Protocol Key Build with below format:
+ *  BIT 0-1:	Opcode kb->ops
+ *  BIT 2-9:	Start / Reg 0 (kb->start_or_reg0)
+ *  BIT 10-17:	Length / Reg 1 (kb->len_or_reg1)
+ */
+static void _imem_npkb_init(struct ice_np_keybuilder *kb, u32 data)
+{
+	kb->ops = (u8)(data & 0x3);
+	kb->start_or_reg0 = (u8)((data >> 2) & 0xff);
+	kb->len_or_reg1 = (u8)((data >> 10) & 0xff);
+}
+
+/** The function parses a 35 bits Parse Graph Key Build with below format:
+ *  BIT 0:	Flag 0 Enable (kb->flag0_ena)
+ *  BIT 1-6:	Flag 0 Index (kb->flag0_idx)
+ *  BIT 7:	Flag 1 Enable (kb->flag1_ena)
+ *  BIT 8-13:	Flag 1 Index (kb->flag1_idx)
+ *  BIT 14:	Flag 2 Enable (kb->flag2_ena)
+ *  BIT 15-20:	Flag 2 Index (kb->flag2_idx)
+ *  BIT 21:	Flag 3 Enable (kb->flag3_ena)
+ *  BIT 22-27:	Flag 3 Index (kb->flag3_idx)
+ *  BIT 28-34:	ALU Register Index (kb->alu_reg_idx)
+ */
+static void _imem_pgkb_init(struct ice_pg_keybuilder *kb, u64 data)
+{
+	kb->flag0_ena = (data & 0x1) != 0;
+	kb->flag0_idx = (u8)((data >> 1) & 0x3f);
+	kb->flag1_ena = ((data >> 7) & 0x1) != 0;
+	kb->flag1_idx = (u8)((data >> 8) & 0x3f);
+	kb->flag2_ena = ((data >> 14) & 0x1) != 0;
+	kb->flag2_idx = (u8)((data >> 15) & 0x3f);
+	kb->flag3_ena = ((data >> 21) & 0x1) != 0;
+	kb->flag3_idx = (u8)((data >> 22) & 0x3f);
+	kb->alu_reg_idx = (u8)((data >> 28) & 0x7f);
+}
+
+/** The function parses a 96 bits ALU entry with below format:
+ *  BIT 0-5:	Opcode (alu->opc)
+ *  BIT 6-13:	Source Start (alu->src_start)
+ *  BIT 14-18:	Source Length (alu->src_len)
+ *  BIT 19:	Shift/Xlate Select (alu->shift_xlate_select)
+ *  BIT 20-23:	Shift/Xlate Key (alu->shift_xlate_key)
+ *  BIT 24-30:	Source Register ID (alu->src_reg_id)
+ *  BIT 31-37:	Dest. Register ID (alu->dst_reg_id)
+ *  BIT 38:	Inc0 (alu->inc0)
+ *  BIT 39:	Inc1:(alu->inc1)
+ *  BIT 40:41	Protocol Offset Opcode (alu->proto_offset_opc)
+ *  BIT 42:49	Protocol Offset (alu->proto_offset)
+ *  BIT 50:57	Branch Address (alu->branch_addr)
+ *  BIT 58:73	Immediate (alu->imm)
+ *  BIT 74	Dedicated Flags Enable (alu->dedicate_flags_ena)
+ *  BIT 75:80	Dest. Start (alu->dst_start)
+ *  BIT 81:86	Dest. Length (alu->dst_len)
+ *  BIT 87	Flags Extract Imm. (alu->flags_extr_imm)
+ *  BIT 88:95	Flags Start/Immediate (alu->flags_start_imm)
+ *
+ *  NOTE: the first 5 bits are skipped as the start bit is not
+ *  byte aligned.
+ */
+static void _imem_alu_init(struct ice_alu *alu, u8 *data)
+{
+	u64 d64 = *(u64 *)data >> 5;
+
+	alu->opc = (enum ice_alu_opcode)(d64 & 0x3f);
+	alu->src_start = (u8)((d64 >> 6) & 0xff);
+	alu->src_len = (u8)((d64 >> 14) & 0x1f);
+	alu->shift_xlate_select = ((d64 >> 19) & 0x1) != 0;
+	alu->shift_xlate_key = (u8)((d64 >> 20) & 0xf);
+	alu->src_reg_id = (u8)((d64 >> 24) & 0x7f);
+	alu->dst_reg_id = (u8)((d64 >> 31) & 0x7f);
+	alu->inc0 = ((d64 >> 38) & 0x1) != 0;
+	alu->inc1 = ((d64 >> 39) & 0x1) != 0;
+	alu->proto_offset_opc = (u8)((d64 >> 40) & 0x3);
+	alu->proto_offset = (u8)((d64 >> 42) & 0xff);
+	alu->branch_addr = (u8)((d64 >> 50) & 0xff);
+
+	d64 = *(u64 *)(&data[7]) >> 7;
+
+	alu->imm = (u16)(d64 & 0xffff);
+	alu->dedicate_flags_ena = ((d64 >> 16) & 0x1) != 0;
+	alu->dst_start = (u8)((d64 >> 17) & 0x3f);
+	alu->dst_len = (u8)((d64 >> 23) & 0x3f);
+	alu->flags_extr_imm = ((d64 >> 29) & 0x1) != 0;
+	alu->flags_start_imm = (u8)((d64 >> 30) & 0xff);
+}
+
+/** The function parses a 384 bits IMEM entry with below format:
+ *  BIT 0-3:	Boost Main (ii->b_m)
+ *  BIT 4-13:	Boost Key Build (ii->b_kb)
+ *  BIT 14-15:	PG Priority (ii->pg)
+ *  BIT 16-33:	Next Proto Key Build (ii->np_kb)
+ *  BIT 34-68:	PG Key Build (ii->pg_kb)
+ *  BIT 69-164:	ALU0 (ii->alu0)
+ *  BIT 165-260:ALU1 (ii->alu1)
+ *  BIT 261-356:ALU2 (ii->alu2)
+ *  BIT 357-383:Reserved
+ */
+static void _imem_parse_item(struct ice_hw *hw, u16 idx, void *item,
+			     void *data, int size)
+{
+	struct ice_imem_item *ii = item;
+	u8 *buf = data;
+
+	ii->idx = idx;
+
+	_imem_bm_init(&ii->b_m, buf[0]);
+	_imem_bkb_init(&ii->b_kb, *((u16 *)(&buf[0])) >> 4);
+
+	ii->pg = (u8)((buf[1] & 0xc0) >> 6);
+	_imem_npkb_init(&ii->np_kb, *((u32 *)(&buf[2])));
+	_imem_pgkb_init(&ii->pg_kb, *((u64 *)(&buf[2])) >> 18);
+	_imem_alu_init(&ii->alu0, &buf[8]);
+	_imem_alu_init(&ii->alu1, &buf[20]);
+	_imem_alu_init(&ii->alu2, &buf[32]);
+
+	if (hw->debug_mask & ICE_DBG_PARSER)
+		ice_imem_dump(hw, ii);
+}
+
+/**
+ * ice_imem_table_get - create an imem table
+ * @hw: pointer to the hardware structure
+ */
+struct ice_imem_item *ice_imem_table_get(struct ice_hw *hw)
+{
+	return (struct ice_imem_item *)
+		ice_parser_create_table(hw, ICE_SID_RXPARSER_IMEM,
+					sizeof(struct ice_imem_item),
+					ICE_IMEM_TABLE_SIZE,
+					ice_parser_sect_item_get,
+					_imem_parse_item);
+}
drivers/net/ethernet/intel/ice/ice_imem.h new file +108 -0

108 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_parser.c +102 -0

127 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_parser.h +3 -0
index c6cd74c6e434..b5a3c473666a 100644
@@ -6,6 +6,9 @@
 
 struct ice_parser {
 	struct ice_hw *hw; /* pointer to the hardware structure */
+
+	/* load data from section ICE_SID_RX_PARSER_IMEM */
+	struct ice_imem_item *imem_table;
 };
 
 int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
drivers/net/ethernet/intel/ice/ice_parser_util.h new file +24 -0
new file mode 100644
index 000000000000..6259d3d97b23
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#ifndef _ICE_PARSER_UTIL_H_
+#define _ICE_PARSER_UTIL_H_
+
+#include "ice_imem.h"
+
+struct ice_pkg_sect_hdr {
+	__le16 count;
+	__le16 offset;
+};
+
+void *ice_parser_sect_item_get(u32 sect_type, void *section,
+			       u32 index, u32 *offset);
+
+void *ice_parser_create_table(struct ice_hw *hw, u32 sect_type,
+			      u32 item_size, u32 length,
+			      void *(*handler)(u32 sect_type, void *section,
+					       u32 index, u32 *offset),
+			      void (*parse_item)(struct ice_hw *hw, u16 idx,
+						 void *item, void *data,
+						 int size));
+#endif /* _ICE_PARSER_UTIL_H_ */
drivers/net/ethernet/intel/ice/ice_type.h +1 -0
index a09556e57803..fa4336dd55f7 100644
@@ -60,6 +60,7 @@ static inline u32 ice_round_to_num(u32 N, u32 R)
 				 ICE_DBG_AQ_DESC	| \
 				 ICE_DBG_AQ_DESC_BUF	| \
 				 ICE_DBG_AQ_CMD)
+#define ICE_DBG_PARSER		BIT_ULL(28)
 
 #define ICE_DBG_USER		BIT_ULL(31)
 
Signature · 6 lines
2.25.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
#3 lore raw

Re: [Intel-wired-lan] [PATCH iwl-next v2 02/15] ice: init imem table for parser

See inline comments...

Quoted 118 lines · Junfeng Guo

Parse DDP section ICE_SID_RXPARSER_IMEM into an arrary of struct ice_imem_item.

---
  drivers/net/ethernet/intel/ice/ice_imem.c     | 250 ++++++++++++++++++
  drivers/net/ethernet/intel/ice/ice_imem.h     | 108 ++++++++
  drivers/net/ethernet/intel/ice/ice_parser.c   | 102 +++++++
  drivers/net/ethernet/intel/ice/ice_parser.h   |   3 +
  .../net/ethernet/intel/ice/ice_parser_util.h  |  24 ++
  drivers/net/ethernet/intel/ice/ice_type.h     |   1 +
  6 files changed, 488 insertions(+)

create mode 100644 drivers/net/ethernet/intel/ice/ice_imem.c create mode 100644 drivers/net/ethernet/intel/ice/ice_imem.h create mode 100644 drivers/net/ethernet/intel/ice/ice_parser_util.h

drivers/net/ethernet/intel/ice/ice_imem.c new file +96 -0
new file mode 100644
index 000000000000..2bd48f080326
@@ -0,0 +1,250 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#include "ice_common.h"
+#include "ice_parser_util.h"
+
+#define ICE_IMEM_TABLE_SIZE 192
+
+static void _imem_bst_bm_dump(struct ice_hw *hw, struct ice_bst_main *bm)
+{
+	dev_info(ice_hw_to_dev(hw), "boost main:\n");
+	dev_info(ice_hw_to_dev(hw), "\tal0 = %d\n", bm->al0);
+	dev_info(ice_hw_to_dev(hw), "\tal1 = %d\n", bm->al1);
+	dev_info(ice_hw_to_dev(hw), "\tal2 = %d\n", bm->al2);
+	dev_info(ice_hw_to_dev(hw), "\tpg = %d\n", bm->pg);
+}
+
+static void _imem_bst_kb_dump(struct ice_hw *hw, struct ice_bst_keybuilder *kb)
+{
+	dev_info(ice_hw_to_dev(hw), "boost key builder:\n");
+	dev_info(ice_hw_to_dev(hw), "\tpriority = %d\n", kb->priority);
+	dev_info(ice_hw_to_dev(hw), "\ttsr_ctrl = %d\n", kb->tsr_ctrl);
+}
+
+static void _imem_np_kb_dump(struct ice_hw *hw, struct ice_np_keybuilder *kb)
+{
+	dev_info(ice_hw_to_dev(hw), "next proto key builder:\n");
+	dev_info(ice_hw_to_dev(hw), "\tops = %d\n", kb->ops);
+	dev_info(ice_hw_to_dev(hw), "\tstart_or_reg0 = %d\n",
+		 kb->start_or_reg0);
+	dev_info(ice_hw_to_dev(hw), "\tlen_or_reg1 = %d\n", kb->len_or_reg1);
+}
+
+static void _imem_pg_kb_dump(struct ice_hw *hw, struct ice_pg_keybuilder *kb)
+{
+	dev_info(ice_hw_to_dev(hw), "parse graph key builder:\n");
+	dev_info(ice_hw_to_dev(hw), "\tflag0_ena = %d\n", kb->flag0_ena);
+	dev_info(ice_hw_to_dev(hw), "\tflag1_ena = %d\n", kb->flag1_ena);
+	dev_info(ice_hw_to_dev(hw), "\tflag2_ena = %d\n", kb->flag2_ena);
+	dev_info(ice_hw_to_dev(hw), "\tflag3_ena = %d\n", kb->flag3_ena);
+	dev_info(ice_hw_to_dev(hw), "\tflag0_idx = %d\n", kb->flag0_idx);
+	dev_info(ice_hw_to_dev(hw), "\tflag1_idx = %d\n", kb->flag1_idx);
+	dev_info(ice_hw_to_dev(hw), "\tflag2_idx = %d\n", kb->flag2_idx);
+	dev_info(ice_hw_to_dev(hw), "\tflag3_idx = %d\n", kb->flag3_idx);
+	dev_info(ice_hw_to_dev(hw), "\talu_reg_idx = %d\n", kb->alu_reg_idx);
+}
+
+static void _imem_alu_dump(struct ice_hw *hw, struct ice_alu *alu, int index)
+{
+	dev_info(ice_hw_to_dev(hw), "alu%d:\n", index);
+	dev_info(ice_hw_to_dev(hw), "\topc = %d\n", alu->opc);
+	dev_info(ice_hw_to_dev(hw), "\tsrc_start = %d\n", alu->src_start);
+	dev_info(ice_hw_to_dev(hw), "\tsrc_len = %d\n", alu->src_len);
+	dev_info(ice_hw_to_dev(hw), "\tshift_xlate_select = %d\n",
+		 alu->shift_xlate_select);
+	dev_info(ice_hw_to_dev(hw), "\tshift_xlate_key = %d\n",
+		 alu->shift_xlate_key);
+	dev_info(ice_hw_to_dev(hw), "\tsrc_reg_id = %d\n", alu->src_reg_id);
+	dev_info(ice_hw_to_dev(hw), "\tdst_reg_id = %d\n", alu->dst_reg_id);
+	dev_info(ice_hw_to_dev(hw), "\tinc0 = %d\n", alu->inc0);
+	dev_info(ice_hw_to_dev(hw), "\tinc1 = %d\n", alu->inc1);
+	dev_info(ice_hw_to_dev(hw), "\tproto_offset_opc = %d\n",
+		 alu->proto_offset_opc);
+	dev_info(ice_hw_to_dev(hw), "\tproto_offset = %d\n",
+		 alu->proto_offset);
+	dev_info(ice_hw_to_dev(hw), "\tbranch_addr = %d\n", alu->branch_addr);
+	dev_info(ice_hw_to_dev(hw), "\timm = %d\n", alu->imm);
+	dev_info(ice_hw_to_dev(hw), "\tdst_start = %d\n", alu->dst_start);
+	dev_info(ice_hw_to_dev(hw), "\tdst_len = %d\n", alu->dst_len);
+	dev_info(ice_hw_to_dev(hw), "\tflags_extr_imm = %d\n",
+		 alu->flags_extr_imm);
+	dev_info(ice_hw_to_dev(hw), "\tflags_start_imm= %d\n",
+		 alu->flags_start_imm);
+}
+
+/**
+ * ice_imem_dump - dump an imem item info
+ * @hw: pointer to the hardware structure
+ * @item: imem item to dump
+ */
+void ice_imem_dump(struct ice_hw *hw, struct ice_imem_item *item)
+{
+	dev_info(ice_hw_to_dev(hw), "index = %d\n", item->idx);
+	_imem_bst_bm_dump(hw, &item->b_m);
+	_imem_bst_kb_dump(hw, &item->b_kb);
+	dev_info(ice_hw_to_dev(hw), "pg priority = %d\n", item->pg);
+	_imem_np_kb_dump(hw, &item->np_kb);
+	_imem_pg_kb_dump(hw, &item->pg_kb);
+	_imem_alu_dump(hw, &item->alu0, 0);
+	_imem_alu_dump(hw, &item->alu1, 1);
+	_imem_alu_dump(hw, &item->alu2, 2);
+}
+
+/** The function parses a 4 bits Boost Main with below format:
+ *  BIT 0: ALU 0 (bm->alu0)
+ *  BIT 1: ALU 1 (bm->alu1)

drivers/net/ethernet/intel/ice/ice_imem.c line 106

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +10 -0
+ *  BIT 2: ALU 2 (bm->alu2)
+ *  BIT 3: Parge Graph (bm->pg)
+ */
+static void _imem_bm_init(struct ice_bst_main *bm, u8 data)
+{
+	bm->al0 = (data & 0x1) != 0;
+	bm->al1 = (data & 0x2) != 0;
+	bm->al2 = (data & 0x4) != 0;
+	bm->pg = (data & 0x8) != 0;
+}

Please introduce mask macros with values BIT(0), BIT(1)... and use them here instead of magic hardcoded values.

drivers/net/ethernet/intel/ice/ice_imem.c line 117

Quoted 11 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +11 -0
+
+/** The function parses a 10 bits Boost Main Build with below format:
+ *  BIT 0-7:	Priority (bkb->priority)
+ *  BIT 8:	TSR Control (bkb->tsr_ctrl)
+ *  BIT 9:	Reserved
+ */
+static void _imem_bkb_init(struct ice_bst_keybuilder *bkb, u16 data)
+{
+	bkb->priority = (u8)(data & 0xff);
+	bkb->tsr_ctrl = (data & 0x100) != 0;
+}

Ditto...

drivers/net/ethernet/intel/ice/ice_imem.c line 129

Quoted 12 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +12 -0
+
+/** The function parses a 18 bits Next Protocol Key Build with below format:
+ *  BIT 0-1:	Opcode kb->ops
+ *  BIT 2-9:	Start / Reg 0 (kb->start_or_reg0)
+ *  BIT 10-17:	Length / Reg 1 (kb->len_or_reg1)
+ */
+static void _imem_npkb_init(struct ice_np_keybuilder *kb, u32 data)
+{
+	kb->ops = (u8)(data & 0x3);
+	kb->start_or_reg0 = (u8)((data >> 2) & 0xff);
+	kb->len_or_reg1 = (u8)((data >> 10) & 0xff);
+}

Ditto... the same also for shift values.

Quoted 24 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +24 -0
+
+/** The function parses a 35 bits Parse Graph Key Build with below format:
+ *  BIT 0:	Flag 0 Enable (kb->flag0_ena)
+ *  BIT 1-6:	Flag 0 Index (kb->flag0_idx)
+ *  BIT 7:	Flag 1 Enable (kb->flag1_ena)
+ *  BIT 8-13:	Flag 1 Index (kb->flag1_idx)
+ *  BIT 14:	Flag 2 Enable (kb->flag2_ena)
+ *  BIT 15-20:	Flag 2 Index (kb->flag2_idx)
+ *  BIT 21:	Flag 3 Enable (kb->flag3_ena)
+ *  BIT 22-27:	Flag 3 Index (kb->flag3_idx)
+ *  BIT 28-34:	ALU Register Index (kb->alu_reg_idx)
+ */
+static void _imem_pgkb_init(struct ice_pg_keybuilder *kb, u64 data)
+{
+	kb->flag0_ena = (data & 0x1) != 0;
+	kb->flag0_idx = (u8)((data >> 1) & 0x3f);
+	kb->flag1_ena = ((data >> 7) & 0x1) != 0;
+	kb->flag1_idx = (u8)((data >> 8) & 0x3f);
+	kb->flag2_ena = ((data >> 14) & 0x1) != 0;
+	kb->flag2_idx = (u8)((data >> 15) & 0x3f);
+	kb->flag3_ena = ((data >> 21) & 0x1) != 0;
+	kb->flag3_idx = (u8)((data >> 22) & 0x3f);
+	kb->alu_reg_idx = (u8)((data >> 28) & 0x7f);
+}

...

Quoted 32 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +32 -0
+
+/** The function parses a 96 bits ALU entry with below format:
+ *  BIT 0-5:	Opcode (alu->opc)
+ *  BIT 6-13:	Source Start (alu->src_start)
+ *  BIT 14-18:	Source Length (alu->src_len)
+ *  BIT 19:	Shift/Xlate Select (alu->shift_xlate_select)
+ *  BIT 20-23:	Shift/Xlate Key (alu->shift_xlate_key)
+ *  BIT 24-30:	Source Register ID (alu->src_reg_id)
+ *  BIT 31-37:	Dest. Register ID (alu->dst_reg_id)
+ *  BIT 38:	Inc0 (alu->inc0)
+ *  BIT 39:	Inc1:(alu->inc1)
+ *  BIT 40:41	Protocol Offset Opcode (alu->proto_offset_opc)
+ *  BIT 42:49	Protocol Offset (alu->proto_offset)
+ *  BIT 50:57	Branch Address (alu->branch_addr)
+ *  BIT 58:73	Immediate (alu->imm)
+ *  BIT 74	Dedicated Flags Enable (alu->dedicate_flags_ena)
+ *  BIT 75:80	Dest. Start (alu->dst_start)
+ *  BIT 81:86	Dest. Length (alu->dst_len)
+ *  BIT 87	Flags Extract Imm. (alu->flags_extr_imm)
+ *  BIT 88:95	Flags Start/Immediate (alu->flags_start_imm)
+ *
+ *  NOTE: the first 5 bits are skipped as the start bit is not
+ *  byte aligned.
+ */
+static void _imem_alu_init(struct ice_alu *alu, u8 *data)
+{
+	u64 d64 = *(u64 *)data >> 5;
+
+	alu->opc = (enum ice_alu_opcode)(d64 & 0x3f);
+	alu->src_start = (u8)((d64 >> 6) & 0xff);
+	alu->src_len = (u8)((d64 >> 14) & 0x1f);
+	alu->shift_xlate_select = ((d64 >> 19) & 0x1) != 0;

drivers/net/ethernet/intel/ice/ice_imem.c line 195

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +10 -0
+	alu->shift_xlate_key = (u8)((d64 >> 20) & 0xf);
+	alu->src_reg_id = (u8)((d64 >> 24) & 0x7f);
+	alu->dst_reg_id = (u8)((d64 >> 31) & 0x7f);
+	alu->inc0 = ((d64 >> 38) & 0x1) != 0;
+	alu->inc1 = ((d64 >> 39) & 0x1) != 0;
+	alu->proto_offset_opc = (u8)((d64 >> 40) & 0x3);
+	alu->proto_offset = (u8)((d64 >> 42) & 0xff);
+	alu->branch_addr = (u8)((d64 >> 50) & 0xff);
+
+	d64 = *(u64 *)(&data[7]) >> 7;

What is at offset 7 and why shift 7?? Use corresponding macros please.

Quoted 31 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +31 -0
+
+	alu->imm = (u16)(d64 & 0xffff);
+	alu->dedicate_flags_ena = ((d64 >> 16) & 0x1) != 0;
+	alu->dst_start = (u8)((d64 >> 17) & 0x3f);
+	alu->dst_len = (u8)((d64 >> 23) & 0x3f);
+	alu->flags_extr_imm = ((d64 >> 29) & 0x1) != 0;
+	alu->flags_start_imm = (u8)((d64 >> 30) & 0xff);
+}
+
+/** The function parses a 384 bits IMEM entry with below format:
+ *  BIT 0-3:	Boost Main (ii->b_m)
+ *  BIT 4-13:	Boost Key Build (ii->b_kb)
+ *  BIT 14-15:	PG Priority (ii->pg)
+ *  BIT 16-33:	Next Proto Key Build (ii->np_kb)
+ *  BIT 34-68:	PG Key Build (ii->pg_kb)
+ *  BIT 69-164:	ALU0 (ii->alu0)
+ *  BIT 165-260:ALU1 (ii->alu1)
+ *  BIT 261-356:ALU2 (ii->alu2)
+ *  BIT 357-383:Reserved
+ */
+static void _imem_parse_item(struct ice_hw *hw, u16 idx, void *item,
+			     void *data, int size)
+{
+	struct ice_imem_item *ii = item;
+	u8 *buf = data;
+
+	ii->idx = idx;
+
+	_imem_bm_init(&ii->b_m, buf[0]);
+	_imem_bkb_init(&ii->b_kb, *((u16 *)(&buf[0])) >> 4);
+

drivers/net/ethernet/intel/ice/ice_imem.c line 236

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +10 -0
+	ii->pg = (u8)((buf[1] & 0xc0) >> 6);
+	_imem_npkb_init(&ii->np_kb, *((u32 *)(&buf[2])));
+	_imem_pgkb_init(&ii->pg_kb, *((u64 *)(&buf[2])) >> 18);
+	_imem_alu_init(&ii->alu0, &buf[8]);
+	_imem_alu_init(&ii->alu1, &buf[20]);
+	_imem_alu_init(&ii->alu2, &buf[32]);
+
+	if (hw->debug_mask & ICE_DBG_PARSER)
+		ice_imem_dump(hw, ii);
+}

The same also here... bits description in the comments are nice but please use macros or enums also in the code.

Quoted 22 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +14 -0
+
+/**
+ * ice_imem_table_get - create an imem table
+ * @hw: pointer to the hardware structure
+ */
+struct ice_imem_item *ice_imem_table_get(struct ice_hw *hw)
+{
+	return (struct ice_imem_item *)
+		ice_parser_create_table(hw, ICE_SID_RXPARSER_IMEM,
+					sizeof(struct ice_imem_item),
+					ICE_IMEM_TABLE_SIZE,
+					ice_parser_sect_item_get,
+					_imem_parse_item);
+}
drivers/net/ethernet/intel/ice/ice_imem.h new file +2 -0
new file mode 100644
index 000000000000..b6b923d67112
@@ -0,0 +1,108 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2018-2023 Intel Corporation */

drivers/net/ethernet/intel/ice/ice_imem.h line 12

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_imem.h new file +10 -0
+
+#ifndef _ICE_IMEM_H_
+#define _ICE_IMEM_H_
+
+struct ice_bst_main {
+	bool al0;
+	bool al1;
+	bool al2;
+	bool pg;
+};

Please use more descriptive names.

Quoted 13 lines
drivers/net/ethernet/intel/ice/ice_imem.h new file +13 -0
+
+struct ice_bst_keybuilder {
+	u8 priority;
+	bool tsr_ctrl;
+};
+
+struct ice_np_keybuilder {
+	u8 ops;
+	u8 start_or_reg0;
+	u8 len_or_reg1;
+};
+
+struct ice_pg_keybuilder {

drivers/net/ethernet/intel/ice/ice_imem.h line 35

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_imem.h new file +10 -0
+	bool flag0_ena;
+	bool flag1_ena;
+	bool flag2_ena;
+	bool flag3_ena;
+	u8 flag0_idx;
+	u8 flag1_idx;
+	u8 flag2_idx;
+	u8 flag3_idx;
+	u8 alu_reg_idx;
+};

What are flag0..3? More descriptive names should be fine... If they are multipurpose you can use anonymous union of bools with context dependent field names inside.

Quoted 109 lines
drivers/net/ethernet/intel/ice/ice_imem.h new file +73 -0
+
+enum ice_alu_opcode {
+	ICE_ALU_PARK = 0,
+	ICE_ALU_MOV_ADD = 1,
+	ICE_ALU_ADD = 2,
+	ICE_ALU_MOV_AND = 4,
+	ICE_ALU_AND = 5,
+	ICE_ALU_AND_IMM = 6,
+	ICE_ALU_MOV_OR = 7,
+	ICE_ALU_OR = 8,
+	ICE_ALU_MOV_XOR = 9,
+	ICE_ALU_XOR = 10,
+	ICE_ALU_NOP = 11,
+	ICE_ALU_BR = 12,
+	ICE_ALU_BREQ = 13,
+	ICE_ALU_BRNEQ = 14,
+	ICE_ALU_BRGT = 15,
+	ICE_ALU_BRLT = 16,
+	ICE_ALU_BRGEQ = 17,
+	ICE_ALU_BRLEG = 18,
+	ICE_ALU_SETEQ = 19,
+	ICE_ALU_ANDEQ = 20,
+	ICE_ALU_OREQ = 21,
+	ICE_ALU_SETNEQ = 22,
+	ICE_ALU_ANDNEQ = 23,
+	ICE_ALU_ORNEQ = 24,
+	ICE_ALU_SETGT = 25,
+	ICE_ALU_ANDGT = 26,
+	ICE_ALU_ORGT = 27,
+	ICE_ALU_SETLT = 28,
+	ICE_ALU_ANDLT = 29,
+	ICE_ALU_ORLT = 30,
+	ICE_ALU_MOV_SUB = 31,
+	ICE_ALU_SUB = 32,
+	ICE_ALU_INVALID = 64,
+};
+
+struct ice_alu {
+	enum ice_alu_opcode opc;
+	u8 src_start;
+	u8 src_len;
+	bool shift_xlate_select;
+	u8 shift_xlate_key;
+	u8 src_reg_id;
+	u8 dst_reg_id;
+	bool inc0;
+	bool inc1;
+	u8 proto_offset_opc;
+	u8 proto_offset;
+	u8 branch_addr;
+	u16 imm;
+	bool dedicate_flags_ena;
+	u8 dst_start;
+	u8 dst_len;
+	bool flags_extr_imm;
+	u8 flags_start_imm;
+};
+
+struct ice_imem_item {
+	u16 idx;
+	struct ice_bst_main b_m;
+	struct ice_bst_keybuilder b_kb;
+	u8 pg;
+	struct ice_np_keybuilder np_kb;
+	struct ice_pg_keybuilder pg_kb;
+	struct ice_alu alu0;
+	struct ice_alu alu1;
+	struct ice_alu alu2;
+};
+
+void ice_imem_dump(struct ice_hw *hw, struct ice_imem_item *item);
+struct ice_imem_item *ice_imem_table_get(struct ice_hw *hw);
+#endif /* _ICE_IMEM_H_ */
drivers/net/ethernet/intel/ice/ice_parser.c +28 -0
index 692ad26ec551..a35f45964c9e 100644
@@ -2,6 +2,96 @@
  /* Copyright (C) 2018-2023 Intel Corporation */
 
  #include "ice_common.h"
+#include "ice_parser_util.h"
+
+#define ICE_SEC_DATA_OFFSET				4
+#define ICE_SID_RXPARSER_IMEM_ENTRY_SIZE		48
+
+/**
+ * ice_parser_sect_item_get - parse a item from a section
+ * @sect_type: section type
+ * @section: section object
+ * @index: index of the item to get
+ * @offset: dummy as prototype of ice_pkg_enum_entry's last parameter
+ */
+void *ice_parser_sect_item_get(u32 sect_type, void *section,
+			       u32 index, u32 *offset)
+{
+	struct ice_pkg_sect_hdr *hdr;
+	int data_off = ICE_SEC_DATA_OFFSET;
+	int size;
+
+	if (!section)
+		return NULL;
+
+	switch (sect_type) {
+	case ICE_SID_RXPARSER_IMEM:
+		size = ICE_SID_RXPARSER_IMEM_ENTRY_SIZE;
+		break;
+	default:
+		return NULL;

drivers/net/ethernet/intel/ice/ice_parser.c line 42

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_parser.c +10 -0
+	}
+
+	hdr = section;
+	if (index >= le16_to_cpu(hdr->count))
+		return NULL;
+
+	return (void *)((uintptr_t)section +
+			(uintptr_t)data_off +
+			((uintptr_t)index * (uintptr_t)size));
+}

Use size_t for 'data' and 'data_off' to avoid superfluous type cast to uintptr_t. Also you don't need to cast section ptr to uintptr_t and back to void *. Just use cast to (u8 *) that can be used in arithmentic and can be used as (void *) return value:

size_t data_off, size;
...
return (u8 *)section + data_off + index * size;

Quoted 138 lines
drivers/net/ethernet/intel/ice/ice_parser.c +64 -0
+
+/**
+ * ice_parser_create_table - create a item table from a section
+ * @hw: pointer to the hardware structure
+ * @sect_type: section type
+ * @item_size: item size in byte
+ * @length: number of items in the table to create
+ * @item_get: the function will be parsed to ice_pkg_enum_entry
+ * @parse_item: the function to parse the item
+ */
+void *ice_parser_create_table(struct ice_hw *hw, u32 sect_type,
+			      u32 item_size, u32 length,
+			      void *(*item_get)(u32 sect_type, void *section,
+						u32 index, u32 *offset),
+			      void (*parse_item)(struct ice_hw *hw, u16 idx,
+						 void *item, void *data,
+						 int size))
+{
+	struct ice_seg *seg = hw->seg;
+	struct ice_pkg_enum state;
+	u16 idx = 0xffff;
+	void *table;
+	void *data;
+
+	if (!seg)
+		return NULL;
+
+	table = devm_kzalloc(ice_hw_to_dev(hw), item_size * length,
+			     GFP_KERNEL);
+	if (!table)
+		return NULL;
+
+	memset(&state, 0, sizeof(state));
+	do {
+		data = ice_pkg_enum_entry(seg, &state, sect_type, NULL,
+					  item_get);
+		seg = NULL;
+		if (data) {
+			struct ice_pkg_sect_hdr *hdr =
+				(struct ice_pkg_sect_hdr *)state.sect;
+
+			idx = le16_to_cpu(hdr->offset) + state.entry_idx;
+			parse_item(hw, idx,
+				   (void *)((uintptr_t)table +
+					    ((uintptr_t)idx *
+					     (uintptr_t)item_size)),
+				   data, item_size);
+		}
+	} while (data);
+
+	return table;
+}
 
  /**
   * ice_parser_create - create a parser instance
@@ -11,6 +101,7 @@
  int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr)
  {
  	struct ice_parser *p;
+	int status;
 
  	p = devm_kzalloc(ice_hw_to_dev(hw), sizeof(struct ice_parser),
  			 GFP_KERNEL);
@@ -20,8 +111,17 @@ int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr)
  	p->hw = hw;
  	p->rt.psr = p;
 
+	p->imem_table = ice_imem_table_get(hw);
+	if (!p->imem_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
  	*psr = p;
  	return 0;
+err:
+	ice_parser_destroy(p);
+	return status;
  }
 
  /**
@@ -30,5 +130,7 @@ int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr)
   */
  void ice_parser_destroy(struct ice_parser *psr)
  {
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->imem_table);
+
  	devm_kfree(ice_hw_to_dev(psr->hw), psr);
  }
drivers/net/ethernet/intel/ice/ice_parser.h +3 -0
index c6cd74c6e434..b5a3c473666a 100644
@@ -6,6 +6,9 @@
 
  struct ice_parser {
  	struct ice_hw *hw; /* pointer to the hardware structure */
+
+	/* load data from section ICE_SID_RX_PARSER_IMEM */
+	struct ice_imem_item *imem_table;
  };
 
  int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
drivers/net/ethernet/intel/ice/ice_parser_util.h new file +24 -0
new file mode 100644
index 000000000000..6259d3d97b23
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#ifndef _ICE_PARSER_UTIL_H_
+#define _ICE_PARSER_UTIL_H_
+
+#include "ice_imem.h"
+
+struct ice_pkg_sect_hdr {
+	__le16 count;
+	__le16 offset;
+};
+
+void *ice_parser_sect_item_get(u32 sect_type, void *section,
+			       u32 index, u32 *offset);
+
+void *ice_parser_create_table(struct ice_hw *hw, u32 sect_type,
+			      u32 item_size, u32 length,
+			      void *(*handler)(u32 sect_type, void *section,
+					       u32 index, u32 *offset),
+			      void (*parse_item)(struct ice_hw *hw, u16 idx,
+						 void *item, void *data,
+						 int size));
+#endif /* _ICE_PARSER_UTIL_H_ */
drivers/net/ethernet/intel/ice/ice_type.h +0 -0
index a09556e57803..fa4336dd55f7 100644

drivers/net/ethernet/intel/ice/ice_type.h static inline u32 ice_round_to_num(u32 N, u32 R) · line 66

Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_type.h +1 -0
@@ -60,6 +60,7 @@ static inline u32 ice_round_to_num(u32 N, u32 R)
  				 ICE_DBG_AQ_DESC	| \
  				 ICE_DBG_AQ_DESC_BUF	| \
  				 ICE_DBG_AQ_CMD)
+#define ICE_DBG_PARSER		BIT_ULL(28)
 
  #define ICE_DBG_USER		BIT_ULL(31)
 

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#4 lore raw

Re: [Intel-wired-lan] [PATCH iwl-next v2 02/15] ice: init imem table for parser

Quoted 160 lines

-----Original Message-----
From: Ivan Vecera <[email protected]>
Sent: Monday, July 24, 2023 18:26
To: Guo, Junfeng <[email protected]>; intel-wired- [email protected]
Cc: Zhang, Qi Z <[email protected]>; mschmidt <[email protected]>; poros <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH iwl-next v2 02/15] ice: init imem table for parser

See inline comments...

Quoted 6 lines · Junfeng Guo

Parse DDP section ICE_SID_RXPARSER_IMEM into an arrary of struct ice_imem_item.

---
  drivers/net/ethernet/intel/ice/ice_imem.c     | 250

++++++++++++++++++

Review

Quoted 11 lines
  drivers/net/ethernet/intel/ice/ice_imem.h     | 108 ++++++++
  drivers/net/ethernet/intel/ice/ice_parser.c   | 102 +++++++
  drivers/net/ethernet/intel/ice/ice_parser.h   |   3 +
  .../net/ethernet/intel/ice/ice_parser_util.h  |  24 ++
  drivers/net/ethernet/intel/ice/ice_type.h     |   1 +
  6 files changed, 488 insertions(+)

create mode 100644 drivers/net/ethernet/intel/ice/ice_imem.c create mode 100644 drivers/net/ethernet/intel/ice/ice_imem.h create mode 100644 drivers/net/ethernet/intel/ice/ice_parser_util.h

(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 5 lines

new file mode 100644
index 000000000000..2bd48f080326

drivers/net/ethernet/intel/ice/ice_imem.c line 9

Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +9 -0
@@ -0,0 +1,250 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#include "ice_common.h"
+#include "ice_parser_util.h"
+
+#define ICE_IMEM_TABLE_SIZE 192
+
+static void _imem_bst_bm_dump(struct ice_hw *hw, struct

ice_bst_main *bm)

drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +9 -0
+{
+	dev_info(ice_hw_to_dev(hw), "boost main:\n");
+	dev_info(ice_hw_to_dev(hw), "\tal0 = %d\n", bm->al0);
+	dev_info(ice_hw_to_dev(hw), "\tal1 = %d\n", bm->al1);
+	dev_info(ice_hw_to_dev(hw), "\tal2 = %d\n", bm->al2);
+	dev_info(ice_hw_to_dev(hw), "\tpg = %d\n", bm->pg);
+}
+
+static void _imem_bst_kb_dump(struct ice_hw *hw, struct

ice_bst_keybuilder *kb)

drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +7 -0
+{
+	dev_info(ice_hw_to_dev(hw), "boost key builder:\n");
+	dev_info(ice_hw_to_dev(hw), "\tpriority = %d\n", kb->priority);
+	dev_info(ice_hw_to_dev(hw), "\ttsr_ctrl = %d\n", kb->tsr_ctrl);
+}
+
+static void _imem_np_kb_dump(struct ice_hw *hw, struct

ice_np_keybuilder *kb)

drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +6 -0
+{
+	dev_info(ice_hw_to_dev(hw), "next proto key builder:\n");
+	dev_info(ice_hw_to_dev(hw), "\tops = %d\n", kb->ops);
+	dev_info(ice_hw_to_dev(hw), "\tstart_or_reg0 = %d\n",
+		 kb->start_or_reg0);
+	dev_info(ice_hw_to_dev(hw), "\tlen_or_reg1 = %d\n", kb-

len_or_reg1);

drivers/net/ethernet/intel/ice/ice_imem.c new file +3 -0
+}
+
+static void _imem_pg_kb_dump(struct ice_hw *hw, struct

ice_pg_keybuilder *kb)

Quoted 20 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +3 -0
+{
+	dev_info(ice_hw_to_dev(hw), "parse graph key builder:\n");
+	dev_info(ice_hw_to_dev(hw), "\tflag0_ena = %d\n", kb-

flag0_ena);

drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tflag1_ena = %d\n", kb-

flag1_ena);

drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tflag2_ena = %d\n", kb-

flag2_ena);

drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tflag3_ena = %d\n", kb-

flag3_ena);

drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tflag0_idx = %d\n", kb-

flag0_idx);

drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tflag1_idx = %d\n", kb-

flag1_idx);

drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tflag2_idx = %d\n", kb-

flag2_idx);

drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tflag3_idx = %d\n", kb-

flag3_idx);

drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\talu_reg_idx = %d\n", kb-

alu_reg_idx);

drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +3 -0
+}
+
+static void _imem_alu_dump(struct ice_hw *hw, struct ice_alu *alu, int

index)

Quoted 58 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +4 -0
+{
+	dev_info(ice_hw_to_dev(hw), "alu%d:\n", index);
+	dev_info(ice_hw_to_dev(hw), "\topc = %d\n", alu->opc);
+	dev_info(ice_hw_to_dev(hw), "\tsrc_start = %d\n", alu-

src_start);

drivers/net/ethernet/intel/ice/ice_imem.c new file +6 -0
+	dev_info(ice_hw_to_dev(hw), "\tsrc_len = %d\n", alu->src_len);
+	dev_info(ice_hw_to_dev(hw), "\tshift_xlate_select = %d\n",
+		 alu->shift_xlate_select);
+	dev_info(ice_hw_to_dev(hw), "\tshift_xlate_key = %d\n",
+		 alu->shift_xlate_key);
+	dev_info(ice_hw_to_dev(hw), "\tsrc_reg_id = %d\n", alu-

src_reg_id);

drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tdst_reg_id = %d\n", alu-

dst_reg_id);

drivers/net/ethernet/intel/ice/ice_imem.c new file +7 -0
+	dev_info(ice_hw_to_dev(hw), "\tinc0 = %d\n", alu->inc0);
+	dev_info(ice_hw_to_dev(hw), "\tinc1 = %d\n", alu->inc1);
+	dev_info(ice_hw_to_dev(hw), "\tproto_offset_opc = %d\n",
+		 alu->proto_offset_opc);
+	dev_info(ice_hw_to_dev(hw), "\tproto_offset = %d\n",
+		 alu->proto_offset);
+	dev_info(ice_hw_to_dev(hw), "\tbranch_addr = %d\n", alu-

branch_addr);

drivers/net/ethernet/intel/ice/ice_imem.c new file +2 -0
+	dev_info(ice_hw_to_dev(hw), "\timm = %d\n", alu->imm);
+	dev_info(ice_hw_to_dev(hw), "\tdst_start = %d\n", alu-

dst_start);

drivers/net/ethernet/intel/ice/ice_imem.c new file +33 -0
+	dev_info(ice_hw_to_dev(hw), "\tdst_len = %d\n", alu->dst_len);
+	dev_info(ice_hw_to_dev(hw), "\tflags_extr_imm = %d\n",
+		 alu->flags_extr_imm);
+	dev_info(ice_hw_to_dev(hw), "\tflags_start_imm= %d\n",
+		 alu->flags_start_imm);
+}
+
+/**
+ * ice_imem_dump - dump an imem item info
+ * @hw: pointer to the hardware structure
+ * @item: imem item to dump
+ */
+void ice_imem_dump(struct ice_hw *hw, struct ice_imem_item *item)
+{
+	dev_info(ice_hw_to_dev(hw), "index = %d\n", item->idx);
+	_imem_bst_bm_dump(hw, &item->b_m);
+	_imem_bst_kb_dump(hw, &item->b_kb);
+	dev_info(ice_hw_to_dev(hw), "pg priority = %d\n", item->pg);
+	_imem_np_kb_dump(hw, &item->np_kb);
+	_imem_pg_kb_dump(hw, &item->pg_kb);
+	_imem_alu_dump(hw, &item->alu0, 0);
+	_imem_alu_dump(hw, &item->alu1, 1);
+	_imem_alu_dump(hw, &item->alu2, 2);
+}
+
+/** The function parses a 4 bits Boost Main with below format:
+ *  BIT 0: ALU 0 (bm->alu0)
+ *  BIT 1: ALU 1 (bm->alu1)
+ *  BIT 2: ALU 2 (bm->alu2)
+ *  BIT 3: Parge Graph (bm->pg)
+ */
+static void _imem_bm_init(struct ice_bst_main *bm, u8 data)
+{
Quoted 8 lines

drivers/net/ethernet/intel/ice/ice_imem.c line 106

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +5 -0
+	bm->al0 = (data & 0x1) != 0;
+	bm->al1 = (data & 0x2) != 0;
+	bm->al2 = (data & 0x4) != 0;
+	bm->pg = (data & 0x8) != 0;
+}

Please introduce mask macros with values BIT(0), BIT(1)... and use them here instead of magic hardcoded values.

Sure, make sense!

The detailed info for each BIT has been commented before the function.
It would be better to use BIT() for one bit select.
But there seems no macro for bit range in kernel. Is there standard usage for this purpose?

Will update in the coming version. Thanks!

Quoted 14 lines

drivers/net/ethernet/intel/ice/ice_imem.c line 117

Quoted 12 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +11 -0
+
+/** The function parses a 10 bits Boost Main Build with below format:
+ *  BIT 0-7:	Priority (bkb->priority)
+ *  BIT 8:	TSR Control (bkb->tsr_ctrl)
+ *  BIT 9:	Reserved
+ */
+static void _imem_bkb_init(struct ice_bst_keybuilder *bkb, u16 data)
+{
+	bkb->priority = (u8)(data & 0xff);
+	bkb->tsr_ctrl = (data & 0x100) != 0;
+}

Ditto...

Sure, thanks!

Quoted 4 lines

drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +2 -0
+
+/** The function parses a 18 bits Next Protocol Key Build with below

format:

Quoted 12 lines

drivers/net/ethernet/intel/ice/ice_imem.c line 129

Quoted 10 lines
+ *  BIT 0-1:	Opcode kb->ops
+ *  BIT 2-9:	Start / Reg 0 (kb->start_or_reg0)
+ *  BIT 10-17:	Length / Reg 1 (kb->len_or_reg1)

+ */

drivers/net/ethernet/intel/ice/ice_imem.c new file +6 -0
+static void _imem_npkb_init(struct ice_np_keybuilder *kb, u32 data)
+{
+	kb->ops = (u8)(data & 0x3);
+	kb->start_or_reg0 = (u8)((data >> 2) & 0xff);
+	kb->len_or_reg1 = (u8)((data >> 10) & 0xff);
+}

Ditto... the same also for shift values.

Sure, thanks!

Quoted 20 lines

drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +2 -0
+
+/** The function parses a 35 bits Parse Graph Key Build with below

format:

Quoted 16 lines
+ *  BIT 0:	Flag 0 Enable (kb->flag0_ena)
+ *  BIT 1-6:	Flag 0 Index (kb->flag0_idx)
+ *  BIT 7:	Flag 1 Enable (kb->flag1_ena)
+ *  BIT 8-13:	Flag 1 Index (kb->flag1_idx)
+ *  BIT 14:	Flag 2 Enable (kb->flag2_ena)
+ *  BIT 15-20:	Flag 2 Index (kb->flag2_idx)
+ *  BIT 21:	Flag 3 Enable (kb->flag3_ena)
+ *  BIT 22-27:	Flag 3 Index (kb->flag3_idx)
+ *  BIT 28-34:	ALU Register Index (kb->alu_reg_idx)

+ */

drivers/net/ethernet/intel/ice/ice_imem.c new file +6 -0
+static void _imem_pgkb_init(struct ice_pg_keybuilder *kb, u64 data)
+{
+	kb->flag0_ena = (data & 0x1) != 0;
+	kb->flag0_idx = (u8)((data >> 1) & 0x3f);
+	kb->flag1_ena = ((data >> 7) & 0x1) != 0;
+	kb->flag1_idx = (u8)((data >> 8) & 0x3f);
Quoted 8 lines
Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +6 -0
+	kb->flag2_ena = ((data >> 14) & 0x1) != 0;
+	kb->flag2_idx = (u8)((data >> 15) & 0x3f);
+	kb->flag3_ena = ((data >> 21) & 0x1) != 0;
+	kb->flag3_idx = (u8)((data >> 22) & 0x3f);
+	kb->alu_reg_idx = (u8)((data >> 28) & 0x7f);
+}

...

Sure, thanks!

Quoted 37 lines
Quoted 37 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +36 -0
+
+/** The function parses a 96 bits ALU entry with below format:
+ *  BIT 0-5:	Opcode (alu->opc)
+ *  BIT 6-13:	Source Start (alu->src_start)
+ *  BIT 14-18:	Source Length (alu->src_len)
+ *  BIT 19:	Shift/Xlate Select (alu->shift_xlate_select)
+ *  BIT 20-23:	Shift/Xlate Key (alu->shift_xlate_key)
+ *  BIT 24-30:	Source Register ID (alu->src_reg_id)
+ *  BIT 31-37:	Dest. Register ID (alu->dst_reg_id)
+ *  BIT 38:	Inc0 (alu->inc0)
+ *  BIT 39:	Inc1:(alu->inc1)
+ *  BIT 40:41	Protocol Offset Opcode (alu->proto_offset_opc)
+ *  BIT 42:49	Protocol Offset (alu->proto_offset)
+ *  BIT 50:57	Branch Address (alu->branch_addr)
+ *  BIT 58:73	Immediate (alu->imm)
+ *  BIT 74	Dedicated Flags Enable (alu->dedicate_flags_ena)
+ *  BIT 75:80	Dest. Start (alu->dst_start)
+ *  BIT 81:86	Dest. Length (alu->dst_len)
+ *  BIT 87	Flags Extract Imm. (alu->flags_extr_imm)
+ *  BIT 88:95	Flags Start/Immediate (alu->flags_start_imm)
+ *
+ *  NOTE: the first 5 bits are skipped as the start bit is not
+ *  byte aligned.
+ */
+static void _imem_alu_init(struct ice_alu *alu, u8 *data)
+{
+	u64 d64 = *(u64 *)data >> 5;
+
+	alu->opc = (enum ice_alu_opcode)(d64 & 0x3f);
+	alu->src_start = (u8)((d64 >> 6) & 0xff);
+	alu->src_len = (u8)((d64 >> 14) & 0x1f);
+	alu->shift_xlate_select = ((d64 >> 19) & 0x1) != 0;
+	alu->shift_xlate_key = (u8)((d64 >> 20) & 0xf);
+	alu->src_reg_id = (u8)((d64 >> 24) & 0x7f);
+	alu->dst_reg_id = (u8)((d64 >> 31) & 0x7f);
+	alu->inc0 = ((d64 >> 38) & 0x1) != 0;
Quoted 8 lines

drivers/net/ethernet/intel/ice/ice_imem.c line 195

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +6 -0
+	alu->inc1 = ((d64 >> 39) & 0x1) != 0;
+	alu->proto_offset_opc = (u8)((d64 >> 40) & 0x3);
+	alu->proto_offset = (u8)((d64 >> 42) & 0xff);
+	alu->branch_addr = (u8)((d64 >> 50) & 0xff);
+
+	d64 = *(u64 *)(&data[7]) >> 7;

What is at offset 7 and why shift 7?? Use corresponding macros please.

This is just calculated numbers to get target bits.
And the first 5 bits are skipped due to not byte aligned.
Thus, 8 * 7 + 7 - 5 = 58, which is just aligned with BIT 58:73 for Immediate (alu->imm).

Sure, it would be better to use macros for this. Thanks!

Quoted 37 lines
Quoted 37 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +36 -0
+
+	alu->imm = (u16)(d64 & 0xffff);
+	alu->dedicate_flags_ena = ((d64 >> 16) & 0x1) != 0;
+	alu->dst_start = (u8)((d64 >> 17) & 0x3f);
+	alu->dst_len = (u8)((d64 >> 23) & 0x3f);
+	alu->flags_extr_imm = ((d64 >> 29) & 0x1) != 0;
+	alu->flags_start_imm = (u8)((d64 >> 30) & 0xff);
+}
+
+/** The function parses a 384 bits IMEM entry with below format:
+ *  BIT 0-3:	Boost Main (ii->b_m)
+ *  BIT 4-13:	Boost Key Build (ii->b_kb)
+ *  BIT 14-15:	PG Priority (ii->pg)
+ *  BIT 16-33:	Next Proto Key Build (ii->np_kb)
+ *  BIT 34-68:	PG Key Build (ii->pg_kb)
+ *  BIT 69-164:	ALU0 (ii->alu0)
+ *  BIT 165-260:ALU1 (ii->alu1)
+ *  BIT 261-356:ALU2 (ii->alu2)
+ *  BIT 357-383:Reserved
+ */
+static void _imem_parse_item(struct ice_hw *hw, u16 idx, void *item,
+			     void *data, int size)
+{
+	struct ice_imem_item *ii = item;
+	u8 *buf = data;
+
+	ii->idx = idx;
+
+	_imem_bm_init(&ii->b_m, buf[0]);
+	_imem_bkb_init(&ii->b_kb, *((u16 *)(&buf[0])) >> 4);
+
+	ii->pg = (u8)((buf[1] & 0xc0) >> 6);
+	_imem_npkb_init(&ii->np_kb, *((u32 *)(&buf[2])));
+	_imem_pgkb_init(&ii->pg_kb, *((u64 *)(&buf[2])) >> 18);
+	_imem_alu_init(&ii->alu0, &buf[8]);
+	_imem_alu_init(&ii->alu1, &buf[20]);
Quoted 8 lines

drivers/net/ethernet/intel/ice/ice_imem.c line 236

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +5 -0
+	_imem_alu_init(&ii->alu2, &buf[32]);
+
+	if (hw->debug_mask & ICE_DBG_PARSER)
+		ice_imem_dump(hw, ii);
+}

The same also here... bits description in the comments are nice but please use macros or enums also in the code.

Sure, thanks!

Quoted 28 lines

Review

Quoted 16 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +14 -0
+
+/**
+ * ice_imem_table_get - create an imem table
+ * @hw: pointer to the hardware structure
+ */
+struct ice_imem_item *ice_imem_table_get(struct ice_hw *hw)
+{
+	return (struct ice_imem_item *)
+		ice_parser_create_table(hw, ICE_SID_RXPARSER_IMEM,
+					sizeof(struct ice_imem_item),
+					ICE_IMEM_TABLE_SIZE,
+					ice_parser_sect_item_get,
+					_imem_parse_item);
+}
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_imem.h

Quoted 11 lines

new file mode 100644
index 000000000000..b6b923d67112

drivers/net/ethernet/intel/ice/ice_imem.h new file +6 -0
@@ -0,0 +1,108 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#ifndef _ICE_IMEM_H_
+#define _ICE_IMEM_H_
+
Quoted 8 lines

drivers/net/ethernet/intel/ice/ice_imem.h line 12

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_imem.h new file +6 -0
+struct ice_bst_main {
+	bool al0;
+	bool al1;
+	bool al2;
+	bool pg;
+};

Please use more descriptive names.

These names are just from the spec of the hardware. Actually there is no more meaningful description about them. These functions are only used to get value from certain bits. Better to keep the names here to aligned with the spec. And we will try if we can add some doc here. Thanks!

Quoted 21 lines
Quoted 21 lines
drivers/net/ethernet/intel/ice/ice_imem.h new file +20 -0
+
+struct ice_bst_keybuilder {
+	u8 priority;
+	bool tsr_ctrl;
+};
+
+struct ice_np_keybuilder {
+	u8 ops;
+	u8 start_or_reg0;
+	u8 len_or_reg1;
+};
+
+struct ice_pg_keybuilder {
+	bool flag0_ena;
+	bool flag1_ena;
+	bool flag2_ena;
+	bool flag3_ena;
+	u8 flag0_idx;
+	u8 flag1_idx;
+	u8 flag2_idx;
Quoted 8 lines

drivers/net/ethernet/intel/ice/ice_imem.h line 35

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_imem.h new file +3 -0
+	u8 flag3_idx;
+	u8 alu_reg_idx;
+};

What are flag0..3? More descriptive names should be fine... If they are multipurpose you can use anonymous union of bools with context dependent
field names inside.

Same here. There is no more meaningful description in the spec. Better to keep these names, in case anyone want to lookup them in the spec. But we will try if we can add some doc here.
Thanks!

Quoted 128 lines

Review

Quoted 75 lines
drivers/net/ethernet/intel/ice/ice_imem.h new file +73 -0
+
+enum ice_alu_opcode {
+	ICE_ALU_PARK = 0,
+	ICE_ALU_MOV_ADD = 1,
+	ICE_ALU_ADD = 2,
+	ICE_ALU_MOV_AND = 4,
+	ICE_ALU_AND = 5,
+	ICE_ALU_AND_IMM = 6,
+	ICE_ALU_MOV_OR = 7,
+	ICE_ALU_OR = 8,
+	ICE_ALU_MOV_XOR = 9,
+	ICE_ALU_XOR = 10,
+	ICE_ALU_NOP = 11,
+	ICE_ALU_BR = 12,
+	ICE_ALU_BREQ = 13,
+	ICE_ALU_BRNEQ = 14,
+	ICE_ALU_BRGT = 15,
+	ICE_ALU_BRLT = 16,
+	ICE_ALU_BRGEQ = 17,
+	ICE_ALU_BRLEG = 18,
+	ICE_ALU_SETEQ = 19,
+	ICE_ALU_ANDEQ = 20,
+	ICE_ALU_OREQ = 21,
+	ICE_ALU_SETNEQ = 22,
+	ICE_ALU_ANDNEQ = 23,
+	ICE_ALU_ORNEQ = 24,
+	ICE_ALU_SETGT = 25,
+	ICE_ALU_ANDGT = 26,
+	ICE_ALU_ORGT = 27,
+	ICE_ALU_SETLT = 28,
+	ICE_ALU_ANDLT = 29,
+	ICE_ALU_ORLT = 30,
+	ICE_ALU_MOV_SUB = 31,
+	ICE_ALU_SUB = 32,
+	ICE_ALU_INVALID = 64,
+};
+
+struct ice_alu {
+	enum ice_alu_opcode opc;
+	u8 src_start;
+	u8 src_len;
+	bool shift_xlate_select;
+	u8 shift_xlate_key;
+	u8 src_reg_id;
+	u8 dst_reg_id;
+	bool inc0;
+	bool inc1;
+	u8 proto_offset_opc;
+	u8 proto_offset;
+	u8 branch_addr;
+	u16 imm;
+	bool dedicate_flags_ena;
+	u8 dst_start;
+	u8 dst_len;
+	bool flags_extr_imm;
+	u8 flags_start_imm;
+};
+
+struct ice_imem_item {
+	u16 idx;
+	struct ice_bst_main b_m;
+	struct ice_bst_keybuilder b_kb;
+	u8 pg;
+	struct ice_np_keybuilder np_kb;
+	struct ice_pg_keybuilder pg_kb;
+	struct ice_alu alu0;
+	struct ice_alu alu1;
+	struct ice_alu alu2;
+};
+
+void ice_imem_dump(struct ice_hw *hw, struct ice_imem_item *item);
+struct ice_imem_item *ice_imem_table_get(struct ice_hw *hw);
+#endif /* _ICE_IMEM_H_ */
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_parser.c

Quoted 8 lines

index 692ad26ec551..a35f45964c9e 100644

drivers/net/ethernet/intel/ice/ice_parser.c +1 -0
@@ -2,6 +2,96 @@
  /* Copyright (C) 2018-2023 Intel Corporation */
 
  #include "ice_common.h"
+#include "ice_parser_util.h"

drivers/net/ethernet/intel/ice/ice_parser.c line 15

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_parser.c +10 -0
+
+#define ICE_SEC_DATA_OFFSET				4
+#define ICE_SID_RXPARSER_IMEM_ENTRY_SIZE		48
+
+/**
+ * ice_parser_sect_item_get - parse a item from a section
+ * @sect_type: section type
+ * @section: section object
+ * @index: index of the item to get
+ * @offset: dummy as prototype of ice_pkg_enum_entry's last

parameter

Quoted 17 lines
drivers/net/ethernet/intel/ice/ice_parser.c +17 -0
+ */
+void *ice_parser_sect_item_get(u32 sect_type, void *section,
+			       u32 index, u32 *offset)
+{
+	struct ice_pkg_sect_hdr *hdr;
+	int data_off = ICE_SEC_DATA_OFFSET;
+	int size;
+
+	if (!section)
+		return NULL;
+
+	switch (sect_type) {
+	case ICE_SID_RXPARSER_IMEM:
+		size = ICE_SID_RXPARSER_IMEM_ENTRY_SIZE;
+		break;
+	default:
+		return NULL;

drivers/net/ethernet/intel/ice/ice_parser.c line 42

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_parser.c +10 -0
+	}
+
+	hdr = section;
+	if (index >= le16_to_cpu(hdr->count))
+		return NULL;
+
+	return (void *)((uintptr_t)section +
+			(uintptr_t)data_off +
+			((uintptr_t)index * (uintptr_t)size));
+}

Use size_t for 'data' and 'data_off' to avoid superfluous type cast to uintptr_t. Also you don't need to cast section ptr to uintptr_t and back to void *. Just use cast to (u8 *) that can be used in arithmentic and can be used as (void *) return value:

Quoted 3 lines

size_t data_off, size;
...
return (u8 *)section + data_off + index * size;

Thanks for the detailed advice!

Will update this in the coming version, thanks a lot!

Quoted 150 lines
Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_parser.c +3 -0
+
+/**
+ * ice_parser_create_table - create a item table from a section

drivers/net/ethernet/intel/ice/ice_parser.c

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_parser.c +10 -0
+ * @hw: pointer to the hardware structure
+ * @sect_type: section type
+ * @item_size: item size in byte
+ * @length: number of items in the table to create
+ * @item_get: the function will be parsed to ice_pkg_enum_entry
+ * @parse_item: the function to parse the item
+ */
+void *ice_parser_create_table(struct ice_hw *hw, u32 sect_type,
+			      u32 item_size, u32 length,
+			      void *(*item_get)(u32 sect_type, void

*section,

drivers/net/ethernet/intel/ice/ice_parser.c int ice_parser_create(struct ice_hw *hw, struct

Quoted 51 lines
drivers/net/ethernet/intel/ice/ice_parser.c +40 -0
+						u32 index, u32 *offset),
+			      void (*parse_item)(struct ice_hw *hw, u16 idx,
+						 void *item, void *data,
+						 int size))
+{
+	struct ice_seg *seg = hw->seg;
+	struct ice_pkg_enum state;
+	u16 idx = 0xffff;
+	void *table;
+	void *data;
+
+	if (!seg)
+		return NULL;
+
+	table = devm_kzalloc(ice_hw_to_dev(hw), item_size * length,
+			     GFP_KERNEL);
+	if (!table)
+		return NULL;
+
+	memset(&state, 0, sizeof(state));
+	do {
+		data = ice_pkg_enum_entry(seg, &state, sect_type, NULL,
+					  item_get);
+		seg = NULL;
+		if (data) {
+			struct ice_pkg_sect_hdr *hdr =
+				(struct ice_pkg_sect_hdr *)state.sect;
+
+			idx = le16_to_cpu(hdr->offset) + state.entry_idx;
+			parse_item(hw, idx,
+				   (void *)((uintptr_t)table +
+					    ((uintptr_t)idx *
+					     (uintptr_t)item_size)),
+				   data, item_size);
+		}
+	} while (data);
+
+	return table;
+}
 
  /**
   * ice_parser_create - create a parser instance
@@ -11,6 +101,7 @@
  int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr)
  {
  	struct ice_parser *p;
+	int status;
 
  	p = devm_kzalloc(ice_hw_to_dev(hw), sizeof(struct ice_parser),
  			 GFP_KERNEL);
@@ -20,8 +111,17 @@ int ice_parser_create(struct ice_hw *hw, struct

ice_parser **psr)

drivers/net/ethernet/intel/ice/ice_parser.c int ice_parser_create(struct ice_hw *hw, struct

Quoted 18 lines
drivers/net/ethernet/intel/ice/ice_parser.c +9 -0
  	p->hw = hw;
  	p->rt.psr = p;
 
+	p->imem_table = ice_imem_table_get(hw);
+	if (!p->imem_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
  	*psr = p;
  	return 0;
+err:
+	ice_parser_destroy(p);
+	return status;
  }
 
  /**
@@ -30,5 +130,7 @@ int ice_parser_create(struct ice_hw *hw, struct

ice_parser **psr)

Review

Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_parser.c +2 -0
   */
  void ice_parser_destroy(struct ice_parser *psr)
  {
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->imem_table);
+
  	devm_kfree(ice_hw_to_dev(psr->hw), psr);
  }
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_parser.h

Review

Quoted 14 lines

index c6cd74c6e434..b5a3c473666a 100644

drivers/net/ethernet/intel/ice/ice_parser.h +3 -0
@@ -6,6 +6,9 @@
 
  struct ice_parser {
  	struct ice_hw *hw; /* pointer to the hardware structure */
+
+	/* load data from section ICE_SID_RX_PARSER_IMEM */
+	struct ice_imem_item *imem_table;
  };
 
  int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_parser_util.h

Review

Quoted 30 lines

new file mode 100644
index 000000000000..6259d3d97b23

drivers/net/ethernet/intel/ice/ice_parser_util.h new file +24 -0
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#ifndef _ICE_PARSER_UTIL_H_
+#define _ICE_PARSER_UTIL_H_
+
+#include "ice_imem.h"
+
+struct ice_pkg_sect_hdr {
+	__le16 count;
+	__le16 offset;
+};
+
+void *ice_parser_sect_item_get(u32 sect_type, void *section,
+			       u32 index, u32 *offset);
+
+void *ice_parser_create_table(struct ice_hw *hw, u32 sect_type,
+			      u32 item_size, u32 length,
+			      void *(*handler)(u32 sect_type, void *section,
+					       u32 index, u32 *offset),
+			      void (*parse_item)(struct ice_hw *hw, u16 idx,
+						 void *item, void *data,
+						 int size));
+#endif /* _ICE_PARSER_UTIL_H_ */
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_type.h

Quoted 9 lines

index a09556e57803..fa4336dd55f7 100644

drivers/net/ethernet/intel/ice/ice_type.h +1 -0
@@ -60,6 +60,7 @@ static inline u32 ice_round_to_num(u32 N, u32 R)
  				 ICE_DBG_AQ_DESC	| \
  				 ICE_DBG_AQ_DESC_BUF	| \
  				 ICE_DBG_AQ_CMD)
+#define ICE_DBG_PARSER		BIT_ULL(28)
 
Quoted 2 lines

drivers/net/ethernet/intel/ice/ice_type.h static inline u32 ice_round_to_num(u32 N, u32 R) · line 66

Quoted 2 lines
drivers/net/ethernet/intel/ice/ice_type.h +0 -0
  #define ICE_DBG_USER		BIT_ULL(31)
 

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#5 lore raw

Re: [Intel-wired-lan] [PATCH iwl-next v2 02/15] ice: init imem table for parser

Hi, thank you for reply... see my inline comments...

Ivan

Quoted 169 lines · Junfeng
Quoted 160 lines

-----Original Message-----
From: Ivan Vecera <[email protected]>
Sent: Monday, July 24, 2023 18:26
To: Guo, Junfeng <[email protected]>; intel-wired- [email protected]
Cc: Zhang, Qi Z <[email protected]>; mschmidt <[email protected]>; poros <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH iwl-next v2 02/15] ice: init imem table for parser

See inline comments...

Quoted 6 lines · Junfeng Guo

Parse DDP section ICE_SID_RXPARSER_IMEM into an arrary of struct ice_imem_item.

---
   drivers/net/ethernet/intel/ice/ice_imem.c     | 250

++++++++++++++++++

Review

Quoted 11 lines
   drivers/net/ethernet/intel/ice/ice_imem.h     | 108 ++++++++
   drivers/net/ethernet/intel/ice/ice_parser.c   | 102 +++++++
   drivers/net/ethernet/intel/ice/ice_parser.h   |   3 +
   .../net/ethernet/intel/ice/ice_parser_util.h  |  24 ++
   drivers/net/ethernet/intel/ice/ice_type.h     |   1 +
   6 files changed, 488 insertions(+)

create mode 100644 drivers/net/ethernet/intel/ice/ice_imem.c create mode 100644 drivers/net/ethernet/intel/ice/ice_imem.h create mode 100644 drivers/net/ethernet/intel/ice/ice_parser_util.h

(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 5 lines

new file mode 100644
index 000000000000..2bd48f080326

drivers/net/ethernet/intel/ice/ice_imem.c line 9

Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +9 -0
@@ -0,0 +1,250 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#include "ice_common.h"
+#include "ice_parser_util.h"
+
+#define ICE_IMEM_TABLE_SIZE 192
+
+static void _imem_bst_bm_dump(struct ice_hw *hw, struct

ice_bst_main *bm)

drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +9 -0
+{
+	dev_info(ice_hw_to_dev(hw), "boost main:\n");
+	dev_info(ice_hw_to_dev(hw), "\tal0 = %d\n", bm->al0);
+	dev_info(ice_hw_to_dev(hw), "\tal1 = %d\n", bm->al1);
+	dev_info(ice_hw_to_dev(hw), "\tal2 = %d\n", bm->al2);
+	dev_info(ice_hw_to_dev(hw), "\tpg = %d\n", bm->pg);
+}
+
+static void _imem_bst_kb_dump(struct ice_hw *hw, struct

ice_bst_keybuilder *kb)

drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +7 -0
+{
+	dev_info(ice_hw_to_dev(hw), "boost key builder:\n");
+	dev_info(ice_hw_to_dev(hw), "\tpriority = %d\n", kb->priority);
+	dev_info(ice_hw_to_dev(hw), "\ttsr_ctrl = %d\n", kb->tsr_ctrl);
+}
+
+static void _imem_np_kb_dump(struct ice_hw *hw, struct

ice_np_keybuilder *kb)

drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +6 -0
+{
+	dev_info(ice_hw_to_dev(hw), "next proto key builder:\n");
+	dev_info(ice_hw_to_dev(hw), "\tops = %d\n", kb->ops);
+	dev_info(ice_hw_to_dev(hw), "\tstart_or_reg0 = %d\n",
+		 kb->start_or_reg0);
+	dev_info(ice_hw_to_dev(hw), "\tlen_or_reg1 = %d\n", kb-

len_or_reg1);

drivers/net/ethernet/intel/ice/ice_imem.c new file +3 -0
+}
+
+static void _imem_pg_kb_dump(struct ice_hw *hw, struct

ice_pg_keybuilder *kb)

Quoted 20 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +3 -0
+{
+	dev_info(ice_hw_to_dev(hw), "parse graph key builder:\n");
+	dev_info(ice_hw_to_dev(hw), "\tflag0_ena = %d\n", kb-

flag0_ena);

drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tflag1_ena = %d\n", kb-

flag1_ena);

drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tflag2_ena = %d\n", kb-

flag2_ena);

drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tflag3_ena = %d\n", kb-

flag3_ena);

drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tflag0_idx = %d\n", kb-

flag0_idx);

drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tflag1_idx = %d\n", kb-

flag1_idx);

drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tflag2_idx = %d\n", kb-

flag2_idx);

drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tflag3_idx = %d\n", kb-

flag3_idx);

drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\talu_reg_idx = %d\n", kb-

alu_reg_idx);

drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +3 -0
+}
+
+static void _imem_alu_dump(struct ice_hw *hw, struct ice_alu *alu, int

index)

Quoted 58 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +4 -0
+{
+	dev_info(ice_hw_to_dev(hw), "alu%d:\n", index);
+	dev_info(ice_hw_to_dev(hw), "\topc = %d\n", alu->opc);
+	dev_info(ice_hw_to_dev(hw), "\tsrc_start = %d\n", alu-

src_start);

drivers/net/ethernet/intel/ice/ice_imem.c new file +6 -0
+	dev_info(ice_hw_to_dev(hw), "\tsrc_len = %d\n", alu->src_len);
+	dev_info(ice_hw_to_dev(hw), "\tshift_xlate_select = %d\n",
+		 alu->shift_xlate_select);
+	dev_info(ice_hw_to_dev(hw), "\tshift_xlate_key = %d\n",
+		 alu->shift_xlate_key);
+	dev_info(ice_hw_to_dev(hw), "\tsrc_reg_id = %d\n", alu-

src_reg_id);

drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tdst_reg_id = %d\n", alu-

dst_reg_id);

drivers/net/ethernet/intel/ice/ice_imem.c new file +7 -0
+	dev_info(ice_hw_to_dev(hw), "\tinc0 = %d\n", alu->inc0);
+	dev_info(ice_hw_to_dev(hw), "\tinc1 = %d\n", alu->inc1);
+	dev_info(ice_hw_to_dev(hw), "\tproto_offset_opc = %d\n",
+		 alu->proto_offset_opc);
+	dev_info(ice_hw_to_dev(hw), "\tproto_offset = %d\n",
+		 alu->proto_offset);
+	dev_info(ice_hw_to_dev(hw), "\tbranch_addr = %d\n", alu-

branch_addr);

drivers/net/ethernet/intel/ice/ice_imem.c new file +2 -0
+	dev_info(ice_hw_to_dev(hw), "\timm = %d\n", alu->imm);
+	dev_info(ice_hw_to_dev(hw), "\tdst_start = %d\n", alu-

dst_start);

drivers/net/ethernet/intel/ice/ice_imem.c new file +33 -0
+	dev_info(ice_hw_to_dev(hw), "\tdst_len = %d\n", alu->dst_len);
+	dev_info(ice_hw_to_dev(hw), "\tflags_extr_imm = %d\n",
+		 alu->flags_extr_imm);
+	dev_info(ice_hw_to_dev(hw), "\tflags_start_imm= %d\n",
+		 alu->flags_start_imm);
+}
+
+/**
+ * ice_imem_dump - dump an imem item info
+ * @hw: pointer to the hardware structure
+ * @item: imem item to dump
+ */
+void ice_imem_dump(struct ice_hw *hw, struct ice_imem_item *item)
+{
+	dev_info(ice_hw_to_dev(hw), "index = %d\n", item->idx);
+	_imem_bst_bm_dump(hw, &item->b_m);
+	_imem_bst_kb_dump(hw, &item->b_kb);
+	dev_info(ice_hw_to_dev(hw), "pg priority = %d\n", item->pg);
+	_imem_np_kb_dump(hw, &item->np_kb);
+	_imem_pg_kb_dump(hw, &item->pg_kb);
+	_imem_alu_dump(hw, &item->alu0, 0);
+	_imem_alu_dump(hw, &item->alu1, 1);
+	_imem_alu_dump(hw, &item->alu2, 2);
+}
+
+/** The function parses a 4 bits Boost Main with below format:
+ *  BIT 0: ALU 0 (bm->alu0)
+ *  BIT 1: ALU 1 (bm->alu1)
+ *  BIT 2: ALU 2 (bm->alu2)
+ *  BIT 3: Parge Graph (bm->pg)
+ */
+static void _imem_bm_init(struct ice_bst_main *bm, u8 data)
+{
Quoted 8 lines

drivers/net/ethernet/intel/ice/ice_imem.c line 106

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +5 -0
+	bm->al0 = (data & 0x1) != 0;
+	bm->al1 = (data & 0x2) != 0;
+	bm->al2 = (data & 0x4) != 0;
+	bm->pg = (data & 0x8) != 0;
+}

Please introduce mask macros with values BIT(0), BIT(1)... and use them here instead of magic hardcoded values.

Quoted 5 lines

Sure, make sense!

The detailed info for each BIT has been commented before the function.
It would be better to use BIT() for one bit select.
But there seems no macro for bit range in kernel. Is there standard usage for this purpose?

For bit ranges you can use GENMASK*() macros from <linux/bits.h>
Check this header file and also <linux/bitops.h>, there is useful stuff for bit operations.

Quoted 115 lines

Will update in the coming version. Thanks!

Quoted 14 lines

drivers/net/ethernet/intel/ice/ice_imem.c line 117

Quoted 12 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +11 -0
+
+/** The function parses a 10 bits Boost Main Build with below format:
+ *  BIT 0-7:	Priority (bkb->priority)
+ *  BIT 8:	TSR Control (bkb->tsr_ctrl)
+ *  BIT 9:	Reserved
+ */
+static void _imem_bkb_init(struct ice_bst_keybuilder *bkb, u16 data)
+{
+	bkb->priority = (u8)(data & 0xff);
+	bkb->tsr_ctrl = (data & 0x100) != 0;
+}

Ditto...

Sure, thanks!

Quoted 4 lines

drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +2 -0
+
+/** The function parses a 18 bits Next Protocol Key Build with below

format:

Quoted 12 lines

drivers/net/ethernet/intel/ice/ice_imem.c line 129

Quoted 10 lines
+ *  BIT 0-1:	Opcode kb->ops
+ *  BIT 2-9:	Start / Reg 0 (kb->start_or_reg0)
+ *  BIT 10-17:	Length / Reg 1 (kb->len_or_reg1)

+ */

drivers/net/ethernet/intel/ice/ice_imem.c new file +6 -0
+static void _imem_npkb_init(struct ice_np_keybuilder *kb, u32 data)
+{
+	kb->ops = (u8)(data & 0x3);
+	kb->start_or_reg0 = (u8)((data >> 2) & 0xff);
+	kb->len_or_reg1 = (u8)((data >> 10) & 0xff);
+}

Ditto... the same also for shift values.

Sure, thanks!

Quoted 20 lines

drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +2 -0
+
+/** The function parses a 35 bits Parse Graph Key Build with below

format:

Quoted 16 lines
+ *  BIT 0:	Flag 0 Enable (kb->flag0_ena)
+ *  BIT 1-6:	Flag 0 Index (kb->flag0_idx)
+ *  BIT 7:	Flag 1 Enable (kb->flag1_ena)
+ *  BIT 8-13:	Flag 1 Index (kb->flag1_idx)
+ *  BIT 14:	Flag 2 Enable (kb->flag2_ena)
+ *  BIT 15-20:	Flag 2 Index (kb->flag2_idx)
+ *  BIT 21:	Flag 3 Enable (kb->flag3_ena)
+ *  BIT 22-27:	Flag 3 Index (kb->flag3_idx)
+ *  BIT 28-34:	ALU Register Index (kb->alu_reg_idx)

+ */

drivers/net/ethernet/intel/ice/ice_imem.c new file +6 -0
+static void _imem_pgkb_init(struct ice_pg_keybuilder *kb, u64 data)
+{
+	kb->flag0_ena = (data & 0x1) != 0;
+	kb->flag0_idx = (u8)((data >> 1) & 0x3f);
+	kb->flag1_ena = ((data >> 7) & 0x1) != 0;
+	kb->flag1_idx = (u8)((data >> 8) & 0x3f);
Quoted 8 lines
Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +6 -0
+	kb->flag2_ena = ((data >> 14) & 0x1) != 0;
+	kb->flag2_idx = (u8)((data >> 15) & 0x3f);
+	kb->flag3_ena = ((data >> 21) & 0x1) != 0;
+	kb->flag3_idx = (u8)((data >> 22) & 0x3f);
+	kb->alu_reg_idx = (u8)((data >> 28) & 0x7f);
+}

...

Sure, thanks!

Quoted 37 lines
Quoted 37 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +36 -0
+
+/** The function parses a 96 bits ALU entry with below format:
+ *  BIT 0-5:	Opcode (alu->opc)
+ *  BIT 6-13:	Source Start (alu->src_start)
+ *  BIT 14-18:	Source Length (alu->src_len)
+ *  BIT 19:	Shift/Xlate Select (alu->shift_xlate_select)
+ *  BIT 20-23:	Shift/Xlate Key (alu->shift_xlate_key)
+ *  BIT 24-30:	Source Register ID (alu->src_reg_id)
+ *  BIT 31-37:	Dest. Register ID (alu->dst_reg_id)
+ *  BIT 38:	Inc0 (alu->inc0)
+ *  BIT 39:	Inc1:(alu->inc1)
+ *  BIT 40:41	Protocol Offset Opcode (alu->proto_offset_opc)
+ *  BIT 42:49	Protocol Offset (alu->proto_offset)
+ *  BIT 50:57	Branch Address (alu->branch_addr)
+ *  BIT 58:73	Immediate (alu->imm)
+ *  BIT 74	Dedicated Flags Enable (alu->dedicate_flags_ena)
+ *  BIT 75:80	Dest. Start (alu->dst_start)
+ *  BIT 81:86	Dest. Length (alu->dst_len)
+ *  BIT 87	Flags Extract Imm. (alu->flags_extr_imm)
+ *  BIT 88:95	Flags Start/Immediate (alu->flags_start_imm)
+ *
+ *  NOTE: the first 5 bits are skipped as the start bit is not
+ *  byte aligned.
+ */
+static void _imem_alu_init(struct ice_alu *alu, u8 *data)
+{
+	u64 d64 = *(u64 *)data >> 5;
+
+	alu->opc = (enum ice_alu_opcode)(d64 & 0x3f);
+	alu->src_start = (u8)((d64 >> 6) & 0xff);
+	alu->src_len = (u8)((d64 >> 14) & 0x1f);
+	alu->shift_xlate_select = ((d64 >> 19) & 0x1) != 0;
+	alu->shift_xlate_key = (u8)((d64 >> 20) & 0xf);
+	alu->src_reg_id = (u8)((d64 >> 24) & 0x7f);
+	alu->dst_reg_id = (u8)((d64 >> 31) & 0x7f);
+	alu->inc0 = ((d64 >> 38) & 0x1) != 0;
Quoted 8 lines

drivers/net/ethernet/intel/ice/ice_imem.c line 195

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +6 -0
+	alu->inc1 = ((d64 >> 39) & 0x1) != 0;
+	alu->proto_offset_opc = (u8)((d64 >> 40) & 0x3);
+	alu->proto_offset = (u8)((d64 >> 42) & 0xff);
+	alu->branch_addr = (u8)((d64 >> 50) & 0xff);
+
+	d64 = *(u64 *)(&data[7]) >> 7;

What is at offset 7 and why shift 7?? Use corresponding macros please.

Quoted 5 lines

This is just calculated numbers to get target bits.
And the first 5 bits are skipped due to not byte aligned.
Thus, 8 * 7 + 7 - 5 = 58, which is just aligned with BIT 58:73 for Immediate (alu->imm).

Sure, it would be better to use macros for this. Thanks!

Look into <linux/bitfield.h> header... I think you could use FIELD_GET(), BIT() and GENMASK() macros for parsing.

Quoted 412 lines
Quoted 37 lines
Quoted 37 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +36 -0
+
+	alu->imm = (u16)(d64 & 0xffff);
+	alu->dedicate_flags_ena = ((d64 >> 16) & 0x1) != 0;
+	alu->dst_start = (u8)((d64 >> 17) & 0x3f);
+	alu->dst_len = (u8)((d64 >> 23) & 0x3f);
+	alu->flags_extr_imm = ((d64 >> 29) & 0x1) != 0;
+	alu->flags_start_imm = (u8)((d64 >> 30) & 0xff);
+}
+
+/** The function parses a 384 bits IMEM entry with below format:
+ *  BIT 0-3:	Boost Main (ii->b_m)
+ *  BIT 4-13:	Boost Key Build (ii->b_kb)
+ *  BIT 14-15:	PG Priority (ii->pg)
+ *  BIT 16-33:	Next Proto Key Build (ii->np_kb)
+ *  BIT 34-68:	PG Key Build (ii->pg_kb)
+ *  BIT 69-164:	ALU0 (ii->alu0)
+ *  BIT 165-260:ALU1 (ii->alu1)
+ *  BIT 261-356:ALU2 (ii->alu2)
+ *  BIT 357-383:Reserved
+ */
+static void _imem_parse_item(struct ice_hw *hw, u16 idx, void *item,
+			     void *data, int size)
+{
+	struct ice_imem_item *ii = item;
+	u8 *buf = data;
+
+	ii->idx = idx;
+
+	_imem_bm_init(&ii->b_m, buf[0]);
+	_imem_bkb_init(&ii->b_kb, *((u16 *)(&buf[0])) >> 4);
+
+	ii->pg = (u8)((buf[1] & 0xc0) >> 6);
+	_imem_npkb_init(&ii->np_kb, *((u32 *)(&buf[2])));
+	_imem_pgkb_init(&ii->pg_kb, *((u64 *)(&buf[2])) >> 18);
+	_imem_alu_init(&ii->alu0, &buf[8]);
+	_imem_alu_init(&ii->alu1, &buf[20]);
Quoted 8 lines

drivers/net/ethernet/intel/ice/ice_imem.c line 236

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +5 -0
+	_imem_alu_init(&ii->alu2, &buf[32]);
+
+	if (hw->debug_mask & ICE_DBG_PARSER)
+		ice_imem_dump(hw, ii);
+}

The same also here... bits description in the comments are nice but please use macros or enums also in the code.

Sure, thanks!

Quoted 28 lines

Review

Quoted 16 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +14 -0
+
+/**
+ * ice_imem_table_get - create an imem table
+ * @hw: pointer to the hardware structure
+ */
+struct ice_imem_item *ice_imem_table_get(struct ice_hw *hw)
+{
+	return (struct ice_imem_item *)
+		ice_parser_create_table(hw, ICE_SID_RXPARSER_IMEM,
+					sizeof(struct ice_imem_item),
+					ICE_IMEM_TABLE_SIZE,
+					ice_parser_sect_item_get,
+					_imem_parse_item);
+}
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_imem.h

Quoted 11 lines

new file mode 100644
index 000000000000..b6b923d67112

drivers/net/ethernet/intel/ice/ice_imem.h new file +6 -0
@@ -0,0 +1,108 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#ifndef _ICE_IMEM_H_
+#define _ICE_IMEM_H_
+
Quoted 8 lines

drivers/net/ethernet/intel/ice/ice_imem.h line 12

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_imem.h new file +6 -0
+struct ice_bst_main {
+	bool al0;
+	bool al1;
+	bool al2;
+	bool pg;
+};

Please use more descriptive names.

These names are just from the spec of the hardware. Actually there is no more meaningful description about them. These functions are only used to get value from certain bits. Better to keep the names here to aligned with the spec. And we will try if we can add some doc here. Thanks!

Quoted 21 lines
Quoted 21 lines
drivers/net/ethernet/intel/ice/ice_imem.h new file +20 -0
+
+struct ice_bst_keybuilder {
+	u8 priority;
+	bool tsr_ctrl;
+};
+
+struct ice_np_keybuilder {
+	u8 ops;
+	u8 start_or_reg0;
+	u8 len_or_reg1;
+};
+
+struct ice_pg_keybuilder {
+	bool flag0_ena;
+	bool flag1_ena;
+	bool flag2_ena;
+	bool flag3_ena;
+	u8 flag0_idx;
+	u8 flag1_idx;
+	u8 flag2_idx;
Quoted 8 lines

drivers/net/ethernet/intel/ice/ice_imem.h line 35

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_imem.h new file +3 -0
+	u8 flag3_idx;
+	u8 alu_reg_idx;
+};

What are flag0..3? More descriptive names should be fine... If they are multipurpose you can use anonymous union of bools with context dependent
field names inside.

Same here. There is no more meaningful description in the spec. Better to keep these names, in case anyone want to lookup them in the spec. But we will try if we can add some doc here.
Thanks!

Quoted 128 lines

Review

Quoted 75 lines
drivers/net/ethernet/intel/ice/ice_imem.h new file +73 -0
+
+enum ice_alu_opcode {
+	ICE_ALU_PARK = 0,
+	ICE_ALU_MOV_ADD = 1,
+	ICE_ALU_ADD = 2,
+	ICE_ALU_MOV_AND = 4,
+	ICE_ALU_AND = 5,
+	ICE_ALU_AND_IMM = 6,
+	ICE_ALU_MOV_OR = 7,
+	ICE_ALU_OR = 8,
+	ICE_ALU_MOV_XOR = 9,
+	ICE_ALU_XOR = 10,
+	ICE_ALU_NOP = 11,
+	ICE_ALU_BR = 12,
+	ICE_ALU_BREQ = 13,
+	ICE_ALU_BRNEQ = 14,
+	ICE_ALU_BRGT = 15,
+	ICE_ALU_BRLT = 16,
+	ICE_ALU_BRGEQ = 17,
+	ICE_ALU_BRLEG = 18,
+	ICE_ALU_SETEQ = 19,
+	ICE_ALU_ANDEQ = 20,
+	ICE_ALU_OREQ = 21,
+	ICE_ALU_SETNEQ = 22,
+	ICE_ALU_ANDNEQ = 23,
+	ICE_ALU_ORNEQ = 24,
+	ICE_ALU_SETGT = 25,
+	ICE_ALU_ANDGT = 26,
+	ICE_ALU_ORGT = 27,
+	ICE_ALU_SETLT = 28,
+	ICE_ALU_ANDLT = 29,
+	ICE_ALU_ORLT = 30,
+	ICE_ALU_MOV_SUB = 31,
+	ICE_ALU_SUB = 32,
+	ICE_ALU_INVALID = 64,
+};
+
+struct ice_alu {
+	enum ice_alu_opcode opc;
+	u8 src_start;
+	u8 src_len;
+	bool shift_xlate_select;
+	u8 shift_xlate_key;
+	u8 src_reg_id;
+	u8 dst_reg_id;
+	bool inc0;
+	bool inc1;
+	u8 proto_offset_opc;
+	u8 proto_offset;
+	u8 branch_addr;
+	u16 imm;
+	bool dedicate_flags_ena;
+	u8 dst_start;
+	u8 dst_len;
+	bool flags_extr_imm;
+	u8 flags_start_imm;
+};
+
+struct ice_imem_item {
+	u16 idx;
+	struct ice_bst_main b_m;
+	struct ice_bst_keybuilder b_kb;
+	u8 pg;
+	struct ice_np_keybuilder np_kb;
+	struct ice_pg_keybuilder pg_kb;
+	struct ice_alu alu0;
+	struct ice_alu alu1;
+	struct ice_alu alu2;
+};
+
+void ice_imem_dump(struct ice_hw *hw, struct ice_imem_item *item);
+struct ice_imem_item *ice_imem_table_get(struct ice_hw *hw);
+#endif /* _ICE_IMEM_H_ */
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_parser.c

Quoted 8 lines

index 692ad26ec551..a35f45964c9e 100644

drivers/net/ethernet/intel/ice/ice_parser.c +1 -0
@@ -2,6 +2,96 @@
   /* Copyright (C) 2018-2023 Intel Corporation */
 
   #include "ice_common.h"
+#include "ice_parser_util.h"

drivers/net/ethernet/intel/ice/ice_parser.c line 15

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_parser.c +10 -0
+
+#define ICE_SEC_DATA_OFFSET				4
+#define ICE_SID_RXPARSER_IMEM_ENTRY_SIZE		48
+
+/**
+ * ice_parser_sect_item_get - parse a item from a section
+ * @sect_type: section type
+ * @section: section object
+ * @index: index of the item to get
+ * @offset: dummy as prototype of ice_pkg_enum_entry's last

parameter

Quoted 17 lines
drivers/net/ethernet/intel/ice/ice_parser.c +17 -0
+ */
+void *ice_parser_sect_item_get(u32 sect_type, void *section,
+			       u32 index, u32 *offset)
+{
+	struct ice_pkg_sect_hdr *hdr;
+	int data_off = ICE_SEC_DATA_OFFSET;
+	int size;
+
+	if (!section)
+		return NULL;
+
+	switch (sect_type) {
+	case ICE_SID_RXPARSER_IMEM:
+		size = ICE_SID_RXPARSER_IMEM_ENTRY_SIZE;
+		break;
+	default:
+		return NULL;

drivers/net/ethernet/intel/ice/ice_parser.c line 42

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_parser.c +10 -0
+	}
+
+	hdr = section;
+	if (index >= le16_to_cpu(hdr->count))
+		return NULL;
+
+	return (void *)((uintptr_t)section +
+			(uintptr_t)data_off +
+			((uintptr_t)index * (uintptr_t)size));
+}

Use size_t for 'data' and 'data_off' to avoid superfluous type cast to uintptr_t. Also you don't need to cast section ptr to uintptr_t and back to void *. Just use cast to (u8 *) that can be used in arithmentic and can be used as (void *) return value:

Quoted 3 lines

size_t data_off, size;
...
return (u8 *)section + data_off + index * size;

Thanks for the detailed advice!

Will update this in the coming version, thanks a lot!

Quoted 150 lines
Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_parser.c +3 -0
+
+/**
+ * ice_parser_create_table - create a item table from a section

drivers/net/ethernet/intel/ice/ice_parser.c

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_parser.c +10 -0
+ * @hw: pointer to the hardware structure
+ * @sect_type: section type
+ * @item_size: item size in byte
+ * @length: number of items in the table to create
+ * @item_get: the function will be parsed to ice_pkg_enum_entry
+ * @parse_item: the function to parse the item
+ */
+void *ice_parser_create_table(struct ice_hw *hw, u32 sect_type,
+			      u32 item_size, u32 length,
+			      void *(*item_get)(u32 sect_type, void

*section,

drivers/net/ethernet/intel/ice/ice_parser.c int ice_parser_create(struct ice_hw *hw, struct

Quoted 51 lines
drivers/net/ethernet/intel/ice/ice_parser.c +40 -0
+						u32 index, u32 *offset),
+			      void (*parse_item)(struct ice_hw *hw, u16 idx,
+						 void *item, void *data,
+						 int size))
+{
+	struct ice_seg *seg = hw->seg;
+	struct ice_pkg_enum state;
+	u16 idx = 0xffff;
+	void *table;
+	void *data;
+
+	if (!seg)
+		return NULL;
+
+	table = devm_kzalloc(ice_hw_to_dev(hw), item_size * length,
+			     GFP_KERNEL);
+	if (!table)
+		return NULL;
+
+	memset(&state, 0, sizeof(state));
+	do {
+		data = ice_pkg_enum_entry(seg, &state, sect_type, NULL,
+					  item_get);
+		seg = NULL;
+		if (data) {
+			struct ice_pkg_sect_hdr *hdr =
+				(struct ice_pkg_sect_hdr *)state.sect;
+
+			idx = le16_to_cpu(hdr->offset) + state.entry_idx;
+			parse_item(hw, idx,
+				   (void *)((uintptr_t)table +
+					    ((uintptr_t)idx *
+					     (uintptr_t)item_size)),
+				   data, item_size);
+		}
+	} while (data);
+
+	return table;
+}
 
   /**
    * ice_parser_create - create a parser instance
@@ -11,6 +101,7 @@
   int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr)
   {
   	struct ice_parser *p;
+	int status;
 
   	p = devm_kzalloc(ice_hw_to_dev(hw), sizeof(struct ice_parser),
   			 GFP_KERNEL);
@@ -20,8 +111,17 @@ int ice_parser_create(struct ice_hw *hw, struct

ice_parser **psr)

drivers/net/ethernet/intel/ice/ice_parser.c int ice_parser_create(struct ice_hw *hw, struct

Quoted 18 lines
drivers/net/ethernet/intel/ice/ice_parser.c +9 -0
   	p->hw = hw;
   	p->rt.psr = p;
 
+	p->imem_table = ice_imem_table_get(hw);
+	if (!p->imem_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
   	*psr = p;
   	return 0;
+err:
+	ice_parser_destroy(p);
+	return status;
   }
 
   /**
@@ -30,5 +130,7 @@ int ice_parser_create(struct ice_hw *hw, struct

ice_parser **psr)

Review

Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_parser.c +2 -0
    */
   void ice_parser_destroy(struct ice_parser *psr)
   {
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->imem_table);
+
   	devm_kfree(ice_hw_to_dev(psr->hw), psr);
   }
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_parser.h

Review

Quoted 14 lines

index c6cd74c6e434..b5a3c473666a 100644

drivers/net/ethernet/intel/ice/ice_parser.h +3 -0
@@ -6,6 +6,9 @@
 
   struct ice_parser {
   	struct ice_hw *hw; /* pointer to the hardware structure */
+
+	/* load data from section ICE_SID_RX_PARSER_IMEM */
+	struct ice_imem_item *imem_table;
   };
 
   int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_parser_util.h

Review

Quoted 30 lines

new file mode 100644
index 000000000000..6259d3d97b23

drivers/net/ethernet/intel/ice/ice_parser_util.h new file +24 -0
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#ifndef _ICE_PARSER_UTIL_H_
+#define _ICE_PARSER_UTIL_H_
+
+#include "ice_imem.h"
+
+struct ice_pkg_sect_hdr {
+	__le16 count;
+	__le16 offset;
+};
+
+void *ice_parser_sect_item_get(u32 sect_type, void *section,
+			       u32 index, u32 *offset);
+
+void *ice_parser_create_table(struct ice_hw *hw, u32 sect_type,
+			      u32 item_size, u32 length,
+			      void *(*handler)(u32 sect_type, void *section,
+					       u32 index, u32 *offset),
+			      void (*parse_item)(struct ice_hw *hw, u16 idx,
+						 void *item, void *data,
+						 int size));
+#endif /* _ICE_PARSER_UTIL_H_ */
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_type.h

Quoted 9 lines

index a09556e57803..fa4336dd55f7 100644

drivers/net/ethernet/intel/ice/ice_type.h +1 -0
@@ -60,6 +60,7 @@ static inline u32 ice_round_to_num(u32 N, u32 R)
   				 ICE_DBG_AQ_DESC	| \
   				 ICE_DBG_AQ_DESC_BUF	| \
   				 ICE_DBG_AQ_CMD)
+#define ICE_DBG_PARSER		BIT_ULL(28)
 
Quoted 3 lines
Quoted 2 lines

drivers/net/ethernet/intel/ice/ice_type.h static inline u32 ice_round_to_num(u32 N, u32 R) · line 66

Quoted 2 lines
drivers/net/ethernet/intel/ice/ice_type.h +0 -0
   #define ICE_DBG_USER		BIT_ULL(31)
 

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#6 lore raw

Re: [Intel-wired-lan] [PATCH iwl-next v2 02/15] ice: init imem table for parser

Quoted 192 lines

-----Original Message-----
From: Ivan Vecera <[email protected]>
Sent: Wednesday, August 2, 2023 23:57
To: Guo, Junfeng <[email protected]>; intel-wired- [email protected]
Cc: Zhang, Qi Z <[email protected]>; mschmidt <[email protected]>; poros <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH iwl-next v2 02/15] ice: init imem table for parser

Hi, thank you for reply... see my inline comments...

Ivan

Quoted 22 lines · Junfeng
Quoted 22 lines

-----Original Message-----
From: Ivan Vecera <[email protected]>
Sent: Monday, July 24, 2023 18:26
To: Guo, Junfeng <[email protected]>; intel-wired- [email protected]
Cc: Zhang, Qi Z <[email protected]>; mschmidt <[email protected]>; poros <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH iwl-next v2 02/15] ice: init imem table for parser

See inline comments...

Quoted 6 lines · Junfeng Guo

Parse DDP section ICE_SID_RXPARSER_IMEM into an arrary of struct ice_imem_item.

---
   drivers/net/ethernet/intel/ice/ice_imem.c     | 250

++++++++++++++++++

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
   drivers/net/ethernet/intel/ice/ice_imem.h     | 108 ++++++++
   drivers/net/ethernet/intel/ice/ice_parser.c   | 102 +++++++
   drivers/net/ethernet/intel/ice/ice_parser.h   |   3 +
   .../net/ethernet/intel/ice/ice_parser_util.h  |  24 ++
   drivers/net/ethernet/intel/ice/ice_type.h     |   1 +
   6 files changed, 488 insertions(+)

create mode 100644 drivers/net/ethernet/intel/ice/ice_imem.c create mode 100644 drivers/net/ethernet/intel/ice/ice_imem.h create mode 100644

drivers/net/ethernet/intel/ice/ice_parser_util.h

Quoted 62 lines
Quoted 62 lines

Review

Quoted 2 lines
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 5 lines

new file mode 100644
index 000000000000..2bd48f080326

drivers/net/ethernet/intel/ice/ice_imem.c line 9

Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +9 -0
@@ -0,0 +1,250 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#include "ice_common.h"
+#include "ice_parser_util.h"
+
+#define ICE_IMEM_TABLE_SIZE 192
+
+static void _imem_bst_bm_dump(struct ice_hw *hw, struct

ice_bst_main *bm)

drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +9 -0
+{
+	dev_info(ice_hw_to_dev(hw), "boost main:\n");
+	dev_info(ice_hw_to_dev(hw), "\tal0 = %d\n", bm->al0);
+	dev_info(ice_hw_to_dev(hw), "\tal1 = %d\n", bm->al1);
+	dev_info(ice_hw_to_dev(hw), "\tal2 = %d\n", bm->al2);
+	dev_info(ice_hw_to_dev(hw), "\tpg = %d\n", bm->pg);
+}
+
+static void _imem_bst_kb_dump(struct ice_hw *hw, struct

ice_bst_keybuilder *kb)

drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +7 -0
+{
+	dev_info(ice_hw_to_dev(hw), "boost key builder:\n");
+	dev_info(ice_hw_to_dev(hw), "\tpriority = %d\n", kb->priority);
+	dev_info(ice_hw_to_dev(hw), "\ttsr_ctrl = %d\n", kb->tsr_ctrl);
+}
+
+static void _imem_np_kb_dump(struct ice_hw *hw, struct

ice_np_keybuilder *kb)

drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +6 -0
+{
+	dev_info(ice_hw_to_dev(hw), "next proto key builder:\n");
+	dev_info(ice_hw_to_dev(hw), "\tops = %d\n", kb->ops);
+	dev_info(ice_hw_to_dev(hw), "\tstart_or_reg0 = %d\n",
+		 kb->start_or_reg0);
+	dev_info(ice_hw_to_dev(hw), "\tlen_or_reg1 = %d\n", kb-

len_or_reg1);

drivers/net/ethernet/intel/ice/ice_imem.c new file +3 -0
+}
+
+static void _imem_pg_kb_dump(struct ice_hw *hw, struct

ice_pg_keybuilder *kb)

Quoted 15 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +3 -0
+{
+	dev_info(ice_hw_to_dev(hw), "parse graph key builder:\n");
+	dev_info(ice_hw_to_dev(hw), "\tflag0_ena = %d\n", kb-

flag0_ena);

drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tflag1_ena = %d\n", kb-

flag1_ena);

drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tflag2_ena = %d\n", kb-

flag2_ena);

drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tflag3_ena = %d\n", kb-

flag3_ena);

drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tflag0_idx = %d\n", kb-

flag0_idx);

drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tflag1_idx = %d\n", kb-

flag1_idx);

drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tflag2_idx = %d\n", kb-
Quoted 8 lines
Quoted 8 lines

drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 8 lines

flag2_idx);

drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tflag3_idx = %d\n", kb-

flag3_idx);

drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\talu_reg_idx = %d\n", kb-

alu_reg_idx);

drivers/net/ethernet/intel/ice/ice_imem.c new file +3 -0
+}
+
+static void _imem_alu_dump(struct ice_hw *hw, struct ice_alu *alu,

int

Quoted 31 lines
Quoted 31 lines

index)

Quoted 30 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +4 -0
+{
+	dev_info(ice_hw_to_dev(hw), "alu%d:\n", index);
+	dev_info(ice_hw_to_dev(hw), "\topc = %d\n", alu->opc);
+	dev_info(ice_hw_to_dev(hw), "\tsrc_start = %d\n", alu-

src_start);

drivers/net/ethernet/intel/ice/ice_imem.c new file +6 -0
+	dev_info(ice_hw_to_dev(hw), "\tsrc_len = %d\n", alu->src_len);
+	dev_info(ice_hw_to_dev(hw), "\tshift_xlate_select = %d\n",
+		 alu->shift_xlate_select);
+	dev_info(ice_hw_to_dev(hw), "\tshift_xlate_key = %d\n",
+		 alu->shift_xlate_key);
+	dev_info(ice_hw_to_dev(hw), "\tsrc_reg_id = %d\n", alu-

src_reg_id);

drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tdst_reg_id = %d\n", alu-

dst_reg_id);

drivers/net/ethernet/intel/ice/ice_imem.c new file +7 -0
+	dev_info(ice_hw_to_dev(hw), "\tinc0 = %d\n", alu->inc0);
+	dev_info(ice_hw_to_dev(hw), "\tinc1 = %d\n", alu->inc1);
+	dev_info(ice_hw_to_dev(hw), "\tproto_offset_opc = %d\n",
+		 alu->proto_offset_opc);
+	dev_info(ice_hw_to_dev(hw), "\tproto_offset = %d\n",
+		 alu->proto_offset);
+	dev_info(ice_hw_to_dev(hw), "\tbranch_addr = %d\n", alu-

branch_addr);

drivers/net/ethernet/intel/ice/ice_imem.c new file +2 -0
+	dev_info(ice_hw_to_dev(hw), "\timm = %d\n", alu->imm);
+	dev_info(ice_hw_to_dev(hw), "\tdst_start = %d\n", alu-

dst_start);

drivers/net/ethernet/intel/ice/ice_imem.c new file +5 -0
+	dev_info(ice_hw_to_dev(hw), "\tdst_len = %d\n", alu->dst_len);
+	dev_info(ice_hw_to_dev(hw), "\tflags_extr_imm = %d\n",
+		 alu->flags_extr_imm);
+	dev_info(ice_hw_to_dev(hw), "\tflags_start_imm= %d\n",
+		 alu->flags_start_imm);
Quoted 8 lines
Quoted 8 lines

drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +8 -0
+}
+
+/**
+ * ice_imem_dump - dump an imem item info
+ * @hw: pointer to the hardware structure
+ * @item: imem item to dump
+ */
+void ice_imem_dump(struct ice_hw *hw, struct ice_imem_item

*item)

Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +19 -0
+{
+	dev_info(ice_hw_to_dev(hw), "index = %d\n", item->idx);
+	_imem_bst_bm_dump(hw, &item->b_m);
+	_imem_bst_kb_dump(hw, &item->b_kb);
+	dev_info(ice_hw_to_dev(hw), "pg priority = %d\n", item->pg);
+	_imem_np_kb_dump(hw, &item->np_kb);
+	_imem_pg_kb_dump(hw, &item->pg_kb);
+	_imem_alu_dump(hw, &item->alu0, 0);
+	_imem_alu_dump(hw, &item->alu1, 1);
+	_imem_alu_dump(hw, &item->alu2, 2);
+}
+
+/** The function parses a 4 bits Boost Main with below format:
+ *  BIT 0: ALU 0 (bm->alu0)
+ *  BIT 1: ALU 1 (bm->alu1)
+ *  BIT 2: ALU 2 (bm->alu2)
+ *  BIT 3: Parge Graph (bm->pg)
+ */
+static void _imem_bm_init(struct ice_bst_main *bm, u8 data)
Quoted 8 lines
Quoted 8 lines

drivers/net/ethernet/intel/ice/ice_imem.c line 106

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +6 -0
+{
+	bm->al0 = (data & 0x1) != 0;
+	bm->al1 = (data & 0x2) != 0;
+	bm->al2 = (data & 0x4) != 0;
+	bm->pg = (data & 0x8) != 0;
+}

Please introduce mask macros with values BIT(0), BIT(1)... and use

them

Quoted 4 lines
Quoted 1 line

here instead of magic hardcoded values.

Sure, make sense!

Quoted 8 lines
Quoted 3 lines

The detailed info for each BIT has been commented before the function. It would be better to use BIT() for one bit select.
But there seems no macro for bit range in kernel. Is there standard

usage for this purpose?

For bit ranges you can use GENMASK*() macros from <linux/bits.h> Check this header file and also <linux/bitops.h>, there is useful stuff for bit operations.

Thanks for the knowledge! It helps a lot!
Will check and utilize this for the code rebase. Thanks!

Quoted 120 lines
Quoted 6 lines

Will update in the coming version. Thanks!

Quoted 3 lines

drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +2 -0
+
+/** The function parses a 10 bits Boost Main Build with below

format:

Quoted 110 lines
Quoted 11 lines

drivers/net/ethernet/intel/ice/ice_imem.c line 117

Quoted 9 lines
+ *  BIT 0-7:	Priority (bkb->priority)
+ *  BIT 8:	TSR Control (bkb->tsr_ctrl)
+ *  BIT 9:	Reserved

+ */

drivers/net/ethernet/intel/ice/ice_imem.c new file +5 -0
+static void _imem_bkb_init(struct ice_bst_keybuilder *bkb, u16 data)
+{
+	bkb->priority = (u8)(data & 0xff);
+	bkb->tsr_ctrl = (data & 0x100) != 0;
+}

Ditto...

Sure, thanks!

Quoted 4 lines

drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +2 -0
+
+/** The function parses a 18 bits Next Protocol Key Build with below

format:

Quoted 12 lines

drivers/net/ethernet/intel/ice/ice_imem.c line 129

Quoted 10 lines
+ *  BIT 0-1:	Opcode kb->ops
+ *  BIT 2-9:	Start / Reg 0 (kb->start_or_reg0)
+ *  BIT 10-17:	Length / Reg 1 (kb->len_or_reg1)

+ */

drivers/net/ethernet/intel/ice/ice_imem.c new file +6 -0
+static void _imem_npkb_init(struct ice_np_keybuilder *kb, u32 data)
+{
+	kb->ops = (u8)(data & 0x3);
+	kb->start_or_reg0 = (u8)((data >> 2) & 0xff);
+	kb->len_or_reg1 = (u8)((data >> 10) & 0xff);
+}

Ditto... the same also for shift values.

Sure, thanks!

Quoted 20 lines

drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +2 -0
+
+/** The function parses a 35 bits Parse Graph Key Build with below

format:

Quoted 16 lines
+ *  BIT 0:	Flag 0 Enable (kb->flag0_ena)
+ *  BIT 1-6:	Flag 0 Index (kb->flag0_idx)
+ *  BIT 7:	Flag 1 Enable (kb->flag1_ena)
+ *  BIT 8-13:	Flag 1 Index (kb->flag1_idx)
+ *  BIT 14:	Flag 2 Enable (kb->flag2_ena)
+ *  BIT 15-20:	Flag 2 Index (kb->flag2_idx)
+ *  BIT 21:	Flag 3 Enable (kb->flag3_ena)
+ *  BIT 22-27:	Flag 3 Index (kb->flag3_idx)
+ *  BIT 28-34:	ALU Register Index (kb->alu_reg_idx)

+ */

drivers/net/ethernet/intel/ice/ice_imem.c new file +6 -0
+static void _imem_pgkb_init(struct ice_pg_keybuilder *kb, u64 data)
+{
+	kb->flag0_ena = (data & 0x1) != 0;
+	kb->flag0_idx = (u8)((data >> 1) & 0x3f);
+	kb->flag1_ena = ((data >> 7) & 0x1) != 0;
+	kb->flag1_idx = (u8)((data >> 8) & 0x3f);
Quoted 8 lines
Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +6 -0
+	kb->flag2_ena = ((data >> 14) & 0x1) != 0;
+	kb->flag2_idx = (u8)((data >> 15) & 0x3f);
+	kb->flag3_ena = ((data >> 21) & 0x1) != 0;
+	kb->flag3_idx = (u8)((data >> 22) & 0x3f);
+	kb->alu_reg_idx = (u8)((data >> 28) & 0x7f);
+}

...

Sure, thanks!

Quoted 37 lines
Quoted 37 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +36 -0
+
+/** The function parses a 96 bits ALU entry with below format:
+ *  BIT 0-5:	Opcode (alu->opc)
+ *  BIT 6-13:	Source Start (alu->src_start)
+ *  BIT 14-18:	Source Length (alu->src_len)
+ *  BIT 19:	Shift/Xlate Select (alu->shift_xlate_select)
+ *  BIT 20-23:	Shift/Xlate Key (alu->shift_xlate_key)
+ *  BIT 24-30:	Source Register ID (alu->src_reg_id)
+ *  BIT 31-37:	Dest. Register ID (alu->dst_reg_id)
+ *  BIT 38:	Inc0 (alu->inc0)
+ *  BIT 39:	Inc1:(alu->inc1)
+ *  BIT 40:41	Protocol Offset Opcode (alu->proto_offset_opc)
+ *  BIT 42:49	Protocol Offset (alu->proto_offset)
+ *  BIT 50:57	Branch Address (alu->branch_addr)
+ *  BIT 58:73	Immediate (alu->imm)
+ *  BIT 74	Dedicated Flags Enable (alu->dedicate_flags_ena)
+ *  BIT 75:80	Dest. Start (alu->dst_start)
+ *  BIT 81:86	Dest. Length (alu->dst_len)
+ *  BIT 87	Flags Extract Imm. (alu->flags_extr_imm)
+ *  BIT 88:95	Flags Start/Immediate (alu->flags_start_imm)
+ *
+ *  NOTE: the first 5 bits are skipped as the start bit is not
+ *  byte aligned.
+ */
+static void _imem_alu_init(struct ice_alu *alu, u8 *data)
+{
+	u64 d64 = *(u64 *)data >> 5;
+
+	alu->opc = (enum ice_alu_opcode)(d64 & 0x3f);
+	alu->src_start = (u8)((d64 >> 6) & 0xff);
+	alu->src_len = (u8)((d64 >> 14) & 0x1f);
+	alu->shift_xlate_select = ((d64 >> 19) & 0x1) != 0;
+	alu->shift_xlate_key = (u8)((d64 >> 20) & 0xf);
+	alu->src_reg_id = (u8)((d64 >> 24) & 0x7f);
+	alu->dst_reg_id = (u8)((d64 >> 31) & 0x7f);
+	alu->inc0 = ((d64 >> 38) & 0x1) != 0;
Quoted 8 lines

drivers/net/ethernet/intel/ice/ice_imem.c line 195

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +6 -0
+	alu->inc1 = ((d64 >> 39) & 0x1) != 0;
+	alu->proto_offset_opc = (u8)((d64 >> 40) & 0x3);
+	alu->proto_offset = (u8)((d64 >> 42) & 0xff);
+	alu->branch_addr = (u8)((d64 >> 50) & 0xff);
+
+	d64 = *(u64 *)(&data[7]) >> 7;

What is at offset 7 and why shift 7?? Use corresponding macros please.

Quoted 3 lines

This is just calculated numbers to get target bits.
And the first 5 bits are skipped due to not byte aligned. Thus, 8 * 7 + 7 - 5 = 58, which is just aligned with BIT 58:73 for

Quoted 6 lines

Immediate (alu->imm).

Quoted 2 lines

Sure, it would be better to use macros for this. Thanks!

Look into <linux/bitfield.h> header... I think you could use FIELD_GET(), BIT() and GENMASK() macros for parsing.

Thanks for the knowledge! It helps a lot! Will check for this too!

Quoted 409 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +13 -0
+
+	alu->imm = (u16)(d64 & 0xffff);
+	alu->dedicate_flags_ena = ((d64 >> 16) & 0x1) != 0;
+	alu->dst_start = (u8)((d64 >> 17) & 0x3f);
+	alu->dst_len = (u8)((d64 >> 23) & 0x3f);
+	alu->flags_extr_imm = ((d64 >> 29) & 0x1) != 0;
+	alu->flags_start_imm = (u8)((d64 >> 30) & 0xff);
+}
+
+/** The function parses a 384 bits IMEM entry with below format:
+ *  BIT 0-3:	Boost Main (ii->b_m)
+ *  BIT 4-13:	Boost Key Build (ii->b_kb)
+ *  BIT 14-15:	PG Priority (ii->pg)
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
+ *  BIT 16-33:	Next Proto Key Build (ii->np_kb)
+ *  BIT 34-68:	PG Key Build (ii->pg_kb)
+ *  BIT 69-164:	ALU0 (ii->alu0)
+ *  BIT 165-260:ALU1 (ii->alu1)
+ *  BIT 261-356:ALU2 (ii->alu2)
+ *  BIT 357-383:Reserved

+ */
+static void _imem_parse_item(struct ice_hw *hw, u16 idx, void

*item,

Quoted 99 lines
Quoted 15 lines
Quoted 15 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +15 -0
+			     void *data, int size)
+{
+	struct ice_imem_item *ii = item;
+	u8 *buf = data;
+
+	ii->idx = idx;
+
+	_imem_bm_init(&ii->b_m, buf[0]);
+	_imem_bkb_init(&ii->b_kb, *((u16 *)(&buf[0])) >> 4);
+
+	ii->pg = (u8)((buf[1] & 0xc0) >> 6);
+	_imem_npkb_init(&ii->np_kb, *((u32 *)(&buf[2])));
+	_imem_pgkb_init(&ii->pg_kb, *((u64 *)(&buf[2])) >> 18);
+	_imem_alu_init(&ii->alu0, &buf[8]);
+	_imem_alu_init(&ii->alu1, &buf[20]);
Quoted 8 lines

drivers/net/ethernet/intel/ice/ice_imem.c line 236

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +5 -0
+	_imem_alu_init(&ii->alu2, &buf[32]);
+
+	if (hw->debug_mask & ICE_DBG_PARSER)
+		ice_imem_dump(hw, ii);
+}

The same also here... bits description in the comments are nice but please use macros or enums also in the code.

Sure, thanks!

Quoted 28 lines

Review

Quoted 16 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +14 -0
+
+/**
+ * ice_imem_table_get - create an imem table
+ * @hw: pointer to the hardware structure
+ */
+struct ice_imem_item *ice_imem_table_get(struct ice_hw *hw)
+{
+	return (struct ice_imem_item *)
+		ice_parser_create_table(hw, ICE_SID_RXPARSER_IMEM,
+					sizeof(struct ice_imem_item),
+					ICE_IMEM_TABLE_SIZE,
+					ice_parser_sect_item_get,
+					_imem_parse_item);
+}
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_imem.h

Quoted 11 lines

new file mode 100644
index 000000000000..b6b923d67112

drivers/net/ethernet/intel/ice/ice_imem.h new file +6 -0
@@ -0,0 +1,108 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#ifndef _ICE_IMEM_H_
+#define _ICE_IMEM_H_
+
Quoted 8 lines

drivers/net/ethernet/intel/ice/ice_imem.h line 12

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_imem.h new file +6 -0
+struct ice_bst_main {
+	bool al0;
+	bool al1;
+	bool al2;
+	bool pg;
+};

Please use more descriptive names.

These names are just from the spec of the hardware. Actually there is no more meaningful description about them. These functions are only used to get value from certain bits. Better to keep the names here to aligned with the spec. And we will try if we can add some doc here. Thanks!

Quoted 21 lines
Quoted 21 lines
drivers/net/ethernet/intel/ice/ice_imem.h new file +20 -0
+
+struct ice_bst_keybuilder {
+	u8 priority;
+	bool tsr_ctrl;
+};
+
+struct ice_np_keybuilder {
+	u8 ops;
+	u8 start_or_reg0;
+	u8 len_or_reg1;
+};
+
+struct ice_pg_keybuilder {
+	bool flag0_ena;
+	bool flag1_ena;
+	bool flag2_ena;
+	bool flag3_ena;
+	u8 flag0_idx;
+	u8 flag1_idx;
+	u8 flag2_idx;
Quoted 8 lines

drivers/net/ethernet/intel/ice/ice_imem.h line 35

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_imem.h new file +3 -0
+	u8 flag3_idx;
+	u8 alu_reg_idx;
+};

What are flag0..3? More descriptive names should be fine... If they are multipurpose you can use anonymous union of bools with context dependent
field names inside.

Quoted 2 lines

Same here. There is no more meaningful description in the spec. Better to keep these names, in case anyone want to lookup them in the

spec.

Quoted 67 lines

But we will try if we can add some doc here.
Thanks!

Quoted 64 lines
Quoted 64 lines
drivers/net/ethernet/intel/ice/ice_imem.h new file +63 -0
+
+enum ice_alu_opcode {
+	ICE_ALU_PARK = 0,
+	ICE_ALU_MOV_ADD = 1,
+	ICE_ALU_ADD = 2,
+	ICE_ALU_MOV_AND = 4,
+	ICE_ALU_AND = 5,
+	ICE_ALU_AND_IMM = 6,
+	ICE_ALU_MOV_OR = 7,
+	ICE_ALU_OR = 8,
+	ICE_ALU_MOV_XOR = 9,
+	ICE_ALU_XOR = 10,
+	ICE_ALU_NOP = 11,
+	ICE_ALU_BR = 12,
+	ICE_ALU_BREQ = 13,
+	ICE_ALU_BRNEQ = 14,
+	ICE_ALU_BRGT = 15,
+	ICE_ALU_BRLT = 16,
+	ICE_ALU_BRGEQ = 17,
+	ICE_ALU_BRLEG = 18,
+	ICE_ALU_SETEQ = 19,
+	ICE_ALU_ANDEQ = 20,
+	ICE_ALU_OREQ = 21,
+	ICE_ALU_SETNEQ = 22,
+	ICE_ALU_ANDNEQ = 23,
+	ICE_ALU_ORNEQ = 24,
+	ICE_ALU_SETGT = 25,
+	ICE_ALU_ANDGT = 26,
+	ICE_ALU_ORGT = 27,
+	ICE_ALU_SETLT = 28,
+	ICE_ALU_ANDLT = 29,
+	ICE_ALU_ORLT = 30,
+	ICE_ALU_MOV_SUB = 31,
+	ICE_ALU_SUB = 32,
+	ICE_ALU_INVALID = 64,
+};
+
+struct ice_alu {
+	enum ice_alu_opcode opc;
+	u8 src_start;
+	u8 src_len;
+	bool shift_xlate_select;
+	u8 shift_xlate_key;
+	u8 src_reg_id;
+	u8 dst_reg_id;
+	bool inc0;
+	bool inc1;
+	u8 proto_offset_opc;
+	u8 proto_offset;
+	u8 branch_addr;
+	u16 imm;
+	bool dedicate_flags_ena;
+	u8 dst_start;
+	u8 dst_len;
+	bool flags_extr_imm;
+	u8 flags_start_imm;
+};
+
+struct ice_imem_item {
+	u16 idx;
+	struct ice_bst_main b_m;
+	struct ice_bst_keybuilder b_kb;
+	u8 pg;
Quoted 8 lines
Quoted 8 lines

drivers/net/ethernet/intel/ice/ice_imem.h

Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_imem.h new file +8 -0
+	struct ice_np_keybuilder np_kb;
+	struct ice_pg_keybuilder pg_kb;
+	struct ice_alu alu0;
+	struct ice_alu alu1;
+	struct ice_alu alu2;
+};
+
+void ice_imem_dump(struct ice_hw *hw, struct ice_imem_item

*item);

Quoted 127 lines
Quoted 56 lines

Review

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_imem.h new file +2 -0
+struct ice_imem_item *ice_imem_table_get(struct ice_hw *hw);
+#endif /* _ICE_IMEM_H_ */
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_parser.c

Quoted 8 lines

index 692ad26ec551..a35f45964c9e 100644

drivers/net/ethernet/intel/ice/ice_parser.c +1 -0
@@ -2,6 +2,96 @@
   /* Copyright (C) 2018-2023 Intel Corporation */
 
   #include "ice_common.h"
+#include "ice_parser_util.h"

drivers/net/ethernet/intel/ice/ice_parser.c line 15

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_parser.c +10 -0
+
+#define ICE_SEC_DATA_OFFSET				4
+#define ICE_SID_RXPARSER_IMEM_ENTRY_SIZE		48
+
+/**
+ * ice_parser_sect_item_get - parse a item from a section
+ * @sect_type: section type
+ * @section: section object
+ * @index: index of the item to get
+ * @offset: dummy as prototype of ice_pkg_enum_entry's last

parameter

Quoted 17 lines
drivers/net/ethernet/intel/ice/ice_parser.c +17 -0
+ */
+void *ice_parser_sect_item_get(u32 sect_type, void *section,
+			       u32 index, u32 *offset)
+{
+	struct ice_pkg_sect_hdr *hdr;
+	int data_off = ICE_SEC_DATA_OFFSET;
+	int size;
+
+	if (!section)
+		return NULL;
+
+	switch (sect_type) {
+	case ICE_SID_RXPARSER_IMEM:
+		size = ICE_SID_RXPARSER_IMEM_ENTRY_SIZE;
+		break;
+	default:
+		return NULL;

drivers/net/ethernet/intel/ice/ice_parser.c line 42

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_parser.c +10 -0
+	}
+
+	hdr = section;
+	if (index >= le16_to_cpu(hdr->count))
+		return NULL;
+
+	return (void *)((uintptr_t)section +
+			(uintptr_t)data_off +
+			((uintptr_t)index * (uintptr_t)size));
+}

Use size_t for 'data' and 'data_off' to avoid superfluous type cast to uintptr_t. Also you don't need to cast section ptr to uintptr_t and back to void *. Just use cast to (u8 *) that can be used in arithmentic and can be used as (void *) return value:

Quoted 3 lines

size_t data_off, size;
...
return (u8 *)section + data_off + index * size;

Thanks for the detailed advice!

Will update this in the coming version, thanks a lot!

Quoted 63 lines
Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_parser.c +3 -0
+
+/**
+ * ice_parser_create_table - create a item table from a section

drivers/net/ethernet/intel/ice/ice_parser.c

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_parser.c +10 -0
+ * @hw: pointer to the hardware structure
+ * @sect_type: section type
+ * @item_size: item size in byte
+ * @length: number of items in the table to create
+ * @item_get: the function will be parsed to ice_pkg_enum_entry
+ * @parse_item: the function to parse the item
+ */
+void *ice_parser_create_table(struct ice_hw *hw, u32 sect_type,
+			      u32 item_size, u32 length,
+			      void *(*item_get)(u32 sect_type, void

*section,

Quoted 48 lines
drivers/net/ethernet/intel/ice/ice_parser.c +40 -0
+						u32 index, u32 *offset),
+			      void (*parse_item)(struct ice_hw *hw, u16 idx,
+						 void *item, void *data,
+						 int size))
+{
+	struct ice_seg *seg = hw->seg;
+	struct ice_pkg_enum state;
+	u16 idx = 0xffff;
+	void *table;
+	void *data;
+
+	if (!seg)
+		return NULL;
+
+	table = devm_kzalloc(ice_hw_to_dev(hw), item_size * length,
+			     GFP_KERNEL);
+	if (!table)
+		return NULL;
+
+	memset(&state, 0, sizeof(state));
+	do {
+		data = ice_pkg_enum_entry(seg, &state, sect_type, NULL,
+					  item_get);
+		seg = NULL;
+		if (data) {
+			struct ice_pkg_sect_hdr *hdr =
+				(struct ice_pkg_sect_hdr *)state.sect;
+
+			idx = le16_to_cpu(hdr->offset) + state.entry_idx;
+			parse_item(hw, idx,
+				   (void *)((uintptr_t)table +
+					    ((uintptr_t)idx *
+					     (uintptr_t)item_size)),
+				   data, item_size);
+		}
+	} while (data);
+
+	return table;
+}
 
   /**
    * ice_parser_create - create a parser instance
@@ -11,6 +101,7 @@
   int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr)
   {
   	struct ice_parser *p;
+	int status;
 
Quoted 3 lines
Quoted 3 lines

drivers/net/ethernet/intel/ice/ice_parser.c int ice_parser_create(struct ice_hw *hw,

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_parser.c +0 -0
   	p = devm_kzalloc(ice_hw_to_dev(hw), sizeof(struct ice_parser),
   			 GFP_KERNEL);
@@ -20,8 +111,17 @@ int ice_parser_create(struct ice_hw *hw,

struct

Quoted 17 lines
Quoted 17 lines

ice_parser **psr)

Quoted 16 lines
drivers/net/ethernet/intel/ice/ice_parser.c +9 -0
   	p->hw = hw;
   	p->rt.psr = p;
 
+	p->imem_table = ice_imem_table_get(hw);
+	if (!p->imem_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
   	*psr = p;
   	return 0;
+err:
+	ice_parser_destroy(p);
+	return status;
   }
 
Quoted 2 lines
Quoted 2 lines

drivers/net/ethernet/intel/ice/ice_parser.c int ice_parser_create(struct ice_hw *hw,

Quoted 2 lines
drivers/net/ethernet/intel/ice/ice_parser.c +0 -0
   /**
@@ -30,5 +130,7 @@ int ice_parser_create(struct ice_hw *hw,

struct

Quoted 56 lines
Quoted 56 lines

ice_parser **psr)

Review

Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_parser.c +2 -0
    */
   void ice_parser_destroy(struct ice_parser *psr)
   {
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->imem_table);
+
   	devm_kfree(ice_hw_to_dev(psr->hw), psr);
   }
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_parser.h

Review

Quoted 14 lines

index c6cd74c6e434..b5a3c473666a 100644

drivers/net/ethernet/intel/ice/ice_parser.h +3 -0
@@ -6,6 +6,9 @@
 
   struct ice_parser {
   	struct ice_hw *hw; /* pointer to the hardware structure */
+
+	/* load data from section ICE_SID_RX_PARSER_IMEM */
+	struct ice_imem_item *imem_table;
   };
 
   int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_parser_util.h

Review

Quoted 30 lines

new file mode 100644
index 000000000000..6259d3d97b23

drivers/net/ethernet/intel/ice/ice_parser_util.h new file +24 -0
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#ifndef _ICE_PARSER_UTIL_H_
+#define _ICE_PARSER_UTIL_H_
+
+#include "ice_imem.h"
+
+struct ice_pkg_sect_hdr {
+	__le16 count;
+	__le16 offset;
+};
+
+void *ice_parser_sect_item_get(u32 sect_type, void *section,
+			       u32 index, u32 *offset);
+
+void *ice_parser_create_table(struct ice_hw *hw, u32 sect_type,
+			      u32 item_size, u32 length,
+			      void *(*handler)(u32 sect_type, void *section,
+					       u32 index, u32 *offset),
+			      void (*parse_item)(struct ice_hw *hw, u16 idx,
+						 void *item, void *data,
+						 int size));
+#endif /* _ICE_PARSER_UTIL_H_ */
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_type.h

Quoted 13 lines
Quoted 4 lines
Quoted 4 lines

drivers/net/ethernet/intel/ice/ice_type.h static inline u32 ice_round_to_num(u32 N, u32

Quoted 4 lines

index a09556e57803..fa4336dd55f7 100644

drivers/net/ethernet/intel/ice/ice_type.h +0 -0
@@ -60,6 +60,7 @@ static inline u32 ice_round_to_num(u32 N, u32

R)

Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_type.h +1 -0
   				 ICE_DBG_AQ_DESC	| \
   				 ICE_DBG_AQ_DESC_BUF	| \
   				 ICE_DBG_AQ_CMD)
+#define ICE_DBG_PARSER		BIT_ULL(28)
 
   #define ICE_DBG_USER		BIT_ULL(31)
 

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#7 lore raw

PATCH v2 3/15 ice: init metainit table for parser

In reply to Junfeng Guo

Parse DDP section ICE_SID_RXPARSER_METADATA_INIT into an array of struct ice_metainit_item.

---
 drivers/net/ethernet/intel/ice/ice_metainit.c | 155 ++++++++++++++++++
 drivers/net/ethernet/intel/ice/ice_metainit.h |  45 +++++
 drivers/net/ethernet/intel/ice/ice_parser.c   |  11 ++
 drivers/net/ethernet/intel/ice/ice_parser.h   |   2 +
 .../net/ethernet/intel/ice/ice_parser_util.h  |   1 +
 5 files changed, 214 insertions(+)
 create mode 100644 drivers/net/ethernet/intel/ice/ice_metainit.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_metainit.h
drivers/net/ethernet/intel/ice/ice_metainit.c new file +155 -0
new file mode 100644
index 000000000000..911099a38087
@@ -0,0 +1,155 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#include "ice_common.h"
+#include "ice_parser_util.h"
+
+#define ICE_METAINIT_TABLE_SIZE 16
+
+/**
+ * ice_metainit_dump - dump an metainit item info
+ * @hw: pointer to the hardware structure
+ * @item: metainit item to dump
+ */
+void ice_metainit_dump(struct ice_hw *hw, struct ice_metainit_item *item)
+{
+	dev_info(ice_hw_to_dev(hw), "index = %d\n", item->idx);
+	dev_info(ice_hw_to_dev(hw), "tsr = %d\n", item->tsr);
+	dev_info(ice_hw_to_dev(hw), "ho = %d\n", item->ho);
+	dev_info(ice_hw_to_dev(hw), "pc = %d\n", item->pc);
+	dev_info(ice_hw_to_dev(hw), "pg_rn = %d\n", item->pg_rn);
+	dev_info(ice_hw_to_dev(hw), "cd = %d\n", item->cd);
+	dev_info(ice_hw_to_dev(hw), "gpr_a_ctrl = %d\n", item->gpr_a_ctrl);
+	dev_info(ice_hw_to_dev(hw), "gpr_a_data_mdid = %d\n",
+		 item->gpr_a_data_mdid);
+	dev_info(ice_hw_to_dev(hw), "gpr_a_data_start = %d\n",
+		 item->gpr_a_data_start);
+	dev_info(ice_hw_to_dev(hw), "gpr_a_data_len = %d\n",
+		 item->gpr_a_data_len);
+	dev_info(ice_hw_to_dev(hw), "gpr_a_id = %d\n", item->gpr_a_id);
+	dev_info(ice_hw_to_dev(hw), "gpr_b_ctrl = %d\n", item->gpr_b_ctrl);
+	dev_info(ice_hw_to_dev(hw), "gpr_b_data_mdid = %d\n",
+		 item->gpr_b_data_mdid);
+	dev_info(ice_hw_to_dev(hw), "gpr_b_data_start = %d\n",
+		 item->gpr_b_data_start);
+	dev_info(ice_hw_to_dev(hw), "gpr_b_data_len = %d\n",
+		 item->gpr_b_data_len);
+	dev_info(ice_hw_to_dev(hw), "gpr_b_id = %d\n", item->gpr_b_id);
+	dev_info(ice_hw_to_dev(hw), "gpr_c_ctrl = %d\n", item->gpr_c_ctrl);
+	dev_info(ice_hw_to_dev(hw), "gpr_c_data_mdid = %d\n",
+		 item->gpr_c_data_mdid);
+	dev_info(ice_hw_to_dev(hw), "gpr_c_data_start = %d\n",
+		 item->gpr_c_data_start);
+	dev_info(ice_hw_to_dev(hw), "gpr_c_data_len = %d\n",
+		 item->gpr_c_data_len);
+	dev_info(ice_hw_to_dev(hw), "gpr_c_id = %d\n", item->gpr_c_id);
+	dev_info(ice_hw_to_dev(hw), "gpr_d_ctrl = %d\n", item->gpr_d_ctrl);
+	dev_info(ice_hw_to_dev(hw), "gpr_d_data_mdid = %d\n",
+		 item->gpr_d_data_mdid);
+	dev_info(ice_hw_to_dev(hw), "gpr_d_data_start = %d\n",
+		 item->gpr_d_data_start);
+	dev_info(ice_hw_to_dev(hw), "gpr_d_data_len = %d\n",
+		 item->gpr_d_data_len);
+	dev_info(ice_hw_to_dev(hw), "gpr_d_id = %d\n", item->gpr_d_id);
+	dev_info(ice_hw_to_dev(hw), "flags = 0x%llx\n",
+		 (unsigned long long)(item->flags));
+}
+
+/** The function parses a 192 bits Metadata Init entry with below format:
+ *  BIT 0-7:	TCAM Search Key Register (mi->tsr)
+ *  BIT 8-16:	Header Offset (mi->ho)
+ *  BIT 17-24:	Program Counter (mi->pc)
+ *  BIT 25-35:	Parse Graph Root Node (mi->pg_rn)
+ *  BIT 36-38:	Control Domain (mi->cd)
+ *  BIT 39:	GPR_A Data Control (mi->gpr_a_ctrl)
+ *  BIT 40-44:	GPR_A MDID.ID (mi->gpr_a_data_mdid)
+ *  BIT 45-48:	GPR_A MDID.START (mi->gpr_a_data_start)
+ *  BIT 49-53:	GPR_A MDID.LEN (mi->gpr_a_data_len)
+ *  BIT 54-55:	reserved
+ *  BIT 56-59:	GPR_A ID (mi->gpr_a_id)
+ *  BIT 60:	GPR_B Data Control (mi->gpr_b_ctrl)
+ *  BIT 61-65:	GPR_B MDID.ID (mi->gpr_b_data_mdid)
+ *  BIT 66-69:	GPR_B MDID.START (mi->gpr_b_data_start)
+ *  BIT 70-74:	GPR_B MDID.LEN (mi->gpr_b_data_len)
+ *  BIT 75-76:	reserved
+ *  BIT 77-80:	GPR_B ID (mi->gpr_a_id)
+ *  BIT 81:	GPR_C Data Control (mi->gpr_c_ctrl)
+ *  BIT 82-86:	GPR_C MDID.ID (mi->gpr_c_data_mdid)
+ *  BIT 87-90:	GPR_C MDID.START (mi->gpr_c_data_start)
+ *  BIT 91-95:	GPR_C MDID.LEN (mi->gpr_c_data_len)
+ *  BIT 96-97:	reserved
+ *  BIT 98-101:	GPR_C ID (mi->gpr_c_id)
+ *  BIT 102:	GPR_D Data Control (mi->gpr_d_ctrl)
+ *  BIT 103-107:GPR_D MDID.ID (mi->gpr_d_data_mdid)
+ *  BIT 108-111:GPR_D MDID.START (mi->gpr_d_data_start)
+ *  BIT 112-116:GPR_D MDID.LEN (mi->gpr_d_data_len)
+ *  BIT 117-118:reserved
+ *  BIT 119-122:GPR_D ID (mi->gpr_d_id)
+ *  BIT 123-186:Flags (mi->flags)
+ *  BIT 187-191:rserved
+ */
+static void _metainit_parse_item(struct ice_hw *hw, u16 idx, void *item,
+				 void *data, int size)
+{
+	struct ice_metainit_item *mi = item;
+	u8 *buf = data;
+	u64 d64;
+
+	mi->idx = idx;
+	d64 = *(u64 *)buf;
+
+	mi->tsr = (u8)(d64 & 0xff);
+	mi->ho = (u16)((d64 >> 8) & 0x1ff);
+	mi->pc = (u16)((d64 >> 17) & 0xff);
+	mi->pg_rn = (u16)((d64 >> 25) & 0x3ff);
+	mi->cd = (u16)((d64 >> 36) & 0x7);
+	mi->gpr_a_ctrl = ((d64 >> 39) & 0x1) != 0;
+	mi->gpr_a_data_mdid = (u8)((d64 >> 40) & 0x1f);
+	mi->gpr_a_data_start = (u8)((d64 >> 45) & 0xf);
+	mi->gpr_a_data_len = (u8)((d64 >> 49) & 0x1f);
+	mi->gpr_a_id = (u8)((d64 >> 56) & 0xf);
+
+	d64 = *(u64 *)&buf[7] >> 4;
+	mi->gpr_b_ctrl = (d64 & 0x1) != 0;
+	mi->gpr_b_data_mdid = (u8)((d64 >> 1) & 0x1f);
+	mi->gpr_b_data_start = (u8)((d64 >> 6) & 0xf);
+	mi->gpr_b_data_len = (u8)((d64 >> 10) & 0x1f);
+	mi->gpr_b_id = (u8)((d64 >> 17) & 0xf);
+
+	mi->gpr_c_ctrl = ((d64 >> 21) & 0x1) != 0;
+	mi->gpr_c_data_mdid = (u8)((d64 >> 22) & 0x1f);
+	mi->gpr_c_data_start = (u8)((d64 >> 27) & 0xf);
+	mi->gpr_c_data_len = (u8)((d64 >> 31) & 0x1f);
+	mi->gpr_c_id = (u8)((d64 >> 38) & 0xf);
+
+	mi->gpr_d_ctrl = ((d64 >> 42) & 0x1) != 0;
+	mi->gpr_d_data_mdid = (u8)((d64 >> 43) & 0x1f);
+	mi->gpr_d_data_start = (u8)((d64 >> 48) & 0xf);
+	mi->gpr_d_data_len = (u8)((d64 >> 52) & 0x1f);
+
+	d64 = *(u64 *)&buf[14] >> 7;
+	mi->gpr_d_id = (u8)(d64 & 0xf);
+
+	d64 = *(u64 *)&buf[15] >> 3;
+	mi->flags = d64;
+
+	d64 = ((*(u64 *)&buf[16] >> 56) & 0x7);
+	mi->flags |= (d64 << 61);
+
+	if (hw->debug_mask & ICE_DBG_PARSER)
+		ice_metainit_dump(hw, mi);
+}
+
+/**
+ * ice_metainit_table_get - create a metainit table
+ * @hw: pointer to the hardware structure
+ */
+struct ice_metainit_item *ice_metainit_table_get(struct ice_hw *hw)
+{
+	return (struct ice_metainit_item *)
+		ice_parser_create_table(hw, ICE_SID_RXPARSER_METADATA_INIT,
+					sizeof(struct ice_metainit_item),
+					ICE_METAINIT_TABLE_SIZE,
+					ice_parser_sect_item_get,
+					_metainit_parse_item);
+}
drivers/net/ethernet/intel/ice/ice_metainit.h new file +45 -0

45 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_parser.c +11 -0
index a35f45964c9e..a1f28395c1a9 100644
@@ -6,6 +6,7 @@
 
 #define ICE_SEC_DATA_OFFSET				4
 #define ICE_SID_RXPARSER_IMEM_ENTRY_SIZE		48
+#define ICE_SID_RXPARSER_METADATA_INIT_ENTRY_SIZE	24
 
 /**
  * ice_parser_sect_item_get - parse a item from a section
@@ -28,6 +29,9 @@ void *ice_parser_sect_item_get(u32 sect_type, void *section,
 	case ICE_SID_RXPARSER_IMEM:
 		size = ICE_SID_RXPARSER_IMEM_ENTRY_SIZE;
 		break;
+	case ICE_SID_RXPARSER_METADATA_INIT:
+		size = ICE_SID_RXPARSER_METADATA_INIT_ENTRY_SIZE;
+		break;
 	default:
 		return NULL;
 	}
@@ -117,6 +121,12 @@ int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr)
 		goto err;
 	}
 
+	p->mi_table = ice_metainit_table_get(hw);
+	if (!p->mi_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
 	*psr = p;
 	return 0;
 err:
@@ -131,6 +141,7 @@ int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr)
 void ice_parser_destroy(struct ice_parser *psr)
 {
 	devm_kfree(ice_hw_to_dev(psr->hw), psr->imem_table);
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->mi_table);
 
 	devm_kfree(ice_hw_to_dev(psr->hw), psr);
 }
drivers/net/ethernet/intel/ice/ice_parser.h +2 -0
index b5a3c473666a..8fcc10479260 100644
@@ -9,6 +9,8 @@ struct ice_parser {
 
 	/* load data from section ICE_SID_RX_PARSER_IMEM */
 	struct ice_imem_item *imem_table;
+	/* load data from section ICE_SID_RXPARSER_METADATA_INIT */
+	struct ice_metainit_item *mi_table;
 };
 
 int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
drivers/net/ethernet/intel/ice/ice_parser_util.h +1 -0
index 6259d3d97b23..59c67f1a1951 100644
@@ -5,6 +5,7 @@
 #define _ICE_PARSER_UTIL_H_
 
 #include "ice_imem.h"
+#include "ice_metainit.h"
 
 struct ice_pkg_sect_hdr {
 	__le16 count;
Signature · 6 lines
2.25.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
#8 lore raw

Re: [Intel-wired-lan] [PATCH iwl-next v2 03/15] ice: init metainit table for parser

See inline comments...

Quoted 151 lines · Junfeng Guo

Parse DDP section ICE_SID_RXPARSER_METADATA_INIT into an array of struct ice_metainit_item.

---
  drivers/net/ethernet/intel/ice/ice_metainit.c | 155 ++++++++++++++++++
  drivers/net/ethernet/intel/ice/ice_metainit.h |  45 +++++
  drivers/net/ethernet/intel/ice/ice_parser.c   |  11 ++
  drivers/net/ethernet/intel/ice/ice_parser.h   |   2 +
  .../net/ethernet/intel/ice/ice_parser_util.h  |   1 +
  5 files changed, 214 insertions(+)

create mode 100644 drivers/net/ethernet/intel/ice/ice_metainit.c create mode 100644 drivers/net/ethernet/intel/ice/ice_metainit.h

drivers/net/ethernet/intel/ice/ice_metainit.c new file +131 -0
new file mode 100644
index 000000000000..911099a38087
@@ -0,0 +1,155 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#include "ice_common.h"
+#include "ice_parser_util.h"
+
+#define ICE_METAINIT_TABLE_SIZE 16
+
+/**
+ * ice_metainit_dump - dump an metainit item info
+ * @hw: pointer to the hardware structure
+ * @item: metainit item to dump
+ */
+void ice_metainit_dump(struct ice_hw *hw, struct ice_metainit_item *item)
+{
+	dev_info(ice_hw_to_dev(hw), "index = %d\n", item->idx);
+	dev_info(ice_hw_to_dev(hw), "tsr = %d\n", item->tsr);
+	dev_info(ice_hw_to_dev(hw), "ho = %d\n", item->ho);
+	dev_info(ice_hw_to_dev(hw), "pc = %d\n", item->pc);
+	dev_info(ice_hw_to_dev(hw), "pg_rn = %d\n", item->pg_rn);
+	dev_info(ice_hw_to_dev(hw), "cd = %d\n", item->cd);
+	dev_info(ice_hw_to_dev(hw), "gpr_a_ctrl = %d\n", item->gpr_a_ctrl);
+	dev_info(ice_hw_to_dev(hw), "gpr_a_data_mdid = %d\n",
+		 item->gpr_a_data_mdid);
+	dev_info(ice_hw_to_dev(hw), "gpr_a_data_start = %d\n",
+		 item->gpr_a_data_start);
+	dev_info(ice_hw_to_dev(hw), "gpr_a_data_len = %d\n",
+		 item->gpr_a_data_len);
+	dev_info(ice_hw_to_dev(hw), "gpr_a_id = %d\n", item->gpr_a_id);
+	dev_info(ice_hw_to_dev(hw), "gpr_b_ctrl = %d\n", item->gpr_b_ctrl);
+	dev_info(ice_hw_to_dev(hw), "gpr_b_data_mdid = %d\n",
+		 item->gpr_b_data_mdid);
+	dev_info(ice_hw_to_dev(hw), "gpr_b_data_start = %d\n",
+		 item->gpr_b_data_start);
+	dev_info(ice_hw_to_dev(hw), "gpr_b_data_len = %d\n",
+		 item->gpr_b_data_len);
+	dev_info(ice_hw_to_dev(hw), "gpr_b_id = %d\n", item->gpr_b_id);
+	dev_info(ice_hw_to_dev(hw), "gpr_c_ctrl = %d\n", item->gpr_c_ctrl);
+	dev_info(ice_hw_to_dev(hw), "gpr_c_data_mdid = %d\n",
+		 item->gpr_c_data_mdid);
+	dev_info(ice_hw_to_dev(hw), "gpr_c_data_start = %d\n",
+		 item->gpr_c_data_start);
+	dev_info(ice_hw_to_dev(hw), "gpr_c_data_len = %d\n",
+		 item->gpr_c_data_len);
+	dev_info(ice_hw_to_dev(hw), "gpr_c_id = %d\n", item->gpr_c_id);
+	dev_info(ice_hw_to_dev(hw), "gpr_d_ctrl = %d\n", item->gpr_d_ctrl);
+	dev_info(ice_hw_to_dev(hw), "gpr_d_data_mdid = %d\n",
+		 item->gpr_d_data_mdid);
+	dev_info(ice_hw_to_dev(hw), "gpr_d_data_start = %d\n",
+		 item->gpr_d_data_start);
+	dev_info(ice_hw_to_dev(hw), "gpr_d_data_len = %d\n",
+		 item->gpr_d_data_len);
+	dev_info(ice_hw_to_dev(hw), "gpr_d_id = %d\n", item->gpr_d_id);
+	dev_info(ice_hw_to_dev(hw), "flags = 0x%llx\n",
+		 (unsigned long long)(item->flags));
+}
+
+/** The function parses a 192 bits Metadata Init entry with below format:
+ *  BIT 0-7:	TCAM Search Key Register (mi->tsr)
+ *  BIT 8-16:	Header Offset (mi->ho)
+ *  BIT 17-24:	Program Counter (mi->pc)
+ *  BIT 25-35:	Parse Graph Root Node (mi->pg_rn)
+ *  BIT 36-38:	Control Domain (mi->cd)
+ *  BIT 39:	GPR_A Data Control (mi->gpr_a_ctrl)
+ *  BIT 40-44:	GPR_A MDID.ID (mi->gpr_a_data_mdid)
+ *  BIT 45-48:	GPR_A MDID.START (mi->gpr_a_data_start)
+ *  BIT 49-53:	GPR_A MDID.LEN (mi->gpr_a_data_len)
+ *  BIT 54-55:	reserved
+ *  BIT 56-59:	GPR_A ID (mi->gpr_a_id)
+ *  BIT 60:	GPR_B Data Control (mi->gpr_b_ctrl)
+ *  BIT 61-65:	GPR_B MDID.ID (mi->gpr_b_data_mdid)
+ *  BIT 66-69:	GPR_B MDID.START (mi->gpr_b_data_start)
+ *  BIT 70-74:	GPR_B MDID.LEN (mi->gpr_b_data_len)
+ *  BIT 75-76:	reserved
+ *  BIT 77-80:	GPR_B ID (mi->gpr_a_id)
+ *  BIT 81:	GPR_C Data Control (mi->gpr_c_ctrl)
+ *  BIT 82-86:	GPR_C MDID.ID (mi->gpr_c_data_mdid)
+ *  BIT 87-90:	GPR_C MDID.START (mi->gpr_c_data_start)
+ *  BIT 91-95:	GPR_C MDID.LEN (mi->gpr_c_data_len)
+ *  BIT 96-97:	reserved
+ *  BIT 98-101:	GPR_C ID (mi->gpr_c_id)
+ *  BIT 102:	GPR_D Data Control (mi->gpr_d_ctrl)
+ *  BIT 103-107:GPR_D MDID.ID (mi->gpr_d_data_mdid)
+ *  BIT 108-111:GPR_D MDID.START (mi->gpr_d_data_start)
+ *  BIT 112-116:GPR_D MDID.LEN (mi->gpr_d_data_len)
+ *  BIT 117-118:reserved
+ *  BIT 119-122:GPR_D ID (mi->gpr_d_id)
+ *  BIT 123-186:Flags (mi->flags)
+ *  BIT 187-191:rserved
+ */
+static void _metainit_parse_item(struct ice_hw *hw, u16 idx, void *item,
+				 void *data, int size)
+{
+	struct ice_metainit_item *mi = item;
+	u8 *buf = data;
+	u64 d64;
+
+	mi->idx = idx;
+	d64 = *(u64 *)buf;
+
+	mi->tsr = (u8)(d64 & 0xff);
+	mi->ho = (u16)((d64 >> 8) & 0x1ff);
+	mi->pc = (u16)((d64 >> 17) & 0xff);
+	mi->pg_rn = (u16)((d64 >> 25) & 0x3ff);
+	mi->cd = (u16)((d64 >> 36) & 0x7);
+	mi->gpr_a_ctrl = ((d64 >> 39) & 0x1) != 0;
+	mi->gpr_a_data_mdid = (u8)((d64 >> 40) & 0x1f);
+	mi->gpr_a_data_start = (u8)((d64 >> 45) & 0xf);
+	mi->gpr_a_data_len = (u8)((d64 >> 49) & 0x1f);
+	mi->gpr_a_id = (u8)((d64 >> 56) & 0xf);
+
+	d64 = *(u64 *)&buf[7] >> 4;
+	mi->gpr_b_ctrl = (d64 & 0x1) != 0;
+	mi->gpr_b_data_mdid = (u8)((d64 >> 1) & 0x1f);
+	mi->gpr_b_data_start = (u8)((d64 >> 6) & 0xf);
+	mi->gpr_b_data_len = (u8)((d64 >> 10) & 0x1f);
+	mi->gpr_b_id = (u8)((d64 >> 17) & 0xf);
+
+	mi->gpr_c_ctrl = ((d64 >> 21) & 0x1) != 0;
+	mi->gpr_c_data_mdid = (u8)((d64 >> 22) & 0x1f);
+	mi->gpr_c_data_start = (u8)((d64 >> 27) & 0xf);
+	mi->gpr_c_data_len = (u8)((d64 >> 31) & 0x1f);
+	mi->gpr_c_id = (u8)((d64 >> 38) & 0xf);
+
+	mi->gpr_d_ctrl = ((d64 >> 42) & 0x1) != 0;
+	mi->gpr_d_data_mdid = (u8)((d64 >> 43) & 0x1f);
+	mi->gpr_d_data_start = (u8)((d64 >> 48) & 0xf);
+	mi->gpr_d_data_len = (u8)((d64 >> 52) & 0x1f);
+
+	d64 = *(u64 *)&buf[14] >> 7;
+	mi->gpr_d_id = (u8)(d64 & 0xf);

drivers/net/ethernet/intel/ice/ice_metainit.c line 141

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_metainit.c new file +10 -0
+
+	d64 = *(u64 *)&buf[15] >> 3;
+	mi->flags = d64;
+
+	d64 = ((*(u64 *)&buf[16] >> 56) & 0x7);
+	mi->flags |= (d64 << 61);
+
+	if (hw->debug_mask & ICE_DBG_PARSER)
+		ice_metainit_dump(hw, mi);
+}

Do not use hardcoded values for indices, masks and shifts and use macros or enums with symbolic names instead.

Quoted 51 lines
drivers/net/ethernet/intel/ice/ice_metainit.c new file +14 -0
+
+/**
+ * ice_metainit_table_get - create a metainit table
+ * @hw: pointer to the hardware structure
+ */
+struct ice_metainit_item *ice_metainit_table_get(struct ice_hw *hw)
+{
+	return (struct ice_metainit_item *)
+		ice_parser_create_table(hw, ICE_SID_RXPARSER_METADATA_INIT,
+					sizeof(struct ice_metainit_item),
+					ICE_METAINIT_TABLE_SIZE,
+					ice_parser_sect_item_get,
+					_metainit_parse_item);
+}
drivers/net/ethernet/intel/ice/ice_metainit.h new file +31 -0
new file mode 100644
index 000000000000..aa7a9e178820
@@ -0,0 +1,45 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#ifndef _ICE_METAINIT_H_
+#define _ICE_METAINIT_H_
+
+struct ice_metainit_item {
+	u16 idx;
+
+	u8 tsr;
+	u16 ho;
+	u16 pc;
+	u16 pg_rn;
+	u8 cd;
+
+	bool gpr_a_ctrl;
+	u8 gpr_a_data_mdid;
+	u8 gpr_a_data_start;
+	u8 gpr_a_data_len;
+	u8 gpr_a_id;
+
+	bool gpr_b_ctrl;
+	u8 gpr_b_data_mdid;
+	u8 gpr_b_data_start;
+	u8 gpr_b_data_len;
+	u8 gpr_b_id;
+
+	bool gpr_c_ctrl;
+	u8 gpr_c_data_mdid;
+	u8 gpr_c_data_start;
+	u8 gpr_c_data_len;

drivers/net/ethernet/intel/ice/ice_metainit.h line 41

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_metainit.h new file +10 -0
+	u8 gpr_c_id;
+
+	bool gpr_d_ctrl;
+	u8 gpr_d_data_mdid;
+	u8 gpr_d_data_start;
+	u8 gpr_d_data_len;
+	u8 gpr_d_id;
+
+	u64 flags;
+};

The field names are not very descriptive except idx and flags. Any documentation in comment would be helpful.

Quoted 65 lines
drivers/net/ethernet/intel/ice/ice_metainit.h new file +4 -0
+
+void ice_metainit_dump(struct ice_hw *hw, struct ice_metainit_item *item);
+struct ice_metainit_item *ice_metainit_table_get(struct ice_hw *hw);
+#endif /*_ICE_METAINIT_H_ */
drivers/net/ethernet/intel/ice/ice_parser.c +11 -0
index a35f45964c9e..a1f28395c1a9 100644
@@ -6,6 +6,7 @@
 
  #define ICE_SEC_DATA_OFFSET				4
  #define ICE_SID_RXPARSER_IMEM_ENTRY_SIZE		48
+#define ICE_SID_RXPARSER_METADATA_INIT_ENTRY_SIZE	24
 
  /**
   * ice_parser_sect_item_get - parse a item from a section
@@ -28,6 +29,9 @@ void *ice_parser_sect_item_get(u32 sect_type, void *section,
  	case ICE_SID_RXPARSER_IMEM:
  		size = ICE_SID_RXPARSER_IMEM_ENTRY_SIZE;
  		break;
+	case ICE_SID_RXPARSER_METADATA_INIT:
+		size = ICE_SID_RXPARSER_METADATA_INIT_ENTRY_SIZE;
+		break;
  	default:
  		return NULL;
  	}
@@ -117,6 +121,12 @@ int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr)
  		goto err;
  	}
 
+	p->mi_table = ice_metainit_table_get(hw);
+	if (!p->mi_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
  	*psr = p;
  	return 0;
  err:
@@ -131,6 +141,7 @@ int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr)
  void ice_parser_destroy(struct ice_parser *psr)
  {
  	devm_kfree(ice_hw_to_dev(psr->hw), psr->imem_table);
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->mi_table);
 
  	devm_kfree(ice_hw_to_dev(psr->hw), psr);
  }
drivers/net/ethernet/intel/ice/ice_parser.h +2 -0
index b5a3c473666a..8fcc10479260 100644
@@ -9,6 +9,8 @@ struct ice_parser {
 
  	/* load data from section ICE_SID_RX_PARSER_IMEM */
  	struct ice_imem_item *imem_table;
+	/* load data from section ICE_SID_RXPARSER_METADATA_INIT */
+	struct ice_metainit_item *mi_table;
  };
 
  int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
drivers/net/ethernet/intel/ice/ice_parser_util.h +0 -0
index 6259d3d97b23..59c67f1a1951 100644

drivers/net/ethernet/intel/ice/ice_parser_util.h line 11

Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_parser_util.h +1 -0
@@ -5,6 +5,7 @@
  #define _ICE_PARSER_UTIL_H_
 
  #include "ice_imem.h"
+#include "ice_metainit.h"
 
  struct ice_pkg_sect_hdr {
  	__le16 count;

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#9 lore raw

Re: [Intel-wired-lan] [PATCH iwl-next v2 03/15] ice: init metainit table for parser

Quoted 183 lines

-----Original Message-----
From: Ivan Vecera <[email protected]>
Sent: Monday, July 24, 2023 18:32
To: Guo, Junfeng <[email protected]>; intel-wired- [email protected]
Cc: Zhang, Qi Z <[email protected]>; mschmidt <[email protected]>; poros <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH iwl-next v2 03/15] ice: init metainit table for parser

See inline comments...

Quoted 6 lines · Junfeng Guo

Parse DDP section ICE_SID_RXPARSER_METADATA_INIT into an array of struct ice_metainit_item.

---
  drivers/net/ethernet/intel/ice/ice_metainit.c | 155

++++++++++++++++++

Review

Quoted 9 lines
  drivers/net/ethernet/intel/ice/ice_metainit.h |  45 +++++
  drivers/net/ethernet/intel/ice/ice_parser.c   |  11 ++
  drivers/net/ethernet/intel/ice/ice_parser.h   |   2 +
  .../net/ethernet/intel/ice/ice_parser_util.h  |   1 +
  5 files changed, 214 insertions(+)

create mode 100644 drivers/net/ethernet/intel/ice/ice_metainit.c create mode 100644 drivers/net/ethernet/intel/ice/ice_metainit.h

(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_metainit.c

Quoted 9 lines

new file mode 100644
index 000000000000..911099a38087

drivers/net/ethernet/intel/ice/ice_metainit.c new file +4 -0
@@ -0,0 +1,155 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#include "ice_common.h"

drivers/net/ethernet/intel/ice/ice_metainit.c line 14

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_metainit.c new file +10 -0
+#include "ice_parser_util.h"
+
+#define ICE_METAINIT_TABLE_SIZE 16
+
+/**
+ * ice_metainit_dump - dump an metainit item info
+ * @hw: pointer to the hardware structure
+ * @item: metainit item to dump
+ */
+void ice_metainit_dump(struct ice_hw *hw, struct ice_metainit_item

*item)

Quoted 46 lines
drivers/net/ethernet/intel/ice/ice_metainit.c new file +8 -0
+{
+	dev_info(ice_hw_to_dev(hw), "index = %d\n", item->idx);
+	dev_info(ice_hw_to_dev(hw), "tsr = %d\n", item->tsr);
+	dev_info(ice_hw_to_dev(hw), "ho = %d\n", item->ho);
+	dev_info(ice_hw_to_dev(hw), "pc = %d\n", item->pc);
+	dev_info(ice_hw_to_dev(hw), "pg_rn = %d\n", item->pg_rn);
+	dev_info(ice_hw_to_dev(hw), "cd = %d\n", item->cd);
+	dev_info(ice_hw_to_dev(hw), "gpr_a_ctrl = %d\n", item-

gpr_a_ctrl);

drivers/net/ethernet/intel/ice/ice_metainit.c new file +7 -0
+	dev_info(ice_hw_to_dev(hw), "gpr_a_data_mdid = %d\n",
+		 item->gpr_a_data_mdid);
+	dev_info(ice_hw_to_dev(hw), "gpr_a_data_start = %d\n",
+		 item->gpr_a_data_start);
+	dev_info(ice_hw_to_dev(hw), "gpr_a_data_len = %d\n",
+		 item->gpr_a_data_len);
+	dev_info(ice_hw_to_dev(hw), "gpr_a_id = %d\n", item-

gpr_a_id);

drivers/net/ethernet/intel/ice/ice_metainit.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "gpr_b_ctrl = %d\n", item-

gpr_b_ctrl);

drivers/net/ethernet/intel/ice/ice_metainit.c new file +7 -0
+	dev_info(ice_hw_to_dev(hw), "gpr_b_data_mdid = %d\n",
+		 item->gpr_b_data_mdid);
+	dev_info(ice_hw_to_dev(hw), "gpr_b_data_start = %d\n",
+		 item->gpr_b_data_start);
+	dev_info(ice_hw_to_dev(hw), "gpr_b_data_len = %d\n",
+		 item->gpr_b_data_len);
+	dev_info(ice_hw_to_dev(hw), "gpr_b_id = %d\n", item-

gpr_b_id);

drivers/net/ethernet/intel/ice/ice_metainit.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "gpr_c_ctrl = %d\n", item-

gpr_c_ctrl);

drivers/net/ethernet/intel/ice/ice_metainit.c new file +8 -0
+	dev_info(ice_hw_to_dev(hw), "gpr_c_data_mdid = %d\n",
+		 item->gpr_c_data_mdid);
+	dev_info(ice_hw_to_dev(hw), "gpr_c_data_start = %d\n",
+		 item->gpr_c_data_start);
+	dev_info(ice_hw_to_dev(hw), "gpr_c_data_len = %d\n",
+		 item->gpr_c_data_len);
+	dev_info(ice_hw_to_dev(hw), "gpr_c_id = %d\n", item->gpr_c_id);
+	dev_info(ice_hw_to_dev(hw), "gpr_d_ctrl = %d\n", item-

gpr_d_ctrl);

drivers/net/ethernet/intel/ice/ice_metainit.c new file +7 -0
+	dev_info(ice_hw_to_dev(hw), "gpr_d_data_mdid = %d\n",
+		 item->gpr_d_data_mdid);
+	dev_info(ice_hw_to_dev(hw), "gpr_d_data_start = %d\n",
+		 item->gpr_d_data_start);
+	dev_info(ice_hw_to_dev(hw), "gpr_d_data_len = %d\n",
+		 item->gpr_d_data_len);
+	dev_info(ice_hw_to_dev(hw), "gpr_d_id = %d\n", item-

gpr_d_id);

drivers/net/ethernet/intel/ice/ice_metainit.c

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_metainit.c new file +5 -0
+	dev_info(ice_hw_to_dev(hw), "flags = 0x%llx\n",
+		 (unsigned long long)(item->flags));
+}
+
+/** The function parses a 192 bits Metadata Init entry with below

format:

Quoted 31 lines
+ *  BIT 0-7:	TCAM Search Key Register (mi->tsr)
+ *  BIT 8-16:	Header Offset (mi->ho)
+ *  BIT 17-24:	Program Counter (mi->pc)
+ *  BIT 25-35:	Parse Graph Root Node (mi->pg_rn)
+ *  BIT 36-38:	Control Domain (mi->cd)
+ *  BIT 39:	GPR_A Data Control (mi->gpr_a_ctrl)
+ *  BIT 40-44:	GPR_A MDID.ID (mi->gpr_a_data_mdid)
+ *  BIT 45-48:	GPR_A MDID.START (mi->gpr_a_data_start)
+ *  BIT 49-53:	GPR_A MDID.LEN (mi->gpr_a_data_len)
+ *  BIT 54-55:	reserved
+ *  BIT 56-59:	GPR_A ID (mi->gpr_a_id)
+ *  BIT 60:	GPR_B Data Control (mi->gpr_b_ctrl)
+ *  BIT 61-65:	GPR_B MDID.ID (mi->gpr_b_data_mdid)
+ *  BIT 66-69:	GPR_B MDID.START (mi->gpr_b_data_start)
+ *  BIT 70-74:	GPR_B MDID.LEN (mi->gpr_b_data_len)
+ *  BIT 75-76:	reserved
+ *  BIT 77-80:	GPR_B ID (mi->gpr_a_id)
+ *  BIT 81:	GPR_C Data Control (mi->gpr_c_ctrl)
+ *  BIT 82-86:	GPR_C MDID.ID (mi->gpr_c_data_mdid)
+ *  BIT 87-90:	GPR_C MDID.START (mi->gpr_c_data_start)
+ *  BIT 91-95:	GPR_C MDID.LEN (mi->gpr_c_data_len)
+ *  BIT 96-97:	reserved
+ *  BIT 98-101:	GPR_C ID (mi->gpr_c_id)
+ *  BIT 102:	GPR_D Data Control (mi->gpr_d_ctrl)
+ *  BIT 103-107:GPR_D MDID.ID (mi->gpr_d_data_mdid)
+ *  BIT 108-111:GPR_D MDID.START (mi->gpr_d_data_start)
+ *  BIT 112-116:GPR_D MDID.LEN (mi->gpr_d_data_len)
+ *  BIT 117-118:reserved
+ *  BIT 119-122:GPR_D ID (mi->gpr_d_id)
+ *  BIT 123-186:Flags (mi->flags)
+ *  BIT 187-191:rserved
Quoted 2 lines

+ */
+static void _metainit_parse_item(struct ice_hw *hw, u16 idx, void

*item,

Quoted 45 lines
drivers/net/ethernet/intel/ice/ice_metainit.c new file +45 -0
+				 void *data, int size)
+{
+	struct ice_metainit_item *mi = item;
+	u8 *buf = data;
+	u64 d64;
+
+	mi->idx = idx;
+	d64 = *(u64 *)buf;
+
+	mi->tsr = (u8)(d64 & 0xff);
+	mi->ho = (u16)((d64 >> 8) & 0x1ff);
+	mi->pc = (u16)((d64 >> 17) & 0xff);
+	mi->pg_rn = (u16)((d64 >> 25) & 0x3ff);
+	mi->cd = (u16)((d64 >> 36) & 0x7);
+	mi->gpr_a_ctrl = ((d64 >> 39) & 0x1) != 0;
+	mi->gpr_a_data_mdid = (u8)((d64 >> 40) & 0x1f);
+	mi->gpr_a_data_start = (u8)((d64 >> 45) & 0xf);
+	mi->gpr_a_data_len = (u8)((d64 >> 49) & 0x1f);
+	mi->gpr_a_id = (u8)((d64 >> 56) & 0xf);
+
+	d64 = *(u64 *)&buf[7] >> 4;
+	mi->gpr_b_ctrl = (d64 & 0x1) != 0;
+	mi->gpr_b_data_mdid = (u8)((d64 >> 1) & 0x1f);
+	mi->gpr_b_data_start = (u8)((d64 >> 6) & 0xf);
+	mi->gpr_b_data_len = (u8)((d64 >> 10) & 0x1f);
+	mi->gpr_b_id = (u8)((d64 >> 17) & 0xf);
+
+	mi->gpr_c_ctrl = ((d64 >> 21) & 0x1) != 0;
+	mi->gpr_c_data_mdid = (u8)((d64 >> 22) & 0x1f);
+	mi->gpr_c_data_start = (u8)((d64 >> 27) & 0xf);
+	mi->gpr_c_data_len = (u8)((d64 >> 31) & 0x1f);
+	mi->gpr_c_id = (u8)((d64 >> 38) & 0xf);
+
+	mi->gpr_d_ctrl = ((d64 >> 42) & 0x1) != 0;
+	mi->gpr_d_data_mdid = (u8)((d64 >> 43) & 0x1f);
+	mi->gpr_d_data_start = (u8)((d64 >> 48) & 0xf);
+	mi->gpr_d_data_len = (u8)((d64 >> 52) & 0x1f);
+
+	d64 = *(u64 *)&buf[14] >> 7;
+	mi->gpr_d_id = (u8)(d64 & 0xf);
+
+	d64 = *(u64 *)&buf[15] >> 3;
+	mi->flags = d64;
+
+	d64 = ((*(u64 *)&buf[16] >> 56) & 0x7);
Quoted 8 lines

drivers/net/ethernet/intel/ice/ice_metainit.c line 141

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_metainit.c new file +5 -0
+	mi->flags |= (d64 << 61);
+
+	if (hw->debug_mask & ICE_DBG_PARSER)
+		ice_metainit_dump(hw, mi);
+}

Do not use hardcoded values for indices, masks and shifts and use macros or enums with symbolic names instead.

Sure, make sense! Will update in the coming version. Thanks!

Quoted 59 lines

drivers/net/ethernet/intel/ice/ice_metainit.c

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_metainit.c new file +9 -0
+
+/**
+ * ice_metainit_table_get - create a metainit table
+ * @hw: pointer to the hardware structure
+ */
+struct ice_metainit_item *ice_metainit_table_get(struct ice_hw *hw)
+{
+	return (struct ice_metainit_item *)
+		ice_parser_create_table(hw,

ICE_SID_RXPARSER_METADATA_INIT,

Review

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_metainit.c new file +5 -0
+					sizeof(struct ice_metainit_item),
+					ICE_METAINIT_TABLE_SIZE,
+					ice_parser_sect_item_get,
+					_metainit_parse_item);
+}
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_metainit.h

Quoted 41 lines

new file mode 100644
index 000000000000..aa7a9e178820

drivers/net/ethernet/intel/ice/ice_metainit.h new file +36 -0
@@ -0,0 +1,45 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#ifndef _ICE_METAINIT_H_
+#define _ICE_METAINIT_H_
+
+struct ice_metainit_item {
+	u16 idx;
+
+	u8 tsr;
+	u16 ho;
+	u16 pc;
+	u16 pg_rn;
+	u8 cd;
+
+	bool gpr_a_ctrl;
+	u8 gpr_a_data_mdid;
+	u8 gpr_a_data_start;
+	u8 gpr_a_data_len;
+	u8 gpr_a_id;
+
+	bool gpr_b_ctrl;
+	u8 gpr_b_data_mdid;
+	u8 gpr_b_data_start;
+	u8 gpr_b_data_len;
+	u8 gpr_b_id;
+
+	bool gpr_c_ctrl;
+	u8 gpr_c_data_mdid;
+	u8 gpr_c_data_start;
+	u8 gpr_c_data_len;
+	u8 gpr_c_id;
+
+	bool gpr_d_ctrl;
+	u8 gpr_d_data_mdid;
+	u8 gpr_d_data_start;
Quoted 8 lines

drivers/net/ethernet/intel/ice/ice_metainit.h line 41

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_metainit.h new file +5 -0
+	u8 gpr_d_data_len;
+	u8 gpr_d_id;
+
+	u64 flags;
+};

The field names are not very descriptive except idx and flags. Any documentation in comment would be helpful.

Same here, there is no more meaningful description in the spec. But we will try if we can add some doc here. Thanks!

Quoted 76 lines

drivers/net/ethernet/intel/ice/ice_metainit.h line 43

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_metainit.h new file +2 -0
+
+void ice_metainit_dump(struct ice_hw *hw, struct ice_metainit_item

*item);

Review

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_metainit.h new file +2 -0
+struct ice_metainit_item *ice_metainit_table_get(struct ice_hw *hw);
+#endif /*_ICE_METAINIT_H_ */
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_parser.c

drivers/net/ethernet/intel/ice/ice_parser.c void *ice_parser_sect_item_get(u32 sect_type,

Quoted 12 lines

index a35f45964c9e..a1f28395c1a9 100644

drivers/net/ethernet/intel/ice/ice_parser.c +1 -0
@@ -6,6 +6,7 @@
 
  #define ICE_SEC_DATA_OFFSET				4
  #define ICE_SID_RXPARSER_IMEM_ENTRY_SIZE		48
+#define ICE_SID_RXPARSER_METADATA_INIT_ENTRY_SIZE	24
 
  /**
   * ice_parser_sect_item_get - parse a item from a section
@@ -28,6 +29,9 @@ void *ice_parser_sect_item_get(u32 sect_type,

void *section,

drivers/net/ethernet/intel/ice/ice_parser.c int ice_parser_create(struct ice_hw *hw,

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_parser.c +3 -0
  	case ICE_SID_RXPARSER_IMEM:
  		size = ICE_SID_RXPARSER_IMEM_ENTRY_SIZE;
  		break;
+	case ICE_SID_RXPARSER_METADATA_INIT:
+		size = ICE_SID_RXPARSER_METADATA_INIT_ENTRY_SIZE;
+		break;
  	default:
  		return NULL;
  	}
@@ -117,6 +121,12 @@ int ice_parser_create(struct ice_hw *hw,

struct ice_parser **psr)

drivers/net/ethernet/intel/ice/ice_parser.c int ice_parser_create(struct ice_hw *hw, struct

Quoted 13 lines
drivers/net/ethernet/intel/ice/ice_parser.c +6 -0
  		goto err;
  	}
 
+	p->mi_table = ice_metainit_table_get(hw);
+	if (!p->mi_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
  	*psr = p;
  	return 0;
  err:
@@ -131,6 +141,7 @@ int ice_parser_create(struct ice_hw *hw, struct

ice_parser **psr)

Review

Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_parser.c +1 -0
  void ice_parser_destroy(struct ice_parser *psr)
  {
  	devm_kfree(ice_hw_to_dev(psr->hw), psr->imem_table);
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->mi_table);
 
  	devm_kfree(ice_hw_to_dev(psr->hw), psr);
  }
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_parser.h

drivers/net/ethernet/intel/ice/ice_parser.h struct ice_parser { · line 12

Quoted 8 lines

index b5a3c473666a..8fcc10479260 100644

drivers/net/ethernet/intel/ice/ice_parser.h +1 -0
@@ -9,6 +9,8 @@ struct ice_parser {
 
  	/* load data from section ICE_SID_RX_PARSER_IMEM */
  	struct ice_imem_item *imem_table;
+	/* load data from section ICE_SID_RXPARSER_METADATA_INIT

*/

Review

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_parser.h +1 -0
+	struct ice_metainit_item *mi_table;
  };
 
  int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_parser_util.h

Quoted 6 lines

index 6259d3d97b23..59c67f1a1951 100644

drivers/net/ethernet/intel/ice/ice_parser_util.h +0 -0
@@ -5,6 +5,7 @@
  #define _ICE_PARSER_UTIL_H_
 
Quoted 5 lines

drivers/net/ethernet/intel/ice/ice_parser_util.h line 11

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_parser_util.h +1 -0
  #include "ice_imem.h"
+#include "ice_metainit.h"
 
  struct ice_pkg_sect_hdr {
  	__le16 count;

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#10 lore raw

Re: [Intel-wired-lan] [PATCH iwl-next v2 03/15] ice: init metainit table for parser

Quoted 262 lines · Junfeng
Quoted 183 lines

-----Original Message-----
From: Ivan Vecera <[email protected]>
Sent: Monday, July 24, 2023 18:32
To: Guo, Junfeng <[email protected]>; intel-wired- [email protected]
Cc: Zhang, Qi Z <[email protected]>; mschmidt <[email protected]>; poros <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH iwl-next v2 03/15] ice: init metainit table for parser

See inline comments...

Quoted 6 lines · Junfeng Guo

Parse DDP section ICE_SID_RXPARSER_METADATA_INIT into an array of struct ice_metainit_item.

---
   drivers/net/ethernet/intel/ice/ice_metainit.c | 155

++++++++++++++++++

Review

Quoted 9 lines
   drivers/net/ethernet/intel/ice/ice_metainit.h |  45 +++++
   drivers/net/ethernet/intel/ice/ice_parser.c   |  11 ++
   drivers/net/ethernet/intel/ice/ice_parser.h   |   2 +
   .../net/ethernet/intel/ice/ice_parser_util.h  |   1 +
   5 files changed, 214 insertions(+)

create mode 100644 drivers/net/ethernet/intel/ice/ice_metainit.c create mode 100644 drivers/net/ethernet/intel/ice/ice_metainit.h

(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_metainit.c

Quoted 9 lines

new file mode 100644
index 000000000000..911099a38087

drivers/net/ethernet/intel/ice/ice_metainit.c new file +4 -0
@@ -0,0 +1,155 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#include "ice_common.h"

drivers/net/ethernet/intel/ice/ice_metainit.c line 14

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_metainit.c new file +10 -0
+#include "ice_parser_util.h"
+
+#define ICE_METAINIT_TABLE_SIZE 16
+
+/**
+ * ice_metainit_dump - dump an metainit item info
+ * @hw: pointer to the hardware structure
+ * @item: metainit item to dump
+ */
+void ice_metainit_dump(struct ice_hw *hw, struct ice_metainit_item

*item)

Quoted 46 lines
drivers/net/ethernet/intel/ice/ice_metainit.c new file +8 -0
+{
+	dev_info(ice_hw_to_dev(hw), "index = %d\n", item->idx);
+	dev_info(ice_hw_to_dev(hw), "tsr = %d\n", item->tsr);
+	dev_info(ice_hw_to_dev(hw), "ho = %d\n", item->ho);
+	dev_info(ice_hw_to_dev(hw), "pc = %d\n", item->pc);
+	dev_info(ice_hw_to_dev(hw), "pg_rn = %d\n", item->pg_rn);
+	dev_info(ice_hw_to_dev(hw), "cd = %d\n", item->cd);
+	dev_info(ice_hw_to_dev(hw), "gpr_a_ctrl = %d\n", item-

gpr_a_ctrl);

drivers/net/ethernet/intel/ice/ice_metainit.c new file +7 -0
+	dev_info(ice_hw_to_dev(hw), "gpr_a_data_mdid = %d\n",
+		 item->gpr_a_data_mdid);
+	dev_info(ice_hw_to_dev(hw), "gpr_a_data_start = %d\n",
+		 item->gpr_a_data_start);
+	dev_info(ice_hw_to_dev(hw), "gpr_a_data_len = %d\n",
+		 item->gpr_a_data_len);
+	dev_info(ice_hw_to_dev(hw), "gpr_a_id = %d\n", item-

gpr_a_id);

drivers/net/ethernet/intel/ice/ice_metainit.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "gpr_b_ctrl = %d\n", item-

gpr_b_ctrl);

drivers/net/ethernet/intel/ice/ice_metainit.c new file +7 -0
+	dev_info(ice_hw_to_dev(hw), "gpr_b_data_mdid = %d\n",
+		 item->gpr_b_data_mdid);
+	dev_info(ice_hw_to_dev(hw), "gpr_b_data_start = %d\n",
+		 item->gpr_b_data_start);
+	dev_info(ice_hw_to_dev(hw), "gpr_b_data_len = %d\n",
+		 item->gpr_b_data_len);
+	dev_info(ice_hw_to_dev(hw), "gpr_b_id = %d\n", item-

gpr_b_id);

drivers/net/ethernet/intel/ice/ice_metainit.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "gpr_c_ctrl = %d\n", item-

gpr_c_ctrl);

drivers/net/ethernet/intel/ice/ice_metainit.c new file +8 -0
+	dev_info(ice_hw_to_dev(hw), "gpr_c_data_mdid = %d\n",
+		 item->gpr_c_data_mdid);
+	dev_info(ice_hw_to_dev(hw), "gpr_c_data_start = %d\n",
+		 item->gpr_c_data_start);
+	dev_info(ice_hw_to_dev(hw), "gpr_c_data_len = %d\n",
+		 item->gpr_c_data_len);
+	dev_info(ice_hw_to_dev(hw), "gpr_c_id = %d\n", item->gpr_c_id);
+	dev_info(ice_hw_to_dev(hw), "gpr_d_ctrl = %d\n", item-

gpr_d_ctrl);

drivers/net/ethernet/intel/ice/ice_metainit.c new file +7 -0
+	dev_info(ice_hw_to_dev(hw), "gpr_d_data_mdid = %d\n",
+		 item->gpr_d_data_mdid);
+	dev_info(ice_hw_to_dev(hw), "gpr_d_data_start = %d\n",
+		 item->gpr_d_data_start);
+	dev_info(ice_hw_to_dev(hw), "gpr_d_data_len = %d\n",
+		 item->gpr_d_data_len);
+	dev_info(ice_hw_to_dev(hw), "gpr_d_id = %d\n", item-

gpr_d_id);

drivers/net/ethernet/intel/ice/ice_metainit.c

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_metainit.c new file +5 -0
+	dev_info(ice_hw_to_dev(hw), "flags = 0x%llx\n",
+		 (unsigned long long)(item->flags));
+}
+
+/** The function parses a 192 bits Metadata Init entry with below

format:

Quoted 31 lines
+ *  BIT 0-7:	TCAM Search Key Register (mi->tsr)
+ *  BIT 8-16:	Header Offset (mi->ho)
+ *  BIT 17-24:	Program Counter (mi->pc)
+ *  BIT 25-35:	Parse Graph Root Node (mi->pg_rn)
+ *  BIT 36-38:	Control Domain (mi->cd)
+ *  BIT 39:	GPR_A Data Control (mi->gpr_a_ctrl)
+ *  BIT 40-44:	GPR_A MDID.ID (mi->gpr_a_data_mdid)
+ *  BIT 45-48:	GPR_A MDID.START (mi->gpr_a_data_start)
+ *  BIT 49-53:	GPR_A MDID.LEN (mi->gpr_a_data_len)
+ *  BIT 54-55:	reserved
+ *  BIT 56-59:	GPR_A ID (mi->gpr_a_id)
+ *  BIT 60:	GPR_B Data Control (mi->gpr_b_ctrl)
+ *  BIT 61-65:	GPR_B MDID.ID (mi->gpr_b_data_mdid)
+ *  BIT 66-69:	GPR_B MDID.START (mi->gpr_b_data_start)
+ *  BIT 70-74:	GPR_B MDID.LEN (mi->gpr_b_data_len)
+ *  BIT 75-76:	reserved
+ *  BIT 77-80:	GPR_B ID (mi->gpr_a_id)
+ *  BIT 81:	GPR_C Data Control (mi->gpr_c_ctrl)
+ *  BIT 82-86:	GPR_C MDID.ID (mi->gpr_c_data_mdid)
+ *  BIT 87-90:	GPR_C MDID.START (mi->gpr_c_data_start)
+ *  BIT 91-95:	GPR_C MDID.LEN (mi->gpr_c_data_len)
+ *  BIT 96-97:	reserved
+ *  BIT 98-101:	GPR_C ID (mi->gpr_c_id)
+ *  BIT 102:	GPR_D Data Control (mi->gpr_d_ctrl)
+ *  BIT 103-107:GPR_D MDID.ID (mi->gpr_d_data_mdid)
+ *  BIT 108-111:GPR_D MDID.START (mi->gpr_d_data_start)
+ *  BIT 112-116:GPR_D MDID.LEN (mi->gpr_d_data_len)
+ *  BIT 117-118:reserved
+ *  BIT 119-122:GPR_D ID (mi->gpr_d_id)
+ *  BIT 123-186:Flags (mi->flags)
+ *  BIT 187-191:rserved
Quoted 2 lines

+ */
+static void _metainit_parse_item(struct ice_hw *hw, u16 idx, void

*item,

Quoted 45 lines
drivers/net/ethernet/intel/ice/ice_metainit.c new file +45 -0
+				 void *data, int size)
+{
+	struct ice_metainit_item *mi = item;
+	u8 *buf = data;
+	u64 d64;
+
+	mi->idx = idx;
+	d64 = *(u64 *)buf;
+
+	mi->tsr = (u8)(d64 & 0xff);
+	mi->ho = (u16)((d64 >> 8) & 0x1ff);
+	mi->pc = (u16)((d64 >> 17) & 0xff);
+	mi->pg_rn = (u16)((d64 >> 25) & 0x3ff);
+	mi->cd = (u16)((d64 >> 36) & 0x7);
+	mi->gpr_a_ctrl = ((d64 >> 39) & 0x1) != 0;
+	mi->gpr_a_data_mdid = (u8)((d64 >> 40) & 0x1f);
+	mi->gpr_a_data_start = (u8)((d64 >> 45) & 0xf);
+	mi->gpr_a_data_len = (u8)((d64 >> 49) & 0x1f);
+	mi->gpr_a_id = (u8)((d64 >> 56) & 0xf);
+
+	d64 = *(u64 *)&buf[7] >> 4;
+	mi->gpr_b_ctrl = (d64 & 0x1) != 0;
+	mi->gpr_b_data_mdid = (u8)((d64 >> 1) & 0x1f);
+	mi->gpr_b_data_start = (u8)((d64 >> 6) & 0xf);
+	mi->gpr_b_data_len = (u8)((d64 >> 10) & 0x1f);
+	mi->gpr_b_id = (u8)((d64 >> 17) & 0xf);
+
+	mi->gpr_c_ctrl = ((d64 >> 21) & 0x1) != 0;
+	mi->gpr_c_data_mdid = (u8)((d64 >> 22) & 0x1f);
+	mi->gpr_c_data_start = (u8)((d64 >> 27) & 0xf);
+	mi->gpr_c_data_len = (u8)((d64 >> 31) & 0x1f);
+	mi->gpr_c_id = (u8)((d64 >> 38) & 0xf);
+
+	mi->gpr_d_ctrl = ((d64 >> 42) & 0x1) != 0;
+	mi->gpr_d_data_mdid = (u8)((d64 >> 43) & 0x1f);
+	mi->gpr_d_data_start = (u8)((d64 >> 48) & 0xf);
+	mi->gpr_d_data_len = (u8)((d64 >> 52) & 0x1f);
+
+	d64 = *(u64 *)&buf[14] >> 7;
+	mi->gpr_d_id = (u8)(d64 & 0xf);
+
+	d64 = *(u64 *)&buf[15] >> 3;
+	mi->flags = d64;
+
+	d64 = ((*(u64 *)&buf[16] >> 56) & 0x7);
Quoted 8 lines

drivers/net/ethernet/intel/ice/ice_metainit.c line 141

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_metainit.c new file +5 -0
+	mi->flags |= (d64 << 61);
+
+	if (hw->debug_mask & ICE_DBG_PARSER)
+		ice_metainit_dump(hw, mi);
+}

Do not use hardcoded values for indices, masks and shifts and use macros or enums with symbolic names instead.

Sure, make sense! Will update in the coming version. Thanks!

Quoted 59 lines

drivers/net/ethernet/intel/ice/ice_metainit.c

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_metainit.c new file +9 -0
+
+/**
+ * ice_metainit_table_get - create a metainit table
+ * @hw: pointer to the hardware structure
+ */
+struct ice_metainit_item *ice_metainit_table_get(struct ice_hw *hw)
+{
+	return (struct ice_metainit_item *)
+		ice_parser_create_table(hw,

ICE_SID_RXPARSER_METADATA_INIT,

Review

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_metainit.c new file +5 -0
+					sizeof(struct ice_metainit_item),
+					ICE_METAINIT_TABLE_SIZE,
+					ice_parser_sect_item_get,
+					_metainit_parse_item);
+}
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_metainit.h

Quoted 41 lines

new file mode 100644
index 000000000000..aa7a9e178820

drivers/net/ethernet/intel/ice/ice_metainit.h new file +36 -0
@@ -0,0 +1,45 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#ifndef _ICE_METAINIT_H_
+#define _ICE_METAINIT_H_
+
+struct ice_metainit_item {
+	u16 idx;
+
+	u8 tsr;
+	u16 ho;
+	u16 pc;
+	u16 pg_rn;
+	u8 cd;
+
+	bool gpr_a_ctrl;
+	u8 gpr_a_data_mdid;
+	u8 gpr_a_data_start;
+	u8 gpr_a_data_len;
+	u8 gpr_a_id;
+
+	bool gpr_b_ctrl;
+	u8 gpr_b_data_mdid;
+	u8 gpr_b_data_start;
+	u8 gpr_b_data_len;
+	u8 gpr_b_id;
+
+	bool gpr_c_ctrl;
+	u8 gpr_c_data_mdid;
+	u8 gpr_c_data_start;
+	u8 gpr_c_data_len;
+	u8 gpr_c_id;
+
+	bool gpr_d_ctrl;
+	u8 gpr_d_data_mdid;
+	u8 gpr_d_data_start;
Quoted 8 lines

drivers/net/ethernet/intel/ice/ice_metainit.h line 41

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_metainit.h new file +5 -0
+	u8 gpr_d_data_len;
+	u8 gpr_d_id;
+
+	u64 flags;
+};

The field names are not very descriptive except idx and flags. Any documentation in comment would be helpful.

Quoted 2 lines

Same here, there is no more meaningful description in the spec. But we will try if we can add some doc here. Thanks!

Perfect, thank you!

Quoted 76 lines
Quoted 76 lines

drivers/net/ethernet/intel/ice/ice_metainit.h line 43

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_metainit.h new file +2 -0
+
+void ice_metainit_dump(struct ice_hw *hw, struct ice_metainit_item

*item);

Review

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_metainit.h new file +2 -0
+struct ice_metainit_item *ice_metainit_table_get(struct ice_hw *hw);
+#endif /*_ICE_METAINIT_H_ */
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_parser.c

drivers/net/ethernet/intel/ice/ice_parser.c void *ice_parser_sect_item_get(u32 sect_type,

Quoted 12 lines

index a35f45964c9e..a1f28395c1a9 100644

drivers/net/ethernet/intel/ice/ice_parser.c +1 -0
@@ -6,6 +6,7 @@
 
   #define ICE_SEC_DATA_OFFSET				4
   #define ICE_SID_RXPARSER_IMEM_ENTRY_SIZE		48
+#define ICE_SID_RXPARSER_METADATA_INIT_ENTRY_SIZE	24
 
   /**
    * ice_parser_sect_item_get - parse a item from a section
@@ -28,6 +29,9 @@ void *ice_parser_sect_item_get(u32 sect_type,

void *section,

drivers/net/ethernet/intel/ice/ice_parser.c int ice_parser_create(struct ice_hw *hw,

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_parser.c +3 -0
   	case ICE_SID_RXPARSER_IMEM:
   		size = ICE_SID_RXPARSER_IMEM_ENTRY_SIZE;
   		break;
+	case ICE_SID_RXPARSER_METADATA_INIT:
+		size = ICE_SID_RXPARSER_METADATA_INIT_ENTRY_SIZE;
+		break;
   	default:
   		return NULL;
   	}
@@ -117,6 +121,12 @@ int ice_parser_create(struct ice_hw *hw,

struct ice_parser **psr)

drivers/net/ethernet/intel/ice/ice_parser.c int ice_parser_create(struct ice_hw *hw, struct

Quoted 13 lines
drivers/net/ethernet/intel/ice/ice_parser.c +6 -0
   		goto err;
   	}
 
+	p->mi_table = ice_metainit_table_get(hw);
+	if (!p->mi_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
   	*psr = p;
   	return 0;
   err:
@@ -131,6 +141,7 @@ int ice_parser_create(struct ice_hw *hw, struct

ice_parser **psr)

Review

Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_parser.c +1 -0
   void ice_parser_destroy(struct ice_parser *psr)
   {
   	devm_kfree(ice_hw_to_dev(psr->hw), psr->imem_table);
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->mi_table);
 
   	devm_kfree(ice_hw_to_dev(psr->hw), psr);
   }
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_parser.h

drivers/net/ethernet/intel/ice/ice_parser.h struct ice_parser { · line 12

Quoted 8 lines

index b5a3c473666a..8fcc10479260 100644

drivers/net/ethernet/intel/ice/ice_parser.h +1 -0
@@ -9,6 +9,8 @@ struct ice_parser {
 
   	/* load data from section ICE_SID_RX_PARSER_IMEM */
   	struct ice_imem_item *imem_table;
+	/* load data from section ICE_SID_RXPARSER_METADATA_INIT

*/

Review

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_parser.h +1 -0
+	struct ice_metainit_item *mi_table;
   };
 
   int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_parser_util.h

Quoted 6 lines

index 6259d3d97b23..59c67f1a1951 100644

drivers/net/ethernet/intel/ice/ice_parser_util.h +0 -0
@@ -5,6 +5,7 @@
   #define _ICE_PARSER_UTIL_H_
 
Quoted 6 lines
Quoted 5 lines

drivers/net/ethernet/intel/ice/ice_parser_util.h line 11

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_parser_util.h +1 -0
   #include "ice_imem.h"
+#include "ice_metainit.h"
 
   struct ice_pkg_sect_hdr {
   	__le16 count;

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#11 lore raw

Re: [Intel-wired-lan] [PATCH iwl-next v2 03/15] ice: init metainit table for parser

Quoted 281 lines

-----Original Message-----
From: Ivan Vecera <[email protected]>
Sent: Wednesday, August 2, 2023 23:57
To: Guo, Junfeng <[email protected]>; intel-wired- [email protected]
Cc: Zhang, Qi Z <[email protected]>; mschmidt <[email protected]>; poros <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH iwl-next v2 03/15] ice: init metainit table for parser

Quoted 10 lines · Junfeng
Quoted 10 lines

-----Original Message-----
From: Ivan Vecera <[email protected]>
Sent: Monday, July 24, 2023 18:32
To: Guo, Junfeng <[email protected]>; intel-wired- [email protected]
Cc: Zhang, Qi Z <[email protected]>; mschmidt <[email protected]>; poros <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH iwl-next v2 03/15] ice: init

metainit

Quoted 6 lines
Quoted 6 lines

table for parser

See inline comments...

Quoted 1 line · Junfeng Guo

Parse DDP section ICE_SID_RXPARSER_METADATA_INIT into an array

of

Quoted 27 lines
Quoted 27 lines
Quoted 5 lines

struct ice_metainit_item.

---
   drivers/net/ethernet/intel/ice/ice_metainit.c | 155

++++++++++++++++++

Review

Quoted 9 lines
   drivers/net/ethernet/intel/ice/ice_metainit.h |  45 +++++
   drivers/net/ethernet/intel/ice/ice_parser.c   |  11 ++
   drivers/net/ethernet/intel/ice/ice_parser.h   |   2 +
   .../net/ethernet/intel/ice/ice_parser_util.h  |   1 +
   5 files changed, 214 insertions(+)

create mode 100644 drivers/net/ethernet/intel/ice/ice_metainit.c create mode 100644 drivers/net/ethernet/intel/ice/ice_metainit.h

(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_metainit.c

Quoted 11 lines

new file mode 100644
index 000000000000..911099a38087

drivers/net/ethernet/intel/ice/ice_metainit.c new file +6 -0
@@ -0,0 +1,155 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#include "ice_common.h"
+#include "ice_parser_util.h"
+
Quoted 8 lines
Quoted 8 lines

drivers/net/ethernet/intel/ice/ice_metainit.c

Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_metainit.c new file +8 -0
+#define ICE_METAINIT_TABLE_SIZE 16
+
+/**
+ * ice_metainit_dump - dump an metainit item info
+ * @hw: pointer to the hardware structure
+ * @item: metainit item to dump
+ */
+void ice_metainit_dump(struct ice_hw *hw, struct

ice_metainit_item

Quoted 131 lines
Quoted 131 lines

*item)

Quoted 46 lines
drivers/net/ethernet/intel/ice/ice_metainit.c new file +8 -0
+{
+	dev_info(ice_hw_to_dev(hw), "index = %d\n", item->idx);
+	dev_info(ice_hw_to_dev(hw), "tsr = %d\n", item->tsr);
+	dev_info(ice_hw_to_dev(hw), "ho = %d\n", item->ho);
+	dev_info(ice_hw_to_dev(hw), "pc = %d\n", item->pc);
+	dev_info(ice_hw_to_dev(hw), "pg_rn = %d\n", item->pg_rn);
+	dev_info(ice_hw_to_dev(hw), "cd = %d\n", item->cd);
+	dev_info(ice_hw_to_dev(hw), "gpr_a_ctrl = %d\n", item-

gpr_a_ctrl);

drivers/net/ethernet/intel/ice/ice_metainit.c new file +7 -0
+	dev_info(ice_hw_to_dev(hw), "gpr_a_data_mdid = %d\n",
+		 item->gpr_a_data_mdid);
+	dev_info(ice_hw_to_dev(hw), "gpr_a_data_start = %d\n",
+		 item->gpr_a_data_start);
+	dev_info(ice_hw_to_dev(hw), "gpr_a_data_len = %d\n",
+		 item->gpr_a_data_len);
+	dev_info(ice_hw_to_dev(hw), "gpr_a_id = %d\n", item-

gpr_a_id);

drivers/net/ethernet/intel/ice/ice_metainit.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "gpr_b_ctrl = %d\n", item-

gpr_b_ctrl);

drivers/net/ethernet/intel/ice/ice_metainit.c new file +7 -0
+	dev_info(ice_hw_to_dev(hw), "gpr_b_data_mdid = %d\n",
+		 item->gpr_b_data_mdid);
+	dev_info(ice_hw_to_dev(hw), "gpr_b_data_start = %d\n",
+		 item->gpr_b_data_start);
+	dev_info(ice_hw_to_dev(hw), "gpr_b_data_len = %d\n",
+		 item->gpr_b_data_len);
+	dev_info(ice_hw_to_dev(hw), "gpr_b_id = %d\n", item-

gpr_b_id);

drivers/net/ethernet/intel/ice/ice_metainit.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "gpr_c_ctrl = %d\n", item-

gpr_c_ctrl);

drivers/net/ethernet/intel/ice/ice_metainit.c new file +8 -0
+	dev_info(ice_hw_to_dev(hw), "gpr_c_data_mdid = %d\n",
+		 item->gpr_c_data_mdid);
+	dev_info(ice_hw_to_dev(hw), "gpr_c_data_start = %d\n",
+		 item->gpr_c_data_start);
+	dev_info(ice_hw_to_dev(hw), "gpr_c_data_len = %d\n",
+		 item->gpr_c_data_len);
+	dev_info(ice_hw_to_dev(hw), "gpr_c_id = %d\n", item->gpr_c_id);
+	dev_info(ice_hw_to_dev(hw), "gpr_d_ctrl = %d\n", item-

gpr_d_ctrl);

drivers/net/ethernet/intel/ice/ice_metainit.c new file +7 -0
+	dev_info(ice_hw_to_dev(hw), "gpr_d_data_mdid = %d\n",
+		 item->gpr_d_data_mdid);
+	dev_info(ice_hw_to_dev(hw), "gpr_d_data_start = %d\n",
+		 item->gpr_d_data_start);
+	dev_info(ice_hw_to_dev(hw), "gpr_d_data_len = %d\n",
+		 item->gpr_d_data_len);
+	dev_info(ice_hw_to_dev(hw), "gpr_d_id = %d\n", item-

gpr_d_id);

drivers/net/ethernet/intel/ice/ice_metainit.c

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_metainit.c new file +5 -0
+	dev_info(ice_hw_to_dev(hw), "flags = 0x%llx\n",
+		 (unsigned long long)(item->flags));
+}
+
+/** The function parses a 192 bits Metadata Init entry with below

format:

Quoted 31 lines
+ *  BIT 0-7:	TCAM Search Key Register (mi->tsr)
+ *  BIT 8-16:	Header Offset (mi->ho)
+ *  BIT 17-24:	Program Counter (mi->pc)
+ *  BIT 25-35:	Parse Graph Root Node (mi->pg_rn)
+ *  BIT 36-38:	Control Domain (mi->cd)
+ *  BIT 39:	GPR_A Data Control (mi->gpr_a_ctrl)
+ *  BIT 40-44:	GPR_A MDID.ID (mi->gpr_a_data_mdid)
+ *  BIT 45-48:	GPR_A MDID.START (mi->gpr_a_data_start)
+ *  BIT 49-53:	GPR_A MDID.LEN (mi->gpr_a_data_len)
+ *  BIT 54-55:	reserved
+ *  BIT 56-59:	GPR_A ID (mi->gpr_a_id)
+ *  BIT 60:	GPR_B Data Control (mi->gpr_b_ctrl)
+ *  BIT 61-65:	GPR_B MDID.ID (mi->gpr_b_data_mdid)
+ *  BIT 66-69:	GPR_B MDID.START (mi->gpr_b_data_start)
+ *  BIT 70-74:	GPR_B MDID.LEN (mi->gpr_b_data_len)
+ *  BIT 75-76:	reserved
+ *  BIT 77-80:	GPR_B ID (mi->gpr_a_id)
+ *  BIT 81:	GPR_C Data Control (mi->gpr_c_ctrl)
+ *  BIT 82-86:	GPR_C MDID.ID (mi->gpr_c_data_mdid)
+ *  BIT 87-90:	GPR_C MDID.START (mi->gpr_c_data_start)
+ *  BIT 91-95:	GPR_C MDID.LEN (mi->gpr_c_data_len)
+ *  BIT 96-97:	reserved
+ *  BIT 98-101:	GPR_C ID (mi->gpr_c_id)
+ *  BIT 102:	GPR_D Data Control (mi->gpr_d_ctrl)
+ *  BIT 103-107:GPR_D MDID.ID (mi->gpr_d_data_mdid)
+ *  BIT 108-111:GPR_D MDID.START (mi->gpr_d_data_start)
+ *  BIT 112-116:GPR_D MDID.LEN (mi->gpr_d_data_len)
+ *  BIT 117-118:reserved
+ *  BIT 119-122:GPR_D ID (mi->gpr_d_id)
+ *  BIT 123-186:Flags (mi->flags)
+ *  BIT 187-191:rserved
Quoted 2 lines

+ */
+static void _metainit_parse_item(struct ice_hw *hw, u16 idx, void

*item,

Quoted 44 lines
drivers/net/ethernet/intel/ice/ice_metainit.c new file +44 -0
+				 void *data, int size)
+{
+	struct ice_metainit_item *mi = item;
+	u8 *buf = data;
+	u64 d64;
+
+	mi->idx = idx;
+	d64 = *(u64 *)buf;
+
+	mi->tsr = (u8)(d64 & 0xff);
+	mi->ho = (u16)((d64 >> 8) & 0x1ff);
+	mi->pc = (u16)((d64 >> 17) & 0xff);
+	mi->pg_rn = (u16)((d64 >> 25) & 0x3ff);
+	mi->cd = (u16)((d64 >> 36) & 0x7);
+	mi->gpr_a_ctrl = ((d64 >> 39) & 0x1) != 0;
+	mi->gpr_a_data_mdid = (u8)((d64 >> 40) & 0x1f);
+	mi->gpr_a_data_start = (u8)((d64 >> 45) & 0xf);
+	mi->gpr_a_data_len = (u8)((d64 >> 49) & 0x1f);
+	mi->gpr_a_id = (u8)((d64 >> 56) & 0xf);
+
+	d64 = *(u64 *)&buf[7] >> 4;
+	mi->gpr_b_ctrl = (d64 & 0x1) != 0;
+	mi->gpr_b_data_mdid = (u8)((d64 >> 1) & 0x1f);
+	mi->gpr_b_data_start = (u8)((d64 >> 6) & 0xf);
+	mi->gpr_b_data_len = (u8)((d64 >> 10) & 0x1f);
+	mi->gpr_b_id = (u8)((d64 >> 17) & 0xf);
+
+	mi->gpr_c_ctrl = ((d64 >> 21) & 0x1) != 0;
+	mi->gpr_c_data_mdid = (u8)((d64 >> 22) & 0x1f);
+	mi->gpr_c_data_start = (u8)((d64 >> 27) & 0xf);
+	mi->gpr_c_data_len = (u8)((d64 >> 31) & 0x1f);
+	mi->gpr_c_id = (u8)((d64 >> 38) & 0xf);
+
+	mi->gpr_d_ctrl = ((d64 >> 42) & 0x1) != 0;
+	mi->gpr_d_data_mdid = (u8)((d64 >> 43) & 0x1f);
+	mi->gpr_d_data_start = (u8)((d64 >> 48) & 0xf);
+	mi->gpr_d_data_len = (u8)((d64 >> 52) & 0x1f);
+
+	d64 = *(u64 *)&buf[14] >> 7;
+	mi->gpr_d_id = (u8)(d64 & 0xf);
+
+	d64 = *(u64 *)&buf[15] >> 3;
+	mi->flags = d64;
+
Quoted 8 lines
Quoted 8 lines

drivers/net/ethernet/intel/ice/ice_metainit.c line 141

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_metainit.c new file +6 -0
+	d64 = ((*(u64 *)&buf[16] >> 56) & 0x7);
+	mi->flags |= (d64 << 61);
+
+	if (hw->debug_mask & ICE_DBG_PARSER)
+		ice_metainit_dump(hw, mi);
+}

Do not use hardcoded values for indices, masks and shifts and use

macros

Quoted 72 lines
Quoted 1 line

or enums with symbolic names instead.

Sure, make sense! Will update in the coming version. Thanks!

Quoted 67 lines

drivers/net/ethernet/intel/ice/ice_metainit.c

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_metainit.c new file +9 -0
+
+/**
+ * ice_metainit_table_get - create a metainit table
+ * @hw: pointer to the hardware structure
+ */
+struct ice_metainit_item *ice_metainit_table_get(struct ice_hw *hw)
+{
+	return (struct ice_metainit_item *)
+		ice_parser_create_table(hw,

ICE_SID_RXPARSER_METADATA_INIT,

Review

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_metainit.c new file +5 -0
+					sizeof(struct ice_metainit_item),
+					ICE_METAINIT_TABLE_SIZE,
+					ice_parser_sect_item_get,
+					_metainit_parse_item);
+}
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_metainit.h

Quoted 36 lines

new file mode 100644
index 000000000000..aa7a9e178820

drivers/net/ethernet/intel/ice/ice_metainit.h new file +31 -0
@@ -0,0 +1,45 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#ifndef _ICE_METAINIT_H_
+#define _ICE_METAINIT_H_
+
+struct ice_metainit_item {
+	u16 idx;
+
+	u8 tsr;
+	u16 ho;
+	u16 pc;
+	u16 pg_rn;
+	u8 cd;
+
+	bool gpr_a_ctrl;
+	u8 gpr_a_data_mdid;
+	u8 gpr_a_data_start;
+	u8 gpr_a_data_len;
+	u8 gpr_a_id;
+
+	bool gpr_b_ctrl;
+	u8 gpr_b_data_mdid;
+	u8 gpr_b_data_start;
+	u8 gpr_b_data_len;
+	u8 gpr_b_id;
+
+	bool gpr_c_ctrl;
+	u8 gpr_c_data_mdid;
+	u8 gpr_c_data_start;
+	u8 gpr_c_data_len;

drivers/net/ethernet/intel/ice/ice_metainit.h line 41

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_metainit.h new file +10 -0
+	u8 gpr_c_id;
+
+	bool gpr_d_ctrl;
+	u8 gpr_d_data_mdid;
+	u8 gpr_d_data_start;
+	u8 gpr_d_data_len;
+	u8 gpr_d_id;
+
+	u64 flags;
+};

The field names are not very descriptive except idx and flags. Any documentation in comment would be helpful.

Quoted 4 lines
Quoted 2 lines

Same here, there is no more meaningful description in the spec. But we will try if we can add some doc here. Thanks!

Perfect, thank you!

Thanks for the careful review!
Will refresh the code and send out patch set with new version. Thanks!

Quoted 38 lines
Quoted 4 lines
Quoted 4 lines

drivers/net/ethernet/intel/ice/ice_metainit.h line 43

Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_metainit.h new file +2 -0
+
+void ice_metainit_dump(struct ice_hw *hw, struct

ice_metainit_item

Quoted 2 lines
Quoted 2 lines

*item);

Quoted 1 line
drivers/net/ethernet/intel/ice/ice_metainit.h new file +1 -0
+struct ice_metainit_item *ice_metainit_table_get(struct ice_hw

*hw);

Quoted 30 lines
Quoted 30 lines

Review

Quoted 2 lines
drivers/net/ethernet/intel/ice/ice_metainit.h new file +1 -0
+#endif /*_ICE_METAINIT_H_ */
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_parser.c

drivers/net/ethernet/intel/ice/ice_parser.c void *ice_parser_sect_item_get(u32 sect_type,

Quoted 12 lines

index a35f45964c9e..a1f28395c1a9 100644

drivers/net/ethernet/intel/ice/ice_parser.c +1 -0
@@ -6,6 +6,7 @@
 
   #define ICE_SEC_DATA_OFFSET				4
   #define ICE_SID_RXPARSER_IMEM_ENTRY_SIZE		48
+#define ICE_SID_RXPARSER_METADATA_INIT_ENTRY_SIZE	24
 
   /**
    * ice_parser_sect_item_get - parse a item from a section
@@ -28,6 +29,9 @@ void *ice_parser_sect_item_get(u32 sect_type,

void *section,

drivers/net/ethernet/intel/ice/ice_parser.c int ice_parser_create(struct ice_hw *hw,

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_parser.c +3 -0
   	case ICE_SID_RXPARSER_IMEM:
   		size = ICE_SID_RXPARSER_IMEM_ENTRY_SIZE;
   		break;
+	case ICE_SID_RXPARSER_METADATA_INIT:
+		size = ICE_SID_RXPARSER_METADATA_INIT_ENTRY_SIZE;
+		break;
   	default:
   		return NULL;
   	}
@@ -117,6 +121,12 @@ int ice_parser_create(struct ice_hw *hw,

struct ice_parser **psr)

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_parser.c +0 -0
   		goto err;
   	}
 
Quoted 48 lines
Quoted 10 lines
Quoted 10 lines

drivers/net/ethernet/intel/ice/ice_parser.c int ice_parser_create(struct ice_hw *hw,

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_parser.c +6 -0
+	p->mi_table = ice_metainit_table_get(hw);
+	if (!p->mi_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
   	*psr = p;
   	return 0;
   err:
@@ -131,6 +141,7 @@ int ice_parser_create(struct ice_hw *hw,

struct

Quoted 37 lines
Quoted 36 lines

ice_parser **psr)

Review

Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_parser.c +1 -0
   void ice_parser_destroy(struct ice_parser *psr)
   {
   	devm_kfree(ice_hw_to_dev(psr->hw), psr->imem_table);
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->mi_table);
 
   	devm_kfree(ice_hw_to_dev(psr->hw), psr);
   }
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_parser.h

drivers/net/ethernet/intel/ice/ice_parser.h struct ice_parser { · line 12

Quoted 8 lines

index b5a3c473666a..8fcc10479260 100644

drivers/net/ethernet/intel/ice/ice_parser.h +1 -0
@@ -9,6 +9,8 @@ struct ice_parser {
 
   	/* load data from section ICE_SID_RX_PARSER_IMEM */
   	struct ice_imem_item *imem_table;
+	/* load data from section ICE_SID_RXPARSER_METADATA_INIT

*/

Review

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_parser.h +1 -0
+	struct ice_metainit_item *mi_table;
   };
 
   int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_parser_util.h

Quoted 11 lines

index 6259d3d97b23..59c67f1a1951 100644

drivers/net/ethernet/intel/ice/ice_parser_util.h +1 -0
@@ -5,6 +5,7 @@
   #define _ICE_PARSER_UTIL_H_
 
   #include "ice_imem.h"
+#include "ice_metainit.h"
 
   struct ice_pkg_sect_hdr {
   	__le16 count;

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#12 lore raw

PATCH v2 4/15 ice: init parse graph cam table for parser

In reply to Junfeng Guo

Parse DDP section ICE_SID_RXPARSER_CAM or ICE_SID_RXPARSER_PG_SPILL into an array of struct ice_pg_cam_item.
Parse DDP section ICE_SID_RXPARSER_NOMATCH_CAM or ICE_SID_RXPARSER_NOMATCH_SPILL into an array of struct ice_pg_nm_cam_item.

---
 drivers/net/ethernet/intel/ice/ice_parser.c |  44 +++
 drivers/net/ethernet/intel/ice/ice_parser.h |  12 +
 drivers/net/ethernet/intel/ice/ice_pg_cam.c | 300 ++++++++++++++++++++
 drivers/net/ethernet/intel/ice/ice_pg_cam.h |  67 +++++
 4 files changed, 423 insertions(+)
 create mode 100644 drivers/net/ethernet/intel/ice/ice_pg_cam.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_pg_cam.h
drivers/net/ethernet/intel/ice/ice_parser.c +44 -0
index a1f28395c1a9..22c2382ae9e8 100644
@@ -7,6 +7,10 @@
 #define ICE_SEC_DATA_OFFSET				4
 #define ICE_SID_RXPARSER_IMEM_ENTRY_SIZE		48
 #define ICE_SID_RXPARSER_METADATA_INIT_ENTRY_SIZE	24
+#define ICE_SID_RXPARSER_CAM_ENTRY_SIZE			16
+#define ICE_SID_RXPARSER_PG_SPILL_ENTRY_SIZE		17
+#define ICE_SID_RXPARSER_NOMATCH_CAM_ENTRY_SIZE		12
+#define ICE_SID_RXPARSER_NOMATCH_SPILL_ENTRY_SIZE	13
 
 /**
  * ice_parser_sect_item_get - parse a item from a section
@@ -32,6 +36,18 @@ void *ice_parser_sect_item_get(u32 sect_type, void *section,
 	case ICE_SID_RXPARSER_METADATA_INIT:
 		size = ICE_SID_RXPARSER_METADATA_INIT_ENTRY_SIZE;
 		break;
+	case ICE_SID_RXPARSER_CAM:
+		size = ICE_SID_RXPARSER_CAM_ENTRY_SIZE;
+		break;
+	case ICE_SID_RXPARSER_PG_SPILL:
+		size = ICE_SID_RXPARSER_PG_SPILL_ENTRY_SIZE;
+		break;
+	case ICE_SID_RXPARSER_NOMATCH_CAM:
+		size = ICE_SID_RXPARSER_NOMATCH_CAM_ENTRY_SIZE;
+		break;
+	case ICE_SID_RXPARSER_NOMATCH_SPILL:
+		size = ICE_SID_RXPARSER_NOMATCH_SPILL_ENTRY_SIZE;
+		break;
 	default:
 		return NULL;
 	}
@@ -127,6 +143,30 @@ int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr)
 		goto err;
 	}
 
+	p->pg_cam_table = ice_pg_cam_table_get(hw);
+	if (!p->pg_cam_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
+	p->pg_sp_cam_table = ice_pg_sp_cam_table_get(hw);
+	if (!p->pg_sp_cam_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
+	p->pg_nm_cam_table = ice_pg_nm_cam_table_get(hw);
+	if (!p->pg_nm_cam_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
+	p->pg_nm_sp_cam_table = ice_pg_nm_sp_cam_table_get(hw);
+	if (!p->pg_nm_sp_cam_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
 	*psr = p;
 	return 0;
 err:
@@ -142,6 +182,10 @@ void ice_parser_destroy(struct ice_parser *psr)
 {
 	devm_kfree(ice_hw_to_dev(psr->hw), psr->imem_table);
 	devm_kfree(ice_hw_to_dev(psr->hw), psr->mi_table);
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->pg_cam_table);
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->pg_sp_cam_table);
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->pg_nm_cam_table);
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->pg_nm_sp_cam_table);
 
 	devm_kfree(ice_hw_to_dev(psr->hw), psr);
 }
drivers/net/ethernet/intel/ice/ice_parser.h +12 -0
index 8fcc10479260..1f699ef12387 100644
@@ -4,6 +4,10 @@
 #ifndef _ICE_PARSER_H_
 #define _ICE_PARSER_H_
 
+#include "ice_metainit.h"
+#include "ice_imem.h"
+#include "ice_pg_cam.h"
+
 struct ice_parser {
 	struct ice_hw *hw; /* pointer to the hardware structure */
 
@@ -11,6 +15,14 @@ struct ice_parser {
 	struct ice_imem_item *imem_table;
 	/* load data from section ICE_SID_RXPARSER_METADATA_INIT */
 	struct ice_metainit_item *mi_table;
+	/* load data from section ICE_SID_RXPARSER_CAM */
+	struct ice_pg_cam_item *pg_cam_table;
+	/* load data from section ICE_SID_RXPARSER_PG_SPILL */
+	struct ice_pg_cam_item *pg_sp_cam_table;
+	/* load data from section ICE_SID_RXPARSER_NOMATCH_CAM */
+	struct ice_pg_nm_cam_item *pg_nm_cam_table;
+	/* load data from section ICE_SID_RXPARSER_NOMATCH_SPILL */
+	struct ice_pg_nm_cam_item *pg_nm_sp_cam_table;
 };
 
 int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +300 -0

300 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_pg_cam.h new file +67 -0

67 lines not on this page · raw message

Signature · 6 lines
2.25.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
#13 lore raw

Re: [Intel-wired-lan] [PATCH iwl-next v2 04/15] ice: init parse graph cam table for parser

See inline comments...

Quoted 218 lines · Junfeng Guo

Parse DDP section ICE_SID_RXPARSER_CAM or ICE_SID_RXPARSER_PG_SPILL into an array of struct ice_pg_cam_item.
Parse DDP section ICE_SID_RXPARSER_NOMATCH_CAM or ICE_SID_RXPARSER_NOMATCH_SPILL into an array of struct ice_pg_nm_cam_item.

---
  drivers/net/ethernet/intel/ice/ice_parser.c |  44 +++
  drivers/net/ethernet/intel/ice/ice_parser.h |  12 +
  drivers/net/ethernet/intel/ice/ice_pg_cam.c | 300 ++++++++++++++++++++
  drivers/net/ethernet/intel/ice/ice_pg_cam.h |  67 +++++
  4 files changed, 423 insertions(+)

create mode 100644 drivers/net/ethernet/intel/ice/ice_pg_cam.c create mode 100644 drivers/net/ethernet/intel/ice/ice_pg_cam.h

drivers/net/ethernet/intel/ice/ice_parser.c +44 -0
index a1f28395c1a9..22c2382ae9e8 100644
@@ -7,6 +7,10 @@
  #define ICE_SEC_DATA_OFFSET				4
  #define ICE_SID_RXPARSER_IMEM_ENTRY_SIZE		48
  #define ICE_SID_RXPARSER_METADATA_INIT_ENTRY_SIZE	24
+#define ICE_SID_RXPARSER_CAM_ENTRY_SIZE			16
+#define ICE_SID_RXPARSER_PG_SPILL_ENTRY_SIZE		17
+#define ICE_SID_RXPARSER_NOMATCH_CAM_ENTRY_SIZE		12
+#define ICE_SID_RXPARSER_NOMATCH_SPILL_ENTRY_SIZE	13
 
  /**
   * ice_parser_sect_item_get - parse a item from a section
@@ -32,6 +36,18 @@ void *ice_parser_sect_item_get(u32 sect_type, void *section,
  	case ICE_SID_RXPARSER_METADATA_INIT:
  		size = ICE_SID_RXPARSER_METADATA_INIT_ENTRY_SIZE;
  		break;
+	case ICE_SID_RXPARSER_CAM:
+		size = ICE_SID_RXPARSER_CAM_ENTRY_SIZE;
+		break;
+	case ICE_SID_RXPARSER_PG_SPILL:
+		size = ICE_SID_RXPARSER_PG_SPILL_ENTRY_SIZE;
+		break;
+	case ICE_SID_RXPARSER_NOMATCH_CAM:
+		size = ICE_SID_RXPARSER_NOMATCH_CAM_ENTRY_SIZE;
+		break;
+	case ICE_SID_RXPARSER_NOMATCH_SPILL:
+		size = ICE_SID_RXPARSER_NOMATCH_SPILL_ENTRY_SIZE;
+		break;
  	default:
  		return NULL;
  	}
@@ -127,6 +143,30 @@ int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr)
  		goto err;
  	}
 
+	p->pg_cam_table = ice_pg_cam_table_get(hw);
+	if (!p->pg_cam_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
+	p->pg_sp_cam_table = ice_pg_sp_cam_table_get(hw);
+	if (!p->pg_sp_cam_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
+	p->pg_nm_cam_table = ice_pg_nm_cam_table_get(hw);
+	if (!p->pg_nm_cam_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
+	p->pg_nm_sp_cam_table = ice_pg_nm_sp_cam_table_get(hw);
+	if (!p->pg_nm_sp_cam_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
  	*psr = p;
  	return 0;
  err:
@@ -142,6 +182,10 @@ void ice_parser_destroy(struct ice_parser *psr)
  {
  	devm_kfree(ice_hw_to_dev(psr->hw), psr->imem_table);
  	devm_kfree(ice_hw_to_dev(psr->hw), psr->mi_table);
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->pg_cam_table);
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->pg_sp_cam_table);
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->pg_nm_cam_table);
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->pg_nm_sp_cam_table);
 
  	devm_kfree(ice_hw_to_dev(psr->hw), psr);
  }
drivers/net/ethernet/intel/ice/ice_parser.h +12 -0
index 8fcc10479260..1f699ef12387 100644
@@ -4,6 +4,10 @@
  #ifndef _ICE_PARSER_H_
  #define _ICE_PARSER_H_
 
+#include "ice_metainit.h"
+#include "ice_imem.h"
+#include "ice_pg_cam.h"
+
  struct ice_parser {
  	struct ice_hw *hw; /* pointer to the hardware structure */
 
@@ -11,6 +15,14 @@ struct ice_parser {
  	struct ice_imem_item *imem_table;
  	/* load data from section ICE_SID_RXPARSER_METADATA_INIT */
  	struct ice_metainit_item *mi_table;
+	/* load data from section ICE_SID_RXPARSER_CAM */
+	struct ice_pg_cam_item *pg_cam_table;
+	/* load data from section ICE_SID_RXPARSER_PG_SPILL */
+	struct ice_pg_cam_item *pg_sp_cam_table;
+	/* load data from section ICE_SID_RXPARSER_NOMATCH_CAM */
+	struct ice_pg_nm_cam_item *pg_nm_cam_table;
+	/* load data from section ICE_SID_RXPARSER_NOMATCH_SPILL */
+	struct ice_pg_nm_cam_item *pg_nm_sp_cam_table;
  };
 
  int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +91 -0
new file mode 100644
index 000000000000..25b837ba684c
@@ -0,0 +1,300 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#include "ice_common.h"
+#include "ice_parser_util.h"
+
+static void _pg_cam_key_dump(struct ice_hw *hw, struct ice_pg_cam_key *key)
+{
+	dev_info(ice_hw_to_dev(hw), "key:\n");
+	dev_info(ice_hw_to_dev(hw), "\tvalid = %d\n", key->valid);
+	dev_info(ice_hw_to_dev(hw), "\tnode_id = %d\n", key->node_id);
+	dev_info(ice_hw_to_dev(hw), "\tflag0 = %d\n", key->flag0);
+	dev_info(ice_hw_to_dev(hw), "\tflag1 = %d\n", key->flag1);
+	dev_info(ice_hw_to_dev(hw), "\tflag2 = %d\n", key->flag2);
+	dev_info(ice_hw_to_dev(hw), "\tflag3 = %d\n", key->flag3);
+	dev_info(ice_hw_to_dev(hw), "\tboost_idx = %d\n", key->boost_idx);
+	dev_info(ice_hw_to_dev(hw), "\talu_reg = 0x%04x\n", key->alu_reg);
+	dev_info(ice_hw_to_dev(hw), "\tnext_proto = 0x%08x\n",
+		 key->next_proto);
+}
+
+static void _pg_nm_cam_key_dump(struct ice_hw *hw,
+				struct ice_pg_nm_cam_key *key)
+{
+	dev_info(ice_hw_to_dev(hw), "key:\n");
+	dev_info(ice_hw_to_dev(hw), "\tvalid = %d\n", key->valid);
+	dev_info(ice_hw_to_dev(hw), "\tnode_id = %d\n", key->node_id);
+	dev_info(ice_hw_to_dev(hw), "\tflag0 = %d\n", key->flag0);
+	dev_info(ice_hw_to_dev(hw), "\tflag1 = %d\n", key->flag1);
+	dev_info(ice_hw_to_dev(hw), "\tflag2 = %d\n", key->flag2);
+	dev_info(ice_hw_to_dev(hw), "\tflag3 = %d\n", key->flag3);
+	dev_info(ice_hw_to_dev(hw), "\tboost_idx = %d\n", key->boost_idx);
+	dev_info(ice_hw_to_dev(hw), "\talu_reg = 0x%04x\n", key->alu_reg);
+}
+
+static void _pg_cam_action_dump(struct ice_hw *hw,
+				struct ice_pg_cam_action *action)
+{
+	dev_info(ice_hw_to_dev(hw), "action:\n");
+	dev_info(ice_hw_to_dev(hw), "\tnext_node = %d\n", action->next_node);
+	dev_info(ice_hw_to_dev(hw), "\tnext_pc = %d\n", action->next_pc);
+	dev_info(ice_hw_to_dev(hw), "\tis_pg = %d\n", action->is_pg);
+	dev_info(ice_hw_to_dev(hw), "\tproto_id = %d\n", action->proto_id);
+	dev_info(ice_hw_to_dev(hw), "\tis_mg = %d\n", action->is_mg);
+	dev_info(ice_hw_to_dev(hw), "\tmarker_id = %d\n", action->marker_id);
+	dev_info(ice_hw_to_dev(hw), "\tis_last_round = %d\n",
+		 action->is_last_round);
+	dev_info(ice_hw_to_dev(hw), "\tho_polarity = %d\n",
+		 action->ho_polarity);
+	dev_info(ice_hw_to_dev(hw), "\tho_inc = %d\n", action->ho_inc);
+}
+
+/**
+ * ice_pg_cam_dump - dump an parse graph cam info
+ * @hw: pointer to the hardware structure
+ * @item: parse graph cam to dump
+ */
+void ice_pg_cam_dump(struct ice_hw *hw, struct ice_pg_cam_item *item)
+{
+	dev_info(ice_hw_to_dev(hw), "index = %d\n", item->idx);
+	_pg_cam_key_dump(hw, &item->key);
+	_pg_cam_action_dump(hw, &item->action);
+}
+
+/**
+ * ice_pg_nm_cam_dump - dump an parse graph no match cam info
+ * @hw: pointer to the hardware structure
+ * @item: parse graph no match cam to dump
+ */
+void ice_pg_nm_cam_dump(struct ice_hw *hw, struct ice_pg_nm_cam_item *item)
+{
+	dev_info(ice_hw_to_dev(hw), "index = %d\n", item->idx);
+	_pg_nm_cam_key_dump(hw, &item->key);
+	_pg_cam_action_dump(hw, &item->action);
+}
+
+/** The function parses a 55 bits Parse Graph CAM Action with below format:
+ *  BIT 0-11:	Next Node ID (action->next_node)
+ *  BIT 12-19:	Next PC (action->next_pc)
+ *  BIT 20:	Is Protocol Group (action->is_pg)
+ *  BIT 21-23:	reserved
+ *  BIT 24-31:	Protocol ID (action->proto_id)
+ *  BIT 32:	Is Marker Group (action->is_mg)
+ *  BIT 33-40:	Marker ID (action->marker_id)
+ *  BIT 41:	Is Last Round (action->is_last_round)
+ *  BIT 42:	Header Offset Polarity (action->ho_poloarity)
+ *  BIT 43-51:	Header Offset Inc (action->ho_inc)
+ *  BIT 52-54:	reserved
+ */
+static void _pg_cam_action_init(struct ice_pg_cam_action *action, u64 data)
+{

drivers/net/ethernet/intel/ice/ice_pg_cam.c line 101

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +10 -0
+	action->next_node = (u16)(data & 0x7ff);
+	action->next_pc = (u8)((data >> 11) & 0xff);
+	action->is_pg = ((data >> 19) & 0x1) != 0;
+	action->proto_id = ((data >> 23) & 0xff);
+	action->is_mg = ((data >> 31) & 0x1) != 0;
+	action->marker_id = ((data >> 32) & 0xff);
+	action->is_last_round = ((data >> 40) & 0x1) != 0;
+	action->ho_polarity = ((data >> 41) & 0x1) != 0;
+	action->ho_inc = ((data >> 42) & 0x1ff);
+}

As in my previous emails... such blocks with hardcoded values are unacceptable.

Quoted 16 lines
drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +16 -0
+
+/** The function parses a 41 bits Parse Graph NoMatch CAM Key with below format:
+ *  BIT 0:	Valid (key->valid)
+ *  BIT 1-11:	Node ID (key->node_id)
+ *  BIT 12:	Flag 0 (key->flag0)
+ *  BIT 13:	Flag 1 (key->flag1)
+ *  BIT 14:	Flag 2 (key->flag2)
+ *  BIT 15:	Flag 3 (key->flag3)
+ *  BIT 16:	Boost Hit (key->boost_idx to 0 if it is 0)
+ *  BIT 17-24:	Boost Index (key->boost_idx only if Boost Hit is not 0)
+ *  BIT 25-40:	ALU Reg (key->alu_reg)
+ */
+static void _pg_nm_cam_key_init(struct ice_pg_nm_cam_key *key, u64 data)
+{
+	key->valid = (data & 0x1) != 0;
+	key->node_id = (u16)((data >> 1) & 0x7ff);

drivers/net/ethernet/intel/ice/ice_pg_cam.c line 127

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +10 -0
+	key->flag0 = ((data >> 12) & 0x1) != 0;
+	key->flag1 = ((data >> 13) & 0x1) != 0;
+	key->flag2 = ((data >> 14) & 0x1) != 0;
+	key->flag3 = ((data >> 15) & 0x1) != 0;
+	if ((data >> 16) & 0x1)
+		key->boost_idx = (u8)((data >> 17) & 0xff);
+	else
+		key->boost_idx = 0;
+	key->alu_reg = (u16)((data >> 25) & 0xffff);
+}

Here the same but also flag0..3? Could it be possible to use more descriptive names or in multi-purpose case union of bools?

Quoted 226 lines
drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +173 -0
+
+/** The function parses a 73 bits Parse Graph CAM Key with below format:
+ *  BIT 0:	Valid (key->valid)
+ *  BIT 1-11:	Node ID (key->node_id)
+ *  BIT 12:	Flag 0 (key->flag0)
+ *  BIT 13:	Flag 1 (key->flag1)
+ *  BIT 14:	Flag 2 (key->flag2)
+ *  BIT 15:	Flag 3 (key->flag3)
+ *  BIT 16:	Boost Hit (key->boost_idx to 0 if it is 0)
+ *  BIT 17-24:	Boost Index (key->boost_idx only if Boost Hit is not 0)
+ *  BIT 25-40:	ALU Reg (key->alu_reg)
+ *  BIT 41-72:	Next Proto Key (key->next_proto)
+ */
+static void _pg_cam_key_init(struct ice_pg_cam_key *key, u8 *data)
+{
+	u64 d64 = *(u64 *)data;
+
+	key->valid = (d64 & 0x1) != 0;
+	key->node_id = (u16)((d64 >> 1) & 0x7ff);
+	key->flag0 = ((d64 >> 12) & 0x1) != 0;
+	key->flag1 = ((d64 >> 13) & 0x1) != 0;
+	key->flag2 = ((d64 >> 14) & 0x1) != 0;
+	key->flag3 = ((d64 >> 15) & 0x1) != 0;
+	if ((d64 >> 16) & 0x1)
+		key->boost_idx = (u8)((d64 >> 17) & 0xff);
+	else
+		key->boost_idx = 0;
+	key->alu_reg = (u16)((d64 >> 25) & 0xffff);
+
+	key->next_proto = (*(u32 *)&data[5] >> 1);
+	key->next_proto |= ((u32)(data[9] & 0x1) << 31);
+}
+
+/** The function parses a 128 bits Parse Graph CAM Entry with below format:
+ *  BIT 0-72:	Key (ci->key)
+ *  BIT 73-127:	Action (ci->action)
+ */
+static void _pg_cam_parse_item(struct ice_hw *hw, u16 idx, void *item,
+			       void *data, int size)
+{
+	struct ice_pg_cam_item *ci = item;
+	u8 *buf = data;
+	u64 d64;
+
+	ci->idx = idx;
+	d64 = (*(u64 *)&buf[9] >> 1);
+	_pg_cam_key_init(&ci->key, buf);
+	_pg_cam_action_init(&ci->action, d64);
+
+	if (hw->debug_mask & ICE_DBG_PARSER)
+		ice_pg_cam_dump(hw, ci);
+}
+
+/** The function parses a 136 bits Parse Graph Spill CAM Entry with below
+ *  format:
+ *  BIT 0-55:	Action (ci->key)
+ *  BIT 56-135:	Key (ci->action)
+ */
+static void _pg_sp_cam_parse_item(struct ice_hw *hw, u16 idx, void *item,
+				  void *data, int size)
+{
+	struct ice_pg_cam_item *ci = item;
+	u8 *buf = data;
+	u64 d64;
+
+	ci->idx = idx;
+	d64 = *(u64 *)buf;
+	_pg_cam_action_init(&ci->action, d64);
+	_pg_cam_key_init(&ci->key, &buf[7]);
+
+	if (hw->debug_mask & ICE_DBG_PARSER)
+		ice_pg_cam_dump(hw, ci);
+}
+
+/** The function parses a 96 bits Parse Graph NoMatch CAM Entry with below
+ *  format:
+ *  BIT 0-40:	Key (ci->key)
+ *  BIT 41-95:	Action (ci->action)
+ */
+static void _pg_nm_cam_parse_item(struct ice_hw *hw, u16 idx, void *item,
+				  void *data, int size)
+{
+	struct ice_pg_nm_cam_item *ci = item;
+	u8 *buf = data;
+	u64 d64;
+
+	ci->idx = idx;
+	d64 = *(u64 *)buf;
+	_pg_nm_cam_key_init(&ci->key, d64);
+	d64 = (*(u64 *)&buf[5] >> 1);
+	_pg_cam_action_init(&ci->action, d64);
+
+	if (hw->debug_mask & ICE_DBG_PARSER)
+		ice_pg_nm_cam_dump(hw, ci);
+}
+
+/** The function parses a 104 bits Parse Graph NoMatch Spill CAM Entry with
+ *  below format:
+ *  BIT 0-55:	Key (ci->key)
+ *  BIT 56-103:	Action (ci->action)
+ */
+static void _pg_nm_sp_cam_parse_item(struct ice_hw *hw, u16 idx, void *item,
+				     void *data, int size)
+{
+	struct ice_pg_nm_cam_item *ci = item;
+	u8 *buf = data;
+	u64 d64;
+
+	ci->idx = idx;
+	d64 = *(u64 *)buf;
+	_pg_cam_action_init(&ci->action, d64);
+	d64 = *(u64 *)&buf[7];
+	_pg_nm_cam_key_init(&ci->key, d64);
+
+	if (hw->debug_mask & ICE_DBG_PARSER)
+		ice_pg_nm_cam_dump(hw, ci);
+}
+
+/**
+ * ice_pg_cam_table_get - create a parse graph cam table
+ * @hw: pointer to the hardware structure
+ */
+struct ice_pg_cam_item *ice_pg_cam_table_get(struct ice_hw *hw)
+{
+	return (struct ice_pg_cam_item *)
+		ice_parser_create_table(hw, ICE_SID_RXPARSER_CAM,
+					sizeof(struct ice_pg_cam_item),
+					ICE_PG_CAM_TABLE_SIZE,
+					ice_parser_sect_item_get,
+					_pg_cam_parse_item);
+}
+
+/**
+ * ice_pg_sp_cam_table_get - create a parse graph spill cam table
+ * @hw: pointer to the hardware structure
+ */
+struct ice_pg_cam_item *ice_pg_sp_cam_table_get(struct ice_hw *hw)
+{
+	return (struct ice_pg_cam_item *)
+		ice_parser_create_table(hw, ICE_SID_RXPARSER_PG_SPILL,
+					sizeof(struct ice_pg_cam_item),
+					ICE_PG_SP_CAM_TABLE_SIZE,
+					ice_parser_sect_item_get,
+					_pg_sp_cam_parse_item);
+}
+
+/**
+ * ice_pg_nm_cam_table_get - create a parse graph no match cam table
+ * @hw: pointer to the hardware structure
+ */
+struct ice_pg_nm_cam_item *ice_pg_nm_cam_table_get(struct ice_hw *hw)
+{
+	return (struct ice_pg_nm_cam_item *)
+		ice_parser_create_table(hw, ICE_SID_RXPARSER_NOMATCH_CAM,
+					sizeof(struct ice_pg_nm_cam_item),
+					ICE_PG_NM_CAM_TABLE_SIZE,
+					ice_parser_sect_item_get,
+					_pg_nm_cam_parse_item);
+}
+
+/**
+ * ice_pg_nm_sp_cam_table_get - create a parse graph no match spill cam table
+ * @hw: pointer to the hardware structure
+ */
+struct ice_pg_nm_cam_item *ice_pg_nm_sp_cam_table_get(struct ice_hw *hw)
+{
+	return (struct ice_pg_nm_cam_item *)
+		ice_parser_create_table(hw, ICE_SID_RXPARSER_NOMATCH_SPILL,
+					sizeof(struct ice_pg_nm_cam_item),
+					ICE_PG_NM_SP_CAM_TABLE_SIZE,
+					ice_parser_sect_item_get,
+					_pg_nm_sp_cam_parse_item);
+}
drivers/net/ethernet/intel/ice/ice_pg_cam.h new file +47 -0
new file mode 100644
index 000000000000..1d794fa519d6
@@ -0,0 +1,67 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#ifndef _ICE_PG_CAM_H_
+#define _ICE_PG_CAM_H_
+
+#define ICE_PG_CAM_TABLE_SIZE		2048
+#define ICE_PG_SP_CAM_TABLE_SIZE	128
+#define ICE_PG_NM_CAM_TABLE_SIZE	1024
+#define ICE_PG_NM_SP_CAM_TABLE_SIZE	64
+
+struct ice_pg_cam_key {
+	bool valid;
+	u16 node_id;
+	bool flag0;
+	bool flag1;
+	bool flag2;
+	bool flag3;
+	u8 boost_idx;
+	u16 alu_reg;
+	u32 next_proto;
+};
+
+struct ice_pg_nm_cam_key {
+	bool valid;
+	u16 node_id;
+	bool flag0;
+	bool flag1;
+	bool flag2;
+	bool flag3;
+	u8 boost_idx;
+	u16 alu_reg;
+};
+
+struct ice_pg_cam_action {
+	u16 next_node;
+	u8 next_pc;
+	bool is_pg;
+	u8 proto_id;
+	bool is_mg;
+	u8 marker_id;
+	bool is_last_round;
+	bool ho_polarity;
+	u16 ho_inc;
+};
+
+struct ice_pg_cam_item {

drivers/net/ethernet/intel/ice/ice_pg_cam.h line 57

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_pg_cam.h new file +10 -0
+	u16 idx;
+	struct ice_pg_cam_key key;
+	struct ice_pg_cam_action action;
+};
+
+struct ice_pg_nm_cam_item {
+	u16 idx;
+	struct ice_pg_nm_cam_key key;
+	struct ice_pg_cam_action action;
+};

Some comment with documentation of the fields in the all structs above would be fine.

drivers/net/ethernet/intel/ice/ice_pg_cam.h line 67

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_pg_cam.h new file +10 -0
+
+void ice_pg_cam_dump(struct ice_hw *hw, struct ice_pg_cam_item *item);
+void ice_pg_nm_cam_dump(struct ice_hw *hw, struct ice_pg_nm_cam_item *item);
+
+struct ice_pg_cam_item *ice_pg_cam_table_get(struct ice_hw *hw);
+struct ice_pg_cam_item *ice_pg_sp_cam_table_get(struct ice_hw *hw);
+
+struct ice_pg_nm_cam_item *ice_pg_nm_cam_table_get(struct ice_hw *hw);
+struct ice_pg_nm_cam_item *ice_pg_nm_sp_cam_table_get(struct ice_hw *hw);
+#endif /* _ICE_PG_CAM_H_ */

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#14 lore raw

Re: [Intel-wired-lan] [PATCH iwl-next v2 04/15] ice: init parse graph cam table for parser

Quoted 259 lines

-----Original Message-----
From: Ivan Vecera <[email protected]>
Sent: Monday, July 24, 2023 18:37
To: Guo, Junfeng <[email protected]>; intel-wired- [email protected]
Cc: Zhang, Qi Z <[email protected]>; mschmidt <[email protected]>; poros <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH iwl-next v2 04/15] ice: init parse graph cam table for parser

See inline comments...

Quoted 1 line · Junfeng Guo

Parse DDP section ICE_SID_RXPARSER_CAM or

ICE_SID_RXPARSER_PG_SPILL

Quoted 3 lines

into an array of struct ice_pg_cam_item. Parse DDP section ICE_SID_RXPARSER_NOMATCH_CAM or ICE_SID_RXPARSER_NOMATCH_SPILL into an array of struct

ice_pg_nm_cam_item.

Quoted 6 lines
---
  drivers/net/ethernet/intel/ice/ice_parser.c |  44 +++
  drivers/net/ethernet/intel/ice/ice_parser.h |  12 +
  drivers/net/ethernet/intel/ice/ice_pg_cam.c | 300

++++++++++++++++++++

Review

Quoted 6 lines
  drivers/net/ethernet/intel/ice/ice_pg_cam.h |  67 +++++
  4 files changed, 423 insertions(+)

create mode 100644 drivers/net/ethernet/intel/ice/ice_pg_cam.c create mode 100644 drivers/net/ethernet/intel/ice/ice_pg_cam.h

(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_parser.c

drivers/net/ethernet/intel/ice/ice_parser.c line 10

Quoted 8 lines

index a1f28395c1a9..22c2382ae9e8 100644

drivers/net/ethernet/intel/ice/ice_parser.c +1 -0
@@ -7,6 +7,10 @@
  #define ICE_SEC_DATA_OFFSET				4
  #define ICE_SID_RXPARSER_IMEM_ENTRY_SIZE		48
  #define ICE_SID_RXPARSER_METADATA_INIT_ENTRY_SIZE	24
+#define ICE_SID_RXPARSER_CAM_ENTRY_SIZE
	16

drivers/net/ethernet/intel/ice/ice_parser.c line 12

Quoted 2 lines
drivers/net/ethernet/intel/ice/ice_parser.c +2 -0
+#define ICE_SID_RXPARSER_PG_SPILL_ENTRY_SIZE		17
+#define ICE_SID_RXPARSER_NOMATCH_CAM_ENTRY_SIZE
	12

drivers/net/ethernet/intel/ice/ice_parser.c void *ice_parser_sect_item_get(u32 sect_type,

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_parser.c +1 -0
+#define ICE_SID_RXPARSER_NOMATCH_SPILL_ENTRY_SIZE	13
 
  /**
   * ice_parser_sect_item_get - parse a item from a section
@@ -32,6 +36,18 @@ void *ice_parser_sect_item_get(u32 sect_type,

void *section,

drivers/net/ethernet/intel/ice/ice_parser.c int ice_parser_create(struct ice_hw *hw,

Quoted 19 lines
drivers/net/ethernet/intel/ice/ice_parser.c +12 -0
  	case ICE_SID_RXPARSER_METADATA_INIT:
  		size = ICE_SID_RXPARSER_METADATA_INIT_ENTRY_SIZE;
  		break;
+	case ICE_SID_RXPARSER_CAM:
+		size = ICE_SID_RXPARSER_CAM_ENTRY_SIZE;
+		break;
+	case ICE_SID_RXPARSER_PG_SPILL:
+		size = ICE_SID_RXPARSER_PG_SPILL_ENTRY_SIZE;
+		break;
+	case ICE_SID_RXPARSER_NOMATCH_CAM:
+		size = ICE_SID_RXPARSER_NOMATCH_CAM_ENTRY_SIZE;
+		break;
+	case ICE_SID_RXPARSER_NOMATCH_SPILL:
+		size = ICE_SID_RXPARSER_NOMATCH_SPILL_ENTRY_SIZE;
+		break;
  	default:
  		return NULL;
  	}
@@ -127,6 +143,30 @@ int ice_parser_create(struct ice_hw *hw,

struct ice_parser **psr)

Quoted 42 lines
drivers/net/ethernet/intel/ice/ice_parser.c +28 -0
  		goto err;
  	}
 
+	p->pg_cam_table = ice_pg_cam_table_get(hw);
+	if (!p->pg_cam_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
+	p->pg_sp_cam_table = ice_pg_sp_cam_table_get(hw);
+	if (!p->pg_sp_cam_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
+	p->pg_nm_cam_table = ice_pg_nm_cam_table_get(hw);
+	if (!p->pg_nm_cam_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
+	p->pg_nm_sp_cam_table = ice_pg_nm_sp_cam_table_get(hw);
+	if (!p->pg_nm_sp_cam_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
  	*psr = p;
  	return 0;
  err:
@@ -142,6 +182,10 @@ void ice_parser_destroy(struct ice_parser *psr)
  {
  	devm_kfree(ice_hw_to_dev(psr->hw), psr->imem_table);
  	devm_kfree(ice_hw_to_dev(psr->hw), psr->mi_table);
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->pg_cam_table);
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->pg_sp_cam_table);
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->pg_nm_cam_table);
+	devm_kfree(ice_hw_to_dev(psr->hw), psr-
 pg_nm_sp_cam_table);
 
  	devm_kfree(ice_hw_to_dev(psr->hw), psr);

}

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_parser.h

Quoted 15 lines

index 8fcc10479260..1f699ef12387 100644

drivers/net/ethernet/intel/ice/ice_parser.h +4 -0
@@ -4,6 +4,10 @@
  #ifndef _ICE_PARSER_H_
  #define _ICE_PARSER_H_
 
+#include "ice_metainit.h"
+#include "ice_imem.h"
+#include "ice_pg_cam.h"
+
  struct ice_parser {
  	struct ice_hw *hw; /* pointer to the hardware structure */
 

drivers/net/ethernet/intel/ice/ice_parser.h struct ice_parser { · line 16

Quoted 2 lines
drivers/net/ethernet/intel/ice/ice_parser.h +0 -0
@@ -11,6 +15,14 @@ struct ice_parser {
  	struct ice_imem_item *imem_table;
  	/* load data from section ICE_SID_RXPARSER_METADATA_INIT

*/

drivers/net/ethernet/intel/ice/ice_parser.h struct ice_parser {

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_parser.h +5 -0
  	struct ice_metainit_item *mi_table;
+	/* load data from section ICE_SID_RXPARSER_CAM */
+	struct ice_pg_cam_item *pg_cam_table;
+	/* load data from section ICE_SID_RXPARSER_PG_SPILL */
+	struct ice_pg_cam_item *pg_sp_cam_table;
+	/* load data from section ICE_SID_RXPARSER_NOMATCH_CAM

*/

drivers/net/ethernet/intel/ice/ice_parser.h struct ice_parser { · line 24

Quoted 2 lines
drivers/net/ethernet/intel/ice/ice_parser.h +2 -0
+	struct ice_pg_nm_cam_item *pg_nm_cam_table;
+	/* load data from section ICE_SID_RXPARSER_NOMATCH_SPILL

*/

Review

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_parser.h +1 -0
+	struct ice_pg_nm_cam_item *pg_nm_sp_cam_table;
  };
 
  int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_pg_cam.c

drivers/net/ethernet/intel/ice/ice_pg_cam.c line 7

Quoted 12 lines

new file mode 100644
index 000000000000..25b837ba684c

drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +7 -0
@@ -0,0 +1,300 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#include "ice_common.h"
+#include "ice_parser_util.h"
+
+static void _pg_cam_key_dump(struct ice_hw *hw, struct

ice_pg_cam_key *key)

Quoted 49 lines
drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +9 -0
+{
+	dev_info(ice_hw_to_dev(hw), "key:\n");
+	dev_info(ice_hw_to_dev(hw), "\tvalid = %d\n", key->valid);
+	dev_info(ice_hw_to_dev(hw), "\tnode_id = %d\n", key->node_id);
+	dev_info(ice_hw_to_dev(hw), "\tflag0 = %d\n", key->flag0);
+	dev_info(ice_hw_to_dev(hw), "\tflag1 = %d\n", key->flag1);
+	dev_info(ice_hw_to_dev(hw), "\tflag2 = %d\n", key->flag2);
+	dev_info(ice_hw_to_dev(hw), "\tflag3 = %d\n", key->flag3);
+	dev_info(ice_hw_to_dev(hw), "\tboost_idx = %d\n", key-

boost_idx);

drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\talu_reg = 0x%04x\n", key-

alu_reg);

drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +15 -0
+	dev_info(ice_hw_to_dev(hw), "\tnext_proto = 0x%08x\n",
+		 key->next_proto);
+}
+
+static void _pg_nm_cam_key_dump(struct ice_hw *hw,
+				struct ice_pg_nm_cam_key *key)
+{
+	dev_info(ice_hw_to_dev(hw), "key:\n");
+	dev_info(ice_hw_to_dev(hw), "\tvalid = %d\n", key->valid);
+	dev_info(ice_hw_to_dev(hw), "\tnode_id = %d\n", key->node_id);
+	dev_info(ice_hw_to_dev(hw), "\tflag0 = %d\n", key->flag0);
+	dev_info(ice_hw_to_dev(hw), "\tflag1 = %d\n", key->flag1);
+	dev_info(ice_hw_to_dev(hw), "\tflag2 = %d\n", key->flag2);
+	dev_info(ice_hw_to_dev(hw), "\tflag3 = %d\n", key->flag3);
+	dev_info(ice_hw_to_dev(hw), "\tboost_idx = %d\n", key-

boost_idx);

drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\talu_reg = 0x%04x\n", key-

alu_reg);

drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +7 -0
+}
+
+static void _pg_cam_action_dump(struct ice_hw *hw,
+				struct ice_pg_cam_action *action)
+{
+	dev_info(ice_hw_to_dev(hw), "action:\n");
+	dev_info(ice_hw_to_dev(hw), "\tnext_node = %d\n", action-

next_node);

drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tnext_pc = %d\n", action-

next_pc);

drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +2 -0
+	dev_info(ice_hw_to_dev(hw), "\tis_pg = %d\n", action->is_pg);
+	dev_info(ice_hw_to_dev(hw), "\tproto_id = %d\n", action-

proto_id);

drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +2 -0
+	dev_info(ice_hw_to_dev(hw), "\tis_mg = %d\n", action->is_mg);
+	dev_info(ice_hw_to_dev(hw), "\tmarker_id = %d\n", action-

marker_id);

drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +3 -0
+	dev_info(ice_hw_to_dev(hw), "\tis_last_round = %d\n",
+		 action->is_last_round);
+	dev_info(ice_hw_to_dev(hw), "\tho_polarity = %d\n",

drivers/net/ethernet/intel/ice/ice_pg_cam.c

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +10 -0
+		 action->ho_polarity);
+	dev_info(ice_hw_to_dev(hw), "\tho_inc = %d\n", action->ho_inc);
+}
+
+/**
+ * ice_pg_cam_dump - dump an parse graph cam info
+ * @hw: pointer to the hardware structure
+ * @item: parse graph cam to dump
+ */
+void ice_pg_cam_dump(struct ice_hw *hw, struct ice_pg_cam_item

*item)

drivers/net/ethernet/intel/ice/ice_pg_cam.c

Quoted 12 lines
drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +12 -0
+{
+	dev_info(ice_hw_to_dev(hw), "index = %d\n", item->idx);
+	_pg_cam_key_dump(hw, &item->key);
+	_pg_cam_action_dump(hw, &item->action);
+}
+
+/**
+ * ice_pg_nm_cam_dump - dump an parse graph no match cam info
+ * @hw: pointer to the hardware structure
+ * @item: parse graph no match cam to dump
+ */
+void ice_pg_nm_cam_dump(struct ice_hw *hw, struct

ice_pg_nm_cam_item *item)

drivers/net/ethernet/intel/ice/ice_pg_cam.c

Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +7 -0
+{
+	dev_info(ice_hw_to_dev(hw), "index = %d\n", item->idx);
+	_pg_nm_cam_key_dump(hw, &item->key);
+	_pg_cam_action_dump(hw, &item->action);
+}
+
+/** The function parses a 55 bits Parse Graph CAM Action with below

format:

Quoted 11 lines
+ *  BIT 0-11:	Next Node ID (action->next_node)
+ *  BIT 12-19:	Next PC (action->next_pc)
+ *  BIT 20:	Is Protocol Group (action->is_pg)
+ *  BIT 21-23:	reserved
+ *  BIT 24-31:	Protocol ID (action->proto_id)
+ *  BIT 32:	Is Marker Group (action->is_mg)
+ *  BIT 33-40:	Marker ID (action->marker_id)
+ *  BIT 41:	Is Last Round (action->is_last_round)
+ *  BIT 42:	Header Offset Polarity (action->ho_poloarity)
+ *  BIT 43-51:	Header Offset Inc (action->ho_inc)
+ *  BIT 52-54:	reserved
Quoted 2 lines

+ */
+static void _pg_cam_action_init(struct ice_pg_cam_action *action,

u64 data)

Quoted 14 lines

drivers/net/ethernet/intel/ice/ice_pg_cam.c line 101

Quoted 11 lines
drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +11 -0
+{
+	action->next_node = (u16)(data & 0x7ff);
+	action->next_pc = (u8)((data >> 11) & 0xff);
+	action->is_pg = ((data >> 19) & 0x1) != 0;
+	action->proto_id = ((data >> 23) & 0xff);
+	action->is_mg = ((data >> 31) & 0x1) != 0;
+	action->marker_id = ((data >> 32) & 0xff);
+	action->is_last_round = ((data >> 40) & 0x1) != 0;
+	action->ho_polarity = ((data >> 41) & 0x1) != 0;
+	action->ho_inc = ((data >> 42) & 0x1ff);
+}

As in my previous emails... such blocks with hardcoded values are unacceptable.

Sure, make sense! Will update in the coming version. Thanks!

Quoted 16 lines

drivers/net/ethernet/intel/ice/ice_pg_cam.c

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +2 -0
+
+/** The function parses a 41 bits Parse Graph NoMatch CAM Key with

below format:

Quoted 11 lines
+ *  BIT 0:	Valid (key->valid)
+ *  BIT 1-11:	Node ID (key->node_id)
+ *  BIT 12:	Flag 0 (key->flag0)
+ *  BIT 13:	Flag 1 (key->flag1)
+ *  BIT 14:	Flag 2 (key->flag2)
+ *  BIT 15:	Flag 3 (key->flag3)
+ *  BIT 16:	Boost Hit (key->boost_idx to 0 if it is 0)
+ *  BIT 17-24:	Boost Index (key->boost_idx only if Boost Hit is not 0)
+ *  BIT 25-40:	ALU Reg (key->alu_reg)

+ */
+static void _pg_nm_cam_key_init(struct ice_pg_nm_cam_key *key,

u64 data)

Quoted 16 lines

drivers/net/ethernet/intel/ice/ice_pg_cam.c line 127

Quoted 13 lines
drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +13 -0
+{
+	key->valid = (data & 0x1) != 0;
+	key->node_id = (u16)((data >> 1) & 0x7ff);
+	key->flag0 = ((data >> 12) & 0x1) != 0;
+	key->flag1 = ((data >> 13) & 0x1) != 0;
+	key->flag2 = ((data >> 14) & 0x1) != 0;
+	key->flag3 = ((data >> 15) & 0x1) != 0;
+	if ((data >> 16) & 0x1)
+		key->boost_idx = (u8)((data >> 17) & 0xff);
+	else
+		key->boost_idx = 0;
+	key->alu_reg = (u16)((data >> 25) & 0xffff);
+}

Here the same but also flag0..3? Could it be possible to use more descriptive names or in multi-purpose case union of bools?

Same here, there is no more meaningful description in the spec. But we will try if we can add some doc here. Thanks!

Quoted 253 lines

drivers/net/ethernet/intel/ice/ice_pg_cam.c

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +2 -0
+
+/** The function parses a 73 bits Parse Graph CAM Key with below

format:

Quoted 22 lines
+ *  BIT 0:	Valid (key->valid)
+ *  BIT 1-11:	Node ID (key->node_id)
+ *  BIT 12:	Flag 0 (key->flag0)
+ *  BIT 13:	Flag 1 (key->flag1)
+ *  BIT 14:	Flag 2 (key->flag2)
+ *  BIT 15:	Flag 3 (key->flag3)
+ *  BIT 16:	Boost Hit (key->boost_idx to 0 if it is 0)
+ *  BIT 17-24:	Boost Index (key->boost_idx only if Boost Hit is not 0)
+ *  BIT 25-40:	ALU Reg (key->alu_reg)
+ *  BIT 41-72:	Next Proto Key (key->next_proto)

+ */

drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +11 -0
+static void _pg_cam_key_init(struct ice_pg_cam_key *key, u8 *data)
+{
+	u64 d64 = *(u64 *)data;
+
+	key->valid = (d64 & 0x1) != 0;
+	key->node_id = (u16)((d64 >> 1) & 0x7ff);
+	key->flag0 = ((d64 >> 12) & 0x1) != 0;
+	key->flag1 = ((d64 >> 13) & 0x1) != 0;
+	key->flag2 = ((d64 >> 14) & 0x1) != 0;
+	key->flag3 = ((d64 >> 15) & 0x1) != 0;
+	if ((d64 >> 16) & 0x1)

drivers/net/ethernet/intel/ice/ice_pg_cam.c

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +10 -0
+		key->boost_idx = (u8)((d64 >> 17) & 0xff);
+	else
+		key->boost_idx = 0;
+	key->alu_reg = (u16)((d64 >> 25) & 0xffff);
+
+	key->next_proto = (*(u32 *)&data[5] >> 1);
+	key->next_proto |= ((u32)(data[9] & 0x1) << 31);
+}
+
+/** The function parses a 128 bits Parse Graph CAM Entry with below

format:

Quoted 4 lines

+ * BIT 0-72: Key (ci->key)
+ * BIT 73-127: Action (ci->action)
+ */
+static void _pg_cam_parse_item(struct ice_hw *hw, u16 idx, void

*item,

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +6 -0
+			       void *data, int size)
+{
+	struct ice_pg_cam_item *ci = item;
+	u8 *buf = data;
+	u64 d64;
+

drivers/net/ethernet/intel/ice/ice_pg_cam.c

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +10 -0
+	ci->idx = idx;
+	d64 = (*(u64 *)&buf[9] >> 1);
+	_pg_cam_key_init(&ci->key, buf);
+	_pg_cam_action_init(&ci->action, d64);
+
+	if (hw->debug_mask & ICE_DBG_PARSER)
+		ice_pg_cam_dump(hw, ci);
+}
+
+/** The function parses a 136 bits Parse Graph Spill CAM Entry with

below

Quoted 5 lines
+ *  format:
+ *  BIT 0-55:	Action (ci->key)
+ *  BIT 56-135:	Key (ci->action)

+ */
+static void _pg_sp_cam_parse_item(struct ice_hw *hw, u16 idx, void

*item,

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +6 -0
+				  void *data, int size)
+{
+	struct ice_pg_cam_item *ci = item;
+	u8 *buf = data;
+	u64 d64;
+

drivers/net/ethernet/intel/ice/ice_pg_cam.c

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +10 -0
+	ci->idx = idx;
+	d64 = *(u64 *)buf;
+	_pg_cam_action_init(&ci->action, d64);
+	_pg_cam_key_init(&ci->key, &buf[7]);
+
+	if (hw->debug_mask & ICE_DBG_PARSER)
+		ice_pg_cam_dump(hw, ci);
+}
+
+/** The function parses a 96 bits Parse Graph NoMatch CAM Entry

with below

Quoted 5 lines
+ *  format:
+ *  BIT 0-40:	Key (ci->key)
+ *  BIT 41-95:	Action (ci->action)

+ */
+static void _pg_nm_cam_parse_item(struct ice_hw *hw, u16 idx, void

*item,

Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +7 -0
+				  void *data, int size)
+{
+	struct ice_pg_nm_cam_item *ci = item;
+	u8 *buf = data;
+	u64 d64;
+
+	ci->idx = idx;

drivers/net/ethernet/intel/ice/ice_pg_cam.c

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +10 -0
+	d64 = *(u64 *)buf;
+	_pg_nm_cam_key_init(&ci->key, d64);
+	d64 = (*(u64 *)&buf[5] >> 1);
+	_pg_cam_action_init(&ci->action, d64);
+
+	if (hw->debug_mask & ICE_DBG_PARSER)
+		ice_pg_nm_cam_dump(hw, ci);
+}
+
+/** The function parses a 104 bits Parse Graph NoMatch Spill CAM

Entry with

Quoted 5 lines
+ *  below format:
+ *  BIT 0-55:	Key (ci->key)
+ *  BIT 56-103:	Action (ci->action)

+ */
+static void _pg_nm_sp_cam_parse_item(struct ice_hw *hw, u16 idx,

void *item,

Quoted 25 lines
drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +25 -0
+				     void *data, int size)
+{
+	struct ice_pg_nm_cam_item *ci = item;
+	u8 *buf = data;
+	u64 d64;
+
+	ci->idx = idx;
+	d64 = *(u64 *)buf;
+	_pg_cam_action_init(&ci->action, d64);
+	d64 = *(u64 *)&buf[7];
+	_pg_nm_cam_key_init(&ci->key, d64);
+
+	if (hw->debug_mask & ICE_DBG_PARSER)
+		ice_pg_nm_cam_dump(hw, ci);
+}
+
+/**
+ * ice_pg_cam_table_get - create a parse graph cam table
+ * @hw: pointer to the hardware structure
+ */
+struct ice_pg_cam_item *ice_pg_cam_table_get(struct ice_hw *hw)
+{
+	return (struct ice_pg_cam_item *)
+		ice_parser_create_table(hw, ICE_SID_RXPARSER_CAM,
+					sizeof(struct ice_pg_cam_item),

drivers/net/ethernet/intel/ice/ice_pg_cam.c

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +10 -0
+					ICE_PG_CAM_TABLE_SIZE,
+					ice_parser_sect_item_get,
+					_pg_cam_parse_item);
+}
+
+/**
+ * ice_pg_sp_cam_table_get - create a parse graph spill cam table
+ * @hw: pointer to the hardware structure
+ */
+struct ice_pg_cam_item *ice_pg_sp_cam_table_get(struct ice_hw

*hw)

drivers/net/ethernet/intel/ice/ice_pg_cam.c

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +3 -0
+{
+	return (struct ice_pg_cam_item *)
+		ice_parser_create_table(hw,

ICE_SID_RXPARSER_PG_SPILL,

drivers/net/ethernet/intel/ice/ice_pg_cam.c

Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +8 -0
+					sizeof(struct ice_pg_cam_item),
+					ICE_PG_SP_CAM_TABLE_SIZE,
+					ice_parser_sect_item_get,
+					_pg_sp_cam_parse_item);
+}
+
+/**
+ * ice_pg_nm_cam_table_get - create a parse graph no match cam

table

Quoted 3 lines

+ * @hw: pointer to the hardware structure
+ */
+struct ice_pg_nm_cam_item *ice_pg_nm_cam_table_get(struct

ice_hw *hw)

drivers/net/ethernet/intel/ice/ice_pg_cam.c

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +3 -0
+{
+	return (struct ice_pg_nm_cam_item *)
+		ice_parser_create_table(hw,

ICE_SID_RXPARSER_NOMATCH_CAM,

drivers/net/ethernet/intel/ice/ice_pg_cam.c

Quoted 1 line
drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +1 -0
+					sizeof(struct

ice_pg_nm_cam_item),

drivers/net/ethernet/intel/ice/ice_pg_cam.c

Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +7 -0
+					ICE_PG_NM_CAM_TABLE_SIZE,
+					ice_parser_sect_item_get,
+					_pg_nm_cam_parse_item);
+}
+
+/**
+ * ice_pg_nm_sp_cam_table_get - create a parse graph no match spill

cam table

Quoted 3 lines

+ * @hw: pointer to the hardware structure
+ */
+struct ice_pg_nm_cam_item *ice_pg_nm_sp_cam_table_get(struct

ice_hw *hw)

drivers/net/ethernet/intel/ice/ice_pg_cam.c

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +3 -0
+{
+	return (struct ice_pg_nm_cam_item *)
+		ice_parser_create_table(hw,

ICE_SID_RXPARSER_NOMATCH_SPILL,

drivers/net/ethernet/intel/ice/ice_pg_cam.c

Quoted 1 line
drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +1 -0
+					sizeof(struct

ice_pg_nm_cam_item),

Quoted 1 line

+

ICE_PG_NM_SP_CAM_TABLE_SIZE,

Review

Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +3 -0
+					ice_parser_sect_item_get,
+					_pg_nm_sp_cam_parse_item);
+}
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_pg_cam.h

Quoted 57 lines

new file mode 100644
index 000000000000..1d794fa519d6

drivers/net/ethernet/intel/ice/ice_pg_cam.h new file +52 -0
@@ -0,0 +1,67 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#ifndef _ICE_PG_CAM_H_
+#define _ICE_PG_CAM_H_
+
+#define ICE_PG_CAM_TABLE_SIZE		2048
+#define ICE_PG_SP_CAM_TABLE_SIZE	128
+#define ICE_PG_NM_CAM_TABLE_SIZE	1024
+#define ICE_PG_NM_SP_CAM_TABLE_SIZE	64
+
+struct ice_pg_cam_key {
+	bool valid;
+	u16 node_id;
+	bool flag0;
+	bool flag1;
+	bool flag2;
+	bool flag3;
+	u8 boost_idx;
+	u16 alu_reg;
+	u32 next_proto;
+};
+
+struct ice_pg_nm_cam_key {
+	bool valid;
+	u16 node_id;
+	bool flag0;
+	bool flag1;
+	bool flag2;
+	bool flag3;
+	u8 boost_idx;
+	u16 alu_reg;
+};
+
+struct ice_pg_cam_action {
+	u16 next_node;
+	u8 next_pc;
+	bool is_pg;
+	u8 proto_id;
+	bool is_mg;
+	u8 marker_id;
+	bool is_last_round;
+	bool ho_polarity;
+	u16 ho_inc;
+};
+
+struct ice_pg_cam_item {
+	u16 idx;
+	struct ice_pg_cam_key key;
+	struct ice_pg_cam_action action;
+};
+
Quoted 8 lines

drivers/net/ethernet/intel/ice/ice_pg_cam.h line 57

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_pg_cam.h new file +5 -0
+struct ice_pg_nm_cam_item {
+	u16 idx;
+	struct ice_pg_nm_cam_key key;
+	struct ice_pg_cam_action action;
+};

Some comment with documentation of the fields in the all structs above would be fine.

Same here, there is no more meaningful description in the spec. But we will try if we can add some doc here. Thanks!

Quoted 10 lines

drivers/net/ethernet/intel/ice/ice_pg_cam.h line 59

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_pg_cam.h new file +2 -0
+
+void ice_pg_cam_dump(struct ice_hw *hw, struct ice_pg_cam_item

*item);

drivers/net/ethernet/intel/ice/ice_pg_cam.h line 60

Quoted 1 line
drivers/net/ethernet/intel/ice/ice_pg_cam.h new file +1 -0
+void ice_pg_nm_cam_dump(struct ice_hw *hw, struct

ice_pg_nm_cam_item *item);

drivers/net/ethernet/intel/ice/ice_pg_cam.h

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_pg_cam.h new file +3 -0
+
+struct ice_pg_cam_item *ice_pg_cam_table_get(struct ice_hw *hw);
+struct ice_pg_cam_item *ice_pg_sp_cam_table_get(struct ice_hw

*hw);

Quoted 6 lines

drivers/net/ethernet/intel/ice/ice_pg_cam.h line 65

Quoted 2 lines
drivers/net/ethernet/intel/ice/ice_pg_cam.h new file +2 -0
+
+struct ice_pg_nm_cam_item *ice_pg_nm_cam_table_get(struct

ice_hw *hw);

drivers/net/ethernet/intel/ice/ice_pg_cam.h line 66

Quoted 1 line
drivers/net/ethernet/intel/ice/ice_pg_cam.h new file +1 -0
+struct ice_pg_nm_cam_item *ice_pg_nm_sp_cam_table_get(struct

ice_hw *hw);

Quoted 1 line
drivers/net/ethernet/intel/ice/ice_pg_cam.h new file +1 -0
+#endif /* _ICE_PG_CAM_H_ */

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#15 lore raw

PATCH v2 5/15 ice: init boost tcam table for parser

In reply to Junfeng Guo

Parse DDP section ICE_SID_RXPARSER_CAM into an array of ice_bst_tcam_item.
Parse DDP section ICE_SID_LBL_RXPARSER_TMEM into an array of ice_lbl_item.

---
 drivers/net/ethernet/intel/ice/ice_bst_tcam.c | 247 ++++++++++++++++++
 drivers/net/ethernet/intel/ice/ice_bst_tcam.h |  27 ++
 drivers/net/ethernet/intel/ice/ice_imem.c     |   2 +-
 drivers/net/ethernet/intel/ice/ice_metainit.c |   2 +-
 drivers/net/ethernet/intel/ice/ice_parser.c   |  47 +++-
 drivers/net/ethernet/intel/ice/ice_parser.h   |   5 +
 .../net/ethernet/intel/ice/ice_parser_util.h  |  12 +-
 drivers/net/ethernet/intel/ice/ice_pg_cam.c   |   8 +-
 8 files changed, 341 insertions(+), 9 deletions(-)
 create mode 100644 drivers/net/ethernet/intel/ice/ice_bst_tcam.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_bst_tcam.h
drivers/net/ethernet/intel/ice/ice_bst_tcam.c new file +247 -0
new file mode 100644
index 000000000000..24e793580637
@@ -0,0 +1,247 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#include "ice_common.h"
+#include "ice_parser_util.h"
+
+#define ICE_BST_TCAM_TABLE_SIZE 256
+
+static void _bst_np_kb_dump(struct ice_hw *hw, struct ice_np_keybuilder *kb)
+{
+	dev_info(ice_hw_to_dev(hw), "next proto key builder:\n");
+	dev_info(ice_hw_to_dev(hw), "\tops = %d\n", kb->ops);
+	dev_info(ice_hw_to_dev(hw), "\tstart_or_reg0 = %d\n",
+		 kb->start_or_reg0);
+	dev_info(ice_hw_to_dev(hw), "\tlen_or_reg1 = %d\n", kb->len_or_reg1);
+}
+
+static void _bst_pg_kb_dump(struct ice_hw *hw, struct ice_pg_keybuilder *kb)
+{
+	dev_info(ice_hw_to_dev(hw), "parse graph key builder:\n");
+	dev_info(ice_hw_to_dev(hw), "\tflag0_ena = %d\n", kb->flag0_ena);
+	dev_info(ice_hw_to_dev(hw), "\tflag1_ena = %d\n", kb->flag1_ena);
+	dev_info(ice_hw_to_dev(hw), "\tflag2_ena = %d\n", kb->flag2_ena);
+	dev_info(ice_hw_to_dev(hw), "\tflag3_ena = %d\n", kb->flag3_ena);
+	dev_info(ice_hw_to_dev(hw), "\tflag0_idx = %d\n", kb->flag0_idx);
+	dev_info(ice_hw_to_dev(hw), "\tflag1_idx = %d\n", kb->flag1_idx);
+	dev_info(ice_hw_to_dev(hw), "\tflag2_idx = %d\n", kb->flag2_idx);
+	dev_info(ice_hw_to_dev(hw), "\tflag3_idx = %d\n", kb->flag3_idx);
+	dev_info(ice_hw_to_dev(hw), "\talu_reg_idx = %d\n", kb->alu_reg_idx);
+}
+
+static void _bst_alu_dump(struct ice_hw *hw, struct ice_alu *alu, int index)
+{
+	dev_info(ice_hw_to_dev(hw), "alu%d:\n", index);
+	dev_info(ice_hw_to_dev(hw), "\topc = %d\n", alu->opc);
+	dev_info(ice_hw_to_dev(hw), "\tsrc_start = %d\n", alu->src_start);
+	dev_info(ice_hw_to_dev(hw), "\tsrc_len = %d\n", alu->src_len);
+	dev_info(ice_hw_to_dev(hw), "\tshift_xlate_select = %d\n",
+		 alu->shift_xlate_select);
+	dev_info(ice_hw_to_dev(hw), "\tshift_xlate_key = %d\n",
+		 alu->shift_xlate_key);
+	dev_info(ice_hw_to_dev(hw), "\tsrc_reg_id = %d\n", alu->src_reg_id);
+	dev_info(ice_hw_to_dev(hw), "\tdst_reg_id = %d\n", alu->dst_reg_id);
+	dev_info(ice_hw_to_dev(hw), "\tinc0 = %d\n", alu->inc0);
+	dev_info(ice_hw_to_dev(hw), "\tinc1 = %d\n", alu->inc1);
+	dev_info(ice_hw_to_dev(hw), "\tproto_offset_opc = %d\n",
+		 alu->proto_offset_opc);
+	dev_info(ice_hw_to_dev(hw), "\tproto_offset = %d\n",
+		 alu->proto_offset);
+	dev_info(ice_hw_to_dev(hw), "\tbranch_addr = %d\n", alu->branch_addr);
+	dev_info(ice_hw_to_dev(hw), "\timm = %d\n", alu->imm);
+	dev_info(ice_hw_to_dev(hw), "\tdst_start = %d\n", alu->dst_start);
+	dev_info(ice_hw_to_dev(hw), "\tdst_len = %d\n", alu->dst_len);
+	dev_info(ice_hw_to_dev(hw), "\tflags_extr_imm = %d\n",
+		 alu->flags_extr_imm);
+	dev_info(ice_hw_to_dev(hw), "\tflags_start_imm= %d\n",
+		 alu->flags_start_imm);
+}
+
+/**
+ * ice_bst_tcam_dump - dump a boost tcam info
+ * @hw: pointer to the hardware structure
+ * @item: boost tcam to dump
+ */
+void ice_bst_tcam_dump(struct ice_hw *hw, struct ice_bst_tcam_item *item)
+{
+	int i;
+
+	dev_info(ice_hw_to_dev(hw), "address = %d\n", item->address);
+	dev_info(ice_hw_to_dev(hw), "key    :");
+	for (i = 0; i < 20; i++)
+		dev_info(ice_hw_to_dev(hw), "%02x ", item->key[i]);
+	dev_info(ice_hw_to_dev(hw), "\n");
+	dev_info(ice_hw_to_dev(hw), "key_inv:");
+	for (i = 0; i < 20; i++)
+		dev_info(ice_hw_to_dev(hw), "%02x ", item->key_inv[i]);
+	dev_info(ice_hw_to_dev(hw), "\n");
+	dev_info(ice_hw_to_dev(hw), "hit_idx_grp = %d\n", item->hit_idx_grp);
+	dev_info(ice_hw_to_dev(hw), "pg_pri = %d\n", item->pg_pri);
+	_bst_np_kb_dump(hw, &item->np_kb);
+	_bst_pg_kb_dump(hw, &item->pg_kb);
+	_bst_alu_dump(hw, &item->alu0, 0);
+	_bst_alu_dump(hw, &item->alu1, 1);
+	_bst_alu_dump(hw, &item->alu2, 2);
+}
+
+/** The function parses a 96 bits ALU entry with below format:
+ *  BIT 0-5:	Opcode (alu->opc)
+ *  BIT 6-13:	Source Start (alu->src_start)
+ *  BIT 14-18:	Source Length (alu->src_len)
+ *  BIT 19:	Shift/Xlate Select (alu->shift_xlate_select)
+ *  BIT 20-23:	Shift/Xlate Key (alu->shift_xlate_key)
+ *  BIT 24-30:	Source Register ID (alu->src_reg_id)
+ *  BIT 31-37:	Dest. Register ID (alu->dst_reg_id)
+ *  BIT 38:	Inc0 (alu->inc0)
+ *  BIT 39:	Inc1:(alu->inc1)
+ *  BIT 40:41	Protocol Offset Opcode (alu->proto_offset_opc)
+ *  BIT 42:49	Protocol Offset (alu->proto_offset)
+ *  BIT 50:57	Branch Address (alu->branch_addr)
+ *  BIT 58:73	Immediate (alu->imm)
+ *  BIT 74	Dedicated Flags Enable (alu->dedicate_flags_ena)
+ *  BIT 75:80	Dest. Start (alu->dst_start)
+ *  BIT 81:86	Dest. Length (alu->dst_len)
+ *  BIT 87	Flags Extract Imm. (alu->flags_extr_imm)
+ *  BIT 88:95	Flags Start/Immediate (alu->flags_start_imm)
+ *
+ *  NOTE: the first 7 bits are skipped as the start bit is not
+ *  byte aligned.
+ */
+static void _bst_alu_init(struct ice_alu *alu, u8 *data)
+{
+	u64 d64 = *(u64 *)data >> 7;
+
+	alu->opc = (enum ice_alu_opcode)(d64 & 0x3f);
+	alu->src_start = (u8)((d64 >> 6) & 0xff);
+	alu->src_len = (u8)((d64 >> 14) & 0x1f);
+	alu->shift_xlate_select = ((d64 >> 19) & 0x1) != 0;
+	alu->shift_xlate_key = (u8)((d64 >> 20) & 0xf);
+	alu->src_reg_id = (u8)((d64 >> 24) & 0x7f);
+	alu->dst_reg_id = (u8)((d64 >> 31) & 0x7f);
+	alu->inc0 = ((d64 >> 38) & 0x1) != 0;
+	alu->inc1 = ((d64 >> 39) & 0x1) != 0;
+	alu->proto_offset_opc = (u8)((d64 >> 40) & 0x3);
+	alu->proto_offset = (u8)((d64 >> 42) & 0xff);
+
+	d64 = *(u64 *)(&data[6]) >> 9;
+
+	alu->branch_addr = (u8)(d64 & 0xff);
+	alu->imm = (u16)((d64 >> 8) & 0xffff);
+	alu->dedicate_flags_ena = ((d64 >> 24) & 0x1) != 0;
+	alu->dst_start = (u8)((d64 >> 25) & 0x3f);
+	alu->dst_len = (u8)((d64 >> 31) & 0x3f);
+	alu->flags_extr_imm = ((d64 >> 37) & 0x1) != 0;
+	alu->flags_start_imm = (u8)((d64 >> 38) & 0xff);
+}
+
+/** The function parses a 35 bits Parse Graph Key Build with below format:
+ *  BIT 0:	Flag 0 Enable (kb->flag0_ena)
+ *  BIT 1-6:	Flag 0 Index (kb->flag0_idx)
+ *  BIT 7:	Flag 1 Enable (kb->flag1_ena)
+ *  BIT 8-13:	Flag 1 Index (kb->flag1_idx)
+ *  BIT 14:	Flag 2 Enable (kb->flag2_ena)
+ *  BIT 15-20:	Flag 2 Index (kb->flag2_idx)
+ *  BIT 21:	Flag 3 Enable (kb->flag3_ena)
+ *  BIT 22-27:	Flag 3 Index (kb->flag3_idx)
+ *  BIT 28-34:	ALU Register Index (kb->alu_reg_idx)
+ */
+static void _bst_pgkb_init(struct ice_pg_keybuilder *kb, u64 data)
+{
+	kb->flag0_ena = (data & 0x1) != 0;
+	kb->flag0_idx = (u8)((data >> 1) & 0x3f);
+	kb->flag1_ena = ((data >> 7) & 0x1) != 0;
+	kb->flag1_idx = (u8)((data >> 8) & 0x3f);
+	kb->flag2_ena = ((data >> 14) & 0x1) != 0;
+	kb->flag2_idx = (u8)((data >> 15) & 0x3f);
+	kb->flag3_ena = ((data >> 21) & 0x1) != 0;
+	kb->flag3_idx = (u8)((data >> 22) & 0x3f);
+	kb->alu_reg_idx = (u8)((data >> 28) & 0x7f);
+}
+
+/** The function parses a 18 bits Next Protocol Key Build with below format:
+ *  BIT 0-1:	Opcode kb->ops
+ *  BIT 2-9:	Start / Reg 0 (kb->start_or_reg0)
+ *  BIT 10-17:	Length / Reg 1 (kb->len_or_reg1)
+ */
+static void _bst_npkb_init(struct ice_np_keybuilder *kb, u32 data)
+{
+	kb->ops = (u8)(data & 0x3);
+	kb->start_or_reg0 = (u8)((data >> 2) & 0xff);
+	kb->len_or_reg1 = (u8)((data >> 10) & 0xff);
+}
+
+/** The function parses a 704 bits Boost TCAM entry with below format:
+ *  BIT 0-15:	Address (ti->address)
+ *  BIT 16-31:	reserved
+ *  BIT 32-191: Key (ti->key)
+ *  BIT 192-351:Key Invert (ti->key_inv)
+ *  BIT 352-359:Boost Hit Index Group (ti->hit_idx_grp)
+ *  BIT 360-361:PG Priority (ti->pg_pri)
+ *  BIT 362-379:Next Proto Key Build (ti->np_kb)
+ *  BIT 380-414:PG Key Build (ti->pg_kb)
+ *  BIT 415-510:ALU 0 (ti->alu0)
+ *  BIT 511-606:ALU 1 (ti->alu1)
+ *  BIT 607-702:ALU 2 (ti->alu2)
+ *  BIT 703:	reserved
+ */
+static void _bst_parse_item(struct ice_hw *hw, u16 idx, void *item,
+			    void *data, int size)
+{
+	struct ice_bst_tcam_item *ti = item;
+	u8 *buf = data;
+	int i;
+
+	ti->address = *(u16 *)buf;
+
+	for (i = 0; i < 20; i++)
+		ti->key[i] = buf[4 + i];
+	for (i = 0; i < 20; i++)
+		ti->key_inv[i] = buf[24 + i];
+	ti->hit_idx_grp = buf[44];
+	ti->pg_pri = buf[45] & 0x3;
+	_bst_npkb_init(&ti->np_kb, *(u32 *)&buf[45] >> 2);
+	_bst_pgkb_init(&ti->pg_kb, *(u64 *)&buf[47] >> 4);
+	_bst_alu_init(&ti->alu0, &buf[51]);
+	_bst_alu_init(&ti->alu1, &buf[63]);
+	_bst_alu_init(&ti->alu2, &buf[75]);
+
+	if (hw->debug_mask & ICE_DBG_PARSER)
+		ice_bst_tcam_dump(hw, ti);
+}
+
+/**
+ * ice_bst_tcam_table_get - create a boost tcam table
+ * @hw: pointer to the hardware structure
+ */
+struct ice_bst_tcam_item *ice_bst_tcam_table_get(struct ice_hw *hw)
+{
+	return (struct ice_bst_tcam_item *)
+		ice_parser_create_table(hw, ICE_SID_RXPARSER_BOOST_TCAM,
+					sizeof(struct ice_bst_tcam_item),
+					ICE_BST_TCAM_TABLE_SIZE,
+					ice_parser_sect_item_get,
+					_bst_parse_item, true);
+}
+
+static void _parse_lbl_item(struct ice_hw *hw, u16 idx, void *item,
+			    void *data, int size)
+{
+	ice_parse_item_dflt(hw, idx, item, data, size);
+
+	if (hw->debug_mask & ICE_DBG_PARSER)
+		ice_lbl_dump(hw, (struct ice_lbl_item *)item);
+}
+
+/**
+ * ice_bst_lbl_table_get - create a boost label table
+ * @hw: pointer to the hardware structure
+ */
+struct ice_lbl_item *ice_bst_lbl_table_get(struct ice_hw *hw)
+{
+	return (struct ice_lbl_item *)
+		ice_parser_create_table(hw, ICE_SID_LBL_RXPARSER_TMEM,
+					sizeof(struct ice_lbl_item),
+					ICE_BST_TCAM_TABLE_SIZE,
+					ice_parser_sect_item_get,
+					_parse_lbl_item, true);
+}
drivers/net/ethernet/intel/ice/ice_bst_tcam.h new file +27 -0
new file mode 100644
index 000000000000..9d78a140bc02
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#ifndef _ICE_BST_TCAM_H_
+#define _ICE_BST_TCAM_H_
+
+#include "ice_imem.h"
+
+struct ice_bst_tcam_item {
+	u16 address;
+	u8 key[20];
+	u8 key_inv[20];
+	u8 hit_idx_grp;
+	u8 pg_pri;
+	struct ice_np_keybuilder np_kb;
+	struct ice_pg_keybuilder pg_kb;
+	struct ice_alu alu0;
+	struct ice_alu alu1;
+	struct ice_alu alu2;
+};
+
+void ice_bst_tcam_dump(struct ice_hw *hw, struct ice_bst_tcam_item *item);
+
+struct ice_bst_tcam_item *ice_bst_tcam_table_get(struct ice_hw *hw);
+
+struct ice_lbl_item *ice_bst_lbl_table_get(struct ice_hw *hw);
+#endif /*_ICE_BST_TCAM_H_ */
drivers/net/ethernet/intel/ice/ice_imem.c +1 -1
index 2bd48f080326..2ce186cbe4fd 100644
@@ -246,5 +246,5 @@ struct ice_imem_item *ice_imem_table_get(struct ice_hw *hw)
 					sizeof(struct ice_imem_item),
 					ICE_IMEM_TABLE_SIZE,
 					ice_parser_sect_item_get,
-					_imem_parse_item);
+					_imem_parse_item, false);
 }
drivers/net/ethernet/intel/ice/ice_metainit.c +1 -1
index 911099a38087..00fd86ce5fcf 100644
@@ -151,5 +151,5 @@ struct ice_metainit_item *ice_metainit_table_get(struct ice_hw *hw)
 					sizeof(struct ice_metainit_item),
 					ICE_METAINIT_TABLE_SIZE,
 					ice_parser_sect_item_get,
-					_metainit_parse_item);
+					_metainit_parse_item, false);
 }
drivers/net/ethernet/intel/ice/ice_parser.c +45 -2

89 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_parser.h +5 -0
index 1f699ef12387..af73b19d09c1 100644
@@ -7,6 +7,7 @@
 #include "ice_metainit.h"
 #include "ice_imem.h"
 #include "ice_pg_cam.h"
+#include "ice_bst_tcam.h"
 
 struct ice_parser {
 	struct ice_hw *hw; /* pointer to the hardware structure */
@@ -23,6 +24,10 @@ struct ice_parser {
 	struct ice_pg_nm_cam_item *pg_nm_cam_table;
 	/* load data from section ICE_SID_RXPARSER_NOMATCH_SPILL */
 	struct ice_pg_nm_cam_item *pg_nm_sp_cam_table;
+	/* load data from section ICE_SID_RXPARSER_BOOST_TCAM */
+	struct ice_bst_tcam_item *bst_tcam_table;
+	/* load data from section ICE_SID_LBL_RXPARSER_TMEM */
+	struct ice_lbl_item *bst_lbl_table;
 };
 
 int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
drivers/net/ethernet/intel/ice/ice_parser_util.h +11 -1
index 59c67f1a1951..2f93f93c1e10 100644
@@ -7,11 +7,20 @@
 #include "ice_imem.h"
 #include "ice_metainit.h"
 
+struct ice_lbl_item {
+	u16 idx;
+	char label[64];
+};
+
 struct ice_pkg_sect_hdr {
 	__le16 count;
 	__le16 offset;
 };
 
+void ice_lbl_dump(struct ice_hw *hw, struct ice_lbl_item *item);
+void ice_parse_item_dflt(struct ice_hw *hw, u16 idx, void *item,
+			 void *data, int size);
+
 void *ice_parser_sect_item_get(u32 sect_type, void *section,
 			       u32 index, u32 *offset);
 
@@ -21,5 +30,6 @@ void *ice_parser_create_table(struct ice_hw *hw, u32 sect_type,
 					       u32 index, u32 *offset),
 			      void (*parse_item)(struct ice_hw *hw, u16 idx,
 						 void *item, void *data,
-						 int size));
+						 int size),
+			      bool no_offset);
 #endif /* _ICE_PARSER_UTIL_H_ */
drivers/net/ethernet/intel/ice/ice_pg_cam.c +4 -4
index 25b837ba684c..1c9a9e906f3e 100644
@@ -254,7 +254,7 @@ struct ice_pg_cam_item *ice_pg_cam_table_get(struct ice_hw *hw)
 					sizeof(struct ice_pg_cam_item),
 					ICE_PG_CAM_TABLE_SIZE,
 					ice_parser_sect_item_get,
-					_pg_cam_parse_item);
+					_pg_cam_parse_item, false);
 }
 
 /**
@@ -268,7 +268,7 @@ struct ice_pg_cam_item *ice_pg_sp_cam_table_get(struct ice_hw *hw)
 					sizeof(struct ice_pg_cam_item),
 					ICE_PG_SP_CAM_TABLE_SIZE,
 					ice_parser_sect_item_get,
-					_pg_sp_cam_parse_item);
+					_pg_sp_cam_parse_item, false);
 }
 
 /**
@@ -282,7 +282,7 @@ struct ice_pg_nm_cam_item *ice_pg_nm_cam_table_get(struct ice_hw *hw)
 					sizeof(struct ice_pg_nm_cam_item),
 					ICE_PG_NM_CAM_TABLE_SIZE,
 					ice_parser_sect_item_get,
-					_pg_nm_cam_parse_item);
+					_pg_nm_cam_parse_item, false);
 }
 
 /**
@@ -296,5 +296,5 @@ struct ice_pg_nm_cam_item *ice_pg_nm_sp_cam_table_get(struct ice_hw *hw)
 					sizeof(struct ice_pg_nm_cam_item),
 					ICE_PG_NM_SP_CAM_TABLE_SIZE,
 					ice_parser_sect_item_get,
-					_pg_nm_sp_cam_parse_item);
+					_pg_nm_sp_cam_parse_item, false);
 }
Signature · 6 lines
2.25.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
#16 lore raw

Re: [Intel-wired-lan] [PATCH iwl-next v2 05/15] ice: init boost tcam table for parser

Like in my previous replies... Do not use hardcoded values for array indices, masks and shifts...

Quoted 515 lines · Junfeng Guo

Parse DDP section ICE_SID_RXPARSER_CAM into an array of ice_bst_tcam_item.
Parse DDP section ICE_SID_LBL_RXPARSER_TMEM into an array of ice_lbl_item.

---
  drivers/net/ethernet/intel/ice/ice_bst_tcam.c | 247 ++++++++++++++++++
  drivers/net/ethernet/intel/ice/ice_bst_tcam.h |  27 ++
  drivers/net/ethernet/intel/ice/ice_imem.c     |   2 +-
  drivers/net/ethernet/intel/ice/ice_metainit.c |   2 +-
  drivers/net/ethernet/intel/ice/ice_parser.c   |  47 +++-
  drivers/net/ethernet/intel/ice/ice_parser.h   |   5 +
  .../net/ethernet/intel/ice/ice_parser_util.h  |  12 +-
  drivers/net/ethernet/intel/ice/ice_pg_cam.c   |   8 +-
  8 files changed, 341 insertions(+), 9 deletions(-)

create mode 100644 drivers/net/ethernet/intel/ice/ice_bst_tcam.c create mode 100644 drivers/net/ethernet/intel/ice/ice_bst_tcam.h

drivers/net/ethernet/intel/ice/ice_bst_tcam.c new file +247 -0
new file mode 100644
index 000000000000..24e793580637
@@ -0,0 +1,247 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#include "ice_common.h"
+#include "ice_parser_util.h"
+
+#define ICE_BST_TCAM_TABLE_SIZE 256
+
+static void _bst_np_kb_dump(struct ice_hw *hw, struct ice_np_keybuilder *kb)
+{
+	dev_info(ice_hw_to_dev(hw), "next proto key builder:\n");
+	dev_info(ice_hw_to_dev(hw), "\tops = %d\n", kb->ops);
+	dev_info(ice_hw_to_dev(hw), "\tstart_or_reg0 = %d\n",
+		 kb->start_or_reg0);
+	dev_info(ice_hw_to_dev(hw), "\tlen_or_reg1 = %d\n", kb->len_or_reg1);
+}
+
+static void _bst_pg_kb_dump(struct ice_hw *hw, struct ice_pg_keybuilder *kb)
+{
+	dev_info(ice_hw_to_dev(hw), "parse graph key builder:\n");
+	dev_info(ice_hw_to_dev(hw), "\tflag0_ena = %d\n", kb->flag0_ena);
+	dev_info(ice_hw_to_dev(hw), "\tflag1_ena = %d\n", kb->flag1_ena);
+	dev_info(ice_hw_to_dev(hw), "\tflag2_ena = %d\n", kb->flag2_ena);
+	dev_info(ice_hw_to_dev(hw), "\tflag3_ena = %d\n", kb->flag3_ena);
+	dev_info(ice_hw_to_dev(hw), "\tflag0_idx = %d\n", kb->flag0_idx);
+	dev_info(ice_hw_to_dev(hw), "\tflag1_idx = %d\n", kb->flag1_idx);
+	dev_info(ice_hw_to_dev(hw), "\tflag2_idx = %d\n", kb->flag2_idx);
+	dev_info(ice_hw_to_dev(hw), "\tflag3_idx = %d\n", kb->flag3_idx);
+	dev_info(ice_hw_to_dev(hw), "\talu_reg_idx = %d\n", kb->alu_reg_idx);
+}
+
+static void _bst_alu_dump(struct ice_hw *hw, struct ice_alu *alu, int index)
+{
+	dev_info(ice_hw_to_dev(hw), "alu%d:\n", index);
+	dev_info(ice_hw_to_dev(hw), "\topc = %d\n", alu->opc);
+	dev_info(ice_hw_to_dev(hw), "\tsrc_start = %d\n", alu->src_start);
+	dev_info(ice_hw_to_dev(hw), "\tsrc_len = %d\n", alu->src_len);
+	dev_info(ice_hw_to_dev(hw), "\tshift_xlate_select = %d\n",
+		 alu->shift_xlate_select);
+	dev_info(ice_hw_to_dev(hw), "\tshift_xlate_key = %d\n",
+		 alu->shift_xlate_key);
+	dev_info(ice_hw_to_dev(hw), "\tsrc_reg_id = %d\n", alu->src_reg_id);
+	dev_info(ice_hw_to_dev(hw), "\tdst_reg_id = %d\n", alu->dst_reg_id);
+	dev_info(ice_hw_to_dev(hw), "\tinc0 = %d\n", alu->inc0);
+	dev_info(ice_hw_to_dev(hw), "\tinc1 = %d\n", alu->inc1);
+	dev_info(ice_hw_to_dev(hw), "\tproto_offset_opc = %d\n",
+		 alu->proto_offset_opc);
+	dev_info(ice_hw_to_dev(hw), "\tproto_offset = %d\n",
+		 alu->proto_offset);
+	dev_info(ice_hw_to_dev(hw), "\tbranch_addr = %d\n", alu->branch_addr);
+	dev_info(ice_hw_to_dev(hw), "\timm = %d\n", alu->imm);
+	dev_info(ice_hw_to_dev(hw), "\tdst_start = %d\n", alu->dst_start);
+	dev_info(ice_hw_to_dev(hw), "\tdst_len = %d\n", alu->dst_len);
+	dev_info(ice_hw_to_dev(hw), "\tflags_extr_imm = %d\n",
+		 alu->flags_extr_imm);
+	dev_info(ice_hw_to_dev(hw), "\tflags_start_imm= %d\n",
+		 alu->flags_start_imm);
+}
+
+/**
+ * ice_bst_tcam_dump - dump a boost tcam info
+ * @hw: pointer to the hardware structure
+ * @item: boost tcam to dump
+ */
+void ice_bst_tcam_dump(struct ice_hw *hw, struct ice_bst_tcam_item *item)
+{
+	int i;
+
+	dev_info(ice_hw_to_dev(hw), "address = %d\n", item->address);
+	dev_info(ice_hw_to_dev(hw), "key    :");
+	for (i = 0; i < 20; i++)
+		dev_info(ice_hw_to_dev(hw), "%02x ", item->key[i]);
+	dev_info(ice_hw_to_dev(hw), "\n");
+	dev_info(ice_hw_to_dev(hw), "key_inv:");
+	for (i = 0; i < 20; i++)
+		dev_info(ice_hw_to_dev(hw), "%02x ", item->key_inv[i]);
+	dev_info(ice_hw_to_dev(hw), "\n");
+	dev_info(ice_hw_to_dev(hw), "hit_idx_grp = %d\n", item->hit_idx_grp);
+	dev_info(ice_hw_to_dev(hw), "pg_pri = %d\n", item->pg_pri);
+	_bst_np_kb_dump(hw, &item->np_kb);
+	_bst_pg_kb_dump(hw, &item->pg_kb);
+	_bst_alu_dump(hw, &item->alu0, 0);
+	_bst_alu_dump(hw, &item->alu1, 1);
+	_bst_alu_dump(hw, &item->alu2, 2);
+}
+
+/** The function parses a 96 bits ALU entry with below format:
+ *  BIT 0-5:	Opcode (alu->opc)
+ *  BIT 6-13:	Source Start (alu->src_start)
+ *  BIT 14-18:	Source Length (alu->src_len)
+ *  BIT 19:	Shift/Xlate Select (alu->shift_xlate_select)
+ *  BIT 20-23:	Shift/Xlate Key (alu->shift_xlate_key)
+ *  BIT 24-30:	Source Register ID (alu->src_reg_id)
+ *  BIT 31-37:	Dest. Register ID (alu->dst_reg_id)
+ *  BIT 38:	Inc0 (alu->inc0)
+ *  BIT 39:	Inc1:(alu->inc1)
+ *  BIT 40:41	Protocol Offset Opcode (alu->proto_offset_opc)
+ *  BIT 42:49	Protocol Offset (alu->proto_offset)
+ *  BIT 50:57	Branch Address (alu->branch_addr)
+ *  BIT 58:73	Immediate (alu->imm)
+ *  BIT 74	Dedicated Flags Enable (alu->dedicate_flags_ena)
+ *  BIT 75:80	Dest. Start (alu->dst_start)
+ *  BIT 81:86	Dest. Length (alu->dst_len)
+ *  BIT 87	Flags Extract Imm. (alu->flags_extr_imm)
+ *  BIT 88:95	Flags Start/Immediate (alu->flags_start_imm)
+ *
+ *  NOTE: the first 7 bits are skipped as the start bit is not
+ *  byte aligned.
+ */
+static void _bst_alu_init(struct ice_alu *alu, u8 *data)
+{
+	u64 d64 = *(u64 *)data >> 7;
+
+	alu->opc = (enum ice_alu_opcode)(d64 & 0x3f);
+	alu->src_start = (u8)((d64 >> 6) & 0xff);
+	alu->src_len = (u8)((d64 >> 14) & 0x1f);
+	alu->shift_xlate_select = ((d64 >> 19) & 0x1) != 0;
+	alu->shift_xlate_key = (u8)((d64 >> 20) & 0xf);
+	alu->src_reg_id = (u8)((d64 >> 24) & 0x7f);
+	alu->dst_reg_id = (u8)((d64 >> 31) & 0x7f);
+	alu->inc0 = ((d64 >> 38) & 0x1) != 0;
+	alu->inc1 = ((d64 >> 39) & 0x1) != 0;
+	alu->proto_offset_opc = (u8)((d64 >> 40) & 0x3);
+	alu->proto_offset = (u8)((d64 >> 42) & 0xff);
+
+	d64 = *(u64 *)(&data[6]) >> 9;
+
+	alu->branch_addr = (u8)(d64 & 0xff);
+	alu->imm = (u16)((d64 >> 8) & 0xffff);
+	alu->dedicate_flags_ena = ((d64 >> 24) & 0x1) != 0;
+	alu->dst_start = (u8)((d64 >> 25) & 0x3f);
+	alu->dst_len = (u8)((d64 >> 31) & 0x3f);
+	alu->flags_extr_imm = ((d64 >> 37) & 0x1) != 0;
+	alu->flags_start_imm = (u8)((d64 >> 38) & 0xff);
+}
+
+/** The function parses a 35 bits Parse Graph Key Build with below format:
+ *  BIT 0:	Flag 0 Enable (kb->flag0_ena)
+ *  BIT 1-6:	Flag 0 Index (kb->flag0_idx)
+ *  BIT 7:	Flag 1 Enable (kb->flag1_ena)
+ *  BIT 8-13:	Flag 1 Index (kb->flag1_idx)
+ *  BIT 14:	Flag 2 Enable (kb->flag2_ena)
+ *  BIT 15-20:	Flag 2 Index (kb->flag2_idx)
+ *  BIT 21:	Flag 3 Enable (kb->flag3_ena)
+ *  BIT 22-27:	Flag 3 Index (kb->flag3_idx)
+ *  BIT 28-34:	ALU Register Index (kb->alu_reg_idx)
+ */
+static void _bst_pgkb_init(struct ice_pg_keybuilder *kb, u64 data)
+{
+	kb->flag0_ena = (data & 0x1) != 0;
+	kb->flag0_idx = (u8)((data >> 1) & 0x3f);
+	kb->flag1_ena = ((data >> 7) & 0x1) != 0;
+	kb->flag1_idx = (u8)((data >> 8) & 0x3f);
+	kb->flag2_ena = ((data >> 14) & 0x1) != 0;
+	kb->flag2_idx = (u8)((data >> 15) & 0x3f);
+	kb->flag3_ena = ((data >> 21) & 0x1) != 0;
+	kb->flag3_idx = (u8)((data >> 22) & 0x3f);
+	kb->alu_reg_idx = (u8)((data >> 28) & 0x7f);
+}
+
+/** The function parses a 18 bits Next Protocol Key Build with below format:
+ *  BIT 0-1:	Opcode kb->ops
+ *  BIT 2-9:	Start / Reg 0 (kb->start_or_reg0)
+ *  BIT 10-17:	Length / Reg 1 (kb->len_or_reg1)
+ */
+static void _bst_npkb_init(struct ice_np_keybuilder *kb, u32 data)
+{
+	kb->ops = (u8)(data & 0x3);
+	kb->start_or_reg0 = (u8)((data >> 2) & 0xff);
+	kb->len_or_reg1 = (u8)((data >> 10) & 0xff);
+}
+
+/** The function parses a 704 bits Boost TCAM entry with below format:
+ *  BIT 0-15:	Address (ti->address)
+ *  BIT 16-31:	reserved
+ *  BIT 32-191: Key (ti->key)
+ *  BIT 192-351:Key Invert (ti->key_inv)
+ *  BIT 352-359:Boost Hit Index Group (ti->hit_idx_grp)
+ *  BIT 360-361:PG Priority (ti->pg_pri)
+ *  BIT 362-379:Next Proto Key Build (ti->np_kb)
+ *  BIT 380-414:PG Key Build (ti->pg_kb)
+ *  BIT 415-510:ALU 0 (ti->alu0)
+ *  BIT 511-606:ALU 1 (ti->alu1)
+ *  BIT 607-702:ALU 2 (ti->alu2)
+ *  BIT 703:	reserved
+ */
+static void _bst_parse_item(struct ice_hw *hw, u16 idx, void *item,
+			    void *data, int size)
+{
+	struct ice_bst_tcam_item *ti = item;
+	u8 *buf = data;
+	int i;
+
+	ti->address = *(u16 *)buf;
+
+	for (i = 0; i < 20; i++)
+		ti->key[i] = buf[4 + i];
+	for (i = 0; i < 20; i++)
+		ti->key_inv[i] = buf[24 + i];
+	ti->hit_idx_grp = buf[44];
+	ti->pg_pri = buf[45] & 0x3;
+	_bst_npkb_init(&ti->np_kb, *(u32 *)&buf[45] >> 2);
+	_bst_pgkb_init(&ti->pg_kb, *(u64 *)&buf[47] >> 4);
+	_bst_alu_init(&ti->alu0, &buf[51]);
+	_bst_alu_init(&ti->alu1, &buf[63]);
+	_bst_alu_init(&ti->alu2, &buf[75]);
+
+	if (hw->debug_mask & ICE_DBG_PARSER)
+		ice_bst_tcam_dump(hw, ti);
+}
+
+/**
+ * ice_bst_tcam_table_get - create a boost tcam table
+ * @hw: pointer to the hardware structure
+ */
+struct ice_bst_tcam_item *ice_bst_tcam_table_get(struct ice_hw *hw)
+{
+	return (struct ice_bst_tcam_item *)
+		ice_parser_create_table(hw, ICE_SID_RXPARSER_BOOST_TCAM,
+					sizeof(struct ice_bst_tcam_item),
+					ICE_BST_TCAM_TABLE_SIZE,
+					ice_parser_sect_item_get,
+					_bst_parse_item, true);
+}
+
+static void _parse_lbl_item(struct ice_hw *hw, u16 idx, void *item,
+			    void *data, int size)
+{
+	ice_parse_item_dflt(hw, idx, item, data, size);
+
+	if (hw->debug_mask & ICE_DBG_PARSER)
+		ice_lbl_dump(hw, (struct ice_lbl_item *)item);
+}
+
+/**
+ * ice_bst_lbl_table_get - create a boost label table
+ * @hw: pointer to the hardware structure
+ */
+struct ice_lbl_item *ice_bst_lbl_table_get(struct ice_hw *hw)
+{
+	return (struct ice_lbl_item *)
+		ice_parser_create_table(hw, ICE_SID_LBL_RXPARSER_TMEM,
+					sizeof(struct ice_lbl_item),
+					ICE_BST_TCAM_TABLE_SIZE,
+					ice_parser_sect_item_get,
+					_parse_lbl_item, true);
+}
drivers/net/ethernet/intel/ice/ice_bst_tcam.h new file +27 -0
new file mode 100644
index 000000000000..9d78a140bc02
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#ifndef _ICE_BST_TCAM_H_
+#define _ICE_BST_TCAM_H_
+
+#include "ice_imem.h"
+
+struct ice_bst_tcam_item {
+	u16 address;
+	u8 key[20];
+	u8 key_inv[20];
+	u8 hit_idx_grp;
+	u8 pg_pri;
+	struct ice_np_keybuilder np_kb;
+	struct ice_pg_keybuilder pg_kb;
+	struct ice_alu alu0;
+	struct ice_alu alu1;
+	struct ice_alu alu2;
+};
+
+void ice_bst_tcam_dump(struct ice_hw *hw, struct ice_bst_tcam_item *item);
+
+struct ice_bst_tcam_item *ice_bst_tcam_table_get(struct ice_hw *hw);
+
+struct ice_lbl_item *ice_bst_lbl_table_get(struct ice_hw *hw);
+#endif /*_ICE_BST_TCAM_H_ */
drivers/net/ethernet/intel/ice/ice_imem.c +1 -1
index 2bd48f080326..2ce186cbe4fd 100644
@@ -246,5 +246,5 @@ struct ice_imem_item *ice_imem_table_get(struct ice_hw *hw)
  					sizeof(struct ice_imem_item),
  					ICE_IMEM_TABLE_SIZE,
  					ice_parser_sect_item_get,
-					_imem_parse_item);
+					_imem_parse_item, false);
  }
drivers/net/ethernet/intel/ice/ice_metainit.c +1 -1
index 911099a38087..00fd86ce5fcf 100644
@@ -151,5 +151,5 @@ struct ice_metainit_item *ice_metainit_table_get(struct ice_hw *hw)
  					sizeof(struct ice_metainit_item),
  					ICE_METAINIT_TABLE_SIZE,
  					ice_parser_sect_item_get,
-					_metainit_parse_item);
+					_metainit_parse_item, false);
  }
drivers/net/ethernet/intel/ice/ice_parser.c +45 -2
index 22c2382ae9e8..b280245dbdd4 100644
@@ -11,6 +11,22 @@
  #define ICE_SID_RXPARSER_PG_SPILL_ENTRY_SIZE		17
  #define ICE_SID_RXPARSER_NOMATCH_CAM_ENTRY_SIZE		12
  #define ICE_SID_RXPARSER_NOMATCH_SPILL_ENTRY_SIZE	13
+#define ICE_SID_RXPARSER_BOOST_TCAM_ENTRY_SIZE		88
+
+#define ICE_SEC_LBL_DATA_OFFSET				2
+#define ICE_SID_LBL_ENTRY_SIZE				66
+
+void ice_lbl_dump(struct ice_hw *hw, struct ice_lbl_item *item)
+{
+	dev_info(ice_hw_to_dev(hw), "index = %d\n", item->idx);
+	dev_info(ice_hw_to_dev(hw), "label = %s\n", item->label);
+}
+
+void ice_parse_item_dflt(struct ice_hw *hw, u16 idx, void *item,
+			 void *data, int size)
+{
+	memcpy(item, data, size);
+}
 
  /**
   * ice_parser_sect_item_get - parse a item from a section
@@ -48,6 +64,13 @@ void *ice_parser_sect_item_get(u32 sect_type, void *section,
  	case ICE_SID_RXPARSER_NOMATCH_SPILL:
  		size = ICE_SID_RXPARSER_NOMATCH_SPILL_ENTRY_SIZE;
  		break;
+	case ICE_SID_RXPARSER_BOOST_TCAM:
+		size = ICE_SID_RXPARSER_BOOST_TCAM_ENTRY_SIZE;
+		break;
+	case ICE_SID_LBL_RXPARSER_TMEM:
+		data_off = ICE_SEC_LBL_DATA_OFFSET;
+		size = ICE_SID_LBL_ENTRY_SIZE;
+		break;
  	default:
  		return NULL;
  	}
@@ -69,6 +92,7 @@ void *ice_parser_sect_item_get(u32 sect_type, void *section,
   * @length: number of items in the table to create
   * @item_get: the function will be parsed to ice_pkg_enum_entry
   * @parse_item: the function to parse the item
+ * @no_offset: ignore header offset, calculate index from 0
   */
  void *ice_parser_create_table(struct ice_hw *hw, u32 sect_type,
  			      u32 item_size, u32 length,
@@ -76,7 +100,8 @@ void *ice_parser_create_table(struct ice_hw *hw, u32 sect_type,
  						u32 index, u32 *offset),
  			      void (*parse_item)(struct ice_hw *hw, u16 idx,
  						 void *item, void *data,
-						 int size))
+						 int size),
+			      bool no_offset)
  {
  	struct ice_seg *seg = hw->seg;
  	struct ice_pkg_enum state;
@@ -101,7 +126,11 @@ void *ice_parser_create_table(struct ice_hw *hw, u32 sect_type,
  			struct ice_pkg_sect_hdr *hdr =
  				(struct ice_pkg_sect_hdr *)state.sect;
 
-			idx = le16_to_cpu(hdr->offset) + state.entry_idx;
+			if (no_offset)
+				idx++;
+			else
+				idx = le16_to_cpu(hdr->offset) +
+							state.entry_idx;
  			parse_item(hw, idx,
  				   (void *)((uintptr_t)table +
  					    ((uintptr_t)idx *
@@ -167,6 +196,18 @@ int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr)
  		goto err;
  	}
 
+	p->bst_tcam_table = ice_bst_tcam_table_get(hw);
+	if (!p->bst_tcam_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
+	p->bst_lbl_table = ice_bst_lbl_table_get(hw);
+	if (!p->bst_lbl_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
  	*psr = p;
  	return 0;
  err:
@@ -186,6 +227,8 @@ void ice_parser_destroy(struct ice_parser *psr)
  	devm_kfree(ice_hw_to_dev(psr->hw), psr->pg_sp_cam_table);
  	devm_kfree(ice_hw_to_dev(psr->hw), psr->pg_nm_cam_table);
  	devm_kfree(ice_hw_to_dev(psr->hw), psr->pg_nm_sp_cam_table);
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->bst_tcam_table);
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->bst_lbl_table);
 
  	devm_kfree(ice_hw_to_dev(psr->hw), psr);
  }
drivers/net/ethernet/intel/ice/ice_parser.h +5 -0
index 1f699ef12387..af73b19d09c1 100644
@@ -7,6 +7,7 @@
  #include "ice_metainit.h"
  #include "ice_imem.h"
  #include "ice_pg_cam.h"
+#include "ice_bst_tcam.h"
 
  struct ice_parser {
  	struct ice_hw *hw; /* pointer to the hardware structure */
@@ -23,6 +24,10 @@ struct ice_parser {
  	struct ice_pg_nm_cam_item *pg_nm_cam_table;
  	/* load data from section ICE_SID_RXPARSER_NOMATCH_SPILL */
  	struct ice_pg_nm_cam_item *pg_nm_sp_cam_table;
+	/* load data from section ICE_SID_RXPARSER_BOOST_TCAM */
+	struct ice_bst_tcam_item *bst_tcam_table;
+	/* load data from section ICE_SID_LBL_RXPARSER_TMEM */
+	struct ice_lbl_item *bst_lbl_table;
  };
 
  int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
drivers/net/ethernet/intel/ice/ice_parser_util.h +11 -1
index 59c67f1a1951..2f93f93c1e10 100644
@@ -7,11 +7,20 @@
  #include "ice_imem.h"
  #include "ice_metainit.h"
 
+struct ice_lbl_item {
+	u16 idx;
+	char label[64];
+};
+
  struct ice_pkg_sect_hdr {
  	__le16 count;
  	__le16 offset;
  };
 
+void ice_lbl_dump(struct ice_hw *hw, struct ice_lbl_item *item);
+void ice_parse_item_dflt(struct ice_hw *hw, u16 idx, void *item,
+			 void *data, int size);
+
  void *ice_parser_sect_item_get(u32 sect_type, void *section,
  			       u32 index, u32 *offset);
 
@@ -21,5 +30,6 @@ void *ice_parser_create_table(struct ice_hw *hw, u32 sect_type,
  					       u32 index, u32 *offset),
  			      void (*parse_item)(struct ice_hw *hw, u16 idx,
  						 void *item, void *data,
-						 int size));
+						 int size),
+			      bool no_offset);
  #endif /* _ICE_PARSER_UTIL_H_ */
drivers/net/ethernet/intel/ice/ice_pg_cam.c +3 -3
index 25b837ba684c..1c9a9e906f3e 100644
@@ -254,7 +254,7 @@ struct ice_pg_cam_item *ice_pg_cam_table_get(struct ice_hw *hw)
  					sizeof(struct ice_pg_cam_item),
  					ICE_PG_CAM_TABLE_SIZE,
  					ice_parser_sect_item_get,
-					_pg_cam_parse_item);
+					_pg_cam_parse_item, false);
  }
 
  /**
@@ -268,7 +268,7 @@ struct ice_pg_cam_item *ice_pg_sp_cam_table_get(struct ice_hw *hw)
  					sizeof(struct ice_pg_cam_item),
  					ICE_PG_SP_CAM_TABLE_SIZE,
  					ice_parser_sect_item_get,
-					_pg_sp_cam_parse_item);
+					_pg_sp_cam_parse_item, false);
  }
 
  /**
@@ -282,7 +282,7 @@ struct ice_pg_nm_cam_item *ice_pg_nm_cam_table_get(struct ice_hw *hw)
  					sizeof(struct ice_pg_nm_cam_item),
  					ICE_PG_NM_CAM_TABLE_SIZE,
  					ice_parser_sect_item_get,
-					_pg_nm_cam_parse_item);
+					_pg_nm_cam_parse_item, false);
  }
 
  /**

drivers/net/ethernet/intel/ice/ice_pg_cam.c struct ice_pg_nm_cam_item *ice_pg_nm_sp_cam_table_get(struct ice_hw *hw) · line 300

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_pg_cam.c +1 -1
@@ -296,5 +296,5 @@ struct ice_pg_nm_cam_item *ice_pg_nm_sp_cam_table_get(struct ice_hw *hw)
  					sizeof(struct ice_pg_nm_cam_item),
  					ICE_PG_NM_SP_CAM_TABLE_SIZE,
  					ice_parser_sect_item_get,
-					_pg_nm_sp_cam_parse_item);
+					_pg_nm_sp_cam_parse_item, false);
  }

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#17 lore raw

Re: [Intel-wired-lan] [PATCH iwl-next v2 05/15] ice: init boost tcam table for parser

Quoted 12 lines

-----Original Message-----
From: Ivan Vecera <[email protected]>
Sent: Monday, July 24, 2023 18:40
To: Guo, Junfeng <[email protected]>; intel-wired- [email protected]
Cc: Zhang, Qi Z <[email protected]>; mschmidt <[email protected]>; poros <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH iwl-next v2 05/15] ice: init boost tcam table for parser

Quoted 2 lines

Like in my previous replies... Do not use hardcoded values for array indices, masks and shifts...

Sure, make sense!

Will go through all the patch set and double check the usage of hardcoded values. Thanks for the careful review!
Will update in the coming version patch set, thanks!

Quoted 570 lines · Junfeng Guo
Quoted 8 lines

Parse DDP section ICE_SID_RXPARSER_CAM into an array of ice_bst_tcam_item.
Parse DDP section ICE_SID_LBL_RXPARSER_TMEM into an array of ice_lbl_item.

---
  drivers/net/ethernet/intel/ice/ice_bst_tcam.c | 247

++++++++++++++++++

Quoted 8 lines
  drivers/net/ethernet/intel/ice/ice_bst_tcam.h |  27 ++
  drivers/net/ethernet/intel/ice/ice_imem.c     |   2 +-
  drivers/net/ethernet/intel/ice/ice_metainit.c |   2 +-
  drivers/net/ethernet/intel/ice/ice_parser.c   |  47 +++-
  drivers/net/ethernet/intel/ice/ice_parser.h   |   5 +
  .../net/ethernet/intel/ice/ice_parser_util.h  |  12 +-
  drivers/net/ethernet/intel/ice/ice_pg_cam.c   |   8 +-
  8 files changed, 341 insertions(+), 9 deletions(-)

Review

Quoted 4 lines

create mode 100644 drivers/net/ethernet/intel/ice/ice_bst_tcam.c create mode 100644 drivers/net/ethernet/intel/ice/ice_bst_tcam.h

(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_bst_tcam.c

Quoted 5 lines

new file mode 100644
index 000000000000..24e793580637

drivers/net/ethernet/intel/ice/ice_bst_tcam.c line 9

Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_bst_tcam.c new file +9 -0
@@ -0,0 +1,247 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#include "ice_common.h"
+#include "ice_parser_util.h"
+
+#define ICE_BST_TCAM_TABLE_SIZE 256
+
+static void _bst_np_kb_dump(struct ice_hw *hw, struct

ice_np_keybuilder *kb)

drivers/net/ethernet/intel/ice/ice_bst_tcam.c

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_bst_tcam.c new file +6 -0
+{
+	dev_info(ice_hw_to_dev(hw), "next proto key builder:\n");
+	dev_info(ice_hw_to_dev(hw), "\tops = %d\n", kb->ops);
+	dev_info(ice_hw_to_dev(hw), "\tstart_or_reg0 = %d\n",
+		 kb->start_or_reg0);
+	dev_info(ice_hw_to_dev(hw), "\tlen_or_reg1 = %d\n", kb-

len_or_reg1);

drivers/net/ethernet/intel/ice/ice_bst_tcam.c new file +3 -0
+}
+
+static void _bst_pg_kb_dump(struct ice_hw *hw, struct

ice_pg_keybuilder *kb)

Quoted 20 lines
drivers/net/ethernet/intel/ice/ice_bst_tcam.c new file +3 -0
+{
+	dev_info(ice_hw_to_dev(hw), "parse graph key builder:\n");
+	dev_info(ice_hw_to_dev(hw), "\tflag0_ena = %d\n", kb-

flag0_ena);

drivers/net/ethernet/intel/ice/ice_bst_tcam.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tflag1_ena = %d\n", kb-

flag1_ena);

drivers/net/ethernet/intel/ice/ice_bst_tcam.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tflag2_ena = %d\n", kb-

flag2_ena);

drivers/net/ethernet/intel/ice/ice_bst_tcam.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tflag3_ena = %d\n", kb-

flag3_ena);

drivers/net/ethernet/intel/ice/ice_bst_tcam.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tflag0_idx = %d\n", kb-

flag0_idx);

drivers/net/ethernet/intel/ice/ice_bst_tcam.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tflag1_idx = %d\n", kb-

flag1_idx);

drivers/net/ethernet/intel/ice/ice_bst_tcam.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tflag2_idx = %d\n", kb-

flag2_idx);

drivers/net/ethernet/intel/ice/ice_bst_tcam.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tflag3_idx = %d\n", kb-

flag3_idx);

drivers/net/ethernet/intel/ice/ice_bst_tcam.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\talu_reg_idx = %d\n", kb-

alu_reg_idx);

drivers/net/ethernet/intel/ice/ice_bst_tcam.c

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_bst_tcam.c new file +3 -0
+}
+
+static void _bst_alu_dump(struct ice_hw *hw, struct ice_alu *alu, int

index)

Quoted 28 lines
drivers/net/ethernet/intel/ice/ice_bst_tcam.c new file +4 -0
+{
+	dev_info(ice_hw_to_dev(hw), "alu%d:\n", index);
+	dev_info(ice_hw_to_dev(hw), "\topc = %d\n", alu->opc);
+	dev_info(ice_hw_to_dev(hw), "\tsrc_start = %d\n", alu-

src_start);

drivers/net/ethernet/intel/ice/ice_bst_tcam.c new file +6 -0
+	dev_info(ice_hw_to_dev(hw), "\tsrc_len = %d\n", alu->src_len);
+	dev_info(ice_hw_to_dev(hw), "\tshift_xlate_select = %d\n",
+		 alu->shift_xlate_select);
+	dev_info(ice_hw_to_dev(hw), "\tshift_xlate_key = %d\n",
+		 alu->shift_xlate_key);
+	dev_info(ice_hw_to_dev(hw), "\tsrc_reg_id = %d\n", alu-

src_reg_id);

drivers/net/ethernet/intel/ice/ice_bst_tcam.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tdst_reg_id = %d\n", alu-

dst_reg_id);

drivers/net/ethernet/intel/ice/ice_bst_tcam.c new file +7 -0
+	dev_info(ice_hw_to_dev(hw), "\tinc0 = %d\n", alu->inc0);
+	dev_info(ice_hw_to_dev(hw), "\tinc1 = %d\n", alu->inc1);
+	dev_info(ice_hw_to_dev(hw), "\tproto_offset_opc = %d\n",
+		 alu->proto_offset_opc);
+	dev_info(ice_hw_to_dev(hw), "\tproto_offset = %d\n",
+		 alu->proto_offset);
+	dev_info(ice_hw_to_dev(hw), "\tbranch_addr = %d\n", alu-

branch_addr);

drivers/net/ethernet/intel/ice/ice_bst_tcam.c new file +2 -0
+	dev_info(ice_hw_to_dev(hw), "\timm = %d\n", alu->imm);
+	dev_info(ice_hw_to_dev(hw), "\tdst_start = %d\n", alu-

dst_start);

drivers/net/ethernet/intel/ice/ice_bst_tcam.c new file +3 -0
+	dev_info(ice_hw_to_dev(hw), "\tdst_len = %d\n", alu->dst_len);
+	dev_info(ice_hw_to_dev(hw), "\tflags_extr_imm = %d\n",
+		 alu->flags_extr_imm);

drivers/net/ethernet/intel/ice/ice_bst_tcam.c

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_bst_tcam.c new file +10 -0
+	dev_info(ice_hw_to_dev(hw), "\tflags_start_imm= %d\n",
+		 alu->flags_start_imm);
+}
+
+/**
+ * ice_bst_tcam_dump - dump a boost tcam info
+ * @hw: pointer to the hardware structure
+ * @item: boost tcam to dump
+ */
+void ice_bst_tcam_dump(struct ice_hw *hw, struct ice_bst_tcam_item

*item)

Quoted 63 lines
drivers/net/ethernet/intel/ice/ice_bst_tcam.c new file +13 -0
+{
+	int i;
+
+	dev_info(ice_hw_to_dev(hw), "address = %d\n", item->address);
+	dev_info(ice_hw_to_dev(hw), "key    :");
+	for (i = 0; i < 20; i++)
+		dev_info(ice_hw_to_dev(hw), "%02x ", item->key[i]);
+	dev_info(ice_hw_to_dev(hw), "\n");
+	dev_info(ice_hw_to_dev(hw), "key_inv:");
+	for (i = 0; i < 20; i++)
+		dev_info(ice_hw_to_dev(hw), "%02x ", item->key_inv[i]);
+	dev_info(ice_hw_to_dev(hw), "\n");
+	dev_info(ice_hw_to_dev(hw), "hit_idx_grp = %d\n", item-

hit_idx_grp);

drivers/net/ethernet/intel/ice/ice_bst_tcam.c new file +49 -0
+	dev_info(ice_hw_to_dev(hw), "pg_pri = %d\n", item->pg_pri);
+	_bst_np_kb_dump(hw, &item->np_kb);
+	_bst_pg_kb_dump(hw, &item->pg_kb);
+	_bst_alu_dump(hw, &item->alu0, 0);
+	_bst_alu_dump(hw, &item->alu1, 1);
+	_bst_alu_dump(hw, &item->alu2, 2);
+}
+
+/** The function parses a 96 bits ALU entry with below format:
+ *  BIT 0-5:	Opcode (alu->opc)
+ *  BIT 6-13:	Source Start (alu->src_start)
+ *  BIT 14-18:	Source Length (alu->src_len)
+ *  BIT 19:	Shift/Xlate Select (alu->shift_xlate_select)
+ *  BIT 20-23:	Shift/Xlate Key (alu->shift_xlate_key)
+ *  BIT 24-30:	Source Register ID (alu->src_reg_id)
+ *  BIT 31-37:	Dest. Register ID (alu->dst_reg_id)
+ *  BIT 38:	Inc0 (alu->inc0)
+ *  BIT 39:	Inc1:(alu->inc1)
+ *  BIT 40:41	Protocol Offset Opcode (alu->proto_offset_opc)
+ *  BIT 42:49	Protocol Offset (alu->proto_offset)
+ *  BIT 50:57	Branch Address (alu->branch_addr)
+ *  BIT 58:73	Immediate (alu->imm)
+ *  BIT 74	Dedicated Flags Enable (alu->dedicate_flags_ena)
+ *  BIT 75:80	Dest. Start (alu->dst_start)
+ *  BIT 81:86	Dest. Length (alu->dst_len)
+ *  BIT 87	Flags Extract Imm. (alu->flags_extr_imm)
+ *  BIT 88:95	Flags Start/Immediate (alu->flags_start_imm)
+ *
+ *  NOTE: the first 7 bits are skipped as the start bit is not
+ *  byte aligned.
+ */
+static void _bst_alu_init(struct ice_alu *alu, u8 *data)
+{
+	u64 d64 = *(u64 *)data >> 7;
+
+	alu->opc = (enum ice_alu_opcode)(d64 & 0x3f);
+	alu->src_start = (u8)((d64 >> 6) & 0xff);
+	alu->src_len = (u8)((d64 >> 14) & 0x1f);
+	alu->shift_xlate_select = ((d64 >> 19) & 0x1) != 0;
+	alu->shift_xlate_key = (u8)((d64 >> 20) & 0xf);
+	alu->src_reg_id = (u8)((d64 >> 24) & 0x7f);
+	alu->dst_reg_id = (u8)((d64 >> 31) & 0x7f);
+	alu->inc0 = ((d64 >> 38) & 0x1) != 0;
+	alu->inc1 = ((d64 >> 39) & 0x1) != 0;
+	alu->proto_offset_opc = (u8)((d64 >> 40) & 0x3);
+	alu->proto_offset = (u8)((d64 >> 42) & 0xff);
+
+	d64 = *(u64 *)(&data[6]) >> 9;
+

drivers/net/ethernet/intel/ice/ice_bst_tcam.c

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_bst_tcam.c new file +10 -0
+	alu->branch_addr = (u8)(d64 & 0xff);
+	alu->imm = (u16)((d64 >> 8) & 0xffff);
+	alu->dedicate_flags_ena = ((d64 >> 24) & 0x1) != 0;
+	alu->dst_start = (u8)((d64 >> 25) & 0x3f);
+	alu->dst_len = (u8)((d64 >> 31) & 0x3f);
+	alu->flags_extr_imm = ((d64 >> 37) & 0x1) != 0;
+	alu->flags_start_imm = (u8)((d64 >> 38) & 0xff);
+}
+
+/** The function parses a 35 bits Parse Graph Key Build with below

format:

Quoted 14 lines
+ *  BIT 0:	Flag 0 Enable (kb->flag0_ena)
+ *  BIT 1-6:	Flag 0 Index (kb->flag0_idx)
+ *  BIT 7:	Flag 1 Enable (kb->flag1_ena)
+ *  BIT 8-13:	Flag 1 Index (kb->flag1_idx)
+ *  BIT 14:	Flag 2 Enable (kb->flag2_ena)
+ *  BIT 15-20:	Flag 2 Index (kb->flag2_idx)
+ *  BIT 21:	Flag 3 Enable (kb->flag3_ena)
+ *  BIT 22-27:	Flag 3 Index (kb->flag3_idx)
+ *  BIT 28-34:	ALU Register Index (kb->alu_reg_idx)

+ */

drivers/net/ethernet/intel/ice/ice_bst_tcam.c new file +4 -0
+static void _bst_pgkb_init(struct ice_pg_keybuilder *kb, u64 data)
+{
+	kb->flag0_ena = (data & 0x1) != 0;
+	kb->flag0_idx = (u8)((data >> 1) & 0x3f);

drivers/net/ethernet/intel/ice/ice_bst_tcam.c

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_bst_tcam.c new file +10 -0
+	kb->flag1_ena = ((data >> 7) & 0x1) != 0;
+	kb->flag1_idx = (u8)((data >> 8) & 0x3f);
+	kb->flag2_ena = ((data >> 14) & 0x1) != 0;
+	kb->flag2_idx = (u8)((data >> 15) & 0x3f);
+	kb->flag3_ena = ((data >> 21) & 0x1) != 0;
+	kb->flag3_idx = (u8)((data >> 22) & 0x3f);
+	kb->alu_reg_idx = (u8)((data >> 28) & 0x7f);
+}
+
+/** The function parses a 18 bits Next Protocol Key Build with below

format:

drivers/net/ethernet/intel/ice/ice_bst_tcam.c

Quoted 12 lines
+ *  BIT 0-1:	Opcode kb->ops
+ *  BIT 2-9:	Start / Reg 0 (kb->start_or_reg0)
+ *  BIT 10-17:	Length / Reg 1 (kb->len_or_reg1)

+ */

drivers/net/ethernet/intel/ice/ice_bst_tcam.c new file +8 -0
+static void _bst_npkb_init(struct ice_np_keybuilder *kb, u32 data)
+{
+	kb->ops = (u8)(data & 0x3);
+	kb->start_or_reg0 = (u8)((data >> 2) & 0xff);
+	kb->len_or_reg1 = (u8)((data >> 10) & 0xff);
+}
+
+/** The function parses a 704 bits Boost TCAM entry with below

format:

Quoted 36 lines
+ *  BIT 0-15:	Address (ti->address)
+ *  BIT 16-31:	reserved
+ *  BIT 32-191: Key (ti->key)
+ *  BIT 192-351:Key Invert (ti->key_inv)
+ *  BIT 352-359:Boost Hit Index Group (ti->hit_idx_grp)
+ *  BIT 360-361:PG Priority (ti->pg_pri)
+ *  BIT 362-379:Next Proto Key Build (ti->np_kb)
+ *  BIT 380-414:PG Key Build (ti->pg_kb)
+ *  BIT 415-510:ALU 0 (ti->alu0)
+ *  BIT 511-606:ALU 1 (ti->alu1)
+ *  BIT 607-702:ALU 2 (ti->alu2)
+ *  BIT 703:	reserved

+ */

drivers/net/ethernet/intel/ice/ice_bst_tcam.c new file +23 -0
+static void _bst_parse_item(struct ice_hw *hw, u16 idx, void *item,
+			    void *data, int size)
+{
+	struct ice_bst_tcam_item *ti = item;
+	u8 *buf = data;
+	int i;
+
+	ti->address = *(u16 *)buf;
+
+	for (i = 0; i < 20; i++)
+		ti->key[i] = buf[4 + i];
+	for (i = 0; i < 20; i++)
+		ti->key_inv[i] = buf[24 + i];
+	ti->hit_idx_grp = buf[44];
+	ti->pg_pri = buf[45] & 0x3;
+	_bst_npkb_init(&ti->np_kb, *(u32 *)&buf[45] >> 2);
+	_bst_pgkb_init(&ti->pg_kb, *(u64 *)&buf[47] >> 4);
+	_bst_alu_init(&ti->alu0, &buf[51]);
+	_bst_alu_init(&ti->alu1, &buf[63]);
+	_bst_alu_init(&ti->alu2, &buf[75]);
+
+	if (hw->debug_mask & ICE_DBG_PARSER)
+		ice_bst_tcam_dump(hw, ti);

drivers/net/ethernet/intel/ice/ice_bst_tcam.c

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_bst_tcam.c new file +10 -0
+}
+
+/**
+ * ice_bst_tcam_table_get - create a boost tcam table
+ * @hw: pointer to the hardware structure
+ */
+struct ice_bst_tcam_item *ice_bst_tcam_table_get(struct ice_hw *hw)
+{
+	return (struct ice_bst_tcam_item *)
+		ice_parser_create_table(hw,

ICE_SID_RXPARSER_BOOST_TCAM,

Quoted 13 lines
drivers/net/ethernet/intel/ice/ice_bst_tcam.c new file +13 -0
+					sizeof(struct ice_bst_tcam_item),
+					ICE_BST_TCAM_TABLE_SIZE,
+					ice_parser_sect_item_get,
+					_bst_parse_item, true);
+}
+
+static void _parse_lbl_item(struct ice_hw *hw, u16 idx, void *item,
+			    void *data, int size)
+{
+	ice_parse_item_dflt(hw, idx, item, data, size);
+
+	if (hw->debug_mask & ICE_DBG_PARSER)
+		ice_lbl_dump(hw, (struct ice_lbl_item *)item);

drivers/net/ethernet/intel/ice/ice_bst_tcam.c

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_bst_tcam.c new file +10 -0
+}
+
+/**
+ * ice_bst_lbl_table_get - create a boost label table
+ * @hw: pointer to the hardware structure
+ */
+struct ice_lbl_item *ice_bst_lbl_table_get(struct ice_hw *hw)
+{
+	return (struct ice_lbl_item *)
+		ice_parser_create_table(hw,

ICE_SID_LBL_RXPARSER_TMEM,

Review

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_bst_tcam.c new file +5 -0
+					sizeof(struct ice_lbl_item),
+					ICE_BST_TCAM_TABLE_SIZE,
+					ice_parser_sect_item_get,
+					_parse_lbl_item, true);
+}
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_bst_tcam.h

Quoted 17 lines

new file mode 100644
index 000000000000..9d78a140bc02

drivers/net/ethernet/intel/ice/ice_bst_tcam.h new file +12 -0
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#ifndef _ICE_BST_TCAM_H_
+#define _ICE_BST_TCAM_H_
+
+#include "ice_imem.h"
+
+struct ice_bst_tcam_item {
+	u16 address;
+	u8 key[20];
+	u8 key_inv[20];

drivers/net/ethernet/intel/ice/ice_bst_tcam.h line 22

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_bst_tcam.h new file +10 -0
+	u8 hit_idx_grp;
+	u8 pg_pri;
+	struct ice_np_keybuilder np_kb;
+	struct ice_pg_keybuilder pg_kb;
+	struct ice_alu alu0;
+	struct ice_alu alu1;
+	struct ice_alu alu2;
+};
+
+void ice_bst_tcam_dump(struct ice_hw *hw, struct ice_bst_tcam_item

*item);

drivers/net/ethernet/intel/ice/ice_bst_tcam.h line 24

Quoted 2 lines
drivers/net/ethernet/intel/ice/ice_bst_tcam.h new file +2 -0
+
+struct ice_bst_tcam_item *ice_bst_tcam_table_get(struct ice_hw

*hw);

Review

Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_bst_tcam.h new file +3 -0
+
+struct ice_lbl_item *ice_bst_lbl_table_get(struct ice_hw *hw);
+#endif /*_ICE_BST_TCAM_H_ */
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_imem.c

drivers/net/ethernet/intel/ice/ice_imem.c struct ice_imem_item

Quoted 4 lines

index 2bd48f080326..2ce186cbe4fd 100644

drivers/net/ethernet/intel/ice/ice_imem.c +0 -0
@@ -246,5 +246,5 @@ struct ice_imem_item

*ice_imem_table_get(struct ice_hw *hw)

Review

Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_imem.c +1 -1
  					sizeof(struct ice_imem_item),
  					ICE_IMEM_TABLE_SIZE,
  					ice_parser_sect_item_get,
-					_imem_parse_item);
+					_imem_parse_item, false);
  }
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_metainit.c

drivers/net/ethernet/intel/ice/ice_metainit.c struct ice_metainit_item

Quoted 4 lines

index 911099a38087..00fd86ce5fcf 100644

drivers/net/ethernet/intel/ice/ice_metainit.c +0 -0
@@ -151,5 +151,5 @@ struct ice_metainit_item

*ice_metainit_table_get(struct ice_hw *hw)

Review

Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_metainit.c +1 -1
  					sizeof(struct ice_metainit_item),
  					ICE_METAINIT_TABLE_SIZE,
  					ice_parser_sect_item_get,
-					_metainit_parse_item);
+					_metainit_parse_item, false);
  }
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_parser.c

drivers/net/ethernet/intel/ice/ice_parser.c line 12

Quoted 6 lines

index 22c2382ae9e8..b280245dbdd4 100644

drivers/net/ethernet/intel/ice/ice_parser.c +0 -0
@@ -11,6 +11,22 @@
  #define ICE_SID_RXPARSER_PG_SPILL_ENTRY_SIZE		17
  #define ICE_SID_RXPARSER_NOMATCH_CAM_ENTRY_SIZE
	12

drivers/net/ethernet/intel/ice/ice_parser.c line 14

Quoted 2 lines
drivers/net/ethernet/intel/ice/ice_parser.c +1 -0
  #define ICE_SID_RXPARSER_NOMATCH_SPILL_ENTRY_SIZE	13
+#define ICE_SID_RXPARSER_BOOST_TCAM_ENTRY_SIZE
	88

drivers/net/ethernet/intel/ice/ice_parser.c void *ice_parser_sect_item_get(u32 sect_type,

Quoted 19 lines
drivers/net/ethernet/intel/ice/ice_parser.c +15 -0
+
+#define ICE_SEC_LBL_DATA_OFFSET				2
+#define ICE_SID_LBL_ENTRY_SIZE				66
+
+void ice_lbl_dump(struct ice_hw *hw, struct ice_lbl_item *item)
+{
+	dev_info(ice_hw_to_dev(hw), "index = %d\n", item->idx);
+	dev_info(ice_hw_to_dev(hw), "label = %s\n", item->label);
+}
+
+void ice_parse_item_dflt(struct ice_hw *hw, u16 idx, void *item,
+			 void *data, int size)
+{
+	memcpy(item, data, size);
+}
 
  /**
   * ice_parser_sect_item_get - parse a item from a section
@@ -48,6 +64,13 @@ void *ice_parser_sect_item_get(u32 sect_type,

void *section,

drivers/net/ethernet/intel/ice/ice_parser.c void *ice_parser_sect_item_get(u32 sect_type,

Quoted 14 lines
drivers/net/ethernet/intel/ice/ice_parser.c +7 -0
  	case ICE_SID_RXPARSER_NOMATCH_SPILL:
  		size = ICE_SID_RXPARSER_NOMATCH_SPILL_ENTRY_SIZE;
  		break;
+	case ICE_SID_RXPARSER_BOOST_TCAM:
+		size = ICE_SID_RXPARSER_BOOST_TCAM_ENTRY_SIZE;
+		break;
+	case ICE_SID_LBL_RXPARSER_TMEM:
+		data_off = ICE_SEC_LBL_DATA_OFFSET;
+		size = ICE_SID_LBL_ENTRY_SIZE;
+		break;
  	default:
  		return NULL;
  	}
@@ -69,6 +92,7 @@ void *ice_parser_sect_item_get(u32 sect_type,

void *section,

drivers/net/ethernet/intel/ice/ice_parser.c void *ice_parser_create_table(struct ice_hw

Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_parser.c +1 -0
   * @length: number of items in the table to create
   * @item_get: the function will be parsed to ice_pkg_enum_entry
   * @parse_item: the function to parse the item
+ * @no_offset: ignore header offset, calculate index from 0
   */
  void *ice_parser_create_table(struct ice_hw *hw, u32 sect_type,
  			      u32 item_size, u32 length,
@@ -76,7 +100,8 @@ void *ice_parser_create_table(struct ice_hw

*hw, u32 sect_type,

drivers/net/ethernet/intel/ice/ice_parser.c void *ice_parser_create_table(struct ice_hw

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_parser.c +2 -1
  						u32 index, u32 *offset),
  			      void (*parse_item)(struct ice_hw *hw, u16 idx,
  						 void *item, void *data,
-						 int size))
+						 int size),
+			      bool no_offset)
  {
  	struct ice_seg *seg = hw->seg;
  	struct ice_pkg_enum state;
@@ -101,7 +126,11 @@ void *ice_parser_create_table(struct ice_hw

*hw, u32 sect_type,

drivers/net/ethernet/intel/ice/ice_parser.c int ice_parser_create(struct ice_hw *hw,

Quoted 13 lines
drivers/net/ethernet/intel/ice/ice_parser.c +5 -1
  			struct ice_pkg_sect_hdr *hdr =
  				(struct ice_pkg_sect_hdr *)state.sect;
 
-			idx = le16_to_cpu(hdr->offset) + state.entry_idx;
+			if (no_offset)
+				idx++;
+			else
+				idx = le16_to_cpu(hdr->offset) +
+							state.entry_idx;
  			parse_item(hw, idx,
  				   (void *)((uintptr_t)table +
  					    ((uintptr_t)idx *
@@ -167,6 +196,18 @@ int ice_parser_create(struct ice_hw *hw,

struct ice_parser **psr)

Quoted 28 lines
drivers/net/ethernet/intel/ice/ice_parser.c +14 -0
  		goto err;
  	}
 
+	p->bst_tcam_table = ice_bst_tcam_table_get(hw);
+	if (!p->bst_tcam_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
+	p->bst_lbl_table = ice_bst_lbl_table_get(hw);
+	if (!p->bst_lbl_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
  	*psr = p;
  	return 0;
  err:
@@ -186,6 +227,8 @@ void ice_parser_destroy(struct ice_parser *psr)
  	devm_kfree(ice_hw_to_dev(psr->hw), psr->pg_sp_cam_table);
  	devm_kfree(ice_hw_to_dev(psr->hw), psr->pg_nm_cam_table);
  	devm_kfree(ice_hw_to_dev(psr->hw), psr-
 pg_nm_sp_cam_table);
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->bst_tcam_table);
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->bst_lbl_table);
 
  	devm_kfree(ice_hw_to_dev(psr->hw), psr);

}

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_parser.h

Quoted 12 lines

index 1f699ef12387..af73b19d09c1 100644

drivers/net/ethernet/intel/ice/ice_parser.h +1 -0
@@ -7,6 +7,7 @@
  #include "ice_metainit.h"
  #include "ice_imem.h"
  #include "ice_pg_cam.h"
+#include "ice_bst_tcam.h"
 
  struct ice_parser {
  	struct ice_hw *hw; /* pointer to the hardware structure */

drivers/net/ethernet/intel/ice/ice_parser.h struct ice_parser { · line 25

Quoted 2 lines
drivers/net/ethernet/intel/ice/ice_parser.h +0 -0
@@ -23,6 +24,10 @@ struct ice_parser {
  	struct ice_pg_nm_cam_item *pg_nm_cam_table;
  	/* load data from section ICE_SID_RXPARSER_NOMATCH_SPILL

*/

Review

Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_parser.h +4 -0
  	struct ice_pg_nm_cam_item *pg_nm_sp_cam_table;
+	/* load data from section ICE_SID_RXPARSER_BOOST_TCAM */
+	struct ice_bst_tcam_item *bst_tcam_table;
+	/* load data from section ICE_SID_LBL_RXPARSER_TMEM */
+	struct ice_lbl_item *bst_lbl_table;
  };
 
  int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_parser_util.h

drivers/net/ethernet/intel/ice/ice_parser_util.h void *ice_parser_create_table(struct ice_hw *hw,

Quoted 25 lines

index 59c67f1a1951..2f93f93c1e10 100644

drivers/net/ethernet/intel/ice/ice_parser_util.h +9 -0
@@ -7,11 +7,20 @@
  #include "ice_imem.h"
  #include "ice_metainit.h"
 
+struct ice_lbl_item {
+	u16 idx;
+	char label[64];
+};
+
  struct ice_pkg_sect_hdr {
  	__le16 count;
  	__le16 offset;
  };
 
+void ice_lbl_dump(struct ice_hw *hw, struct ice_lbl_item *item);
+void ice_parse_item_dflt(struct ice_hw *hw, u16 idx, void *item,
+			 void *data, int size);
+
  void *ice_parser_sect_item_get(u32 sect_type, void *section,
  			       u32 index, u32 *offset);
 
@@ -21,5 +30,6 @@ void *ice_parser_create_table(struct ice_hw *hw,

u32 sect_type,

Review

Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_parser_util.h +2 -1
  					       u32 index, u32 *offset),
  			      void (*parse_item)(struct ice_hw *hw, u16 idx,
  						 void *item, void *data,
-						 int size));
+						 int size),
+			      bool no_offset);
  #endif /* _ICE_PARSER_UTIL_H_ */
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_pg_cam.c

drivers/net/ethernet/intel/ice/ice_pg_cam.c struct ice_pg_cam_item

Quoted 4 lines

index 25b837ba684c..1c9a9e906f3e 100644

drivers/net/ethernet/intel/ice/ice_pg_cam.c +0 -0
@@ -254,7 +254,7 @@ struct ice_pg_cam_item

*ice_pg_cam_table_get(struct ice_hw *hw)

drivers/net/ethernet/intel/ice/ice_pg_cam.c struct ice_pg_cam_item

Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_pg_cam.c +1 -1
  					sizeof(struct ice_pg_cam_item),
  					ICE_PG_CAM_TABLE_SIZE,
  					ice_parser_sect_item_get,
-					_pg_cam_parse_item);
+					_pg_cam_parse_item, false);
  }
 
  /**
@@ -268,7 +268,7 @@ struct ice_pg_cam_item

*ice_pg_sp_cam_table_get(struct ice_hw *hw)

drivers/net/ethernet/intel/ice/ice_pg_cam.c struct ice_pg_nm_cam_item

Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_pg_cam.c +1 -1
  					sizeof(struct ice_pg_cam_item),
  					ICE_PG_SP_CAM_TABLE_SIZE,
  					ice_parser_sect_item_get,
-					_pg_sp_cam_parse_item);
+					_pg_sp_cam_parse_item, false);
  }
 
  /**
@@ -282,7 +282,7 @@ struct ice_pg_nm_cam_item

*ice_pg_nm_cam_table_get(struct ice_hw *hw)

drivers/net/ethernet/intel/ice/ice_pg_cam.c struct ice_pg_nm_cam_item · line 282

Quoted 1 line
drivers/net/ethernet/intel/ice/ice_pg_cam.c +0 -0
  					sizeof(struct

ice_pg_nm_cam_item),

drivers/net/ethernet/intel/ice/ice_pg_cam.c struct ice_pg_nm_cam_item

Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_pg_cam.c +1 -1
  					ICE_PG_NM_CAM_TABLE_SIZE,
  					ice_parser_sect_item_get,
-					_pg_nm_cam_parse_item);
+					_pg_nm_cam_parse_item, false);
  }
 
  /**
@@ -296,5 +296,5 @@ struct ice_pg_nm_cam_item

*ice_pg_nm_sp_cam_table_get(struct ice_hw *hw)

Quoted 9 lines

drivers/net/ethernet/intel/ice/ice_pg_cam.c struct ice_pg_nm_cam_item · line 296

Quoted 1 line
drivers/net/ethernet/intel/ice/ice_pg_cam.c +0 -0
  					sizeof(struct

ice_pg_nm_cam_item),

Quoted 1 line

ICE_PG_NM_SP_CAM_TABLE_SIZE,

drivers/net/ethernet/intel/ice/ice_pg_cam.c

Quoted 3 lines

ice_parser_sect_item_get,

drivers/net/ethernet/intel/ice/ice_pg_cam.c +1 -1
-					_pg_nm_sp_cam_parse_item);
+					_pg_nm_sp_cam_parse_item,

false);

Quoted 1 line
  }

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#18 lore raw

PATCH v2 6/15 ice: init ptype marker tcam table for parser

In reply to Junfeng Guo

Parse DDP section ICE_SID_RXPARSER_MARKER_PTYPE into an array of ice_ptype_mk_tcam_item.

---
 drivers/net/ethernet/intel/ice/ice_parser.c   | 11 ++++
 drivers/net/ethernet/intel/ice/ice_parser.h   |  3 ++
 drivers/net/ethernet/intel/ice/ice_ptype_mk.c | 53 +++++++++++++++++++
 drivers/net/ethernet/intel/ice/ice_ptype_mk.h | 17 ++++++
 4 files changed, 84 insertions(+)
 create mode 100644 drivers/net/ethernet/intel/ice/ice_ptype_mk.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_ptype_mk.h
drivers/net/ethernet/intel/ice/ice_parser.c +11 -0
index b280245dbdd4..970e379e074e 100644
@@ -12,6 +12,7 @@
 #define ICE_SID_RXPARSER_NOMATCH_CAM_ENTRY_SIZE		12
 #define ICE_SID_RXPARSER_NOMATCH_SPILL_ENTRY_SIZE	13
 #define ICE_SID_RXPARSER_BOOST_TCAM_ENTRY_SIZE		88
+#define ICE_SID_RXPARSER_MARKER_TYPE_ENTRY_SIZE		24
 
 #define ICE_SEC_LBL_DATA_OFFSET				2
 #define ICE_SID_LBL_ENTRY_SIZE				66
@@ -71,6 +72,9 @@ void *ice_parser_sect_item_get(u32 sect_type, void *section,
 		data_off = ICE_SEC_LBL_DATA_OFFSET;
 		size = ICE_SID_LBL_ENTRY_SIZE;
 		break;
+	case ICE_SID_RXPARSER_MARKER_PTYPE:
+		size = ICE_SID_RXPARSER_MARKER_TYPE_ENTRY_SIZE;
+		break;
 	default:
 		return NULL;
 	}
@@ -208,6 +212,12 @@ int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr)
 		goto err;
 	}
 
+	p->ptype_mk_tcam_table = ice_ptype_mk_tcam_table_get(hw);
+	if (!p->ptype_mk_tcam_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
 	*psr = p;
 	return 0;
 err:
@@ -229,6 +239,7 @@ void ice_parser_destroy(struct ice_parser *psr)
 	devm_kfree(ice_hw_to_dev(psr->hw), psr->pg_nm_sp_cam_table);
 	devm_kfree(ice_hw_to_dev(psr->hw), psr->bst_tcam_table);
 	devm_kfree(ice_hw_to_dev(psr->hw), psr->bst_lbl_table);
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->ptype_mk_tcam_table);
 
 	devm_kfree(ice_hw_to_dev(psr->hw), psr);
 }
drivers/net/ethernet/intel/ice/ice_parser.h +3 -0
index af73b19d09c1..1474a2337ad3 100644
@@ -8,6 +8,7 @@
 #include "ice_imem.h"
 #include "ice_pg_cam.h"
 #include "ice_bst_tcam.h"
+#include "ice_ptype_mk.h"
 
 struct ice_parser {
 	struct ice_hw *hw; /* pointer to the hardware structure */
@@ -28,6 +29,8 @@ struct ice_parser {
 	struct ice_bst_tcam_item *bst_tcam_table;
 	/* load data from section ICE_SID_LBL_RXPARSER_TMEM */
 	struct ice_lbl_item *bst_lbl_table;
+	/* load data from section ICE_SID_RXPARSER_MARKER_PTYPE */
+	struct ice_ptype_mk_tcam_item *ptype_mk_tcam_table;
 };
 
 int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
drivers/net/ethernet/intel/ice/ice_ptype_mk.c new file +53 -0

53 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_ptype_mk.h new file +17 -0
new file mode 100644
index 000000000000..b0a64a602641
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#ifndef _ICE_PTYPE_MK_H_
+#define _ICE_PTYPE_MK_H_
+
+struct ice_ptype_mk_tcam_item {
+	u16 address;
+	u16 ptype;
+	u8 key[10];
+	u8 key_inv[10];
+};
+
+void ice_ptype_mk_tcam_dump(struct ice_hw *hw,
+			    struct ice_ptype_mk_tcam_item *item);
+struct ice_ptype_mk_tcam_item *ice_ptype_mk_tcam_table_get(struct ice_hw *hw);
+#endif /* _ICE_PTYPE_MK_H_ */
Signature · 6 lines
2.25.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
#19 lore raw

PATCH v2 7/15 ice: init marker and protocol group table for parser

In reply to Junfeng Guo

Parse DDP section ICE_SID_RXPARSER_MARKER_GRP into an array of ice_mk_grp_item.
Parse DDP section ICE_SID_RXPARSER_PROTO_GRP into an array of ice_proto_grp_item.

---
 drivers/net/ethernet/intel/ice/ice_mk_grp.c   |  54 +++++++++
 drivers/net/ethernet/intel/ice/ice_mk_grp.h   |  14 +++
 drivers/net/ethernet/intel/ice/ice_parser.c   |  22 ++++
 drivers/net/ethernet/intel/ice/ice_parser.h   |   6 +
 .../net/ethernet/intel/ice/ice_proto_grp.c    | 105 ++++++++++++++++++
 .../net/ethernet/intel/ice/ice_proto_grp.h    |  23 ++++
 6 files changed, 224 insertions(+)
 create mode 100644 drivers/net/ethernet/intel/ice/ice_mk_grp.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_mk_grp.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_proto_grp.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_proto_grp.h
drivers/net/ethernet/intel/ice/ice_mk_grp.c new file +54 -0
new file mode 100644
index 000000000000..7068cfb832d6
@@ -0,0 +1,54 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#include "ice_common.h"
+#include "ice_parser_util.h"
+
+#define ICE_MK_GRP_TABLE_SIZE 128
+#define ICE_MK_COUNT_PER_GRP 8
+
+/**
+ * ice_mk_grp_dump - dump an marker group item info
+ * @hw: pointer to the hardware structure
+ * @item: marker group item to dump
+ */
+void ice_mk_grp_dump(struct ice_hw *hw, struct ice_mk_grp_item *item)
+{
+	int i;
+
+	dev_info(ice_hw_to_dev(hw), "index = %d\n", item->idx);
+	dev_info(ice_hw_to_dev(hw), "markers: ");
+	for (i = 0; i < ICE_MK_COUNT_PER_GRP; i++)
+		dev_info(ice_hw_to_dev(hw), "%d ", item->markers[i]);
+	dev_info(ice_hw_to_dev(hw), "\n");
+}
+
+static void _mk_grp_parse_item(struct ice_hw *hw, u16 idx, void *item,
+			       void *data, int size)
+{
+	struct ice_mk_grp_item *grp = item;
+	u8 *buf = data;
+	int i;
+
+	grp->idx = idx;
+
+	for (i = 0; i < ICE_MK_COUNT_PER_GRP; i++)
+		grp->markers[i] = buf[i];
+
+	if (hw->debug_mask & ICE_DBG_PARSER)
+		ice_mk_grp_dump(hw, grp);
+}
+
+/**
+ * ice_mk_grp_table_get - create a marker group table
+ * @hw: pointer to the hardware structure
+ */
+struct ice_mk_grp_item *ice_mk_grp_table_get(struct ice_hw *hw)
+{
+	return (struct ice_mk_grp_item *)
+		ice_parser_create_table(hw, ICE_SID_RXPARSER_MARKER_GRP,
+					sizeof(struct ice_mk_grp_item),
+					ICE_MK_GRP_TABLE_SIZE,
+					ice_parser_sect_item_get,
+					_mk_grp_parse_item, false);
+}
drivers/net/ethernet/intel/ice/ice_mk_grp.h new file +14 -0
new file mode 100644
index 000000000000..3c6c340a2a9a
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#ifndef _ICE_MK_GRP_H_
+#define _ICE_MK_GRP_H_
+
+struct ice_mk_grp_item {
+	int idx;
+	u8 markers[8];
+};
+
+void ice_mk_grp_dump(struct ice_hw *hw, struct ice_mk_grp_item *item);
+struct ice_mk_grp_item *ice_mk_grp_table_get(struct ice_hw *hw);
+#endif /* _ICE_MK_GRP_H_ */
drivers/net/ethernet/intel/ice/ice_parser.c +22 -0
index 970e379e074e..1185bf1cd249 100644
@@ -13,6 +13,8 @@
 #define ICE_SID_RXPARSER_NOMATCH_SPILL_ENTRY_SIZE	13
 #define ICE_SID_RXPARSER_BOOST_TCAM_ENTRY_SIZE		88
 #define ICE_SID_RXPARSER_MARKER_TYPE_ENTRY_SIZE		24
+#define ICE_SID_RXPARSER_MARKER_GRP_ENTRY_SIZE		8
+#define ICE_SID_RXPARSER_PROTO_GRP_ENTRY_SIZE		24
 
 #define ICE_SEC_LBL_DATA_OFFSET				2
 #define ICE_SID_LBL_ENTRY_SIZE				66
@@ -75,6 +77,12 @@ void *ice_parser_sect_item_get(u32 sect_type, void *section,
 	case ICE_SID_RXPARSER_MARKER_PTYPE:
 		size = ICE_SID_RXPARSER_MARKER_TYPE_ENTRY_SIZE;
 		break;
+	case ICE_SID_RXPARSER_MARKER_GRP:
+		size = ICE_SID_RXPARSER_MARKER_GRP_ENTRY_SIZE;
+		break;
+	case ICE_SID_RXPARSER_PROTO_GRP:
+		size = ICE_SID_RXPARSER_PROTO_GRP_ENTRY_SIZE;
+		break;
 	default:
 		return NULL;
 	}
@@ -218,6 +226,18 @@ int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr)
 		goto err;
 	}
 
+	p->mk_grp_table = ice_mk_grp_table_get(hw);
+	if (!p->mk_grp_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
+	p->proto_grp_table = ice_proto_grp_table_get(hw);
+	if (!p->proto_grp_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
 	*psr = p;
 	return 0;
 err:
@@ -240,6 +260,8 @@ void ice_parser_destroy(struct ice_parser *psr)
 	devm_kfree(ice_hw_to_dev(psr->hw), psr->bst_tcam_table);
 	devm_kfree(ice_hw_to_dev(psr->hw), psr->bst_lbl_table);
 	devm_kfree(ice_hw_to_dev(psr->hw), psr->ptype_mk_tcam_table);
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->mk_grp_table);
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->proto_grp_table);
 
 	devm_kfree(ice_hw_to_dev(psr->hw), psr);
 }
drivers/net/ethernet/intel/ice/ice_parser.h +6 -0
index 1474a2337ad3..3f17b15a1381 100644
@@ -9,6 +9,8 @@
 #include "ice_pg_cam.h"
 #include "ice_bst_tcam.h"
 #include "ice_ptype_mk.h"
+#include "ice_mk_grp.h"
+#include "ice_proto_grp.h"
 
 struct ice_parser {
 	struct ice_hw *hw; /* pointer to the hardware structure */
@@ -31,6 +33,10 @@ struct ice_parser {
 	struct ice_lbl_item *bst_lbl_table;
 	/* load data from section ICE_SID_RXPARSER_MARKER_PTYPE */
 	struct ice_ptype_mk_tcam_item *ptype_mk_tcam_table;
+	/* load data from section ICE_SID_RXPARSER_MARKER_GRP */
+	struct ice_mk_grp_item *mk_grp_table;
+	/* load data from section ICE_SID_RXPARSER_PROTO_GRP */
+	struct ice_proto_grp_item *proto_grp_table;
 };
 
 int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
drivers/net/ethernet/intel/ice/ice_proto_grp.c new file +105 -0

105 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_proto_grp.h new file +23 -0
new file mode 100644
index 000000000000..eb380489478e
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#ifndef _ICE_PROTO_GRP_H_
+#define _ICE_PROTO_GRP_H_
+
+#define ICE_PROTO_COUNT_PER_GRP 8
+#define ICE_PROTO_GRP_TABLE_SIZE 192
+
+struct ice_proto_off {
+	bool polarity; /* true: positive, false: nagtive */
+	u8 proto_id;
+	u16 offset;
+};
+
+struct ice_proto_grp_item {
+	u16 idx;
+	struct ice_proto_off po[ICE_PROTO_COUNT_PER_GRP];
+};
+
+void ice_proto_grp_dump(struct ice_hw *hw, struct ice_proto_grp_item *item);
+struct ice_proto_grp_item *ice_proto_grp_table_get(struct ice_hw *hw);
+#endif /* _ICE_PROTO_GRP_H_ */
Signature · 6 lines
2.25.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
#20 lore raw

Re: [Intel-wired-lan] [PATCH iwl-next v2 07/15] ice: init marker and protocol group table for parser

See inline comments...

Quoted 42 lines · Junfeng Guo

Parse DDP section ICE_SID_RXPARSER_MARKER_GRP into an array of ice_mk_grp_item.
Parse DDP section ICE_SID_RXPARSER_PROTO_GRP into an array of ice_proto_grp_item.

---
  drivers/net/ethernet/intel/ice/ice_mk_grp.c   |  54 +++++++++
  drivers/net/ethernet/intel/ice/ice_mk_grp.h   |  14 +++
  drivers/net/ethernet/intel/ice/ice_parser.c   |  22 ++++
  drivers/net/ethernet/intel/ice/ice_parser.h   |   6 +
  .../net/ethernet/intel/ice/ice_proto_grp.c    | 105 ++++++++++++++++++
  .../net/ethernet/intel/ice/ice_proto_grp.h    |  23 ++++
  6 files changed, 224 insertions(+)

create mode 100644 drivers/net/ethernet/intel/ice/ice_mk_grp.c create mode 100644 drivers/net/ethernet/intel/ice/ice_mk_grp.h create mode 100644 drivers/net/ethernet/intel/ice/ice_proto_grp.c create mode 100644 drivers/net/ethernet/intel/ice/ice_proto_grp.h

drivers/net/ethernet/intel/ice/ice_mk_grp.c new file +17 -0
new file mode 100644
index 000000000000..7068cfb832d6
@@ -0,0 +1,54 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#include "ice_common.h"
+#include "ice_parser_util.h"
+
+#define ICE_MK_GRP_TABLE_SIZE 128
+#define ICE_MK_COUNT_PER_GRP 8
+
+/**
+ * ice_mk_grp_dump - dump an marker group item info
+ * @hw: pointer to the hardware structure
+ * @item: marker group item to dump
+ */
+void ice_mk_grp_dump(struct ice_hw *hw, struct ice_mk_grp_item *item)
+{
+	int i;

drivers/net/ethernet/intel/ice/ice_mk_grp.c line 27

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_mk_grp.c new file +10 -0
+
+	dev_info(ice_hw_to_dev(hw), "index = %d\n", item->idx);
+	dev_info(ice_hw_to_dev(hw), "markers: ");
+	for (i = 0; i < ICE_MK_COUNT_PER_GRP; i++)
+		dev_info(ice_hw_to_dev(hw), "%d ", item->markers[i]);
+	dev_info(ice_hw_to_dev(hw), "\n");
+}
+
+static void _mk_grp_parse_item(struct ice_hw *hw, u16 idx, void *item,
+			       void *data, int size)

Please prefix also static local function names to avoid namespace pollution:

_mk_grp_parse_item -> ice_mk_grp_parse_item

This comment is also valid for another patches from this series..

Quoted 255 lines
drivers/net/ethernet/intel/ice/ice_mk_grp.c new file +27 -0
+{
+	struct ice_mk_grp_item *grp = item;
+	u8 *buf = data;
+	int i;
+
+	grp->idx = idx;
+
+	for (i = 0; i < ICE_MK_COUNT_PER_GRP; i++)
+		grp->markers[i] = buf[i];
+
+	if (hw->debug_mask & ICE_DBG_PARSER)
+		ice_mk_grp_dump(hw, grp);
+}
+
+/**
+ * ice_mk_grp_table_get - create a marker group table
+ * @hw: pointer to the hardware structure
+ */
+struct ice_mk_grp_item *ice_mk_grp_table_get(struct ice_hw *hw)
+{
+	return (struct ice_mk_grp_item *)
+		ice_parser_create_table(hw, ICE_SID_RXPARSER_MARKER_GRP,
+					sizeof(struct ice_mk_grp_item),
+					ICE_MK_GRP_TABLE_SIZE,
+					ice_parser_sect_item_get,
+					_mk_grp_parse_item, false);
+}
drivers/net/ethernet/intel/ice/ice_mk_grp.h new file +14 -0
new file mode 100644
index 000000000000..3c6c340a2a9a
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#ifndef _ICE_MK_GRP_H_
+#define _ICE_MK_GRP_H_
+
+struct ice_mk_grp_item {
+	int idx;
+	u8 markers[8];
+};
+
+void ice_mk_grp_dump(struct ice_hw *hw, struct ice_mk_grp_item *item);
+struct ice_mk_grp_item *ice_mk_grp_table_get(struct ice_hw *hw);
+#endif /* _ICE_MK_GRP_H_ */
drivers/net/ethernet/intel/ice/ice_parser.c +22 -0
index 970e379e074e..1185bf1cd249 100644
@@ -13,6 +13,8 @@
  #define ICE_SID_RXPARSER_NOMATCH_SPILL_ENTRY_SIZE	13
  #define ICE_SID_RXPARSER_BOOST_TCAM_ENTRY_SIZE		88
  #define ICE_SID_RXPARSER_MARKER_TYPE_ENTRY_SIZE		24
+#define ICE_SID_RXPARSER_MARKER_GRP_ENTRY_SIZE		8
+#define ICE_SID_RXPARSER_PROTO_GRP_ENTRY_SIZE		24
 
  #define ICE_SEC_LBL_DATA_OFFSET				2
  #define ICE_SID_LBL_ENTRY_SIZE				66
@@ -75,6 +77,12 @@ void *ice_parser_sect_item_get(u32 sect_type, void *section,
  	case ICE_SID_RXPARSER_MARKER_PTYPE:
  		size = ICE_SID_RXPARSER_MARKER_TYPE_ENTRY_SIZE;
  		break;
+	case ICE_SID_RXPARSER_MARKER_GRP:
+		size = ICE_SID_RXPARSER_MARKER_GRP_ENTRY_SIZE;
+		break;
+	case ICE_SID_RXPARSER_PROTO_GRP:
+		size = ICE_SID_RXPARSER_PROTO_GRP_ENTRY_SIZE;
+		break;
  	default:
  		return NULL;
  	}
@@ -218,6 +226,18 @@ int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr)
  		goto err;
  	}
 
+	p->mk_grp_table = ice_mk_grp_table_get(hw);
+	if (!p->mk_grp_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
+	p->proto_grp_table = ice_proto_grp_table_get(hw);
+	if (!p->proto_grp_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
  	*psr = p;
  	return 0;
  err:
@@ -240,6 +260,8 @@ void ice_parser_destroy(struct ice_parser *psr)
  	devm_kfree(ice_hw_to_dev(psr->hw), psr->bst_tcam_table);
  	devm_kfree(ice_hw_to_dev(psr->hw), psr->bst_lbl_table);
  	devm_kfree(ice_hw_to_dev(psr->hw), psr->ptype_mk_tcam_table);
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->mk_grp_table);
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->proto_grp_table);
 
  	devm_kfree(ice_hw_to_dev(psr->hw), psr);
  }
drivers/net/ethernet/intel/ice/ice_parser.h +6 -0
index 1474a2337ad3..3f17b15a1381 100644
@@ -9,6 +9,8 @@
  #include "ice_pg_cam.h"
  #include "ice_bst_tcam.h"
  #include "ice_ptype_mk.h"
+#include "ice_mk_grp.h"
+#include "ice_proto_grp.h"
 
  struct ice_parser {
  	struct ice_hw *hw; /* pointer to the hardware structure */
@@ -31,6 +33,10 @@ struct ice_parser {
  	struct ice_lbl_item *bst_lbl_table;
  	/* load data from section ICE_SID_RXPARSER_MARKER_PTYPE */
  	struct ice_ptype_mk_tcam_item *ptype_mk_tcam_table;
+	/* load data from section ICE_SID_RXPARSER_MARKER_GRP */
+	struct ice_mk_grp_item *mk_grp_table;
+	/* load data from section ICE_SID_RXPARSER_PROTO_GRP */
+	struct ice_proto_grp_item *proto_grp_table;
  };
 
  int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
drivers/net/ethernet/intel/ice/ice_proto_grp.c new file +105 -0
new file mode 100644
index 000000000000..781adbda0851
@@ -0,0 +1,105 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#include "ice_common.h"
+#include "ice_parser_util.h"
+
+static void _proto_off_dump(struct ice_hw *hw, struct ice_proto_off *po,
+			    int idx)
+{
+	dev_info(ice_hw_to_dev(hw), "proto %d\n", idx);
+	dev_info(ice_hw_to_dev(hw), "\tpolarity = %d\n", po->polarity);
+	dev_info(ice_hw_to_dev(hw), "\tproto_id = %d\n", po->proto_id);
+	dev_info(ice_hw_to_dev(hw), "\toffset = %d\n", po->offset);
+}
+
+/**
+ * ice_proto_grp_dump - dump a proto group item info
+ * @hw: pointer to the hardware structure
+ * @item: proto group item to dump
+ */
+void ice_proto_grp_dump(struct ice_hw *hw, struct ice_proto_grp_item *item)
+{
+	int i;
+
+	dev_info(ice_hw_to_dev(hw), "index = %d\n", item->idx);
+
+	for (i = 0; i < ICE_PROTO_COUNT_PER_GRP; i++)
+		_proto_off_dump(hw, &item->po[i], i);
+}
+
+/** The function parses a 22 bits Protocol entry with below format:
+ *  BIT 0:	Polarity of Protocol Offset (po->polarity)
+ *  BIT 1-8:	Protocol ID (po->proto_id)
+ *  BIT 9-11:	reserved
+ *  BIT 12-21:	Protocol Offset (po->offset)
+ */
+static void _proto_off_parse(struct ice_proto_off *po, u32 data)
+{
+	po->polarity = (data & 0x1) != 0;
+	po->proto_id = (u8)((data >> 1) & 0xff);
+	po->offset = (u16)((data >> 12) & 0x3ff);
+}
+
+/** The function parses a 192 bits Protocol Group Table entry with below
+ *  format:
+ *  BIT 0-21:	Protocol 0 (grp->po[0])
+ *  BIT 22-43:	Protocol 1 (grp->po[1])
+ *  BIT 44-65:	Protocol 2 (grp->po[2])
+ *  BIT 66-87:	Protocol 3 (grp->po[3])
+ *  BIT 88-109:	Protocol 4 (grp->po[4])
+ *  BIT 110-131:Protocol 5 (grp->po[5])
+ *  BIT 132-153:Protocol 6 (grp->po[6])
+ *  BIT 154-175:Protocol 7 (grp->po[7])
+ *  BIT 176-191:reserved
+ */
+static void _proto_grp_parse_item(struct ice_hw *hw, u16 idx, void *item,
+				  void *data, int size)
+{
+	struct ice_proto_grp_item *grp = item;
+	u8 *buf = data;
+	u32 d32;
+
+	grp->idx = idx;
+
+	d32 = *(u32 *)buf;
+	_proto_off_parse(&grp->po[0], d32);
+
+	d32 = (*(u32 *)&buf[2] >> 6);
+	_proto_off_parse(&grp->po[1], d32);
+
+	d32 = (*(u32 *)&buf[5] >> 4);
+	_proto_off_parse(&grp->po[2], d32);
+
+	d32 = (*(u32 *)&buf[8] >> 2);
+	_proto_off_parse(&grp->po[3], d32);
+
+	d32 = *(u32 *)&buf[11];
+	_proto_off_parse(&grp->po[4], d32);
+
+	d32 = (*(u32 *)&buf[13] >> 6);
+	_proto_off_parse(&grp->po[5], d32);
+
+	d32 = (*(u32 *)&buf[16] >> 4);
+	_proto_off_parse(&grp->po[6], d32);
+
+	d32 = (*(u32 *)&buf[19] >> 2);
+	_proto_off_parse(&grp->po[7], d32);
+
+	if (hw->debug_mask & ICE_DBG_PARSER)
+		ice_proto_grp_dump(hw, grp);
+}
+
+/**
+ * ice_proto_grp_table_get - create a proto group table
+ * @hw: pointer to the hardware structure
+ */
+struct ice_proto_grp_item *ice_proto_grp_table_get(struct ice_hw *hw)
+{
+	return (struct ice_proto_grp_item *)
+		ice_parser_create_table(hw, ICE_SID_RXPARSER_PROTO_GRP,
+					sizeof(struct ice_proto_grp_item),
+					ICE_PROTO_GRP_TABLE_SIZE,
+					ice_parser_sect_item_get,
+					_proto_grp_parse_item, false);
+}
drivers/net/ethernet/intel/ice/ice_proto_grp.h new file +13 -0
new file mode 100644
index 000000000000..eb380489478e
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#ifndef _ICE_PROTO_GRP_H_
+#define _ICE_PROTO_GRP_H_
+
+#define ICE_PROTO_COUNT_PER_GRP 8
+#define ICE_PROTO_GRP_TABLE_SIZE 192
+
+struct ice_proto_off {
+	bool polarity; /* true: positive, false: nagtive */
+	u8 proto_id;
+	u16 offset;

drivers/net/ethernet/intel/ice/ice_proto_grp.h line 23

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_proto_grp.h new file +10 -0
+};
+
+struct ice_proto_grp_item {
+	u16 idx;
+	struct ice_proto_off po[ICE_PROTO_COUNT_PER_GRP];
+};
+
+void ice_proto_grp_dump(struct ice_hw *hw, struct ice_proto_grp_item *item);
+struct ice_proto_grp_item *ice_proto_grp_table_get(struct ice_hw *hw);
+#endif /* _ICE_PROTO_GRP_H_ */

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#21 lore raw

Re: [Intel-wired-lan] [PATCH iwl-next v2 07/15] ice: init marker and protocol group table for parser

Quoted 70 lines

-----Original Message-----
From: Ivan Vecera <[email protected]>
Sent: Monday, July 24, 2023 19:02
To: Guo, Junfeng <[email protected]>; intel-wired- [email protected]
Cc: Zhang, Qi Z <[email protected]>; mschmidt <[email protected]>; poros <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH iwl-next v2 07/15] ice: init marker and protocol group table for parser

See inline comments...

Quoted 5 lines · Junfeng Guo

Parse DDP section ICE_SID_RXPARSER_MARKER_GRP into an array of ice_mk_grp_item.
Parse DDP section ICE_SID_RXPARSER_PROTO_GRP into an array of ice_proto_grp_item.

Quoted 7 lines
---
  drivers/net/ethernet/intel/ice/ice_mk_grp.c   |  54 +++++++++
  drivers/net/ethernet/intel/ice/ice_mk_grp.h   |  14 +++
  drivers/net/ethernet/intel/ice/ice_parser.c   |  22 ++++
  drivers/net/ethernet/intel/ice/ice_parser.h   |   6 +
  .../net/ethernet/intel/ice/ice_proto_grp.c    | 105

++++++++++++++++++

Review

Quoted 8 lines
  .../net/ethernet/intel/ice/ice_proto_grp.h    |  23 ++++
  6 files changed, 224 insertions(+)

create mode 100644 drivers/net/ethernet/intel/ice/ice_mk_grp.c create mode 100644 drivers/net/ethernet/intel/ice/ice_mk_grp.h create mode 100644 drivers/net/ethernet/intel/ice/ice_proto_grp.c create mode 100644 drivers/net/ethernet/intel/ice/ice_proto_grp.h

(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_mk_grp.c

Quoted 10 lines

new file mode 100644
index 000000000000..7068cfb832d6

drivers/net/ethernet/intel/ice/ice_mk_grp.c new file +5 -0
@@ -0,0 +1,54 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#include "ice_common.h"
+#include "ice_parser_util.h"

drivers/net/ethernet/intel/ice/ice_mk_grp.c line 15

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_mk_grp.c new file +10 -0
+
+#define ICE_MK_GRP_TABLE_SIZE 128
+#define ICE_MK_COUNT_PER_GRP 8
+
+/**
+ * ice_mk_grp_dump - dump an marker group item info
+ * @hw: pointer to the hardware structure
+ * @item: marker group item to dump
+ */
+void ice_mk_grp_dump(struct ice_hw *hw, struct ice_mk_grp_item

*item)

drivers/net/ethernet/intel/ice/ice_mk_grp.c

Quoted 11 lines
drivers/net/ethernet/intel/ice/ice_mk_grp.c new file +11 -0
+{
+	int i;
+
+	dev_info(ice_hw_to_dev(hw), "index = %d\n", item->idx);
+	dev_info(ice_hw_to_dev(hw), "markers: ");
+	for (i = 0; i < ICE_MK_COUNT_PER_GRP; i++)
+		dev_info(ice_hw_to_dev(hw), "%d ", item->markers[i]);
+	dev_info(ice_hw_to_dev(hw), "\n");
+}
+
+static void _mk_grp_parse_item(struct ice_hw *hw, u16 idx, void

*item,

Quoted 9 lines

drivers/net/ethernet/intel/ice/ice_mk_grp.c line 27

Quoted 1 line
drivers/net/ethernet/intel/ice/ice_mk_grp.c new file +1 -0
+			       void *data, int size)

Please prefix also static local function names to avoid namespace pollution:

_mk_grp_parse_item -> ice_mk_grp_parse_item

This comment is also valid for another patches from this series..

Sure, make sense! Will update in the coming version. Thanks!

Quoted 286 lines
Quoted 13 lines
drivers/net/ethernet/intel/ice/ice_mk_grp.c new file +12 -0
+{
+	struct ice_mk_grp_item *grp = item;
+	u8 *buf = data;
+	int i;
+
+	grp->idx = idx;
+
+	for (i = 0; i < ICE_MK_COUNT_PER_GRP; i++)
+		grp->markers[i] = buf[i];
+
+	if (hw->debug_mask & ICE_DBG_PARSER)
+		ice_mk_grp_dump(hw, grp);

drivers/net/ethernet/intel/ice/ice_mk_grp.c

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_mk_grp.c new file +10 -0
+}
+
+/**
+ * ice_mk_grp_table_get - create a marker group table
+ * @hw: pointer to the hardware structure
+ */
+struct ice_mk_grp_item *ice_mk_grp_table_get(struct ice_hw *hw)
+{
+	return (struct ice_mk_grp_item *)
+		ice_parser_create_table(hw,

ICE_SID_RXPARSER_MARKER_GRP,

Review

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_mk_grp.c new file +5 -0
+					sizeof(struct ice_mk_grp_item),
+					ICE_MK_GRP_TABLE_SIZE,
+					ice_parser_sect_item_get,
+					_mk_grp_parse_item, false);
+}
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_mk_grp.h

Quoted 7 lines

new file mode 100644
index 000000000000..3c6c340a2a9a

drivers/net/ethernet/intel/ice/ice_mk_grp.h new file +2 -0
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2018-2023 Intel Corporation */

drivers/net/ethernet/intel/ice/ice_mk_grp.h line 12

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_mk_grp.h new file +10 -0
+
+#ifndef _ICE_MK_GRP_H_
+#define _ICE_MK_GRP_H_
+
+struct ice_mk_grp_item {
+	int idx;
+	u8 markers[8];
+};
+
+void ice_mk_grp_dump(struct ice_hw *hw, struct ice_mk_grp_item

*item);

Review

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_mk_grp.h new file +2 -0
+struct ice_mk_grp_item *ice_mk_grp_table_get(struct ice_hw *hw);
+#endif /* _ICE_MK_GRP_H_ */
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_parser.c

drivers/net/ethernet/intel/ice/ice_parser.c line 14

Quoted 6 lines

index 970e379e074e..1185bf1cd249 100644

drivers/net/ethernet/intel/ice/ice_parser.c +0 -0
@@ -13,6 +13,8 @@
  #define ICE_SID_RXPARSER_NOMATCH_SPILL_ENTRY_SIZE	13
  #define ICE_SID_RXPARSER_BOOST_TCAM_ENTRY_SIZE
	88

drivers/net/ethernet/intel/ice/ice_parser.c line 15

Quoted 1 line
drivers/net/ethernet/intel/ice/ice_parser.c +0 -0
  #define ICE_SID_RXPARSER_MARKER_TYPE_ENTRY_SIZE
	24

drivers/net/ethernet/intel/ice/ice_parser.c line 16

Quoted 1 line
drivers/net/ethernet/intel/ice/ice_parser.c +1 -0
+#define ICE_SID_RXPARSER_MARKER_GRP_ENTRY_SIZE
	8

drivers/net/ethernet/intel/ice/ice_parser.c line 17

Quoted 1 line
drivers/net/ethernet/intel/ice/ice_parser.c +1 -0
+#define ICE_SID_RXPARSER_PROTO_GRP_ENTRY_SIZE
	24

drivers/net/ethernet/intel/ice/ice_parser.c void *ice_parser_sect_item_get(u32 sect_type,

Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_parser.c +0 -0
  #define ICE_SEC_LBL_DATA_OFFSET				2
  #define ICE_SID_LBL_ENTRY_SIZE				66
@@ -75,6 +77,12 @@ void *ice_parser_sect_item_get(u32 sect_type,

void *section,

drivers/net/ethernet/intel/ice/ice_parser.c int ice_parser_create(struct ice_hw *hw,

Quoted 13 lines
drivers/net/ethernet/intel/ice/ice_parser.c +6 -0
  	case ICE_SID_RXPARSER_MARKER_PTYPE:
  		size = ICE_SID_RXPARSER_MARKER_TYPE_ENTRY_SIZE;
  		break;
+	case ICE_SID_RXPARSER_MARKER_GRP:
+		size = ICE_SID_RXPARSER_MARKER_GRP_ENTRY_SIZE;
+		break;
+	case ICE_SID_RXPARSER_PROTO_GRP:
+		size = ICE_SID_RXPARSER_PROTO_GRP_ENTRY_SIZE;
+		break;
  	default:
  		return NULL;
  	}
@@ -218,6 +226,18 @@ int ice_parser_create(struct ice_hw *hw,

struct ice_parser **psr)

Quoted 28 lines
drivers/net/ethernet/intel/ice/ice_parser.c +14 -0
  		goto err;
  	}
 
+	p->mk_grp_table = ice_mk_grp_table_get(hw);
+	if (!p->mk_grp_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
+	p->proto_grp_table = ice_proto_grp_table_get(hw);
+	if (!p->proto_grp_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
  	*psr = p;
  	return 0;
  err:
@@ -240,6 +260,8 @@ void ice_parser_destroy(struct ice_parser *psr)
  	devm_kfree(ice_hw_to_dev(psr->hw), psr->bst_tcam_table);
  	devm_kfree(ice_hw_to_dev(psr->hw), psr->bst_lbl_table);
  	devm_kfree(ice_hw_to_dev(psr->hw), psr-
 ptype_mk_tcam_table);
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->mk_grp_table);
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->proto_grp_table);
 
  	devm_kfree(ice_hw_to_dev(psr->hw), psr);

}

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_parser.h

Review

Quoted 24 lines

index 1474a2337ad3..3f17b15a1381 100644

drivers/net/ethernet/intel/ice/ice_parser.h +6 -0
@@ -9,6 +9,8 @@
  #include "ice_pg_cam.h"
  #include "ice_bst_tcam.h"
  #include "ice_ptype_mk.h"
+#include "ice_mk_grp.h"
+#include "ice_proto_grp.h"
 
  struct ice_parser {
  	struct ice_hw *hw; /* pointer to the hardware structure */
@@ -31,6 +33,10 @@ struct ice_parser {
  	struct ice_lbl_item *bst_lbl_table;
  	/* load data from section ICE_SID_RXPARSER_MARKER_PTYPE */
  	struct ice_ptype_mk_tcam_item *ptype_mk_tcam_table;
+	/* load data from section ICE_SID_RXPARSER_MARKER_GRP */
+	struct ice_mk_grp_item *mk_grp_table;
+	/* load data from section ICE_SID_RXPARSER_PROTO_GRP */
+	struct ice_proto_grp_item *proto_grp_table;
  };
 
  int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_proto_grp.c

drivers/net/ethernet/intel/ice/ice_proto_grp.c line 7

Quoted 12 lines

new file mode 100644
index 000000000000..781adbda0851

drivers/net/ethernet/intel/ice/ice_proto_grp.c new file +7 -0
@@ -0,0 +1,105 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#include "ice_common.h"
+#include "ice_parser_util.h"
+
+static void _proto_off_dump(struct ice_hw *hw, struct ice_proto_off

*po,

Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_proto_grp.c new file +4 -0
+			    int idx)
+{
+	dev_info(ice_hw_to_dev(hw), "proto %d\n", idx);
+	dev_info(ice_hw_to_dev(hw), "\tpolarity = %d\n", po->polarity);

drivers/net/ethernet/intel/ice/ice_proto_grp.c

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_proto_grp.c new file +10 -0
+	dev_info(ice_hw_to_dev(hw), "\tproto_id = %d\n", po->proto_id);
+	dev_info(ice_hw_to_dev(hw), "\toffset = %d\n", po->offset);
+}
+
+/**
+ * ice_proto_grp_dump - dump a proto group item info
+ * @hw: pointer to the hardware structure
+ * @item: proto group item to dump
+ */
+void ice_proto_grp_dump(struct ice_hw *hw, struct

ice_proto_grp_item *item)

Quoted 13 lines
drivers/net/ethernet/intel/ice/ice_proto_grp.c new file +13 -0
+{
+	int i;
+
+	dev_info(ice_hw_to_dev(hw), "index = %d\n", item->idx);
+
+	for (i = 0; i < ICE_PROTO_COUNT_PER_GRP; i++)
+		_proto_off_dump(hw, &item->po[i], i);
+}
+
+/** The function parses a 22 bits Protocol entry with below format:
+ *  BIT 0:	Polarity of Protocol Offset (po->polarity)
+ *  BIT 1-8:	Protocol ID (po->proto_id)
+ *  BIT 9-11:	reserved

drivers/net/ethernet/intel/ice/ice_proto_grp.c

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_proto_grp.c new file +10 -0
+ *  BIT 12-21:	Protocol Offset (po->offset)
+ */
+static void _proto_off_parse(struct ice_proto_off *po, u32 data)
+{
+	po->polarity = (data & 0x1) != 0;
+	po->proto_id = (u8)((data >> 1) & 0xff);
+	po->offset = (u16)((data >> 12) & 0x3ff);
+}
+
+/** The function parses a 192 bits Protocol Group Table entry with

below

drivers/net/ethernet/intel/ice/ice_proto_grp.c

Quoted 12 lines
drivers/net/ethernet/intel/ice/ice_proto_grp.c new file +12 -0
+ *  format:
+ *  BIT 0-21:	Protocol 0 (grp->po[0])
+ *  BIT 22-43:	Protocol 1 (grp->po[1])
+ *  BIT 44-65:	Protocol 2 (grp->po[2])
+ *  BIT 66-87:	Protocol 3 (grp->po[3])
+ *  BIT 88-109:	Protocol 4 (grp->po[4])
+ *  BIT 110-131:Protocol 5 (grp->po[5])
+ *  BIT 132-153:Protocol 6 (grp->po[6])
+ *  BIT 154-175:Protocol 7 (grp->po[7])
+ *  BIT 176-191:reserved
+ */
+static void _proto_grp_parse_item(struct ice_hw *hw, u16 idx, void

*item,

Quoted 31 lines
drivers/net/ethernet/intel/ice/ice_proto_grp.c new file +31 -0
+				  void *data, int size)
+{
+	struct ice_proto_grp_item *grp = item;
+	u8 *buf = data;
+	u32 d32;
+
+	grp->idx = idx;
+
+	d32 = *(u32 *)buf;
+	_proto_off_parse(&grp->po[0], d32);
+
+	d32 = (*(u32 *)&buf[2] >> 6);
+	_proto_off_parse(&grp->po[1], d32);
+
+	d32 = (*(u32 *)&buf[5] >> 4);
+	_proto_off_parse(&grp->po[2], d32);
+
+	d32 = (*(u32 *)&buf[8] >> 2);
+	_proto_off_parse(&grp->po[3], d32);
+
+	d32 = *(u32 *)&buf[11];
+	_proto_off_parse(&grp->po[4], d32);
+
+	d32 = (*(u32 *)&buf[13] >> 6);
+	_proto_off_parse(&grp->po[5], d32);
+
+	d32 = (*(u32 *)&buf[16] >> 4);
+	_proto_off_parse(&grp->po[6], d32);
+
+	d32 = (*(u32 *)&buf[19] >> 2);
+	_proto_off_parse(&grp->po[7], d32);

drivers/net/ethernet/intel/ice/ice_proto_grp.c

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_proto_grp.c new file +10 -0
+
+	if (hw->debug_mask & ICE_DBG_PARSER)
+		ice_proto_grp_dump(hw, grp);
+}
+
+/**
+ * ice_proto_grp_table_get - create a proto group table
+ * @hw: pointer to the hardware structure
+ */
+struct ice_proto_grp_item *ice_proto_grp_table_get(struct ice_hw

*hw)

drivers/net/ethernet/intel/ice/ice_proto_grp.c

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_proto_grp.c new file +3 -0
+{
+	return (struct ice_proto_grp_item *)
+		ice_parser_create_table(hw,

ICE_SID_RXPARSER_PROTO_GRP,

drivers/net/ethernet/intel/ice/ice_proto_grp.c line 101

Quoted 1 line
drivers/net/ethernet/intel/ice/ice_proto_grp.c new file +1 -0
+					sizeof(struct

ice_proto_grp_item),

Review

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_proto_grp.c new file +4 -0
+					ICE_PROTO_GRP_TABLE_SIZE,
+					ice_parser_sect_item_get,
+					_proto_grp_parse_item, false);
+}
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_proto_grp.h

Quoted 16 lines

new file mode 100644
index 000000000000..eb380489478e

drivers/net/ethernet/intel/ice/ice_proto_grp.h new file +11 -0
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#ifndef _ICE_PROTO_GRP_H_
+#define _ICE_PROTO_GRP_H_
+
+#define ICE_PROTO_COUNT_PER_GRP 8
+#define ICE_PROTO_GRP_TABLE_SIZE 192
+
+struct ice_proto_off {
+	bool polarity; /* true: positive, false: nagtive */

drivers/net/ethernet/intel/ice/ice_proto_grp.h line 21

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_proto_grp.h new file +10 -0
+	u8 proto_id;
+	u16 offset;
+};
+
+struct ice_proto_grp_item {
+	u16 idx;
+	struct ice_proto_off po[ICE_PROTO_COUNT_PER_GRP];
+};
+
+void ice_proto_grp_dump(struct ice_hw *hw, struct

ice_proto_grp_item *item);

Quoted 3 lines

drivers/net/ethernet/intel/ice/ice_proto_grp.h line 22

Quoted 1 line
drivers/net/ethernet/intel/ice/ice_proto_grp.h new file +1 -0
+struct ice_proto_grp_item *ice_proto_grp_table_get(struct ice_hw

*hw);

Quoted 1 line
drivers/net/ethernet/intel/ice/ice_proto_grp.h new file +1 -0
+#endif /* _ICE_PROTO_GRP_H_ */

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#22 lore raw

PATCH v2 8/15 ice: init flag redirect table for parser

In reply to Junfeng Guo

Parse DDP section ICE_SID_RXPARSER_FLAG_REDIR into an array of ice_flag_rd_item.

---
 drivers/net/ethernet/intel/ice/ice_ddp.h    |  1 +
 drivers/net/ethernet/intel/ice/ice_flg_rd.c | 52 +++++++++++++++++++++
 drivers/net/ethernet/intel/ice/ice_flg_rd.h | 15 ++++++
 drivers/net/ethernet/intel/ice/ice_parser.c | 11 +++++
 drivers/net/ethernet/intel/ice/ice_parser.h |  3 ++
 5 files changed, 82 insertions(+)
 create mode 100644 drivers/net/ethernet/intel/ice/ice_flg_rd.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_flg_rd.h
drivers/net/ethernet/intel/ice/ice_ddp.h +1 -0
index da5dfeed3b1f..45beed8b4415 100644
@@ -261,6 +261,7 @@ struct ice_meta_sect {
 #define ICE_SID_CDID_KEY_BUILDER_PE 87
 #define ICE_SID_CDID_REDIR_PE 88
 
+#define ICE_SID_RXPARSER_FLAG_REDIR	97
 /* Label Metadata section IDs */
 #define ICE_SID_LBL_FIRST 0x80000010
 #define ICE_SID_LBL_RXPARSER_TMEM 0x80000018
drivers/net/ethernet/intel/ice/ice_flg_rd.c new file +52 -0

52 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_flg_rd.h new file +15 -0
new file mode 100644
index 000000000000..b53e35a46796
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#ifndef _ICE_FLG_RD_H_
+#define _ICE_FLG_RD_H_
+
+struct ice_flg_rd_item {
+	u16 idx;
+	bool expose;
+	u8 intr_flg_id;
+};
+
+void ice_flg_rd_dump(struct ice_hw *hw, struct ice_flg_rd_item *item);
+struct ice_flg_rd_item *ice_flg_rd_table_get(struct ice_hw *hw);
+#endif /* _ICE_FLG_RD_H_ */
drivers/net/ethernet/intel/ice/ice_parser.c +11 -0
index 1185bf1cd249..e8f047c08cd9 100644
@@ -15,6 +15,7 @@
 #define ICE_SID_RXPARSER_MARKER_TYPE_ENTRY_SIZE		24
 #define ICE_SID_RXPARSER_MARKER_GRP_ENTRY_SIZE		8
 #define ICE_SID_RXPARSER_PROTO_GRP_ENTRY_SIZE		24
+#define ICE_SID_RXPARSER_FLAG_REDIR_ENTRY_SIZE		1
 
 #define ICE_SEC_LBL_DATA_OFFSET				2
 #define ICE_SID_LBL_ENTRY_SIZE				66
@@ -83,6 +84,9 @@ void *ice_parser_sect_item_get(u32 sect_type, void *section,
 	case ICE_SID_RXPARSER_PROTO_GRP:
 		size = ICE_SID_RXPARSER_PROTO_GRP_ENTRY_SIZE;
 		break;
+	case ICE_SID_RXPARSER_FLAG_REDIR:
+		size = ICE_SID_RXPARSER_FLAG_REDIR_ENTRY_SIZE;
+		break;
 	default:
 		return NULL;
 	}
@@ -238,6 +242,12 @@ int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr)
 		goto err;
 	}
 
+	p->flg_rd_table = ice_flg_rd_table_get(hw);
+	if (!p->flg_rd_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
 	*psr = p;
 	return 0;
 err:
@@ -262,6 +272,7 @@ void ice_parser_destroy(struct ice_parser *psr)
 	devm_kfree(ice_hw_to_dev(psr->hw), psr->ptype_mk_tcam_table);
 	devm_kfree(ice_hw_to_dev(psr->hw), psr->mk_grp_table);
 	devm_kfree(ice_hw_to_dev(psr->hw), psr->proto_grp_table);
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->flg_rd_table);
 
 	devm_kfree(ice_hw_to_dev(psr->hw), psr);
 }
drivers/net/ethernet/intel/ice/ice_parser.h +3 -0
index 3f17b15a1381..5eed54d9d189 100644
@@ -11,6 +11,7 @@
 #include "ice_ptype_mk.h"
 #include "ice_mk_grp.h"
 #include "ice_proto_grp.h"
+#include "ice_flg_rd.h"
 
 struct ice_parser {
 	struct ice_hw *hw; /* pointer to the hardware structure */
@@ -37,6 +38,8 @@ struct ice_parser {
 	struct ice_mk_grp_item *mk_grp_table;
 	/* load data from section ICE_SID_RXPARSER_PROTO_GRP */
 	struct ice_proto_grp_item *proto_grp_table;
+	/* load data from section ICE_SID_RXPARSER_FLAG_REDIR */
+	struct ice_flg_rd_item *flg_rd_table;
 };
 
 int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
Signature · 6 lines
2.25.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
#23 lore raw

PATCH v2 9/15 ice: init XLT key builder for parser

In reply to Junfeng Guo

Parse below DDP section into struct ice_xlt_kb:
ICE_SID_XLT_KEY_BUILDER_SW
ICE_SID_XLT_KEY_BUILDER_ACL
ICE_SID_XLT_KEY_BUILDER_FD
ICE_SID_XLT_KEY_BUILDER_RSS

---
 drivers/net/ethernet/intel/ice/ice_parser.c |  28 +++
 drivers/net/ethernet/intel/ice/ice_parser.h |   9 +
 drivers/net/ethernet/intel/ice/ice_xlt_kb.c | 191 ++++++++++++++++++++
 drivers/net/ethernet/intel/ice/ice_xlt_kb.h |  32 ++++
 4 files changed, 260 insertions(+)
 create mode 100644 drivers/net/ethernet/intel/ice/ice_xlt_kb.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_xlt_kb.h
drivers/net/ethernet/intel/ice/ice_parser.c +28 -0
index e8f047c08cd9..507b06f1fcfe 100644
@@ -248,6 +248,30 @@ int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr)
 		goto err;
 	}
 
+	p->xlt_kb_sw = ice_xlt_kb_get_sw(hw);
+	if (!p->xlt_kb_sw) {
+		status = -EINVAL;
+		goto err;
+	}
+
+	p->xlt_kb_acl = ice_xlt_kb_get_acl(hw);
+	if (!p->xlt_kb_acl) {
+		status = -EINVAL;
+		goto err;
+	}
+
+	p->xlt_kb_fd = ice_xlt_kb_get_fd(hw);
+	if (!p->xlt_kb_fd) {
+		status = -EINVAL;
+		goto err;
+	}
+
+	p->xlt_kb_rss = ice_xlt_kb_get_rss(hw);
+	if (!p->xlt_kb_rss) {
+		status = -EINVAL;
+		goto err;
+	}
+
 	*psr = p;
 	return 0;
 err:
@@ -273,6 +297,10 @@ void ice_parser_destroy(struct ice_parser *psr)
 	devm_kfree(ice_hw_to_dev(psr->hw), psr->mk_grp_table);
 	devm_kfree(ice_hw_to_dev(psr->hw), psr->proto_grp_table);
 	devm_kfree(ice_hw_to_dev(psr->hw), psr->flg_rd_table);
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->xlt_kb_sw);
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->xlt_kb_acl);
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->xlt_kb_fd);
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->xlt_kb_rss);
 
 	devm_kfree(ice_hw_to_dev(psr->hw), psr);
 }
drivers/net/ethernet/intel/ice/ice_parser.h +9 -0
index 5eed54d9d189..8222e738d493 100644
@@ -12,6 +12,7 @@
 #include "ice_mk_grp.h"
 #include "ice_proto_grp.h"
 #include "ice_flg_rd.h"
+#include "ice_xlt_kb.h"
 
 struct ice_parser {
 	struct ice_hw *hw; /* pointer to the hardware structure */
@@ -40,6 +41,14 @@ struct ice_parser {
 	struct ice_proto_grp_item *proto_grp_table;
 	/* load data from section ICE_SID_RXPARSER_FLAG_REDIR */
 	struct ice_flg_rd_item *flg_rd_table;
+	/* load data from section ICE_SID_XLT_KEY_BUILDER_SW */
+	struct ice_xlt_kb *xlt_kb_sw;
+	/* load data from section ICE_SID_XLT_KEY_BUILDER_ACL */
+	struct ice_xlt_kb *xlt_kb_acl;
+	/* load data from section ICE_SID_XLT_KEY_BUILDER_FD */
+	struct ice_xlt_kb *xlt_kb_fd;
+	/* load data from section ICE_SID_XLT_KEY_BUILDER_RSS */
+	struct ice_xlt_kb *xlt_kb_rss;
 };
 
 int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
drivers/net/ethernet/intel/ice/ice_xlt_kb.c new file +191 -0

191 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_xlt_kb.h new file +32 -0
new file mode 100644
index 000000000000..f15c3d8f3695
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#ifndef _ICE_XLT_KB_H_
+#define _ICE_XLT_KB_H_
+
+#define ICE_XLT_KB_TBL_CNT 8
+#define ICE_XLT_KB_FLAG0_14_CNT 15
+
+struct ice_xlt_kb_entry {
+	u8 xlt1_ad_sel;
+	u8 xlt2_ad_sel;
+	u16 flg0_14_sel[ICE_XLT_KB_FLAG0_14_CNT];
+	u8 xlt1_md_sel;
+	u8 xlt2_md_sel;
+};
+
+struct ice_xlt_kb {
+	u8 xlt1_pm;
+	u8 xlt2_pm;
+	u8 prof_id_pm;
+	u64 flag15;
+
+	struct ice_xlt_kb_entry entries[ICE_XLT_KB_TBL_CNT];
+};
+
+void ice_xlt_kb_dump(struct ice_hw *hw, struct ice_xlt_kb *kb);
+struct ice_xlt_kb *ice_xlt_kb_get_sw(struct ice_hw *hw);
+struct ice_xlt_kb *ice_xlt_kb_get_acl(struct ice_hw *hw);
+struct ice_xlt_kb *ice_xlt_kb_get_fd(struct ice_hw *hw);
+struct ice_xlt_kb *ice_xlt_kb_get_rss(struct ice_hw *hw);
+#endif /* _ICE_XLT_KB_H */
Signature · 6 lines
2.25.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
#24 lore raw

PATCH v2 10/15 ice: add parser runtime skeleton

In reply to Junfeng Guo

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

---
 drivers/net/ethernet/intel/ice/ice_parser.c   | 39 ++++++++
 drivers/net/ethernet/intel/ice/ice_parser.h   | 24 +++++
 .../net/ethernet/intel/ice/ice_parser_rt.c    | 95 +++++++++++++++++++
 .../net/ethernet/intel/ice/ice_parser_rt.h    | 27 ++++++
 4 files changed, 185 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
drivers/net/ethernet/intel/ice/ice_parser.c +39 -0
index 507b06f1fcfe..eddbc80d71fa 100644
@@ -304,3 +304,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);
+}
drivers/net/ethernet/intel/ice/ice_parser.h +24 -0
index 8222e738d493..189fe254bfb4 100644
@@ -13,6 +13,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 */
@@ -49,8 +50,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 */
 };
 
 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 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 */
+};
+
+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_ */
drivers/net/ethernet/intel/ice/ice_parser_rt.c new file +95 -0

95 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_parser_rt.h new file +27 -0
new file mode 100644
index 000000000000..2c909a8dc01e
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2018-2023 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;
+int ice_parser_rt_execute(struct ice_parser_rt *rt,
+			  struct ice_parser_result *rslt);
+#endif /* _ICE_PARSER_RT_H_ */
Signature · 6 lines
2.25.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
#25 lore raw

PATCH v2 11/15 ice: add internal help functions

In reply to Junfeng Guo

Add below internal helper function:

- [ice_bst_tcam_match]:
to perform ternary match on boost TCAM.

- [ice_pg_cam_match]:
to perform parse graph key match in cam table.

- [ice_pg_nm_cam_match]:
to perform parse graph key no match in cam table.

- [ice_ptype_mk_tcam_match]:
to perform ptype markers match in tcam table.

- [ice_flg_redirect]:
to redirect parser flags to packet flags.

- [ice_xlt_kb_flg_get]:
to aggregate 64 bit packet flag into 16 bit key builder flags.

---
 drivers/net/ethernet/intel/ice/ice_bst_tcam.c | 22 ++++++
 drivers/net/ethernet/intel/ice/ice_bst_tcam.h |  3 +
 drivers/net/ethernet/intel/ice/ice_flg_rd.c   | 23 ++++++
 drivers/net/ethernet/intel/ice/ice_flg_rd.h   |  1 +
 drivers/net/ethernet/intel/ice/ice_parser.h   |  1 +
 drivers/net/ethernet/intel/ice/ice_pg_cam.c   | 76 +++++++++++++++++++
 drivers/net/ethernet/intel/ice/ice_pg_cam.h   |  6 ++
 drivers/net/ethernet/intel/ice/ice_ptype_mk.c | 22 ++++++
 drivers/net/ethernet/intel/ice/ice_ptype_mk.h |  3 +
 drivers/net/ethernet/intel/ice/ice_tmatch.h   | 43 +++++++++++
 drivers/net/ethernet/intel/ice/ice_xlt_kb.c   | 27 +++++++
 drivers/net/ethernet/intel/ice/ice_xlt_kb.h   |  1 +
 12 files changed, 228 insertions(+)
 create mode 100644 drivers/net/ethernet/intel/ice/ice_tmatch.h
drivers/net/ethernet/intel/ice/ice_bst_tcam.c +22 -0
index 24e793580637..bd3ebc8a5f5b 100644
@@ -245,3 +245,25 @@ struct ice_lbl_item *ice_bst_lbl_table_get(struct ice_hw *hw)
 					ice_parser_sect_item_get,
 					_parse_lbl_item, true);
 }
+
+/**
+ * ice_bst_tcam_match - match a pattern on the boost tcam table
+ * @tcam_table: boost tcam table to search
+ * @pat: pattern to match
+ */
+struct ice_bst_tcam_item *
+ice_bst_tcam_match(struct ice_bst_tcam_item *tcam_table, u8 *pat)
+{
+	int i;
+
+	for (i = 0; i < ICE_BST_TCAM_TABLE_SIZE; i++) {
+		struct ice_bst_tcam_item *item = &tcam_table[i];
+
+		if (item->hit_idx_grp == 0)
+			continue;
+		if (ice_ternary_match(item->key, item->key_inv, pat, 20))
+			return item;
+	}
+
+	return NULL;
+}
drivers/net/ethernet/intel/ice/ice_bst_tcam.h +3 -0
index 9d78a140bc02..7b69f3b88da5 100644
@@ -24,4 +24,7 @@ void ice_bst_tcam_dump(struct ice_hw *hw, struct ice_bst_tcam_item *item);
 struct ice_bst_tcam_item *ice_bst_tcam_table_get(struct ice_hw *hw);
 
 struct ice_lbl_item *ice_bst_lbl_table_get(struct ice_hw *hw);
+
+struct ice_bst_tcam_item *
+ice_bst_tcam_match(struct ice_bst_tcam_item *tcam_table, u8 *pat);
 #endif /*_ICE_BST_TCAM_H_ */
drivers/net/ethernet/intel/ice/ice_flg_rd.c +23 -0
index 827b659e2332..e5afd026e8a9 100644
@@ -50,3 +50,26 @@ struct ice_flg_rd_item *ice_flg_rd_table_get(struct ice_hw *hw)
 					ice_parser_sect_item_get,
 					_flg_rd_parse_item, false);
 }
+
+/**
+ * ice_flg_redirect - redirect a parser flag to packet flag
+ * @table: flag redirect table
+ * @psr_flg: parser flag to redirect
+ */
+u64 ice_flg_redirect(struct ice_flg_rd_item *table, u64 psr_flg)
+{
+	u64 flg = 0;
+	int i;
+
+	for (i = 0; i < 64; i++) {
+		struct ice_flg_rd_item *item = &table[i];
+
+		if (!item->expose)
+			continue;
+
+		if (psr_flg & (1ul << item->intr_flg_id))
+			flg |= (1ul << i);
+	}
+
+	return flg;
+}
drivers/net/ethernet/intel/ice/ice_flg_rd.h +1 -0
index b53e35a46796..0843f42c2a6a 100644
@@ -12,4 +12,5 @@ struct ice_flg_rd_item {
 
 void ice_flg_rd_dump(struct ice_hw *hw, struct ice_flg_rd_item *item);
 struct ice_flg_rd_item *ice_flg_rd_table_get(struct ice_hw *hw);
+u64 ice_flg_redirect(struct ice_flg_rd_item *table, u64 psr_flg);
 #endif /* _ICE_FLG_RD_H_ */
drivers/net/ethernet/intel/ice/ice_parser.h +1 -0
index 189fe254bfb4..d4de0796a292 100644
@@ -14,6 +14,7 @@
 #include "ice_flg_rd.h"
 #include "ice_xlt_kb.h"
 #include "ice_parser_rt.h"
+#include "ice_tmatch.h"
 
 struct ice_parser {
 	struct ice_hw *hw; /* pointer to the hardware structure */
drivers/net/ethernet/intel/ice/ice_pg_cam.c +76 -0

79 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_pg_cam.h +6 -0
index 1d794fa519d6..86a4434605eb 100644
@@ -64,4 +64,10 @@ struct ice_pg_cam_item *ice_pg_sp_cam_table_get(struct ice_hw *hw);
 
 struct ice_pg_nm_cam_item *ice_pg_nm_cam_table_get(struct ice_hw *hw);
 struct ice_pg_nm_cam_item *ice_pg_nm_sp_cam_table_get(struct ice_hw *hw);
+
+struct ice_pg_cam_item *ice_pg_cam_match(struct ice_pg_cam_item *table,
+					 int size, struct ice_pg_cam_key *key);
+struct ice_pg_nm_cam_item *
+ice_pg_nm_cam_match(struct ice_pg_nm_cam_item *table, int size,
+		    struct ice_pg_cam_key *key);
 #endif /* _ICE_PG_CAM_H_ */
drivers/net/ethernet/intel/ice/ice_ptype_mk.c +22 -0
index 36877f47a074..be6ebfd03386 100644
@@ -51,3 +51,25 @@ struct ice_ptype_mk_tcam_item *ice_ptype_mk_tcam_table_get(struct ice_hw *hw)
 					ice_parser_sect_item_get,
 					_parse_ptype_mk_tcam_item, true);
 }
+
+/**
+ * ice_ptype_mk_tcam_match - match a pattern on a ptype marker tcam table
+ * @table: ptype marker tcam table to search
+ * @pat: pattern to match
+ * @len: length of the pattern
+ */
+struct ice_ptype_mk_tcam_item *
+ice_ptype_mk_tcam_match(struct ice_ptype_mk_tcam_item *table,
+			u8 *pat, int len)
+{
+	int i;
+
+	for (i = 0; i < ICE_PTYPE_MK_TCAM_TABLE_SIZE; i++) {
+		struct ice_ptype_mk_tcam_item *item = &table[i];
+
+		if (ice_ternary_match(item->key, item->key_inv, pat, len))
+			return item;
+	}
+
+	return NULL;
+}
drivers/net/ethernet/intel/ice/ice_ptype_mk.h +3 -0
index b0a64a602641..8254fbcd2d9f 100644
@@ -14,4 +14,7 @@ struct ice_ptype_mk_tcam_item {
 void ice_ptype_mk_tcam_dump(struct ice_hw *hw,
 			    struct ice_ptype_mk_tcam_item *item);
 struct ice_ptype_mk_tcam_item *ice_ptype_mk_tcam_table_get(struct ice_hw *hw);
+struct ice_ptype_mk_tcam_item *
+ice_ptype_mk_tcam_match(struct ice_ptype_mk_tcam_item *table,
+			u8 *pat, int len);
 #endif /* _ICE_PTYPE_MK_H_ */
drivers/net/ethernet/intel/ice/ice_tmatch.h new file +43 -0

43 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_xlt_kb.c +27 -0
index 146602dd6b57..4c686a553869 100644
@@ -189,3 +189,30 @@ struct ice_xlt_kb *ice_xlt_kb_get_rss(struct ice_hw *hw)
 {
 	return _xlt_kb_get(hw, ICE_SID_XLT_KEY_BUILDER_RSS);
 }
+
+/**
+ * ice_xlt_kb_flag_get - aggregate 64 bits packet flag into 16 bits xlt flag
+ * @kb: xlt key build
+ * @pkt_flag: 64 bits packet flag
+ */
+u16 ice_xlt_kb_flag_get(struct ice_xlt_kb *kb, u64 pkt_flag)
+{
+	struct ice_xlt_kb_entry *entry = &kb->entries[0];
+	u16 flg = 0;
+	int i;
+
+	/* check flag 15 */
+	if (kb->flag15 & pkt_flag)
+		flg = (u16)(1u << 15);
+
+	/* check flag 0 - 14 */
+	for (i = 0; i < 15; i++) {
+		/* only check first entry */
+		u16 idx = (u16)(entry->flg0_14_sel[i] & 0x3f);
+
+		if (pkt_flag & (1ul << idx))
+			flg |=  (u16)(1u << i);
+	}
+
+	return flg;
+}
drivers/net/ethernet/intel/ice/ice_xlt_kb.h +1 -0
index f15c3d8f3695..97f7567c6a56 100644
@@ -29,4 +29,5 @@ struct ice_xlt_kb *ice_xlt_kb_get_sw(struct ice_hw *hw);
 struct ice_xlt_kb *ice_xlt_kb_get_acl(struct ice_hw *hw);
 struct ice_xlt_kb *ice_xlt_kb_get_fd(struct ice_hw *hw);
 struct ice_xlt_kb *ice_xlt_kb_get_rss(struct ice_hw *hw);
+u16 ice_xlt_kb_flag_get(struct ice_xlt_kb *kb, u64 pkt_flag);
 #endif /* _ICE_XLT_KB_H */
Signature · 6 lines
2.25.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
#26 lore raw

PATCH v2 12/15 ice: add parser execution main loop

In reply to Junfeng Guo

Implement function ice_parser_rt_execute which perform the main loop of the parser.
Also include the Parser Library files into ice Makefile.

---
 drivers/net/ethernet/intel/ice/Makefile       |  11 +
 .../net/ethernet/intel/ice/ice_parser_rt.c    | 779 +++++++++++++++++-
 .../net/ethernet/intel/ice/ice_parser_rt.h    |  20 +
 3 files changed, 806 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/ice/Makefile +11 -0
index 5d89392f969b..a0c3d4804300 100644
@@ -26,6 +26,17 @@ ice-y := ice_main.o	\
 	 ice_vlan_mode.o \
 	 ice_flex_pipe.o \
 	 ice_flow.o	\
+	 ice_parser.o    \
+	 ice_imem.o      \
+	 ice_pg_cam.o    \
+	 ice_metainit.o  \
+	 ice_bst_tcam.o  \
+	 ice_ptype_mk.o  \
+	 ice_mk_grp.o    \
+	 ice_proto_grp.o \
+	 ice_flg_rd.o    \
+	 ice_xlt_kb.o    \
+	 ice_parser_rt.o \
 	 ice_idc.o	\
 	 ice_devlink.o	\
 	 ice_ddp.o	\
drivers/net/ethernet/intel/ice/ice_parser_rt.c +775 -4

805 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_parser_rt.h +20 -0
index 2c909a8dc01e..6f0764745758 100644
@@ -9,12 +9,32 @@ struct ice_parser_ctx;
 #define ICE_PARSER_MAX_PKT_LEN 504
 #define ICE_PARSER_GPR_NUM 128
 
+struct ice_gpr_pu {
+	bool gpr_val_upd[128]; /* flag to indicate if GRP needs to be updated */
+	u16 gpr_val[128];
+	u64 flg_msk;
+	u64 flg_val;
+	u16 err_msk;
+	u16 err_val;
+};
+
 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;
+	u8 bst_key[20];
+	struct ice_pg_cam_key pg_key;
+	struct ice_alu *alu0;
+	struct ice_alu *alu1;
+	struct ice_alu *alu2;
+	struct ice_pg_cam_action *action;
+	u8 pg;
+	struct ice_gpr_pu pu;
+	u8 markers[9]; /* 8 * 9 = 72 bits*/
+	bool protocols[256];
+	u16 offsets[256];
 };
 
 void ice_parser_rt_reset(struct ice_parser_rt *rt);
Signature · 6 lines
2.25.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
#27 lore raw

PATCH v2 13/15 ice: support double vlan mode configure for parser

In reply to Junfeng Guo

Add API ice_parser_dvm_set to support turn on/off parser's double vlan mode.

---
 drivers/net/ethernet/intel/ice/ice_bst_tcam.c | 28 ++++++++++++++++++
 drivers/net/ethernet/intel/ice/ice_bst_tcam.h |  4 +++
 drivers/net/ethernet/intel/ice/ice_parser.c   | 29 +++++++++++++++++++
 drivers/net/ethernet/intel/ice/ice_parser.h   |  1 +
 4 files changed, 62 insertions(+)
drivers/net/ethernet/intel/ice/ice_bst_tcam.c +28 -0
index bd3ebc8a5f5b..e29c7d6c554b 100644
@@ -267,3 +267,31 @@ ice_bst_tcam_match(struct ice_bst_tcam_item *tcam_table, u8 *pat)
 
 	return NULL;
 }
+
+static bool _start_with(const char *prefix, const char *string)
+{
+	int len1 = strlen(prefix);
+	int len2 = strlen(string);
+
+	if (len2 < len1)
+		return false;
+
+	return !memcmp(prefix, string, len1);
+}
+
+struct ice_bst_tcam_item *
+ice_bst_tcam_search(struct ice_bst_tcam_item *tcam_table,
+		    struct ice_lbl_item *lbl_table,
+		    const char *prefix, u16 *start)
+{
+	u16 i = *start;
+
+	for (; i < ICE_BST_TCAM_TABLE_SIZE; i++) {
+		if (_start_with(prefix, lbl_table[i].label)) {
+			*start = i;
+			return &tcam_table[lbl_table[i].idx];
+		}
+	}
+
+	return NULL;
+}
drivers/net/ethernet/intel/ice/ice_bst_tcam.h +4 -0
index 7b69f3b88da5..873ff42fcdb7 100644
@@ -27,4 +27,8 @@ struct ice_lbl_item *ice_bst_lbl_table_get(struct ice_hw *hw);
 
 struct ice_bst_tcam_item *
 ice_bst_tcam_match(struct ice_bst_tcam_item *tcam_table, u8 *pat);
+struct ice_bst_tcam_item *
+ice_bst_tcam_search(struct ice_bst_tcam_item *tcam_table,
+		    struct ice_lbl_item *lbl_table,
+		    const char *prefix, u16 *start);
 #endif /*_ICE_BST_TCAM_H_ */
drivers/net/ethernet/intel/ice/ice_parser.c +29 -0
index eddbc80d71fa..33b649a4644a 100644
@@ -343,3 +343,32 @@ void ice_parser_result_dump(struct ice_hw *hw, struct ice_parser_result *rslt)
 	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);
 }
+
+static void _bst_vm_set(struct ice_parser *psr, const char *prefix, bool on)
+{
+	u16 i = 0;
+
+	while (true) {
+		struct ice_bst_tcam_item *item;
+
+		item = ice_bst_tcam_search(psr->bst_tcam_table,
+					   psr->bst_lbl_table,
+					   prefix, &i);
+		if (!item)
+			break;
+		item->key[0] = (u8)(on ? 0xff : 0xfe);
+		item->key_inv[0] = (u8)(on ? 0xff : 0xfe);
+		i++;
+	}
+}
+
+/**
+ * ice_parser_dvm_set - configure double vlan mode for parser
+ * @psr: pointer to a parser instance
+ * @on: true to turn on; false to turn off
+ */
+void ice_parser_dvm_set(struct ice_parser *psr, bool on)
+{
+	_bst_vm_set(psr, "BOOST_MAC_VLAN_DVM", on);
+	_bst_vm_set(psr, "BOOST_MAC_VLAN_SVM", !on);
+}
drivers/net/ethernet/intel/ice/ice_parser.h +1 -0
index d4de0796a292..02ea2ef5fc91 100644
@@ -56,6 +56,7 @@ struct ice_parser {
 
 int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
 void ice_parser_destroy(struct ice_parser *psr);
+void ice_parser_dvm_set(struct ice_parser *psr, bool on);
 
 struct ice_parser_proto_off {
 	u8 proto_id; /* hardware protocol ID */
Signature · 6 lines
2.25.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
#28 lore raw

Re: [Intel-wired-lan] [PATCH iwl-next v2 13/15] ice: support double vlan mode configure for parser

See inline comments...

Quoted 20 lines · Junfeng Guo

Add API ice_parser_dvm_set to support turn on/off parser's double vlan mode.

---
  drivers/net/ethernet/intel/ice/ice_bst_tcam.c | 28 ++++++++++++++++++
  drivers/net/ethernet/intel/ice/ice_bst_tcam.h |  4 +++
  drivers/net/ethernet/intel/ice/ice_parser.c   | 29 +++++++++++++++++++
  drivers/net/ethernet/intel/ice/ice_parser.h   |  1 +
  4 files changed, 62 insertions(+)
drivers/net/ethernet/intel/ice/ice_bst_tcam.c +1 -0
index bd3ebc8a5f5b..e29c7d6c554b 100644
@@ -267,3 +267,31 @@ ice_bst_tcam_match(struct ice_bst_tcam_item *tcam_table, u8 *pat)
 
  	return NULL;
  }
+

drivers/net/ethernet/intel/ice/ice_bst_tcam.c ice_bst_tcam_match(struct ice_bst_tcam_item *tcam_table, u8 *pat) · line 280

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_bst_tcam.c +10 -0
+static bool _start_with(const char *prefix, const char *string)
+{
+	int len1 = strlen(prefix);
+	int len2 = strlen(string);
+
+	if (len2 < len1)
+		return false;
+
+	return !memcmp(prefix, string, len1);
+}

Isn't there any existing implementation for this general purpose function? You can use strstarts() function instead of your own implementation.

Quoted 72 lines
drivers/net/ethernet/intel/ice/ice_bst_tcam.c +17 -0
+
+struct ice_bst_tcam_item *
+ice_bst_tcam_search(struct ice_bst_tcam_item *tcam_table,
+		    struct ice_lbl_item *lbl_table,
+		    const char *prefix, u16 *start)
+{
+	u16 i = *start;
+
+	for (; i < ICE_BST_TCAM_TABLE_SIZE; i++) {
+		if (_start_with(prefix, lbl_table[i].label)) {
+			*start = i;
+			return &tcam_table[lbl_table[i].idx];
+		}
+	}
+
+	return NULL;
+}
drivers/net/ethernet/intel/ice/ice_bst_tcam.h +4 -0
index 7b69f3b88da5..873ff42fcdb7 100644
@@ -27,4 +27,8 @@ struct ice_lbl_item *ice_bst_lbl_table_get(struct ice_hw *hw);
 
  struct ice_bst_tcam_item *
  ice_bst_tcam_match(struct ice_bst_tcam_item *tcam_table, u8 *pat);
+struct ice_bst_tcam_item *
+ice_bst_tcam_search(struct ice_bst_tcam_item *tcam_table,
+		    struct ice_lbl_item *lbl_table,
+		    const char *prefix, u16 *start);
  #endif /*_ICE_BST_TCAM_H_ */
drivers/net/ethernet/intel/ice/ice_parser.c +29 -0
index eddbc80d71fa..33b649a4644a 100644
@@ -343,3 +343,32 @@ void ice_parser_result_dump(struct ice_hw *hw, struct ice_parser_result *rslt)
  	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);
  }
+
+static void _bst_vm_set(struct ice_parser *psr, const char *prefix, bool on)
+{
+	u16 i = 0;
+
+	while (true) {
+		struct ice_bst_tcam_item *item;
+
+		item = ice_bst_tcam_search(psr->bst_tcam_table,
+					   psr->bst_lbl_table,
+					   prefix, &i);
+		if (!item)
+			break;
+		item->key[0] = (u8)(on ? 0xff : 0xfe);
+		item->key_inv[0] = (u8)(on ? 0xff : 0xfe);
+		i++;
+	}
+}
+
+/**
+ * ice_parser_dvm_set - configure double vlan mode for parser
+ * @psr: pointer to a parser instance
+ * @on: true to turn on; false to turn off
+ */
+void ice_parser_dvm_set(struct ice_parser *psr, bool on)
+{
+	_bst_vm_set(psr, "BOOST_MAC_VLAN_DVM", on);
+	_bst_vm_set(psr, "BOOST_MAC_VLAN_SVM", !on);
+}
drivers/net/ethernet/intel/ice/ice_parser.h +0 -0
index d4de0796a292..02ea2ef5fc91 100644

drivers/net/ethernet/intel/ice/ice_parser.h struct ice_parser { · line 62

Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_parser.h +1 -0
@@ -56,6 +56,7 @@ struct ice_parser {
 
  int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
  void ice_parser_destroy(struct ice_parser *psr);
+void ice_parser_dvm_set(struct ice_parser *psr, bool on);
 
  struct ice_parser_proto_off {
  	u8 proto_id; /* hardware protocol ID */

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#29 lore raw

Re: [Intel-wired-lan] [PATCH iwl-next v2 13/15] ice: support double vlan mode configure for parser

Quoted 36 lines

-----Original Message-----
From: Ivan Vecera <[email protected]>
Sent: Monday, July 24, 2023 19:10
To: Guo, Junfeng <[email protected]>; intel-wired- [email protected]
Cc: Zhang, Qi Z <[email protected]>; mschmidt <[email protected]>; poros <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH iwl-next v2 13/15] ice: support double vlan mode configure for parser

See inline comments...

Quoted 6 lines · Junfeng Guo

Add API ice_parser_dvm_set to support turn on/off parser's double vlan mode.

---
  drivers/net/ethernet/intel/ice/ice_bst_tcam.c | 28

++++++++++++++++++

Quoted 2 lines
  drivers/net/ethernet/intel/ice/ice_bst_tcam.h |  4 +++
  drivers/net/ethernet/intel/ice/ice_parser.c   | 29

+++++++++++++++++++

Review

Quoted 4 lines
  drivers/net/ethernet/intel/ice/ice_parser.h   |  1 +
  4 files changed, 62 insertions(+)
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_bst_tcam.c

drivers/net/ethernet/intel/ice/ice_bst_tcam.c ice_bst_tcam_match(struct

Quoted 4 lines

index bd3ebc8a5f5b..e29c7d6c554b 100644

drivers/net/ethernet/intel/ice/ice_bst_tcam.c +0 -0
@@ -267,3 +267,31 @@ ice_bst_tcam_match(struct

ice_bst_tcam_item *tcam_table, u8 *pat)

Quoted 1 line
Quoted 16 lines

drivers/net/ethernet/intel/ice/ice_bst_tcam.c ice_bst_tcam_match(struct ice_bst_tcam_item *tcam_table, u8 *pat) · line 280

Quoted 13 lines
  	return NULL;
  }
drivers/net/ethernet/intel/ice/ice_bst_tcam.c +11 -0
+
+static bool _start_with(const char *prefix, const char *string)
+{
+	int len1 = strlen(prefix);
+	int len2 = strlen(string);
+
+	if (len2 < len1)
+		return false;
+
+	return !memcmp(prefix, string, len1);
+}

Isn't there any existing implementation for this general purpose function? You can use strstarts() function instead of your own implementation.

Sure, will update in the coming version! Thanks for the knowledge!

Quoted 82 lines

Review

Quoted 19 lines
drivers/net/ethernet/intel/ice/ice_bst_tcam.c +17 -0
+
+struct ice_bst_tcam_item *
+ice_bst_tcam_search(struct ice_bst_tcam_item *tcam_table,
+		    struct ice_lbl_item *lbl_table,
+		    const char *prefix, u16 *start)
+{
+	u16 i = *start;
+
+	for (; i < ICE_BST_TCAM_TABLE_SIZE; i++) {
+		if (_start_with(prefix, lbl_table[i].label)) {
+			*start = i;
+			return &tcam_table[lbl_table[i].idx];
+		}
+	}
+
+	return NULL;
+}
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_bst_tcam.h

drivers/net/ethernet/intel/ice/ice_bst_tcam.h struct ice_lbl_item *ice_bst_lbl_table_get(struct

Quoted 4 lines

index 7b69f3b88da5..873ff42fcdb7 100644

drivers/net/ethernet/intel/ice/ice_bst_tcam.h +0 -0
@@ -27,4 +27,8 @@ struct ice_lbl_item *ice_bst_lbl_table_get(struct

ice_hw *hw);

Review

Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_bst_tcam.h +4 -0
  struct ice_bst_tcam_item *
  ice_bst_tcam_match(struct ice_bst_tcam_item *tcam_table, u8 *pat);
+struct ice_bst_tcam_item *
+ice_bst_tcam_search(struct ice_bst_tcam_item *tcam_table,
+		    struct ice_lbl_item *lbl_table,
+		    const char *prefix, u16 *start);
  #endif /*_ICE_BST_TCAM_H_ */
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_parser.c

drivers/net/ethernet/intel/ice/ice_parser.c void ice_parser_result_dump(struct ice_hw

Quoted 4 lines

index eddbc80d71fa..33b649a4644a 100644

drivers/net/ethernet/intel/ice/ice_parser.c +0 -0
@@ -343,3 +343,32 @@ void ice_parser_result_dump(struct ice_hw

*hw, struct ice_parser_result *rslt)

drivers/net/ethernet/intel/ice/ice_parser.c

Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_parser.c +0 -0
  	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);
}

drivers/net/ethernet/intel/ice/ice_parser.c +2 -0
+
+static void _bst_vm_set(struct ice_parser *psr, const char *prefix, bool

on)

Review

Quoted 28 lines
drivers/net/ethernet/intel/ice/ice_parser.c +27 -0
+{
+	u16 i = 0;
+
+	while (true) {
+		struct ice_bst_tcam_item *item;
+
+		item = ice_bst_tcam_search(psr->bst_tcam_table,
+					   psr->bst_lbl_table,
+					   prefix, &i);
+		if (!item)
+			break;
+		item->key[0] = (u8)(on ? 0xff : 0xfe);
+		item->key_inv[0] = (u8)(on ? 0xff : 0xfe);
+		i++;
+	}
+}
+
+/**
+ * ice_parser_dvm_set - configure double vlan mode for parser
+ * @psr: pointer to a parser instance
+ * @on: true to turn on; false to turn off
+ */
+void ice_parser_dvm_set(struct ice_parser *psr, bool on)
+{
+	_bst_vm_set(psr, "BOOST_MAC_VLAN_DVM", on);
+	_bst_vm_set(psr, "BOOST_MAC_VLAN_SVM", !on);
+}
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_parser.h

Quoted 5 lines

index d4de0796a292..02ea2ef5fc91 100644

drivers/net/ethernet/intel/ice/ice_parser.h +0 -0
@@ -56,6 +56,7 @@ struct ice_parser {
 
Quoted 6 lines

drivers/net/ethernet/intel/ice/ice_parser.h struct ice_parser { · line 62

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_parser.h +1 -0
  int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
  void ice_parser_destroy(struct ice_parser *psr);
+void ice_parser_dvm_set(struct ice_parser *psr, bool on);
 
  struct ice_parser_proto_off {
  	u8 proto_id; /* hardware protocol ID */

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#30 lore raw

Re: [Intel-wired-lan] [PATCH iwl-next v2 13/15] ice: support double vlan mode configure for parser

Quoted 53 lines · Junfeng
Quoted 36 lines

-----Original Message-----
From: Ivan Vecera <[email protected]>
Sent: Monday, July 24, 2023 19:10
To: Guo, Junfeng <[email protected]>; intel-wired- [email protected]
Cc: Zhang, Qi Z <[email protected]>; mschmidt <[email protected]>; poros <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH iwl-next v2 13/15] ice: support double vlan mode configure for parser

See inline comments...

Quoted 6 lines · Junfeng Guo

Add API ice_parser_dvm_set to support turn on/off parser's double vlan mode.

---
   drivers/net/ethernet/intel/ice/ice_bst_tcam.c | 28

++++++++++++++++++

Quoted 2 lines
   drivers/net/ethernet/intel/ice/ice_bst_tcam.h |  4 +++
   drivers/net/ethernet/intel/ice/ice_parser.c   | 29

+++++++++++++++++++

Review

Quoted 4 lines
   drivers/net/ethernet/intel/ice/ice_parser.h   |  1 +
   4 files changed, 62 insertions(+)
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_bst_tcam.c

drivers/net/ethernet/intel/ice/ice_bst_tcam.c ice_bst_tcam_match(struct

Quoted 4 lines

index bd3ebc8a5f5b..e29c7d6c554b 100644

drivers/net/ethernet/intel/ice/ice_bst_tcam.c +0 -0
@@ -267,3 +267,31 @@ ice_bst_tcam_match(struct

ice_bst_tcam_item *tcam_table, u8 *pat)

Quoted 1 line
Quoted 16 lines

drivers/net/ethernet/intel/ice/ice_bst_tcam.c ice_bst_tcam_match(struct ice_bst_tcam_item *tcam_table, u8 *pat) · line 280

Quoted 13 lines
   	return NULL;
   }
drivers/net/ethernet/intel/ice/ice_bst_tcam.c +11 -0
+
+static bool _start_with(const char *prefix, const char *string)
+{
+	int len1 = strlen(prefix);
+	int len2 = strlen(string);
+
+	if (len2 < len1)
+		return false;
+
+	return !memcmp(prefix, string, len1);
+}

Isn't there any existing implementation for this general purpose function? You can use strstarts() function instead of your own implementation.

Quoted 2 lines

Sure, will update in the coming version! Thanks for the knowledge!

Thank you,

Ivan

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#31 lore raw

PATCH v2 14/15 ice: add tunnel port support for parser

In reply to Junfeng Guo

UDP tunnel can be added/deleted for vxlan, geneve, ecpri through below APIs:
ice_parser_vxlan_tunnel_set ice_parser_geneve_tunnel_set ice_parser_ecpri_tunnel_set

---
 drivers/net/ethernet/intel/ice/ice_parser.c | 76 +++++++++++++++++++++
 drivers/net/ethernet/intel/ice/ice_parser.h |  6 ++
 2 files changed, 82 insertions(+)
drivers/net/ethernet/intel/ice/ice_parser.c +76 -0
index 33b649a4644a..1ca0886e6590 100644
@@ -372,3 +372,79 @@ void ice_parser_dvm_set(struct ice_parser *psr, bool on)
 	_bst_vm_set(psr, "BOOST_MAC_VLAN_DVM", on);
 	_bst_vm_set(psr, "BOOST_MAC_VLAN_SVM", !on);
 }
+
+static int
+_tunnel_port_set(struct ice_parser *psr, const char *prefix, u16 udp_port,
+		 bool on)
+{
+	u8 *buf = (u8 *)&udp_port;
+	u16 i = 0;
+
+	while (true) {
+		struct ice_bst_tcam_item *item;
+
+		item = ice_bst_tcam_search(psr->bst_tcam_table,
+					   psr->bst_lbl_table,
+					   prefix, &i);
+		if (!item)
+			break;
+
+		/* found empty slot to add */
+		if (on && item->key[16] == 0xfe && item->key_inv[16] == 0xfe) {
+			item->key_inv[15] = buf[0];
+			item->key_inv[16] = buf[1];
+			item->key[15] = (u8)(0xff - buf[0]);
+			item->key[16] = (u8)(0xff - buf[1]);
+
+			return 0;
+		/* found a matched slot to delete */
+		} else if (!on && (item->key_inv[15] == buf[0] ||
+			   item->key_inv[16] == buf[1])) {
+			item->key_inv[15] = 0xff;
+			item->key_inv[16] = 0xfe;
+			item->key[15] = 0xff;
+			item->key[16] = 0xfe;
+
+			return 0;
+		}
+		i++;
+	}
+
+	return -EINVAL;
+}
+
+/**
+ * ice_parser_vxlan_tunnel_set - configure vxlan tunnel for parser
+ * @psr: pointer to a parser instance
+ * @udp_port: vxlan tunnel port in UDP header
+ * @on: true to turn on; false to turn off
+ */
+int ice_parser_vxlan_tunnel_set(struct ice_parser *psr,
+				u16 udp_port, bool on)
+{
+	return _tunnel_port_set(psr, "TNL_VXLAN", udp_port, on);
+}
+
+/**
+ * ice_parser_geneve_tunnel_set - configure geneve tunnel for parser
+ * @psr: pointer to a parser instance
+ * @udp_port: geneve tunnel port in UDP header
+ * @on: true to turn on; false to turn off
+ */
+int ice_parser_geneve_tunnel_set(struct ice_parser *psr,
+				 u16 udp_port, bool on)
+{
+	return _tunnel_port_set(psr, "TNL_GENEVE", udp_port, on);
+}
+
+/**
+ * ice_parser_ecpri_tunnel_set - configure ecpri tunnel for parser
+ * @psr: pointer to a parser instance
+ * @udp_port: ecpri tunnel port in UDP header
+ * @on: true to turn on; false to turn off
+ */
+int ice_parser_ecpri_tunnel_set(struct ice_parser *psr,
+				u16 udp_port, bool on)
+{
+	return _tunnel_port_set(psr, "TNL_UDP_ECPRI", udp_port, on);
+}
drivers/net/ethernet/intel/ice/ice_parser.h +6 -0
index 02ea2ef5fc91..432d47031298 100644
@@ -57,6 +57,12 @@ struct ice_parser {
 int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
 void ice_parser_destroy(struct ice_parser *psr);
 void ice_parser_dvm_set(struct ice_parser *psr, bool on);
+int ice_parser_vxlan_tunnel_set(struct ice_parser *psr,
+				u16 udp_port, bool on);
+int ice_parser_geneve_tunnel_set(struct ice_parser *psr,
+				 u16 udp_port, bool on);
+int ice_parser_ecpri_tunnel_set(struct ice_parser *psr,
+				u16 udp_port, bool on);
 
 struct ice_parser_proto_off {
 	u8 proto_id; /* hardware protocol ID */
Signature · 6 lines
2.25.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
#32 lore raw

PATCH v2 15/15 ice: add API for parser profile initialization

In reply to Junfeng Guo

Add API ice_parser_profile_init to init a parser profile base on a parser result and a mask buffer. The ice_parser_profile can feed to low level FXP engine to create HW profile / field vector directly.

---
 drivers/net/ethernet/intel/ice/ice_parser.c | 113 ++++++++++++++++++++
 drivers/net/ethernet/intel/ice/ice_parser.h |  24 +++++
 2 files changed, 137 insertions(+)
drivers/net/ethernet/intel/ice/ice_parser.c +113 -0
index 1ca0886e6590..ad42dcd31cb3 100644
@@ -448,3 +448,116 @@ int ice_parser_ecpri_tunnel_set(struct ice_parser *psr,
 {
 	return _tunnel_port_set(psr, "TNL_UDP_ECPRI", udp_port, on);
 }
+
+static bool _nearest_proto_id(struct ice_parser_result *rslt, u16 offset,
+			      u8 *proto_id, u16 *proto_off)
+{
+	u16 dist = 0xffff;
+	u8 p = 0;
+	int i;
+
+	for (i = 0; i < rslt->po_num; i++) {
+		if (offset < rslt->po[i].offset)
+			continue;
+		if (offset - rslt->po[i].offset < dist) {
+			p = rslt->po[i].proto_id;
+			dist = offset - rslt->po[i].offset;
+		}
+	}
+
+	if (dist % 2)
+		return false;
+
+	*proto_id = p;
+	*proto_off = dist;
+
+	return true;
+}
+
+/** default flag mask to cover GTP_EH_PDU, GTP_EH_PDU_LINK and TUN2
+ * In future, the flag masks should learn from DDP
+ */
+#define ICE_KEYBUILD_FLAG_MASK_DEFAULT_SW	0x4002
+#define ICE_KEYBUILD_FLAG_MASK_DEFAULT_ACL	0x0000
+#define ICE_KEYBUILD_FLAG_MASK_DEFAULT_FD	0x6080
+#define ICE_KEYBUILD_FLAG_MASK_DEFAULT_RSS	0x6010
+
+/**
+ * ice_parser_profile_init  - initialize a FXP profile base on parser result
+ * @rslt: a instance of a parser result
+ * @pkt_buf: packet data buffer
+ * @msk_buf: packet mask buffer
+ * @buf_len: packet length
+ * @blk: FXP pipeline stage
+ * @prefix_match: match protocol stack exactly or only prefix
+ * @prof: input/output parameter to save the profile
+ */
+int ice_parser_profile_init(struct ice_parser_result *rslt,
+			    const u8 *pkt_buf, const u8 *msk_buf,
+			    int buf_len, enum ice_block blk,
+			    bool prefix_match,
+			    struct ice_parser_profile *prof)
+{
+	u8 proto_id = 0xff;
+	u16 proto_off = 0;
+	u16 off;
+
+	memset(prof, 0, sizeof(*prof));
+	set_bit(rslt->ptype, prof->ptypes);
+	if (blk == ICE_BLK_SW) {
+		prof->flags = rslt->flags_sw;
+		prof->flags_msk = ICE_KEYBUILD_FLAG_MASK_DEFAULT_SW;
+	} else if (blk == ICE_BLK_ACL) {
+		prof->flags = rslt->flags_acl;
+		prof->flags_msk = ICE_KEYBUILD_FLAG_MASK_DEFAULT_ACL;
+	} else if (blk == ICE_BLK_FD) {
+		prof->flags = rslt->flags_fd;
+		prof->flags_msk = ICE_KEYBUILD_FLAG_MASK_DEFAULT_FD;
+	} else if (blk == ICE_BLK_RSS) {
+		prof->flags = rslt->flags_rss;
+		prof->flags_msk = ICE_KEYBUILD_FLAG_MASK_DEFAULT_RSS;
+	} else {
+		return -EINVAL;
+	}
+
+	for (off = 0; off < buf_len - 1; off++) {
+		if (msk_buf[off] == 0 && msk_buf[off + 1] == 0)
+			continue;
+		if (!_nearest_proto_id(rslt, off, &proto_id, &proto_off))
+			continue;
+		if (prof->fv_num >= 32)
+			return -EINVAL;
+
+		prof->fv[prof->fv_num].proto_id = proto_id;
+		prof->fv[prof->fv_num].offset = proto_off;
+		prof->fv[prof->fv_num].spec = *(const u16 *)&pkt_buf[off];
+		prof->fv[prof->fv_num].msk = *(const u16 *)&msk_buf[off];
+		prof->fv_num++;
+	}
+
+	return 0;
+}
+
+/**
+ * ice_parser_profile_dump - dump an FXP profile info
+ * @hw: pointer to the hardware structure
+ * @prof: profile info to dump
+ */
+void ice_parser_profile_dump(struct ice_hw *hw, struct ice_parser_profile *prof)
+{
+	u16 i;
+
+	dev_info(ice_hw_to_dev(hw), "ptypes:\n");
+	for (i = 0; i < ICE_FLOW_PTYPE_MAX; i++)
+		if (test_bit(i, prof->ptypes))
+			dev_info(ice_hw_to_dev(hw), "\t%d\n", i);
+
+	for (i = 0; i < prof->fv_num; i++)
+		dev_info(ice_hw_to_dev(hw),
+			 "proto = %d, offset = %d spec = 0x%04x, mask = 0x%04x\n",
+			 prof->fv[i].proto_id, prof->fv[i].offset,
+			 prof->fv[i].spec, prof->fv[i].msk);
+
+	dev_info(ice_hw_to_dev(hw), "flags = 0x%04x\n", prof->flags);
+	dev_info(ice_hw_to_dev(hw), "flags_msk = 0x%04x\n", prof->flags_msk);
+}
drivers/net/ethernet/intel/ice/ice_parser.h +24 -0
index 432d47031298..ecbec5843e9f 100644
@@ -85,4 +85,28 @@ struct ice_parser_result {
 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);
+
+struct ice_parser_fv {
+	u8 proto_id; /* hardware protocol ID */
+	u16 offset; /* offset from the start of the protocol header */
+	u16 spec; /* 16 bits pattern to match */
+	u16 msk; /* 16 bits pattern mask */
+};
+
+struct ice_parser_profile {
+	struct ice_parser_fv fv[48]; /* field vector arrary */
+	int fv_num; /* field vector number must <= 48 */
+	u16 flags; /* 16 bits key builder flag */
+	u16 flags_msk; /* key builder flag masker */
+	/* 1024 bits PTYPE bitmap */
+	DECLARE_BITMAP(ptypes, ICE_FLOW_PTYPE_MAX);
+};
+
+int ice_parser_profile_init(struct ice_parser_result *rslt,
+			    const u8 *pkt_buf, const u8 *msk_buf,
+					int buf_len, enum ice_block blk,
+					bool prefix_match,
+					struct ice_parser_profile *prof);
+void ice_parser_profile_dump(struct ice_hw *hw,
+			     struct ice_parser_profile *prof);
 #endif /* _ICE_PARSER_H_ */
Signature · 6 lines
2.25.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
#33 lore raw

Re: [Intel-wired-lan] [PATCH iwl-next v2 15/15] ice: add API for parser profile initialization

Quoted 15 lines · Junfeng Guo

Add API ice_parser_profile_init to init a parser profile base on a parser result and a mask buffer. The ice_parser_profile can feed to low level FXP engine to create HW profile / field vector directly.

---
  drivers/net/ethernet/intel/ice/ice_parser.c | 113 ++++++++++++++++++++
  drivers/net/ethernet/intel/ice/ice_parser.h |  24 +++++
  2 files changed, 137 insertions(+)
drivers/net/ethernet/intel/ice/ice_parser.c +0 -0
index 1ca0886e6590..ad42dcd31cb3 100644

drivers/net/ethernet/intel/ice/ice_parser.c int ice_parser_ecpri_tunnel_set(struct ice_parser *psr, · line 455

Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_parser.c +5 -0
@@ -448,3 +448,116 @@ int ice_parser_ecpri_tunnel_set(struct ice_parser *psr,
  {
  	return _tunnel_port_set(psr, "TNL_UDP_ECPRI", udp_port, on);
  }
+
+static bool _nearest_proto_id(struct ice_parser_result *rslt, u16 offset,
+			      u8 *proto_id, u16 *proto_off)
+{
+	u16 dist = 0xffff;

Use U16_MAX here...

drivers/net/ethernet/intel/ice/ice_parser.c int ice_parser_ecpri_tunnel_set(struct ice_parser *psr, · line 456

Quoted 1 line
drivers/net/ethernet/intel/ice/ice_parser.c +1 -0
+	u8 p = 0

Also 'proto' instead of 'p' would be better.

Quoted 130 lines
drivers/net/ethernet/intel/ice/ice_parser.c +107 -0
+	int i;
+
+	for (i = 0; i < rslt->po_num; i++) {
+		if (offset < rslt->po[i].offset)
+			continue;
+		if (offset - rslt->po[i].offset < dist) {
+			p = rslt->po[i].proto_id;
+			dist = offset - rslt->po[i].offset;
+		}
+	}
+
+	if (dist % 2)
+		return false;
+
+	*proto_id = p;
+	*proto_off = dist;
+
+	return true;
+}
+
+/** default flag mask to cover GTP_EH_PDU, GTP_EH_PDU_LINK and TUN2
+ * In future, the flag masks should learn from DDP
+ */
+#define ICE_KEYBUILD_FLAG_MASK_DEFAULT_SW	0x4002
+#define ICE_KEYBUILD_FLAG_MASK_DEFAULT_ACL	0x0000
+#define ICE_KEYBUILD_FLAG_MASK_DEFAULT_FD	0x6080
+#define ICE_KEYBUILD_FLAG_MASK_DEFAULT_RSS	0x6010
+
+/**
+ * ice_parser_profile_init  - initialize a FXP profile base on parser result
+ * @rslt: a instance of a parser result
+ * @pkt_buf: packet data buffer
+ * @msk_buf: packet mask buffer
+ * @buf_len: packet length
+ * @blk: FXP pipeline stage
+ * @prefix_match: match protocol stack exactly or only prefix
+ * @prof: input/output parameter to save the profile
+ */
+int ice_parser_profile_init(struct ice_parser_result *rslt,
+			    const u8 *pkt_buf, const u8 *msk_buf,
+			    int buf_len, enum ice_block blk,
+			    bool prefix_match,
+			    struct ice_parser_profile *prof)
+{
+	u8 proto_id = 0xff;
+	u16 proto_off = 0;
+	u16 off;
+
+	memset(prof, 0, sizeof(*prof));
+	set_bit(rslt->ptype, prof->ptypes);
+	if (blk == ICE_BLK_SW) {
+		prof->flags = rslt->flags_sw;
+		prof->flags_msk = ICE_KEYBUILD_FLAG_MASK_DEFAULT_SW;
+	} else if (blk == ICE_BLK_ACL) {
+		prof->flags = rslt->flags_acl;
+		prof->flags_msk = ICE_KEYBUILD_FLAG_MASK_DEFAULT_ACL;
+	} else if (blk == ICE_BLK_FD) {
+		prof->flags = rslt->flags_fd;
+		prof->flags_msk = ICE_KEYBUILD_FLAG_MASK_DEFAULT_FD;
+	} else if (blk == ICE_BLK_RSS) {
+		prof->flags = rslt->flags_rss;
+		prof->flags_msk = ICE_KEYBUILD_FLAG_MASK_DEFAULT_RSS;
+	} else {
+		return -EINVAL;
+	}
+
+	for (off = 0; off < buf_len - 1; off++) {
+		if (msk_buf[off] == 0 && msk_buf[off + 1] == 0)
+			continue;
+		if (!_nearest_proto_id(rslt, off, &proto_id, &proto_off))
+			continue;
+		if (prof->fv_num >= 32)
+			return -EINVAL;
+
+		prof->fv[prof->fv_num].proto_id = proto_id;
+		prof->fv[prof->fv_num].offset = proto_off;
+		prof->fv[prof->fv_num].spec = *(const u16 *)&pkt_buf[off];
+		prof->fv[prof->fv_num].msk = *(const u16 *)&msk_buf[off];
+		prof->fv_num++;
+	}
+
+	return 0;
+}
+
+/**
+ * ice_parser_profile_dump - dump an FXP profile info
+ * @hw: pointer to the hardware structure
+ * @prof: profile info to dump
+ */
+void ice_parser_profile_dump(struct ice_hw *hw, struct ice_parser_profile *prof)
+{
+	u16 i;
+
+	dev_info(ice_hw_to_dev(hw), "ptypes:\n");
+	for (i = 0; i < ICE_FLOW_PTYPE_MAX; i++)
+		if (test_bit(i, prof->ptypes))
+			dev_info(ice_hw_to_dev(hw), "\t%d\n", i);
+
+	for (i = 0; i < prof->fv_num; i++)
+		dev_info(ice_hw_to_dev(hw),
+			 "proto = %d, offset = %d spec = 0x%04x, mask = 0x%04x\n",
+			 prof->fv[i].proto_id, prof->fv[i].offset,
+			 prof->fv[i].spec, prof->fv[i].msk);
+
+	dev_info(ice_hw_to_dev(hw), "flags = 0x%04x\n", prof->flags);
+	dev_info(ice_hw_to_dev(hw), "flags_msk = 0x%04x\n", prof->flags_msk);
+}
drivers/net/ethernet/intel/ice/ice_parser.h +15 -0
index 432d47031298..ecbec5843e9f 100644
@@ -85,4 +85,28 @@ struct ice_parser_result {
  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);
+
+struct ice_parser_fv {
+	u8 proto_id; /* hardware protocol ID */
+	u16 offset; /* offset from the start of the protocol header */
+	u16 spec; /* 16 bits pattern to match */
+	u16 msk; /* 16 bits pattern mask */
+};
+
+struct ice_parser_profile {
+	struct ice_parser_fv fv[48]; /* field vector arrary */
+	int fv_num; /* field vector number must <= 48 */
+	u16 flags; /* 16 bits key builder flag */
+	u16 flags_msk; /* key builder flag masker */
+	/* 1024 bits PTYPE bitmap */
+	DECLARE_BITMAP(ptypes, ICE_FLOW_PTYPE_MAX);

drivers/net/ethernet/intel/ice/ice_parser.h struct ice_parser_result { · line 112

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_parser.h +9 -0
+};
+
+int ice_parser_profile_init(struct ice_parser_result *rslt,
+			    const u8 *pkt_buf, const u8 *msk_buf,
+					int buf_len, enum ice_block blk,
+					bool prefix_match,
+					struct ice_parser_profile *prof);
+void ice_parser_profile_dump(struct ice_hw *hw,
+			     struct ice_parser_profile *prof);
  #endif /* _ICE_PARSER_H_ */

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#34 lore raw

Re: [Intel-wired-lan] [PATCH iwl-next v2 15/15] ice: add API for parser profile initialization

Quoted 33 lines

-----Original Message-----
From: Ivan Vecera <[email protected]>
Sent: Monday, July 24, 2023 19:17
To: Guo, Junfeng <[email protected]>; intel-wired- [email protected]
Cc: Zhang, Qi Z <[email protected]>; mschmidt <[email protected]>; poros <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH iwl-next v2 15/15] ice: add API for parser profile initialization

Quoted 7 lines · Junfeng Guo

Add API ice_parser_profile_init to init a parser profile base on a parser result and a mask buffer. The ice_parser_profile can feed to low level FXP engine to create HW profile / field vector directly.

---
  drivers/net/ethernet/intel/ice/ice_parser.c | 113

++++++++++++++++++++

Review

Quoted 4 lines
  drivers/net/ethernet/intel/ice/ice_parser.h |  24 +++++
  2 files changed, 137 insertions(+)
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_parser.c

drivers/net/ethernet/intel/ice/ice_parser.c int ice_parser_ecpri_tunnel_set(struct

Quoted 4 lines

index 1ca0886e6590..ad42dcd31cb3 100644

drivers/net/ethernet/intel/ice/ice_parser.c +0 -0
@@ -448,3 +448,116 @@ int ice_parser_ecpri_tunnel_set(struct

ice_parser *psr,

Quoted 10 lines

drivers/net/ethernet/intel/ice/ice_parser.c int ice_parser_ecpri_tunnel_set(struct ice_parser *psr, · line 455

Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_parser.c +5 -0
  {
  	return _tunnel_port_set(psr, "TNL_UDP_ECPRI", udp_port, on);
  }
+
+static bool _nearest_proto_id(struct ice_parser_result *rslt, u16 offset,
+			      u8 *proto_id, u16 *proto_off)
+{
+	u16 dist = 0xffff;

Use U16_MAX here...

Sure, make sense! Will update in the coming version. Thanks!

Quoted 4 lines

drivers/net/ethernet/intel/ice/ice_parser.c int ice_parser_ecpri_tunnel_set(struct · line 456

Quoted 2 lines
drivers/net/ethernet/intel/ice/ice_parser.c +1 -0
+	u8 p = 0

Also 'proto' instead of 'p' would be better.

Sure, make sense! Will update in the coming version. Thanks!

Quoted 145 lines
Quoted 12 lines
drivers/net/ethernet/intel/ice/ice_parser.c +11 -0
+	int i;
+
+	for (i = 0; i < rslt->po_num; i++) {
+		if (offset < rslt->po[i].offset)
+			continue;
+		if (offset - rslt->po[i].offset < dist) {
+			p = rslt->po[i].proto_id;
+			dist = offset - rslt->po[i].offset;
+		}
+	}
+

drivers/net/ethernet/intel/ice/ice_parser.c int ice_parser_ecpri_tunnel_set(struct ice_parser *psr,

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_parser.c +10 -0
+	if (dist % 2)
+		return false;
+
+	*proto_id = p;
+	*proto_off = dist;
+
+	return true;
+}
+
+/** default flag mask to cover GTP_EH_PDU, GTP_EH_PDU_LINK and

TUN2

Quoted 22 lines
drivers/net/ethernet/intel/ice/ice_parser.c +22 -0
+ * In future, the flag masks should learn from DDP
+ */
+#define ICE_KEYBUILD_FLAG_MASK_DEFAULT_SW	0x4002
+#define ICE_KEYBUILD_FLAG_MASK_DEFAULT_ACL	0x0000
+#define ICE_KEYBUILD_FLAG_MASK_DEFAULT_FD	0x6080
+#define ICE_KEYBUILD_FLAG_MASK_DEFAULT_RSS	0x6010
+
+/**
+ * ice_parser_profile_init  - initialize a FXP profile base on parser result
+ * @rslt: a instance of a parser result
+ * @pkt_buf: packet data buffer
+ * @msk_buf: packet mask buffer
+ * @buf_len: packet length
+ * @blk: FXP pipeline stage
+ * @prefix_match: match protocol stack exactly or only prefix
+ * @prof: input/output parameter to save the profile
+ */
+int ice_parser_profile_init(struct ice_parser_result *rslt,
+			    const u8 *pkt_buf, const u8 *msk_buf,
+			    int buf_len, enum ice_block blk,
+			    bool prefix_match,
+			    struct ice_parser_profile *prof)

drivers/net/ethernet/intel/ice/ice_parser.c int ice_parser_ecpri_tunnel_set(struct ice_parser *psr,

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_parser.c +10 -0
+{
+	u8 proto_id = 0xff;
+	u16 proto_off = 0;
+	u16 off;
+
+	memset(prof, 0, sizeof(*prof));
+	set_bit(rslt->ptype, prof->ptypes);
+	if (blk == ICE_BLK_SW) {
+		prof->flags = rslt->flags_sw;
+		prof->flags_msk =

ICE_KEYBUILD_FLAG_MASK_DEFAULT_SW;

drivers/net/ethernet/intel/ice/ice_parser.c int ice_parser_ecpri_tunnel_set(struct ice_parser *psr,

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_parser.c +3 -0
+	} else if (blk == ICE_BLK_ACL) {
+		prof->flags = rslt->flags_acl;
+		prof->flags_msk =

ICE_KEYBUILD_FLAG_MASK_DEFAULT_ACL;

drivers/net/ethernet/intel/ice/ice_parser.c int ice_parser_ecpri_tunnel_set(struct ice_parser *psr,

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_parser.c +3 -0
+	} else if (blk == ICE_BLK_FD) {
+		prof->flags = rslt->flags_fd;
+		prof->flags_msk =

ICE_KEYBUILD_FLAG_MASK_DEFAULT_FD;

drivers/net/ethernet/intel/ice/ice_parser.c int ice_parser_ecpri_tunnel_set(struct ice_parser *psr,

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_parser.c +3 -0
+	} else if (blk == ICE_BLK_RSS) {
+		prof->flags = rslt->flags_rss;
+		prof->flags_msk =

ICE_KEYBUILD_FLAG_MASK_DEFAULT_RSS;

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_parser.c +5 -0
+	} else {
+		return -EINVAL;
+	}
+
+	for (off = 0; off < buf_len - 1; off++) {

drivers/net/ethernet/intel/ice/ice_parser.c int ice_parser_ecpri_tunnel_set(struct ice_parser *psr,

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_parser.c +10 -0
+		if (msk_buf[off] == 0 && msk_buf[off + 1] == 0)
+			continue;
+		if (!_nearest_proto_id(rslt, off, &proto_id, &proto_off))
+			continue;
+		if (prof->fv_num >= 32)
+			return -EINVAL;
+
+		prof->fv[prof->fv_num].proto_id = proto_id;
+		prof->fv[prof->fv_num].offset = proto_off;
+		prof->fv[prof->fv_num].spec = *(const u16

*)&pkt_buf[off];

drivers/net/ethernet/intel/ice/ice_parser.c int ice_parser_ecpri_tunnel_set(struct · line 534

Quoted 1 line
drivers/net/ethernet/intel/ice/ice_parser.c +1 -0
+		prof->fv[prof->fv_num].msk = *(const u16

*)&msk_buf[off];

drivers/net/ethernet/intel/ice/ice_parser.c int ice_parser_ecpri_tunnel_set(struct ice_parser *psr,

Quoted 12 lines
drivers/net/ethernet/intel/ice/ice_parser.c +12 -0
+		prof->fv_num++;
+	}
+
+	return 0;
+}
+
+/**
+ * ice_parser_profile_dump - dump an FXP profile info
+ * @hw: pointer to the hardware structure
+ * @prof: profile info to dump
+ */
+void ice_parser_profile_dump(struct ice_hw *hw, struct

ice_parser_profile *prof)

drivers/net/ethernet/intel/ice/ice_parser.c int ice_parser_ecpri_tunnel_set(struct ice_parser *psr,

Quoted 11 lines
drivers/net/ethernet/intel/ice/ice_parser.c +11 -0
+{
+	u16 i;
+
+	dev_info(ice_hw_to_dev(hw), "ptypes:\n");
+	for (i = 0; i < ICE_FLOW_PTYPE_MAX; i++)
+		if (test_bit(i, prof->ptypes))
+			dev_info(ice_hw_to_dev(hw), "\t%d\n", i);
+
+	for (i = 0; i < prof->fv_num; i++)
+		dev_info(ice_hw_to_dev(hw),
+			 "proto = %d, offset = %d spec = 0x%04x, mask =

0x%04x\n",

Review

Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_parser.c +5 -0
+			 prof->fv[i].proto_id, prof->fv[i].offset,
+			 prof->fv[i].spec, prof->fv[i].msk);
+
+	dev_info(ice_hw_to_dev(hw), "flags = 0x%04x\n", prof->flags);
+	dev_info(ice_hw_to_dev(hw), "flags_msk = 0x%04x\n", prof-

flags_msk);

drivers/net/ethernet/intel/ice/ice_parser.c +1 -0
+}
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_parser.h

drivers/net/ethernet/intel/ice/ice_parser.h struct ice_parser_result { · line 87

Quoted 7 lines

index 432d47031298..ecbec5843e9f 100644

drivers/net/ethernet/intel/ice/ice_parser.h +0 -0
@@ -85,4 +85,28 @@ struct ice_parser_result {
  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);

Quoted 17 lines
drivers/net/ethernet/intel/ice/ice_parser.h +17 -0
+
+struct ice_parser_fv {
+	u8 proto_id; /* hardware protocol ID */
+	u16 offset; /* offset from the start of the protocol header */
+	u16 spec; /* 16 bits pattern to match */
+	u16 msk; /* 16 bits pattern mask */
+};
+
+struct ice_parser_profile {
+	struct ice_parser_fv fv[48]; /* field vector arrary */
+	int fv_num; /* field vector number must <= 48 */
+	u16 flags; /* 16 bits key builder flag */
+	u16 flags_msk; /* key builder flag masker */
+	/* 1024 bits PTYPE bitmap */
+	DECLARE_BITMAP(ptypes, ICE_FLOW_PTYPE_MAX);
+};
+
Quoted 8 lines

drivers/net/ethernet/intel/ice/ice_parser.h struct ice_parser_result { · line 112

Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_parser.h +7 -0
+int ice_parser_profile_init(struct ice_parser_result *rslt,
+			    const u8 *pkt_buf, const u8 *msk_buf,
+					int buf_len, enum ice_block blk,
+					bool prefix_match,
+					struct ice_parser_profile *prof);
+void ice_parser_profile_dump(struct ice_hw *hw,
+			     struct ice_parser_profile *prof);
  #endif /* _ICE_PARSER_H_ */

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#35 lore raw

Re: [Intel-wired-lan] [PATCH iwl-next v2 15/15] ice: add API for parser profile initialization

Quoted 41 lines · Junfeng
Quoted 32 lines

-----Original Message-----
From: Ivan Vecera<[email protected]>
Sent: Monday, July 24, 2023 19:17
To: Guo, Junfeng<[email protected]>; intel-wired- [email protected]
Cc: Zhang, Qi Z<[email protected]>; mschmidt <[email protected]>; poros<[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH iwl-next v2 15/15] ice: add API for parser profile initialization

Quoted 7 lines · Junfeng Guo

Add API ice_parser_profile_init to init a parser profile base on a parser result and a mask buffer. The ice_parser_profile can feed to low level FXP engine to create HW profile / field vector directly.

---
   drivers/net/ethernet/intel/ice/ice_parser.c | 113

++++++++++++++++++++

Review

Quoted 4 lines
   drivers/net/ethernet/intel/ice/ice_parser.h |  24 +++++
   2 files changed, 137 insertions(+)
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_parser.c

drivers/net/ethernet/intel/ice/ice_parser.c int ice_parser_ecpri_tunnel_set(struct

Quoted 4 lines

index 1ca0886e6590..ad42dcd31cb3 100644

drivers/net/ethernet/intel/ice/ice_parser.c +0 -0
@@ -448,3 +448,116 @@ int ice_parser_ecpri_tunnel_set(struct

ice_parser *psr,

Quoted 9 lines

drivers/net/ethernet/intel/ice/ice_parser.c int ice_parser_ecpri_tunnel_set(struct ice_parser *psr, · line 455

Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_parser.c +5 -0
   {
   	return _tunnel_port_set(psr, "TNL_UDP_ECPRI", udp_port, on);
   }
+
+static bool _nearest_proto_id(struct ice_parser_result *rslt, u16 offset,
+			      u8 *proto_id, u16 *proto_off)
+{
+	u16 dist = 0xffff;

Use U16_MAX here...

Quoted 6 lines

Sure, make sense! Will update in the coming version. Thanks!

Quoted 2 lines

drivers/net/ethernet/intel/ice/ice_parser.c int ice_parser_ecpri_tunnel_set(struct · line 456

Quoted 1 line
drivers/net/ethernet/intel/ice/ice_parser.c +1 -0
+	u8 p = 0

Also 'proto' instead of 'p' would be better.

Sure, make sense! Will update in the coming version. Thanks!

I'm looking forward for the next version.

Thank you,

Ivan

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#36 lore raw

v3 cover Introduce the Parser Library

In reply to Junfeng Guo

Current software architecture for flow filtering offloading limited the capability of Intel® Ethernet 800 Series Dynamic Device Personalization (DDP) Package. The flow filtering offloading in the driver is enabled based on the naming parsers, each flow pattern is represented by a protocol header stack. And there are multiple layers (e.g., virtchnl) to maintain their own enum/macro/structure to represent a protocol header (IP, TCP, UDP ...), thus the extra parsers to verify if a pattern is supported by hardware or not as well as the extra converters that to translate represents between different layers. Every time a new protocol/field is requested to be supported, the corresponding logic for the parsers and the converters needs to be modified accordingly. Thus, huge & redundant efforts are required to support the increasing flow filtering offloading features, especially for the tunnel types flow filtering.

This patch set provides a way for applications to send down training packets & masks (in binary) to the driver. Then these binary data would be used by the driver to generate certain data that are needed to create a filter rule in the filtering stage of switch/RSS/FDIR.

Note that the impact of a malicious rule in the raw packet filter is limited to performance rather than functionality. It may affect the performance of the workload, similar to other limitations in FDIR/RSS on AVF. For example, there is no resource boundary for VF FDIR/RSS rules, so one malicious VF could potentially make other VFs inefficient in offloading.

The parser library is expected to include boundary checks to prevent critical errors such as infinite loops or segmentation faults. However, only implementing and validating the parser emulator in a sandbox environment (like ebpf) presents a challenge.

The idea is to make the driver be able to learn from the DDP package directly to understand how the hardware parser works (i.e., the Parser Library), so that it can process on the raw training packet (in binary) directly and create the filter rule accordingly.

Based on this Parser Library, the raw flow filtering of switch/RSS/FDIR could be enabled to allow new flow filtering offloading features to be supported without any driver changes (only need to update the DDP package).

v3:
- Replace magic hardcoded values with macros.
- Use size_t to avoid superfluous type cast to uintptr_t in function ice_parser_sect_item_get.
- Prefix for static local function names to avoid namespace pollution.
- Use strstarts() function instead of self implementation.

v2:
- Fix build warnings.
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

Junfeng Guo (15):
ice: add parser create and destroy skeleton
ice: init imem table for parser
ice: init metainit table for parser
ice: init parse graph cam tables for parser
ice: init boost tcam and label tables for parser
ice: init ptype marker tcam table for parser
ice: init marker and protocol group tables for parser
ice: init flag redirect table for parser
ice: init XLT key builder for parser
ice: add parser runtime skeleton
ice: add internal help functions
ice: add parser execution main loop
ice: support double vlan mode configure for parser
ice: add tunnel port support for parser
ice: add API for parser profile initialization

 drivers/net/ethernet/intel/ice/Makefile       |  11 +
 drivers/net/ethernet/intel/ice/ice_bst_tcam.c | 313 +++++++
 drivers/net/ethernet/intel/ice/ice_bst_tcam.h |  52 ++
 drivers/net/ethernet/intel/ice/ice_common.h   |   4 +
 drivers/net/ethernet/intel/ice/ice_ddp.c      |  10 +-
 drivers/net/ethernet/intel/ice/ice_ddp.h      |  14 +
 drivers/net/ethernet/intel/ice/ice_flg_rd.c   |  73 ++
 drivers/net/ethernet/intel/ice/ice_flg_rd.h   |  24 +
 drivers/net/ethernet/intel/ice/ice_imem.c     | 279 ++++++
 drivers/net/ethernet/intel/ice/ice_imem.h     | 217 +++++
 drivers/net/ethernet/intel/ice/ice_metainit.c | 181 ++++
 drivers/net/ethernet/intel/ice/ice_metainit.h | 104 +++
 drivers/net/ethernet/intel/ice/ice_mk_grp.c   |  51 +
 drivers/net/ethernet/intel/ice/ice_mk_grp.h   |  17 +
 drivers/net/ethernet/intel/ice/ice_parser.c   | 562 +++++++++++
 drivers/net/ethernet/intel/ice/ice_parser.h   | 140 +++
 .../net/ethernet/intel/ice/ice_parser_rt.c    | 877 ++++++++++++++++++
 .../net/ethernet/intel/ice/ice_parser_rt.h    |  73 ++
 .../net/ethernet/intel/ice/ice_parser_util.h  |  37 +
 drivers/net/ethernet/intel/ice/ice_pg_cam.c   | 397 ++++++++
 drivers/net/ethernet/intel/ice/ice_pg_cam.h   | 142 +++
 .../net/ethernet/intel/ice/ice_proto_grp.c    |  90 ++
 .../net/ethernet/intel/ice/ice_proto_grp.h    |  31 +
 drivers/net/ethernet/intel/ice/ice_ptype_mk.c |  73 ++
 drivers/net/ethernet/intel/ice/ice_ptype_mk.h |  23 +
 drivers/net/ethernet/intel/ice/ice_tmatch.h   |  40 +
 drivers/net/ethernet/intel/ice/ice_type.h     |   1 +
 drivers/net/ethernet/intel/ice/ice_xlt_kb.c   | 262 ++++++
 drivers/net/ethernet/intel/ice/ice_xlt_kb.h   |  80 ++
 29 files changed, 4173 insertions(+), 5 deletions(-)
 create mode 100644 drivers/net/ethernet/intel/ice/ice_bst_tcam.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_bst_tcam.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_flg_rd.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_flg_rd.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_imem.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_imem.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_metainit.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_metainit.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_mk_grp.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_mk_grp.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_parser.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_parser.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_parser_rt.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_parser_rt.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_parser_util.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_pg_cam.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_pg_cam.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_proto_grp.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_proto_grp.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_ptype_mk.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_ptype_mk.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_tmatch.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_xlt_kb.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_xlt_kb.h
Signature · 6 lines
2.25.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
#37 lore raw

PATCH v3 1/15 ice: add parser create and destroy skeleton

Add new parser module which can parse a packet in binary and generate information like ptype, protocol/offset pairs and flags which can be used to feed the FXP profile creation directly.

The patch added skeleton of the create and destroy APIs:
ice_parser_create
ice_parser_destroy

---
 drivers/net/ethernet/intel/ice/ice_common.h |  4 +++
 drivers/net/ethernet/intel/ice/ice_ddp.c    | 10 +++---
 drivers/net/ethernet/intel/ice/ice_ddp.h    | 13 ++++++++
 drivers/net/ethernet/intel/ice/ice_parser.c | 34 +++++++++++++++++++++
 drivers/net/ethernet/intel/ice/ice_parser.h | 13 ++++++++
 5 files changed, 69 insertions(+), 5 deletions(-)
 create mode 100644 drivers/net/ethernet/intel/ice/ice_parser.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_parser.h
drivers/net/ethernet/intel/ice/ice_common.h +4 -0
index 8ba5f935a092..528dde976373 100644
@@ -9,10 +9,14 @@
 #include "ice_type.h"
 #include "ice_nvm.h"
 #include "ice_flex_pipe.h"
+#include "ice_parser.h"
 #include <linux/avf/virtchnl.h>
 #include "ice_switch.h"
 #include "ice_fdir.h"
 
+#define BITS_PER_WORD	16
+#define BITMAP_MASK(n)	GENMASK(((n) - 1), 0)
+
 #define ICE_SQ_SEND_DELAY_TIME_MS	10
 #define ICE_SQ_SEND_MAX_EXECUTE		3
 
drivers/net/ethernet/intel/ice/ice_ddp.c +5 -5
index d71ed210f9c4..3bdf03b9ee71 100644
@@ -288,11 +288,11 @@ void *ice_pkg_enum_section(struct ice_seg *ice_seg, struct ice_pkg_enum *state,
  * indicates a base offset of 10, and the index for the entry is 2, then
  * section handler function should set the offset to 10 + 2 = 12.
  */
-static void *ice_pkg_enum_entry(struct ice_seg *ice_seg,
-				struct ice_pkg_enum *state, u32 sect_type,
-				u32 *offset,
-				void *(*handler)(u32 sect_type, void *section,
-						 u32 index, u32 *offset))
+void *ice_pkg_enum_entry(struct ice_seg *ice_seg,
+			 struct ice_pkg_enum *state, u32 sect_type,
+			 u32 *offset,
+			 void *(*handler)(u32 sect_type, void *section,
+					  u32 index, u32 *offset))
 {
 	void *entry;
 
drivers/net/ethernet/intel/ice/ice_ddp.h +13 -0
index 37eadb3d27a8..da5dfeed3b1f 100644
@@ -238,10 +238,18 @@ struct ice_meta_sect {
 #define ICE_SID_CDID_KEY_BUILDER_RSS 47
 #define ICE_SID_CDID_REDIR_RSS 48
 
+#define ICE_SID_RXPARSER_CAM		50
+#define ICE_SID_RXPARSER_NOMATCH_CAM	51
+#define ICE_SID_RXPARSER_IMEM		52
 #define ICE_SID_RXPARSER_MARKER_PTYPE 55
 #define ICE_SID_RXPARSER_BOOST_TCAM 56
+#define ICE_SID_RXPARSER_PROTO_GRP	57
 #define ICE_SID_RXPARSER_METADATA_INIT 58
+#define ICE_SID_TXPARSER_NOMATCH_CAM	61
 #define ICE_SID_TXPARSER_BOOST_TCAM 66
+#define ICE_SID_RXPARSER_MARKER_GRP	72
+#define ICE_SID_RXPARSER_PG_SPILL	76
+#define ICE_SID_RXPARSER_NOMATCH_SPILL	78
 
 #define ICE_SID_XLT0_PE 80
 #define ICE_SID_XLT_KEY_BUILDER_PE 81
@@ -437,6 +445,11 @@ int ice_update_pkg(struct ice_hw *hw, struct ice_buf *bufs, u32 count);
 
 int ice_pkg_buf_reserve_section(struct ice_buf_build *bld, u16 count);
 u16 ice_pkg_buf_get_active_sections(struct ice_buf_build *bld);
+void *
+ice_pkg_enum_entry(struct ice_seg *ice_seg, struct ice_pkg_enum *state,
+		   u32 sect_type, u32 *offset,
+		   void *(*handler)(u32 sect_type, void *section,
+				    u32 index, u32 *offset));
 void *ice_pkg_enum_section(struct ice_seg *ice_seg, struct ice_pkg_enum *state,
 			   u32 sect_type);
 
drivers/net/ethernet/intel/ice/ice_parser.c new file +34 -0
new file mode 100644
index 000000000000..692ad26ec551
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#include "ice_common.h"
+
+/**
+ * ice_parser_create - create a parser instance
+ * @hw: pointer to the hardware structure
+ * @psr: output parameter for a new parser instance be created
+ */
+int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr)
+{
+	struct ice_parser *p;
+
+	p = devm_kzalloc(ice_hw_to_dev(hw), sizeof(struct ice_parser),
+			 GFP_KERNEL);
+	if (!p)
+		return -ENOMEM;
+
+	p->hw = hw;
+	p->rt.psr = p;
+
+	*psr = p;
+	return 0;
+}
+
+/**
+ * ice_parser_destroy - destroy a parser instance
+ * @psr: pointer to a parser instance
+ */
+void ice_parser_destroy(struct ice_parser *psr)
+{
+	devm_kfree(ice_hw_to_dev(psr->hw), psr);
+}
drivers/net/ethernet/intel/ice/ice_parser.h new file +13 -0
new file mode 100644
index 000000000000..c6cd74c6e434
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#ifndef _ICE_PARSER_H_
+#define _ICE_PARSER_H_
+
+struct ice_parser {
+	struct ice_hw *hw; /* pointer to the hardware structure */
+};
+
+int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
+void ice_parser_destroy(struct ice_parser *psr);
+#endif /* _ICE_PARSER_H_ */
Signature · 6 lines
2.25.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
#38 lore raw

v4 cover Introduce the Parser Library

Current software architecture for flow filtering offloading limited the capability of Intel� Ethernet 800 Series Dynamic Device Personalization (DDP) Package. The flow filtering offloading in the driver is enabled based on the naming parsers, each flow pattern is represented by a protocol header stack. And there are multiple layers (e.g., virtchnl) to maintain their own enum/macro/structure to represent a protocol header (IP, TCP, UDP ...), thus the extra parsers to verify if a pattern is supported by hardware or not as well as the extra converters that to translate represents between different layers. Every time a new protocol/field is requested to be supported, the corresponding logic for the parsers and the converters needs to be modified accordingly. Thus, huge & redundant efforts are required to support the increasing flow filtering offloading features, especially for the tunnel types flow filtering.

This patch set provides a way for applications to send down training packets & masks (in binary) to the driver. Then these binary data would be used by the driver to generate certain data that are needed to create a filter rule in the filtering stage of switch/RSS/FDIR.

Note that the impact of a malicious rule in the raw packet filter is limited to performance rather than functionality. It may affect the performance of the workload, similar to other limitations in FDIR/RSS on AVF. For example, there is no resource boundary for VF FDIR/RSS rules, so one malicious VF could potentially make other VFs inefficient in offloading.

The parser library is expected to include boundary checks to prevent critical errors such as infinite loops or segmentation faults. However, only implementing and validating the parser emulator in a sandbox environment (like ebpf) presents a challenge.

The idea is to make the driver be able to learn from the DDP package directly to understand how the hardware parser works (i.e., the Parser Library), so that it can process on the raw training packet (in binary) directly and create the filter rule accordingly.

Based on this Parser Library, the raw flow filtering of switch/RSS/FDIR could be enabled to allow new flow filtering offloading features to be supported without any driver changes (only need to update the DDP package).

v4:
- Update cover letter series title.

v3:
- Replace magic hardcoded values with macros.
- Use size_t to avoid superfluous type cast to uintptr_t in function ice_parser_sect_item_get.
- Prefix for static local function names to avoid namespace pollution.
- Use strstarts() function instead of self implementation.

v2:
- Fix build warnings.
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

Junfeng Guo (15):
ice: add parser create and destroy skeleton
ice: init imem table for parser
ice: init metainit table for parser
ice: init parse graph cam tables for parser
ice: init boost tcam and label tables for parser
ice: init ptype marker tcam table for parser
ice: init marker and protocol group tables for parser
ice: init flag redirect table for parser
ice: init XLT key builder for parser
ice: add parser runtime skeleton
ice: add internal help functions
ice: add parser execution main loop
ice: support double vlan mode configure for parser
ice: add tunnel port support for parser
ice: add API for parser profile initialization

 drivers/net/ethernet/intel/ice/Makefile       |  11 +
 drivers/net/ethernet/intel/ice/ice_bst_tcam.c | 313 +++++++
 drivers/net/ethernet/intel/ice/ice_bst_tcam.h |  52 ++
 drivers/net/ethernet/intel/ice/ice_common.h   |   4 +
 drivers/net/ethernet/intel/ice/ice_ddp.c      |  10 +-
 drivers/net/ethernet/intel/ice/ice_ddp.h      |  14 +
 drivers/net/ethernet/intel/ice/ice_flg_rd.c   |  73 ++
 drivers/net/ethernet/intel/ice/ice_flg_rd.h   |  24 +
 drivers/net/ethernet/intel/ice/ice_imem.c     | 279 ++++++
 drivers/net/ethernet/intel/ice/ice_imem.h     | 217 +++++
 drivers/net/ethernet/intel/ice/ice_metainit.c | 181 ++++
 drivers/net/ethernet/intel/ice/ice_metainit.h | 104 +++
 drivers/net/ethernet/intel/ice/ice_mk_grp.c   |  51 +
 drivers/net/ethernet/intel/ice/ice_mk_grp.h   |  17 +
 drivers/net/ethernet/intel/ice/ice_parser.c   | 562 +++++++++++
 drivers/net/ethernet/intel/ice/ice_parser.h   | 140 +++
 .../net/ethernet/intel/ice/ice_parser_rt.c    | 877 ++++++++++++++++++
 .../net/ethernet/intel/ice/ice_parser_rt.h    |  73 ++
 .../net/ethernet/intel/ice/ice_parser_util.h  |  37 +
 drivers/net/ethernet/intel/ice/ice_pg_cam.c   | 397 ++++++++
 drivers/net/ethernet/intel/ice/ice_pg_cam.h   | 142 +++
 .../net/ethernet/intel/ice/ice_proto_grp.c    |  90 ++
 .../net/ethernet/intel/ice/ice_proto_grp.h    |  31 +
 drivers/net/ethernet/intel/ice/ice_ptype_mk.c |  73 ++
 drivers/net/ethernet/intel/ice/ice_ptype_mk.h |  23 +
 drivers/net/ethernet/intel/ice/ice_tmatch.h   |  40 +
 drivers/net/ethernet/intel/ice/ice_type.h     |   1 +
 drivers/net/ethernet/intel/ice/ice_xlt_kb.c   | 262 ++++++
 drivers/net/ethernet/intel/ice/ice_xlt_kb.h   |  80 ++
 29 files changed, 4173 insertions(+), 5 deletions(-)
 create mode 100644 drivers/net/ethernet/intel/ice/ice_bst_tcam.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_bst_tcam.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_flg_rd.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_flg_rd.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_imem.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_imem.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_metainit.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_metainit.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_mk_grp.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_mk_grp.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_parser.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_parser.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_parser_rt.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_parser_rt.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_parser_util.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_pg_cam.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_pg_cam.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_proto_grp.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_proto_grp.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_ptype_mk.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_ptype_mk.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_tmatch.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_xlt_kb.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_xlt_kb.h
Signature · 1 line
2.25.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#39 lore raw

PATCH v4 1/15 ice: add parser create and destroy skeleton

Add new parser module which can parse a packet in binary and generate information like ptype, protocol/offset pairs and flags which can be used to feed the FXP profile creation directly.

The patch added skeleton of the create and destroy APIs:
ice_parser_create
ice_parser_destroy

---
 drivers/net/ethernet/intel/ice/ice_common.h |  4 +++
 drivers/net/ethernet/intel/ice/ice_ddp.c    | 10 +++---
 drivers/net/ethernet/intel/ice/ice_ddp.h    | 13 ++++++++
 drivers/net/ethernet/intel/ice/ice_parser.c | 34 +++++++++++++++++++++
 drivers/net/ethernet/intel/ice/ice_parser.h | 13 ++++++++
 5 files changed, 69 insertions(+), 5 deletions(-)
 create mode 100644 drivers/net/ethernet/intel/ice/ice_parser.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_parser.h
drivers/net/ethernet/intel/ice/ice_common.h +4 -0
index 8ba5f935a092..528dde976373 100644
@@ -9,10 +9,14 @@
 #include "ice_type.h"
 #include "ice_nvm.h"
 #include "ice_flex_pipe.h"
+#include "ice_parser.h"
 #include <linux/avf/virtchnl.h>
 #include "ice_switch.h"
 #include "ice_fdir.h"
 
+#define BITS_PER_WORD	16
+#define BITMAP_MASK(n)	GENMASK(((n) - 1), 0)
+
 #define ICE_SQ_SEND_DELAY_TIME_MS	10
 #define ICE_SQ_SEND_MAX_EXECUTE		3
 
drivers/net/ethernet/intel/ice/ice_ddp.c +5 -5
index d71ed210f9c4..3bdf03b9ee71 100644
@@ -288,11 +288,11 @@ void *ice_pkg_enum_section(struct ice_seg *ice_seg, struct ice_pkg_enum *state,
  * indicates a base offset of 10, and the index for the entry is 2, then
  * section handler function should set the offset to 10 + 2 = 12.
  */
-static void *ice_pkg_enum_entry(struct ice_seg *ice_seg,
-				struct ice_pkg_enum *state, u32 sect_type,
-				u32 *offset,
-				void *(*handler)(u32 sect_type, void *section,
-						 u32 index, u32 *offset))
+void *ice_pkg_enum_entry(struct ice_seg *ice_seg,
+			 struct ice_pkg_enum *state, u32 sect_type,
+			 u32 *offset,
+			 void *(*handler)(u32 sect_type, void *section,
+					  u32 index, u32 *offset))
 {
 	void *entry;
 
drivers/net/ethernet/intel/ice/ice_ddp.h +13 -0
index 37eadb3d27a8..da5dfeed3b1f 100644
@@ -238,10 +238,18 @@ struct ice_meta_sect {
 #define ICE_SID_CDID_KEY_BUILDER_RSS 47
 #define ICE_SID_CDID_REDIR_RSS 48
 
+#define ICE_SID_RXPARSER_CAM		50
+#define ICE_SID_RXPARSER_NOMATCH_CAM	51
+#define ICE_SID_RXPARSER_IMEM		52
 #define ICE_SID_RXPARSER_MARKER_PTYPE 55
 #define ICE_SID_RXPARSER_BOOST_TCAM 56
+#define ICE_SID_RXPARSER_PROTO_GRP	57
 #define ICE_SID_RXPARSER_METADATA_INIT 58
+#define ICE_SID_TXPARSER_NOMATCH_CAM	61
 #define ICE_SID_TXPARSER_BOOST_TCAM 66
+#define ICE_SID_RXPARSER_MARKER_GRP	72
+#define ICE_SID_RXPARSER_PG_SPILL	76
+#define ICE_SID_RXPARSER_NOMATCH_SPILL	78
 
 #define ICE_SID_XLT0_PE 80
 #define ICE_SID_XLT_KEY_BUILDER_PE 81
@@ -437,6 +445,11 @@ int ice_update_pkg(struct ice_hw *hw, struct ice_buf *bufs, u32 count);
 
 int ice_pkg_buf_reserve_section(struct ice_buf_build *bld, u16 count);
 u16 ice_pkg_buf_get_active_sections(struct ice_buf_build *bld);
+void *
+ice_pkg_enum_entry(struct ice_seg *ice_seg, struct ice_pkg_enum *state,
+		   u32 sect_type, u32 *offset,
+		   void *(*handler)(u32 sect_type, void *section,
+				    u32 index, u32 *offset));
 void *ice_pkg_enum_section(struct ice_seg *ice_seg, struct ice_pkg_enum *state,
 			   u32 sect_type);
 
drivers/net/ethernet/intel/ice/ice_parser.c new file +34 -0
new file mode 100644
index 000000000000..692ad26ec551
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#include "ice_common.h"
+
+/**
+ * ice_parser_create - create a parser instance
+ * @hw: pointer to the hardware structure
+ * @psr: output parameter for a new parser instance be created
+ */
+int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr)
+{
+	struct ice_parser *p;
+
+	p = devm_kzalloc(ice_hw_to_dev(hw), sizeof(struct ice_parser),
+			 GFP_KERNEL);
+	if (!p)
+		return -ENOMEM;
+
+	p->hw = hw;
+	p->rt.psr = p;
+
+	*psr = p;
+	return 0;
+}
+
+/**
+ * ice_parser_destroy - destroy a parser instance
+ * @psr: pointer to a parser instance
+ */
+void ice_parser_destroy(struct ice_parser *psr)
+{
+	devm_kfree(ice_hw_to_dev(psr->hw), psr);
+}
drivers/net/ethernet/intel/ice/ice_parser.h new file +13 -0
new file mode 100644
index 000000000000..c6cd74c6e434
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#ifndef _ICE_PARSER_H_
+#define _ICE_PARSER_H_
+
+struct ice_parser {
+	struct ice_hw *hw; /* pointer to the hardware structure */
+};
+
+int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
+void ice_parser_destroy(struct ice_parser *psr);
+#endif /* _ICE_PARSER_H_ */
Signature · 6 lines
2.25.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
#40 lore raw

PATCH v4 2/15 ice: init imem table for parser

In reply to Junfeng Guo

Parse DDP section ICE_SID_RXPARSER_IMEM into an arrary of struct ice_imem_item.

---
 drivers/net/ethernet/intel/ice/ice_imem.c     | 279 ++++++++++++++++++
 drivers/net/ethernet/intel/ice/ice_imem.h     | 217 ++++++++++++++
 drivers/net/ethernet/intel/ice/ice_parser.c   |  97 ++++++
 drivers/net/ethernet/intel/ice/ice_parser.h   |   8 +
 .../net/ethernet/intel/ice/ice_parser_util.h  |  24 ++
 drivers/net/ethernet/intel/ice/ice_type.h     |   1 +
 6 files changed, 626 insertions(+)
 create mode 100644 drivers/net/ethernet/intel/ice/ice_imem.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_imem.h
 create mode 100644 drivers/net/ethernet/intel/ice/ice_parser_util.h
drivers/net/ethernet/intel/ice/ice_imem.c new file +279 -0
new file mode 100644
index 000000000000..a47748d1b1bf
@@ -0,0 +1,279 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#include "ice_common.h"
+#include "ice_parser_util.h"
+
+static void _ice_imem_bst_bm_dump(struct ice_hw *hw, struct ice_bst_main *bm)
+{
+	dev_info(ice_hw_to_dev(hw), "boost main:\n");
+	dev_info(ice_hw_to_dev(hw), "\talu0 = %d\n", bm->alu0);
+	dev_info(ice_hw_to_dev(hw), "\talu1 = %d\n", bm->alu1);
+	dev_info(ice_hw_to_dev(hw), "\talu2 = %d\n", bm->alu2);
+	dev_info(ice_hw_to_dev(hw), "\tpg = %d\n", bm->pg);
+}
+
+static void _ice_imem_bst_kb_dump(struct ice_hw *hw,
+				  struct ice_bst_keybuilder *kb)
+{
+	dev_info(ice_hw_to_dev(hw), "boost key builder:\n");
+	dev_info(ice_hw_to_dev(hw), "\tpriority = %d\n", kb->prio);
+	dev_info(ice_hw_to_dev(hw), "\ttsr_ctrl = %d\n", kb->tsr_ctrl);
+}
+
+static void _ice_imem_np_kb_dump(struct ice_hw *hw,
+				 struct ice_np_keybuilder *kb)
+{
+	dev_info(ice_hw_to_dev(hw), "next proto key builder:\n");
+	dev_info(ice_hw_to_dev(hw), "\tops = %d\n", kb->opc);
+	dev_info(ice_hw_to_dev(hw), "\tstart_or_reg0 = %d\n",
+		 kb->start_reg0);
+	dev_info(ice_hw_to_dev(hw), "\tlen_or_reg1 = %d\n", kb->len_reg1);
+}
+
+static void _ice_imem_pg_kb_dump(struct ice_hw *hw,
+				 struct ice_pg_keybuilder *kb)
+{
+	dev_info(ice_hw_to_dev(hw), "parse graph key builder:\n");
+	dev_info(ice_hw_to_dev(hw), "\tflag0_ena = %d\n", kb->flag0_ena);
+	dev_info(ice_hw_to_dev(hw), "\tflag1_ena = %d\n", kb->flag1_ena);
+	dev_info(ice_hw_to_dev(hw), "\tflag2_ena = %d\n", kb->flag2_ena);
+	dev_info(ice_hw_to_dev(hw), "\tflag3_ena = %d\n", kb->flag3_ena);
+	dev_info(ice_hw_to_dev(hw), "\tflag0_idx = %d\n", kb->flag0_idx);
+	dev_info(ice_hw_to_dev(hw), "\tflag1_idx = %d\n", kb->flag1_idx);
+	dev_info(ice_hw_to_dev(hw), "\tflag2_idx = %d\n", kb->flag2_idx);
+	dev_info(ice_hw_to_dev(hw), "\tflag3_idx = %d\n", kb->flag3_idx);
+	dev_info(ice_hw_to_dev(hw), "\talu_reg_idx = %d\n", kb->alu_reg_idx);
+}
+
+static void _ice_imem_alu_dump(struct ice_hw *hw,
+			       struct ice_alu *alu, int index)
+{
+	dev_info(ice_hw_to_dev(hw), "alu%d:\n", index);
+	dev_info(ice_hw_to_dev(hw), "\topc = %d\n", alu->opc);
+	dev_info(ice_hw_to_dev(hw), "\tsrc_start = %d\n", alu->src_start);
+	dev_info(ice_hw_to_dev(hw), "\tsrc_len = %d\n", alu->src_len);
+	dev_info(ice_hw_to_dev(hw), "\tshift_xlate_sel = %d\n",
+		 alu->shift_xlate_sel);
+	dev_info(ice_hw_to_dev(hw), "\tshift_xlate_key = %d\n",
+		 alu->shift_xlate_key);
+	dev_info(ice_hw_to_dev(hw), "\tsrc_reg_id = %d\n", alu->src_reg_id);
+	dev_info(ice_hw_to_dev(hw), "\tdst_reg_id = %d\n", alu->dst_reg_id);
+	dev_info(ice_hw_to_dev(hw), "\tinc0 = %d\n", alu->inc0);
+	dev_info(ice_hw_to_dev(hw), "\tinc1 = %d\n", alu->inc1);
+	dev_info(ice_hw_to_dev(hw), "\tproto_offset_opc = %d\n",
+		 alu->proto_offset_opc);
+	dev_info(ice_hw_to_dev(hw), "\tproto_offset = %d\n",
+		 alu->proto_offset);
+	dev_info(ice_hw_to_dev(hw), "\tbranch_addr = %d\n", alu->branch_addr);
+	dev_info(ice_hw_to_dev(hw), "\timm = %d\n", alu->imm);
+	dev_info(ice_hw_to_dev(hw), "\tdst_start = %d\n", alu->dst_start);
+	dev_info(ice_hw_to_dev(hw), "\tdst_len = %d\n", alu->dst_len);
+	dev_info(ice_hw_to_dev(hw), "\tflags_extr_imm = %d\n",
+		 alu->flags_extr_imm);
+	dev_info(ice_hw_to_dev(hw), "\tflags_start_imm= %d\n",
+		 alu->flags_start_imm);
+}
+
+/**
+ * ice_imem_dump - dump an imem item info
+ * @hw: pointer to the hardware structure
+ * @item: imem item to dump
+ */
+void ice_imem_dump(struct ice_hw *hw, struct ice_imem_item *item)
+{
+	dev_info(ice_hw_to_dev(hw), "index = %d\n", item->idx);
+	_ice_imem_bst_bm_dump(hw, &item->b_m);
+	_ice_imem_bst_kb_dump(hw, &item->b_kb);
+	dev_info(ice_hw_to_dev(hw), "pg priority = %d\n", item->pg_pri);
+	_ice_imem_np_kb_dump(hw, &item->np_kb);
+	_ice_imem_pg_kb_dump(hw, &item->pg_kb);
+	_ice_imem_alu_dump(hw, &item->alu0, 0);
+	_ice_imem_alu_dump(hw, &item->alu1, 1);
+	_ice_imem_alu_dump(hw, &item->alu2, 2);
+}
+
+/** The function parses a 4 bits Boost Main with below format:
+ *  BIT 0: ALU 0	(bm->alu0)
+ *  BIT 1: ALU 1	(bm->alu1)
+ *  BIT 2: ALU 2	(bm->alu2)
+ *  BIT 3: Parge Graph	(bm->pg)
+ */
+static void _ice_imem_bm_init(struct ice_bst_main *bm, u8 data)
+{
+	bm->alu0	= !!(data & ICE_BM_ALU0);
+	bm->alu1	= !!(data & ICE_BM_ALU1);
+	bm->alu2	= !!(data & ICE_BM_ALU2);
+	bm->pg		= !!(data & ICE_BM_PG);
+}
+
+/** The function parses a 10 bits Boost Main Build with below format:
+ *  BIT 0-7:	Priority	(bkb->prio)
+ *  BIT 8:	TSR Control	(bkb->tsr_ctrl)
+ *  BIT 9:	Reserved
+ */
+static void _ice_imem_bkb_init(struct ice_bst_keybuilder *bkb, u16 data)
+{
+	bkb->prio	= (u8)(data & ICE_BKB_PRIO_M);
+	bkb->tsr_ctrl	= !!(data >> ICE_BKB_TSRC_S & ICE_BKB_TSRC_M);
+}
+
+/** The function parses a 18 bits Next Protocol Key Build with below format:
+ *  BIT 0-1:	Opcode		(kb->ops)
+ *  BIT 2-9:	Start / Reg 0	(kb->start_or_reg0)
+ *  BIT 10-17:	Length / Reg 1	(kb->len_or_reg1)
+ */
+static void _ice_imem_npkb_init(struct ice_np_keybuilder *kb, u32 data)
+{
+	kb->opc		= (u8)(data & ICE_NPKB_OPC_M);
+	kb->start_reg0	= (u8)((data >> ICE_NPKB_SR0_S) & ICE_NPKB_SR0_M);
+	kb->len_reg1	= (u8)((data >> ICE_NPKB_LR1_S) & ICE_NPKB_LR1_M);
+}
+
+/** The function parses a 35 bits Parse Graph Key Build with below format:
+ *  BIT 0:	Flag 0 Enable		(kb->flag0_ena)
+ *  BIT 1-6:	Flag 0 Index		(kb->flag0_idx)
+ *  BIT 7:	Flag 1 Enable		(kb->flag1_ena)
+ *  BIT 8-13:	Flag 1 Index		(kb->flag1_idx)
+ *  BIT 14:	Flag 2 Enable		(kb->flag2_ena)
+ *  BIT 15-20:	Flag 2 Index		(kb->flag2_idx)
+ *  BIT 21:	Flag 3 Enable		(kb->flag3_ena)
+ *  BIT 22-27:	Flag 3 Index		(kb->flag3_idx)
+ *  BIT 28-34:	ALU Register Index	(kb->alu_reg_idx)
+ */
+static void _ice_imem_pgkb_init(struct ice_pg_keybuilder *kb, u64 data)
+{
+	kb->flag0_ena	= !!(data & ICE_PGKB_F0E_M);
+	kb->flag0_idx	= (u8)((data >> ICE_PGKB_F0I_S) & ICE_PGKB_F0I_M);
+	kb->flag1_ena	= !!((data >> ICE_PGKB_F1E_S) & ICE_PGKB_F1E_M);
+	kb->flag1_idx	= (u8)((data >> ICE_PGKB_F1I_S) & ICE_PGKB_F1I_M);
+	kb->flag2_ena	= !!((data >> ICE_PGKB_F2E_S) & ICE_PGKB_F2E_M);
+	kb->flag2_idx	= (u8)((data >> ICE_PGKB_F2I_S) & ICE_PGKB_F2I_M);
+	kb->flag3_ena	= !!((data >> ICE_PGKB_F3E_S) & ICE_PGKB_F3E_M);
+	kb->flag3_idx	= (u8)((data >> ICE_PGKB_F3I_S) & ICE_PGKB_F3I_M);
+	kb->alu_reg_idx	= (u8)((data >> ICE_PGKB_ARI_S) & ICE_PGKB_ARI_M);
+}
+
+/** The function parses a 96 bits ALU entry with below format:
+ *  BIT 0-5:	Opcode			(alu->opc)
+ *  BIT 6-13:	Source Start		(alu->src_start)
+ *  BIT 14-18:	Source Length		(alu->src_len)
+ *  BIT 19:	Shift/Xlate Select	(alu->shift_xlate_select)
+ *  BIT 20-23:	Shift/Xlate Key		(alu->shift_xlate_key)
+ *  BIT 24-30:	Source Register ID	(alu->src_reg_id)
+ *  BIT 31-37:	Dest. Register ID	(alu->dst_reg_id)
+ *  BIT 38:	Inc0			(alu->inc0)
+ *  BIT 39:	Inc1			(alu->inc1)
+ *  BIT 40:41	Protocol Offset Opcode	(alu->proto_offset_opc)
+ *  BIT 42:49	Protocol Offset		(alu->proto_offset)
+ *  BIT 50:57	Branch Address		(alu->branch_addr)
+ *  BIT 58:73	Immediate		(alu->imm)
+ *  BIT 74	Dedicated Flags Enable	(alu->dedicate_flags_ena)
+ *  BIT 75:80	Dest. Start		(alu->dst_start)
+ *  BIT 81:86	Dest. Length		(alu->dst_len)
+ *  BIT 87	Flags Extract Imm.	(alu->flags_extr_imm)
+ *  BIT 88:95	Flags Start/Immediate	(alu->flags_start_imm)
+ */
+static void _ice_imem_alu_init(struct ice_alu *alu, u8 *data, u8 off)
+{
+	u64 d64;
+	u8 idd;
+
+	d64 = *((u64 *)data) >> off;
+
+	alu->opc		= (enum ice_alu_opcode)(d64 & ICE_ALU_OPC_M);
+	alu->src_start		= (u8)((d64 >> ICE_ALU_SS_S) & ICE_ALU_SS_M);
+	alu->src_len		= (u8)((d64 >> ICE_ALU_SL_S) & ICE_ALU_SL_M);
+	alu->shift_xlate_sel	= !!((d64 >> ICE_ALU_SXS_S) & ICE_ALU_SXS_M);
+	alu->shift_xlate_key	= (u8)((d64 >> ICE_ALU_SXK_S) & ICE_ALU_SXK_M);
+	alu->src_reg_id		= (u8)((d64 >> ICE_ALU_SRI_S) & ICE_ALU_SRI_M);
+	alu->dst_reg_id		= (u8)((d64 >> ICE_ALU_DRI_S) & ICE_ALU_DRI_M);
+	alu->inc0		= !!((d64 >> ICE_ALU_INC0_S) & ICE_ALU_INC0_M);
+	alu->inc1		= !!((d64 >> ICE_ALU_INC1_S) & ICE_ALU_INC1_M);
+	alu->proto_offset_opc	= (u8)((d64 >> ICE_ALU_POO_S) & ICE_ALU_POO_M);
+	alu->proto_offset	= (u8)((d64 >> ICE_ALU_PO_S) & ICE_ALU_PO_M);
+
+	idd = (ICE_ALU_BA_S + off) / BITS_PER_BYTE;
+	off = (ICE_ALU_BA_S + off) % BITS_PER_BYTE;
+	d64 = *((u64 *)(&data[idd])) >> off;
+
+	alu->branch_addr	= (u8)(d64 & ICE_ALU_BA_M);
+	off			= ICE_ALU_IMM_S - ICE_ALU_BA_S;
+	alu->imm		= (u16)((d64 >> off) & ICE_ALU_IMM_M);
+	off			= ICE_ALU_DFE_S - ICE_ALU_BA_S;
+	alu->dedicate_flags_ena	= !!((d64 >> off) & ICE_ALU_DFE_M);
+	off			= ICE_ALU_DS_S - ICE_ALU_BA_S;
+	alu->dst_start		= (u8)((d64 >> off) & ICE_ALU_DS_M);
+	off			= ICE_ALU_DL_S - ICE_ALU_BA_S;
+	alu->dst_len		= (u8)((d64 >> off) & ICE_ALU_DL_M);
+	off			= ICE_ALU_FEI_S - ICE_ALU_BA_S;
+	alu->flags_extr_imm	= !!((d64 >> off) & ICE_ALU_FEI_M);
+	off			= ICE_ALU_FSI_S - ICE_ALU_BA_S;
+	alu->flags_start_imm	= (u8)((d64 >> off) & ICE_ALU_FSI_M);
+}
+
+/** The function parses a 384 bits IMEM entry with below format:
+ *  BIT 0-3:	Boost Main		(ii->b_m)
+ *  BIT 4-13:	Boost Key Build		(ii->b_kb)
+ *  BIT 14-15:	PG Priority		(ii->pg)
+ *  BIT 16-33:	Next Proto Key Build	(ii->np_kb)
+ *  BIT 34-68:	PG Key Build		(ii->pg_kb)
+ *  BIT 69-164:	ALU0			(ii->alu0)
+ *  BIT 165-260:ALU1			(ii->alu1)
+ *  BIT 261-356:ALU2			(ii->alu2)
+ *  BIT 357-383:Reserved
+ */
+static void _ice_imem_parse_item(struct ice_hw *hw, u16 idx, void *item,
+				 void *data, int size)
+{
+	struct ice_imem_item *ii = item;
+	u8 *buf = (u8 *)data;
+	u8 idd, off;
+
+	ii->idx = idx;
+
+	_ice_imem_bm_init(&ii->b_m, *(u8 *)buf);
+
+	idd = ICE_IMEM_BKB_S / BITS_PER_BYTE;
+	off = ICE_IMEM_BKB_S % BITS_PER_BYTE;
+	_ice_imem_bkb_init(&ii->b_kb, *((u16 *)(&buf[idd])) >> off);
+
+	ii->pg_pri = (u8)((*(u16 *)buf >> ICE_IMEM_PGP_S) & ICE_IMEM_PGP_M);
+
+	idd = ICE_IMEM_NPKB_S / BITS_PER_BYTE;
+	off = ICE_IMEM_NPKB_S % BITS_PER_BYTE;
+	_ice_imem_npkb_init(&ii->np_kb, *((u32 *)(&buf[idd])) >> off);
+
+	idd = ICE_IMEM_PGKB_S / BITS_PER_BYTE;
+	off = ICE_IMEM_PGKB_S % BITS_PER_BYTE;
+	_ice_imem_pgkb_init(&ii->pg_kb, *((u64 *)(&buf[idd])) >> off);
+
+	idd = ICE_IMEM_ALU0_S / BITS_PER_BYTE;
+	off = ICE_IMEM_ALU0_S % BITS_PER_BYTE;
+	_ice_imem_alu_init(&ii->alu0, &buf[idd], off);
+
+	idd = ICE_IMEM_ALU1_S / BITS_PER_BYTE;
+	off = ICE_IMEM_ALU1_S % BITS_PER_BYTE;
+	_ice_imem_alu_init(&ii->alu1, &buf[idd], off);
+
+	idd = ICE_IMEM_ALU2_S / BITS_PER_BYTE;
+	off = ICE_IMEM_ALU2_S % BITS_PER_BYTE;
+	_ice_imem_alu_init(&ii->alu2, &buf[idd], off);
+
+	if (hw->debug_mask & ICE_DBG_PARSER)
+		ice_imem_dump(hw, ii);
+}
+
+/**
+ * ice_imem_table_get - create an imem table
+ * @hw: pointer to the hardware structure
+ */
+struct ice_imem_item *ice_imem_table_get(struct ice_hw *hw)
+{
+	return (struct ice_imem_item *)
+		ice_parser_create_table(hw, ICE_SID_RXPARSER_IMEM,
+					sizeof(struct ice_imem_item),
+					ICE_IMEM_TABLE_SIZE,
+					ice_parser_sect_item_get,
+					_ice_imem_parse_item);
+}
drivers/net/ethernet/intel/ice/ice_imem.h new file +217 -0

217 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_parser.c +97 -0

122 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_parser.h +8 -0
index c6cd74c6e434..3450830db473 100644
@@ -4,8 +4,16 @@
 #ifndef _ICE_PARSER_H_
 #define _ICE_PARSER_H_
 
+#include "ice_imem.h"
+
+#define ICE_SEC_DATA_OFFSET				4
+#define ICE_SID_RXPARSER_IMEM_ENTRY_SIZE		48
+
 struct ice_parser {
 	struct ice_hw *hw; /* pointer to the hardware structure */
+
+	/* load data from section ICE_SID_RX_PARSER_IMEM */
+	struct ice_imem_item *imem_table;
 };
 
 int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
drivers/net/ethernet/intel/ice/ice_parser_util.h new file +24 -0
new file mode 100644
index 000000000000..6259d3d97b23
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#ifndef _ICE_PARSER_UTIL_H_
+#define _ICE_PARSER_UTIL_H_
+
+#include "ice_imem.h"
+
+struct ice_pkg_sect_hdr {
+	__le16 count;
+	__le16 offset;
+};
+
+void *ice_parser_sect_item_get(u32 sect_type, void *section,
+			       u32 index, u32 *offset);
+
+void *ice_parser_create_table(struct ice_hw *hw, u32 sect_type,
+			      u32 item_size, u32 length,
+			      void *(*handler)(u32 sect_type, void *section,
+					       u32 index, u32 *offset),
+			      void (*parse_item)(struct ice_hw *hw, u16 idx,
+						 void *item, void *data,
+						 int size));
+#endif /* _ICE_PARSER_UTIL_H_ */
drivers/net/ethernet/intel/ice/ice_type.h +1 -0
index a09556e57803..fa4336dd55f7 100644
@@ -60,6 +60,7 @@ static inline u32 ice_round_to_num(u32 N, u32 R)
 				 ICE_DBG_AQ_DESC	| \
 				 ICE_DBG_AQ_DESC_BUF	| \
 				 ICE_DBG_AQ_CMD)
+#define ICE_DBG_PARSER		BIT_ULL(28)
 
 #define ICE_DBG_USER		BIT_ULL(31)
 
Signature · 6 lines
2.25.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
#41 lore raw

Re: [Intel-wired-lan] [PATCH net-next v4 02/15] ice: init imem table for parser

Masks and shifts can be simplified by FIELD_GET() macro from linux/bitfield.h... See below...

Quoted 120 lines · Junfeng Guo

Parse DDP section ICE_SID_RXPARSER_IMEM into an arrary of struct ice_imem_item.

---
  drivers/net/ethernet/intel/ice/ice_imem.c     | 279 ++++++++++++++++++
  drivers/net/ethernet/intel/ice/ice_imem.h     | 217 ++++++++++++++
  drivers/net/ethernet/intel/ice/ice_parser.c   |  97 ++++++
  drivers/net/ethernet/intel/ice/ice_parser.h   |   8 +
  .../net/ethernet/intel/ice/ice_parser_util.h  |  24 ++
  drivers/net/ethernet/intel/ice/ice_type.h     |   1 +
  6 files changed, 626 insertions(+)

create mode 100644 drivers/net/ethernet/intel/ice/ice_imem.c create mode 100644 drivers/net/ethernet/intel/ice/ice_imem.h create mode 100644 drivers/net/ethernet/intel/ice/ice_parser_util.h

drivers/net/ethernet/intel/ice/ice_imem.c new file +98 -0
new file mode 100644
index 000000000000..a47748d1b1bf
@@ -0,0 +1,279 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#include "ice_common.h"
+#include "ice_parser_util.h"
+
+static void _ice_imem_bst_bm_dump(struct ice_hw *hw, struct ice_bst_main *bm)
+{
+	dev_info(ice_hw_to_dev(hw), "boost main:\n");
+	dev_info(ice_hw_to_dev(hw), "\talu0 = %d\n", bm->alu0);
+	dev_info(ice_hw_to_dev(hw), "\talu1 = %d\n", bm->alu1);
+	dev_info(ice_hw_to_dev(hw), "\talu2 = %d\n", bm->alu2);
+	dev_info(ice_hw_to_dev(hw), "\tpg = %d\n", bm->pg);
+}
+
+static void _ice_imem_bst_kb_dump(struct ice_hw *hw,
+				  struct ice_bst_keybuilder *kb)
+{
+	dev_info(ice_hw_to_dev(hw), "boost key builder:\n");
+	dev_info(ice_hw_to_dev(hw), "\tpriority = %d\n", kb->prio);
+	dev_info(ice_hw_to_dev(hw), "\ttsr_ctrl = %d\n", kb->tsr_ctrl);
+}
+
+static void _ice_imem_np_kb_dump(struct ice_hw *hw,
+				 struct ice_np_keybuilder *kb)
+{
+	dev_info(ice_hw_to_dev(hw), "next proto key builder:\n");
+	dev_info(ice_hw_to_dev(hw), "\tops = %d\n", kb->opc);
+	dev_info(ice_hw_to_dev(hw), "\tstart_or_reg0 = %d\n",
+		 kb->start_reg0);
+	dev_info(ice_hw_to_dev(hw), "\tlen_or_reg1 = %d\n", kb->len_reg1);
+}
+
+static void _ice_imem_pg_kb_dump(struct ice_hw *hw,
+				 struct ice_pg_keybuilder *kb)
+{
+	dev_info(ice_hw_to_dev(hw), "parse graph key builder:\n");
+	dev_info(ice_hw_to_dev(hw), "\tflag0_ena = %d\n", kb->flag0_ena);
+	dev_info(ice_hw_to_dev(hw), "\tflag1_ena = %d\n", kb->flag1_ena);
+	dev_info(ice_hw_to_dev(hw), "\tflag2_ena = %d\n", kb->flag2_ena);
+	dev_info(ice_hw_to_dev(hw), "\tflag3_ena = %d\n", kb->flag3_ena);
+	dev_info(ice_hw_to_dev(hw), "\tflag0_idx = %d\n", kb->flag0_idx);
+	dev_info(ice_hw_to_dev(hw), "\tflag1_idx = %d\n", kb->flag1_idx);
+	dev_info(ice_hw_to_dev(hw), "\tflag2_idx = %d\n", kb->flag2_idx);
+	dev_info(ice_hw_to_dev(hw), "\tflag3_idx = %d\n", kb->flag3_idx);
+	dev_info(ice_hw_to_dev(hw), "\talu_reg_idx = %d\n", kb->alu_reg_idx);
+}
+
+static void _ice_imem_alu_dump(struct ice_hw *hw,
+			       struct ice_alu *alu, int index)
+{
+	dev_info(ice_hw_to_dev(hw), "alu%d:\n", index);
+	dev_info(ice_hw_to_dev(hw), "\topc = %d\n", alu->opc);
+	dev_info(ice_hw_to_dev(hw), "\tsrc_start = %d\n", alu->src_start);
+	dev_info(ice_hw_to_dev(hw), "\tsrc_len = %d\n", alu->src_len);
+	dev_info(ice_hw_to_dev(hw), "\tshift_xlate_sel = %d\n",
+		 alu->shift_xlate_sel);
+	dev_info(ice_hw_to_dev(hw), "\tshift_xlate_key = %d\n",
+		 alu->shift_xlate_key);
+	dev_info(ice_hw_to_dev(hw), "\tsrc_reg_id = %d\n", alu->src_reg_id);
+	dev_info(ice_hw_to_dev(hw), "\tdst_reg_id = %d\n", alu->dst_reg_id);
+	dev_info(ice_hw_to_dev(hw), "\tinc0 = %d\n", alu->inc0);
+	dev_info(ice_hw_to_dev(hw), "\tinc1 = %d\n", alu->inc1);
+	dev_info(ice_hw_to_dev(hw), "\tproto_offset_opc = %d\n",
+		 alu->proto_offset_opc);
+	dev_info(ice_hw_to_dev(hw), "\tproto_offset = %d\n",
+		 alu->proto_offset);
+	dev_info(ice_hw_to_dev(hw), "\tbranch_addr = %d\n", alu->branch_addr);
+	dev_info(ice_hw_to_dev(hw), "\timm = %d\n", alu->imm);
+	dev_info(ice_hw_to_dev(hw), "\tdst_start = %d\n", alu->dst_start);
+	dev_info(ice_hw_to_dev(hw), "\tdst_len = %d\n", alu->dst_len);
+	dev_info(ice_hw_to_dev(hw), "\tflags_extr_imm = %d\n",
+		 alu->flags_extr_imm);
+	dev_info(ice_hw_to_dev(hw), "\tflags_start_imm= %d\n",
+		 alu->flags_start_imm);
+}
+
+/**
+ * ice_imem_dump - dump an imem item info
+ * @hw: pointer to the hardware structure
+ * @item: imem item to dump
+ */
+void ice_imem_dump(struct ice_hw *hw, struct ice_imem_item *item)
+{
+	dev_info(ice_hw_to_dev(hw), "index = %d\n", item->idx);
+	_ice_imem_bst_bm_dump(hw, &item->b_m);
+	_ice_imem_bst_kb_dump(hw, &item->b_kb);
+	dev_info(ice_hw_to_dev(hw), "pg priority = %d\n", item->pg_pri);
+	_ice_imem_np_kb_dump(hw, &item->np_kb);
+	_ice_imem_pg_kb_dump(hw, &item->pg_kb);
+	_ice_imem_alu_dump(hw, &item->alu0, 0);
+	_ice_imem_alu_dump(hw, &item->alu1, 1);
+	_ice_imem_alu_dump(hw, &item->alu2, 2);
+}
+
+/** The function parses a 4 bits Boost Main with below format:
+ *  BIT 0: ALU 0	(bm->alu0)
+ *  BIT 1: ALU 1	(bm->alu1)

drivers/net/ethernet/intel/ice/ice_imem.c line 108

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +10 -0
+ *  BIT 2: ALU 2	(bm->alu2)
+ *  BIT 3: Parge Graph	(bm->pg)
+ */
+static void _ice_imem_bm_init(struct ice_bst_main *bm, u8 data)
+{
+	bm->alu0	= !!(data & ICE_BM_ALU0);
+	bm->alu1	= !!(data & ICE_BM_ALU1);
+	bm->alu2	= !!(data & ICE_BM_ALU2);
+	bm->pg		= !!(data & ICE_BM_PG);
+}

Can be written as:
#define ICE_BM_ALU0 BIT(0)
#define ICE_BM_ALU1 BIT(1)
#define ICE_BM_ALU2 BIT(2)
#define ICE_BM_PG BIT(3)
...
bm->alu0 = FIELD_GET(ICE_BM_ALU0, data);
bm->alu1 = FIELD_GET(ICE_BM_ALU1, data);
bm->alu2 = FIELD_GET(ICE_BM_ALU2, data);
bm->pg = FIELD_GET(ICE_BM_PG, data);

drivers/net/ethernet/intel/ice/ice_imem.c line 119

Quoted 11 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +11 -0
+
+/** The function parses a 10 bits Boost Main Build with below format:
+ *  BIT 0-7:	Priority	(bkb->prio)
+ *  BIT 8:	TSR Control	(bkb->tsr_ctrl)
+ *  BIT 9:	Reserved
+ */
+static void _ice_imem_bkb_init(struct ice_bst_keybuilder *bkb, u16 data)
+{
+	bkb->prio	= (u8)(data & ICE_BKB_PRIO_M);
+	bkb->tsr_ctrl	= !!(data >> ICE_BKB_TSRC_S & ICE_BKB_TSRC_M);
+}

Here:
#define ICE_BKB_PRIO GENMASK(7, 0)
#define ICE_BKB_TSRC BIT(8)
...
bkb->prio = FIELD_GET(ICE_BKB_PRIO, data);
bkb->tsr_ctrl = FIELD_GET(ICE_BKB_TSRC, data);

drivers/net/ethernet/intel/ice/ice_imem.c line 131

Quoted 12 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +12 -0
+
+/** The function parses a 18 bits Next Protocol Key Build with below format:
+ *  BIT 0-1:	Opcode		(kb->ops)
+ *  BIT 2-9:	Start / Reg 0	(kb->start_or_reg0)
+ *  BIT 10-17:	Length / Reg 1	(kb->len_or_reg1)
+ */
+static void _ice_imem_npkb_init(struct ice_np_keybuilder *kb, u32 data)
+{
+	kb->opc		= (u8)(data & ICE_NPKB_OPC_M);
+	kb->start_reg0	= (u8)((data >> ICE_NPKB_SR0_S) & ICE_NPKB_SR0_M);
+	kb->len_reg1	= (u8)((data >> ICE_NPKB_LR1_S) & ICE_NPKB_LR1_M);
+}

Likewise... etc etc etc in other parts below.

The advantage of this is that you don't need to specify defines for mask and shift separately... Just use BIT for single bit field or GENMASK for multi-bit field and FIELD_GET takes care about masking & shifting. Code is more readable...

Quoted 557 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +148 -0
+
+/** The function parses a 35 bits Parse Graph Key Build with below format:
+ *  BIT 0:	Flag 0 Enable		(kb->flag0_ena)
+ *  BIT 1-6:	Flag 0 Index		(kb->flag0_idx)
+ *  BIT 7:	Flag 1 Enable		(kb->flag1_ena)
+ *  BIT 8-13:	Flag 1 Index		(kb->flag1_idx)
+ *  BIT 14:	Flag 2 Enable		(kb->flag2_ena)
+ *  BIT 15-20:	Flag 2 Index		(kb->flag2_idx)
+ *  BIT 21:	Flag 3 Enable		(kb->flag3_ena)
+ *  BIT 22-27:	Flag 3 Index		(kb->flag3_idx)
+ *  BIT 28-34:	ALU Register Index	(kb->alu_reg_idx)
+ */
+static void _ice_imem_pgkb_init(struct ice_pg_keybuilder *kb, u64 data)
+{
+	kb->flag0_ena	= !!(data & ICE_PGKB_F0E_M);
+	kb->flag0_idx	= (u8)((data >> ICE_PGKB_F0I_S) & ICE_PGKB_F0I_M);
+	kb->flag1_ena	= !!((data >> ICE_PGKB_F1E_S) & ICE_PGKB_F1E_M);
+	kb->flag1_idx	= (u8)((data >> ICE_PGKB_F1I_S) & ICE_PGKB_F1I_M);
+	kb->flag2_ena	= !!((data >> ICE_PGKB_F2E_S) & ICE_PGKB_F2E_M);
+	kb->flag2_idx	= (u8)((data >> ICE_PGKB_F2I_S) & ICE_PGKB_F2I_M);
+	kb->flag3_ena	= !!((data >> ICE_PGKB_F3E_S) & ICE_PGKB_F3E_M);
+	kb->flag3_idx	= (u8)((data >> ICE_PGKB_F3I_S) & ICE_PGKB_F3I_M);
+	kb->alu_reg_idx	= (u8)((data >> ICE_PGKB_ARI_S) & ICE_PGKB_ARI_M);
+}
+
+/** The function parses a 96 bits ALU entry with below format:
+ *  BIT 0-5:	Opcode			(alu->opc)
+ *  BIT 6-13:	Source Start		(alu->src_start)
+ *  BIT 14-18:	Source Length		(alu->src_len)
+ *  BIT 19:	Shift/Xlate Select	(alu->shift_xlate_select)
+ *  BIT 20-23:	Shift/Xlate Key		(alu->shift_xlate_key)
+ *  BIT 24-30:	Source Register ID	(alu->src_reg_id)
+ *  BIT 31-37:	Dest. Register ID	(alu->dst_reg_id)
+ *  BIT 38:	Inc0			(alu->inc0)
+ *  BIT 39:	Inc1			(alu->inc1)
+ *  BIT 40:41	Protocol Offset Opcode	(alu->proto_offset_opc)
+ *  BIT 42:49	Protocol Offset		(alu->proto_offset)
+ *  BIT 50:57	Branch Address		(alu->branch_addr)
+ *  BIT 58:73	Immediate		(alu->imm)
+ *  BIT 74	Dedicated Flags Enable	(alu->dedicate_flags_ena)
+ *  BIT 75:80	Dest. Start		(alu->dst_start)
+ *  BIT 81:86	Dest. Length		(alu->dst_len)
+ *  BIT 87	Flags Extract Imm.	(alu->flags_extr_imm)
+ *  BIT 88:95	Flags Start/Immediate	(alu->flags_start_imm)
+ */
+static void _ice_imem_alu_init(struct ice_alu *alu, u8 *data, u8 off)
+{
+	u64 d64;
+	u8 idd;
+
+	d64 = *((u64 *)data) >> off;
+
+	alu->opc		= (enum ice_alu_opcode)(d64 & ICE_ALU_OPC_M);
+	alu->src_start		= (u8)((d64 >> ICE_ALU_SS_S) & ICE_ALU_SS_M);
+	alu->src_len		= (u8)((d64 >> ICE_ALU_SL_S) & ICE_ALU_SL_M);
+	alu->shift_xlate_sel	= !!((d64 >> ICE_ALU_SXS_S) & ICE_ALU_SXS_M);
+	alu->shift_xlate_key	= (u8)((d64 >> ICE_ALU_SXK_S) & ICE_ALU_SXK_M);
+	alu->src_reg_id		= (u8)((d64 >> ICE_ALU_SRI_S) & ICE_ALU_SRI_M);
+	alu->dst_reg_id		= (u8)((d64 >> ICE_ALU_DRI_S) & ICE_ALU_DRI_M);
+	alu->inc0		= !!((d64 >> ICE_ALU_INC0_S) & ICE_ALU_INC0_M);
+	alu->inc1		= !!((d64 >> ICE_ALU_INC1_S) & ICE_ALU_INC1_M);
+	alu->proto_offset_opc	= (u8)((d64 >> ICE_ALU_POO_S) & ICE_ALU_POO_M);
+	alu->proto_offset	= (u8)((d64 >> ICE_ALU_PO_S) & ICE_ALU_PO_M);
+
+	idd = (ICE_ALU_BA_S + off) / BITS_PER_BYTE;
+	off = (ICE_ALU_BA_S + off) % BITS_PER_BYTE;
+	d64 = *((u64 *)(&data[idd])) >> off;
+
+	alu->branch_addr	= (u8)(d64 & ICE_ALU_BA_M);
+	off			= ICE_ALU_IMM_S - ICE_ALU_BA_S;
+	alu->imm		= (u16)((d64 >> off) & ICE_ALU_IMM_M);
+	off			= ICE_ALU_DFE_S - ICE_ALU_BA_S;
+	alu->dedicate_flags_ena	= !!((d64 >> off) & ICE_ALU_DFE_M);
+	off			= ICE_ALU_DS_S - ICE_ALU_BA_S;
+	alu->dst_start		= (u8)((d64 >> off) & ICE_ALU_DS_M);
+	off			= ICE_ALU_DL_S - ICE_ALU_BA_S;
+	alu->dst_len		= (u8)((d64 >> off) & ICE_ALU_DL_M);
+	off			= ICE_ALU_FEI_S - ICE_ALU_BA_S;
+	alu->flags_extr_imm	= !!((d64 >> off) & ICE_ALU_FEI_M);
+	off			= ICE_ALU_FSI_S - ICE_ALU_BA_S;
+	alu->flags_start_imm	= (u8)((d64 >> off) & ICE_ALU_FSI_M);
+}
+
+/** The function parses a 384 bits IMEM entry with below format:
+ *  BIT 0-3:	Boost Main		(ii->b_m)
+ *  BIT 4-13:	Boost Key Build		(ii->b_kb)
+ *  BIT 14-15:	PG Priority		(ii->pg)
+ *  BIT 16-33:	Next Proto Key Build	(ii->np_kb)
+ *  BIT 34-68:	PG Key Build		(ii->pg_kb)
+ *  BIT 69-164:	ALU0			(ii->alu0)
+ *  BIT 165-260:ALU1			(ii->alu1)
+ *  BIT 261-356:ALU2			(ii->alu2)
+ *  BIT 357-383:Reserved
+ */
+static void _ice_imem_parse_item(struct ice_hw *hw, u16 idx, void *item,
+				 void *data, int size)
+{
+	struct ice_imem_item *ii = item;
+	u8 *buf = (u8 *)data;
+	u8 idd, off;
+
+	ii->idx = idx;
+
+	_ice_imem_bm_init(&ii->b_m, *(u8 *)buf);
+
+	idd = ICE_IMEM_BKB_S / BITS_PER_BYTE;
+	off = ICE_IMEM_BKB_S % BITS_PER_BYTE;
+	_ice_imem_bkb_init(&ii->b_kb, *((u16 *)(&buf[idd])) >> off);
+
+	ii->pg_pri = (u8)((*(u16 *)buf >> ICE_IMEM_PGP_S) & ICE_IMEM_PGP_M);
+
+	idd = ICE_IMEM_NPKB_S / BITS_PER_BYTE;
+	off = ICE_IMEM_NPKB_S % BITS_PER_BYTE;
+	_ice_imem_npkb_init(&ii->np_kb, *((u32 *)(&buf[idd])) >> off);
+
+	idd = ICE_IMEM_PGKB_S / BITS_PER_BYTE;
+	off = ICE_IMEM_PGKB_S % BITS_PER_BYTE;
+	_ice_imem_pgkb_init(&ii->pg_kb, *((u64 *)(&buf[idd])) >> off);
+
+	idd = ICE_IMEM_ALU0_S / BITS_PER_BYTE;
+	off = ICE_IMEM_ALU0_S % BITS_PER_BYTE;
+	_ice_imem_alu_init(&ii->alu0, &buf[idd], off);
+
+	idd = ICE_IMEM_ALU1_S / BITS_PER_BYTE;
+	off = ICE_IMEM_ALU1_S % BITS_PER_BYTE;
+	_ice_imem_alu_init(&ii->alu1, &buf[idd], off);
+
+	idd = ICE_IMEM_ALU2_S / BITS_PER_BYTE;
+	off = ICE_IMEM_ALU2_S % BITS_PER_BYTE;
+	_ice_imem_alu_init(&ii->alu2, &buf[idd], off);
+
+	if (hw->debug_mask & ICE_DBG_PARSER)
+		ice_imem_dump(hw, ii);
+}
+
+/**
+ * ice_imem_table_get - create an imem table
+ * @hw: pointer to the hardware structure
+ */
+struct ice_imem_item *ice_imem_table_get(struct ice_hw *hw)
+{
+	return (struct ice_imem_item *)
+		ice_parser_create_table(hw, ICE_SID_RXPARSER_IMEM,
+					sizeof(struct ice_imem_item),
+					ICE_IMEM_TABLE_SIZE,
+					ice_parser_sect_item_get,
+					_ice_imem_parse_item);
+}
drivers/net/ethernet/intel/ice/ice_imem.h new file +217 -0
new file mode 100644
index 000000000000..50861379659e
@@ -0,0 +1,217 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#ifndef _ICE_IMEM_H_
+#define _ICE_IMEM_H_
+
+#define ICE_IMEM_TABLE_SIZE	192
+
+#define ICE_BM_ALU0	BIT(0)
+#define ICE_BM_ALU1	BIT(1)
+#define ICE_BM_ALU2	BIT(2)
+#define ICE_BM_PG	BIT(3)
+
+struct ice_bst_main {
+	bool alu0;
+	bool alu1;
+	bool alu2;
+	bool pg;
+};
+
+#define ICE_BKB_PRIO_S		0
+#define ICE_BKB_PRIO_M		BITMAP_MASK(8)
+#define ICE_BKB_TSRC_S		8
+#define ICE_BKB_TSRC_M		BITMAP_MASK(1)
+
+struct ice_bst_keybuilder {
+	u8 prio;
+	bool tsr_ctrl;
+};
+
+#define ICE_NPKB_HV_SIZE	8
+
+#define ICE_NPKB_OPC_S		0
+#define ICE_NPKB_OPC_M		BITMAP_MASK(2)
+#define ICE_NPKB_SR0_S		2
+#define ICE_NPKB_SR0_M		BITMAP_MASK(8)
+#define ICE_NPKB_LR1_S		10
+#define ICE_NPKB_LR1_M		BITMAP_MASK(8)
+
+struct ice_np_keybuilder {
+	u8 opc;
+	u8 start_reg0;
+	u8 len_reg1;
+};
+
+enum ice_np_keybuilder_opcode {
+	ICE_NPKB_OPC_EXTRACT	= 0,
+	ICE_NPKB_OPC_BUILD	= 1,
+	ICE_NPKB_OPC_BYPASS	= 2,
+};
+
+#define ICE_PGKB_F0E_S		0
+#define ICE_PGKB_F0E_M		BITMAP_MASK(1)
+#define ICE_PGKB_F0I_S		1
+#define ICE_PGKB_F0I_M		BITMAP_MASK(6)
+#define ICE_PGKB_F1E_S		7
+#define ICE_PGKB_F1E_M		BITMAP_MASK(1)
+#define ICE_PGKB_F1I_S		8
+#define ICE_PGKB_F1I_M		BITMAP_MASK(6)
+#define ICE_PGKB_F2E_S		14
+#define ICE_PGKB_F2E_M		BITMAP_MASK(1)
+#define ICE_PGKB_F2I_S		15
+#define ICE_PGKB_F2I_M		BITMAP_MASK(6)
+#define ICE_PGKB_F3E_S		21
+#define ICE_PGKB_F3E_M		BITMAP_MASK(1)
+#define ICE_PGKB_F3I_S		22
+#define ICE_PGKB_F3I_M		BITMAP_MASK(6)
+#define ICE_PGKB_ARI_S		28
+#define ICE_PGKB_ARI_M		BITMAP_MASK(7)
+
+struct ice_pg_keybuilder {
+	bool flag0_ena;
+	bool flag1_ena;
+	bool flag2_ena;
+	bool flag3_ena;
+	u8 flag0_idx;
+	u8 flag1_idx;
+	u8 flag2_idx;
+	u8 flag3_idx;
+	u8 alu_reg_idx;
+};
+
+enum ice_alu_idx {
+	ICE_ALU0_IDX	= 0,
+	ICE_ALU1_IDX	= 1,
+	ICE_ALU2_IDX	= 2,
+};
+
+enum ice_alu_opcode {
+	ICE_ALU_PARK	= 0,
+	ICE_ALU_MOV_ADD	= 1,
+	ICE_ALU_ADD	= 2,
+	ICE_ALU_MOV_AND	= 4,
+	ICE_ALU_AND	= 5,
+	ICE_ALU_AND_IMM	= 6,
+	ICE_ALU_MOV_OR	= 7,
+	ICE_ALU_OR	= 8,
+	ICE_ALU_MOV_XOR	= 9,
+	ICE_ALU_XOR	= 10,
+	ICE_ALU_NOP	= 11,
+	ICE_ALU_BR	= 12,
+	ICE_ALU_BREQ	= 13,
+	ICE_ALU_BRNEQ	= 14,
+	ICE_ALU_BRGT	= 15,
+	ICE_ALU_BRLT	= 16,
+	ICE_ALU_BRGEQ	= 17,
+	ICE_ALU_BRLEG	= 18,
+	ICE_ALU_SETEQ	= 19,
+	ICE_ALU_ANDEQ	= 20,
+	ICE_ALU_OREQ	= 21,
+	ICE_ALU_SETNEQ	= 22,
+	ICE_ALU_ANDNEQ	= 23,
+	ICE_ALU_ORNEQ	= 24,
+	ICE_ALU_SETGT	= 25,
+	ICE_ALU_ANDGT	= 26,
+	ICE_ALU_ORGT	= 27,
+	ICE_ALU_SETLT	= 28,
+	ICE_ALU_ANDLT	= 29,
+	ICE_ALU_ORLT	= 30,
+	ICE_ALU_MOV_SUB	= 31,
+	ICE_ALU_SUB	= 32,
+	ICE_ALU_INVALID	= 64,
+};
+
+enum ice_proto_off_opcode {
+	ICE_PO_OFF_REMAIN	= 0,
+	ICE_PO_OFF_HDR_ADD	= 1,
+	ICE_PO_OFF_HDR_SUB	= 2,
+};
+
+#define ICE_ALU_REG_SIZE	4
+
+#define ICE_ALU_OPC_S		0
+#define ICE_ALU_OPC_M		BITMAP_MASK(6)
+#define ICE_ALU_SS_S		6
+#define ICE_ALU_SS_M		BITMAP_MASK(8)
+#define ICE_ALU_SL_S		14
+#define ICE_ALU_SL_M		BITMAP_MASK(5)
+#define ICE_ALU_SXS_S		19
+#define ICE_ALU_SXS_M		BITMAP_MASK(1)
+#define ICE_ALU_SXK_S		20
+#define ICE_ALU_SXK_M		BITMAP_MASK(4)
+#define ICE_ALU_SRI_S		24
+#define ICE_ALU_SRI_M		BITMAP_MASK(7)
+#define ICE_ALU_DRI_S		31
+#define ICE_ALU_DRI_M		BITMAP_MASK(7)
+#define ICE_ALU_INC0_S		38
+#define ICE_ALU_INC0_M		BITMAP_MASK(1)
+#define ICE_ALU_INC1_S		39
+#define ICE_ALU_INC1_M		BITMAP_MASK(1)
+#define ICE_ALU_POO_S		40
+#define ICE_ALU_POO_M		BITMAP_MASK(2)
+#define ICE_ALU_PO_S		42
+#define ICE_ALU_PO_M		BITMAP_MASK(8)
+#define ICE_ALU_BA_S		50
+#define ICE_ALU_BA_M		BITMAP_MASK(8)
+#define ICE_ALU_IMM_S		58
+#define ICE_ALU_IMM_M		BITMAP_MASK(16)
+#define ICE_ALU_DFE_S		74
+#define ICE_ALU_DFE_M		BITMAP_MASK(1)
+#define ICE_ALU_DS_S		75
+#define ICE_ALU_DS_M		BITMAP_MASK(6)
+#define ICE_ALU_DL_S		81
+#define ICE_ALU_DL_M		BITMAP_MASK(6)
+#define ICE_ALU_FEI_S		87
+#define ICE_ALU_FEI_M		BITMAP_MASK(1)
+#define ICE_ALU_FSI_S		88
+#define ICE_ALU_FSI_M		BITMAP_MASK(8)
+
+struct ice_alu {
+	enum ice_alu_opcode opc;
+	u8 src_start;
+	u8 src_len;
+	bool shift_xlate_sel;
+	u8 shift_xlate_key;
+	u8 src_reg_id;
+	u8 dst_reg_id;
+	bool inc0;
+	bool inc1;
+	u8 proto_offset_opc;
+	u8 proto_offset;
+	u8 branch_addr;
+	u16 imm;
+	bool dedicate_flags_ena;
+	u8 dst_start;
+	u8 dst_len;
+	bool flags_extr_imm;
+	u8 flags_start_imm;
+};
+
+#define ICE_IMEM_BM_S		0
+#define ICE_IMEM_BM_M		BITMAP_MASK(4)
+#define ICE_IMEM_BKB_S		4
+#define ICE_IMEM_BKB_M		BITMAP_MASK(10)
+#define ICE_IMEM_PGP_S		14
+#define ICE_IMEM_PGP_M		BITMAP_MASK(2)
+#define ICE_IMEM_NPKB_S		16
+#define ICE_IMEM_PGKB_S		34
+#define ICE_IMEM_ALU0_S		69
+#define ICE_IMEM_ALU1_S		165
+#define ICE_IMEM_ALU2_S		357
+
+struct ice_imem_item {
+	u16 idx;
+	struct ice_bst_main b_m;
+	struct ice_bst_keybuilder b_kb;
+	u8 pg_pri;
+	struct ice_np_keybuilder np_kb;
+	struct ice_pg_keybuilder pg_kb;
+	struct ice_alu alu0;
+	struct ice_alu alu1;
+	struct ice_alu alu2;
+};
+
+void ice_imem_dump(struct ice_hw *hw, struct ice_imem_item *item);
+struct ice_imem_item *ice_imem_table_get(struct ice_hw *hw);
+#endif /* _ICE_IMEM_H_ */
drivers/net/ethernet/intel/ice/ice_parser.c +97 -0
index 692ad26ec551..2a543c469fdf 100644
@@ -2,6 +2,91 @@
  /* Copyright (C) 2018-2023 Intel Corporation */
 
  #include "ice_common.h"
+#include "ice_parser_util.h"
+
+/**
+ * ice_parser_sect_item_get - parse a item from a section
+ * @sect_type: section type
+ * @section: section object
+ * @index: index of the item to get
+ * @offset: dummy as prototype of ice_pkg_enum_entry's last parameter
+ */
+void *ice_parser_sect_item_get(u32 sect_type, void *section,
+			       u32 index, u32 *offset)
+{
+	size_t data_off = ICE_SEC_DATA_OFFSET;
+	struct ice_pkg_sect_hdr *hdr;
+	size_t size;
+
+	if (!section)
+		return NULL;
+
+	switch (sect_type) {
+	case ICE_SID_RXPARSER_IMEM:
+		size = ICE_SID_RXPARSER_IMEM_ENTRY_SIZE;
+		break;
+	default:
+		return NULL;
+	}
+
+	hdr = section;
+	if (index >= le16_to_cpu(hdr->count))
+		return NULL;
+
+	return (u8 *)section + data_off + index * size;
+}
+
+/**
+ * ice_parser_create_table - create a item table from a section
+ * @hw: pointer to the hardware structure
+ * @sect_type: section type
+ * @item_size: item size in byte
+ * @length: number of items in the table to create
+ * @item_get: the function will be parsed to ice_pkg_enum_entry
+ * @parse_item: the function to parse the item
+ */
+void *ice_parser_create_table(struct ice_hw *hw, u32 sect_type,
+			      u32 item_size, u32 length,
+			      void *(*item_get)(u32 sect_type, void *section,
+						u32 index, u32 *offset),
+			      void (*parse_item)(struct ice_hw *hw, u16 idx,
+						 void *item, void *data,
+						 int size))
+{
+	struct ice_seg *seg = hw->seg;
+	struct ice_pkg_enum state;
+	u16 idx = U16_MAX;
+	void *table;
+	void *data;
+
+	if (!seg)
+		return NULL;
+
+	table = devm_kzalloc(ice_hw_to_dev(hw), item_size * length,
+			     GFP_KERNEL);
+	if (!table)
+		return NULL;
+
+	memset(&state, 0, sizeof(state));
+	do {
+		data = ice_pkg_enum_entry(seg, &state, sect_type, NULL,
+					  item_get);
+		seg = NULL;
+		if (data) {
+			struct ice_pkg_sect_hdr *hdr =
+				(struct ice_pkg_sect_hdr *)state.sect;
+
+			idx = le16_to_cpu(hdr->offset) + state.entry_idx;
+			parse_item(hw, idx,
+				   (void *)((uintptr_t)table +
+					    ((uintptr_t)idx *
+					     (uintptr_t)item_size)),
+				   data, item_size);
+		}
+	} while (data);
+
+	return table;
+}
 
  /**
   * ice_parser_create - create a parser instance
@@ -11,6 +96,7 @@
  int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr)
  {
  	struct ice_parser *p;
+	int status;
 
  	p = devm_kzalloc(ice_hw_to_dev(hw), sizeof(struct ice_parser),
  			 GFP_KERNEL);
@@ -20,8 +106,17 @@ int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr)
  	p->hw = hw;
  	p->rt.psr = p;
 
+	p->imem_table = ice_imem_table_get(hw);
+	if (!p->imem_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
  	*psr = p;
  	return 0;
+err:
+	ice_parser_destroy(p);
+	return status;
  }
 
  /**
@@ -30,5 +125,7 @@ int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr)
   */
  void ice_parser_destroy(struct ice_parser *psr)
  {
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->imem_table);
+
  	devm_kfree(ice_hw_to_dev(psr->hw), psr);
  }
drivers/net/ethernet/intel/ice/ice_parser.h +8 -0
index c6cd74c6e434..3450830db473 100644
@@ -4,8 +4,16 @@
  #ifndef _ICE_PARSER_H_
  #define _ICE_PARSER_H_
 
+#include "ice_imem.h"
+
+#define ICE_SEC_DATA_OFFSET				4
+#define ICE_SID_RXPARSER_IMEM_ENTRY_SIZE		48
+
  struct ice_parser {
  	struct ice_hw *hw; /* pointer to the hardware structure */
+
+	/* load data from section ICE_SID_RX_PARSER_IMEM */
+	struct ice_imem_item *imem_table;
  };
 
  int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
drivers/net/ethernet/intel/ice/ice_parser_util.h new file +24 -0
new file mode 100644
index 000000000000..6259d3d97b23
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#ifndef _ICE_PARSER_UTIL_H_
+#define _ICE_PARSER_UTIL_H_
+
+#include "ice_imem.h"
+
+struct ice_pkg_sect_hdr {
+	__le16 count;
+	__le16 offset;
+};
+
+void *ice_parser_sect_item_get(u32 sect_type, void *section,
+			       u32 index, u32 *offset);
+
+void *ice_parser_create_table(struct ice_hw *hw, u32 sect_type,
+			      u32 item_size, u32 length,
+			      void *(*handler)(u32 sect_type, void *section,
+					       u32 index, u32 *offset),
+			      void (*parse_item)(struct ice_hw *hw, u16 idx,
+						 void *item, void *data,
+						 int size));
+#endif /* _ICE_PARSER_UTIL_H_ */
drivers/net/ethernet/intel/ice/ice_type.h +0 -0
index a09556e57803..fa4336dd55f7 100644

drivers/net/ethernet/intel/ice/ice_type.h static inline u32 ice_round_to_num(u32 N, u32 R) · line 66

Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_type.h +1 -0
@@ -60,6 +60,7 @@ static inline u32 ice_round_to_num(u32 N, u32 R)
  				 ICE_DBG_AQ_DESC	| \
  				 ICE_DBG_AQ_DESC_BUF	| \
  				 ICE_DBG_AQ_CMD)
+#define ICE_DBG_PARSER		BIT_ULL(28)
 
  #define ICE_DBG_USER		BIT_ULL(31)
 

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#42 lore raw

Re: [Intel-wired-lan] [PATCH net-next v4 02/15] ice: init imem table for parser

Quoted 170 lines

-----Original Message-----
From: Ivan Vecera <[email protected]>
Sent: Tuesday, August 22, 2023 22:58
To: Guo, Junfeng <[email protected]>; intel-wired- [email protected]
Cc: Zhang, Qi Z <[email protected]>; Samudrala, Sridhar <[email protected]>
Subject: Re: [PATCH net-next v4 02/15] ice: init imem table for parser

Masks and shifts can be simplified by FIELD_GET() macro from linux/bitfield.h... See below...

Quoted 6 lines · Junfeng Guo

Parse DDP section ICE_SID_RXPARSER_IMEM into an arrary of struct ice_imem_item.

---
  drivers/net/ethernet/intel/ice/ice_imem.c     | 279

++++++++++++++++++

Quoted 9 lines
  drivers/net/ethernet/intel/ice/ice_imem.h     | 217 ++++++++++++++
  drivers/net/ethernet/intel/ice/ice_parser.c   |  97 ++++++
  drivers/net/ethernet/intel/ice/ice_parser.h   |   8 +
  .../net/ethernet/intel/ice/ice_parser_util.h  |  24 ++
  drivers/net/ethernet/intel/ice/ice_type.h     |   1 +
  6 files changed, 626 insertions(+)

create mode 100644 drivers/net/ethernet/intel/ice/ice_imem.c create mode 100644 drivers/net/ethernet/intel/ice/ice_imem.h create mode 100644

drivers/net/ethernet/intel/ice/ice_parser_util.h

Review

Quoted 2 lines
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_imem.c

drivers/net/ethernet/intel/ice/ice_imem.c line 7

Quoted 12 lines

new file mode 100644
index 000000000000..a47748d1b1bf

drivers/net/ethernet/intel/ice/ice_imem.c new file +7 -0
@@ -0,0 +1,279 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#include "ice_common.h"
+#include "ice_parser_util.h"
+
+static void _ice_imem_bst_bm_dump(struct ice_hw *hw, struct

ice_bst_main *bm)

Quoted 82 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +24 -0
+{
+	dev_info(ice_hw_to_dev(hw), "boost main:\n");
+	dev_info(ice_hw_to_dev(hw), "\talu0 = %d\n", bm->alu0);
+	dev_info(ice_hw_to_dev(hw), "\talu1 = %d\n", bm->alu1);
+	dev_info(ice_hw_to_dev(hw), "\talu2 = %d\n", bm->alu2);
+	dev_info(ice_hw_to_dev(hw), "\tpg = %d\n", bm->pg);
+}
+
+static void _ice_imem_bst_kb_dump(struct ice_hw *hw,
+				  struct ice_bst_keybuilder *kb)
+{
+	dev_info(ice_hw_to_dev(hw), "boost key builder:\n");
+	dev_info(ice_hw_to_dev(hw), "\tpriority = %d\n", kb->prio);
+	dev_info(ice_hw_to_dev(hw), "\ttsr_ctrl = %d\n", kb->tsr_ctrl);
+}
+
+static void _ice_imem_np_kb_dump(struct ice_hw *hw,
+				 struct ice_np_keybuilder *kb)
+{
+	dev_info(ice_hw_to_dev(hw), "next proto key builder:\n");
+	dev_info(ice_hw_to_dev(hw), "\tops = %d\n", kb->opc);
+	dev_info(ice_hw_to_dev(hw), "\tstart_or_reg0 = %d\n",
+		 kb->start_reg0);
+	dev_info(ice_hw_to_dev(hw), "\tlen_or_reg1 = %d\n", kb-

len_reg1);

drivers/net/ethernet/intel/ice/ice_imem.c new file +7 -0
+}
+
+static void _ice_imem_pg_kb_dump(struct ice_hw *hw,
+				 struct ice_pg_keybuilder *kb)
+{
+	dev_info(ice_hw_to_dev(hw), "parse graph key builder:\n");
+	dev_info(ice_hw_to_dev(hw), "\tflag0_ena = %d\n", kb-

flag0_ena);

drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tflag1_ena = %d\n", kb-

flag1_ena);

drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tflag2_ena = %d\n", kb-

flag2_ena);

drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tflag3_ena = %d\n", kb-

flag3_ena);

drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tflag0_idx = %d\n", kb-

flag0_idx);

drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tflag1_idx = %d\n", kb-

flag1_idx);

drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tflag2_idx = %d\n", kb-

flag2_idx);

drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tflag3_idx = %d\n", kb-

flag3_idx);

drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\talu_reg_idx = %d\n", kb-

alu_reg_idx);

drivers/net/ethernet/intel/ice/ice_imem.c new file +8 -0
+}
+
+static void _ice_imem_alu_dump(struct ice_hw *hw,
+			       struct ice_alu *alu, int index)
+{
+	dev_info(ice_hw_to_dev(hw), "alu%d:\n", index);
+	dev_info(ice_hw_to_dev(hw), "\topc = %d\n", alu->opc);
+	dev_info(ice_hw_to_dev(hw), "\tsrc_start = %d\n", alu-

src_start);

drivers/net/ethernet/intel/ice/ice_imem.c new file +6 -0
+	dev_info(ice_hw_to_dev(hw), "\tsrc_len = %d\n", alu->src_len);
+	dev_info(ice_hw_to_dev(hw), "\tshift_xlate_sel = %d\n",
+		 alu->shift_xlate_sel);
+	dev_info(ice_hw_to_dev(hw), "\tshift_xlate_key = %d\n",
+		 alu->shift_xlate_key);
+	dev_info(ice_hw_to_dev(hw), "\tsrc_reg_id = %d\n", alu-

src_reg_id);

drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tdst_reg_id = %d\n", alu-

dst_reg_id);

drivers/net/ethernet/intel/ice/ice_imem.c new file +7 -0
+	dev_info(ice_hw_to_dev(hw), "\tinc0 = %d\n", alu->inc0);
+	dev_info(ice_hw_to_dev(hw), "\tinc1 = %d\n", alu->inc1);
+	dev_info(ice_hw_to_dev(hw), "\tproto_offset_opc = %d\n",
+		 alu->proto_offset_opc);
+	dev_info(ice_hw_to_dev(hw), "\tproto_offset = %d\n",
+		 alu->proto_offset);
+	dev_info(ice_hw_to_dev(hw), "\tbranch_addr = %d\n", alu-

branch_addr);

drivers/net/ethernet/intel/ice/ice_imem.c new file +2 -0
+	dev_info(ice_hw_to_dev(hw), "\timm = %d\n", alu->imm);
+	dev_info(ice_hw_to_dev(hw), "\tdst_start = %d\n", alu-

dst_start);

drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	dev_info(ice_hw_to_dev(hw), "\tdst_len = %d\n", alu-

dst_len);

drivers/net/ethernet/intel/ice/ice_imem.c new file +2 -0
+	dev_info(ice_hw_to_dev(hw), "\tflags_extr_imm = %d\n",
+		 alu->flags_extr_imm);

drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +10 -0
+	dev_info(ice_hw_to_dev(hw), "\tflags_start_imm= %d\n",
+		 alu->flags_start_imm);
+}
+
+/**
+ * ice_imem_dump - dump an imem item info
+ * @hw: pointer to the hardware structure
+ * @item: imem item to dump
+ */
+void ice_imem_dump(struct ice_hw *hw, struct ice_imem_item

*item)

Quoted 16 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +5 -0
+{
+	dev_info(ice_hw_to_dev(hw), "index = %d\n", item->idx);
+	_ice_imem_bst_bm_dump(hw, &item->b_m);
+	_ice_imem_bst_kb_dump(hw, &item->b_kb);
+	dev_info(ice_hw_to_dev(hw), "pg priority = %d\n", item-

pg_pri);

drivers/net/ethernet/intel/ice/ice_imem.c new file +10 -0
+	_ice_imem_np_kb_dump(hw, &item->np_kb);
+	_ice_imem_pg_kb_dump(hw, &item->pg_kb);
+	_ice_imem_alu_dump(hw, &item->alu0, 0);
+	_ice_imem_alu_dump(hw, &item->alu1, 1);
+	_ice_imem_alu_dump(hw, &item->alu2, 2);
+}
+
+/** The function parses a 4 bits Boost Main with below format:
+ *  BIT 0: ALU 0	(bm->alu0)
+ *  BIT 1: ALU 1	(bm->alu1)

drivers/net/ethernet/intel/ice/ice_imem.c line 108

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +10 -0
+ *  BIT 2: ALU 2	(bm->alu2)
+ *  BIT 3: Parge Graph	(bm->pg)
+ */
+static void _ice_imem_bm_init(struct ice_bst_main *bm, u8 data)
+{
+	bm->alu0	= !!(data & ICE_BM_ALU0);
+	bm->alu1	= !!(data & ICE_BM_ALU1);
+	bm->alu2	= !!(data & ICE_BM_ALU2);
+	bm->pg		= !!(data & ICE_BM_PG);
+}

Can be written as:
#define ICE_BM_ALU0 BIT(0)

Quoted 8 lines

#define ICE_BM_ALU1 BIT(1)
#define ICE_BM_ALU2 BIT(2)
#define ICE_BM_PG BIT(3)
...
bm->alu0 = FIELD_GET(ICE_BM_ALU0, data);
bm->alu1 = FIELD_GET(ICE_BM_ALU1, data);
bm->alu2 = FIELD_GET(ICE_BM_ALU2, data);
bm->pg = FIELD_GET(ICE_BM_PG, data);

Sure, it looks much better!

Thanks for the tips!
Will update these macros in the coming version.

Quoted 40 lines

drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +2 -0
+
+/** The function parses a 10 bits Boost Main Build with below

format:

Quoted 5 lines
+ *  BIT 0-7:	Priority	(bkb->prio)
+ *  BIT 8:	TSR Control	(bkb->tsr_ctrl)
+ *  BIT 9:	Reserved

+ */
+static void _ice_imem_bkb_init(struct ice_bst_keybuilder *bkb, u16

data)

drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +3 -0
+{
+	bkb->prio	= (u8)(data & ICE_BKB_PRIO_M);
+	bkb->tsr_ctrl	= !!(data >> ICE_BKB_TSRC_S &

ICE_BKB_TSRC_M);

Quoted 1 line

+}

Here:
#define ICE_BKB_PRIO GENMASK(7, 0)
#define ICE_BKB_TSRC BIT(8)
...
bkb->prio = FIELD_GET(ICE_BKB_PRIO, data);
bkb->tsr_ctrl = FIELD_GET(ICE_BKB_TSRC, data);

drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 2 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +2 -0
+
+/** The function parses a 18 bits Next Protocol Key Build with

below format:

Quoted 5 lines
+ *  BIT 0-1:	Opcode		(kb->ops)
+ *  BIT 2-9:	Start / Reg 0	(kb->start_or_reg0)
+ *  BIT 10-17:	Length / Reg 1	(kb->len_or_reg1)

+ */
+static void _ice_imem_npkb_init(struct ice_np_keybuilder *kb, u32

data)

drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +3 -0
+{
+	kb->opc		= (u8)(data & ICE_NPKB_OPC_M);
+	kb->start_reg0	= (u8)((data >> ICE_NPKB_SR0_S) &

ICE_NPKB_SR0_M);

drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 1 line
drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	kb->len_reg1	= (u8)((data >> ICE_NPKB_LR1_S) &

ICE_NPKB_LR1_M);

Quoted 1 line

+}

Quoted 7 lines

Likewise... etc etc etc in other parts below.

The advantage of this is that you don't need to specify defines for mask
and shift separately... Just use BIT for single bit field or GENMASK for multi-bit field and FIELD_GET takes care about masking & shifting. Code is more readable...

Yes! Thanks for sharing the tips!

Quoted 594 lines

drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +2 -0
+
+/** The function parses a 35 bits Parse Graph Key Build with below

format:

Quoted 11 lines
+ *  BIT 0:	Flag 0 Enable		(kb->flag0_ena)
+ *  BIT 1-6:	Flag 0 Index		(kb->flag0_idx)
+ *  BIT 7:	Flag 1 Enable		(kb->flag1_ena)
+ *  BIT 8-13:	Flag 1 Index		(kb->flag1_idx)
+ *  BIT 14:	Flag 2 Enable		(kb->flag2_ena)
+ *  BIT 15-20:	Flag 2 Index		(kb->flag2_idx)
+ *  BIT 21:	Flag 3 Enable		(kb->flag3_ena)
+ *  BIT 22-27:	Flag 3 Index		(kb->flag3_idx)
+ *  BIT 28-34:	ALU Register Index	(kb->alu_reg_idx)

+ */
+static void _ice_imem_pgkb_init(struct ice_pg_keybuilder *kb, u64

data)

drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +3 -0
+{
+	kb->flag0_ena	= !!(data & ICE_PGKB_F0E_M);
+	kb->flag0_idx	= (u8)((data >> ICE_PGKB_F0I_S) &

ICE_PGKB_F0I_M);

drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 1 line
drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	kb->flag1_ena	= !!((data >> ICE_PGKB_F1E_S) &

ICE_PGKB_F1E_M);

drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 1 line
drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	kb->flag1_idx	= (u8)((data >> ICE_PGKB_F1I_S) &

ICE_PGKB_F1I_M);

drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 1 line
drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	kb->flag2_ena	= !!((data >> ICE_PGKB_F2E_S) &

ICE_PGKB_F2E_M);

drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 1 line
drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	kb->flag2_idx	= (u8)((data >> ICE_PGKB_F2I_S) &

ICE_PGKB_F2I_M);

drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 1 line
drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	kb->flag3_ena	= !!((data >> ICE_PGKB_F3E_S) &

ICE_PGKB_F3E_M);

drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 1 line
drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	kb->flag3_idx	= (u8)((data >> ICE_PGKB_F3I_S) &

ICE_PGKB_F3I_M);

drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 1 line
drivers/net/ethernet/intel/ice/ice_imem.c new file +1 -0
+	kb->alu_reg_idx	= (u8)((data >> ICE_PGKB_ARI_S) &

ICE_PGKB_ARI_M);

Quoted 20 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +20 -0
+}
+
+/** The function parses a 96 bits ALU entry with below format:
+ *  BIT 0-5:	Opcode			(alu->opc)
+ *  BIT 6-13:	Source Start		(alu->src_start)
+ *  BIT 14-18:	Source Length		(alu->src_len)
+ *  BIT 19:	Shift/Xlate Select	(alu->shift_xlate_select)
+ *  BIT 20-23:	Shift/Xlate Key		(alu->shift_xlate_key)
+ *  BIT 24-30:	Source Register ID	(alu->src_reg_id)
+ *  BIT 31-37:	Dest. Register ID	(alu->dst_reg_id)
+ *  BIT 38:	Inc0			(alu->inc0)
+ *  BIT 39:	Inc1			(alu->inc1)
+ *  BIT 40:41	Protocol Offset Opcode	(alu->proto_offset_opc)
+ *  BIT 42:49	Protocol Offset		(alu->proto_offset)
+ *  BIT 50:57	Branch Address		(alu->branch_addr)
+ *  BIT 58:73	Immediate		(alu->imm)
+ *  BIT 74	Dedicated Flags Enable	(alu->dedicate_flags_ena)
+ *  BIT 75:80	Dest. Start		(alu->dst_start)
+ *  BIT 81:86	Dest. Length		(alu->dst_len)
+ *  BIT 87	Flags Extract Imm.	(alu->flags_extr_imm)

drivers/net/ethernet/intel/ice/ice_imem.c

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_imem.c new file +10 -0
+ *  BIT 88:95	Flags Start/Immediate	(alu->flags_start_imm)
+ */
+static void _ice_imem_alu_init(struct ice_alu *alu, u8 *data, u8 off)
+{
+	u64 d64;
+	u8 idd;
+
+	d64 = *((u64 *)data) >> off;
+
+	alu->opc		= (enum ice_alu_opcode)(d64 &

ICE_ALU_OPC_M);

529 lines not shown · raw message

Quoted 12 lines

12 lines not shown · raw message

4 lines not shown · raw message

Part of this message is not shown here. View the raw message.

#43 lore raw

PATCH v4 3/15 ice: init metainit table for parser

In reply to Junfeng Guo

Parse DDP section ICE_SID_RXPARSER_METADATA_INIT into an array of struct ice_metainit_item.

---
 drivers/net/ethernet/intel/ice/ice_metainit.c | 181 ++++++++++++++++++
 drivers/net/ethernet/intel/ice/ice_metainit.h | 104 ++++++++++
 drivers/net/ethernet/intel/ice/ice_parser.c   |  10 +
 drivers/net/ethernet/intel/ice/ice_parser.h   |   4 +
 .../net/ethernet/intel/ice/ice_parser_util.h  |   1 +
 5 files changed, 300 insertions(+)
 create mode 100644 drivers/net/ethernet/intel/ice/ice_metainit.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_metainit.h
drivers/net/ethernet/intel/ice/ice_metainit.c new file +181 -0
new file mode 100644
index 000000000000..037cb21beddb
@@ -0,0 +1,181 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) 2018-2023 Intel Corporation */
+
+#include "ice_common.h"
+#include "ice_parser_util.h"
+
+/**
+ * ice_metainit_dump - dump an metainit item info
+ * @hw: pointer to the hardware structure
+ * @item: metainit item to dump
+ */
+void ice_metainit_dump(struct ice_hw *hw, struct ice_metainit_item *item)
+{
+	dev_info(ice_hw_to_dev(hw), "index = %d\n", item->idx);
+
+	dev_info(ice_hw_to_dev(hw), "tsr = %d\n", item->tsr);
+	dev_info(ice_hw_to_dev(hw), "ho = %d\n", item->ho);
+	dev_info(ice_hw_to_dev(hw), "pc = %d\n", item->pc);
+	dev_info(ice_hw_to_dev(hw), "pg_rn = %d\n", item->pg_rn);
+	dev_info(ice_hw_to_dev(hw), "cd = %d\n", item->cd);
+
+	dev_info(ice_hw_to_dev(hw), "gpr_a_ctrl = %d\n", item->gpr_a_ctrl);
+	dev_info(ice_hw_to_dev(hw), "gpr_a_data_mdid = %d\n",
+		 item->gpr_a_data_mdid);
+	dev_info(ice_hw_to_dev(hw), "gpr_a_data_start = %d\n",
+		 item->gpr_a_data_start);
+	dev_info(ice_hw_to_dev(hw), "gpr_a_data_len = %d\n",
+		 item->gpr_a_data_len);
+	dev_info(ice_hw_to_dev(hw), "gpr_a_id = %d\n", item->gpr_a_id);
+
+	dev_info(ice_hw_to_dev(hw), "gpr_b_ctrl = %d\n", item->gpr_b_ctrl);
+	dev_info(ice_hw_to_dev(hw), "gpr_b_data_mdid = %d\n",
+		 item->gpr_b_data_mdid);
+	dev_info(ice_hw_to_dev(hw), "gpr_b_data_start = %d\n",
+		 item->gpr_b_data_start);
+	dev_info(ice_hw_to_dev(hw), "gpr_b_data_len = %d\n",
+		 item->gpr_b_data_len);
+	dev_info(ice_hw_to_dev(hw), "gpr_b_id = %d\n", item->gpr_b_id);
+
+	dev_info(ice_hw_to_dev(hw), "gpr_c_ctrl = %d\n", item->gpr_c_ctrl);
+	dev_info(ice_hw_to_dev(hw), "gpr_c_data_mdid = %d\n",
+		 item->gpr_c_data_mdid);
+	dev_info(ice_hw_to_dev(hw), "gpr_c_data_start = %d\n",
+		 item->gpr_c_data_start);
+	dev_info(ice_hw_to_dev(hw), "gpr_c_data_len = %d\n",
+		 item->gpr_c_data_len);
+	dev_info(ice_hw_to_dev(hw), "gpr_c_id = %d\n", item->gpr_c_id);
+
+	dev_info(ice_hw_to_dev(hw), "gpr_d_ctrl = %d\n", item->gpr_d_ctrl);
+	dev_info(ice_hw_to_dev(hw), "gpr_d_data_mdid = %d\n",
+		 item->gpr_d_data_mdid);
+	dev_info(ice_hw_to_dev(hw), "gpr_d_data_start = %d\n",
+		 item->gpr_d_data_start);
+	dev_info(ice_hw_to_dev(hw), "gpr_d_data_len = %d\n",
+		 item->gpr_d_data_len);
+	dev_info(ice_hw_to_dev(hw), "gpr_d_id = %d\n", item->gpr_d_id);
+
+	dev_info(ice_hw_to_dev(hw), "flags = 0x%llx\n",
+		 (unsigned long long)(item->flags));
+}
+
+/** The function parses a 192 bits Metadata Init entry with below format:
+ *  BIT 0-7:	TCAM Search Key Register	(mi->tsr)
+ *  BIT 8-16:	Header Offset			(mi->ho)
+ *  BIT 17-24:	Program Counter			(mi->pc)
+ *  BIT 25-35:	Parse Graph Root Node		(mi->pg_rn)
+ *  BIT 36-38:	Control Domain			(mi->cd)
+ *  BIT 39:	GPR_A Data Control		(mi->gpr_a_ctrl)
+ *  BIT 40-44:	GPR_A MDID.ID			(mi->gpr_a_data_mdid)
+ *  BIT 45-48:	GPR_A MDID.START		(mi->gpr_a_data_start)
+ *  BIT 49-53:	GPR_A MDID.LEN			(mi->gpr_a_data_len)
+ *  BIT 54-55:	reserved
+ *  BIT 56-59:	GPR_A ID			(mi->gpr_a_id)
+ *  BIT 60:	GPR_B Data Control		(mi->gpr_b_ctrl)
+ *  BIT 61-65:	GPR_B MDID.ID			(mi->gpr_b_data_mdid)
+ *  BIT 66-69:	GPR_B MDID.START		(mi->gpr_b_data_start)
+ *  BIT 70-74:	GPR_B MDID.LEN			(mi->gpr_b_data_len)
+ *  BIT 75-76:	reserved
+ *  BIT 77-80:	GPR_B ID			(mi->gpr_a_id)
+ *  BIT 81:	GPR_C Data Control		(mi->gpr_c_ctrl)
+ *  BIT 82-86:	GPR_C MDID.ID			(mi->gpr_c_data_mdid)
+ *  BIT 87-90:	GPR_C MDID.START		(mi->gpr_c_data_start)
+ *  BIT 91-95:	GPR_C MDID.LEN			(mi->gpr_c_data_len)
+ *  BIT 96-97:	reserved
+ *  BIT 98-101:	GPR_C ID			(mi->gpr_c_id)
+ *  BIT 102:	GPR_D Data Control		(mi->gpr_d_ctrl)
+ *  BIT 103-107:GPR_D MDID.ID			(mi->gpr_d_data_mdid)
+ *  BIT 108-111:GPR_D MDID.START		(mi->gpr_d_data_start)
+ *  BIT 112-116:GPR_D MDID.LEN			(mi->gpr_d_data_len)
+ *  BIT 117-118:reserved
+ *  BIT 119-122:GPR_D ID			(mi->gpr_d_id)
+ *  BIT 123-186:Flags				(mi->flags)
+ *  BIT 187-191:rserved
+ */
+static void _ice_metainit_parse_item(struct ice_hw *hw, u16 idx, void *item,
+				     void *data, int size)
+{
+	struct ice_metainit_item *mi = item;
+	u8 *buf = (u8 *)data;
+	u8 idd, off;
+	u64 d64;
+
+	mi->idx = idx;
+
+	d64 = *(u64 *)buf;
+
+	mi->tsr			= (u8)(d64 & ICE_MI_TSR_M);
+	mi->ho			= (u16)((d64 >> ICE_MI_HO_S) & ICE_MI_HO_M);
+	mi->pc			= (u16)((d64 >> ICE_MI_PC_S) & ICE_MI_PC_M);
+	mi->pg_rn		= (u16)((d64 >> ICE_MI_PGRN_S) & ICE_MI_PGRN_M);
+	mi->cd			= (u16)((d64 >> ICE_MI_CD_S) & ICE_MI_CD_M);
+
+	mi->gpr_a_ctrl		= !!((d64 >> ICE_MI_GAC_S) & ICE_MI_GAC_M);
+	mi->gpr_a_data_mdid	= (u8)((d64 >> ICE_MI_GADM_S) & ICE_MI_GADM_M);
+	mi->gpr_a_data_start	= (u8)((d64 >> ICE_MI_GADS_S) & ICE_MI_GADS_M);
+	mi->gpr_a_data_len	= (u8)((d64 >> ICE_MI_GADL_S) & ICE_MI_GADL_M);
+	mi->gpr_a_id		= (u8)((d64 >> ICE_MI_GAI_S) & ICE_MI_GAI_M);
+
+	idd = ICE_MI_GBC_S / BITS_PER_BYTE;
+	off = ICE_MI_GBC_S % BITS_PER_BYTE;
+	d64 = *((u64 *)&buf[idd]) >> off;
+
+	mi->gpr_b_ctrl		= !!(d64 & ICE_MI_GBC_M);
+	off			= ICE_MI_GBDM_S - ICE_MI_GBC_S;
+	mi->gpr_b_data_mdid	= (u8)((d64 >> off) & ICE_MI_GBDM_M);
+	off			= ICE_MI_GBDS_S - ICE_MI_GBC_S;
+	mi->gpr_b_data_start	= (u8)((d64 >> off) & ICE_MI_GBDS_M);
+	off			= ICE_MI_GBDL_S - ICE_MI_GBC_S;
+	mi->gpr_b_data_len	= (u8)((d64 >> off) & ICE_MI_GBDL_M);
+	off			= ICE_MI_GBI_S - ICE_MI_GBC_S;
+	mi->gpr_b_id		= (u8)((d64 >> off) & ICE_MI_GBI_M);
+
+	off			= ICE_MI_GCC_S - ICE_MI_GBC_S;
+	mi->gpr_c_ctrl		= !!((d64 >> off) & ICE_MI_GCC_M);
+	off			= ICE_MI_GCDM_S - ICE_MI_GBC_S;
+	mi->gpr_c_data_mdid	= (u8)((d64 >> off) & ICE_MI_GCDM_M);
+	off			= ICE_MI_GCDS_S - ICE_MI_GBC_S;
+	mi->gpr_c_data_start	= (u8)((d64 >> off) & ICE_MI_GCDS_M);
+	off			= ICE_MI_GCDL_S - ICE_MI_GBC_S;
+	mi->gpr_c_data_len	= (u8)((d64 >> off) & ICE_MI_GCDL_M);
+	off			= ICE_MI_GCI_S - ICE_MI_GBC_S;
+	mi->gpr_c_id		= (u8)((d64 >> off) & ICE_MI_GCI_M);
+
+	off			= ICE_MI_GDC_S - ICE_MI_GBC_S;
+	mi->gpr_d_ctrl		= !!((d64 >> off) & ICE_MI_GDC_M);
+	off			= ICE_MI_GDDM_S - ICE_MI_GBC_S;
+	mi->gpr_d_data_mdid	= (u8)((d64 >> off) & ICE_MI_GDDM_M);
+	off			= ICE_MI_GDDS_S - ICE_MI_GBC_S;
+	mi->gpr_d_data_start	= (u8)((d64 >> off) & ICE_MI_GDDS_M);
+	off			= ICE_MI_GDDL_S - ICE_MI_GBC_S;
+	mi->gpr_d_data_len	= (u8)((d64 >> off) & ICE_MI_GDDL_M);
+
+	idd = ICE_MI_GDI_S / BITS_PER_BYTE;
+	off = ICE_MI_GDI_S % BITS_PER_BYTE;
+	d64 = *((u64 *)&buf[idd]) >> off;
+
+	mi->gpr_d_id = (u8)(d64 & ICE_MI_GDI_M);
+
+	idd = ICE_MI_FLAG_S / BITS_PER_BYTE;
+	off = ICE_MI_FLAG_S % BITS_PER_BYTE;
+	d64 = *((u64 *)&buf[idd]) >> off;
+
+	mi->flags = d64;
+
+	if (hw->debug_mask & ICE_DBG_PARSER)
+		ice_metainit_dump(hw, mi);
+}
+
+/**
+ * ice_metainit_table_get - create a metainit table
+ * @hw: pointer to the hardware structure
+ */
+struct ice_metainit_item *ice_metainit_table_get(struct ice_hw *hw)
+{
+	return (struct ice_metainit_item *)
+		ice_parser_create_table(hw, ICE_SID_RXPARSER_METADATA_INIT,
+					sizeof(struct ice_metainit_item),
+					ICE_METAINIT_TABLE_SIZE,
+					ice_parser_sect_item_get,
+					_ice_metainit_parse_item);
+}
drivers/net/ethernet/intel/ice/ice_metainit.h new file +104 -0

104 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_parser.c +10 -0
index 2a543c469fdf..9520594891d3 100644
@@ -25,6 +25,9 @@ void *ice_parser_sect_item_get(u32 sect_type, void *section,
 	case ICE_SID_RXPARSER_IMEM:
 		size = ICE_SID_RXPARSER_IMEM_ENTRY_SIZE;
 		break;
+	case ICE_SID_RXPARSER_METADATA_INIT:
+		size = ICE_SID_RXPARSER_METADATA_INIT_ENTRY_SIZE;
+		break;
 	default:
 		return NULL;
 	}
@@ -112,6 +115,12 @@ int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr)
 		goto err;
 	}
 
+	p->mi_table = ice_metainit_table_get(hw);
+	if (!p->mi_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
 	*psr = p;
 	return 0;
 err:
@@ -126,6 +135,7 @@ int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr)
 void ice_parser_destroy(struct ice_parser *psr)
 {
 	devm_kfree(ice_hw_to_dev(psr->hw), psr->imem_table);
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->mi_table);
 
 	devm_kfree(ice_hw_to_dev(psr->hw), psr);
 }
drivers/net/ethernet/intel/ice/ice_parser.h +4 -0
index 3450830db473..d6df105bc4ec 100644
@@ -4,16 +4,20 @@
 #ifndef _ICE_PARSER_H_
 #define _ICE_PARSER_H_
 
+#include "ice_metainit.h"
 #include "ice_imem.h"
 
 #define ICE_SEC_DATA_OFFSET				4
 #define ICE_SID_RXPARSER_IMEM_ENTRY_SIZE		48
+#define ICE_SID_RXPARSER_METADATA_INIT_ENTRY_SIZE	24
 
 struct ice_parser {
 	struct ice_hw *hw; /* pointer to the hardware structure */
 
 	/* load data from section ICE_SID_RX_PARSER_IMEM */
 	struct ice_imem_item *imem_table;
+	/* load data from section ICE_SID_RXPARSER_METADATA_INIT */
+	struct ice_metainit_item *mi_table;
 };
 
 int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
drivers/net/ethernet/intel/ice/ice_parser_util.h +1 -0
index 6259d3d97b23..59c67f1a1951 100644
@@ -5,6 +5,7 @@
 #define _ICE_PARSER_UTIL_H_
 
 #include "ice_imem.h"
+#include "ice_metainit.h"
 
 struct ice_pkg_sect_hdr {
 	__le16 count;
Signature · 6 lines
2.25.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
#44 lore raw

PATCH v4 4/15 ice: init parse graph cam tables for parser

In reply to Junfeng Guo

Parse DDP section ICE_SID_RXPARSER_CAM or ICE_SID_RXPARSER_PG_SPILL into an array of struct ice_pg_cam_item.
Parse DDP section ICE_SID_RXPARSER_NOMATCH_CAM or ICE_SID_RXPARSER_NOMATCH_SPILL into an array of struct ice_pg_nm_cam_item.

---
 drivers/net/ethernet/intel/ice/ice_parser.c |  40 +++
 drivers/net/ethernet/intel/ice/ice_parser.h |  13 +
 drivers/net/ethernet/intel/ice/ice_pg_cam.c | 321 ++++++++++++++++++++
 drivers/net/ethernet/intel/ice/ice_pg_cam.h | 136 +++++++++
 4 files changed, 510 insertions(+)
 create mode 100644 drivers/net/ethernet/intel/ice/ice_pg_cam.c
 create mode 100644 drivers/net/ethernet/intel/ice/ice_pg_cam.h
drivers/net/ethernet/intel/ice/ice_parser.c +40 -0
index 9520594891d3..ffe58ceb91c7 100644
@@ -28,6 +28,18 @@ void *ice_parser_sect_item_get(u32 sect_type, void *section,
 	case ICE_SID_RXPARSER_METADATA_INIT:
 		size = ICE_SID_RXPARSER_METADATA_INIT_ENTRY_SIZE;
 		break;
+	case ICE_SID_RXPARSER_CAM:
+		size = ICE_SID_RXPARSER_CAM_ENTRY_SIZE;
+		break;
+	case ICE_SID_RXPARSER_PG_SPILL:
+		size = ICE_SID_RXPARSER_PG_SPILL_ENTRY_SIZE;
+		break;
+	case ICE_SID_RXPARSER_NOMATCH_CAM:
+		size = ICE_SID_RXPARSER_NOMATCH_CAM_ENTRY_SIZE;
+		break;
+	case ICE_SID_RXPARSER_NOMATCH_SPILL:
+		size = ICE_SID_RXPARSER_NOMATCH_SPILL_ENTRY_SIZE;
+		break;
 	default:
 		return NULL;
 	}
@@ -121,6 +133,30 @@ int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr)
 		goto err;
 	}
 
+	p->pg_cam_table = ice_pg_cam_table_get(hw);
+	if (!p->pg_cam_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
+	p->pg_sp_cam_table = ice_pg_sp_cam_table_get(hw);
+	if (!p->pg_sp_cam_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
+	p->pg_nm_cam_table = ice_pg_nm_cam_table_get(hw);
+	if (!p->pg_nm_cam_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
+	p->pg_nm_sp_cam_table = ice_pg_nm_sp_cam_table_get(hw);
+	if (!p->pg_nm_sp_cam_table) {
+		status = -EINVAL;
+		goto err;
+	}
+
 	*psr = p;
 	return 0;
 err:
@@ -136,6 +172,10 @@ void ice_parser_destroy(struct ice_parser *psr)
 {
 	devm_kfree(ice_hw_to_dev(psr->hw), psr->imem_table);
 	devm_kfree(ice_hw_to_dev(psr->hw), psr->mi_table);
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->pg_cam_table);
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->pg_sp_cam_table);
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->pg_nm_cam_table);
+	devm_kfree(ice_hw_to_dev(psr->hw), psr->pg_nm_sp_cam_table);
 
 	devm_kfree(ice_hw_to_dev(psr->hw), psr);
 }
drivers/net/ethernet/intel/ice/ice_parser.h +13 -0
index d6df105bc4ec..a632ed41e64b 100644
@@ -6,10 +6,15 @@
 
 #include "ice_metainit.h"
 #include "ice_imem.h"
+#include "ice_pg_cam.h"
 
 #define ICE_SEC_DATA_OFFSET				4
 #define ICE_SID_RXPARSER_IMEM_ENTRY_SIZE		48
 #define ICE_SID_RXPARSER_METADATA_INIT_ENTRY_SIZE	24
+#define ICE_SID_RXPARSER_CAM_ENTRY_SIZE			16
+#define ICE_SID_RXPARSER_PG_SPILL_ENTRY_SIZE		17
+#define ICE_SID_RXPARSER_NOMATCH_CAM_ENTRY_SIZE		12
+#define ICE_SID_RXPARSER_NOMATCH_SPILL_ENTRY_SIZE	13
 
 struct ice_parser {
 	struct ice_hw *hw; /* pointer to the hardware structure */
@@ -18,6 +23,14 @@ struct ice_parser {
 	struct ice_imem_item *imem_table;
 	/* load data from section ICE_SID_RXPARSER_METADATA_INIT */
 	struct ice_metainit_item *mi_table;
+	/* load data from section ICE_SID_RXPARSER_CAM */
+	struct ice_pg_cam_item *pg_cam_table;
+	/* load data from section ICE_SID_RXPARSER_PG_SPILL */
+	struct ice_pg_cam_item *pg_sp_cam_table;
+	/* load data from section ICE_SID_RXPARSER_NOMATCH_CAM */
+	struct ice_pg_nm_cam_item *pg_nm_cam_table;
+	/* load data from section ICE_SID_RXPARSER_NOMATCH_SPILL */
+	struct ice_pg_nm_cam_item *pg_nm_sp_cam_table;
 };
 
 int ice_parser_create(struct ice_hw *hw, struct ice_parser **psr);
drivers/net/ethernet/intel/ice/ice_pg_cam.c new file +321 -0

321 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_pg_cam.h new file +136 -0

136 lines not on this page · raw message

Signature · 6 lines
2.25.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan