From nobody Sat May 18 22:14:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1612456775; cv=none; d=zohomail.com; s=zohoarc; b=QdI1CDGicZqtS7fPQ9p8Iuy5s4U6EVmAIxi9Tvd9lLYtmlEjxUFyUQedMIX0DvU8pd2shS5mZcNis2jWvjFm6pwj6wzHPx6/2LHTCd8BL0Qps60fd5glOufVdG6aZGNLWCungERoo0H073vIvxvNwlE6M3bJyxH6ZtseTjsxz5M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612456775; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Qy2e9yCeCbLW2TyypLKklMLFEi/pzkwaSVzGs7kRXVI=; b=hG4+n0jGUVyoffCT+jbSrQ+khg0LuncQS7ucUzIbb89/hzgoNtdT540hK89Z6tXmnD6lP5KELYHLTshW4jnZ1iBkDUEyEVpLLa0hTVMB84anOXBFGiffqgbPaP+dAZYnqX6JvRZw/2Q6IaTok9uXiEWhgXIQdB8hNEm/yu439Z0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1612456775881222.2073959490573; Thu, 4 Feb 2021 08:39:35 -0800 (PST) Received: from localhost ([::1]:60610 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7hfK-0006sm-QD for importer@patchew.org; Thu, 04 Feb 2021 11:39:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38942) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7hbk-0002xM-Az for qemu-devel@nongnu.org; Thu, 04 Feb 2021 11:35:52 -0500 Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]:38379) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l7hbi-0002T1-FS for qemu-devel@nongnu.org; Thu, 04 Feb 2021 11:35:52 -0500 Received: by mail-lf1-x12c.google.com with SMTP id m22so5458962lfg.5 for ; Thu, 04 Feb 2021 08:35:47 -0800 (PST) Received: from navi.cosmonova.net.ua ([95.67.24.131]) by smtp.gmail.com with ESMTPSA id c123sm668172lfd.95.2021.02.04.08.35.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 08:35:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Qy2e9yCeCbLW2TyypLKklMLFEi/pzkwaSVzGs7kRXVI=; b=JxrWS/taYgEJYx/TwwjKbQEo/84rgFhKatuvH1oeqFtnZy+jT1Nm9kaKPeVXZQPJB0 0mNcjDN2kag/HbQoZcYGCf51zusCEOubqW7h79saG8QGgJHC4aT9eO1TZBvCrPQRDXzF ZOe7WHK6ZI/h6owVKO7KU2pRdB5gWnGb+m96h3eXzDBh4Tx057LFhZPf+rGyDVyAewkO CANz2vQSWfHQi/WKaCjB1Y3/pCVbDPSHze84lnvSfdYD/zeyJHvjD3VAT8r4kVbOzU2K MRSmFAdYDgYdxrZry9FKtNQ0CcaQKsNblOHIBNQEyFApChIevnCLayQRHXqRFmNeYaGt qPrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Qy2e9yCeCbLW2TyypLKklMLFEi/pzkwaSVzGs7kRXVI=; b=F7wqPvotJwvcPAZNprEUG0049GCYCcKbxnRsFAx1tsSQgUJKPR1zWKsGVm+5qey0II jK0DNOkCwMX/eHf9ZgxiL5vZVrFpyvgYOHxDqAXmHguvW4WdzDc/YNHTqErGCFj8Btye W9Px1af6Ly+7Qd8UB2JoxcGAsNtQSUlVEtEM2gwZ28D+nnv4r3Cqyy9L8vC9zJ7P3YWq IXaDbE6l/6PqHM/kIu0YlLMpQ5AKz9gBCznuzICoOTTh5xx9sSide04xU69Q0B0dWE2h RyjFmcO7jmYNkGzY3c6rtWwj1uTeoBO2zoDpTK7hG48mXsHMFbJL8UEuUcu6Y8AuZXuw cfug== X-Gm-Message-State: AOAM5325klcUoQnJ2TzZzUaTDl0PHQouPP6PoEqrfKCo2JSFTRJMzmXa 6BIqqXFssFgRL/sbBYfvzP/0rQ== X-Google-Smtp-Source: ABdhPJx3cNxqn27C4RbBqxVUPiXKdhTpaav9fno3Yb8azMotfci6lMK3bhW1P3cb5c1ahVNC9YYV6A== X-Received: by 2002:a05:6512:516:: with SMTP id o22mr103585lfb.487.1612456544295; Thu, 04 Feb 2021 08:35:44 -0800 (PST) From: Andrew Melnychenko To: jasowang@redhat.com, mst@redhat.com Subject: [RFC PATCH v4 1/7] net/tap: Added TUNSETSTEERINGEBPF code. Date: Thu, 4 Feb 2021 19:09:45 +0200 Message-Id: <20210204170951.91805-2-andrew@daynix.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210204170951.91805-1-andrew@daynix.com> References: <20210204170951.91805-1-andrew@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2a00:1450:4864:20::12c; envelope-from=andrew@daynix.com; helo=mail-lf1-x12c.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yan@daynix.com, yuri.benditovich@daynix.com, berrange@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Andrew Additional code that will be used for eBPF setting steering routine. Signed-off-by: Andrew Melnychenko --- net/tap-linux.h | 1 + 1 file changed, 1 insertion(+) diff --git a/net/tap-linux.h b/net/tap-linux.h index 2f36d100fc..1d06fe0de6 100644 --- a/net/tap-linux.h +++ b/net/tap-linux.h @@ -31,6 +31,7 @@ #define TUNSETQUEUE _IOW('T', 217, int) #define TUNSETVNETLE _IOW('T', 220, int) #define TUNSETVNETBE _IOW('T', 222, int) +#define TUNSETSTEERINGEBPF _IOR('T', 224, int) =20 #endif =20 --=20 2.30.0 From nobody Sat May 18 22:14:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1612457399; cv=none; d=zohomail.com; s=zohoarc; b=Ci1Ccs9CeuEkf+io4kIBTGP75nHPYLs+WtCMiadthO1lJqiXUzWttMxSJOLHBPI1nKVGFfIuxq0K2t7P8K4QIubNl+Ta0ycJZf+zqVt69sLF1K1thmKdmD6NGvOK7olEvj1nUN5u6KO8bp8nPp0XhvDZhn5zUGOV06nQRUxVL2A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612457399; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cP5ueAi9y+O3krqgK3UyLK5m0SKkF5/Zu4Expc80iEI=; b=TfeIMjaaxR1FrHx06FgQHNXJ2oQ11oJfRA+2XMNB8apjBYP2D7QxJmSiEbPWyC5pqf2w8KtPNL+YOHVe2MFiFBcclrecoubImd3X+dA+hyIvQXraIMSBtEO/QAfh8Qodi7A/YC/X9o1C0frqYugWxlRZRqiKSd2BFJRyVBAw8s4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 161245739951984.85087982541756; Thu, 4 Feb 2021 08:49:59 -0800 (PST) Received: from localhost ([::1]:33676 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7hpO-0003dO-Fy for importer@patchew.org; Thu, 04 Feb 2021 11:49:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38970) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7hbl-00030l-HX for qemu-devel@nongnu.org; Thu, 04 Feb 2021 11:35:53 -0500 Received: from mail-lj1-x22c.google.com ([2a00:1450:4864:20::22c]:41903) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l7hbi-0002Sy-F6 for qemu-devel@nongnu.org; Thu, 04 Feb 2021 11:35:53 -0500 Received: by mail-lj1-x22c.google.com with SMTP id y14so4144707ljn.8 for ; Thu, 04 Feb 2021 08:35:47 -0800 (PST) Received: from navi.cosmonova.net.ua ([95.67.24.131]) by smtp.gmail.com with ESMTPSA id c123sm668172lfd.95.2021.02.04.08.35.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 08:35:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cP5ueAi9y+O3krqgK3UyLK5m0SKkF5/Zu4Expc80iEI=; b=S5t1ioK7SaiODl7ycSCAQ6/cFd5zttCAva6SHYmn+fViICLJ7PezoCtphIlzw1a2Uv 8NWv1kcaYHQYDgs3Jv30qcOrsfOV8KV+2p67pFlbma8rUqwpSLcHXM4iikzpqcI0LCh6 88EspThFqnclqy6Dvg4LBpJMs36CZXOiU5To6kLA9eUF5hTAWVpIAObO8cuWNOEGk2fy M424nN3TOJhFH5crSlJt3rRyqYJ4TFJNbf3jcv/35GTm4m98T9nEMPKEhGP/hDaaD+WX n1eUoUeLWH/3ASoFXdr1kDw0uk/RW8H5Wv+00wdqe/z4z69r8VOH9A3tvENKTI7HpLqF uY1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cP5ueAi9y+O3krqgK3UyLK5m0SKkF5/Zu4Expc80iEI=; b=ltqhh51G+ctnMM+RvfAiz1nZ7Q2ZSG6NLXiMtmPb7Mi+HRdiX8nT1NyGxcwhW+8yD+ whZsLp27anNs4fufRBBMaUl4tbr5ZztxEHLdvdKvvH7tMrI+mB7knBNKz08DChUXPvXB COv+Yd5hu2uF1xMRkJ7zMsxv6aQE+r3apUMx3PmCjgtRZPWUIUbU0joWTNqWkLUiedeG TePOiX3E+YJ+y3aHqVKSARzORIVnFFakQZbf7rOqrt0g8/Djlbzg2P4wb4pksw+1/4Xi PkfA8hr4eqI83aFuo7GNwKOL4WRMHAbzAk2ZirSh0CpWTcaCjyGKCPstsJtTc2f6Lhz8 bC8g== X-Gm-Message-State: AOAM532hhdtuVlACH8PjPn8d7nKNtkgTtZB/zdL1iJ40cBTvekGNn6OW NHpZrQm8kgBm09UM+ncMLtQZpA== X-Google-Smtp-Source: ABdhPJwWbM6avGr6YHUPumwr9pWvyqrb4tUZWBv/OQJnph4Edwtq8SGoe71Z979nlOgPrwC6y7jWwg== X-Received: by 2002:a05:651c:2049:: with SMTP id t9mr104431ljo.505.1612456545555; Thu, 04 Feb 2021 08:35:45 -0800 (PST) From: Andrew Melnychenko To: jasowang@redhat.com, mst@redhat.com Subject: [RFC PATCH v4 2/7] net: Added SetSteeringEBPF method for NetClientState. Date: Thu, 4 Feb 2021 19:09:46 +0200 Message-Id: <20210204170951.91805-3-andrew@daynix.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210204170951.91805-1-andrew@daynix.com> References: <20210204170951.91805-1-andrew@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2a00:1450:4864:20::22c; envelope-from=andrew@daynix.com; helo=mail-lj1-x22c.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yan@daynix.com, yuri.benditovich@daynix.com, berrange@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Andrew For now, that method supported only by Linux TAP. Linux TAP uses TUNSETSTEERINGEBPF ioctl. Signed-off-by: Andrew Melnychenko --- include/net/net.h | 2 ++ net/tap-bsd.c | 5 +++++ net/tap-linux.c | 13 +++++++++++++ net/tap-solaris.c | 5 +++++ net/tap-stub.c | 5 +++++ net/tap.c | 9 +++++++++ net/tap_int.h | 1 + 7 files changed, 40 insertions(+) diff --git a/include/net/net.h b/include/net/net.h index 919facaad2..d77fbb8878 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -61,6 +61,7 @@ typedef int (SetVnetBE)(NetClientState *, bool); typedef struct SocketReadState SocketReadState; typedef void (SocketReadStateFinalize)(SocketReadState *rs); typedef void (NetAnnounce)(NetClientState *); +typedef bool (SetSteeringEBPF)(NetClientState *, int); =20 typedef struct NetClientInfo { NetClientDriver type; @@ -82,6 +83,7 @@ typedef struct NetClientInfo { SetVnetLE *set_vnet_le; SetVnetBE *set_vnet_be; NetAnnounce *announce; + SetSteeringEBPF *set_steering_ebpf; } NetClientInfo; =20 struct NetClientState { diff --git a/net/tap-bsd.c b/net/tap-bsd.c index 77aaf674b1..4f64f31e98 100644 --- a/net/tap-bsd.c +++ b/net/tap-bsd.c @@ -259,3 +259,8 @@ int tap_fd_get_ifname(int fd, char *ifname) { return -1; } + +int tap_fd_set_steering_ebpf(int fd, int prog_fd) +{ + return -1; +} diff --git a/net/tap-linux.c b/net/tap-linux.c index b0635e9e32..9584769740 100644 --- a/net/tap-linux.c +++ b/net/tap-linux.c @@ -316,3 +316,16 @@ int tap_fd_get_ifname(int fd, char *ifname) pstrcpy(ifname, sizeof(ifr.ifr_name), ifr.ifr_name); return 0; } + +int tap_fd_set_steering_ebpf(int fd, int prog_fd) +{ + if (ioctl(fd, TUNSETSTEERINGEBPF, (void *) &prog_fd) !=3D 0) { + error_report("Issue while setting TUNSETSTEERINGEBPF:" + " %s with fd: %d, prog_fd: %d", + strerror(errno), fd, prog_fd); + + return -1; + } + + return 0; +} diff --git a/net/tap-solaris.c b/net/tap-solaris.c index 0475a58207..d85224242b 100644 --- a/net/tap-solaris.c +++ b/net/tap-solaris.c @@ -255,3 +255,8 @@ int tap_fd_get_ifname(int fd, char *ifname) { return -1; } + +int tap_fd_set_steering_ebpf(int fd, int prog_fd) +{ + return -1; +} diff --git a/net/tap-stub.c b/net/tap-stub.c index de525a2e69..a0fa25804b 100644 --- a/net/tap-stub.c +++ b/net/tap-stub.c @@ -85,3 +85,8 @@ int tap_fd_get_ifname(int fd, char *ifname) { return -1; } + +int tap_fd_set_steering_ebpf(int fd, int prog_fd) +{ + return -1; +} diff --git a/net/tap.c b/net/tap.c index b7512853f4..d0c1356a04 100644 --- a/net/tap.c +++ b/net/tap.c @@ -337,6 +337,14 @@ static void tap_poll(NetClientState *nc, bool enable) tap_write_poll(s, enable); } =20 +static bool tap_set_steering_ebpf(NetClientState *nc, int prog_fd) +{ + TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_TAP); + + return tap_fd_set_steering_ebpf(s->fd, prog_fd) =3D=3D 0; +} + int tap_get_fd(NetClientState *nc) { TAPState *s =3D DO_UPCAST(TAPState, nc, nc); @@ -362,6 +370,7 @@ static NetClientInfo net_tap_info =3D { .set_vnet_hdr_len =3D tap_set_vnet_hdr_len, .set_vnet_le =3D tap_set_vnet_le, .set_vnet_be =3D tap_set_vnet_be, + .set_steering_ebpf =3D tap_set_steering_ebpf, }; =20 static TAPState *net_tap_fd_init(NetClientState *peer, diff --git a/net/tap_int.h b/net/tap_int.h index 225a49ea48..547f8a5a28 100644 --- a/net/tap_int.h +++ b/net/tap_int.h @@ -44,5 +44,6 @@ int tap_fd_set_vnet_be(int fd, int vnet_is_be); int tap_fd_enable(int fd); int tap_fd_disable(int fd); int tap_fd_get_ifname(int fd, char *ifname); +int tap_fd_set_steering_ebpf(int fd, int prog_fd); =20 #endif /* NET_TAP_INT_H */ --=20 2.30.0 From nobody Sat May 18 22:14:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1612457650; cv=none; d=zohomail.com; s=zohoarc; b=IIb6t7p0yrK77zb12b6nutBr3SMP89UfZZzpsHDhFE/uFCegXvr87TYxISRa+KjpD8Ik3n8iLfC5n4jP+0TWdQ8DshnRy67AqnITUiMB6pvJrYEtsg3fx/Ec4t7SdzMCvhZiFI3kfP0dDMueIhh4eXNL6o0zcwg/8c7z0inri4o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612457650; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SmzgTivoWQvVwlqs0QHa20WqNbX1BgiLp4ouGGix+XM=; b=HCK/qL3VJK2MMXzrlu/FhCIW+vi6VXZYXVPQGP4aHM7Z3gf2Nfr5iD6+W5ADJNBjJ/Q3kw7Xh5ngw7GJWq+/fizyN7K6CAR1TBhGTBZ2vnF0QiepV4Js/7I7AUaA9MU4Bv01LHjZYL1jEmXU1BrxNh+i+5z6qhxdOfPtAAdlNOA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1612457650393244.20215507092155; Thu, 4 Feb 2021 08:54:10 -0800 (PST) Received: from localhost ([::1]:42372 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7htR-0007fv-5J for importer@patchew.org; Thu, 04 Feb 2021 11:54:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38998) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7hbn-00034s-2g for qemu-devel@nongnu.org; Thu, 04 Feb 2021 11:35:55 -0500 Received: from mail-lj1-x242.google.com ([2a00:1450:4864:20::242]:44874) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l7hbj-0002U2-I2 for qemu-devel@nongnu.org; Thu, 04 Feb 2021 11:35:54 -0500 Received: by mail-lj1-x242.google.com with SMTP id f2so4113545ljp.11 for ; Thu, 04 Feb 2021 08:35:51 -0800 (PST) Received: from navi.cosmonova.net.ua ([95.67.24.131]) by smtp.gmail.com with ESMTPSA id c123sm668172lfd.95.2021.02.04.08.35.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 08:35:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SmzgTivoWQvVwlqs0QHa20WqNbX1BgiLp4ouGGix+XM=; b=o5qvcIyKoxsTrQYKLh8ZY5l+ovsyNykqZnY3pRVS1x1NMr71XYuOdDern+3gm548s1 d1NbdhAdiweJokEuGgVs23cX7jkljgAHqIMPnCRCaidNzHlEQCqeEvd3RYbz0fgARvSn hbIE/pQ4439Yz1DoSMMNp1O4bivbXkDeoa+GqYpMt2pm5XDUN5O910v+72tmjTCJ2M8Y HJFyoyuR98DBFIgDvEac45sr0B53FURugl1xUGwOfemnTRL2CJkYtTjxGb0hHeogengU 2hnGYTy24irWfMUVjM4p6GZip2e0JZOsLKTbpFonyEADLjua95Q4eUSWF0FXpxYDSc/H KOqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SmzgTivoWQvVwlqs0QHa20WqNbX1BgiLp4ouGGix+XM=; b=RzqNwgurxK3bhV4M9/4XwoTARsu+vFMsuH0t68XAeAhmz0r6tQZao97f2t+A1c9wLY qyBfwrcLBMbKKO1EMD1B4aEvcmb0dBt16gG1IVFTKuM9kObCp3KY7CdSpgdtEV96DQUz rryj4mY2flDXn9WE3s16EywqJ0tq/dvIgJFPPmYGUt0lX6y1n9gxu21ZxpyRjH3BJiIW xl1rxCar6h+mO6OjUVOkqp1RDNt1PTKqi0rF/CA8VSCzoYEWVKlR7QVqiTNf3K3npkAJ VKUIZ0hWhq+ybxv3Z1nRwgy1ujf6vPs7chSOmXq1spXoVBaj/i5BZ5Z2fJNAurXAVXZc sPiw== X-Gm-Message-State: AOAM532kTpRSl49syRLZ2rJLHUnbYtRNgOZWyG1e01F8OXbjjlOYT55v ZsTuj4wZjgN6E4po2mgO/aH2ZA== X-Google-Smtp-Source: ABdhPJx/sLPLAEq2ifCGNfuQviVSq00OQz7LOmZ23uLkTzEXdw03bdv1hRYoY6C2kQojQ/DWR4GeRg== X-Received: by 2002:a2e:964f:: with SMTP id z15mr138111ljh.368.1612456547087; Thu, 04 Feb 2021 08:35:47 -0800 (PST) From: Andrew Melnychenko To: jasowang@redhat.com, mst@redhat.com Subject: [RFC PATCH v4 3/7] ebpf: Added eBPF RSS program. Date: Thu, 4 Feb 2021 19:09:47 +0200 Message-Id: <20210204170951.91805-4-andrew@daynix.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210204170951.91805-1-andrew@daynix.com> References: <20210204170951.91805-1-andrew@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2a00:1450:4864:20::242; envelope-from=andrew@daynix.com; helo=mail-lj1-x242.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yan@daynix.com, yuri.benditovich@daynix.com, berrange@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Andrew RSS program and Makefile to build it. The bpftool used to generate '.h' file. The data in that file may be loaded by libbpf. EBPF compilation is not required for building qemu. You can use Makefile if you need to regenerate rss.bpf.skeleton.h. Signed-off-by: Yuri Benditovich Signed-off-by: Andrew Melnychenko --- tools/ebpf/Makefile.ebpf | 33 +++ tools/ebpf/rss.bpf.c | 505 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 538 insertions(+) create mode 100755 tools/ebpf/Makefile.ebpf create mode 100644 tools/ebpf/rss.bpf.c diff --git a/tools/ebpf/Makefile.ebpf b/tools/ebpf/Makefile.ebpf new file mode 100755 index 0000000000..d32d1680b8 --- /dev/null +++ b/tools/ebpf/Makefile.ebpf @@ -0,0 +1,33 @@ +OBJS =3D rss.bpf.o + +LLC ?=3D llc +CLANG ?=3D clang +INC_FLAGS =3D `$(CLANG) -print-file-name=3Dinclude` +EXTRA_CFLAGS ?=3D -O2 -emit-llvm -fno-stack-protector + +ifdef linuxhdrs +LINUXINCLUDE =3D -I $(linuxhdrs)/arch/x86/include/uapi \ + -I $(linuxhdrs)/arch/x86/include/generated/uapi \ + -I $(linuxhdrs)/arch/x86/include/generated \ + -I $(linuxhdrs)/include/generated/uapi \ + -I $(linuxhdrs)/include/uapi \ + -I $(linuxhdrs)/include \ + -I $(linuxhdrs)/tools/lib +INC_FLAGS +=3D -nostdinc -isystem +endif + +all: $(OBJS) + +.PHONY: clean + +clean: + rm -f $(OBJS) + +$(OBJS): %.o:%.c + $(CLANG) $(INC_FLAGS) \ + -D__KERNEL__ -D__ASM_SYSREG_H \ + -I../include $(LINUXINCLUDE) \ + $(EXTRA_CFLAGS) -c $< -o -| $(LLC) -march=3Dbpf -filetype= =3Dobj -o $@ + bpftool gen skeleton rss.bpf.o > rss.bpf.skeleton.h + cp rss.bpf.skeleton.h ../../ebpf/ + diff --git a/tools/ebpf/rss.bpf.c b/tools/ebpf/rss.bpf.c new file mode 100644 index 0000000000..eb377247fc --- /dev/null +++ b/tools/ebpf/rss.bpf.c @@ -0,0 +1,505 @@ +/* + * eBPF RSS program + * + * Developed by Daynix Computing LTD (http://www.daynix.com) + * + * Authors: + * Andrew Melnychenko + * Yuri Benditovich + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + * Prepare: + * Requires llvm, clang, bpftool, linux kernel tree + * + * Build rss.bpf.skeleton.h: + * make -f Makefile.ebpf clean all + */ + +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include +#include + +#define INDIRECTION_TABLE_SIZE 128 +#define HASH_CALCULATION_BUFFER_SIZE 36 + +struct rss_config_t { + __u8 redirect; + __u8 populate_hash; + __u32 hash_types; + __u16 indirections_len; + __u16 default_queue; +}; + +struct toeplitz_key_data_t { + __u32 leftmost_32_bits; + __u8 next_byte[HASH_CALCULATION_BUFFER_SIZE]; +}; + +struct packet_hash_info_t { + __u8 is_ipv4; + __u8 is_ipv6; + __u8 is_udp; + __u8 is_tcp; + __u8 is_ipv6_ext_src; + __u8 is_ipv6_ext_dst; + + __u16 src_port; + __u16 dst_port; + + union { + struct { + __be32 in_src; + __be32 in_dst; + }; + + struct { + struct in6_addr in6_src; + struct in6_addr in6_dst; + struct in6_addr in6_ext_src; + struct in6_addr in6_ext_dst; + }; + }; +}; + +struct bpf_map_def SEC("maps") +tap_rss_map_configurations =3D { + .type =3D BPF_MAP_TYPE_ARRAY, + .key_size =3D sizeof(__u32), + .value_size =3D sizeof(struct rss_config_t), + .max_entries =3D 1, +}; + +struct bpf_map_def SEC("maps") +tap_rss_map_toeplitz_key =3D { + .type =3D BPF_MAP_TYPE_ARRAY, + .key_size =3D sizeof(__u32), + .value_size =3D sizeof(struct toeplitz_key_data_t), + .max_entries =3D 1, +}; + +struct bpf_map_def SEC("maps") +tap_rss_map_indirection_table =3D { + .type =3D BPF_MAP_TYPE_ARRAY, + .key_size =3D sizeof(__u32), + .value_size =3D sizeof(__u16), + .max_entries =3D INDIRECTION_TABLE_SIZE, +}; + +static inline void net_rx_rss_add_chunk(__u8 *rss_input, size_t *bytes_wri= tten, + const void *ptr, size_t size) { + __builtin_memcpy(&rss_input[*bytes_written], ptr, size); + *bytes_written +=3D size; +} + +static inline +void net_toeplitz_add(__u32 *result, + __u8 *input, + __u32 len + , struct toeplitz_key_data_t *key) { + + __u32 accumulator =3D *result; + __u32 leftmost_32_bits =3D key->leftmost_32_bits; + __u32 byte; + + for (byte =3D 0; byte < HASH_CALCULATION_BUFFER_SIZE; byte++) { + __u8 input_byte =3D input[byte]; + __u8 key_byte =3D key->next_byte[byte]; + __u8 bit; + + for (bit =3D 0; bit < 8; bit++) { + if (input_byte & (1 << 7)) { + accumulator ^=3D leftmost_32_bits; + } + + leftmost_32_bits =3D + (leftmost_32_bits << 1) | ((key_byte & (1 << 7)) >> 7); + + input_byte <<=3D 1; + key_byte <<=3D 1; + } + } + + *result =3D accumulator; +} + + +static inline int ip6_extension_header_type(__u8 hdr_type) +{ + switch (hdr_type) { + case IPPROTO_HOPOPTS: + case IPPROTO_ROUTING: + case IPPROTO_FRAGMENT: + case IPPROTO_ICMPV6: + case IPPROTO_NONE: + case IPPROTO_DSTOPTS: + case IPPROTO_MH: + return 1; + default: + return 0; + } +} +/* + * According to https://www.iana.org/assignments/ipv6-parameters/ipv6-para= meters.xhtml + * we suspect that there are would be no more than 11 extensions in IPv6 h= eader, + * also there is 27 TLV options for Destination and Hop-by-hop extensions. + * Need to choose reasonable amount of maximum extensions/options we may c= heck to find + * ext src/dst. + */ +#define IP6_EXTENSIONS_COUNT 11 +#define IP6_OPTIONS_COUNT 30 + +static inline void parse_ipv6_ext(struct __sk_buff *skb, + struct packet_hash_info_t *info, + __u8 *l4_protocol, size_t *l4_offset) +{ + if (!ip6_extension_header_type(*l4_protocol)) { + return; + } + + struct ipv6_opt_hdr ext_hdr =3D {}; + + for (unsigned int i =3D 0; i < IP6_EXTENSIONS_COUNT; ++i) { + + bpf_skb_load_bytes_relative(skb, *l4_offset, &ext_hdr, + sizeof(ext_hdr), BPF_HDR_START_NET); + + if (*l4_protocol =3D=3D IPPROTO_ROUTING) { + struct ipv6_rt_hdr ext_rt =3D {}; + + bpf_skb_load_bytes_relative(skb, *l4_offset, &ext_rt, + sizeof(ext_rt), BPF_HDR_START_NET); + + if ((ext_rt.type =3D=3D IPV6_SRCRT_TYPE_2) && + (ext_rt.hdrlen =3D=3D sizeof(struct in6_addr) / 8) && + (ext_rt.segments_left =3D=3D 1)) { + + bpf_skb_load_bytes_relative(skb, + *l4_offset + offsetof(struct rt2_hdr, addr), + &info->in6_ext_dst, sizeof(info->in6_ext_dst), + BPF_HDR_START_NET); + + info->is_ipv6_ext_dst =3D 1; + } + + } else if (*l4_protocol =3D=3D IPPROTO_DSTOPTS) { + struct ipv6_opt_t { + __u8 type; + __u8 length; + } __attribute__((packed)) opt =3D {}; + + size_t opt_offset =3D sizeof(ext_hdr); + + for (unsigned int j =3D 0; j < IP6_OPTIONS_COUNT; ++j) { + bpf_skb_load_bytes_relative(skb, *l4_offset + opt_offset, + &opt, sizeof(opt), BPF_HDR_START_N= ET); + + opt_offset +=3D (opt.type =3D=3D IPV6_TLV_PAD1) ? + 1 : opt.length + sizeof(opt); + + if (opt_offset + 1 >=3D ext_hdr.hdrlen * 8) { + break; + } + + if (opt.type =3D=3D IPV6_TLV_HAO) { + bpf_skb_load_bytes_relative(skb, + *l4_offset + opt_offset + offsetof(struct ipv6_des= topt_hao, addr), + &info->is_ipv6_ext_src, sizeof(info->is_ipv6_ext_s= rc), + BPF_HDR_START_NET); + + info->is_ipv6_ext_src =3D 1; + break; + } + } + } + + *l4_protocol =3D ext_hdr.nexthdr; + *l4_offset +=3D (ext_hdr.hdrlen + 1) * 8; + + if (!ip6_extension_header_type(ext_hdr.nexthdr)) { + return; + } + } +} + +static __be16 parse_eth_type(struct __sk_buff *skb) +{ + unsigned int offset =3D 12; + __be16 ret =3D 0; + + bpf_skb_load_bytes_relative(skb, offset, &ret, sizeof(ret), + BPF_HDR_START_MAC); + + switch (__be16_to_cpu(ret)) { + case ETH_P_8021AD: + offset +=3D 4; + case ETH_P_8021Q: + offset +=3D 4; + bpf_skb_load_bytes_relative(skb, offset, &ret, sizeof(ret), + BPF_HDR_START_MAC); + default: + break; + } + + return ret; +} + +static inline void parse_packet(struct __sk_buff *skb, + struct packet_hash_info_t *info) +{ + if (!info || !skb) { + return; + } + + size_t l4_offset =3D 0; + __u8 l4_protocol =3D 0; + __u16 l3_protocol =3D __be16_to_cpu(parse_eth_type(skb)); + + if (l3_protocol =3D=3D ETH_P_IP) { + info->is_ipv4 =3D 1; + + struct iphdr ip =3D {}; + bpf_skb_load_bytes_relative(skb, 0, &ip, sizeof(ip), + BPF_HDR_START_NET); + + info->in_src =3D ip.saddr; + info->in_dst =3D ip.daddr; + + l4_protocol =3D ip.protocol; + l4_offset =3D ip.ihl * 4; + } else if (l3_protocol =3D=3D ETH_P_IPV6) { + info->is_ipv6 =3D 1; + + struct ipv6hdr ip6 =3D {}; + bpf_skb_load_bytes_relative(skb, 0, &ip6, sizeof(ip6), + BPF_HDR_START_NET); + + info->in6_src =3D ip6.saddr; + info->in6_dst =3D ip6.daddr; + + l4_protocol =3D ip6.nexthdr; + l4_offset =3D sizeof(ip6); + + parse_ipv6_ext(skb, info, &l4_protocol, &l4_offset); + } + + if (l4_protocol !=3D 0) { + if (l4_protocol =3D=3D IPPROTO_TCP) { + info->is_tcp =3D 1; + + struct tcphdr tcp =3D {}; + bpf_skb_load_bytes_relative(skb, l4_offset, &tcp, sizeof(tcp), + BPF_HDR_START_NET); + + info->src_port =3D tcp.source; + info->dst_port =3D tcp.dest; + } else if (l4_protocol =3D=3D IPPROTO_UDP) { /* TODO: add udplite?= */ + info->is_udp =3D 1; + + struct udphdr udp =3D {}; + bpf_skb_load_bytes_relative(skb, l4_offset, &udp, sizeof(udp), + BPF_HDR_START_NET); + + info->src_port =3D udp.source; + info->dst_port =3D udp.dest; + } + } +} + +static inline __u32 calculate_rss_hash(struct __sk_buff *skb, + struct rss_config_t *config, struct toeplitz_key_data_t *toe) +{ + __u8 rss_input[HASH_CALCULATION_BUFFER_SIZE] =3D {}; + size_t bytes_written =3D 0; + __u32 result =3D 0; + struct packet_hash_info_t packet_info =3D {}; + + parse_packet(skb, &packet_info); + + if (packet_info.is_ipv4) { + if (packet_info.is_tcp && + config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_TCPv4) { + + net_rx_rss_add_chunk(rss_input, &bytes_written, + &packet_info.in_src, + sizeof(packet_info.in_src)); + net_rx_rss_add_chunk(rss_input, &bytes_written, + &packet_info.in_dst, + sizeof(packet_info.in_dst)); + net_rx_rss_add_chunk(rss_input, &bytes_written, + &packet_info.src_port, + sizeof(packet_info.src_port)); + net_rx_rss_add_chunk(rss_input, &bytes_written, + &packet_info.dst_port, + sizeof(packet_info.dst_port)); + } else if (packet_info.is_udp && + config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_UDPv4) { + + net_rx_rss_add_chunk(rss_input, &bytes_written, + &packet_info.in_src, + sizeof(packet_info.in_src)); + net_rx_rss_add_chunk(rss_input, &bytes_written, + &packet_info.in_dst, + sizeof(packet_info.in_dst)); + net_rx_rss_add_chunk(rss_input, &bytes_written, + &packet_info.src_port, + sizeof(packet_info.src_port)); + net_rx_rss_add_chunk(rss_input, &bytes_written, + &packet_info.dst_port, + sizeof(packet_info.dst_port)); + } else if (config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_IPv4) { + net_rx_rss_add_chunk(rss_input, &bytes_written, + &packet_info.in_src, + sizeof(packet_info.in_src)); + net_rx_rss_add_chunk(rss_input, &bytes_written, + &packet_info.in_dst, + sizeof(packet_info.in_dst)); + } + } else if (packet_info.is_ipv6) { + if (packet_info.is_tcp && + config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_TCPv6) { + + if (packet_info.is_ipv6_ext_src && + config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_TCP_EX) { + + net_rx_rss_add_chunk(rss_input, &bytes_written, + &packet_info.in6_ext_src, + sizeof(packet_info.in6_ext_src)); + } else { + net_rx_rss_add_chunk(rss_input, &bytes_written, + &packet_info.in6_src, + sizeof(packet_info.in6_src)); + } + if (packet_info.is_ipv6_ext_dst && + config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_TCP_EX) { + + net_rx_rss_add_chunk(rss_input, &bytes_written, + &packet_info.in6_ext_dst, + sizeof(packet_info.in6_ext_dst)); + } else { + net_rx_rss_add_chunk(rss_input, &bytes_written, + &packet_info.in6_dst, + sizeof(packet_info.in6_dst)); + } + net_rx_rss_add_chunk(rss_input, &bytes_written, + &packet_info.src_port, + sizeof(packet_info.src_port)); + net_rx_rss_add_chunk(rss_input, &bytes_written, + &packet_info.dst_port, + sizeof(packet_info.dst_port)); + } else if (packet_info.is_udp && + config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_UDPv6) { + + if (packet_info.is_ipv6_ext_src && + config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_UDP_EX) { + + net_rx_rss_add_chunk(rss_input, &bytes_written, + &packet_info.in6_ext_src, + sizeof(packet_info.in6_ext_src)); + } else { + net_rx_rss_add_chunk(rss_input, &bytes_written, + &packet_info.in6_src, + sizeof(packet_info.in6_src)); + } + if (packet_info.is_ipv6_ext_dst && + config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_UDP_EX) { + + net_rx_rss_add_chunk(rss_input, &bytes_written, + &packet_info.in6_ext_dst, + sizeof(packet_info.in6_ext_dst)); + } else { + net_rx_rss_add_chunk(rss_input, &bytes_written, + &packet_info.in6_dst, + sizeof(packet_info.in6_dst)); + } + + net_rx_rss_add_chunk(rss_input, &bytes_written, + &packet_info.src_port, + sizeof(packet_info.src_port)); + net_rx_rss_add_chunk(rss_input, &bytes_written, + &packet_info.dst_port, + sizeof(packet_info.dst_port)); + + } else if (config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_IPv6) { + if (packet_info.is_ipv6_ext_src && + config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_IP_EX) { + + net_rx_rss_add_chunk(rss_input, &bytes_written, + &packet_info.in6_ext_src, + sizeof(packet_info.in6_ext_src)); + } else { + net_rx_rss_add_chunk(rss_input, &bytes_written, + &packet_info.in6_src, + sizeof(packet_info.in6_src)); + } + if (packet_info.is_ipv6_ext_dst && + config->hash_types & VIRTIO_NET_RSS_HASH_TYPE_IP_EX) { + + net_rx_rss_add_chunk(rss_input, &bytes_written, + &packet_info.in6_ext_dst, + sizeof(packet_info.in6_ext_dst)); + } else { + net_rx_rss_add_chunk(rss_input, &bytes_written, + &packet_info.in6_dst, + sizeof(packet_info.in6_dst)); + } + } + } + + if (bytes_written) { + net_toeplitz_add(&result, rss_input, bytes_written, toe); + } + + return result; +} + +SEC("tun_rss_steering") +int tun_rss_steering_prog(struct __sk_buff *skb) +{ + + struct rss_config_t *config; + struct toeplitz_key_data_t *toe; + + __u32 key =3D 0; + __u32 hash =3D 0; + + config =3D bpf_map_lookup_elem(&tap_rss_map_configurations, &key); + toe =3D bpf_map_lookup_elem(&tap_rss_map_toeplitz_key, &key); + + if (config && toe) { + if (!config->redirect) { + return config->default_queue; + } + + hash =3D calculate_rss_hash(skb, config, toe); + if (hash) { + __u32 table_idx =3D hash % config->indirections_len; + __u16 *queue =3D 0; + + queue =3D bpf_map_lookup_elem(&tap_rss_map_indirection_table, + &table_idx); + + if (queue) { + return *queue; + } + } + + return config->default_queue; + } + + return -1; +} + +char _license[] SEC("license") =3D "GPL v2"; --=20 2.30.0 From nobody Sat May 18 22:14:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1612457610; cv=none; d=zohomail.com; s=zohoarc; b=WaljYhBearUdZJd13Vj+vFZVC55X6gjsn7bnzP7O9X5KR8nXR74MPec26Lx+nqHpWFb84s7nGTJrqDplrsQLYA0qfuyXWApUF7RJiXx7XY1Co/etB2zPxDq05njLzpLbXKju0c1Q9GDCIiepO0XOYCzM8FVqywP69qooNPbVMMI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612457610; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NkQNDc0ZSaen4++5XWWjIQjwZEogfjMNf3dCFblL4oc=; b=lklIQiz42N2/Kj5VfOIc4OpiRwBDQ8Dc/19APYgcfr175jZdi0pwgRuvay+sD7bbNG2p9VzfB+NdKWxjFTTFSs7FFRGJOnSIcX+2SjszW1KqUTdAQeL1Idw3OGy6MAduCsI68cGqC7NKEyd/M2feIq+maR4gTs3zbwGjm7bX/JM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1612457610251882.9343492954837; Thu, 4 Feb 2021 08:53:30 -0800 (PST) Received: from localhost ([::1]:41206 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7hsl-00079P-W5 for importer@patchew.org; Thu, 04 Feb 2021 11:53:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39024) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7hbp-0003BJ-Br for qemu-devel@nongnu.org; Thu, 04 Feb 2021 11:35:57 -0500 Received: from mail-lj1-x242.google.com ([2a00:1450:4864:20::242]:45764) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l7hbl-0002V0-82 for qemu-devel@nongnu.org; Thu, 04 Feb 2021 11:35:57 -0500 Received: by mail-lj1-x242.google.com with SMTP id e18so4109728lja.12 for ; Thu, 04 Feb 2021 08:35:52 -0800 (PST) Received: from navi.cosmonova.net.ua ([95.67.24.131]) by smtp.gmail.com with ESMTPSA id c123sm668172lfd.95.2021.02.04.08.35.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 08:35:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NkQNDc0ZSaen4++5XWWjIQjwZEogfjMNf3dCFblL4oc=; b=S3Srk8HU01Q6DkiSCqxbE/2sXz8G9/nF2yq3hkUWAPQXRgih76WxmYuUFRNpma1c7m 4iiaOceQ8XlKEGZnkPMwm0B1DPd1qerDCOskbmBG1//ZTENRIFuEngnKpInn8jOYjFaG +tIlqUHrTkZD3/+sA2TGrgIzBlPiDhtnPeNAsDUcflf4hcSQuYjT1CB55RykoEiKyye1 h4A0KG4CGNpPsJ+MB5yjz00O/GR9Q9ACJA9G0ru/QpNu34ZpFJiwMSdZn9R9UspsoUPQ WLyszUrnuXkK5nFPmVEwYFc4M5Yafg+0IUIGVtuyw4fCxoMnbaSaJ2jM7OkxJopD+aWt Qm5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NkQNDc0ZSaen4++5XWWjIQjwZEogfjMNf3dCFblL4oc=; b=Wk0cXm4LwOSXxPVVUzSe8+XGnSFX761/cUjg23vwf+tNT6XxexJK/2+wrMega4IqVj ErPOYsi3Ck2LwsMI6fqvCqdHqeW95/sN+Lj/AwFZJc/PONVN07KJd2j3NRUOZnwVs3S2 trkeOL/s9EtfV/jUswjQVjY+rRdsaud/GrOhe5ZioIbh1HyRiUw6XJhy7GC/1Y9I93Aq 2+d3SYg28iVluL3EK2Katrl+Lr/F9Gyf9d28vg57rUEtNNW8q5YIkHihcoJtP5as5Vax H4vLFwo0rsKE/v0oLYa2BGNjePtVJIbDHDQ0jW4NktSGqFWaJfqhmoewcy5k4LgA+4t0 9l+w== X-Gm-Message-State: AOAM5326kPhQ8OXfdBLmssX/4wQ49nB56kTxIMBcggX1z0IJjl/j53yM kNHpS+Lb2yxDyMdx30l2ZzMZ3w== X-Google-Smtp-Source: ABdhPJyCPsiLMIFOBJ20qJjdbS1O4w4twZjghUCU95N0dJHrr91dU3xRuS86egBopHMsm9QqowJ76w== X-Received: by 2002:a2e:9bce:: with SMTP id w14mr145644ljj.120.1612456548439; Thu, 04 Feb 2021 08:35:48 -0800 (PST) From: Andrew Melnychenko To: jasowang@redhat.com, mst@redhat.com Subject: [RFC PATCH v4 4/7] ebpf: Added eBPF RSS loader. Date: Thu, 4 Feb 2021 19:09:48 +0200 Message-Id: <20210204170951.91805-5-andrew@daynix.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210204170951.91805-1-andrew@daynix.com> References: <20210204170951.91805-1-andrew@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2a00:1450:4864:20::242; envelope-from=andrew@daynix.com; helo=mail-lj1-x242.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yan@daynix.com, yuri.benditovich@daynix.com, berrange@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Andrew Added function that loads RSS eBPF program. Added stub functions for RSS eBPF loader. Added meson and configuration options. By default, eBPF feature enabled if libbpf is present in the build system. libbpf checked in configuration shell script and meson script. Signed-off-by: Yuri Benditovich Signed-off-by: Andrew Melnychenko --- configure | 30 +++ ebpf/ebpf_rss-stub.c | 40 ++++ ebpf/ebpf_rss.c | 165 +++++++++++++++++ ebpf/ebpf_rss.h | 44 +++++ ebpf/meson.build | 1 + ebpf/rss.bpf.skeleton.h | 397 ++++++++++++++++++++++++++++++++++++++++ ebpf/trace-events | 4 + ebpf/trace.h | 2 + meson.build | 13 ++ 9 files changed, 696 insertions(+) create mode 100644 ebpf/ebpf_rss-stub.c create mode 100644 ebpf/ebpf_rss.c create mode 100644 ebpf/ebpf_rss.h create mode 100644 ebpf/meson.build create mode 100644 ebpf/rss.bpf.skeleton.h create mode 100644 ebpf/trace-events create mode 100644 ebpf/trace.h diff --git a/configure b/configure index e85d6baf8f..38797e0116 100755 --- a/configure +++ b/configure @@ -348,6 +348,7 @@ vhost_vsock=3D"$default_feature" vhost_user=3D"no" vhost_user_blk_server=3D"auto" vhost_user_fs=3D"$default_feature" +bpf=3D"" kvm=3D"auto" hax=3D"auto" hvf=3D"auto" @@ -1227,6 +1228,10 @@ for opt do ;; --enable-membarrier) membarrier=3D"yes" ;; + --disable-bpf) bpf=3D"no" + ;; + --enable-bpf) bpf=3D"yes" + ;; --disable-blobs) blobs=3D"false" ;; --with-pkgversion=3D*) pkgversion=3D"$optarg" @@ -1856,6 +1861,7 @@ disabled with --disable-FEATURE, default is enabled i= f available vhost-user vhost-user backend support vhost-user-blk-server vhost-user-blk server support vhost-vdpa vhost-vdpa kernel backend support + bpf BPF kernel support spice spice rbd rados block device (rbd) libiscsi iscsi support @@ -5000,6 +5006,27 @@ else membarrier=3Dno fi =20 +########################################## +# check for usable bpf system call +if test "$bpf" =3D ""; then + have_bpf=3Dno + if test "$linux" =3D "yes" -a "$bigendian" !=3D "yes"; then + cat > $TMPC << EOF + #include + #include + int main(void) { + struct bpf_object *obj =3D NULL; + bpf_object__load(obj); + exit(0); + } +EOF + if compile_prog "" "-lbpf" ; then + have_bpf=3Dyes + bpf=3Dyes + fi + fi +fi + ########################################## # check if rtnetlink.h exists and is useful have_rtnetlink=3Dno @@ -5784,6 +5811,9 @@ fi if test "$membarrier" =3D "yes" ; then echo "CONFIG_MEMBARRIER=3Dy" >> $config_host_mak fi +if test "$bpf" =3D "yes" -a "$bigendian" !=3D "yes" -a "$linux" =3D "yes" = ; then + echo "CONFIG_EBPF=3Dy" >> $config_host_mak +fi if test "$signalfd" =3D "yes" ; then echo "CONFIG_SIGNALFD=3Dy" >> $config_host_mak fi diff --git a/ebpf/ebpf_rss-stub.c b/ebpf/ebpf_rss-stub.c new file mode 100644 index 0000000000..e71e229190 --- /dev/null +++ b/ebpf/ebpf_rss-stub.c @@ -0,0 +1,40 @@ +/* + * eBPF RSS stub file + * + * Developed by Daynix Computing LTD (http://www.daynix.com) + * + * Authors: + * Yuri Benditovich + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "ebpf/ebpf_rss.h" + +void ebpf_rss_init(struct EBPFRSSContext *ctx) +{ + +} + +bool ebpf_rss_is_loaded(struct EBPFRSSContext *ctx) +{ + return false; +} + +bool ebpf_rss_load(struct EBPFRSSContext *ctx) +{ + return false; +} + +bool ebpf_rss_set_all(struct EBPFRSSContext *ctx, struct EBPFRSSConfig *co= nfig, + uint16_t *indirections_table, uint8_t *toeplitz_key) +{ + return false; +} + +void ebpf_rss_unload(struct EBPFRSSContext *ctx) +{ + +} diff --git a/ebpf/ebpf_rss.c b/ebpf/ebpf_rss.c new file mode 100644 index 0000000000..118c68da83 --- /dev/null +++ b/ebpf/ebpf_rss.c @@ -0,0 +1,165 @@ +/* + * eBPF RSS loader + * + * Developed by Daynix Computing LTD (http://www.daynix.com) + * + * Authors: + * Andrew Melnychenko + * Yuri Benditovich + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qemu/error-report.h" + +#include +#include + +#include "hw/virtio/virtio-net.h" /* VIRTIO_NET_RSS_MAX_TABLE_LEN */ + +#include "ebpf/ebpf_rss.h" +#include "ebpf/rss.bpf.skeleton.h" +#include "trace.h" + +void ebpf_rss_init(struct EBPFRSSContext *ctx) +{ + if (ctx !=3D NULL) { + ctx->obj =3D NULL; + } +} + +bool ebpf_rss_is_loaded(struct EBPFRSSContext *ctx) +{ + return ctx !=3D NULL && ctx->obj !=3D NULL; +} + +bool ebpf_rss_load(struct EBPFRSSContext *ctx) +{ + struct rss_bpf *rss_bpf_ctx; + + if (ctx =3D=3D NULL) { + return false; + } + + rss_bpf_ctx =3D rss_bpf__open(); + if (rss_bpf_ctx =3D=3D NULL) { + trace_ebpf_error("eBPF RSS", "can not open eBPF RSS object"); + goto error; + } + + bpf_program__set_socket_filter(rss_bpf_ctx->progs.tun_rss_steering_pro= g); + + if (rss_bpf__load(rss_bpf_ctx)) { + trace_ebpf_error("eBPF RSS", "can not load RSS program"); + goto error; + } + + ctx->obj =3D rss_bpf_ctx; + ctx->program_fd =3D bpf_program__fd( + rss_bpf_ctx->progs.tun_rss_steering_prog); + ctx->map_configuration =3D bpf_map__fd( + rss_bpf_ctx->maps.tap_rss_map_configurations); + ctx->map_indirections_table =3D bpf_map__fd( + rss_bpf_ctx->maps.tap_rss_map_indirection_table); + ctx->map_toeplitz_key =3D bpf_map__fd( + rss_bpf_ctx->maps.tap_rss_map_toeplitz_key); + + return true; +error: + rss_bpf__destroy(rss_bpf_ctx); + ctx->obj =3D NULL; + + return false; +} + +static bool ebpf_rss_set_config(struct EBPFRSSContext *ctx, + struct EBPFRSSConfig *config) +{ + uint32_t map_key =3D 0; + + if (!ebpf_rss_is_loaded(ctx)) { + return false; + } + if (bpf_map_update_elem(ctx->map_configuration, + &map_key, config, 0) < 0) { + return false; + } + return true; +} + +static bool ebpf_rss_set_indirections_table(struct EBPFRSSContext *ctx, + uint16_t *indirections_table, + size_t len) +{ + uint32_t i =3D 0; + + if (!ebpf_rss_is_loaded(ctx) || indirections_table =3D=3D NULL || + len > VIRTIO_NET_RSS_MAX_TABLE_LEN) { + return false; + } + + for (; i < len; ++i) { + if (bpf_map_update_elem(ctx->map_indirections_table, &i, + indirections_table + i, 0) < 0) { + return false; + } + } + return true; +} + +static bool ebpf_rss_set_toepliz_key(struct EBPFRSSContext *ctx, + uint8_t *toeplitz_key) +{ + uint32_t map_key =3D 0; + + /* prepare toeplitz key */ + uint8_t toe[VIRTIO_NET_RSS_MAX_KEY_SIZE] =3D {}; + + if (!ebpf_rss_is_loaded(ctx) || toeplitz_key =3D=3D NULL) { + return false; + } + memcpy(toe, toeplitz_key, VIRTIO_NET_RSS_MAX_KEY_SIZE); + *(uint32_t *)toe =3D ntohl(*(uint32_t *)toe); + + if (bpf_map_update_elem(ctx->map_toeplitz_key, &map_key, toe, + 0) < 0) { + return false; + } + return true; +} + +bool ebpf_rss_set_all(struct EBPFRSSContext *ctx, struct EBPFRSSConfig *co= nfig, + uint16_t *indirections_table, uint8_t *toeplitz_key) +{ + if (!ebpf_rss_is_loaded(ctx) || config =3D=3D NULL || + indirections_table =3D=3D NULL || toeplitz_key =3D=3D NULL) { + return false; + } + + if (!ebpf_rss_set_config(ctx, config)) { + return false; + } + + if (!ebpf_rss_set_indirections_table(ctx, indirections_table, + config->indirections_len)) { + return false; + } + + if (!ebpf_rss_set_toepliz_key(ctx, toeplitz_key)) { + return false; + } + + return true; +} + +void ebpf_rss_unload(struct EBPFRSSContext *ctx) +{ + if (!ebpf_rss_is_loaded(ctx)) { + return; + } + + rss_bpf__destroy(ctx->obj); + ctx->obj =3D NULL; +} diff --git a/ebpf/ebpf_rss.h b/ebpf/ebpf_rss.h new file mode 100644 index 0000000000..0fcb4e010f --- /dev/null +++ b/ebpf/ebpf_rss.h @@ -0,0 +1,44 @@ +/* + * eBPF RSS header + * + * Developed by Daynix Computing LTD (http://www.daynix.com) + * + * Authors: + * Andrew Melnychenko + * Yuri Benditovich + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + */ + +#ifndef QEMU_EBPF_RSS_H +#define QEMU_EBPF_RSS_H + +struct EBPFRSSContext { + void *obj; + int program_fd; + int map_configuration; + int map_toeplitz_key; + int map_indirections_table; +}; + +struct EBPFRSSConfig { + uint8_t redirect; + uint8_t populate_hash; + uint32_t hash_types; + uint16_t indirections_len; + uint16_t default_queue; +}; + +void ebpf_rss_init(struct EBPFRSSContext *ctx); + +bool ebpf_rss_is_loaded(struct EBPFRSSContext *ctx); + +bool ebpf_rss_load(struct EBPFRSSContext *ctx); + +bool ebpf_rss_set_all(struct EBPFRSSContext *ctx, struct EBPFRSSConfig *co= nfig, + uint16_t *indirections_table, uint8_t *toeplitz_key); + +void ebpf_rss_unload(struct EBPFRSSContext *ctx); + +#endif /* QEMU_EBPF_RSS_H */ diff --git a/ebpf/meson.build b/ebpf/meson.build new file mode 100644 index 0000000000..f5bd5a0f01 --- /dev/null +++ b/ebpf/meson.build @@ -0,0 +1 @@ +common_ss.add(when: 'CONFIG_EBPF', if_true: files('ebpf_rss.c'), if_false:= files('ebpf_rss-stub.c')) diff --git a/ebpf/rss.bpf.skeleton.h b/ebpf/rss.bpf.skeleton.h new file mode 100644 index 0000000000..76616a5ca6 --- /dev/null +++ b/ebpf/rss.bpf.skeleton.h @@ -0,0 +1,397 @@ +/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ + +/* THIS FILE IS AUTOGENERATED! */ +#ifndef __RSS_BPF_SKEL_H__ +#define __RSS_BPF_SKEL_H__ + +#include +#include + +struct rss_bpf { + struct bpf_object_skeleton *skeleton; + struct bpf_object *obj; + struct { + struct bpf_map *tap_rss_map_configurations; + struct bpf_map *tap_rss_map_indirection_table; + struct bpf_map *tap_rss_map_toeplitz_key; + } maps; + struct { + struct bpf_program *tun_rss_steering_prog; + } progs; + struct { + struct bpf_link *tun_rss_steering_prog; + } links; +}; + +static void +rss_bpf__destroy(struct rss_bpf *obj) +{ + if (!obj) + return; + if (obj->skeleton) + bpf_object__destroy_skeleton(obj->skeleton); + free(obj); +} + +static inline int +rss_bpf__create_skeleton(struct rss_bpf *obj); + +static inline struct rss_bpf * +rss_bpf__open_opts(const struct bpf_object_open_opts *opts) +{ + struct rss_bpf *obj; + + obj =3D (struct rss_bpf *)calloc(1, sizeof(*obj)); + if (!obj) + return NULL; + if (rss_bpf__create_skeleton(obj)) + goto err; + if (bpf_object__open_skeleton(obj->skeleton, opts)) + goto err; + + return obj; +err: + rss_bpf__destroy(obj); + return NULL; +} + +static inline struct rss_bpf * +rss_bpf__open(void) +{ + return rss_bpf__open_opts(NULL); +} + +static inline int +rss_bpf__load(struct rss_bpf *obj) +{ + return bpf_object__load_skeleton(obj->skeleton); +} + +static inline struct rss_bpf * +rss_bpf__open_and_load(void) +{ + struct rss_bpf *obj; + + obj =3D rss_bpf__open(); + if (!obj) + return NULL; + if (rss_bpf__load(obj)) { + rss_bpf__destroy(obj); + return NULL; + } + return obj; +} + +static inline int +rss_bpf__attach(struct rss_bpf *obj) +{ + return bpf_object__attach_skeleton(obj->skeleton); +} + +static inline void +rss_bpf__detach(struct rss_bpf *obj) +{ + return bpf_object__detach_skeleton(obj->skeleton); +} + +static inline int +rss_bpf__create_skeleton(struct rss_bpf *obj) +{ + struct bpf_object_skeleton *s; + + s =3D (struct bpf_object_skeleton *)calloc(1, sizeof(*s)); + if (!s) + return -1; + obj->skeleton =3D s; + + s->sz =3D sizeof(*s); + s->name =3D "rss_bpf"; + s->obj =3D &obj->obj; + + /* maps */ + s->map_cnt =3D 3; + s->map_skel_sz =3D sizeof(*s->maps); + s->maps =3D (struct bpf_map_skeleton *)calloc(s->map_cnt, s->map_skel_sz); + if (!s->maps) + goto err; + + s->maps[0].name =3D "tap_rss_map_configurations"; + s->maps[0].map =3D &obj->maps.tap_rss_map_configurations; + + s->maps[1].name =3D "tap_rss_map_indirection_table"; + s->maps[1].map =3D &obj->maps.tap_rss_map_indirection_table; + + s->maps[2].name =3D "tap_rss_map_toeplitz_key"; + s->maps[2].map =3D &obj->maps.tap_rss_map_toeplitz_key; + + /* programs */ + s->prog_cnt =3D 1; + s->prog_skel_sz =3D sizeof(*s->progs); + s->progs =3D (struct bpf_prog_skeleton *)calloc(s->prog_cnt, s->prog_skel= _sz); + if (!s->progs) + goto err; + + s->progs[0].name =3D "tun_rss_steering_prog"; + s->progs[0].prog =3D &obj->progs.tun_rss_steering_prog; + s->progs[0].link =3D &obj->links.tun_rss_steering_prog; + + s->data_sz =3D 7088; + s->data =3D (void *)"\ +\x7f\x45\x4c\x46\x02\x01\x01\0\0\0\0\0\0\0\0\0\x01\0\xf7\0\x01\0\0\0\0\0\0= \0\0\ +\0\0\0\0\0\0\0\0\0\0\0\x30\x19\0\0\0\0\0\0\0\0\0\0\x40\0\0\0\0\0\x40\0\x0a= \0\ +\x01\0\x7b\x1a\x38\xff\0\0\0\0\xb7\x01\0\0\0\0\0\0\x63\x1a\x4c\xff\0\0\0\0= \xbf\ +\xa6\0\0\0\0\0\0\x07\x06\0\0\x4c\xff\xff\xff\x18\x01\0\0\0\0\0\0\0\0\0\0\0= \0\0\ +\0\xbf\x62\0\0\0\0\0\0\x85\0\0\0\x01\0\0\0\xbf\x07\0\0\0\0\0\0\x18\x01\0\0= \0\0\ +\0\0\0\0\0\0\0\0\0\0\xbf\x62\0\0\0\0\0\0\x85\0\0\0\x01\0\0\0\xbf\x08\0\0\0= \0\0\ +\0\x18\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0\x15\x07\x0f\x02\0\0\0\0\xbf\x= 89\0\ +\0\0\0\0\0\x15\x09\x0d\x02\0\0\0\0\x71\x71\0\0\0\0\0\0\x55\x01\x01\0\0\0\0= \0\ +\x05\0\x09\x02\0\0\0\0\xb7\x01\0\0\0\0\0\0\x63\x1a\xc0\xff\0\0\0\0\x7b\x1a= \xb8\ +\xff\0\0\0\0\x7b\x1a\xb0\xff\0\0\0\0\x7b\x1a\xa8\xff\0\0\0\0\x7b\x1a\xa0\x= ff\0\ +\0\0\0\x63\x1a\x98\xff\0\0\0\0\x7b\x1a\x90\xff\0\0\0\0\x7b\x1a\x88\xff\0\0= \0\0\ +\x7b\x1a\x80\xff\0\0\0\0\x7b\x1a\x78\xff\0\0\0\0\x7b\x1a\x70\xff\0\0\0\0\x= 7b\ +\x1a\x68\xff\0\0\0\0\x7b\x1a\x60\xff\0\0\0\0\x7b\x1a\x58\xff\0\0\0\0\x7b\x= 1a\ +\x50\xff\0\0\0\0\x79\xa6\x38\xff\0\0\0\0\x15\x06\x85\0\0\0\0\0\x6b\x1a\xd0= \xff\ +\0\0\0\0\xbf\xa3\0\0\0\0\0\0\x07\x03\0\0\xd0\xff\xff\xff\xbf\x61\0\0\0\0\0= \0\ +\xb7\x02\0\0\x0c\0\0\0\xb7\x04\0\0\x02\0\0\0\xb7\x05\0\0\0\0\0\0\x85\0\0\0= \x44\ +\0\0\0\xb7\x02\0\0\x10\0\0\0\x69\xa1\xd0\xff\0\0\0\0\xbf\x13\0\0\0\0\0\0\x= dc\ +\x03\0\0\x10\0\0\0\x15\x03\x02\0\0\x81\0\0\x55\x03\x08\0\xa8\x88\0\0\xb7\x= 02\0\ +\0\x14\0\0\0\xbf\xa3\0\0\0\0\0\0\x07\x03\0\0\xd0\xff\xff\xff\xbf\x61\0\0\0= \0\0\ +\0\xb7\x04\0\0\x02\0\0\0\xb7\x05\0\0\0\0\0\0\x85\0\0\0\x44\0\0\0\x69\xa1\x= d0\ +\xff\0\0\0\0\xdc\x01\0\0\x10\0\0\0\x15\x01\x26\0\xdd\x86\0\0\x55\x01\x6c\0= \0\ +\x08\0\0\xb7\x01\0\0\x01\0\0\0\x73\x1a\x50\xff\0\0\0\0\xb7\x01\0\0\0\0\0\0= \x63\ +\x1a\xe0\xff\0\0\0\0\x7b\x1a\xd8\xff\0\0\0\0\x7b\x1a\xd0\xff\0\0\0\0\xbf\x= a3\0\ +\0\0\0\0\0\x07\x03\0\0\xd0\xff\xff\xff\xbf\x61\0\0\0\0\0\0\xb7\x02\0\0\0\0= \0\0\ +\xb7\x04\0\0\x14\0\0\0\xb7\x05\0\0\x01\0\0\0\x85\0\0\0\x44\0\0\0\x61\xa1\x= dc\ +\xff\0\0\0\0\x63\x1a\x5c\xff\0\0\0\0\x61\xa1\xe0\xff\0\0\0\0\x63\x1a\x60\x= ff\0\ +\0\0\0\x71\xa6\xd9\xff\0\0\0\0\x71\xa1\xd0\xff\0\0\0\0\x67\x01\0\0\x02\0\0= \0\ +\x57\x01\0\0\x3c\0\0\0\x7b\x1a\x40\xff\0\0\0\0\x57\x06\0\0\xff\0\0\0\x15\x= 06\ +\x45\0\x11\0\0\0\x79\xa1\x38\xff\0\0\0\0\x55\x06\x52\0\x06\0\0\0\xb7\x02\0= \0\ +\x01\0\0\0\x73\x2a\x53\xff\0\0\0\0\xb7\x02\0\0\0\0\0\0\x63\x2a\xe0\xff\0\0= \0\0\ +\x7b\x2a\xd8\xff\0\0\0\0\x7b\x2a\xd0\xff\0\0\0\0\xbf\xa3\0\0\0\0\0\0\x07\x= 03\0\ +\0\xd0\xff\xff\xff\x79\xa2\x40\xff\0\0\0\0\xb7\x04\0\0\x14\0\0\0\x05\0\x41= \0\0\ +\0\0\0\x7b\x7a\x10\xff\0\0\0\0\xb7\x07\0\0\x01\0\0\0\x73\x7a\x51\xff\0\0\0= \0\ +\xb7\x01\0\0\0\0\0\0\x7b\x1a\xf0\xff\0\0\0\0\x7b\x1a\xe8\xff\0\0\0\0\x7b\x= 1a\ +\xe0\xff\0\0\0\0\x7b\x1a\xd8\xff\0\0\0\0\x7b\x1a\xd0\xff\0\0\0\0\xbf\xa3\0= \0\0\ +\0\0\0\x07\x03\0\0\xd0\xff\xff\xff\xb7\x01\0\0\x28\0\0\0\x7b\x1a\x40\xff\0= \0\0\ +\0\xbf\x61\0\0\0\0\0\0\xb7\x02\0\0\0\0\0\0\xb7\x04\0\0\x28\0\0\0\xb7\x05\0= \0\ +\x01\0\0\0\x85\0\0\0\x44\0\0\0\x79\xa1\xd8\xff\0\0\0\0\x63\x1a\x5c\xff\0\0= \0\0\ +\x77\x01\0\0\x20\0\0\0\x63\x1a\x60\xff\0\0\0\0\x79\xa1\xe0\xff\0\0\0\0\x63= \x1a\ +\x64\xff\0\0\0\0\x77\x01\0\0\x20\0\0\0\x63\x1a\x68\xff\0\0\0\0\x79\xa1\xe8= \xff\ +\0\0\0\0\x63\x1a\x6c\xff\0\0\0\0\x77\x01\0\0\x20\0\0\0\x63\x1a\x70\xff\0\0= \0\0\ +\x79\xa1\xf0\xff\0\0\0\0\x63\x1a\x74\xff\0\0\0\0\x77\x01\0\0\x20\0\0\0\x63= \x1a\ +\x78\xff\0\0\0\0\x71\xa6\xd6\xff\0\0\0\0\x25\x06\xb1\0\x3c\0\0\0\x6f\x67\0= \0\0\ +\0\0\0\x18\x01\0\0\x01\0\0\0\0\0\0\0\0\x18\0\x1c\x5f\x17\0\0\0\0\0\0\x55\x= 07\ +\x01\0\0\0\0\0\x05\0\xab\0\0\0\0\0\xb7\x01\0\0\0\0\0\0\x6b\x1a\xfe\xff\0\0= \0\0\ +\xb7\x01\0\0\x28\0\0\0\x7b\x1a\x40\xff\0\0\0\0\xbf\xa1\0\0\0\0\0\0\x07\x01= \0\0\ +\x8c\xff\xff\xff\x7b\x1a\x20\xff\0\0\0\0\xbf\xa1\0\0\0\0\0\0\x07\x01\0\0\x= 54\ +\xff\xff\xff\x7b\x1a\x18\xff\0\0\0\0\xb7\x07\0\0\0\0\0\0\x7b\x8a\x30\xff\0= \0\0\ +\0\x7b\x9a\x28\xff\0\0\0\0\x05\0\xdf\0\0\0\0\0\xb7\x01\0\0\x01\0\0\0\x73\x= 1a\ +\x52\xff\0\0\0\0\xb7\x01\0\0\0\0\0\0\x7b\x1a\xd0\xff\0\0\0\0\xbf\xa3\0\0\0= \0\0\ +\0\x07\x03\0\0\xd0\xff\xff\xff\x79\xa1\x38\xff\0\0\0\0\x79\xa2\x40\xff\0\0= \0\0\ +\xb7\x04\0\0\x08\0\0\0\xb7\x05\0\0\x01\0\0\0\x85\0\0\0\x44\0\0\0\x69\xa1\x= d0\ +\xff\0\0\0\0\x6b\x1a\x56\xff\0\0\0\0\x69\xa1\xd2\xff\0\0\0\0\x6b\x1a\x58\x= ff\0\ +\0\0\0\x71\xa1\x50\xff\0\0\0\0\x15\x01\x0f\0\0\0\0\0\x61\x71\x04\0\0\0\0\0= \x71\ +\xa2\x53\xff\0\0\0\0\x15\x02\x41\0\0\0\0\0\xbf\x12\0\0\0\0\0\0\x57\x02\0\0= \x02\ +\0\0\0\x15\x02\x3e\0\0\0\0\0\x61\xa1\x5c\xff\0\0\0\0\x63\x1a\xa0\xff\0\0\0= \0\ +\x61\xa1\x60\xff\0\0\0\0\x63\x1a\xa4\xff\0\0\0\0\x69\xa1\x56\xff\0\0\0\0\x= 6b\ +\x1a\xa8\xff\0\0\0\0\x69\xa1\x58\xff\0\0\0\0\x6b\x1a\xaa\xff\0\0\0\0\x05\0= \xf4\ +\0\0\0\0\0\x71\xa1\x51\xff\0\0\0\0\x15\x01\x5f\x01\0\0\0\0\x61\x71\x04\0\0= \0\0\ +\0\x71\xa2\x53\xff\0\0\0\0\x15\x02\x3d\0\0\0\0\0\xbf\x12\0\0\0\0\0\0\x57\x= 02\0\ +\0\x10\0\0\0\x15\x02\x3a\0\0\0\0\0\xbf\xa2\0\0\0\0\0\0\x07\x02\0\0\x5c\xff= \xff\ +\xff\x71\xa4\x54\xff\0\0\0\0\xbf\x23\0\0\0\0\0\0\x15\x04\x02\0\0\0\0\0\xbf= \xa3\ +\0\0\0\0\0\0\x07\x03\0\0\x7c\xff\xff\xff\x67\x01\0\0\x38\0\0\0\xc7\x01\0\0= \x38\ +\0\0\0\x65\x01\x01\0\xff\xff\xff\xff\xbf\x32\0\0\0\0\0\0\xbf\xa3\0\0\0\0\0= \0\ +\x07\x03\0\0\x6c\xff\xff\xff\x71\xa5\x55\xff\0\0\0\0\xbf\x34\0\0\0\0\0\0\x= 15\ +\x05\x02\0\0\0\0\0\xbf\xa4\0\0\0\0\0\0\x07\x04\0\0\x8c\xff\xff\xff\x65\x01= \x01\ +\0\xff\xff\xff\xff\xbf\x43\0\0\0\0\0\0\x61\x21\x04\0\0\0\0\0\x67\x01\0\0\x= 20\0\ +\0\0\x61\x24\0\0\0\0\0\0\x4f\x41\0\0\0\0\0\0\x7b\x1a\xa0\xff\0\0\0\0\x61\x= 21\ +\x08\0\0\0\0\0\x61\x22\x0c\0\0\0\0\0\x67\x02\0\0\x20\0\0\0\x4f\x12\0\0\0\0= \0\0\ +\x7b\x2a\xa8\xff\0\0\0\0\x61\x31\0\0\0\0\0\0\x61\x32\x04\0\0\0\0\0\x61\x34= \x08\ +\0\0\0\0\0\x61\x33\x0c\0\0\0\0\0\x69\xa5\x58\xff\0\0\0\0\x6b\x5a\xc2\xff\0= \0\0\ +\0\x69\xa5\x56\xff\0\0\0\0\x6b\x5a\xc0\xff\0\0\0\0\x67\x03\0\0\x20\0\0\0\x= 4f\ +\x43\0\0\0\0\0\0\x7b\x3a\xb8\xff\0\0\0\0\x67\x02\0\0\x20\0\0\0\x4f\x12\0\0= \0\0\ +\0\0\x7b\x2a\xb0\xff\0\0\0\0\x05\0\xbf\0\0\0\0\0\x71\xa2\x52\xff\0\0\0\0\x= 15\ +\x02\x04\0\0\0\0\0\xbf\x12\0\0\0\0\0\0\x57\x02\0\0\x04\0\0\0\x15\x02\x01\0= \0\0\ +\0\0\x05\0\xbc\xff\0\0\0\0\x57\x01\0\0\x01\0\0\0\x15\x01\x24\x01\0\0\0\0\x= 61\ +\xa1\x5c\xff\0\0\0\0\x63\x1a\xa0\xff\0\0\0\0\x61\xa1\x60\xff\0\0\0\0\x63\x= 1a\ +\xa4\xff\0\0\0\0\x05\0\xb2\0\0\0\0\0\x71\xa2\x52\xff\0\0\0\0\x15\x02\x16\0= \0\0\ +\0\0\xbf\x12\0\0\0\0\0\0\x57\x02\0\0\x20\0\0\0\x15\x02\x13\0\0\0\0\0\xbf\x= a2\0\ +\0\0\0\0\0\x07\x02\0\0\x5c\xff\xff\xff\x71\xa4\x54\xff\0\0\0\0\xbf\x23\0\0= \0\0\ +\0\0\x15\x04\x02\0\0\0\0\0\xbf\xa3\0\0\0\0\0\0\x07\x03\0\0\x7c\xff\xff\xff= \x57\ +\x01\0\0\0\x01\0\0\x15\x01\x01\0\0\0\0\0\xbf\x32\0\0\0\0\0\0\xbf\xa3\0\0\0= \0\0\ +\0\x07\x03\0\0\x6c\xff\xff\xff\x71\xa5\x55\xff\0\0\0\0\xbf\x34\0\0\0\0\0\0= \x15\ +\x05\x02\0\0\0\0\0\xbf\xa4\0\0\0\0\0\0\x07\x04\0\0\x8c\xff\xff\xff\x15\x01= \xc3\ +\xff\0\0\0\0\x05\0\xc1\xff\0\0\0\0\xbf\x12\0\0\0\0\0\0\x57\x02\0\0\x08\0\0= \0\ +\x15\x02\x04\x01\0\0\0\0\xbf\xa2\0\0\0\0\0\0\x07\x02\0\0\x5c\xff\xff\xff\x= 71\ +\xa4\x54\xff\0\0\0\0\xbf\x23\0\0\0\0\0\0\x15\x04\x02\0\0\0\0\0\xbf\xa3\0\0= \0\0\ +\0\0\x07\x03\0\0\x7c\xff\xff\xff\x57\x01\0\0\x40\0\0\0\x15\x01\x01\0\0\0\0= \0\ +\xbf\x32\0\0\0\0\0\0\x61\x23\x04\0\0\0\0\0\x67\x03\0\0\x20\0\0\0\x61\x24\0= \0\0\ +\0\0\0\x4f\x43\0\0\0\0\0\0\x7b\x3a\xa0\xff\0\0\0\0\x61\x23\x08\0\0\0\0\0\x= 61\ +\x22\x0c\0\0\0\0\0\x67\x02\0\0\x20\0\0\0\x4f\x32\0\0\0\0\0\0\x7b\x2a\xa8\x= ff\0\ +\0\0\0\x15\x01\x78\0\0\0\0\0\x71\xa1\x55\xff\0\0\0\0\x15\x01\x76\0\0\0\0\0= \x61\ +\xa1\x98\xff\0\0\0\0\x67\x01\0\0\x20\0\0\0\x61\xa2\x94\xff\0\0\0\0\x4f\x21= \0\0\ +\0\0\0\0\x7b\x1a\xb8\xff\0\0\0\0\x61\xa1\x90\xff\0\0\0\0\x67\x01\0\0\x20\0= \0\0\ +\x61\xa2\x8c\xff\0\0\0\0\x05\0\x75\0\0\0\0\0\x15\x06\x54\xff\x87\0\0\0\x05= \0\ +\x3e\0\0\0\0\0\x0f\x96\0\0\0\0\0\0\xbf\x62\0\0\0\0\0\0\x07\x02\0\0\x01\0\0= \0\ +\x71\xa3\xff\xff\0\0\0\0\x67\x03\0\0\x03\0\0\0\x3d\x32\x22\0\0\0\0\0\x55\x= 01\ +\x0c\0\xc9\0\0\0\x79\xa1\x40\xff\0\0\0\0\x0f\x16\0\0\0\0\0\0\x07\x06\0\0\x= 02\0\ +\0\0\x79\xa1\x38\xff\0\0\0\0\xbf\x62\0\0\0\0\0\0\x79\xa3\x18\xff\0\0\0\0\x= b7\ +\x04\0\0\x01\0\0\0\xb7\x05\0\0\x01\0\0\0\x85\0\0\0\x44\0\0\0\xb7\x01\0\0\x= 01\0\ +\0\0\x73\x1a\x54\xff\0\0\0\0\x05\0\x15\0\0\0\0\0\x07\x08\0\0\xff\xff\xff\x= ff\ +\xbf\x81\0\0\0\0\0\0\x67\x01\0\0\x20\0\0\0\x77\x01\0\0\x20\0\0\0\xbf\x69\0= \0\0\ +\0\0\0\x15\x01\x0f\0\0\0\0\0\xbf\x92\0\0\0\0\0\0\x79\xa1\x40\xff\0\0\0\0\x= 0f\ +\x12\0\0\0\0\0\0\xbf\xa3\0\0\0\0\0\0\x07\x03\0\0\xf8\xff\xff\xff\xb7\x06\0= \0\ +\x01\0\0\0\x79\xa1\x38\xff\0\0\0\0\xb7\x04\0\0\x02\0\0\0\xb7\x05\0\0\x01\0= \0\0\ +\x85\0\0\0\x44\0\0\0\x71\xa1\xf8\xff\0\0\0\0\x15\x01\xdb\xff\0\0\0\0\x71\x= a6\ +\xf9\xff\0\0\0\0\x07\x06\0\0\x02\0\0\0\x05\0\xd8\xff\0\0\0\0\x79\xa8\x30\x= ff\0\ +\0\0\0\x79\xa9\x28\xff\0\0\0\0\x71\xa1\xff\xff\0\0\0\0\x67\x01\0\0\x03\0\0= \0\ +\x79\xa2\x40\xff\0\0\0\0\x0f\x12\0\0\0\0\0\0\x07\x02\0\0\x08\0\0\0\x7b\x2a= \x40\ +\xff\0\0\0\0\x71\xa6\xfe\xff\0\0\0\0\x25\x06\x37\0\x3c\0\0\0\xb7\x01\0\0\x= 01\0\ +\0\0\x6f\x61\0\0\0\0\0\0\x18\x02\0\0\x01\0\0\0\0\0\0\0\0\x18\0\x1c\x5f\x21= \0\0\ +\0\0\0\0\x55\x01\x01\0\0\0\0\0\x05\0\x30\0\0\0\0\0\x07\x07\0\0\x01\0\0\0\x= bf\ +\x71\0\0\0\0\0\0\x67\x01\0\0\x20\0\0\0\x77\x01\0\0\x20\0\0\0\x55\x01\x02\0= \x0b\ +\0\0\0\x79\xa7\x10\xff\0\0\0\0\x05\0\xda\xfe\0\0\0\0\xbf\xa3\0\0\0\0\0\0\x= 07\ +\x03\0\0\xfe\xff\xff\xff\x79\xa1\x38\xff\0\0\0\0\x79\xa2\x40\xff\0\0\0\0\x= b7\ +\x04\0\0\x02\0\0\0\xb7\x05\0\0\x01\0\0\0\x85\0\0\0\x44\0\0\0\xbf\x61\0\0\0= \0\0\ +\0\x15\x01\x1b\0\x3c\0\0\0\x55\x01\xe0\xff\x2b\0\0\0\xb7\x01\0\0\0\0\0\0\x= 63\ +\x1a\xf8\xff\0\0\0\0\xbf\xa3\0\0\0\0\0\0\x07\x03\0\0\xf8\xff\xff\xff\x79\x= a6\ +\x38\xff\0\0\0\0\xbf\x61\0\0\0\0\0\0\x79\xa2\x40\xff\0\0\0\0\xb7\x04\0\0\x= 04\0\ +\0\0\xb7\x05\0\0\x01\0\0\0\x85\0\0\0\x44\0\0\0\x71\xa1\xfa\xff\0\0\0\0\x55= \x01\ +\xd4\xff\x02\0\0\0\x71\xa1\xf9\xff\0\0\0\0\x55\x01\xd2\xff\x02\0\0\0\x71\x= a1\ +\xfb\xff\0\0\0\0\x55\x01\xd0\xff\x01\0\0\0\x79\xa2\x40\xff\0\0\0\0\x07\x02= \0\0\ +\x08\0\0\0\xbf\x61\0\0\0\0\0\0\x79\xa3\x20\xff\0\0\0\0\xb7\x04\0\0\x10\0\0= \0\ +\xb7\x05\0\0\x01\0\0\0\x85\0\0\0\x44\0\0\0\xb7\x01\0\0\x01\0\0\0\x73\x1a\x= 55\ +\xff\0\0\0\0\x05\0\xc6\xff\0\0\0\0\xb7\x01\0\0\0\0\0\0\x6b\x1a\xf8\xff\0\0= \0\0\ +\xb7\x09\0\0\x02\0\0\0\xb7\x08\0\0\x1e\0\0\0\x05\0\xb0\xff\0\0\0\0\x15\x06= \xcf\ +\xff\x87\0\0\0\x05\0\xd3\xff\0\0\0\0\x61\xa1\x78\xff\0\0\0\0\x67\x01\0\0\x= 20\0\ +\0\0\x61\xa2\x74\xff\0\0\0\0\x4f\x21\0\0\0\0\0\0\x7b\x1a\xb8\xff\0\0\0\0\x= 61\ +\xa1\x70\xff\0\0\0\0\x67\x01\0\0\x20\0\0\0\x61\xa2\x6c\xff\0\0\0\0\x4f\x21= \0\0\ +\0\0\0\0\x7b\x1a\xb0\xff\0\0\0\0\xb7\x01\0\0\0\0\0\0\x07\x08\0\0\x04\0\0\0= \x61\ +\x92\0\0\0\0\0\0\xb7\x05\0\0\0\0\0\0\x05\0\x4e\0\0\0\0\0\xaf\x53\0\0\0\0\0= \0\ +\xbf\x85\0\0\0\0\0\0\x0f\x15\0\0\0\0\0\0\x71\x55\0\0\0\0\0\0\x67\x02\0\0\x= 01\0\ +\0\0\xbf\x50\0\0\0\0\0\0\x77\0\0\0\x07\0\0\0\x4f\x02\0\0\0\0\0\0\xbf\x40\0= \0\0\ +\0\0\0\x67\0\0\0\x39\0\0\0\xc7\0\0\0\x3f\0\0\0\x5f\x20\0\0\0\0\0\0\xaf\x03= \0\0\ +\0\0\0\0\xbf\x50\0\0\0\0\0\0\x77\0\0\0\x06\0\0\0\x57\0\0\0\x01\0\0\0\x67\x= 02\0\ +\0\x01\0\0\0\x4f\x02\0\0\0\0\0\0\xbf\x40\0\0\0\0\0\0\x67\0\0\0\x3a\0\0\0\x= c7\0\ +\0\0\x3f\0\0\0\x5f\x20\0\0\0\0\0\0\xaf\x03\0\0\0\0\0\0\x67\x02\0\0\x01\0\0= \0\ +\xbf\x50\0\0\0\0\0\0\x77\0\0\0\x05\0\0\0\x57\0\0\0\x01\0\0\0\x4f\x02\0\0\0= \0\0\ +\0\xbf\x40\0\0\0\0\0\0\x67\0\0\0\x3b\0\0\0\xc7\0\0\0\x3f\0\0\0\x5f\x20\0\0= \0\0\ +\0\0\xaf\x03\0\0\0\0\0\0\x67\x02\0\0\x01\0\0\0\xbf\x50\0\0\0\0\0\0\x77\0\0= \0\ +\x04\0\0\0\x57\0\0\0\x01\0\0\0\x4f\x02\0\0\0\0\0\0\xbf\x40\0\0\0\0\0\0\x67= \0\0\ +\0\x3c\0\0\0\xc7\0\0\0\x3f\0\0\0\x5f\x20\0\0\0\0\0\0\xaf\x03\0\0\0\0\0\0\x= bf\ +\x50\0\0\0\0\0\0\x77\0\0\0\x03\0\0\0\x57\0\0\0\x01\0\0\0\x67\x02\0\0\x01\0= \0\0\ +\x4f\x02\0\0\0\0\0\0\xbf\x40\0\0\0\0\0\0\x67\0\0\0\x3d\0\0\0\xc7\0\0\0\x3f= \0\0\ +\0\x5f\x20\0\0\0\0\0\0\xaf\x03\0\0\0\0\0\0\xbf\x50\0\0\0\0\0\0\x77\0\0\0\x= 02\0\ +\0\0\x57\0\0\0\x01\0\0\0\x67\x02\0\0\x01\0\0\0\x4f\x02\0\0\0\0\0\0\xbf\x40= \0\0\ +\0\0\0\0\x67\0\0\0\x3e\0\0\0\xc7\0\0\0\x3f\0\0\0\x5f\x20\0\0\0\0\0\0\xaf\x= 03\0\ +\0\0\0\0\0\xbf\x50\0\0\0\0\0\0\x77\0\0\0\x01\0\0\0\x57\0\0\0\x01\0\0\0\x67= \x02\ +\0\0\x01\0\0\0\x4f\x02\0\0\0\0\0\0\x57\x04\0\0\x01\0\0\0\x87\x04\0\0\0\0\0= \0\ +\x5f\x24\0\0\0\0\0\0\xaf\x43\0\0\0\0\0\0\x57\x05\0\0\x01\0\0\0\x67\x02\0\0= \x01\ +\0\0\0\x4f\x52\0\0\0\0\0\0\x07\x01\0\0\x01\0\0\0\xbf\x35\0\0\0\0\0\0\x15\x= 01\ +\x0b\0\x24\0\0\0\xbf\xa3\0\0\0\0\0\0\x07\x03\0\0\xa0\xff\xff\xff\x0f\x13\0= \0\0\ +\0\0\0\x71\x34\0\0\0\0\0\0\xbf\x40\0\0\0\0\0\0\x67\0\0\0\x38\0\0\0\xc7\0\0= \0\ +\x38\0\0\0\xb7\x03\0\0\0\0\0\0\x65\0\xa9\xff\xff\xff\xff\xff\xbf\x23\0\0\0= \0\0\ +\0\x05\0\xa7\xff\0\0\0\0\xbf\x31\0\0\0\0\0\0\x67\x01\0\0\x20\0\0\0\x77\x01= \0\0\ +\x20\0\0\0\x15\x01\x0b\0\0\0\0\0\x69\x72\x08\0\0\0\0\0\x3f\x21\0\0\0\0\0\0= \x2f\ +\x21\0\0\0\0\0\0\x1f\x13\0\0\0\0\0\0\x63\x3a\x50\xff\0\0\0\0\xbf\xa2\0\0\0= \0\0\ +\0\x07\x02\0\0\x50\xff\xff\xff\x18\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x85\0\0= \0\ +\x01\0\0\0\x55\0\x02\0\0\0\0\0\x69\x70\x0a\0\0\0\0\0\x95\0\0\0\0\0\0\0\x69= \0\0\ +\0\0\0\0\0\x05\0\xfd\xff\0\0\0\0\x02\0\0\0\x04\0\0\0\x0c\0\0\0\x01\0\0\0\0= \0\0\ +\0\x02\0\0\0\x04\0\0\0\x28\0\0\0\x01\0\0\0\0\0\0\0\x02\0\0\0\x04\0\0\0\x02= \0\0\ +\0\x80\0\0\0\0\0\0\0\x47\x50\x4c\x20\x76\x32\0\0\0\0\0\0\x10\0\0\0\0\0\0\0= \x01\ +\x7a\x52\0\x08\x7c\x0b\x01\x0c\0\0\0\x18\0\0\0\x18\0\0\0\0\0\0\0\0\0\0\0\x= 20\ +\x11\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x= a0\0\ +\0\0\x04\0\xf1\xff\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xd7\x01\0\0\0\0\x03\0\x= 38\ +\x03\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xbf\x01\0\0\0\0\x03\0\xe0\x09\0\0\0\0\0\0= \0\0\ +\0\0\0\0\0\0\x68\x01\0\0\0\0\x03\0\x88\x04\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x48= \x01\ +\0\0\0\0\x03\0\xf0\x0b\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xcf\x01\0\0\0\0\x03\0\x= 10\ +\x0d\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xb7\x01\0\0\0\0\x03\0\x88\x0a\0\0\0\0\0\0= \0\0\ +\0\0\0\0\0\0\x9f\x01\0\0\0\0\x03\0\xb8\x0a\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x40= \x01\ +\0\0\0\0\x03\0\xf0\x09\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xf1\0\0\0\0\0\x03\0\x30= \x0b\ +\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x17\x02\0\0\0\0\x03\0\x40\x0b\0\0\0\0\0\0\0\0= \0\0\ +\0\0\0\0\xf7\x01\0\0\0\0\x03\0\x38\x0d\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xaf\x01= \0\0\ +\0\0\x03\0\xb8\x0b\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x97\x01\0\0\0\0\x03\0\xe0\x= 0b\0\ +\0\0\0\0\0\0\0\0\0\0\0\0\0\x60\x01\0\0\0\0\x03\0\xc0\x02\0\0\0\0\0\0\0\0\0= \0\0\ +\0\0\0\x10\x01\0\0\0\0\x03\0\xf8\x04\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xe9\0\0\0= \0\0\ +\x03\0\x40\x05\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x70\x01\0\0\0\0\x03\0\xb8\0\0\0= \0\0\ +\0\0\0\0\0\0\0\0\0\0\x0f\x02\0\0\0\0\x03\0\x70\x05\0\0\0\0\0\0\0\0\0\0\0\0= \0\0\ +\xa7\x01\0\0\0\0\x03\0\xb0\x05\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x8f\x01\0\0\0\0= \x03\ +\0\xa0\x07\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x28\x01\0\0\0\0\x03\0\xd0\x07\0\0\0= \0\0\ +\0\0\0\0\0\0\0\0\0\xe1\0\0\0\0\0\x03\0\xf8\x05\0\0\0\0\0\0\0\0\0\0\0\0\0\0= \x87\ +\x01\0\0\0\0\x03\0\x70\x06\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x38\x01\0\0\0\0\x03= \0\ +\x90\x06\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x08\x01\0\0\0\0\x03\0\xc8\x06\0\0\0\0= \0\0\ +\0\0\0\0\0\0\0\0\xd9\0\0\0\0\0\x03\0\xd0\x06\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x= 07\ +\x02\0\0\0\0\x03\0\xd8\x06\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xef\x01\0\0\0\0\x03= \0\ +\x08\x08\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x58\x01\0\0\0\0\x03\0\x68\x08\0\0\0\0= \0\0\ +\0\0\0\0\0\0\0\0\x20\x01\0\0\0\0\x03\0\x80\x08\0\0\0\0\0\0\0\0\0\0\0\0\0\0= \xd1\ +\0\0\0\0\0\x03\0\xb8\x08\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xe7\x01\0\0\0\0\x03\0= \xc8\ +\x08\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x7f\x01\0\0\0\0\x03\0\x18\x09\0\0\0\0\0\0= \0\0\ +\0\0\0\0\0\0\x30\x01\0\0\0\0\x03\0\x30\x09\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xc9= \0\0\ +\0\0\0\x03\0\x48\x0d\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xf9\0\0\0\0\0\x03\0\xc0\x= 01\0\ +\0\0\0\0\0\0\0\0\0\0\0\0\0\xff\x01\0\0\0\0\x03\0\x88\x0d\0\0\0\0\0\0\0\0\0= \0\0\ +\0\0\0\xdf\x01\0\0\0\0\x03\0\x98\x0d\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xc7\x01\0= \0\0\ +\0\x03\0\x30\x10\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x77\x01\0\0\0\0\x03\0\xc0\x0d= \0\0\ +\0\0\0\0\0\0\0\0\0\0\0\0\x50\x01\0\0\0\0\x03\0\x88\x10\0\0\0\0\0\0\0\0\0\0= \0\0\ +\0\0\x18\x01\0\0\0\0\x03\0\0\x11\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x01\0\0\0\0= \x03\ +\0\x08\x11\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xc1\0\0\0\0\0\x03\0\x10\x11\0\0\0\0= \0\0\ +\0\0\0\0\0\0\0\0\xba\0\0\0\0\0\x03\0\xf8\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0= \0\0\ +\0\x03\0\x03\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x6b\0\0\0\x11\0\x06\0\0\0\0= \0\0\ +\0\0\0\x07\0\0\0\0\0\0\0\x25\0\0\0\x11\0\x05\0\0\0\0\0\0\0\0\0\x14\0\0\0\0= \0\0\ +\0\x82\0\0\0\x11\0\x05\0\x28\0\0\0\0\0\0\0\x14\0\0\0\0\0\0\0\x01\0\0\0\x11= \0\ +\x05\0\x14\0\0\0\0\0\0\0\x14\0\0\0\0\0\0\0\x40\0\0\0\x12\0\x03\0\0\0\0\0\0= \0\0\ +\0\x20\x11\0\0\0\0\0\0\x28\0\0\0\0\0\0\0\x01\0\0\0\x31\0\0\0\x50\0\0\0\0\0= \0\0\ +\x01\0\0\0\x33\0\0\0\xe0\x10\0\0\0\0\0\0\x01\0\0\0\x32\0\0\0\x1c\0\0\0\0\0= \0\0\ +\x01\0\0\0\x2f\0\0\0\0\x74\x61\x70\x5f\x72\x73\x73\x5f\x6d\x61\x70\x5f\x74= \x6f\ +\x65\x70\x6c\x69\x74\x7a\x5f\x6b\x65\x79\0\x2e\x74\x65\x78\x74\0\x6d\x61\x= 70\ +\x73\0\x74\x61\x70\x5f\x72\x73\x73\x5f\x6d\x61\x70\x5f\x63\x6f\x6e\x66\x69= \x67\ +\x75\x72\x61\x74\x69\x6f\x6e\x73\0\x74\x75\x6e\x5f\x72\x73\x73\x5f\x73\x74= \x65\ +\x65\x72\x69\x6e\x67\x5f\x70\x72\x6f\x67\0\x2e\x72\x65\x6c\x74\x75\x6e\x5f= \x72\ +\x73\x73\x5f\x73\x74\x65\x65\x72\x69\x6e\x67\0\x5f\x6c\x69\x63\x65\x6e\x73= \x65\ +\0\x2e\x72\x65\x6c\x2e\x65\x68\x5f\x66\x72\x61\x6d\x65\0\x74\x61\x70\x5f\x= 72\ +\x73\x73\x5f\x6d\x61\x70\x5f\x69\x6e\x64\x69\x72\x65\x63\x74\x69\x6f\x6e\x= 5f\ +\x74\x61\x62\x6c\x65\0\x72\x73\x73\x2e\x62\x70\x66\x2e\x63\0\x2e\x73\x74\x= 72\ +\x74\x61\x62\0\x2e\x73\x79\x6d\x74\x61\x62\0\x4c\x42\x42\x30\x5f\x39\0\x4c= \x42\ +\x42\x30\x5f\x38\x39\0\x4c\x42\x42\x30\x5f\x37\x39\0\x4c\x42\x42\x30\x5f\x= 36\ +\x39\0\x4c\x42\x42\x30\x5f\x35\x39\0\x4c\x42\x42\x30\x5f\x34\x39\0\x4c\x42= \x42\ +\x30\x5f\x33\x39\0\x4c\x42\x42\x30\x5f\x32\x39\0\x4c\x42\x42\x30\x5f\x38\0= \x4c\ +\x42\x42\x30\x5f\x38\x38\0\x4c\x42\x42\x30\x5f\x35\x38\0\x4c\x42\x42\x30\x= 5f\ +\x33\x38\0\x4c\x42\x42\x30\x5f\x38\x37\0\x4c\x42\x42\x30\x5f\x36\x37\0\x4c= \x42\ +\x42\x30\x5f\x34\x37\0\x4c\x42\x42\x30\x5f\x37\x36\0\x4c\x42\x42\x30\x5f\x= 35\ +\x36\0\x4c\x42\x42\x30\x5f\x32\x36\0\x4c\x42\x42\x30\x5f\x31\x36\0\x4c\x42= \x42\ +\x30\x5f\x38\x35\0\x4c\x42\x42\x30\x5f\x36\x35\0\x4c\x42\x42\x30\x5f\x33\x= 35\0\ +\x4c\x42\x42\x30\x5f\x31\x35\0\x4c\x42\x42\x30\x5f\x34\0\x4c\x42\x42\x30\x= 5f\ +\x38\x34\0\x4c\x42\x42\x30\x5f\x37\x34\0\x4c\x42\x42\x30\x5f\x35\x34\0\x4c= \x42\ +\x42\x30\x5f\x34\x34\0\x4c\x42\x42\x30\x5f\x33\x34\0\x4c\x42\x42\x30\x5f\x= 32\ +\x34\0\x4c\x42\x42\x30\x5f\x34\x33\0\x4c\x42\x42\x30\x5f\x33\x33\0\x4c\x42= \x42\ +\x30\x5f\x32\x33\0\x4c\x42\x42\x30\x5f\x31\x33\0\x4c\x42\x42\x30\x5f\x38\x= 32\0\ +\x4c\x42\x42\x30\x5f\x32\x32\0\x4c\x42\x42\x30\x5f\x31\x32\0\x4c\x42\x42\x= 30\ +\x5f\x38\x31\0\x4c\x42\x42\x30\x5f\x37\x31\0\x4c\x42\x42\x30\x5f\x36\x31\0= \x4c\ +\x42\x42\x30\x5f\x33\x31\0\x4c\x42\x42\x30\x5f\x38\x30\0\x4c\x42\x42\x30\x= 5f\ +\x36\x30\0\x4c\x42\x42\x30\x5f\x34\x30\0\x4c\x42\x42\x30\x5f\x33\x30\0\0\0= \0\0\ +\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0= \0\0\ +\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xaa\0\0\0\x03\0\0\0\0\0\0\0\0= \0\0\ +\0\0\0\0\0\0\0\0\0\x10\x17\0\0\0\0\0\0\x1f\x02\0\0\0\0\0\0\0\0\0\0\0\0\0\0= \x01\ +\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x1a\0\0\0\x01\0\0\0\x06\0\0\0\0\0\0\0\0\0\0= \0\0\ +\0\0\0\x40\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x04\0\0\0\0\0\0\0= \0\0\ +\0\0\0\0\0\0\x5a\0\0\0\x01\0\0\0\x06\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x40\0\0= \0\0\ +\0\0\0\x20\x11\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x08\0\0\0\0\0\0\0\0\0\0\0\0\0\0= \0\ +\x56\0\0\0\x09\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xd0\x16\0\0\0\0\0\0\x= 30\0\ +\0\0\0\0\0\0\x09\0\0\0\x03\0\0\0\x08\0\0\0\0\0\0\0\x10\0\0\0\0\0\0\0\x20\0= \0\0\ +\x01\0\0\0\x03\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x60\x11\0\0\0\0\0\0\x3c\0\0\0= \0\0\ +\0\0\0\0\0\0\0\0\0\0\x04\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x6c\0\0\0\x01\0\0\0= \x03\ +\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x9c\x11\0\0\0\0\0\0\x07\0\0\0\0\0\0\0\0\0\0= \0\0\ +\0\0\0\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x78\0\0\0\x01\0\0\0\x02\0\0\0\0\0= \0\0\ +\0\0\0\0\0\0\0\0\xa8\x11\0\0\0\0\0\0\x30\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x08= \0\0\ +\0\0\0\0\0\0\0\0\0\0\0\0\0\x74\0\0\0\x09\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0= \0\0\ +\0\x17\0\0\0\0\0\0\x10\0\0\0\0\0\0\0\x09\0\0\0\x07\0\0\0\x08\0\0\0\0\0\0\0= \x10\ +\0\0\0\0\0\0\0\xb2\0\0\0\x02\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xd8\x11= \0\0\ +\0\0\0\0\xf8\x04\0\0\0\0\0\0\x01\0\0\0\x30\0\0\0\x08\0\0\0\0\0\0\0\x18\0\0= \0\0\ +\0\0\0"; + + return 0; +err: + bpf_object__destroy_skeleton(s); + return -1; +} + +#endif /* __RSS_BPF_SKEL_H__ */ diff --git a/ebpf/trace-events b/ebpf/trace-events new file mode 100644 index 0000000000..411b1e2be3 --- /dev/null +++ b/ebpf/trace-events @@ -0,0 +1,4 @@ +# See docs/devel/tracing.txt for syntax documentation. + +# ebpf-rss.c +ebpf_error(const char *s1, const char *s2) "error in %s: %s" diff --git a/ebpf/trace.h b/ebpf/trace.h new file mode 100644 index 0000000000..ad570e6691 --- /dev/null +++ b/ebpf/trace.h @@ -0,0 +1,2 @@ +#include "trace/trace-ebpf.h" + diff --git a/meson.build b/meson.build index 2d8b433ff0..9a24020bc3 100644 --- a/meson.build +++ b/meson.build @@ -995,6 +995,13 @@ if not get_option('fuse_lseek').disabled() endif endif =20 +# libbpf +libbpf =3D not_found +if 'CONFIG_EBPF' in config_host + libbpf =3D cc.find_library('bpf', required: true) + +endif + if get_option('cfi') cfi_flags=3D[] # Check for dependency on LTO @@ -1748,6 +1755,7 @@ if have_system 'backends', 'backends/tpm', 'chardev', + 'ebpf', 'hw/9pfs', 'hw/acpi', 'hw/adc', @@ -1914,6 +1922,9 @@ subdir('accel') subdir('plugins') subdir('bsd-user') subdir('linux-user') +subdir('ebpf') + +common_ss.add(libbpf) =20 bsd_user_ss.add(files('gdbstub.c')) specific_ss.add_all(when: 'CONFIG_BSD_USER', if_true: bsd_user_ss) @@ -2592,6 +2603,7 @@ summary_info +=3D {'RDMA support': config_host.h= as_key('CONFIG_RDMA')} summary_info +=3D {'PVRDMA support': config_host.has_key('CONFIG_PVRDMA= ')} summary_info +=3D {'fdt support': fdt_opt =3D=3D 'disabled' ? false = : fdt_opt} summary_info +=3D {'libcap-ng support': libcap_ng.found()} +summary_info +=3D {'bpf support': config_host.has_key('CONFIG_EBPF')} # TODO: add back protocol and server version summary_info +=3D {'spice support': config_host.has_key('CONFIG_SPICE'= )} summary_info +=3D {'rbd support': rbd.found()} @@ -2653,3 +2665,4 @@ if not supported_oses.contains(targetos) message('if you care about QEMU on this platform you should contact') message('us upstream at qemu-devel@nongnu.org.') endif + --=20 2.30.0 From nobody Sat May 18 22:14:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1612457003; cv=none; d=zohomail.com; s=zohoarc; b=ELE8pekSZADINVpCf4TAscQbwL6sNZNrRsi15bp/8Iyx3IDCHIj7kgQSAr5WFeSxQ0ZXIvsNiD/CWOYZjf/cahkWQ8bfO5AeGAsOns3/oCWae4dV/XJ6VtZKAaDO36Sw5pOebNBNRvGDnJm2vOWbXbrayAZI/Pa7M+a7RVcEQy4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612457003; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KcZ5oUK0QMgxCckL+xrjdPqB65jx369Eyixf15nrtjc=; b=UWFtReuH7catTt0icTEpCa64h34J7kPtn4XVrMBGbAe0+PT//tNbc5iQczmBZ30hJhXvpGrtyH32SPRcmNUzFfVgJCzd8GAwOfCmVEHnybPR106Lri6K645vY9jJerfr3Q+TDePGns9a+6Z+cXL2PMPYaLaW+mz8S7/jlro09F4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 161245700342460.2116561884402; Thu, 4 Feb 2021 08:43:23 -0800 (PST) Received: from localhost ([::1]:43032 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7hiz-0003nz-VG for importer@patchew.org; Thu, 04 Feb 2021 11:43:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38976) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7hbl-00031l-Vy for qemu-devel@nongnu.org; Thu, 04 Feb 2021 11:35:54 -0500 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]:35184) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l7hbj-0002Tz-Hr for qemu-devel@nongnu.org; Thu, 04 Feb 2021 11:35:53 -0500 Received: by mail-lf1-x132.google.com with SMTP id u25so5488652lfc.2 for ; Thu, 04 Feb 2021 08:35:51 -0800 (PST) Received: from navi.cosmonova.net.ua ([95.67.24.131]) by smtp.gmail.com with ESMTPSA id c123sm668172lfd.95.2021.02.04.08.35.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 08:35:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KcZ5oUK0QMgxCckL+xrjdPqB65jx369Eyixf15nrtjc=; b=0SqSEhps3SmnUOhFpmI1yuK5RwqNH1G0luKH602E3fleAqpqU1P+MzPOjaeGnswpbC PDLkHbXAA8H0T99J1q/Vrmxq0Ix7z2e9gqud6LbPlVjn7tHQF1jY+wlnvUc4TUz5CxAc c8X6JWaBBTxu3b0N28yHDFliXVRhC7fV16ZZ3mWsnVjWFF0OIL9BL5NMiEaerI8b/SHe dER0tcLMZ9G+ISZI8HT3cfiAvICcTkEvuw3k4+LelumNHJOTLhrKlWP4NgI2QvGcm+T2 LLLyu36z1UN0tlCdXsBukV1G2agERfMOXNmS3DCoEOKyNVcIhRJDTO1NKHrmaa4vYCMf S0Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KcZ5oUK0QMgxCckL+xrjdPqB65jx369Eyixf15nrtjc=; b=txrbPWa4V+WAcoYIXQOq2n2sj7KJLBUvDFsYInXc2MvjloUv9d7IJURZ0jJkyOhrdd m+Upxxe5zRU8/rtuyBEsUZSap6H4ioIjJB78yxR07QEL8n8thadydvTQvqh7aMapuc5s LuFPcIOq0J+iW/9zIGZlJx9mMh7o5HhPIlNaNW7NMsq8/Kux+g8DEBWJDDj9zfxtp05J l0mozBNIz4q6sQAyczy+Udvr4p2IgQeuDwFvos/zu5Mq92Gn62qpmuobFHK9igZZVKph vLhcWThBHyJ5gT9LgJtr5pOg4Nx4m6lAbedsYbkb0ouQ0Jlyad7x3PfGRSbJB1Vl3wQF u7Cg== X-Gm-Message-State: AOAM530BD7yxnl6Fts8FjnU+B/ehU8NeQytqKS+EaXMH0EHR7lZrcQL1 sKzadpwRhEGLuPB1BM2XnAlUzJ1VqzKH6g== X-Google-Smtp-Source: ABdhPJz6WLNIz6F7rrH5eAM0TLcwXEczYBQGHYq8N8zS3BVfWbKQqYbrUusMAdpntqXagG0PDG6SVg== X-Received: by 2002:a19:615:: with SMTP id 21mr129953lfg.614.1612456549649; Thu, 04 Feb 2021 08:35:49 -0800 (PST) From: Andrew Melnychenko To: jasowang@redhat.com, mst@redhat.com Subject: [RFC PATCH v4 5/7] virtio-net: Added eBPF RSS to virtio-net. Date: Thu, 4 Feb 2021 19:09:49 +0200 Message-Id: <20210204170951.91805-6-andrew@daynix.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210204170951.91805-1-andrew@daynix.com> References: <20210204170951.91805-1-andrew@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2a00:1450:4864:20::132; envelope-from=andrew@daynix.com; helo=mail-lf1-x132.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yan@daynix.com, yuri.benditovich@daynix.com, berrange@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Andrew When RSS is enabled the device tries to load the eBPF program to select RX virtqueue in the TUN. If eBPF can be loaded the RSS will function also with vhost (works with kernel 5.8 and later). Software RSS is used as a fallback with vhost=3Doff when eBPF can't be load= ed or when hash population requested by the guest. Signed-off-by: Yuri Benditovich Signed-off-by: Andrew Melnychenko --- hw/net/vhost_net.c | 2 + hw/net/virtio-net.c | 129 ++++++++++++++++++++++++++++++++- include/hw/virtio/virtio-net.h | 4 + net/vhost-vdpa.c | 2 + 4 files changed, 133 insertions(+), 4 deletions(-) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 24d555e764..16124f99c3 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -71,6 +71,8 @@ static const int user_feature_bits[] =3D { VIRTIO_NET_F_MTU, VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_RING_PACKED, + VIRTIO_NET_F_RSS, + VIRTIO_NET_F_HASH_REPORT, =20 /* This bit implies RARP isn't sent by QEMU out of band */ VIRTIO_NET_F_GUEST_ANNOUNCE, diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 5150f295e8..322d035f8c 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -691,6 +691,19 @@ static void virtio_net_set_queues(VirtIONet *n) =20 static void virtio_net_set_multiqueue(VirtIONet *n, int multiqueue); =20 +static uint64_t fix_ebpf_vhost_features(uint64_t features) +{ + /* If vhost=3Don & CONFIG_EBPF doesn't set - disable RSS feature */ + uint64_t ret =3D features; +#ifndef CONFIG_EBPF + virtio_clear_feature(&ret, VIRTIO_NET_F_RSS); +#endif + /* for now, there is no solution for populating the hash from eBPF */ + virtio_clear_feature(&ret, VIRTIO_NET_F_HASH_REPORT); + + return ret; +} + static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t featu= res, Error **errp) { @@ -725,9 +738,9 @@ static uint64_t virtio_net_get_features(VirtIODevice *v= dev, uint64_t features, return features; } =20 - virtio_clear_feature(&features, VIRTIO_NET_F_RSS); - virtio_clear_feature(&features, VIRTIO_NET_F_HASH_REPORT); - features =3D vhost_net_get_features(get_vhost_net(nc->peer), features); + features =3D fix_ebpf_vhost_features( + vhost_net_get_features(get_vhost_net(nc->peer), features)); + vdev->backend_features =3D features; =20 if (n->mtu_bypass_backend && @@ -1151,12 +1164,79 @@ static int virtio_net_handle_announce(VirtIONet *n,= uint8_t cmd, } } =20 +static void virtio_net_detach_epbf_rss(VirtIONet *n); + static void virtio_net_disable_rss(VirtIONet *n) { if (n->rss_data.enabled) { trace_virtio_net_rss_disable(); } n->rss_data.enabled =3D false; + + virtio_net_detach_epbf_rss(n); +} + +static bool virtio_net_attach_ebpf_to_backend(NICState *nic, int prog_fd) +{ + NetClientState *nc =3D qemu_get_peer(qemu_get_queue(nic), 0); + if (nc =3D=3D NULL || nc->info->set_steering_ebpf =3D=3D NULL) { + return false; + } + + return nc->info->set_steering_ebpf(nc, prog_fd); +} + +static void rss_data_to_rss_config(struct VirtioNetRssData *data, + struct EBPFRSSConfig *config) +{ + config->redirect =3D data->redirect; + config->populate_hash =3D data->populate_hash; + config->hash_types =3D data->hash_types; + config->indirections_len =3D data->indirections_len; + config->default_queue =3D data->default_queue; +} + +static bool virtio_net_attach_epbf_rss(VirtIONet *n) +{ + struct EBPFRSSConfig config =3D {}; + + if (!ebpf_rss_is_loaded(&n->ebpf_rss)) { + return false; + } + + rss_data_to_rss_config(&n->rss_data, &config); + + if (!ebpf_rss_set_all(&n->ebpf_rss, &config, + n->rss_data.indirections_table, n->rss_data.key)= ) { + return false; + } + + if (!virtio_net_attach_ebpf_to_backend(n->nic, n->ebpf_rss.program_fd)= ) { + return false; + } + + return true; +} + +static void virtio_net_detach_epbf_rss(VirtIONet *n) +{ + virtio_net_attach_ebpf_to_backend(n->nic, -1); +} + +static bool virtio_net_load_ebpf(VirtIONet *n) +{ + if (!virtio_net_attach_ebpf_to_backend(n->nic, -1)) { + /* backend does't support steering ebpf */ + return false; + } + + return ebpf_rss_load(&n->ebpf_rss); +} + +static void virtio_net_unload_ebpf(VirtIONet *n) +{ + virtio_net_attach_ebpf_to_backend(n->nic, -1); + ebpf_rss_unload(&n->ebpf_rss); } =20 static uint16_t virtio_net_handle_rss(VirtIONet *n, @@ -1271,6 +1351,25 @@ static uint16_t virtio_net_handle_rss(VirtIONet *n, goto error; } n->rss_data.enabled =3D true; + + if (!n->rss_data.populate_hash) { + if (!virtio_net_attach_epbf_rss(n)) { + /* EBPF must be loaded for vhost */ + if (get_vhost_net(qemu_get_queue(n->nic)->peer)) { + warn_report("Can't load eBPF RSS for vhost"); + goto error; + } + /* fallback to software RSS */ + warn_report("Can't load eBPF RSS - fallback to software RSS"); + n->rss_data.enabled_software_rss =3D true; + } + } else { + /* use software RSS for hash populating */ + /* and detach eBPF if was loaded before */ + virtio_net_detach_epbf_rss(n); + n->rss_data.enabled_software_rss =3D true; + } + trace_virtio_net_rss_enable(n->rss_data.hash_types, n->rss_data.indirections_len, temp.b); @@ -1656,7 +1755,7 @@ static ssize_t virtio_net_receive_rcu(NetClientState = *nc, const uint8_t *buf, return -1; } =20 - if (!no_rss && n->rss_data.enabled) { + if (!no_rss && n->rss_data.enabled && n->rss_data.enabled_software_rss= ) { int index =3D virtio_net_process_rss(nc, buf, size); if (index >=3D 0) { NetClientState *nc2 =3D qemu_get_subqueue(n->nic, index); @@ -2760,6 +2859,18 @@ static int virtio_net_post_load_device(void *opaque,= int version_id) } =20 if (n->rss_data.enabled) { + n->rss_data.enabled_software_rss =3D n->rss_data.populate_hash; + if (!n->rss_data.populate_hash) { + if (!virtio_net_attach_epbf_rss(n)) { + if (get_vhost_net(qemu_get_queue(n->nic)->peer)) { + error_report("Can't post-load eBPF RSS for vhost"); + } else { + warn_report("Can't post-load eBPF RSS - fallback to so= ftware RSS"); + n->rss_data.enabled_software_rss =3D true; + } + } + } + trace_virtio_net_rss_enable(n->rss_data.hash_types, n->rss_data.indirections_len, sizeof(n->rss_data.key)); @@ -3336,6 +3447,10 @@ static void virtio_net_device_realize(DeviceState *d= ev, Error **errp) n->qdev =3D dev; =20 net_rx_pkt_init(&n->rx_pkt, false); + + if (virtio_has_feature(n->host_features, VIRTIO_NET_F_RSS)) { + virtio_net_load_ebpf(n); + } } =20 static void virtio_net_device_unrealize(DeviceState *dev) @@ -3344,6 +3459,10 @@ static void virtio_net_device_unrealize(DeviceState = *dev) VirtIONet *n =3D VIRTIO_NET(dev); int i, max_queues; =20 + if (virtio_has_feature(n->host_features, VIRTIO_NET_F_RSS)) { + virtio_net_unload_ebpf(n); + } + /* This will stop vhost backend if appropriate. */ virtio_net_set_status(vdev, 0); =20 @@ -3386,6 +3505,8 @@ static void virtio_net_instance_init(Object *obj) device_add_bootindex_property(obj, &n->nic_conf.bootindex, "bootindex", "/ethernet-phy@0", DEVICE(n)); + + ebpf_rss_init(&n->ebpf_rss); } =20 static int virtio_net_pre_save(void *opaque) diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index 7e96d193aa..824a69c23f 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -21,6 +21,8 @@ #include "qemu/option_int.h" #include "qom/object.h" =20 +#include "ebpf/ebpf_rss.h" + #define TYPE_VIRTIO_NET "virtio-net-device" OBJECT_DECLARE_SIMPLE_TYPE(VirtIONet, VIRTIO_NET) =20 @@ -130,6 +132,7 @@ typedef struct VirtioNetRscChain { =20 typedef struct VirtioNetRssData { bool enabled; + bool enabled_software_rss; bool redirect; bool populate_hash; uint32_t hash_types; @@ -209,6 +212,7 @@ struct VirtIONet { Notifier migration_state; VirtioNetRssData rss_data; struct NetRxPkt *rx_pkt; + struct EBPFRSSContext ebpf_rss; }; =20 void virtio_net_set_netclient_name(VirtIONet *n, const char *name, diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index fe659ec9e2..8b14215549 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -54,6 +54,8 @@ const int vdpa_feature_bits[] =3D { VIRTIO_NET_F_MTU, VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_RING_PACKED, + VIRTIO_NET_F_RSS, + VIRTIO_NET_F_HASH_REPORT, VIRTIO_NET_F_GUEST_ANNOUNCE, VIRTIO_NET_F_STATUS, VHOST_INVALID_FEATURE_BIT --=20 2.30.0 From nobody Sat May 18 22:14:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1612457379; cv=none; d=zohomail.com; s=zohoarc; b=asX6KweJTNpIZ/8+1u8kOtp9QHkURtBe79WVMJmxiURf8nG7pFx6U2k6zO5U6pM/x8RtBBYY33Il45i99Z+/g4gyV5B6W3DlZKn4c7jmOpl0qiBAJpfhiezJb6jIgmiEzPC12doKp6COkxyL5nMi5UNy+P1MD9z6bKXhYb45d7M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612457379; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wFTDn18MKEjEreyR/iIK0LARtIm3Uw+Kz3Ig8TxkhcU=; b=jDhrHvwCVj6LeG5UqKw6kMz0H07VUqU/HMg/sOtX1HNth4VibH318i0VsgDr+nO0+xU/Xv4yFuGKySBU4InJGLkSNOE/A8LlS7h6pZUuNyg1GqMe8jfqjEX4KL0BdLMO1hML6PeB+hEmNDDQLXwPrUuWE0uhM8GrUkp/7lf5Me0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1612457379971139.6508580883749; Thu, 4 Feb 2021 08:49:39 -0800 (PST) Received: from localhost ([::1]:60696 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7hp4-00038S-UN for importer@patchew.org; Thu, 04 Feb 2021 11:49:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39010) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7hbo-00037Y-02 for qemu-devel@nongnu.org; Thu, 04 Feb 2021 11:35:56 -0500 Received: from mail-lj1-x235.google.com ([2a00:1450:4864:20::235]:34969) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l7hbm-0002VA-3U for qemu-devel@nongnu.org; Thu, 04 Feb 2021 11:35:55 -0500 Received: by mail-lj1-x235.google.com with SMTP id a17so4177292ljq.2 for ; Thu, 04 Feb 2021 08:35:53 -0800 (PST) Received: from navi.cosmonova.net.ua ([95.67.24.131]) by smtp.gmail.com with ESMTPSA id c123sm668172lfd.95.2021.02.04.08.35.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 08:35:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wFTDn18MKEjEreyR/iIK0LARtIm3Uw+Kz3Ig8TxkhcU=; b=fsUodhfNUiJfS4dKHar7UOt66uUXcIZyOggyXW6NXs+Uv5XW5/rlX/dbtpiEbcrkHw EbUx7crCL3kEk4PulypAyuRsZozI4NWUS/0cWR0iIZ8gIH00miQSSfrcHROkGulHTu+A Azy9fL0HgCVGtDVJDtgJgjgvoqZXZ1XNITQ6XQ7dxzPe+iDLD0IcU4F8un8MKbQxYArz aET9C8tyi0+zMoWghPjfAelAkngYLiiiC+zdplyepkTCFYbvio+1QmILwZCLcZOZvDPK 5sf2lZg0/C67lQ7nHAPUNfBrS5TYUE9Rzww0XddXjBgE8tlfAfgxeN6jorU4GCRx8WBG kCtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wFTDn18MKEjEreyR/iIK0LARtIm3Uw+Kz3Ig8TxkhcU=; b=pVY74g19HXy42wSAUFnm/Yvlmt7CIJJfBIGarJwjf8ENaUTqFJz2qP9s0j5/1R9xnH ZtDaStptdK2Au6n/TnWB5HWk6kZBqgmEOi8DZ7UiLJwhtVmIamff98zZszaR7sIYRKwA 3J68sbqTYCQSzY36+kJxB8mI34KHdal/xK2Jh0UR9k40XJMquBjEKPtRZVLQhF/NIM/Q qCjkRdKlVBFjGG3FzoGRMujFRnCLUoUBM2UHgRfvWZ/jZ2mpzJfW+nerUfpqnt3MK5l+ pWcZNgO+uOnazOdtMJdiGvQeN1ULziEhI/ru0qjGZRPW0JdYXZz2zAp7B9VVcTtT2tJT AMjg== X-Gm-Message-State: AOAM532k3f+OHGzFb43qshZDc2e5coem5++WR2eaU1c+5J/+bftPTYYZ mkXH13GTf0SJH9aWe36ZX/5T8A== X-Google-Smtp-Source: ABdhPJy7jgadNcQcMVGMkDPvvXvamB9+X2JSXXqWWDDsbW6vyW3WZiNinRdKOkiALGHwDSn7Rwr8rQ== X-Received: by 2002:a2e:1519:: with SMTP id s25mr109231ljd.495.1612456551012; Thu, 04 Feb 2021 08:35:51 -0800 (PST) From: Andrew Melnychenko To: jasowang@redhat.com, mst@redhat.com Subject: [RFC PATCH v4 6/7] docs: Added eBPF documentation. Date: Thu, 4 Feb 2021 19:09:50 +0200 Message-Id: <20210204170951.91805-7-andrew@daynix.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210204170951.91805-1-andrew@daynix.com> References: <20210204170951.91805-1-andrew@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2a00:1450:4864:20::235; envelope-from=andrew@daynix.com; helo=mail-lj1-x235.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yan@daynix.com, yuri.benditovich@daynix.com, berrange@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Andrew Signed-off-by: Yuri Benditovich Signed-off-by: Andrew Melnychenko --- docs/ebpf_rss.rst | 125 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 docs/ebpf_rss.rst diff --git a/docs/ebpf_rss.rst b/docs/ebpf_rss.rst new file mode 100644 index 0000000000..5beecfe33f --- /dev/null +++ b/docs/ebpf_rss.rst @@ -0,0 +1,125 @@ +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D +eBPF RSS virtio-net support +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D + +RSS(Receive Side Scaling) is used to distribute network packets to guest v= irtqueues +by calculating packet hash. Usually every queue is processed then by a spe= cific guest CPU core. + +For now there are 2 RSS implementations in qemu: +- 'in-qemu' RSS (functions if qemu receives network packets, i.e. vhost=3D= off) +- eBPF RSS (can function with also with vhost=3Don) + +eBPF support (CONFIG_EBPF) is enabled by 'configure' script. +To enable eBPF RSS support use './configure --enable-bpf'. + +If steering BPF is not set for kernel's TUN module, the TUN uses automatic= selection +of rx virtqueue based on lookup table built according to calculated symmet= ric hash +of transmitted packets. +If steering BPF is set for TUN the BPF code calculates the hash of packet = header and +returns the virtqueue number to place the packet to. + +Simplified decision formula: + +.. code:: C + + queue_index =3D indirection_table[hash()%] + + +Not for all packets, the hash can/should be calculated. + +Note: currently, eBPF RSS does not support hash reporting. + +eBPF RSS turned on by different combinations of vhost-net, vitrio-net and = tap configurations: + +- eBPF is used: + + tap,vhost=3Doff & virtio-net-pci,rss=3Don,hash=3Doff + +- eBPF is used: + + tap,vhost=3Don & virtio-net-pci,rss=3Don,hash=3Doff + +- 'in-qemu' RSS is used: + + tap,vhost=3Doff & virtio-net-pci,rss=3Don,hash=3Don + +- eBPF is used, hash population feature is not reported to the guest: + + tap,vhost=3Don & virtio-net-pci,rss=3Don,hash=3Don + +If CONFIG_EBPF is not set then only 'in-qemu' RSS is supported. +Also 'in-qemu' RSS, as a fallback, is used if the eBPF program failed to l= oad or set to TUN. + +RSS eBPF program +---------------- + +RSS program located in ebpf/rss.bpf.skeleton.h generated by bpftool. +So the program is part of the qemu binary. +Initially, the eBPF program was compiled by clang and source code located = at tools/ebpf/rss.bpf.c. +Prerequisites to recompile the eBPF program (regenerate ebpf/rss.bpf.skele= ton.h): + + llvm, clang, kernel source tree, bpftool + Adjust 'linuxhdrs' in Makefile.ebpf to reflect the location of the= kernel source tree + + $ cd ebpf + $ make -f Makefile.ebpf + +Current eBPF RSS implementation uses 'bounded loops' with 'backward jump i= nstructions' which present in the last kernels. +Overall eBPF RSS works on kernels 5.8+. + +eBPF RSS implementation +----------------------- + +eBPF RSS loading functionality located in ebpf/ebpf_rss.c and ebpf/ebpf_rs= s.h. + +The `struct EBPFRSSContext` structure that holds 4 file descriptors: + +- ctx - pointer of the libbpf context. +- program_fd - file descriptor of the eBPF RSS program. +- map_configuration - file descriptor of the 'configuration' map. This map= contains one element of 'struct EBPFRSSConfig'. This configuration determi= nes eBPF program behavior. +- map_toeplitz_key - file descriptor of the 'Toeplitz key' map. One elemen= t of the 40byte key prepared for the hashing algorithm. +- map_indirections_table - 128 elements of queue indexes. + +`struct EBPFRSSConfig` fields: + +- redirect - "boolean" value, should the hash be calculated, on false - `= default_queue` would be used as the final decision. +- populate_hash - for now, not used. eBPF RSS doesn't support hash reporti= ng. +- hash_types - binary mask of different hash types. See `VIRTIO_NET_RSS_HA= SH_TYPE_*` defines. If for packet hash should not be calculated - `default_= queue` would be used. +- indirections_len - length of the indirections table, maximum 128. +- default_queue - the queue index that used for packet that shouldn't be h= ashed. For some packets, the hash can't be calculated(g.e ARP). + +Functions: + +- `ebpf_rss_init()` - sets ctx to NULL, which indicates that EBPFRSSContex= t is not loaded. +- `ebpf_rss_load()` - creates 3 maps and loads eBPF program from tun_rss_s= teering.h. Returns 'true' on success. After that, program_fd can be used to= set steering for TAP. +- `ebpf_rss_set_all()` - sets values for eBPF maps. `indirections_table` l= ength is in EBPFRSSConfig. `toeplitz_key` is VIRTIO_NET_RSS_MAX_KEY_SIZE ak= a 40 bytes array. +- `ebpf_rss_unload()` - close all file descriptors and set ctx to NULL. + +Simplified eBPF RSS workflow: + +.. code:: C + + struct EBPFRSSConfig config; + config.redirect =3D 1; + config.hash_types =3D VIRTIO_NET_RSS_HASH_TYPE_UDPv4 | VIRTIO_NET_RSS_= HASH_TYPE_TCPv4; + config.indirections_len =3D VIRTIO_NET_RSS_MAX_TABLE_LEN; + config.default_queue =3D 0; + + uint16_t table[VIRTIO_NET_RSS_MAX_TABLE_LEN] =3D {...}; + uint8_t key[VIRTIO_NET_RSS_MAX_KEY_SIZE] =3D {...}; + + struct EBPFRSSContext ctx; + ebpf_rss_init(&ctx); + ebpf_rss_load(&ctx); + ebpf_rss_set_all(&ctx, &config, table, key); + if (net_client->info->set_steering_ebpf !=3D NULL) { + net_client->info->set_steering_ebpf(net_client, ctx->program_fd); + } + ... + ebpf_unload(&ctx); + + +NetClientState SetSteeringEBPF() +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +For now, `set_steering_ebpf()` method supported by Linux TAP NetClientStat= e. The method requires an eBPF program file descriptor as an argument. --=20 2.30.0 From nobody Sat May 18 22:14:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1612457189; cv=none; d=zohomail.com; s=zohoarc; b=OeYM/YIfNsAdZGHjI6Wcac1w7lYHU7gKfsfNBf29FChWMUJ0Cmv1G7ST5TSvgW8XASSnre+/qvnP4f/2rtF7ckQIy5dS73xeAmbPje0R/BJFr2VmIhmRls6kw0AI9FAWY3eSa3w5HMhZGN6Va2TCyEWR9vVuu02xdwbBpiZAfbU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612457189; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4WI16CTOIH3OYsFhn8s8asBAXjvcK1IPlUFFZNLp6qM=; b=RUcyrmhI+nco9ZLdNzsvYMBdmwGPMqp83jpOcLGWiG5EsYm7Rd247zHlMOMprs3K87yh9vfokyMu7524xcDzf0xRU7rRKMz2VELk457RPedFMMWwApPzM0G6iVwpPRMP1OFfh52jqVtWegC11baZZU22cU3dpYgtLqNEBxeAMAw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1612457189494510.66438280911973; Thu, 4 Feb 2021 08:46:29 -0800 (PST) Received: from localhost ([::1]:51772 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7hm0-0007eX-EY for importer@patchew.org; Thu, 04 Feb 2021 11:46:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39004) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7hbn-00036h-J9 for qemu-devel@nongnu.org; Thu, 04 Feb 2021 11:35:55 -0500 Received: from mail-lf1-x12b.google.com ([2a00:1450:4864:20::12b]:41370) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l7hbm-0002V9-1k for qemu-devel@nongnu.org; Thu, 04 Feb 2021 11:35:55 -0500 Received: by mail-lf1-x12b.google.com with SMTP id a8so5426823lfi.8 for ; Thu, 04 Feb 2021 08:35:53 -0800 (PST) Received: from navi.cosmonova.net.ua ([95.67.24.131]) by smtp.gmail.com with ESMTPSA id c123sm668172lfd.95.2021.02.04.08.35.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 08:35:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4WI16CTOIH3OYsFhn8s8asBAXjvcK1IPlUFFZNLp6qM=; b=jVRnJC5/sf0nf352t3fX3TX48Kl2NNB2VjgSFGX5jyeT2J2whX1lmFSIHC/zOJqBC8 S5WJ0N7h92Kk2zYv4cQvCwPOxrVUZFiWPiBBVfbqpJDJoWWsdHe5mYuIMR6UFuOW8jCt aX/Ke4KQQBzxGZ7T0XRw6DwQnQKVfjIm4/TEBomXUcOibaaw8p/hR3HKmrlvzvQAGmRW RkUJtK6GQuCWdxp4bJ15sjR5HVjDGtEwJtoMSd/jEinbf3QwXvJZScOh21X6Riy8Mqix r6+MJBboa2GAkoIwEg8zrElu1RLO0FzcS4WE3rosXt7+hzyBJsgMuCbMay5GsxR0ozVo 2BUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4WI16CTOIH3OYsFhn8s8asBAXjvcK1IPlUFFZNLp6qM=; b=m1OvD3QRaYYr+/jx4i23JUGP/Y/M1kvZoDTTEW0vISGz5rAX+H1f3fo6V9yQA7s0iD Kqk590OG96ANVZa1SPlmZ5JckXtCPqkyaj+Q9eZA6a477KN90kbO11AD4b5/fY5LBZ9e mdaw0WyOjZINUtq6PqWeKgNKigo/9HptCdXr3QiucpNeoNYqqy2TENX6d46KQiw0pxhl 6RXDnSvb+JqwpYJVY3x2Wy0XnLTcRcI2B66FiiGUQD1eE9RL+BV9Kvreu78qSj0mmuKq hztmtV5bZ2jIGfDqJKppDmb18IAA5S3B0q22GELzpqP3VbY8Xm7Ubov2tyieHmGLzgU8 sP+Q== X-Gm-Message-State: AOAM530P0MTBHUnHYJZQ8MxCTm5PeOHcAFEo1VdAcQCCPFTnR1HS9Z4I 1h7ANbvbh/80NTw8WTfu14bIKw== X-Google-Smtp-Source: ABdhPJx00HUbTZlTsswRRmsWo5FVxOwcicXIuJMDTiqnPfmrEFC370rHgdp8OjD/yUE/J5/aZeXQTQ== X-Received: by 2002:ac2:510a:: with SMTP id q10mr138036lfb.48.1612456552204; Thu, 04 Feb 2021 08:35:52 -0800 (PST) From: Andrew Melnychenko To: jasowang@redhat.com, mst@redhat.com Subject: [RFC PATCH v4 7/7] MAINTAINERS: Added eBPF maintainers information. Date: Thu, 4 Feb 2021 19:09:51 +0200 Message-Id: <20210204170951.91805-8-andrew@daynix.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210204170951.91805-1-andrew@daynix.com> References: <20210204170951.91805-1-andrew@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2a00:1450:4864:20::12b; envelope-from=andrew@daynix.com; helo=mail-lf1-x12b.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yan@daynix.com, yuri.benditovich@daynix.com, berrange@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Andrew Signed-off-by: Yuri Benditovich Signed-off-by: Andrew Melnychenko --- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 00626941f1..5ca9e8f304 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3194,6 +3194,14 @@ S: Maintained F: hw/semihosting/ F: include/hw/semihosting/ =20 +EBPF: +M: Jason Wang +R: Andrew Melnychenko +R: Yuri Benditovich +S: Maintained +F: ebpf/* +F: tools/ebpf/* + Build and test automation ------------------------- Build and test automation --=20 2.30.0