Commit eebce385 authored by Martin Schwidefsky's avatar Martin Schwidefsky Committed by David S. Miller

[S390]: Adapt netiucv driver to new IUCV API

Adapt netiucv network device driver to new IUCV API
Signed-off-by: default avatarFrank Pavlic <fpavlic@de.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c9101c5b
/* /*
* IUCV network driver * IUCV network driver
* *
* Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation * Copyright 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation
* Author(s): Fritz Elfert (elfert@de.ibm.com, felfert@millenux.com) * Author(s): Fritz Elfert (elfert@de.ibm.com, felfert@millenux.com)
* *
* Sysfs integration and all bugs therein by Cornelia Huck * Sysfs integration and all bugs therein by Cornelia Huck
...@@ -58,13 +58,94 @@ ...@@ -58,13 +58,94 @@
#include <asm/io.h> #include <asm/io.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "iucv.h" #include <net/iucv/iucv.h>
#include "fsm.h" #include "fsm.h"
MODULE_AUTHOR MODULE_AUTHOR
("(C) 2001 IBM Corporation by Fritz Elfert (felfert@millenux.com)"); ("(C) 2001 IBM Corporation by Fritz Elfert (felfert@millenux.com)");
MODULE_DESCRIPTION ("Linux for S/390 IUCV network driver"); MODULE_DESCRIPTION ("Linux for S/390 IUCV network driver");
/**
* Debug Facility stuff
*/
#define IUCV_DBF_SETUP_NAME "iucv_setup"
#define IUCV_DBF_SETUP_LEN 32
#define IUCV_DBF_SETUP_PAGES 2
#define IUCV_DBF_SETUP_NR_AREAS 1
#define IUCV_DBF_SETUP_LEVEL 3
#define IUCV_DBF_DATA_NAME "iucv_data"
#define IUCV_DBF_DATA_LEN 128
#define IUCV_DBF_DATA_PAGES 2
#define IUCV_DBF_DATA_NR_AREAS 1
#define IUCV_DBF_DATA_LEVEL 2
#define IUCV_DBF_TRACE_NAME "iucv_trace"
#define IUCV_DBF_TRACE_LEN 16
#define IUCV_DBF_TRACE_PAGES 4
#define IUCV_DBF_TRACE_NR_AREAS 1
#define IUCV_DBF_TRACE_LEVEL 3
#define IUCV_DBF_TEXT(name,level,text) \
do { \
debug_text_event(iucv_dbf_##name,level,text); \
} while (0)
#define IUCV_DBF_HEX(name,level,addr,len) \
do { \
debug_event(iucv_dbf_##name,level,(void*)(addr),len); \
} while (0)
DECLARE_PER_CPU(char[256], iucv_dbf_txt_buf);
#define IUCV_DBF_TEXT_(name,level,text...) \
do { \
char* iucv_dbf_txt_buf = get_cpu_var(iucv_dbf_txt_buf); \
sprintf(iucv_dbf_txt_buf, text); \
debug_text_event(iucv_dbf_##name,level,iucv_dbf_txt_buf); \
put_cpu_var(iucv_dbf_txt_buf); \
} while (0)
#define IUCV_DBF_SPRINTF(name,level,text...) \
do { \
debug_sprintf_event(iucv_dbf_trace, level, ##text ); \
debug_sprintf_event(iucv_dbf_trace, level, text ); \
} while (0)
/**
* some more debug stuff
*/
#define IUCV_HEXDUMP16(importance,header,ptr) \
PRINT_##importance(header "%02x %02x %02x %02x %02x %02x %02x %02x " \
"%02x %02x %02x %02x %02x %02x %02x %02x\n", \
*(((char*)ptr)),*(((char*)ptr)+1),*(((char*)ptr)+2), \
*(((char*)ptr)+3),*(((char*)ptr)+4),*(((char*)ptr)+5), \
*(((char*)ptr)+6),*(((char*)ptr)+7),*(((char*)ptr)+8), \
*(((char*)ptr)+9),*(((char*)ptr)+10),*(((char*)ptr)+11), \
*(((char*)ptr)+12),*(((char*)ptr)+13), \
*(((char*)ptr)+14),*(((char*)ptr)+15)); \
PRINT_##importance(header "%02x %02x %02x %02x %02x %02x %02x %02x " \
"%02x %02x %02x %02x %02x %02x %02x %02x\n", \
*(((char*)ptr)+16),*(((char*)ptr)+17), \
*(((char*)ptr)+18),*(((char*)ptr)+19), \
*(((char*)ptr)+20),*(((char*)ptr)+21), \
*(((char*)ptr)+22),*(((char*)ptr)+23), \
*(((char*)ptr)+24),*(((char*)ptr)+25), \
*(((char*)ptr)+26),*(((char*)ptr)+27), \
*(((char*)ptr)+28),*(((char*)ptr)+29), \
*(((char*)ptr)+30),*(((char*)ptr)+31));
static inline void iucv_hex_dump(unsigned char *buf, size_t len)
{
size_t i;
for (i = 0; i < len; i++) {
if (i && !(i % 16))
printk("\n");
printk("%02x ", *(buf + i));
}
printk("\n");
}
#define PRINTK_HEADER " iucv: " /* for debugging */ #define PRINTK_HEADER " iucv: " /* for debugging */
...@@ -73,6 +154,25 @@ static struct device_driver netiucv_driver = { ...@@ -73,6 +154,25 @@ static struct device_driver netiucv_driver = {
.bus = &iucv_bus, .bus = &iucv_bus,
}; };
static int netiucv_callback_connreq(struct iucv_path *,
u8 ipvmid[8], u8 ipuser[16]);
static void netiucv_callback_connack(struct iucv_path *, u8 ipuser[16]);
static void netiucv_callback_connrej(struct iucv_path *, u8 ipuser[16]);
static void netiucv_callback_connsusp(struct iucv_path *, u8 ipuser[16]);
static void netiucv_callback_connres(struct iucv_path *, u8 ipuser[16]);
static void netiucv_callback_rx(struct iucv_path *, struct iucv_message *);
static void netiucv_callback_txdone(struct iucv_path *, struct iucv_message *);
static struct iucv_handler netiucv_handler = {
.path_pending = netiucv_callback_connreq,
.path_complete = netiucv_callback_connack,
.path_severed = netiucv_callback_connrej,
.path_quiesced = netiucv_callback_connsusp,
.path_resumed = netiucv_callback_connres,
.message_pending = netiucv_callback_rx,
.message_complete = netiucv_callback_txdone
};
/** /**
* Per connection profiling data * Per connection profiling data
*/ */
...@@ -92,9 +192,8 @@ struct connection_profile { ...@@ -92,9 +192,8 @@ struct connection_profile {
* Representation of one iucv connection * Representation of one iucv connection
*/ */
struct iucv_connection { struct iucv_connection {
struct iucv_connection *next; struct list_head list;
iucv_handle_t handle; struct iucv_path *path;
__u16 pathid;
struct sk_buff *rx_buff; struct sk_buff *rx_buff;
struct sk_buff *tx_buff; struct sk_buff *tx_buff;
struct sk_buff_head collect_queue; struct sk_buff_head collect_queue;
...@@ -112,12 +211,9 @@ struct iucv_connection { ...@@ -112,12 +211,9 @@ struct iucv_connection {
/** /**
* Linked list of all connection structs. * Linked list of all connection structs.
*/ */
struct iucv_connection_struct { static struct list_head iucv_connection_list =
struct iucv_connection *iucv_connections; LIST_HEAD_INIT(iucv_connection_list);
rwlock_t iucv_rwlock; static rwlock_t iucv_connection_rwlock = RW_LOCK_UNLOCKED;
};
static struct iucv_connection_struct iucv_conns;
/** /**
* Representation of event-data for the * Representation of event-data for the
...@@ -142,11 +238,11 @@ struct netiucv_priv { ...@@ -142,11 +238,11 @@ struct netiucv_priv {
/** /**
* Link level header for a packet. * Link level header for a packet.
*/ */
typedef struct ll_header_t { struct ll_header {
__u16 next; u16 next;
} ll_header; };
#define NETIUCV_HDRLEN (sizeof(ll_header)) #define NETIUCV_HDRLEN (sizeof(struct ll_header))
#define NETIUCV_BUFSIZE_MAX 32768 #define NETIUCV_BUFSIZE_MAX 32768
#define NETIUCV_BUFSIZE_DEFAULT NETIUCV_BUFSIZE_MAX #define NETIUCV_BUFSIZE_DEFAULT NETIUCV_BUFSIZE_MAX
#define NETIUCV_MTU_MAX (NETIUCV_BUFSIZE_MAX - NETIUCV_HDRLEN) #define NETIUCV_MTU_MAX (NETIUCV_BUFSIZE_MAX - NETIUCV_HDRLEN)
...@@ -158,35 +254,25 @@ typedef struct ll_header_t { ...@@ -158,35 +254,25 @@ typedef struct ll_header_t {
* Compatibility macros for busy handling * Compatibility macros for busy handling
* of network devices. * of network devices.
*/ */
static __inline__ void netiucv_clear_busy(struct net_device *dev) static inline void netiucv_clear_busy(struct net_device *dev)
{ {
clear_bit(0, &(((struct netiucv_priv *)dev->priv)->tbusy)); struct netiucv_priv *priv = netdev_priv(dev);
clear_bit(0, &priv->tbusy);
netif_wake_queue(dev); netif_wake_queue(dev);
} }
static __inline__ int netiucv_test_and_set_busy(struct net_device *dev) static inline int netiucv_test_and_set_busy(struct net_device *dev)
{ {
struct netiucv_priv *priv = netdev_priv(dev);
netif_stop_queue(dev); netif_stop_queue(dev);
return test_and_set_bit(0, &((struct netiucv_priv *)dev->priv)->tbusy); return test_and_set_bit(0, &priv->tbusy);
} }
static __u8 iucv_host[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; static u8 iucvMagic[16] = {
static __u8 iucvMagic[16] = {
0xF0, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0xF0, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
0xF0, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40 0xF0, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40
}; };
/**
* This mask means the 16-byte IUCV "magic" and the origin userid must
* match exactly as specified in order to give connection_pending()
* control.
*/
static __u8 netiucv_mask[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
/** /**
* Convert an iucv userId to its printable * Convert an iucv userId to its printable
* form (strip whitespace at end). * form (strip whitespace at end).
...@@ -195,8 +281,7 @@ static __u8 netiucv_mask[] = { ...@@ -195,8 +281,7 @@ static __u8 netiucv_mask[] = {
* *
* @returns The printable string (static data!!) * @returns The printable string (static data!!)
*/ */
static __inline__ char * static inline char *netiucv_printname(char *name)
netiucv_printname(char *name)
{ {
static char tmp[9]; static char tmp[9];
char *p = tmp; char *p = tmp;
...@@ -379,8 +464,7 @@ static debug_info_t *iucv_dbf_trace = NULL; ...@@ -379,8 +464,7 @@ static debug_info_t *iucv_dbf_trace = NULL;
DEFINE_PER_CPU(char[256], iucv_dbf_txt_buf); DEFINE_PER_CPU(char[256], iucv_dbf_txt_buf);
static void static void iucv_unregister_dbf_views(void)
iucv_unregister_dbf_views(void)
{ {
if (iucv_dbf_setup) if (iucv_dbf_setup)
debug_unregister(iucv_dbf_setup); debug_unregister(iucv_dbf_setup);
...@@ -389,8 +473,7 @@ iucv_unregister_dbf_views(void) ...@@ -389,8 +473,7 @@ iucv_unregister_dbf_views(void)
if (iucv_dbf_trace) if (iucv_dbf_trace)
debug_unregister(iucv_dbf_trace); debug_unregister(iucv_dbf_trace);
} }
static int static int iucv_register_dbf_views(void)
iucv_register_dbf_views(void)
{ {
iucv_dbf_setup = debug_register(IUCV_DBF_SETUP_NAME, iucv_dbf_setup = debug_register(IUCV_DBF_SETUP_NAME,
IUCV_DBF_SETUP_PAGES, IUCV_DBF_SETUP_PAGES,
...@@ -422,125 +505,111 @@ iucv_register_dbf_views(void) ...@@ -422,125 +505,111 @@ iucv_register_dbf_views(void)
return 0; return 0;
} }
/** /*
* Callback-wrappers, called from lowlevel iucv layer. * Callback-wrappers, called from lowlevel iucv layer.
*****************************************************************************/ */
static void static void netiucv_callback_rx(struct iucv_path *path,
netiucv_callback_rx(iucv_MessagePending *eib, void *pgm_data) struct iucv_message *msg)
{ {
struct iucv_connection *conn = (struct iucv_connection *)pgm_data; struct iucv_connection *conn = path->private;
struct iucv_event ev; struct iucv_event ev;
ev.conn = conn; ev.conn = conn;
ev.data = (void *)eib; ev.data = msg;
fsm_event(conn->fsm, CONN_EVENT_RX, &ev); fsm_event(conn->fsm, CONN_EVENT_RX, &ev);
} }
static void static void netiucv_callback_txdone(struct iucv_path *path,
netiucv_callback_txdone(iucv_MessageComplete *eib, void *pgm_data) struct iucv_message *msg)
{ {
struct iucv_connection *conn = (struct iucv_connection *)pgm_data; struct iucv_connection *conn = path->private;
struct iucv_event ev; struct iucv_event ev;
ev.conn = conn; ev.conn = conn;
ev.data = (void *)eib; ev.data = msg;
fsm_event(conn->fsm, CONN_EVENT_TXDONE, &ev); fsm_event(conn->fsm, CONN_EVENT_TXDONE, &ev);
} }
static void static void netiucv_callback_connack(struct iucv_path *path, u8 ipuser[16])
netiucv_callback_connack(iucv_ConnectionComplete *eib, void *pgm_data)
{ {
struct iucv_connection *conn = (struct iucv_connection *)pgm_data; struct iucv_connection *conn = path->private;
struct iucv_event ev;
ev.conn = conn; fsm_event(conn->fsm, CONN_EVENT_CONN_ACK, conn);
ev.data = (void *)eib;
fsm_event(conn->fsm, CONN_EVENT_CONN_ACK, &ev);
} }
static void static int netiucv_callback_connreq(struct iucv_path *path,
netiucv_callback_connreq(iucv_ConnectionPending *eib, void *pgm_data) u8 ipvmid[8], u8 ipuser[16])
{ {
struct iucv_connection *conn = (struct iucv_connection *)pgm_data; struct iucv_connection *conn = path->private;
struct iucv_event ev; struct iucv_event ev;
int rc;
ev.conn = conn; if (memcmp(iucvMagic, ipuser, sizeof(ipuser)))
ev.data = (void *)eib; /* ipuser must match iucvMagic. */
fsm_event(conn->fsm, CONN_EVENT_CONN_REQ, &ev); return -EINVAL;
rc = -EINVAL;
read_lock_bh(&iucv_connection_rwlock);
list_for_each_entry(conn, &iucv_connection_list, list) {
if (strncmp(ipvmid, conn->userid, 8))
continue;
/* Found a matching connection for this path. */
conn->path = path;
ev.conn = conn;
ev.data = path;
fsm_event(conn->fsm, CONN_EVENT_CONN_REQ, &ev);
rc = 0;
}
read_unlock_bh(&iucv_connection_rwlock);
return rc;
} }
static void static void netiucv_callback_connrej(struct iucv_path *path, u8 ipuser[16])
netiucv_callback_connrej(iucv_ConnectionSevered *eib, void *pgm_data)
{ {
struct iucv_connection *conn = (struct iucv_connection *)pgm_data; struct iucv_connection *conn = path->private;
struct iucv_event ev;
ev.conn = conn; fsm_event(conn->fsm, CONN_EVENT_CONN_REJ, conn);
ev.data = (void *)eib;
fsm_event(conn->fsm, CONN_EVENT_CONN_REJ, &ev);
} }
static void static void netiucv_callback_connsusp(struct iucv_path *path, u8 ipuser[16])
netiucv_callback_connsusp(iucv_ConnectionQuiesced *eib, void *pgm_data)
{ {
struct iucv_connection *conn = (struct iucv_connection *)pgm_data; struct iucv_connection *conn = path->private;
struct iucv_event ev;
ev.conn = conn; fsm_event(conn->fsm, CONN_EVENT_CONN_SUS, conn);
ev.data = (void *)eib;
fsm_event(conn->fsm, CONN_EVENT_CONN_SUS, &ev);
} }
static void static void netiucv_callback_connres(struct iucv_path *path, u8 ipuser[16])
netiucv_callback_connres(iucv_ConnectionResumed *eib, void *pgm_data)
{ {
struct iucv_connection *conn = (struct iucv_connection *)pgm_data; struct iucv_connection *conn = path->private;
struct iucv_event ev;
ev.conn = conn; fsm_event(conn->fsm, CONN_EVENT_CONN_RES, conn);
ev.data = (void *)eib; }
fsm_event(conn->fsm, CONN_EVENT_CONN_RES, &ev);
}
static iucv_interrupt_ops_t netiucv_ops = {
.ConnectionPending = netiucv_callback_connreq,
.ConnectionComplete = netiucv_callback_connack,
.ConnectionSevered = netiucv_callback_connrej,
.ConnectionQuiesced = netiucv_callback_connsusp,
.ConnectionResumed = netiucv_callback_connres,
.MessagePending = netiucv_callback_rx,
.MessageComplete = netiucv_callback_txdone
};
/** /**
* Dummy NOP action for all statemachines * Dummy NOP action for all statemachines
*/ */
static void static void fsm_action_nop(fsm_instance *fi, int event, void *arg)
fsm_action_nop(fsm_instance *fi, int event, void *arg)
{ {
} }
/** /*
* Actions of the connection statemachine * Actions of the connection statemachine
*****************************************************************************/ */
/** /**
* Helper function for conn_action_rx() * netiucv_unpack_skb
* Unpack a just received skb and hand it over to * @conn: The connection where this skb has been received.
* upper layers. * @pskb: The received skb.
* *
* @param conn The connection where this skb has been received. * Unpack a just received skb and hand it over to upper layers.
* @param pskb The received skb. * Helper function for conn_action_rx.
*/ */
//static __inline__ void static void netiucv_unpack_skb(struct iucv_connection *conn,
static void struct sk_buff *pskb)
netiucv_unpack_skb(struct iucv_connection *conn, struct sk_buff *pskb)
{ {
struct net_device *dev = conn->netdev; struct net_device *dev = conn->netdev;
struct netiucv_priv *privptr = dev->priv; struct netiucv_priv *privptr = netdev_priv(dev);
__u16 offset = 0; u16 offset = 0;
skb_put(pskb, NETIUCV_HDRLEN); skb_put(pskb, NETIUCV_HDRLEN);
pskb->dev = dev; pskb->dev = dev;
...@@ -549,7 +618,7 @@ netiucv_unpack_skb(struct iucv_connection *conn, struct sk_buff *pskb) ...@@ -549,7 +618,7 @@ netiucv_unpack_skb(struct iucv_connection *conn, struct sk_buff *pskb)
while (1) { while (1) {
struct sk_buff *skb; struct sk_buff *skb;
ll_header *header = (ll_header *)pskb->data; struct ll_header *header = (struct ll_header *) pskb->data;
if (!header->next) if (!header->next)
break; break;
...@@ -595,40 +664,37 @@ netiucv_unpack_skb(struct iucv_connection *conn, struct sk_buff *pskb) ...@@ -595,40 +664,37 @@ netiucv_unpack_skb(struct iucv_connection *conn, struct sk_buff *pskb)
} }
} }
static void static void conn_action_rx(fsm_instance *fi, int event, void *arg)
conn_action_rx(fsm_instance *fi, int event, void *arg)
{ {
struct iucv_event *ev = (struct iucv_event *)arg; struct iucv_event *ev = arg;
struct iucv_connection *conn = ev->conn; struct iucv_connection *conn = ev->conn;
iucv_MessagePending *eib = (iucv_MessagePending *)ev->data; struct iucv_message *msg = ev->data;
struct netiucv_priv *privptr =(struct netiucv_priv *)conn->netdev->priv; struct netiucv_priv *privptr = netdev_priv(conn->netdev);
__u32 msglen = eib->ln1msg2.ipbfln1f;
int rc; int rc;
IUCV_DBF_TEXT(trace, 4, __FUNCTION__); IUCV_DBF_TEXT(trace, 4, __FUNCTION__);
if (!conn->netdev) { if (!conn->netdev) {
/* FRITZ: How to tell iucv LL to drop the msg? */ iucv_message_reject(conn->path, msg);
PRINT_WARN("Received data for unlinked connection\n"); PRINT_WARN("Received data for unlinked connection\n");
IUCV_DBF_TEXT(data, 2, IUCV_DBF_TEXT(data, 2,
"Received data for unlinked connection\n"); "Received data for unlinked connection\n");
return; return;
} }
if (msglen > conn->max_buffsize) { if (msg->length > conn->max_buffsize) {
/* FRITZ: How to tell iucv LL to drop the msg? */ iucv_message_reject(conn->path, msg);
privptr->stats.rx_dropped++; privptr->stats.rx_dropped++;
PRINT_WARN("msglen %d > max_buffsize %d\n", PRINT_WARN("msglen %d > max_buffsize %d\n",
msglen, conn->max_buffsize); msg->length, conn->max_buffsize);
IUCV_DBF_TEXT_(data, 2, "msglen %d > max_buffsize %d\n", IUCV_DBF_TEXT_(data, 2, "msglen %d > max_buffsize %d\n",
msglen, conn->max_buffsize); msg->length, conn->max_buffsize);
return; return;
} }
conn->rx_buff->data = conn->rx_buff->tail = conn->rx_buff->head; conn->rx_buff->data = conn->rx_buff->tail = conn->rx_buff->head;
conn->rx_buff->len = 0; conn->rx_buff->len = 0;
rc = iucv_receive(conn->pathid, eib->ipmsgid, eib->iptrgcls, rc = iucv_message_receive(conn->path, msg, 0, conn->rx_buff->data,
conn->rx_buff->data, msglen, NULL, NULL, NULL); msg->length, NULL);
if (rc || msglen < 5) { if (rc || msg->length < 5) {
privptr->stats.rx_errors++; privptr->stats.rx_errors++;
PRINT_WARN("iucv_receive returned %08x\n", rc); PRINT_WARN("iucv_receive returned %08x\n", rc);
IUCV_DBF_TEXT_(data, 2, "rc %d from iucv_receive\n", rc); IUCV_DBF_TEXT_(data, 2, "rc %d from iucv_receive\n", rc);
...@@ -637,26 +703,26 @@ conn_action_rx(fsm_instance *fi, int event, void *arg) ...@@ -637,26 +703,26 @@ conn_action_rx(fsm_instance *fi, int event, void *arg)
netiucv_unpack_skb(conn, conn->rx_buff); netiucv_unpack_skb(conn, conn->rx_buff);
} }
static void static void conn_action_txdone(fsm_instance *fi, int event, void *arg)
conn_action_txdone(fsm_instance *fi, int event, void *arg)
{ {
struct iucv_event *ev = (struct iucv_event *)arg; struct iucv_event *ev = arg;
struct iucv_connection *conn = ev->conn; struct iucv_connection *conn = ev->conn;
iucv_MessageComplete *eib = (iucv_MessageComplete *)ev->data; struct iucv_message *msg = ev->data;
struct iucv_message txmsg;
struct netiucv_priv *privptr = NULL; struct netiucv_priv *privptr = NULL;
/* Shut up, gcc! skb is always below 2G. */ u32 single_flag = msg->tag;
__u32 single_flag = eib->ipmsgtag; u32 txbytes = 0;
__u32 txbytes = 0; u32 txpackets = 0;
__u32 txpackets = 0; u32 stat_maxcq = 0;
__u32 stat_maxcq = 0;
struct sk_buff *skb; struct sk_buff *skb;
unsigned long saveflags; unsigned long saveflags;
ll_header header; struct ll_header header;
int rc;
IUCV_DBF_TEXT(trace, 4, __FUNCTION__); IUCV_DBF_TEXT(trace, 4, __FUNCTION__);
if (conn && conn->netdev && conn->netdev->priv) if (conn && conn->netdev)
privptr = (struct netiucv_priv *)conn->netdev->priv; privptr = netdev_priv(conn->netdev);
conn->prof.tx_pending--; conn->prof.tx_pending--;
if (single_flag) { if (single_flag) {
if ((skb = skb_dequeue(&conn->commit_queue))) { if ((skb = skb_dequeue(&conn->commit_queue))) {
...@@ -688,56 +754,55 @@ conn_action_txdone(fsm_instance *fi, int event, void *arg) ...@@ -688,56 +754,55 @@ conn_action_txdone(fsm_instance *fi, int event, void *arg)
conn->prof.maxmulti = conn->collect_len; conn->prof.maxmulti = conn->collect_len;
conn->collect_len = 0; conn->collect_len = 0;
spin_unlock_irqrestore(&conn->collect_lock, saveflags); spin_unlock_irqrestore(&conn->collect_lock, saveflags);
if (conn->tx_buff->len) { if (conn->tx_buff->len == 0) {
int rc; fsm_newstate(fi, CONN_STATE_IDLE);
return;
header.next = 0; }
memcpy(skb_put(conn->tx_buff, NETIUCV_HDRLEN), &header,
NETIUCV_HDRLEN);
conn->prof.send_stamp = xtime; header.next = 0;
rc = iucv_send(conn->pathid, NULL, 0, 0, 0, 0, memcpy(skb_put(conn->tx_buff, NETIUCV_HDRLEN), &header, NETIUCV_HDRLEN);
conn->prof.send_stamp = xtime;
txmsg.class = 0;
txmsg.tag = 0;
rc = iucv_message_send(conn->path, &txmsg, 0, 0,
conn->tx_buff->data, conn->tx_buff->len); conn->tx_buff->data, conn->tx_buff->len);
conn->prof.doios_multi++; conn->prof.doios_multi++;
conn->prof.txlen += conn->tx_buff->len; conn->prof.txlen += conn->tx_buff->len;
conn->prof.tx_pending++; conn->prof.tx_pending++;
if (conn->prof.tx_pending > conn->prof.tx_max_pending) if (conn->prof.tx_pending > conn->prof.tx_max_pending)
conn->prof.tx_max_pending = conn->prof.tx_pending; conn->prof.tx_max_pending = conn->prof.tx_pending;
if (rc) { if (rc) {
conn->prof.tx_pending--; conn->prof.tx_pending--;
fsm_newstate(fi, CONN_STATE_IDLE);
if (privptr)
privptr->stats.tx_errors += txpackets;
PRINT_WARN("iucv_send returned %08x\n", rc);
IUCV_DBF_TEXT_(data, 2, "rc %d from iucv_send\n", rc);
} else {
if (privptr) {
privptr->stats.tx_packets += txpackets;
privptr->stats.tx_bytes += txbytes;
}
if (stat_maxcq > conn->prof.maxcqueue)
conn->prof.maxcqueue = stat_maxcq;
}
} else
fsm_newstate(fi, CONN_STATE_IDLE); fsm_newstate(fi, CONN_STATE_IDLE);
if (privptr)
privptr->stats.tx_errors += txpackets;
PRINT_WARN("iucv_send returned %08x\n", rc);
IUCV_DBF_TEXT_(data, 2, "rc %d from iucv_send\n", rc);
} else {
if (privptr) {
privptr->stats.tx_packets += txpackets;
privptr->stats.tx_bytes += txbytes;
}
if (stat_maxcq > conn->prof.maxcqueue)
conn->prof.maxcqueue = stat_maxcq;
}
} }
static void static void conn_action_connaccept(fsm_instance *fi, int event, void *arg)
conn_action_connaccept(fsm_instance *fi, int event, void *arg)
{ {
struct iucv_event *ev = (struct iucv_event *)arg; struct iucv_event *ev = arg;
struct iucv_connection *conn = ev->conn; struct iucv_connection *conn = ev->conn;
iucv_ConnectionPending *eib = (iucv_ConnectionPending *)ev->data; struct iucv_path *path = ev->data;
struct net_device *netdev = conn->netdev; struct net_device *netdev = conn->netdev;
struct netiucv_priv *privptr = (struct netiucv_priv *)netdev->priv; struct netiucv_priv *privptr = netdev_priv(netdev);
int rc; int rc;
__u16 msglimit;
__u8 udata[16];
IUCV_DBF_TEXT(trace, 3, __FUNCTION__); IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
rc = iucv_accept(eib->ippathid, NETIUCV_QUEUELEN_DEFAULT, udata, 0, conn->path = path;
conn->handle, conn, NULL, &msglimit); path->msglim = NETIUCV_QUEUELEN_DEFAULT;
path->flags = 0;
rc = iucv_path_accept(path, &netiucv_handler, NULL, conn);
if (rc) { if (rc) {
PRINT_WARN("%s: IUCV accept failed with error %d\n", PRINT_WARN("%s: IUCV accept failed with error %d\n",
netdev->name, rc); netdev->name, rc);
...@@ -745,183 +810,126 @@ conn_action_connaccept(fsm_instance *fi, int event, void *arg) ...@@ -745,183 +810,126 @@ conn_action_connaccept(fsm_instance *fi, int event, void *arg)
return; return;
} }
fsm_newstate(fi, CONN_STATE_IDLE); fsm_newstate(fi, CONN_STATE_IDLE);
conn->pathid = eib->ippathid; netdev->tx_queue_len = conn->path->msglim;
netdev->tx_queue_len = msglimit;
fsm_event(privptr->fsm, DEV_EVENT_CONUP, netdev); fsm_event(privptr->fsm, DEV_EVENT_CONUP, netdev);
} }
static void static void conn_action_connreject(fsm_instance *fi, int event, void *arg)
conn_action_connreject(fsm_instance *fi, int event, void *arg)
{ {
struct iucv_event *ev = (struct iucv_event *)arg; struct iucv_event *ev = arg;
struct iucv_connection *conn = ev->conn; struct iucv_path *path = ev->data;
struct net_device *netdev = conn->netdev;
iucv_ConnectionPending *eib = (iucv_ConnectionPending *)ev->data;
__u8 udata[16];
IUCV_DBF_TEXT(trace, 3, __FUNCTION__); IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
iucv_path_sever(path, NULL);
iucv_sever(eib->ippathid, udata);
if (eib->ippathid != conn->pathid) {
PRINT_INFO("%s: IR Connection Pending; "
"pathid %d does not match original pathid %d\n",
netdev->name, eib->ippathid, conn->pathid);
IUCV_DBF_TEXT_(data, 2,
"connreject: IR pathid %d, conn. pathid %d\n",
eib->ippathid, conn->pathid);
iucv_sever(conn->pathid, udata);
}
} }
static void static void conn_action_connack(fsm_instance *fi, int event, void *arg)
conn_action_connack(fsm_instance *fi, int event, void *arg)
{ {
struct iucv_event *ev = (struct iucv_event *)arg; struct iucv_connection *conn = arg;
struct iucv_connection *conn = ev->conn;
iucv_ConnectionComplete *eib = (iucv_ConnectionComplete *)ev->data;
struct net_device *netdev = conn->netdev; struct net_device *netdev = conn->netdev;
struct netiucv_priv *privptr = (struct netiucv_priv *)netdev->priv; struct netiucv_priv *privptr = netdev_priv(netdev);
IUCV_DBF_TEXT(trace, 3, __FUNCTION__); IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
fsm_deltimer(&conn->timer); fsm_deltimer(&conn->timer);
fsm_newstate(fi, CONN_STATE_IDLE); fsm_newstate(fi, CONN_STATE_IDLE);
if (eib->ippathid != conn->pathid) { netdev->tx_queue_len = conn->path->msglim;
PRINT_INFO("%s: IR Connection Complete; "
"pathid %d does not match original pathid %d\n",
netdev->name, eib->ippathid, conn->pathid);
IUCV_DBF_TEXT_(data, 2,
"connack: IR pathid %d, conn. pathid %d\n",
eib->ippathid, conn->pathid);
conn->pathid = eib->ippathid;
}
netdev->tx_queue_len = eib->ipmsglim;
fsm_event(privptr->fsm, DEV_EVENT_CONUP, netdev); fsm_event(privptr->fsm, DEV_EVENT_CONUP, netdev);
} }
static void static void conn_action_conntimsev(fsm_instance *fi, int event, void *arg)
conn_action_conntimsev(fsm_instance *fi, int event, void *arg)
{ {
struct iucv_connection *conn = (struct iucv_connection *)arg; struct iucv_connection *conn = arg;
__u8 udata[16];
IUCV_DBF_TEXT(trace, 3, __FUNCTION__); IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
fsm_deltimer(&conn->timer); fsm_deltimer(&conn->timer);
iucv_sever(conn->pathid, udata); iucv_path_sever(conn->path, NULL);
fsm_newstate(fi, CONN_STATE_STARTWAIT); fsm_newstate(fi, CONN_STATE_STARTWAIT);
} }
static void static void conn_action_connsever(fsm_instance *fi, int event, void *arg)
conn_action_connsever(fsm_instance *fi, int event, void *arg)
{ {
struct iucv_event *ev = (struct iucv_event *)arg; struct iucv_connection *conn = arg;
struct iucv_connection *conn = ev->conn;
struct net_device *netdev = conn->netdev; struct net_device *netdev = conn->netdev;
struct netiucv_priv *privptr = (struct netiucv_priv *)netdev->priv; struct netiucv_priv *privptr = netdev_priv(netdev);
__u8 udata[16];
IUCV_DBF_TEXT(trace, 3, __FUNCTION__); IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
fsm_deltimer(&conn->timer); fsm_deltimer(&conn->timer);
iucv_sever(conn->pathid, udata); iucv_path_sever(conn->path, NULL);
PRINT_INFO("%s: Remote dropped connection\n", netdev->name); PRINT_INFO("%s: Remote dropped connection\n", netdev->name);
IUCV_DBF_TEXT(data, 2, IUCV_DBF_TEXT(data, 2,
"conn_action_connsever: Remote dropped connection\n"); "conn_action_connsever: Remote dropped connection\n");
fsm_newstate(fi, CONN_STATE_STARTWAIT); fsm_newstate(fi, CONN_STATE_STARTWAIT);
fsm_event(privptr->fsm, DEV_EVENT_CONDOWN, netdev); fsm_event(privptr->fsm, DEV_EVENT_CONDOWN, netdev);
} }
static void static void conn_action_start(fsm_instance *fi, int event, void *arg)
conn_action_start(fsm_instance *fi, int event, void *arg)
{ {
struct iucv_event *ev = (struct iucv_event *)arg; struct iucv_connection *conn = arg;
struct iucv_connection *conn = ev->conn;
__u16 msglimit;
int rc; int rc;
IUCV_DBF_TEXT(trace, 3, __FUNCTION__); IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
if (!conn->handle) { fsm_newstate(fi, CONN_STATE_STARTWAIT);
IUCV_DBF_TEXT(trace, 5, "calling iucv_register_program\n");
conn->handle =
iucv_register_program(iucvMagic, conn->userid,
netiucv_mask,
&netiucv_ops, conn);
fsm_newstate(fi, CONN_STATE_STARTWAIT);
if (!conn->handle) {
fsm_newstate(fi, CONN_STATE_REGERR);
conn->handle = NULL;
IUCV_DBF_TEXT(setup, 2,
"NULL from iucv_register_program\n");
return;
}
PRINT_DEBUG("%s('%s'): registered successfully\n",
conn->netdev->name, conn->userid);
}
PRINT_DEBUG("%s('%s'): connecting ...\n", PRINT_DEBUG("%s('%s'): connecting ...\n",
conn->netdev->name, conn->userid); conn->netdev->name, conn->userid);
/* We must set the state before calling iucv_connect because the callback /*
* handler could be called at any point after the connection request is * We must set the state before calling iucv_connect because the
* sent */ * callback handler could be called at any point after the connection
* request is sent
*/
fsm_newstate(fi, CONN_STATE_SETUPWAIT); fsm_newstate(fi, CONN_STATE_SETUPWAIT);
rc = iucv_connect(&(conn->pathid), NETIUCV_QUEUELEN_DEFAULT, iucvMagic, conn->path = iucv_path_alloc(NETIUCV_QUEUELEN_DEFAULT, 0, GFP_KERNEL);
conn->userid, iucv_host, 0, NULL, &msglimit, rc = iucv_path_connect(conn->path, &netiucv_handler, conn->userid,
conn->handle, conn); NULL, iucvMagic, conn);
switch (rc) { switch (rc) {
case 0: case 0:
conn->netdev->tx_queue_len = msglimit; conn->netdev->tx_queue_len = conn->path->msglim;
fsm_addtimer(&conn->timer, NETIUCV_TIMEOUT_5SEC, fsm_addtimer(&conn->timer, NETIUCV_TIMEOUT_5SEC,
CONN_EVENT_TIMER, conn); CONN_EVENT_TIMER, conn);
return; return;
case 11: case 11:
PRINT_INFO("%s: User %s is currently not available.\n", PRINT_INFO("%s: User %s is currently not available.\n",
conn->netdev->name, conn->netdev->name,
netiucv_printname(conn->userid)); netiucv_printname(conn->userid));
fsm_newstate(fi, CONN_STATE_STARTWAIT); fsm_newstate(fi, CONN_STATE_STARTWAIT);
return; break;
case 12: case 12:
PRINT_INFO("%s: User %s is currently not ready.\n", PRINT_INFO("%s: User %s is currently not ready.\n",
conn->netdev->name, conn->netdev->name,
netiucv_printname(conn->userid)); netiucv_printname(conn->userid));
fsm_newstate(fi, CONN_STATE_STARTWAIT); fsm_newstate(fi, CONN_STATE_STARTWAIT);
return; break;
case 13: case 13:
PRINT_WARN("%s: Too many IUCV connections.\n", PRINT_WARN("%s: Too many IUCV connections.\n",
conn->netdev->name); conn->netdev->name);
fsm_newstate(fi, CONN_STATE_CONNERR); fsm_newstate(fi, CONN_STATE_CONNERR);
break; break;
case 14: case 14:
PRINT_WARN( PRINT_WARN("%s: User %s has too many IUCV connections.\n",
"%s: User %s has too many IUCV connections.\n", conn->netdev->name,
conn->netdev->name, netiucv_printname(conn->userid));
netiucv_printname(conn->userid)); fsm_newstate(fi, CONN_STATE_CONNERR);
fsm_newstate(fi, CONN_STATE_CONNERR); break;
break; case 15:
case 15: PRINT_WARN("%s: No IUCV authorization in CP directory.\n",
PRINT_WARN( conn->netdev->name);
"%s: No IUCV authorization in CP directory.\n", fsm_newstate(fi, CONN_STATE_CONNERR);
conn->netdev->name); break;
fsm_newstate(fi, CONN_STATE_CONNERR); default:
break; PRINT_WARN("%s: iucv_connect returned error %d\n",
default: conn->netdev->name, rc);
PRINT_WARN("%s: iucv_connect returned error %d\n", fsm_newstate(fi, CONN_STATE_CONNERR);
conn->netdev->name, rc); break;
fsm_newstate(fi, CONN_STATE_CONNERR);
break;
} }
IUCV_DBF_TEXT_(setup, 5, "iucv_connect rc is %d\n", rc); IUCV_DBF_TEXT_(setup, 5, "iucv_connect rc is %d\n", rc);
IUCV_DBF_TEXT(trace, 5, "calling iucv_unregister_program\n"); kfree(conn->path);
iucv_unregister_program(conn->handle); conn->path = NULL;
conn->handle = NULL;
} }
static void static void netiucv_purge_skb_queue(struct sk_buff_head *q)
netiucv_purge_skb_queue(struct sk_buff_head *q)
{ {
struct sk_buff *skb; struct sk_buff *skb;
...@@ -931,36 +939,34 @@ netiucv_purge_skb_queue(struct sk_buff_head *q) ...@@ -931,36 +939,34 @@ netiucv_purge_skb_queue(struct sk_buff_head *q)
} }
} }
static void static void conn_action_stop(fsm_instance *fi, int event, void *arg)
conn_action_stop(fsm_instance *fi, int event, void *arg)
{ {
struct iucv_event *ev = (struct iucv_event *)arg; struct iucv_event *ev = arg;
struct iucv_connection *conn = ev->conn; struct iucv_connection *conn = ev->conn;
struct net_device *netdev = conn->netdev; struct net_device *netdev = conn->netdev;
struct netiucv_priv *privptr = (struct netiucv_priv *)netdev->priv; struct netiucv_priv *privptr = netdev_priv(netdev);
IUCV_DBF_TEXT(trace, 3, __FUNCTION__); IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
fsm_deltimer(&conn->timer); fsm_deltimer(&conn->timer);
fsm_newstate(fi, CONN_STATE_STOPPED); fsm_newstate(fi, CONN_STATE_STOPPED);
netiucv_purge_skb_queue(&conn->collect_queue); netiucv_purge_skb_queue(&conn->collect_queue);
if (conn->handle) if (conn->path) {
IUCV_DBF_TEXT(trace, 5, "calling iucv_unregister_program\n"); IUCV_DBF_TEXT(trace, 5, "calling iucv_path_sever\n");
iucv_unregister_program(conn->handle); iucv_path_sever(conn->path, iucvMagic);
conn->handle = NULL; kfree(conn->path);
conn->path = NULL;
}
netiucv_purge_skb_queue(&conn->commit_queue); netiucv_purge_skb_queue(&conn->commit_queue);
fsm_event(privptr->fsm, DEV_EVENT_CONDOWN, netdev); fsm_event(privptr->fsm, DEV_EVENT_CONDOWN, netdev);
} }
static void static void conn_action_inval(fsm_instance *fi, int event, void *arg)
conn_action_inval(fsm_instance *fi, int event, void *arg)
{ {
struct iucv_event *ev = (struct iucv_event *)arg; struct iucv_connection *conn = arg;
struct iucv_connection *conn = ev->conn;
struct net_device *netdev = conn->netdev; struct net_device *netdev = conn->netdev;
PRINT_WARN("%s: Cannot connect without username\n", PRINT_WARN("%s: Cannot connect without username\n", netdev->name);
netdev->name);
IUCV_DBF_TEXT(data, 2, "conn_action_inval called\n"); IUCV_DBF_TEXT(data, 2, "conn_action_inval called\n");
} }
...@@ -999,29 +1005,27 @@ static const fsm_node conn_fsm[] = { ...@@ -999,29 +1005,27 @@ static const fsm_node conn_fsm[] = {
static const int CONN_FSM_LEN = sizeof(conn_fsm) / sizeof(fsm_node); static const int CONN_FSM_LEN = sizeof(conn_fsm) / sizeof(fsm_node);
/** /*
* Actions for interface - statemachine. * Actions for interface - statemachine.
*****************************************************************************/ */
/** /**
* Startup connection by sending CONN_EVENT_START to it. * dev_action_start
* @fi: An instance of an interface statemachine.
* @event: The event, just happened.
* @arg: Generic pointer, casted from struct net_device * upon call.
* *
* @param fi An instance of an interface statemachine. * Startup connection by sending CONN_EVENT_START to it.
* @param event The event, just happened.
* @param arg Generic pointer, casted from struct net_device * upon call.
*/ */
static void static void dev_action_start(fsm_instance *fi, int event, void *arg)
dev_action_start(fsm_instance *fi, int event, void *arg)
{ {
struct net_device *dev = (struct net_device *)arg; struct net_device *dev = arg;
struct netiucv_priv *privptr = dev->priv; struct netiucv_priv *privptr = netdev_priv(dev);
struct iucv_event ev;
IUCV_DBF_TEXT(trace, 3, __FUNCTION__); IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
ev.conn = privptr->conn;
fsm_newstate(fi, DEV_STATE_STARTWAIT); fsm_newstate(fi, DEV_STATE_STARTWAIT);
fsm_event(privptr->conn->fsm, CONN_EVENT_START, &ev); fsm_event(privptr->conn->fsm, CONN_EVENT_START, privptr->conn);
} }
/** /**
...@@ -1034,8 +1038,8 @@ dev_action_start(fsm_instance *fi, int event, void *arg) ...@@ -1034,8 +1038,8 @@ dev_action_start(fsm_instance *fi, int event, void *arg)
static void static void
dev_action_stop(fsm_instance *fi, int event, void *arg) dev_action_stop(fsm_instance *fi, int event, void *arg)
{ {
struct net_device *dev = (struct net_device *)arg; struct net_device *dev = arg;
struct netiucv_priv *privptr = dev->priv; struct netiucv_priv *privptr = netdev_priv(dev);
struct iucv_event ev; struct iucv_event ev;
IUCV_DBF_TEXT(trace, 3, __FUNCTION__); IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
...@@ -1057,8 +1061,8 @@ dev_action_stop(fsm_instance *fi, int event, void *arg) ...@@ -1057,8 +1061,8 @@ dev_action_stop(fsm_instance *fi, int event, void *arg)
static void static void
dev_action_connup(fsm_instance *fi, int event, void *arg) dev_action_connup(fsm_instance *fi, int event, void *arg)
{ {
struct net_device *dev = (struct net_device *)arg; struct net_device *dev = arg;
struct netiucv_priv *privptr = dev->priv; struct netiucv_priv *privptr = netdev_priv(dev);
IUCV_DBF_TEXT(trace, 3, __FUNCTION__); IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
...@@ -1131,11 +1135,13 @@ static const int DEV_FSM_LEN = sizeof(dev_fsm) / sizeof(fsm_node); ...@@ -1131,11 +1135,13 @@ static const int DEV_FSM_LEN = sizeof(dev_fsm) / sizeof(fsm_node);
* *
* @return 0 on success, -ERRNO on failure. (Never fails.) * @return 0 on success, -ERRNO on failure. (Never fails.)
*/ */
static int static int netiucv_transmit_skb(struct iucv_connection *conn,
netiucv_transmit_skb(struct iucv_connection *conn, struct sk_buff *skb) { struct sk_buff *skb)
{
struct iucv_message msg;
unsigned long saveflags; unsigned long saveflags;
ll_header header; struct ll_header header;
int rc = 0; int rc;
if (fsm_getstate(conn->fsm) != CONN_STATE_IDLE) { if (fsm_getstate(conn->fsm) != CONN_STATE_IDLE) {
int l = skb->len + NETIUCV_HDRLEN; int l = skb->len + NETIUCV_HDRLEN;
...@@ -1145,11 +1151,12 @@ netiucv_transmit_skb(struct iucv_connection *conn, struct sk_buff *skb) { ...@@ -1145,11 +1151,12 @@ netiucv_transmit_skb(struct iucv_connection *conn, struct sk_buff *skb) {
(conn->max_buffsize - NETIUCV_HDRLEN)) { (conn->max_buffsize - NETIUCV_HDRLEN)) {
rc = -EBUSY; rc = -EBUSY;
IUCV_DBF_TEXT(data, 2, IUCV_DBF_TEXT(data, 2,
"EBUSY from netiucv_transmit_skb\n"); "EBUSY from netiucv_transmit_skb\n");
} else { } else {
atomic_inc(&skb->users); atomic_inc(&skb->users);
skb_queue_tail(&conn->collect_queue, skb); skb_queue_tail(&conn->collect_queue, skb);
conn->collect_len += l; conn->collect_len += l;
rc = 0;
} }
spin_unlock_irqrestore(&conn->collect_lock, saveflags); spin_unlock_irqrestore(&conn->collect_lock, saveflags);
} else { } else {
...@@ -1188,9 +1195,10 @@ netiucv_transmit_skb(struct iucv_connection *conn, struct sk_buff *skb) { ...@@ -1188,9 +1195,10 @@ netiucv_transmit_skb(struct iucv_connection *conn, struct sk_buff *skb) {
fsm_newstate(conn->fsm, CONN_STATE_TX); fsm_newstate(conn->fsm, CONN_STATE_TX);
conn->prof.send_stamp = xtime; conn->prof.send_stamp = xtime;
rc = iucv_send(conn->pathid, NULL, 0, 0, 1 /* single_flag */, msg.tag = 1;
0, nskb->data, nskb->len); msg.class = 0;
/* Shut up, gcc! nskb is always below 2G. */ rc = iucv_message_send(conn->path, &msg, 0, 0,
nskb->data, nskb->len);
conn->prof.doios_single++; conn->prof.doios_single++;
conn->prof.txlen += skb->len; conn->prof.txlen += skb->len;
conn->prof.tx_pending++; conn->prof.tx_pending++;
...@@ -1200,7 +1208,7 @@ netiucv_transmit_skb(struct iucv_connection *conn, struct sk_buff *skb) { ...@@ -1200,7 +1208,7 @@ netiucv_transmit_skb(struct iucv_connection *conn, struct sk_buff *skb) {
struct netiucv_priv *privptr; struct netiucv_priv *privptr;
fsm_newstate(conn->fsm, CONN_STATE_IDLE); fsm_newstate(conn->fsm, CONN_STATE_IDLE);
conn->prof.tx_pending--; conn->prof.tx_pending--;
privptr = (struct netiucv_priv *)conn->netdev->priv; privptr = netdev_priv(conn->netdev);
if (privptr) if (privptr)
privptr->stats.tx_errors++; privptr->stats.tx_errors++;
if (copied) if (copied)
...@@ -1226,9 +1234,9 @@ netiucv_transmit_skb(struct iucv_connection *conn, struct sk_buff *skb) { ...@@ -1226,9 +1234,9 @@ netiucv_transmit_skb(struct iucv_connection *conn, struct sk_buff *skb) {
return rc; return rc;
} }
/** /*
* Interface API for upper network layers * Interface API for upper network layers
*****************************************************************************/ */
/** /**
* Open an interface. * Open an interface.
...@@ -1238,9 +1246,11 @@ netiucv_transmit_skb(struct iucv_connection *conn, struct sk_buff *skb) { ...@@ -1238,9 +1246,11 @@ netiucv_transmit_skb(struct iucv_connection *conn, struct sk_buff *skb) {
* *
* @return 0 on success, -ERRNO on failure. (Never fails.) * @return 0 on success, -ERRNO on failure. (Never fails.)
*/ */
static int static int netiucv_open(struct net_device *dev)
netiucv_open(struct net_device *dev) { {
fsm_event(((struct netiucv_priv *)dev->priv)->fsm, DEV_EVENT_START,dev); struct netiucv_priv *priv = netdev_priv(dev);
fsm_event(priv->fsm, DEV_EVENT_START, dev);
return 0; return 0;
} }
...@@ -1252,9 +1262,11 @@ netiucv_open(struct net_device *dev) { ...@@ -1252,9 +1262,11 @@ netiucv_open(struct net_device *dev) {
* *
* @return 0 on success, -ERRNO on failure. (Never fails.) * @return 0 on success, -ERRNO on failure. (Never fails.)
*/ */
static int static int netiucv_close(struct net_device *dev)
netiucv_close(struct net_device *dev) { {
fsm_event(((struct netiucv_priv *)dev->priv)->fsm, DEV_EVENT_STOP, dev); struct netiucv_priv *priv = netdev_priv(dev);
fsm_event(priv->fsm, DEV_EVENT_STOP, dev);
return 0; return 0;
} }
...@@ -1271,8 +1283,8 @@ netiucv_close(struct net_device *dev) { ...@@ -1271,8 +1283,8 @@ netiucv_close(struct net_device *dev) {
*/ */
static int netiucv_tx(struct sk_buff *skb, struct net_device *dev) static int netiucv_tx(struct sk_buff *skb, struct net_device *dev)
{ {
int rc = 0; struct netiucv_priv *privptr = netdev_priv(dev);
struct netiucv_priv *privptr = dev->priv; int rc;
IUCV_DBF_TEXT(trace, 4, __FUNCTION__); IUCV_DBF_TEXT(trace, 4, __FUNCTION__);
/** /**
...@@ -1312,40 +1324,41 @@ static int netiucv_tx(struct sk_buff *skb, struct net_device *dev) ...@@ -1312,40 +1324,41 @@ static int netiucv_tx(struct sk_buff *skb, struct net_device *dev)
return -EBUSY; return -EBUSY;
} }
dev->trans_start = jiffies; dev->trans_start = jiffies;
if (netiucv_transmit_skb(privptr->conn, skb)) rc = netiucv_transmit_skb(privptr->conn, skb) != 0;
rc = 1;
netiucv_clear_busy(dev); netiucv_clear_busy(dev);
return rc; return rc;
} }
/** /**
* Returns interface statistics of a device. * netiucv_stats
* @dev: Pointer to interface struct.
* *
* @param dev Pointer to interface struct. * Returns interface statistics of a device.
* *
* @return Pointer to stats struct of this interface. * Returns pointer to stats struct of this interface.
*/ */
static struct net_device_stats * static struct net_device_stats *netiucv_stats (struct net_device * dev)
netiucv_stats (struct net_device * dev)
{ {
struct netiucv_priv *priv = netdev_priv(dev);
IUCV_DBF_TEXT(trace, 5, __FUNCTION__); IUCV_DBF_TEXT(trace, 5, __FUNCTION__);
return &((struct netiucv_priv *)dev->priv)->stats; return &priv->stats;
} }
/** /**
* Sets MTU of an interface. * netiucv_change_mtu
* @dev: Pointer to interface struct.
* @new_mtu: The new MTU to use for this interface.
* *
* @param dev Pointer to interface struct. * Sets MTU of an interface.
* @param new_mtu The new MTU to use for this interface.
* *
* @return 0 on success, -EINVAL if MTU is out of valid range. * Returns 0 on success, -EINVAL if MTU is out of valid range.
* (valid range is 576 .. NETIUCV_MTU_MAX). * (valid range is 576 .. NETIUCV_MTU_MAX).
*/ */
static int static int netiucv_change_mtu(struct net_device * dev, int new_mtu)
netiucv_change_mtu (struct net_device * dev, int new_mtu)
{ {
IUCV_DBF_TEXT(trace, 3, __FUNCTION__); IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
if ((new_mtu < 576) || (new_mtu > NETIUCV_MTU_MAX)) { if (new_mtu < 576 || new_mtu > NETIUCV_MTU_MAX) {
IUCV_DBF_TEXT(setup, 2, "given MTU out of valid range\n"); IUCV_DBF_TEXT(setup, 2, "given MTU out of valid range\n");
return -EINVAL; return -EINVAL;
} }
...@@ -1353,12 +1366,12 @@ netiucv_change_mtu (struct net_device * dev, int new_mtu) ...@@ -1353,12 +1366,12 @@ netiucv_change_mtu (struct net_device * dev, int new_mtu)
return 0; return 0;
} }
/** /*
* attributes in sysfs * attributes in sysfs
*****************************************************************************/ */
static ssize_t static ssize_t user_show(struct device *dev, struct device_attribute *attr,
user_show (struct device *dev, struct device_attribute *attr, char *buf) char *buf)
{ {
struct netiucv_priv *priv = dev->driver_data; struct netiucv_priv *priv = dev->driver_data;
...@@ -1366,8 +1379,8 @@ user_show (struct device *dev, struct device_attribute *attr, char *buf) ...@@ -1366,8 +1379,8 @@ user_show (struct device *dev, struct device_attribute *attr, char *buf)
return sprintf(buf, "%s\n", netiucv_printname(priv->conn->userid)); return sprintf(buf, "%s\n", netiucv_printname(priv->conn->userid));
} }
static ssize_t static ssize_t user_write(struct device *dev, struct device_attribute *attr,
user_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) const char *buf, size_t count)
{ {
struct netiucv_priv *priv = dev->driver_data; struct netiucv_priv *priv = dev->driver_data;
struct net_device *ndev = priv->conn->netdev; struct net_device *ndev = priv->conn->netdev;
...@@ -1375,80 +1388,70 @@ user_write (struct device *dev, struct device_attribute *attr, const char *buf, ...@@ -1375,80 +1388,70 @@ user_write (struct device *dev, struct device_attribute *attr, const char *buf,
char *tmp; char *tmp;
char username[9]; char username[9];
int i; int i;
struct iucv_connection **clist = &iucv_conns.iucv_connections; struct iucv_connection *cp;
unsigned long flags;
IUCV_DBF_TEXT(trace, 3, __FUNCTION__); IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
if (count>9) { if (count > 9) {
PRINT_WARN("netiucv: username too long (%d)!\n", (int)count); PRINT_WARN("netiucv: username too long (%d)!\n", (int) count);
IUCV_DBF_TEXT_(setup, 2, IUCV_DBF_TEXT_(setup, 2,
"%d is length of username\n", (int)count); "%d is length of username\n", (int) count);
return -EINVAL; return -EINVAL;
} }
tmp = strsep((char **) &buf, "\n"); tmp = strsep((char **) &buf, "\n");
for (i=0, p=tmp; i<8 && *p; i++, p++) { for (i = 0, p = tmp; i < 8 && *p; i++, p++) {
if (isalnum(*p) || (*p == '$')) if (isalnum(*p) || (*p == '$')) {
username[i]= toupper(*p); username[i]= toupper(*p);
else if (*p == '\n') { continue;
}
if (*p == '\n') {
/* trailing lf, grr */ /* trailing lf, grr */
break; break;
} else {
PRINT_WARN("netiucv: Invalid char %c in username!\n",
*p);
IUCV_DBF_TEXT_(setup, 2,
"username: invalid character %c\n",
*p);
return -EINVAL;
} }
PRINT_WARN("netiucv: Invalid char %c in username!\n", *p);
IUCV_DBF_TEXT_(setup, 2,
"username: invalid character %c\n", *p);
return -EINVAL;
} }
while (i<8) while (i < 8)
username[i++] = ' '; username[i++] = ' ';
username[8] = '\0'; username[8] = '\0';
if (memcmp(username, priv->conn->userid, 9)) { if (memcmp(username, priv->conn->userid, 9) &&
/* username changed */ (ndev->flags & (IFF_UP | IFF_RUNNING))) {
if (ndev->flags & (IFF_UP | IFF_RUNNING)) { /* username changed while the interface is active. */
PRINT_WARN( PRINT_WARN("netiucv: device %s active, connected to %s\n",
"netiucv: device %s active, connected to %s\n", dev->bus_id, priv->conn->userid);
dev->bus_id, priv->conn->userid); PRINT_WARN("netiucv: user cannot be updated\n");
PRINT_WARN("netiucv: user cannot be updated\n"); IUCV_DBF_TEXT(setup, 2, "user_write: device active\n");
IUCV_DBF_TEXT(setup, 2, "user_write: device active\n"); return -EBUSY;
return -EBUSY; }
read_lock_bh(&iucv_connection_rwlock);
list_for_each_entry(cp, &iucv_connection_list, list) {
if (!strncmp(username, cp->userid, 9) && cp->netdev != ndev) {
read_unlock_bh(&iucv_connection_rwlock);
PRINT_WARN("netiucv: Connection to %s already "
"exists\n", username);
return -EEXIST;
} }
} }
read_lock_irqsave(&iucv_conns.iucv_rwlock, flags); read_unlock_bh(&iucv_connection_rwlock);
while (*clist) {
if (!strncmp(username, (*clist)->userid, 9) ||
((*clist)->netdev != ndev))
break;
clist = &((*clist)->next);
}
read_unlock_irqrestore(&iucv_conns.iucv_rwlock, flags);
if (*clist) {
PRINT_WARN("netiucv: Connection to %s already exists\n",
username);
return -EEXIST;
}
memcpy(priv->conn->userid, username, 9); memcpy(priv->conn->userid, username, 9);
return count; return count;
} }
static DEVICE_ATTR(user, 0644, user_show, user_write); static DEVICE_ATTR(user, 0644, user_show, user_write);
static ssize_t static ssize_t buffer_show (struct device *dev, struct device_attribute *attr,
buffer_show (struct device *dev, struct device_attribute *attr, char *buf) char *buf)
{ { struct netiucv_priv *priv = dev->driver_data;
struct netiucv_priv *priv = dev->driver_data;
IUCV_DBF_TEXT(trace, 5, __FUNCTION__); IUCV_DBF_TEXT(trace, 5, __FUNCTION__);
return sprintf(buf, "%d\n", priv->conn->max_buffsize); return sprintf(buf, "%d\n", priv->conn->max_buffsize);
} }
static ssize_t static ssize_t buffer_write (struct device *dev, struct device_attribute *attr,
buffer_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) const char *buf, size_t count)
{ {
struct netiucv_priv *priv = dev->driver_data; struct netiucv_priv *priv = dev->driver_data;
struct net_device *ndev = priv->conn->netdev; struct net_device *ndev = priv->conn->netdev;
...@@ -1502,8 +1505,8 @@ buffer_write (struct device *dev, struct device_attribute *attr, const char *buf ...@@ -1502,8 +1505,8 @@ buffer_write (struct device *dev, struct device_attribute *attr, const char *buf
static DEVICE_ATTR(buffer, 0644, buffer_show, buffer_write); static DEVICE_ATTR(buffer, 0644, buffer_show, buffer_write);
static ssize_t static ssize_t dev_fsm_show (struct device *dev, struct device_attribute *attr,
dev_fsm_show (struct device *dev, struct device_attribute *attr, char *buf) char *buf)
{ {
struct netiucv_priv *priv = dev->driver_data; struct netiucv_priv *priv = dev->driver_data;
...@@ -1513,8 +1516,8 @@ dev_fsm_show (struct device *dev, struct device_attribute *attr, char *buf) ...@@ -1513,8 +1516,8 @@ dev_fsm_show (struct device *dev, struct device_attribute *attr, char *buf)
static DEVICE_ATTR(device_fsm_state, 0444, dev_fsm_show, NULL); static DEVICE_ATTR(device_fsm_state, 0444, dev_fsm_show, NULL);
static ssize_t static ssize_t conn_fsm_show (struct device *dev,
conn_fsm_show (struct device *dev, struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct netiucv_priv *priv = dev->driver_data; struct netiucv_priv *priv = dev->driver_data;
...@@ -1524,8 +1527,8 @@ conn_fsm_show (struct device *dev, struct device_attribute *attr, char *buf) ...@@ -1524,8 +1527,8 @@ conn_fsm_show (struct device *dev, struct device_attribute *attr, char *buf)
static DEVICE_ATTR(connection_fsm_state, 0444, conn_fsm_show, NULL); static DEVICE_ATTR(connection_fsm_state, 0444, conn_fsm_show, NULL);
static ssize_t static ssize_t maxmulti_show (struct device *dev,
maxmulti_show (struct device *dev, struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct netiucv_priv *priv = dev->driver_data; struct netiucv_priv *priv = dev->driver_data;
...@@ -1533,8 +1536,9 @@ maxmulti_show (struct device *dev, struct device_attribute *attr, char *buf) ...@@ -1533,8 +1536,9 @@ maxmulti_show (struct device *dev, struct device_attribute *attr, char *buf)
return sprintf(buf, "%ld\n", priv->conn->prof.maxmulti); return sprintf(buf, "%ld\n", priv->conn->prof.maxmulti);
} }
static ssize_t static ssize_t maxmulti_write (struct device *dev,
maxmulti_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) struct device_attribute *attr,
const char *buf, size_t count)
{ {
struct netiucv_priv *priv = dev->driver_data; struct netiucv_priv *priv = dev->driver_data;
...@@ -1545,8 +1549,8 @@ maxmulti_write (struct device *dev, struct device_attribute *attr, const char *b ...@@ -1545,8 +1549,8 @@ maxmulti_write (struct device *dev, struct device_attribute *attr, const char *b
static DEVICE_ATTR(max_tx_buffer_used, 0644, maxmulti_show, maxmulti_write); static DEVICE_ATTR(max_tx_buffer_used, 0644, maxmulti_show, maxmulti_write);
static ssize_t static ssize_t maxcq_show (struct device *dev, struct device_attribute *attr,
maxcq_show (struct device *dev, struct device_attribute *attr, char *buf) char *buf)
{ {
struct netiucv_priv *priv = dev->driver_data; struct netiucv_priv *priv = dev->driver_data;
...@@ -1554,8 +1558,8 @@ maxcq_show (struct device *dev, struct device_attribute *attr, char *buf) ...@@ -1554,8 +1558,8 @@ maxcq_show (struct device *dev, struct device_attribute *attr, char *buf)
return sprintf(buf, "%ld\n", priv->conn->prof.maxcqueue); return sprintf(buf, "%ld\n", priv->conn->prof.maxcqueue);
} }
static ssize_t static ssize_t maxcq_write (struct device *dev, struct device_attribute *attr,
maxcq_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) const char *buf, size_t count)
{ {
struct netiucv_priv *priv = dev->driver_data; struct netiucv_priv *priv = dev->driver_data;
...@@ -1566,8 +1570,8 @@ maxcq_write (struct device *dev, struct device_attribute *attr, const char *buf, ...@@ -1566,8 +1570,8 @@ maxcq_write (struct device *dev, struct device_attribute *attr, const char *buf,
static DEVICE_ATTR(max_chained_skbs, 0644, maxcq_show, maxcq_write); static DEVICE_ATTR(max_chained_skbs, 0644, maxcq_show, maxcq_write);
static ssize_t static ssize_t sdoio_show (struct device *dev, struct device_attribute *attr,
sdoio_show (struct device *dev, struct device_attribute *attr, char *buf) char *buf)
{ {
struct netiucv_priv *priv = dev->driver_data; struct netiucv_priv *priv = dev->driver_data;
...@@ -1575,8 +1579,8 @@ sdoio_show (struct device *dev, struct device_attribute *attr, char *buf) ...@@ -1575,8 +1579,8 @@ sdoio_show (struct device *dev, struct device_attribute *attr, char *buf)
return sprintf(buf, "%ld\n", priv->conn->prof.doios_single); return sprintf(buf, "%ld\n", priv->conn->prof.doios_single);
} }
static ssize_t static ssize_t sdoio_write (struct device *dev, struct device_attribute *attr,
sdoio_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) const char *buf, size_t count)
{ {
struct netiucv_priv *priv = dev->driver_data; struct netiucv_priv *priv = dev->driver_data;
...@@ -1587,8 +1591,8 @@ sdoio_write (struct device *dev, struct device_attribute *attr, const char *buf, ...@@ -1587,8 +1591,8 @@ sdoio_write (struct device *dev, struct device_attribute *attr, const char *buf,
static DEVICE_ATTR(tx_single_write_ops, 0644, sdoio_show, sdoio_write); static DEVICE_ATTR(tx_single_write_ops, 0644, sdoio_show, sdoio_write);
static ssize_t static ssize_t mdoio_show (struct device *dev, struct device_attribute *attr,
mdoio_show (struct device *dev, struct device_attribute *attr, char *buf) char *buf)
{ {
struct netiucv_priv *priv = dev->driver_data; struct netiucv_priv *priv = dev->driver_data;
...@@ -1596,8 +1600,8 @@ mdoio_show (struct device *dev, struct device_attribute *attr, char *buf) ...@@ -1596,8 +1600,8 @@ mdoio_show (struct device *dev, struct device_attribute *attr, char *buf)
return sprintf(buf, "%ld\n", priv->conn->prof.doios_multi); return sprintf(buf, "%ld\n", priv->conn->prof.doios_multi);
} }
static ssize_t static ssize_t mdoio_write (struct device *dev, struct device_attribute *attr,
mdoio_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) const char *buf, size_t count)
{ {
struct netiucv_priv *priv = dev->driver_data; struct netiucv_priv *priv = dev->driver_data;
...@@ -1608,8 +1612,8 @@ mdoio_write (struct device *dev, struct device_attribute *attr, const char *buf, ...@@ -1608,8 +1612,8 @@ mdoio_write (struct device *dev, struct device_attribute *attr, const char *buf,
static DEVICE_ATTR(tx_multi_write_ops, 0644, mdoio_show, mdoio_write); static DEVICE_ATTR(tx_multi_write_ops, 0644, mdoio_show, mdoio_write);
static ssize_t static ssize_t txlen_show (struct device *dev, struct device_attribute *attr,
txlen_show (struct device *dev, struct device_attribute *attr, char *buf) char *buf)
{ {
struct netiucv_priv *priv = dev->driver_data; struct netiucv_priv *priv = dev->driver_data;
...@@ -1617,8 +1621,8 @@ txlen_show (struct device *dev, struct device_attribute *attr, char *buf) ...@@ -1617,8 +1621,8 @@ txlen_show (struct device *dev, struct device_attribute *attr, char *buf)
return sprintf(buf, "%ld\n", priv->conn->prof.txlen); return sprintf(buf, "%ld\n", priv->conn->prof.txlen);
} }
static ssize_t static ssize_t txlen_write (struct device *dev, struct device_attribute *attr,
txlen_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) const char *buf, size_t count)
{ {
struct netiucv_priv *priv = dev->driver_data; struct netiucv_priv *priv = dev->driver_data;
...@@ -1629,8 +1633,8 @@ txlen_write (struct device *dev, struct device_attribute *attr, const char *buf, ...@@ -1629,8 +1633,8 @@ txlen_write (struct device *dev, struct device_attribute *attr, const char *buf,
static DEVICE_ATTR(netto_bytes, 0644, txlen_show, txlen_write); static DEVICE_ATTR(netto_bytes, 0644, txlen_show, txlen_write);
static ssize_t static ssize_t txtime_show (struct device *dev, struct device_attribute *attr,
txtime_show (struct device *dev, struct device_attribute *attr, char *buf) char *buf)
{ {
struct netiucv_priv *priv = dev->driver_data; struct netiucv_priv *priv = dev->driver_data;
...@@ -1638,8 +1642,8 @@ txtime_show (struct device *dev, struct device_attribute *attr, char *buf) ...@@ -1638,8 +1642,8 @@ txtime_show (struct device *dev, struct device_attribute *attr, char *buf)
return sprintf(buf, "%ld\n", priv->conn->prof.tx_time); return sprintf(buf, "%ld\n", priv->conn->prof.tx_time);
} }
static ssize_t static ssize_t txtime_write (struct device *dev, struct device_attribute *attr,
txtime_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) const char *buf, size_t count)
{ {
struct netiucv_priv *priv = dev->driver_data; struct netiucv_priv *priv = dev->driver_data;
...@@ -1650,8 +1654,8 @@ txtime_write (struct device *dev, struct device_attribute *attr, const char *buf ...@@ -1650,8 +1654,8 @@ txtime_write (struct device *dev, struct device_attribute *attr, const char *buf
static DEVICE_ATTR(max_tx_io_time, 0644, txtime_show, txtime_write); static DEVICE_ATTR(max_tx_io_time, 0644, txtime_show, txtime_write);
static ssize_t static ssize_t txpend_show (struct device *dev, struct device_attribute *attr,
txpend_show (struct device *dev, struct device_attribute *attr, char *buf) char *buf)
{ {
struct netiucv_priv *priv = dev->driver_data; struct netiucv_priv *priv = dev->driver_data;
...@@ -1659,8 +1663,8 @@ txpend_show (struct device *dev, struct device_attribute *attr, char *buf) ...@@ -1659,8 +1663,8 @@ txpend_show (struct device *dev, struct device_attribute *attr, char *buf)
return sprintf(buf, "%ld\n", priv->conn->prof.tx_pending); return sprintf(buf, "%ld\n", priv->conn->prof.tx_pending);
} }
static ssize_t static ssize_t txpend_write (struct device *dev, struct device_attribute *attr,
txpend_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) const char *buf, size_t count)
{ {
struct netiucv_priv *priv = dev->driver_data; struct netiucv_priv *priv = dev->driver_data;
...@@ -1671,8 +1675,8 @@ txpend_write (struct device *dev, struct device_attribute *attr, const char *buf ...@@ -1671,8 +1675,8 @@ txpend_write (struct device *dev, struct device_attribute *attr, const char *buf
static DEVICE_ATTR(tx_pending, 0644, txpend_show, txpend_write); static DEVICE_ATTR(tx_pending, 0644, txpend_show, txpend_write);
static ssize_t static ssize_t txmpnd_show (struct device *dev, struct device_attribute *attr,
txmpnd_show (struct device *dev, struct device_attribute *attr, char *buf) char *buf)
{ {
struct netiucv_priv *priv = dev->driver_data; struct netiucv_priv *priv = dev->driver_data;
...@@ -1680,8 +1684,8 @@ txmpnd_show (struct device *dev, struct device_attribute *attr, char *buf) ...@@ -1680,8 +1684,8 @@ txmpnd_show (struct device *dev, struct device_attribute *attr, char *buf)
return sprintf(buf, "%ld\n", priv->conn->prof.tx_max_pending); return sprintf(buf, "%ld\n", priv->conn->prof.tx_max_pending);
} }
static ssize_t static ssize_t txmpnd_write (struct device *dev, struct device_attribute *attr,
txmpnd_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) const char *buf, size_t count)
{ {
struct netiucv_priv *priv = dev->driver_data; struct netiucv_priv *priv = dev->driver_data;
...@@ -1721,8 +1725,7 @@ static struct attribute_group netiucv_stat_attr_group = { ...@@ -1721,8 +1725,7 @@ static struct attribute_group netiucv_stat_attr_group = {
.attrs = netiucv_stat_attrs, .attrs = netiucv_stat_attrs,
}; };
static inline int static inline int netiucv_add_files(struct device *dev)
netiucv_add_files(struct device *dev)
{ {
int ret; int ret;
...@@ -1736,18 +1739,16 @@ netiucv_add_files(struct device *dev) ...@@ -1736,18 +1739,16 @@ netiucv_add_files(struct device *dev)
return ret; return ret;
} }
static inline void static inline void netiucv_remove_files(struct device *dev)
netiucv_remove_files(struct device *dev)
{ {
IUCV_DBF_TEXT(trace, 3, __FUNCTION__); IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
sysfs_remove_group(&dev->kobj, &netiucv_stat_attr_group); sysfs_remove_group(&dev->kobj, &netiucv_stat_attr_group);
sysfs_remove_group(&dev->kobj, &netiucv_attr_group); sysfs_remove_group(&dev->kobj, &netiucv_attr_group);
} }
static int static int netiucv_register_device(struct net_device *ndev)
netiucv_register_device(struct net_device *ndev)
{ {
struct netiucv_priv *priv = ndev->priv; struct netiucv_priv *priv = netdev_priv(ndev);
struct device *dev = kzalloc(sizeof(struct device), GFP_KERNEL); struct device *dev = kzalloc(sizeof(struct device), GFP_KERNEL);
int ret; int ret;
...@@ -1786,8 +1787,7 @@ netiucv_register_device(struct net_device *ndev) ...@@ -1786,8 +1787,7 @@ netiucv_register_device(struct net_device *ndev)
return ret; return ret;
} }
static void static void netiucv_unregister_device(struct device *dev)
netiucv_unregister_device(struct device *dev)
{ {
IUCV_DBF_TEXT(trace, 3, __FUNCTION__); IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
netiucv_remove_files(dev); netiucv_remove_files(dev);
...@@ -1798,107 +1798,89 @@ netiucv_unregister_device(struct device *dev) ...@@ -1798,107 +1798,89 @@ netiucv_unregister_device(struct device *dev)
* Allocate and initialize a new connection structure. * Allocate and initialize a new connection structure.
* Add it to the list of netiucv connections; * Add it to the list of netiucv connections;
*/ */
static struct iucv_connection * static struct iucv_connection *netiucv_new_connection(struct net_device *dev,
netiucv_new_connection(struct net_device *dev, char *username) char *username)
{ {
unsigned long flags; struct iucv_connection *conn;
struct iucv_connection **clist = &iucv_conns.iucv_connections;
struct iucv_connection *conn =
kzalloc(sizeof(struct iucv_connection), GFP_KERNEL);
if (conn) {
skb_queue_head_init(&conn->collect_queue);
skb_queue_head_init(&conn->commit_queue);
spin_lock_init(&conn->collect_lock);
conn->max_buffsize = NETIUCV_BUFSIZE_DEFAULT;
conn->netdev = dev;
conn->rx_buff = alloc_skb(NETIUCV_BUFSIZE_DEFAULT,
GFP_KERNEL | GFP_DMA);
if (!conn->rx_buff) {
kfree(conn);
return NULL;
}
conn->tx_buff = alloc_skb(NETIUCV_BUFSIZE_DEFAULT,
GFP_KERNEL | GFP_DMA);
if (!conn->tx_buff) {
kfree_skb(conn->rx_buff);
kfree(conn);
return NULL;
}
conn->fsm = init_fsm("netiucvconn", conn_state_names,
conn_event_names, NR_CONN_STATES,
NR_CONN_EVENTS, conn_fsm, CONN_FSM_LEN,
GFP_KERNEL);
if (!conn->fsm) {
kfree_skb(conn->tx_buff);
kfree_skb(conn->rx_buff);
kfree(conn);
return NULL;
}
fsm_settimer(conn->fsm, &conn->timer);
fsm_newstate(conn->fsm, CONN_STATE_INVALID);
if (username) {
memcpy(conn->userid, username, 9);
fsm_newstate(conn->fsm, CONN_STATE_STOPPED);
}
write_lock_irqsave(&iucv_conns.iucv_rwlock, flags); conn = kzalloc(sizeof(*conn), GFP_KERNEL);
conn->next = *clist; if (!conn)
*clist = conn; goto out;
write_unlock_irqrestore(&iucv_conns.iucv_rwlock, flags); skb_queue_head_init(&conn->collect_queue);
skb_queue_head_init(&conn->commit_queue);
spin_lock_init(&conn->collect_lock);
conn->max_buffsize = NETIUCV_BUFSIZE_DEFAULT;
conn->netdev = dev;
conn->rx_buff = alloc_skb(conn->max_buffsize, GFP_KERNEL | GFP_DMA);
if (!conn->rx_buff)
goto out_conn;
conn->tx_buff = alloc_skb(conn->max_buffsize, GFP_KERNEL | GFP_DMA);
if (!conn->tx_buff)
goto out_rx;
conn->fsm = init_fsm("netiucvconn", conn_state_names,
conn_event_names, NR_CONN_STATES,
NR_CONN_EVENTS, conn_fsm, CONN_FSM_LEN,
GFP_KERNEL);
if (!conn->fsm)
goto out_tx;
fsm_settimer(conn->fsm, &conn->timer);
fsm_newstate(conn->fsm, CONN_STATE_INVALID);
if (username) {
memcpy(conn->userid, username, 9);
fsm_newstate(conn->fsm, CONN_STATE_STOPPED);
} }
write_lock_bh(&iucv_connection_rwlock);
list_add_tail(&conn->list, &iucv_connection_list);
write_unlock_bh(&iucv_connection_rwlock);
return conn; return conn;
out_tx:
kfree_skb(conn->tx_buff);
out_rx:
kfree_skb(conn->rx_buff);
out_conn:
kfree(conn);
out:
return NULL;
} }
/** /**
* Release a connection structure and remove it from the * Release a connection structure and remove it from the
* list of netiucv connections. * list of netiucv connections.
*/ */
static void static void netiucv_remove_connection(struct iucv_connection *conn)
netiucv_remove_connection(struct iucv_connection *conn)
{ {
struct iucv_connection **clist = &iucv_conns.iucv_connections;
unsigned long flags;
IUCV_DBF_TEXT(trace, 3, __FUNCTION__); IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
if (conn == NULL) write_lock_bh(&iucv_connection_rwlock);
return; list_del_init(&conn->list);
write_lock_irqsave(&iucv_conns.iucv_rwlock, flags); write_unlock_bh(&iucv_connection_rwlock);
while (*clist) { if (conn->path) {
if (*clist == conn) { iucv_path_sever(conn->path, iucvMagic);
*clist = conn->next; kfree(conn->path);
write_unlock_irqrestore(&iucv_conns.iucv_rwlock, flags); conn->path = NULL;
if (conn->handle) {
iucv_unregister_program(conn->handle);
conn->handle = NULL;
}
fsm_deltimer(&conn->timer);
kfree_fsm(conn->fsm);
kfree_skb(conn->rx_buff);
kfree_skb(conn->tx_buff);
return;
}
clist = &((*clist)->next);
} }
write_unlock_irqrestore(&iucv_conns.iucv_rwlock, flags); fsm_deltimer(&conn->timer);
kfree_fsm(conn->fsm);
kfree_skb(conn->rx_buff);
kfree_skb(conn->tx_buff);
} }
/** /**
* Release everything of a net device. * Release everything of a net device.
*/ */
static void static void netiucv_free_netdevice(struct net_device *dev)
netiucv_free_netdevice(struct net_device *dev)
{ {
struct netiucv_priv *privptr; struct netiucv_priv *privptr = netdev_priv(dev);
IUCV_DBF_TEXT(trace, 3, __FUNCTION__); IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
if (!dev) if (!dev)
return; return;
privptr = (struct netiucv_priv *)dev->priv;
if (privptr) { if (privptr) {
if (privptr->conn) if (privptr->conn)
netiucv_remove_connection(privptr->conn); netiucv_remove_connection(privptr->conn);
...@@ -1913,11 +1895,8 @@ netiucv_free_netdevice(struct net_device *dev) ...@@ -1913,11 +1895,8 @@ netiucv_free_netdevice(struct net_device *dev)
/** /**
* Initialize a net device. (Called from kernel in alloc_netdev()) * Initialize a net device. (Called from kernel in alloc_netdev())
*/ */
static void static void netiucv_setup_netdevice(struct net_device *dev)
netiucv_setup_netdevice(struct net_device *dev)
{ {
memset(dev->priv, 0, sizeof(struct netiucv_priv));
dev->mtu = NETIUCV_MTU_DEFAULT; dev->mtu = NETIUCV_MTU_DEFAULT;
dev->hard_start_xmit = netiucv_tx; dev->hard_start_xmit = netiucv_tx;
dev->open = netiucv_open; dev->open = netiucv_open;
...@@ -1936,8 +1915,7 @@ netiucv_setup_netdevice(struct net_device *dev) ...@@ -1936,8 +1915,7 @@ netiucv_setup_netdevice(struct net_device *dev)
/** /**
* Allocate and initialize everything of a net device. * Allocate and initialize everything of a net device.
*/ */
static struct net_device * static struct net_device *netiucv_init_netdevice(char *username)
netiucv_init_netdevice(char *username)
{ {
struct netiucv_priv *privptr; struct netiucv_priv *privptr;
struct net_device *dev; struct net_device *dev;
...@@ -1946,40 +1924,40 @@ netiucv_init_netdevice(char *username) ...@@ -1946,40 +1924,40 @@ netiucv_init_netdevice(char *username)
netiucv_setup_netdevice); netiucv_setup_netdevice);
if (!dev) if (!dev)
return NULL; return NULL;
if (dev_alloc_name(dev, dev->name) < 0) { if (dev_alloc_name(dev, dev->name) < 0)
free_netdev(dev); goto out_netdev;
return NULL;
}
privptr = (struct netiucv_priv *)dev->priv; privptr = netdev_priv(dev);
privptr->fsm = init_fsm("netiucvdev", dev_state_names, privptr->fsm = init_fsm("netiucvdev", dev_state_names,
dev_event_names, NR_DEV_STATES, NR_DEV_EVENTS, dev_event_names, NR_DEV_STATES, NR_DEV_EVENTS,
dev_fsm, DEV_FSM_LEN, GFP_KERNEL); dev_fsm, DEV_FSM_LEN, GFP_KERNEL);
if (!privptr->fsm) { if (!privptr->fsm)
free_netdev(dev); goto out_netdev;
return NULL;
}
privptr->conn = netiucv_new_connection(dev, username); privptr->conn = netiucv_new_connection(dev, username);
if (!privptr->conn) { if (!privptr->conn) {
kfree_fsm(privptr->fsm);
free_netdev(dev);
IUCV_DBF_TEXT(setup, 2, "NULL from netiucv_new_connection\n"); IUCV_DBF_TEXT(setup, 2, "NULL from netiucv_new_connection\n");
return NULL; goto out_fsm;
} }
fsm_newstate(privptr->fsm, DEV_STATE_STOPPED); fsm_newstate(privptr->fsm, DEV_STATE_STOPPED);
return dev; return dev;
out_fsm:
kfree_fsm(privptr->fsm);
out_netdev:
free_netdev(dev);
return NULL;
} }
static ssize_t static ssize_t conn_write(struct device_driver *drv,
conn_write(struct device_driver *drv, const char *buf, size_t count) const char *buf, size_t count)
{ {
char *p; const char *p;
char username[9]; char username[9];
int i, ret; int i, rc;
struct net_device *dev; struct net_device *dev;
struct iucv_connection **clist = &iucv_conns.iucv_connections; struct netiucv_priv *priv;
unsigned long flags; struct iucv_connection *cp;
IUCV_DBF_TEXT(trace, 3, __FUNCTION__); IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
if (count>9) { if (count>9) {
...@@ -1988,83 +1966,82 @@ conn_write(struct device_driver *drv, const char *buf, size_t count) ...@@ -1988,83 +1966,82 @@ conn_write(struct device_driver *drv, const char *buf, size_t count)
return -EINVAL; return -EINVAL;
} }
for (i=0, p=(char *)buf; i<8 && *p; i++, p++) { for (i = 0, p = buf; i < 8 && *p; i++, p++) {
if (isalnum(*p) || (*p == '$')) if (isalnum(*p) || *p == '$') {
username[i]= toupper(*p); username[i] = toupper(*p);
else if (*p == '\n') { continue;
}
if (*p == '\n')
/* trailing lf, grr */ /* trailing lf, grr */
break; break;
} else { PRINT_WARN("netiucv: Invalid character in username!\n");
PRINT_WARN("netiucv: Invalid character in username!\n"); IUCV_DBF_TEXT_(setup, 2,
IUCV_DBF_TEXT_(setup, 2, "conn_write: invalid character %c\n", *p);
"conn_write: invalid character %c\n", *p); return -EINVAL;
return -EINVAL;
}
} }
while (i<8) while (i < 8)
username[i++] = ' '; username[i++] = ' ';
username[8] = '\0'; username[8] = '\0';
read_lock_irqsave(&iucv_conns.iucv_rwlock, flags); read_lock_bh(&iucv_connection_rwlock);
while (*clist) { list_for_each_entry(cp, &iucv_connection_list, list) {
if (!strncmp(username, (*clist)->userid, 9)) if (!strncmp(username, cp->userid, 9)) {
break; read_unlock_bh(&iucv_connection_rwlock);
clist = &((*clist)->next); PRINT_WARN("netiucv: Connection to %s already "
} "exists\n", username);
read_unlock_irqrestore(&iucv_conns.iucv_rwlock, flags); return -EEXIST;
if (*clist) { }
PRINT_WARN("netiucv: Connection to %s already exists\n",
username);
return -EEXIST;
} }
read_unlock_bh(&iucv_connection_rwlock);
dev = netiucv_init_netdevice(username); dev = netiucv_init_netdevice(username);
if (!dev) { if (!dev) {
PRINT_WARN( PRINT_WARN("netiucv: Could not allocate network device "
"netiucv: Could not allocate network device structure " "structure for user '%s'\n",
"for user '%s'\n", netiucv_printname(username)); netiucv_printname(username));
IUCV_DBF_TEXT(setup, 2, "NULL from netiucv_init_netdevice\n"); IUCV_DBF_TEXT(setup, 2, "NULL from netiucv_init_netdevice\n");
return -ENODEV; return -ENODEV;
} }
if ((ret = netiucv_register_device(dev))) { rc = netiucv_register_device(dev);
if (rc) {
IUCV_DBF_TEXT_(setup, 2, IUCV_DBF_TEXT_(setup, 2,
"ret %d from netiucv_register_device\n", ret); "ret %d from netiucv_register_device\n", rc);
goto out_free_ndev; goto out_free_ndev;
} }
/* sysfs magic */ /* sysfs magic */
SET_NETDEV_DEV(dev, priv = netdev_priv(dev);
(struct device*)((struct netiucv_priv*)dev->priv)->dev); SET_NETDEV_DEV(dev, priv->dev);
if ((ret = register_netdev(dev))) { rc = register_netdev(dev);
netiucv_unregister_device((struct device*) if (rc)
((struct netiucv_priv*)dev->priv)->dev); goto out_unreg;
goto out_free_ndev;
}
PRINT_INFO("%s: '%s'\n", dev->name, netiucv_printname(username)); PRINT_INFO("%s: '%s'\n", dev->name, netiucv_printname(username));
return count; return count;
out_unreg:
netiucv_unregister_device(priv->dev);
out_free_ndev: out_free_ndev:
PRINT_WARN("netiucv: Could not register '%s'\n", dev->name); PRINT_WARN("netiucv: Could not register '%s'\n", dev->name);
IUCV_DBF_TEXT(setup, 2, "conn_write: could not register\n"); IUCV_DBF_TEXT(setup, 2, "conn_write: could not register\n");
netiucv_free_netdevice(dev); netiucv_free_netdevice(dev);
return ret; return rc;
} }
static DRIVER_ATTR(connection, 0200, NULL, conn_write); static DRIVER_ATTR(connection, 0200, NULL, conn_write);
static ssize_t static ssize_t remove_write (struct device_driver *drv,
remove_write (struct device_driver *drv, const char *buf, size_t count) const char *buf, size_t count)
{ {
struct iucv_connection **clist = &iucv_conns.iucv_connections; struct iucv_connection *cp;
unsigned long flags;
struct net_device *ndev; struct net_device *ndev;
struct netiucv_priv *priv; struct netiucv_priv *priv;
struct device *dev; struct device *dev;
char name[IFNAMSIZ]; char name[IFNAMSIZ];
char *p; const char *p;
int i; int i;
IUCV_DBF_TEXT(trace, 3, __FUNCTION__); IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
...@@ -2072,33 +2049,27 @@ remove_write (struct device_driver *drv, const char *buf, size_t count) ...@@ -2072,33 +2049,27 @@ remove_write (struct device_driver *drv, const char *buf, size_t count)
if (count >= IFNAMSIZ) if (count >= IFNAMSIZ)
count = IFNAMSIZ - 1;; count = IFNAMSIZ - 1;;
for (i=0, p=(char *)buf; i<count && *p; i++, p++) { for (i = 0, p = buf; i < count && *p; i++, p++) {
if ((*p == '\n') || (*p == ' ')) { if (*p == '\n' || *p == ' ')
/* trailing lf, grr */ /* trailing lf, grr */
break; break;
} else { name[i] = *p;
name[i]=*p;
}
} }
name[i] = '\0'; name[i] = '\0';
read_lock_irqsave(&iucv_conns.iucv_rwlock, flags); read_lock_bh(&iucv_connection_rwlock);
while (*clist) { list_for_each_entry(cp, &iucv_connection_list, list) {
ndev = (*clist)->netdev; ndev = cp->netdev;
priv = (struct netiucv_priv*)ndev->priv; priv = netdev_priv(ndev);
dev = priv->dev; dev = priv->dev;
if (strncmp(name, ndev->name, count))
if (strncmp(name, ndev->name, count)) { continue;
clist = &((*clist)->next); read_unlock_bh(&iucv_connection_rwlock);
continue;
}
read_unlock_irqrestore(&iucv_conns.iucv_rwlock, flags);
if (ndev->flags & (IFF_UP | IFF_RUNNING)) { if (ndev->flags & (IFF_UP | IFF_RUNNING)) {
PRINT_WARN( PRINT_WARN("netiucv: net device %s active with peer "
"netiucv: net device %s active with peer %s\n", "%s\n", ndev->name, priv->conn->userid);
ndev->name, priv->conn->userid);
PRINT_WARN("netiucv: %s cannot be removed\n", PRINT_WARN("netiucv: %s cannot be removed\n",
ndev->name); ndev->name);
IUCV_DBF_TEXT(data, 2, "remove_write: still active\n"); IUCV_DBF_TEXT(data, 2, "remove_write: still active\n");
return -EBUSY; return -EBUSY;
} }
...@@ -2106,7 +2077,7 @@ remove_write (struct device_driver *drv, const char *buf, size_t count) ...@@ -2106,7 +2077,7 @@ remove_write (struct device_driver *drv, const char *buf, size_t count)
netiucv_unregister_device(dev); netiucv_unregister_device(dev);
return count; return count;
} }
read_unlock_irqrestore(&iucv_conns.iucv_rwlock, flags); read_unlock_bh(&iucv_connection_rwlock);
PRINT_WARN("netiucv: net device %s unknown\n", name); PRINT_WARN("netiucv: net device %s unknown\n", name);
IUCV_DBF_TEXT(data, 2, "remove_write: unknown device\n"); IUCV_DBF_TEXT(data, 2, "remove_write: unknown device\n");
return -EINVAL; return -EINVAL;
...@@ -2114,67 +2085,86 @@ remove_write (struct device_driver *drv, const char *buf, size_t count) ...@@ -2114,67 +2085,86 @@ remove_write (struct device_driver *drv, const char *buf, size_t count)
static DRIVER_ATTR(remove, 0200, NULL, remove_write); static DRIVER_ATTR(remove, 0200, NULL, remove_write);
static void static struct attribute * netiucv_drv_attrs[] = {
netiucv_banner(void) &driver_attr_connection.attr,
&driver_attr_remove.attr,
NULL,
};
static struct attribute_group netiucv_drv_attr_group = {
.attrs = netiucv_drv_attrs,
};
static void netiucv_banner(void)
{ {
PRINT_INFO("NETIUCV driver initialized\n"); PRINT_INFO("NETIUCV driver initialized\n");
} }
static void __exit static void __exit netiucv_exit(void)
netiucv_exit(void)
{ {
struct iucv_connection *cp;
struct net_device *ndev;
struct netiucv_priv *priv;
struct device *dev;
IUCV_DBF_TEXT(trace, 3, __FUNCTION__); IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
while (iucv_conns.iucv_connections) { while (!list_empty(&iucv_connection_list)) {
struct net_device *ndev = iucv_conns.iucv_connections->netdev; cp = list_entry(iucv_connection_list.next,
struct netiucv_priv *priv = (struct netiucv_priv*)ndev->priv; struct iucv_connection, list);
struct device *dev = priv->dev; list_del(&cp->list);
ndev = cp->netdev;
priv = netdev_priv(ndev);
dev = priv->dev;
unregister_netdev(ndev); unregister_netdev(ndev);
netiucv_unregister_device(dev); netiucv_unregister_device(dev);
} }
driver_remove_file(&netiucv_driver, &driver_attr_connection); sysfs_remove_group(&netiucv_driver.kobj, &netiucv_drv_attr_group);
driver_remove_file(&netiucv_driver, &driver_attr_remove);
driver_unregister(&netiucv_driver); driver_unregister(&netiucv_driver);
iucv_unregister(&netiucv_handler, 1);
iucv_unregister_dbf_views(); iucv_unregister_dbf_views();
PRINT_INFO("NETIUCV driver unloaded\n"); PRINT_INFO("NETIUCV driver unloaded\n");
return; return;
} }
static int __init static int __init netiucv_init(void)
netiucv_init(void)
{ {
int ret; int rc;
ret = iucv_register_dbf_views(); rc = iucv_register_dbf_views();
if (ret) { if (rc)
PRINT_WARN("netiucv_init failed, " goto out;
"iucv_register_dbf_views rc = %d\n", ret); rc = iucv_register(&netiucv_handler, 1);
return ret; if (rc)
} goto out_dbf;
IUCV_DBF_TEXT(trace, 3, __FUNCTION__); IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
ret = driver_register(&netiucv_driver); rc = driver_register(&netiucv_driver);
if (ret) { if (rc) {
PRINT_ERR("NETIUCV: failed to register driver.\n"); PRINT_ERR("NETIUCV: failed to register driver.\n");
IUCV_DBF_TEXT_(setup, 2, "ret %d from driver_register\n", ret); IUCV_DBF_TEXT_(setup, 2, "ret %d from driver_register\n", rc);
iucv_unregister_dbf_views(); goto out_iucv;
return ret;
} }
/* Add entry for specifying connections. */ rc = sysfs_create_group(&netiucv_driver.kobj, &netiucv_drv_attr_group);
ret = driver_create_file(&netiucv_driver, &driver_attr_connection); if (rc) {
if (!ret) { PRINT_ERR("NETIUCV: failed to add driver attributes.\n");
ret = driver_create_file(&netiucv_driver, &driver_attr_remove); IUCV_DBF_TEXT_(setup, 2,
netiucv_banner(); "ret %d - netiucv_drv_attr_group\n", rc);
rwlock_init(&iucv_conns.iucv_rwlock); goto out_driver;
} else {
PRINT_ERR("NETIUCV: failed to add driver attribute.\n");
IUCV_DBF_TEXT_(setup, 2, "ret %d from driver_create_file\n", ret);
driver_unregister(&netiucv_driver);
iucv_unregister_dbf_views();
} }
return ret; netiucv_banner();
return rc;
out_driver:
driver_unregister(&netiucv_driver);
out_iucv:
iucv_unregister(&netiucv_handler, 1);
out_dbf:
iucv_unregister_dbf_views();
out:
return rc;
} }
module_init(netiucv_init); module_init(netiucv_init);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment