Skip to content

Commit

Permalink
bnx2x: consistent statistics after internal driver reload
Browse files Browse the repository at this point in the history
Currently bnx2x statistics are reset by inner driver reload, e.g. by MTU
change. This patch fixes this issue - from now on statistics should only
be reset upon device closure.
Thanks to Michal Schmidt <mschmidt@redhat.com> for his initial patch
regarding this issue.

Signed-off-by: Yuval Mintz <yuvalmin@broadcom.com>
Signed-off-by: Eilon Greenstein <eilong@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Mintz Yuval authored and David S. Miller committed Feb 15, 2012
1 parent eb40d89 commit 1355b70
Show file tree
Hide file tree
Showing 6 changed files with 374 additions and 236 deletions.
6 changes: 5 additions & 1 deletion drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ struct bnx2x_fastpath {
struct ustorm_per_queue_stats old_uclient;
struct xstorm_per_queue_stats old_xclient;
struct bnx2x_eth_q_stats eth_q_stats;
struct bnx2x_eth_q_stats_old eth_q_stats_old;

/* The size is calculated using the following:
sizeof name field from netdev structure +
Expand Down Expand Up @@ -1046,7 +1047,6 @@ struct bnx2x_slowpath {
struct nig_stats nig_stats;
struct host_port_stats port_stats;
struct host_func_stats func_stats;
struct host_func_stats func_stats_base;

u32 wb_comp;
u32 wb_data[4];
Expand Down Expand Up @@ -1462,6 +1462,10 @@ struct bnx2x {

u16 stats_counter;
struct bnx2x_eth_stats eth_stats;
struct bnx2x_eth_stats_old eth_stats_old;
struct bnx2x_net_stats_old net_stats_old;
struct bnx2x_fw_port_stats_old fw_stats_old;
bool stats_init;

struct z_stream_s *strm;
void *gunzip_buf;
Expand Down
41 changes: 1 addition & 40 deletions drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,46 +31,6 @@



/**
* bnx2x_bz_fp - zero content of the fastpath structure.
*
* @bp: driver handle
* @index: fastpath index to be zeroed
*
* Makes sure the contents of the bp->fp[index].napi is kept
* intact.
*/
static inline void bnx2x_bz_fp(struct bnx2x *bp, int index)
{
struct bnx2x_fastpath *fp = &bp->fp[index];
struct napi_struct orig_napi = fp->napi;
/* bzero bnx2x_fastpath contents */
memset(fp, 0, sizeof(*fp));

/* Restore the NAPI object as it has been already initialized */
fp->napi = orig_napi;

fp->bp = bp;
fp->index = index;
if (IS_ETH_FP(fp))
fp->max_cos = bp->max_cos;
else
/* Special queues support only one CoS */
fp->max_cos = 1;

/*
* set the tpa flag for each queue. The tpa flag determines the queue
* minimal size so it must be set prior to queue memory allocation
*/
fp->disable_tpa = ((bp->flags & TPA_ENABLE_FLAG) == 0);

#ifdef BCM_CNIC
/* We don't want TPA on an FCoE L2 ring */
if (IS_FCOE_FP(fp))
fp->disable_tpa = 1;
#endif
}

/**
* bnx2x_move_fp - move content of the fastpath structure.
*
Expand Down Expand Up @@ -2084,6 +2044,7 @@ int bnx2x_nic_unload(struct bnx2x *bp, int unload_mode)
bnx2x_drv_pulse(bp);

bnx2x_stats_handle(bp, STATS_EVENT_STOP);
bnx2x_save_statistics(bp);

/* Cleanup the chip if needed */
if (unload_mode != UNLOAD_RECOVERY)
Expand Down
73 changes: 73 additions & 0 deletions drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
Original file line number Diff line number Diff line change
Expand Up @@ -1491,6 +1491,79 @@ static inline u16 bnx2x_extract_max_cfg(struct bnx2x *bp, u32 mf_cfg)
return max_cfg;
}

/**
* bnx2x_bz_fp - zero content of the fastpath structure.
*
* @bp: driver handle
* @index: fastpath index to be zeroed
*
* Makes sure the contents of the bp->fp[index].napi is kept
* intact.
*/
static inline void bnx2x_bz_fp(struct bnx2x *bp, int index)
{
struct bnx2x_fastpath *fp = &bp->fp[index];
struct napi_struct orig_napi = fp->napi;
/* bzero bnx2x_fastpath contents */
if (bp->stats_init)
memset(fp, 0, sizeof(*fp));
else {
/* Keep Queue statistics */
struct bnx2x_eth_q_stats *tmp_eth_q_stats;
struct bnx2x_eth_q_stats_old *tmp_eth_q_stats_old;

tmp_eth_q_stats = kzalloc(sizeof(struct bnx2x_eth_q_stats),
GFP_KERNEL);
if (tmp_eth_q_stats)
memcpy(tmp_eth_q_stats, &fp->eth_q_stats,
sizeof(struct bnx2x_eth_q_stats));

tmp_eth_q_stats_old =
kzalloc(sizeof(struct bnx2x_eth_q_stats_old),
GFP_KERNEL);
if (tmp_eth_q_stats_old)
memcpy(tmp_eth_q_stats_old, &fp->eth_q_stats_old,
sizeof(struct bnx2x_eth_q_stats_old));

memset(fp, 0, sizeof(*fp));

if (tmp_eth_q_stats) {
memcpy(&fp->eth_q_stats, tmp_eth_q_stats,
sizeof(struct bnx2x_eth_q_stats));
kfree(tmp_eth_q_stats);
}

if (tmp_eth_q_stats_old) {
memcpy(&fp->eth_q_stats_old, tmp_eth_q_stats_old,
sizeof(struct bnx2x_eth_q_stats_old));
kfree(tmp_eth_q_stats_old);
}

}

/* Restore the NAPI object as it has been already initialized */
fp->napi = orig_napi;

fp->bp = bp;
fp->index = index;
if (IS_ETH_FP(fp))
fp->max_cos = bp->max_cos;
else
/* Special queues support only one CoS */
fp->max_cos = 1;

/*
* set the tpa flag for each queue. The tpa flag determines the queue
* minimal size so it must be set prior to queue memory allocation
*/
fp->disable_tpa = (bp->flags & TPA_ENABLE_FLAG) == 0;
#ifdef BCM_CNIC
/* We don't want TPA on an FCoE L2 ring */
if (IS_FCOE_FP(fp))
fp->disable_tpa = 1;
#endif
}

/**
* bnx2x_get_iscsi_info - update iSCSI params according to licensing info.
*
Expand Down
2 changes: 2 additions & 0 deletions drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -10235,6 +10235,8 @@ static int bnx2x_open(struct net_device *dev)
int other_engine = BP_PATH(bp) ? 0 : 1;
bool other_load_status, load_status;

bp->stats_init = true;

netif_carrier_off(dev);

bnx2x_set_power_state(bp, PCI_D0);
Expand Down
Loading

0 comments on commit 1355b70

Please sign in to comment.