mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-07-15 10:09:40 +02:00

The main desire behind this is to provide coherent bridge information to the fast path without locking. For example, right now we set dp->bridge_dev and dp->bridge_num from separate code paths, it is theoretically possible for a packet transmission to read these two port properties consecutively and find a bridge number which does not correspond with the bridge device. Another desire is to start passing more complex bridge information to dsa_switch_ops functions. For example, with FDB isolation, it is expected that drivers will need to be passed the bridge which requested an FDB/MDB entry to be offloaded, and along with that bridge_dev, the associated bridge_num should be passed too, in case the driver might want to implement an isolation scheme based on that number. We already pass the {bridge_dev, bridge_num} pair to the TX forwarding offload switch API, however we'd like to remove that and squash it into the basic bridge join/leave API. So that means we need to pass this pair to the bridge join/leave API. During dsa_port_bridge_leave, first we unset dp->bridge_dev, then we call the driver's .port_bridge_leave with what used to be our dp->bridge_dev, but provided as an argument. When bridge_dev and bridge_num get folded into a single structure, we need to preserve this behavior in dsa_port_bridge_leave: we need a copy of what used to be in dp->bridge. Switch drivers check bridge membership by comparing dp->bridge_dev with the provided bridge_dev, but now, if we provide the struct dsa_bridge as a pointer, they cannot keep comparing dp->bridge to the provided pointer, since this only points to an on-stack copy. To make this obvious and prevent driver writers from forgetting and doing stupid things, in this new API, the struct dsa_bridge is provided as a full structure (not very large, contains an int and a pointer) instead of a pointer. An explicit comparison function needs to be used to determine bridge membership: dsa_port_offloads_bridge(). Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Alvin Šipraga <alsi@bang-olufsen.dk> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
63 lines
1.4 KiB
C
63 lines
1.4 KiB
C
/* SPDX-License-Identifier: GPL-2.0
|
|
* Copyright (c) 2019, Vladimir Oltean <olteanv@gmail.com>
|
|
*/
|
|
|
|
#ifndef _NET_DSA_8021Q_H
|
|
#define _NET_DSA_8021Q_H
|
|
|
|
#include <linux/refcount.h>
|
|
#include <linux/types.h>
|
|
#include <net/dsa.h>
|
|
|
|
struct dsa_switch;
|
|
struct dsa_port;
|
|
struct sk_buff;
|
|
struct net_device;
|
|
|
|
struct dsa_tag_8021q_vlan {
|
|
struct list_head list;
|
|
int port;
|
|
u16 vid;
|
|
refcount_t refcount;
|
|
};
|
|
|
|
struct dsa_8021q_context {
|
|
struct dsa_switch *ds;
|
|
struct list_head vlans;
|
|
/* EtherType of RX VID, used for filtering on master interface */
|
|
__be16 proto;
|
|
};
|
|
|
|
int dsa_tag_8021q_register(struct dsa_switch *ds, __be16 proto);
|
|
|
|
void dsa_tag_8021q_unregister(struct dsa_switch *ds);
|
|
|
|
struct sk_buff *dsa_8021q_xmit(struct sk_buff *skb, struct net_device *netdev,
|
|
u16 tpid, u16 tci);
|
|
|
|
void dsa_8021q_rcv(struct sk_buff *skb, int *source_port, int *switch_id);
|
|
|
|
int dsa_tag_8021q_bridge_tx_fwd_offload(struct dsa_switch *ds, int port,
|
|
struct dsa_bridge bridge);
|
|
|
|
void dsa_tag_8021q_bridge_tx_fwd_unoffload(struct dsa_switch *ds, int port,
|
|
struct dsa_bridge bridge);
|
|
|
|
u16 dsa_8021q_bridge_tx_fwd_offload_vid(unsigned int bridge_num);
|
|
|
|
u16 dsa_tag_8021q_tx_vid(const struct dsa_port *dp);
|
|
|
|
u16 dsa_tag_8021q_rx_vid(const struct dsa_port *dp);
|
|
|
|
int dsa_8021q_rx_switch_id(u16 vid);
|
|
|
|
int dsa_8021q_rx_source_port(u16 vid);
|
|
|
|
bool vid_is_dsa_8021q_rxvlan(u16 vid);
|
|
|
|
bool vid_is_dsa_8021q_txvlan(u16 vid);
|
|
|
|
bool vid_is_dsa_8021q(u16 vid);
|
|
|
|
#endif /* _NET_DSA_8021Q_H */
|