dsa.h (6a43cba3034015d1c029c8a81b62eb9c2660fd6e) dsa.h (d3eed0e57d5d1bcbf1bd60f83a4adfe7d7b8dd9c)
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*
3 * include/net/dsa.h - Driver for Distributed Switch Architecture switch chips
4 * Copyright (c) 2008-2009 Marvell Semiconductor
5 */
6
7#ifndef __LINUX_NET_DSA_H
8#define __LINUX_NET_DSA_H

--- 205 unchanged lines hidden (view full) ---

214 unsigned long cookie;
215 enum dsa_port_mall_action_type type;
216 union {
217 struct dsa_mall_mirror_tc_entry mirror;
218 struct dsa_mall_policer_tc_entry policer;
219 };
220};
221
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*
3 * include/net/dsa.h - Driver for Distributed Switch Architecture switch chips
4 * Copyright (c) 2008-2009 Marvell Semiconductor
5 */
6
7#ifndef __LINUX_NET_DSA_H
8#define __LINUX_NET_DSA_H

--- 205 unchanged lines hidden (view full) ---

214 unsigned long cookie;
215 enum dsa_port_mall_action_type type;
216 union {
217 struct dsa_mall_mirror_tc_entry mirror;
218 struct dsa_mall_policer_tc_entry policer;
219 };
220};
221
222struct dsa_bridge {
223 struct net_device *dev;
224 unsigned int num;
225 refcount_t refcount;
226};
222
223struct dsa_port {
224 /* A CPU port is physically connected to a master device.
225 * A user port exposed to userspace has a slave device.
226 */
227 union {
228 struct net_device *master;
229 struct net_device *slave;

--- 21 unchanged lines hidden (view full) ---

251 struct dsa_port *cpu_dp;
252 u8 mac[ETH_ALEN];
253 struct device_node *dn;
254 unsigned int ageing_time;
255 bool vlan_filtering;
256 /* Managed by DSA on user ports and by drivers on CPU and DSA ports */
257 bool learning;
258 u8 stp_state;
227
228struct dsa_port {
229 /* A CPU port is physically connected to a master device.
230 * A user port exposed to userspace has a slave device.
231 */
232 union {
233 struct net_device *master;
234 struct net_device *slave;

--- 21 unchanged lines hidden (view full) ---

256 struct dsa_port *cpu_dp;
257 u8 mac[ETH_ALEN];
258 struct device_node *dn;
259 unsigned int ageing_time;
260 bool vlan_filtering;
261 /* Managed by DSA on user ports and by drivers on CPU and DSA ports */
262 bool learning;
263 u8 stp_state;
259 struct net_device *bridge_dev;
260 unsigned int bridge_num;
264 struct dsa_bridge *bridge;
261 struct devlink_port devlink_port;
262 bool devlink_port_setup;
263 struct phylink *pl;
264 struct phylink_config pl_config;
265 struct net_device *lag_dev;
266 bool lag_tx_enabled;
267 struct net_device *hsr_dev;
268

--- 314 unchanged lines hidden (view full) ---

583 return ds->vlan_filtering;
584 else
585 return dp->vlan_filtering;
586}
587
588static inline
589struct net_device *dsa_port_to_bridge_port(const struct dsa_port *dp)
590{
265 struct devlink_port devlink_port;
266 bool devlink_port_setup;
267 struct phylink *pl;
268 struct phylink_config pl_config;
269 struct net_device *lag_dev;
270 bool lag_tx_enabled;
271 struct net_device *hsr_dev;
272

--- 314 unchanged lines hidden (view full) ---

587 return ds->vlan_filtering;
588 else
589 return dp->vlan_filtering;
590}
591
592static inline
593struct net_device *dsa_port_to_bridge_port(const struct dsa_port *dp)
594{
591 if (!dp->bridge_dev)
595 if (!dp->bridge)
592 return NULL;
593
594 if (dp->lag_dev)
595 return dp->lag_dev;
596 else if (dp->hsr_dev)
597 return dp->hsr_dev;
598
599 return dp->slave;
600}
601
602static inline struct net_device *
603dsa_port_bridge_dev_get(const struct dsa_port *dp)
604{
596 return NULL;
597
598 if (dp->lag_dev)
599 return dp->lag_dev;
600 else if (dp->hsr_dev)
601 return dp->hsr_dev;
602
603 return dp->slave;
604}
605
606static inline struct net_device *
607dsa_port_bridge_dev_get(const struct dsa_port *dp)
608{
605 return dp->bridge_dev;
609 return dp->bridge ? dp->bridge->dev : NULL;
606}
607
608static inline unsigned int dsa_port_bridge_num_get(struct dsa_port *dp)
609{
610}
611
612static inline unsigned int dsa_port_bridge_num_get(struct dsa_port *dp)
613{
610 return dp->bridge_num;
614 return dp->bridge ? dp->bridge->num : 0;
611}
612
613static inline bool dsa_port_bridge_same(const struct dsa_port *a,
614 const struct dsa_port *b)
615{
616 struct net_device *br_a = dsa_port_bridge_dev_get(a);
617 struct net_device *br_b = dsa_port_bridge_dev_get(b);
618

--- 12 unchanged lines hidden (view full) ---

631 const struct net_device *bridge_dev)
632{
633 /* DSA ports connected to a bridge, and event was emitted
634 * for the bridge.
635 */
636 return dsa_port_bridge_dev_get(dp) == bridge_dev;
637}
638
615}
616
617static inline bool dsa_port_bridge_same(const struct dsa_port *a,
618 const struct dsa_port *b)
619{
620 struct net_device *br_a = dsa_port_bridge_dev_get(a);
621 struct net_device *br_b = dsa_port_bridge_dev_get(b);
622

--- 12 unchanged lines hidden (view full) ---

635 const struct net_device *bridge_dev)
636{
637 /* DSA ports connected to a bridge, and event was emitted
638 * for the bridge.
639 */
640 return dsa_port_bridge_dev_get(dp) == bridge_dev;
641}
642
643static inline bool dsa_port_offloads_bridge(struct dsa_port *dp,
644 const struct dsa_bridge *bridge)
645{
646 return dsa_port_bridge_dev_get(dp) == bridge->dev;
647}
648
639/* Returns true if any port of this tree offloads the given net_device */
640static inline bool dsa_tree_offloads_bridge_port(struct dsa_switch_tree *dst,
641 const struct net_device *dev)
642{
643 struct dsa_port *dp;
644
645 list_for_each_entry(dp, &dst->ports, list)
646 if (dsa_port_offloads_bridge_port(dp, dev))

--- 160 unchanged lines hidden (view full) ---

807 int (*port_prechangeupper)(struct dsa_switch *ds, int port,
808 struct netdev_notifier_changeupper_info *info);
809
810 /*
811 * Bridge integration
812 */
813 int (*set_ageing_time)(struct dsa_switch *ds, unsigned int msecs);
814 int (*port_bridge_join)(struct dsa_switch *ds, int port,
649/* Returns true if any port of this tree offloads the given net_device */
650static inline bool dsa_tree_offloads_bridge_port(struct dsa_switch_tree *dst,
651 const struct net_device *dev)
652{
653 struct dsa_port *dp;
654
655 list_for_each_entry(dp, &dst->ports, list)
656 if (dsa_port_offloads_bridge_port(dp, dev))

--- 160 unchanged lines hidden (view full) ---

817 int (*port_prechangeupper)(struct dsa_switch *ds, int port,
818 struct netdev_notifier_changeupper_info *info);
819
820 /*
821 * Bridge integration
822 */
823 int (*set_ageing_time)(struct dsa_switch *ds, unsigned int msecs);
824 int (*port_bridge_join)(struct dsa_switch *ds, int port,
815 struct net_device *bridge);
825 struct dsa_bridge bridge);
816 void (*port_bridge_leave)(struct dsa_switch *ds, int port,
826 void (*port_bridge_leave)(struct dsa_switch *ds, int port,
817 struct net_device *bridge);
827 struct dsa_bridge bridge);
818 /* Called right after .port_bridge_join() */
819 int (*port_bridge_tx_fwd_offload)(struct dsa_switch *ds, int port,
828 /* Called right after .port_bridge_join() */
829 int (*port_bridge_tx_fwd_offload)(struct dsa_switch *ds, int port,
820 struct net_device *bridge,
821 unsigned int bridge_num);
830 struct dsa_bridge bridge);
822 /* Called right before .port_bridge_leave() */
823 void (*port_bridge_tx_fwd_unoffload)(struct dsa_switch *ds, int port,
831 /* Called right before .port_bridge_leave() */
832 void (*port_bridge_tx_fwd_unoffload)(struct dsa_switch *ds, int port,
824 struct net_device *bridge,
825 unsigned int bridge_num);
833 struct dsa_bridge bridge);
826 void (*port_stp_state_set)(struct dsa_switch *ds, int port,
827 u8 state);
828 void (*port_fast_age)(struct dsa_switch *ds, int port);
829 int (*port_pre_bridge_flags)(struct dsa_switch *ds, int port,
830 struct switchdev_brport_flags flags,
831 struct netlink_ext_ack *extack);
832 int (*port_bridge_flags)(struct dsa_switch *ds, int port,
833 struct switchdev_brport_flags flags,

--- 55 unchanged lines hidden (view full) ---

889 int (*port_setup_tc)(struct dsa_switch *ds, int port,
890 enum tc_setup_type type, void *type_data);
891
892 /*
893 * Cross-chip operations
894 */
895 int (*crosschip_bridge_join)(struct dsa_switch *ds, int tree_index,
896 int sw_index, int port,
834 void (*port_stp_state_set)(struct dsa_switch *ds, int port,
835 u8 state);
836 void (*port_fast_age)(struct dsa_switch *ds, int port);
837 int (*port_pre_bridge_flags)(struct dsa_switch *ds, int port,
838 struct switchdev_brport_flags flags,
839 struct netlink_ext_ack *extack);
840 int (*port_bridge_flags)(struct dsa_switch *ds, int port,
841 struct switchdev_brport_flags flags,

--- 55 unchanged lines hidden (view full) ---

897 int (*port_setup_tc)(struct dsa_switch *ds, int port,
898 enum tc_setup_type type, void *type_data);
899
900 /*
901 * Cross-chip operations
902 */
903 int (*crosschip_bridge_join)(struct dsa_switch *ds, int tree_index,
904 int sw_index, int port,
897 struct net_device *br);
905 struct dsa_bridge bridge);
898 void (*crosschip_bridge_leave)(struct dsa_switch *ds, int tree_index,
899 int sw_index, int port,
906 void (*crosschip_bridge_leave)(struct dsa_switch *ds, int tree_index,
907 int sw_index, int port,
900 struct net_device *br);
908 struct dsa_bridge bridge);
901 int (*crosschip_lag_change)(struct dsa_switch *ds, int sw_index,
902 int port);
903 int (*crosschip_lag_join)(struct dsa_switch *ds, int sw_index,
904 int port, struct net_device *lag,
905 struct netdev_lag_upper_info *info);
906 int (*crosschip_lag_leave)(struct dsa_switch *ds, int sw_index,
907 int port, struct net_device *lag);
908

--- 348 unchanged lines hidden ---
909 int (*crosschip_lag_change)(struct dsa_switch *ds, int sw_index,
910 int port);
911 int (*crosschip_lag_join)(struct dsa_switch *ds, int sw_index,
912 int port, struct net_device *lag,
913 struct netdev_lag_upper_info *info);
914 int (*crosschip_lag_leave)(struct dsa_switch *ds, int sw_index,
915 int port, struct net_device *lag);
916

--- 348 unchanged lines hidden ---