From patchwork Wed Sep 4 00:34:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13789524 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-oo1-f43.google.com (mail-oo1-f43.google.com [209.85.161.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 955D6646 for ; Wed, 4 Sep 2024 00:35:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725410118; cv=none; b=CVcpJauRPtqd08ErV+qHvtX9gbaFvci8ED51+/mXQyup+WpiKJN1oAbkI2gY3gVnu8TMiZHnhUYfQDuw9Hp7w0z47DhLqo4uhXHPRobB/21s2cbRKsHyQmhnyw3qnQZ5CHT8SIznNzFDGSxlV4xHhDjwd++8bjJa4f3GMaa8h50= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725410118; c=relaxed/simple; bh=Ilk/r3EqQMJreOmj91JPQuwrxQIJ/C1rFi8Z1C5hXug=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Trbvm7SlxwNr0dKSYPBgp2AL6EgYiyltB+MqRPvj4GProgr297bfoh8aNSbrVF3fGX0rL1OxkAB/IqjuMMk6J04E7Uey9czFtpvHU5I7WwwkFoLJtTXxu6mk6lpItsFkd0GPOK8WGDeS7tkp+j3l0DHmXlQDkzvWcUyZzk64yMg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Pj6+Qr4a; arc=none smtp.client-ip=209.85.161.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Pj6+Qr4a" Received: by mail-oo1-f43.google.com with SMTP id 006d021491bc7-5dca9cc71b2so175844eaf.2 for ; Tue, 03 Sep 2024 17:35:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725410115; x=1726014915; darn=vger.kernel.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=YP+kyHfxNs79ILywdhtEjvX/1fKjka7Zb78lPonahLs=; b=Pj6+Qr4an4ceHaYg+nYI5cO9M6JinM4AGrhEvjDNESN27OTQFN/Fm3CgCBndO6AUfb G4fP+bczFARCe99+kZleviM/6AATulk3EI6AW8NmY9odyB6XcYPKdV40VUfLhCxKSq3F TKEfHxlBHikuktURaGsM93s7ivEtBGrNAKr6uLrB19tsGgP5pk/QKaGRlPouzu+lGTUU HqUC6QAsa4eGmFarGFl5sOlskrc9a6dnctRN1PDnqVLYsHbX+TXF993cNB38avxfMRFX wUe3hQiYAbLWaLvH7XzWkecFG45bXcbBs5wORtgN3yUILYsqk4ZdlTO697I0Cz4ZYTcy Yn8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725410115; x=1726014915; 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=YP+kyHfxNs79ILywdhtEjvX/1fKjka7Zb78lPonahLs=; b=XPSRdo78UzbL0yWhttqam4+uDz847bn13QqEup1L2AxkpjYh8OL4DbZLdiJgS0hQb4 XYRCQXDMicqUaRrYkWlKs0PmQu0bIsbv08vPHNxwdOngCjY796ohn8ejsqSDdWBjoDqA N19bl+KQIBDj740FU1Jzg2O4RtMCxy6SNDXfWV56/PStqeAElP/Xvp6bkjYl1hG292bk RoW161ugV57hcwSfdnStsvEJJ2iQsMiIu/jtH+PSqWariTXH4xplAoHSIugHYlZ2+Kru gGEJIF+6/L/N+/e3eHDH0pEm0NZGUNqzhR3XmlfY6FaNGnm+dU4WfbTiOQwX9YMm1y4n Nz4g== X-Gm-Message-State: AOJu0YzV9NX+87cgxpCGMM5pKQa2rQ850ttjdw2xg7zEIsQw33ZKUIv5 sNwMntNm7lXIV2SJ+IkEoPqxk67Dw8CZ7YBrHL8UPfIU6lk75d78awhokeoJ04P/3Q== X-Google-Smtp-Source: AGHT+IFNn2EceYt6pq6dnoO3LsKl/54/jki6skUFoG4ewHvjc22dQFTBWIXXcxEoFN+YivIL4A4mPQ== X-Received: by 2002:a05:6870:961d:b0:278:2316:8422 with SMTP id 586e51a60fabf-2782316dc23mr3645919fac.27.1725410115267; Tue, 03 Sep 2024 17:35:15 -0700 (PDT) Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71778589133sm444218b3a.109.2024.09.03.17.35.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 17:35:14 -0700 (PDT) From: Hangbin Liu To: netdev@vger.kernel.org Cc: Jay Vosburgh , Andy Gospodarek , "David S . Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , Nikolay Aleksandrov , Tariq Toukan , Jianbo Liu , Sabrina Dubroca , Simon Horman , Steffen Klassert , Hangbin Liu , Jay Vosburgh Subject: [PATCHv7 net-next 2/3] bonding: Add ESN support to IPSec HW offload Date: Wed, 4 Sep 2024 08:34:56 +0800 Message-ID: <20240904003457.3847086-3-liuhangbin@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240904003457.3847086-1-liuhangbin@gmail.com> References: <20240904003457.3847086-1-liuhangbin@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Currently, users can see that bonding supports IPSec HW offload via ethtool. However, this functionality does not work with NICs like Mellanox cards when ESN (Extended Sequence Numbers) is enabled, as ESN functions are not yet supported. This patch adds ESN support to the bonding IPSec device offload, ensuring proper functionality with NICs that support ESN. Reviewed-by: Nikolay Aleksandrov Acked-by: Jay Vosburgh Signed-off-by: Hangbin Liu --- drivers/net/bonding/bond_main.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 46f46fea9152..a6628b1f33a7 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -694,11 +694,36 @@ static bool bond_ipsec_offload_ok(struct sk_buff *skb, struct xfrm_state *xs) return ok; } +/** + * bond_advance_esn_state - ESN support for IPSec HW offload + * @xs: pointer to transformer state struct + **/ +static void bond_advance_esn_state(struct xfrm_state *xs) +{ + struct net_device *real_dev; + + rcu_read_lock(); + real_dev = bond_ipsec_dev(xs); + if (!real_dev) + goto out; + + if (!real_dev->xfrmdev_ops || + !real_dev->xfrmdev_ops->xdo_dev_state_advance_esn) { + pr_warn_ratelimited("%s: %s doesn't support xdo_dev_state_advance_esn\n", __func__, real_dev->name); + goto out; + } + + real_dev->xfrmdev_ops->xdo_dev_state_advance_esn(xs); +out: + rcu_read_unlock(); +} + static const struct xfrmdev_ops bond_xfrmdev_ops = { .xdo_dev_state_add = bond_ipsec_add_sa, .xdo_dev_state_delete = bond_ipsec_del_sa, .xdo_dev_state_free = bond_ipsec_free_sa, .xdo_dev_offload_ok = bond_ipsec_offload_ok, + .xdo_dev_state_advance_esn = bond_advance_esn_state, }; #endif /* CONFIG_XFRM_OFFLOAD */