Commit 11a20c71 authored by David S. Miller's avatar David S. Miller

Merge branch '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-queue

Tony Nguyen says:

====================
100GbE Intel Wired LAN Driver Updates 2020-07-01

This series contains updates to the ice driver only.

Jacob implements a devlink region for device capabilities.

Bruce removes structs containing only one-element arrays that are either
unused or only used for indexing. Instead, use pointer arithmetic or
other indexing to access the elements. Converts "C struct hack"
variable-length types to the preferred C99 flexible array member.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents a3b658cf 66486d89
...@@ -373,6 +373,7 @@ struct ice_pf { ...@@ -373,6 +373,7 @@ struct ice_pf {
struct devlink_port devlink_port; struct devlink_port devlink_port;
struct devlink_region *nvm_region; struct devlink_region *nvm_region;
struct devlink_region *devcaps_region;
/* OS reserved IRQ details */ /* OS reserved IRQ details */
struct msix_entry *msix_entries; struct msix_entry *msix_entries;
......
...@@ -215,13 +215,6 @@ struct ice_aqc_get_sw_cfg_resp_elem { ...@@ -215,13 +215,6 @@ struct ice_aqc_get_sw_cfg_resp_elem {
#define ICE_AQC_GET_SW_CONF_RESP_IS_VF BIT(15) #define ICE_AQC_GET_SW_CONF_RESP_IS_VF BIT(15)
}; };
/* The response buffer is as follows. Note that the length of the
* elements array varies with the length of the command response.
*/
struct ice_aqc_get_sw_cfg_resp {
struct ice_aqc_get_sw_cfg_resp_elem elements[1];
};
/* These resource type defines are used for all switch resource /* These resource type defines are used for all switch resource
* commands where a resource type is required, such as: * commands where a resource type is required, such as:
* Get Resource Allocation command (indirect 0x0204) * Get Resource Allocation command (indirect 0x0204)
...@@ -274,7 +267,7 @@ struct ice_aqc_alloc_free_res_elem { ...@@ -274,7 +267,7 @@ struct ice_aqc_alloc_free_res_elem {
#define ICE_AQC_RES_TYPE_VSI_PRUNE_LIST_M \ #define ICE_AQC_RES_TYPE_VSI_PRUNE_LIST_M \
(0xF << ICE_AQC_RES_TYPE_VSI_PRUNE_LIST_S) (0xF << ICE_AQC_RES_TYPE_VSI_PRUNE_LIST_S)
__le16 num_elems; __le16 num_elems;
struct ice_aqc_res_elem elem[1]; struct ice_aqc_res_elem elem[];
}; };
/* Add VSI (indirect 0x0210) /* Add VSI (indirect 0x0210)
...@@ -568,8 +561,8 @@ struct ice_sw_rule_lkup_rx_tx { ...@@ -568,8 +561,8 @@ struct ice_sw_rule_lkup_rx_tx {
* lookup-type * lookup-type
*/ */
__le16 hdr_len; __le16 hdr_len;
u8 hdr[1]; u8 hdr[];
} __packed; };
/* Add/Update/Remove large action command/response entry /* Add/Update/Remove large action command/response entry
* "index" is returned as part of a response to a successful Add command, and * "index" is returned as part of a response to a successful Add command, and
...@@ -578,7 +571,6 @@ struct ice_sw_rule_lkup_rx_tx { ...@@ -578,7 +571,6 @@ struct ice_sw_rule_lkup_rx_tx {
struct ice_sw_rule_lg_act { struct ice_sw_rule_lg_act {
__le16 index; /* Index in large action table */ __le16 index; /* Index in large action table */
__le16 size; __le16 size;
__le32 act[1]; /* array of size for actions */
/* Max number of large actions */ /* Max number of large actions */
#define ICE_MAX_LG_ACT 4 #define ICE_MAX_LG_ACT 4
/* Bit 0:1 - Action type */ /* Bit 0:1 - Action type */
...@@ -629,6 +621,7 @@ struct ice_sw_rule_lg_act { ...@@ -629,6 +621,7 @@ struct ice_sw_rule_lg_act {
#define ICE_LG_ACT_STAT_COUNT 0x7 #define ICE_LG_ACT_STAT_COUNT 0x7
#define ICE_LG_ACT_STAT_COUNT_S 3 #define ICE_LG_ACT_STAT_COUNT_S 3
#define ICE_LG_ACT_STAT_COUNT_M (0x7F << ICE_LG_ACT_STAT_COUNT_S) #define ICE_LG_ACT_STAT_COUNT_M (0x7F << ICE_LG_ACT_STAT_COUNT_S)
__le32 act[]; /* array of size for actions */
}; };
/* Add/Update/Remove VSI list command/response entry /* Add/Update/Remove VSI list command/response entry
...@@ -638,7 +631,7 @@ struct ice_sw_rule_lg_act { ...@@ -638,7 +631,7 @@ struct ice_sw_rule_lg_act {
struct ice_sw_rule_vsi_list { struct ice_sw_rule_vsi_list {
__le16 index; /* Index of VSI/Prune list */ __le16 index; /* Index of VSI/Prune list */
__le16 number_vsi; __le16 number_vsi;
__le16 vsi[1]; /* Array of number_vsi VSI numbers */ __le16 vsi[]; /* Array of number_vsi VSI numbers */
}; };
/* Query VSI list command/response entry */ /* Query VSI list command/response entry */
...@@ -695,14 +688,6 @@ struct ice_aqc_sched_elem_cmd { ...@@ -695,14 +688,6 @@ struct ice_aqc_sched_elem_cmd {
__le32 addr_low; __le32 addr_low;
}; };
/* This is the buffer for:
* Suspend Nodes (indirect 0x0409)
* Resume Nodes (indirect 0x040A)
*/
struct ice_aqc_suspend_resume_elem {
__le32 teid[1];
};
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;
...@@ -753,15 +738,7 @@ struct ice_aqc_txsched_topo_grp_info_hdr { ...@@ -753,15 +738,7 @@ struct ice_aqc_txsched_topo_grp_info_hdr {
struct ice_aqc_add_elem { struct ice_aqc_add_elem {
struct ice_aqc_txsched_topo_grp_info_hdr hdr; struct ice_aqc_txsched_topo_grp_info_hdr hdr;
struct ice_aqc_txsched_elem_data generic[1]; struct ice_aqc_txsched_elem_data generic[];
};
struct ice_aqc_conf_elem {
struct ice_aqc_txsched_elem_data generic[1];
};
struct ice_aqc_get_elem {
struct ice_aqc_txsched_elem_data generic[1];
}; };
struct ice_aqc_get_topo_elem { struct ice_aqc_get_topo_elem {
...@@ -772,7 +749,7 @@ struct ice_aqc_get_topo_elem { ...@@ -772,7 +749,7 @@ struct ice_aqc_get_topo_elem {
struct ice_aqc_delete_elem { struct ice_aqc_delete_elem {
struct ice_aqc_txsched_topo_grp_info_hdr hdr; struct ice_aqc_txsched_topo_grp_info_hdr hdr;
__le32 teid[1]; __le32 teid[];
}; };
/* Query Port ETS (indirect 0x040E) /* Query Port ETS (indirect 0x040E)
...@@ -835,10 +812,6 @@ struct ice_aqc_rl_profile_elem { ...@@ -835,10 +812,6 @@ struct ice_aqc_rl_profile_elem {
__le16 rl_encode; __le16 rl_encode;
}; };
struct ice_aqc_rl_profile_generic_elem {
struct ice_aqc_rl_profile_elem generic[1];
};
/* Query Scheduler Resource Allocation (indirect 0x0412) /* Query Scheduler Resource Allocation (indirect 0x0412)
* This indirect command retrieves the scheduler resources allocated by * This indirect command retrieves the scheduler resources allocated by
* EMP Firmware to the given PF. * EMP Firmware to the given PF.
...@@ -1537,7 +1510,7 @@ struct ice_aqc_add_tx_qgrp { ...@@ -1537,7 +1510,7 @@ struct ice_aqc_add_tx_qgrp {
__le32 parent_teid; __le32 parent_teid;
u8 num_txqs; u8 num_txqs;
u8 rsvd[3]; u8 rsvd[3];
struct ice_aqc_add_txqs_perq txqs[1]; struct ice_aqc_add_txqs_perq txqs[];
}; };
/* Disable Tx LAN Queues (indirect 0x0C31) */ /* Disable Tx LAN Queues (indirect 0x0C31) */
...@@ -1575,18 +1548,13 @@ struct ice_aqc_dis_txq_item { ...@@ -1575,18 +1548,13 @@ struct ice_aqc_dis_txq_item {
u8 num_qs; u8 num_qs;
u8 rsvd; u8 rsvd;
/* The length of the q_id array varies according to num_qs */ /* The length of the q_id array varies according to num_qs */
__le16 q_id[1];
/* This only applies from F8 onward */
#define ICE_AQC_Q_DIS_BUF_ELEM_TYPE_S 15 #define ICE_AQC_Q_DIS_BUF_ELEM_TYPE_S 15
#define ICE_AQC_Q_DIS_BUF_ELEM_TYPE_LAN_Q \ #define ICE_AQC_Q_DIS_BUF_ELEM_TYPE_LAN_Q \
(0 << ICE_AQC_Q_DIS_BUF_ELEM_TYPE_S) (0 << ICE_AQC_Q_DIS_BUF_ELEM_TYPE_S)
#define ICE_AQC_Q_DIS_BUF_ELEM_TYPE_RDMA_QSET \ #define ICE_AQC_Q_DIS_BUF_ELEM_TYPE_RDMA_QSET \
(1 << ICE_AQC_Q_DIS_BUF_ELEM_TYPE_S) (1 << ICE_AQC_Q_DIS_BUF_ELEM_TYPE_S)
}; __le16 q_id[];
} __packed;
struct ice_aqc_dis_txq {
struct ice_aqc_dis_txq_item qgrps[1];
};
/* Configure Firmware Logging Command (indirect 0xFF09) /* Configure Firmware Logging Command (indirect 0xFF09)
* Logging Information Read Response (indirect 0xFF10) * Logging Information Read Response (indirect 0xFF10)
...@@ -1636,12 +1604,7 @@ enum ice_aqc_fw_logging_mod { ...@@ -1636,12 +1604,7 @@ enum ice_aqc_fw_logging_mod {
ICE_AQC_FW_LOG_ID_MAX, ICE_AQC_FW_LOG_ID_MAX,
}; };
/* This is the buffer for both of the logging commands. /* Defines for both above FW logging command/response buffers */
* The entry array size depends on the datalen parameter in the descriptor.
* There will be a total of datalen / 2 entries.
*/
struct ice_aqc_fw_logging_data {
__le16 entry[1];
#define ICE_AQC_FW_LOG_ID_S 0 #define ICE_AQC_FW_LOG_ID_S 0
#define ICE_AQC_FW_LOG_ID_M (0xFFF << ICE_AQC_FW_LOG_ID_S) #define ICE_AQC_FW_LOG_ID_M (0xFFF << ICE_AQC_FW_LOG_ID_S)
...@@ -1654,7 +1617,6 @@ struct ice_aqc_fw_logging_data { ...@@ -1654,7 +1617,6 @@ struct ice_aqc_fw_logging_data {
#define ICE_AQC_FW_LOG_INIT_EN BIT(13) /* Used by command */ #define ICE_AQC_FW_LOG_INIT_EN BIT(13) /* Used by command */
#define ICE_AQC_FW_LOG_FLOW_EN BIT(14) /* Used by command */ #define ICE_AQC_FW_LOG_FLOW_EN BIT(14) /* Used by command */
#define ICE_AQC_FW_LOG_ERR_EN BIT(15) /* Used by command */ #define ICE_AQC_FW_LOG_ERR_EN BIT(15) /* Used by command */
};
/* Get/Clear FW Log (indirect 0xFF11) */ /* Get/Clear FW Log (indirect 0xFF11) */
struct ice_aqc_get_clear_fw_log { struct ice_aqc_get_clear_fw_log {
...@@ -1716,7 +1678,7 @@ struct ice_aqc_get_pkg_info { ...@@ -1716,7 +1678,7 @@ struct ice_aqc_get_pkg_info {
/* Get Package Info List response buffer format (0x0C43) */ /* Get Package Info List response buffer format (0x0C43) */
struct ice_aqc_get_pkg_info_resp { struct ice_aqc_get_pkg_info_resp {
__le32 count; __le32 count;
struct ice_aqc_get_pkg_info pkg_info[1]; struct ice_aqc_get_pkg_info pkg_info[];
}; };
/* Lan Queue Overflow Event (direct, 0x1001) */ /* Lan Queue Overflow Event (direct, 0x1001) */
......
...@@ -635,10 +635,10 @@ int ...@@ -635,10 +635,10 @@ int
ice_vsi_cfg_txq(struct ice_vsi *vsi, struct ice_ring *ring, ice_vsi_cfg_txq(struct ice_vsi *vsi, struct ice_ring *ring,
struct ice_aqc_add_tx_qgrp *qg_buf) struct ice_aqc_add_tx_qgrp *qg_buf)
{ {
u8 buf_len = struct_size(qg_buf, txqs, 1);
struct ice_tlan_ctx tlan_ctx = { 0 }; struct ice_tlan_ctx tlan_ctx = { 0 };
struct ice_aqc_add_txqs_perq *txq; struct ice_aqc_add_txqs_perq *txq;
struct ice_pf *pf = vsi->back; struct ice_pf *pf = vsi->back;
u8 buf_len = sizeof(*qg_buf);
struct ice_hw *hw = &pf->hw; struct ice_hw *hw = &pf->hw;
enum ice_status status; enum ice_status status;
u16 pf_q; u16 pf_q;
......
This diff is collapsed.
...@@ -87,6 +87,9 @@ enum ice_status ...@@ -87,6 +87,9 @@ enum ice_status
ice_aq_get_phy_caps(struct ice_port_info *pi, bool qual_mods, u8 report_mode, ice_aq_get_phy_caps(struct ice_port_info *pi, bool qual_mods, u8 report_mode,
struct ice_aqc_get_phy_caps_data *caps, struct ice_aqc_get_phy_caps_data *caps,
struct ice_sq_cd *cd); struct ice_sq_cd *cd);
enum ice_status
ice_aq_list_caps(struct ice_hw *hw, void *buf, u16 buf_size, u32 *cap_count,
enum ice_adminq_opc opc, struct ice_sq_cd *cd);
void void
ice_update_phy_type(u64 *phy_type_low, u64 *phy_type_high, ice_update_phy_type(u64 *phy_type_low, u64 *phy_type_high,
u16 link_speeds_bitmap); u16 link_speeds_bitmap);
...@@ -152,5 +155,5 @@ ice_stat_update32(struct ice_hw *hw, u32 reg, bool prev_stat_loaded, ...@@ -152,5 +155,5 @@ ice_stat_update32(struct ice_hw *hw, u32 reg, bool prev_stat_loaded,
u64 *prev_stat, u64 *cur_stat); u64 *prev_stat, u64 *cur_stat);
enum ice_status enum ice_status
ice_sched_query_elem(struct ice_hw *hw, u32 node_teid, ice_sched_query_elem(struct ice_hw *hw, u32 node_teid,
struct ice_aqc_get_elem *buf); struct ice_aqc_txsched_elem_data *buf);
#endif /* _ICE_COMMON_H_ */ #endif /* _ICE_COMMON_H_ */
...@@ -1362,7 +1362,7 @@ ice_update_port_tc_tree_cfg(struct ice_port_info *pi, ...@@ -1362,7 +1362,7 @@ ice_update_port_tc_tree_cfg(struct ice_port_info *pi,
struct ice_aqc_port_ets_elem *buf) struct ice_aqc_port_ets_elem *buf)
{ {
struct ice_sched_node *node, *tc_node; struct ice_sched_node *node, *tc_node;
struct ice_aqc_get_elem elem; struct ice_aqc_txsched_elem_data elem;
enum ice_status status = 0; enum ice_status status = 0;
u32 teid1, teid2; u32 teid1, teid2;
u8 i, j; u8 i, j;
...@@ -1404,7 +1404,7 @@ ice_update_port_tc_tree_cfg(struct ice_port_info *pi, ...@@ -1404,7 +1404,7 @@ ice_update_port_tc_tree_cfg(struct ice_port_info *pi,
/* new TC */ /* new TC */
status = ice_sched_query_elem(pi->hw, teid2, &elem); status = ice_sched_query_elem(pi->hw, teid2, &elem);
if (!status) if (!status)
status = ice_sched_add_node(pi, 1, &elem.generic[0]); status = ice_sched_add_node(pi, 1, &elem);
if (status) if (status)
break; break;
/* update the TC number */ /* update the TC number */
......
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
struct ice_lldp_org_tlv { struct ice_lldp_org_tlv {
__be16 typelen; __be16 typelen;
__be32 ouisubtype; __be32 ouisubtype;
u8 tlvinfo[1]; u8 tlvinfo[];
} __packed; } __packed;
struct ice_cee_tlv_hdr { struct ice_cee_tlv_hdr {
...@@ -109,7 +109,7 @@ struct ice_cee_feat_tlv { ...@@ -109,7 +109,7 @@ struct ice_cee_feat_tlv {
#define ICE_CEE_FEAT_TLV_WILLING_M 0x40 #define ICE_CEE_FEAT_TLV_WILLING_M 0x40
#define ICE_CEE_FEAT_TLV_ERR_M 0x20 #define ICE_CEE_FEAT_TLV_ERR_M 0x20
u8 subtype; u8 subtype;
u8 tlvinfo[1]; u8 tlvinfo[];
}; };
struct ice_cee_app_prio { struct ice_cee_app_prio {
......
...@@ -397,12 +397,60 @@ static int ice_devlink_nvm_snapshot(struct devlink *devlink, ...@@ -397,12 +397,60 @@ static int ice_devlink_nvm_snapshot(struct devlink *devlink,
return 0; return 0;
} }
/**
* ice_devlink_devcaps_snapshot - Capture snapshot of device capabilities
* @devlink: the devlink instance
* @extack: extended ACK response structure
* @data: on exit points to snapshot data buffer
*
* This function is called in response to the DEVLINK_CMD_REGION_TRIGGER for
* the device-caps devlink region. It captures a snapshot of the device
* capabilities reported by firmware.
*
* @returns zero on success, and updates the data pointer. Returns a non-zero
* error code on failure.
*/
static int
ice_devlink_devcaps_snapshot(struct devlink *devlink,
struct netlink_ext_ack *extack, u8 **data)
{
struct ice_pf *pf = devlink_priv(devlink);
struct device *dev = ice_pf_to_dev(pf);
struct ice_hw *hw = &pf->hw;
enum ice_status status;
void *devcaps;
devcaps = vzalloc(ICE_AQ_MAX_BUF_LEN);
if (!devcaps)
return -ENOMEM;
status = ice_aq_list_caps(hw, devcaps, ICE_AQ_MAX_BUF_LEN, NULL,
ice_aqc_opc_list_dev_caps, NULL);
if (status) {
dev_dbg(dev, "ice_aq_list_caps: failed to read device capabilities, err %d aq_err %d\n",
status, hw->adminq.sq_last_status);
NL_SET_ERR_MSG_MOD(extack, "Failed to read device capabilities");
vfree(devcaps);
return -EIO;
}
*data = (u8 *)devcaps;
return 0;
}
static const struct devlink_region_ops ice_nvm_region_ops = { static const struct devlink_region_ops ice_nvm_region_ops = {
.name = "nvm-flash", .name = "nvm-flash",
.destructor = vfree, .destructor = vfree,
.snapshot = ice_devlink_nvm_snapshot, .snapshot = ice_devlink_nvm_snapshot,
}; };
static const struct devlink_region_ops ice_devcaps_region_ops = {
.name = "device-caps",
.destructor = vfree,
.snapshot = ice_devlink_devcaps_snapshot,
};
/** /**
* ice_devlink_init_regions - Initialize devlink regions * ice_devlink_init_regions - Initialize devlink regions
* @pf: the PF device structure * @pf: the PF device structure
...@@ -424,6 +472,15 @@ void ice_devlink_init_regions(struct ice_pf *pf) ...@@ -424,6 +472,15 @@ void ice_devlink_init_regions(struct ice_pf *pf)
PTR_ERR(pf->nvm_region)); PTR_ERR(pf->nvm_region));
pf->nvm_region = NULL; pf->nvm_region = NULL;
} }
pf->devcaps_region = devlink_region_create(devlink,
&ice_devcaps_region_ops, 10,
ICE_AQ_MAX_BUF_LEN);
if (IS_ERR(pf->devcaps_region)) {
dev_err(dev, "failed to create device-caps devlink region, err %ld\n",
PTR_ERR(pf->devcaps_region));
pf->devcaps_region = NULL;
}
} }
/** /**
...@@ -436,4 +493,6 @@ void ice_devlink_destroy_regions(struct ice_pf *pf) ...@@ -436,4 +493,6 @@ void ice_devlink_destroy_regions(struct ice_pf *pf)
{ {
if (pf->nvm_region) if (pf->nvm_region)
devlink_region_destroy(pf->nvm_region); devlink_region_destroy(pf->nvm_region);
if (pf->devcaps_region)
devlink_region_destroy(pf->devcaps_region);
} }
...@@ -1121,8 +1121,7 @@ static enum ice_status ice_get_pkg_info(struct ice_hw *hw) ...@@ -1121,8 +1121,7 @@ static enum ice_status ice_get_pkg_info(struct ice_hw *hw)
u16 size; u16 size;
u32 i; u32 i;
size = sizeof(*pkg_info) + (sizeof(pkg_info->pkg_info[0]) * size = struct_size(pkg_info, pkg_info, ICE_PKG_CNT);
(ICE_PKG_CNT - 1));
pkg_info = kzalloc(size, GFP_KERNEL); pkg_info = kzalloc(size, GFP_KERNEL);
if (!pkg_info) if (!pkg_info)
return ICE_ERR_NO_MEMORY; return ICE_ERR_NO_MEMORY;
...@@ -1180,7 +1179,7 @@ static enum ice_status ice_verify_pkg(struct ice_pkg_hdr *pkg, u32 len) ...@@ -1180,7 +1179,7 @@ static enum ice_status ice_verify_pkg(struct ice_pkg_hdr *pkg, u32 len)
u32 seg_count; u32 seg_count;
u32 i; u32 i;
if (len < sizeof(*pkg)) if (len < struct_size(pkg, seg_offset, 1))
return ICE_ERR_BUF_TOO_SHORT; return ICE_ERR_BUF_TOO_SHORT;
if (pkg->pkg_format_ver.major != ICE_PKG_FMT_VER_MAJ || if (pkg->pkg_format_ver.major != ICE_PKG_FMT_VER_MAJ ||
...@@ -1195,7 +1194,7 @@ static enum ice_status ice_verify_pkg(struct ice_pkg_hdr *pkg, u32 len) ...@@ -1195,7 +1194,7 @@ static enum ice_status ice_verify_pkg(struct ice_pkg_hdr *pkg, u32 len)
return ICE_ERR_CFG; return ICE_ERR_CFG;
/* make sure segment array fits in package length */ /* make sure segment array fits in package length */
if (len < sizeof(*pkg) + ((seg_count - 1) * sizeof(pkg->seg_offset))) if (len < struct_size(pkg, seg_offset, seg_count))
return ICE_ERR_BUF_TOO_SHORT; return ICE_ERR_BUF_TOO_SHORT;
/* all segments must fit within length */ /* all segments must fit within length */
...@@ -1300,7 +1299,7 @@ ice_chk_pkg_compat(struct ice_hw *hw, struct ice_pkg_hdr *ospkg, ...@@ -1300,7 +1299,7 @@ ice_chk_pkg_compat(struct ice_hw *hw, struct ice_pkg_hdr *ospkg,
} }
/* Check if FW is compatible with the OS package */ /* Check if FW is compatible with the OS package */
size = struct_size(pkg, pkg_info, ICE_PKG_CNT - 1); size = struct_size(pkg, pkg_info, ICE_PKG_CNT);
pkg = kzalloc(size, GFP_KERNEL); pkg = kzalloc(size, GFP_KERNEL);
if (!pkg) if (!pkg)
return ICE_ERR_NO_MEMORY; return ICE_ERR_NO_MEMORY;
...@@ -1764,13 +1763,13 @@ ice_create_tunnel(struct ice_hw *hw, enum ice_tunnel_type type, u16 port) ...@@ -1764,13 +1763,13 @@ ice_create_tunnel(struct ice_hw *hw, enum ice_tunnel_type type, u16 port)
goto ice_create_tunnel_err; goto ice_create_tunnel_err;
sect_rx = ice_pkg_buf_alloc_section(bld, ICE_SID_RXPARSER_BOOST_TCAM, sect_rx = ice_pkg_buf_alloc_section(bld, ICE_SID_RXPARSER_BOOST_TCAM,
sizeof(*sect_rx)); struct_size(sect_rx, tcam, 1));
if (!sect_rx) if (!sect_rx)
goto ice_create_tunnel_err; goto ice_create_tunnel_err;
sect_rx->count = cpu_to_le16(1); sect_rx->count = cpu_to_le16(1);
sect_tx = ice_pkg_buf_alloc_section(bld, ICE_SID_TXPARSER_BOOST_TCAM, sect_tx = ice_pkg_buf_alloc_section(bld, ICE_SID_TXPARSER_BOOST_TCAM,
sizeof(*sect_tx)); struct_size(sect_tx, tcam, 1));
if (!sect_tx) if (!sect_tx)
goto ice_create_tunnel_err; goto ice_create_tunnel_err;
sect_tx->count = cpu_to_le16(1); sect_tx->count = cpu_to_le16(1);
...@@ -1847,7 +1846,7 @@ enum ice_status ice_destroy_tunnel(struct ice_hw *hw, u16 port, bool all) ...@@ -1847,7 +1846,7 @@ enum ice_status ice_destroy_tunnel(struct ice_hw *hw, u16 port, bool all)
} }
/* size of section - there is at least one entry */ /* size of section - there is at least one entry */
size = struct_size(sect_rx, tcam, count - 1); size = struct_size(sect_rx, tcam, count);
bld = ice_pkg_buf_alloc(hw); bld = ice_pkg_buf_alloc(hw);
if (!bld) { if (!bld) {
...@@ -3324,10 +3323,10 @@ ice_prof_bld_es(struct ice_hw *hw, enum ice_block blk, ...@@ -3324,10 +3323,10 @@ ice_prof_bld_es(struct ice_hw *hw, enum ice_block blk,
u32 id; u32 id;
id = ice_sect_id(blk, ICE_VEC_TBL); id = ice_sect_id(blk, ICE_VEC_TBL);
p = (struct ice_pkg_es *) p = ice_pkg_buf_alloc_section(bld, id,
ice_pkg_buf_alloc_section(bld, id, sizeof(*p) + struct_size(p, es, 1) +
vec_size - vec_size -
sizeof(p->es[0])); sizeof(p->es[0]));
if (!p) if (!p)
return ICE_ERR_MAX_LIMIT; return ICE_ERR_MAX_LIMIT;
...@@ -3360,8 +3359,8 @@ ice_prof_bld_tcam(struct ice_hw *hw, enum ice_block blk, ...@@ -3360,8 +3359,8 @@ ice_prof_bld_tcam(struct ice_hw *hw, enum ice_block blk,
u32 id; u32 id;
id = ice_sect_id(blk, ICE_PROF_TCAM); id = ice_sect_id(blk, ICE_PROF_TCAM);
p = (struct ice_prof_id_section *) p = ice_pkg_buf_alloc_section(bld, id,
ice_pkg_buf_alloc_section(bld, id, sizeof(*p)); struct_size(p, entry, 1));
if (!p) if (!p)
return ICE_ERR_MAX_LIMIT; return ICE_ERR_MAX_LIMIT;
...@@ -3396,8 +3395,8 @@ ice_prof_bld_xlt1(enum ice_block blk, struct ice_buf_build *bld, ...@@ -3396,8 +3395,8 @@ ice_prof_bld_xlt1(enum ice_block blk, struct ice_buf_build *bld,
u32 id; u32 id;
id = ice_sect_id(blk, ICE_XLT1); id = ice_sect_id(blk, ICE_XLT1);
p = (struct ice_xlt1_section *) p = ice_pkg_buf_alloc_section(bld, id,
ice_pkg_buf_alloc_section(bld, id, sizeof(*p)); struct_size(p, value, 1));
if (!p) if (!p)
return ICE_ERR_MAX_LIMIT; return ICE_ERR_MAX_LIMIT;
...@@ -3431,8 +3430,8 @@ ice_prof_bld_xlt2(enum ice_block blk, struct ice_buf_build *bld, ...@@ -3431,8 +3430,8 @@ ice_prof_bld_xlt2(enum ice_block blk, struct ice_buf_build *bld,
case ICE_VSI_MOVE: case ICE_VSI_MOVE:
case ICE_VSIG_REM: case ICE_VSIG_REM:
id = ice_sect_id(blk, ICE_XLT2); id = ice_sect_id(blk, ICE_XLT2);
p = (struct ice_xlt2_section *) p = ice_pkg_buf_alloc_section(bld, id,
ice_pkg_buf_alloc_section(bld, id, sizeof(*p)); struct_size(p, value, 1));
if (!p) if (!p)
return ICE_ERR_MAX_LIMIT; return ICE_ERR_MAX_LIMIT;
......
...@@ -22,7 +22,7 @@ struct ice_fv { ...@@ -22,7 +22,7 @@ struct ice_fv {
struct ice_pkg_hdr { struct ice_pkg_hdr {
struct ice_pkg_ver pkg_format_ver; struct ice_pkg_ver pkg_format_ver;
__le32 seg_count; __le32 seg_count;
__le32 seg_offset[1]; __le32 seg_offset[];
}; };
/* generic segment */ /* generic segment */
...@@ -53,12 +53,12 @@ struct ice_device_id_entry { ...@@ -53,12 +53,12 @@ struct ice_device_id_entry {
struct ice_seg { struct ice_seg {
struct ice_generic_seg_hdr hdr; struct ice_generic_seg_hdr hdr;
__le32 device_table_count; __le32 device_table_count;
struct ice_device_id_entry device_table[1]; struct ice_device_id_entry device_table[];
}; };
struct ice_nvm_table { struct ice_nvm_table {
__le32 table_count; __le32 table_count;
__le32 vers[1]; __le32 vers[];
}; };
struct ice_buf { struct ice_buf {
...@@ -68,7 +68,7 @@ struct ice_buf { ...@@ -68,7 +68,7 @@ struct ice_buf {
struct ice_buf_table { struct ice_buf_table {
__le32 buf_count; __le32 buf_count;
struct ice_buf buf_array[1]; struct ice_buf buf_array[];
}; };
/* global metadata specific segment */ /* global metadata specific segment */
...@@ -101,11 +101,12 @@ struct ice_section_entry { ...@@ -101,11 +101,12 @@ struct ice_section_entry {
struct ice_buf_hdr { struct ice_buf_hdr {
__le16 section_count; __le16 section_count;
__le16 data_end; __le16 data_end;
struct ice_section_entry section_entry[1]; struct ice_section_entry section_entry[];
}; };
#define ICE_MAX_ENTRIES_IN_BUF(hd_sz, ent_sz) ((ICE_PKG_BUF_SIZE - \ #define ICE_MAX_ENTRIES_IN_BUF(hd_sz, ent_sz) ((ICE_PKG_BUF_SIZE - \
sizeof(struct ice_buf_hdr) - (hd_sz)) / (ent_sz)) struct_size((struct ice_buf_hdr *)0, section_entry, 1) - (hd_sz)) /\
(ent_sz))
/* ice package section IDs */ /* ice package section IDs */
#define ICE_SID_XLT0_SW 10 #define ICE_SID_XLT0_SW 10
...@@ -198,17 +199,17 @@ struct ice_label { ...@@ -198,17 +199,17 @@ struct ice_label {
struct ice_label_section { struct ice_label_section {
__le16 count; __le16 count;
struct ice_label label[1]; struct ice_label label[];
}; };
#define ICE_MAX_LABELS_IN_BUF ICE_MAX_ENTRIES_IN_BUF( \ #define ICE_MAX_LABELS_IN_BUF ICE_MAX_ENTRIES_IN_BUF( \
sizeof(struct ice_label_section) - sizeof(struct ice_label), \ struct_size((struct ice_label_section *)0, label, 1) - \
sizeof(struct ice_label)) sizeof(struct ice_label), sizeof(struct ice_label))
struct ice_sw_fv_section { struct ice_sw_fv_section {
__le16 count; __le16 count;
__le16 base_offset; __le16 base_offset;
struct ice_fv fv[1]; struct ice_fv fv[];
}; };
/* The BOOST TCAM stores the match packet header in reverse order, meaning /* The BOOST TCAM stores the match packet header in reverse order, meaning
...@@ -245,30 +246,30 @@ struct ice_boost_tcam_entry { ...@@ -245,30 +246,30 @@ struct ice_boost_tcam_entry {
struct ice_boost_tcam_section { struct ice_boost_tcam_section {
__le16 count; __le16 count;
__le16 reserved; __le16 reserved;
struct ice_boost_tcam_entry tcam[1]; struct ice_boost_tcam_entry tcam[];
}; };
#define ICE_MAX_BST_TCAMS_IN_BUF ICE_MAX_ENTRIES_IN_BUF( \ #define ICE_MAX_BST_TCAMS_IN_BUF ICE_MAX_ENTRIES_IN_BUF( \
sizeof(struct ice_boost_tcam_section) - \ struct_size((struct ice_boost_tcam_section *)0, tcam, 1) - \
sizeof(struct ice_boost_tcam_entry), \ sizeof(struct ice_boost_tcam_entry), \
sizeof(struct ice_boost_tcam_entry)) sizeof(struct ice_boost_tcam_entry))
struct ice_xlt1_section { struct ice_xlt1_section {
__le16 count; __le16 count;
__le16 offset; __le16 offset;
u8 value[1]; u8 value[];
} __packed; };
struct ice_xlt2_section { struct ice_xlt2_section {
__le16 count; __le16 count;
__le16 offset; __le16 offset;
__le16 value[1]; __le16 value[];
}; };
struct ice_prof_redir_section { struct ice_prof_redir_section {
__le16 count; __le16 count;
__le16 offset; __le16 offset;
u8 redir_value[1]; u8 redir_value[];
}; };
/* package buffer building */ /* package buffer building */
...@@ -327,7 +328,7 @@ struct ice_tunnel_table { ...@@ -327,7 +328,7 @@ struct ice_tunnel_table {
struct ice_pkg_es { struct ice_pkg_es {
__le16 count; __le16 count;
__le16 offset; __le16 offset;
struct ice_fv_word es[1]; struct ice_fv_word es[];
}; };
struct ice_es { struct ice_es {
...@@ -461,8 +462,8 @@ struct ice_prof_tcam_entry { ...@@ -461,8 +462,8 @@ struct ice_prof_tcam_entry {
struct ice_prof_id_section { struct ice_prof_id_section {
__le16 count; __le16 count;
struct ice_prof_tcam_entry entry[1]; struct ice_prof_tcam_entry entry[];
} __packed; };
struct ice_prof_tcam { struct ice_prof_tcam {
u32 sid; u32 sid;
......
...@@ -1667,7 +1667,7 @@ ice_vsi_cfg_txqs(struct ice_vsi *vsi, struct ice_ring **rings) ...@@ -1667,7 +1667,7 @@ ice_vsi_cfg_txqs(struct ice_vsi *vsi, struct ice_ring **rings)
u16 q_idx = 0; u16 q_idx = 0;
int err = 0; int err = 0;
qg_buf = kzalloc(sizeof(*qg_buf), GFP_KERNEL); qg_buf = kzalloc(struct_size(qg_buf, txqs, 1), GFP_KERNEL);
if (!qg_buf) if (!qg_buf)
return -ENOMEM; return -ENOMEM;
......
...@@ -129,7 +129,7 @@ ice_aqc_send_sched_elem_cmd(struct ice_hw *hw, enum ice_adminq_opc cmd_opc, ...@@ -129,7 +129,7 @@ ice_aqc_send_sched_elem_cmd(struct ice_hw *hw, enum ice_adminq_opc cmd_opc,
*/ */
enum ice_status enum ice_status
ice_aq_query_sched_elems(struct ice_hw *hw, u16 elems_req, ice_aq_query_sched_elems(struct ice_hw *hw, u16 elems_req,
struct ice_aqc_get_elem *buf, u16 buf_size, struct ice_aqc_txsched_elem_data *buf, u16 buf_size,
u16 *elems_ret, struct ice_sq_cd *cd) u16 *elems_ret, struct ice_sq_cd *cd)
{ {
return ice_aqc_send_sched_elem_cmd(hw, ice_aqc_opc_get_sched_elems, return ice_aqc_send_sched_elem_cmd(hw, ice_aqc_opc_get_sched_elems,
...@@ -149,8 +149,8 @@ enum ice_status ...@@ -149,8 +149,8 @@ enum ice_status
ice_sched_add_node(struct ice_port_info *pi, u8 layer, ice_sched_add_node(struct ice_port_info *pi, u8 layer,
struct ice_aqc_txsched_elem_data *info) struct ice_aqc_txsched_elem_data *info)
{ {
struct ice_aqc_txsched_elem_data elem;
struct ice_sched_node *parent; struct ice_sched_node *parent;
struct ice_aqc_get_elem elem;
struct ice_sched_node *node; struct ice_sched_node *node;
enum ice_status status; enum ice_status status;
struct ice_hw *hw; struct ice_hw *hw;
...@@ -195,7 +195,7 @@ ice_sched_add_node(struct ice_port_info *pi, u8 layer, ...@@ -195,7 +195,7 @@ ice_sched_add_node(struct ice_port_info *pi, u8 layer,
node->parent = parent; node->parent = parent;
node->tx_sched_layer = layer; node->tx_sched_layer = layer;
parent->children[parent->num_children++] = node; parent->children[parent->num_children++] = node;
memcpy(&node->info, &elem.generic[0], sizeof(node->info)); node->info = elem;
return 0; return 0;
} }
...@@ -238,7 +238,7 @@ ice_sched_remove_elems(struct ice_hw *hw, struct ice_sched_node *parent, ...@@ -238,7 +238,7 @@ ice_sched_remove_elems(struct ice_hw *hw, struct ice_sched_node *parent,
enum ice_status status; enum ice_status status;
u16 buf_size; u16 buf_size;
buf_size = sizeof(*buf) + sizeof(u32) * (num_nodes - 1); buf_size = struct_size(buf, teid, num_nodes);
buf = devm_kzalloc(ice_hw_to_dev(hw), buf_size, GFP_KERNEL); buf = devm_kzalloc(ice_hw_to_dev(hw), buf_size, GFP_KERNEL);
if (!buf) if (!buf)
return ICE_ERR_NO_MEMORY; return ICE_ERR_NO_MEMORY;
...@@ -423,7 +423,7 @@ ice_aq_add_sched_elems(struct ice_hw *hw, u16 grps_req, ...@@ -423,7 +423,7 @@ ice_aq_add_sched_elems(struct ice_hw *hw, u16 grps_req,
*/ */
static enum ice_status static enum ice_status
ice_aq_cfg_sched_elems(struct ice_hw *hw, u16 elems_req, ice_aq_cfg_sched_elems(struct ice_hw *hw, u16 elems_req,
struct ice_aqc_conf_elem *buf, u16 buf_size, struct ice_aqc_txsched_elem_data *buf, u16 buf_size,
u16 *elems_cfgd, struct ice_sq_cd *cd) u16 *elems_cfgd, struct ice_sq_cd *cd)
{ {
return ice_aqc_send_sched_elem_cmd(hw, ice_aqc_opc_cfg_sched_elems, return ice_aqc_send_sched_elem_cmd(hw, ice_aqc_opc_cfg_sched_elems,
...@@ -443,8 +443,7 @@ ice_aq_cfg_sched_elems(struct ice_hw *hw, u16 elems_req, ...@@ -443,8 +443,7 @@ ice_aq_cfg_sched_elems(struct ice_hw *hw, u16 elems_req,
* Suspend scheduling elements (0x0409) * Suspend scheduling elements (0x0409)
*/ */
static enum ice_status static enum ice_status
ice_aq_suspend_sched_elems(struct ice_hw *hw, u16 elems_req, ice_aq_suspend_sched_elems(struct ice_hw *hw, u16 elems_req, __le32 *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_aqc_send_sched_elem_cmd(hw, ice_aqc_opc_suspend_sched_elems, return ice_aqc_send_sched_elem_cmd(hw, ice_aqc_opc_suspend_sched_elems,
...@@ -464,8 +463,7 @@ ice_aq_suspend_sched_elems(struct ice_hw *hw, u16 elems_req, ...@@ -464,8 +463,7 @@ ice_aq_suspend_sched_elems(struct ice_hw *hw, u16 elems_req,
* resume scheduling elements (0x040A) * resume scheduling elements (0x040A)
*/ */
static enum ice_status static enum ice_status
ice_aq_resume_sched_elems(struct ice_hw *hw, u16 elems_req, ice_aq_resume_sched_elems(struct ice_hw *hw, u16 elems_req, __le32 *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_aqc_send_sched_elem_cmd(hw, ice_aqc_opc_resume_sched_elems, return ice_aqc_send_sched_elem_cmd(hw, ice_aqc_opc_resume_sched_elems,
...@@ -506,9 +504,9 @@ static enum ice_status ...@@ -506,9 +504,9 @@ static enum ice_status
ice_sched_suspend_resume_elems(struct ice_hw *hw, u8 num_nodes, u32 *node_teids, ice_sched_suspend_resume_elems(struct ice_hw *hw, u8 num_nodes, u32 *node_teids,
bool suspend) bool suspend)
{ {
struct ice_aqc_suspend_resume_elem *buf;
u16 i, buf_size, num_elem_ret = 0; u16 i, buf_size, num_elem_ret = 0;
enum ice_status status; enum ice_status status;
__le32 *buf;
buf_size = sizeof(*buf) * num_nodes; buf_size = sizeof(*buf) * num_nodes;
buf = devm_kzalloc(ice_hw_to_dev(hw), buf_size, GFP_KERNEL); buf = devm_kzalloc(ice_hw_to_dev(hw), buf_size, GFP_KERNEL);
...@@ -516,7 +514,7 @@ ice_sched_suspend_resume_elems(struct ice_hw *hw, u8 num_nodes, u32 *node_teids, ...@@ -516,7 +514,7 @@ ice_sched_suspend_resume_elems(struct ice_hw *hw, u8 num_nodes, u32 *node_teids,
return ICE_ERR_NO_MEMORY; return ICE_ERR_NO_MEMORY;
for (i = 0; i < num_nodes; i++) for (i = 0; i < num_nodes; i++)
buf->teid[i] = cpu_to_le32(node_teids[i]); buf[i] = cpu_to_le32(node_teids[i]);
if (suspend) if (suspend)
status = ice_aq_suspend_sched_elems(hw, num_nodes, buf, status = ice_aq_suspend_sched_elems(hw, num_nodes, buf,
...@@ -591,7 +589,7 @@ ice_alloc_lan_q_ctx(struct ice_hw *hw, u16 vsi_handle, u8 tc, u16 new_numqs) ...@@ -591,7 +589,7 @@ ice_alloc_lan_q_ctx(struct ice_hw *hw, u16 vsi_handle, u8 tc, u16 new_numqs)
*/ */
static enum ice_status static enum ice_status
ice_aq_rl_profile(struct ice_hw *hw, enum ice_adminq_opc opcode, ice_aq_rl_profile(struct ice_hw *hw, enum ice_adminq_opc opcode,
u16 num_profiles, struct ice_aqc_rl_profile_generic_elem *buf, u16 num_profiles, struct ice_aqc_rl_profile_elem *buf,
u16 buf_size, u16 *num_processed, struct ice_sq_cd *cd) u16 buf_size, u16 *num_processed, struct ice_sq_cd *cd)
{ {
struct ice_aqc_rl_profile *cmd; struct ice_aqc_rl_profile *cmd;
...@@ -622,13 +620,11 @@ ice_aq_rl_profile(struct ice_hw *hw, enum ice_adminq_opc opcode, ...@@ -622,13 +620,11 @@ ice_aq_rl_profile(struct ice_hw *hw, enum ice_adminq_opc opcode,
*/ */
static enum ice_status static enum ice_status
ice_aq_add_rl_profile(struct ice_hw *hw, u16 num_profiles, ice_aq_add_rl_profile(struct ice_hw *hw, u16 num_profiles,
struct ice_aqc_rl_profile_generic_elem *buf, struct ice_aqc_rl_profile_elem *buf, u16 buf_size,
u16 buf_size, u16 *num_profiles_added, u16 *num_profiles_added, struct ice_sq_cd *cd)
struct ice_sq_cd *cd)
{ {
return ice_aq_rl_profile(hw, ice_aqc_opc_add_rl_profiles, return ice_aq_rl_profile(hw, ice_aqc_opc_add_rl_profiles, num_profiles,
num_profiles, buf, buf, buf_size, num_profiles_added, cd);
buf_size, num_profiles_added, cd);
} }
/** /**
...@@ -644,13 +640,12 @@ ice_aq_add_rl_profile(struct ice_hw *hw, u16 num_profiles, ...@@ -644,13 +640,12 @@ ice_aq_add_rl_profile(struct ice_hw *hw, u16 num_profiles,
*/ */
static enum ice_status static enum ice_status
ice_aq_remove_rl_profile(struct ice_hw *hw, u16 num_profiles, ice_aq_remove_rl_profile(struct ice_hw *hw, u16 num_profiles,
struct ice_aqc_rl_profile_generic_elem *buf, struct ice_aqc_rl_profile_elem *buf, u16 buf_size,
u16 buf_size, u16 *num_profiles_removed, u16 *num_profiles_removed, struct ice_sq_cd *cd)
struct ice_sq_cd *cd)
{ {
return ice_aq_rl_profile(hw, ice_aqc_opc_remove_rl_profiles, return ice_aq_rl_profile(hw, ice_aqc_opc_remove_rl_profiles,
num_profiles, buf, num_profiles, buf, buf_size,
buf_size, num_profiles_removed, cd); num_profiles_removed, cd);
} }
/** /**
...@@ -666,7 +661,7 @@ static enum ice_status ...@@ -666,7 +661,7 @@ static enum ice_status
ice_sched_del_rl_profile(struct ice_hw *hw, ice_sched_del_rl_profile(struct ice_hw *hw,
struct ice_aqc_rl_profile_info *rl_info) struct ice_aqc_rl_profile_info *rl_info)
{ {
struct ice_aqc_rl_profile_generic_elem *buf; struct ice_aqc_rl_profile_elem *buf;
u16 num_profiles_removed; u16 num_profiles_removed;
enum ice_status status; enum ice_status status;
u16 num_profiles = 1; u16 num_profiles = 1;
...@@ -675,8 +670,7 @@ ice_sched_del_rl_profile(struct ice_hw *hw, ...@@ -675,8 +670,7 @@ ice_sched_del_rl_profile(struct ice_hw *hw,
return ICE_ERR_IN_USE; return ICE_ERR_IN_USE;
/* Safe to remove profile ID */ /* Safe to remove profile ID */
buf = (struct ice_aqc_rl_profile_generic_elem *) buf = &rl_info->profile;
&rl_info->profile;
status = ice_aq_remove_rl_profile(hw, num_profiles, buf, sizeof(*buf), status = ice_aq_remove_rl_profile(hw, num_profiles, buf, sizeof(*buf),
&num_profiles_removed, NULL); &num_profiles_removed, NULL);
if (status || num_profiles_removed != num_profiles) if (status || num_profiles_removed != num_profiles)
...@@ -831,7 +825,7 @@ ice_sched_add_elems(struct ice_port_info *pi, struct ice_sched_node *tc_node, ...@@ -831,7 +825,7 @@ ice_sched_add_elems(struct ice_port_info *pi, struct ice_sched_node *tc_node,
size_t buf_size; size_t buf_size;
u32 teid; u32 teid;
buf_size = struct_size(buf, generic, num_nodes - 1); buf_size = struct_size(buf, generic, num_nodes);
buf = devm_kzalloc(ice_hw_to_dev(hw), buf_size, GFP_KERNEL); buf = devm_kzalloc(ice_hw_to_dev(hw), buf_size, GFP_KERNEL);
if (!buf) if (!buf)
return ICE_ERR_NO_MEMORY; return ICE_ERR_NO_MEMORY;
...@@ -1867,7 +1861,7 @@ static void ice_sched_rm_unused_rl_prof(struct ice_port_info *pi) ...@@ -1867,7 +1861,7 @@ static void ice_sched_rm_unused_rl_prof(struct ice_port_info *pi)
* @node: pointer to node * @node: pointer to node
* @info: node info to update * @info: node info to update
* *
* It updates the HW DB, and local SW DB of node. It updates the scheduling * Update the HW DB, and local SW DB of node. Update the scheduling
* parameters of node from argument info data buffer (Info->data buf) and * parameters of node from argument info data buffer (Info->data buf) and
* returns success or error on config sched element failure. The caller * returns success or error on config sched element failure. The caller
* needs to hold scheduler lock. * needs to hold scheduler lock.
...@@ -1876,18 +1870,18 @@ static enum ice_status ...@@ -1876,18 +1870,18 @@ static enum ice_status
ice_sched_update_elem(struct ice_hw *hw, struct ice_sched_node *node, ice_sched_update_elem(struct ice_hw *hw, struct ice_sched_node *node,
struct ice_aqc_txsched_elem_data *info) struct ice_aqc_txsched_elem_data *info)
{ {
struct ice_aqc_conf_elem buf; struct ice_aqc_txsched_elem_data buf;
enum ice_status status; enum ice_status status;
u16 elem_cfgd = 0; u16 elem_cfgd = 0;
u16 num_elems = 1; u16 num_elems = 1;
buf.generic[0] = *info; buf = *info;
/* Parent TEID is reserved field in this aq call */ /* Parent TEID is reserved field in this aq call */
buf.generic[0].parent_teid = 0; buf.parent_teid = 0;
/* Element type is reserved field in this aq call */ /* Element type is reserved field in this aq call */
buf.generic[0].data.elem_type = 0; buf.data.elem_type = 0;
/* Flags is reserved field in this aq call */ /* Flags is reserved field in this aq call */
buf.generic[0].data.flags = 0; buf.data.flags = 0;
/* Update HW DB */ /* Update HW DB */
/* Configure element node */ /* Configure element node */
...@@ -2131,9 +2125,9 @@ static struct ice_aqc_rl_profile_info * ...@@ -2131,9 +2125,9 @@ static struct ice_aqc_rl_profile_info *
ice_sched_add_rl_profile(struct ice_port_info *pi, ice_sched_add_rl_profile(struct ice_port_info *pi,
enum ice_rl_type rl_type, u32 bw, u8 layer_num) enum ice_rl_type rl_type, u32 bw, u8 layer_num)
{ {
struct ice_aqc_rl_profile_generic_elem *buf;
struct ice_aqc_rl_profile_info *rl_prof_elem; struct ice_aqc_rl_profile_info *rl_prof_elem;
u16 profiles_added = 0, num_profiles = 1; u16 profiles_added = 0, num_profiles = 1;
struct ice_aqc_rl_profile_elem *buf;
enum ice_status status; enum ice_status status;
struct ice_hw *hw; struct ice_hw *hw;
u8 profile_type; u8 profile_type;
...@@ -2182,8 +2176,7 @@ ice_sched_add_rl_profile(struct ice_port_info *pi, ...@@ -2182,8 +2176,7 @@ ice_sched_add_rl_profile(struct ice_port_info *pi,
rl_prof_elem->profile.max_burst_size = cpu_to_le16(hw->max_burst_size); rl_prof_elem->profile.max_burst_size = cpu_to_le16(hw->max_burst_size);
/* Create new entry in HW DB */ /* Create new entry in HW DB */
buf = (struct ice_aqc_rl_profile_generic_elem *) buf = &rl_prof_elem->profile;
&rl_prof_elem->profile;
status = ice_aq_add_rl_profile(hw, num_profiles, buf, sizeof(*buf), status = ice_aq_add_rl_profile(hw, num_profiles, buf, sizeof(*buf),
&profiles_added, NULL); &profiles_added, NULL);
if (status || profiles_added != num_profiles) if (status || profiles_added != num_profiles)
......
...@@ -56,7 +56,7 @@ struct ice_sched_agg_info { ...@@ -56,7 +56,7 @@ struct ice_sched_agg_info {
/* FW AQ command calls */ /* FW AQ command calls */
enum ice_status enum ice_status
ice_aq_query_sched_elems(struct ice_hw *hw, u16 elems_req, ice_aq_query_sched_elems(struct ice_hw *hw, u16 elems_req,
struct ice_aqc_get_elem *buf, u16 buf_size, struct ice_aqc_txsched_elem_data *buf, u16 buf_size,
u16 *elems_ret, struct ice_sq_cd *cd); u16 *elems_ret, struct ice_sq_cd *cd);
enum ice_status ice_sched_init_port(struct ice_port_info *pi); enum ice_status ice_sched_init_port(struct ice_port_info *pi);
enum ice_status ice_sched_query_res_alloc(struct ice_hw *hw); enum ice_status ice_sched_query_res_alloc(struct ice_hw *hw);
......
...@@ -29,25 +29,17 @@ static const u8 dummy_eth_header[DUMMY_ETH_HDR_LEN] = { 0x2, 0, 0, 0, 0, 0, ...@@ -29,25 +29,17 @@ static const u8 dummy_eth_header[DUMMY_ETH_HDR_LEN] = { 0x2, 0, 0, 0, 0, 0,
0x81, 0, 0, 0}; 0x81, 0, 0, 0};
#define ICE_SW_RULE_RX_TX_ETH_HDR_SIZE \ #define ICE_SW_RULE_RX_TX_ETH_HDR_SIZE \
(sizeof(struct ice_aqc_sw_rules_elem) - \ (offsetof(struct ice_aqc_sw_rules_elem, pdata.lkup_tx_rx.hdr) + \
sizeof(((struct ice_aqc_sw_rules_elem *)0)->pdata) + \ (DUMMY_ETH_HDR_LEN * \
sizeof(struct ice_sw_rule_lkup_rx_tx) + DUMMY_ETH_HDR_LEN - 1) sizeof(((struct ice_sw_rule_lkup_rx_tx *)0)->hdr[0])))
#define ICE_SW_RULE_RX_TX_NO_HDR_SIZE \ #define ICE_SW_RULE_RX_TX_NO_HDR_SIZE \
(sizeof(struct ice_aqc_sw_rules_elem) - \ (offsetof(struct ice_aqc_sw_rules_elem, pdata.lkup_tx_rx.hdr))
sizeof(((struct ice_aqc_sw_rules_elem *)0)->pdata) + \
sizeof(struct ice_sw_rule_lkup_rx_tx) - 1)
#define ICE_SW_RULE_LG_ACT_SIZE(n) \ #define ICE_SW_RULE_LG_ACT_SIZE(n) \
(sizeof(struct ice_aqc_sw_rules_elem) - \ (offsetof(struct ice_aqc_sw_rules_elem, pdata.lg_act.act) + \
sizeof(((struct ice_aqc_sw_rules_elem *)0)->pdata) + \ ((n) * sizeof(((struct ice_sw_rule_lg_act *)0)->act[0])))
sizeof(struct ice_sw_rule_lg_act) - \
sizeof(((struct ice_sw_rule_lg_act *)0)->act) + \
((n) * sizeof(((struct ice_sw_rule_lg_act *)0)->act)))
#define ICE_SW_RULE_VSI_LIST_SIZE(n) \ #define ICE_SW_RULE_VSI_LIST_SIZE(n) \
(sizeof(struct ice_aqc_sw_rules_elem) - \ (offsetof(struct ice_aqc_sw_rules_elem, pdata.vsi_list.vsi) + \
sizeof(((struct ice_aqc_sw_rules_elem *)0)->pdata) + \ ((n) * sizeof(((struct ice_sw_rule_vsi_list *)0)->vsi[0])))
sizeof(struct ice_sw_rule_vsi_list) - \
sizeof(((struct ice_sw_rule_vsi_list *)0)->vsi) + \
((n) * sizeof(((struct ice_sw_rule_vsi_list *)0)->vsi)))
/** /**
* ice_init_def_sw_recp - initialize the recipe book keeping tables * ice_init_def_sw_recp - initialize the recipe book keeping tables
...@@ -87,7 +79,7 @@ enum ice_status ice_init_def_sw_recp(struct ice_hw *hw) ...@@ -87,7 +79,7 @@ enum ice_status ice_init_def_sw_recp(struct ice_hw *hw)
* @num_elems: pointer to number of elements * @num_elems: pointer to number of elements
* @cd: pointer to command details structure or NULL * @cd: pointer to command details structure or NULL
* *
* Get switch configuration (0x0200) to be placed in 'buff'. * Get switch configuration (0x0200) to be placed in buf.
* This admin command returns information such as initial VSI/port number * This admin command returns information such as initial VSI/port number
* and switch ID it belongs to. * and switch ID it belongs to.
* *
...@@ -104,13 +96,13 @@ enum ice_status ice_init_def_sw_recp(struct ice_hw *hw) ...@@ -104,13 +96,13 @@ enum ice_status ice_init_def_sw_recp(struct ice_hw *hw)
* parsing the response buffer. * parsing the response buffer.
*/ */
static enum ice_status static enum ice_status
ice_aq_get_sw_cfg(struct ice_hw *hw, struct ice_aqc_get_sw_cfg_resp *buf, ice_aq_get_sw_cfg(struct ice_hw *hw, struct ice_aqc_get_sw_cfg_resp_elem *buf,
u16 buf_size, u16 *req_desc, u16 *num_elems, u16 buf_size, u16 *req_desc, u16 *num_elems,
struct ice_sq_cd *cd) struct ice_sq_cd *cd)
{ {
struct ice_aqc_get_sw_cfg *cmd; struct ice_aqc_get_sw_cfg *cmd;
enum ice_status status;
struct ice_aq_desc desc; struct ice_aq_desc desc;
enum ice_status status;
ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_get_sw_cfg); ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_get_sw_cfg);
cmd = &desc.params.get_sw_conf; cmd = &desc.params.get_sw_conf;
...@@ -449,7 +441,7 @@ ice_aq_alloc_free_vsi_list(struct ice_hw *hw, u16 *vsi_list_id, ...@@ -449,7 +441,7 @@ ice_aq_alloc_free_vsi_list(struct ice_hw *hw, u16 *vsi_list_id,
enum ice_status status; enum ice_status status;
u16 buf_len; u16 buf_len;
buf_len = sizeof(*sw_buf); buf_len = struct_size(sw_buf, elem, 1);
sw_buf = devm_kzalloc(ice_hw_to_dev(hw), buf_len, GFP_KERNEL); sw_buf = devm_kzalloc(ice_hw_to_dev(hw), buf_len, GFP_KERNEL);
if (!sw_buf) if (!sw_buf)
return ICE_ERR_NO_MEMORY; return ICE_ERR_NO_MEMORY;
...@@ -550,7 +542,7 @@ ice_init_port_info(struct ice_port_info *pi, u16 vsi_port_num, u8 type, ...@@ -550,7 +542,7 @@ ice_init_port_info(struct ice_port_info *pi, u16 vsi_port_num, u8 type,
*/ */
enum ice_status ice_get_initial_sw_cfg(struct ice_hw *hw) enum ice_status ice_get_initial_sw_cfg(struct ice_hw *hw)
{ {
struct ice_aqc_get_sw_cfg_resp *rbuf; struct ice_aqc_get_sw_cfg_resp_elem *rbuf;
enum ice_status status; enum ice_status status;
u16 req_desc = 0; u16 req_desc = 0;
u16 num_elems; u16 num_elems;
...@@ -568,19 +560,19 @@ enum ice_status ice_get_initial_sw_cfg(struct ice_hw *hw) ...@@ -568,19 +560,19 @@ enum ice_status ice_get_initial_sw_cfg(struct ice_hw *hw)
* writing a non-zero value in req_desc * writing a non-zero value in req_desc
*/ */
do { do {
struct ice_aqc_get_sw_cfg_resp_elem *ele;
status = ice_aq_get_sw_cfg(hw, rbuf, ICE_SW_CFG_MAX_BUF_LEN, status = ice_aq_get_sw_cfg(hw, rbuf, ICE_SW_CFG_MAX_BUF_LEN,
&req_desc, &num_elems, NULL); &req_desc, &num_elems, NULL);
if (status) if (status)
break; break;
for (i = 0; i < num_elems; i++) { for (i = 0, ele = rbuf; i < num_elems; i++, ele++) {
struct ice_aqc_get_sw_cfg_resp_elem *ele;
u16 pf_vf_num, swid, vsi_port_num; u16 pf_vf_num, swid, vsi_port_num;
bool is_vf = false; bool is_vf = false;
u8 res_type; u8 res_type;
ele = rbuf[i].elements;
vsi_port_num = le16_to_cpu(ele->vsi_port_num) & vsi_port_num = le16_to_cpu(ele->vsi_port_num) &
ICE_AQC_GET_SW_CONF_RESP_VSI_PORT_NUM_M; ICE_AQC_GET_SW_CONF_RESP_VSI_PORT_NUM_M;
...@@ -856,8 +848,7 @@ ice_add_marker_act(struct ice_hw *hw, struct ice_fltr_mgmt_list_entry *m_ent, ...@@ -856,8 +848,7 @@ ice_add_marker_act(struct ice_hw *hw, struct ice_fltr_mgmt_list_entry *m_ent,
m_ent->fltr_info.fwd_id.hw_vsi_id; m_ent->fltr_info.fwd_id.hw_vsi_id;
act = ICE_LG_ACT_VSI_FORWARDING | ICE_LG_ACT_VALID_BIT; act = ICE_LG_ACT_VSI_FORWARDING | ICE_LG_ACT_VALID_BIT;
act |= (id << ICE_LG_ACT_VSI_LIST_ID_S) & act |= (id << ICE_LG_ACT_VSI_LIST_ID_S) & ICE_LG_ACT_VSI_LIST_ID_M;
ICE_LG_ACT_VSI_LIST_ID_M;
if (m_ent->vsi_count > 1) if (m_ent->vsi_count > 1)
act |= ICE_LG_ACT_VSI_LIST; act |= ICE_LG_ACT_VSI_LIST;
lg_act->pdata.lg_act.act[0] = cpu_to_le32(act); lg_act->pdata.lg_act.act[0] = cpu_to_le32(act);
...@@ -2037,7 +2028,8 @@ ice_cfg_dflt_vsi(struct ice_hw *hw, u16 vsi_handle, bool set, u8 direction) ...@@ -2037,7 +2028,8 @@ ice_cfg_dflt_vsi(struct ice_hw *hw, u16 vsi_handle, bool set, u8 direction)
hw_vsi_id = ice_get_hw_vsi_num(hw, vsi_handle); hw_vsi_id = ice_get_hw_vsi_num(hw, vsi_handle);
s_rule_size = set ? ICE_SW_RULE_RX_TX_ETH_HDR_SIZE : s_rule_size = set ? ICE_SW_RULE_RX_TX_ETH_HDR_SIZE :
ICE_SW_RULE_RX_TX_NO_HDR_SIZE; ICE_SW_RULE_RX_TX_NO_HDR_SIZE;
s_rule = devm_kzalloc(ice_hw_to_dev(hw), s_rule_size, GFP_KERNEL); s_rule = devm_kzalloc(ice_hw_to_dev(hw), s_rule_size, GFP_KERNEL);
if (!s_rule) if (!s_rule)
return ICE_ERR_NO_MEMORY; return ICE_ERR_NO_MEMORY;
...@@ -2691,7 +2683,7 @@ ice_alloc_res_cntr(struct ice_hw *hw, u8 type, u8 alloc_shared, u16 num_items, ...@@ -2691,7 +2683,7 @@ ice_alloc_res_cntr(struct ice_hw *hw, u8 type, u8 alloc_shared, u16 num_items,
u16 buf_len; u16 buf_len;
/* Allocate resource */ /* Allocate resource */
buf_len = sizeof(*buf); buf_len = struct_size(buf, elem, 1);
buf = kzalloc(buf_len, GFP_KERNEL); buf = kzalloc(buf_len, GFP_KERNEL);
if (!buf) if (!buf)
return ICE_ERR_NO_MEMORY; return ICE_ERR_NO_MEMORY;
...@@ -2729,7 +2721,7 @@ ice_free_res_cntr(struct ice_hw *hw, u8 type, u8 alloc_shared, u16 num_items, ...@@ -2729,7 +2721,7 @@ ice_free_res_cntr(struct ice_hw *hw, u8 type, u8 alloc_shared, u16 num_items,
u16 buf_len; u16 buf_len;
/* Free resource */ /* Free resource */
buf_len = sizeof(*buf); buf_len = struct_size(buf, elem, 1);
buf = kzalloc(buf_len, GFP_KERNEL); buf = kzalloc(buf_len, GFP_KERNEL);
if (!buf) if (!buf)
return ICE_ERR_NO_MEMORY; return ICE_ERR_NO_MEMORY;
......
...@@ -206,12 +206,14 @@ static int ice_qp_ena(struct ice_vsi *vsi, u16 q_idx) ...@@ -206,12 +206,14 @@ static int ice_qp_ena(struct ice_vsi *vsi, u16 q_idx)
struct ice_aqc_add_tx_qgrp *qg_buf; struct ice_aqc_add_tx_qgrp *qg_buf;
struct ice_ring *tx_ring, *rx_ring; struct ice_ring *tx_ring, *rx_ring;
struct ice_q_vector *q_vector; struct ice_q_vector *q_vector;
u16 size;
int err; int err;
if (q_idx >= vsi->num_rxq || q_idx >= vsi->num_txq) if (q_idx >= vsi->num_rxq || q_idx >= vsi->num_txq)
return -EINVAL; return -EINVAL;
qg_buf = kzalloc(sizeof(*qg_buf), GFP_KERNEL); size = struct_size(qg_buf, txqs, 1);
qg_buf = kzalloc(size, GFP_KERNEL);
if (!qg_buf) if (!qg_buf)
return -ENOMEM; return -ENOMEM;
...@@ -228,7 +230,7 @@ static int ice_qp_ena(struct ice_vsi *vsi, u16 q_idx) ...@@ -228,7 +230,7 @@ static int ice_qp_ena(struct ice_vsi *vsi, u16 q_idx)
if (ice_is_xdp_ena_vsi(vsi)) { if (ice_is_xdp_ena_vsi(vsi)) {
struct ice_ring *xdp_ring = vsi->xdp_rings[q_idx]; struct ice_ring *xdp_ring = vsi->xdp_rings[q_idx];
memset(qg_buf, 0, sizeof(*qg_buf)); memset(qg_buf, 0, size);
qg_buf->num_txqs = 1; qg_buf->num_txqs = 1;
err = ice_vsi_cfg_txq(vsi, xdp_ring, qg_buf); err = ice_vsi_cfg_txq(vsi, xdp_ring, qg_buf);
if (err) if (err)
......
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