This source file includes following definitions.
- readq
- writeq
- csio_list_deleted
- csio_set_state
- csio_init_state
- csio_post_event
- csio_get_state
- csio_match_state
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 #ifndef __CSIO_DEFS_H__
36 #define __CSIO_DEFS_H__
37
38 #include <linux/kernel.h>
39 #include <linux/stddef.h>
40 #include <linux/timer.h>
41 #include <linux/list.h>
42 #include <linux/bug.h>
43 #include <linux/pci.h>
44 #include <linux/jiffies.h>
45
46 #define CSIO_INVALID_IDX 0xFFFFFFFF
47 #define CSIO_INC_STATS(elem, val) ((elem)->stats.val++)
48 #define CSIO_DEC_STATS(elem, val) ((elem)->stats.val--)
49 #define CSIO_VALID_WWN(__n) ((*__n >> 4) == 0x5 ? true : false)
50 #define CSIO_DID_MASK 0xFFFFFF
51 #define CSIO_WORD_TO_BYTE 4
52
53 #ifndef readq
54 static inline u64 readq(void __iomem *addr)
55 {
56 return readl(addr) + ((u64)readl(addr + 4) << 32);
57 }
58
59 static inline void writeq(u64 val, void __iomem *addr)
60 {
61 writel(val, addr);
62 writel(val >> 32, addr + 4);
63 }
64 #endif
65
66 static inline int
67 csio_list_deleted(struct list_head *list)
68 {
69 return ((list->next == list) && (list->prev == list));
70 }
71
72 #define csio_list_next(elem) (((struct list_head *)(elem))->next)
73 #define csio_list_prev(elem) (((struct list_head *)(elem))->prev)
74
75
76 typedef void (*csio_sm_state_t)(void *, uint32_t);
77
78 struct csio_sm {
79 struct list_head sm_list;
80 csio_sm_state_t sm_state;
81 };
82
83 static inline void
84 csio_set_state(void *smp, void *state)
85 {
86 ((struct csio_sm *)smp)->sm_state = (csio_sm_state_t)state;
87 }
88
89 static inline void
90 csio_init_state(struct csio_sm *smp, void *state)
91 {
92 csio_set_state(smp, state);
93 }
94
95 static inline void
96 csio_post_event(void *smp, uint32_t evt)
97 {
98 ((struct csio_sm *)smp)->sm_state(smp, evt);
99 }
100
101 static inline csio_sm_state_t
102 csio_get_state(void *smp)
103 {
104 return ((struct csio_sm *)smp)->sm_state;
105 }
106
107 static inline bool
108 csio_match_state(void *smp, void *state)
109 {
110 return (csio_get_state(smp) == (csio_sm_state_t)state);
111 }
112
113 #define CSIO_ASSERT(cond) BUG_ON(!(cond))
114
115 #ifdef __CSIO_DEBUG__
116 #define CSIO_DB_ASSERT(__c) CSIO_ASSERT((__c))
117 #else
118 #define CSIO_DB_ASSERT(__c)
119 #endif
120
121 #endif