* [PATCH 3/3] skge: add byte queue limit support
@ 2012-01-20 0:43 Stephen Hemminger
2012-01-20 6:23 ` Eric Dumazet
2012-01-22 19:24 ` David Miller
0 siblings, 2 replies; 7+ messages in thread
From: Stephen Hemminger @ 2012-01-20 0:43 UTC (permalink / raw)
To: David Miller; +Cc: netdev
This also changes the cleanup logic slightly to aggregate
completed notifications for multiple packets.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/ethernet/marvell/skge.c 2012-01-19 16:12:19.000000000 -0800
+++ b/drivers/net/ethernet/marvell/skge.c 2012-01-19 16:42:17.675908798 -0800
@@ -2831,6 +2831,7 @@ static netdev_tx_t skge_xmit_frame(struc
netif_stop_queue(dev);
}
+ netdev_sent_queue(dev, skb->len);
return NETDEV_TX_OK;
mapping_unwind:
@@ -2858,11 +2859,9 @@ mapping_error:
/* Free resources associated with this reing element */
-static void skge_tx_free(struct skge_port *skge, struct skge_element *e,
- u32 control)
+static inline void skge_tx_unmap(struct pci_dev *pdev, struct skge_element *e,
+ u32 control)
{
- struct pci_dev *pdev = skge->hw->pdev;
-
/* skb header vs. fragment */
if (control & BMU_STF)
pci_unmap_single(pdev, dma_unmap_addr(e, mapaddr),
@@ -2872,13 +2871,6 @@ static void skge_tx_free(struct skge_por
pci_unmap_page(pdev, dma_unmap_addr(e, mapaddr),
dma_unmap_len(e, maplen),
PCI_DMA_TODEVICE);
-
- if (control & BMU_EOF) {
- netif_printk(skge, tx_done, KERN_DEBUG, skge->netdev,
- "tx done slot %td\n", e - skge->tx_ring.start);
-
- dev_kfree_skb(e->skb);
- }
}
/* Free all buffers in transmit ring */
@@ -2889,10 +2881,15 @@ static void skge_tx_clean(struct net_dev
for (e = skge->tx_ring.to_clean; e != skge->tx_ring.to_use; e = e->next) {
struct skge_tx_desc *td = e->desc;
- skge_tx_free(skge, e, td->control);
+
+ skge_tx_unmap(skge->hw->pdev, e, td->control);
+
+ if (td->control & BMU_EOF)
+ dev_kfree_skb(e->skb);
td->control = 0;
}
+ netdev_reset_queue(dev);
skge->tx_ring.to_clean = e;
}
@@ -3157,6 +3154,7 @@ static void skge_tx_done(struct net_devi
struct skge_port *skge = netdev_priv(dev);
struct skge_ring *ring = &skge->tx_ring;
struct skge_element *e;
+ unsigned int bytes_compl = 0, pkts_compl = 0;
skge_write8(skge->hw, Q_ADDR(txqaddr[skge->port], Q_CSR), CSR_IRQ_CL_F);
@@ -3166,8 +3164,20 @@ static void skge_tx_done(struct net_devi
if (control & BMU_OWN)
break;
- skge_tx_free(skge, e, control);
+ skge_tx_unmap(skge->hw->pdev, e, control);
+
+ if (control & BMU_EOF) {
+ netif_printk(skge, tx_done, KERN_DEBUG, skge->netdev,
+ "tx done slot %td\n",
+ e - skge->tx_ring.start);
+
+ pkts_compl++;
+ bytes_compl += e->skb->len;
+
+ dev_kfree_skb(e->skb);
+ }
}
+ netdev_completed_queue(dev, pkts_compl, bytes_compl);
skge->tx_ring.to_clean = e;
/* Can run lockless until we need to synchronize to restart queue. */
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 3/3] skge: add byte queue limit support
2012-01-20 0:43 [PATCH 3/3] skge: add byte queue limit support Stephen Hemminger
@ 2012-01-20 6:23 ` Eric Dumazet
2012-01-22 19:25 ` David Miller
2012-01-22 19:24 ` David Miller
1 sibling, 1 reply; 7+ messages in thread
From: Eric Dumazet @ 2012-01-20 6:23 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: David Miller, netdev
Le jeudi 19 janvier 2012 à 16:43 -0800, Stephen Hemminger a écrit :
> This also changes the cleanup logic slightly to aggregate
> completed notifications for multiple packets.
>
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
>
> --- a/drivers/net/ethernet/marvell/skge.c 2012-01-19 16:12:19.000000000 -0800
> +++ b/drivers/net/ethernet/marvell/skge.c 2012-01-19 16:42:17.675908798 -0800
> @@ -2831,6 +2831,7 @@ static netdev_tx_t skge_xmit_frame(struc
> netif_stop_queue(dev);
> }
>
> + netdev_sent_queue(dev, skb->len);
I doubt this is safe, as skb might already be freed by tx completion
handler from another cpu.
> return NETDEV_TX_OK;
>
> mapping_unwind:
> @@ -2858,11 +2859,9 @@ mapping_error:
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 3/3] skge: add byte queue limit support
2012-01-20 0:43 [PATCH 3/3] skge: add byte queue limit support Stephen Hemminger
2012-01-20 6:23 ` Eric Dumazet
@ 2012-01-22 19:24 ` David Miller
1 sibling, 0 replies; 7+ messages in thread
From: David Miller @ 2012-01-22 19:24 UTC (permalink / raw)
To: shemminger; +Cc: netdev
From: Stephen Hemminger <shemminger@vyatta.com>
Date: Thu, 19 Jan 2012 16:43:54 -0800
> This also changes the cleanup logic slightly to aggregate
> completed notifications for multiple packets.
>
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Applied.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 3/3] skge: add byte queue limit support
2012-01-20 6:23 ` Eric Dumazet
@ 2012-01-22 19:25 ` David Miller
2012-01-22 19:40 ` Stephen Hemminger
0 siblings, 1 reply; 7+ messages in thread
From: David Miller @ 2012-01-22 19:25 UTC (permalink / raw)
To: eric.dumazet; +Cc: shemminger, netdev
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Fri, 20 Jan 2012 07:23:44 +0100
> Le jeudi 19 janvier 2012 à 16:43 -0800, Stephen Hemminger a écrit :
>> This also changes the cleanup logic slightly to aggregate
>> completed notifications for multiple packets.
>>
>> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
>>
>> --- a/drivers/net/ethernet/marvell/skge.c 2012-01-19 16:12:19.000000000 -0800
>> +++ b/drivers/net/ethernet/marvell/skge.c 2012-01-19 16:42:17.675908798 -0800
>> @@ -2831,6 +2831,7 @@ static netdev_tx_t skge_xmit_frame(struc
>> netif_stop_queue(dev);
>> }
>>
>> + netdev_sent_queue(dev, skb->len);
>
>
> I doubt this is safe, as skb might already be freed by tx completion
> handler from another cpu.
Oops, I'll not apply this for now then.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/3] skge: add byte queue limit support
2012-01-22 19:25 ` David Miller
@ 2012-01-22 19:40 ` Stephen Hemminger
2012-01-23 15:48 ` Eric Dumazet
0 siblings, 1 reply; 7+ messages in thread
From: Stephen Hemminger @ 2012-01-22 19:40 UTC (permalink / raw)
To: David Miller; +Cc: eric.dumazet, netdev
This also changes the cleanup logic slightly to aggregate
completed notifications for multiple packets.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
---
v2 - change location of netdev_sent_queue to avoid race
--- a/drivers/net/ethernet/marvell/skge.c 2012-01-19 16:12:19.000000000 -0800
+++ b/drivers/net/ethernet/marvell/skge.c 2012-01-20 10:18:25.988415244 -0800
@@ -2817,6 +2817,8 @@ static netdev_tx_t skge_xmit_frame(struc
td->control = BMU_OWN | BMU_SW | BMU_STF | control | len;
wmb();
+ netdev_sent_queue(dev, skb->len);
+
skge_write8(hw, Q_ADDR(txqaddr[skge->port], Q_CSR), CSR_START);
netif_printk(skge, tx_queued, KERN_DEBUG, skge->netdev,
@@ -2858,11 +2860,9 @@ mapping_error:
/* Free resources associated with this reing element */
-static void skge_tx_free(struct skge_port *skge, struct skge_element *e,
- u32 control)
+static inline void skge_tx_unmap(struct pci_dev *pdev, struct skge_element *e,
+ u32 control)
{
- struct pci_dev *pdev = skge->hw->pdev;
-
/* skb header vs. fragment */
if (control & BMU_STF)
pci_unmap_single(pdev, dma_unmap_addr(e, mapaddr),
@@ -2872,13 +2872,6 @@ static void skge_tx_free(struct skge_por
pci_unmap_page(pdev, dma_unmap_addr(e, mapaddr),
dma_unmap_len(e, maplen),
PCI_DMA_TODEVICE);
-
- if (control & BMU_EOF) {
- netif_printk(skge, tx_done, KERN_DEBUG, skge->netdev,
- "tx done slot %td\n", e - skge->tx_ring.start);
-
- dev_kfree_skb(e->skb);
- }
}
/* Free all buffers in transmit ring */
@@ -2889,10 +2882,15 @@ static void skge_tx_clean(struct net_dev
for (e = skge->tx_ring.to_clean; e != skge->tx_ring.to_use; e = e->next) {
struct skge_tx_desc *td = e->desc;
- skge_tx_free(skge, e, td->control);
+
+ skge_tx_unmap(skge->hw->pdev, e, td->control);
+
+ if (td->control & BMU_EOF)
+ dev_kfree_skb(e->skb);
td->control = 0;
}
+ netdev_reset_queue(dev);
skge->tx_ring.to_clean = e;
}
@@ -3157,6 +3155,7 @@ static void skge_tx_done(struct net_devi
struct skge_port *skge = netdev_priv(dev);
struct skge_ring *ring = &skge->tx_ring;
struct skge_element *e;
+ unsigned int bytes_compl = 0, pkts_compl = 0;
skge_write8(skge->hw, Q_ADDR(txqaddr[skge->port], Q_CSR), CSR_IRQ_CL_F);
@@ -3166,8 +3165,20 @@ static void skge_tx_done(struct net_devi
if (control & BMU_OWN)
break;
- skge_tx_free(skge, e, control);
+ skge_tx_unmap(skge->hw->pdev, e, control);
+
+ if (control & BMU_EOF) {
+ netif_printk(skge, tx_done, KERN_DEBUG, skge->netdev,
+ "tx done slot %td\n",
+ e - skge->tx_ring.start);
+
+ pkts_compl++;
+ bytes_compl += e->skb->len;
+
+ dev_kfree_skb(e->skb);
+ }
}
+ netdev_completed_queue(dev, pkts_compl, bytes_compl);
skge->tx_ring.to_clean = e;
/* Can run lockless until we need to synchronize to restart queue. */
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 3/3] skge: add byte queue limit support
2012-01-22 19:40 ` Stephen Hemminger
@ 2012-01-23 15:48 ` Eric Dumazet
2012-01-23 19:25 ` David Miller
0 siblings, 1 reply; 7+ messages in thread
From: Eric Dumazet @ 2012-01-23 15:48 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: David Miller, netdev
Le dimanche 22 janvier 2012 à 11:40 -0800, Stephen Hemminger a écrit :
> This also changes the cleanup logic slightly to aggregate
> completed notifications for multiple packets.
>
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
> ---
> v2 - change location of netdev_sent_queue to avoid race
Acked-by: Eric Dumazet <eric.dumazet@gmail.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 3/3] skge: add byte queue limit support
2012-01-23 15:48 ` Eric Dumazet
@ 2012-01-23 19:25 ` David Miller
0 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2012-01-23 19:25 UTC (permalink / raw)
To: eric.dumazet; +Cc: shemminger, netdev
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Mon, 23 Jan 2012 16:48:22 +0100
> Le dimanche 22 janvier 2012 à 11:40 -0800, Stephen Hemminger a écrit :
>> This also changes the cleanup logic slightly to aggregate
>> completed notifications for multiple packets.
>>
>> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
>> ---
>> v2 - change location of netdev_sent_queue to avoid race
>
> Acked-by: Eric Dumazet <eric.dumazet@gmail.com>
Applied.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-01-23 19:25 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-20 0:43 [PATCH 3/3] skge: add byte queue limit support Stephen Hemminger
2012-01-20 6:23 ` Eric Dumazet
2012-01-22 19:25 ` David Miller
2012-01-22 19:40 ` Stephen Hemminger
2012-01-23 15:48 ` Eric Dumazet
2012-01-23 19:25 ` David Miller
2012-01-22 19:24 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).