From: Qi Zhang Date: Fri, 17 Sep 2021 14:43:10 +0000 (+0800) Subject: net/ice/base: init protocol group table for parser X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=7b61be517fd501e9b05f3379b9a71404d50e8338;p=dpdk.git net/ice/base: init protocol group table for parser 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 --- 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 e96503c871..1c875e6899 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 = [