On Wed, Jul 10, 2024 at 02:40:04PM -0600, Ahmed Zaki wrote: > From: Junfeng Guo <junfeng....@intel.com> > > Parse the following DDP sections: > - ICE_SID_RXPARSER_IMEM into an array of struct ice_imem_item > - ICE_SID_RXPARSER_METADATA_INIT into an array of struct ice_metainit_item > - ICE_SID_RXPARSER_CAM or ICE_SID_RXPARSER_PG_SPILL into an array of > struct ice_pg_cam_item > - ICE_SID_RXPARSER_NOMATCH_CAM or ICE_SID_RXPARSER_NOMATCH_SPILL into an > array of struct ice_pg_nm_cam_item > - ICE_SID_RXPARSER_CAM into an array of ice_bst_tcam_item > - ICE_SID_LBL_RXPARSER_TMEM into an array of ice_lbl_item > - ICE_SID_RXPARSER_MARKER_PTYPE into an array of ice_ptype_mk_tcam_item > - ICE_SID_RXPARSER_MARKER_GRP into an array of ice_mk_grp_item > - ICE_SID_RXPARSER_PROTO_GRP into an array of ice_proto_grp_item > - ICE_SID_RXPARSER_FLAG_REDIR into an array of ice_flg_rd_item > - ICE_SID_XLT_KEY_BUILDER_SW, ICE_SID_XLT_KEY_BUILDER_ACL, > ICE_SID_XLT_KEY_BUILDER_FD and ICE_SID_XLT_KEY_BUILDER_RSS into > struct ice_xlt_kb > > Reviewed-by: Marcin Szycik <marcin.szy...@linux.intel.com> > Signed-off-by: Qi Zhang <qi.z.zh...@intel.com> > Signed-off-by: Junfeng Guo <junfeng....@intel.com> > Co-developed-by: Ahmed Zaki <ahmed.z...@intel.com> > Signed-off-by: Ahmed Zaki <ahmed.z...@intel.com>
Hi Ahmed, Junfeng, all, Some minor feedback from my side. ... > diff --git a/drivers/net/ethernet/intel/ice/ice_parser.c > b/drivers/net/ethernet/intel/ice/ice_parser.c ... > +/** > + * ice_parser_create_table - create an item table from a section > + * @hw: pointer to the hardware structure > + * @sect_type: section type > + * @item_size: item size in byte > + * @length: number of items in the table to create > + * @parse_item: the function to parse the item > + * @no_offset: ignore header offset, calculate index from 0 > + * > + * Return: a pointer to the allocated table or ERR_PTR. > + */ > +static > +void *ice_parser_create_table(struct ice_hw *hw, u32 sect_type, > + u32 item_size, u32 length, > + void (*parse_item)(struct ice_hw *hw, u16 idx, > + void *item, void *data, > + int size), > + bool no_offset) > +{ > + struct ice_pkg_enum state = {}; > + struct ice_seg *seg = hw->seg; > + void *table, *data, *item; > + u16 idx = U16_MAX; > + > + if (!seg) > + return ERR_PTR(-EINVAL); > + > + table = kzalloc(item_size * length, GFP_KERNEL); > + if (!table) > + return ERR_PTR(-ENOMEM); > + > + do { > + data = ice_pkg_enum_entry(seg, &state, sect_type, NULL, > + ice_parser_sect_item_get); > + seg = NULL; > + if (data) { > + struct ice_pkg_sect_hdr *hdr = > + (struct ice_pkg_sect_hdr *)state.sect; nit: As the type of state.sect is void * I don't think there is a need to explicitly cast it to another type of pointer. struct ice_pkg_sect_hdr *hdr = state.sect; > + > + if (no_offset) > + idx++; > + else > + idx = le16_to_cpu(hdr->offset) + > + state.entry_idx; > + > + item = (void *)((uintptr_t)table + idx * item_size); > + parse_item(hw, idx, item, data, item_size); > + } > + } while (data); > + > + return table; > +} ... > +/** > + * ice_imem_parse_item - parse 384 bits of IMEM entry > + * @hw: pointer to the hardware structure > + * @idx: index of IMEM entry > + * @item: item of IMEM entry > + * @data: IMEM entry data to be parsed > + * @size: size of IMEM entry > + */ > +static void ice_imem_parse_item(struct ice_hw *hw, u16 idx, void *item, > + void *data, int __maybe_unused size) > +{ > + struct ice_imem_item *ii = item; > + u8 *buf = (u8 *)data; Similarly, I don't think there is a need to explicitly cast here: u8 *buf = data; > + > + ii->idx = idx; > + > + ice_imem_bm_init(&ii->b_m, *(u8 *)buf); > + ice_imem_bkb_init(&ii->b_kb, > + *((u16 *)(&buf[ICE_IMEM_BKB_IDD])) >> > + ICE_IMEM_BKB_OFF); > + > + ii->pg_prio = FIELD_GET(ICE_IMEM_PGP, *(u16 *)buf); > + > + ice_imem_npkb_init(&ii->np_kb, > + *((u32 *)(&buf[ICE_IMEM_NPKB_IDD])) >> > + ICE_IMEM_NPKB_OFF); > + ice_imem_pgkb_init(&ii->pg_kb, > + *((u64 *)(&buf[ICE_IMEM_PGKB_IDD])) >> > + ICE_IMEM_PGKB_OFF); > + > + ice_imem_alu_init(&ii->alu0, > + &buf[ICE_IMEM_ALU0_IDD], > + ICE_IMEM_ALU0_OFF); > + ice_imem_alu_init(&ii->alu1, > + &buf[ICE_IMEM_ALU1_IDD], > + ICE_IMEM_ALU1_OFF); > + ice_imem_alu_init(&ii->alu2, > + &buf[ICE_IMEM_ALU2_IDD], > + ICE_IMEM_ALU2_OFF); > +} > + > +/** > + * ice_imem_table_get - create an imem table > + * @hw: pointer to the hardware structure > + * > + * Return: a pointer to the allocated IMEM table. > + */ > +static struct ice_imem_item *ice_imem_table_get(struct ice_hw *hw) > +{ > + return (struct ice_imem_item *) > + ice_parser_create_table(hw, ICE_SID_RXPARSER_IMEM, > + sizeof(struct ice_imem_item), > + ICE_IMEM_TABLE_SIZE, > + ice_imem_parse_item, false); > +} Or here. And, likewise, for other similar calls to ice_parser_create_table(). ...