Message ID | 20240215160458.1727237-2-ast@fiberby.net |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-67280-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp506901dyb; Thu, 15 Feb 2024 08:14:13 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUgyyLEg9S1k9W0mRFr9DQ7mnNQ1nq8mu+O3tTNwPGSLnCj6phwcs5K+f25vTUShF3k6Gz2dSymJM+LIxMxxRS9VcxhSw== X-Google-Smtp-Source: AGHT+IE2CkH3GUBnGYzyaJSXCGFjRac08kWBGDd23HTY3tLozWvAv2rZnq3EkpRmOe0AV9oyL4va X-Received: by 2002:a17:90b:1281:b0:298:ad38:75c8 with SMTP id fw1-20020a17090b128100b00298ad3875c8mr1941438pjb.45.1708013653032; Thu, 15 Feb 2024 08:14:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708013653; cv=pass; d=google.com; s=arc-20160816; b=Rnd7nkyBZ8O3CmibBOwmKMXEVZmWzEZrr2kUdSCNRpFqCkMSpRDzda+L68P94WaHUf HjrZlGuxjzdTbwWeF9IFVjCvB8v9Iy6+U6Jx4hLiJY1Xl3HwDDWyE7tR6t/fxZPGPTXE T+9jVRGtY9oiJ//rpWLD9cKyn933x0AeiDWCV/a+5yY9gcbvpw5mEN9zyz7Oi+jw6iuc CDzgyd5bsjNj1yJMRdu8Zg4woEvUjuz8NjbXcLEx/ppfdljSXigK9KWIboIc7uYo/HVr PQaZZTfhxzKdZKBwDxuoNpn4/iMifpTdumjmqO9n4a9mBgdaBPQ/DdjJ8Cfnqvs2qSzC ANOw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Ldu3/MWiz8i5k7YFRP8XCiyFuOJo3CjiWT3JeYNwRPA=; fh=qwn0ZN7d/LlgLhwKKJFblL2+CYxSTOyA+LLcZtnY3QM=; b=oHW4dv0gW1hXSHBz0PGklc5UesiFh7xMrATXpwnqBwTS+Oap62oW/5lNIVC+oze0T4 jdR+vdbJx8sm2TCu0fdAevO8oXEiBeC135eUblHb4YXvijDH2N1tbYZZt8bWf6YIYD44 /MEjJ3GbE8w6lzBpUoztd0jk7JDoeAiTY1Tpq15KQwK6LtY937DO6jyZSuOlHo6/Z+Kb NuTrq3mmCsgz+ZfAhwqxjcU6+KwaDvHQYlBYTu7RCV/TW2KQUXUHufeusranA5pSW35z rHaH2KTgQleNJHJSHSvbX2Kke135D4z/wc++HpLTgpR9oobFGCrIVk2AHmCIfiYdRVU6 5WvQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@fiberby.net header.s=202008 header.b=q+DVNN2Q; arc=pass (i=1 spf=pass spfdomain=fiberby.net dkim=pass dkdomain=fiberby.net dmarc=pass fromdomain=fiberby.net); spf=pass (google.com: domain of linux-kernel+bounces-67280-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67280-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fiberby.net Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id mu4-20020a17090b388400b00296fcd007d2si1464301pjb.29.2024.02.15.08.14.12 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 08:14:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67280-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@fiberby.net header.s=202008 header.b=q+DVNN2Q; arc=pass (i=1 spf=pass spfdomain=fiberby.net dkim=pass dkdomain=fiberby.net dmarc=pass fromdomain=fiberby.net); spf=pass (google.com: domain of linux-kernel+bounces-67280-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67280-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fiberby.net Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id A4EBE282A13 for <ouuuleilei@gmail.com>; Thu, 15 Feb 2024 16:13:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 306C213664C; Thu, 15 Feb 2024 16:06:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b="q+DVNN2Q" Received: from mail1.fiberby.net (mail1.fiberby.net [193.104.135.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2FFD91350F0; Thu, 15 Feb 2024 16:06:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.104.135.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708013202; cv=none; b=Yt1g1QdaAdZt+tzW/qHQRnkMXVJSE81wb11aM4juZOdfLgi6BRZhiCeehIf1tlK9KqeyTLSJ8nEx8noJXLzGRz1Do6ul2DLoC2gEst/6sK5y4LcclQseJSca2XxJSnPu9j7TbIiXQhSKSuwcR40eQoYpiGIfbn6drr96adsxlmU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708013202; c=relaxed/simple; bh=akjpUr+ZYSjEQ/296swH0R+gJmt5trZjoLKfmLO+NZU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=V6cmz3/Oo016awz1fZcC2MbXZFD7PGBxR27dUKPwq8IaHTXUsQgLczsY91WXgyBHcP6OSuOqWyo4eaksIo/LN5aVqsOwyhzmqMcVdRBv1qUKPpAY2EITjgmRDfHbpyOIRuZ5SEpwBauq6VGeHgG5PPRzaVBAPcDKF7ilJfcG5Ak= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net; spf=pass smtp.mailfrom=fiberby.net; dkim=pass (2048-bit key) header.d=fiberby.net header.i=@fiberby.net header.b=q+DVNN2Q; arc=none smtp.client-ip=193.104.135.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fiberby.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fiberby.net Received: from x201s (193-104-135-243.ip4.fiberby.net [193.104.135.243]) by mail1.fiberby.net (Postfix) with ESMTPSA id 0E11F600D4; Thu, 15 Feb 2024 16:06:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fiberby.net; s=202008; t=1708013196; bh=akjpUr+ZYSjEQ/296swH0R+gJmt5trZjoLKfmLO+NZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q+DVNN2QORy7bWZJmmlebtJiMPJDFrwsJrv5EHEWHCk5oEuNzyP+UCunwTvFR9dvu dn+LZ7CSwcrQPShycKPCZ+Aqc9IRXWZaYmAjCg+Nb3X0OcUmkhfpZZBHN4/7jbxvvq w5ymk2v4y9F7HIk3xnvFAEnyb+dJWAnnvapHXPdE6BiMHtRksemd7laYjg4THKBLMo Rqogm2f+2zKhVl9QNSfHdJdZmEFPkJL+owLTCUu9yL/k3qR3jmr4fe8mmZkfLShX5J qbMvemeeVmmU79S/8Ptf1LyGOngQ3KAHnEv/NWvAmwG40/CVZFhnohOTiKDvuNTXHX HNOXDs+ShwJYA== Received: by x201s (Postfix, from userid 1000) id 42E0D202FB6; Thu, 15 Feb 2024 16:05:44 +0000 (UTC) From: =?utf-8?q?Asbj=C3=B8rn_Sloth_T=C3=B8nnesen?= <ast@fiberby.net> To: Jamal Hadi Salim <jhs@mojatatu.com>, Cong Wang <xiyou.wangcong@gmail.com>, Jiri Pirko <jiri@resnulli.us> Cc: =?utf-8?q?Asbj=C3=B8rn_Sloth_T=C3=B8nnesen?= <ast@fiberby.net>, Daniel Borkmann <daniel@iogearbox.net>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, llu@fiberby.dk Subject: [PATCH net-next 1/3] net: sched: cls_api: add skip_sw counter Date: Thu, 15 Feb 2024 16:04:42 +0000 Message-ID: <20240215160458.1727237-2-ast@fiberby.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215160458.1727237-1-ast@fiberby.net> References: <20240215160458.1727237-1-ast@fiberby.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790982124374134874 X-GMAIL-MSGID: 1790982124374134874 |
Series |
make skip_sw actually skip software
|
|
Commit Message
Asbjørn Sloth Tønnesen
Feb. 15, 2024, 4:04 p.m. UTC
Maintain a count of skip_sw filters.
This counter is protected by the cb_lock, and is updated
at the same time as offloadcnt.
Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
---
include/net/sch_generic.h | 1 +
net/sched/cls_api.c | 4 ++++
2 files changed, 5 insertions(+)
Comments
On Thu 15 Feb 2024 at 23:34, Asbjørn Sloth Tønnesen <ast@fiberby.net> wrote: > Hi Jamal, > > Thank you for the review. > > On 2/15/24 17:39, Jamal Hadi Salim wrote: >> +Cc Vlad and Marcelo.. >> On Thu, Feb 15, 2024 at 11:06 AM Asbjørn Sloth Tønnesen <ast@fiberby.net> >> wrote: >>> >>> Maintain a count of skip_sw filters. >>> >>> This counter is protected by the cb_lock, and is updated >>> at the same time as offloadcnt. >>> >>> Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net> >>> --- >>> include/net/sch_generic.h | 1 + >>> net/sched/cls_api.c | 4 ++++ >>> 2 files changed, 5 insertions(+) >>> >>> diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h >>> index 934fdb977551..46a63d1818a0 100644 >>> --- a/include/net/sch_generic.h >>> +++ b/include/net/sch_generic.h >>> @@ -476,6 +476,7 @@ struct tcf_block { >>> struct flow_block flow_block; >>> struct list_head owner_list; >>> bool keep_dst; >>> + atomic_t skipswcnt; /* Number of skip_sw filters */ >>> atomic_t offloadcnt; /* Number of oddloaded filters */ >> For your use case is skipswcnt ever going to be any different than offloadcnt? > > No, we only use skip_sw filters, since we only use TC as a control path to > install skip_sw rules into hardware. > > AFAICT offloadcnt is the sum of skip_sw filters, and filters with no flags which > have implicitly been offloaded. > > The reason that I didn't just use offloadcnt, is that I'm not sure if it is > acceptable to treat implicitly offloaded rules without skip_sw, as if they were > explicitly skip_sw. It sounds reasonable, given that the filters without skip_* flags > shouldn't really care. It is not acceptable since there are valid use-cases where packets need to match sw filters that are supposedly also in-hw. For example, filters with tunnel_key set action during neighbor update event. > > I tried to only trigger the TC bypass, in the cases that I was absolutely sure would > be safe as a first step. > > >> cheers, >> jamal >> >>> unsigned int nooffloaddevcnt; /* Number of devs unable to do offload */ >>> unsigned int lockeddevcnt; /* Number of devs that require rtnl lock. */ >>> diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c >>> index ca5676b2668e..397c3d29659c 100644 >>> --- a/net/sched/cls_api.c >>> +++ b/net/sched/cls_api.c >>> @@ -3483,6 +3483,8 @@ static void tcf_block_offload_inc(struct tcf_block *block, u32 *flags) >>> if (*flags & TCA_CLS_FLAGS_IN_HW) >>> return; >>> *flags |= TCA_CLS_FLAGS_IN_HW; >>> + if (tc_skip_sw(*flags)) >>> + atomic_inc(&block->skipswcnt); >>> atomic_inc(&block->offloadcnt); >>> } >>> >>> @@ -3491,6 +3493,8 @@ static void tcf_block_offload_dec(struct tcf_block *block, u32 *flags) >>> if (!(*flags & TCA_CLS_FLAGS_IN_HW)) >>> return; >>> *flags &= ~TCA_CLS_FLAGS_IN_HW; >>> + if (tc_skip_sw(*flags)) >>> + atomic_dec(&block->skipswcnt); >>> atomic_dec(&block->offloadcnt); >>> } >>> >>> -- >>> 2.43.0 >>>
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index 934fdb977551..46a63d1818a0 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h @@ -476,6 +476,7 @@ struct tcf_block { struct flow_block flow_block; struct list_head owner_list; bool keep_dst; + atomic_t skipswcnt; /* Number of skip_sw filters */ atomic_t offloadcnt; /* Number of oddloaded filters */ unsigned int nooffloaddevcnt; /* Number of devs unable to do offload */ unsigned int lockeddevcnt; /* Number of devs that require rtnl lock. */ diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index ca5676b2668e..397c3d29659c 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -3483,6 +3483,8 @@ static void tcf_block_offload_inc(struct tcf_block *block, u32 *flags) if (*flags & TCA_CLS_FLAGS_IN_HW) return; *flags |= TCA_CLS_FLAGS_IN_HW; + if (tc_skip_sw(*flags)) + atomic_inc(&block->skipswcnt); atomic_inc(&block->offloadcnt); } @@ -3491,6 +3493,8 @@ static void tcf_block_offload_dec(struct tcf_block *block, u32 *flags) if (!(*flags & TCA_CLS_FLAGS_IN_HW)) return; *flags &= ~TCA_CLS_FLAGS_IN_HW; + if (tc_skip_sw(*flags)) + atomic_dec(&block->skipswcnt); atomic_dec(&block->offloadcnt); }