Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
[deliverable/linux.git] / drivers / staging / silicom / libbp_sd.h
1 /******************************************************************************/
2 /* */
3 /* bypass library, Copyright (c) 2004 Silicom, Ltd */
4 /* Corporation. */
5 /* */
6 /* This program is free software; you can redistribute it and/or modify */
7 /* it under the terms of the GNU General Public License as published by */
8 /* the Free Software Foundation, located in the file LICENSE. */
9 /* */
10 /* Ver 1.0.0 */
11 /* */
12 /* libbypass.h */
13 /* */
14 /******************************************************************************/
15
16 #define BP_CAP 0x01 /* BIT_0 */
17 #define BP_STATUS_CAP 0x02
18 #define BP_STATUS_CHANGE_CAP 0x04
19 #define SW_CTL_CAP 0x08
20 #define BP_DIS_CAP 0x10
21 #define BP_DIS_STATUS_CAP 0x20
22 #define STD_NIC_CAP 0x40
23 #define BP_PWOFF_ON_CAP 0x80
24 #define BP_PWOFF_OFF_CAP 0x0100
25 #define BP_PWOFF_CTL_CAP 0x0200
26 #define BP_PWUP_ON_CAP 0x0400
27 #define BP_PWUP_OFF_CAP 0x0800
28 #define BP_PWUP_CTL_CAP 0x1000
29 #define WD_CTL_CAP 0x2000
30 #define WD_STATUS_CAP 0x4000
31 #define WD_TIMEOUT_CAP 0x8000
32 #define TX_CTL_CAP 0x10000
33 #define TX_STATUS_CAP 0x20000
34 #define TAP_CAP 0x40000
35 #define TAP_STATUS_CAP 0x80000
36 #define TAP_STATUS_CHANGE_CAP 0x100000
37 #define TAP_DIS_CAP 0x200000
38 #define TAP_DIS_STATUS_CAP 0x400000
39 #define TAP_PWUP_ON_CAP 0x800000
40 #define TAP_PWUP_OFF_CAP 0x1000000
41 #define TAP_PWUP_CTL_CAP 0x2000000
42 #define NIC_CAP_NEG 0x4000000 /* BIT 26 */
43
44 #define WD_MIN_TIME_GET(desc) (desc & 0xf)
45 #define WDT_STEP_TIME 0x10
46
47 struct bp_info {
48 char prod_name[14];
49 unsigned char fw_ver;
50 };
51
52 /**
53 * is_bypass - check if device is a Bypass controlling device
54 * @if_index: network device index
55 *
56 * Output:
57 * 1 - if device is bypass controlling device,
58 * 0 - if device is bypass slave device
59 * -1 - device not support Bypass
60 **/
61 int is_bypass_sd(int if_index);
62
63 /**
64 * get_bypass_slave - get second port participate in the Bypass pair
65 * @if_index: network device index
66 *
67 * Output:
68 * network device index of the slave device
69 * -1 - on failure (device not support Bypass or it's a slave device)
70 **/
71 int get_bypass_slave_sd(int if_index);
72
73 /**
74 * get_bypass_caps - get second port participate in the Bypass pair
75 * @if_index: network device index
76 *
77 * Output:
78 * flags word on success;flag word is a 32-bit mask word with each bit defines different
79 * capability as described bellow.
80 * Value of 1 for supporting this feature. 0 for not supporting this feature.
81 * -1 - on failure (if the device is not capable of the operation or not a Bypass device)
82 * Bit feature description
83 *
84 * 0 BP_CAP The interface is Bypass capable in general
85 *
86 * 1 BP_STATUS_CAP The interface can report of the current Bypass mode
87 *
88 * 2 BP_STATUS_CHANGE_CAP The interface can report on a change to bypass mode from
89 * the last time the mode was defined
90 *
91 * 3 SW_CTL_CAP The interface is Software controlled capable for bypass/non bypass modes.
92 *
93 * 4 BP_DIS_CAP The interface is capable of disabling the Bypass mode at all times.
94 * This mode will retain its mode even during power loss and also after
95 * power recovery. This will overcome on any bypass operation due to
96 * watchdog timeout or set bypass command.
97 *
98 * 5 BP_DIS_STATUS_CAP The interface can report of the current DIS_BP_CAP
99 *
100 * 6 STD_NIC_CAP The interface is capable to be configured to operate as standard, non Bypass,
101 * NIC interface (have direct connection to interfaces at all power modes)
102 *
103 * 7 BP_PWOFF_NO_CAP The interface can be in Bypass mode at power off state
104 *
105 * 8 BP_PWOFF_OFF_CAP The interface can disconnect the Bypass mode at power off state without
106 * effecting all the other states of operation
107 *
108 * 9 BP_PWOFF_CTL_CAP The behavior of the Bypass mode at Power-off state can be controlled by
109 * software without effecting any other state
110 *
111 *10 BP_PWUP_ON_CAP The interface can be in Bypass mode when power is turned on
112 * (until the system take control of the bypass functionality)
113 *
114 *11 BP_PWUP_OFF_CAP The interface can disconnect from Bypass mode when power is turned on
115 * (until the system take control of the bypass functionality)
116 *
117 *12 BP_PWUP_CTL_CAP The behavior of the Bypass mode at Power-up can be controlled by software
118 *
119 *13 WD_CTL_CAP The interface has watchdog capabilities to turn to Bypass mode when not reset
120 * for defined period of time.
121 *
122 *14 WD_STATUS_CAP The interface can report on the watchdog status (Active/inactive)
123 *
124 *15 WD_TIMEOUT_CAP The interface can report the time left till watchdog triggers to Bypass mode.
125 *
126 *16-31 RESERVED
127 *
128 * **/
129 int get_bypass_caps_sd(int if_index);
130
131 /**
132 * get_wd_set_caps - Obtain watchdog timer setting capabilities
133 * @if_index: network device index
134 *
135 * Output:
136 *
137 * Set of numbers defining the various parameters of the watchdog capable
138 * to be set to as described bellow.
139 * -1 - on failure (device not support Bypass or it's a slave device)
140 *
141 * Bit feature description
142 *
143 * 0-3 WD_MIN_TIME The interface WD minimal time period in 100mS units
144 *
145 * 4 WD_STEP_TIME The steps of the WD timer in
146 * 0 - for linear steps (WD_MIN_TIME * X)
147 * 1 - for multiply by 2 from previous step (WD_MIN_TIME * 2^X)
148 *
149 * 5-8 WD_STEP_COUNT Number of steps the WD timer supports in 2^X
150 * (X bit available for defining the value)
151 *
152 *
153 *
154 **/
155 int get_wd_set_caps_sd(int if_index);
156
157 /**
158 * set_bypass - set Bypass state
159 * @if_index: network device index of the controlling device
160 * @bypass_mode: bypass mode (1=on, 0=off)
161 * Output:
162 * 0 - on success
163 * -1 - on failure (device not support Bypass or it's a slave device)
164 **/
165 int set_bypass_sd(int if_index, int bypass_mode);
166
167 /**
168 * get_bypass - Get Bypass mode state
169 * @if_index: network device index of the controlling device
170 * Output:
171 * 0/1 - (off/on) on success
172 * -1 - on failure (device not support Bypass or it's a slave device)
173 **/
174 int get_bypass_sd(int if_index);
175
176 /**
177 * get_bypass_change - Get change of Bypass mode state from last status check
178 * @if_index: network device index of the controlling device
179 * Output:
180 * 0/1 - (off/on) on success
181 * -1 - on failure (device not support Bypass or it's a slave device)
182 **/
183 int get_bypass_change_sd(int if_index);
184
185 /**
186 * set_dis_bypass - Set Disable Bypass mode
187 * @if_index: network device index of the controlling device
188 * @dis_bypass: disable bypass(1=dis, 0=en)
189 * Output:
190 * 0 - on success
191 * -1 - on failure (device is not capable of the operation ordevice not support Bypass
192 * or it's a slave device)
193 **/
194 int set_dis_bypass_sd(int if_index, int dis_bypass);
195
196 /**
197 * get_dis_bypass - Get Disable Bypass mode state
198 * @if_index: network device index of the controlling device
199 * Output:
200 * 0/1 - on success (normal Bypass mode/ Disable bypass)
201 * -1 - on failure (device is not capable of the operation ordevice not support Bypass
202 * or it's a slave device)
203 **/
204 int get_dis_bypass_sd(int if_index);
205
206 /**
207 * set_bypass_pwoff - Set Bypass mode at power-off state
208 * @if_index: network device index of the controlling device
209 * @bypass_mode: bypass mode setting at power off state (1=BP en, 0=BP Dis)
210 * Output:
211 * 0 - on success
212 * -1 - on failure (device is not capable of the operation ordevice not support Bypass
213 * or it's a slave device)
214 **/
215 int set_bypass_pwoff_sd(int if_index, int bypass_mode);
216
217 /**
218 * get_bypass_pwoff - Get Bypass mode state at power-off state
219 * @if_index: network device index of the controlling device
220 * Output:
221 * 0/1 - on success (Disable bypass at power off state / normal Bypass mode)
222 * -1 - on failure (device is not capable of the operation ordevice not support Bypass
223 * or it's a slave device)
224 **/
225 int get_bypass_pwoff_sd(int if_index);
226
227 /**
228 * set_bypass_pwup - Set Bypass mode at power-up state
229 * @if_index: network device index of the controlling device
230 * @bypass_mode: bypass mode setting at power up state (1=BP en, 0=BP Dis)
231 * Output:
232 * 0 - on success
233 * -1 - on failure (device is not capable of the operation ordevice not support Bypass
234 * or it's a slave device)
235 **/
236 int set_bypass_pwup_sd(int if_index, int bypass_mode);
237
238 /**
239 * get_bypass_pwup - Get Bypass mode state at power-up state
240 * @if_index: network device index of the controlling device
241 * Output:
242 * 0/1 - on success (Disable bypass at power up state / normal Bypass mode)
243 * -1 - on failure (device is not capable of the operation ordevice not support Bypass
244 * or it's a slave device)
245 **/
246 int get_bypass_pwup_sd(int if_index);
247
248 /**
249 * set_bypass_wd - Set watchdog state
250 * @if_index: network device index of the controlling device
251 * @ms_timeout: requested timeout (in ms units), 0 for disabling the watchdog timer
252 * @ms_timeout_set(output): requested timeout (in ms units),
253 * that the adapter supports and will be used by the watchdog
254 * Output:
255 * 0 - on success
256 * -1 - on failure (device is not capable of the operation ordevice not support Bypass
257 * or it's a slave device)
258 **/
259 int set_bypass_wd_sd(int if_index, int ms_timeout, int *ms_timeout_set);
260
261 /**
262 * get_bypass_wd - Get watchdog state
263 * @if_index: network device index of the controlling device
264 * @ms_timeout (output): WDT timeout (in ms units),
265 * -1 for unknown wdt status
266 * 0 if WDT is disabled
267 * Output:
268 * 0 - on success
269 * -1 - on failure (device is not capable of the operation ordevice not support Bypass
270 * or it's a slave device)
271 **/
272 int get_bypass_wd_sd(int if_index, int *ms_timeout_set);
273
274 /**
275 * get_wd_expire_time - Get watchdog expire
276 * @if_index: network device index of the controlling device
277 * @ms_time_left (output): time left till watchdog time expire,
278 * -1 if WDT has expired
279 * 0 if WDT is disabled
280 * Output:
281 * 0 - on success
282 * -1 - on failure (device is not capable of the operation ordevice not support Bypass
283 * or it's a slave device or unknown wdt status)
284 **/
285 int get_wd_expire_time_sd(int if_index, int *ms_time_left);
286
287 /**
288 * reset_bypass_wd_timer - Reset watchdog timer
289 * @if_index: network device index of the controlling device
290 *
291 * Output:
292 * 1 - on success
293 * 0 - watchdog is not configured
294 * -1 - on failure (device is not capable of the operation ordevice not support Bypass
295 * or it's a slave device or unknown wdt status)
296 **/
297 int reset_bypass_wd_timer_sd(int if_index);
298
299 /**
300 * set_std_nic - Standard NIC mode of operation
301 * @if_index: network device index of the controlling device
302 * @nic_mode: 0/1 (Default Bypass mode / Standard NIC mode)
303 *
304 * Output:
305 * 0 - on success
306 * -1 - on failure (device is not capable of the operation ordevice not support Bypass
307 * or it's a slave device)
308 **/
309 int set_std_nic_sd(int if_index, int nic_mode);
310
311 /**
312 * get_std_nic - Get Standard NIC mode setting
313 * @if_index: network device index of the controlling device
314 *
315 * Output:
316 * 0/1 (Default Bypass mode / Standard NIC mode) on success
317 * -1 - on failure (device is not capable of the operation ordevice not support Bypass
318 * or it's a slave device)
319 **/
320 int get_std_nic_sd(int if_index);
321
322 /**
323 * set_tx - set transmitter enable/disable
324 * @if_index: network device index of the controlling device
325 * @tx_state: 0/1 (Transmit Disable / Transmit Enable)
326 *
327 * Output:
328 * 0 - on success
329 * -1 - on failure (device is not capable of the operation )
330 **/
331 int set_tx_sd(int if_index, int tx_state);
332
333 /**
334 * get_tx - get transmitter state (disable / enable)
335 * @if_index: network device index of the controlling device
336 *
337 * Output:
338 * 0/1 (ransmit Disable / Transmit Enable) on success
339 * -1 - on failure (device is not capable of the operation ordevice not support Bypass)
340 **/
341 int get_tx_sd(int if_index);
342
343 /**
344 * set_tpl - set TPL enable/disable
345 * @if_index: network device index of the controlling device
346 * @tx_state: 0/1 (TPL Disable / TPL Enable)
347 *
348 * Output:
349 * 0 - on success
350 * -1 - on failure (device is not capable of the operation )
351 **/
352 int set_tpl_sd(int if_index, int tpl_state);
353
354 /**
355 * get_tpl - get TPL state (disable / enable)
356 * @if_index: network device index of the controlling device
357 *
358 * Output:
359 * 0/1 (TPL Disable / TPL Enable) on success
360 * -1 - on failure (device is not capable of the operation)
361 **/
362 int get_tpl_sd(int if_index);
363
364 int get_bp_hw_reset_sd(int if_index);
365
366 int set_bp_hw_reset_sd(int if_index, int status);
367
368 /**
369 * set_tap - set TAP state
370 * @if_index: network device index of the controlling device
371 * @tap_mode: 1 tap mode , 0 normal nic mode
372 * Output:
373 * 0 - on success
374 * -1 - on failure (device not support TAP or it's a slave device)
375 **/
376 int set_tap_sd(int if_index, int tap_mode);
377
378 /**
379 * get_tap - Get TAP mode state
380 * @if_index: network device index of the controlling device
381 * Output:
382 * 0/1 - (off/on) on success
383 * -1 - on failure (device not support TAP or it's a slave device)
384 **/
385 int get_tap_sd(int if_index);
386
387 /**
388 * get_tap_change - Get change of TAP mode state from last status check
389 * @if_index: network device index of the controlling device
390 * Output:
391 * 0/1 - (off/on) on success
392 * -1 - on failure (device not support TAP or it's a slave device)
393 **/
394 int get_tap_change_sd(int if_index);
395
396 /**
397 * set_dis_tap - Set Disable TAP mode
398 * @if_index: network device index of the controlling device
399 * @dis_tap: disable tap(1=dis, 0=en)
400 * Output:
401 * 0 - on success
402 * -1 - on failure (device is not capable of the operation ordevice not support TAP
403 * or it's a slave device)
404 **/
405 int set_dis_tap_sd(int if_index, int dis_tap);
406
407 /**
408 * get_dis_tap - Get Disable TAP mode state
409 * @if_index: network device index of the controlling device
410 * Output:
411 * 0/1 - on success (normal TAP mode/ Disable TAP)
412 * -1 - on failure (device is not capable of the operation ordevice not support TAP
413 * or it's a slave device)
414 **/
415 int get_dis_tap_sd(int if_index);
416
417 /**
418 * set_tap_pwup - Set TAP mode at power-up state
419 * @if_index: network device index of the controlling device
420 * @bypass_mode: tap mode setting at power up state (1=TAP en, 0=TAP Dis)
421 * Output:
422 * 0 - on success
423 * -1 - on failure (device is not capable of the operation ordevice not support TAP
424 * or it's a slave device)
425 **/
426 int set_tap_pwup_sd(int if_index, int tap_mode);
427
428 /**
429 * get_tap_pwup - Get TAP mode state at power-up state
430 * @if_index: network device index of the controlling device
431 * Output:
432 * 0/1 - on success (Disable TAP at power up state / normal TAP mode)
433 * -1 - on failure (device is not capable of the operation ordevice not support TAP
434 * or it's a slave device)
435 **/
436 int get_tap_pwup_sd(int if_index);
437
438 /**
439 * set_wd_exp_mode - Set adapter state when WDT expired.
440 * @if_index: network device index of the controlling device
441 * @bypass_mode: adapter mode (1=tap mode, 0=bypass mode)
442 * Output:
443 * 0 - on success
444 * -1 - on failure (device not support Bypass or it's a slave device)
445 **/
446 int set_wd_exp_mode_sd(int if_index, int bypass_mode);
447
448 /**
449 * get_wd_exp_mode - Get adapter state when WDT expired.
450 * @if_index: network device index of the controlling device
451 * Output:
452 * 0/1 - (bypass/tap) on success
453 * -1 - on failure (device not support Bypass or it's a slave device)
454 **/
455 int get_wd_exp_mode_sd(int if_index);
456
457 /**
458 * set_wd_autoreset - reset WDT periodically.
459 * @if_index: network device index of the controlling device
460 * @bypass_mode: adapter mode (1=tap mode, 0=bypass mode)
461 * Output:
462 * 1 - on success
463 * -1 - on failure (device is not capable of the operation ordevice not support Bypass
464 * or it's a slave device or unknown wdt status)
465 **/
466 int set_wd_autoreset_sd(int if_index, int time);
467
468 /**
469 * set_wd_autoreset - reset WDT periodically.
470 * @if_index: network device index of the controlling device
471 * @bypass_mode: adapter mode (1=tap mode, 0=bypass mode)
472 * Output:
473 * 1 - on success
474 * -1 - on failure (device is not capable of the operation ordevice not support Bypass
475 * or it's a slave device or unknown wdt status)
476 **/
477 int get_wd_autoreset_sd(int if_index);
478 /**
479 * set_disc - set DISC state
480 * @if_index: network device index of the controlling device
481 * @tap_mode: 1 DISC mode , 0 normal nic mode
482 * Output:
483 * 0 - on success
484 * -1 - on failure (device not support disconnect or it's a slave device)
485 **/
486 int set_bp_disc_sd(int if_index, int disc_mode);
487
488 /**
489 * get_disc - Get disc mode state
490 * @if_index: network device index of the controlling device
491 * Output:
492 * 0/1 - (off/on) on success
493 * -1 - on failure (device not support disconnect or it's a slave device)
494 **/
495 int get_bp_disc_sd(int if_index);
496
497 /**
498 * get_disc_change - Get change of DISC mode state from last status check
499 * @if_index: network device index of the controlling device
500 * Output:
501 * 0/1 - (off/on) on success
502 * -1 - on failure (device not support disconnect or it's a slave device)
503 **/
504 int get_bp_disc_change_sd(int if_index);
505
506 /**
507 * set_dis_disc - Set Disable DISC mode
508 * @if_index: network device index of the controlling device
509 * @dis_disc: disable disconnect(1=dis, 0=en)
510 * Output:
511 * 0 - on success
512 * -1 - on failure (device is not capable of the operation ordevice not support DISC
513 * or it's a slave device)
514 **/
515 int set_bp_dis_disc_sd(int if_index, int dis_disc);
516
517 /**
518 * get_dis_disc - Get Disable DISC mode state
519 * @if_index: network device index of the controlling device
520 * Output:
521 * 0/1 - on success (normal DISC mode/ Disable DISC)
522 * -1 - on failure (device is not capable of the operation ordevice not support TAP
523 * or it's a slave device)
524 **/
525 int get_bp_dis_disc_sd(int if_index);
526
527 /**
528 * set_disc_pwup - Set DISC mode at power-up state
529 * @if_index: network device index of the controlling device
530 * @disc_mode: DISC mode setting at power up state (1= en, 0= Dis)
531 * Output:
532 * 0 - on success
533 * -1 - on failure (device is not capable of the operation ordevice not support DISC
534 * or it's a slave device)
535 **/
536 int set_bp_disc_pwup_sd(int if_index, int disc_mode);
537
538 /**
539 * get_disc_pwup - Get DISC mode state at power-up state
540 * @if_index: network device index of the controlling device
541 * Output:
542 * 0/1 - on success (Disable DISC at power up state / normal DISC mode)
543 * -1 - on failure (device is not capable of the operation ordevice not support DISC
544 * or it's a slave device)
545 **/
546 int get_bp_disc_pwup_sd(int if_index);
547
548 int get_bypass_info_sd(int if_index, struct bp_info *bp_info);
549 int bp_if_scan_sd(void);
550 /*int get_dev_num_sd(void);*/
This page took 0.041683 seconds and 5 git commands to generate.