From patchwork Thu Aug 24 07:54:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Guo, Junfeng" X-Patchwork-Id: 13363684 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1FB89C8E7 for ; Thu, 24 Aug 2023 07:56:29 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8168A1727 for ; Thu, 24 Aug 2023 00:56:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692863785; x=1724399785; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9VVAzoph9bkRZBHLWwGeyUb9l+/n3HuJxnr1k8LVCiQ=; b=fE3t4Q5f3rNLNMVgq79Uu3U7wII9IoHrSNex4bd1va41Eh/vhOuGYMbg tMJpPBgsWIpF+Xn9IZDLzFZAFup1GdZo9JdMcspz/6NuaC4D2JizF73Nc YwkzQZua2Rp1+zpYBgJ+RyQu8Km8cY+NZbkL4jmTmOs0n/gfc3ZKZzAkS RZR0Db1Ow18t6+5Z9iMc72ANQjfN8w+rtKXwq1oiaUrQycddizcc258y8 Mz9yrL5q6nZMxi78+2ICgiUPR3+vjWrh2X1s5IMAhqprlK2m9fRDED5Sf EqWpsCSbCQrJW8sAU6NppxUjPJIMUTalRMznUgG8b/6bHLnlzzSUj+09W w==; X-IronPort-AV: E=McAfee;i="6600,9927,10811"; a="354705553" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="354705553" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Aug 2023 00:56:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10811"; a="772022668" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="772022668" Received: from dpdk-jf-ntb-v2.sh.intel.com ([10.67.119.19]) by orsmga001.jf.intel.com with ESMTP; 24 Aug 2023 00:56:14 -0700 From: Junfeng Guo To: intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org, anthony.l.nguyen@intel.com, jesse.brandeburg@intel.com, qi.z.zhang@intel.com, ivecera@redhat.com, sridhar.samudrala@intel.com, horms@kernel.org, kuba@kernel.org, edumazet@google.com, davem@davemloft.net, pabeni@redhat.com, Junfeng Guo Subject: [PATCH iwl-next v8 14/15] ice: add tunnel port support for parser Date: Thu, 24 Aug 2023 15:54:59 +0800 Message-Id: <20230824075500.1735790-15-junfeng.guo@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230824075500.1735790-1-junfeng.guo@intel.com> References: <20230823093158.782802-1-junfeng.guo@intel.com> <20230824075500.1735790-1-junfeng.guo@intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org 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 --- drivers/net/ethernet/intel/ice/ice_parser.c | 85 +++++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_parser.h | 10 +++ 2 files changed, 95 insertions(+) diff --git a/drivers/net/ethernet/intel/ice/ice_parser.c b/drivers/net/ethernet/intel/ice/ice_parser.c index 5ce98cd303e1..85a2833ffc58 100644 --- a/drivers/net/ethernet/intel/ice/ice_parser.c +++ b/drivers/net/ethernet/intel/ice/ice_parser.c @@ -361,3 +361,88 @@ void ice_parser_dvm_set(struct ice_parser *psr, bool on) _ice_bst_vm_set(psr, "BOOST_MAC_VLAN_DVM", on); _ice_bst_vm_set(psr, "BOOST_MAC_VLAN_SVM", !on); } + +static int _ice_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[ICE_BT_TUN_PORT_OFF_H] == ICE_BT_INV_KEY && + item->key_inv[ICE_BT_TUN_PORT_OFF_H] == ICE_BT_INV_KEY) { + item->key_inv[ICE_BT_TUN_PORT_OFF_L] = + buf[ICE_UDP_PORT_OFF_L]; + item->key_inv[ICE_BT_TUN_PORT_OFF_H] = + buf[ICE_UDP_PORT_OFF_H]; + + item->key[ICE_BT_TUN_PORT_OFF_L] = + (u8)(ICE_BT_VLD_KEY - buf[ICE_UDP_PORT_OFF_L]); + item->key[ICE_BT_TUN_PORT_OFF_H] = + (u8)(ICE_BT_VLD_KEY - buf[ICE_UDP_PORT_OFF_H]); + + return 0; + /* found a matched slot to delete */ + } else if (!on && + (item->key_inv[ICE_BT_TUN_PORT_OFF_L] == + buf[ICE_UDP_PORT_OFF_L] || + item->key_inv[ICE_BT_TUN_PORT_OFF_H] == + buf[ICE_UDP_PORT_OFF_H])) { + item->key_inv[ICE_BT_TUN_PORT_OFF_L] = ICE_BT_VLD_KEY; + item->key_inv[ICE_BT_TUN_PORT_OFF_H] = ICE_BT_INV_KEY; + + item->key[ICE_BT_TUN_PORT_OFF_L] = ICE_BT_VLD_KEY; + item->key[ICE_BT_TUN_PORT_OFF_H] = ICE_BT_INV_KEY; + + 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 _ice_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 _ice_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 _ice_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 c9eee988ebb2..3cfcec4dc477 100644 --- a/drivers/net/ethernet/intel/ice/ice_parser.h +++ b/drivers/net/ethernet/intel/ice/ice_parser.h @@ -33,6 +33,10 @@ #define ICE_SID_LBL_ENTRY_SIZE 66 #define ICE_PARSER_PROTO_OFF_PAIR_SIZE 16 +#define ICE_BT_TUN_PORT_OFF_H 16 +#define ICE_BT_TUN_PORT_OFF_L 15 +#define ICE_UDP_PORT_OFF_H 1 +#define ICE_UDP_PORT_OFF_L 0 #define ICE_BT_VM_OFF 0 struct ice_parser { @@ -76,6 +80,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 */