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