/*
- * $Id: netiucv.c,v 1.57 2004/06/30 09:26:40 braunu Exp $
- *
* IUCV network driver
*
* Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation
* Author(s): Fritz Elfert (elfert@de.ibm.com, felfert@millenux.com)
*
- * Driverfs integration and all bugs therein by Cornelia Huck(cohuck@de.ibm.com)
+ * Sysfs integration and all bugs therein by Cornelia Huck
+ * (cornelia.huck@de.ibm.com)
*
* Documentation used:
* the source of the original IUCV driver by:
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * RELEASE-TAG: IUCV network driver $Revision: 1.57 $
- *
*/
-\f
+
#undef DEBUG
#include <linux/module.h>
#include <linux/interrupt.h>
#include <linux/timer.h>
#include <linux/sched.h>
+#include <linux/bitops.h>
#include <linux/signal.h>
#include <linux/string.h>
#include <net/dst.h>
#include <asm/io.h>
-#include <asm/bitops.h>
#include <asm/uaccess.h>
#include "iucv.h"
("(C) 2001 IBM Corporation by Fritz Elfert (felfert@millenux.com)");
MODULE_DESCRIPTION ("Linux for S/390 IUCV network driver");
-\f
+
+#define PRINTK_HEADER " iucv: " /* for debugging */
+
+static struct device_driver netiucv_driver = {
+ .name = "netiucv",
+ .bus = &iucv_bus,
+};
+
/**
* Per connection profiling data
*/
/**
* Linked list of all connection structs.
*/
-static struct iucv_connection *connections;
+static struct iucv_connection *iucv_connections;
/**
* Representation of event-data for the
* match exactly as specified in order to give connection_pending()
* control.
*/
-static __u8 mask[] = {
+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
*p = '\0';
return tmp;
}
-\f
+
/**
* States of the interface statemachine.
*/
"Connection up",
"Connection down",
};
-\f
+
/**
* Events of the connection statemachine
*/
"Connect error",
};
-\f
+
+/**
+ * Debug Facility Stuff
+ */
+static debug_info_t *iucv_dbf_setup = NULL;
+static debug_info_t *iucv_dbf_data = NULL;
+static debug_info_t *iucv_dbf_trace = NULL;
+
+DEFINE_PER_CPU(char[256], iucv_dbf_txt_buf);
+
+static void
+iucv_unregister_dbf_views(void)
+{
+ if (iucv_dbf_setup)
+ debug_unregister(iucv_dbf_setup);
+ if (iucv_dbf_data)
+ debug_unregister(iucv_dbf_data);
+ if (iucv_dbf_trace)
+ debug_unregister(iucv_dbf_trace);
+}
+static int
+iucv_register_dbf_views(void)
+{
+ iucv_dbf_setup = debug_register(IUCV_DBF_SETUP_NAME,
+ IUCV_DBF_SETUP_PAGES,
+ IUCV_DBF_SETUP_NR_AREAS,
+ IUCV_DBF_SETUP_LEN);
+ iucv_dbf_data = debug_register(IUCV_DBF_DATA_NAME,
+ IUCV_DBF_DATA_PAGES,
+ IUCV_DBF_DATA_NR_AREAS,
+ IUCV_DBF_DATA_LEN);
+ iucv_dbf_trace = debug_register(IUCV_DBF_TRACE_NAME,
+ IUCV_DBF_TRACE_PAGES,
+ IUCV_DBF_TRACE_NR_AREAS,
+ IUCV_DBF_TRACE_LEN);
+
+ if ((iucv_dbf_setup == NULL) || (iucv_dbf_data == NULL) ||
+ (iucv_dbf_trace == NULL)) {
+ iucv_unregister_dbf_views();
+ return -ENOMEM;
+ }
+ debug_register_view(iucv_dbf_setup, &debug_hex_ascii_view);
+ debug_set_level(iucv_dbf_setup, IUCV_DBF_SETUP_LEVEL);
+
+ debug_register_view(iucv_dbf_data, &debug_hex_ascii_view);
+ debug_set_level(iucv_dbf_data, IUCV_DBF_DATA_LEVEL);
+
+ debug_register_view(iucv_dbf_trace, &debug_hex_ascii_view);
+ debug_set_level(iucv_dbf_trace, IUCV_DBF_TRACE_LEVEL);
+
+ return 0;
+}
+
/**
* Callback-wrappers, called from lowlevel iucv layer.
*****************************************************************************/
fsm_action_nop(fsm_instance *fi, int event, void *arg)
{
}
-\f
+
/**
* Actions of the connection statemachine
*****************************************************************************/
struct sk_buff *skb;
ll_header *header = (ll_header *)pskb->data;
- if (header->next == 0)
+ if (!header->next)
break;
skb_pull(pskb, NETIUCV_HDRLEN);
offset += header->next;
header->next -= NETIUCV_HDRLEN;
if (skb_tailroom(pskb) < header->next) {
- printk(KERN_WARNING
- "%s: Illegal next field in iucv header: "
+ PRINT_WARN("%s: Illegal next field in iucv header: "
"%d > %d\n",
dev->name, header->next, skb_tailroom(pskb));
+ IUCV_DBF_TEXT_(data, 2, "Illegal next field: %d > %d\n",
+ header->next, skb_tailroom(pskb));
return;
}
skb_put(pskb, header->next);
pskb->mac.raw = pskb->data;
skb = dev_alloc_skb(pskb->len);
if (!skb) {
- printk(KERN_WARNING
- "%s Out of memory in netiucv_unpack_skb\n",
+ PRINT_WARN("%s Out of memory in netiucv_unpack_skb\n",
dev->name);
+ IUCV_DBF_TEXT(data, 2,
+ "Out of memory in netiucv_unpack_skb\n");
privptr->stats.rx_dropped++;
return;
}
struct iucv_event *ev = (struct iucv_event *)arg;
struct iucv_connection *conn = ev->conn;
iucv_MessagePending *eib = (iucv_MessagePending *)ev->data;
- struct netiucv_priv *privptr = (struct netiucv_priv *)conn->netdev->priv;
+ struct netiucv_priv *privptr =(struct netiucv_priv *)conn->netdev->priv;
__u32 msglen = eib->ln1msg2.ipbfln1f;
int rc;
- pr_debug("%s() called\n", __FUNCTION__);
+ IUCV_DBF_TEXT(trace, 4, __FUNCTION__);
if (!conn->netdev) {
/* FRITZ: How to tell iucv LL to drop the msg? */
- printk(KERN_WARNING
- "Received data for unlinked connection\n");
+ PRINT_WARN("Received data for unlinked connection\n");
+ IUCV_DBF_TEXT(data, 2,
+ "Received data for unlinked connection\n");
return;
}
if (msglen > conn->max_buffsize) {
/* FRITZ: How to tell iucv LL to drop the msg? */
privptr->stats.rx_dropped++;
+ PRINT_WARN("msglen %d > max_buffsize %d\n",
+ msglen, conn->max_buffsize);
+ IUCV_DBF_TEXT_(data, 2, "msglen %d > max_buffsize %d\n",
+ msglen, conn->max_buffsize);
return;
}
conn->rx_buff->data = conn->rx_buff->tail = conn->rx_buff->head;
conn->rx_buff->len = 0;
rc = iucv_receive(conn->pathid, eib->ipmsgid, eib->iptrgcls,
conn->rx_buff->data, msglen, NULL, NULL, NULL);
- if (rc != 0 || msglen < 5) {
+ if (rc || msglen < 5) {
privptr->stats.rx_errors++;
- printk(KERN_INFO "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);
return;
}
netiucv_unpack_skb(conn, conn->rx_buff);
unsigned long saveflags;
ll_header header;
- pr_debug("%s() called\n", __FUNCTION__);
+ IUCV_DBF_TEXT(trace, 4, __FUNCTION__);
if (conn && conn->netdev && conn->netdev->priv)
privptr = (struct netiucv_priv *)conn->netdev->priv;
conn->prof.tx_pending++;
if (conn->prof.tx_pending > conn->prof.tx_max_pending)
conn->prof.tx_max_pending = conn->prof.tx_pending;
- if (rc != 0) {
+ if (rc) {
conn->prof.tx_pending--;
fsm_newstate(fi, CONN_STATE_IDLE);
if (privptr)
privptr->stats.tx_errors += txpackets;
- printk(KERN_INFO "iucv_send returned %08x\n",
- rc);
+ 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;
__u16 msglimit;
__u8 udata[16];
- pr_debug("%s() called\n", __FUNCTION__);
+ IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
rc = iucv_accept(eib->ippathid, NETIUCV_QUEUELEN_DEFAULT, udata, 0,
conn->handle, conn, NULL, &msglimit);
- if (rc != 0) {
- printk(KERN_WARNING
- "%s: IUCV accept failed with error %d\n",
+ if (rc) {
+ PRINT_WARN("%s: IUCV accept failed with error %d\n",
netdev->name, rc);
+ IUCV_DBF_TEXT_(setup, 2, "rc %d from iucv_accept", rc);
return;
}
fsm_newstate(fi, CONN_STATE_IDLE);
iucv_ConnectionPending *eib = (iucv_ConnectionPending *)ev->data;
__u8 udata[16];
- pr_debug("%s() called\n", __FUNCTION__);
+ IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
iucv_sever(eib->ippathid, udata);
if (eib->ippathid != conn->pathid) {
- printk(KERN_INFO
- "%s: IR Connection Pending; pathid %d does not match original pathid %d\n",
+ 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);
}
}
struct net_device *netdev = conn->netdev;
struct netiucv_priv *privptr = (struct netiucv_priv *)netdev->priv;
- pr_debug("%s() called\n", __FUNCTION__);
+ IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
fsm_deltimer(&conn->timer);
fsm_newstate(fi, CONN_STATE_IDLE);
if (eib->ippathid != conn->pathid) {
- printk(KERN_INFO
- "%s: IR Connection Complete; pathid %d does not match original pathid %d\n",
+ 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;
struct iucv_connection *conn = (struct iucv_connection *)arg;
__u8 udata[16];
- pr_debug("%s() called\n", __FUNCTION__);
+ IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
fsm_deltimer(&conn->timer);
iucv_sever(conn->pathid, udata);
struct netiucv_priv *privptr = (struct netiucv_priv *)netdev->priv;
__u8 udata[16];
- pr_debug("%s() called\n", __FUNCTION__);
+ IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
fsm_deltimer(&conn->timer);
iucv_sever(conn->pathid, udata);
- printk(KERN_INFO "%s: Remote dropped connection\n",
- netdev->name);
+ PRINT_INFO("%s: Remote dropped connection\n", netdev->name);
+ IUCV_DBF_TEXT(data, 2,
+ "conn_action_connsever: Remote dropped connection\n");
fsm_newstate(fi, CONN_STATE_STARTWAIT);
fsm_event(privptr->fsm, DEV_EVENT_CONDOWN, netdev);
}
__u16 msglimit;
int rc;
- pr_debug("%s() called\n", __FUNCTION__);
+ IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
- if (conn->handle == 0) {
+ if (!conn->handle) {
+ IUCV_DBF_TEXT(trace, 5, "calling iucv_register_program\n");
conn->handle =
- iucv_register_program(iucvMagic, conn->userid, mask,
+ iucv_register_program(iucvMagic, conn->userid,
+ netiucv_mask,
&netiucv_ops, conn);
fsm_newstate(fi, CONN_STATE_STARTWAIT);
- if (conn->handle <= 0) {
+ if (!conn->handle) {
fsm_newstate(fi, CONN_STATE_REGERR);
- conn->handle = 0;
+ conn->handle = NULL;
+ IUCV_DBF_TEXT(setup, 2,
+ "NULL from iucv_register_program\n");
return;
}
- pr_debug("%s('%s'): registered successfully\n",
+ PRINT_DEBUG("%s('%s'): registered successfully\n",
conn->netdev->name, conn->userid);
}
- pr_debug("%s('%s'): connecting ...\n",
+ PRINT_DEBUG("%s('%s'): connecting ...\n",
conn->netdev->name, conn->userid);
/* We must set the state before calling iucv_connect because the callback
fsm_newstate(fi, CONN_STATE_SETUPWAIT);
rc = iucv_connect(&(conn->pathid), NETIUCV_QUEUELEN_DEFAULT, iucvMagic,
- conn->userid, iucv_host, 0, NULL, &msglimit, conn->handle,
- conn);
+ conn->userid, iucv_host, 0, NULL, &msglimit,
+ conn->handle, conn);
switch (rc) {
case 0:
conn->netdev->tx_queue_len = msglimit;
CONN_EVENT_TIMER, conn);
return;
case 11:
- printk(KERN_NOTICE
- "%s: User %s is currently not available.\n",
+ PRINT_INFO("%s: User %s is currently not available.\n",
conn->netdev->name,
netiucv_printname(conn->userid));
fsm_newstate(fi, CONN_STATE_STARTWAIT);
return;
case 12:
- printk(KERN_NOTICE
- "%s: User %s is currently not ready.\n",
+ PRINT_INFO("%s: User %s is currently not ready.\n",
conn->netdev->name,
netiucv_printname(conn->userid));
fsm_newstate(fi, CONN_STATE_STARTWAIT);
return;
case 13:
- printk(KERN_WARNING
- "%s: Too many IUCV connections.\n",
+ PRINT_WARN("%s: Too many IUCV connections.\n",
conn->netdev->name);
fsm_newstate(fi, CONN_STATE_CONNERR);
break;
case 14:
- printk(KERN_WARNING
+ PRINT_WARN(
"%s: User %s has too many IUCV connections.\n",
conn->netdev->name,
netiucv_printname(conn->userid));
fsm_newstate(fi, CONN_STATE_CONNERR);
break;
case 15:
- printk(KERN_WARNING
+ PRINT_WARN(
"%s: No IUCV authorization in CP directory.\n",
conn->netdev->name);
fsm_newstate(fi, CONN_STATE_CONNERR);
break;
default:
- printk(KERN_WARNING
- "%s: iucv_connect returned error %d\n",
+ PRINT_WARN("%s: iucv_connect returned error %d\n",
conn->netdev->name, rc);
fsm_newstate(fi, CONN_STATE_CONNERR);
break;
}
+ IUCV_DBF_TEXT_(setup, 5, "iucv_connect rc is %d\n", rc);
+ IUCV_DBF_TEXT(trace, 5, "calling iucv_unregister_program\n");
iucv_unregister_program(conn->handle);
- conn->handle = 0;
+ conn->handle = NULL;
}
static void
struct net_device *netdev = conn->netdev;
struct netiucv_priv *privptr = (struct netiucv_priv *)netdev->priv;
- pr_debug("%s() called\n", __FUNCTION__);
+ IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
fsm_deltimer(&conn->timer);
fsm_newstate(fi, CONN_STATE_STOPPED);
netiucv_purge_skb_queue(&conn->collect_queue);
if (conn->handle)
+ IUCV_DBF_TEXT(trace, 5, "calling iucv_unregister_program\n");
iucv_unregister_program(conn->handle);
- conn->handle = 0;
+ conn->handle = NULL;
netiucv_purge_skb_queue(&conn->commit_queue);
fsm_event(privptr->fsm, DEV_EVENT_CONDOWN, netdev);
}
struct iucv_connection *conn = ev->conn;
struct net_device *netdev = conn->netdev;
- printk(KERN_WARNING
- "%s: Cannot connect without username\n",
+ PRINT_WARN("%s: Cannot connect without username\n",
netdev->name);
+ IUCV_DBF_TEXT(data, 2, "conn_action_inval called\n");
}
static const fsm_node conn_fsm[] = {
static const int CONN_FSM_LEN = sizeof(conn_fsm) / sizeof(fsm_node);
-\f
+
/**
* Actions for interface - statemachine.
*****************************************************************************/
struct netiucv_priv *privptr = dev->priv;
struct iucv_event ev;
- pr_debug("%s() called\n", __FUNCTION__);
+ IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
ev.conn = privptr->conn;
fsm_newstate(fi, DEV_STATE_STARTWAIT);
struct netiucv_priv *privptr = dev->priv;
struct iucv_event ev;
- pr_debug("%s() called\n", __FUNCTION__);
+ IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
ev.conn = privptr->conn;
struct net_device *dev = (struct net_device *)arg;
struct netiucv_priv *privptr = dev->priv;
- pr_debug("%s() called\n", __FUNCTION__);
+ IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
switch (fsm_getstate(fi)) {
case DEV_STATE_STARTWAIT:
fsm_newstate(fi, DEV_STATE_RUNNING);
- printk(KERN_INFO
- "%s: connected with remote side %s\n",
+ PRINT_INFO("%s: connected with remote side %s\n",
dev->name, privptr->conn->userid);
+ IUCV_DBF_TEXT(setup, 3,
+ "connection is up and running\n");
break;
case DEV_STATE_STOPWAIT:
- printk(KERN_INFO
- "%s: got connection UP event during shutdown!!\n",
+ PRINT_INFO(
+ "%s: got connection UP event during shutdown!\n",
dev->name);
+ IUCV_DBF_TEXT(data, 2,
+ "dev_action_connup: in DEV_STATE_STOPWAIT\n");
break;
}
}
static void
dev_action_conndown(fsm_instance *fi, int event, void *arg)
{
- pr_debug("%s() called\n", __FUNCTION__);
+ IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
switch (fsm_getstate(fi)) {
case DEV_STATE_RUNNING:
break;
case DEV_STATE_STOPWAIT:
fsm_newstate(fi, DEV_STATE_STOPPED);
+ IUCV_DBF_TEXT(setup, 3, "connection is down\n");
break;
}
}
spin_lock_irqsave(&conn->collect_lock, saveflags);
if (conn->collect_len + l >
- (conn->max_buffsize - NETIUCV_HDRLEN))
+ (conn->max_buffsize - NETIUCV_HDRLEN)) {
rc = -EBUSY;
- else {
+ IUCV_DBF_TEXT(data, 2,
+ "EBUSY from netiucv_transmit_skb\n");
+ } else {
atomic_inc(&skb->users);
skb_queue_tail(&conn->collect_queue, skb);
conn->collect_len += l;
nskb = alloc_skb(skb->len + NETIUCV_HDRLEN +
NETIUCV_HDRLEN, GFP_ATOMIC | GFP_DMA);
if (!nskb) {
- printk(KERN_WARNING
- "%s: Could not allocate tx_skb\n",
+ PRINT_WARN("%s: Could not allocate tx_skb\n",
conn->netdev->name);
+ IUCV_DBF_TEXT(data, 2, "alloc_skb failed\n");
rc = -ENOMEM;
return rc;
} else {
fsm_newstate(conn->fsm, CONN_STATE_TX);
conn->prof.send_stamp = xtime;
-
+
rc = iucv_send(conn->pathid, NULL, 0, 0, 1 /* single_flag */,
0, nskb->data, nskb->len);
/* Shut up, gcc! nskb is always below 2G. */
conn->prof.tx_pending++;
if (conn->prof.tx_pending > conn->prof.tx_max_pending)
conn->prof.tx_max_pending = conn->prof.tx_pending;
- if (rc != 0) {
+ if (rc) {
struct netiucv_priv *privptr;
fsm_newstate(conn->fsm, CONN_STATE_IDLE);
conn->prof.tx_pending--;
skb_pull(skb, NETIUCV_HDRLEN);
skb_trim(skb, skb->len - NETIUCV_HDRLEN);
}
- printk(KERN_INFO "iucv_send returned %08x\n",
- rc);
+ PRINT_WARN("iucv_send returned %08x\n", rc);
+ IUCV_DBF_TEXT_(data, 2, "rc %d from iucv_send\n", rc);
} else {
if (copied)
dev_kfree_skb(skb);
return rc;
}
-\f
+
/**
* Interface API for upper network layers
*****************************************************************************/
*/
static int
netiucv_open(struct net_device *dev) {
- fsm_event(((struct netiucv_priv *)dev->priv)->fsm, DEV_EVENT_START, dev);
+ fsm_event(((struct netiucv_priv *)dev->priv)->fsm, DEV_EVENT_START,dev);
return 0;
}
int rc = 0;
struct netiucv_priv *privptr = dev->priv;
+ IUCV_DBF_TEXT(trace, 4, __FUNCTION__);
/**
* Some sanity checks ...
*/
if (skb == NULL) {
- printk(KERN_WARNING "%s: NULL sk_buff passed\n", dev->name);
+ PRINT_WARN("%s: NULL sk_buff passed\n", dev->name);
+ IUCV_DBF_TEXT(data, 2, "netiucv_tx: skb is NULL\n");
privptr->stats.tx_dropped++;
return 0;
}
- if (skb_headroom(skb) < (NETIUCV_HDRLEN)) {
- printk(KERN_WARNING
- "%s: Got sk_buff with head room < %ld bytes\n",
+ if (skb_headroom(skb) < NETIUCV_HDRLEN) {
+ PRINT_WARN("%s: Got sk_buff with head room < %ld bytes\n",
dev->name, NETIUCV_HDRLEN);
+ IUCV_DBF_TEXT(data, 2,
+ "netiucv_tx: skb_headroom < NETIUCV_HDRLEN\n");
dev_kfree_skb(skb);
privptr->stats.tx_dropped++;
return 0;
/**
* If connection is not running, try to restart it
- * and throw away packet.
+ * and throw away packet.
*/
if (fsm_getstate(privptr->fsm) != DEV_STATE_RUNNING) {
fsm_event(privptr->fsm, DEV_EVENT_START, dev);
return 0;
}
- if (netiucv_test_and_set_busy(dev))
+ if (netiucv_test_and_set_busy(dev)) {
+ IUCV_DBF_TEXT(data, 2, "EBUSY from netiucv_tx\n");
return -EBUSY;
-
+ }
dev->trans_start = jiffies;
- if (netiucv_transmit_skb(privptr->conn, skb) != 0)
+ if (netiucv_transmit_skb(privptr->conn, skb))
rc = 1;
netiucv_clear_busy(dev);
return rc;
static struct net_device_stats *
netiucv_stats (struct net_device * dev)
{
+ IUCV_DBF_TEXT(trace, 5, __FUNCTION__);
return &((struct netiucv_priv *)dev->priv)->stats;
}
static int
netiucv_change_mtu (struct net_device * dev, int new_mtu)
{
- if ((new_mtu < 576) || (new_mtu > NETIUCV_MTU_MAX))
+ IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
+ if ((new_mtu < 576) || (new_mtu > NETIUCV_MTU_MAX)) {
+ IUCV_DBF_TEXT(setup, 2, "given MTU out of valid range\n");
return -EINVAL;
+ }
dev->mtu = new_mtu;
return 0;
}
*****************************************************************************/
static ssize_t
-user_show (struct device *dev, char *buf)
+user_show (struct device *dev, struct device_attribute *attr, char *buf)
{
struct netiucv_priv *priv = dev->driver_data;
+ IUCV_DBF_TEXT(trace, 5, __FUNCTION__);
return sprintf(buf, "%s\n", netiucv_printname(priv->conn->userid));
}
static ssize_t
-user_write (struct device *dev, const char *buf, size_t count)
+user_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
struct netiucv_priv *priv = dev->driver_data;
struct net_device *ndev = priv->conn->netdev;
char username[10];
int i;
+ IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
if (count>9) {
- printk(KERN_WARNING
- "netiucv: username too long (%d)!\n", (int)count);
+ PRINT_WARN("netiucv: username too long (%d)!\n", (int)count);
+ IUCV_DBF_TEXT_(setup, 2,
+ "%d is length of username\n", (int)count);
return -EINVAL;
}
/* trailing lf, grr */
break;
} else {
- printk(KERN_WARNING
- "netiucv: Invalid character in username!\n");
+ PRINT_WARN("netiucv: Invalid char %c in username!\n",
+ *p);
+ IUCV_DBF_TEXT_(setup, 2,
+ "username: invalid character %c\n",
+ *p);
return -EINVAL;
}
}
username[i++] = ' ';
username[9] = '\0';
- if (memcmp(username, priv->conn->userid, 8) != 0) {
+ if (memcmp(username, priv->conn->userid, 8)) {
/* username changed */
if (ndev->flags & (IFF_UP | IFF_RUNNING)) {
- printk(KERN_WARNING
+ PRINT_WARN(
"netiucv: device %s active, connected to %s\n",
dev->bus_id, priv->conn->userid);
- printk(KERN_WARNING
- "netiucv: user cannot be updated\n");
+ PRINT_WARN("netiucv: user cannot be updated\n");
+ IUCV_DBF_TEXT(setup, 2, "user_write: device active\n");
return -EBUSY;
}
}
static DEVICE_ATTR(user, 0644, user_show, user_write);
static ssize_t
-buffer_show (struct device *dev, char *buf)
+buffer_show (struct device *dev, struct device_attribute *attr, char *buf)
{
struct netiucv_priv *priv = dev->driver_data;
+ IUCV_DBF_TEXT(trace, 5, __FUNCTION__);
return sprintf(buf, "%d\n", priv->conn->max_buffsize);
}
static ssize_t
-buffer_write (struct device *dev, const char *buf, size_t count)
+buffer_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
struct netiucv_priv *priv = dev->driver_data;
struct net_device *ndev = priv->conn->netdev;
char *e;
int bs1;
+ IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
if (count >= 39)
return -EINVAL;
bs1 = simple_strtoul(buf, &e, 0);
if (e && (!isspace(*e))) {
- printk(KERN_WARNING
- "netiucv: Invalid character in buffer!\n");
+ PRINT_WARN("netiucv: Invalid character in buffer!\n");
+ IUCV_DBF_TEXT_(setup, 2, "buffer_write: invalid char %c\n", *e);
return -EINVAL;
}
if (bs1 > NETIUCV_BUFSIZE_MAX) {
- printk(KERN_WARNING
- "netiucv: Given buffer size %d too large.\n",
+ PRINT_WARN("netiucv: Given buffer size %d too large.\n",
+ bs1);
+ IUCV_DBF_TEXT_(setup, 2,
+ "buffer_write: buffer size %d too large\n",
bs1);
-
return -EINVAL;
}
if ((ndev->flags & IFF_RUNNING) &&
- (bs1 < (ndev->mtu + NETIUCV_HDRLEN + 2)))
+ (bs1 < (ndev->mtu + NETIUCV_HDRLEN + 2))) {
+ PRINT_WARN("netiucv: Given buffer size %d too small.\n",
+ bs1);
+ IUCV_DBF_TEXT_(setup, 2,
+ "buffer_write: buffer size %d too small\n",
+ bs1);
return -EINVAL;
- if (bs1 < (576 + NETIUCV_HDRLEN + NETIUCV_HDRLEN))
+ }
+ if (bs1 < (576 + NETIUCV_HDRLEN + NETIUCV_HDRLEN)) {
+ PRINT_WARN("netiucv: Given buffer size %d too small.\n",
+ bs1);
+ IUCV_DBF_TEXT_(setup, 2,
+ "buffer_write: buffer size %d too small\n",
+ bs1);
return -EINVAL;
+ }
priv->conn->max_buffsize = bs1;
if (!(ndev->flags & IFF_RUNNING))
static DEVICE_ATTR(buffer, 0644, buffer_show, buffer_write);
static ssize_t
-dev_fsm_show (struct device *dev, char *buf)
+dev_fsm_show (struct device *dev, struct device_attribute *attr, char *buf)
{
struct netiucv_priv *priv = dev->driver_data;
-
+
+ IUCV_DBF_TEXT(trace, 5, __FUNCTION__);
return sprintf(buf, "%s\n", fsm_getstate_str(priv->fsm));
}
static DEVICE_ATTR(device_fsm_state, 0444, dev_fsm_show, NULL);
static ssize_t
-conn_fsm_show (struct device *dev, char *buf)
+conn_fsm_show (struct device *dev, struct device_attribute *attr, char *buf)
{
struct netiucv_priv *priv = dev->driver_data;
-
+
+ IUCV_DBF_TEXT(trace, 5, __FUNCTION__);
return sprintf(buf, "%s\n", fsm_getstate_str(priv->conn->fsm));
}
static DEVICE_ATTR(connection_fsm_state, 0444, conn_fsm_show, NULL);
static ssize_t
-maxmulti_show (struct device *dev, char *buf)
+maxmulti_show (struct device *dev, struct device_attribute *attr, char *buf)
{
struct netiucv_priv *priv = dev->driver_data;
-
+
+ IUCV_DBF_TEXT(trace, 5, __FUNCTION__);
return sprintf(buf, "%ld\n", priv->conn->prof.maxmulti);
}
static ssize_t
-maxmulti_write (struct device *dev, const char *buf, size_t count)
+maxmulti_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
struct netiucv_priv *priv = dev->driver_data;
-
+
+ IUCV_DBF_TEXT(trace, 4, __FUNCTION__);
priv->conn->prof.maxmulti = 0;
return count;
}
static DEVICE_ATTR(max_tx_buffer_used, 0644, maxmulti_show, maxmulti_write);
static ssize_t
-maxcq_show (struct device *dev, char *buf)
+maxcq_show (struct device *dev, struct device_attribute *attr, char *buf)
{
struct netiucv_priv *priv = dev->driver_data;
-
+
+ IUCV_DBF_TEXT(trace, 5, __FUNCTION__);
return sprintf(buf, "%ld\n", priv->conn->prof.maxcqueue);
}
static ssize_t
-maxcq_write (struct device *dev, const char *buf, size_t count)
+maxcq_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
struct netiucv_priv *priv = dev->driver_data;
-
+
+ IUCV_DBF_TEXT(trace, 4, __FUNCTION__);
priv->conn->prof.maxcqueue = 0;
return count;
}
static DEVICE_ATTR(max_chained_skbs, 0644, maxcq_show, maxcq_write);
static ssize_t
-sdoio_show (struct device *dev, char *buf)
+sdoio_show (struct device *dev, struct device_attribute *attr, char *buf)
{
struct netiucv_priv *priv = dev->driver_data;
-
+
+ IUCV_DBF_TEXT(trace, 5, __FUNCTION__);
return sprintf(buf, "%ld\n", priv->conn->prof.doios_single);
}
static ssize_t
-sdoio_write (struct device *dev, const char *buf, size_t count)
+sdoio_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
struct netiucv_priv *priv = dev->driver_data;
-
+
+ IUCV_DBF_TEXT(trace, 4, __FUNCTION__);
priv->conn->prof.doios_single = 0;
return count;
}
static DEVICE_ATTR(tx_single_write_ops, 0644, sdoio_show, sdoio_write);
static ssize_t
-mdoio_show (struct device *dev, char *buf)
+mdoio_show (struct device *dev, struct device_attribute *attr, char *buf)
{
struct netiucv_priv *priv = dev->driver_data;
-
+
+ IUCV_DBF_TEXT(trace, 5, __FUNCTION__);
return sprintf(buf, "%ld\n", priv->conn->prof.doios_multi);
}
static ssize_t
-mdoio_write (struct device *dev, const char *buf, size_t count)
+mdoio_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
struct netiucv_priv *priv = dev->driver_data;
-
+
+ IUCV_DBF_TEXT(trace, 5, __FUNCTION__);
priv->conn->prof.doios_multi = 0;
return count;
}
static DEVICE_ATTR(tx_multi_write_ops, 0644, mdoio_show, mdoio_write);
static ssize_t
-txlen_show (struct device *dev, char *buf)
+txlen_show (struct device *dev, struct device_attribute *attr, char *buf)
{
struct netiucv_priv *priv = dev->driver_data;
-
+
+ IUCV_DBF_TEXT(trace, 5, __FUNCTION__);
return sprintf(buf, "%ld\n", priv->conn->prof.txlen);
}
static ssize_t
-txlen_write (struct device *dev, const char *buf, size_t count)
+txlen_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
struct netiucv_priv *priv = dev->driver_data;
-
+
+ IUCV_DBF_TEXT(trace, 4, __FUNCTION__);
priv->conn->prof.txlen = 0;
return count;
}
static DEVICE_ATTR(netto_bytes, 0644, txlen_show, txlen_write);
static ssize_t
-txtime_show (struct device *dev, char *buf)
+txtime_show (struct device *dev, struct device_attribute *attr, char *buf)
{
struct netiucv_priv *priv = dev->driver_data;
-
+
+ IUCV_DBF_TEXT(trace, 5, __FUNCTION__);
return sprintf(buf, "%ld\n", priv->conn->prof.tx_time);
}
static ssize_t
-txtime_write (struct device *dev, const char *buf, size_t count)
+txtime_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
struct netiucv_priv *priv = dev->driver_data;
-
+
+ IUCV_DBF_TEXT(trace, 4, __FUNCTION__);
priv->conn->prof.tx_time = 0;
return count;
}
static DEVICE_ATTR(max_tx_io_time, 0644, txtime_show, txtime_write);
static ssize_t
-txpend_show (struct device *dev, char *buf)
+txpend_show (struct device *dev, struct device_attribute *attr, char *buf)
{
struct netiucv_priv *priv = dev->driver_data;
+ IUCV_DBF_TEXT(trace, 5, __FUNCTION__);
return sprintf(buf, "%ld\n", priv->conn->prof.tx_pending);
}
static ssize_t
-txpend_write (struct device *dev, const char *buf, size_t count)
+txpend_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
struct netiucv_priv *priv = dev->driver_data;
+ IUCV_DBF_TEXT(trace, 4, __FUNCTION__);
priv->conn->prof.tx_pending = 0;
return count;
}
static DEVICE_ATTR(tx_pending, 0644, txpend_show, txpend_write);
static ssize_t
-txmpnd_show (struct device *dev, char *buf)
+txmpnd_show (struct device *dev, struct device_attribute *attr, char *buf)
{
struct netiucv_priv *priv = dev->driver_data;
+ IUCV_DBF_TEXT(trace, 5, __FUNCTION__);
return sprintf(buf, "%ld\n", priv->conn->prof.tx_max_pending);
}
static ssize_t
-txmpnd_write (struct device *dev, const char *buf, size_t count)
+txmpnd_write (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
struct netiucv_priv *priv = dev->driver_data;
+ IUCV_DBF_TEXT(trace, 4, __FUNCTION__);
priv->conn->prof.tx_max_pending = 0;
return count;
}
{
int ret;
- pr_debug("%s() called\n", __FUNCTION__);
-
+ IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
ret = sysfs_create_group(&dev->kobj, &netiucv_attr_group);
if (ret)
return ret;
static inline void
netiucv_remove_files(struct device *dev)
{
- pr_debug("%s() called\n", __FUNCTION__);
+ IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
sysfs_remove_group(&dev->kobj, &netiucv_stat_attr_group);
sysfs_remove_group(&dev->kobj, &netiucv_attr_group);
}
netiucv_register_device(struct net_device *ndev)
{
struct netiucv_priv *priv = ndev->priv;
- struct device *dev = kmalloc(sizeof(struct device), GFP_KERNEL);
+ struct device *dev = kzalloc(sizeof(struct device), GFP_KERNEL);
int ret;
- pr_debug("%s() called\n", __FUNCTION__);
+ IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
if (dev) {
- memset(dev, 0, sizeof(struct device));
snprintf(dev->bus_id, BUS_ID_SIZE, "net%s", ndev->name);
dev->bus = &iucv_bus;
dev->parent = iucv_root;
* but legitime ...).
*/
dev->release = (void (*)(struct device *))kfree;
+ dev->driver = &netiucv_driver;
} else
return -ENOMEM;
ret = netiucv_add_files(dev);
if (ret)
goto out_unreg;
- dev->driver_data = priv;
priv->dev = dev;
+ dev->driver_data = priv;
return 0;
out_unreg:
static void
netiucv_unregister_device(struct device *dev)
{
- pr_debug("%s() called\n", __FUNCTION__);
+ IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
netiucv_remove_files(dev);
device_unregister(dev);
}
/**
* Allocate and initialize a new connection structure.
- * Add it to the list of connections;
+ * Add it to the list of netiucv connections;
*/
static struct iucv_connection *
netiucv_new_connection(struct net_device *dev, char *username)
{
- struct iucv_connection **clist = &connections;
+ struct iucv_connection **clist = &iucv_connections;
struct iucv_connection *conn =
- (struct iucv_connection *)
- kmalloc(sizeof(struct iucv_connection), GFP_KERNEL);
+ kzalloc(sizeof(struct iucv_connection), GFP_KERNEL);
if (conn) {
- memset(conn, 0, sizeof(struct iucv_connection));
skb_queue_head_init(&conn->collect_queue);
skb_queue_head_init(&conn->commit_queue);
conn->max_buffsize = NETIUCV_BUFSIZE_DEFAULT;
/**
* Release a connection structure and remove it from the
- * list of connections.
+ * list of netiucv connections.
*/
static void
netiucv_remove_connection(struct iucv_connection *conn)
{
- struct iucv_connection **clist = &connections;
-
- pr_debug("%s() called\n", __FUNCTION__);
+ struct iucv_connection **clist = &iucv_connections;
+ IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
if (conn == NULL)
return;
while (*clist) {
if (*clist == conn) {
*clist = conn->next;
- if (conn->handle != 0) {
+ if (conn->handle) {
iucv_unregister_program(conn->handle);
- conn->handle = 0;
+ conn->handle = NULL;
}
fsm_deltimer(&conn->timer);
kfree_fsm(conn->fsm);
{
struct netiucv_priv *privptr;
- pr_debug("%s() called\n", __FUNCTION__);
+ IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
if (!dev)
return;
netiucv_remove_connection(privptr->conn);
if (privptr->fsm)
kfree_fsm(privptr->fsm);
- privptr->conn = 0; privptr->fsm = 0;
+ privptr->conn = NULL; privptr->fsm = NULL;
/* privptr gets freed by free_netdev() */
}
free_netdev(dev);
netiucv_setup_netdevice);
if (!dev)
return NULL;
+ if (dev_alloc_name(dev, dev->name) < 0) {
+ free_netdev(dev);
+ return NULL;
+ }
- privptr = (struct netiucv_priv *)dev->priv;
+ privptr = (struct netiucv_priv *)dev->priv;
privptr->fsm = init_fsm("netiucvdev", dev_state_names,
dev_event_names, NR_DEV_STATES, NR_DEV_EVENTS,
dev_fsm, DEV_FSM_LEN, GFP_KERNEL);
- if (privptr->fsm == NULL) {
+ if (!privptr->fsm) {
free_netdev(dev);
return NULL;
}
if (!privptr->conn) {
kfree_fsm(privptr->fsm);
free_netdev(dev);
+ IUCV_DBF_TEXT(setup, 2, "NULL from netiucv_new_connection\n");
return NULL;
}
fsm_newstate(privptr->fsm, DEV_STATE_STOPPED);
int i, ret;
struct net_device *dev;
+ IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
if (count>9) {
- printk(KERN_WARNING
- "netiucv: username too long (%d)!\n", (int)count);
+ PRINT_WARN("netiucv: username too long (%d)!\n", (int)count);
+ IUCV_DBF_TEXT(setup, 2, "conn_write: too long\n");
return -EINVAL;
}
/* trailing lf, grr */
break;
} else {
- printk(KERN_WARNING
- "netiucv: Invalid character in username!\n");
+ PRINT_WARN("netiucv: Invalid character in username!\n");
+ IUCV_DBF_TEXT_(setup, 2,
+ "conn_write: invalid character %c\n", *p);
return -EINVAL;
}
}
username[9] = '\0';
dev = netiucv_init_netdevice(username);
if (!dev) {
- printk(KERN_WARNING
+ PRINT_WARN(
"netiucv: Could not allocate network device structure "
"for user '%s'\n", netiucv_printname(username));
+ IUCV_DBF_TEXT(setup, 2, "NULL from netiucv_init_netdevice\n");
return -ENODEV;
}
-
- if ((ret = register_netdev(dev))) {
- goto out_free_ndev;
- }
if ((ret = netiucv_register_device(dev))) {
- unregister_netdev(dev);
+ IUCV_DBF_TEXT_(setup, 2,
+ "ret %d from netiucv_register_device\n", ret);
goto out_free_ndev;
}
/* sysfs magic */
- SET_NETDEV_DEV(dev, (struct device*)((struct netiucv_priv*)dev->priv)->dev);
- printk(KERN_INFO "%s: '%s'\n", dev->name, netiucv_printname(username));
-
+ SET_NETDEV_DEV(dev,
+ (struct device*)((struct netiucv_priv*)dev->priv)->dev);
+
+ if ((ret = register_netdev(dev))) {
+ netiucv_unregister_device((struct device*)
+ ((struct netiucv_priv*)dev->priv)->dev);
+ goto out_free_ndev;
+ }
+
+ PRINT_INFO("%s: '%s'\n", dev->name, netiucv_printname(username));
+
return count;
out_free_ndev:
- printk(KERN_WARNING
- "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");
netiucv_free_netdevice(dev);
return ret;
}
static ssize_t
remove_write (struct device_driver *drv, const char *buf, size_t count)
{
- struct iucv_connection **clist = &connections;
+ struct iucv_connection **clist = &iucv_connections;
struct net_device *ndev;
struct netiucv_priv *priv;
struct device *dev;
char *p;
int i;
- pr_debug("%s() called\n", __FUNCTION__);
+ IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
if (count >= IFNAMSIZ)
count = IFNAMSIZ-1;
continue;
}
if (ndev->flags & (IFF_UP | IFF_RUNNING)) {
- printk(KERN_WARNING
+ PRINT_WARN(
"netiucv: net device %s active with peer %s\n",
ndev->name, priv->conn->userid);
- printk(KERN_WARNING
- "netiucv: %s cannot be removed\n",
+ PRINT_WARN("netiucv: %s cannot be removed\n",
ndev->name);
+ IUCV_DBF_TEXT(data, 2, "remove_write: still active\n");
return -EBUSY;
}
unregister_netdev(ndev);
netiucv_unregister_device(dev);
return count;
}
- printk(KERN_WARNING
- "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");
return -EINVAL;
}
DRIVER_ATTR(remove, 0200, NULL, remove_write);
-static struct device_driver netiucv_driver = {
- .name = "netiucv",
- .bus = &iucv_bus,
-};
-
static void
netiucv_banner(void)
{
- char vbuf[] = "$Revision: 1.57 $";
- char *version = vbuf;
-
- if ((version = strchr(version, ':'))) {
- char *p = strchr(version + 1, '$');
- if (p)
- *p = '\0';
- } else
- version = " ??? ";
- printk(KERN_INFO "NETIUCV driver Version%s initialized\n", version);
+ PRINT_INFO("NETIUCV driver initialized\n");
}
static void __exit
netiucv_exit(void)
{
- while (connections) {
- struct net_device *ndev = connections->netdev;
+ IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
+ while (iucv_connections) {
+ struct net_device *ndev = iucv_connections->netdev;
struct netiucv_priv *priv = (struct netiucv_priv*)ndev->priv;
struct device *dev = priv->dev;
driver_remove_file(&netiucv_driver, &driver_attr_connection);
driver_remove_file(&netiucv_driver, &driver_attr_remove);
driver_unregister(&netiucv_driver);
+ iucv_unregister_dbf_views();
- printk(KERN_INFO "NETIUCV driver unloaded\n");
+ PRINT_INFO("NETIUCV driver unloaded\n");
return;
}
netiucv_init(void)
{
int ret;
-
+
+ ret = iucv_register_dbf_views();
+ if (ret) {
+ PRINT_WARN("netiucv_init failed, "
+ "iucv_register_dbf_views rc = %d\n", ret);
+ return ret;
+ }
+ IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
ret = driver_register(&netiucv_driver);
- if (ret != 0) {
- printk(KERN_ERR "NETIUCV: failed to register driver.\n");
+ if (ret) {
+ PRINT_ERR("NETIUCV: failed to register driver.\n");
+ IUCV_DBF_TEXT_(setup, 2, "ret %d from driver_register\n", ret);
+ iucv_unregister_dbf_views();
return ret;
}
/* Add entry for specifying connections. */
ret = driver_create_file(&netiucv_driver, &driver_attr_connection);
- if (ret == 0) {
+ if (!ret) {
ret = driver_create_file(&netiucv_driver, &driver_attr_remove);
netiucv_banner();
} else {
- printk(KERN_ERR "NETIUCV: failed to add driver attribute.\n");
+ 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;
}
-
+
module_init(netiucv_init);
module_exit(netiucv_exit);
MODULE_LICENSE("GPL");