Commit ece127f9 authored by li hongming's avatar li hongming

add a new mode "cascaded" for dualport function.

    separate PPS_out with time_valid.
    Disable transmitting packets when link is not up.
parent 46d036c8
#
# Automatically generated make config: don't edit
# Automatically generated file; DO NOT EDIT.
# WR PTP Core software configuration
#
# CONFIG_WR_SWITCH is not set
CONFIG_WR_NODE=y
CONFIG_PPSI_FORCE_CONFIG=y
CONFIG_PRINT_BUFSIZE=128
CONFIG_PRINTF_XINT=y
CONFIG_RAMSIZE=131072
CONFIG_TEMP_POLL_INTERVAL=15
CONFIG_TEMP_HIGH_THRESHOLD=70
CONFIG_TEMP_HIGH_RAPPEL=60
# CONFIG_PLL_VERBOSE is not set
# CONFIG_PFILTER_VERBOSE is not set
# CONFIG_WRC_VERBOSE is not set
# CONFIG_VLAN is not set
CONFIG_VLAN_NR=0
CONFIG_VLAN_1_FOR_CLASS7=0
CONFIG_VLAN_2_FOR_CLASS7=0
CONFIG_VLAN_FOR_CLASS6=0
# CONFIG_HOST_PROCESS is not set
CONFIG_LM32=y
CONFIG_EMBEDDED_NODE=y
# CONFIG_WR_NODE_PCS16 is not set
CONFIG_STACKSIZE=2048
CONFIG_PPSI=y
CONFIG_UART=y
CONFIG_W1=y
CONFIG_ETHERBONE=y
CONFIG_WRNIC=y
CONFIG_LATENCY_ETHTYPE=291
# CONFIG_P2P is not set
CONFIG_IP=y
# CONFIG_CMD_CONFIG is not set
CONFIG_NIC_PFILTER=y
# CONFIG_SYSLOG is not set
CONFIG_SNMP=y
CONFIG_SNMP_SET=y
# CONFIG_BUILD_INIT is not set
CONFIG_INIT_COMMAND=""
CONFIG_HAS_BUILD_INIT=0
CONFIG_HAS_FLASH_INIT=1
CONFIG_FLASH_INIT=y
# CONFIG_AUX_DIAG is not set
CONFIG_SDB_STORAGE=y
CONFIG_GENSDBFS=y
# CONFIG_LEGACY_EEPROM is not set
# CONFIG_WR_DIAG is not set
# CONFIG_WR_NODE_SIM is not set
# CONFIG_ABSCAL is not set
# CONFIG_LLDP is not set
#
# wrpc-sw is tainted if you change the following options
#
CONFIG_DEVELOPER=y
# CONFIG_CMD_LL is not set
CONFIG_CMD_LL=y
# CONFIG_DAC_LOG is not set
# CONFIG_CHECK_RESET is not set
# CONFIG_SPLL_FIFO_LOG is not set
CONFIG_PRINTF_IS_XINT=y
# CONFIG_PRINTF_IS_FULL is not set
# CONFIG_PRINTF_IS_MINI is not set
# CONFIG_PRINTF_IS_NONE is not set
CONFIG_ASSERT=y
# CONFIG_DETERMINISTIC_BINARY is not set
# CONFIG_NET_VERBOSE is not set
# CONFIG_SNMP_VERBOSE is not set
# CONFIG_FAKE_TEMPERATURES is not set
# CONFIG_LATENCY_PROBE is not set
CONFIG_DEFAULT_PRINT_TASK_TIME_THRESHOLD=0
CONFIG_VLAN_ARRAY_SIZE=1
CONFIG_PRINTF_XINT=y
# CONFIG_PRINTF_FULL is not set
# CONFIG_PRINTF_MINI is not set
# CONFIG_PRINTF_NONE is not set
# CONFIG_DETERMINISTIC_BINARY is not set
# CONFIG_UART_SW is not set
# CONFIG_SDB_STORAGE is not set
CONFIG_LEGACY_EEPROM=y
CONFIG_VLAN_ARRAY_SIZE=1
......@@ -55,7 +55,7 @@ void sdb_print_devices(void)
/* To save a little size, we enumerate our vendors */
#define VID_CERN 0x0000ce42LL
#define VID_GSI 0x00000651LL
#define VID_THU 0x00001103LL
#define VID_THU 0x00746875LL
struct wrc_device {
unsigned char **base;
......
......@@ -195,8 +195,9 @@ int minic_rx_frame(struct wr_ethhdr *hdr, uint8_t * payload, uint32_t buf_size,
EXPLODE_WR_TIMESTAMP(raw_ts, counter_r, counter_f);
if (counter_r > 3 * REF_CLOCK_FREQ_HZ / 4
&& counter_ppsg < 250000000)
// if (counter_r > 3 * REF_CLOCK_FREQ_HZ / 4
// && counter_ppsg < 250000000)
if (counter_ppsg < counter_r*(REF_CLOCK_PERIOD_PS / 1000))
sec--;
hwts->sec = sec;
......
......@@ -70,14 +70,16 @@ void shw_pps_gen_set_time(uint64_t seconds, uint32_t nanoseconds, int counter)
{
ppsg_write(ADJ_UTCLO, (uint32_t) (seconds & 0xffffffffLL));
ppsg_write(ADJ_UTCHI, (uint32_t) (seconds >> 32) & 0xff);
if (counter == PPSG_SET_SEC)
ppsg_write(ESCR, (ppsg_read(ESCR) & 0xffffffe7) | PPSG_ESCR_SEC_SET);
return;
ppsg_write(ADJ_NSEC,
(int32_t) ((int64_t) nanoseconds * 1000LL /
(int64_t) REF_CLOCK_PERIOD_PS));
if (counter == PPSG_SET_ALL)
ppsg_write(CR, (ppsg_read(CR) & 0xfffffffb) | PPSG_CR_CNT_SET);
else if (counter == PPSG_SET_SEC)
ppsg_write(ESCR, (ppsg_read(ESCR) & 0xffffffe7) | PPSG_ESCR_SEC_SET);
else if (counter == PPSG_SET_NSEC)
ppsg_write(ESCR, (ppsg_read(ESCR) & 0xffffffe7) | PPSG_ESCR_NSEC_SET);
}
......@@ -127,10 +129,24 @@ int shw_pps_gen_enable_output(int enable)
uint32_t escr = ppsg_read(ESCR);
if (enable)
ppsg_write(ESCR,
escr | PPSG_ESCR_PPS_VALID | PPSG_ESCR_TM_VALID);
escr | PPSG_ESCR_PPS_VALID);
else
ppsg_write(ESCR,
escr & ~(PPSG_ESCR_PPS_VALID | PPSG_ESCR_TM_VALID));
escr & ~(PPSG_ESCR_PPS_VALID));
return 0;
}
/* Time valid or unvalid */
int shw_pps_gen_time_valid(int valid)
{
uint32_t escr = ppsg_read(ESCR);
if (valid)
ppsg_write(ESCR,
escr | PPSG_ESCR_TM_VALID);
else
ppsg_write(ESCR,
escr & ~(PPSG_ESCR_TM_VALID));
return 0;
}
......
......@@ -195,6 +195,7 @@ int rxts_calibration_update(uint32_t *t24p_value, int port)
int measure_t24p(uint32_t *value, int port)
{
int rv;
int retry_cnt;
pp_printf("Waiting for link...\n");
while (!ep_link_up(NULL, port))
timer_delay_ms(100);
......@@ -202,7 +203,12 @@ int measure_t24p(uint32_t *value, int port)
spll_init(SPLL_MODE_SLAVE, port, 1);
pp_printf("Locking PLL...\n");
while (!spll_check_lock(0))
{
timer_delay_ms(100);
retry_cnt++;
if (retry_cnt>400)
return -1;
}
pp_printf("\n");
pp_printf("Calibrating RX timestamper...\n");
......@@ -223,14 +229,6 @@ static int calib_t24p_master(uint32_t *value, int port)
return rv;
}
pp_printf("port %d t24p read from storage: %d ps\n", port,*value);
if ((*value)>100000)
{
pp_printf("Port %d Measuring t2/t4 phase transition...\n", port);
measure_t24p(value, port);
rv=storage_phtrans(value, 1, port);
pp_printf("Wrote new t24p value: %d ps (%s)\n", *value,
rv < 0 ? "Failed" : "Success");
}
return rv;
}
......
......@@ -4,8 +4,10 @@
#include "endpoint.h"
#include "arp.h"
#include "ptpd_netif.h"
#include "hw/tcpip-config.h"
#include "tcpip_config.h"
#include "lib/ipv4.h"
extern uint8_t tcpip_status = TCPIP_NULL;
......@@ -25,18 +27,16 @@ void tcpip_init(void)
uint8_t tmp_ip_addr[4];
if (!tcpip_present())
{
pp_printf("No TCPIP module is found!\n");
return;
}
get_mac_addr(tcpip_mac_addr, 0);
memcpy((uint8_t *)(BASE_TCPIP_CFG + TCPIP_MAC_HIGH16 + 2), (uint8_t *)tcpip_mac_addr, 2);
memcpy((uint8_t *)(BASE_TCPIP_CFG + TCPIP_MAC_LOW32), (uint8_t *)tcpip_mac_addr+2, 4);
// default udp tx dst/src port
tcpip_tx_dst_port(60000);
tcpip_tx_src_port(60000);
tcpip_tx_src_port(2000);
tcpip_tx_dst_port(2000);
// tcpip_rx_tcp_port(8000);
getIP(tmp_ip_addr, 0);
// tcpip module, default IP
......@@ -49,7 +49,6 @@ void tcpip_init(void)
// tcpip module, default subnet mask
tmp_ip_addr[0]=0xff;tmp_ip_addr[1]=0xff;tmp_ip_addr[2]=0xff;tmp_ip_addr[3]=0x00;
tcpip_subnet_addr(tmp_ip_addr);
}
void tcpip_ip_addr(uint8_t *ip)
......@@ -113,30 +112,37 @@ void tcpip_get_hisMAC(uint8_t mac_addr[])
memcpy(mac_addr+2, (uint8_t *)(BASE_TCPIP_CFG + TCPIP_UDP_TX_DST_MAC_LOW32), 4);
}
void tcpip_rx_tcp_port(uint16_t port)
{
volatile unsigned int *rtp =
(unsigned int *)(BASE_TCPIP_CFG + TCPIP_TCP_LOCAL_PORT);
*rtp = (uint32_t)port;
}
// void tcpip_rx_tcp_port(uint16_t port)
// {
// volatile unsigned int *rtp =
// (unsigned int *)(BASE_TCPIP_CFG + TCPIP_TCP_LOCAL_PORT);
// *rtp = (uint32_t)port;
// }
uint8_t tcpip_poll()
{
uint8_t * ip;
static uint16_t arp_count = 0;
static uint32_t last_jiffies;
if (tcpip_status == TCPIP_OK)
if (link_status[0]!=LINK_UP)
return 0;
if (tcpip_status == TCPIP_ARP)
arp_count++;
if(ip_status == IP_TRAINING)
return 0;
if (tcpip_status != TCPIP_ARP)
return 0;
if (!last_jiffies)
last_jiffies = timer_get_tics() - 1 - TICS_PER_SECOND;
if (arp_count<65530)
if (time_before(timer_get_tics(), last_jiffies + TICS_PER_SECOND))
return 0;
last_jiffies = timer_get_tics();
tcpip_get_hisIP(ip);
send_arp(ip, 0);
arp_count=0;
return 1;
}
......
......@@ -31,7 +31,7 @@
#define UART_BAUDRATE 115200ULL
/* Maximum number of simultaneously created sockets */
#define NET_MAX_SOCKETS 12
#define NET_MAX_SOCKETS 8
/* Socket buffer size, determines the max. RX packet size */
#define NET_MAX_SKBUF_SIZE 512
......
......@@ -18,8 +18,8 @@
#define TCPIP_GATEWAY 28
#define TCPIP_SUBNET_MASK 32
#define TCPIP_UDP_RX_PORT 36
#define TCPIP_UDP_TX_SRC_PORT 40
#define TCPIP_UDP_TX_DST_PORT 44
#define TCPIP_UDP_TX_DST_PORT 40
#define TCPIP_UDP_TX_SRC_PORT 44
#define TCPIP_UDP_TX_DST_IP 48
#define TCPIP_UDP_TX_DST_MAC_HIGH16 52
#define TCPIP_UDP_TX_DST_MAC_LOW32 56
......
......@@ -26,6 +26,9 @@ int shw_pps_gen_busy(void);
/* Enables/disables PPS Generator PPS output */
int shw_pps_gen_enable_output(int enable);
/* Time valid */
int shw_pps_gen_time_valid(int valid);
/* Masks/unmasks PPS output when link is down (useful in master mode) */
int shw_pps_gen_unmask_output(int unmask);
......
......@@ -3,6 +3,7 @@
#include <stdint.h>
void tcpip_init(void);
void tcpip_ip_addr(uint8_t *ip);
void tcpip_gateway_addr(uint8_t *gw);
void tcpip_subnet_addr(uint8_t *sn);
......
......@@ -86,4 +86,7 @@ extern uint32_t __div64_32(uint64_t *n, uint32_t base);
#define wr_num_ports 1
#endif
// pps delay between ext pps in and pps out
int ext_pps_latency_ps;
#endif /* __WRC_H__ */
......@@ -6,6 +6,7 @@
#define WRC_MODE_MASTER 2
#define WRC_MODE_SLAVE 3
#define WRC_MODE_ABSCAL 4
#define WRC_MODE_CASCADED 5
extern int ptp_mode[wr_num_ports];
......
......@@ -38,11 +38,23 @@ static void arp_init(void)
PTPD_SOCK_RAW_ETHERNET, 0, port);
}
static int process_arp(uint8_t * buf, int len)
static void dp_arp_init(void)
{
struct wr_sockaddr saddr;
int port=1;
/* Configure socket filter */
memset(&saddr, 0, sizeof(saddr));
// memset(&saddr.mac, 0xFF, 6); /* Broadcast */
saddr.ethertype = htons(0x0806); /* ARP */
arp_socket[port] = ptpd_netif_create_socket(&__static_arp_socket[port], &saddr,
PTPD_SOCK_RAW_ETHERNET, 0, port);
}
static int process_arp(uint8_t * buf, int len, int port)
{
uint8_t hisMAC[6];
uint8_t hisIP[4];
int port=0;
uint8_t myIP[2][4];
if (len < ARP_END)
......@@ -69,7 +81,7 @@ static int process_arp(uint8_t * buf, int len)
buf[ARP_OPER + 0] = 0;
buf[ARP_OPER + 1] = 2;
// my MAC
get_mac_addr(buf + ARP_SHA, 0);
get_mac_addr(buf + ARP_SHA, port);
for (port = 0; port < wr_num_ports; ++port)
{
......@@ -105,14 +117,36 @@ static int arp_poll(void)
int port=0;
int ret;
if (ip_status[port] == IP_TRAINING)
return 0; /* can't do ARP w/o an address... */
if ((link_status[port]!=LINK_UP) || (ip_status[port] == IP_TRAINING))
return 0;
ret = 0;
if ((len = ptpd_netif_recvfrom(arp_socket[port],
&addr, buf, sizeof(buf), 0, port)) > 0)
{
if ((len = process_arp(buf, len, port)) > 0)
ptpd_netif_sendto(arp_socket[port], &addr, buf, len, 0, port);
ret = 1;
}
return ret;
}
static int dp_arp_poll(void)
{
uint8_t buf[ARP_END + 100];
struct wr_sockaddr addr;
int len;
int port=1;
int ret;
if ((link_status[port]!=LINK_UP) || (ip_status[port] == IP_TRAINING))
return 0;
ret = 0;
if ((len = ptpd_netif_recvfrom(arp_socket[port],
&addr, buf, sizeof(buf), 0, port)) > 0)
{
if ((len = process_arp(buf, len)) > 0)
if ((len = process_arp(buf, len, port)) > 0)
ptpd_netif_sendto(arp_socket[port], &addr, buf, len, 0, port);
ret = 1;
}
......@@ -153,3 +187,10 @@ DEFINE_WRC_TASK(arp) = {
.init = arp_init,
.job = arp_poll,
};
DEFINE_WRC_TASK(dp_arp) = {
.name = "dp-arp",
.enable = &(link_status[1]),
.init = dp_arp_init,
.job = dp_arp_poll,
};
......@@ -86,24 +86,24 @@ static void ipv4_init(void)
int port=0;
/* Bootp: use UDP engine activated by function arguments */
bootp_socket = ptpd_netif_create_socket(&__static_bootp_socket, NULL,
PTPD_SOCK_UDP, 68 /* bootpc */, 0);
// bootp_socket = ptpd_netif_create_socket(&__static_bootp_socket, NULL,
// PTPD_SOCK_UDP, 68 /* bootpc */, port);
/* time (rdate): UDP */
rdate_socket = ptpd_netif_create_socket(&__static_rdate_socket, NULL,
PTPD_SOCK_UDP, 37 /* time */, 0);
PTPD_SOCK_UDP, 37 /* time */, port);
/* remote update (remote_update): UDP */
remote_update_socket = ptpd_netif_create_socket(&__static_remote_update_socket, NULL,
PTPD_SOCK_UDP, 71 /* remote update */, 0);
PTPD_SOCK_UDP, 71 /* remote update */, port);
/* ICMP: specify raw (not UDP), with IPV4 ethtype */
memset(&saddr, 0, sizeof(saddr));
saddr.ethertype = htons(0x0800);
// All SNMPs go through port 0
icmp_socket[0] = ptpd_netif_create_socket(&__static_icmp_socket[0], &saddr,
PTPD_SOCK_RAW_ETHERNET, 0, 0);
syslog_init();
icmp_socket[port] = ptpd_netif_create_socket(&__static_icmp_socket[port], &saddr,
PTPD_SOCK_RAW_ETHERNET, 0, port);
// syslog_init();
}
static int bootp_retry = 0;
......@@ -137,21 +137,18 @@ static int icmp_poll()
{
struct wr_sockaddr addr;
uint8_t buf[128];
int len;
int port=0;
int len;
len = ptpd_netif_recvfrom(icmp_socket[0], &addr,
buf, sizeof(buf), NULL, 0);
len = ptpd_netif_recvfrom(icmp_socket[port], &addr,
buf, sizeof(buf), NULL, port);
if (len <= 0)
return 0;
/* check the destination IP */
for (port= 0;port<wr_num_ports;++port)
{
if(check_dest_ip(buf, port)==0){
if ((len = process_icmp(buf, len, port)) > 0)
ptpd_netif_sendto(icmp_socket[0], &addr, buf, len, 0, 0);
return 1;
}
if(check_dest_ip(buf, port)==0){
if ((len = process_icmp(buf, len, port)) > 0)
ptpd_netif_sendto(icmp_socket[port], &addr, buf, len, 0, port);
return 1;
}
return 0;
}
......@@ -192,6 +189,7 @@ static int remote_update_poll(void)
int len;
uint32_t type;
uint32_t data_addr;
static uint32_t prog_data_addr;
uint8_t* reg_addr;
int data_size;
int port;
......@@ -201,7 +199,6 @@ static int remote_update_poll(void)
if (len <= 0)
return 0;
/* check the destination IP */
if (check_dest_ip(buf, 0))
return 0;
......@@ -209,14 +206,14 @@ static int remote_update_poll(void)
if (check_magic_udp(buf)<0)
{
// magic data error
memset(buf+UDP_END, 0x00000001, 4);
len = UDP_END + 4 + 64;
memset(buf+UDP_END, 0xfe, 1);
len = UDP_END + 12 + 64;
}
else if (check_magic_udp(buf)>0)
{
// udp checksum err
memset(buf+UDP_END, 0xffff0000, 4);
len = UDP_END + 4 + 64;
memset(buf+UDP_END, 0xff, 1);
len = UDP_END + 12 + 64;
return 0;
}
else
......@@ -225,19 +222,30 @@ static int remote_update_poll(void)
switch(type)
{
case FLASH_ERASE:
wrc_ptp_set_mode(WRC_MODE_MASTER, 0);
for (port = 0; port < wr_num_ports; ++port)
wrc_ptp_run(0,port);
data_addr = (buf[UDP_END+8]<<24)+(buf[UDP_END+9]<<16)+(buf[UDP_END+10]<<8)+buf[UDP_END+11];
data_size = (buf[UDP_END+12]<<24)+(buf[UDP_END+13]<<16)+(buf[UDP_END+14]<<8)+buf[UDP_END+15];
flash_erase(data_addr,data_size);
memset(buf+UDP_END+12, 0x00000000, 4);
len = UDP_END + 16 + 64;
prog_data_addr = data_addr;
memset(buf+UDP_END, 0x00, 1);
len = UDP_END + 12 + 64;
break;
case FLASH_WRITE:
data_addr = (buf[UDP_END+8]<<24)+(buf[UDP_END+9]<<16)+(buf[UDP_END+10]<<8)+buf[UDP_END+11];
data_size = (buf[UDP_END+12]<<24)+(buf[UDP_END+13]<<16)+(buf[UDP_END+14]<<8)+buf[UDP_END+15];
flash_write(data_addr,buf+UDP_END+16,data_size);
memset(buf+UDP_END+12, 0x00000000, 4);
len = UDP_END + 16 + 64 ;
if (prog_data_addr==data_addr)
{
flash_write(data_addr,buf+UDP_END+16,data_size);
prog_data_addr=prog_data_addr+256;
memset(buf+UDP_END, 0x00, 1);
} else {
pp_printf("Prog addr error %x\n",data_addr);
// reply lose error
memset(buf+UDP_END, 0xfd, 1);
}
len = UDP_END + 12 + 64 ;
break;
case FLASH_READ:
data_addr = (buf[UDP_END+8]<<24)+(buf[UDP_END+9]<<16)+(buf[UDP_END+10]<<8)+buf[UDP_END+11];
......@@ -259,8 +267,8 @@ static int remote_update_poll(void)
len = UDP_END + 16 + data_size + 64;
break;
default:
// type error
memset(buf+UDP_END, 0x00000002, 4);
// operation type error
memset(buf+UDP_END, 0xfc, 1);
len = UDP_END + 4 + 64;
}
}
......@@ -274,9 +282,10 @@ static int ipv4_poll(void)
{
int ret = 0;
if (link_status[0] == LINK_WENT_UP && ip_status[0] == IP_OK_BOOTP)
ip_status[0] = IP_TRAINING;
ret = bootp_poll();
if (link_status[0]!=LINK_UP)
return 0;
// ret = bootp_poll();
ret += icmp_poll();
......@@ -284,7 +293,19 @@ static int ipv4_poll(void)
ret += remote_update_poll();
ret += syslog_poll();
// ret += syslog_poll();
return ret != 0;
}
static int dp_ipv4_poll(void)
{
int ret = 0;
if (link_status[1]!=LINK_UP)
return 0;
ret = dp_icmp_poll();
return ret != 0;
}
......@@ -296,7 +317,7 @@ void getIP(unsigned char *IP, int port)
DEFINE_WRC_TASK(ipv4) = {
.name = "ipv4",
.enable = &link_status[0],
.enable = &(link_status[0]),
.init = ipv4_init,
.job = ipv4_poll,
};
......
......@@ -219,6 +219,9 @@ static int latency_poll_tx(void)
* Send three frames -- lazily in native byte order. Possibly
* subtract a fake delay, to trigger reporting.
*/
if (link_status[0]!=LINK_UP)
return 0;
memset(&frame, 0, sizeof(frame));
frame.sequence = sequence++;
......@@ -274,7 +277,7 @@ static int latency_poll(void)
return latency_poll_tx();
}
DEFINE_WRC_TASK(uptime) = {
DEFINE_WRC_TASK(latency) = {
.name = "latency-probe",
.init = latency_init,
.job = latency_poll,
......
......@@ -245,6 +245,9 @@ static int lldp_poll(void)
uint8_t new_mac[ETH_ALEN];
static uint8_t old_mac[ETH_ALEN];
if (link_status[0]!=LINK_UP)
return 0;
/* periodic tasks */
if (ticks > LLDP_TX_TICK_INTERVAL) {
get_mac_addr(new_mac);
......
......@@ -62,9 +62,9 @@ struct wrpc_socket *ptpd_netif_create_socket(struct wrpc_socket *sock,
pp_printf("%s: no socket slots left\n", __func__);
return NULL;
}
net_verbose("%s: socket %p for %04x:%04x, slot %i\n", __func__,
net_verbose("%s: socket %p for %04x:%04x, slot %i, port %d\n", __func__,
sock, ntohs(bind_addr->ethertype),
udpport, i);
udpport, i, port);
switch(port){
case 0: port_name="wr0";break;
......@@ -321,7 +321,7 @@ static int update_rx_queues()
int recvd, i, q_required;
static uint8_t buffer[NET_MAX_SKBUF_SIZE - 32];
uint8_t *payload = buffer;
uint16_t size, port;
uint16_t size, udpport;
uint16_t ethtype, tag;
recvd =
......@@ -349,9 +349,9 @@ static int update_rx_queues()
/* Prepare for IP/UDP checks */
if (payload[IP_VERSION] == 0x45 && payload[IP_PROTOCOL] == 17)
port = payload[UDP_DPORT] << 8 | payload[UDP_DPORT + 1];
udpport = payload[UDP_DPORT] << 8 | payload[UDP_DPORT + 1];
else
port = 0;
udpport = 0;
for (i = 0; i < ARRAY_SIZE(socks[0]); i++) {
s = socks[0][i];
......@@ -359,9 +359,9 @@ static int update_rx_queues()
continue;
if (hdr.ethtype != s->bind_addr.ethertype)
continue;
if (!port && !s->bind_addr.udpport)
if (!udpport && !s->bind_addr.udpport)
raws = s; /* match with raw socket */
if (port && s->bind_addr.udpport == port)
if (udpport && s->bind_addr.udpport == udpport)
udps = s; /* match with udp socket */
}
s = udps;
......@@ -413,7 +413,7 @@ static int update_dp_rx_queues(void)
int recvd, i, q_required;
static uint8_t buffer[NET_MAX_SKBUF_SIZE - 32];
uint8_t *payload = buffer;
uint16_t size, port;
uint16_t size, udpport;
uint16_t ethtype, tag;
recvd = minic_rx_frame(&hdr, buffer, sizeof(buffer), &hwts, 1);
......@@ -438,9 +438,9 @@ static int update_dp_rx_queues(void)
/* Prepare for IP/UDP checks */
if (payload[IP_VERSION] == 0x45 && payload[IP_PROTOCOL] == 17)
port = payload[UDP_DPORT] << 8 | payload[UDP_DPORT + 1];
udpport = payload[UDP_DPORT] << 8 | payload[UDP_DPORT + 1];
else
port = 0;
udpport = 0;
for (i = 0; i < ARRAY_SIZE(socks[1]); i++) {
s = socks[1][i];
......@@ -448,9 +448,9 @@ static int update_dp_rx_queues(void)
continue;
if (hdr.ethtype != s->bind_addr.ethertype)
continue;
if (!port && !s->bind_addr.udpport)
if (!udpport && !s->bind_addr.udpport)
raws = s; /* match with raw socket */
if (port && s->bind_addr.udpport == port)
if (udpport && s->bind_addr.udpport == udpport)
udps = s; /* match with udp socket */
}
s = udps;
......
......@@ -43,11 +43,10 @@ int wrpc_get_port_state(struct hal_port_state *state, const char *port_name)
int port = atoi(&port_name[2]);
int wrc_mode = wrc_ptp_get_mode(port);
if(port == 0)
if(wrc_mode == WRC_MODE_SLAVE)
state->mode = HEXP_PORT_MODE_WR_SLAVE;
else
state->mode = HEXP_PORT_MODE_WR_MASTER;
if(wrc_mode == WRC_MODE_SLAVE)
state->mode = HEXP_PORT_MODE_WR_SLAVE;
else
state->mode = HEXP_PORT_MODE_WR_MASTER;
/* all deltas are added anyway */
ep_get_deltas(&state->calib.delta_tx_board, &state->calib.delta_rx_board, port);
......
......@@ -1653,6 +1653,9 @@ static int snmp_poll(void)
uint8_t buf[200];
int len;
if (link_status[0]!=LINK_UP)