/*
 * Broadcom BCM570x Ethernet Driver for U-Boot.
 * Support 5701, 5702, 5703, and 5704. Single instance driver.
 * Copyright (C) 2002 James F. Dougherty (jfd@broadcom.com)
 */

#include <common.h>

#ifdef CONFIG_BMW
#include <mpc824x.h>
#endif
#include <net.h>
#include "bcm570x_mm.h"
#include "bcm570x_autoneg.h"
#include <pci.h>
#include <malloc.h>

/*
 * PCI Registers and definitions.
 */
#define PCI_CMD_MASK	0xffff0000	/* mask to save status bits */
#define PCI_ANY_ID (~0)

/*
 * PCI memory base for Ethernet device as well as device Interrupt.
 */
#define BCM570X_MBAR	0x80100000
#define BCM570X_ILINE   1

#define SECOND_USEC	1000000
#define MAX_PACKET_SIZE 1600
#define MAX_UNITS       4

/* Globals to this module */
int initialized = 0;
unsigned int ioBase = 0;
volatile PLM_DEVICE_BLOCK pDevice = NULL;	/* 570x softc */
volatile PUM_DEVICE_BLOCK pUmDevice = NULL;

/* Used to pass the full-duplex flag, etc. */
int line_speed[MAX_UNITS] = { 0, 0, 0, 0 };
static int full_duplex[MAX_UNITS] = { 1, 1, 1, 1 };
static int rx_flow_control[MAX_UNITS] = { 0, 0, 0, 0 };
static int tx_flow_control[MAX_UNITS] = { 0, 0, 0, 0 };
static int auto_flow_control[MAX_UNITS] = { 0, 0, 0, 0 };
static int tx_checksum[MAX_UNITS] = { 1, 1, 1, 1 };
static int rx_checksum[MAX_UNITS] = { 1, 1, 1, 1 };
static int auto_speed[MAX_UNITS] = { 1, 1, 1, 1 };

#if JUMBO_FRAMES
/* Jumbo MTU for interfaces. */
static int mtu[MAX_UNITS] = { 0, 0, 0, 0 };
#endif

/* Turn on Wake-on lan for a device unit */
static int enable_wol[MAX_UNITS] = { 0, 0, 0, 0 };

#define TX_DESC_CNT DEFAULT_TX_PACKET_DESC_COUNT
static unsigned int tx_pkt_desc_cnt[MAX_UNITS] =
    { TX_DESC_CNT, TX_DESC_CNT, TX_DESC_CNT, TX_DESC_CNT };

#define RX_DESC_CNT DEFAULT_STD_RCV_DESC_COUNT
static unsigned int rx_std_desc_cnt[MAX_UNITS] =
    { RX_DESC_CNT, RX_DESC_CNT, RX_DESC_CNT, RX_DESC_CNT };

static unsigned int rx_adaptive_coalesce[MAX_UNITS] = { 1, 1, 1, 1 };

#if T3_JUMBO_RCV_RCB_ENTRY_COUNT
#define JBO_DESC_CNT DEFAULT_JUMBO_RCV_DESC_COUNT
static unsigned int rx_jumbo_desc_cnt[MAX_UNITS] =
    { JBO_DESC_CNT, JBO_DESC_CNT, JBO_DESC_CNT, JBO_DESC_CNT };
#endif
#define RX_COAL_TK DEFAULT_RX_COALESCING_TICKS
static unsigned int rx_coalesce_ticks[MAX_UNITS] =
    { RX_COAL_TK, RX_COAL_TK, RX_COAL_TK, RX_COAL_TK };

#define RX_COAL_FM DEFAULT_RX_MAX_COALESCED_FRAMES
static unsigned int rx_max_coalesce_frames[MAX_UNITS] =
    { RX_COAL_FM, RX_COAL_FM, RX_COAL_FM, RX_COAL_FM };

#define TX_COAL_TK DEFAULT_TX_COALESCING_TICKS
static unsigned int tx_coalesce_ticks[MAX_UNITS] =
    { TX_COAL_TK, TX_COAL_TK, TX_COAL_TK, TX_COAL_TK };

#define TX_COAL_FM DEFAULT_TX_MAX_COALESCED_FRAMES
static unsigned int tx_max_coalesce_frames[MAX_UNITS] =
    { TX_COAL_FM, TX_COAL_FM, TX_COAL_FM, TX_COAL_FM };

#define ST_COAL_TK DEFAULT_STATS_COALESCING_TICKS
static unsigned int stats_coalesce_ticks[MAX_UNITS] =
    { ST_COAL_TK, ST_COAL_TK, ST_COAL_TK, ST_COAL_TK };

/*
 * Legitimate values for BCM570x device types
 */
typedef enum {
	BCM5700VIGIL = 0,
	BCM5700A6,
	BCM5700T6,
	BCM5700A9,
	BCM5700T9,
	BCM5700,
	BCM5701A5,
	BCM5701T1,
	BCM5701T8,
	BCM5701A7,
	BCM5701A10,
	BCM5701A12,
	BCM5701,
	BCM5702,
	BCM5703,
	BCM5703A31,
	TC996T,
	TC996ST,
	TC996SSX,
	TC996SX,
	TC996BT,
	TC997T,
	TC997SX,
	TC1000T,
	TC940BR01,
	TC942BR01,
	NC6770,
	NC7760,
	NC7770,
	NC7780
} board_t;

/* Chip-Rev names for each device-type */
static struct {
	char *name;
} chip_rev[] = {
	{
	"BCM5700VIGIL"}, {
	"BCM5700A6"}, {
	"BCM5700T6"}, {
	"BCM5700A9"}, {
	"BCM5700T9"}, {
	"BCM5700"}, {
	"BCM5701A5"}, {
	"BCM5701T1"}, {
	"BCM5701T8"}, {
	"BCM5701A7"}, {
	"BCM5701A10"}, {
	"BCM5701A12"}, {
	"BCM5701"}, {
	"BCM5702"}, {
	"BCM5703"}, {
	"BCM5703A31"}, {
	"TC996T"}, {
	"TC996ST"}, {
	"TC996SSX"}, {
	"TC996SX"}, {
	"TC996BT"}, {
	"TC997T"}, {
	"TC997SX"}, {
	"TC1000T"}, {
	"TC940BR01"}, {
	"TC942BR01"}, {
	"NC6770"}, {
	"NC7760"}, {
	"NC7770"}, {
	"NC7780"}, {
	0}
};

/* indexed by board_t, above */
static struct {
	char *name;
} board_info[] = {
	{
	"Broadcom Vigil B5700 1000Base-T"}, {
	"Broadcom BCM5700 1000Base-T"}, {
	"Broadcom BCM5700 1000Base-SX"}, {
	"Broadcom BCM5700 1000Base-SX"}, {
	"Broadcom BCM5700 1000Base-T"}, {
	"Broadcom BCM5700"}, {
	"Broadcom BCM5701 1000Base-T"}, {
	"Broadcom BCM5701 1000Base-T"}, {
	"Broadcom BCM5701 1000Base-T"}, {
	"Broadcom BCM5701 1000Base-SX"}, {
	"Broadcom BCM5701 1000Base-T"}, {
	"Broadcom BCM5701 1000Base-T"}, {
	"Broadcom BCM5701"}, {
	"Broadcom BCM5702 1000Base-T"}, {
	"Broadcom BCM5703 1000Base-T"}, {
	"Broadcom BCM5703 1000Base-SX"}, {
	"3Com 3C996 10/100/1000 Server NIC"}, {
	"3Com 3C996 10/100/1000 Server NIC"}, {
	"3Com 3C996 Gigabit Fiber-SX Server NIC"}, {
	"3Com 3C996 Gigabit Fiber-SX Server NIC"}, {
	"3Com 3C996B Gigabit Server NIC"}, {
	"3Com 3C997 Gigabit Server NIC"}, {
	"3Com 3C997 Gigabit Fiber-SX Server NIC"}, {
	"3Com 3C1000 Gigabit NIC"}, {
	"3Com 3C940 Gigabit LOM (21X21)"}, {
	"3Com 3C942 Gigabit LOM (31X31)"}, {
	"Compaq NC6770 Gigabit Server Adapter"}, {
	"Compaq NC7760 Gigabit Server Adapter"}, {
	"Compaq NC7770 Gigabit Server Adapter"}, {
	"Compaq NC7780 Gigabit Server Adapter"}, {
0},};

/* PCI Devices which use the 570x chipset */
struct pci_device_table {
	unsigned short vendor_id, device_id;	/* Vendor/DeviceID */
	unsigned short subvendor, subdevice;	/* Subsystem ID's or PCI_ANY_ID */
	unsigned int class, class_mask;	/* (class,subclass,prog-if) triplet */
	unsigned long board_id;	/* Data private to the driver */
	int io_size, min_latency;
} bcm570xDevices[] = {
	{
	0x14e4, 0x1644, 0x1014, 0x0277, 0, 0, BCM5700VIGIL, 128, 32}, {
	0x14e4, 0x1644, 0x14e4, 0x1644, 0, 0, BCM5700A6, 128, 32}, {
	0x14e4, 0x1644, 0x14e4, 0x2, 0, 0, BCM5700T6, 128, 32}, {
	0x14e4, 0x1644, 0x14e4, 0x3, 0, 0, BCM5700A9, 128, 32}, {
	0x14e4, 0x1644, 0x14e4, 0x4, 0, 0, BCM5700T9, 128, 32}, {
	0x14e4, 0x1644, 0x1028, 0xd1, 0, 0, BCM5700, 128, 32}, {
	0x14e4, 0x1644, 0x1028, 0x0106, 0, 0, BCM5700, 128, 32}, {
	0x14e4, 0x1644, 0x1028, 0x0109, 0, 0, BCM5700, 128, 32}, {
	0x14e4, 0x1644, 0x1028, 0x010a, 0, 0, BCM5700, 128, 32}, {
	0x14e4, 0x1644, 0x10b7, 0x1000, 0, 0, TC996T, 128, 32}, {
	0x14e4, 0x1644, 0x10b7, 0x1001, 0, 0, TC996ST, 128, 32}, {
	0x14e4, 0x1644, 0x10b7, 0x1002, 0, 0, TC996SSX, 128, 32}, {
	0x14e4, 0x1644, 0x10b7, 0x1003, 0, 0, TC997T, 128, 32}, {
	0x14e4, 0x1644, 0x10b7, 0x1005, 0, 0, TC997SX, 128, 32}, {
	0x14e4, 0x1644, 0x10b7, 0x1008, 0, 0, TC942BR01, 128, 32}, {
	0x14e4, 0x1644, PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5700, 128, 32}, {
	0x14e4, 0x1645, 0x14e4, 1, 0, 0, BCM5701A5, 128, 32}, {
	0x14e4, 0x1645, 0x14e4, 5, 0, 0, BCM5701T1, 128, 32}, {
	0x14e4, 0x1645, 0x14e4, 6, 0, 0, BCM5701T8, 128, 32}, {
	0x14e4, 0x1645, 0x14e4, 7, 0, 0, BCM5701A7, 128, 32}, {
	0x14e4, 0x1645, 0x14e4, 8, 0, 0, BCM5701A10, 128, 32}, {
	0x14e4, 0x1645, 0x14e4, 0x8008, 0, 0, BCM5701A12, 128, 32}, {
	0x14e4, 0x1645, 0x0e11, 0xc1, 0, 0, NC6770, 128, 32}, {
	0x14e4, 0x1645, 0x0e11, 0x7c, 0, 0, NC7770, 128, 32}, {
	0x14e4, 0x1645, 0x0e11, 0x85, 0, 0, NC7780, 128, 32}, {
	0x14e4, 0x1645, 0x1028, 0x0121, 0, 0, BCM5701, 128, 32}, {
	0x14e4, 0x1645, 0x10b7, 0x1004, 0, 0, TC996SX, 128, 32}, {
	0x14e4, 0x1645, 0x10b7, 0x1006, 0, 0, TC996BT, 128, 32}, {
	0x14e4, 0x1645, 0x10b7, 0x1007, 0, 0, TC1000T, 128, 32}, {
	0x14e4, 0x1645, 0x10b7, 0x1008, 0, 0, TC940BR01, 128, 32}, {
	0x14e4, 0x1645, PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5701, 128, 32}, {
	0x14e4, 0x1646, 0x14e4, 0x8009, 0, 0, BCM5702, 128, 32}, {
	0x14e4, 0x1646, 0x0e11, 0xbb, 0, 0, NC7760, 128, 32}, {
	0x14e4, 0x1646, PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5702, 128, 32}, {
	0x14e4, 0x16a6, 0x14e4, 0x8009, 0, 0, BCM5702, 128, 32}, {
	0x14e4, 0x16a6, 0x0e11, 0xbb, 0, 0, NC7760, 128, 32}, {
	0x14e4, 0x16a6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5702, 128, 32}, {
	0x14e4, 0x1647, 0x14e4, 0x0009, 0, 0, BCM5703, 128, 32}, {
	0x14e4, 0x1647, 0x14e4, 0x000a, 0, 0, BCM5703A31, 128, 32}, {
	0x14e4, 0x1647, 0x14e4, 0x000b, 0, 0, BCM5703, 128, 32}, {
	0x14e4, 0x1647, 0x14e4, 0x800a, 0, 0, BCM5703, 128, 32}, {
	0x14e4, 0x1647, 0x0e11, 0x9a, 0, 0, NC7770, 128, 32}, {
	0x14e4, 0x1647, 0x0e11, 0x99, 0, 0, NC7780, 128, 32}, {
	0x14e4, 0x1647, PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5703, 128, 32}, {
	0x14e4, 0x16a7, 0x14e4, 0x0009, 0, 0, BCM5703, 128, 32}, {
	0x14e4, 0x16a7, 0x14e4, 0x000a, 0, 0, BCM5703A31, 128, 32}, {
	0x14e4, 0x16a7, 0x14e4, 0x000b, 0, 0, BCM5703, 128, 32}, {
	0x14e4, 0x16a7, 0x14e4, 0x800a, 0, 0, BCM5703, 128, 32}, {
	0x14e4, 0x16a7, 0x0e11, 0x9a, 0, 0, NC7770, 128, 32}, {
	0x14e4, 0x16a7, 0x0e11, 0x99, 0, 0, NC7780, 128, 32}, {
	0x14e4, 0x16a7, PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5703, 128, 32}
};

#define n570xDevices   (sizeof(bcm570xDevices)/sizeof(bcm570xDevices[0]))

/*
 * Allocate a packet buffer from the bcm570x packet pool.
 */
void *bcm570xPktAlloc (int u, int pksize)
{
	return malloc (pksize);
}

/*
 * Free a packet previously allocated from the bcm570x packet
 * buffer pool.
 */
void bcm570xPktFree (int u, void *p)
{
	free (p);
}

int bcm570xReplenishRxBuffers (PUM_DEVICE_BLOCK pUmDevice)
{
	PLM_PACKET pPacket;
	PUM_PACKET pUmPacket;
	void *skb;
	int queue_rx = 0;
	int ret = 0;

	while ((pUmPacket = (PUM_PACKET)
		QQ_PopHead (&pUmDevice->rx_out_of_buf_q.Container)) != 0) {

		pPacket = (PLM_PACKET) pUmPacket;

		/* reuse an old skb */
		if (pUmPacket->skbuff) {
			QQ_PushTail (&pDevice->RxPacketFreeQ.Container,
				     pPacket);
			queue_rx = 1;
			continue;
		}
		if ((skb = bcm570xPktAlloc (pUmDevice->index,
					    pPacket->u.Rx.RxBufferSize + 2)) ==
		    0) {
			QQ_PushHead (&pUmDevice->rx_out_of_buf_q.Container,
				     pPacket);
			printf ("NOTICE: Out of RX memory.\n");
			ret = 1;
			break;
		}

		pUmPacket->skbuff = skb;
		QQ_PushTail (&pDevice->RxPacketFreeQ.Container, pPacket);
		queue_rx = 1;
	}

	if (queue_rx) {
		LM_QueueRxPackets (pDevice);
	}

	return ret;
}

/*
 * Probe, Map, and Init 570x device.
 */
int eth_init (bd_t * bis)
{
	int i, rv, devFound = FALSE;
	pci_dev_t devbusfn;
	unsigned short status;

	/* Find PCI device, if it exists, configure ...  */
	for (i = 0; i < n570xDevices; i++) {
		devbusfn = pci_find_device (bcm570xDevices[i].vendor_id,
					    bcm570xDevices[i].device_id, 0);
		if (devbusfn == -1) {
			continue;	/* No device of that vendor/device ID */
		} else {

			/* Set ILINE */
			pci_write_config_byte (devbusfn,
					       PCI_INTERRUPT_LINE,
					       BCM570X_ILINE);

			/*
			 * 0x10 - 0x14 define one 64-bit MBAR.
			 * 0x14 is the higher-order address bits of the BAR.
			 */
			pci_write_config_dword (devbusfn,
						PCI_BASE_ADDRESS_1, 0);

			ioBase = BCM570X_MBAR;

			pci_write_config_dword (devbusfn,
						PCI_BASE_ADDRESS_0, ioBase);

			/*
			 * Enable PCI memory, IO, and Master -- don't
			 * reset any status bits in doing so.
			 */
			pci_read_config_word (devbusfn, PCI_COMMAND, &status);

			status |= PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER;

			pci_write_config_word (devbusfn, PCI_COMMAND, status);

			printf
			    ("\n%s: bus %d, device %d, function %d: MBAR=0x%x\n",
			     board_info[bcm570xDevices[i].board_id].name,
			     PCI_BUS (devbusfn), PCI_DEV (devbusfn),
			     PCI_FUNC (devbusfn), ioBase);

			/* Allocate once, but always clear on init */
			if (!pDevice) {
				pDevice = malloc (sizeof (UM_DEVICE_BLOCK));
				pUmDevice = (PUM_DEVICE_BLOCK) pDevice;
				memset (pDevice, 0x0, sizeof (UM_DEVICE_BLOCK));
			}

			/* Configure pci dev structure */
			pUmDevice->pdev = devbusfn;
			pUmDevice->index = 0;
			pUmDevice->tx_pkt = 0;
			pUmDevice->rx_pkt = 0;
			devFound = TRUE;
			break;
		}
	}

	if (!devFound) {
		printf
		    ("eth_init: FAILURE: no BCM570x Ethernet devices found.\n");
		return -1;
	}

	/* Setup defaults for chip */
	pDevice->TaskToOffload = LM_TASK_OFFLOAD_NONE;

	if (pDevice->ChipRevId == T3_CHIP_ID_5700_B0) {
		pDevice->TaskToOffload = LM_TASK_OFFLOAD_NONE;
	} else {

		if (rx_checksum[i]) {
			pDevice->TaskToOffload |=
			    LM_TASK_OFFLOAD_RX_TCP_CHECKSUM |
			    LM_TASK_OFFLOAD_RX_UDP_CHECKSUM;
		}

		if (tx_checksum[i]) {
			pDevice->TaskToOffload |=
			    LM_TASK_OFFLOAD_TX_TCP_CHECKSUM |
			    LM_TASK_OFFLOAD_TX_UDP_CHECKSUM;
			pDevice->NoTxPseudoHdrChksum = TRUE;
		}
	}

	/* Set Device PCI Memory base address */
	pDevice->pMappedMemBase = (PLM_UINT8) ioBase;

	/* Pull down adapter info */
	if ((rv = LM_GetAdapterInfo (pDevice)) != LM_STATUS_SUCCESS) {
		printf ("bcm570xEnd: LM_GetAdapterInfo failed: rv=%d!\n", rv);
		return -2;
	}

	/* Lock not needed */
	pUmDevice->do_global_lock = 0;

	if (T3_ASIC_REV (pUmDevice->lm_dev.ChipRevId) == T3_ASIC_REV_5700) {
		/* The 5700 chip works best without interleaved register */
		/* accesses on certain machines. */
		pUmDevice->do_global_lock = 1;
	}

	/* Setup timer delays */
	if (T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5701) {
		pDevice->UseTaggedStatus = TRUE;
		pUmDevice->timer_interval = CFG_HZ;
	} else {
		pUmDevice->timer_interval = CFG_HZ / 50;
	}

	/* Grab name .... */
	pUmDevice->name =
	    (char *)malloc (strlen (board_info[bcm570xDevices[i].board_id].name)
			    + 1);
	strcpy (pUmDevice->name, board_info[bcm570xDevices[i].board_id].name);

	memcpy (pDevice->NodeAddress, bis->bi_enetaddr, 6);
	LM_SetMacAddress (pDevice, bis->bi_enetaddr);
	/* Init queues  .. */
	QQ_InitQueue (&pUmDevice->rx_out_of_buf_q.Container,
		      MAX_RX_PACKET_DESC_COUNT);
	pUmDevice->rx_last_cnt = pUmDevice->tx_last_cnt = 0;

	/* delay for 4 seconds */
	pUmDevice->delayed_link_ind = (4 * CFG_HZ) / pUmDevice->timer_interval;

	pUmDevice->adaptive_expiry = CFG_HZ / pUmDevice->timer_interval;

	/* Sometimes we get spurious ints. after reset when link is down. */
	/* This field tells the isr to service the int. even if there is */
	/* no status block update. */
	pUmDevice->adapter_just_inited =
	    (3 * CFG_HZ) / pUmDevice->timer_interval;

	/* Initialize 570x */
	if (LM_InitializeAdapter (pDevice) != LM_STATUS_SUCCESS) {
		printf ("ERROR: Adapter initialization failed.\n");
		return ERROR;
	}

	/* Enable chip ISR */
	LM_EnableInterrupt (pDevice);

	/* Clear MC table */
	LM_MulticastClear (pDevice);

	/* Enable Multicast */
	LM_SetReceiveMask (pDevice,
			   pDevice->ReceiveMask | LM_ACCEPT_ALL_MULTICAST);

	pUmDevice->opened = 1;
	pUmDevice->tx_full = 0;
	pUmDevice->tx_pkt = 0;
	pUmDevice->rx_pkt = 0;
	printf ("eth%d: %s @0x%lx,",
		pDevice->index, pUmDevice->name, (unsigned long)ioBase);
	printf ("node addr ");
	for (i = 0; i < 6; i++) {
		printf ("%2.2x", pDevice->NodeAddress[i]);
	}
	printf ("\n");

	printf ("eth%d: ", pDevice->index);
	printf ("%s with ", chip_rev[bcm570xDevices[i].board_id].name);

	if ((pDevice->PhyId & PHY_ID_MASK) == PHY_BCM5400_PHY_ID)
		printf ("Broadcom BCM5400 Copper ");
	else if ((pDevice->PhyId & PHY_ID_MASK) == PHY_BCM5401_PHY_ID)
		printf ("Broadcom BCM5401 Copper ");
	else if ((pDevice->PhyId & PHY_ID_MASK) == PHY_BCM5411_PHY_ID)
		printf ("Broadcom BCM5411 Copper ");
	else if ((pDevice->PhyId & PHY_ID_MASK) == PHY_BCM5701_PHY_ID)
		printf ("Broadcom BCM5701 Integrated Copper ");
	else if ((pDevice->PhyId & PHY_ID_MASK) == PHY_BCM5703_PHY_ID)
		printf ("Broadcom BCM5703 Integrated Copper ");
	else if ((pDevice->PhyId & PHY_ID_MASK) == PHY_BCM8002_PHY_ID)
		printf ("Broadcom BCM8002 SerDes ");
	else if (pDevice->EnableTbi)
		printf ("Agilent HDMP-1636 SerDes ");
	else
		printf ("Unknown ");
	printf ("transceiver found\n");

	printf ("eth%d: %s, MTU: %d,",
		pDevice->index, pDevice->BusSpeedStr, 1500);

	if ((pDevice->ChipRevId != T3_CHIP_ID_5700_B0) && rx_checksum[i])
		printf ("Rx Checksum ON\n");
	else
		printf ("Rx Checksum OFF\n");
	initialized++;

	return 0;
}

/* Ethernet Interrupt service routine */
void eth_isr (void)
{
	LM_UINT32 oldtag, newtag;
	int i;

	pUmDevice->interrupt = 1;

	if (pDevice->UseTaggedStatus) {
		if ((pDevice->pStatusBlkVirt->Status & STATUS_BLOCK_UPDATED) ||
		    pUmDevice->adapter_just_inited) {
			MB_REG_WR (pDevice, Mailbox.Interrupt[0].Low, 1);
			oldtag = pDevice->pStatusBlkVirt->StatusTag;

			for (i = 0;; i++) {
				pDevice->pStatusBlkVirt->Status &=
				    ~STATUS_BLOCK_UPDATED;
				LM_ServiceInterrupts (pDevice);
				newtag = pDevice->pStatusBlkVirt->StatusTag;
				if ((newtag == oldtag) || (i > 50)) {
					MB_REG_WR (pDevice,
						   Mailbox.Interrupt[0].Low,
						   newtag << 24);
					if (pDevice->UndiFix) {
						REG_WR (pDevice, Grc.LocalCtrl,
							pDevice->
							GrcLocalCtrl | 0x2);
					}
					break;
				}
				oldtag = newtag;
			}
		}
	} else {
		while (pDevice->pStatusBlkVirt->Status & STATUS_BLOCK_UPDATED) {
			unsigned int dummy;

			pDevice->pMemView->Mailbox.Interrupt[0].Low = 1;
			pDevice->pStatusBlkVirt->Status &=
			    ~STATUS_BLOCK_UPDATED;
			LM_ServiceInterrupts (pDevice);
			pDevice->pMemView->Mailbox.Interrupt[0].Low = 0;
			dummy = pDevice->pMemView->Mailbox.Interrupt[0].Low;
		}
	}

	/* Allocate new RX buffers */
	if (QQ_GetEntryCnt (&pUmDevice->rx_out_of_buf_q.Container)) {
		bcm570xReplenishRxBuffers (pUmDevice);
	}

	/* Queue packets */
	if (QQ_GetEntryCnt (&pDevice->RxPacketFreeQ.Container)) {
		LM_QueueRxPackets (pDevice);
	}

	if (pUmDevice->tx_queued) {
		pUmDevice->tx_queued = 0;
	}

	if (pUmDevice->tx_full) {
		if (pDevice->LinkStatus != LM_STATUS_LINK_DOWN) {
			printf
			    ("NOTICE: tx was previously blocked, restarting MUX\n");
			pUmDevice->tx_full = 0;
		}
	}

	pUmDevice->interrupt = 0;

}

int eth_send (volatile void *packet, int length)
{
	int status = 0;
#if ET_DEBUG
	unsigned char *ptr = (unsigned char *)packet;
#endif
	PLM_PACKET pPacket;
	PUM_PACKET pUmPacket;

	/* Link down, return */
	while (pDevice->LinkStatus == LM_STATUS_LINK_DOWN) {
#if 0
		printf ("eth%d: link down - check cable or link partner.\n",
			pUmDevice->index);
#endif
		eth_isr ();

		/* Wait to see link for one-half a second before sending ... */
		udelay (1500000);

	}

	/* Clear sent flag */
	pUmDevice->tx_pkt = 0;

	/* Previously blocked */
	if (pUmDevice->tx_full) {
		printf ("eth%d: tx blocked.\n", pUmDevice->index);
		return 0;
	}

	pPacket = (PLM_PACKET)
	    QQ_PopHead (&pDevice->TxPacketFreeQ.Container);

	if (pPacket == 0) {
		pUmDevice->tx_full = 1;
		printf ("bcm570xEndSend: TX full!\n");
		return 0;
	}

	if (pDevice->SendBdLeft.counter == 0) {
		pUmDevice->tx_full = 1;
		printf ("bcm570xEndSend: no more TX descriptors!\n");
		QQ_PushHead (&pDevice->TxPacketFreeQ.Container, pPacket);
		return 0;
	}

	if (length <= 0) {
		printf ("eth: bad packet size: %d\n", length);
		goto out;
	}

	/* Get packet buffers and fragment list */
	pUmPacket = (PUM_PACKET) pPacket;
	/* Single DMA Descriptor transmit.
	 * Fragments may be provided, but one DMA descriptor max is
	 * used to send the packet.
	 */
	if (MM_CoalesceTxBuffer (pDevice, pPacket) != LM_STATUS_SUCCESS) {
		if (pUmPacket->skbuff == NULL) {
			/* Packet was discarded */
			printf ("TX: failed (1)\n");
			status = 1;
		} else {
			printf ("TX: failed (2)\n");
			status = 2;
		}
		QQ_PushHead (&pDevice->TxPacketFreeQ.Container, pPacket);
		return status;
	}

	/* Copy packet to DMA buffer */
	memset (pUmPacket->skbuff, 0x0, MAX_PACKET_SIZE);
	memcpy ((void *)pUmPacket->skbuff, (void *)packet, length);
	pPacket->PacketSize = length;
	pPacket->Flags |= SND_BD_FLAG_END | SND_BD_FLAG_COAL_NOW;
	pPacket->u.Tx.FragCount = 1;
	/* We've already provided a frame ready for transmission */
	pPacket->Flags &= ~SND_BD_FLAG_TCP_UDP_CKSUM;

	if (LM_SendPacket (pDevice, pPacket) == LM_STATUS_FAILURE) {
		/*
		 *  A lower level send failure will push the packet descriptor back
		 *  in the free queue, so just deal with the VxWorks clusters.
		 */
		if (pUmPacket->skbuff == NULL) {
			printf ("TX failed (1)!\n");
			/* Packet was discarded */
			status = 3;
		} else {
			/* A resource problem ... */
			printf ("TX failed (2)!\n");
			status = 4;
		}

		if (QQ_GetEntryCnt (&pDevice->TxPacketFreeQ.Container) == 0) {
			printf ("TX: emptyQ!\n");
			pUmDevice->tx_full = 1;
		}
	}

	while (pUmDevice->tx_pkt == 0) {
		/* Service TX */
		eth_isr ();
	}
#if ET_DEBUG
	printf ("eth_send: 0x%x, %d bytes\n"
		"[%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x] ...\n",
		(int)pPacket, length,
		ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5],
		ptr[6], ptr[7], ptr[8], ptr[9], ptr[10], ptr[11], ptr[12],
		ptr[13], ptr[14], ptr[15]);
#endif
	pUmDevice->tx_pkt = 0;
	QQ_PushHead (&pDevice->TxPacketFreeQ.Container, pPacket);

	/* Done with send */
      out:
	return status;
}

/* Ethernet receive */
int eth_rx (void)
{
	PLM_PACKET pPacket = NULL;
	PUM_PACKET pUmPacket = NULL;
	void *skb;
	int size = 0;

	while (TRUE) {

	      bcm570x_service_isr:
		/* Pull down packet if it is there */
		eth_isr ();

		/* Indicate RX packets called */
		if (pUmDevice->rx_pkt) {
			/* printf("eth_rx: got a packet...\n"); */
			pUmDevice->rx_pkt = 0;
		} else {
			/* printf("eth_rx: waiting for packet...\n"); */
			goto bcm570x_service_isr;
		}

		pPacket = (PLM_PACKET)
		    QQ_PopHead (&pDevice->RxPacketReceivedQ.Container);

		if (pPacket == 0) {
			printf ("eth_rx: empty packet!\n");
			goto bcm570x_service_isr;
		}

		pUmPacket = (PUM_PACKET) pPacket;
#if ET_DEBUG
		printf ("eth_rx: packet @0x%x\n", (int)pPacket);
#endif
		/* If the packet generated an error, reuse buffer */
		if ((pPacket->PacketStatus != LM_STATUS_SUCCESS) ||
		    ((size = pPacket->PacketSize) > pDevice->RxMtu)) {

			/* reuse skb */
			QQ_PushTail (&pDevice->RxPacketFreeQ.Container,
				     pPacket);
			printf ("eth_rx: error in packet dma!\n");
			goto bcm570x_service_isr;
		}

		/* Set size and address */
		skb = pUmPacket->skbuff;
		size = pPacket->PacketSize;

		/* Pass the packet up to the protocol
		 * layers.
		 */
		NetReceive (skb, size);

		/* Free packet buffer */
		bcm570xPktFree (pUmDevice->index, skb);
		pUmPacket->skbuff = NULL;

		/* Reuse SKB */
		QQ_PushTail (&pDevice->RxPacketFreeQ.Container, pPacket);

		return 0;	/* Got a packet, bail ... */
	}
	return size;
}

/* Shut down device */
void eth_halt (void)
{
	int i;
	if (initialized)
		if (pDevice && pUmDevice && pUmDevice->opened) {
			printf ("\neth%d:%s,", pUmDevice->index,
				pUmDevice->name);
			printf ("HALT,");
			/* stop device */
			LM_Halt (pDevice);
			printf ("POWER DOWN,");
			LM_SetPowerState (pDevice, LM_POWER_STATE_D3);

			/* Free the memory allocated by the device in tigon3 */
			for (i = 0; i < pUmDevice->mem_list_num; i++) {
				if (pUmDevice->mem_list[i]) {
					/* sanity check */
					if (pUmDevice->dma_list[i]) {	/* cache-safe memory */
						free (pUmDevice->mem_list[i]);
					} else {
						free (pUmDevice->mem_list[i]);	/* normal memory   */
					}
				}
			}
			pUmDevice->opened = 0;
			free (pDevice);
			pDevice = NULL;
			pUmDevice = NULL;
			initialized = 0;
			printf ("done - offline.\n");
		}
}

/*
 *
 * Middle Module: Interface between the HW driver (tigon3 modules) and
 * the native (SENS) driver.  These routines implement the system
 * interface for tigon3 on VxWorks.
 */

/* Middle module dependency - size of a packet descriptor */
int MM_Packet_Desc_Size = sizeof (UM_PACKET);

LM_STATUS
MM_ReadConfig32 (PLM_DEVICE_BLOCK pDevice,
		 LM_UINT32 Offset, LM_UINT32 * pValue32)
{
	UM_DEVICE_BLOCK *pUmDevice;
	pUmDevice = (UM_DEVICE_BLOCK *) pDevice;
	pci_read_config_dword (pUmDevice->pdev, Offset, (u32 *) pValue32);
	return LM_STATUS_SUCCESS;
}

LM_STATUS
MM_WriteConfig32 (PLM_DEVICE_BLOCK pDevice, LM_UINT32 Offset, LM_UINT32 Value32)
{
	UM_DEVICE_BLOCK *pUmDevice;
	pUmDevice = (UM_DEVICE_BLOCK *) pDevice;
	pci_write_config_dword (pUmDevice->pdev, Offset, Value32);
	return LM_STATUS_SUCCESS;
}

LM_STATUS
MM_ReadConfig16 (PLM_DEVICE_BLOCK pDevice,
		 LM_UINT32 Offset, LM_UINT16 * pValue16)
{
	UM_DEVICE_BLOCK *pUmDevice;
	pUmDevice = (UM_DEVICE_BLOCK *) pDevice;
	pci_read_config_word (pUmDevice->pdev, Offset, (u16 *) pValue16);
	return LM_STATUS_SUCCESS;
}

LM_STATUS
MM_WriteConfig16 (PLM_DEVICE_BLOCK pDevice, LM_UINT32 Offset, LM_UINT16 Value16)
{
	UM_DEVICE_BLOCK *pUmDevice;
	pUmDevice = (UM_DEVICE_BLOCK *) pDevice;
	pci_write_config_word (pUmDevice->pdev, Offset, Value16);
	return LM_STATUS_SUCCESS;
}

LM_STATUS
MM_AllocateSharedMemory (PLM_DEVICE_BLOCK pDevice, LM_UINT32 BlockSize,
			 PLM_VOID * pMemoryBlockVirt,
			 PLM_PHYSICAL_ADDRESS pMemoryBlockPhy, LM_BOOL Cached)
{
	PLM_VOID pvirt;
	PUM_DEVICE_BLOCK pUmDevice = (PUM_DEVICE_BLOCK) pDevice;
	dma_addr_t mapping;

	pvirt = malloc (BlockSize);
	mapping = (dma_addr_t) (pvirt);
	if (!pvirt)
		return LM_STATUS_FAILURE;

	pUmDevice->mem_list[pUmDevice->mem_list_num] = pvirt;
	pUmDevice->dma_list[pUmDevice->mem_list_num] = mapping;
	pUmDevice->mem_size_list[pUmDevice->mem_list_num++] = BlockSize;
	memset (pvirt, 0, BlockSize);

	*pMemoryBlockVirt = (PLM_VOID) pvirt;
	MM_SetAddr (pMemoryBlockPhy, (dma_addr_t) mapping);

	return LM_STATUS_SUCCESS;
}

LM_STATUS
MM_AllocateMemory (PLM_DEVICE_BLOCK pDevice, LM_UINT32 BlockSize,
		   PLM_VOID * pMemoryBlockVirt)
{
	PLM_VOID pvirt;
	PUM_DEVICE_BLOCK pUmDevice = (PUM_DEVICE_BLOCK) pDevice;

	pvirt = malloc (BlockSize);

	if (!pvirt)
		return LM_STATUS_FAILURE;

	pUmDevice->mem_list[pUmDevice->mem_list_num] = pvirt;
	pUmDevice->dma_list[pUmDevice->mem_list_num] = 0;
	pUmDevice->mem_size_list[pUmDevice->mem_list_num++] = BlockSize;
	memset (pvirt, 0, BlockSize);
	*pMemoryBlockVirt = pvirt;

	return LM_STATUS_SUCCESS;
}

LM_STATUS MM_MapMemBase (PLM_DEVICE_BLOCK pDevice)
{
	printf ("BCM570x PCI Memory base address @0x%x\n",
		(unsigned int)pDevice->pMappedMemBase);
	return LM_STATUS_SUCCESS;
}

LM_STATUS MM_InitializeUmPackets (PLM_DEVICE_BLOCK pDevice)
{
	int i;
	void *skb;
	PUM_DEVICE_BLOCK pUmDevice = (PUM_DEVICE_BLOCK) pDevice;
	PUM_PACKET pUmPacket = NULL;
	PLM_PACKET pPacket = NULL;

	for (i = 0; i < pDevice->RxPacketDescCnt; i++) {
		pPacket = QQ_PopHead (&pDevice->RxPacketFreeQ.Container);
		pUmPacket = (PUM_PACKET) pPacket;

		if (pPacket == 0) {
			printf ("MM_InitializeUmPackets: Bad RxPacketFreeQ\n");
		}

		skb = bcm570xPktAlloc (pUmDevice->index,
				       pPacket->u.Rx.RxBufferSize + 2);

		if (skb == 0) {
			pUmPacket->skbuff = 0;
			QQ_PushTail (&pUmDevice->rx_out_of_buf_q.Container,
				     pPacket);
			printf ("MM_InitializeUmPackets: out of buffer.\n");
			continue;
		}

		pUmPacket->skbuff = skb;
		QQ_PushTail (&pDevice->RxPacketFreeQ.Container, pPacket);
	}

	pUmDevice->rx_low_buf_thresh = pDevice->RxPacketDescCnt / 8;

	return LM_STATUS_SUCCESS;
}

LM_STATUS MM_GetConfig (PLM_DEVICE_BLOCK pDevice)
{
	PUM_DEVICE_BLOCK pUmDevice = (PUM_DEVICE_BLOCK) pDevice;
	int index = pDevice->index;

	if (auto_speed[index] == 0)
		pDevice->DisableAutoNeg = TRUE;
	else
		pDevice->DisableAutoNeg = FALSE;

	if (line_speed[index] == 0) {
		pDevice->RequestedMediaType = LM_REQUESTED_MEDIA_TYPE_AUTO;
		pDevice->DisableAutoNeg = FALSE;
	} else {
		if (line_speed[index] == 1000) {
			if (pDevice->EnableTbi) {
				pDevice->RequestedMediaType =
				    LM_REQUESTED_MEDIA_TYPE_FIBER_1000MBPS_FULL_DUPLEX;
			} else if (full_duplex[index]) {
				pDevice->RequestedMediaType =
				    LM_REQUESTED_MEDIA_TYPE_UTP_1000MBPS_FULL_DUPLEX;
			} else {
				pDevice->RequestedMediaType =
				    LM_REQUESTED_MEDIA_TYPE_UTP_1000MBPS;
			}
			if (!pDevice->EnableTbi)
				pDevice->DisableAutoNeg = FALSE;
		} else if (line_speed[index] == 100) {
			if (full_duplex[index]) {
				pDevice->RequestedMediaType =
				    LM_REQUESTED_MEDIA_TYPE_UTP_100MBPS_FULL_DUPLEX;
			} else {
				pDevice->RequestedMediaType =
				    LM_REQUESTED_MEDIA_TYPE_UTP_100MBPS;
			}
		} else if (line_speed[index] == 10) {
			if (full_duplex[index]) {
				pDevice->RequestedMediaType =
				    LM_REQUESTED_MEDIA_TYPE_UTP_10MBPS_FULL_DUPLEX;
			} else {
				pDevice->RequestedMediaType =
				    LM_REQUESTED_MEDIA_TYPE_UTP_10MBPS;
			}
		} else {
			pDevice->RequestedMediaType =
			    LM_REQUESTED_MEDIA_TYPE_AUTO;
			pDevice->DisableAutoNeg = FALSE;
		}

	}
	pDevice->FlowControlCap = 0;
	if (rx_flow_control[index] != 0) {
		pDevice->FlowControlCap |= LM_FLOW_CONTROL_RECEIVE_PAUSE;
	}
	if (tx_flow_control[index] != 0) {
		pDevice->FlowControlCap |= LM_FLOW_CONTROL_TRANSMIT_PAUSE;
	}
	if ((auto_flow_control[index] != 0) &&
	    (pDevice->DisableAutoNeg == FALSE)) {

		pDevice->FlowControlCap |= LM_FLOW_CONTROL_AUTO_PAUSE;
		if ((tx_flow_control[index] == 0) &&
		    (rx_flow_control[index] == 0)) {
			pDevice->FlowControlCap |=
			    LM_FLOW_CONTROL_TRANSMIT_PAUSE |
			    LM_FLOW_CONTROL_RECEIVE_PAUSE;
		}
	}

	/* Default MTU for now */
	pUmDevice->mtu = 1500;

#if T3_JUMBO_RCV_RCB_ENTRY_COUNT
	if (pUmDevice->mtu > 1500) {
		pDevice->RxMtu = pUmDevice->mtu;
		pDevice->RxJumboDescCnt = DEFAULT_JUMBO_RCV_DESC_COUNT;
	} else {
		pDevice->RxJumboDescCnt = 0;
	}
	pDevice->RxJumboDescCnt = rx_jumbo_desc_cnt[index];
#else
	pDevice->RxMtu = pUmDevice->mtu;
#endif

	if (T3_ASIC_REV (pDevice->ChipRevId) == T3_ASIC_REV_5701) {
		pDevice->UseTaggedStatus = TRUE;
		pUmDevice->timer_interval = CFG_HZ;
	} else {
		pUmDevice->timer_interval = CFG_HZ / 50;
	}

	pDevice->TxPacketDescCnt = tx_pkt_desc_cnt[index];
	pDevice->RxStdDescCnt = rx_std_desc_cnt[index];
	/* Note:  adaptive coalescence really isn't adaptive in this driver */
	pUmDevice->rx_adaptive_coalesce = rx_adaptive_coalesce[index];
	if (!pUmDevice->rx_adaptive_coalesce) {
		pDevice->RxCoalescingTicks = rx_coalesce_ticks[index];
		if (pDevice->RxCoalescingTicks > MAX_RX_COALESCING_TICKS)
			pDevice->RxCoalescingTicks = MAX_RX_COALESCING_TICKS;
		pUmDevice->rx_curr_coalesce_ticks = pDevice->RxCoalescingTicks;

		pDevice->RxMaxCoalescedFrames = rx_max_coalesce_frames[index];
		if (pDevice->RxMaxCoalescedFrames > MAX_RX_MAX_COALESCED_FRAMES)
			pDevice->RxMaxCoalescedFrames =
			    MAX_RX_MAX_COALESCED_FRAMES;
		pUmDevice->rx_curr_coalesce_frames =
		    pDevice->RxMaxCoalescedFrames;
		pDevice->StatsCoalescingTicks = stats_coalesce_ticks[index];
		if (pDevice->StatsCoalescingTicks > MAX_STATS_COALESCING_TICKS)
			pDevice->StatsCoalescingTicks =
			    MAX_STATS_COALESCING_TICKS;
	} else {
		pUmDevice->rx_curr_coalesce_frames =
		    DEFAULT_RX_MAX_COALESCED_FRAMES;
		pUmDevice->rx_curr_coalesce_ticks = DEFAULT_RX_COALESCING_TICKS;
	}
	pDevice->TxCoalescingTicks = tx_coalesce_ticks[index];
	if (pDevice->TxCoalescingTicks > MAX_TX_COALESCING_TICKS)
		pDevice->TxCoalescingTicks = MAX_TX_COALESCING_TICKS;
	pDevice->TxMaxCoalescedFrames = tx_max_coalesce_frames[index];
	if (pDevice->TxMaxCoalescedFrames > MAX_TX_MAX_COALESCED_FRAMES)
		pDevice->TxMaxCoalescedFrames = MAX_TX_MAX_COALESCED_FRAMES;

	if (enable_wol[index]) {
		pDevice->WakeUpModeCap = LM_WAKE_UP_MODE_MAGIC_PACKET;
		pDevice->WakeUpMode = LM_WAKE_UP_MODE_MAGIC_PACKET;
	}
	pDevice->NicSendBd = TRUE;

	/* Don't update status blocks during interrupt */
	pDevice->RxCoalescingTicksDuringInt = 0;
	pDevice->TxCoalescingTicksDuringInt = 0;

	return LM_STATUS_SUCCESS;

}

LM_STATUS MM_StartTxDma (PLM_DEVICE_BLOCK pDevice, PLM_PACKET pPacket)
{
	PUM_DEVICE_BLOCK pUmDevice = (PUM_DEVICE_BLOCK) pDevice;
	printf ("Start TX DMA: dev=%d packet @0x%x\n",
		(int)pUmDevice->index, (unsigned int)pPacket);

	return LM_STATUS_SUCCESS;
}

LM_STATUS MM_CompleteTxDma (PLM_DEVICE_BLOCK pDevice, PLM_PACKET pPacket)
{
	PUM_DEVICE_BLOCK pUmDevice = (PUM_DEVICE_BLOCK) pDevice;
	printf ("Complete TX DMA: dev=%d packet @0x%x\n",
		(int)pUmDevice->index, (unsigned int)pPacket);
	return LM_STATUS_SUCCESS;
}

LM_STATUS MM_IndicateStatus (PLM_DEVICE_BLOCK pDevice, LM_STATUS Status)
{
	char buf[128];
	char lcd[4];
	PUM_DEVICE_BLOCK pUmDevice = (PUM_DEVICE_BLOCK) pDevice;
	LM_FLOW_CONTROL flow_control;

	pUmDevice->delayed_link_ind = 0;
	memset (lcd, 0x0, 4);

	if (Status == LM_STATUS_LINK_DOWN) {
		sprintf (buf, "eth%d: %s: NIC Link is down\n",
			 pUmDevice->index, pUmDevice->name);
		lcd[0] = 'L';
		lcd[1] = 'N';
		lcd[2] = 'K';
		lcd[3] = '?';
	} else if (Status == LM_STATUS_LINK_ACTIVE) {
		sprintf (buf, "eth%d:%s: ", pUmDevice->index, pUmDevice->name);

		if (pDevice->LineSpeed == LM_LINE_SPEED_1000MBPS) {
			strcat (buf, "1000 Mbps ");
			lcd[0] = '1';
			lcd[1] = 'G';
			lcd[2] = 'B';
		} else if (pDevice->LineSpeed == LM_LINE_SPEED_100MBPS) {
			strcat (buf, "100 Mbps ");
			lcd[0] = '1';
			lcd[1] = '0';
			lcd[2] = '0';
		} else if (pDevice->LineSpeed == LM_LINE_SPEED_10MBPS) {
			strcat (buf, "10 Mbps ");
			lcd[0] = '1';
			lcd[1] = '0';
			lcd[2] = ' ';
		}
		if (pDevice->DuplexMode == LM_DUPLEX_MODE_FULL) {
			strcat (buf, "full duplex");
			lcd[3] = 'F';
		} else {
			strcat (buf, "half duplex");
			lcd[3] = 'H';
		}
		strcat (buf, " link up");

		flow_control = pDevice->FlowControl &
		    (LM_FLOW_CONTROL_RECEIVE_PAUSE |
		     LM_FLOW_CONTROL_TRANSMIT_PAUSE);

		if (flow_control) {
			if (flow_control & LM_FLOW_CONTROL_RECEIVE_PAUSE) {
				strcat (buf, ", receive ");
				if (flow_control &
				    LM_FLOW_CONTROL_TRANSMIT_PAUSE)
					strcat (buf, " & transmit ");
			} else {
				strcat (buf, ", transmit ");
			}
			strcat (buf, "flow control ON");
		} else {
			strcat (buf, ", flow control OFF");
		}
		strcat (buf, "\n");
		printf ("%s", buf);
	}
#if 0
	sysLedDsply (lcd[0], lcd[1], lcd[2], lcd[3]);
#endif
	return LM_STATUS_SUCCESS;
}

LM_STATUS MM_FreeRxBuffer (PLM_DEVICE_BLOCK pDevice, PLM_PACKET pPacket)
{

	PUM_DEVICE_BLOCK pUmDevice = (PUM_DEVICE_BLOCK) pDevice;
	PUM_PACKET pUmPacket;
	void *skb;

	pUmPacket = (PUM_PACKET) pPacket;

	if ((skb = pUmPacket->skbuff))
		bcm570xPktFree (pUmDevice->index, skb);

	pUmPacket->skbuff = 0;

	return LM_STATUS_SUCCESS;
}

unsigned long MM_AnGetCurrentTime_us (PAN_STATE_INFO pAnInfo)
{
	return get_timer (0);
}

/*
 *   Transform an MBUF chain into a single MBUF.
 *   This routine will fail if the amount of data in the
 *   chain overflows a transmit buffer.  In that case,
 *   the incoming MBUF chain will be freed.  This routine can
 *   also fail by not being able to allocate a new MBUF (including
 *   cluster and mbuf headers).  In that case the failure is
 *   non-fatal.  The incoming cluster chain is not freed, giving
 *   the caller the choice of whether to try a retransmit later.
 */
LM_STATUS MM_CoalesceTxBuffer (PLM_DEVICE_BLOCK pDevice, PLM_PACKET pPacket)
{
	PUM_PACKET pUmPacket = (PUM_PACKET) pPacket;
	PUM_DEVICE_BLOCK pUmDevice = (PUM_DEVICE_BLOCK) pDevice;
	void *skbnew;
	int len = 0;

	if (len == 0)
		return (LM_STATUS_SUCCESS);

	if (len > MAX_PACKET_SIZE) {
		printf ("eth%d: xmit frame discarded, too big!, size = %d\n",
			pUmDevice->index, len);
		return (LM_STATUS_FAILURE);
	}

	skbnew = bcm570xPktAlloc (pUmDevice->index, MAX_PACKET_SIZE);

	if (skbnew == NULL) {
		pUmDevice->tx_full = 1;
		printf ("eth%d: out of transmit buffers", pUmDevice->index);
		return (LM_STATUS_FAILURE);
	}

	/* New packet values */
	pUmPacket->skbuff = skbnew;
	pUmPacket->lm_packet.u.Tx.FragCount = 1;

	return (LM_STATUS_SUCCESS);
}

LM_STATUS MM_IndicateRxPackets (PLM_DEVICE_BLOCK pDevice)
{
	PUM_DEVICE_BLOCK pUmDevice = (PUM_DEVICE_BLOCK) pDevice;
	pUmDevice->rx_pkt = 1;
	return LM_STATUS_SUCCESS;
}

LM_STATUS MM_IndicateTxPackets (PLM_DEVICE_BLOCK pDevice)
{
	PUM_DEVICE_BLOCK pUmDevice = (PUM_DEVICE_BLOCK) pDevice;
	PLM_PACKET pPacket;
	PUM_PACKET pUmPacket;
	void *skb;
	while (TRUE) {

		pPacket = (PLM_PACKET)
		    QQ_PopHead (&pDevice->TxPacketXmittedQ.Container);

		if (pPacket == 0)
			break;

		pUmPacket = (PUM_PACKET) pPacket;
		skb = (void *)pUmPacket->skbuff;

		/*
		 * Free MBLK if we transmitted a fragmented packet or a
		 * non-fragmented packet straight from the VxWorks
		 * buffer pool. If packet was copied to a local transmit
		 * buffer, then there's no MBUF to free, just free
		 * the transmit buffer back to the cluster pool.
		 */

		if (skb)
			bcm570xPktFree (pUmDevice->index, skb);

		pUmPacket->skbuff = 0;
		QQ_PushTail (&pDevice->TxPacketFreeQ.Container, pPacket);
		pUmDevice->tx_pkt = 1;
	}
	if (pUmDevice->tx_full) {
		if (QQ_GetEntryCnt (&pDevice->TxPacketFreeQ.Container) >=
		    (QQ_GetSize (&pDevice->TxPacketFreeQ.Container) >> 1))
			pUmDevice->tx_full = 0;
	}
	return LM_STATUS_SUCCESS;
}

/*
 *  Scan an MBUF chain until we reach fragment number "frag"
 *  Return its length and physical address.
 */
void MM_MapTxDma
    (PLM_DEVICE_BLOCK pDevice,
     struct _LM_PACKET *pPacket,
     T3_64BIT_HOST_ADDR * paddr, LM_UINT32 * len, int frag) {
	PUM_PACKET pUmPacket = (PUM_PACKET) pPacket;
	*len = pPacket->PacketSize;
	MM_SetT3Addr (paddr, (dma_addr_t) pUmPacket->skbuff);
}

/*
 *  Convert an mbuf address, a CPU local virtual address,
 *  to a physical address as seen from a PCI device.  Store the
 *  result at paddr.
 */
void MM_MapRxDma (PLM_DEVICE_BLOCK pDevice,
		  struct _LM_PACKET *pPacket, T3_64BIT_HOST_ADDR * paddr)
{
	PUM_PACKET pUmPacket = (PUM_PACKET) pPacket;
	MM_SetT3Addr (paddr, (dma_addr_t) pUmPacket->skbuff);
}

void MM_SetAddr (LM_PHYSICAL_ADDRESS * paddr, dma_addr_t addr)
{
#if (BITS_PER_LONG == 64)
	paddr->High = ((unsigned long)addr) >> 32;
	paddr->Low = ((unsigned long)addr) & 0xffffffff;
#else
	paddr->High = 0;
	paddr->Low = (unsigned long)addr;
#endif
}

void MM_SetT3Addr (T3_64BIT_HOST_ADDR * paddr, dma_addr_t addr)
{
	unsigned long baddr = (unsigned long)addr;
#if (BITS_PER_LONG == 64)
	set_64bit_addr (paddr, baddr & 0xffffffff, baddr >> 32);
#else
	set_64bit_addr (paddr, baddr, 0);
#endif
}

/*
 * This combination of `inline' and `extern' has almost the effect of a
 * macro.  The way to use it is to put a function definition in a header
 * file with these keywords, and put another copy of the definition
 * (lacking `inline' and `extern') in a library file.  The definition in
 * the header file will cause most calls to the function to be inlined.
 * If any uses of the function remain, they will refer to the single copy
 * in the library.
 */
void atomic_set (atomic_t * entry, int val)
{
	entry->counter = val;
}

int atomic_read (atomic_t * entry)
{
	return entry->counter;
}

void atomic_inc (atomic_t * entry)
{
	if (entry)
		entry->counter++;
}

void atomic_dec (atomic_t * entry)
{
	if (entry)
		entry->counter--;
}

void atomic_sub (int a, atomic_t * entry)
{
	if (entry)
		entry->counter -= a;
}

void atomic_add (int a, atomic_t * entry)
{
	if (entry)
		entry->counter += a;
}

/******************************************************************************/
/* Description:                                                               */
/*                                                                            */
/* Return:                                                                    */
/******************************************************************************/
void QQ_InitQueue (PQQ_CONTAINER pQueue, unsigned int QueueSize)
{
	pQueue->Head = 0;
	pQueue->Tail = 0;
	pQueue->Size = QueueSize + 1;
	atomic_set (&pQueue->EntryCnt, 0);
}				/* QQ_InitQueue */

/******************************************************************************/
/* Description:                                                               */
/*                                                                            */
/* Return:                                                                    */
/******************************************************************************/
char QQ_Full (PQQ_CONTAINER pQueue)
{
	unsigned int NewHead;

	NewHead = (pQueue->Head + 1) % pQueue->Size;

	return (NewHead == pQueue->Tail);
}				/* QQ_Full */

/******************************************************************************/
/* Description:                                                               */
/*                                                                            */
/* Return:                                                                    */
/******************************************************************************/
char QQ_Empty (PQQ_CONTAINER pQueue)
{
	return (pQueue->Head == pQueue->Tail);
}				/* QQ_Empty */

/******************************************************************************/
/* Description:                                                               */
/*                                                                            */
/* Return:                                                                    */
/******************************************************************************/
unsigned int QQ_GetSize (PQQ_CONTAINER pQueue)
{
	return pQueue->Size;
}				/* QQ_GetSize */

/******************************************************************************/
/* Description:                                                               */
/*                                                                            */
/* Return:                                                                    */
/******************************************************************************/
unsigned int QQ_GetEntryCnt (PQQ_CONTAINER pQueue)
{
	return atomic_read (&pQueue->EntryCnt);
}				/* QQ_GetEntryCnt */

/******************************************************************************/
/* Description:                                                               */
/*                                                                            */
/* Return:                                                                    */
/*    TRUE entry was added successfully.                                      */
/*    FALSE queue is full.                                                    */
/******************************************************************************/
char QQ_PushHead (PQQ_CONTAINER pQueue, PQQ_ENTRY pEntry)
{
	unsigned int Head;

	Head = (pQueue->Head + 1) % pQueue->Size;

#if !defined(QQ_NO_OVERFLOW_CHECK)
	if (Head == pQueue->Tail) {
		return 0;
	}			/* if */
#endif				/* QQ_NO_OVERFLOW_CHECK */

	pQueue->Array[pQueue->Head] = pEntry;
	wmb ();
	pQueue->Head = Head;
	atomic_inc (&pQueue->EntryCnt);

	return -1;
}				/* QQ_PushHead */

/******************************************************************************/
/* Description:                                                               */
/*                                                                            */
/* Return:                                                                    */
/*    TRUE entry was added successfully.                                      */
/*    FALSE queue is full.                                                    */
/******************************************************************************/
char QQ_PushTail (PQQ_CONTAINER pQueue, PQQ_ENTRY pEntry)
{
	unsigned int Tail;

	Tail = pQueue->Tail;
	if (Tail == 0) {
		Tail = pQueue->Size;
	}			/* if */
	Tail--;

#if !defined(QQ_NO_OVERFLOW_CHECK)
	if (Tail == pQueue->Head) {
		return 0;
	}			/* if */
#endif				/* QQ_NO_OVERFLOW_CHECK */

	pQueue->Array[Tail] = pEntry;
	wmb ();
	pQueue->Tail = Tail;
	atomic_inc (&pQueue->EntryCnt);

	return -1;
}				/* QQ_PushTail */

/******************************************************************************/
/* Description:                                                               */
/*                                                                            */
/* Return:                                                                    */
/******************************************************************************/
PQQ_ENTRY QQ_PopHead (PQQ_CONTAINER pQueue)
{
	unsigned int Head;
	PQQ_ENTRY Entry;

	Head = pQueue->Head;

#if !defined(QQ_NO_UNDERFLOW_CHECK)
	if (Head == pQueue->Tail) {
		return (PQQ_ENTRY) 0;
	}			/* if */
#endif				/* QQ_NO_UNDERFLOW_CHECK */

	if (Head == 0) {
		Head = pQueue->Size;
	}			/* if */
	Head--;

	Entry = pQueue->Array[Head];
	membar ();

	pQueue->Head = Head;
	atomic_dec (&pQueue->EntryCnt);

	return Entry;
}				/* QQ_PopHead */

/******************************************************************************/
/* Description:                                                               */
/*                                                                            */
/* Return:                                                                    */
/******************************************************************************/
PQQ_ENTRY QQ_PopTail (PQQ_CONTAINER pQueue)
{
	unsigned int Tail;
	PQQ_ENTRY Entry;

	Tail = pQueue->Tail;

#if !defined(QQ_NO_UNDERFLOW_CHECK)
	if (Tail == pQueue->Head) {
		return (PQQ_ENTRY) 0;
	}			/* if */
#endif				/* QQ_NO_UNDERFLOW_CHECK */

	Entry = pQueue->Array[Tail];
	membar ();
	pQueue->Tail = (Tail + 1) % pQueue->Size;
	atomic_dec (&pQueue->EntryCnt);

	return Entry;
}				/* QQ_PopTail */

/******************************************************************************/
/* Description:                                                               */
/*                                                                            */
/* Return:                                                                    */
/******************************************************************************/
PQQ_ENTRY QQ_GetHead (PQQ_CONTAINER pQueue, unsigned int Idx)
{
	if (Idx >= atomic_read (&pQueue->EntryCnt)) {
		return (PQQ_ENTRY) 0;
	}

	if (pQueue->Head > Idx) {
		Idx = pQueue->Head - Idx;
	} else {
		Idx = pQueue->Size - (Idx - pQueue->Head);
	}
	Idx--;

	return pQueue->Array[Idx];
}

/******************************************************************************/
/* Description:                                                               */
/*                                                                            */
/* Return:                                                                    */
/******************************************************************************/
PQQ_ENTRY QQ_GetTail (PQQ_CONTAINER pQueue, unsigned int Idx)
{
	if (Idx >= atomic_read (&pQueue->EntryCnt)) {
		return (PQQ_ENTRY) 0;
	}

	Idx += pQueue->Tail;
	if (Idx >= pQueue->Size) {
		Idx = Idx - pQueue->Size;
	}

	return pQueue->Array[Idx];
}
