sfc: efx: add support for skb->xmit_more
Subsystems (3)
PATCH 1/1 sfc: efx: add support for skb->xmit_more
Add support for xmit_more batching: efx has BQL support, thus we need to only move the queue hang check before the hw tail pointer write and test for xmit_more bit resp. whether the queue/stack has stopped. Thanks to Nikolay Aleksandrov who had a Solarflare NIC to test!
--- drivers/net/ethernet/sfc/tx.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/net/ethernet/sfc/tx.c +8 -7
@@ -439,13 +439,13 @@ finish_packet:netdev_tx_sent_queue (tx_queue->core_txq, skb->len); +efx_tx_maybe_stop_queue (tx_queue); +/* Pass off to hardware */ -efx_nic_push_buffers (tx_queue); +if (!skb->xmit_more ||netif_xmit_stopped (tx_queue->core_txq)) +efx_nic_push_buffers (tx_queue); tx_queue->tx_packets++; - -efx_tx_maybe_stop_queue (tx_queue); -return NETDEV_TX_OK ; dma_err:
@@ -1308,11 +1308,12 @@ static int efx_enqueue_skb_tso(struct efx_tx_queue *tx_queue,netdev_tx_sent_queue (tx_queue->core_txq, skb->len); -/* Pass off to hardware */ -efx_nic_push_buffers (tx_queue); -efx_tx_maybe_stop_queue (tx_queue); +/* Pass off to hardware */ +if (!skb->xmit_more ||netif_xmit_stopped (tx_queue->core_txq)) +efx_nic_push_buffers (tx_queue); + tx_queue->tso_bursts++;return NETDEV_TX_OK ;
Signature · 1 line
1.7.11.7
Quoted 4 lines · Daniel Borkmann
Add support for
xmit_morebatching: efx has BQL support, thus we need to only move the queue hang check before the hw tail pointer write and test forxmit_morebit resp. whether the queue/stack has stopped. Thanks to Nikolay Aleksandrov who had a Solarflare NIC to test!
I see two issues here.
1) The error handling path (labels dma_err: and err:) will unwind back to tx_queue->insert_count, which (AFAICT) only gets updated by efx_nic_push_buffers() (at least on EF10, where that calls efx_ef10_tx_write()).
So if we transmit a bunch of skbs with xmit_more, then get an error, we will unwind all the way back to the start, whereas (again, AFAICT) the previous skbs were nicely completed and safe to send.
The unwind will leave us in a good state, but we'll have failed to send some packets that there was nothing wrong with.
I think the appropriate fix for this would be to maintain two separate insert_counts, as xmit_more means we can't conflate "last write pointer pushed" and "write pointer at start of this skb" any longer.
2) I think we shouldn't do PIO when xmit_more is set - it's probably bad for performance (though I haven't measured), and I'm not entirely convinced it will behave correctly. I think efx_nic_tx_is_empty(tx_queue) will return true if we have xmit_more'd a PIO packet, enabling us to potentially PIO the next packet as well, thus overwriting the PIO buffer before the NIC's had a chance to read it. I'm also unsure about what happens to TX Push (efx_ef10_push_tx_desc), for similar reasons.
So I think TX PIO and TX Push both need to be suppressed when skb->xmit_more (as a correctness issue), and should also be suppressed on the !xmit_more skb that 'uncorks' a previous row of xmit_mores - as a performance issue at the least, and for TX Push I'm also unsure about the correctness (though I haven't worked that one through in detail).
Until these issues are addressed, I have to NAK this. Tomorrow I'll try to rustle up an rfc patch that handles these issues, unless someone beats me to it.
-Edward
Quoted 45 lines
Signed-off-by Daniel Borkmann <[email protected]>Cc Shradha Shah <[email protected]>--- drivers/net/ethernet/sfc/tx.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)drivers/net/ethernet/sfc/tx.c +8
-7@@ -439,13 +439,13 @@ finish_packet:netdev_tx_sent_queue (tx_queue->core_txq, skb->len); +efx_tx_maybe_stop_queue (tx_queue); +/* Pass off to hardware */ -efx_nic_push_buffers (tx_queue); +if (!skb->xmit_more ||netif_xmit_stopped (tx_queue->core_txq)) +efx_nic_push_buffers (tx_queue); tx_queue->tx_packets++; - -efx_tx_maybe_stop_queue (tx_queue); -return NETDEV_TX_OK ; dma_err:@@ -1308,11 +1308,12 @@ static int efx_enqueue_skb_tso(struct efx_tx_queue *tx_queue,netdev_tx_sent_queue (tx_queue->core_txq, skb->len); -/* Pass off to hardware */ -efx_nic_push_buffers (tx_queue); -efx_tx_maybe_stop_queue (tx_queue); +/* Pass off to hardware */ +if (!skb->xmit_more ||netif_xmit_stopped (tx_queue->core_txq)) +efx_nic_push_buffers (tx_queue); + tx_queue->tso_bursts++;return NETDEV_TX_OK ;
On 10/13/2014 08:02 PM, Edward Cree wrote:
...
Quoted 3 lines
Until these issues are addressed, I have to NAK this. Tomorrow I'll try to rustle up an rfc patch that handles these issues, unless someone beats me to it.
Thanks for your feedback! Yes, please feel free to take this onwards and integrate/adapt it to your needs for sfc's xmit_more support.
Thanks a lot,
Daniel
RFC PATCH 1/1 sfc: add support for skb->xmit_more
Don't ring the doorbell, and don't do PIO. This will also prevent
TX Push, because there will be more than one buffer waiting when the doorbell is rung.
---
drivers/net/ethernet/sfc/nic.h | 29 +++++++++++++++++++++++----- drivers/net/ethernet/sfc/tx.c | 43 +++++++++++++++++------------------------- 2 files changed, 41 insertions(+), 31 deletions(-)
drivers/net/ethernet/sfc/nic.h +24 -5
@@ -71,9 +71,17 @@ efx_tx_desc(struct efx_tx_queue *tx_queue, unsigned int index)return ((efx_qword_t *) (tx_queue->txd.buf.addr)) + index; } -/* Report whether the NIC considers this TX queue empty, given the -* write_count used for the last doorbell push. May return false -* negative. +/* Get partner of a TX queue, seen as part of the same net core queue */ +static struct efx_tx_queue *efx_tx_queue_partner (struct efx_tx_queue *tx_queue) +{ +if (tx_queue->queue &EFX_TXQ_TYPE_OFFLOAD ) +return tx_queue -EFX_TXQ_TYPE_OFFLOAD ; +else +return tx_queue +EFX_TXQ_TYPE_OFFLOAD ; +} + +/* Report whether this TX queue would be empty for the given write_count. +* May return false negative. */ static inline bool __efx_nic_tx_is_empty (struct efx_tx_queue *tx_queue,unsigned int write_count)
@@ -86,9 +94,18 @@ static inline bool __efx_nic_tx_is_empty(struct efx_tx_queue *tx_queue,return ((empty_read_count ^ write_count) & ~EFX_EMPTY_COUNT_VALID ) ==0 ; } -static inline bool efx_nic_tx_is_empty (struct efx_tx_queue *tx_queue) +/* Decide whether we can use TX PIO, ie. write packet data directly into +* a buffer on the device. This can reduce latency at the expense of +* throughput, so we only do this if both hardware and software TX rings +* are empty. This also ensures that only one packet at a time can be +* using the PIO buffer. +*/ +static inline bool efx_nic_may_tx_pio (struct efx_tx_queue *tx_queue) { -return __efx_nic_tx_is_empty (tx_queue, tx_queue->write_count); +struct efx_tx_queue *partner =efx_tx_queue_partner (tx_queue); +return tx_queue->piobuf && +__efx_nic_tx_is_empty (tx_queue, tx_queue->insert_count) && +__efx_nic_tx_is_empty (partner, partner->insert_count); }/* Decide whether to push a TX descriptor to the NIC vs merely writing
@@ -96,6 +113,8 @@ static inline bool efx_nic_tx_is_empty(struct efx_tx_queue *tx_queue)* descriptor to an empty queue, but is otherwise pointless. Further, * Falcon and Siena have hardware bugs (SF bug 33851) that may be * triggered if we don't check this. +* We use the write_count used for the last doorbell push, to get the +* NIC's view of the tx queue. */ static inline bool efx_nic_may_push_tx_desc (struct efx_tx_queue *tx_queue,unsigned int write_count)
drivers/net/ethernet/sfc/tx.c +17 -26
118 lines not on this page · raw message
Signature · 1 line
1.7.11.7
David Miller
maintainerRe: [PATCH RFC net-next] sfc: add support for skb->xmit_more
From: Edward Cree <[email protected]>
Date: Tue, 14 Oct 2014 19:41:37 +0100
Quoted 5 lines
Don't ring the doorbell, and don't do PIO. This will also prevent
TX Push, because there will be more than one buffer waiting when the doorbell is rung.Signed-off-by Edward Cree <[email protected]>
This looks good to me, mind if I apply this now?
Re: [PATCH RFC net-next] sfc: add support for skb->xmit_more
Quoted 9 lines · David Miller
From: Edward Cree <[email protected]>
Date: Tue, 14 Oct 2014 19:41:37 +0100Quoted 5 lines
Don't ring the doorbell, and don't do PIO. This will also prevent
TX Push, because there will be more than one buffer waiting when the doorbell is rung.Signed-off-by Edward Cree <[email protected]>This looks good to me, mind if I apply this now?
I'd rather wait until Jon Cooper's had a chance to look at it; he understands our TX path better than I.
-Edward
David Miller
maintainerRe: [PATCH RFC net-next] sfc: add support for skb->xmit_more
From: Edward Cree <[email protected]>
Date: Wed, 15 Oct 2014 12:05:35 +0100
Quoted 12 lines · David Miller
Quoted 9 lines
From: Edward Cree <[email protected]>
Date: Tue, 14 Oct 2014 19:41:37 +0100Quoted 5 lines
Don't ring the doorbell, and don't do PIO. This will also prevent
TX Push, because there will be more than one buffer waiting when the doorbell is rung.Signed-off-by Edward Cree <[email protected]>This looks good to me, mind if I apply this now?
I'd rather wait until Jon Cooper's had a chance to look at it; he understands our TX path better than I.
Ok.
Jonathan Cooper
Acked-byRe: [PATCH RFC net-next] sfc: add support for skb->xmit_more
Quoted 11 lines · David Miller
From: Edward Cree <[email protected]>
Date: Wed, 15 Oct 2014 12:05:35 +0100Quoted 8 lines · David Miller
Quoted 7 lines
From: Edward Cree <[email protected]>
Date: Tue, 14 Oct 2014 19:41:37 +0100Quoted 4 lines
Don't ring the doorbell, and don't do PIO. This will also prevent
TX Push, because there will be more than one buffer waiting when the doorbell is rung.
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines
Quoted 1 line
Signed-off-by Edward Cree <[email protected]>This looks good to me, mind if I apply this now?
I'd rather wait until Jon Cooper's had a chance to look at it; he understands our TX path better than I.
Ok.
Looks good to me.
Re: [PATCH RFC net-next] sfc: add support for skb->xmit_more
In reply to Edward CreeQuoted 8 lines · Edward Cree
Don't ring the doorbell, and don't do PIO. This will also prevent
TX Push, because there will be more than one buffer waiting when the doorbell is rung.Signed-off-by Edward Cree <[email protected]>---
drivers/net/ethernet/sfc/tx.c netdev_tx_t efx_enqueue_skb(struct efx_tx_queue *tx_queue, struct sk_buff *skb) · line 347
Quoted 7 lines
drivers/net/ethernet/sfc/tx.c +0
-2@@ -351,8 +343,6 @@ netdev_tx_t efx_enqueue_skb(struct efx_tx_queue *tx_queue, struct sk_buff *skb)unsigned short dma_flags;int i =0 ; -EFX_BUG_ON_PARANOID (tx_queue->write_count != tx_queue->insert_count); -if (skb_shinfo (skb)->gso_size)return efx_enqueue_skb_tso (tx_queue, skb);
Would it be possible to keep a weaker version of this check i.e. EFX_BUG_ON_PARANOID(tx_queue->write_count > tx_queue->insert_count);
Quoted 6 lines
drivers/net/ethernet/sfc/tx.c +1
-0@@ -1258,14 +1249,13 @@ static int efx_enqueue_skb_tso(struct efx_tx_queue *tx_queue, struct sk_buff *skb) {struct efx_nic *efx = tx_queue->efx; +unsigned int old_insert_count = tx_queue->insert_count;int frag_i, rc;
drivers/net/ethernet/sfc/tx.c static int efx_enqueue_skb_tso(struct efx_tx_queue *tx_queue, · line 1261
Quoted 10 lines
drivers/net/ethernet/sfc/tx.c +0
-2struct tso_state state;/* Find the packet protocol and sanity-check it */ state.protocol =efx_tso_check_protocol (skb); -EFX_BUG_ON_PARANOID (tx_queue->write_count != tx_queue->insert_count); - rc =tso_start (&state, efx, skb);if (rc) goto mem_err;
The same would apply here.
Thanks
Rob
PATCH 1/1 sfc: add support for skb->xmit_more
Don't ring the doorbell, and don't do PIO. This will also prevent
TX Push, because there will be more than one buffer waiting when the doorbell is rung.
--- drivers/net/ethernet/sfc/nic.h | 29 +++++++++++++++++++++++----- drivers/net/ethernet/sfc/tx.c | 43 +++++++++++++++++++----------------------- 2 files changed, 43 insertions(+), 29 deletions(-)
drivers/net/ethernet/sfc/nic.h +24 -5
@@ -71,9 +71,17 @@ efx_tx_desc(struct efx_tx_queue *tx_queue, unsigned int index)return ((efx_qword_t *) (tx_queue->txd.buf.addr)) + index; } -/* Report whether the NIC considers this TX queue empty, given the -* write_count used for the last doorbell push. May return false -* negative. +/* Get partner of a TX queue, seen as part of the same net core queue */ +static struct efx_tx_queue *efx_tx_queue_partner (struct efx_tx_queue *tx_queue) +{ +if (tx_queue->queue &EFX_TXQ_TYPE_OFFLOAD ) +return tx_queue -EFX_TXQ_TYPE_OFFLOAD ; +else +return tx_queue +EFX_TXQ_TYPE_OFFLOAD ; +} + +/* Report whether this TX queue would be empty for the given write_count. +* May return false negative. */ static inline bool __efx_nic_tx_is_empty (struct efx_tx_queue *tx_queue,unsigned int write_count)
@@ -86,9 +94,18 @@ static inline bool __efx_nic_tx_is_empty(struct efx_tx_queue *tx_queue,return ((empty_read_count ^ write_count) & ~EFX_EMPTY_COUNT_VALID ) ==0 ; } -static inline bool efx_nic_tx_is_empty (struct efx_tx_queue *tx_queue) +/* Decide whether we can use TX PIO, ie. write packet data directly into +* a buffer on the device. This can reduce latency at the expense of +* throughput, so we only do this if both hardware and software TX rings +* are empty. This also ensures that only one packet at a time can be +* using the PIO buffer. +*/ +static inline bool efx_nic_may_tx_pio (struct efx_tx_queue *tx_queue) { -return __efx_nic_tx_is_empty (tx_queue, tx_queue->write_count); +struct efx_tx_queue *partner =efx_tx_queue_partner (tx_queue); +return tx_queue->piobuf && +__efx_nic_tx_is_empty (tx_queue, tx_queue->insert_count) && +__efx_nic_tx_is_empty (partner, partner->insert_count); }/* Decide whether to push a TX descriptor to the NIC vs merely writing
@@ -96,6 +113,8 @@ static inline bool efx_nic_tx_is_empty(struct efx_tx_queue *tx_queue)* descriptor to an empty queue, but is otherwise pointless. Further, * Falcon and Siena have hardware bugs (SF bug 33851) that may be * triggered if we don't check this. +* We use the write_count used for the last doorbell push, to get the +* NIC's view of the tx queue. */ static inline bool efx_nic_may_push_tx_desc (struct efx_tx_queue *tx_queue,unsigned int write_count)
drivers/net/ethernet/sfc/tx.c +19 -24
118 lines not on this page · raw message
Signature · 1 line
1.7.11.7
Re: [PATCH net-next] sfc: add support for skb->xmit_more
From: Edward Cree <[email protected]>
Date: Fri, 17 Oct 2014 15:32:25 +0100
Quoted 5 lines
Don't ring the doorbell, and don't do PIO. This will also prevent
TX Push, because there will be more than one buffer waiting when the doorbell is rung.Signed-off-by Edward Cree <[email protected]>
Applied, thanks.
Re: [PATCH net-next] sfc: add support for skb->xmit_more
In reply to Edward CreeOn Fri, 2014-10-17 at 15:32 +0100, Edward Cree wrote:
[...]
drivers/net/ethernet/sfc/tx.c netdev_tx_t efx_enqueue_skb(struct efx_tx_queue *tx_queue, struct sk_buff *skb) · line 346
Quoted 6 lines
drivers/net/ethernet/sfc/tx.c +1
-1@@ -351,7 +343,7 @@ netdev_tx_t efx_enqueue_skb(struct efx_tx_queue *tx_queue, struct sk_buff *skb)unsigned short dma_flags;int i =0 ; -EFX_BUG_ON_PARANOID (tx_queue->write_count != tx_queue->insert_count); +EFX_BUG_ON_PARANOID (tx_queue->write_count > tx_queue->insert_count);
[...]
Doesn't this break after 2^32 descriptors? It seems like you would need a similar comparison to time_after(); possibly:
EFX_BUG_ON_PARANOID((int)(tx_queue->write_count - tx_queue->insert_count) > 0);
Ben.
Signature · 2 lines
Ben Hutchings For every action, there is an equal and opposite criticism. - Harrison
Re: [PATCH net-next] sfc: add support for skb->xmit_more
Quoted 10 lines · Ben Hutchings
On Fri, 2014-10-17 at 15:32 +0100, Edward Cree wrote:
[...]Quoted 6 lines
drivers/net/ethernet/sfc/tx.c +1
-1@@ -351,7 +343,7 @@ netdev_tx_t efx_enqueue_skb(struct efx_tx_queue *tx_queue, struct sk_buff *skb)unsigned short dma_flags;int i =0 ; -EFX_BUG_ON_PARANOID (tx_queue->write_count != tx_queue->insert_count); +EFX_BUG_ON_PARANOID (tx_queue->write_count > tx_queue->insert_count);[...]
Quoted 7 lines
Doesn't this break after 2^32 descriptors? It seems like you would need a similar comparison to
time_after(); possibly:EFX_BUG_ON_PARANOID((int)(tx_queue->write_count - tx_queue->insert_count) > 0);Ben.
Yes, Jon already spotted that. We just diked it out - see "[PATCH net]
sfc: remove incorrect EFX_BUG_ON_PARANOID check"
http://patchwork.ozlabs.org/patch/401503/
But your suggestion is a good one; feel free to post as a new patch on that thread.
-Edward