From b662854750f59dde574705bd238711c1b90b1256 Mon Sep 17 00:00:00 2001 From: Howard Mao Date: Tue, 27 Jun 2017 18:06:02 -0700 Subject: [PATCH] changes to SimpleNIC interface --- testchipip | 2 +- tests/nic-loopback.c | 32 +++++++++++++++++++------------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/testchipip b/testchipip index f058ee11..0df970e8 160000 --- a/testchipip +++ b/testchipip @@ -1 +1 @@ -Subproject commit f058ee11ad9c52554296fbb295894abb8375577c +Subproject commit 0df970e8d1e7ff4623b592acf509e8fb12417f5b diff --git a/tests/nic-loopback.c b/tests/nic-loopback.c index 3cf0cfb6..6b610465 100644 --- a/tests/nic-loopback.c +++ b/tests/nic-loopback.c @@ -3,36 +3,42 @@ #include #define SIMPLENIC_BASE 0x10016000L -#define SIMPLENIC_SEND (SIMPLENIC_BASE + 0) -#define SIMPLENIC_RECV (SIMPLENIC_BASE + 8) -#define SIMPLENIC_COMP (SIMPLENIC_BASE + 16) -#define SIMPLENIC_COUNTS (SIMPLENIC_BASE + 18) +#define SIMPLENIC_SEND_REQ (SIMPLENIC_BASE + 0) +#define SIMPLENIC_RECV_REQ (SIMPLENIC_BASE + 8) +#define SIMPLENIC_SEND_COMP (SIMPLENIC_BASE + 16) +#define SIMPLENIC_RECV_COMP (SIMPLENIC_BASE + 18) +#define SIMPLENIC_COUNTS (SIMPLENIC_BASE + 20) uint64_t src[200]; uint64_t dst[201]; -static inline int nic_send_avail(void) +static inline int nic_send_req_avail(void) { return reg_read16(SIMPLENIC_COUNTS) & 0xf; } -static inline int nic_recv_avail(void) +static inline int nic_recv_req_avail(void) { return (reg_read16(SIMPLENIC_COUNTS) >> 4) & 0xf; } -static inline int nic_comp_avail(void) +static inline int nic_send_comp_avail(void) { return (reg_read16(SIMPLENIC_COUNTS) >> 8) & 0xf; } +static inline int nic_recv_comp_avail(void) +{ + return (reg_read16(SIMPLENIC_COUNTS) >> 12) & 0xf; +} + static void nic_send(void *data, unsigned long len) { uintptr_t addr = ((uintptr_t) data) & ((1L << 48) - 1); unsigned long packet = (len << 48) | addr; - while (nic_send_avail() == 0); - reg_write64(SIMPLENIC_SEND, packet); + while (nic_send_req_avail() == 0); + reg_write64(SIMPLENIC_SEND_REQ, packet); } static int nic_recv(void *dest) @@ -40,12 +46,12 @@ static int nic_recv(void *dest) uintptr_t addr = (uintptr_t) dest; int len; - while (nic_recv_avail() == 0); - reg_write64(SIMPLENIC_RECV, addr); + while (nic_recv_req_avail() == 0); + reg_write64(SIMPLENIC_RECV_REQ, addr); // Poll for completion - while (nic_comp_avail() == 0); - len = reg_read16(SIMPLENIC_COMP); + while (nic_recv_comp_avail() == 0); + len = reg_read16(SIMPLENIC_RECV_COMP); return len; }