atl2: convert to KNF
Change-Id: Ie4b979aab3127a91a12b8086326da0eb1f9a860b
This commit is contained in:
parent
d1db724f47
commit
1539606d98
2 changed files with 263 additions and 282 deletions
|
@ -1,6 +1,6 @@
|
||||||
/* Attansic/Atheros L2 FastEthernet driver, by D.C. van Moolenbroek */
|
/* Attansic/Atheros L2 FastEthernet driver, by D.C. van Moolenbroek */
|
||||||
|
/*
|
||||||
/* No documentation is available for this card. The FreeBSD driver is based
|
* No documentation is available for this card. The FreeBSD driver is based
|
||||||
* heavily on the official Linux driver; this driver is based heavily on both.
|
* heavily on the official Linux driver; this driver is based heavily on both.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -27,9 +27,9 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
u32_t hdr;
|
uint32_t hdr;
|
||||||
u32_t vtag;
|
uint32_t vtag;
|
||||||
u8_t data[ATL2_RXD_SIZE - sizeof(u32_t) * 2];
|
uint8_t data[ATL2_RXD_SIZE - sizeof(uint32_t) * 2];
|
||||||
} rxd_t;
|
} rxd_t;
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
|
@ -37,13 +37,13 @@ static struct {
|
||||||
int irq; /* IRQ number */
|
int irq; /* IRQ number */
|
||||||
int hook_id; /* IRQ hook ID */
|
int hook_id; /* IRQ hook ID */
|
||||||
int mode; /* datalink mode */
|
int mode; /* datalink mode */
|
||||||
volatile u8_t *base; /* base address of memory-mapped registers */
|
volatile uint8_t *base; /* base address of memory-mapped registers */
|
||||||
u32_t size; /* size of memory-mapped area */
|
uint32_t size; /* size of memory-mapped area */
|
||||||
u32_t hwaddr[2]; /* MAC address, in register representation */
|
uint32_t hwaddr[2]; /* MAC address, in register representation */
|
||||||
|
|
||||||
u8_t *txd_base; /* local address of TxD ring buffer base */
|
uint8_t *txd_base; /* local address of TxD ring buffer base */
|
||||||
u32_t *txs_base; /* local address of TxS ring buffer base */
|
uint32_t *txs_base; /* local address of TxS ring buffer base */
|
||||||
u8_t *rxd_base_u; /* unaligned base address of RxD ring buffer */
|
uint8_t *rxd_base_u; /* unaligned base address of RxD ring buffer */
|
||||||
rxd_t *rxd_base; /* local address of RxD ring buffer base */
|
rxd_t *rxd_base; /* local address of RxD ring buffer base */
|
||||||
|
|
||||||
int rxd_align; /* alignment offset of RxD ring buffer */
|
int rxd_align; /* alignment offset of RxD ring buffer */
|
||||||
|
@ -73,32 +73,32 @@ static struct {
|
||||||
#define ATL2_FLAG_PACK_RCVD 0x08 /* packet received */
|
#define ATL2_FLAG_PACK_RCVD 0x08 /* packet received */
|
||||||
#define ATL2_FLAG_PACK_SENT 0x10 /* packet transmitted */
|
#define ATL2_FLAG_PACK_SENT 0x10 /* packet transmitted */
|
||||||
|
|
||||||
#define ATL2_READ_U8(off) (* (u8_t *) (state.base + (off)))
|
#define ATL2_READ_U8(off) (*(volatile uint8_t *)(state.base + (off)))
|
||||||
#define ATL2_READ_U16(off) (* (u16_t *) (state.base + (off)))
|
#define ATL2_READ_U16(off) (*(volatile uint16_t *)(state.base + (off)))
|
||||||
#define ATL2_READ_U32(off) (* (u32_t *) (state.base + (off)))
|
#define ATL2_READ_U32(off) (*(volatile uint32_t *)(state.base + (off)))
|
||||||
#define ATL2_WRITE_U8(off, val) * (u8_t *) (state.base + (off)) = (val);
|
#define ATL2_WRITE_U8(off, val) \
|
||||||
#define ATL2_WRITE_U16(off, val) * (u16_t *) (state.base + (off)) = (val);
|
*(volatile uint8_t *)(state.base + (off)) = (val)
|
||||||
#define ATL2_WRITE_U32(off, val) * (u32_t *) (state.base + (off)) = (val);
|
#define ATL2_WRITE_U16(off, val) \
|
||||||
|
*(volatile uint16_t *)(state.base + (off)) = (val)
|
||||||
|
#define ATL2_WRITE_U32(off, val) \
|
||||||
|
*(volatile uint32_t *)(state.base + (off)) = (val)
|
||||||
|
|
||||||
#define ATL2_ALIGN_32(n) (((n) + 3) & ~3)
|
#define ATL2_ALIGN_32(n) (((n) + 3) & ~3)
|
||||||
|
|
||||||
static iovec_s_t iovec[NR_IOREQS];
|
static iovec_s_t iovec[NR_IOREQS];
|
||||||
|
|
||||||
static int instance;
|
/*
|
||||||
|
* Read a value from the VPD register area.
|
||||||
/*===========================================================================*
|
|
||||||
* atl2_read_vpd *
|
|
||||||
*===========================================================================*/
|
|
||||||
static int atl2_read_vpd(int index, u32_t *res)
|
|
||||||
{
|
|
||||||
/* Read a value from the VPD register area.
|
|
||||||
*/
|
*/
|
||||||
u32_t off, val;
|
static int
|
||||||
|
atl2_read_vpd(int index, uint32_t * res)
|
||||||
|
{
|
||||||
|
uint32_t off, val;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
ATL2_WRITE_U32(ATL2_VPD_DATA_REG, 0);
|
ATL2_WRITE_U32(ATL2_VPD_DATA_REG, 0);
|
||||||
|
|
||||||
off = ATL2_VPD_REGBASE + index * sizeof(u32_t);
|
off = ATL2_VPD_REGBASE + index * sizeof(uint32_t);
|
||||||
|
|
||||||
ATL2_WRITE_U32(ATL2_VPD_CAP_REG,
|
ATL2_WRITE_U32(ATL2_VPD_CAP_REG,
|
||||||
(off << ATL2_VPD_CAP_ADDR_SHIFT) & ATL2_VPD_CAP_ADDR_MASK);
|
(off << ATL2_VPD_CAP_ADDR_SHIFT) & ATL2_VPD_CAP_ADDR_MASK);
|
||||||
|
@ -120,15 +120,14 @@ static int atl2_read_vpd(int index, u32_t *res)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
/*
|
||||||
* atl2_get_vpd_hwaddr *
|
* Read the MAC address from the EEPROM, using the Vital Product Data register
|
||||||
*===========================================================================*/
|
* interface.
|
||||||
static int atl2_get_vpd_hwaddr(void)
|
|
||||||
{
|
|
||||||
/* Read the MAC address from the EEPROM, using the Vital Product Data
|
|
||||||
* register interface.
|
|
||||||
*/
|
*/
|
||||||
u32_t key, val;
|
static int
|
||||||
|
atl2_get_vpd_hwaddr(void)
|
||||||
|
{
|
||||||
|
uint32_t key, val;
|
||||||
int i, n, found[2];
|
int i, n, found[2];
|
||||||
|
|
||||||
/* No idea, copied from FreeBSD which copied it from Linux. */
|
/* No idea, copied from FreeBSD which copied it from Linux. */
|
||||||
|
@ -144,7 +143,8 @@ static int atl2_get_vpd_hwaddr(void)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Read out the set of key/value pairs. Look for the two parts that
|
/*
|
||||||
|
* Read out the set of key/value pairs. Look for the two parts that
|
||||||
* make up the MAC address.
|
* make up the MAC address.
|
||||||
*/
|
*/
|
||||||
found[0] = found[1] = FALSE;
|
found[0] = found[1] = FALSE;
|
||||||
|
@ -173,14 +173,13 @@ static int atl2_get_vpd_hwaddr(void)
|
||||||
return found[0] && found[1];
|
return found[0] && found[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
/*
|
||||||
* atl2_get_hwaddr *
|
* Get the MAC address of the card. First try the EEPROM; if that fails, just
|
||||||
*===========================================================================*/
|
* use whatever the card was already set to.
|
||||||
static void atl2_get_hwaddr(void)
|
|
||||||
{
|
|
||||||
/* Get the MAC address of the card. First try the EEPROM; if that
|
|
||||||
* fails, just use whatever the card was already set to.
|
|
||||||
*/
|
*/
|
||||||
|
static void
|
||||||
|
atl2_get_hwaddr(void)
|
||||||
|
{
|
||||||
|
|
||||||
if (!atl2_get_vpd_hwaddr()) {
|
if (!atl2_get_vpd_hwaddr()) {
|
||||||
printf("ATL2: unable to read from VPD\n");
|
printf("ATL2: unable to read from VPD\n");
|
||||||
|
@ -193,14 +192,13 @@ static void atl2_get_hwaddr(void)
|
||||||
state.hwaddr[1], state.hwaddr[0]));
|
state.hwaddr[1], state.hwaddr[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
/*
|
||||||
* atl2_read_mdio *
|
* Read a MII PHY register using MDIO.
|
||||||
*===========================================================================*/
|
|
||||||
static int atl2_read_mdio(int addr, u16_t *res)
|
|
||||||
{
|
|
||||||
/* Read a MII PHY register using MDIO.
|
|
||||||
*/
|
*/
|
||||||
u32_t rval;
|
static int
|
||||||
|
atl2_read_mdio(int addr, uint16_t * res)
|
||||||
|
{
|
||||||
|
uint32_t rval;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
rval = ((addr << ATL2_MDIO_ADDR_SHIFT) & ATL2_MDIO_ADDR_MASK) |
|
rval = ((addr << ATL2_MDIO_ADDR_SHIFT) & ATL2_MDIO_ADDR_MASK) |
|
||||||
|
@ -220,30 +218,29 @@ static int atl2_read_mdio(int addr, u16_t *res)
|
||||||
|
|
||||||
if (i == ATL2_MDIO_NTRIES) return FALSE;
|
if (i == ATL2_MDIO_NTRIES) return FALSE;
|
||||||
|
|
||||||
*res = (u16_t) (rval & ATL2_MDIO_DATA_MASK);
|
*res = (uint16_t)(rval & ATL2_MDIO_DATA_MASK);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
/*
|
||||||
* atl2_alloc_dma *
|
* Allocate DMA ring buffers.
|
||||||
*===========================================================================*/
|
|
||||||
static int atl2_alloc_dma(void)
|
|
||||||
{
|
|
||||||
/* Allocate DMA ring buffers.
|
|
||||||
*/
|
*/
|
||||||
|
static int
|
||||||
|
atl2_alloc_dma(void)
|
||||||
|
{
|
||||||
|
|
||||||
state.txd_base = alloc_contig(ATL2_TXD_BUFSIZE,
|
state.txd_base = alloc_contig(ATL2_TXD_BUFSIZE, AC_ALIGN4K,
|
||||||
AC_ALIGN4K, &state.txd_phys);
|
&state.txd_phys);
|
||||||
state.txs_base = alloc_contig(ATL2_TXS_COUNT * sizeof(u32_t),
|
state.txs_base = alloc_contig(ATL2_TXS_COUNT * sizeof(uint32_t),
|
||||||
AC_ALIGN4K, &state.txs_phys);
|
AC_ALIGN4K, &state.txs_phys);
|
||||||
|
|
||||||
/* The data buffer in each RxD descriptor must be 128-byte aligned.
|
/*
|
||||||
|
* The data buffer in each RxD descriptor must be 128-byte aligned.
|
||||||
* The two Tx buffers merely require a 4-byte start alignment.
|
* The two Tx buffers merely require a 4-byte start alignment.
|
||||||
*/
|
*/
|
||||||
state.rxd_align = 128 - offsetof(rxd_t, data);
|
state.rxd_align = 128 - offsetof(rxd_t, data);
|
||||||
state.rxd_base_u =
|
state.rxd_base_u = alloc_contig(state.rxd_align +
|
||||||
alloc_contig(state.rxd_align + ATL2_RXD_COUNT * ATL2_RXD_SIZE,
|
ATL2_RXD_COUNT * ATL2_RXD_SIZE, AC_ALIGN4K, &state.rxd_phys);
|
||||||
AC_ALIGN4K, &state.rxd_phys);
|
|
||||||
|
|
||||||
/* Unlike mmap, alloc_contig returns NULL on failure. */
|
/* Unlike mmap, alloc_contig returns NULL on failure. */
|
||||||
if (!state.txd_base || !state.txs_base || !state.rxd_base_u)
|
if (!state.txd_base || !state.txs_base || !state.rxd_base_u)
|
||||||
|
@ -254,20 +251,19 @@ static int atl2_alloc_dma(void)
|
||||||
|
|
||||||
/* Zero out just in case. */
|
/* Zero out just in case. */
|
||||||
memset(state.txd_base, 0, ATL2_TXD_BUFSIZE);
|
memset(state.txd_base, 0, ATL2_TXD_BUFSIZE);
|
||||||
memset(state.txs_base, 0, ATL2_TXS_COUNT * sizeof(u32_t));
|
memset(state.txs_base, 0, ATL2_TXS_COUNT * sizeof(uint32_t));
|
||||||
memset(state.rxd_base, 0, ATL2_RXD_COUNT * ATL2_RXD_SIZE);
|
memset(state.rxd_base, 0, ATL2_RXD_COUNT * ATL2_RXD_SIZE);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
/*
|
||||||
* atl2_stop *
|
* Stop the device.
|
||||||
*===========================================================================*/
|
|
||||||
static int atl2_stop(void)
|
|
||||||
{
|
|
||||||
/* Stop the device.
|
|
||||||
*/
|
*/
|
||||||
u32_t val;
|
static int
|
||||||
|
atl2_stop(void)
|
||||||
|
{
|
||||||
|
uint32_t val;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Clear and disable interrupts. */
|
/* Clear and disable interrupts. */
|
||||||
|
@ -296,14 +292,13 @@ static int atl2_stop(void)
|
||||||
return (i < ATL2_IDLE_NTRIES);
|
return (i < ATL2_IDLE_NTRIES);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
/*
|
||||||
* atl2_reset *
|
* Reset the device to a known good state.
|
||||||
*===========================================================================*/
|
|
||||||
static int atl2_reset(void)
|
|
||||||
{
|
|
||||||
/* Reset the device to a known good state.
|
|
||||||
*/
|
*/
|
||||||
u32_t val;
|
static int
|
||||||
|
atl2_reset(void)
|
||||||
|
{
|
||||||
|
uint32_t val;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Issue a soft reset, and wait for the device to respond. */
|
/* Issue a soft reset, and wait for the device to respond. */
|
||||||
|
@ -331,15 +326,14 @@ static int atl2_reset(void)
|
||||||
return (i < ATL2_IDLE_NTRIES);
|
return (i < ATL2_IDLE_NTRIES);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
/*
|
||||||
* atl2_set_mode *
|
* Reconfigure the device's promiscuity, multicast, and broadcast mode
|
||||||
*===========================================================================*/
|
|
||||||
static void atl2_set_mode(void)
|
|
||||||
{
|
|
||||||
/* Reconfigure the device's promiscuity, multicast, and broadcast mode
|
|
||||||
* settings.
|
* settings.
|
||||||
*/
|
*/
|
||||||
u32_t val;
|
static void
|
||||||
|
atl2_set_mode(void)
|
||||||
|
{
|
||||||
|
uint32_t val;
|
||||||
|
|
||||||
val = ATL2_READ_U32(ATL2_MAC_REG);
|
val = ATL2_READ_U32(ATL2_MAC_REG);
|
||||||
val &= ~(ATL2_MAC_PROMISC_EN | ATL2_MAC_MCAST_EN | ATL2_MAC_BCAST_EN);
|
val &= ~(ATL2_MAC_PROMISC_EN | ATL2_MAC_MCAST_EN | ATL2_MAC_BCAST_EN);
|
||||||
|
@ -354,21 +348,20 @@ static void atl2_set_mode(void)
|
||||||
ATL2_WRITE_U32(ATL2_MAC_REG, val);
|
ATL2_WRITE_U32(ATL2_MAC_REG, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
/*
|
||||||
* atl2_setup *
|
* Set up the device for normal operation.
|
||||||
*===========================================================================*/
|
|
||||||
static int atl2_setup(void)
|
|
||||||
{
|
|
||||||
/* Set up the device for normal operation.
|
|
||||||
*/
|
*/
|
||||||
u32_t val;
|
static int
|
||||||
|
atl2_setup(void)
|
||||||
|
{
|
||||||
|
uint32_t val;
|
||||||
|
|
||||||
atl2_stop();
|
atl2_stop();
|
||||||
|
|
||||||
if (!atl2_reset())
|
if (!atl2_reset())
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* Initialize PCIE module. Magic. */
|
/* Initialize PCIe module. Magic. */
|
||||||
ATL2_WRITE_U32(ATL2_LTSSM_TESTMODE_REG, ATL2_LTSSM_TESTMODE_DEFAULT);
|
ATL2_WRITE_U32(ATL2_LTSSM_TESTMODE_REG, ATL2_LTSSM_TESTMODE_DEFAULT);
|
||||||
ATL2_WRITE_U32(ATL2_DLL_TX_CTRL_REG, ATL2_DLL_TX_CTRL_DEFAULT);
|
ATL2_WRITE_U32(ATL2_DLL_TX_CTRL_REG, ATL2_DLL_TX_CTRL_DEFAULT);
|
||||||
|
|
||||||
|
@ -390,7 +383,8 @@ static int atl2_setup(void)
|
||||||
ATL2_WRITE_U32(ATL2_RXD_ADDR_LO_REG, state.rxd_phys);
|
ATL2_WRITE_U32(ATL2_RXD_ADDR_LO_REG, state.rxd_phys);
|
||||||
|
|
||||||
ATL2_WRITE_U16(ATL2_RXD_COUNT_REG, ATL2_RXD_COUNT);
|
ATL2_WRITE_U16(ATL2_RXD_COUNT_REG, ATL2_RXD_COUNT);
|
||||||
ATL2_WRITE_U16(ATL2_TXD_BUFSIZE_REG, ATL2_TXD_BUFSIZE / sizeof(u32_t));
|
ATL2_WRITE_U16(ATL2_TXD_BUFSIZE_REG,
|
||||||
|
ATL2_TXD_BUFSIZE / sizeof(uint32_t));
|
||||||
ATL2_WRITE_U16(ATL2_TXS_COUNT_REG, ATL2_TXS_COUNT);
|
ATL2_WRITE_U16(ATL2_TXS_COUNT_REG, ATL2_TXS_COUNT);
|
||||||
|
|
||||||
/* A whole lot of other initialization copied from Linux/FreeBSD. */
|
/* A whole lot of other initialization copied from Linux/FreeBSD. */
|
||||||
|
@ -439,7 +433,8 @@ static int atl2_setup(void)
|
||||||
/* Configure MAC. */
|
/* Configure MAC. */
|
||||||
ATL2_WRITE_U32(ATL2_MAC_REG, ATL2_MAC_DEFAULT);
|
ATL2_WRITE_U32(ATL2_MAC_REG, ATL2_MAC_DEFAULT);
|
||||||
|
|
||||||
/* Inet does not tell us about the multicast addresses that it is
|
/*
|
||||||
|
* Inet does not tell us about the multicast addresses that it is
|
||||||
* interested in, so we have to simply accept all multicast packets.
|
* interested in, so we have to simply accept all multicast packets.
|
||||||
*/
|
*/
|
||||||
ATL2_WRITE_U32(ATL2_MHT0_REG, 0xffffffff);
|
ATL2_WRITE_U32(ATL2_MHT0_REG, 0xffffffff);
|
||||||
|
@ -454,14 +449,13 @@ static int atl2_setup(void)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
/*
|
||||||
* atl2_probe *
|
* Find a matching PCI device.
|
||||||
*===========================================================================*/
|
|
||||||
static int atl2_probe(int skip)
|
|
||||||
{
|
|
||||||
/* Find a matching PCI device.
|
|
||||||
*/
|
*/
|
||||||
u16_t vid, did;
|
static int
|
||||||
|
atl2_probe(int skip)
|
||||||
|
{
|
||||||
|
uint16_t vid, did;
|
||||||
#if VERBOSE
|
#if VERBOSE
|
||||||
char *dname;
|
char *dname;
|
||||||
#endif
|
#endif
|
||||||
|
@ -482,8 +476,7 @@ static int atl2_probe(int skip)
|
||||||
#if VERBOSE
|
#if VERBOSE
|
||||||
dname = pci_dev_name(vid, did);
|
dname = pci_dev_name(vid, did);
|
||||||
ATL2_DEBUG(("ATL2: found %s (%x/%x) at %s\n",
|
ATL2_DEBUG(("ATL2: found %s (%x/%x) at %s\n",
|
||||||
dname ? dname : "<unknown>", vid, did,
|
dname ? dname : "<unknown>", vid, did, pci_slot_name(devind)));
|
||||||
pci_slot_name(devind)));
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pci_reserve(devind);
|
pci_reserve(devind);
|
||||||
|
@ -491,14 +484,13 @@ static int atl2_probe(int skip)
|
||||||
return devind;
|
return devind;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
/*
|
||||||
* atl2_init *
|
* Initialize the device.
|
||||||
*===========================================================================*/
|
|
||||||
static void atl2_init(int devind)
|
|
||||||
{
|
|
||||||
/* Initialize the device.
|
|
||||||
*/
|
*/
|
||||||
u32_t bar;
|
static void
|
||||||
|
atl2_init(int devind)
|
||||||
|
{
|
||||||
|
uint32_t bar;
|
||||||
int r, flag;
|
int r, flag;
|
||||||
|
|
||||||
/* Initialize global state. */
|
/* Initialize global state. */
|
||||||
|
@ -539,13 +531,12 @@ static void atl2_init(int devind)
|
||||||
atl2_setup();
|
atl2_setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
/*
|
||||||
* atl2_tx_stat *
|
* Update statistics for packet transmission.
|
||||||
*===========================================================================*/
|
|
||||||
static void atl2_tx_stat(u32_t stat)
|
|
||||||
{
|
|
||||||
/* Update statistics for packet transmission.
|
|
||||||
*/
|
*/
|
||||||
|
static void
|
||||||
|
atl2_tx_stat(uint32_t stat)
|
||||||
|
{
|
||||||
|
|
||||||
if (stat & ATL2_TXS_SUCCESS)
|
if (stat & ATL2_TXS_SUCCESS)
|
||||||
state.stat.ets_packetT++;
|
state.stat.ets_packetT++;
|
||||||
|
@ -566,13 +557,12 @@ static void atl2_tx_stat(u32_t stat)
|
||||||
state.stat.ets_fifoUnder++;
|
state.stat.ets_fifoUnder++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
/*
|
||||||
* atl2_rx_stat *
|
* Update statistics for packet receipt.
|
||||||
*===========================================================================*/
|
|
||||||
static void atl2_rx_stat(u32_t stat)
|
|
||||||
{
|
|
||||||
/* Update statistics for packet receipt.
|
|
||||||
*/
|
*/
|
||||||
|
static void
|
||||||
|
atl2_rx_stat(uint32_t stat)
|
||||||
|
{
|
||||||
|
|
||||||
if (stat & ATL2_RXD_SUCCESS)
|
if (stat & ATL2_RXD_SUCCESS)
|
||||||
state.stat.ets_packetR++;
|
state.stat.ets_packetR++;
|
||||||
|
@ -589,14 +579,13 @@ static void atl2_rx_stat(u32_t stat)
|
||||||
state.stat.ets_frameAll++;
|
state.stat.ets_frameAll++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
/*
|
||||||
* atl2_tx_advance *
|
* Advance the TxD/TxS tails by as many sent packets as found.
|
||||||
*===========================================================================*/
|
|
||||||
static int atl2_tx_advance(void)
|
|
||||||
{
|
|
||||||
/* Advance the TxD/TxS tails by as many sent packets as found.
|
|
||||||
*/
|
*/
|
||||||
u32_t stat, size, dsize;
|
static int
|
||||||
|
atl2_tx_advance(void)
|
||||||
|
{
|
||||||
|
uint32_t stat, size, dsize;
|
||||||
int advanced;
|
int advanced;
|
||||||
|
|
||||||
advanced = FALSE;
|
advanced = FALSE;
|
||||||
|
@ -608,32 +597,32 @@ static int atl2_tx_advance(void)
|
||||||
if (!(stat & ATL2_TXS_UPDATE))
|
if (!(stat & ATL2_TXS_UPDATE))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* The packet size from the status must match the packet size
|
/*
|
||||||
|
* The packet size from the status must match the packet size
|
||||||
* we put in. If they don't, there's not much we can do..
|
* we put in. If they don't, there's not much we can do..
|
||||||
*/
|
*/
|
||||||
size = stat & ATL2_TXS_SIZE_MASK;
|
size = stat & ATL2_TXS_SIZE_MASK;
|
||||||
|
|
||||||
assert((u32_t) state.txd_tail <=
|
assert((uint32_t)state.txd_tail <=
|
||||||
ATL2_TXD_BUFSIZE - sizeof(u32_t));
|
ATL2_TXD_BUFSIZE - sizeof(uint32_t));
|
||||||
dsize = * (u32_t *) (state.txd_base + state.txd_tail);
|
dsize = *(uint32_t *)(state.txd_base + state.txd_tail);
|
||||||
if (size != dsize)
|
if (size != dsize)
|
||||||
printf("ATL2: TxD/TxS size mismatch (%x vs %x)\n",
|
printf("ATL2: TxD/TxS size mismatch (%x vs %x)\n",
|
||||||
size, dsize);
|
size, dsize);
|
||||||
|
|
||||||
/* Advance tails accordingly. */
|
/* Advance tails accordingly. */
|
||||||
size = sizeof(u32_t) + ATL2_ALIGN_32(dsize);
|
size = sizeof(uint32_t) + ATL2_ALIGN_32(dsize);
|
||||||
assert((u32_t) state.txd_num >= size);
|
assert((uint32_t)state.txd_num >= size);
|
||||||
state.txd_tail = (state.txd_tail + size) % ATL2_TXD_BUFSIZE;
|
state.txd_tail = (state.txd_tail + size) % ATL2_TXD_BUFSIZE;
|
||||||
state.txd_num -= size;
|
state.txd_num -= size;
|
||||||
|
|
||||||
state.txs_tail = (state.txs_tail + 1) % ATL2_TXS_COUNT;
|
state.txs_tail = (state.txs_tail + 1) % ATL2_TXS_COUNT;
|
||||||
state.txs_num--;
|
state.txs_num--;
|
||||||
|
|
||||||
if (stat & ATL2_TXS_SUCCESS) {
|
if (stat & ATL2_TXS_SUCCESS)
|
||||||
ATL2_DEBUG(("ATL2: successfully sent packet\n"));
|
ATL2_DEBUG(("ATL2: successfully sent packet\n"));
|
||||||
} else {
|
else
|
||||||
ATL2_DEBUG(("ATL2: failed to send packet\n"));
|
ATL2_DEBUG(("ATL2: failed to send packet\n"));
|
||||||
}
|
|
||||||
|
|
||||||
/* Update statistics. */
|
/* Update statistics. */
|
||||||
atl2_tx_stat(stat);
|
atl2_tx_stat(stat);
|
||||||
|
@ -644,18 +633,17 @@ static int atl2_tx_advance(void)
|
||||||
return advanced;
|
return advanced;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
/*
|
||||||
* atl2_rx_advance *
|
* Advance the RxD tail by as many failed receipts as possible, and see if
|
||||||
*===========================================================================*/
|
* there is an actual packet left to receive. If 'next' is set, the packet at
|
||||||
static void atl2_rx_advance(int next)
|
* the current tail has been processed.
|
||||||
{
|
|
||||||
/* Advance the RxD tail by as many failed receipts as possible, and
|
|
||||||
* see if there is an actual packet left to receive. If 'next' is set,
|
|
||||||
* the packet at the current tail has been processed.
|
|
||||||
*/
|
*/
|
||||||
|
static void
|
||||||
|
atl2_rx_advance(int next)
|
||||||
|
{
|
||||||
int update_tail;
|
int update_tail;
|
||||||
rxd_t *rxd;
|
rxd_t *rxd;
|
||||||
u32_t hdr, size;
|
uint32_t hdr, size;
|
||||||
|
|
||||||
update_tail = FALSE;
|
update_tail = FALSE;
|
||||||
|
|
||||||
|
@ -679,12 +667,13 @@ static void atl2_rx_advance(int next)
|
||||||
if (!(hdr & ATL2_RXD_UPDATE))
|
if (!(hdr & ATL2_RXD_UPDATE))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
rxd->hdr = hdr & ~(ATL2_RXD_UPDATE);
|
rxd->hdr = hdr & ~ATL2_RXD_UPDATE;
|
||||||
|
|
||||||
/* Update statistics. */
|
/* Update statistics. */
|
||||||
atl2_rx_stat(hdr);
|
atl2_rx_stat(hdr);
|
||||||
|
|
||||||
/* Stop at the first successful receipt. The packet will be
|
/*
|
||||||
|
* Stop at the first successful receipt. The packet will be
|
||||||
* picked up by Inet later.
|
* picked up by Inet later.
|
||||||
*/
|
*/
|
||||||
size = hdr & ATL2_RXD_SIZE_MASK;
|
size = hdr & ATL2_RXD_SIZE_MASK;
|
||||||
|
@ -712,13 +701,12 @@ static void atl2_rx_advance(int next)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
/*
|
||||||
* atl2_reply *
|
* Send a task reply to Inet.
|
||||||
*===========================================================================*/
|
|
||||||
static void atl2_reply(void)
|
|
||||||
{
|
|
||||||
/* Send a task reply to Inet.
|
|
||||||
*/
|
*/
|
||||||
|
static void
|
||||||
|
atl2_reply(void)
|
||||||
|
{
|
||||||
message m;
|
message m;
|
||||||
int r, flags;
|
int r, flags;
|
||||||
|
|
||||||
|
@ -742,17 +730,16 @@ static void atl2_reply(void)
|
||||||
state.recv_count = 0;
|
state.recv_count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
/*
|
||||||
* atl2_readv *
|
* Read packet data.
|
||||||
*===========================================================================*/
|
|
||||||
static void atl2_readv(const message *m, int from_int)
|
|
||||||
{
|
|
||||||
/* Read packet data.
|
|
||||||
*/
|
*/
|
||||||
|
static void
|
||||||
|
atl2_readv(const message * m, int from_int)
|
||||||
|
{
|
||||||
rxd_t *rxd;
|
rxd_t *rxd;
|
||||||
iovec_s_t *iovp;
|
iovec_s_t *iovp;
|
||||||
size_t count, off, left, size;
|
size_t count, off, left, size;
|
||||||
u8_t *pos;
|
uint8_t *pos;
|
||||||
int i, j, r, batch;
|
int i, j, r, batch;
|
||||||
|
|
||||||
/* We can deal with only one read request from Inet at a time. */
|
/* We can deal with only one read request from Inet at a time. */
|
||||||
|
@ -777,7 +764,8 @@ static void atl2_readv(const message *m, int from_int)
|
||||||
left = count;
|
left = count;
|
||||||
pos = rxd->data;
|
pos = rxd->data;
|
||||||
|
|
||||||
for (i = 0; i < m->m_net_netdrv_dl_readv_s.count && left > 0; i += batch) {
|
for (i = 0; i < m->m_net_netdrv_dl_readv_s.count && left > 0;
|
||||||
|
i += batch) {
|
||||||
/* Copy in the next batch. */
|
/* Copy in the next batch. */
|
||||||
batch = MIN(m->m_net_netdrv_dl_readv_s.count - i, NR_IOREQS);
|
batch = MIN(m->m_net_netdrv_dl_readv_s.count - i, NR_IOREQS);
|
||||||
|
|
||||||
|
@ -825,7 +813,8 @@ static void atl2_readv(const message *m, int from_int)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
suspend:
|
suspend:
|
||||||
/* No packets are available at this time. If we were not already
|
/*
|
||||||
|
* No packets are available at this time. If we were not already
|
||||||
* trying to resume receipt, save the read request for later, and tell
|
* trying to resume receipt, save the read request for later, and tell
|
||||||
* Inet that the request has been suspended.
|
* Inet that the request has been suspended.
|
||||||
*/
|
*/
|
||||||
|
@ -838,17 +827,16 @@ suspend:
|
||||||
atl2_reply();
|
atl2_reply();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
/*
|
||||||
* atl2_writev *
|
* Write packet data.
|
||||||
*===========================================================================*/
|
|
||||||
static void atl2_writev(const message *m, int from_int)
|
|
||||||
{
|
|
||||||
/* Write packet data.
|
|
||||||
*/
|
*/
|
||||||
|
static void
|
||||||
|
atl2_writev(const message * m, int from_int)
|
||||||
|
{
|
||||||
iovec_s_t *iovp;
|
iovec_s_t *iovp;
|
||||||
size_t off, count, left, pos, skip;
|
size_t off, count, left, pos, skip;
|
||||||
vir_bytes size;
|
vir_bytes size;
|
||||||
u8_t *sizep;
|
uint8_t *sizep;
|
||||||
int i, j, r, batch, maxnum;
|
int i, j, r, batch, maxnum;
|
||||||
|
|
||||||
/* We can deal with only one write request from Inet at a time. */
|
/* We can deal with only one write request from Inet at a time. */
|
||||||
|
@ -856,24 +844,26 @@ static void atl2_writev(const message *m, int from_int)
|
||||||
|
|
||||||
state.task_endpt = m->m_source;
|
state.task_endpt = m->m_source;
|
||||||
|
|
||||||
/* If we are already certain that the packet won't fit, bail out.
|
/*
|
||||||
|
* If we are already certain that the packet won't fit, bail out.
|
||||||
* Keep at least some space between TxD head and tail, as it is not
|
* Keep at least some space between TxD head and tail, as it is not
|
||||||
* clear whether the device deals well with the case that they collide.
|
* clear whether the device deals well with the case that they collide.
|
||||||
*/
|
*/
|
||||||
if (state.txs_num >= ATL2_TXS_COUNT)
|
if (state.txs_num >= ATL2_TXS_COUNT)
|
||||||
goto suspend;
|
goto suspend;
|
||||||
maxnum = ATL2_TXD_BUFSIZE - ETH_MIN_PACK_SIZE - sizeof(u32_t);
|
maxnum = ATL2_TXD_BUFSIZE - ETH_MIN_PACK_SIZE - sizeof(uint32_t);
|
||||||
if (state.txd_num >= maxnum)
|
if (state.txd_num >= maxnum)
|
||||||
goto suspend;
|
goto suspend;
|
||||||
|
|
||||||
/* Optimistically try to copy in the data; suspend if it turns out
|
/*
|
||||||
|
* Optimistically try to copy in the data; suspend if it turns out
|
||||||
* that it does not fit.
|
* that it does not fit.
|
||||||
*/
|
*/
|
||||||
off = 0;
|
off = 0;
|
||||||
count = 0;
|
count = 0;
|
||||||
left = state.txd_num - sizeof(u32_t);
|
left = state.txd_num - sizeof(uint32_t);
|
||||||
pos = (state.txd_tail + state.txd_num +
|
pos = (state.txd_tail + state.txd_num +
|
||||||
sizeof(u32_t)) % ATL2_TXD_BUFSIZE;
|
sizeof(uint32_t)) % ATL2_TXD_BUFSIZE;
|
||||||
|
|
||||||
for (i = 0; i < m->m_net_netdrv_dl_writev_s.count; i += batch) {
|
for (i = 0; i < m->m_net_netdrv_dl_writev_s.count; i += batch) {
|
||||||
/* Copy in the next batch. */
|
/* Copy in the next batch. */
|
||||||
|
@ -896,8 +886,7 @@ static void atl2_writev(const message *m, int from_int)
|
||||||
skip = ATL2_TXD_BUFSIZE - pos;
|
skip = ATL2_TXD_BUFSIZE - pos;
|
||||||
r = sys_safecopyfrom(m->m_source,
|
r = sys_safecopyfrom(m->m_source,
|
||||||
iovp->iov_grant, 0,
|
iovp->iov_grant, 0,
|
||||||
(vir_bytes) (state.txd_base + pos),
|
(vir_bytes)(state.txd_base + pos), skip);
|
||||||
skip);
|
|
||||||
if (r != OK)
|
if (r != OK)
|
||||||
panic("safe copy failed: %d", r);
|
panic("safe copy failed: %d", r);
|
||||||
pos = 0;
|
pos = 0;
|
||||||
|
@ -922,10 +911,10 @@ static void atl2_writev(const message *m, int from_int)
|
||||||
/* Write the length to the DWORD right before the packet. */
|
/* Write the length to the DWORD right before the packet. */
|
||||||
sizep = state.txd_base +
|
sizep = state.txd_base +
|
||||||
(state.txd_tail + state.txd_num) % ATL2_TXD_BUFSIZE;
|
(state.txd_tail + state.txd_num) % ATL2_TXD_BUFSIZE;
|
||||||
* (u32_t *) sizep = count;
|
*(uint32_t *)sizep = count;
|
||||||
|
|
||||||
/* Update the TxD head. */
|
/* Update the TxD head. */
|
||||||
state.txd_num += sizeof(u32_t) + ATL2_ALIGN_32(count);
|
state.txd_num += sizeof(uint32_t) + ATL2_ALIGN_32(count);
|
||||||
pos = ATL2_ALIGN_32(pos) % ATL2_TXD_BUFSIZE;
|
pos = ATL2_ALIGN_32(pos) % ATL2_TXD_BUFSIZE;
|
||||||
assert((int)pos ==
|
assert((int)pos ==
|
||||||
(state.txd_tail + state.txd_num) % ATL2_TXD_BUFSIZE);
|
(state.txd_tail + state.txd_num) % ATL2_TXD_BUFSIZE);
|
||||||
|
@ -937,7 +926,7 @@ static void atl2_writev(const message *m, int from_int)
|
||||||
/* Tell the device about our new position. */
|
/* Tell the device about our new position. */
|
||||||
__insn_barrier();
|
__insn_barrier();
|
||||||
|
|
||||||
ATL2_WRITE_U32(ATL2_TXD_IDX_REG, pos / sizeof(u32_t));
|
ATL2_WRITE_U32(ATL2_TXD_IDX_REG, pos / sizeof(uint32_t));
|
||||||
|
|
||||||
/* We have now successfully set up the transmission of a packet. */
|
/* We have now successfully set up the transmission of a packet. */
|
||||||
state.flags &= ~ATL2_FLAG_WRITE_PEND;
|
state.flags &= ~ATL2_FLAG_WRITE_PEND;
|
||||||
|
@ -950,7 +939,8 @@ static void atl2_writev(const message *m, int from_int)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
suspend:
|
suspend:
|
||||||
/* We cannot transmit the packet at this time. If we were not already
|
/*
|
||||||
|
* We cannot transmit the packet at this time. If we were not already
|
||||||
* trying to resume transmission, save the write request for later,
|
* trying to resume transmission, save the write request for later,
|
||||||
* and tell Inet that the request has been suspended.
|
* and tell Inet that the request has been suspended.
|
||||||
*/
|
*/
|
||||||
|
@ -963,14 +953,13 @@ suspend:
|
||||||
atl2_reply();
|
atl2_reply();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
/*
|
||||||
* atl2_intr *
|
* Process an interrupt.
|
||||||
*===========================================================================*/
|
|
||||||
static void atl2_intr(const message *UNUSED(m))
|
|
||||||
{
|
|
||||||
/* Interrupt received.
|
|
||||||
*/
|
*/
|
||||||
u32_t val;
|
static void
|
||||||
|
atl2_intr(const message * __unused m)
|
||||||
|
{
|
||||||
|
uint32_t val;
|
||||||
int r, try_write, try_read;
|
int r, try_write, try_read;
|
||||||
|
|
||||||
/* Clear and disable interrupts. */
|
/* Clear and disable interrupts. */
|
||||||
|
@ -982,9 +971,8 @@ static void atl2_intr(const message *UNUSED(m))
|
||||||
|
|
||||||
/* If an error occurred, reset the card. */
|
/* If an error occurred, reset the card. */
|
||||||
if (val & (ATL2_ISR_DMAR_TIMEOUT | ATL2_ISR_DMAW_TIMEOUT |
|
if (val & (ATL2_ISR_DMAR_TIMEOUT | ATL2_ISR_DMAW_TIMEOUT |
|
||||||
ATL2_ISR_PHY_LINKDOWN)) {
|
ATL2_ISR_PHY_LINKDOWN))
|
||||||
atl2_setup();
|
atl2_setup();
|
||||||
}
|
|
||||||
|
|
||||||
try_write = try_read = FALSE;
|
try_write = try_read = FALSE;
|
||||||
|
|
||||||
|
@ -1018,13 +1006,12 @@ static void atl2_intr(const message *UNUSED(m))
|
||||||
atl2_reply();
|
atl2_reply();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
/*
|
||||||
* atl2_conf *
|
* Configure the mode of the card.
|
||||||
*===========================================================================*/
|
|
||||||
static void atl2_conf(message *m)
|
|
||||||
{
|
|
||||||
/* Configure the mode of the card.
|
|
||||||
*/
|
*/
|
||||||
|
static void
|
||||||
|
atl2_conf(message * m)
|
||||||
|
{
|
||||||
ether_addr_t addr;
|
ether_addr_t addr;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
@ -1049,13 +1036,12 @@ static void atl2_conf(message *m)
|
||||||
printf("ATL2: unable to send reply (%d)\n", r);
|
printf("ATL2: unable to send reply (%d)\n", r);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
/*
|
||||||
* atl2_getstat *
|
* Copy out statistics.
|
||||||
*===========================================================================*/
|
|
||||||
static void atl2_getstat(message *m)
|
|
||||||
{
|
|
||||||
/* Copy out statistics.
|
|
||||||
*/
|
*/
|
||||||
|
static void
|
||||||
|
atl2_getstat(message * m)
|
||||||
|
{
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
sys_safecopyto(m->m_source, m->m_net_netdrv_dl_getstat_s.grant, 0,
|
sys_safecopyto(m->m_source, m->m_net_netdrv_dl_getstat_s.grant, 0,
|
||||||
|
@ -1067,14 +1053,13 @@ static void atl2_getstat(message *m)
|
||||||
printf("ATL2: unable to send reply (%d)\n", r);
|
printf("ATL2: unable to send reply (%d)\n", r);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
/*
|
||||||
* atl2_dump_link *
|
* Dump link status.
|
||||||
*===========================================================================*/
|
|
||||||
static void atl2_dump_link(void)
|
|
||||||
{
|
|
||||||
/* Dump link status.
|
|
||||||
*/
|
*/
|
||||||
u16_t val;
|
static void
|
||||||
|
atl2_dump_link(void)
|
||||||
|
{
|
||||||
|
uint16_t val;
|
||||||
int link_up;
|
int link_up;
|
||||||
|
|
||||||
/* The link status bit is latched. Read the status register twice. */
|
/* The link status bit is latched. Read the status register twice. */
|
||||||
|
@ -1104,13 +1089,12 @@ static void atl2_dump_link(void)
|
||||||
printf("%s duplex)", (val & ATL2_MII_PSSR_DUPLEX) ? "full" : "half");
|
printf("%s duplex)", (val & ATL2_MII_PSSR_DUPLEX) ? "full" : "half");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
/*
|
||||||
* atl2_dump *
|
* Dump statistics.
|
||||||
*===========================================================================*/
|
|
||||||
static void atl2_dump(void)
|
|
||||||
{
|
|
||||||
/* Dump statistics.
|
|
||||||
*/
|
*/
|
||||||
|
static void
|
||||||
|
atl2_dump(void)
|
||||||
|
{
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("Attansic L2 statistics:\n");
|
printf("Attansic L2 statistics:\n");
|
||||||
|
@ -1148,14 +1132,13 @@ static void atl2_dump(void)
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
/*
|
||||||
* sef_cb_init_fresh *
|
* Initialize the atl2 driver.
|
||||||
*===========================================================================*/
|
|
||||||
static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info))
|
|
||||||
{
|
|
||||||
/* Initialize the atl2 driver.
|
|
||||||
*/
|
*/
|
||||||
int r, devind;
|
static int
|
||||||
|
sef_cb_init_fresh(int __unused type, sef_init_info_t * __unused info)
|
||||||
|
{
|
||||||
|
int r, devind, instance;
|
||||||
long v;
|
long v;
|
||||||
#if ATL2_FKEY
|
#if ATL2_FKEY
|
||||||
int fkeys, sfkeys;
|
int fkeys, sfkeys;
|
||||||
|
@ -1186,17 +1169,16 @@ static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info))
|
||||||
printf("ATL2: warning, could not map Shift+F11 key (%d)\n", r);
|
printf("ATL2: warning, could not map Shift+F11 key (%d)\n", r);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return(OK);
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
/*
|
||||||
* sef_cb_signal_handler *
|
* In case of a termination signal, shut down this driver. Stop the device,
|
||||||
*===========================================================================*/
|
* and deallocate resources as proof of concept.
|
||||||
static void sef_cb_signal_handler(int signo)
|
|
||||||
{
|
|
||||||
/* In case of a termination signal, shut down this driver.
|
|
||||||
* Stop the device, and deallocate resources as proof of concept.
|
|
||||||
*/
|
*/
|
||||||
|
static void
|
||||||
|
sef_cb_signal_handler(int signo)
|
||||||
|
{
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
/* Only check for termination signal, ignore anything else. */
|
/* Only check for termination signal, ignore anything else. */
|
||||||
|
@ -1208,7 +1190,7 @@ static void sef_cb_signal_handler(int signo)
|
||||||
panic("unable to deregister IRQ: %d", r);
|
panic("unable to deregister IRQ: %d", r);
|
||||||
|
|
||||||
free_contig(state.txd_base, ATL2_TXD_BUFSIZE);
|
free_contig(state.txd_base, ATL2_TXD_BUFSIZE);
|
||||||
free_contig(state.txs_base, ATL2_TXS_COUNT * sizeof(u32_t));
|
free_contig(state.txs_base, ATL2_TXS_COUNT * sizeof(uint32_t));
|
||||||
free_contig(state.rxd_base_u,
|
free_contig(state.rxd_base_u,
|
||||||
state.rxd_align + ATL2_RXD_COUNT * ATL2_RXD_SIZE);
|
state.rxd_align + ATL2_RXD_COUNT * ATL2_RXD_SIZE);
|
||||||
|
|
||||||
|
@ -1219,11 +1201,13 @@ static void sef_cb_signal_handler(int signo)
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
/*
|
||||||
* sef_local_startup *
|
* Perform SEF initialization.
|
||||||
*===========================================================================*/
|
*/
|
||||||
static void sef_local_startup(void)
|
static void
|
||||||
|
sef_local_startup(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Register init callbacks. */
|
/* Register init callbacks. */
|
||||||
sef_setcb_init_fresh(sef_cb_init_fresh);
|
sef_setcb_init_fresh(sef_cb_init_fresh);
|
||||||
sef_setcb_init_lu(sef_cb_init_fresh);
|
sef_setcb_init_lu(sef_cb_init_fresh);
|
||||||
|
@ -1240,13 +1224,12 @@ static void sef_local_startup(void)
|
||||||
sef_startup();
|
sef_startup();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
/*
|
||||||
* main *
|
* The ATL2 ethernet driver.
|
||||||
*===========================================================================*/
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
/* Driver task.
|
|
||||||
*/
|
*/
|
||||||
|
int
|
||||||
|
main(int argc, char ** argv)
|
||||||
|
{
|
||||||
message m;
|
message m;
|
||||||
int ipc_status;
|
int ipc_status;
|
||||||
int r;
|
int r;
|
||||||
|
@ -1255,7 +1238,7 @@ int main(int argc, char **argv)
|
||||||
env_setargs(argc, argv);
|
env_setargs(argc, argv);
|
||||||
sef_local_startup();
|
sef_local_startup();
|
||||||
|
|
||||||
while (TRUE) {
|
for (;;) {
|
||||||
if ((r = netdriver_receive(ANY, &m, &ipc_status)) != OK)
|
if ((r = netdriver_receive(ANY, &m, &ipc_status)) != OK)
|
||||||
panic("netdriver_receive failed: %d", r);
|
panic("netdriver_receive failed: %d", r);
|
||||||
|
|
||||||
|
|
|
@ -179,5 +179,3 @@
|
||||||
#define ATL2_TXS_ABORTCOL 0x04000000 /* collision abort */
|
#define ATL2_TXS_ABORTCOL 0x04000000 /* collision abort */
|
||||||
#define ATL2_TXS_UNDERRUN 0x08000000 /* buffer underrun */
|
#define ATL2_TXS_UNDERRUN 0x08000000 /* buffer underrun */
|
||||||
#define ATL2_TXS_UPDATE 0x80000000 /* updated by device */
|
#define ATL2_TXS_UPDATE 0x80000000 /* updated by device */
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue