Commit 6c277a45 authored by Adam Wujek's avatar Adam Wujek 💬

Merge branch 'adam-wriX'

Change the names of interfaces from wr0..wr17 (wrX) to wri1..wri18 (wriX).
Such change was done to avoid confusion that ports on the front panel are
numbered from 1 to 18, while in software they were numbered from 0 to 17.
Inconsistency started to show up especially in messages produced by software
causing confusion.

Be aware that even after these changes some software internally uses indexing
or ports from 0 to 17.
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parents d42fdfbe e197bcd4
...@@ -289,83 +289,83 @@ endmenu ...@@ -289,83 +289,83 @@ endmenu
menu "Port Timing Configuration" menu "Port Timing Configuration"
config PORT00_PARAMS config PORT01_PARAMS
string "Parameters for the first port" string "Parameters for the first port"
default "name=wr0,proto=raw,tx=223896,rx=226310,role=slave,fiber=0" if TIME_BC default "name=wri1,proto=raw,tx=223896,rx=226310,role=slave,fiber=0" if TIME_BC
default "name=wr0,proto=raw,tx=223896,rx=226310,role=master,fiber=0" default "name=wri1,proto=raw,tx=223896,rx=226310,role=master,fiber=0"
help help
This item, and the following ones, are used to assign the This item, and the following ones, are used to assign the
constant delays (likely from calibration), protocol type (raw or udp), constant delays (likely from calibration), protocol type (raw or udp),
port roles and type of fiber for each of the ports. Please refer to port roles and type of fiber for each of the ports. Please refer to
the user manual for more information. the user manual for more information.
config PORT01_PARAMS
string "Parameters for the second port"
default "name=wr1,proto=raw,tx=224066,rx=226334,role=master,fiber=0"
config PORT02_PARAMS config PORT02_PARAMS
string "Parameters for a further port" string "Parameters for the second port"
default "name=wr2,proto=raw,tx=224170,rx=226620,role=master,fiber=0" default "name=wri2,proto=raw,tx=224066,rx=226334,role=master,fiber=0"
config PORT03_PARAMS config PORT03_PARAMS
string "Parameters for a further port" string "Parameters for a further port"
default "name=wr3,proto=raw,tx=224278,rx=226722,role=master,fiber=0" default "name=wri3,proto=raw,tx=224170,rx=226620,role=master,fiber=0"
config PORT04_PARAMS config PORT04_PARAMS
string "Parameters for a further port" string "Parameters for a further port"
default "name=wr4,proto=raw,tx=224431,rx=227755,role=master,fiber=0" default "name=wri4,proto=raw,tx=224278,rx=226722,role=master,fiber=0"
config PORT05_PARAMS config PORT05_PARAMS
string "Parameters for a further port" string "Parameters for a further port"
default "name=wr5,proto=raw,tx=224607,rx=228005,role=master,fiber=0" default "name=wri5,proto=raw,tx=224431,rx=227755,role=master,fiber=0"
config PORT06_PARAMS config PORT06_PARAMS
string "Parameters for a further port" string "Parameters for a further port"
default "name=wr6,proto=raw,tx=224788,rx=228176,role=master,fiber=0" default "name=wri6,proto=raw,tx=224607,rx=228005,role=master,fiber=0"
config PORT07_PARAMS config PORT07_PARAMS
string "Parameters for a further port" string "Parameters for a further port"
default "name=wr7,proto=raw,tx=224903,rx=228251,role=master,fiber=0" default "name=wri7,proto=raw,tx=224788,rx=228176,role=master,fiber=0"
config PORT08_PARAMS config PORT08_PARAMS
string "Parameters for a further port" string "Parameters for a further port"
default "name=wr8,proto=raw,tx=225040,rx=228274,role=master,fiber=0" default "name=wri8,proto=raw,tx=224903,rx=228251,role=master,fiber=0"
config PORT09_PARAMS config PORT09_PARAMS
string "Parameters for a further port" string "Parameters for a further port"
default "name=wr9,proto=raw,tx=225285,rx=228599,role=master,fiber=0" default "name=wri9,proto=raw,tx=225040,rx=228274,role=master,fiber=0"
config PORT10_PARAMS config PORT10_PARAMS
string "Parameters for a further port" string "Parameters for a further port"
default "name=wr10,proto=raw,tx=225510,rx=229052,role=master,fiber=0" default "name=wri10,proto=raw,tx=225285,rx=228599,role=master,fiber=0"
config PORT11_PARAMS config PORT11_PARAMS
string "Parameters for a further port" string "Parameters for a further port"
default "name=wr11,proto=raw,tx=225625,rx=229111,role=master,fiber=0" default "name=wri11,proto=raw,tx=225510,rx=229052,role=master,fiber=0"
config PORT12_PARAMS config PORT12_PARAMS
string "Parameters for a further port" string "Parameters for a further port"
default "name=wr12,proto=raw,tx=225779,rx=229389,role=master,fiber=0" default "name=wri12,proto=raw,tx=225625,rx=229111,role=master,fiber=0"
config PORT13_PARAMS config PORT13_PARAMS
string "Parameters for a further port" string "Parameters for a further port"
default "name=wr13,proto=raw,tx=226005,rx=229533,role=master,fiber=0" default "name=wri13,proto=raw,tx=225779,rx=229389,role=master,fiber=0"
config PORT14_PARAMS config PORT14_PARAMS
string "Parameters for a further port" string "Parameters for a further port"
default "name=wr14,proto=raw,tx=226228,rx=229984,role=master,fiber=0" default "name=wri14,proto=raw,tx=226005,rx=229533,role=master,fiber=0"
config PORT15_PARAMS config PORT15_PARAMS
string "Parameters for a further port" string "Parameters for a further port"
default "name=wr15,proto=raw,tx=226352,rx=230126,role=master,fiber=0" default "name=wri15,proto=raw,tx=226228,rx=229984,role=master,fiber=0"
config PORT16_PARAMS config PORT16_PARAMS
string "Parameters for a further port" string "Parameters for a further port"
default "name=wr16,proto=raw,tx=226534,rx=230134,role=master,fiber=0" default "name=wri16,proto=raw,tx=226352,rx=230126,role=master,fiber=0"
config PORT17_PARAMS config PORT17_PARAMS
string "Parameters for a further port" string "Parameters for a further port"
default "name=wr17,proto=raw,tx=226733,rx=230371,role=master,fiber=0" default "name=wri17,proto=raw,tx=226534,rx=230134,role=master,fiber=0"
config PORT18_PARAMS
string "Parameters for a further port"
default "name=wri18,proto=raw,tx=226733,rx=230371,role=master,fiber=0"
endmenu endmenu
...@@ -470,13 +470,13 @@ choice ...@@ -470,13 +470,13 @@ choice
default PTP_PORT_PARAMS default PTP_PORT_PARAMS
config PTP_PORT_PARAMS config PTP_PORT_PARAMS
bool "Raw Ethernet, WR on, Slave on wr0, Master on other ports" bool "Raw Ethernet, WR on, Slave on wri1, Master on other ports"
help help
You can choose wether to use parameters defined in PORTXX_PARAMS or You can choose wether to use parameters defined in PORTXX_PARAMS or
your own custom configuration file defined by your own custom configuration file defined by
CONFIG_PTP_CUSTOM_FILENAME. CONFIG_PTP_CUSTOM_FILENAME.
The default setting for boundary clock forces port wr0 The default setting for boundary clock forces port wri1
to be PTP slave and all other ports to be master, in to be PTP slave and all other ports to be master, in
Ethernet mode and with full WR protocol extensions. The default Ethernet mode and with full WR protocol extensions. The default
for a Grand-Master or Free-Running master has all ports as for a Grand-Master or Free-Running master has all ports as
......
...@@ -28,7 +28,7 @@ bootargs="$bootargs root=nfs rw ip=$ipinfo" ...@@ -28,7 +28,7 @@ bootargs="$bootargs root=nfs rw ip=$ipinfo"
bootargs="$bootargs nfsroot=/opt/root/wrs,tcp" bootargs="$bootargs nfsroot=/opt/root/wrs,tcp"
# And pass the WR base MAC address, that barebox retrieved from SDB # And pass the WR base MAC address, that barebox retrieved from SDB
bootargs="$bootargs wr_nic.macaddr=$wr0_ethaddr" bootargs="$bootargs wr_nic.macaddr=$wri1_ethaddr"
# Load the kernel using the personal name chosen above, and boot it # Load the kernel using the personal name chosen above, and boot it
tftp $kernelname /dev/mem.kernel; bootz /dev/mem.kernel tftp $kernelname /dev/mem.kernel; bootz /dev/mem.kernel
...@@ -22,7 +22,7 @@ cp /boot/wrs-initramfs.gz /dev/mem.initramfs ...@@ -22,7 +22,7 @@ cp /boot/wrs-initramfs.gz /dev/mem.initramfs
#bootargs="verbose console=ttyS0,115200 panic=10" #bootargs="verbose console=ttyS0,115200 panic=10"
bootargs="quiet console=ttyS0,115200 panic=10" bootargs="quiet console=ttyS0,115200 panic=10"
bootargs="$bootargs initrd=0x71800000,0x400000" bootargs="$bootargs initrd=0x71800000,0x400000"
bootargs="$bootargs wr_nic.macaddr=$wr0_ethaddr" bootargs="$bootargs wr_nic.macaddr=$wri1_ethaddr"
bootz /dev/mem.kernel bootz /dev/mem.kernel
# Sleep 2 seconds so you can see the message and return to menu # Sleep 2 seconds so you can see the message and return to menu
......
...@@ -31,7 +31,7 @@ bootargs="$bootargs root=nfs rw ip=$ipinfo" ...@@ -31,7 +31,7 @@ bootargs="$bootargs root=nfs rw ip=$ipinfo"
bootargs="$bootargs nfsroot=/opt/root/wrs,tcp" bootargs="$bootargs nfsroot=/opt/root/wrs,tcp"
# And pass the WR base MAC address, that barebox retrieved from SDB # And pass the WR base MAC address, that barebox retrieved from SDB
bootargs="$bootargs wr_nic.macaddr=$wr0_ethaddr" bootargs="$bootargs wr_nic.macaddr=$wri1_ethaddr"
# Load the kernel using the personal name chosen above, and boot it # Load the kernel using the personal name chosen above, and boot it
tftp $kernelname /dev/mem.kernel; bootz /dev/mem.kernel tftp $kernelname /dev/mem.kernel; bootz /dev/mem.kernel
...@@ -59,7 +59,7 @@ while [ $# -ge 1 ]; do ...@@ -59,7 +59,7 @@ while [ $# -ge 1 ]; do
shift; shift shift; shift
;; ;;
-m2|--mac2|--wr0.ethaddr) -m2|--mac2|--wri1.ethaddr)
MAC2="$2" MAC2="$2"
checkMAC $MAC2 checkMAC $MAC2
if [ $? -eq 1 ];then if [ $? -eq 1 ];then
......
...@@ -36,24 +36,24 @@ CONFIG_WRS_LOG_WRSWATCHDOG="daemon.info" ...@@ -36,24 +36,24 @@ CONFIG_WRS_LOG_WRSWATCHDOG="daemon.info"
# #
# Port Timing Configuration # Port Timing Configuration
# #
CONFIG_PORT00_PARAMS="name=wr0,proto=raw,tx=223896,rx=226310,role=slave,fiber=0" CONFIG_PORT01_PARAMS="name=wri1,proto=raw,tx=223896,rx=226310,role=slave,fiber=0"
CONFIG_PORT01_PARAMS="name=wr1,proto=raw,tx=224066,rx=226334,role=master,fiber=0" CONFIG_PORT02_PARAMS="name=wri2,proto=raw,tx=224066,rx=226334,role=master,fiber=0"
CONFIG_PORT02_PARAMS="name=wr2,proto=raw,tx=224170,rx=226620,role=master,fiber=0" CONFIG_PORT03_PARAMS="name=wri3,proto=raw,tx=224170,rx=226620,role=master,fiber=0"
CONFIG_PORT03_PARAMS="name=wr3,proto=raw,tx=224278,rx=226722,role=master,fiber=0" CONFIG_PORT04_PARAMS="name=wri4,proto=raw,tx=224278,rx=226722,role=master,fiber=0"
CONFIG_PORT04_PARAMS="name=wr4,proto=raw,tx=224431,rx=227755,role=master,fiber=0" CONFIG_PORT05_PARAMS="name=wri5,proto=raw,tx=224431,rx=227755,role=master,fiber=0"
CONFIG_PORT05_PARAMS="name=wr5,proto=raw,tx=224607,rx=228005,role=master,fiber=0" CONFIG_PORT06_PARAMS="name=wri6,proto=raw,tx=224607,rx=228005,role=master,fiber=0"
CONFIG_PORT06_PARAMS="name=wr6,proto=raw,tx=224788,rx=228176,role=master,fiber=0" CONFIG_PORT07_PARAMS="name=wri7,proto=raw,tx=224788,rx=228176,role=master,fiber=0"
CONFIG_PORT07_PARAMS="name=wr7,proto=raw,tx=224903,rx=228251,role=master,fiber=0" CONFIG_PORT08_PARAMS="name=wri8,proto=raw,tx=224903,rx=228251,role=master,fiber=0"
CONFIG_PORT08_PARAMS="name=wr8,proto=raw,tx=225040,rx=228274,role=master,fiber=0" CONFIG_PORT09_PARAMS="name=wri9,proto=raw,tx=225040,rx=228274,role=master,fiber=0"
CONFIG_PORT09_PARAMS="name=wr9,proto=raw,tx=225285,rx=228599,role=master,fiber=0" CONFIG_PORT10_PARAMS="name=wri10,proto=raw,tx=225285,rx=228599,role=master,fiber=0"
CONFIG_PORT10_PARAMS="name=wr10,proto=raw,tx=225510,rx=229052,role=master,fiber=0" CONFIG_PORT11_PARAMS="name=wri11,proto=raw,tx=225510,rx=229052,role=master,fiber=0"
CONFIG_PORT11_PARAMS="name=wr11,proto=raw,tx=225625,rx=229111,role=master,fiber=0" CONFIG_PORT12_PARAMS="name=wri12,proto=raw,tx=225625,rx=229111,role=master,fiber=0"
CONFIG_PORT12_PARAMS="name=wr12,proto=raw,tx=225779,rx=229389,role=master,fiber=0" CONFIG_PORT13_PARAMS="name=wri13,proto=raw,tx=225779,rx=229389,role=master,fiber=0"
CONFIG_PORT13_PARAMS="name=wr13,proto=raw,tx=226005,rx=229533,role=master,fiber=0" CONFIG_PORT14_PARAMS="name=wri14,proto=raw,tx=226005,rx=229533,role=master,fiber=0"
CONFIG_PORT14_PARAMS="name=wr14,proto=raw,tx=226228,rx=229984,role=master,fiber=0" CONFIG_PORT15_PARAMS="name=wri15,proto=raw,tx=226228,rx=229984,role=master,fiber=0"
CONFIG_PORT15_PARAMS="name=wr15,proto=raw,tx=226352,rx=230126,role=master,fiber=0" CONFIG_PORT16_PARAMS="name=wri16,proto=raw,tx=226352,rx=230126,role=master,fiber=0"
CONFIG_PORT16_PARAMS="name=wr16,proto=raw,tx=226534,rx=230134,role=master,fiber=0" CONFIG_PORT17_PARAMS="name=wri17,proto=raw,tx=226534,rx=230134,role=master,fiber=0"
CONFIG_PORT17_PARAMS="name=wr17,proto=raw,tx=226733,rx=230371,role=master,fiber=0" CONFIG_PORT18_PARAMS="name=wri18,proto=raw,tx=226733,rx=230371,role=master,fiber=0"
# #
# SFP and Media Timing Configuration # SFP and Media Timing Configuration
......
...@@ -520,7 +520,7 @@ interface is a line. This approach allows the same MIB to work for ...@@ -520,7 +520,7 @@ interface is a line. This approach allows the same MIB to work for
every possible configuration. For WR port statistics we chose a every possible configuration. For WR port statistics we chose a
different approach: the counters themselves are somehow dynamic (they different approach: the counters themselves are somehow dynamic (they
may change across versions, while the gateware develops) while the may change across versions, while the gateware develops) while the
interfaces are restricted to be in the set @t{wr0}--@t{wr17}. interfaces are restricted to be in the set @t{wri1}--@t{wri18}.
So our pStats table is reversed from the common use of @sc{snmp} tables. So our pStats table is reversed from the common use of @sc{snmp} tables.
As a side effect this allows the WR switch to return the name of each As a side effect this allows the WR switch to return the name of each
......
...@@ -594,9 +594,9 @@ The following list resumes the most interesting commands: ...@@ -594,9 +594,9 @@ The following list resumes the most interesting commands:
> ***Note:*** More information about the tools are explained in the [wrs-user-manual.pdf] or can be obtain using the embedded help argument: `--help`, `-h` or `help`. > ***Note:*** More information about the tools are explained in the [wrs-user-manual.pdf] or can be obtain using the embedded help argument: `--help`, `-h` or `help`.
#### Warning: #### Note:
The SFP ports are labeled from 1 to 18 on the front panel but their corresponding The SFP ports are labeled from 1 to 18 on the front panel, their corresponding
network interface are named from `wr0` to `wr17`. network interface are named from `wri1` to `wri18`.
Firmware updates Firmware updates
......
...@@ -1927,7 +1927,7 @@ The binary image includes 4 files, stored as an @sc{sdb} filesystem: ...@@ -1927,7 +1927,7 @@ The binary image includes 4 files, stored as an @sc{sdb} filesystem:
The MAC address for the management Ethernet port (RJ45, 100Mb/s). The MAC address for the management Ethernet port (RJ45, 100Mb/s).
@item wr0.ethaddr @item wri1.ethaddr
The MAC address for the first fiber port (SFP, 1Gb/s). Other ports The MAC address for the first fiber port (SFP, 1Gb/s). Other ports
are assigned sequential addresses starting from this one. are assigned sequential addresses starting from this one.
...@@ -2068,7 +2068,7 @@ in the boot scripts, as we now extract the mac addresses from sdb. ...@@ -2068,7 +2068,7 @@ in the boot scripts, as we now extract the mac addresses from sdb.
bb> sdb ls /dev/dataflash0.hwinfo bb> sdb ls /dev/dataflash0.hwinfo
46696c6544617461:2e202020 @ 00000000-0000083f . 46696c6544617461:2e202020 @ 00000000-0000083f .
46696c6544617461:7363625f @ 00000240-00000243 scb_version 46696c6544617461:7363625f @ 00000240-00000243 scb_version
46696c6544617461:7772302e @ 00000220-00000231 wr0.ethaddr 46696c6544617461:7772302e @ 00000220-00000231 wri1.ethaddr
46696c6544617461:6d616e75 @ 00000260-0000026f manufacturer 46696c6544617461:6d616e75 @ 00000260-0000026f manufacturer
46696c6544617461:68775f69 @ 00000420-0000083f hw_info 46696c6544617461:68775f69 @ 00000420-0000083f hw_info
46696c6544617461:65746830 @ 00000200-00000211 eth0.ethaddr 46696c6544617461:65746830 @ 00000200-00000211 eth0.ethaddr
...@@ -2078,7 +2078,7 @@ in the boot scripts, as we now extract the mac addresses from sdb. ...@@ -2078,7 +2078,7 @@ in the boot scripts, as we now extract the mac addresses from sdb.
bb> sdb cat /dev/dataflash0.hwinfo hw_info bb> sdb cat /dev/dataflash0.hwinfo hw_info
fpga: LX240T fpga: LX240T
scb_serial: 12345 scb_serial: 12345
bb> sdb set /dev/dataflash0.hwinfo wraddr wr0.ethaddr bb> sdb set /dev/dataflash0.hwinfo wraddr wri1.ethaddr
bb> echo $wraddr bb> echo $wraddr
22:33:44:55:66:77 22:33:44:55:66:77
......
...@@ -256,7 +256,7 @@ implementation. ...@@ -256,7 +256,7 @@ implementation.
@item WR GrandMaster Switch should be holy provided it has an @item WR GrandMaster Switch should be holy provided it has an
external reference. Currently if we have a GrandMaster Switch and we external reference. Currently if we have a GrandMaster Switch and we
connect a Free-running Master to it's Slave port (wr0) then it becomes connect a Free-running Master to it's Slave port (wri1) then it becomes
Slave to the Free-running Master and jumps it's WR time. All the Slave to the Free-running Master and jumps it's WR time. All the
mechanism is in place, this should be trivial to fix. mechanism is in place, this should be trivial to fix.
......
This diff is collapsed.
...@@ -273,7 +273,7 @@ ...@@ -273,7 +273,7 @@
messages to determine the WR port on which the problem is reported. In messages to determine the WR port on which the problem is reported. In
case of Syslog, you should see a message similar to this one:\\ case of Syslog, you should see a message similar to this one:\\
\texttt{Unknown SFP vn="AVAGO" pn="ABCU-5710RZ" vs="AN1151PD8A" on port \texttt{Unknown SFP vn="AVAGO" pn="ABCU-5710RZ" vs="AN1151PD8A" on port
wr1} wri2}
\item If the reported port is intended to be used to connect a device that \item If the reported port is intended to be used to connect a device that
does not require WR synchronization (e.g. using a copper SFP module), does not require WR synchronization (e.g. using a copper SFP module),
then you should verify whether the role in the timing configuration for then you should verify whether the role in the timing configuration for
......
# We have 5 files only: eth0.ethaddr, wr0.ethaddr, manufacturer, scb_version # We have 5 files only: eth0.ethaddr, wri1.ethaddr, manufacturer, scb_version
# and hw_info. # and hw_info.
# #
# They are at static addresses so to be able to change them from a script # They are at static addresses so to be able to change them from a script
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
eth0.ethaddr eth0.ethaddr
position = 0x200 position = 0x200
wr0.ethaddr wri1.ethaddr
position = 0x220 position = 0x220
scb_version scb_version
......
...@@ -241,6 +241,7 @@ int wrn_endpoint_probe(struct net_device *dev) ...@@ -241,6 +241,7 @@ int wrn_endpoint_probe(struct net_device *dev)
{ {
struct wrn_ep *ep = netdev_priv(dev); struct wrn_ep *ep = netdev_priv(dev);
static u8 wraddr[6]; static u8 wraddr[6];
char wrint_name[16]; /* 6 is enough, but to be super cautious use 16 */
int err; int err;
int prio, prio_map; int prio, prio_map;
u32 val; u32 val;
...@@ -278,9 +279,12 @@ int wrn_endpoint_probe(struct net_device *dev) ...@@ -278,9 +279,12 @@ int wrn_endpoint_probe(struct net_device *dev)
if (ep->ep_number == 0) if (ep->ep_number == 0)
pr_info("WR-nic: Using address %pM\n", wraddr); pr_info("WR-nic: Using address %pM\n", wraddr);
/* assign wr interfaces numbers from 1 */
snprintf(wrint_name, 16, "wri%d", ep->ep_number + 1);
/* Use wraddr as MAC */ /* Use wraddr as MAC */
memcpy(dev->dev_addr, wraddr, ETH_ALEN); memcpy(dev->dev_addr, wraddr, ETH_ALEN);
pr_debug("wr_nic: assign MAC %pM to wr%d\n", dev->dev_addr, ep->ep_number); pr_info("wr_nic: assign MAC %pM to %s\n", dev->dev_addr, wrint_name);
/* Check whether the ep has been sinthetized or not */ /* Check whether the ep has been sinthetized or not */
val = readl(&ep->ep_regs->IDCODE); val = readl(&ep->ep_regs->IDCODE);
...@@ -291,7 +295,7 @@ int wrn_endpoint_probe(struct net_device *dev) ...@@ -291,7 +295,7 @@ int wrn_endpoint_probe(struct net_device *dev)
} }
/* Errors different from -ENODEV are fatal to insmod */ /* Errors different from -ENODEV are fatal to insmod */
dev_alloc_name(dev, "wr%d"); dev_alloc_name(dev, wrint_name);
wrn_netops_init(dev); /* function in ./nic-core.c */ wrn_netops_init(dev); /* function in ./nic-core.c */
wrn_ethtool_init(dev); /* function in ./ethtool.c */ wrn_ethtool_init(dev); /* function in ./ethtool.c */
/* Napi is not supported on this device */ /* Napi is not supported on this device */
......
...@@ -43,9 +43,10 @@ static unsigned int firmware_adr_pp; /* number of words with counters */ ...@@ -43,9 +43,10 @@ static unsigned int firmware_adr_pp; /* number of words with counters */
static unsigned int firmware_cpw; /* number of counters per word */ static unsigned int firmware_cpw; /* number of counters per word */
module_param(pstats_nports, int, S_IRUGO); module_param(pstats_nports, int, S_IRUGO);
const char *portnames[] = {"port0", "port1", "port2", "port3", "port4", const char *portnames[] = {"wrport1", "wrport2", "wrport3", "wrport4",
"port5", "port6", "port7", "port8", "port9", "port10", "port11", "wrport5", "wrport6", "wrport7", "wrport8", "wrport9", "wrport10",
"port12", "port13", "port14", "port15", "port16", "port17"}; "wrport11", "wrport12", "wrport13", "wrport14", "wrport15", "wrport16",
"wrport17", "wrport18"};
static struct pstats_version_description pstats_desc[] = { static struct pstats_version_description pstats_desc[] = {
[0] = { [0] = {
......
...@@ -8,7 +8,7 @@ cp /boot/wrs-initramfs.gz /dev/mem.initramfs ...@@ -8,7 +8,7 @@ cp /boot/wrs-initramfs.gz /dev/mem.initramfs
#bootargs="verbose console=ttyS0,115200 panic=10" #bootargs="verbose console=ttyS0,115200 panic=10"
bootargs="quiet console=ttyS0,115200 panic=10" bootargs="quiet console=ttyS0,115200 panic=10"
bootargs="$bootargs initrd=0x71800000,0x400000" bootargs="$bootargs initrd=0x71800000,0x400000"
bootargs="$bootargs wr_nic.macaddr=$wr0_ethaddr" bootargs="$bootargs wr_nic.macaddr=$wri1_ethaddr"
bootz /dev/mem.kernel bootz /dev/mem.kernel
# Sleep 2 seconds so you can see the message and return to menu # Sleep 2 seconds so you can see the message and return to menu
......
...@@ -45,12 +45,16 @@ autoboot_select="1" ...@@ -45,12 +45,16 @@ autoboot_select="1"
# Ethernet addresses are taken from sdb in hwinfo partition # Ethernet addresses are taken from sdb in hwinfo partition
addpart /dev/dataflash0 0x840@0x94800(hwinfo) addpart /dev/dataflash0 0x840@0x94800(hwinfo)
sdb set /dev/dataflash0.hwinfo eth0.ethaddr sdb set /dev/dataflash0.hwinfo eth0.ethaddr
sdb set /dev/dataflash0.hwinfo wr0_ethaddr wr0.ethaddr sdb set /dev/dataflash0.hwinfo wri1_ethaddr wri1.ethaddr
export wr0_ethaddr if [ x$wri1_ethaddr = x ]; then
sdb set /dev/dataflash0.hwinfo wri1_ethaddr wr0.ethaddr
echo "Using wr0.ethaddr from sdb (" $wri1_ethaddr ")"
fi
export wri1_ethaddr
### Override default value using /env/config (empty by default) ### Override default value using /env/config (empty by default)
. /env/config . /env/config
echo "Starting up barebox [wrs3] (MAC=$eth0.ethaddr WR_MAC=$wr0_ethaddr)" echo "Starting up barebox [wrs3] (MAC=$eth0.ethaddr WR_MAC=$wri1_ethaddr)"
### Generic setup ### Generic setup
......
...@@ -537,13 +537,13 @@ int shw_sfp_read_header(int num, struct shw_sfp_header *head) ...@@ -537,13 +537,13 @@ int shw_sfp_read_header(int num, struct shw_sfp_header *head)
int ret; int ret;
if (shw_sfp_id(num) < 0) { if (shw_sfp_id(num) < 0) {
pr_error("shw_sfp_read_header: wrong SFP num %d\n", num); pr_error("shw_sfp_read_header: wrong SFP num %d\n", num + 1);
return -1; return -1;
} }
ret = shw_sfp_module_scan(); ret = shw_sfp_module_scan();
if (!(ret & (1 << num))) { if (!(ret & (1 << num))) {
pr_error("shw_sfp_read_header: SFP not present %d\n", num); pr_error("shw_sfp_read_header: SFP not present %d\n", num + 1);
return -2; return -2;
} }
......
...@@ -4,7 +4,7 @@ start() { ...@@ -4,7 +4,7 @@ start() {
echo -n "Enable switching: " echo -n "Enable switching: "
# bring up all interfaces # bring up all interfaces
for i in `ls /sys/class/net | grep wr` for i in `ls /sys/class/net | grep wri`
do do
ifconfig $i up ifconfig $i up
done done
...@@ -16,7 +16,7 @@ stop() { ...@@ -16,7 +16,7 @@ stop() {
echo -n "Disable switching: " echo -n "Disable switching: "
# bring down all interfaces # bring down all interfaces
for i in `ls /sys/class/net | grep wr` for i in `ls /sys/class/net | grep wri`
do do
ifconfig $i down ifconfig $i down
done done
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
# people upgrading from older wr-switch-sw releases. # people upgrading from older wr-switch-sw releases.
# #
# This script is run late, because it will have effect at next boot only. # This script is run late, because it will have effect at next boot only.
# If we run it too early, we can't get the mac address from wr0 which does # If we run it too early, we can't get the mac address from wri1 which does
# not exist yet. # not exist yet.
# This allows me to pass WRS_VERBOSE=y on the command line... # This allows me to pass WRS_VERBOSE=y on the command line...
...@@ -39,9 +39,9 @@ fi ...@@ -39,9 +39,9 @@ fi
# we need the eth addresses # we need the eth addresses
ethaddr=$(ifconfig eth0 | grep HWaddr | awk '{print $5}') ethaddr=$(ifconfig eth0 | grep HWaddr | awk '{print $5}')
wraddr=$(ifconfig wr0 | grep HWaddr | awk '{print $5}') wraddr=$(ifconfig wri1 | grep HWaddr | awk '{print $5}')
# if we run this early (upgrade mess from v4.0) there is no wr0, # if we run this early (upgrade mess from v4.0) there is no wri1,
# so pick if from the command line: # so pick if from the command line:
if [ "x$wraddr" = "x" ]; then if [ "x$wraddr" = "x" ]; then
wraddr=$(awk 'BEGIN {FS="="; RS=" "} /wr_nic.macaddr/ {print $2}' \ wraddr=$(awk 'BEGIN {FS="="; RS=" "} /wr_nic.macaddr/ {print $2}' \
......
...@@ -24,9 +24,9 @@ ...@@ -24,9 +24,9 @@
echo '<form method=POST> echo '<form method=POST>
Select an Endpoint: <select name="endpoint" class="sec">'; Select an Endpoint: <select name="endpoint" class="sec">';
for($op = 0; $op < 18; $op++){ for($op = 1; $op <= 18; $op++){
echo '<option value="wr'.$op.'">wr'.$op.'</option>'; echo '<option value="'.$op.'">wri'.$op.'</option>';
} }
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
echo '<option value="txcal1">Enable Calibration Transmission</option>'; echo '<option value="txcal1">Enable Calibration Transmission</option>';
echo '<option value="txcal0">Disable Calibration Transmission</option>'; echo '<option value="txcal0">Disable Calibration Transmission</option>';
echo '<option value="dump">See Registers</option>'; echo '<option value="dump">See Registers</option>';
echo '<option value="wr">Modify Registers</option>'; echo '<option value="wri">Modify Registers</option>';
//echo '<option value="rt">Show Flags</option>'; //echo '<option value="rt">Show Flags</option>';
echo '<option value="lock">Lock Endpoint</option>'; echo '<option value="lock">Lock Endpoint</option>';
//echo '<option value="master">Make Master</option>'; //echo '<option value="master">Make Master</option>';
......
...@@ -38,8 +38,7 @@ ...@@ -38,8 +38,7 @@
$header = array ("WR port","Protocol","Tx","Rx","Mode","Fiber"); $header = array ("WR port","Protocol","Tx","Rx","Mode","Fiber");
else else
$header = array ("WR port","Tx","Rx","Mode","Fiber"); $header = array ("WR port","Tx","Rx","Mode","Fiber");
$matrix = array ("key=CONFIG_PORT00_PARAMS,".$_SESSION["KCONFIG"]["CONFIG_PORT00_PARAMS"], $matrix = array ("key=CONFIG_PORT01_PARAMS,".$_SESSION["KCONFIG"]["CONFIG_PORT01_PARAMS"],
"key=CONFIG_PORT01_PARAMS,".$_SESSION["KCONFIG"]["CONFIG_PORT01_PARAMS"],
"key=CONFIG_PORT02_PARAMS,".$_SESSION["KCONFIG"]["CONFIG_PORT02_PARAMS"], "key=CONFIG_PORT02_PARAMS,".$_SESSION["KCONFIG"]["CONFIG_PORT02_PARAMS"],
"key=CONFIG_PORT03_PARAMS,".$_SESSION["KCONFIG"]["CONFIG_PORT03_PARAMS"], "key=CONFIG_PORT03_PARAMS,".$_SESSION["KCONFIG"]["CONFIG_PORT03_PARAMS"],
"key=CONFIG_PORT04_PARAMS,".$_SESSION["KCONFIG"]["CONFIG_PORT04_PARAMS"], "key=CONFIG_PORT04_PARAMS,".$_SESSION["KCONFIG"]["CONFIG_PORT04_PARAMS"],
...@@ -56,6 +55,7 @@ ...@@ -56,6 +55,7 @@
"key=CONFIG_PORT15_PARAMS,".$_SESSION["KCONFIG"]["CONFIG_PORT15_PARAMS"], "key=CONFIG_PORT15_PARAMS,".$_SESSION["KCONFIG"]["CONFIG_PORT15_PARAMS"],
"key=CONFIG_PORT16_PARAMS,".$_SESSION["KCONFIG"]["CONFIG_PORT16_PARAMS"], "key=CONFIG_PORT16_PARAMS,".$_SESSION["KCONFIG"]["CONFIG_PORT16_PARAMS"],
"key=CONFIG_PORT17_PARAMS,".$_SESSION["KCONFIG"]["CONFIG_PORT17_PARAMS"], "key=CONFIG_PORT17_PARAMS,".$_SESSION["KCONFIG"]["CONFIG_PORT17_PARAMS"],
"key=CONFIG_PORT18_PARAMS,".$_SESSION["KCONFIG"]["CONFIG_PORT18_PARAMS"],
); );
print_multi_form($matrix, $header, $formatID, $class, $infoname, $size); print_multi_form($matrix, $header, $formatID, $class, $infoname, $size);
......
...@@ -28,11 +28,11 @@ ...@@ -28,11 +28,11 @@
echo '<table class="altrowstable" id="alternatecolor" style="width:100%;text-align:center">'; echo '<table class="altrowstable" id="alternatecolor" style="width:100%;text-align:center">';
for($i = 0; $i < 9; $i++){ for($i = 0; $i < 9; $i++){
echo '<tr>'; echo '<tr>';
echo '<th>wr'.($i).'</td>'; echo '<th>wri'.($i+1).'</td>';
echo '<td><a href="modifymode.php?wr='.($i).'&mode='.$modes[$i].'">'.$modes[$i].'</a></th>'; echo '<td><a href="modifymode.php?wri='.($i+1).'&mode='.$modes[$i].'">'.$modes[$i].'</a></th>';
echo '<th>wr'.($i+9).'</th>'; echo '<th>wri'.($i+10).'</th>';
echo '<td><a href="modifymode.php?wr='.($i+9).'&mode='.$modes[$i+9].'">'.$modes[$i+9].'</a></td>'; echo '<td><a href="modifymode.php?wri='.($i+10).'&mode='.$modes[$i+9].'">'.$modes[$i+9].'</a></td>';
echo '</tr>'; echo '</tr>';
} }
echo '</table>'; echo '</table>';
......
...@@ -93,7 +93,7 @@ function wrs_header_ports(){ ...@@ -93,7 +93,7 @@ function wrs_header_ports(){
} }
else $mode="linkdown"; else $mode="linkdown";
$desc=sprintf("#%02d: wr%d (%s)",$cont+1,$cont,$mode); $desc=sprintf("#%02d: wri%d (%s)",$cont+1,$cont+1,$mode);
echo '<th>'."<img class='".$mode."' src='img/".$mode.".png' alt='".$desc."', title='".$desc."'>".'</th>'; echo '<th>'."<img class='".$mode."' src='img/".$mode.".png' alt='".$desc."', title='".$desc."'>".'</th>';
$cont++; $cont++;
...@@ -480,10 +480,10 @@ function wr_endpoint_phytool($option1, $endpoint){ ...@@ -480,10 +480,10 @@ function wr_endpoint_phytool($option1, $endpoint){
$output=shell_exec("/wr/bin/wr_phytool ".$endpoint." dump"); $output=shell_exec("/wr/bin/wr_phytool ".$endpoint." dump");
$ports = explode(" ", $output); $ports = explode(" ", $output);
echo 'wri'.$endpoint.'<BR>';
echo "<table border='0' align='center'>"; echo "<table border='0' align='center'>";
echo '<tr>'; echo '<tr>';
echo '<th>'.$endpoint.' Register</th>'; echo '<th>Register</th>';
echo '<th>Value</th>'; echo '<th>Value</th>';
echo '</tr>'; echo '</tr>';
...@@ -503,20 +503,17 @@ function wr_endpoint_phytool($option1, $endpoint){ ...@@ -503,20 +503,17 @@ function wr_endpoint_phytool($option1, $endpoint){
//} //}
// User wants to modify endpoint's registers // User wants to modify endpoint's registers
} else if(!strcmp($option1, "wr")){ } else if(!strcmp($option1, "wri")){
$output=shell_exec("/wr/bin/wr_phytool ".$endpoint." dump");
$ports = explode(" ", $output);
echo '<br>'; echo '<br>';
echo '<center></center><form method=POST>'; echo '<center></center><form method=POST>';
echo "<table border='0' align='center'>"; echo "<table border='0' align='center'>";
echo '<tr>'; echo '<tr>';
echo '<th>'.$endpoint.' Registers</th>'; echo '<th>wri'.$endpoint.' Registers</th>';
echo '<th><center>Value</center></th>'; echo '<th><center>Value</center></th>';
echo '</tr>'; echo '</tr>';
/* wr_phytool prints 17 registers */
for($i=0; $i<18; $i++){ for($i=0; $i<17; $i++){
echo '<tr>'; echo '<tr>';
echo '<th>R'.$i.'</th>'; echo '<th>R'.$i.'</th>';
echo '<th><input type="text" name="r'.$i.'" value="'.$_POST['r'.$i].'"></th>'; echo '<th><input type="text" name="r'.$i.'" value="'.$_POST['r'.$i].'"></th>';
...@@ -526,12 +523,12 @@ function wr_endpoint_phytool($option1, $endpoint){ ...@@ -526,12 +523,12 @@ function wr_endpoint_phytool($option1, $endpoint){
echo '</tr>'; echo '</tr>';
echo '</table>'; echo '</table>';
echo '<input type="hidden" name="option1" value="wr">'; echo '<input type="hidden" name="option1" value="wri">';
echo '<input type="hidden" name="wr" value="yes">'; echo '<input type="hidden" name="wri" value="yes">';
echo '<input type="hidden" name="endpoint" value="'.$endpoint.'">'; echo '<input type="hidden" name="endpoint" value="'.$endpoint.'">';
echo '<center><input type="submit" value="Update" class="btn"></center></form><center>'; echo '<center><input type="submit" value="Update" class="btn"></center></form><center>';
if(!empty($_POST['wr'])){ if(!empty($_POST['wri'])){
for($i=0; $i<18 ; $i++){ for($i=0; $i<18 ; $i++){
if (!empty($_POST['r'.$i])){ if (!empty($_POST['r'.$i])){
$cmd = '/wr/bin/wr_phytool '.$_POST['endpoint'].' wr '.dechex($i).' '.$_POST['r'.$i].''; $cmd = '/wr/bin/wr_phytool '.$_POST['endpoint'].' wr '.dechex($i).' '.$_POST['r'.$i].'';
...@@ -573,8 +570,8 @@ function wr_endpoint_phytool($option1, $endpoint){ ...@@ -573,8 +570,8 @@ function wr_endpoint_phytool($option1, $endpoint){
function wr_show_endpoint_rt_show(){ function wr_show_endpoint_rt_show(){
/* use port number between 1 and 18 */
$output=shell_exec('/wr/bin/wr_phytool wr0 rt show'); $output=shell_exec('/wr/bin/wr_phytool 1 rt show');
$rts = nl2br($output); $rts = nl2br($output);
echo $rts; echo $rts;
} }
...@@ -1161,7 +1158,7 @@ function parse_endpoint_modes(){ ...@@ -1161,7 +1158,7 @@ function parse_endpoint_modes(){
$modes = array(); $modes = array();
for($i = 0; $i < 18; $i++){ for($i = 1; $i <= 18; $i++){
$endpoint = intval($i); $endpoint = intval($i);
$endpoint = sprintf("%02s", $endpoint); $endpoint = sprintf("%02s", $endpoint);
$endpoint = strval($endpoint); $endpoint = strval($endpoint);
...@@ -1219,12 +1216,7 @@ function parse_mask2ports($vlanmask){ ...@@ -1219,12 +1216,7 @@ function parse_mask2ports($vlanmask){
for($i=0; $i<18; $i++){ for($i=0; $i<18; $i++){
if($bin[$i]=="1"){ if($bin[$i]=="1"){
$ports .= "wr".($i+1)." "; $ports .= "wri".($i+1)." ";
$counter++;
if($counter==4){
$ports .= "<br>";
$counter = 0;
}
} }
} }
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<?php <?php
$endpoint = intval($_GET["wr"]); $endpoint = intval($_GET["wri"]);
$endpoint = sprintf("%02s", $endpoint); $endpoint = sprintf("%02s", $endpoint);
$endpoint = strval($endpoint); $endpoint = strval($endpoint);
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
$single_line = explode(" ",$vlans_assignment[$i+1]); //info per endpoint line $single_line = explode(" ",$vlans_assignment[$i+1]); //info per endpoint line
echo '<tr>'; echo '<tr>';
echo '<th><center><b>wr'.($i+1).'</b></center></th>'; echo '<th><center><b>'.($single_line[0]).'</b></center></th>';
//Show the Vlan option button //Show the Vlan option button
echo '<th>'; echo '<th>';
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
echo '<option class="btn" value="'.$vlan[0].$vlan[1].'"><center>ID'.$vlan[0].$vlan[1].'</center></option>'; echo '<option class="btn" value="'.$vlan[0].$vlan[1].'"><center>ID'.$vlan[0].$vlan[1].'</center></option>';
} }
}*/ }*/
echo '<input STYLE="background-color:'.$vlancolor[$single_line[6]].';text-align:center;" size="5" type="text" value="'.$single_line[6].'" name="vlan'.($i).'">'; echo '<input STYLE="background-color:'.$vlancolor[$single_line[5]].';text-align:center;" size="5" type="text" value="'.$single_line[5].'" name="vlan'.($i).'">';
//echo '<option class="btn" selected="selected" value="disabled"><center>Disabled</center></option>'; //echo '<option class="btn" selected="selected" value="disabled"><center>Disabled</center></option>';
//echo '</select>'; // end Vlan ID assignation //echo '</select>'; // end Vlan ID assignation
...@@ -75,24 +75,24 @@ ...@@ -75,24 +75,24 @@
echo '<th>'; // Mode selection echo '<th>'; // Mode selection
echo '<select name=mode'.($i).'>'; echo '<select name=mode'.($i).'>';
echo '<option class="btn" '; echo (!strcmp($single_line[2],"0")) ? 'selected="selected"' : ''; echo ' value="0"><center>Access</center></option>'; echo '<option class="btn" '; echo (!strcmp($single_line[1],"0")) ? 'selected="selected"' : ''; echo ' value="0"><center>Access</center></option>';
echo '<option class="btn" '; echo (!strcmp($single_line[2],"1")) ? 'selected="selected"' : ''; echo ' value="1"><center>Trunk</center></option>'; echo '<option class="btn" '; echo (!strcmp($single_line[1],"1")) ? 'selected="selected"' : ''; echo ' value="1"><center>Trunk</center></option>';
echo '<option class="btn" '; echo (!strcmp($single_line[2],"2")) ? 'selected="selected"' : ''; echo ' value="2"><center>VLAN Disabled</center></option>'; echo '<option class="btn" '; echo (!strcmp($single_line[1],"2")) ? 'selected="selected"' : ''; echo ' value="2"><center>VLAN Disabled</center></option>';
echo '<option class="btn" '; echo (!strcmp($single_line[2],"3")) ? 'selected="selected"' : ''; echo ' value="3"><center>Unqualified port</center></option>'; echo '<option class="btn" '; echo (!strcmp($single_line[1],"3")) ? 'selected="selected"' : ''; echo ' value="3"><center>Unqualified port</center></option>';
echo '</select>'; // end mode echo '</select>'; // end mode
echo '</th>'; echo '</th>';
echo '<th>'; // Priority selection echo '<th>'; // Priority selection
echo '<select name=prio'.($i).'>'; echo '<select name=prio'.($i).'>';
echo '<option class="btn" '; echo (!strcmp($single_line[5],"0")) ? 'selected="selected"' : ''; echo 'value="0"><center>0</center></option>'; echo '<option class="btn" '; echo (!strcmp($single_line[4],"0")) ? 'selected="selected"' : ''; echo 'value="0"><center>0</center></option>';
echo '<option class="btn" '; echo (!strcmp($single_line[5],"1")) ? 'selected="selected"' : ''; echo 'value="1"><center>1</center></option>'; echo '<option class="btn" '; echo (!strcmp($single_line[4],"1")) ? 'selected="selected"' : ''; echo 'value="1"><center>1</center></option>';
echo '<option class="btn" '; echo (!strcmp($single_line[5],"2")) ? 'selected="selected"' : ''; echo 'value="2"><center>2</center></option>'; echo '<option class="btn" '; echo (!strcmp($single_line[4],"2")) ? 'selected="selected"' : ''; echo 'value="2"><center>2</center></option>';
echo '<option class="btn" '; echo (!strcmp($single_line[5],"3")) ? 'selected="selected"' : ''; echo 'value="3"><center>3</center></option>'; echo '<option class="btn" '; echo (!strcmp($single_line[4],"3")) ? 'selected="selected"' : ''; echo 'value="3"><center>3</center></option>';
echo '<option class="btn" '; echo (!strcmp($single_line[5],"4")) ? 'selected="selected"' : ''; echo 'value="4"><center>4</center></option>'; echo '<option class="btn" '; echo (!strcmp($single_line[4],"4")) ? 'selected="selected"' : ''; echo 'value="4"><center>4</center></option>';
echo '<option class="btn" '; echo (!strcmp($single_line[5],"5")) ? 'selected="selected"' : ''; echo 'value="5"><center>5</center></option>'; echo '<option class="btn" '; echo (!strcmp($single_line[4],"5")) ? 'selected="selected"' : ''; echo 'value="5"><center>5</center></option>';
echo '<option class="btn" '; echo (!strcmp($single_line[5],"6")) ? 'selected="selected"' : ''; echo 'value="6"><center>6</center></option>'; echo '<option class="btn" '; echo (!strcmp($single_line[4],"6")) ? 'selected="selected"' : ''; echo 'value="6"><center>6</center></option>';
echo '<option class="btn" '; echo (!strcmp($single_line[5],"7")) ? 'selected="selected"' : ''; echo 'value="7"><center>7</center></option>'; echo '<option class="btn" '; echo (!strcmp($single_line[4],"7")) ? 'selected="selected"' : ''; echo 'value="7"><center>7</center></option>';
echo '</select>'; // end Priority echo '</select>'; // end Priority
...@@ -115,27 +115,28 @@ ...@@ -115,27 +115,28 @@
for($i = 0; $i < 18; $i++){ for($i = 0; $i < 18; $i++){
//if(strcmp($_POST['vlan'.$i],"disabled")){ //VLAN selected //if(strcmp($_POST['vlan'.$i],"disabled")){ //VLAN selected
$vlan_cmd .= " --ep ".$i; $vlan_cmd .= " --ep ".($i+1);
$vlan_cmd .= " --emode ".$_POST['mode'.$i]; $vlan_cmd .= " --emode ".$_POST['mode'.$i];
$vlan_cmd .= " --eprio ".$_POST['prio'.$i]; $vlan_cmd .= " --eprio ".$_POST['prio'.$i];
if(!empty($_POST['vlan'.$i])){$vlan_cmd .= " --evid ".$_POST['vlan'.$i];} if(!empty($_POST['vlan'.$i])){$vlan_cmd .= " --evid ".$_POST['vlan'.$i];}
if(!empty($_POST['mask'.$i])){$vlan_cmd .= " --eumask ".$_POST['mask'.$i];} if(!empty($_POST['mask'.$i])){$vlan_cmd .= " --eumask ".$_POST['mask'.$i];}
$output = shell_exec($vlan_cmd); $output = shell_exec($vlan_cmd);
echo $vlan_cmd; echo $vlan_cmd;
echo '<br><p><center>Port WR'.($i+1).' added to VLAN'.$_POST['vlan'.$i].'</center></p>'; echo '<br><p><center>Port wri'.($i+1).' added to VLAN'.$_POST['vlan'.$i].'</center></p>';
//}else{ //}else{
if(!strcmp($_POST['mode'.$i],"2")){ //Disable VLAN for endpoint if(!strcmp($_POST['mode'.$i],"2")){ //Disable VLAN for endpoint
$vlan_cmd .= " --ep ".$i; $vlan_cmd .= " --ep ".($i+1);
$vlan_cmd .= " --emode ".$_POST['mode'.$i]; $vlan_cmd .= " --emode ".$_POST['mode'.$i];
$output = shell_exec($vlan_cmd); $output = shell_exec($vlan_cmd);
echo '<br><p><center>VLAN removed for port WR'.($i+1).'</center></p>'; echo '<br><p><center>VLAN removed for port wri'.($i+1).'</center></p>';
} }
//} //}
$vlan_cmd= "/wr/bin/wrs_vlans "; $vlan_cmd= "/wr/bin/wrs_vlans ";
} }
/* redirect to vlan.php */
header('Location: vlan.php'); header('Location: vlan.php');
} }
......
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
if($counter>=2 && !empty($line)){ if($counter>=2 && !empty($line)){
$line = explode(" ", $line); $line = explode(" ", $line);
echo '<tr align=center><td>WR'.($line[1]+1).'</td><td>'.$line[2]." (".$line[3].')</td><td>'.($line[5]).'</td><td bgcolor="'.$vlancolor[$line[6]].'">VLAN '.$line[6].'</td><td>'.$line[7].'</td></td></tr>'; echo '<tr align=center><td>'.($line[0]).'</td><td>'.$line[1]." (".$line[2].')</td><td>'.($line[4]).'</td><td bgcolor="'.$vlancolor[$line[5]].'">VLAN '.$line[5].'</td><td>'.$line[6].'</td></td></tr>';
} }
......
...@@ -20,7 +20,7 @@ echo "# This file will be overwritten at next boot." >> $OUTPUT_FILE ...@@ -20,7 +20,7 @@ echo "# This file will be overwritten at next boot." >> $OUTPUT_FILE
#copy top of ppsi.conf #copy top of ppsi.conf
cat $PRE_FILE >> $OUTPUT_FILE cat $PRE_FILE >> $OUTPUT_FILE
for i_zero in {00..17};do for i_zero in {01..18};do
# unset parametes # unset parametes
unset p_name unset p_name
unset p_proto unset p_proto
...@@ -57,12 +57,12 @@ for i_zero in {00..17};do ...@@ -57,12 +57,12 @@ for i_zero in {00..17};do
i=$(expr $i_zero + 0) i=$(expr $i_zero + 0)
if [ -n "$p_proto" ]; then if [ -n "$p_proto" ]; then
echo "port wr$i-$p_proto" >> $OUTPUT_FILE echo "port wri$i-$p_proto" >> $OUTPUT_FILE
echo "proto $p_proto" >> $OUTPUT_FILE echo "proto $p_proto" >> $OUTPUT_FILE
else else
echo "port wr$i-raw" >> $OUTPUT_FILE echo "port wri$i-raw" >> $OUTPUT_FILE
fi fi
echo "iface wr$i" >> $OUTPUT_FILE echo "iface wri$i" >> $OUTPUT_FILE
if [ -n "$p_role" ]; then if [ -n "$p_role" ]; then
echo "role $p_role" >> $OUTPUT_FILE echo "role $p_role" >> $OUTPUT_FILE
fi fi
......
...@@ -4,93 +4,93 @@ ...@@ -4,93 +4,93 @@
clock-class 187 clock-class 187
clock-accuracy 254 clock-accuracy 254
port wr0 port wri1
iface wr0 iface wri1
role auto role auto
extension whiterabbit extension whiterabbit
port wr1 port wri2
iface wr1 iface wri2
role auto role auto
extension whiterabbit extension whiterabbit
port wr2 port wri3
iface wr2 iface wri3
role auto role auto
extension whiterabbit extension whiterabbit
port wr3 port wri4
iface wr3 iface wri4
role auto role auto
extension whiterabbit extension whiterabbit
port wr4 port wri5
iface wr4 iface wri5
role auto role auto
extension whiterabbit extension whiterabbit
port wr5 port wri6
iface wr5 iface wri6
role auto role auto
extension whiterabbit extension whiterabbit
port wr6 port wri7
iface wr6 iface wri7
role auto role auto
extension whiterabbit extension whiterabbit
port wr7 port wri8
iface wr7 iface wri8
role auto role auto
extension whiterabbit extension whiterabbit
port wr8 port wri9
iface wr8 iface wri9
role auto role auto
extension whiterabbit extension whiterabbit
port wr9 port wri10
iface wr9 iface wri10
role auto role auto
extension whiterabbit extension whiterabbit
port wr10 port wri11
iface wr10 iface wri11
role auto role auto
extension whiterabbit extension whiterabbit
port wr11 port wri12
iface wr11 iface wri12
role auto role auto
extension whiterabbit extension whiterabbit
port wr12 port wri13
iface wr12 iface wri13
role auto role auto
extension whiterabbit extension whiterabbit
port wr13 port wri14
iface wr13 iface wri14
role auto role auto
extension whiterabbit extension whiterabbit
port wr14 port wri15
iface wr14 iface wri15
role auto role auto
extension whiterabbit extension whiterabbit
port wr15 port wri16
iface wr15 iface wri16
role auto role auto
extension whiterabbit extension whiterabbit
port wr16 port wri17
iface wr16 iface wri17
role auto role auto
extension whiterabbit extension whiterabbit
port wr17 port wri18
iface wr17 iface wri18
role auto role auto
extension whiterabbit extension whiterabbit
...@@ -5,17 +5,17 @@ set -e ...@@ -5,17 +5,17 @@ set -e
## fill this file with vlans configuration ## fill this file with vlans configuration
## Please note: ## Please note:
## wr1 is marked as port 2 on the front panel of the switch ## wri2 is marked as port 2 on the front panel of the switch
## in other words: ## in other words:
## --ep1 == wr1 ## --port 2 == wri2
## but: ## and:
## wr1 == port2 ## wri2 == port2
## example configuration: ## example configuration:
# configure ports 1-4,6,8-18 as evid 1 # configure ports 1-4,6,8-18 as pvid 1
# /wr/bin/wrs_vlans --ep 0-3,5,7-17 --emode 0 --evid 1 # /wr/bin/wrs_vlans --port 1-4,6,8-18 --pmode 0 --pvid 1
# configure ports 5,7 as evid 2 # configure ports 5,7 as pvid 2
# /wr/bin/wrs_vlans --ep 4,6 --emode 0 --evid 2 # /wr/bin/wrs_vlans --port 5,7 --pmode 0 --pvid 2
## set VID=1 on all ports except 4 and 6 ## set VID=1 on all ports except 4 and 6
## - binary: 11 1111 1111 1010 1111 ## - binary: 11 1111 1111 1010 1111
...@@ -28,6 +28,6 @@ set -e ...@@ -28,6 +28,6 @@ set -e
# /wr/bin/wrs_vlans --rvid 2 --rfid 2 --rmask 0x00050 # /wr/bin/wrs_vlans --rvid 2 --rfid 2 --rmask 0x00050
## when VLANs are defined, comment out the line below ## when VLANs are defined, comment out the line below
echo -n "no configuration " echo -n "no vlan configuration "
exit 0 exit 0
The initial version of wrsScalar.c and wrsScalar.h is generated by running
export BUILD_DIR="$WRS_OUTPUT_DIR/build/buildroot-2011.11/output/build"
export MIBDIRS=$BUILD_DIR/netsnmp-5.6.1.1/mibs
And then this "intuitive" command:
export MIBS=./WR-SWITCH-MIB.txt
$BUILD_DIR/netsnmp-5.6.1.1/local/mib2c \
-I $BUILD_DIR/netsnmp-5.6.1.1/local \
-c mib2c.scalar.conf \
wrsScalar
Clearly, if you rename the item, the code must be completely rewritten
(and I already did it once).
Pstats code, on the other hand, is based on what ifTable does in the
real snmpd. i.e., no autogeneration was used.
This is one option I tried, but the result was too complex:
export MIBS=./WR-SWITCH-MIB.txt
$BUILD_DIR/netsnmp-5.6.1.1/local/mib2c \
-I $BUILD_DIR/netsnmp-5.6.1.1/local \
-I $BUILD_DIR/netsnmp-5.6.1.1/local/mib2c-conf.d \
-c mib2c.mfd.conf \
pstatsTable
This one spits out a single file, but again too complex for me:
export MIBS=./WR-SWITCH-MIB.txt
$BUILD_DIR/netsnmp-5.6.1.1/local/mib2c \
-I $BUILD_DIR/netsnmp-5.6.1.1/local \
-I $BUILD_DIR/netsnmp-5.6.1.1/local/mib2c-conf.d \
-c mib2c.raw-table.conf \
pstatsTable
Using "mib2c.create-dataset.conf" is even worse, becahse the dataset
is static and hidden in some obscure place, I can't change it after
creation.
With the current code base, I properly get the counters:
tornado% snmpwalk -c public -v 2c wrs SNMPv2-SMI::enterprises.96.100 | wc -l
743
The numeric OID for WRS is:
.1.3.6.1.4.1.96.100
The OID for counters is:
.1.3.6.1.4.1.96.100.2.1
Then, column 1 is the counter names, and colomn N+2 is the counters for
port wrN (0..17). Column M+1 is for port M as written on the device (1..18).
Example: get counter 18 (line 19):
snmpwalk -On -c public -v 2c wrs SNMPv2-SMI::enterprises.96.100.2.1 | \
grep '2\.1\..*\.19 ='
.1.3.6.1.4.1.96.100.2.1.1.19 = STRING: "TX Frames"
.1.3.6.1.4.1.96.100.2.1.2.19 = Counter32: 38
.1.3.6.1.4.1.96.100.2.1.3.19 = Counter32: 38
.1.3.6.1.4.1.96.100.2.1.4.19 = Counter32: 0
.1.3.6.1.4.1.96.100.2.1.5.19 = Counter32: 38
.1.3.6.1.4.1.96.100.2.1.6.19 = Counter32: 38
.1.3.6.1.4.1.96.100.2.1.7.19 = Counter32: 38
.1.3.6.1.4.1.96.100.2.1.8.19 = Counter32: 38
.1.3.6.1.4.1.96.100.2.1.9.19 = Counter32: 38
.1.3.6.1.4.1.96.100.2.1.10.19 = Counter32: 38
.1.3.6.1.4.1.96.100.2.1.11.19 = Counter32: 38
.1.3.6.1.4.1.96.100.2.1.12.19 = Counter32: 1057
.1.3.6.1.4.1.96.100.2.1.13.19 = Counter32: 38
.1.3.6.1.4.1.96.100.2.1.14.19 = Counter32: 0
.1.3.6.1.4.1.96.100.2.1.15.19 = Counter32: 38
.1.3.6.1.4.1.96.100.2.1.16.19 = Counter32: 1025
.1.3.6.1.4.1.96.100.2.1.17.19 = Counter32: 38
.1.3.6.1.4.1.96.100.2.1.18.19 = Counter32: 38
.1.3.6.1.4.1.96.100.2.1.19.19 = Counter32: 38
You can get a symbolic readout by forcing the tool to access the
local WR-SWITCH-MIB.txt. So we can get all counters for port WR14 like
this:
snmpwalk -m $WR_SWITCH_SW/userspace/snmpd/WR-SWITCH-MIB.txt \
-c public -v 2c wrs 1.3.6.1.4.1.96.100.2 | \
grep WR14
...@@ -17,8 +17,8 @@ proc updatew {wname} { ...@@ -17,8 +17,8 @@ proc updatew {wname} {
set new [expr ![llength [winfo children $wname]]] set new [expr ![llength [winfo children $wname]]]
if $new { if $new {
grid [label $wname.name -text "CTR NAME" -fg blue] -row 0 -column 1 grid [label $wname.name -text "CTR NAME" -fg blue] -row 0 -column 1
for {set i 0; set c 2} {$i < 18} {incr i; incr c} { for {set i 1; set c 2} {$i < 19} {incr i; incr c} {
grid [label $wname.wr$i -text "WR$i" -fg blue] -row 0 -column $c grid [label $wname.wri$i -text "WRI$i" -fg blue] -row 0 -column $c
} }
} }
set labels {wrsPstatsHCPortName set labels {wrsPstatsHCPortName
......
...@@ -73,7 +73,7 @@ static int get_endpoint_status(struct ns_pstats *old, ...@@ -73,7 +73,7 @@ static int get_endpoint_status(struct ns_pstats *old,
* logs */ * logs */
ret = 1; ret = 1;
snmp_log(LOG_ERR, "SNMP: wrsEndpointStatus failed for " snmp_log(LOG_ERR, "SNMP: wrsEndpointStatus failed for "
"port %d\n", i); "port %d (wri %d)\n", i + 1, i + 1);
} }
} }
return ret; return ret;
...@@ -107,7 +107,7 @@ static int get_swcore_status(struct ns_pstats *old, ...@@ -107,7 +107,7 @@ static int get_swcore_status(struct ns_pstats *old,
* logs */ * logs */
ret = 1; ret = 1;
snmp_log(LOG_ERR, "SNMP: wrsSwcoreStatus failed for " snmp_log(LOG_ERR, "SNMP: wrsSwcoreStatus failed for "
"port %d\n", i); "port %d (wri %d)\n", i + 1, i + 1);
} }
#endif #endif
/* values from 2.2.5 "Too much HP traffic / Per-priority queue /* values from 2.2.5 "Too much HP traffic / Per-priority queue
...@@ -129,7 +129,7 @@ static int get_swcore_status(struct ns_pstats *old, ...@@ -129,7 +129,7 @@ static int get_swcore_status(struct ns_pstats *old,
* logs */ * logs */
ret = 1; ret = 1;
snmp_log(LOG_ERR, "SNMP: wrsSwcoreStatus failed for " snmp_log(LOG_ERR, "SNMP: wrsSwcoreStatus failed for "
"port %d\n", i); "port %d (wri %d)\n", i + 1, i + 1);
} }
} }
return ret; return ret;
...@@ -151,7 +151,7 @@ static int get_rtu_status(struct ns_pstats *old, ...@@ -151,7 +151,7 @@ static int get_rtu_status(struct ns_pstats *old,
* logs */ * logs */
ret = 1; ret = 1;
snmp_log(LOG_ERR, "SNMP: wrsEndpointStatus failed for " snmp_log(LOG_ERR, "SNMP: wrsEndpointStatus failed for "
"port %d\n", i); "port %d (wri %d)\n", i + 1, i + 1);
} }
} }
/* TODO: add 2.2.7 "Network loop - two or more identical MACs on two or /* TODO: add 2.2.7 "Network loop - two or more identical MACs on two or
......
...@@ -67,7 +67,7 @@ time_t wrsPortStatusTable_data_fill(unsigned int *n_rows) ...@@ -67,7 +67,7 @@ time_t wrsPortStatusTable_data_fill(unsigned int *n_rows)
/* Assume that number of ports does not change between /* Assume that number of ports does not change between
* reads */ * reads */
snprintf(wrsPortStatusTable_array[i].port_name, 10, snprintf(wrsPortStatusTable_array[i].port_name, 10,
"wr%d", i); "wri%d", i + 1);
port_state = hal_lookup_port(hal_ports, port_state = hal_lookup_port(hal_ports,
hal_nports_local, hal_nports_local,
wrsPortStatusTable_array[i].port_name); wrsPortStatusTable_array[i].port_name);
......
...@@ -108,8 +108,8 @@ wrsPstatsHCTable_data_fill(unsigned int *n_rows) ...@@ -108,8 +108,8 @@ wrsPstatsHCTable_data_fill(unsigned int *n_rows)
/* read pstats for each port */ /* read pstats for each port */
for (wrport = 0; wrport < WRS_N_PORTS; wrport++) { for (wrport = 0; wrport < WRS_N_PORTS; wrport++) {
snprintf(pstats_array[wrport].port_name, 10, snprintf(pstats_array[wrport].port_name, 10,
"wr%d", wrport); "wri%d", wrport + 1);
sprintf(fname, PSTATS_SYSCTL_PATH"port%i", wrport); sprintf(fname, PSTATS_SYSCTL_PATH"wrport%i", wrport + 1);
f = fopen(fname, "r"); f = fopen(fname, "r");
if (!f) { if (!f) {
snmp_log(LOG_ERR, snmp_log(LOG_ERR,
......
...@@ -243,7 +243,8 @@ static void get_wrsSlaveLinksStatus(unsigned int port_status_nrows) ...@@ -243,7 +243,8 @@ static void get_wrsSlaveLinksStatus(unsigned int port_status_nrows)
wrsTimingStatus_s.wrsSlaveLinksStatus = wrsTimingStatus_s.wrsSlaveLinksStatus =
WRS_SLAVE_LINK_STATUS_ERROR; WRS_SLAVE_LINK_STATUS_ERROR;
snmp_log(LOG_ERR, "SNMP: wrsSlaveLinksStatus (slave) " snmp_log(LOG_ERR, "SNMP: wrsSlaveLinksStatus (slave) "
"failed for port %d\n", i); "failed for port %d (wri%d)\n",
i + 1, i + 1);
} }
/* error when slave port is up when switch is in master or /* error when slave port is up when switch is in master or
* grandmaster mode */ * grandmaster mode */
...@@ -253,7 +254,8 @@ static void get_wrsSlaveLinksStatus(unsigned int port_status_nrows) ...@@ -253,7 +254,8 @@ static void get_wrsSlaveLinksStatus(unsigned int port_status_nrows)
wrsTimingStatus_s.wrsSlaveLinksStatus = wrsTimingStatus_s.wrsSlaveLinksStatus =
WRS_SLAVE_LINK_STATUS_ERROR; WRS_SLAVE_LINK_STATUS_ERROR;
snmp_log(LOG_ERR, "SNMP: wrsSlaveLinksStatus (master) " snmp_log(LOG_ERR, "SNMP: wrsSlaveLinksStatus (master) "
"failed for port %d\n", i); "failed for port %d (wri%d)\n",
i + 1, i + 1);
} }
} }
} }
...@@ -295,7 +297,8 @@ static void get_wrsPTPFramesFlowing(unsigned int port_status_nrows) ...@@ -295,7 +297,8 @@ static void get_wrsPTPFramesFlowing(unsigned int port_status_nrows)
wrsTimingStatus_s.wrsPTPFramesFlowing = wrsTimingStatus_s.wrsPTPFramesFlowing =
WRS_PTP_FRAMES_FLOWING_ERROR; WRS_PTP_FRAMES_FLOWING_ERROR;
snmp_log(LOG_ERR, "SNMP: wrsPTPFramesFlowing " snmp_log(LOG_ERR, "SNMP: wrsPTPFramesFlowing "
"failed for port %d\n", i); "failed for port %d (wri%d)\n",
i + 1, i + 1);
/* can't go worse, no need to change other ports */ /* can't go worse, no need to change other ports */
break; break;
......
...@@ -102,7 +102,7 @@ char *decode_ports(int dpm, int nports) ...@@ -102,7 +102,7 @@ char *decode_ports(int dpm, int nports)
for (i = 0; i < nports; i++) for (i = 0; i < nports; i++)
{ {
sprintf(str2,"%d ", i); sprintf(str2, "%d ", i + 1);
if(dpm&(1<<i)) strcat(str,str2); if(dpm&(1<<i)) strcat(str,str2);
} }
...@@ -322,29 +322,57 @@ int main(int argc, char **argv) ...@@ -322,29 +322,57 @@ int main(int argc, char **argv)
isok=0; isok=0;
if(argc>1) if(argc>1)
{ {
if(strcmp(argv[1], "remove")==0) if (strcmp(argv[1], "remove") == 0) {
{
i=atoidef(argv[2],-1); i=atoidef(argv[2],-1);
if((0 <= i && i < 18) && (rtudexp_clear_entries(i,atoidef(argv[3],0))==0)) isok=1; /* interface number 1..18*/
else printf("Could not %s entry for wr%d\n",argv[1],i); if ((0 < i && i <= 18)
} && (rtudexp_clear_entries(i - 1,
else if(strcmp(argv[1], "add")==0) atoidef(argv[3], 0)
{ ) == 0)) {
if((argc > 3) && (rtudexp_add_entry(argv[2],atoi(argv[3]),atoidef(argv[4],0))==0)) isok=1; /* ok */
else printf("Could not %s entry for %s\n",argv[2],argv[3]); isok = 1;
} } else {
else if(strcmp(argv[1], "vlan")==0) printf("Could not %s entry for wri%d\n",
{ argv[1], i);
if((argc > 3 ) && (rtudexp_vlan_entry(atoi(argv[2]),atoi(argv[3]),argv[4], exit(1);
atoidef(argv[5],0),atoidef(argv[6],0),atoidef(argv[7],0), }
atoidef(argv[8],0))==0)) isok=1; } else if (strcmp(argv[1], "add") == 0) {
else printf("Could not %s entry for %s\n",argv[2],argv[3]); /* interface number 1..18*/
exit(1); if ((argc > 3)
} && (rtudexp_add_entry(argv[2],
else if(strcmp(argv[1], "list")==0) isok=1; atoi(argv[3]) - 1,
atoidef(argv[4], 0)
) == 0)) {
/* ok */
isok = 1;
} else {
printf("Could not %s entry for %s\n", argv[2],
argv[3] - 1);
exit(1);
}
} else if (strcmp(argv[1], "vlan") == 0) {
if ((argc > 3)
&& (rtudexp_vlan_entry(atoi(argv[2]),
atoi(argv[3]) - 1,
argv[4],
atoidef(argv[5], 0),
atoidef(argv[6], 0),
atoidef(argv[7], 0),
atoidef(argv[8], 0)
) == 0)) {
/* ok */
isok = 1;
} else {
printf("Could not %s entry for %s\n", argv[2],
argv[3]);
exit(1);
}
} else if (strcmp(argv[1], "list") == 0)
isok = 1;
//Does not continue //Does not continue
if(!isok) show_help(argv[0]); if (!isok)
show_help(argv[0]);
} }
......
...@@ -247,7 +247,7 @@ void show_ports(void) ...@@ -247,7 +247,7 @@ void show_ports(void)
int print_port = 0; int print_port = 0;
int print_mode_color = 0; int print_mode_color = 0;
snprintf(if_name, 10, "wr%d", i); snprintf(if_name, 10, "wri%d", i + 1);
port_state = hal_lookup_port(hal_ports_local_copy, port_state = hal_lookup_port(hal_ports_local_copy,
hal_nports_local, if_name); hal_nports_local, if_name);
......
...@@ -297,7 +297,7 @@ void calc_trans(int ep, int argc, char *argv[]) ...@@ -297,7 +297,7 @@ void calc_trans(int ep, int argc, char *argv[])
if(argc >= 3) if(argc >= 3)
f_log = fopen(argv[3], "wb"); f_log = fopen(argv[3], "wb");
snprintf(sock_addr.if_name, sizeof(sock_addr.if_name), "wr%d", ep); snprintf(sock_addr.if_name, sizeof(sock_addr.if_name), "wri%d", ep);
sock_addr.family = PTPD_SOCK_RAW_ETHERNET; // socket type sock_addr.family = PTPD_SOCK_RAW_ETHERNET; // socket type
sock_addr.ethertype = 12345; sock_addr.ethertype = 12345;
memset(sock_addr.mac, 0xff, 6); memset(sock_addr.mac, 0xff, 6);
...@@ -425,7 +425,7 @@ void pps_adjustment_test(int ep, int argc, char *argv[]) ...@@ -425,7 +425,7 @@ void pps_adjustment_test(int ep, int argc, char *argv[])
signal (SIGINT, sighandler); signal (SIGINT, sighandler);
snprintf(sock_addr.if_name, sizeof(sock_addr.if_name), "wr%d", ep); snprintf(sock_addr.if_name, sizeof(sock_addr.if_name), "wri%d", ep);
sock_addr.family = PTPD_SOCK_RAW_ETHERNET; // socket type sock_addr.family = PTPD_SOCK_RAW_ETHERNET; // socket type
sock_addr.ethertype = 12345; sock_addr.ethertype = 12345;
memset(sock_addr.mac, 0xff, 6); memset(sock_addr.mac, 0xff, 6);
...@@ -468,6 +468,8 @@ void pps_adjustment_test(int ep, int argc, char *argv[]) ...@@ -468,6 +468,8 @@ void pps_adjustment_test(int ep, int argc, char *argv[])
void rt_command(int ep, int argc, char *argv[]) void rt_command(int ep, int argc, char *argv[])
{ {
/* ep is 0..17 */
struct rts_pll_state pstate; struct rts_pll_state pstate;
int i; int i;
...@@ -476,7 +478,7 @@ void rt_command(int ep, int argc, char *argv[]) ...@@ -476,7 +478,7 @@ void rt_command(int ep, int argc, char *argv[])
if( rts_connect(NULL) < 0) if( rts_connect(NULL) < 0)
{ {
printf("Can't connect to the RT subsys\n"); printf("Can't connect to the RT subsys\n");
return; exit(1);
} }
rts_get_state(&pstate); rts_get_state(&pstate);
...@@ -487,7 +489,8 @@ void rt_command(int ep, int argc, char *argv[]) ...@@ -487,7 +489,8 @@ void rt_command(int ep, int argc, char *argv[])
hal_nports_local); hal_nports_local);
printf("CurrentRef: %d Mode: %d Flags: %x\n", pstate.current_ref, pstate.mode, pstate.flags); printf("CurrentRef: %d Mode: %d Flags: %x\n", pstate.current_ref, pstate.mode, pstate.flags);
for (i = 0; i < hal_nports_local; i++) for (i = 0; i < hal_nports_local; i++)
printf("wr%-2d: setpoint: %-8dps current: %-8dps loopback: %-8dps flags: %x\n", i, printf("wri%-2d: setpoint: %-8dps current: %-8dps "
"loopback: %-8dps flags: %x\n", i + 1,
pstate.channels[i].phase_setpoint, pstate.channels[i].phase_setpoint,
pstate.channels[i].phase_current, pstate.channels[i].phase_current,
pstate.channels[i].phase_loopback, pstate.channels[i].phase_loopback,
...@@ -514,7 +517,7 @@ void rt_command(int ep, int argc, char *argv[]) ...@@ -514,7 +517,7 @@ void rt_command(int ep, int argc, char *argv[])
} }
else if (!strcmp(argv[3], "track")) else if (!strcmp(argv[3], "track"))
{ {
printf("Enabling ptracker @ port %d\n", ep); printf("Enabling ptracker @ port %d (wri%d)\n", ep + 1, ep + 1);
rts_enable_ptracker(ep, 1); rts_enable_ptracker(ep, 1);
} }
...@@ -580,6 +583,7 @@ struct { ...@@ -580,6 +583,7 @@ struct {
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int i; int i;
int ep;
wrs_msg_init(1, argv); /* only use argv[0]: no cmdline */ wrs_msg_init(1, argv); /* only use argv[0]: no cmdline */
...@@ -601,7 +605,14 @@ int main(int argc, char **argv) ...@@ -601,7 +605,14 @@ int main(int argc, char **argv)
for(i=0; commands[i].cmd;i++) for(i=0; commands[i].cmd;i++)
if(!strcmp(commands[i].cmd, argv[2])) if(!strcmp(commands[i].cmd, argv[2]))
{ {
commands[i].func(atoi(argv[1]), argc, argv); /* first parameter is an enpoint number 1..18 */
ep = atoi(argv[1]) - 1;
if (ep < 0) {
printf("Wrong endpoint number %d\n", ep + 1);
exit(1);
}
/* pass endpoint as number 0..17 */
commands[i].func(ep, argc, argv);
return 0; return 0;
} }
......
...@@ -317,7 +317,7 @@ int dump_hal_mem(struct wrs_shm_head *head) ...@@ -317,7 +317,7 @@ int dump_hal_mem(struct wrs_shm_head *head)
} }
for (i = 0; i < n; i++, p++) { for (i = 0; i < n; i++, p++) {
printf("dump port %i\n", i); printf("dump port %i\n", i + 1);
dump_many_fields(p, hal_port_info, ARRAY_SIZE(hal_port_info)); dump_many_fields(p, hal_port_info, ARRAY_SIZE(hal_port_info));
} }
return 0; return 0;
......
...@@ -15,8 +15,9 @@ static struct EP_WB _ep_wb; ...@@ -15,8 +15,9 @@ static struct EP_WB _ep_wb;
/* convert WR switch endpoint register name to an address value */ /* convert WR switch endpoint register name to an address value */
#define EP_REG(regname) ((uint32_t)((void *)&_ep_wb.regname - (void *)&_ep_wb)) #define EP_REG(regname) ((uint32_t)((void *)&_ep_wb.regname - (void *)&_ep_wb))
/* convert port number (x) to an endpoint address, x from 0 to 17 on switch */ /* convert port number (x) to an endpoint address, x is 1..18 on switch,
#define IDX_TO_EP(x) (0x30000 + ((x) * 0x400)) * ep is 0..17 */
#define IDX_TO_EP(x) (0x30000 + (((x) - 1) * 0x400))
/* FIXME: if include of endpoint-mdio.h is fixed this define can go: /* FIXME: if include of endpoint-mdio.h is fixed this define can go:
* #ifndef __WBGEN2_REGDEFS_ENDPOINT-MDIO_WB to * #ifndef __WBGEN2_REGDEFS_ENDPOINT-MDIO_WB to
...@@ -39,7 +40,7 @@ void help(char *prgname) ...@@ -39,7 +40,7 @@ void help(char *prgname)
" -h print help\n" " -h print help\n"
"\n" "\n"
" Port numbers:\n" " Port numbers:\n"
" <port_nr> = 0 to 17 (on 18 port switch)\n" " <port_nr> = 1 to 18 (on 18 port switch)\n"
"\n" "\n"
" Commands <cmd> are:\n" " Commands <cmd> are:\n"
" on - switch TX laser on.\n" " on - switch TX laser on.\n"
...@@ -49,38 +50,40 @@ void help(char *prgname) ...@@ -49,38 +50,40 @@ void help(char *prgname)
/* /*
* Read a 1000base-X TBI PCS register on a WR switch endpoint * Read a 1000base-X TBI PCS register on a WR switch endpoint
* ep: endpoint number (0 to 17, will be translated to address offset) * port: endpoint number (1 to 18, will be translated to address offset)
* reg: WR endpoint 1000base-X TBI PCS register address to read from * reg: WR endpoint 1000base-X TBI PCS register address to read from
*/ */
uint32_t pcs_read(int ep, uint32_t reg) uint32_t pcs_read(int port, uint32_t reg)
{ {
/* /*
* write the PCS register address to read from to the MDIO control * write the PCS register address to read from to the MDIO control
* register on the WR switch endpoint. * register on the WR switch endpoint.
*/ */
_fpga_writel(IDX_TO_EP(ep) + EP_REG(MDIO_CR), EP_MDIO_CR_ADDR_W(reg)); _fpga_writel(IDX_TO_EP(port) + EP_REG(MDIO_CR),
EP_MDIO_CR_ADDR_W(reg));
/* /*
* wait until the control register has processed the address and copied * wait until the control register has processed the address and copied
* the data from the address into the control register * the data from the address into the control register
*/ */
while (!(_fpga_readl(IDX_TO_EP(ep) + EP_REG(MDIO_ASR)) & while (!(_fpga_readl(IDX_TO_EP(port) + EP_REG(MDIO_ASR)) &
EP_MDIO_ASR_READY)) EP_MDIO_ASR_READY))
; ;
/* read data copied into the control register */ /* read data copied into the control register */
return EP_MDIO_CR_DATA_R(_fpga_readl(IDX_TO_EP(ep) + EP_REG(MDIO_ASR))); return EP_MDIO_CR_DATA_R(_fpga_readl(IDX_TO_EP(port) +
EP_REG(MDIO_ASR)));
} }
/* /*
* Write a value to a 1000base-X TBI PCS register on a WR switch endpoint * Write a value to a 1000base-X TBI PCS register on a WR switch endpoint
* ep: endpoint number (0 to 17, will be translated to address offset) * port: endpoint number (1 to 18, will be translated to address offset)
* reg: WR endpoint 1000base-X TBI PCS register address to write to * reg: WR endpoint 1000base-X TBI PCS register address to write to
* value: PCS register value to write * value: PCS register value to write
*/ */
void pcs_write(int ep, uint32_t reg, uint32_t val) void pcs_write(int port, uint32_t reg, uint32_t val)
{ {
_fpga_writel(IDX_TO_EP(ep) + EP_REG(MDIO_CR), EP_MDIO_CR_ADDR_W(reg) _fpga_writel(IDX_TO_EP(port) + EP_REG(MDIO_CR), EP_MDIO_CR_ADDR_W(reg)
| EP_MDIO_CR_DATA_W(val) | EP_MDIO_CR_RW); | EP_MDIO_CR_DATA_W(val) | EP_MDIO_CR_RW);
while (!(_fpga_readl(IDX_TO_EP(ep) + EP_REG(MDIO_ASR)) & while (!(_fpga_readl(IDX_TO_EP(port) + EP_REG(MDIO_ASR)) &
EP_MDIO_ASR_READY)) EP_MDIO_ASR_READY))
; ;
} }
...@@ -166,7 +169,7 @@ int main(int argc, char *argv[]) ...@@ -166,7 +169,7 @@ int main(int argc, char *argv[])
if (argc > 2) { if (argc > 2) {
port_number = atoi(argv[1]); port_number = atoi(argv[1]);
if (port_number < 0 || port_number > get_nports_from_hal()-1) { if (port_number < 1 || port_number > get_nports_from_hal()) {
printf("Port number out of range\n"); printf("Port number out of range\n");
exit(1); exit(1);
} }
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include <libwr/switch_hw.h> #include <libwr/switch_hw.h>
#include <libwr/hal_client.h> #include <libwr/hal_client.h>
static void parse_sysfs(int init); static void parse_sysfs(void);
#define NPORTS 18 #define NPORTS 18
#define CNT_PP 39 #define CNT_PP 39
...@@ -25,7 +25,13 @@ struct cnt_word { ...@@ -25,7 +25,13 @@ struct cnt_word {
uint64_t init; uint64_t init;
}; };
struct cnt_word cnt_pp[NPORTS][CNT_PP]; #define IF_SIZE 8
struct p_cnt {
char if_name[IF_SIZE];
struct cnt_word counters[CNT_PP];
};
struct p_cnt cnt_pp[NPORTS];
int use_ports; int use_ports;
char info[][20] = {{"Tu-run|"}, // 0 char info[][20] = {{"Tu-run|"}, // 0
...@@ -72,54 +78,66 @@ char info[][20] = {{"Tu-run|"}, // 0 ...@@ -72,54 +78,66 @@ char info[][20] = {{"Tu-run|"}, // 0
int pstats_init(int init) int pstats_init(int init)
{ {
int i, j; int i, j;
FILE *file;
uint32_t p_index, cntr;
uint32_t tmp1;
uint32_t tmp2;
uint64_t val;
char filename[30];
printf("module initialized\n"); printf("module initialized\n");
for(i=0; i<use_ports; ++i) for(i=0; i<use_ports; ++i)
for(j=0; j<CNT_PP; ++j) for(j=0; j<CNT_PP; ++j)
{ {
cnt_pp[i][j].init = 0; cnt_pp[i].counters[j].init = 0;
cnt_pp[i][j].cnt = 0; cnt_pp[i].counters[j].cnt = 0;
} }
parse_sysfs(init);
return 0;
}
static void parse_sysfs(int init) for (p_index = 0; p_index < use_ports; ++p_index) {
{ /* wrport is numbered from 1 to 18 */
FILE *file; snprintf(cnt_pp[p_index].if_name, IF_SIZE, "wri%u",
uint32_t port, cntr; p_index + 1);
uint32_t tmp1;
uint32_t tmp2;
uint64_t val;
char filename[30];
if (init == 1) { if (init == 1) {
for(port=0; port<use_ports; ++port) { sprintf(filename, "/proc/sys/pstats/wrport%u",
sprintf(filename, "/proc/sys/pstats/port%u", port); p_index + 1);
file = fopen(filename, "r"); file = fopen(filename, "r");
for(cntr=0; cntr<CNT_PP; ++cntr) { for (cntr = 0; cntr < CNT_PP; ++cntr) {
fscanf(file, "%" SCNu32, &tmp1); fscanf(file, "%" SCNu32, &tmp1);
fscanf(file, "%" SCNu32, &tmp2); fscanf(file, "%" SCNu32, &tmp2);
val = (((uint64_t) tmp2) << 32) | tmp1; val = (((uint64_t) tmp2) << 32) | tmp1;
cnt_pp[port][cntr].init = val; cnt_pp[p_index].counters[cntr].init = val;
} }
fclose(file); fclose(file);
} }
} }
else { parse_sysfs();
for(port=0; port<use_ports; ++port) { return 0;
}
sprintf(filename, "/proc/sys/pstats/port%u", port); static void parse_sysfs(void)
file = fopen(filename, "r"); {
for(cntr=0; cntr<CNT_PP; ++cntr) { FILE *file;
fscanf(file, "%" SCNu32, &tmp1); uint32_t p_index, cntr;
fscanf(file, "%" SCNu32, &tmp2); uint32_t tmp1;
val = (((uint64_t) tmp2) << 32) | tmp1; uint32_t tmp2;
cnt_pp[port][cntr].cnt = val - cnt_pp[port][cntr].init; uint64_t val;
} char filename[30];
fclose(file);
for (p_index = 0; p_index < use_ports; ++p_index) {
/* wrport is numbered from 1 to 18 */
sprintf(filename, "/proc/sys/pstats/wrport%u",
p_index + 1);
file = fopen(filename, "r");
for (cntr = 0; cntr < CNT_PP; ++cntr) {
fscanf(file, "%" SCNu32, &tmp1);
fscanf(file, "%" SCNu32, &tmp2);
val = (((uint64_t) tmp2) << 32) | tmp1;
cnt_pp[p_index].counters[cntr].cnt =
val - cnt_pp[p_index].counters[cntr].init;
} }
fclose(file);
} }
} }
...@@ -127,8 +145,8 @@ static void parse_sysfs(int init) ...@@ -127,8 +145,8 @@ static void parse_sysfs(int init)
void print_first_n_cnts(int n_cnts) void print_first_n_cnts(int n_cnts)
{ {
int cnt = 0; int cnt = 0;
int port = 0; int p_index = 0;
printf("P |"); printf("P |");
for(cnt=0; cnt<n_cnts; ++cnt) for(cnt=0; cnt<n_cnts; ++cnt)
printf("%2d:%s", cnt,info[cnt]); printf("%2d:%s", cnt,info[cnt]);
printf("\n"); printf("\n");
...@@ -137,11 +155,11 @@ void print_first_n_cnts(int n_cnts) ...@@ -137,11 +155,11 @@ void print_first_n_cnts(int n_cnts)
printf("----------"); printf("----------");
printf("\n"); printf("\n");
for(port=0; port<use_ports; ++port) for (p_index = 0; p_index < use_ports; ++p_index)
{ {
printf("%2u|", port); printf("%-5s|", cnt_pp[p_index].if_name);
for(cnt=0; cnt<n_cnts;++cnt) for (cnt = 0; cnt < n_cnts; ++cnt)
printf("%9llu|", cnt_pp[port][cnt].cnt); printf("%9llu|", cnt_pp[p_index].counters[cnt].cnt);
printf("\n"); printf("\n");
} }
} }
...@@ -149,9 +167,9 @@ void print_first_n_cnts(int n_cnts) ...@@ -149,9 +167,9 @@ void print_first_n_cnts(int n_cnts)
void print_chosen_cnts( int cnts_list[], int n_cnts) void print_chosen_cnts( int cnts_list[], int n_cnts)
{ {
int cnt = 0; int cnt = 0;
int port = 0; int p_index = 0;
printf("P |"); printf("P |");
for(cnt=0; cnt<n_cnts; ++cnt) for(cnt=0; cnt<n_cnts; ++cnt)
printf("%2d:%s", cnts_list[cnt],info[cnts_list[cnt]]); printf("%2d:%s", cnts_list[cnt],info[cnts_list[cnt]]);
printf("\n"); printf("\n");
...@@ -159,11 +177,12 @@ void print_chosen_cnts( int cnts_list[], int n_cnts) ...@@ -159,11 +177,12 @@ void print_chosen_cnts( int cnts_list[], int n_cnts)
for(cnt=0; cnt<n_cnts; ++cnt) for(cnt=0; cnt<n_cnts; ++cnt)
printf("----------"); printf("----------");
printf("\n"); printf("\n");
for(port=0; port<use_ports; ++port) for (p_index = 0; p_index < use_ports; ++p_index)
{ {
printf("%2u|", port); printf("%-5s|", cnt_pp[p_index].if_name);
for(cnt=0; cnt<n_cnts;++cnt) for (cnt = 0; cnt < n_cnts; ++cnt)
printf("%9llu|", cnt_pp[port][cnts_list[cnt]].cnt); printf("%9llu|",
cnt_pp[p_index].counters[cnts_list[cnt]].cnt);
printf("\n"); printf("\n");
} }
} }
...@@ -223,7 +242,7 @@ int main(int argc, char **argv) ...@@ -223,7 +242,7 @@ int main(int argc, char **argv)
while(1) while(1)
{ {
printf("\033[2J\033[1;1H"); printf("\033[2J\033[1;1H");
parse_sysfs(0); parse_sysfs();
switch(op) { switch(op) {
case 'p': case 'p':
print_chosen_cnts(prio_cnts, 8); print_chosen_cnts(prio_cnts, 8);
......
...@@ -79,14 +79,14 @@ int main(int argc, char **argv) ...@@ -79,14 +79,14 @@ int main(int argc, char **argv)
for (i = dump_port; i <= nports; i++) { for (i = dump_port; i <= nports; i++) {
memset(&shdr, 0, sizeof(shdr)); memset(&shdr, 0, sizeof(shdr));
printf("========= port %d =========\n", i - 1); printf("========= port %d =========\n", i);
err = shw_sfp_read_verify_header(i - 1, &shdr); err = shw_sfp_read_verify_header(i - 1, &shdr);
if (err == -2) { if (err == -2) {
pr_error("SFP module not inserted in port %d. Failed " pr_error("SFP module not inserted in port %d. Failed "
"to read SFP configuration header\n", i - 1); "to read SFP configuration header\n", i);
} else if (err < 0) { } else if (err < 0) {
pr_error("Failed to read SFP configuration header on " pr_error("Failed to read SFP configuration header on "
"port %d\n", i - 1); "port %d\n", i);
} else { } else {
shw_sfp_print_header(&shdr); shw_sfp_print_header(&shdr);
if (dump_hex_header) { if (dump_hex_header) {
......
...@@ -48,12 +48,12 @@ static struct option ropts[] = { ...@@ -48,12 +48,12 @@ static struct option ropts[] = {
{"debug", 0, &debug, 1}, {"debug", 0, &debug, 1},
{"clear", 0, NULL, OPT_CLEAR}, {"clear", 0, NULL, OPT_CLEAR},
{"list", 0, NULL, OPT_LIST}, {"list", 0, NULL, OPT_LIST},
{"ep", 1, NULL, OPT_EP_PORT}, {"port", 1, NULL, OPT_P_PORT},
{"emode", 1, NULL, OPT_EP_QMODE}, {"pmode", 1, NULL, OPT_P_QMODE},
{"evid", 1, NULL, OPT_EP_VID}, {"pvid", 1, NULL, OPT_P_VID},
{"eprio", 1, NULL, OPT_EP_PRIO}, {"pprio", 1, NULL, OPT_P_PRIO},
{"eumask", 1, NULL, OPT_EP_UMASK}, {"pumask", 1, NULL, OPT_P_UMASK},
{"elist", 0, NULL, OPT_EP_LIST}, {"plist", 0, NULL, OPT_P_LIST},
{"rvid", 1, NULL, OPT_RTU_VID}, {"rvid", 1, NULL, OPT_RTU_VID},
{"rfid", 1, NULL, OPT_RTU_FID}, {"rfid", 1, NULL, OPT_RTU_FID},
{"rmask", 1, NULL, OPT_RTU_PMASK}, {"rmask", 1, NULL, OPT_RTU_PMASK},
...@@ -75,7 +75,7 @@ static int set_rtu_vlan(int vid, int fid, int pmask, int drop, int prio, ...@@ -75,7 +75,7 @@ static int set_rtu_vlan(int vid, int fid, int pmask, int drop, int prio,
int del, int flags); int del, int flags);
static void free_rtu_vlans(struct rtu_vlans_t *ptr); static void free_rtu_vlans(struct rtu_vlans_t *ptr);
static void list_rtu_vlans(void); static void list_rtu_vlans(void);
static void list_ep_vlans(void); static void list_p_vlans(void);
static int rtu_find_vlan(struct rtu_vlan_table_entry *rtu_vlan_entry, int vid, static int rtu_find_vlan(struct rtu_vlan_table_entry *rtu_vlan_entry, int vid,
int fid); int fid);
static int config_rtud(void); static int config_rtud(void);
...@@ -113,6 +113,10 @@ static int parse_mask(char *arg, unsigned long *pmask) ...@@ -113,6 +113,10 @@ static int parse_mask(char *arg, unsigned long *pmask)
default: default:
return -1; return -1;
} }
/* parameter --port should be from the range 1..18,
* but internally we use 0..17 */
p1--;
p2--;
if ((p1 > p2) || (p1 < 0) || (p2 >= NPORTS)) if ((p1 > p2) || (p1 < 0) || (p2 >= NPORTS))
return -1; return -1;
for (; p1 <= p2; p1++) { for (; p1 <= p2; p1++) {
...@@ -123,9 +127,9 @@ static int parse_mask(char *arg, unsigned long *pmask) ...@@ -123,9 +127,9 @@ static int parse_mask(char *arg, unsigned long *pmask)
if (!debug) if (!debug)
return 0; return 0;
fprintf(stderr, "%s: working on ports:", prgname); printf("%s: working on ports:\n", prgname);
iterate_ports(p1, *pmask) iterate_ports(p1, *pmask)
printf(" %i", p1); printf(" %i", p1 + 1);
printf("\n"); printf("\n");
return 0; return 0;
} }
...@@ -133,7 +137,7 @@ static int parse_mask(char *arg, unsigned long *pmask) ...@@ -133,7 +137,7 @@ static int parse_mask(char *arg, unsigned long *pmask)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int c, i, arg; int c, i, arg;
unsigned long conf_pmask = 0; //current '--ep' port mask unsigned long conf_pmask = 0; /* current '--port' port mask */
struct rtu_shmem_header *rtu_hdr; struct rtu_shmem_header *rtu_hdr;
int n_wait = 0; int n_wait = 0;
int ret; int ret;
...@@ -208,19 +212,18 @@ int main(int argc, char *argv[]) ...@@ -208,19 +212,18 @@ int main(int argc, char *argv[])
/*parse parameters*/ /*parse parameters*/
while( (c = getopt_long(argc, argv, "h", ropts, NULL)) != -1) { while( (c = getopt_long(argc, argv, "h", ropts, NULL)) != -1) {
switch(c) { switch(c) {
case OPT_EP_PORT: case OPT_P_PORT:
//port number /* port number */
conf_pmask = 0; conf_pmask = 0;
if (parse_mask(optarg, &conf_pmask) < 0) { if (parse_mask(optarg, &conf_pmask) < 0) {
fprintf(stderr, "%s: wrong port mask " fprintf(stderr, "%s: wrong port mask "
"\"%s\"\n", prgname, optarg); "\"%s\"\n", prgname, optarg);
exit(1); exit(1);
} }
break; break;
case OPT_EP_QMODE:
//qmode for port case OPT_P_QMODE:
/* qmode for port */
arg = atoi(optarg); arg = atoi(optarg);
if (arg < 0 || arg > 3) { if (arg < 0 || arg > 3) {
fprintf(stderr, "%s: invalid qmode %i (\"%s\")\n", fprintf(stderr, "%s: invalid qmode %i (\"%s\")\n",
...@@ -235,22 +238,25 @@ int main(int argc, char *argv[]) ...@@ -235,22 +238,25 @@ int main(int argc, char *argv[])
vlans[i].untag_mask = (arg == 0); vlans[i].untag_mask = (arg == 0);
} }
break; break;
case OPT_EP_PRIO:
//priority value for port, forces fix_prio=1 case OPT_P_PRIO:
/* priority value for port, forces fix_prio=1 */
iterate_ports(i, conf_pmask) { iterate_ports(i, conf_pmask) {
vlans[i].prio_val = atoi(optarg); vlans[i].prio_val = atoi(optarg);
vlans[i].fix_prio = 1; vlans[i].fix_prio = 1;
vlans[i].valid_mask |= VALID_PRIO; vlans[i].valid_mask |= VALID_PRIO;
} }
break; break;
case OPT_EP_VID:
//VID for port case OPT_P_VID:
/* VID for port */
iterate_ports(i, conf_pmask) { iterate_ports(i, conf_pmask) {
vlans[i].vid = atoi(optarg); vlans[i].vid = atoi(optarg);
vlans[i].valid_mask |= VALID_VID; vlans[i].valid_mask |= VALID_VID;
} }
break; break;
case OPT_EP_UMASK:
case OPT_P_UMASK:
//untag mask -- currently 0 or 1. Overrides default set in QMODE above //untag mask -- currently 0 or 1. Overrides default set in QMODE above
arg = atoi(optarg); arg = atoi(optarg);
if (arg < 0 || arg > 1) { if (arg < 0 || arg > 1) {
...@@ -263,9 +269,10 @@ int main(int argc, char *argv[]) ...@@ -263,9 +269,10 @@ int main(int argc, char *argv[])
vlans[i].valid_mask |= VALID_UNTAG; vlans[i].valid_mask |= VALID_UNTAG;
} }
break; break;
case OPT_EP_LIST:
// list endpoint stuff case OPT_P_LIST:
list_ep_vlans(); /* list endpoint stuff */
list_p_vlans();
break; break;
/****************************************************/ /****************************************************/
...@@ -322,28 +329,29 @@ int main(int argc, char *argv[]) ...@@ -322,28 +329,29 @@ int main(int argc, char *argv[])
static int print_help(char *prgname) static int print_help(char *prgname)
{ {
fprintf(stderr, "Use: %s [--ep <port number> <EP options> --ep <port number> " fprintf(stderr, "Use: %s [--port <port number 1..18> <port options> "
"<EP options> ...] [--rvid <vid> --rfid <fid> --rmask <mask> --rdrop " "--port <port number> <port options> ...] "
"[--rvid <vid> --rfid <fid> --rmask <mask> --rdrop "
"--rprio <prio> --rvid <vid>...] [--debug]\n", prgname); "--rprio <prio> --rvid <vid>...] [--debug]\n", prgname);
fprintf(stderr, fprintf(stderr,
"Endpoint options:\n" "Port options:\n"
"\t --emode <mode No.> sets qmode for a port, possible values:\n" "\t --pmode <mode No.> sets qmode for a port, possible values:\n"
"\t \t 0: ACCESS - tags untagged frames, drops tagged frames not belinging to configured VLAN\n" "\t \t 0: ACCESS - tags untagged frames, drops tagged frames not belinging to configured VLAN\n"
"\t \t 1: TRUNK - passes only tagged frames, drops all untagged frames\n" "\t \t 1: TRUNK - passes only tagged frames, drops all untagged frames\n"
"\t \t 2: VLANs disabled - passess all frames as is\n" "\t \t 2: VLANs disabled - passess all frames as is\n"
"\t \t 3: Unqualified port - passess all frames regardless VLAN config\n" "\t \t 3: Unqualified port - passess all frames regardless VLAN config\n"
"\t --eprio <priority> sets priority for retagging\n" "\t --pprio <priority> sets priority for retagging\n"
"\t --evid <vid> sets VLAN Id for port\n" "\t --pvid <vid> sets VLAN Id for port\n"
"\t --eumask <hex mask> sets untag mask for port\n" "\t --pumask <hex mask> sets untag mask for port\n"
"\t --elist lists current EP configuration\n" "\t --plist lists current ports configuration\n"
"RTU options:\n" "RTU options:\n"
"\t --rvid <vid> configure VLAN <vid> in rtud\n" "\t --rvid <vid> configure VLAN <vid> in rtud\n"
"\t --del delete selected VLAN from rtud\n" "\t --del delete selected VLAN from rtud\n"
"\t --rfid <fid> assign <fid> to configured VLAN\n" "\t --rfid <fid> assign <fid> to configured VLAN\n"
"\t --rmask <hex mask> ports belonging to configured VLAN\n" "\t --rmask <hex mask> ports belonging to configured VLAN\n"
"\t --rdrop <1/0> drop/don't drop frames on VLAN\n" "\t --rdrop <1/0> drop/don't drop frames on VLAN\n"
"\t --rprio <prio> force priority for VLAN (-1 cancels priority override\n" "\t --rprio <prio> force priority for VLAN (-1 cancels priority override)\n"
"Other options:\n" "Other options:\n"
"\t --clear clears RTUd VLAN table\n" "\t --clear clears RTUd VLAN table\n"
"\t --list prints the content of RTUd VLAN table\n" "\t --list prints the content of RTUd VLAN table\n"
...@@ -359,10 +367,17 @@ static void print_config(struct s_port_vlans *vlans) ...@@ -359,10 +367,17 @@ static void print_config(struct s_port_vlans *vlans)
for_each_port(i) { for_each_port(i) {
printf("port: %d, qmode: %d, qmode_valid: %d, fix_prio: %d, prio_val: %d, " printf("port: %d, qmode: %d, qmode_valid: %d, fix_prio: %d, prio_val: %d, "
"prio_valid: %d, vid: %d, vid_valid: %d, untag_mask: 0x%X, untag_valid: %d\n", "prio_valid: %d, vid: %d, vid_valid: %d, untag_mask: 0x%X, untag_valid: %d\n",
i, vlans[i].qmode, ((vlans[i].valid_mask & VALID_QMODE) != 0), vlans[i].fix_prio, i + 1,
vlans[i].prio_val, ((vlans[i].valid_mask & VALID_PRIO) != 0),vlans[i].vid, vlans[i].qmode,
((vlans[i].valid_mask & VALID_VID) != 0), vlans[i].untag_mask, ((vlans[i].valid_mask & VALID_QMODE) != 0),
((vlans[i].valid_mask & VALID_UNTAG) != 0) ); vlans[i].fix_prio,
vlans[i].prio_val,
((vlans[i].valid_mask & VALID_PRIO) != 0),
vlans[i].vid,
((vlans[i].valid_mask & VALID_VID) != 0),
vlans[i].untag_mask,
((vlans[i].valid_mask & VALID_UNTAG) != 0)
);
} }
} }
...@@ -501,19 +516,19 @@ static void list_rtu_vlans(void) ...@@ -501,19 +516,19 @@ static void list_rtu_vlans(void)
} }
static void list_ep_vlans(void) static void list_p_vlans(void)
{ {
uint32_t v, r; uint32_t v, r;
int ep; int ep;
static char *names[] = {"ACCESS", "TRUNK", "disabled", "unqualified"}; static char *names[] = {"ACCESS", "TRUNK", "disabled", "unqualified"};
printf("# QMODE FIX_PRIO PRIO PVID MAC\n"); printf("# QMODE FIX_PRIO PRIO PVID MAC\n");
printf("#---------------------------------------------\n"); printf("#-----------------------------------------------\n");
for (ep = 0; ep < NPORTS; ep++) { for (ep = 0; ep < NPORTS; ep++) {
r = offsetof(struct EP_WB, VCR0); r = offsetof(struct EP_WB, VCR0);
v = ep_read(ep, r); v = ep_read(ep, r);
printf(" %2i %i %6.6s %i %i %4i %04x%08x\n", printf("wri%-2i %i %6.6s %i %i %4i %04x%08x\n",
ep, v & 3, names[v & 3], ep + 1, v & 3, names[v & 3],
v & EP_VCR0_FIX_PRIO ? 1 : 0, v & EP_VCR0_FIX_PRIO ? 1 : 0,
EP_VCR0_PRIO_VAL_R(v), EP_VCR0_PRIO_VAL_R(v),
EP_VCR0_PVID_R(v), EP_VCR0_PVID_R(v),
......
...@@ -46,12 +46,12 @@ ...@@ -46,12 +46,12 @@
#define OPT_DEBUG 'd' #define OPT_DEBUG 'd'
#define OPT_CLEAR 3 #define OPT_CLEAR 3
#define OPT_LIST 4 #define OPT_LIST 4
#define OPT_EP_PORT 10 #define OPT_P_PORT 10
#define OPT_EP_QMODE 11 #define OPT_P_QMODE 11
#define OPT_EP_VID 12 #define OPT_P_VID 12
#define OPT_EP_PRIO 13 #define OPT_P_PRIO 13
#define OPT_EP_UMASK 14 #define OPT_P_UMASK 14
#define OPT_EP_LIST 15 #define OPT_P_LIST 15
#define OPT_RTU_VID 20 #define OPT_RTU_VID 20
#define OPT_RTU_FID 21 #define OPT_RTU_FID 21
#define OPT_RTU_PMASK 22 #define OPT_RTU_PMASK 22
......
...@@ -39,11 +39,11 @@ int halexp_lock_cmd(const char *port_name, int command, int priority) ...@@ -39,11 +39,11 @@ int halexp_lock_cmd(const char *port_name, int command, int priority)
of the reference frequency. (priority) parameter of the reference frequency. (priority) parameter
allows to distinguish between various reference allows to distinguish between various reference
sources and establish a switchover order. For sources and establish a switchover order. For
example when wr0, wr1, wr2 have respectively example when wri1, wri2, wri3 have respectively
priorities (1, 0, 2), the primary clock source is priorities (1, 0, 2), the primary clock source is
wr1. When it dies (e.g. rats ate the fiber), the wri2. When it dies (e.g. rats ate the fiber), the
PLL will automatically switch to wr1, and if wr1 PLL will automatically switch to wri2, and if wri2
dies, to wr2. When all the ports are down, the PLL dies, to wri3. When all the ports are down, the PLL
will switch to holdover mode. In V3, calling this will switch to holdover mode. In V3, calling this
command with negative (priority) removes the port command with negative (priority) removes the port
from the locking list. from the locking list.
......
...@@ -92,13 +92,17 @@ static int hal_port_init(int index) ...@@ -92,13 +92,17 @@ static int hal_port_init(int index)
struct hal_port_state *p = &ports[index]; struct hal_port_state *p = &ports[index];
char name[128], s[128]; char name[128], s[128];
int val, error; int val, error;
int port_i;
/* index is 0..17, port_i 1..18 */
port_i = index + 1;
/* make sure the states and other variables are in their init state */ /* make sure the states and other variables are in their init state */
hal_port_reset_state(p); hal_port_reset_state(p);
/* read dot-config values for this index, starting from name */ /* read dot-config values for this index, starting from name */
error = libwr_cfg_convert2("PORT%02i_PARAMS", "name", LIBWR_STRING, error = libwr_cfg_convert2("PORT%02i_PARAMS", "name", LIBWR_STRING,
name, index); name, port_i);
if (error) if (error)
return -1; return -1;
strncpy(p->name, name, 16); strncpy(p->name, name, 16);
...@@ -112,23 +116,26 @@ static int hal_port_init(int index) ...@@ -112,23 +116,26 @@ static int hal_port_init(int index)
val = 18 * 800; /* magic default from previous code */ val = 18 * 800; /* magic default from previous code */
error = libwr_cfg_convert2("PORT%02i_PARAMS", "tx", LIBWR_INT, error = libwr_cfg_convert2("PORT%02i_PARAMS", "tx", LIBWR_INT,
&val, index); &val, port_i);
if (error) if (error)
pr_error("port index %i (%s): no \"tx=\" specified\n", pr_error("port %i (%s): no \"tx=\" specified\n",
index, name); port_i, name);
p->calib.phy_tx_min = val; p->calib.phy_tx_min = val;
val = 18 * 800; /* magic default from previous code */ val = 18 * 800; /* magic default from previous code */
error = libwr_cfg_convert2("PORT%02i_PARAMS", "rx", LIBWR_INT, error = libwr_cfg_convert2("PORT%02i_PARAMS", "rx", LIBWR_INT,
&val, index); &val, port_i);
if (error) if (error)
pr_error("port index %i (%s): no \"rx=\" specified\n", pr_error("port %i (%s): no \"rx=\" specified\n",
index, name); port_i, name);
p->calib.phy_rx_min = val; p->calib.phy_rx_min = val;
p->calib.delta_tx_board = 0; /* never set */ p->calib.delta_tx_board = 0; /* never set */
p->calib.delta_rx_board = 0; /* never set */ p->calib.delta_rx_board = 0; /* never set */
sscanf(p->name + 2, "%d", &p->hw_index); /* get the number of a port from notation wriX */
sscanf(p->name + 3, "%d", &p->hw_index);
/* hw_index is 0..17, p->name wri1..18 */
p->hw_index--;
p->t2_phase_transition = DEFAULT_T2_PHASE_TRANS; p->t2_phase_transition = DEFAULT_T2_PHASE_TRANS;
p->t4_phase_transition = DEFAULT_T4_PHASE_TRANS; p->t4_phase_transition = DEFAULT_T4_PHASE_TRANS;
...@@ -148,36 +155,36 @@ static int hal_port_init(int index) ...@@ -148,36 +155,36 @@ static int hal_port_init(int index)
strcpy(s, "non-wr"); /* default if no string passed */ strcpy(s, "non-wr"); /* default if no string passed */
p->mode = HEXP_PORT_MODE_NON_WR; p->mode = HEXP_PORT_MODE_NON_WR;
error = libwr_cfg_convert2("PORT%02i_PARAMS", "role", error = libwr_cfg_convert2("PORT%02i_PARAMS", "role",
LIBWR_STRING, s, index); LIBWR_STRING, s, port_i);
if (error) if (error)
pr_error("port index %i (%s): " pr_error("port %i (%s): "
"no \"role=\" specified\n", index, name); "no \"role=\" specified\n", port_i, name);
for (rp = rt; rp->name; rp++) for (rp = rt; rp->name; rp++)
if (!strcasecmp(s, rp->name)) if (!strcasecmp(s, rp->name))
break; break;
p->mode = rp->value; p->mode = rp->value;
if (!rp->name) if (!rp->name)
pr_error("port index %i (%s): invalid role " pr_error("port %i (%s): invalid role "
"\"%s\" specified\n", index, name, s); "\"%s\" specified\n", port_i, name, s);
pr_debug("Port %s: mode %i\n", p->name, val); pr_debug("Port %s: mode %i\n", p->name, val);
} }
/* Get fiber type */ /* Get fiber type */
error = libwr_cfg_convert2("PORT%02i_PARAMS", "fiber", error = libwr_cfg_convert2("PORT%02i_PARAMS", "fiber",
LIBWR_INT, &p->fiber_index, index); LIBWR_INT, &p->fiber_index, port_i);
if (error) { if (error) {
pr_error("port index %i (%s): " pr_error("port %i (%s): "
"no \"fiber=\" specified, default fiber to 0\n", "no \"fiber=\" specified, default fiber to 0\n",
index, name); port_i, name);
p->fiber_index = 0; p->fiber_index = 0;
} }
if (p->fiber_index > 3) { if (p->fiber_index > 3) {
pr_error("port index %i (%s): " pr_error("port %i (%s): "
"not supported \"fiber=\" value, default to 0\n", "not supported \"fiber=\" value, default to 0\n",
index, name); port_i, name);
p->fiber_index = 0; p->fiber_index = 0;
} }
...@@ -230,6 +237,7 @@ int hal_port_init_all(char *logfilename) ...@@ -230,6 +237,7 @@ int hal_port_init_all(char *logfilename)
for (index = 0; index < HAL_MAX_PORTS; index++) for (index = 0; index < HAL_MAX_PORTS; index++)
if (hal_port_init(index) < 0) if (hal_port_init(index) < 0)
break; break;
hal_port_nports = index; hal_port_nports = index;
pr_info("Number of physical ports supported in HW: %d\n", pr_info("Number of physical ports supported in HW: %d\n",
......
...@@ -572,8 +572,9 @@ void rtu_fd_clear_entries_for_port(int dest_port) ...@@ -572,8 +572,9 @@ void rtu_fd_clear_entries_for_port(int dest_port)
* including current */ * including current */
pr_error("cleaning multicast entries " pr_error("cleaning multicast entries "
"not supported yet... " "not supported yet... "
"mask=0x%x port=%d\n", "mask=0x%x port=%d (wri%d)\n",
ent->port_mask_dst, dest_port); ent->port_mask_dst,
dest_port + 1, dest_port + 1);
} }
} }
} }
......
...@@ -155,7 +155,7 @@ static void rtu_update_ports_state(void) ...@@ -155,7 +155,7 @@ static void rtu_update_ports_state(void)
int link_up; int link_up;
/* update hal_ports_local_copy */ /* update hal_ports_local_copy */
read_ports(); read_ports();
for (i = 0; i <= MAX_PORT; i++) { for (i = 0; (i <= MAX_PORT) && (i < hal_nports_local); i++) {
if (!hal_ports_local_copy[i].in_use) if (!hal_ports_local_copy[i].in_use)
continue; continue;
...@@ -222,8 +222,8 @@ static int rtu_daemon_learning_process(void) ...@@ -222,8 +222,8 @@ static int rtu_daemon_learning_process(void)
err = rtu_read_learning_queue(&req); err = rtu_read_learning_queue(&req);
if (!err) { if (!err) {
pr_debug( pr_debug(
"ureq: port %d src %s VID %d priority %d\n", "ureq: port %d (wri%d) src %s VID %d priority %d\n",
req.port_id, req.port_id + 1, req.port_id + 1,
mac_to_string(req.src), mac_to_string(req.src),
req.has_vid ? req.vid : 0, req.has_vid ? req.vid : 0,
req.has_prio ? req.prio : 0); req.has_prio ? req.prio : 0);
...@@ -233,7 +233,7 @@ static int rtu_daemon_learning_process(void) ...@@ -233,7 +233,7 @@ static int rtu_daemon_learning_process(void)
if (p->in_use && p->hw_index == req.port_id if (p->in_use && p->hw_index == req.port_id
&& !state_up(p->state)) { && !state_up(p->state)) {
port_down = 1; port_down = 1;
pr_debug("port down %d\n", i); pr_debug("port down %s\n", p->name);
break; break;
} }
} }
......
...@@ -53,7 +53,8 @@ int rtudexp_clear_entries(const struct minipc_pd *pd, ...@@ -53,7 +53,8 @@ int rtudexp_clear_entries(const struct minipc_pd *pd,
int iface_num = (int)args[0]; int iface_num = (int)args[0];
int *p_ret = (int *)ret; //force pointed to int type int *p_ret = (int *)ret; //force pointed to int type
pr_debug("Removing dynamic entries on interface %d\n", iface_num); pr_debug("Removing dynamic entries on interface %d (wri%d)\n",
iface_num + 1, iface_num + 1);
rtu_fd_clear_entries_for_port(iface_num); rtu_fd_clear_entries_for_port(iface_num);
*p_ret = 0; *p_ret = 0;
...@@ -80,8 +81,9 @@ int rtudexp_add_entry(const struct minipc_pd *pd, uint32_t * args, void *ret) ...@@ -80,8 +81,9 @@ int rtudexp_add_entry(const struct minipc_pd *pd, uint32_t * args, void *ret)
"%s is an invalid MAC format (XX:XX:XX:XX:XX:XX)\n", "%s is an invalid MAC format (XX:XX:XX:XX:XX:XX)\n",
strEHA); strEHA);
pr_info("Create entry for (MAC=%s) port %x, mode:%s\n", pr_info("Create entry for (MAC=%s) port %x (wri%d), mode:%s\n",
mac_to_string(mac_tmp), 1 << port, (mode) ? "DYNAMIC" : "STATIC"); mac_to_string(mac_tmp), 1 << port, port + 1,
(mode) ? "DYNAMIC" : "STATIC");
*p_ret = *p_ret =
rtu_fd_create_entry(mac_tmp, 0, 1 << port, mode, OVERRIDE_EXISTING); rtu_fd_create_entry(mac_tmp, 0, 1 << port, mode, OVERRIDE_EXISTING);
return *p_ret; return *p_ret;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment