xref: /linux/net/iucv/iucv.c (revision c4dde411bc366f568dbe33366253bbfea049e8ea)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * IUCV base infrastructure.
4  *
5  * Copyright IBM Corp. 2001, 2009
6  *
7  * Author(s):
8  *    Original source:
9  *	Alan Altmark (Alan_Altmark@us.ibm.com)	Sept. 2000
10  *	Xenia Tkatschow (xenia@us.ibm.com)
11  *    2Gb awareness and general cleanup:
12  *	Fritz Elfert (elfert@de.ibm.com, felfert@millenux.com)
13  *    Rewritten for af_iucv:
14  *	Martin Schwidefsky <schwidefsky@de.ibm.com>
15  *    PM functions:
16  *	Ursula Braun (ursula.braun@de.ibm.com)
17  *
18  * Documentation used:
19  *    The original source
20  *    CP Programming Service, IBM document # SC24-5760
21  */
22 
23 #define pr_fmt(fmt) "iucv: " fmt
24 
25 #include <linux/kernel_stat.h>
26 #include <linux/export.h>
27 #include <linux/module.h>
28 #include <linux/moduleparam.h>
29 #include <linux/spinlock.h>
30 #include <linux/kernel.h>
31 #include <linux/slab.h>
32 #include <linux/init.h>
33 #include <linux/interrupt.h>
34 #include <linux/list.h>
35 #include <linux/errno.h>
36 #include <linux/err.h>
37 #include <linux/device.h>
38 #include <linux/cpu.h>
39 #include <linux/reboot.h>
40 #include <net/iucv/iucv.h>
41 #include <linux/atomic.h>
42 #include <asm/machine.h>
43 #include <asm/ebcdic.h>
44 #include <asm/io.h>
45 #include <asm/irq.h>
46 #include <asm/smp.h>
47 
48 /*
49  * FLAGS:
50  * All flags are defined in the field IPFLAGS1 of each function
51  * and can be found in CP Programming Services.
52  * IPSRCCLS - Indicates you have specified a source class.
53  * IPTRGCLS - Indicates you have specified a target class.
54  * IPFGPID  - Indicates you have specified a pathid.
55  * IPFGMID  - Indicates you have specified a message ID.
56  * IPNORPY  - Indicates a one-way message. No reply expected.
57  * IPALL    - Indicates that all paths are affected.
58  */
59 #define IUCV_IPSRCCLS	0x01
60 #define IUCV_IPTRGCLS	0x01
61 #define IUCV_IPFGPID	0x02
62 #define IUCV_IPFGMID	0x04
63 #define IUCV_IPNORPY	0x10
64 #define IUCV_IPALL	0x80
65 
66 static int iucv_bus_match(struct device *dev, const struct device_driver *drv)
67 {
68 	return 0;
69 }
70 
71 const struct bus_type iucv_bus = {
72 	.name = "iucv",
73 	.match = iucv_bus_match,
74 };
75 EXPORT_SYMBOL(iucv_bus);
76 
77 static struct device *iucv_root;
78 
79 static void iucv_release_device(struct device *device)
80 {
81 	kfree(device);
82 }
83 
84 struct device *iucv_alloc_device(const struct attribute_group **attrs,
85 				 struct device_driver *driver,
86 				 void *priv, const char *fmt, ...)
87 {
88 	struct device *dev;
89 	va_list vargs;
90 	char buf[20];
91 	int rc;
92 
93 	dev = kzalloc_obj(*dev);
94 	if (!dev)
95 		goto out_error;
96 	va_start(vargs, fmt);
97 	vscnprintf(buf, sizeof(buf), fmt, vargs);
98 	rc = dev_set_name(dev, "%s", buf);
99 	va_end(vargs);
100 	if (rc)
101 		goto out_error;
102 	dev->bus = &iucv_bus;
103 	dev->parent = iucv_root;
104 	dev->driver = driver;
105 	dev->groups = attrs;
106 	dev->release = iucv_release_device;
107 	dev_set_drvdata(dev, priv);
108 	return dev;
109 
110 out_error:
111 	kfree(dev);
112 	return NULL;
113 }
114 EXPORT_SYMBOL(iucv_alloc_device);
115 
116 static int iucv_available;
117 
118 /* General IUCV interrupt structure */
119 struct iucv_irq_data {
120 	u16 ippathid;
121 	u8  ipflags1;
122 	u8  iptype;
123 	u32 res2[9];
124 };
125 
126 struct iucv_irq_list {
127 	struct list_head list;
128 	struct iucv_irq_data data;
129 };
130 
131 static struct iucv_irq_data *iucv_irq_data[NR_CPUS];
132 static cpumask_t iucv_buffer_cpumask = { CPU_BITS_NONE };
133 static cpumask_t iucv_irq_cpumask = { CPU_BITS_NONE };
134 
135 /*
136  * Queue of interrupt buffers lock for delivery via the tasklet
137  * (fast but can't call smp_call_function).
138  */
139 static LIST_HEAD(iucv_task_queue);
140 
141 /*
142  * The tasklet for fast delivery of iucv interrupts.
143  */
144 static void iucv_tasklet_fn(unsigned long);
145 static DECLARE_TASKLET_OLD(iucv_tasklet, iucv_tasklet_fn);
146 
147 /*
148  * Queue of interrupt buffers for delivery via a work queue
149  * (slower but can call smp_call_function).
150  */
151 static LIST_HEAD(iucv_work_queue);
152 
153 /*
154  * The work element to deliver path pending interrupts.
155  */
156 static void iucv_work_fn(struct work_struct *work);
157 static DECLARE_WORK(iucv_work, iucv_work_fn);
158 
159 /*
160  * Spinlock protecting task and work queue.
161  */
162 static DEFINE_SPINLOCK(iucv_queue_lock);
163 
164 enum iucv_command_codes {
165 	IUCV_QUERY = 0,
166 	IUCV_RETRIEVE_BUFFER = 2,
167 	IUCV_SEND = 4,
168 	IUCV_RECEIVE = 5,
169 	IUCV_REPLY = 6,
170 	IUCV_REJECT = 8,
171 	IUCV_PURGE = 9,
172 	IUCV_ACCEPT = 10,
173 	IUCV_CONNECT = 11,
174 	IUCV_DECLARE_BUFFER = 12,
175 	IUCV_QUIESCE = 13,
176 	IUCV_RESUME = 14,
177 	IUCV_SEVER = 15,
178 	IUCV_SETMASK = 16,
179 	IUCV_SETCONTROLMASK = 17,
180 };
181 
182 /*
183  * Error messages that are used with the iucv_sever function. They get
184  * converted to EBCDIC.
185  */
186 static char iucv_error_no_listener[16] = "NO LISTENER";
187 static char iucv_error_no_memory[16] = "NO MEMORY";
188 static char iucv_error_pathid[16] = "INVALID PATHID";
189 
190 /*
191  * iucv_handler_list: List of registered handlers.
192  */
193 static LIST_HEAD(iucv_handler_list);
194 
195 /*
196  * iucv_path_table: array of pointers to iucv_path structures.
197  */
198 static struct iucv_path **iucv_path_table;
199 static unsigned long iucv_max_pathid;
200 
201 /*
202  * iucv_lock: spinlock protecting iucv_handler_list and iucv_pathid_table
203  */
204 static DEFINE_SPINLOCK(iucv_table_lock);
205 
206 /*
207  * iucv_active_cpu: contains the number of the cpu executing the tasklet
208  * or the work handler. Needed for iucv_path_sever called from tasklet.
209  */
210 static int iucv_active_cpu = -1;
211 
212 /*
213  * Mutex and wait queue for iucv_register/iucv_unregister.
214  */
215 static DEFINE_MUTEX(iucv_register_mutex);
216 
217 /*
218  * Counter for number of non-smp capable handlers.
219  */
220 static int iucv_nonsmp_handler;
221 
222 /*
223  * IUCV control data structure. Used by iucv_path_accept, iucv_path_connect,
224  * iucv_path_quiesce and iucv_path_sever.
225  */
226 struct iucv_cmd_control {
227 	u16 ippathid;
228 	u8  ipflags1;
229 	u8  iprcode;
230 	u16 ipmsglim;
231 	u16 res1;
232 	u8  ipvmid[8];
233 	u8  ipuser[16];
234 	u8  iptarget[8];
235 } __attribute__ ((packed,aligned(8)));
236 
237 /*
238  * Data in parameter list iucv structure. Used by iucv_message_send,
239  * iucv_message_send2way and iucv_message_reply.
240  */
241 struct iucv_cmd_dpl {
242 	u16 ippathid;
243 	u8  ipflags1;
244 	u8  iprcode;
245 	u32 ipmsgid;
246 	u32 iptrgcls;
247 	u8  iprmmsg[8];
248 	u32 ipsrccls;
249 	u32 ipmsgtag;
250 	dma32_t ipbfadr2;
251 	u32 ipbfln2f;
252 	u32 res;
253 } __attribute__ ((packed,aligned(8)));
254 
255 /*
256  * Data in buffer iucv structure. Used by iucv_message_receive,
257  * iucv_message_reject, iucv_message_send, iucv_message_send2way
258  * and iucv_declare_cpu.
259  */
260 struct iucv_cmd_db {
261 	u16 ippathid;
262 	u8  ipflags1;
263 	u8  iprcode;
264 	u32 ipmsgid;
265 	u32 iptrgcls;
266 	dma32_t ipbfadr1;
267 	u32 ipbfln1f;
268 	u32 ipsrccls;
269 	u32 ipmsgtag;
270 	dma32_t ipbfadr2;
271 	u32 ipbfln2f;
272 	u32 res;
273 } __attribute__ ((packed,aligned(8)));
274 
275 /*
276  * Purge message iucv structure. Used by iucv_message_purge.
277  */
278 struct iucv_cmd_purge {
279 	u16 ippathid;
280 	u8  ipflags1;
281 	u8  iprcode;
282 	u32 ipmsgid;
283 	u8  ipaudit[3];
284 	u8  res1[5];
285 	u32 res2;
286 	u32 ipsrccls;
287 	u32 ipmsgtag;
288 	u32 res3[3];
289 } __attribute__ ((packed,aligned(8)));
290 
291 /*
292  * Set mask iucv structure. Used by iucv_enable_cpu.
293  */
294 struct iucv_cmd_set_mask {
295 	u8  ipmask;
296 	u8  res1[2];
297 	u8  iprcode;
298 	u32 res2[9];
299 } __attribute__ ((packed,aligned(8)));
300 
301 union iucv_param {
302 	struct iucv_cmd_control ctrl;
303 	struct iucv_cmd_dpl dpl;
304 	struct iucv_cmd_db db;
305 	struct iucv_cmd_purge purge;
306 	struct iucv_cmd_set_mask set_mask;
307 };
308 
309 /*
310  * Anchor for per-cpu IUCV command parameter block.
311  */
312 static union iucv_param *iucv_param[NR_CPUS];
313 static union iucv_param *iucv_param_irq[NR_CPUS];
314 
315 /**
316  * __iucv_call_b2f0 - Calls CP to execute IUCV commands.
317  *
318  * @command: identifier of IUCV call to CP.
319  * @parm: pointer to a struct iucv_parm block
320  *
321  * Returns: the result of the CP IUCV call.
322  */
323 static inline int __iucv_call_b2f0(int command, union iucv_param *parm)
324 {
325 	unsigned long reg1 = virt_to_phys(parm);
326 	int cc;
327 
328 	asm volatile(
329 		"	lgr	0,%[reg0]\n"
330 		"	lgr	1,%[reg1]\n"
331 		"	.long	0xb2f01000\n"
332 		"	ipm	%[cc]\n"
333 		"	srl	%[cc],28\n"
334 		: [cc] "=&d" (cc), "+m" (*parm)
335 		: [reg0] "d" ((unsigned long)command),
336 		  [reg1] "d" (reg1)
337 		: "cc", "0", "1");
338 	return cc;
339 }
340 
341 static inline int iucv_call_b2f0(int command, union iucv_param *parm)
342 {
343 	int ccode;
344 
345 	ccode = __iucv_call_b2f0(command, parm);
346 	return ccode == 1 ? parm->ctrl.iprcode : ccode;
347 }
348 
349 /*
350  * iucv_query_maxconn - Determine the maximum number of connections that
351  * may be established.
352  *
353  * Returns: the maximum number of connections or -EPERM is IUCV is not
354  * available.
355  */
356 static int __iucv_query_maxconn(void *param, unsigned long *max_pathid)
357 {
358 	unsigned long reg1 = virt_to_phys(param);
359 	int cc;
360 
361 	asm volatile (
362 		"	lghi	0,%[cmd]\n"
363 		"	lgr	1,%[reg1]\n"
364 		"	.long	0xb2f01000\n"
365 		"	ipm	%[cc]\n"
366 		"	srl	%[cc],28\n"
367 		"	lgr	%[reg1],1\n"
368 		: [cc] "=&d" (cc), [reg1] "+&d" (reg1)
369 		: [cmd] "K" (IUCV_QUERY)
370 		: "cc", "0", "1");
371 	*max_pathid = reg1;
372 	return cc;
373 }
374 
375 static int iucv_query_maxconn(void)
376 {
377 	unsigned long max_pathid;
378 	void *param;
379 	int ccode;
380 
381 	param = kzalloc_obj(union iucv_param, GFP_KERNEL | GFP_DMA);
382 	if (!param)
383 		return -ENOMEM;
384 	ccode = __iucv_query_maxconn(param, &max_pathid);
385 	if (ccode == 0)
386 		iucv_max_pathid = max_pathid;
387 	kfree(param);
388 	return ccode ? -EPERM : 0;
389 }
390 
391 /**
392  * iucv_allow_cpu - Allow iucv interrupts on this cpu.
393  *
394  * @data: unused
395  */
396 static void iucv_allow_cpu(void *data)
397 {
398 	int cpu = smp_processor_id();
399 	union iucv_param *parm;
400 
401 	/*
402 	 * Enable all iucv interrupts.
403 	 * ipmask contains bits for the different interrupts
404 	 *	0x80 - Flag to allow nonpriority message pending interrupts
405 	 *	0x40 - Flag to allow priority message pending interrupts
406 	 *	0x20 - Flag to allow nonpriority message completion interrupts
407 	 *	0x10 - Flag to allow priority message completion interrupts
408 	 *	0x08 - Flag to allow IUCV control interrupts
409 	 */
410 	parm = iucv_param_irq[cpu];
411 	memset(parm, 0, sizeof(union iucv_param));
412 	parm->set_mask.ipmask = 0xf8;
413 	iucv_call_b2f0(IUCV_SETMASK, parm);
414 
415 	/*
416 	 * Enable all iucv control interrupts.
417 	 * ipmask contains bits for the different interrupts
418 	 *	0x80 - Flag to allow pending connections interrupts
419 	 *	0x40 - Flag to allow connection complete interrupts
420 	 *	0x20 - Flag to allow connection severed interrupts
421 	 *	0x10 - Flag to allow connection quiesced interrupts
422 	 *	0x08 - Flag to allow connection resumed interrupts
423 	 */
424 	memset(parm, 0, sizeof(union iucv_param));
425 	parm->set_mask.ipmask = 0xf8;
426 	iucv_call_b2f0(IUCV_SETCONTROLMASK, parm);
427 	/* Set indication that iucv interrupts are allowed for this cpu. */
428 	cpumask_set_cpu(cpu, &iucv_irq_cpumask);
429 }
430 
431 /**
432  * iucv_block_cpu - Block iucv interrupts on this cpu.
433  *
434  * @data: unused
435  */
436 static void iucv_block_cpu(void *data)
437 {
438 	int cpu = smp_processor_id();
439 	union iucv_param *parm;
440 
441 	/* Disable all iucv interrupts. */
442 	parm = iucv_param_irq[cpu];
443 	memset(parm, 0, sizeof(union iucv_param));
444 	iucv_call_b2f0(IUCV_SETMASK, parm);
445 
446 	/* Clear indication that iucv interrupts are allowed for this cpu. */
447 	cpumask_clear_cpu(cpu, &iucv_irq_cpumask);
448 }
449 
450 /**
451  * iucv_declare_cpu - Declare a interrupt buffer on this cpu.
452  *
453  * @data: unused
454  */
455 static void iucv_declare_cpu(void *data)
456 {
457 	int cpu = smp_processor_id();
458 	union iucv_param *parm;
459 	int rc;
460 
461 	if (cpumask_test_cpu(cpu, &iucv_buffer_cpumask))
462 		return;
463 
464 	/* Declare interrupt buffer. */
465 	parm = iucv_param_irq[cpu];
466 	memset(parm, 0, sizeof(union iucv_param));
467 	parm->db.ipbfadr1 = virt_to_dma32(iucv_irq_data[cpu]);
468 	rc = iucv_call_b2f0(IUCV_DECLARE_BUFFER, parm);
469 	if (rc) {
470 		char *err = "Unknown";
471 		switch (rc) {
472 		case 0x03:
473 			err = "Directory error";
474 			break;
475 		case 0x0a:
476 			err = "Invalid length";
477 			break;
478 		case 0x13:
479 			err = "Buffer already exists";
480 			break;
481 		case 0x3e:
482 			err = "Buffer overlap";
483 			break;
484 		case 0x5c:
485 			err = "Paging or storage error";
486 			break;
487 		}
488 		pr_warn("Defining an interrupt buffer on CPU %i failed with 0x%02x (%s)\n",
489 			cpu, rc, err);
490 		return;
491 	}
492 
493 	/* Set indication that an iucv buffer exists for this cpu. */
494 	cpumask_set_cpu(cpu, &iucv_buffer_cpumask);
495 
496 	if (iucv_nonsmp_handler == 0 || cpumask_empty(&iucv_irq_cpumask))
497 		/* Enable iucv interrupts on this cpu. */
498 		iucv_allow_cpu(NULL);
499 	else
500 		/* Disable iucv interrupts on this cpu. */
501 		iucv_block_cpu(NULL);
502 }
503 
504 /**
505  * iucv_retrieve_cpu - Retrieve interrupt buffer on this cpu.
506  *
507  * @data: unused
508  */
509 static void iucv_retrieve_cpu(void *data)
510 {
511 	int cpu = smp_processor_id();
512 	union iucv_param *parm;
513 
514 	if (!cpumask_test_cpu(cpu, &iucv_buffer_cpumask))
515 		return;
516 
517 	/* Block iucv interrupts. */
518 	iucv_block_cpu(NULL);
519 
520 	/* Retrieve interrupt buffer. */
521 	parm = iucv_param_irq[cpu];
522 	iucv_call_b2f0(IUCV_RETRIEVE_BUFFER, parm);
523 
524 	/* Clear indication that an iucv buffer exists for this cpu. */
525 	cpumask_clear_cpu(cpu, &iucv_buffer_cpumask);
526 }
527 
528 /*
529  * iucv_setmask_mp - Allow iucv interrupts on all cpus.
530  */
531 static void iucv_setmask_mp(void)
532 {
533 	int cpu;
534 
535 	cpus_read_lock();
536 	for_each_online_cpu(cpu)
537 		/* Enable all cpus with a declared buffer. */
538 		if (cpumask_test_cpu(cpu, &iucv_buffer_cpumask) &&
539 		    !cpumask_test_cpu(cpu, &iucv_irq_cpumask))
540 			smp_call_function_single(cpu, iucv_allow_cpu,
541 						 NULL, 1);
542 	cpus_read_unlock();
543 }
544 
545 /*
546  * iucv_setmask_up - Allow iucv interrupts on a single cpu.
547  */
548 static void iucv_setmask_up(void)
549 {
550 	static cpumask_t cpumask;
551 	int cpu;
552 
553 	/* Disable all cpu but the first in cpu_irq_cpumask. */
554 	cpumask_copy(&cpumask, &iucv_irq_cpumask);
555 	cpumask_clear_cpu(cpumask_first(&iucv_irq_cpumask), &cpumask);
556 	for_each_cpu(cpu, &cpumask)
557 		smp_call_function_single(cpu, iucv_block_cpu, NULL, 1);
558 }
559 
560 /*
561  * iucv_enable - Make the iucv ready for use
562  *
563  * It allocates the pathid table, declares an iucv interrupt buffer and
564  * enables the iucv interrupts. Called when the first user has registered
565  * an iucv handler.
566  */
567 static int iucv_enable(void)
568 {
569 	size_t alloc_size;
570 	int cpu, rc;
571 
572 	cpus_read_lock();
573 	rc = -ENOMEM;
574 	alloc_size = iucv_max_pathid * sizeof(*iucv_path_table);
575 	iucv_path_table = kzalloc(alloc_size, GFP_KERNEL);
576 	if (!iucv_path_table)
577 		goto out;
578 	/* Declare per cpu buffers. */
579 	rc = -EIO;
580 	for_each_online_cpu(cpu)
581 		smp_call_function_single(cpu, iucv_declare_cpu, NULL, 1);
582 	if (cpumask_empty(&iucv_buffer_cpumask))
583 		/* No cpu could declare an iucv buffer. */
584 		goto out;
585 	cpus_read_unlock();
586 	return 0;
587 out:
588 	kfree(iucv_path_table);
589 	iucv_path_table = NULL;
590 	cpus_read_unlock();
591 	return rc;
592 }
593 
594 /*
595  * iucv_disable - Shuts down iucv.
596  *
597  * It disables iucv interrupts, retrieves the iucv interrupt buffer and frees
598  * the pathid table. Called after the last user unregister its iucv handler.
599  */
600 static void iucv_disable(void)
601 {
602 	cpus_read_lock();
603 	on_each_cpu(iucv_retrieve_cpu, NULL, 1);
604 	kfree(iucv_path_table);
605 	iucv_path_table = NULL;
606 	cpus_read_unlock();
607 }
608 
609 static int iucv_cpu_dead(unsigned int cpu)
610 {
611 	kfree(iucv_param_irq[cpu]);
612 	iucv_param_irq[cpu] = NULL;
613 	kfree(iucv_param[cpu]);
614 	iucv_param[cpu] = NULL;
615 	kfree(iucv_irq_data[cpu]);
616 	iucv_irq_data[cpu] = NULL;
617 	return 0;
618 }
619 
620 static int iucv_cpu_prepare(unsigned int cpu)
621 {
622 	/* Note: GFP_DMA used to get memory below 2G */
623 	iucv_irq_data[cpu] = kmalloc_node(sizeof(struct iucv_irq_data),
624 			     GFP_KERNEL|GFP_DMA, cpu_to_node(cpu));
625 	if (!iucv_irq_data[cpu])
626 		goto out_free;
627 
628 	/* Allocate parameter blocks. */
629 	iucv_param[cpu] = kmalloc_node(sizeof(union iucv_param),
630 			  GFP_KERNEL|GFP_DMA, cpu_to_node(cpu));
631 	if (!iucv_param[cpu])
632 		goto out_free;
633 
634 	iucv_param_irq[cpu] = kmalloc_node(sizeof(union iucv_param),
635 			  GFP_KERNEL|GFP_DMA, cpu_to_node(cpu));
636 	if (!iucv_param_irq[cpu])
637 		goto out_free;
638 
639 	return 0;
640 
641 out_free:
642 	iucv_cpu_dead(cpu);
643 	return -ENOMEM;
644 }
645 
646 static int iucv_cpu_online(unsigned int cpu)
647 {
648 	if (!iucv_path_table)
649 		return 0;
650 	iucv_declare_cpu(NULL);
651 	return 0;
652 }
653 
654 static int iucv_cpu_down_prep(unsigned int cpu)
655 {
656 	cpumask_var_t cpumask;
657 	int ret = 0;
658 
659 	if (!iucv_path_table)
660 		return 0;
661 
662 	if (!alloc_cpumask_var(&cpumask, GFP_KERNEL))
663 		return -ENOMEM;
664 
665 	cpumask_copy(cpumask, &iucv_buffer_cpumask);
666 	cpumask_clear_cpu(cpu, cpumask);
667 	if (cpumask_empty(cpumask)) {
668 		/* Can't offline last IUCV enabled cpu. */
669 		ret = -EINVAL;
670 		goto __free_cpumask;
671 	}
672 
673 	iucv_retrieve_cpu(NULL);
674 	if (!cpumask_empty(&iucv_irq_cpumask))
675 		goto __free_cpumask;
676 
677 	smp_call_function_single(cpumask_first(&iucv_buffer_cpumask),
678 				 iucv_allow_cpu, NULL, 1);
679 
680 __free_cpumask:
681 	free_cpumask_var(cpumask);
682 	return ret;
683 }
684 
685 /**
686  * iucv_sever_pathid - Sever an iucv path to free up the pathid. Used internally.
687  *
688  * @pathid: path identification number.
689  * @userdata: 16-bytes of user data.
690  *
691  * Returns: 0 on success, the result of the CP b2f0 IUCV call.
692  */
693 static int iucv_sever_pathid(u16 pathid, u8 *userdata)
694 {
695 	union iucv_param *parm;
696 
697 	parm = iucv_param_irq[smp_processor_id()];
698 	memset(parm, 0, sizeof(union iucv_param));
699 	if (userdata)
700 		memcpy(parm->ctrl.ipuser, userdata, sizeof(parm->ctrl.ipuser));
701 	parm->ctrl.ippathid = pathid;
702 	return iucv_call_b2f0(IUCV_SEVER, parm);
703 }
704 
705 /**
706  * __iucv_cleanup_queue - Nop function called via smp_call_function to force
707  * work items from pending external iucv interrupts to the work queue.
708  *
709  * @dummy: unused dummy argument
710  */
711 static void __iucv_cleanup_queue(void *dummy)
712 {
713 }
714 
715 /**
716  * iucv_cleanup_queue - Called after a path has been severed to find all
717  * remaining work items for the now stale pathid.
718  *
719  * The caller needs to hold the iucv_table_lock.
720  */
721 static void iucv_cleanup_queue(void)
722 {
723 	struct iucv_irq_list *p, *n;
724 
725 	/*
726 	 * When a path is severed, the pathid can be reused immediately
727 	 * on a iucv connect or a connection pending interrupt. Remove
728 	 * all entries from the task queue that refer to a stale pathid
729 	 * (iucv_path_table[ix] == NULL). Only then do the iucv connect
730 	 * or deliver the connection pending interrupt. To get all the
731 	 * pending interrupts force them to the work queue by calling
732 	 * an empty function on all cpus.
733 	 */
734 	smp_call_function(__iucv_cleanup_queue, NULL, 1);
735 	spin_lock_irq(&iucv_queue_lock);
736 	list_for_each_entry_safe(p, n, &iucv_task_queue, list) {
737 		/* Remove stale work items from the task queue. */
738 		if (iucv_path_table[p->data.ippathid] == NULL) {
739 			list_del(&p->list);
740 			kfree(p);
741 		}
742 	}
743 	spin_unlock_irq(&iucv_queue_lock);
744 }
745 
746 /**
747  * iucv_register - Registers a driver with IUCV.
748  *
749  * @handler: address of iucv handler structure
750  * @smp: != 0 indicates that the handler can deal with out of order messages
751  *
752  * Returns: 0 on success, -ENOMEM if the memory allocation for the pathid
753  * table failed, or -EIO if IUCV_DECLARE_BUFFER failed on all cpus.
754  */
755 int iucv_register(struct iucv_handler *handler, int smp)
756 {
757 	int rc;
758 
759 	if (!iucv_available)
760 		return -ENOSYS;
761 	mutex_lock(&iucv_register_mutex);
762 	if (!smp)
763 		iucv_nonsmp_handler++;
764 	if (list_empty(&iucv_handler_list)) {
765 		rc = iucv_enable();
766 		if (rc)
767 			goto out_mutex;
768 	} else if (!smp && iucv_nonsmp_handler == 1)
769 		iucv_setmask_up();
770 	INIT_LIST_HEAD(&handler->paths);
771 
772 	spin_lock_bh(&iucv_table_lock);
773 	list_add_tail(&handler->list, &iucv_handler_list);
774 	spin_unlock_bh(&iucv_table_lock);
775 	rc = 0;
776 out_mutex:
777 	mutex_unlock(&iucv_register_mutex);
778 	return rc;
779 }
780 EXPORT_SYMBOL(iucv_register);
781 
782 /**
783  * iucv_unregister - Unregister driver from IUCV.
784  *
785  * @handler:  address of iucv handler structure
786  * @smp: != 0 indicates that the handler can deal with out of order messages
787  */
788 void iucv_unregister(struct iucv_handler *handler, int smp)
789 {
790 	struct iucv_path *p, *n;
791 
792 	mutex_lock(&iucv_register_mutex);
793 	spin_lock_bh(&iucv_table_lock);
794 	/* Remove handler from the iucv_handler_list. */
795 	list_del_init(&handler->list);
796 	/* Sever all pathids still referring to the handler. */
797 	list_for_each_entry_safe(p, n, &handler->paths, list) {
798 		iucv_sever_pathid(p->pathid, NULL);
799 		iucv_path_table[p->pathid] = NULL;
800 		list_del(&p->list);
801 		iucv_path_free(p);
802 	}
803 	spin_unlock_bh(&iucv_table_lock);
804 	if (!smp)
805 		iucv_nonsmp_handler--;
806 	if (list_empty(&iucv_handler_list))
807 		iucv_disable();
808 	else if (!smp && iucv_nonsmp_handler == 0)
809 		iucv_setmask_mp();
810 	mutex_unlock(&iucv_register_mutex);
811 }
812 EXPORT_SYMBOL(iucv_unregister);
813 
814 static int iucv_reboot_event(struct notifier_block *this,
815 			     unsigned long event, void *ptr)
816 {
817 	int i;
818 
819 	if (cpumask_empty(&iucv_irq_cpumask))
820 		return NOTIFY_DONE;
821 
822 	cpus_read_lock();
823 	on_each_cpu_mask(&iucv_irq_cpumask, iucv_block_cpu, NULL, 1);
824 	preempt_disable();
825 	for (i = 0; i < iucv_max_pathid; i++) {
826 		if (iucv_path_table[i])
827 			iucv_sever_pathid(i, NULL);
828 	}
829 	preempt_enable();
830 	cpus_read_unlock();
831 	iucv_disable();
832 	return NOTIFY_DONE;
833 }
834 
835 static struct notifier_block iucv_reboot_notifier = {
836 	.notifier_call = iucv_reboot_event,
837 };
838 
839 /**
840  * iucv_path_accept - Complete the IUCV communication path
841  *
842  * @path: address of iucv path structure
843  * @handler: address of iucv handler structure
844  * @userdata: 16 bytes of data reflected to the communication partner
845  * @private: private data passed to interrupt handlers for this path
846  *
847  * This function is issued after the user received a connection pending
848  * external interrupt and now wishes to complete the IUCV communication path.
849  *
850  * Returns: the result of the CP IUCV call.
851  */
852 int iucv_path_accept(struct iucv_path *path, struct iucv_handler *handler,
853 		     u8 *userdata, void *private)
854 {
855 	union iucv_param *parm;
856 	int rc;
857 
858 	local_bh_disable();
859 	if (cpumask_empty(&iucv_buffer_cpumask)) {
860 		rc = -EIO;
861 		goto out;
862 	}
863 	/* Prepare parameter block. */
864 	parm = iucv_param[smp_processor_id()];
865 	memset(parm, 0, sizeof(union iucv_param));
866 	parm->ctrl.ippathid = path->pathid;
867 	parm->ctrl.ipmsglim = path->msglim;
868 	if (userdata)
869 		memcpy(parm->ctrl.ipuser, userdata, sizeof(parm->ctrl.ipuser));
870 	parm->ctrl.ipflags1 = path->flags;
871 
872 	rc = iucv_call_b2f0(IUCV_ACCEPT, parm);
873 	if (!rc) {
874 		path->private = private;
875 		path->msglim = parm->ctrl.ipmsglim;
876 		path->flags = parm->ctrl.ipflags1;
877 	}
878 out:
879 	local_bh_enable();
880 	return rc;
881 }
882 EXPORT_SYMBOL(iucv_path_accept);
883 
884 /**
885  * iucv_path_connect - Establish an IUCV path
886  *
887  * @path: address of iucv path structure
888  * @handler: address of iucv handler structure
889  * @userid: 8-byte user identification
890  * @system: 8-byte target system identification
891  * @userdata: 16 bytes of data reflected to the communication partner
892  * @private: private data passed to interrupt handlers for this path
893  *
894  * This function establishes an IUCV path. Although the connect may complete
895  * successfully, you are not able to use the path until you receive an IUCV
896  * Connection Complete external interrupt.
897  *
898  * Returns: the result of the CP IUCV call.
899  */
900 int iucv_path_connect(struct iucv_path *path, struct iucv_handler *handler,
901 		      u8 *userid, u8 *system, u8 *userdata,
902 		      void *private)
903 {
904 	union iucv_param *parm;
905 	int rc;
906 
907 	spin_lock_bh(&iucv_table_lock);
908 	iucv_cleanup_queue();
909 	if (cpumask_empty(&iucv_buffer_cpumask)) {
910 		rc = -EIO;
911 		goto out;
912 	}
913 	parm = iucv_param[smp_processor_id()];
914 	memset(parm, 0, sizeof(union iucv_param));
915 	parm->ctrl.ipmsglim = path->msglim;
916 	parm->ctrl.ipflags1 = path->flags;
917 	if (userid) {
918 		memcpy(parm->ctrl.ipvmid, userid, sizeof(parm->ctrl.ipvmid));
919 		ASCEBC(parm->ctrl.ipvmid, sizeof(parm->ctrl.ipvmid));
920 		EBC_TOUPPER(parm->ctrl.ipvmid, sizeof(parm->ctrl.ipvmid));
921 	}
922 	if (system) {
923 		memcpy(parm->ctrl.iptarget, system,
924 		       sizeof(parm->ctrl.iptarget));
925 		ASCEBC(parm->ctrl.iptarget, sizeof(parm->ctrl.iptarget));
926 		EBC_TOUPPER(parm->ctrl.iptarget, sizeof(parm->ctrl.iptarget));
927 	}
928 	if (userdata)
929 		memcpy(parm->ctrl.ipuser, userdata, sizeof(parm->ctrl.ipuser));
930 
931 	rc = iucv_call_b2f0(IUCV_CONNECT, parm);
932 	if (!rc) {
933 		if (parm->ctrl.ippathid < iucv_max_pathid) {
934 			path->pathid = parm->ctrl.ippathid;
935 			path->msglim = parm->ctrl.ipmsglim;
936 			path->flags = parm->ctrl.ipflags1;
937 			path->handler = handler;
938 			path->private = private;
939 			list_add_tail(&path->list, &handler->paths);
940 			iucv_path_table[path->pathid] = path;
941 		} else {
942 			iucv_sever_pathid(parm->ctrl.ippathid,
943 					  iucv_error_pathid);
944 			rc = -EIO;
945 		}
946 	}
947 out:
948 	spin_unlock_bh(&iucv_table_lock);
949 	return rc;
950 }
951 EXPORT_SYMBOL(iucv_path_connect);
952 
953 /**
954  * iucv_path_quiesce - Temporarily suspend incoming messages
955  * @path: address of iucv path structure
956  * @userdata: 16 bytes of data reflected to the communication partner
957  *
958  * This function temporarily suspends incoming messages on an IUCV path.
959  * You can later reactivate the path by invoking the iucv_resume function.
960  *
961  * Returns: the result from the CP IUCV call.
962  */
963 int iucv_path_quiesce(struct iucv_path *path, u8 *userdata)
964 {
965 	union iucv_param *parm;
966 	int rc;
967 
968 	local_bh_disable();
969 	if (cpumask_empty(&iucv_buffer_cpumask)) {
970 		rc = -EIO;
971 		goto out;
972 	}
973 	parm = iucv_param[smp_processor_id()];
974 	memset(parm, 0, sizeof(union iucv_param));
975 	if (userdata)
976 		memcpy(parm->ctrl.ipuser, userdata, sizeof(parm->ctrl.ipuser));
977 	parm->ctrl.ippathid = path->pathid;
978 	rc = iucv_call_b2f0(IUCV_QUIESCE, parm);
979 out:
980 	local_bh_enable();
981 	return rc;
982 }
983 EXPORT_SYMBOL(iucv_path_quiesce);
984 
985 /**
986  * iucv_path_resume - Resume incoming messages on a suspended IUCV path
987  *
988  * @path: address of iucv path structure
989  * @userdata: 16 bytes of data reflected to the communication partner
990  *
991  * This function resumes incoming messages on an IUCV path that has
992  * been stopped with iucv_path_quiesce.
993  *
994  * Returns: the result from the CP IUCV call.
995  */
996 int iucv_path_resume(struct iucv_path *path, u8 *userdata)
997 {
998 	union iucv_param *parm;
999 	int rc;
1000 
1001 	local_bh_disable();
1002 	if (cpumask_empty(&iucv_buffer_cpumask)) {
1003 		rc = -EIO;
1004 		goto out;
1005 	}
1006 	parm = iucv_param[smp_processor_id()];
1007 	memset(parm, 0, sizeof(union iucv_param));
1008 	if (userdata)
1009 		memcpy(parm->ctrl.ipuser, userdata, sizeof(parm->ctrl.ipuser));
1010 	parm->ctrl.ippathid = path->pathid;
1011 	rc = iucv_call_b2f0(IUCV_RESUME, parm);
1012 out:
1013 	local_bh_enable();
1014 	return rc;
1015 }
1016 
1017 /**
1018  * iucv_path_sever - Terminates an IUCV path.
1019  *
1020  * @path: address of iucv path structure
1021  * @userdata: 16 bytes of data reflected to the communication partner
1022  *
1023  * Returns: the result from the CP IUCV call.
1024  */
1025 int iucv_path_sever(struct iucv_path *path, u8 *userdata)
1026 {
1027 	int rc;
1028 
1029 	preempt_disable();
1030 	if (cpumask_empty(&iucv_buffer_cpumask)) {
1031 		rc = -EIO;
1032 		goto out;
1033 	}
1034 	if (iucv_active_cpu != smp_processor_id())
1035 		spin_lock_bh(&iucv_table_lock);
1036 	rc = iucv_sever_pathid(path->pathid, userdata);
1037 	iucv_path_table[path->pathid] = NULL;
1038 	list_del_init(&path->list);
1039 	if (iucv_active_cpu != smp_processor_id())
1040 		spin_unlock_bh(&iucv_table_lock);
1041 out:
1042 	preempt_enable();
1043 	return rc;
1044 }
1045 EXPORT_SYMBOL(iucv_path_sever);
1046 
1047 /**
1048  * iucv_message_purge - Cancels a message you have sent.
1049  *
1050  * @path: address of iucv path structure
1051  * @msg: address of iucv msg structure
1052  * @srccls: source class of message
1053  *
1054  * Returns: the result from the CP IUCV call.
1055  */
1056 int iucv_message_purge(struct iucv_path *path, struct iucv_message *msg,
1057 		       u32 srccls)
1058 {
1059 	union iucv_param *parm;
1060 	int rc;
1061 
1062 	local_bh_disable();
1063 	if (cpumask_empty(&iucv_buffer_cpumask)) {
1064 		rc = -EIO;
1065 		goto out;
1066 	}
1067 	parm = iucv_param[smp_processor_id()];
1068 	memset(parm, 0, sizeof(union iucv_param));
1069 	parm->purge.ippathid = path->pathid;
1070 	parm->purge.ipmsgid = msg->id;
1071 	parm->purge.ipsrccls = srccls;
1072 	parm->purge.ipflags1 = IUCV_IPSRCCLS | IUCV_IPFGMID | IUCV_IPFGPID;
1073 	rc = iucv_call_b2f0(IUCV_PURGE, parm);
1074 	if (!rc) {
1075 		msg->audit = (*(u32 *) &parm->purge.ipaudit) >> 8;
1076 		msg->tag = parm->purge.ipmsgtag;
1077 	}
1078 out:
1079 	local_bh_enable();
1080 	return rc;
1081 }
1082 EXPORT_SYMBOL(iucv_message_purge);
1083 
1084 /**
1085  * iucv_message_receive_iprmdata - Internal function to receive RMDATA
1086  * stored in &struct iucv_message
1087  *
1088  * @path: address of iucv path structure
1089  * @msg: address of iucv msg structure
1090  * @flags: how the message is received (IUCV_IPBUFLST)
1091  * @buffer: address of data buffer or address of struct iucv_array
1092  * @size: length of data buffer
1093  * @residual: number of bytes remaining in the data buffer
1094  *
1095  * Internal function used by iucv_message_receive and __iucv_message_receive
1096  * to receive RMDATA data stored in struct iucv_message.
1097  *
1098  * Returns: 0
1099  */
1100 static int iucv_message_receive_iprmdata(struct iucv_path *path,
1101 					 struct iucv_message *msg,
1102 					 u8 flags, void *buffer,
1103 					 size_t size, size_t *residual)
1104 {
1105 	struct iucv_array *array;
1106 	u8 *rmmsg;
1107 	size_t copy;
1108 
1109 	/*
1110 	 * Message is 8 bytes long and has been stored to the
1111 	 * message descriptor itself.
1112 	 */
1113 	if (residual)
1114 		*residual = abs(size - 8);
1115 	rmmsg = msg->rmmsg;
1116 	if (flags & IUCV_IPBUFLST) {
1117 		/* Copy to struct iucv_array. */
1118 		size = (size < 8) ? size : 8;
1119 		for (array = buffer; size > 0; array++) {
1120 			copy = min_t(size_t, size, array->length);
1121 			memcpy(dma32_to_virt(array->address), rmmsg, copy);
1122 			rmmsg += copy;
1123 			size -= copy;
1124 		}
1125 	} else {
1126 		/* Copy to direct buffer. */
1127 		memcpy(buffer, rmmsg, min_t(size_t, size, 8));
1128 	}
1129 	return 0;
1130 }
1131 
1132 /**
1133  * __iucv_message_receive - Receives messages on an established path (no locking)
1134  *
1135  * @path: address of iucv path structure
1136  * @msg: address of iucv msg structure
1137  * @flags: flags that affect how the message is received (IUCV_IPBUFLST)
1138  * @buffer: address of data buffer or address of struct iucv_array
1139  * @size: length of data buffer
1140  * @residual:
1141  *
1142  * This function receives messages that are being sent to you over
1143  * established paths. This function will deal with RMDATA messages
1144  * embedded in struct iucv_message as well.
1145  *
1146  * Locking:	no locking
1147  *
1148  * Returns: the result from the CP IUCV call.
1149  */
1150 int __iucv_message_receive(struct iucv_path *path, struct iucv_message *msg,
1151 			   u8 flags, void *buffer, size_t size, size_t *residual)
1152 {
1153 	union iucv_param *parm;
1154 	int rc;
1155 
1156 	if (msg->flags & IUCV_IPRMDATA)
1157 		return iucv_message_receive_iprmdata(path, msg, flags,
1158 						     buffer, size, residual);
1159 	if (cpumask_empty(&iucv_buffer_cpumask))
1160 		return -EIO;
1161 
1162 	parm = iucv_param[smp_processor_id()];
1163 	memset(parm, 0, sizeof(union iucv_param));
1164 	parm->db.ipbfadr1 = virt_to_dma32(buffer);
1165 	parm->db.ipbfln1f = (u32) size;
1166 	parm->db.ipmsgid = msg->id;
1167 	parm->db.ippathid = path->pathid;
1168 	parm->db.iptrgcls = msg->class;
1169 	parm->db.ipflags1 = (flags | IUCV_IPFGPID |
1170 			     IUCV_IPFGMID | IUCV_IPTRGCLS);
1171 	rc = iucv_call_b2f0(IUCV_RECEIVE, parm);
1172 	if (!rc || rc == 5) {
1173 		msg->flags = parm->db.ipflags1;
1174 		if (residual)
1175 			*residual = parm->db.ipbfln1f;
1176 	}
1177 	return rc;
1178 }
1179 EXPORT_SYMBOL(__iucv_message_receive);
1180 
1181 /**
1182  * iucv_message_receive - Receives messages on an established path, with locking
1183  *
1184  * @path: address of iucv path structure
1185  * @msg: address of iucv msg structure
1186  * @flags: flags that affect how the message is received (IUCV_IPBUFLST)
1187  * @buffer: address of data buffer or address of struct iucv_array
1188  * @size: length of data buffer
1189  * @residual:
1190  *
1191  * This function receives messages that are being sent to you over
1192  * established paths. This function will deal with RMDATA messages
1193  * embedded in struct iucv_message as well.
1194  *
1195  * Locking:	local_bh_enable/local_bh_disable
1196  *
1197  * Returns: the result from the CP IUCV call.
1198  */
1199 int iucv_message_receive(struct iucv_path *path, struct iucv_message *msg,
1200 			 u8 flags, void *buffer, size_t size, size_t *residual)
1201 {
1202 	int rc;
1203 
1204 	if (msg->flags & IUCV_IPRMDATA)
1205 		return iucv_message_receive_iprmdata(path, msg, flags,
1206 						     buffer, size, residual);
1207 	local_bh_disable();
1208 	rc = __iucv_message_receive(path, msg, flags, buffer, size, residual);
1209 	local_bh_enable();
1210 	return rc;
1211 }
1212 EXPORT_SYMBOL(iucv_message_receive);
1213 
1214 /**
1215  * iucv_message_reject - Refuses a specified message
1216  *
1217  * @path: address of iucv path structure
1218  * @msg: address of iucv msg structure
1219  *
1220  * The reject function refuses a specified message. Between the time you
1221  * are notified of a message and the time that you complete the message,
1222  * the message may be rejected.
1223  *
1224  * Returns: the result from the CP IUCV call.
1225  */
1226 int iucv_message_reject(struct iucv_path *path, struct iucv_message *msg)
1227 {
1228 	union iucv_param *parm;
1229 	int rc;
1230 
1231 	local_bh_disable();
1232 	if (cpumask_empty(&iucv_buffer_cpumask)) {
1233 		rc = -EIO;
1234 		goto out;
1235 	}
1236 	parm = iucv_param[smp_processor_id()];
1237 	memset(parm, 0, sizeof(union iucv_param));
1238 	parm->db.ippathid = path->pathid;
1239 	parm->db.ipmsgid = msg->id;
1240 	parm->db.iptrgcls = msg->class;
1241 	parm->db.ipflags1 = (IUCV_IPTRGCLS | IUCV_IPFGMID | IUCV_IPFGPID);
1242 	rc = iucv_call_b2f0(IUCV_REJECT, parm);
1243 out:
1244 	local_bh_enable();
1245 	return rc;
1246 }
1247 EXPORT_SYMBOL(iucv_message_reject);
1248 
1249 /**
1250  * iucv_message_reply - Replies to a specified message
1251  *
1252  * @path: address of iucv path structure
1253  * @msg: address of iucv msg structure
1254  * @flags: how the reply is sent (IUCV_IPRMDATA, IUCV_IPPRTY, IUCV_IPBUFLST)
1255  * @reply: address of reply data buffer or address of struct iucv_array
1256  * @size: length of reply data buffer
1257  *
1258  * This function responds to the two-way messages that you receive. You
1259  * must identify completely the message to which you wish to reply. I.e.,
1260  * pathid, msgid, and trgcls. Prmmsg signifies the data is moved into
1261  * the parameter list.
1262  *
1263  * Returns: the result from the CP IUCV call.
1264  */
1265 int iucv_message_reply(struct iucv_path *path, struct iucv_message *msg,
1266 		       u8 flags, void *reply, size_t size)
1267 {
1268 	union iucv_param *parm;
1269 	int rc;
1270 
1271 	local_bh_disable();
1272 	if (cpumask_empty(&iucv_buffer_cpumask)) {
1273 		rc = -EIO;
1274 		goto out;
1275 	}
1276 	parm = iucv_param[smp_processor_id()];
1277 	memset(parm, 0, sizeof(union iucv_param));
1278 	if (flags & IUCV_IPRMDATA) {
1279 		parm->dpl.ippathid = path->pathid;
1280 		parm->dpl.ipflags1 = flags;
1281 		parm->dpl.ipmsgid = msg->id;
1282 		parm->dpl.iptrgcls = msg->class;
1283 		memcpy(parm->dpl.iprmmsg, reply, min_t(size_t, size, 8));
1284 	} else {
1285 		parm->db.ipbfadr1 = virt_to_dma32(reply);
1286 		parm->db.ipbfln1f = (u32) size;
1287 		parm->db.ippathid = path->pathid;
1288 		parm->db.ipflags1 = flags;
1289 		parm->db.ipmsgid = msg->id;
1290 		parm->db.iptrgcls = msg->class;
1291 	}
1292 	rc = iucv_call_b2f0(IUCV_REPLY, parm);
1293 out:
1294 	local_bh_enable();
1295 	return rc;
1296 }
1297 EXPORT_SYMBOL(iucv_message_reply);
1298 
1299 /**
1300  * __iucv_message_send - Transmits a one-way message, no locking
1301  *
1302  * @path: address of iucv path structure
1303  * @msg: address of iucv msg structure
1304  * @flags: how the message is sent (IUCV_IPRMDATA, IUCV_IPPRTY, IUCV_IPBUFLST)
1305  * @srccls: source class of message
1306  * @buffer: address of send buffer or address of struct iucv_array
1307  * @size: length of send buffer
1308  *
1309  * This function transmits data to another application. Data to be
1310  * transmitted is in a buffer and this is a one-way message and the
1311  * receiver will not reply to the message.
1312  *
1313  * Locking:	no locking
1314  *
1315  * Returns: the result from the CP IUCV call.
1316  */
1317 int __iucv_message_send(struct iucv_path *path, struct iucv_message *msg,
1318 		      u8 flags, u32 srccls, void *buffer, size_t size)
1319 {
1320 	union iucv_param *parm;
1321 	int rc;
1322 
1323 	if (cpumask_empty(&iucv_buffer_cpumask)) {
1324 		rc = -EIO;
1325 		goto out;
1326 	}
1327 	parm = iucv_param[smp_processor_id()];
1328 	memset(parm, 0, sizeof(union iucv_param));
1329 	if (flags & IUCV_IPRMDATA) {
1330 		/* Message of 8 bytes can be placed into the parameter list. */
1331 		parm->dpl.ippathid = path->pathid;
1332 		parm->dpl.ipflags1 = flags | IUCV_IPNORPY;
1333 		parm->dpl.iptrgcls = msg->class;
1334 		parm->dpl.ipsrccls = srccls;
1335 		parm->dpl.ipmsgtag = msg->tag;
1336 		memcpy(parm->dpl.iprmmsg, buffer, 8);
1337 	} else {
1338 		parm->db.ipbfadr1 = virt_to_dma32(buffer);
1339 		parm->db.ipbfln1f = (u32) size;
1340 		parm->db.ippathid = path->pathid;
1341 		parm->db.ipflags1 = flags | IUCV_IPNORPY;
1342 		parm->db.iptrgcls = msg->class;
1343 		parm->db.ipsrccls = srccls;
1344 		parm->db.ipmsgtag = msg->tag;
1345 	}
1346 	rc = iucv_call_b2f0(IUCV_SEND, parm);
1347 	if (!rc)
1348 		msg->id = parm->db.ipmsgid;
1349 out:
1350 	return rc;
1351 }
1352 EXPORT_SYMBOL(__iucv_message_send);
1353 
1354 /**
1355  * iucv_message_send - Transmits a one-way message, with locking
1356  *
1357  * @path: address of iucv path structure
1358  * @msg: address of iucv msg structure
1359  * @flags: how the message is sent (IUCV_IPRMDATA, IUCV_IPPRTY, IUCV_IPBUFLST)
1360  * @srccls: source class of message
1361  * @buffer: address of send buffer or address of struct iucv_array
1362  * @size: length of send buffer
1363  *
1364  * This function transmits data to another application. Data to be
1365  * transmitted is in a buffer and this is a one-way message and the
1366  * receiver will not reply to the message.
1367  *
1368  * Locking:	local_bh_enable/local_bh_disable
1369  *
1370  * Returns: the result from the CP IUCV call.
1371  */
1372 int iucv_message_send(struct iucv_path *path, struct iucv_message *msg,
1373 		      u8 flags, u32 srccls, void *buffer, size_t size)
1374 {
1375 	int rc;
1376 
1377 	local_bh_disable();
1378 	rc = __iucv_message_send(path, msg, flags, srccls, buffer, size);
1379 	local_bh_enable();
1380 	return rc;
1381 }
1382 EXPORT_SYMBOL(iucv_message_send);
1383 
1384 /**
1385  * iucv_message_send2way - Transmits a two-way message
1386  *
1387  * @path: address of iucv path structure
1388  * @msg: address of iucv msg structure
1389  * @flags: how the message is sent and the reply is received
1390  *	   (IUCV_IPRMDATA, IUCV_IPBUFLST, IUCV_IPPRTY, IUCV_ANSLST)
1391  * @srccls: source class of message
1392  * @buffer: address of send buffer or address of struct iucv_array
1393  * @size: length of send buffer
1394  * @answer: address of answer buffer or address of struct iucv_array
1395  * @asize: size of reply buffer
1396  * @residual: ignored
1397  *
1398  * This function transmits data to another application. Data to be
1399  * transmitted is in a buffer. The receiver of the send is expected to
1400  * reply to the message and a buffer is provided into which IUCV moves
1401  * the reply to this message.
1402  *
1403  * Returns: the result from the CP IUCV call.
1404  */
1405 int iucv_message_send2way(struct iucv_path *path, struct iucv_message *msg,
1406 			  u8 flags, u32 srccls, void *buffer, size_t size,
1407 			  void *answer, size_t asize, size_t *residual)
1408 {
1409 	union iucv_param *parm;
1410 	int rc;
1411 
1412 	local_bh_disable();
1413 	if (cpumask_empty(&iucv_buffer_cpumask)) {
1414 		rc = -EIO;
1415 		goto out;
1416 	}
1417 	parm = iucv_param[smp_processor_id()];
1418 	memset(parm, 0, sizeof(union iucv_param));
1419 	if (flags & IUCV_IPRMDATA) {
1420 		parm->dpl.ippathid = path->pathid;
1421 		parm->dpl.ipflags1 = path->flags;	/* priority message */
1422 		parm->dpl.iptrgcls = msg->class;
1423 		parm->dpl.ipsrccls = srccls;
1424 		parm->dpl.ipmsgtag = msg->tag;
1425 		parm->dpl.ipbfadr2 = virt_to_dma32(answer);
1426 		parm->dpl.ipbfln2f = (u32) asize;
1427 		memcpy(parm->dpl.iprmmsg, buffer, 8);
1428 	} else {
1429 		parm->db.ippathid = path->pathid;
1430 		parm->db.ipflags1 = path->flags;	/* priority message */
1431 		parm->db.iptrgcls = msg->class;
1432 		parm->db.ipsrccls = srccls;
1433 		parm->db.ipmsgtag = msg->tag;
1434 		parm->db.ipbfadr1 = virt_to_dma32(buffer);
1435 		parm->db.ipbfln1f = (u32) size;
1436 		parm->db.ipbfadr2 = virt_to_dma32(answer);
1437 		parm->db.ipbfln2f = (u32) asize;
1438 	}
1439 	rc = iucv_call_b2f0(IUCV_SEND, parm);
1440 	if (!rc)
1441 		msg->id = parm->db.ipmsgid;
1442 out:
1443 	local_bh_enable();
1444 	return rc;
1445 }
1446 EXPORT_SYMBOL(iucv_message_send2way);
1447 
1448 struct iucv_path_pending {
1449 	u16 ippathid;
1450 	u8  ipflags1;
1451 	u8  iptype;
1452 	u16 ipmsglim;
1453 	u16 res1;
1454 	u8  ipvmid[8];
1455 	u8  ipuser[16];
1456 	u32 res3;
1457 	u8  ippollfg;
1458 	u8  res4[3];
1459 } __packed;
1460 
1461 /**
1462  * iucv_path_pending - Process connection pending work item
1463  *
1464  * @data: Pointer to external interrupt buffer
1465  *
1466  * Context: Called from tasklet while holding iucv_table_lock.
1467  */
1468 static void iucv_path_pending(struct iucv_irq_data *data)
1469 {
1470 	struct iucv_path_pending *ipp = (void *) data;
1471 	struct iucv_handler *handler;
1472 	struct iucv_path *path;
1473 	char *error;
1474 
1475 	BUG_ON(iucv_path_table[ipp->ippathid]);
1476 	/* New pathid, handler found. Create a new path struct. */
1477 	error = iucv_error_no_memory;
1478 	path = iucv_path_alloc(ipp->ipmsglim, ipp->ipflags1, GFP_ATOMIC);
1479 	if (!path)
1480 		goto out_sever;
1481 	path->pathid = ipp->ippathid;
1482 	iucv_path_table[path->pathid] = path;
1483 	EBCASC(ipp->ipvmid, 8);
1484 
1485 	/* Call registered handler until one is found that wants the path. */
1486 	list_for_each_entry(handler, &iucv_handler_list, list) {
1487 		if (!handler->path_pending)
1488 			continue;
1489 		/*
1490 		 * Add path to handler to allow a call to iucv_path_sever
1491 		 * inside the path_pending function. If the handler returns
1492 		 * an error remove the path from the handler again.
1493 		 */
1494 		list_add(&path->list, &handler->paths);
1495 		path->handler = handler;
1496 		if (!handler->path_pending(path, ipp->ipvmid, ipp->ipuser))
1497 			return;
1498 		list_del(&path->list);
1499 		path->handler = NULL;
1500 	}
1501 	/* No handler wanted the path. */
1502 	iucv_path_table[path->pathid] = NULL;
1503 	iucv_path_free(path);
1504 	error = iucv_error_no_listener;
1505 out_sever:
1506 	iucv_sever_pathid(ipp->ippathid, error);
1507 }
1508 
1509 struct iucv_path_complete {
1510 	u16 ippathid;
1511 	u8  ipflags1;
1512 	u8  iptype;
1513 	u16 ipmsglim;
1514 	u16 res1;
1515 	u8  res2[8];
1516 	u8  ipuser[16];
1517 	u32 res3;
1518 	u8  ippollfg;
1519 	u8  res4[3];
1520 } __packed;
1521 
1522 /**
1523  * iucv_path_complete - Process connection complete work item
1524  *
1525  * @data: Pointer to external interrupt buffer
1526  *
1527  * Context: Called from tasklet while holding iucv_table_lock.
1528  */
1529 static void iucv_path_complete(struct iucv_irq_data *data)
1530 {
1531 	struct iucv_path_complete *ipc = (void *) data;
1532 	struct iucv_path *path = iucv_path_table[ipc->ippathid];
1533 
1534 	if (path)
1535 		path->flags = ipc->ipflags1;
1536 	if (path && path->handler && path->handler->path_complete)
1537 		path->handler->path_complete(path, ipc->ipuser);
1538 }
1539 
1540 struct iucv_path_severed {
1541 	u16 ippathid;
1542 	u8  res1;
1543 	u8  iptype;
1544 	u32 res2;
1545 	u8  res3[8];
1546 	u8  ipuser[16];
1547 	u32 res4;
1548 	u8  ippollfg;
1549 	u8  res5[3];
1550 } __packed;
1551 
1552 /**
1553  * iucv_path_severed - Process connection severed work item.
1554  *
1555  * @data: Pointer to external interrupt buffer
1556  *
1557  * Context: Called from tasklet while holding iucv_table_lock.
1558  */
1559 static void iucv_path_severed(struct iucv_irq_data *data)
1560 {
1561 	struct iucv_path_severed *ips = (void *) data;
1562 	struct iucv_path *path = iucv_path_table[ips->ippathid];
1563 
1564 	if (!path || !path->handler)	/* Already severed */
1565 		return;
1566 	if (path->handler->path_severed)
1567 		path->handler->path_severed(path, ips->ipuser);
1568 	else {
1569 		iucv_sever_pathid(path->pathid, NULL);
1570 		iucv_path_table[path->pathid] = NULL;
1571 		list_del(&path->list);
1572 		iucv_path_free(path);
1573 	}
1574 }
1575 
1576 struct iucv_path_quiesced {
1577 	u16 ippathid;
1578 	u8  res1;
1579 	u8  iptype;
1580 	u32 res2;
1581 	u8  res3[8];
1582 	u8  ipuser[16];
1583 	u32 res4;
1584 	u8  ippollfg;
1585 	u8  res5[3];
1586 } __packed;
1587 
1588 /**
1589  * iucv_path_quiesced - Process connection quiesced work item.
1590  *
1591  * @data: Pointer to external interrupt buffer
1592  *
1593  * Context: Called from tasklet while holding iucv_table_lock.
1594  */
1595 static void iucv_path_quiesced(struct iucv_irq_data *data)
1596 {
1597 	struct iucv_path_quiesced *ipq = (void *) data;
1598 	struct iucv_path *path = iucv_path_table[ipq->ippathid];
1599 
1600 	if (path && path->handler && path->handler->path_quiesced)
1601 		path->handler->path_quiesced(path, ipq->ipuser);
1602 }
1603 
1604 struct iucv_path_resumed {
1605 	u16 ippathid;
1606 	u8  res1;
1607 	u8  iptype;
1608 	u32 res2;
1609 	u8  res3[8];
1610 	u8  ipuser[16];
1611 	u32 res4;
1612 	u8  ippollfg;
1613 	u8  res5[3];
1614 } __packed;
1615 
1616 /**
1617  * iucv_path_resumed - Process connection resumed work item.
1618  *
1619  * @data: Pointer to external interrupt buffer
1620  *
1621  * Context: Called from tasklet while holding iucv_table_lock.
1622  */
1623 static void iucv_path_resumed(struct iucv_irq_data *data)
1624 {
1625 	struct iucv_path_resumed *ipr = (void *) data;
1626 	struct iucv_path *path = iucv_path_table[ipr->ippathid];
1627 
1628 	if (path && path->handler && path->handler->path_resumed)
1629 		path->handler->path_resumed(path, ipr->ipuser);
1630 }
1631 
1632 struct iucv_message_complete {
1633 	u16 ippathid;
1634 	u8  ipflags1;
1635 	u8  iptype;
1636 	u32 ipmsgid;
1637 	u32 ipaudit;
1638 	u8  iprmmsg[8];
1639 	u32 ipsrccls;
1640 	u32 ipmsgtag;
1641 	u32 res;
1642 	u32 ipbfln2f;
1643 	u8  ippollfg;
1644 	u8  res2[3];
1645 } __packed;
1646 
1647 /**
1648  * iucv_message_complete - Process message complete work item.
1649  *
1650  * @data: Pointer to external interrupt buffer
1651  *
1652  * Context: Called from tasklet while holding iucv_table_lock.
1653  */
1654 static void iucv_message_complete(struct iucv_irq_data *data)
1655 {
1656 	struct iucv_message_complete *imc = (void *) data;
1657 	struct iucv_path *path = iucv_path_table[imc->ippathid];
1658 	struct iucv_message msg;
1659 
1660 	if (path && path->handler && path->handler->message_complete) {
1661 		msg.flags = imc->ipflags1;
1662 		msg.id = imc->ipmsgid;
1663 		msg.audit = imc->ipaudit;
1664 		memcpy(msg.rmmsg, imc->iprmmsg, 8);
1665 		msg.class = imc->ipsrccls;
1666 		msg.tag = imc->ipmsgtag;
1667 		msg.length = imc->ipbfln2f;
1668 		path->handler->message_complete(path, &msg);
1669 	}
1670 }
1671 
1672 struct iucv_message_pending {
1673 	u16 ippathid;
1674 	u8  ipflags1;
1675 	u8  iptype;
1676 	u32 ipmsgid;
1677 	u32 iptrgcls;
1678 	struct {
1679 		union {
1680 			u32 iprmmsg1_u32;
1681 			u8  iprmmsg1[4];
1682 		} ln1msg1;
1683 		union {
1684 			u32 ipbfln1f;
1685 			u8  iprmmsg2[4];
1686 		} ln1msg2;
1687 	} rmmsg;
1688 	u32 res1[3];
1689 	u32 ipbfln2f;
1690 	u8  ippollfg;
1691 	u8  res2[3];
1692 } __packed;
1693 
1694 /**
1695  * iucv_message_pending - Process message pending work item.
1696  *
1697  * @data: Pointer to external interrupt buffer
1698  *
1699  * Context: Called from tasklet while holding iucv_table_lock.
1700  */
1701 static void iucv_message_pending(struct iucv_irq_data *data)
1702 {
1703 	struct iucv_message_pending *imp = (void *) data;
1704 	struct iucv_path *path = iucv_path_table[imp->ippathid];
1705 	struct iucv_message msg;
1706 
1707 	if (path && path->handler && path->handler->message_pending) {
1708 		msg.flags = imp->ipflags1;
1709 		msg.id = imp->ipmsgid;
1710 		msg.class = imp->iptrgcls;
1711 		if (imp->ipflags1 & IUCV_IPRMDATA) {
1712 			memcpy(msg.rmmsg, &imp->rmmsg, 8);
1713 			msg.length = 8;
1714 		} else
1715 			msg.length = imp->rmmsg.ln1msg2.ipbfln1f;
1716 		msg.reply_size = imp->ipbfln2f;
1717 		path->handler->message_pending(path, &msg);
1718 	}
1719 }
1720 
1721 /*
1722  * iucv_tasklet_fn - Process the queue of IRQ buffers
1723  *
1724  * This tasklet loops over the queue of irq buffers created by
1725  * iucv_external_interrupt, calls the appropriate action handler
1726  * and then frees the buffer.
1727  */
1728 static void iucv_tasklet_fn(unsigned long ignored)
1729 {
1730 	typedef void iucv_irq_fn(struct iucv_irq_data *);
1731 	static iucv_irq_fn *irq_fn[] = {
1732 		[0x02] = iucv_path_complete,
1733 		[0x03] = iucv_path_severed,
1734 		[0x04] = iucv_path_quiesced,
1735 		[0x05] = iucv_path_resumed,
1736 		[0x06] = iucv_message_complete,
1737 		[0x07] = iucv_message_complete,
1738 		[0x08] = iucv_message_pending,
1739 		[0x09] = iucv_message_pending,
1740 	};
1741 	LIST_HEAD(task_queue);
1742 	struct iucv_irq_list *p, *n;
1743 
1744 	/* Serialize tasklet, iucv_path_sever and iucv_path_connect. */
1745 	if (!spin_trylock(&iucv_table_lock)) {
1746 		tasklet_schedule(&iucv_tasklet);
1747 		return;
1748 	}
1749 	iucv_active_cpu = smp_processor_id();
1750 
1751 	spin_lock_irq(&iucv_queue_lock);
1752 	list_splice_init(&iucv_task_queue, &task_queue);
1753 	spin_unlock_irq(&iucv_queue_lock);
1754 
1755 	list_for_each_entry_safe(p, n, &task_queue, list) {
1756 		list_del_init(&p->list);
1757 		irq_fn[p->data.iptype](&p->data);
1758 		kfree(p);
1759 	}
1760 
1761 	iucv_active_cpu = -1;
1762 	spin_unlock(&iucv_table_lock);
1763 }
1764 
1765 /*
1766  * iucv_work_fn - Process the queue of path pending IRQ blocks
1767  *
1768  * This work function loops over the queue of path pending irq blocks
1769  * created by iucv_external_interrupt, calls the appropriate action
1770  * handler and then frees the buffer.
1771  */
1772 static void iucv_work_fn(struct work_struct *work)
1773 {
1774 	LIST_HEAD(work_queue);
1775 	struct iucv_irq_list *p, *n;
1776 
1777 	/* Serialize tasklet, iucv_path_sever and iucv_path_connect. */
1778 	spin_lock_bh(&iucv_table_lock);
1779 	iucv_active_cpu = smp_processor_id();
1780 
1781 	spin_lock_irq(&iucv_queue_lock);
1782 	list_splice_init(&iucv_work_queue, &work_queue);
1783 	spin_unlock_irq(&iucv_queue_lock);
1784 
1785 	iucv_cleanup_queue();
1786 	list_for_each_entry_safe(p, n, &work_queue, list) {
1787 		list_del_init(&p->list);
1788 		iucv_path_pending(&p->data);
1789 		kfree(p);
1790 	}
1791 
1792 	iucv_active_cpu = -1;
1793 	spin_unlock_bh(&iucv_table_lock);
1794 }
1795 
1796 /*
1797  * iucv_external_interrupt - Handles external interrupts coming in from CP.
1798  *
1799  * Places the interrupt buffer on a queue and schedules iucv_tasklet_fn().
1800  */
1801 static void iucv_external_interrupt(struct ext_code ext_code,
1802 				    unsigned int param32, unsigned long param64)
1803 {
1804 	struct iucv_irq_data *p;
1805 	struct iucv_irq_list *work;
1806 
1807 	inc_irq_stat(IRQEXT_IUC);
1808 	p = iucv_irq_data[smp_processor_id()];
1809 	if (p->ippathid >= iucv_max_pathid) {
1810 		WARN_ON(p->ippathid >= iucv_max_pathid);
1811 		iucv_sever_pathid(p->ippathid, iucv_error_no_listener);
1812 		return;
1813 	}
1814 	BUG_ON(p->iptype  < 0x01 || p->iptype > 0x09);
1815 	work = kmalloc_obj(struct iucv_irq_list, GFP_ATOMIC);
1816 	if (!work) {
1817 		pr_warn("iucv_external_interrupt: out of memory\n");
1818 		return;
1819 	}
1820 	memcpy(&work->data, p, sizeof(work->data));
1821 	spin_lock(&iucv_queue_lock);
1822 	if (p->iptype == 0x01) {
1823 		/* Path pending interrupt. */
1824 		list_add_tail(&work->list, &iucv_work_queue);
1825 		schedule_work(&iucv_work);
1826 	} else {
1827 		/* The other interrupts. */
1828 		list_add_tail(&work->list, &iucv_task_queue);
1829 		tasklet_schedule(&iucv_tasklet);
1830 	}
1831 	spin_unlock(&iucv_queue_lock);
1832 }
1833 
1834 struct iucv_interface iucv_if = {
1835 	.message_receive = iucv_message_receive,
1836 	.__message_receive = __iucv_message_receive,
1837 	.message_reply = iucv_message_reply,
1838 	.message_reject = iucv_message_reject,
1839 	.message_send = iucv_message_send,
1840 	.__message_send = __iucv_message_send,
1841 	.message_send2way = iucv_message_send2way,
1842 	.message_purge = iucv_message_purge,
1843 	.path_accept = iucv_path_accept,
1844 	.path_connect = iucv_path_connect,
1845 	.path_quiesce = iucv_path_quiesce,
1846 	.path_resume = iucv_path_resume,
1847 	.path_sever = iucv_path_sever,
1848 	.iucv_register = iucv_register,
1849 	.iucv_unregister = iucv_unregister,
1850 	.bus = NULL,
1851 	.root = NULL,
1852 };
1853 EXPORT_SYMBOL(iucv_if);
1854 
1855 static enum cpuhp_state iucv_online;
1856 
1857 /**
1858  * iucv_init - Allocates and initializes various data structures.
1859  *
1860  * Returns: 0 on success, return code on failure.
1861  */
1862 static int __init iucv_init(void)
1863 {
1864 	int rc;
1865 
1866 	if (!machine_is_vm()) {
1867 		rc = -EPROTONOSUPPORT;
1868 		goto out;
1869 	}
1870 	system_ctl_set_bit(0, CR0_IUCV_BIT);
1871 	rc = iucv_query_maxconn();
1872 	if (rc)
1873 		goto out_ctl;
1874 	rc = register_external_irq(EXT_IRQ_IUCV, iucv_external_interrupt);
1875 	if (rc)
1876 		goto out_ctl;
1877 	iucv_root = root_device_register("iucv");
1878 	if (IS_ERR(iucv_root)) {
1879 		rc = PTR_ERR(iucv_root);
1880 		goto out_int;
1881 	}
1882 
1883 	rc = cpuhp_setup_state(CPUHP_NET_IUCV_PREPARE, "net/iucv:prepare",
1884 			       iucv_cpu_prepare, iucv_cpu_dead);
1885 	if (rc)
1886 		goto out_dev;
1887 	rc = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "net/iucv:online",
1888 			       iucv_cpu_online, iucv_cpu_down_prep);
1889 	if (rc < 0)
1890 		goto out_prep;
1891 	iucv_online = rc;
1892 
1893 	rc = register_reboot_notifier(&iucv_reboot_notifier);
1894 	if (rc)
1895 		goto out_remove_hp;
1896 	ASCEBC(iucv_error_no_listener, 16);
1897 	ASCEBC(iucv_error_no_memory, 16);
1898 	ASCEBC(iucv_error_pathid, 16);
1899 	iucv_available = 1;
1900 	rc = bus_register(&iucv_bus);
1901 	if (rc)
1902 		goto out_reboot;
1903 	iucv_if.root = iucv_root;
1904 	iucv_if.bus = &iucv_bus;
1905 	return 0;
1906 
1907 out_reboot:
1908 	unregister_reboot_notifier(&iucv_reboot_notifier);
1909 out_remove_hp:
1910 	cpuhp_remove_state(iucv_online);
1911 out_prep:
1912 	cpuhp_remove_state(CPUHP_NET_IUCV_PREPARE);
1913 out_dev:
1914 	root_device_unregister(iucv_root);
1915 out_int:
1916 	unregister_external_irq(EXT_IRQ_IUCV, iucv_external_interrupt);
1917 out_ctl:
1918 	system_ctl_clear_bit(0, 1);
1919 out:
1920 	return rc;
1921 }
1922 
1923 /**
1924  * iucv_exit - Frees everything allocated from iucv_init.
1925  */
1926 static void __exit iucv_exit(void)
1927 {
1928 	struct iucv_irq_list *p, *n;
1929 
1930 	spin_lock_irq(&iucv_queue_lock);
1931 	list_for_each_entry_safe(p, n, &iucv_task_queue, list)
1932 		kfree(p);
1933 	list_for_each_entry_safe(p, n, &iucv_work_queue, list)
1934 		kfree(p);
1935 	spin_unlock_irq(&iucv_queue_lock);
1936 	unregister_reboot_notifier(&iucv_reboot_notifier);
1937 
1938 	cpuhp_remove_state_nocalls(iucv_online);
1939 	cpuhp_remove_state(CPUHP_NET_IUCV_PREPARE);
1940 	root_device_unregister(iucv_root);
1941 	bus_unregister(&iucv_bus);
1942 	unregister_external_irq(EXT_IRQ_IUCV, iucv_external_interrupt);
1943 }
1944 
1945 subsys_initcall(iucv_init);
1946 module_exit(iucv_exit);
1947 
1948 MODULE_AUTHOR("(C) 2001 IBM Corp. by Fritz Elfert <felfert@millenux.com>");
1949 MODULE_DESCRIPTION("Linux for S/390 IUCV lowlevel driver");
1950 MODULE_LICENSE("GPL");
1951