Commit 1f9c7840 authored by Anirudh Venkataramanan's avatar Anirudh Venkataramanan Committed by Jeff Kirsher

ice: Refactor a few Tx scheduler functions

The following functions were refactored to call a new common function,
ice_aqc_send_sched_elem_cmd():

- ice_aq_add_sched_elems()
- ice_aq_delete_sched_elems()
- ice_aq_move_sched_elems()
- ice_aq_query_sched_elems()
- ice_aq_cfg_sched_elems()
- ice_aq_suspend_sched_elems()
- ice_aq_resume_sched_elems()
Signed-off-by: default avatarGreg Priest <greg.priest@intel.com>
Signed-off-by: default avatarAnirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Tested-by: default avatarAndrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent 3d505147
...@@ -657,8 +657,13 @@ struct ice_aqc_get_topo { ...@@ -657,8 +657,13 @@ struct ice_aqc_get_topo {
/* Update TSE (indirect 0x0403) /* Update TSE (indirect 0x0403)
* Get TSE (indirect 0x0404) * Get TSE (indirect 0x0404)
* Add TSE (indirect 0x0401)
* Delete TSE (indirect 0x040F)
* Move TSE (indirect 0x0408)
* Suspend Nodes (indirect 0x0409)
* Resume Nodes (indirect 0x040A)
*/ */
struct ice_aqc_get_cfg_elem { struct ice_aqc_sched_elem_cmd {
__le16 num_elem_req; /* Used by commands */ __le16 num_elem_req; /* Used by commands */
__le16 num_elem_resp; /* Used by responses */ __le16 num_elem_resp; /* Used by responses */
__le32 reserved; __le32 reserved;
...@@ -674,18 +679,6 @@ struct ice_aqc_suspend_resume_elem { ...@@ -674,18 +679,6 @@ struct ice_aqc_suspend_resume_elem {
__le32 teid[1]; __le32 teid[1];
}; };
/* Add TSE (indirect 0x0401)
* Delete TSE (indirect 0x040F)
* Move TSE (indirect 0x0408)
*/
struct ice_aqc_add_move_delete_elem {
__le16 num_grps_req;
__le16 num_grps_updated;
__le32 reserved;
__le32 addr_high;
__le32 addr_low;
};
struct ice_aqc_elem_info_bw { struct ice_aqc_elem_info_bw {
__le16 bw_profile_idx; __le16 bw_profile_idx;
__le16 bw_alloc; __le16 bw_alloc;
...@@ -1344,9 +1337,8 @@ struct ice_aq_desc { ...@@ -1344,9 +1337,8 @@ struct ice_aq_desc {
struct ice_aqc_get_sw_cfg get_sw_conf; struct ice_aqc_get_sw_cfg get_sw_conf;
struct ice_aqc_sw_rules sw_rules; struct ice_aqc_sw_rules sw_rules;
struct ice_aqc_get_topo get_topo; struct ice_aqc_get_topo get_topo;
struct ice_aqc_get_cfg_elem get_update_elem; struct ice_aqc_sched_elem_cmd sched_elem_cmd;
struct ice_aqc_query_txsched_res query_sched_res; struct ice_aqc_query_txsched_res query_sched_res;
struct ice_aqc_add_move_delete_elem add_move_delete_elem;
struct ice_aqc_nvm nvm; struct ice_aqc_nvm nvm;
struct ice_aqc_pf_vf_msg virt; struct ice_aqc_pf_vf_msg virt;
struct ice_aqc_get_set_rss_lut get_set_rss_lut; struct ice_aqc_get_set_rss_lut get_set_rss_lut;
......
...@@ -85,36 +85,58 @@ ice_sched_find_node_by_teid(struct ice_sched_node *start_node, u32 teid) ...@@ -85,36 +85,58 @@ ice_sched_find_node_by_teid(struct ice_sched_node *start_node, u32 teid)
} }
/** /**
* ice_aq_query_sched_elems - query scheduler elements * ice_aqc_send_sched_elem_cmd - send scheduling elements cmd
* @hw: pointer to the hw struct * @hw: pointer to the hw struct
* @elems_req: number of elements to query * @cmd_opc: cmd opcode
* @elems_req: number of elements to request
* @buf: pointer to buffer * @buf: pointer to buffer
* @buf_size: buffer size in bytes * @buf_size: buffer size in bytes
* @elems_ret: returns total number of elements returned * @elems_resp: returns total number of elements response
* @cd: pointer to command details structure or NULL * @cd: pointer to command details structure or NULL
* *
* Query scheduling elements (0x0404) * This function sends a scheduling elements cmd (cmd_opc)
*/ */
static enum ice_status static enum ice_status
ice_aq_query_sched_elems(struct ice_hw *hw, u16 elems_req, ice_aqc_send_sched_elem_cmd(struct ice_hw *hw, enum ice_adminq_opc cmd_opc,
struct ice_aqc_get_elem *buf, u16 buf_size, u16 elems_req, void *buf, u16 buf_size,
u16 *elems_ret, struct ice_sq_cd *cd) u16 *elems_resp, struct ice_sq_cd *cd)
{ {
struct ice_aqc_get_cfg_elem *cmd; struct ice_aqc_sched_elem_cmd *cmd;
struct ice_aq_desc desc; struct ice_aq_desc desc;
enum ice_status status; enum ice_status status;
cmd = &desc.params.get_update_elem; cmd = &desc.params.sched_elem_cmd;
ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_get_sched_elems); ice_fill_dflt_direct_cmd_desc(&desc, cmd_opc);
cmd->num_elem_req = cpu_to_le16(elems_req); cmd->num_elem_req = cpu_to_le16(elems_req);
desc.flags |= cpu_to_le16(ICE_AQ_FLAG_RD); desc.flags |= cpu_to_le16(ICE_AQ_FLAG_RD);
status = ice_aq_send_cmd(hw, &desc, buf, buf_size, cd); status = ice_aq_send_cmd(hw, &desc, buf, buf_size, cd);
if (!status && elems_ret) if (!status && elems_resp)
*elems_ret = le16_to_cpu(cmd->num_elem_resp); *elems_resp = le16_to_cpu(cmd->num_elem_resp);
return status; return status;
} }
/**
* ice_aq_query_sched_elems - query scheduler elements
* @hw: pointer to the hw struct
* @elems_req: number of elements to query
* @buf: pointer to buffer
* @buf_size: buffer size in bytes
* @elems_ret: returns total number of elements returned
* @cd: pointer to command details structure or NULL
*
* Query scheduling elements (0x0404)
*/
static enum ice_status
ice_aq_query_sched_elems(struct ice_hw *hw, u16 elems_req,
struct ice_aqc_get_elem *buf, u16 buf_size,
u16 *elems_ret, struct ice_sq_cd *cd)
{
return ice_aqc_send_sched_elem_cmd(hw, ice_aqc_opc_get_sched_elems,
elems_req, (void *)buf, buf_size,
elems_ret, cd);
}
/** /**
* ice_sched_query_elem - query element information from hw * ice_sched_query_elem - query element information from hw
* @hw: pointer to the hw struct * @hw: pointer to the hw struct
...@@ -218,20 +240,9 @@ ice_aq_delete_sched_elems(struct ice_hw *hw, u16 grps_req, ...@@ -218,20 +240,9 @@ ice_aq_delete_sched_elems(struct ice_hw *hw, u16 grps_req,
struct ice_aqc_delete_elem *buf, u16 buf_size, struct ice_aqc_delete_elem *buf, u16 buf_size,
u16 *grps_del, struct ice_sq_cd *cd) u16 *grps_del, struct ice_sq_cd *cd)
{ {
struct ice_aqc_add_move_delete_elem *cmd; return ice_aqc_send_sched_elem_cmd(hw, ice_aqc_opc_delete_sched_elems,
struct ice_aq_desc desc; grps_req, (void *)buf, buf_size,
enum ice_status status; grps_del, cd);
cmd = &desc.params.add_move_delete_elem;
ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_delete_sched_elems);
desc.flags |= cpu_to_le16(ICE_AQ_FLAG_RD);
cmd->num_grps_req = cpu_to_le16(grps_req);
status = ice_aq_send_cmd(hw, &desc, buf, buf_size, cd);
if (!status && grps_del)
*grps_del = le16_to_cpu(cmd->num_grps_updated);
return status;
} }
/** /**
...@@ -442,52 +453,9 @@ ice_aq_add_sched_elems(struct ice_hw *hw, u16 grps_req, ...@@ -442,52 +453,9 @@ ice_aq_add_sched_elems(struct ice_hw *hw, u16 grps_req,
struct ice_aqc_add_elem *buf, u16 buf_size, struct ice_aqc_add_elem *buf, u16 buf_size,
u16 *grps_added, struct ice_sq_cd *cd) u16 *grps_added, struct ice_sq_cd *cd)
{ {
struct ice_aqc_add_move_delete_elem *cmd; return ice_aqc_send_sched_elem_cmd(hw, ice_aqc_opc_add_sched_elems,
struct ice_aq_desc desc; grps_req, (void *)buf, buf_size,
enum ice_status status; grps_added, cd);
cmd = &desc.params.add_move_delete_elem;
ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_add_sched_elems);
desc.flags |= cpu_to_le16(ICE_AQ_FLAG_RD);
cmd->num_grps_req = cpu_to_le16(grps_req);
status = ice_aq_send_cmd(hw, &desc, buf, buf_size, cd);
if (!status && grps_added)
*grps_added = le16_to_cpu(cmd->num_grps_updated);
return status;
}
/**
* ice_suspend_resume_elems - suspend/resume scheduler elements
* @hw: pointer to the hw struct
* @elems_req: number of elements to suspend
* @buf: pointer to buffer
* @buf_size: buffer size in bytes
* @elems_ret: returns total number of elements suspended
* @cd: pointer to command details structure or NULL
* @cmd_code: command code for suspend or resume
*
* suspend/resume scheduler elements
*/
static enum ice_status
ice_suspend_resume_elems(struct ice_hw *hw, u16 elems_req,
struct ice_aqc_suspend_resume_elem *buf, u16 buf_size,
u16 *elems_ret, struct ice_sq_cd *cd,
enum ice_adminq_opc cmd_code)
{
struct ice_aqc_get_cfg_elem *cmd;
struct ice_aq_desc desc;
enum ice_status status;
cmd = &desc.params.get_update_elem;
ice_fill_dflt_direct_cmd_desc(&desc, cmd_code);
cmd->num_elem_req = cpu_to_le16(elems_req);
desc.flags |= cpu_to_le16(ICE_AQ_FLAG_RD);
status = ice_aq_send_cmd(hw, &desc, buf, buf_size, cd);
if (!status && elems_ret)
*elems_ret = le16_to_cpu(cmd->num_elem_resp);
return status;
} }
/** /**
...@@ -506,8 +474,9 @@ ice_aq_suspend_sched_elems(struct ice_hw *hw, u16 elems_req, ...@@ -506,8 +474,9 @@ ice_aq_suspend_sched_elems(struct ice_hw *hw, u16 elems_req,
struct ice_aqc_suspend_resume_elem *buf, struct ice_aqc_suspend_resume_elem *buf,
u16 buf_size, u16 *elems_ret, struct ice_sq_cd *cd) u16 buf_size, u16 *elems_ret, struct ice_sq_cd *cd)
{ {
return ice_suspend_resume_elems(hw, elems_req, buf, buf_size, elems_ret, return ice_aqc_send_sched_elem_cmd(hw, ice_aqc_opc_suspend_sched_elems,
cd, ice_aqc_opc_suspend_sched_elems); elems_req, (void *)buf, buf_size,
elems_ret, cd);
} }
/** /**
...@@ -526,8 +495,9 @@ ice_aq_resume_sched_elems(struct ice_hw *hw, u16 elems_req, ...@@ -526,8 +495,9 @@ ice_aq_resume_sched_elems(struct ice_hw *hw, u16 elems_req,
struct ice_aqc_suspend_resume_elem *buf, struct ice_aqc_suspend_resume_elem *buf,
u16 buf_size, u16 *elems_ret, struct ice_sq_cd *cd) u16 buf_size, u16 *elems_ret, struct ice_sq_cd *cd)
{ {
return ice_suspend_resume_elems(hw, elems_req, buf, buf_size, elems_ret, return ice_aqc_send_sched_elem_cmd(hw, ice_aqc_opc_resume_sched_elems,
cd, ice_aqc_opc_resume_sched_elems); elems_req, (void *)buf, buf_size,
elems_ret, cd);
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment