2 * IUCV base infrastructure.
4 * Copyright 2001, 2006 IBM Deutschland Entwicklung GmbH, IBM Corporation
7 * Alan Altmark (Alan_Altmark@us.ibm.com) Sept. 2000
8 * Xenia Tkatschow (xenia@us.ibm.com)
9 * 2Gb awareness and general cleanup:
10 * Fritz Elfert (elfert@de.ibm.com, felfert@millenux.com)
11 * Rewritten for af_iucv:
12 * Martin Schwidefsky <schwidefsky@de.ibm.com>
16 * CP Programming Service, IBM document # SC24-5760
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2, or (at your option)
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
33 #define KMSG_COMPONENT "iucv"
34 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
36 #include <linux/module.h>
37 #include <linux/moduleparam.h>
38 #include <linux/spinlock.h>
39 #include <linux/kernel.h>
40 #include <linux/slab.h>
41 #include <linux/init.h>
42 #include <linux/interrupt.h>
43 #include <linux/list.h>
44 #include <linux/errno.h>
45 #include <linux/err.h>
46 #include <linux/device.h>
47 #include <linux/cpu.h>
48 #include <net/iucv/iucv.h>
49 #include <asm/atomic.h>
50 #include <asm/ebcdic.h>
52 #include <asm/s390_ext.h>
57 * All flags are defined in the field IPFLAGS1 of each function
58 * and can be found in CP Programming Services.
59 * IPSRCCLS - Indicates you have specified a source class.
60 * IPTRGCLS - Indicates you have specified a target class.
61 * IPFGPID - Indicates you have specified a pathid.
62 * IPFGMID - Indicates you have specified a message ID.
63 * IPNORPY - Indicates a one-way message. No reply expected.
64 * IPALL - Indicates that all paths are affected.
66 #define IUCV_IPSRCCLS 0x01
67 #define IUCV_IPTRGCLS 0x01
68 #define IUCV_IPFGPID 0x02
69 #define IUCV_IPFGMID 0x04
70 #define IUCV_IPNORPY 0x10
71 #define IUCV_IPALL 0x80
73 static int iucv_bus_match(struct device *dev, struct device_driver *drv)
78 struct bus_type iucv_bus = {
80 .match = iucv_bus_match,
82 EXPORT_SYMBOL(iucv_bus);
84 struct device *iucv_root;
85 EXPORT_SYMBOL(iucv_root);
87 static int iucv_available;
89 /* General IUCV interrupt structure */
90 struct iucv_irq_data {
97 struct iucv_irq_list {
98 struct list_head list;
99 struct iucv_irq_data data;
102 static struct iucv_irq_data *iucv_irq_data[NR_CPUS];
103 static cpumask_t iucv_buffer_cpumask = CPU_MASK_NONE;
104 static cpumask_t iucv_irq_cpumask = CPU_MASK_NONE;
107 * Queue of interrupt buffers lock for delivery via the tasklet
108 * (fast but can't call smp_call_function).
110 static LIST_HEAD(iucv_task_queue);
113 * The tasklet for fast delivery of iucv interrupts.
115 static void iucv_tasklet_fn(unsigned long);
116 static DECLARE_TASKLET(iucv_tasklet, iucv_tasklet_fn,0);
119 * Queue of interrupt buffers for delivery via a work queue
120 * (slower but can call smp_call_function).
122 static LIST_HEAD(iucv_work_queue);
125 * The work element to deliver path pending interrupts.
127 static void iucv_work_fn(struct work_struct *work);
128 static DECLARE_WORK(iucv_work, iucv_work_fn);
131 * Spinlock protecting task and work queue.
133 static DEFINE_SPINLOCK(iucv_queue_lock);
135 enum iucv_command_codes {
137 IUCV_RETRIEVE_BUFFER = 2,
145 IUCV_DECLARE_BUFFER = 12,
153 * Error messages that are used with the iucv_sever function. They get
154 * converted to EBCDIC.
156 static char iucv_error_no_listener[16] = "NO LISTENER";
157 static char iucv_error_no_memory[16] = "NO MEMORY";
158 static char iucv_error_pathid[16] = "INVALID PATHID";
161 * iucv_handler_list: List of registered handlers.
163 static LIST_HEAD(iucv_handler_list);
166 * iucv_path_table: an array of iucv_path structures.
168 static struct iucv_path **iucv_path_table;
169 static unsigned long iucv_max_pathid;
172 * iucv_lock: spinlock protecting iucv_handler_list and iucv_pathid_table
174 static DEFINE_SPINLOCK(iucv_table_lock);
177 * iucv_active_cpu: contains the number of the cpu executing the tasklet
178 * or the work handler. Needed for iucv_path_sever called from tasklet.
180 static int iucv_active_cpu = -1;
183 * Mutex and wait queue for iucv_register/iucv_unregister.
185 static DEFINE_MUTEX(iucv_register_mutex);
188 * Counter for number of non-smp capable handlers.
190 static int iucv_nonsmp_handler;
193 * IUCV control data structure. Used by iucv_path_accept, iucv_path_connect,
194 * iucv_path_quiesce and iucv_path_sever.
196 struct iucv_cmd_control {
205 } __attribute__ ((packed,aligned(8)));
208 * Data in parameter list iucv structure. Used by iucv_message_send,
209 * iucv_message_send2way and iucv_message_reply.
211 struct iucv_cmd_dpl {
223 } __attribute__ ((packed,aligned(8)));
226 * Data in buffer iucv structure. Used by iucv_message_receive,
227 * iucv_message_reject, iucv_message_send, iucv_message_send2way
228 * and iucv_declare_cpu.
243 } __attribute__ ((packed,aligned(8)));
246 * Purge message iucv structure. Used by iucv_message_purge.
248 struct iucv_cmd_purge {
259 } __attribute__ ((packed,aligned(8)));
262 * Set mask iucv structure. Used by iucv_enable_cpu.
264 struct iucv_cmd_set_mask {
269 } __attribute__ ((packed,aligned(8)));
272 struct iucv_cmd_control ctrl;
273 struct iucv_cmd_dpl dpl;
274 struct iucv_cmd_db db;
275 struct iucv_cmd_purge purge;
276 struct iucv_cmd_set_mask set_mask;
280 * Anchor for per-cpu IUCV command parameter block.
282 static union iucv_param *iucv_param[NR_CPUS];
283 static union iucv_param *iucv_param_irq[NR_CPUS];
287 * @code: identifier of IUCV call to CP.
288 * @parm: pointer to a struct iucv_parm block
290 * Calls CP to execute IUCV commands.
292 * Returns the result of the CP IUCV call.
294 static inline int iucv_call_b2f0(int command, union iucv_param *parm)
296 register unsigned long reg0 asm ("0");
297 register unsigned long reg1 asm ("1");
301 reg1 = virt_to_phys(parm);
303 " .long 0xb2f01000\n"
306 : "=d" (ccode), "=m" (*parm), "+d" (reg0), "+a" (reg1)
307 : "m" (*parm) : "cc");
308 return (ccode == 1) ? parm->ctrl.iprcode : ccode;
314 * Determines the maximum number of connections that may be established.
316 * Returns the maximum number of connections or -EPERM is IUCV is not
319 static int iucv_query_maxconn(void)
321 register unsigned long reg0 asm ("0");
322 register unsigned long reg1 asm ("1");
326 param = kzalloc(sizeof(union iucv_param), GFP_KERNEL|GFP_DMA);
330 reg1 = (unsigned long) param;
332 " .long 0xb2f01000\n"
335 : "=d" (ccode), "+d" (reg0), "+d" (reg1) : : "cc");
337 iucv_max_pathid = reg0;
339 return ccode ? -EPERM : 0;
346 * Allow iucv interrupts on this cpu.
348 static void iucv_allow_cpu(void *data)
350 int cpu = smp_processor_id();
351 union iucv_param *parm;
354 * Enable all iucv interrupts.
355 * ipmask contains bits for the different interrupts
356 * 0x80 - Flag to allow nonpriority message pending interrupts
357 * 0x40 - Flag to allow priority message pending interrupts
358 * 0x20 - Flag to allow nonpriority message completion interrupts
359 * 0x10 - Flag to allow priority message completion interrupts
360 * 0x08 - Flag to allow IUCV control interrupts
362 parm = iucv_param_irq[cpu];
363 memset(parm, 0, sizeof(union iucv_param));
364 parm->set_mask.ipmask = 0xf8;
365 iucv_call_b2f0(IUCV_SETMASK, parm);
367 /* Set indication that iucv interrupts are allowed for this cpu. */
368 cpu_set(cpu, iucv_irq_cpumask);
375 * Block iucv interrupts on this cpu.
377 static void iucv_block_cpu(void *data)
379 int cpu = smp_processor_id();
380 union iucv_param *parm;
382 /* Disable all iucv interrupts. */
383 parm = iucv_param_irq[cpu];
384 memset(parm, 0, sizeof(union iucv_param));
385 iucv_call_b2f0(IUCV_SETMASK, parm);
387 /* Clear indication that iucv interrupts are allowed for this cpu. */
388 cpu_clear(cpu, iucv_irq_cpumask);
395 * Declare a interrupt buffer on this cpu.
397 static void iucv_declare_cpu(void *data)
399 int cpu = smp_processor_id();
400 union iucv_param *parm;
403 if (cpu_isset(cpu, iucv_buffer_cpumask))
406 /* Declare interrupt buffer. */
407 parm = iucv_param_irq[cpu];
408 memset(parm, 0, sizeof(union iucv_param));
409 parm->db.ipbfadr1 = virt_to_phys(iucv_irq_data[cpu]);
410 rc = iucv_call_b2f0(IUCV_DECLARE_BUFFER, parm);
412 char *err = "Unknown";
415 err = "Directory error";
418 err = "Invalid length";
421 err = "Buffer already exists";
424 err = "Buffer overlap";
427 err = "Paging or storage error";
430 pr_warning("Defining an interrupt buffer on CPU %i"
431 " failed with 0x%02x (%s)\n", cpu, rc, err);
435 /* Set indication that an iucv buffer exists for this cpu. */
436 cpu_set(cpu, iucv_buffer_cpumask);
438 if (iucv_nonsmp_handler == 0 || cpus_empty(iucv_irq_cpumask))
439 /* Enable iucv interrupts on this cpu. */
440 iucv_allow_cpu(NULL);
442 /* Disable iucv interrupts on this cpu. */
443 iucv_block_cpu(NULL);
450 * Retrieve interrupt buffer on this cpu.
452 static void iucv_retrieve_cpu(void *data)
454 int cpu = smp_processor_id();
455 union iucv_param *parm;
457 if (!cpu_isset(cpu, iucv_buffer_cpumask))
460 /* Block iucv interrupts. */
461 iucv_block_cpu(NULL);
463 /* Retrieve interrupt buffer. */
464 parm = iucv_param_irq[cpu];
465 iucv_call_b2f0(IUCV_RETRIEVE_BUFFER, parm);
467 /* Clear indication that an iucv buffer exists for this cpu. */
468 cpu_clear(cpu, iucv_buffer_cpumask);
474 * Allow iucv interrupts on all cpus.
476 static void iucv_setmask_mp(void)
481 for_each_online_cpu(cpu)
482 /* Enable all cpus with a declared buffer. */
483 if (cpu_isset(cpu, iucv_buffer_cpumask) &&
484 !cpu_isset(cpu, iucv_irq_cpumask))
485 smp_call_function_single(cpu, iucv_allow_cpu,
493 * Allow iucv interrupts on a single cpu.
495 static void iucv_setmask_up(void)
500 /* Disable all cpu but the first in cpu_irq_cpumask. */
501 cpumask = iucv_irq_cpumask;
502 cpu_clear(first_cpu(iucv_irq_cpumask), cpumask);
503 for_each_cpu_mask_nr(cpu, cpumask)
504 smp_call_function_single(cpu, iucv_block_cpu, NULL, 1);
510 * This function makes iucv ready for use. It allocates the pathid
511 * table, declares an iucv interrupt buffer and enables the iucv
512 * interrupts. Called when the first user has registered an iucv
515 static int iucv_enable(void)
522 alloc_size = iucv_max_pathid * sizeof(struct iucv_path);
523 iucv_path_table = kzalloc(alloc_size, GFP_KERNEL);
524 if (!iucv_path_table)
526 /* Declare per cpu buffers. */
528 for_each_online_cpu(cpu)
529 smp_call_function_single(cpu, iucv_declare_cpu, NULL, 1);
530 if (cpus_empty(iucv_buffer_cpumask))
531 /* No cpu could declare an iucv buffer. */
536 kfree(iucv_path_table);
537 iucv_path_table = NULL;
545 * This function shuts down iucv. It disables iucv interrupts, retrieves
546 * the iucv interrupt buffer and frees the pathid table. Called after the
547 * last user unregister its iucv handler.
549 static void iucv_disable(void)
552 on_each_cpu(iucv_retrieve_cpu, NULL, 1);
553 kfree(iucv_path_table);
554 iucv_path_table = NULL;
558 static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
559 unsigned long action, void *hcpu)
562 long cpu = (long) hcpu;
566 case CPU_UP_PREPARE_FROZEN:
567 iucv_irq_data[cpu] = kmalloc_node(sizeof(struct iucv_irq_data),
568 GFP_KERNEL|GFP_DMA, cpu_to_node(cpu));
569 if (!iucv_irq_data[cpu])
571 iucv_param[cpu] = kmalloc_node(sizeof(union iucv_param),
572 GFP_KERNEL|GFP_DMA, cpu_to_node(cpu));
573 if (!iucv_param[cpu]) {
574 kfree(iucv_irq_data[cpu]);
575 iucv_irq_data[cpu] = NULL;
578 iucv_param_irq[cpu] = kmalloc_node(sizeof(union iucv_param),
579 GFP_KERNEL|GFP_DMA, cpu_to_node(cpu));
580 if (!iucv_param_irq[cpu]) {
581 kfree(iucv_param[cpu]);
582 iucv_param[cpu] = NULL;
583 kfree(iucv_irq_data[cpu]);
584 iucv_irq_data[cpu] = NULL;
588 case CPU_UP_CANCELED:
589 case CPU_UP_CANCELED_FROZEN:
591 case CPU_DEAD_FROZEN:
592 kfree(iucv_param_irq[cpu]);
593 iucv_param_irq[cpu] = NULL;
594 kfree(iucv_param[cpu]);
595 iucv_param[cpu] = NULL;
596 kfree(iucv_irq_data[cpu]);
597 iucv_irq_data[cpu] = NULL;
600 case CPU_ONLINE_FROZEN:
601 case CPU_DOWN_FAILED:
602 case CPU_DOWN_FAILED_FROZEN:
603 if (!iucv_path_table)
605 smp_call_function_single(cpu, iucv_declare_cpu, NULL, 1);
607 case CPU_DOWN_PREPARE:
608 case CPU_DOWN_PREPARE_FROZEN:
609 if (!iucv_path_table)
611 cpumask = iucv_buffer_cpumask;
612 cpu_clear(cpu, cpumask);
613 if (cpus_empty(cpumask))
614 /* Can't offline last IUCV enabled cpu. */
616 smp_call_function_single(cpu, iucv_retrieve_cpu, NULL, 1);
617 if (cpus_empty(iucv_irq_cpumask))
618 smp_call_function_single(first_cpu(iucv_buffer_cpumask),
619 iucv_allow_cpu, NULL, 1);
625 static struct notifier_block __refdata iucv_cpu_notifier = {
626 .notifier_call = iucv_cpu_notify,
631 * @pathid: path identification number.
632 * @userdata: 16-bytes of user data.
634 * Sever an iucv path to free up the pathid. Used internally.
636 static int iucv_sever_pathid(u16 pathid, u8 userdata[16])
638 union iucv_param *parm;
640 parm = iucv_param_irq[smp_processor_id()];
641 memset(parm, 0, sizeof(union iucv_param));
643 memcpy(parm->ctrl.ipuser, userdata, sizeof(parm->ctrl.ipuser));
644 parm->ctrl.ippathid = pathid;
645 return iucv_call_b2f0(IUCV_SEVER, parm);
649 * __iucv_cleanup_queue
650 * @dummy: unused dummy argument
652 * Nop function called via smp_call_function to force work items from
653 * pending external iucv interrupts to the work queue.
655 static void __iucv_cleanup_queue(void *dummy)
662 * Function called after a path has been severed to find all remaining
663 * work items for the now stale pathid. The caller needs to hold the
666 static void iucv_cleanup_queue(void)
668 struct iucv_irq_list *p, *n;
671 * When a path is severed, the pathid can be reused immediatly
672 * on a iucv connect or a connection pending interrupt. Remove
673 * all entries from the task queue that refer to a stale pathid
674 * (iucv_path_table[ix] == NULL). Only then do the iucv connect
675 * or deliver the connection pending interrupt. To get all the
676 * pending interrupts force them to the work queue by calling
677 * an empty function on all cpus.
679 smp_call_function(__iucv_cleanup_queue, NULL, 1);
680 spin_lock_irq(&iucv_queue_lock);
681 list_for_each_entry_safe(p, n, &iucv_task_queue, list) {
682 /* Remove stale work items from the task queue. */
683 if (iucv_path_table[p->data.ippathid] == NULL) {
688 spin_unlock_irq(&iucv_queue_lock);
693 * @handler: address of iucv handler structure
694 * @smp: != 0 indicates that the handler can deal with out of order messages
696 * Registers a driver with IUCV.
698 * Returns 0 on success, -ENOMEM if the memory allocation for the pathid
699 * table failed, or -EIO if IUCV_DECLARE_BUFFER failed on all cpus.
701 int iucv_register(struct iucv_handler *handler, int smp)
707 mutex_lock(&iucv_register_mutex);
709 iucv_nonsmp_handler++;
710 if (list_empty(&iucv_handler_list)) {
714 } else if (!smp && iucv_nonsmp_handler == 1)
716 INIT_LIST_HEAD(&handler->paths);
718 spin_lock_bh(&iucv_table_lock);
719 list_add_tail(&handler->list, &iucv_handler_list);
720 spin_unlock_bh(&iucv_table_lock);
723 mutex_unlock(&iucv_register_mutex);
726 EXPORT_SYMBOL(iucv_register);
730 * @handler: address of iucv handler structure
731 * @smp: != 0 indicates that the handler can deal with out of order messages
733 * Unregister driver from IUCV.
735 void iucv_unregister(struct iucv_handler *handler, int smp)
737 struct iucv_path *p, *n;
739 mutex_lock(&iucv_register_mutex);
740 spin_lock_bh(&iucv_table_lock);
741 /* Remove handler from the iucv_handler_list. */
742 list_del_init(&handler->list);
743 /* Sever all pathids still refering to the handler. */
744 list_for_each_entry_safe(p, n, &handler->paths, list) {
745 iucv_sever_pathid(p->pathid, NULL);
746 iucv_path_table[p->pathid] = NULL;
750 spin_unlock_bh(&iucv_table_lock);
752 iucv_nonsmp_handler--;
753 if (list_empty(&iucv_handler_list))
755 else if (!smp && iucv_nonsmp_handler == 0)
757 mutex_unlock(&iucv_register_mutex);
759 EXPORT_SYMBOL(iucv_unregister);
763 * @path: address of iucv path structure
764 * @handler: address of iucv handler structure
765 * @userdata: 16 bytes of data reflected to the communication partner
766 * @private: private data passed to interrupt handlers for this path
768 * This function is issued after the user received a connection pending
769 * external interrupt and now wishes to complete the IUCV communication path.
771 * Returns the result of the CP IUCV call.
773 int iucv_path_accept(struct iucv_path *path, struct iucv_handler *handler,
774 u8 userdata[16], void *private)
776 union iucv_param *parm;
780 /* Prepare parameter block. */
781 parm = iucv_param[smp_processor_id()];
782 memset(parm, 0, sizeof(union iucv_param));
783 parm->ctrl.ippathid = path->pathid;
784 parm->ctrl.ipmsglim = path->msglim;
786 memcpy(parm->ctrl.ipuser, userdata, sizeof(parm->ctrl.ipuser));
787 parm->ctrl.ipflags1 = path->flags;
789 rc = iucv_call_b2f0(IUCV_ACCEPT, parm);
791 path->private = private;
792 path->msglim = parm->ctrl.ipmsglim;
793 path->flags = parm->ctrl.ipflags1;
798 EXPORT_SYMBOL(iucv_path_accept);
802 * @path: address of iucv path structure
803 * @handler: address of iucv handler structure
804 * @userid: 8-byte user identification
805 * @system: 8-byte target system identification
806 * @userdata: 16 bytes of data reflected to the communication partner
807 * @private: private data passed to interrupt handlers for this path
809 * This function establishes an IUCV path. Although the connect may complete
810 * successfully, you are not able to use the path until you receive an IUCV
811 * Connection Complete external interrupt.
813 * Returns the result of the CP IUCV call.
815 int iucv_path_connect(struct iucv_path *path, struct iucv_handler *handler,
816 u8 userid[8], u8 system[8], u8 userdata[16],
819 union iucv_param *parm;
822 spin_lock_bh(&iucv_table_lock);
823 iucv_cleanup_queue();
824 parm = iucv_param[smp_processor_id()];
825 memset(parm, 0, sizeof(union iucv_param));
826 parm->ctrl.ipmsglim = path->msglim;
827 parm->ctrl.ipflags1 = path->flags;
829 memcpy(parm->ctrl.ipvmid, userid, sizeof(parm->ctrl.ipvmid));
830 ASCEBC(parm->ctrl.ipvmid, sizeof(parm->ctrl.ipvmid));
831 EBC_TOUPPER(parm->ctrl.ipvmid, sizeof(parm->ctrl.ipvmid));
834 memcpy(parm->ctrl.iptarget, system,
835 sizeof(parm->ctrl.iptarget));
836 ASCEBC(parm->ctrl.iptarget, sizeof(parm->ctrl.iptarget));
837 EBC_TOUPPER(parm->ctrl.iptarget, sizeof(parm->ctrl.iptarget));
840 memcpy(parm->ctrl.ipuser, userdata, sizeof(parm->ctrl.ipuser));
842 rc = iucv_call_b2f0(IUCV_CONNECT, parm);
844 if (parm->ctrl.ippathid < iucv_max_pathid) {
845 path->pathid = parm->ctrl.ippathid;
846 path->msglim = parm->ctrl.ipmsglim;
847 path->flags = parm->ctrl.ipflags1;
848 path->handler = handler;
849 path->private = private;
850 list_add_tail(&path->list, &handler->paths);
851 iucv_path_table[path->pathid] = path;
853 iucv_sever_pathid(parm->ctrl.ippathid,
858 spin_unlock_bh(&iucv_table_lock);
861 EXPORT_SYMBOL(iucv_path_connect);
865 * @path: address of iucv path structure
866 * @userdata: 16 bytes of data reflected to the communication partner
868 * This function temporarily suspends incoming messages on an IUCV path.
869 * You can later reactivate the path by invoking the iucv_resume function.
871 * Returns the result from the CP IUCV call.
873 int iucv_path_quiesce(struct iucv_path *path, u8 userdata[16])
875 union iucv_param *parm;
879 parm = iucv_param[smp_processor_id()];
880 memset(parm, 0, sizeof(union iucv_param));
882 memcpy(parm->ctrl.ipuser, userdata, sizeof(parm->ctrl.ipuser));
883 parm->ctrl.ippathid = path->pathid;
884 rc = iucv_call_b2f0(IUCV_QUIESCE, parm);
888 EXPORT_SYMBOL(iucv_path_quiesce);
892 * @path: address of iucv path structure
893 * @userdata: 16 bytes of data reflected to the communication partner
895 * This function resumes incoming messages on an IUCV path that has
896 * been stopped with iucv_path_quiesce.
898 * Returns the result from the CP IUCV call.
900 int iucv_path_resume(struct iucv_path *path, u8 userdata[16])
902 union iucv_param *parm;
906 parm = iucv_param[smp_processor_id()];
907 memset(parm, 0, sizeof(union iucv_param));
909 memcpy(parm->ctrl.ipuser, userdata, sizeof(parm->ctrl.ipuser));
910 parm->ctrl.ippathid = path->pathid;
911 rc = iucv_call_b2f0(IUCV_RESUME, parm);
918 * @path: address of iucv path structure
919 * @userdata: 16 bytes of data reflected to the communication partner
921 * This function terminates an IUCV path.
923 * Returns the result from the CP IUCV call.
925 int iucv_path_sever(struct iucv_path *path, u8 userdata[16])
930 if (iucv_active_cpu != smp_processor_id())
931 spin_lock_bh(&iucv_table_lock);
932 rc = iucv_sever_pathid(path->pathid, userdata);
933 iucv_path_table[path->pathid] = NULL;
934 list_del_init(&path->list);
935 if (iucv_active_cpu != smp_processor_id())
936 spin_unlock_bh(&iucv_table_lock);
940 EXPORT_SYMBOL(iucv_path_sever);
944 * @path: address of iucv path structure
945 * @msg: address of iucv msg structure
946 * @srccls: source class of message
948 * Cancels a message you have sent.
950 * Returns the result from the CP IUCV call.
952 int iucv_message_purge(struct iucv_path *path, struct iucv_message *msg,
955 union iucv_param *parm;
959 parm = iucv_param[smp_processor_id()];
960 memset(parm, 0, sizeof(union iucv_param));
961 parm->purge.ippathid = path->pathid;
962 parm->purge.ipmsgid = msg->id;
963 parm->purge.ipsrccls = srccls;
964 parm->purge.ipflags1 = IUCV_IPSRCCLS | IUCV_IPFGMID | IUCV_IPFGPID;
965 rc = iucv_call_b2f0(IUCV_PURGE, parm);
967 msg->audit = (*(u32 *) &parm->purge.ipaudit) >> 8;
968 msg->tag = parm->purge.ipmsgtag;
973 EXPORT_SYMBOL(iucv_message_purge);
976 * iucv_message_receive_iprmdata
977 * @path: address of iucv path structure
978 * @msg: address of iucv msg structure
979 * @flags: how the message is received (IUCV_IPBUFLST)
980 * @buffer: address of data buffer or address of struct iucv_array
981 * @size: length of data buffer
984 * Internal function used by iucv_message_receive and __iucv_message_receive
985 * to receive RMDATA data stored in struct iucv_message.
987 static int iucv_message_receive_iprmdata(struct iucv_path *path,
988 struct iucv_message *msg,
989 u8 flags, void *buffer,
990 size_t size, size_t *residual)
992 struct iucv_array *array;
997 * Message is 8 bytes long and has been stored to the
998 * message descriptor itself.
1001 *residual = abs(size - 8);
1003 if (flags & IUCV_IPBUFLST) {
1004 /* Copy to struct iucv_array. */
1005 size = (size < 8) ? size : 8;
1006 for (array = buffer; size > 0; array++) {
1007 copy = min_t(size_t, size, array->length);
1008 memcpy((u8 *)(addr_t) array->address,
1014 /* Copy to direct buffer. */
1015 memcpy(buffer, rmmsg, min_t(size_t, size, 8));
1021 * __iucv_message_receive
1022 * @path: address of iucv path structure
1023 * @msg: address of iucv msg structure
1024 * @flags: how the message is received (IUCV_IPBUFLST)
1025 * @buffer: address of data buffer or address of struct iucv_array
1026 * @size: length of data buffer
1029 * This function receives messages that are being sent to you over
1030 * established paths. This function will deal with RMDATA messages
1031 * embedded in struct iucv_message as well.
1033 * Locking: no locking
1035 * Returns the result from the CP IUCV call.
1037 int __iucv_message_receive(struct iucv_path *path, struct iucv_message *msg,
1038 u8 flags, void *buffer, size_t size, size_t *residual)
1040 union iucv_param *parm;
1043 if (msg->flags & IUCV_IPRMDATA)
1044 return iucv_message_receive_iprmdata(path, msg, flags,
1045 buffer, size, residual);
1046 parm = iucv_param[smp_processor_id()];
1047 memset(parm, 0, sizeof(union iucv_param));
1048 parm->db.ipbfadr1 = (u32)(addr_t) buffer;
1049 parm->db.ipbfln1f = (u32) size;
1050 parm->db.ipmsgid = msg->id;
1051 parm->db.ippathid = path->pathid;
1052 parm->db.iptrgcls = msg->class;
1053 parm->db.ipflags1 = (flags | IUCV_IPFGPID |
1054 IUCV_IPFGMID | IUCV_IPTRGCLS);
1055 rc = iucv_call_b2f0(IUCV_RECEIVE, parm);
1056 if (!rc || rc == 5) {
1057 msg->flags = parm->db.ipflags1;
1059 *residual = parm->db.ipbfln1f;
1063 EXPORT_SYMBOL(__iucv_message_receive);
1066 * iucv_message_receive
1067 * @path: address of iucv path structure
1068 * @msg: address of iucv msg structure
1069 * @flags: how the message is received (IUCV_IPBUFLST)
1070 * @buffer: address of data buffer or address of struct iucv_array
1071 * @size: length of data buffer
1074 * This function receives messages that are being sent to you over
1075 * established paths. This function will deal with RMDATA messages
1076 * embedded in struct iucv_message as well.
1078 * Locking: local_bh_enable/local_bh_disable
1080 * Returns the result from the CP IUCV call.
1082 int iucv_message_receive(struct iucv_path *path, struct iucv_message *msg,
1083 u8 flags, void *buffer, size_t size, size_t *residual)
1087 if (msg->flags & IUCV_IPRMDATA)
1088 return iucv_message_receive_iprmdata(path, msg, flags,
1089 buffer, size, residual);
1091 rc = __iucv_message_receive(path, msg, flags, buffer, size, residual);
1095 EXPORT_SYMBOL(iucv_message_receive);
1098 * iucv_message_reject
1099 * @path: address of iucv path structure
1100 * @msg: address of iucv msg structure
1102 * The reject function refuses a specified message. Between the time you
1103 * are notified of a message and the time that you complete the message,
1104 * the message may be rejected.
1106 * Returns the result from the CP IUCV call.
1108 int iucv_message_reject(struct iucv_path *path, struct iucv_message *msg)
1110 union iucv_param *parm;
1114 parm = iucv_param[smp_processor_id()];
1115 memset(parm, 0, sizeof(union iucv_param));
1116 parm->db.ippathid = path->pathid;
1117 parm->db.ipmsgid = msg->id;
1118 parm->db.iptrgcls = msg->class;
1119 parm->db.ipflags1 = (IUCV_IPTRGCLS | IUCV_IPFGMID | IUCV_IPFGPID);
1120 rc = iucv_call_b2f0(IUCV_REJECT, parm);
1124 EXPORT_SYMBOL(iucv_message_reject);
1127 * iucv_message_reply
1128 * @path: address of iucv path structure
1129 * @msg: address of iucv msg structure
1130 * @flags: how the reply is sent (IUCV_IPRMDATA, IUCV_IPPRTY, IUCV_IPBUFLST)
1131 * @reply: address of reply data buffer or address of struct iucv_array
1132 * @size: length of reply data buffer
1134 * This function responds to the two-way messages that you receive. You
1135 * must identify completely the message to which you wish to reply. ie,
1136 * pathid, msgid, and trgcls. Prmmsg signifies the data is moved into
1137 * the parameter list.
1139 * Returns the result from the CP IUCV call.
1141 int iucv_message_reply(struct iucv_path *path, struct iucv_message *msg,
1142 u8 flags, void *reply, size_t size)
1144 union iucv_param *parm;
1148 parm = iucv_param[smp_processor_id()];
1149 memset(parm, 0, sizeof(union iucv_param));
1150 if (flags & IUCV_IPRMDATA) {
1151 parm->dpl.ippathid = path->pathid;
1152 parm->dpl.ipflags1 = flags;
1153 parm->dpl.ipmsgid = msg->id;
1154 parm->dpl.iptrgcls = msg->class;
1155 memcpy(parm->dpl.iprmmsg, reply, min_t(size_t, size, 8));
1157 parm->db.ipbfadr1 = (u32)(addr_t) reply;
1158 parm->db.ipbfln1f = (u32) size;
1159 parm->db.ippathid = path->pathid;
1160 parm->db.ipflags1 = flags;
1161 parm->db.ipmsgid = msg->id;
1162 parm->db.iptrgcls = msg->class;
1164 rc = iucv_call_b2f0(IUCV_REPLY, parm);
1168 EXPORT_SYMBOL(iucv_message_reply);
1171 * __iucv_message_send
1172 * @path: address of iucv path structure
1173 * @msg: address of iucv msg structure
1174 * @flags: how the message is sent (IUCV_IPRMDATA, IUCV_IPPRTY, IUCV_IPBUFLST)
1175 * @srccls: source class of message
1176 * @buffer: address of send buffer or address of struct iucv_array
1177 * @size: length of send buffer
1179 * This function transmits data to another application. Data to be
1180 * transmitted is in a buffer and this is a one-way message and the
1181 * receiver will not reply to the message.
1183 * Locking: no locking
1185 * Returns the result from the CP IUCV call.
1187 int __iucv_message_send(struct iucv_path *path, struct iucv_message *msg,
1188 u8 flags, u32 srccls, void *buffer, size_t size)
1190 union iucv_param *parm;
1193 parm = iucv_param[smp_processor_id()];
1194 memset(parm, 0, sizeof(union iucv_param));
1195 if (flags & IUCV_IPRMDATA) {
1196 /* Message of 8 bytes can be placed into the parameter list. */
1197 parm->dpl.ippathid = path->pathid;
1198 parm->dpl.ipflags1 = flags | IUCV_IPNORPY;
1199 parm->dpl.iptrgcls = msg->class;
1200 parm->dpl.ipsrccls = srccls;
1201 parm->dpl.ipmsgtag = msg->tag;
1202 memcpy(parm->dpl.iprmmsg, buffer, 8);
1204 parm->db.ipbfadr1 = (u32)(addr_t) buffer;
1205 parm->db.ipbfln1f = (u32) size;
1206 parm->db.ippathid = path->pathid;
1207 parm->db.ipflags1 = flags | IUCV_IPNORPY;
1208 parm->db.iptrgcls = msg->class;
1209 parm->db.ipsrccls = srccls;
1210 parm->db.ipmsgtag = msg->tag;
1212 rc = iucv_call_b2f0(IUCV_SEND, parm);
1214 msg->id = parm->db.ipmsgid;
1217 EXPORT_SYMBOL(__iucv_message_send);
1221 * @path: address of iucv path structure
1222 * @msg: address of iucv msg structure
1223 * @flags: how the message is sent (IUCV_IPRMDATA, IUCV_IPPRTY, IUCV_IPBUFLST)
1224 * @srccls: source class of message
1225 * @buffer: address of send buffer or address of struct iucv_array
1226 * @size: length of send buffer
1228 * This function transmits data to another application. Data to be
1229 * transmitted is in a buffer and this is a one-way message and the
1230 * receiver will not reply to the message.
1232 * Locking: local_bh_enable/local_bh_disable
1234 * Returns the result from the CP IUCV call.
1236 int iucv_message_send(struct iucv_path *path, struct iucv_message *msg,
1237 u8 flags, u32 srccls, void *buffer, size_t size)
1242 rc = __iucv_message_send(path, msg, flags, srccls, buffer, size);
1246 EXPORT_SYMBOL(iucv_message_send);
1249 * iucv_message_send2way
1250 * @path: address of iucv path structure
1251 * @msg: address of iucv msg structure
1252 * @flags: how the message is sent and the reply is received
1253 * (IUCV_IPRMDATA, IUCV_IPBUFLST, IUCV_IPPRTY, IUCV_ANSLST)
1254 * @srccls: source class of message
1255 * @buffer: address of send buffer or address of struct iucv_array
1256 * @size: length of send buffer
1257 * @ansbuf: address of answer buffer or address of struct iucv_array
1258 * @asize: size of reply buffer
1260 * This function transmits data to another application. Data to be
1261 * transmitted is in a buffer. The receiver of the send is expected to
1262 * reply to the message and a buffer is provided into which IUCV moves
1263 * the reply to this message.
1265 * Returns the result from the CP IUCV call.
1267 int iucv_message_send2way(struct iucv_path *path, struct iucv_message *msg,
1268 u8 flags, u32 srccls, void *buffer, size_t size,
1269 void *answer, size_t asize, size_t *residual)
1271 union iucv_param *parm;
1275 parm = iucv_param[smp_processor_id()];
1276 memset(parm, 0, sizeof(union iucv_param));
1277 if (flags & IUCV_IPRMDATA) {
1278 parm->dpl.ippathid = path->pathid;
1279 parm->dpl.ipflags1 = path->flags; /* priority message */
1280 parm->dpl.iptrgcls = msg->class;
1281 parm->dpl.ipsrccls = srccls;
1282 parm->dpl.ipmsgtag = msg->tag;
1283 parm->dpl.ipbfadr2 = (u32)(addr_t) answer;
1284 parm->dpl.ipbfln2f = (u32) asize;
1285 memcpy(parm->dpl.iprmmsg, buffer, 8);
1287 parm->db.ippathid = path->pathid;
1288 parm->db.ipflags1 = path->flags; /* priority message */
1289 parm->db.iptrgcls = msg->class;
1290 parm->db.ipsrccls = srccls;
1291 parm->db.ipmsgtag = msg->tag;
1292 parm->db.ipbfadr1 = (u32)(addr_t) buffer;
1293 parm->db.ipbfln1f = (u32) size;
1294 parm->db.ipbfadr2 = (u32)(addr_t) answer;
1295 parm->db.ipbfln2f = (u32) asize;
1297 rc = iucv_call_b2f0(IUCV_SEND, parm);
1299 msg->id = parm->db.ipmsgid;
1303 EXPORT_SYMBOL(iucv_message_send2way);
1307 * @data: Pointer to external interrupt buffer
1309 * Process connection pending work item. Called from tasklet while holding
1312 struct iucv_path_pending {
1323 } __attribute__ ((packed));
1325 static void iucv_path_pending(struct iucv_irq_data *data)
1327 struct iucv_path_pending *ipp = (void *) data;
1328 struct iucv_handler *handler;
1329 struct iucv_path *path;
1332 BUG_ON(iucv_path_table[ipp->ippathid]);
1333 /* New pathid, handler found. Create a new path struct. */
1334 error = iucv_error_no_memory;
1335 path = iucv_path_alloc(ipp->ipmsglim, ipp->ipflags1, GFP_ATOMIC);
1338 path->pathid = ipp->ippathid;
1339 iucv_path_table[path->pathid] = path;
1340 EBCASC(ipp->ipvmid, 8);
1342 /* Call registered handler until one is found that wants the path. */
1343 list_for_each_entry(handler, &iucv_handler_list, list) {
1344 if (!handler->path_pending)
1347 * Add path to handler to allow a call to iucv_path_sever
1348 * inside the path_pending function. If the handler returns
1349 * an error remove the path from the handler again.
1351 list_add(&path->list, &handler->paths);
1352 path->handler = handler;
1353 if (!handler->path_pending(path, ipp->ipvmid, ipp->ipuser))
1355 list_del(&path->list);
1356 path->handler = NULL;
1358 /* No handler wanted the path. */
1359 iucv_path_table[path->pathid] = NULL;
1360 iucv_path_free(path);
1361 error = iucv_error_no_listener;
1363 iucv_sever_pathid(ipp->ippathid, error);
1367 * iucv_path_complete
1368 * @data: Pointer to external interrupt buffer
1370 * Process connection complete work item. Called from tasklet while holding
1373 struct iucv_path_complete {
1384 } __attribute__ ((packed));
1386 static void iucv_path_complete(struct iucv_irq_data *data)
1388 struct iucv_path_complete *ipc = (void *) data;
1389 struct iucv_path *path = iucv_path_table[ipc->ippathid];
1392 path->flags = ipc->ipflags1;
1393 if (path && path->handler && path->handler->path_complete)
1394 path->handler->path_complete(path, ipc->ipuser);
1399 * @data: Pointer to external interrupt buffer
1401 * Process connection severed work item. Called from tasklet while holding
1404 struct iucv_path_severed {
1414 } __attribute__ ((packed));
1416 static void iucv_path_severed(struct iucv_irq_data *data)
1418 struct iucv_path_severed *ips = (void *) data;
1419 struct iucv_path *path = iucv_path_table[ips->ippathid];
1421 if (!path || !path->handler) /* Already severed */
1423 if (path->handler->path_severed)
1424 path->handler->path_severed(path, ips->ipuser);
1426 iucv_sever_pathid(path->pathid, NULL);
1427 iucv_path_table[path->pathid] = NULL;
1428 list_del(&path->list);
1429 iucv_path_free(path);
1434 * iucv_path_quiesced
1435 * @data: Pointer to external interrupt buffer
1437 * Process connection quiesced work item. Called from tasklet while holding
1440 struct iucv_path_quiesced {
1450 } __attribute__ ((packed));
1452 static void iucv_path_quiesced(struct iucv_irq_data *data)
1454 struct iucv_path_quiesced *ipq = (void *) data;
1455 struct iucv_path *path = iucv_path_table[ipq->ippathid];
1457 if (path && path->handler && path->handler->path_quiesced)
1458 path->handler->path_quiesced(path, ipq->ipuser);
1463 * @data: Pointer to external interrupt buffer
1465 * Process connection resumed work item. Called from tasklet while holding
1468 struct iucv_path_resumed {
1478 } __attribute__ ((packed));
1480 static void iucv_path_resumed(struct iucv_irq_data *data)
1482 struct iucv_path_resumed *ipr = (void *) data;
1483 struct iucv_path *path = iucv_path_table[ipr->ippathid];
1485 if (path && path->handler && path->handler->path_resumed)
1486 path->handler->path_resumed(path, ipr->ipuser);
1490 * iucv_message_complete
1491 * @data: Pointer to external interrupt buffer
1493 * Process message complete work item. Called from tasklet while holding
1496 struct iucv_message_complete {
1509 } __attribute__ ((packed));
1511 static void iucv_message_complete(struct iucv_irq_data *data)
1513 struct iucv_message_complete *imc = (void *) data;
1514 struct iucv_path *path = iucv_path_table[imc->ippathid];
1515 struct iucv_message msg;
1517 if (path && path->handler && path->handler->message_complete) {
1518 msg.flags = imc->ipflags1;
1519 msg.id = imc->ipmsgid;
1520 msg.audit = imc->ipaudit;
1521 memcpy(msg.rmmsg, imc->iprmmsg, 8);
1522 msg.class = imc->ipsrccls;
1523 msg.tag = imc->ipmsgtag;
1524 msg.length = imc->ipbfln2f;
1525 path->handler->message_complete(path, &msg);
1530 * iucv_message_pending
1531 * @data: Pointer to external interrupt buffer
1533 * Process message pending work item. Called from tasklet while holding
1536 struct iucv_message_pending {
1554 } __attribute__ ((packed));
1556 static void iucv_message_pending(struct iucv_irq_data *data)
1558 struct iucv_message_pending *imp = (void *) data;
1559 struct iucv_path *path = iucv_path_table[imp->ippathid];
1560 struct iucv_message msg;
1562 if (path && path->handler && path->handler->message_pending) {
1563 msg.flags = imp->ipflags1;
1564 msg.id = imp->ipmsgid;
1565 msg.class = imp->iptrgcls;
1566 if (imp->ipflags1 & IUCV_IPRMDATA) {
1567 memcpy(msg.rmmsg, imp->ln1msg1.iprmmsg1, 8);
1570 msg.length = imp->ln1msg2.ipbfln1f;
1571 msg.reply_size = imp->ipbfln2f;
1572 path->handler->message_pending(path, &msg);
1579 * This tasklet loops over the queue of irq buffers created by
1580 * iucv_external_interrupt, calls the appropriate action handler
1581 * and then frees the buffer.
1583 static void iucv_tasklet_fn(unsigned long ignored)
1585 typedef void iucv_irq_fn(struct iucv_irq_data *);
1586 static iucv_irq_fn *irq_fn[] = {
1587 [0x02] = iucv_path_complete,
1588 [0x03] = iucv_path_severed,
1589 [0x04] = iucv_path_quiesced,
1590 [0x05] = iucv_path_resumed,
1591 [0x06] = iucv_message_complete,
1592 [0x07] = iucv_message_complete,
1593 [0x08] = iucv_message_pending,
1594 [0x09] = iucv_message_pending,
1596 LIST_HEAD(task_queue);
1597 struct iucv_irq_list *p, *n;
1599 /* Serialize tasklet, iucv_path_sever and iucv_path_connect. */
1600 if (!spin_trylock(&iucv_table_lock)) {
1601 tasklet_schedule(&iucv_tasklet);
1604 iucv_active_cpu = smp_processor_id();
1606 spin_lock_irq(&iucv_queue_lock);
1607 list_splice_init(&iucv_task_queue, &task_queue);
1608 spin_unlock_irq(&iucv_queue_lock);
1610 list_for_each_entry_safe(p, n, &task_queue, list) {
1611 list_del_init(&p->list);
1612 irq_fn[p->data.iptype](&p->data);
1616 iucv_active_cpu = -1;
1617 spin_unlock(&iucv_table_lock);
1623 * This work function loops over the queue of path pending irq blocks
1624 * created by iucv_external_interrupt, calls the appropriate action
1625 * handler and then frees the buffer.
1627 static void iucv_work_fn(struct work_struct *work)
1629 typedef void iucv_irq_fn(struct iucv_irq_data *);
1630 LIST_HEAD(work_queue);
1631 struct iucv_irq_list *p, *n;
1633 /* Serialize tasklet, iucv_path_sever and iucv_path_connect. */
1634 spin_lock_bh(&iucv_table_lock);
1635 iucv_active_cpu = smp_processor_id();
1637 spin_lock_irq(&iucv_queue_lock);
1638 list_splice_init(&iucv_work_queue, &work_queue);
1639 spin_unlock_irq(&iucv_queue_lock);
1641 iucv_cleanup_queue();
1642 list_for_each_entry_safe(p, n, &work_queue, list) {
1643 list_del_init(&p->list);
1644 iucv_path_pending(&p->data);
1648 iucv_active_cpu = -1;
1649 spin_unlock_bh(&iucv_table_lock);
1653 * iucv_external_interrupt
1656 * Handles external interrupts coming in from CP.
1657 * Places the interrupt buffer on a queue and schedules iucv_tasklet_fn().
1659 static void iucv_external_interrupt(u16 code)
1661 struct iucv_irq_data *p;
1662 struct iucv_irq_list *work;
1664 p = iucv_irq_data[smp_processor_id()];
1665 if (p->ippathid >= iucv_max_pathid) {
1666 WARN_ON(p->ippathid >= iucv_max_pathid);
1667 iucv_sever_pathid(p->ippathid, iucv_error_no_listener);
1670 BUG_ON(p->iptype < 0x01 || p->iptype > 0x09);
1671 work = kmalloc(sizeof(struct iucv_irq_list), GFP_ATOMIC);
1673 pr_warning("iucv_external_interrupt: out of memory\n");
1676 memcpy(&work->data, p, sizeof(work->data));
1677 spin_lock(&iucv_queue_lock);
1678 if (p->iptype == 0x01) {
1679 /* Path pending interrupt. */
1680 list_add_tail(&work->list, &iucv_work_queue);
1681 schedule_work(&iucv_work);
1683 /* The other interrupts. */
1684 list_add_tail(&work->list, &iucv_task_queue);
1685 tasklet_schedule(&iucv_tasklet);
1687 spin_unlock(&iucv_queue_lock);
1693 * Allocates and initializes various data structures.
1695 static int __init iucv_init(void)
1700 if (!MACHINE_IS_VM) {
1701 rc = -EPROTONOSUPPORT;
1704 rc = iucv_query_maxconn();
1707 rc = register_external_interrupt(0x4000, iucv_external_interrupt);
1710 iucv_root = root_device_register("iucv");
1711 if (IS_ERR(iucv_root)) {
1712 rc = PTR_ERR(iucv_root);
1716 for_each_online_cpu(cpu) {
1717 /* Note: GFP_DMA used to get memory below 2G */
1718 iucv_irq_data[cpu] = kmalloc_node(sizeof(struct iucv_irq_data),
1719 GFP_KERNEL|GFP_DMA, cpu_to_node(cpu));
1720 if (!iucv_irq_data[cpu]) {
1725 /* Allocate parameter blocks. */
1726 iucv_param[cpu] = kmalloc_node(sizeof(union iucv_param),
1727 GFP_KERNEL|GFP_DMA, cpu_to_node(cpu));
1728 if (!iucv_param[cpu]) {
1732 iucv_param_irq[cpu] = kmalloc_node(sizeof(union iucv_param),
1733 GFP_KERNEL|GFP_DMA, cpu_to_node(cpu));
1734 if (!iucv_param_irq[cpu]) {
1740 rc = register_hotcpu_notifier(&iucv_cpu_notifier);
1743 ASCEBC(iucv_error_no_listener, 16);
1744 ASCEBC(iucv_error_no_memory, 16);
1745 ASCEBC(iucv_error_pathid, 16);
1747 rc = bus_register(&iucv_bus);
1753 unregister_hotcpu_notifier(&iucv_cpu_notifier);
1755 for_each_possible_cpu(cpu) {
1756 kfree(iucv_param_irq[cpu]);
1757 iucv_param_irq[cpu] = NULL;
1758 kfree(iucv_param[cpu]);
1759 iucv_param[cpu] = NULL;
1760 kfree(iucv_irq_data[cpu]);
1761 iucv_irq_data[cpu] = NULL;
1763 root_device_unregister(iucv_root);
1765 unregister_external_interrupt(0x4000, iucv_external_interrupt);
1773 * Frees everything allocated from iucv_init.
1775 static void __exit iucv_exit(void)
1777 struct iucv_irq_list *p, *n;
1780 spin_lock_irq(&iucv_queue_lock);
1781 list_for_each_entry_safe(p, n, &iucv_task_queue, list)
1783 list_for_each_entry_safe(p, n, &iucv_work_queue, list)
1785 spin_unlock_irq(&iucv_queue_lock);
1786 unregister_hotcpu_notifier(&iucv_cpu_notifier);
1787 for_each_possible_cpu(cpu) {
1788 kfree(iucv_param_irq[cpu]);
1789 iucv_param_irq[cpu] = NULL;
1790 kfree(iucv_param[cpu]);
1791 iucv_param[cpu] = NULL;
1792 kfree(iucv_irq_data[cpu]);
1793 iucv_irq_data[cpu] = NULL;
1795 root_device_unregister(iucv_root);
1796 bus_unregister(&iucv_bus);
1797 unregister_external_interrupt(0x4000, iucv_external_interrupt);
1800 subsys_initcall(iucv_init);
1801 module_exit(iucv_exit);
1803 MODULE_AUTHOR("(C) 2001 IBM Corp. by Fritz Elfert (felfert@millenux.com)");
1804 MODULE_DESCRIPTION("Linux for S/390 IUCV lowlevel driver");
1805 MODULE_LICENSE("GPL");