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"
9 static void _proto_off_dump(struct ice_hw *hw, struct ice_proto_off *po,
12 ice_info(hw, "proto %d\n", idx);
13 ice_info(hw, "\tpolarity = %d\n", po->polarity);
14 ice_info(hw, "\tproto_id = %d\n", po->proto_id);
15 ice_info(hw, "\toffset = %d\n", po->offset);
19 * ice_proto_grp_dump - dump a proto group item info
20 * @ice_hw: pointer to the hardware structure
21 * @item: proto group item to dump
23 void ice_proto_grp_dump(struct ice_hw *hw, struct ice_proto_grp_item *item)
27 ice_info(hw, "index = %d\n", item->idx);
29 for (i = 0; i < ICE_PROTO_COUNT_PER_GRP; i++)
30 _proto_off_dump(hw, &item->po[i], i);
33 /** The function parses a 22 bits Protocol entry with below format:
34 * BIT 0: Polarity of Protocol Offset (po->polarity)
35 * BIT 1-8: Protocol ID (po->proto_id)
37 * BIT 12-21: Protocol Offset (po->offset)
39 static void _proto_off_parse(struct ice_proto_off *po, u32 data)
41 po->polarity = (data & 0x1) != 0;
42 po->proto_id = (u8)((data >> 1) & 0xff);
43 po->offset = (u16)((data >> 12) & 0x3ff);
46 /** The function parses a 192 bits Protocol Group Table entry with below
48 * BIT 0-21: Protocol 0 (grp->po[0])
49 * BIT 22-43: Protocol 1 (grp->po[1])
50 * BIT 44-65: Protocol 2 (grp->po[2])
51 * BIT 66-87: Protocol 3 (grp->po[3])
52 * BIT 88-109: Protocol 4 (grp->po[4])
53 * BIT 110-131:Protocol 5 (grp->po[5])
54 * BIT 132-153:Protocol 6 (grp->po[6])
55 * BIT 154-175:Protocol 7 (grp->po[7])
56 * BIT 176-191:reserved
58 static void _proto_grp_parse_item(struct ice_hw *hw, u16 idx, void *item,
61 struct ice_proto_grp_item *grp = (struct ice_proto_grp_item *)item;
68 _proto_off_parse(&grp->po[0], d32);
70 d32 = (*(u32 *)&buf[2] >> 6);
71 _proto_off_parse(&grp->po[1], d32);
73 d32 = (*(u32 *)&buf[5] >> 4);
74 _proto_off_parse(&grp->po[2], d32);
76 d32 = (*(u32 *)&buf[8] >> 2);
77 _proto_off_parse(&grp->po[3], d32);
79 d32 = *(u32 *)&buf[11];
80 _proto_off_parse(&grp->po[4], d32);
82 d32 = (*(u32 *)&buf[13] >> 6);
83 _proto_off_parse(&grp->po[5], d32);
85 d32 = (*(u32 *)&buf[16] >> 4);
86 _proto_off_parse(&grp->po[6], d32);
88 d32 = (*(u32 *)&buf[19] >> 2);
89 _proto_off_parse(&grp->po[7], d32);
91 if (hw->debug_mask & ICE_DBG_PARSER)
92 ice_proto_grp_dump(hw, grp);
96 * ice_proto_grp_table_get - create a proto group table
97 * @ice_hw: pointer to the hardware structure
99 struct ice_proto_grp_item *ice_proto_grp_table_get(struct ice_hw *hw)
101 return (struct ice_proto_grp_item *)
102 ice_parser_create_table(hw, ICE_SID_RXPARSER_PROTO_GRP,
103 sizeof(struct ice_proto_grp_item),
104 ICE_PROTO_GRP_TABLE_SIZE,
105 ice_parser_sect_item_get,
106 _proto_grp_parse_item, false);