dect
/
linux-2.6
Archived
13
0
Fork 0

be2net: cleanup rx/tx rate calculations

Hi, Pls accept this patch to cleanup rx/tx rate calculations as follows:
- check for jiffies wraparound
- remove typecast of a denominator
- do rate calculation only in workqueue context periodically

Signed-off-by: Sathya Perla <sathyap@serverengines.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Sathya Perla 2009-03-24 16:40:13 -07:00 committed by David S. Miller
parent 38938bfe34
commit 4097f663cb
2 changed files with 75 additions and 39 deletions

View File

@ -100,9 +100,9 @@ struct be_drvr_stats {
u32 be_tx_wrbs; /* number of tx WRBs used */
u32 be_tx_events; /* number of tx completion events */
u32 be_tx_compl; /* number of tx completion entries processed */
u64 be_tx_jiffies;
ulong be_tx_bytes;
ulong be_tx_bytes_prev;
ulong be_tx_jiffies;
u64 be_tx_bytes;
u64 be_tx_bytes_prev;
u32 be_tx_rate;
u32 cache_barrier[16];
@ -113,9 +113,9 @@ struct be_drvr_stats {
u32 be_rx_compl; /* number of rx completion entries processed */
u32 be_lro_hgram_data[8]; /* histogram of LRO data packets */
u32 be_lro_hgram_ack[8]; /* histogram of LRO ACKs */
u64 be_rx_jiffies;
ulong be_rx_bytes;
ulong be_rx_bytes_prev;
ulong be_rx_jiffies;
u64 be_rx_bytes;
u64 be_rx_bytes_prev;
u32 be_rx_rate;
/* number of non ether type II frames dropped where
* frame len > length field of Mac Hdr */

View File

@ -245,19 +245,29 @@ static void be_link_status_update(struct be_adapter *adapter)
/* Update the EQ delay n BE based on the RX frags consumed / sec */
static void be_rx_eqd_update(struct be_adapter *adapter)
{
u32 eqd;
struct be_ctrl_info *ctrl = &adapter->ctrl;
struct be_eq_obj *rx_eq = &adapter->rx_eq;
struct be_drvr_stats *stats = &adapter->stats.drvr_stats;
ulong now = jiffies;
u32 eqd;
if (!rx_eq->enable_aic)
return;
/* Wrapped around */
if (time_before(now, stats->rx_fps_jiffies)) {
stats->rx_fps_jiffies = now;
return;
}
/* Update once a second */
if (((jiffies - stats->rx_fps_jiffies) < HZ) || rx_eq->enable_aic == 0)
if ((now - stats->rx_fps_jiffies) < HZ)
return;
stats->be_rx_fps = (stats->be_rx_frags - stats->be_prev_rx_frags) /
((jiffies - stats->rx_fps_jiffies) / HZ);
((now - stats->rx_fps_jiffies) / HZ);
stats->rx_fps_jiffies = jiffies;
stats->rx_fps_jiffies = now;
stats->be_prev_rx_frags = stats->be_rx_frags;
eqd = stats->be_rx_fps / 110000;
eqd = eqd << 3;
@ -280,26 +290,38 @@ static struct net_device_stats *be_get_stats(struct net_device *dev)
return &adapter->stats.net_stats;
}
static void be_tx_rate_update(struct be_adapter *adapter)
{
struct be_drvr_stats *stats = drvr_stats(adapter);
ulong now = jiffies;
/* Wrapped around? */
if (time_before(now, stats->be_tx_jiffies)) {
stats->be_tx_jiffies = now;
return;
}
/* Update tx rate once in two seconds */
if ((now - stats->be_tx_jiffies) > 2 * HZ) {
u32 r;
r = (stats->be_tx_bytes - stats->be_tx_bytes_prev) /
((now - stats->be_tx_jiffies) / HZ);
r = r / 1000000; /* M bytes/s */
stats->be_tx_rate = r * 8; /* M bits/s */
stats->be_tx_jiffies = now;
stats->be_tx_bytes_prev = stats->be_tx_bytes;
}
}
static void be_tx_stats_update(struct be_adapter *adapter,
u32 wrb_cnt, u32 copied, bool stopped)
{
struct be_drvr_stats *stats = &adapter->stats.drvr_stats;
struct be_drvr_stats *stats = drvr_stats(adapter);
stats->be_tx_reqs++;
stats->be_tx_wrbs += wrb_cnt;
stats->be_tx_bytes += copied;
if (stopped)
stats->be_tx_stops++;
/* Update tx rate once in two seconds */
if ((jiffies - stats->be_tx_jiffies) > 2 * HZ) {
u32 r;
r = (stats->be_tx_bytes - stats->be_tx_bytes_prev) /
((u32) (jiffies - stats->be_tx_jiffies) / HZ);
r = (r / 1000000); /* M bytes/s */
stats->be_tx_rate = (r * 8); /* M bits/s */
stats->be_tx_jiffies = jiffies;
stats->be_tx_bytes_prev = stats->be_tx_bytes;
}
}
/* Determine number of WRB entries needed to xmit data in an skb */
@ -573,26 +595,38 @@ static void be_set_multicast_list(struct net_device *netdev)
}
}
static void be_rx_rate_update(struct be_adapter *adapter, u32 pktsize,
u16 numfrags)
static void be_rx_rate_update(struct be_adapter *adapter)
{
struct be_drvr_stats *stats = &adapter->stats.drvr_stats;
struct be_drvr_stats *stats = drvr_stats(adapter);
ulong now = jiffies;
u32 rate;
/* Wrapped around */
if (time_before(now, stats->be_rx_jiffies)) {
stats->be_rx_jiffies = now;
return;
}
/* Update the rate once in two seconds */
if ((now - stats->be_rx_jiffies) < 2 * HZ)
return;
rate = (stats->be_rx_bytes - stats->be_rx_bytes_prev) /
((now - stats->be_rx_jiffies) / HZ);
rate = rate / 1000000; /* MB/Sec */
stats->be_rx_rate = rate * 8; /* Mega Bits/Sec */
stats->be_rx_jiffies = now;
stats->be_rx_bytes_prev = stats->be_rx_bytes;
}
static void be_rx_stats_update(struct be_adapter *adapter,
u32 pktsize, u16 numfrags)
{
struct be_drvr_stats *stats = drvr_stats(adapter);
stats->be_rx_compl++;
stats->be_rx_frags += numfrags;
stats->be_rx_bytes += pktsize;
/* Update the rate once in two seconds */
if ((jiffies - stats->be_rx_jiffies) < 2 * HZ)
return;
rate = (stats->be_rx_bytes - stats->be_rx_bytes_prev) /
((u32) (jiffies - stats->be_rx_jiffies) / HZ);
rate = (rate / 1000000); /* MB/Sec */
stats->be_rx_rate = (rate * 8); /* Mega Bits/Sec */
stats->be_rx_jiffies = jiffies;
stats->be_rx_bytes_prev = stats->be_rx_bytes;
}
static struct be_rx_page_info *
@ -700,7 +734,7 @@ static void skb_fill_rx_data(struct be_adapter *adapter,
memset(page_info, 0, sizeof(*page_info));
}
be_rx_rate_update(adapter, pktsize, num_rcvd);
be_rx_stats_update(adapter, pktsize, num_rcvd);
return;
}
@ -799,7 +833,7 @@ static void be_rx_compl_process_lro(struct be_adapter *adapter,
vid, NULL, 0);
}
be_rx_rate_update(adapter, pkt_size, num_rcvd);
be_rx_stats_update(adapter, pkt_size, num_rcvd);
return;
}
@ -841,7 +875,6 @@ static void be_post_rx_frags(struct be_adapter *adapter)
u64 page_dmaaddr = 0, frag_dmaaddr;
u32 posted, page_offset = 0;
page_info = &page_info_tbl[rxq->head];
for (posted = 0; posted < MAX_RX_POST && !page_info->page; posted++) {
if (!pagep) {
@ -1305,6 +1338,9 @@ static void be_worker(struct work_struct *work)
/* Set EQ delay */
be_rx_eqd_update(adapter);
be_tx_rate_update(adapter);
be_rx_rate_update(adapter);
if (adapter->rx_post_starved) {
adapter->rx_post_starved = false;
be_post_rx_frags(adapter);