net: dsa: prepare master receive hot path
authorVivien Didelot <vivien.didelot@savoirfairelinux.com>
Fri, 29 Sep 2017 21:19:19 +0000 (17:19 -0400)
committerDavid S. Miller <davem@davemloft.net>
Sun, 1 Oct 2017 03:15:07 +0000 (04:15 +0100)
In preparation to make DSA master devices point to their corresponding
CPU port instead of the whole tree, add copies of dst and rcv in the
dsa_port structure so that we keep fast access in the receive hot path.

Also keep the copies at the beginning of the dsa_port structure in order
to ensure they are available in cacheline 1.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/dsa.h
net/dsa/dsa2.c
net/dsa/legacy.c

index 4d1df2f086e898b82a97b3023e346d6727cc875d..6bda01fa574779a7432b596fd4003f98b10a216d 100644 (file)
@@ -178,6 +178,11 @@ struct dsa_port {
        /* CPU port tagging operations used by master or slave devices */
        const struct dsa_device_ops *tag_ops;
 
+       /* Copies for faster access in master receive hot path */
+       struct dsa_switch_tree *dst;
+       struct sk_buff *(*rcv)(struct sk_buff *skb, struct net_device *dev,
+                              struct packet_type *pt);
+
        struct dsa_switch       *ds;
        unsigned int            index;
        const char              *name;
index 9eac4726dc0c823a8c5c5c838e6cc60435e9eddc..b71e3bb478e43c554065a317f032d35b2f0f9243 100644 (file)
@@ -524,7 +524,11 @@ static int dsa_cpu_parse(struct dsa_port *port, u32 index,
 
        dst->cpu_dp->tag_ops = tag_ops;
        dst->tag_ops = tag_ops;
+
+       /* Make a few copies for faster access in master receive hot path */
+       dst->cpu_dp->rcv = dst->cpu_dp->tag_ops->rcv;
        dst->rcv = dst->tag_ops->rcv;
+       dst->cpu_dp->dst = dst;
 
        return 0;
 }
index 4d374541815ac50ccfb290073582017dc4adf338..96c7e3f8b8bb86ea12cabe4115993bdbfb7b26c9 100644 (file)
@@ -154,7 +154,11 @@ static int dsa_switch_setup_one(struct dsa_switch *ds,
 
                dst->cpu_dp->tag_ops = tag_ops;
                dst->tag_ops = tag_ops;
+
+               /* Few copies for faster access in master receive hot path */
+               dst->cpu_dp->rcv = dst->cpu_dp->tag_ops->rcv;
                dst->rcv = dst->tag_ops->rcv;
+               dst->cpu_dp->dst = dst;
        }
 
        memcpy(ds->rtable, cd->rtable, sizeof(ds->rtable));