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_SEC_DATA_OFFSET 4
9 : : #define ICE_SID_RXPARSER_IMEM_ENTRY_SIZE 48
10 : : #define ICE_SID_RXPARSER_METADATA_INIT_ENTRY_SIZE 24
11 : : #define ICE_SID_RXPARSER_CAM_ENTRY_SIZE 16
12 : : #define ICE_SID_RXPARSER_PG_SPILL_ENTRY_SIZE 17
13 : : #define ICE_SID_RXPARSER_NOMATCH_CAM_ENTRY_SIZE 12
14 : : #define ICE_SID_RXPARSER_NOMATCH_SPILL_ENTRY_SIZE 13
15 : : #define ICE_SID_RXPARSER_BOOST_TCAM_ENTRY_SIZE 88
16 : : #define ICE_SID_RXPARSER_MARKER_TYPE_ENTRY_SIZE 24
17 : : #define ICE_SID_RXPARSER_MARKER_GRP_ENTRY_SIZE 8
18 : : #define ICE_SID_RXPARSER_PROTO_GRP_ENTRY_SIZE 24
19 : : #define ICE_SID_RXPARSER_FLAG_REDIR_ENTRY_SIZE 1
20 : :
21 : : #define ICE_SEC_LBL_DATA_OFFSET 2
22 : : #define ICE_SID_LBL_ENTRY_SIZE 66
23 : :
24 : 0 : void ice_lbl_dump(struct ice_hw *hw, struct ice_lbl_item *item)
25 : : {
26 [ # # ]: 0 : ice_info(hw, "index = %d\n", item->idx);
27 [ # # ]: 0 : ice_info(hw, "label = %s\n", item->label);
28 : 0 : }
29 : :
30 : 0 : void ice_parse_item_dflt(struct ice_hw *hw, u16 idx, void *item,
31 : : void *data, int size)
32 : : {
33 [ # # ]: 0 : ice_memcpy(item, data, size, ICE_DMA_TO_NONDMA);
34 : 0 : }
35 : :
36 : : /**
37 : : * ice_parser_sect_item_get - parse a item from a section
38 : : * @sect_type: section type
39 : : * @section: section object
40 : : * @index: index of the item to get
41 : : * @offset: dummy as prototype of ice_pkg_enum_entry's last parameter
42 : : */
43 : 0 : void *ice_parser_sect_item_get(u32 sect_type, void *section,
44 : : u32 index, u32 *offset)
45 : : {
46 : : struct ice_pkg_sect_hdr *hdr;
47 : : int data_off = ICE_SEC_DATA_OFFSET;
48 : : int size;
49 : :
50 [ # # ]: 0 : if (!section)
51 : : return NULL;
52 : :
53 [ # # # # : 0 : switch (sect_type) {
# # # # #
# # # # ]
54 : : case ICE_SID_RXPARSER_IMEM:
55 : : size = ICE_SID_RXPARSER_IMEM_ENTRY_SIZE;
56 : : break;
57 : 0 : case ICE_SID_RXPARSER_METADATA_INIT:
58 : : size = ICE_SID_RXPARSER_METADATA_INIT_ENTRY_SIZE;
59 : 0 : break;
60 : 0 : case ICE_SID_RXPARSER_CAM:
61 : : size = ICE_SID_RXPARSER_CAM_ENTRY_SIZE;
62 : 0 : break;
63 : 0 : case ICE_SID_RXPARSER_PG_SPILL:
64 : : size = ICE_SID_RXPARSER_PG_SPILL_ENTRY_SIZE;
65 : 0 : break;
66 : 0 : case ICE_SID_RXPARSER_NOMATCH_CAM:
67 : : size = ICE_SID_RXPARSER_NOMATCH_CAM_ENTRY_SIZE;
68 : 0 : break;
69 : 0 : case ICE_SID_RXPARSER_NOMATCH_SPILL:
70 : : size = ICE_SID_RXPARSER_NOMATCH_SPILL_ENTRY_SIZE;
71 : 0 : break;
72 : 0 : case ICE_SID_RXPARSER_BOOST_TCAM:
73 : : size = ICE_SID_RXPARSER_BOOST_TCAM_ENTRY_SIZE;
74 : 0 : break;
75 : 0 : case ICE_SID_LBL_RXPARSER_TMEM:
76 : : data_off = ICE_SEC_LBL_DATA_OFFSET;
77 : : size = ICE_SID_LBL_ENTRY_SIZE;
78 : 0 : break;
79 : 0 : case ICE_SID_RXPARSER_MARKER_PTYPE:
80 : : size = ICE_SID_RXPARSER_MARKER_TYPE_ENTRY_SIZE;
81 : 0 : break;
82 : 0 : case ICE_SID_RXPARSER_MARKER_GRP:
83 : : size = ICE_SID_RXPARSER_MARKER_GRP_ENTRY_SIZE;
84 : 0 : break;
85 : 0 : case ICE_SID_RXPARSER_PROTO_GRP:
86 : : size = ICE_SID_RXPARSER_PROTO_GRP_ENTRY_SIZE;
87 : 0 : break;
88 : 0 : case ICE_SID_RXPARSER_FLAG_REDIR:
89 : : size = ICE_SID_RXPARSER_FLAG_REDIR_ENTRY_SIZE;
90 : 0 : break;
91 : : default:
92 : : return NULL;
93 : : }
94 : :
95 : : hdr = (struct ice_pkg_sect_hdr *)section;
96 [ # # ]: 0 : if (index >= LE16_TO_CPU(hdr->count))
97 : : return NULL;
98 : :
99 : 0 : return (void *)((uintptr_t)section + data_off + index * size);
100 : : }
101 : :
102 : : /**
103 : : * ice_parser_create_table - create a item table from a section
104 : : * @hw: pointer to the hardware structure
105 : : * @sect_type: section type
106 : : * @item_size: item size in byte
107 : : * @length: number of items in the table to create
108 : : * @item_get: the function will be parsed to ice_pkg_enum_entry
109 : : * @parse_item: the function to parse the item
110 : : * @no_offset: ignore header offset, calculate index from 0
111 : : */
112 : 0 : void *ice_parser_create_table(struct ice_hw *hw, u32 sect_type,
113 : : u32 item_size, u32 length,
114 : : void *(*item_get)(u32 sect_type, void *section,
115 : : u32 index, u32 *offset),
116 : : void (*parse_item)(struct ice_hw *hw, u16 idx,
117 : : void *item, void *data,
118 : : int size),
119 : : bool no_offset)
120 : : {
121 : 0 : struct ice_seg *seg = hw->seg;
122 : : struct ice_pkg_enum state;
123 : : u16 idx = 0xffff;
124 : : void *table;
125 : : void *data;
126 : :
127 [ # # ]: 0 : if (!seg)
128 : : return NULL;
129 : :
130 : 0 : table = ice_malloc(hw, item_size * length);
131 [ # # ]: 0 : if (!table) {
132 [ # # ]: 0 : ice_debug(hw, ICE_DBG_PARSER, "failed to allocate memory for table type %d.\n",
133 : : sect_type);
134 : 0 : return NULL;
135 : : }
136 : :
137 : : ice_memset(&state, 0, sizeof(state), ICE_NONDMA_MEM);
138 : : do {
139 : 0 : data = ice_pkg_enum_entry(seg, &state, sect_type, NULL,
140 : : item_get);
141 : : seg = NULL;
142 [ # # ]: 0 : if (data) {
143 : 0 : struct ice_pkg_sect_hdr *hdr =
144 : : (struct ice_pkg_sect_hdr *)state.sect;
145 : :
146 [ # # ]: 0 : if (no_offset)
147 : 0 : idx++;
148 : : else
149 : 0 : idx = hdr->offset + state.entry_idx;
150 : 0 : parse_item(hw, idx,
151 : 0 : (void *)((uintptr_t)table + idx * item_size),
152 : : data, item_size);
153 : : }
154 [ # # ]: 0 : } while (data);
155 : :
156 : : return table;
157 : : }
158 : :
159 : : /**
160 : : * ice_parser_create - create a parser instance
161 : : * @hw: pointer to the hardware structure
162 : : * @psr: output parameter for a new parser instance be created
163 : : */
164 : 0 : enum ice_status ice_parser_create(struct ice_hw *hw, struct ice_parser **psr)
165 : : {
166 : : enum ice_status status;
167 : : struct ice_parser *p;
168 : :
169 : 0 : p = (struct ice_parser *)ice_malloc(hw, sizeof(struct ice_parser));
170 [ # # ]: 0 : if (!p)
171 : : return ICE_ERR_NO_MEMORY;
172 : :
173 : 0 : p->hw = hw;
174 : 0 : p->rt.psr = p;
175 : :
176 : 0 : p->imem_table = ice_imem_table_get(hw);
177 [ # # ]: 0 : if (!p->imem_table) {
178 : : status = ICE_ERR_PARAM;
179 : 0 : goto err;
180 : : }
181 : :
182 : 0 : p->mi_table = ice_metainit_table_get(hw);
183 [ # # ]: 0 : if (!p->mi_table) {
184 : : status = ICE_ERR_PARAM;
185 : 0 : goto err;
186 : : }
187 : :
188 : 0 : p->pg_cam_table = ice_pg_cam_table_get(hw);
189 [ # # ]: 0 : if (!p->pg_cam_table) {
190 : : status = ICE_ERR_PARAM;
191 : 0 : goto err;
192 : : }
193 : :
194 : 0 : p->pg_sp_cam_table = ice_pg_sp_cam_table_get(hw);
195 [ # # ]: 0 : if (!p->pg_sp_cam_table) {
196 : : status = ICE_ERR_PARAM;
197 : 0 : goto err;
198 : : }
199 : :
200 : 0 : p->pg_nm_cam_table = ice_pg_nm_cam_table_get(hw);
201 [ # # ]: 0 : if (!p->pg_nm_cam_table) {
202 : : status = ICE_ERR_PARAM;
203 : 0 : goto err;
204 : : }
205 : :
206 : 0 : p->pg_nm_sp_cam_table = ice_pg_nm_sp_cam_table_get(hw);
207 [ # # ]: 0 : if (!p->pg_nm_sp_cam_table) {
208 : : status = ICE_ERR_PARAM;
209 : 0 : goto err;
210 : : }
211 : :
212 : 0 : p->bst_tcam_table = ice_bst_tcam_table_get(hw);
213 [ # # ]: 0 : if (!p->bst_tcam_table) {
214 : : status = ICE_ERR_PARAM;
215 : 0 : goto err;
216 : : }
217 : :
218 : 0 : p->bst_lbl_table = ice_bst_lbl_table_get(hw);
219 [ # # ]: 0 : if (!p->bst_lbl_table) {
220 : : status = ICE_ERR_PARAM;
221 : 0 : goto err;
222 : : }
223 : :
224 : 0 : p->ptype_mk_tcam_table = ice_ptype_mk_tcam_table_get(hw);
225 [ # # ]: 0 : if (!p->ptype_mk_tcam_table) {
226 : : status = ICE_ERR_PARAM;
227 : 0 : goto err;
228 : : }
229 : :
230 : 0 : p->mk_grp_table = ice_mk_grp_table_get(hw);
231 [ # # ]: 0 : if (!p->mk_grp_table) {
232 : : status = ICE_ERR_PARAM;
233 : 0 : goto err;
234 : : }
235 : :
236 : 0 : p->proto_grp_table = ice_proto_grp_table_get(hw);
237 [ # # ]: 0 : if (!p->proto_grp_table) {
238 : : status = ICE_ERR_PARAM;
239 : 0 : goto err;
240 : : }
241 : :
242 : 0 : p->flg_rd_table = ice_flg_rd_table_get(hw);
243 [ # # ]: 0 : if (!p->flg_rd_table) {
244 : : status = ICE_ERR_PARAM;
245 : 0 : goto err;
246 : : }
247 : :
248 : 0 : p->xlt_kb_sw = ice_xlt_kb_get_sw(hw);
249 [ # # ]: 0 : if (!p->xlt_kb_sw) {
250 : : status = ICE_ERR_PARAM;
251 : 0 : goto err;
252 : : }
253 : :
254 : 0 : p->xlt_kb_acl = ice_xlt_kb_get_acl(hw);
255 [ # # ]: 0 : if (!p->xlt_kb_acl) {
256 : : status = ICE_ERR_PARAM;
257 : 0 : goto err;
258 : : }
259 : :
260 : 0 : p->xlt_kb_fd = ice_xlt_kb_get_fd(hw);
261 [ # # ]: 0 : if (!p->xlt_kb_fd) {
262 : : status = ICE_ERR_PARAM;
263 : 0 : goto err;
264 : : }
265 : :
266 : 0 : p->xlt_kb_rss = ice_xlt_kb_get_rss(hw);
267 [ # # ]: 0 : if (!p->xlt_kb_rss) {
268 : : status = ICE_ERR_PARAM;
269 : 0 : goto err;
270 : : }
271 : :
272 : 0 : *psr = p;
273 : 0 : return ICE_SUCCESS;
274 : 0 : err:
275 : 0 : ice_parser_destroy(p);
276 : 0 : return status;
277 : : }
278 : :
279 : : /**
280 : : * ice_parser_destroy - destroy a parser instance
281 : : * @psr: pointer to a parser instance
282 : : */
283 : 0 : void ice_parser_destroy(struct ice_parser *psr)
284 : : {
285 : 0 : ice_free(psr->hw, psr->imem_table);
286 : 0 : ice_free(psr->hw, psr->mi_table);
287 : 0 : ice_free(psr->hw, psr->pg_cam_table);
288 : 0 : ice_free(psr->hw, psr->pg_sp_cam_table);
289 : 0 : ice_free(psr->hw, psr->pg_nm_cam_table);
290 : 0 : ice_free(psr->hw, psr->pg_nm_sp_cam_table);
291 : 0 : ice_free(psr->hw, psr->bst_tcam_table);
292 : 0 : ice_free(psr->hw, psr->bst_lbl_table);
293 : 0 : ice_free(psr->hw, psr->ptype_mk_tcam_table);
294 : 0 : ice_free(psr->hw, psr->mk_grp_table);
295 : 0 : ice_free(psr->hw, psr->proto_grp_table);
296 : 0 : ice_free(psr->hw, psr->flg_rd_table);
297 : 0 : ice_free(psr->hw, psr->xlt_kb_sw);
298 : 0 : ice_free(psr->hw, psr->xlt_kb_acl);
299 : 0 : ice_free(psr->hw, psr->xlt_kb_fd);
300 : 0 : ice_free(psr->hw, psr->xlt_kb_rss);
301 : :
302 : 0 : ice_free(psr->hw, psr);
303 : 0 : }
304 : :
305 : : /**
306 : : * ice_parser_run - parse on a packet in binary and return the result
307 : : * @psr: pointer to a parser instance
308 : : * @pkt_buf: packet data
309 : : * @pkt_len: packet length
310 : : * @rslt: input/output parameter to save parser result.
311 : : */
312 : 0 : enum ice_status ice_parser_run(struct ice_parser *psr, const u8 *pkt_buf,
313 : : int pkt_len, struct ice_parser_result *rslt)
314 : : {
315 : 0 : ice_parser_rt_reset(&psr->rt);
316 : 0 : ice_parser_rt_pktbuf_set(&psr->rt, pkt_buf, pkt_len);
317 : :
318 : 0 : return ice_parser_rt_execute(&psr->rt, rslt);
319 : : }
320 : :
321 : : /**
322 : : * ice_parser_result_dump - dump a parser result info
323 : : * @hw: pointer to the hardware structure
324 : : * @rslt: parser result info to dump
325 : : */
326 : 0 : void ice_parser_result_dump(struct ice_hw *hw, struct ice_parser_result *rslt)
327 : : {
328 : : int i;
329 : :
330 [ # # ]: 0 : ice_info(hw, "ptype = %d\n", rslt->ptype);
331 [ # # ]: 0 : for (i = 0; i < rslt->po_num; i++)
332 [ # # ]: 0 : ice_info(hw, "proto = %d, offset = %d\n",
333 : : rslt->po[i].proto_id, rslt->po[i].offset);
334 : :
335 [ # # ]: 0 : ice_info(hw, "flags_psr = 0x%016" PRIx64 "\n", rslt->flags_psr);
336 [ # # ]: 0 : ice_info(hw, "flags_pkt = 0x%016" PRIx64 "\n", rslt->flags_pkt);
337 [ # # ]: 0 : ice_info(hw, "flags_sw = 0x%04x\n", rslt->flags_sw);
338 [ # # ]: 0 : ice_info(hw, "flags_fd = 0x%04x\n", rslt->flags_fd);
339 [ # # ]: 0 : ice_info(hw, "flags_rss = 0x%04x\n", rslt->flags_rss);
340 : 0 : }
341 : :
342 : 0 : static void _bst_vm_set(struct ice_parser *psr, const char *prefix, bool on)
343 : : {
344 : : struct ice_bst_tcam_item *item;
345 : 0 : u16 i = 0;
346 : :
347 : : while (true) {
348 : 0 : item = ice_bst_tcam_search(psr->bst_tcam_table,
349 : : psr->bst_lbl_table,
350 : : prefix, &i);
351 [ # # ]: 0 : if (!item)
352 : : break;
353 [ # # ]: 0 : item->key[0] = (u8)(on ? 0xff : 0xfe);
354 : 0 : item->key_inv[0] = (u8)(on ? 0xff : 0xfe);
355 : 0 : i++;
356 : : }
357 : 0 : }
358 : :
359 : : /**
360 : : * ice_parser_dvm_set - configure double vlan mode for parser
361 : : * @psr: pointer to a parser instance
362 : : * @on: true to turn on; false to turn off
363 : : */
364 : 0 : void ice_parser_dvm_set(struct ice_parser *psr, bool on)
365 : : {
366 : 0 : _bst_vm_set(psr, "BOOST_MAC_VLAN_DVM", on);
367 : 0 : _bst_vm_set(psr, "BOOST_MAC_VLAN_SVM", !on);
368 : 0 : }
369 : :
370 : : static enum ice_status
371 : 0 : _tunnel_port_set(struct ice_parser *psr, const char *prefix, u16 udp_port,
372 : : bool on)
373 : : {
374 : : u8 *buf = (u8 *)&udp_port;
375 : : struct ice_bst_tcam_item *item;
376 : 0 : u16 i = 0;
377 : :
378 : : while (true) {
379 : 0 : item = ice_bst_tcam_search(psr->bst_tcam_table,
380 : : psr->bst_lbl_table,
381 : : prefix, &i);
382 [ # # ]: 0 : if (!item)
383 : : break;
384 : :
385 : : /* found empty slot to add */
386 [ # # # # : 0 : if (on && item->key[16] == 0xfe && item->key_inv[16] == 0xfe) {
# # ]
387 : 0 : item->key_inv[15] = buf[0];
388 : 0 : item->key_inv[16] = buf[1];
389 : 0 : item->key[15] = (u8)(0xff - buf[0]);
390 : 0 : item->key[16] = (u8)(0xff - buf[1]);
391 : :
392 : 0 : return ICE_SUCCESS;
393 : : /* found a matched slot to delete */
394 [ # # # # ]: 0 : } else if (!on && (item->key_inv[15] == buf[0] ||
395 [ # # ]: 0 : item->key_inv[16] == buf[1])) {
396 : 0 : item->key_inv[15] = 0xff;
397 : 0 : item->key_inv[16] = 0xfe;
398 : 0 : item->key[15] = 0xff;
399 : 0 : item->key[16] = 0xfe;
400 : :
401 : 0 : return ICE_SUCCESS;
402 : : }
403 : 0 : i++;
404 : : }
405 : :
406 : : return ICE_ERR_PARAM;
407 : : }
408 : :
409 : : /**
410 : : * ice_parser_vxlan_tunnel_set - configure vxlan tunnel for parser
411 : : * @psr: pointer to a parser instance
412 : : * @udp_port: vxlan tunnel port in UDP header
413 : : * @on: true to turn on; false to turn off
414 : : */
415 : 0 : enum ice_status ice_parser_vxlan_tunnel_set(struct ice_parser *psr,
416 : : u16 udp_port, bool on)
417 : : {
418 : 0 : return _tunnel_port_set(psr, "TNL_VXLAN", udp_port, on);
419 : : }
420 : :
421 : : /**
422 : : * ice_parser_geneve_tunnel_set - configure geneve tunnel for parser
423 : : * @psr: pointer to a parser instance
424 : : * @udp_port: geneve tunnel port in UDP header
425 : : * @on: true to turn on; false to turn off
426 : : */
427 : 0 : enum ice_status ice_parser_geneve_tunnel_set(struct ice_parser *psr,
428 : : u16 udp_port, bool on)
429 : : {
430 : 0 : return _tunnel_port_set(psr, "TNL_GENEVE", udp_port, on);
431 : : }
432 : :
433 : : /**
434 : : * ice_parser_ecpri_tunnel_set - configure ecpri tunnel for parser
435 : : * @psr: pointer to a parser instance
436 : : * @udp_port: ecpri tunnel port in UDP header
437 : : * @on: true to turn on; false to turn off
438 : : */
439 : 0 : enum ice_status ice_parser_ecpri_tunnel_set(struct ice_parser *psr,
440 : : u16 udp_port, bool on)
441 : : {
442 : 0 : return _tunnel_port_set(psr, "TNL_UDP_ECPRI", udp_port, on);
443 : : }
444 : :
445 : : static bool _nearest_proto_id(struct ice_parser_result *rslt, u16 offset,
446 : : u8 *proto_id, u16 *proto_off)
447 : : {
448 : : u16 dist = 0xffff;
449 : : u8 p = 0;
450 : : int i;
451 : :
452 [ # # ]: 0 : for (i = 0; i < rslt->po_num; i++) {
453 [ # # ]: 0 : if (offset < rslt->po[i].offset)
454 : 0 : continue;
455 [ # # ]: 0 : if (offset - rslt->po[i].offset < dist) {
456 : 0 : p = rslt->po[i].proto_id;
457 : 0 : dist = offset - rslt->po[i].offset;
458 : : }
459 : : }
460 : :
461 [ # # ]: 0 : if (dist % 2)
462 : : return false;
463 : :
464 : : *proto_id = p;
465 : : *proto_off = dist;
466 : :
467 : 0 : return true;
468 : : }
469 : :
470 : : /** default flag mask to cover GTP_EH_PDU, GTP_EH_PDU_LINK and TUN2
471 : : * In future, the flag masks should learn from DDP
472 : : */
473 : : #define ICE_KEYBUILD_FLAG_MASK_DEFAULT_SW 0x4002
474 : : #define ICE_KEYBUILD_FLAG_MASK_DEFAULT_ACL 0x0000
475 : : #define ICE_KEYBUILD_FLAG_MASK_DEFAULT_FD 0x6080
476 : : #define ICE_KEYBUILD_FLAG_MASK_DEFAULT_RSS 0x6010
477 : :
478 : : /**
479 : : * ice_parser_profile_init - initialize a FXP profile base on parser result
480 : : * @rslt: a instance of a parser result
481 : : * @pkt_buf: packet data buffer
482 : : * @msk_buf: packet mask buffer
483 : : * @buf_len: packet length
484 : : * @blk: FXP pipeline stage
485 : : * @prefix_match: match protocol stack exactly or only prefix
486 : : * @prof: input/output parameter to save the profile
487 : : */
488 [ # # ]: 0 : enum ice_status ice_parser_profile_init(struct ice_parser_result *rslt,
489 : : const u8 *pkt_buf, const u8 *msk_buf,
490 : : int buf_len, enum ice_block blk,
491 : : bool prefix_match,
492 : : struct ice_parser_profile *prof)
493 : : {
494 : : u8 proto_id = 0xff;
495 : : u16 proto_off = 0;
496 : : u16 off;
497 : :
498 : : ice_memset(prof, 0, sizeof(*prof), ICE_NONDMA_MEM);
499 [ # # ]: 0 : ice_set_bit(rslt->ptype, prof->ptypes);
500 [ # # ]: 0 : if (blk == ICE_BLK_SW) {
501 : 0 : prof->flags = rslt->flags_sw;
502 : 0 : prof->flags_msk = ICE_KEYBUILD_FLAG_MASK_DEFAULT_SW;
503 [ # # ]: 0 : } else if (blk == ICE_BLK_ACL) {
504 : 0 : prof->flags = rslt->flags_acl;
505 : 0 : prof->flags_msk = ICE_KEYBUILD_FLAG_MASK_DEFAULT_ACL;
506 [ # # ]: 0 : } else if (blk == ICE_BLK_FD) {
507 : 0 : prof->flags = rslt->flags_fd;
508 : 0 : prof->flags_msk = ICE_KEYBUILD_FLAG_MASK_DEFAULT_FD;
509 [ # # ]: 0 : } else if (blk == ICE_BLK_RSS) {
510 : 0 : prof->flags = rslt->flags_rss;
511 : 0 : prof->flags_msk = ICE_KEYBUILD_FLAG_MASK_DEFAULT_RSS;
512 : : } else {
513 : : return ICE_ERR_PARAM;
514 : : }
515 : :
516 [ # # ]: 0 : for (off = 0; off < buf_len - 1; off++) {
517 [ # # # # ]: 0 : if (msk_buf[off] == 0 && msk_buf[off + 1] == 0)
518 : 0 : continue;
519 [ # # ]: 0 : if (!_nearest_proto_id(rslt, off, &proto_id, &proto_off))
520 : 0 : continue;
521 [ # # ]: 0 : if (prof->fv_num >= 32)
522 : : return ICE_ERR_PARAM;
523 : :
524 : 0 : prof->fv[prof->fv_num].proto_id = proto_id;
525 : 0 : prof->fv[prof->fv_num].offset = proto_off;
526 : 0 : prof->fv[prof->fv_num].spec = *(const u16 *)&pkt_buf[off];
527 : 0 : prof->fv[prof->fv_num].msk = *(const u16 *)&msk_buf[off];
528 : 0 : prof->fv_num++;
529 : : }
530 : :
531 : : return ICE_SUCCESS;
532 : : }
533 : :
534 : : /**
535 : : * ice_parser_profile_dump - dump an FXP profile info
536 : : * @hw: pointer to the hardware structure
537 : : * @prof: profile info to dump
538 : : */
539 : 0 : void ice_parser_profile_dump(struct ice_hw *hw, struct ice_parser_profile *prof)
540 : : {
541 : : u16 i;
542 : :
543 [ # # ]: 0 : ice_info(hw, "ptypes:\n");
544 [ # # ]: 0 : for (i = 0; i < ICE_FLOW_PTYPE_MAX; i++)
545 [ # # ]: 0 : if (ice_is_bit_set(prof->ptypes, i))
546 [ # # ]: 0 : ice_info(hw, "\t%d\n", i);
547 : :
548 [ # # ]: 0 : for (i = 0; i < prof->fv_num; i++)
549 [ # # ]: 0 : ice_info(hw, "proto = %d, offset = %d spec = 0x%04x, mask = 0x%04x\n",
550 : : prof->fv[i].proto_id, prof->fv[i].offset,
551 : : prof->fv[i].spec, prof->fv[i].msk);
552 : :
553 [ # # ]: 0 : ice_info(hw, "flags = 0x%04x\n", prof->flags);
554 [ # # ]: 0 : ice_info(hw, "flags_msk = 0x%04x\n", prof->flags_msk);
555 : 0 : }
556 : :
557 : : /**
558 : : * ice_check_ddp_support_proto_id - check DDP package file support protocol ID
559 : : * @hw: pointer to the HW struct
560 : : * @proto_id: protocol ID value
561 : : *
562 : : * This function maintains the compatibility of the program process by checking
563 : : * whether the current DDP file supports the required protocol ID.
564 : : */
565 : 0 : bool ice_check_ddp_support_proto_id(struct ice_hw *hw,
566 : : enum ice_prot_id proto_id)
567 : : {
568 : : struct ice_proto_grp_item *proto_grp_table;
569 : : struct ice_proto_grp_item *proto_grp;
570 : : bool exist = false;
571 : : u16 idx, i;
572 : :
573 : 0 : proto_grp_table = ice_proto_grp_table_get(hw);
574 [ # # ]: 0 : if (!proto_grp_table)
575 : : return false;
576 : :
577 [ # # ]: 0 : for (idx = 0; idx < ICE_PROTO_GRP_TABLE_SIZE; idx++) {
578 : 0 : proto_grp = &proto_grp_table[idx];
579 [ # # ]: 0 : for (i = 0; i < ICE_PROTO_COUNT_PER_GRP; i++) {
580 [ # # ]: 0 : if (proto_grp->po[i].proto_id == proto_id) {
581 : : exist = true;
582 : 0 : goto exit;
583 : : }
584 : : }
585 : : }
586 : :
587 : 0 : exit:
588 : 0 : ice_free(hw, proto_grp_table);
589 : 0 : return exist;
590 : : }
|