Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contrib/ports/xmos/include/netif/ethernetif.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ int xcore_ethernetif_init(const uint8_t* mac_address_phy, const xtcp_ipconfig_t*
void xcore_lwip_init_timers(uint32_t period[NUM_TIMEOUTS], uint32_t timeout[NUM_TIMEOUTS], uint32_t time_now);

/* LwIP Ethernet packet input function */
void ethernetif_input(const uint8_t buffer[], int32_t n_bytes);
void ethernetif_input(const uint8_t buffer[], int32_t n_bytes, uint32_t timestamp);

/* Wrapper for LwIP link notifications */
void xcore_net_link_up(void);
Expand Down
2 changes: 2 additions & 0 deletions contrib/ports/xmos/include/netif/xcore_netif_output.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ void xcore_netif_output_init(client ethernet_tx_if ?i_eth_tx, client mii_if ?i_m
*/
void xcore_netif_low_level_output(int buffer[], size_t n_bytes);

uint32_t xcore_netif_low_level_output_timed(int buffer[], size_t n_bytes);

#endif /* __XCORE_NETIF_H__ */
17 changes: 15 additions & 2 deletions contrib/ports/xmos/lib/minimal/lwipopts.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,20 @@

// Custom data in pbuf to hold remote address for UDP recvfrom()
#include "xtcp.h"
#define LWIP_PBUF_CUSTOM_DATA xtcp_host_t remote;
#define LWIP_PBUF_CUSTOM_DATA_INIT(p) p->remote.ipaddr[0] = 0; p->remote.ipaddr[1] = 0; p->remote.ipaddr[2] = 0; p->remote.ipaddr[3] = 0; p->remote.port_number = 0;
#define LWIP_PBUF_CUSTOM_DATA \
xtcp_host_t remote; \
unsigned timestamp;

#define LWIP_PBUF_CUSTOM_DATA_INIT(p) \
p->remote.ipaddr[0] = 0; \
p->remote.ipaddr[1] = 0; \
p->remote.ipaddr[2] = 0; \
p->remote.ipaddr[3] = 0; \
p->remote.port_number = 0; \
p->timestamp = 0;

// this reuses the flag field to avoid adding an additional field;
// care should be taken if lwIP adds additional flags
#define PBUF_FLAG_TX_TIMESTAMP 0x80

#endif /* __LWIPOPTS_H__ */
17 changes: 15 additions & 2 deletions contrib/ports/xmos/lib/standard/lwipopts.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,20 @@

// Custom data in pbuf to hold remote address for UDP recvfrom()
#include "xtcp.h"
#define LWIP_PBUF_CUSTOM_DATA xtcp_host_t remote;
#define LWIP_PBUF_CUSTOM_DATA_INIT(p) p->remote.ipaddr[0] = 0; p->remote.ipaddr[1] = 0; p->remote.ipaddr[2] = 0; p->remote.ipaddr[3] = 0; p->remote.port_number = 0;
#define LWIP_PBUF_CUSTOM_DATA \
xtcp_host_t remote; \
unsigned timestamp;

#define LWIP_PBUF_CUSTOM_DATA_INIT(p) \
p->remote.ipaddr[0] = 0; \
p->remote.ipaddr[1] = 0; \
p->remote.ipaddr[2] = 0; \
p->remote.ipaddr[3] = 0; \
p->remote.port_number = 0; \
p->timestamp = 0;

// this reuses the flag field to avoid adding an additional field;
// care should be taken if lwIP adds additional flags
#define PBUF_FLAG_TX_TIMESTAMP 0x80

#endif /* __LWIPOPTS_H__ */
14 changes: 11 additions & 3 deletions contrib/ports/xmos/port/ethernetif.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,18 @@ static err_t xcore_ethernetif_linkoutput(struct netif *netif, struct pbuf *p) {

n_bytes = 60;
/* Start MAC transmit here */
xcore_netif_low_level_output(txbuf, n_bytes);
if (p->flags & PBUF_FLAG_TX_TIMESTAMP)
p->timestamp = xcore_netif_low_level_output_timed(txbuf, n_bytes);
else
xcore_netif_low_level_output(txbuf, n_bytes);
} else {
// NOTE: this is not expecting or setup to deal with pbuf chains

/* Start MAC transmit here */
xcore_netif_low_level_output(p->payload, n_bytes);
if (p->flags & PBUF_FLAG_TX_TIMESTAMP)
p->timestamp = xcore_netif_low_level_output_timed(p->payload, n_bytes);
else
xcore_netif_low_level_output(p->payload, n_bytes);
}

#if ETH_PAD_SIZE
Expand Down Expand Up @@ -324,12 +330,14 @@ void xcore_timeout(xtcp_lwip_timeout_type timeout) {
* interface.
*
*/
void ethernetif_input(const uint8_t buffer[], int32_t n_bytes) {
void ethernetif_input(const uint8_t buffer[], int32_t n_bytes, uint32_t timestamp) {
/* move received packet into a new pbuf */
struct pbuf *p = xcore_net_low_level_input(buffer, n_bytes);

/* if no packet could be read, silently ignore this */
if (p != NULL) {
p->timestamp = timestamp;

/* pass all packets to ethernet_input, which decides what packets it supports */
if (xcore_netif.input(p, &xcore_netif) != ERR_OK) {

Expand Down
14 changes: 14 additions & 0 deletions contrib/ports/xmos/port/xcore_netif_output.xc
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,17 @@ void xcore_netif_low_level_output(int buffer[], size_t n_bytes) {
fail("xcore_netif_low_level_output: netif output interface not set.\n");
}
}

uint32_t xcore_netif_low_level_output_timed(int buffer[], size_t n_bytes) {
if (xcore_netif_eth == XCORE_NETIF_ETH_TX) {
unsafe {
// TODO - Check whether ETHERNET_ALL_INTERFACES is correct when we support dual-PHY
return ((client interface ethernet_tx_if)xtcp_i_eth_tx).send_timed_packet((char *)buffer,
n_bytes,
ETHERNET_ALL_INTERFACES);
}
} else {
fail("xcore_netif_low_level_output: netif output interface not set.\n");
return 0;
}
}