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
7 #ifndef __LINUX_NET_DSA_H
8 #define __LINUX_NET_DSA_H
11 #include <linux/if_ether.h>
12 #include <linux/list.h>
13 #include <linux/notifier.h>
14 #include <linux/timer.h>
15 #include <linux/workqueue.h>
17 #include <linux/ethtool.h>
18 #include <linux/net_tstamp.h>
19 #include <linux/phy.h>
20 #include <linux/platform_data/dsa.h>
21 #include <linux/phylink.h>
22 #include <net/devlink.h>
23 #include <net/switchdev.h>
27 struct fixed_phy_status
;
28 struct phylink_link_state
;
30 #define DSA_TAG_PROTO_NONE_VALUE 0
31 #define DSA_TAG_PROTO_BRCM_VALUE 1
32 #define DSA_TAG_PROTO_BRCM_PREPEND_VALUE 2
33 #define DSA_TAG_PROTO_DSA_VALUE 3
34 #define DSA_TAG_PROTO_EDSA_VALUE 4
35 #define DSA_TAG_PROTO_GSWIP_VALUE 5
36 #define DSA_TAG_PROTO_KSZ9477_VALUE 6
37 #define DSA_TAG_PROTO_KSZ9893_VALUE 7
38 #define DSA_TAG_PROTO_LAN9303_VALUE 8
39 #define DSA_TAG_PROTO_MTK_VALUE 9
40 #define DSA_TAG_PROTO_QCA_VALUE 10
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
48 enum dsa_tag_protocol
{
49 DSA_TAG_PROTO_NONE
= DSA_TAG_PROTO_NONE_VALUE
,
50 DSA_TAG_PROTO_BRCM
= DSA_TAG_PROTO_BRCM_VALUE
,
51 DSA_TAG_PROTO_BRCM_PREPEND
= DSA_TAG_PROTO_BRCM_PREPEND_VALUE
,
52 DSA_TAG_PROTO_DSA
= DSA_TAG_PROTO_DSA_VALUE
,
53 DSA_TAG_PROTO_EDSA
= DSA_TAG_PROTO_EDSA_VALUE
,
54 DSA_TAG_PROTO_GSWIP
= DSA_TAG_PROTO_GSWIP_VALUE
,
55 DSA_TAG_PROTO_KSZ9477
= DSA_TAG_PROTO_KSZ9477_VALUE
,
56 DSA_TAG_PROTO_KSZ9893
= DSA_TAG_PROTO_KSZ9893_VALUE
,
57 DSA_TAG_PROTO_LAN9303
= DSA_TAG_PROTO_LAN9303_VALUE
,
58 DSA_TAG_PROTO_MTK
= DSA_TAG_PROTO_MTK_VALUE
,
59 DSA_TAG_PROTO_QCA
= DSA_TAG_PROTO_QCA_VALUE
,
60 DSA_TAG_PROTO_TRAILER
= DSA_TAG_PROTO_TRAILER_VALUE
,
61 DSA_TAG_PROTO_8021Q
= DSA_TAG_PROTO_8021Q_VALUE
,
62 DSA_TAG_PROTO_SJA1105
= DSA_TAG_PROTO_SJA1105_VALUE
,
63 DSA_TAG_PROTO_KSZ8795
= DSA_TAG_PROTO_KSZ8795_VALUE
,
64 DSA_TAG_PROTO_OCELOT
= DSA_TAG_PROTO_OCELOT_VALUE
,
65 DSA_TAG_PROTO_AR9331
= DSA_TAG_PROTO_AR9331_VALUE
,
71 struct dsa_device_ops
{
72 struct sk_buff
*(*xmit
)(struct sk_buff
*skb
, struct net_device
*dev
);
73 struct sk_buff
*(*rcv
)(struct sk_buff
*skb
, struct net_device
*dev
,
74 struct packet_type
*pt
);
75 int (*flow_dissect
)(const struct sk_buff
*skb
, __be16
*proto
,
77 /* Used to determine which traffic should match the DSA filter in
78 * eth_type_trans, and which, if any, should bypass it and be processed
79 * as regular on the master net device.
81 bool (*filter
)(const struct sk_buff
*skb
, struct net_device
*dev
);
82 unsigned int overhead
;
84 enum dsa_tag_protocol proto
;
87 #define DSA_TAG_DRIVER_ALIAS "dsa_tag-"
88 #define MODULE_ALIAS_DSA_TAG_DRIVER(__proto) \
89 MODULE_ALIAS(DSA_TAG_DRIVER_ALIAS __stringify(__proto##_VALUE))
92 struct sk_buff
*clone
;
97 u8 priv
[48 - sizeof(struct dsa_skb_cb
)];
100 #define DSA_SKB_CB(skb) ((struct dsa_skb_cb *)((skb)->cb))
102 #define DSA_SKB_CB_PRIV(skb) \
103 ((void *)(skb)->cb + offsetof(struct __dsa_skb_cb, priv))
105 struct dsa_switch_tree
{
106 struct list_head list
;
108 /* Notifier chain for switch-wide events */
109 struct raw_notifier_head nh
;
111 /* Tree identifier */
114 /* Number of switches attached to this tree */
115 struct kref refcount
;
117 /* Has this tree been applied to the hardware? */
121 * Configuration data for the platform device that owns
122 * this dsa switch tree instance.
124 struct dsa_platform_data
*pd
;
126 /* List of switch ports */
127 struct list_head ports
;
129 /* List of DSA links composing the routing table */
130 struct list_head rtable
;
133 /* TC matchall action types, only mirroring for now */
134 enum dsa_port_mall_action_type
{
135 DSA_PORT_MALL_MIRROR
,
138 /* TC mirroring entry */
139 struct dsa_mall_mirror_tc_entry
{
144 /* TC matchall entry */
145 struct dsa_mall_tc_entry
{
146 struct list_head list
;
147 unsigned long cookie
;
148 enum dsa_port_mall_action_type type
;
150 struct dsa_mall_mirror_tc_entry mirror
;
156 /* A CPU port is physically connected to a master device.
157 * A user port exposed to userspace has a slave device.
160 struct net_device
*master
;
161 struct net_device
*slave
;
164 /* CPU port tagging operations used by master or slave devices */
165 const struct dsa_device_ops
*tag_ops
;
167 /* Copies for faster access in master receive hot path */
168 struct dsa_switch_tree
*dst
;
169 struct sk_buff
*(*rcv
)(struct sk_buff
*skb
, struct net_device
*dev
,
170 struct packet_type
*pt
);
171 bool (*filter
)(const struct sk_buff
*skb
, struct net_device
*dev
);
174 DSA_PORT_TYPE_UNUSED
= 0,
180 struct dsa_switch
*ds
;
183 struct dsa_port
*cpu_dp
;
185 struct device_node
*dn
;
186 unsigned int ageing_time
;
189 struct net_device
*bridge_dev
;
190 struct devlink_port devlink_port
;
192 struct phylink_config pl_config
;
194 struct list_head list
;
197 * Give the switch driver somewhere to hang its per-port private data
198 * structures (accessible from the tagger).
203 * Original copy of the master netdev ethtool_ops
205 const struct ethtool_ops
*orig_ethtool_ops
;
208 * Original copy of the master netdev net_device_ops
210 const struct net_device_ops
*orig_ndo_ops
;
215 /* TODO: ideally DSA ports would have a single dp->link_dp member,
216 * and no dst->rtable nor this struct dsa_link would be needed,
217 * but this would require some more complex tree walking,
218 * so keep it stupid at the moment and list them all.
222 struct dsa_port
*link_dp
;
223 struct list_head list
;
232 * Parent switch tree, and switch index.
234 struct dsa_switch_tree
*dst
;
237 /* Listener for switch fabric events */
238 struct notifier_block nb
;
241 * Give the switch driver somewhere to hang its private data
247 * Configuration data for this switch.
249 struct dsa_chip_data
*cd
;
252 * The switch operations.
254 const struct dsa_switch_ops
*ops
;
257 * Slave mii_bus and devices for the individual ports.
260 struct mii_bus
*slave_mii_bus
;
262 /* Ageing Time limits in msecs */
263 unsigned int ageing_time_min
;
264 unsigned int ageing_time_max
;
266 /* devlink used to represent this switch device */
267 struct devlink
*devlink
;
269 /* Number of switch port queues */
270 unsigned int num_tx_queues
;
272 /* Disallow bridge core from requesting different VLAN awareness
273 * settings on ports if not hardware-supported
275 bool vlan_filtering_is_global
;
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.
282 /* MAC PCS does not provide link state change interrupt, and requires
283 * polling. Flag passed on to PHYLINK.
290 static inline struct dsa_port
*dsa_to_port(struct dsa_switch
*ds
, int p
)
292 struct dsa_switch_tree
*dst
= ds
->dst
;
295 list_for_each_entry(dp
, &dst
->ports
, list
)
296 if (dp
->ds
== ds
&& dp
->index
== p
)
302 static inline bool dsa_is_unused_port(struct dsa_switch
*ds
, int p
)
304 return dsa_to_port(ds
, p
)->type
== DSA_PORT_TYPE_UNUSED
;
307 static inline bool dsa_is_cpu_port(struct dsa_switch
*ds
, int p
)
309 return dsa_to_port(ds
, p
)->type
== DSA_PORT_TYPE_CPU
;
312 static inline bool dsa_is_dsa_port(struct dsa_switch
*ds
, int p
)
314 return dsa_to_port(ds
, p
)->type
== DSA_PORT_TYPE_DSA
;
317 static inline bool dsa_is_user_port(struct dsa_switch
*ds
, int p
)
319 return dsa_to_port(ds
, p
)->type
== DSA_PORT_TYPE_USER
;
322 static inline u32
dsa_user_ports(struct dsa_switch
*ds
)
327 for (p
= 0; p
< ds
->num_ports
; p
++)
328 if (dsa_is_user_port(ds
, p
))
334 /* Return the local port used to reach an arbitrary switch device */
335 static inline unsigned int dsa_routing_port(struct dsa_switch
*ds
, int device
)
337 struct dsa_switch_tree
*dst
= ds
->dst
;
340 list_for_each_entry(dl
, &dst
->rtable
, list
)
341 if (dl
->dp
->ds
== ds
&& dl
->link_dp
->ds
->index
== device
)
342 return dl
->dp
->index
;
344 return ds
->num_ports
;
347 /* Return the local port used to reach an arbitrary switch port */
348 static inline unsigned int dsa_towards_port(struct dsa_switch
*ds
, int device
,
351 if (device
== ds
->index
)
354 return dsa_routing_port(ds
, device
);
357 /* Return the local port used to reach the dedicated CPU port */
358 static inline unsigned int dsa_upstream_port(struct dsa_switch
*ds
, int port
)
360 const struct dsa_port
*dp
= dsa_to_port(ds
, port
);
361 const struct dsa_port
*cpu_dp
= dp
->cpu_dp
;
366 return dsa_towards_port(ds
, cpu_dp
->ds
->index
, cpu_dp
->index
);
369 static inline bool dsa_port_is_vlan_filtering(const struct dsa_port
*dp
)
371 const struct dsa_switch
*ds
= dp
->ds
;
373 if (ds
->vlan_filtering_is_global
)
374 return ds
->vlan_filtering
;
376 return dp
->vlan_filtering
;
379 typedef int dsa_fdb_dump_cb_t(const unsigned char *addr
, u16 vid
,
380 bool is_static
, void *data
);
381 struct dsa_switch_ops
{
382 enum dsa_tag_protocol (*get_tag_protocol
)(struct dsa_switch
*ds
,
384 enum dsa_tag_protocol mprot
);
386 int (*setup
)(struct dsa_switch
*ds
);
387 void (*teardown
)(struct dsa_switch
*ds
);
388 u32 (*get_phy_flags
)(struct dsa_switch
*ds
, int port
);
391 * Access to the switch's PHY registers.
393 int (*phy_read
)(struct dsa_switch
*ds
, int port
, int regnum
);
394 int (*phy_write
)(struct dsa_switch
*ds
, int port
,
395 int regnum
, u16 val
);
398 * Link state adjustment (called from libphy)
400 void (*adjust_link
)(struct dsa_switch
*ds
, int port
,
401 struct phy_device
*phydev
);
402 void (*fixed_link_update
)(struct dsa_switch
*ds
, int port
,
403 struct fixed_phy_status
*st
);
406 * PHYLINK integration
408 void (*phylink_validate
)(struct dsa_switch
*ds
, int port
,
409 unsigned long *supported
,
410 struct phylink_link_state
*state
);
411 int (*phylink_mac_link_state
)(struct dsa_switch
*ds
, int port
,
412 struct phylink_link_state
*state
);
413 void (*phylink_mac_config
)(struct dsa_switch
*ds
, int port
,
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
,
419 phy_interface_t interface
);
420 void (*phylink_mac_link_up
)(struct dsa_switch
*ds
, int port
,
422 phy_interface_t interface
,
423 struct phy_device
*phydev
);
424 void (*phylink_fixed_state
)(struct dsa_switch
*ds
, int port
,
425 struct phylink_link_state
*state
);
427 * ethtool hardware statistics.
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
,
432 int port
, uint64_t *data
);
433 int (*get_sset_count
)(struct dsa_switch
*ds
, int port
, int sset
);
434 void (*get_ethtool_phy_stats
)(struct dsa_switch
*ds
,
435 int port
, uint64_t *data
);
438 * ethtool Wake-on-LAN
440 void (*get_wol
)(struct dsa_switch
*ds
, int port
,
441 struct ethtool_wolinfo
*w
);
442 int (*set_wol
)(struct dsa_switch
*ds
, int port
,
443 struct ethtool_wolinfo
*w
);
446 * ethtool timestamp info
448 int (*get_ts_info
)(struct dsa_switch
*ds
, int port
,
449 struct ethtool_ts_info
*ts
);
454 int (*suspend
)(struct dsa_switch
*ds
);
455 int (*resume
)(struct dsa_switch
*ds
);
458 * Port enable/disable
460 int (*port_enable
)(struct dsa_switch
*ds
, int port
,
461 struct phy_device
*phy
);
462 void (*port_disable
)(struct dsa_switch
*ds
, int port
);
465 * Port's MAC EEE settings
467 int (*set_mac_eee
)(struct dsa_switch
*ds
, int port
,
468 struct ethtool_eee
*e
);
469 int (*get_mac_eee
)(struct dsa_switch
*ds
, int port
,
470 struct ethtool_eee
*e
);
473 int (*get_eeprom_len
)(struct dsa_switch
*ds
);
474 int (*get_eeprom
)(struct dsa_switch
*ds
,
475 struct ethtool_eeprom
*eeprom
, u8
*data
);
476 int (*set_eeprom
)(struct dsa_switch
*ds
,
477 struct ethtool_eeprom
*eeprom
, u8
*data
);
482 int (*get_regs_len
)(struct dsa_switch
*ds
, int port
);
483 void (*get_regs
)(struct dsa_switch
*ds
, int port
,
484 struct ethtool_regs
*regs
, void *p
);
489 int (*set_ageing_time
)(struct dsa_switch
*ds
, unsigned int msecs
);
490 int (*port_bridge_join
)(struct dsa_switch
*ds
, int port
,
491 struct net_device
*bridge
);
492 void (*port_bridge_leave
)(struct dsa_switch
*ds
, int port
,
493 struct net_device
*bridge
);
494 void (*port_stp_state_set
)(struct dsa_switch
*ds
, int port
,
496 void (*port_fast_age
)(struct dsa_switch
*ds
, int port
);
497 int (*port_egress_floods
)(struct dsa_switch
*ds
, int port
,
498 bool unicast
, bool multicast
);
503 int (*port_vlan_filtering
)(struct dsa_switch
*ds
, int port
,
504 bool vlan_filtering
);
505 int (*port_vlan_prepare
)(struct dsa_switch
*ds
, int port
,
506 const struct switchdev_obj_port_vlan
*vlan
);
507 void (*port_vlan_add
)(struct dsa_switch
*ds
, int port
,
508 const struct switchdev_obj_port_vlan
*vlan
);
509 int (*port_vlan_del
)(struct dsa_switch
*ds
, int port
,
510 const struct switchdev_obj_port_vlan
*vlan
);
512 * Forwarding database
514 int (*port_fdb_add
)(struct dsa_switch
*ds
, int port
,
515 const unsigned char *addr
, u16 vid
);
516 int (*port_fdb_del
)(struct dsa_switch
*ds
, int port
,
517 const unsigned char *addr
, u16 vid
);
518 int (*port_fdb_dump
)(struct dsa_switch
*ds
, int port
,
519 dsa_fdb_dump_cb_t
*cb
, void *data
);
524 int (*port_mdb_prepare
)(struct dsa_switch
*ds
, int port
,
525 const struct switchdev_obj_port_mdb
*mdb
);
526 void (*port_mdb_add
)(struct dsa_switch
*ds
, int port
,
527 const struct switchdev_obj_port_mdb
*mdb
);
528 int (*port_mdb_del
)(struct dsa_switch
*ds
, int port
,
529 const struct switchdev_obj_port_mdb
*mdb
);
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
);
541 int (*port_mirror_add
)(struct dsa_switch
*ds
, int port
,
542 struct dsa_mall_mirror_tc_entry
*mirror
,
544 void (*port_mirror_del
)(struct dsa_switch
*ds
, int port
,
545 struct dsa_mall_mirror_tc_entry
*mirror
);
546 int (*port_setup_tc
)(struct dsa_switch
*ds
, int port
,
547 enum tc_setup_type type
, void *type_data
);
550 * Cross-chip operations
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
);
560 int (*port_hwtstamp_get
)(struct dsa_switch
*ds
, int port
,
562 int (*port_hwtstamp_set
)(struct dsa_switch
*ds
, int port
,
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
);
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
);
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)
580 int dsa_devlink_param_get(struct devlink
*dl
, u32 id
,
581 struct devlink_param_gset_ctx
*ctx
);
582 int dsa_devlink_param_set(struct devlink
*dl
, u32 id
,
583 struct devlink_param_gset_ctx
*ctx
);
584 int dsa_devlink_params_register(struct dsa_switch
*ds
,
585 const struct devlink_param
*params
,
586 size_t params_count
);
587 void dsa_devlink_params_unregister(struct dsa_switch
*ds
,
588 const struct devlink_param
*params
,
589 size_t params_count
);
590 int dsa_devlink_resource_register(struct dsa_switch
*ds
,
591 const char *resource_name
,
594 u64 parent_resource_id
,
595 const struct devlink_resource_size_params
*size_params
);
597 void dsa_devlink_resources_unregister(struct dsa_switch
*ds
);
599 void dsa_devlink_resource_occ_get_register(struct dsa_switch
*ds
,
601 devlink_resource_occ_get_t
*occ_get
,
603 void dsa_devlink_resource_occ_get_unregister(struct dsa_switch
*ds
,
606 struct dsa_devlink_priv
{
607 struct dsa_switch
*ds
;
610 struct dsa_switch_driver
{
611 struct list_head list
;
612 const struct dsa_switch_ops
*ops
;
615 struct net_device
*dsa_dev_to_net_device(struct device
*dev
);
617 /* Keep inline for faster access in hot path */
618 static inline bool netdev_uses_dsa(struct net_device
*dev
)
620 #if IS_ENABLED(CONFIG_NET_DSA)
621 return dev
->dsa_ptr
&& dev
->dsa_ptr
->rcv
;
626 static inline bool dsa_can_decode(const struct sk_buff
*skb
,
627 struct net_device
*dev
)
629 #if IS_ENABLED(CONFIG_NET_DSA)
630 return !dev
->dsa_ptr
->filter
|| dev
->dsa_ptr
->filter(skb
, dev
);
635 void dsa_unregister_switch(struct dsa_switch
*ds
);
636 int dsa_register_switch(struct dsa_switch
*ds
);
637 #ifdef CONFIG_PM_SLEEP
638 int dsa_switch_suspend(struct dsa_switch
*ds
);
639 int dsa_switch_resume(struct dsa_switch
*ds
);
641 static inline int dsa_switch_suspend(struct dsa_switch
*ds
)
645 static inline int dsa_switch_resume(struct dsa_switch
*ds
)
649 #endif /* CONFIG_PM_SLEEP */
651 enum dsa_notifier_type
{
656 struct dsa_notifier_info
{
657 struct net_device
*dev
;
660 struct dsa_notifier_register_info
{
661 struct dsa_notifier_info info
; /* must be first */
662 struct net_device
*master
;
663 unsigned int port_number
;
664 unsigned int switch_number
;
667 static inline struct net_device
*
668 dsa_notifier_info_to_dev(const struct dsa_notifier_info
*info
)
673 #if IS_ENABLED(CONFIG_NET_DSA)
674 int register_dsa_notifier(struct notifier_block
*nb
);
675 int unregister_dsa_notifier(struct notifier_block
*nb
);
676 int call_dsa_notifiers(unsigned long val
, struct net_device
*dev
,
677 struct dsa_notifier_info
*info
);
679 static inline int register_dsa_notifier(struct notifier_block
*nb
)
684 static inline int unregister_dsa_notifier(struct notifier_block
*nb
)
689 static inline int call_dsa_notifiers(unsigned long val
, struct net_device
*dev
,
690 struct dsa_notifier_info
*info
)
696 /* Broadcom tag specific helpers to insert and extract queue/port number */
697 #define BRCM_TAG_SET_PORT_QUEUE(p, q) ((p) << 8 | q)
698 #define BRCM_TAG_GET_PORT(v) ((v) >> 8)
699 #define BRCM_TAG_GET_QUEUE(v) ((v) & 0xff)
702 netdev_tx_t
dsa_enqueue_skb(struct sk_buff
*skb
, struct net_device
*dev
);
703 int dsa_port_get_phy_strings(struct dsa_port
*dp
, uint8_t *data
);
704 int dsa_port_get_ethtool_phy_stats(struct dsa_port
*dp
, uint64_t *data
);
705 int dsa_port_get_phy_sset_count(struct dsa_port
*dp
);
706 void dsa_port_phylink_mac_change(struct dsa_switch
*ds
, int port
, bool up
);
708 struct dsa_tag_driver
{
709 const struct dsa_device_ops
*ops
;
710 struct list_head list
;
711 struct module
*owner
;
714 void dsa_tag_drivers_register(struct dsa_tag_driver
*dsa_tag_driver_array
[],
716 struct module
*owner
);
717 void dsa_tag_drivers_unregister(struct dsa_tag_driver
*dsa_tag_driver_array
[],
720 #define dsa_tag_driver_module_drivers(__dsa_tag_drivers_array, __count) \
721 static int __init dsa_tag_driver_module_init(void) \
723 dsa_tag_drivers_register(__dsa_tag_drivers_array, __count, \
727 module_init(dsa_tag_driver_module_init); \
729 static void __exit dsa_tag_driver_module_exit(void) \
731 dsa_tag_drivers_unregister(__dsa_tag_drivers_array, __count); \
733 module_exit(dsa_tag_driver_module_exit)
736 * module_dsa_tag_drivers() - Helper macro for registering DSA tag
738 * @__ops_array: Array of tag driver strucutres
740 * Helper macro for DSA tag drivers which do not do anything special
741 * in module init/exit. Each module may only use this macro once, and
742 * calling it replaces module_init() and module_exit().
744 #define module_dsa_tag_drivers(__ops_array) \
745 dsa_tag_driver_module_drivers(__ops_array, ARRAY_SIZE(__ops_array))
747 #define DSA_TAG_DRIVER_NAME(__ops) dsa_tag_driver ## _ ## __ops
749 /* Create a static structure we can build a linked list of dsa_tag
752 #define DSA_TAG_DRIVER(__ops) \
753 static struct dsa_tag_driver DSA_TAG_DRIVER_NAME(__ops) = { \
758 * module_dsa_tag_driver() - Helper macro for registering a single DSA tag
760 * @__ops: Single tag driver structures
762 * Helper macro for DSA tag drivers which do not do anything special
763 * in module init/exit. Each module may only use this macro once, and
764 * calling it replaces module_init() and module_exit().
766 #define module_dsa_tag_driver(__ops) \
767 DSA_TAG_DRIVER(__ops); \
769 static struct dsa_tag_driver *dsa_tag_driver_array[] = { \
770 &DSA_TAG_DRIVER_NAME(__ops) \
772 module_dsa_tag_drivers(dsa_tag_driver_array)