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
36
37
38
39
40
41
42
43
44#ifndef EHCA_TOOLS_H
45#define EHCA_TOOLS_H
46
47#include <linux/kernel.h>
48#include <linux/spinlock.h>
49#include <linux/delay.h>
50#include <linux/idr.h>
51#include <linux/kthread.h>
52#include <linux/mm.h>
53#include <linux/mman.h>
54#include <linux/module.h>
55#include <linux/moduleparam.h>
56#include <linux/vmalloc.h>
57#include <linux/notifier.h>
58#include <linux/cpu.h>
59#include <linux/device.h>
60
61#include <asm/atomic.h>
62#include <asm/abs_addr.h>
63#include <asm/ibmebus.h>
64#include <asm/io.h>
65#include <asm/pgtable.h>
66#include <asm/hvcall.h>
67
68extern int ehca_debug_level;
69
70#define ehca_dbg(ib_dev, format, arg...) \
71 do { \
72 if (unlikely(ehca_debug_level)) \
73 dev_printk(KERN_DEBUG, (ib_dev)->dma_device, \
74 "PU%04x EHCA_DBG:%s " format "\n", \
75 raw_smp_processor_id(), __func__, \
76 ## arg); \
77 } while (0)
78
79#define ehca_info(ib_dev, format, arg...) \
80 dev_info((ib_dev)->dma_device, "PU%04x EHCA_INFO:%s " format "\n", \
81 raw_smp_processor_id(), __func__, ## arg)
82
83#define ehca_warn(ib_dev, format, arg...) \
84 dev_warn((ib_dev)->dma_device, "PU%04x EHCA_WARN:%s " format "\n", \
85 raw_smp_processor_id(), __func__, ## arg)
86
87#define ehca_err(ib_dev, format, arg...) \
88 dev_err((ib_dev)->dma_device, "PU%04x EHCA_ERR:%s " format "\n", \
89 raw_smp_processor_id(), __func__, ## arg)
90
91
92#define ehca_gen_dbg(format, arg...) \
93 do { \
94 if (unlikely(ehca_debug_level)) \
95 printk(KERN_DEBUG "PU%04x EHCA_DBG:%s " format "\n", \
96 raw_smp_processor_id(), __func__, ## arg); \
97 } while (0)
98
99#define ehca_gen_warn(format, arg...) \
100 printk(KERN_INFO "PU%04x EHCA_WARN:%s " format "\n", \
101 raw_smp_processor_id(), __func__, ## arg)
102
103#define ehca_gen_err(format, arg...) \
104 printk(KERN_ERR "PU%04x EHCA_ERR:%s " format "\n", \
105 raw_smp_processor_id(), __func__, ## arg)
106
107
108
109
110
111
112#define ehca_dmp(adr, len, format, args...) \
113 do { \
114 unsigned int x; \
115 unsigned int l = (unsigned int)(len); \
116 unsigned char *deb = (unsigned char *)(adr); \
117 for (x = 0; x < l; x += 16) { \
118 printk(KERN_INFO "EHCA_DMP:%s " format \
119 " adr=%p ofs=%04x %016llx %016llx\n", \
120 __func__, ##args, deb, x, \
121 *((u64 *)&deb[0]), *((u64 *)&deb[8])); \
122 deb += 16; \
123 } \
124 } while (0)
125
126
127#define EHCA_BMASK(pos, length) (((pos) << 16) + (length))
128
129
130#define EHCA_BMASK_IBM(from, to) (((63 - to) << 16) + ((to) - (from) + 1))
131
132
133#define EHCA_BMASK_SHIFTPOS(mask) (((mask) >> 16) & 0xffff)
134
135
136#define EHCA_BMASK_MASK(mask) (~0ULL >> ((64 - (mask)) & 0xffff))
137
138
139
140
141
142
143
144#define EHCA_BMASK_SET(mask, value) \
145 ((EHCA_BMASK_MASK(mask) & ((u64)(value))) << EHCA_BMASK_SHIFTPOS(mask))
146
147
148
149
150#define EHCA_BMASK_GET(mask, value) \
151 (EHCA_BMASK_MASK(mask) & (((u64)(value)) >> EHCA_BMASK_SHIFTPOS(mask)))
152
153
154int ehca2ib_return_code(u64 ehca_rc);
155
156#endif
157