From nobody Wed Nov 27 06:37:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=1700299814; cv=none; d=zohomail.com; s=zohoarc; b=XN+wVMUnIN4oNYAcoiKt/nY2MRgS5tcYaftZGGFmSnF2q7n6xJkprY0YrWuCDUQFDni75+ZLC2OKJC26SeZA01O5zPCyHGIivGEJu42KC0GEwKXvPNSM4TuRtlPkpWCGys5O+eQcmcheRRQOj0Q4r3I52Wmox8O2yzT7gUJLASg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700299814; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:Message-Id:Reply-To:To; bh=0bMxXc53w5OZ8Z87TMnvwY5bBiL/RmptQnjEe3mn7CI=; b=lJKcaIUiB5maVQso2At1zf705UuoaqBpwM8I1E9bBA897b6F04naTZ+cUZRIZKWKLvabqH5Kgq7wQnTzdF1AJmnu/ousvh5qkv8UqBLdSDS1g5oeC+UCDKPHUGgyMcm21FhK6Xx5xzOi4A6XCyi0L0bq3PFm7gEaXTdk22VILnY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1700299814771673.1237790486435; Sat, 18 Nov 2023 01:30:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r4Hc2-0000A3-0p; Sat, 18 Nov 2023 04:27:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r4Hbr-0008ED-Bd for qemu-devel@nongnu.org; Sat, 18 Nov 2023 04:27:30 -0500 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r4Hbo-0003rY-Px for qemu-devel@nongnu.org; Sat, 18 Nov 2023 04:27:27 -0500 Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-28094a3b760so2180120a91.3 for ; Sat, 18 Nov 2023 01:27:24 -0800 (PST) Received: from localhost ([157.82.205.15]) by smtp.gmail.com with UTF8SMTPSA id n5-20020a170902e54500b001ce5b881e21sm2619433plf.306.2023.11.18.01.27.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 18 Nov 2023 01:27:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1700299643; x=1700904443; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0bMxXc53w5OZ8Z87TMnvwY5bBiL/RmptQnjEe3mn7CI=; b=df7y3aihg5yHhX7lLITxmtkcCzFePJAbGY7hztiKyyDLCPdPgA8yfzABh18wCqXgcm KdAH433fKIwIwzInwsUKMrmLYV6ff0Fwu4p5C02jKATSqe1ceOc9smhGQQJTATzblE8c OYyDMBwRmBaQ22QmLuRnSW4aLqC2Qz2gS6idPyGxzaqOu0ce+6KDnY+DJmjehyRgErby cQchxWWs/GDvvwEb+bCMrtpw7qX64CBVBBT+ZQbYP7tJUWNZahTGj/r0GOlOriRdpdp9 efXGgzaA4w4fYeVmg93d9jSk3Ke5cV/Vj5tY62PBm0MmDFyLa6QsumyHLUJc2ZlP4Y4h NpiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700299643; x=1700904443; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0bMxXc53w5OZ8Z87TMnvwY5bBiL/RmptQnjEe3mn7CI=; b=aaEB+tK0Kmjn4C9zShK+x+KZ+ORF7nDiVGiZhPuJPxls90uEum5UxVkAKw99XDYxUb HtMLTOHwJzsPBp88i0t1NUzbfo9Oh+PRU1XP3eqAgDm5cV5QdFmS9HPARRh87dp8eAwH kjtnZOG8QIc2xNr6zZ0Yjtdr4jfE2ycRaRlT7kdyUabncARvCRWrD7TRhoi0uoAMYS5m X7O3tKHTPvWeB9YiCcvwsrxebnXo2wYYx20TAZSWWLxB0efVpIDuEIInxvtBn3Ys360T PK7+EmqF8lUfRh0g7Briqd20xYah/ozN35qpPzwGKUVptiJu/R49QItJOYWoXru2mnpa r/LQ== X-Gm-Message-State: AOJu0YzX6r/NGzoSuXISObp06FbdzyZEpIK2Jo6/fIyaUCVDB34lhJee neAs61jqBOsFrdW4F5RwU6AiAWnP23kpi8Tjbsk= X-Google-Smtp-Source: AGHT+IH9WIp2kTvCJl5aclAn7z8fqEYRRV2w8Ijo2t6XYmb68TlhbWzLfVm29ckVD37XD+JFjXutwA== X-Received: by 2002:a17:90b:33c7:b0:280:a460:c3b with SMTP id lk7-20020a17090b33c700b00280a4600c3bmr1302651pjb.48.1700299642856; Sat, 18 Nov 2023 01:27:22 -0800 (PST) From: Akihiko Odaki To: Cc: qemu-devel@nongnu.org, Yuri Benditovich , Andrew Melnychenko , "Michael S . Tsirkin" , Jason Wang , "Zhang, Chen" , Akihiko Odaki Subject: [PATCH RESEND v7 18/19] ebpf: Refactor tun_rss_steering_prog() Date: Sat, 18 Nov 2023 18:25:58 +0900 Message-ID: <20231118092601.7132-19-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231118092601.7132-1-akihiko.odaki@daynix.com> References: <20231118092601.7132-1-akihiko.odaki@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=2607:f8b0:4864:20::1034; envelope-from=akihiko.odaki@daynix.com; helo=mail-pj1-x1034.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1700299816150100002 Content-Type: text/plain; charset="utf-8" This saves branches and makes later BPF program changes easier. Signed-off-by: Akihiko Odaki --- tools/ebpf/rss.bpf.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/tools/ebpf/rss.bpf.c b/tools/ebpf/rss.bpf.c index 22c75d5912..012af38df1 100644 --- a/tools/ebpf/rss.bpf.c +++ b/tools/ebpf/rss.bpf.c @@ -544,27 +544,23 @@ int tun_rss_steering_prog(struct __sk_buff *skb) config =3D bpf_map_lookup_elem(&tap_rss_map_configurations, &key); toe =3D bpf_map_lookup_elem(&tap_rss_map_toeplitz_key, &key); =20 - if (config && toe) { - if (!config->redirect) { - return config->default_queue; - } + if (!config || !toe) { + return 0; + } =20 - if (calculate_rss_hash(skb, config, toe, &hash)) { - __u32 table_idx =3D hash % config->indirections_len; - __u16 *queue =3D 0; + if (config->redirect && calculate_rss_hash(skb, config, toe, &hash)) { + __u32 table_idx =3D hash % config->indirections_len; + __u16 *queue =3D 0; =20 - queue =3D bpf_map_lookup_elem(&tap_rss_map_indirection_table, - &table_idx); + queue =3D bpf_map_lookup_elem(&tap_rss_map_indirection_table, + &table_idx); =20 - if (queue) { - return *queue; - } + if (queue) { + return *queue; } - - return config->default_queue; } =20 - return 0; + return config->default_queue; } =20 char _license[] SEC("license") =3D "GPL v2"; --=20 2.42.1