From: Junfeng Guo <junfeng.guo@intel.com>
To: intel-wired-lan@lists.osuosl.org
Cc: qi.z.zhang@intel.com
Subject: [Intel-wired-lan] [PATCH iwl-next 14/15] ice: add tunnel port support for parser
Date: Mon, 5 Jun 2023 10:29:19 +0800 [thread overview]
Message-ID: <20230605022920.2361266-15-junfeng.guo@intel.com> (raw)
In-Reply-To: <20230605022920.2361266-1-junfeng.guo@intel.com>
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
Signed-off-by: Junfeng Guo <junfeng.guo@intel.com>
---
drivers/net/ethernet/intel/ice/ice_parser.c | 76 +++++++++++++++++++++
drivers/net/ethernet/intel/ice/ice_parser.h | 6 ++
2 files changed, 82 insertions(+)
diff --git a/drivers/net/ethernet/intel/ice/ice_parser.c b/drivers/net/ethernet/intel/ice/ice_parser.c
index a41d73063681..b70c18044331 100644
--- a/drivers/net/ethernet/intel/ice/ice_parser.c
+++ b/drivers/net/ethernet/intel/ice/ice_parser.c
@@ -368,3 +368,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);
+}
diff --git a/drivers/net/ethernet/intel/ice/ice_parser.h b/drivers/net/ethernet/intel/ice/ice_parser.h
index 02ea2ef5fc91..432d47031298 100644
--- a/drivers/net/ethernet/intel/ice/ice_parser.h
+++ b/drivers/net/ethernet/intel/ice/ice_parser.h
@@ -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 */
--
2.25.1
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
next prev parent reply other threads:[~2023-06-05 2:30 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-05 2:29 [Intel-wired-lan] [PATCH iwl-next 00/15] Introduce the Parser Library Junfeng Guo
2023-06-05 2:29 ` [Intel-wired-lan] [PATCH iwl-next 01/15] ice: add parser create and destroy skeleton Junfeng Guo
2023-06-05 2:29 ` [Intel-wired-lan] [PATCH iwl-next 02/15] ice: init imem table for parser Junfeng Guo
2023-06-05 2:29 ` [Intel-wired-lan] [PATCH iwl-next 03/15] ice: init metainit " Junfeng Guo
2023-06-05 2:29 ` [Intel-wired-lan] [PATCH iwl-next 04/15] ice: init parse graph cam " Junfeng Guo
2023-06-05 2:29 ` [Intel-wired-lan] [PATCH iwl-next 05/15] ice: init boost tcam " Junfeng Guo
2023-06-05 2:29 ` [Intel-wired-lan] [PATCH iwl-next 06/15] ice: init ptype marker " Junfeng Guo
2023-06-05 2:29 ` [Intel-wired-lan] [PATCH iwl-next 07/15] ice: init marker and protocol group " Junfeng Guo
2023-06-05 2:29 ` [Intel-wired-lan] [PATCH iwl-next 08/15] ice: init flag redirect " Junfeng Guo
2023-06-05 2:29 ` [Intel-wired-lan] [PATCH iwl-next 09/15] ice: init XLT key builder " Junfeng Guo
2023-06-05 2:29 ` [Intel-wired-lan] [PATCH iwl-next 10/15] ice: add parser runtime skeleton Junfeng Guo
2023-06-05 2:29 ` [Intel-wired-lan] [PATCH iwl-next 11/15] ice: add internal help functions Junfeng Guo
2023-06-05 2:29 ` [Intel-wired-lan] [PATCH iwl-next 12/15] ice: add parser execution main loop Junfeng Guo
2023-06-05 4:47 ` kernel test robot
2023-06-05 2:29 ` [Intel-wired-lan] [PATCH iwl-next 13/15] ice: support double vlan mode configure for parser Junfeng Guo
2023-06-05 2:29 ` Junfeng Guo [this message]
2023-06-05 2:29 ` [Intel-wired-lan] [PATCH iwl-next 15/15] ice: add API for parser profile initialization Junfeng Guo
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=20230605022920.2361266-15-junfeng.guo@intel.com \
--to=junfeng.guo@intel.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=qi.z.zhang@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