diff options
Diffstat (limited to 'drivers/staging/unisys/uislib/uislib.c')
-rw-r--r-- | drivers/staging/unisys/uislib/uislib.c | 935 |
1 files changed, 75 insertions, 860 deletions
diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c index 3152a2180c45..d4a7ef821bae 100644 --- a/drivers/staging/unisys/uislib/uislib.c +++ b/drivers/staging/unisys/uislib/uislib.c @@ -1,6 +1,6 @@ /* uislib.c * - * Copyright � 2010 - 2013 UNISYS CORPORATION + * Copyright (C) 2010 - 2013 UNISYS CORPORATION * All rights reserved. * * This program is free software; you can redistribute it and/or modify @@ -23,6 +23,7 @@ #include <config/modversions.h> #endif #include <linux/module.h> +#include <linux/debugfs.h> #include "commontypes.h" @@ -45,7 +46,6 @@ #define SET_PROC_OWNER(x, y) -#define UISLIB_TEST_PROC #define POLLJIFFIES_NORMAL 1 /* Choose whether or not you want to wakeup the request-polling thread * after an IO termination: @@ -89,146 +89,34 @@ static DEFINE_SEMAPHORE(Lock_Polling_Device_Channels); /* unlocked */ static DECLARE_WAIT_QUEUE_HEAD(Wakeup_Polling_Device_Channels); static int Go_Polling_Device_Channels; -static struct proc_dir_entry *uislib_proc_dir; -static struct proc_dir_entry *uislib_proc_vbus_dir; -static struct proc_dir_entry *vnic_proc_entry; /* Used to be "datachan" */ -static struct proc_dir_entry *ctrlchan_proc_entry; -static struct proc_dir_entry *pmem_proc_entry; -static struct proc_dir_entry *info_proc_entry; -static struct proc_dir_entry *switch_proc_entry; -static struct proc_dir_entry *extport_proc_entry; -static struct proc_dir_entry *platformnumber_proc_entry; -static struct proc_dir_entry *bus_proc_entry; -static struct proc_dir_entry *dev_proc_entry; -static struct proc_dir_entry *chipset_proc_entry; -static struct proc_dir_entry *cycles_before_wait_proc_entry; -static struct proc_dir_entry *reset_counts_proc_entry; -static struct proc_dir_entry *smart_wakeup_proc_entry; -static struct proc_dir_entry *disable_proc_entry; - -#define DIR_PROC_ENTRY "uislib" -#define DIR_VBUS_PROC_ENTRY "vbus" -#define VNIC_PROC_ENTRY_FN "vnic" /* Used to be "datachan" */ -#define CTRLCHAN_PROC_ENTRY_FN "ctrlchan" -#define PMEM_PROC_ENTRY_FN "phys_to_virt" -#define INFO_PROC_ENTRY_FN "info" -#define SWITCH_PROC_ENTRY_FN "switch" -#define SWITCH_COUNT_PROC_ENTRY_FN "switch_count" -#define EXTPORT_PROC_ENTRY_FN "extport" -#define PLATFORMNUMBER_PROC_ENTRY_FN "platform" -#define BUS_PROC_ENTRY_FN "bus" -#define DEV_PROC_ENTRY_FN "device" -#define CHIPSET_PROC_ENTRY_FN "chipset" -#define CYCLES_BEFORE_WAIT_PROC_ENTRY_FN "cycles_before_wait" -#define RESET_COUNTS_PROC_ENTRY_FN "reset_counts" -#define SMART_WAKEUP_PROC_ENTRY_FN "smart_wakeup" #define CALLHOME_PROC_ENTRY_FN "callhome" #define CALLHOME_THROTTLED_PROC_ENTRY_FN "callhome_throttled" -#define DISABLE_PROC_ENTRY_FN "switch_state" -#ifdef UISLIB_TEST_PROC -static struct proc_dir_entry *test_proc_entry; -#define TEST_PROC_ENTRY_FN "test" -#endif -static unsigned long long cycles_before_wait, wait_cycles; -/*****************************************************/ -/* local functions */ -/*****************************************************/ +#define DIR_DEBUGFS_ENTRY "uislib" +static struct dentry *dir_debugfs; -static int proc_info_vbus_show(struct seq_file *m, void *v); -static int -proc_info_vbus_open(struct inode *inode, struct file *filp) -{ - /* proc_info_vbus_show will grab this from seq_file.private: */ - struct bus_info *bus = PDE_DATA(inode); - return single_open(filp, proc_info_vbus_show, bus); -} +#define PLATFORMNUMBER_DEBUGFS_ENTRY_FN "platform" +static struct dentry *platformnumber_debugfs_read; -static const struct file_operations proc_info_vbus_fops = { - .open = proc_info_vbus_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static ssize_t uislib_proc_read_writeonly(struct file *file, - char __user *buffer, - size_t count, loff_t *ppos); +#define CYCLES_BEFORE_WAIT_DEBUGFS_ENTRY_FN "cycles_before_wait" +static struct dentry *cycles_before_wait_debugfs_read; -static ssize_t vnic_proc_write(struct file *file, const char __user *buffer, - size_t count, loff_t *ppos); +#define SMART_WAKEUP_DEBUGFS_ENTRY_FN "smart_wakeup" +static struct dentry *smart_wakeup_debugfs_entry; -static const struct file_operations proc_vnic_fops = { - .read = uislib_proc_read_writeonly, - .write = vnic_proc_write, -}; +#define INFO_DEBUGFS_ENTRY_FN "info" +static struct dentry *info_debugfs_entry; -static ssize_t chipset_proc_write(struct file *file, const char __user *buffer, - size_t count, loff_t *ppos); +static unsigned long long cycles_before_wait, wait_cycles; -static const struct file_operations proc_chipset_fops = { - .read = uislib_proc_read_writeonly, - .write = chipset_proc_write, -}; +/*****************************************************/ +/* local functions */ +/*****************************************************/ -static ssize_t info_proc_read(struct file *file, char __user *buf, +static ssize_t info_debugfs_read(struct file *file, char __user *buf, size_t len, loff_t *offset); -static const struct file_operations proc_info_fops = { - .read = info_proc_read, -}; - -static ssize_t platformnumber_proc_read(struct file *file, char __user *buf, - size_t len, loff_t *offset); -static const struct file_operations proc_platformnumber_fops = { - .read = platformnumber_proc_read, -}; - -static ssize_t cycles_before_wait_proc_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *ppos); -static const struct file_operations proc_cycles_before_wait_fops = { - .read = uislib_proc_read_writeonly, - .write = cycles_before_wait_proc_write, -}; - -static ssize_t reset_counts_proc_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *ppos); -static const struct file_operations proc_reset_counts_fops = { - .read = uislib_proc_read_writeonly, - .write = reset_counts_proc_write, -}; - -static ssize_t smart_wakeup_proc_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *ppos); -static const struct file_operations proc_smart_wakeup_fops = { - .read = uislib_proc_read_writeonly, - .write = smart_wakeup_proc_write, -}; - -static ssize_t test_proc_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *ppos); -static const struct file_operations proc_test_fops = { - .read = uislib_proc_read_writeonly, - .write = test_proc_write, -}; - -static ssize_t bus_proc_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *ppos); -static const struct file_operations proc_bus_fops = { - .read = uislib_proc_read_writeonly, - .write = bus_proc_write, -}; - -static ssize_t dev_proc_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *ppos); -static const struct file_operations proc_dev_fops = { - .read = uislib_proc_read_writeonly, - .write = dev_proc_write, +static const struct file_operations debugfs_info_fops = { + .read = info_debugfs_read, }; static void @@ -240,31 +128,10 @@ init_msg_header(CONTROLVM_MESSAGE *msg, U32 id, uint rsp, uint svr) msg->hdr.Flags.server = svr; } -static void -create_bus_proc_entries(struct bus_info *bus) -{ - bus->proc_dir = proc_mkdir(bus->name, uislib_proc_vbus_dir); - if (!bus->proc_dir) { - LOGERR("failed to create /proc/uislib/vbus/%s directory", - bus->name); - return; - } - bus->proc_info = proc_create_data("info", 0, bus->proc_dir, - &proc_info_vbus_fops, bus); - if (!bus->proc_info) { - LOGERR("failed to create /proc/uislib/vbus/%s/info", bus->name); - remove_proc_entry(bus->name, uislib_proc_vbus_dir); - bus->proc_dir = NULL; - return; - } - SET_PROC_OWNER(bus->proc_info, THIS_MODULE); - -} - static __iomem void * init_vbus_channel(U64 channelAddr, U32 channelBytes, int isServer) { - void *rc = NULL; + void __iomem *rc = NULL; void __iomem *pChan = uislib_ioremap_cache(channelAddr, channelBytes); if (!pChan) { LOGERR("CONTROLVM_BUS_CREATE error: ioremap_cache of channelAddr:%Lx for channelBytes:%llu failed", @@ -396,7 +263,6 @@ create_bus(CONTROLVM_MESSAGE *msg, char *buf) CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR; } } - create_bus_proc_entries(bus); /* add bus at the head of our list */ write_lock(&BusListLock); @@ -473,14 +339,6 @@ destroy_bus(CONTROLVM_MESSAGE *msg, char *buf) read_unlock(&BusListLock); return CONTROLVM_RESP_ERROR_ALREADY_DONE; } - if (bus->proc_info) { - remove_proc_entry("info", bus->proc_dir); - bus->proc_info = NULL; - } - if (bus->proc_dir) { - remove_proc_entry(bus->name, uislib_proc_vbus_dir); - bus->proc_dir = NULL; - } if (bus->pBusChannel) { uislib_iounmap(bus->pBusChannel); bus->pBusChannel = NULL; @@ -587,11 +445,9 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf) */ if (!msg->hdr.Flags.server) { struct guest_msgs cmd; - if (!memcmp - (&dev->channelTypeGuid, - &UltraVhbaChannelProtocolGuid, - sizeof(GUID))) { - WAIT_FOR_VALID_GUID(((CHANNEL_HEADER + if (!uuid_le_cmp(dev->channelTypeGuid, + UltraVhbaChannelProtocolGuid)) { + wait_for_valid_guid(&((CHANNEL_HEADER __iomem *) (dev-> chanptr))-> Type); @@ -614,11 +470,9 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf) dev->devInstGuid; cmd.add_vhba.intr = dev->intr; } else - if (!memcmp - (&dev->channelTypeGuid, - &UltraVnicChannelProtocolGuid, - sizeof(GUID))) { - WAIT_FOR_VALID_GUID(((CHANNEL_HEADER + if (!uuid_le_cmp(dev->channelTypeGuid, + UltraVnicChannelProtocolGuid)) { + wait_for_valid_guid(&((CHANNEL_HEADER __iomem *) (dev-> chanptr))-> Type); @@ -723,16 +577,13 @@ pause_device(CONTROLVM_MESSAGE *msg) /* the msg is bound for virtpci; send * guest_msgs struct to callback */ - if (!memcmp - (&dev->channelTypeGuid, - &UltraVhbaChannelProtocolGuid, sizeof(GUID))) { + if (!uuid_le_cmp(dev->channelTypeGuid, + UltraVhbaChannelProtocolGuid)) { cmd.msgtype = GUEST_PAUSE_VHBA; cmd.pause_vhba.chanptr = dev->chanptr; } else - if (!memcmp - (&dev->channelTypeGuid, - &UltraVnicChannelProtocolGuid, - sizeof(GUID))) { + if (!uuid_le_cmp(dev->channelTypeGuid, + UltraVnicChannelProtocolGuid)) { cmd.msgtype = GUEST_PAUSE_VNIC; cmd.pause_vnic.chanptr = dev->chanptr; } else { @@ -798,15 +649,13 @@ resume_device(CONTROLVM_MESSAGE *msg) /* the msg is bound for virtpci; send * guest_msgs struct to callback */ - if (!memcmp(&dev->channelTypeGuid, - &UltraVhbaChannelProtocolGuid, - sizeof(GUID))) { + if (!uuid_le_cmp(dev->channelTypeGuid, + UltraVhbaChannelProtocolGuid)) { cmd.msgtype = GUEST_RESUME_VHBA; cmd.resume_vhba.chanptr = dev->chanptr; } else - if (!memcmp(&dev->channelTypeGuid, - &UltraVnicChannelProtocolGuid, - sizeof(GUID))) { + if (!uuid_le_cmp(dev->channelTypeGuid, + UltraVnicChannelProtocolGuid)) { cmd.msgtype = GUEST_RESUME_VNIC; cmd.resume_vnic.chanptr = dev->chanptr; } else { @@ -873,16 +722,13 @@ destroy_device(CONTROLVM_MESSAGE *msg, char *buf) /* the msg is bound for virtpci; send * guest_msgs struct to callback */ - if (!memcmp - (&dev->channelTypeGuid, - &UltraVhbaChannelProtocolGuid, sizeof(GUID))) { + if (!uuid_le_cmp(dev->channelTypeGuid, + UltraVhbaChannelProtocolGuid)) { cmd.msgtype = GUEST_DEL_VHBA; cmd.del_vhba.chanptr = dev->chanptr; } else - if (!memcmp - (&dev->channelTypeGuid, - &UltraVnicChannelProtocolGuid, - sizeof(GUID))) { + if (!uuid_le_cmp(dev->channelTypeGuid, + UltraVnicChannelProtocolGuid)) { cmd.msgtype = GUEST_DEL_VNIC; cmd.del_vnic.chanptr = dev->chanptr; } else { @@ -957,27 +803,6 @@ init_chipset(CONTROLVM_MESSAGE *msg, char *buf) } static int -stop_chipset(CONTROLVM_MESSAGE *msg, char *buf) -{ - /* Check that all buses and switches have been torn down and - * destroyed. - */ - if (BusListHead) { - /* Buses still exist. */ - LOGERR("CONTROLVM_CHIPSET_STOP: BusListHead is not NULL"); - return CONTROLVM_RESP_ERROR_CHIPSET_STOP_FAILED_BUS; - } - if (BusListCount) { - /* BusListHead is NULL, but BusListCount != 0 */ - LOGERR("CONTROLVM_CHIPSET_STOP: BusListCount != 0"); - return CONTROLVM_RESP_ERROR_CHIPSET_STOP_FAILED_BUS; - } - - /* Buses are shut down. */ - return visorchipset_chipset_notready(); -} - -static int delete_bus_glue(U32 busNo) { CONTROLVM_MESSAGE msg; @@ -1008,7 +833,7 @@ delete_device_glue(U32 busNo, U32 devNo) } int -uislib_client_inject_add_bus(U32 busNo, GUID instGuid, +uislib_client_inject_add_bus(U32 busNo, uuid_le instGuid, U64 channelAddr, ulong nChannelBytes) { CONTROLVM_MESSAGE msg; @@ -1109,7 +934,7 @@ EXPORT_SYMBOL_GPL(uislib_client_inject_resume_vhba); int uislib_client_inject_add_vhba(U32 busNo, U32 devNo, U64 phys_chan_addr, U32 chan_bytes, - int is_test_addr, GUID instGuid, + int is_test_addr, uuid_le instGuid, struct InterruptInfo *intr) { CONTROLVM_MESSAGE msg; @@ -1168,7 +993,7 @@ EXPORT_SYMBOL_GPL(uislib_client_inject_del_vhba); int uislib_client_inject_add_vnic(U32 busNo, U32 devNo, U64 phys_chan_addr, U32 chan_bytes, - int is_test_addr, GUID instGuid, + int is_test_addr, uuid_le instGuid, struct InterruptInfo *intr) { CONTROLVM_MESSAGE msg; @@ -1272,7 +1097,6 @@ uislib_client_add_vnic(U32 busNo) BOOL busCreated = FALSE; int devNo = 0; /* Default to 0, since only one device * will be created for this bus... */ - GUID dummyGuid = GUID0; CONTROLVM_MESSAGE msg; init_msg_header(&msg, CONTROLVM_BUS_CREATE, 0, 0); @@ -1291,7 +1115,7 @@ uislib_client_add_vnic(U32 busNo) msg.hdr.Flags.testMessage = 1; msg.cmd.createDevice.busNo = busNo; msg.cmd.createDevice.devNo = devNo; - msg.cmd.createDevice.devInstGuid = dummyGuid; + msg.cmd.createDevice.devInstGuid = NULL_UUID_LE; memset(&msg.cmd.createDevice.intr, 0, sizeof(struct InterruptInfo)); msg.cmd.createDevice.channelAddr = PhysicalDataChan; msg.cmd.createDevice.channelBytes = MIN_IO_CHANNEL_SIZE; @@ -1376,135 +1200,11 @@ EXPORT_SYMBOL_GPL(uislib_cache_free); /* proc filesystem callback functions */ /*****************************************************/ -static ssize_t -vnic_proc_write(struct file *file, const char __user *buffer, - size_t count, loff_t *ppos) -{ - int action = 0xffff, busNo = 0, i, result = 0; - char buf[4]; - char direction; -/* GUID guid; */ - if (count >= ARRAY_SIZE(buf)) - return -EINVAL; - - if (copy_from_user(buf, buffer, count)) { - LOGERR("echo > /proc/uislib/vnic copy_from_user ****FAILED.\n"); - return -EFAULT; - } - - i = sscanf(buf, "%d%c", &action, &direction); - if (i != 2) { - LOGERR("unable to parse vnic proc parameters.\n"); - return -EFAULT; - } - - if ((direction != '-') && (direction != '+')) { - LOGERR("unable to determine whether to add or delete vnic\n"); - return -EFAULT; - } - - /* if (i < 1), i.e., if we didn't even read the action field, - * then action will default to 0xffff and the code below will - * fall through the switch and print usage. - */ - switch (action) { - case 0: - /* call client method... */ - busNo = 0; /* All client drivers use bus value of 0... */ - if (direction == '+') - result = uislib_client_add_vnic(busNo); - else - result = uislib_client_delete_vnic(busNo); - if (!result) { - LOGERR("echo 0%c > /proc/uislib/vnic failed (client end)", - direction); - return -EFAULT; - } - return count; - - default: - break; - } - - LOGERR("USAGE: echo <action><direction (up/down)> > /proc/uislib/vnic"); - LOGERR(" "); - LOGERR("Client Syntax"); - LOGERR("-------------"); - LOGERR("0+ ==> add vnic"); - LOGERR("0- ==> delete vnic"); - LOGERR(" "); - return count; -} /* end vnic_proc_write */ - -static ssize_t -chipset_proc_write(struct file *file, const char __user *buffer, - size_t count, loff_t *ppos) -{ - int i, action = 0xffff; - char buf[4]; - CONTROLVM_MESSAGE msg; - - if (count >= ARRAY_SIZE(buf)) - return -EINVAL; - - memset(&msg, 0, sizeof(CONTROLVM_MESSAGE)); - - if (copy_from_user(buf, buffer, count)) { - LOGERR("copy_from_user ****FAILED.\n"); - return -EFAULT; - } - - if (chipset_inited) { - LOGINF("Chipset already initialized\n"); - return -EFAULT; - } - i = sscanf(buf, "%x", &action); - - /* if (i < 1), i.e., if we didn't even read the action field, - * then action will default to 0xffff and the code below will - * fall through the switch and print usage. - */ - switch (action) { - case 1: - /* GUEST */ - /* step: initialize the chipset */ - init_msg_header(&msg, CONTROLVM_CHIPSET_INIT, 0, 0); - msg.hdr.Flags.testMessage = 0; - msg.cmd.initChipset.busCount = 23; - msg.cmd.initChipset.switchCount = 23; - - if (init_chipset(&msg, NULL) != CONTROLVM_RESP_SUCCESS) { - LOGERR("init_chipset failed.\n"); - return 0; - } - return 1; - case 2: - /* BOTH */ - init_msg_header(&msg, CONTROLVM_CHIPSET_INIT, 0, 0); - msg.hdr.Flags.testMessage = 1; - msg.cmd.initChipset.busCount = 23; - msg.cmd.initChipset.switchCount = 23; - - if (init_chipset(&msg, NULL) != CONTROLVM_RESP_SUCCESS) { - LOGERR("init_chipset failed.\n"); - return 0; - } - return 1; - - default: - break; - } - - LOGERR("usage: 1 ==> init_chipset client\n"); - LOGERR("usage: 2 ==> init_chipset test\n"); - return -EFAULT; -} - #define PLINE(...) uisutil_add_proc_line_ex(&tot, buff, \ buff_len, __VA_ARGS__) static int -info_proc_read_helper(char **buff, int *buff_len) +info_debugfs_read_helper(char **buff, int *buff_len) { int i, tot = 0; struct bus_info *bus; @@ -1564,7 +1264,8 @@ err_done: } static ssize_t -info_proc_read(struct file *file, char __user *buf, size_t len, loff_t *offset) +info_debugfs_read(struct file *file, char __user *buf, + size_t len, loff_t *offset) { char *temp; int totalBytes = 0; @@ -1584,9 +1285,9 @@ info_proc_read(struct file *file, char __user *buf, size_t len, loff_t *offset) temp = ProcReadBuffer; if ((*offset == 0) || (!ProcReadBufferValid)) { - DBGINF("calling info_proc_read_helper.\n"); + DBGINF("calling info_debugfs_read_helper.\n"); /* if the read fails, then -1 will be returned */ - totalBytes = info_proc_read_helper(&temp, &remaining_bytes); + totalBytes = info_debugfs_read_helper(&temp, &remaining_bytes); ProcReadBufferValid = 1; } else totalBytes = strlen(ProcReadBuffer); @@ -1595,432 +1296,6 @@ info_proc_read(struct file *file, char __user *buf, size_t len, loff_t *offset) ProcReadBuffer, totalBytes); } -static ssize_t -platformnumber_proc_read(struct file *file, char __user *buf, - size_t len, loff_t *offset) -{ - int length = 0; - char *vbuf; - loff_t pos = *offset; - - if (pos < 0) - return -EINVAL; - - if (pos > 0 || !len) - return 0; - - vbuf = kzalloc(len, GFP_KERNEL); - if (!vbuf) - return -ENOMEM; - - length = sprintf(vbuf, "%d\n", PlatformNumber); - - if (copy_to_user(buf, vbuf, length)) { - kfree(vbuf); - return -EFAULT; - } - - kfree(vbuf); - *offset += length; - return length; -} - -#ifdef UISLIB_TEST_PROC - -/* proc/uislib/vbus/<x>/info */ -static int -proc_info_vbus_show(struct seq_file *m, void *v) -{ - struct bus_info *bus = m->private; - int i, devInfoCount, x; - char buf[999]; - - if (bus == NULL) - return 0; - seq_printf(m, "Client device / client driver info for %s partition (vbus #%d):\n", - bus->partitionName, bus->busNo); - if ((bus->busChannelBytes == 0) || (bus->pBusChannel == NULL)) - return 0; - devInfoCount = - (bus->busChannelBytes - - sizeof(ULTRA_VBUS_CHANNEL_PROTOCOL)) / - sizeof(ULTRA_VBUS_DEVICEINFO); - x = VBUSCHANNEL_devInfoToStringBuffer(&bus->pBusChannel->ChpInfo, buf, - sizeof(buf) - 1, -1); - buf[x] = '\0'; - seq_printf(m, "%s", buf); - x = VBUSCHANNEL_devInfoToStringBuffer(&bus->pBusChannel->BusInfo, - buf, sizeof(buf) - 1, -1); - buf[x] = '\0'; - seq_printf(m, "%s", buf); - for (i = 0; i < devInfoCount; i++) { - x = VBUSCHANNEL_devInfoToStringBuffer(&bus->pBusChannel-> - DevInfo[i], buf, - sizeof(buf) - 1, i); - if (x > 0) { - buf[x] = '\0'; - seq_printf(m, "%s", buf); - } - } - return 0; -} - -static ssize_t -bus_proc_write(struct file *file, const char __user *buffer, - size_t count, loff_t *ppos) -{ - int server_flag = 0; - int i, action = 0xffff, result; - char buf[16]; - CONTROLVM_MESSAGE msg; - U32 busNo, deviceCount; - - if (count >= ARRAY_SIZE(buf)) - return -EINVAL; - - memset(&msg, 0, sizeof(CONTROLVM_MESSAGE)); - - if (copy_from_user(buf, buffer, count)) { - LOGERR("echo > /proc/uislib/bus: copy_from_user ****FAILED."); - return -EFAULT; - } - - i = sscanf(buf, "%x-%d-%d", &action, &busNo, &deviceCount); - - /* if (i < 1), i.e., if we didn't even read the action field, - * then action will default to 0xffff and the code below will - * fall through the switch and print usage. - */ - switch (action) { - case 0: - /* destroy a bus */ - if (i != 2) - break; - init_msg_header(&msg, CONTROLVM_BUS_DESTROY, 0, server_flag); - msg.cmd.destroyBus.busNo = busNo; - - result = destroy_bus(&msg, NULL); - - if (result != CONTROLVM_RESP_SUCCESS) { - LOGERR("echo 0-%d > /proc/uislib/bus {CONTROLVM_BUS_DESTROY Failed} Result(%d)", - busNo, result); - return -EFAULT; - } - return count; - case 1: - /* create a bus */ - if (i != 3) - break; - init_msg_header(&msg, CONTROLVM_BUS_CREATE, 0, server_flag); - msg.cmd.createBus.busNo = busNo; - msg.cmd.createBus.deviceCount = deviceCount; - - result = create_bus(&msg, NULL); - - if (result != CONTROLVM_RESP_SUCCESS) { - LOGERR("echo 1-%d-%d > /proc/uislib/bus {CONTROLVM_BUS_CREATE Failed} Result(%d)", - busNo, deviceCount, result); - return -EFAULT; - } - - return count; - default: - break; - } - - LOGERR("USAGE: echo <action>-<busNo>... > /proc/uislib/bus"); - LOGERR(" "); - LOGERR("Destruct Syntax ControlVM Message Id"); - LOGERR("--------------- ---------------------"); - LOGERR("0-<busNo> ==> CONTROLVM_BUS_DESTROY"); - LOGERR(" "); - LOGERR("Construct Syntax ControlVM Message Id"); - LOGERR("----------------------- -------------------- "); - LOGERR("1-<busNo>-<deviceCount> ==> CONTROLVM_BUS_CREATE"); - - return -EFAULT; -} - -static ssize_t -uislib_proc_read_writeonly(struct file *file, char __user *buffer, - size_t count, loff_t *ppos) -{ - return 0; -} - -static ssize_t -dev_proc_write(struct file *file, const char __user *buffer, - size_t count, loff_t *ppos) -{ - int server_flag = 0; - CONTROLVM_MESSAGE msg; - U32 busNo, devNo; - char buf[32]; - unsigned int chanptr; - int type, i, action = 0xffff, result; - - if (count >= ARRAY_SIZE(buf)) - return -EINVAL; - - if (copy_from_user(buf, buffer, count)) { - LOGERR("echo > /proc/uislib/device: copy_from_user ****FAILED."); - return -EFAULT; - } - - i = sscanf(buf, "%x-%d-%d-%x-%d", - &action, &busNo, &devNo, &chanptr, &type); - - switch (action) { - case 0: - if (i != 3) - break; - - /* destroy a device */ - init_msg_header(&msg, CONTROLVM_DEVICE_DESTROY, 0, server_flag); - msg.cmd.destroyDevice.busNo = busNo; - msg.cmd.destroyDevice.devNo = devNo; - - result = destroy_device(&msg, NULL); - - if (result != CONTROLVM_RESP_SUCCESS) { - LOGERR("echo 0-%d-%d > /proc/uislib/device {CONTROLVM_DEVICE_DESTROY Failed} Result(%d)", - busNo, devNo, result); - return -EFAULT; - } - - return count; - - case 1: - if (i != 5) - break; - - /* create a device */ - init_msg_header(&msg, CONTROLVM_DEVICE_CREATE, 0, server_flag); - msg.cmd.createDevice.busNo = busNo; - msg.cmd.createDevice.devNo = devNo; - msg.cmd.createDevice.channelAddr = __pa(chanptr); - msg.cmd.createDevice.channelBytes = MIN_IO_CHANNEL_SIZE; - - if (type == 0) - msg.cmd.createDevice.dataTypeGuid = - UltraVhbaChannelProtocolGuid; - else if (type == 1) - msg.cmd.createDevice.dataTypeGuid = - UltraVnicChannelProtocolGuid; - else { - LOGERR("echo 1-%d-%d-%x-<type> > /proc/uislib/devce failed: invalid device type %d.", - busNo, devNo, chanptr, type); - return -EFAULT; - } - - result = create_device(&msg, NULL); - - if (result != CONTROLVM_RESP_SUCCESS) { - if (type == 0) - LOGERR("echo 1-%d-%d-%x-0 > /proc/uislib/device {CONTROLVM_DEVICE_CREATE[vHBA] Failed} Result(%d)", - busNo, devNo, chanptr, result); - else - LOGERR("echo 1-%d-%d-%x-1 > /proc/uislib/device {CONTROLVM_DEVICE_CREATE[vNIC] Failed} Result(%d)", - busNo, devNo, chanptr, result); - return -EFAULT; - } - - default: - break; - } - - LOGERR("USAGE: echo <action>-<busNo>-<devNo>... > /proc/uislib/device"); - LOGERR(" "); - LOGERR("Destruct Syntax ControlVM Message Id"); - LOGERR("----------------- ------------------------"); - LOGERR("0-<busNo>-<devNo> ==> CONTROLVM_DEVICE_DESTROY"); - LOGERR(" "); - LOGERR("Construct Syntax ControlVM Message Id"); - LOGERR - ("---------------------------------- ----------------------- "); - LOGERR - ("1-<busNo>-<devNo>-<chanptr>-<type> ==> CONTROLVM_DEVICE_CREATE"); - LOGERR(" <type = 0>: vHBA"); - LOGERR(" <type = 1>: vNIC"); - LOGERR(" "); - - return -EFAULT; -} - -static ssize_t -cycles_before_wait_proc_write(struct file *file, const char __user *buffer, - size_t count, loff_t *ppos) -{ - char buf[16]; - -#define CYCLES_BEFORE_WAIT_USE_ERROR { \ - LOGERR("Incorrect Call Home Input.\n"); \ - pr_info("Please pass Call Home Event Parameters in the form:\n"); \ - pr_info("EventID Category Type[parameter1][parameter2][parameter3][parameter4][parameter5][parameter6]\n"); \ - return -EFAULT; \ -} - if (count >= ARRAY_SIZE(buf)) - return -EINVAL; - - if (count == 0) - CYCLES_BEFORE_WAIT_USE_ERROR; - - if (copy_from_user(buf, buffer, count)) { - LOGERR("copy_from_user failed.\n"); - return -EFAULT; - } - buf[count - 1] = '\0'; /* Replace the LF at the end of the - * input with a NULL */ - /* Pull out the cycles_before_wait must be decimal integer */ - if (sscanf(buf, "%lld", &cycles_before_wait) != 1) - CYCLES_BEFORE_WAIT_USE_ERROR; - - return count; -} - -static ssize_t -reset_counts_proc_write(struct file *file, const char __user *buffer, - size_t count, loff_t *ppos) -{ - char buf[16]; - unsigned long long new_value; - struct bus_info *bus; - int i; - -#define RESET_COUNTS_USE_ERROR { \ - LOGERR("Incorrect reset_counts Input.\n"); \ - pr_info("Please pass the new value for the counters:\n"); \ - pr_info("e.g. echo 0 > reset_counts\n"); \ - return -EFAULT; \ - } - - if (count >= ARRAY_SIZE(buf)) - return -EINVAL; - - if (count == 0) - RESET_COUNTS_USE_ERROR; - - if (copy_from_user(buf, buffer, count)) { - LOGERR("copy_from_user failed.\n"); - return -EFAULT; - } - buf[count - 1] = '\0'; /* Replace the LF at the end of the - * input with a NULL */ - /* Pull out the reset_counts must be decimal integer */ - if (sscanf(buf, "%llu", &new_value) != 1) - RESET_COUNTS_USE_ERROR; - read_lock(&BusListLock); - for (bus = BusListHead; bus; bus = bus->next) { - - for (i = 0; i < bus->deviceCount; i++) { - if (bus->device[i]) { - bus->device[i]->first_busy_cnt = new_value; - bus->device[i]->moved_to_tail_cnt = new_value; - bus->device[i]->last_on_list_cnt = new_value; - } - } - } - read_unlock(&BusListLock); - tot_moved_to_tail_cnt = new_value; - tot_wait_cnt = new_value; - tot_wakeup_cnt = new_value; - tot_schedule_cnt = new_value; - return count; -} - -static ssize_t -smart_wakeup_proc_write(struct file *file, const char __user *buffer, - size_t count, loff_t *ppos) -{ - char buf[16]; - int new_value; - -#define SMART_WAKEUP_USE_ERROR { \ - LOGERR("Incorrect smart_wakeup Input 0 disables smart_wakeup, and 1 enables smart_wakeup.\n"); \ - pr_info("echo 0 > smart_wakeup\n"); \ - pr_info("echo 1 > smart_wakeup\n"); \ - return -EFAULT; \ - } - - if (count >= ARRAY_SIZE(buf)) - return -EINVAL; - - if (count == 0) - SMART_WAKEUP_USE_ERROR; - - if (copy_from_user(buf, buffer, count)) { - LOGERR("copy_from_user failed.\n"); - return -EFAULT; - } - buf[count - 1] = '\0'; /* Replace the LF at the end of the - * input with a NULL */ - /* Pull out the smart_wakeup must be decimal integer */ - if (sscanf(buf, "%d", &new_value) != 1) - SMART_WAKEUP_USE_ERROR; - en_smart_wakeup = new_value; - return count; -} - -static ssize_t -test_proc_write(struct file *file, const char __user *buffer, - size_t count, loff_t *ppos) -{ - int i, action = 0xffff; - char buf[16]; - CONTROLVM_MESSAGE msg; - S64 vrtc_offset; - - if (count >= ARRAY_SIZE(buf)) - return -EINVAL; - - memset(&msg, 0, sizeof(CONTROLVM_MESSAGE)); - - if (copy_from_user(buf, buffer, count)) { - LOGERR("copy_from_user ****FAILED.\n"); - return -EFAULT; - } - - i = sscanf(buf, "%x", &action); - - /* if (i < 1), i.e., if we didn't even read the action field, - * then action will default to 0xffff and the code below will - * fall through the switch and print usage. */ - switch (action) { - case 6: - msg.hdr.Id = CONTROLVM_CHIPSET_STOP; - msg.hdr.Flags.responseExpected = 1; - stop_chipset(&msg, NULL); - break; - case 7: - vrtc_offset = 0; - LOGERR("about to issue QUERY vrtc_offset=%LX", vrtc_offset); - vrtc_offset = Issue_VMCALL_QUERY_GUEST_VIRTUAL_TIME_OFFSET(); - LOGERR("result is vrtc_offset=%LX", vrtc_offset); - break; - case 8: - vrtc_offset = 60; - LOGERR("about to increase physical time by 0x%LX seconds", - vrtc_offset); - vrtc_offset = Issue_VMCALL_UPDATE_PHYSICAL_TIME(vrtc_offset); - break; - case 9: - vrtc_offset = -60; - LOGERR("about to decrease physical time by 0x%LX seconds", - vrtc_offset); - vrtc_offset = Issue_VMCALL_UPDATE_PHYSICAL_TIME(vrtc_offset); - break; - default: - LOGERR("usage: 6 for CHIPSET_STOP\n"); - LOGERR(" 7 for VMCALL_QUERY_GUEST_VIRTUAL_TIME_OFFSET()\n"); - LOGERR(" 8 for VMCALL_UPDATE_PHYSICAL_TIME(60)\n"); - LOGERR(" 9 for VMCALL_UPDATE_PHYSICAL_TIME(-60)\n"); - return -EFAULT; - break; - } - return count; -} - -#endif /* UISLIB_TEST_PROC */ static struct device_info * find_dev(U32 busNo, U32 devNo) { @@ -2277,6 +1552,9 @@ static int __init uislib_mod_init(void) { + if (!unisys_spar_platform) + return -ENODEV; + LOGINF("MONITORAPIS"); LOGINF("sizeof(struct uiscmdrsp):%lu bytes\n", @@ -2308,59 +1586,25 @@ uislib_mod_init(void) * then map this physical address to a virtual address. */ POSTCODE_LINUX_2(DRIVER_ENTRY_PC, POSTCODE_SEVERITY_INFO); - /* create the proc entries for the channels */ - uislib_proc_dir = proc_mkdir(DIR_PROC_ENTRY, NULL); - /* (e.g., for /proc/uislib/vbus/<x>/info) */ - uislib_proc_vbus_dir = proc_mkdir(DIR_VBUS_PROC_ENTRY, uislib_proc_dir); - - vnic_proc_entry = proc_create(VNIC_PROC_ENTRY_FN, 0, uislib_proc_dir, - &proc_vnic_fops); - SET_PROC_OWNER(vnic_proc_entry, THIS_MODULE); - - /* for testing purposes only, create the proc entries for - * enqueuing Control Channel messages */ - chipset_proc_entry = - proc_create(CHIPSET_PROC_ENTRY_FN, 0, uislib_proc_dir, - &proc_chipset_fops); - SET_PROC_OWNER(chipset_proc_entry, THIS_MODULE); - - info_proc_entry = proc_create(INFO_PROC_ENTRY_FN, 0, uislib_proc_dir, - &proc_info_fops); - SET_PROC_OWNER(info_proc_entry, THIS_MODULE); - - platformnumber_proc_entry = - proc_create(PLATFORMNUMBER_PROC_ENTRY_FN, 0, uislib_proc_dir, - &proc_platformnumber_fops); - SET_PROC_OWNER(platformnumberinfo_proc_entry, THIS_MODULE); - - cycles_before_wait_proc_entry = - proc_create(CYCLES_BEFORE_WAIT_PROC_ENTRY_FN, 0, uislib_proc_dir, - &proc_cycles_before_wait_fops); - SET_PROC_OWNER(cycles_before_wait_proc_entry, THIS_MODULE); - - reset_counts_proc_entry = - proc_create(RESET_COUNTS_PROC_ENTRY_FN, 0, uislib_proc_dir, - &proc_reset_counts_fops); - SET_PROC_OWNER(reset_counts_proc_entry, THIS_MODULE); - - smart_wakeup_proc_entry = - proc_create(SMART_WAKEUP_PROC_ENTRY_FN, 0, uislib_proc_dir, - &proc_smart_wakeup_fops); - SET_PROC_OWNER(smart_wakeup_proc_entry, THIS_MODULE); - -#ifdef UISLIB_TEST_PROC - test_proc_entry = proc_create(TEST_PROC_ENTRY_FN, 0, uislib_proc_dir, - &proc_test_fops); - SET_PROC_OWNER(test_proc_entry, THIS_MODULE); - - bus_proc_entry = proc_create(BUS_PROC_ENTRY_FN, 0, uislib_proc_dir, - &proc_bus_fops); - SET_PROC_OWNER(bus_proc_entry, THIS_MODULE); - - dev_proc_entry = proc_create(DEV_PROC_ENTRY_FN, 0, uislib_proc_dir, - &proc_dev_fops); - SET_PROC_OWNER(dev_proc_entry, THIS_MODULE); -#endif /* UISLIB_TEST_PROC */ + dir_debugfs = debugfs_create_dir(DIR_DEBUGFS_ENTRY, NULL); + if (dir_debugfs) { + info_debugfs_entry = debugfs_create_file( + INFO_DEBUGFS_ENTRY_FN, 0444, dir_debugfs, NULL, + &debugfs_info_fops); + + platformnumber_debugfs_read = debugfs_create_u32( + PLATFORMNUMBER_DEBUGFS_ENTRY_FN, 0444, dir_debugfs, + &PlatformNumber); + + cycles_before_wait_debugfs_read = debugfs_create_u64( + CYCLES_BEFORE_WAIT_DEBUGFS_ENTRY_FN, 0666, dir_debugfs, + &cycles_before_wait); + + smart_wakeup_debugfs_entry = debugfs_create_bool( + SMART_WAKEUP_DEBUGFS_ENTRY_FN, 0666, dir_debugfs, + &en_smart_wakeup); + } + POSTCODE_LINUX_3(DRIVER_EXIT_PC, 0, POSTCODE_SEVERITY_INFO); return 0; } @@ -2368,46 +1612,17 @@ uislib_mod_init(void) static void __exit uislib_mod_exit(void) { - if (disable_proc_entry) - remove_proc_entry(DISABLE_PROC_ENTRY_FN, uislib_proc_dir); - if (cycles_before_wait_proc_entry) - remove_proc_entry(CYCLES_BEFORE_WAIT_PROC_ENTRY_FN, - uislib_proc_dir); - if (reset_counts_proc_entry) - remove_proc_entry(RESET_COUNTS_PROC_ENTRY_FN, uislib_proc_dir); - if (smart_wakeup_proc_entry) - remove_proc_entry(SMART_WAKEUP_PROC_ENTRY_FN, uislib_proc_dir); - if (ctrlchan_proc_entry) - remove_proc_entry(CTRLCHAN_PROC_ENTRY_FN, uislib_proc_dir); - if (pmem_proc_entry) - remove_proc_entry(PMEM_PROC_ENTRY_FN, uislib_proc_dir); - if (info_proc_entry) - remove_proc_entry(INFO_PROC_ENTRY_FN, uislib_proc_dir); - if (switch_proc_entry) - remove_proc_entry(SWITCH_PROC_ENTRY_FN, uislib_proc_dir); - if (extport_proc_entry) - remove_proc_entry(EXTPORT_PROC_ENTRY_FN, uislib_proc_dir); - if (platformnumber_proc_entry) - remove_proc_entry(PLATFORMNUMBER_PROC_ENTRY_FN, - uislib_proc_dir); - if (bus_proc_entry) - remove_proc_entry(BUS_PROC_ENTRY_FN, uislib_proc_dir); - if (dev_proc_entry) - remove_proc_entry(DEV_PROC_ENTRY_FN, uislib_proc_dir); - if (vnic_proc_entry) - remove_proc_entry(VNIC_PROC_ENTRY_FN, uislib_proc_dir); - if (chipset_proc_entry) - remove_proc_entry(CHIPSET_PROC_ENTRY_FN, uislib_proc_dir); - if (uislib_proc_vbus_dir) - remove_proc_entry(DIR_VBUS_PROC_ENTRY, uislib_proc_dir); - if (uislib_proc_dir) - remove_proc_entry(DIR_PROC_ENTRY, NULL); - if (ProcReadBuffer) { vfree(ProcReadBuffer); ProcReadBuffer = NULL; } + debugfs_remove(info_debugfs_entry); + debugfs_remove(smart_wakeup_debugfs_entry); + debugfs_remove(cycles_before_wait_debugfs_read); + debugfs_remove(platformnumber_debugfs_read); + debugfs_remove(dir_debugfs); + DBGINF("goodbye.\n"); return; } |