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_FLG_RD_TABLE_SIZE 64 9 : : 10 : : /** 11 : : * ice_flg_rd_dump - dump a flag redirect item info 12 : : * @hw: pointer to the hardware structure 13 : : * @item: flag redirect item to dump 14 : : */ 15 : 0 : void ice_flg_rd_dump(struct ice_hw *hw, struct ice_flg_rd_item *item) 16 : : { 17 [ # # ]: 0 : ice_info(hw, "index = %d\n", item->idx); 18 [ # # ]: 0 : ice_info(hw, "expose = %d\n", item->expose); 19 [ # # ]: 0 : ice_info(hw, "intr_flg_id = %d\n", item->intr_flg_id); 20 : 0 : } 21 : : 22 : : /** The function parses a 8 bits Flag Redirect Table entry with below format: 23 : : * BIT 0: Expose (rdi->expose) 24 : : * BIT 1-6: Internal Flag ID (rdi->intr_flg_id) 25 : : * BIT 7: reserved 26 : : */ 27 : 0 : static void _flg_rd_parse_item(struct ice_hw *hw, u16 idx, void *item, 28 : : void *data, int size) 29 : : { 30 : : struct ice_flg_rd_item *rdi = (struct ice_flg_rd_item *)item; 31 : 0 : u8 d8 = *(u8 *)data; 32 : : 33 : 0 : rdi->idx = idx; 34 : 0 : rdi->expose = (d8 & 0x1) != 0; 35 : 0 : rdi->intr_flg_id = (u8)((d8 >> 1) & 0x3f); 36 : : 37 [ # # ]: 0 : if (hw->debug_mask & ICE_DBG_PARSER) 38 : 0 : ice_flg_rd_dump(hw, rdi); 39 : 0 : } 40 : : 41 : : /** 42 : : * ice_flg_rd_table_get - create a flag redirect table 43 : : * @hw: pointer to the hardware structure 44 : : */ 45 : 0 : struct ice_flg_rd_item *ice_flg_rd_table_get(struct ice_hw *hw) 46 : : { 47 : 0 : return (struct ice_flg_rd_item *) 48 : 0 : ice_parser_create_table(hw, ICE_SID_RXPARSER_FLAG_REDIR, 49 : : sizeof(struct ice_flg_rd_item), 50 : : ICE_FLG_RD_TABLE_SIZE, 51 : : ice_parser_sect_item_get, 52 : : _flg_rd_parse_item, false); 53 : : } 54 : : 55 : : /** 56 : : * ice_flg_redirect - redirect a parser flag to packet flag 57 : : * @table: flag redirect table 58 : : * @psr_flg: parser flag to redirect 59 : : */ 60 : 0 : u64 ice_flg_redirect(struct ice_flg_rd_item *table, u64 psr_flg) 61 : : { 62 : : u64 flg = 0; 63 : : int i; 64 : : 65 [ # # ]: 0 : for (i = 0; i < 64; i++) { 66 : 0 : struct ice_flg_rd_item *item = &table[i]; 67 : : 68 [ # # ]: 0 : if (!item->expose) 69 : 0 : continue; 70 : : 71 [ # # ]: 0 : if (psr_flg & (1ul << item->intr_flg_id)) 72 : 0 : flg |= (1ul << i); 73 : : } 74 : : 75 : 0 : return flg; 76 : : }