Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 86911
b: refs/heads/master
c: 1d60ab0
h: refs/heads/master
i:
  86909: 5f35fc4
  86907: 05f0512
  86903: f00ce24
  86895: 06f56fd
  86879: d60e4d7
  86847: 7057f25
  86783: d60ca20
v: v3
  • Loading branch information
Stefano Brivio authored and John W. Linville committed Mar 4, 2008
1 parent 8c8fdcd commit 219931f
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 66 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ed58dd41f3aeefc11a7f634db90687f92ea8632e
refs/heads/master: 1d60ab0574fae362b1cca0ef52181ef75fd46832
7 changes: 3 additions & 4 deletions trunk/include/linux/netpoll.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ struct netpoll {

struct netpoll_info {
atomic_t refcnt;
int rx_flags;
spinlock_t rx_lock;
struct netpoll *rx_np; /* netpoll that registered an rx_hook */
struct sk_buff_head arp_tx; /* list of arp requests to reply to */
Expand All @@ -51,12 +50,12 @@ static inline int netpoll_rx(struct sk_buff *skb)
unsigned long flags;
int ret = 0;

if (!npinfo || (!npinfo->rx_np && !npinfo->rx_flags))
if (!npinfo || !npinfo->rx_np)
return 0;

spin_lock_irqsave(&npinfo->rx_lock, flags);
/* check rx_flags again with the lock held */
if (npinfo->rx_flags && __netpoll_rx(skb))
/* check rx_np again with the lock held */
if (npinfo->rx_np && __netpoll_rx(skb))
ret = 1;
spin_unlock_irqrestore(&npinfo->rx_lock, flags);

Expand Down
3 changes: 1 addition & 2 deletions trunk/include/net/inet_sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,7 @@ extern void build_ehash_secret(void);
static inline unsigned int inet_ehashfn(const __be32 laddr, const __u16 lport,
const __be32 faddr, const __be16 fport)
{
return jhash_3words((__force __u32) laddr,
(__force __u32) faddr,
return jhash_2words((__force __u32) laddr ^ (__force __u32) faddr,
((__u32) lport) << 16 | (__force __u32)fport,
inet_ehash_secret);
}
Expand Down
12 changes: 4 additions & 8 deletions trunk/net/core/netpoll.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ static struct sk_buff_head skb_pool;
static atomic_t trapped;

#define USEC_PER_POLL 50
#define NETPOLL_RX_ENABLED 1
#define NETPOLL_RX_DROP 2

#define MAX_SKB_SIZE \
(MAX_UDP_CHUNK + sizeof(struct udphdr) + \
Expand Down Expand Up @@ -128,13 +126,11 @@ static int poll_one_napi(struct netpoll_info *npinfo,
if (!test_bit(NAPI_STATE_SCHED, &napi->state))
return budget;

npinfo->rx_flags |= NETPOLL_RX_DROP;
atomic_inc(&trapped);

work = napi->poll(napi, budget);

atomic_dec(&trapped);
npinfo->rx_flags &= ~NETPOLL_RX_DROP;

return budget - work;
}
Expand Down Expand Up @@ -476,7 +472,7 @@ int __netpoll_rx(struct sk_buff *skb)
if (skb->dev->type != ARPHRD_ETHER)
goto out;

/* check if netpoll clients need ARP */
/* if receive ARP during middle of NAPI poll, then queue */
if (skb->protocol == htons(ETH_P_ARP) &&
atomic_read(&trapped)) {
skb_queue_tail(&npi->arp_tx, skb);
Expand Down Expand Up @@ -538,6 +534,9 @@ int __netpoll_rx(struct sk_buff *skb)
return 1;

out:
/* If packet received while already in poll then just
* silently drop.
*/
if (atomic_read(&trapped)) {
kfree_skb(skb);
return 1;
Expand Down Expand Up @@ -676,7 +675,6 @@ int netpoll_setup(struct netpoll *np)
goto release;
}

npinfo->rx_flags = 0;
npinfo->rx_np = NULL;

spin_lock_init(&npinfo->rx_lock);
Expand Down Expand Up @@ -758,7 +756,6 @@ int netpoll_setup(struct netpoll *np)

if (np->rx_hook) {
spin_lock_irqsave(&npinfo->rx_lock, flags);
npinfo->rx_flags |= NETPOLL_RX_ENABLED;
npinfo->rx_np = np;
spin_unlock_irqrestore(&npinfo->rx_lock, flags);
}
Expand Down Expand Up @@ -800,7 +797,6 @@ void netpoll_cleanup(struct netpoll *np)
if (npinfo->rx_np == np) {
spin_lock_irqsave(&npinfo->rx_lock, flags);
npinfo->rx_np = NULL;
npinfo->rx_flags &= ~NETPOLL_RX_ENABLED;
spin_unlock_irqrestore(&npinfo->rx_lock, flags);
}

Expand Down
2 changes: 1 addition & 1 deletion trunk/net/ipv4/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ config INET_ESP
tristate "IP: ESP transformation"
select XFRM
select CRYPTO
select CRYPTO_AUTHENC
select CRYPTO_AEAD
select CRYPTO_HMAC
select CRYPTO_MD5
select CRYPTO_CBC
Expand Down
2 changes: 1 addition & 1 deletion trunk/net/ipv6/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ config INET6_ESP
depends on IPV6
select XFRM
select CRYPTO
select CRYPTO_AUTHENC
select CRYPTO_AEAD
select CRYPTO_HMAC
select CRYPTO_MD5
select CRYPTO_CBC
Expand Down
92 changes: 43 additions & 49 deletions trunk/net/mac80211/rc80211_pid_algo.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright 2002-2005, Instant802 Networks, Inc.
* Copyright 2005, Devicescape Software, Inc.
* Copyright 2007, Mattias Nissler <mattias.nissler@gmx.de>
* Copyright 2007, Stefano Brivio <stefano.brivio@polimi.it>
* Copyright 2007-2008, Stefano Brivio <stefano.brivio@polimi.it>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
Expand Down Expand Up @@ -63,72 +63,66 @@
* RC_PID_ARITH_SHIFT.
*/


/* Shift the adjustment so that we won't switch to a lower rate if it exhibited
* a worse failed frames behaviour and we'll choose the highest rate whose
* failed frames behaviour is not worse than the one of the original rate
* target. While at it, check that the adjustment is within the ranges. Then,
* provide the new rate index. */
static int rate_control_pid_shift_adjust(struct rc_pid_rateinfo *r,
int adj, int cur, int l)
{
int i, j, k, tmp;

j = r[cur].rev_index;
i = j + adj;

if (i < 0)
return r[0].index;
if (i >= l - 1)
return r[l - 1].index;

tmp = i;

if (adj < 0) {
for (k = j; k >= i; k--)
if (r[k].diff <= r[j].diff)
tmp = k;
} else {
for (k = i + 1; k + i < l; k++)
if (r[k].diff <= r[i].diff)
tmp = k;
}

return r[tmp].index;
}

/* Adjust the rate while ensuring that we won't switch to a lower rate if it
* exhibited a worse failed frames behaviour and we'll choose the highest rate
* whose failed frames behaviour is not worse than the one of the original rate
* target. While at it, check that the new rate is valid. */
static void rate_control_pid_adjust_rate(struct ieee80211_local *local,
struct sta_info *sta, int adj,
struct rc_pid_rateinfo *rinfo)
{
struct ieee80211_sub_if_data *sdata;
struct ieee80211_hw_mode *mode;
int newidx;
int maxrate;
int back = (adj > 0) ? 1 : -1;
int cur_sorted, new_sorted, probe, tmp, n_bitrates;
int cur = sta->txrate;

sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev);

mode = local->oper_hw_mode;
maxrate = sdata->bss ? sdata->bss->max_ratectrl_rateidx : -1;
n_bitrates = mode->num_rates;

newidx = rate_control_pid_shift_adjust(rinfo, adj, sta->txrate,
mode->num_rates);
/* Map passed arguments to sorted values. */
cur_sorted = rinfo[cur].rev_index;
new_sorted = cur_sorted + adj;

while (newidx != sta->txrate) {
if (rate_supported(sta, mode, newidx) &&
(maxrate < 0 || newidx <= maxrate)) {
sta->txrate = newidx;
break;
}
/* Check limits. */
if (new_sorted < 0)
new_sorted = rinfo[0].rev_index;
else if (new_sorted >= n_bitrates)
new_sorted = rinfo[n_bitrates - 1].rev_index;

newidx += back;
tmp = new_sorted;

if (adj < 0) {
/* Ensure that the rate decrease isn't disadvantageous. */
for (probe = cur_sorted; probe >= new_sorted; probe--)
if (rinfo[probe].diff <= rinfo[cur_sorted].diff &&
rate_supported(sta, mode, rinfo[probe].index))
tmp = probe;
} else {
/* Look for rate increase with zero (or below) cost. */
for (probe = new_sorted + 1; probe < n_bitrates; probe++)
if (rinfo[probe].diff <= rinfo[new_sorted].diff &&
rate_supported(sta, mode, rinfo[probe].index))
tmp = probe;
}

/* Fit the rate found to the nearest supported rate. */
do {
if (rate_supported(sta, mode, rinfo[tmp].index)) {
sta->txrate = rinfo[tmp].index;
break;
}
if (adj < 0)
tmp--;
else
tmp++;
} while (tmp < n_bitrates && tmp >= 0);

#ifdef CONFIG_MAC80211_DEBUGFS
rate_control_pid_event_rate_change(
&((struct rc_pid_sta_info *)sta->rate_ctrl_priv)->events,
newidx, mode->rates[newidx].rate);
cur, mode->rates[cur].rate);
#endif
}

Expand Down

0 comments on commit 219931f

Please sign in to comment.