networking works (sort of). For some reason, the Firebee packets don't cross my switch (or only very few of them do). If I put a Linux box in between (cross cable), using it as router, everything works flawlessly.

This commit is contained in:
Markus Fröschle
2014-01-06 18:44:36 +00:00
parent 3f3787872d
commit e365f91254
21 changed files with 447 additions and 411 deletions

View File

@@ -17,7 +17,7 @@
#error "unknown machine"
#endif
#define DBG_AM79
//#define DBG_AM79
#ifdef DBG_AM79
#define dbg(format, arg...) do { xprintf("DEBUG: " format, ##arg); } while (0)
#else
@@ -55,6 +55,7 @@ int am79c874_init(uint8_t fec_ch, uint8_t phy_addr, uint8_t speed, uint8_t duple
/* Reset the PHY */
if (!fec_mii_write(fec_ch, phy_addr, MII_AM79C874_CR, MII_AM79C874_CR_RESET))
return 0;
/* Wait for the PHY to reset */
for (timeout = 0; timeout < FEC_MII_TIMEOUT; timeout++)
{
@@ -63,7 +64,10 @@ int am79c874_init(uint8_t fec_ch, uint8_t phy_addr, uint8_t speed, uint8_t duple
break;
}
if (timeout >= FEC_MII_TIMEOUT)
{
dbg("%s: PHY reset failed\r\n", __FUNCTION__);
return 0;
};
dbg("%s: PHY reset OK\r\n", __FUNCTION__);
dbg("%s: PHY Enable Auto-Negotiation\r\n", __FUNCTION__);
@@ -107,7 +111,7 @@ int am79c874_init(uint8_t fec_ch, uint8_t phy_addr, uint8_t speed, uint8_t duple
else
dbg("%s: Half-duplex\r\n", __FUNCTION__);
dbg("%s:PHY auto-negociation complete\r\n", __FUNCTION__);
dbg("%s:PHY auto-negotiation complete\r\n", __FUNCTION__);
#endif /* DBG_AM79 */
return 1;

View File

@@ -29,7 +29,7 @@
#error Unknown machine!
#endif
#define DBG_FEC
//#define DBG_FEC
#ifdef DBG_FEC
#define dbg(format, arg...) do { xprintf("DEBUG: " format, ##arg); } while (0)
#else
@@ -96,7 +96,7 @@ int fec_mii_write(uint8_t ch, uint8_t phy_addr, uint8_t reg_addr, uint16_t data)
}
if(timeout == FEC_MII_TIMEOUT)
return 1;
return 0;
/*
* Clear the MII interrupt bit
@@ -108,7 +108,7 @@ int fec_mii_write(uint8_t ch, uint8_t phy_addr, uint8_t reg_addr, uint16_t data)
*/
MCF_FEC_EIMR(ch) = eimr;
return 0;
return 1;
}
/*
@@ -161,7 +161,7 @@ int fec_mii_read(uint8_t ch, uint8_t phy_addr, uint8_t reg_addr, uint16_t *data)
}
if(timeout == FEC_MII_TIMEOUT)
return 1;
return 0;
/*
* Clear the MII interrupt bit
@@ -170,7 +170,7 @@ int fec_mii_read(uint8_t ch, uint8_t phy_addr, uint8_t reg_addr, uint16_t *data)
*data = (uint16_t)(MCF_FEC_MMFR(ch) & 0x0000FFFF);
return 0;
return 1;
}
/*
@@ -481,9 +481,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)
@@ -668,6 +668,8 @@ void fec_rx_frame(uint8_t ch, NIF *nif)
NBUF *cur_nbuf, *new_nbuf;
int keep;
dbg("%s: started\r\n", __FUNCTION__);
while ((pRxBD = fecbd_rx_alloc(ch)) != NULL)
{
fec_log[ch].drxf++;
@@ -778,6 +780,7 @@ void fec_rx_frame(uint8_t ch, NIF *nif)
*/
if (nif_protocol_exist(nif, eth_hdr->type))
{
hexdump((uint8_t *) eth_hdr, ETH_MAX_FRM);
nif_protocol_handler(nif, eth_hdr->type, cur_nbuf);
}
else
@@ -989,6 +992,7 @@ void fec_tx_frame(uint8_t ch)
{
FECBD *pTxBD;
NBUF *pNbuf;
bool is_empty = true;
dbg("%s:\r\n", __FUNCTION__);
while ((pTxBD = fecbd_tx_free(ch)) != NULL)
@@ -1011,10 +1015,11 @@ void fec_tx_frame(uint8_t ch)
*/
pTxBD->data = NULL;
pTxBD->length = 0;
is_empty = false;
return;
}
dbg("%s: BD ring is empty\r\n", __FUNCTION__);
if (is_empty)
dbg("%s: transmit queue was empty!\r\n", __FUNCTION__);
}
void fec0_tx_frame(void)
@@ -1198,7 +1203,7 @@ static void fec_irq_handler(uint8_t ch)
fec_log[ch].rferr++;
dbg("%s: RFERR\r\n", __FUNCTION__);
dbg("%s: FECRFSR%d = 0x%08x\r\n", __FUNCTION__, ch, MCF_FEC_FECRFSR(ch));
fec_eth_stop(ch);
//fec_eth_stop(ch);
}
if (event & MCF_FEC_EIR_XFERR)
@@ -1213,7 +1218,7 @@ static void fec_irq_handler(uint8_t ch)
fec_log[ch].total++;
fec_log[ch].xfun++;
dbg("%s: XFUN\r\n", __FUNCTION__);
fec_eth_stop(ch);
//fec_eth_stop(ch);
}
if (event & MCF_FEC_EIR_RL)
@@ -1271,6 +1276,10 @@ static void fec_irq_handler(uint8_t ch)
}
}
/*
* handler for FEC interrupts
* arg2 is a pointer to the nif in this case
*/
int fec0_interrupt_handler(void* arg1, void* arg2)
{
(void) arg1;
@@ -1332,7 +1341,10 @@ void fec_eth_setup(uint8_t ch, uint8_t trcvr, uint8_t speed, uint8_t duplex, con
* Initialize the MII interface
*/
#if defined(MACHINE_FIREBEE)
am79c874_init(0, 0, speed, duplex);
if (am79c874_init(0, 0, speed, duplex))
dbg("%s: PHY init completed\r\n", __FUNCTION__);
else
dbg("%s: PHY init failed\r\n", __FUNCTION__);
#elif defined(MACHINE_M548X)
bcm_5222_init(0, 0, speed, duplex);
#else
@@ -1385,6 +1397,7 @@ void fec_eth_stop(uint8_t ch)
*/
level = set_ipl(7);
dbg("%s: fec %d stopped\r\n", __FUNCTION__, ch);
/*
* Gracefully disable the receiver and transmitter
*/

View File

@@ -11,7 +11,7 @@
#include "bas_printf.h"
#include <stddef.h>
#define DBG_FECBD
//#define DBG_FECBD
#ifdef DBG_FECBD
#define dbg(format, arg...) do { xprintf("DEBUG: " format, ##arg); } while (0)
#else

View File

@@ -11,7 +11,7 @@
#include <stddef.h>
#define IP_DEBUG
//#define IP_DEBUG
#if defined(IP_DEBUG)
#define dbg(format, arg...) do { xprintf("DEBUG: " format, ##arg); } while (0)
#else

View File

@@ -12,7 +12,7 @@
#include "bas_printf.h"
#define DBG_NBUF
//#define DBG_NBUF
#if defined(DBG_NBUF)
#define dbg(format, arg...) do { xprintf("DEBUG: " format, ##arg); } while (0)
#else

View File

@@ -12,7 +12,7 @@
#include "MCF5475.h"
#include "interrupts.h"
#define DBG_TMR
//#define DBG_TMR
#ifdef DBG_TMR
#define dbg(format, arg...) do { xprintf("DEBUG: " format, ##arg); } while (0)
#else

View File

@@ -12,7 +12,7 @@
#include "net.h"
#include <stddef.h>
#define DBG_UDP
//#define DBG_UDP
#if defined(DBG_UDP)
#define dbg(format, arg...) do { xprintf("DEBUG: " format "\r\n", ##arg); } while (0)
#else