From 758e09037a1e49d99d2fd3b9de47c8fd66766a7a Mon Sep 17 00:00:00 2001 From: Howard Mao Date: Fri, 21 Jul 2017 21:50:28 +0000 Subject: [PATCH] use stored MAC address in pingd --- rocket-chip | 2 +- testchipip | 2 +- tests/nic.h | 6 ++++++ tests/pingd.c | 12 +++++++++++- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/rocket-chip b/rocket-chip index 6d0821f1..cf75c204 160000 --- a/rocket-chip +++ b/rocket-chip @@ -1 +1 @@ -Subproject commit 6d0821f19a7a791df12df90421556aab8d649d43 +Subproject commit cf75c2049d0d1ebbed629fbd8a045acc669002d1 diff --git a/testchipip b/testchipip index 3dfe32a3..db0bd0fe 160000 --- a/testchipip +++ b/testchipip @@ -1 +1 @@ -Subproject commit 3dfe32a3b8d7ff14899dec317d8dac11849ac6dd +Subproject commit db0bd0fe6ed3e7eb89eafea1a0ced103e2f781ee diff --git a/tests/nic.h b/tests/nic.h index c3e80c49..55a86a2d 100644 --- a/tests/nic.h +++ b/tests/nic.h @@ -4,6 +4,7 @@ #define SIMPLENIC_SEND_COMP (SIMPLENIC_BASE + 16) #define SIMPLENIC_RECV_COMP (SIMPLENIC_BASE + 18) #define SIMPLENIC_COUNTS (SIMPLENIC_BASE + 20) +#define SIMPLENIC_MACADDR (SIMPLENIC_BASE + 24) static inline int nic_send_req_avail(void) { @@ -52,3 +53,8 @@ static int nic_recv(void *dest) return len; } + +static inline uint64_t nic_macaddr(void) +{ + return reg_read64(SIMPLENIC_MACADDR); +} diff --git a/tests/pingd.c b/tests/pingd.c index 850975d0..9e02cafe 100644 --- a/tests/pingd.c +++ b/tests/pingd.c @@ -230,11 +230,21 @@ static int process_packet(void *buf, uint8_t *mac) } } -uint8_t macaddr[MAC_ADDR_SIZE] = {0xaa, 0xbc, 0xde, 0xff, 0x25, 0x37}; uint64_t buffer[ETH_MAX_WORDS]; int main(void) { + uint64_t macaddr_long; + uint8_t *macaddr; + + macaddr_long = nic_macaddr(); + macaddr = (uint8_t *) &macaddr_long; + + printf("macaddr - %02x", macaddr[0]); + for (int i = 1; i < MAC_ADDR_SIZE; i++) + printf(":%02x", macaddr[i]); + printf("\n"); + for (;;) { if (process_packet(buffer, macaddr)) return -1;