b42aafddae999f07d3af23969e2d177309241372
[cascardo/linux.git] / drivers / net / ethernet / brocade / bna / cna.h
1 /*
2  * Linux network driver for QLogic BR-series Converged Network Adapter.
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License (GPL) Version 2 as
6  * published by the Free Software Foundation
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * General Public License for more details.
12  */
13 /*
14  * Copyright (c) 2006-2014 Brocade Communications Systems, Inc.
15  * Copyright (c) 2014-2015 QLogic Corporation
16  * All rights reserved
17  * www.qlogic.com
18  */
19
20 #ifndef __CNA_H__
21 #define __CNA_H__
22
23 #include <linux/kernel.h>
24 #include <linux/types.h>
25 #include <linux/mutex.h>
26 #include <linux/pci.h>
27 #include <linux/delay.h>
28 #include <linux/bitops.h>
29 #include <linux/timer.h>
30 #include <linux/interrupt.h>
31 #include <linux/if_vlan.h>
32 #include <linux/if_ether.h>
33
34 #define bfa_sm_fault(__event)    do {                            \
35         pr_err("SM Assertion failure: %s: %d: event = %d\n",    \
36                  __FILE__, __LINE__, __event);                  \
37 } while (0)
38
39 extern char bfa_version[];
40
41 #define CNA_FW_FILE_CT  "ctfw-3.2.5.1.bin"
42 #define CNA_FW_FILE_CT2 "ct2fw-3.2.5.1.bin"
43 #define FC_SYMNAME_MAX  256     /*!< max name server symbolic name size */
44
45 #define bfa_q_first(_q) ((void *)(((struct list_head *) (_q))->next))
46 #define bfa_q_next(_qe) (((struct list_head *) (_qe))->next)
47 #define bfa_q_prev(_qe) (((struct list_head *) (_qe))->prev)
48
49 /*
50  * bfa_q_qe_init - to initialize a queue element
51  */
52 #define bfa_q_qe_init(_qe) {                                            \
53         bfa_q_next(_qe) = (struct list_head *) NULL;                    \
54         bfa_q_prev(_qe) = (struct list_head *) NULL;                    \
55 }
56
57 /*
58  * bfa_q_deq - dequeue an element from head of the queue
59  */
60 #define bfa_q_deq(_q, _qe) {                                            \
61         if (!list_empty(_q)) {                                          \
62                 (*((struct list_head **) (_qe))) = bfa_q_next(_q);      \
63                 bfa_q_prev(bfa_q_next(*((struct list_head **) _qe))) =  \
64                                                 (struct list_head *) (_q); \
65                 bfa_q_next(_q) = bfa_q_next(*((struct list_head **) _qe)); \
66                 bfa_q_qe_init(*((struct list_head **) _qe));            \
67         } else {                                                        \
68                 *((struct list_head **)(_qe)) = NULL;                   \
69         }                                                               \
70 }
71
72 /*
73  * bfa_q_deq_tail - dequeue an element from tail of the queue
74  */
75 #define bfa_q_deq_tail(_q, _qe) {                                       \
76         if (!list_empty(_q)) {                                          \
77                 *((struct list_head **) (_qe)) = bfa_q_prev(_q);        \
78                 bfa_q_next(bfa_q_prev(*((struct list_head **) _qe))) =  \
79                                                 (struct list_head *) (_q); \
80                 bfa_q_prev(_q) = bfa_q_prev(*(struct list_head **) _qe);\
81                 bfa_q_qe_init(*((struct list_head **) _qe));            \
82         } else {                                                        \
83                 *((struct list_head **) (_qe)) = (struct list_head *) NULL; \
84         }                                                               \
85 }
86
87 /*
88  * bfa_add_tail_head - enqueue an element at the head of queue
89  */
90 #define bfa_q_enq_head(_q, _qe) {                                       \
91         if (!(bfa_q_next(_qe) == NULL) && (bfa_q_prev(_qe) == NULL))    \
92                 pr_err("Assertion failure: %s:%d: %d",                  \
93                         __FILE__, __LINE__,                             \
94                 (bfa_q_next(_qe) == NULL) && (bfa_q_prev(_qe) == NULL));\
95         bfa_q_next(_qe) = bfa_q_next(_q);                               \
96         bfa_q_prev(_qe) = (struct list_head *) (_q);                    \
97         bfa_q_prev(bfa_q_next(_q)) = (struct list_head *) (_qe);        \
98         bfa_q_next(_q) = (struct list_head *) (_qe);                    \
99 }
100
101 #endif /* __CNA_H__ */