summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaolo Abeni <pabeni@redhat.com>2016-07-20 12:11:32 -0400
committerDavid S. Miller <davem@davemloft.net>2016-07-22 00:50:41 -0400
commit5491e7c6b1a95df39b917e16f2eeddc84f9e8491 (patch)
tree5d8e34879a4a9c47ad1bf63481254f23bce0f61e
parent5f652bb2eb3eb38f97194ce5c41da1fa12e914b8 (diff)
macsec: enable GRO and RPS on macsec devices
Use gro_gells to trigger GRO and allow RPS on macsec traffic after decryption. Also, be sure to avoid clearing software offload features in macsec_fix_features(). Overall this increase TCP tput by 30% on recent h/w. Signed-off-by: Paolo Abeni <pabeni@redhat.com> Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/macsec.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index 8bcd78f94966..0cbb935078da 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -18,6 +18,7 @@
18#include <linux/rtnetlink.h> 18#include <linux/rtnetlink.h>
19#include <net/genetlink.h> 19#include <net/genetlink.h>
20#include <net/sock.h> 20#include <net/sock.h>
21#include <net/gro_cells.h>
21 22
22#include <uapi/linux/if_macsec.h> 23#include <uapi/linux/if_macsec.h>
23 24
@@ -268,6 +269,7 @@ struct macsec_dev {
268 struct net_device *real_dev; 269 struct net_device *real_dev;
269 struct pcpu_secy_stats __percpu *stats; 270 struct pcpu_secy_stats __percpu *stats;
270 struct list_head secys; 271 struct list_head secys;
272 struct gro_cells gro_cells;
271}; 273};
272 274
273/** 275/**
@@ -879,7 +881,7 @@ static void macsec_decrypt_done(struct crypto_async_request *base, int err)
879 macsec_reset_skb(skb, macsec->secy.netdev); 881 macsec_reset_skb(skb, macsec->secy.netdev);
880 882
881 len = skb->len; 883 len = skb->len;
882 ret = netif_rx(skb); 884 ret = gro_cells_receive(&macsec->gro_cells, skb);
883 if (ret == NET_RX_SUCCESS) 885 if (ret == NET_RX_SUCCESS)
884 count_rx(dev, len); 886 count_rx(dev, len);
885 else 887 else
@@ -1052,6 +1054,7 @@ static rx_handler_result_t macsec_handle_frame(struct sk_buff **pskb)
1052 struct pcpu_rx_sc_stats *rxsc_stats; 1054 struct pcpu_rx_sc_stats *rxsc_stats;
1053 struct pcpu_secy_stats *secy_stats; 1055 struct pcpu_secy_stats *secy_stats;
1054 bool pulled_sci; 1056 bool pulled_sci;
1057 int ret;
1055 1058
1056 if (skb_headroom(skb) < ETH_HLEN) 1059 if (skb_headroom(skb) < ETH_HLEN)
1057 goto drop_direct; 1060 goto drop_direct;
@@ -1193,12 +1196,17 @@ deliver:
1193 1196
1194 if (rx_sa) 1197 if (rx_sa)
1195 macsec_rxsa_put(rx_sa); 1198 macsec_rxsa_put(rx_sa);
1196 count_rx(dev, skb->len); 1199
1200 ret = gro_cells_receive(&macsec->gro_cells, skb);
1201 if (ret == NET_RX_SUCCESS)
1202 count_rx(dev, skb->len);
1203 else
1204 macsec->secy.netdev->stats.rx_dropped++;
1197 1205
1198 rcu_read_unlock(); 1206 rcu_read_unlock();
1199 1207
1200 *pskb = skb; 1208 *pskb = NULL;
1201 return RX_HANDLER_ANOTHER; 1209 return RX_HANDLER_CONSUMED;
1202 1210
1203drop: 1211drop:
1204 macsec_rxsa_put(rx_sa); 1212 macsec_rxsa_put(rx_sa);
@@ -1218,7 +1226,6 @@ nosci:
1218 1226
1219 list_for_each_entry_rcu(macsec, &rxd->secys, secys) { 1227 list_for_each_entry_rcu(macsec, &rxd->secys, secys) {
1220 struct sk_buff *nskb; 1228 struct sk_buff *nskb;
1221 int ret;
1222 1229
1223 secy_stats = this_cpu_ptr(macsec->stats); 1230 secy_stats = this_cpu_ptr(macsec->stats);
1224 1231
@@ -2675,11 +2682,18 @@ static int macsec_dev_init(struct net_device *dev)
2675{ 2682{
2676 struct macsec_dev *macsec = macsec_priv(dev); 2683 struct macsec_dev *macsec = macsec_priv(dev);
2677 struct net_device *real_dev = macsec->real_dev; 2684 struct net_device *real_dev = macsec->real_dev;
2685 int err;
2678 2686
2679 dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); 2687 dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
2680 if (!dev->tstats) 2688 if (!dev->tstats)
2681 return -ENOMEM; 2689 return -ENOMEM;
2682 2690
2691 err = gro_cells_init(&macsec->gro_cells, dev);
2692 if (err) {
2693 free_percpu(dev->tstats);
2694 return err;
2695 }
2696
2683 dev->features = real_dev->features & MACSEC_FEATURES; 2697 dev->features = real_dev->features & MACSEC_FEATURES;
2684 dev->features |= NETIF_F_LLTX | NETIF_F_GSO_SOFTWARE; 2698 dev->features |= NETIF_F_LLTX | NETIF_F_GSO_SOFTWARE;
2685 2699
@@ -2698,6 +2712,9 @@ static int macsec_dev_init(struct net_device *dev)
2698 2712
2699static void macsec_dev_uninit(struct net_device *dev) 2713static void macsec_dev_uninit(struct net_device *dev)
2700{ 2714{
2715 struct macsec_dev *macsec = macsec_priv(dev);
2716
2717 gro_cells_destroy(&macsec->gro_cells);
2701 free_percpu(dev->tstats); 2718 free_percpu(dev->tstats);
2702} 2719}
2703 2720
@@ -2707,8 +2724,9 @@ static netdev_features_t macsec_fix_features(struct net_device *dev,
2707 struct macsec_dev *macsec = macsec_priv(dev); 2724 struct macsec_dev *macsec = macsec_priv(dev);
2708 struct net_device *real_dev = macsec->real_dev; 2725 struct net_device *real_dev = macsec->real_dev;
2709 2726
2710 features &= real_dev->features & MACSEC_FEATURES; 2727 features &= (real_dev->features & MACSEC_FEATURES) |
2711 features |= NETIF_F_LLTX | NETIF_F_GSO_SOFTWARE; 2728 NETIF_F_GSO_SOFTWARE | NETIF_F_SOFT_FEATURES;
2729 features |= NETIF_F_LLTX;
2712 2730
2713 return features; 2731 return features;
2714} 2732}