From: David Wei Add a ynl sample application that calls bind-queue to bind a real rxq to a mapped rxq in a virtual netdev. # ethtool -X eth0 start 0 equal 15 # ethtool -X eth0 start 15 equal 1 context new # ethtool --config-ntuple eth0 flow-type [...] action 15 # ip link add numrxqueues 2 nk type netkit single # ethtool -l nk Channel parameters for nk: Pre-set maximums: RX: 2 TX: 1 Other: n/a Combined: 1 Current hardware settings: RX: 1 TX: 1 Other: n/a Combined: 0 # ip a 4: eth0: mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether e8:eb:d3:a3:43:f6 brd ff:ff:ff:ff:ff:ff [...] 8: nk@NONE: mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff # ynl-bind eth0 15 nk bound eth0, queue 15 to nk, queue 1 # ethtool -l nk [...] Current hardware settings: RX: 2 TX: 1 Other: n/a Combined: 0 Signed-off-by: David Wei Co-developed-by: Daniel Borkmann Signed-off-by: Daniel Borkmann --- tools/net/ynl/samples/bind.c | 56 ++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 tools/net/ynl/samples/bind.c diff --git a/tools/net/ynl/samples/bind.c b/tools/net/ynl/samples/bind.c new file mode 100644 index 000000000000..a6426121cbd4 --- /dev/null +++ b/tools/net/ynl/samples/bind.c @@ -0,0 +1,56 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include +#include +#include +#include + +#include "netdev-user.h" + +int main(int argc, char **argv) +{ + struct netdev_bind_queue_req *req; + struct netdev_bind_queue_rsp *rsp; + char if_src[IF_NAMESIZE] = {}; + char if_dst[IF_NAMESIZE] = {}; + struct ynl_sock *ys; + struct ynl_error yerr; + int src_ifindex = 0, dst_ifindex = 0; + int src_queue_id = 0; + + if (argc > 1) + src_ifindex = if_nametoindex(argv[1]); + if (argc > 2) + src_queue_id = strtol(argv[2], NULL, 0); + if (argc > 3) + dst_ifindex = if_nametoindex(argv[3]); + + ys = ynl_sock_create(&ynl_netdev_family, &yerr); + if (!ys) { + fprintf(stderr, "YNL: %s\n", yerr.msg); + return 1; + } + + req = netdev_bind_queue_req_alloc(); + netdev_bind_queue_req_set_src_ifindex(req, src_ifindex); + netdev_bind_queue_req_set_src_queue_id(req, src_queue_id); + netdev_bind_queue_req_set_dst_ifindex(req, dst_ifindex); + + rsp = netdev_bind_queue(ys, req); + netdev_bind_queue_req_free(req); + if (!rsp) + goto err; + + assert(rsp->_present.dst_queue_id); + printf("bound %s, queue %d to %s, queue %d\n", + if_indextoname(src_ifindex, if_src), src_queue_id, + if_indextoname(dst_ifindex, if_dst), rsp->dst_queue_id); + + netdev_bind_queue_rsp_free(rsp); + ynl_sock_destroy(ys); + return 0; +err: + fprintf(stderr, "YNL: %s\n", ys->err.msg); + ynl_sock_destroy(ys); + return 2; +} -- 2.43.0