drivers/net: remove useless semicolons
[safe/jmp/linux-2.6] / drivers / net / vxge / vxge-main.h
1 /******************************************************************************
2  * This software may be used and distributed according to the terms of
3  * the GNU General Public License (GPL), incorporated herein by reference.
4  * Drivers based on or derived from this code fall under the GPL and must
5  * retain the authorship, copyright and license notice.  This file is not
6  * a complete program and may only be used when the entire operating
7  * system is licensed under the GPL.
8  * See the file COPYING in this distribution for more information.
9  *
10  * vxge-main.h: Driver for Neterion Inc's X3100 Series 10GbE PCIe I/O
11  *              Virtualized Server Adapter.
12  * Copyright(c) 2002-2009 Neterion Inc.
13  ******************************************************************************/
14 #ifndef VXGE_MAIN_H
15 #define VXGE_MAIN_H
16
17 #include "vxge-traffic.h"
18 #include "vxge-config.h"
19 #include "vxge-version.h"
20 #include <linux/list.h>
21
22 #define VXGE_DRIVER_NAME                "vxge"
23 #define VXGE_DRIVER_VENDOR              "Neterion, Inc"
24 #define VXGE_DRIVER_FW_VERSION_MAJOR    1
25
26 #define DRV_VERSION     VXGE_VERSION_MAJOR"."VXGE_VERSION_MINOR"."\
27         VXGE_VERSION_FIX"."VXGE_VERSION_BUILD"-"\
28         VXGE_VERSION_FOR
29
30 #define PCI_DEVICE_ID_TITAN_WIN         0x5733
31 #define PCI_DEVICE_ID_TITAN_UNI         0x5833
32 #define VXGE_USE_DEFAULT                0xffffffff
33 #define VXGE_HW_VPATH_MSIX_ACTIVE       4
34 #define VXGE_ALARM_MSIX_ID              2
35 #define VXGE_HW_RXSYNC_FREQ_CNT         4
36 #define VXGE_LL_WATCH_DOG_TIMEOUT       (15 * HZ)
37 #define VXGE_LL_RX_COPY_THRESHOLD       256
38 #define VXGE_DEF_FIFO_LENGTH            84
39
40 #define NO_STEERING             0
41 #define PORT_STEERING           0x1
42 #define RTH_STEERING            0x2
43 #define RX_TOS_STEERING         0x3
44 #define RX_VLAN_STEERING        0x4
45 #define RTH_BUCKET_SIZE         4
46
47 #define TX_PRIORITY_STEERING    1
48 #define TX_VLAN_STEERING        2
49 #define TX_PORT_STEERING        3
50 #define TX_MULTIQ_STEERING      4
51
52 #define VXGE_HW_MAC_ADDR_LEARN_DEFAULT VXGE_HW_RTS_MAC_DISABLE
53
54 #define VXGE_TTI_BTIMER_VAL 250000
55
56 #define VXGE_TTI_LTIMER_VAL 1000
57 #define VXGE_TTI_RTIMER_VAL 0
58 #define VXGE_RTI_BTIMER_VAL 250
59 #define VXGE_RTI_LTIMER_VAL 100
60 #define VXGE_RTI_RTIMER_VAL 0
61 #define VXGE_FIFO_INDICATE_MAX_PKTS VXGE_DEF_FIFO_LENGTH
62 #define VXGE_ISR_POLLING_CNT    8
63 #define VXGE_MAX_CONFIG_DEV     0xFF
64 #define VXGE_EXEC_MODE_DISABLE  0
65 #define VXGE_EXEC_MODE_ENABLE   1
66 #define VXGE_MAX_CONFIG_PORT    1
67 #define VXGE_ALL_VID_DISABLE    0
68 #define VXGE_ALL_VID_ENABLE     1
69 #define VXGE_PAUSE_CTRL_DISABLE 0
70 #define VXGE_PAUSE_CTRL_ENABLE  1
71
72 #define TTI_TX_URANGE_A 5
73 #define TTI_TX_URANGE_B 15
74 #define TTI_TX_URANGE_C 40
75 #define TTI_TX_UFC_A    5
76 #define TTI_TX_UFC_B    40
77 #define TTI_TX_UFC_C    60
78 #define TTI_TX_UFC_D    100
79
80 #define RTI_RX_URANGE_A 5
81 #define RTI_RX_URANGE_B 15
82 #define RTI_RX_URANGE_C 40
83 #define RTI_RX_UFC_A    1
84 #define RTI_RX_UFC_B    5
85 #define RTI_RX_UFC_C    10
86 #define RTI_RX_UFC_D    15
87
88 /* Milli secs timer period */
89 #define VXGE_TIMER_DELAY                10000
90
91 #define VXGE_LL_MAX_FRAME_SIZE(dev) ((dev)->mtu + VXGE_HW_MAC_HEADER_MAX_SIZE)
92
93 #define is_sriov(function_mode) \
94         ((function_mode == VXGE_HW_FUNCTION_MODE_SRIOV) || \
95         (function_mode == VXGE_HW_FUNCTION_MODE_SRIOV_8) || \
96         (function_mode == VXGE_HW_FUNCTION_MODE_SRIOV_4))
97
98 enum vxge_reset_event {
99         /* reset events */
100         VXGE_LL_VPATH_RESET     = 0,
101         VXGE_LL_DEVICE_RESET    = 1,
102         VXGE_LL_FULL_RESET      = 2,
103         VXGE_LL_START_RESET     = 3,
104         VXGE_LL_COMPL_RESET     = 4
105 };
106 /* These flags represent the devices temporary state */
107 enum vxge_device_state_t {
108 __VXGE_STATE_RESET_CARD = 0,
109 __VXGE_STATE_CARD_UP
110 };
111
112 enum vxge_mac_addr_state {
113         /* mac address states */
114         VXGE_LL_MAC_ADDR_IN_LIST        = 0,
115         VXGE_LL_MAC_ADDR_IN_DA_TABLE    = 1
116 };
117
118 struct vxge_drv_config {
119         int config_dev_cnt;
120         int total_dev_cnt;
121         int g_no_cpus;
122         unsigned int vpath_per_dev;
123 };
124
125 struct macInfo {
126         unsigned char macaddr[ETH_ALEN];
127         unsigned char macmask[ETH_ALEN];
128         unsigned int vpath_no;
129         enum vxge_mac_addr_state state;
130 };
131
132 struct vxge_config {
133         int             tx_pause_enable;
134         int             rx_pause_enable;
135
136 #define NEW_NAPI_WEIGHT 64
137         int             napi_weight;
138 #define VXGE_GRO_DONOT_AGGREGATE                0
139 #define VXGE_GRO_ALWAYS_AGGREGATE               1
140         int             gro_enable;
141         int             intr_type;
142 #define INTA    0
143 #define MSI     1
144 #define MSI_X   2
145
146         int             addr_learn_en;
147
148         int             rth_steering;
149         int             rth_algorithm;
150         int             rth_hash_type_tcpipv4;
151         int             rth_hash_type_ipv4;
152         int             rth_hash_type_tcpipv6;
153         int             rth_hash_type_ipv6;
154         int             rth_hash_type_tcpipv6ex;
155         int             rth_hash_type_ipv6ex;
156         int             rth_bkt_sz;
157         int             rth_jhash_golden_ratio;
158         int             tx_steering_type;
159         int     fifo_indicate_max_pkts;
160         struct vxge_hw_device_hw_info device_hw_info;
161 };
162
163 struct vxge_msix_entry {
164         /* Mimicing the msix_entry struct of Kernel. */
165         u16 vector;
166         u16 entry;
167         u16 in_use;
168         void *arg;
169 };
170
171 /* Software Statistics */
172
173 struct vxge_sw_stats {
174         /* Network Stats (interface stats) */
175         struct net_device_stats net_stats;
176
177         /* Tx */
178         u64 tx_frms;
179         u64 tx_errors;
180         u64 tx_bytes;
181         u64 txd_not_free;
182         u64 txd_out_of_desc;
183
184         /* Virtual Path */
185         u64 vpaths_open;
186         u64 vpath_open_fail;
187
188         /* Rx */
189         u64 rx_frms;
190         u64 rx_errors;
191         u64 rx_bytes;
192         u64 rx_mcast;
193
194         /* Misc. */
195         u64 link_up;
196         u64 link_down;
197         u64 pci_map_fail;
198         u64 skb_alloc_fail;
199 };
200
201 struct vxge_mac_addrs {
202         struct list_head item;
203         u64 macaddr;
204         u64 macmask;
205         enum vxge_mac_addr_state state;
206 };
207
208 struct vxgedev;
209
210 struct vxge_fifo_stats {
211         u64 tx_frms;
212         u64 tx_errors;
213         u64 tx_bytes;
214         u64 txd_not_free;
215         u64 txd_out_of_desc;
216         u64 pci_map_fail;
217 };
218
219 struct vxge_fifo {
220         struct net_device       *ndev;
221         struct pci_dev          *pdev;
222         struct __vxge_hw_fifo *handle;
223
224         /* The vpath id maintained in the driver -
225          * 0 to 'maximum_vpaths_in_function - 1'
226          */
227         int driver_id;
228         int tx_steering_type;
229         int indicate_max_pkts;
230         spinlock_t tx_lock;
231         /* flag used to maintain queue state when MULTIQ is not enabled */
232 #define VPATH_QUEUE_START       0
233 #define VPATH_QUEUE_STOP        1
234         int queue_state;
235
236         /* Tx stats */
237         struct vxge_fifo_stats stats;
238 } ____cacheline_aligned;
239
240 struct vxge_ring_stats {
241         u64 prev_rx_frms;
242         u64 rx_frms;
243         u64 rx_errors;
244         u64 rx_dropped;
245         u64 rx_bytes;
246         u64 rx_mcast;
247         u64 pci_map_fail;
248         u64 skb_alloc_fail;
249 };
250
251 struct vxge_ring {
252         struct net_device       *ndev;
253         struct pci_dev          *pdev;
254         struct __vxge_hw_ring   *handle;
255         /* The vpath id maintained in the driver -
256          * 0 to 'maximum_vpaths_in_function - 1'
257          */
258         int driver_id;
259
260          /* copy of the flag indicating whether rx_csum is to be used */
261         u32 rx_csum;
262
263         int pkts_processed;
264         int budget;
265         int gro_enable;
266
267         struct napi_struct napi;
268         struct napi_struct *napi_p;
269
270 #define VXGE_MAX_MAC_ADDR_COUNT         30
271
272         int vlan_tag_strip;
273         struct vlan_group *vlgrp;
274         int rx_vector_no;
275         enum vxge_hw_status last_status;
276
277         /* Rx stats */
278         struct vxge_ring_stats stats;
279 } ____cacheline_aligned;
280
281 struct vxge_vpath {
282
283         struct vxge_fifo fifo;
284         struct vxge_ring ring;
285
286         struct __vxge_hw_vpath_handle *handle;
287
288         /* Actual vpath id for this vpath in the device - 0 to 16 */
289         int device_id;
290         int max_mac_addr_cnt;
291         int is_configured;
292         int is_open;
293         struct vxgedev *vdev;
294         u8 (macaddr)[ETH_ALEN];
295         u8 (macmask)[ETH_ALEN];
296
297 #define VXGE_MAX_LEARN_MAC_ADDR_CNT     2048
298         /* mac addresses currently programmed into NIC */
299         u16 mac_addr_cnt;
300         u16 mcast_addr_cnt;
301         struct list_head mac_addr_list;
302
303         u32 level_err;
304         u32 level_trace;
305 };
306 #define VXGE_COPY_DEBUG_INFO_TO_LL(vdev, err, trace) {  \
307         for (i = 0; i < vdev->no_of_vpath; i++) {               \
308                 vdev->vpaths[i].level_err = err;                \
309                 vdev->vpaths[i].level_trace = trace;            \
310         }                                                       \
311         vdev->level_err = err;                                  \
312         vdev->level_trace = trace;                              \
313 }
314
315 struct vxgedev {
316         struct net_device       *ndev;
317         struct pci_dev          *pdev;
318         struct __vxge_hw_device *devh;
319         struct vlan_group       *vlgrp;
320         int vlan_tag_strip;
321         struct vxge_config      config;
322         unsigned long   state;
323
324         /* Indicates which vpath to reset */
325         unsigned long  vp_reset;
326
327         /* Timer used for polling vpath resets */
328         struct timer_list vp_reset_timer;
329
330         /* Timer used for polling vpath lockup */
331         struct timer_list vp_lockup_timer;
332
333         /*
334          * Flags to track whether device is in All Multicast
335          * or in promiscuous mode.
336          */
337         u16             all_multi_flg;
338
339          /* A flag indicating whether rx_csum is to be used or not. */
340         u32     rx_csum;
341
342         struct vxge_msix_entry *vxge_entries;
343         struct msix_entry *entries;
344         /*
345          * 4 for each vpath * 17;
346          * total is 68
347          */
348 #define VXGE_MAX_REQUESTED_MSIX 68
349 #define VXGE_INTR_STRLEN 80
350         char desc[VXGE_MAX_REQUESTED_MSIX][VXGE_INTR_STRLEN];
351
352         enum vxge_hw_event cric_err_event;
353
354         int max_vpath_supported;
355         int no_of_vpath;
356
357         struct napi_struct napi;
358         /* A debug option, when enabled and if error condition occurs,
359          * the driver will do following steps:
360          * - mask all interrupts
361          * - Not clear the source of the alarm
362          * - gracefully stop all I/O
363          * A diagnostic dump of register and stats at this point
364          * reveals very useful information.
365          */
366         int exec_mode;
367         int max_config_port;
368         struct vxge_vpath       *vpaths;
369
370         struct __vxge_hw_vpath_handle *vp_handles[VXGE_HW_MAX_VIRTUAL_PATHS];
371         void __iomem *bar0;
372         struct vxge_sw_stats    stats;
373         int             mtu;
374         /* Below variables are used for vpath selection to transmit a packet */
375         u8              vpath_selector[VXGE_HW_MAX_VIRTUAL_PATHS];
376         u64             vpaths_deployed;
377
378         u32             intr_cnt;
379         u32             level_err;
380         u32             level_trace;
381         char            fw_version[VXGE_HW_FW_STRLEN];
382 };
383
384 struct vxge_rx_priv {
385         struct sk_buff          *skb;
386         unsigned char           *skb_data;
387         dma_addr_t              data_dma;
388         dma_addr_t              data_size;
389 };
390
391 struct vxge_tx_priv {
392         struct sk_buff          *skb;
393         dma_addr_t              dma_buffers[MAX_SKB_FRAGS+1];
394 };
395
396 #define VXGE_MODULE_PARAM_INT(p, val) \
397         static int p = val; \
398         module_param(p, int, 0)
399
400 #define vxge_os_bug(fmt...)             { printk(fmt); BUG(); }
401
402 #define vxge_os_timer(timer, handle, arg, exp) do { \
403                 init_timer(&timer); \
404                 timer.function = handle; \
405                 timer.data = (unsigned long) arg; \
406                 mod_timer(&timer, (jiffies + exp)); \
407         } while (0);
408
409 int __devinit vxge_device_register(struct __vxge_hw_device *devh,
410                                     struct vxge_config *config,
411                                     int high_dma, int no_of_vpath,
412                                     struct vxgedev **vdev);
413
414 void vxge_device_unregister(struct __vxge_hw_device *devh);
415
416 void vxge_vpath_intr_enable(struct vxgedev *vdev, int vp_id);
417
418 void vxge_vpath_intr_disable(struct vxgedev *vdev, int vp_id);
419
420 void vxge_callback_link_up(struct __vxge_hw_device *devh);
421
422 void vxge_callback_link_down(struct __vxge_hw_device *devh);
423
424 enum vxge_hw_status vxge_add_mac_addr(struct vxgedev *vdev,
425         struct macInfo *mac);
426
427 int vxge_mac_list_del(struct vxge_vpath *vpath, struct macInfo *mac);
428
429 int vxge_reset(struct vxgedev *vdev);
430
431 enum vxge_hw_status
432 vxge_rx_1b_compl(struct __vxge_hw_ring *ringh, void *dtr,
433         u8 t_code, void *userdata);
434
435 enum vxge_hw_status
436 vxge_xmit_compl(struct __vxge_hw_fifo *fifo_hw, void *dtr,
437         enum vxge_hw_fifo_tcode t_code, void *userdata,
438         struct sk_buff ***skb_ptr, int nr_skbs, int *more);
439
440 int vxge_close(struct net_device *dev);
441
442 int vxge_open(struct net_device *dev);
443
444 void vxge_close_vpaths(struct vxgedev *vdev, int index);
445
446 int vxge_open_vpaths(struct vxgedev *vdev);
447
448 enum vxge_hw_status vxge_reset_all_vpaths(struct vxgedev *vdev);
449
450 void vxge_stop_all_tx_queue(struct vxgedev *vdev);
451
452 void vxge_stop_tx_queue(struct vxge_fifo *fifo);
453
454 void vxge_start_all_tx_queue(struct vxgedev *vdev);
455
456 void vxge_wake_tx_queue(struct vxge_fifo *fifo, struct sk_buff *skb);
457
458 enum vxge_hw_status vxge_add_mac_addr(struct vxgedev *vdev,
459         struct macInfo *mac);
460
461 enum vxge_hw_status vxge_del_mac_addr(struct vxgedev *vdev,
462         struct macInfo *mac);
463
464 int vxge_mac_list_add(struct vxge_vpath *vpath,
465         struct macInfo *mac);
466
467 void vxge_free_mac_add_list(struct vxge_vpath *vpath);
468
469 enum vxge_hw_status vxge_restore_vpath_mac_addr(struct vxge_vpath *vpath);
470
471 enum vxge_hw_status vxge_restore_vpath_vid_table(struct vxge_vpath *vpath);
472
473 int do_vxge_close(struct net_device *dev, int do_io);
474 extern void initialize_ethtool_ops(struct net_device *ndev);
475 /**
476  * #define VXGE_DEBUG_INIT: debug for initialization functions
477  * #define VXGE_DEBUG_TX         : debug transmit related functions
478  * #define VXGE_DEBUG_RX  : debug recevice related functions
479  * #define VXGE_DEBUG_MEM : debug memory module
480  * #define VXGE_DEBUG_LOCK: debug locks
481  * #define VXGE_DEBUG_SEM : debug semaphore
482  * #define VXGE_DEBUG_ENTRYEXIT: debug functions by adding entry exit statements
483 */
484 #define VXGE_DEBUG_INIT         0x00000001
485 #define VXGE_DEBUG_TX           0x00000002
486 #define VXGE_DEBUG_RX           0x00000004
487 #define VXGE_DEBUG_MEM          0x00000008
488 #define VXGE_DEBUG_LOCK         0x00000010
489 #define VXGE_DEBUG_SEM          0x00000020
490 #define VXGE_DEBUG_ENTRYEXIT    0x00000040
491 #define VXGE_DEBUG_INTR         0x00000080
492 #define VXGE_DEBUG_LL_CONFIG    0x00000100
493
494 /* Debug tracing for VXGE driver */
495 #ifndef VXGE_DEBUG_MASK
496 #define VXGE_DEBUG_MASK 0x0
497 #endif
498
499 #if (VXGE_DEBUG_LL_CONFIG & VXGE_DEBUG_MASK)
500 #define vxge_debug_ll_config(level, fmt, ...) \
501         vxge_debug_ll(level, VXGE_DEBUG_LL_CONFIG, fmt, __VA_ARGS__)
502 #else
503 #define vxge_debug_ll_config(level, fmt, ...)
504 #endif
505
506 #if (VXGE_DEBUG_INIT & VXGE_DEBUG_MASK)
507 #define vxge_debug_init(level, fmt, ...) \
508         vxge_debug_ll(level, VXGE_DEBUG_INIT, fmt, __VA_ARGS__)
509 #else
510 #define vxge_debug_init(level, fmt, ...)
511 #endif
512
513 #if (VXGE_DEBUG_TX & VXGE_DEBUG_MASK)
514 #define vxge_debug_tx(level, fmt, ...) \
515         vxge_debug_ll(level, VXGE_DEBUG_TX, fmt, __VA_ARGS__)
516 #else
517 #define vxge_debug_tx(level, fmt, ...)
518 #endif
519
520 #if (VXGE_DEBUG_RX & VXGE_DEBUG_MASK)
521 #define vxge_debug_rx(level, fmt, ...) \
522         vxge_debug_ll(level, VXGE_DEBUG_RX, fmt, __VA_ARGS__)
523 #else
524 #define vxge_debug_rx(level, fmt, ...)
525 #endif
526
527 #if (VXGE_DEBUG_MEM & VXGE_DEBUG_MASK)
528 #define vxge_debug_mem(level, fmt, ...) \
529         vxge_debug_ll(level, VXGE_DEBUG_MEM, fmt, __VA_ARGS__)
530 #else
531 #define vxge_debug_mem(level, fmt, ...)
532 #endif
533
534 #if (VXGE_DEBUG_ENTRYEXIT & VXGE_DEBUG_MASK)
535 #define vxge_debug_entryexit(level, fmt, ...) \
536         vxge_debug_ll(level, VXGE_DEBUG_ENTRYEXIT, fmt, __VA_ARGS__)
537 #else
538 #define vxge_debug_entryexit(level, fmt, ...)
539 #endif
540
541 #if (VXGE_DEBUG_INTR & VXGE_DEBUG_MASK)
542 #define vxge_debug_intr(level, fmt, ...) \
543         vxge_debug_ll(level, VXGE_DEBUG_INTR, fmt, __VA_ARGS__)
544 #else
545 #define vxge_debug_intr(level, fmt, ...)
546 #endif
547
548 #define VXGE_DEVICE_DEBUG_LEVEL_SET(level, mask, vdev) {\
549         vxge_hw_device_debug_set((struct __vxge_hw_device  *)vdev->devh, \
550                 level, mask);\
551         VXGE_COPY_DEBUG_INFO_TO_LL(vdev, \
552                 vxge_hw_device_error_level_get((struct __vxge_hw_device  *) \
553                         vdev->devh), \
554                 vxge_hw_device_trace_level_get((struct __vxge_hw_device  *) \
555                         vdev->devh));\
556 }
557
558 #ifdef NETIF_F_GSO
559 #define vxge_tcp_mss(skb) (skb_shinfo(skb)->gso_size)
560 #define vxge_udp_mss(skb) (skb_shinfo(skb)->gso_size)
561 #define vxge_offload_type(skb) (skb_shinfo(skb)->gso_type)
562 #endif
563
564 #endif