use stored MAC address in pingd

This commit is contained in:
Howard Mao
2017-07-21 21:50:28 +00:00
parent f28f2379a4
commit 758e09037a
4 changed files with 19 additions and 3 deletions

View File

@@ -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);
}

View File

@@ -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;