diff options
Diffstat (limited to 'drivers/misc/sgi-xp/xp.h')
-rw-r--r-- | drivers/misc/sgi-xp/xp.h | 225 |
1 files changed, 98 insertions, 127 deletions
diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h index 03a87a307e32..859a5281c61b 100644 --- a/drivers/misc/sgi-xp/xp.h +++ b/drivers/misc/sgi-xp/xp.h | |||
@@ -13,11 +13,34 @@ | |||
13 | #ifndef _DRIVERS_MISC_SGIXP_XP_H | 13 | #ifndef _DRIVERS_MISC_SGIXP_XP_H |
14 | #define _DRIVERS_MISC_SGIXP_XP_H | 14 | #define _DRIVERS_MISC_SGIXP_XP_H |
15 | 15 | ||
16 | #include <linux/cache.h> | ||
17 | #include <linux/hardirq.h> | ||
18 | #include <linux/mutex.h> | 16 | #include <linux/mutex.h> |
19 | #include <asm/sn/types.h> | 17 | |
20 | #include <asm/sn/bte.h> | 18 | #ifdef CONFIG_IA64 |
19 | #include <asm/system.h> | ||
20 | #include <asm/sn/arch.h> /* defines is_shub1() and is_shub2() */ | ||
21 | #define is_shub() ia64_platform_is("sn2") | ||
22 | #define is_uv() ia64_platform_is("uv") | ||
23 | #endif | ||
24 | #ifdef CONFIG_X86_64 | ||
25 | #include <asm/genapic.h> | ||
26 | #define is_uv() is_uv_system() | ||
27 | #endif | ||
28 | |||
29 | #ifndef is_shub1 | ||
30 | #define is_shub1() 0 | ||
31 | #endif | ||
32 | |||
33 | #ifndef is_shub2 | ||
34 | #define is_shub2() 0 | ||
35 | #endif | ||
36 | |||
37 | #ifndef is_shub | ||
38 | #define is_shub() 0 | ||
39 | #endif | ||
40 | |||
41 | #ifndef is_uv | ||
42 | #define is_uv() 0 | ||
43 | #endif | ||
21 | 44 | ||
22 | #ifdef USE_DBUG_ON | 45 | #ifdef USE_DBUG_ON |
23 | #define DBUG_ON(condition) BUG_ON(condition) | 46 | #define DBUG_ON(condition) BUG_ON(condition) |
@@ -26,133 +49,56 @@ | |||
26 | #endif | 49 | #endif |
27 | 50 | ||
28 | /* | 51 | /* |
29 | * Define the maximum number of logically defined partitions the system | 52 | * Define the maximum number of partitions the system can possibly support. |
30 | * can support. It is constrained by the maximum number of hardware | 53 | * It is based on the maximum number of hardware partitionable regions. The |
31 | * partitionable regions. The term 'region' in this context refers to the | 54 | * term 'region' in this context refers to the minimum number of nodes that |
32 | * minimum number of nodes that can comprise an access protection grouping. | 55 | * can comprise an access protection grouping. The access protection is in |
33 | * The access protection is in regards to memory, IPI and IOI. | 56 | * regards to memory, IPI and IOI. |
34 | * | 57 | * |
35 | * The maximum number of hardware partitionable regions is equal to the | 58 | * The maximum number of hardware partitionable regions is equal to the |
36 | * maximum number of nodes in the entire system divided by the minimum number | 59 | * maximum number of nodes in the entire system divided by the minimum number |
37 | * of nodes that comprise an access protection grouping. | 60 | * of nodes that comprise an access protection grouping. |
38 | */ | 61 | */ |
39 | #define XP_MAX_PARTITIONS 64 | 62 | #define XP_MAX_NPARTITIONS_SN2 64 |
40 | 63 | #define XP_MAX_NPARTITIONS_UV 256 | |
41 | /* | ||
42 | * Define the number of u64s required to represent all the C-brick nasids | ||
43 | * as a bitmap. The cross-partition kernel modules deal only with | ||
44 | * C-brick nasids, thus the need for bitmaps which don't account for | ||
45 | * odd-numbered (non C-brick) nasids. | ||
46 | */ | ||
47 | #define XP_MAX_PHYSNODE_ID (MAX_NUMALINK_NODES / 2) | ||
48 | #define XP_NASID_MASK_BYTES ((XP_MAX_PHYSNODE_ID + 7) / 8) | ||
49 | #define XP_NASID_MASK_WORDS ((XP_MAX_PHYSNODE_ID + 63) / 64) | ||
50 | |||
51 | /* | ||
52 | * Wrapper for bte_copy() that should it return a failure status will retry | ||
53 | * the bte_copy() once in the hope that the failure was due to a temporary | ||
54 | * aberration (i.e., the link going down temporarily). | ||
55 | * | ||
56 | * src - physical address of the source of the transfer. | ||
57 | * vdst - virtual address of the destination of the transfer. | ||
58 | * len - number of bytes to transfer from source to destination. | ||
59 | * mode - see bte_copy() for definition. | ||
60 | * notification - see bte_copy() for definition. | ||
61 | * | ||
62 | * Note: xp_bte_copy() should never be called while holding a spinlock. | ||
63 | */ | ||
64 | static inline bte_result_t | ||
65 | xp_bte_copy(u64 src, u64 vdst, u64 len, u64 mode, void *notification) | ||
66 | { | ||
67 | bte_result_t ret; | ||
68 | u64 pdst = ia64_tpa(vdst); | ||
69 | |||
70 | /* | ||
71 | * Ensure that the physically mapped memory is contiguous. | ||
72 | * | ||
73 | * We do this by ensuring that the memory is from region 7 only. | ||
74 | * If the need should arise to use memory from one of the other | ||
75 | * regions, then modify the BUG_ON() statement to ensure that the | ||
76 | * memory from that region is always physically contiguous. | ||
77 | */ | ||
78 | BUG_ON(REGION_NUMBER(vdst) != RGN_KERNEL); | ||
79 | |||
80 | ret = bte_copy(src, pdst, len, mode, notification); | ||
81 | if ((ret != BTE_SUCCESS) && BTE_ERROR_RETRY(ret)) { | ||
82 | if (!in_interrupt()) | ||
83 | cond_resched(); | ||
84 | |||
85 | ret = bte_copy(src, pdst, len, mode, notification); | ||
86 | } | ||
87 | |||
88 | return ret; | ||
89 | } | ||
90 | 64 | ||
91 | /* | 65 | /* |
92 | * XPC establishes channel connections between the local partition and any | 66 | * XPC establishes channel connections between the local partition and any |
93 | * other partition that is currently up. Over these channels, kernel-level | 67 | * other partition that is currently up. Over these channels, kernel-level |
94 | * `users' can communicate with their counterparts on the other partitions. | 68 | * `users' can communicate with their counterparts on the other partitions. |
95 | * | 69 | * |
96 | * The maxinum number of channels is limited to eight. For performance reasons, | ||
97 | * the internal cross partition structures require sixteen bytes per channel, | ||
98 | * and eight allows all of this interface-shared info to fit in one cache line. | ||
99 | * | ||
100 | * XPC_NCHANNELS reflects the total number of channels currently defined. | ||
101 | * If the need for additional channels arises, one can simply increase | 70 | * If the need for additional channels arises, one can simply increase |
102 | * XPC_NCHANNELS accordingly. If the day should come where that number | 71 | * XPC_MAX_NCHANNELS accordingly. If the day should come where that number |
103 | * exceeds the MAXIMUM number of channels allowed (eight), then one will need | 72 | * exceeds the absolute MAXIMUM number of channels possible (eight), then one |
104 | * to make changes to the XPC code to allow for this. | 73 | * will need to make changes to the XPC code to accommodate for this. |
74 | * | ||
75 | * The absolute maximum number of channels possible is limited to eight for | ||
76 | * performance reasons on sn2 hardware. The internal cross partition structures | ||
77 | * require sixteen bytes per channel, and eight allows all of this | ||
78 | * interface-shared info to fit in one 128-byte cacheline. | ||
105 | */ | 79 | */ |
106 | #define XPC_MEM_CHANNEL 0 /* memory channel number */ | 80 | #define XPC_MEM_CHANNEL 0 /* memory channel number */ |
107 | #define XPC_NET_CHANNEL 1 /* network channel number */ | 81 | #define XPC_NET_CHANNEL 1 /* network channel number */ |
108 | 82 | ||
109 | #define XPC_NCHANNELS 2 /* #of defined channels */ | 83 | #define XPC_MAX_NCHANNELS 2 /* max #of channels allowed */ |
110 | #define XPC_MAX_NCHANNELS 8 /* max #of channels allowed */ | ||
111 | 84 | ||
112 | #if XPC_NCHANNELS > XPC_MAX_NCHANNELS | 85 | #if XPC_MAX_NCHANNELS > 8 |
113 | #error XPC_NCHANNELS exceeds MAXIMUM allowed. | 86 | #error XPC_MAX_NCHANNELS exceeds absolute MAXIMUM possible. |
114 | #endif | 87 | #endif |
115 | 88 | ||
116 | /* | 89 | /* |
117 | * The format of an XPC message is as follows: | 90 | * Define macro, XPC_MSG_SIZE(), is provided for the user |
118 | * | ||
119 | * +-------+--------------------------------+ | ||
120 | * | flags |////////////////////////////////| | ||
121 | * +-------+--------------------------------+ | ||
122 | * | message # | | ||
123 | * +----------------------------------------+ | ||
124 | * | payload (user-defined message) | | ||
125 | * | | | ||
126 | * : | ||
127 | * | | | ||
128 | * +----------------------------------------+ | ||
129 | * | ||
130 | * The size of the payload is defined by the user via xpc_connect(). A user- | ||
131 | * defined message resides in the payload area. | ||
132 | * | ||
133 | * The user should have no dealings with the message header, but only the | ||
134 | * message's payload. When a message entry is allocated (via xpc_allocate()) | ||
135 | * a pointer to the payload area is returned and not the actual beginning of | ||
136 | * the XPC message. The user then constructs a message in the payload area | ||
137 | * and passes that pointer as an argument on xpc_send() or xpc_send_notify(). | ||
138 | * | ||
139 | * The size of a message entry (within a message queue) must be a cacheline | ||
140 | * sized multiple in order to facilitate the BTE transfer of messages from one | ||
141 | * message queue to another. A macro, XPC_MSG_SIZE(), is provided for the user | ||
142 | * that wants to fit as many msg entries as possible in a given memory size | 91 | * that wants to fit as many msg entries as possible in a given memory size |
143 | * (e.g. a memory page). | 92 | * (e.g. a memory page). |
144 | */ | 93 | */ |
145 | struct xpc_msg { | 94 | #define XPC_MSG_MAX_SIZE 128 |
146 | u8 flags; /* FOR XPC INTERNAL USE ONLY */ | 95 | #define XPC_MSG_HDR_MAX_SIZE 16 |
147 | u8 reserved[7]; /* FOR XPC INTERNAL USE ONLY */ | 96 | #define XPC_MSG_PAYLOAD_MAX_SIZE (XPC_MSG_MAX_SIZE - XPC_MSG_HDR_MAX_SIZE) |
148 | s64 number; /* FOR XPC INTERNAL USE ONLY */ | ||
149 | |||
150 | u64 payload; /* user defined portion of message */ | ||
151 | }; | ||
152 | 97 | ||
153 | #define XPC_MSG_PAYLOAD_OFFSET (u64) (&((struct xpc_msg *)0)->payload) | ||
154 | #define XPC_MSG_SIZE(_payload_size) \ | 98 | #define XPC_MSG_SIZE(_payload_size) \ |
155 | L1_CACHE_ALIGN(XPC_MSG_PAYLOAD_OFFSET + (_payload_size)) | 99 | ALIGN(XPC_MSG_HDR_MAX_SIZE + (_payload_size), \ |
100 | is_uv() ? 64 : 128) | ||
101 | |||
156 | 102 | ||
157 | /* | 103 | /* |
158 | * Define the return values and values passed to user's callout functions. | 104 | * Define the return values and values passed to user's callout functions. |
@@ -233,8 +179,20 @@ enum xp_retval { | |||
233 | xpDisconnected, /* 51: channel disconnected (closed) */ | 179 | xpDisconnected, /* 51: channel disconnected (closed) */ |
234 | 180 | ||
235 | xpBteCopyError, /* 52: bte_copy() returned error */ | 181 | xpBteCopyError, /* 52: bte_copy() returned error */ |
182 | xpSalError, /* 53: sn SAL error */ | ||
183 | xpRsvdPageNotSet, /* 54: the reserved page is not set up */ | ||
184 | xpPayloadTooBig, /* 55: payload too large for message slot */ | ||
185 | |||
186 | xpUnsupported, /* 56: unsupported functionality or resource */ | ||
187 | xpNeedMoreInfo, /* 57: more info is needed by SAL */ | ||
236 | 188 | ||
237 | xpUnknownReason /* 53: unknown reason - must be last in enum */ | 189 | xpGruCopyError, /* 58: gru_copy_gru() returned error */ |
190 | xpGruSendMqError, /* 59: gru send message queue related error */ | ||
191 | |||
192 | xpBadChannelNumber, /* 60: invalid channel number */ | ||
193 | xpBadMsgType, /* 60: invalid message type */ | ||
194 | |||
195 | xpUnknownReason /* 61: unknown reason - must be last in enum */ | ||
238 | }; | 196 | }; |
239 | 197 | ||
240 | /* | 198 | /* |
@@ -285,6 +243,9 @@ typedef void (*xpc_channel_func) (enum xp_retval reason, short partid, | |||
285 | * calling xpc_received(). | 243 | * calling xpc_received(). |
286 | * | 244 | * |
287 | * All other reason codes indicate failure. | 245 | * All other reason codes indicate failure. |
246 | * | ||
247 | * NOTE: The user defined function must be callable by an interrupt handler | ||
248 | * and thus cannot block. | ||
288 | */ | 249 | */ |
289 | typedef void (*xpc_notify_func) (enum xp_retval reason, short partid, | 250 | typedef void (*xpc_notify_func) (enum xp_retval reason, short partid, |
290 | int ch_number, void *key); | 251 | int ch_number, void *key); |
@@ -308,23 +269,22 @@ struct xpc_registration { | |||
308 | xpc_channel_func func; /* function to call */ | 269 | xpc_channel_func func; /* function to call */ |
309 | void *key; /* pointer to user's key */ | 270 | void *key; /* pointer to user's key */ |
310 | u16 nentries; /* #of msg entries in local msg queue */ | 271 | u16 nentries; /* #of msg entries in local msg queue */ |
311 | u16 msg_size; /* message queue's message size */ | 272 | u16 entry_size; /* message queue's message entry size */ |
312 | u32 assigned_limit; /* limit on #of assigned kthreads */ | 273 | u32 assigned_limit; /* limit on #of assigned kthreads */ |
313 | u32 idle_limit; /* limit on #of idle kthreads */ | 274 | u32 idle_limit; /* limit on #of idle kthreads */ |
314 | } ____cacheline_aligned; | 275 | } ____cacheline_aligned; |
315 | 276 | ||
316 | #define XPC_CHANNEL_REGISTERED(_c) (xpc_registrations[_c].func != NULL) | 277 | #define XPC_CHANNEL_REGISTERED(_c) (xpc_registrations[_c].func != NULL) |
317 | 278 | ||
318 | /* the following are valid xpc_allocate() flags */ | 279 | /* the following are valid xpc_send() or xpc_send_notify() flags */ |
319 | #define XPC_WAIT 0 /* wait flag */ | 280 | #define XPC_WAIT 0 /* wait flag */ |
320 | #define XPC_NOWAIT 1 /* no wait flag */ | 281 | #define XPC_NOWAIT 1 /* no wait flag */ |
321 | 282 | ||
322 | struct xpc_interface { | 283 | struct xpc_interface { |
323 | void (*connect) (int); | 284 | void (*connect) (int); |
324 | void (*disconnect) (int); | 285 | void (*disconnect) (int); |
325 | enum xp_retval (*allocate) (short, int, u32, void **); | 286 | enum xp_retval (*send) (short, int, u32, void *, u16); |
326 | enum xp_retval (*send) (short, int, void *); | 287 | enum xp_retval (*send_notify) (short, int, u32, void *, u16, |
327 | enum xp_retval (*send_notify) (short, int, void *, | ||
328 | xpc_notify_func, void *); | 288 | xpc_notify_func, void *); |
329 | void (*received) (short, int, void *); | 289 | void (*received) (short, int, void *); |
330 | enum xp_retval (*partid_to_nasids) (short, void *); | 290 | enum xp_retval (*partid_to_nasids) (short, void *); |
@@ -334,10 +294,9 @@ extern struct xpc_interface xpc_interface; | |||
334 | 294 | ||
335 | extern void xpc_set_interface(void (*)(int), | 295 | extern void xpc_set_interface(void (*)(int), |
336 | void (*)(int), | 296 | void (*)(int), |
337 | enum xp_retval (*)(short, int, u32, void **), | 297 | enum xp_retval (*)(short, int, u32, void *, u16), |
338 | enum xp_retval (*)(short, int, void *), | 298 | enum xp_retval (*)(short, int, u32, void *, u16, |
339 | enum xp_retval (*)(short, int, void *, | 299 | xpc_notify_func, void *), |
340 | xpc_notify_func, void *), | ||
341 | void (*)(short, int, void *), | 300 | void (*)(short, int, void *), |
342 | enum xp_retval (*)(short, void *)); | 301 | enum xp_retval (*)(short, void *)); |
343 | extern void xpc_clear_interface(void); | 302 | extern void xpc_clear_interface(void); |
@@ -347,22 +306,19 @@ extern enum xp_retval xpc_connect(int, xpc_channel_func, void *, u16, | |||
347 | extern void xpc_disconnect(int); | 306 | extern void xpc_disconnect(int); |
348 | 307 | ||
349 | static inline enum xp_retval | 308 | static inline enum xp_retval |
350 | xpc_allocate(short partid, int ch_number, u32 flags, void **payload) | 309 | xpc_send(short partid, int ch_number, u32 flags, void *payload, |
351 | { | 310 | u16 payload_size) |
352 | return xpc_interface.allocate(partid, ch_number, flags, payload); | ||
353 | } | ||
354 | |||
355 | static inline enum xp_retval | ||
356 | xpc_send(short partid, int ch_number, void *payload) | ||
357 | { | 311 | { |
358 | return xpc_interface.send(partid, ch_number, payload); | 312 | return xpc_interface.send(partid, ch_number, flags, payload, |
313 | payload_size); | ||
359 | } | 314 | } |
360 | 315 | ||
361 | static inline enum xp_retval | 316 | static inline enum xp_retval |
362 | xpc_send_notify(short partid, int ch_number, void *payload, | 317 | xpc_send_notify(short partid, int ch_number, u32 flags, void *payload, |
363 | xpc_notify_func func, void *key) | 318 | u16 payload_size, xpc_notify_func func, void *key) |
364 | { | 319 | { |
365 | return xpc_interface.send_notify(partid, ch_number, payload, func, key); | 320 | return xpc_interface.send_notify(partid, ch_number, flags, payload, |
321 | payload_size, func, key); | ||
366 | } | 322 | } |
367 | 323 | ||
368 | static inline void | 324 | static inline void |
@@ -377,8 +333,23 @@ xpc_partid_to_nasids(short partid, void *nasids) | |||
377 | return xpc_interface.partid_to_nasids(partid, nasids); | 333 | return xpc_interface.partid_to_nasids(partid, nasids); |
378 | } | 334 | } |
379 | 335 | ||
336 | extern short xp_max_npartitions; | ||
337 | extern short xp_partition_id; | ||
338 | extern u8 xp_region_size; | ||
339 | |||
340 | extern unsigned long (*xp_pa) (void *); | ||
341 | extern enum xp_retval (*xp_remote_memcpy) (unsigned long, const unsigned long, | ||
342 | size_t); | ||
343 | extern int (*xp_cpu_to_nasid) (int); | ||
344 | |||
380 | extern u64 xp_nofault_PIOR_target; | 345 | extern u64 xp_nofault_PIOR_target; |
381 | extern int xp_nofault_PIOR(void *); | 346 | extern int xp_nofault_PIOR(void *); |
382 | extern int xp_error_PIOR(void); | 347 | extern int xp_error_PIOR(void); |
383 | 348 | ||
349 | extern struct device *xp; | ||
350 | extern enum xp_retval xp_init_sn2(void); | ||
351 | extern enum xp_retval xp_init_uv(void); | ||
352 | extern void xp_exit_sn2(void); | ||
353 | extern void xp_exit_uv(void); | ||
354 | |||
384 | #endif /* _DRIVERS_MISC_SGIXP_XP_H */ | 355 | #endif /* _DRIVERS_MISC_SGIXP_XP_H */ |