mirror of https://github.com/m-labs/artiq.git
lwip/liteethif: cleanup, drop frames above MTU (#398)
This commit is contained in:
parent
ccdfa1eff3
commit
2b447055e5
|
@ -15,9 +15,6 @@
|
||||||
#include <hw/flags.h>
|
#include <hw/flags.h>
|
||||||
#include <hw/ethmac_mem.h>
|
#include <hw/ethmac_mem.h>
|
||||||
|
|
||||||
static unsigned int rxslot;
|
|
||||||
static unsigned int rxlen;
|
|
||||||
static char *rxbuffer;
|
|
||||||
static char *rxbuffer0;
|
static char *rxbuffer0;
|
||||||
static char *rxbuffer1;
|
static char *rxbuffer1;
|
||||||
static unsigned int txslot;
|
static unsigned int txslot;
|
||||||
|
@ -29,31 +26,6 @@ static char *txbuffer1;
|
||||||
#define IFNAME0 'e'
|
#define IFNAME0 'e'
|
||||||
#define IFNAME1 't'
|
#define IFNAME1 't'
|
||||||
|
|
||||||
static void liteeth_low_level_init(struct netif *netif)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
netif->hwaddr_len = 6;
|
|
||||||
for(i=0;i<netif->hwaddr_len;i++)
|
|
||||||
netif->hwaddr[i] = macadr[i];
|
|
||||||
netif->mtu = 1514;
|
|
||||||
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP;
|
|
||||||
|
|
||||||
ethmac_sram_reader_ev_pending_write(ETHMAC_EV_SRAM_READER);
|
|
||||||
ethmac_sram_writer_ev_pending_write(ETHMAC_EV_SRAM_WRITER);
|
|
||||||
|
|
||||||
rxbuffer0 = (char *)ETHMAC_RX0_BASE;
|
|
||||||
rxbuffer1 = (char *)ETHMAC_RX1_BASE;
|
|
||||||
txbuffer0 = (char *)ETHMAC_TX0_BASE;
|
|
||||||
txbuffer1 = (char *)ETHMAC_TX1_BASE;
|
|
||||||
|
|
||||||
rxslot = 0;
|
|
||||||
txslot = 0;
|
|
||||||
|
|
||||||
rxbuffer = rxbuffer0;
|
|
||||||
txbuffer = txbuffer0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static err_t liteeth_low_level_output(struct netif *netif, struct pbuf *p)
|
static err_t liteeth_low_level_output(struct netif *netif, struct pbuf *p)
|
||||||
{
|
{
|
||||||
struct pbuf *q;
|
struct pbuf *q;
|
||||||
|
@ -86,10 +58,18 @@ static err_t liteeth_low_level_output(struct netif *netif, struct pbuf *p)
|
||||||
|
|
||||||
static struct pbuf *liteeth_low_level_input(struct netif *netif)
|
static struct pbuf *liteeth_low_level_input(struct netif *netif)
|
||||||
{
|
{
|
||||||
|
unsigned int rxslot;
|
||||||
|
unsigned int rxlen;
|
||||||
|
char *rxbuffer;
|
||||||
struct pbuf *p, *q;
|
struct pbuf *p, *q;
|
||||||
|
|
||||||
|
p = NULL;
|
||||||
|
|
||||||
|
if(ethmac_sram_writer_ev_pending_read() & ETHMAC_EV_SRAM_WRITER) {
|
||||||
rxslot = ethmac_sram_writer_slot_read();
|
rxslot = ethmac_sram_writer_slot_read();
|
||||||
rxlen = ethmac_sram_writer_length_read();
|
rxlen = ethmac_sram_writer_length_read();
|
||||||
|
/* dest MAC + source MAC + 802.1Q + ethertype + payload (MTU) */
|
||||||
|
if(rxlen <= (netif->mtu + 18)) {
|
||||||
if(rxslot)
|
if(rxslot)
|
||||||
rxbuffer = rxbuffer1;
|
rxbuffer = rxbuffer1;
|
||||||
else
|
else
|
||||||
|
@ -105,7 +85,9 @@ static struct pbuf *liteeth_low_level_input(struct netif *netif)
|
||||||
else
|
else
|
||||||
q = NULL;
|
q = NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
ethmac_sram_writer_ev_pending_write(ETHMAC_EV_SRAM_WRITER);
|
||||||
|
}
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,23 +101,28 @@ void liteeth_input(struct netif *netif)
|
||||||
|
|
||||||
err_t liteeth_init(struct netif *netif)
|
err_t liteeth_init(struct netif *netif)
|
||||||
{
|
{
|
||||||
struct liteethif *liteethif;
|
int i;
|
||||||
|
|
||||||
liteethif = mem_malloc(sizeof(struct liteethif));
|
|
||||||
if(liteethif == NULL)
|
|
||||||
return ERR_MEM;
|
|
||||||
netif->state = liteethif;
|
|
||||||
|
|
||||||
netif->hwaddr_len = 6;
|
netif->hwaddr_len = 6;
|
||||||
|
for(i=0;i<netif->hwaddr_len;i++)
|
||||||
|
netif->hwaddr[i] = macadr[i];
|
||||||
netif->name[0] = IFNAME0;
|
netif->name[0] = IFNAME0;
|
||||||
netif->name[1] = IFNAME1;
|
netif->name[1] = IFNAME1;
|
||||||
netif->output = etharp_output;
|
netif->output = etharp_output;
|
||||||
netif->linkoutput = liteeth_low_level_output;
|
netif->linkoutput = liteeth_low_level_output;
|
||||||
netif->mtu = 1514;
|
netif->mtu = 1500;
|
||||||
|
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP;
|
||||||
|
|
||||||
liteethif->ethaddr = (struct eth_addr *)&(netif->hwaddr[0]);
|
ethmac_sram_reader_ev_pending_write(ETHMAC_EV_SRAM_READER);
|
||||||
|
ethmac_sram_writer_ev_pending_write(ETHMAC_EV_SRAM_WRITER);
|
||||||
|
|
||||||
liteeth_low_level_init(netif);
|
rxbuffer0 = (char *)ETHMAC_RX0_BASE;
|
||||||
|
rxbuffer1 = (char *)ETHMAC_RX1_BASE;
|
||||||
|
txbuffer0 = (char *)ETHMAC_TX0_BASE;
|
||||||
|
txbuffer1 = (char *)ETHMAC_TX1_BASE;
|
||||||
|
|
||||||
|
txslot = 0;
|
||||||
|
txbuffer = txbuffer0;
|
||||||
|
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,10 +7,6 @@
|
||||||
|
|
||||||
extern unsigned char macadr[];
|
extern unsigned char macadr[];
|
||||||
|
|
||||||
struct liteethif {
|
|
||||||
struct eth_addr *ethaddr;
|
|
||||||
};
|
|
||||||
|
|
||||||
void liteeth_input(struct netif *netif);
|
void liteeth_input(struct netif *netif);
|
||||||
err_t liteeth_init(struct netif *netif);
|
err_t liteeth_init(struct netif *netif);
|
||||||
|
|
||||||
|
|
|
@ -56,10 +56,7 @@ static void lwip_service(void)
|
||||||
{
|
{
|
||||||
sys_check_timeouts();
|
sys_check_timeouts();
|
||||||
#ifdef CSR_ETHMAC_BASE
|
#ifdef CSR_ETHMAC_BASE
|
||||||
if(ethmac_sram_writer_ev_pending_read() & ETHMAC_EV_SRAM_WRITER) {
|
|
||||||
liteeth_input(&netif);
|
liteeth_input(&netif);
|
||||||
ethmac_sram_writer_ev_pending_write(ETHMAC_EV_SRAM_WRITER);
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
if(uart_read_nonblock()) {
|
if(uart_read_nonblock()) {
|
||||||
u8_t c;
|
u8_t c;
|
||||||
|
|
Loading…
Reference in New Issue