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 EF042A0C4C; Tue, 21 Sep 2021 15:18:12 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0626E41163; Tue, 21 Sep 2021 15:17:23 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id 1CBF741150 for ; Tue, 21 Sep 2021 15:17:17 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10113"; a="202847455" X-IronPort-AV: E=Sophos;i="5.85,311,1624345200"; d="scan'208";a="202847455" 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:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,311,1624345200"; d="scan'208";a="484173850" Received: from dpdk51.sh.intel.com ([10.67.111.142]) by orsmga008.jf.intel.com with ESMTP; 21 Sep 2021 06:17:16 -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:19:57 +0800 Message-Id: <20210921132009.3461020-9-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 08/20] net/ice/base: init protocol group table 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" Parse DDP section ICE_SID_RXPARSER_PROTO_GRP into an array of ice_proto_grp_item. Signed-off-by: Qi Zhang Acked-by: Junfeng Guo --- drivers/net/ice/base/ice_parser.c | 11 +++ drivers/net/ice/base/ice_parser.h | 3 + drivers/net/ice/base/ice_proto_grp.c | 108 +++++++++++++++++++++++++++ drivers/net/ice/base/ice_proto_grp.h | 23 ++++++ drivers/net/ice/base/meson.build | 1 + 5 files changed, 146 insertions(+) create mode 100644 drivers/net/ice/base/ice_proto_grp.c create mode 100644 drivers/net/ice/base/ice_proto_grp.h diff --git a/drivers/net/ice/base/ice_parser.c b/drivers/net/ice/base/ice_parser.c index 142da462ee..0ed7c5fe32 100644 --- a/drivers/net/ice/base/ice_parser.c +++ b/drivers/net/ice/base/ice_parser.c @@ -15,6 +15,7 @@ #define ICE_SID_RXPARSER_BOOST_TCAM_ENTRY_SIZE 88 #define ICE_SID_RXPARSER_MARKER_TYPE_ENTRY_SIZE 24 #define ICE_SID_RXPARSER_MARKER_GRP_ENTRY_SIZE 8 +#define ICE_SID_RXPARSER_PROTO_GRP_ENTRY_SIZE 24 #define ICE_SEC_LBL_DATA_OFFSET 2 #define ICE_SID_LBL_ENTRY_SIZE 66 @@ -80,6 +81,9 @@ void *ice_parser_sect_item_get(u32 sect_type, void *section, case ICE_SID_RXPARSER_MARKER_GRP: size = ICE_SID_RXPARSER_MARKER_GRP_ENTRY_SIZE; break; + case ICE_SID_RXPARSER_PROTO_GRP: + size = ICE_SID_RXPARSER_PROTO_GRP_ENTRY_SIZE; + break; default: return NULL; } @@ -225,6 +229,12 @@ enum ice_status ice_parser_create(struct ice_hw *hw, struct ice_parser **psr) goto err; } + p->proto_grp_table = ice_proto_grp_table_get(hw); + if (!p->proto_grp_table) { + status = ICE_ERR_PARAM; + goto err; + } + *psr = p; return ICE_SUCCESS; err: @@ -248,6 +258,7 @@ void ice_parser_destroy(struct ice_parser *psr) ice_free(psr->hw, psr->bst_lbl_table); ice_free(psr->hw, psr->ptype_mk_tcam_table); ice_free(psr->hw, psr->mk_grp_table); + ice_free(psr->hw, psr->proto_grp_table); ice_free(psr->hw, psr); } diff --git a/drivers/net/ice/base/ice_parser.h b/drivers/net/ice/base/ice_parser.h index b390eecb2b..ac4139abd7 100644 --- a/drivers/net/ice/base/ice_parser.h +++ b/drivers/net/ice/base/ice_parser.h @@ -11,6 +11,7 @@ #include "ice_bst_tcam.h" #include "ice_ptype_mk.h" #include "ice_mk_grp.h" +#include "ice_proto_grp.h" struct ice_parser { struct ice_hw *hw; /* pointer to the hardware structure */ @@ -35,6 +36,8 @@ struct ice_parser { struct ice_ptype_mk_tcam_item *ptype_mk_tcam_table; /* load data from section ICE_SID_RXPARSER_MARKER_GRP */ struct ice_mk_grp_item *mk_grp_table; + /* load data from section ICE_SID_RXPARSER_PROTO_GRP */ + struct ice_proto_grp_item *proto_grp_table; }; enum ice_status ice_parser_create(struct ice_hw *hw, struct ice_parser **psr); diff --git a/drivers/net/ice/base/ice_proto_grp.c b/drivers/net/ice/base/ice_proto_grp.c new file mode 100644 index 0000000000..69d5d9a18a --- /dev/null +++ b/drivers/net/ice/base/ice_proto_grp.c @@ -0,0 +1,108 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2001-2021 Intel Corporation + */ + +#include "ice_common.h" +#include "ice_parser_util.h" + +#define ICE_PROTO_GRP_TABLE_SIZE 192 + +static void _proto_off_dump(struct ice_hw *hw, struct ice_proto_off *po, + int idx) +{ + ice_info(hw, "proto %d\n", idx); + ice_info(hw, "\tpolarity = %d\n", po->polarity); + ice_info(hw, "\tproto_id = %d\n", po->proto_id); + ice_info(hw, "\toffset = %d\n", po->offset); +} + +/** + * ice_proto_grp_dump - dump a proto group item info + * @ice_hw: pointer to the hardware structure + * @item: proto group item to dump + */ +void ice_proto_grp_dump(struct ice_hw *hw, struct ice_proto_grp_item *item) +{ + int i; + + ice_info(hw, "index = %d\n", item->idx); + + for (i = 0; i < ICE_PROTO_COUNT_PER_GRP; i++) + _proto_off_dump(hw, &item->po[i], i); +} + +/** The function parses a 22 bits Protocol entry with below format: + * BIT 0: Polarity of Protocol Offset (po->polarity) + * BIT 1-8: Protocol ID (po->proto_id) + * BIT 9-11: reserved + * BIT 12-21: Protocol Offset (po->offset) + */ +static void _proto_off_parse(struct ice_proto_off *po, u32 data) +{ + po->polarity = (data & 0x1) != 0; + po->proto_id = (u8)((data >> 1) & 0xff); + po->offset = (u16)((data >> 12) & 0x3ff); +} + +/** The function parses a 192 bits Protocol Group Table entry with below + * format: + * BIT 0-21: Protocol 0 (grp->po[0]) + * BIT 22-43: Protocol 1 (grp->po[1]) + * BIT 44-65: Protocol 2 (grp->po[2]) + * BIT 66-87: Protocol 3 (grp->po[3]) + * BIT 88-109: Protocol 4 (grp->po[4]) + * BIT 110-131:Protocol 5 (grp->po[5]) + * BIT 132-153:Protocol 6 (grp->po[6]) + * BIT 154-175:Protocol 7 (grp->po[7]) + * BIT 176-191:reserved + */ +static void _proto_grp_parse_item(struct ice_hw *hw, u16 idx, void *item, + void *data, int size) +{ + struct ice_proto_grp_item *grp = (struct ice_proto_grp_item *)item; + u8 *buf = (u8 *)data; + u32 d32; + + grp->idx = idx; + + d32 = *(u32 *)buf; + _proto_off_parse(&grp->po[0], d32); + + d32 = (*(u32 *)&buf[2] >> 6); + _proto_off_parse(&grp->po[1], d32); + + d32 = (*(u32 *)&buf[5] >> 4); + _proto_off_parse(&grp->po[2], d32); + + d32 = (*(u32 *)&buf[8] >> 2); + _proto_off_parse(&grp->po[3], d32); + + d32 = *(u32 *)&buf[11]; + _proto_off_parse(&grp->po[4], d32); + + d32 = (*(u32 *)&buf[13] >> 6); + _proto_off_parse(&grp->po[5], d32); + + d32 = (*(u32 *)&buf[16] >> 4); + _proto_off_parse(&grp->po[6], d32); + + d32 = (*(u32 *)&buf[19] >> 2); + _proto_off_parse(&grp->po[7], d32); + + if (hw->debug_mask & ICE_DBG_PARSER) + ice_proto_grp_dump(hw, grp); +} + +/** + * ice_proto_grp_table_get - create a proto group table + * @ice_hw: pointer to the hardware structure + */ +struct ice_proto_grp_item *ice_proto_grp_table_get(struct ice_hw *hw) +{ + return (struct ice_proto_grp_item *) + ice_parser_create_table(hw, ICE_SID_RXPARSER_PROTO_GRP, + sizeof(struct ice_proto_grp_item), + ICE_PROTO_GRP_TABLE_SIZE, + ice_parser_sect_item_get, + _proto_grp_parse_item, false); +} diff --git a/drivers/net/ice/base/ice_proto_grp.h b/drivers/net/ice/base/ice_proto_grp.h new file mode 100644 index 0000000000..88d84505dd --- /dev/null +++ b/drivers/net/ice/base/ice_proto_grp.h @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2001-2021 Intel Corporation + */ + +#ifndef _ICE_PROTO_GRP_H_ +#define _ICE_PROTO_GRP_H_ + +#define ICE_PROTO_COUNT_PER_GRP 8 + +struct ice_proto_off { + bool polarity; /* true: positive, false: nagtive */ + u8 proto_id; + u16 offset; +}; + +struct ice_proto_grp_item { + u16 idx; + struct ice_proto_off po[ICE_PROTO_COUNT_PER_GRP]; +}; + +void ice_proto_grp_dump(struct ice_hw *hw, struct ice_proto_grp_item *item); +struct ice_proto_grp_item *ice_proto_grp_table_get(struct ice_hw *hw); +#endif /* _ICE_PROTO_GRP_H_ */ diff --git a/drivers/net/ice/base/meson.build b/drivers/net/ice/base/meson.build index df021b12dd..8da942a2be 100644 --- a/drivers/net/ice/base/meson.build +++ b/drivers/net/ice/base/meson.build @@ -22,6 +22,7 @@ sources = [ 'ice_bst_tcam.c', 'ice_ptype_mk.c', 'ice_mk_grp.c', + 'ice_proto_grp.c', ] error_cflags = [ -- 2.26.2