提交 c46e9907 编写于 作者: E Eric Dumazet 提交者: David S. Miller

amd8111e: add GRO support

Use napi_complete_done() instead of __napi_complete() to :

1) Get support of gro_flush_timeout if opt-in
2) Not rearm interrupts for busy-polling users.
3) use standard NAPI API.
4) get rid of baroque code and ease maintenance.
Signed-off-by: NEric Dumazet <edumazet@google.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 1fa8c5f3
...@@ -695,23 +695,13 @@ static int amd8111e_rx_poll(struct napi_struct *napi, int budget) ...@@ -695,23 +695,13 @@ static int amd8111e_rx_poll(struct napi_struct *napi, int budget)
void __iomem *mmio = lp->mmio; void __iomem *mmio = lp->mmio;
struct sk_buff *skb,*new_skb; struct sk_buff *skb,*new_skb;
int min_pkt_len, status; int min_pkt_len, status;
unsigned int intr0;
int num_rx_pkt = 0; int num_rx_pkt = 0;
short pkt_len; short pkt_len;
#if AMD8111E_VLAN_TAG_USED #if AMD8111E_VLAN_TAG_USED
short vtag; short vtag;
#endif #endif
int rx_pkt_limit = budget;
unsigned long flags;
if (rx_pkt_limit <= 0)
goto rx_not_empty;
do{ while (num_rx_pkt < budget) {
/* process receive packets until we use the quota.
* If we own the next entry, it's a new packet. Send it up.
*/
while(1) {
status = le16_to_cpu(lp->rx_ring[rx_index].rx_flags); status = le16_to_cpu(lp->rx_ring[rx_index].rx_flags);
if (status & OWN_BIT) if (status & OWN_BIT)
break; break;
...@@ -722,13 +712,13 @@ static int amd8111e_rx_poll(struct napi_struct *napi, int budget) ...@@ -722,13 +712,13 @@ static int amd8111e_rx_poll(struct napi_struct *napi, int budget)
* jabber packet to use two buffers, with only * jabber packet to use two buffers, with only
* the last correctly noting the error. * the last correctly noting the error.
*/ */
if(status & ERR_BIT) { if (status & ERR_BIT) {
/* resetting flags */ /* resetting flags */
lp->rx_ring[rx_index].rx_flags &= RESET_RX_FLAGS; lp->rx_ring[rx_index].rx_flags &= RESET_RX_FLAGS;
goto err_next_pkt; goto err_next_pkt;
} }
/* check for STP and ENP */ /* check for STP and ENP */
if(!((status & STP_BIT) && (status & ENP_BIT))){ if (!((status & STP_BIT) && (status & ENP_BIT))){
/* resetting flags */ /* resetting flags */
lp->rx_ring[rx_index].rx_flags &= RESET_RX_FLAGS; lp->rx_ring[rx_index].rx_flags &= RESET_RX_FLAGS;
goto err_next_pkt; goto err_next_pkt;
...@@ -737,20 +727,18 @@ static int amd8111e_rx_poll(struct napi_struct *napi, int budget) ...@@ -737,20 +727,18 @@ static int amd8111e_rx_poll(struct napi_struct *napi, int budget)
#if AMD8111E_VLAN_TAG_USED #if AMD8111E_VLAN_TAG_USED
vtag = status & TT_MASK; vtag = status & TT_MASK;
/*MAC will strip vlan tag*/ /* MAC will strip vlan tag */
if (vtag != 0) if (vtag != 0)
min_pkt_len =MIN_PKT_LEN - 4; min_pkt_len = MIN_PKT_LEN - 4;
else else
#endif #endif
min_pkt_len =MIN_PKT_LEN; min_pkt_len = MIN_PKT_LEN;
if (pkt_len < min_pkt_len) { if (pkt_len < min_pkt_len) {
lp->rx_ring[rx_index].rx_flags &= RESET_RX_FLAGS; lp->rx_ring[rx_index].rx_flags &= RESET_RX_FLAGS;
lp->drv_rx_errors++; lp->drv_rx_errors++;
goto err_next_pkt; goto err_next_pkt;
} }
if(--rx_pkt_limit < 0)
goto rx_not_empty;
new_skb = netdev_alloc_skb(dev, lp->rx_buff_len); new_skb = netdev_alloc_skb(dev, lp->rx_buff_len);
if (!new_skb) { if (!new_skb) {
/* if allocation fail, /* if allocation fail,
...@@ -780,13 +768,13 @@ static int amd8111e_rx_poll(struct napi_struct *napi, int budget) ...@@ -780,13 +768,13 @@ static int amd8111e_rx_poll(struct napi_struct *napi, int budget)
__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vlan_tag); __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vlan_tag);
} }
#endif #endif
netif_receive_skb(skb); napi_gro_receive(napi, skb);
/*COAL update rx coalescing parameters*/ /* COAL update rx coalescing parameters */
lp->coal_conf.rx_packets++; lp->coal_conf.rx_packets++;
lp->coal_conf.rx_bytes += pkt_len; lp->coal_conf.rx_bytes += pkt_len;
num_rx_pkt++; num_rx_pkt++;
err_next_pkt: err_next_pkt:
lp->rx_ring[rx_index].buff_phy_addr lp->rx_ring[rx_index].buff_phy_addr
= cpu_to_le32(lp->rx_dma_addr[rx_index]); = cpu_to_le32(lp->rx_dma_addr[rx_index]);
lp->rx_ring[rx_index].buff_count = lp->rx_ring[rx_index].buff_count =
...@@ -795,25 +783,17 @@ static int amd8111e_rx_poll(struct napi_struct *napi, int budget) ...@@ -795,25 +783,17 @@ static int amd8111e_rx_poll(struct napi_struct *napi, int budget)
lp->rx_ring[rx_index].rx_flags |= cpu_to_le16(OWN_BIT); lp->rx_ring[rx_index].rx_flags |= cpu_to_le16(OWN_BIT);
rx_index = (++lp->rx_idx) & RX_RING_DR_MOD_MASK; rx_index = (++lp->rx_idx) & RX_RING_DR_MOD_MASK;
} }
/* Check the interrupt status register for more packets in the
* mean time. Process them since we have not used up our quota.
*/
intr0 = readl(mmio + INT0);
/*Ack receive packets */
writel(intr0 & RINT0,mmio + INT0);
} while(intr0 & RINT0); if (num_rx_pkt < budget && napi_complete_done(napi, num_rx_pkt)) {
unsigned long flags;
if (rx_pkt_limit > 0) {
/* Receive descriptor is empty now */ /* Receive descriptor is empty now */
spin_lock_irqsave(&lp->lock, flags); spin_lock_irqsave(&lp->lock, flags);
__napi_complete(napi);
writel(VAL0|RINTEN0, mmio + INTEN0); writel(VAL0|RINTEN0, mmio + INTEN0);
writel(VAL2 | RDMD0, mmio + CMD0); writel(VAL2 | RDMD0, mmio + CMD0);
spin_unlock_irqrestore(&lp->lock, flags); spin_unlock_irqrestore(&lp->lock, flags);
} }
rx_not_empty:
return num_rx_pkt; return num_rx_pkt;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册