net/ice/base: reduce profile to recip info get from firmware

Only need to get profile_to_recip info from firmware for
profiles used by switch, no need for other free profile
in order that we can reduce the time consumed when
download a switch rule.

Signed-off-by: Wei Zhao <wei.zhao1@intel.com>
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Acked-by: Qiming Yang <qiming.yang@intel.com>
This commit is contained in:
Qi Zhang 2020-08-26 18:39:47 +08:00 committed by Ferruh Yigit
parent 24b38f1ea5
commit af73360557
3 changed files with 85 additions and 33 deletions

View File

@ -1344,6 +1344,88 @@ fw_ddp_compat_free_alloc:
return status;
}
/**
* ice_sw_fv_handler
* @sect_type: section type
* @section: pointer to section
* @index: index of the field vector entry to be returned
* @offset: ptr to variable that receives the offset in the field vector table
*
* This is a callback function that can be passed to ice_pkg_enum_entry.
* This function treats the given section as of type ice_sw_fv_section and
* enumerates offset field. "offset" is an index into the field vector table.
*/
static void *
ice_sw_fv_handler(u32 sect_type, void *section, u32 index, u32 *offset)
{
struct ice_sw_fv_section *fv_section =
(struct ice_sw_fv_section *)section;
if (!section || sect_type != ICE_SID_FLD_VEC_SW)
return NULL;
if (index >= LE16_TO_CPU(fv_section->count))
return NULL;
if (offset)
/* "index" passed in to this function is relative to a given
* 4k block. To get to the true index into the field vector
* table need to add the relative index to the base_offset
* field of this section
*/
*offset = LE16_TO_CPU(fv_section->base_offset) + index;
return fv_section->fv + index;
}
/**
* ice_get_prof_index_max - get the max profile index for used profile
* @hw: pointer to the HW struct
*
* Calling this function will get the max profile index for used profile
* and store the index number in struct ice_switch_info *switch_info
* in hw for following use.
*/
static int ice_get_prof_index_max(struct ice_hw *hw)
{
u16 prof_index = 0, j, max_prof_index = 0;
struct ice_pkg_enum state;
struct ice_seg *ice_seg;
bool flag = false;
struct ice_fv *fv;
u32 offset;
ice_memset(&state, 0, sizeof(state), ICE_NONDMA_MEM);
if (!hw->seg)
return ICE_ERR_PARAM;
ice_seg = hw->seg;
do {
fv = (struct ice_fv *)
ice_pkg_enum_entry(ice_seg, &state, ICE_SID_FLD_VEC_SW,
&offset, ice_sw_fv_handler);
if (!fv)
break;
ice_seg = NULL;
/* in the profile that not be used, the prot_id is set to 0xff
* and the off is set to 0x1ff for all the field vectors.
*/
for (j = 0; j < hw->blk[ICE_BLK_SW].es.fvw; j++)
if (fv->ew[j].prot_id != ICE_PROT_INVALID ||
fv->ew[j].off != ICE_FV_OFFSET_INVAL)
flag = true;
if (flag && prof_index > max_prof_index)
max_prof_index = prof_index;
prof_index++;
flag = false;
} while (fv);
hw->switch_info->max_used_prof_index = max_prof_index;
return ICE_SUCCESS;
}
/**
* ice_init_pkg - initialize/download package
* @hw: pointer to the hardware structure
@ -1423,6 +1505,7 @@ enum ice_status ice_init_pkg(struct ice_hw *hw, u8 *buf, u32 len)
*/
ice_init_pkg_regs(hw);
ice_fill_blk_tbls(hw);
ice_get_prof_index_max(hw);
} else {
ice_debug(hw, ICE_DBG_INIT, "package load failed, %d\n",
status);
@ -1499,38 +1582,6 @@ static struct ice_buf_build *ice_pkg_buf_alloc(struct ice_hw *hw)
return bld;
}
/**
* ice_sw_fv_handler
* @sect_type: section type
* @section: pointer to section
* @index: index of the field vector entry to be returned
* @offset: ptr to variable that receives the offset in the field vector table
*
* This is a callback function that can be passed to ice_pkg_enum_entry.
* This function treats the given section as of type ice_sw_fv_section and
* enumerates offset field. "offset" is an index into the field vector
* vector table.
*/
static void *
ice_sw_fv_handler(u32 sect_type, void *section, u32 index, u32 *offset)
{
struct ice_sw_fv_section *fv_section =
(struct ice_sw_fv_section *)section;
if (!section || sect_type != ICE_SID_FLD_VEC_SW)
return NULL;
if (index >= LE16_TO_CPU(fv_section->count))
return NULL;
if (offset)
/* "index" passed in to this function is relative to a given
* 4k block. To get to the true index into the field vector
* table need to add the relative index to the base_offset
* field of this section
*/
*offset = LE16_TO_CPU(fv_section->base_offset) + index;
return fv_section->fv + index;
}
/**
* ice_get_sw_prof_type - determine switch profile type
* @hw: pointer to the HW structure

View File

@ -1591,7 +1591,7 @@ static void ice_get_recp_to_prof_map(struct ice_hw *hw)
ice_declare_bitmap(r_bitmap, ICE_MAX_NUM_RECIPES);
u16 i;
for (i = 0; i < ICE_MAX_NUM_PROFILES; i++) {
for (i = 0; i < hw->switch_info->max_used_prof_index + 1; i++) {
u16 j;
ice_zero_bitmap(profile_to_recipe[i], ICE_MAX_NUM_RECIPES);

View File

@ -792,6 +792,7 @@ struct ice_switch_info {
struct LIST_HEAD_TYPE vsi_list_map_head;
struct ice_sw_recipe *recp_list;
u16 prof_res_bm_init;
u16 max_used_prof_index;
ice_declare_bitmap(prof_res_bm[ICE_MAX_NUM_PROFILES], ICE_MAX_FV_WORDS);
};