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
];
286 * @code: identifier of IUCV call to CP.
287 * @parm: pointer to a struct iucv_parm block
289 * Calls CP to execute IUCV commands.
291 * Returns the result of the CP IUCV call.
293 static inline int iucv_call_b2f0(int command
, union iucv_param
*parm
)
295 register unsigned long reg0
asm ("0");
296 register unsigned long reg1
asm ("1");
300 reg1
= virt_to_phys(parm
);
302 " .long 0xb2f01000\n"
305 : "=d" (ccode
), "=m" (*parm
), "+d" (reg0
), "+a" (reg1
)
306 : "m" (*parm
) : "cc");
307 return (ccode
== 1) ? parm
->ctrl
.iprcode
: ccode
;
313 * Determines the maximum number of connections that may be established.
315 * Returns the maximum number of connections or -EPERM is IUCV is not
318 static int iucv_query_maxconn(void)
320 register unsigned long reg0
asm ("0");
321 register unsigned long reg1
asm ("1");
325 param
= kzalloc(sizeof(union iucv_param
), GFP_KERNEL
|GFP_DMA
);
329 reg1
= (unsigned long) param
;
331 " .long 0xb2f01000\n"
334 : "=d" (ccode
), "+d" (reg0
), "+d" (reg1
) : : "cc");
336 iucv_max_pathid
= reg0
;
338 return ccode
? -EPERM
: 0;
345 * Allow iucv interrupts on this cpu.
347 static void iucv_allow_cpu(void *data
)
349 int cpu
= smp_processor_id();
350 union iucv_param
*parm
;
353 * Enable all iucv interrupts.
354 * ipmask contains bits for the different interrupts
355 * 0x80 - Flag to allow nonpriority message pending interrupts
356 * 0x40 - Flag to allow priority message pending interrupts
357 * 0x20 - Flag to allow nonpriority message completion interrupts
358 * 0x10 - Flag to allow priority message completion interrupts
359 * 0x08 - Flag to allow IUCV control interrupts
361 parm
= iucv_param
[cpu
];
362 memset(parm
, 0, sizeof(union iucv_param
));
363 parm
->set_mask
.ipmask
= 0xf8;
364 iucv_call_b2f0(IUCV_SETMASK
, parm
);
366 /* Set indication that iucv interrupts are allowed for this cpu. */
367 cpu_set(cpu
, iucv_irq_cpumask
);
374 * Block iucv interrupts on this cpu.
376 static void iucv_block_cpu(void *data
)
378 int cpu
= smp_processor_id();
379 union iucv_param
*parm
;
381 /* Disable all iucv interrupts. */
382 parm
= iucv_param
[cpu
];
383 memset(parm
, 0, sizeof(union iucv_param
));
384 iucv_call_b2f0(IUCV_SETMASK
, parm
);
386 /* Clear indication that iucv interrupts are allowed for this cpu. */
387 cpu_clear(cpu
, iucv_irq_cpumask
);
394 * Declare a interrupt buffer on this cpu.
396 static void iucv_declare_cpu(void *data
)
398 int cpu
= smp_processor_id();
399 union iucv_param
*parm
;
402 if (cpu_isset(cpu
, iucv_buffer_cpumask
))
405 /* Declare interrupt buffer. */
406 parm
= iucv_param
[cpu
];
407 memset(parm
, 0, sizeof(union iucv_param
));
408 parm
->db
.ipbfadr1
= virt_to_phys(iucv_irq_data
[cpu
]);
409 rc
= iucv_call_b2f0(IUCV_DECLARE_BUFFER
, parm
);
411 char *err
= "Unknown";
414 err
= "Directory error";
417 err
= "Invalid length";
420 err
= "Buffer already exists";
423 err
= "Buffer overlap";
426 err
= "Paging or storage error";
429 pr_warning("Defining an interrupt buffer on CPU %i"
430 " failed with 0x%02x (%s)\n", cpu
, rc
, err
);
434 /* Set indication that an iucv buffer exists for this cpu. */
435 cpu_set(cpu
, iucv_buffer_cpumask
);
437 if (iucv_nonsmp_handler
== 0 || cpus_empty(iucv_irq_cpumask
))
438 /* Enable iucv interrupts on this cpu. */
439 iucv_allow_cpu(NULL
);
441 /* Disable iucv interrupts on this cpu. */
442 iucv_block_cpu(NULL
);
449 * Retrieve interrupt buffer on this cpu.
451 static void iucv_retrieve_cpu(void *data
)
453 int cpu
= smp_processor_id();
454 union iucv_param
*parm
;
456 if (!cpu_isset(cpu
, iucv_buffer_cpumask
))
459 /* Block iucv interrupts. */
460 iucv_block_cpu(NULL
);
462 /* Retrieve interrupt buffer. */
463 parm
= iucv_param
[cpu
];
464 iucv_call_b2f0(IUCV_RETRIEVE_BUFFER
, parm
);
466 /* Clear indication that an iucv buffer exists for this cpu. */
467 cpu_clear(cpu
, iucv_buffer_cpumask
);
473 * Allow iucv interrupts on all cpus.
475 static void iucv_setmask_mp(void)
480 for_each_online_cpu(cpu
)
481 /* Enable all cpus with a declared buffer. */
482 if (cpu_isset(cpu
, iucv_buffer_cpumask
) &&
483 !cpu_isset(cpu
, iucv_irq_cpumask
))
484 smp_call_function_single(cpu
, iucv_allow_cpu
,
492 * Allow iucv interrupts on a single cpu.
494 static void iucv_setmask_up(void)
499 /* Disable all cpu but the first in cpu_irq_cpumask. */
500 cpumask
= iucv_irq_cpumask
;
501 cpu_clear(first_cpu(iucv_irq_cpumask
), cpumask
);
502 for_each_cpu_mask_nr(cpu
, cpumask
)
503 smp_call_function_single(cpu
, iucv_block_cpu
, NULL
, 1);
509 * This function makes iucv ready for use. It allocates the pathid
510 * table, declares an iucv interrupt buffer and enables the iucv
511 * interrupts. Called when the first user has registered an iucv
514 static int iucv_enable(void)
521 alloc_size
= iucv_max_pathid
* sizeof(struct iucv_path
);
522 iucv_path_table
= kzalloc(alloc_size
, GFP_KERNEL
);
523 if (!iucv_path_table
)
525 /* Declare per cpu buffers. */
527 for_each_online_cpu(cpu
)
528 smp_call_function_single(cpu
, iucv_declare_cpu
, NULL
, 1);
529 if (cpus_empty(iucv_buffer_cpumask
))
530 /* No cpu could declare an iucv buffer. */
535 kfree(iucv_path_table
);
536 iucv_path_table
= NULL
;
544 * This function shuts down iucv. It disables iucv interrupts, retrieves
545 * the iucv interrupt buffer and frees the pathid table. Called after the
546 * last user unregister its iucv handler.
548 static void iucv_disable(void)
551 on_each_cpu(iucv_retrieve_cpu
, NULL
, 1);
552 kfree(iucv_path_table
);
553 iucv_path_table
= NULL
;
557 static int __cpuinit
iucv_cpu_notify(struct notifier_block
*self
,
558 unsigned long action
, void *hcpu
)
561 long cpu
= (long) hcpu
;
565 case CPU_UP_PREPARE_FROZEN
:
566 iucv_irq_data
[cpu
] = kmalloc_node(sizeof(struct iucv_irq_data
),
567 GFP_KERNEL
|GFP_DMA
, cpu_to_node(cpu
));
568 if (!iucv_irq_data
[cpu
])
570 iucv_param
[cpu
] = kmalloc_node(sizeof(union iucv_param
),
571 GFP_KERNEL
|GFP_DMA
, cpu_to_node(cpu
));
572 if (!iucv_param
[cpu
]) {
573 kfree(iucv_irq_data
[cpu
]);
574 iucv_irq_data
[cpu
] = NULL
;
578 case CPU_UP_CANCELED
:
579 case CPU_UP_CANCELED_FROZEN
:
581 case CPU_DEAD_FROZEN
:
582 kfree(iucv_param
[cpu
]);
583 iucv_param
[cpu
] = NULL
;
584 kfree(iucv_irq_data
[cpu
]);
585 iucv_irq_data
[cpu
] = NULL
;
588 case CPU_ONLINE_FROZEN
:
589 case CPU_DOWN_FAILED
:
590 case CPU_DOWN_FAILED_FROZEN
:
591 if (!iucv_path_table
)
593 smp_call_function_single(cpu
, iucv_declare_cpu
, NULL
, 1);
595 case CPU_DOWN_PREPARE
:
596 case CPU_DOWN_PREPARE_FROZEN
:
597 if (!iucv_path_table
)
599 cpumask
= iucv_buffer_cpumask
;
600 cpu_clear(cpu
, cpumask
);
601 if (cpus_empty(cpumask
))
602 /* Can't offline last IUCV enabled cpu. */
604 smp_call_function_single(cpu
, iucv_retrieve_cpu
, NULL
, 1);
605 if (cpus_empty(iucv_irq_cpumask
))
606 smp_call_function_single(first_cpu(iucv_buffer_cpumask
),
607 iucv_allow_cpu
, NULL
, 1);
613 static struct notifier_block __refdata iucv_cpu_notifier
= {
614 .notifier_call
= iucv_cpu_notify
,
619 * @pathid: path identification number.
620 * @userdata: 16-bytes of user data.
622 * Sever an iucv path to free up the pathid. Used internally.
624 static int iucv_sever_pathid(u16 pathid
, u8 userdata
[16])
626 union iucv_param
*parm
;
628 parm
= iucv_param
[smp_processor_id()];
629 memset(parm
, 0, sizeof(union iucv_param
));
631 memcpy(parm
->ctrl
.ipuser
, userdata
, sizeof(parm
->ctrl
.ipuser
));
632 parm
->ctrl
.ippathid
= pathid
;
633 return iucv_call_b2f0(IUCV_SEVER
, parm
);
637 * __iucv_cleanup_queue
638 * @dummy: unused dummy argument
640 * Nop function called via smp_call_function to force work items from
641 * pending external iucv interrupts to the work queue.
643 static void __iucv_cleanup_queue(void *dummy
)
650 * Function called after a path has been severed to find all remaining
651 * work items for the now stale pathid. The caller needs to hold the
654 static void iucv_cleanup_queue(void)
656 struct iucv_irq_list
*p
, *n
;
659 * When a path is severed, the pathid can be reused immediatly
660 * on a iucv connect or a connection pending interrupt. Remove
661 * all entries from the task queue that refer to a stale pathid
662 * (iucv_path_table[ix] == NULL). Only then do the iucv connect
663 * or deliver the connection pending interrupt. To get all the
664 * pending interrupts force them to the work queue by calling
665 * an empty function on all cpus.
667 smp_call_function(__iucv_cleanup_queue
, NULL
, 1);
668 spin_lock_irq(&iucv_queue_lock
);
669 list_for_each_entry_safe(p
, n
, &iucv_task_queue
, list
) {
670 /* Remove stale work items from the task queue. */
671 if (iucv_path_table
[p
->data
.ippathid
] == NULL
) {
676 spin_unlock_irq(&iucv_queue_lock
);
681 * @handler: address of iucv handler structure
682 * @smp: != 0 indicates that the handler can deal with out of order messages
684 * Registers a driver with IUCV.
686 * Returns 0 on success, -ENOMEM if the memory allocation for the pathid
687 * table failed, or -EIO if IUCV_DECLARE_BUFFER failed on all cpus.
689 int iucv_register(struct iucv_handler
*handler
, int smp
)
695 mutex_lock(&iucv_register_mutex
);
697 iucv_nonsmp_handler
++;
698 if (list_empty(&iucv_handler_list
)) {
702 } else if (!smp
&& iucv_nonsmp_handler
== 1)
704 INIT_LIST_HEAD(&handler
->paths
);
706 spin_lock_bh(&iucv_table_lock
);
707 list_add_tail(&handler
->list
, &iucv_handler_list
);
708 spin_unlock_bh(&iucv_table_lock
);
711 mutex_unlock(&iucv_register_mutex
);
714 EXPORT_SYMBOL(iucv_register
);
718 * @handler: address of iucv handler structure
719 * @smp: != 0 indicates that the handler can deal with out of order messages
721 * Unregister driver from IUCV.
723 void iucv_unregister(struct iucv_handler
*handler
, int smp
)
725 struct iucv_path
*p
, *n
;
727 mutex_lock(&iucv_register_mutex
);
728 spin_lock_bh(&iucv_table_lock
);
729 /* Remove handler from the iucv_handler_list. */
730 list_del_init(&handler
->list
);
731 /* Sever all pathids still refering to the handler. */
732 list_for_each_entry_safe(p
, n
, &handler
->paths
, list
) {
733 iucv_sever_pathid(p
->pathid
, NULL
);
734 iucv_path_table
[p
->pathid
] = NULL
;
738 spin_unlock_bh(&iucv_table_lock
);
740 iucv_nonsmp_handler
--;
741 if (list_empty(&iucv_handler_list
))
743 else if (!smp
&& iucv_nonsmp_handler
== 0)
745 mutex_unlock(&iucv_register_mutex
);
747 EXPORT_SYMBOL(iucv_unregister
);
751 * @path: address of iucv path structure
752 * @handler: address of iucv handler structure
753 * @userdata: 16 bytes of data reflected to the communication partner
754 * @private: private data passed to interrupt handlers for this path
756 * This function is issued after the user received a connection pending
757 * external interrupt and now wishes to complete the IUCV communication path.
759 * Returns the result of the CP IUCV call.
761 int iucv_path_accept(struct iucv_path
*path
, struct iucv_handler
*handler
,
762 u8 userdata
[16], void *private)
764 union iucv_param
*parm
;
768 /* Prepare parameter block. */
769 parm
= iucv_param
[smp_processor_id()];
770 memset(parm
, 0, sizeof(union iucv_param
));
771 parm
->ctrl
.ippathid
= path
->pathid
;
772 parm
->ctrl
.ipmsglim
= path
->msglim
;
774 memcpy(parm
->ctrl
.ipuser
, userdata
, sizeof(parm
->ctrl
.ipuser
));
775 parm
->ctrl
.ipflags1
= path
->flags
;
777 rc
= iucv_call_b2f0(IUCV_ACCEPT
, parm
);
779 path
->private = private;
780 path
->msglim
= parm
->ctrl
.ipmsglim
;
781 path
->flags
= parm
->ctrl
.ipflags1
;
786 EXPORT_SYMBOL(iucv_path_accept
);
790 * @path: address of iucv path structure
791 * @handler: address of iucv handler structure
792 * @userid: 8-byte user identification
793 * @system: 8-byte target system identification
794 * @userdata: 16 bytes of data reflected to the communication partner
795 * @private: private data passed to interrupt handlers for this path
797 * This function establishes an IUCV path. Although the connect may complete
798 * successfully, you are not able to use the path until you receive an IUCV
799 * Connection Complete external interrupt.
801 * Returns the result of the CP IUCV call.
803 int iucv_path_connect(struct iucv_path
*path
, struct iucv_handler
*handler
,
804 u8 userid
[8], u8 system
[8], u8 userdata
[16],
807 union iucv_param
*parm
;
810 spin_lock_bh(&iucv_table_lock
);
811 iucv_cleanup_queue();
812 parm
= iucv_param
[smp_processor_id()];
813 memset(parm
, 0, sizeof(union iucv_param
));
814 parm
->ctrl
.ipmsglim
= path
->msglim
;
815 parm
->ctrl
.ipflags1
= path
->flags
;
817 memcpy(parm
->ctrl
.ipvmid
, userid
, sizeof(parm
->ctrl
.ipvmid
));
818 ASCEBC(parm
->ctrl
.ipvmid
, sizeof(parm
->ctrl
.ipvmid
));
819 EBC_TOUPPER(parm
->ctrl
.ipvmid
, sizeof(parm
->ctrl
.ipvmid
));
822 memcpy(parm
->ctrl
.iptarget
, system
,
823 sizeof(parm
->ctrl
.iptarget
));
824 ASCEBC(parm
->ctrl
.iptarget
, sizeof(parm
->ctrl
.iptarget
));
825 EBC_TOUPPER(parm
->ctrl
.iptarget
, sizeof(parm
->ctrl
.iptarget
));
828 memcpy(parm
->ctrl
.ipuser
, userdata
, sizeof(parm
->ctrl
.ipuser
));
830 rc
= iucv_call_b2f0(IUCV_CONNECT
, parm
);
832 if (parm
->ctrl
.ippathid
< iucv_max_pathid
) {
833 path
->pathid
= parm
->ctrl
.ippathid
;
834 path
->msglim
= parm
->ctrl
.ipmsglim
;
835 path
->flags
= parm
->ctrl
.ipflags1
;
836 path
->handler
= handler
;
837 path
->private = private;
838 list_add_tail(&path
->list
, &handler
->paths
);
839 iucv_path_table
[path
->pathid
] = path
;
841 iucv_sever_pathid(parm
->ctrl
.ippathid
,
846 spin_unlock_bh(&iucv_table_lock
);
849 EXPORT_SYMBOL(iucv_path_connect
);
853 * @path: address of iucv path structure
854 * @userdata: 16 bytes of data reflected to the communication partner
856 * This function temporarily suspends incoming messages on an IUCV path.
857 * You can later reactivate the path by invoking the iucv_resume function.
859 * Returns the result from the CP IUCV call.
861 int iucv_path_quiesce(struct iucv_path
*path
, u8 userdata
[16])
863 union iucv_param
*parm
;
867 parm
= iucv_param
[smp_processor_id()];
868 memset(parm
, 0, sizeof(union iucv_param
));
870 memcpy(parm
->ctrl
.ipuser
, userdata
, sizeof(parm
->ctrl
.ipuser
));
871 parm
->ctrl
.ippathid
= path
->pathid
;
872 rc
= iucv_call_b2f0(IUCV_QUIESCE
, parm
);
876 EXPORT_SYMBOL(iucv_path_quiesce
);
880 * @path: address of iucv path structure
881 * @userdata: 16 bytes of data reflected to the communication partner
883 * This function resumes incoming messages on an IUCV path that has
884 * been stopped with iucv_path_quiesce.
886 * Returns the result from the CP IUCV call.
888 int iucv_path_resume(struct iucv_path
*path
, u8 userdata
[16])
890 union iucv_param
*parm
;
894 parm
= iucv_param
[smp_processor_id()];
895 memset(parm
, 0, sizeof(union iucv_param
));
897 memcpy(parm
->ctrl
.ipuser
, userdata
, sizeof(parm
->ctrl
.ipuser
));
898 parm
->ctrl
.ippathid
= path
->pathid
;
899 rc
= iucv_call_b2f0(IUCV_RESUME
, parm
);
906 * @path: address of iucv path structure
907 * @userdata: 16 bytes of data reflected to the communication partner
909 * This function terminates an IUCV path.
911 * Returns the result from the CP IUCV call.
913 int iucv_path_sever(struct iucv_path
*path
, u8 userdata
[16])
918 if (iucv_active_cpu
!= smp_processor_id())
919 spin_lock_bh(&iucv_table_lock
);
920 rc
= iucv_sever_pathid(path
->pathid
, userdata
);
922 iucv_path_table
[path
->pathid
] = NULL
;
923 list_del_init(&path
->list
);
925 if (iucv_active_cpu
!= smp_processor_id())
926 spin_unlock_bh(&iucv_table_lock
);
930 EXPORT_SYMBOL(iucv_path_sever
);
934 * @path: address of iucv path structure
935 * @msg: address of iucv msg structure
936 * @srccls: source class of message
938 * Cancels a message you have sent.
940 * Returns the result from the CP IUCV call.
942 int iucv_message_purge(struct iucv_path
*path
, struct iucv_message
*msg
,
945 union iucv_param
*parm
;
949 parm
= iucv_param
[smp_processor_id()];
950 memset(parm
, 0, sizeof(union iucv_param
));
951 parm
->purge
.ippathid
= path
->pathid
;
952 parm
->purge
.ipmsgid
= msg
->id
;
953 parm
->purge
.ipsrccls
= srccls
;
954 parm
->purge
.ipflags1
= IUCV_IPSRCCLS
| IUCV_IPFGMID
| IUCV_IPFGPID
;
955 rc
= iucv_call_b2f0(IUCV_PURGE
, parm
);
957 msg
->audit
= (*(u32
*) &parm
->purge
.ipaudit
) >> 8;
958 msg
->tag
= parm
->purge
.ipmsgtag
;
963 EXPORT_SYMBOL(iucv_message_purge
);
966 * iucv_message_receive_iprmdata
967 * @path: address of iucv path structure
968 * @msg: address of iucv msg structure
969 * @flags: how the message is received (IUCV_IPBUFLST)
970 * @buffer: address of data buffer or address of struct iucv_array
971 * @size: length of data buffer
974 * Internal function used by iucv_message_receive and __iucv_message_receive
975 * to receive RMDATA data stored in struct iucv_message.
977 static int iucv_message_receive_iprmdata(struct iucv_path
*path
,
978 struct iucv_message
*msg
,
979 u8 flags
, void *buffer
,
980 size_t size
, size_t *residual
)
982 struct iucv_array
*array
;
987 * Message is 8 bytes long and has been stored to the
988 * message descriptor itself.
991 *residual
= abs(size
- 8);
993 if (flags
& IUCV_IPBUFLST
) {
994 /* Copy to struct iucv_array. */
995 size
= (size
< 8) ? size
: 8;
996 for (array
= buffer
; size
> 0; array
++) {
997 copy
= min_t(size_t, size
, array
->length
);
998 memcpy((u8
*)(addr_t
) array
->address
,
1004 /* Copy to direct buffer. */
1005 memcpy(buffer
, rmmsg
, min_t(size_t, size
, 8));
1011 * __iucv_message_receive
1012 * @path: address of iucv path structure
1013 * @msg: address of iucv msg structure
1014 * @flags: how the message is received (IUCV_IPBUFLST)
1015 * @buffer: address of data buffer or address of struct iucv_array
1016 * @size: length of data buffer
1019 * This function receives messages that are being sent to you over
1020 * established paths. This function will deal with RMDATA messages
1021 * embedded in struct iucv_message as well.
1023 * Locking: no locking
1025 * Returns the result from the CP IUCV call.
1027 int __iucv_message_receive(struct iucv_path
*path
, struct iucv_message
*msg
,
1028 u8 flags
, void *buffer
, size_t size
, size_t *residual
)
1030 union iucv_param
*parm
;
1033 if (msg
->flags
& IUCV_IPRMDATA
)
1034 return iucv_message_receive_iprmdata(path
, msg
, flags
,
1035 buffer
, size
, residual
);
1036 parm
= iucv_param
[smp_processor_id()];
1037 memset(parm
, 0, sizeof(union iucv_param
));
1038 parm
->db
.ipbfadr1
= (u32
)(addr_t
) buffer
;
1039 parm
->db
.ipbfln1f
= (u32
) size
;
1040 parm
->db
.ipmsgid
= msg
->id
;
1041 parm
->db
.ippathid
= path
->pathid
;
1042 parm
->db
.iptrgcls
= msg
->class;
1043 parm
->db
.ipflags1
= (flags
| IUCV_IPFGPID
|
1044 IUCV_IPFGMID
| IUCV_IPTRGCLS
);
1045 rc
= iucv_call_b2f0(IUCV_RECEIVE
, parm
);
1046 if (!rc
|| rc
== 5) {
1047 msg
->flags
= parm
->db
.ipflags1
;
1049 *residual
= parm
->db
.ipbfln1f
;
1053 EXPORT_SYMBOL(__iucv_message_receive
);
1056 * iucv_message_receive
1057 * @path: address of iucv path structure
1058 * @msg: address of iucv msg structure
1059 * @flags: how the message is received (IUCV_IPBUFLST)
1060 * @buffer: address of data buffer or address of struct iucv_array
1061 * @size: length of data buffer
1064 * This function receives messages that are being sent to you over
1065 * established paths. This function will deal with RMDATA messages
1066 * embedded in struct iucv_message as well.
1068 * Locking: local_bh_enable/local_bh_disable
1070 * Returns the result from the CP IUCV call.
1072 int iucv_message_receive(struct iucv_path
*path
, struct iucv_message
*msg
,
1073 u8 flags
, void *buffer
, size_t size
, size_t *residual
)
1077 if (msg
->flags
& IUCV_IPRMDATA
)
1078 return iucv_message_receive_iprmdata(path
, msg
, flags
,
1079 buffer
, size
, residual
);
1081 rc
= __iucv_message_receive(path
, msg
, flags
, buffer
, size
, residual
);
1085 EXPORT_SYMBOL(iucv_message_receive
);
1088 * iucv_message_reject
1089 * @path: address of iucv path structure
1090 * @msg: address of iucv msg structure
1092 * The reject function refuses a specified message. Between the time you
1093 * are notified of a message and the time that you complete the message,
1094 * the message may be rejected.
1096 * Returns the result from the CP IUCV call.
1098 int iucv_message_reject(struct iucv_path
*path
, struct iucv_message
*msg
)
1100 union iucv_param
*parm
;
1104 parm
= iucv_param
[smp_processor_id()];
1105 memset(parm
, 0, sizeof(union iucv_param
));
1106 parm
->db
.ippathid
= path
->pathid
;
1107 parm
->db
.ipmsgid
= msg
->id
;
1108 parm
->db
.iptrgcls
= msg
->class;
1109 parm
->db
.ipflags1
= (IUCV_IPTRGCLS
| IUCV_IPFGMID
| IUCV_IPFGPID
);
1110 rc
= iucv_call_b2f0(IUCV_REJECT
, parm
);
1114 EXPORT_SYMBOL(iucv_message_reject
);
1117 * iucv_message_reply
1118 * @path: address of iucv path structure
1119 * @msg: address of iucv msg structure
1120 * @flags: how the reply is sent (IUCV_IPRMDATA, IUCV_IPPRTY, IUCV_IPBUFLST)
1121 * @reply: address of reply data buffer or address of struct iucv_array
1122 * @size: length of reply data buffer
1124 * This function responds to the two-way messages that you receive. You
1125 * must identify completely the message to which you wish to reply. ie,
1126 * pathid, msgid, and trgcls. Prmmsg signifies the data is moved into
1127 * the parameter list.
1129 * Returns the result from the CP IUCV call.
1131 int iucv_message_reply(struct iucv_path
*path
, struct iucv_message
*msg
,
1132 u8 flags
, void *reply
, size_t size
)
1134 union iucv_param
*parm
;
1138 parm
= iucv_param
[smp_processor_id()];
1139 memset(parm
, 0, sizeof(union iucv_param
));
1140 if (flags
& IUCV_IPRMDATA
) {
1141 parm
->dpl
.ippathid
= path
->pathid
;
1142 parm
->dpl
.ipflags1
= flags
;
1143 parm
->dpl
.ipmsgid
= msg
->id
;
1144 parm
->dpl
.iptrgcls
= msg
->class;
1145 memcpy(parm
->dpl
.iprmmsg
, reply
, min_t(size_t, size
, 8));
1147 parm
->db
.ipbfadr1
= (u32
)(addr_t
) reply
;
1148 parm
->db
.ipbfln1f
= (u32
) size
;
1149 parm
->db
.ippathid
= path
->pathid
;
1150 parm
->db
.ipflags1
= flags
;
1151 parm
->db
.ipmsgid
= msg
->id
;
1152 parm
->db
.iptrgcls
= msg
->class;
1154 rc
= iucv_call_b2f0(IUCV_REPLY
, parm
);
1158 EXPORT_SYMBOL(iucv_message_reply
);
1161 * __iucv_message_send
1162 * @path: address of iucv path structure
1163 * @msg: address of iucv msg structure
1164 * @flags: how the message is sent (IUCV_IPRMDATA, IUCV_IPPRTY, IUCV_IPBUFLST)
1165 * @srccls: source class of message
1166 * @buffer: address of send buffer or address of struct iucv_array
1167 * @size: length of send buffer
1169 * This function transmits data to another application. Data to be
1170 * transmitted is in a buffer and this is a one-way message and the
1171 * receiver will not reply to the message.
1173 * Locking: no locking
1175 * Returns the result from the CP IUCV call.
1177 int __iucv_message_send(struct iucv_path
*path
, struct iucv_message
*msg
,
1178 u8 flags
, u32 srccls
, void *buffer
, size_t size
)
1180 union iucv_param
*parm
;
1183 parm
= iucv_param
[smp_processor_id()];
1184 memset(parm
, 0, sizeof(union iucv_param
));
1185 if (flags
& IUCV_IPRMDATA
) {
1186 /* Message of 8 bytes can be placed into the parameter list. */
1187 parm
->dpl
.ippathid
= path
->pathid
;
1188 parm
->dpl
.ipflags1
= flags
| IUCV_IPNORPY
;
1189 parm
->dpl
.iptrgcls
= msg
->class;
1190 parm
->dpl
.ipsrccls
= srccls
;
1191 parm
->dpl
.ipmsgtag
= msg
->tag
;
1192 memcpy(parm
->dpl
.iprmmsg
, buffer
, 8);
1194 parm
->db
.ipbfadr1
= (u32
)(addr_t
) buffer
;
1195 parm
->db
.ipbfln1f
= (u32
) size
;
1196 parm
->db
.ippathid
= path
->pathid
;
1197 parm
->db
.ipflags1
= flags
| IUCV_IPNORPY
;
1198 parm
->db
.iptrgcls
= msg
->class;
1199 parm
->db
.ipsrccls
= srccls
;
1200 parm
->db
.ipmsgtag
= msg
->tag
;
1202 rc
= iucv_call_b2f0(IUCV_SEND
, parm
);
1204 msg
->id
= parm
->db
.ipmsgid
;
1207 EXPORT_SYMBOL(__iucv_message_send
);
1211 * @path: address of iucv path structure
1212 * @msg: address of iucv msg structure
1213 * @flags: how the message is sent (IUCV_IPRMDATA, IUCV_IPPRTY, IUCV_IPBUFLST)
1214 * @srccls: source class of message
1215 * @buffer: address of send buffer or address of struct iucv_array
1216 * @size: length of send buffer
1218 * This function transmits data to another application. Data to be
1219 * transmitted is in a buffer and this is a one-way message and the
1220 * receiver will not reply to the message.
1222 * Locking: local_bh_enable/local_bh_disable
1224 * Returns the result from the CP IUCV call.
1226 int iucv_message_send(struct iucv_path
*path
, struct iucv_message
*msg
,
1227 u8 flags
, u32 srccls
, void *buffer
, size_t size
)
1232 rc
= __iucv_message_send(path
, msg
, flags
, srccls
, buffer
, size
);
1236 EXPORT_SYMBOL(iucv_message_send
);
1239 * iucv_message_send2way
1240 * @path: address of iucv path structure
1241 * @msg: address of iucv msg structure
1242 * @flags: how the message is sent and the reply is received
1243 * (IUCV_IPRMDATA, IUCV_IPBUFLST, IUCV_IPPRTY, IUCV_ANSLST)
1244 * @srccls: source class of message
1245 * @buffer: address of send buffer or address of struct iucv_array
1246 * @size: length of send buffer
1247 * @ansbuf: address of answer buffer or address of struct iucv_array
1248 * @asize: size of reply buffer
1250 * This function transmits data to another application. Data to be
1251 * transmitted is in a buffer. The receiver of the send is expected to
1252 * reply to the message and a buffer is provided into which IUCV moves
1253 * the reply to this message.
1255 * Returns the result from the CP IUCV call.
1257 int iucv_message_send2way(struct iucv_path
*path
, struct iucv_message
*msg
,
1258 u8 flags
, u32 srccls
, void *buffer
, size_t size
,
1259 void *answer
, size_t asize
, size_t *residual
)
1261 union iucv_param
*parm
;
1265 parm
= iucv_param
[smp_processor_id()];
1266 memset(parm
, 0, sizeof(union iucv_param
));
1267 if (flags
& IUCV_IPRMDATA
) {
1268 parm
->dpl
.ippathid
= path
->pathid
;
1269 parm
->dpl
.ipflags1
= path
->flags
; /* priority message */
1270 parm
->dpl
.iptrgcls
= msg
->class;
1271 parm
->dpl
.ipsrccls
= srccls
;
1272 parm
->dpl
.ipmsgtag
= msg
->tag
;
1273 parm
->dpl
.ipbfadr2
= (u32
)(addr_t
) answer
;
1274 parm
->dpl
.ipbfln2f
= (u32
) asize
;
1275 memcpy(parm
->dpl
.iprmmsg
, buffer
, 8);
1277 parm
->db
.ippathid
= path
->pathid
;
1278 parm
->db
.ipflags1
= path
->flags
; /* priority message */
1279 parm
->db
.iptrgcls
= msg
->class;
1280 parm
->db
.ipsrccls
= srccls
;
1281 parm
->db
.ipmsgtag
= msg
->tag
;
1282 parm
->db
.ipbfadr1
= (u32
)(addr_t
) buffer
;
1283 parm
->db
.ipbfln1f
= (u32
) size
;
1284 parm
->db
.ipbfadr2
= (u32
)(addr_t
) answer
;
1285 parm
->db
.ipbfln2f
= (u32
) asize
;
1287 rc
= iucv_call_b2f0(IUCV_SEND
, parm
);
1289 msg
->id
= parm
->db
.ipmsgid
;
1293 EXPORT_SYMBOL(iucv_message_send2way
);
1297 * @data: Pointer to external interrupt buffer
1299 * Process connection pending work item. Called from tasklet while holding
1302 struct iucv_path_pending
{
1313 } __attribute__ ((packed
));
1315 static void iucv_path_pending(struct iucv_irq_data
*data
)
1317 struct iucv_path_pending
*ipp
= (void *) data
;
1318 struct iucv_handler
*handler
;
1319 struct iucv_path
*path
;
1322 BUG_ON(iucv_path_table
[ipp
->ippathid
]);
1323 /* New pathid, handler found. Create a new path struct. */
1324 error
= iucv_error_no_memory
;
1325 path
= iucv_path_alloc(ipp
->ipmsglim
, ipp
->ipflags1
, GFP_ATOMIC
);
1328 path
->pathid
= ipp
->ippathid
;
1329 iucv_path_table
[path
->pathid
] = path
;
1330 EBCASC(ipp
->ipvmid
, 8);
1332 /* Call registered handler until one is found that wants the path. */
1333 list_for_each_entry(handler
, &iucv_handler_list
, list
) {
1334 if (!handler
->path_pending
)
1337 * Add path to handler to allow a call to iucv_path_sever
1338 * inside the path_pending function. If the handler returns
1339 * an error remove the path from the handler again.
1341 list_add(&path
->list
, &handler
->paths
);
1342 path
->handler
= handler
;
1343 if (!handler
->path_pending(path
, ipp
->ipvmid
, ipp
->ipuser
))
1345 list_del(&path
->list
);
1346 path
->handler
= NULL
;
1348 /* No handler wanted the path. */
1349 iucv_path_table
[path
->pathid
] = NULL
;
1350 iucv_path_free(path
);
1351 error
= iucv_error_no_listener
;
1353 iucv_sever_pathid(ipp
->ippathid
, error
);
1357 * iucv_path_complete
1358 * @data: Pointer to external interrupt buffer
1360 * Process connection complete work item. Called from tasklet while holding
1363 struct iucv_path_complete
{
1374 } __attribute__ ((packed
));
1376 static void iucv_path_complete(struct iucv_irq_data
*data
)
1378 struct iucv_path_complete
*ipc
= (void *) data
;
1379 struct iucv_path
*path
= iucv_path_table
[ipc
->ippathid
];
1381 if (path
&& path
->handler
&& path
->handler
->path_complete
)
1382 path
->handler
->path_complete(path
, ipc
->ipuser
);
1387 * @data: Pointer to external interrupt buffer
1389 * Process connection severed work item. Called from tasklet while holding
1392 struct iucv_path_severed
{
1402 } __attribute__ ((packed
));
1404 static void iucv_path_severed(struct iucv_irq_data
*data
)
1406 struct iucv_path_severed
*ips
= (void *) data
;
1407 struct iucv_path
*path
= iucv_path_table
[ips
->ippathid
];
1409 if (!path
|| !path
->handler
) /* Already severed */
1411 if (path
->handler
->path_severed
)
1412 path
->handler
->path_severed(path
, ips
->ipuser
);
1414 iucv_sever_pathid(path
->pathid
, NULL
);
1415 iucv_path_table
[path
->pathid
] = NULL
;
1416 list_del_init(&path
->list
);
1417 iucv_path_free(path
);
1422 * iucv_path_quiesced
1423 * @data: Pointer to external interrupt buffer
1425 * Process connection quiesced work item. Called from tasklet while holding
1428 struct iucv_path_quiesced
{
1438 } __attribute__ ((packed
));
1440 static void iucv_path_quiesced(struct iucv_irq_data
*data
)
1442 struct iucv_path_quiesced
*ipq
= (void *) data
;
1443 struct iucv_path
*path
= iucv_path_table
[ipq
->ippathid
];
1445 if (path
&& path
->handler
&& path
->handler
->path_quiesced
)
1446 path
->handler
->path_quiesced(path
, ipq
->ipuser
);
1451 * @data: Pointer to external interrupt buffer
1453 * Process connection resumed work item. Called from tasklet while holding
1456 struct iucv_path_resumed
{
1466 } __attribute__ ((packed
));
1468 static void iucv_path_resumed(struct iucv_irq_data
*data
)
1470 struct iucv_path_resumed
*ipr
= (void *) data
;
1471 struct iucv_path
*path
= iucv_path_table
[ipr
->ippathid
];
1473 if (path
&& path
->handler
&& path
->handler
->path_resumed
)
1474 path
->handler
->path_resumed(path
, ipr
->ipuser
);
1478 * iucv_message_complete
1479 * @data: Pointer to external interrupt buffer
1481 * Process message complete work item. Called from tasklet while holding
1484 struct iucv_message_complete
{
1497 } __attribute__ ((packed
));
1499 static void iucv_message_complete(struct iucv_irq_data
*data
)
1501 struct iucv_message_complete
*imc
= (void *) data
;
1502 struct iucv_path
*path
= iucv_path_table
[imc
->ippathid
];
1503 struct iucv_message msg
;
1505 if (path
&& path
->handler
&& path
->handler
->message_complete
) {
1506 msg
.flags
= imc
->ipflags1
;
1507 msg
.id
= imc
->ipmsgid
;
1508 msg
.audit
= imc
->ipaudit
;
1509 memcpy(msg
.rmmsg
, imc
->iprmmsg
, 8);
1510 msg
.class = imc
->ipsrccls
;
1511 msg
.tag
= imc
->ipmsgtag
;
1512 msg
.length
= imc
->ipbfln2f
;
1513 path
->handler
->message_complete(path
, &msg
);
1518 * iucv_message_pending
1519 * @data: Pointer to external interrupt buffer
1521 * Process message pending work item. Called from tasklet while holding
1524 struct iucv_message_pending
{
1542 } __attribute__ ((packed
));
1544 static void iucv_message_pending(struct iucv_irq_data
*data
)
1546 struct iucv_message_pending
*imp
= (void *) data
;
1547 struct iucv_path
*path
= iucv_path_table
[imp
->ippathid
];
1548 struct iucv_message msg
;
1550 if (path
&& path
->handler
&& path
->handler
->message_pending
) {
1551 msg
.flags
= imp
->ipflags1
;
1552 msg
.id
= imp
->ipmsgid
;
1553 msg
.class = imp
->iptrgcls
;
1554 if (imp
->ipflags1
& IUCV_IPRMDATA
) {
1555 memcpy(msg
.rmmsg
, imp
->ln1msg1
.iprmmsg1
, 8);
1558 msg
.length
= imp
->ln1msg2
.ipbfln1f
;
1559 msg
.reply_size
= imp
->ipbfln2f
;
1560 path
->handler
->message_pending(path
, &msg
);
1567 * This tasklet loops over the queue of irq buffers created by
1568 * iucv_external_interrupt, calls the appropriate action handler
1569 * and then frees the buffer.
1571 static void iucv_tasklet_fn(unsigned long ignored
)
1573 typedef void iucv_irq_fn(struct iucv_irq_data
*);
1574 static iucv_irq_fn
*irq_fn
[] = {
1575 [0x02] = iucv_path_complete
,
1576 [0x03] = iucv_path_severed
,
1577 [0x04] = iucv_path_quiesced
,
1578 [0x05] = iucv_path_resumed
,
1579 [0x06] = iucv_message_complete
,
1580 [0x07] = iucv_message_complete
,
1581 [0x08] = iucv_message_pending
,
1582 [0x09] = iucv_message_pending
,
1584 LIST_HEAD(task_queue
);
1585 struct iucv_irq_list
*p
, *n
;
1587 /* Serialize tasklet, iucv_path_sever and iucv_path_connect. */
1588 if (!spin_trylock(&iucv_table_lock
)) {
1589 tasklet_schedule(&iucv_tasklet
);
1592 iucv_active_cpu
= smp_processor_id();
1594 spin_lock_irq(&iucv_queue_lock
);
1595 list_splice_init(&iucv_task_queue
, &task_queue
);
1596 spin_unlock_irq(&iucv_queue_lock
);
1598 list_for_each_entry_safe(p
, n
, &task_queue
, list
) {
1599 list_del_init(&p
->list
);
1600 irq_fn
[p
->data
.iptype
](&p
->data
);
1604 iucv_active_cpu
= -1;
1605 spin_unlock(&iucv_table_lock
);
1611 * This work function loops over the queue of path pending irq blocks
1612 * created by iucv_external_interrupt, calls the appropriate action
1613 * handler and then frees the buffer.
1615 static void iucv_work_fn(struct work_struct
*work
)
1617 typedef void iucv_irq_fn(struct iucv_irq_data
*);
1618 LIST_HEAD(work_queue
);
1619 struct iucv_irq_list
*p
, *n
;
1621 /* Serialize tasklet, iucv_path_sever and iucv_path_connect. */
1622 spin_lock_bh(&iucv_table_lock
);
1623 iucv_active_cpu
= smp_processor_id();
1625 spin_lock_irq(&iucv_queue_lock
);
1626 list_splice_init(&iucv_work_queue
, &work_queue
);
1627 spin_unlock_irq(&iucv_queue_lock
);
1629 iucv_cleanup_queue();
1630 list_for_each_entry_safe(p
, n
, &work_queue
, list
) {
1631 list_del_init(&p
->list
);
1632 iucv_path_pending(&p
->data
);
1636 iucv_active_cpu
= -1;
1637 spin_unlock_bh(&iucv_table_lock
);
1641 * iucv_external_interrupt
1644 * Handles external interrupts coming in from CP.
1645 * Places the interrupt buffer on a queue and schedules iucv_tasklet_fn().
1647 static void iucv_external_interrupt(u16 code
)
1649 struct iucv_irq_data
*p
;
1650 struct iucv_irq_list
*work
;
1652 p
= iucv_irq_data
[smp_processor_id()];
1653 if (p
->ippathid
>= iucv_max_pathid
) {
1654 WARN_ON(p
->ippathid
>= iucv_max_pathid
);
1655 iucv_sever_pathid(p
->ippathid
, iucv_error_no_listener
);
1658 BUG_ON(p
->iptype
< 0x01 || p
->iptype
> 0x09);
1659 work
= kmalloc(sizeof(struct iucv_irq_list
), GFP_ATOMIC
);
1661 pr_warning("iucv_external_interrupt: out of memory\n");
1664 memcpy(&work
->data
, p
, sizeof(work
->data
));
1665 spin_lock(&iucv_queue_lock
);
1666 if (p
->iptype
== 0x01) {
1667 /* Path pending interrupt. */
1668 list_add_tail(&work
->list
, &iucv_work_queue
);
1669 schedule_work(&iucv_work
);
1671 /* The other interrupts. */
1672 list_add_tail(&work
->list
, &iucv_task_queue
);
1673 tasklet_schedule(&iucv_tasklet
);
1675 spin_unlock(&iucv_queue_lock
);
1681 * Allocates and initializes various data structures.
1683 static int __init
iucv_init(void)
1688 if (!MACHINE_IS_VM
) {
1689 rc
= -EPROTONOSUPPORT
;
1692 rc
= iucv_query_maxconn();
1695 rc
= register_external_interrupt(0x4000, iucv_external_interrupt
);
1698 iucv_root
= root_device_register("iucv");
1699 if (IS_ERR(iucv_root
)) {
1700 rc
= PTR_ERR(iucv_root
);
1704 for_each_online_cpu(cpu
) {
1705 /* Note: GFP_DMA used to get memory below 2G */
1706 iucv_irq_data
[cpu
] = kmalloc_node(sizeof(struct iucv_irq_data
),
1707 GFP_KERNEL
|GFP_DMA
, cpu_to_node(cpu
));
1708 if (!iucv_irq_data
[cpu
]) {
1713 /* Allocate parameter blocks. */
1714 iucv_param
[cpu
] = kmalloc_node(sizeof(union iucv_param
),
1715 GFP_KERNEL
|GFP_DMA
, cpu_to_node(cpu
));
1716 if (!iucv_param
[cpu
]) {
1721 rc
= register_hotcpu_notifier(&iucv_cpu_notifier
);
1724 ASCEBC(iucv_error_no_listener
, 16);
1725 ASCEBC(iucv_error_no_memory
, 16);
1726 ASCEBC(iucv_error_pathid
, 16);
1728 rc
= bus_register(&iucv_bus
);
1734 unregister_hotcpu_notifier(&iucv_cpu_notifier
);
1736 for_each_possible_cpu(cpu
) {
1737 kfree(iucv_param
[cpu
]);
1738 iucv_param
[cpu
] = NULL
;
1739 kfree(iucv_irq_data
[cpu
]);
1740 iucv_irq_data
[cpu
] = NULL
;
1742 root_device_unregister(iucv_root
);
1744 unregister_external_interrupt(0x4000, iucv_external_interrupt
);
1752 * Frees everything allocated from iucv_init.
1754 static void __exit
iucv_exit(void)
1756 struct iucv_irq_list
*p
, *n
;
1759 spin_lock_irq(&iucv_queue_lock
);
1760 list_for_each_entry_safe(p
, n
, &iucv_task_queue
, list
)
1762 list_for_each_entry_safe(p
, n
, &iucv_work_queue
, list
)
1764 spin_unlock_irq(&iucv_queue_lock
);
1765 unregister_hotcpu_notifier(&iucv_cpu_notifier
);
1766 for_each_possible_cpu(cpu
) {
1767 kfree(iucv_param
[cpu
]);
1768 iucv_param
[cpu
] = NULL
;
1769 kfree(iucv_irq_data
[cpu
]);
1770 iucv_irq_data
[cpu
] = NULL
;
1772 root_device_unregister(iucv_root
);
1773 bus_unregister(&iucv_bus
);
1774 unregister_external_interrupt(0x4000, iucv_external_interrupt
);
1777 subsys_initcall(iucv_init
);
1778 module_exit(iucv_exit
);
1780 MODULE_AUTHOR("(C) 2001 IBM Corp. by Fritz Elfert (felfert@millenux.com)");
1781 MODULE_DESCRIPTION("Linux for S/390 IUCV lowlevel driver");
1782 MODULE_LICENSE("GPL");