blob: fbd023cee4ba22d0a393da583c804f65d7ab0d3f [file] [log] [blame]
Hendrik Brueckner44a01d52008-12-25 13:38:57 +01001/*
Hendrik Brueckner17e19f02009-01-09 12:14:59 +01002 * hvc_iucv.c - z/VM IUCV hypervisor console (HVC) device driver
Hendrik Brueckner44a01d52008-12-25 13:38:57 +01003 *
Hendrik Brueckner17e19f02009-01-09 12:14:59 +01004 * This HVC device driver provides terminal access using
Hendrik Brueckner44a01d52008-12-25 13:38:57 +01005 * z/VM IUCV communication paths.
6 *
Hendrik Brueckner02591622009-06-16 10:30:45 +02007 * Copyright IBM Corp. 2008, 2009
Hendrik Brueckner44a01d52008-12-25 13:38:57 +01008 *
9 * Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
10 */
11#define KMSG_COMPONENT "hvc_iucv"
Hendrik Brueckner17e19f02009-01-09 12:14:59 +010012#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
Hendrik Brueckner44a01d52008-12-25 13:38:57 +010013
14#include <linux/types.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090015#include <linux/slab.h>
Hendrik Brueckner44a01d52008-12-25 13:38:57 +010016#include <asm/ebcdic.h>
Hendrik Brueckner431429f2009-03-26 15:23:55 +010017#include <linux/ctype.h>
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +010018#include <linux/delay.h>
Hendrik Brueckner02591622009-06-16 10:30:45 +020019#include <linux/device.h>
Hendrik Brueckner68c6b3d2009-01-09 12:15:00 +010020#include <linux/init.h>
Hendrik Brueckner44a01d52008-12-25 13:38:57 +010021#include <linux/mempool.h>
Hendrik Brueckner431429f2009-03-26 15:23:55 +010022#include <linux/moduleparam.h>
Hendrik Brueckner44a01d52008-12-25 13:38:57 +010023#include <linux/tty.h>
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +010024#include <linux/wait.h>
Hendrik Brueckner44a01d52008-12-25 13:38:57 +010025#include <net/iucv/iucv.h>
26
27#include "hvc_console.h"
28
29
Hendrik Brueckner17e19f02009-01-09 12:14:59 +010030/* General device driver settings */
Hendrik Brueckner44a01d52008-12-25 13:38:57 +010031#define HVC_IUCV_MAGIC 0xc9e4c3e5
32#define MAX_HVC_IUCV_LINES HVC_ALLOC_TTY_ADAPTERS
33#define MEMPOOL_MIN_NR (PAGE_SIZE / sizeof(struct iucv_tty_buffer)/4)
34
35/* IUCV TTY message */
36#define MSG_VERSION 0x02 /* Message version */
37#define MSG_TYPE_ERROR 0x01 /* Error message */
38#define MSG_TYPE_TERMENV 0x02 /* Terminal environment variable */
39#define MSG_TYPE_TERMIOS 0x04 /* Terminal IO struct update */
40#define MSG_TYPE_WINSIZE 0x08 /* Terminal window size update */
41#define MSG_TYPE_DATA 0x10 /* Terminal data */
42
Hendrik Brueckner44a01d52008-12-25 13:38:57 +010043struct iucv_tty_msg {
44 u8 version; /* Message version */
45 u8 type; /* Message type */
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +010046#define MSG_MAX_DATALEN ((u16)(~0))
Hendrik Brueckner44a01d52008-12-25 13:38:57 +010047 u16 datalen; /* Payload length */
48 u8 data[]; /* Payload buffer */
49} __attribute__((packed));
Hendrik Brueckner17e19f02009-01-09 12:14:59 +010050#define MSG_SIZE(s) ((s) + offsetof(struct iucv_tty_msg, data))
Hendrik Brueckner44a01d52008-12-25 13:38:57 +010051
52enum iucv_state_t {
53 IUCV_DISCONN = 0,
54 IUCV_CONNECTED = 1,
55 IUCV_SEVERED = 2,
56};
57
58enum tty_state_t {
59 TTY_CLOSED = 0,
60 TTY_OPENED = 1,
61};
62
63struct hvc_iucv_private {
Hendrik Brueckner17e19f02009-01-09 12:14:59 +010064 struct hvc_struct *hvc; /* HVC struct reference */
Hendrik Brueckner44a01d52008-12-25 13:38:57 +010065 u8 srv_name[8]; /* IUCV service name (ebcdic) */
Hendrik Brueckner6c089fd2009-01-09 12:15:01 +010066 unsigned char is_console; /* Linux console usage flag */
Hendrik Brueckner44a01d52008-12-25 13:38:57 +010067 enum iucv_state_t iucv_state; /* IUCV connection status */
68 enum tty_state_t tty_state; /* TTY status */
69 struct iucv_path *path; /* IUCV path pointer */
70 spinlock_t lock; /* hvc_iucv_private lock */
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +010071#define SNDBUF_SIZE (PAGE_SIZE) /* must be < MSG_MAX_DATALEN */
72 void *sndbuf; /* send buffer */
73 size_t sndbuf_len; /* length of send buffer */
74#define QUEUE_SNDBUF_DELAY (HZ / 25)
75 struct delayed_work sndbuf_work; /* work: send iucv msg(s) */
76 wait_queue_head_t sndbuf_waitq; /* wait for send completion */
Hendrik Brueckner44a01d52008-12-25 13:38:57 +010077 struct list_head tty_outqueue; /* outgoing IUCV messages */
78 struct list_head tty_inqueue; /* incoming IUCV messages */
Hendrik Brueckner02591622009-06-16 10:30:45 +020079 struct device *dev; /* device structure */
Hendrik Bruecknerf1206ba2014-01-17 14:42:00 +010080 u8 info_path[16]; /* IUCV path info (dev attr) */
Hendrik Brueckner44a01d52008-12-25 13:38:57 +010081};
82
83struct iucv_tty_buffer {
84 struct list_head list; /* list pointer */
Hendrik Brueckner17e19f02009-01-09 12:14:59 +010085 struct iucv_message msg; /* store an IUCV message */
Hendrik Brueckner44a01d52008-12-25 13:38:57 +010086 size_t offset; /* data buffer offset */
87 struct iucv_tty_msg *mbuf; /* buffer to store input/output data */
88};
89
90/* IUCV callback handler */
91static int hvc_iucv_path_pending(struct iucv_path *, u8[8], u8[16]);
92static void hvc_iucv_path_severed(struct iucv_path *, u8[16]);
93static void hvc_iucv_msg_pending(struct iucv_path *, struct iucv_message *);
94static void hvc_iucv_msg_complete(struct iucv_path *, struct iucv_message *);
95
96
Hendrik Brueckner2dc184c2009-01-09 12:14:57 +010097/* Kernel module parameter: use one terminal device as default */
98static unsigned long hvc_iucv_devices = 1;
Hendrik Brueckner44a01d52008-12-25 13:38:57 +010099
100/* Array of allocated hvc iucv tty lines... */
101static struct hvc_iucv_private *hvc_iucv_table[MAX_HVC_IUCV_LINES];
Hendrik Brueckner6c089fd2009-01-09 12:15:01 +0100102#define IUCV_HVC_CON_IDX (0)
Hendrik Brueckner431429f2009-03-26 15:23:55 +0100103/* List of z/VM user ID filter entries (struct iucv_vmid_filter) */
104#define MAX_VMID_FILTER (500)
105static size_t hvc_iucv_filter_size;
106static void *hvc_iucv_filter;
107static const char *hvc_iucv_filter_string;
108static DEFINE_RWLOCK(hvc_iucv_filter_lock);
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100109
110/* Kmem cache and mempool for iucv_tty_buffer elements */
111static struct kmem_cache *hvc_iucv_buffer_cache;
112static mempool_t *hvc_iucv_mempool;
113
114/* IUCV handler callback functions */
115static struct iucv_handler hvc_iucv_handler = {
116 .path_pending = hvc_iucv_path_pending,
117 .path_severed = hvc_iucv_path_severed,
118 .message_complete = hvc_iucv_msg_complete,
119 .message_pending = hvc_iucv_msg_pending,
120};
121
122
123/**
124 * hvc_iucv_get_private() - Return a struct hvc_iucv_private instance.
125 * @num: The HVC virtual terminal number (vtermno)
126 *
127 * This function returns the struct hvc_iucv_private instance that corresponds
128 * to the HVC virtual terminal number specified as parameter @num.
129 */
Hendrik Brueckner2ee13c62014-01-17 16:07:46 +0100130static struct hvc_iucv_private *hvc_iucv_get_private(uint32_t num)
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100131{
132 if ((num < HVC_IUCV_MAGIC) || (num - HVC_IUCV_MAGIC > hvc_iucv_devices))
133 return NULL;
134 return hvc_iucv_table[num - HVC_IUCV_MAGIC];
135}
136
137/**
Hendrik Brueckner17e19f02009-01-09 12:14:59 +0100138 * alloc_tty_buffer() - Return a new struct iucv_tty_buffer element.
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100139 * @size: Size of the internal buffer used to store data.
140 * @flags: Memory allocation flags passed to mempool.
141 *
142 * This function allocates a new struct iucv_tty_buffer element and, optionally,
143 * allocates an internal data buffer with the specified size @size.
Hendrik Brueckner91a970d2010-03-08 12:25:15 +0100144 * The internal data buffer is always allocated with GFP_DMA which is
145 * required for receiving and sending data with IUCV.
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100146 * Note: The total message size arises from the internal buffer size and the
147 * members of the iucv_tty_msg structure.
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100148 * The function returns NULL if memory allocation has failed.
149 */
150static struct iucv_tty_buffer *alloc_tty_buffer(size_t size, gfp_t flags)
151{
152 struct iucv_tty_buffer *bufp;
153
154 bufp = mempool_alloc(hvc_iucv_mempool, flags);
155 if (!bufp)
156 return NULL;
Hendrik Brueckner6c089fd2009-01-09 12:15:01 +0100157 memset(bufp, 0, sizeof(*bufp));
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100158
159 if (size > 0) {
160 bufp->msg.length = MSG_SIZE(size);
Hendrik Brueckner91a970d2010-03-08 12:25:15 +0100161 bufp->mbuf = kmalloc(bufp->msg.length, flags | GFP_DMA);
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100162 if (!bufp->mbuf) {
163 mempool_free(bufp, hvc_iucv_mempool);
164 return NULL;
165 }
166 bufp->mbuf->version = MSG_VERSION;
167 bufp->mbuf->type = MSG_TYPE_DATA;
168 bufp->mbuf->datalen = (u16) size;
169 }
170 return bufp;
171}
172
173/**
174 * destroy_tty_buffer() - destroy struct iucv_tty_buffer element.
175 * @bufp: Pointer to a struct iucv_tty_buffer element, SHALL NOT be NULL.
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100176 */
177static void destroy_tty_buffer(struct iucv_tty_buffer *bufp)
178{
179 kfree(bufp->mbuf);
180 mempool_free(bufp, hvc_iucv_mempool);
181}
182
183/**
184 * destroy_tty_buffer_list() - call destroy_tty_buffer() for each list element.
Hendrik Brueckner17e19f02009-01-09 12:14:59 +0100185 * @list: List containing struct iucv_tty_buffer elements.
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100186 */
187static void destroy_tty_buffer_list(struct list_head *list)
188{
189 struct iucv_tty_buffer *ent, *next;
190
191 list_for_each_entry_safe(ent, next, list, list) {
192 list_del(&ent->list);
193 destroy_tty_buffer(ent);
194 }
195}
196
197/**
Hendrik Brueckner17e19f02009-01-09 12:14:59 +0100198 * hvc_iucv_write() - Receive IUCV message & write data to HVC buffer.
199 * @priv: Pointer to struct hvc_iucv_private
200 * @buf: HVC buffer for writing received terminal data.
201 * @count: HVC buffer size.
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100202 * @has_more_data: Pointer to an int variable.
203 *
204 * The function picks up pending messages from the input queue and receives
205 * the message data that is then written to the specified buffer @buf.
Hendrik Brueckner17e19f02009-01-09 12:14:59 +0100206 * If the buffer size @count is less than the data message size, the
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100207 * message is kept on the input queue and @has_more_data is set to 1.
Hendrik Brueckner17e19f02009-01-09 12:14:59 +0100208 * If all message data has been written, the message is removed from
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100209 * the input queue.
210 *
211 * The function returns the number of bytes written to the terminal, zero if
212 * there are no pending data messages available or if there is no established
213 * IUCV path.
214 * If the IUCV path has been severed, then -EPIPE is returned to cause a
Hendrik Brueckner17e19f02009-01-09 12:14:59 +0100215 * hang up (that is issued by the HVC layer).
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100216 */
217static int hvc_iucv_write(struct hvc_iucv_private *priv,
218 char *buf, int count, int *has_more_data)
219{
220 struct iucv_tty_buffer *rb;
221 int written;
222 int rc;
223
Hendrik Brueckner17e19f02009-01-09 12:14:59 +0100224 /* immediately return if there is no IUCV connection */
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100225 if (priv->iucv_state == IUCV_DISCONN)
226 return 0;
227
Hendrik Brueckner17e19f02009-01-09 12:14:59 +0100228 /* if the IUCV path has been severed, return -EPIPE to inform the
229 * HVC layer to hang up the tty device. */
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100230 if (priv->iucv_state == IUCV_SEVERED)
231 return -EPIPE;
232
233 /* check if there are pending messages */
234 if (list_empty(&priv->tty_inqueue))
235 return 0;
236
Hendrik Brueckner17e19f02009-01-09 12:14:59 +0100237 /* receive an iucv message and flip data to the tty (ldisc) */
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100238 rb = list_first_entry(&priv->tty_inqueue, struct iucv_tty_buffer, list);
239
240 written = 0;
241 if (!rb->mbuf) { /* message not yet received ... */
242 /* allocate mem to store msg data; if no memory is available
243 * then leave the buffer on the list and re-try later */
Hendrik Brueckner91a970d2010-03-08 12:25:15 +0100244 rb->mbuf = kmalloc(rb->msg.length, GFP_ATOMIC | GFP_DMA);
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100245 if (!rb->mbuf)
246 return -ENOMEM;
247
248 rc = __iucv_message_receive(priv->path, &rb->msg, 0,
249 rb->mbuf, rb->msg.length, NULL);
250 switch (rc) {
251 case 0: /* Successful */
252 break;
253 case 2: /* No message found */
254 case 9: /* Message purged */
255 break;
256 default:
257 written = -EIO;
258 }
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300259 /* remove buffer if an error has occurred or received data
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100260 * is not correct */
261 if (rc || (rb->mbuf->version != MSG_VERSION) ||
262 (rb->msg.length != MSG_SIZE(rb->mbuf->datalen)))
263 goto out_remove_buffer;
264 }
265
266 switch (rb->mbuf->type) {
267 case MSG_TYPE_DATA:
268 written = min_t(int, rb->mbuf->datalen - rb->offset, count);
269 memcpy(buf, rb->mbuf->data + rb->offset, written);
270 if (written < (rb->mbuf->datalen - rb->offset)) {
271 rb->offset += written;
272 *has_more_data = 1;
273 goto out_written;
274 }
275 break;
276
277 case MSG_TYPE_WINSIZE:
278 if (rb->mbuf->datalen != sizeof(struct winsize))
279 break;
Hendrik Brueckner254be492009-08-27 01:45:39 +0000280 /* The caller must ensure that the hvc is locked, which
281 * is the case when called from hvc_iucv_get_chars() */
282 __hvc_resize(priv->hvc, *((struct winsize *) rb->mbuf->data));
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100283 break;
284
285 case MSG_TYPE_ERROR: /* ignored ... */
286 case MSG_TYPE_TERMENV: /* ignored ... */
287 case MSG_TYPE_TERMIOS: /* ignored ... */
288 break;
289 }
290
291out_remove_buffer:
292 list_del(&rb->list);
293 destroy_tty_buffer(rb);
294 *has_more_data = !list_empty(&priv->tty_inqueue);
295
296out_written:
297 return written;
298}
299
300/**
301 * hvc_iucv_get_chars() - HVC get_chars operation.
302 * @vtermno: HVC virtual terminal number.
303 * @buf: Pointer to a buffer to store data
304 * @count: Size of buffer available for writing
305 *
Hendrik Brueckner17e19f02009-01-09 12:14:59 +0100306 * The HVC thread calls this method to read characters from the back-end.
307 * If an IUCV communication path has been established, pending IUCV messages
308 * are received and data is copied into buffer @buf up to @count bytes.
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100309 *
310 * Locking: The routine gets called under an irqsave() spinlock; and
311 * the routine locks the struct hvc_iucv_private->lock to call
312 * helper functions.
313 */
314static int hvc_iucv_get_chars(uint32_t vtermno, char *buf, int count)
315{
316 struct hvc_iucv_private *priv = hvc_iucv_get_private(vtermno);
317 int written;
318 int has_more_data;
319
320 if (count <= 0)
321 return 0;
322
323 if (!priv)
324 return -ENODEV;
325
326 spin_lock(&priv->lock);
327 has_more_data = 0;
328 written = hvc_iucv_write(priv, buf, count, &has_more_data);
329 spin_unlock(&priv->lock);
330
331 /* if there are still messages on the queue... schedule another run */
332 if (has_more_data)
333 hvc_kick();
334
335 return written;
336}
337
338/**
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +0100339 * hvc_iucv_queue() - Buffer terminal data for sending.
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100340 * @priv: Pointer to struct hvc_iucv_private instance.
341 * @buf: Buffer containing data to send.
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +0100342 * @count: Size of buffer and amount of data to send.
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100343 *
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +0100344 * The function queues data for sending. To actually send the buffered data,
Hendrik Brueckner17e19f02009-01-09 12:14:59 +0100345 * a work queue function is scheduled (with QUEUE_SNDBUF_DELAY).
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +0100346 * The function returns the number of data bytes that has been buffered.
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100347 *
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +0100348 * If the device is not connected, data is ignored and the function returns
349 * @count.
350 * If the buffer is full, the function returns 0.
Hendrik Brueckner17e19f02009-01-09 12:14:59 +0100351 * If an existing IUCV communicaton path has been severed, -EPIPE is returned
352 * (that can be passed to HVC layer to cause a tty hangup).
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100353 */
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +0100354static int hvc_iucv_queue(struct hvc_iucv_private *priv, const char *buf,
Hendrik Brueckner17e19f02009-01-09 12:14:59 +0100355 int count)
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100356{
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +0100357 size_t len;
358
359 if (priv->iucv_state == IUCV_DISCONN)
360 return count; /* ignore data */
361
362 if (priv->iucv_state == IUCV_SEVERED)
363 return -EPIPE;
364
365 len = min_t(size_t, count, SNDBUF_SIZE - priv->sndbuf_len);
366 if (!len)
367 return 0;
368
369 memcpy(priv->sndbuf + priv->sndbuf_len, buf, len);
370 priv->sndbuf_len += len;
371
372 if (priv->iucv_state == IUCV_CONNECTED)
373 schedule_delayed_work(&priv->sndbuf_work, QUEUE_SNDBUF_DELAY);
374
375 return len;
376}
377
378/**
379 * hvc_iucv_send() - Send an IUCV message containing terminal data.
380 * @priv: Pointer to struct hvc_iucv_private instance.
381 *
Hendrik Brueckner17e19f02009-01-09 12:14:59 +0100382 * If an IUCV communication path has been established, the buffered output data
383 * is sent via an IUCV message and the number of bytes sent is returned.
384 * Returns 0 if there is no established IUCV communication path or
385 * -EPIPE if an existing IUCV communicaton path has been severed.
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +0100386 */
387static int hvc_iucv_send(struct hvc_iucv_private *priv)
388{
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100389 struct iucv_tty_buffer *sb;
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +0100390 int rc, len;
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100391
392 if (priv->iucv_state == IUCV_SEVERED)
393 return -EPIPE;
394
395 if (priv->iucv_state == IUCV_DISCONN)
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +0100396 return -EIO;
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100397
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +0100398 if (!priv->sndbuf_len)
399 return 0;
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100400
401 /* allocate internal buffer to store msg data and also compute total
402 * message length */
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +0100403 sb = alloc_tty_buffer(priv->sndbuf_len, GFP_ATOMIC);
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100404 if (!sb)
405 return -ENOMEM;
406
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +0100407 memcpy(sb->mbuf->data, priv->sndbuf, priv->sndbuf_len);
408 sb->mbuf->datalen = (u16) priv->sndbuf_len;
409 sb->msg.length = MSG_SIZE(sb->mbuf->datalen);
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100410
411 list_add_tail(&sb->list, &priv->tty_outqueue);
412
413 rc = __iucv_message_send(priv->path, &sb->msg, 0, 0,
414 (void *) sb->mbuf, sb->msg.length);
415 if (rc) {
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +0100416 /* drop the message here; however we might want to handle
417 * 0x03 (msg limit reached) by trying again... */
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100418 list_del(&sb->list);
419 destroy_tty_buffer(sb);
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100420 }
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +0100421 len = priv->sndbuf_len;
422 priv->sndbuf_len = 0;
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100423
424 return len;
425}
426
427/**
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +0100428 * hvc_iucv_sndbuf_work() - Send buffered data over IUCV
429 * @work: Work structure.
430 *
Hendrik Brueckner17e19f02009-01-09 12:14:59 +0100431 * This work queue function sends buffered output data over IUCV and,
432 * if not all buffered data could be sent, reschedules itself.
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +0100433 */
434static void hvc_iucv_sndbuf_work(struct work_struct *work)
435{
436 struct hvc_iucv_private *priv;
437
438 priv = container_of(work, struct hvc_iucv_private, sndbuf_work.work);
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +0100439 if (!priv)
440 return;
441
442 spin_lock_bh(&priv->lock);
443 hvc_iucv_send(priv);
444 spin_unlock_bh(&priv->lock);
445}
446
447/**
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100448 * hvc_iucv_put_chars() - HVC put_chars operation.
449 * @vtermno: HVC virtual terminal number.
450 * @buf: Pointer to an buffer to read data from
451 * @count: Size of buffer available for reading
452 *
Hendrik Brueckner17e19f02009-01-09 12:14:59 +0100453 * The HVC thread calls this method to write characters to the back-end.
454 * The function calls hvc_iucv_queue() to queue terminal data for sending.
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100455 *
456 * Locking: The method gets called under an irqsave() spinlock; and
457 * locks struct hvc_iucv_private->lock.
458 */
459static int hvc_iucv_put_chars(uint32_t vtermno, const char *buf, int count)
460{
461 struct hvc_iucv_private *priv = hvc_iucv_get_private(vtermno);
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +0100462 int queued;
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100463
464 if (count <= 0)
465 return 0;
466
467 if (!priv)
468 return -ENODEV;
469
470 spin_lock(&priv->lock);
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +0100471 queued = hvc_iucv_queue(priv, buf, count);
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100472 spin_unlock(&priv->lock);
473
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +0100474 return queued;
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100475}
476
477/**
478 * hvc_iucv_notifier_add() - HVC notifier for opening a TTY for the first time.
479 * @hp: Pointer to the HVC device (struct hvc_struct)
480 * @id: Additional data (originally passed to hvc_alloc): the index of an struct
481 * hvc_iucv_private instance.
482 *
Hendrik Brueckner6c089fd2009-01-09 12:15:01 +0100483 * The function sets the tty state to TTY_OPENED for the struct hvc_iucv_private
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100484 * instance that is derived from @id. Always returns 0.
485 *
486 * Locking: struct hvc_iucv_private->lock, spin_lock_bh
487 */
488static int hvc_iucv_notifier_add(struct hvc_struct *hp, int id)
489{
490 struct hvc_iucv_private *priv;
491
492 priv = hvc_iucv_get_private(id);
493 if (!priv)
494 return 0;
495
496 spin_lock_bh(&priv->lock);
497 priv->tty_state = TTY_OPENED;
498 spin_unlock_bh(&priv->lock);
499
500 return 0;
501}
502
503/**
Hendrik Brueckner17e19f02009-01-09 12:14:59 +0100504 * hvc_iucv_cleanup() - Clean up and reset a z/VM IUCV HVC instance.
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100505 * @priv: Pointer to the struct hvc_iucv_private instance.
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100506 */
507static void hvc_iucv_cleanup(struct hvc_iucv_private *priv)
508{
509 destroy_tty_buffer_list(&priv->tty_outqueue);
510 destroy_tty_buffer_list(&priv->tty_inqueue);
511
512 priv->tty_state = TTY_CLOSED;
513 priv->iucv_state = IUCV_DISCONN;
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +0100514
515 priv->sndbuf_len = 0;
516}
517
518/**
519 * tty_outqueue_empty() - Test if the tty outq is empty
520 * @priv: Pointer to struct hvc_iucv_private instance.
521 */
522static inline int tty_outqueue_empty(struct hvc_iucv_private *priv)
523{
524 int rc;
525
526 spin_lock_bh(&priv->lock);
527 rc = list_empty(&priv->tty_outqueue);
528 spin_unlock_bh(&priv->lock);
529
530 return rc;
531}
532
533/**
534 * flush_sndbuf_sync() - Flush send buffer and wait for completion
535 * @priv: Pointer to struct hvc_iucv_private instance.
536 *
537 * The routine cancels a pending sndbuf work, calls hvc_iucv_send()
538 * to flush any buffered terminal output data and waits for completion.
539 */
540static void flush_sndbuf_sync(struct hvc_iucv_private *priv)
541{
542 int sync_wait;
543
544 cancel_delayed_work_sync(&priv->sndbuf_work);
545
546 spin_lock_bh(&priv->lock);
547 hvc_iucv_send(priv); /* force sending buffered data */
548 sync_wait = !list_empty(&priv->tty_outqueue); /* anything queued ? */
549 spin_unlock_bh(&priv->lock);
550
551 if (sync_wait)
552 wait_event_timeout(priv->sndbuf_waitq,
Hendrik Brueckner02591622009-06-16 10:30:45 +0200553 tty_outqueue_empty(priv), HZ/10);
554}
555
556/**
557 * hvc_iucv_hangup() - Sever IUCV path and schedule hvc tty hang up
558 * @priv: Pointer to hvc_iucv_private structure
559 *
560 * This routine severs an existing IUCV communication path and hangs
561 * up the underlying HVC terminal device.
562 * The hang-up occurs only if an IUCV communication path is established;
563 * otherwise there is no need to hang up the terminal device.
564 *
565 * The IUCV HVC hang-up is separated into two steps:
566 * 1. After the IUCV path has been severed, the iucv_state is set to
567 * IUCV_SEVERED.
568 * 2. Later, when the HVC thread calls hvc_iucv_get_chars(), the
569 * IUCV_SEVERED state causes the tty hang-up in the HVC layer.
570 *
571 * If the tty has not yet been opened, clean up the hvc_iucv_private
572 * structure to allow re-connects.
573 * If the tty has been opened, let get_chars() return -EPIPE to signal
574 * the HVC layer to hang up the tty and, if so, wake up the HVC thread
575 * to call get_chars()...
576 *
577 * Special notes on hanging up a HVC terminal instantiated as console:
578 * Hang-up: 1. do_tty_hangup() replaces file ops (= hung_up_tty_fops)
579 * 2. do_tty_hangup() calls tty->ops->close() for console_filp
580 * => no hangup notifier is called by HVC (default)
581 * 2. hvc_close() returns because of tty_hung_up_p(filp)
582 * => no delete notifier is called!
583 * Finally, the back-end is not being notified, thus, the tty session is
584 * kept active (TTY_OPEN) to be ready for re-connects.
585 *
586 * Locking: spin_lock(&priv->lock) w/o disabling bh
587 */
588static void hvc_iucv_hangup(struct hvc_iucv_private *priv)
589{
590 struct iucv_path *path;
591
592 path = NULL;
593 spin_lock(&priv->lock);
594 if (priv->iucv_state == IUCV_CONNECTED) {
595 path = priv->path;
596 priv->path = NULL;
597 priv->iucv_state = IUCV_SEVERED;
598 if (priv->tty_state == TTY_CLOSED)
599 hvc_iucv_cleanup(priv);
600 else
601 /* console is special (see above) */
602 if (priv->is_console) {
603 hvc_iucv_cleanup(priv);
604 priv->tty_state = TTY_OPENED;
605 } else
606 hvc_kick();
607 }
608 spin_unlock(&priv->lock);
609
610 /* finally sever path (outside of priv->lock due to lock ordering) */
611 if (path) {
612 iucv_path_sever(path, NULL);
613 iucv_path_free(path);
614 }
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100615}
616
617/**
Hendrik Brueckner17e19f02009-01-09 12:14:59 +0100618 * hvc_iucv_notifier_hangup() - HVC notifier for TTY hangups.
619 * @hp: Pointer to the HVC device (struct hvc_struct)
620 * @id: Additional data (originally passed to hvc_alloc):
621 * the index of an struct hvc_iucv_private instance.
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100622 *
Hendrik Brueckner17e19f02009-01-09 12:14:59 +0100623 * This routine notifies the HVC back-end that a tty hangup (carrier loss,
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300624 * virtual or otherwise) has occurred.
Hendrik Brueckner17e19f02009-01-09 12:14:59 +0100625 * The z/VM IUCV HVC device driver ignores virtual hangups (vhangup())
626 * to keep an existing IUCV communication path established.
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100627 * (Background: vhangup() is called from user space (by getty or login) to
628 * disable writing to the tty by other applications).
Hendrik Brueckner17e19f02009-01-09 12:14:59 +0100629 * If the tty has been opened and an established IUCV path has been severed
630 * (we caused the tty hangup), the function calls hvc_iucv_cleanup().
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100631 *
632 * Locking: struct hvc_iucv_private->lock
633 */
634static void hvc_iucv_notifier_hangup(struct hvc_struct *hp, int id)
635{
636 struct hvc_iucv_private *priv;
637
638 priv = hvc_iucv_get_private(id);
639 if (!priv)
640 return;
641
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +0100642 flush_sndbuf_sync(priv);
643
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100644 spin_lock_bh(&priv->lock);
645 /* NOTE: If the hangup was scheduled by ourself (from the iucv
Hendrik Brueckner17e19f02009-01-09 12:14:59 +0100646 * path_servered callback [IUCV_SEVERED]), we have to clean up
647 * our structure and to set state to TTY_CLOSED.
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100648 * If the tty was hung up otherwise (e.g. vhangup()), then we
649 * ignore this hangup and keep an established IUCV path open...
650 * (...the reason is that we are not able to connect back to the
651 * client if we disconnect on hang up) */
652 priv->tty_state = TTY_CLOSED;
653
654 if (priv->iucv_state == IUCV_SEVERED)
655 hvc_iucv_cleanup(priv);
656 spin_unlock_bh(&priv->lock);
657}
658
659/**
Hendrik Brueckner74b3b4c2013-07-02 17:07:15 +0200660 * hvc_iucv_dtr_rts() - HVC notifier for handling DTR/RTS
661 * @hp: Pointer the HVC device (struct hvc_struct)
662 * @raise: Non-zero to raise or zero to lower DTR/RTS lines
663 *
664 * This routine notifies the HVC back-end to raise or lower DTR/RTS
665 * lines. Raising DTR/RTS is ignored. Lowering DTR/RTS indicates to
666 * drop the IUCV connection (similar to hang up the modem).
667 */
668static void hvc_iucv_dtr_rts(struct hvc_struct *hp, int raise)
669{
670 struct hvc_iucv_private *priv;
671 struct iucv_path *path;
672
673 /* Raising the DTR/RTS is ignored as IUCV connections can be
674 * established at any times.
675 */
676 if (raise)
677 return;
678
679 priv = hvc_iucv_get_private(hp->vtermno);
680 if (!priv)
681 return;
682
683 /* Lowering the DTR/RTS lines disconnects an established IUCV
684 * connection.
685 */
686 flush_sndbuf_sync(priv);
687
688 spin_lock_bh(&priv->lock);
689 path = priv->path; /* save reference to IUCV path */
690 priv->path = NULL;
691 priv->iucv_state = IUCV_DISCONN;
692 spin_unlock_bh(&priv->lock);
693
694 /* Sever IUCV path outside of priv->lock due to lock ordering of:
695 * priv->lock <--> iucv_table_lock */
696 if (path) {
697 iucv_path_sever(path, NULL);
698 iucv_path_free(path);
699 }
700}
701
702/**
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100703 * hvc_iucv_notifier_del() - HVC notifier for closing a TTY for the last time.
704 * @hp: Pointer to the HVC device (struct hvc_struct)
705 * @id: Additional data (originally passed to hvc_alloc):
706 * the index of an struct hvc_iucv_private instance.
707 *
Hendrik Brueckner17e19f02009-01-09 12:14:59 +0100708 * This routine notifies the HVC back-end that the last tty device fd has been
Hendrik Brueckner74b3b4c2013-07-02 17:07:15 +0200709 * closed. The function cleans up tty resources. The clean-up of the IUCV
710 * connection is done in hvc_iucv_dtr_rts() and depends on the HUPCL termios
711 * control setting.
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100712 *
713 * Locking: struct hvc_iucv_private->lock
714 */
715static void hvc_iucv_notifier_del(struct hvc_struct *hp, int id)
716{
717 struct hvc_iucv_private *priv;
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100718
719 priv = hvc_iucv_get_private(id);
720 if (!priv)
721 return;
722
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +0100723 flush_sndbuf_sync(priv);
724
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100725 spin_lock_bh(&priv->lock);
Hendrik Brueckner74b3b4c2013-07-02 17:07:15 +0200726 destroy_tty_buffer_list(&priv->tty_outqueue);
727 destroy_tty_buffer_list(&priv->tty_inqueue);
728 priv->tty_state = TTY_CLOSED;
729 priv->sndbuf_len = 0;
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100730 spin_unlock_bh(&priv->lock);
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100731}
732
733/**
Hendrik Brueckner431429f2009-03-26 15:23:55 +0100734 * hvc_iucv_filter_connreq() - Filter connection request based on z/VM user ID
735 * @ipvmid: Originating z/VM user ID (right padded with blanks)
736 *
737 * Returns 0 if the z/VM user ID @ipvmid is allowed to connection, otherwise
738 * non-zero.
739 */
740static int hvc_iucv_filter_connreq(u8 ipvmid[8])
741{
742 size_t i;
743
744 /* Note: default policy is ACCEPT if no filter is set */
745 if (!hvc_iucv_filter_size)
746 return 0;
747
748 for (i = 0; i < hvc_iucv_filter_size; i++)
749 if (0 == memcmp(ipvmid, hvc_iucv_filter + (8 * i), 8))
750 return 0;
751 return 1;
752}
753
754/**
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100755 * hvc_iucv_path_pending() - IUCV handler to process a connection request.
756 * @path: Pending path (struct iucv_path)
Hendrik Brueckner17e19f02009-01-09 12:14:59 +0100757 * @ipvmid: z/VM system identifier of originator
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100758 * @ipuser: User specified data for this path
759 * (AF_IUCV: port/service name and originator port)
760 *
Hendrik Brueckner17e19f02009-01-09 12:14:59 +0100761 * The function uses the @ipuser data to determine if the pending path belongs
762 * to a terminal managed by this device driver.
763 * If the path belongs to this driver, ensure that the terminal is not accessed
764 * multiple times (only one connection to a terminal is allowed).
765 * If the terminal is not yet connected, the pending path is accepted and is
766 * associated to the appropriate struct hvc_iucv_private instance.
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100767 *
Hendrik Brueckner17e19f02009-01-09 12:14:59 +0100768 * Returns 0 if @path belongs to a terminal managed by the this device driver;
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100769 * otherwise returns -ENODEV in order to dispatch this path to other handlers.
770 *
771 * Locking: struct hvc_iucv_private->lock
772 */
773static int hvc_iucv_path_pending(struct iucv_path *path,
774 u8 ipvmid[8], u8 ipuser[16])
775{
776 struct hvc_iucv_private *priv;
777 u8 nuser_data[16];
Hendrik Brueckner431429f2009-03-26 15:23:55 +0100778 u8 vm_user_id[9];
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100779 int i, rc;
780
781 priv = NULL;
782 for (i = 0; i < hvc_iucv_devices; i++)
783 if (hvc_iucv_table[i] &&
784 (0 == memcmp(hvc_iucv_table[i]->srv_name, ipuser, 8))) {
785 priv = hvc_iucv_table[i];
786 break;
787 }
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100788 if (!priv)
789 return -ENODEV;
790
Hendrik Brueckner431429f2009-03-26 15:23:55 +0100791 /* Enforce that ipvmid is allowed to connect to us */
792 read_lock(&hvc_iucv_filter_lock);
793 rc = hvc_iucv_filter_connreq(ipvmid);
794 read_unlock(&hvc_iucv_filter_lock);
795 if (rc) {
796 iucv_path_sever(path, ipuser);
797 iucv_path_free(path);
798 memcpy(vm_user_id, ipvmid, 8);
799 vm_user_id[8] = 0;
800 pr_info("A connection request from z/VM user ID %s "
801 "was refused\n", vm_user_id);
802 return 0;
803 }
804
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100805 spin_lock(&priv->lock);
806
807 /* If the terminal is already connected or being severed, then sever
808 * this path to enforce that there is only ONE established communication
809 * path per terminal. */
810 if (priv->iucv_state != IUCV_DISCONN) {
811 iucv_path_sever(path, ipuser);
812 iucv_path_free(path);
813 goto out_path_handled;
814 }
815
816 /* accept path */
817 memcpy(nuser_data, ipuser + 8, 8); /* remote service (for af_iucv) */
818 memcpy(nuser_data + 8, ipuser, 8); /* local service (for af_iucv) */
819 path->msglim = 0xffff; /* IUCV MSGLIMIT */
820 path->flags &= ~IUCV_IPRMDATA; /* TODO: use IUCV_IPRMDATA */
821 rc = iucv_path_accept(path, &hvc_iucv_handler, nuser_data, priv);
822 if (rc) {
823 iucv_path_sever(path, ipuser);
824 iucv_path_free(path);
825 goto out_path_handled;
826 }
827 priv->path = path;
828 priv->iucv_state = IUCV_CONNECTED;
829
Hendrik Bruecknerf1206ba2014-01-17 14:42:00 +0100830 /* store path information */
831 memcpy(priv->info_path, ipvmid, 8);
832 memcpy(priv->info_path + 8, ipuser + 8, 8);
833
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +0100834 /* flush buffered output data... */
835 schedule_delayed_work(&priv->sndbuf_work, 5);
836
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100837out_path_handled:
838 spin_unlock(&priv->lock);
839 return 0;
840}
841
842/**
843 * hvc_iucv_path_severed() - IUCV handler to process a path sever.
844 * @path: Pending path (struct iucv_path)
845 * @ipuser: User specified data for this path
846 * (AF_IUCV: port/service name and originator port)
847 *
Hendrik Brueckner02591622009-06-16 10:30:45 +0200848 * This function calls the hvc_iucv_hangup() function for the
849 * respective IUCV HVC terminal.
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100850 *
851 * Locking: struct hvc_iucv_private->lock
852 */
853static void hvc_iucv_path_severed(struct iucv_path *path, u8 ipuser[16])
854{
855 struct hvc_iucv_private *priv = path->private;
856
Hendrik Brueckner02591622009-06-16 10:30:45 +0200857 hvc_iucv_hangup(priv);
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100858}
859
860/**
861 * hvc_iucv_msg_pending() - IUCV handler to process an incoming IUCV message.
862 * @path: Pending path (struct iucv_path)
863 * @msg: Pointer to the IUCV message
864 *
Hendrik Brueckner17e19f02009-01-09 12:14:59 +0100865 * The function puts an incoming message on the input queue for later
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100866 * processing (by hvc_iucv_get_chars() / hvc_iucv_write()).
Hendrik Brueckner17e19f02009-01-09 12:14:59 +0100867 * If the tty has not yet been opened, the message is rejected.
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100868 *
869 * Locking: struct hvc_iucv_private->lock
870 */
871static void hvc_iucv_msg_pending(struct iucv_path *path,
872 struct iucv_message *msg)
873{
874 struct hvc_iucv_private *priv = path->private;
875 struct iucv_tty_buffer *rb;
876
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +0100877 /* reject messages that exceed max size of iucv_tty_msg->datalen */
878 if (msg->length > MSG_SIZE(MSG_MAX_DATALEN)) {
879 iucv_message_reject(path, msg);
880 return;
881 }
882
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100883 spin_lock(&priv->lock);
884
885 /* reject messages if tty has not yet been opened */
886 if (priv->tty_state == TTY_CLOSED) {
887 iucv_message_reject(path, msg);
888 goto unlock_return;
889 }
890
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +0100891 /* allocate tty buffer to save iucv msg only */
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100892 rb = alloc_tty_buffer(0, GFP_ATOMIC);
893 if (!rb) {
894 iucv_message_reject(path, msg);
895 goto unlock_return; /* -ENOMEM */
896 }
897 rb->msg = *msg;
898
899 list_add_tail(&rb->list, &priv->tty_inqueue);
900
Hendrik Brueckner17e19f02009-01-09 12:14:59 +0100901 hvc_kick(); /* wake up hvc thread */
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100902
903unlock_return:
904 spin_unlock(&priv->lock);
905}
906
907/**
908 * hvc_iucv_msg_complete() - IUCV handler to process message completion
909 * @path: Pending path (struct iucv_path)
910 * @msg: Pointer to the IUCV message
911 *
Hendrik Brueckner17e19f02009-01-09 12:14:59 +0100912 * The function is called upon completion of message delivery to remove the
913 * message from the outqueue. Additional delivery information can be found
914 * msg->audit: rejected messages (0x040000 (IPADRJCT)), and
915 * purged messages (0x010000 (IPADPGNR)).
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100916 *
917 * Locking: struct hvc_iucv_private->lock
918 */
919static void hvc_iucv_msg_complete(struct iucv_path *path,
920 struct iucv_message *msg)
921{
922 struct hvc_iucv_private *priv = path->private;
923 struct iucv_tty_buffer *ent, *next;
924 LIST_HEAD(list_remove);
925
926 spin_lock(&priv->lock);
927 list_for_each_entry_safe(ent, next, &priv->tty_outqueue, list)
928 if (ent->msg.id == msg->id) {
929 list_move(&ent->list, &list_remove);
930 break;
931 }
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +0100932 wake_up(&priv->sndbuf_waitq);
Hendrik Brueckner44a01d52008-12-25 13:38:57 +0100933 spin_unlock(&priv->lock);
934 destroy_tty_buffer_list(&list_remove);
935}
936
Hendrik Brueckner02591622009-06-16 10:30:45 +0200937/**
938 * hvc_iucv_pm_freeze() - Freeze PM callback
939 * @dev: IUVC HVC terminal device
940 *
941 * Sever an established IUCV communication path and
942 * trigger a hang-up of the underlying HVC terminal.
943 */
944static int hvc_iucv_pm_freeze(struct device *dev)
945{
946 struct hvc_iucv_private *priv = dev_get_drvdata(dev);
947
948 local_bh_disable();
949 hvc_iucv_hangup(priv);
950 local_bh_enable();
951
952 return 0;
953}
954
955/**
956 * hvc_iucv_pm_restore_thaw() - Thaw and restore PM callback
957 * @dev: IUVC HVC terminal device
958 *
959 * Wake up the HVC thread to trigger hang-up and respective
960 * HVC back-end notifier invocations.
961 */
962static int hvc_iucv_pm_restore_thaw(struct device *dev)
963{
964 hvc_kick();
965 return 0;
966}
967
Hendrik Bruecknerf1206ba2014-01-17 14:42:00 +0100968static ssize_t hvc_iucv_dev_termid_show(struct device *dev,
969 struct device_attribute *attr,
970 char *buf)
971{
972 struct hvc_iucv_private *priv = dev_get_drvdata(dev);
973 size_t len;
974
975 len = sizeof(priv->srv_name);
976 memcpy(buf, priv->srv_name, len);
977 EBCASC(buf, len);
978 buf[len++] = '\n';
979 return len;
980}
981
982static ssize_t hvc_iucv_dev_state_show(struct device *dev,
983 struct device_attribute *attr,
984 char *buf)
985{
986 struct hvc_iucv_private *priv = dev_get_drvdata(dev);
987 return sprintf(buf, "%u:%u\n", priv->iucv_state, priv->tty_state);
988}
989
990static ssize_t hvc_iucv_dev_peer_show(struct device *dev,
991 struct device_attribute *attr,
992 char *buf)
993{
994 struct hvc_iucv_private *priv = dev_get_drvdata(dev);
995 char vmid[9], ipuser[9];
996
997 memset(vmid, 0, sizeof(vmid));
998 memset(ipuser, 0, sizeof(ipuser));
999
1000 spin_lock_bh(&priv->lock);
1001 if (priv->iucv_state == IUCV_CONNECTED) {
1002 memcpy(vmid, priv->info_path, 8);
1003 memcpy(ipuser, priv->info_path + 8, 8);
1004 }
1005 spin_unlock_bh(&priv->lock);
1006 EBCASC(ipuser, 8);
1007
1008 return sprintf(buf, "%s:%s\n", vmid, ipuser);
1009}
1010
Hendrik Brueckner44a01d52008-12-25 13:38:57 +01001011
1012/* HVC operations */
Rusty Russell1dff3992009-11-28 12:20:26 +05301013static const struct hv_ops hvc_iucv_ops = {
Hendrik Brueckner44a01d52008-12-25 13:38:57 +01001014 .get_chars = hvc_iucv_get_chars,
1015 .put_chars = hvc_iucv_put_chars,
1016 .notifier_add = hvc_iucv_notifier_add,
1017 .notifier_del = hvc_iucv_notifier_del,
1018 .notifier_hangup = hvc_iucv_notifier_hangup,
Hendrik Brueckner74b3b4c2013-07-02 17:07:15 +02001019 .dtr_rts = hvc_iucv_dtr_rts,
Hendrik Brueckner44a01d52008-12-25 13:38:57 +01001020};
1021
Hendrik Brueckner02591622009-06-16 10:30:45 +02001022/* Suspend / resume device operations */
Alexey Dobriyan47145212009-12-14 18:00:08 -08001023static const struct dev_pm_ops hvc_iucv_pm_ops = {
Hendrik Brueckner02591622009-06-16 10:30:45 +02001024 .freeze = hvc_iucv_pm_freeze,
1025 .thaw = hvc_iucv_pm_restore_thaw,
1026 .restore = hvc_iucv_pm_restore_thaw,
1027};
1028
1029/* IUCV HVC device driver */
1030static struct device_driver hvc_iucv_driver = {
1031 .name = KMSG_COMPONENT,
1032 .bus = &iucv_bus,
1033 .pm = &hvc_iucv_pm_ops,
1034};
1035
Hendrik Bruecknerf1206ba2014-01-17 14:42:00 +01001036/* IUCV HVC device attributes */
1037static DEVICE_ATTR(termid, 0640, hvc_iucv_dev_termid_show, NULL);
1038static DEVICE_ATTR(state, 0640, hvc_iucv_dev_state_show, NULL);
1039static DEVICE_ATTR(peer, 0640, hvc_iucv_dev_peer_show, NULL);
1040static struct attribute *hvc_iucv_dev_attrs[] = {
1041 &dev_attr_termid.attr,
1042 &dev_attr_state.attr,
1043 &dev_attr_peer.attr,
1044 NULL,
1045};
1046static struct attribute_group hvc_iucv_dev_attr_group = {
1047 .attrs = hvc_iucv_dev_attrs,
1048};
1049static const struct attribute_group *hvc_iucv_dev_attr_groups[] = {
1050 &hvc_iucv_dev_attr_group,
1051 NULL,
1052};
1053
1054
Hendrik Brueckner44a01d52008-12-25 13:38:57 +01001055/**
1056 * hvc_iucv_alloc() - Allocates a new struct hvc_iucv_private instance
Hendrik Brueckner6c089fd2009-01-09 12:15:01 +01001057 * @id: hvc_iucv_table index
1058 * @is_console: Flag if the instance is used as Linux console
Hendrik Brueckner44a01d52008-12-25 13:38:57 +01001059 *
Hendrik Brueckner17e19f02009-01-09 12:14:59 +01001060 * This function allocates a new hvc_iucv_private structure and stores
1061 * the instance in hvc_iucv_table at index @id.
Hendrik Brueckner44a01d52008-12-25 13:38:57 +01001062 * Returns 0 on success; otherwise non-zero.
1063 */
Hendrik Brueckner6c089fd2009-01-09 12:15:01 +01001064static int __init hvc_iucv_alloc(int id, unsigned int is_console)
Hendrik Brueckner44a01d52008-12-25 13:38:57 +01001065{
1066 struct hvc_iucv_private *priv;
1067 char name[9];
1068 int rc;
1069
1070 priv = kzalloc(sizeof(struct hvc_iucv_private), GFP_KERNEL);
1071 if (!priv)
1072 return -ENOMEM;
1073
1074 spin_lock_init(&priv->lock);
1075 INIT_LIST_HEAD(&priv->tty_outqueue);
1076 INIT_LIST_HEAD(&priv->tty_inqueue);
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +01001077 INIT_DELAYED_WORK(&priv->sndbuf_work, hvc_iucv_sndbuf_work);
1078 init_waitqueue_head(&priv->sndbuf_waitq);
1079
1080 priv->sndbuf = (void *) get_zeroed_page(GFP_KERNEL);
1081 if (!priv->sndbuf) {
1082 kfree(priv);
1083 return -ENOMEM;
1084 }
Hendrik Brueckner44a01d52008-12-25 13:38:57 +01001085
Hendrik Brueckner6c089fd2009-01-09 12:15:01 +01001086 /* set console flag */
1087 priv->is_console = is_console;
1088
Hendrik Brueckner02591622009-06-16 10:30:45 +02001089 /* allocate hvc device */
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +01001090 priv->hvc = hvc_alloc(HVC_IUCV_MAGIC + id, /* PAGE_SIZE */
1091 HVC_IUCV_MAGIC + id, &hvc_iucv_ops, 256);
Hendrik Brueckner44a01d52008-12-25 13:38:57 +01001092 if (IS_ERR(priv->hvc)) {
1093 rc = PTR_ERR(priv->hvc);
Hendrik Brueckner02591622009-06-16 10:30:45 +02001094 goto out_error_hvc;
Hendrik Brueckner44a01d52008-12-25 13:38:57 +01001095 }
1096
Hendrik Brueckner17e19f02009-01-09 12:14:59 +01001097 /* notify HVC thread instead of using polling */
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +01001098 priv->hvc->irq_requested = 1;
1099
Hendrik Brueckner44a01d52008-12-25 13:38:57 +01001100 /* setup iucv related information */
Hendrik Brueckner2dc184c2009-01-09 12:14:57 +01001101 snprintf(name, 9, "lnxhvc%-2d", id);
Hendrik Brueckner44a01d52008-12-25 13:38:57 +01001102 memcpy(priv->srv_name, name, 8);
1103 ASCEBC(priv->srv_name, 8);
1104
Hendrik Brueckner02591622009-06-16 10:30:45 +02001105 /* create and setup device */
1106 priv->dev = kzalloc(sizeof(*priv->dev), GFP_KERNEL);
1107 if (!priv->dev) {
1108 rc = -ENOMEM;
1109 goto out_error_dev;
1110 }
1111 dev_set_name(priv->dev, "hvc_iucv%d", id);
1112 dev_set_drvdata(priv->dev, priv);
1113 priv->dev->bus = &iucv_bus;
1114 priv->dev->parent = iucv_root;
1115 priv->dev->driver = &hvc_iucv_driver;
Hendrik Bruecknerf1206ba2014-01-17 14:42:00 +01001116 priv->dev->groups = hvc_iucv_dev_attr_groups;
Hendrik Brueckner02591622009-06-16 10:30:45 +02001117 priv->dev->release = (void (*)(struct device *)) kfree;
1118 rc = device_register(priv->dev);
1119 if (rc) {
Sebastian Ottc6304932009-09-11 10:28:38 +02001120 put_device(priv->dev);
Hendrik Brueckner02591622009-06-16 10:30:45 +02001121 goto out_error_dev;
1122 }
1123
Hendrik Brueckner44a01d52008-12-25 13:38:57 +01001124 hvc_iucv_table[id] = priv;
1125 return 0;
Hendrik Brueckner02591622009-06-16 10:30:45 +02001126
1127out_error_dev:
1128 hvc_remove(priv->hvc);
1129out_error_hvc:
1130 free_page((unsigned long) priv->sndbuf);
1131 kfree(priv);
1132
1133 return rc;
1134}
1135
1136/**
1137 * hvc_iucv_destroy() - Destroy and free hvc_iucv_private instances
1138 */
1139static void __init hvc_iucv_destroy(struct hvc_iucv_private *priv)
1140{
1141 hvc_remove(priv->hvc);
1142 device_unregister(priv->dev);
1143 free_page((unsigned long) priv->sndbuf);
1144 kfree(priv);
Hendrik Brueckner44a01d52008-12-25 13:38:57 +01001145}
1146
1147/**
Hendrik Brueckner431429f2009-03-26 15:23:55 +01001148 * hvc_iucv_parse_filter() - Parse filter for a single z/VM user ID
1149 * @filter: String containing a comma-separated list of z/VM user IDs
1150 */
1151static const char *hvc_iucv_parse_filter(const char *filter, char *dest)
1152{
1153 const char *nextdelim, *residual;
1154 size_t len;
1155
1156 nextdelim = strchr(filter, ',');
1157 if (nextdelim) {
1158 len = nextdelim - filter;
1159 residual = nextdelim + 1;
1160 } else {
1161 len = strlen(filter);
1162 residual = filter + len;
1163 }
1164
1165 if (len == 0)
1166 return ERR_PTR(-EINVAL);
1167
1168 /* check for '\n' (if called from sysfs) */
1169 if (filter[len - 1] == '\n')
1170 len--;
1171
1172 if (len > 8)
1173 return ERR_PTR(-EINVAL);
1174
1175 /* pad with blanks and save upper case version of user ID */
1176 memset(dest, ' ', 8);
1177 while (len--)
1178 dest[len] = toupper(filter[len]);
1179 return residual;
1180}
1181
1182/**
1183 * hvc_iucv_setup_filter() - Set up z/VM user ID filter
1184 * @filter: String consisting of a comma-separated list of z/VM user IDs
1185 *
1186 * The function parses the @filter string and creates an array containing
1187 * the list of z/VM user ID filter entries.
1188 * Return code 0 means success, -EINVAL if the filter is syntactically
1189 * incorrect, -ENOMEM if there was not enough memory to allocate the
1190 * filter list array, or -ENOSPC if too many z/VM user IDs have been specified.
1191 */
1192static int hvc_iucv_setup_filter(const char *val)
1193{
1194 const char *residual;
1195 int err;
1196 size_t size, count;
1197 void *array, *old_filter;
1198
1199 count = strlen(val);
1200 if (count == 0 || (count == 1 && val[0] == '\n')) {
1201 size = 0;
1202 array = NULL;
1203 goto out_replace_filter; /* clear filter */
1204 }
1205
1206 /* count user IDs in order to allocate sufficient memory */
1207 size = 1;
1208 residual = val;
1209 while ((residual = strchr(residual, ',')) != NULL) {
1210 residual++;
1211 size++;
1212 }
1213
1214 /* check if the specified list exceeds the filter limit */
1215 if (size > MAX_VMID_FILTER)
1216 return -ENOSPC;
1217
1218 array = kzalloc(size * 8, GFP_KERNEL);
1219 if (!array)
1220 return -ENOMEM;
1221
1222 count = size;
1223 residual = val;
1224 while (*residual && count) {
1225 residual = hvc_iucv_parse_filter(residual,
1226 array + ((size - count) * 8));
1227 if (IS_ERR(residual)) {
1228 err = PTR_ERR(residual);
1229 kfree(array);
1230 goto out_err;
1231 }
1232 count--;
1233 }
1234
1235out_replace_filter:
1236 write_lock_bh(&hvc_iucv_filter_lock);
1237 old_filter = hvc_iucv_filter;
1238 hvc_iucv_filter_size = size;
1239 hvc_iucv_filter = array;
1240 write_unlock_bh(&hvc_iucv_filter_lock);
1241 kfree(old_filter);
1242
1243 err = 0;
1244out_err:
1245 return err;
1246}
1247
1248/**
1249 * param_set_vmidfilter() - Set z/VM user ID filter parameter
1250 * @val: String consisting of a comma-separated list of z/VM user IDs
1251 * @kp: Kernel parameter pointing to hvc_iucv_filter array
1252 *
1253 * The function sets up the z/VM user ID filter specified as comma-separated
1254 * list of user IDs in @val.
1255 * Note: If it is called early in the boot process, @val is stored and
1256 * parsed later in hvc_iucv_init().
1257 */
Sachin Sant549a8a02009-11-17 18:51:03 +05301258static int param_set_vmidfilter(const char *val, const struct kernel_param *kp)
Hendrik Brueckner431429f2009-03-26 15:23:55 +01001259{
1260 int rc;
1261
1262 if (!MACHINE_IS_VM || !hvc_iucv_devices)
1263 return -ENODEV;
1264
1265 if (!val)
1266 return -EINVAL;
1267
1268 rc = 0;
1269 if (slab_is_available())
1270 rc = hvc_iucv_setup_filter(val);
1271 else
1272 hvc_iucv_filter_string = val; /* defer... */
1273 return rc;
1274}
1275
1276/**
1277 * param_get_vmidfilter() - Get z/VM user ID filter
1278 * @buffer: Buffer to store z/VM user ID filter,
1279 * (buffer size assumption PAGE_SIZE)
1280 * @kp: Kernel parameter pointing to the hvc_iucv_filter array
1281 *
1282 * The function stores the filter as a comma-separated list of z/VM user IDs
1283 * in @buffer. Typically, sysfs routines call this function for attr show.
1284 */
Sachin Sant549a8a02009-11-17 18:51:03 +05301285static int param_get_vmidfilter(char *buffer, const struct kernel_param *kp)
Hendrik Brueckner431429f2009-03-26 15:23:55 +01001286{
1287 int rc;
1288 size_t index, len;
1289 void *start, *end;
1290
1291 if (!MACHINE_IS_VM || !hvc_iucv_devices)
1292 return -ENODEV;
1293
1294 rc = 0;
1295 read_lock_bh(&hvc_iucv_filter_lock);
1296 for (index = 0; index < hvc_iucv_filter_size; index++) {
1297 start = hvc_iucv_filter + (8 * index);
1298 end = memchr(start, ' ', 8);
1299 len = (end) ? end - start : 8;
1300 memcpy(buffer + rc, start, len);
1301 rc += len;
1302 buffer[rc++] = ',';
1303 }
1304 read_unlock_bh(&hvc_iucv_filter_lock);
1305 if (rc)
1306 buffer[--rc] = '\0'; /* replace last comma and update rc */
1307 return rc;
1308}
1309
1310#define param_check_vmidfilter(name, p) __param_check(name, p, void)
1311
Sachin Sant549a8a02009-11-17 18:51:03 +05301312static struct kernel_param_ops param_ops_vmidfilter = {
1313 .set = param_set_vmidfilter,
1314 .get = param_get_vmidfilter,
1315};
1316
Hendrik Brueckner431429f2009-03-26 15:23:55 +01001317/**
Hendrik Brueckner17e19f02009-01-09 12:14:59 +01001318 * hvc_iucv_init() - z/VM IUCV HVC device driver initialization
Hendrik Brueckner44a01d52008-12-25 13:38:57 +01001319 */
1320static int __init hvc_iucv_init(void)
1321{
Hendrik Brueckner6c089fd2009-01-09 12:15:01 +01001322 int rc;
1323 unsigned int i;
Hendrik Brueckner44a01d52008-12-25 13:38:57 +01001324
Hendrik Brueckner431429f2009-03-26 15:23:55 +01001325 if (!hvc_iucv_devices)
1326 return -ENODEV;
1327
Hendrik Brueckner44a01d52008-12-25 13:38:57 +01001328 if (!MACHINE_IS_VM) {
Hendrik Brueckner82f3a792009-03-26 15:23:54 +01001329 pr_notice("The z/VM IUCV HVC device driver cannot "
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +01001330 "be used without z/VM\n");
Hendrik Brueckner431429f2009-03-26 15:23:55 +01001331 rc = -ENODEV;
1332 goto out_error;
Hendrik Brueckner44a01d52008-12-25 13:38:57 +01001333 }
1334
Hendrik Brueckner82f3a792009-03-26 15:23:54 +01001335 if (hvc_iucv_devices > MAX_HVC_IUCV_LINES) {
1336 pr_err("%lu is not a valid value for the hvc_iucv= "
1337 "kernel parameter\n", hvc_iucv_devices);
Hendrik Brueckner431429f2009-03-26 15:23:55 +01001338 rc = -EINVAL;
1339 goto out_error;
1340 }
1341
Hendrik Brueckner02591622009-06-16 10:30:45 +02001342 /* register IUCV HVC device driver */
1343 rc = driver_register(&hvc_iucv_driver);
1344 if (rc)
1345 goto out_error;
1346
Hendrik Brueckner431429f2009-03-26 15:23:55 +01001347 /* parse hvc_iucv_allow string and create z/VM user ID filter list */
1348 if (hvc_iucv_filter_string) {
1349 rc = hvc_iucv_setup_filter(hvc_iucv_filter_string);
1350 switch (rc) {
1351 case 0:
1352 break;
1353 case -ENOMEM:
1354 pr_err("Allocating memory failed with "
1355 "reason code=%d\n", 3);
1356 goto out_error;
1357 case -EINVAL:
1358 pr_err("hvc_iucv_allow= does not specify a valid "
1359 "z/VM user ID list\n");
1360 goto out_error;
1361 case -ENOSPC:
1362 pr_err("hvc_iucv_allow= specifies too many "
1363 "z/VM user IDs\n");
1364 goto out_error;
1365 default:
1366 goto out_error;
1367 }
Hendrik Brueckner82f3a792009-03-26 15:23:54 +01001368 }
Hendrik Brueckner44a01d52008-12-25 13:38:57 +01001369
1370 hvc_iucv_buffer_cache = kmem_cache_create(KMSG_COMPONENT,
1371 sizeof(struct iucv_tty_buffer),
1372 0, 0, NULL);
1373 if (!hvc_iucv_buffer_cache) {
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +01001374 pr_err("Allocating memory failed with reason code=%d\n", 1);
Hendrik Brueckner431429f2009-03-26 15:23:55 +01001375 rc = -ENOMEM;
1376 goto out_error;
Hendrik Brueckner44a01d52008-12-25 13:38:57 +01001377 }
1378
1379 hvc_iucv_mempool = mempool_create_slab_pool(MEMPOOL_MIN_NR,
1380 hvc_iucv_buffer_cache);
1381 if (!hvc_iucv_mempool) {
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +01001382 pr_err("Allocating memory failed with reason code=%d\n", 2);
Hendrik Brueckner44a01d52008-12-25 13:38:57 +01001383 kmem_cache_destroy(hvc_iucv_buffer_cache);
Hendrik Brueckner431429f2009-03-26 15:23:55 +01001384 rc = -ENOMEM;
1385 goto out_error;
Hendrik Brueckner44a01d52008-12-25 13:38:57 +01001386 }
1387
Hendrik Brueckner68c6b3d2009-01-09 12:15:00 +01001388 /* register the first terminal device as console
1389 * (must be done before allocating hvc terminal devices) */
Hendrik Brueckner6c089fd2009-01-09 12:15:01 +01001390 rc = hvc_instantiate(HVC_IUCV_MAGIC, IUCV_HVC_CON_IDX, &hvc_iucv_ops);
1391 if (rc) {
1392 pr_err("Registering HVC terminal device as "
1393 "Linux console failed\n");
1394 goto out_error_memory;
1395 }
Hendrik Brueckner68c6b3d2009-01-09 12:15:00 +01001396
Hendrik Brueckner44a01d52008-12-25 13:38:57 +01001397 /* allocate hvc_iucv_private structs */
1398 for (i = 0; i < hvc_iucv_devices; i++) {
Hendrik Brueckner6c089fd2009-01-09 12:15:01 +01001399 rc = hvc_iucv_alloc(i, (i == IUCV_HVC_CON_IDX) ? 1 : 0);
Hendrik Brueckner44a01d52008-12-25 13:38:57 +01001400 if (rc) {
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +01001401 pr_err("Creating a new HVC terminal device "
Hendrik Brueckner17e19f02009-01-09 12:14:59 +01001402 "failed with error code=%d\n", rc);
Hendrik Brueckner44a01d52008-12-25 13:38:57 +01001403 goto out_error_hvc;
1404 }
1405 }
1406
1407 /* register IUCV callback handler */
1408 rc = iucv_register(&hvc_iucv_handler, 0);
1409 if (rc) {
Hendrik Bruecknerc45ce4b2009-01-09 12:14:58 +01001410 pr_err("Registering IUCV handlers failed with error code=%d\n",
1411 rc);
Hendrik Bruecknerc77f7cf2010-10-25 16:10:22 +02001412 goto out_error_hvc;
Hendrik Brueckner44a01d52008-12-25 13:38:57 +01001413 }
1414
1415 return 0;
1416
Hendrik Brueckner44a01d52008-12-25 13:38:57 +01001417out_error_hvc:
1418 for (i = 0; i < hvc_iucv_devices; i++)
Hendrik Brueckner02591622009-06-16 10:30:45 +02001419 if (hvc_iucv_table[i])
1420 hvc_iucv_destroy(hvc_iucv_table[i]);
Hendrik Brueckner6c089fd2009-01-09 12:15:01 +01001421out_error_memory:
Hendrik Brueckner44a01d52008-12-25 13:38:57 +01001422 mempool_destroy(hvc_iucv_mempool);
1423 kmem_cache_destroy(hvc_iucv_buffer_cache);
Hendrik Brueckner431429f2009-03-26 15:23:55 +01001424out_error:
Hendrik Bruecknerac526f42013-10-25 16:01:04 +02001425 kfree(hvc_iucv_filter);
Hendrik Brueckner431429f2009-03-26 15:23:55 +01001426 hvc_iucv_devices = 0; /* ensure that we do not provide any device */
Hendrik Brueckner44a01d52008-12-25 13:38:57 +01001427 return rc;
1428}
1429
1430/**
Hendrik Brueckner44a01d52008-12-25 13:38:57 +01001431 * hvc_iucv_config() - Parsing of hvc_iucv= kernel command line parameter
1432 * @val: Parameter value (numeric)
1433 */
1434static int __init hvc_iucv_config(char *val)
1435{
Jingoo Han86b40562013-06-01 16:30:06 +09001436 return kstrtoul(val, 10, &hvc_iucv_devices);
Hendrik Brueckner44a01d52008-12-25 13:38:57 +01001437}
1438
1439
Hendrik Brueckner68c6b3d2009-01-09 12:15:00 +01001440device_initcall(hvc_iucv_init);
Hendrik Brueckner44a01d52008-12-25 13:38:57 +01001441__setup("hvc_iucv=", hvc_iucv_config);
Hendrik Brueckner431429f2009-03-26 15:23:55 +01001442core_param(hvc_iucv_allow, hvc_iucv_filter, vmidfilter, 0640);