From: Junfeng Guo <junfeng.guo@intel.com>
To: intel-wired-lan@lists.osuosl.org
Cc: netdev@vger.kernel.org, anthony.l.nguyen@intel.com,
jesse.brandeburg@intel.com, qi.z.zhang@intel.com,
ivecera@redhat.com, sridhar.samudrala@intel.com,
Junfeng Guo <junfeng.guo@intel.com>
Subject: [PATCH iwl-next v5 15/15] ice: add API for parser profile initialization
Date: Mon, 21 Aug 2023 10:38:33 +0800 [thread overview]
Message-ID: <20230821023833.2700902-16-junfeng.guo@intel.com> (raw)
In-Reply-To: <20230821023833.2700902-1-junfeng.guo@intel.com>
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.
Signed-off-by: Junfeng Guo <junfeng.guo@intel.com>
---
drivers/net/ethernet/intel/ice/ice_parser.c | 114 ++++++++++++++++++++
drivers/net/ethernet/intel/ice/ice_parser.h | 27 +++++
2 files changed, 141 insertions(+)
diff --git a/drivers/net/ethernet/intel/ice/ice_parser.c b/drivers/net/ethernet/intel/ice/ice_parser.c
index 85a2833ffc58..7a4cf7e9da57 100644
--- a/drivers/net/ethernet/intel/ice/ice_parser.c
+++ b/drivers/net/ethernet/intel/ice/ice_parser.c
@@ -446,3 +446,117 @@ int ice_parser_ecpri_tunnel_set(struct ice_parser *psr,
{
return _ice_tunnel_port_set(psr, "TNL_UDP_ECPRI", udp_port, on);
}
+
+static bool _ice_nearest_proto_id(struct ice_parser_result *rslt, u16 offset,
+ u8 *proto_id, u16 *proto_off)
+{
+ u16 dist = U16_MAX;
+ u8 proto = 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) {
+ proto = rslt->po[i].proto_id;
+ dist = offset - rslt->po[i].offset;
+ }
+ }
+
+ if (dist % 2)
+ return false;
+
+ *proto_id = proto;
+ *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 = U8_MAX;
+ 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 (!_ice_nearest_proto_id(rslt, off, &proto_id, &proto_off))
+ continue;
+ if (prof->fv_num >= ICE_PARSER_FV_MAX)
+ 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 = %2d; 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);
+}
diff --git a/drivers/net/ethernet/intel/ice/ice_parser.h b/drivers/net/ethernet/intel/ice/ice_parser.h
index 3cfcec4dc477..503c610b5c92 100644
--- a/drivers/net/ethernet/intel/ice/ice_parser.h
+++ b/drivers/net/ethernet/intel/ice/ice_parser.h
@@ -33,6 +33,8 @@
#define ICE_SID_LBL_ENTRY_SIZE 66
#define ICE_PARSER_PROTO_OFF_PAIR_SIZE 16
+#define ICE_PARSER_FV_SIZE 48
+#define ICE_PARSER_FV_MAX 24
#define ICE_BT_TUN_PORT_OFF_H 16
#define ICE_BT_TUN_PORT_OFF_L 15
#define ICE_UDP_PORT_OFF_H 1
@@ -110,4 +112,29 @@ 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 {
+ /* array of field vectors */
+ struct ice_parser_fv fv[ICE_PARSER_FV_SIZE];
+ int fv_num; /* # of field vectors must <= 48 */
+ u16 flags; /* 16 bits key builder flags */
+ u16 flags_msk; /* key builder flag mask */
+
+ DECLARE_BITMAP(ptypes, ICE_FLOW_PTYPE_MAX); /* PTYPE bitmap */
+};
+
+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_ */
--
2.25.1
next prev parent reply other threads:[~2023-08-21 2:39 UTC|newest]
Thread overview: 76+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20230605054641.2865142-1-junfeng.guo@intel.com>
2023-08-21 2:38 ` [PATCH iwl-next v5 00/15] Introduce the Parser Library Junfeng Guo
2023-08-21 2:38 ` [PATCH iwl-next v5 01/15] ice: add parser create and destroy skeleton Junfeng Guo
2023-08-21 7:20 ` Simon Horman
2023-08-21 7:30 ` Simon Horman
2023-08-21 7:34 ` Guo, Junfeng
2023-08-21 14:47 ` Simon Horman
2023-08-22 2:47 ` Guo, Junfeng
2023-08-21 2:38 ` [PATCH iwl-next v5 02/15] ice: init imem table for parser Junfeng Guo
2023-08-21 2:38 ` [PATCH iwl-next v5 03/15] ice: init metainit " Junfeng Guo
2023-08-21 2:38 ` [PATCH iwl-next v5 04/15] ice: init parse graph cam tables " Junfeng Guo
2023-08-21 2:38 ` [PATCH iwl-next v5 05/15] ice: init boost tcam and label " Junfeng Guo
2023-08-21 2:38 ` [PATCH iwl-next v5 06/15] ice: init ptype marker tcam table " Junfeng Guo
2023-08-21 2:38 ` [PATCH iwl-next v5 07/15] ice: init marker and protocol group tables " Junfeng Guo
2023-08-21 2:38 ` [PATCH iwl-next v5 08/15] ice: init flag redirect table " Junfeng Guo
2023-08-21 2:38 ` [PATCH iwl-next v5 09/15] ice: init XLT key builder " Junfeng Guo
2023-08-21 2:38 ` [PATCH iwl-next v5 10/15] ice: add parser runtime skeleton Junfeng Guo
2023-08-21 2:38 ` [PATCH iwl-next v5 11/15] ice: add internal help functions Junfeng Guo
2023-08-21 2:38 ` [PATCH iwl-next v5 12/15] ice: add parser execution main loop Junfeng Guo
2023-08-21 2:38 ` [PATCH iwl-next v5 13/15] ice: support double vlan mode configure for parser Junfeng Guo
2023-08-21 2:38 ` [PATCH iwl-next v5 14/15] ice: add tunnel port support " Junfeng Guo
2023-08-21 2:38 ` Junfeng Guo [this message]
2023-08-21 6:46 ` [EXT] [PATCH iwl-next v5 00/15] Introduce the Parser Library Subbaraya Sundeep Bhatta
2023-08-21 7:15 ` Guo, Junfeng
2023-08-21 8:14 ` [PATCH iwl-next v6 " Junfeng Guo
2023-08-21 8:14 ` [PATCH iwl-next v6 01/15] ice: add parser create and destroy skeleton Junfeng Guo
2023-08-21 8:14 ` [PATCH iwl-next v6 02/15] ice: init imem table for parser Junfeng Guo
2023-08-21 8:14 ` [PATCH iwl-next v6 03/15] ice: init metainit " Junfeng Guo
2023-08-21 8:14 ` [PATCH iwl-next v6 04/15] ice: init parse graph cam tables " Junfeng Guo
2023-08-21 8:14 ` [PATCH iwl-next v6 05/15] ice: init boost tcam and label " Junfeng Guo
2023-08-21 8:14 ` [PATCH iwl-next v6 06/15] ice: init ptype marker tcam table " Junfeng Guo
2023-08-21 8:14 ` [PATCH iwl-next v6 07/15] ice: init marker and protocol group tables " Junfeng Guo
2023-08-21 8:14 ` [PATCH iwl-next v6 08/15] ice: init flag redirect table " Junfeng Guo
2023-08-21 8:14 ` [PATCH iwl-next v6 09/15] ice: init XLT key builder " Junfeng Guo
2023-08-21 8:14 ` [PATCH iwl-next v6 10/15] ice: add parser runtime skeleton Junfeng Guo
2023-08-21 8:14 ` [PATCH iwl-next v6 11/15] ice: add internal help functions Junfeng Guo
2023-08-21 8:14 ` [PATCH iwl-next v6 12/15] ice: add parser execution main loop Junfeng Guo
2023-08-21 8:14 ` [PATCH iwl-next v6 13/15] ice: support double vlan mode configure for parser Junfeng Guo
2023-08-21 8:14 ` [PATCH iwl-next v6 14/15] ice: add tunnel port support " Junfeng Guo
2023-08-21 8:14 ` [PATCH iwl-next v6 15/15] ice: add API for parser profile initialization Junfeng Guo
2023-08-23 9:31 ` [PATCH iwl-next v7 00/15] Introduce the Parser Library Junfeng Guo
2023-08-23 9:31 ` [PATCH iwl-next v7 01/15] ice: add parser create and destroy skeleton Junfeng Guo
2023-08-23 9:31 ` [PATCH iwl-next v7 02/15] ice: init imem table for parser Junfeng Guo
2023-08-23 9:31 ` [PATCH iwl-next v7 03/15] ice: init metainit " Junfeng Guo
2023-08-23 9:31 ` [PATCH iwl-next v7 04/15] ice: init parse graph cam tables " Junfeng Guo
2023-08-23 9:31 ` [PATCH iwl-next v7 05/15] ice: init boost tcam and label " Junfeng Guo
2023-08-23 9:31 ` [PATCH iwl-next v7 06/15] ice: init ptype marker tcam table " Junfeng Guo
2023-08-23 9:31 ` [PATCH iwl-next v7 07/15] ice: init marker and protocol group tables " Junfeng Guo
2023-08-23 9:31 ` [PATCH iwl-next v7 08/15] ice: init flag redirect table " Junfeng Guo
2023-08-23 9:31 ` [PATCH iwl-next v7 09/15] ice: init XLT key builder " Junfeng Guo
2023-08-23 9:31 ` [PATCH iwl-next v7 10/15] ice: add parser runtime skeleton Junfeng Guo
2023-08-23 9:31 ` [PATCH iwl-next v7 11/15] ice: add internal help functions Junfeng Guo
2023-08-23 9:31 ` [PATCH iwl-next v7 12/15] ice: add parser execution main loop Junfeng Guo
2023-08-23 9:31 ` [PATCH iwl-next v7 13/15] ice: support double vlan mode configure for parser Junfeng Guo
2023-08-23 9:31 ` [PATCH iwl-next v7 14/15] ice: add tunnel port support " Junfeng Guo
2023-08-23 9:31 ` [PATCH iwl-next v7 15/15] ice: add API for parser profile initialization Junfeng Guo
2023-08-24 7:54 ` [PATCH iwl-next v8 00/15] Introduce the Parser Library Junfeng Guo
2023-08-24 7:54 ` [PATCH iwl-next v8 01/15] ice: add parser create and destroy skeleton Junfeng Guo
2023-08-24 7:54 ` [PATCH iwl-next v8 02/15] ice: init imem table for parser Junfeng Guo
2023-08-28 9:55 ` Ivan Vecera
2023-08-24 7:54 ` [PATCH iwl-next v8 03/15] ice: init metainit " Junfeng Guo
2023-08-24 7:54 ` [PATCH iwl-next v8 04/15] ice: init parse graph cam tables " Junfeng Guo
2023-08-24 7:54 ` [PATCH iwl-next v8 05/15] ice: init boost tcam and label " Junfeng Guo
2023-08-24 7:54 ` [PATCH iwl-next v8 06/15] ice: init ptype marker tcam table " Junfeng Guo
2023-08-24 7:54 ` [PATCH iwl-next v8 07/15] ice: init marker and protocol group tables " Junfeng Guo
2023-08-24 7:54 ` [PATCH iwl-next v8 08/15] ice: init flag redirect table " Junfeng Guo
2023-08-24 7:54 ` [PATCH iwl-next v8 09/15] ice: init XLT key builder " Junfeng Guo
2023-08-24 7:54 ` [PATCH iwl-next v8 10/15] ice: add parser runtime skeleton Junfeng Guo
2023-08-24 7:54 ` [PATCH iwl-next v8 11/15] ice: add internal help functions Junfeng Guo
2023-08-24 7:54 ` [PATCH iwl-next v8 12/15] ice: add parser execution main loop Junfeng Guo
2023-08-24 15:39 ` Simon Horman
2023-08-24 7:54 ` [PATCH iwl-next v8 13/15] ice: support double vlan mode configure for parser Junfeng Guo
2023-08-24 7:54 ` [PATCH iwl-next v8 14/15] ice: add tunnel port support " Junfeng Guo
2023-08-24 7:55 ` [PATCH iwl-next v8 15/15] ice: add API for parser profile initialization Junfeng Guo
2023-08-24 15:20 ` [PATCH iwl-next v8 00/15] Introduce the Parser Library Jakub Kicinski
2023-08-25 10:52 ` Alexander Lobakin
2023-08-26 0:23 ` Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230821023833.2700902-16-junfeng.guo@intel.com \
--to=junfeng.guo@intel.com \
--cc=anthony.l.nguyen@intel.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=ivecera@redhat.com \
--cc=jesse.brandeburg@intel.com \
--cc=netdev@vger.kernel.org \
--cc=qi.z.zhang@intel.com \
--cc=sridhar.samudrala@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).