Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: dsa: move tag_8021q headers to their proper place

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.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Vladimir Oltean and committed by
Jakub Kicinski
19d05ea7 8e396fec

+48 -38
+1 -30
include/linux/dsa/8021q.h
··· 5 5 #ifndef _NET_DSA_8021Q_H 6 6 #define _NET_DSA_8021Q_H 7 7 8 - #include <linux/refcount.h> 9 - #include <linux/types.h> 10 8 #include <net/dsa.h> 11 - 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 - }; 9 + #include <linux/types.h> 30 10 31 11 int dsa_tag_8021q_register(struct dsa_switch *ds, __be16 proto); 32 12 ··· 17 37 18 38 void dsa_tag_8021q_bridge_leave(struct dsa_switch *ds, int port, 19 39 struct dsa_bridge bridge); 20 - 21 - struct sk_buff *dsa_8021q_xmit(struct sk_buff *skb, struct net_device *netdev, 22 - u16 tpid, u16 tci); 23 - 24 - void dsa_8021q_rcv(struct sk_buff *skb, int *source_port, int *switch_id, 25 - int *vbid); 26 - 27 - struct net_device *dsa_tag_8021q_find_port_by_vbid(struct net_device *master, 28 - int vbid); 29 40 30 41 u16 dsa_tag_8021q_bridge_vid(unsigned int bridge_num); 31 42
+1
include/net/dsa.h
··· 22 22 #include <net/devlink.h> 23 23 #include <net/switchdev.h> 24 24 25 + struct dsa_8021q_context; 25 26 struct tc_action; 26 27 struct phy_device; 27 28 struct fixed_phy_status;
-8
net/dsa/dsa_priv.h
··· 13 13 14 14 #define DSA_MAX_NUM_OFFLOADING_BRIDGES BITS_PER_LONG 15 15 16 - struct dsa_notifier_tag_8021q_vlan_info; 17 - 18 16 /* netlink.c */ 19 17 extern struct rtnl_link_ops dsa_link_ops __read_mostly; 20 - 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 18 27 19 #endif
+1
net/dsa/port.c
··· 16 16 #include "port.h" 17 17 #include "slave.h" 18 18 #include "switch.h" 19 + #include "tag_8021q.h" 19 20 20 21 /** 21 22 * dsa_port_notify - Notify the switching fabric of changes to a port
+1
net/dsa/switch.c
··· 17 17 #include "port.h" 18 18 #include "slave.h" 19 19 #include "switch.h" 20 + #include "tag_8021q.h" 20 21 21 22 static unsigned int dsa_switch_fastest_ageing_time(struct dsa_switch *ds, 22 23 unsigned int ageing_time)
+15
net/dsa/tag_8021q.c
··· 11 11 #include "port.h" 12 12 #include "switch.h" 13 13 #include "tag.h" 14 + #include "tag_8021q.h" 14 15 15 16 /* Binary structure of the fake 12-bit VID field (when the TPID is 16 17 * ETH_P_DSA_8021Q): ··· 63 62 #define DSA_8021Q_PORT_MASK GENMASK(3, 0) 64 63 #define DSA_8021Q_PORT(x) (((x) << DSA_8021Q_PORT_SHIFT) & \ 65 64 DSA_8021Q_PORT_MASK) 65 + 66 + struct dsa_tag_8021q_vlan { 67 + struct list_head list; 68 + int port; 69 + u16 vid; 70 + refcount_t refcount; 71 + }; 72 + 73 + struct dsa_8021q_context { 74 + struct dsa_switch *ds; 75 + struct list_head vlans; 76 + /* EtherType of RX VID, used for filtering on master interface */ 77 + __be16 proto; 78 + }; 66 79 67 80 u16 dsa_tag_8021q_bridge_vid(unsigned int bridge_num) 68 81 {
+27
net/dsa/tag_8021q.h
··· 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
+1
net/dsa/tag_ocelot_8021q.c
··· 12 12 #include <linux/dsa/ocelot.h> 13 13 14 14 #include "tag.h" 15 + #include "tag_8021q.h" 15 16 16 17 #define OCELOT_8021Q_NAME "ocelot-8021q" 17 18
+1
net/dsa/tag_sja1105.c
··· 7 7 #include <linux/packing.h> 8 8 9 9 #include "tag.h" 10 + #include "tag_8021q.h" 10 11 11 12 #define SJA1105_NAME "sja1105" 12 13 #define SJA1110_NAME "sja1110"