Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2001-2023 Intel Corporation
3 : : */
4 : :
5 : : #include "ice_common.h"
6 : : #include "ice_parser_util.h"
7 : :
8 : : #define ICE_IMEM_TABLE_SIZE 192
9 : :
10 : 0 : static void _imem_bst_bm_dump(struct ice_hw *hw, struct ice_bst_main *bm)
11 : : {
12 [ # # ]: 0 : ice_info(hw, "boost main:\n");
13 [ # # ]: 0 : ice_info(hw, "\tal0 = %d\n", bm->al0);
14 [ # # ]: 0 : ice_info(hw, "\tal1 = %d\n", bm->al1);
15 [ # # ]: 0 : ice_info(hw, "\tal2 = %d\n", bm->al2);
16 [ # # ]: 0 : ice_info(hw, "\tpg = %d\n", bm->pg);
17 : 0 : }
18 : :
19 : 0 : static void _imem_bst_kb_dump(struct ice_hw *hw, struct ice_bst_keybuilder *kb)
20 : : {
21 [ # # ]: 0 : ice_info(hw, "boost key builder:\n");
22 [ # # ]: 0 : ice_info(hw, "\tpriority = %d\n", kb->priority);
23 [ # # ]: 0 : ice_info(hw, "\ttsr_ctrl = %d\n", kb->tsr_ctrl);
24 : 0 : }
25 : :
26 : 0 : static void _imem_np_kb_dump(struct ice_hw *hw, struct ice_np_keybuilder *kb)
27 : : {
28 [ # # ]: 0 : ice_info(hw, "next proto key builder:\n");
29 [ # # ]: 0 : ice_info(hw, "\tops = %d\n", kb->ops);
30 [ # # ]: 0 : ice_info(hw, "\tstart_or_reg0 = %d\n", kb->start_or_reg0);
31 [ # # ]: 0 : ice_info(hw, "\tlen_or_reg1 = %d\n", kb->len_or_reg1);
32 : 0 : }
33 : :
34 : 0 : static void _imem_pg_kb_dump(struct ice_hw *hw, struct ice_pg_keybuilder *kb)
35 : : {
36 [ # # ]: 0 : ice_info(hw, "parse graph key builder:\n");
37 [ # # ]: 0 : ice_info(hw, "\tflag0_ena = %d\n", kb->flag0_ena);
38 [ # # ]: 0 : ice_info(hw, "\tflag1_ena = %d\n", kb->flag1_ena);
39 [ # # ]: 0 : ice_info(hw, "\tflag2_ena = %d\n", kb->flag2_ena);
40 [ # # ]: 0 : ice_info(hw, "\tflag3_ena = %d\n", kb->flag3_ena);
41 [ # # ]: 0 : ice_info(hw, "\tflag0_idx = %d\n", kb->flag0_idx);
42 [ # # ]: 0 : ice_info(hw, "\tflag1_idx = %d\n", kb->flag1_idx);
43 [ # # ]: 0 : ice_info(hw, "\tflag2_idx = %d\n", kb->flag2_idx);
44 [ # # ]: 0 : ice_info(hw, "\tflag3_idx = %d\n", kb->flag3_idx);
45 [ # # ]: 0 : ice_info(hw, "\talu_reg_idx = %d\n", kb->alu_reg_idx);
46 : 0 : }
47 : :
48 : 0 : static void _imem_alu_dump(struct ice_hw *hw, struct ice_alu *alu, int index)
49 : : {
50 [ # # ]: 0 : ice_info(hw, "alu%d:\n", index);
51 [ # # ]: 0 : ice_info(hw, "\topc = %d\n", alu->opc);
52 [ # # ]: 0 : ice_info(hw, "\tsrc_start = %d\n", alu->src_start);
53 [ # # ]: 0 : ice_info(hw, "\tsrc_len = %d\n", alu->src_len);
54 [ # # ]: 0 : ice_info(hw, "\tshift_xlate_select = %d\n", alu->shift_xlate_select);
55 [ # # ]: 0 : ice_info(hw, "\tshift_xlate_key = %d\n", alu->shift_xlate_key);
56 [ # # ]: 0 : ice_info(hw, "\tsrc_reg_id = %d\n", alu->src_reg_id);
57 [ # # ]: 0 : ice_info(hw, "\tdst_reg_id = %d\n", alu->dst_reg_id);
58 [ # # ]: 0 : ice_info(hw, "\tinc0 = %d\n", alu->inc0);
59 [ # # ]: 0 : ice_info(hw, "\tinc1 = %d\n", alu->inc1);
60 [ # # ]: 0 : ice_info(hw, "\tproto_offset_opc = %d\n", alu->proto_offset_opc);
61 [ # # ]: 0 : ice_info(hw, "\tproto_offset = %d\n", alu->proto_offset);
62 [ # # ]: 0 : ice_info(hw, "\tbranch_addr = %d\n", alu->branch_addr);
63 [ # # ]: 0 : ice_info(hw, "\timm = %d\n", alu->imm);
64 [ # # ]: 0 : ice_info(hw, "\tdst_start = %d\n", alu->dst_start);
65 [ # # ]: 0 : ice_info(hw, "\tdst_len = %d\n", alu->dst_len);
66 [ # # ]: 0 : ice_info(hw, "\tflags_extr_imm = %d\n", alu->flags_extr_imm);
67 [ # # ]: 0 : ice_info(hw, "\tflags_start_imm= %d\n", alu->flags_start_imm);
68 : 0 : }
69 : :
70 : : /**
71 : : * ice_imem_dump - dump an imem item info
72 : : * @hw: pointer to the hardware structure
73 : : * @item: imem item to dump
74 : : */
75 : 0 : void ice_imem_dump(struct ice_hw *hw, struct ice_imem_item *item)
76 : : {
77 [ # # ]: 0 : ice_info(hw, "index = %d\n", item->idx);
78 : 0 : _imem_bst_bm_dump(hw, &item->b_m);
79 : 0 : _imem_bst_kb_dump(hw, &item->b_kb);
80 [ # # ]: 0 : ice_info(hw, "pg priority = %d\n", item->pg);
81 : 0 : _imem_np_kb_dump(hw, &item->np_kb);
82 : 0 : _imem_pg_kb_dump(hw, &item->pg_kb);
83 : 0 : _imem_alu_dump(hw, &item->alu0, 0);
84 : 0 : _imem_alu_dump(hw, &item->alu1, 1);
85 : 0 : _imem_alu_dump(hw, &item->alu2, 2);
86 : 0 : }
87 : :
88 : : /** The function parses a 4 bits Boost Main with below format:
89 : : * BIT 0: ALU 0 (bm->alu0)
90 : : * BIT 1: ALU 1 (bm->alu1)
91 : : * BIT 2: ALU 2 (bm->alu2)
92 : : * BIT 3: Parge Graph (bm->pg)
93 : : */
94 : : static void _imem_bm_init(struct ice_bst_main *bm, u8 data)
95 : : {
96 : 0 : bm->al0 = (data & 0x1) != 0;
97 : 0 : bm->al1 = (data & 0x2) != 0;
98 : 0 : bm->al2 = (data & 0x4) != 0;
99 : 0 : bm->pg = (data & 0x8) != 0;
100 : : }
101 : :
102 : : /** The function parses a 10 bits Boost Main Build with below format:
103 : : * BIT 0-7: Priority (bkb->priority)
104 : : * BIT 8: TSR Control (bkb->tsr_ctrl)
105 : : * BIT 9: Reserved
106 : : */
107 : : static void _imem_bkb_init(struct ice_bst_keybuilder *bkb, u16 data)
108 : : {
109 : 0 : bkb->priority = (u8)(data & 0xff);
110 : 0 : bkb->tsr_ctrl = (data & 0x100) != 0;
111 : : }
112 : :
113 : : /** The function parses a 18 bits Next Protocol Key Build with below format:
114 : : * BIT 0-1: Opcode kb->ops
115 : : * BIT 2-9: Start / Reg 0 (kb->start_or_reg0)
116 : : * BIT 10-17: Length / Reg 1 (kb->len_or_reg1)
117 : : */
118 : : static void _imem_npkb_init(struct ice_np_keybuilder *kb, u32 data)
119 : : {
120 : 0 : kb->ops = (u8)(data & 0x3);
121 : 0 : kb->start_or_reg0 = (u8)((data >> 2) & 0xff);
122 : 0 : kb->len_or_reg1 = (u8)((data >> 10) & 0xff);
123 : : }
124 : :
125 : : /** The function parses a 35 bits Parse Graph Key Build with below format:
126 : : * BIT 0: Flag 0 Enable (kb->flag0_ena)
127 : : * BIT 1-6: Flag 0 Index (kb->flag0_idx)
128 : : * BIT 7: Flag 1 Enable (kb->flag1_ena)
129 : : * BIT 8-13: Flag 1 Index (kb->flag1_idx)
130 : : * BIT 14: Flag 2 Enable (kb->flag2_ena)
131 : : * BIT 15-20: Flag 2 Index (kb->flag2_idx)
132 : : * BIT 21: Flag 3 Enable (kb->flag3_ena)
133 : : * BIT 22-27: Flag 3 Index (kb->flag3_idx)
134 : : * BIT 28-34: ALU Register Index (kb->alu_reg_idx)
135 : : */
136 : 0 : static void _imem_pgkb_init(struct ice_pg_keybuilder *kb, u64 data)
137 : : {
138 : 0 : kb->flag0_ena = (data & 0x1) != 0;
139 : 0 : kb->flag0_idx = (u8)((data >> 1) & 0x3f);
140 : 0 : kb->flag1_ena = ((data >> 7) & 0x1) != 0;
141 : 0 : kb->flag1_idx = (u8)((data >> 8) & 0x3f);
142 : 0 : kb->flag2_ena = ((data >> 14) & 0x1) != 0;
143 : 0 : kb->flag2_idx = (u8)((data >> 15) & 0x3f);
144 : 0 : kb->flag3_ena = ((data >> 21) & 0x1) != 0;
145 : 0 : kb->flag3_idx = (u8)((data >> 22) & 0x3f);
146 : 0 : kb->alu_reg_idx = (u8)((data >> 28) & 0x7f);
147 : 0 : }
148 : :
149 : : /** The function parses a 96 bits ALU entry with below format:
150 : : * BIT 0-5: Opcode (alu->opc)
151 : : * BIT 6-13: Source Start (alu->src_start)
152 : : * BIT 14-18: Source Length (alu->src_len)
153 : : * BIT 19: Shift/Xlate Select (alu->shift_xlate_select)
154 : : * BIT 20-23: Shift/Xlate Key (alu->shift_xlate_key)
155 : : * BIT 24-30: Source Register ID (alu->src_reg_id)
156 : : * BIT 31-37: Dest. Register ID (alu->dst_reg_id)
157 : : * BIT 38: Inc0 (alu->inc0)
158 : : * BIT 39: Inc1:(alu->inc1)
159 : : * BIT 40:41 Protocol Offset Opcode (alu->proto_offset_opc)
160 : : * BIT 42:49 Protocol Offset (alu->proto_offset)
161 : : * BIT 50:57 Branch Address (alu->branch_addr)
162 : : * BIT 58:73 Immediate (alu->imm)
163 : : * BIT 74 Dedicated Flags Enable (alu->dedicate_flags_ena)
164 : : * BIT 75:80 Dest. Start (alu->dst_start)
165 : : * BIT 81:86 Dest. Length (alu->dst_len)
166 : : * BIT 87 Flags Extract Imm. (alu->flags_extr_imm)
167 : : * BIT 88:95 Flags Start/Immediate (alu->flags_start_imm)
168 : : *
169 : : * NOTE: the first 5 bits are skipped as the start bit is not
170 : : * byte aligned.
171 : : */
172 : 0 : static void _imem_alu_init(struct ice_alu *alu, u8 *data)
173 : : {
174 : 0 : u64 d64 = *(u64 *)data >> 5;
175 : :
176 : 0 : alu->opc = (enum ice_alu_opcode)(d64 & 0x3f);
177 : 0 : alu->src_start = (u8)((d64 >> 6) & 0xff);
178 : 0 : alu->src_len = (u8)((d64 >> 14) & 0x1f);
179 : 0 : alu->shift_xlate_select = ((d64 >> 19) & 0x1) != 0;
180 : 0 : alu->shift_xlate_key = (u8)((d64 >> 20) & 0xf);
181 : 0 : alu->src_reg_id = (u8)((d64 >> 24) & 0x7f);
182 : 0 : alu->dst_reg_id = (u8)((d64 >> 31) & 0x7f);
183 : 0 : alu->inc0 = ((d64 >> 38) & 0x1) != 0;
184 : 0 : alu->inc1 = ((d64 >> 39) & 0x1) != 0;
185 : 0 : alu->proto_offset_opc = (u8)((d64 >> 40) & 0x3);
186 : 0 : alu->proto_offset = (u8)((d64 >> 42) & 0xff);
187 : 0 : alu->branch_addr = (u8)((d64 >> 50) & 0xff);
188 : :
189 : 0 : d64 = *(u64 *)(&data[7]) >> 7;
190 : :
191 : 0 : alu->imm = (u16)(d64 & 0xffff);
192 : 0 : alu->dedicate_flags_ena = ((d64 >> 16) & 0x1) != 0;
193 : 0 : alu->dst_start = (u8)((d64 >> 17) & 0x3f);
194 : 0 : alu->dst_len = (u8)((d64 >> 23) & 0x3f);
195 : 0 : alu->flags_extr_imm = ((d64 >> 29) & 0x1) != 0;
196 : 0 : alu->flags_start_imm = (u8)((d64 >> 30) & 0xff);
197 : 0 : }
198 : :
199 : : /** The function parses a 384 bits IMEM entry with below format:
200 : : * BIT 0-3: Boost Main (ii->b_m)
201 : : * BIT 4-13: Boost Key Build (ii->b_kb)
202 : : * BIT 14-15: PG Priority (ii->pg)
203 : : * BIT 16-33: Next Proto Key Build (ii->np_kb)
204 : : * BIT 34-68: PG Key Build (ii->pg_kb)
205 : : * BIT 69-164: ALU0 (ii->alu0)
206 : : * BIT 165-260:ALU1 (ii->alu1)
207 : : * BIT 261-356:ALU2 (ii->alu2)
208 : : * BIT 357-383:Reserved
209 : : */
210 : 0 : static void _imem_parse_item(struct ice_hw *hw, u16 idx, void *item,
211 : : void *data, int size)
212 : : {
213 : : struct ice_imem_item *ii = (struct ice_imem_item *)item;
214 : : u8 *buf = (u8 *)data;
215 : :
216 : 0 : ii->idx = idx;
217 : :
218 : 0 : _imem_bm_init(&ii->b_m, buf[0]);
219 : 0 : _imem_bkb_init(&ii->b_kb, *((u16 *)(&buf[0])) >> 4);
220 : :
221 : 0 : ii->pg = (u8)((buf[1] & 0xc0) >> 6);
222 : 0 : _imem_npkb_init(&ii->np_kb, *((u32 *)(&buf[2])));
223 : 0 : _imem_pgkb_init(&ii->pg_kb, *((u64 *)(&buf[2])) >> 18);
224 : 0 : _imem_alu_init(&ii->alu0, &buf[8]);
225 : 0 : _imem_alu_init(&ii->alu1, &buf[20]);
226 : 0 : _imem_alu_init(&ii->alu2, &buf[32]);
227 : :
228 [ # # ]: 0 : if (hw->debug_mask & ICE_DBG_PARSER)
229 : 0 : ice_imem_dump(hw, ii);
230 : 0 : }
231 : :
232 : : /**
233 : : * ice_imem_table_get - create an imem table
234 : : * @hw: pointer to the hardware structure
235 : : */
236 : 0 : struct ice_imem_item *ice_imem_table_get(struct ice_hw *hw)
237 : : {
238 : 0 : return (struct ice_imem_item *)
239 : 0 : ice_parser_create_table(hw, ICE_SID_RXPARSER_IMEM,
240 : : sizeof(struct ice_imem_item),
241 : : ICE_IMEM_TABLE_SIZE,
242 : : ice_parser_sect_item_get,
243 : : _imem_parse_item, false);
244 : : }
|