Skip to content

Commit 9f7dfb1

Browse files
elvinongblNobody
authored andcommitted
samples/bpf: xdpsock: add time-out for cleaning Tx
When user sets tx-pkt-count and in case where there are invalid Tx frame, the complete_tx_only_all() process polls indefinitely. So, this patch adds a time-out mechanism into the process so that the application can terminate automatically after it retries 3*polling interval duration. sock0@enp0s29f1:2 txonly xdp-drv pps pkts 1.00 rx 0 0 tx 136383 1000000 rx dropped 0 0 rx invalid 0 0 tx invalid 35 245 rx queue full 0 0 fill ring empty 0 1 tx ring empty 957 7011 sock0@enp0s29f1:2 txonly xdp-drv pps pkts 1.00 rx 0 0 tx 0 1000000 rx dropped 0 0 rx invalid 0 0 tx invalid 0 245 rx queue full 0 0 fill ring empty 0 1 tx ring empty 1 7012 sock0@enp0s29f1:2 txonly xdp-drv pps pkts 1.00 rx 0 0 tx 0 1000000 rx dropped 0 0 rx invalid 0 0 tx invalid 0 245 rx queue full 0 0 fill ring empty 0 1 tx ring empty 1 7013 sock0@enp0s29f1:2 txonly xdp-drv pps pkts 1.00 rx 0 0 tx 0 1000000 rx dropped 0 0 rx invalid 0 0 tx invalid 0 245 rx queue full 0 0 fill ring empty 0 1 tx ring empty 1 7014 sock0@enp0s29f1:2 txonly xdp-drv pps pkts 1.00 rx 0 0 tx 0 1000000 rx dropped 0 0 rx invalid 0 0 tx invalid 0 245 rx queue full 0 0 fill ring empty 0 1 tx ring empty 0 7014 sock0@enp0s29f1:2 txonly xdp-drv pps pkts 0.00 rx 0 0 tx 0 1000000 rx dropped 0 0 rx invalid 0 0 tx invalid 0 245 rx queue full 0 0 fill ring empty 0 1 tx ring empty 0 7014 Signed-off-by: Ong Boon Leong <[email protected]>
1 parent 38ab5f4 commit 9f7dfb1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

samples/bpf/xdpsock_user.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1410,6 +1410,7 @@ static inline int get_batch_size(int pkt_cnt)
14101410

14111411
static void complete_tx_only_all(void)
14121412
{
1413+
u32 retries = 3;
14131414
bool pending;
14141415
int i;
14151416

@@ -1421,7 +1422,8 @@ static void complete_tx_only_all(void)
14211422
pending = !!xsks[i]->outstanding_tx;
14221423
}
14231424
}
1424-
} while (pending);
1425+
sleep(opt_interval);
1426+
} while (pending && retries-- > 0);
14251427
}
14261428

14271429
static void tx_only_all(void)

0 commit comments

Comments
 (0)