6b13f685e
김민수
BSP 최초 추가
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
#ifndef __LINUX_NET_DSA_H
#define __LINUX_NET_DSA_H
#include <linux/if_ether.h>
#include <linux/list.h>
#include <linux/timer.h>
#include <linux/workqueue.h>
#define DSA_MAX_SWITCHES 4
#define DSA_MAX_PORTS 12
struct dsa_chip_data {
struct device *mii_bus;
int sw_addr;
char *port_names[DSA_MAX_PORTS];
s8 *rtable;
};
struct dsa_platform_data {
struct device *netdev;
int nr_chips;
struct dsa_chip_data *chip;
};
struct dsa_switch_tree {
struct dsa_platform_data *pd;
struct net_device *master_netdev;
__be16 tag_protocol;
s8 cpu_switch;
s8 cpu_port;
int link_poll_needed;
struct work_struct link_poll_work;
struct timer_list link_poll_timer;
struct dsa_switch *ds[DSA_MAX_SWITCHES];
};
struct dsa_switch {
struct dsa_switch_tree *dst;
int index;
struct dsa_chip_data *pd;
struct dsa_switch_driver *drv;
struct mii_bus *master_mii_bus;
u32 dsa_port_mask;
u32 phys_port_mask;
struct mii_bus *slave_mii_bus;
struct net_device *ports[DSA_MAX_PORTS];
};
static inline bool dsa_is_cpu_port(struct dsa_switch *ds, int p)
{
return !!(ds->index == ds->dst->cpu_switch && p == ds->dst->cpu_port);
}
static inline u8 dsa_upstream_port(struct dsa_switch *ds)
{
struct dsa_switch_tree *dst = ds->dst;
if (dst->cpu_switch == ds->index)
return dst->cpu_port;
else
return ds->pd->rtable[dst->cpu_switch];
}
struct dsa_switch_driver {
struct list_head list;
__be16 tag_protocol;
int priv_size;
char *(*probe)(struct mii_bus *bus, int sw_addr);
int (*setup)(struct dsa_switch *ds);
int (*set_addr)(struct dsa_switch *ds, u8 *addr);
int (*phy_read)(struct dsa_switch *ds, int port, int regnum);
int (*phy_write)(struct dsa_switch *ds, int port,
int regnum, u16 val);
void (*poll_link)(struct dsa_switch *ds);
void (*get_strings)(struct dsa_switch *ds, int port, uint8_t *data);
void (*get_ethtool_stats)(struct dsa_switch *ds,
int port, uint64_t *data);
int (*get_sset_count)(struct dsa_switch *ds);
};
void register_switch_driver(struct dsa_switch_driver *type);
void unregister_switch_driver(struct dsa_switch_driver *type);
static inline bool dsa_uses_dsa_tags(struct dsa_switch_tree *dst)
{
return !!(dst->tag_protocol == htons(ETH_P_DSA));
}
static inline bool dsa_uses_trailer_tags(struct dsa_switch_tree *dst)
{
return !!(dst->tag_protocol == htons(ETH_P_TRAILER));
}
#endif
|