Lines Matching +full:dp +full:- +full:port
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
106 #define DSA_TAG_DRIVER_ALIAS "dsa_tag-"
116 u8 priv[48 - sizeof(struct dsa_skb_cb)];
119 #define DSA_SKB_CB(skb) ((struct dsa_skb_cb *)((skb)->cb))
122 ((void *)(skb)->cb + offsetof(struct __dsa_skb_cb, priv))
127 /* Notifier chain for switch-wide events */
164 /* TC port policer entry */
183 /* A CPU port is physically connected to a master device.
184 * A user port exposed to userspace has a slave device.
191 /* CPU port tagging operations used by master or slave devices */
225 * Give the switch driver somewhere to hang its per-port private data
243 /* TODO: ideally DSA ports would have a single dp->link_dp member,
244 * and no dst->rtable nor this struct dsa_link would be needed,
249 struct dsa_port *dp; member
297 /* Number of switch port queues */
301 * settings on ports if not hardware-supported
312 /* If the switch driver always programs the CPU port as egress tagged
321 * should be retrieved from here and not from the per-port settings.
341 struct dsa_switch_tree *dst = ds->dst; in dsa_to_port()
342 struct dsa_port *dp; in dsa_to_port() local
344 list_for_each_entry(dp, &dst->ports, list) in dsa_to_port()
345 if (dp->ds == ds && dp->index == p) in dsa_to_port()
346 return dp; in dsa_to_port()
353 return dsa_to_port(ds, p)->type == DSA_PORT_TYPE_UNUSED; in dsa_is_unused_port()
358 return dsa_to_port(ds, p)->type == DSA_PORT_TYPE_CPU; in dsa_is_cpu_port()
363 return dsa_to_port(ds, p)->type == DSA_PORT_TYPE_DSA; in dsa_is_dsa_port()
368 return dsa_to_port(ds, p)->type == DSA_PORT_TYPE_USER; in dsa_is_user_port()
376 for (p = 0; p < ds->num_ports; p++) in dsa_user_ports()
383 /* Return the local port used to reach an arbitrary switch device */
386 struct dsa_switch_tree *dst = ds->dst; in dsa_routing_port()
389 list_for_each_entry(dl, &dst->rtable, list) in dsa_routing_port()
390 if (dl->dp->ds == ds && dl->link_dp->ds->index == device) in dsa_routing_port()
391 return dl->dp->index; in dsa_routing_port()
393 return ds->num_ports; in dsa_routing_port()
396 /* Return the local port used to reach an arbitrary switch port */
398 int port) in dsa_towards_port() argument
400 if (device == ds->index) in dsa_towards_port()
401 return port; in dsa_towards_port()
406 /* Return the local port used to reach the dedicated CPU port */
407 static inline unsigned int dsa_upstream_port(struct dsa_switch *ds, int port) in dsa_upstream_port() argument
409 const struct dsa_port *dp = dsa_to_port(ds, port); in dsa_upstream_port() local
410 const struct dsa_port *cpu_dp = dp->cpu_dp; in dsa_upstream_port()
413 return port; in dsa_upstream_port()
415 return dsa_towards_port(ds, cpu_dp->ds->index, cpu_dp->index); in dsa_upstream_port()
418 static inline bool dsa_port_is_vlan_filtering(const struct dsa_port *dp) in dsa_port_is_vlan_filtering() argument
420 const struct dsa_switch *ds = dp->ds; in dsa_port_is_vlan_filtering()
422 if (ds->vlan_filtering_is_global) in dsa_port_is_vlan_filtering()
423 return ds->vlan_filtering; in dsa_port_is_vlan_filtering()
425 return dp->vlan_filtering; in dsa_port_is_vlan_filtering()
432 int port,
437 u32 (*get_phy_flags)(struct dsa_switch *ds, int port);
442 int (*phy_read)(struct dsa_switch *ds, int port, int regnum);
443 int (*phy_write)(struct dsa_switch *ds, int port,
449 void (*adjust_link)(struct dsa_switch *ds, int port,
451 void (*fixed_link_update)(struct dsa_switch *ds, int port,
457 void (*phylink_validate)(struct dsa_switch *ds, int port,
460 int (*phylink_mac_link_state)(struct dsa_switch *ds, int port,
462 void (*phylink_mac_config)(struct dsa_switch *ds, int port,
465 void (*phylink_mac_an_restart)(struct dsa_switch *ds, int port);
466 void (*phylink_mac_link_down)(struct dsa_switch *ds, int port,
469 void (*phylink_mac_link_up)(struct dsa_switch *ds, int port,
475 void (*phylink_fixed_state)(struct dsa_switch *ds, int port,
480 void (*get_strings)(struct dsa_switch *ds, int port,
483 int port, uint64_t *data);
484 int (*get_sset_count)(struct dsa_switch *ds, int port, int sset);
486 int port, uint64_t *data);
489 * ethtool Wake-on-LAN
491 void (*get_wol)(struct dsa_switch *ds, int port,
493 int (*set_wol)(struct dsa_switch *ds, int port,
499 int (*get_ts_info)(struct dsa_switch *ds, int port,
509 * Port enable/disable
511 int (*port_enable)(struct dsa_switch *ds, int port,
513 void (*port_disable)(struct dsa_switch *ds, int port);
516 * Port's MAC EEE settings
518 int (*set_mac_eee)(struct dsa_switch *ds, int port,
520 int (*get_mac_eee)(struct dsa_switch *ds, int port,
533 int (*get_regs_len)(struct dsa_switch *ds, int port);
534 void (*get_regs)(struct dsa_switch *ds, int port,
541 int (*port_bridge_join)(struct dsa_switch *ds, int port,
543 void (*port_bridge_leave)(struct dsa_switch *ds, int port,
545 void (*port_stp_state_set)(struct dsa_switch *ds, int port,
547 void (*port_fast_age)(struct dsa_switch *ds, int port);
548 int (*port_egress_floods)(struct dsa_switch *ds, int port,
554 int (*port_vlan_filtering)(struct dsa_switch *ds, int port,
557 int (*port_vlan_prepare)(struct dsa_switch *ds, int port,
559 void (*port_vlan_add)(struct dsa_switch *ds, int port,
561 int (*port_vlan_del)(struct dsa_switch *ds, int port,
566 int (*port_fdb_add)(struct dsa_switch *ds, int port,
568 int (*port_fdb_del)(struct dsa_switch *ds, int port,
570 int (*port_fdb_dump)(struct dsa_switch *ds, int port,
576 int (*port_mdb_prepare)(struct dsa_switch *ds, int port,
578 void (*port_mdb_add)(struct dsa_switch *ds, int port,
580 int (*port_mdb_del)(struct dsa_switch *ds, int port,
585 int (*get_rxnfc)(struct dsa_switch *ds, int port,
587 int (*set_rxnfc)(struct dsa_switch *ds, int port,
593 int (*cls_flower_add)(struct dsa_switch *ds, int port,
595 int (*cls_flower_del)(struct dsa_switch *ds, int port,
597 int (*cls_flower_stats)(struct dsa_switch *ds, int port,
599 int (*port_mirror_add)(struct dsa_switch *ds, int port,
602 void (*port_mirror_del)(struct dsa_switch *ds, int port,
604 int (*port_policer_add)(struct dsa_switch *ds, int port,
606 void (*port_policer_del)(struct dsa_switch *ds, int port);
607 int (*port_setup_tc)(struct dsa_switch *ds, int port,
611 * Cross-chip operations
614 int sw_index, int port,
617 int sw_index, int port,
623 int (*port_hwtstamp_get)(struct dsa_switch *ds, int port,
625 int (*port_hwtstamp_set)(struct dsa_switch *ds, int port,
627 bool (*port_txtstamp)(struct dsa_switch *ds, int port,
629 bool (*port_rxtstamp)(struct dsa_switch *ds, int port,
644 * If the switch needs to account for the DSA tag on the CPU port, this
647 int (*port_change_mtu)(struct dsa_switch *ds, int port,
649 int (*port_max_mtu)(struct dsa_switch *ds, int port);
687 int port,
702 return dl_priv->ds; in dsa_devlink_to_ds()
706 struct dsa_switch *dsa_devlink_port_to_ds(struct devlink_port *port) in dsa_devlink_port_to_ds() argument
708 struct devlink *dl = port->devlink; in dsa_devlink_port_to_ds()
711 return dl_priv->ds; in dsa_devlink_port_to_ds()
714 static inline int dsa_devlink_port_to_port(struct devlink_port *port) in dsa_devlink_port_to_port() argument
716 return port->index; in dsa_devlink_port_to_port()
730 return dev->dsa_ptr && dev->dsa_ptr->rcv; in netdev_uses_dsa()
739 return !dev->dsa_ptr->filter || dev->dsa_ptr->filter(skb, dev); in dsa_can_decode()
749 * - offset: the (B - A) difference between:
751 * B. the current skb->data (aka ETH_HLEN bytes into the frame, aka 2 bytes
756 * - proto: the value of the real EtherType.
762 const struct dsa_device_ops *ops = skb->dev->dsa_ptr->tag_ops; in dsa_tag_generic_flow_dissect()
763 int tag_len = ops->overhead; in dsa_tag_generic_flow_dissect()
766 *proto = ((__be16 *)skb->data)[(tag_len / 2) - 1]; in dsa_tag_generic_flow_dissect()
773 int err = -EOPNOTSUPP; in __dsa_netdevice_ops_check()
775 if (!dev->dsa_ptr) in __dsa_netdevice_ops_check()
778 if (!dev->dsa_ptr->netdev_ops) in __dsa_netdevice_ops_check()
794 ops = dev->dsa_ptr->netdev_ops; in dsa_ndo_do_ioctl()
796 return ops->ndo_do_ioctl(dev, ifr, cmd); in dsa_ndo_do_ioctl()
802 return -EOPNOTSUPP; in dsa_ndo_do_ioctl()
842 return info->dev; in dsa_notifier_info_to_dev()
868 /* Broadcom tag specific helpers to insert and extract queue/port number */
875 int dsa_port_get_phy_strings(struct dsa_port *dp, uint8_t *data);
876 int dsa_port_get_ethtool_phy_stats(struct dsa_port *dp, uint64_t *data);
877 int dsa_port_get_phy_sset_count(struct dsa_port *dp);
878 void dsa_port_phylink_mac_change(struct dsa_switch *ds, int port, bool up);
908 * module_dsa_tag_drivers() - Helper macro for registering DSA tag
930 * module_dsa_tag_driver() - Helper macro for registering a single DSA tag