diff options
| -rw-r--r-- | firmware/microblaze/apps/txrx_uhd.c | 2 | ||||
| -rw-r--r-- | firmware/microblaze/lib/banal.h | 18 | ||||
| -rw-r--r-- | firmware/microblaze/lib/net_common.c | 11 | ||||
| -rw-r--r-- | firmware/microblaze/lib/net_common.h | 7 | ||||
| -rw-r--r-- | firmware/microblaze/lib/pkt_ctrl.c | 23 | ||||
| -rw-r--r-- | firmware/microblaze/lib/pkt_ctrl.h | 7 | ||||
| -rw-r--r-- | firmware/microblaze/lib/u2_init.c | 10 | 
7 files changed, 23 insertions, 55 deletions
| diff --git a/firmware/microblaze/apps/txrx_uhd.c b/firmware/microblaze/apps/txrx_uhd.c index 741167c0e..6f852bb18 100644 --- a/firmware/microblaze/apps/txrx_uhd.c +++ b/firmware/microblaze/apps/txrx_uhd.c @@ -349,7 +349,7 @@ main(void)    //1) register the addresses into the network stack    register_addrs(ethernet_mac_addr(), get_ip_addr()); -  pkt_ctrl_register_addrs(ethernet_mac_addr(), get_ip_addr()); +  pkt_ctrl_register_ip_addr(get_ip_addr());    //2) register callbacks for udp ports we service    register_udp_listener(USRP2_UDP_CTRL_PORT, handle_udp_ctrl_packet); diff --git a/firmware/microblaze/lib/banal.h b/firmware/microblaze/lib/banal.h index 634234350..eb7ed509a 100644 --- a/firmware/microblaze/lib/banal.h +++ b/firmware/microblaze/lib/banal.h @@ -19,27 +19,9 @@  #define INCLUDED_BANAL_H  #include <stdint.h> -#include <lwip/ip_addr.h>  #define dimof(x) (sizeof(x)/sizeof(x[0])) -/* - * 1's complement sum for IP and UDP headers - * - * init chksum to zero to start. - */ -static inline unsigned int -CHKSUM(unsigned int x, unsigned int *chksum) -{ -  *chksum += x; -  *chksum = (*chksum & 0xffff) + (*chksum>>16); -  *chksum = (*chksum & 0xffff) + (*chksum>>16); -  return x; -} - -unsigned int  -chksum_buffer(unsigned short *buf, int nshorts, unsigned int initial_chksum); -  //-------------- unsigned get_int 8, 16, 32, 64 --------------//  static inline uint8_t diff --git a/firmware/microblaze/lib/net_common.c b/firmware/microblaze/lib/net_common.c index e9b633b13..9804ae4c5 100644 --- a/firmware/microblaze/lib/net_common.c +++ b/firmware/microblaze/lib/net_common.c @@ -162,7 +162,15 @@ send_pkt(eth_mac_addr_t dst, int ethertype,    //printf("sent %d bytes\n", total_len);  } -unsigned int  +unsigned int CHKSUM(unsigned int x, unsigned int *chksum) +{ +  *chksum += x; +  *chksum = (*chksum & 0xffff) + (*chksum>>16); +  *chksum = (*chksum & 0xffff) + (*chksum>>16); +  return x; +} + +static unsigned int  chksum_buffer(unsigned short *buf, int nshorts, unsigned int initial_chksum)  {    unsigned int chksum = initial_chksum; @@ -172,7 +180,6 @@ chksum_buffer(unsigned short *buf, int nshorts, unsigned int initial_chksum)    return chksum;  } -  void  send_ip_pkt(struct ip_addr dst, int protocol,  	    const void *buf0, size_t len0, diff --git a/firmware/microblaze/lib/net_common.h b/firmware/microblaze/lib/net_common.h index 5e364adeb..4004ca6e6 100644 --- a/firmware/microblaze/lib/net_common.h +++ b/firmware/microblaze/lib/net_common.h @@ -23,6 +23,13 @@  #include <net/socket_address.h>  #include <net/eth_mac_addr.h> +/* + * 1's complement sum for IP and UDP headers + * + * init chksum to zero to start. + */ +unsigned int CHKSUM(unsigned int x, unsigned int *chksum); +  typedef void (*udp_receiver_t)(struct socket_address src, struct socket_address dst,  			       unsigned char *payload, int payload_len); diff --git a/firmware/microblaze/lib/pkt_ctrl.c b/firmware/microblaze/lib/pkt_ctrl.c index 52ba80e3a..9870a1f8a 100644 --- a/firmware/microblaze/lib/pkt_ctrl.c +++ b/firmware/microblaze/lib/pkt_ctrl.c @@ -47,28 +47,15 @@ static bool is_status_bit_set(int bit){  #define MODE_BIT 2  #define CLR_BIT 8 -void pkt_ctrl_register_addrs( -    const eth_mac_addr_t *mac_addr, const struct ip_addr *ip_addr -){ +void pkt_ctrl_register_ip_addr(const struct ip_addr *ip_addr){      //program in the ip addr -    set_control(0x1 << 4, 0x7 << 4); +    set_control(0x1 << 4, 0x3 << 4);      set_control((ip_addr->addr & 0x0000ffff) << 16, 0xffff << 16); -    set_control(0x2 << 4, 0x7 << 4); +    set_control(0x2 << 4, 0x3 << 4);      set_control((ip_addr->addr & 0xffff0000) << 0,  0xffff << 16); -    //program in the mac addr -    set_control(0x3 << 4, 0x7 << 4); -    set_control((uint32_t)mac_addr->addr[0] << 16, 0x00ff << 16); -    set_control((uint32_t)mac_addr->addr[1] << 24, 0xff00 << 16); -    set_control(0x4 << 4, 0x7 << 4); -    set_control((uint32_t)mac_addr->addr[2] << 16, 0x00ff << 16); -    set_control((uint32_t)mac_addr->addr[3] << 24, 0xff00 << 16); -    set_control(0x5 << 4, 0x7 << 4); -    set_control((uint32_t)mac_addr->addr[4] << 16, 0x00ff << 16); -    set_control((uint32_t)mac_addr->addr[5] << 24, 0xff00 << 16); -      //clear cmd -    set_control(0x0, 0x7 << 4); +    set_control(0x0, 0x3 << 4);  }  void pkt_ctrl_set_routing_mode(pkt_ctrl_routing_mode_t mode){ @@ -80,8 +67,6 @@ void pkt_ctrl_set_routing_mode(pkt_ctrl_routing_mode_t mode){          set_control_bit(MODE_BIT);          break;      } -    set_control_bit(CLR_BIT); //clear after mode change -    clr_control_bit(CLR_BIT); //unset the clear signal  }  void *pkt_ctrl_claim_incoming_buffer(size_t *num_lines){ diff --git a/firmware/microblaze/lib/pkt_ctrl.h b/firmware/microblaze/lib/pkt_ctrl.h index 761209530..2e175bca0 100644 --- a/firmware/microblaze/lib/pkt_ctrl.h +++ b/firmware/microblaze/lib/pkt_ctrl.h @@ -20,17 +20,14 @@  #include <stddef.h>  #include <lwip/ip_addr.h> -#include <net/eth_mac_addr.h>  typedef enum {      PKT_CTRL_ROUTING_MODE_SLAVE,      PKT_CTRL_ROUTING_MODE_MASTER,  } pkt_ctrl_routing_mode_t; -//! Register this devices addresses into the router -void pkt_ctrl_register_addrs( -    const eth_mac_addr_t *mac_addr, const struct ip_addr *ip_addr -); +//! Register the IP address into the router +void pkt_ctrl_register_ip_addr(const struct ip_addr *ip_addr);  //! Set the routing mode for this device  void pkt_ctrl_set_routing_mode(pkt_ctrl_routing_mode_t mode); diff --git a/firmware/microblaze/lib/u2_init.c b/firmware/microblaze/lib/u2_init.c index 9302c90b2..191a0e816 100644 --- a/firmware/microblaze/lib/u2_init.c +++ b/firmware/microblaze/lib/u2_init.c @@ -27,16 +27,6 @@  #include "usrp2/fw_common.h"  #include "nonstdio.h" -unsigned char u2_hw_rev_major; -unsigned char u2_hw_rev_minor; - -static inline void -get_hw_rev(void) -{ -  bool ok = eeprom_read(USRP2_I2C_ADDR_MBOARD, USRP2_EE_MBOARD_REV, &u2_hw_rev_minor, 1); -  ok &= eeprom_read(USRP2_I2C_ADDR_MBOARD, USRP2_EE_MBOARD_REV+1, &u2_hw_rev_major, 1); -} -  /*   * We ought to arrange for this to be called before main, but for now,   * we require that the user's main call u2_init as the first thing... | 
