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_PTYPE_MK_TCAM_TABLE_SIZE 1024
9 : :
10 : : /**
11 : : * ice_ptype_mk_tcam_dump - dump an ptype marker tcam info_
12 : : * @hw: pointer to the hardware structure
13 : : * @item: ptype marker tcam to dump
14 : : */
15 : 0 : void ice_ptype_mk_tcam_dump(struct ice_hw *hw,
16 : : struct ice_ptype_mk_tcam_item *item)
17 : : {
18 : : int i;
19 : :
20 [ # # ]: 0 : ice_info(hw, "address = %d\n", item->address);
21 [ # # ]: 0 : ice_info(hw, "ptype = %d\n", item->ptype);
22 [ # # ]: 0 : ice_info(hw, "key :");
23 [ # # ]: 0 : for (i = 0; i < 10; i++)
24 [ # # ]: 0 : ice_info(hw, "%02x ", item->key[i]);
25 [ # # ]: 0 : ice_info(hw, "\n");
26 [ # # ]: 0 : ice_info(hw, "key_inv:");
27 [ # # ]: 0 : for (i = 0; i < 10; i++)
28 [ # # ]: 0 : ice_info(hw, "%02x ", item->key_inv[i]);
29 [ # # ]: 0 : ice_info(hw, "\n");
30 : 0 : }
31 : :
32 : 0 : static void _parse_ptype_mk_tcam_item(struct ice_hw *hw, u16 idx, void *item,
33 : : void *data, int size)
34 : : {
35 : 0 : ice_parse_item_dflt(hw, idx, item, data, size);
36 : :
37 [ # # ]: 0 : if (hw->debug_mask & ICE_DBG_PARSER)
38 : 0 : ice_ptype_mk_tcam_dump(hw,
39 : : (struct ice_ptype_mk_tcam_item *)item);
40 : 0 : }
41 : :
42 : : /**
43 : : * ice_ptype_mk_tcam_table_get - create a ptype marker tcam table
44 : : * @hw: pointer to the hardware structure
45 : : */
46 : 0 : struct ice_ptype_mk_tcam_item *ice_ptype_mk_tcam_table_get(struct ice_hw *hw)
47 : : {
48 : 0 : return (struct ice_ptype_mk_tcam_item *)
49 : 0 : ice_parser_create_table(hw, ICE_SID_RXPARSER_MARKER_PTYPE,
50 : : sizeof(struct ice_ptype_mk_tcam_item),
51 : : ICE_PTYPE_MK_TCAM_TABLE_SIZE,
52 : : ice_parser_sect_item_get,
53 : : _parse_ptype_mk_tcam_item, true);
54 : : }
55 : :
56 : : /**
57 : : * ice_ptype_mk_tcam_match - match a pattern on a ptype marker tcam table
58 : : * @table: ptype marker tcam table to search
59 : : * @pat: pattern to match
60 : : * @len: length of the pattern
61 : : */
62 : : struct ice_ptype_mk_tcam_item *
63 : 0 : ice_ptype_mk_tcam_match(struct ice_ptype_mk_tcam_item *table,
64 : : u8 *pat, int len)
65 : : {
66 : : int i;
67 : :
68 [ # # ]: 0 : for (i = 0; i < ICE_PTYPE_MK_TCAM_TABLE_SIZE; i++) {
69 : 0 : struct ice_ptype_mk_tcam_item *item = &table[i];
70 : :
71 [ # # ]: 0 : if (ice_ternary_match(item->key, item->key_inv, pat, len))
72 : 0 : return item;
73 : : }
74 : :
75 : : return NULL;
76 : : }
|