Commit 947af82f authored by Ben Collins's avatar Ben Collins

[PATCH] Update IEEE1394 (r986)

 ETH1394  : - Minor cleanups.
            - Fix incorrect error handling with no broadcast channel.
	    - Set max/default MTU to 1500.
	    - Fix broken spinlock handling on device open.
 IEEE1394 : Make bus-nodeid printk's of a consistent format.
 OHCI1394 : Change one printk to a verbose/debug only message.
parent df7c718d
/*
* eth1394.c -- Ethernet driver for Linux IEEE-1394 Subsystem
*
* Copyright (C) 2001 Ben Collins <bcollins@debian.org>
* Copyright (C) 2001-2003 Ben Collins <bcollins@debian.org>
* 2000 Bonin Franck <boninf@free.fr>
* 2003 Steve Kinneberg <kinnebergsteve@acmsystems.com>
*
......@@ -33,7 +33,7 @@
* - Add MCAP. Limited Multicast exists only to 224.0.0.1 and 224.0.0.2.
*
* Non-RFC 2734 related:
* - Fix bug related to fragmented broadcast datagrams
* - Handle fragmented skb's coming from the networking layer.
* - Move generic GASP reception to core 1394 code
* - Convert kmalloc/kfree for link fragments to use kmem_cache_* instead
* - Stability improvements
......@@ -89,7 +89,7 @@
#define TRACE() printk(KERN_ERR "%s:%s[%d] ---- TRACE\n", driver_name, __FUNCTION__, __LINE__)
static char version[] __devinitdata =
"$Rev: 971 $ Ben Collins <bcollins@debian.org>";
"$Rev: 986 $ Ben Collins <bcollins@debian.org>";
struct fragment_info {
struct list_head list;
......@@ -122,6 +122,12 @@ static const int hdr_type_len[] = {
sizeof (struct eth1394_sf_hdr)
};
/* Change this to IEEE1394_SPEED_S100 to make testing easier */
#define ETH1394_SPEED_DEF IEEE1394_SPEED_MAX
/* For now, this needs to be 1500, so that XP works with us */
#define ETH1394_DATA_LEN ETH_DATA_LEN
static const u16 eth1394_speedto_maxpayload[] = {
/* S100, S200, S400, S800, S1600, S3200 */
512, 1024, 2048, 4096, 8192, 16384
......@@ -167,7 +173,8 @@ static void eth1394_iso_shutdown(struct eth1394_priv *priv)
priv->bc_state = ETHER1394_BC_CLOSED;
if (priv->iso != NULL) {
hpsb_iso_shutdown(priv->iso);
if (!in_interrupt())
hpsb_iso_shutdown(priv->iso);
priv->iso = NULL;
}
}
......@@ -192,8 +199,7 @@ static int ether1394_init_bc(struct net_device *dev)
"Error BROADCAST_CHANNEL register valid "
"bit not set, can't send IP traffic\n");
if (!in_interrupt())
eth1394_iso_shutdown(priv);
eth1394_iso_shutdown(priv);
return -EAGAIN;
}
......@@ -202,11 +208,11 @@ static int ether1394_init_bc(struct net_device *dev)
* the IEEE 1394 spec changes regarding broadcast
* channels in the future. */
eth1394_iso_shutdown(priv);
if (in_interrupt())
return -EAGAIN;
eth1394_iso_shutdown(priv);
priv->broadcast_channel = bc & 0x3f;
ETH1394_PRINT(KERN_INFO, dev->name,
"Changing to broadcast channel %d...\n",
......@@ -226,8 +232,7 @@ static int ether1394_init_bc(struct net_device *dev)
ETH1394_PRINT(KERN_ERR, dev->name,
"Could not start data stream reception\n");
if (!in_interrupt())
eth1394_iso_shutdown(priv);
eth1394_iso_shutdown(priv);
return -EAGAIN;
}
......@@ -244,8 +249,10 @@ static int ether1394_open (struct net_device *dev)
unsigned long flags;
int ret;
/* Set the spinlock before grabbing IRQ! */
priv->lock = SPIN_LOCK_UNLOCKED;
/* Something bad happened, don't even try */
if (priv->bc_state == ETHER1394_BC_CLOSED)
return -EAGAIN;
spin_lock_irqsave(&priv->lock, flags);
ret = ether1394_init_bc(dev);
spin_unlock_irqrestore(&priv->lock, flags);
......@@ -287,9 +294,8 @@ static int ether1394_change_mtu(struct net_device *dev, int new_mtu)
struct eth1394_priv *priv = (struct eth1394_priv *)dev->priv;
int phy_id = NODEID_TO_NODE(priv->host->node_id);
if ((new_mtu < 68) || (new_mtu > MIN(ETH_DATA_LEN, (priv->maxpayload[phy_id] -
(sizeof(union eth1394_hdr) +
ETHER1394_GASP_OVERHEAD)))))
if ((new_mtu < 68) || (new_mtu > min(ETH1394_DATA_LEN, (int)(priv->maxpayload[phy_id] -
(sizeof(union eth1394_hdr) + ETHER1394_GASP_OVERHEAD)))))
return -EINVAL;
dev->mtu = new_mtu;
return 0;
......@@ -322,8 +328,7 @@ static void ether1394_reset_priv (struct net_device *dev, int set_mtu)
struct eth1394_priv *priv = (struct eth1394_priv *)dev->priv;
struct hpsb_host *host = priv->host;
int phy_id = NODEID_TO_NODE(host->node_id);
u64 guid = (u64)(((u64)be32_to_cpu(host->csr.rom[3]) << 32) |
be32_to_cpu(host->csr.rom[4]));
u64 guid = *((u64*)&(host->csr.rom[3]));
u16 maxpayload = 1 << (((be32_to_cpu(host->csr.rom[2]) >> 12) & 0xf) + 1);
spin_lock_irqsave (&priv->lock, flags);
......@@ -333,15 +338,8 @@ static void ether1394_reset_priv (struct net_device *dev, int set_mtu)
memset (priv->sspd, 0, sizeof (priv->sspd));
memset (priv->fifo, 0, sizeof (priv->fifo));
#if 1
/* Compile this out to make testing of fragmented broadcast datagrams
* easier. */
priv->sspd[ALL_NODES] = IEEE1394_SPEED_MAX;
priv->maxpayload[ALL_NODES] = eth1394_speedto_maxpayload[IEEE1394_SPEED_MAX];
#else
priv->sspd[ALL_NODES] = IEEE1394_SPEED_100;
priv->maxpayload[ALL_NODES] = eth1394_speedto_maxpayload[IEEE1394_SPEED_100];
#endif
priv->sspd[ALL_NODES] = ETH1394_SPEED_DEF;
priv->maxpayload[ALL_NODES] = eth1394_speedto_maxpayload[priv->sspd[ALL_NODES]];
priv->bc_state = ETHER1394_BC_CHECK;
......@@ -352,9 +350,8 @@ static void ether1394_reset_priv (struct net_device *dev, int set_mtu)
/* We'll use our maxpayload as the default mtu */
if (set_mtu) {
dev->mtu = MIN(ETH_DATA_LEN, priv->maxpayload[phy_id] -
(sizeof(union eth1394_hdr) +
ETHER1394_GASP_OVERHEAD));
dev->mtu = min(ETH1394_DATA_LEN, (int)(priv->maxpayload[phy_id] -
(sizeof(union eth1394_hdr) + ETHER1394_GASP_OVERHEAD)));
/* Set our hardware address while we're at it */
*(u64*)dev->dev_addr = guid;
......@@ -444,8 +441,8 @@ static void ether1394_add_host (struct hpsb_host *host)
priv = (struct eth1394_priv *)dev->priv;
priv->host = host;
spin_lock_init(&priv->lock);
priv->host = host;
for (i = 0; i < ALL_NODES; i++) {
spin_lock_init(&priv->pdg[i].lock);
......@@ -501,7 +498,6 @@ static void ether1394_remove_host (struct hpsb_host *host)
if (hi != NULL) {
struct eth1394_priv *priv = (struct eth1394_priv *)hi->dev->priv;
priv->bc_state = ETHER1394_BC_CLOSED;
eth1394_iso_shutdown(priv);
if (hi->dev) {
......@@ -1380,17 +1376,15 @@ static inline void ether1394_dg_complete(struct packet_task *ptask, int fail)
unsigned long flags;
/* Statistics */
spin_lock_irqsave(&priv->lock, flags);
if (fail) {
spin_lock_irqsave(&priv->lock, flags);
priv->stats.tx_dropped++;
priv->stats.tx_errors++;
spin_unlock_irqrestore(&priv->lock, flags);
} else {
spin_lock_irqsave(&priv->lock, flags);
priv->stats.tx_bytes += skb->len;
priv->stats.tx_packets++;
spin_unlock_irqrestore(&priv->lock, flags);
}
spin_unlock_irqrestore(&priv->lock, flags);
dev_kfree_skb_any(skb);
kmem_cache_free(packet_task_cache, ptask);
......@@ -1460,11 +1454,9 @@ static int ether1394_tx (struct sk_buff *skb, struct net_device *dev)
goto fail;
}
if (priv->bc_state == ETHER1394_BC_CHECK) {
if (ether1394_init_bc(dev)) {
spin_unlock_irqrestore (&priv->lock, flags);
goto fail;
}
if ((ret = ether1394_init_bc(dev))) {
spin_unlock_irqrestore (&priv->lock, flags);
goto fail;
}
spin_unlock_irqrestore (&priv->lock, flags);
......@@ -1608,7 +1600,7 @@ static int ether1394_ethtool_ioctl(struct net_device *dev, void *useraddr)
case ETHTOOL_GDRVINFO: {
struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
strcpy (info.driver, driver_name);
strcpy (info.version, "$Rev: 971 $");
strcpy (info.version, "$Rev: 986 $");
/* FIXME XXX provide sane businfo */
strcpy (info.bus_info, "ieee1394");
if (copy_to_user (useraddr, &info, sizeof (info)))
......
......@@ -1303,8 +1303,9 @@ static void nodemgr_update_node(struct node_entry *ne, quadlet_t busoptions,
snprintf(ne->device.name, DEVICE_NAME_SIZE,
"IEEE-1394 device %d-" NODE_BUS_FMT,
hi->host->id, NODE_BUS_ARGS(ne->nodeid));
HPSB_DEBUG("Node " NODE_BUS_FMT " changed to " NODE_BUS_FMT,
NODE_BUS_ARGS(ne->nodeid), NODE_BUS_ARGS(nodeid));
HPSB_DEBUG("Node changed: %d-" NODE_BUS_FMT " -> %d-" NODE_BUS_FMT,
ne->host->id, NODE_BUS_ARGS(ne->nodeid),
ne->host->id, NODE_BUS_ARGS(nodeid));
ne->nodeid = nodeid;
update_ud_names++;
......@@ -1507,8 +1508,8 @@ static void nodemgr_node_probe(struct host_info *hi, int generation)
nodemgr_remove_node)) {
struct node_entry *ne = cleanup.ne;
HPSB_DEBUG("Device removed: ID:BUS[" NODE_BUS_FMT "] GUID[%016Lx]",
NODE_BUS_ARGS(ne->nodeid), (unsigned long long)ne->guid);
HPSB_DEBUG("Node removed: ID:BUS[%d-" NODE_BUS_FMT "] GUID[%016Lx]",
host->id, NODE_BUS_ARGS(ne->nodeid), (unsigned long long)ne->guid);
nodemgr_remove_ne(ne);
}
......@@ -1782,7 +1783,7 @@ static void nodemgr_host_reset(struct hpsb_host *host)
if (hi != NULL) {
#ifdef CONFIG_IEEE1394_VERBOSEDEBUG
HPSB_DEBUG ("NodeMgr: Processing host reset for %s", host->driver->name);
HPSB_DEBUG ("NodeMgr: Processing host reset for %s", hi->daemon_name);
#endif
up(&hi->reset_sem);
} else
......
......@@ -164,7 +164,7 @@ printk(level "%s: " fmt "\n" , OHCI1394_DRIVER_NAME , ## args)
printk(level "%s_%d: " fmt "\n" , OHCI1394_DRIVER_NAME, card , ## args)
static char version[] __devinitdata =
"$Rev: 952 $ Ben Collins <bcollins@debian.org>";
"$Rev: 986 $ Ben Collins <bcollins@debian.org>";
/* Module Parameters */
static int phys_dma = 1;
......@@ -810,8 +810,7 @@ static int dma_trm_flush(struct ti_ohci *ohci, struct dma_trm_ctx *d)
}
if (d->free_prgs == 0)
PRINT(KERN_INFO, ohci->id,
"Transmit DMA FIFO ctx=%d is full... waiting",d->ctx);
DBGMSG(ohci->id, "Transmit DMA FIFO ctx=%d is full... waiting", d->ctx);
/* Is the context running ? (should be unless it is
the first packet to be sent in this context) */
......
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