From 7eea883c377f64862a4d83f1b33a83fdf3cfc392 Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Mon, 31 Aug 2009 12:08:30 -0700 Subject: Merged SVN matt/new_eth r10782:11633 into new_eth * svn diff http://gnuradio.org/svn/branches/developers/matt/new_eth -r10782:11633 * Patch applied with no conflicts or fuzz. --- usrp2/firmware/lib/eth_mac.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'usrp2/firmware/lib/eth_mac.c') diff --git a/usrp2/firmware/lib/eth_mac.c b/usrp2/firmware/lib/eth_mac.c index 5fadaf40b..41690af95 100644 --- a/usrp2/firmware/lib/eth_mac.c +++ b/usrp2/firmware/lib/eth_mac.c @@ -21,7 +21,7 @@ #include "bool.h" #include "eth_phy.h" // for simulation constants #include "mdelay.h" - +#include "stdio.h" #define PHY_ADDR 1 @@ -29,7 +29,11 @@ void eth_mac_set_addr(const u2_mac_addr_t *src) { int i; - + eth_mac->ucast_hi = ((unsigned int)src->addr[0])<<8 + ((unsigned int)src->addr[1]); + eth_mac->ucast_lo = ((unsigned int)src->addr[2])<<24 + ((unsigned int)src->addr[3])<<16 + + ((unsigned int)src->addr[4])<<8 +((unsigned int)src->addr[5]); + + /* // tell mac our source address and enable automatic insertion on Tx. eth_mac->mac_tx_add_prom_wr = 0; // just in case for (i = 0; i < 6; i++){ @@ -53,6 +57,8 @@ eth_mac_set_addr(const u2_mac_addr_t *src) mdelay(1); } // eth_mac->mac_rx_add_chk_en = 1; // FIXME enable when everything's working + + */ } @@ -62,14 +68,14 @@ eth_mac_init(const u2_mac_addr_t *src) eth_mac->miimoder = 25; // divider from CPU clock (50MHz/25 = 2MHz) eth_mac_set_addr(src); - + eth_mac->settings = 0x39; // set rx flow control high and low water marks // unsigned int lwmark = (2*2048 + 64)/4; // 2 * 2048-byte frames + 1 * 64-byte pause frame // eth_mac->fc_hwmark = lwmark + 2048/4; // plus a 2048-byte frame - eth_mac->fc_lwmark = 600; // there are currently 2047 lines in the fifo - eth_mac->fc_hwmark = 1200; - eth_mac->fc_padtime = 1700; // how long before flow control runs out do we + // eth_mac->fc_lwmark = 600; // there are currently 2047 lines in the fifo + // eth_mac->fc_hwmark = 1200; + //eth_mac->fc_padtime = 1700; // how long before flow control runs out do we // request a re-pause. Units of 8ns (bytes) //eth_mac->tx_pause_en = 0; // pay attn to pause frames sent to us @@ -80,8 +86,8 @@ eth_mac_init(const u2_mac_addr_t *src) int eth_mac_read_rmon(int addr) { - int t; - + int t = 0; + /* eth_mac->rmon_rd_addr = addr; eth_mac->rmon_rd_apply = 1; while(eth_mac->rmon_rd_grant == 0) @@ -89,6 +95,7 @@ eth_mac_read_rmon(int addr) t = eth_mac->rmon_rd_dout; eth_mac->rmon_rd_apply = 0; + */ return t; } @@ -111,6 +118,7 @@ eth_mac_miim_read(int addr) while((eth_mac->miistatus & MIIS_BUSY) != 0) ; + printf("MIIM-READ ADDR %d DATA %d\n",addr, eth_mac->miirx_data); return eth_mac->miirx_data; } @@ -122,6 +130,7 @@ eth_mac_miim_write(int addr, int value) eth_mac->miitx_data = value; eth_mac->miicommand = MIIC_WCTRLDATA; + printf("MIIM-WRITE ADDR %d VAL %d\n",addr,value); while((eth_mac->miistatus & MIIS_BUSY) != 0) ; } -- cgit From 7e013c464ce04a7dc559a3f2798559c0716ccae8 Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Tue, 1 Sep 2009 18:43:07 -0700 Subject: tell s/w link is up. additional debugging output --- usrp2/firmware/lib/eth_mac.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'usrp2/firmware/lib/eth_mac.c') diff --git a/usrp2/firmware/lib/eth_mac.c b/usrp2/firmware/lib/eth_mac.c index 41690af95..f38ea65f9 100644 --- a/usrp2/firmware/lib/eth_mac.c +++ b/usrp2/firmware/lib/eth_mac.c @@ -118,8 +118,9 @@ eth_mac_miim_read(int addr) while((eth_mac->miistatus & MIIS_BUSY) != 0) ; - printf("MIIM-READ ADDR %d DATA %d\n",addr, eth_mac->miirx_data); - return eth_mac->miirx_data; + int r = eth_mac->miirx_data; + printf("MIIM-READ ADDR 0x%x DATA 0x%x\n",addr, r); + return r; } void @@ -130,7 +131,7 @@ eth_mac_miim_write(int addr, int value) eth_mac->miitx_data = value; eth_mac->miicommand = MIIC_WCTRLDATA; - printf("MIIM-WRITE ADDR %d VAL %d\n",addr,value); + printf("MIIM-WRITE ADDR 0x%x VAL 0x%x\n",addr,value); while((eth_mac->miistatus & MIIS_BUSY) != 0) ; } -- cgit From 7cb806f71a3bcc52c3c2e5688a9b6b48e3401615 Mon Sep 17 00:00:00 2001 From: Matt Ettus Date: Fri, 4 Sep 2009 15:31:26 -0700 Subject: properly set the address filter --- usrp2/firmware/lib/eth_mac.c | 47 ++++++++++++-------------------------------- 1 file changed, 13 insertions(+), 34 deletions(-) (limited to 'usrp2/firmware/lib/eth_mac.c') diff --git a/usrp2/firmware/lib/eth_mac.c b/usrp2/firmware/lib/eth_mac.c index f38ea65f9..becd93644 100644 --- a/usrp2/firmware/lib/eth_mac.c +++ b/usrp2/firmware/lib/eth_mac.c @@ -28,37 +28,15 @@ void eth_mac_set_addr(const u2_mac_addr_t *src) { - int i; - eth_mac->ucast_hi = ((unsigned int)src->addr[0])<<8 + ((unsigned int)src->addr[1]); - eth_mac->ucast_lo = ((unsigned int)src->addr[2])<<24 + ((unsigned int)src->addr[3])<<16 + - ((unsigned int)src->addr[4])<<8 +((unsigned int)src->addr[5]); - - /* - // tell mac our source address and enable automatic insertion on Tx. - eth_mac->mac_tx_add_prom_wr = 0; // just in case - for (i = 0; i < 6; i++){ - eth_mac->mac_tx_add_prom_add = i; - eth_mac->mac_tx_add_prom_data = src->addr[i]; - eth_mac->mac_tx_add_prom_wr = 1; - mdelay(1); - eth_mac->mac_tx_add_prom_wr = 0; - mdelay(1); - } - eth_mac->mac_tx_add_en = 1; // overwrite pkt src addr field with this stuff - - // set up receive destination address filter - eth_mac->mac_rx_add_prom_wr = 0; // just in case - for (i = 0; i < 6; i++){ - eth_mac->mac_rx_add_prom_add = i; - eth_mac->mac_rx_add_prom_data = src->addr[i]; - eth_mac->mac_rx_add_prom_wr = 1; - mdelay(1); - eth_mac->mac_rx_add_prom_wr = 0; - mdelay(1); - } - // eth_mac->mac_rx_add_chk_en = 1; // FIXME enable when everything's working - - */ + eth_mac->ucast_hi = + (((unsigned int)src->addr[0])<<8) + + ((unsigned int)src->addr[1]); + eth_mac->ucast_lo = + (((unsigned int)src->addr[2])<<24) + + (((unsigned int)src->addr[3])<<16) + + (((unsigned int)src->addr[4])<<8) + + (((unsigned int)src->addr[5])); + printf("RDBK %x:%x\n",eth_mac->ucast_hi,eth_mac->ucast_lo); } @@ -68,7 +46,8 @@ eth_mac_init(const u2_mac_addr_t *src) eth_mac->miimoder = 25; // divider from CPU clock (50MHz/25 = 2MHz) eth_mac_set_addr(src); - eth_mac->settings = 0x39; + eth_mac->settings = MAC_SET_PAUSE_EN | MAC_SET_PASS_BCAST | MAC_SET_PASS_UCAST; // 0x39; + // set rx flow control high and low water marks // unsigned int lwmark = (2*2048 + 64)/4; // 2 * 2048-byte frames + 1 * 64-byte pause frame // eth_mac->fc_hwmark = lwmark + 2048/4; // plus a 2048-byte frame @@ -119,7 +98,7 @@ eth_mac_miim_read(int addr) ; int r = eth_mac->miirx_data; - printf("MIIM-READ ADDR 0x%x DATA 0x%x\n",addr, r); + //printf("MIIM-READ ADDR 0x%x DATA 0x%x\n",addr, r); return r; } @@ -131,7 +110,7 @@ eth_mac_miim_write(int addr, int value) eth_mac->miitx_data = value; eth_mac->miicommand = MIIC_WCTRLDATA; - printf("MIIM-WRITE ADDR 0x%x VAL 0x%x\n",addr,value); + //printf("MIIM-WRITE ADDR 0x%x VAL 0x%x\n",addr,value); while((eth_mac->miistatus & MIIS_BUSY) != 0) ; } -- cgit From 9e05f0770b92f9c85f09e3629f875011e8f1ac24 Mon Sep 17 00:00:00 2001 From: Matt Ettus Date: Fri, 4 Sep 2009 22:23:27 -0700 Subject: Implement Eth flow control using pause frames Not fully tested, but it seems to work without frame errors, sequence number errors or ethernet overruns. Still of course will get tx underruns on a slow machine, and the transmitted signal has some issues though. --- usrp2/firmware/lib/eth_mac.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'usrp2/firmware/lib/eth_mac.c') diff --git a/usrp2/firmware/lib/eth_mac.c b/usrp2/firmware/lib/eth_mac.c index becd93644..2ef1f73f4 100644 --- a/usrp2/firmware/lib/eth_mac.c +++ b/usrp2/firmware/lib/eth_mac.c @@ -46,7 +46,10 @@ eth_mac_init(const u2_mac_addr_t *src) eth_mac->miimoder = 25; // divider from CPU clock (50MHz/25 = 2MHz) eth_mac_set_addr(src); - eth_mac->settings = MAC_SET_PAUSE_EN | MAC_SET_PASS_BCAST | MAC_SET_PASS_UCAST; // 0x39; + eth_mac->settings = MAC_SET_PAUSE_EN | MAC_SET_PASS_BCAST | MAC_SET_PASS_UCAST | MAC_SET_PAUSE_SEND_EN; + + eth_mac->pause_time = 38; + eth_mac->pause_thresh = 1200; // set rx flow control high and low water marks // unsigned int lwmark = (2*2048 + 64)/4; // 2 * 2048-byte frames + 1 * 64-byte pause frame -- cgit From 147de5cd3e57a07914673a31fb73a35ebf18b3a2 Mon Sep 17 00:00:00 2001 From: Matt Ettus Date: Wed, 30 Sep 2009 19:55:05 -0700 Subject: remove debugging code --- usrp2/firmware/lib/eth_mac.c | 1 - 1 file changed, 1 deletion(-) (limited to 'usrp2/firmware/lib/eth_mac.c') diff --git a/usrp2/firmware/lib/eth_mac.c b/usrp2/firmware/lib/eth_mac.c index 2ef1f73f4..88051dca0 100644 --- a/usrp2/firmware/lib/eth_mac.c +++ b/usrp2/firmware/lib/eth_mac.c @@ -36,7 +36,6 @@ eth_mac_set_addr(const u2_mac_addr_t *src) (((unsigned int)src->addr[3])<<16) + (((unsigned int)src->addr[4])<<8) + (((unsigned int)src->addr[5])); - printf("RDBK %x:%x\n",eth_mac->ucast_hi,eth_mac->ucast_lo); } -- cgit