From nobody Wed Nov 27 21:31:50 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=1697378761; cv=none; d=zohomail.com; s=zohoarc; b=SmWiJLd+i6cRUPGY/CbsmqcomxG6bA95x+t0dgsitlfSeefBXM0/1uJiEmwOYGMG+wHi3x20VR4qe8zbIWtrFA2xm6HdSh3qn5LyNCYMITLhMTgeSstjNzkgavyoCNYc1SC15FExljvTkdFmJveKtsIM5dxkcy9oJzSwbbScVXw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697378761; 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=Y61p5FMMcfWvvqbRqBr1GjNfFP2hj2byDlX9tvC0bnM=; b=MdTF3SAJMQWytZ2wbR+9O3a2lH8FwpoFScQJxEDQgojQLN5CRDwKF2d/2MkWG9tAqu16bxmdt6sbMplvazxha914mhi2Hhm4SAbtCabol5iUuDiHBDJ4FqvJZuk+Zt0CZ4idqPHYVLtpxEBPJZUqgNfwrf8GOcjkwv3tQkGlVfk= 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 1697378761172705.7610567392483; Sun, 15 Oct 2023 07:06:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qs1jI-0003kf-Dh; Sun, 15 Oct 2023 10:04:28 -0400 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 1qs1jB-0003Go-Rq for qemu-devel@nongnu.org; Sun, 15 Oct 2023 10:04:22 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qs1j9-0007xD-BW for qemu-devel@nongnu.org; Sun, 15 Oct 2023 10:04:20 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-6bce254ba56so474057b3a.1 for ; Sun, 15 Oct 2023 07:04:19 -0700 (PDT) Received: from localhost ([2400:4050:a840:1e00:78d2:b862:10a7:d486]) by smtp.gmail.com with UTF8SMTPSA id j15-20020aa7800f000000b0068aca503b9fsm16476292pfi.114.2023.10.15.07.04.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 15 Oct 2023 07:04:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1697378658; x=1697983458; 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=Y61p5FMMcfWvvqbRqBr1GjNfFP2hj2byDlX9tvC0bnM=; b=Q9SVS/5RlpQE7pydFIp4hDVNqXdtFquoI0W2nMRBcvt7AgPlQt1EjQ+xSAt5dAa4pK alrCfnlJvOMAFbccPDjnpAuKMZ4qFoRPLxWeewC560BfHCKaDWi1ElrINrFA6Mzt8BgK Sj+UA95kvLA5tHxsd/SSL0M1FABHr8sOX5in6jef31euBXtzxd1/wCFCqlbNptikWbPK SQTUt39JT0a8oEADMhuh0mlIBgry+cL/SCiDG+B/BrZKie2QkpJ8YmX7ODlJbRYuVkGp esD7OlBiWAoIoS8oxEPhamZE2QAnAyoPQ3YFtqDMptEpkWKsGgvXwV/pWiok+LiMvuNX 332w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697378658; x=1697983458; 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=Y61p5FMMcfWvvqbRqBr1GjNfFP2hj2byDlX9tvC0bnM=; b=ghy8KYC0DJVcwI7B7g3z8mSAzo603u+veHENBy+BKpLBB8sALb5t88KKzhgDQXovHL vULFj+rFYgrHIqmnOdbGBoys4FZgUBOfmDA9DPHQJhw1j5RYwPGaN5LsWoDish0UDzRc B1y11R5BzFKux/bByHCZ9N0brykViySRbEmnUP/B68e8UQJBMwKZg7Hqp321anAFLRQM 7gwL0fZe2q7NAmuYjVm9MjNtTog5qqe0DfFglcyP9KrJr/wj7cdY6QeyAlrF7L1l+bna 5ozDgSJ+7s+R64plSqP5FDtcmPzNhWWIriUj6gPXvPY+3t9yOFo8ZkTdzPpWXEtM8kWf mDqg== X-Gm-Message-State: AOJu0Ywb9m37z5AE0Qq3D69WE+4F5kW9jj7Is1KTToYt4Tv3/eBUlBik anlIHZ1637ebN6+DAMI30TlOW2nO0XmAbYv7Rc3wGQ== X-Google-Smtp-Source: AGHT+IE21iiXsOgBl+NYQdbf/DQpWDTU8VTVqpw6X9oNi2NuITfR9JWScDrjqwDTZmGOfPpi+uMoXg== X-Received: by 2002:a05:6a00:a92:b0:68e:399e:70db with SMTP id b18-20020a056a000a9200b0068e399e70dbmr31519988pfl.6.1697378657747; Sun, 15 Oct 2023 07:04:17 -0700 (PDT) From: Akihiko Odaki To: Cc: qemu-devel@nongnu.org, Yuri Benditovich , Andrew Melnychenko , "Michael S . Tsirkin" , Jason Wang , Akihiko Odaki Subject: [PATCH v4 19/20] ebpf: Refactor tun_rss_steering_prog() Date: Sun, 15 Oct 2023 23:02:51 +0900 Message-ID: <20231015140259.259434-20-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231015140259.259434-1-akihiko.odaki@daynix.com> References: <20231015140259.259434-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::435; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x435.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.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: 1697378762392100003 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.0