cleaned up
This commit is contained in:
@@ -201,7 +201,7 @@ void fec_mii_init(uint8_t ch, uint32_t sys_clk)
|
||||
*/
|
||||
void fec_mib_init(uint8_t ch)
|
||||
{
|
||||
//To do
|
||||
//To do
|
||||
}
|
||||
|
||||
/********************************************************************/
|
||||
@@ -212,7 +212,7 @@ void fec_mib_init(uint8_t ch)
|
||||
*/
|
||||
void fec_mib_dump(uint8_t ch)
|
||||
{
|
||||
//To do
|
||||
//To do
|
||||
}
|
||||
|
||||
/********************************************************************/
|
||||
@@ -344,7 +344,7 @@ uint8_t fec_hash_address(const uint8_t *addr)
|
||||
byte = addr[i];
|
||||
for (j = 0; j < 8; ++j)
|
||||
{
|
||||
if ((byte & 0x01)^(crc & 0x01))
|
||||
if ((byte & 0x01) ^ (crc & 0x01))
|
||||
{
|
||||
crc >>= 1;
|
||||
crc = crc ^ 0xEDB88320;
|
||||
@@ -366,15 +366,15 @@ uint8_t fec_hash_address(const uint8_t *addr)
|
||||
* ch FEC channel
|
||||
* pa Physical (Hardware) Address for the selected FEC
|
||||
*/
|
||||
void fec_set_address (uint8_t ch, const uint8_t *pa)
|
||||
void fec_set_address(uint8_t ch, const uint8_t *pa)
|
||||
{
|
||||
uint8_t crc;
|
||||
|
||||
/*
|
||||
* Set the Physical Address
|
||||
*/
|
||||
MCF_FEC_PALR(ch) = (uint32_t)((pa[0] << 24) | (pa[1] << 16) | (pa[2] << 8) | pa[3]);
|
||||
MCF_FEC_PAHR(ch) = (uint32_t)((pa[4] << 24) | (pa[5] << 16));
|
||||
MCF_FEC_PALR(ch) = (uint32_t) ((pa[0] << 24) | (pa[1] << 16) | (pa[2] << 8) | pa[3]);
|
||||
MCF_FEC_PAHR(ch) = (uint32_t) ((pa[4] << 24) | (pa[5] << 16));
|
||||
|
||||
/*
|
||||
* Calculate and set the hash for given Physical Address
|
||||
@@ -382,9 +382,9 @@ void fec_set_address (uint8_t ch, const uint8_t *pa)
|
||||
*/
|
||||
crc = fec_hash_address(pa);
|
||||
if(crc >= 32)
|
||||
MCF_FEC_IAUR(ch) |= (uint32_t)(1 << (crc - 32));
|
||||
MCF_FEC_IAUR(ch) |= (uint32_t) (1 << (crc - 32));
|
||||
else
|
||||
MCF_FEC_IALR(ch) |= (uint32_t)(1 << crc);
|
||||
MCF_FEC_IALR(ch) |= (uint32_t) (1 << crc);
|
||||
}
|
||||
|
||||
/********************************************************************/
|
||||
@@ -489,9 +489,9 @@ void fec_init(uint8_t ch, uint8_t mode, const uint8_t *pa)
|
||||
*/
|
||||
MCF_FEC_RCR(ch) = 0
|
||||
| MCF_FEC_RCR_MAX_FL(ETH_MAX_FRM)
|
||||
#ifdef FEC_PROMISCUOUS
|
||||
#ifdef FEC_PROMISCUOUS
|
||||
| MCF_FEC_RCR_PROM
|
||||
#endif
|
||||
#endif
|
||||
| MCF_FEC_RCR_FCE;
|
||||
|
||||
if (mode == FEC_MODE_MII)
|
||||
@@ -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)
|
||||
{
|
||||
uint32_t initiator;
|
||||
int channel, result;
|
||||
int channel;
|
||||
int result;
|
||||
|
||||
(void) result; /* to avoid compiler warning */
|
||||
|
||||
/*
|
||||
* Make the initiator assignment
|
||||
@@ -608,6 +611,7 @@ void fec_rx_continue(uint8_t ch)
|
||||
* selected FEC
|
||||
*/
|
||||
channel = dma_get_channel(DMA_FEC_RX(ch));
|
||||
|
||||
/*
|
||||
* Continue/restart the DMA task
|
||||
*/
|
||||
@@ -637,6 +641,7 @@ void fec_rx_stop (uint8_t ch)
|
||||
* selected FEC
|
||||
*/
|
||||
channel = dma_get_channel(DMA_FEC_RX(ch));
|
||||
|
||||
/* Kill the FEC Rx DMA task */
|
||||
MCD_killDma(channel);
|
||||
|
||||
@@ -730,9 +735,7 @@ void fec_rx_frame(uint8_t ch, NIF *nif)
|
||||
new_nbuf = nbuf_alloc();
|
||||
if (new_nbuf == NULL)
|
||||
{
|
||||
#ifdef DEBUG_PRINT
|
||||
dbg("nbuf_alloc() failed\n");
|
||||
#endif
|
||||
dbg("%s: nbuf_alloc() failed\n", __FUNCTION__);
|
||||
|
||||
/*
|
||||
* 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;
|
||||
nbuf_add(NBUF_RX_RING, cur_nbuf);
|
||||
fec_rx_continue(ch);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -773,18 +777,21 @@ void fec_rx_frame(uint8_t ch, NIF *nif)
|
||||
/*
|
||||
* Get pointer to the frame data inside the network buffer
|
||||
*/
|
||||
eth_hdr = (ETH_HDR *)cur_nbuf->data;
|
||||
eth_hdr = (ETH_HDR *) cur_nbuf->data;
|
||||
|
||||
/*
|
||||
* Pass the received packet up the network stack if the
|
||||
* protocol is supported in our network interface (NIF)
|
||||
*/
|
||||
if (nif_protocol_exist(nif,eth_hdr->type))
|
||||
if (nif_protocol_exist(nif, eth_hdr->type))
|
||||
{
|
||||
nif_protocol_handler(nif, eth_hdr->type, cur_nbuf);
|
||||
}
|
||||
else
|
||||
{
|
||||
nbuf_free(cur_nbuf);
|
||||
dbg("%s: got unsupported packet %d, trashed it\r\n", __FUNCTION__, eth_hdr->type);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -838,10 +845,14 @@ void fec1_rx_frame(void)
|
||||
void fec_tx_start(uint8_t ch, int8_t *txbd)
|
||||
{
|
||||
uint32_t initiator;
|
||||
int channel, result;
|
||||
int channel;
|
||||
int result;
|
||||
void fec0_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
|
||||
*/
|
||||
@@ -938,7 +949,7 @@ void fec_tx_stop (uint8_t ch)
|
||||
MCF_FEC_TCR(ch) |= MCF_FEC_TCR_GTS;
|
||||
|
||||
/* Wait for the Graceful Stop Complete interrupt */
|
||||
while(!(MCF_FEC_EIR(ch) & MCF_FEC_EIR_GRA))
|
||||
while (!(MCF_FEC_EIR(ch) & MCF_FEC_EIR_GRA))
|
||||
{
|
||||
if (!(MCF_FEC_ECR(ch) & MCF_FEC_ECR_ETHER_EN))
|
||||
break;
|
||||
@@ -1173,10 +1184,8 @@ static void fec_irq_handler(uint8_t ch)
|
||||
eir = MCF_FEC_EIR(ch);
|
||||
event = eir & MCF_FEC_EIMR(ch);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (event != eir)
|
||||
dbg("Pending but not enabled: 0x%08X\n", (event ^ eir));
|
||||
#endif
|
||||
dbg("%s: pending but not enabled: 0x%08x\r\n", __FUNCTION__, (event ^ eir));
|
||||
|
||||
/*
|
||||
* 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].rferr++;
|
||||
#ifdef DEBUG
|
||||
dbg("RFERR\n");
|
||||
dbg("FECRFSR%d = 0x%08x\n", ch, MCF_FEC_FECRFSR(ch));
|
||||
dbg("%s: RFERR\r\n", __FUNCTION__);
|
||||
dbg("%s: FECRFSR%d = 0x%08x\r\n", __FUNCTION__, ch, MCF_FEC_FECRFSR(ch));
|
||||
fec_eth_stop(ch);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (event & MCF_FEC_EIR_XFERR)
|
||||
{
|
||||
fec_log[ch].total++;
|
||||
fec_log[ch].xferr++;
|
||||
#ifdef DEBUG
|
||||
dbg("XFERR\n");
|
||||
#endif
|
||||
dbg("%s: XFERR\r\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
if (event & MCF_FEC_EIR_XFUN)
|
||||
{
|
||||
fec_log[ch].total++;
|
||||
fec_log[ch].xfun++;
|
||||
#ifdef DEBUG
|
||||
dbg("XFUN\n");
|
||||
dbg("%s: XFUN\r\n", __FUNCTION__);
|
||||
fec_eth_stop(ch);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (event & MCF_FEC_EIR_RL)
|
||||
{
|
||||
fec_log[ch].total++;
|
||||
fec_log[ch].rl++;
|
||||
#ifdef DEBUG
|
||||
dbg("RL\n");
|
||||
#endif
|
||||
dbg("%s: RL\r\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
if (event & MCF_FEC_EIR_LC)
|
||||
{
|
||||
fec_log[ch].total++;
|
||||
fec_log[ch].lc++;
|
||||
#ifdef DEBUG
|
||||
dbg("LC\n");
|
||||
#endif
|
||||
dbg("%s: LC\r\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
if (event & MCF_FEC_EIR_MII)
|
||||
{
|
||||
fec_log[ch].mii++;
|
||||
}
|
||||
|
||||
if (event & MCF_FEC_EIR_TXF)
|
||||
{
|
||||
fec_log[ch].txf++;
|
||||
}
|
||||
|
||||
if (event & MCF_FEC_EIR_GRA)
|
||||
{
|
||||
fec_log[ch].gra++;
|
||||
}
|
||||
|
||||
if (event & MCF_FEC_EIR_BABT)
|
||||
{
|
||||
fec_log[ch].total++;
|
||||
fec_log[ch].babt++;
|
||||
#ifdef DEBUG
|
||||
dbg("BABT\n");
|
||||
#endif
|
||||
dbg("%s: BABT\r\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
if (event & MCF_FEC_EIR_BABR)
|
||||
{
|
||||
fec_log[ch].total++;
|
||||
fec_log[ch].babr++;
|
||||
#ifdef DEBUG
|
||||
dbg("BABR\n");
|
||||
#endif
|
||||
dbg("%s: BABR\r\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
if (event & MCF_FEC_EIR_HBERR)
|
||||
{
|
||||
fec_log[ch].total++;
|
||||
fec_log[ch].hberr++;
|
||||
#ifdef DEBUG
|
||||
dbg("HBERR\n");
|
||||
#endif
|
||||
dbg("%s: HBERR\r\n", __FUNCTION__);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1268,7 +1271,9 @@ int fec0_interrupt_handler(void* arg1, void* arg2)
|
||||
{
|
||||
(void) arg1;
|
||||
(void) arg2;
|
||||
|
||||
fec_irq_handler(0);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1276,7 +1281,9 @@ int fec1_interrupt_handler(void* arg1, void* arg2)
|
||||
{
|
||||
(void) arg1;
|
||||
(void) arg2;
|
||||
|
||||
fec_irq_handler(1);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1384,10 +1391,10 @@ void fec_eth_stop(uint8_t ch)
|
||||
*/
|
||||
MCF_FEC_ECR(ch) &= ~MCF_FEC_ECR_ETHER_EN;
|
||||
|
||||
#ifdef DEBUG_PRINT
|
||||
#ifdef DBG_FEC
|
||||
nbuf_debug_dump();
|
||||
fec_log_dump(ch);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Flush the network buffers
|
||||
|
||||
Reference in New Issue
Block a user