mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
selftests: drv-net: ncdevmem: add -n flag to skip NIC configuration
Add a -n (skip_config) flag that causes ncdevmem to skip NIC configuration when operating as an RX server. When -n is passed, ncdevmem skips configuring header split, RSS, and flow steering, as well as their teardown on exit. This allows ksft tests to pre-configure the NIC in the host namespace before launching ncdevmem in the guest namespace. This is needed for netkit devmem tests where the test harness namespace has direct access to the NIC and the ncdevmem namespace does not. Acked-by: Stanislav Fomichev <sdf@fomichev.me> Signed-off-by: Bobby Eshleman <bobbyeshleman@meta.com> Link: https://patch.msgid.link/20260514-tcp-dm-netkit-v5-4-408c59b91e66@meta.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
1abe839b34
commit
ecbdf3da78
|
|
@ -93,6 +93,7 @@ static char *port;
|
|||
static size_t do_validation;
|
||||
static int start_queue = -1;
|
||||
static int num_queues = -1;
|
||||
static int skip_config;
|
||||
static char *ifname;
|
||||
static unsigned int ifindex;
|
||||
static unsigned int dmabuf_id;
|
||||
|
|
@ -828,7 +829,7 @@ static struct netdev_queue_id *create_queues(void)
|
|||
|
||||
static int do_server(struct memory_buffer *mem)
|
||||
{
|
||||
struct ethtool_rings_get_rsp *ring_config;
|
||||
struct ethtool_rings_get_rsp *ring_config = NULL;
|
||||
char ctrl_data[sizeof(int) * 20000];
|
||||
size_t non_page_aligned_frags = 0;
|
||||
struct sockaddr_in6 client_addr;
|
||||
|
|
@ -851,27 +852,29 @@ static int do_server(struct memory_buffer *mem)
|
|||
return -1;
|
||||
}
|
||||
|
||||
ring_config = get_ring_config();
|
||||
if (!ring_config) {
|
||||
pr_err("Failed to get current ring configuration");
|
||||
return -1;
|
||||
}
|
||||
if (!skip_config) {
|
||||
ring_config = get_ring_config();
|
||||
if (!ring_config) {
|
||||
pr_err("Failed to get current ring configuration");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (configure_headersplit(ring_config, 1)) {
|
||||
pr_err("Failed to enable TCP header split");
|
||||
goto err_free_ring_config;
|
||||
}
|
||||
if (configure_headersplit(ring_config, 1)) {
|
||||
pr_err("Failed to enable TCP header split");
|
||||
goto err_free_ring_config;
|
||||
}
|
||||
|
||||
/* Configure RSS to divert all traffic from our devmem queues */
|
||||
if (configure_rss()) {
|
||||
pr_err("Failed to configure rss");
|
||||
goto err_reset_headersplit;
|
||||
}
|
||||
/* Configure RSS to divert all traffic from our devmem queues */
|
||||
if (configure_rss()) {
|
||||
pr_err("Failed to configure rss");
|
||||
goto err_reset_headersplit;
|
||||
}
|
||||
|
||||
/* Flow steer our devmem flows to start_queue */
|
||||
if (configure_flow_steering(&server_sin)) {
|
||||
pr_err("Failed to configure flow steering");
|
||||
goto err_reset_rss;
|
||||
/* Flow steer our devmem flows to start_queue */
|
||||
if (configure_flow_steering(&server_sin)) {
|
||||
pr_err("Failed to configure flow steering");
|
||||
goto err_reset_rss;
|
||||
}
|
||||
}
|
||||
|
||||
if (bind_rx_queue(ifindex, mem->fd, create_queues(), num_queues, &ys)) {
|
||||
|
|
@ -1052,13 +1055,17 @@ static int do_server(struct memory_buffer *mem)
|
|||
err_unbind:
|
||||
ynl_sock_destroy(ys);
|
||||
err_reset_flow_steering:
|
||||
reset_flow_steering();
|
||||
if (!skip_config)
|
||||
reset_flow_steering();
|
||||
err_reset_rss:
|
||||
reset_rss();
|
||||
if (!skip_config)
|
||||
reset_rss();
|
||||
err_reset_headersplit:
|
||||
restore_ring_config(ring_config);
|
||||
if (!skip_config)
|
||||
restore_ring_config(ring_config);
|
||||
err_free_ring_config:
|
||||
ethtool_rings_get_rsp_free(ring_config);
|
||||
if (!skip_config)
|
||||
ethtool_rings_get_rsp_free(ring_config);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
@ -1404,7 +1411,7 @@ int main(int argc, char *argv[])
|
|||
int is_server = 0, opt;
|
||||
int ret, err = 1;
|
||||
|
||||
while ((opt = getopt(argc, argv, "Lls:c:p:v:q:t:f:z:")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "Lls:c:p:v:q:t:f:z:n")) != -1) {
|
||||
switch (opt) {
|
||||
case 'L':
|
||||
fail_on_linear = true;
|
||||
|
|
@ -1436,6 +1443,9 @@ int main(int argc, char *argv[])
|
|||
case 'z':
|
||||
max_chunk = atoi(optarg);
|
||||
break;
|
||||
case 'n':
|
||||
skip_config = 1;
|
||||
break;
|
||||
case '?':
|
||||
fprintf(stderr, "unknown option: %c\n", optopt);
|
||||
break;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user