dsa.h (0fdc50dfab47d525b71a9f0d8310746cdc0c09c5) dsa.h (54a0ed0df49609f4e3f098f8943e38e389dc2e15)
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

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

125
126 /* List of switch ports */
127 struct list_head ports;
128
129 /* List of DSA links composing the routing table */
130 struct list_head rtable;
131};
132
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

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

125
126 /* List of switch ports */
127 struct list_head ports;
128
129 /* List of DSA links composing the routing table */
130 struct list_head rtable;
131};
132
133/* TC matchall action types, only mirroring for now */
133/* TC matchall action types */
134enum dsa_port_mall_action_type {
135 DSA_PORT_MALL_MIRROR,
134enum dsa_port_mall_action_type {
135 DSA_PORT_MALL_MIRROR,
136 DSA_PORT_MALL_POLICER,
136};
137
138/* TC mirroring entry */
139struct dsa_mall_mirror_tc_entry {
140 u8 to_local_port;
141 bool ingress;
142};
143
137};
138
139/* TC mirroring entry */
140struct dsa_mall_mirror_tc_entry {
141 u8 to_local_port;
142 bool ingress;
143};
144
145/* TC port policer entry */
146struct dsa_mall_policer_tc_entry {
147 s64 burst;
148 u64 rate_bytes_per_sec;
149};
150
144/* TC matchall entry */
145struct dsa_mall_tc_entry {
146 struct list_head list;
147 unsigned long cookie;
148 enum dsa_port_mall_action_type type;
149 union {
150 struct dsa_mall_mirror_tc_entry mirror;
151/* TC matchall entry */
152struct dsa_mall_tc_entry {
153 struct list_head list;
154 unsigned long cookie;
155 enum dsa_port_mall_action_type type;
156 union {
157 struct dsa_mall_mirror_tc_entry mirror;
158 struct dsa_mall_policer_tc_entry policer;
151 };
152};
153
154
155struct dsa_port {
156 /* A CPU port is physically connected to a master device.
157 * A user port exposed to userspace has a slave device.
158 */

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

269 /* Number of switch port queues */
270 unsigned int num_tx_queues;
271
272 /* Disallow bridge core from requesting different VLAN awareness
273 * settings on ports if not hardware-supported
274 */
275 bool vlan_filtering_is_global;
276
159 };
160};
161
162
163struct dsa_port {
164 /* A CPU port is physically connected to a master device.
165 * A user port exposed to userspace has a slave device.
166 */

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

277 /* Number of switch port queues */
278 unsigned int num_tx_queues;
279
280 /* Disallow bridge core from requesting different VLAN awareness
281 * settings on ports if not hardware-supported
282 */
283 bool vlan_filtering_is_global;
284
285 /* Pass .port_vlan_add and .port_vlan_del to drivers even for bridges
286 * that have vlan_filtering=0. All drivers should ideally set this (and
287 * then the option would get removed), but it is unknown whether this
288 * would break things or not.
289 */
290 bool configure_vlan_while_not_filtering;
291
277 /* In case vlan_filtering_is_global is set, the VLAN awareness state
278 * should be retrieved from here and not from the per-port settings.
279 */
280 bool vlan_filtering;
281
282 /* MAC PCS does not provide link state change interrupt, and requires
283 * polling. Flag passed on to PHYLINK.
284 */
285 bool pcs_poll;
286
292 /* In case vlan_filtering_is_global is set, the VLAN awareness state
293 * should be retrieved from here and not from the per-port settings.
294 */
295 bool vlan_filtering;
296
297 /* MAC PCS does not provide link state change interrupt, and requires
298 * polling. Flag passed on to PHYLINK.
299 */
300 bool pcs_poll;
301
302 /* For switches that only have the MRU configurable. To ensure the
303 * configured MTU is not exceeded, normalization of MRU on all bridged
304 * interfaces is needed.
305 */
306 bool mtu_enforcement_ingress;
307
287 size_t num_ports;
288};
289
290static inline struct dsa_port *dsa_to_port(struct dsa_switch *ds, int p)
291{
292 struct dsa_switch_tree *dst = ds->dst;
293 struct dsa_port *dp;
294

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

415 const struct phylink_link_state *state);
416 void (*phylink_mac_an_restart)(struct dsa_switch *ds, int port);
417 void (*phylink_mac_link_down)(struct dsa_switch *ds, int port,
418 unsigned int mode,
419 phy_interface_t interface);
420 void (*phylink_mac_link_up)(struct dsa_switch *ds, int port,
421 unsigned int mode,
422 phy_interface_t interface,
308 size_t num_ports;
309};
310
311static inline struct dsa_port *dsa_to_port(struct dsa_switch *ds, int p)
312{
313 struct dsa_switch_tree *dst = ds->dst;
314 struct dsa_port *dp;
315

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

436 const struct phylink_link_state *state);
437 void (*phylink_mac_an_restart)(struct dsa_switch *ds, int port);
438 void (*phylink_mac_link_down)(struct dsa_switch *ds, int port,
439 unsigned int mode,
440 phy_interface_t interface);
441 void (*phylink_mac_link_up)(struct dsa_switch *ds, int port,
442 unsigned int mode,
443 phy_interface_t interface,
423 struct phy_device *phydev);
444 struct phy_device *phydev,
445 int speed, int duplex,
446 bool tx_pause, bool rx_pause);
424 void (*phylink_fixed_state)(struct dsa_switch *ds, int port,
425 struct phylink_link_state *state);
426 /*
427 * ethtool hardware statistics.
428 */
429 void (*get_strings)(struct dsa_switch *ds, int port,
430 u32 stringset, uint8_t *data);
431 void (*get_ethtool_stats)(struct dsa_switch *ds,

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

533 int (*get_rxnfc)(struct dsa_switch *ds, int port,
534 struct ethtool_rxnfc *nfc, u32 *rule_locs);
535 int (*set_rxnfc)(struct dsa_switch *ds, int port,
536 struct ethtool_rxnfc *nfc);
537
538 /*
539 * TC integration
540 */
447 void (*phylink_fixed_state)(struct dsa_switch *ds, int port,
448 struct phylink_link_state *state);
449 /*
450 * ethtool hardware statistics.
451 */
452 void (*get_strings)(struct dsa_switch *ds, int port,
453 u32 stringset, uint8_t *data);
454 void (*get_ethtool_stats)(struct dsa_switch *ds,

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

556 int (*get_rxnfc)(struct dsa_switch *ds, int port,
557 struct ethtool_rxnfc *nfc, u32 *rule_locs);
558 int (*set_rxnfc)(struct dsa_switch *ds, int port,
559 struct ethtool_rxnfc *nfc);
560
561 /*
562 * TC integration
563 */
564 int (*cls_flower_add)(struct dsa_switch *ds, int port,
565 struct flow_cls_offload *cls, bool ingress);
566 int (*cls_flower_del)(struct dsa_switch *ds, int port,
567 struct flow_cls_offload *cls, bool ingress);
568 int (*cls_flower_stats)(struct dsa_switch *ds, int port,
569 struct flow_cls_offload *cls, bool ingress);
541 int (*port_mirror_add)(struct dsa_switch *ds, int port,
542 struct dsa_mall_mirror_tc_entry *mirror,
543 bool ingress);
544 void (*port_mirror_del)(struct dsa_switch *ds, int port,
545 struct dsa_mall_mirror_tc_entry *mirror);
570 int (*port_mirror_add)(struct dsa_switch *ds, int port,
571 struct dsa_mall_mirror_tc_entry *mirror,
572 bool ingress);
573 void (*port_mirror_del)(struct dsa_switch *ds, int port,
574 struct dsa_mall_mirror_tc_entry *mirror);
575 int (*port_policer_add)(struct dsa_switch *ds, int port,
576 struct dsa_mall_policer_tc_entry *policer);
577 void (*port_policer_del)(struct dsa_switch *ds, int port);
546 int (*port_setup_tc)(struct dsa_switch *ds, int port,
547 enum tc_setup_type type, void *type_data);
548
549 /*
550 * Cross-chip operations
551 */
578 int (*port_setup_tc)(struct dsa_switch *ds, int port,
579 enum tc_setup_type type, void *type_data);
580
581 /*
582 * Cross-chip operations
583 */
552 int (*crosschip_bridge_join)(struct dsa_switch *ds, int sw_index,
553 int port, struct net_device *br);
554 void (*crosschip_bridge_leave)(struct dsa_switch *ds, int sw_index,
555 int port, struct net_device *br);
584 int (*crosschip_bridge_join)(struct dsa_switch *ds, int tree_index,
585 int sw_index, int port,
586 struct net_device *br);
587 void (*crosschip_bridge_leave)(struct dsa_switch *ds, int tree_index,
588 int sw_index, int port,
589 struct net_device *br);
556
557 /*
558 * PTP functionality
559 */
560 int (*port_hwtstamp_get)(struct dsa_switch *ds, int port,
561 struct ifreq *ifr);
562 int (*port_hwtstamp_set)(struct dsa_switch *ds, int port,
563 struct ifreq *ifr);
564 bool (*port_txtstamp)(struct dsa_switch *ds, int port,
565 struct sk_buff *clone, unsigned int type);
566 bool (*port_rxtstamp)(struct dsa_switch *ds, int port,
567 struct sk_buff *skb, unsigned int type);
568
569 /* Devlink parameters */
570 int (*devlink_param_get)(struct dsa_switch *ds, u32 id,
571 struct devlink_param_gset_ctx *ctx);
572 int (*devlink_param_set)(struct dsa_switch *ds, u32 id,
573 struct devlink_param_gset_ctx *ctx);
590
591 /*
592 * PTP functionality
593 */
594 int (*port_hwtstamp_get)(struct dsa_switch *ds, int port,
595 struct ifreq *ifr);
596 int (*port_hwtstamp_set)(struct dsa_switch *ds, int port,
597 struct ifreq *ifr);
598 bool (*port_txtstamp)(struct dsa_switch *ds, int port,
599 struct sk_buff *clone, unsigned int type);
600 bool (*port_rxtstamp)(struct dsa_switch *ds, int port,
601 struct sk_buff *skb, unsigned int type);
602
603 /* Devlink parameters */
604 int (*devlink_param_get)(struct dsa_switch *ds, u32 id,
605 struct devlink_param_gset_ctx *ctx);
606 int (*devlink_param_set)(struct dsa_switch *ds, u32 id,
607 struct devlink_param_gset_ctx *ctx);
608
609 /*
610 * MTU change functionality. Switches can also adjust their MRU through
611 * this method. By MTU, one understands the SDU (L2 payload) length.
612 * If the switch needs to account for the DSA tag on the CPU port, this
613 * method needs to to do so privately.
614 */
615 int (*port_change_mtu)(struct dsa_switch *ds, int port,
616 int new_mtu);
617 int (*port_max_mtu)(struct dsa_switch *ds, int port);
574};
575
576#define DSA_DEVLINK_PARAM_DRIVER(_id, _name, _type, _cmodes) \
577 DEVLINK_PARAM_DRIVER(_id, _name, _type, _cmodes, \
578 dsa_devlink_param_get, dsa_devlink_param_set, NULL)
579
580int dsa_devlink_param_get(struct devlink *dl, u32 id,
581 struct devlink_param_gset_ctx *ctx);

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

597void dsa_devlink_resources_unregister(struct dsa_switch *ds);
598
599void dsa_devlink_resource_occ_get_register(struct dsa_switch *ds,
600 u64 resource_id,
601 devlink_resource_occ_get_t *occ_get,
602 void *occ_get_priv);
603void dsa_devlink_resource_occ_get_unregister(struct dsa_switch *ds,
604 u64 resource_id);
618};
619
620#define DSA_DEVLINK_PARAM_DRIVER(_id, _name, _type, _cmodes) \
621 DEVLINK_PARAM_DRIVER(_id, _name, _type, _cmodes, \
622 dsa_devlink_param_get, dsa_devlink_param_set, NULL)
623
624int dsa_devlink_param_get(struct devlink *dl, u32 id,
625 struct devlink_param_gset_ctx *ctx);

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

641void dsa_devlink_resources_unregister(struct dsa_switch *ds);
642
643void dsa_devlink_resource_occ_get_register(struct dsa_switch *ds,
644 u64 resource_id,
645 devlink_resource_occ_get_t *occ_get,
646 void *occ_get_priv);
647void dsa_devlink_resource_occ_get_unregister(struct dsa_switch *ds,
648 u64 resource_id);
649struct dsa_port *dsa_port_from_netdev(struct net_device *netdev);
605
606struct dsa_devlink_priv {
607 struct dsa_switch *ds;
608};
609
610struct dsa_switch_driver {
611 struct list_head list;
612 const struct dsa_switch_ops *ops;
613};
614
615struct net_device *dsa_dev_to_net_device(struct device *dev);
616
617/* Keep inline for faster access in hot path */
650
651struct dsa_devlink_priv {
652 struct dsa_switch *ds;
653};
654
655struct dsa_switch_driver {
656 struct list_head list;
657 const struct dsa_switch_ops *ops;
658};
659
660struct net_device *dsa_dev_to_net_device(struct device *dev);
661
662/* Keep inline for faster access in hot path */
618static inline bool netdev_uses_dsa(struct net_device *dev)
663static inline bool netdev_uses_dsa(const struct net_device *dev)
619{
620#if IS_ENABLED(CONFIG_NET_DSA)
621 return dev->dsa_ptr && dev->dsa_ptr->rcv;
622#endif
623 return false;
624}
625
626static inline bool dsa_can_decode(const struct sk_buff *skb,
627 struct net_device *dev)
628{
629#if IS_ENABLED(CONFIG_NET_DSA)
630 return !dev->dsa_ptr->filter || dev->dsa_ptr->filter(skb, dev);
631#endif
632 return false;
633}
634
635void dsa_unregister_switch(struct dsa_switch *ds);
636int dsa_register_switch(struct dsa_switch *ds);
664{
665#if IS_ENABLED(CONFIG_NET_DSA)
666 return dev->dsa_ptr && dev->dsa_ptr->rcv;
667#endif
668 return false;
669}
670
671static inline bool dsa_can_decode(const struct sk_buff *skb,
672 struct net_device *dev)
673{
674#if IS_ENABLED(CONFIG_NET_DSA)
675 return !dev->dsa_ptr->filter || dev->dsa_ptr->filter(skb, dev);
676#endif
677 return false;
678}
679
680void dsa_unregister_switch(struct dsa_switch *ds);
681int dsa_register_switch(struct dsa_switch *ds);
682struct dsa_switch *dsa_switch_find(int tree_index, int sw_index);
637#ifdef CONFIG_PM_SLEEP
638int dsa_switch_suspend(struct dsa_switch *ds);
639int dsa_switch_resume(struct dsa_switch *ds);
640#else
641static inline int dsa_switch_suspend(struct dsa_switch *ds)
642{
643 return 0;
644}

--- 130 unchanged lines hidden ---
683#ifdef CONFIG_PM_SLEEP
684int dsa_switch_suspend(struct dsa_switch *ds);
685int dsa_switch_resume(struct dsa_switch *ds);
686#else
687static inline int dsa_switch_suspend(struct dsa_switch *ds)
688{
689 return 0;
690}

--- 130 unchanged lines hidden ---