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 C0AE8A0C46; Fri, 17 Sep 2021 16:41:57 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 49178411AB; Fri, 17 Sep 2021 16:40:48 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id C18474117B for ; Fri, 17 Sep 2021 16:40:45 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10110"; a="202967907" X-IronPort-AV: E=Sophos;i="5.85,301,1624345200"; d="scan'208";a="202967907" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Sep 2021 07:40:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,301,1624345200"; d="scan'208";a="546445529" Received: from dpdk51.sh.intel.com ([10.67.111.142]) by FMSMGA003.fm.intel.com with ESMTP; 17 Sep 2021 07:40:43 -0700 From: Qi Zhang To: qiming.yang@intel.com Cc: junfeng.guo@intel.com, dev@dpdk.org, Qi Zhang Date: Fri, 17 Sep 2021 22:43:20 +0800 Message-Id: <20210917144322.3141886-19-qi.z.zhang@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210917144322.3141886-1-qi.z.zhang@intel.com> References: <20210917144322.3141886-1-qi.z.zhang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 18/20] net/ice/base: support double VLAN mode configure 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" Add API ice_parser_dvm_set to support turn on/off parser's double vlan mode. Signed-off-by: Qi Zhang --- drivers/net/ice/base/ice_bst_tcam.c | 28 ++++++++++++++++++++++++++++ drivers/net/ice/base/ice_bst_tcam.h | 4 ++++ drivers/net/ice/base/ice_parser.c | 27 +++++++++++++++++++++++++++ drivers/net/ice/base/ice_parser.h | 1 + 4 files changed, 60 insertions(+) diff --git a/drivers/net/ice/base/ice_bst_tcam.c b/drivers/net/ice/base/ice_bst_tcam.c index 76b3a5c551..306f62db2a 100644 --- a/drivers/net/ice/base/ice_bst_tcam.c +++ b/drivers/net/ice/base/ice_bst_tcam.c @@ -261,3 +261,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; +} diff --git a/drivers/net/ice/base/ice_bst_tcam.h b/drivers/net/ice/base/ice_bst_tcam.h index 3cba0bbf55..e4c96c439d 100644 --- a/drivers/net/ice/base/ice_bst_tcam.h +++ b/drivers/net/ice/base/ice_bst_tcam.h @@ -28,4 +28,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_ */ diff --git a/drivers/net/ice/base/ice_parser.c b/drivers/net/ice/base/ice_parser.c index a0c5c9989d..052bc67a4c 100644 --- a/drivers/net/ice/base/ice_parser.c +++ b/drivers/net/ice/base/ice_parser.c @@ -340,3 +340,30 @@ void ice_parser_result_dump(struct ice_hw *hw, struct ice_parser_result *rslt) ice_info(hw, "flags_fd = 0x%04x\n", rslt->flags_fd); ice_info(hw, "flags_rss = 0x%04x\n", rslt->flags_rss); } + +static void _bst_vm_set(struct ice_parser *psr, const char *prefix, bool on) +{ + 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; + 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 + */ +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); +} diff --git a/drivers/net/ice/base/ice_parser.h b/drivers/net/ice/base/ice_parser.h index 715158d6eb..e310466678 100644 --- a/drivers/net/ice/base/ice_parser.h +++ b/drivers/net/ice/base/ice_parser.h @@ -57,6 +57,7 @@ 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); struct ice_parser_proto_off { u8 proto_id; /* hardware protocol ID */ -- 2.26.2