Lines Matching +full:dp +full:- +full:bridge
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * include/net/dsa.h - Driver for Distributed Switch Architecture switch chips
4 * Copyright (c) 2008-2009 Marvell Semiconductor
125 /* Notifier chain for switch-wide events */
134 /* Maps offloaded LAG netdevs to a zero-based linear ID for
166 /* LAG IDs are one-based, the dst->lags array is zero-based */
168 for ((_id) = 1; (_id) <= (_dst)->lags_len; (_id)++) \
169 if ((_dst)->lags[(_id) - 1])
172 list_for_each_entry((_dp), &(_dst)->ports, list) \
176 list_for_each_entry((_dp), &(_ds)->dst->ports, list) \
177 if ((_dp)->ds == (_ds) && (_dp)->hsr_dev == (_hsr))
182 /* DSA LAG IDs are one-based, dst->lags is zero-based */ in dsa_lag_by_id()
183 return dst->lags[id - 1]; in dsa_lag_by_id()
194 if (lag->dev == lag_dev) in dsa_lag_id()
195 return lag->id; in dsa_lag_id()
198 return -ENODEV; in dsa_lag_id()
239 * exposes a network device to user-space, called 'user' here.
295 struct dsa_bridge *bridge; member
335 /* TODO: ideally DSA ports would have a single dp->link_dp member,
336 * and no dst->rtable nor this struct dsa_link would be needed,
341 struct dsa_port *dp; member
356 const struct dsa_port *dp; member
358 struct dsa_bridge bridge; member
391 /* Disallow bridge core from requesting different VLAN awareness
392 * settings on ports if not hardware-supported
406 /* Pop the default_pvid of VLAN-unaware bridge ports from tagged frames.
411 /* Pop the default_pvid of VLAN-aware bridge ports from tagged frames.
414 * VLAN-tagged to the CPU, including those which were originally
420 * CPU, based on the software bridge database.
425 * should be retrieved from here and not from the per-port settings.
436 * to true to receive the bridge as an argument in .port_fdb_{add,del}
437 * and .port_mdb_{add,del}. Otherwise, the bridge.num will always be
500 /* Drivers that support bridge forwarding offload or FDB isolation
502 * switch tree (or all trees, in the case of cross-tree bridging
512 struct dsa_switch_tree *dst = ds->dst; in dsa_to_port()
513 struct dsa_port *dp; in dsa_to_port() local
515 list_for_each_entry(dp, &dst->ports, list) in dsa_to_port()
516 if (dp->ds == ds && dp->index == p) in dsa_to_port()
517 return dp; in dsa_to_port()
524 return port->type == DSA_PORT_TYPE_DSA; in dsa_port_is_dsa()
529 return port->type == DSA_PORT_TYPE_CPU; in dsa_port_is_cpu()
532 static inline bool dsa_port_is_user(struct dsa_port *dp) in dsa_port_is_user() argument
534 return dp->type == DSA_PORT_TYPE_USER; in dsa_port_is_user()
537 static inline bool dsa_port_is_unused(struct dsa_port *dp) in dsa_port_is_unused() argument
539 return dp->type == DSA_PORT_TYPE_UNUSED; in dsa_port_is_unused()
542 static inline bool dsa_port_conduit_is_operational(struct dsa_port *dp) in dsa_port_conduit_is_operational() argument
544 return dsa_port_is_cpu(dp) && dp->conduit_admin_up && in dsa_port_conduit_is_operational()
545 dp->conduit_oper_up; in dsa_port_conduit_is_operational()
550 return dsa_to_port(ds, p)->type == DSA_PORT_TYPE_UNUSED; in dsa_is_unused_port()
555 return dsa_to_port(ds, p)->type == DSA_PORT_TYPE_CPU; in dsa_is_cpu_port()
560 return dsa_to_port(ds, p)->type == DSA_PORT_TYPE_DSA; in dsa_is_dsa_port()
565 return dsa_to_port(ds, p)->type == DSA_PORT_TYPE_USER; in dsa_is_user_port()
569 list_for_each_entry((_dp), &(_dst)->ports, list) \
573 list_for_each_entry_continue_reverse((_dp), &(_dst)->ports, list) \
577 list_for_each_entry((_dp), &(_dst)->ports, list) \
581 list_for_each_entry((_dp), &(_ds)->dst->ports, list) \
582 if ((_dp)->ds == (_ds))
585 list_for_each_entry_safe((_dp), (_next), &(_ds)->dst->ports, list) \
586 if ((_dp)->ds == (_ds))
589 list_for_each_entry_continue_reverse((_dp), &(_ds)->dst->ports, list) \
590 if ((_dp)->ds == (_ds))
614 struct dsa_port *dp; in dsa_user_ports() local
617 dsa_switch_for_each_user_port(dp, ds) in dsa_user_ports()
618 mask |= BIT(dp->index); in dsa_user_ports()
629 mask |= BIT(cpu_dp->index); in dsa_cpu_ports()
637 struct dsa_switch_tree *dst = ds->dst; in dsa_routing_port()
640 list_for_each_entry(dl, &dst->rtable, list) in dsa_routing_port()
641 if (dl->dp->ds == ds && dl->link_dp->ds->index == device) in dsa_routing_port()
642 return dl->dp->index; in dsa_routing_port()
644 return ds->num_ports; in dsa_routing_port()
651 if (device == ds->index) in dsa_towards_port()
660 const struct dsa_port *dp = dsa_to_port(ds, port); in dsa_upstream_port() local
661 const struct dsa_port *cpu_dp = dp->cpu_dp; in dsa_upstream_port()
666 return dsa_towards_port(ds, cpu_dp->ds->index, cpu_dp->index); in dsa_upstream_port()
687 struct dsa_port *dp; in dsa_switch_upstream_port() local
689 dsa_switch_for_each_available_port(dp, ds) { in dsa_switch_upstream_port()
690 return dsa_upstream_port(ds, dp->index); in dsa_switch_upstream_port()
693 return ds->num_ports; in dsa_switch_upstream_port()
708 routing_port = dsa_routing_port(downstream_ds, upstream_ds->index); in dsa_switch_is_upstream_of()
713 static inline bool dsa_port_is_vlan_filtering(const struct dsa_port *dp) in dsa_port_is_vlan_filtering() argument
715 const struct dsa_switch *ds = dp->ds; in dsa_port_is_vlan_filtering()
717 if (ds->vlan_filtering_is_global) in dsa_port_is_vlan_filtering()
718 return ds->vlan_filtering; in dsa_port_is_vlan_filtering()
720 return dp->vlan_filtering; in dsa_port_is_vlan_filtering()
723 static inline unsigned int dsa_port_lag_id_get(struct dsa_port *dp) in dsa_port_lag_id_get() argument
725 return dp->lag ? dp->lag->id : 0; in dsa_port_lag_id_get()
728 static inline struct net_device *dsa_port_lag_dev_get(struct dsa_port *dp) in dsa_port_lag_dev_get() argument
730 return dp->lag ? dp->lag->dev : NULL; in dsa_port_lag_dev_get()
733 static inline bool dsa_port_offloads_lag(struct dsa_port *dp, in dsa_port_offloads_lag() argument
736 return dsa_port_lag_dev_get(dp) == lag->dev; in dsa_port_offloads_lag()
739 static inline struct net_device *dsa_port_to_conduit(const struct dsa_port *dp) in dsa_port_to_conduit() argument
741 if (dp->cpu_port_in_lag) in dsa_port_to_conduit()
742 return dsa_port_lag_dev_get(dp->cpu_dp); in dsa_port_to_conduit()
744 return dp->cpu_dp->conduit; in dsa_port_to_conduit()
748 struct net_device *dsa_port_to_bridge_port(const struct dsa_port *dp) in dsa_port_to_bridge_port() argument
750 if (!dp->bridge) in dsa_port_to_bridge_port()
753 if (dp->lag) in dsa_port_to_bridge_port()
754 return dp->lag->dev; in dsa_port_to_bridge_port()
755 else if (dp->hsr_dev) in dsa_port_to_bridge_port()
756 return dp->hsr_dev; in dsa_port_to_bridge_port()
758 return dp->user; in dsa_port_to_bridge_port()
762 dsa_port_bridge_dev_get(const struct dsa_port *dp) in dsa_port_bridge_dev_get() argument
764 return dp->bridge ? dp->bridge->dev : NULL; in dsa_port_bridge_dev_get()
767 static inline unsigned int dsa_port_bridge_num_get(struct dsa_port *dp) in dsa_port_bridge_num_get() argument
769 return dp->bridge ? dp->bridge->num : 0; in dsa_port_bridge_num_get()
778 /* Standalone ports are not in the same bridge with one another */ in dsa_port_bridge_same()
782 static inline bool dsa_port_offloads_bridge_port(struct dsa_port *dp, in dsa_port_offloads_bridge_port() argument
785 return dsa_port_to_bridge_port(dp) == dev; in dsa_port_offloads_bridge_port()
789 dsa_port_offloads_bridge_dev(struct dsa_port *dp, in dsa_port_offloads_bridge_dev() argument
792 /* DSA ports connected to a bridge, and event was emitted in dsa_port_offloads_bridge_dev()
793 * for the bridge. in dsa_port_offloads_bridge_dev()
795 return dsa_port_bridge_dev_get(dp) == bridge_dev; in dsa_port_offloads_bridge_dev()
798 static inline bool dsa_port_offloads_bridge(struct dsa_port *dp, in dsa_port_offloads_bridge() argument
799 const struct dsa_bridge *bridge) in dsa_port_offloads_bridge() argument
801 return dsa_port_bridge_dev_get(dp) == bridge->dev; in dsa_port_offloads_bridge()
808 struct dsa_port *dp; in dsa_tree_offloads_bridge_port() local
810 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_offloads_bridge_port()
811 if (dsa_port_offloads_bridge_port(dp, dev)) in dsa_tree_offloads_bridge_port()
817 /* Returns true if any port of this tree offloads the given bridge */
822 struct dsa_port *dp; in dsa_tree_offloads_bridge_dev() local
824 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_offloads_bridge_dev()
825 if (dsa_port_offloads_bridge_dev(dp, bridge_dev)) in dsa_tree_offloads_bridge_dev()
834 return a->ds->dst == b->ds->dst; in dsa_port_tree_same()
864 /* Optional switch-wide initialization and destruction methods */
868 /* Per-port initialization and destruction methods. Mandatory if the
932 * ethtool Wake-on-LAN
1032 * Bridge integration
1036 struct dsa_bridge bridge,
1040 struct dsa_bridge bridge);
1067 int (*vlan_msti_set)(struct dsa_switch *ds, struct dsa_bridge bridge,
1126 * Cross-chip operations
1130 struct dsa_bridge bridge,
1134 struct dsa_bridge bridge);
1307 return dl_priv->ds; in dsa_devlink_to_ds()
1313 struct devlink *dl = port->devlink; in dsa_devlink_port_to_ds()
1316 return dl_priv->ds; in dsa_devlink_port_to_ds()
1321 return port->index; in dsa_devlink_port_to_port()
1340 return dev->dsa_ptr && dev->dsa_ptr->rcv; in netdev_uses_dsa()
1350 * - offset: the (B - A) difference between:
1352 * B. the current skb->data (aka ETH_HLEN bytes into the frame, aka 2 bytes
1357 * - proto: the value of the real EtherType.
1363 const struct dsa_device_ops *ops = skb->dev->dsa_ptr->tag_ops; in dsa_tag_generic_flow_dissect()
1364 int tag_len = ops->needed_headroom; in dsa_tag_generic_flow_dissect()
1367 *proto = ((__be16 *)skb->data)[(tag_len / 2) - 1]; in dsa_tag_generic_flow_dissect()