Commit 95ff18a6 authored by Tristan Gingold's avatar Tristan Gingold

Add support for multiple nic

parent 0deda175
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "dev/spi_flash.h" #include "dev/spi_flash.h"
#include "dev/endpoint.h" #include "dev/endpoint.h"
#include "dev/netif.h" #include "dev/netif.h"
#include "dev/minic.h"
#include "softpll_ng.h" #include "softpll_ng.h"
#include "hw/si570_if_wb.h" #include "hw/si570_if_wb.h"
...@@ -765,8 +766,8 @@ int wrc_board_early_init() ...@@ -765,8 +766,8 @@ int wrc_board_early_init()
net_rst(); net_rst();
ep_init( &wrc_endpoint_dev, (void *) BASE_WR_ENDPOINT_MAIN ); ep_init( &wrc_endpoint_dev, (void *) BASE_WR_ENDPOINT_MAIN );
ep_init( &board.ep_btrain, (void *) BASE_WR_ENDPOINT_BTRAIN ); ep_init( &board.ep_btrain, (void *) BASE_WR_ENDPOINT_BTRAIN );
netif_register_device(&wrc_endpoint_dev); netif_register_device(&wrc_endpoint_dev, &minic);
netif_register_device(&board.ep_btrain ); netif_register_device(&board.ep_btrain, NULL);
#if defined (CONFIG_TARGET_AFCZ_V1) #if defined (CONFIG_TARGET_AFCZ_V1)
afczv1_read_persistent_mac(); afczv1_read_persistent_mac();
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include "dev/console-uart.h" #include "dev/console-uart.h"
#include "dev/endpoint.h" #include "dev/endpoint.h"
#include "dev/74x595.h" #include "dev/74x595.h"
#include "dev/minic.h"
#include "dev/netif.h" #include "dev/netif.h"
#include "dev/leds.h" #include "dev/leds.h"
#include "dev/wdiags.h" #include "dev/wdiags.h"
...@@ -2506,7 +2507,7 @@ int wrc_board_early_init() ...@@ -2506,7 +2507,7 @@ int wrc_board_early_init()
/* reset the networking part of the WRCore and start the WR Endpoint */ /* reset the networking part of the WRCore and start the WR Endpoint */
ep_init( &wrc_endpoint_dev, (void *) BASE_EP ); ep_init( &wrc_endpoint_dev, (void *) BASE_EP );
ep_set_mac_addr( &wrc_endpoint_dev, ertm14_mac ); ep_set_mac_addr( &wrc_endpoint_dev, ertm14_mac );
netif_register_device(&wrc_endpoint_dev ); netif_register_device(&wrc_endpoint_dev, &minic);
/* 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 */
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "dev/syscon.h" #include "dev/syscon.h"
#include "dev/endpoint.h" #include "dev/endpoint.h"
#include "dev/netif.h" #include "dev/netif.h"
#include "dev/minic.h"
#include "softpll_ng.h" #include "softpll_ng.h"
#include "storage.h" #include "storage.h"
#include <wrc-event.h> #include <wrc-event.h>
...@@ -95,7 +96,7 @@ int wrc_board_early_init() ...@@ -95,7 +96,7 @@ int wrc_board_early_init()
ep_init( &wrc_endpoint_dev, (void *) BASE_EP ); ep_init( &wrc_endpoint_dev, (void *) BASE_EP );
ep_set_mac_addr( &wrc_endpoint_dev, board_mac_addr ); ep_set_mac_addr( &wrc_endpoint_dev, board_mac_addr );
netif_register_device(&wrc_endpoint_dev ); netif_register_device(&wrc_endpoint_dev, &minic);
/* 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 */
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include "dev/24aa025.h" #include "dev/24aa025.h"
#include "softpll_ng.h" #include "softpll_ng.h"
#include "dev/minic.h"
#include "storage.h" #include "storage.h"
#include "wrc_ptp.h" #include "wrc_ptp.h"
...@@ -118,7 +119,7 @@ int wrc_board_early_init(void) ...@@ -118,7 +119,7 @@ int wrc_board_early_init(void)
ep_init(&wrc_endpoint_dev, (void *) BASE_EP); ep_init(&wrc_endpoint_dev, (void *) BASE_EP);
ep_set_mac_addr( &wrc_endpoint_dev, board_mac_addr ); ep_set_mac_addr( &wrc_endpoint_dev, board_mac_addr );
netif_register_device(&wrc_endpoint_dev ); netif_register_device(&wrc_endpoint_dev, &minic);
/* 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 */
......
#include <wrc.h> #include "wrc.h"
#include <wrpc.h> #include "wrpc.h"
#include <string.h> #include <string.h>
#include <shell.h> #include "shell.h"
#include <lib/ipv4.h> #include "lib/ipv4.h"
#include "dev/netif.h"
/* a tx-only socket: no queue is there */ /* a tx-only socket: no queue is there */
static DECLARE_WRPC_SOCKET(daclog_socket, 0); static DECLARE_WRPC_SOCKET(daclog_socket, 0);
...@@ -35,9 +36,11 @@ void spll_log_dac(int y) ...@@ -35,9 +36,11 @@ void spll_log_dac(int y)
void daclog_init(void) void daclog_init(void)
{ {
struct wrc_netif_device *nif = netif_get_device(0);
daclog_socket = ptpd_netif_create_socket daclog_socket = ptpd_netif_create_socket
(GET_WRPC_SOCKET(daclog_socket), LEN_WRPC_SOCKET(daclog_socket), (GET_WRPC_SOCKET(daclog_socket), LEN_WRPC_SOCKET(daclog_socket),
NULL, PTPD_SOCK_UDP, 1050); NULL, PTPD_SOCK_UDP, 1050, nif);
daclog_addr.sport = daclog_addr.dport = htons(1050); daclog_addr.sport = daclog_addr.dport = htons(1050);
} }
......
...@@ -36,34 +36,38 @@ ...@@ -36,34 +36,38 @@
rc = (raw) & 0xfffffff; \ rc = (raw) & 0xfffffff; \
fc = (raw >> 28) & 0xf; fc = (raw >> 28) & 0xf;
//#define RX_DUMP
/* Exported for snmp. */ /* Exported for snmp. */
struct wr_minic minic; struct wr_minic minic;
static unsigned char ver_supported; static unsigned char ver_supported;
static inline void minic_writel(uint32_t reg, uint32_t data) static inline void minic_writel(struct wr_minic *nic, uint32_t reg, uint32_t data)
{ {
*(volatile uint32_t *)(BASE_MINIC + reg) = data; *(volatile uint32_t *)(nic->base + reg) = data;
} }
static inline uint32_t minic_readl(uint32_t reg) static inline uint32_t minic_readl(struct wr_minic *nic, uint32_t reg)
{ {
return *(volatile uint32_t *)(BASE_MINIC + reg); return *(volatile uint32_t *)(nic->base + reg);
} }
static inline void minic_txword(int type, uint16_t word) static inline void minic_txword(struct wr_minic *nic, int type, uint16_t word)
{ {
minic_writel(MINIC_REG_TX_FIFO, minic_writel(nic, MINIC_REG_TX_FIFO,
MINIC_TX_FIFO_TYPE_W(type) | MINIC_TX_FIFO_DAT_W(word)); MINIC_TX_FIFO_TYPE_W(type) | MINIC_TX_FIFO_DAT_W(word));
} }
void minic_init(void) void minic_init(struct wr_minic *nic, void *base)
{ {
uint32_t mcr; uint32_t mcr;
nic->base = base;
/* before doing anything, check the HDL interface version */ /* before doing anything, check the HDL interface version */
mcr = minic_readl(MINIC_REG_MCR); mcr = minic_readl(nic, MINIC_REG_MCR);
if (MINIC_MCR_VER_R(mcr) != MINIC_HDL_VERSION) { if (MINIC_MCR_VER_R(mcr) != MINIC_HDL_VERSION) {
pp_printf("Error: Minic HDL version %d not supported by sw\n", pp_printf("Error: Minic HDL version %d not supported by sw\n",
(int) MINIC_MCR_VER_R(mcr)); (int) MINIC_MCR_VER_R(mcr));
...@@ -73,31 +77,32 @@ void minic_init(void) ...@@ -73,31 +77,32 @@ void minic_init(void)
ver_supported = 1; ver_supported = 1;
/* disable interrupts, driver does polling */ /* disable interrupts, driver does polling */
minic_writel(MINIC_REG_EIC_IDR, MINIC_EIC_IDR_TX | minic_writel(nic, MINIC_REG_EIC_IDR, MINIC_EIC_IDR_TX |
MINIC_EIC_IDR_RX | MINIC_EIC_IDR_TXTS); MINIC_EIC_IDR_RX | MINIC_EIC_IDR_TXTS);
/* enable RX path */ /* enable RX path */
minic_writel(MINIC_REG_MCR, mcr | MINIC_MCR_RX_EN); minic_writel(nic, MINIC_REG_MCR, mcr | MINIC_MCR_RX_EN);
} }
void minic_disable() void minic_disable(struct wr_minic *nic)
{ {
minic_writel(MINIC_REG_MCR, 0); minic_writel(nic, MINIC_REG_MCR, 0);
} }
int minic_poll_rx() int minic_poll_rx(struct wr_minic *nic)
{ {
uint32_t mcr; uint32_t mcr;
if (!ver_supported) if (!ver_supported)
return 0; return 0;
mcr = minic_readl(MINIC_REG_MCR); mcr = minic_readl(nic, MINIC_REG_MCR);
return (mcr & MINIC_MCR_RX_EMPTY) ? 0 : 1; return (mcr & MINIC_MCR_RX_EMPTY) ? 0 : 1;
} }
int minic_rx_frame(struct wr_ethhdr *hdr, uint8_t * payload, uint32_t buf_size, int minic_rx_frame(struct wr_minic *nic, struct wr_ethhdr *hdr,
uint8_t *payload, uint32_t buf_size,
struct hw_timestamp *hwts) struct hw_timestamp *hwts)
{ {
uint32_t hdr_size, payload_size; uint32_t hdr_size, payload_size;
...@@ -112,8 +117,11 @@ int minic_rx_frame(struct wr_ethhdr *hdr, uint8_t * payload, uint32_t buf_size, ...@@ -112,8 +117,11 @@ int minic_rx_frame(struct wr_ethhdr *hdr, uint8_t * payload, uint32_t buf_size,
int cntr_diff; int cntr_diff;
int got_rx_error = 0; int got_rx_error = 0;
if (!ver_supported)
return 0;
/* check if there is something in the Rx FIFO to be retrieved */ /* check if there is something in the Rx FIFO to be retrieved */
if ((minic_readl(MINIC_REG_MCR) & MINIC_MCR_RX_EMPTY) || !ver_supported) if ((minic_readl(nic, MINIC_REG_MCR) & MINIC_MCR_RX_EMPTY))
return 0; return 0;
hdr_size = 0; hdr_size = 0;
...@@ -127,22 +135,22 @@ int minic_rx_frame(struct wr_ethhdr *hdr, uint8_t * payload, uint32_t buf_size, ...@@ -127,22 +135,22 @@ int minic_rx_frame(struct wr_ethhdr *hdr, uint8_t * payload, uint32_t buf_size,
oob_hdr = RXOOB_TS_INCORRECT; oob_hdr = RXOOB_TS_INCORRECT;
#ifdef RX_DUMP #ifdef RX_DUMP
pp_printf("RX:"); pp_printf("RX@%x:", (unsigned)nic->base);
#endif #endif
do { do {
uint32_t rx; unsigned rx;
rx = minic_readl(MINIC_REG_RX_FIFO); rx = minic_readl(nic, MINIC_REG_RX_FIFO);
#ifdef RX_DUMP #ifdef RX_DUMP
if ((rx >> 16) == 0) if ((rx >> 16) == 0)
pp_printf(" %04x", (unsigned)rx); pp_printf(" %04x", rx);
else else
pp_printf(" %08x", (unsigned)rx); pp_printf(" %08x", rx);
#endif #endif
rx_type = MINIC_RX_FIFO_TYPE_R(rx); rx_type = MINIC_RX_FIFO_TYPE_R(rx);
rx_data = (uint16_t) MINIC_RX_FIFO_DAT_R(rx); rx_data = MINIC_RX_FIFO_DAT_R(rx);
rx_empty = (rx & MINIC_RX_FIFO_EMPTY) ? 1 : 0; rx_empty = (rx & MINIC_RX_FIFO_EMPTY);
if (rx_type == WRF_DATA && hdr_size < ETH_HEADER_SIZE) { if (rx_type == WRF_DATA && hdr_size < ETH_HEADER_SIZE) {
/* reading header */ /* reading header */
...@@ -168,8 +176,8 @@ int minic_rx_frame(struct wr_ethhdr *hdr, uint8_t * payload, uint32_t buf_size, ...@@ -168,8 +176,8 @@ int minic_rx_frame(struct wr_ethhdr *hdr, uint8_t * payload, uint32_t buf_size,
//pp_printf("Rxstat %x\n", rx_data); //pp_printf("Rxstat %x\n", rx_data);
if (RX_STATUS_ERROR(rx_data)) if (RX_STATUS_ERROR(rx_data))
{ {
pp_printf("Warning: Minic received erroneous " pp_printf("Warning: Minic @%x received erroneous "
"frame, %x\n", rx_data); "frame, %x\n", (unsigned)nic->base, rx);
got_rx_error = 1; got_rx_error = 1;
} }
...@@ -225,20 +233,21 @@ int minic_rx_frame(struct wr_ethhdr *hdr, uint8_t * payload, uint32_t buf_size, ...@@ -225,20 +233,21 @@ int minic_rx_frame(struct wr_ethhdr *hdr, uint8_t * payload, uint32_t buf_size,
/* Increment Rx counter for statistics */ /* Increment Rx counter for statistics */
if( got_rx_error ) if( got_rx_error )
{ {
minic.rx_errors++; nic->rx_errors++;
return -1; return -1;
} else { } else {
minic.rx_count++; nic->rx_count++;
} }
if (minic_readl(MINIC_REG_MCR) & MINIC_MCR_RX_FULL) if (minic_readl(nic, MINIC_REG_MCR) & MINIC_MCR_RX_FULL)
pp_printf("Warning: Minic Rx fifo full, expect wrong frames\n"); pp_printf("Warning: Minic Rx fifo full, expect wrong frames\n");
/* return number of bytes written to the *payload buffer */ /* return number of bytes written to the *payload buffer */
return (buf_size < payload_size ? buf_size : payload_size); return (buf_size < payload_size ? buf_size : payload_size);
} }
int minic_tx_frame(struct wr_ethhdr_vlan *hdr, uint8_t *payload, uint32_t size, int minic_tx_frame(struct wr_minic *nic, struct wr_ethhdr_vlan *hdr,
uint8_t *payload, uint32_t size,
struct hw_timestamp *hwts) struct hw_timestamp *hwts)
{ {
uint32_t mcr, pwords, hwords; uint32_t mcr, pwords, hwords;
...@@ -260,10 +269,10 @@ int minic_tx_frame(struct wr_ethhdr_vlan *hdr, uint8_t *payload, uint32_t size, ...@@ -260,10 +269,10 @@ int minic_tx_frame(struct wr_ethhdr_vlan *hdr, uint8_t *payload, uint32_t size,
pwords = size >> 1; pwords = size >> 1;
/* First we write status word (empty status for Tx) */ /* First we write status word (empty status for Tx) */
minic_txword(WRF_STATUS, 0); minic_txword(nic, WRF_STATUS, 0);
#ifdef TX_DUMP #ifdef TX_DUMP
pp_printf("TX:"); pp_printf("TX @%x:", (unsigned)nic->base);
#endif #endif
/* Write the header of the frame */ /* Write the header of the frame */
ptr = (uint16_t *)hdr; ptr = (uint16_t *)hdr;
...@@ -271,7 +280,7 @@ int minic_tx_frame(struct wr_ethhdr_vlan *hdr, uint8_t *payload, uint32_t size, ...@@ -271,7 +280,7 @@ int minic_tx_frame(struct wr_ethhdr_vlan *hdr, uint8_t *payload, uint32_t size,
#ifdef TX_DUMP #ifdef TX_DUMP
pp_printf(" %04x", htons(ptr[i])); pp_printf(" %04x", htons(ptr[i]));
#endif #endif
minic_txword(WRF_DATA, htons(ptr[i])); minic_txword(nic, WRF_DATA, htons(ptr[i]));
} }
/* Write the payload without the last word (which can be one byte) */ /* Write the payload without the last word (which can be one byte) */
...@@ -280,12 +289,12 @@ int minic_tx_frame(struct wr_ethhdr_vlan *hdr, uint8_t *payload, uint32_t size, ...@@ -280,12 +289,12 @@ int minic_tx_frame(struct wr_ethhdr_vlan *hdr, uint8_t *payload, uint32_t size,
#ifdef TX_DUMP #ifdef TX_DUMP
pp_printf(" %04x", htons(ptr[i])); pp_printf(" %04x", htons(ptr[i]));
#endif #endif
minic_txword(WRF_DATA, htons(ptr[i])); minic_txword(nic, WRF_DATA, htons(ptr[i]));
} }
/* Write last word of the payload (which can be one byte) */ /* Write last word of the payload (which can be one byte) */
if (size & 1) if (size & 1)
minic_txword(WRF_BYTESEL, htons(ptr[i])); minic_txword(nic, WRF_BYTESEL, htons(ptr[i]));
#ifdef TX_DUMP #ifdef TX_DUMP
pp_printf("\n"); pp_printf("\n");
...@@ -293,18 +302,18 @@ int minic_tx_frame(struct wr_ethhdr_vlan *hdr, uint8_t *payload, uint32_t size, ...@@ -293,18 +302,18 @@ int minic_tx_frame(struct wr_ethhdr_vlan *hdr, uint8_t *payload, uint32_t size,
/* Write also OOB if needed */ /* Write also OOB if needed */
if (hwts) { if (hwts) {
minic_txword(WRF_OOB, TX_OOB); minic_txword(nic, WRF_OOB, TX_OOB);
minic_txword(WRF_OOB, WRPC_FID); minic_txword(nic, WRF_OOB, WRPC_FID);
} }
/* Start sending the frame, and while we read mcr check for fifo full */ /* Start sending the frame, and while we read mcr check for fifo full */
mcr = minic_readl(MINIC_REG_MCR); mcr = minic_readl(nic, MINIC_REG_MCR);
assert_warn((mcr & MINIC_MCR_TX_FULL) == 0, "Minic tx fifo full\n"); assert_warn((mcr & MINIC_MCR_TX_FULL) == 0, "Minic tx fifo full\n");
minic_writel(MINIC_REG_MCR, mcr | MINIC_MCR_TX_START); minic_writel(nic, MINIC_REG_MCR, mcr | MINIC_MCR_TX_START);
/* wait for the DMA to finish */ /* wait for the DMA to finish */
for (i = 0; i < 1000; ++i) { for (i = 0; i < 1000; ++i) {
mcr = minic_readl(MINIC_REG_MCR); mcr = minic_readl(nic, MINIC_REG_MCR);
if ((mcr & MINIC_MCR_TX_IDLE) != 0) break; if ((mcr & MINIC_MCR_TX_IDLE) != 0) break;
timer_delay_ms(1); timer_delay_ms(1);
} }
...@@ -322,7 +331,7 @@ int minic_tx_frame(struct wr_ethhdr_vlan *hdr, uint8_t *payload, uint32_t size, ...@@ -322,7 +331,7 @@ int minic_tx_frame(struct wr_ethhdr_vlan *hdr, uint8_t *payload, uint32_t size,
/* wait for the timestamp */ /* wait for the timestamp */
for (i = 0; i < 100; ++i) { for (i = 0; i < 100; ++i) {
mcr = minic_readl(MINIC_REG_MCR); mcr = minic_readl(nic, MINIC_REG_MCR);
if ((mcr & MINIC_MCR_TX_TS_READY) != 0) break; if ((mcr & MINIC_MCR_TX_TS_READY) != 0) break;
timer_delay_ms(1); timer_delay_ms(1);
} }
...@@ -337,11 +346,11 @@ int minic_tx_frame(struct wr_ethhdr_vlan *hdr, uint8_t *payload, uint32_t size, ...@@ -337,11 +346,11 @@ int minic_tx_frame(struct wr_ethhdr_vlan *hdr, uint8_t *payload, uint32_t size,
if(ts_valid) if(ts_valid)
ts_valid = minic_readl(MINIC_REG_TSR0) ts_valid = minic_readl(nic, MINIC_REG_TSR0)
& MINIC_TSR0_VALID; & MINIC_TSR0_VALID;
raw_ts = minic_readl(MINIC_REG_TSR1); raw_ts = minic_readl(nic, MINIC_REG_TSR1);
fid = MINIC_TSR0_FID_R(minic_readl(MINIC_REG_TSR0)); fid = MINIC_TSR0_FID_R(minic_readl(nic, MINIC_REG_TSR0));
if (fid != WRPC_FID) { if (fid != WRPC_FID) {
wrc_verbose("minic_tx_frame: unmatched fid %d vs %d\n", wrc_verbose("minic_tx_frame: unmatched fid %d vs %d\n",
...@@ -360,16 +369,16 @@ int minic_tx_frame(struct wr_ethhdr_vlan *hdr, uint8_t *payload, uint32_t size, ...@@ -360,16 +369,16 @@ int minic_tx_frame(struct wr_ethhdr_vlan *hdr, uint8_t *payload, uint32_t size,
hwts->ahead = 0; hwts->ahead = 0;
hwts->nsec = counter_r * (REF_CLOCK_PERIOD_PS / 1000); hwts->nsec = counter_r * (REF_CLOCK_PERIOD_PS / 1000);
minic.tx_count++; nic->tx_count++;
} }
return size; return size;
} }
void minic_get_stats(int *tx_frames, int *rx_frames, int *rx_errors) void minic_get_stats(struct wr_minic *nic, int *tx_frames, int *rx_frames, int *rx_errors)
{ {
*tx_frames = minic.tx_count; *tx_frames = nic->tx_count;
*rx_frames = minic.rx_count; *rx_frames = nic->rx_count;
if(rx_errors) if(rx_errors)
*rx_errors = minic.rx_errors; *rx_errors = nic->rx_errors;
} }
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
static unsigned char netif_n_count = 0; static unsigned char netif_n_count = 0;
static struct wrc_netif_device netif_devs[WRC_NETIF_MAX_DEVICES]; static struct wrc_netif_device netif_devs[WRC_NETIF_MAX_DEVICES];
int netif_register_device(struct wr_endpoint_device* ep) int netif_register_device(struct wr_endpoint_device *ep, struct wr_minic *nic)
{ {
if( netif_n_count >= WRC_NETIF_MAX_DEVICES ) if( netif_n_count >= WRC_NETIF_MAX_DEVICES )
return -1; return -1;
...@@ -30,6 +30,7 @@ int netif_register_device(struct wr_endpoint_device* ep) ...@@ -30,6 +30,7 @@ int netif_register_device(struct wr_endpoint_device* ep)
struct wrc_netif_device *ndev = &netif_devs[netif_n_count]; struct wrc_netif_device *ndev = &netif_devs[netif_n_count];
ndev->ep = ep; ndev->ep = ep;
ndev->nic = nic;
dev_dbg("Registered network interface %u @ %p\n", netif_n_count, ndev->ep->base ); dev_dbg("Registered network interface %u @ %p\n", netif_n_count, ndev->ep->base );
......
...@@ -19,17 +19,14 @@ ...@@ -19,17 +19,14 @@
#define TX_OOB 0x1000 #define TX_OOB 0x1000
void minic_init(void); /* Standard ethernet mac packet header. */
void minic_disable(void);
int minic_poll_rx(void);
void minic_get_stats(int *tx_frames, int *rx_frames, int*rx_errors);
struct wr_ethhdr { struct wr_ethhdr {
uint8_t dstmac[6]; uint8_t dstmac[6];
uint8_t srcmac[6]; uint8_t srcmac[6];
uint16_t ethtype; uint16_t ethtype;
}; };
/* Ethernet mac packet header with VLAN. */
struct wr_ethhdr_vlan { struct wr_ethhdr_vlan {
uint8_t dstmac[6]; uint8_t dstmac[6];
uint8_t srcmac[6]; uint8_t srcmac[6];
...@@ -39,7 +36,8 @@ struct wr_ethhdr_vlan { ...@@ -39,7 +36,8 @@ struct wr_ethhdr_vlan {
}; };
struct wr_minic { struct wr_minic {
int tx_count, rx_count, rx_errors; void *base;
unsigned tx_count, rx_count, rx_errors;
}; };
struct hw_timestamp { struct hw_timestamp {
...@@ -52,9 +50,16 @@ struct hw_timestamp { ...@@ -52,9 +50,16 @@ struct hw_timestamp {
extern struct wr_minic minic; extern struct wr_minic minic;
int minic_rx_frame(struct wr_ethhdr *hdr, uint8_t * payload, uint32_t buf_size, void minic_init(struct wr_minic *nic, void *base);
void minic_disable(struct wr_minic *nic);
int minic_poll_rx(struct wr_minic *nic);
void minic_get_stats(struct wr_minic *nic, int *tx_frames, int *rx_frames, int*rx_errors);
int minic_rx_frame(struct wr_minic *nic, struct wr_ethhdr *hdr,
uint8_t *payload, uint32_t buf_size,
struct hw_timestamp *hwts); struct hw_timestamp *hwts);
int minic_tx_frame(struct wr_ethhdr_vlan *hdr, uint8_t * payload, uint32_t size, int minic_tx_frame(struct wr_minic *nic, struct wr_ethhdr_vlan *hdr,
uint8_t *payload, uint32_t size,
struct hw_timestamp *hwts); struct hw_timestamp *hwts);
#endif #endif
...@@ -18,9 +18,10 @@ ...@@ -18,9 +18,10 @@
struct wrc_netif_device struct wrc_netif_device
{ {
struct wr_endpoint_device* ep; struct wr_endpoint_device* ep;
struct wr_minic *nic;
}; };
int netif_register_device(struct wr_endpoint_device* ep); int netif_register_device(struct wr_endpoint_device *ep, struct wr_minic *nic);
int netif_get_device_count(void); int netif_get_device_count(void);
struct wrc_netif_device* netif_get_device(int idx); struct wrc_netif_device* netif_get_device(int idx);
......
...@@ -42,6 +42,7 @@ struct sockq { ...@@ -42,6 +42,7 @@ struct sockq {
struct wrpc_socket { struct wrpc_socket {
struct wr_sockaddr bind_addr; struct wr_sockaddr bind_addr;
struct wrc_netif_device *nif;
uint16_t prio; uint16_t prio;
uint32_t phase_transition; uint32_t phase_transition;
...@@ -78,6 +79,8 @@ struct wr_timestamp { ...@@ -78,6 +79,8 @@ struct wr_timestamp {
int correct; int correct;
}; };
struct wr_minic;
/* Copy a mac address (wrapper around memcpy). */ /* Copy a mac address (wrapper around memcpy). */
void copy_eth_addr(mac_addr_t dest, const mac_addr_t src); void copy_eth_addr(mac_addr_t dest, const mac_addr_t src);
...@@ -85,8 +88,9 @@ void copy_eth_addr(mac_addr_t dest, const mac_addr_t src); ...@@ -85,8 +88,9 @@ void copy_eth_addr(mac_addr_t dest, const mac_addr_t src);
// to bind_addr. // to bind_addr.
struct wrpc_socket *ptpd_netif_create_socket(struct wrpc_socket *s, struct wrpc_socket *ptpd_netif_create_socket(struct wrpc_socket *s,
unsigned len, unsigned len,
struct wr_sockaddr * bind_addr, struct wr_sockaddr *bind_addr,
int udp_or_raw, int udpport); int udp_or_raw, int udpport,
struct wrc_netif_device *nif);
// Sends a UDP/RAW packet (data, data_length) to addr in wr_sockaddr. // Sends a UDP/RAW packet (data, data_length) to addr in wr_sockaddr.
// For raw frames, mac/ethertype needs to be provided, for UDP - ip/port. // For raw frames, mac/ethertype needs to be provided, for UDP - ip/port.
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "dev/endpoint.h" #include "dev/endpoint.h"
#include "ipv4.h" #include "ipv4.h"
#include "net.h" #include "net.h"
#include "dev/netif.h"
#include "wrc_global.h" #include "wrc_global.h"
static DECLARE_WRPC_SOCKET(arp_socket, 128); static DECLARE_WRPC_SOCKET(arp_socket, 128);
...@@ -32,6 +33,7 @@ static struct wrpc_socket *arp_socket; ...@@ -32,6 +33,7 @@ static struct wrpc_socket *arp_socket;
void arp_init(void) void arp_init(void)
{ {
struct wr_sockaddr saddr; struct wr_sockaddr saddr;
struct wrc_netif_device *nif = netif_get_device(0);
/* Configure socket filter */ /* Configure socket filter */
memset(&saddr, 0, sizeof(saddr)); memset(&saddr, 0, sizeof(saddr));
...@@ -40,7 +42,7 @@ void arp_init(void) ...@@ -40,7 +42,7 @@ void arp_init(void)
arp_socket = ptpd_netif_create_socket arp_socket = ptpd_netif_create_socket
(GET_WRPC_SOCKET(arp_socket), LEN_WRPC_SOCKET(arp_socket), (GET_WRPC_SOCKET(arp_socket), LEN_WRPC_SOCKET(arp_socket),
&saddr, PTPD_SOCK_RAW_ETHERNET, 0); &saddr, PTPD_SOCK_RAW_ETHERNET, 0, nif);
} }
static int process_arp(uint8_t * buf, int len) static int process_arp(uint8_t * buf, int len)
......
...@@ -58,23 +58,24 @@ unsigned int ipv4_checksum(unsigned short *buf, int shorts) ...@@ -58,23 +58,24 @@ unsigned int ipv4_checksum(unsigned short *buf, int shorts)
void ipv4_init(void) void ipv4_init(void)
{ {
struct wr_sockaddr saddr; struct wr_sockaddr saddr;
struct wrc_netif_device *nif = netif_get_device(0);
/* Bootp: use UDP engine activated by function arguments */ /* Bootp: use UDP engine activated by function arguments */
bootp_socket = ptpd_netif_create_socket bootp_socket = ptpd_netif_create_socket
(GET_WRPC_SOCKET(bootp_socket), LEN_WRPC_SOCKET(bootp_socket), (GET_WRPC_SOCKET(bootp_socket), LEN_WRPC_SOCKET(bootp_socket),
NULL, PTPD_SOCK_UDP, 68 /* bootpc */); NULL, PTPD_SOCK_UDP, 68 /* bootpc */, nif);
/* time (rdate): UDP */ /* time (rdate): UDP */
rdate_socket = ptpd_netif_create_socket rdate_socket = ptpd_netif_create_socket
(GET_WRPC_SOCKET(rdate_socket), LEN_WRPC_SOCKET(rdate_socket), (GET_WRPC_SOCKET(rdate_socket), LEN_WRPC_SOCKET(rdate_socket),
NULL, PTPD_SOCK_UDP, 37 /* time */); NULL, PTPD_SOCK_UDP, 37 /* time */, nif);
/* ICMP: specify raw (not UDP), with IPV4 ethtype */ /* ICMP: specify raw (not UDP), with IPV4 ethtype */
memset(&saddr, 0, sizeof(saddr)); memset(&saddr, 0, sizeof(saddr));
saddr.ethertype = htons(0x0800); saddr.ethertype = htons(0x0800);
icmp_socket = ptpd_netif_create_socket icmp_socket = ptpd_netif_create_socket
(GET_WRPC_SOCKET(icmp_socket), LEN_WRPC_SOCKET(icmp_socket), (GET_WRPC_SOCKET(icmp_socket), LEN_WRPC_SOCKET(icmp_socket),
&saddr, PTPD_SOCK_RAW_ETHERNET, 0); &saddr, PTPD_SOCK_RAW_ETHERNET, 0, nif);
syslog_init(); syslog_init();
} }
......
...@@ -6,14 +6,15 @@ ...@@ -6,14 +6,15 @@
* *
* 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 "wrpc.h"
#include <net.h> #include "net.h"
#include <shell.h> #include "shell.h"
#include "ipv4.h" #include "ipv4.h"
#include <dev/endpoint.h> /* get_mac_addr() */ #include "dev/endpoint.h" /* get_mac_addr() */
#include <ppsi/jiffies.h> /* time_before() */ #include "ppsi/jiffies.h" /* time_before() */
#include <lib/syslog.h> #include "dev/netif.h"
#include "lib/syslog.h"
#define jiffies timer_get_tics() #define jiffies timer_get_tics()
#ifdef CONFIG_LATENCY_SYSLOG #ifdef CONFIG_LATENCY_SYSLOG
...@@ -39,10 +40,12 @@ static struct wr_sockaddr latency_addr = { ...@@ -39,10 +40,12 @@ static struct wr_sockaddr latency_addr = {
void latency_init(void) void latency_init(void)
{ {
struct wrc_netif_device *nif = netif_get_device(0);
latency_addr.ethertype = htons(CONFIG_LATENCY_ETHTYPE); latency_addr.ethertype = htons(CONFIG_LATENCY_ETHTYPE);
latency_socket = ptpd_netif_create_socket latency_socket = ptpd_netif_create_socket
(GET_WRPC_SOCKET(latency_socket), LEN_WRPC_SOCKET(latency_socket), (GET_WRPC_SOCKET(latency_socket), LEN_WRPC_SOCKET(latency_socket),
&latency_addr, PTPD_SOCK_RAW_ETHERNET, 0); &latency_addr, PTPD_SOCK_RAW_ETHERNET, 0, nif);
} }
static struct latency_frame { static struct latency_frame {
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "shell.h" #include "shell.h"
#include "wrc_ptp.h" #include "wrc_ptp.h"
#include "wrc_global.h" #include "wrc_global.h"
#include "dev/netif.h"
#include "dev/syscon.h" #include "dev/syscon.h"
#include "softpll_ng.h" #include "softpll_ng.h"
...@@ -242,6 +243,7 @@ static void lldp_update(void) ...@@ -242,6 +243,7 @@ static void lldp_update(void)
void lldp_init(void) void lldp_init(void)
{ {
struct wrc_netif_device *nif = netif_get_device(0);
struct wr_sockaddr saddr; struct wr_sockaddr saddr;
/* LLDP: raw ethernet*/ /* LLDP: raw ethernet*/
...@@ -250,7 +252,7 @@ void lldp_init(void) ...@@ -250,7 +252,7 @@ void lldp_init(void)
lldp_socket = ptpd_netif_create_socket lldp_socket = ptpd_netif_create_socket
(GET_WRPC_SOCKET(lldp_socket), LEN_WRPC_SOCKET(lldp_socket), (GET_WRPC_SOCKET(lldp_socket), LEN_WRPC_SOCKET(lldp_socket),
&saddr, PTPD_SOCK_RAW_ETHERNET, 0); &saddr, PTPD_SOCK_RAW_ETHERNET, 0, nif);
memset(&addr, 0x0, sizeof(struct wr_sockaddr)); memset(&addr, 0x0, sizeof(struct wr_sockaddr));
memcpy(addr.mac, LLDP_MCAST_MAC, 6); memcpy(addr.mac, LLDP_MCAST_MAC, 6);
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "dev/pps_gen.h" #include "dev/pps_gen.h"
#include "dev/minic.h" #include "dev/minic.h"
#include "dev/endpoint.h" #include "dev/endpoint.h"
#include "dev/netif.h"
#include "softpll_ng.h" #include "softpll_ng.h"
#include "ipv4.h" #include "ipv4.h"
#include "dev/rxts_calibrator.h" #include "dev/rxts_calibrator.h"
...@@ -43,11 +44,11 @@ void ptpd_netif_set_phase_transition(uint32_t phase) ...@@ -43,11 +44,11 @@ void ptpd_netif_set_phase_transition(uint32_t phase)
} }
} }
struct wrpc_socket *ptpd_netif_create_socket(struct wrpc_socket *sock, struct wrpc_socket *ptpd_netif_create_socket(struct wrpc_socket *sock,
unsigned len, unsigned len,
struct wr_sockaddr * bind_addr, struct wr_sockaddr * bind_addr,
int udp_or_raw, int udpport) int udp_or_raw, int udpport,
struct wrc_netif_device *nif)
{ {
int i; int i;
...@@ -72,6 +73,8 @@ struct wrpc_socket *ptpd_netif_create_socket(struct wrpc_socket *sock, ...@@ -72,6 +73,8 @@ struct wrpc_socket *ptpd_netif_create_socket(struct wrpc_socket *sock,
sock->bind_addr.udpport = udpport; sock->bind_addr.udpport = udpport;
} }
sock->nif = nif;
net_verbose("%s: socket %p for %04x:%04x, slot %i\n", __func__, net_verbose("%s: socket %p for %04x:%04x, slot %i\n", __func__,
sock, ntohs(sock->bind_addr.ethertype), sock, ntohs(sock->bind_addr.ethertype),
udpport, i); udpport, i);
...@@ -264,16 +267,16 @@ int ptpd_netif_recvfrom(struct wrpc_socket *s, struct wr_sockaddr *from, void *d ...@@ -264,16 +267,16 @@ int ptpd_netif_recvfrom(struct wrpc_socket *s, struct wr_sockaddr *from, void *d
return min(size, data_length); return min(size, data_length);
} }
int ptpd_netif_sendto(struct wrpc_socket * sock, struct wr_sockaddr *to, void *data, int ptpd_netif_sendto(struct wrpc_socket *sock, struct wr_sockaddr *to,
size_t data_length, struct wr_timestamp *tx_timestamp) void *data, size_t data_length,
struct wr_timestamp *tx_timestamp)
{ {
struct wrpc_socket *s = (struct wrpc_socket *)sock;
struct hw_timestamp hwts; struct hw_timestamp hwts;
struct wr_ethhdr_vlan hdr; struct wr_ethhdr_vlan hdr;
int rval; int rval;
copy_eth_addr(hdr.dstmac, to->mac); copy_eth_addr(hdr.dstmac, to->mac);
copy_eth_addr(hdr.srcmac, wrc_endpoint_dev.mac_addr); copy_eth_addr(hdr.srcmac, sock->nif->ep->mac_addr);
if (wrc_vlan_number) { if (wrc_vlan_number) {
hdr.ethtype = htons(0x8100); hdr.ethtype = htons(0x8100);
hdr.tag = htons(wrc_vlan_number | (sock->prio << 13)); hdr.tag = htons(wrc_vlan_number | (sock->prio << 13));
...@@ -282,11 +285,11 @@ int ptpd_netif_sendto(struct wrpc_socket * sock, struct wr_sockaddr *to, void *d ...@@ -282,11 +285,11 @@ int ptpd_netif_sendto(struct wrpc_socket * sock, struct wr_sockaddr *to, void *d
hdr.ethtype = sock->bind_addr.ethertype; hdr.ethtype = sock->bind_addr.ethertype;
} }
net_verbose("TX: socket %04x:%04x, len %i\n", net_verbose("TX: socket %04x:%04x, len %i\n",
ntohs(s->bind_addr.ethertype), ntohs(sock->bind_addr.ethertype),
s->bind_addr.udpport, sock->bind_addr.udpport,
data_length); data_length);
rval = minic_tx_frame(&hdr, (uint8_t *) data, data_length, &hwts); rval = minic_tx_frame(sock->nif->nic, &hdr, (uint8_t *) data, data_length, &hwts);
if (tx_timestamp) { if (tx_timestamp) {
tx_timestamp->sec = hwts.sec; tx_timestamp->sec = hwts.sec;
...@@ -297,7 +300,7 @@ int ptpd_netif_sendto(struct wrpc_socket * sock, struct wr_sockaddr *to, void *d ...@@ -297,7 +300,7 @@ int ptpd_netif_sendto(struct wrpc_socket * sock, struct wr_sockaddr *to, void *d
return rval; return rval;
} }
int net_bh_poll(void) static int netif_poll(struct wrc_netif_device *nif)
{ {
struct wrpc_socket *s = NULL, *raws = NULL, *udps = NULL; struct wrpc_socket *s = NULL, *raws = NULL, *udps = NULL;
struct sockq *q; struct sockq *q;
...@@ -309,7 +312,7 @@ int net_bh_poll(void) ...@@ -309,7 +312,7 @@ int net_bh_poll(void)
uint16_t size, port; uint16_t size, port;
uint16_t ethtype, tag; uint16_t ethtype, tag;
recvd = minic_rx_frame(&hdr, buffer, sizeof(buffer), &hwts); recvd = minic_rx_frame(nif->nic, &hdr, buffer, sizeof(buffer), &hwts);
if (recvd <= 0) /* No data received? */ if (recvd <= 0) /* No data received? */
return 0; return 0;
...@@ -327,7 +330,7 @@ int net_bh_poll(void) ...@@ -327,7 +330,7 @@ int net_bh_poll(void)
net_verbose("%s: want vlan %i, got %i: discard\n", net_verbose("%s: want vlan %i, got %i: discard\n",
__func__, wrc_vlan_number, __func__, wrc_vlan_number,
ntohs(tag) & 0xfff); ntohs(tag) & 0xfff);
return 0; return 0;
} }
/* Prepare for IP/UDP checks */ /* Prepare for IP/UDP checks */
...@@ -340,6 +343,8 @@ int net_bh_poll(void) ...@@ -340,6 +343,8 @@ int net_bh_poll(void)
s = socks[i]; s = socks[i];
if (!s) if (!s)
continue; continue;
if (s->nif != nif)
continue;
if (hdr.ethtype != s->bind_addr.ethertype) if (hdr.ethtype != s->bind_addr.ethertype)
continue; continue;
if (!port && !s->bind_addr.udpport) if (!port && !s->bind_addr.udpport)
...@@ -395,3 +400,17 @@ int net_bh_poll(void) ...@@ -395,3 +400,17 @@ int net_bh_poll(void)
q->avail, q->n, q_required); q->avail, q->n, q_required);
return 1; return 1;
} }
int net_bh_poll(void)
{
unsigned i;
int res = 0;
for (i = 0; i < netif_get_device_count(); i++) {
struct wrc_netif_device *nif = netif_get_device(i);
res |= netif_poll(nif);
}
return res;
}
...@@ -7,14 +7,15 @@ ...@@ -7,14 +7,15 @@
* 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 <string.h> #include <string.h>
#include <wrc.h> #include "wrc.h"
#include <wrpc.h> #include "wrpc.h"
#include "wrc_global.h" #include "wrc_global.h"
#include "ipv4.h" #include "ipv4.h"
#include "net.h" #include "net.h"
#include "shell.h" #include "shell.h"
#include "netconsole.h" #include "netconsole.h"
#include "dev/netif.h"
#ifdef CONFIG_NETCONSOLE_DEF_WAIT #ifdef CONFIG_NETCONSOLE_DEF_WAIT
#define NETCONSOLE_DEF_VAL NETCONSOLE_WAIT #define NETCONSOLE_DEF_VAL NETCONSOLE_WAIT
...@@ -35,9 +36,11 @@ struct wr_udp_addr netconsole_udp_addr; ...@@ -35,9 +36,11 @@ struct wr_udp_addr netconsole_udp_addr;
/* init for netconsole task */ /* init for netconsole task */
void netconsole_init(void) void netconsole_init(void)
{ {
struct wrc_netif_device *nif = netif_get_device(0);
netconsole_socket = ptpd_netif_create_socket netconsole_socket = ptpd_netif_create_socket
(GET_WRPC_SOCKET(netconsole_socket), LEN_WRPC_SOCKET(netconsole_socket), (GET_WRPC_SOCKET(netconsole_socket), LEN_WRPC_SOCKET(netconsole_socket),
NULL, PTPD_SOCK_UDP, NETCONSOLE_PORT); NULL, PTPD_SOCK_UDP, NETCONSOLE_PORT, nif);
} }
int netconsole_read_byte(void) int netconsole_read_byte(void)
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "dev/minic.h" #include "dev/minic.h"
#include "ipv4.h" #include "ipv4.h"
#include "net.h" #include "net.h"
#include "dev/netif.h"
#include "dev/pps_gen.h" #include "dev/pps_gen.h"
#include "hw/etherbone-config.h" #include "hw/etherbone-config.h"
#include "revision.h" #include "revision.h"
...@@ -269,8 +270,6 @@ static uint32_t aux_diag_reg_ro_num; ...@@ -269,8 +270,6 @@ static uint32_t aux_diag_reg_ro_num;
static uint32_t aux_diag_reg_rw_num; static uint32_t aux_diag_reg_rw_num;
extern struct pp_instance ppi_static;
/* __DATE__ and __TIME__ is already stored in struct spll_stats stats, but /* __DATE__ and __TIME__ is already stored in struct spll_stats stats, but
* redefining it here makes code smaller than concatenate existing one */ * redefining it here makes code smaller than concatenate existing one */
static const char snmp_build_date[] = __DATE__ " " __TIME__; static const char snmp_build_date[] = __DATE__ " " __TIME__;
...@@ -611,11 +610,12 @@ void snmp_init(void) ...@@ -611,11 +610,12 @@ void snmp_init(void)
{ {
uint32_t aux_diag_id; uint32_t aux_diag_id;
uint32_t aux_diag_ver; uint32_t aux_diag_ver;
struct wrc_netif_device *nif = netif_get_device(0);
/* Use UDP engine activated by function arguments */ /* Use UDP engine activated by function arguments */
snmp_socket = ptpd_netif_create_socket snmp_socket = ptpd_netif_create_socket
(GET_WRPC_SOCKET(snmp_socket), LEN_WRPC_SOCKET(snmp_socket), (GET_WRPC_SOCKET(snmp_socket), LEN_WRPC_SOCKET(snmp_socket),
NULL, PTPD_SOCK_UDP, 161 /* snmp */); NULL, PTPD_SOCK_UDP, 161 /* snmp */, nif);
if (SNMP_AUX_DIAG_ENABLED) { if (SNMP_AUX_DIAG_ENABLED) {
/* Fix ID and version of aux diag registers by values read from FPGA */ /* Fix ID and version of aux diag registers by values read from FPGA */
diag_read_info(&aux_diag_id, &aux_diag_ver, &aux_diag_reg_rw_num, diag_read_info(&aux_diag_id, &aux_diag_ver, &aux_diag_reg_rw_num,
......
...@@ -23,9 +23,11 @@ static uint32_t tics, tics_zero; ...@@ -23,9 +23,11 @@ static uint32_t tics, tics_zero;
void syslog_init(void) void syslog_init(void)
{ {
struct wrc_netif_device *nif = netif_get_device(0);
syslog_socket = ptpd_netif_create_socket syslog_socket = ptpd_netif_create_socket
(GET_WRPC_SOCKET(syslog_socket), LEN_WRPC_SOCKET(syslog_socket), (GET_WRPC_SOCKET(syslog_socket), LEN_WRPC_SOCKET(syslog_socket),
NULL, PTPD_SOCK_UDP, 514 /* syslog */); NULL, PTPD_SOCK_UDP, 514 /* syslog */, nif);
syslog_addr.sport = syslog_addr.dport = htons(514); syslog_addr.sport = syslog_addr.dport = htons(514);
tics_zero = timer_get_tics(); tics_zero = timer_get_tics();
} }
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
int wrc_wr_diags(void) int wrc_wr_diags(void)
{ {
static uint32_t last_update_tick; static uint32_t last_update_tick;
struct wrc_netif_device *ndev = netif_get_device(0);
int tx, rx, rx_err; int tx, rx, rx_err;
uint64_t sec; uint64_t sec;
uint32_t nsec; uint32_t nsec;
...@@ -51,7 +52,7 @@ int wrc_wr_diags(void) ...@@ -51,7 +52,7 @@ int wrc_wr_diags(void)
wdiag_set_valid(0); wdiag_set_valid(0);
/* frame statistics */ /* frame statistics */
minic_get_stats(&tx, &rx, &rx_err); minic_get_stats(ndev->nic, &tx, &rx, &rx_err);
wdiags_write_cnts(tx, rx, rx_err); wdiags_write_cnts(tx, rx, rx_err);
/* local time */ /* local time */
......
...@@ -26,6 +26,7 @@ uint32_t wrc_stats_last; ...@@ -26,6 +26,7 @@ uint32_t wrc_stats_last;
int wrc_log_stats(void) int wrc_log_stats(void)
{ {
struct wrc_netif_device *ndev = netif_get_device(0);
int tx, rx, rx_err; int tx, rx, rx_err;
struct spll_aux_clock_status aux_stat; struct spll_aux_clock_status aux_stat;
uint64_t sec; uint64_t sec;
...@@ -61,7 +62,7 @@ int wrc_log_stats(void) ...@@ -61,7 +62,7 @@ int wrc_log_stats(void)
wrc_stats_last = s->update_count; wrc_stats_last = s->update_count;
shw_pps_gen_get_time(&sec, &nsec); shw_pps_gen_get_time(&sec, &nsec);
minic_get_stats(&tx, &rx, &rx_err); minic_get_stats(ndev->nic, &tx, &rx, &rx_err);
pp_printf("lnk:%d rx:%d tx:%d ", (wrc_global_link.link_up == NETIF_LINK_UP), rx, tx); pp_printf("lnk:%d rx:%d tx:%d ", (wrc_global_link.link_up == NETIF_LINK_UP), rx, tx);
pp_printf("lock:%d ", spll_check_lock(0) ? 1 : 0); pp_printf("lock:%d ", spll_check_lock(0) ? 1 : 0);
......
...@@ -311,7 +311,7 @@ static void print_port(unsigned i) ...@@ -311,7 +311,7 @@ static void print_port(unsigned i)
} else } else
pcprintf(7, 26, C_GREEN, " "); pcprintf(7, 26, C_GREEN, " ");
minic_get_stats(&tx, &rx, &rx_err); minic_get_stats(ndev->nic, &tx, &rx, &rx_err);
pcprintf(7, 52, C_MAGENTA, "%7d", rx); pcprintf(7, 52, C_MAGENTA, "%7d", rx);
pprintf(7, 62, "%7d", tx); pprintf(7, 62, "%7d", tx);
pprintf(7, 72, "%4d", wrc_vlan_number); pprintf(7, 72, "%4d", wrc_vlan_number);
......
...@@ -114,14 +114,14 @@ static void wrc_initialize(void) ...@@ -114,14 +114,14 @@ 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(&wrc_endpoint_dev ); netif_register_device(&wrc_endpoint_dev, &minic);
/* 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);
ep_enable( &wrc_endpoint_dev, 1, 1 ); ep_enable( &wrc_endpoint_dev, 1, 1 );
#endif #endif
minic_init(); minic_init(&minic, (void *)BASE_MINIC);
shw_pps_gen_init(); shw_pps_gen_init();
/* initialize w1 temp sensor. Note that w1 must have been initialized /* initialize w1 temp sensor. Note that w1 must have been initialized
......
...@@ -90,7 +90,7 @@ static void wrc_sim_initialize(void) ...@@ -90,7 +90,7 @@ static void wrc_sim_initialize(void)
ep_init(&wrc_endpoint_dev, (void *) BASE_EP); ep_init(&wrc_endpoint_dev, (void *) BASE_EP);
ep_enable(&wrc_endpoint_dev, 1, 1); ep_enable(&wrc_endpoint_dev, 1, 1);
minic_init(); minic_init(&minic, &wrc_endpoint_dev);
shw_pps_gen_init(); shw_pps_gen_init();
spll_very_init(); spll_very_init();
/* wait for link up before enabling tm_time_valid_o */ /* wait for link up before enabling tm_time_valid_o */
...@@ -161,10 +161,10 @@ int wrpc_test_1(void) ...@@ -161,10 +161,10 @@ int wrpc_test_1(void)
/* A frame is sent out with sequenceID (firt octet) and awaited /* A frame is sent out with sequenceID (firt octet) and awaited
* reception. */ * reception. */
minic_tx_frame(&tx_hdr, tx_payload, 62, &hwts); minic_tx_frame(&minic, &tx_hdr, tx_payload, 62, &hwts);
tx_cnt++; tx_cnt++;
ret = minic_rx_frame(&rx_hdr, rx_payload, NET_MAX_SKBUF_SIZE, ret = minic_rx_frame(&minic, &rx_hdr, rx_payload,
&hwts); NET_MAX_SKBUF_SIZE, &hwts);
/** check whether the received value is OK */ /** check whether the received value is OK */
if (ret == 0) { if (ret == 0) {
......
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