s390/hvc_iucv: Automatically assign free HVC terminal devices

Add the generic "lnxhvc" terminal ID to automatically assign a HVC terminal when
connecting to the HVC IUCV terminal device driver.  The terminal device driver
tries to find a free (not connected) HVC terminal to satisfy the incoming
connection request.

With this improvement, you do not longer need to guess which HVC terminal is
free, that is, not connected.  Also you can still connect to a particular HVC
terminal by using its associated terminal ID.

Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
This commit is contained in:
Hendrik Brueckner 2014-01-17 16:11:07 +01:00 committed by Martin Schwidefsky
parent f1206bad25
commit 4f5922194d
1 changed files with 26 additions and 7 deletions

View File

@ -773,16 +773,35 @@ static int hvc_iucv_filter_connreq(u8 ipvmid[8])
static int hvc_iucv_path_pending(struct iucv_path *path, static int hvc_iucv_path_pending(struct iucv_path *path,
u8 ipvmid[8], u8 ipuser[16]) u8 ipvmid[8], u8 ipuser[16])
{ {
struct hvc_iucv_private *priv; struct hvc_iucv_private *priv, *tmp;
u8 wildcard[9] = "lnxhvc ";
int i, rc, find_unused;
u8 nuser_data[16]; u8 nuser_data[16];
u8 vm_user_id[9]; u8 vm_user_id[9];
int i, rc;
ASCEBC(wildcard, sizeof(wildcard));
find_unused = !memcmp(wildcard, ipuser, 8);
/* First, check if the pending path request is managed by this
* IUCV handler:
* - find a disconnected device if ipuser contains the wildcard
* - find the device that matches the terminal ID in ipuser
*/
priv = NULL; priv = NULL;
for (i = 0; i < hvc_iucv_devices; i++) for (i = 0; i < hvc_iucv_devices; i++) {
if (hvc_iucv_table[i] && tmp = hvc_iucv_table[i];
(0 == memcmp(hvc_iucv_table[i]->srv_name, ipuser, 8))) { if (!tmp)
priv = hvc_iucv_table[i]; continue;
if (find_unused) {
spin_lock(&tmp->lock);
if (tmp->iucv_state == IUCV_DISCONN)
priv = tmp;
spin_unlock(&tmp->lock);
} else if (!memcmp(tmp->srv_name, ipuser, 8))
priv = tmp;
if (priv)
break; break;
} }
if (!priv) if (!priv)