Commit e73b898a authored by Grzegorz Daniluk's avatar Grzegorz Daniluk

bring back IP support

parent d6f4484c
Pipeline #285 failed with stages
in 9 seconds
......@@ -98,6 +98,8 @@ int board_update(void);
#define HAS_ABSCAL 0
#endif
#define HAS_EB 0
#undef CONFIG_DISALLOW_LONG_DIVISION
#define BOARD_MAX_CONSOLE_DEVICES 1
......
......@@ -67,6 +67,8 @@ int board_update(void);
#define HAS_IP 0
#endif
#define HAS_EB 0
#define ERTM14_MAX_CONFIGS 8
extern unsigned char *BASE_MINIC;
......
......@@ -18,7 +18,7 @@
#define BASE_SYSCON 0x20400
#define BASE_UART 0x20500
#define BASE_ONEWIRE 0x20600
//#define BASE_ETHERNOBE_CFG 0x20700
#define BASE_ETHERBONE_CFG 0x20700
/* Board-specific parameters */
#define TICS_PER_SECOND 1000
......@@ -71,6 +71,8 @@
#define HAS_ABSCAL 0
#endif
#define HAS_EB 1
#define CONFIG_DISALLOW_LONG_DIVISION
#define BOARD_MAX_CONSOLE_DEVICES 1
......
......@@ -64,6 +64,8 @@
#define HAS_ABSCAL 0
#endif
#define HAS_EB 0
#define CONFIG_DISALLOW_LONG_DIVISION
#define BOARD_MAX_CONSOLE_DEVICES 1
......
......@@ -34,5 +34,6 @@ struct wrc_task *wrc_task_get(int tid);
void wrc_start_all_tasks(void);
void wrc_poll_all_tasks(void);
void wrc_tasks_accounting_init(void);
int wrc_task_not_yet(uint32_t *lastt, unsigned period);
#endif /* __WRC_TASK_H__ */
......@@ -10,7 +10,7 @@
#include <wrpc.h>
#include <string.h>
#include "endpoint.h"
#include "dev/endpoint.h"
#include "ipv4.h"
#include "ptpd_netif.h"
......@@ -77,7 +77,7 @@ static int process_arp(uint8_t * buf, int len)
buf[ARP_OPER + 0] = 0;
buf[ARP_OPER + 1] = 2;
// my MAC+IP
get_mac_addr(buf + ARP_SHA);
ep_get_mac_addr(buf + ARP_SHA);
memcpy(buf + ARP_SPA, myIP, 4);
// his MAC+IP
memcpy(buf + ARP_THA, hisMAC, 6);
......
......@@ -8,7 +8,7 @@
*/
#include <string.h>
#include <wrc.h>
#include "endpoint.h"
#include "dev/endpoint.h"
#include "ipv4.h"
......@@ -40,7 +40,7 @@ int prepare_bootp(struct wr_sockaddr *addr, uint8_t * buf, int retry)
buf[BOOTP_HOPS] = 0;
/* A unique identifier for the request !!! FIXME */
get_mac_addr(buf + BOOTP_XID);
ep_get_mac_addr(buf + BOOTP_XID);
buf[BOOTP_XID + 0] ^= buf[BOOTP_XID + 4];
buf[BOOTP_XID + 1] ^= buf[BOOTP_XID + 5];
buf[BOOTP_XID + 2] ^= (retry >> 8) & 0xFF;
......@@ -56,7 +56,7 @@ int prepare_bootp(struct wr_sockaddr *addr, uint8_t * buf, int retry)
memset(buf + BOOTP_GIADDR, 0, 4);
memset(buf + BOOTP_CHADDR, 0, 16);
get_mac_addr(buf + BOOTP_CHADDR); /* own MAC address */
ep_get_mac_addr(buf + BOOTP_CHADDR); /* own MAC address */
memset(buf + BOOTP_SNAME, 0, 64); /* desired BOOTP server */
memset(buf + BOOTP_FILE, 0, 128); /* desired BOOTP file */
......@@ -81,7 +81,7 @@ int process_bootp(uint8_t * buf, int len)
uint8_t mac[6];
uint8_t ip[4];
get_mac_addr(mac);
ep_get_mac_addr(mac);
if (len != BOOTP_END)
return 0;
......
......@@ -10,10 +10,10 @@
#include <wrpc.h>
#include <string.h>
#include "endpoint.h"
#include "dev/endpoint.h"
#include "ipv4.h"
#include "ptpd_netif.h"
#include "pps_gen.h"
#include "dev/pps_gen.h"
#include "hw/etherbone-config.h"
enum ip_status ip_status = IP_TRAINING;
......@@ -109,7 +109,7 @@ static int bootp_poll(void)
if (len > 0)
ret = process_bootp(buf, len);
if (task_not_yet(&bootp_tics, TICS_PER_SECOND))
if (wrc_task_not_yet(&bootp_tics, TICS_PER_SECOND))
return ret;
len = prepare_bootp(&addr, buf, ++bootp_retry);
......@@ -199,8 +199,10 @@ void setIP(unsigned char *IP)
memcpy(myIP, IP, 4);
ip = (myIP[0] << 24) | (myIP[1] << 16) | (myIP[2] << 8) | (myIP[3]);
while (*eb_ip != ip)
*eb_ip = ip;
if (HAS_EB) {
while (*eb_ip != ip)
*eb_ip = ip;
}
if (ip == 0)
ip_status = IP_TRAINING;
......
......@@ -91,7 +91,7 @@ static void latency_report(struct wr_timestamp *lat)
unsigned char mac[6];
/* first time; pick a time in the future */
get_mac_addr(mac);
ep_get_mac_addr(mac);
nextj = jiffies + TICS_PER_SECOND * (10 + (mac[5] % 60));
pp_printf("%s: first sending at %li\n", __func__, nextj);
}
......@@ -269,7 +269,7 @@ int latency_poll(void)
return latency_poll_rx();
/* Periodically send the frames */
if (task_not_yet(&lastt, latency_period_ms))
if (wrc_task_not_yet(&lastt, latency_period_ms))
return 0;
return latency_poll_tx();
}
......
......@@ -48,7 +48,7 @@ static void fill_mac(uint8_t *tlv, uint8_t type)
{
*tlv = type;
/* write MAC after subtype byte */
get_mac_addr(tlv + LLDP_SUBTYPE);
ep_get_mac_addr(tlv + LLDP_SUBTYPE);
}
static void lldp_add_tlv(int tlv_type) {
......@@ -119,7 +119,7 @@ static void lldp_add_tlv(int tlv_type) {
(char *)buf);
} else {
/* NOTE: no subtype */
get_mac_addr(mac);
ep_get_mac_addr(mac);
pp_sprintf(buf,
"%02x:%02x:%02x:%02x:%02x:%02x",
mac[0], mac[1], mac[2], mac[3],
......@@ -251,7 +251,7 @@ int lldp_poll(void)
/* periodic tasks */
if (ticks > LLDP_TX_TICK_INTERVAL) {
get_mac_addr(new_mac);
ep_get_mac_addr(new_mac);
if (HAS_IP) {
getIP(&new_ipWR);
}
......
......@@ -130,7 +130,7 @@ int syslog_poll(void)
if (!tics) {
/* first time ever, or new syslog server */
tics = now - 1;
get_mac_addr(mac);
ep_get_mac_addr(mac);
len = syslog_header(buf, SYSLOG_DEFAULT_LEVEL, ip);
len += pp_sprintf(buf + len, "(%s) Node up "
"since %i seconds", format_mac(b, mac),
......
......@@ -146,4 +146,19 @@ void wrc_tasks_accounting_init()
shw_pps_gen_get_time(NULL, &prev_nanos_for_profile);
/* get tics */
prev_ticks_for_profile = timer_get_tics();
}
\ No newline at end of file
}
int wrc_task_not_yet(uint32_t *lastt, unsigned period)
{
uint32_t now = timer_get_tics();
if (!*lastt) {
*lastt = now;
return 0;
}
if (time_before(now, *lastt + period))
return 1; /* not yet */
*lastt += period;
return 0;
}
......@@ -364,5 +364,7 @@ void shell_register_commands()
REGISTER_WRC_COMMAND(diag);
REGISTER_WRC_COMMAND(init);
REGISTER_WRC_COMMAND(sfp);
if (HAS_IP)
REGISTER_WRC_COMMAND(ip);
}
......@@ -40,10 +40,6 @@
#include "dev/dac_log.h"
#endif
#ifdef CONFIG_IP
#include "lib/arp.h"
#endif
#ifdef CONFIG_LATENCY_PROBE
#include "lib/latency.h"
#endif
......@@ -52,10 +48,6 @@
#include "lib/lldp.h"
#endif
#ifdef CONFIG_SNMP
#include "lib/snmp.h"
#endif
char wrc_hw_name[HW_NAME_LENGTH];
uint32_t cal_phase_transition = 2389;
......
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