> -----Original Message-----
> From: Zhang, Qi Z <qi.z.zh...@intel.com>
> Sent: Friday, September 17, 2021 10:43 PM
> To: Yang, Qiming <qiming.y...@intel.com>
> Cc: Guo, Junfeng <junfeng....@intel.com>; dev@dpdk.org; Zhang, Qi Z
> <qi.z.zh...@intel.com>
> Subject: [PATCH v2 02/20] net/ice/base: init imem table for parser
> 
> Parse DDP section ICE_SID_RXPARSER_IMEM into an array of struct
> ice_imem_item.
> 
> Signed-off-by: Qi Zhang <qi.z.zh...@intel.com>
> ---


.....

> +/**
> + * ice_parser_sect_item_get - parse a item from a section
> + * @sect_type: section type
> + * @section: section object
> + * @index: index of the item to get
> + * @offset: dummy as prototype of ice_pkg_enum_entry's last parameter
> +*/ void *ice_parser_sect_item_get(u32 sect_type, void *section,
> +                            u32 index, u32 *offset)
> +{
> +     struct ice_pkg_sect_hdr *hdr;
> +     int data_off = ICE_SEC_DATA_OFFSET;
> +     int size;
> +
> +     if (!section)
> +             return NULL;
> +
> +     switch (sect_type) {
> +     case ICE_SID_RXPARSER_IMEM:
> +             size = ICE_SID_RXPARSER_IMEM_ENTRY_SIZE;
> +             break;
> +     default:
> +             return NULL;
> +     }
> +
> +     hdr = (struct ice_pkg_sect_hdr *)section;
> +     if (index >= LE16_TO_CPU(hdr->count))
> +             return NULL;
> +
> +     return (void *)((u64)section + data_off + index * size); }

Compile warning for 32bit, replace u64 with uintptr_t 

> +
> +/**
> + * ice_parser_create_table - create a 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
> + * @item_get: the function will be parsed to ice_pkg_enum_entry
> + * @parser_item: the function to parse the item  */ void
> +*ice_parser_create_table(struct ice_hw *hw, u32 sect_type,
> +                           u32 item_size, u32 length,
> +                           void *(*item_get)(u32 sect_type, void *section,
> +                                             u32 index, u32 *offset),
> +                           void (*parse_item)(struct ice_hw *hw, u16 idx,
> +                                              void *item, void *data,
> +                                              int size))
> +{
> +     struct ice_seg *seg = hw->seg;
> +     struct ice_pkg_enum state;
> +     u16 idx = 0;
> +     void *table;
> +     void *data;
> +
> +     if (!seg)
> +             return NULL;
> +
> +     table = ice_malloc(hw, item_size * length);
> +     if (!table) {
> +             ice_debug(hw, ICE_DBG_PARSER, "failed to allocate memory for
> table type %d.\n",
> +                       sect_type);
> +             return NULL;
> +     }
> +
> +     ice_memset(&state, 0, sizeof(state), ICE_NONDMA_MEM);
> +     do {
> +             data = ice_pkg_enum_entry(seg, &state, sect_type, NULL,
> +                                       item_get);
> +             seg = NULL;
> +             if (data) {
> +                     struct ice_pkg_sect_hdr *hdr =
> +                             (struct ice_pkg_sect_hdr *)state.sect;
> +
> +                     idx = hdr->offset + state.entry_idx;
> +                     parse_item(hw, idx,
> +                                (void *)((u64)table + idx * item_size),

Same issue as above.

Will fix during apply.


Reply via email to