From 6f2d1b519a14d75a1b6529c6e7738e41329f42c8 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 14 Nov 2010 13:38:42 -0800 Subject: usrp2: pretty much gutted the buffer pool stuff with other misc changes, not in working shape --- firmware/microblaze/apps/txrx_uhd.c | 111 ++--------- firmware/microblaze/lib/Makefile.inc | 5 +- firmware/microblaze/lib/banal.h | 5 +- firmware/microblaze/lib/bsm12.c | 319 ------------------------------- firmware/microblaze/lib/bsm12.h | 83 -------- firmware/microblaze/lib/buffer_pool.c | 72 ------- firmware/microblaze/lib/buffer_pool.h | 75 -------- firmware/microblaze/lib/compiler.h | 3 +- firmware/microblaze/lib/dbsm.c | 299 ----------------------------- firmware/microblaze/lib/dbsm.h | 90 --------- firmware/microblaze/lib/net_common.c | 36 ++-- firmware/microblaze/lib/net_common.h | 10 - firmware/microblaze/lib/nonstdio.h | 2 + firmware/microblaze/lib/print_addrs.c | 32 ++++ firmware/microblaze/lib/print_mac_addr.c | 28 --- firmware/microblaze/lib/u2_init.c | 5 - firmware/microblaze/lib/usrp2_bytesex.h | 66 ------- firmware/microblaze/lib/wb16550.h | 98 ---------- 18 files changed, 66 insertions(+), 1273 deletions(-) delete mode 100644 firmware/microblaze/lib/bsm12.c delete mode 100644 firmware/microblaze/lib/bsm12.h delete mode 100644 firmware/microblaze/lib/buffer_pool.c delete mode 100644 firmware/microblaze/lib/buffer_pool.h delete mode 100644 firmware/microblaze/lib/dbsm.c delete mode 100644 firmware/microblaze/lib/dbsm.h create mode 100644 firmware/microblaze/lib/print_addrs.c delete mode 100644 firmware/microblaze/lib/print_mac_addr.c delete mode 100644 firmware/microblaze/lib/usrp2_bytesex.h delete mode 100644 firmware/microblaze/lib/wb16550.h diff --git a/firmware/microblaze/apps/txrx_uhd.c b/firmware/microblaze/apps/txrx_uhd.c index 9c1873e1c..2d001cfa8 100644 --- a/firmware/microblaze/apps/txrx_uhd.c +++ b/firmware/microblaze/apps/txrx_uhd.c @@ -28,12 +28,10 @@ #include "memory_map.h" #include "spi.h" #include "hal_io.h" -#include "buffer_pool.h" #include "pic.h" #include #include "ethernet.h" #include "nonstdio.h" -#include "dbsm.h" #include #include #include "memcpy_wa.h" @@ -48,82 +46,6 @@ #include #include "udp_fw_update.h" -/* - * Full duplex Tx and Rx between ethernet and DSP pipelines - * - * Buffer 1 is used by the cpu to send frames to the host. - * Buffers 2 and 3 are used to double-buffer the DSP Rx to eth flow - * Buffers 4 and 5 are used to double-buffer the eth to DSP Tx eth flow - */ -//#define CPU_RX_BUF 0 // eth -> cpu - -#define DSP_RX_BUF_0 2 // dsp rx -> eth (double buffer) -#define DSP_RX_BUF_1 3 // dsp rx -> eth -#define DSP_TX_BUF_0 4 // eth -> dsp tx (double buffer) -#define DSP_TX_BUF_1 5 // eth -> dsp tx - -/* - * ================================================================ - * configure DSP TX double buffering state machine (eth -> dsp) - * ================================================================ - */ - -// DSP Tx reads ethernet header words -#define DSP_TX_FIRST_LINE ((sizeof(padded_eth_hdr_t) + sizeof(struct ip_hdr) + sizeof(struct udp_hdr))/sizeof(uint32_t)) - -// Receive from ethernet -buf_cmd_args_t dsp_tx_recv_args = { - PORT_ETH, - 0, - BP_LAST_LINE -}; - -// send to DSP Tx -buf_cmd_args_t dsp_tx_send_args = { - PORT_DSP, - DSP_TX_FIRST_LINE, // starts just past transport header - 0 // filled in from last_line register -}; - -dbsm_t dsp_tx_sm; // the state machine - -/* - * ================================================================ - * configure DSP RX double buffering state machine (dsp -> eth) - * ================================================================ - */ - -static const uint32_t rx_ctrl_word = 1 << 16; - -// DSP Rx writes ethernet header words -#define DSP_RX_FIRST_LINE sizeof(rx_ctrl_word)/sizeof(uint32_t) - -static bool dbsm_rx_inspector(dbsm_t *sm, int buf_this){ - size_t num_lines = buffer_pool_status->last_line[buf_this]-DSP_RX_FIRST_LINE; - ((uint32_t*)buffer_ram(buf_this))[0] = (num_lines*sizeof(uint32_t)) | (1 << 16); - return false; -} - -// receive from DSP -buf_cmd_args_t dsp_rx_recv_args = { - PORT_DSP, - DSP_RX_FIRST_LINE, - BP_LAST_LINE -}; - -// send to ETH -buf_cmd_args_t dsp_rx_send_args = { - PORT_ETH, - 0, // starts with ethernet header in line 0 - 0, // filled in from list_line register -}; - -dbsm_t dsp_rx_sm; // the state machine - - -// The mac address of the host we're sending to. -eth_mac_addr_t host_mac_addr; - static void setup_network(void); // ---------------------------------------------------------------- @@ -136,11 +58,6 @@ static struct socket_address fp_socket_src, fp_socket_dst; void start_rx_streaming_cmd(void); void stop_rx_cmd(void); -static void print_ip_addr(const void *t){ - uint8_t *p = (uint8_t *)t; - printf("%d.%d.%d.%d", p[0], p[1], p[2], p[3]); -} - void handle_udp_data_packet( struct socket_address src, struct socket_address dst, unsigned char *payload, int payload_len @@ -167,7 +84,7 @@ void handle_udp_data_packet( setup_network(); // kick off the state machine - dbsm_start(&dsp_rx_sm); + //FIME dbsm_start(&dsp_rx_sm); } @@ -382,6 +299,7 @@ void handle_udp_ctrl_packet( * Return true if we handled it here, otherwise * it'll be passed on to the DSP Tx pipe */ +/* static bool eth_pkt_inspector(dbsm_t *sm, int bufno) { @@ -419,6 +337,7 @@ eth_pkt_inspector(dbsm_t *sm, int bufno) handle_eth_packet(buff, len); return true; } +*/ //------------------------------------------------------------------ @@ -486,10 +405,10 @@ static void setup_network(void){ inline static void buffer_irq_handler(unsigned irq) { - uint32_t status = buffer_pool_status->status; + //FIXME uint32_t status = buffer_pool_status->status; - dbsm_process_status(&dsp_tx_sm, status); - dbsm_process_status(&dsp_rx_sm, status); + //FIXME dbsm_process_status(&dsp_tx_sm, status); + //FIXME dbsm_process_status(&dsp_rx_sm, status); } int @@ -529,23 +448,23 @@ main(void) // initialize double buffering state machine for ethernet -> DSP Tx - dbsm_init(&dsp_tx_sm, DSP_TX_BUF_0, - &dsp_tx_recv_args, &dsp_tx_send_args, - eth_pkt_inspector); + //FIXME dbsm_init(&dsp_tx_sm, DSP_TX_BUF_0, +//FIXME &dsp_tx_recv_args, &dsp_tx_send_args, +//FIXME eth_pkt_inspector); // initialize double buffering state machine for DSP RX -> Ethernet - dbsm_init(&dsp_rx_sm, DSP_RX_BUF_0, - &dsp_rx_recv_args, &dsp_rx_send_args, - dbsm_rx_inspector); +//FIXME dbsm_init(&dsp_rx_sm, DSP_RX_BUF_0, +//FIXME &dsp_rx_recv_args, &dsp_rx_send_args, +//FIXME dbsm_rx_inspector); sr_tx_ctrl->clear_state = 1; - bp_clear_buf(DSP_TX_BUF_0); - bp_clear_buf(DSP_TX_BUF_1); +//FIXME bp_clear_buf(DSP_TX_BUF_0); +//FIXME bp_clear_buf(DSP_TX_BUF_1); // kick off the state machine - dbsm_start(&dsp_tx_sm); +//FIXME dbsm_start(&dsp_tx_sm); //int which = 0; diff --git a/firmware/microblaze/lib/Makefile.inc b/firmware/microblaze/lib/Makefile.inc index 38c630df4..1ca375861 100644 --- a/firmware/microblaze/lib/Makefile.inc +++ b/firmware/microblaze/lib/Makefile.inc @@ -21,10 +21,7 @@ COMMON_SRCS = \ $(top_srcdir)/lib/u2_init.c \ $(top_srcdir)/lib/abort.c \ $(top_srcdir)/lib/ad9510.c \ - $(top_srcdir)/lib/bsm12.c \ - $(top_srcdir)/lib/buffer_pool.c \ $(top_srcdir)/lib/clocks.c \ - $(top_srcdir)/lib/dbsm.c \ $(top_srcdir)/lib/eeprom.c \ $(top_srcdir)/lib/eth_addrs.c \ $(top_srcdir)/lib/eth_mac.c \ @@ -39,7 +36,7 @@ COMMON_SRCS = \ $(top_srcdir)/lib/memset_wa.c \ $(top_srcdir)/lib/nonstdio.c \ $(top_srcdir)/lib/pic.c \ - $(top_srcdir)/lib/print_mac_addr.c \ + $(top_srcdir)/lib/print_addrs.c \ $(top_srcdir)/lib/print_rmon_regs.c \ $(top_srcdir)/lib/print_buffer.c \ $(top_srcdir)/lib/printf.c \ diff --git a/firmware/microblaze/lib/banal.h b/firmware/microblaze/lib/banal.h index 7b3c71a20..634234350 100644 --- a/firmware/microblaze/lib/banal.h +++ b/firmware/microblaze/lib/banal.h @@ -21,6 +21,8 @@ #include #include +#define dimof(x) (sizeof(x)/sizeof(x[0])) + /* * 1's complement sum for IP and UDP headers * @@ -84,7 +86,4 @@ get_int64(const unsigned char *s) return get_uint64(s); } -void -print_ip(struct ip_addr ip); - #endif /* INCLUDED_BANAL_H */ diff --git a/firmware/microblaze/lib/bsm12.c b/firmware/microblaze/lib/bsm12.c deleted file mode 100644 index 3f17fe42d..000000000 --- a/firmware/microblaze/lib/bsm12.c +++ /dev/null @@ -1,319 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 Free Software Foundation, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* - * buffer state machine: 1 input to two outputs - * - * Typically used to read packets from the ethernet and then after inspecting, - * handle the packet in firmware or pass it on to 1 of the 2 buffer destinations. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "bsm12.h" -#include "memory_map.h" -#include "buffer_pool.h" -#include -#include "nonstdio.h" -#include - -typedef enum { - BS_EMPTY, - BS_FILLING, - BS_FULL, - BS_EMPTYING, -} buffer_state_t; - -static buffer_state_t buffer_state[NBUFFERS]; -static uint32_t last_send_ctrl[NBUFFERS]; -static int8_t buffer_target[NBUFFERS]; // -1, 0 or 1. -static uint8_t buffer_dst[NBUFFERS]; // 0 or 1. Valid only when BF_EMPTYING - -#define ST_IDLE (-1) - -void -bsm12_init(bsm12_t *sm, int buf0, - const buf_cmd_args_t *recv, - const buf_cmd_args_t *send0, - const buf_cmd_args_t *send1, - bsm12_inspector_t inspect) -{ - if (buf0 & 0x3) // precondition: buf0 % 4 == 0 - abort(); - - sm->buf0 = buf0; - sm->running = false; - sm->recv_args = *recv; - sm->send_args[0] = *send0; - sm->send_args[1] = *send1; - - sm->rx_state = ST_IDLE; - sm->tx_state[0] = ST_IDLE; - sm->tx_state[1] = ST_IDLE; - - sm->inspect = inspect; - - sm->bps_error = BPS_ERROR(buf0 + 0) | BPS_ERROR(buf0 + 1) | BPS_ERROR(buf0 + 2); - sm->bps_done = BPS_DONE(buf0 + 0) | BPS_DONE(buf0 + 1) | BPS_DONE(buf0 + 2); - sm->bps_error_or_done = sm->bps_error | sm->bps_done; - - // How much to adjust the last_line register. - // It's 1 for everything but the ethernet. - sm->last_line_adj = recv->port == PORT_ETH ? 3 : 1; - - buffer_state[sm->buf0 + 0] = BS_EMPTY; - buffer_state[sm->buf0 + 1] = BS_EMPTY; - buffer_state[sm->buf0 + 2] = BS_EMPTY; - - buffer_target[sm->buf0 + 0] = -1; - buffer_target[sm->buf0 + 1] = -1; - buffer_target[sm->buf0 + 2] = -1; - - for (int i = 0; i < NBUFFERS; i++) - sm->next_buf[i] = buf0; - - sm->next_buf[buf0 + 0] = buf0 + 1; - sm->next_buf[buf0 + 1] = buf0 + 2; - sm->next_buf[buf0 + 2] = buf0 + 0; - - for (int i = 0; i < 3; i++){ - sm->precomputed_receive_to_buf_ctrl_word[i] = - (BPC_READ - | BPC_BUFFER(sm->buf0 + i) - | BPC_PORT(sm->recv_args.port) - | BPC_STEP(1) - | BPC_FIRST_LINE(sm->recv_args.first_line) - | BPC_LAST_LINE(sm->recv_args.last_line)); - - for (int j = 0; j < 2; j++){ - sm->precomputed_send_from_buf_ctrl_word[i][j] = - (BPC_WRITE - | BPC_BUFFER(sm->buf0 + i) - | BPC_PORT(sm->send_args[j].port) - | BPC_STEP(1) - | BPC_FIRST_LINE(sm->send_args[j].first_line) - | BPC_LAST_LINE(0)); // last line filled in at runtime - } - } -} - -static inline void -bsm12_receive_to_buf(bsm12_t *sm, int bufno) -{ - buffer_pool_ctrl->ctrl = sm->precomputed_receive_to_buf_ctrl_word[bufno & 0x3]; -} - -static inline void -bsm12_send_from_buf(bsm12_t *sm, int bufno, int dst_idx) -{ - dst_idx &= 0x1; - - uint32_t t = - (sm->precomputed_send_from_buf_ctrl_word[bufno & 0x3][dst_idx] - | BPC_LAST_LINE(buffer_pool_status->last_line[bufno] - sm->last_line_adj)); - - buffer_pool_ctrl->ctrl = t; - last_send_ctrl[bufno] = t; - buffer_dst[bufno] = dst_idx; -} - -static inline void -bsm12_resend_from_buf(bsm12_t *sm, int bufno) -{ - buffer_pool_ctrl->ctrl = last_send_ctrl[bufno]; -} - -void -bsm12_start(bsm12_t *sm) -{ - sm->running = true; - - buffer_state[sm->buf0 + 0] = BS_EMPTY; - buffer_state[sm->buf0 + 1] = BS_EMPTY; - buffer_state[sm->buf0 + 2] = BS_EMPTY; - - buffer_target[sm->buf0 + 0] = -1; - buffer_target[sm->buf0 + 1] = -1; - buffer_target[sm->buf0 + 2] = -1; - - bp_clear_buf(sm->buf0 + 0); - bp_clear_buf(sm->buf0 + 1); - bp_clear_buf(sm->buf0 + 2); - - sm->rx_state = 0; - sm->tx_state[0] = ST_IDLE; - sm->tx_state[1] = ST_IDLE; - bsm12_receive_to_buf(sm, sm->buf0); - buffer_state[sm->buf0] = BS_FILLING; -} - -void -bsm12_stop(bsm12_t *sm) -{ - sm->running = false; - bp_clear_buf(sm->buf0 + 0); - bp_clear_buf(sm->buf0 + 1); - bp_clear_buf(sm->buf0 + 2); - buffer_state[sm->buf0 + 0] = BS_EMPTY; - buffer_state[sm->buf0 + 1] = BS_EMPTY; - buffer_state[sm->buf0 + 2] = BS_EMPTY; -} - -static void bsm12_process_helper(bsm12_t *sm, int buf_this); -static void bsm12_error_helper(bsm12_t *sm, int buf_this); - -void -bsm12_process_status(bsm12_t *sm, uint32_t status) -{ - // anything for us? - if ((status & sm->bps_error_or_done) == 0 || !sm->running) - return; - - if (status & sm->bps_error){ - // Most likely an ethernet Rx error. We just restart the transfer. - if (status & (BPS_ERROR(sm->buf0 + 0))) - bsm12_error_helper(sm, sm->buf0 + 0); - - if (status & (BPS_ERROR(sm->buf0 + 1))) - bsm12_error_helper(sm, sm->buf0 + 1); - - if (status & (BPS_ERROR(sm->buf0 + 2))) - bsm12_error_helper(sm, sm->buf0 + 2); - } - - if (status & BPS_DONE(sm->buf0 + 0)) - bsm12_process_helper(sm, sm->buf0 + 0); - - if (status & BPS_DONE(sm->buf0 + 1)) - bsm12_process_helper(sm, sm->buf0 + 1); - - if (status & BPS_DONE(sm->buf0 + 2)) - bsm12_process_helper(sm, sm->buf0 + 2); -} - - static void -bsm12_process_helper(bsm12_t *sm, int buf_this) -{ - bp_clear_buf(buf_this); - - if (buffer_state[buf_this] == BS_FILLING){ - - buffer_state[buf_this] = BS_FULL; - buffer_target[buf_this] = -1; - - // - // where does this packet go? - // - int dst = sm->inspect(sm, buf_this); - if (dst == -1){ - // - // f/w handled the packet; refill the buffer - // - bsm12_receive_to_buf(sm, buf_this); - buffer_state[buf_this] = BS_FILLING; - buffer_target[buf_this] = -1; - sm->rx_state = buf_this & 0x3; - } - else { // goes to dst 0 or 1 - // - // If the next buffer is empty, start a receive on it - // - int t = sm->next_buf[buf_this]; - if (buffer_state[t] == BS_EMPTY){ - bsm12_receive_to_buf(sm, t); - buffer_state[t] = BS_FILLING; - buffer_target[t] = -1; - sm->rx_state = t & 0x3; - } - else - sm->rx_state = ST_IDLE; - - // - // If the destination is idle, start the xfer, othewise remember it - // - if (sm->tx_state[dst] == ST_IDLE){ - bsm12_send_from_buf(sm, buf_this, dst); - sm->tx_state[dst] = buf_this & 0x3; - buffer_state[buf_this] = BS_EMPTYING; - buffer_target[buf_this] = -1; - } - else { - buffer_target[buf_this] = dst; - } - } - } - - else { // BS_EMPTYING - - buffer_state[buf_this] = BS_EMPTY; - buffer_target[buf_this] = -1; - - if (sm->rx_state == ST_IDLE){ // fire off another receive - sm->rx_state = buf_this & 0x3; - bsm12_receive_to_buf(sm, buf_this); - buffer_state[buf_this] = BS_FILLING; - buffer_target[buf_this] = -1; - } - - int dst = buffer_dst[buf_this]; // the dst we were emptying into - // is the next buffer full and for us? - int t = sm->next_buf[buf_this]; - if (buffer_target[t] == dst){ // yes, - bsm12_send_from_buf(sm, t, dst); // send it - buffer_state[t] = BS_EMPTYING; - buffer_target[t] = -1; - sm->tx_state[dst] = t & 0x3; - } - // how about the one after that? - else if (buffer_target[t=sm->next_buf[t]] == dst){ // yes, - bsm12_send_from_buf(sm, t, dst); // send it - buffer_state[t] = BS_EMPTYING; - buffer_target[t] = -1; - sm->tx_state[dst] = t & 0x3; - } - else { - sm->tx_state[dst] = ST_IDLE; - } - } -} - -static void -bsm12_error_helper(bsm12_t *sm, int buf_this) -{ - bp_clear_buf(buf_this); // clears ERROR flag - - if (buffer_state[buf_this] == BS_FILLING){ - bsm12_receive_to_buf(sm, buf_this); // restart the xfer - } - else { // buffer was emptying - bsm12_resend_from_buf(sm, buf_this); // restart the xfer - } -} - - -void -bsm12_handle_tx_underrun(bsm12_t *sm) -{ -} - -void -bsm12_handle_rx_overrun(bsm12_t *sm) -{ -} diff --git a/firmware/microblaze/lib/bsm12.h b/firmware/microblaze/lib/bsm12.h deleted file mode 100644 index b8e576b79..000000000 --- a/firmware/microblaze/lib/bsm12.h +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 Free Software Foundation, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef INCLUDED_BSM12_H -#define INCLUDED_BSM12_H - -#include "dbsm.h" -#include "memory_map.h" - -/*! - * buffer state machine: 1 input to two outputs - * - * Typically used to read packets from the ethernet and then after inspecting, - * handle the packet in firmware or pass it on to 1 of the 2 buffer destinations. - */ - -struct _bsm12; -typedef struct _bsm12 bsm12_t; - -/*! - * Pointer to function that does packet inspection. - * - * \param sm the state machine - * \param buf_this the index of the buffer to inspect and/or pass on - * - * Returns -1, 0 or 1. If it returns -1, it means that the s/w - * handled that packet, and that it should NOT be passed on to one of - * the buffer endpoints. 0 indicates the first endpoint, 1 the second endpoint. - */ -typedef int (*bsm12_inspector_t)(bsm12_t *sm, int buf_this); - - -/*! - * buffer state machine: 1 input to two outputs - */ -struct _bsm12 -{ - uint8_t buf0; // This machine uses buf0, buf0+1 and buf0+2. buf0 % 4 == 0. - uint8_t running; - int8_t rx_state; // -1, 0, 1, 2 which buffer we're receiving into - int8_t tx_state[2]; // -1, 0, 1, 2 which buffer we're sending from - buf_cmd_args_t recv_args; - buf_cmd_args_t send_args[2]; - bsm12_inspector_t inspect; - int last_line_adj; - uint32_t bps_error; - uint32_t bps_done; - uint32_t bps_error_or_done; - uint8_t next_buf[NBUFFERS]; - uint32_t precomputed_receive_to_buf_ctrl_word[3]; - uint32_t precomputed_send_from_buf_ctrl_word[4][2]; // really only 3, not 4 - // (easier addr comp) -}; - -void bsm12_init(bsm12_t *sm, int buf0, - const buf_cmd_args_t *recv, - const buf_cmd_args_t *send0, - const buf_cmd_args_t *send1, - bsm12_inspector_t inspect); - -void bsm12_start(bsm12_t *sm); -void bsm12_stop(bsm12_t *sm); -void bsm12_process_status(bsm12_t *sm, uint32_t status); -void bsm12_handle_tx_underrun(bsm12_t *sm); -void bsm12_handle_rx_overrun(bsm12_t *sm); - - -#endif /* INCLUDED_BSM12_H */ diff --git a/firmware/microblaze/lib/buffer_pool.c b/firmware/microblaze/lib/buffer_pool.c deleted file mode 100644 index 77e7c5213..000000000 --- a/firmware/microblaze/lib/buffer_pool.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "memory_map.h" -#include "buffer_pool.h" -#include "hal_io.h" - -void -bp_init(void) -{ - int i; - bp_disable_port(PORT_SERDES); - bp_disable_port(PORT_DSP); - bp_disable_port(PORT_ETH); - bp_disable_port(PORT_RAM); - - for (i = 0; i < NBUFFERS; i++) - bp_clear_buf(i); -} - -#ifndef INLINE_BUFFER_POOL - -void -bp_clear_buf(int bufnum) -{ - buffer_pool_ctrl->ctrl = BPC_BUFFER(bufnum) | BPC_PORT_NIL | BPC_CLR; -} - -void -bp_disable_port(int portnum) -{ - // disable buffer connections to this port - buffer_pool_ctrl->ctrl = BPC_BUFFER_NIL | BPC_PORT(portnum); -} - -void -bp_receive_to_buf(int bufnum, int port, int step, int fl, int ll) -{ - buffer_pool_ctrl->ctrl = (BPC_READ - | BPC_BUFFER(bufnum) - | BPC_PORT(port) - | BPC_STEP(step) - | BPC_FIRST_LINE(fl) - | BPC_LAST_LINE(ll)); -} - -void -bp_send_from_buf(int bufnum, int port, int step, int fl, int ll) -{ - buffer_pool_ctrl->ctrl = (BPC_WRITE - | BPC_BUFFER(bufnum) - | BPC_PORT(port) - | BPC_STEP(step) - | BPC_FIRST_LINE(fl) - | BPC_LAST_LINE(ll)); -} - -#endif diff --git a/firmware/microblaze/lib/buffer_pool.h b/firmware/microblaze/lib/buffer_pool.h deleted file mode 100644 index 145b20f8d..000000000 --- a/firmware/microblaze/lib/buffer_pool.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef INCLUDED_BUFFER_POOL_H -#define INCLUDED_BUFFER_POOL_H - -#include "memory_map.h" - -// Buffer Pool Management - - -// define to have common buffer operations inlined -#define INLINE_BUFFER_POOL 1 - -void bp_init(void); - -#ifndef INLINE_BUFFER_POOL - -void bp_clear_buf(int bufnum); -void bp_disable_port(int portnum); -void bp_receive_to_buf(int bufnum, int port, int step, int fl, int ll); -void bp_send_from_buf(int bufnum, int port, int step, int fl, int ll); - -#else - -static inline void -bp_clear_buf(int bufnum) -{ - buffer_pool_ctrl->ctrl = BPC_BUFFER(bufnum) | BPC_PORT_NIL | BPC_CLR; -} - -static inline void -bp_disable_port(int portnum) -{ - // disable buffer connections to this port - buffer_pool_ctrl->ctrl = BPC_BUFFER_NIL | BPC_PORT(portnum); -} - -static inline void -bp_receive_to_buf(int bufnum, int port, int step, int fl, int ll) -{ - buffer_pool_ctrl->ctrl = (BPC_READ - | BPC_BUFFER(bufnum) - | BPC_PORT(port) - | BPC_STEP(step) - | BPC_FIRST_LINE(fl) - | BPC_LAST_LINE(ll)); -} - -static inline void -bp_send_from_buf(int bufnum, int port, int step, int fl, int ll) -{ - buffer_pool_ctrl->ctrl = (BPC_WRITE - | BPC_BUFFER(bufnum) - | BPC_PORT(port) - | BPC_STEP(step) - | BPC_FIRST_LINE(fl) - | BPC_LAST_LINE(ll)); -} -#endif -#endif diff --git a/firmware/microblaze/lib/compiler.h b/firmware/microblaze/lib/compiler.h index 4fa9b49f8..f677bdc3b 100644 --- a/firmware/microblaze/lib/compiler.h +++ b/firmware/microblaze/lib/compiler.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2009 Ettus Research LLC + * Copyright 2009, 2010 Ettus Research LLC * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,5 +21,6 @@ // FIXME gcc specific. #define _AL4 __attribute__((aligned (4))) +#define FORCE_INLINE inline __attribute__((always_inline)) #endif /* INCLUDED_COMPILER_H */ diff --git a/firmware/microblaze/lib/dbsm.c b/firmware/microblaze/lib/dbsm.c deleted file mode 100644 index cee343eaa..000000000 --- a/firmware/microblaze/lib/dbsm.c +++ /dev/null @@ -1,299 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008 Free Software Foundation, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* - * Double Buffering State Machine - */ - -#include "dbsm.h" -#include "memory_map.h" -#include "buffer_pool.h" -#include -#include "nonstdio.h" -#include - -typedef enum { - BS_EMPTY, - BS_FILLING, - BS_FULL, - BS_EMPTYING, -} buffer_state_t; - -static buffer_state_t buffer_state[NBUFFERS]; - -bool -dbsm_nop_inspector(dbsm_t *sm, int buf_this) -{ - return false; -} - -void -dbsm_init(dbsm_t *sm, int buf0, - const buf_cmd_args_t *recv, const buf_cmd_args_t *send, - inspector_t inspect) -{ - if (buf0 & 0x1) // must be even - abort(); - - sm->buf0 = buf0; - sm->running = false; - sm->recv_args = *recv; - sm->send_args = *send; - - sm->rx_idle = true; - sm->tx_idle = true; - - sm->inspect = inspect; - - // How much to adjust the last_line register. - // It's 1 for everything but the ethernet. - //sm->last_line_adj = recv->port == PORT_ETH ? 3 : 1; - sm->last_line_adj = 1; - - buffer_state[sm->buf0] = BS_EMPTY; - buffer_state[sm->buf0 ^ 1] = BS_EMPTY; - - sm->precomputed_receive_to_buf_ctrl_word[0] = - (BPC_READ - | BPC_BUFFER(sm->buf0) - | BPC_PORT(sm->recv_args.port) - | BPC_STEP(1) - | BPC_FIRST_LINE(sm->recv_args.first_line) - | BPC_LAST_LINE(sm->recv_args.last_line)); - - sm->precomputed_receive_to_buf_ctrl_word[1] = - (BPC_READ - | BPC_BUFFER(sm->buf0 ^ 1) - | BPC_PORT(sm->recv_args.port) - | BPC_STEP(1) - | BPC_FIRST_LINE(sm->recv_args.first_line) - | BPC_LAST_LINE(sm->recv_args.last_line)); - - sm->precomputed_send_from_buf_ctrl_word[0] = - (BPC_WRITE - | BPC_BUFFER(sm->buf0) - | BPC_PORT(sm->send_args.port) - | BPC_STEP(1) - | BPC_FIRST_LINE(sm->send_args.first_line) - | BPC_LAST_LINE(0)); // last line filled in at runtime - - sm->precomputed_send_from_buf_ctrl_word[1] = - (BPC_WRITE - | BPC_BUFFER(sm->buf0 ^ 1) - | BPC_PORT(sm->send_args.port) - | BPC_STEP(1) - | BPC_FIRST_LINE(sm->send_args.first_line) - | BPC_LAST_LINE(0)); // last line filled in at runtime - -} - -static inline void -dbsm_receive_to_buf(dbsm_t *sm, int bufno) -{ - buffer_pool_ctrl->ctrl = sm->precomputed_receive_to_buf_ctrl_word[bufno & 1]; -} - -static inline void -dbsm_send_from_buf(dbsm_t *sm, int bufno) -{ - buffer_pool_ctrl->ctrl = - (sm->precomputed_send_from_buf_ctrl_word[bufno & 1] - | BPC_LAST_LINE(buffer_pool_status->last_line[bufno] - sm->last_line_adj)); -} - -void -dbsm_start(dbsm_t *sm) -{ - // printf("dbsm_start: buf0 = %d, recv_port = %d\n", sm->buf0, sm->recv_args.port); - - sm->running = true; - - buffer_state[sm->buf0] = BS_EMPTY; - buffer_state[sm->buf0 ^ 1] = BS_EMPTY; - - bp_clear_buf(sm->buf0); - bp_clear_buf(sm->buf0 ^ 1); - - sm->tx_idle = true; - sm->rx_idle = false; - dbsm_receive_to_buf(sm, sm->buf0); - buffer_state[sm->buf0] = BS_FILLING; - -} - - -void -dbsm_stop(dbsm_t *sm) -{ - sm->running = false; - bp_clear_buf(sm->buf0); - bp_clear_buf(sm->buf0 ^ 1); - buffer_state[sm->buf0] = BS_EMPTY; - buffer_state[sm->buf0 ^ 1] = BS_EMPTY; -} - -static void dbsm_process_helper(dbsm_t *sm, int buf_this); -static void dbsm_error_helper(dbsm_t *sm, int buf_this); - -void -dbsm_process_status(dbsm_t *sm, uint32_t status) -{ - if (!sm->running) - return; - - if (status & (BPS_ERROR(sm->buf0) | BPS_ERROR(sm->buf0 ^ 1))){ - putchar('E'); - // Most likely an ethernet Rx error. We just restart the transfer. - if (status & (BPS_ERROR(sm->buf0))) - dbsm_error_helper(sm, sm->buf0); - //dbsm_process_helper(sm, sm->buf0); //forward errors - - if (status & (BPS_ERROR(sm->buf0 ^ 1))) - dbsm_error_helper(sm, sm->buf0 ^ 1); - //dbsm_process_helper(sm, sm->buf0 ^ 1); //forward errors - } - - if (status & BPS_DONE(sm->buf0)) - dbsm_process_helper(sm, sm->buf0); - - if (status & BPS_DONE(sm->buf0 ^ 1)) - dbsm_process_helper(sm, sm->buf0 ^ 1); -} - -static void -dbsm_process_helper(dbsm_t *sm, int buf_this) -{ - int buf_other = buf_this ^ 1; - - bp_clear_buf(buf_this); - - if (buffer_state[buf_this] == BS_FILLING){ - buffer_state[buf_this] = BS_FULL; - // - // does s/w handle this packet? - // - if (sm->inspect(sm, buf_this)){ - // s/w handled the packet; refill the buffer - dbsm_receive_to_buf(sm, buf_this); - buffer_state[buf_this] = BS_FILLING; - } - - else { // s/w didn't handle this; pass it on - - if(buffer_state[buf_other] == BS_EMPTY){ - dbsm_receive_to_buf(sm, buf_other); - buffer_state[buf_other] = BS_FILLING; - } - else - sm->rx_idle = true; - - if (sm->tx_idle){ - sm->tx_idle = false; - dbsm_send_from_buf(sm, buf_this); - buffer_state[buf_this] = BS_EMPTYING; - } - } - } - else { // buffer was emptying - buffer_state[buf_this] = BS_EMPTY; - if (sm->rx_idle){ - sm->rx_idle = false; - dbsm_receive_to_buf(sm, buf_this); - buffer_state[buf_this] = BS_FILLING; - } - if (buffer_state[buf_other] == BS_FULL){ - dbsm_send_from_buf(sm, buf_other); - buffer_state[buf_other] = BS_EMPTYING; - } - else - sm->tx_idle = true; - } -} - -static void -dbsm_error_helper(dbsm_t *sm, int buf_this) -{ - bp_clear_buf(buf_this); // clears ERROR flag - - if (buffer_state[buf_this] == BS_FILLING){ - dbsm_receive_to_buf(sm, buf_this); // restart the xfer - } - else { // buffer was emptying - dbsm_send_from_buf(sm, buf_this); // restart the xfer - } -} - -/* - * Handle DSP Tx underrun - */ -void -dbsm_handle_tx_underrun(dbsm_t *sm) -{ - // clear the DSP Tx state machine - sr_tx_ctrl->clear_state = 1; - - // If there's a buffer that's empyting, clear it & flush xfer - - if (buffer_state[sm->buf0] == BS_EMPTYING){ - bp_clear_buf(sm->buf0); - sr_tx_ctrl->clear_state = 1; // flush partial packet - // drop frame in progress on ground. Pretend it finished - dbsm_process_helper(sm, sm->buf0); - } - else if (buffer_state[sm->buf0 ^ 1] == BS_EMPTYING){ - bp_clear_buf(sm->buf0 ^ 1); - sr_tx_ctrl->clear_state = 1; // flush partial packet - // drop frame in progress on ground. Pretend it finished - dbsm_process_helper(sm, sm->buf0 ^ 1); - } -} - -/* - * Handle DSP Rx overrun - */ -void -dbsm_handle_rx_overrun(dbsm_t *sm) -{ - sr_rx_ctrl->clear_overrun = 1; - - // If there's a buffer that's filling, clear it. - // Any restart will be the job of the caller. - - if (buffer_state[sm->buf0] == BS_FILLING) - bp_clear_buf(sm->buf0); - - if (buffer_state[sm->buf0 ^1] == BS_FILLING) - bp_clear_buf(sm->buf0 ^ 1); -} - -void -dbsm_wait_for_opening(dbsm_t *sm) -{ - if (buffer_state[sm->buf0] == BS_EMPTYING){ - // wait for xfer to complete - int mask = BPS_DONE(sm->buf0) | BPS_ERROR(sm->buf0) | BPS_IDLE(sm->buf0); - while ((buffer_pool_status->status & mask) == 0) - ; - } - else if (buffer_state[sm->buf0 ^ 1] == BS_EMPTYING){ - // wait for xfer to complete - int mask = BPS_DONE(sm->buf0 ^ 1) | BPS_ERROR(sm->buf0 ^ 1) | BPS_IDLE(sm->buf0 ^ 1); - while ((buffer_pool_status->status & mask) == 0) - ; - } -} diff --git a/firmware/microblaze/lib/dbsm.h b/firmware/microblaze/lib/dbsm.h deleted file mode 100644 index cb7e12fc3..000000000 --- a/firmware/microblaze/lib/dbsm.h +++ /dev/null @@ -1,90 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#ifndef INCLUDED_DBSM_H -#define INCLUDED_DBSM_H - -/* - * Double Buffering State Machine - */ - -#include -#include - -struct _dbsm; -typedef struct _dbsm dbsm_t; - -/* - * pointer to function that does packet inspection. - * - * If one of these returns true, it means that the s/w - * handled that packet, and that it should NOT be passed - * on to the normal destination port. - */ -typedef bool (*inspector_t)(dbsm_t *sm, int buf_this); - -bool dbsm_nop_inspector(dbsm_t *sm, int buf_this); // returns false - - -typedef struct -{ - uint16_t port; - uint16_t first_line; - uint16_t last_line; -} buf_cmd_args_t; - -/*! - * double buffer state machine - */ -struct _dbsm -{ - uint8_t buf0; // Must be even. This machine uses buf0 and buf0+1 - uint8_t running; - uint8_t rx_idle; - uint8_t tx_idle; - buf_cmd_args_t recv_args; - buf_cmd_args_t send_args; - inspector_t inspect; - uint32_t precomputed_receive_to_buf_ctrl_word[2]; - uint32_t precomputed_send_from_buf_ctrl_word[2]; - int last_line_adj; -}; - -void dbsm_init(dbsm_t *sm, int buf0, - const buf_cmd_args_t *recv, const buf_cmd_args_t *send, - inspector_t inspect); - -void dbsm_start(dbsm_t *sm); -void dbsm_stop(dbsm_t *sm); -void dbsm_process_status(dbsm_t *sm, uint32_t status); -void dbsm_handle_tx_underrun(dbsm_t *sm); -void dbsm_handle_rx_overrun(dbsm_t *sm); - -/* - * The cpu calls this when it want to ensure that it can send a buffer - * to the same destination being used by this state machine. - * - * If neither buffer is EMPTYING it returns immediately. If a buffer - * is EMPYTING, it waits for the h/w to transition to the DONE or - * ERROR state. - * - * When this function returns, the caller queues it's buffer and busy - * waits for it to complete. - */ -void dbsm_wait_for_opening(dbsm_t *sm); - -#endif /* INCLUDED_DBSM_H */ diff --git a/firmware/microblaze/lib/net_common.c b/firmware/microblaze/lib/net_common.c index 6305408d6..1ff7ebde7 100644 --- a/firmware/microblaze/lib/net_common.c +++ b/firmware/microblaze/lib/net_common.c @@ -22,7 +22,6 @@ #include "net_common.h" #include "banal.h" #include -#include #include #include #include @@ -37,12 +36,6 @@ #include #include - -int cpu_tx_buf_dest_port = PORT_ETH; - -// If this is non-zero, this dbsm could be writing to the ethernet -dbsm_t *ac_could_be_sending_to_eth; - static inline bool ip_addr_eq(const struct ip_addr a, const struct ip_addr b) { @@ -130,8 +123,8 @@ send_pkt(eth_mac_addr_t dst, int ethertype, // FIXME can this ever not be ready? //hal_set_leds(LED_BUF_BUSY, LED_BUF_BUSY); - while((buffer_pool_status->status & BPS_IDLE(CPU_TX_BUF)) == 0) - ; + //FIXME while((buffer_pool_status->status & BPS_IDLE(CPU_TX_BUF)) == 0) + //FIXME ; //hal_set_leds(0, LED_BUF_BUSY); // Assemble the header @@ -141,7 +134,7 @@ send_pkt(eth_mac_addr_t dst, int ethertype, ehdr.src = _local_mac_addr; ehdr.ethertype = ethertype; - uint32_t *p = buffer_ram(CPU_TX_BUF); + uint32_t *p = 0;//FIXME buffer_ram(CPU_TX_BUF); // Copy the pieces into the buffer *p++ = 0x0; // slow path @@ -173,31 +166,26 @@ send_pkt(eth_mac_addr_t dst, int ethertype, p += len2/sizeof(uint32_t); } - size_t total_len = (p - buffer_ram(CPU_TX_BUF)) * sizeof(uint32_t); + size_t total_len = 0;//FIXME (p - buffer_ram(CPU_TX_BUF)) * sizeof(uint32_t); if (total_len < 60) // ensure that we don't try to send a short packet total_len = 60; // wait until nobody else is sending to the ethernet - if (ac_could_be_sending_to_eth){ + //FIXME if (ac_could_be_sending_to_eth){ //hal_set_leds(LED_ETH_BUSY, LED_ETH_BUSY); - dbsm_wait_for_opening(ac_could_be_sending_to_eth); + //FIXME dbsm_wait_for_opening(ac_could_be_sending_to_eth); //hal_set_leds(0x0, LED_ETH_BUSY); - } + //FIXME } - if (0){ - printf("send_pkt to port %d, len = %d\n", - cpu_tx_buf_dest_port, (int) total_len); - print_buffer(buffer_ram(CPU_TX_BUF), total_len/4); - } // fire it off - bp_send_from_buf(CPU_TX_BUF, cpu_tx_buf_dest_port, 1, 0, total_len/4); + //FIXME bp_send_from_buf(CPU_TX_BUF, cpu_tx_buf_dest_port, 1, 0, total_len/4); // wait for it to complete (not long, it's a small pkt) - while((buffer_pool_status->status & (BPS_DONE(CPU_TX_BUF) | BPS_ERROR(CPU_TX_BUF))) == 0) - ; + //FIXME while((buffer_pool_status->status & (BPS_DONE(CPU_TX_BUF) | BPS_ERROR(CPU_TX_BUF))) == 0) + //FIXME ; - bp_clear_buf(CPU_TX_BUF); + //FIXME bp_clear_buf(CPU_TX_BUF); } unsigned int @@ -235,7 +223,7 @@ send_ip_pkt(struct ip_addr dst, int protocol, bool found = arp_cache_lookup_mac(&ip.dest, &dst_mac); if (!found){ printf("net_common: failed to hit cache looking for "); - print_ip(ip.dest); + print_ip_addr(&ip.dest); newline(); return; } diff --git a/firmware/microblaze/lib/net_common.h b/firmware/microblaze/lib/net_common.h index 3040e5ef3..9d6a3e345 100644 --- a/firmware/microblaze/lib/net_common.h +++ b/firmware/microblaze/lib/net_common.h @@ -20,19 +20,9 @@ #include #include -#include #include #include -#define CPU_TX_BUF 7 // cpu -> eth - -extern int cpu_tx_buf_dest_port; - -// If this is non-zero, this dbsm could be writing to the ethernet -extern dbsm_t *ac_could_be_sending_to_eth; - -void stop_streaming(void); - 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/nonstdio.h b/firmware/microblaze/lib/nonstdio.h index 62ebfa46d..6aca7ed9a 100644 --- a/firmware/microblaze/lib/nonstdio.h +++ b/firmware/microblaze/lib/nonstdio.h @@ -45,4 +45,6 @@ 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 *t); + #endif /* INCLUDED_NONSTDIO_H */ diff --git a/firmware/microblaze/lib/print_addrs.c b/firmware/microblaze/lib/print_addrs.c new file mode 100644 index 000000000..29601c47c --- /dev/null +++ b/firmware/microblaze/lib/print_addrs.c @@ -0,0 +1,32 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007 Free Software Foundation, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include "nonstdio.h" + +void +print_mac_addr(const unsigned char addr[6]) +{ + for(size_t i = 0; i < 6; i++){ + if(i) putchar(':'); + puthex8(addr[i]); + } +} + +void print_ip_addr(const void *t){ + uint8_t *p = (uint8_t *)t; + printf("%d.%d.%d.%d", p[0], p[1], p[2], p[3]); +} diff --git a/firmware/microblaze/lib/print_mac_addr.c b/firmware/microblaze/lib/print_mac_addr.c deleted file mode 100644 index 475082325..000000000 --- a/firmware/microblaze/lib/print_mac_addr.c +++ /dev/null @@ -1,28 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#include "nonstdio.h" - -void -print_mac_addr(const unsigned char addr[6]) -{ - for(size_t i = 0; i < 6; i++){ - if(i) putchar(':'); - puthex8(addr[i]); - } -} - diff --git a/firmware/microblaze/lib/u2_init.c b/firmware/microblaze/lib/u2_init.c index 4a553a713..2a6ae5a60 100644 --- a/firmware/microblaze/lib/u2_init.c +++ b/firmware/microblaze/lib/u2_init.c @@ -20,7 +20,6 @@ #include "spi.h" #include "pic.h" #include "hal_io.h" -#include "buffer_pool.h" #include "hal_uart.h" #include "i2c.h" #include "i2c_async.h" @@ -63,10 +62,6 @@ u2_init(void) i2c_register_handler(); //for using async I2C hal_enable_ints(); - bp_init(); // buffer pool - - - // flash all leds to let us know board is alive hal_set_leds(0x0, 0x1f); mdelay(100); diff --git a/firmware/microblaze/lib/usrp2_bytesex.h b/firmware/microblaze/lib/usrp2_bytesex.h deleted file mode 100644 index 2b74f2a0b..000000000 --- a/firmware/microblaze/lib/usrp2_bytesex.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#ifndef INCLUDED_USRP2_BYTESEX_H -#define INCLUDED_USRP2_BYTESEX_H - -// The USRP2 speaks big-endian... -// Use the standard include files or provide substitutions for -// htons and friends - -#if defined(HAVE_ARPA_INET_H) -#include -#elif defined(HAVE_NETINET_IN_H) -#include -#else -#include - -#ifdef WORDS_BIGENDIAN // nothing to do... - -static inline uint32_t htonl(uint32_t x){ return x; } -static inline uint16_t htons(uint16_t x){ return x; } -static inline uint32_t ntohl(uint32_t x){ return x; } -static inline uint16_t ntohs(uint16_t x){ return x; } - -#else - -#ifdef HAVE_BYTESWAP_H -#include -#else - -static inline uint16_t -bswap_16 (uint16_t x) -{ - return ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8)); -} - -static inline uint32_t -bswap_32 (uint32_t x) -{ - return ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) \ - | (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)); -} -#endif - -static inline uint32_t htonl(uint32_t x){ return bswap_32(x); } -static inline uint16_t htons(uint16_t x){ return bswap_16(x); } -static inline uint32_t ntohl(uint32_t x){ return bswap_32(x); } -static inline uint16_t ntohs(uint16_t x){ return bswap_16(x); } - -#endif -#endif -#endif /* INCLUDED_USRP2_BYTESEX_H */ diff --git a/firmware/microblaze/lib/wb16550.h b/firmware/microblaze/lib/wb16550.h deleted file mode 100644 index 7522f4438..000000000 --- a/firmware/microblaze/lib/wb16550.h +++ /dev/null @@ -1,98 +0,0 @@ -/* -*- c -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - - -// Wishbone National Semiconductor 16550A compatible UART - -#ifndef INCLUDED_WB16550_H -#define INCLUDED_WB16550_H - -#include - -typedef struct { - volatile uint8_t data; // 0 r/w: r: rx fifo, w: tx fifo (if DLAB: LSB of divisor) - volatile uint8_t ier; // 1 r/w: Interrupt Enable Register (if DLAB: MSB of divisor) - volatile uint8_t iir_fcr; // 2 r/w: r: Interrupt ID Register, - // w: Fifo Control Register - volatile uint8_t lcr; // 3 r/w: Line Control Register - volatile uint8_t mcr; // 4 w: Modem Control Register - volatile uint8_t lsr; // 5 r: Line Status Register - volatile uint8_t msr; // 6 r: Modem Status Register - -} wb16550_reg_t; - -#define UART_IER_RDI 0x01 // Enable received data interrupt -#define UART_IER_THRI 0x02 // Enable transmitter holding reg empty int. -#define UART_IER_RLSI 0x04 // Enable receiver line status interrupt -#define UART_IER_MSI 0x08 // Enable modem status interrupt - -#define UART_IIR_NO_INT 0x01 // No interrupts pending -#define UART_IIR_ID_MASK 0x06 // Mask for interrupt ID -#define UART_IIR_MSI 0x00 // Modem status interrupt -#define UART_IIR_THRI 0x02 // Tx holding register empty int -#define UART_IIR_RDI 0x04 // Rx data available int -#define UART_IIR_RLSI 0x06 // Receiver line status int - -#define UART_FCR_ENABLE_FIFO 0x01 // ignore, always enabled -#define UART_FCR_CLEAR_RCVR 0x02 // Clear the RCVR FIFO -#define UART_FCR_CLEAR_XMIT 0x04 // Clear the XMIT FIFO -#define UART_FCR_TRIGGER_MASK 0xC0 // Mask for FIFO trigger range -#define UART_FCR_TRIGGER_1 0x00 // Rx fifo trigger level: 1 byte -#define UART_FCR_TRIGGER_4 0x40 // Rx fifo trigger level: 4 bytes -#define UART_FCR_TRIGGER_8 0x80 // Rx fifo trigger level: 8 bytes -#define UART_FCR_TRIGGER_14 0xC0 // Rx fifo trigger level: 14 bytes - -#define UART_LCR_DLAB 0x80 // Divisor latch access bit -#define UART_LCR_SBC 0x40 // Set break control -#define UART_LCR_SPAR 0x20 // Stick parity -#define UART_LCR_EPAR 0x10 // Even parity select -#define UART_LCR_PARITY 0x08 // Parity Enable -#define UART_LCR_STOP 0x04 // Stop bits: 0=1 bit, 1=2 bits -#define UART_LCR_WLEN5 0x00 // Wordlength: 5 bits -#define UART_LCR_WLEN6 0x01 // Wordlength: 6 bits -#define UART_LCR_WLEN7 0x02 // Wordlength: 7 bits -#define UART_LCR_WLEN8 0x03 // Wordlength: 8 bits - -#define UART_MCR_LOOP 0x10 // Enable loopback test mode -#define UART_MCR_OUT2n 0x08 // Out2 complement (loopback mode) -#define UART_MCR_OUT1n 0x04 // Out1 complement (loopback mode) -#define UART_MCR_RTSn 0x02 // RTS complement -#define UART_MCR_DTRn 0x01 // DTR complement - -#define UART_LSR_TEMT 0x40 // Transmitter empty -#define UART_LSR_THRE 0x20 // Transmit-hold-register empty -#define UART_LSR_BI 0x10 // Break interrupt indicator -#define UART_LSR_FE 0x08 // Frame error indicator -#define UART_LSR_PE 0x04 // Parity error indicator -#define UART_LSR_OE 0x02 // Overrun error indicator -#define UART_LSR_DR 0x01 // Receiver data ready -#define UART_LSR_BRK_ERROR_BITS 0x1E // BI, FE, PE, OE bits -#define UART_LSR_ERROR 0x80 // At least 1 PE, FE or BI are in the fifo - -#define UART_MSR_DCD 0x80 // Data Carrier Detect -#define UART_MSR_RI 0x40 // Ring Indicator -#define UART_MSR_DSR 0x20 // Data Set Ready -#define UART_MSR_CTS 0x10 // Clear to Send -#define UART_MSR_DDCD 0x08 // Delta DCD -#define UART_MSR_TERI 0x04 // Trailing edge ring indicator -#define UART_MSR_DDSR 0x02 // Delta DSR -#define UART_MSR_DCTS 0x01 // Delta CTS -#define UART_MSR_ANY_DELTA 0x0F // Any of the delta bits! - - -#endif // INCLUDED_WB16550_H -- cgit v1.2.3 From 5d9cf99cad000faee61ddecb6990b414661eb49b Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 15 Nov 2010 10:53:24 -0800 Subject: usrp2: implemented packet ctrl to read and write slow path packets from the new interface --- firmware/microblaze/apps/txrx_uhd.c | 83 ++++++------------------------------ firmware/microblaze/lib/Makefile.inc | 1 + firmware/microblaze/lib/net_common.c | 30 +++---------- firmware/microblaze/lib/pkt_ctrl.c | 54 +++++++++++++++++++++++ firmware/microblaze/lib/pkt_ctrl.h | 47 ++++++++++++++++++++ 5 files changed, 119 insertions(+), 96 deletions(-) create mode 100644 firmware/microblaze/lib/pkt_ctrl.c create mode 100644 firmware/microblaze/lib/pkt_ctrl.h diff --git a/firmware/microblaze/apps/txrx_uhd.c b/firmware/microblaze/apps/txrx_uhd.c index 2d001cfa8..8a4abadf0 100644 --- a/firmware/microblaze/apps/txrx_uhd.c +++ b/firmware/microblaze/apps/txrx_uhd.c @@ -45,6 +45,7 @@ #include #include #include "udp_fw_update.h" +#include "pkt_ctrl.h" static void setup_network(void); @@ -83,9 +84,6 @@ void handle_udp_data_packet( //setup network and vrt setup_network(); - // kick off the state machine - //FIME dbsm_start(&dsp_rx_sm); - } #define OTW_GPIO_BANK_TO_NUM(bank) \ @@ -294,28 +292,7 @@ void handle_udp_ctrl_packet( } -/* - * Called when an ethernet packet is received. - * Return true if we handled it here, otherwise - * it'll be passed on to the DSP Tx pipe - */ -/* -static bool -eth_pkt_inspector(dbsm_t *sm, int bufno) -{ - //point me to the ethernet frame - uint32_t *buff = (uint32_t *)buffer_ram(bufno); - - //treat this as fast-path data? - // We have to do this operation as fast as possible. - // Therefore, we do not check all the headers, - // just check that the udp port matches - // and that the vrt header is non zero. - // In the future, a hardware state machine will do this... - if ( //warning! magic numbers approaching.... - (((buff + ((2 + 14 + 20)/sizeof(uint32_t)))[0] & 0xffff) == USRP2_UDP_DATA_PORT) && - ((buff + ((2 + 14 + 20 + 8)/sizeof(uint32_t)))[1] != USRP2_INVALID_VRT_HEADER) - ) return false; +static void handle_inp_packet(uint32_t *buff, size_t num_lines){ //test if its an ip recovery packet typedef struct{ @@ -329,15 +306,13 @@ eth_pkt_inspector(dbsm_t *sm, int bufno) if (recovery_packet->eth_hdr.ethertype == 0xbeee && strncmp(recovery_packet->code, "addr", 4) == 0){ printf("Got ip recovery packet: "); print_ip_addr(&recovery_packet->data.ip_addr); newline(); set_ip_addr(&recovery_packet->data.ip_addr); - return true; + return; } //pass it to the slow-path handler - size_t len = buffer_pool_status->last_line[bufno] - 3; - handle_eth_packet(buff, len); - return true; + handle_eth_packet(buff, num_lines); } -*/ + //------------------------------------------------------------------ @@ -402,15 +377,6 @@ static void setup_network(void){ sr_udp_sm->udp_hdr.checksum = UDP_SM_LAST_WORD; // zero UDP checksum } -inline static void -buffer_irq_handler(unsigned irq) -{ - //FIXME uint32_t status = buffer_pool_status->status; - - //FIXME dbsm_process_status(&dsp_tx_sm, status); - //FIXME dbsm_process_status(&dsp_rx_sm, status); -} - int main(void) { @@ -446,33 +412,14 @@ main(void) ethernet_register_link_changed_callback(link_changed_callback); ethernet_init(); - // initialize double buffering state machine for ethernet -> DSP Tx - - //FIXME dbsm_init(&dsp_tx_sm, DSP_TX_BUF_0, -//FIXME &dsp_tx_recv_args, &dsp_tx_send_args, -//FIXME eth_pkt_inspector); + while(true){ - - // initialize double buffering state machine for DSP RX -> Ethernet - -//FIXME dbsm_init(&dsp_rx_sm, DSP_RX_BUF_0, -//FIXME &dsp_rx_recv_args, &dsp_rx_send_args, -//FIXME dbsm_rx_inspector); - - sr_tx_ctrl->clear_state = 1; -//FIXME bp_clear_buf(DSP_TX_BUF_0); -//FIXME bp_clear_buf(DSP_TX_BUF_1); - - // kick off the state machine -//FIXME dbsm_start(&dsp_tx_sm); - - //int which = 0; - - while(1){ - // hal_gpio_write(GPIO_TX_BANK, which, 0x8000); - // which ^= 0x8000; - - buffer_irq_handler(0); + size_t num_lines; + void *buff = claim_incoming_buffer(&num_lines); + if (buff != NULL){ + handle_inp_packet((uint32_t *)buff, num_lines); + release_incoming_buffer(); + } if(i2c_done) { i2c_done = false; @@ -488,18 +435,12 @@ main(void) int pending = pic_regs->pending; // poll for under or overrun if (pending & PIC_UNDERRUN_INT){ - //dbsm_handle_tx_underrun(&dsp_tx_sm); pic_regs->pending = PIC_UNDERRUN_INT; // clear interrupt putchar('U'); } if (pending & PIC_OVERRUN_INT){ - //dbsm_handle_rx_overrun(&dsp_rx_sm); pic_regs->pending = PIC_OVERRUN_INT; // clear pending interrupt - - // FIXME Figure out how to handle this robustly. - // Any buffers that are emptying should be allowed to drain... - putchar('O'); } } diff --git a/firmware/microblaze/lib/Makefile.inc b/firmware/microblaze/lib/Makefile.inc index 1ca375861..471a244e0 100644 --- a/firmware/microblaze/lib/Makefile.inc +++ b/firmware/microblaze/lib/Makefile.inc @@ -36,6 +36,7 @@ COMMON_SRCS = \ $(top_srcdir)/lib/memset_wa.c \ $(top_srcdir)/lib/nonstdio.c \ $(top_srcdir)/lib/pic.c \ + $(top_srcdir)/lib/pkt_ctrl.c \ $(top_srcdir)/lib/print_addrs.c \ $(top_srcdir)/lib/print_rmon_regs.c \ $(top_srcdir)/lib/print_buffer.c \ diff --git a/firmware/microblaze/lib/net_common.c b/firmware/microblaze/lib/net_common.c index 1ff7ebde7..cc08997a0 100644 --- a/firmware/microblaze/lib/net_common.c +++ b/firmware/microblaze/lib/net_common.c @@ -35,6 +35,7 @@ #include "if_arp.h" #include #include +#include "pkt_ctrl.h" static inline bool ip_addr_eq(const struct ip_addr a, const struct ip_addr b) @@ -119,13 +120,6 @@ send_pkt(eth_mac_addr_t dst, int ethertype, const void *buf1, size_t len1, const void *buf2, size_t len2) { - // Wait for buffer to become idle - // FIXME can this ever not be ready? - - //hal_set_leds(LED_BUF_BUSY, LED_BUF_BUSY); - //FIXME while((buffer_pool_status->status & BPS_IDLE(CPU_TX_BUF)) == 0) - //FIXME ; - //hal_set_leds(0, LED_BUF_BUSY); // Assemble the header padded_eth_hdr_t ehdr; @@ -134,9 +128,10 @@ send_pkt(eth_mac_addr_t dst, int ethertype, ehdr.src = _local_mac_addr; ehdr.ethertype = ethertype; - uint32_t *p = 0;//FIXME buffer_ram(CPU_TX_BUF); + uint32_t *buff = (uint32_t *)claim_outgoing_buffer(); // Copy the pieces into the buffer + uint32_t *p = buff; *p++ = 0x0; // slow path memcpy_wa(p, &ehdr, sizeof(ehdr)); // 4 lines p += sizeof(ehdr)/sizeof(uint32_t); @@ -166,26 +161,11 @@ send_pkt(eth_mac_addr_t dst, int ethertype, p += len2/sizeof(uint32_t); } - size_t total_len = 0;//FIXME (p - buffer_ram(CPU_TX_BUF)) * sizeof(uint32_t); + size_t total_len = (p - buff) * sizeof(uint32_t); if (total_len < 60) // ensure that we don't try to send a short packet total_len = 60; - - // wait until nobody else is sending to the ethernet - //FIXME if (ac_could_be_sending_to_eth){ - //hal_set_leds(LED_ETH_BUSY, LED_ETH_BUSY); - //FIXME dbsm_wait_for_opening(ac_could_be_sending_to_eth); - //hal_set_leds(0x0, LED_ETH_BUSY); - //FIXME } - - - // fire it off - //FIXME bp_send_from_buf(CPU_TX_BUF, cpu_tx_buf_dest_port, 1, 0, total_len/4); - - // wait for it to complete (not long, it's a small pkt) - //FIXME while((buffer_pool_status->status & (BPS_DONE(CPU_TX_BUF) | BPS_ERROR(CPU_TX_BUF))) == 0) - //FIXME ; - //FIXME bp_clear_buf(CPU_TX_BUF); + commit_outgoing_buffer(total_len/4); } unsigned int diff --git a/firmware/microblaze/lib/pkt_ctrl.c b/firmware/microblaze/lib/pkt_ctrl.c new file mode 100644 index 000000000..235a09459 --- /dev/null +++ b/firmware/microblaze/lib/pkt_ctrl.c @@ -0,0 +1,54 @@ +/* + * Copyright 2010 Ettus Research LLC + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "pkt_ctrl.h" +#include "memory_map.h" +#include +#include +#include + +static void set_control(uint32_t value, uint32_t mask){ + static uint32_t ctrl_shadow = 0; + + ctrl_shadow &= ~mask; + ctrl_shadow |= value & mask; + + buffer_pool_ctrl->ctrl = ctrl_shadow; +} + +void *claim_incoming_buffer(size_t *num_lines){ + if ((buffer_pool_status->status & 0x1) != 1) return NULL; + *num_lines = (buffer_pool_status->status >> 16) & 0xffff; + set_control(0x1, 0x1); + return buffer_ram(0); +} + +void release_incoming_buffer(void){ + set_control(0x0, 0x1); + while ((buffer_pool_status->status & 0x1) != 0){} +} + +void *claim_outgoing_buffer(void){ + while ((buffer_pool_status->status & 0x2) != 0x2){} + return buffer_ram(1); +} + +void commit_outgoing_buffer(size_t num_lines){ + set_control(0x2 | (num_lines << 16), 0x2 | (0xffff << 16)); + while ((buffer_pool_status->status & 0x2) != 0x0){} + set_control(0x0, 0x2); +} diff --git a/firmware/microblaze/lib/pkt_ctrl.h b/firmware/microblaze/lib/pkt_ctrl.h new file mode 100644 index 000000000..156fc06dc --- /dev/null +++ b/firmware/microblaze/lib/pkt_ctrl.h @@ -0,0 +1,47 @@ +/* + * Copyright 2010 Ettus Research LLC + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef INCLUDED_PKT_CTRL_H +#define INCLUDED_PKT_CTRL_H + +#include + +/*! + * Try to claim an incomming buffer. + * \param num_lines filled with the buffer size + * \return a pointer to the buffer memory or NULL + */ +void *claim_incoming_buffer(size_t *num_lines); + +/*! + * Release the incoming buffer. Call when done. + */ +void release_incoming_buffer(void); + +/*! + * Claim an outgoing buffer. + * \return a pointer to the buffer + */ +void *claim_outgoing_buffer(void); + +/*! + * Commit the outgoing buffer. + * \param num_lines how many lines written. + */ +void commit_outgoing_buffer(size_t num_lines); + +#endif /* INCLUDED_PKT_CTRL_H */ -- cgit v1.2.3 From 57fcedbba7cbedda714aefa6653bf00e30e5981a Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 17 Nov 2010 15:42:29 -0800 Subject: usrp2: removed buffer pool macros and constants from memory map --- firmware/microblaze/usrp2/memory_map.h | 108 -------------------------------- firmware/microblaze/usrp2p/memory_map.h | 108 -------------------------------- 2 files changed, 216 deletions(-) diff --git a/firmware/microblaze/usrp2/memory_map.h b/firmware/microblaze/usrp2/memory_map.h index eac0c217f..8e2360c93 100644 --- a/firmware/microblaze/usrp2/memory_map.h +++ b/firmware/microblaze/usrp2/memory_map.h @@ -184,74 +184,6 @@ typedef struct { #define buffer_pool_status ((buffer_pool_status_t *) BUFFER_POOL_STATUS_BASE) -/* - * Buffer n's xfer is done. - * Clear this bit by issuing bp_clear_buf(n) - */ -#define BPS_DONE(n) (0x00000001 << (n)) -#define BPS_DONE_0 BPS_DONE(0) -#define BPS_DONE_1 BPS_DONE(1) -#define BPS_DONE_2 BPS_DONE(2) -#define BPS_DONE_3 BPS_DONE(3) -#define BPS_DONE_4 BPS_DONE(4) -#define BPS_DONE_5 BPS_DONE(5) -#define BPS_DONE_6 BPS_DONE(6) -#define BPS_DONE_7 BPS_DONE(7) - -/* - * Buffer n's xfer had an error. - * Clear this bit by issuing bp_clear_buf(n) - */ -#define BPS_ERROR(n) (0x00000100 << (n)) -#define BPS_ERROR_0 BPS_ERROR(0) -#define BPS_ERROR_1 BPS_ERROR(1) -#define BPS_ERROR_2 BPS_ERROR(2) -#define BPS_ERROR_3 BPS_ERROR(3) -#define BPS_ERROR_4 BPS_ERROR(4) -#define BPS_ERROR_5 BPS_ERROR(5) -#define BPS_ERROR_6 BPS_ERROR(6) -#define BPS_ERROR_7 BPS_ERROR(7) - -/* - * Buffer n is idle. A buffer is idle if it's not - * DONE, ERROR, or processing a transaction. If it's - * IDLE, it's safe to start a new transaction. - * - * Clear this bit by starting a xfer with - * bp_send_from_buf or bp_receive_to_buf. - */ -#define BPS_IDLE(n) (0x00010000 << (n)) -#define BPS_IDLE_0 BPS_IDLE(0) -#define BPS_IDLE_1 BPS_IDLE(1) -#define BPS_IDLE_2 BPS_IDLE(2) -#define BPS_IDLE_3 BPS_IDLE(3) -#define BPS_IDLE_4 BPS_IDLE(4) -#define BPS_IDLE_5 BPS_IDLE(5) -#define BPS_IDLE_6 BPS_IDLE(6) -#define BPS_IDLE_7 BPS_IDLE(7) - -/* - * Buffer n has a "slow path" packet in it. - * This bit is orthogonal to the bits above and indicates that - * the FPGA ethernet rx protocol engine has identified this packet - * as one requiring firmware intervention. - */ -#define BPS_SLOWPATH(n) (0x01000000 << (n)) -#define BPS_SLOWPATH_0 BPS_SLOWPATH(0) -#define BPS_SLOWPATH_1 BPS_SLOWPATH(1) -#define BPS_SLOWPATH_2 BPS_SLOWPATH(2) -#define BPS_SLOWPATH_3 BPS_SLOWPATH(3) -#define BPS_SLOWPATH_4 BPS_SLOWPATH(4) -#define BPS_SLOWPATH_5 BPS_SLOWPATH(5) -#define BPS_SLOWPATH_6 BPS_SLOWPATH(6) -#define BPS_SLOWPATH_7 BPS_SLOWPATH(7) - - -#define BPS_DONE_ALL 0x000000ff // mask of all dones -#define BPS_ERROR_ALL 0x0000ff00 // mask of all errors -#define BPS_IDLE_ALL 0x00ff0000 // mask of all idles -#define BPS_SLOWPATH_ALL 0xff000000 // mask of all slowpaths - // The hw_config register #define HWC_SIMULATION 0x80000000 @@ -319,46 +251,6 @@ typedef struct { volatile uint32_t ctrl; } buffer_pool_ctrl_t; -// buffer pool ports - -#define PORT_SERDES 0 // serial/deserializer -#define PORT_DSP 1 // DSP tx or rx pipeline -#define PORT_ETH 2 // ethernet tx or rx -#define PORT_RAM 3 // RAM tx or rx - -// the buffer pool ctrl register fields - -#define BPC_BUFFER(n) (((n) & 0xf) << 28) -#define BPC_BUFFER_MASK BPC_BUFFER(~0) -#define BPC_BUFFER_0 BPC_BUFFER(0) -#define BPC_BUFFER_1 BPC_BUFFER(1) -#define BPC_BUFFER_2 BPC_BUFFER(2) -#define BPC_BUFFER_3 BPC_BUFFER(3) -#define BPC_BUFFER_4 BPC_BUFFER(4) -#define BPC_BUFFER_5 BPC_BUFFER(5) -#define BPC_BUFFER_6 BPC_BUFFER(6) -#define BPC_BUFFER_7 BPC_BUFFER(7) -#define BPC_BUFFER_NIL BPC_BUFFER(0x8) // disable - -#define BPC_PORT(n) (((n) & 0x7) << 25) -#define BPC_PORT_MASK BPC_PORT(~0) -#define BPC_PORT_SERDES BPC_PORT(PORT_SERDES) -#define BPC_PORT_DSP BPC_PORT(PORT_DSP) -#define BPC_PORT_ETH BPC_PORT(PORT_ETH) -#define BPC_PORT_RAM BPC_PORT(PORT_RAM) -#define BPC_PORT_NIL BPC_PORT(0x4) // disable - -#define BPC_CLR (1 << 24) // mutually excl commands -#define BPC_READ (1 << 23) -#define BPC_WRITE (1 << 22) - -#define BPC_STEP(step) (((step) & 0xf) << 18) -#define BPC_STEP_MASK BPC_STEP(~0) -#define BPC_LAST_LINE(line) (((line) & 0x1ff) << 9) -#define BPC_LAST_LINE_MASK BPC_LAST_LINE(~0) -#define BPC_FIRST_LINE(line) (((line) & 0x1ff) << 0) -#define BPC_FIRST_LINE_MASK BPC_FIRST_LINE(~0) - #define buffer_pool_ctrl ((buffer_pool_ctrl_t *) BUFFER_POOL_CTRL_BASE) // --- misc outputs --- diff --git a/firmware/microblaze/usrp2p/memory_map.h b/firmware/microblaze/usrp2p/memory_map.h index 3b2dc0057..ca2933f6c 100644 --- a/firmware/microblaze/usrp2p/memory_map.h +++ b/firmware/microblaze/usrp2p/memory_map.h @@ -211,74 +211,6 @@ typedef struct { #define BUTTON_PUSHED ((buffer_pool_status->irqs & PIC_BUTTON) ? 0 : 1) -/* - * Buffer n's xfer is done. - * Clear this bit by issuing bp_clear_buf(n) - */ -#define BPS_DONE(n) (0x00000001 << (n)) -#define BPS_DONE_0 BPS_DONE(0) -#define BPS_DONE_1 BPS_DONE(1) -#define BPS_DONE_2 BPS_DONE(2) -#define BPS_DONE_3 BPS_DONE(3) -#define BPS_DONE_4 BPS_DONE(4) -#define BPS_DONE_5 BPS_DONE(5) -#define BPS_DONE_6 BPS_DONE(6) -#define BPS_DONE_7 BPS_DONE(7) - -/* - * Buffer n's xfer had an error. - * Clear this bit by issuing bp_clear_buf(n) - */ -#define BPS_ERROR(n) (0x00000100 << (n)) -#define BPS_ERROR_0 BPS_ERROR(0) -#define BPS_ERROR_1 BPS_ERROR(1) -#define BPS_ERROR_2 BPS_ERROR(2) -#define BPS_ERROR_3 BPS_ERROR(3) -#define BPS_ERROR_4 BPS_ERROR(4) -#define BPS_ERROR_5 BPS_ERROR(5) -#define BPS_ERROR_6 BPS_ERROR(6) -#define BPS_ERROR_7 BPS_ERROR(7) - -/* - * Buffer n is idle. A buffer is idle if it's not - * DONE, ERROR, or processing a transaction. If it's - * IDLE, it's safe to start a new transaction. - * - * Clear this bit by starting a xfer with - * bp_send_from_buf or bp_receive_to_buf. - */ -#define BPS_IDLE(n) (0x00010000 << (n)) -#define BPS_IDLE_0 BPS_IDLE(0) -#define BPS_IDLE_1 BPS_IDLE(1) -#define BPS_IDLE_2 BPS_IDLE(2) -#define BPS_IDLE_3 BPS_IDLE(3) -#define BPS_IDLE_4 BPS_IDLE(4) -#define BPS_IDLE_5 BPS_IDLE(5) -#define BPS_IDLE_6 BPS_IDLE(6) -#define BPS_IDLE_7 BPS_IDLE(7) - -/* - * Buffer n has a "slow path" packet in it. - * This bit is orthogonal to the bits above and indicates that - * the FPGA ethernet rx protocol engine has identified this packet - * as one requiring firmware intervention. - */ -#define BPS_SLOWPATH(n) (0x01000000 << (n)) -#define BPS_SLOWPATH_0 BPS_SLOWPATH(0) -#define BPS_SLOWPATH_1 BPS_SLOWPATH(1) -#define BPS_SLOWPATH_2 BPS_SLOWPATH(2) -#define BPS_SLOWPATH_3 BPS_SLOWPATH(3) -#define BPS_SLOWPATH_4 BPS_SLOWPATH(4) -#define BPS_SLOWPATH_5 BPS_SLOWPATH(5) -#define BPS_SLOWPATH_6 BPS_SLOWPATH(6) -#define BPS_SLOWPATH_7 BPS_SLOWPATH(7) - - -#define BPS_DONE_ALL 0x000000ff // mask of all dones -#define BPS_ERROR_ALL 0x0000ff00 // mask of all errors -#define BPS_IDLE_ALL 0x00ff0000 // mask of all idles -#define BPS_SLOWPATH_ALL 0xff000000 // mask of all slowpaths - // The hw_config register #define HWC_SIMULATION 0x80000000 @@ -346,46 +278,6 @@ typedef struct { volatile uint32_t ctrl; } buffer_pool_ctrl_t; -// buffer pool ports - -#define PORT_SERDES 0 // serial/deserializer -#define PORT_DSP 1 // DSP tx or rx pipeline -#define PORT_ETH 2 // ethernet tx or rx -#define PORT_RAM 3 // RAM tx or rx - -// the buffer pool ctrl register fields - -#define BPC_BUFFER(n) (((n) & 0xf) << 28) -#define BPC_BUFFER_MASK BPC_BUFFER(~0) -#define BPC_BUFFER_0 BPC_BUFFER(0) -#define BPC_BUFFER_1 BPC_BUFFER(1) -#define BPC_BUFFER_2 BPC_BUFFER(2) -#define BPC_BUFFER_3 BPC_BUFFER(3) -#define BPC_BUFFER_4 BPC_BUFFER(4) -#define BPC_BUFFER_5 BPC_BUFFER(5) -#define BPC_BUFFER_6 BPC_BUFFER(6) -#define BPC_BUFFER_7 BPC_BUFFER(7) -#define BPC_BUFFER_NIL BPC_BUFFER(0x8) // disable - -#define BPC_PORT(n) (((n) & 0x7) << 25) -#define BPC_PORT_MASK BPC_PORT(~0) -#define BPC_PORT_SERDES BPC_PORT(PORT_SERDES) -#define BPC_PORT_DSP BPC_PORT(PORT_DSP) -#define BPC_PORT_ETH BPC_PORT(PORT_ETH) -#define BPC_PORT_RAM BPC_PORT(PORT_RAM) -#define BPC_PORT_NIL BPC_PORT(0x4) // disable - -#define BPC_CLR (1 << 24) // mutually excl commands -#define BPC_READ (1 << 23) -#define BPC_WRITE (1 << 22) - -#define BPC_STEP(step) (((step) & 0xf) << 18) -#define BPC_STEP_MASK BPC_STEP(~0) -#define BPC_LAST_LINE(line) (((line) & 0x1ff) << 9) -#define BPC_LAST_LINE_MASK BPC_LAST_LINE(~0) -#define BPC_FIRST_LINE(line) (((line) & 0x1ff) << 0) -#define BPC_FIRST_LINE_MASK BPC_FIRST_LINE(~0) - #define buffer_pool_ctrl ((buffer_pool_ctrl_t *) BUFFER_POOL_CTRL_BASE) // --- misc outputs --- -- cgit v1.2.3 From b621dea91eeebe05c4823bc2da8780fa12997169 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 17 Nov 2010 16:12:00 -0800 Subject: usrp2: replaced spi and i2c async stuff with sync (since were out of the fast-path) --- firmware/microblaze/apps/txrx_uhd.c | 95 +++++------------------------------ firmware/microblaze/lib/Makefile.inc | 1 - firmware/microblaze/lib/spi.c | 6 ++- firmware/microblaze/lib/spi.h | 8 +-- firmware/microblaze/lib/u2_init.c | 2 - firmware/microblaze/usrp2/Makefile.am | 4 +- 6 files changed, 22 insertions(+), 94 deletions(-) diff --git a/firmware/microblaze/apps/txrx_uhd.c b/firmware/microblaze/apps/txrx_uhd.c index 8a4abadf0..4adccfed9 100644 --- a/firmware/microblaze/apps/txrx_uhd.c +++ b/firmware/microblaze/apps/txrx_uhd.c @@ -40,12 +40,12 @@ #include #include "clocks.h" #include "usrp2/fw_common.h" -#include #include #include #include #include "udp_fw_update.h" #include "pkt_ctrl.h" +#include "banal.h" static void setup_network(void); @@ -55,10 +55,6 @@ static void setup_network(void); static eth_mac_addr_t fp_mac_addr_src, fp_mac_addr_dst; static struct socket_address fp_socket_src, fp_socket_dst; -// ---------------------------------------------------------------- -void start_rx_streaming_cmd(void); -void stop_rx_cmd(void); - void handle_udp_data_packet( struct socket_address src, struct socket_address dst, unsigned char *payload, int payload_len @@ -89,33 +85,6 @@ void handle_udp_data_packet( #define OTW_GPIO_BANK_TO_NUM(bank) \ (((bank) == USRP2_DIR_RX)? (GPIO_RX_BANK) : (GPIO_TX_BANK)) -//setup the output data -static usrp2_ctrl_data_t ctrl_data_out; -static struct socket_address i2c_src; -static struct socket_address spi_src; - -static volatile bool i2c_done = false; -void i2c_read_done_callback(void) { - //printf("I2C read done callback\n"); - i2c_async_data_ready(ctrl_data_out.data.i2c_args.data); - i2c_done = true; - i2c_register_callback(0); -} - -void i2c_write_done_callback(void) { - //printf("I2C write done callback\n"); - i2c_done = true; - i2c_register_callback(0); -} - -static volatile bool spi_done = false; -static volatile uint32_t spi_readback_data; -void get_spi_readback_data(void) { - ctrl_data_out.data.spi_args.data = spi_get_data(); - spi_done = true; - spi_register_callback(0); -} - void handle_udp_ctrl_packet( struct socket_address src, struct socket_address dst, unsigned char *payload, int payload_len @@ -141,6 +110,7 @@ void handle_udp_ctrl_packet( } //setup the output data + usrp2_ctrl_data_t ctrl_data_out; ctrl_data_out.proto_ver = USRP2_FW_COMPAT_NUM; ctrl_data_out.id=USRP2_CTRL_ID_HUH_WHAT; ctrl_data_out.seq=ctrl_data_in->seq; @@ -154,7 +124,6 @@ void handle_udp_ctrl_packet( case USRP2_CTRL_ID_WAZZUP_BRO: ctrl_data_out.id = USRP2_CTRL_ID_WAZZUP_DUDE; memcpy(&ctrl_data_out.data.ip_addr, get_ip_addr(), sizeof(struct ip_addr)); - send_udp_pkt(USRP2_UDP_CTRL_PORT, src, &ctrl_data_out, sizeof(ctrl_data_out)); break; /******************************************************************* @@ -162,21 +131,19 @@ void handle_udp_ctrl_packet( ******************************************************************/ case USRP2_CTRL_ID_TRANSACT_ME_SOME_SPI_BRO:{ //transact - bool success = spi_async_transact( - //(ctrl_data_in->data.spi_args.readback == 0)? SPI_TXONLY : SPI_TXRX, + uint32_t result = spi_transact( + (ctrl_data_in->data.spi_args.readback == 0)? SPI_TXONLY : SPI_TXRX, ctrl_data_in->data.spi_args.dev, //which device ctrl_data_in->data.spi_args.data, //32 bit data ctrl_data_in->data.spi_args.num_bits, //length in bits - (ctrl_data_in->data.spi_args.mosi_edge == USRP2_CLK_EDGE_RISE)? SPIF_PUSH_FALL : SPIF_PUSH_RISE | //flags - (ctrl_data_in->data.spi_args.miso_edge == USRP2_CLK_EDGE_RISE)? SPIF_LATCH_RISE : SPIF_LATCH_FALL, - get_spi_readback_data //callback + (ctrl_data_in->data.spi_args.mosi_edge == USRP2_CLK_EDGE_RISE)? SPIF_PUSH_FALL : SPIF_PUSH_RISE | + (ctrl_data_in->data.spi_args.miso_edge == USRP2_CLK_EDGE_RISE)? SPIF_LATCH_RISE : SPIF_LATCH_FALL ); //load output + ctrl_data_out.data.spi_args.data = result; ctrl_data_out.id = USRP2_CTRL_ID_OMG_TRANSACTED_SPI_DUDE; - spi_src = src; } -// send_udp_pkt(USRP2_UDP_CTRL_PORT, src, &ctrl_data_out, sizeof(ctrl_data_out)); break; /******************************************************************* @@ -184,13 +151,11 @@ void handle_udp_ctrl_packet( ******************************************************************/ case USRP2_CTRL_ID_DO_AN_I2C_READ_FOR_ME_BRO:{ uint8_t num_bytes = ctrl_data_in->data.i2c_args.bytes; - i2c_register_callback(i2c_read_done_callback); - i2c_async_read( + i2c_read( ctrl_data_in->data.i2c_args.addr, + ctrl_data_out.data.i2c_args.data, num_bytes ); - i2c_src = src; -// i2c_dst = dst; ctrl_data_out.id = USRP2_CTRL_ID_HERES_THE_I2C_DATA_DUDE; ctrl_data_out.data.i2c_args.bytes = num_bytes; } @@ -198,14 +163,11 @@ void handle_udp_ctrl_packet( case USRP2_CTRL_ID_WRITE_THESE_I2C_VALUES_BRO:{ uint8_t num_bytes = ctrl_data_in->data.i2c_args.bytes; - i2c_register_callback(i2c_read_done_callback); - i2c_async_write( + i2c_write( ctrl_data_in->data.i2c_args.addr, ctrl_data_in->data.i2c_args.data, num_bytes ); - i2c_src = src; -// i2c_dst = dst; ctrl_data_out.id = USRP2_CTRL_ID_COOL_IM_DONE_I2C_WRITE_DUDE; ctrl_data_out.data.i2c_args.bytes = num_bytes; } @@ -237,7 +199,6 @@ void handle_udp_ctrl_packet( } ctrl_data_out.id = USRP2_CTRL_ID_OMG_POKED_REGISTER_SO_BAD_DUDE; - send_udp_pkt(USRP2_UDP_CTRL_PORT, src, &ctrl_data_out, sizeof(ctrl_data_out)); break; case USRP2_CTRL_ID_PEEK_AT_THIS_REGISTER_FOR_ME_BRO: @@ -260,7 +221,6 @@ void handle_udp_ctrl_packet( } ctrl_data_out.id = USRP2_CTRL_ID_WOAH_I_DEFINITELY_PEEKED_IT_DUDE; - send_udp_pkt(USRP2_UDP_CTRL_PORT, src, &ctrl_data_out, sizeof(ctrl_data_out)); break; case USRP2_CTRL_ID_SO_LIKE_CAN_YOU_READ_THIS_UART_BRO:{ @@ -287,9 +247,8 @@ void handle_udp_ctrl_packet( default: ctrl_data_out.id = USRP2_CTRL_ID_HUH_WHAT; - send_udp_pkt(USRP2_UDP_CTRL_PORT, src, &ctrl_data_out, sizeof(ctrl_data_out)); } - + send_udp_pkt(USRP2_UDP_CTRL_PORT, src, &ctrl_data_out, sizeof(ctrl_data_out)); } static void handle_inp_packet(uint32_t *buff, size_t num_lines){ @@ -316,28 +275,11 @@ static void handle_inp_packet(uint32_t *buff, size_t num_lines){ //------------------------------------------------------------------ -/* - * 1's complement sum for IP and UDP headers - * - * init chksum to zero to start. - */ -static unsigned int -CHKSUM(unsigned int x, unsigned int *chksum) -{ - *chksum += x; - *chksum = (*chksum & 0xffff) + (*chksum>>16); - *chksum = (*chksum & 0xffff) + (*chksum>>16); - return x; -} - /* * Called when eth phy state changes (w/ interrupts disabled) */ -volatile bool link_is_up = false; // eth handler sets this -void -link_changed_callback(int speed) -{ - link_is_up = speed != 0; +void link_changed_callback(int speed){ + bool link_is_up = speed != 0; hal_set_leds(link_is_up ? LED_RJ45 : 0x0, LED_RJ45); printf("\neth link changed: speed = %d\n", speed); if (link_is_up) send_gratuitous_arp(); @@ -421,17 +363,6 @@ main(void) release_incoming_buffer(); } - if(i2c_done) { - i2c_done = false; - send_udp_pkt(USRP2_UDP_CTRL_PORT, i2c_src, &ctrl_data_out, sizeof(ctrl_data_out)); - //printf("Sending UDP packet from main loop for I2C...\n"); - } - - if(spi_done) { - spi_done = false; - send_udp_pkt(USRP2_UDP_CTRL_PORT, spi_src, &ctrl_data_out, sizeof(ctrl_data_out)); - } - int pending = pic_regs->pending; // poll for under or overrun if (pending & PIC_UNDERRUN_INT){ diff --git a/firmware/microblaze/lib/Makefile.inc b/firmware/microblaze/lib/Makefile.inc index 471a244e0..d99fc4d98 100644 --- a/firmware/microblaze/lib/Makefile.inc +++ b/firmware/microblaze/lib/Makefile.inc @@ -30,7 +30,6 @@ COMMON_SRCS = \ $(top_srcdir)/lib/hal_io.c \ $(top_srcdir)/lib/hal_uart.c \ $(top_srcdir)/lib/i2c.c \ - $(top_srcdir)/lib/i2c_async.c \ $(top_srcdir)/lib/mdelay.c \ $(top_srcdir)/lib/memcpy_wa.c \ $(top_srcdir)/lib/memset_wa.c \ diff --git a/firmware/microblaze/lib/spi.c b/firmware/microblaze/lib/spi.c index 2a41a1bfa..af0d8a68f 100644 --- a/firmware/microblaze/lib/spi.c +++ b/firmware/microblaze/lib/spi.c @@ -20,9 +20,9 @@ #include "pic.h" #include "nonstdio.h" -void (*volatile spi_callback)(void); //SPI callback when xfer complete. +//void (*volatile spi_callback)(void); //SPI callback when xfer complete. -static void spi_irq_handler(unsigned irq); +//static void spi_irq_handler(unsigned irq); void spi_init(void) @@ -66,6 +66,7 @@ spi_transact(bool readback, int slave, uint32_t data, int length, uint32_t flags return 0; } +/* void spi_register_callback(void (*volatile callback)(void)) { spi_callback = callback; } @@ -106,3 +107,4 @@ spi_async_transact(int slave, uint32_t data, int length, uint32_t flags, void (* return true; } +*/ diff --git a/firmware/microblaze/lib/spi.h b/firmware/microblaze/lib/spi.h index 54618cedd..71245150a 100644 --- a/firmware/microblaze/lib/spi.h +++ b/firmware/microblaze/lib/spi.h @@ -48,12 +48,12 @@ void spi_wait(void); uint32_t spi_transact(bool readback, int slave, uint32_t data, int length, uint32_t flags); -uint32_t spi_get_data(void); +//uint32_t spi_get_data(void); //static void spi_irq_handler(unsigned irq); -void spi_register_callback(void (*volatile callback)(void)); +//void spi_register_callback(void (*volatile callback)(void)); -bool -spi_async_transact(int slave, uint32_t data, int length, uint32_t flags, void (*volatile callback)(void)); +//bool +//spi_async_transact(int slave, uint32_t data, int length, uint32_t flags, void (*volatile callback)(void)); // ---------------------------------------------------------------- // Routines that manipulate the FLASH SPI BUS diff --git a/firmware/microblaze/lib/u2_init.c b/firmware/microblaze/lib/u2_init.c index 2a6ae5a60..a2669103a 100644 --- a/firmware/microblaze/lib/u2_init.c +++ b/firmware/microblaze/lib/u2_init.c @@ -22,7 +22,6 @@ #include "hal_io.h" #include "hal_uart.h" #include "i2c.h" -#include "i2c_async.h" #include "mdelay.h" #include "clocks.h" #include "usrp2/fw_common.h" @@ -59,7 +58,6 @@ u2_init(void) // init i2c so we can read our rev pic_init(); // progammable interrupt controller i2c_init(); - i2c_register_handler(); //for using async I2C hal_enable_ints(); // flash all leds to let us know board is alive diff --git a/firmware/microblaze/usrp2/Makefile.am b/firmware/microblaze/usrp2/Makefile.am index 7a58e7253..7fd353204 100644 --- a/firmware/microblaze/usrp2/Makefile.am +++ b/firmware/microblaze/usrp2/Makefile.am @@ -24,8 +24,6 @@ AM_LDFLAGS = \ $(COMMON_LFLAGS) \ -Wl,-defsym -Wl,_TEXT_START_ADDR=0x0050 \ -Wl,-defsym -Wl,_STACK_SIZE=3072 - -LDADD = libusrp2.a LDADD = libusrp2.a @@ -38,7 +36,7 @@ libusrp2_a_SOURCES = \ $(COMMON_SRCS) \ sd.c \ ethernet.c \ - udp_fw_update.c + udp_fw_update.c noinst_PROGRAMS = \ usrp2_txrx_uhd.elf -- cgit v1.2.3 From 58d19c5adf7bde9298ad4363c275f72e4bbecd73 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 17 Nov 2010 16:42:27 -0800 Subject: usrp2: remove non-relevant buffer pool things from memory map --- firmware/microblaze/usrp2/memory_map.h | 6 ++---- firmware/microblaze/usrp2p/memory_map.h | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/firmware/microblaze/usrp2/memory_map.h b/firmware/microblaze/usrp2/memory_map.h index 8e2360c93..2b07ff148 100644 --- a/firmware/microblaze/usrp2/memory_map.h +++ b/firmware/microblaze/usrp2/memory_map.h @@ -53,9 +53,7 @@ #define BUFFER_POOL_RAM_BASE 0x8000 -#define NBUFFERS 8 #define BP_NLINES 0x0200 // number of 32-bit lines in a buffer -#define BP_LAST_LINE (BP_NLINES - 1) // last line in a buffer #define buffer_pool_ram \ ((uint32_t *) BUFFER_POOL_RAM_BASE) @@ -173,8 +171,8 @@ typedef struct { #define BUFFER_POOL_STATUS_BASE 0xCC00 typedef struct { - volatile uint32_t last_line[NBUFFERS]; // last line xfer'd in buffer - volatile uint32_t status; // error and done flags + volatile uint32_t _padding[8]; + volatile uint32_t status; volatile uint32_t hw_config; // see below volatile uint32_t dummy[3]; volatile uint32_t irqs; diff --git a/firmware/microblaze/usrp2p/memory_map.h b/firmware/microblaze/usrp2p/memory_map.h index ca2933f6c..431dc19e7 100644 --- a/firmware/microblaze/usrp2p/memory_map.h +++ b/firmware/microblaze/usrp2p/memory_map.h @@ -78,9 +78,7 @@ wb_1master #(.decode_w(8), #define BUFFER_POOL_RAM_BASE 0x4000 -#define NBUFFERS 8 #define BP_NLINES 0x0200 // number of 32-bit lines in a buffer -#define BP_LAST_LINE (BP_NLINES - 1) // last line in a buffer #define buffer_pool_ram \ ((uint32_t *) BUFFER_POOL_RAM_BASE) @@ -198,8 +196,8 @@ typedef struct { #define BUFFER_POOL_STATUS_BASE 0x3300 typedef struct { - volatile uint32_t last_line[NBUFFERS]; // last line xfer'd in buffer - volatile uint32_t status; // error and done flags + volatile uint32_t _padding[8]; + volatile uint32_t status; volatile uint32_t hw_config; // see below volatile uint32_t dummy[3]; volatile uint32_t irqs; -- cgit v1.2.3 From 68af2b9ccf556f42d7697c73406abdcc31093d1b Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 17 Nov 2010 17:12:01 -0800 Subject: usrp2: implement routing mode calls, and prefix pkt ctrl calls --- firmware/microblaze/apps/txrx_uhd.c | 18 ++++++++++++------ firmware/microblaze/lib/net_common.c | 4 ++-- firmware/microblaze/lib/pkt_ctrl.c | 19 +++++++++++++++---- firmware/microblaze/lib/pkt_ctrl.h | 16 ++++++++++++---- 4 files changed, 41 insertions(+), 16 deletions(-) diff --git a/firmware/microblaze/apps/txrx_uhd.c b/firmware/microblaze/apps/txrx_uhd.c index 4adccfed9..938491b0e 100644 --- a/firmware/microblaze/apps/txrx_uhd.c +++ b/firmware/microblaze/apps/txrx_uhd.c @@ -279,10 +279,16 @@ static void handle_inp_packet(uint32_t *buff, size_t num_lines){ * Called when eth phy state changes (w/ interrupts disabled) */ void link_changed_callback(int speed){ - bool link_is_up = speed != 0; - hal_set_leds(link_is_up ? LED_RJ45 : 0x0, LED_RJ45); - printf("\neth link changed: speed = %d\n", speed); - if (link_is_up) send_gratuitous_arp(); + printf("\neth link changed: speed = %d\n", speed); + if (speed != 0){ + hal_set_leds(LED_RJ45, LED_RJ45); + pkt_ctrl_set_routing_mode(PKT_CTRL_ROUTING_MODE_MASTER); + send_gratuitous_arp(); //garp after setting the routing mode + } + else{ + hal_set_leds(0x0, LED_RJ45); + pkt_ctrl_set_routing_mode(PKT_CTRL_ROUTING_MODE_SLAVE); + } } static void setup_network(void){ @@ -357,10 +363,10 @@ main(void) while(true){ size_t num_lines; - void *buff = claim_incoming_buffer(&num_lines); + void *buff = pkt_ctrl_claim_incoming_buffer(&num_lines); if (buff != NULL){ handle_inp_packet((uint32_t *)buff, num_lines); - release_incoming_buffer(); + pkt_ctrl_release_incoming_buffer(); } int pending = pic_regs->pending; // poll for under or overrun diff --git a/firmware/microblaze/lib/net_common.c b/firmware/microblaze/lib/net_common.c index cc08997a0..486a34252 100644 --- a/firmware/microblaze/lib/net_common.c +++ b/firmware/microblaze/lib/net_common.c @@ -128,7 +128,7 @@ send_pkt(eth_mac_addr_t dst, int ethertype, ehdr.src = _local_mac_addr; ehdr.ethertype = ethertype; - uint32_t *buff = (uint32_t *)claim_outgoing_buffer(); + uint32_t *buff = (uint32_t *)pkt_ctrl_claim_outgoing_buffer(); // Copy the pieces into the buffer uint32_t *p = buff; @@ -165,7 +165,7 @@ send_pkt(eth_mac_addr_t dst, int ethertype, if (total_len < 60) // ensure that we don't try to send a short packet total_len = 60; - commit_outgoing_buffer(total_len/4); + pkt_ctrl_commit_outgoing_buffer(total_len/4); } unsigned int diff --git a/firmware/microblaze/lib/pkt_ctrl.c b/firmware/microblaze/lib/pkt_ctrl.c index 235a09459..f7f808cfc 100644 --- a/firmware/microblaze/lib/pkt_ctrl.c +++ b/firmware/microblaze/lib/pkt_ctrl.c @@ -30,24 +30,35 @@ static void set_control(uint32_t value, uint32_t mask){ buffer_pool_ctrl->ctrl = ctrl_shadow; } -void *claim_incoming_buffer(size_t *num_lines){ +void pkt_ctrl_set_routing_mode(pkt_ctrl_routing_mode_t mode){ + switch(mode){ + case PKT_CTRL_ROUTING_MODE_SLAVE: + set_control(0x0, 0x4); + break; + case PKT_CTRL_ROUTING_MODE_MASTER: + set_control(0x4, 0x4); + break; + } +} + +void *pkt_ctrl_claim_incoming_buffer(size_t *num_lines){ if ((buffer_pool_status->status & 0x1) != 1) return NULL; *num_lines = (buffer_pool_status->status >> 16) & 0xffff; set_control(0x1, 0x1); return buffer_ram(0); } -void release_incoming_buffer(void){ +void pkt_ctrl_release_incoming_buffer(void){ set_control(0x0, 0x1); while ((buffer_pool_status->status & 0x1) != 0){} } -void *claim_outgoing_buffer(void){ +void *pkt_ctrl_claim_outgoing_buffer(void){ while ((buffer_pool_status->status & 0x2) != 0x2){} return buffer_ram(1); } -void commit_outgoing_buffer(size_t num_lines){ +void pkt_ctrl_commit_outgoing_buffer(size_t num_lines){ set_control(0x2 | (num_lines << 16), 0x2 | (0xffff << 16)); while ((buffer_pool_status->status & 0x2) != 0x0){} set_control(0x0, 0x2); diff --git a/firmware/microblaze/lib/pkt_ctrl.h b/firmware/microblaze/lib/pkt_ctrl.h index 156fc06dc..86fb46d32 100644 --- a/firmware/microblaze/lib/pkt_ctrl.h +++ b/firmware/microblaze/lib/pkt_ctrl.h @@ -20,28 +20,36 @@ #include +typedef enum { + PKT_CTRL_ROUTING_MODE_SLAVE, + PKT_CTRL_ROUTING_MODE_MASTER, +} pkt_ctrl_routing_mode_t; + +//! Set the routing mode for this device +void pkt_ctrl_set_routing_mode(pkt_ctrl_routing_mode_t mode); + /*! * Try to claim an incomming buffer. * \param num_lines filled with the buffer size * \return a pointer to the buffer memory or NULL */ -void *claim_incoming_buffer(size_t *num_lines); +void *pkt_ctrl_claim_incoming_buffer(size_t *num_lines); /*! * Release the incoming buffer. Call when done. */ -void release_incoming_buffer(void); +void pkt_ctrl_release_incoming_buffer(void); /*! * Claim an outgoing buffer. * \return a pointer to the buffer */ -void *claim_outgoing_buffer(void); +void *pkt_ctrl_claim_outgoing_buffer(void); /*! * Commit the outgoing buffer. * \param num_lines how many lines written. */ -void commit_outgoing_buffer(size_t num_lines); +void pkt_ctrl_commit_outgoing_buffer(size_t num_lines); #endif /* INCLUDED_PKT_CTRL_H */ -- cgit v1.2.3 From 8fcd9f421315ade5768f0ff4e99dad4a1d0d1451 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 18 Nov 2010 16:28:17 -0800 Subject: packet_router: filter on dest ip addr and bcast mac addr --- firmware/microblaze/lib/net_common.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/firmware/microblaze/lib/net_common.c b/firmware/microblaze/lib/net_common.c index 486a34252..cb1ced46c 100644 --- a/firmware/microblaze/lib/net_common.c +++ b/firmware/microblaze/lib/net_common.c @@ -37,6 +37,8 @@ #include #include "pkt_ctrl.h" +static const eth_mac_addr_t BCAST_MAC_ADDR = {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}}; + static inline bool ip_addr_eq(const struct ip_addr a, const struct ip_addr b) { @@ -341,8 +343,7 @@ void send_gratuitous_arp(void){ memcpy(req.ar_tip, get_ip_addr(), sizeof(struct ip_addr)); //send the request with a broadcast ethernet mac address - eth_mac_addr_t t; memset(&t, 0xff, sizeof(t)); - send_pkt(t, ETHERTYPE_ARP, &req, sizeof(req), 0, 0, 0, 0); + send_pkt(BCAST_MAC_ADDR, ETHERTYPE_ARP, &req, sizeof(req), 0, 0, 0, 0); } static void @@ -390,13 +391,13 @@ handle_eth_packet(uint32_t *p, size_t nlines) { //print_buffer(p, nlines); - int ethertype = p[3] & 0xffff; + padded_eth_hdr_t *eth_hdr = (padded_eth_hdr_t *)p; - if (ethertype == ETHERTYPE_ARP){ + if (eth_hdr->ethertype == ETHERTYPE_ARP){ struct arp_eth_ipv4 *arp = (struct arp_eth_ipv4 *)(p + 4); handle_arp_packet(arp, nlines*sizeof(uint32_t) - 14); } - else if (ethertype == ETHERTYPE_IPV4){ + else if (eth_hdr->ethertype == ETHERTYPE_IPV4){ struct ip_hdr *ip = (struct ip_hdr *)(p + 4); if (IPH_V(ip) != 4 || IPH_HL(ip) != 5) // ignore pkts w/ bad version or options return; @@ -404,7 +405,10 @@ handle_eth_packet(uint32_t *p, size_t nlines) if (IPH_OFFSET(ip) & (IP_MF | IP_OFFMASK)) // ignore fragmented packets return; - // FIXME filter on dest ip addr (should be broadcast or for us) + // filter on dest ip addr (should be broadcast or for us) + bool is_bcast = memcmp(ð_hdr->dst, &BCAST_MAC_ADDR, sizeof(BCAST_MAC_ADDR)) == 0; + bool is_my_ip = memcmp(&ip->dest, &_local_ip_addr, sizeof(_local_ip_addr)) == 0; + if (!is_bcast && !is_my_ip) return; arp_cache_update(&ip->src, (eth_mac_addr_t *)(((char *)p)+8)); -- cgit v1.2.3 From a1f3a6605077ffb3275b094c58e8e9cdf78a899d Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 18 Nov 2010 19:30:55 -0800 Subject: packet_router: enable the serdes and always send GARP --- firmware/microblaze/apps/txrx_uhd.c | 2 +- firmware/microblaze/lib/u2_init.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/firmware/microblaze/apps/txrx_uhd.c b/firmware/microblaze/apps/txrx_uhd.c index 938491b0e..c61bc647c 100644 --- a/firmware/microblaze/apps/txrx_uhd.c +++ b/firmware/microblaze/apps/txrx_uhd.c @@ -283,12 +283,12 @@ void link_changed_callback(int speed){ if (speed != 0){ hal_set_leds(LED_RJ45, LED_RJ45); pkt_ctrl_set_routing_mode(PKT_CTRL_ROUTING_MODE_MASTER); - send_gratuitous_arp(); //garp after setting the routing mode } else{ hal_set_leds(0x0, LED_RJ45); pkt_ctrl_set_routing_mode(PKT_CTRL_ROUTING_MODE_SLAVE); } + send_gratuitous_arp(); } static void setup_network(void){ diff --git a/firmware/microblaze/lib/u2_init.c b/firmware/microblaze/lib/u2_init.c index a2669103a..9302c90b2 100644 --- a/firmware/microblaze/lib/u2_init.c +++ b/firmware/microblaze/lib/u2_init.c @@ -78,6 +78,8 @@ u2_init(void) printf("ad9510 reg[0x%x] = 0x%x\n", rr, vv); } #endif - + + output_regs->serdes_ctrl = (SERDES_ENABLE | SERDES_RXEN); + return true; } -- cgit v1.2.3 From 8f07cc031b944668f18112fd9ec11228227e2207 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 18 Nov 2010 20:10:50 -0800 Subject: packet_router: take that back and only garp when link is up (FIXME initial state before garp call) --- firmware/microblaze/apps/txrx_uhd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/microblaze/apps/txrx_uhd.c b/firmware/microblaze/apps/txrx_uhd.c index c61bc647c..8e2a35f58 100644 --- a/firmware/microblaze/apps/txrx_uhd.c +++ b/firmware/microblaze/apps/txrx_uhd.c @@ -283,12 +283,12 @@ void link_changed_callback(int speed){ if (speed != 0){ hal_set_leds(LED_RJ45, LED_RJ45); pkt_ctrl_set_routing_mode(PKT_CTRL_ROUTING_MODE_MASTER); + send_gratuitous_arp(); } else{ hal_set_leds(0x0, LED_RJ45); pkt_ctrl_set_routing_mode(PKT_CTRL_ROUTING_MODE_SLAVE); } - send_gratuitous_arp(); } static void setup_network(void){ -- cgit v1.2.3 From 9f28245c26c46e57448c4d8f3a2c4e038d6abd2a Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 19 Nov 2010 15:23:51 -0800 Subject: packet_router: added helper functions to packet router, added clear, fixed handshake, garp at start --- firmware/microblaze/apps/txrx_uhd.c | 6 +++++- firmware/microblaze/lib/net_common.c | 3 +++ firmware/microblaze/lib/pkt_ctrl.c | 39 +++++++++++++++++++++++++++--------- 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/firmware/microblaze/apps/txrx_uhd.c b/firmware/microblaze/apps/txrx_uhd.c index 8e2a35f58..f922ce4af 100644 --- a/firmware/microblaze/apps/txrx_uhd.c +++ b/firmware/microblaze/apps/txrx_uhd.c @@ -356,7 +356,11 @@ main(void) register_udp_listener(USRP2_UDP_DATA_PORT, handle_udp_data_packet); register_udp_listener(USRP2_UDP_UPDATE_PORT, handle_udp_fw_update_packet); - //3) setup ethernet hardware to bring the link up + //3) set the routing mode to slave and send a garp + 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); ethernet_init(); diff --git a/firmware/microblaze/lib/net_common.c b/firmware/microblaze/lib/net_common.c index cb1ced46c..48aa460f9 100644 --- a/firmware/microblaze/lib/net_common.c +++ b/firmware/microblaze/lib/net_common.c @@ -168,6 +168,7 @@ send_pkt(eth_mac_addr_t dst, int ethertype, total_len = 60; pkt_ctrl_commit_outgoing_buffer(total_len/4); + //printf("sent %d bytes\n", total_len); } unsigned int @@ -389,6 +390,8 @@ handle_arp_packet(struct arp_eth_ipv4 *p, size_t size) void handle_eth_packet(uint32_t *p, size_t nlines) { + //static size_t bcount = 0; + //printf("===> %d\n", bcount++); //print_buffer(p, nlines); padded_eth_hdr_t *eth_hdr = (padded_eth_hdr_t *)p; diff --git a/firmware/microblaze/lib/pkt_ctrl.c b/firmware/microblaze/lib/pkt_ctrl.c index f7f808cfc..a1e9ec1fe 100644 --- a/firmware/microblaze/lib/pkt_ctrl.c +++ b/firmware/microblaze/lib/pkt_ctrl.c @@ -30,36 +30,55 @@ static void set_control(uint32_t value, uint32_t mask){ buffer_pool_ctrl->ctrl = ctrl_shadow; } +static void set_control_bit(int bit){ + set_control(1 << bit, 1 << bit); +} + +static void clr_control_bit(int bit){ + set_control(0 << bit, 1 << bit); +} + +static bool is_status_bit_set(int bit){ + return buffer_pool_status->status & (1 << bit); +} + +#define INP_HS_BIT 0 //CPU out in packet_router.v +#define OUT_HS_BIT 1 //CPU inp in packet_router.v +#define MODE_BIT 2 +#define CLR_BIT 8 + void pkt_ctrl_set_routing_mode(pkt_ctrl_routing_mode_t mode){ switch(mode){ case PKT_CTRL_ROUTING_MODE_SLAVE: - set_control(0x0, 0x4); + clr_control_bit(MODE_BIT); break; case PKT_CTRL_ROUTING_MODE_MASTER: - set_control(0x4, 0x4); + 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){ - if ((buffer_pool_status->status & 0x1) != 1) return NULL; + if (!is_status_bit_set(INP_HS_BIT)) return NULL; *num_lines = (buffer_pool_status->status >> 16) & 0xffff; - set_control(0x1, 0x1); return buffer_ram(0); } void pkt_ctrl_release_incoming_buffer(void){ - set_control(0x0, 0x1); - while ((buffer_pool_status->status & 0x1) != 0){} + set_control_bit(INP_HS_BIT); + while (is_status_bit_set(INP_HS_BIT)){} + clr_control_bit(INP_HS_BIT); } void *pkt_ctrl_claim_outgoing_buffer(void){ - while ((buffer_pool_status->status & 0x2) != 0x2){} + while (!is_status_bit_set(OUT_HS_BIT)){} return buffer_ram(1); } void pkt_ctrl_commit_outgoing_buffer(size_t num_lines){ - set_control(0x2 | (num_lines << 16), 0x2 | (0xffff << 16)); - while ((buffer_pool_status->status & 0x2) != 0x0){} - set_control(0x0, 0x2); + set_control((1 << OUT_HS_BIT) | (num_lines << 16), (1 << OUT_HS_BIT) | (0xffff << 16)); + while (is_status_bit_set(OUT_HS_BIT)){} + clr_control_bit(OUT_HS_BIT); } -- cgit v1.2.3 From fe35b8ae0785fff7d33e18b62e3b435cfd5a5475 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 21 Nov 2010 12:17:01 -0800 Subject: packet_router: split control transaction for commit into two lines --- firmware/microblaze/lib/pkt_ctrl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/firmware/microblaze/lib/pkt_ctrl.c b/firmware/microblaze/lib/pkt_ctrl.c index a1e9ec1fe..9f662122d 100644 --- a/firmware/microblaze/lib/pkt_ctrl.c +++ b/firmware/microblaze/lib/pkt_ctrl.c @@ -78,7 +78,8 @@ void *pkt_ctrl_claim_outgoing_buffer(void){ } void pkt_ctrl_commit_outgoing_buffer(size_t num_lines){ - set_control((1 << OUT_HS_BIT) | (num_lines << 16), (1 << OUT_HS_BIT) | (0xffff << 16)); + set_control(num_lines << 16, 0xffff << 16); + set_control_bit(OUT_HS_BIT); while (is_status_bit_set(OUT_HS_BIT)){} clr_control_bit(OUT_HS_BIT); } -- cgit v1.2.3 From 6004410a7b73a52d95b8f5f0cf0fa969bef4e910 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 21 Nov 2010 13:36:25 -0800 Subject: packet_router: implemented code to program the addresses into the router --- firmware/microblaze/apps/txrx_uhd.c | 6 +++--- firmware/microblaze/lib/net_common.c | 15 +++------------ firmware/microblaze/lib/net_common.h | 4 +--- firmware/microblaze/lib/pkt_ctrl.c | 24 ++++++++++++++++++++++++ firmware/microblaze/lib/pkt_ctrl.h | 7 +++++++ 5 files changed, 38 insertions(+), 18 deletions(-) diff --git a/firmware/microblaze/apps/txrx_uhd.c b/firmware/microblaze/apps/txrx_uhd.c index f922ce4af..741167c0e 100644 --- a/firmware/microblaze/apps/txrx_uhd.c +++ b/firmware/microblaze/apps/txrx_uhd.c @@ -348,9 +348,9 @@ main(void) printf("Firmware compatibility number: %d\n", USRP2_FW_COMPAT_NUM); //1) register the addresses into the network stack - register_mac_addr(ethernet_mac_addr()); - register_ip_addr(get_ip_addr()); - + register_addrs(ethernet_mac_addr(), get_ip_addr()); + pkt_ctrl_register_addrs(ethernet_mac_addr(), get_ip_addr()); + //2) register callbacks for udp ports we service register_udp_listener(USRP2_UDP_CTRL_PORT, handle_udp_ctrl_packet); register_udp_listener(USRP2_UDP_DATA_PORT, handle_udp_data_packet); diff --git a/firmware/microblaze/lib/net_common.c b/firmware/microblaze/lib/net_common.c index 48aa460f9..e9b633b13 100644 --- a/firmware/microblaze/lib/net_common.c +++ b/firmware/microblaze/lib/net_common.c @@ -39,21 +39,12 @@ static const eth_mac_addr_t BCAST_MAC_ADDR = {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}}; -static inline bool -ip_addr_eq(const struct ip_addr a, const struct ip_addr b) -{ - return a.addr == b.addr; -} - // ------------------------------------------------------------------------ static eth_mac_addr_t _local_mac_addr; -void register_mac_addr(const eth_mac_addr_t *mac_addr){ - _local_mac_addr = *mac_addr; -} - static struct ip_addr _local_ip_addr; -void register_ip_addr(const struct ip_addr *ip_addr){ +void register_addrs(const eth_mac_addr_t *mac_addr, const struct ip_addr *ip_addr){ + _local_mac_addr = *mac_addr; _local_ip_addr = *ip_addr; } @@ -382,7 +373,7 @@ handle_arp_packet(struct arp_eth_ipv4 *p, size_t size) sip.addr = get_int32(p->ar_sip); tip.addr = get_int32(p->ar_tip); - if (ip_addr_eq(tip, _local_ip_addr)){ // They're looking for us... + if (memcmp(&tip, &_local_ip_addr, sizeof(_local_ip_addr)) == 0){ // They're looking for us... send_arp_reply(p, _local_mac_addr); } } diff --git a/firmware/microblaze/lib/net_common.h b/firmware/microblaze/lib/net_common.h index 9d6a3e345..5e364adeb 100644 --- a/firmware/microblaze/lib/net_common.h +++ b/firmware/microblaze/lib/net_common.h @@ -26,9 +26,7 @@ typedef void (*udp_receiver_t)(struct socket_address src, struct socket_address dst, unsigned char *payload, int payload_len); -void register_mac_addr(const eth_mac_addr_t *mac_addr); - -void register_ip_addr(const struct ip_addr *ip_addr); +void register_addrs(const eth_mac_addr_t *mac_addr, const struct ip_addr *ip_addr); void register_udp_listener(int port, udp_receiver_t rcvr); diff --git a/firmware/microblaze/lib/pkt_ctrl.c b/firmware/microblaze/lib/pkt_ctrl.c index 9f662122d..52ba80e3a 100644 --- a/firmware/microblaze/lib/pkt_ctrl.c +++ b/firmware/microblaze/lib/pkt_ctrl.c @@ -47,6 +47,30 @@ 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 +){ + //program in the ip addr + set_control(0x1 << 4, 0x7 << 4); + set_control((ip_addr->addr & 0x0000ffff) << 16, 0xffff << 16); + set_control(0x2 << 4, 0x7 << 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); +} + void pkt_ctrl_set_routing_mode(pkt_ctrl_routing_mode_t mode){ switch(mode){ case PKT_CTRL_ROUTING_MODE_SLAVE: diff --git a/firmware/microblaze/lib/pkt_ctrl.h b/firmware/microblaze/lib/pkt_ctrl.h index 86fb46d32..761209530 100644 --- a/firmware/microblaze/lib/pkt_ctrl.h +++ b/firmware/microblaze/lib/pkt_ctrl.h @@ -19,12 +19,19 @@ #define INCLUDED_PKT_CTRL_H #include +#include +#include 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 +); + //! Set the routing mode for this device void pkt_ctrl_set_routing_mode(pkt_ctrl_routing_mode_t mode); -- cgit v1.2.3 From 95499e2e132b1c619704b6fbc452e661633b3233 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 22 Nov 2010 13:54:48 -0800 Subject: packet_router: dont register mac, also reorganized some tidbits --- firmware/microblaze/apps/txrx_uhd.c | 2 +- firmware/microblaze/lib/banal.h | 18 ------------------ firmware/microblaze/lib/net_common.c | 11 +++++++++-- firmware/microblaze/lib/net_common.h | 7 +++++++ firmware/microblaze/lib/pkt_ctrl.c | 23 ++++------------------- firmware/microblaze/lib/pkt_ctrl.h | 7 ++----- 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 -#include #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 #include +/* + * 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 #include -#include 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... -- cgit v1.2.3 From 07de916b7646c78d4ad5ba9104d52343e993d198 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 23 Nov 2010 18:09:51 -0800 Subject: packet_router: added sregs for ip addr and ports the pkt control now programs the inspector with port and ip addr set the eth mac to pass all unicast added easy debug flag to net common --- firmware/microblaze/apps/txrx_uhd.c | 2 +- firmware/microblaze/lib/eth_mac.c | 4 +++- firmware/microblaze/lib/net_common.c | 10 ++++++---- firmware/microblaze/lib/pkt_ctrl.c | 16 +++++----------- firmware/microblaze/lib/pkt_ctrl.h | 8 ++++++-- firmware/microblaze/usrp2/memory_map.h | 2 ++ firmware/microblaze/usrp2p/memory_map.h | 2 ++ 7 files changed, 25 insertions(+), 19 deletions(-) diff --git a/firmware/microblaze/apps/txrx_uhd.c b/firmware/microblaze/apps/txrx_uhd.c index 6f852bb18..8ee53ac3e 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_ip_addr(get_ip_addr()); + pkt_ctrl_program_inspector(get_ip_addr(), USRP2_UDP_DATA_PORT); //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/eth_mac.c b/firmware/microblaze/lib/eth_mac.c index 034a4d494..581a5c69f 100644 --- a/firmware/microblaze/lib/eth_mac.c +++ b/firmware/microblaze/lib/eth_mac.c @@ -28,6 +28,7 @@ void eth_mac_set_addr(const eth_mac_addr_t *src) { + /* disable because MAC_SET_PASS_ALL is set below eth_mac->ucast_hi = (((unsigned int)src->addr[0])<<8) + ((unsigned int)src->addr[1]); @@ -36,6 +37,7 @@ eth_mac_set_addr(const eth_mac_addr_t *src) (((unsigned int)src->addr[3])<<16) + (((unsigned int)src->addr[4])<<8) + (((unsigned int)src->addr[5])); +*/ } @@ -45,7 +47,7 @@ eth_mac_init(const eth_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 | MAC_SET_PAUSE_SEND_EN; + eth_mac->settings = MAC_SET_PAUSE_EN | MAC_SET_PASS_BCAST | MAC_SET_PASS_UCAST | MAC_SET_PAUSE_SEND_EN | MAC_SET_PASS_ALL; eth_mac->pause_time = 38; eth_mac->pause_thresh = 1200; diff --git a/firmware/microblaze/lib/net_common.c b/firmware/microblaze/lib/net_common.c index 9804ae4c5..947f41dae 100644 --- a/firmware/microblaze/lib/net_common.c +++ b/firmware/microblaze/lib/net_common.c @@ -37,6 +37,8 @@ #include #include "pkt_ctrl.h" +static const bool debug = false; + static const eth_mac_addr_t BCAST_MAC_ADDR = {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}}; // ------------------------------------------------------------------------ @@ -159,7 +161,7 @@ send_pkt(eth_mac_addr_t dst, int ethertype, total_len = 60; pkt_ctrl_commit_outgoing_buffer(total_len/4); - //printf("sent %d bytes\n", total_len); + if (debug) printf("sent %d bytes\n", (int)total_len); } unsigned int CHKSUM(unsigned int x, unsigned int *chksum) @@ -388,9 +390,9 @@ handle_arp_packet(struct arp_eth_ipv4 *p, size_t size) void handle_eth_packet(uint32_t *p, size_t nlines) { - //static size_t bcount = 0; - //printf("===> %d\n", bcount++); - //print_buffer(p, nlines); + static size_t bcount = 0; + if (debug) printf("===> %d\n", (int)bcount++); + if (debug) print_buffer(p, nlines); padded_eth_hdr_t *eth_hdr = (padded_eth_hdr_t *)p; diff --git a/firmware/microblaze/lib/pkt_ctrl.c b/firmware/microblaze/lib/pkt_ctrl.c index 9870a1f8a..f4b4b7825 100644 --- a/firmware/microblaze/lib/pkt_ctrl.c +++ b/firmware/microblaze/lib/pkt_ctrl.c @@ -17,8 +17,6 @@ #include "pkt_ctrl.h" #include "memory_map.h" -#include -#include #include static void set_control(uint32_t value, uint32_t mask){ @@ -47,15 +45,11 @@ static bool is_status_bit_set(int bit){ #define MODE_BIT 2 #define CLR_BIT 8 -void pkt_ctrl_register_ip_addr(const struct ip_addr *ip_addr){ - //program in the ip addr - set_control(0x1 << 4, 0x3 << 4); - set_control((ip_addr->addr & 0x0000ffff) << 16, 0xffff << 16); - set_control(0x2 << 4, 0x3 << 4); - set_control((ip_addr->addr & 0xffff0000) << 0, 0xffff << 16); - - //clear cmd - set_control(0x0, 0x3 << 4); +void pkt_ctrl_program_inspector( + const struct ip_addr *ip_addr, uint16_t dsp_udp_port +){ + buffer_pool_ctrl->ip_addr = ip_addr->addr; + buffer_pool_ctrl->udp_ports = dsp_udp_port; } void pkt_ctrl_set_routing_mode(pkt_ctrl_routing_mode_t mode){ diff --git a/firmware/microblaze/lib/pkt_ctrl.h b/firmware/microblaze/lib/pkt_ctrl.h index 2e175bca0..927d1fc7a 100644 --- a/firmware/microblaze/lib/pkt_ctrl.h +++ b/firmware/microblaze/lib/pkt_ctrl.h @@ -19,6 +19,8 @@ #define INCLUDED_PKT_CTRL_H #include +#include +#include #include typedef enum { @@ -26,8 +28,10 @@ typedef enum { PKT_CTRL_ROUTING_MODE_MASTER, } pkt_ctrl_routing_mode_t; -//! Register the IP address into the router -void pkt_ctrl_register_ip_addr(const struct ip_addr *ip_addr); +//! Program the decision values into the packet inspector +void pkt_ctrl_program_inspector( + const struct ip_addr *ip_addr, uint16_t dsp_udp_port +); //! Set the routing mode for this device void pkt_ctrl_set_routing_mode(pkt_ctrl_routing_mode_t mode); diff --git a/firmware/microblaze/usrp2/memory_map.h b/firmware/microblaze/usrp2/memory_map.h index 2b07ff148..25c800893 100644 --- a/firmware/microblaze/usrp2/memory_map.h +++ b/firmware/microblaze/usrp2/memory_map.h @@ -247,6 +247,8 @@ hwconfig_wishbone_divisor(void) typedef struct { volatile uint32_t ctrl; + volatile uint32_t ip_addr; + volatile uint32_t udp_ports; //dsp0 (low 16) dsp1 (high 16) } buffer_pool_ctrl_t; #define buffer_pool_ctrl ((buffer_pool_ctrl_t *) BUFFER_POOL_CTRL_BASE) diff --git a/firmware/microblaze/usrp2p/memory_map.h b/firmware/microblaze/usrp2p/memory_map.h index 431dc19e7..dedfdac8b 100644 --- a/firmware/microblaze/usrp2p/memory_map.h +++ b/firmware/microblaze/usrp2p/memory_map.h @@ -274,6 +274,8 @@ hwconfig_wishbone_divisor(void) typedef struct { volatile uint32_t ctrl; + volatile uint32_t ip_addr; + volatile uint32_t udp_ports; //dsp0 (low 16) dsp1 (high 16) } buffer_pool_ctrl_t; #define buffer_pool_ctrl ((buffer_pool_ctrl_t *) BUFFER_POOL_CTRL_BASE) -- cgit v1.2.3 From 59a7133edf4ce2a939ac2b9a3264623fb269e9c6 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 24 Nov 2010 10:16:51 -0800 Subject: usrp-n: removed serdes control, its not needed, fw must set this up --- host/lib/usrp/usrp2/CMakeLists.txt | 2 -- host/lib/usrp/usrp2/mboard_impl.cpp | 1 - host/lib/usrp/usrp2/serdes_ctrl.cpp | 46 ------------------------------------- host/lib/usrp/usrp2/serdes_ctrl.hpp | 40 -------------------------------- host/lib/usrp/usrp2/usrp2_impl.hpp | 2 -- 5 files changed, 91 deletions(-) delete mode 100644 host/lib/usrp/usrp2/serdes_ctrl.cpp delete mode 100644 host/lib/usrp/usrp2/serdes_ctrl.hpp diff --git a/host/lib/usrp/usrp2/CMakeLists.txt b/host/lib/usrp/usrp2/CMakeLists.txt index afd69cae9..81b73fcc2 100644 --- a/host/lib/usrp/usrp2/CMakeLists.txt +++ b/host/lib/usrp/usrp2/CMakeLists.txt @@ -36,8 +36,6 @@ IF(ENABLE_USRP2) ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/gps_ctrl.cpp ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/io_impl.cpp ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/mboard_impl.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/serdes_ctrl.cpp - ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/serdes_ctrl.hpp ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/usrp2_iface.cpp ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/usrp2_iface.hpp ${CMAKE_SOURCE_DIR}/lib/usrp/usrp2/usrp2_impl.cpp diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp index 766ea993c..deb43bb13 100644 --- a/host/lib/usrp/usrp2/mboard_impl.cpp +++ b/host/lib/usrp/usrp2/mboard_impl.cpp @@ -58,7 +58,6 @@ usrp2_mboard_impl::usrp2_mboard_impl( //contruct the interfaces to mboard perifs _clock_ctrl = usrp2_clock_ctrl::make(_iface); _codec_ctrl = usrp2_codec_ctrl::make(_iface); - _serdes_ctrl = usrp2_serdes_ctrl::make(_iface); //_gps_ctrl = usrp2_gps_ctrl::make(_iface); //if(_gps_ctrl->gps_detected()) std::cout << "GPS time: " << _gps_ctrl->get_time() << std::endl; diff --git a/host/lib/usrp/usrp2/serdes_ctrl.cpp b/host/lib/usrp/usrp2/serdes_ctrl.cpp deleted file mode 100644 index 1cda22f45..000000000 --- a/host/lib/usrp/usrp2/serdes_ctrl.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// -// Copyright 2010 Ettus Research LLC -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - -#include "serdes_ctrl.hpp" -#include "usrp2_regs.hpp" - -using namespace uhd; - -/*! - * A usrp2 serdes control implementation - */ -class usrp2_serdes_ctrl_impl : public usrp2_serdes_ctrl{ -public: - usrp2_serdes_ctrl_impl(usrp2_iface::sptr iface){ - _iface = iface; - _iface->poke32(_iface->regs.misc_ctrl_serdes, U2_FLAG_MISC_CTRL_SERDES_ENABLE | U2_FLAG_MISC_CTRL_SERDES_RXEN); - } - - ~usrp2_serdes_ctrl_impl(void){ - _iface->poke32(_iface->regs.misc_ctrl_serdes, 0); //power-down - } - -private: - usrp2_iface::sptr _iface; -}; - -/*********************************************************************** - * Public make function for the usrp2 serdes control - **********************************************************************/ -usrp2_serdes_ctrl::sptr usrp2_serdes_ctrl::make(usrp2_iface::sptr iface){ - return sptr(new usrp2_serdes_ctrl_impl(iface)); -} diff --git a/host/lib/usrp/usrp2/serdes_ctrl.hpp b/host/lib/usrp/usrp2/serdes_ctrl.hpp deleted file mode 100644 index 3c909c531..000000000 --- a/host/lib/usrp/usrp2/serdes_ctrl.hpp +++ /dev/null @@ -1,40 +0,0 @@ -// -// Copyright 2010 Ettus Research LLC -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - -#ifndef INCLUDED_SERDES_CTRL_HPP -#define INCLUDED_SERDES_CTRL_HPP - -#include "usrp2_iface.hpp" -#include -#include - -class usrp2_serdes_ctrl : boost::noncopyable{ -public: - typedef boost::shared_ptr sptr; - - /*! - * Make a serdes control object for the usrp2 serdes port. - * \param _iface a pointer to the usrp2 interface object - * \return a new serdes control object - */ - static sptr make(usrp2_iface::sptr iface); - - //TODO fill me in with virtual methods - -}; - -#endif /* INCLUDED_SERDES_CTRL_HPP */ diff --git a/host/lib/usrp/usrp2/usrp2_impl.hpp b/host/lib/usrp/usrp2/usrp2_impl.hpp index aa8eb0155..d0bc175ca 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.hpp +++ b/host/lib/usrp/usrp2/usrp2_impl.hpp @@ -22,7 +22,6 @@ #include "clock_ctrl.hpp" #include "codec_ctrl.hpp" #include "gps_ctrl.hpp" -#include "serdes_ctrl.hpp" #include #include #include @@ -105,7 +104,6 @@ private: usrp2_iface::sptr _iface; usrp2_clock_ctrl::sptr _clock_ctrl; usrp2_codec_ctrl::sptr _codec_ctrl; - usrp2_serdes_ctrl::sptr _serdes_ctrl; usrp2_gps_ctrl::sptr _gps_ctrl; //properties for this mboard -- cgit v1.2.3 From ecdb22b449e13d1ded69b82e5736d4c09c7db23a Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 24 Nov 2010 20:26:38 -0800 Subject: packet_router: added cpu input and output control registers, modified control code --- firmware/microblaze/lib/pkt_ctrl.c | 54 +++++++++++---------------------- firmware/microblaze/usrp2/memory_map.h | 4 ++- firmware/microblaze/usrp2p/memory_map.h | 4 ++- 3 files changed, 23 insertions(+), 39 deletions(-) diff --git a/firmware/microblaze/lib/pkt_ctrl.c b/firmware/microblaze/lib/pkt_ctrl.c index f4b4b7825..d2bfc339d 100644 --- a/firmware/microblaze/lib/pkt_ctrl.c +++ b/firmware/microblaze/lib/pkt_ctrl.c @@ -19,32 +19,6 @@ #include "memory_map.h" #include -static void set_control(uint32_t value, uint32_t mask){ - static uint32_t ctrl_shadow = 0; - - ctrl_shadow &= ~mask; - ctrl_shadow |= value & mask; - - buffer_pool_ctrl->ctrl = ctrl_shadow; -} - -static void set_control_bit(int bit){ - set_control(1 << bit, 1 << bit); -} - -static void clr_control_bit(int bit){ - set_control(0 << bit, 1 << bit); -} - -static bool is_status_bit_set(int bit){ - return buffer_pool_status->status & (1 << bit); -} - -#define INP_HS_BIT 0 //CPU out in packet_router.v -#define OUT_HS_BIT 1 //CPU inp in packet_router.v -#define MODE_BIT 2 -#define CLR_BIT 8 - void pkt_ctrl_program_inspector( const struct ip_addr *ip_addr, uint16_t dsp_udp_port ){ @@ -55,34 +29,40 @@ void pkt_ctrl_program_inspector( void pkt_ctrl_set_routing_mode(pkt_ctrl_routing_mode_t mode){ switch(mode){ case PKT_CTRL_ROUTING_MODE_SLAVE: - clr_control_bit(MODE_BIT); + buffer_pool_ctrl->misc_ctrl = 0; break; case PKT_CTRL_ROUTING_MODE_MASTER: - set_control_bit(MODE_BIT); + buffer_pool_ctrl->misc_ctrl = 1; break; } } +static inline bool is_status_bit_set(int bit){ + return buffer_pool_status->status & (1 << bit); +} + +#define CPU_OUT_HS_BIT 0 //from packet router to CPU +#define CPU_INP_HS_BIT 1 //from CPU to packet router + void *pkt_ctrl_claim_incoming_buffer(size_t *num_lines){ - if (!is_status_bit_set(INP_HS_BIT)) return NULL; + if (!is_status_bit_set(CPU_OUT_HS_BIT)) return NULL; *num_lines = (buffer_pool_status->status >> 16) & 0xffff; return buffer_ram(0); } void pkt_ctrl_release_incoming_buffer(void){ - set_control_bit(INP_HS_BIT); - while (is_status_bit_set(INP_HS_BIT)){} - clr_control_bit(INP_HS_BIT); + buffer_pool_ctrl->cpu_out_ctrl = 1; + while (is_status_bit_set(CPU_OUT_HS_BIT)){} + buffer_pool_ctrl->cpu_out_ctrl = 0; } void *pkt_ctrl_claim_outgoing_buffer(void){ - while (!is_status_bit_set(OUT_HS_BIT)){} + while (!is_status_bit_set(CPU_INP_HS_BIT)){} return buffer_ram(1); } void pkt_ctrl_commit_outgoing_buffer(size_t num_lines){ - set_control(num_lines << 16, 0xffff << 16); - set_control_bit(OUT_HS_BIT); - while (is_status_bit_set(OUT_HS_BIT)){} - clr_control_bit(OUT_HS_BIT); + buffer_pool_ctrl->cpu_inp_ctrl = ((num_lines & 0xffff) << 16) | 1; + while (is_status_bit_set(CPU_INP_HS_BIT)){} + buffer_pool_ctrl->cpu_inp_ctrl = 0; } diff --git a/firmware/microblaze/usrp2/memory_map.h b/firmware/microblaze/usrp2/memory_map.h index 25c800893..09aef643e 100644 --- a/firmware/microblaze/usrp2/memory_map.h +++ b/firmware/microblaze/usrp2/memory_map.h @@ -246,9 +246,11 @@ hwconfig_wishbone_divisor(void) // --- buffer pool control regs --- typedef struct { - volatile uint32_t ctrl; + volatile uint32_t misc_ctrl; volatile uint32_t ip_addr; volatile uint32_t udp_ports; //dsp0 (low 16) dsp1 (high 16) + volatile uint32_t cpu_out_ctrl; + volatile uint32_t cpu_inp_ctrl; } buffer_pool_ctrl_t; #define buffer_pool_ctrl ((buffer_pool_ctrl_t *) BUFFER_POOL_CTRL_BASE) diff --git a/firmware/microblaze/usrp2p/memory_map.h b/firmware/microblaze/usrp2p/memory_map.h index dedfdac8b..277f433c5 100644 --- a/firmware/microblaze/usrp2p/memory_map.h +++ b/firmware/microblaze/usrp2p/memory_map.h @@ -273,9 +273,11 @@ hwconfig_wishbone_divisor(void) // --- buffer pool control regs --- typedef struct { - volatile uint32_t ctrl; + volatile uint32_t misc_ctrl; volatile uint32_t ip_addr; volatile uint32_t udp_ports; //dsp0 (low 16) dsp1 (high 16) + volatile uint32_t cpu_out_ctrl; + volatile uint32_t cpu_inp_ctrl; } buffer_pool_ctrl_t; #define buffer_pool_ctrl ((buffer_pool_ctrl_t *) BUFFER_POOL_CTRL_BASE) -- cgit v1.2.3 From 5f651c29913e3ae2616569ea6aef24d7a2f3f9d6 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 24 Nov 2010 20:30:42 -0800 Subject: packet_router: incremented fpga and fw compat numbers --- host/lib/usrp/usrp2/fw_common.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/host/lib/usrp/usrp2/fw_common.h b/host/lib/usrp/usrp2/fw_common.h index a9c39e650..efbb4b954 100644 --- a/host/lib/usrp/usrp2/fw_common.h +++ b/host/lib/usrp/usrp2/fw_common.h @@ -33,8 +33,8 @@ extern "C" { #endif //fpga and firmware compatibility numbers -#define USRP2_FPGA_COMPAT_NUM 3 -#define USRP2_FW_COMPAT_NUM 7 +#define USRP2_FPGA_COMPAT_NUM 4 +#define USRP2_FW_COMPAT_NUM 8 //used to differentiate control packets over data port #define USRP2_INVALID_VRT_HEADER 0 -- cgit v1.2.3 From 8af031ad8957817c5e93a2da41ca569dcd088a6f Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 24 Nov 2010 21:27:08 -0800 Subject: usrp-n: configure clocking over the serdes cable added status to register to readback master/slave mode removed mimo enum from clock config, its not relevant added serdes clock config to the update clock config method --- host/include/uhd/types/clock_config.hpp | 2 -- host/lib/usrp/usrp2/clock_ctrl.cpp | 4 +--- host/lib/usrp/usrp2/clock_ctrl.hpp | 4 +++- host/lib/usrp/usrp2/mboard_impl.cpp | 13 ++++++++++--- host/lib/usrp/usrp2/usrp2_regs.cpp | 1 + host/lib/usrp/usrp2/usrp2_regs.hpp | 1 + 6 files changed, 16 insertions(+), 9 deletions(-) diff --git a/host/include/uhd/types/clock_config.hpp b/host/include/uhd/types/clock_config.hpp index 9342fbb7b..5966dcf3a 100644 --- a/host/include/uhd/types/clock_config.hpp +++ b/host/include/uhd/types/clock_config.hpp @@ -32,12 +32,10 @@ namespace uhd{ REF_AUTO = 'a', //automatic (device specific) REF_INT = 'i', //internal reference REF_SMA = 's', //external sma port - REF_MIMO = 'm' //mimo cable (usrp2 only) } ref_source; enum pps_source_t { PPS_INT = 'i', //there is no internal PPS_SMA = 's', //external sma port - PPS_MIMO = 'm' //mimo cable (usrp2 only) } pps_source; enum pps_polarity_t { PPS_NEG = 'n', //negative edge diff --git a/host/lib/usrp/usrp2/clock_ctrl.cpp b/host/lib/usrp/usrp2/clock_ctrl.cpp index 428d5539b..7dde88027 100644 --- a/host/lib/usrp/usrp2/clock_ctrl.cpp +++ b/host/lib/usrp/usrp2/clock_ctrl.cpp @@ -66,13 +66,11 @@ public: this->enable_external_ref(false); this->enable_rx_dboard_clock(false); this->enable_tx_dboard_clock(false); + this->enable_mimo_clock_out(false); /* private clock enables, must be set here */ this->enable_dac_clock(true); this->enable_adc_clock(true); - - /* always driving the mimo reference */ - this->enable_mimo_clock_out(true); } ~usrp2_clock_ctrl_impl(void){ diff --git a/host/lib/usrp/usrp2/clock_ctrl.hpp b/host/lib/usrp/usrp2/clock_ctrl.hpp index db6c52c83..10523fa6b 100644 --- a/host/lib/usrp/usrp2/clock_ctrl.hpp +++ b/host/lib/usrp/usrp2/clock_ctrl.hpp @@ -91,8 +91,10 @@ public: virtual void enable_test_clock(bool enb) = 0; /*! - * TODO other clock control api here.... + * Enable/disable the ref clock output over the serdes cable. + * \param enb true to enable */ + virtual void enable_mimo_clock_out(bool enb) = 0; }; diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp index deb43bb13..20404635a 100644 --- a/host/lib/usrp/usrp2/mboard_impl.cpp +++ b/host/lib/usrp/usrp2/mboard_impl.cpp @@ -154,7 +154,6 @@ void usrp2_mboard_impl::update_clock_config(void){ //translate pps source enums switch(_clock_config.pps_source){ case clock_config_t::PPS_SMA: pps_flags |= U2_FLAG_TIME64_PPS_SMA; break; - case clock_config_t::PPS_MIMO: pps_flags |= U2_FLAG_TIME64_PPS_MIMO; break; default: throw std::runtime_error("unhandled clock configuration pps source"); } @@ -175,7 +174,6 @@ void usrp2_mboard_impl::update_clock_config(void){ switch(_clock_config.ref_source){ case clock_config_t::REF_INT : _iface->poke32(_iface->regs.misc_ctrl_clock, 0x12); break; case clock_config_t::REF_SMA : _iface->poke32(_iface->regs.misc_ctrl_clock, 0x1C); break; - case clock_config_t::REF_MIMO: _iface->poke32(_iface->regs.misc_ctrl_clock, 0x15); break; default: throw std::runtime_error("unhandled clock configuration reference source"); } _clock_ctrl->enable_external_ref(true); //USRP2P has an internal 10MHz TCXO @@ -186,7 +184,6 @@ void usrp2_mboard_impl::update_clock_config(void){ switch(_clock_config.ref_source){ case clock_config_t::REF_INT : _iface->poke32(_iface->regs.misc_ctrl_clock, 0x10); break; case clock_config_t::REF_SMA : _iface->poke32(_iface->regs.misc_ctrl_clock, 0x1C); break; - case clock_config_t::REF_MIMO: _iface->poke32(_iface->regs.misc_ctrl_clock, 0x15); break; default: throw std::runtime_error("unhandled clock configuration reference source"); } _clock_ctrl->enable_external_ref(_clock_config.ref_source != clock_config_t::REF_INT); @@ -194,6 +191,16 @@ void usrp2_mboard_impl::update_clock_config(void){ case usrp2_iface::USRP_NXXX: break; } + + //Handle the serdes clocking based on master/slave mode: + // - Masters always drive the clock over serdes. + // - Slaves always lock to this serdes clock. + // - Slaves lock their time over the serdes. + const bool master_mode = bool(_iface->peek32(_iface->regs.status) & (1 << 8)); + _clock_ctrl->enable_mimo_clock_out(master_mode); + if (not master_mode) _iface->poke32(_iface->regs.misc_ctrl_clock, 0x15); + //TODO slaves lock time over the serdes... + } void usrp2_mboard_impl::set_time_spec(const time_spec_t &time_spec, bool now){ diff --git a/host/lib/usrp/usrp2/usrp2_regs.cpp b/host/lib/usrp/usrp2/usrp2_regs.cpp index dd0433816..0590082f6 100644 --- a/host/lib/usrp/usrp2/usrp2_regs.cpp +++ b/host/lib/usrp/usrp2/usrp2_regs.cpp @@ -57,6 +57,7 @@ usrp2_regs_t usrp2_get_regs(bool use_n2xx_map) { x.time64_flags = sr_addr(misc_output_base, x.sr_time64 + 2); x.time64_imm = sr_addr(misc_output_base, x.sr_time64 + 3); x.time64_tps = sr_addr(misc_output_base, x.sr_time64 + 4); + x.status = bp_base + 4*8; x.time64_secs_rb = bp_base + 4*10; x.time64_ticks_rb = bp_base + 4*11; x.compat_num_rb = bp_base + 4*12; diff --git a/host/lib/usrp/usrp2/usrp2_regs.hpp b/host/lib/usrp/usrp2/usrp2_regs.hpp index 9936d634a..40c3635fb 100644 --- a/host/lib/usrp/usrp2/usrp2_regs.hpp +++ b/host/lib/usrp/usrp2/usrp2_regs.hpp @@ -57,6 +57,7 @@ typedef struct { int time64_flags; // flags -- see chart below int time64_imm; // set immediate (0=latch on next pps, 1=latch immediate, default=0) int time64_tps; // ticks per second rollover count + int status; int time64_secs_rb; int time64_ticks_rb; int compat_num_rb; -- cgit v1.2.3 From 0336b6fb3500fe12326a8618e65c1f48f0a36f1c Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Fri, 10 Dec 2010 12:18:02 -0800 Subject: packet_router: added set_mimo_clock_delay to clock_ctrl. Delay range is fixed right now to [0.444, 9.744]ns in 300ps increments --- host/lib/usrp/usrp2/clock_ctrl.cpp | 46 ++++++++++++++++++++++++++++++++++++++ host/lib/usrp/usrp2/clock_ctrl.hpp | 8 +++++++ 2 files changed, 54 insertions(+) diff --git a/host/lib/usrp/usrp2/clock_ctrl.cpp b/host/lib/usrp/usrp2/clock_ctrl.cpp index 7dde88027..73331e594 100644 --- a/host/lib/usrp/usrp2/clock_ctrl.cpp +++ b/host/lib/usrp/usrp2/clock_ctrl.cpp @@ -244,6 +244,52 @@ public: double get_master_clock_rate(void){ return 100e6; } + + void set_mimo_clock_delay(boost::uint8_t delay) { + //delay is a 5-bit value (0-31) for fine control + //the equations below determine delay for a given ramp current, # of caps and fine delay register + //delay range: + //range_ns = 200*((caps+3)/i_ramp_ua)*1.3286 + //offset (zero delay): + //offset_ns = 0.34 + (1600 - i_ramp_ua)*1e-4 + ((caps-1)/ramp)*6 + //delay_ns = offset_ns + range_ns * delay / 31 + + if(delay == 0) { + switch(clk_regs.exp) { + case 5: + _ad9510_regs.delay_control_out5 = 0; + break; + case 6: + _ad9510_regs.delay_control_out6 = 0; + break; + default: + break; //delay not supported on U2 rev 3 + } + } else { + switch(clk_regs.exp) { + case 5: + _ad9510_regs.delay_control_out5 = 1; + _ad9510_regs.ramp_current_out5 = ad9510_regs_t::RAMP_CURRENT_OUT5_200UA; + _ad9510_regs.ramp_capacitor_out5 = ad9510_regs_t::RAMP_CAPACITOR_OUT5_4CAPS; + _ad9510_regs.delay_fine_adjust_out5 = delay; + this->write_reg(0x34); + this->write_reg(0x35); + this->write_reg(0x36); + break; + case 6: + _ad9510_regs.delay_control_out6 = 1; + _ad9510_regs.ramp_current_out6 = ad9510_regs_t::RAMP_CURRENT_OUT6_200UA; + _ad9510_regs.ramp_capacitor_out6 = ad9510_regs_t::RAMP_CAPACITOR_OUT6_4CAPS; + _ad9510_regs.delay_fine_adjust_out6 = delay; + this->write_reg(0x38); + this->write_reg(0x39); + this->write_reg(0x3A); + break; + default: + break; + } + } + } private: /*! diff --git a/host/lib/usrp/usrp2/clock_ctrl.hpp b/host/lib/usrp/usrp2/clock_ctrl.hpp index 10523fa6b..2ec347cac 100644 --- a/host/lib/usrp/usrp2/clock_ctrl.hpp +++ b/host/lib/usrp/usrp2/clock_ctrl.hpp @@ -95,6 +95,14 @@ public: * \param enb true to enable */ virtual void enable_mimo_clock_out(bool enb) = 0; + + /*! + * Set the output delay of the mimo clock + * Used to synchronise daisy-chained USRPs over the MIMO cable + * Can also be used to adjust delay for uneven reference cable lengths + * \param delay in an arbitrary scaling + */ + virtual void set_mimo_clock_delay(boost::uint8_t delay) = 0; }; -- cgit v1.2.3 From 1bf0619c9ed076bfc85856138309e2fa9be8e371 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 10 Dec 2010 13:02:21 -0800 Subject: usrp2: configured clock delay over mimo cable --- host/lib/usrp/usrp2/clock_ctrl.cpp | 27 +++++++++++++++++---------- host/lib/usrp/usrp2/clock_ctrl.hpp | 4 ++-- host/lib/usrp/usrp2/mboard_impl.cpp | 19 ++++++++++++++++++- 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/host/lib/usrp/usrp2/clock_ctrl.cpp b/host/lib/usrp/usrp2/clock_ctrl.cpp index 73331e594..27ccefb2b 100644 --- a/host/lib/usrp/usrp2/clock_ctrl.cpp +++ b/host/lib/usrp/usrp2/clock_ctrl.cpp @@ -22,10 +22,13 @@ #include #include #include +#include #include using namespace uhd; +static const bool enb_test_clk = false; + /*! * A usrp2 clock control specific to the ad9510 ic. */ @@ -71,6 +74,7 @@ public: /* private clock enables, must be set here */ this->enable_dac_clock(true); this->enable_adc_clock(true); + this->enable_test_clock(enb_test_clk); } ~usrp2_clock_ctrl_impl(void){ @@ -81,6 +85,7 @@ public: this->enable_dac_clock(false); this->enable_adc_clock(false); this->enable_mimo_clock_out(false); + this->enable_test_clock(false); } void enable_mimo_clock_out(bool enb){ @@ -245,22 +250,24 @@ public: return 100e6; } - void set_mimo_clock_delay(boost::uint8_t delay) { - //delay is a 5-bit value (0-31) for fine control + void set_mimo_clock_delay(double delay) { + //delay_val is a 5-bit value (0-31) for fine control //the equations below determine delay for a given ramp current, # of caps and fine delay register //delay range: //range_ns = 200*((caps+3)/i_ramp_ua)*1.3286 //offset (zero delay): //offset_ns = 0.34 + (1600 - i_ramp_ua)*1e-4 + ((caps-1)/ramp)*6 //delay_ns = offset_ns + range_ns * delay / 31 - - if(delay == 0) { + + int delay_val = boost::math::iround(delay/9.744e-9*31); + + if(delay_val == 0) { switch(clk_regs.exp) { case 5: - _ad9510_regs.delay_control_out5 = 0; + _ad9510_regs.delay_control_out5 = 1; break; case 6: - _ad9510_regs.delay_control_out6 = 0; + _ad9510_regs.delay_control_out6 = 1; break; default: break; //delay not supported on U2 rev 3 @@ -268,19 +275,19 @@ public: } else { switch(clk_regs.exp) { case 5: - _ad9510_regs.delay_control_out5 = 1; + _ad9510_regs.delay_control_out5 = 0; _ad9510_regs.ramp_current_out5 = ad9510_regs_t::RAMP_CURRENT_OUT5_200UA; _ad9510_regs.ramp_capacitor_out5 = ad9510_regs_t::RAMP_CAPACITOR_OUT5_4CAPS; - _ad9510_regs.delay_fine_adjust_out5 = delay; + _ad9510_regs.delay_fine_adjust_out5 = delay_val; this->write_reg(0x34); this->write_reg(0x35); this->write_reg(0x36); break; case 6: - _ad9510_regs.delay_control_out6 = 1; + _ad9510_regs.delay_control_out6 = 0; _ad9510_regs.ramp_current_out6 = ad9510_regs_t::RAMP_CURRENT_OUT6_200UA; _ad9510_regs.ramp_capacitor_out6 = ad9510_regs_t::RAMP_CAPACITOR_OUT6_4CAPS; - _ad9510_regs.delay_fine_adjust_out6 = delay; + _ad9510_regs.delay_fine_adjust_out6 = delay_val; this->write_reg(0x38); this->write_reg(0x39); this->write_reg(0x3A); diff --git a/host/lib/usrp/usrp2/clock_ctrl.hpp b/host/lib/usrp/usrp2/clock_ctrl.hpp index 2ec347cac..9ccbc959e 100644 --- a/host/lib/usrp/usrp2/clock_ctrl.hpp +++ b/host/lib/usrp/usrp2/clock_ctrl.hpp @@ -100,9 +100,9 @@ public: * Set the output delay of the mimo clock * Used to synchronise daisy-chained USRPs over the MIMO cable * Can also be used to adjust delay for uneven reference cable lengths - * \param delay in an arbitrary scaling + * \param delay the clock delay in seconds */ - virtual void set_mimo_clock_delay(boost::uint8_t delay) = 0; + virtual void set_mimo_clock_delay(double delay) = 0; }; diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp index 20404635a..29867cf9d 100644 --- a/host/lib/usrp/usrp2/mboard_impl.cpp +++ b/host/lib/usrp/usrp2/mboard_impl.cpp @@ -198,7 +198,24 @@ void usrp2_mboard_impl::update_clock_config(void){ // - Slaves lock their time over the serdes. const bool master_mode = bool(_iface->peek32(_iface->regs.status) & (1 << 8)); _clock_ctrl->enable_mimo_clock_out(master_mode); - if (not master_mode) _iface->poke32(_iface->regs.misc_ctrl_clock, 0x15); + if (master_mode){ + switch(_iface->get_rev()){ + case usrp2_iface::USRP_N200: + case usrp2_iface::USRP_N210: + _clock_ctrl->set_mimo_clock_delay(0/*TODO*/); + break; + + case usrp2_iface::USRP2_REV4: + _clock_ctrl->set_mimo_clock_delay(3.08e-9); + break; + + default: break; //not handled + } + } + else{ + _iface->poke32(_iface->regs.misc_ctrl_clock, 0x15); + _clock_ctrl->enable_external_ref(true); + } //TODO slaves lock time over the serdes... } -- cgit v1.2.3 From 9e75fadc0476b93ea73a7cab905d0fcbbc74d2df Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 10 Dec 2010 14:04:07 -0800 Subject: usrp2: set time over serdes when slave, added constants to top of cpp file --- host/lib/usrp/usrp2/mboard_impl.cpp | 19 +++++++++++++------ host/lib/usrp/usrp2/usrp2_regs.cpp | 1 + host/lib/usrp/usrp2/usrp2_regs.hpp | 1 + 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp index 29867cf9d..ac447d209 100644 --- a/host/lib/usrp/usrp2/mboard_impl.cpp +++ b/host/lib/usrp/usrp2/mboard_impl.cpp @@ -27,6 +27,10 @@ #include #include +static const double mimo_clock_delay_usrp2_rev4 = 4.18e-9; +static const double mimo_clock_delay_usrp_n2xx = 0; //TODO +static const int mimo_clock_sync_delay_cycles = 134; + using namespace uhd; using namespace uhd::usrp; using namespace boost::posix_time; @@ -196,27 +200,30 @@ void usrp2_mboard_impl::update_clock_config(void){ // - Masters always drive the clock over serdes. // - Slaves always lock to this serdes clock. // - Slaves lock their time over the serdes. - const bool master_mode = bool(_iface->peek32(_iface->regs.status) & (1 << 8)); - _clock_ctrl->enable_mimo_clock_out(master_mode); - if (master_mode){ + if (_iface->peek32(_iface->regs.status) & (1 << 8)){ + _clock_ctrl->enable_mimo_clock_out(true); switch(_iface->get_rev()){ case usrp2_iface::USRP_N200: case usrp2_iface::USRP_N210: - _clock_ctrl->set_mimo_clock_delay(0/*TODO*/); + _clock_ctrl->set_mimo_clock_delay(mimo_clock_delay_usrp_n2xx); break; case usrp2_iface::USRP2_REV4: - _clock_ctrl->set_mimo_clock_delay(3.08e-9); + _clock_ctrl->set_mimo_clock_delay(mimo_clock_delay_usrp2_rev4); break; default: break; //not handled } + _iface->poke32(_iface->regs.time64_mimo_sync, 0); } else{ _iface->poke32(_iface->regs.misc_ctrl_clock, 0x15); _clock_ctrl->enable_external_ref(true); + _clock_ctrl->enable_mimo_clock_out(false); + _iface->poke32(_iface->regs.time64_mimo_sync, + (1 << 8) | (mimo_clock_sync_delay_cycles & 0xff) + ); } - //TODO slaves lock time over the serdes... } diff --git a/host/lib/usrp/usrp2/usrp2_regs.cpp b/host/lib/usrp/usrp2/usrp2_regs.cpp index 0590082f6..82ad30f08 100644 --- a/host/lib/usrp/usrp2/usrp2_regs.cpp +++ b/host/lib/usrp/usrp2/usrp2_regs.cpp @@ -57,6 +57,7 @@ usrp2_regs_t usrp2_get_regs(bool use_n2xx_map) { x.time64_flags = sr_addr(misc_output_base, x.sr_time64 + 2); x.time64_imm = sr_addr(misc_output_base, x.sr_time64 + 3); x.time64_tps = sr_addr(misc_output_base, x.sr_time64 + 4); + x.time64_mimo_sync = sr_addr(misc_output_base, x.sr_time64 + 5); x.status = bp_base + 4*8; x.time64_secs_rb = bp_base + 4*10; x.time64_ticks_rb = bp_base + 4*11; diff --git a/host/lib/usrp/usrp2/usrp2_regs.hpp b/host/lib/usrp/usrp2/usrp2_regs.hpp index 40c3635fb..0311ac625 100644 --- a/host/lib/usrp/usrp2/usrp2_regs.hpp +++ b/host/lib/usrp/usrp2/usrp2_regs.hpp @@ -57,6 +57,7 @@ typedef struct { int time64_flags; // flags -- see chart below int time64_imm; // set immediate (0=latch on next pps, 1=latch immediate, default=0) int time64_tps; // ticks per second rollover count + int time64_mimo_sync; int status; int time64_secs_rb; int time64_ticks_rb; -- cgit v1.2.3 From e53662172430ba055f6b60d74c142995aa24deaf Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 10 Dec 2010 15:31:53 -0800 Subject: added docs for mimo cable usage --- host/docs/usrp2.rst | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/host/docs/usrp2.rst b/host/docs/usrp2.rst index 8e5743102..326943f59 100644 --- a/host/docs/usrp2.rst +++ b/host/docs/usrp2.rst @@ -101,7 +101,7 @@ On some systems, the firewall will block UDP broadcast packets. It is recommended that you change or disable your firewall settings. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Multiple device configuration +Multiple devices per host ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ For maximum throughput, one ethernet interface per USRP2 is recommended, although multiple devices may be connected via a gigabit ethernet switch. @@ -209,6 +209,18 @@ Example device address string representation for 2 USRP2s with IPv4 addresses 19 addr0=192.168.10.2, addr1=192.168.20.2 +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +MIMO cable configuration +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Using the MIMO cable, two USRP devices can be grouped together in a multi-device configuration. +Only one device in the configuration can be attached to the ethernet. +This device will be referred to as the master, and the other device, the slave. + +* The master provides reference clock and time synchronization to the slave. +* All data passing between the host and the slave is router over the MIMO cable. +* Both master and slave must have different IPv4 addresses but in the same subnet. +* The master and slave may be used individually or in a multi-device configuration. + ------------------------------------------------------------------------ Hardware setup notes ------------------------------------------------------------------------ -- cgit v1.2.3 From 096405b9291d1d3b3ac37d9768232cca43a37db6 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 10 Dec 2010 18:57:17 -0800 Subject: packet_router: added control register to set the udp control port --- firmware/microblaze/apps/txrx_uhd.c | 2 +- firmware/microblaze/lib/pkt_ctrl.c | 5 +++-- firmware/microblaze/lib/pkt_ctrl.h | 2 +- firmware/microblaze/usrp2/memory_map.h | 3 ++- firmware/microblaze/usrp2p/memory_map.h | 3 ++- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/firmware/microblaze/apps/txrx_uhd.c b/firmware/microblaze/apps/txrx_uhd.c index 8ee53ac3e..dc41e56c4 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_program_inspector(get_ip_addr(), USRP2_UDP_DATA_PORT); + pkt_ctrl_program_inspector(get_ip_addr(), USRP2_UDP_CTRL_PORT, USRP2_UDP_DATA_PORT); //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/pkt_ctrl.c b/firmware/microblaze/lib/pkt_ctrl.c index d2bfc339d..7e095ec00 100644 --- a/firmware/microblaze/lib/pkt_ctrl.c +++ b/firmware/microblaze/lib/pkt_ctrl.c @@ -20,10 +20,11 @@ #include void pkt_ctrl_program_inspector( - const struct ip_addr *ip_addr, uint16_t dsp_udp_port + const struct ip_addr *ip_addr, uint16_t ctrl_port, uint16_t data_port ){ buffer_pool_ctrl->ip_addr = ip_addr->addr; - buffer_pool_ctrl->udp_ports = dsp_udp_port; + buffer_pool_ctrl->ctrl_ports = ctrl_port; + buffer_pool_ctrl->data_ports = data_port; } void pkt_ctrl_set_routing_mode(pkt_ctrl_routing_mode_t mode){ diff --git a/firmware/microblaze/lib/pkt_ctrl.h b/firmware/microblaze/lib/pkt_ctrl.h index 927d1fc7a..346e22094 100644 --- a/firmware/microblaze/lib/pkt_ctrl.h +++ b/firmware/microblaze/lib/pkt_ctrl.h @@ -30,7 +30,7 @@ typedef enum { //! Program the decision values into the packet inspector void pkt_ctrl_program_inspector( - const struct ip_addr *ip_addr, uint16_t dsp_udp_port + const struct ip_addr *ip_addr, uint16_t ctrl_port, uint16_t data_port ); //! Set the routing mode for this device diff --git a/firmware/microblaze/usrp2/memory_map.h b/firmware/microblaze/usrp2/memory_map.h index 09aef643e..23d96389f 100644 --- a/firmware/microblaze/usrp2/memory_map.h +++ b/firmware/microblaze/usrp2/memory_map.h @@ -248,7 +248,8 @@ hwconfig_wishbone_divisor(void) typedef struct { volatile uint32_t misc_ctrl; volatile uint32_t ip_addr; - volatile uint32_t udp_ports; //dsp0 (low 16) dsp1 (high 16) + volatile uint32_t ctrl_ports; //ctrl (low 16) other (high 16) + volatile uint32_t data_ports; //dsp0 (low 16) dsp1 (high 16) volatile uint32_t cpu_out_ctrl; volatile uint32_t cpu_inp_ctrl; } buffer_pool_ctrl_t; diff --git a/firmware/microblaze/usrp2p/memory_map.h b/firmware/microblaze/usrp2p/memory_map.h index 277f433c5..5edb3b313 100644 --- a/firmware/microblaze/usrp2p/memory_map.h +++ b/firmware/microblaze/usrp2p/memory_map.h @@ -275,7 +275,8 @@ hwconfig_wishbone_divisor(void) typedef struct { volatile uint32_t misc_ctrl; volatile uint32_t ip_addr; - volatile uint32_t udp_ports; //dsp0 (low 16) dsp1 (high 16) + volatile uint32_t ctrl_ports; //ctrl (low 16) other (high 16) + volatile uint32_t data_ports; //dsp0 (low 16) dsp1 (high 16) volatile uint32_t cpu_out_ctrl; volatile uint32_t cpu_inp_ctrl; } buffer_pool_ctrl_t; -- cgit v1.2.3 From 219bcb1af4a84010f3349acb5f352fa3ce3f76d7 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 13 Dec 2010 15:54:56 -0800 Subject: packet_router: reject icmp dest unreachable when port does not match --- firmware/microblaze/apps/txrx_uhd.c | 2 +- firmware/microblaze/lib/net_common.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/firmware/microblaze/apps/txrx_uhd.c b/firmware/microblaze/apps/txrx_uhd.c index dc41e56c4..e9c98c26e 100644 --- a/firmware/microblaze/apps/txrx_uhd.c +++ b/firmware/microblaze/apps/txrx_uhd.c @@ -53,7 +53,7 @@ static void setup_network(void); // the fast-path setup global variables // ---------------------------------------------------------------- static eth_mac_addr_t fp_mac_addr_src, fp_mac_addr_dst; -static struct socket_address fp_socket_src, fp_socket_dst; +extern struct socket_address fp_socket_src, fp_socket_dst; void handle_udp_data_packet( struct socket_address src, struct socket_address dst, diff --git a/firmware/microblaze/lib/net_common.c b/firmware/microblaze/lib/net_common.c index 947f41dae..a34ca615b 100644 --- a/firmware/microblaze/lib/net_common.c +++ b/firmware/microblaze/lib/net_common.c @@ -41,6 +41,9 @@ static const bool debug = false; static const eth_mac_addr_t BCAST_MAC_ADDR = {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}}; +//used in the top level application... +struct socket_address fp_socket_src, fp_socket_dst; + // ------------------------------------------------------------------------ static eth_mac_addr_t _local_mac_addr; @@ -265,6 +268,11 @@ handle_icmp_packet(struct ip_addr src, struct ip_addr dst, if (icmp->code == ICMP_DUR_PORT){ // port unreachable //handle destination port unreachable (the host ctrl+c'd the app): + //filter out non udp data response + struct ip_hdr *ip = (struct ip_hdr *)(((uint8_t*)icmp) + sizeof(struct icmp_echo_hdr)); + struct udp_hdr *udp = (struct udp_hdr *)(((char *)ip) + IP_HLEN); + if (IPH_PROTO(ip) != IP_PROTO_UDP || udp->dest != fp_socket_dst.port) return; + //end async update packets per second sr_tx_ctrl->cyc_per_up = 0; -- cgit v1.2.3 From 5952f5bb6b3411c36633c4327b0c265991bf791a Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 13 Dec 2010 16:38:31 -0800 Subject: usrp2: added clocking notes to mimo cable docs --- host/docs/usrp2.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/host/docs/usrp2.rst b/host/docs/usrp2.rst index 326943f59..04622b9ce 100644 --- a/host/docs/usrp2.rst +++ b/host/docs/usrp2.rst @@ -217,9 +217,10 @@ Only one device in the configuration can be attached to the ethernet. This device will be referred to as the master, and the other device, the slave. * The master provides reference clock and time synchronization to the slave. -* All data passing between the host and the slave is router over the MIMO cable. +* All data passing between the host and the slave is routed over the MIMO cable. * Both master and slave must have different IPv4 addresses but in the same subnet. * The master and slave may be used individually or in a multi-device configuration. +* External clocking is optional, and should only be supplied to the master device. ------------------------------------------------------------------------ Hardware setup notes -- cgit v1.2.3 From 4d9b9ae7e9fe36bf7c1e2e60a37845e9cc4ecee3 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 13 Dec 2010 23:39:28 -0800 Subject: usrp2: added mimo_mode address arg and documented it --- host/docs/usrp2.rst | 57 +++++++++++++++++++++++++++++++++---- host/lib/usrp/usrp2/mboard_impl.cpp | 24 ++++++++++++---- host/lib/usrp/usrp2/usrp2_impl.cpp | 14 ++++----- host/lib/usrp/usrp2/usrp2_impl.hpp | 7 +++-- 4 files changed, 82 insertions(+), 20 deletions(-) diff --git a/host/docs/usrp2.rst b/host/docs/usrp2.rst index 04622b9ce..3031a0075 100644 --- a/host/docs/usrp2.rst +++ b/host/docs/usrp2.rst @@ -209,19 +209,66 @@ Example device address string representation for 2 USRP2s with IPv4 addresses 19 addr0=192.168.10.2, addr1=192.168.20.2 +------------------------------------------------------------------------ +Using the MIMO Cable +------------------------------------------------------------------------ +The MIMO cable allows two USRP devices to share reference clocks, +time synchronization, and the ethernet interface. + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -MIMO cable configuration +Shared ethernet mode ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Using the MIMO cable, two USRP devices can be grouped together in a multi-device configuration. -Only one device in the configuration can be attached to the ethernet. +In shared ethernet mode, +only one device in the configuration can be attached to the ethernet. This device will be referred to as the master, and the other device, the slave. * The master provides reference clock and time synchronization to the slave. * All data passing between the host and the slave is routed over the MIMO cable. -* Both master and slave must have different IPv4 addresses but in the same subnet. +* Both master and slave must have different IPv4 addresses in the same subnet. +* The master and slave may be used individually or in a multi-device configuration. +* External clocking is optional, and should only be supplied to the master device. +* The role of slave and master may be switched with the "mimo_mode" device address (see dual ethernet mode). + +Example device address string representation for 2 USRP2s with IPv4 addresses 192.168.10.2 (master) and 192.168.10.3 (slave) +:: + + -- Multi-device example -- + + addr0=192.168.10.2, addr1=192.168.10.3 + + -- Two single devices example -- + + addr=192.168.10.2 + + addr=192.168.10.3 + +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Dual ethernet mode +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +In dual ethernet mode, +both devices in the configuration must be attached to the ethernet. +One of the devices in the configuration will be configured to provide synchronization. +This device will be referred to as the master, and the other device, the slave. + +* The master provides reference clock and time synchronization to the slave. +* The devices require the special device address argument "mimo_mode" set. +* Both master and slave must have different IPv4 addresses in different subnets. * The master and slave may be used individually or in a multi-device configuration. * External clocking is optional, and should only be supplied to the master device. +Example device address string representation for 2 USRP2s with IPv4 addresses 192.168.10.2 (master) and 192.168.20.2 (slave) +:: + + -- Multi-device example -- + + addr0=192.168.10.2, mimo_mode0=master, addr1=192.168.20.2, mimo_mode1=slave + + -- Two single devices example -- + + addr=192.168.10.2, mimo_mode=master + + addr=192.168.20.2, mimo_mode=slave + ------------------------------------------------------------------------ Hardware setup notes ------------------------------------------------------------------------ @@ -233,7 +280,7 @@ The LEDs on the front panel can be useful in debugging hardware and software iss The LEDs reveal the following about the state of the device: * **LED A:** transmitting -* **LED B:** serdes link +* **LED B:** mimo cable link * **LED C:** receiving * **LED D:** firmware loaded * **LED E:** reference lock diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp index ac447d209..b8ebd6030 100644 --- a/host/lib/usrp/usrp2/mboard_impl.cpp +++ b/host/lib/usrp/usrp2/mboard_impl.cpp @@ -42,8 +42,8 @@ usrp2_mboard_impl::usrp2_mboard_impl( size_t index, transport::udp_simple::sptr ctrl_transport, transport::zero_copy_if::sptr data_transport, - size_t recv_samps_per_packet, - const device_addr_t &flow_control_hints + const device_addr_t &device_args, + size_t recv_samps_per_packet ): _index(index), _iface(usrp2_iface::make(ctrl_transport)) @@ -101,14 +101,14 @@ usrp2_mboard_impl::usrp2_mboard_impl( _iface->poke32(_iface->regs.tx_ctrl_policy, U2_FLAG_TX_CTRL_POLICY_NEXT_PACKET); //setting the cycles per update (disabled by default) - const double ups_per_sec = flow_control_hints.cast("ups_per_sec", 0.0); + const double ups_per_sec = device_args.cast("ups_per_sec", 0.0); if (ups_per_sec > 0.0){ const size_t cycles_per_up = size_t(_clock_ctrl->get_master_clock_rate()/ups_per_sec); _iface->poke32(_iface->regs.tx_ctrl_cycles_per_up, U2_FLAG_TX_CTRL_UP_ENB | cycles_per_up); } //setting the packets per update (enabled by default) - const double ups_per_fifo = flow_control_hints.cast("ups_per_fifo", 8.0); + const double ups_per_fifo = device_args.cast("ups_per_fifo", 8.0); if (ups_per_fifo > 0.0){ const size_t packets_per_up = size_t(usrp2_impl::sram_bytes/ups_per_fifo/data_transport->get_send_frame_size()); _iface->poke32(_iface->regs.tx_ctrl_packets_per_up, U2_FLAG_TX_CTRL_UP_ENB | packets_per_up); @@ -121,6 +121,20 @@ usrp2_mboard_impl::usrp2_mboard_impl( init_duc_config(); //initialize the clock configuration + if (device_args.has_key("mimo_mode")){ + if (device_args["mimo_mode"] == "master"){ + _mimo_clocking_mode_is_master = true; + } + else if (device_args["mimo_mode"] == "slave"){ + _mimo_clocking_mode_is_master = false; + } + else throw std::runtime_error( + "mimo_mode must be set to master or slave" + ); + } + else { + _mimo_clocking_mode_is_master = bool(_iface->peek32(_iface->regs.status) & (1 << 8)); + } init_clock_config(); //init the codec before the dboard @@ -200,7 +214,7 @@ void usrp2_mboard_impl::update_clock_config(void){ // - Masters always drive the clock over serdes. // - Slaves always lock to this serdes clock. // - Slaves lock their time over the serdes. - if (_iface->peek32(_iface->regs.status) & (1 << 8)){ + if (_mimo_clocking_mode_is_master){ _clock_ctrl->enable_mimo_clock_out(true); switch(_iface->get_rev()){ case usrp2_iface::USRP_N200: diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp index c3bbe4d65..133c39a35 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.cpp +++ b/host/lib/usrp/usrp2/usrp2_impl.cpp @@ -201,8 +201,9 @@ sep_indexed_dev_addrs(device_addr); //create a ctrl and data transport for each address std::vector ctrl_transports; std::vector data_transports; + const device_addrs_t device_addrs = sep_indexed_dev_addrs(device_addr); - BOOST_FOREACH(const device_addr_t &dev_addr_i, sep_indexed_dev_addrs(device_addr)){ + BOOST_FOREACH(const device_addr_t &dev_addr_i, device_addrs){ ctrl_transports.push_back(udp_simple::make_connected( dev_addr_i["addr"], num2str(USRP2_UDP_CTRL_PORT) )); @@ -213,7 +214,7 @@ sep_indexed_dev_addrs(device_addr); //create the usrp2 implementation guts return device::sptr( - new usrp2_impl(ctrl_transports, data_transports, device_addr) + new usrp2_impl(ctrl_transports, data_transports, device_addrs) ); } @@ -227,7 +228,7 @@ UHD_STATIC_BLOCK(register_usrp2_device){ usrp2_impl::usrp2_impl( std::vector ctrl_transports, std::vector data_transports, - const device_addr_t &flow_control_hints + const device_addrs_t &device_args ): _data_transports(data_transports) { @@ -244,11 +245,10 @@ usrp2_impl::usrp2_impl( //!!!!! set the otw type here before continuing, its used below //create a new mboard handler for each control transport - for(size_t i = 0; i < ctrl_transports.size(); i++){ + for(size_t i = 0; i < device_args.size(); i++){ _mboards.push_back(usrp2_mboard_impl::sptr(new usrp2_mboard_impl( - i, ctrl_transports[i], data_transports[i], - this->get_max_recv_samps_per_packet(), - flow_control_hints + i, ctrl_transports[i], data_transports[i], device_args[i], + this->get_max_recv_samps_per_packet() ))); //use an empty name when there is only one mboard std::string name = (ctrl_transports.size() > 1)? boost::lexical_cast(i) : ""; diff --git a/host/lib/usrp/usrp2/usrp2_impl.hpp b/host/lib/usrp/usrp2/usrp2_impl.hpp index d0bc175ca..85c00b079 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.hpp +++ b/host/lib/usrp/usrp2/usrp2_impl.hpp @@ -85,8 +85,8 @@ public: size_t index, uhd::transport::udp_simple::sptr, uhd::transport::zero_copy_if::sptr, - size_t recv_samps_per_packet, - const uhd::device_addr_t &flow_control_hints + const uhd::device_addr_t &device_args, + size_t recv_samps_per_packet ); ~usrp2_mboard_impl(void); @@ -99,6 +99,7 @@ public: private: size_t _index; bool _continuous_streaming; + bool _mimo_clocking_mode_is_master; //interfaces usrp2_iface::sptr _iface; @@ -190,7 +191,7 @@ public: usrp2_impl( std::vector ctrl_transports, std::vector data_transports, - const uhd::device_addr_t &flow_control_hints + const uhd::device_addrs_t &device_args ); ~usrp2_impl(void); -- cgit v1.2.3