1
2
3
4
5
6#ifndef __NCSI_INTERNAL_H__
7#define __NCSI_INTERNAL_H__
8
9enum {
10 NCSI_CAP_BASE = 0,
11 NCSI_CAP_GENERIC = 0,
12 NCSI_CAP_BC,
13 NCSI_CAP_MC,
14 NCSI_CAP_BUFFER,
15 NCSI_CAP_AEN,
16 NCSI_CAP_VLAN,
17 NCSI_CAP_MAX
18};
19
20enum {
21 NCSI_CAP_GENERIC_HWA = 0x01,
22 NCSI_CAP_GENERIC_HDS = 0x02,
23 NCSI_CAP_GENERIC_FC = 0x04,
24 NCSI_CAP_GENERIC_FC1 = 0x08,
25 NCSI_CAP_GENERIC_MC = 0x10,
26 NCSI_CAP_GENERIC_HWA_UNKNOWN = 0x00,
27 NCSI_CAP_GENERIC_HWA_SUPPORT = 0x20,
28 NCSI_CAP_GENERIC_HWA_NOT_SUPPORT = 0x40,
29 NCSI_CAP_GENERIC_HWA_RESERVED = 0x60,
30 NCSI_CAP_GENERIC_HWA_MASK = 0x60,
31 NCSI_CAP_GENERIC_MASK = 0x7f,
32 NCSI_CAP_BC_ARP = 0x01,
33 NCSI_CAP_BC_DHCPC = 0x02,
34 NCSI_CAP_BC_DHCPS = 0x04,
35 NCSI_CAP_BC_NETBIOS = 0x08,
36 NCSI_CAP_BC_MASK = 0x0f,
37 NCSI_CAP_MC_IPV6_NEIGHBOR = 0x01,
38 NCSI_CAP_MC_IPV6_ROUTER = 0x02,
39 NCSI_CAP_MC_DHCPV6_RELAY = 0x04,
40 NCSI_CAP_MC_DHCPV6_WELL_KNOWN = 0x08,
41 NCSI_CAP_MC_IPV6_MLD = 0x10,
42 NCSI_CAP_MC_IPV6_NEIGHBOR_S = 0x20,
43 NCSI_CAP_MC_MASK = 0x3f,
44 NCSI_CAP_AEN_LSC = 0x01,
45 NCSI_CAP_AEN_CR = 0x02,
46 NCSI_CAP_AEN_HDS = 0x04,
47 NCSI_CAP_AEN_MASK = 0x07,
48 NCSI_CAP_VLAN_ONLY = 0x01,
49 NCSI_CAP_VLAN_NO = 0x02,
50 NCSI_CAP_VLAN_ANY = 0x04,
51 NCSI_CAP_VLAN_MASK = 0x07
52};
53
54enum {
55 NCSI_MODE_BASE = 0,
56 NCSI_MODE_ENABLE = 0,
57 NCSI_MODE_TX_ENABLE,
58 NCSI_MODE_LINK,
59 NCSI_MODE_VLAN,
60 NCSI_MODE_BC,
61 NCSI_MODE_MC,
62 NCSI_MODE_AEN,
63 NCSI_MODE_FC,
64 NCSI_MODE_MAX
65};
66
67
68
69
70
71
72
73enum {
74 MLX_MC_RBT_SUPPORT = 0x01,
75 MLX_MC_RBT_AVL = 0x08,
76};
77
78
79#define NCSI_OEM_MFR_MLX_ID 0x8119
80#define NCSI_OEM_MFR_BCM_ID 0x113d
81
82#define NCSI_OEM_BCM_CMD_GMA 0x01
83
84#define NCSI_OEM_MLX_CMD_GMA 0x00
85#define NCSI_OEM_MLX_CMD_GMA_PARAM 0x1b
86#define NCSI_OEM_MLX_CMD_SMAF 0x01
87#define NCSI_OEM_MLX_CMD_SMAF_PARAM 0x07
88
89#define NCSI_OEM_BCM_CMD_GMA_LEN 12
90#define NCSI_OEM_MLX_CMD_GMA_LEN 8
91#define NCSI_OEM_MLX_CMD_SMAF_LEN 60
92
93#define MLX_SMAF_MAC_ADDR_OFFSET 8
94#define MLX_SMAF_MED_SUPPORT_OFFSET 14
95
96#define BCM_MAC_ADDR_OFFSET 28
97#define MLX_MAC_ADDR_OFFSET 8
98
99
100struct ncsi_channel_version {
101 u32 version;
102 u32 alpha2;
103 u8 fw_name[12];
104 u32 fw_version;
105 u16 pci_ids[4];
106 u32 mf_id;
107};
108
109struct ncsi_channel_cap {
110 u32 index;
111 u32 cap;
112};
113
114struct ncsi_channel_mode {
115 u32 index;
116 u32 enable;
117 u32 size;
118 u32 data[8];
119};
120
121struct ncsi_channel_mac_filter {
122 u8 n_uc;
123 u8 n_mc;
124 u8 n_mixed;
125 u64 bitmap;
126 unsigned char *addrs;
127};
128
129struct ncsi_channel_vlan_filter {
130 u8 n_vids;
131 u64 bitmap;
132 u16 *vids;
133};
134
135struct ncsi_channel_stats {
136 u32 hnc_cnt_hi;
137 u32 hnc_cnt_lo;
138 u32 hnc_rx_bytes;
139 u32 hnc_tx_bytes;
140 u32 hnc_rx_uc_pkts;
141 u32 hnc_rx_mc_pkts;
142 u32 hnc_rx_bc_pkts;
143 u32 hnc_tx_uc_pkts;
144 u32 hnc_tx_mc_pkts;
145 u32 hnc_tx_bc_pkts;
146 u32 hnc_fcs_err;
147 u32 hnc_align_err;
148 u32 hnc_false_carrier;
149 u32 hnc_runt_pkts;
150 u32 hnc_jabber_pkts;
151 u32 hnc_rx_pause_xon;
152 u32 hnc_rx_pause_xoff;
153 u32 hnc_tx_pause_xon;
154 u32 hnc_tx_pause_xoff;
155 u32 hnc_tx_s_collision;
156 u32 hnc_tx_m_collision;
157 u32 hnc_l_collision;
158 u32 hnc_e_collision;
159 u32 hnc_rx_ctl_frames;
160 u32 hnc_rx_64_frames;
161 u32 hnc_rx_127_frames;
162 u32 hnc_rx_255_frames;
163 u32 hnc_rx_511_frames;
164 u32 hnc_rx_1023_frames;
165 u32 hnc_rx_1522_frames;
166 u32 hnc_rx_9022_frames;
167 u32 hnc_tx_64_frames;
168 u32 hnc_tx_127_frames;
169 u32 hnc_tx_255_frames;
170 u32 hnc_tx_511_frames;
171 u32 hnc_tx_1023_frames;
172 u32 hnc_tx_1522_frames;
173 u32 hnc_tx_9022_frames;
174 u32 hnc_rx_valid_bytes;
175 u32 hnc_rx_runt_pkts;
176 u32 hnc_rx_jabber_pkts;
177 u32 ncsi_rx_cmds;
178 u32 ncsi_dropped_cmds;
179 u32 ncsi_cmd_type_errs;
180 u32 ncsi_cmd_csum_errs;
181 u32 ncsi_rx_pkts;
182 u32 ncsi_tx_pkts;
183 u32 ncsi_tx_aen_pkts;
184 u32 pt_tx_pkts;
185 u32 pt_tx_dropped;
186 u32 pt_tx_channel_err;
187 u32 pt_tx_us_err;
188 u32 pt_rx_pkts;
189 u32 pt_rx_dropped;
190 u32 pt_rx_channel_err;
191 u32 pt_rx_us_err;
192 u32 pt_rx_os_err;
193};
194
195struct ncsi_dev_priv;
196struct ncsi_package;
197
198#define NCSI_PACKAGE_SHIFT 5
199#define NCSI_PACKAGE_INDEX(c) (((c) >> NCSI_PACKAGE_SHIFT) & 0x7)
200#define NCSI_RESERVED_CHANNEL 0x1f
201#define NCSI_CHANNEL_INDEX(c) ((c) & ((1 << NCSI_PACKAGE_SHIFT) - 1))
202#define NCSI_TO_CHANNEL(p, c) (((p) << NCSI_PACKAGE_SHIFT) | (c))
203#define NCSI_MAX_PACKAGE 8
204#define NCSI_MAX_CHANNEL 32
205
206struct ncsi_channel {
207 unsigned char id;
208 int state;
209#define NCSI_CHANNEL_INACTIVE 1
210#define NCSI_CHANNEL_ACTIVE 2
211#define NCSI_CHANNEL_INVISIBLE 3
212 bool reconfigure_needed;
213 spinlock_t lock;
214 struct ncsi_package *package;
215 struct ncsi_channel_version version;
216 struct ncsi_channel_cap caps[NCSI_CAP_MAX];
217 struct ncsi_channel_mode modes[NCSI_MODE_MAX];
218
219 struct ncsi_channel_mac_filter mac_filter;
220 struct ncsi_channel_vlan_filter vlan_filter;
221 struct ncsi_channel_stats stats;
222 struct {
223 struct timer_list timer;
224 bool enabled;
225 unsigned int state;
226#define NCSI_CHANNEL_MONITOR_START 0
227#define NCSI_CHANNEL_MONITOR_RETRY 1
228#define NCSI_CHANNEL_MONITOR_WAIT 2
229#define NCSI_CHANNEL_MONITOR_WAIT_MAX 5
230 } monitor;
231 struct list_head node;
232 struct list_head link;
233};
234
235struct ncsi_package {
236 unsigned char id;
237 unsigned char uuid[16];
238 struct ncsi_dev_priv *ndp;
239 spinlock_t lock;
240 unsigned int channel_num;
241 struct list_head channels;
242 struct list_head node;
243
244 bool multi_channel;
245 u32 channel_whitelist;
246 struct ncsi_channel *preferred_channel;
247};
248
249struct ncsi_request {
250 unsigned char id;
251 bool used;
252 unsigned int flags;
253#define NCSI_REQ_FLAG_EVENT_DRIVEN 1
254#define NCSI_REQ_FLAG_NETLINK_DRIVEN 2
255 struct ncsi_dev_priv *ndp;
256 struct sk_buff *cmd;
257 struct sk_buff *rsp;
258 struct timer_list timer;
259 bool enabled;
260 u32 snd_seq;
261 u32 snd_portid;
262 struct nlmsghdr nlhdr;
263};
264
265enum {
266 ncsi_dev_state_major = 0xff00,
267 ncsi_dev_state_minor = 0x00ff,
268 ncsi_dev_state_probe_deselect = 0x0201,
269 ncsi_dev_state_probe_package,
270 ncsi_dev_state_probe_channel,
271 ncsi_dev_state_probe_mlx_gma,
272 ncsi_dev_state_probe_mlx_smaf,
273 ncsi_dev_state_probe_cis,
274 ncsi_dev_state_probe_gvi,
275 ncsi_dev_state_probe_gc,
276 ncsi_dev_state_probe_gls,
277 ncsi_dev_state_probe_dp,
278 ncsi_dev_state_config_sp = 0x0301,
279 ncsi_dev_state_config_cis,
280 ncsi_dev_state_config_oem_gma,
281 ncsi_dev_state_config_clear_vids,
282 ncsi_dev_state_config_svf,
283 ncsi_dev_state_config_ev,
284 ncsi_dev_state_config_sma,
285 ncsi_dev_state_config_ebf,
286 ncsi_dev_state_config_dgmf,
287 ncsi_dev_state_config_ecnt,
288 ncsi_dev_state_config_ec,
289 ncsi_dev_state_config_ae,
290 ncsi_dev_state_config_gls,
291 ncsi_dev_state_config_done,
292 ncsi_dev_state_suspend_select = 0x0401,
293 ncsi_dev_state_suspend_gls,
294 ncsi_dev_state_suspend_dcnt,
295 ncsi_dev_state_suspend_dc,
296 ncsi_dev_state_suspend_deselect,
297 ncsi_dev_state_suspend_done
298};
299
300struct vlan_vid {
301 struct list_head list;
302 __be16 proto;
303 u16 vid;
304};
305
306struct ncsi_dev_priv {
307 struct ncsi_dev ndev;
308 unsigned int flags;
309#define NCSI_DEV_PROBED 1
310#define NCSI_DEV_HWA 2
311#define NCSI_DEV_RESHUFFLE 4
312#define NCSI_DEV_RESET 8
313 unsigned int gma_flag;
314 spinlock_t lock;
315 unsigned int package_probe_id;
316 unsigned int package_num;
317 struct list_head packages;
318 struct ncsi_channel *hot_channel;
319 struct ncsi_request requests[256];
320 unsigned int request_id;
321#define NCSI_REQ_START_IDX 1
322 unsigned int pending_req_num;
323 struct ncsi_package *active_package;
324 struct ncsi_channel *active_channel;
325 struct list_head channel_queue;
326 struct work_struct work;
327 struct packet_type ptype;
328 struct list_head node;
329#define NCSI_MAX_VLAN_VIDS 15
330 struct list_head vlan_vids;
331
332 bool multi_package;
333 bool mlx_multi_host;
334 u32 package_whitelist;
335};
336
337struct ncsi_cmd_arg {
338 struct ncsi_dev_priv *ndp;
339 unsigned char type;
340 unsigned char id;
341 unsigned char package;
342 unsigned char channel;
343 unsigned short payload;
344 unsigned int req_flags;
345 union {
346 unsigned char bytes[16];
347 unsigned short words[8];
348 unsigned int dwords[4];
349 };
350 unsigned char *data;
351 struct genl_info *info;
352};
353
354extern struct list_head ncsi_dev_list;
355extern spinlock_t ncsi_dev_lock;
356
357#define TO_NCSI_DEV_PRIV(nd) \
358 container_of(nd, struct ncsi_dev_priv, ndev)
359#define NCSI_FOR_EACH_DEV(ndp) \
360 list_for_each_entry_rcu(ndp, &ncsi_dev_list, node)
361#define NCSI_FOR_EACH_PACKAGE(ndp, np) \
362 list_for_each_entry_rcu(np, &ndp->packages, node)
363#define NCSI_FOR_EACH_CHANNEL(np, nc) \
364 list_for_each_entry_rcu(nc, &np->channels, node)
365
366
367int ncsi_reset_dev(struct ncsi_dev *nd);
368void ncsi_start_channel_monitor(struct ncsi_channel *nc);
369void ncsi_stop_channel_monitor(struct ncsi_channel *nc);
370struct ncsi_channel *ncsi_find_channel(struct ncsi_package *np,
371 unsigned char id);
372struct ncsi_channel *ncsi_add_channel(struct ncsi_package *np,
373 unsigned char id);
374struct ncsi_package *ncsi_find_package(struct ncsi_dev_priv *ndp,
375 unsigned char id);
376struct ncsi_package *ncsi_add_package(struct ncsi_dev_priv *ndp,
377 unsigned char id);
378void ncsi_remove_package(struct ncsi_package *np);
379void ncsi_find_package_and_channel(struct ncsi_dev_priv *ndp,
380 unsigned char id,
381 struct ncsi_package **np,
382 struct ncsi_channel **nc);
383struct ncsi_request *ncsi_alloc_request(struct ncsi_dev_priv *ndp,
384 unsigned int req_flags);
385void ncsi_free_request(struct ncsi_request *nr);
386struct ncsi_dev *ncsi_find_dev(struct net_device *dev);
387int ncsi_process_next_channel(struct ncsi_dev_priv *ndp);
388bool ncsi_channel_has_link(struct ncsi_channel *channel);
389bool ncsi_channel_is_last(struct ncsi_dev_priv *ndp,
390 struct ncsi_channel *channel);
391int ncsi_update_tx_channel(struct ncsi_dev_priv *ndp,
392 struct ncsi_package *np,
393 struct ncsi_channel *disable,
394 struct ncsi_channel *enable);
395
396
397u32 ncsi_calculate_checksum(unsigned char *data, int len);
398int ncsi_xmit_cmd(struct ncsi_cmd_arg *nca);
399int ncsi_rcv_rsp(struct sk_buff *skb, struct net_device *dev,
400 struct packet_type *pt, struct net_device *orig_dev);
401int ncsi_aen_handler(struct ncsi_dev_priv *ndp, struct sk_buff *skb);
402
403#endif
404