dsa: Add MODULE_ALIAS to taggers in preparation to become modules
authorAndrew Lunn <andrew@lunn.ch>
Sun, 28 Apr 2019 17:37:12 +0000 (19:37 +0200)
committerDavid S. Miller <davem@davemloft.net>
Sun, 28 Apr 2019 23:41:01 +0000 (19:41 -0400)
When the tag drivers become modules, we will need to dynamically load
them based on what the switch drivers need. Add aliases to map between
the TAG protocol and the driver.

In order to do this, we need the tag protocol number as something
which the C pre-processor can stringinfy. Only the compiler knows the
value of an enum, CPP cannot use them. So add #defines.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/dsa.h
net/dsa/tag_brcm.c
net/dsa/tag_dsa.c
net/dsa/tag_edsa.c
net/dsa/tag_gswip.c
net/dsa/tag_ksz.c
net/dsa/tag_lan9303.c
net/dsa/tag_mtk.c
net/dsa/tag_qca.c
net/dsa/tag_trailer.c

index 801346e31e9bb1cda1b10c39e1812dfbd002778d..8f3d5e0825a2efac1e15523023bc110647e048d0 100644 (file)
@@ -30,20 +30,33 @@ struct phy_device;
 struct fixed_phy_status;
 struct phylink_link_state;
 
+#define DSA_TAG_PROTO_NONE_VALUE               0
+#define DSA_TAG_PROTO_BRCM_VALUE               1
+#define DSA_TAG_PROTO_BRCM_PREPEND_VALUE       2
+#define DSA_TAG_PROTO_DSA_VALUE                        3
+#define DSA_TAG_PROTO_EDSA_VALUE               4
+#define DSA_TAG_PROTO_GSWIP_VALUE              5
+#define DSA_TAG_PROTO_KSZ9477_VALUE            6
+#define DSA_TAG_PROTO_KSZ9893_VALUE            7
+#define DSA_TAG_PROTO_LAN9303_VALUE            8
+#define DSA_TAG_PROTO_MTK_VALUE                        9
+#define DSA_TAG_PROTO_QCA_VALUE                        10
+#define DSA_TAG_PROTO_TRAILER_VALUE            11
+
 enum dsa_tag_protocol {
-       DSA_TAG_PROTO_NONE = 0,
-       DSA_TAG_PROTO_BRCM,
-       DSA_TAG_PROTO_BRCM_PREPEND,
-       DSA_TAG_PROTO_DSA,
-       DSA_TAG_PROTO_EDSA,
-       DSA_TAG_PROTO_GSWIP,
-       DSA_TAG_PROTO_KSZ9477,
-       DSA_TAG_PROTO_KSZ9893,
-       DSA_TAG_PROTO_LAN9303,
-       DSA_TAG_PROTO_MTK,
-       DSA_TAG_PROTO_QCA,
-       DSA_TAG_PROTO_TRAILER,
-       DSA_TAG_LAST,           /* MUST BE LAST */
+       DSA_TAG_PROTO_NONE              = DSA_TAG_PROTO_NONE_VALUE,
+       DSA_TAG_PROTO_BRCM              = DSA_TAG_PROTO_BRCM_VALUE,
+       DSA_TAG_PROTO_BRCM_PREPEND      = DSA_TAG_PROTO_BRCM_PREPEND_VALUE,
+       DSA_TAG_PROTO_DSA               = DSA_TAG_PROTO_DSA_VALUE,
+       DSA_TAG_PROTO_EDSA              = DSA_TAG_PROTO_EDSA_VALUE,
+       DSA_TAG_PROTO_GSWIP             = DSA_TAG_PROTO_GSWIP_VALUE,
+       DSA_TAG_PROTO_KSZ9477           = DSA_TAG_PROTO_KSZ9477_VALUE,
+       DSA_TAG_PROTO_KSZ9893           = DSA_TAG_PROTO_KSZ9893_VALUE,
+       DSA_TAG_PROTO_LAN9303           = DSA_TAG_PROTO_LAN9303_VALUE,
+       DSA_TAG_PROTO_MTK               = DSA_TAG_PROTO_MTK_VALUE,
+       DSA_TAG_PROTO_QCA               = DSA_TAG_PROTO_QCA_VALUE,
+       DSA_TAG_PROTO_TRAILER           = DSA_TAG_PROTO_TRAILER_VALUE,
+       DSA_TAG_LAST,                   /* MUST BE LAST */
 };
 
 struct packet_type;
@@ -59,6 +72,10 @@ struct dsa_device_ops {
        const char *name;
 };
 
+#define DSA_TAG_DRIVER_ALIAS "dsa_tag-"
+#define MODULE_ALIAS_DSA_TAG_DRIVER(__proto)                           \
+       MODULE_ALIAS(DSA_TAG_DRIVER_ALIAS __stringify(__proto##_VALUE))
+
 struct dsa_switch_tree {
        struct list_head        list;
 
index 1b7dfbe6b3aec34df920af42fea4453ae0202aed..24d8f45a7e6fd88d6bcb82f5d5f5f71d7066afe1 100644 (file)
@@ -173,6 +173,8 @@ const struct dsa_device_ops brcm_netdev_ops = {
        .rcv    = brcm_tag_rcv,
        .overhead = BRCM_TAG_LEN,
 };
+
+MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_BRCM);
 #endif
 
 #ifdef CONFIG_NET_DSA_TAG_BRCM_PREPEND
@@ -198,3 +200,5 @@ const struct dsa_device_ops brcm_prepend_netdev_ops = {
        .overhead = BRCM_TAG_LEN,
 };
 #endif
+
+MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_BRCM_PREPEND);
index e1c90709de6cc501c97bcae17a279cd43a979677..8aefaf96c1cabd467cd48bb1e67ce0297b4e0ea3 100644 (file)
@@ -157,3 +157,5 @@ const struct dsa_device_ops dsa_netdev_ops = {
        .flow_dissect   = dsa_tag_flow_dissect,
        .overhead = DSA_HLEN,
 };
+
+MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_DSA);
index b936b4660b717f1cf9d15d3c9d480f4ca97f9a85..bad12e760f3d8cda51944eb781d31fbde9399f8e 100644 (file)
@@ -176,3 +176,5 @@ const struct dsa_device_ops edsa_netdev_ops = {
        .flow_dissect   = edsa_tag_flow_dissect,
        .overhead = EDSA_HLEN,
 };
+
+MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_EDSA);
index d1c1e7db87b69c62b878128a1ea28b1250cafd61..30bf7036620ffc3d5e981b2b9ca057dfc1ca905d 100644 (file)
@@ -109,3 +109,5 @@ const struct dsa_device_ops gswip_netdev_ops = {
        .rcv = gswip_tag_rcv,
        .overhead = GSWIP_RX_HEADER_LEN,
 };
+
+MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_GSWIP);
index 631094599514c37dce0df4e01ebdc91949ffac29..9be0f5f12afbfccf9044fb9ced1eec0a98519eed 100644 (file)
@@ -140,6 +140,8 @@ const struct dsa_device_ops ksz9477_netdev_ops = {
        .overhead = KSZ9477_INGRESS_TAG_LEN,
 };
 
+MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_KSZ9477);
+
 #define KSZ9893_TAIL_TAG_OVERRIDE      BIT(5)
 #define KSZ9893_TAIL_TAG_LOOKUP                BIT(6)
 
@@ -173,3 +175,5 @@ const struct dsa_device_ops ksz9893_netdev_ops = {
        .rcv    = ksz9477_rcv,
        .overhead = KSZ_INGRESS_TAG_LEN,
 };
+
+MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_KSZ9893);
index 67d70339536d8fdb610c7e47c47a8f9efcef9b45..48bca20024d4d9131cae354984f7553b2be445f7 100644 (file)
@@ -134,3 +134,5 @@ const struct dsa_device_ops lan9303_netdev_ops = {
        .rcv = lan9303_rcv,
        .overhead = LAN9303_TAG_LEN,
 };
+
+MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_LAN9303);
index dc537d9a18c01c54b09fede9d8745dd799001885..23210a65cbed87b4d56725a407b777520ee1cced 100644 (file)
@@ -105,3 +105,5 @@ const struct dsa_device_ops mtk_netdev_ops = {
        .flow_dissect   = mtk_tag_flow_dissect,
        .overhead       = MTK_HDR_LEN,
 };
+
+MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_MTK);
index f62296ffc5b7584c1421b171b121f4ff8c16c1d3..7d9cb178da3deff2af2d6f858654038b59d077d9 100644 (file)
@@ -106,3 +106,5 @@ const struct dsa_device_ops qca_netdev_ops = {
        .flow_dissect = qca_tag_flow_dissect,
        .overhead = QCA_HDR_LEN,
 };
+
+MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_QCA);
index 20ee7f84fe4df183779780baa987881b6a88824b..00d521cf9c484a5579b0b0d449c30fd75d3b0eeb 100644 (file)
@@ -83,3 +83,5 @@ const struct dsa_device_ops trailer_netdev_ops = {
        .rcv    = trailer_rcv,
        .overhead = 4,
 };
+
+MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_TRAILER);