Commit 3bec63dd authored by li hongming's avatar li hongming

Add CONFIG parameters CONFIG_DUALPORT

parent d6a1db54
......@@ -44,6 +44,7 @@ CONFIG_GENSDBFS=y
# CONFIG_WR_DIAG is not set
# CONFIG_WR_NODE_SIM is not set
# CONFIG_ABSCAL is not set
CONFIG_DUALPORT=y
# CONFIG_LLDP is not set
#
......
......@@ -297,6 +297,15 @@ config ABSCAL
using a loop-back SFP adapter, according to the procedure
described and documented by Peter Jansweijer.
config DUALPORT
depends on WR_NODE
default y
boolean "Support dualport function"
help
If you select this, the node could support second WR port and a
cascaded WR link could be built. In future, the second WR port
could act as back up port.
config LLDP
depends on WR_NODE
boolean "Include LLDP protocol transmit-only"
......
......@@ -9,6 +9,7 @@ endif
export CROSS_COMPILE
export CONFIG_ABSCAL
export CONFIG_DUALPORT
CC = $(CROSS_COMPILE)gcc
LD = $(CROSS_COMPILE)ld
......
......@@ -46,6 +46,7 @@ CONFIG_GENSDBFS=y
# CONFIG_WR_DIAG is not set
# CONFIG_WR_NODE_SIM is not set
CONFIG_ABSCAL=y
CONFIG_DUALPORT=y
#
# wrpc-sw is tainted if you change the following options
......
......@@ -45,6 +45,7 @@ CONFIG_GENSDBFS=y
# CONFIG_WR_DIAG is not set
# CONFIG_WR_NODE_SIM is not set
CONFIG_ABSCAL=y
CONFIG_DUALPORT=y
#
# wrpc-sw is tainted if you change the following options
......
......@@ -45,6 +45,7 @@ CONFIG_GENSDBFS=y
# CONFIG_WR_DIAG is not set
# CONFIG_WR_NODE_SIM is not set
CONFIG_ABSCAL=y
CONFIG_DUALPORT=y
#
# wrpc-sw is tainted if you change the following options
......
......@@ -42,6 +42,7 @@ CONFIG_GENSDBFS=y
CONFIG_WR_DIAG=y
# CONFIG_WR_NODE_SIM is not set
CONFIG_ABSCAL=y
CONFIG_DUALPORT=y
CONFIG_LLDP=y
#
......
......@@ -42,6 +42,7 @@ CONFIG_GENSDBFS=y
CONFIG_WR_DIAG=y
# CONFIG_WR_NODE_SIM is not set
CONFIG_ABSCAL=y
CONFIG_DUALPORT=y
CONFIG_LLDP=y
#
......
......@@ -41,6 +41,7 @@ CONFIG_GENSDBFS=y
# CONFIG_WR_DIAG is not set
# CONFIG_WR_NODE_SIM is not set
CONFIG_ABSCAL=y
CONFIG_DUALPORT=y
#
# wrpc-sw is tainted if you change the following options
......
......@@ -41,6 +41,7 @@ CONFIG_GENSDBFS=y
# CONFIG_WR_DIAG is not set
CONFIG_WR_NODE_SIM=y
CONFIG_ABSCAL=y
CONFIG_DUALPORT=y
#
# wrpc-sw is tainted if you change the following options
......
......@@ -6,13 +6,12 @@
*
* Released according to the GNU GPL, version 2 or any later version.
*/
#include <wrc.h>
#define SDBFS_BIG_ENDIAN
#include <libsdbfs.h>
/* The following pointers are exported */
unsigned char *BASE_MINIC[wr_num_ports];
unsigned char *BASE_EP[wr_num_ports];
unsigned char *BASE_MINIC[2];
unsigned char *BASE_EP[2];
unsigned char *BASE_SOFTPLL;
unsigned char *BASE_PPS_GEN;
unsigned char *BASE_SYSCON;
......@@ -66,9 +65,11 @@ struct wrc_device {
struct wrc_device devs[] = {
{&BASE_MINIC[0], VID_CERN, 0xab28633a},
{&BASE_MINIC[1], VID_CERN, 0xa224633b},
{&BASE_EP[0], VID_CERN, 0x650c2d4f},
#ifdef CONFIG_DUALPORT
{&BASE_MINIC[1], VID_CERN, 0xa224633b},
{&BASE_EP[1], VID_CERN, 0x650c2d4e},
#endif
{&BASE_SOFTPLL, VID_CERN, 0x65158dc0},
{&BASE_PPS_GEN, VID_CERN, 0xde0d8ced},
{&BASE_SYSCON, VID_CERN, 0xff07fc47},
......
......@@ -72,9 +72,7 @@ void get_mac_addr(uint8_t dev_addr[], int port)
void ep_init(uint8_t mac_addr[], int port)
{
EP[port] = (volatile struct EP_WB *)BASE_EP[port];
pp_printf("Port %d address is %x", port, EP[port]);
set_mac_addr(mac_addr,port);
pp_printf("Port %d address is %x", port, EP[port]);
ep_sfp_enable(1,port);
if (!IS_WR_NODE_SIM){
......
......@@ -44,7 +44,7 @@ struct wr_minic {
int tx_count, rx_count;
};
extern struct wr_minic minic[2];
extern struct wr_minic minic[wr_num_ports];
int minic_rx_frame(struct wr_ethhdr *hdr, uint8_t * payload, uint32_t buf_size,
struct hw_timestamp *hwts, int port);
......
......@@ -18,7 +18,7 @@
#define PTPD_SOCK_UDP 0 /* wrong name, it should be "WRPC" */
#define PTPD_SOCK_RAW_ETHERNET 1 /* but used in ppsi, which I won't change */
extern uint8_t link_status[2];
extern uint8_t link_status[wr_num_ports];
#define LINK_DOWN 0
#define LINK_WENT_UP 1
#define LINK_WENT_DOWN 2
......
......@@ -52,7 +52,7 @@
#define HAS_GENSDBFS 0
#endif
extern uint32_t cal_phase_transition[2];
extern uint32_t cal_phase_transition[wr_num_ports];
extern uint8_t has_eeprom;
struct s_sfpinfo {
......
......@@ -80,6 +80,10 @@ void rtipc_action(void);
extern uint32_t __div64_32(uint64_t *n, uint32_t base);
// CUTE DP
#define wr_num_ports 2
#ifdef CONFIG_DUALPORT
#define wr_num_ports 2
#else
#define wr_num_ports 1
#endif
#endif /* __WRC_H__ */
......@@ -85,12 +85,13 @@ unsigned int ipv4_checksum(unsigned short *buf, int shorts)
static void ipv4_init(void)
{
struct wr_sockaddr saddr;
int port;
/* Bootp: use UDP engine activated by function arguments */
bootp_socket[0] = ptpd_netif_create_socket(&__static_bootp_socket[0], NULL,
PTPD_SOCK_UDP, 68 /* bootpc */, 0);
bootp_socket[1] = ptpd_netif_create_socket(&__static_bootp_socket[1], NULL,
PTPD_SOCK_UDP, 68 /* bootpc */, 1);
for (port=0; port < wr_num_ports; ++port) {
bootp_socket[port] = ptpd_netif_create_socket(&__static_bootp_socket[0], NULL,
PTPD_SOCK_UDP, 68 /* bootpc */, port);
}
/* time (rdate): UDP */
rdate_socket = ptpd_netif_create_socket(&__static_rdate_socket, NULL,
......@@ -103,10 +104,10 @@ static void ipv4_init(void)
/* ICMP: specify raw (not UDP), with IPV4 ethtype */
memset(&saddr, 0, sizeof(saddr));
saddr.ethertype = htons(0x0800);
icmp_socket[0] = ptpd_netif_create_socket(&__static_icmp_socket[0], &saddr,
PTPD_SOCK_RAW_ETHERNET, 0, 0);
icmp_socket[1] = ptpd_netif_create_socket(&__static_icmp_socket[1], &saddr,
PTPD_SOCK_RAW_ETHERNET, 0, 1);
for (port=0; port < wr_num_ports; ++port) {
icmp_socket[port] = ptpd_netif_create_socket(&__static_icmp_socket[0], &saddr,
PTPD_SOCK_RAW_ETHERNET, 0, port);
}
syslog_init();
}
......
......@@ -66,7 +66,11 @@ struct wrpc_socket *ptpd_netif_create_socket(struct wrpc_socket *sock,
sock, ntohs(bind_addr->ethertype),
udpport, i);
port_name = (port) ? "wr0" : "wr1";
switch(port){
case 0: port_name="wr0";break;
case 1: port_name="wr1";break;
default:port_name="wr0";
};
if (wrpc_get_port_state(&pstate, port_name) < 0)
return NULL;
......
ppsi @ f13b2ae9
Subproject commit 61d931c09fc567f374621bc624f29ba2cd78c543
Subproject commit f13b2ae9628ca46cd20efc8bbf42657baeee511a
......@@ -17,6 +17,10 @@ struct subcmd {
} subcmd[] = {
{"start", wrc_ptp_run, 1},
{"stop", wrc_ptp_run, 0},
#ifdef CONFIG_DUALPORT
{"start1", wrc_ptp_run, 3},
{"stop1", wrc_ptp_run, 2},
#endif
{"e2e", wrc_ptp_sync_mech, PP_E2E_MECH},
{"delay", wrc_ptp_sync_mech, PP_E2E_MECH},
#ifdef CONFIG_P2P
......@@ -31,7 +35,13 @@ struct subcmd {
#endif
};
#ifdef CONFIG_DUALPORT
static char *is_run[] = {"Port 0&1 stopped", "Port 0 running, Port 1 stopped",
"Port 0 stopped, Port 1 running","Port 0&1 running"};
#else
static char *is_run[] = {"stopped", "running"};
#endif
static char *is_mech[] = {[PP_E2E_MECH] = "e2e", [PP_P2P_MECH] = "p2p"};
static char *is_mode[] = {[WRC_MODE_GM] = "gm", [WRC_MODE_MASTER] = "master",
[WRC_MODE_SLAVE] = "slave"
......
......@@ -99,18 +99,15 @@ static void wrc_initialize(void)
mac_addr[1][5]=mac_addr[0][5];
}
pp_printf("PORT 0 Local MAC address: %02x:%02x:%02x:%02x:%02x:%02x\n",
mac_addr[0][0], mac_addr[0][1], mac_addr[0][2], mac_addr[0][3],
mac_addr[0][4], mac_addr[0][5]);
pp_printf("PORT 1 Local MAC address: %02x:%02x:%02x:%02x:%02x:%02x\n",
mac_addr[1][0], mac_addr[1][1], mac_addr[1][2], mac_addr[1][3],
mac_addr[1][4], mac_addr[1][5]);
net_rst();
//Duplicate the configuration for both ports.
for (port=0; port<wr_num_ports;port++)
{
pp_printf("PORT %d Local MAC address: %02x:%02x:%02x:%02x:%02x:%02x\n", port,
mac_addr[port][0], mac_addr[port][1], mac_addr[port][2], mac_addr[port][3],
mac_addr[port][4], mac_addr[port][5]);
ep_init(mac_addr[port], port);
/* Sleep for 1s to make sure WRS v4.2 always realizes that
* the link is down */
......@@ -133,8 +130,9 @@ static void wrc_initialize(void)
_endram = ENDRAM_MAGIC;
wrc_ptp_set_mode(WRC_MODE_SLAVE);
wrc_ptp_start(0);
wrc_ptp_start(1);
for (port=0; port<wr_num_ports;port++) {
wrc_ptp_start(port);
}
shw_pps_gen_get_time(NULL, &prev_nanos_for_profile);
/* get tics */
prev_ticks_for_profile = timer_get_tics();
......@@ -149,50 +147,41 @@ uint8_t link_status[wr_num_ports];
static int wrc_check_link(void)
{
static int prev_state[wr_num_ports] = {-1,-1};
static int prev_state[] = {-1,-1};
int state[wr_num_ports];
int rv = 0;
int port;
for(port=0; port<wr_num_ports; port++)
for(port=0; port<wr_num_ports; port++) {
state[port] = ep_link_up(NULL, port);
if (!prev_state[0] && state[0]) {
wrc_verbose("Port 0 Link up.\n");
gpio_out(GPIO_LED_LINK, 1);
sfp_match(0);
wrc_ptp_start(0);
link_status[0] = LINK_WENT_UP;
rv = 1;
} else if (prev_state[0] && !state[0]) {
wrc_verbose("Port 0 Link down.\n");
gpio_out(GPIO_LED_LINK, 0);
link_status[0] = LINK_WENT_DOWN;
wrc_ptp_stop(0);
rv = 1;
/* special case */
spll_init(SPLL_MODE_FREE_RUNNING_MASTER, 0, 1);
shw_pps_gen_enable_output(0);
} else
link_status[0] = (state[0] ? LINK_UP : LINK_DOWN);
prev_state[0] = state[0];
if (!prev_state[1] && state[1]) {
wrc_verbose("Port 1 Link up.\n");
gpio_out(GPIO_DP_LED_LINK, 1);
sfp_match(1);
wrc_ptp_start(1);
link_status[1] = LINK_WENT_UP;
rv = 1;
} else if (prev_state[1] && !state[1]) {
wrc_verbose("Port 1 Link down.\n");
gpio_out(GPIO_DP_LED_LINK, 1);
link_status[1] = LINK_WENT_DOWN;
wrc_ptp_stop(1);
rv = 1;
} else
link_status[1] = (state[1] ? LINK_UP : LINK_DOWN);
prev_state[1] = state[1];
if (!prev_state[port] && state[port]) {
wrc_verbose("Port 0 Link up.\n");
if (port==0)
gpio_out(GPIO_LED_LINK, 1);
else
gpio_out(GPIO_DP_LED_LINK, 1);
sfp_match(port);
wrc_ptp_start(port);
link_status[port] = LINK_WENT_UP;
rv = 1;
} else if (prev_state[port] && !state[port]) {
wrc_verbose("Port %d Link down.\n",port);
if (port==0)
gpio_out(GPIO_LED_LINK, 0);
else
gpio_out(GPIO_DP_LED_LINK, 0);
link_status[port] = LINK_WENT_DOWN;
wrc_ptp_stop(port);
rv = 1;
/* special case */
if (port==0) {
spll_init(SPLL_MODE_FREE_RUNNING_MASTER, 0, 1);
shw_pps_gen_enable_output(0);
}
} else
link_status[port] = (state[port] ? LINK_UP : LINK_DOWN);
prev_state[port] = state[port];
}
return rv;
}
......
......@@ -84,8 +84,8 @@ static void wrc_sim_initialize(void)
// uncomment the following line to perform a dynamic search
// at runtime.
//sdb_find_devices();
BASE_MINIC = (void *)0x20000;
BASE_EP = (void *)0x20100;
BASE_MINIC[0] = (void *)0x20000;
BASE_EP[0] = (void *)0x20100;
BASE_SOFTPLL = (void *)0x20200;
BASE_PPS_GEN = (void *)0x20300;
BASE_SYSCON = (void *)0x20400;
......
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