Skip to content

Commit

Permalink
ice: make use of DEFINE_FLEX() for struct ice_aqc_dis_txq_item
Browse files Browse the repository at this point in the history
Use DEFINE_FLEX() macro for 1-elem flex array use case
of struct ice_aqc_dis_txq_item.

Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Link: https://lore.kernel.org/r/20230912115937.1645707-7-przemyslaw.kitszel@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Przemek Kitszel authored and Jakub Kicinski committed Oct 3, 2023
1 parent 43bba3b commit 11dee3d
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions drivers/net/ethernet/intel/ice/ice_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -4790,11 +4790,11 @@ ice_dis_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u8 num_queues,
enum ice_disq_rst_src rst_src, u16 vmvf_num,
struct ice_sq_cd *cd)
{
struct ice_aqc_dis_txq_item *qg_list;
DEFINE_FLEX(struct ice_aqc_dis_txq_item, qg_list, q_id, 1);
u16 i, buf_size = __struct_size(qg_list);
struct ice_q_ctx *q_ctx;
int status = -ENOENT;
struct ice_hw *hw;
u16 i, buf_size;

if (!pi || pi->port_state != ICE_SCHED_PORT_STATE_READY)
return -EIO;
Expand All @@ -4812,11 +4812,6 @@ ice_dis_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u8 num_queues,
return -EIO;
}

buf_size = struct_size(qg_list, q_id, 1);
qg_list = kzalloc(buf_size, GFP_KERNEL);
if (!qg_list)
return -ENOMEM;

mutex_lock(&pi->sched_lock);

for (i = 0; i < num_queues; i++) {
Expand Down Expand Up @@ -4849,7 +4844,6 @@ ice_dis_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u8 num_queues,
q_ctx->q_teid = ICE_INVAL_TEID;
}
mutex_unlock(&pi->sched_lock);
kfree(qg_list);
return status;
}

Expand Down Expand Up @@ -5018,22 +5012,17 @@ int
ice_dis_vsi_rdma_qset(struct ice_port_info *pi, u16 count, u32 *qset_teid,
u16 *q_id)
{
struct ice_aqc_dis_txq_item *qg_list;
DEFINE_FLEX(struct ice_aqc_dis_txq_item, qg_list, q_id, 1);
u16 qg_size = __struct_size(qg_list);
struct ice_hw *hw;
int status = 0;
u16 qg_size;
int i;

if (!pi || pi->port_state != ICE_SCHED_PORT_STATE_READY)
return -EIO;

hw = pi->hw;

qg_size = struct_size(qg_list, q_id, 1);
qg_list = kzalloc(qg_size, GFP_KERNEL);
if (!qg_list)
return -ENOMEM;

mutex_lock(&pi->sched_lock);

for (i = 0; i < count; i++) {
Expand All @@ -5058,7 +5047,6 @@ ice_dis_vsi_rdma_qset(struct ice_port_info *pi, u16 count, u32 *qset_teid,
}

mutex_unlock(&pi->sched_lock);
kfree(qg_list);
return status;
}

Expand Down

0 comments on commit 11dee3d

Please sign in to comment.