cleaned up

This commit is contained in:
Markus Fröschle
2014-01-02 06:35:15 +00:00
parent 225c53cf57
commit 2a4cd2de88

View File

@@ -543,7 +543,10 @@ void fec_init(uint8_t ch, uint8_t mode, const uint8_t *pa)
void fec_rx_start(uint8_t ch, int8_t *rxbd) void fec_rx_start(uint8_t ch, int8_t *rxbd)
{ {
uint32_t initiator; uint32_t initiator;
int channel, result; int channel;
int result;
(void) result; /* to avoid compiler warning */
/* /*
* Make the initiator assignment * Make the initiator assignment
@@ -608,6 +611,7 @@ void fec_rx_continue(uint8_t ch)
* selected FEC * selected FEC
*/ */
channel = dma_get_channel(DMA_FEC_RX(ch)); channel = dma_get_channel(DMA_FEC_RX(ch));
/* /*
* Continue/restart the DMA task * Continue/restart the DMA task
*/ */
@@ -637,6 +641,7 @@ void fec_rx_stop (uint8_t ch)
* selected FEC * selected FEC
*/ */
channel = dma_get_channel(DMA_FEC_RX(ch)); channel = dma_get_channel(DMA_FEC_RX(ch));
/* Kill the FEC Rx DMA task */ /* Kill the FEC Rx DMA task */
MCD_killDma(channel); MCD_killDma(channel);
@@ -730,9 +735,7 @@ void fec_rx_frame(uint8_t ch, NIF *nif)
new_nbuf = nbuf_alloc(); new_nbuf = nbuf_alloc();
if (new_nbuf == NULL) if (new_nbuf == NULL)
{ {
#ifdef DEBUG_PRINT dbg("%s: nbuf_alloc() failed\n", __FUNCTION__);
dbg("nbuf_alloc() failed\n");
#endif
/* /*
* Can't allocate a new network buffer, so we * Can't allocate a new network buffer, so we
@@ -745,6 +748,7 @@ void fec_rx_frame(uint8_t ch, NIF *nif)
pRxBD->status |= RX_BD_E; pRxBD->status |= RX_BD_E;
nbuf_add(NBUF_RX_RING, cur_nbuf); nbuf_add(NBUF_RX_RING, cur_nbuf);
fec_rx_continue(ch); fec_rx_continue(ch);
continue; continue;
} }
@@ -784,7 +788,10 @@ void fec_rx_frame(uint8_t ch, NIF *nif)
nif_protocol_handler(nif, eth_hdr->type, cur_nbuf); nif_protocol_handler(nif, eth_hdr->type, cur_nbuf);
} }
else else
{
nbuf_free(cur_nbuf); nbuf_free(cur_nbuf);
dbg("%s: got unsupported packet %d, trashed it\r\n", __FUNCTION__, eth_hdr->type);
}
} }
else else
{ {
@@ -838,10 +845,14 @@ void fec1_rx_frame(void)
void fec_tx_start(uint8_t ch, int8_t *txbd) void fec_tx_start(uint8_t ch, int8_t *txbd)
{ {
uint32_t initiator; uint32_t initiator;
int channel, result; int channel;
int result;
void fec0_tx_frame(void); void fec0_tx_frame(void);
void fec1_tx_frame(void); void fec1_tx_frame(void);
(void) result; /* to avoid compiler warning */
/* FIXME: code assumes that there are always free initiator slots */
/* /*
* Make the initiator assignment * Make the initiator assignment
*/ */
@@ -1173,10 +1184,8 @@ static void fec_irq_handler(uint8_t ch)
eir = MCF_FEC_EIR(ch); eir = MCF_FEC_EIR(ch);
event = eir & MCF_FEC_EIMR(ch); event = eir & MCF_FEC_EIMR(ch);
#ifdef DEBUG
if (event != eir) if (event != eir)
dbg("Pending but not enabled: 0x%08X\n", (event ^ eir)); dbg("%s: pending but not enabled: 0x%08x\r\n", __FUNCTION__, (event ^ eir));
#endif
/* /*
* Clear the event(s) in the EIR immediately * Clear the event(s) in the EIR immediately
@@ -1187,80 +1196,74 @@ static void fec_irq_handler(uint8_t ch)
{ {
fec_log[ch].total++; fec_log[ch].total++;
fec_log[ch].rferr++; fec_log[ch].rferr++;
#ifdef DEBUG dbg("%s: RFERR\r\n", __FUNCTION__);
dbg("RFERR\n"); dbg("%s: FECRFSR%d = 0x%08x\r\n", __FUNCTION__, ch, MCF_FEC_FECRFSR(ch));
dbg("FECRFSR%d = 0x%08x\n", ch, MCF_FEC_FECRFSR(ch));
fec_eth_stop(ch); fec_eth_stop(ch);
#endif
} }
if (event & MCF_FEC_EIR_XFERR) if (event & MCF_FEC_EIR_XFERR)
{ {
fec_log[ch].total++; fec_log[ch].total++;
fec_log[ch].xferr++; fec_log[ch].xferr++;
#ifdef DEBUG dbg("%s: XFERR\r\n", __FUNCTION__);
dbg("XFERR\n");
#endif
} }
if (event & MCF_FEC_EIR_XFUN) if (event & MCF_FEC_EIR_XFUN)
{ {
fec_log[ch].total++; fec_log[ch].total++;
fec_log[ch].xfun++; fec_log[ch].xfun++;
#ifdef DEBUG dbg("%s: XFUN\r\n", __FUNCTION__);
dbg("XFUN\n");
fec_eth_stop(ch); fec_eth_stop(ch);
#endif
} }
if (event & MCF_FEC_EIR_RL) if (event & MCF_FEC_EIR_RL)
{ {
fec_log[ch].total++; fec_log[ch].total++;
fec_log[ch].rl++; fec_log[ch].rl++;
#ifdef DEBUG dbg("%s: RL\r\n", __FUNCTION__);
dbg("RL\n");
#endif
} }
if (event & MCF_FEC_EIR_LC) if (event & MCF_FEC_EIR_LC)
{ {
fec_log[ch].total++; fec_log[ch].total++;
fec_log[ch].lc++; fec_log[ch].lc++;
#ifdef DEBUG dbg("%s: LC\r\n", __FUNCTION__);
dbg("LC\n");
#endif
} }
if (event & MCF_FEC_EIR_MII) if (event & MCF_FEC_EIR_MII)
{ {
fec_log[ch].mii++; fec_log[ch].mii++;
} }
if (event & MCF_FEC_EIR_TXF) if (event & MCF_FEC_EIR_TXF)
{ {
fec_log[ch].txf++; fec_log[ch].txf++;
} }
if (event & MCF_FEC_EIR_GRA) if (event & MCF_FEC_EIR_GRA)
{ {
fec_log[ch].gra++; fec_log[ch].gra++;
} }
if (event & MCF_FEC_EIR_BABT) if (event & MCF_FEC_EIR_BABT)
{ {
fec_log[ch].total++; fec_log[ch].total++;
fec_log[ch].babt++; fec_log[ch].babt++;
#ifdef DEBUG dbg("%s: BABT\r\n", __FUNCTION__);
dbg("BABT\n");
#endif
} }
if (event & MCF_FEC_EIR_BABR) if (event & MCF_FEC_EIR_BABR)
{ {
fec_log[ch].total++; fec_log[ch].total++;
fec_log[ch].babr++; fec_log[ch].babr++;
#ifdef DEBUG dbg("%s: BABR\r\n", __FUNCTION__);
dbg("BABR\n");
#endif
} }
if (event & MCF_FEC_EIR_HBERR) if (event & MCF_FEC_EIR_HBERR)
{ {
fec_log[ch].total++; fec_log[ch].total++;
fec_log[ch].hberr++; fec_log[ch].hberr++;
#ifdef DEBUG dbg("%s: HBERR\r\n", __FUNCTION__);
dbg("HBERR\n");
#endif
} }
} }
@@ -1268,7 +1271,9 @@ int fec0_interrupt_handler(void* arg1, void* arg2)
{ {
(void) arg1; (void) arg1;
(void) arg2; (void) arg2;
fec_irq_handler(0); fec_irq_handler(0);
return 1; return 1;
} }
@@ -1276,7 +1281,9 @@ int fec1_interrupt_handler(void* arg1, void* arg2)
{ {
(void) arg1; (void) arg1;
(void) arg2; (void) arg2;
fec_irq_handler(1); fec_irq_handler(1);
return 1; return 1;
} }
@@ -1384,7 +1391,7 @@ void fec_eth_stop(uint8_t ch)
*/ */
MCF_FEC_ECR(ch) &= ~MCF_FEC_ECR_ETHER_EN; MCF_FEC_ECR(ch) &= ~MCF_FEC_ECR_ETHER_EN;
#ifdef DEBUG_PRINT #ifdef DBG_FEC
nbuf_debug_dump(); nbuf_debug_dump();
fec_log_dump(ch); fec_log_dump(ch);
#endif #endif