tag_8021q definitions are all over the place. Some are exported to linux/dsa/8021q.h (visible by DSA core, taggers, switch drivers and everyone else), and some are in dsa_priv.h. Move the structures that don't need external visibility into tag_8021q.c, and the ones which don't need the world or switch drivers to see them into tag_8021q.h. We also have the tag_8021q.h inclusion from switch.c, which is basically the entire reason why tag_8021q.c was built into DSA in commit 8b6e638b4be2 ("net: dsa: build tag_8021q.c as part of DSA core"). I still don't know how to better deal with that, so leave it alone.
Unified · Split
| @@ -5,28 +5,8 @@ · 4 unmodified lines | |||
| 5 | #ifndef _NET_DSA_8021Q_H | 5 | #ifndef _NET_DSA_8021Q_H |
| 6 | #define _NET_DSA_8021Q_H | 6 | #define _NET_DSA_8021Q_H |
| 7 | 7 | ||
| 8 | #include <linux/refcount.h> | ||
| 9 | #include <linux/types.h> | ||
| 10 | #include <net/dsa.h> | 8 | #include <net/dsa.h> |
| 11 | 9 | #include <linux/types.h> | |
| 12 | struct dsa_switch; | ||
| 13 | struct dsa_port; | ||
| 14 | struct sk_buff; | ||
| 15 | struct net_device; | ||
| 16 | |||
| 17 | struct dsa_tag_8021q_vlan { | ||
| 18 | struct list_head list; | ||
| 19 | int port; | ||
| 20 | u16 vid; | ||
| 21 | refcount_t refcount; | ||
| 22 | }; | ||
| 23 | |||
| 24 | struct dsa_8021q_context { | ||
| 25 | struct dsa_switch *ds; | ||
| 26 | struct list_head vlans; | ||
| 27 | /* EtherType of RX VID, used for filtering on master interface */ | ||
| 28 | __be16 proto; | ||
| 29 | }; | ||
| 30 | 10 | ||
| 31 | int dsa_tag_8021q_register(struct dsa_switch *ds, __be16 proto); | 11 | int dsa_tag_8021q_register(struct dsa_switch *ds, __be16 proto); |
| 32 | 12 | ||
| @@ -38,15 +18,6 @@ int dsa_tag_8021q_bridge_join(struct dsa_switch *ds, int port, · 5 unmodified lines | |||
| 38 | void dsa_tag_8021q_bridge_leave(struct dsa_switch *ds, int port, | 18 | void dsa_tag_8021q_bridge_leave(struct dsa_switch *ds, int port, |
| 39 | struct dsa_bridge bridge); | 19 | struct dsa_bridge bridge); |
| 40 | 20 | ||
| 41 | struct sk_buff *dsa_8021q_xmit(struct sk_buff *skb, struct net_device *netdev, | ||
| 42 | u16 tpid, u16 tci); | ||
| 43 | |||
| 44 | void dsa_8021q_rcv(struct sk_buff *skb, int *source_port, int *switch_id, | ||
| 45 | int *vbid); | ||
| 46 | |||
| 47 | struct net_device *dsa_tag_8021q_find_port_by_vbid(struct net_device *master, | ||
| 48 | int vbid); | ||
| 49 | |||
| 50 | u16 dsa_tag_8021q_bridge_vid(unsigned int bridge_num); | 21 | u16 dsa_tag_8021q_bridge_vid(unsigned int bridge_num); |
| 51 | 22 | ||
| 52 | u16 dsa_tag_8021q_standalone_vid(const struct dsa_port *dp); | 23 | u16 dsa_tag_8021q_standalone_vid(const struct dsa_port *dp); |
| @@ -22,6 +22,7 @@ · 21 unmodified lines | |||
| 22 | #include <net/devlink.h> | 22 | #include <net/devlink.h> |
| 23 | #include <net/switchdev.h> | 23 | #include <net/switchdev.h> |
| 24 | 24 | ||
| 25 | struct dsa_8021q_context; | ||
| 25 | struct tc_action; | 26 | struct tc_action; |
| 26 | struct phy_device; | 27 | struct phy_device; |
| 27 | struct fixed_phy_status; | 28 | struct fixed_phy_status; |
| @@ -13,15 +13,7 @@ · 12 unmodified lines | |||
| 13 | 13 | ||
| 14 | #define DSA_MAX_NUM_OFFLOADING_BRIDGES BITS_PER_LONG | 14 | #define DSA_MAX_NUM_OFFLOADING_BRIDGES BITS_PER_LONG |
| 15 | 15 | ||
| 16 | struct dsa_notifier_tag_8021q_vlan_info; | ||
| 17 | |||
| 18 | /* netlink.c */ | 16 | /* netlink.c */ |
| 19 | extern struct rtnl_link_ops dsa_link_ops __read_mostly; | 17 | extern struct rtnl_link_ops dsa_link_ops __read_mostly; |
| 20 | 18 | ||
| 21 | /* tag_8021q.c */ | ||
| 22 | int dsa_switch_tag_8021q_vlan_add(struct dsa_switch *ds, | ||
| 23 | struct dsa_notifier_tag_8021q_vlan_info *info); | ||
| 24 | int dsa_switch_tag_8021q_vlan_del(struct dsa_switch *ds, | ||
| 25 | struct dsa_notifier_tag_8021q_vlan_info *info); | ||
| 26 | |||
| 27 | #endif | 19 | #endif |
| @@ -16,6 +16,7 @@ · 15 unmodified lines | |||
| 16 | #include "port.h" | 16 | #include "port.h" |
| 17 | #include "slave.h" | 17 | #include "slave.h" |
| 18 | #include "switch.h" | 18 | #include "switch.h" |
| 19 | #include "tag_8021q.h" | ||
| 19 | 20 | ||
| 20 | /** | 21 | /** |
| 21 | * dsa_port_notify - Notify the switching fabric of changes to a port | 22 | * dsa_port_notify - Notify the switching fabric of changes to a port |
| @@ -17,6 +17,7 @@ · 16 unmodified lines | |||
| 17 | #include "port.h" | 17 | #include "port.h" |
| 18 | #include "slave.h" | 18 | #include "slave.h" |
| 19 | #include "switch.h" | 19 | #include "switch.h" |
| 20 | #include "tag_8021q.h" | ||
| 20 | 21 | ||
| 21 | static unsigned int dsa_switch_fastest_ageing_time(struct dsa_switch *ds, | 22 | static unsigned int dsa_switch_fastest_ageing_time(struct dsa_switch *ds, |
| 22 | unsigned int ageing_time) | 23 | unsigned int ageing_time) |
| @@ -11,6 +11,7 @@ · 10 unmodified lines | |||
| 11 | #include "port.h" | 11 | #include "port.h" |
| 12 | #include "switch.h" | 12 | #include "switch.h" |
| 13 | #include "tag.h" | 13 | #include "tag.h" |
| 14 | #include "tag_8021q.h" | ||
| 14 | 15 | ||
| 15 | /* Binary structure of the fake 12-bit VID field (when the TPID is | 16 | /* Binary structure of the fake 12-bit VID field (when the TPID is |
| 16 | * ETH_P_DSA_8021Q): | 17 | * ETH_P_DSA_8021Q): |
| @@ -63,6 +64,20 @@ · 46 unmodified lines | |||
| 63 | #define DSA_8021Q_PORT(x) (((x) << DSA_8021Q_PORT_SHIFT) & \ | 64 | #define DSA_8021Q_PORT(x) (((x) << DSA_8021Q_PORT_SHIFT) & \ |
| 64 | DSA_8021Q_PORT_MASK) | 65 | DSA_8021Q_PORT_MASK) |
| 65 | 66 | ||
| 67 | struct dsa_tag_8021q_vlan { | ||
| 68 | struct list_head list; | ||
| 69 | int port; | ||
| 70 | u16 vid; | ||
| 71 | refcount_t refcount; | ||
| 72 | }; | ||
| 73 | |||
| 74 | struct dsa_8021q_context { | ||
| 75 | struct dsa_switch *ds; | ||
| 76 | struct list_head vlans; | ||
| 77 | /* EtherType of RX VID, used for filtering on master interface */ | ||
| 78 | __be16 proto; | ||
| 79 | }; | ||
| 80 | |||
| 66 | u16 dsa_tag_8021q_bridge_vid(unsigned int bridge_num) | 81 | u16 dsa_tag_8021q_bridge_vid(unsigned int bridge_num) |
| 67 | { | 82 | { |
| 68 | /* The VBID value of 0 is reserved for precise TX, but it is also | 83 | /* The VBID value of 0 is reserved for precise TX, but it is also |
| @@ -0,0 +1,27 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ | ||
| 2 | |||
| 3 | #ifndef __DSA_TAG_8021Q_H | ||
| 4 | #define __DSA_TAG_8021Q_H | ||
| 5 | |||
| 6 | #include <net/dsa.h> | ||
| 7 | |||
| 8 | #include "switch.h" | ||
| 9 | |||
| 10 | struct sk_buff; | ||
| 11 | struct net_device; | ||
| 12 | |||
| 13 | struct sk_buff *dsa_8021q_xmit(struct sk_buff *skb, struct net_device *netdev, | ||
| 14 | u16 tpid, u16 tci); | ||
| 15 | |||
| 16 | void dsa_8021q_rcv(struct sk_buff *skb, int *source_port, int *switch_id, | ||
| 17 | int *vbid); | ||
| 18 | |||
| 19 | struct net_device *dsa_tag_8021q_find_port_by_vbid(struct net_device *master, | ||
| 20 | int vbid); | ||
| 21 | |||
| 22 | int dsa_switch_tag_8021q_vlan_add(struct dsa_switch *ds, | ||
| 23 | struct dsa_notifier_tag_8021q_vlan_info *info); | ||
| 24 | int dsa_switch_tag_8021q_vlan_del(struct dsa_switch *ds, | ||
| 25 | struct dsa_notifier_tag_8021q_vlan_info *info); | ||
| 26 | |||
| 27 | #endif | ||
| @@ -12,6 +12,7 @@ · 11 unmodified lines | |||
| 12 | #include <linux/dsa/ocelot.h> | 12 | #include <linux/dsa/ocelot.h> |
| 13 | 13 | ||
| 14 | #include "tag.h" | 14 | #include "tag.h" |
| 15 | #include "tag_8021q.h" | ||
| 15 | 16 | ||
| 16 | #define OCELOT_8021Q_NAME "ocelot-8021q" | 17 | #define OCELOT_8021Q_NAME "ocelot-8021q" |
| 17 | 18 | ||
| @@ -7,6 +7,7 @@ · 6 unmodified lines | |||
| 7 | #include <linux/packing.h> | 7 | #include <linux/packing.h> |
| 8 | 8 | ||
| 9 | #include "tag.h" | 9 | #include "tag.h" |
| 10 | #include "tag_8021q.h" | ||
| 10 | 11 | ||
| 11 | #define SJA1105_NAME "sja1105" | 12 | #define SJA1105_NAME "sja1105" |
| 12 | #define SJA1110_NAME "sja1110" | 13 | #define SJA1110_NAME "sja1110" |