Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 332923
b: refs/heads/master
c: 2e71a6f
h: refs/heads/master
i:
  332921: 4154dc2
  332919: b3de3bb
v: v3
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Oct 8, 2012
1 parent 1726114 commit 1f423ae
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 16 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: a2af139ff1cd85df586690ff626619ab1ee88b0a
refs/heads/master: 2e71a6f8084e7ac87166dd77d99c44190fb844fc
2 changes: 1 addition & 1 deletion trunk/drivers/net/ethernet/marvell/skge.c
Original file line number Diff line number Diff line change
Expand Up @@ -3189,7 +3189,7 @@ static int skge_poll(struct napi_struct *napi, int to_do)
if (work_done < to_do) {
unsigned long flags;

napi_gro_flush(napi);
napi_gro_flush(napi, false);
spin_lock_irqsave(&hw->hw_lock, flags);
__napi_complete(napi);
hw->intr_mask |= napimask[skge->port];
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/net/ethernet/realtek/8139cp.c
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ static int cp_rx_poll(struct napi_struct *napi, int budget)
if (cpr16(IntrStatus) & cp_rx_intr_mask)
goto rx_status_loop;

napi_gro_flush(napi);
napi_gro_flush(napi, false);
spin_lock_irqsave(&cp->lock, flags);
__napi_complete(napi);
cpw16_f(IntrMask, cp_intr_mask);
Expand Down
15 changes: 9 additions & 6 deletions trunk/include/linux/netdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -1497,19 +1497,22 @@ struct napi_gro_cb {
/* This indicates where we are processing relative to skb->data. */
int data_offset;

/* This is non-zero if the packet may be of the same flow. */
int same_flow;

/* This is non-zero if the packet cannot be merged with the new skb. */
int flush;

/* Number of segments aggregated. */
int count;
u16 count;

/* This is non-zero if the packet may be of the same flow. */
u8 same_flow;

/* Free the skb? */
int free;
u8 free;
#define NAPI_GRO_FREE 1
#define NAPI_GRO_FREE_STOLEN_HEAD 2

/* jiffies when first packet was created/queued */
unsigned long age;
};

#define NAPI_GRO_CB(skb) ((struct napi_gro_cb *)(skb)->cb)
Expand Down Expand Up @@ -2156,7 +2159,7 @@ extern gro_result_t dev_gro_receive(struct napi_struct *napi,
extern gro_result_t napi_skb_finish(gro_result_t ret, struct sk_buff *skb);
extern gro_result_t napi_gro_receive(struct napi_struct *napi,
struct sk_buff *skb);
extern void napi_gro_flush(struct napi_struct *napi);
extern void napi_gro_flush(struct napi_struct *napi, bool flush_old);
extern struct sk_buff * napi_get_frags(struct napi_struct *napi);
extern gro_result_t napi_frags_finish(struct napi_struct *napi,
struct sk_buff *skb,
Expand Down
38 changes: 31 additions & 7 deletions trunk/net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -3471,17 +3471,31 @@ static int napi_gro_complete(struct sk_buff *skb)
return netif_receive_skb(skb);
}

inline void napi_gro_flush(struct napi_struct *napi)
/* napi->gro_list contains packets ordered by age.
* youngest packets at the head of it.
* Complete skbs in reverse order to reduce latencies.
*/
void napi_gro_flush(struct napi_struct *napi, bool flush_old)
{
struct sk_buff *skb, *next;
struct sk_buff *skb, *prev = NULL;

for (skb = napi->gro_list; skb; skb = next) {
next = skb->next;
/* scan list and build reverse chain */
for (skb = napi->gro_list; skb != NULL; skb = skb->next) {
skb->prev = prev;
prev = skb;
}

for (skb = prev; skb; skb = prev) {
skb->next = NULL;

if (flush_old && NAPI_GRO_CB(skb)->age == jiffies)
return;

prev = skb->prev;
napi_gro_complete(skb);
napi->gro_count--;
}

napi->gro_count = 0;
napi->gro_list = NULL;
}
EXPORT_SYMBOL(napi_gro_flush);
Expand Down Expand Up @@ -3542,6 +3556,7 @@ enum gro_result dev_gro_receive(struct napi_struct *napi, struct sk_buff *skb)

napi->gro_count++;
NAPI_GRO_CB(skb)->count = 1;
NAPI_GRO_CB(skb)->age = jiffies;
skb_shinfo(skb)->gso_size = skb_gro_len(skb);
skb->next = napi->gro_list;
napi->gro_list = skb;
Expand Down Expand Up @@ -3878,7 +3893,7 @@ void napi_complete(struct napi_struct *n)
if (unlikely(test_bit(NAPI_STATE_NPSVC, &n->state)))
return;

napi_gro_flush(n);
napi_gro_flush(n, false);
local_irq_save(flags);
__napi_complete(n);
local_irq_restore(flags);
Expand Down Expand Up @@ -3983,8 +3998,17 @@ static void net_rx_action(struct softirq_action *h)
local_irq_enable();
napi_complete(n);
local_irq_disable();
} else
} else {
if (n->gro_list) {
/* flush too old packets
* If HZ < 1000, flush all packets.
*/
local_irq_enable();
napi_gro_flush(n, HZ >= 1000);
local_irq_disable();
}
list_move_tail(&n->poll_list, &sd->poll_list);
}
}

netpoll_poll_unlock(have);
Expand Down

0 comments on commit 1f423ae

Please sign in to comment.