1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2001-2021 Intel Corporation
5 #include "ice_common.h"
6 #include "ice_parser_util.h"
8 #define ICE_PROTO_GRP_TABLE_SIZE 192
10 static void _proto_off_dump(struct ice_hw *hw, struct ice_proto_off *po,
13 ice_info(hw, "proto %d\n", idx);
14 ice_info(hw, "\tpolarity = %d\n", po->polarity);
15 ice_info(hw, "\tproto_id = %d\n", po->proto_id);
16 ice_info(hw, "\toffset = %d\n", po->offset);
20 * ice_proto_grp_dump - dump a proto group item info
21 * @ice_hw: pointer to the hardware structure
22 * @item: proto group item to dump
24 void ice_proto_grp_dump(struct ice_hw *hw, struct ice_proto_grp_item *item)
28 ice_info(hw, "index = %d\n", item->idx);
30 for (i = 0; i < ICE_PROTO_COUNT_PER_GRP; i++)
31 _proto_off_dump(hw, &item->po[i], i);
34 /** The function parses a 22 bits Protocol entry with below format:
35 * BIT 0: Polarity of Protocol Offset (po->polarity)
36 * BIT 1-8: Protocol ID (po->proto_id)
38 * BIT 12-21: Protocol Offset (po->offset)
40 static void _proto_off_parse(struct ice_proto_off *po, u32 data)
42 po->polarity = (data & 0x1) != 0;
43 po->proto_id = (u8)((data >> 1) & 0xff);
44 po->offset = (u16)((data >> 12) & 0x3ff);
47 /** The function parses a 192 bits Protocol Group Table entry with below
49 * BIT 0-21: Protocol 0 (grp->po[0])
50 * BIT 22-43: Protocol 1 (grp->po[1])
51 * BIT 44-65: Protocol 2 (grp->po[2])
52 * BIT 66-87: Protocol 3 (grp->po[3])
53 * BIT 88-109: Protocol 4 (grp->po[4])
54 * BIT 110-131:Protocol 5 (grp->po[5])
55 * BIT 132-153:Protocol 6 (grp->po[6])
56 * BIT 154-175:Protocol 7 (grp->po[7])
57 * BIT 176-191:reserved
59 static void _proto_grp_parse_item(struct ice_hw *hw, u16 idx, void *item,
62 struct ice_proto_grp_item *grp = (struct ice_proto_grp_item *)item;
69 _proto_off_parse(&grp->po[0], d32);
71 d32 = (*(u32 *)&buf[2] >> 6);
72 _proto_off_parse(&grp->po[1], d32);
74 d32 = (*(u32 *)&buf[5] >> 4);
75 _proto_off_parse(&grp->po[2], d32);
77 d32 = (*(u32 *)&buf[8] >> 2);
78 _proto_off_parse(&grp->po[3], d32);
80 d32 = *(u32 *)&buf[11];
81 _proto_off_parse(&grp->po[4], d32);
83 d32 = (*(u32 *)&buf[13] >> 6);
84 _proto_off_parse(&grp->po[5], d32);
86 d32 = (*(u32 *)&buf[16] >> 4);
87 _proto_off_parse(&grp->po[6], d32);
89 d32 = (*(u32 *)&buf[19] >> 2);
90 _proto_off_parse(&grp->po[7], d32);
92 if (hw->debug_mask & ICE_DBG_PARSER)
93 ice_proto_grp_dump(hw, grp);
97 * ice_proto_grp_table_get - create a proto group table
98 * @ice_hw: pointer to the hardware structure
100 struct ice_proto_grp_item *ice_proto_grp_table_get(struct ice_hw *hw)
102 return (struct ice_proto_grp_item *)
103 ice_parser_create_table(hw, ICE_SID_RXPARSER_PROTO_GRP,
104 sizeof(struct ice_proto_grp_item),
105 ICE_PROTO_GRP_TABLE_SIZE,
106 ice_parser_sect_item_get,
107 _proto_grp_parse_item, false);