bnx2x: namespace and dead code cleanups
PATCH 1/1 bnx2x: namespace and dead code cleanups
Fix a bunch of whole lot of namespace issues with the Broadcom bnx2x driver found by running 'make namespacecheck'
* global variables must be prefixed with bnx2x_
naming a variable int_mode, or num_queue is invitation to disaster
* make local functions static
* move some inline's used in one file out of header (this driver has a bad case of inline-itis)
* remove resulting dead code fallout
bnx2x_pfc_statistic,
bnx2x_emac_get_pfc_stat
bnx2x_init_vlan_mac_obj,
Looks like vlan mac support in this driver was a botch from day one either never worked, or not implemented or missing support functions
Compile tested only.
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x.h | 1 drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 67 ++++- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h | 124 ---------- drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c | 62 ----- drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h | 10 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 91 +++++-- drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c | 264 ---------------------- drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h | 13 - drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c | 8 drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h | 14 - drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c | 17 - 11 files changed, 147 insertions(+), 524 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +52 -15
@@ -30,6 +30,43 @@#include "bnx2x_init.h" #include "bnx2x_sp.h" +static void bnx2x_free_fp_mem_cnic (struct bnx2x *bp); +static int bnx2x_alloc_fp_mem_cnic (struct bnx2x *bp); +static int bnx2x_alloc_fp_mem (struct bnx2x *bp); +static int bnx2x_poll (struct napi_struct *napi,int budget); + +static void bnx2x_add_all_napi_cnic (struct bnx2x *bp) +{ +int i; + +/* Add NAPI objects */ +for_each_rx_queue_cnic (bp, i) { +netif_napi_add (bp->dev, &bnx2x_fp (bp, i, napi), + bnx2x_poll,NAPI_POLL_WEIGHT ); +napi_hash_add (&bnx2x_fp (bp, i, napi)); + } +} + +static void bnx2x_add_all_napi (struct bnx2x *bp) +{ +int i; + +/* Add NAPI objects */ +for_each_eth_queue (bp, i) { +netif_napi_add (bp->dev, &bnx2x_fp (bp, i, napi), + bnx2x_poll,NAPI_POLL_WEIGHT ); +napi_hash_add (&bnx2x_fp (bp, i, napi)); + } +} + +static int bnx2x_calc_num_queues (struct bnx2x *bp) +{ +return bnx2x_num_queues ? +min_t (int, bnx2x_num_queues,BNX2X_MAX_QUEUES (bp)) : +min_t (int,netif_get_num_default_rss_queues (), +BNX2X_MAX_QUEUES (bp)); +} +/** * bnx2x_move_fp - move content of the fastpath structure. *
@@ -145,7 +182,7 @@ static void bnx2x_shrink_eth_fp(struct b } } -int load_count[2 ][3 ] = { {0 } };/* per-path: 0-common, 1-port0, 2-port1 */ +int bnx2x_load_count[2 ][3 ] = { {0 } };/* per-path: 0-common, 1-port0, 2-port1 */ /* free skb in the packet ring at pos idx * return idx of last bd freed
@@ -813,7 +850,7 @@ void bnx2x_csum_validate(struct sk_buff skb->ip_summed =CHECKSUM_UNNECESSARY ; } -int bnx2x_rx_int (struct bnx2x_fastpath *fp,int budget) +static int bnx2x_rx_int (struct bnx2x_fastpath *fp,int budget) {struct bnx2x *bp = fp->bp;u16 bd_cons, bd_prod, bd_prod_fw, comp_ring_cons;
@@ -1483,7 +1520,7 @@ static void bnx2x_free_rx_skbs(struct bn } } -void bnx2x_free_skbs_cnic (struct bnx2x *bp) +static void bnx2x_free_skbs_cnic (struct bnx2x *bp) {bnx2x_free_tx_skbs_cnic (bp);bnx2x_free_rx_skbs_cnic (bp);
@@ -2302,16 +2339,16 @@ static int bnx2x_nic_load_no_mcp(structint path =BP_PATH (bp);DP (NETIF_MSG_IFUP ,"NO MCP - load counts[%d] %d, %d, %d\n" , - path, load_count[path][0 ], load_count[path][1 ], - load_count[path][2 ]); - load_count[path][0 ]++; - load_count[path][1 + port]++; + path, bnx2x_load_count[path][0 ], bnx2x_load_count[path][1 ], + bnx2x_load_count[path][2 ]); + bnx2x_load_count[path][0 ]++; + bnx2x_load_count[path][1 + port]++;DP (NETIF_MSG_IFUP ,"NO MCP - new load counts[%d] %d, %d, %d\n" , - path, load_count[path][0 ], load_count[path][1 ], - load_count[path][2 ]); -if (load_count[path][0 ] ==1 ) + path, bnx2x_load_count[path][0 ], bnx2x_load_count[path][1 ], + bnx2x_load_count[path][2 ]); +if (bnx2x_load_count[path][0 ] ==1 )return FW_MSG_CODE_DRV_LOAD_COMMON ; -else if (load_count[path][1 + port] ==1 ) +else if (bnx2x_load_count[path][1 + port] ==1 )return FW_MSG_CODE_DRV_LOAD_PORT ;else return FW_MSG_CODE_DRV_LOAD_FUNCTION ;
@@ -3069,7 +3106,7 @@ int bnx2x_set_power_state(struct bnx2x */* * net_device service functions */ -int bnx2x_poll (struct napi_struct *napi,int budget) +static int bnx2x_poll (struct napi_struct *napi,int budget) {int work_done =0 ;u8 cos;
@@ -4196,7 +4233,7 @@ static void bnx2x_free_fp_mem_at(struct/* end of fastpath */ } -void bnx2x_free_fp_mem_cnic (struct bnx2x *bp) +static void bnx2x_free_fp_mem_cnic (struct bnx2x *bp) {int i;for_each_cnic_queue (bp, i)
@@ -4410,7 +4447,7 @@ alloc_mem_err:return 0 ; } -int bnx2x_alloc_fp_mem_cnic (struct bnx2x *bp) +static int bnx2x_alloc_fp_mem_cnic (struct bnx2x *bp) {if (!NO_FCOE (bp))/* FCoE */
@@ -4423,7 +4460,7 @@ int bnx2x_alloc_fp_mem_cnic(struct bnx2xreturn 0 ; } -int bnx2x_alloc_fp_mem (struct bnx2x *bp) +static int bnx2x_alloc_fp_mem (struct bnx2x *bp) {int i;
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h +2 -122
183 lines not on this page · raw message
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +68 -23
165 lines not on this page · raw message
drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c +8 -54
80 lines not on this page · raw message
drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.h +1 -9
@@ -533,19 +533,11 @@ int bnx2x_ets_strict(const struct link_pint bnx2x_ets_e3b0_config (const struct link_params *params,const struct link_vars *vars,struct bnx2x_ets_params *ets_params); -/* Read pfc statistic*/ -void bnx2x_pfc_statistic (struct link_params *params,struct link_vars *vars, -u32 pfc_frames_sent[2 ], -u32 pfc_frames_received[2 ]); +void bnx2x_init_mod_abs_int (struct bnx2x *bp,struct link_vars *vars,u32 chip_id,u32 shmem_base,u32 shmem2_base,u8 port); -int bnx2x_sfp_module_detection (struct bnx2x_phy *phy, -struct link_params *params); -void bnx2x_period_func (struct link_params *params,struct link_vars *vars); -int bnx2x_check_half_open_conn (struct link_params *params, -struct link_vars *vars,u8 notify);#endif /* BNX2X_LINK_H */
drivers/net/ethernet/broadcom/bnx2x/bnx2x.h +0 -1
@@ -2057,7 +2057,6 @@ int bnx2x_del_all_macs(struct bnx2x *bp,void bnx2x_func_init (struct bnx2x *bp,struct bnx2x_func_init_params *p);void bnx2x_init_sb (struct bnx2x *bp,dma_addr_t mapping,int vfid,u8 vf_valid,int fw_sb_id,int igu_sb_id); -u32 bnx2x_get_pretend_reg (struct bnx2x *bp);int bnx2x_get_gpio (struct bnx2x *bp,int gpio_num,u8 port);int bnx2x_set_gpio (struct bnx2x *bp,int gpio_num,u32 mode,u8 port);int bnx2x_set_mult_gpio (struct bnx2x *bp,u8 pins,u32 mode);
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c +2 -262
318 lines not on this page · raw message
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h +0 -13
@@ -448,9 +448,6 @@ enum { BNX2X_LLH_CAM_MAX_PF_LINE = NIG_REG_LLH1_FUNC_MEM_SIZE / 2 }; -void bnx2x_set_mac_in_nig (struct bnx2x *bp, -bool add,unsigned char *dev_addr,int index); -/** RX_MODE verbs:DROP_ALL/ACCEPT_ALL/ACCEPT_ALL_MULTI/ACCEPT_ALL_VLAN/NORMAL */ /* RX_MODE ramrod special flags: set in rx_mode_flags field in
@@ -1307,22 +1304,12 @@ void bnx2x_init_vlan_obj(struct bnx2x *b unsigned long *pstate, bnx2x_obj_type type, struct bnx2x_credit_pool_obj *vlans_pool); -void bnx2x_init_vlan_mac_obj (struct bnx2x *bp, -struct bnx2x_vlan_mac_obj *vlan_mac_obj, -u8 cl_id,u32 cid,u8 func_id,void *rdata, -dma_addr_t rdata_mapping,int state, -unsigned long *pstate,bnx2x_obj_type type, -struct bnx2x_credit_pool_obj *macs_pool, -struct bnx2x_credit_pool_obj *vlans_pool); -int bnx2x_vlan_mac_h_read_lock (struct bnx2x *bp,struct bnx2x_vlan_mac_obj *o);void bnx2x_vlan_mac_h_read_unlock (struct bnx2x *bp,struct bnx2x_vlan_mac_obj *o);int bnx2x_vlan_mac_h_write_lock (struct bnx2x *bp,struct bnx2x_vlan_mac_obj *o); -void bnx2x_vlan_mac_h_write_unlock (struct bnx2x *bp, -struct bnx2x_vlan_mac_obj *o);int bnx2x_config_vlan_mac (struct bnx2x *bp,struct bnx2x_vlan_mac_ramrod_params *p);
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c +4 -4
@@ -799,10 +799,10 @@ int bnx2x_vfop_mac_list_cmd(struct bnx2xreturn -ENOMEM ; } -int bnx2x_vfop_vlan_set_cmd (struct bnx2x *bp, -struct bnx2x_virtf *vf, -struct bnx2x_vfop_cmd *cmd, -int qid,u16 vid,bool add) +static int bnx2x_vfop_vlan_set_cmd (struct bnx2x *bp, +struct bnx2x_virtf *vf, +struct bnx2x_vfop_cmd *cmd, +int qid,u16 vid,bool add) {struct bnx2x_vfop *vfop =bnx2x_vfop_add (bp, vf);int rc;
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h +0 -14
@@ -665,11 +665,6 @@ int bnx2x_vfop_mac_list_cmd(struct bnx2xstruct bnx2x_vfop_filters *macs, int qid, bool drv_only); -int bnx2x_vfop_vlan_set_cmd (struct bnx2x *bp, -struct bnx2x_virtf *vf, -struct bnx2x_vfop_cmd *cmd, -int qid,u16 vid,bool add); - int bnx2x_vfop_vlan_list_cmd(struct bnx2x *bp, struct bnx2x_virtf *vf, struct bnx2x_vfop_cmd *cmd,
@@ -727,13 +722,6 @@ void bnx2x_vf_enable_access(struct bnx2x/* Handles an FLR (or VF_DISABLE) notification form the MCP */ void bnx2x_vf_handle_flr_event (struct bnx2x *bp); -void bnx2x_add_tlv (struct bnx2x *bp,void *tlvs_list,u16 offset,u16 type, -u16 length); -void bnx2x_vfpf_prep (struct bnx2x *bp,struct vfpf_first_tlv *first_tlv, -u16 type,u16 length); -void bnx2x_vfpf_finalize (struct bnx2x *bp,struct vfpf_first_tlv *first_tlv); -void bnx2x_dp_tlv_list (struct bnx2x *bp,void *tlvs_list); -bool bnx2x_tlv_supported (u16 tlvtype); u32 bnx2x_crc_vf_bulletin(struct bnx2x *bp,
@@ -750,7 +738,6 @@ int bnx2x_vfpf_init(struct bnx2x *bp);void bnx2x_vfpf_close_vf (struct bnx2x *bp);int bnx2x_vfpf_setup_q (struct bnx2x *bp,struct bnx2x_fastpath *fp,bool is_leading); -int bnx2x_vfpf_teardown_queue (struct bnx2x *bp,int qidx);int bnx2x_vfpf_config_mac (struct bnx2x *bp,u8 *addr,u8 vf_qid,bool set);int bnx2x_vfpf_config_rss (struct bnx2x *bp,struct bnx2x_config_rss_params *params);
@@ -814,7 +801,6 @@ static inline int bnx2x_vfpf_release(strstatic inline int bnx2x_vfpf_init (struct bnx2x *bp) {return 0 ; }static inline void bnx2x_vfpf_close_vf (struct bnx2x *bp) {}static inline int bnx2x_vfpf_setup_q (struct bnx2x *bp,struct bnx2x_fastpath *fp,bool is_leading) {return 0 ; } -static inline int bnx2x_vfpf_teardown_queue (struct bnx2x *bp,int qidx) {return 0 ; }static inline int bnx2x_vfpf_config_mac (struct bnx2x *bp,u8 *addr,u8 vf_qid,bool set) {return 0 ; } static inline int bnx2x_vfpf_config_rss(struct bnx2x *bp,
drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c +10 -7
@@ -21,9 +21,11 @@#include "bnx2x_cmn.h" #include <linux/crc32.h> +static int bnx2x_vfpf_teardown_queue (struct bnx2x *bp,int qidx); +/* place a given tlv on the tlv buffer at a given offset */ -void bnx2x_add_tlv (struct bnx2x *bp,void *tlvs_list,u16 offset,u16 type, -u16 length) +static void bnx2x_add_tlv (struct bnx2x *bp,void *tlvs_list, +u16 offset,u16 type,u16 length) {struct channel_tlv *tl = (struct channel_tlv *)(tlvs_list + offset);
@@ -33,8 +35,8 @@ void bnx2x_add_tlv(struct bnx2x *bp, voi }/* Clear the mailbox and init the header of the first tlv */ -void bnx2x_vfpf_prep (struct bnx2x *bp,struct vfpf_first_tlv *first_tlv, -u16 type,u16 length) +static void bnx2x_vfpf_prep (struct bnx2x *bp,struct vfpf_first_tlv *first_tlv, +u16 type,u16 length) {mutex_lock (&bp->vf2pf_mutex);
@@ -52,7 +54,8 @@ void bnx2x_vfpf_prep(struct bnx2x *bp, s }/* releases the mailbox */ -void bnx2x_vfpf_finalize (struct bnx2x *bp,struct vfpf_first_tlv *first_tlv) +static void bnx2x_vfpf_finalize (struct bnx2x *bp, +struct vfpf_first_tlv *first_tlv) {DP (BNX2X_MSG_IOV ,"done sending [%d] tlv over vf pf channel\n" , first_tlv->tl.type);
@@ -85,7 +88,7 @@ static void *bnx2x_search_tlv_list(struc }/* list the types and lengths of the tlvs on the buffer */ -void bnx2x_dp_tlv_list (struct bnx2x *bp,void *tlvs_list) +static void bnx2x_dp_tlv_list (struct bnx2x *bp,void *tlvs_list) {int i =1 ;struct channel_tlv *tlv = (struct channel_tlv *)tlvs_list;
@@ -633,7 +636,7 @@ int bnx2x_vfpf_setup_q(struct bnx2x *bp,return rc; } -int bnx2x_vfpf_teardown_queue (struct bnx2x *bp,int qidx) +static int bnx2x_vfpf_teardown_queue (struct bnx2x *bp,int qidx) {struct vfpf_q_op_tlv *req = &bp->vf2pf_mbox->req.q_op;struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp;
From: Stephen Hemminger <[email protected]>
Date: Thu, 9 Jan 2014 22:20:11 -0800
Quoted 18 lines
Fix a bunch of whole lot of namespace issues with the Broadcom bnx2x driver found by running 'make namespacecheck'
* global variables must be prefixed with
bnx2x_
naming a variableint_mode, ornum_queueis invitation to disaster* make local functions static
* move some inline's used in one file out of header (this driver has a bad case of inline-itis)
* remove resulting dead code fallout
bnx2x_pfc_statistic,
bnx2x_emac_get_pfc_stat
bnx2x_init_vlan_mac_obj,
Looks like vlan mac support in this driver was a botch from day one either never worked, or not implemented or missing support functions
Quoted 3 lines
Compile tested only.
Signed-off-by Stephen Hemminger <[email protected]>
Applied.