Commit 9cff3a5e authored by Adam Wujek's avatar Adam Wujek

Uplift PPSI to version used in WRS v6.0 and changes needed by it

parents 6be7212f 8bb551e9
Pipeline #3233 failed with stage
in 0 seconds
...@@ -57,13 +57,14 @@ config STACKSIZE ...@@ -57,13 +57,14 @@ config STACKSIZE
config PRINT_BUFSIZE config PRINT_BUFSIZE
int int
default 128 default CUSTOM_PRINT_BUFSIZE if DEVELOPER
default 256
config RAMSIZE config RAMSIZE
int int
default 65536 if TARGET_WR_SWITCH default 65536 if TARGET_WR_SWITCH
default 196608 if TARGET_ERTM14 default 196608 if TARGET_ERTM14
default 131072 default 196608
config TEMP_POLL_INTERVAL config TEMP_POLL_INTERVAL
int int
...@@ -218,20 +219,33 @@ config SNMP_SET ...@@ -218,20 +219,33 @@ config SNMP_SET
This option enables support for SET requests for Mini SNMP responder This option enables support for SET requests for Mini SNMP responder
config SNMP_INIT config SNMP_INIT
depends on SNMP && BUILD_INIT depends on SNMP && SNMP_SET && FLASH_INIT
default y if BUILD_INIT default y
default n
boolean "Adds support of changing init script/commands via SNMP" boolean "Adds support of changing init script/commands via SNMP"
help help
This option adds a branch wrpcInitScriptConfigGroup to the SNMP This option adds a branch wrpcInitScriptConfigGroup to the SNMP
config SNMP_SDB config SNMP_SDB
depends on SNMP && GENSDBFS depends on SNMP && SNMP_SET && GENSDBFS
default y default y
boolean "Adds support of generation of SDB via SNMP" boolean "Adds support of generation of SDB via SNMP"
help help
This option adds a branch wrpcSdbGroup to the SNMP This option adds a branch wrpcSdbGroup to the SNMP
config SNMP_CMD
depends on SNMP && SNMP_SET
default y
boolean "Allow to run any shell command via SNMP"
help
This option adds a branch wrpcShellCmdGroup to the SNMP
config SNMP_NETCONSOLE
depends on SNMP && NETCONSOLE
default y
boolean "Adds support of enabling/disabling netconsole via SNMP"
help
This option adds a branch wrpcNetconsoleGroup to the SNMP
config SNMP_AUX_DIAG config SNMP_AUX_DIAG
depends on SNMP && AUX_DIAG depends on SNMP && AUX_DIAG
default y if AUX_DIAG default y if AUX_DIAG
...@@ -363,6 +377,53 @@ config LLDP ...@@ -363,6 +377,53 @@ config LLDP
used by network devices for advertising their identity, capabilities, used by network devices for advertising their identity, capabilities,
and neighbors on local area network. and neighbors on local area network.
config CMD_PPS
depends on WR_NODE
boolean "Include PPS command"
default n
help
This enables pps command, which can be used to force PPS output
all the time for all clock classes.
config CMD_LEAPSEC
depends on WR_NODE
boolean "Include command to control leapsecond value"
default n
help
This enables leapsec command, which can be used to adjust leap seconds
value.
config NETCONSOLE
depends on WR_NODE && IP && !NET_VERBOSE
boolean "Include netconsole via UDP"
default y
help
Include netconsole to be run via UDP
choice
prompt "Default mode of netconsole"
depends on NETCONSOLE
default NETCONSOLE_DEF_DISABLE
config NETCONSOLE_DEF_WAIT
boolean "Netconsole is waiting for peer"
help
Netconsole is waiting for peer to send a command
config NETCONSOLE_DEF_DISABLE
boolean "Netconsole is disabled"
help
Use SNMP or shell command to enable netconsole
endchoice
config CMD_NETCONSOLE
depends on NETCONSOLE
boolean "Include shell command to configure netconsole"
default y
help
Include command to configure netconsole
# #
# This is a set of configuration options that should not be changed by # This is a set of configuration options that should not be changed by
# normal users. If the "developer" menu is used, the binary is tainted. # normal users. If the "developer" menu is used, the binary is tainted.
...@@ -487,7 +548,7 @@ config CUSTOM_STACKSIZE ...@@ -487,7 +548,7 @@ config CUSTOM_STACKSIZE
config CUSTOM_PRINT_BUFSIZE config CUSTOM_PRINT_BUFSIZE
depends on DEVELOPER depends on DEVELOPER
int "Size for the temporary output string of pp_printf" int "Size for the temporary output string of pp_printf"
default 128 default 256
help help
This buffer is constant storage (i.e. wasted space), but it This buffer is constant storage (i.e. wasted space), but it
also constraints the maximum lenght of text that can be written also constraints the maximum lenght of text that can be written
...@@ -550,6 +611,7 @@ config SPLL_FIFO_LOG ...@@ -550,6 +611,7 @@ config SPLL_FIFO_LOG
choice choice
prompt "Implementation of pp_printf" prompt "Implementation of pp_printf"
depends on DEVELOPER depends on DEVELOPER
default PRINTF_IS_FULL if EMBEDDED_NODE
config PRINTF_IS_XINT config PRINTF_IS_XINT
bool "hex-and-int" bool "hex-and-int"
...@@ -688,12 +750,12 @@ config VLAN_ARRAY_SIZE ...@@ -688,12 +750,12 @@ config VLAN_ARRAY_SIZE
################# helper configuration items ############# ################# helper configuration items #############
config PRINTF_XINT config PRINTF_XINT
boolean boolean
default PRINTF_IS_XINT if (DEVELOPER && WR_NODE) default PRINTF_IS_XINT
default y
config PRINTF_FULL config PRINTF_FULL
boolean boolean
default PRINTF_IS_FULL default PRINTF_IS_FULL if (DEVELOPER && WR_NODE)
default y
config PRINTF_MINI config PRINTF_MINI
boolean boolean
......
...@@ -18,6 +18,10 @@ SIZE = $(CROSS_COMPILE)size ...@@ -18,6 +18,10 @@ SIZE = $(CROSS_COMPILE)size
AUTOCONF = $(CURDIR)/include/generated/autoconf.h AUTOCONF = $(CURDIR)/include/generated/autoconf.h
AUTOCONF_PPSI = $(CURDIR)/ppsi/include/generated/autoconf.h
export AUTOCONF
export AUTOCONF_PPSI
PPSI = ppsi PPSI = ppsi
...@@ -34,7 +38,7 @@ obj-$(CONFIG_WR_NODE) += wrc_main.o ...@@ -34,7 +38,7 @@ obj-$(CONFIG_WR_NODE) += wrc_main.o
obj-$(CONFIG_WR_NODE_SIM) += wrc_main_sim.o obj-$(CONFIG_WR_NODE_SIM) += wrc_main_sim.o
obj-$(CONFIG_TARGET_WR_SWITCH) += ipc/minipc-mem-server.o ipc/rt_ipc.o obj-$(CONFIG_TARGET_WR_SWITCH) += ipc/minipc-mem-server.o ipc/rt_ipc.o
obj-y += dump-info.o obj-$(CONFIG-PPSI) += dump-info.o
# our linker script is preprocessed, so have a rule here # our linker script is preprocessed, so have a rule here
%.ld: %.ld.S $(AUTOCONF) .config %.ld: %.ld.S $(AUTOCONF) .config
$(CC) -include $(AUTOCONF) -E -P $*.ld.S -o $@ $(CC) -include $(AUTOCONF) -E -P $*.ld.S -o $@
...@@ -203,6 +207,22 @@ pconfig.o: ppsi/.config ...@@ -203,6 +207,22 @@ pconfig.o: ppsi/.config
$(AUTOCONF): silentoldconfig gitmodules $(AUTOCONF): silentoldconfig gitmodules
$(AUTOCONF_PPSI): $(obj-ppsi)
AUTOCONF_PPSI-$(CONFIG_PPSI) = $(AUTOCONF_PPSI)
# below have dependency on $(AUTOCONF_PPSI) file
REQUIRE_AUTOCONF_PPSI+= \
monitor/monitor_ppsi.o \
dump-info.o \
wrc_main.o \
# some files require $(AUTOCONF_PPSI) to be present before build
$(REQUIRE_AUTOCONF_PPSI): $(AUTOCONF_PPSI)
# and wants to include $(AUTOCONF_PPSI) during the build
$(REQUIRE_AUTOCONF_PPSI): CFLAGS+=-include $(AUTOCONF_PPSI)
clean: clean:
rm -f $(OBJS) config.o pconfig.o revision.o $(OUTPUT).elf \ rm -f $(OBJS) config.o pconfig.o revision.o $(OUTPUT).elf \
$(LDS) \ $(LDS) \
...@@ -229,7 +249,7 @@ liblinux: ...@@ -229,7 +249,7 @@ liblinux:
extest: extest:
$(MAKE) -C liblinux/extest CC=cc $(MAKE) -C liblinux/extest CC=cc
tools: .config gitmodules liblinux extest tools: .config gitmodules liblinux extest $(AUTOCONF_PPSI-y)
$(MAKE) -C tools $(MAKE) -C tools
tools-diag: liblinux extest tools-diag: liblinux extest
......
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
*/ */
#define __ASSEMBLY__ #define __ASSEMBLY__
#include "include/revision.h" #include "include/revision.h"
#include "ppsi/proto-ext-whiterabbit/wr-api.h" #include "ppsi/include/hw-specific/wrh.h"
#include "arch/lm32/crt0.h" #include "arch/lm32/crt0.h"
#include "include/generated/autoconf.h" #include "include/generated/autoconf.h"
/* From include/sys/signal.h */ /* From include/sys/signal.h */
...@@ -119,8 +119,10 @@ _true_reset: ...@@ -119,8 +119,10 @@ _true_reset:
.word softpll .word softpll
.org FIFO_LOG_PADDR .org FIFO_LOG_PADDR
.word fifo_log .word fifo_log
.org PPI_STATIC_PADDR #ifdef CONFIG_PPSI
.word ppi_static .org PPG_STATIC_PADDR
.word ppg_static
#endif
.org STATS_PADDR .org STATS_PADDR
.word stats .word stats
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#define WRPC_MARK 0x80 #define WRPC_MARK 0x80
#define SOFTPLL_PADDR 0x90 #define SOFTPLL_PADDR 0x90
#define FIFO_LOG_PADDR 0x94 #define FIFO_LOG_PADDR 0x94
#define PPI_STATIC_PADDR 0x98 #define PPG_STATIC_PADDR 0x98
#define STATS_PADDR 0x9c #define STATS_PADDR 0x9c
#define UPTIME_SEC_ADDR 0xa0 #define UPTIME_SEC_ADDR 0xa0
#define VERSION_WRPC_ADDR 0xa4 #define VERSION_WRPC_ADDR 0xa4
......
...@@ -3,6 +3,9 @@ ...@@ -3,6 +3,9 @@
* *
* Released according to the GNU GPL, version 2 or any later version. * Released according to the GNU GPL, version 2 or any later version.
*/ */
#include <netconsole.h>
#ifndef __BOARD_WRC_H #ifndef __BOARD_WRC_H
#define __BOARD_WRC_H #define __BOARD_WRC_H
/* /*
...@@ -59,9 +62,9 @@ ...@@ -59,9 +62,9 @@
#define BOARD_MAX_CHAN_AUX 2 #define BOARD_MAX_CHAN_AUX 2
#define BOARD_MAX_PTRACKERS 1 #define BOARD_MAX_PTRACKERS 1
#define CONFIG_DISALLOW_LONG_DIVISION #undef CONFIG_DISALLOW_LONG_DIVISION
#define BOARD_MAX_CONSOLE_DEVICES 1 #define BOARD_MAX_CONSOLE_DEVICES (1 + HAS_NETCONSOLE)
#define CONSOLE_UART_BAUDRATE 115200 #define CONSOLE_UART_BAUDRATE 115200
......
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
#define BOARD_MAX_CHAN_AUX 2 #define BOARD_MAX_CHAN_AUX 2
#define BOARD_MAX_PTRACKERS 1 #define BOARD_MAX_PTRACKERS 1
#define CONFIG_DISALLOW_LONG_DIVISION #undef CONFIG_DISALLOW_LONG_DIVISION
#define BOARD_MAX_CONSOLE_DEVICES 1 #define BOARD_MAX_CONSOLE_DEVICES 1
......
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
#define BOARD_MAX_CHAN_AUX 2 #define BOARD_MAX_CHAN_AUX 2
#define BOARD_MAX_PTRACKERS 1 #define BOARD_MAX_PTRACKERS 1
#define CONFIG_DISALLOW_LONG_DIVISION #undef CONFIG_DISALLOW_LONG_DIVISION
#define BOARD_MAX_CONSOLE_DEVICES 1 #define BOARD_MAX_CONSOLE_DEVICES 1
......
...@@ -67,8 +67,8 @@ CONFIG_FAKE_TEMPERATURES=y ...@@ -67,8 +67,8 @@ CONFIG_FAKE_TEMPERATURES=y
CONFIG_LATENCY_PROBE=y CONFIG_LATENCY_PROBE=y
CONFIG_DEFAULT_PRINT_TASK_TIME_THRESHOLD=0 CONFIG_DEFAULT_PRINT_TASK_TIME_THRESHOLD=0
CONFIG_VLAN_ARRAY_SIZE=1 CONFIG_VLAN_ARRAY_SIZE=1
CONFIG_PRINTF_XINT=y # CONFIG_PRINTF_XINT is not set
# CONFIG_PRINTF_FULL is not set CONFIG_PRINTF_FULL=y
# CONFIG_PRINTF_MINI is not set # CONFIG_PRINTF_MINI is not set
# CONFIG_PRINTF_NONE is not set # CONFIG_PRINTF_NONE is not set
# CONFIG_LLDP is not set # CONFIG_LLDP is not set
...@@ -65,8 +65,8 @@ CONFIG_PRINTF_IS_XINT=y ...@@ -65,8 +65,8 @@ CONFIG_PRINTF_IS_XINT=y
CONFIG_LATENCY_PROBE=y CONFIG_LATENCY_PROBE=y
CONFIG_DEFAULT_PRINT_TASK_TIME_THRESHOLD=0 CONFIG_DEFAULT_PRINT_TASK_TIME_THRESHOLD=0
CONFIG_VLAN_ARRAY_SIZE=1 CONFIG_VLAN_ARRAY_SIZE=1
CONFIG_PRINTF_XINT=y # CONFIG_PRINTF_XINT is not set
# CONFIG_PRINTF_FULL is not set CONFIG_PRINTF_FULL=y
# CONFIG_PRINTF_MINI is not set # CONFIG_PRINTF_MINI is not set
# CONFIG_PRINTF_NONE is not set # CONFIG_PRINTF_NONE is not set
# CONFIG_LLDP is not set # CONFIG_LLDP is not set
...@@ -65,8 +65,8 @@ CONFIG_PRINTF_IS_XINT=y ...@@ -65,8 +65,8 @@ CONFIG_PRINTF_IS_XINT=y
CONFIG_LATENCY_PROBE=y CONFIG_LATENCY_PROBE=y
CONFIG_DEFAULT_PRINT_TASK_TIME_THRESHOLD=0 CONFIG_DEFAULT_PRINT_TASK_TIME_THRESHOLD=0
CONFIG_VLAN_ARRAY_SIZE=1 CONFIG_VLAN_ARRAY_SIZE=1
CONFIG_PRINTF_XINT=y # CONFIG_PRINTF_XINT is not set
# CONFIG_PRINTF_FULL is not set CONFIG_PRINTF_FULL=y
# CONFIG_PRINTF_MINI is not set # CONFIG_PRINTF_MINI is not set
# CONFIG_PRINTF_NONE is not set # CONFIG_PRINTF_NONE is not set
# CONFIG_LLDP is not set # CONFIG_LLDP is not set
...@@ -83,7 +83,7 @@ CONFIG_ASSERT=y ...@@ -83,7 +83,7 @@ CONFIG_ASSERT=y
# CONFIG_LATENCY_PROBE is not set # CONFIG_LATENCY_PROBE is not set
CONFIG_DEFAULT_PRINT_TASK_TIME_THRESHOLD=0 CONFIG_DEFAULT_PRINT_TASK_TIME_THRESHOLD=0
CONFIG_VLAN_ARRAY_SIZE=1 CONFIG_VLAN_ARRAY_SIZE=1
CONFIG_PRINTF_XINT=y # CONFIG_PRINTF_XINT is not set
# CONFIG_PRINTF_FULL is not set CONFIG_PRINTF_FULL=y
# CONFIG_PRINTF_MINI is not set # CONFIG_PRINTF_MINI is not set
# CONFIG_PRINTF_NONE is not set # CONFIG_PRINTF_NONE is not set
...@@ -49,7 +49,7 @@ CONFIG_LLDP=y ...@@ -49,7 +49,7 @@ CONFIG_LLDP=y
# #
# CONFIG_DEVELOPER is not set # CONFIG_DEVELOPER is not set
CONFIG_VLAN_ARRAY_SIZE=1 CONFIG_VLAN_ARRAY_SIZE=1
CONFIG_PRINTF_XINT=y # CONFIG_PRINTF_XINT is not set
# CONFIG_PRINTF_FULL is not set CONFIG_PRINTF_FULL=y
# CONFIG_PRINTF_MINI is not set # CONFIG_PRINTF_MINI is not set
# CONFIG_PRINTF_NONE is not set # CONFIG_PRINTF_NONE is not set
...@@ -49,7 +49,7 @@ CONFIG_LLDP=y ...@@ -49,7 +49,7 @@ CONFIG_LLDP=y
# #
# CONFIG_DEVELOPER is not set # CONFIG_DEVELOPER is not set
CONFIG_VLAN_ARRAY_SIZE=1 CONFIG_VLAN_ARRAY_SIZE=1
CONFIG_PRINTF_XINT=y # CONFIG_PRINTF_XINT is not set
# CONFIG_PRINTF_FULL is not set CONFIG_PRINTF_FULL=y
# CONFIG_PRINTF_MINI is not set # CONFIG_PRINTF_MINI is not set
# CONFIG_PRINTF_NONE is not set # CONFIG_PRINTF_NONE is not set
...@@ -44,7 +44,7 @@ CONFIG_ABSCAL=y ...@@ -44,7 +44,7 @@ CONFIG_ABSCAL=y
# #
# CONFIG_DEVELOPER is not set # CONFIG_DEVELOPER is not set
CONFIG_VLAN_ARRAY_SIZE=1 CONFIG_VLAN_ARRAY_SIZE=1
CONFIG_PRINTF_XINT=y # CONFIG_PRINTF_XINT is not set
# CONFIG_PRINTF_FULL is not set CONFIG_PRINTF_FULL=y
# CONFIG_PRINTF_MINI is not set # CONFIG_PRINTF_MINI is not set
# CONFIG_PRINTF_NONE is not set # CONFIG_PRINTF_NONE is not set
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "board.h" #include "board.h"
#include "dev/simple_uart.h" #include "dev/simple_uart.h"
#include "dev/console.h" #include "dev/console.h"
#include <netconsole.h>
static int puts_direct = 0; static int puts_direct = 0;
...@@ -30,6 +31,7 @@ struct console_uart_priv_data ...@@ -30,6 +31,7 @@ struct console_uart_priv_data
static struct console_uart_priv_data console_uart_priv; static struct console_uart_priv_data console_uart_priv;
struct console_device console_uart_dev; struct console_device console_uart_dev;
struct console_device* console_devs[BOARD_MAX_CONSOLE_DEVICES]; struct console_device* console_devs[BOARD_MAX_CONSOLE_DEVICES];
static struct console_device console_netconsole_dev;
#define CON_ESCAPE_CODE 0x1b #define CON_ESCAPE_CODE 0x1b
#define CON_SWITCH_BINARY_CODE 'B' #define CON_SWITCH_BINARY_CODE 'B'
...@@ -271,6 +273,23 @@ void console_ipmi_init( ) ...@@ -271,6 +273,23 @@ void console_ipmi_init( )
#endif #endif
static int con_netconsole_getc(struct console_device* dev)
{
return netconsole_read_byte();
}
static int con_netconsole_put_string(struct console_device* dev, const char *s)
{
return netconsole_write_string(s);
}
static void console_netconsole_init(void)
{
console_netconsole_dev.get_char = con_netconsole_getc;
console_netconsole_dev.put_string = con_netconsole_put_string;
console_register_device( &console_netconsole_dev );
}
int puts(const char *s) int puts(const char *s)
{ {
if( puts_direct) if( puts_direct)
...@@ -334,6 +353,9 @@ void console_init() ...@@ -334,6 +353,9 @@ void console_init()
console_ipmi_init(); console_ipmi_init();
#endif #endif
if (HAS_NETCONSOLE)
console_netconsole_init();
pp_printf("Console UART FIFO:: %d\n", suart_is_fifo_supported( &console_uart_priv.uart_dev ) ); pp_printf("Console UART FIFO:: %d\n", suart_is_fifo_supported( &console_uart_priv.uart_dev ) );
} }
......
...@@ -58,6 +58,10 @@ dev/ep_pfilter.o: $(pfilter-y) ...@@ -58,6 +58,10 @@ dev/ep_pfilter.o: $(pfilter-y)
dev/storage.o: $(sdbfsimg-y) dev/storage.o: $(sdbfsimg-y)
# below have dependency on $(AUTOCONF_PPSI) file
REQUIRE_AUTOCONF_PPSI += \
dev/minic.o \
$(pfilter-y): tools $(pfilter-y): tools
./tools/pfilter-builder include/generated/ ./tools/pfilter-builder include/generated/
......
...@@ -25,13 +25,13 @@ ...@@ -25,13 +25,13 @@
* ---------------------------------------------- * ----------------------------------------------
* | cal_ph_trans (4B) | SFP count (1B) | * | cal_ph_trans (4B) | SFP count (1B) |
* -------------------------------------------------------------------------------------------- * --------------------------------------------------------------------------------------------
* | SFP(1) part number (16B) | alpha (4B) | deltaTx (4B) | deltaRx (4B) | chksum(1B) | * | SFP(1) part number (16B) | alpha (8B) | deltaTx (4B) | deltaRx (4B) | chksum(1B) |
* -------------------------------------------------------------------------------------------- * --------------------------------------------------------------------------------------------
* | SFP(2) part number (16B) | alpha (4B) | deltaTx (4B) | deltaRx (4B) | chksum(1B) | * | SFP(2) part number (16B) | alpha (8B) | deltaTx (4B) | deltaRx (4B) | chksum(1B) |
* -------------------------------------------------------------------------------------------- * --------------------------------------------------------------------------------------------
* | (....) | (....) | (....) | (....) | (...) | * | (....) | (....) | (....) | (....) | (...) |
* -------------------------------------------------------------------------------------------- * --------------------------------------------------------------------------------------------
* | SFP(count) part number (16B) | alpha (4B) | deltaTx (4B) | deltaRx (4B) | chksum(1B) | * | SFP(count) part number (16B) | alpha (8B) | deltaTx (4B) | deltaRx (4B) | chksum(1B) |
* -------------------------------------------------------------------------------------------- * --------------------------------------------------------------------------------------------
* *
* Fields description: * Fields description:
......
...@@ -176,35 +176,12 @@ int ep_get_bitslide(struct wr_endpoint_device* dev) ...@@ -176,35 +176,12 @@ int ep_get_bitslide(struct wr_endpoint_device* dev)
} }
/* Returns the TX/RX latencies. They are valid only when the link is up. */ /* Returns the TX/RX latencies. They are valid only when the link is up. */
int ep_get_deltas(struct wr_endpoint_device* dev, uint32_t * delta_tx, uint32_t * delta_rx) int ep_get_deltas(struct wr_endpoint_device* dev, int *delta_tx, int *delta_rx)
{ {
/* fixme: these values should be stored in calibration block in the EEPROM on the FMC. Also, the TX/RX delays of a particular SFP /* fixme: these values should be stored in calibration block in the EEPROM on the FMC. Also, the TX/RX delays of a particular SFP
should be added here */ should be added here */
*delta_tx = sfp_deltaTx; *delta_tx = sfp_deltaTx;
*delta_rx = *delta_rx = sfp_deltaRx;
sfp_deltaRx +
PICOS_PER_SERIAL_BIT *
MDIO_WR_SPEC_BSLIDE_R(ep_pcs_read(dev, MDIO_REG_WR_SPEC));
return 0;
}
int ep_cal_pattern_enable(struct wr_endpoint_device* dev)
{
uint32_t val;
val = ep_pcs_read(dev, MDIO_REG_WR_SPEC);
val |= MDIO_WR_SPEC_TX_CAL;
ep_pcs_write(dev, MDIO_REG_WR_SPEC, val);
return 0;
}
int ep_cal_pattern_disable(struct wr_endpoint_device* dev)
{
uint32_t val;
val = ep_pcs_read(dev, MDIO_REG_WR_SPEC);
val &= (~MDIO_WR_SPEC_TX_CAL);
ep_pcs_write(dev, MDIO_REG_WR_SPEC, val);
return 0; return 0;
} }
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include "storage.h" #include "storage.h"
/* Calibration data (from EEPROM if available) */ /* Calibration data (from EEPROM if available) */
int32_t sfp_alpha = 73622176; /* default values if could not read EEPROM */ int64_t sfp_alpha = 1235332333756144; /* def values if could not read EEPROM */
int32_t sfp_deltaTx = 0; int32_t sfp_deltaTx = 0;
int32_t sfp_deltaRx = 0; int32_t sfp_deltaRx = 0;
int32_t sfp_in_db = 0; int32_t sfp_in_db = 0;
......
...@@ -48,6 +48,7 @@ void suart_write_byte(struct simple_uart_device *dev, int b) ...@@ -48,6 +48,7 @@ void suart_write_byte(struct simple_uart_device *dev, int b)
int suart_write_string(struct simple_uart_device *dev, const char *s) int suart_write_string(struct simple_uart_device *dev, const char *s)
{ {
const char *t = s; const char *t = s;
while (*s) while (*s)
suart_write_byte(dev, *(s++)); suart_write_byte(dev, *(s++));
return s - t; return s - t;
......
...@@ -460,12 +460,12 @@ int set_persistent_mac(uint8_t portnum, uint8_t *mac) ...@@ -460,12 +460,12 @@ int set_persistent_mac(uint8_t portnum, uint8_t *mac)
* For each sfp we have * For each sfp we have
* *
* - part number (16 bytes) * - part number (16 bytes)
* - alpha (4 bytes) * - alpha (8 bytes)
* - deltaTx (4 bytes) * - deltaTx (4 bytes)
* - delta Rx (4 bytes) * - delta Rx (4 bytes)
* - checksum (1 byte) (low order 8 bits of the sum of all bytes) * - checksum (1 byte) (low order 8 bits of the sum of all bytes)
* *
* the total is 29 bytes for each sfp (ugly, but we are byte-oriented anyways * the total is 33 bytes for each sfp (ugly, but we are byte-oriented anyways
*/ */
......
This diff is collapsed.
doc/wrpc_mon.png

171 KB | W: | H:

doc/wrpc_mon.png

90.2 KB | W: | H:

doc/wrpc_mon.png
doc/wrpc_mon.png
doc/wrpc_mon.png
doc/wrpc_mon.png
  • 2-up
  • Swipe
  • Onion skin
This diff is collapsed.
...@@ -24,6 +24,9 @@ extern void __assert(const char *func, int line, int forever, ...@@ -24,6 +24,9 @@ extern void __assert(const char *func, int line, int forever,
const char *fmt, ...) const char *fmt, ...)
__attribute__((format(printf, 4, 5))); __attribute__((format(printf, 4, 5)));
/* PPSi's dot-config also has the same option in dot-config as WRPC,
* undefine it to avoid conflicts */
#undef CONFIG_HAS_ASSERT
#ifdef CONFIG_ASSERT #ifdef CONFIG_ASSERT
# define CONFIG_HAS_ASSERT 1 # define CONFIG_HAS_ASSERT 1
#else #else
......
...@@ -47,9 +47,7 @@ int ep_is_mac_addr_set(struct wr_endpoint_device* dev); ...@@ -47,9 +47,7 @@ int ep_is_mac_addr_set(struct wr_endpoint_device* dev);
int ep_enable(struct wr_endpoint_device* dev, int enabled, int autoneg); int ep_enable(struct wr_endpoint_device* dev, int enabled, int autoneg);
int ep_link_up(struct wr_endpoint_device* dev, uint16_t * lpa); int ep_link_up(struct wr_endpoint_device* dev, uint16_t * lpa);
int ep_get_bitslide(struct wr_endpoint_device* dev); int ep_get_bitslide(struct wr_endpoint_device* dev);
int ep_get_deltas(struct wr_endpoint_device* dev,uint32_t * delta_tx, uint32_t * delta_rx); int ep_get_deltas(struct wr_endpoint_device *dev, int *delta_tx, int *delta_rx);
int ep_cal_pattern_enable(struct wr_endpoint_device* dev);
int ep_cal_pattern_disable(struct wr_endpoint_device* dev);
int ep_timestamper_cal_pulse(struct wr_endpoint_device* dev); int ep_timestamper_cal_pulse(struct wr_endpoint_device* dev);
int ep_sfp_enable(struct wr_endpoint_device* dev, int ena); int ep_sfp_enable(struct wr_endpoint_device* dev, int ena);
......
...@@ -19,6 +19,7 @@ enum dump_type { ...@@ -19,6 +19,7 @@ enum dump_type {
dump_type_uint32_t, dump_type_uint32_t,
dump_type_uint16_t, dump_type_uint16_t,
dump_type_int, dump_type_int,
dump_type_long_long,
dump_type_unsigned_long, dump_type_unsigned_long,
dump_type_unsigned_char, dump_type_unsigned_char,
dump_type_unsigned_short, dump_type_unsigned_short,
...@@ -35,22 +36,71 @@ enum dump_type { ...@@ -35,22 +36,71 @@ enum dump_type {
dump_type_UInteger8, dump_type_UInteger8,
dump_type_Integer8, dump_type_Integer8,
dump_type_Enumeration8, dump_type_Enumeration8,
dump_type_UInteger4,
dump_type_Boolean, dump_type_Boolean,
dump_type_ClockIdentity, dump_type_ClockIdentity,
dump_type_PortIdentity, dump_type_PortIdentity,
dump_type_ClockQuality, dump_type_ClockQuality,
dump_type_TimeInterval,
dump_type_RelativeDifference,
dump_type_FixedDelta,
dump_type_dummy,
/* and this is ours */ /* and this is ours */
dump_type_yes_no,
dump_type_yes_no_Boolean,
dump_type_spll_mode,
dump_type_pp_time, dump_type_pp_time,
dump_type_ip_address, dump_type_ip_address,
dump_type_delay_mechanism,
dump_type_protocol_extension,
dump_type_wrpc_mode_cfg,
dump_type_timing_mode,
dump_type_ppi_state,
dump_type_ppi_state_Enumeration8,
dump_type_wr_config,
dump_type_wr_config_Enumeration8,
dump_type_wr_role,
dump_type_wr_role_Enumeration8,
dump_type_pp_pdstate,
dump_type_exstate,
dump_type_pp_servo_flag,
dump_type_pp_servo_state,
dump_type_wr_state,
dump_type_ppi_profile,
dump_type_ppi_proto,
dump_type_ppi_flag,
}; };
/* because of the sizeof later on, we need these typedefs */ /* because of the sizeof later on, we need these typedefs */
typedef void * pointer; typedef void * pointer;
typedef struct pp_time pp_time; typedef struct pp_time pp_time;
typedef long long long_long;
typedef unsigned long unsigned_long; typedef unsigned long unsigned_long;
typedef unsigned char unsigned_char; typedef unsigned char unsigned_char;
typedef unsigned short unsigned_short; typedef unsigned short unsigned_short;
typedef uint8_t dummy; /* use the smallest */
typedef struct {unsigned char addr[4];} ip_address; typedef struct {unsigned char addr[4];} ip_address;
typedef Boolean yes_no_Boolean;
typedef uint8_t yes_no;
typedef int spll_mode;
typedef int delay_mechanism;
typedef int protocol_extension;
typedef wrh_timing_mode_t timing_mode;
typedef int wrpc_mode_cfg;
typedef int ppi_state;
typedef Enumeration8 ppi_state_Enumeration8;
typedef int wr_config;
typedef Enumeration8 wr_config_Enumeration8;
typedef int wr_role;
typedef Enumeration8 wr_role_Enumeration8;
typedef pp_pdstate_t pp_pdstate;
typedef pp_exstate_t exstate;
typedef unsigned long pp_servo_flag;
typedef int pp_servo_state;
typedef wr_state_t wr_state;
typedef int ppi_profile;
typedef int ppi_proto;
typedef unsigned char ppi_flag;
/* /*
* This is generated with the target compiler, and then linked * This is generated with the target compiler, and then linked
...@@ -64,7 +114,7 @@ struct dump_info { ...@@ -64,7 +114,7 @@ struct dump_info {
uint32_t type; uint32_t type;
uint32_t offset; uint32_t offset;
uint32_t size; uint32_t size;
char name[48]; char name[60];
}; };
extern struct dump_info dump_info[]; /* wrpc-sw/dump-info.c -> bina -> elf */ extern struct dump_info dump_info[]; /* wrpc-sw/dump-info.c -> bina -> elf */
......
...@@ -39,6 +39,9 @@ typedef struct hal_port_calibration { ...@@ -39,6 +39,9 @@ typedef struct hal_port_calibration {
uint32_t delta_tx_phy; uint32_t delta_tx_phy;
uint32_t delta_rx_phy; uint32_t delta_rx_phy;
/* bit slide expressed in picos */
uint32_t bitslide_ps;
/* Current board routing delays (between the DDMTD inputs to /* Current board routing delays (between the DDMTD inputs to
the PHY clock inputs/outputs), in picoseconds */ the PHY clock inputs/outputs), in picoseconds */
uint32_t delta_tx_board; uint32_t delta_tx_board;
......
/*
* This work is part of the White Rabbit project
*
* Released according to the GNU GPL, version 2 or any later version.
*/
#ifndef __LIBWR_SHW_SFPLIB_H #ifndef __LIBWR_SHW_SFPLIB_H
#define __LIBWR_SHW_SFPLIB_H #define __LIBWR_SHW_SFPLIB_H
#define SFP_LED_LINK (1 << 0) /* note each led contains green and orange part */
#define SFP_LED_WRMODE (1 << 1) #define SFP_LED_WRMODE1 (1 << 0)
#define SFP_LED_WRMODE2 (1 << 1)
#define SFP_LED_SYNCED (1 << 2) #define SFP_LED_SYNCED (1 << 2)
#define SFP_TX_DISABLE (1 << 3) #define SFP_TX_DISABLE (1 << 3)
#define shw_sfp_set_led_link(num, status) \
shw_sfp_set_generic(num, status, SFP_LED_LINK)
#define shw_sfp_set_led_wrmode(num, status) \
shw_sfp_set_generic(num, status, SFP_LED_WRMODE)
#define shw_sfp_set_led_synced(num, status) \ #define shw_sfp_set_led_synced(num, status) \
shw_sfp_set_generic(num, status, SFP_LED_SYNCED) shw_sfp_set_generic(num, status, SFP_LED_SYNCED)
...@@ -25,14 +15,36 @@ ...@@ -25,14 +15,36 @@
#define SFP_FLAG_CLASS_DATA (1 << 0) #define SFP_FLAG_CLASS_DATA (1 << 0)
#define SFP_FLAG_DEVICE_DATA (1 << 1) #define SFP_FLAG_DEVICE_DATA (1 << 1)
#define SFP_FLAG_1GbE (1 << 2) /* SFP is 1GbE */
#define SFP_FLAG_IN_DB (1 << 3) /* SFP is present in data base */
#define SFP_SPEED_1Gb 0x0D /* Speed of SFP in 100MB/s. According to
* SFF-8472.PDF: By convention 1.25 Gb/s
* should be rounded up to 0Dh (13 in
* units of 100 MBd) for Ethernet
* 1000BASE-X. */
#define SFP_SPEED_1Gb_10 0x0A /* Unfortunatelly the above is not always true,
* e.g. Cisco copper SFP (MGBT1) says simply 10 and not 13.*/
#define SFP_SPEED_1Gb_12 0x0C /* Some fiber SFPs say 12 and not 13 */
#define SFP_DIAGNOSTIC_IMPLEMENTED (1 << 6) /* Digital diagnostic monitoring
implemented. "1" for compliance
with SFF-8472 */
#define SFP_ADDR_CHANGE_REQ (1 << 2) /* Bit 2 indicates whether or not it is
necessary for the host to perform an
address change sequence before
accessing information at 2-wire serial
address A2h. */
struct shw_sfp_caldata { struct shw_sfp_caldata {
int flags; uint32_t flags;
/* /*
* Part number used to identify it. Serial number because we * Part number used to identify it. Serial number because we
* may specify per-specimen delays, but it is not used at this * may specify per-specimen delays, but it is not used at this
* point in time * point in time
*/ */
char vendor_name[16];
char part_num[16]; char part_num[16];
char vendor_serial[16]; char vendor_serial[16];
/* Callibration data */ /* Callibration data */
...@@ -59,13 +71,14 @@ struct shw_sfp_header { ...@@ -59,13 +71,14 @@ struct shw_sfp_header {
uint8_t length3; /* Link length supported for 50/125 mm fiber (10m) */ uint8_t length3; /* Link length supported for 50/125 mm fiber (10m) */
uint8_t length4; /* Link length supported for 62.5/125 mm fiber (10m) */ uint8_t length4; /* Link length supported for 62.5/125 mm fiber (10m) */
uint8_t length5; /* Link length supported for copper (1m) */ uint8_t length5; /* Link length supported for copper (1m) */
uint8_t reserved2; uint8_t length6; /* Link length supported on OM3 (1m) */
uint8_t vendor_name[16]; uint8_t vendor_name[16];
uint8_t reserved3; uint8_t reserved3; /* This is now a field named transceiver */
uint8_t vendor_oui[3]; uint8_t vendor_oui[3];
uint8_t vendor_pn[16]; uint8_t vendor_pn[16];
uint8_t vendor_rev[4]; uint8_t vendor_rev[4];
uint8_t reserved4[3]; uint8_t tx_wavelength[2];
uint8_t reserved4;
uint8_t cc_base; uint8_t cc_base;
/* extended ID fields start here */ /* extended ID fields start here */
...@@ -74,10 +87,73 @@ struct shw_sfp_header { ...@@ -74,10 +87,73 @@ struct shw_sfp_header {
uint8_t br_min; uint8_t br_min;
uint8_t vendor_serial[16]; uint8_t vendor_serial[16];
uint8_t date_code[8]; uint8_t date_code[8];
uint8_t reserved[3]; uint8_t diagnostic_monitoring_type;
uint8_t enhanced_options;
uint8_t sff_8472_compliance;
uint8_t cc_ext; uint8_t cc_ext;
} __attribute__ ((packed)); } __attribute__ ((packed));
struct shw_sfp_dom {
/* Treshold values, 0 - 55 */
uint8_t temp_high_alarm[2];
uint8_t temp_low_alarm[2];
uint8_t temp_high_warn[2];
uint8_t temp_low_warn[2];
uint8_t volt_high_alarm[2];
uint8_t volt_low_alarm[2];
uint8_t volt_high_warn[2];
uint8_t volt_low_warn[2];
uint8_t bias_high_alarm[2];
uint8_t bias_low_alarm[2];
uint8_t bias_high_warn[2];
uint8_t bias_low_warn[2];
uint8_t tx_pow_high_alarm[2];
uint8_t tx_pow_low_alarm[2];
uint8_t tx_pow_high_warn[2];
uint8_t tx_pow_low_warn[2];
uint8_t rx_pow_high_alarm[2];
uint8_t rx_pow_log_alarm[2];
uint8_t rx_power_high_warn[2];
uint8_t rx_power_low_warn[2];
uint8_t unalloc0[16];
/* Calibration data, 56-91 */
uint8_t cal_rx_pwr4[4];
uint8_t cal_rx_pwr3[4];
uint8_t cal_rx_pwr2[4];
uint8_t cal_rx_pwr1[4];
uint8_t cal_rx_pwr0[4];
uint8_t cal_tx_i_slope[2];
uint8_t cal_tx_i_offset[2];
uint8_t cal_tx_pow_slope[2];
uint8_t cal_tx_pow_offset[2];
uint8_t cal_T_slope[2];
uint8_t cal_T_offset[2];
uint8_t cal_V_slope[2];
uint8_t cal_V_offset[2];
/* Unallocated and checksum, 92-95 */
uint8_t cal_unalloc[3];
uint8_t CC_DMI;
/* Real Time Diagnostics, 96-111 */
uint8_t temp[2];
uint8_t vcc[2];
uint8_t tx_bias[2];
uint8_t tx_pow[2];
uint8_t rx_pow[2];
uint8_t rtd_unalloc0[4];
uint8_t OSCB;
uint8_t rtd_unalloc1;
/* Alarms and Warnings, 112 - 117 */
uint8_t alw[6];
/* Extended Module Control/Status bytes 118 - 119 */
uint8_t emcsb[2];
/* Vendor locations 120 - 127 */
uint8_t vendor_locations[8];
/* User data 128 - 247 */
uint8_t dom_user[120];
/* Vendor specific control function locations 248 - 255 */
uint8_t vendor_functions[8];
} __attribute__ ((packed));
/* Public API */ /* Public API */
/* /*
...@@ -107,10 +183,20 @@ int shw_sfp_read_db(void); ...@@ -107,10 +183,20 @@ int shw_sfp_read_db(void);
/* Read and verify the header all at once. returns -1 on failure */ /* Read and verify the header all at once. returns -1 on failure */
int shw_sfp_read_verify_header(int num, struct shw_sfp_header *head); int shw_sfp_read_verify_header(int num, struct shw_sfp_header *head);
/* return NULL if no data found */ /* Read the SFP diagnostics page */
struct shw_sfp_caldata *shw_sfp_get_cal_data(int num); int shw_sfp_read_dom(int num, struct shw_sfp_dom *dom);
/* Read and verify the header all at once. returns -1 on failure */ /* Update the SFP diagnostics page */
int shw_sfp_read_verify_header(int num, struct shw_sfp_header *head); int shw_sfp_update_dom(int num, struct shw_sfp_dom *dom);
/* Decode and print the SFP real time diagnostics */
void shw_sfp_print_dom(struct shw_sfp_dom * dom);
/* Dump the SFP diagnostics page in hex */
void shw_sfp_dom_dump(struct shw_sfp_dom * dom);
/* return NULL if no data found */
struct shw_sfp_caldata *shw_sfp_get_cal_data(int num,
struct shw_sfp_header *head);
#endif /* __LIBWR_SHW_SFPLIB_H */ #endif /* __LIBWR_SHW_SFPLIB_H */
/*
* This work is part of the White Rabbit project
*
* Released according to the GNU GPL, version 2 or any later version.
*/
#ifndef __NETCONSOLE_H__
#define __NETCONSOLE_H__
#ifdef CONFIG_NETCONSOLE
#define HAS_NETCONSOLE 1
#else
#define HAS_NETCONSOLE 0
#endif
#define NETCONSOLE_ENABLED 1
#define NETCONSOLE_DISABLED 2
#define NETCONSOLE_WAIT 3
#define NETCONSOLE_PORT 55
extern struct wr_sockaddr netconsole_sock_addr;
extern int netconsole_status;
extern struct wr_udp_addr netconsole_udp_addr;
void netconsole_init(void);
int netconsole_poll(void);
int netconsole_read_byte(void);
int netconsole_write_string(const char *s);
#endif /* __NETCONSOLE_H__ */
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
extern char sfp_pn[SFP_PN_LEN]; extern char sfp_pn[SFP_PN_LEN];
extern int32_t sfp_in_db; extern int32_t sfp_in_db;
extern int32_t sfp_alpha; extern int64_t sfp_alpha;
extern int32_t sfp_deltaTx; extern int32_t sfp_deltaTx;
extern int32_t sfp_deltaRx; extern int32_t sfp_deltaRx;
......
...@@ -9,6 +9,9 @@ ...@@ -9,6 +9,9 @@
#define UI_SHELL_MODE 0 #define UI_SHELL_MODE 0
#define UI_GUI_MODE 1 #define UI_GUI_MODE 1
#define SH_MAX_LINE_LEN 80
#define SH_MAX_ARGS 8
extern int wrc_ui_mode; extern int wrc_ui_mode;
extern int wrc_stat_running; extern int wrc_stat_running;
......
...@@ -24,4 +24,52 @@ typedef unsigned long intptr_t; ...@@ -24,4 +24,52 @@ typedef unsigned long intptr_t;
#define UINT32_MAX 4294967295U #define UINT32_MAX 4294967295U
/* gcc 4.5.3 used for wrpc does not have these */
#ifndef INT64_MIN
# define INT64_MIN (-9223372036854775807LL-1)
#endif
#ifndef INT64_MAX
# define INT64_MAX (9223372036854775807LL)
#endif
/* printf formats
* Copied form gcc's inttypes.h */
#define __STRINGIFY(a) #a
/* 32-bit types */
#define __PRI32(x) __STRINGIFY(x)
#define __SCN32(x) __STRINGIFY(x)
#define PRId32 __PRI32(d)
#define PRId32 __PRI32(d)
#define PRIi32 __PRI32(i)
#define PRIo32 __PRI32(o)
#define PRIu32 __PRI32(u)
#define PRIx32 __PRI32(x)
#define PRIX32 __PRI32(X)
#define SCNd32 __SCN32(d)
#define SCNi32 __SCN32(i)
#define SCNo32 __SCN32(o)
#define SCNu32 __SCN32(u)
#define SCNx32 __SCN32(x)
/* 64-bit types */
#define __PRI64(x) __STRINGIFY(ll##x)
#define __SCN64(x) __STRINGIFY(ll##x)
#define PRId64 __PRI64(d)
#define PRIi64 __PRI64(i)
#define PRIo64 __PRI64(o)
#define PRIu64 __PRI64(u)
#define PRIx64 __PRI64(x)
#define PRIX64 __PRI64(X)
#define SCNd64 __SCN64(d)
#define SCNi64 __SCN64(i)
#define SCNo64 __SCN64(o)
#define SCNu64 __SCN64(u)
#define SCNx64 __SCN64(x)
#endif #endif
...@@ -41,8 +41,10 @@ ...@@ -41,8 +41,10 @@
/* It should be: /* It should be:
* #define EE_BASE_INIT (EE_BASE_SFP + sizeof(sfpcount) + \ * #define EE_BASE_INIT (EE_BASE_SFP + sizeof(sfpcount) + \
* SFPS_MAX * sizeof(struct s_sfpinfo)) * SFPS_MAX * sizeof(struct s_sfpinfo))
* The used definition define the start of the init script 5 bytes * The used definition define the start of the init script 21 bytes
* (sizeof(sfpcount) + sizeof(t24p)) before the end of SFP database. * (sizeof(sfpcount) + sizeof(t24p)) before the end of SFP database.
* Edit: Since the alpha was changed to 64bit, the size of sizeof(struct s_sfpinfo)
* increased by 4. The error is now 5 + 16 = 21 bytes, not 5 as before.
* To make the init script working during the update of old versions of wrpc * To make the init script working during the update of old versions of wrpc
* SFPS_MAX is limited to 3. Adding the 4th SFP will corrupt the init script * SFPS_MAX is limited to 3. Adding the 4th SFP will corrupt the init script
* anyway. * anyway.
...@@ -73,7 +75,7 @@ struct storage_device; ...@@ -73,7 +75,7 @@ struct storage_device;
struct s_sfpinfo { struct s_sfpinfo {
char pn[SFP_PN_LEN]; char pn[SFP_PN_LEN];
int32_t alpha; int64_t alpha;
int32_t dTx; int32_t dTx;
int32_t dRx; int32_t dRx;
uint8_t chksum; uint8_t chksum;
......
...@@ -10,11 +10,14 @@ ...@@ -10,11 +10,14 @@
/* Color codes for cprintf()/pcprintf() */ /* Color codes for cprintf()/pcprintf() */
#define C_DIM 0x80 #define C_DIM 0x80
#define C_WHITE 7
#define C_GREY (C_WHITE | C_DIM)
#define C_RED 1 #define C_RED 1
#define C_GREEN 2 #define C_GREEN 2
#define C_BLUE 4 #define C_BLUE 4
#define C_MAGENTA 5
#define C_CYAN 6
/* Default foreground color, White or Black depends on User's terminal */
#define C_WHITE 9
/* Return TAI date/time in human-readable form. Non-reentrant. */ /* Return TAI date/time in human-readable form. Non-reentrant. */
char *format_time(uint64_t sec, int format); char *format_time(uint64_t sec, int format);
...@@ -28,17 +31,24 @@ typedef struct ...@@ -28,17 +31,24 @@ typedef struct
uint32_t timeout; uint32_t timeout;
} timeout_t; } timeout_t;
/* Color printf() variant. */ /* Color printf() variant. Does not restore color */
void cprintf(int color, const char *fmt, ...); void cprintf(int color, const char *fmt, ...);
/* Color printf() variant, sets curspor position to (row, col) too. */ /* Color printf() variant, sets curspor position to (row, col) too.
* Does not restore color */
void pcprintf(int row, int col, int color, const char *fmt, ...); void pcprintf(int row, int col, int color, const char *fmt, ...);
/* Printf, sets curspor position to (row, col) */
void pprintf(int row, int col, const char *fmt, ...);
void __debug_printf(const char *fmt, ...); void __debug_printf(const char *fmt, ...);
/* Clears the terminal scree. */ /* Clears the terminal screen */
void term_clear(void); void term_clear(void);
/* Clears the terminal screen from cursor to the end */
void term_clear_to_end(void);
int tmo_init(timeout_t *tmo, uint32_t milliseconds); int tmo_init(timeout_t *tmo, uint32_t milliseconds);
int tmo_restart(timeout_t *tmo); int tmo_restart(timeout_t *tmo);
int tmo_expired(timeout_t *tmo); int tmo_expired(timeout_t *tmo);
......
...@@ -30,6 +30,14 @@ ...@@ -30,6 +30,14 @@
_a < _b ? _a : _b; }) _a < _b ? _a : _b; })
#endif #endif
#ifndef htons
# define htons(x) (x)
#endif
#ifndef htonl
# define htonl(x) (x)
#endif
#undef offsetof #undef offsetof
#define offsetof(TYPE, MEMBER) ((long) &((TYPE *)0)->MEMBER) #define offsetof(TYPE, MEMBER) ((long) &((TYPE *)0)->MEMBER)
#undef ARRAY_SIZE #undef ARRAY_SIZE
...@@ -77,6 +85,7 @@ ...@@ -77,6 +85,7 @@
extern int wrc_vlan_number; extern int wrc_vlan_number;
int wrc_mon_gui(void); int wrc_mon_gui(void);
void redraw_gui(void);
int wrc_log_stats(void); int wrc_log_stats(void);
void shell_init(void); void shell_init(void);
......
...@@ -14,5 +14,8 @@ int wrc_ptp_get_mode(void); ...@@ -14,5 +14,8 @@ int wrc_ptp_get_mode(void);
int wrc_ptp_start(void); int wrc_ptp_start(void);
int wrc_ptp_stop(void); int wrc_ptp_stop(void);
int wrc_ptp_update(void); int wrc_ptp_update(void);
int wrc_ptp_bmc_update(void);
int wrc_ptp_link_down(void);
int wrc_ptp_is_abscal(void);
#endif #endif
...@@ -6,8 +6,8 @@ WR-WRPC-MIB DEFINITIONS ::= BEGIN ...@@ -6,8 +6,8 @@ WR-WRPC-MIB DEFINITIONS ::= BEGIN
-- IMPORTS: Include definitions from other mibs here -- IMPORTS: Include definitions from other mibs here
IMPORTS IMPORTS
OBJECT-TYPE, Integer32, Unsigned32, Counter32, Counter64, OBJECT-TYPE, Integer32, Unsigned32, Counter32, Counter64,
MODULE-IDENTITY, enterprises, TimeTicks FROM SNMPv2-SMI MODULE-IDENTITY, enterprises, TimeTicks, IpAddress FROM SNMPv2-SMI
DisplayString FROM SNMPv2-TC; DisplayString, MacAddress FROM SNMPv2-TC;
wrWrpcMIB MODULE-IDENTITY wrWrpcMIB MODULE-IDENTITY
LAST-UPDATED "201607061700Z" LAST-UPDATED "201607061700Z"
...@@ -773,7 +773,6 @@ wrpcInitScriptConfigLine OBJECT-TYPE ...@@ -773,7 +773,6 @@ wrpcInitScriptConfigLine OBJECT-TYPE
"Line to be added to the init script." "Line to be added to the init script."
::= { wrpcInitScriptConfigGroup 2 } ::= { wrpcInitScriptConfigGroup 2 }
-- **************************************************************************** -- ****************************************************************************
wrpcSdbGroup OBJECT IDENTIFIER ::= { wrpcCore 10 } wrpcSdbGroup OBJECT IDENTIFIER ::= { wrpcCore 10 }
...@@ -829,6 +828,129 @@ wrpcSdbParam OBJECT-TYPE ...@@ -829,6 +828,129 @@ wrpcSdbParam OBJECT-TYPE
address (for I2C EEPROM)." address (for I2C EEPROM)."
::= { wrpcSdbGroup 4 } ::= { wrpcSdbGroup 4 }
-- ****************************************************************************
wrpcNetconsoleGroup OBJECT IDENTIFIER ::= { wrpcCore 11 }
wrpcNetconsoleGetGroup OBJECT IDENTIFIER ::= { wrpcNetconsoleGroup 1 }
wrpcNetconsoleSetGroup OBJECT IDENTIFIER ::= { wrpcNetconsoleGroup 2 }
-- **************************************
wrpcNetconsoleGetStatus OBJECT-TYPE
SYNTAX INTEGER {
na(0),
enabled(1),
disable(2),
wait(3)
}
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Status of netconsole
enabled - serial console is copied to a host in the network
disabled - netconsole is not working, to resume it, please set it to _wait_
wait - node is listening for commands to arrive from host, but nothing
is send; when netconsole packet arrives all further messages
from serial console will be copied to netconsole
"
::= { wrpcNetconsoleGetGroup 1 }
wrpcNetconsoleGetPeerMac OBJECT-TYPE
SYNTAX MacAddress
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"MAC address of netconsole's peer"
::= { wrpcNetconsoleGetGroup 2 }
wrpcNetconsoleGetPeerIp OBJECT-TYPE
SYNTAX IpAddress
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"IP address of netconsole's peer"
::= { wrpcNetconsoleGetGroup 3 }
wrpcNetconsoleGetPeerPort OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"Port of netconsole's peer"
::= { wrpcNetconsoleGetGroup 4 }
-- **************************************
wrpcNetconsoleSetApply OBJECT-TYPE
SYNTAX INTEGER {
na(0),
disable(2),
wait(3),
applySuccessful(100),
applyFailed(200),
}
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"Make a change to a netconsole setting:
disable - don't send anything via netconsole nor wait for any input
wait - don't send anything via netconsole, but wait for any input to start sending
applySuccessful - successful to change state of netconsole
applyFailed - failed to change state of netconsole
"
::= { wrpcNetconsoleSetGroup 1 }
-- ****************************************************************************
wrpcShellCmdGroup OBJECT IDENTIFIER ::= { wrpcCore 12 }
wrpcShellCmdRun OBJECT-TYPE
SYNTAX INTEGER {
na(0),
execute(12),
executionSuccessful(100),
executionFailed(200),
executionFailedEmptyLine(201)
executionFailedSetMagicTo44451(202)
}
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"Run a shell command stored in wrpcShellCmdLine. Before command is run
OID wrpcShellCmdMagic has to be filled with 44451. This oid can have
the following values:
execute - to run the command stored in wrpcShellCmdLine
executionSuccessful - trigger of a command was successful,
but this has no information whether the command itslef was successful!
Check the wrpcShellCmdReturnCode!
executionFailed - failed to trigger the command
executionFailedEmptyLine - empty wrpcShellCmdLine
executionFailedSetMagicTo44451 - wrong magic in wrpcShellCmdMagic
"
::= { wrpcShellCmdGroup 1 }
wrpcShellCmdLine OBJECT-TYPE
SYNTAX DisplayString (SIZE(0..80))
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"Specify the command to be run"
::= { wrpcShellCmdGroup 2 }
wrpcShellCmdMagic OBJECT-TYPE
SYNTAX INTEGER {
na(0),
magic(44451)
}
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"To be able to execute command this OID has to contain 44451. After a run of a command this OID is zeroed"
::= { wrpcShellCmdGroup 3 }
wrpcShellCmdReturnCode OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"Return code of last executed command"
::= { wrpcShellCmdGroup 4 }
-- **************************************************************************** -- ****************************************************************************
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
* Released according to the GNU GPL, version 2 or any later version. * Released according to the GNU GPL, version 2 or any later version.
*/ */
#include <wrc.h> #include <wrc.h>
#include <wrpc.h>
#include <string.h> #include <string.h>
#include "dev/endpoint.h" #include "dev/endpoint.h"
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
* Released according to the GNU GPL, version 2 or any later version. * Released according to the GNU GPL, version 2 or any later version.
*/ */
#include <wrc.h> #include <wrc.h>
#include <wrpc.h>
#include <string.h> #include <string.h>
#include "dev/endpoint.h" #include "dev/endpoint.h"
...@@ -104,7 +103,7 @@ static int bootp_poll(void) ...@@ -104,7 +103,7 @@ static int bootp_poll(void)
return 0; return 0;
/* no extra traffic when abscal is in progress */ /* no extra traffic when abscal is in progress */
if (HAS_ABSCAL && ptp_mode == WRC_MODE_ABSCAL) if (HAS_ABSCAL && wrc_ptp_is_abscal())
return 0; return 0;
if (len > 0) if (len > 0)
......
...@@ -36,6 +36,8 @@ ...@@ -36,6 +36,8 @@
#define UDP_CHECKSUM (UDP_LENGTH+2) #define UDP_CHECKSUM (UDP_LENGTH+2)
#define UDP_END (UDP_CHECKSUM+2) #define UDP_END (UDP_CHECKSUM+2)
#define INET_ALEN 4
/* Internal to IP stack: */ /* Internal to IP stack: */
unsigned int ipv4_checksum(unsigned short *buf, int shorts); unsigned int ipv4_checksum(unsigned short *buf, int shorts);
......
...@@ -13,3 +13,8 @@ obj-$(CONFIG_SYSLOG) += lib/syslog.o ...@@ -13,3 +13,8 @@ obj-$(CONFIG_SYSLOG) += lib/syslog.o
obj-$(CONFIG_LATENCY_PROBE) += lib/latency.o obj-$(CONFIG_LATENCY_PROBE) += lib/latency.o
obj-$(CONFIG_SNMP) += lib/snmp.o obj-$(CONFIG_SNMP) += lib/snmp.o
obj-$(CONFIG_LLDP) += lib/lldp.o obj-$(CONFIG_LLDP) += lib/lldp.o
obj-$(CONFIG_NETCONSOLE) += lib/netconsole.o
# below requires $(AUTOCONF_PPSI) to be present before build
REQUIRE_AUTOCONF_PPSI += \
lib/net.o \
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include "ipv4.h" #include "ipv4.h"
#include "shell.h" #include "shell.h"
#include "dev/syscon.h" #include "dev/syscon.h"
#include <wrpc.h> /*needed for htons()*/
static uint8_t lldpdu[LLDP_MAX_PKT_LEN]; static uint8_t lldpdu[LLDP_MAX_PKT_LEN];
static uint16_t lldpdu_len; static uint16_t lldpdu_len;
...@@ -246,7 +245,7 @@ int lldp_poll(void) ...@@ -246,7 +245,7 @@ int lldp_poll(void)
static uint8_t old_mac[ETH_ALEN]; static uint8_t old_mac[ETH_ALEN];
/* no extra traffic when abscal is in progress */ /* no extra traffic when abscal is in progress */
if (HAS_ABSCAL && ptp_mode == WRC_MODE_ABSCAL) if (HAS_ABSCAL && wrc_ptp_is_abscal())
return 0; return 0;
/* periodic tasks */ /* periodic tasks */
......
/*
* This work is part of the White Rabbit project
*
* Copyright (C) 2018 CERN (www.cern.ch)
* Author: Adam Wujek <adam.wujek@cern.ch>
*
* Released according to the GNU GPL, version 2 or any later version.
*/
#include <wrc.h>
//#include <wrpc.h>
#include <string.h>
#include "ipv4.h"
#include "ptpd_netif.h"
#include "shell.h"
#include "netconsole.h"
#ifdef CONFIG_NETCONSOLE_DEF_WAIT
#define NETCONSOLE_DEF_VAL NETCONSOLE_WAIT
#else
#define NETCONSOLE_DEF_VAL NETCONSOLE_DISABLED
#endif
static uint8_t __netconsole_queue[152];
static struct wrpc_socket __static_netconsole_socket = {
.queue.buff = __netconsole_queue,
.queue.size = sizeof(__netconsole_queue),
};
static struct wrpc_socket *netconsole_socket;
static unsigned char *cmd_rx_p = NULL;
/* net headers + cmd len */
static uint8_t tx_buf[UDP_END + SH_MAX_LINE_LEN + 1];
static uint8_t rx_buf[UDP_END + SH_MAX_LINE_LEN + 1];
struct wr_sockaddr netconsole_sock_addr;
int netconsole_status = NETCONSOLE_DEF_VAL;
struct wr_udp_addr netconsole_udp_addr;
/* init for netconsole task */
void netconsole_init(void)
{
netconsole_socket = ptpd_netif_create_socket(
&__static_netconsole_socket, NULL,
PTPD_SOCK_UDP, NETCONSOLE_PORT);
}
int netconsole_read_byte(void)
{
if (cmd_rx_p && *cmd_rx_p != 0)
return *(cmd_rx_p++);
return -1;
}
/* NOTE: pp_printf will not work in this function
* because it can be called from pp_printf */
int netconsole_write_string(const char *s)
{
static int len = 0;
const uint8_t *p;
static uint8_t *d = NULL;
static int rec_level = 0;
if (netconsole_status != NETCONSOLE_ENABLED)
return 0;
/* Prevent recursive calls when net verbose configured.
* NOTE: Even with the following if, NET_IS_VERBOSE does not work
* with netconsole */
if (rec_level > 0)
return 0;
rec_level++;
p = (uint8_t *)s;
while (1) {
if (!d) {
d = &tx_buf[UDP_END];
len = 0;
}
if (!*p) {
break;
}
*d = *p;
len++;
/* send packet on:
* --newline
* --"#", so prompt is send
* --max line length
*/
if (*d == '\n' || *d == '#' || len == SH_MAX_LINE_LEN) {
len += UDP_END;
netconsole_udp_addr.sport = htons(NETCONSOLE_PORT);
getIP((void *)&netconsole_udp_addr.saddr);
fill_udp((uint8_t *)tx_buf, len, &netconsole_udp_addr);
ptpd_netif_sendto(netconsole_socket,
&netconsole_sock_addr, tx_buf, len,
0);
d = NULL;
/* len is cleared when d == NULL */
p++;
continue;
}
p++;
d++;
}
rec_level--;
return 0;
}
int netconsole_poll(void)
{
int len;
if (ip_status == IP_TRAINING
|| netconsole_status == NETCONSOLE_DISABLED) {
/* can't do netconsole w/o an address...
* or netconsole disabled */
return 0;
}
if ((len = ptpd_netif_recvfrom(netconsole_socket,
&netconsole_sock_addr, rx_buf,
sizeof(rx_buf), NULL)
) > 0) {
if (check_dest_ip(rx_buf)) {
/* wrong destination IP */
return 0;
}
rx_buf[len] = 0;
/* copy peer's IP address and port */
memcpy(&netconsole_udp_addr.daddr, rx_buf + IP_SOURCE, 4);
memcpy(&netconsole_udp_addr.dport, rx_buf + UDP_SPORT, 2);
cmd_rx_p = &rx_buf[UDP_END];
netconsole_status = NETCONSOLE_ENABLED;
return 1;
}
return 0;
}
...@@ -47,12 +47,14 @@ int wrpc_get_port_state(struct hal_port_state *port, const char *port_name) ...@@ -47,12 +47,14 @@ int wrpc_get_port_state(struct hal_port_state *port, const char *port_name)
port->mode = HEXP_PORT_MODE_WR_MASTER; port->mode = HEXP_PORT_MODE_WR_MASTER;
/* all deltas are added anyway */ /* all deltas are added anyway */
ep_get_deltas(&wrc_endpoint_dev, &port->calib.delta_tx_board, ep_get_deltas(&wrc_endpoint_dev, &port->calib.sfp.delta_tx_ps,
&port->calib.delta_rx_board); &port->calib.sfp.delta_rx_ps);
/* get the bitslide */
port->calib.bitslide_ps = ep_get_bitslide(&wrc_endpoint_dev);
port->calib.delta_tx_phy = 0; port->calib.delta_tx_phy = 0;
port->calib.delta_rx_phy = 0; port->calib.delta_rx_phy = 0;
port->calib.sfp.delta_tx_ps = 0; port->calib.delta_tx_board = 0;
port->calib.sfp.delta_rx_ps = 0; port->calib.delta_rx_board = 0;
read_phase_val(port); read_phase_val(port);
port->state = ep_link_up(&wrc_endpoint_dev, NULL); port->state = ep_link_up(&wrc_endpoint_dev, NULL);
port->calib.tx_calibrated = 1; port->calib.tx_calibrated = 1;
......
This diff is collapsed.
...@@ -97,7 +97,6 @@ void cprintf(int color, const char *fmt, ...) ...@@ -97,7 +97,6 @@ void cprintf(int color, const char *fmt, ...)
va_start(ap, fmt); va_start(ap, fmt);
pp_vprintf(fmt, ap); pp_vprintf(fmt, ap);
va_end(ap); va_end(ap);
pp_printf("\e[m");
} }
void pcprintf(int row, int col, int color, const char *fmt, ...) void pcprintf(int row, int col, int color, const char *fmt, ...)
...@@ -108,7 +107,15 @@ void pcprintf(int row, int col, int color, const char *fmt, ...) ...@@ -108,7 +107,15 @@ void pcprintf(int row, int col, int color, const char *fmt, ...)
va_start(ap, fmt); va_start(ap, fmt);
pp_vprintf(fmt, ap); pp_vprintf(fmt, ap);
va_end(ap); va_end(ap);
pp_printf("\e[m"); }
void pprintf(int row, int col, const char *fmt, ...)
{
va_list ap;
pp_printf("\e[%d;%df", row, col);
va_start(ap, fmt);
pp_vprintf(fmt, ap);
va_end(ap);
} }
void __debug_printf(const char *fmt, ...) void __debug_printf(const char *fmt, ...)
...@@ -125,6 +132,11 @@ void term_clear(void) ...@@ -125,6 +132,11 @@ void term_clear(void)
pp_printf("\e[2J\e[1;1H"); pp_printf("\e[2J\e[1;1H");
} }
void term_clear_to_end(void)
{
pp_printf("\e[J");
}
int tmo_init(timeout_t *tmo, uint32_t milliseconds) int tmo_init(timeout_t *tmo, uint32_t milliseconds)
{ {
tmo->start_tics = timer_get_tics(); tmo->start_tics = timer_get_tics();
......
This diff is collapsed.
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
/* BEGIN OF HACKS */ /* BEGIN OF HACKS */
#include <pp-printf.h> #include <pp-printf.h>
#define CONFIG_PRINTF_64BIT
/* <linux/types.h> -- but if we typedef we get redefined type when hosted */ /* <linux/types.h> -- but if we typedef we get redefined type when hosted */
#define u8 uint8_t #define u8 uint8_t
#define size_t unsigned long #define size_t unsigned long
...@@ -335,11 +336,13 @@ int pp_vsprintf(char *buf, const char *fmt, va_list args) ...@@ -335,11 +336,13 @@ int pp_vsprintf(char *buf, const char *fmt, va_list args)
str = string(str, va_arg(args, char *), field_width, precision, flags); str = string(str, va_arg(args, char *), field_width, precision, flags);
continue; continue;
#if 0
case 'p': case 'p':
str = pointer(fmt+1, str, str = pointer(fmt+1, str,
va_arg(args, void *), va_arg(args, void *),
field_width, precision, flags); field_width, precision, flags);
continue; continue;
#endif
case 'n': case 'n':
if (qualifier == 'l') { if (qualifier == 'l') {
......
Subproject commit dc1c7d268968cbb37a6ab5655e4cd683b25b7a50 Subproject commit 3d815ee0fba517175db3f3e21c6e6f4151865341
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
static int cmd_gui(const char *args[]) static int cmd_gui(const char *args[])
{ {
redraw_gui();
shell_activate_ui_command( wrc_mon_gui ); shell_activate_ui_command( wrc_mon_gui );
return 0; return 0;
} }
......
/*
* This work is part of the White Rabbit project
*
* Copyright (C) 2021 CERN (www.cern.ch)
* Author: Adam Wujek
*
* Released according to the GNU GPL, version 2 or any later version.
*/
/* Command: leapsec
Arguments:
set SEC - sets leap seconds value
<none> - dumps leap seconds value
Description: set/read leap seconds value used by PTP */
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <wrc.h>
#include <wrpc.h>
#include "shell.h"
#include "util.h"
#include "wrc_ptp.h"
/* Setting leap second makes sense only for GM. For other modes leap seconds
* counter is received from a master (slave) or is hardcoded in PPSI (master).
* In master it is hardcoded to PP_DEFAULT_UTC_OFFSET, since master mode does
* not have timescale set. */
static int cmd_leapsec(const char *args[])
{
int ptp_offset, system_offset;
if (args[1] && !strcasecmp(args[0], "set")) {
wrc_ptp_set_leapsec(atoi(args[1]));
} else if (args[0] && strcasecmp(args[0], "get")) {
/* other param given, but not "get" */
return -EINVAL;
}
wrc_ptp_get_leapsec(&ptp_offset, &system_offset);
pp_printf("leap seconds: ptp %d, system %d\n", ptp_offset, system_offset);
return 0;
}
DEFINE_WRC_COMMAND(leapsec) = {
.name = "leapsec",
.exec = cmd_leapsec,
};
/*
* This work is part of the White Rabbit project
*
* Copyright (C) 2012 GSI (www.gsi.de)
* Author: Wesley W. Terpstra <w.terpstra@gsi.de>
*
* Released according to the GNU GPL, version 2 or any later version.
*/
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <wrc.h>
#include <lib/ipv4.h>
#include <netconsole.h>
#include <shell.h>
static void print_netconsole_status(void) {
char buf[20];
/* print netconsole's status */
switch (netconsole_status) {
case NETCONSOLE_ENABLED:
/* Print peer's MAC and IP */
pp_printf("netconsole's peer: ");
format_mac(buf, (void *)&netconsole_sock_addr.mac);
pp_printf("MAC: %s ", buf);
format_ip(buf, (void *)&netconsole_udp_addr.daddr);
pp_printf("IP: %s ", buf);
pp_printf("port: %d\n", netconsole_udp_addr.dport);
break;
case NETCONSOLE_WAIT:
pp_printf("netconsole is waiting for peer\n");
break;
case NETCONSOLE_DISABLED:
pp_printf("netconsole disabled\n");
break;
default:
break;
}
}
static int cmd_netconsole(const char *args[])
{
if (!args[0]) {
/* do nothing here, later print status */
} else if (!strcasecmp(args[0], "wait")) {
/* Disable netconsole */
netconsole_status = NETCONSOLE_WAIT;
} else if (!strcasecmp(args[0], "disable")) {
/* Disable permanently netconsole */
netconsole_status = NETCONSOLE_DISABLED;
} else if (args[0] && args[1] && args[2]) {
/* Set MAC and IP for netconsole peer */
decode_mac(args[0], (void *)&netconsole_sock_addr.mac);
decode_ip(args[1], (void *)&netconsole_udp_addr.daddr);
netconsole_udp_addr.dport = atoi(args[2]);
netconsole_status = NETCONSOLE_ENABLED;
} else {
pp_printf("uage: netconsole wait | disable | "
"<MAC> <IP> <port> \n");
return -EINVAL;
}
print_netconsole_status();
return 0;
}
DEFINE_WRC_COMMAND(netconsole) = {
.name = "netconsole",
.exec = cmd_netconsole,
};
/*
* This work is part of the White Rabbit project
*
* Copyright (C) 2021 CERN (www.cern.ch)
* Author: Adam Wujek
*
* Released according to the GNU GPL, version 2 or any later version.
*/
/* Command: pps
Arguments:
force on|off - sets the behaviour of forcing PPS generation
<none> - dumps force PPS generation setting
Description: Enable disable generation of PPS all the time */
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <wrc.h>
#include <wrpc.h>
#include "shell.h"
#include "util.h"
#include "wrc_ptp.h"
char * pps_force_map[] = {
[pps_force_off] = "off",
[pps_force_on] = "on",
};
static int cmd_pps(const char *args[])
{
if (!strcasecmp(args[0], "force")) {
if (!strcasecmp(args[1], "on")) {
wrc_pps_force(pps_force_on);
} else if (!strcasecmp(args[1], "off")) {
wrc_pps_force(pps_force_off);
} else {
return -1;
}
}
pp_printf("PPS force %s\n", pps_force_map[wrc_pps_force(pps_force_check)]);
return 0;
}
DEFINE_WRC_COMMAND(pps) = {
.name = "pps",
.exec = cmd_pps,
};
...@@ -17,11 +17,11 @@ struct subcmd { ...@@ -17,11 +17,11 @@ struct subcmd {
} subcmd[] = { } subcmd[] = {
{"start", wrc_ptp_run, 1}, {"start", wrc_ptp_run, 1},
{"stop", wrc_ptp_run, 0}, {"stop", wrc_ptp_run, 0},
{"e2e", wrc_ptp_sync_mech, PP_E2E_MECH}, {"e2e", wrc_ptp_sync_mech, E2E},
{"delay", wrc_ptp_sync_mech, PP_E2E_MECH}, {"delay", wrc_ptp_sync_mech, E2E},
#ifdef CONFIG_P2P #ifdef CONFIG_P2P
{"p2p", wrc_ptp_sync_mech, PP_P2P_MECH}, {"p2p", wrc_ptp_sync_mech, P2P},
{"pdelay", wrc_ptp_sync_mech, PP_P2P_MECH}, {"pdelay", wrc_ptp_sync_mech, P2P},
#endif #endif
{"gm", wrc_ptp_set_mode, WRC_MODE_GM}, {"gm", wrc_ptp_set_mode, WRC_MODE_GM},
{"master", wrc_ptp_set_mode, WRC_MODE_MASTER}, {"master", wrc_ptp_set_mode, WRC_MODE_MASTER},
...@@ -32,7 +32,7 @@ struct subcmd { ...@@ -32,7 +32,7 @@ struct subcmd {
}; };
static char *is_run[] = {"stopped", "running"}; static char *is_run[] = {"stopped", "running"};
static char *is_mech[] = {[PP_E2E_MECH] = "e2e", [PP_P2P_MECH] = "p2p"}; static char *is_mech[] = {[E2E] = "e2e", [P2P] = "p2p"};
static char *is_mode[] = {[WRC_MODE_GM] = "gm", [WRC_MODE_MASTER] = "master", static char *is_mode[] = {[WRC_MODE_GM] = "gm", [WRC_MODE_MASTER] = "master",
[WRC_MODE_SLAVE] = "slave" [WRC_MODE_SLAVE] = "slave"
#ifdef CONFIG_ABSCAL #ifdef CONFIG_ABSCAL
......
...@@ -18,18 +18,27 @@ ...@@ -18,18 +18,27 @@
#endif #endif
extern int wrc_phase_tracking; extern int wrc_phase_tracking;
extern struct pp_globals *ppg;
static int cmd_ptrack(const char *args[]) static int cmd_ptrack(const char *args[])
{ {
struct pp_instance *ppi = ppg->pp_instances;
#ifdef CONFIG_HAS_EXT_WR
if (args[0] && !strcasecmp(args[0], "enable")) { if (args[0] && !strcasecmp(args[0], "enable")) {
wr_servo_enable_tracking(1); wrh_servo_enable_tracking(1);
wrc_phase_tracking = 1;
} }
else if (args[0] && !strcasecmp(args[0], "disable")) { else if (args[0] && !strcasecmp(args[0], "disable")) {
wr_servo_enable_tracking(0); wrh_servo_enable_tracking(0);
wrc_phase_tracking = 0;
} }
pp_printf("phase tracking %s\n", wrc_phase_tracking?"ON":"OFF");
if (ppi->protocol_extension==PPSI_EXT_WR && ppi->extState==PP_EXSTATE_ACTIVE)
pp_printf("phase tracking %s\n", WRH_SRV(ppi)->tracking_enabled?"ON":"OFF");
#endif
#if CONFIG_HAS_EXT_L1SYNC
pp_printf("phase tracking not implemented for L1sync!\n");
#endif
return 0; return 0;
} }
......
...@@ -47,7 +47,7 @@ static int cmd_sfp(const char *args[]) ...@@ -47,7 +47,7 @@ static int cmd_sfp(const char *args[])
return -EIO; return -EIO;
} }
return 0; return 0;
} else if (args[4] && !strcasecmp(args[0], "add")) { } else if (args[5] && !strcasecmp(args[0], "add")) {
temp = strnlen(args[1], SFP_PN_LEN); temp = strnlen(args[1], SFP_PN_LEN);
for (i = 0; i < temp; ++i) for (i = 0; i < temp; ++i)
sfp.pn[i] = args[1][i]; sfp.pn[i] = args[1][i];
...@@ -56,6 +56,9 @@ static int cmd_sfp(const char *args[]) ...@@ -56,6 +56,9 @@ static int cmd_sfp(const char *args[])
sfp.dTx = atoi(args[2]); sfp.dTx = atoi(args[2]);
sfp.dRx = atoi(args[3]); sfp.dRx = atoi(args[3]);
sfp.alpha = atoi(args[4]); sfp.alpha = atoi(args[4]);
sfp.alpha = sfp.alpha * 1000000000;
/* first value defines a sign */
sfp.alpha += (sfp.alpha < 0?-1:1) * atoi(args[5]);
temp = storage_get_sfp(&sfp, SFP_ADD, 0); temp = storage_get_sfp(&sfp, SFP_ADD, 0);
if (temp == EE_RET_DBFULL) { if (temp == EE_RET_DBFULL) {
pp_printf("SFP DB is full\n"); pp_printf("SFP DB is full\n");
...@@ -83,7 +86,7 @@ static int cmd_sfp(const char *args[]) ...@@ -83,7 +86,7 @@ static int cmd_sfp(const char *args[])
pp_printf("%d: PN:", i + 1); pp_printf("%d: PN:", i + 1);
for (temp = 0; temp < SFP_PN_LEN; ++temp) for (temp = 0; temp < SFP_PN_LEN; ++temp)
pp_printf("%c", sfp.pn[temp]); pp_printf("%c", sfp.pn[temp]);
pp_printf(" dTx: %8d dRx: %8d alpha: %8d\n", sfp.dTx, pp_printf(" dTx: %8d dRx: %8d alpha: %19Ld\n", sfp.dTx,
sfp.dRx, sfp.alpha); sfp.dRx, sfp.alpha);
} }
return 0; return 0;
...@@ -112,7 +115,7 @@ static int cmd_sfp(const char *args[]) ...@@ -112,7 +115,7 @@ static int cmd_sfp(const char *args[])
return ret; return ret;
} }
/* match successful */ /* match successful */
pp_printf("SFP matched, dTx=%d dRx=%d alpha=%d\n", pp_printf("SFP matched, dTx=%d dRx=%d alpha=%Ld\n",
sfp_deltaTx, sfp_deltaRx, sfp_alpha); sfp_deltaTx, sfp_deltaRx, sfp_alpha);
return ret; return ret;
} else if (args[1] && !strcasecmp(args[0], "ena")) { } else if (args[1] && !strcasecmp(args[0], "ena")) {
......
...@@ -20,9 +20,6 @@ ...@@ -20,9 +20,6 @@
#include "shell.h" #include "shell.h"
#include "storage.h" #include "storage.h"
#define SH_MAX_LINE_LEN 80
#define SH_MAX_ARGS 8
/* interactive shell state definitions */ /* interactive shell state definitions */
#define SHELL_MAX_COMMANDS 32 #define SHELL_MAX_COMMANDS 32
...@@ -37,10 +34,32 @@ ...@@ -37,10 +34,32 @@
#define KEY_LEFT (ESCAPE_FLAG | 68) #define KEY_LEFT (ESCAPE_FLAG | 68)
#define KEY_RIGHT (ESCAPE_FLAG | 67) #define KEY_RIGHT (ESCAPE_FLAG | 67)
#define KEY_ENTER (13) #define KEY_ENTER (13)
#define KEY_ENTER10 (10)
#define KEY_ESCAPE (27) #define KEY_ESCAPE (27)
#define KEY_BACKSPACE (127) #define KEY_BACKSPACE (127)
#define KEY_DELETE (126) #define KEY_DELETE (126)
#ifdef CONFIG_CMD_PPS
#define HAS_CMD_PPS 1
#else
#define HAS_CMD_PPS 0
#endif
#ifdef CONFIG_CMD_LEAPSEC
#define HAS_CMD_LEAPSEC 1
#else
#define HAS_CMD_LEAPSEC 0
#endif
#ifdef CONFIG_CMD_NETCONSOLE
#define HAS_CMD_NETCONSOLE 1
#else
#define HAS_CMD_NETCONSOLE 0
#endif
static char cmd_buf[SH_MAX_LINE_LEN + 1]; static char cmd_buf[SH_MAX_LINE_LEN + 1];
static int cmd_pos = 0, cmd_len = 0; static int cmd_pos = 0, cmd_len = 0;
static int state = SH_PROMPT; static int state = SH_PROMPT;
...@@ -137,6 +156,8 @@ int shell_exec(const char *cmd) ...@@ -137,6 +156,8 @@ int shell_exec(const char *cmd)
shell_is_interacting = 1; shell_is_interacting = 1;
i = _shell_exec(); i = _shell_exec();
shell_is_interacting = 0; shell_is_interacting = 0;
/* clean cmd_buf */
cmd_buf[0] = '\0';
return i; return i;
} }
...@@ -187,6 +208,7 @@ int shell_interactive() ...@@ -187,6 +208,7 @@ int shell_interactive()
break; break;
case KEY_ENTER: case KEY_ENTER:
case KEY_ENTER10:
pp_printf("\n"); pp_printf("\n");
state = SH_EXEC; state = SH_EXEC;
break; break;
...@@ -236,7 +258,11 @@ int shell_interactive() ...@@ -236,7 +258,11 @@ int shell_interactive()
case SH_EXEC_UI: case SH_EXEC_UI:
if( !shell_ui_callback || shell_ui_callback() < 0 || console_getc() == 27 ) c = console_getc();
if (c == 'r')
redraw_gui();
if (!shell_ui_callback || shell_ui_callback() < 0 || c == 27 || c == 'q')
{ {
cmd_buf[cmd_len] = 0; cmd_buf[cmd_len] = 0;
state = SH_PROMPT; state = SH_PROMPT;
...@@ -343,6 +369,7 @@ void shell_activate_ui_command( int (*callback)(void) ) ...@@ -343,6 +369,7 @@ void shell_activate_ui_command( int (*callback)(void) )
shell_ui_callback = callback; shell_ui_callback = callback;
state = SH_EXEC_UI; state = SH_EXEC_UI;
pp_printf("Activateui: %p\n", callback ); pp_printf("Activateui: %p\n", callback );
term_clear();
cmd_len = 0; cmd_len = 0;
} }
...@@ -365,9 +392,17 @@ void shell_register_commands(void) ...@@ -365,9 +392,17 @@ void shell_register_commands(void)
REGISTER_WRC_COMMAND(init); REGISTER_WRC_COMMAND(init);
REGISTER_WRC_COMMAND(sfp); REGISTER_WRC_COMMAND(sfp);
REGISTER_WRC_COMMAND(stat); REGISTER_WRC_COMMAND(stat);
REGISTER_WRC_COMMAND(ver);
REGISTER_WRC_COMMAND(ptrack);
REGISTER_WRC_COMMAND(time);
if (HAS_IP) if (HAS_IP)
REGISTER_WRC_COMMAND(ip); REGISTER_WRC_COMMAND(ip);
if (HAS_VLANS) if (HAS_VLANS)
REGISTER_WRC_COMMAND(vlan); REGISTER_WRC_COMMAND(vlan);
if (HAS_CMD_PPS)
REGISTER_WRC_COMMAND(pps);
if (HAS_CMD_LEAPSEC)
REGISTER_WRC_COMMAND(leapsec);
if (HAS_CMD_NETCONSOLE)
REGISTER_WRC_COMMAND(netconsole);
} }
...@@ -24,6 +24,17 @@ obj-$(CONFIG_IP) += shell/cmd_ip.o ...@@ -24,6 +24,17 @@ obj-$(CONFIG_IP) += shell/cmd_ip.o
obj-$(CONFIG_PPSI) += shell/cmd_verbose.o obj-$(CONFIG_PPSI) += shell/cmd_verbose.o
obj-$(CONFIG_CMD_CONFIG) += shell/cmd_config.o obj-$(CONFIG_CMD_CONFIG) += shell/cmd_config.o
obj-$(CONFIG_CMD_SLEEP) += shell/cmd_sleep.o obj-$(CONFIG_CMD_SLEEP) += shell/cmd_sleep.o
obj-$(CONFIG_CMD_NETCONSOLE) += shell/cmd_netconsole.o
obj-$(CONFIG_CMD_LL) += shell/cmd_ll.o obj-$(CONFIG_CMD_LL) += shell/cmd_ll.o
obj-$(CONFIG_CMD_PPS) += shell/cmd_pps.o
obj-$(CONFIG_CMD_LEAPSEC) += shell/cmd_leapsec.o
obj-$(CONFIG_FLASH_INIT) += shell/cmd_init.o obj-$(CONFIG_FLASH_INIT) += shell/cmd_init.o
obj-$(CONFIG_VLAN) += shell/cmd_vlan.o obj-$(CONFIG_VLAN) += shell/cmd_vlan.o
# below have dependency on $(AUTOCONF_PPSI) file
REQUIRE_AUTOCONF_PPSI += \
shell/cmd_leapsec.o \
shell/cmd_pps.o \
shell/cmd_ptp.o \
shell/cmd_ptrack.o \
shell/cmd_verbose.o \
include ../.config
EB ?= no EB ?= no
SDBFS ?= no SDBFS ?= no
...@@ -8,11 +9,14 @@ LDFLAGS += -lreadline ...@@ -8,11 +9,14 @@ LDFLAGS += -lreadline
ALL = genraminit genramvhd genrammif ALL = genraminit genramvhd genrammif
#ALL += wrpc-w1-read wrpc-w1-write #ALL += wrpc-w1-read wrpc-w1-write
ALL += pfilter-builder ALL += pfilter-builder
ALL += wrpc-dump mapper ALL += mapper
ALL += wrpc-vuart ALL += wrpc-vuart
ALL += wr-streamers ALL += wr-streamers
ALL += wrpc-diags ALL += wrpc-diags
ALL += gensdbfs ALL += gensdbfs
ALL-$(CONFIG_PPSI) += wrpc-dump
ALL+= $(ALL-y)
ifneq ($(EB),no) ifneq ($(EB),no)
ALL += eb-w1-write ALL += eb-w1-write
...@@ -53,10 +57,16 @@ gensdbfs: ...@@ -53,10 +57,16 @@ gensdbfs:
sdb-wrpc.bin: sdbfs sdb-wrpc.bin: sdbfs
$(SDBFS)/gensdbfs $< $@ $(SDBFS)/gensdbfs $< $@
wrpc-dump: wrpc-dump.c dump-info-host.o wrpc-dump: wrpc-dump.c dump-info-host.o time_lib.o
$(CC) $(CFLAGS) -I../ppsi/include -I../ppsi/arch-wrpc/include -I.. \ $(CC) $(CFLAGS) -include $(AUTOCONF) -include $(AUTOCONF_PPSI) -I../ppsi/include -I../ppsi/arch-wrpc -I../ppsi/arch-wrpc/include -I.. \
-I ../softpll \ -I ../softpll \
$^ -o $@ \ $^ -o $@
time_lib.o: time_lib.c
$(CC) $(CFLAGS) -include $(AUTOCONF) -include $(AUTOCONF_PPSI) -I../ppsi/include -I../ppsi/arch-wrpc/include -I.. \
-I ../softpll -c \
$^ -o $@
wr-streamers: wr-streamers.c wr-streamers: wr-streamers.c
$(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@ $(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@
......
/*
* time_lib.c
*
* - Time to string conversion functions
* - Decode leap seconds file
*
* Created on: 2019
* Authors:
* - Jean-Claude BAU / CERN
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License...
*/
#include <errno.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <inttypes.h>
#include <sys/timex.h>
#include <ppsi/ppsi.h>
char * timeIntervalToString(TimeInterval time,char *buf) {
int64_t sign,nanos,picos;
if ( time<0 && time !=INT64_MIN) {
sign=-1;
time=-time;
} else {
sign=1;
}
nanos = time >> TIME_INTERVAL_FRACBITS;
picos = (((time & TIME_INTERVAL_FRACMASK) * 1000) + TIME_INTERVAL_ROUNDING_VALUE ) >> TIME_INTERVAL_FRACBITS;
sprintf(buf,"%" PRId64 ".%03" PRId64, sign*nanos,picos);
return buf;
}
char * timeToString(struct pp_time *time, char *buf) {
char sign = '+';
int64_t scaled_nsecs = time->scaled_nsecs;
int64_t secs = time->secs, nanos, picos;
if (!is_incorrect(time)) {
if (scaled_nsecs < 0 || secs < 0) {
sign = '-';
scaled_nsecs = -scaled_nsecs;
secs = -secs;
}
nanos = scaled_nsecs >> TIME_FRACBITS;
picos = ((scaled_nsecs & TIME_FRACMASK) * 1000 + TIME_ROUNDING_VALUE)
>> TIME_FRACBITS;
sprintf(buf,"%c%" PRId64 ".%09" PRId64 "%03" PRId64,
sign,secs,nanos,picos);
} else {
sprintf(buf, "--Incorrect--");
}
return buf;
}
char * timestampToString(struct Timestamp *time,char *buf){
uint64_t sec=(time->secondsField.msb << sizeof(time->secondsField.msb)) + time->secondsField.lsb;
sprintf(buf,"%" PRIu64 ".%09" PRIu32 "000",
sec, (uint32_t)time->nanosecondsField);
return buf;
}
char * relativeDifferenceToString(RelativeDifference time, char *buf ) {
char sign;
int32_t nsecs;
uint64_t sub_yocto=0;
int64_t fraction;
uint64_t bitWeight=500000000000000000;
uint64_t mask;
if ( time<0 ) {
time=-time;
sign='-';
} else {
sign='+';
}
nsecs=time >> REL_DIFF_FRACBITS;
fraction=time & REL_DIFF_FRACMASK;
for (mask=(uint64_t) 1<< (REL_DIFF_FRACBITS-1);mask!=0; mask>>=1 ) {
if ( mask & fraction )
sub_yocto+=bitWeight;
bitWeight/=2;
}
sprintf(buf,"%c%"PRId32".%018"PRIu64, sign, nsecs, sub_yocto);
return buf;
}
/**
* Function to subtract timeval in a robust way
*
* In order to properly print the result on screen you can use:
*
* int neg=timeval_subtract(&diff, &a, &b);
* printf("%c%li.%06li\n",neg?'-':'+',labs(diff.tv_sec),labs(diff.tv_usec));
*
* @ref: https://stackoverflow.com/questions/15846762/timeval-subtract-explanation
* @note for safety reason a copy of x,y is used internally so x,y are never modified
* @param[inout] result A pointer on a timeval structure where the result will be stored.
* @param[in] x A pointer on x timeval struct
* @param[in] y A pointer on y timeval struct
* @return 1 if result is negative (seconds or useconds)
*
*
*/
int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y)
{
struct timeval xx = *x;
struct timeval yy = *y;
x = &xx; y = &yy;
if (x->tv_usec > 999999)
{
x->tv_sec += x->tv_usec / 1000000;
x->tv_usec %= 1000000;
}
if (y->tv_usec > 999999)
{
y->tv_sec += y->tv_usec / 1000000;
y->tv_usec %= 1000000;
}
result->tv_sec = x->tv_sec - y->tv_sec;
result->tv_usec = x->tv_usec - y->tv_usec;
if(result->tv_sec>0 && result->tv_usec < 0)
{
result->tv_usec += 1000000;
result->tv_sec--; // borrow
}
else if(result->tv_sec<0 && result->tv_usec > 0)
{
result->tv_usec -= 1000000;
result->tv_sec++; // borrow
}
return (result->tv_sec < 0) || (result->tv_usec<0);
}
/**
* Get the TAI offset decoding the leap seconds file
* @param leapSecondsFile The leapSecond file name. Use the default one if NULL
* @param utc Number of seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC)
* @param nextTai if nextTai is not NULL, set to the next TAI in the next 12 hours
* @param hasExpired if hasExpired is not NULL, set to 1 if the file has expired
* @return >=0 : TAI offset
* -1 : Error
*/
#define OFFSET_NTP_TIME_TO_UTC ((uint64_t)2208988800LL) /* NTP time to UTC (1900 to 1970 in seconds) */
#define TWELVE_HOURS ((uint64_t)(60*60*12) ) /* Number of seconds in 12 hours */
static char *defaultLeapSecondsFile = "/etc/leap-seconds.list";
int getTaiOffsetFromLeapSecondsFile(char *leapSecondsFile, time_t utc, int *nextTai,int *hasExpired ) {
uint64_t expirationDate, ntpTime,nextNtpTime;
int tai_offset = 9; /* For the time before 1972, we consider that the offset is 9 */
FILE *f;
char line[128];
if ( leapSecondsFile == NULL )
leapSecondsFile=defaultLeapSecondsFile;
ntpTime = (uint64_t)utc + OFFSET_NTP_TIME_TO_UTC;
nextNtpTime= ntpTime + TWELVE_HOURS;
f = fopen(leapSecondsFile, "r");
if (!f) {
fprintf(stderr, "%s: Cannot open file %s: %s\n", __func__, leapSecondsFile,strerror(errno));
return -1;
}
/* Scan the file */
while (fgets(line, sizeof(line), f)) {
int tai;
uint64_t leapNtpTime;
if ( strcmp(line,"# ")==0)
continue; // This is a comment
if (sscanf(line, "#@ %" PRIu64 , &expirationDate) == 1) {
if ( hasExpired !=NULL )
*hasExpired=ntpTime>expirationDate;
continue;
}
if (sscanf(line, "%" PRIu64 " %i", &leapNtpTime, &tai) != 2)
continue;
/* check this line, and apply it if it's in the past */
if (leapNtpTime < ntpTime) {
tai_offset = tai;
if ( nextTai )
*nextTai=tai;
}
else {
if ( nextTai && leapNtpTime<=nextNtpTime )
*nextTai=tai;
break; // File read can be aborted
}
}
fclose(f);
return tai_offset;
}
/**
* Fix the TAI representation looking at the leap file
* @param leapSecondsFile The leapSecond file name. Use the default one if NULL
* @param utc Number of seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC)
* @param hasExpired if hasExpired is not NULL, set to 1 if the file has expired
* @param verbose Activate verbose mode
* @return >=0 : TAI offset
* -1 : Error
*/
int fixHostTai(char *leapSecondsFile, time_t utc, int *hasExpired, int verbose)
{
struct timex t;
int tai_offset;
/* first: get the current offset */
memset(&t, 0, sizeof(t));
if (adjtimex(&t) < 0) {
fprintf(stderr, "%s: adjtimex(): %s\n", __func__,
strerror(errno));
return 0;
}
if ( (tai_offset=getTaiOffsetFromLeapSecondsFile(NULL,utc,NULL,hasExpired))<0 ) {
fprintf(stderr, "%s: Cannot get TAI offset\n", __func__);
return 0;
}
if ( verbose && hasExpired && *hasExpired ) {
printf("Leap seconds file has expired.\n");
}
if (tai_offset != t.tai) {
if (verbose)
printf("Previous TAI offset: %i\n", t.tai);
t.constant = tai_offset;
t.modes = MOD_TAI;
if (adjtimex(&t) < 0) {
fprintf(stderr, "%s: adjtimex(): %s\n", __func__,
strerror(errno));
return tai_offset;
}
/* read back timex */
memset(&t, 0, sizeof(t));
if (adjtimex(&t) < 0) {
fprintf(stderr, "%s: adjtimex(): %s\n", __func__,
strerror(errno));
return 0;
}
}
if (verbose)
printf("Current TAI offset: %i\n", t.tai);
return tai_offset;
}
/*
* time_lib.h
*
* - Time to string conversion functions
* - Decode leap seconds file
*
* Created on: 2019
* Authors:
* - Jean-Claude BAU / CERN
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License...
*/
#include <ppsi/ppsi.h>
#include <time.h>
#include <sys/time.h>
/* Prototypes */
extern char * timeIntervalToString(TimeInterval time,char *buf);
extern char * timeToString(struct pp_time *time,char *buf);
extern char * timestampToString(struct Timestamp *time,char *buf);
extern char * relativeDifferenceToString(RelativeDifference time, char *buf );
extern int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y);
extern int getTaiOffsetFromLeapSecondsFile(char *leapSecondsFile, time_t utc, int *nextTai,int *hasExpired );
extern int fixHostTai(char *leapSecondsFile, time_t utc, int *hasExpired, int verbose);
This diff is collapsed.
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <dev/rxts_calibrator.h> #include <dev/rxts_calibrator.h>
#include <dev/flash.h> #include <dev/flash.h>
#include <dev/gpio.h> #include <dev/gpio.h>
#include <netconsole.h>
#include <wrc_ptp.h> #include <wrc_ptp.h>
#include <system_checks.h> #include <system_checks.h>
...@@ -89,6 +90,7 @@ static void wrc_initialize(void) ...@@ -89,6 +90,7 @@ static void wrc_initialize(void)
#ifndef BOARD_HAS_CUSTOM_NETWORK_INIT #ifndef BOARD_HAS_CUSTOM_NETWORK_INIT
net_rst(); net_rst();
ep_init( &wrc_endpoint_dev, (void *) BASE_EP ); ep_init( &wrc_endpoint_dev, (void *) BASE_EP );
netif_register_device( "wr0", "default", &wrc_endpoint_dev );
/* Sleep for 1s to make sure WRS v4.2 always realizes that /* Sleep for 1s to make sure WRS v4.2 always realizes that
* the link is down */ * the link is down */
timer_delay_ms(200); timer_delay_ms(200);
...@@ -112,7 +114,6 @@ static void wrc_initialize(void) ...@@ -112,7 +114,6 @@ static void wrc_initialize(void)
_endram = ENDRAM_MAGIC; _endram = ENDRAM_MAGIC;
wrc_ptp_set_mode(WRC_MODE_SLAVE); wrc_ptp_set_mode(WRC_MODE_SLAVE);
wrc_ptp_start();
wrc_tasks_accounting_init(); wrc_tasks_accounting_init();
wrc_board_create_tasks(); wrc_board_create_tasks();
...@@ -146,11 +147,8 @@ static int wrc_check_link(void) ...@@ -146,11 +147,8 @@ static int wrc_check_link(void)
gen_gpio_out(&pin_sysc_led_link, 0); gen_gpio_out(&pin_sysc_led_link, 0);
link_status = NETIF_LINK_WENT_DOWN; link_status = NETIF_LINK_WENT_DOWN;
wrc_ptp_stop(); wrc_ptp_stop();
wrc_ptp_link_down();
rv = 1; rv = 1;
/* special case */
spll_init(SPLL_MODE_FREE_RUNNING_MASTER, 0, SPLL_FLAG_ALIGN_PPS);
shw_pps_gen_enable_output(0);
} else } else
link_status = (state ? NETIF_LINK_UP : NETIF_LINK_DOWN); link_status = (state ? NETIF_LINK_UP : NETIF_LINK_DOWN);
...@@ -217,7 +215,7 @@ static int wrc_dispatch_ptp_events_poll(void) ...@@ -217,7 +215,7 @@ static int wrc_dispatch_ptp_events_poll(void)
{ {
extern struct pp_instance ppi_static; extern struct pp_instance ppi_static;
struct pp_instance *ppi = &ppi_static; struct pp_instance *ppi = &ppi_static;
struct wr_servo_state *ss = &((struct wr_data *)ppi->ext_data)->servo_state; struct pp_servo *ss = SRV(ppi);//= &((struct wr_data *)ppi->ext_data)->servo_state;
int mode = wrc_ptp_get_mode(); int mode = wrc_ptp_get_mode();
...@@ -249,12 +247,12 @@ static int wrc_dispatch_ptp_events_poll(void) ...@@ -249,12 +247,12 @@ static int wrc_dispatch_ptp_events_poll(void)
{ {
if( ppi->state == PPS_SLAVE ) if( ppi->state == PPS_SLAVE )
{ {
if( ss->state == WR_TRACK_PHASE && prev_servo_state != WR_TRACK_PHASE ) if( ss->state == WRH_TRACK_PHASE && prev_servo_state != WRH_TRACK_PHASE )
{ {
prev_timing_ok = 1; prev_timing_ok = 1;
event_post( WRC_EVENT_TIMING_UP ); event_post( WRC_EVENT_TIMING_UP );
} }
else if( ss->state != WR_TRACK_PHASE && prev_servo_state == WR_TRACK_PHASE ) else if( ss->state != WRH_TRACK_PHASE && prev_servo_state == WRH_TRACK_PHASE )
{ {
prev_timing_ok = 0; prev_timing_ok = 0;
event_post( WRC_EVENT_TIMING_DOWN ); event_post( WRC_EVENT_TIMING_DOWN );
...@@ -282,6 +280,7 @@ static void create_tasks(void) ...@@ -282,6 +280,7 @@ static void create_tasks(void)
wrc_task_create( "check-link", NULL, wrc_check_link ); wrc_task_create( "check-link", NULL, wrc_check_link );
wrc_task_create( "uptime", init_uptime, update_uptime ); wrc_task_create( "uptime", init_uptime, update_uptime );
wrc_task_create( "ptp", NULL, wrc_ptp_update); wrc_task_create( "ptp", NULL, wrc_ptp_update);
wrc_task_create( "ptp_bmc", NULL, wrc_ptp_bmc_update);
wrc_task_create( "shell+gui", shell_boot_script, ui_update ); wrc_task_create( "shell+gui", shell_boot_script, ui_update );
wrc_task_create( "spll-bh", NULL, spll_update ); wrc_task_create( "spll-bh", NULL, spll_update );
wrc_task_create( "ptp-events", wrc_dispatch_ptp_events_init, wrc_dispatch_ptp_events_poll ); wrc_task_create( "ptp-events", wrc_dispatch_ptp_events_init, wrc_dispatch_ptp_events_poll );
...@@ -322,6 +321,11 @@ static void create_tasks(void) ...@@ -322,6 +321,11 @@ static void create_tasks(void)
#ifdef CONFIG_WR_DIAG #ifdef CONFIG_WR_DIAG
wrc_task_create( "diags", NULL, wrc_wr_diags ); wrc_task_create( "diags", NULL, wrc_wr_diags );
#endif #endif
#ifdef CONFIG_NETCONSOLE
t = wrc_task_create( "netconsole", netconsole_init, netconsole_poll );
wrc_task_set_enable( t, is_link_up );
#endif
} }
int main(void) __attribute__ ((weak)); int main(void) __attribute__ ((weak));
......
...@@ -103,8 +103,8 @@ static void wrc_sim_initialize(void) ...@@ -103,8 +103,8 @@ static void wrc_sim_initialize(void)
mac_addr[4] = 0xBA; mac_addr[4] = 0xBA;
mac_addr[5] = 0xBE; mac_addr[5] = 0xBE;
ep_init(mac_addr); ep_init(&wrc_endpoint_dev, (void *) BASE_EP);
ep_enable(1, 1); ep_enable(&wrc_endpoint_dev, 1, 1);
minic_init(); minic_init();
shw_pps_gen_init(); shw_pps_gen_init();
......
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