Commit | Line | Data |
---|---|---|
12e364b9 KC |
1 | /* visorchipset_main.c |
2 | * | |
3 | * Copyright � 2010 - 2013 UNISYS CORPORATION | |
4 | * All rights reserved. | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 2 of the License, or (at | |
9 | * your option) any later version. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, but | |
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | |
14 | * NON INFRINGEMENT. See the GNU General Public License for more | |
15 | * details. | |
16 | */ | |
17 | ||
18 | #include "globals.h" | |
19 | #include "controlvm.h" | |
20 | #include "visorchipset.h" | |
21 | #include "procobjecttree.h" | |
22 | #include "visorchannel.h" | |
23 | #include "periodic_work.h" | |
24 | #include "testing.h" | |
25 | #include "file.h" | |
26 | #include "parser.h" | |
27 | #include "uniklog.h" | |
28 | #include "uisutils.h" | |
29 | #include "guidutils.h" | |
30 | #include "controlvmcompletionstatus.h" | |
31 | #include "guestlinuxdebug.h" | |
32 | #include "filexfer.h" | |
33 | ||
34 | #include <linux/nls.h> | |
35 | #include <linux/netdevice.h> | |
36 | #include <linux/platform_device.h> | |
37 | ||
38 | #define CURRENT_FILE_PC VISOR_CHIPSET_PC_visorchipset_main_c | |
39 | #define TEST_VNIC_PHYSITF "eth0" /* physical network itf for | |
40 | * vnic loopback test */ | |
41 | #define TEST_VNIC_SWITCHNO 1 | |
42 | #define TEST_VNIC_BUSNO 9 | |
43 | ||
44 | #define MAX_NAME_SIZE 128 | |
45 | #define MAX_IP_SIZE 50 | |
46 | #define MAXOUTSTANDINGCHANNELCOMMAND 256 | |
47 | #define POLLJIFFIES_CONTROLVMCHANNEL_FAST 1 | |
48 | #define POLLJIFFIES_CONTROLVMCHANNEL_SLOW 100 | |
49 | ||
50 | /* When the controlvm channel is idle for at least MIN_IDLE_SECONDS, | |
51 | * we switch to slow polling mode. As soon as we get a controlvm | |
52 | * message, we switch back to fast polling mode. | |
53 | */ | |
54 | #define MIN_IDLE_SECONDS 10 | |
bd5b9b32 KC |
55 | static ulong Poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST; |
56 | static ulong Most_recent_message_jiffies; /* when we got our last | |
57 | * controlvm message */ | |
12e364b9 KC |
58 | static inline char * |
59 | NONULLSTR(char *s) | |
60 | { | |
61 | if (s) | |
62 | return s; | |
63 | else | |
64 | return ""; | |
65 | } | |
66 | ||
67 | static int serverregistered; | |
68 | static int clientregistered; | |
69 | ||
70 | #define MAX_CHIPSET_EVENTS 2 | |
71 | static U8 chipset_events[MAX_CHIPSET_EVENTS] = { 0, 0 }; | |
72 | ||
73 | static struct delayed_work Periodic_controlvm_work; | |
74 | static struct workqueue_struct *Periodic_controlvm_workqueue; | |
bd5b9b32 | 75 | static DEFINE_SEMAPHORE(NotifierLock); |
12e364b9 KC |
76 | |
77 | typedef struct { | |
78 | CONTROLVM_MESSAGE message; | |
79 | unsigned int crc; | |
80 | } MESSAGE_ENVELOPE; | |
81 | ||
82 | static CONTROLVM_MESSAGE_HEADER g_DiagMsgHdr; | |
83 | static CONTROLVM_MESSAGE_HEADER g_ChipSetMsgHdr; | |
84 | static CONTROLVM_MESSAGE_HEADER g_DelDumpMsgHdr; | |
85 | static const GUID UltraDiagPoolChannelProtocolGuid = | |
86 | ULTRA_DIAG_POOL_CHANNEL_PROTOCOL_GUID; | |
87 | /* 0xffffff is an invalid Bus/Device number */ | |
88 | static ulong g_diagpoolBusNo = 0xffffff; | |
89 | static ulong g_diagpoolDevNo = 0xffffff; | |
90 | static CONTROLVM_MESSAGE_PACKET g_DeviceChangeStatePacket; | |
91 | ||
92 | /* Only VNIC and VHBA channels are sent to visorclientbus (aka | |
93 | * "visorhackbus") | |
94 | */ | |
95 | #define FOR_VISORHACKBUS(channel_type_guid) \ | |
96 | ((memcmp(&channel_type_guid, &UltraVnicChannelProtocolGuid, \ | |
97 | sizeof(GUID)) == 0) || \ | |
98 | (memcmp(&channel_type_guid, &UltraVhbaChannelProtocolGuid, \ | |
99 | sizeof(GUID)) == 0)) | |
100 | #define FOR_VISORBUS(channel_type_guid) (!(FOR_VISORHACKBUS(channel_type_guid))) | |
101 | ||
102 | #define is_diagpool_channel(channel_type_guid) \ | |
103 | (memcmp(&channel_type_guid, \ | |
104 | &UltraDiagPoolChannelProtocolGuid, sizeof(GUID)) == 0) | |
105 | ||
106 | typedef enum { | |
107 | PARTPROP_invalid, | |
108 | PARTPROP_name, | |
109 | PARTPROP_description, | |
110 | PARTPROP_handle, | |
111 | PARTPROP_busNumber, | |
112 | /* add new properties above, but don't forget to change | |
113 | * InitPartitionProperties() and show_partition_property() also... | |
114 | */ | |
115 | PARTPROP_last | |
116 | } PARTITION_property; | |
117 | static const char *PartitionTypeNames[] = { "partition", NULL }; | |
118 | ||
119 | static char *PartitionPropertyNames[PARTPROP_last + 1]; | |
120 | static void | |
121 | InitPartitionProperties(void) | |
122 | { | |
123 | char **p = PartitionPropertyNames; | |
124 | p[PARTPROP_invalid] = ""; | |
125 | p[PARTPROP_name] = "name"; | |
126 | p[PARTPROP_description] = "description"; | |
127 | p[PARTPROP_handle] = "handle"; | |
128 | p[PARTPROP_busNumber] = "busNumber"; | |
129 | p[PARTPROP_last] = NULL; | |
130 | } | |
131 | ||
132 | typedef enum { | |
133 | CTLVMPROP_invalid, | |
134 | CTLVMPROP_physAddr, | |
135 | CTLVMPROP_controlChannelAddr, | |
136 | CTLVMPROP_controlChannelBytes, | |
137 | CTLVMPROP_sparBootPart, | |
138 | CTLVMPROP_sparStoragePart, | |
139 | CTLVMPROP_livedumpLength, | |
140 | CTLVMPROP_livedumpCrc32, | |
141 | /* add new properties above, but don't forget to change | |
142 | * InitControlVmProperties() show_controlvm_property() also... | |
143 | */ | |
144 | CTLVMPROP_last | |
145 | } CONTROLVM_property; | |
146 | ||
147 | static const char *ControlVmTypeNames[] = { "controlvm", NULL }; | |
148 | ||
149 | static char *ControlVmPropertyNames[CTLVMPROP_last + 1]; | |
150 | static void | |
151 | InitControlVmProperties(void) | |
152 | { | |
153 | char **p = ControlVmPropertyNames; | |
154 | p[CTLVMPROP_invalid] = ""; | |
155 | p[CTLVMPROP_physAddr] = "physAddr"; | |
156 | p[CTLVMPROP_controlChannelAddr] = "controlChannelAddr"; | |
157 | p[CTLVMPROP_controlChannelBytes] = "controlChannelBytes"; | |
158 | p[CTLVMPROP_sparBootPart] = "spar_boot_part"; | |
159 | p[CTLVMPROP_sparStoragePart] = "spar_storage_part"; | |
160 | p[CTLVMPROP_livedumpLength] = "livedumpLength"; | |
161 | p[CTLVMPROP_livedumpCrc32] = "livedumpCrc32"; | |
162 | p[CTLVMPROP_last] = NULL; | |
163 | } | |
164 | ||
165 | static MYPROCOBJECT *ControlVmObject; | |
166 | static MYPROCTYPE *PartitionType; | |
167 | static MYPROCTYPE *ControlVmType; | |
168 | ||
169 | #define VISORCHIPSET_DIAG_PROC_ENTRY_FN "diagdump" | |
170 | static struct proc_dir_entry *diag_proc_dir; | |
171 | ||
172 | #define VISORCHIPSET_CHIPSET_PROC_ENTRY_FN "chipsetready" | |
173 | static struct proc_dir_entry *chipset_proc_dir; | |
174 | ||
175 | #define VISORCHIPSET_PARAHOTPLUG_PROC_ENTRY_FN "parahotplug" | |
176 | static struct proc_dir_entry *parahotplug_proc_dir; | |
177 | ||
178 | static LIST_HEAD(BusInfoList); | |
179 | static LIST_HEAD(DevInfoList); | |
180 | ||
181 | static struct proc_dir_entry *ProcDir; | |
182 | static VISORCHANNEL *ControlVm_channel; | |
183 | ||
184 | static ssize_t visorchipset_proc_read_writeonly(struct file *file, | |
185 | char __user *buf, | |
186 | size_t len, loff_t *offset); | |
187 | static ssize_t proc_read_installer(struct file *file, char __user *buf, | |
188 | size_t len, loff_t *offset); | |
189 | static ssize_t proc_write_installer(struct file *file, | |
190 | const char __user *buffer, | |
191 | size_t count, loff_t *ppos); | |
192 | static ssize_t proc_read_toolaction(struct file *file, char __user *buf, | |
193 | size_t len, loff_t *offset); | |
194 | static ssize_t proc_write_toolaction(struct file *file, | |
195 | const char __user *buffer, | |
196 | size_t count, loff_t *ppos); | |
197 | static ssize_t proc_read_bootToTool(struct file *file, char __user *buf, | |
198 | size_t len, loff_t *offset); | |
199 | static ssize_t proc_write_bootToTool(struct file *file, | |
200 | const char __user *buffer, | |
201 | size_t count, loff_t *ppos); | |
202 | static const struct file_operations proc_installer_fops = { | |
203 | .read = proc_read_installer, | |
204 | .write = proc_write_installer, | |
205 | }; | |
206 | ||
207 | static const struct file_operations proc_toolaction_fops = { | |
208 | .read = proc_read_toolaction, | |
209 | .write = proc_write_toolaction, | |
210 | }; | |
211 | ||
212 | static const struct file_operations proc_bootToTool_fops = { | |
213 | .read = proc_read_bootToTool, | |
214 | .write = proc_write_bootToTool, | |
215 | }; | |
216 | ||
217 | typedef struct { | |
bd5b9b32 | 218 | U8 __iomem *ptr; /* pointer to base address of payload pool */ |
12e364b9 KC |
219 | U64 offset; /* offset from beginning of controlvm |
220 | * channel to beginning of payload * pool */ | |
221 | U32 bytes; /* number of bytes in payload pool */ | |
222 | } CONTROLVM_PAYLOAD_INFO; | |
223 | ||
224 | /* Manages the request payload in the controlvm channel */ | |
225 | static CONTROLVM_PAYLOAD_INFO ControlVm_payload_info; | |
226 | ||
227 | static pCHANNEL_HEADER Test_Vnic_channel; | |
228 | ||
229 | typedef struct { | |
230 | CONTROLVM_MESSAGE_HEADER Dumpcapture_header; | |
231 | CONTROLVM_MESSAGE_HEADER Gettextdump_header; | |
232 | CONTROLVM_MESSAGE_HEADER Dumpcomplete_header; | |
233 | BOOL Gettextdump_outstanding; | |
234 | u32 crc32; | |
235 | ulong length; | |
236 | atomic_t buffers_in_use; | |
237 | ulong destination; | |
238 | } LIVEDUMP_INFO; | |
239 | /* Manages the info for a CONTROLVM_DUMP_CAPTURESTATE / | |
240 | * CONTROLVM_DUMP_GETTEXTDUMP / CONTROLVM_DUMP_COMPLETE conversation. | |
241 | */ | |
242 | static LIVEDUMP_INFO LiveDump_info; | |
243 | ||
244 | /* The following globals are used to handle the scenario where we are unable to | |
245 | * offload the payload from a controlvm message due to memory requirements. In | |
246 | * this scenario, we simply stash the controlvm message, then attempt to | |
247 | * process it again the next time controlvm_periodic_work() runs. | |
248 | */ | |
249 | static CONTROLVM_MESSAGE ControlVm_Pending_Msg; | |
250 | static BOOL ControlVm_Pending_Msg_Valid = FALSE; | |
251 | ||
252 | /* Pool of struct putfile_buffer_entry, for keeping track of pending (incoming) | |
253 | * TRANSMIT_FILE PutFile payloads. | |
254 | */ | |
255 | static struct kmem_cache *Putfile_buffer_list_pool; | |
256 | static const char Putfile_buffer_list_pool_name[] = | |
257 | "controlvm_putfile_buffer_list_pool"; | |
258 | ||
259 | /* This identifies a data buffer that has been received via a controlvm messages | |
260 | * in a remote --> local CONTROLVM_TRANSMIT_FILE conversation. | |
261 | */ | |
262 | struct putfile_buffer_entry { | |
263 | struct list_head next; /* putfile_buffer_entry list */ | |
264 | PARSER_CONTEXT *parser_ctx; /* points to buffer containing input data */ | |
265 | }; | |
266 | ||
267 | /* List of struct putfile_request *, via next_putfile_request member. | |
268 | * Each entry in this list identifies an outstanding TRANSMIT_FILE | |
269 | * conversation. | |
270 | */ | |
271 | static LIST_HEAD(Putfile_request_list); | |
272 | ||
273 | /* This describes a buffer and its current state of transfer (e.g., how many | |
274 | * bytes have already been supplied as putfile data, and how many bytes are | |
275 | * remaining) for a putfile_request. | |
276 | */ | |
277 | struct putfile_active_buffer { | |
278 | /* a payload from a controlvm message, containing a file data buffer */ | |
279 | PARSER_CONTEXT *parser_ctx; | |
280 | /* points within data area of parser_ctx to next byte of data */ | |
281 | u8 *pnext; | |
282 | /* # bytes left from <pnext> to the end of this data buffer */ | |
283 | size_t bytes_remaining; | |
284 | }; | |
285 | ||
286 | #define PUTFILE_REQUEST_SIG 0x0906101302281211 | |
287 | /* This identifies a single remote --> local CONTROLVM_TRANSMIT_FILE | |
288 | * conversation. Structs of this type are dynamically linked into | |
289 | * <Putfile_request_list>. | |
290 | */ | |
291 | struct putfile_request { | |
292 | u64 sig; /* PUTFILE_REQUEST_SIG */ | |
293 | ||
294 | /* header from original TransmitFile request */ | |
295 | CONTROLVM_MESSAGE_HEADER controlvm_header; | |
296 | u64 file_request_number; /* from original TransmitFile request */ | |
297 | ||
298 | /* link to next struct putfile_request */ | |
299 | struct list_head next_putfile_request; | |
300 | ||
301 | /* most-recent sequence number supplied via a controlvm message */ | |
302 | u64 data_sequence_number; | |
303 | ||
304 | /* head of putfile_buffer_entry list, which describes the data to be | |
305 | * supplied as putfile data; | |
306 | * - this list is added to when controlvm messages come in that supply | |
307 | * file data | |
308 | * - this list is removed from via the hotplug program that is actually | |
309 | * consuming these buffers to write as file data */ | |
310 | struct list_head input_buffer_list; | |
311 | spinlock_t req_list_lock; /* lock for input_buffer_list */ | |
312 | ||
313 | /* waiters for input_buffer_list to go non-empty */ | |
314 | wait_queue_head_t input_buffer_wq; | |
315 | ||
316 | /* data not yet read within current putfile_buffer_entry */ | |
317 | struct putfile_active_buffer active_buf; | |
318 | ||
319 | /* <0 = failed, 0 = in-progress, >0 = successful; */ | |
320 | /* note that this must be set with req_list_lock, and if you set <0, */ | |
321 | /* it is your responsibility to also free up all of the other objects */ | |
322 | /* in this struct (like input_buffer_list, active_buf.parser_ctx) */ | |
323 | /* before releasing the lock */ | |
324 | int completion_status; | |
325 | }; | |
326 | ||
bd5b9b32 | 327 | static atomic_t Visorchipset_cache_buffers_in_use = ATOMIC_INIT(0); |
12e364b9 KC |
328 | |
329 | struct parahotplug_request { | |
330 | struct list_head list; | |
331 | int id; | |
332 | unsigned long expiration; | |
333 | CONTROLVM_MESSAGE msg; | |
334 | }; | |
335 | ||
336 | static LIST_HEAD(Parahotplug_request_list); | |
337 | static DEFINE_SPINLOCK(Parahotplug_request_list_lock); /* lock for above */ | |
338 | static void parahotplug_process_list(void); | |
339 | ||
340 | /* Manages the info for a CONTROLVM_DUMP_CAPTURESTATE / | |
341 | * CONTROLVM_REPORTEVENT. | |
342 | */ | |
343 | static VISORCHIPSET_BUSDEV_NOTIFIERS BusDev_Server_Notifiers; | |
344 | static VISORCHIPSET_BUSDEV_NOTIFIERS BusDev_Client_Notifiers; | |
345 | ||
346 | static void bus_create_response(ulong busNo, int response); | |
347 | static void bus_destroy_response(ulong busNo, int response); | |
348 | static void device_create_response(ulong busNo, ulong devNo, int response); | |
349 | static void device_destroy_response(ulong busNo, ulong devNo, int response); | |
350 | static void device_resume_response(ulong busNo, ulong devNo, int response); | |
351 | ||
352 | static VISORCHIPSET_BUSDEV_RESPONDERS BusDev_Responders = { | |
353 | .bus_create = bus_create_response, | |
354 | .bus_destroy = bus_destroy_response, | |
355 | .device_create = device_create_response, | |
356 | .device_destroy = device_destroy_response, | |
927c7927 | 357 | .device_pause = visorchipset_device_pause_response, |
12e364b9 KC |
358 | .device_resume = device_resume_response, |
359 | }; | |
360 | ||
361 | /* info for /dev/visorchipset */ | |
362 | static dev_t MajorDev = -1; /**< indicates major num for device */ | |
363 | ||
364 | /* /sys/devices/platform/visorchipset */ | |
365 | static struct platform_device Visorchipset_platform_device = { | |
366 | .name = "visorchipset", | |
367 | .id = -1, | |
368 | }; | |
369 | ||
370 | /* Function prototypes */ | |
371 | static void controlvm_respond(CONTROLVM_MESSAGE_HEADER *msgHdr, int response); | |
372 | static void controlvm_respond_chipset_init(CONTROLVM_MESSAGE_HEADER *msgHdr, | |
373 | int response, | |
374 | ULTRA_CHIPSET_FEATURE features); | |
375 | static void controlvm_respond_physdev_changestate(CONTROLVM_MESSAGE_HEADER * | |
376 | msgHdr, int response, | |
377 | ULTRA_SEGMENT_STATE state); | |
378 | ||
379 | static void | |
380 | show_partition_property(struct seq_file *f, void *ctx, int property) | |
381 | { | |
382 | VISORCHIPSET_BUS_INFO *info = (VISORCHIPSET_BUS_INFO *) (ctx); | |
383 | ||
384 | switch (property) { | |
385 | case PARTPROP_name: | |
386 | seq_printf(f, "%s\n", NONULLSTR(info->name)); | |
387 | break; | |
388 | case PARTPROP_description: | |
389 | seq_printf(f, "%s\n", NONULLSTR(info->description)); | |
390 | break; | |
391 | case PARTPROP_handle: | |
392 | seq_printf(f, "0x%-16.16Lx\n", info->partitionHandle); | |
393 | break; | |
394 | case PARTPROP_busNumber: | |
395 | seq_printf(f, "%d\n", info->busNo); | |
396 | break; | |
397 | default: | |
398 | seq_printf(f, "(%d??)\n", property); | |
399 | break; | |
400 | } | |
401 | } | |
402 | ||
403 | static void | |
404 | show_controlvm_property(struct seq_file *f, void *ctx, int property) | |
405 | { | |
406 | /* Note: ctx is not needed since we only have 1 controlvm channel */ | |
407 | switch (property) { | |
408 | case CTLVMPROP_physAddr: | |
409 | if (ControlVm_channel == NULL) | |
410 | seq_puts(f, "0x0\n"); | |
411 | else | |
412 | seq_printf(f, "0x%-16.16Lx\n", | |
413 | visorchannel_get_physaddr | |
414 | (ControlVm_channel)); | |
415 | break; | |
416 | case CTLVMPROP_controlChannelAddr: | |
417 | if (ControlVm_channel == NULL) | |
418 | seq_puts(f, "0x0\n"); | |
419 | else { | |
420 | GUEST_PHYSICAL_ADDRESS addr = 0; | |
421 | visorchannel_read(ControlVm_channel, | |
422 | offsetof | |
423 | (ULTRA_CONTROLVM_CHANNEL_PROTOCOL, | |
424 | gpControlChannel), &addr, | |
425 | sizeof(addr)); | |
426 | seq_printf(f, "0x%-16.16Lx\n", (u64) (addr)); | |
427 | } | |
428 | break; | |
429 | case CTLVMPROP_controlChannelBytes: | |
430 | if (ControlVm_channel == NULL) | |
431 | seq_puts(f, "0x0\n"); | |
432 | else { | |
433 | U32 bytes = 0; | |
434 | visorchannel_read(ControlVm_channel, | |
435 | offsetof | |
436 | (ULTRA_CONTROLVM_CHANNEL_PROTOCOL, | |
437 | ControlChannelBytes), &bytes, | |
438 | sizeof(bytes)); | |
439 | seq_printf(f, "%lu\n", (ulong) (bytes)); | |
440 | } | |
441 | break; | |
442 | case CTLVMPROP_sparBootPart: | |
443 | seq_puts(f, "0:0:0:0/1\n"); | |
444 | break; | |
445 | case CTLVMPROP_sparStoragePart: | |
446 | seq_puts(f, "0:0:0:0/2\n"); | |
447 | break; | |
448 | case CTLVMPROP_livedumpLength: | |
449 | seq_printf(f, "%lu\n", LiveDump_info.length); | |
450 | break; | |
451 | case CTLVMPROP_livedumpCrc32: | |
452 | seq_printf(f, "%lu\n", (ulong) LiveDump_info.crc32); | |
453 | break; | |
454 | default: | |
455 | seq_printf(f, "(%d??)\n", property); | |
456 | break; | |
457 | } | |
458 | } | |
459 | ||
460 | static void | |
461 | proc_Init(void) | |
462 | { | |
463 | if (ProcDir == NULL) { | |
464 | ProcDir = proc_mkdir(MYDRVNAME, NULL); | |
465 | if (ProcDir == NULL) { | |
466 | LOGERR("failed to create /proc directory %s", | |
467 | MYDRVNAME); | |
468 | POSTCODE_LINUX_2(CHIPSET_INIT_FAILURE_PC, | |
469 | POSTCODE_SEVERITY_ERR); | |
470 | } | |
471 | } | |
472 | } | |
473 | ||
474 | static void | |
475 | proc_DeInit(void) | |
476 | { | |
477 | if (ProcDir != NULL) | |
478 | remove_proc_entry(MYDRVNAME, NULL); | |
479 | ProcDir = NULL; | |
480 | } | |
481 | ||
482 | #if 0 | |
483 | static void | |
484 | testUnicode(void) | |
485 | { | |
486 | wchar_t unicodeString[] = { 'a', 'b', 'c', 0 }; | |
487 | char s[sizeof(unicodeString) * NLS_MAX_CHARSET_SIZE]; | |
488 | wchar_t unicode2[99]; | |
489 | ||
490 | /* NOTE: Either due to a bug, or feature I don't understand, the | |
491 | * kernel utf8_mbstowcs() and utf_wcstombs() do NOT copy the | |
492 | * trailed NUL byte!! REALLY!!!!! Arrrrgggghhhhh | |
493 | */ | |
494 | ||
495 | LOGINF("sizeof(wchar_t) = %d", sizeof(wchar_t)); | |
496 | LOGINF("utf8_wcstombs=%d", | |
497 | chrs = utf8_wcstombs(s, unicodeString, sizeof(s))); | |
498 | if (chrs >= 0) | |
499 | s[chrs] = '\0'; /* GRRRRRRRR */ | |
500 | LOGINF("s='%s'", s); | |
501 | LOGINF("utf8_mbstowcs=%d", chrs = utf8_mbstowcs(unicode2, s, 100)); | |
502 | if (chrs >= 0) | |
503 | unicode2[chrs] = 0; /* GRRRRRRRR */ | |
504 | if (memcmp(unicodeString, unicode2, sizeof(unicodeString)) == 0) | |
505 | LOGINF("strings match... good"); | |
506 | else | |
507 | LOGINF("strings did not match!!"); | |
508 | } | |
509 | #endif | |
510 | ||
511 | static void | |
512 | busInfo_clear(void *v) | |
513 | { | |
514 | VISORCHIPSET_BUS_INFO *p = (VISORCHIPSET_BUS_INFO *) (v); | |
515 | ||
516 | if (p->procObject) { | |
927c7927 | 517 | visor_proc_DestroyObject(p->procObject); |
12e364b9 KC |
518 | p->procObject = NULL; |
519 | } | |
520 | kfree(p->name); | |
521 | p->name = NULL; | |
522 | ||
523 | kfree(p->description); | |
524 | p->description = NULL; | |
525 | ||
526 | p->state.created = 0; | |
527 | memset(p, 0, sizeof(VISORCHIPSET_BUS_INFO)); | |
528 | } | |
529 | ||
530 | static void | |
531 | devInfo_clear(void *v) | |
532 | { | |
533 | VISORCHIPSET_DEVICE_INFO *p = (VISORCHIPSET_DEVICE_INFO *) (v); | |
534 | p->state.created = 0; | |
535 | memset(p, 0, sizeof(VISORCHIPSET_DEVICE_INFO)); | |
536 | } | |
537 | ||
538 | static U8 | |
539 | check_chipset_events(void) | |
540 | { | |
541 | int i; | |
542 | U8 send_msg = 1; | |
543 | /* Check events to determine if response should be sent */ | |
544 | for (i = 0; i < MAX_CHIPSET_EVENTS; i++) | |
545 | send_msg &= chipset_events[i]; | |
546 | return send_msg; | |
547 | } | |
548 | ||
549 | static void | |
550 | clear_chipset_events(void) | |
551 | { | |
552 | int i; | |
553 | /* Clear chipset_events */ | |
554 | for (i = 0; i < MAX_CHIPSET_EVENTS; i++) | |
555 | chipset_events[i] = 0; | |
556 | } | |
557 | ||
558 | void | |
559 | visorchipset_register_busdev_server(VISORCHIPSET_BUSDEV_NOTIFIERS *notifiers, | |
560 | VISORCHIPSET_BUSDEV_RESPONDERS *responders, | |
561 | ULTRA_VBUS_DEVICEINFO *driverInfo) | |
562 | { | |
563 | LOCKSEM_UNINTERRUPTIBLE(&NotifierLock); | |
564 | if (notifiers == NULL) { | |
565 | memset(&BusDev_Server_Notifiers, 0, | |
566 | sizeof(BusDev_Server_Notifiers)); | |
567 | serverregistered = 0; /* clear flag */ | |
568 | } else { | |
569 | BusDev_Server_Notifiers = *notifiers; | |
570 | serverregistered = 1; /* set flag */ | |
571 | } | |
572 | if (responders) | |
573 | *responders = BusDev_Responders; | |
574 | if (driverInfo) | |
575 | BusDeviceInfo_Init(driverInfo, "chipset", "visorchipset", | |
576 | VERSION, NULL, __DATE__, __TIME__); | |
577 | ||
578 | UNLOCKSEM(&NotifierLock); | |
579 | } | |
580 | EXPORT_SYMBOL_GPL(visorchipset_register_busdev_server); | |
581 | ||
582 | void | |
583 | visorchipset_register_busdev_client(VISORCHIPSET_BUSDEV_NOTIFIERS *notifiers, | |
584 | VISORCHIPSET_BUSDEV_RESPONDERS *responders, | |
585 | ULTRA_VBUS_DEVICEINFO *driverInfo) | |
586 | { | |
587 | LOCKSEM_UNINTERRUPTIBLE(&NotifierLock); | |
588 | if (notifiers == NULL) { | |
589 | memset(&BusDev_Client_Notifiers, 0, | |
590 | sizeof(BusDev_Client_Notifiers)); | |
591 | clientregistered = 0; /* clear flag */ | |
592 | } else { | |
593 | BusDev_Client_Notifiers = *notifiers; | |
594 | clientregistered = 1; /* set flag */ | |
595 | } | |
596 | if (responders) | |
597 | *responders = BusDev_Responders; | |
598 | if (driverInfo) | |
599 | BusDeviceInfo_Init(driverInfo, "chipset(bolts)", "visorchipset", | |
600 | VERSION, NULL, __DATE__, __TIME__); | |
601 | UNLOCKSEM(&NotifierLock); | |
602 | } | |
603 | EXPORT_SYMBOL_GPL(visorchipset_register_busdev_client); | |
604 | ||
605 | static void | |
606 | cleanup_controlvm_structures(void) | |
607 | { | |
608 | VISORCHIPSET_BUS_INFO *bi; | |
609 | VISORCHIPSET_DEVICE_INFO *di; | |
610 | ||
611 | list_for_each_entry(bi, &BusInfoList, entry) { | |
612 | busInfo_clear(bi); | |
613 | list_del(&bi->entry); | |
614 | kfree(bi); | |
615 | } | |
616 | ||
617 | list_for_each_entry(di, &DevInfoList, entry) { | |
618 | devInfo_clear(di); | |
619 | list_del(&di->entry); | |
620 | kfree(di); | |
621 | } | |
622 | } | |
623 | ||
624 | static void | |
625 | chipset_init(CONTROLVM_MESSAGE *inmsg) | |
626 | { | |
627 | static int chipset_inited; | |
628 | ULTRA_CHIPSET_FEATURE features = 0; | |
629 | int rc = CONTROLVM_RESP_SUCCESS; | |
630 | ||
631 | POSTCODE_LINUX_2(CHIPSET_INIT_ENTRY_PC, POSTCODE_SEVERITY_INFO); | |
632 | if (chipset_inited) { | |
633 | LOGERR("CONTROLVM_CHIPSET_INIT Failed: Already Done."); | |
634 | RETINT(-CONTROLVM_RESP_ERROR_ALREADY_DONE); | |
635 | } | |
636 | chipset_inited = 1; | |
637 | POSTCODE_LINUX_2(CHIPSET_INIT_EXIT_PC, POSTCODE_SEVERITY_INFO); | |
638 | ||
639 | /* Set features to indicate we support parahotplug (if Command | |
640 | * also supports it). */ | |
641 | features = | |
642 | inmsg->cmd.initChipset. | |
643 | features & ULTRA_CHIPSET_FEATURE_PARA_HOTPLUG; | |
644 | ||
645 | /* Set the "reply" bit so Command knows this is a | |
646 | * features-aware driver. */ | |
647 | features |= ULTRA_CHIPSET_FEATURE_REPLY; | |
648 | ||
649 | Away: | |
650 | if (rc < 0) | |
651 | cleanup_controlvm_structures(); | |
652 | if (inmsg->hdr.Flags.responseExpected) | |
653 | controlvm_respond_chipset_init(&inmsg->hdr, rc, features); | |
654 | } | |
655 | ||
656 | static void | |
657 | controlvm_init_response(CONTROLVM_MESSAGE *msg, | |
658 | CONTROLVM_MESSAGE_HEADER *msgHdr, int response) | |
659 | { | |
660 | memset(msg, 0, sizeof(CONTROLVM_MESSAGE)); | |
661 | memcpy(&msg->hdr, msgHdr, sizeof(CONTROLVM_MESSAGE_HEADER)); | |
662 | msg->hdr.PayloadBytes = 0; | |
663 | msg->hdr.PayloadVmOffset = 0; | |
664 | msg->hdr.PayloadMaxBytes = 0; | |
665 | if (response < 0) { | |
666 | msg->hdr.Flags.failed = 1; | |
667 | msg->hdr.CompletionStatus = (U32) (-response); | |
668 | } | |
669 | } | |
670 | ||
671 | static void | |
672 | controlvm_respond(CONTROLVM_MESSAGE_HEADER *msgHdr, int response) | |
673 | { | |
674 | CONTROLVM_MESSAGE outmsg; | |
675 | if (!ControlVm_channel) | |
676 | return; | |
677 | controlvm_init_response(&outmsg, msgHdr, response); | |
678 | /* For DiagPool channel DEVICE_CHANGESTATE, we need to send | |
679 | * back the deviceChangeState structure in the packet. */ | |
680 | if (msgHdr->Id == CONTROLVM_DEVICE_CHANGESTATE | |
681 | && g_DeviceChangeStatePacket.deviceChangeState.busNo == | |
682 | g_diagpoolBusNo | |
683 | && g_DeviceChangeStatePacket.deviceChangeState.devNo == | |
684 | g_diagpoolDevNo) | |
685 | outmsg.cmd = g_DeviceChangeStatePacket; | |
686 | if (outmsg.hdr.Flags.testMessage == 1) { | |
687 | LOGINF("%s controlvm_msg=0x%x response=%d for test message", | |
688 | __func__, outmsg.hdr.Id, response); | |
689 | return; | |
690 | } | |
691 | if (!visorchannel_signalinsert(ControlVm_channel, | |
692 | CONTROLVM_QUEUE_REQUEST, &outmsg)) { | |
693 | LOGERR("signalinsert failed!"); | |
694 | return; | |
695 | } | |
696 | } | |
697 | ||
698 | static void | |
699 | controlvm_respond_chipset_init(CONTROLVM_MESSAGE_HEADER *msgHdr, int response, | |
700 | ULTRA_CHIPSET_FEATURE features) | |
701 | { | |
702 | CONTROLVM_MESSAGE outmsg; | |
703 | if (!ControlVm_channel) | |
704 | return; | |
705 | controlvm_init_response(&outmsg, msgHdr, response); | |
706 | outmsg.cmd.initChipset.features = features; | |
707 | if (!visorchannel_signalinsert(ControlVm_channel, | |
708 | CONTROLVM_QUEUE_REQUEST, &outmsg)) { | |
709 | LOGERR("signalinsert failed!"); | |
710 | return; | |
711 | } | |
712 | } | |
713 | ||
714 | static void | |
715 | controlvm_respond_physdev_changestate(CONTROLVM_MESSAGE_HEADER *msgHdr, | |
716 | int response, ULTRA_SEGMENT_STATE state) | |
717 | { | |
718 | CONTROLVM_MESSAGE outmsg; | |
719 | if (!ControlVm_channel) | |
720 | return; | |
721 | controlvm_init_response(&outmsg, msgHdr, response); | |
722 | outmsg.cmd.deviceChangeState.state = state; | |
723 | outmsg.cmd.deviceChangeState.flags.physicalDevice = 1; | |
724 | if (!visorchannel_signalinsert(ControlVm_channel, | |
725 | CONTROLVM_QUEUE_REQUEST, &outmsg)) { | |
726 | LOGERR("signalinsert failed!"); | |
727 | return; | |
728 | } | |
729 | } | |
730 | ||
731 | void | |
732 | visorchipset_save_message(CONTROLVM_MESSAGE *msg, CRASH_OBJ_TYPE type) | |
733 | { | |
734 | U32 localSavedCrashMsgOffset; | |
735 | U16 localSavedCrashMsgCount; | |
736 | ||
737 | /* get saved message count */ | |
738 | if (visorchannel_read(ControlVm_channel, | |
739 | offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, | |
740 | SavedCrashMsgCount), | |
741 | &localSavedCrashMsgCount, sizeof(U16)) < 0) { | |
742 | LOGERR("failed to get Saved Message Count"); | |
743 | POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC, | |
744 | POSTCODE_SEVERITY_ERR); | |
745 | return; | |
746 | } | |
747 | ||
748 | if (localSavedCrashMsgCount != CONTROLVM_CRASHMSG_MAX) { | |
749 | LOGERR("Saved Message Count incorrect %d", | |
750 | localSavedCrashMsgCount); | |
751 | POSTCODE_LINUX_3(CRASH_DEV_COUNT_FAILURE_PC, | |
752 | localSavedCrashMsgCount, | |
753 | POSTCODE_SEVERITY_ERR); | |
754 | return; | |
755 | } | |
756 | ||
757 | /* get saved crash message offset */ | |
758 | if (visorchannel_read(ControlVm_channel, | |
759 | offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, | |
760 | SavedCrashMsgOffset), | |
761 | &localSavedCrashMsgOffset, sizeof(U32)) < 0) { | |
762 | LOGERR("failed to get Saved Message Offset"); | |
763 | POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC, | |
764 | POSTCODE_SEVERITY_ERR); | |
765 | return; | |
766 | } | |
767 | ||
768 | if (type == CRASH_bus) { | |
769 | if (visorchannel_write(ControlVm_channel, | |
770 | localSavedCrashMsgOffset, | |
771 | msg, sizeof(CONTROLVM_MESSAGE)) < 0) { | |
772 | LOGERR("SAVE_MSG_BUS_FAILURE: Failed to write CrashCreateBusMsg!"); | |
773 | POSTCODE_LINUX_2(SAVE_MSG_BUS_FAILURE_PC, | |
774 | POSTCODE_SEVERITY_ERR); | |
775 | return; | |
776 | } | |
777 | } else { | |
778 | if (visorchannel_write(ControlVm_channel, | |
779 | localSavedCrashMsgOffset + | |
780 | sizeof(CONTROLVM_MESSAGE), msg, | |
781 | sizeof(CONTROLVM_MESSAGE)) < 0) { | |
782 | LOGERR("SAVE_MSG_DEV_FAILURE: Failed to write CrashCreateDevMsg!"); | |
783 | POSTCODE_LINUX_2(SAVE_MSG_DEV_FAILURE_PC, | |
784 | POSTCODE_SEVERITY_ERR); | |
785 | return; | |
786 | } | |
787 | } | |
788 | } | |
789 | EXPORT_SYMBOL_GPL(visorchipset_save_message); | |
790 | ||
791 | static void | |
792 | bus_responder(CONTROLVM_ID cmdId, ulong busNo, int response) | |
793 | { | |
794 | VISORCHIPSET_BUS_INFO *p = NULL; | |
795 | BOOL need_clear = FALSE; | |
796 | ||
797 | p = findbus(&BusInfoList, busNo); | |
798 | if (!p) { | |
799 | LOGERR("internal error busNo=%lu", busNo); | |
800 | return; | |
801 | } | |
802 | if (response < 0) { | |
803 | if ((cmdId == CONTROLVM_BUS_CREATE) && | |
804 | (response != (-CONTROLVM_RESP_ERROR_ALREADY_DONE))) | |
805 | /* undo the row we just created... */ | |
806 | delbusdevices(&DevInfoList, busNo); | |
807 | } else { | |
808 | if (cmdId == CONTROLVM_BUS_CREATE) | |
809 | p->state.created = 1; | |
810 | if (cmdId == CONTROLVM_BUS_DESTROY) | |
811 | need_clear = TRUE; | |
812 | } | |
813 | ||
814 | if (p->pendingMsgHdr.Id == CONTROLVM_INVALID) { | |
815 | LOGERR("bus_responder no pending msg"); | |
816 | return; /* no controlvm response needed */ | |
817 | } | |
818 | if (p->pendingMsgHdr.Id != (U32) cmdId) { | |
819 | LOGERR("expected=%d, found=%d", cmdId, p->pendingMsgHdr.Id); | |
820 | return; | |
821 | } | |
822 | controlvm_respond(&p->pendingMsgHdr, response); | |
823 | p->pendingMsgHdr.Id = CONTROLVM_INVALID; | |
824 | if (need_clear) { | |
825 | busInfo_clear(p); | |
826 | delbusdevices(&DevInfoList, busNo); | |
827 | } | |
828 | } | |
829 | ||
830 | static void | |
831 | device_changestate_responder(CONTROLVM_ID cmdId, | |
832 | ulong busNo, ulong devNo, int response, | |
833 | ULTRA_SEGMENT_STATE responseState) | |
834 | { | |
835 | VISORCHIPSET_DEVICE_INFO *p = NULL; | |
836 | CONTROLVM_MESSAGE outmsg; | |
837 | ||
838 | if (!ControlVm_channel) | |
839 | return; | |
840 | ||
841 | p = finddevice(&DevInfoList, busNo, devNo); | |
842 | if (!p) { | |
843 | LOGERR("internal error; busNo=%lu, devNo=%lu", busNo, devNo); | |
844 | return; | |
845 | } | |
846 | if (p->pendingMsgHdr.Id == CONTROLVM_INVALID) { | |
847 | LOGERR("device_responder no pending msg"); | |
848 | return; /* no controlvm response needed */ | |
849 | } | |
850 | if (p->pendingMsgHdr.Id != cmdId) { | |
851 | LOGERR("expected=%d, found=%d", cmdId, p->pendingMsgHdr.Id); | |
852 | return; | |
853 | } | |
854 | ||
855 | controlvm_init_response(&outmsg, &p->pendingMsgHdr, response); | |
856 | ||
857 | outmsg.cmd.deviceChangeState.busNo = busNo; | |
858 | outmsg.cmd.deviceChangeState.devNo = devNo; | |
859 | outmsg.cmd.deviceChangeState.state = responseState; | |
860 | ||
861 | if (!visorchannel_signalinsert(ControlVm_channel, | |
862 | CONTROLVM_QUEUE_REQUEST, &outmsg)) { | |
863 | LOGERR("signalinsert failed!"); | |
864 | return; | |
865 | } | |
866 | ||
867 | p->pendingMsgHdr.Id = CONTROLVM_INVALID; | |
868 | } | |
869 | ||
870 | static void | |
871 | device_responder(CONTROLVM_ID cmdId, ulong busNo, ulong devNo, int response) | |
872 | { | |
873 | VISORCHIPSET_DEVICE_INFO *p = NULL; | |
874 | BOOL need_clear = FALSE; | |
875 | ||
876 | p = finddevice(&DevInfoList, busNo, devNo); | |
877 | if (!p) { | |
878 | LOGERR("internal error; busNo=%lu, devNo=%lu", busNo, devNo); | |
879 | return; | |
880 | } | |
881 | if (response >= 0) { | |
882 | if (cmdId == CONTROLVM_DEVICE_CREATE) | |
883 | p->state.created = 1; | |
884 | if (cmdId == CONTROLVM_DEVICE_DESTROY) | |
885 | need_clear = TRUE; | |
886 | } | |
887 | ||
888 | if (p->pendingMsgHdr.Id == CONTROLVM_INVALID) { | |
889 | LOGERR("device_responder no pending msg"); | |
890 | return; /* no controlvm response needed */ | |
891 | } | |
892 | if (p->pendingMsgHdr.Id != (U32) cmdId) { | |
893 | LOGERR("expected=%d, found=%d", cmdId, p->pendingMsgHdr.Id); | |
894 | return; | |
895 | } | |
896 | controlvm_respond(&p->pendingMsgHdr, response); | |
897 | p->pendingMsgHdr.Id = CONTROLVM_INVALID; | |
898 | if (need_clear) | |
899 | devInfo_clear(p); | |
900 | } | |
901 | ||
902 | static void | |
903 | bus_epilog(U32 busNo, | |
904 | U32 cmd, CONTROLVM_MESSAGE_HEADER *msgHdr, | |
905 | int response, BOOL needResponse) | |
906 | { | |
907 | BOOL notified = FALSE; | |
908 | ||
909 | VISORCHIPSET_BUS_INFO *pBusInfo = findbus(&BusInfoList, busNo); | |
910 | ||
911 | if (!pBusInfo) { | |
912 | LOGERR("HUH? bad busNo=%d", busNo); | |
913 | return; | |
914 | } | |
915 | if (needResponse) { | |
916 | memcpy(&pBusInfo->pendingMsgHdr, msgHdr, | |
917 | sizeof(CONTROLVM_MESSAGE_HEADER)); | |
918 | } else | |
919 | pBusInfo->pendingMsgHdr.Id = CONTROLVM_INVALID; | |
920 | ||
921 | LOCKSEM_UNINTERRUPTIBLE(&NotifierLock); | |
922 | if (response == CONTROLVM_RESP_SUCCESS) { | |
923 | switch (cmd) { | |
924 | case CONTROLVM_BUS_CREATE: | |
925 | /* We can't tell from the bus_create | |
926 | * information which of our 2 bus flavors the | |
927 | * devices on this bus will ultimately end up. | |
928 | * FORTUNATELY, it turns out it is harmless to | |
929 | * send the bus_create to both of them. We can | |
930 | * narrow things down a little bit, though, | |
931 | * because we know: - BusDev_Server can handle | |
932 | * either server or client devices | |
933 | * - BusDev_Client can handle ONLY client | |
934 | * devices */ | |
935 | if (BusDev_Server_Notifiers.bus_create) { | |
936 | (*BusDev_Server_Notifiers.bus_create) (busNo); | |
937 | notified = TRUE; | |
938 | } | |
939 | if ((!pBusInfo->flags.server) /*client */ && | |
940 | BusDev_Client_Notifiers.bus_create) { | |
941 | (*BusDev_Client_Notifiers.bus_create) (busNo); | |
942 | notified = TRUE; | |
943 | } | |
944 | break; | |
945 | case CONTROLVM_BUS_DESTROY: | |
946 | if (BusDev_Server_Notifiers.bus_destroy) { | |
947 | (*BusDev_Server_Notifiers.bus_destroy) (busNo); | |
948 | notified = TRUE; | |
949 | } | |
950 | if ((!pBusInfo->flags.server) /*client */ && | |
951 | BusDev_Client_Notifiers.bus_destroy) { | |
952 | (*BusDev_Client_Notifiers.bus_destroy) (busNo); | |
953 | notified = TRUE; | |
954 | } | |
955 | break; | |
956 | } | |
957 | } | |
958 | if (notified) | |
959 | /* The callback function just called above is responsible | |
960 | * for calling the appropriate VISORCHIPSET_BUSDEV_RESPONDERS | |
961 | * function, which will call bus_responder() | |
962 | */ | |
963 | ; | |
964 | else | |
965 | bus_responder(cmd, busNo, response); | |
966 | UNLOCKSEM(&NotifierLock); | |
967 | } | |
968 | ||
969 | static void | |
970 | device_epilog(U32 busNo, U32 devNo, ULTRA_SEGMENT_STATE state, U32 cmd, | |
971 | CONTROLVM_MESSAGE_HEADER *msgHdr, int response, | |
972 | BOOL needResponse, BOOL for_visorbus) | |
973 | { | |
974 | VISORCHIPSET_BUSDEV_NOTIFIERS *notifiers = NULL; | |
975 | BOOL notified = FALSE; | |
976 | ||
977 | VISORCHIPSET_DEVICE_INFO *pDevInfo = | |
978 | finddevice(&DevInfoList, busNo, devNo); | |
979 | char *envp[] = { | |
980 | "SPARSP_DIAGPOOL_PAUSED_STATE = 1", | |
981 | NULL | |
982 | }; | |
983 | ||
984 | if (!pDevInfo) { | |
985 | LOGERR("HUH? bad busNo=%d, devNo=%d", busNo, devNo); | |
986 | return; | |
987 | } | |
988 | if (for_visorbus) | |
989 | notifiers = &BusDev_Server_Notifiers; | |
990 | else | |
991 | notifiers = &BusDev_Client_Notifiers; | |
992 | if (needResponse) { | |
993 | memcpy(&pDevInfo->pendingMsgHdr, msgHdr, | |
994 | sizeof(CONTROLVM_MESSAGE_HEADER)); | |
995 | } else | |
996 | pDevInfo->pendingMsgHdr.Id = CONTROLVM_INVALID; | |
997 | ||
998 | LOCKSEM_UNINTERRUPTIBLE(&NotifierLock); | |
999 | if (response >= 0) { | |
1000 | switch (cmd) { | |
1001 | case CONTROLVM_DEVICE_CREATE: | |
1002 | if (notifiers->device_create) { | |
1003 | (*notifiers->device_create) (busNo, devNo); | |
1004 | notified = TRUE; | |
1005 | } | |
1006 | break; | |
1007 | case CONTROLVM_DEVICE_CHANGESTATE: | |
1008 | /* ServerReady / ServerRunning / SegmentStateRunning */ | |
1009 | if (state.Alive == SegmentStateRunning.Alive && | |
1010 | state.Operating == SegmentStateRunning.Operating) { | |
1011 | if (notifiers->device_resume) { | |
1012 | (*notifiers->device_resume) (busNo, | |
1013 | devNo); | |
1014 | notified = TRUE; | |
1015 | } | |
1016 | } | |
1017 | /* ServerNotReady / ServerLost / SegmentStateStandby */ | |
1018 | else if (state.Alive == SegmentStateStandby.Alive && | |
1019 | state.Operating == | |
1020 | SegmentStateStandby.Operating) { | |
1021 | /* technically this is standby case | |
1022 | * where server is lost | |
1023 | */ | |
1024 | if (notifiers->device_pause) { | |
1025 | (*notifiers->device_pause) (busNo, | |
1026 | devNo); | |
1027 | notified = TRUE; | |
1028 | } | |
1029 | } else if (state.Alive == SegmentStatePaused.Alive && | |
1030 | state.Operating == | |
1031 | SegmentStatePaused.Operating) { | |
1032 | /* this is lite pause where channel is | |
1033 | * still valid just 'pause' of it | |
1034 | */ | |
1035 | if (busNo == g_diagpoolBusNo | |
1036 | && devNo == g_diagpoolDevNo) { | |
1037 | LOGINF("DEVICE_CHANGESTATE(DiagpoolChannel busNo=%d devNo=%d is pausing...)", | |
1038 | busNo, devNo); | |
1039 | /* this will trigger the | |
1040 | * diag_shutdown.sh script in | |
1041 | * the visorchipset hotplug */ | |
1042 | kobject_uevent_env | |
1043 | (&Visorchipset_platform_device.dev. | |
1044 | kobj, KOBJ_ONLINE, envp); | |
1045 | } | |
1046 | } | |
1047 | break; | |
1048 | case CONTROLVM_DEVICE_DESTROY: | |
1049 | if (notifiers->device_destroy) { | |
1050 | (*notifiers->device_destroy) (busNo, devNo); | |
1051 | notified = TRUE; | |
1052 | } | |
1053 | break; | |
1054 | } | |
1055 | } | |
1056 | if (notified) | |
1057 | /* The callback function just called above is responsible | |
1058 | * for calling the appropriate VISORCHIPSET_BUSDEV_RESPONDERS | |
1059 | * function, which will call device_responder() | |
1060 | */ | |
1061 | ; | |
1062 | else | |
1063 | device_responder(cmd, busNo, devNo, response); | |
1064 | UNLOCKSEM(&NotifierLock); | |
1065 | } | |
1066 | ||
1067 | static void | |
1068 | bus_create(CONTROLVM_MESSAGE *inmsg) | |
1069 | { | |
1070 | CONTROLVM_MESSAGE_PACKET *cmd = &inmsg->cmd; | |
1071 | ulong busNo = cmd->createBus.busNo; | |
1072 | int rc = CONTROLVM_RESP_SUCCESS; | |
1073 | VISORCHIPSET_BUS_INFO *pBusInfo = NULL; | |
1074 | ||
1075 | ||
1076 | pBusInfo = findbus(&BusInfoList, busNo); | |
1077 | if (pBusInfo && (pBusInfo->state.created == 1)) { | |
1078 | LOGERR("CONTROLVM_BUS_CREATE Failed: bus %lu already exists", | |
1079 | busNo); | |
1080 | POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, busNo, | |
1081 | POSTCODE_SEVERITY_ERR); | |
1082 | RETINT(-CONTROLVM_RESP_ERROR_ALREADY_DONE); | |
1083 | } | |
97a84f12 | 1084 | pBusInfo = kzalloc(sizeof(VISORCHIPSET_BUS_INFO), GFP_KERNEL); |
12e364b9 | 1085 | if (pBusInfo == NULL) { |
97a84f12 | 1086 | LOGERR("CONTROLVM_BUS_CREATE Failed: bus %lu kzalloc failed", |
12e364b9 KC |
1087 | busNo); |
1088 | POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, busNo, | |
1089 | POSTCODE_SEVERITY_ERR); | |
1090 | RETINT(-CONTROLVM_RESP_ERROR_KMALLOC_FAILED); | |
1091 | } | |
1092 | ||
12e364b9 KC |
1093 | INIT_LIST_HEAD(&pBusInfo->entry); |
1094 | pBusInfo->busNo = busNo; | |
1095 | pBusInfo->devNo = cmd->createBus.deviceCount; | |
1096 | ||
1097 | POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, busNo, POSTCODE_SEVERITY_INFO); | |
1098 | ||
1099 | if (inmsg->hdr.Flags.testMessage == 1) | |
1100 | pBusInfo->chanInfo.addrType = ADDRTYPE_localTest; | |
1101 | else | |
1102 | pBusInfo->chanInfo.addrType = ADDRTYPE_localPhysical; | |
1103 | ||
1104 | pBusInfo->flags.server = inmsg->hdr.Flags.server; | |
1105 | pBusInfo->chanInfo.channelAddr = cmd->createBus.channelAddr; | |
1106 | pBusInfo->chanInfo.nChannelBytes = cmd->createBus.channelBytes; | |
1107 | pBusInfo->chanInfo.channelTypeGuid = cmd->createBus.busDataTypeGuid; | |
1108 | pBusInfo->chanInfo.channelInstGuid = cmd->createBus.busInstGuid; | |
1109 | ||
1110 | list_add(&pBusInfo->entry, &BusInfoList); | |
1111 | ||
1112 | POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, busNo, POSTCODE_SEVERITY_INFO); | |
1113 | ||
1114 | Away: | |
1115 | bus_epilog(busNo, CONTROLVM_BUS_CREATE, &inmsg->hdr, | |
1116 | rc, inmsg->hdr.Flags.responseExpected == 1); | |
1117 | } | |
1118 | ||
1119 | static void | |
1120 | bus_destroy(CONTROLVM_MESSAGE *inmsg) | |
1121 | { | |
1122 | CONTROLVM_MESSAGE_PACKET *cmd = &inmsg->cmd; | |
1123 | ulong busNo = cmd->destroyBus.busNo; | |
1124 | VISORCHIPSET_BUS_INFO *pBusInfo; | |
1125 | int rc = CONTROLVM_RESP_SUCCESS; | |
1126 | ||
1127 | pBusInfo = findbus(&BusInfoList, busNo); | |
1128 | if (!pBusInfo) { | |
1129 | LOGERR("CONTROLVM_BUS_DESTROY Failed: bus %lu invalid", busNo); | |
1130 | RETINT(-CONTROLVM_RESP_ERROR_BUS_INVALID); | |
1131 | } | |
1132 | if (pBusInfo->state.created == 0) { | |
1133 | LOGERR("CONTROLVM_BUS_DESTROY Failed: bus %lu already destroyed", | |
1134 | busNo); | |
1135 | RETINT(-CONTROLVM_RESP_ERROR_ALREADY_DONE); | |
1136 | } | |
1137 | ||
1138 | Away: | |
1139 | bus_epilog(busNo, CONTROLVM_BUS_DESTROY, &inmsg->hdr, | |
1140 | rc, inmsg->hdr.Flags.responseExpected == 1); | |
1141 | } | |
1142 | ||
1143 | static void | |
1144 | bus_configure(CONTROLVM_MESSAGE *inmsg, PARSER_CONTEXT *parser_ctx) | |
1145 | { | |
1146 | CONTROLVM_MESSAGE_PACKET *cmd = &inmsg->cmd; | |
1147 | ulong busNo = cmd->configureBus.busNo; | |
1148 | VISORCHIPSET_BUS_INFO *pBusInfo = NULL; | |
1149 | int rc = CONTROLVM_RESP_SUCCESS; | |
1150 | char s[99]; | |
1151 | ||
1152 | busNo = cmd->configureBus.busNo; | |
1153 | POSTCODE_LINUX_3(BUS_CONFIGURE_ENTRY_PC, busNo, POSTCODE_SEVERITY_INFO); | |
1154 | ||
1155 | pBusInfo = findbus(&BusInfoList, busNo); | |
1156 | if (!pBusInfo) { | |
1157 | LOGERR("CONTROLVM_BUS_CONFIGURE Failed: bus %lu invalid", | |
1158 | busNo); | |
1159 | POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, busNo, | |
1160 | POSTCODE_SEVERITY_ERR); | |
1161 | RETINT(-CONTROLVM_RESP_ERROR_BUS_INVALID); | |
1162 | } | |
1163 | if (pBusInfo->state.created == 0) { | |
1164 | LOGERR("CONTROLVM_BUS_CONFIGURE Failed: Invalid bus %lu - not created yet", | |
1165 | busNo); | |
1166 | POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, busNo, | |
1167 | POSTCODE_SEVERITY_ERR); | |
1168 | RETINT(-CONTROLVM_RESP_ERROR_BUS_INVALID); | |
1169 | } | |
1170 | /* TBD - add this check to other commands also... */ | |
1171 | if (pBusInfo->pendingMsgHdr.Id != CONTROLVM_INVALID) { | |
1172 | LOGERR("CONTROLVM_BUS_CONFIGURE Failed: bus %lu MsgId=%u outstanding", | |
1173 | busNo, (uint) pBusInfo->pendingMsgHdr.Id); | |
1174 | POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, busNo, | |
1175 | POSTCODE_SEVERITY_ERR); | |
1176 | RETINT(-CONTROLVM_RESP_ERROR_MESSAGE_ID_INVALID_FOR_CLIENT); | |
1177 | } | |
1178 | ||
1179 | pBusInfo->partitionHandle = cmd->configureBus.guestHandle; | |
1180 | pBusInfo->partitionGuid = parser_id_get(parser_ctx); | |
1181 | parser_param_start(parser_ctx, PARSERSTRING_NAME); | |
1182 | pBusInfo->name = parser_string_get(parser_ctx); | |
1183 | ||
1184 | visorchannel_GUID_id(&pBusInfo->partitionGuid, s); | |
1185 | pBusInfo->procObject = | |
927c7927 | 1186 | visor_proc_CreateObject(PartitionType, s, (void *) (pBusInfo)); |
12e364b9 KC |
1187 | if (pBusInfo->procObject == NULL) { |
1188 | LOGERR("CONTROLVM_BUS_CONFIGURE Failed: busNo=%lu failed to create /proc entry", | |
1189 | busNo); | |
1190 | POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, busNo, | |
1191 | POSTCODE_SEVERITY_ERR); | |
1192 | RETINT(-CONTROLVM_RESP_ERROR_KMALLOC_FAILED); | |
1193 | } | |
1194 | POSTCODE_LINUX_3(BUS_CONFIGURE_EXIT_PC, busNo, POSTCODE_SEVERITY_INFO); | |
1195 | Away: | |
1196 | bus_epilog(busNo, CONTROLVM_BUS_CONFIGURE, &inmsg->hdr, | |
1197 | rc, inmsg->hdr.Flags.responseExpected == 1); | |
1198 | } | |
1199 | ||
1200 | static void | |
1201 | my_device_create(CONTROLVM_MESSAGE *inmsg) | |
1202 | { | |
1203 | CONTROLVM_MESSAGE_PACKET *cmd = &inmsg->cmd; | |
1204 | ulong busNo = cmd->createDevice.busNo; | |
1205 | ulong devNo = cmd->createDevice.devNo; | |
1206 | VISORCHIPSET_DEVICE_INFO *pDevInfo = NULL; | |
1207 | VISORCHIPSET_BUS_INFO *pBusInfo = NULL; | |
1208 | int rc = CONTROLVM_RESP_SUCCESS; | |
1209 | ||
1210 | pDevInfo = finddevice(&DevInfoList, busNo, devNo); | |
1211 | if (pDevInfo && (pDevInfo->state.created == 1)) { | |
1212 | LOGERR("CONTROLVM_DEVICE_CREATE Failed: busNo=%lu, devNo=%lu already exists", | |
1213 | busNo, devNo); | |
1214 | POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, devNo, busNo, | |
1215 | POSTCODE_SEVERITY_ERR); | |
1216 | RETINT(-CONTROLVM_RESP_ERROR_ALREADY_DONE); | |
1217 | } | |
1218 | pBusInfo = findbus(&BusInfoList, busNo); | |
1219 | if (!pBusInfo) { | |
1220 | LOGERR("CONTROLVM_DEVICE_CREATE Failed: Invalid bus %lu - out of range", | |
1221 | busNo); | |
1222 | POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, devNo, busNo, | |
1223 | POSTCODE_SEVERITY_ERR); | |
1224 | RETINT(-CONTROLVM_RESP_ERROR_BUS_INVALID); | |
1225 | } | |
1226 | if (pBusInfo->state.created == 0) { | |
1227 | LOGERR("CONTROLVM_DEVICE_CREATE Failed: Invalid bus %lu - not created yet", | |
1228 | busNo); | |
1229 | POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, devNo, busNo, | |
1230 | POSTCODE_SEVERITY_ERR); | |
1231 | RETINT(-CONTROLVM_RESP_ERROR_BUS_INVALID); | |
1232 | } | |
97a84f12 | 1233 | pDevInfo = kzalloc(sizeof(VISORCHIPSET_DEVICE_INFO), GFP_KERNEL); |
12e364b9 KC |
1234 | if (pDevInfo == NULL) { |
1235 | LOGERR("CONTROLVM_DEVICE_CREATE Failed: busNo=%lu, devNo=%lu kmaloc failed", | |
1236 | busNo, devNo); | |
1237 | POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, devNo, busNo, | |
1238 | POSTCODE_SEVERITY_ERR); | |
1239 | RETINT(-CONTROLVM_RESP_ERROR_KMALLOC_FAILED); | |
1240 | } | |
97a84f12 | 1241 | |
12e364b9 KC |
1242 | INIT_LIST_HEAD(&pDevInfo->entry); |
1243 | pDevInfo->busNo = busNo; | |
1244 | pDevInfo->devNo = devNo; | |
1245 | pDevInfo->devInstGuid = cmd->createDevice.devInstGuid; | |
1246 | POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, devNo, busNo, | |
1247 | POSTCODE_SEVERITY_INFO); | |
1248 | ||
1249 | if (inmsg->hdr.Flags.testMessage == 1) | |
1250 | pDevInfo->chanInfo.addrType = ADDRTYPE_localTest; | |
1251 | else | |
1252 | pDevInfo->chanInfo.addrType = ADDRTYPE_localPhysical; | |
1253 | pDevInfo->chanInfo.channelAddr = cmd->createDevice.channelAddr; | |
1254 | pDevInfo->chanInfo.nChannelBytes = cmd->createDevice.channelBytes; | |
1255 | pDevInfo->chanInfo.channelTypeGuid = cmd->createDevice.dataTypeGuid; | |
1256 | pDevInfo->chanInfo.intr = cmd->createDevice.intr; | |
1257 | list_add(&pDevInfo->entry, &DevInfoList); | |
1258 | POSTCODE_LINUX_4(DEVICE_CREATE_EXIT_PC, devNo, busNo, | |
1259 | POSTCODE_SEVERITY_INFO); | |
1260 | Away: | |
1261 | /* get the bus and devNo for DiagPool channel */ | |
1262 | if (is_diagpool_channel(pDevInfo->chanInfo.channelTypeGuid)) { | |
1263 | g_diagpoolBusNo = busNo; | |
1264 | g_diagpoolDevNo = devNo; | |
1265 | LOGINF("CONTROLVM_DEVICE_CREATE for DiagPool channel: busNo=%lu, devNo=%lu", | |
1266 | g_diagpoolBusNo, g_diagpoolDevNo); | |
1267 | } | |
1268 | device_epilog(busNo, devNo, SegmentStateRunning, | |
1269 | CONTROLVM_DEVICE_CREATE, &inmsg->hdr, rc, | |
1270 | inmsg->hdr.Flags.responseExpected == 1, | |
1271 | FOR_VISORBUS(pDevInfo->chanInfo.channelTypeGuid)); | |
1272 | } | |
1273 | ||
1274 | static void | |
1275 | my_device_changestate(CONTROLVM_MESSAGE *inmsg) | |
1276 | { | |
1277 | CONTROLVM_MESSAGE_PACKET *cmd = &inmsg->cmd; | |
1278 | ulong busNo = cmd->deviceChangeState.busNo; | |
1279 | ulong devNo = cmd->deviceChangeState.devNo; | |
1280 | ULTRA_SEGMENT_STATE state = cmd->deviceChangeState.state; | |
1281 | VISORCHIPSET_DEVICE_INFO *pDevInfo = NULL; | |
1282 | int rc = CONTROLVM_RESP_SUCCESS; | |
1283 | ||
1284 | pDevInfo = finddevice(&DevInfoList, busNo, devNo); | |
1285 | if (!pDevInfo) { | |
1286 | LOGERR("CONTROLVM_DEVICE_CHANGESTATE Failed: busNo=%lu, devNo=%lu invalid (doesn't exist)", | |
1287 | busNo, devNo); | |
1288 | POSTCODE_LINUX_4(DEVICE_CHANGESTATE_FAILURE_PC, devNo, busNo, | |
1289 | POSTCODE_SEVERITY_ERR); | |
1290 | RETINT(-CONTROLVM_RESP_ERROR_DEVICE_INVALID); | |
1291 | } | |
1292 | if (pDevInfo->state.created == 0) { | |
1293 | LOGERR("CONTROLVM_DEVICE_CHANGESTATE Failed: busNo=%lu, devNo=%lu invalid (not created)", | |
1294 | busNo, devNo); | |
1295 | POSTCODE_LINUX_4(DEVICE_CHANGESTATE_FAILURE_PC, devNo, busNo, | |
1296 | POSTCODE_SEVERITY_ERR); | |
1297 | RETINT(-CONTROLVM_RESP_ERROR_DEVICE_INVALID); | |
1298 | } | |
1299 | Away: | |
1300 | if ((rc >= CONTROLVM_RESP_SUCCESS) && pDevInfo) | |
1301 | device_epilog(busNo, devNo, state, CONTROLVM_DEVICE_CHANGESTATE, | |
1302 | &inmsg->hdr, rc, | |
1303 | inmsg->hdr.Flags.responseExpected == 1, | |
1304 | FOR_VISORBUS(pDevInfo->chanInfo.channelTypeGuid)); | |
1305 | } | |
1306 | ||
1307 | static void | |
1308 | my_device_destroy(CONTROLVM_MESSAGE *inmsg) | |
1309 | { | |
1310 | CONTROLVM_MESSAGE_PACKET *cmd = &inmsg->cmd; | |
1311 | ulong busNo = cmd->destroyDevice.busNo; | |
1312 | ulong devNo = cmd->destroyDevice.devNo; | |
1313 | VISORCHIPSET_DEVICE_INFO *pDevInfo = NULL; | |
1314 | int rc = CONTROLVM_RESP_SUCCESS; | |
1315 | ||
1316 | pDevInfo = finddevice(&DevInfoList, busNo, devNo); | |
1317 | if (!pDevInfo) { | |
1318 | LOGERR("CONTROLVM_DEVICE_DESTROY Failed: busNo=%lu, devNo=%lu invalid", | |
1319 | busNo, devNo); | |
1320 | RETINT(-CONTROLVM_RESP_ERROR_DEVICE_INVALID); | |
1321 | } | |
1322 | if (pDevInfo->state.created == 0) { | |
1323 | LOGERR("CONTROLVM_DEVICE_DESTROY Failed: busNo=%lu, devNo=%lu already destroyed", | |
1324 | busNo, devNo); | |
1325 | RETINT(-CONTROLVM_RESP_ERROR_ALREADY_DONE); | |
1326 | } | |
1327 | ||
1328 | Away: | |
1329 | if ((rc >= CONTROLVM_RESP_SUCCESS) && pDevInfo) | |
1330 | device_epilog(busNo, devNo, SegmentStateRunning, | |
1331 | CONTROLVM_DEVICE_DESTROY, &inmsg->hdr, rc, | |
1332 | inmsg->hdr.Flags.responseExpected == 1, | |
1333 | FOR_VISORBUS(pDevInfo->chanInfo.channelTypeGuid)); | |
1334 | } | |
1335 | ||
1336 | /* When provided with the physical address of the controlvm channel | |
1337 | * (phys_addr), the offset to the payload area we need to manage | |
1338 | * (offset), and the size of this payload area (bytes), fills in the | |
1339 | * CONTROLVM_PAYLOAD_INFO struct. Returns TRUE for success or FALSE | |
1340 | * for failure. | |
1341 | */ | |
1342 | static int | |
1343 | initialize_controlvm_payload_info(HOSTADDRESS phys_addr, U64 offset, U32 bytes, | |
1344 | CONTROLVM_PAYLOAD_INFO *info) | |
1345 | { | |
bd5b9b32 | 1346 | U8 __iomem *payload = NULL; |
12e364b9 KC |
1347 | int rc = CONTROLVM_RESP_SUCCESS; |
1348 | ||
1349 | if (info == NULL) { | |
1350 | LOGERR("HUH ? CONTROLVM_PAYLOAD_INIT Failed : Programmer check at %s:%d", | |
1351 | __FILE__, __LINE__); | |
1352 | RETINT(-CONTROLVM_RESP_ERROR_PAYLOAD_INVALID); | |
1353 | } | |
1354 | memset(info, 0, sizeof(CONTROLVM_PAYLOAD_INFO)); | |
1355 | if ((offset == 0) || (bytes == 0)) { | |
1356 | LOGERR("CONTROLVM_PAYLOAD_INIT Failed: RequestPayloadOffset=%llu RequestPayloadBytes=%llu!", | |
1357 | (u64) offset, (u64) bytes); | |
1358 | RETINT(-CONTROLVM_RESP_ERROR_PAYLOAD_INVALID); | |
1359 | } | |
1360 | payload = ioremap_cache(phys_addr + offset, bytes); | |
1361 | if (payload == NULL) { | |
1362 | LOGERR("CONTROLVM_PAYLOAD_INIT Failed: ioremap_cache %llu for %llu bytes failed", | |
1363 | (u64) offset, (u64) bytes); | |
1364 | RETINT(-CONTROLVM_RESP_ERROR_IOREMAP_FAILED); | |
1365 | } | |
1366 | ||
1367 | info->offset = offset; | |
1368 | info->bytes = bytes; | |
1369 | info->ptr = payload; | |
1370 | LOGINF("offset=%llu, bytes=%lu, ptr=%p", | |
1371 | (u64) (info->offset), (ulong) (info->bytes), info->ptr); | |
1372 | ||
1373 | Away: | |
1374 | if (rc < 0) { | |
1375 | if (payload != NULL) { | |
1376 | iounmap(payload); | |
1377 | payload = NULL; | |
1378 | } | |
1379 | } | |
1380 | return rc; | |
1381 | } | |
1382 | ||
1383 | static void | |
1384 | destroy_controlvm_payload_info(CONTROLVM_PAYLOAD_INFO *info) | |
1385 | { | |
1386 | if (info->ptr != NULL) { | |
1387 | iounmap(info->ptr); | |
1388 | info->ptr = NULL; | |
1389 | } | |
1390 | memset(info, 0, sizeof(CONTROLVM_PAYLOAD_INFO)); | |
1391 | } | |
1392 | ||
1393 | static void | |
1394 | initialize_controlvm_payload(void) | |
1395 | { | |
1396 | HOSTADDRESS phys_addr = visorchannel_get_physaddr(ControlVm_channel); | |
1397 | U64 payloadOffset = 0; | |
1398 | U32 payloadBytes = 0; | |
1399 | if (visorchannel_read(ControlVm_channel, | |
1400 | offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, | |
1401 | RequestPayloadOffset), | |
1402 | &payloadOffset, sizeof(payloadOffset)) < 0) { | |
1403 | LOGERR("CONTROLVM_PAYLOAD_INIT Failed to read controlvm channel!"); | |
1404 | POSTCODE_LINUX_2(CONTROLVM_INIT_FAILURE_PC, | |
1405 | POSTCODE_SEVERITY_ERR); | |
1406 | return; | |
1407 | } | |
1408 | if (visorchannel_read(ControlVm_channel, | |
1409 | offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, | |
1410 | RequestPayloadBytes), | |
1411 | &payloadBytes, sizeof(payloadBytes)) < 0) { | |
1412 | LOGERR("CONTROLVM_PAYLOAD_INIT Failed to read controlvm channel!"); | |
1413 | POSTCODE_LINUX_2(CONTROLVM_INIT_FAILURE_PC, | |
1414 | POSTCODE_SEVERITY_ERR); | |
1415 | return; | |
1416 | } | |
1417 | initialize_controlvm_payload_info(phys_addr, | |
1418 | payloadOffset, payloadBytes, | |
1419 | &ControlVm_payload_info); | |
1420 | } | |
1421 | ||
1422 | /* Send ACTION=online for DEVPATH=/sys/devices/platform/visorchipset. | |
1423 | * Returns CONTROLVM_RESP_xxx code. | |
1424 | */ | |
1425 | int | |
1426 | visorchipset_chipset_ready(void) | |
1427 | { | |
1428 | kobject_uevent(&Visorchipset_platform_device.dev.kobj, KOBJ_ONLINE); | |
1429 | return CONTROLVM_RESP_SUCCESS; | |
1430 | } | |
1431 | EXPORT_SYMBOL_GPL(visorchipset_chipset_ready); | |
1432 | ||
1433 | int | |
1434 | visorchipset_chipset_selftest(void) | |
1435 | { | |
1436 | char env_selftest[20]; | |
1437 | char *envp[] = { env_selftest, NULL }; | |
1438 | sprintf(env_selftest, "SPARSP_SELFTEST=%d", 1); | |
1439 | kobject_uevent_env(&Visorchipset_platform_device.dev.kobj, KOBJ_CHANGE, | |
1440 | envp); | |
1441 | return CONTROLVM_RESP_SUCCESS; | |
1442 | } | |
1443 | EXPORT_SYMBOL_GPL(visorchipset_chipset_selftest); | |
1444 | ||
1445 | /* Send ACTION=offline for DEVPATH=/sys/devices/platform/visorchipset. | |
1446 | * Returns CONTROLVM_RESP_xxx code. | |
1447 | */ | |
1448 | int | |
1449 | visorchipset_chipset_notready(void) | |
1450 | { | |
1451 | kobject_uevent(&Visorchipset_platform_device.dev.kobj, KOBJ_OFFLINE); | |
1452 | return CONTROLVM_RESP_SUCCESS; | |
1453 | } | |
1454 | EXPORT_SYMBOL_GPL(visorchipset_chipset_notready); | |
1455 | ||
1456 | static void | |
1457 | chipset_ready(CONTROLVM_MESSAGE_HEADER *msgHdr) | |
1458 | { | |
1459 | int rc = visorchipset_chipset_ready(); | |
1460 | if (rc != CONTROLVM_RESP_SUCCESS) | |
1461 | rc = -rc; | |
1462 | if (msgHdr->Flags.responseExpected && !visorchipset_holdchipsetready) | |
1463 | controlvm_respond(msgHdr, rc); | |
1464 | if (msgHdr->Flags.responseExpected && visorchipset_holdchipsetready) { | |
1465 | /* Send CHIPSET_READY response when all modules have been loaded | |
1466 | * and disks mounted for the partition | |
1467 | */ | |
1468 | g_ChipSetMsgHdr = *msgHdr; | |
1469 | LOGINF("Holding CHIPSET_READY response"); | |
1470 | } | |
1471 | } | |
1472 | ||
1473 | static void | |
1474 | chipset_selftest(CONTROLVM_MESSAGE_HEADER *msgHdr) | |
1475 | { | |
1476 | int rc = visorchipset_chipset_selftest(); | |
1477 | if (rc != CONTROLVM_RESP_SUCCESS) | |
1478 | rc = -rc; | |
1479 | if (msgHdr->Flags.responseExpected) | |
1480 | controlvm_respond(msgHdr, rc); | |
1481 | } | |
1482 | ||
1483 | static void | |
1484 | chipset_notready(CONTROLVM_MESSAGE_HEADER *msgHdr) | |
1485 | { | |
1486 | int rc = visorchipset_chipset_notready(); | |
1487 | if (rc != CONTROLVM_RESP_SUCCESS) | |
1488 | rc = -rc; | |
1489 | if (msgHdr->Flags.responseExpected) | |
1490 | controlvm_respond(msgHdr, rc); | |
1491 | } | |
1492 | ||
1493 | /* This is your "one-stop" shop for grabbing the next message from the | |
1494 | * CONTROLVM_QUEUE_EVENT queue in the controlvm channel. | |
1495 | */ | |
1496 | static BOOL | |
1497 | read_controlvm_event(CONTROLVM_MESSAGE *msg) | |
1498 | { | |
1499 | if (visorchannel_signalremove(ControlVm_channel, | |
1500 | CONTROLVM_QUEUE_EVENT, msg)) { | |
1501 | /* got a message */ | |
1502 | if (msg->hdr.Flags.testMessage == 1) { | |
1503 | LOGERR("ignoring bad CONTROLVM_QUEUE_EVENT msg with controlvm_msg_id=0x%x because Flags.testMessage is nonsensical (=1)", msg->hdr.Id); | |
1504 | return FALSE; | |
1505 | } else | |
1506 | return TRUE; | |
1507 | } | |
1508 | return FALSE; | |
1509 | } | |
1510 | ||
1511 | /* | |
1512 | * The general parahotplug flow works as follows. The visorchipset | |
1513 | * driver receives a DEVICE_CHANGESTATE message from Command | |
1514 | * specifying a physical device to enable or disable. The CONTROLVM | |
1515 | * message handler calls parahotplug_process_message, which then adds | |
1516 | * the message to a global list and kicks off a udev event which | |
1517 | * causes a user level script to enable or disable the specified | |
1518 | * device. The udev script then writes to | |
1519 | * /proc/visorchipset/parahotplug, which causes parahotplug_proc_write | |
1520 | * to get called, at which point the appropriate CONTROLVM message is | |
1521 | * retrieved from the list and responded to. | |
1522 | */ | |
1523 | ||
1524 | #define PARAHOTPLUG_TIMEOUT_MS 2000 | |
1525 | ||
1526 | /* | |
1527 | * Generate unique int to match an outstanding CONTROLVM message with a | |
1528 | * udev script /proc response | |
1529 | */ | |
1530 | static int | |
1531 | parahotplug_next_id(void) | |
1532 | { | |
1533 | static atomic_t id = ATOMIC_INIT(0); | |
1534 | return atomic_inc_return(&id); | |
1535 | } | |
1536 | ||
1537 | /* | |
1538 | * Returns the time (in jiffies) when a CONTROLVM message on the list | |
1539 | * should expire -- PARAHOTPLUG_TIMEOUT_MS in the future | |
1540 | */ | |
1541 | static unsigned long | |
1542 | parahotplug_next_expiration(void) | |
1543 | { | |
1544 | return jiffies + PARAHOTPLUG_TIMEOUT_MS * HZ / 1000; | |
1545 | } | |
1546 | ||
1547 | /* | |
1548 | * Create a parahotplug_request, which is basically a wrapper for a | |
1549 | * CONTROLVM_MESSAGE that we can stick on a list | |
1550 | */ | |
1551 | static struct parahotplug_request * | |
1552 | parahotplug_request_create(CONTROLVM_MESSAGE *msg) | |
1553 | { | |
1554 | struct parahotplug_request *req = | |
1555 | kmalloc(sizeof(struct parahotplug_request), | |
1556 | GFP_KERNEL|__GFP_NORETRY); | |
1557 | if (req == NULL) | |
1558 | return NULL; | |
1559 | ||
1560 | req->id = parahotplug_next_id(); | |
1561 | req->expiration = parahotplug_next_expiration(); | |
1562 | req->msg = *msg; | |
1563 | ||
1564 | return req; | |
1565 | } | |
1566 | ||
1567 | /* | |
1568 | * Free a parahotplug_request. | |
1569 | */ | |
1570 | static void | |
1571 | parahotplug_request_destroy(struct parahotplug_request *req) | |
1572 | { | |
1573 | kfree(req); | |
1574 | } | |
1575 | ||
1576 | /* | |
1577 | * Cause uevent to run the user level script to do the disable/enable | |
1578 | * specified in (the CONTROLVM message in) the specified | |
1579 | * parahotplug_request | |
1580 | */ | |
1581 | static void | |
1582 | parahotplug_request_kickoff(struct parahotplug_request *req) | |
1583 | { | |
1584 | CONTROLVM_MESSAGE_PACKET *cmd = &req->msg.cmd; | |
1585 | char env_cmd[40], env_id[40], env_state[40], env_bus[40], env_dev[40], | |
1586 | env_func[40]; | |
1587 | char *envp[] = { | |
1588 | env_cmd, env_id, env_state, env_bus, env_dev, env_func, NULL | |
1589 | }; | |
1590 | ||
1591 | sprintf(env_cmd, "SPAR_PARAHOTPLUG=1"); | |
1592 | sprintf(env_id, "SPAR_PARAHOTPLUG_ID=%d", req->id); | |
1593 | sprintf(env_state, "SPAR_PARAHOTPLUG_STATE=%d", | |
1594 | cmd->deviceChangeState.state.Active); | |
1595 | sprintf(env_bus, "SPAR_PARAHOTPLUG_BUS=%d", | |
1596 | cmd->deviceChangeState.busNo); | |
1597 | sprintf(env_dev, "SPAR_PARAHOTPLUG_DEVICE=%d", | |
1598 | cmd->deviceChangeState.devNo >> 3); | |
1599 | sprintf(env_func, "SPAR_PARAHOTPLUG_FUNCTION=%d", | |
1600 | cmd->deviceChangeState.devNo & 0x7); | |
1601 | ||
1602 | LOGINF("parahotplug_request_kickoff: state=%d, bdf=%d/%d/%d, id=%u\n", | |
1603 | cmd->deviceChangeState.state.Active, | |
1604 | cmd->deviceChangeState.busNo, cmd->deviceChangeState.devNo >> 3, | |
1605 | cmd->deviceChangeState.devNo & 7, req->id); | |
1606 | ||
1607 | kobject_uevent_env(&Visorchipset_platform_device.dev.kobj, KOBJ_CHANGE, | |
1608 | envp); | |
1609 | } | |
1610 | ||
1611 | /* | |
1612 | * Remove any request from the list that's been on there too long and | |
1613 | * respond with an error. | |
1614 | */ | |
1615 | static void | |
1616 | parahotplug_process_list(void) | |
1617 | { | |
1618 | struct list_head *pos = NULL; | |
1619 | struct list_head *tmp = NULL; | |
1620 | ||
1621 | spin_lock(&Parahotplug_request_list_lock); | |
1622 | ||
1623 | list_for_each_safe(pos, tmp, &Parahotplug_request_list) { | |
1624 | struct parahotplug_request *req = | |
1625 | list_entry(pos, struct parahotplug_request, list); | |
1626 | if (time_after_eq(jiffies, req->expiration)) { | |
1627 | list_del(pos); | |
1628 | if (req->msg.hdr.Flags.responseExpected) | |
1629 | controlvm_respond_physdev_changestate( | |
1630 | &req->msg.hdr, | |
1631 | CONTROLVM_RESP_ERROR_DEVICE_UDEV_TIMEOUT, | |
1632 | req->msg.cmd.deviceChangeState.state); | |
1633 | parahotplug_request_destroy(req); | |
1634 | } | |
1635 | } | |
1636 | ||
1637 | spin_unlock(&Parahotplug_request_list_lock); | |
1638 | } | |
1639 | ||
1640 | /* | |
1641 | * Called from the /proc handler, which means the user script has | |
1642 | * finished the enable/disable. Find the matching identifier, and | |
1643 | * respond to the CONTROLVM message with success. | |
1644 | */ | |
1645 | static int | |
1646 | parahotplug_request_complete(int id, U16 active) | |
1647 | { | |
1648 | struct list_head *pos = NULL; | |
1649 | struct list_head *tmp = NULL; | |
1650 | ||
1651 | spin_lock(&Parahotplug_request_list_lock); | |
1652 | ||
1653 | /* Look for a request matching "id". */ | |
1654 | list_for_each_safe(pos, tmp, &Parahotplug_request_list) { | |
1655 | struct parahotplug_request *req = | |
1656 | list_entry(pos, struct parahotplug_request, list); | |
1657 | if (req->id == id) { | |
1658 | /* Found a match. Remove it from the list and | |
1659 | * respond. | |
1660 | */ | |
1661 | list_del(pos); | |
1662 | spin_unlock(&Parahotplug_request_list_lock); | |
1663 | req->msg.cmd.deviceChangeState.state.Active = active; | |
1664 | if (req->msg.hdr.Flags.responseExpected) | |
1665 | controlvm_respond_physdev_changestate( | |
1666 | &req->msg.hdr, CONTROLVM_RESP_SUCCESS, | |
1667 | req->msg.cmd.deviceChangeState.state); | |
1668 | parahotplug_request_destroy(req); | |
1669 | return 0; | |
1670 | } | |
1671 | } | |
1672 | ||
1673 | spin_unlock(&Parahotplug_request_list_lock); | |
1674 | return -1; | |
1675 | } | |
1676 | ||
1677 | /* | |
1678 | * Enables or disables a PCI device by kicking off a udev script | |
1679 | */ | |
bd5b9b32 | 1680 | static void |
12e364b9 KC |
1681 | parahotplug_process_message(CONTROLVM_MESSAGE *inmsg) |
1682 | { | |
1683 | struct parahotplug_request *req; | |
1684 | ||
1685 | req = parahotplug_request_create(inmsg); | |
1686 | ||
1687 | if (req == NULL) { | |
1688 | LOGERR("parahotplug_process_message: couldn't allocate request"); | |
1689 | return; | |
1690 | } | |
1691 | ||
1692 | if (inmsg->cmd.deviceChangeState.state.Active) { | |
1693 | /* For enable messages, just respond with success | |
1694 | * right away. This is a bit of a hack, but there are | |
1695 | * issues with the early enable messages we get (with | |
1696 | * either the udev script not detecting that the device | |
1697 | * is up, or not getting called at all). Fortunately | |
1698 | * the messages that get lost don't matter anyway, as | |
1699 | * devices are automatically enabled at | |
1700 | * initialization. | |
1701 | */ | |
1702 | parahotplug_request_kickoff(req); | |
1703 | controlvm_respond_physdev_changestate(&inmsg->hdr, | |
1704 | CONTROLVM_RESP_SUCCESS, | |
1705 | inmsg->cmd. | |
1706 | deviceChangeState.state); | |
1707 | parahotplug_request_destroy(req); | |
1708 | } else { | |
1709 | /* For disable messages, add the request to the | |
1710 | * request list before kicking off the udev script. It | |
1711 | * won't get responded to until the script has | |
1712 | * indicated it's done. | |
1713 | */ | |
1714 | spin_lock(&Parahotplug_request_list_lock); | |
1715 | list_add_tail(&(req->list), &Parahotplug_request_list); | |
1716 | spin_unlock(&Parahotplug_request_list_lock); | |
1717 | ||
1718 | parahotplug_request_kickoff(req); | |
1719 | } | |
1720 | } | |
1721 | ||
1722 | /* | |
1723 | * Gets called when the udev script writes to | |
1724 | * /proc/visorchipset/parahotplug. Expects input in the form of "<id> | |
1725 | * <active>" where <id> is the identifier passed to the script that | |
1726 | * matches a request on the request list, and <active> is 0 or 1 | |
1727 | * indicating whether the device is now enabled or not. | |
1728 | */ | |
1729 | static ssize_t | |
1730 | parahotplug_proc_write(struct file *file, const char __user *buffer, | |
1731 | size_t count, loff_t *ppos) | |
1732 | { | |
1733 | char buf[64]; | |
1734 | uint id; | |
1735 | ushort active; | |
1736 | ||
1737 | if (count > sizeof(buf) - 1) { | |
1738 | LOGERR("parahotplug_proc_write: count (%d) exceeds size of buffer (%d)", | |
1739 | (int) count, (int) sizeof(buf)); | |
1740 | return -EINVAL; | |
1741 | } | |
1742 | if (copy_from_user(buf, buffer, count)) { | |
1743 | LOGERR("parahotplug_proc_write: copy_from_user failed"); | |
1744 | return -EFAULT; | |
1745 | } | |
1746 | buf[count] = '\0'; | |
1747 | ||
1748 | if (sscanf(buf, "%u %hu", &id, &active) != 2) { | |
1749 | id = 0; | |
1750 | active = 0; | |
1751 | } | |
1752 | ||
1753 | if (active != 1 && active != 0) { | |
1754 | LOGERR("parahotplug_proc_write: invalid active field"); | |
1755 | return -EINVAL; | |
1756 | } | |
1757 | ||
1758 | parahotplug_request_complete((int) id, (U16) active); | |
1759 | ||
1760 | return count; | |
1761 | } | |
1762 | ||
1763 | static const struct file_operations parahotplug_proc_fops = { | |
1764 | .owner = THIS_MODULE, | |
1765 | .read = visorchipset_proc_read_writeonly, | |
1766 | .write = parahotplug_proc_write, | |
1767 | }; | |
1768 | ||
1769 | /* Process a controlvm message. | |
1770 | * Return result: | |
1771 | * FALSE - this function will return FALSE only in the case where the | |
1772 | * controlvm message was NOT processed, but processing must be | |
1773 | * retried before reading the next controlvm message; a | |
1774 | * scenario where this can occur is when we need to throttle | |
1775 | * the allocation of memory in which to copy out controlvm | |
1776 | * payload data | |
1777 | * TRUE - processing of the controlvm message completed, | |
1778 | * either successfully or with an error. | |
1779 | */ | |
1780 | static BOOL | |
1781 | handle_command(CONTROLVM_MESSAGE inmsg, HOSTADDRESS channel_addr) | |
1782 | { | |
1783 | CONTROLVM_MESSAGE_PACKET *cmd = &inmsg.cmd; | |
1784 | U64 parametersAddr = 0; | |
1785 | U32 parametersBytes = 0; | |
1786 | PARSER_CONTEXT *parser_ctx = NULL; | |
1787 | BOOL isLocalAddr = FALSE; | |
1788 | CONTROLVM_MESSAGE ackmsg; | |
1789 | ||
1790 | /* create parsing context if necessary */ | |
1791 | isLocalAddr = (inmsg.hdr.Flags.testMessage == 1); | |
1792 | if (channel_addr == 0) { | |
1793 | LOGERR("HUH? channel_addr is 0!"); | |
1794 | return TRUE; | |
1795 | } | |
1796 | parametersAddr = channel_addr + inmsg.hdr.PayloadVmOffset; | |
1797 | parametersBytes = inmsg.hdr.PayloadBytes; | |
1798 | ||
1799 | /* Parameter and channel addresses within test messages actually lie | |
1800 | * within our OS-controlled memory. We need to know that, because it | |
1801 | * makes a difference in how we compute the virtual address. | |
1802 | */ | |
1803 | if (parametersAddr != 0 && parametersBytes != 0) { | |
1804 | BOOL retry = FALSE; | |
1805 | parser_ctx = | |
1806 | parser_init_byteStream(parametersAddr, parametersBytes, | |
1807 | isLocalAddr, &retry); | |
1808 | if (!parser_ctx) { | |
1809 | if (retry) { | |
1810 | LOGWRN("throttling to copy payload"); | |
1811 | return FALSE; | |
1812 | } | |
1813 | LOGWRN("parsing failed"); | |
1814 | LOGWRN("inmsg.hdr.Id=0x%lx", (ulong) inmsg.hdr.Id); | |
1815 | LOGWRN("parametersAddr=0x%llx", (u64) parametersAddr); | |
1816 | LOGWRN("parametersBytes=%lu", (ulong) parametersBytes); | |
1817 | LOGWRN("isLocalAddr=%d", isLocalAddr); | |
1818 | } | |
1819 | } | |
1820 | ||
1821 | if (!isLocalAddr) { | |
1822 | controlvm_init_response(&ackmsg, &inmsg.hdr, | |
1823 | CONTROLVM_RESP_SUCCESS); | |
1824 | if ((ControlVm_channel) | |
1825 | && | |
1826 | (!visorchannel_signalinsert | |
1827 | (ControlVm_channel, CONTROLVM_QUEUE_ACK, &ackmsg))) | |
1828 | LOGWRN("failed to send ACK failed"); | |
1829 | } | |
1830 | switch (inmsg.hdr.Id) { | |
1831 | case CONTROLVM_CHIPSET_INIT: | |
1832 | LOGINF("CHIPSET_INIT(#busses=%lu,#switches=%lu)", | |
1833 | (ulong) inmsg.cmd.initChipset.busCount, | |
1834 | (ulong) inmsg.cmd.initChipset.switchCount); | |
1835 | chipset_init(&inmsg); | |
1836 | break; | |
1837 | case CONTROLVM_BUS_CREATE: | |
1838 | LOGINF("BUS_CREATE(%lu,#devs=%lu)", | |
1839 | (ulong) cmd->createBus.busNo, | |
1840 | (ulong) cmd->createBus.deviceCount); | |
1841 | bus_create(&inmsg); | |
1842 | break; | |
1843 | case CONTROLVM_BUS_DESTROY: | |
1844 | LOGINF("BUS_DESTROY(%lu)", (ulong) cmd->destroyBus.busNo); | |
1845 | bus_destroy(&inmsg); | |
1846 | break; | |
1847 | case CONTROLVM_BUS_CONFIGURE: | |
1848 | LOGINF("BUS_CONFIGURE(%lu)", (ulong) cmd->configureBus.busNo); | |
1849 | bus_configure(&inmsg, parser_ctx); | |
1850 | break; | |
1851 | case CONTROLVM_DEVICE_CREATE: | |
1852 | LOGINF("DEVICE_CREATE(%lu,%lu)", | |
1853 | (ulong) cmd->createDevice.busNo, | |
1854 | (ulong) cmd->createDevice.devNo); | |
1855 | my_device_create(&inmsg); | |
1856 | break; | |
1857 | case CONTROLVM_DEVICE_CHANGESTATE: | |
1858 | if (cmd->deviceChangeState.flags.physicalDevice) { | |
1859 | LOGINF("DEVICE_CHANGESTATE for physical device (%lu,%lu, active=%lu)", | |
1860 | (ulong) cmd->deviceChangeState.busNo, | |
1861 | (ulong) cmd->deviceChangeState.devNo, | |
1862 | (ulong) cmd->deviceChangeState.state.Active); | |
1863 | parahotplug_process_message(&inmsg); | |
1864 | } else { | |
1865 | LOGINF("DEVICE_CHANGESTATE for virtual device (%lu,%lu, state.Alive=0x%lx)", | |
1866 | (ulong) cmd->deviceChangeState.busNo, | |
1867 | (ulong) cmd->deviceChangeState.devNo, | |
1868 | (ulong) cmd->deviceChangeState.state.Alive); | |
1869 | /* save the hdr and cmd structures for later use */ | |
1870 | /* when sending back the response to Command */ | |
1871 | my_device_changestate(&inmsg); | |
1872 | g_DiagMsgHdr = inmsg.hdr; | |
1873 | g_DeviceChangeStatePacket = inmsg.cmd; | |
1874 | break; | |
1875 | } | |
1876 | break; | |
1877 | case CONTROLVM_DEVICE_DESTROY: | |
1878 | LOGINF("DEVICE_DESTROY(%lu,%lu)", | |
1879 | (ulong) cmd->destroyDevice.busNo, | |
1880 | (ulong) cmd->destroyDevice.devNo); | |
1881 | my_device_destroy(&inmsg); | |
1882 | break; | |
1883 | case CONTROLVM_DEVICE_CONFIGURE: | |
1884 | LOGINF("DEVICE_CONFIGURE(%lu,%lu)", | |
1885 | (ulong) cmd->configureDevice.busNo, | |
1886 | (ulong) cmd->configureDevice.devNo); | |
1887 | /* no op for now, just send a respond that we passed */ | |
1888 | if (inmsg.hdr.Flags.responseExpected) | |
1889 | controlvm_respond(&inmsg.hdr, CONTROLVM_RESP_SUCCESS); | |
1890 | break; | |
1891 | case CONTROLVM_CHIPSET_READY: | |
1892 | LOGINF("CHIPSET_READY"); | |
1893 | chipset_ready(&inmsg.hdr); | |
1894 | break; | |
1895 | case CONTROLVM_CHIPSET_SELFTEST: | |
1896 | LOGINF("CHIPSET_SELFTEST"); | |
1897 | chipset_selftest(&inmsg.hdr); | |
1898 | break; | |
1899 | case CONTROLVM_CHIPSET_STOP: | |
1900 | LOGINF("CHIPSET_STOP"); | |
1901 | chipset_notready(&inmsg.hdr); | |
1902 | break; | |
1903 | default: | |
1904 | LOGERR("unrecognized controlvm cmd=%d", (int) inmsg.hdr.Id); | |
1905 | if (inmsg.hdr.Flags.responseExpected) | |
1906 | controlvm_respond(&inmsg.hdr, | |
1907 | -CONTROLVM_RESP_ERROR_MESSAGE_ID_UNKNOWN); | |
1908 | break; | |
1909 | } | |
1910 | ||
1911 | if (parser_ctx != NULL) { | |
1912 | parser_done(parser_ctx); | |
1913 | parser_ctx = NULL; | |
1914 | } | |
1915 | return TRUE; | |
1916 | } | |
1917 | ||
1918 | static void | |
1919 | controlvm_periodic_work(struct work_struct *work) | |
1920 | { | |
1921 | VISORCHIPSET_CHANNEL_INFO chanInfo; | |
1922 | CONTROLVM_MESSAGE inmsg; | |
1923 | char s[99]; | |
1924 | BOOL gotACommand = FALSE; | |
1925 | BOOL handle_command_failed = FALSE; | |
1926 | static U64 Poll_Count; | |
1927 | ||
1928 | /* make sure visorbus server is registered for controlvm callbacks */ | |
1929 | if (visorchipset_serverregwait && !serverregistered) | |
1930 | RETVOID; | |
1931 | /* make sure visorclientbus server is regsitered for controlvm | |
1932 | * callbacks | |
1933 | */ | |
1934 | if (visorchipset_clientregwait && !clientregistered) | |
1935 | RETVOID; | |
1936 | ||
1937 | memset(&chanInfo, 0, sizeof(VISORCHIPSET_CHANNEL_INFO)); | |
1938 | if (!ControlVm_channel) { | |
1939 | HOSTADDRESS addr = controlvm_get_channel_address(); | |
1940 | if (addr != 0) { | |
1941 | ControlVm_channel = | |
1942 | visorchannel_create_with_lock | |
1943 | (addr, | |
1944 | sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL), | |
1945 | UltraControlvmChannelProtocolGuid); | |
1946 | if (ControlVm_channel == NULL) | |
1947 | LOGERR("failed to create controlvm channel"); | |
1948 | else if (ULTRA_CONTROLVM_CHANNEL_OK_CLIENT | |
1949 | (visorchannel_get_header(ControlVm_channel), | |
1950 | NULL)) { | |
1951 | LOGINF("Channel %s (ControlVm) discovered", | |
1952 | visorchannel_id(ControlVm_channel, s)); | |
1953 | initialize_controlvm_payload(); | |
1954 | } else { | |
1955 | LOGERR("controlvm channel is invalid"); | |
1956 | visorchannel_destroy(ControlVm_channel); | |
1957 | ControlVm_channel = NULL; | |
1958 | } | |
1959 | } | |
1960 | } | |
1961 | ||
1962 | Poll_Count++; | |
1963 | if ((ControlVm_channel != NULL) || (Poll_Count >= 250)) | |
1964 | ; /* keep going */ | |
1965 | else | |
1966 | RETVOID; | |
1967 | ||
1968 | /* Check events to determine if response to CHIPSET_READY | |
1969 | * should be sent | |
1970 | */ | |
1971 | if (visorchipset_holdchipsetready | |
1972 | && (g_ChipSetMsgHdr.Id != CONTROLVM_INVALID)) { | |
1973 | if (check_chipset_events() == 1) { | |
1974 | LOGINF("Sending CHIPSET_READY response"); | |
1975 | controlvm_respond(&g_ChipSetMsgHdr, 0); | |
1976 | clear_chipset_events(); | |
1977 | memset(&g_ChipSetMsgHdr, 0, | |
1978 | sizeof(CONTROLVM_MESSAGE_HEADER)); | |
1979 | } | |
1980 | } | |
1981 | ||
1982 | if (ControlVm_channel) { | |
1983 | while (visorchannel_signalremove(ControlVm_channel, | |
1984 | CONTROLVM_QUEUE_RESPONSE, | |
1985 | &inmsg)) { | |
1986 | if (inmsg.hdr.PayloadMaxBytes != 0) { | |
1987 | LOGERR("Payload of size %lu returned @%lu with unexpected message id %d.", | |
1988 | (ulong) inmsg.hdr.PayloadMaxBytes, | |
1989 | (ulong) inmsg.hdr.PayloadVmOffset, | |
1990 | inmsg.hdr.Id); | |
1991 | } | |
1992 | } | |
1993 | if (!gotACommand) { | |
1994 | if (ControlVm_Pending_Msg_Valid) { | |
1995 | /* we throttled processing of a prior | |
1996 | * msg, so try to process it again | |
1997 | * rather than reading a new one | |
1998 | */ | |
1999 | inmsg = ControlVm_Pending_Msg; | |
2000 | ControlVm_Pending_Msg_Valid = FALSE; | |
2001 | gotACommand = TRUE; | |
2002 | } else | |
2003 | gotACommand = read_controlvm_event(&inmsg); | |
2004 | } | |
2005 | } | |
2006 | ||
2007 | handle_command_failed = FALSE; | |
2008 | while (gotACommand && (!handle_command_failed)) { | |
2009 | Most_recent_message_jiffies = jiffies; | |
2010 | if (ControlVm_channel) { | |
2011 | if (handle_command(inmsg, | |
2012 | visorchannel_get_physaddr | |
2013 | (ControlVm_channel))) | |
2014 | gotACommand = read_controlvm_event(&inmsg); | |
2015 | else { | |
2016 | /* this is a scenario where throttling | |
2017 | * is required, but probably NOT an | |
2018 | * error...; we stash the current | |
2019 | * controlvm msg so we will attempt to | |
2020 | * reprocess it on our next loop | |
2021 | */ | |
2022 | handle_command_failed = TRUE; | |
2023 | ControlVm_Pending_Msg = inmsg; | |
2024 | ControlVm_Pending_Msg_Valid = TRUE; | |
2025 | } | |
2026 | ||
2027 | } else { | |
2028 | handle_command(inmsg, 0); | |
2029 | gotACommand = FALSE; | |
2030 | } | |
2031 | } | |
2032 | ||
2033 | /* parahotplug_worker */ | |
2034 | parahotplug_process_list(); | |
2035 | ||
2036 | RETVOID; | |
2037 | ||
2038 | Away: | |
2039 | ||
2040 | if (time_after(jiffies, | |
2041 | Most_recent_message_jiffies + (HZ * MIN_IDLE_SECONDS))) { | |
2042 | /* it's been longer than MIN_IDLE_SECONDS since we | |
2043 | * processed our last controlvm message; slow down the | |
2044 | * polling | |
2045 | */ | |
2046 | if (Poll_jiffies != POLLJIFFIES_CONTROLVMCHANNEL_SLOW) { | |
2047 | LOGINF("switched to slow controlvm polling"); | |
2048 | Poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_SLOW; | |
2049 | } | |
2050 | } else { | |
2051 | if (Poll_jiffies != POLLJIFFIES_CONTROLVMCHANNEL_FAST) { | |
2052 | Poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST; | |
2053 | LOGINF("switched to fast controlvm polling"); | |
2054 | } | |
2055 | } | |
2056 | ||
4b4b535e DY |
2057 | queue_delayed_work(Periodic_controlvm_workqueue, |
2058 | &Periodic_controlvm_work, Poll_jiffies); | |
12e364b9 KC |
2059 | } |
2060 | ||
2061 | static void | |
2062 | setup_crash_devices_work_queue(struct work_struct *work) | |
2063 | { | |
2064 | ||
2065 | CONTROLVM_MESSAGE localCrashCreateBusMsg; | |
2066 | CONTROLVM_MESSAGE localCrashCreateDevMsg; | |
2067 | CONTROLVM_MESSAGE msg; | |
2068 | HOSTADDRESS host_addr; | |
2069 | U32 localSavedCrashMsgOffset; | |
2070 | U16 localSavedCrashMsgCount; | |
2071 | ||
2072 | /* make sure visorbus server is registered for controlvm callbacks */ | |
2073 | if (visorchipset_serverregwait && !serverregistered) | |
2074 | RETVOID; | |
2075 | ||
2076 | /* make sure visorclientbus server is regsitered for controlvm | |
2077 | * callbacks | |
2078 | */ | |
2079 | if (visorchipset_clientregwait && !clientregistered) | |
2080 | RETVOID; | |
2081 | ||
2082 | POSTCODE_LINUX_2(CRASH_DEV_ENTRY_PC, POSTCODE_SEVERITY_INFO); | |
2083 | ||
2084 | /* send init chipset msg */ | |
2085 | msg.hdr.Id = CONTROLVM_CHIPSET_INIT; | |
2086 | msg.cmd.initChipset.busCount = 23; | |
2087 | msg.cmd.initChipset.switchCount = 0; | |
2088 | ||
2089 | chipset_init(&msg); | |
2090 | ||
2091 | host_addr = controlvm_get_channel_address(); | |
2092 | if (!host_addr) { | |
2093 | LOGERR("Huh? Host address is NULL"); | |
2094 | POSTCODE_LINUX_2(CRASH_DEV_HADDR_NULL, POSTCODE_SEVERITY_ERR); | |
2095 | return; | |
2096 | } | |
2097 | ||
2098 | ControlVm_channel = | |
2099 | visorchannel_create_with_lock | |
2100 | (host_addr, | |
2101 | sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL), | |
2102 | UltraControlvmChannelProtocolGuid); | |
2103 | ||
2104 | if (ControlVm_channel == NULL) { | |
2105 | LOGERR("failed to create controlvm channel"); | |
2106 | POSTCODE_LINUX_2(CRASH_DEV_CONTROLVM_NULL, | |
2107 | POSTCODE_SEVERITY_ERR); | |
2108 | return; | |
2109 | } | |
2110 | ||
2111 | /* get saved message count */ | |
2112 | if (visorchannel_read(ControlVm_channel, | |
2113 | offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, | |
2114 | SavedCrashMsgCount), | |
2115 | &localSavedCrashMsgCount, sizeof(U16)) < 0) { | |
2116 | LOGERR("failed to get Saved Message Count"); | |
2117 | POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC, | |
2118 | POSTCODE_SEVERITY_ERR); | |
2119 | return; | |
2120 | } | |
2121 | ||
2122 | if (localSavedCrashMsgCount != CONTROLVM_CRASHMSG_MAX) { | |
2123 | LOGERR("Saved Message Count incorrect %d", | |
2124 | localSavedCrashMsgCount); | |
2125 | POSTCODE_LINUX_3(CRASH_DEV_COUNT_FAILURE_PC, | |
2126 | localSavedCrashMsgCount, | |
2127 | POSTCODE_SEVERITY_ERR); | |
2128 | return; | |
2129 | } | |
2130 | ||
2131 | /* get saved crash message offset */ | |
2132 | if (visorchannel_read(ControlVm_channel, | |
2133 | offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, | |
2134 | SavedCrashMsgOffset), | |
2135 | &localSavedCrashMsgOffset, sizeof(U32)) < 0) { | |
2136 | LOGERR("failed to get Saved Message Offset"); | |
2137 | POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC, | |
2138 | POSTCODE_SEVERITY_ERR); | |
2139 | return; | |
2140 | } | |
2141 | ||
2142 | /* read create device message for storage bus offset */ | |
2143 | if (visorchannel_read(ControlVm_channel, | |
2144 | localSavedCrashMsgOffset, | |
2145 | &localCrashCreateBusMsg, | |
2146 | sizeof(CONTROLVM_MESSAGE)) < 0) { | |
2147 | LOGERR("CRASH_DEV_RD_BUS_FAIULRE: Failed to read CrashCreateBusMsg!"); | |
2148 | POSTCODE_LINUX_2(CRASH_DEV_RD_BUS_FAIULRE_PC, | |
2149 | POSTCODE_SEVERITY_ERR); | |
2150 | return; | |
2151 | } | |
2152 | ||
2153 | /* read create device message for storage device */ | |
2154 | if (visorchannel_read(ControlVm_channel, | |
2155 | localSavedCrashMsgOffset + | |
2156 | sizeof(CONTROLVM_MESSAGE), | |
2157 | &localCrashCreateDevMsg, | |
2158 | sizeof(CONTROLVM_MESSAGE)) < 0) { | |
2159 | LOGERR("CRASH_DEV_RD_DEV_FAIULRE: Failed to read CrashCreateDevMsg!"); | |
2160 | POSTCODE_LINUX_2(CRASH_DEV_RD_DEV_FAIULRE_PC, | |
2161 | POSTCODE_SEVERITY_ERR); | |
2162 | return; | |
2163 | } | |
2164 | ||
2165 | /* reuse IOVM create bus message */ | |
2166 | if (localCrashCreateBusMsg.cmd.createBus.channelAddr != 0) | |
2167 | bus_create(&localCrashCreateBusMsg); | |
2168 | else { | |
2169 | LOGERR("CrashCreateBusMsg is null, no dump will be taken"); | |
2170 | POSTCODE_LINUX_2(CRASH_DEV_BUS_NULL_FAILURE_PC, | |
2171 | POSTCODE_SEVERITY_ERR); | |
2172 | return; | |
2173 | } | |
2174 | ||
2175 | /* reuse create device message for storage device */ | |
2176 | if (localCrashCreateDevMsg.cmd.createDevice.channelAddr != 0) | |
2177 | my_device_create(&localCrashCreateDevMsg); | |
2178 | else { | |
2179 | LOGERR("CrashCreateDevMsg is null, no dump will be taken"); | |
2180 | POSTCODE_LINUX_2(CRASH_DEV_DEV_NULL_FAILURE_PC, | |
2181 | POSTCODE_SEVERITY_ERR); | |
2182 | return; | |
2183 | } | |
2184 | LOGINF("Bus and device ready for dumping"); | |
2185 | POSTCODE_LINUX_2(CRASH_DEV_EXIT_PC, POSTCODE_SEVERITY_INFO); | |
2186 | return; | |
2187 | ||
2188 | Away: | |
2189 | ||
2190 | Poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_SLOW; | |
2191 | ||
4b4b535e DY |
2192 | queue_delayed_work(Periodic_controlvm_workqueue, |
2193 | &Periodic_controlvm_work, Poll_jiffies); | |
12e364b9 KC |
2194 | } |
2195 | ||
2196 | static void | |
2197 | bus_create_response(ulong busNo, int response) | |
2198 | { | |
2199 | bus_responder(CONTROLVM_BUS_CREATE, busNo, response); | |
2200 | } | |
2201 | ||
2202 | static void | |
2203 | bus_destroy_response(ulong busNo, int response) | |
2204 | { | |
2205 | bus_responder(CONTROLVM_BUS_DESTROY, busNo, response); | |
2206 | } | |
2207 | ||
2208 | static void | |
2209 | device_create_response(ulong busNo, ulong devNo, int response) | |
2210 | { | |
2211 | device_responder(CONTROLVM_DEVICE_CREATE, busNo, devNo, response); | |
2212 | } | |
2213 | ||
2214 | static void | |
2215 | device_destroy_response(ulong busNo, ulong devNo, int response) | |
2216 | { | |
2217 | device_responder(CONTROLVM_DEVICE_DESTROY, busNo, devNo, response); | |
2218 | } | |
2219 | ||
2220 | void | |
927c7927 | 2221 | visorchipset_device_pause_response(ulong busNo, ulong devNo, int response) |
12e364b9 KC |
2222 | { |
2223 | ||
2224 | device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE, | |
2225 | busNo, devNo, response, | |
2226 | SegmentStateStandby); | |
2227 | } | |
927c7927 | 2228 | EXPORT_SYMBOL_GPL(visorchipset_device_pause_response); |
12e364b9 KC |
2229 | |
2230 | static void | |
2231 | device_resume_response(ulong busNo, ulong devNo, int response) | |
2232 | { | |
2233 | device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE, | |
2234 | busNo, devNo, response, | |
2235 | SegmentStateRunning); | |
2236 | } | |
2237 | ||
2238 | BOOL | |
2239 | visorchipset_get_bus_info(ulong busNo, VISORCHIPSET_BUS_INFO *busInfo) | |
2240 | { | |
2241 | void *p = findbus(&BusInfoList, busNo); | |
2242 | if (!p) { | |
2243 | LOGERR("(%lu) failed", busNo); | |
2244 | return FALSE; | |
2245 | } | |
2246 | memcpy(busInfo, p, sizeof(VISORCHIPSET_BUS_INFO)); | |
2247 | return TRUE; | |
2248 | } | |
2249 | EXPORT_SYMBOL_GPL(visorchipset_get_bus_info); | |
2250 | ||
2251 | BOOL | |
2252 | visorchipset_set_bus_context(ulong busNo, void *context) | |
2253 | { | |
2254 | VISORCHIPSET_BUS_INFO *p = findbus(&BusInfoList, busNo); | |
2255 | if (!p) { | |
2256 | LOGERR("(%lu) failed", busNo); | |
2257 | return FALSE; | |
2258 | } | |
2259 | p->bus_driver_context = context; | |
2260 | return TRUE; | |
2261 | } | |
2262 | EXPORT_SYMBOL_GPL(visorchipset_set_bus_context); | |
2263 | ||
2264 | BOOL | |
2265 | visorchipset_get_device_info(ulong busNo, ulong devNo, | |
2266 | VISORCHIPSET_DEVICE_INFO *devInfo) | |
2267 | { | |
2268 | void *p = finddevice(&DevInfoList, busNo, devNo); | |
2269 | if (!p) { | |
2270 | LOGERR("(%lu,%lu) failed", busNo, devNo); | |
2271 | return FALSE; | |
2272 | } | |
2273 | memcpy(devInfo, p, sizeof(VISORCHIPSET_DEVICE_INFO)); | |
2274 | return TRUE; | |
2275 | } | |
2276 | EXPORT_SYMBOL_GPL(visorchipset_get_device_info); | |
2277 | ||
2278 | BOOL | |
2279 | visorchipset_set_device_context(ulong busNo, ulong devNo, void *context) | |
2280 | { | |
2281 | VISORCHIPSET_DEVICE_INFO *p = finddevice(&DevInfoList, busNo, devNo); | |
2282 | if (!p) { | |
2283 | LOGERR("(%lu,%lu) failed", busNo, devNo); | |
2284 | return FALSE; | |
2285 | } | |
2286 | p->bus_driver_context = context; | |
2287 | return TRUE; | |
2288 | } | |
2289 | EXPORT_SYMBOL_GPL(visorchipset_set_device_context); | |
2290 | ||
2291 | /* Generic wrapper function for allocating memory from a kmem_cache pool. | |
2292 | */ | |
2293 | void * | |
2294 | visorchipset_cache_alloc(struct kmem_cache *pool, BOOL ok_to_block, | |
2295 | char *fn, int ln) | |
2296 | { | |
2297 | gfp_t gfp; | |
2298 | void *p; | |
2299 | ||
2300 | if (ok_to_block) | |
2301 | gfp = GFP_KERNEL; | |
2302 | else | |
2303 | gfp = GFP_ATOMIC; | |
2304 | /* __GFP_NORETRY means "ok to fail", meaning | |
2305 | * kmem_cache_alloc() can return NULL, implying the caller CAN | |
2306 | * cope with failure. If you do NOT specify __GFP_NORETRY, | |
2307 | * Linux will go to extreme measures to get memory for you | |
2308 | * (like, invoke oom killer), which will probably cripple the | |
2309 | * system. | |
2310 | */ | |
2311 | gfp |= __GFP_NORETRY; | |
2312 | p = kmem_cache_alloc(pool, gfp); | |
2313 | if (!p) { | |
2314 | LOGERR("kmem_cache_alloc failed early @%s:%d\n", fn, ln); | |
2315 | return NULL; | |
2316 | } | |
2317 | atomic_inc(&Visorchipset_cache_buffers_in_use); | |
2318 | return p; | |
2319 | } | |
2320 | ||
2321 | /* Generic wrapper function for freeing memory from a kmem_cache pool. | |
2322 | */ | |
2323 | void | |
2324 | visorchipset_cache_free(struct kmem_cache *pool, void *p, char *fn, int ln) | |
2325 | { | |
2326 | if (!p) { | |
2327 | LOGERR("NULL pointer @%s:%d\n", fn, ln); | |
2328 | return; | |
2329 | } | |
2330 | atomic_dec(&Visorchipset_cache_buffers_in_use); | |
2331 | kmem_cache_free(pool, p); | |
2332 | } | |
2333 | ||
2334 | #define gettoken(bufp) strsep(bufp, " -\t\n") | |
2335 | ||
2336 | static ssize_t | |
2337 | chipset_proc_write(struct file *file, const char __user *buffer, | |
2338 | size_t count, loff_t *ppos) | |
2339 | { | |
2340 | char buf[512]; | |
2341 | char *token, *p; | |
2342 | ||
2343 | if (count > sizeof(buf) - 1) { | |
2344 | LOGERR("chipset_proc_write: count (%d) exceeds size of buffer (%d)", | |
2345 | (int) count, (int) sizeof(buffer)); | |
2346 | return -EINVAL; | |
2347 | } | |
2348 | if (copy_from_user(buf, buffer, count)) { | |
2349 | LOGERR("chipset_proc_write: copy_from_user failed"); | |
2350 | return -EFAULT; | |
2351 | } | |
2352 | buf[count] = '\0'; | |
2353 | ||
2354 | p = buf; | |
2355 | token = gettoken(&p); | |
2356 | ||
2357 | if (strcmp(token, "CALLHOMEDISK_MOUNTED") == 0) { | |
2358 | token = gettoken(&p); | |
2359 | /* The Call Home Disk has been mounted */ | |
2360 | if (strcmp(token, "0") == 0) | |
2361 | chipset_events[0] = 1; | |
2362 | } else if (strcmp(token, "MODULES_LOADED") == 0) { | |
2363 | token = gettoken(&p); | |
2364 | /* All modules for the partition have been loaded */ | |
2365 | if (strcmp(token, "0") == 0) | |
2366 | chipset_events[1] = 1; | |
2367 | } else if (token == NULL) { | |
2368 | /* No event specified */ | |
2369 | LOGERR("No event was specified to send CHIPSET_READY response"); | |
2370 | return -1; | |
2371 | } else { | |
2372 | /* Unsupported event specified */ | |
2373 | LOGERR("%s is an invalid event for sending CHIPSET_READY response", token); | |
2374 | return -1; | |
2375 | } | |
2376 | ||
2377 | return count; | |
2378 | } | |
2379 | ||
2380 | static ssize_t | |
2381 | visorchipset_proc_read_writeonly(struct file *file, char __user *buf, | |
2382 | size_t len, loff_t *offset) | |
2383 | { | |
2384 | return 0; | |
2385 | } | |
2386 | ||
2387 | /** | |
2388 | * Reads the InstallationError, InstallationTextId, | |
2389 | * InstallationRemainingSteps fields of ControlVMChannel. | |
2390 | */ | |
2391 | static ssize_t | |
2392 | proc_read_installer(struct file *file, char __user *buf, | |
2393 | size_t len, loff_t *offset) | |
2394 | { | |
2395 | int length = 0; | |
2396 | U16 remainingSteps; | |
2397 | U32 error, textId; | |
2398 | char *vbuf; | |
2399 | loff_t pos = *offset; | |
2400 | ||
2401 | if (pos < 0) | |
2402 | return -EINVAL; | |
2403 | ||
2404 | if (pos > 0 || !len) | |
2405 | return 0; | |
2406 | ||
2407 | vbuf = kzalloc(len, GFP_KERNEL); | |
2408 | if (!vbuf) | |
2409 | return -ENOMEM; | |
2410 | ||
2411 | visorchannel_read(ControlVm_channel, | |
2412 | offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, | |
2413 | InstallationRemainingSteps), &remainingSteps, | |
2414 | sizeof(U16)); | |
2415 | visorchannel_read(ControlVm_channel, | |
2416 | offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, | |
2417 | InstallationError), &error, sizeof(U32)); | |
2418 | visorchannel_read(ControlVm_channel, | |
2419 | offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, | |
2420 | InstallationTextId), &textId, sizeof(U32)); | |
2421 | ||
2422 | length = sprintf(vbuf, "%u %u %u\n", remainingSteps, error, textId); | |
2423 | if (copy_to_user(buf, vbuf, length)) { | |
2424 | kfree(vbuf); | |
2425 | return -EFAULT; | |
2426 | } | |
2427 | ||
2428 | kfree(vbuf); | |
2429 | *offset += length; | |
2430 | return length; | |
2431 | } | |
2432 | ||
2433 | /** | |
2434 | * Writes to the InstallationError, InstallationTextId, | |
2435 | * InstallationRemainingSteps fields of | |
2436 | * ControlVMChannel. | |
2437 | * Input: RemainingSteps Error TextId | |
2438 | * Limit 32 characters input | |
2439 | */ | |
2440 | #define UINT16_MAX (65535U) | |
2441 | #define UINT32_MAX (4294967295U) | |
2442 | static ssize_t | |
2443 | proc_write_installer(struct file *file, | |
2444 | const char __user *buffer, size_t count, loff_t *ppos) | |
2445 | { | |
2446 | char buf[32]; | |
2447 | U16 remainingSteps; | |
2448 | U32 error, textId; | |
2449 | ||
2450 | /* Check to make sure there is no buffer overflow */ | |
2451 | if (count > (sizeof(buf) - 1)) | |
2452 | return -EINVAL; | |
2453 | ||
2454 | if (copy_from_user(buf, buffer, count)) { | |
2455 | WARN(1, "Error copying from user space\n"); | |
2456 | return -EFAULT; | |
2457 | } | |
2458 | ||
2459 | if (sscanf(buf, "%hu %i %i", &remainingSteps, &error, &textId) != 3) { | |
2460 | remainingSteps = UINT16_MAX; | |
2461 | error = UINT32_MAX; | |
2462 | textId = UINT32_MAX; | |
2463 | } | |
2464 | ||
2465 | if (remainingSteps != UINT16_MAX) { | |
2466 | if (visorchannel_write | |
2467 | (ControlVm_channel, | |
2468 | offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, | |
2469 | InstallationRemainingSteps), &remainingSteps, | |
2470 | sizeof(U16)) < 0) | |
2471 | WARN(1, "Installation Status Write Failed - Write function error - RemainingSteps = %d\n", | |
2472 | remainingSteps); | |
2473 | } | |
2474 | ||
2475 | if (error != UINT32_MAX) { | |
2476 | if (visorchannel_write | |
2477 | (ControlVm_channel, | |
2478 | offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, | |
2479 | InstallationError), &error, sizeof(U32)) < 0) | |
2480 | WARN(1, "Installation Status Write Failed - Write function error - Error = %d\n", | |
2481 | error); | |
2482 | } | |
2483 | ||
2484 | if (textId != UINT32_MAX) { | |
2485 | if (visorchannel_write | |
2486 | (ControlVm_channel, | |
2487 | offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, | |
2488 | InstallationTextId), &textId, sizeof(U32)) < 0) | |
2489 | WARN(1, "Installation Status Write Failed - Write function error - TextId = %d\n", | |
2490 | textId); | |
2491 | } | |
2492 | ||
2493 | /* So this function isn't called multiple times, must return | |
2494 | * size of buffer | |
2495 | */ | |
2496 | return count; | |
2497 | } | |
2498 | ||
2499 | /** | |
2500 | * Reads the ToolAction field of ControlVMChannel. | |
2501 | */ | |
2502 | static ssize_t | |
2503 | proc_read_toolaction(struct file *file, char __user *buf, | |
2504 | size_t len, loff_t *offset) | |
2505 | { | |
2506 | int length = 0; | |
2507 | U8 toolAction; | |
2508 | char *vbuf; | |
2509 | loff_t pos = *offset; | |
2510 | ||
2511 | if (pos < 0) | |
2512 | return -EINVAL; | |
2513 | ||
2514 | if (pos > 0 || !len) | |
2515 | return 0; | |
2516 | ||
2517 | vbuf = kzalloc(len, GFP_KERNEL); | |
2518 | if (!vbuf) | |
2519 | return -ENOMEM; | |
2520 | ||
2521 | visorchannel_read(ControlVm_channel, | |
2522 | offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, | |
2523 | ToolAction), &toolAction, sizeof(U8)); | |
2524 | ||
2525 | length = sprintf(vbuf, "%u\n", toolAction); | |
2526 | if (copy_to_user(buf, vbuf, length)) { | |
2527 | kfree(vbuf); | |
2528 | return -EFAULT; | |
2529 | } | |
2530 | ||
2531 | kfree(vbuf); | |
2532 | *offset += length; | |
2533 | return length; | |
2534 | } | |
2535 | ||
2536 | /** | |
2537 | * Writes to the ToolAction field of ControlVMChannel. | |
2538 | * Input: ToolAction | |
2539 | * Limit 3 characters input | |
2540 | */ | |
2541 | #define UINT8_MAX (255U) | |
2542 | static ssize_t | |
2543 | proc_write_toolaction(struct file *file, | |
2544 | const char __user *buffer, size_t count, loff_t *ppos) | |
2545 | { | |
2546 | char buf[3]; | |
2547 | U8 toolAction; | |
2548 | ||
2549 | /* Check to make sure there is no buffer overflow */ | |
2550 | if (count > (sizeof(buf) - 1)) | |
2551 | return -EINVAL; | |
2552 | ||
2553 | if (copy_from_user(buf, buffer, count)) { | |
2554 | WARN(1, "Error copying from user space\n"); | |
2555 | return -EFAULT; | |
2556 | } | |
2557 | ||
2558 | if (sscanf(buf, "%hhd", &toolAction) != 1) | |
2559 | toolAction = UINT8_MAX; | |
2560 | ||
2561 | if (toolAction != UINT8_MAX) { | |
2562 | if (visorchannel_write | |
2563 | (ControlVm_channel, | |
2564 | offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, ToolAction), | |
2565 | &toolAction, sizeof(U8)) < 0) | |
2566 | WARN(1, "Installation ToolAction Write Failed - ToolAction = %d\n", | |
2567 | toolAction); | |
2568 | } | |
2569 | ||
2570 | /* So this function isn't called multiple times, must return | |
2571 | * size of buffer | |
2572 | */ | |
2573 | return count; | |
2574 | } | |
2575 | ||
2576 | /** | |
2577 | * Reads the EfiSparIndication.BootToTool field of ControlVMChannel. | |
2578 | */ | |
2579 | static ssize_t | |
2580 | proc_read_bootToTool(struct file *file, char __user *buf, | |
2581 | size_t len, loff_t *offset) | |
2582 | { | |
2583 | int length = 0; | |
2584 | ULTRA_EFI_SPAR_INDICATION efiSparIndication; | |
2585 | char *vbuf; | |
2586 | loff_t pos = *offset; | |
2587 | ||
2588 | if (pos < 0) | |
2589 | return -EINVAL; | |
2590 | ||
2591 | if (pos > 0 || !len) | |
2592 | return 0; | |
2593 | ||
2594 | vbuf = kzalloc(len, GFP_KERNEL); | |
2595 | if (!vbuf) | |
2596 | return -ENOMEM; | |
2597 | ||
2598 | visorchannel_read(ControlVm_channel, | |
2599 | offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, | |
2600 | EfiSparIndication), &efiSparIndication, | |
2601 | sizeof(ULTRA_EFI_SPAR_INDICATION)); | |
2602 | ||
2603 | length = sprintf(vbuf, "%d\n", (int) efiSparIndication.BootToTool); | |
2604 | if (copy_to_user(buf, vbuf, length)) { | |
2605 | kfree(vbuf); | |
2606 | return -EFAULT; | |
2607 | } | |
2608 | ||
2609 | kfree(vbuf); | |
2610 | *offset += length; | |
2611 | return length; | |
2612 | } | |
2613 | ||
2614 | /** | |
2615 | * Writes to the EfiSparIndication.BootToTool field of ControlVMChannel. | |
2616 | * Input: 1 or 0 (1 being on, 0 being off) | |
2617 | */ | |
2618 | static ssize_t | |
2619 | proc_write_bootToTool(struct file *file, | |
2620 | const char __user *buffer, size_t count, loff_t *ppos) | |
2621 | { | |
2622 | char buf[3]; | |
2623 | int inputVal; | |
2624 | ULTRA_EFI_SPAR_INDICATION efiSparIndication; | |
2625 | ||
2626 | /* Check to make sure there is no buffer overflow */ | |
2627 | if (count > (sizeof(buf) - 1)) | |
2628 | return -EINVAL; | |
2629 | ||
2630 | if (copy_from_user(buf, buffer, count)) { | |
2631 | WARN(1, "Error copying from user space\n"); | |
2632 | return -EFAULT; | |
2633 | } | |
2634 | ||
2635 | if (sscanf(buf, "%i", &inputVal) != 1) | |
2636 | inputVal = 0; | |
2637 | ||
2638 | efiSparIndication.BootToTool = (inputVal == 1 ? 1 : 0); | |
2639 | ||
2640 | if (visorchannel_write | |
2641 | (ControlVm_channel, | |
2642 | offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, EfiSparIndication), | |
2643 | &efiSparIndication, sizeof(ULTRA_EFI_SPAR_INDICATION)) < 0) | |
2644 | printk | |
2645 | ("Installation BootToTool Write Failed - BootToTool = %d\n", | |
2646 | (int) efiSparIndication.BootToTool); | |
2647 | ||
2648 | /* So this function isn't called multiple times, must return | |
2649 | * size of buffer | |
2650 | */ | |
2651 | return count; | |
2652 | } | |
2653 | ||
2654 | static const struct file_operations chipset_proc_fops = { | |
2655 | .owner = THIS_MODULE, | |
2656 | .read = visorchipset_proc_read_writeonly, | |
2657 | .write = chipset_proc_write, | |
2658 | }; | |
2659 | ||
2660 | static int __init | |
2661 | visorchipset_init(void) | |
2662 | { | |
2663 | int rc = 0, x = 0; | |
2664 | struct proc_dir_entry *installer_file; | |
2665 | struct proc_dir_entry *toolaction_file; | |
2666 | struct proc_dir_entry *bootToTool_file; | |
2667 | ||
2668 | LOGINF("chipset driver version %s loaded", VERSION); | |
2669 | /* process module options */ | |
2670 | POSTCODE_LINUX_2(DRIVER_ENTRY_PC, POSTCODE_SEVERITY_INFO); | |
2671 | ||
2672 | LOGINF("option - testvnic=%d", visorchipset_testvnic); | |
2673 | LOGINF("option - testvnicclient=%d", visorchipset_testvnicclient); | |
2674 | LOGINF("option - testmsg=%d", visorchipset_testmsg); | |
2675 | LOGINF("option - testteardown=%d", visorchipset_testteardown); | |
2676 | LOGINF("option - major=%d", visorchipset_major); | |
2677 | LOGINF("option - serverregwait=%d", visorchipset_serverregwait); | |
2678 | LOGINF("option - clientregwait=%d", visorchipset_clientregwait); | |
2679 | LOGINF("option - holdchipsetready=%d", visorchipset_holdchipsetready); | |
2680 | ||
2681 | memset(&BusDev_Server_Notifiers, 0, sizeof(BusDev_Server_Notifiers)); | |
2682 | memset(&BusDev_Client_Notifiers, 0, sizeof(BusDev_Client_Notifiers)); | |
2683 | memset(&ControlVm_payload_info, 0, sizeof(ControlVm_payload_info)); | |
2684 | memset(&LiveDump_info, 0, sizeof(LiveDump_info)); | |
2685 | atomic_set(&LiveDump_info.buffers_in_use, 0); | |
2686 | ||
9f8d0e8b KC |
2687 | if (visorchipset_testvnic) { |
2688 | ERRDRV("testvnic option no longer supported: (status = %d)\n", | |
2689 | x); | |
2690 | POSTCODE_LINUX_3(CHIPSET_INIT_FAILURE_PC, x, DIAG_SEVERITY_ERR); | |
2691 | rc = x; | |
2692 | goto Away; | |
2693 | } | |
12e364b9 KC |
2694 | |
2695 | controlvm_init(); | |
2696 | MajorDev = MKDEV(visorchipset_major, 0); | |
9f8d0e8b | 2697 | rc = visorchipset_file_init(MajorDev, &ControlVm_channel); |
4cb005a9 KC |
2698 | if (rc < 0) { |
2699 | ERRDRV("visorchipset_file_init(MajorDev, &ControlVm_channel): error (status=%d)\n", rc); | |
2700 | POSTCODE_LINUX_2(CHIPSET_INIT_FAILURE_PC, DIAG_SEVERITY_ERR); | |
2701 | goto Away; | |
2702 | } | |
9f8d0e8b | 2703 | |
12e364b9 KC |
2704 | proc_Init(); |
2705 | memset(PartitionPropertyNames, 0, sizeof(PartitionPropertyNames)); | |
2706 | memset(ControlVmPropertyNames, 0, sizeof(ControlVmPropertyNames)); | |
2707 | InitPartitionProperties(); | |
2708 | InitControlVmProperties(); | |
2709 | ||
927c7927 KC |
2710 | PartitionType = visor_proc_CreateType(ProcDir, PartitionTypeNames, |
2711 | (const char **) | |
2712 | PartitionPropertyNames, | |
2713 | &show_partition_property); | |
12e364b9 | 2714 | ControlVmType = |
927c7927 KC |
2715 | visor_proc_CreateType(ProcDir, ControlVmTypeNames, |
2716 | (const char **) ControlVmPropertyNames, | |
2717 | &show_controlvm_property); | |
12e364b9 | 2718 | |
927c7927 | 2719 | ControlVmObject = visor_proc_CreateObject(ControlVmType, NULL, NULL); |
12e364b9 KC |
2720 | |
2721 | /* Setup Installation fields */ | |
2722 | installer_file = proc_create("installer", 0644, ProcDir, | |
2723 | &proc_installer_fops); | |
2724 | /* Setup the ToolAction field */ | |
2725 | toolaction_file = proc_create("toolaction", 0644, ProcDir, | |
2726 | &proc_toolaction_fops); | |
2727 | /* Setup the BootToTool field */ | |
2728 | bootToTool_file = proc_create("boottotool", 0644, ProcDir, | |
2729 | &proc_bootToTool_fops); | |
2730 | ||
2731 | memset(&g_DiagMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER)); | |
2732 | ||
2733 | chipset_proc_dir = proc_create(VISORCHIPSET_CHIPSET_PROC_ENTRY_FN, | |
2734 | 0644, ProcDir, &chipset_proc_fops); | |
2735 | memset(&g_ChipSetMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER)); | |
2736 | ||
2737 | parahotplug_proc_dir = | |
2738 | proc_create(VISORCHIPSET_PARAHOTPLUG_PROC_ENTRY_FN, 0200, | |
2739 | ProcDir, ¶hotplug_proc_fops); | |
2740 | memset(&g_DelDumpMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER)); | |
2741 | ||
2742 | if (filexfer_constructor(sizeof(struct putfile_request)) < 0) { | |
4cb005a9 KC |
2743 | ERRDRV("filexfer_constructor failed: (status=-1)\n"); |
2744 | POSTCODE_LINUX_2(CHIPSET_INIT_FAILURE_PC, DIAG_SEVERITY_ERR); | |
2745 | rc = -1; | |
2746 | goto Away; | |
12e364b9 KC |
2747 | } |
2748 | Putfile_buffer_list_pool = | |
2749 | kmem_cache_create(Putfile_buffer_list_pool_name, | |
2750 | sizeof(struct putfile_buffer_entry), | |
2751 | 0, SLAB_HWCACHE_ALIGN, NULL); | |
2752 | if (!Putfile_buffer_list_pool) { | |
4cb005a9 KC |
2753 | ERRDRV("failed to alloc Putfile_buffer_list_pool: (status=-1)\n"); |
2754 | POSTCODE_LINUX_2(CHIPSET_INIT_FAILURE_PC, DIAG_SEVERITY_ERR); | |
2755 | rc = -1; | |
2756 | goto Away; | |
12e364b9 KC |
2757 | } |
2758 | if (visorchipset_disable_controlvm) { | |
2759 | LOGINF("visorchipset_init:controlvm disabled"); | |
2760 | } else { | |
2761 | /* if booting in a crash kernel */ | |
2762 | if (visorchipset_crash_kernel) | |
2763 | INIT_DELAYED_WORK(&Periodic_controlvm_work, | |
2764 | setup_crash_devices_work_queue); | |
2765 | else | |
2766 | INIT_DELAYED_WORK(&Periodic_controlvm_work, | |
2767 | controlvm_periodic_work); | |
2768 | Periodic_controlvm_workqueue = | |
2769 | create_singlethread_workqueue("visorchipset_controlvm"); | |
2770 | ||
4cb005a9 KC |
2771 | if (Periodic_controlvm_workqueue == NULL) { |
2772 | ERRDRV("cannot create controlvm workqueue: (status=%d)\n", | |
2773 | -ENOMEM); | |
2774 | POSTCODE_LINUX_2(CREATE_WORKQUEUE_FAILED_PC, | |
2775 | DIAG_SEVERITY_ERR); | |
2776 | rc = -ENOMEM; | |
2777 | goto Away; | |
2778 | } | |
12e364b9 KC |
2779 | Most_recent_message_jiffies = jiffies; |
2780 | Poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST; | |
9f8d0e8b KC |
2781 | rc = queue_delayed_work(Periodic_controlvm_workqueue, |
2782 | &Periodic_controlvm_work, Poll_jiffies); | |
4cb005a9 KC |
2783 | if (rc < 0) { |
2784 | ERRDRV("queue_delayed_work(Periodic_controlvm_workqueue, &Periodic_controlvm_work, Poll_jiffies): error (status=%d)\n", rc); | |
2785 | POSTCODE_LINUX_2(QUEUE_DELAYED_WORK_PC, | |
2786 | DIAG_SEVERITY_ERR); | |
2787 | goto Away; | |
2788 | } | |
9f8d0e8b | 2789 | |
12e364b9 KC |
2790 | } |
2791 | ||
2792 | Visorchipset_platform_device.dev.devt = MajorDev; | |
4cb005a9 KC |
2793 | if (platform_device_register(&Visorchipset_platform_device) < 0) { |
2794 | ERRDRV("platform_device_register(visorchipset) failed: (status=-1)\n"); | |
2795 | POSTCODE_LINUX_2(DEVICE_REGISTER_FAILURE_PC, DIAG_SEVERITY_ERR); | |
2796 | rc = -1; | |
2797 | goto Away; | |
2798 | } | |
12e364b9 KC |
2799 | LOGINF("visorchipset device created"); |
2800 | POSTCODE_LINUX_2(CHIPSET_INIT_SUCCESS_PC, POSTCODE_SEVERITY_INFO); | |
2801 | RETINT(0); | |
2802 | ||
2803 | Away: | |
2804 | ||
2805 | if (rc) { | |
2806 | LOGERR("visorchipset_init failed"); | |
2807 | POSTCODE_LINUX_3(CHIPSET_INIT_FAILURE_PC, rc, | |
2808 | POSTCODE_SEVERITY_ERR); | |
2809 | } | |
2810 | return rc; | |
2811 | } | |
2812 | ||
2813 | static void | |
2814 | visorchipset_exit(void) | |
2815 | { | |
2816 | char s[99]; | |
2817 | POSTCODE_LINUX_2(DRIVER_EXIT_PC, POSTCODE_SEVERITY_INFO); | |
2818 | ||
2819 | if (visorchipset_disable_controlvm) { | |
2820 | ; | |
2821 | } else { | |
2822 | cancel_delayed_work(&Periodic_controlvm_work); | |
2823 | flush_workqueue(Periodic_controlvm_workqueue); | |
2824 | destroy_workqueue(Periodic_controlvm_workqueue); | |
2825 | Periodic_controlvm_workqueue = NULL; | |
2826 | destroy_controlvm_payload_info(&ControlVm_payload_info); | |
2827 | } | |
2828 | Test_Vnic_channel = NULL; | |
2829 | if (Putfile_buffer_list_pool) { | |
2830 | kmem_cache_destroy(Putfile_buffer_list_pool); | |
2831 | Putfile_buffer_list_pool = NULL; | |
2832 | } | |
2833 | filexfer_destructor(); | |
2834 | if (ControlVmObject) { | |
927c7927 | 2835 | visor_proc_DestroyObject(ControlVmObject); |
12e364b9 KC |
2836 | ControlVmObject = NULL; |
2837 | } | |
2838 | cleanup_controlvm_structures(); | |
2839 | ||
2840 | if (ControlVmType) { | |
927c7927 | 2841 | visor_proc_DestroyType(ControlVmType); |
12e364b9 KC |
2842 | ControlVmType = NULL; |
2843 | } | |
2844 | if (PartitionType) { | |
927c7927 | 2845 | visor_proc_DestroyType(PartitionType); |
12e364b9 KC |
2846 | PartitionType = NULL; |
2847 | } | |
2848 | if (diag_proc_dir) { | |
2849 | remove_proc_entry(VISORCHIPSET_DIAG_PROC_ENTRY_FN, ProcDir); | |
2850 | diag_proc_dir = NULL; | |
2851 | } | |
2852 | memset(&g_DiagMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER)); | |
2853 | ||
2854 | if (chipset_proc_dir) { | |
2855 | remove_proc_entry(VISORCHIPSET_CHIPSET_PROC_ENTRY_FN, ProcDir); | |
2856 | chipset_proc_dir = NULL; | |
2857 | } | |
2858 | memset(&g_ChipSetMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER)); | |
2859 | ||
2860 | if (parahotplug_proc_dir) { | |
2861 | remove_proc_entry(VISORCHIPSET_PARAHOTPLUG_PROC_ENTRY_FN, | |
2862 | ProcDir); | |
2863 | parahotplug_proc_dir = NULL; | |
2864 | } | |
2865 | ||
2866 | memset(&g_DelDumpMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER)); | |
2867 | ||
2868 | proc_DeInit(); | |
2869 | if (ControlVm_channel != NULL) { | |
2870 | LOGINF("Channel %s (ControlVm) disconnected", | |
2871 | visorchannel_id(ControlVm_channel, s)); | |
2872 | visorchannel_destroy(ControlVm_channel); | |
2873 | ControlVm_channel = NULL; | |
2874 | } | |
2875 | controlvm_deinit(); | |
2876 | visorchipset_file_cleanup(); | |
2877 | POSTCODE_LINUX_2(DRIVER_EXIT_PC, POSTCODE_SEVERITY_INFO); | |
2878 | LOGINF("chipset driver unloaded"); | |
2879 | } | |
2880 | ||
2881 | module_param_named(testvnic, visorchipset_testvnic, int, S_IRUGO); | |
2882 | MODULE_PARM_DESC(visorchipset_testvnic, "1 to test vnic, using dummy VNIC connected via a loopback to a physical ethernet"); | |
2883 | int visorchipset_testvnic = 0; | |
2884 | ||
2885 | module_param_named(testvnicclient, visorchipset_testvnicclient, int, S_IRUGO); | |
2886 | MODULE_PARM_DESC(visorchipset_testvnicclient, "1 to test vnic, using real VNIC channel attached to a separate IOVM guest"); | |
2887 | int visorchipset_testvnicclient = 0; | |
2888 | ||
2889 | module_param_named(testmsg, visorchipset_testmsg, int, S_IRUGO); | |
2890 | MODULE_PARM_DESC(visorchipset_testmsg, | |
2891 | "1 to manufacture the chipset, bus, and switch messages"); | |
2892 | int visorchipset_testmsg = 0; | |
2893 | ||
2894 | module_param_named(major, visorchipset_major, int, S_IRUGO); | |
2895 | MODULE_PARM_DESC(visorchipset_major, "major device number to use for the device node"); | |
2896 | int visorchipset_major = 0; | |
2897 | ||
2898 | module_param_named(serverregwait, visorchipset_serverregwait, int, S_IRUGO); | |
2899 | MODULE_PARM_DESC(visorchipset_serverreqwait, | |
2900 | "1 to have the module wait for the visor bus to register"); | |
2901 | int visorchipset_serverregwait = 0; /* default is off */ | |
2902 | module_param_named(clientregwait, visorchipset_clientregwait, int, S_IRUGO); | |
2903 | MODULE_PARM_DESC(visorchipset_clientregwait, "1 to have the module wait for the visorclientbus to register"); | |
2904 | int visorchipset_clientregwait = 1; /* default is on */ | |
2905 | module_param_named(testteardown, visorchipset_testteardown, int, S_IRUGO); | |
2906 | MODULE_PARM_DESC(visorchipset_testteardown, | |
2907 | "1 to test teardown of the chipset, bus, and switch"); | |
2908 | int visorchipset_testteardown = 0; /* default is off */ | |
2909 | module_param_named(disable_controlvm, visorchipset_disable_controlvm, int, | |
2910 | S_IRUGO); | |
2911 | MODULE_PARM_DESC(visorchipset_disable_controlvm, | |
2912 | "1 to disable polling of controlVm channel"); | |
2913 | int visorchipset_disable_controlvm = 0; /* default is off */ | |
2914 | module_param_named(crash_kernel, visorchipset_crash_kernel, int, S_IRUGO); | |
2915 | MODULE_PARM_DESC(visorchipset_crash_kernel, | |
2916 | "1 means we are running in crash kernel"); | |
2917 | int visorchipset_crash_kernel = 0; /* default is running in non-crash kernel */ | |
2918 | module_param_named(holdchipsetready, visorchipset_holdchipsetready, | |
2919 | int, S_IRUGO); | |
2920 | MODULE_PARM_DESC(visorchipset_holdchipsetready, | |
2921 | "1 to hold response to CHIPSET_READY"); | |
2922 | int visorchipset_holdchipsetready = 0; /* default is to send CHIPSET_READY | |
2923 | * response immediately */ | |
2924 | module_init(visorchipset_init); | |
2925 | module_exit(visorchipset_exit); | |
2926 | ||
2927 | MODULE_AUTHOR("Unisys"); | |
2928 | MODULE_LICENSE("GPL"); | |
2929 | MODULE_DESCRIPTION("Supervisor chipset driver for service partition: ver " | |
2930 | VERSION); | |
2931 | MODULE_VERSION(VERSION); |