aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Pirko <jiri@mellanox.com>2017-11-03 06:46:25 -0400
committerDavid S. Miller <davem@davemloft.net>2017-11-03 08:57:24 -0400
commit46209401f8f6116bd0b2c2d14a63958e83ffca0b (patch)
tree54915d3a3f2af715f1681da274e3a98f6198e71b
parentc7eb7d7230509ec862d4144f7a831f995bc5d028 (diff)
net: core: introduce mini_Qdisc and eliminate usage of tp->q for clsact fastpath
In sch_handle_egress and sch_handle_ingress tp->q is used only in order to update stats. So stats and filter list are the only things that are needed in clsact qdisc fastpath processing. Introduce new mini_Qdisc struct to hold those items. Also, introduce a helper to swap the mini_Qdisc structures in case filter list head changes. This removes need for tp->q usage without added overhead. Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/linux/netdevice.h9
-rw-r--r--include/net/sch_generic.h32
-rw-r--r--net/core/dev.c21
-rw-r--r--net/sched/sch_generic.c46
-rw-r--r--net/sched/sch_ingress.c19
5 files changed, 109 insertions, 18 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 5e02f79b2110..7de7656550c2 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1559,6 +1559,8 @@ enum netdev_priv_flags {
1559 * 1559 *
1560 * @rx_handler: handler for received packets 1560 * @rx_handler: handler for received packets
1561 * @rx_handler_data: XXX: need comments on this one 1561 * @rx_handler_data: XXX: need comments on this one
1562 * @miniq_ingress: ingress/clsact qdisc specific data for
1563 * ingress processing
1562 * @ingress_queue: XXX: need comments on this one 1564 * @ingress_queue: XXX: need comments on this one
1563 * @broadcast: hw bcast address 1565 * @broadcast: hw bcast address
1564 * 1566 *
@@ -1576,7 +1578,8 @@ enum netdev_priv_flags {
1576 * @tx_global_lock: XXX: need comments on this one 1578 * @tx_global_lock: XXX: need comments on this one
1577 * 1579 *
1578 * @xps_maps: XXX: need comments on this one 1580 * @xps_maps: XXX: need comments on this one
1579 * 1581 * @miniq_egress: clsact qdisc specific data for
1582 * egress processing
1580 * @watchdog_timeo: Represents the timeout that is used by 1583 * @watchdog_timeo: Represents the timeout that is used by
1581 * the watchdog (see dev_watchdog()) 1584 * the watchdog (see dev_watchdog())
1582 * @watchdog_timer: List of timers 1585 * @watchdog_timer: List of timers
@@ -1795,7 +1798,7 @@ struct net_device {
1795 void __rcu *rx_handler_data; 1798 void __rcu *rx_handler_data;
1796 1799
1797#ifdef CONFIG_NET_CLS_ACT 1800#ifdef CONFIG_NET_CLS_ACT
1798 struct tcf_proto __rcu *ingress_cl_list; 1801 struct mini_Qdisc __rcu *miniq_ingress;
1799#endif 1802#endif
1800 struct netdev_queue __rcu *ingress_queue; 1803 struct netdev_queue __rcu *ingress_queue;
1801#ifdef CONFIG_NETFILTER_INGRESS 1804#ifdef CONFIG_NETFILTER_INGRESS
@@ -1826,7 +1829,7 @@ struct net_device {
1826 struct xps_dev_maps __rcu *xps_maps; 1829 struct xps_dev_maps __rcu *xps_maps;
1827#endif 1830#endif
1828#ifdef CONFIG_NET_CLS_ACT 1831#ifdef CONFIG_NET_CLS_ACT
1829 struct tcf_proto __rcu *egress_cl_list; 1832 struct mini_Qdisc __rcu *miniq_egress;
1830#endif 1833#endif
1831 1834
1832 /* These may be needed for future network-power-down code. */ 1835 /* These may be needed for future network-power-down code. */
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index f230269e0bfb..c64e62c9450a 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -904,4 +904,36 @@ static inline void psched_ratecfg_getrate(struct tc_ratespec *res,
904 res->linklayer = (r->linklayer & TC_LINKLAYER_MASK); 904 res->linklayer = (r->linklayer & TC_LINKLAYER_MASK);
905} 905}
906 906
907/* Mini Qdisc serves for specific needs of ingress/clsact Qdisc.
908 * The fast path only needs to access filter list and to update stats
909 */
910struct mini_Qdisc {
911 struct tcf_proto *filter_list;
912 struct gnet_stats_basic_cpu __percpu *cpu_bstats;
913 struct gnet_stats_queue __percpu *cpu_qstats;
914 struct rcu_head rcu;
915};
916
917static inline void mini_qdisc_bstats_cpu_update(struct mini_Qdisc *miniq,
918 const struct sk_buff *skb)
919{
920 bstats_cpu_update(this_cpu_ptr(miniq->cpu_bstats), skb);
921}
922
923static inline void mini_qdisc_qstats_cpu_drop(struct mini_Qdisc *miniq)
924{
925 this_cpu_inc(miniq->cpu_qstats->drops);
926}
927
928struct mini_Qdisc_pair {
929 struct mini_Qdisc miniq1;
930 struct mini_Qdisc miniq2;
931 struct mini_Qdisc __rcu **p_miniq;
932};
933
934void mini_qdisc_pair_swap(struct mini_Qdisc_pair *miniqp,
935 struct tcf_proto *tp_head);
936void mini_qdisc_pair_init(struct mini_Qdisc_pair *miniqp, struct Qdisc *qdisc,
937 struct mini_Qdisc __rcu **p_miniq);
938
907#endif 939#endif
diff --git a/net/core/dev.c b/net/core/dev.c
index 24ac9083bc13..1423cf4d695c 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3274,22 +3274,22 @@ EXPORT_SYMBOL(dev_loopback_xmit);
3274static struct sk_buff * 3274static struct sk_buff *
3275sch_handle_egress(struct sk_buff *skb, int *ret, struct net_device *dev) 3275sch_handle_egress(struct sk_buff *skb, int *ret, struct net_device *dev)
3276{ 3276{
3277 struct tcf_proto *cl = rcu_dereference_bh(dev->egress_cl_list); 3277 struct mini_Qdisc *miniq = rcu_dereference_bh(dev->miniq_egress);
3278 struct tcf_result cl_res; 3278 struct tcf_result cl_res;
3279 3279
3280 if (!cl) 3280 if (!miniq)
3281 return skb; 3281 return skb;
3282 3282
3283 /* qdisc_skb_cb(skb)->pkt_len was already set by the caller. */ 3283 /* qdisc_skb_cb(skb)->pkt_len was already set by the caller. */
3284 qdisc_bstats_cpu_update(cl->q, skb); 3284 mini_qdisc_bstats_cpu_update(miniq, skb);
3285 3285
3286 switch (tcf_classify(skb, cl, &cl_res, false)) { 3286 switch (tcf_classify(skb, miniq->filter_list, &cl_res, false)) {
3287 case TC_ACT_OK: 3287 case TC_ACT_OK:
3288 case TC_ACT_RECLASSIFY: 3288 case TC_ACT_RECLASSIFY:
3289 skb->tc_index = TC_H_MIN(cl_res.classid); 3289 skb->tc_index = TC_H_MIN(cl_res.classid);
3290 break; 3290 break;
3291 case TC_ACT_SHOT: 3291 case TC_ACT_SHOT:
3292 qdisc_qstats_cpu_drop(cl->q); 3292 mini_qdisc_qstats_cpu_drop(miniq);
3293 *ret = NET_XMIT_DROP; 3293 *ret = NET_XMIT_DROP;
3294 kfree_skb(skb); 3294 kfree_skb(skb);
3295 return NULL; 3295 return NULL;
@@ -4189,7 +4189,7 @@ sch_handle_ingress(struct sk_buff *skb, struct packet_type **pt_prev, int *ret,
4189 struct net_device *orig_dev) 4189 struct net_device *orig_dev)
4190{ 4190{
4191#ifdef CONFIG_NET_CLS_ACT 4191#ifdef CONFIG_NET_CLS_ACT
4192 struct tcf_proto *cl = rcu_dereference_bh(skb->dev->ingress_cl_list); 4192 struct mini_Qdisc *miniq = rcu_dereference_bh(skb->dev->miniq_ingress);
4193 struct tcf_result cl_res; 4193 struct tcf_result cl_res;
4194 4194
4195 /* If there's at least one ingress present somewhere (so 4195 /* If there's at least one ingress present somewhere (so
@@ -4197,8 +4197,9 @@ sch_handle_ingress(struct sk_buff *skb, struct packet_type **pt_prev, int *ret,
4197 * that are not configured with an ingress qdisc will bail 4197 * that are not configured with an ingress qdisc will bail
4198 * out here. 4198 * out here.
4199 */ 4199 */
4200 if (!cl) 4200 if (!miniq)
4201 return skb; 4201 return skb;
4202
4202 if (*pt_prev) { 4203 if (*pt_prev) {
4203 *ret = deliver_skb(skb, *pt_prev, orig_dev); 4204 *ret = deliver_skb(skb, *pt_prev, orig_dev);
4204 *pt_prev = NULL; 4205 *pt_prev = NULL;
@@ -4206,15 +4207,15 @@ sch_handle_ingress(struct sk_buff *skb, struct packet_type **pt_prev, int *ret,
4206 4207
4207 qdisc_skb_cb(skb)->pkt_len = skb->len; 4208 qdisc_skb_cb(skb)->pkt_len = skb->len;
4208 skb->tc_at_ingress = 1; 4209 skb->tc_at_ingress = 1;
4209 qdisc_bstats_cpu_update(cl->q, skb); 4210 mini_qdisc_bstats_cpu_update(miniq, skb);
4210 4211
4211 switch (tcf_classify(skb, cl, &cl_res, false)) { 4212 switch (tcf_classify(skb, miniq->filter_list, &cl_res, false)) {
4212 case TC_ACT_OK: 4213 case TC_ACT_OK:
4213 case TC_ACT_RECLASSIFY: 4214 case TC_ACT_RECLASSIFY:
4214 skb->tc_index = TC_H_MIN(cl_res.classid); 4215 skb->tc_index = TC_H_MIN(cl_res.classid);
4215 break; 4216 break;
4216 case TC_ACT_SHOT: 4217 case TC_ACT_SHOT:
4217 qdisc_qstats_cpu_drop(cl->q); 4218 mini_qdisc_qstats_cpu_drop(miniq);
4218 kfree_skb(skb); 4219 kfree_skb(skb);
4219 return NULL; 4220 return NULL;
4220 case TC_ACT_STOLEN: 4221 case TC_ACT_STOLEN:
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index aa74aa42b5d7..3839cbbdc32b 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -1024,3 +1024,49 @@ void psched_ratecfg_precompute(struct psched_ratecfg *r,
1024 } 1024 }
1025} 1025}
1026EXPORT_SYMBOL(psched_ratecfg_precompute); 1026EXPORT_SYMBOL(psched_ratecfg_precompute);
1027
1028static void mini_qdisc_rcu_func(struct rcu_head *head)
1029{
1030}
1031
1032void mini_qdisc_pair_swap(struct mini_Qdisc_pair *miniqp,
1033 struct tcf_proto *tp_head)
1034{
1035 struct mini_Qdisc *miniq_old = rtnl_dereference(*miniqp->p_miniq);
1036 struct mini_Qdisc *miniq;
1037
1038 if (!tp_head) {
1039 RCU_INIT_POINTER(*miniqp->p_miniq, NULL);
1040 return;
1041 }
1042
1043 miniq = !miniq_old || miniq_old == &miniqp->miniq2 ?
1044 &miniqp->miniq1 : &miniqp->miniq2;
1045