From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 94B65A0C4C; Tue, 21 Sep 2021 15:19:20 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CBE52411A3; Tue, 21 Sep 2021 15:17:38 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id 41FEE41181 for ; Tue, 21 Sep 2021 15:17:35 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10113"; a="202847524" X-IronPort-AV: E=Sophos;i="5.85,311,1624345200"; d="scan'208";a="202847524" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2021 06:17:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,311,1624345200"; d="scan'208";a="484173973" Received: from dpdk51.sh.intel.com ([10.67.111.142]) by orsmga008.jf.intel.com with ESMTP; 21 Sep 2021 06:17:33 -0700 From: Qi Zhang To: qiming.yang@intel.com Cc: junfeng.guo@intel.com, dev@dpdk.org, Qi Zhang Date: Tue, 21 Sep 2021 21:20:08 +0800 Message-Id: <20210921132009.3461020-20-qi.z.zhang@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210921132009.3461020-1-qi.z.zhang@intel.com> References: <20210921132009.3461020-1-qi.z.zhang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 19/20] net/ice/base: add tunnel port support for parser X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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: Qi Zhang Acked-by: Junfeng Guo --- drivers/net/ice/base/ice_parser.c | 75 +++++++++++++++++++++++++++++++ drivers/net/ice/base/ice_parser.h | 6 +++ 2 files changed, 81 insertions(+) diff --git a/drivers/net/ice/base/ice_parser.c b/drivers/net/ice/base/ice_parser.c index 395ad220a0..a657e826a3 100644 --- a/drivers/net/ice/base/ice_parser.c +++ b/drivers/net/ice/base/ice_parser.c @@ -367,3 +367,78 @@ 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 enum ice_status +_tunnel_port_set(struct ice_parser *psr, const char *prefix, u16 udp_port, + bool on) +{ + u8 *buf = (u8 *)&udp_port; + struct ice_bst_tcam_item *item; + u16 i = 0; + + while (true) { + 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 ICE_SUCCESS; + /* 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 ICE_SUCCESS; + } + i++; + } + + return ICE_ERR_PARAM; +} + +/** + * 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 + */ +enum ice_status 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 + */ +enum ice_status 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 + */ +enum ice_status 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/ice/base/ice_parser.h b/drivers/net/ice/base/ice_parser.h index e310466678..105d908ebe 100644 --- a/drivers/net/ice/base/ice_parser.h +++ b/drivers/net/ice/base/ice_parser.h @@ -58,6 +58,12 @@ struct ice_parser { enum ice_status 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); +enum ice_status ice_parser_vxlan_tunnel_set(struct ice_parser *psr, + u16 udp_port, bool on); +enum ice_status ice_parser_geneve_tunnel_set(struct ice_parser *psr, + u16 udp_port, bool on); +enum ice_status 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.26.2