changes to SimpleNIC interface
This commit is contained in:
Submodule testchipip updated: f058ee11ad...0df970e8d1
@@ -3,36 +3,42 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#define SIMPLENIC_BASE 0x10016000L
|
#define SIMPLENIC_BASE 0x10016000L
|
||||||
#define SIMPLENIC_SEND (SIMPLENIC_BASE + 0)
|
#define SIMPLENIC_SEND_REQ (SIMPLENIC_BASE + 0)
|
||||||
#define SIMPLENIC_RECV (SIMPLENIC_BASE + 8)
|
#define SIMPLENIC_RECV_REQ (SIMPLENIC_BASE + 8)
|
||||||
#define SIMPLENIC_COMP (SIMPLENIC_BASE + 16)
|
#define SIMPLENIC_SEND_COMP (SIMPLENIC_BASE + 16)
|
||||||
#define SIMPLENIC_COUNTS (SIMPLENIC_BASE + 18)
|
#define SIMPLENIC_RECV_COMP (SIMPLENIC_BASE + 18)
|
||||||
|
#define SIMPLENIC_COUNTS (SIMPLENIC_BASE + 20)
|
||||||
|
|
||||||
uint64_t src[200];
|
uint64_t src[200];
|
||||||
uint64_t dst[201];
|
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;
|
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;
|
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;
|
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)
|
static void nic_send(void *data, unsigned long len)
|
||||||
{
|
{
|
||||||
uintptr_t addr = ((uintptr_t) data) & ((1L << 48) - 1);
|
uintptr_t addr = ((uintptr_t) data) & ((1L << 48) - 1);
|
||||||
unsigned long packet = (len << 48) | addr;
|
unsigned long packet = (len << 48) | addr;
|
||||||
|
|
||||||
while (nic_send_avail() == 0);
|
while (nic_send_req_avail() == 0);
|
||||||
reg_write64(SIMPLENIC_SEND, packet);
|
reg_write64(SIMPLENIC_SEND_REQ, packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nic_recv(void *dest)
|
static int nic_recv(void *dest)
|
||||||
@@ -40,12 +46,12 @@ static int nic_recv(void *dest)
|
|||||||
uintptr_t addr = (uintptr_t) dest;
|
uintptr_t addr = (uintptr_t) dest;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
while (nic_recv_avail() == 0);
|
while (nic_recv_req_avail() == 0);
|
||||||
reg_write64(SIMPLENIC_RECV, addr);
|
reg_write64(SIMPLENIC_RECV_REQ, addr);
|
||||||
|
|
||||||
// Poll for completion
|
// Poll for completion
|
||||||
while (nic_comp_avail() == 0);
|
while (nic_recv_comp_avail() == 0);
|
||||||
len = reg_read16(SIMPLENIC_COMP);
|
len = reg_read16(SIMPLENIC_RECV_COMP);
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user