dsa.h (9d4d8572a539ef807e21c196f145aa365fd52f0e) dsa.h (18596f504a3e56c4f8e132b2a437cbe23a3f4635)
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

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

41#define DSA_TAG_PROTO_TRAILER_VALUE 11
42#define DSA_TAG_PROTO_8021Q_VALUE 12
43#define DSA_TAG_PROTO_SJA1105_VALUE 13
44#define DSA_TAG_PROTO_KSZ8795_VALUE 14
45#define DSA_TAG_PROTO_OCELOT_VALUE 15
46#define DSA_TAG_PROTO_AR9331_VALUE 16
47#define DSA_TAG_PROTO_RTL4_A_VALUE 17
48#define DSA_TAG_PROTO_HELLCREEK_VALUE 18
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

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

41#define DSA_TAG_PROTO_TRAILER_VALUE 11
42#define DSA_TAG_PROTO_8021Q_VALUE 12
43#define DSA_TAG_PROTO_SJA1105_VALUE 13
44#define DSA_TAG_PROTO_KSZ8795_VALUE 14
45#define DSA_TAG_PROTO_OCELOT_VALUE 15
46#define DSA_TAG_PROTO_AR9331_VALUE 16
47#define DSA_TAG_PROTO_RTL4_A_VALUE 17
48#define DSA_TAG_PROTO_HELLCREEK_VALUE 18
49#define DSA_TAG_PROTO_XRS700X_VALUE 19
50#define DSA_TAG_PROTO_OCELOT_8021Q_VALUE 20
49
50enum dsa_tag_protocol {
51 DSA_TAG_PROTO_NONE = DSA_TAG_PROTO_NONE_VALUE,
52 DSA_TAG_PROTO_BRCM = DSA_TAG_PROTO_BRCM_VALUE,
53 DSA_TAG_PROTO_BRCM_PREPEND = DSA_TAG_PROTO_BRCM_PREPEND_VALUE,
54 DSA_TAG_PROTO_DSA = DSA_TAG_PROTO_DSA_VALUE,
55 DSA_TAG_PROTO_EDSA = DSA_TAG_PROTO_EDSA_VALUE,
56 DSA_TAG_PROTO_GSWIP = DSA_TAG_PROTO_GSWIP_VALUE,

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

62 DSA_TAG_PROTO_TRAILER = DSA_TAG_PROTO_TRAILER_VALUE,
63 DSA_TAG_PROTO_8021Q = DSA_TAG_PROTO_8021Q_VALUE,
64 DSA_TAG_PROTO_SJA1105 = DSA_TAG_PROTO_SJA1105_VALUE,
65 DSA_TAG_PROTO_KSZ8795 = DSA_TAG_PROTO_KSZ8795_VALUE,
66 DSA_TAG_PROTO_OCELOT = DSA_TAG_PROTO_OCELOT_VALUE,
67 DSA_TAG_PROTO_AR9331 = DSA_TAG_PROTO_AR9331_VALUE,
68 DSA_TAG_PROTO_RTL4_A = DSA_TAG_PROTO_RTL4_A_VALUE,
69 DSA_TAG_PROTO_HELLCREEK = DSA_TAG_PROTO_HELLCREEK_VALUE,
51
52enum dsa_tag_protocol {
53 DSA_TAG_PROTO_NONE = DSA_TAG_PROTO_NONE_VALUE,
54 DSA_TAG_PROTO_BRCM = DSA_TAG_PROTO_BRCM_VALUE,
55 DSA_TAG_PROTO_BRCM_PREPEND = DSA_TAG_PROTO_BRCM_PREPEND_VALUE,
56 DSA_TAG_PROTO_DSA = DSA_TAG_PROTO_DSA_VALUE,
57 DSA_TAG_PROTO_EDSA = DSA_TAG_PROTO_EDSA_VALUE,
58 DSA_TAG_PROTO_GSWIP = DSA_TAG_PROTO_GSWIP_VALUE,

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

64 DSA_TAG_PROTO_TRAILER = DSA_TAG_PROTO_TRAILER_VALUE,
65 DSA_TAG_PROTO_8021Q = DSA_TAG_PROTO_8021Q_VALUE,
66 DSA_TAG_PROTO_SJA1105 = DSA_TAG_PROTO_SJA1105_VALUE,
67 DSA_TAG_PROTO_KSZ8795 = DSA_TAG_PROTO_KSZ8795_VALUE,
68 DSA_TAG_PROTO_OCELOT = DSA_TAG_PROTO_OCELOT_VALUE,
69 DSA_TAG_PROTO_AR9331 = DSA_TAG_PROTO_AR9331_VALUE,
70 DSA_TAG_PROTO_RTL4_A = DSA_TAG_PROTO_RTL4_A_VALUE,
71 DSA_TAG_PROTO_HELLCREEK = DSA_TAG_PROTO_HELLCREEK_VALUE,
72 DSA_TAG_PROTO_XRS700X = DSA_TAG_PROTO_XRS700X_VALUE,
73 DSA_TAG_PROTO_OCELOT_8021Q = DSA_TAG_PROTO_OCELOT_8021Q_VALUE,
70};
71
72struct packet_type;
73struct dsa_switch;
74
75struct dsa_device_ops {
76 struct sk_buff *(*xmit)(struct sk_buff *skb, struct net_device *dev);
77 struct sk_buff *(*rcv)(struct sk_buff *skb, struct net_device *dev,

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

133 unsigned int index;
134
135 /* Number of switches attached to this tree */
136 struct kref refcount;
137
138 /* Has this tree been applied to the hardware? */
139 bool setup;
140
74};
75
76struct packet_type;
77struct dsa_switch;
78
79struct dsa_device_ops {
80 struct sk_buff *(*xmit)(struct sk_buff *skb, struct net_device *dev);
81 struct sk_buff *(*rcv)(struct sk_buff *skb, struct net_device *dev,

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

137 unsigned int index;
138
139 /* Number of switches attached to this tree */
140 struct kref refcount;
141
142 /* Has this tree been applied to the hardware? */
143 bool setup;
144
145 /* Tagging protocol operations */
146 const struct dsa_device_ops *tag_ops;
147
141 /*
142 * Configuration data for the platform device that owns
143 * this dsa switch tree instance.
144 */
145 struct dsa_platform_data *pd;
146
147 /* List of switch ports */
148 struct list_head ports;
149
150 /* List of DSA links composing the routing table */
151 struct list_head rtable;
148 /*
149 * Configuration data for the platform device that owns
150 * this dsa switch tree instance.
151 */
152 struct dsa_platform_data *pd;
153
154 /* List of switch ports */
155 struct list_head ports;
156
157 /* List of DSA links composing the routing table */
158 struct list_head rtable;
159
160 /* Maps offloaded LAG netdevs to a zero-based linear ID for
161 * drivers that need it.
162 */
163 struct net_device **lags;
164 unsigned int lags_len;
152};
153
165};
166
167#define dsa_lags_foreach_id(_id, _dst) \
168 for ((_id) = 0; (_id) < (_dst)->lags_len; (_id)++) \
169 if ((_dst)->lags[(_id)])
170
171#define dsa_lag_foreach_port(_dp, _dst, _lag) \
172 list_for_each_entry((_dp), &(_dst)->ports, list) \
173 if ((_dp)->lag_dev == (_lag))
174
175#define dsa_hsr_foreach_port(_dp, _ds, _hsr) \
176 list_for_each_entry((_dp), &(_ds)->dst->ports, list) \
177 if ((_dp)->ds == (_ds) && (_dp)->hsr_dev == (_hsr))
178
179static inline struct net_device *dsa_lag_dev(struct dsa_switch_tree *dst,
180 unsigned int id)
181{
182 return dst->lags[id];
183}
184
185static inline int dsa_lag_id(struct dsa_switch_tree *dst,
186 struct net_device *lag)
187{
188 unsigned int id;
189
190 dsa_lags_foreach_id(id, dst) {
191 if (dsa_lag_dev(dst, id) == lag)
192 return id;
193 }
194
195 return -ENODEV;
196}
197
154/* TC matchall action types */
155enum dsa_port_mall_action_type {
156 DSA_PORT_MALL_MIRROR,
157 DSA_PORT_MALL_POLICER,
158};
159
160/* TC mirroring entry */
161struct dsa_mall_mirror_tc_entry {

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

185 /* A CPU port is physically connected to a master device.
186 * A user port exposed to userspace has a slave device.
187 */
188 union {
189 struct net_device *master;
190 struct net_device *slave;
191 };
192
198/* TC matchall action types */
199enum dsa_port_mall_action_type {
200 DSA_PORT_MALL_MIRROR,
201 DSA_PORT_MALL_POLICER,
202};
203
204/* TC mirroring entry */
205struct dsa_mall_mirror_tc_entry {

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

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;
235 };
236
193 /* CPU port tagging operations used by master or slave devices */
237 /* Copy of the tagging protocol operations, for quicker access
238 * in the data path. Valid only for the CPU ports.
239 */
194 const struct dsa_device_ops *tag_ops;
195
196 /* Copies for faster access in master receive hot path */
197 struct dsa_switch_tree *dst;
198 struct sk_buff *(*rcv)(struct sk_buff *skb, struct net_device *dev,
199 struct packet_type *pt);
200 bool (*filter)(const struct sk_buff *skb, struct net_device *dev);
201

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

215 unsigned int ageing_time;
216 bool vlan_filtering;
217 u8 stp_state;
218 struct net_device *bridge_dev;
219 struct devlink_port devlink_port;
220 bool devlink_port_setup;
221 struct phylink *pl;
222 struct phylink_config pl_config;
240 const struct dsa_device_ops *tag_ops;
241
242 /* Copies for faster access in master receive hot path */
243 struct dsa_switch_tree *dst;
244 struct sk_buff *(*rcv)(struct sk_buff *skb, struct net_device *dev,
245 struct packet_type *pt);
246 bool (*filter)(const struct sk_buff *skb, struct net_device *dev);
247

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

261 unsigned int ageing_time;
262 bool vlan_filtering;
263 u8 stp_state;
264 struct net_device *bridge_dev;
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;
223
224 struct list_head list;
225
226 /*
227 * Give the switch driver somewhere to hang its per-port private data
228 * structures (accessible from the tagger).
229 */
230 void *priv;

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

314 /* If the switch driver always programs the CPU port as egress tagged
315 * despite the VLAN configuration indicating otherwise, then setting
316 * @untag_bridge_pvid will force the DSA receive path to pop the bridge's
317 * default_pvid VLAN tagged frames to offer a consistent behavior
318 * between a vlan_filtering=0 and vlan_filtering=1 bridge device.
319 */
320 bool untag_bridge_pvid;
321
272
273 struct list_head list;
274
275 /*
276 * Give the switch driver somewhere to hang its per-port private data
277 * structures (accessible from the tagger).
278 */
279 void *priv;

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

363 /* If the switch driver always programs the CPU port as egress tagged
364 * despite the VLAN configuration indicating otherwise, then setting
365 * @untag_bridge_pvid will force the DSA receive path to pop the bridge's
366 * default_pvid VLAN tagged frames to offer a consistent behavior
367 * between a vlan_filtering=0 and vlan_filtering=1 bridge device.
368 */
369 bool untag_bridge_pvid;
370
371 /* Let DSA manage the FDB entries towards the CPU, based on the
372 * software bridge database.
373 */
374 bool assisted_learning_on_cpu_port;
375
322 /* In case vlan_filtering_is_global is set, the VLAN awareness state
323 * should be retrieved from here and not from the per-port settings.
324 */
325 bool vlan_filtering;
326
327 /* MAC PCS does not provide link state change interrupt, and requires
328 * polling. Flag passed on to PHYLINK.
329 */
330 bool pcs_poll;
331
332 /* For switches that only have the MRU configurable. To ensure the
333 * configured MTU is not exceeded, normalization of MRU on all bridged
334 * interfaces is needed.
335 */
336 bool mtu_enforcement_ingress;
337
376 /* In case vlan_filtering_is_global is set, the VLAN awareness state
377 * should be retrieved from here and not from the per-port settings.
378 */
379 bool vlan_filtering;
380
381 /* MAC PCS does not provide link state change interrupt, and requires
382 * polling. Flag passed on to PHYLINK.
383 */
384 bool pcs_poll;
385
386 /* For switches that only have the MRU configurable. To ensure the
387 * configured MTU is not exceeded, normalization of MRU on all bridged
388 * interfaces is needed.
389 */
390 bool mtu_enforcement_ingress;
391
392 /* Drivers that benefit from having an ID associated with each
393 * offloaded LAG should set this to the maximum number of
394 * supported IDs. DSA will then maintain a mapping of _at
395 * least_ these many IDs, accessible to drivers via
396 * dsa_lag_id().
397 */
398 unsigned int num_lag_ids;
399
338 size_t num_ports;
339};
340
341static inline struct dsa_port *dsa_to_port(struct dsa_switch *ds, int p)
342{
343 struct dsa_switch_tree *dst = ds->dst;
344 struct dsa_port *dp;
345

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

425 return ds->vlan_filtering;
426 else
427 return dp->vlan_filtering;
428}
429
430typedef int dsa_fdb_dump_cb_t(const unsigned char *addr, u16 vid,
431 bool is_static, void *data);
432struct dsa_switch_ops {
400 size_t num_ports;
401};
402
403static inline struct dsa_port *dsa_to_port(struct dsa_switch *ds, int p)
404{
405 struct dsa_switch_tree *dst = ds->dst;
406 struct dsa_port *dp;
407

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

487 return ds->vlan_filtering;
488 else
489 return dp->vlan_filtering;
490}
491
492typedef int dsa_fdb_dump_cb_t(const unsigned char *addr, u16 vid,
493 bool is_static, void *data);
494struct dsa_switch_ops {
495 /*
496 * Tagging protocol helpers called for the CPU ports and DSA links.
497 * @get_tag_protocol retrieves the initial tagging protocol and is
498 * mandatory. Switches which can operate using multiple tagging
499 * protocols should implement @change_tag_protocol and report in
500 * @get_tag_protocol the tagger in current use.
501 */
433 enum dsa_tag_protocol (*get_tag_protocol)(struct dsa_switch *ds,
434 int port,
435 enum dsa_tag_protocol mprot);
502 enum dsa_tag_protocol (*get_tag_protocol)(struct dsa_switch *ds,
503 int port,
504 enum dsa_tag_protocol mprot);
505 int (*change_tag_protocol)(struct dsa_switch *ds, int port,
506 enum dsa_tag_protocol proto);
436
437 int (*setup)(struct dsa_switch *ds);
438 void (*teardown)(struct dsa_switch *ds);
439 u32 (*get_phy_flags)(struct dsa_switch *ds, int port);
440
441 /*
442 * Access to the switch's PHY registers.
443 */

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

472 unsigned int mode,
473 phy_interface_t interface,
474 struct phy_device *phydev,
475 int speed, int duplex,
476 bool tx_pause, bool rx_pause);
477 void (*phylink_fixed_state)(struct dsa_switch *ds, int port,
478 struct phylink_link_state *state);
479 /*
507
508 int (*setup)(struct dsa_switch *ds);
509 void (*teardown)(struct dsa_switch *ds);
510 u32 (*get_phy_flags)(struct dsa_switch *ds, int port);
511
512 /*
513 * Access to the switch's PHY registers.
514 */

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

543 unsigned int mode,
544 phy_interface_t interface,
545 struct phy_device *phydev,
546 int speed, int duplex,
547 bool tx_pause, bool rx_pause);
548 void (*phylink_fixed_state)(struct dsa_switch *ds, int port,
549 struct phylink_link_state *state);
550 /*
480 * ethtool hardware statistics.
551 * Port statistics counters.
481 */
482 void (*get_strings)(struct dsa_switch *ds, int port,
483 u32 stringset, uint8_t *data);
484 void (*get_ethtool_stats)(struct dsa_switch *ds,
485 int port, uint64_t *data);
486 int (*get_sset_count)(struct dsa_switch *ds, int port, int sset);
487 void (*get_ethtool_phy_stats)(struct dsa_switch *ds,
488 int port, uint64_t *data);
552 */
553 void (*get_strings)(struct dsa_switch *ds, int port,
554 u32 stringset, uint8_t *data);
555 void (*get_ethtool_stats)(struct dsa_switch *ds,
556 int port, uint64_t *data);
557 int (*get_sset_count)(struct dsa_switch *ds, int port, int sset);
558 void (*get_ethtool_phy_stats)(struct dsa_switch *ds,
559 int port, uint64_t *data);
560 void (*get_stats64)(struct dsa_switch *ds, int port,
561 struct rtnl_link_stats64 *s);
489
490 /*
491 * ethtool Wake-on-LAN
492 */
493 void (*get_wol)(struct dsa_switch *ds, int port,
494 struct ethtool_wolinfo *w);
495 int (*set_wol)(struct dsa_switch *ds, int port,
496 struct ethtool_wolinfo *w);

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

555 void (*port_fast_age)(struct dsa_switch *ds, int port);
556 int (*port_egress_floods)(struct dsa_switch *ds, int port,
557 bool unicast, bool multicast);
558
559 /*
560 * VLAN support
561 */
562 int (*port_vlan_filtering)(struct dsa_switch *ds, int port,
562
563 /*
564 * ethtool Wake-on-LAN
565 */
566 void (*get_wol)(struct dsa_switch *ds, int port,
567 struct ethtool_wolinfo *w);
568 int (*set_wol)(struct dsa_switch *ds, int port,
569 struct ethtool_wolinfo *w);

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

628 void (*port_fast_age)(struct dsa_switch *ds, int port);
629 int (*port_egress_floods)(struct dsa_switch *ds, int port,
630 bool unicast, bool multicast);
631
632 /*
633 * VLAN support
634 */
635 int (*port_vlan_filtering)(struct dsa_switch *ds, int port,
563 bool vlan_filtering,
564 struct switchdev_trans *trans);
565 int (*port_vlan_prepare)(struct dsa_switch *ds, int port,
636 bool vlan_filtering);
637 int (*port_vlan_add)(struct dsa_switch *ds, int port,
566 const struct switchdev_obj_port_vlan *vlan);
638 const struct switchdev_obj_port_vlan *vlan);
567 void (*port_vlan_add)(struct dsa_switch *ds, int port,
568 const struct switchdev_obj_port_vlan *vlan);
569 int (*port_vlan_del)(struct dsa_switch *ds, int port,
570 const struct switchdev_obj_port_vlan *vlan);
571 /*
572 * Forwarding database
573 */
574 int (*port_fdb_add)(struct dsa_switch *ds, int port,
575 const unsigned char *addr, u16 vid);
576 int (*port_fdb_del)(struct dsa_switch *ds, int port,
577 const unsigned char *addr, u16 vid);
578 int (*port_fdb_dump)(struct dsa_switch *ds, int port,
579 dsa_fdb_dump_cb_t *cb, void *data);
580
581 /*
582 * Multicast database
583 */
639 int (*port_vlan_del)(struct dsa_switch *ds, int port,
640 const struct switchdev_obj_port_vlan *vlan);
641 /*
642 * Forwarding database
643 */
644 int (*port_fdb_add)(struct dsa_switch *ds, int port,
645 const unsigned char *addr, u16 vid);
646 int (*port_fdb_del)(struct dsa_switch *ds, int port,
647 const unsigned char *addr, u16 vid);
648 int (*port_fdb_dump)(struct dsa_switch *ds, int port,
649 dsa_fdb_dump_cb_t *cb, void *data);
650
651 /*
652 * Multicast database
653 */
584 int (*port_mdb_prepare)(struct dsa_switch *ds, int port,
654 int (*port_mdb_add)(struct dsa_switch *ds, int port,
585 const struct switchdev_obj_port_mdb *mdb);
655 const struct switchdev_obj_port_mdb *mdb);
586 void (*port_mdb_add)(struct dsa_switch *ds, int port,
587 const struct switchdev_obj_port_mdb *mdb);
588 int (*port_mdb_del)(struct dsa_switch *ds, int port,
589 const struct switchdev_obj_port_mdb *mdb);
590 /*
591 * RXNFC
592 */
593 int (*get_rxnfc)(struct dsa_switch *ds, int port,
594 struct ethtool_rxnfc *nfc, u32 *rule_locs);
595 int (*set_rxnfc)(struct dsa_switch *ds, int port,

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

619 * Cross-chip operations
620 */
621 int (*crosschip_bridge_join)(struct dsa_switch *ds, int tree_index,
622 int sw_index, int port,
623 struct net_device *br);
624 void (*crosschip_bridge_leave)(struct dsa_switch *ds, int tree_index,
625 int sw_index, int port,
626 struct net_device *br);
656 int (*port_mdb_del)(struct dsa_switch *ds, int port,
657 const struct switchdev_obj_port_mdb *mdb);
658 /*
659 * RXNFC
660 */
661 int (*get_rxnfc)(struct dsa_switch *ds, int port,
662 struct ethtool_rxnfc *nfc, u32 *rule_locs);
663 int (*set_rxnfc)(struct dsa_switch *ds, int port,

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

687 * Cross-chip operations
688 */
689 int (*crosschip_bridge_join)(struct dsa_switch *ds, int tree_index,
690 int sw_index, int port,
691 struct net_device *br);
692 void (*crosschip_bridge_leave)(struct dsa_switch *ds, int tree_index,
693 int sw_index, int port,
694 struct net_device *br);
695 int (*crosschip_lag_change)(struct dsa_switch *ds, int sw_index,
696 int port);
697 int (*crosschip_lag_join)(struct dsa_switch *ds, int sw_index,
698 int port, struct net_device *lag,
699 struct netdev_lag_upper_info *info);
700 int (*crosschip_lag_leave)(struct dsa_switch *ds, int sw_index,
701 int port, struct net_device *lag);
627
628 /*
629 * PTP functionality
630 */
631 int (*port_hwtstamp_get)(struct dsa_switch *ds, int port,
632 struct ifreq *ifr);
633 int (*port_hwtstamp_set)(struct dsa_switch *ds, int port,
634 struct ifreq *ifr);

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

640 /* Devlink parameters, etc */
641 int (*devlink_param_get)(struct dsa_switch *ds, u32 id,
642 struct devlink_param_gset_ctx *ctx);
643 int (*devlink_param_set)(struct dsa_switch *ds, u32 id,
644 struct devlink_param_gset_ctx *ctx);
645 int (*devlink_info_get)(struct dsa_switch *ds,
646 struct devlink_info_req *req,
647 struct netlink_ext_ack *extack);
702
703 /*
704 * PTP functionality
705 */
706 int (*port_hwtstamp_get)(struct dsa_switch *ds, int port,
707 struct ifreq *ifr);
708 int (*port_hwtstamp_set)(struct dsa_switch *ds, int port,
709 struct ifreq *ifr);

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

715 /* Devlink parameters, etc */
716 int (*devlink_param_get)(struct dsa_switch *ds, u32 id,
717 struct devlink_param_gset_ctx *ctx);
718 int (*devlink_param_set)(struct dsa_switch *ds, u32 id,
719 struct devlink_param_gset_ctx *ctx);
720 int (*devlink_info_get)(struct dsa_switch *ds,
721 struct devlink_info_req *req,
722 struct netlink_ext_ack *extack);
723 int (*devlink_sb_pool_get)(struct dsa_switch *ds,
724 unsigned int sb_index, u16 pool_index,
725 struct devlink_sb_pool_info *pool_info);
726 int (*devlink_sb_pool_set)(struct dsa_switch *ds, unsigned int sb_index,
727 u16 pool_index, u32 size,
728 enum devlink_sb_threshold_type threshold_type,
729 struct netlink_ext_ack *extack);
730 int (*devlink_sb_port_pool_get)(struct dsa_switch *ds, int port,
731 unsigned int sb_index, u16 pool_index,
732 u32 *p_threshold);
733 int (*devlink_sb_port_pool_set)(struct dsa_switch *ds, int port,
734 unsigned int sb_index, u16 pool_index,
735 u32 threshold,
736 struct netlink_ext_ack *extack);
737 int (*devlink_sb_tc_pool_bind_get)(struct dsa_switch *ds, int port,
738 unsigned int sb_index, u16 tc_index,
739 enum devlink_sb_pool_type pool_type,
740 u16 *p_pool_index, u32 *p_threshold);
741 int (*devlink_sb_tc_pool_bind_set)(struct dsa_switch *ds, int port,
742 unsigned int sb_index, u16 tc_index,
743 enum devlink_sb_pool_type pool_type,
744 u16 pool_index, u32 threshold,
745 struct netlink_ext_ack *extack);
746 int (*devlink_sb_occ_snapshot)(struct dsa_switch *ds,
747 unsigned int sb_index);
748 int (*devlink_sb_occ_max_clear)(struct dsa_switch *ds,
749 unsigned int sb_index);
750 int (*devlink_sb_occ_port_pool_get)(struct dsa_switch *ds, int port,
751 unsigned int sb_index, u16 pool_index,
752 u32 *p_cur, u32 *p_max);
753 int (*devlink_sb_occ_tc_port_bind_get)(struct dsa_switch *ds, int port,
754 unsigned int sb_index, u16 tc_index,
755 enum devlink_sb_pool_type pool_type,
756 u32 *p_cur, u32 *p_max);
648
649 /*
650 * MTU change functionality. Switches can also adjust their MRU through
651 * this method. By MTU, one understands the SDU (L2 payload) length.
652 * If the switch needs to account for the DSA tag on the CPU port, this
653 * method needs to do so privately.
654 */
655 int (*port_change_mtu)(struct dsa_switch *ds, int port,
656 int new_mtu);
657 int (*port_max_mtu)(struct dsa_switch *ds, int port);
757
758 /*
759 * MTU change functionality. Switches can also adjust their MRU through
760 * this method. By MTU, one understands the SDU (L2 payload) length.
761 * If the switch needs to account for the DSA tag on the CPU port, this
762 * method needs to do so privately.
763 */
764 int (*port_change_mtu)(struct dsa_switch *ds, int port,
765 int new_mtu);
766 int (*port_max_mtu)(struct dsa_switch *ds, int port);
767
768 /*
769 * LAG integration
770 */
771 int (*port_lag_change)(struct dsa_switch *ds, int port);
772 int (*port_lag_join)(struct dsa_switch *ds, int port,
773 struct net_device *lag,
774 struct netdev_lag_upper_info *info);
775 int (*port_lag_leave)(struct dsa_switch *ds, int port,
776 struct net_device *lag);
777
778 /*
779 * HSR integration
780 */
781 int (*port_hsr_join)(struct dsa_switch *ds, int port,
782 struct net_device *hsr);
783 int (*port_hsr_leave)(struct dsa_switch *ds, int port,
784 struct net_device *hsr);
658};
659
660#define DSA_DEVLINK_PARAM_DRIVER(_id, _name, _type, _cmodes) \
661 DEVLINK_PARAM_DRIVER(_id, _name, _type, _cmodes, \
662 dsa_devlink_param_get, dsa_devlink_param_set, NULL)
663
664int dsa_devlink_param_get(struct devlink *dl, u32 id,
665 struct devlink_param_gset_ctx *ctx);

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

823 return 0;
824}
825static inline int dsa_switch_resume(struct dsa_switch *ds)
826{
827 return 0;
828}
829#endif /* CONFIG_PM_SLEEP */
830
785};
786
787#define DSA_DEVLINK_PARAM_DRIVER(_id, _name, _type, _cmodes) \
788 DEVLINK_PARAM_DRIVER(_id, _name, _type, _cmodes, \
789 dsa_devlink_param_get, dsa_devlink_param_set, NULL)
790
791int dsa_devlink_param_get(struct devlink *dl, u32 id,
792 struct devlink_param_gset_ctx *ctx);

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

950 return 0;
951}
952static inline int dsa_switch_resume(struct dsa_switch *ds)
953{
954 return 0;
955}
956#endif /* CONFIG_PM_SLEEP */
957
831enum dsa_notifier_type {
832 DSA_PORT_REGISTER,
833 DSA_PORT_UNREGISTER,
834};
835
836struct dsa_notifier_info {
837 struct net_device *dev;
838};
839
840struct dsa_notifier_register_info {
841 struct dsa_notifier_info info; /* must be first */
842 struct net_device *master;
843 unsigned int port_number;
844 unsigned int switch_number;
845};
846
847static inline struct net_device *
848dsa_notifier_info_to_dev(const struct dsa_notifier_info *info)
849{
850 return info->dev;
851}
852
853#if IS_ENABLED(CONFIG_NET_DSA)
958#if IS_ENABLED(CONFIG_NET_DSA)
854int register_dsa_notifier(struct notifier_block *nb);
855int unregister_dsa_notifier(struct notifier_block *nb);
856int call_dsa_notifiers(unsigned long val, struct net_device *dev,
857 struct dsa_notifier_info *info);
959bool dsa_slave_dev_check(const struct net_device *dev);
858#else
960#else
859static inline int register_dsa_notifier(struct notifier_block *nb)
961static inline bool dsa_slave_dev_check(const struct net_device *dev)
860{
962{
861 return 0;
963 return false;
862}
964}
863
864static inline int unregister_dsa_notifier(struct notifier_block *nb)
865{
866 return 0;
867}
868
869static inline int call_dsa_notifiers(unsigned long val, struct net_device *dev,
870 struct dsa_notifier_info *info)
871{
872 return NOTIFY_DONE;
873}
874#endif
875
965#endif
966
876/* Broadcom tag specific helpers to insert and extract queue/port number */
877#define BRCM_TAG_SET_PORT_QUEUE(p, q) ((p) << 8 | q)
878#define BRCM_TAG_GET_PORT(v) ((v) >> 8)
879#define BRCM_TAG_GET_QUEUE(v) ((v) & 0xff)
880
881
882netdev_tx_t dsa_enqueue_skb(struct sk_buff *skb, struct net_device *dev);
883int dsa_port_get_phy_strings(struct dsa_port *dp, uint8_t *data);
884int dsa_port_get_ethtool_phy_stats(struct dsa_port *dp, uint64_t *data);
885int dsa_port_get_phy_sset_count(struct dsa_port *dp);
886void dsa_port_phylink_mac_change(struct dsa_switch *ds, int port, bool up);
887
888struct dsa_tag_driver {
889 const struct dsa_device_ops *ops;

--- 65 unchanged lines hidden ---
967netdev_tx_t dsa_enqueue_skb(struct sk_buff *skb, struct net_device *dev);
968int dsa_port_get_phy_strings(struct dsa_port *dp, uint8_t *data);
969int dsa_port_get_ethtool_phy_stats(struct dsa_port *dp, uint64_t *data);
970int dsa_port_get_phy_sset_count(struct dsa_port *dp);
971void dsa_port_phylink_mac_change(struct dsa_switch *ds, int port, bool up);
972
973struct dsa_tag_driver {
974 const struct dsa_device_ops *ops;

--- 65 unchanged lines hidden ---