aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlias Apalodimas <ilias.apalodimas@linaro.org>2019-01-14 16:11:18 +0200
committerIlias Apalodimas <ilias.apalodimas@linaro.org>2019-01-14 16:11:18 +0200
commit95de484e5af1721b6400fced483b5caf51c062ee (patch)
tree6b413b6753497241f30e05e63b9fdac48592319e
parentb0c661205748783981299e1b4d014f5cd263f393 (diff)
netsec: socionext: Use xdp meta data to record timestampssynquasher_01_page_pool_xdp_timestamps
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
-rw-r--r--drivers/net/ethernet/socionext/netsec.c10
-rw-r--r--samples/bpf/xdpsock_user.c25
2 files changed, 31 insertions, 4 deletions
diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c
index 9c7fc7f99a32..e6f742763ab0 100644
--- a/drivers/net/ethernet/socionext/netsec.c
+++ b/drivers/net/ethernet/socionext/netsec.c
@@ -908,6 +908,11 @@ static int netsec_process_rx(struct netsec_priv *priv, int budget)
u16 xdp_xmit = 0;
u32 xdp_act = 0;
int done = 0;
+ u64 ts = 0;
+ //u64 ts = ktime_get_real_ns();
+
+ asm volatile("mrs %0, CNTVCT_EL0" : "=r" (ts));
+ asm volatile ("isb sy");
while (done < budget) {
u16 idx = dring->tail;
@@ -961,8 +966,9 @@ static int netsec_process_rx(struct netsec_priv *priv, int budget)
prefetch(desc->addr);
xdp.data_hard_start = desc->addr;
- xdp.data = desc->addr + NETSEC_RXBUF_HEADROOM;
- xdp_set_data_meta_invalid(&xdp);
+ xdp.data = xdp.data_hard_start + NETSEC_RXBUF_HEADROOM;
+ xdp.data_meta = xdp.data - sizeof(ts);
+ memcpy(xdp.data_meta, &ts, sizeof(ts));
xdp.data_end = xdp.data + pkt_len;
xdp.rxq = &dring->xdp_rxq;
diff --git a/samples/bpf/xdpsock_user.c b/samples/bpf/xdpsock_user.c
index 57ecadc58403..6dcd70a3ac21 100644
--- a/samples/bpf/xdpsock_user.c
+++ b/samples/bpf/xdpsock_user.c
@@ -61,6 +61,10 @@ typedef __u32 u32;
static unsigned long prev_time;
+FILE *outfile;
+int cnt = 0;
+u64 packets[1048576];
+
enum benchmark_type {
BENCH_RXDROP = 0,
BENCH_TXONLY = 1,
@@ -631,9 +635,14 @@ static void *poller(void *arg)
static void int_exit(int sig)
{
+ int i;
+
(void)sig;
dump_stats();
bpf_set_link_xdp_fd(opt_ifindex, -1, opt_xdp_flags);
+
+ for (i = 0; i < cnt; i++)
+ fprintf(outfile, "%d:%lld\n", i, packets[i]);
exit(EXIT_SUCCESS);
}
@@ -791,14 +800,23 @@ static void rx_drop(struct xdpsock *xsk)
{
struct xdp_desc descs[BATCH_SIZE];
unsigned int rcvd, i;
+ __u64 tss, ts = 0;
rcvd = xq_deq(&xsk->rx, descs, BATCH_SIZE);
if (!rcvd)
return;
for (i = 0; i < rcvd; i++) {
- char *pkt = xq_get_data(xsk, descs[i].addr);
-
+ char *pkt = xq_get_data(xsk, descs[i].addr - sizeof(u64));
+
+ asm volatile("mrs %0, CNTVCT_EL0" : "=r" (tss));
+ asm volatile ("isb sy");
+ ts = (u64) pkt[7] << 56 | (u64) pkt[6] << 48 |
+ (u64) pkt[5] << 40 | (u64) pkt[4] << 32 |
+ (u64) pkt[3] << 24 | (u64) pkt[2] << 16 |
+ (u64) pkt[1] << 8 | (u64) pkt[0];
+ packets[cnt] = (tss - ts) * 10;
+ cnt++;
hex_dump(pkt, descs[i].len, descs[i].addr);
}
@@ -910,6 +928,9 @@ int main(int argc, char **argv)
int i, ret, key = 0;
pthread_t pt;
+ if ((outfile = fopen("/home/apalos/xdp_speed", "w+")) == NULL)
+ return -1;
+
parse_command_line(argc, argv);
if (setrlimit(RLIMIT_MEMLOCK, &r)) {