diff options
author | Neil Horman <nhorman@tuxdriver.com> | 2014-01-22 16:01:44 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-01-22 20:35:50 -0500 |
commit | 2d36097d26b5991d71a2cf4a20c1a158f0f1bfcd (patch) | |
tree | 86ad219b1481a17780efec984c314e1b0f6bc87e /net/packet/af_packet.c | |
parent | b414ac9a3ea8a547e4a413160d36bffefb2ba5c7 (diff) |
af_packet: Add Queue mapping mode to af_packet fanout operation
This patch adds a queue mapping mode to the fanout operation of af_packet
sockets. This allows user space af_packet users to better filter on flows
ingressing and egressing via a specific hardware queue, and avoids the potential
packet reordering that can occur when FANOUT_CPU is being used and irq affinity
varies.
Tested successfully by myself. applies to net-next
Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
CC: "David S. Miller" <davem@davemloft.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/packet/af_packet.c')
-rw-r--r-- | net/packet/af_packet.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 97346162803d..6a2bb37506c5 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c | |||
@@ -1312,6 +1312,13 @@ static unsigned int fanout_demux_rollover(struct packet_fanout *f, | |||
1312 | return idx; | 1312 | return idx; |
1313 | } | 1313 | } |
1314 | 1314 | ||
1315 | static unsigned int fanout_demux_qm(struct packet_fanout *f, | ||
1316 | struct sk_buff *skb, | ||
1317 | unsigned int num) | ||
1318 | { | ||
1319 | return skb_get_queue_mapping(skb) % num; | ||
1320 | } | ||
1321 | |||
1315 | static bool fanout_has_flag(struct packet_fanout *f, u16 flag) | 1322 | static bool fanout_has_flag(struct packet_fanout *f, u16 flag) |
1316 | { | 1323 | { |
1317 | return f->flags & (flag >> 8); | 1324 | return f->flags & (flag >> 8); |
@@ -1351,6 +1358,9 @@ static int packet_rcv_fanout(struct sk_buff *skb, struct net_device *dev, | |||
1351 | case PACKET_FANOUT_RND: | 1358 | case PACKET_FANOUT_RND: |
1352 | idx = fanout_demux_rnd(f, skb, num); | 1359 | idx = fanout_demux_rnd(f, skb, num); |
1353 | break; | 1360 | break; |
1361 | case PACKET_FANOUT_QM: | ||
1362 | idx = fanout_demux_qm(f, skb, num); | ||
1363 | break; | ||
1354 | case PACKET_FANOUT_ROLLOVER: | 1364 | case PACKET_FANOUT_ROLLOVER: |
1355 | idx = fanout_demux_rollover(f, skb, 0, (unsigned int) -1, num); | 1365 | idx = fanout_demux_rollover(f, skb, 0, (unsigned int) -1, num); |
1356 | break; | 1366 | break; |
@@ -1421,6 +1431,7 @@ static int fanout_add(struct sock *sk, u16 id, u16 type_flags) | |||
1421 | case PACKET_FANOUT_LB: | 1431 | case PACKET_FANOUT_LB: |
1422 | case PACKET_FANOUT_CPU: | 1432 | case PACKET_FANOUT_CPU: |
1423 | case PACKET_FANOUT_RND: | 1433 | case PACKET_FANOUT_RND: |
1434 | case PACKET_FANOUT_QM: | ||
1424 | break; | 1435 | break; |
1425 | default: | 1436 | default: |
1426 | return -EINVAL; | 1437 | return -EINVAL; |