Lines Matching +full:cpu +full:- +full:ports

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
122 /* List of switch ports */
123 struct list_head ports; member
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()
238 /* A CPU port is physically connected to a conduit device. A user port
239 * exposes a network device to user-space, called 'user' here.
247 * in the data path. Valid only for the CPU ports.
278 /* Managed by DSA on user ports and by drivers on CPU and DSA ports */
283 /* conduit state bits, valid only on CPU ports */
287 /* Valid only on user ports */
310 * These are only valid on CPU ports and DSA links.
318 /* List of VLANs that CPU and DSA ports are members of.
322 /* List of VLANs that user ports are members of.
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,
392 * settings on ports if not hardware-supported
396 /* Keep VLAN filtering enabled on ports not offloading any upper */
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.
443 * true to automatically apply the settings to all ports.
474 * User mii_bus and devices for the individual ports.
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()
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()
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()
534 return dp->type == DSA_PORT_TYPE_USER; in dsa_port_is_user()
539 return dp->type == DSA_PORT_TYPE_UNUSED; in dsa_port_is_unused()
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))
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()
657 /* Return the local port used to reach the dedicated CPU port */
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()
669 /* Return true if this is the local port used to reach the CPU port */
678 /* Return true if this is a DSA port leading away from the CPU */
684 /* Return the local port used to reach the CPU port */
690 return dsa_upstream_port(ds, dp->index); in dsa_switch_upstream_port()
693 return ds->num_ports; in dsa_switch_upstream_port()
698 * which @downstream_ds uses to reach its dedicated CPU.
708 routing_port = dsa_routing_port(downstream_ds, upstream_ds->index); in dsa_switch_is_upstream_of()
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()
725 return dp->lag ? dp->lag->id : 0; in dsa_port_lag_id_get()
730 return dp->lag ? dp->lag->dev : NULL; in dsa_port_lag_dev_get()
736 return dsa_port_lag_dev_get(dp) == lag->dev; in dsa_port_offloads_lag()
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()
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()
764 return dp->bridge ? dp->bridge->dev : NULL; in dsa_port_bridge_dev_get()
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()
792 /* DSA ports connected to a bridge, and event was emitted in dsa_port_offloads_bridge_dev()
801 return dsa_port_bridge_dev_get(dp) == bridge->dev; in dsa_port_offloads_bridge()
810 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_offloads_bridge_port()
824 list_for_each_entry(dp, &dst->ports, list) in dsa_tree_offloads_bridge_dev()
834 return a->ds->dst == b->ds->dst; in dsa_port_tree_same()
841 * Tagging protocol helpers called for the CPU ports and DSA links.
864 /* Optional switch-wide initialization and destruction methods */
868 /* Per-port initialization and destruction methods. Mandatory if the
932 * ethtool Wake-on-LAN
987 * Notification for MAC address changes on user ports. Drivers can
996 * Compatibility between device trees defining multiple CPU ports and
998 * CPU port of a switch for its local ports. This can return NULL,
1126 * Cross-chip operations
1202 * If the switch needs to account for the DSA tag on the CPU port, this
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()