* [PATCH 0/2] pf_packet fixes
@ 2014-04-02 18:52 Daniel Borkmann
2014-04-02 18:52 ` [PATCH 1/2] packet: report tx_dropped in packet_direct_xmit Daniel Borkmann
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Daniel Borkmann @ 2014-04-02 18:52 UTC (permalink / raw)
To: davem; +Cc: eric.dumazet, netdev
Applies to net-next tree. Thanks!
Daniel Borkmann (2):
packet: report tx_dropped in packet_direct_xmit
packet: fix packet_direct_xmit for BQL enabled drivers
include/linux/netdevice.h | 24 +++++++++++++++++++-----
net/packet/af_packet.c | 3 ++-
2 files changed, 21 insertions(+), 6 deletions(-)
--
1.7.11.7
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] packet: report tx_dropped in packet_direct_xmit
2014-04-02 18:52 [PATCH 0/2] pf_packet fixes Daniel Borkmann
@ 2014-04-02 18:52 ` Daniel Borkmann
2014-04-02 18:52 ` [PATCH 2/2] packet: fix packet_direct_xmit for BQL enabled drivers Daniel Borkmann
2014-04-03 18:29 ` [PATCH 0/2] pf_packet fixes David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Daniel Borkmann @ 2014-04-02 18:52 UTC (permalink / raw)
To: davem; +Cc: eric.dumazet, netdev
Since commit 015f0688f57c ("net: net: add a core netdev->tx_dropped
counter"), we can now account for TX drops from within the core
stack instead of drivers.
Therefore, fix packet_direct_xmit() and increase drop count when we
encounter a problem before driver's xmit function was called (we do
not want to doubly account for it).
Suggested-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
---
net/packet/af_packet.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 01039d2..c81a971 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -275,6 +275,7 @@ static int packet_direct_xmit(struct sk_buff *skb)
return ret;
drop:
+ atomic_long_inc(&dev->tx_dropped);
kfree_skb(skb);
return NET_XMIT_DROP;
}
--
1.7.11.7
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] packet: fix packet_direct_xmit for BQL enabled drivers
2014-04-02 18:52 [PATCH 0/2] pf_packet fixes Daniel Borkmann
2014-04-02 18:52 ` [PATCH 1/2] packet: report tx_dropped in packet_direct_xmit Daniel Borkmann
@ 2014-04-02 18:52 ` Daniel Borkmann
2014-04-03 18:29 ` [PATCH 0/2] pf_packet fixes David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Daniel Borkmann @ 2014-04-02 18:52 UTC (permalink / raw)
To: davem; +Cc: eric.dumazet, netdev, Eric Dumazet
Currently, in packet_direct_xmit() we test the assigned netdevice queue
for netif_xmit_frozen_or_stopped() before doing an ndo_start_xmit().
This can have the side-effect that BQL enabled drivers which make use
of netdev_tx_sent_queue() internally, set __QUEUE_STATE_STACK_XOFF from
within the stack and would not fully fill the device's TX ring from
packet sockets with PACKET_QDISC_BYPASS enabled.
Instead, use a test without BQL bit so that bursts can be absorbed
into the NICs TX ring. Fix and code suggested by Eric Dumazet, thanks!
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
---
include/linux/netdevice.h | 24 +++++++++++++++++++-----
net/packet/af_packet.c | 2 +-
2 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 775cc95..7ed3a3a 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -519,11 +519,18 @@ enum netdev_queue_state_t {
__QUEUE_STATE_DRV_XOFF,
__QUEUE_STATE_STACK_XOFF,
__QUEUE_STATE_FROZEN,
-#define QUEUE_STATE_ANY_XOFF ((1 << __QUEUE_STATE_DRV_XOFF) | \
- (1 << __QUEUE_STATE_STACK_XOFF))
-#define QUEUE_STATE_ANY_XOFF_OR_FROZEN (QUEUE_STATE_ANY_XOFF | \
- (1 << __QUEUE_STATE_FROZEN))
};
+
+#define QUEUE_STATE_DRV_XOFF (1 << __QUEUE_STATE_DRV_XOFF)
+#define QUEUE_STATE_STACK_XOFF (1 << __QUEUE_STATE_STACK_XOFF)
+#define QUEUE_STATE_FROZEN (1 << __QUEUE_STATE_FROZEN)
+
+#define QUEUE_STATE_ANY_XOFF (QUEUE_STATE_DRV_XOFF | QUEUE_STATE_STACK_XOFF)
+#define QUEUE_STATE_ANY_XOFF_OR_FROZEN (QUEUE_STATE_ANY_XOFF | \
+ QUEUE_STATE_FROZEN)
+#define QUEUE_STATE_DRV_XOFF_OR_FROZEN (QUEUE_STATE_DRV_XOFF | \
+ QUEUE_STATE_FROZEN)
+
/*
* __QUEUE_STATE_DRV_XOFF is used by drivers to stop the transmit queue. The
* netif_tx_* functions below are used to manipulate this flag. The
@@ -2252,11 +2259,18 @@ static inline bool netif_xmit_stopped(const struct netdev_queue *dev_queue)
return dev_queue->state & QUEUE_STATE_ANY_XOFF;
}
-static inline bool netif_xmit_frozen_or_stopped(const struct netdev_queue *dev_queue)
+static inline bool
+netif_xmit_frozen_or_stopped(const struct netdev_queue *dev_queue)
{
return dev_queue->state & QUEUE_STATE_ANY_XOFF_OR_FROZEN;
}
+static inline bool
+netif_xmit_frozen_or_drv_stopped(const struct netdev_queue *dev_queue)
+{
+ return dev_queue->state & QUEUE_STATE_DRV_XOFF_OR_FROZEN;
+}
+
static inline void netdev_tx_sent_queue(struct netdev_queue *dev_queue,
unsigned int bytes)
{
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index c81a971..72e0c71 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -261,7 +261,7 @@ static int packet_direct_xmit(struct sk_buff *skb)
local_bh_disable();
HARD_TX_LOCK(dev, txq, smp_processor_id());
- if (!netif_xmit_frozen_or_stopped(txq)) {
+ if (!netif_xmit_frozen_or_drv_stopped(txq)) {
ret = ops->ndo_start_xmit(skb, dev);
if (ret == NETDEV_TX_OK)
txq_trans_update(txq);
--
1.7.11.7
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] pf_packet fixes
2014-04-02 18:52 [PATCH 0/2] pf_packet fixes Daniel Borkmann
2014-04-02 18:52 ` [PATCH 1/2] packet: report tx_dropped in packet_direct_xmit Daniel Borkmann
2014-04-02 18:52 ` [PATCH 2/2] packet: fix packet_direct_xmit for BQL enabled drivers Daniel Borkmann
@ 2014-04-03 18:29 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2014-04-03 18:29 UTC (permalink / raw)
To: dborkman; +Cc: eric.dumazet, netdev
From: Daniel Borkmann <dborkman@redhat.com>
Date: Wed, 2 Apr 2014 20:52:55 +0200
> Applies to net-next tree. Thanks!
>
> Daniel Borkmann (2):
> packet: report tx_dropped in packet_direct_xmit
> packet: fix packet_direct_xmit for BQL enabled drivers
Series applied, thanks a lot.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-04-03 18:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-02 18:52 [PATCH 0/2] pf_packet fixes Daniel Borkmann
2014-04-02 18:52 ` [PATCH 1/2] packet: report tx_dropped in packet_direct_xmit Daniel Borkmann
2014-04-02 18:52 ` [PATCH 2/2] packet: fix packet_direct_xmit for BQL enabled drivers Daniel Borkmann
2014-04-03 18:29 ` [PATCH 0/2] pf_packet fixes 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).