aboutsummaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2016-08-01 18:17:41 -0700
committerMartin Braun <martin.braun@ettus.com>2016-08-09 12:42:52 -0700
commit3bf4b000f7d9a7f4af82c21753556ede7e8df6e3 (patch)
tree2228d7eb58c4d83d91192cb9b6a908e4e49f6317 /firmware
parentc5b076173e2d866f3ee99c113a37183c5ec20f0b (diff)
downloaduhd-3bf4b000f7d9a7f4af82c21753556ede7e8df6e3.tar.gz
uhd-3bf4b000f7d9a7f4af82c21753556ede7e8df6e3.tar.bz2
uhd-3bf4b000f7d9a7f4af82c21753556ede7e8df6e3.zip
Merging RFNoC support for X310
Diffstat (limited to 'firmware')
-rwxr-xr-xfirmware/usrp3/x300/x300_debug.py125
-rw-r--r--firmware/usrp3/x300/x300_defs.h2
-rw-r--r--firmware/usrp3/x300/x300_main.c22
3 files changed, 90 insertions, 59 deletions
diff --git a/firmware/usrp3/x300/x300_debug.py b/firmware/usrp3/x300/x300_debug.py
index 5fb55dc9d..e134a7275 100755
--- a/firmware/usrp3/x300/x300_debug.py
+++ b/firmware/usrp3/x300/x300_debug.py
@@ -1,9 +1,6 @@
-from __future__ import print_function
-from builtins import range
-from builtins import object
#!/usr/bin/env python
#
-# Copyright 2010-2011 Ettus Research LLC
+# Copyright 2010-2014 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
@@ -19,7 +16,7 @@ from builtins import object
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-import argparse
+import optparse
import math
import socket
import struct
@@ -34,16 +31,26 @@ X300_FW_COMMS_FLAGS_ERROR = 2
X300_FW_COMMS_FLAGS_POKE32 = 4
X300_FW_COMMS_FLAGS_PEEK32 = 8
+X300_FIXED_PORTS = 5
+
+X300_ZPU_MISC_SR_BUS_OFFSET = 0xA000
+X300_ZPU_XBAR_SR_BUS_OFFSET = 0xB000
+
+# Settings register bus addresses (hangs off ZPU wishbone bus)
+# Multiple by 4 as ZPU wishbone bus is word aligned
+X300_SR_NUM_CE = X300_ZPU_MISC_SR_BUS_OFFSET + 4*7
+X300_SR_RB_ADDR_XBAR = X300_ZPU_MISC_SR_BUS_OFFSET + 4*128
+# Readback addresses
+X300_RB_CROSSBAR = X300_ZPU_MISC_SR_BUS_OFFSET + 4*128
+
#UDP_CTRL_PORT = 49183
UDP_MAX_XFER_BYTES = 1024
UDP_TIMEOUT = 3
-#USRP2_FW_PROTO_VERSION = 11 #should be unused after r6
#REG_ARGS_FMT = '!LLLLLB15x'
#REG_IP_FMT = '!LLLL20x'
REG_PEEK_POKE_FMT = '!LLLL'
-
_seq = -1
def seq():
global _seq
@@ -80,31 +87,51 @@ class ctrl_socket(object):
self._sock.send(pkt)
return self._sock.recv(UDP_MAX_XFER_BYTES)
- def read_router_stats(self):
- print()
- print((" "), end=' ')
- ports = [' eth0',' eth1',' radio0',' radio1',' compute0',' compute1',' compute2',' pcie']
- for in_prt in ports:
- print(("%s" % in_prt), end=' ')
- print(" Egress Port")
- print((" "), end=' ')
- for in_prt in range (0, 8):
- print(("____________"), end=' ')
- print()
- for in_prt in range (0, 8):
- print(("%s |" % ports[in_prt]), end=' ')
- for out_prt in range (0, 8):
- out_pkt = pack_reg_peek_poke_fmt(X300_FW_COMMS_FLAGS_PEEK32|X300_FW_COMMS_FLAGS_ACK, seq(), 0xA000+256+((in_prt*8+out_prt)*4), 0)
- in_pkt = self.send_and_recv(out_pkt)
- (flags, rxseq, addr, data) = unpack_reg_peek_poke_fmt(in_pkt)
- if flags & X300_FW_COMMS_FLAGS_ERROR == X300_FW_COMMS_FLAGS_ERROR:
- raise Exception("X300 peek returns error code")
- print(("%10d " % (data)), end=' ')
- print()
- print()
+ def read_router_stats(self, blocks=None, ignore=None):
+ # Readback number of CEs
+ num_ports = self.peek(X300_SR_NUM_CE) + X300_FIXED_PORTS
+ ports = ['eth0', 'eth1', 'pcie', 'radio0', 'radio1'] + ["Block{num}".format(num=x) for x in range(num_ports-X300_FIXED_PORTS)]
+ if blocks is None:
+ print("\nNote: Using default CE port names (use --blocks to specify)\n")
+ else:
+ user_ports = [x.strip() for x in blocks.split(",") if len(x.strip())]
+ for idx, user_port in enumerate(user_ports):
+ ports[idx + X300_FIXED_PORTS] = user_port
+ if ignore is None:
+ ignore = []
+ else:
+ ignore = [int(x.strip()) for x in ignore.split(",") if len(x.strip())]
+ print("Egress Port "),
+ # Write out xbar ports
+ PORT_MAX_LEN = 12
+ for idx, in_prt in enumerate(ports):
+ if idx in ignore:
+ continue
+ print "{spaces}{name}".format(spaces=(" "*max(0, PORT_MAX_LEN-len(in_prt))), name=in_prt),
+ print
+ print(" "*(PORT_MAX_LEN+1)),
+ for in_prt in range(num_ports-len(ignore)):
+ print("_" * (PORT_MAX_LEN-1) + " "),
+ print
+ for in_prt, port_name in enumerate(ports):
+ if in_prt in ignore:
+ continue
+ print "{spaces}{name} |".format(spaces=(" "*max(0, PORT_MAX_LEN-len(port_name))), name=port_name),
+ for out_prt in range(num_ports):
+ if out_prt in ignore:
+ continue
+ self.poke(X300_SR_RB_ADDR_XBAR,(in_prt*num_ports+out_prt))
+ data = self.peek(X300_RB_CROSSBAR)
+ print("%10d " % (data)),
+ print
+ print
print("Ingress Port")
- print()
+ print
+ def peek_print(self,peek_addr):
+ peek_data = self.peek(peek_addr)
+ print("PEEK of address %d(0x%x) reads %d(0x%x)" % (peek_addr,peek_addr,peek_data,peek_data))
+ return peek_data
def peek(self,peek_addr):
out_pkt = pack_reg_peek_poke_fmt(X300_FW_COMMS_FLAGS_PEEK32|X300_FW_COMMS_FLAGS_ACK, seq(), peek_addr, 0)
@@ -114,28 +141,34 @@ class ctrl_socket(object):
raise Exception("X300 peek of address %d returns error code" % (addr))
return data
+ def poke_print(self,poke_addr,poke_data):
+ print("POKE of address %d(0x%x) with %d(0x%x)" % (poke_addr,poke_addr,poke_data,poke_data))
+ return(self.poke(poke_addr,poke_data))
+
def poke(self,poke_addr,poke_data):
out_pkt = pack_reg_peek_poke_fmt(X300_FW_COMMS_FLAGS_POKE32|X300_FW_COMMS_FLAGS_ACK, seq(), poke_addr, poke_data)
in_pkt = self.send_and_recv(out_pkt)
(flags, rxseq, addr, data) = unpack_reg_peek_poke_fmt(in_pkt)
if flags & X300_FW_COMMS_FLAGS_ERROR == X300_FW_COMMS_FLAGS_ERROR:
raise Exception("X300 peek of address %d returns error code" % (addr))
+ return data
########################################################################
# command line options
########################################################################
-def auto_int(x):
- return int(x, 0)
-
def get_options():
- parser = argparse.ArgumentParser(description='Debug utility for the USRP X3X0')
- parser.add_argument('--addr', type=str, default=None, required=True, help='IP Address of USRP-X3X0 device')
- parser.add_argument('--peek', type=auto_int, default=None, help='Read from memory map')
- parser.add_argument('--poke', type=auto_int, default=None, help='Write to memory map')
- parser.add_argument('--data', type=auto_int, default=None, help='Data for poke')
- parser.add_argument('--stats', action='store_true', default=False, help='Display crossbar network Stats')
- return parser.parse_args()
+ parser = optparse.OptionParser()
+ parser.add_option("--addr", type="string", help="USRP-X300 device address", default='')
+ parser.add_option("--stats", action="store_true", help="Display RFNoC Crossbar Stats", default=False)
+ parser.add_option("--peek", type="int", help="Read from memory map", default=None)
+ parser.add_option("--poke", type="int", help="Write to memory map", default=None)
+ parser.add_option("--data", type="int", help="Data for poke", default=None)
+ parser.add_option("--blocks", help="List names of blocks (post-radio)", default=None)
+ parser.add_option("--ignore", help="List of ports to ignore", default=None)
+ (options, args) = parser.parse_args()
+ return options
+
########################################################################
# main
@@ -143,20 +176,18 @@ def get_options():
if __name__=='__main__':
options = get_options()
+ if not options.addr: raise Exception('no address specified')
+
status = ctrl_socket(addr=options.addr)
if options.stats:
- status.read_router_stats()
-
+ status.read_router_stats(options.blocks, options.ignore)
if options.peek is not None:
addr = options.peek
- data = status.peek(addr)
- print("PEEK of address %d(0x%x) reads %d(0x%x)" % (addr,addr,data,data))
+ status.peek_print(addr)
if options.poke is not None and options.data is not None:
addr = options.poke
data = options.data
- status.poke(addr,data)
- print("POKE of address %d(0x%x) with %d(0x%x)" % (addr,addr,data,data))
-
+ status.poke_print(addr,data)
diff --git a/firmware/usrp3/x300/x300_defs.h b/firmware/usrp3/x300/x300_defs.h
index cb8b7324f..efd44b49d 100644
--- a/firmware/usrp3/x300/x300_defs.h
+++ b/firmware/usrp3/x300/x300_defs.h
@@ -33,6 +33,7 @@ static const int SR_SFPP_CTRL = 4;
static const int SR_SPI = 32;
static const int SR_ETHINT0 = 40;
static const int SR_ETHINT1 = 56;
+static const int SR_RB_ADDR = 128;
//led shifts for SR_LEDS
static const int LED_ACT1 = (1 << 5);
@@ -51,6 +52,7 @@ static const int RB_SFP1_TYPE = 5;
static const int RB_FPGA_COMPAT = 6;
static const int RB_SFP0_STATUS = 8;
static const int RB_SFP1_STATUS = 9;
+static const int RB_XBAR = 128;
// Bootloader Memory Map
static const int BL_ADDRESS = 0;
diff --git a/firmware/usrp3/x300/x300_main.c b/firmware/usrp3/x300/x300_main.c
index eca0802be..42ee3248b 100644
--- a/firmware/usrp3/x300/x300_main.c
+++ b/firmware/usrp3/x300/x300_main.c
@@ -246,18 +246,16 @@ static void handle_claim(void)
/***********************************************************************
* LED blinky logic and support utilities
**********************************************************************/
-static uint32_t get_xbar_total(const uint8_t port)
+static uint32_t get_xbar_total(const uint32_t port)
{
- #define get_xbar_stat(in_prt, out_prt) \
- wb_peek32(RB0_BASE+256+(((in_prt)*8+(out_prt))*4))
+ static const uint32_t NUM_PORTS = 16;
uint32_t total = 0;
- for (size_t i = 0; i < 8; i++)
+ for (uint32_t i = 0; i < NUM_PORTS; i++)
{
- total += get_xbar_stat(port, i);
- }
- for (size_t i = 0; i < 8; i++)
- {
- total += get_xbar_stat(i, port);
+ wb_poke32(SET0_BASE + SR_RB_ADDR*4, (NUM_PORTS*port + i));
+ total += wb_peek32(RB0_BASE + RB_XBAR*4);
+ wb_poke32(SET0_BASE + SR_RB_ADDR*4, (NUM_PORTS*i + port));
+ total += wb_peek32(RB0_BASE + RB_XBAR*4);
}
if (port < 2) //also netstack if applicable
{
@@ -279,10 +277,10 @@ static size_t popcntll(uint64_t num)
static void update_leds(void)
{
//update activity status for all ports
- uint64_t activity_shreg[8];
- for (size_t i = 0; i < 8; i++)
+ uint64_t activity_shreg[16];
+ for (uint32_t i = 0; i < 16; i++)
{
- static uint32_t last_total[8];
+ static uint32_t last_total[16];
const uint32_t total = get_xbar_total(i);
activity_shreg[i] <<= 1;
activity_shreg[i] |= (total == last_total[i])? 0 : 1;