diff options
author | Josh Blum <josh@joshknows.com> | 2011-01-07 11:51:31 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-01-07 11:51:31 -0800 |
commit | e0005a2a00b49b1c6802fd7e78e8f92ff22a6bce (patch) | |
tree | 6e2fcaa7c44648402d2ffcb830819d9d63d893a0 /firmware | |
parent | f879a50989a35a2ba4886630164d71353a560c2e (diff) | |
download | uhd-e0005a2a00b49b1c6802fd7e78e8f92ff22a6bce.tar.gz uhd-e0005a2a00b49b1c6802fd7e78e8f92ff22a6bce.tar.bz2 uhd-e0005a2a00b49b1c6802fd7e78e8f92ff22a6bce.zip |
usrp2: tweaking firmware
added delay to the link up/down code to space out calls
removed the pkt_ctrl init and just do it when the mode changes
tweaked the addr printing
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/zpu/apps/txrx_uhd.c | 19 | ||||
-rw-r--r-- | firmware/zpu/lib/nonstdio.h | 9 | ||||
-rw-r--r-- | firmware/zpu/lib/pkt_ctrl.c | 49 | ||||
-rw-r--r-- | firmware/zpu/lib/pkt_ctrl.h | 3 | ||||
-rw-r--r-- | firmware/zpu/lib/print_addrs.c | 9 |
5 files changed, 37 insertions, 52 deletions
diff --git a/firmware/zpu/apps/txrx_uhd.c b/firmware/zpu/apps/txrx_uhd.c index cd66c18f1..3fcda8a4e 100644 --- a/firmware/zpu/apps/txrx_uhd.c +++ b/firmware/zpu/apps/txrx_uhd.c @@ -77,14 +77,14 @@ static void handle_udp_data_packet( sr_udp_sm->dsp0_port = (((uint32_t)dst.port) << 16) | src.port; printf("Storing for fast path:\n"); printf(" source mac addr: "); - print_mac_addr(fp_mac_addr_src.addr); newline(); + print_mac_addr(&fp_mac_addr_src); newline(); printf(" source ip addr: "); - print_ip_addr(&fp_socket_src.addr); newline(); + print_ip_addr(&fp_socket_src); newline(); printf(" source udp port: %d\n", fp_socket_src.port); printf(" destination mac addr: "); - print_mac_addr(fp_mac_addr_dst.addr); newline(); + print_mac_addr(&fp_mac_addr_dst); newline(); printf(" destination ip addr: "); - print_ip_addr(&fp_socket_dst.addr); newline(); + print_ip_addr(&fp_socket_dst); newline(); printf(" destination udp port: %d\n", fp_socket_dst.port); newline(); @@ -332,7 +332,6 @@ int main(void) { u2_init(); - pkt_ctrl_init(); //we do this to see if we should set a default ip addr or not #ifdef USRP2P @@ -344,9 +343,8 @@ main(void) } #endif - putstr("\nTxRx-NEWETH\n"); - print_mac_addr(ethernet_mac_addr()->addr); - newline(); + putstr("\nTxRx-UHD-ZPU\n"); + print_mac_addr(ethernet_mac_addr()); newline(); print_ip_addr(get_ip_addr()); newline(); printf("FPGA compatibility number: %d\n", USRP2_FPGA_COMPAT_NUM); printf("Firmware compatibility number: %d\n", USRP2_FW_COMPAT_NUM); @@ -364,9 +362,8 @@ main(void) register_udp_listener(USRP2_UDP_UPDATE_PORT, handle_udp_fw_update_packet); #endif - //3) set the routing mode to slave and send a garp + //3) set the routing mode to slave to set defaults pkt_ctrl_set_routing_mode(PKT_CTRL_ROUTING_MODE_SLAVE); - send_gratuitous_arp(); //4) setup ethernet hardware to bring the link up ethernet_register_link_changed_callback(link_changed_callback); @@ -390,7 +387,7 @@ main(void) } if (pending & PIC_OVERRUN_INT){ - pic_regs->pending = PIC_OVERRUN_INT; // clear pending interrupt + pic_regs->pending = PIC_OVERRUN_INT; // clear interrupt putchar('O'); } } diff --git a/firmware/zpu/lib/nonstdio.h b/firmware/zpu/lib/nonstdio.h index 6aca7ed9a..2c4aeb961 100644 --- a/firmware/zpu/lib/nonstdio.h +++ b/firmware/zpu/lib/nonstdio.h @@ -38,13 +38,10 @@ void puthex32_nl(unsigned long x); #define puthex_nl puthex32_nl void newline(); // putchar('\n') -void print_mac_addr(const unsigned char addr[6]); -void print_uint64(uint64_t v); +void print_mac_addr(const void *addr); -void print_buffer(uint32_t *buf, size_t n); -//char *itoa(signed long value, char *result, int base); -//void reverse(char s[]); +void print_ip_addr(const void *addr); -void print_ip_addr(const void *t); +void print_buffer(uint32_t *buf, size_t n); #endif /* INCLUDED_NONSTDIO_H */ diff --git a/firmware/zpu/lib/pkt_ctrl.c b/firmware/zpu/lib/pkt_ctrl.c index df5851c35..341ad44e1 100644 --- a/firmware/zpu/lib/pkt_ctrl.c +++ b/firmware/zpu/lib/pkt_ctrl.c @@ -18,20 +18,7 @@ #include "pkt_ctrl.h" #include "memory_map.h" #include <nonstdio.h> - -void pkt_ctrl_program_inspector( - const struct ip_addr *ip_addr, uint16_t data_port -){ - router_ctrl->ip_addr = ip_addr->addr; - router_ctrl->data_ports = data_port; -} - -void pkt_ctrl_set_routing_mode(pkt_ctrl_routing_mode_t mode){ - switch(mode){ - case PKT_CTRL_ROUTING_MODE_SLAVE: router_ctrl->mode_ctrl = 0; break; - case PKT_CTRL_ROUTING_MODE_MASTER: router_ctrl->mode_ctrl = 1; break; - } -} +#include <mdelay.h> //status signals from WB into PR #define CPU_STAT_RD_DONE (1 << 0) @@ -51,7 +38,22 @@ void pkt_ctrl_set_routing_mode(pkt_ctrl_routing_mode_t mode){ #define CPU_CTRL_WR_CLEAR (1 << 2) #define CPU_CTRL_WR_START (1 << 3) -static bool i_am_writing; +void pkt_ctrl_program_inspector( + const struct ip_addr *ip_addr, uint16_t data_port +){ + router_ctrl->ip_addr = ip_addr->addr; + router_ctrl->data_ports = data_port; +} + +void pkt_ctrl_set_routing_mode(pkt_ctrl_routing_mode_t mode){ + mdelay(100); //give a little delay to space out subsequent calls + switch(mode){ + case PKT_CTRL_ROUTING_MODE_SLAVE: router_ctrl->mode_ctrl = 0; break; + case PKT_CTRL_ROUTING_MODE_MASTER: router_ctrl->mode_ctrl = 1; break; + } + router_ctrl->iface_ctrl = CPU_CTRL_WR_CLEAR; //reset the write state machine + pkt_ctrl_release_incoming_buffer(); //reset the read state machine, and read +} static inline void cpu_stat_wait_for(int bm){ while((router_status->status & bm) == 0){ @@ -59,11 +61,6 @@ static inline void cpu_stat_wait_for(int bm){ } } -void pkt_ctrl_init(void){ - router_ctrl->iface_ctrl = CPU_CTRL_WR_CLEAR | CPU_CTRL_RD_START; - i_am_writing = false; -} - void *pkt_ctrl_claim_incoming_buffer(size_t *num_lines){ uint32_t status = router_status->status; @@ -74,7 +71,7 @@ void *pkt_ctrl_claim_incoming_buffer(size_t *num_lines){ } //if error: drop the packet and start a new read - else if (status & CPU_STAT_RD_EROR){ + if (status & CPU_STAT_RD_EROR){ putstr("E"); pkt_ctrl_release_incoming_buffer(); } @@ -91,12 +88,6 @@ void pkt_ctrl_release_incoming_buffer(void){ } void *pkt_ctrl_claim_outgoing_buffer(void){ - if (i_am_writing){ - //wait for the write to become done - cpu_stat_wait_for(CPU_STAT_WR_DONE); - router_ctrl->iface_ctrl = CPU_CTRL_WR_CLEAR; - i_am_writing = false; - } //wait for idle and return the buffer cpu_stat_wait_for(CPU_STAT_WR_IDLE); return ((uint32_t *) ROUTER_RAM_BASE); @@ -105,5 +96,7 @@ void *pkt_ctrl_claim_outgoing_buffer(void){ void pkt_ctrl_commit_outgoing_buffer(size_t num_lines){ //start a new write with the given length router_ctrl->iface_ctrl = ((num_lines & 0xffff) << 16) | CPU_CTRL_WR_START; - i_am_writing = true; + //wait for the write to become done + cpu_stat_wait_for(CPU_STAT_WR_DONE); + router_ctrl->iface_ctrl = CPU_CTRL_WR_CLEAR; } diff --git a/firmware/zpu/lib/pkt_ctrl.h b/firmware/zpu/lib/pkt_ctrl.h index 06b81538d..410ffdaa4 100644 --- a/firmware/zpu/lib/pkt_ctrl.h +++ b/firmware/zpu/lib/pkt_ctrl.h @@ -23,9 +23,6 @@ #include <stdbool.h> #include <lwip/ip_addr.h> -//! Initialize the packet router into a good state -void pkt_ctrl_init(void); - typedef enum { PKT_CTRL_ROUTING_MODE_SLAVE, PKT_CTRL_ROUTING_MODE_MASTER, diff --git a/firmware/zpu/lib/print_addrs.c b/firmware/zpu/lib/print_addrs.c index 29601c47c..fa2a49fc3 100644 --- a/firmware/zpu/lib/print_addrs.c +++ b/firmware/zpu/lib/print_addrs.c @@ -18,15 +18,16 @@ #include "nonstdio.h" void -print_mac_addr(const unsigned char addr[6]) +print_mac_addr(const void *addr) { + uint8_t *p = (uint8_t *)addr; for(size_t i = 0; i < 6; i++){ if(i) putchar(':'); - puthex8(addr[i]); + puthex8(p[i]); } } -void print_ip_addr(const void *t){ - uint8_t *p = (uint8_t *)t; +void print_ip_addr(const void *addr){ + uint8_t *p = (uint8_t *)addr; printf("%d.%d.%d.%d", p[0], p[1], p[2], p[3]); } |