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>
53 #include <asm/s390_rdev.h>
58 * All flags are defined in the field IPFLAGS1 of each function
59 * and can be found in CP Programming Services.
60 * IPSRCCLS - Indicates you have specified a source class.
61 * IPTRGCLS - Indicates you have specified a target class.
62 * IPFGPID - Indicates you have specified a pathid.
63 * IPFGMID - Indicates you have specified a message ID.
64 * IPNORPY - Indicates a one-way message. No reply expected.
65 * IPALL - Indicates that all paths are affected.
67 #define IUCV_IPSRCCLS 0x01
68 #define IUCV_IPTRGCLS 0x01
69 #define IUCV_IPFGPID 0x02
70 #define IUCV_IPFGMID 0x04
71 #define IUCV_IPNORPY 0x10
72 #define IUCV_IPALL 0x80
74 static int iucv_bus_match(struct device
*dev
, struct device_driver
*drv
)
79 struct bus_type iucv_bus
= {
81 .match
= iucv_bus_match
,
83 EXPORT_SYMBOL(iucv_bus
);
85 struct device
*iucv_root
;
86 EXPORT_SYMBOL(iucv_root
);
88 static int iucv_available
;
90 /* General IUCV interrupt structure */
91 struct iucv_irq_data
{
98 struct iucv_irq_list
{
99 struct list_head list
;
100 struct iucv_irq_data data
;
103 static struct iucv_irq_data
*iucv_irq_data
[NR_CPUS
];
104 static cpumask_t iucv_buffer_cpumask
= CPU_MASK_NONE
;
105 static cpumask_t iucv_irq_cpumask
= CPU_MASK_NONE
;
108 * Queue of interrupt buffers lock for delivery via the tasklet
109 * (fast but can't call smp_call_function).
111 static LIST_HEAD(iucv_task_queue
);
114 * The tasklet for fast delivery of iucv interrupts.
116 static void iucv_tasklet_fn(unsigned long);
117 static DECLARE_TASKLET(iucv_tasklet
, iucv_tasklet_fn
,0);
120 * Queue of interrupt buffers for delivery via a work queue
121 * (slower but can call smp_call_function).
123 static LIST_HEAD(iucv_work_queue
);
126 * The work element to deliver path pending interrupts.
128 static void iucv_work_fn(struct work_struct
*work
);
129 static DECLARE_WORK(iucv_work
, iucv_work_fn
);
132 * Spinlock protecting task and work queue.
134 static DEFINE_SPINLOCK(iucv_queue_lock
);
136 enum iucv_command_codes
{
138 IUCV_RETRIEVE_BUFFER
= 2,
146 IUCV_DECLARE_BUFFER
= 12,
154 * Error messages that are used with the iucv_sever function. They get
155 * converted to EBCDIC.
157 static char iucv_error_no_listener
[16] = "NO LISTENER";
158 static char iucv_error_no_memory
[16] = "NO MEMORY";
159 static char iucv_error_pathid
[16] = "INVALID PATHID";
162 * iucv_handler_list: List of registered handlers.
164 static LIST_HEAD(iucv_handler_list
);
167 * iucv_path_table: an array of iucv_path structures.
169 static struct iucv_path
**iucv_path_table
;
170 static unsigned long iucv_max_pathid
;
173 * iucv_lock: spinlock protecting iucv_handler_list and iucv_pathid_table
175 static DEFINE_SPINLOCK(iucv_table_lock
);
178 * iucv_active_cpu: contains the number of the cpu executing the tasklet
179 * or the work handler. Needed for iucv_path_sever called from tasklet.
181 static int iucv_active_cpu
= -1;
184 * Mutex and wait queue for iucv_register/iucv_unregister.
186 static DEFINE_MUTEX(iucv_register_mutex
);
189 * Counter for number of non-smp capable handlers.
191 static int iucv_nonsmp_handler
;
194 * IUCV control data structure. Used by iucv_path_accept, iucv_path_connect,
195 * iucv_path_quiesce and iucv_path_sever.
197 struct iucv_cmd_control
{
206 } __attribute__ ((packed
,aligned(8)));
209 * Data in parameter list iucv structure. Used by iucv_message_send,
210 * iucv_message_send2way and iucv_message_reply.
212 struct iucv_cmd_dpl
{
224 } __attribute__ ((packed
,aligned(8)));
227 * Data in buffer iucv structure. Used by iucv_message_receive,
228 * iucv_message_reject, iucv_message_send, iucv_message_send2way
229 * and iucv_declare_cpu.
244 } __attribute__ ((packed
,aligned(8)));
247 * Purge message iucv structure. Used by iucv_message_purge.
249 struct iucv_cmd_purge
{
260 } __attribute__ ((packed
,aligned(8)));
263 * Set mask iucv structure. Used by iucv_enable_cpu.
265 struct iucv_cmd_set_mask
{
270 } __attribute__ ((packed
,aligned(8)));
273 struct iucv_cmd_control ctrl
;
274 struct iucv_cmd_dpl dpl
;
275 struct iucv_cmd_db db
;
276 struct iucv_cmd_purge purge
;
277 struct iucv_cmd_set_mask set_mask
;
281 * Anchor for per-cpu IUCV command parameter block.
283 static union iucv_param
*iucv_param
[NR_CPUS
];
287 * @code: identifier of IUCV call to CP.
288 * @parm: pointer to a struct iucv_parm block
290 * Calls CP to execute IUCV commands.
292 * Returns the result of the CP IUCV call.
294 static inline int iucv_call_b2f0(int command
, union iucv_param
*parm
)
296 register unsigned long reg0
asm ("0");
297 register unsigned long reg1
asm ("1");
301 reg1
= virt_to_phys(parm
);
303 " .long 0xb2f01000\n"
306 : "=d" (ccode
), "=m" (*parm
), "+d" (reg0
), "+a" (reg1
)
307 : "m" (*parm
) : "cc");
308 return (ccode
== 1) ? parm
->ctrl
.iprcode
: ccode
;
314 * Determines the maximum number of connections that may be established.
316 * Returns the maximum number of connections or -EPERM is IUCV is not
319 static int iucv_query_maxconn(void)
321 register unsigned long reg0
asm ("0");
322 register unsigned long reg1
asm ("1");
326 param
= kzalloc(sizeof(union iucv_param
), GFP_KERNEL
|GFP_DMA
);
330 reg1
= (unsigned long) param
;
332 " .long 0xb2f01000\n"
335 : "=d" (ccode
), "+d" (reg0
), "+d" (reg1
) : : "cc");
337 iucv_max_pathid
= reg0
;
339 return ccode
? -EPERM
: 0;
346 * Allow iucv interrupts on this cpu.
348 static void iucv_allow_cpu(void *data
)
350 int cpu
= smp_processor_id();
351 union iucv_param
*parm
;
354 * Enable all iucv interrupts.
355 * ipmask contains bits for the different interrupts
356 * 0x80 - Flag to allow nonpriority message pending interrupts
357 * 0x40 - Flag to allow priority message pending interrupts
358 * 0x20 - Flag to allow nonpriority message completion interrupts
359 * 0x10 - Flag to allow priority message completion interrupts
360 * 0x08 - Flag to allow IUCV control interrupts
362 parm
= iucv_param
[cpu
];
363 memset(parm
, 0, sizeof(union iucv_param
));
364 parm
->set_mask
.ipmask
= 0xf8;
365 iucv_call_b2f0(IUCV_SETMASK
, parm
);
367 /* Set indication that iucv interrupts are allowed for this cpu. */
368 cpu_set(cpu
, iucv_irq_cpumask
);
375 * Block iucv interrupts on this cpu.
377 static void iucv_block_cpu(void *data
)
379 int cpu
= smp_processor_id();
380 union iucv_param
*parm
;
382 /* Disable all iucv interrupts. */
383 parm
= iucv_param
[cpu
];
384 memset(parm
, 0, sizeof(union iucv_param
));
385 iucv_call_b2f0(IUCV_SETMASK
, parm
);
387 /* Clear indication that iucv interrupts are allowed for this cpu. */
388 cpu_clear(cpu
, iucv_irq_cpumask
);
395 * Declare a interrupt buffer on this cpu.
397 static void iucv_declare_cpu(void *data
)
399 int cpu
= smp_processor_id();
400 union iucv_param
*parm
;
403 if (cpu_isset(cpu
, iucv_buffer_cpumask
))
406 /* Declare interrupt buffer. */
407 parm
= iucv_param
[cpu
];
408 memset(parm
, 0, sizeof(union iucv_param
));
409 parm
->db
.ipbfadr1
= virt_to_phys(iucv_irq_data
[cpu
]);
410 rc
= iucv_call_b2f0(IUCV_DECLARE_BUFFER
, parm
);
412 char *err
= "Unknown";
415 err
= "Directory error";
418 err
= "Invalid length";
421 err
= "Buffer already exists";
424 err
= "Buffer overlap";
427 err
= "Paging or storage error";
430 pr_warning("Defining an interrupt buffer on CPU %i"
431 " failed with 0x%02x (%s)\n", cpu
, rc
, err
);
435 /* Set indication that an iucv buffer exists for this cpu. */
436 cpu_set(cpu
, iucv_buffer_cpumask
);
438 if (iucv_nonsmp_handler
== 0 || cpus_empty(iucv_irq_cpumask
))
439 /* Enable iucv interrupts on this cpu. */
440 iucv_allow_cpu(NULL
);
442 /* Disable iucv interrupts on this cpu. */
443 iucv_block_cpu(NULL
);
450 * Retrieve interrupt buffer on this cpu.
452 static void iucv_retrieve_cpu(void *data
)
454 int cpu
= smp_processor_id();
455 union iucv_param
*parm
;
457 if (!cpu_isset(cpu
, iucv_buffer_cpumask
))
460 /* Block iucv interrupts. */
461 iucv_block_cpu(NULL
);
463 /* Retrieve interrupt buffer. */
464 parm
= iucv_param
[cpu
];
465 iucv_call_b2f0(IUCV_RETRIEVE_BUFFER
, parm
);
467 /* Clear indication that an iucv buffer exists for this cpu. */
468 cpu_clear(cpu
, iucv_buffer_cpumask
);
474 * Allow iucv interrupts on all cpus.
476 static void iucv_setmask_mp(void)
481 for_each_online_cpu(cpu
)
482 /* Enable all cpus with a declared buffer. */
483 if (cpu_isset(cpu
, iucv_buffer_cpumask
) &&
484 !cpu_isset(cpu
, iucv_irq_cpumask
))
485 smp_call_function_single(cpu
, iucv_allow_cpu
,
493 * Allow iucv interrupts on a single cpu.
495 static void iucv_setmask_up(void)
500 /* Disable all cpu but the first in cpu_irq_cpumask. */
501 cpumask
= iucv_irq_cpumask
;
502 cpu_clear(first_cpu(iucv_irq_cpumask
), cpumask
);
503 for_each_cpu_mask_nr(cpu
, cpumask
)
504 smp_call_function_single(cpu
, iucv_block_cpu
, NULL
, 1);
510 * This function makes iucv ready for use. It allocates the pathid
511 * table, declares an iucv interrupt buffer and enables the iucv
512 * interrupts. Called when the first user has registered an iucv
515 static int iucv_enable(void)
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. */
528 for_each_online_cpu(cpu
)
529 smp_call_function_single(cpu
, iucv_declare_cpu
, NULL
, 1);
530 if (cpus_empty(iucv_buffer_cpumask
))
531 /* No cpu could declare an iucv buffer. */
538 kfree(iucv_path_table
);
546 * This function shuts down iucv. It disables iucv interrupts, retrieves
547 * the iucv interrupt buffer and frees the pathid table. Called after the
548 * last user unregister its iucv handler.
550 static void iucv_disable(void)
553 on_each_cpu(iucv_retrieve_cpu
, NULL
, 1);
555 kfree(iucv_path_table
);
558 static int __cpuinit
iucv_cpu_notify(struct notifier_block
*self
,
559 unsigned long action
, void *hcpu
)
562 long cpu
= (long) hcpu
;
566 case CPU_UP_PREPARE_FROZEN
:
567 iucv_irq_data
[cpu
] = kmalloc_node(sizeof(struct iucv_irq_data
),
568 GFP_KERNEL
|GFP_DMA
, cpu_to_node(cpu
));
569 if (!iucv_irq_data
[cpu
])
571 iucv_param
[cpu
] = kmalloc_node(sizeof(union iucv_param
),
572 GFP_KERNEL
|GFP_DMA
, cpu_to_node(cpu
));
573 if (!iucv_param
[cpu
]) {
574 kfree(iucv_irq_data
[cpu
]);
575 iucv_irq_data
[cpu
] = NULL
;
579 case CPU_UP_CANCELED
:
580 case CPU_UP_CANCELED_FROZEN
:
582 case CPU_DEAD_FROZEN
:
583 kfree(iucv_param
[cpu
]);
584 iucv_param
[cpu
] = NULL
;
585 kfree(iucv_irq_data
[cpu
]);
586 iucv_irq_data
[cpu
] = NULL
;
589 case CPU_ONLINE_FROZEN
:
590 case CPU_DOWN_FAILED
:
591 case CPU_DOWN_FAILED_FROZEN
:
592 smp_call_function_single(cpu
, iucv_declare_cpu
, NULL
, 1);
594 case CPU_DOWN_PREPARE
:
595 case CPU_DOWN_PREPARE_FROZEN
:
596 cpumask
= iucv_buffer_cpumask
;
597 cpu_clear(cpu
, cpumask
);
598 if (cpus_empty(cpumask
))
599 /* Can't offline last IUCV enabled cpu. */
601 smp_call_function_single(cpu
, iucv_retrieve_cpu
, NULL
, 1);
602 if (cpus_empty(iucv_irq_cpumask
))
603 smp_call_function_single(first_cpu(iucv_buffer_cpumask
),
604 iucv_allow_cpu
, NULL
, 1);
610 static struct notifier_block __refdata iucv_cpu_notifier
= {
611 .notifier_call
= iucv_cpu_notify
,
616 * @pathid: path identification number.
617 * @userdata: 16-bytes of user data.
619 * Sever an iucv path to free up the pathid. Used internally.
621 static int iucv_sever_pathid(u16 pathid
, u8 userdata
[16])
623 union iucv_param
*parm
;
625 parm
= iucv_param
[smp_processor_id()];
626 memset(parm
, 0, sizeof(union iucv_param
));
628 memcpy(parm
->ctrl
.ipuser
, userdata
, sizeof(parm
->ctrl
.ipuser
));
629 parm
->ctrl
.ippathid
= pathid
;
630 return iucv_call_b2f0(IUCV_SEVER
, parm
);
634 * __iucv_cleanup_queue
635 * @dummy: unused dummy argument
637 * Nop function called via smp_call_function to force work items from
638 * pending external iucv interrupts to the work queue.
640 static void __iucv_cleanup_queue(void *dummy
)
647 * Function called after a path has been severed to find all remaining
648 * work items for the now stale pathid. The caller needs to hold the
651 static void iucv_cleanup_queue(void)
653 struct iucv_irq_list
*p
, *n
;
656 * When a path is severed, the pathid can be reused immediatly
657 * on a iucv connect or a connection pending interrupt. Remove
658 * all entries from the task queue that refer to a stale pathid
659 * (iucv_path_table[ix] == NULL). Only then do the iucv connect
660 * or deliver the connection pending interrupt. To get all the
661 * pending interrupts force them to the work queue by calling
662 * an empty function on all cpus.
664 smp_call_function(__iucv_cleanup_queue
, NULL
, 1);
665 spin_lock_irq(&iucv_queue_lock
);
666 list_for_each_entry_safe(p
, n
, &iucv_task_queue
, list
) {
667 /* Remove stale work items from the task queue. */
668 if (iucv_path_table
[p
->data
.ippathid
] == NULL
) {
673 spin_unlock_irq(&iucv_queue_lock
);
678 * @handler: address of iucv handler structure
679 * @smp: != 0 indicates that the handler can deal with out of order messages
681 * Registers a driver with IUCV.
683 * Returns 0 on success, -ENOMEM if the memory allocation for the pathid
684 * table failed, or -EIO if IUCV_DECLARE_BUFFER failed on all cpus.
686 int iucv_register(struct iucv_handler
*handler
, int smp
)
692 mutex_lock(&iucv_register_mutex
);
694 iucv_nonsmp_handler
++;
695 if (list_empty(&iucv_handler_list
)) {
699 } else if (!smp
&& iucv_nonsmp_handler
== 1)
701 INIT_LIST_HEAD(&handler
->paths
);
703 spin_lock_bh(&iucv_table_lock
);
704 list_add_tail(&handler
->list
, &iucv_handler_list
);
705 spin_unlock_bh(&iucv_table_lock
);
708 mutex_unlock(&iucv_register_mutex
);
711 EXPORT_SYMBOL(iucv_register
);
715 * @handler: address of iucv handler structure
716 * @smp: != 0 indicates that the handler can deal with out of order messages
718 * Unregister driver from IUCV.
720 void iucv_unregister(struct iucv_handler
*handler
, int smp
)
722 struct iucv_path
*p
, *n
;
724 mutex_lock(&iucv_register_mutex
);
725 spin_lock_bh(&iucv_table_lock
);
726 /* Remove handler from the iucv_handler_list. */
727 list_del_init(&handler
->list
);
728 /* Sever all pathids still refering to the handler. */
729 list_for_each_entry_safe(p
, n
, &handler
->paths
, list
) {
730 iucv_sever_pathid(p
->pathid
, NULL
);
731 iucv_path_table
[p
->pathid
] = NULL
;
735 spin_unlock_bh(&iucv_table_lock
);
737 iucv_nonsmp_handler
--;
738 if (list_empty(&iucv_handler_list
))
740 else if (!smp
&& iucv_nonsmp_handler
== 0)
742 mutex_unlock(&iucv_register_mutex
);
744 EXPORT_SYMBOL(iucv_unregister
);
748 * @path: address of iucv path structure
749 * @handler: address of iucv handler structure
750 * @userdata: 16 bytes of data reflected to the communication partner
751 * @private: private data passed to interrupt handlers for this path
753 * This function is issued after the user received a connection pending
754 * external interrupt and now wishes to complete the IUCV communication path.
756 * Returns the result of the CP IUCV call.
758 int iucv_path_accept(struct iucv_path
*path
, struct iucv_handler
*handler
,
759 u8 userdata
[16], void *private)
761 union iucv_param
*parm
;
765 /* Prepare parameter block. */
766 parm
= iucv_param
[smp_processor_id()];
767 memset(parm
, 0, sizeof(union iucv_param
));
768 parm
->ctrl
.ippathid
= path
->pathid
;
769 parm
->ctrl
.ipmsglim
= path
->msglim
;
771 memcpy(parm
->ctrl
.ipuser
, userdata
, sizeof(parm
->ctrl
.ipuser
));
772 parm
->ctrl
.ipflags1
= path
->flags
;
774 rc
= iucv_call_b2f0(IUCV_ACCEPT
, parm
);
776 path
->private = private;
777 path
->msglim
= parm
->ctrl
.ipmsglim
;
778 path
->flags
= parm
->ctrl
.ipflags1
;
783 EXPORT_SYMBOL(iucv_path_accept
);
787 * @path: address of iucv path structure
788 * @handler: address of iucv handler structure
789 * @userid: 8-byte user identification
790 * @system: 8-byte target system identification
791 * @userdata: 16 bytes of data reflected to the communication partner
792 * @private: private data passed to interrupt handlers for this path
794 * This function establishes an IUCV path. Although the connect may complete
795 * successfully, you are not able to use the path until you receive an IUCV
796 * Connection Complete external interrupt.
798 * Returns the result of the CP IUCV call.
800 int iucv_path_connect(struct iucv_path
*path
, struct iucv_handler
*handler
,
801 u8 userid
[8], u8 system
[8], u8 userdata
[16],
804 union iucv_param
*parm
;
807 spin_lock_bh(&iucv_table_lock
);
808 iucv_cleanup_queue();
809 parm
= iucv_param
[smp_processor_id()];
810 memset(parm
, 0, sizeof(union iucv_param
));
811 parm
->ctrl
.ipmsglim
= path
->msglim
;
812 parm
->ctrl
.ipflags1
= path
->flags
;
814 memcpy(parm
->ctrl
.ipvmid
, userid
, sizeof(parm
->ctrl
.ipvmid
));
815 ASCEBC(parm
->ctrl
.ipvmid
, sizeof(parm
->ctrl
.ipvmid
));
816 EBC_TOUPPER(parm
->ctrl
.ipvmid
, sizeof(parm
->ctrl
.ipvmid
));
819 memcpy(parm
->ctrl
.iptarget
, system
,
820 sizeof(parm
->ctrl
.iptarget
));
821 ASCEBC(parm
->ctrl
.iptarget
, sizeof(parm
->ctrl
.iptarget
));
822 EBC_TOUPPER(parm
->ctrl
.iptarget
, sizeof(parm
->ctrl
.iptarget
));
825 memcpy(parm
->ctrl
.ipuser
, userdata
, sizeof(parm
->ctrl
.ipuser
));
827 rc
= iucv_call_b2f0(IUCV_CONNECT
, parm
);
829 if (parm
->ctrl
.ippathid
< iucv_max_pathid
) {
830 path
->pathid
= parm
->ctrl
.ippathid
;
831 path
->msglim
= parm
->ctrl
.ipmsglim
;
832 path
->flags
= parm
->ctrl
.ipflags1
;
833 path
->handler
= handler
;
834 path
->private = private;
835 list_add_tail(&path
->list
, &handler
->paths
);
836 iucv_path_table
[path
->pathid
] = path
;
838 iucv_sever_pathid(parm
->ctrl
.ippathid
,
843 spin_unlock_bh(&iucv_table_lock
);
846 EXPORT_SYMBOL(iucv_path_connect
);
850 * @path: address of iucv path structure
851 * @userdata: 16 bytes of data reflected to the communication partner
853 * This function temporarily suspends incoming messages on an IUCV path.
854 * You can later reactivate the path by invoking the iucv_resume function.
856 * Returns the result from the CP IUCV call.
858 int iucv_path_quiesce(struct iucv_path
*path
, u8 userdata
[16])
860 union iucv_param
*parm
;
864 parm
= iucv_param
[smp_processor_id()];
865 memset(parm
, 0, sizeof(union iucv_param
));
867 memcpy(parm
->ctrl
.ipuser
, userdata
, sizeof(parm
->ctrl
.ipuser
));
868 parm
->ctrl
.ippathid
= path
->pathid
;
869 rc
= iucv_call_b2f0(IUCV_QUIESCE
, parm
);
873 EXPORT_SYMBOL(iucv_path_quiesce
);
877 * @path: address of iucv path structure
878 * @userdata: 16 bytes of data reflected to the communication partner
880 * This function resumes incoming messages on an IUCV path that has
881 * been stopped with iucv_path_quiesce.
883 * Returns the result from the CP IUCV call.
885 int iucv_path_resume(struct iucv_path
*path
, u8 userdata
[16])
887 union iucv_param
*parm
;
891 parm
= iucv_param
[smp_processor_id()];
892 memset(parm
, 0, sizeof(union iucv_param
));
894 memcpy(parm
->ctrl
.ipuser
, userdata
, sizeof(parm
->ctrl
.ipuser
));
895 parm
->ctrl
.ippathid
= path
->pathid
;
896 rc
= iucv_call_b2f0(IUCV_RESUME
, parm
);
903 * @path: address of iucv path structure
904 * @userdata: 16 bytes of data reflected to the communication partner
906 * This function terminates an IUCV path.
908 * Returns the result from the CP IUCV call.
910 int iucv_path_sever(struct iucv_path
*path
, u8 userdata
[16])
915 if (iucv_active_cpu
!= smp_processor_id())
916 spin_lock_bh(&iucv_table_lock
);
917 rc
= iucv_sever_pathid(path
->pathid
, userdata
);
919 iucv_path_table
[path
->pathid
] = NULL
;
920 list_del_init(&path
->list
);
922 if (iucv_active_cpu
!= smp_processor_id())
923 spin_unlock_bh(&iucv_table_lock
);
927 EXPORT_SYMBOL(iucv_path_sever
);
931 * @path: address of iucv path structure
932 * @msg: address of iucv msg structure
933 * @srccls: source class of message
935 * Cancels a message you have sent.
937 * Returns the result from the CP IUCV call.
939 int iucv_message_purge(struct iucv_path
*path
, struct iucv_message
*msg
,
942 union iucv_param
*parm
;
946 parm
= iucv_param
[smp_processor_id()];
947 memset(parm
, 0, sizeof(union iucv_param
));
948 parm
->purge
.ippathid
= path
->pathid
;
949 parm
->purge
.ipmsgid
= msg
->id
;
950 parm
->purge
.ipsrccls
= srccls
;
951 parm
->purge
.ipflags1
= IUCV_IPSRCCLS
| IUCV_IPFGMID
| IUCV_IPFGPID
;
952 rc
= iucv_call_b2f0(IUCV_PURGE
, parm
);
954 msg
->audit
= (*(u32
*) &parm
->purge
.ipaudit
) >> 8;
955 msg
->tag
= parm
->purge
.ipmsgtag
;
960 EXPORT_SYMBOL(iucv_message_purge
);
963 * iucv_message_receive_iprmdata
964 * @path: address of iucv path structure
965 * @msg: address of iucv msg structure
966 * @flags: how the message is received (IUCV_IPBUFLST)
967 * @buffer: address of data buffer or address of struct iucv_array
968 * @size: length of data buffer
971 * Internal function used by iucv_message_receive and __iucv_message_receive
972 * to receive RMDATA data stored in struct iucv_message.
974 static int iucv_message_receive_iprmdata(struct iucv_path
*path
,
975 struct iucv_message
*msg
,
976 u8 flags
, void *buffer
,
977 size_t size
, size_t *residual
)
979 struct iucv_array
*array
;
984 * Message is 8 bytes long and has been stored to the
985 * message descriptor itself.
988 *residual
= abs(size
- 8);
990 if (flags
& IUCV_IPBUFLST
) {
991 /* Copy to struct iucv_array. */
992 size
= (size
< 8) ? size
: 8;
993 for (array
= buffer
; size
> 0; array
++) {
994 copy
= min_t(size_t, size
, array
->length
);
995 memcpy((u8
*)(addr_t
) array
->address
,
1001 /* Copy to direct buffer. */
1002 memcpy(buffer
, rmmsg
, min_t(size_t, size
, 8));
1008 * __iucv_message_receive
1009 * @path: address of iucv path structure
1010 * @msg: address of iucv msg structure
1011 * @flags: how the message is received (IUCV_IPBUFLST)
1012 * @buffer: address of data buffer or address of struct iucv_array
1013 * @size: length of data buffer
1016 * This function receives messages that are being sent to you over
1017 * established paths. This function will deal with RMDATA messages
1018 * embedded in struct iucv_message as well.
1020 * Locking: no locking
1022 * Returns the result from the CP IUCV call.
1024 int __iucv_message_receive(struct iucv_path
*path
, struct iucv_message
*msg
,
1025 u8 flags
, void *buffer
, size_t size
, size_t *residual
)
1027 union iucv_param
*parm
;
1030 if (msg
->flags
& IUCV_IPRMDATA
)
1031 return iucv_message_receive_iprmdata(path
, msg
, flags
,
1032 buffer
, size
, residual
);
1033 parm
= iucv_param
[smp_processor_id()];
1034 memset(parm
, 0, sizeof(union iucv_param
));
1035 parm
->db
.ipbfadr1
= (u32
)(addr_t
) buffer
;
1036 parm
->db
.ipbfln1f
= (u32
) size
;
1037 parm
->db
.ipmsgid
= msg
->id
;
1038 parm
->db
.ippathid
= path
->pathid
;
1039 parm
->db
.iptrgcls
= msg
->class;
1040 parm
->db
.ipflags1
= (flags
| IUCV_IPFGPID
|
1041 IUCV_IPFGMID
| IUCV_IPTRGCLS
);
1042 rc
= iucv_call_b2f0(IUCV_RECEIVE
, parm
);
1043 if (!rc
|| rc
== 5) {
1044 msg
->flags
= parm
->db
.ipflags1
;
1046 *residual
= parm
->db
.ipbfln1f
;
1050 EXPORT_SYMBOL(__iucv_message_receive
);
1053 * iucv_message_receive
1054 * @path: address of iucv path structure
1055 * @msg: address of iucv msg structure
1056 * @flags: how the message is received (IUCV_IPBUFLST)
1057 * @buffer: address of data buffer or address of struct iucv_array
1058 * @size: length of data buffer
1061 * This function receives messages that are being sent to you over
1062 * established paths. This function will deal with RMDATA messages
1063 * embedded in struct iucv_message as well.
1065 * Locking: local_bh_enable/local_bh_disable
1067 * Returns the result from the CP IUCV call.
1069 int iucv_message_receive(struct iucv_path
*path
, struct iucv_message
*msg
,
1070 u8 flags
, void *buffer
, size_t size
, size_t *residual
)
1074 if (msg
->flags
& IUCV_IPRMDATA
)
1075 return iucv_message_receive_iprmdata(path
, msg
, flags
,
1076 buffer
, size
, residual
);
1078 rc
= __iucv_message_receive(path
, msg
, flags
, buffer
, size
, residual
);
1082 EXPORT_SYMBOL(iucv_message_receive
);
1085 * iucv_message_reject
1086 * @path: address of iucv path structure
1087 * @msg: address of iucv msg structure
1089 * The reject function refuses a specified message. Between the time you
1090 * are notified of a message and the time that you complete the message,
1091 * the message may be rejected.
1093 * Returns the result from the CP IUCV call.
1095 int iucv_message_reject(struct iucv_path
*path
, struct iucv_message
*msg
)
1097 union iucv_param
*parm
;
1101 parm
= iucv_param
[smp_processor_id()];
1102 memset(parm
, 0, sizeof(union iucv_param
));
1103 parm
->db
.ippathid
= path
->pathid
;
1104 parm
->db
.ipmsgid
= msg
->id
;
1105 parm
->db
.iptrgcls
= msg
->class;
1106 parm
->db
.ipflags1
= (IUCV_IPTRGCLS
| IUCV_IPFGMID
| IUCV_IPFGPID
);
1107 rc
= iucv_call_b2f0(IUCV_REJECT
, parm
);
1111 EXPORT_SYMBOL(iucv_message_reject
);
1114 * iucv_message_reply
1115 * @path: address of iucv path structure
1116 * @msg: address of iucv msg structure
1117 * @flags: how the reply is sent (IUCV_IPRMDATA, IUCV_IPPRTY, IUCV_IPBUFLST)
1118 * @reply: address of reply data buffer or address of struct iucv_array
1119 * @size: length of reply data buffer
1121 * This function responds to the two-way messages that you receive. You
1122 * must identify completely the message to which you wish to reply. ie,
1123 * pathid, msgid, and trgcls. Prmmsg signifies the data is moved into
1124 * the parameter list.
1126 * Returns the result from the CP IUCV call.
1128 int iucv_message_reply(struct iucv_path
*path
, struct iucv_message
*msg
,
1129 u8 flags
, void *reply
, size_t size
)
1131 union iucv_param
*parm
;
1135 parm
= iucv_param
[smp_processor_id()];
1136 memset(parm
, 0, sizeof(union iucv_param
));
1137 if (flags
& IUCV_IPRMDATA
) {
1138 parm
->dpl
.ippathid
= path
->pathid
;
1139 parm
->dpl
.ipflags1
= flags
;
1140 parm
->dpl
.ipmsgid
= msg
->id
;
1141 parm
->dpl
.iptrgcls
= msg
->class;
1142 memcpy(parm
->dpl
.iprmmsg
, reply
, min_t(size_t, size
, 8));
1144 parm
->db
.ipbfadr1
= (u32
)(addr_t
) reply
;
1145 parm
->db
.ipbfln1f
= (u32
) size
;
1146 parm
->db
.ippathid
= path
->pathid
;
1147 parm
->db
.ipflags1
= flags
;
1148 parm
->db
.ipmsgid
= msg
->id
;
1149 parm
->db
.iptrgcls
= msg
->class;
1151 rc
= iucv_call_b2f0(IUCV_REPLY
, parm
);
1155 EXPORT_SYMBOL(iucv_message_reply
);
1158 * __iucv_message_send
1159 * @path: address of iucv path structure
1160 * @msg: address of iucv msg structure
1161 * @flags: how the message is sent (IUCV_IPRMDATA, IUCV_IPPRTY, IUCV_IPBUFLST)
1162 * @srccls: source class of message
1163 * @buffer: address of send buffer or address of struct iucv_array
1164 * @size: length of send buffer
1166 * This function transmits data to another application. Data to be
1167 * transmitted is in a buffer and this is a one-way message and the
1168 * receiver will not reply to the message.
1170 * Locking: no locking
1172 * Returns the result from the CP IUCV call.
1174 int __iucv_message_send(struct iucv_path
*path
, struct iucv_message
*msg
,
1175 u8 flags
, u32 srccls
, void *buffer
, size_t size
)
1177 union iucv_param
*parm
;
1180 parm
= iucv_param
[smp_processor_id()];
1181 memset(parm
, 0, sizeof(union iucv_param
));
1182 if (flags
& IUCV_IPRMDATA
) {
1183 /* Message of 8 bytes can be placed into the parameter list. */
1184 parm
->dpl
.ippathid
= path
->pathid
;
1185 parm
->dpl
.ipflags1
= flags
| IUCV_IPNORPY
;
1186 parm
->dpl
.iptrgcls
= msg
->class;
1187 parm
->dpl
.ipsrccls
= srccls
;
1188 parm
->dpl
.ipmsgtag
= msg
->tag
;
1189 memcpy(parm
->dpl
.iprmmsg
, buffer
, 8);
1191 parm
->db
.ipbfadr1
= (u32
)(addr_t
) buffer
;
1192 parm
->db
.ipbfln1f
= (u32
) size
;
1193 parm
->db
.ippathid
= path
->pathid
;
1194 parm
->db
.ipflags1
= flags
| IUCV_IPNORPY
;
1195 parm
->db
.iptrgcls
= msg
->class;
1196 parm
->db
.ipsrccls
= srccls
;
1197 parm
->db
.ipmsgtag
= msg
->tag
;
1199 rc
= iucv_call_b2f0(IUCV_SEND
, parm
);
1201 msg
->id
= parm
->db
.ipmsgid
;
1204 EXPORT_SYMBOL(__iucv_message_send
);
1208 * @path: address of iucv path structure
1209 * @msg: address of iucv msg structure
1210 * @flags: how the message is sent (IUCV_IPRMDATA, IUCV_IPPRTY, IUCV_IPBUFLST)
1211 * @srccls: source class of message
1212 * @buffer: address of send buffer or address of struct iucv_array
1213 * @size: length of send buffer
1215 * This function transmits data to another application. Data to be
1216 * transmitted is in a buffer and this is a one-way message and the
1217 * receiver will not reply to the message.
1219 * Locking: local_bh_enable/local_bh_disable
1221 * Returns the result from the CP IUCV call.
1223 int iucv_message_send(struct iucv_path
*path
, struct iucv_message
*msg
,
1224 u8 flags
, u32 srccls
, void *buffer
, size_t size
)
1229 rc
= __iucv_message_send(path
, msg
, flags
, srccls
, buffer
, size
);
1233 EXPORT_SYMBOL(iucv_message_send
);
1236 * iucv_message_send2way
1237 * @path: address of iucv path structure
1238 * @msg: address of iucv msg structure
1239 * @flags: how the message is sent and the reply is received
1240 * (IUCV_IPRMDATA, IUCV_IPBUFLST, IUCV_IPPRTY, IUCV_ANSLST)
1241 * @srccls: source class of message
1242 * @buffer: address of send buffer or address of struct iucv_array
1243 * @size: length of send buffer
1244 * @ansbuf: address of answer buffer or address of struct iucv_array
1245 * @asize: size of reply buffer
1247 * This function transmits data to another application. Data to be
1248 * transmitted is in a buffer. The receiver of the send is expected to
1249 * reply to the message and a buffer is provided into which IUCV moves
1250 * the reply to this message.
1252 * Returns the result from the CP IUCV call.
1254 int iucv_message_send2way(struct iucv_path
*path
, struct iucv_message
*msg
,
1255 u8 flags
, u32 srccls
, void *buffer
, size_t size
,
1256 void *answer
, size_t asize
, size_t *residual
)
1258 union iucv_param
*parm
;
1262 parm
= iucv_param
[smp_processor_id()];
1263 memset(parm
, 0, sizeof(union iucv_param
));
1264 if (flags
& IUCV_IPRMDATA
) {
1265 parm
->dpl
.ippathid
= path
->pathid
;
1266 parm
->dpl
.ipflags1
= path
->flags
; /* priority message */
1267 parm
->dpl
.iptrgcls
= msg
->class;
1268 parm
->dpl
.ipsrccls
= srccls
;
1269 parm
->dpl
.ipmsgtag
= msg
->tag
;
1270 parm
->dpl
.ipbfadr2
= (u32
)(addr_t
) answer
;
1271 parm
->dpl
.ipbfln2f
= (u32
) asize
;
1272 memcpy(parm
->dpl
.iprmmsg
, buffer
, 8);
1274 parm
->db
.ippathid
= path
->pathid
;
1275 parm
->db
.ipflags1
= path
->flags
; /* priority message */
1276 parm
->db
.iptrgcls
= msg
->class;
1277 parm
->db
.ipsrccls
= srccls
;
1278 parm
->db
.ipmsgtag
= msg
->tag
;
1279 parm
->db
.ipbfadr1
= (u32
)(addr_t
) buffer
;
1280 parm
->db
.ipbfln1f
= (u32
) size
;
1281 parm
->db
.ipbfadr2
= (u32
)(addr_t
) answer
;
1282 parm
->db
.ipbfln2f
= (u32
) asize
;
1284 rc
= iucv_call_b2f0(IUCV_SEND
, parm
);
1286 msg
->id
= parm
->db
.ipmsgid
;
1290 EXPORT_SYMBOL(iucv_message_send2way
);
1294 * @data: Pointer to external interrupt buffer
1296 * Process connection pending work item. Called from tasklet while holding
1299 struct iucv_path_pending
{
1310 } __attribute__ ((packed
));
1312 static void iucv_path_pending(struct iucv_irq_data
*data
)
1314 struct iucv_path_pending
*ipp
= (void *) data
;
1315 struct iucv_handler
*handler
;
1316 struct iucv_path
*path
;
1319 BUG_ON(iucv_path_table
[ipp
->ippathid
]);
1320 /* New pathid, handler found. Create a new path struct. */
1321 error
= iucv_error_no_memory
;
1322 path
= iucv_path_alloc(ipp
->ipmsglim
, ipp
->ipflags1
, GFP_ATOMIC
);
1325 path
->pathid
= ipp
->ippathid
;
1326 iucv_path_table
[path
->pathid
] = path
;
1327 EBCASC(ipp
->ipvmid
, 8);
1329 /* Call registered handler until one is found that wants the path. */
1330 list_for_each_entry(handler
, &iucv_handler_list
, list
) {
1331 if (!handler
->path_pending
)
1334 * Add path to handler to allow a call to iucv_path_sever
1335 * inside the path_pending function. If the handler returns
1336 * an error remove the path from the handler again.
1338 list_add(&path
->list
, &handler
->paths
);
1339 path
->handler
= handler
;
1340 if (!handler
->path_pending(path
, ipp
->ipvmid
, ipp
->ipuser
))
1342 list_del(&path
->list
);
1343 path
->handler
= NULL
;
1345 /* No handler wanted the path. */
1346 iucv_path_table
[path
->pathid
] = NULL
;
1347 iucv_path_free(path
);
1348 error
= iucv_error_no_listener
;
1350 iucv_sever_pathid(ipp
->ippathid
, error
);
1354 * iucv_path_complete
1355 * @data: Pointer to external interrupt buffer
1357 * Process connection complete work item. Called from tasklet while holding
1360 struct iucv_path_complete
{
1371 } __attribute__ ((packed
));
1373 static void iucv_path_complete(struct iucv_irq_data
*data
)
1375 struct iucv_path_complete
*ipc
= (void *) data
;
1376 struct iucv_path
*path
= iucv_path_table
[ipc
->ippathid
];
1378 if (path
&& path
->handler
&& path
->handler
->path_complete
)
1379 path
->handler
->path_complete(path
, ipc
->ipuser
);
1384 * @data: Pointer to external interrupt buffer
1386 * Process connection severed work item. Called from tasklet while holding
1389 struct iucv_path_severed
{
1399 } __attribute__ ((packed
));
1401 static void iucv_path_severed(struct iucv_irq_data
*data
)
1403 struct iucv_path_severed
*ips
= (void *) data
;
1404 struct iucv_path
*path
= iucv_path_table
[ips
->ippathid
];
1406 if (!path
|| !path
->handler
) /* Already severed */
1408 if (path
->handler
->path_severed
)
1409 path
->handler
->path_severed(path
, ips
->ipuser
);
1411 iucv_sever_pathid(path
->pathid
, NULL
);
1412 iucv_path_table
[path
->pathid
] = NULL
;
1413 list_del_init(&path
->list
);
1414 iucv_path_free(path
);
1419 * iucv_path_quiesced
1420 * @data: Pointer to external interrupt buffer
1422 * Process connection quiesced work item. Called from tasklet while holding
1425 struct iucv_path_quiesced
{
1435 } __attribute__ ((packed
));
1437 static void iucv_path_quiesced(struct iucv_irq_data
*data
)
1439 struct iucv_path_quiesced
*ipq
= (void *) data
;
1440 struct iucv_path
*path
= iucv_path_table
[ipq
->ippathid
];
1442 if (path
&& path
->handler
&& path
->handler
->path_quiesced
)
1443 path
->handler
->path_quiesced(path
, ipq
->ipuser
);
1448 * @data: Pointer to external interrupt buffer
1450 * Process connection resumed work item. Called from tasklet while holding
1453 struct iucv_path_resumed
{
1463 } __attribute__ ((packed
));
1465 static void iucv_path_resumed(struct iucv_irq_data
*data
)
1467 struct iucv_path_resumed
*ipr
= (void *) data
;
1468 struct iucv_path
*path
= iucv_path_table
[ipr
->ippathid
];
1470 if (path
&& path
->handler
&& path
->handler
->path_resumed
)
1471 path
->handler
->path_resumed(path
, ipr
->ipuser
);
1475 * iucv_message_complete
1476 * @data: Pointer to external interrupt buffer
1478 * Process message complete work item. Called from tasklet while holding
1481 struct iucv_message_complete
{
1494 } __attribute__ ((packed
));
1496 static void iucv_message_complete(struct iucv_irq_data
*data
)
1498 struct iucv_message_complete
*imc
= (void *) data
;
1499 struct iucv_path
*path
= iucv_path_table
[imc
->ippathid
];
1500 struct iucv_message msg
;
1502 if (path
&& path
->handler
&& path
->handler
->message_complete
) {
1503 msg
.flags
= imc
->ipflags1
;
1504 msg
.id
= imc
->ipmsgid
;
1505 msg
.audit
= imc
->ipaudit
;
1506 memcpy(msg
.rmmsg
, imc
->iprmmsg
, 8);
1507 msg
.class = imc
->ipsrccls
;
1508 msg
.tag
= imc
->ipmsgtag
;
1509 msg
.length
= imc
->ipbfln2f
;
1510 path
->handler
->message_complete(path
, &msg
);
1515 * iucv_message_pending
1516 * @data: Pointer to external interrupt buffer
1518 * Process message pending work item. Called from tasklet while holding
1521 struct iucv_message_pending
{
1539 } __attribute__ ((packed
));
1541 static void iucv_message_pending(struct iucv_irq_data
*data
)
1543 struct iucv_message_pending
*imp
= (void *) data
;
1544 struct iucv_path
*path
= iucv_path_table
[imp
->ippathid
];
1545 struct iucv_message msg
;
1547 if (path
&& path
->handler
&& path
->handler
->message_pending
) {
1548 msg
.flags
= imp
->ipflags1
;
1549 msg
.id
= imp
->ipmsgid
;
1550 msg
.class = imp
->iptrgcls
;
1551 if (imp
->ipflags1
& IUCV_IPRMDATA
) {
1552 memcpy(msg
.rmmsg
, imp
->ln1msg1
.iprmmsg1
, 8);
1555 msg
.length
= imp
->ln1msg2
.ipbfln1f
;
1556 msg
.reply_size
= imp
->ipbfln2f
;
1557 path
->handler
->message_pending(path
, &msg
);
1564 * This tasklet loops over the queue of irq buffers created by
1565 * iucv_external_interrupt, calls the appropriate action handler
1566 * and then frees the buffer.
1568 static void iucv_tasklet_fn(unsigned long ignored
)
1570 typedef void iucv_irq_fn(struct iucv_irq_data
*);
1571 static iucv_irq_fn
*irq_fn
[] = {
1572 [0x02] = iucv_path_complete
,
1573 [0x03] = iucv_path_severed
,
1574 [0x04] = iucv_path_quiesced
,
1575 [0x05] = iucv_path_resumed
,
1576 [0x06] = iucv_message_complete
,
1577 [0x07] = iucv_message_complete
,
1578 [0x08] = iucv_message_pending
,
1579 [0x09] = iucv_message_pending
,
1581 LIST_HEAD(task_queue
);
1582 struct iucv_irq_list
*p
, *n
;
1584 /* Serialize tasklet, iucv_path_sever and iucv_path_connect. */
1585 if (!spin_trylock(&iucv_table_lock
)) {
1586 tasklet_schedule(&iucv_tasklet
);
1589 iucv_active_cpu
= smp_processor_id();
1591 spin_lock_irq(&iucv_queue_lock
);
1592 list_splice_init(&iucv_task_queue
, &task_queue
);
1593 spin_unlock_irq(&iucv_queue_lock
);
1595 list_for_each_entry_safe(p
, n
, &task_queue
, list
) {
1596 list_del_init(&p
->list
);
1597 irq_fn
[p
->data
.iptype
](&p
->data
);
1601 iucv_active_cpu
= -1;
1602 spin_unlock(&iucv_table_lock
);
1608 * This work function loops over the queue of path pending irq blocks
1609 * created by iucv_external_interrupt, calls the appropriate action
1610 * handler and then frees the buffer.
1612 static void iucv_work_fn(struct work_struct
*work
)
1614 typedef void iucv_irq_fn(struct iucv_irq_data
*);
1615 LIST_HEAD(work_queue
);
1616 struct iucv_irq_list
*p
, *n
;
1618 /* Serialize tasklet, iucv_path_sever and iucv_path_connect. */
1619 spin_lock_bh(&iucv_table_lock
);
1620 iucv_active_cpu
= smp_processor_id();
1622 spin_lock_irq(&iucv_queue_lock
);
1623 list_splice_init(&iucv_work_queue
, &work_queue
);
1624 spin_unlock_irq(&iucv_queue_lock
);
1626 iucv_cleanup_queue();
1627 list_for_each_entry_safe(p
, n
, &work_queue
, list
) {
1628 list_del_init(&p
->list
);
1629 iucv_path_pending(&p
->data
);
1633 iucv_active_cpu
= -1;
1634 spin_unlock_bh(&iucv_table_lock
);
1638 * iucv_external_interrupt
1641 * Handles external interrupts coming in from CP.
1642 * Places the interrupt buffer on a queue and schedules iucv_tasklet_fn().
1644 static void iucv_external_interrupt(u16 code
)
1646 struct iucv_irq_data
*p
;
1647 struct iucv_irq_list
*work
;
1649 p
= iucv_irq_data
[smp_processor_id()];
1650 if (p
->ippathid
>= iucv_max_pathid
) {
1651 WARN_ON(p
->ippathid
>= iucv_max_pathid
);
1652 iucv_sever_pathid(p
->ippathid
, iucv_error_no_listener
);
1655 BUG_ON(p
->iptype
< 0x01 || p
->iptype
> 0x09);
1656 work
= kmalloc(sizeof(struct iucv_irq_list
), GFP_ATOMIC
);
1658 pr_warning("iucv_external_interrupt: out of memory\n");
1661 memcpy(&work
->data
, p
, sizeof(work
->data
));
1662 spin_lock(&iucv_queue_lock
);
1663 if (p
->iptype
== 0x01) {
1664 /* Path pending interrupt. */
1665 list_add_tail(&work
->list
, &iucv_work_queue
);
1666 schedule_work(&iucv_work
);
1668 /* The other interrupts. */
1669 list_add_tail(&work
->list
, &iucv_task_queue
);
1670 tasklet_schedule(&iucv_tasklet
);
1672 spin_unlock(&iucv_queue_lock
);
1678 * Allocates and initializes various data structures.
1680 static int __init
iucv_init(void)
1685 if (!MACHINE_IS_VM
) {
1686 rc
= -EPROTONOSUPPORT
;
1689 rc
= iucv_query_maxconn();
1692 rc
= register_external_interrupt(0x4000, iucv_external_interrupt
);
1695 iucv_root
= s390_root_dev_register("iucv");
1696 if (IS_ERR(iucv_root
)) {
1697 rc
= PTR_ERR(iucv_root
);
1701 for_each_online_cpu(cpu
) {
1702 /* Note: GFP_DMA used to get memory below 2G */
1703 iucv_irq_data
[cpu
] = kmalloc_node(sizeof(struct iucv_irq_data
),
1704 GFP_KERNEL
|GFP_DMA
, cpu_to_node(cpu
));
1705 if (!iucv_irq_data
[cpu
]) {
1710 /* Allocate parameter blocks. */
1711 iucv_param
[cpu
] = kmalloc_node(sizeof(union iucv_param
),
1712 GFP_KERNEL
|GFP_DMA
, cpu_to_node(cpu
));
1713 if (!iucv_param
[cpu
]) {
1718 rc
= register_hotcpu_notifier(&iucv_cpu_notifier
);
1721 ASCEBC(iucv_error_no_listener
, 16);
1722 ASCEBC(iucv_error_no_memory
, 16);
1723 ASCEBC(iucv_error_pathid
, 16);
1725 rc
= bus_register(&iucv_bus
);
1731 unregister_hotcpu_notifier(&iucv_cpu_notifier
);
1733 for_each_possible_cpu(cpu
) {
1734 kfree(iucv_param
[cpu
]);
1735 iucv_param
[cpu
] = NULL
;
1736 kfree(iucv_irq_data
[cpu
]);
1737 iucv_irq_data
[cpu
] = NULL
;
1739 s390_root_dev_unregister(iucv_root
);
1741 unregister_external_interrupt(0x4000, iucv_external_interrupt
);
1749 * Frees everything allocated from iucv_init.
1751 static void __exit
iucv_exit(void)
1753 struct iucv_irq_list
*p
, *n
;
1756 spin_lock_irq(&iucv_queue_lock
);
1757 list_for_each_entry_safe(p
, n
, &iucv_task_queue
, list
)
1759 list_for_each_entry_safe(p
, n
, &iucv_work_queue
, list
)
1761 spin_unlock_irq(&iucv_queue_lock
);
1762 unregister_hotcpu_notifier(&iucv_cpu_notifier
);
1763 for_each_possible_cpu(cpu
) {
1764 kfree(iucv_param
[cpu
]);
1765 iucv_param
[cpu
] = NULL
;
1766 kfree(iucv_irq_data
[cpu
]);
1767 iucv_irq_data
[cpu
] = NULL
;
1769 s390_root_dev_unregister(iucv_root
);
1770 bus_unregister(&iucv_bus
);
1771 unregister_external_interrupt(0x4000, iucv_external_interrupt
);
1774 subsys_initcall(iucv_init
);
1775 module_exit(iucv_exit
);
1777 MODULE_AUTHOR("(C) 2001 IBM Corp. by Fritz Elfert (felfert@millenux.com)");
1778 MODULE_DESCRIPTION("Linux for S/390 IUCV lowlevel driver");
1779 MODULE_LICENSE("GPL");