Commit | Line | Data |
---|---|---|
91da11f8 LB |
1 | /* |
2 | * include/net/dsa.h - Driver for Distributed Switch Architecture switch chips | |
e84665c9 | 3 | * Copyright (c) 2008-2009 Marvell Semiconductor |
91da11f8 LB |
4 | * |
5 | * This program is free software; you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License as published by | |
7 | * the Free Software Foundation; either version 2 of the License, or | |
8 | * (at your option) any later version. | |
9 | */ | |
10 | ||
11 | #ifndef __LINUX_NET_DSA_H | |
12 | #define __LINUX_NET_DSA_H | |
13 | ||
cf50dcc2 BH |
14 | #include <linux/timer.h> |
15 | #include <linux/workqueue.h> | |
16 | ||
e84665c9 LB |
17 | #define DSA_MAX_SWITCHES 4 |
18 | #define DSA_MAX_PORTS 12 | |
19 | ||
20 | struct dsa_chip_data { | |
21 | /* | |
22 | * How to access the switch configuration registers. | |
23 | */ | |
24 | struct device *mii_bus; | |
25 | int sw_addr; | |
26 | ||
27 | /* | |
28 | * The names of the switch's ports. Use "cpu" to | |
29 | * designate the switch port that the cpu is connected to, | |
30 | * "dsa" to indicate that this port is a DSA link to | |
31 | * another switch, NULL to indicate the port is unused, | |
32 | * or any other string to indicate this is a physical port. | |
33 | */ | |
34 | char *port_names[DSA_MAX_PORTS]; | |
35 | ||
36 | /* | |
37 | * An array (with nr_chips elements) of which element [a] | |
38 | * indicates which port on this switch should be used to | |
39 | * send packets to that are destined for switch a. Can be | |
40 | * NULL if there is only one switch chip. | |
41 | */ | |
42 | s8 *rtable; | |
43 | }; | |
91da11f8 LB |
44 | |
45 | struct dsa_platform_data { | |
46 | /* | |
47 | * Reference to a Linux network interface that connects | |
e84665c9 | 48 | * to the root switch chip of the tree. |
91da11f8 LB |
49 | */ |
50 | struct device *netdev; | |
51 | ||
52 | /* | |
e84665c9 LB |
53 | * Info structs describing each of the switch chips |
54 | * connected via this network interface. | |
91da11f8 | 55 | */ |
e84665c9 LB |
56 | int nr_chips; |
57 | struct dsa_chip_data *chip; | |
91da11f8 LB |
58 | }; |
59 | ||
cf50dcc2 BH |
60 | struct dsa_switch_tree { |
61 | /* | |
62 | * Configuration data for the platform device that owns | |
63 | * this dsa switch tree instance. | |
64 | */ | |
65 | struct dsa_platform_data *pd; | |
66 | ||
67 | /* | |
68 | * Reference to network device to use, and which tagging | |
69 | * protocol to use. | |
70 | */ | |
71 | struct net_device *master_netdev; | |
72 | __be16 tag_protocol; | |
73 | ||
74 | /* | |
75 | * The switch and port to which the CPU is attached. | |
76 | */ | |
77 | s8 cpu_switch; | |
78 | s8 cpu_port; | |
79 | ||
80 | /* | |
81 | * Link state polling. | |
82 | */ | |
83 | int link_poll_needed; | |
84 | struct work_struct link_poll_work; | |
85 | struct timer_list link_poll_timer; | |
86 | ||
87 | /* | |
88 | * Data for the individual switch chips. | |
89 | */ | |
90 | struct dsa_switch *ds[DSA_MAX_SWITCHES]; | |
91 | }; | |
92 | ||
93 | /* | |
94 | * The original DSA tag format and some other tag formats have no | |
95 | * ethertype, which means that we need to add a little hack to the | |
96 | * networking receive path to make sure that received frames get | |
97 | * the right ->protocol assigned to them when one of those tag | |
98 | * formats is in use. | |
99 | */ | |
100 | static inline bool dsa_uses_dsa_tags(struct dsa_switch_tree *dst) | |
101 | { | |
102 | return !!(dst->tag_protocol == htons(ETH_P_DSA)); | |
103 | } | |
cf85d08f | 104 | |
cf50dcc2 BH |
105 | static inline bool dsa_uses_trailer_tags(struct dsa_switch_tree *dst) |
106 | { | |
107 | return !!(dst->tag_protocol == htons(ETH_P_TRAILER)); | |
108 | } | |
91da11f8 LB |
109 | |
110 | #endif |