Commit 443d4171 authored by Jeff Garzik's avatar Jeff Garzik

Merge kernel.bkbits.net:net-drivers-2.5

into redhat.com:/home/jgarzik/repo/net-drivers-2.5
parents 828bb5f4 0453aca6
......@@ -12,8 +12,8 @@
#include <linux/if_ether.h>
#include <linux/etherdevice.h>
#include <linux/pci.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/init.h>
#include <asm/uaccess.h>
#include <asm/io.h>
......@@ -23,8 +23,8 @@
#define DRV_MODULE_NAME "b44"
#define PFX DRV_MODULE_NAME ": "
#define DRV_MODULE_VERSION "0.1"
#define DRV_MODULE_RELDATE "Nov 6, 2002"
#define DRV_MODULE_VERSION "0.6"
#define DRV_MODULE_RELDATE "Nov 11, 2002"
#define B44_DEF_MSG_ENABLE \
(NETIF_MSG_DRV | \
......@@ -62,7 +62,6 @@
(BP)->tx_cons - (BP)->tx_prod - TX_RING_GAP(BP))
#define NEXT_TX(N) (((N) + 1) & (B44_TX_RING_SIZE - 1))
/* XXX check this */
#define RX_PKT_BUF_SZ (1536 + bp->rx_offset + 64)
/* minimum number of free TX descriptors required to wake up TX process */
......@@ -72,18 +71,13 @@ static char version[] __devinitdata =
DRV_MODULE_NAME ".c:v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n";
MODULE_AUTHOR("David S. Miller (davem@redhat.com)");
MODULE_DESCRIPTION("Broadcom 4400 ethernet driver");
MODULE_DESCRIPTION("Broadcom 4400 10/100 PCI ethernet driver");
MODULE_LICENSE("GPL");
MODULE_PARM(b44_debug, "i");
MODULE_PARM_DESC(b44_debug, "B44 bitmapped debugging message enable value");
static int b44_debug = -1; /* -1 == use B44_DEF_MSG_ENABLE as value */
/* XXX put this to pci_ids.h and pci.ids */
#ifndef PCI_DEVICE_ID_BCM4401
#define PCI_DEVICE_ID_BCM4401 0x4401
#endif
static struct pci_device_id b44_pci_tbl[] __devinitdata = {
{ PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_BCM4401,
PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
......@@ -96,8 +90,8 @@ static void b44_halt(struct b44 *);
static void b44_init_rings(struct b44 *);
static int b44_init_hw(struct b44 *);
static void b44_wait_bit(struct b44 *bp, unsigned long reg,
u32 bit, unsigned long timeout, int clear)
static int b44_wait_bit(struct b44 *bp, unsigned long reg,
u32 bit, unsigned long timeout, const int clear)
{
unsigned long i;
......@@ -116,7 +110,9 @@ static void b44_wait_bit(struct b44 *bp, unsigned long reg,
bp->dev->name,
bit, reg,
(clear ? "clear" : "set"));
return -ENODEV;
}
return 0;
}
/* Sonics SiliconBackplane support routines. ROFL, you should see all the
......@@ -301,15 +297,18 @@ static void b44_enable_ints(struct b44 *bp)
static int b44_readphy(struct b44 *bp, int reg, u32 *val)
{
int err;
bw32(B44_EMAC_ISTAT, EMAC_INT_MII);
bw32(B44_MDIO_DATA, (MDIO_DATA_SB_START |
(MDIO_OP_READ << MDIO_DATA_OP_SHIFT) |
(bp->phy_addr << MDIO_DATA_PMD_SHIFT) |
(reg << MDIO_DATA_RA_SHIFT) |
(MDIO_TA_VALID << MDIO_DATA_TA_SHIFT)));
b44_wait_bit(bp, B44_EMAC_ISTAT, EMAC_INT_MII, 100, 0);
err = b44_wait_bit(bp, B44_EMAC_ISTAT, EMAC_INT_MII, 100, 0);
*val = br32(B44_MDIO_DATA) & MDIO_DATA_DATA;
return 0;
return err;
}
static int b44_writephy(struct b44 *bp, int reg, u32 val)
......@@ -321,8 +320,7 @@ static int b44_writephy(struct b44 *bp, int reg, u32 val)
(reg << MDIO_DATA_RA_SHIFT) |
(MDIO_TA_VALID << MDIO_DATA_TA_SHIFT) |
(val & MDIO_DATA_DATA)));
b44_wait_bit(bp, B44_EMAC_ISTAT, EMAC_INT_MII, 100, 0);
return 0;
return b44_wait_bit(bp, B44_EMAC_ISTAT, EMAC_INT_MII, 100, 0);
}
static int b44_phy_reset(struct b44 *bp)
......@@ -346,12 +344,6 @@ static int b44_phy_reset(struct b44 *bp)
return 0;
}
#if 0
static int b44_set_power_state(struct b44 *bp, int state)
{
}
#endif
static void __b44_set_flow_ctrl(struct b44 *bp, u32 pause_flags)
{
u32 val;
......@@ -575,7 +567,6 @@ static void b44_tx(struct b44 *bp)
if (unlikely(skb == NULL))
BUG();
pci_unmap_single(bp->pdev,
pci_unmap_addr(rp, mapping),
skb->len,
......@@ -592,10 +583,16 @@ static void b44_tx(struct b44 *bp)
bw32(B44_GPTIMER, 0);
}
/* Works like this. This chip writes a 'struct rx_header" 30 bytes
* before the DMA address you give it. So we allocate 30 more bytes
* for the RX buffer, DMA map all of it, skb_reserve the 30 bytes, then
* point the chip at 30 bytes past where the rx_header will go.
*/
static int b44_alloc_rx_skb(struct b44 *bp, int src_idx, u32 dest_idx_unmasked)
{
struct dma_desc *dp;
struct ring_info *src_map, *map;
struct rx_header *rh;
struct sk_buff *skb;
dma_addr_t mapping;
int dest_idx;
......@@ -616,6 +613,11 @@ static int b44_alloc_rx_skb(struct b44 *bp, int src_idx, u32 dest_idx_unmasked)
PCI_DMA_FROMDEVICE);
skb_reserve(skb, bp->rx_offset);
rh = (struct rx_header *)
(skb->data - bp->rx_offset);
rh->len = 0;
rh->flags = 0;
map->skb = skb;
pci_unmap_addr_set(map, mapping, mapping);
......@@ -637,6 +639,7 @@ static void b44_recycle_rx(struct b44 *bp, int src_idx, u32 dest_idx_unmasked)
{
struct dma_desc *src_desc, *dest_desc;
struct ring_info *src_map, *dest_map;
struct rx_header *rh;
int dest_idx;
u32 ctrl;
......@@ -647,6 +650,10 @@ static void b44_recycle_rx(struct b44 *bp, int src_idx, u32 dest_idx_unmasked)
src_map = &bp->rx_buffers[src_idx];
dest_map->skb = src_map->skb;
rh = (struct rx_header *)
(src_map->skb->data - bp->rx_offset);
rh->len = 0;
rh->flags = 0;
pci_unmap_addr_set(dest_map, mapping,
pci_unmap_addr(src_map, mapping));
......@@ -680,7 +687,8 @@ static int b44_rx(struct b44 *bp, int budget)
PCI_DMA_FROMDEVICE);
rh = (struct rx_header *) (skb->data - bp->rx_offset);
len = cpu_to_le16(rh->len);
if (rh->flags & cpu_to_le16(RX_FLAG_ERRORS)) {
if ((len > (RX_PKT_BUF_SZ - bp->rx_offset)) ||
(rh->flags & cpu_to_le16(RX_FLAG_ERRORS))) {
drop_it:
b44_recycle_rx(bp, cons, bp->rx_prod);
drop_it_no_recycle:
......@@ -688,6 +696,21 @@ static int b44_rx(struct b44 *bp, int budget)
goto next_pkt;
}
if (len == 0) {
int i = 0;
do {
udelay(2);
barrier();
len = cpu_to_le16(rh->len);
} while (len == 0 && i++ < 5);
if (len == 0)
goto drop_it;
}
/* Omit CRC. */
len -= 4;
if (len > RX_COPY_THRESHOLD) {
int skb_size;
skb_size = b44_alloc_rx_skb(bp, cons, bp->rx_prod);
......@@ -927,7 +950,7 @@ static void b44_free_rings(struct b44 *bp)
continue;
pci_unmap_single(bp->pdev,
pci_unmap_addr(rp, mapping),
RX_PKT_BUF_SZ - bp->rx_offset,
RX_PKT_BUF_SZ,
PCI_DMA_FROMDEVICE);
dev_kfree_skb_any(rp->skb);
rp->skb = NULL;
......@@ -1053,7 +1076,10 @@ static void b44_chip_reset(struct b44 *bp)
b44_wait_bit(bp, B44_ENET_CTRL, ENET_CTRL_DISABLE, 100, 1);
bw32(B44_DMATX_CTRL, 0);
bp->tx_prod = bp->tx_cons = 0;
b44_wait_bit(bp, B44_DMARX_STAT, DMARX_STAT_SIDLE, 100, 0);
if (br32(B44_DMARX_STAT) & DMARX_STAT_EMASK) {
b44_wait_bit(bp, B44_DMARX_STAT, DMARX_STAT_SIDLE,
100, 0);
}
bw32(B44_DMARX_CTRL, 0);
bp->rx_prod = bp->rx_cons = 0;
} else {
......@@ -1173,45 +1199,38 @@ static int b44_open(struct net_device *dev)
if (err)
return err;
err = request_irq(dev->irq, b44_interrupt,
SA_SHIRQ, dev->name, dev);
if (err) {
b44_free_consistent(bp);
return err;
}
err = request_irq(dev->irq, b44_interrupt, SA_SHIRQ, dev->name, dev);
if (err)
goto err_out_free;
spin_lock_irq(&bp->lock);
b44_init_rings(bp);
err = b44_init_hw(bp);
if (err) {
b44_halt(bp);
b44_free_rings(bp);
} else {
bp->flags |= B44_FLAG_INIT_COMPLETE;
}
if (err)
goto err_out_noinit;
bp->flags |= B44_FLAG_INIT_COMPLETE;
spin_unlock_irq(&bp->lock);
if (err) {
free_irq(dev->irq, dev);
b44_free_consistent(bp);
return err;
} else {
init_timer(&bp->timer);
bp->timer.expires = jiffies + HZ;
bp->timer.data = (unsigned long) bp;
bp->timer.function = b44_timer;
add_timer(&bp->timer);
}
spin_lock_irq(&bp->lock);
init_timer(&bp->timer);
bp->timer.expires = jiffies + HZ;
bp->timer.data = (unsigned long) bp;
bp->timer.function = b44_timer;
add_timer(&bp->timer);
b44_enable_ints(bp);
spin_unlock_irq(&bp->lock);
return 0;
err_out_noinit:
b44_halt(bp);
b44_free_rings(bp);
spin_unlock_irq(&bp->lock);
free_irq(dev->irq, dev);
err_out_free:
b44_free_consistent(bp);
return err;
}
#if 0
......@@ -1232,7 +1251,18 @@ static int b44_close(struct net_device *dev)
netif_stop_queue(dev);
del_timer_sync(&bp->timer);
spin_lock_irq(&bp->lock);
#if 0
b44_dump_state(bp);
#endif
b44_halt(bp);
b44_free_rings(bp);
bp->flags &= ~B44_FLAG_INIT_COMPLETE;
netif_carrier_off(bp->dev);
spin_unlock_irq(&bp->lock);
free_irq(dev->irq, dev);
......@@ -1711,8 +1741,8 @@ static int __devinit b44_init_one(struct pci_dev *pdev,
bp = dev->priv;
bp->pdev = pdev;
bp->dev = dev;
if (b44_debug > 0)
bp->msg_enable = b44_debug;
if (b44_debug >= 0)
bp->msg_enable = (1 << b44_debug) - 1;
else
bp->msg_enable = B44_DEF_MSG_ENABLE;
......@@ -1809,10 +1839,6 @@ static struct pci_driver b44_driver = {
.id_table = b44_pci_tbl,
.probe = b44_init_one,
.remove = __devexit_p(b44_remove_one),
#if 0
.suspend = b44_suspend,
.resume = b44_resume
#endif
};
static int __init b44_init(void)
......@@ -1827,3 +1853,4 @@ static void __exit b44_cleanup(void)
module_init(b44_init);
module_exit(b44_cleanup);
......@@ -1604,6 +1604,7 @@
#define PCI_DEVICE_ID_TIGON3_5702FE 0x164d
#define PCI_DEVICE_ID_TIGON3_5702X 0x16a6
#define PCI_DEVICE_ID_TIGON3_5703X 0x16a7
#define PCI_DEVICE_ID_BCM4401 0x4401
#define PCI_VENDOR_ID_SYBA 0x1592
#define PCI_DEVICE_ID_SYBA_2P_EPP 0x0782
......
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