ice: refactor functions to make them static
Subsystems (2)
PATCH 1/2 ice: refactor functions to make them static
Some methods in ice codebase are not used outside the files they're defined in. These can safely be made static.
--- drivers/net/ethernet/intel/ice/ice_ddp.c | 183 +++---- drivers/net/ethernet/intel/ice/ice_ddp.h | 10 - drivers/net/ethernet/intel/ice/ice_lib.c | 70 +-- drivers/net/ethernet/intel/ice/ice_lib.h | 3 - drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 8 +- drivers/net/ethernet/intel/ice/ice_ptp_hw.h | 4 - drivers/net/ethernet/intel/ice/ice_sched.c | 2 +- drivers/net/ethernet/intel/ice/ice_sched.h | 4 - drivers/net/ethernet/intel/ice/ice_vf_lib.c | 486 +++++++++--------- .../ethernet/intel/ice/ice_vf_lib_private.h | 3 - 10 files changed, 375 insertions(+), 398 deletions(-)
drivers/net/ethernet/intel/ice/ice_ddp.c +92 -91
@@ -30,7 +30,7 @@ static const struct ice_tunnel_type_scan tnls[] = {* Verifies various attributes of the package file, including length, format * version, and the requirement of at least one segment. */ -enum ice_ddp_state ice_verify_pkg (struct ice_pkg_hdr *pkg,u32 len) +static enum ice_ddp_state ice_verify_pkg (struct ice_pkg_hdr *pkg,u32 len) {u32 seg_count;u32 i;
@@ -118,7 +118,7 @@ static enum ice_ddp_state ice_chk_pkg_version(struct ice_pkg_ver *pkg_ver)* * This helper function validates a buffer's header. */ -struct ice_buf_hdr *ice_pkg_val_buf (struct ice_buf *buf) +static struct ice_buf_hdr *ice_pkg_val_buf (struct ice_buf *buf) {struct ice_buf_hdr *hdr;u16 section_count;
@@ -1152,6 +1152,53 @@ static void ice_release_global_cfg_lock(struct ice_hw *hw)ice_release_res (hw,ICE_GLOBAL_CFG_LOCK_RES_ID ); } +/** +* ice_aq_download_pkg +* @hw: pointer to the hardware structure +* @pkg_buf: the package buffer to transfer +* @buf_size: the size of the package buffer +* @last_buf: last buffer indicator +* @error_offset: returns error offset +* @error_info: returns error information +* @cd: pointer to command details structure or NULL +* +* Download Package (0x0C40) +*/ +static int ice_aq_download_pkg (struct ice_hw *hw,struct ice_buf_hdr *pkg_buf, +u16 buf_size,bool last_buf,u32 *error_offset, +u32 *error_info,struct ice_sq_cd *cd) +{ +struct ice_aqc_download_pkg *cmd; +struct ice_aq_desc desc; +int status; + +if (error_offset) + *error_offset =0 ; +if (error_info) + *error_info =0 ; + + cmd = &desc.params.download_pkg; +ice_fill_dflt_direct_cmd_desc (&desc, ice_aqc_opc_download_pkg); + desc.flags |=cpu_to_le16 (ICE_AQ_FLAG_RD ); + +if (last_buf) + cmd->flags |=ICE_AQC_DOWNLOAD_PKG_LAST_BUF ; + + status =ice_aq_send_cmd (hw, &desc, pkg_buf, buf_size, cd); +if (status == -EIO ) { +/* Read error from buffer only when the FW returned an error */ +struct ice_aqc_download_pkg_resp *resp; + + resp = (struct ice_aqc_download_pkg_resp *)pkg_buf; +if (error_offset) + *error_offset =le32_to_cpu (resp->error_offset); +if (error_info) + *error_info =le32_to_cpu (resp->error_info); + } + +return status; +} +/** * ice_dwnld_cfg_bufs * @hw: pointer to the hardware structure
@@ -1294,70 +1341,39 @@ static enum ice_ddp_state ice_download_pkg(struct ice_hw *hw, }/** -* ice_aq_download_pkg +* ice_find_seg_in_pkg * @hw: pointer to the hardware structure -* @pkg_buf: the package buffer to transfer -* @buf_size: the size of the package buffer -* @last_buf: last buffer indicator -* @error_offset: returns error offset -* @error_info: returns error information -* @cd: pointer to command details structure or NULL +* @seg_type: the segment type to search for (i.e., SEGMENT_TYPE_CPK) +* @pkg_hdr: pointer to the package header to be searched * -* Download Package (0x0C40) +* This function searches a package file for a particular segment type. On +* success it returns a pointer to the segment header, otherwise it will +* return NULL. */ -int ice_aq_download_pkg (struct ice_hw *hw,struct ice_buf_hdr *pkg_buf, -u16 buf_size,bool last_buf,u32 *error_offset, -u32 *error_info,struct ice_sq_cd *cd) +static struct ice_generic_seg_hdr * +ice_find_seg_in_pkg (struct ice_hw *hw,u32 seg_type, +struct ice_pkg_hdr *pkg_hdr) { -struct ice_aqc_download_pkg *cmd; -struct ice_aq_desc desc; -int status; - -if (error_offset) - *error_offset =0 ; -if (error_info) - *error_info =0 ; +u32 i; - cmd = &desc.params.download_pkg; -ice_fill_dflt_direct_cmd_desc (&desc, ice_aqc_opc_download_pkg); - desc.flags |=cpu_to_le16 (ICE_AQ_FLAG_RD ); +ice_debug (hw,ICE_DBG_PKG ,"Package format version: %d.%d.%d.%d\n" , + pkg_hdr->pkg_format_ver.major, pkg_hdr->pkg_format_ver.minor, + pkg_hdr->pkg_format_ver.update, + pkg_hdr->pkg_format_ver.draft); -if (last_buf) - cmd->flags |=ICE_AQC_DOWNLOAD_PKG_LAST_BUF ; +/* Search all package segments for the requested segment type */ +for (i =0 ; i <le32_to_cpu (pkg_hdr->seg_count); i++) { +struct ice_generic_seg_hdr *seg; - status =ice_aq_send_cmd (hw, &desc, pkg_buf, buf_size, cd); -if (status == -EIO ) { -/* Read error from buffer only when the FW returned an error */ -struct ice_aqc_download_pkg_resp *resp; + seg = (struct ice_generic_seg_hdr + *)((u8 *)pkg_hdr + +le32_to_cpu (pkg_hdr->seg_offset[i])); - resp = (struct ice_aqc_download_pkg_resp *)pkg_buf; -if (error_offset) - *error_offset =le32_to_cpu (resp->error_offset); -if (error_info) - *error_info =le32_to_cpu (resp->error_info); +if (le32_to_cpu (seg->seg_type) == seg_type) +return seg; } -return status; -} - -/** -* ice_aq_upload_section -* @hw: pointer to the hardware structure -* @pkg_buf: the package buffer which will receive the section -* @buf_size: the size of the package buffer -* @cd: pointer to command details structure or NULL -* -* Upload Section (0x0C41) -*/ -int ice_aq_upload_section (struct ice_hw *hw,struct ice_buf_hdr *pkg_buf, -u16 buf_size,struct ice_sq_cd *cd) -{ -struct ice_aq_desc desc; - -ice_fill_dflt_direct_cmd_desc (&desc, ice_aqc_opc_upload_section); - desc.flags |=cpu_to_le16 (ICE_AQ_FLAG_RD ); - -return ice_aq_send_cmd (hw, &desc, pkg_buf, buf_size, cd); +return NULL ; }/**
@@ -1407,6 +1423,26 @@ static int ice_aq_update_pkg(struct ice_hw *hw, struct ice_buf_hdr *pkg_buf,return status; } +/** +* ice_aq_upload_section +* @hw: pointer to the hardware structure +* @pkg_buf: the package buffer which will receive the section +* @buf_size: the size of the package buffer +* @cd: pointer to command details structure or NULL +* +* Upload Section (0x0C41) +*/ +int ice_aq_upload_section (struct ice_hw *hw,struct ice_buf_hdr *pkg_buf, +u16 buf_size,struct ice_sq_cd *cd) +{ +struct ice_aq_desc desc; + +ice_fill_dflt_direct_cmd_desc (&desc, ice_aqc_opc_upload_section); + desc.flags |=cpu_to_le16 (ICE_AQ_FLAG_RD ); + +return ice_aq_send_cmd (hw, &desc, pkg_buf, buf_size, cd); +} +/** * ice_update_pkg_no_lock * @hw: pointer to the hardware structure
@@ -1460,41 +1496,6 @@ int ice_update_pkg(struct ice_hw *hw, struct ice_buf *bufs, u32 count)return status; } -/** -* ice_find_seg_in_pkg -* @hw: pointer to the hardware structure -* @seg_type: the segment type to search for (i.e., SEGMENT_TYPE_CPK) -* @pkg_hdr: pointer to the package header to be searched -* -* This function searches a package file for a particular segment type. On -* success it returns a pointer to the segment header, otherwise it will -* return NULL. -*/ -struct ice_generic_seg_hdr *ice_find_seg_in_pkg (struct ice_hw *hw,u32 seg_type, -struct ice_pkg_hdr *pkg_hdr) -{ -u32 i; - -ice_debug (hw,ICE_DBG_PKG ,"Package format version: %d.%d.%d.%d\n" , - pkg_hdr->pkg_format_ver.major, pkg_hdr->pkg_format_ver.minor, - pkg_hdr->pkg_format_ver.update, - pkg_hdr->pkg_format_ver.draft); - -/* Search all package segments for the requested segment type */ -for (i =0 ; i <le32_to_cpu (pkg_hdr->seg_count); i++) { -struct ice_generic_seg_hdr *seg; - - seg = (struct ice_generic_seg_hdr - *)((u8 *)pkg_hdr + -le32_to_cpu (pkg_hdr->seg_offset[i])); - -if (le32_to_cpu (seg->seg_type) == seg_type) -return seg; - } - -return NULL ; -} -/** * ice_init_pkg_info * @hw: pointer to the hardware structure
drivers/net/ethernet/intel/ice/ice_ddp.h +0 -10
@@ -416,21 +416,13 @@ struct ice_pkg_enum {void *(*handler)(u32 sect_type,void *section,u32 index,u32 *offset); }; -int ice_aq_download_pkg (struct ice_hw *hw,struct ice_buf_hdr *pkg_buf, -u16 buf_size,bool last_buf,u32 *error_offset, -u32 *error_info,struct ice_sq_cd *cd);int ice_aq_upload_section (struct ice_hw *hw,struct ice_buf_hdr *pkg_buf,u16 buf_size,struct ice_sq_cd *cd);void *ice_pkg_buf_alloc_section (struct ice_buf_build *bld,u32 type,u16 size); -enum ice_ddp_state ice_verify_pkg (struct ice_pkg_hdr *pkg,u32 len); -struct ice_buf_build *ice_pkg_buf_alloc (struct ice_hw *hw); -struct ice_generic_seg_hdr *ice_find_seg_in_pkg (struct ice_hw *hw,u32 seg_type, -struct ice_pkg_hdr *pkg_hdr); -int ice_update_pkg_no_lock (struct ice_hw *hw,struct ice_buf *bufs,u32 count);int ice_update_pkg (struct ice_hw *hw,struct ice_buf *bufs,u32 count);
@@ -439,6 +431,4 @@ u16 ice_pkg_buf_get_active_sections(struct ice_buf_build *bld);void *ice_pkg_enum_section (struct ice_seg *ice_seg,struct ice_pkg_enum *state,u32 sect_type); -struct ice_buf_hdr *ice_pkg_val_buf (struct ice_buf *buf); -#endif
drivers/net/ethernet/intel/ice/ice_lib.c +35 -35
94 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_lib.h +0 -3
@@ -76,8 +76,6 @@ int ice_vsi_cfg_xdp_txqs(struct ice_vsi *vsi);int ice_vsi_stop_xdp_tx_rings (struct ice_vsi *vsi); -bool ice_vsi_is_vlan_pruning_ena (struct ice_vsi *vsi); -void ice_cfg_sw_lldp (struct ice_vsi *vsi,bool tx,bool create);int ice_set_link (struct ice_vsi *vsi,bool ena);
@@ -130,7 +128,6 @@ void ice_update_tx_ring_stats(struct ice_tx_ring *ring, u64 pkts, u64 bytes);void ice_update_rx_ring_stats (struct ice_rx_ring *ring,u64 pkts,u64 bytes); -void ice_vsi_cfg_frame_size (struct ice_vsi *vsi);void ice_write_intrl (struct ice_q_vector *q_vector,u8 intrl);void ice_write_itr (struct ice_ring_container *rc,u16 itr);void ice_set_q_vector_intrl (struct ice_q_vector *q_vector);
drivers/net/ethernet/intel/ice/ice_ptp_hw.c +4 -4
@@ -305,7 +305,7 @@ static bool ice_is_40b_phy_reg_e822(u16 low_addr, u16 *high_addr)* * Read a PHY register for the given port over the device sideband queue. */ -int +static int ice_read_phy_reg_e822 (struct ice_hw *hw,u8 port,u16 offset,u32 *val) {struct ice_sbq_msg_input msg = {0 };
@@ -382,7 +382,7 @@ ice_read_64b_phy_reg_e822(struct ice_hw *hw, u8 port, u16 low_addr, u64 *val)* * Write a PHY register for the given port over the device sideband queue. */ -int +static int ice_write_phy_reg_e822 (struct ice_hw *hw,u8 port,u16 offset,u32 val) {struct ice_sbq_msg_input msg = {0 };
@@ -1091,7 +1091,7 @@ ice_ptp_prep_phy_time_e822(struct ice_hw *hw, u32 time)* * Negative adjustments are supported using 2s complement arithmetic. */ -int +static int ice_ptp_prep_port_adj_e822 (struct ice_hw *hw,u8 port,s64 time) {u32 l_time, u_time;
@@ -2692,7 +2692,7 @@ static int ice_clear_phy_tstamp_e810(struct ice_hw *hw, u8 lport, u8 idx)* Enable the timesync PTP functionality for the external PHY connected to * this function. */ -int ice_ptp_init_phy_e810 (struct ice_hw *hw) +static int ice_ptp_init_phy_e810 (struct ice_hw *hw) {u8 tmr_idx;int err;
drivers/net/ethernet/intel/ice/ice_ptp_hw.h +0 -4
@@ -143,11 +143,8 @@ int ice_ptp_init_phc(struct ice_hw *hw);int ice_get_phy_tx_tstamp_ready (struct ice_hw *hw,u8 block,u64 *tstamp_ready);/* E822 family functions */ -int ice_read_phy_reg_e822 (struct ice_hw *hw,u8 port,u16 offset,u32 *val); -int ice_write_phy_reg_e822 (struct ice_hw *hw,u8 port,u16 offset,u32 val);int ice_read_quad_reg_e822 (struct ice_hw *hw,u8 quad,u16 offset,u32 *val);int ice_write_quad_reg_e822 (struct ice_hw *hw,u8 quad,u16 offset,u32 val); -int ice_ptp_prep_port_adj_e822 (struct ice_hw *hw,u8 port,s64 time);void ice_ptp_reset_ts_memory_quad_e822 (struct ice_hw *hw,u8 quad);/**
@@ -197,7 +194,6 @@ int ice_phy_cfg_tx_offset_e822(struct ice_hw *hw, u8 port);int ice_phy_cfg_rx_offset_e822 (struct ice_hw *hw,u8 port);/* E810 family functions */ -int ice_ptp_init_phy_e810 (struct ice_hw *hw);int ice_read_sma_ctrl_e810t (struct ice_hw *hw,u8 *data);int ice_write_sma_ctrl_e810t (struct ice_hw *hw,u8 data);int ice_read_pca9575_reg_e810t (struct ice_hw *hw,u8 offset,u8 *data);
drivers/net/ethernet/intel/ice/ice_sched.c +1 -1
@@ -3971,7 +3971,7 @@ ice_sched_get_node_by_id_type(struct ice_port_info *pi, u32 id,* This function sets BW limit of VSI or Aggregator scheduling node * based on TC information from passed in argument BW. */ -int +static int ice_sched_set_node_bw_lmt_per_tc (struct ice_port_info *pi,u32 id,enum ice_agg_type agg_type,u8 tc,enum ice_rl_type rl_type,u32 bw)
drivers/net/ethernet/intel/ice/ice_sched.h +0 -4
@@ -141,10 +141,6 @@ ice_cfg_vsi_bw_lmt_per_tc(struct ice_port_info *pi, u16 vsi_handle, u8 tc,int ice_cfg_vsi_bw_dflt_lmt_per_tc (struct ice_port_info *pi,u16 vsi_handle,u8 tc,enum ice_rl_type rl_type); -int -ice_sched_set_node_bw_lmt_per_tc (struct ice_port_info *pi,u32 id, -enum ice_agg_type agg_type,u8 tc, -enum ice_rl_type rl_type,u32 bw);int ice_cfg_rl_burst_size (struct ice_hw *hw,u32 bytes); int ice_sched_suspend_resume_elems(struct ice_hw *hw, u8 num_nodes, u32 *node_teids,
drivers/net/ethernet/intel/ice/ice_vf_lib.c +243 -243
516 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_vf_lib_private.h +0 -3
@@ -32,13 +32,10 @@ int ice_vsi_apply_spoofchk(struct ice_vsi *vsi, bool enable);bool ice_is_vf_trusted (struct ice_vf *vf);bool ice_vf_has_no_qs_ena (struct ice_vf *vf);bool ice_is_vf_link_up (struct ice_vf *vf); -void ice_vf_rebuild_host_cfg (struct ice_vf *vf); -void ice_vf_ctrl_invalidate_vsi (struct ice_vf *vf);void ice_vf_ctrl_vsi_release (struct ice_vf *vf);struct ice_vsi *ice_vf_ctrl_vsi_setup (struct ice_vf *vf);int ice_vf_init_host_cfg (struct ice_vf *vf,struct ice_vsi *vsi);void ice_vf_invalidate_vsi (struct ice_vf *vf);void ice_vf_vsi_release (struct ice_vf *vf); -void ice_vf_set_initialized (struct ice_vf *vf);#endif /* _ICE_VF_LIB_PRIVATE_H_ */
Signature · 6 lines
2.31.1 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
PATCH 2/2 ice: remove unused methods
Following methods were found to no longer be in use:ice_is_pca9575_presentice_mac_fltr_existice_napi_del
Remove them.
--- drivers/net/ethernet/intel/ice/ice_lib.c | 15 ------- drivers/net/ethernet/intel/ice/ice_lib.h | 2 - drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 19 -------- drivers/net/ethernet/intel/ice/ice_ptp_hw.h | 1 - drivers/net/ethernet/intel/ice/ice_switch.c | 48 --------------------- drivers/net/ethernet/intel/ice/ice_switch.h | 1 - 6 files changed, 86 deletions(-)
drivers/net/ethernet/intel/ice/ice_lib.c +0 -15
@@ -2943,21 +2943,6 @@ void ice_vsi_dis_irq(struct ice_vsi *vsi)synchronize_irq (vsi->q_vectors[i]->irq.virq); } -/** -* ice_napi_del - Remove NAPI handler for the VSI -* @vsi: VSI for which NAPI handler is to be removed -*/ -void ice_napi_del (struct ice_vsi *vsi) -{ -int v_idx; - -if (!vsi->netdev) -return ; - -ice_for_each_q_vector (vsi, v_idx) -netif_napi_del (&vsi->q_vectors[v_idx]->napi); -} -/** * ice_vsi_release - Delete a VSI and free its resources * @vsi: the VSI being removed
drivers/net/ethernet/intel/ice/ice_lib.h +0 -2
@@ -91,8 +91,6 @@ void ice_vsi_cfg_netdev_tc(struct ice_vsi *vsi, u8 ena_tc);struct ice_vsi *ice_vsi_setup (struct ice_pf *pf,struct ice_vsi_cfg_params *params); -void ice_napi_del (struct ice_vsi *vsi); -int ice_vsi_release (struct ice_vsi *vsi);void ice_vsi_close (struct ice_vsi *vsi);
drivers/net/ethernet/intel/ice/ice_ptp_hw.c +0 -19
@@ -3063,25 +3063,6 @@ int ice_read_pca9575_reg_e810t(struct ice_hw *hw, u8 offset, u8 *data)return ice_aq_read_i2c (hw, link_topo,0 , addr,1 , data,NULL ); } -/** -* ice_is_pca9575_present -* @hw: pointer to the hw struct -* -* Check if the SW IO expander is present in the netlist -*/ -bool ice_is_pca9575_present (struct ice_hw *hw) -{ -u16 handle =0 ; -int status; - -if (!ice_is_e810t (hw)) -return false; - - status =ice_get_pca9575_handle (hw, &handle); - -return !status && handle; -} -/* Device agnostic functions * * The following functions implement shared behavior common to both E822 and
drivers/net/ethernet/intel/ice/ice_ptp_hw.h +0 -1
@@ -197,7 +197,6 @@ int ice_phy_cfg_rx_offset_e822(struct ice_hw *hw, u8 port);int ice_read_sma_ctrl_e810t (struct ice_hw *hw,u8 *data);int ice_write_sma_ctrl_e810t (struct ice_hw *hw,u8 data);int ice_read_pca9575_reg_e810t (struct ice_hw *hw,u8 offset,u8 *data); -bool ice_is_pca9575_present (struct ice_hw *hw);void ice_ptp_init_phy_model (struct ice_hw *hw);
drivers/net/ethernet/intel/ice/ice_switch.c +0 -48
54 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_switch.h +0 -1
@@ -371,7 +371,6 @@ int ice_add_vlan(struct ice_hw *hw, struct list_head *m_list);int ice_remove_vlan (struct ice_hw *hw,struct list_head *v_list);int ice_add_mac (struct ice_hw *hw,struct list_head *m_lst);int ice_remove_mac (struct ice_hw *hw,struct list_head *m_lst); -bool ice_mac_fltr_exist (struct ice_hw *hw,u8 *mac,u16 vsi_handle);bool ice_vlan_fltr_exist (struct ice_hw *hw,u16 vlan_id,u16 vsi_handle);int ice_add_eth_mac (struct ice_hw *hw,struct list_head *em_list);int ice_remove_eth_mac (struct ice_hw *hw,struct list_head *em_list);
Signature · 6 lines
2.31.1 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
From: Jan Sokolowski <[email protected]>
Date: Wed, 26 Jul 2023 09:53:13 +0200
Quoted 4 lines
Some methods in ice codebase are not used outside the files they're defined in. These can safely be made static.
Signed-off-by Jan Sokolowski <[email protected]>
Quoted 12 lines
--- drivers/net/ethernet/intel/ice/ice_ddp.c | 183 +++---- drivers/net/ethernet/intel/ice/ice_ddp.h | 10 - drivers/net/ethernet/intel/ice/ice_lib.c | 70 +-- drivers/net/ethernet/intel/ice/ice_lib.h | 3 - drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 8 +- drivers/net/ethernet/intel/ice/ice_ptp_hw.h | 4 - drivers/net/ethernet/intel/ice/ice_sched.c | 2 +- drivers/net/ethernet/intel/ice/ice_sched.h | 4 - drivers/net/ethernet/intel/ice/ice_vf_lib.c | 486 +++++++++--------- .../ethernet/intel/ice/ice_vf_lib_private.h | 3 - 10 files changed, 375 insertions(+), 398 deletions(-)
Too much for one commit. It is not atomic, I don't think there is enough reasons to do it that way.
[...]
Thanks,
Olek
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan