3 * Copyright (C) 2010 - 2013 UNISYS CORPORATION
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.
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
19 #include "visorchipset.h"
20 #include "procobjecttree.h"
21 #include "visorchannel.h"
22 #include "periodic_work.h"
26 #include "controlvmcompletionstatus.h"
27 #include "guestlinuxdebug.h"
29 #include <linux/nls.h>
30 #include <linux/netdevice.h>
31 #include <linux/platform_device.h>
32 #include <linux/uuid.h>
33 #include <linux/crash_dump.h>
35 #define CURRENT_FILE_PC VISOR_CHIPSET_PC_visorchipset_main_c
36 #define TEST_VNIC_PHYSITF "eth0" /* physical network itf for
37 * vnic loopback test */
38 #define TEST_VNIC_SWITCHNO 1
39 #define TEST_VNIC_BUSNO 9
41 #define MAX_NAME_SIZE 128
42 #define MAX_IP_SIZE 50
43 #define MAXOUTSTANDINGCHANNELCOMMAND 256
44 #define POLLJIFFIES_CONTROLVMCHANNEL_FAST 1
45 #define POLLJIFFIES_CONTROLVMCHANNEL_SLOW 100
50 static int visorchipset_testvnic;
51 static int visorchipset_testvnicclient;
52 static int visorchipset_testmsg;
53 static int visorchipset_major;
54 static int visorchipset_serverregwait;
55 static int visorchipset_clientregwait = 1; /* default is on */
56 static int visorchipset_testteardown;
57 static int visorchipset_disable_controlvm;
58 static int visorchipset_holdchipsetready;
60 /* When the controlvm channel is idle for at least MIN_IDLE_SECONDS,
61 * we switch to slow polling mode. As soon as we get a controlvm
62 * message, we switch back to fast polling mode.
64 #define MIN_IDLE_SECONDS 10
65 static unsigned long poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST;
66 static unsigned long most_recent_message_jiffies; /* when we got our last
67 * controlvm message */
68 static int serverregistered;
69 static int clientregistered;
71 #define MAX_CHIPSET_EVENTS 2
72 static u8 chipset_events[MAX_CHIPSET_EVENTS] = { 0, 0 };
74 static struct delayed_work periodic_controlvm_work;
75 static struct workqueue_struct *periodic_controlvm_workqueue;
76 static DEFINE_SEMAPHORE(notifier_lock);
78 static struct controlvm_message_header g_diag_msg_hdr;
79 static struct controlvm_message_header g_chipset_msg_hdr;
80 static struct controlvm_message_header g_del_dump_msg_hdr;
81 static const uuid_le spar_diag_pool_channel_protocol_uuid =
82 SPAR_DIAG_POOL_CHANNEL_PROTOCOL_UUID;
83 /* 0xffffff is an invalid Bus/Device number */
84 static u32 g_diagpool_bus_no = 0xffffff;
85 static u32 g_diagpool_dev_no = 0xffffff;
86 static struct controlvm_message_packet g_devicechangestate_packet;
88 /* Only VNIC and VHBA channels are sent to visorclientbus (aka
91 #define FOR_VISORHACKBUS(channel_type_guid) \
92 (((uuid_le_cmp(channel_type_guid,\
93 spar_vnic_channel_protocol_uuid) == 0) ||\
94 (uuid_le_cmp(channel_type_guid,\
95 spar_vhba_channel_protocol_uuid) == 0)))
96 #define FOR_VISORBUS(channel_type_guid) (!(FOR_VISORHACKBUS(channel_type_guid)))
98 #define is_diagpool_channel(channel_type_guid) \
99 (uuid_le_cmp(channel_type_guid,\
100 spar_diag_pool_channel_protocol_uuid) == 0)
102 static LIST_HEAD(bus_info_list);
103 static LIST_HEAD(dev_info_list);
105 static struct visorchannel *controlvm_channel;
107 /* Manages the request payload in the controlvm channel */
108 struct visor_controlvm_payload_info {
109 u8 __iomem *ptr; /* pointer to base address of payload pool */
110 u64 offset; /* offset from beginning of controlvm
111 * channel to beginning of payload * pool */
112 u32 bytes; /* number of bytes in payload pool */
115 static struct visor_controlvm_payload_info controlvm_payload_info;
117 /* Manages the info for a CONTROLVM_DUMP_CAPTURESTATE /
118 * CONTROLVM_DUMP_GETTEXTDUMP / CONTROLVM_DUMP_COMPLETE conversation.
120 struct visor_livedump_info {
121 struct controlvm_message_header dumpcapture_header;
122 struct controlvm_message_header gettextdump_header;
123 struct controlvm_message_header dumpcomplete_header;
124 bool gettextdump_outstanding;
126 unsigned long length;
127 atomic_t buffers_in_use;
128 unsigned long destination;
131 static struct visor_livedump_info livedump_info;
133 /* The following globals are used to handle the scenario where we are unable to
134 * offload the payload from a controlvm message due to memory requirements. In
135 * this scenario, we simply stash the controlvm message, then attempt to
136 * process it again the next time controlvm_periodic_work() runs.
138 static struct controlvm_message controlvm_pending_msg;
139 static bool controlvm_pending_msg_valid = false;
141 /* This identifies a data buffer that has been received via a controlvm messages
142 * in a remote --> local CONTROLVM_TRANSMIT_FILE conversation.
144 struct putfile_buffer_entry {
145 struct list_head next; /* putfile_buffer_entry list */
146 struct parser_context *parser_ctx; /* points to input data buffer */
149 /* List of struct putfile_request *, via next_putfile_request member.
150 * Each entry in this list identifies an outstanding TRANSMIT_FILE
153 static LIST_HEAD(putfile_request_list);
155 /* This describes a buffer and its current state of transfer (e.g., how many
156 * bytes have already been supplied as putfile data, and how many bytes are
157 * remaining) for a putfile_request.
159 struct putfile_active_buffer {
160 /* a payload from a controlvm message, containing a file data buffer */
161 struct parser_context *parser_ctx;
162 /* points within data area of parser_ctx to next byte of data */
164 /* # bytes left from <pnext> to the end of this data buffer */
165 size_t bytes_remaining;
168 #define PUTFILE_REQUEST_SIG 0x0906101302281211
169 /* This identifies a single remote --> local CONTROLVM_TRANSMIT_FILE
170 * conversation. Structs of this type are dynamically linked into
171 * <Putfile_request_list>.
173 struct putfile_request {
174 u64 sig; /* PUTFILE_REQUEST_SIG */
176 /* header from original TransmitFile request */
177 struct controlvm_message_header controlvm_header;
178 u64 file_request_number; /* from original TransmitFile request */
180 /* link to next struct putfile_request */
181 struct list_head next_putfile_request;
183 /* most-recent sequence number supplied via a controlvm message */
184 u64 data_sequence_number;
186 /* head of putfile_buffer_entry list, which describes the data to be
187 * supplied as putfile data;
188 * - this list is added to when controlvm messages come in that supply
190 * - this list is removed from via the hotplug program that is actually
191 * consuming these buffers to write as file data */
192 struct list_head input_buffer_list;
193 spinlock_t req_list_lock; /* lock for input_buffer_list */
195 /* waiters for input_buffer_list to go non-empty */
196 wait_queue_head_t input_buffer_wq;
198 /* data not yet read within current putfile_buffer_entry */
199 struct putfile_active_buffer active_buf;
201 /* <0 = failed, 0 = in-progress, >0 = successful; */
202 /* note that this must be set with req_list_lock, and if you set <0, */
203 /* it is your responsibility to also free up all of the other objects */
204 /* in this struct (like input_buffer_list, active_buf.parser_ctx) */
205 /* before releasing the lock */
206 int completion_status;
209 struct parahotplug_request {
210 struct list_head list;
212 unsigned long expiration;
213 struct controlvm_message msg;
216 static LIST_HEAD(parahotplug_request_list);
217 static DEFINE_SPINLOCK(parahotplug_request_list_lock); /* lock for above */
218 static void parahotplug_process_list(void);
220 /* Manages the info for a CONTROLVM_DUMP_CAPTURESTATE /
221 * CONTROLVM_REPORTEVENT.
223 static struct visorchipset_busdev_notifiers busdev_server_notifiers;
224 static struct visorchipset_busdev_notifiers busdev_client_notifiers;
226 static void bus_create_response(u32 bus_no, int response);
227 static void bus_destroy_response(u32 bus_no, int response);
228 static void device_create_response(u32 bus_no, u32 dev_no, int response);
229 static void device_destroy_response(u32 bus_no, u32 dev_no, int response);
230 static void device_resume_response(u32 bus_no, u32 dev_no, int response);
232 static struct visorchipset_busdev_responders busdev_responders = {
233 .bus_create = bus_create_response,
234 .bus_destroy = bus_destroy_response,
235 .device_create = device_create_response,
236 .device_destroy = device_destroy_response,
237 .device_pause = visorchipset_device_pause_response,
238 .device_resume = device_resume_response,
241 /* info for /dev/visorchipset */
242 static dev_t major_dev = -1; /**< indicates major num for device */
244 /* prototypes for attributes */
245 static ssize_t toolaction_show(struct device *dev,
246 struct device_attribute *attr, char *buf);
247 static ssize_t toolaction_store(struct device *dev,
248 struct device_attribute *attr,
249 const char *buf, size_t count);
250 static DEVICE_ATTR_RW(toolaction);
252 static ssize_t boottotool_show(struct device *dev,
253 struct device_attribute *attr, char *buf);
254 static ssize_t boottotool_store(struct device *dev,
255 struct device_attribute *attr, const char *buf,
257 static DEVICE_ATTR_RW(boottotool);
259 static ssize_t error_show(struct device *dev, struct device_attribute *attr,
261 static ssize_t error_store(struct device *dev, struct device_attribute *attr,
262 const char *buf, size_t count);
263 static DEVICE_ATTR_RW(error);
265 static ssize_t textid_show(struct device *dev, struct device_attribute *attr,
267 static ssize_t textid_store(struct device *dev, struct device_attribute *attr,
268 const char *buf, size_t count);
269 static DEVICE_ATTR_RW(textid);
271 static ssize_t remaining_steps_show(struct device *dev,
272 struct device_attribute *attr, char *buf);
273 static ssize_t remaining_steps_store(struct device *dev,
274 struct device_attribute *attr,
275 const char *buf, size_t count);
276 static DEVICE_ATTR_RW(remaining_steps);
278 static ssize_t chipsetready_store(struct device *dev,
279 struct device_attribute *attr,
280 const char *buf, size_t count);
281 static DEVICE_ATTR_WO(chipsetready);
283 static ssize_t devicedisabled_store(struct device *dev,
284 struct device_attribute *attr,
285 const char *buf, size_t count);
286 static DEVICE_ATTR_WO(devicedisabled);
288 static ssize_t deviceenabled_store(struct device *dev,
289 struct device_attribute *attr,
290 const char *buf, size_t count);
291 static DEVICE_ATTR_WO(deviceenabled);
293 static struct attribute *visorchipset_install_attrs[] = {
294 &dev_attr_toolaction.attr,
295 &dev_attr_boottotool.attr,
296 &dev_attr_error.attr,
297 &dev_attr_textid.attr,
298 &dev_attr_remaining_steps.attr,
302 static struct attribute_group visorchipset_install_group = {
304 .attrs = visorchipset_install_attrs
307 static struct attribute *visorchipset_guest_attrs[] = {
308 &dev_attr_chipsetready.attr,
312 static struct attribute_group visorchipset_guest_group = {
314 .attrs = visorchipset_guest_attrs
317 static struct attribute *visorchipset_parahotplug_attrs[] = {
318 &dev_attr_devicedisabled.attr,
319 &dev_attr_deviceenabled.attr,
323 static struct attribute_group visorchipset_parahotplug_group = {
324 .name = "parahotplug",
325 .attrs = visorchipset_parahotplug_attrs
328 static const struct attribute_group *visorchipset_dev_groups[] = {
329 &visorchipset_install_group,
330 &visorchipset_guest_group,
331 &visorchipset_parahotplug_group,
335 /* /sys/devices/platform/visorchipset */
336 static struct platform_device visorchipset_platform_device = {
337 .name = "visorchipset",
339 .dev.groups = visorchipset_dev_groups,
342 /* Function prototypes */
343 static void controlvm_respond(struct controlvm_message_header *msg_hdr,
345 static void controlvm_respond_chipset_init(
346 struct controlvm_message_header *msg_hdr, int response,
347 enum ultra_chipset_feature features);
348 static void controlvm_respond_physdev_changestate(
349 struct controlvm_message_header *msg_hdr, int response,
350 struct spar_segment_state state);
352 static ssize_t toolaction_show(struct device *dev,
353 struct device_attribute *attr,
358 visorchannel_read(controlvm_channel,
359 offsetof(struct spar_controlvm_channel_protocol,
360 tool_action), &tool_action, sizeof(u8));
361 return scnprintf(buf, PAGE_SIZE, "%u\n", tool_action);
364 static ssize_t toolaction_store(struct device *dev,
365 struct device_attribute *attr,
366 const char *buf, size_t count)
371 if (kstrtou8(buf, 10, &tool_action))
374 ret = visorchannel_write(controlvm_channel,
375 offsetof(struct spar_controlvm_channel_protocol,
377 &tool_action, sizeof(u8));
384 static ssize_t boottotool_show(struct device *dev,
385 struct device_attribute *attr,
388 struct efi_spar_indication efi_spar_indication;
390 visorchannel_read(controlvm_channel,
391 offsetof(struct spar_controlvm_channel_protocol,
392 efi_spar_ind), &efi_spar_indication,
393 sizeof(struct efi_spar_indication));
394 return scnprintf(buf, PAGE_SIZE, "%u\n",
395 efi_spar_indication.boot_to_tool);
398 static ssize_t boottotool_store(struct device *dev,
399 struct device_attribute *attr,
400 const char *buf, size_t count)
403 struct efi_spar_indication efi_spar_indication;
405 if (kstrtoint(buf, 10, &val))
408 efi_spar_indication.boot_to_tool = val;
409 ret = visorchannel_write(controlvm_channel,
410 offsetof(struct spar_controlvm_channel_protocol,
411 efi_spar_ind), &(efi_spar_indication),
412 sizeof(struct efi_spar_indication));
419 static ssize_t error_show(struct device *dev, struct device_attribute *attr,
424 visorchannel_read(controlvm_channel,
425 offsetof(struct spar_controlvm_channel_protocol,
427 &error, sizeof(u32));
428 return scnprintf(buf, PAGE_SIZE, "%i\n", error);
431 static ssize_t error_store(struct device *dev, struct device_attribute *attr,
432 const char *buf, size_t count)
437 if (kstrtou32(buf, 10, &error))
440 ret = visorchannel_write(controlvm_channel,
441 offsetof(struct spar_controlvm_channel_protocol,
443 &error, sizeof(u32));
449 static ssize_t textid_show(struct device *dev, struct device_attribute *attr,
454 visorchannel_read(controlvm_channel,
455 offsetof(struct spar_controlvm_channel_protocol,
456 installation_text_id),
457 &text_id, sizeof(u32));
458 return scnprintf(buf, PAGE_SIZE, "%i\n", text_id);
461 static ssize_t textid_store(struct device *dev, struct device_attribute *attr,
462 const char *buf, size_t count)
467 if (kstrtou32(buf, 10, &text_id))
470 ret = visorchannel_write(controlvm_channel,
471 offsetof(struct spar_controlvm_channel_protocol,
472 installation_text_id),
473 &text_id, sizeof(u32));
479 static ssize_t remaining_steps_show(struct device *dev,
480 struct device_attribute *attr, char *buf)
484 visorchannel_read(controlvm_channel,
485 offsetof(struct spar_controlvm_channel_protocol,
486 installation_remaining_steps),
487 &remaining_steps, sizeof(u16));
488 return scnprintf(buf, PAGE_SIZE, "%hu\n", remaining_steps);
491 static ssize_t remaining_steps_store(struct device *dev,
492 struct device_attribute *attr,
493 const char *buf, size_t count)
498 if (kstrtou16(buf, 10, &remaining_steps))
501 ret = visorchannel_write(controlvm_channel,
502 offsetof(struct spar_controlvm_channel_protocol,
503 installation_remaining_steps),
504 &remaining_steps, sizeof(u16));
511 bus_info_clear(void *v)
513 struct visorchipset_bus_info *p = (struct visorchipset_bus_info *) v;
516 kfree(p->description);
517 memset(p, 0, sizeof(struct visorchipset_bus_info));
521 dev_info_clear(void *v)
523 struct visorchipset_device_info *p =
524 (struct visorchipset_device_info *) v;
526 memset(p, 0, sizeof(struct visorchipset_device_info));
529 static struct visorchipset_bus_info *
530 bus_find(struct list_head *list, u32 bus_no)
532 struct visorchipset_bus_info *p;
534 list_for_each_entry(p, list, entry) {
535 if (p->bus_no == bus_no)
542 static struct visorchipset_device_info *
543 device_find(struct list_head *list, u32 bus_no, u32 dev_no)
545 struct visorchipset_device_info *p;
547 list_for_each_entry(p, list, entry) {
548 if (p->bus_no == bus_no && p->dev_no == dev_no)
555 static void busdevices_del(struct list_head *list, u32 bus_no)
557 struct visorchipset_device_info *p, *tmp;
559 list_for_each_entry_safe(p, tmp, list, entry) {
560 if (p->bus_no == bus_no) {
568 check_chipset_events(void)
572 /* Check events to determine if response should be sent */
573 for (i = 0; i < MAX_CHIPSET_EVENTS; i++)
574 send_msg &= chipset_events[i];
579 clear_chipset_events(void)
582 /* Clear chipset_events */
583 for (i = 0; i < MAX_CHIPSET_EVENTS; i++)
584 chipset_events[i] = 0;
588 visorchipset_register_busdev_server(
589 struct visorchipset_busdev_notifiers *notifiers,
590 struct visorchipset_busdev_responders *responders,
591 struct ultra_vbus_deviceinfo *driver_info)
593 down(¬ifier_lock);
595 memset(&busdev_server_notifiers, 0,
596 sizeof(busdev_server_notifiers));
597 serverregistered = 0; /* clear flag */
599 busdev_server_notifiers = *notifiers;
600 serverregistered = 1; /* set flag */
603 *responders = busdev_responders;
605 bus_device_info_init(driver_info, "chipset", "visorchipset",
610 EXPORT_SYMBOL_GPL(visorchipset_register_busdev_server);
613 visorchipset_register_busdev_client(
614 struct visorchipset_busdev_notifiers *notifiers,
615 struct visorchipset_busdev_responders *responders,
616 struct ultra_vbus_deviceinfo *driver_info)
618 down(¬ifier_lock);
620 memset(&busdev_client_notifiers, 0,
621 sizeof(busdev_client_notifiers));
622 clientregistered = 0; /* clear flag */
624 busdev_client_notifiers = *notifiers;
625 clientregistered = 1; /* set flag */
628 *responders = busdev_responders;
630 bus_device_info_init(driver_info, "chipset(bolts)",
631 "visorchipset", VERSION, NULL);
634 EXPORT_SYMBOL_GPL(visorchipset_register_busdev_client);
637 cleanup_controlvm_structures(void)
639 struct visorchipset_bus_info *bi, *tmp_bi;
640 struct visorchipset_device_info *di, *tmp_di;
642 list_for_each_entry_safe(bi, tmp_bi, &bus_info_list, entry) {
644 list_del(&bi->entry);
648 list_for_each_entry_safe(di, tmp_di, &dev_info_list, entry) {
650 list_del(&di->entry);
656 chipset_init(struct controlvm_message *inmsg)
658 static int chipset_inited;
659 enum ultra_chipset_feature features = 0;
660 int rc = CONTROLVM_RESP_SUCCESS;
662 POSTCODE_LINUX_2(CHIPSET_INIT_ENTRY_PC, POSTCODE_SEVERITY_INFO);
663 if (chipset_inited) {
664 rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
668 POSTCODE_LINUX_2(CHIPSET_INIT_EXIT_PC, POSTCODE_SEVERITY_INFO);
670 /* Set features to indicate we support parahotplug (if Command
671 * also supports it). */
673 inmsg->cmd.init_chipset.
674 features & ULTRA_CHIPSET_FEATURE_PARA_HOTPLUG;
676 /* Set the "reply" bit so Command knows this is a
677 * features-aware driver. */
678 features |= ULTRA_CHIPSET_FEATURE_REPLY;
682 cleanup_controlvm_structures();
683 if (inmsg->hdr.flags.response_expected)
684 controlvm_respond_chipset_init(&inmsg->hdr, rc, features);
688 controlvm_init_response(struct controlvm_message *msg,
689 struct controlvm_message_header *msg_hdr, int response)
691 memset(msg, 0, sizeof(struct controlvm_message));
692 memcpy(&msg->hdr, msg_hdr, sizeof(struct controlvm_message_header));
693 msg->hdr.payload_bytes = 0;
694 msg->hdr.payload_vm_offset = 0;
695 msg->hdr.payload_max_bytes = 0;
697 msg->hdr.flags.failed = 1;
698 msg->hdr.completion_status = (u32) (-response);
703 controlvm_respond(struct controlvm_message_header *msg_hdr, int response)
705 struct controlvm_message outmsg;
707 controlvm_init_response(&outmsg, msg_hdr, response);
708 /* For DiagPool channel DEVICE_CHANGESTATE, we need to send
709 * back the deviceChangeState structure in the packet. */
710 if (msg_hdr->id == CONTROLVM_DEVICE_CHANGESTATE &&
711 g_devicechangestate_packet.device_change_state.bus_no ==
713 g_devicechangestate_packet.device_change_state.dev_no ==
715 outmsg.cmd = g_devicechangestate_packet;
716 if (outmsg.hdr.flags.test_message == 1)
719 if (!visorchannel_signalinsert(controlvm_channel,
720 CONTROLVM_QUEUE_REQUEST, &outmsg)) {
726 controlvm_respond_chipset_init(struct controlvm_message_header *msg_hdr,
728 enum ultra_chipset_feature features)
730 struct controlvm_message outmsg;
732 controlvm_init_response(&outmsg, msg_hdr, response);
733 outmsg.cmd.init_chipset.features = features;
734 if (!visorchannel_signalinsert(controlvm_channel,
735 CONTROLVM_QUEUE_REQUEST, &outmsg)) {
740 static void controlvm_respond_physdev_changestate(
741 struct controlvm_message_header *msg_hdr, int response,
742 struct spar_segment_state state)
744 struct controlvm_message outmsg;
746 controlvm_init_response(&outmsg, msg_hdr, response);
747 outmsg.cmd.device_change_state.state = state;
748 outmsg.cmd.device_change_state.flags.phys_device = 1;
749 if (!visorchannel_signalinsert(controlvm_channel,
750 CONTROLVM_QUEUE_REQUEST, &outmsg)) {
756 visorchipset_save_message(struct controlvm_message *msg,
757 enum crash_obj_type type)
759 u32 crash_msg_offset;
762 /* get saved message count */
763 if (visorchannel_read(controlvm_channel,
764 offsetof(struct spar_controlvm_channel_protocol,
765 saved_crash_message_count),
766 &crash_msg_count, sizeof(u16)) < 0) {
767 POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC,
768 POSTCODE_SEVERITY_ERR);
772 if (crash_msg_count != CONTROLVM_CRASHMSG_MAX) {
773 POSTCODE_LINUX_3(CRASH_DEV_COUNT_FAILURE_PC,
775 POSTCODE_SEVERITY_ERR);
779 /* get saved crash message offset */
780 if (visorchannel_read(controlvm_channel,
781 offsetof(struct spar_controlvm_channel_protocol,
782 saved_crash_message_offset),
783 &crash_msg_offset, sizeof(u32)) < 0) {
784 POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC,
785 POSTCODE_SEVERITY_ERR);
789 if (type == CRASH_BUS) {
790 if (visorchannel_write(controlvm_channel,
793 sizeof(struct controlvm_message)) < 0) {
794 POSTCODE_LINUX_2(SAVE_MSG_BUS_FAILURE_PC,
795 POSTCODE_SEVERITY_ERR);
799 if (visorchannel_write(controlvm_channel,
801 sizeof(struct controlvm_message), msg,
802 sizeof(struct controlvm_message)) < 0) {
803 POSTCODE_LINUX_2(SAVE_MSG_DEV_FAILURE_PC,
804 POSTCODE_SEVERITY_ERR);
809 EXPORT_SYMBOL_GPL(visorchipset_save_message);
812 bus_responder(enum controlvm_id cmd_id, u32 bus_no, int response)
814 struct visorchipset_bus_info *p;
815 bool need_clear = false;
817 p = bus_find(&bus_info_list, bus_no);
822 if ((cmd_id == CONTROLVM_BUS_CREATE) &&
823 (response != (-CONTROLVM_RESP_ERROR_ALREADY_DONE)))
824 /* undo the row we just created... */
825 busdevices_del(&dev_info_list, bus_no);
827 if (cmd_id == CONTROLVM_BUS_CREATE)
828 p->state.created = 1;
829 if (cmd_id == CONTROLVM_BUS_DESTROY)
833 if (p->pending_msg_hdr.id == CONTROLVM_INVALID)
834 return; /* no controlvm response needed */
835 if (p->pending_msg_hdr.id != (u32)cmd_id)
837 controlvm_respond(&p->pending_msg_hdr, response);
838 p->pending_msg_hdr.id = CONTROLVM_INVALID;
841 busdevices_del(&dev_info_list, bus_no);
846 device_changestate_responder(enum controlvm_id cmd_id,
847 u32 bus_no, u32 dev_no, int response,
848 struct spar_segment_state response_state)
850 struct visorchipset_device_info *p;
851 struct controlvm_message outmsg;
853 p = device_find(&dev_info_list, bus_no, dev_no);
856 if (p->pending_msg_hdr.id == CONTROLVM_INVALID)
857 return; /* no controlvm response needed */
858 if (p->pending_msg_hdr.id != cmd_id)
861 controlvm_init_response(&outmsg, &p->pending_msg_hdr, response);
863 outmsg.cmd.device_change_state.bus_no = bus_no;
864 outmsg.cmd.device_change_state.dev_no = dev_no;
865 outmsg.cmd.device_change_state.state = response_state;
867 if (!visorchannel_signalinsert(controlvm_channel,
868 CONTROLVM_QUEUE_REQUEST, &outmsg))
871 p->pending_msg_hdr.id = CONTROLVM_INVALID;
875 device_responder(enum controlvm_id cmd_id, u32 bus_no, u32 dev_no, int response)
877 struct visorchipset_device_info *p;
878 bool need_clear = false;
880 p = device_find(&dev_info_list, bus_no, dev_no);
884 if (cmd_id == CONTROLVM_DEVICE_CREATE)
885 p->state.created = 1;
886 if (cmd_id == CONTROLVM_DEVICE_DESTROY)
890 if (p->pending_msg_hdr.id == CONTROLVM_INVALID)
891 return; /* no controlvm response needed */
893 if (p->pending_msg_hdr.id != (u32)cmd_id)
896 controlvm_respond(&p->pending_msg_hdr, response);
897 p->pending_msg_hdr.id = CONTROLVM_INVALID;
903 bus_epilog(u32 bus_no,
904 u32 cmd, struct controlvm_message_header *msg_hdr,
905 int response, bool need_response)
907 struct visorchipset_bus_info *bus_info;
908 bool notified = false;
910 bus_info = bus_find(&bus_info_list, bus_no);
916 memcpy(&bus_info->pending_msg_hdr, msg_hdr,
917 sizeof(struct controlvm_message_header));
919 bus_info->pending_msg_hdr.id = CONTROLVM_INVALID;
922 down(¬ifier_lock);
923 if (response == CONTROLVM_RESP_SUCCESS) {
925 case CONTROLVM_BUS_CREATE:
926 /* We can't tell from the bus_create
927 * information which of our 2 bus flavors the
928 * devices on this bus will ultimately end up.
929 * FORTUNATELY, it turns out it is harmless to
930 * send the bus_create to both of them. We can
931 * narrow things down a little bit, though,
932 * because we know: - BusDev_Server can handle
933 * either server or client devices
934 * - BusDev_Client can handle ONLY client
936 if (busdev_server_notifiers.bus_create) {
937 (*busdev_server_notifiers.bus_create) (bus_no);
940 if ((!bus_info->flags.server) /*client */ &&
941 busdev_client_notifiers.bus_create) {
942 (*busdev_client_notifiers.bus_create) (bus_no);
946 case CONTROLVM_BUS_DESTROY:
947 if (busdev_server_notifiers.bus_destroy) {
948 (*busdev_server_notifiers.bus_destroy) (bus_no);
951 if ((!bus_info->flags.server) /*client */ &&
952 busdev_client_notifiers.bus_destroy) {
953 (*busdev_client_notifiers.bus_destroy) (bus_no);
960 /* The callback function just called above is responsible
961 * for calling the appropriate visorchipset_busdev_responders
962 * function, which will call bus_responder()
966 bus_responder(cmd, bus_no, response);
971 device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd,
972 struct controlvm_message_header *msg_hdr, int response,
973 bool need_response, bool for_visorbus)
975 struct visorchipset_busdev_notifiers *notifiers;
976 bool notified = false;
978 struct visorchipset_device_info *dev_info =
979 device_find(&dev_info_list, bus_no, dev_no);
981 "SPARSP_DIAGPOOL_PAUSED_STATE = 1",
989 notifiers = &busdev_server_notifiers;
991 notifiers = &busdev_client_notifiers;
993 memcpy(&dev_info->pending_msg_hdr, msg_hdr,
994 sizeof(struct controlvm_message_header));
996 dev_info->pending_msg_hdr.id = CONTROLVM_INVALID;
999 down(¬ifier_lock);
1000 if (response >= 0) {
1002 case CONTROLVM_DEVICE_CREATE:
1003 if (notifiers->device_create) {
1004 (*notifiers->device_create) (bus_no, dev_no);
1008 case CONTROLVM_DEVICE_CHANGESTATE:
1009 /* ServerReady / ServerRunning / SegmentStateRunning */
1010 if (state.alive == segment_state_running.alive &&
1012 segment_state_running.operating) {
1013 if (notifiers->device_resume) {
1014 (*notifiers->device_resume) (bus_no,
1019 /* ServerNotReady / ServerLost / SegmentStateStandby */
1020 else if (state.alive == segment_state_standby.alive &&
1022 segment_state_standby.operating) {
1023 /* technically this is standby case
1024 * where server is lost
1026 if (notifiers->device_pause) {
1027 (*notifiers->device_pause) (bus_no,
1031 } else if (state.alive == segment_state_paused.alive &&
1033 segment_state_paused.operating) {
1034 /* this is lite pause where channel is
1035 * still valid just 'pause' of it
1037 if (bus_no == g_diagpool_bus_no &&
1038 dev_no == g_diagpool_dev_no) {
1039 /* this will trigger the
1040 * diag_shutdown.sh script in
1041 * the visorchipset hotplug */
1043 (&visorchipset_platform_device.dev.
1044 kobj, KOBJ_ONLINE, envp);
1048 case CONTROLVM_DEVICE_DESTROY:
1049 if (notifiers->device_destroy) {
1050 (*notifiers->device_destroy) (bus_no, dev_no);
1057 /* The callback function just called above is responsible
1058 * for calling the appropriate visorchipset_busdev_responders
1059 * function, which will call device_responder()
1063 device_responder(cmd, bus_no, dev_no, response);
1068 bus_create(struct controlvm_message *inmsg)
1070 struct controlvm_message_packet *cmd = &inmsg->cmd;
1071 u32 bus_no = cmd->create_bus.bus_no;
1072 int rc = CONTROLVM_RESP_SUCCESS;
1073 struct visorchipset_bus_info *bus_info;
1075 bus_info = bus_find(&bus_info_list, bus_no);
1076 if (bus_info && (bus_info->state.created == 1)) {
1077 POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no,
1078 POSTCODE_SEVERITY_ERR);
1079 rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
1082 bus_info = kzalloc(sizeof(*bus_info), GFP_KERNEL);
1084 POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no,
1085 POSTCODE_SEVERITY_ERR);
1086 rc = -CONTROLVM_RESP_ERROR_KMALLOC_FAILED;
1090 INIT_LIST_HEAD(&bus_info->entry);
1091 bus_info->bus_no = bus_no;
1093 POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, bus_no, POSTCODE_SEVERITY_INFO);
1095 if (inmsg->hdr.flags.test_message == 1)
1096 bus_info->chan_info.addr_type = ADDRTYPE_LOCALTEST;
1098 bus_info->chan_info.addr_type = ADDRTYPE_LOCALPHYSICAL;
1100 bus_info->flags.server = inmsg->hdr.flags.server;
1101 bus_info->chan_info.channel_addr = cmd->create_bus.channel_addr;
1102 bus_info->chan_info.n_channel_bytes = cmd->create_bus.channel_bytes;
1103 bus_info->chan_info.channel_type_uuid =
1104 cmd->create_bus.bus_data_type_uuid;
1105 bus_info->chan_info.channel_inst_uuid = cmd->create_bus.bus_inst_uuid;
1107 list_add(&bus_info->entry, &bus_info_list);
1109 POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, bus_no, POSTCODE_SEVERITY_INFO);
1112 bus_epilog(bus_no, CONTROLVM_BUS_CREATE, &inmsg->hdr,
1113 rc, inmsg->hdr.flags.response_expected == 1);
1117 bus_destroy(struct controlvm_message *inmsg)
1119 struct controlvm_message_packet *cmd = &inmsg->cmd;
1120 u32 bus_no = cmd->destroy_bus.bus_no;
1121 struct visorchipset_bus_info *bus_info;
1122 int rc = CONTROLVM_RESP_SUCCESS;
1124 bus_info = bus_find(&bus_info_list, bus_no);
1126 rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
1127 else if (bus_info->state.created == 0)
1128 rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
1130 bus_epilog(bus_no, CONTROLVM_BUS_DESTROY, &inmsg->hdr,
1131 rc, inmsg->hdr.flags.response_expected == 1);
1135 bus_configure(struct controlvm_message *inmsg,
1136 struct parser_context *parser_ctx)
1138 struct controlvm_message_packet *cmd = &inmsg->cmd;
1140 struct visorchipset_bus_info *bus_info;
1141 int rc = CONTROLVM_RESP_SUCCESS;
1144 bus_no = cmd->configure_bus.bus_no;
1145 POSTCODE_LINUX_3(BUS_CONFIGURE_ENTRY_PC, bus_no,
1146 POSTCODE_SEVERITY_INFO);
1148 bus_info = bus_find(&bus_info_list, bus_no);
1150 POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, bus_no,
1151 POSTCODE_SEVERITY_ERR);
1152 rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
1153 } else if (bus_info->state.created == 0) {
1154 POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, bus_no,
1155 POSTCODE_SEVERITY_ERR);
1156 rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
1157 } else if (bus_info->pending_msg_hdr.id != CONTROLVM_INVALID) {
1158 POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, bus_no,
1159 POSTCODE_SEVERITY_ERR);
1160 rc = -CONTROLVM_RESP_ERROR_MESSAGE_ID_INVALID_FOR_CLIENT;
1162 bus_info->partition_handle = cmd->configure_bus.guest_handle;
1163 bus_info->partition_uuid = parser_id_get(parser_ctx);
1164 parser_param_start(parser_ctx, PARSERSTRING_NAME);
1165 bus_info->name = parser_string_get(parser_ctx);
1167 visorchannel_uuid_id(&bus_info->partition_uuid, s);
1168 POSTCODE_LINUX_3(BUS_CONFIGURE_EXIT_PC, bus_no,
1169 POSTCODE_SEVERITY_INFO);
1171 bus_epilog(bus_no, CONTROLVM_BUS_CONFIGURE, &inmsg->hdr,
1172 rc, inmsg->hdr.flags.response_expected == 1);
1176 my_device_create(struct controlvm_message *inmsg)
1178 struct controlvm_message_packet *cmd = &inmsg->cmd;
1179 u32 bus_no = cmd->create_device.bus_no;
1180 u32 dev_no = cmd->create_device.dev_no;
1181 struct visorchipset_device_info *dev_info;
1182 struct visorchipset_bus_info *bus_info;
1183 int rc = CONTROLVM_RESP_SUCCESS;
1185 dev_info = device_find(&dev_info_list, bus_no, dev_no);
1186 if (dev_info && (dev_info->state.created == 1)) {
1187 POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
1188 POSTCODE_SEVERITY_ERR);
1189 rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
1192 bus_info = bus_find(&bus_info_list, bus_no);
1194 POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
1195 POSTCODE_SEVERITY_ERR);
1196 rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
1199 if (bus_info->state.created == 0) {
1200 POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
1201 POSTCODE_SEVERITY_ERR);
1202 rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
1205 dev_info = kzalloc(sizeof(*dev_info), GFP_KERNEL);
1207 POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
1208 POSTCODE_SEVERITY_ERR);
1209 rc = -CONTROLVM_RESP_ERROR_KMALLOC_FAILED;
1213 INIT_LIST_HEAD(&dev_info->entry);
1214 dev_info->bus_no = bus_no;
1215 dev_info->dev_no = dev_no;
1216 dev_info->dev_inst_uuid = cmd->create_device.dev_inst_uuid;
1217 POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, dev_no, bus_no,
1218 POSTCODE_SEVERITY_INFO);
1220 if (inmsg->hdr.flags.test_message == 1)
1221 dev_info->chan_info.addr_type = ADDRTYPE_LOCALTEST;
1223 dev_info->chan_info.addr_type = ADDRTYPE_LOCALPHYSICAL;
1224 dev_info->chan_info.channel_addr = cmd->create_device.channel_addr;
1225 dev_info->chan_info.n_channel_bytes = cmd->create_device.channel_bytes;
1226 dev_info->chan_info.channel_type_uuid =
1227 cmd->create_device.data_type_uuid;
1228 dev_info->chan_info.intr = cmd->create_device.intr;
1229 list_add(&dev_info->entry, &dev_info_list);
1230 POSTCODE_LINUX_4(DEVICE_CREATE_EXIT_PC, dev_no, bus_no,
1231 POSTCODE_SEVERITY_INFO);
1233 /* get the bus and devNo for DiagPool channel */
1235 is_diagpool_channel(dev_info->chan_info.channel_type_uuid)) {
1236 g_diagpool_bus_no = bus_no;
1237 g_diagpool_dev_no = dev_no;
1239 device_epilog(bus_no, dev_no, segment_state_running,
1240 CONTROLVM_DEVICE_CREATE, &inmsg->hdr, rc,
1241 inmsg->hdr.flags.response_expected == 1,
1242 FOR_VISORBUS(dev_info->chan_info.channel_type_uuid));
1246 my_device_changestate(struct controlvm_message *inmsg)
1248 struct controlvm_message_packet *cmd = &inmsg->cmd;
1249 u32 bus_no = cmd->device_change_state.bus_no;
1250 u32 dev_no = cmd->device_change_state.dev_no;
1251 struct spar_segment_state state = cmd->device_change_state.state;
1252 struct visorchipset_device_info *dev_info;
1253 int rc = CONTROLVM_RESP_SUCCESS;
1255 dev_info = device_find(&dev_info_list, bus_no, dev_no);
1257 POSTCODE_LINUX_4(DEVICE_CHANGESTATE_FAILURE_PC, dev_no, bus_no,
1258 POSTCODE_SEVERITY_ERR);
1259 rc = -CONTROLVM_RESP_ERROR_DEVICE_INVALID;
1260 } else if (dev_info->state.created == 0) {
1261 POSTCODE_LINUX_4(DEVICE_CHANGESTATE_FAILURE_PC, dev_no, bus_no,
1262 POSTCODE_SEVERITY_ERR);
1263 rc = -CONTROLVM_RESP_ERROR_DEVICE_INVALID;
1265 if ((rc >= CONTROLVM_RESP_SUCCESS) && dev_info)
1266 device_epilog(bus_no, dev_no, state,
1267 CONTROLVM_DEVICE_CHANGESTATE, &inmsg->hdr, rc,
1268 inmsg->hdr.flags.response_expected == 1,
1270 dev_info->chan_info.channel_type_uuid));
1274 my_device_destroy(struct controlvm_message *inmsg)
1276 struct controlvm_message_packet *cmd = &inmsg->cmd;
1277 u32 bus_no = cmd->destroy_device.bus_no;
1278 u32 dev_no = cmd->destroy_device.dev_no;
1279 struct visorchipset_device_info *dev_info;
1280 int rc = CONTROLVM_RESP_SUCCESS;
1282 dev_info = device_find(&dev_info_list, bus_no, dev_no);
1284 rc = -CONTROLVM_RESP_ERROR_DEVICE_INVALID;
1285 else if (dev_info->state.created == 0)
1286 rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
1288 if ((rc >= CONTROLVM_RESP_SUCCESS) && dev_info)
1289 device_epilog(bus_no, dev_no, segment_state_running,
1290 CONTROLVM_DEVICE_DESTROY, &inmsg->hdr, rc,
1291 inmsg->hdr.flags.response_expected == 1,
1293 dev_info->chan_info.channel_type_uuid));
1296 /* When provided with the physical address of the controlvm channel
1297 * (phys_addr), the offset to the payload area we need to manage
1298 * (offset), and the size of this payload area (bytes), fills in the
1299 * controlvm_payload_info struct. Returns true for success or false
1303 initialize_controlvm_payload_info(HOSTADDRESS phys_addr, u64 offset, u32 bytes,
1304 struct visor_controlvm_payload_info *info)
1306 u8 __iomem *payload = NULL;
1307 int rc = CONTROLVM_RESP_SUCCESS;
1310 rc = -CONTROLVM_RESP_ERROR_PAYLOAD_INVALID;
1313 memset(info, 0, sizeof(struct visor_controlvm_payload_info));
1314 if ((offset == 0) || (bytes == 0)) {
1315 rc = -CONTROLVM_RESP_ERROR_PAYLOAD_INVALID;
1318 payload = ioremap_cache(phys_addr + offset, bytes);
1320 rc = -CONTROLVM_RESP_ERROR_IOREMAP_FAILED;
1324 info->offset = offset;
1325 info->bytes = bytes;
1326 info->ptr = payload;
1339 destroy_controlvm_payload_info(struct visor_controlvm_payload_info *info)
1345 memset(info, 0, sizeof(struct visor_controlvm_payload_info));
1349 initialize_controlvm_payload(void)
1351 HOSTADDRESS phys_addr = visorchannel_get_physaddr(controlvm_channel);
1352 u64 payload_offset = 0;
1353 u32 payload_bytes = 0;
1355 if (visorchannel_read(controlvm_channel,
1356 offsetof(struct spar_controlvm_channel_protocol,
1357 request_payload_offset),
1358 &payload_offset, sizeof(payload_offset)) < 0) {
1359 POSTCODE_LINUX_2(CONTROLVM_INIT_FAILURE_PC,
1360 POSTCODE_SEVERITY_ERR);
1363 if (visorchannel_read(controlvm_channel,
1364 offsetof(struct spar_controlvm_channel_protocol,
1365 request_payload_bytes),
1366 &payload_bytes, sizeof(payload_bytes)) < 0) {
1367 POSTCODE_LINUX_2(CONTROLVM_INIT_FAILURE_PC,
1368 POSTCODE_SEVERITY_ERR);
1371 initialize_controlvm_payload_info(phys_addr,
1372 payload_offset, payload_bytes,
1373 &controlvm_payload_info);
1376 /* Send ACTION=online for DEVPATH=/sys/devices/platform/visorchipset.
1377 * Returns CONTROLVM_RESP_xxx code.
1380 visorchipset_chipset_ready(void)
1382 kobject_uevent(&visorchipset_platform_device.dev.kobj, KOBJ_ONLINE);
1383 return CONTROLVM_RESP_SUCCESS;
1385 EXPORT_SYMBOL_GPL(visorchipset_chipset_ready);
1388 visorchipset_chipset_selftest(void)
1390 char env_selftest[20];
1391 char *envp[] = { env_selftest, NULL };
1393 sprintf(env_selftest, "SPARSP_SELFTEST=%d", 1);
1394 kobject_uevent_env(&visorchipset_platform_device.dev.kobj, KOBJ_CHANGE,
1396 return CONTROLVM_RESP_SUCCESS;
1398 EXPORT_SYMBOL_GPL(visorchipset_chipset_selftest);
1400 /* Send ACTION=offline for DEVPATH=/sys/devices/platform/visorchipset.
1401 * Returns CONTROLVM_RESP_xxx code.
1404 visorchipset_chipset_notready(void)
1406 kobject_uevent(&visorchipset_platform_device.dev.kobj, KOBJ_OFFLINE);
1407 return CONTROLVM_RESP_SUCCESS;
1409 EXPORT_SYMBOL_GPL(visorchipset_chipset_notready);
1412 chipset_ready(struct controlvm_message_header *msg_hdr)
1414 int rc = visorchipset_chipset_ready();
1416 if (rc != CONTROLVM_RESP_SUCCESS)
1418 if (msg_hdr->flags.response_expected && !visorchipset_holdchipsetready)
1419 controlvm_respond(msg_hdr, rc);
1420 if (msg_hdr->flags.response_expected && visorchipset_holdchipsetready) {
1421 /* Send CHIPSET_READY response when all modules have been loaded
1422 * and disks mounted for the partition
1424 g_chipset_msg_hdr = *msg_hdr;
1429 chipset_selftest(struct controlvm_message_header *msg_hdr)
1431 int rc = visorchipset_chipset_selftest();
1433 if (rc != CONTROLVM_RESP_SUCCESS)
1435 if (msg_hdr->flags.response_expected)
1436 controlvm_respond(msg_hdr, rc);
1440 chipset_notready(struct controlvm_message_header *msg_hdr)
1442 int rc = visorchipset_chipset_notready();
1444 if (rc != CONTROLVM_RESP_SUCCESS)
1446 if (msg_hdr->flags.response_expected)
1447 controlvm_respond(msg_hdr, rc);
1450 /* This is your "one-stop" shop for grabbing the next message from the
1451 * CONTROLVM_QUEUE_EVENT queue in the controlvm channel.
1454 read_controlvm_event(struct controlvm_message *msg)
1456 if (visorchannel_signalremove(controlvm_channel,
1457 CONTROLVM_QUEUE_EVENT, msg)) {
1459 if (msg->hdr.flags.test_message == 1)
1467 * The general parahotplug flow works as follows. The visorchipset
1468 * driver receives a DEVICE_CHANGESTATE message from Command
1469 * specifying a physical device to enable or disable. The CONTROLVM
1470 * message handler calls parahotplug_process_message, which then adds
1471 * the message to a global list and kicks off a udev event which
1472 * causes a user level script to enable or disable the specified
1473 * device. The udev script then writes to
1474 * /proc/visorchipset/parahotplug, which causes parahotplug_proc_write
1475 * to get called, at which point the appropriate CONTROLVM message is
1476 * retrieved from the list and responded to.
1479 #define PARAHOTPLUG_TIMEOUT_MS 2000
1482 * Generate unique int to match an outstanding CONTROLVM message with a
1483 * udev script /proc response
1486 parahotplug_next_id(void)
1488 static atomic_t id = ATOMIC_INIT(0);
1490 return atomic_inc_return(&id);
1494 * Returns the time (in jiffies) when a CONTROLVM message on the list
1495 * should expire -- PARAHOTPLUG_TIMEOUT_MS in the future
1497 static unsigned long
1498 parahotplug_next_expiration(void)
1500 return jiffies + msecs_to_jiffies(PARAHOTPLUG_TIMEOUT_MS);
1504 * Create a parahotplug_request, which is basically a wrapper for a
1505 * CONTROLVM_MESSAGE that we can stick on a list
1507 static struct parahotplug_request *
1508 parahotplug_request_create(struct controlvm_message *msg)
1510 struct parahotplug_request *req;
1512 req = kmalloc(sizeof(*req), GFP_KERNEL | __GFP_NORETRY);
1516 req->id = parahotplug_next_id();
1517 req->expiration = parahotplug_next_expiration();
1524 * Free a parahotplug_request.
1527 parahotplug_request_destroy(struct parahotplug_request *req)
1533 * Cause uevent to run the user level script to do the disable/enable
1534 * specified in (the CONTROLVM message in) the specified
1535 * parahotplug_request
1538 parahotplug_request_kickoff(struct parahotplug_request *req)
1540 struct controlvm_message_packet *cmd = &req->msg.cmd;
1541 char env_cmd[40], env_id[40], env_state[40], env_bus[40], env_dev[40],
1544 env_cmd, env_id, env_state, env_bus, env_dev, env_func, NULL
1547 sprintf(env_cmd, "SPAR_PARAHOTPLUG=1");
1548 sprintf(env_id, "SPAR_PARAHOTPLUG_ID=%d", req->id);
1549 sprintf(env_state, "SPAR_PARAHOTPLUG_STATE=%d",
1550 cmd->device_change_state.state.active);
1551 sprintf(env_bus, "SPAR_PARAHOTPLUG_BUS=%d",
1552 cmd->device_change_state.bus_no);
1553 sprintf(env_dev, "SPAR_PARAHOTPLUG_DEVICE=%d",
1554 cmd->device_change_state.dev_no >> 3);
1555 sprintf(env_func, "SPAR_PARAHOTPLUG_FUNCTION=%d",
1556 cmd->device_change_state.dev_no & 0x7);
1558 kobject_uevent_env(&visorchipset_platform_device.dev.kobj, KOBJ_CHANGE,
1563 * Remove any request from the list that's been on there too long and
1564 * respond with an error.
1567 parahotplug_process_list(void)
1569 struct list_head *pos;
1570 struct list_head *tmp;
1572 spin_lock(¶hotplug_request_list_lock);
1574 list_for_each_safe(pos, tmp, ¶hotplug_request_list) {
1575 struct parahotplug_request *req =
1576 list_entry(pos, struct parahotplug_request, list);
1578 if (!time_after_eq(jiffies, req->expiration))
1582 if (req->msg.hdr.flags.response_expected)
1583 controlvm_respond_physdev_changestate(
1585 CONTROLVM_RESP_ERROR_DEVICE_UDEV_TIMEOUT,
1586 req->msg.cmd.device_change_state.state);
1587 parahotplug_request_destroy(req);
1590 spin_unlock(¶hotplug_request_list_lock);
1594 * Called from the /proc handler, which means the user script has
1595 * finished the enable/disable. Find the matching identifier, and
1596 * respond to the CONTROLVM message with success.
1599 parahotplug_request_complete(int id, u16 active)
1601 struct list_head *pos;
1602 struct list_head *tmp;
1604 spin_lock(¶hotplug_request_list_lock);
1606 /* Look for a request matching "id". */
1607 list_for_each_safe(pos, tmp, ¶hotplug_request_list) {
1608 struct parahotplug_request *req =
1609 list_entry(pos, struct parahotplug_request, list);
1610 if (req->id == id) {
1611 /* Found a match. Remove it from the list and
1615 spin_unlock(¶hotplug_request_list_lock);
1616 req->msg.cmd.device_change_state.state.active = active;
1617 if (req->msg.hdr.flags.response_expected)
1618 controlvm_respond_physdev_changestate(
1619 &req->msg.hdr, CONTROLVM_RESP_SUCCESS,
1620 req->msg.cmd.device_change_state.state);
1621 parahotplug_request_destroy(req);
1626 spin_unlock(¶hotplug_request_list_lock);
1631 * Enables or disables a PCI device by kicking off a udev script
1634 parahotplug_process_message(struct controlvm_message *inmsg)
1636 struct parahotplug_request *req;
1638 req = parahotplug_request_create(inmsg);
1643 if (inmsg->cmd.device_change_state.state.active) {
1644 /* For enable messages, just respond with success
1645 * right away. This is a bit of a hack, but there are
1646 * issues with the early enable messages we get (with
1647 * either the udev script not detecting that the device
1648 * is up, or not getting called at all). Fortunately
1649 * the messages that get lost don't matter anyway, as
1650 * devices are automatically enabled at
1653 parahotplug_request_kickoff(req);
1654 controlvm_respond_physdev_changestate(&inmsg->hdr,
1655 CONTROLVM_RESP_SUCCESS,
1656 inmsg->cmd.device_change_state.state);
1657 parahotplug_request_destroy(req);
1659 /* For disable messages, add the request to the
1660 * request list before kicking off the udev script. It
1661 * won't get responded to until the script has
1662 * indicated it's done.
1664 spin_lock(¶hotplug_request_list_lock);
1665 list_add_tail(&req->list, ¶hotplug_request_list);
1666 spin_unlock(¶hotplug_request_list_lock);
1668 parahotplug_request_kickoff(req);
1672 /* Process a controlvm message.
1674 * false - this function will return FALSE only in the case where the
1675 * controlvm message was NOT processed, but processing must be
1676 * retried before reading the next controlvm message; a
1677 * scenario where this can occur is when we need to throttle
1678 * the allocation of memory in which to copy out controlvm
1680 * true - processing of the controlvm message completed,
1681 * either successfully or with an error.
1684 handle_command(struct controlvm_message inmsg, HOSTADDRESS channel_addr)
1686 struct controlvm_message_packet *cmd = &inmsg.cmd;
1689 struct parser_context *parser_ctx = NULL;
1691 struct controlvm_message ackmsg;
1693 /* create parsing context if necessary */
1694 local_addr = (inmsg.hdr.flags.test_message == 1);
1695 if (channel_addr == 0)
1697 parm_addr = channel_addr + inmsg.hdr.payload_vm_offset;
1698 parm_bytes = inmsg.hdr.payload_bytes;
1700 /* Parameter and channel addresses within test messages actually lie
1701 * within our OS-controlled memory. We need to know that, because it
1702 * makes a difference in how we compute the virtual address.
1704 if (parm_addr && parm_bytes) {
1708 parser_init_byte_stream(parm_addr, parm_bytes,
1709 local_addr, &retry);
1710 if (!parser_ctx && retry)
1715 controlvm_init_response(&ackmsg, &inmsg.hdr,
1716 CONTROLVM_RESP_SUCCESS);
1717 if (controlvm_channel)
1718 visorchannel_signalinsert(controlvm_channel,
1719 CONTROLVM_QUEUE_ACK,
1722 switch (inmsg.hdr.id) {
1723 case CONTROLVM_CHIPSET_INIT:
1724 chipset_init(&inmsg);
1726 case CONTROLVM_BUS_CREATE:
1729 case CONTROLVM_BUS_DESTROY:
1730 bus_destroy(&inmsg);
1732 case CONTROLVM_BUS_CONFIGURE:
1733 bus_configure(&inmsg, parser_ctx);
1735 case CONTROLVM_DEVICE_CREATE:
1736 my_device_create(&inmsg);
1738 case CONTROLVM_DEVICE_CHANGESTATE:
1739 if (cmd->device_change_state.flags.phys_device) {
1740 parahotplug_process_message(&inmsg);
1742 /* save the hdr and cmd structures for later use */
1743 /* when sending back the response to Command */
1744 my_device_changestate(&inmsg);
1745 g_diag_msg_hdr = inmsg.hdr;
1746 g_devicechangestate_packet = inmsg.cmd;
1750 case CONTROLVM_DEVICE_DESTROY:
1751 my_device_destroy(&inmsg);
1753 case CONTROLVM_DEVICE_CONFIGURE:
1754 /* no op for now, just send a respond that we passed */
1755 if (inmsg.hdr.flags.response_expected)
1756 controlvm_respond(&inmsg.hdr, CONTROLVM_RESP_SUCCESS);
1758 case CONTROLVM_CHIPSET_READY:
1759 chipset_ready(&inmsg.hdr);
1761 case CONTROLVM_CHIPSET_SELFTEST:
1762 chipset_selftest(&inmsg.hdr);
1764 case CONTROLVM_CHIPSET_STOP:
1765 chipset_notready(&inmsg.hdr);
1768 if (inmsg.hdr.flags.response_expected)
1769 controlvm_respond(&inmsg.hdr,
1770 -CONTROLVM_RESP_ERROR_MESSAGE_ID_UNKNOWN);
1775 parser_done(parser_ctx);
1781 static HOSTADDRESS controlvm_get_channel_address(void)
1786 if (!VMCALL_SUCCESSFUL(issue_vmcall_io_controlvm_addr(&addr, &size)))
1793 controlvm_periodic_work(struct work_struct *work)
1795 struct controlvm_message inmsg;
1796 bool got_command = false;
1797 bool handle_command_failed = false;
1798 static u64 poll_count;
1800 /* make sure visorbus server is registered for controlvm callbacks */
1801 if (visorchipset_serverregwait && !serverregistered)
1803 /* make sure visorclientbus server is regsitered for controlvm
1806 if (visorchipset_clientregwait && !clientregistered)
1810 if (poll_count >= 250)
1815 /* Check events to determine if response to CHIPSET_READY
1818 if (visorchipset_holdchipsetready &&
1819 (g_chipset_msg_hdr.id != CONTROLVM_INVALID)) {
1820 if (check_chipset_events() == 1) {
1821 controlvm_respond(&g_chipset_msg_hdr, 0);
1822 clear_chipset_events();
1823 memset(&g_chipset_msg_hdr, 0,
1824 sizeof(struct controlvm_message_header));
1828 while (visorchannel_signalremove(controlvm_channel,
1829 CONTROLVM_QUEUE_RESPONSE,
1833 if (controlvm_pending_msg_valid) {
1834 /* we throttled processing of a prior
1835 * msg, so try to process it again
1836 * rather than reading a new one
1838 inmsg = controlvm_pending_msg;
1839 controlvm_pending_msg_valid = false;
1842 got_command = read_controlvm_event(&inmsg);
1846 handle_command_failed = false;
1847 while (got_command && (!handle_command_failed)) {
1848 most_recent_message_jiffies = jiffies;
1849 if (handle_command(inmsg,
1850 visorchannel_get_physaddr
1851 (controlvm_channel)))
1852 got_command = read_controlvm_event(&inmsg);
1854 /* this is a scenario where throttling
1855 * is required, but probably NOT an
1856 * error...; we stash the current
1857 * controlvm msg so we will attempt to
1858 * reprocess it on our next loop
1860 handle_command_failed = true;
1861 controlvm_pending_msg = inmsg;
1862 controlvm_pending_msg_valid = true;
1866 /* parahotplug_worker */
1867 parahotplug_process_list();
1871 if (time_after(jiffies,
1872 most_recent_message_jiffies + (HZ * MIN_IDLE_SECONDS))) {
1873 /* it's been longer than MIN_IDLE_SECONDS since we
1874 * processed our last controlvm message; slow down the
1877 if (poll_jiffies != POLLJIFFIES_CONTROLVMCHANNEL_SLOW)
1878 poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_SLOW;
1880 if (poll_jiffies != POLLJIFFIES_CONTROLVMCHANNEL_FAST)
1881 poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST;
1884 queue_delayed_work(periodic_controlvm_workqueue,
1885 &periodic_controlvm_work, poll_jiffies);
1889 setup_crash_devices_work_queue(struct work_struct *work)
1891 struct controlvm_message local_crash_bus_msg;
1892 struct controlvm_message local_crash_dev_msg;
1893 struct controlvm_message msg;
1894 u32 local_crash_msg_offset;
1895 u16 local_crash_msg_count;
1897 /* make sure visorbus server is registered for controlvm callbacks */
1898 if (visorchipset_serverregwait && !serverregistered)
1901 /* make sure visorclientbus server is regsitered for controlvm
1904 if (visorchipset_clientregwait && !clientregistered)
1907 POSTCODE_LINUX_2(CRASH_DEV_ENTRY_PC, POSTCODE_SEVERITY_INFO);
1909 /* send init chipset msg */
1910 msg.hdr.id = CONTROLVM_CHIPSET_INIT;
1911 msg.cmd.init_chipset.bus_count = 23;
1912 msg.cmd.init_chipset.switch_count = 0;
1916 /* get saved message count */
1917 if (visorchannel_read(controlvm_channel,
1918 offsetof(struct spar_controlvm_channel_protocol,
1919 saved_crash_message_count),
1920 &local_crash_msg_count, sizeof(u16)) < 0) {
1921 POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC,
1922 POSTCODE_SEVERITY_ERR);
1926 if (local_crash_msg_count != CONTROLVM_CRASHMSG_MAX) {
1927 POSTCODE_LINUX_3(CRASH_DEV_COUNT_FAILURE_PC,
1928 local_crash_msg_count,
1929 POSTCODE_SEVERITY_ERR);
1933 /* get saved crash message offset */
1934 if (visorchannel_read(controlvm_channel,
1935 offsetof(struct spar_controlvm_channel_protocol,
1936 saved_crash_message_offset),
1937 &local_crash_msg_offset, sizeof(u32)) < 0) {
1938 POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC,
1939 POSTCODE_SEVERITY_ERR);
1943 /* read create device message for storage bus offset */
1944 if (visorchannel_read(controlvm_channel,
1945 local_crash_msg_offset,
1946 &local_crash_bus_msg,
1947 sizeof(struct controlvm_message)) < 0) {
1948 POSTCODE_LINUX_2(CRASH_DEV_RD_BUS_FAIULRE_PC,
1949 POSTCODE_SEVERITY_ERR);
1953 /* read create device message for storage device */
1954 if (visorchannel_read(controlvm_channel,
1955 local_crash_msg_offset +
1956 sizeof(struct controlvm_message),
1957 &local_crash_dev_msg,
1958 sizeof(struct controlvm_message)) < 0) {
1959 POSTCODE_LINUX_2(CRASH_DEV_RD_DEV_FAIULRE_PC,
1960 POSTCODE_SEVERITY_ERR);
1964 /* reuse IOVM create bus message */
1965 if (local_crash_bus_msg.cmd.create_bus.channel_addr) {
1966 bus_create(&local_crash_bus_msg);
1968 POSTCODE_LINUX_2(CRASH_DEV_BUS_NULL_FAILURE_PC,
1969 POSTCODE_SEVERITY_ERR);
1973 /* reuse create device message for storage device */
1974 if (local_crash_dev_msg.cmd.create_device.channel_addr) {
1975 my_device_create(&local_crash_dev_msg);
1977 POSTCODE_LINUX_2(CRASH_DEV_DEV_NULL_FAILURE_PC,
1978 POSTCODE_SEVERITY_ERR);
1981 POSTCODE_LINUX_2(CRASH_DEV_EXIT_PC, POSTCODE_SEVERITY_INFO);
1986 poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_SLOW;
1988 queue_delayed_work(periodic_controlvm_workqueue,
1989 &periodic_controlvm_work, poll_jiffies);
1993 bus_create_response(u32 bus_no, int response)
1995 bus_responder(CONTROLVM_BUS_CREATE, bus_no, response);
1999 bus_destroy_response(u32 bus_no, int response)
2001 bus_responder(CONTROLVM_BUS_DESTROY, bus_no, response);
2005 device_create_response(u32 bus_no, u32 dev_no, int response)
2007 device_responder(CONTROLVM_DEVICE_CREATE, bus_no, dev_no, response);
2011 device_destroy_response(u32 bus_no, u32 dev_no, int response)
2013 device_responder(CONTROLVM_DEVICE_DESTROY, bus_no, dev_no, response);
2017 visorchipset_device_pause_response(u32 bus_no, u32 dev_no, int response)
2019 device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE,
2020 bus_no, dev_no, response,
2021 segment_state_standby);
2023 EXPORT_SYMBOL_GPL(visorchipset_device_pause_response);
2026 device_resume_response(u32 bus_no, u32 dev_no, int response)
2028 device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE,
2029 bus_no, dev_no, response,
2030 segment_state_running);
2034 visorchipset_get_bus_info(u32 bus_no, struct visorchipset_bus_info *bus_info)
2036 void *p = bus_find(&bus_info_list, bus_no);
2040 memcpy(bus_info, p, sizeof(struct visorchipset_bus_info));
2043 EXPORT_SYMBOL_GPL(visorchipset_get_bus_info);
2046 visorchipset_set_bus_context(u32 bus_no, void *context)
2048 struct visorchipset_bus_info *p = bus_find(&bus_info_list, bus_no);
2052 p->bus_driver_context = context;
2055 EXPORT_SYMBOL_GPL(visorchipset_set_bus_context);
2058 visorchipset_get_device_info(u32 bus_no, u32 dev_no,
2059 struct visorchipset_device_info *dev_info)
2061 void *p = device_find(&dev_info_list, bus_no, dev_no);
2065 memcpy(dev_info, p, sizeof(struct visorchipset_device_info));
2068 EXPORT_SYMBOL_GPL(visorchipset_get_device_info);
2071 visorchipset_set_device_context(u32 bus_no, u32 dev_no, void *context)
2073 struct visorchipset_device_info *p;
2075 p = device_find(&dev_info_list, bus_no, dev_no);
2079 p->bus_driver_context = context;
2082 EXPORT_SYMBOL_GPL(visorchipset_set_device_context);
2084 /* Generic wrapper function for allocating memory from a kmem_cache pool.
2087 visorchipset_cache_alloc(struct kmem_cache *pool, bool ok_to_block,
2097 /* __GFP_NORETRY means "ok to fail", meaning
2098 * kmem_cache_alloc() can return NULL, implying the caller CAN
2099 * cope with failure. If you do NOT specify __GFP_NORETRY,
2100 * Linux will go to extreme measures to get memory for you
2101 * (like, invoke oom killer), which will probably cripple the
2104 gfp |= __GFP_NORETRY;
2105 p = kmem_cache_alloc(pool, gfp);
2112 /* Generic wrapper function for freeing memory from a kmem_cache pool.
2115 visorchipset_cache_free(struct kmem_cache *pool, void *p, char *fn, int ln)
2120 kmem_cache_free(pool, p);
2123 static ssize_t chipsetready_store(struct device *dev,
2124 struct device_attribute *attr,
2125 const char *buf, size_t count)
2129 if (sscanf(buf, "%63s", msgtype) != 1)
2132 if (!strcmp(msgtype, "CALLHOMEDISK_MOUNTED")) {
2133 chipset_events[0] = 1;
2135 } else if (!strcmp(msgtype, "MODULES_LOADED")) {
2136 chipset_events[1] = 1;
2142 /* The parahotplug/devicedisabled interface gets called by our support script
2143 * when an SR-IOV device has been shut down. The ID is passed to the script
2144 * and then passed back when the device has been removed.
2146 static ssize_t devicedisabled_store(struct device *dev,
2147 struct device_attribute *attr,
2148 const char *buf, size_t count)
2152 if (kstrtouint(buf, 10, &id))
2155 parahotplug_request_complete(id, 0);
2159 /* The parahotplug/deviceenabled interface gets called by our support script
2160 * when an SR-IOV device has been recovered. The ID is passed to the script
2161 * and then passed back when the device has been brought back up.
2163 static ssize_t deviceenabled_store(struct device *dev,
2164 struct device_attribute *attr,
2165 const char *buf, size_t count)
2169 if (kstrtouint(buf, 10, &id))
2172 parahotplug_request_complete(id, 1);
2177 visorchipset_init(void)
2182 if (!unisys_spar_platform)
2185 memset(&busdev_server_notifiers, 0, sizeof(busdev_server_notifiers));
2186 memset(&busdev_client_notifiers, 0, sizeof(busdev_client_notifiers));
2187 memset(&controlvm_payload_info, 0, sizeof(controlvm_payload_info));
2188 memset(&livedump_info, 0, sizeof(livedump_info));
2189 atomic_set(&livedump_info.buffers_in_use, 0);
2191 if (visorchipset_testvnic) {
2192 POSTCODE_LINUX_3(CHIPSET_INIT_FAILURE_PC, x, DIAG_SEVERITY_ERR);
2197 addr = controlvm_get_channel_address();
2200 visorchannel_create_with_lock
2202 sizeof(struct spar_controlvm_channel_protocol),
2203 spar_controlvm_channel_protocol_uuid);
2204 if (SPAR_CONTROLVM_CHANNEL_OK_CLIENT(
2205 visorchannel_get_header(controlvm_channel))) {
2206 initialize_controlvm_payload();
2208 visorchannel_destroy(controlvm_channel);
2209 controlvm_channel = NULL;
2216 major_dev = MKDEV(visorchipset_major, 0);
2217 rc = visorchipset_file_init(major_dev, &controlvm_channel);
2219 POSTCODE_LINUX_2(CHIPSET_INIT_FAILURE_PC, DIAG_SEVERITY_ERR);
2223 memset(&g_diag_msg_hdr, 0, sizeof(struct controlvm_message_header));
2225 memset(&g_chipset_msg_hdr, 0, sizeof(struct controlvm_message_header));
2227 memset(&g_del_dump_msg_hdr, 0, sizeof(struct controlvm_message_header));
2229 if (!visorchipset_disable_controlvm) {
2230 /* if booting in a crash kernel */
2231 if (is_kdump_kernel())
2232 INIT_DELAYED_WORK(&periodic_controlvm_work,
2233 setup_crash_devices_work_queue);
2235 INIT_DELAYED_WORK(&periodic_controlvm_work,
2236 controlvm_periodic_work);
2237 periodic_controlvm_workqueue =
2238 create_singlethread_workqueue("visorchipset_controlvm");
2240 if (!periodic_controlvm_workqueue) {
2241 POSTCODE_LINUX_2(CREATE_WORKQUEUE_FAILED_PC,
2246 most_recent_message_jiffies = jiffies;
2247 poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST;
2248 rc = queue_delayed_work(periodic_controlvm_workqueue,
2249 &periodic_controlvm_work, poll_jiffies);
2251 POSTCODE_LINUX_2(QUEUE_DELAYED_WORK_PC,
2257 visorchipset_platform_device.dev.devt = major_dev;
2258 if (platform_device_register(&visorchipset_platform_device) < 0) {
2259 POSTCODE_LINUX_2(DEVICE_REGISTER_FAILURE_PC, DIAG_SEVERITY_ERR);
2263 POSTCODE_LINUX_2(CHIPSET_INIT_SUCCESS_PC, POSTCODE_SEVERITY_INFO);
2267 POSTCODE_LINUX_3(CHIPSET_INIT_FAILURE_PC, rc,
2268 POSTCODE_SEVERITY_ERR);
2274 visorchipset_exit(void)
2276 POSTCODE_LINUX_2(DRIVER_EXIT_PC, POSTCODE_SEVERITY_INFO);
2278 if (visorchipset_disable_controlvm) {
2281 cancel_delayed_work(&periodic_controlvm_work);
2282 flush_workqueue(periodic_controlvm_workqueue);
2283 destroy_workqueue(periodic_controlvm_workqueue);
2284 periodic_controlvm_workqueue = NULL;
2285 destroy_controlvm_payload_info(&controlvm_payload_info);
2288 cleanup_controlvm_structures();
2290 memset(&g_diag_msg_hdr, 0, sizeof(struct controlvm_message_header));
2292 memset(&g_chipset_msg_hdr, 0, sizeof(struct controlvm_message_header));
2294 memset(&g_del_dump_msg_hdr, 0, sizeof(struct controlvm_message_header));
2296 visorchannel_destroy(controlvm_channel);
2298 visorchipset_file_cleanup(visorchipset_platform_device.dev.devt);
2299 POSTCODE_LINUX_2(DRIVER_EXIT_PC, POSTCODE_SEVERITY_INFO);
2302 module_param_named(testvnic, visorchipset_testvnic, int, S_IRUGO);
2303 MODULE_PARM_DESC(visorchipset_testvnic, "1 to test vnic, using dummy VNIC connected via a loopback to a physical ethernet");
2304 module_param_named(testvnicclient, visorchipset_testvnicclient, int, S_IRUGO);
2305 MODULE_PARM_DESC(visorchipset_testvnicclient, "1 to test vnic, using real VNIC channel attached to a separate IOVM guest");
2306 module_param_named(testmsg, visorchipset_testmsg, int, S_IRUGO);
2307 MODULE_PARM_DESC(visorchipset_testmsg,
2308 "1 to manufacture the chipset, bus, and switch messages");
2309 module_param_named(major, visorchipset_major, int, S_IRUGO);
2310 MODULE_PARM_DESC(visorchipset_major,
2311 "major device number to use for the device node");
2312 module_param_named(serverregwait, visorchipset_serverregwait, int, S_IRUGO);
2313 MODULE_PARM_DESC(visorchipset_serverreqwait,
2314 "1 to have the module wait for the visor bus to register");
2315 module_param_named(clientregwait, visorchipset_clientregwait, int, S_IRUGO);
2316 MODULE_PARM_DESC(visorchipset_clientregwait, "1 to have the module wait for the visorclientbus to register");
2317 module_param_named(testteardown, visorchipset_testteardown, int, S_IRUGO);
2318 MODULE_PARM_DESC(visorchipset_testteardown,
2319 "1 to test teardown of the chipset, bus, and switch");
2320 module_param_named(disable_controlvm, visorchipset_disable_controlvm, int,
2322 MODULE_PARM_DESC(visorchipset_disable_controlvm,
2323 "1 to disable polling of controlVm channel");
2324 module_param_named(holdchipsetready, visorchipset_holdchipsetready,
2326 MODULE_PARM_DESC(visorchipset_holdchipsetready,
2327 "1 to hold response to CHIPSET_READY");
2329 module_init(visorchipset_init);
2330 module_exit(visorchipset_exit);
2332 MODULE_AUTHOR("Unisys");
2333 MODULE_LICENSE("GPL");
2334 MODULE_DESCRIPTION("Supervisor chipset driver for service partition: ver "
2336 MODULE_VERSION(VERSION);