From patchwork Mon Jun 19 05:05:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Mi X-Patchwork-Id: 1796311 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=PIEhkvy1; dkim-atps=neutral Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QkyR50cQdz20Wk for ; Mon, 19 Jun 2023 15:06:25 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 4748340528; Mon, 19 Jun 2023 05:06:23 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 4748340528 Authentication-Results: smtp2.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=PIEhkvy1 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uElnMzlohoRo; Mon, 19 Jun 2023 05:06:22 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id 5A7A0404C2; Mon, 19 Jun 2023 05:06:21 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 5A7A0404C2 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 2AA0BC007A; Mon, 19 Jun 2023 05:06:21 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 7E5C1C0029 for ; Mon, 19 Jun 2023 05:06:20 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 70505415E6 for ; Mon, 19 Jun 2023 05:06:18 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 70505415E6 Authentication-Results: smtp4.osuosl.org; dkim=pass (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=PIEhkvy1 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9dZ8IW0-fTA0 for ; Mon, 19 Jun 2023 05:06:17 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 35F624160F Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2062d.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eab::62d]) by smtp4.osuosl.org (Postfix) with ESMTPS id 35F624160F for ; Mon, 19 Jun 2023 05:06:17 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RG9TEH6K/jLqzXx7PVEn0Vd9CYL90ucRpLz9FoF33XjV5elFneb4kEfGWmmBkEi/304aOin8/74eCwAshJv7vDs63KF7mnk6MlFAMg2QdZMCzLM2VgbaUnpdNK004ZYxghN4Znwr0aSEAyQPgqxZrONpb/Bm74JApCMcUPkqKlluE7ClNTmvOncy6R98n8jHY59jo7K4ypvSabAv10hFjPjdjBDX5jh9FqLCsmNFqNKRWGXIvfb1F0i4CCsKXBgE77rXpt70crGQ/1s0DHoU/EcyczaVKOHj2pYG+9LcoB6kFdXPzg4soqPPVIgr79TB8HrxoDF951uneLV4MvegaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=eo6HWp+kXlXk46W30de3ve8rjPXSXif89pFW/3qvQRk=; b=R9mRUNV16NfLGAa8lGAfstUZVd6NpUVbnunzV5mFO/EaVSiTnj62cRSbuYIdcI9VsDOXLntJAPJtcVhVDgIxLNii3EYsWcS5+/lhdI7mS0+XgwfW751ncP13L6ckSRU0y5e99Z2Il6mA3hwJMKXo3oDNNXCFeLPJ5VUqFtG/lO1RK4smXIIoNqZFfb+6FH4r17WTVszBgh+yCgurU0fwwP03aqODjt24Q8vK+Sd/m6ro0bO4LxCN3M4kiKOlzwWbZTmeA1iW69e+TB4GgY6yZN7EjNVuYzCeoZcB1HRpPrvb2rSCSaLLgEyI+aJlIo9MxNl5hMiLOvUMTgw8AJ4EyA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=openvswitch.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eo6HWp+kXlXk46W30de3ve8rjPXSXif89pFW/3qvQRk=; b=PIEhkvy1hhKyhUDAyXxYfbiVDP+qw82oyQJ632AcDI+mvLNY90+eu9zThSK4quA0fLxcbhqqESXCKGJus0U3ob7zgNg8BDQK3hWi2c2Iob8Qw2uCwFTgRvjhn3yFZeW8d+MHSh5AbmmiTtZR+plzrMgVayWSdelYqi7M+VXHDEmqP6FpU6sVnmNBBdMAvtHrgzs0L5+mrtufVlDaadOo+UtmNKX9ve0dKPPMu7tcVWlo2bZddrl52wb1yokLyiLwqiny33SoQ08G51jMULAcDR2CjAWXilBazHHsKUkDSiJ2bRGH2xY6QCznEgMqEnduJEsMK1mOiTlv4wZtxuYTMg== Received: from DM6PR06CA0038.namprd06.prod.outlook.com (2603:10b6:5:54::15) by DM4PR12MB6160.namprd12.prod.outlook.com (2603:10b6:8:a7::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.35; Mon, 19 Jun 2023 05:06:11 +0000 Received: from DM6NAM11FT034.eop-nam11.prod.protection.outlook.com (2603:10b6:5:54:cafe::82) by DM6PR06CA0038.outlook.office365.com (2603:10b6:5:54::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.36 via Frontend Transport; Mon, 19 Jun 2023 05:06:11 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by DM6NAM11FT034.mail.protection.outlook.com (10.13.173.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.36 via Frontend Transport; Mon, 19 Jun 2023 05:06:10 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Sun, 18 Jun 2023 22:06:06 -0700 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Sun, 18 Jun 2023 22:06:06 -0700 Received: from c-237-115-160-164.mtl.labs.mlnx (10.127.8.13) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Sun, 18 Jun 2023 22:06:03 -0700 To: Date: Mon, 19 Jun 2023 08:05:50 +0300 Message-ID: <20230619050557.310690-2-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230619050557.310690-1-cmi@nvidia.com> References: <20230619050557.310690-1-cmi@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT034:EE_|DM4PR12MB6160:EE_ X-MS-Office365-Filtering-Correlation-Id: 598bc3ce-a00f-4cc2-7d1f-08db7082e60f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 89Ajiax5ZmmvS5SlXhPkPoWxtamHpbvjweYsfR7ZeMklnhtFsEDa/PhmvKSfzSmlAIBXIOvt8TDACvRKr2210dUbB4gSE/NhyVybLCS55E3aacgloc5I2ZqdolD7q1tV7GCYZN7YpTV0bQVmDb7+/GzadIfLW6bNBdpkBmdCvDoEy52hAUTqTvWdIZCGQ/XcDBAx8a3TTCfJGJQnC3f/pKKX1ztEoxRfIE1L1u93CWL2rxem9P0g/U+H8OtRoXteqLHpool0aoIl+4SixwKncY7HgxbqzODuwCyP989yVqU++XI7eqSS7OOUb4ztUHdjEJmyTew7pnUprb+6Ed70NMi4UM2zRyMdFzR5HKVVbCRAEVtILvu0RCRw20jM/AchAfnPzGiVm21buJTDlTAlkoDisd6Trk19lGG/haa4bZspcUK3yL2M8gGX7kw35a0TKZpLTykQiHkcGNBJGSZ1A7QTYcc6iSNpXU0VV7Q1m1kui2iHaZ/AXyeEmFbddGT1bkViAlBxV67VXJk2Depqu9PtXk/Ywi4nw/jXD56vjrFxtaXuKVddpADsUglk8tDKFFTjMkI1RnvORPu9GqGCNFpXUqu7hYGhO5eaX2LWMBsQ5/qFrY2bKkbgg7oW5kOh0iGm73QPO4R2xNvc901M/KAI1+AlDSk9Ql1SYQOmcb2kb0G3pAD8ZPCJOivHnUvpSYTS5ecl2xBP2s4fqcWWdG8gnMHSKxTxUYHgz9G5t18= X-Forefront-Antispam-Report: CIP:216.228.118.233; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge2.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(346002)(396003)(136003)(376002)(451199021)(40470700004)(36840700001)(46966006)(6666004)(40460700003)(86362001)(2906002)(478600001)(107886003)(1076003)(36756003)(82310400005)(316002)(6916009)(70586007)(70206006)(5660300002)(8936002)(8676002)(41300700001)(40480700001)(54906003)(4326008)(47076005)(2616005)(82740400003)(83380400001)(426003)(336012)(356005)(7636003)(36860700001)(186003)(26005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2023 05:06:10.9485 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 598bc3ce-a00f-4cc2-7d1f-08db7082e60f X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.233]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT034.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6160 Cc: elibr@nvidia.com, simon.horman@corigine.com, roniba@nvidia.com, i.maximets@ovn.org, konguyen@redhat.com, majd@nvidia.com, maord@nvidia.com Subject: [ovs-dev] [PATCH v28 1/8] compat: Add psample and tc sample action defines for older kernels X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Chris Mi via dev From: Chris Mi Reply-To: Chris Mi Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Update kernel UAPI to support psample and the tc sample action. Signed-off-by: Chris Mi Reviewed-by: Roi Dayan Acked-by: Eelco Chaudron --- include/linux/automake.mk | 10 +++--- include/linux/psample.h | 62 ++++++++++++++++++++++++++++++++ include/linux/tc_act/tc_sample.h | 25 +++++++++++++ 3 files changed, 93 insertions(+), 4 deletions(-) create mode 100644 include/linux/psample.h create mode 100644 include/linux/tc_act/tc_sample.h diff --git a/include/linux/automake.mk b/include/linux/automake.mk index cdae5eedc..a397562c0 100644 --- a/include/linux/automake.mk +++ b/include/linux/automake.mk @@ -1,12 +1,14 @@ noinst_HEADERS += \ - include/linux/netlink.h \ + include/linux/gen_stats.h \ include/linux/netfilter/nf_conntrack_sctp.h \ + include/linux/netlink.h \ include/linux/openvswitch.h \ include/linux/pkt_cls.h \ - include/linux/gen_stats.h \ + include/linux/psample.h \ + include/linux/tc_act/tc_ct.h \ include/linux/tc_act/tc_mpls.h \ include/linux/tc_act/tc_pedit.h \ + include/linux/tc_act/tc_sample.h \ include/linux/tc_act/tc_skbedit.h \ include/linux/tc_act/tc_tunnel_key.h \ - include/linux/tc_act/tc_vlan.h \ - include/linux/tc_act/tc_ct.h + include/linux/tc_act/tc_vlan.h diff --git a/include/linux/psample.h b/include/linux/psample.h new file mode 100644 index 000000000..e585db5bf --- /dev/null +++ b/include/linux/psample.h @@ -0,0 +1,62 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __UAPI_PSAMPLE_H +#define __UAPI_PSAMPLE_H + +enum { + PSAMPLE_ATTR_IIFINDEX, + PSAMPLE_ATTR_OIFINDEX, + PSAMPLE_ATTR_ORIGSIZE, + PSAMPLE_ATTR_SAMPLE_GROUP, + PSAMPLE_ATTR_GROUP_SEQ, + PSAMPLE_ATTR_SAMPLE_RATE, + PSAMPLE_ATTR_DATA, + PSAMPLE_ATTR_GROUP_REFCOUNT, + PSAMPLE_ATTR_TUNNEL, + + PSAMPLE_ATTR_PAD, + PSAMPLE_ATTR_OUT_TC, /* u16 */ + PSAMPLE_ATTR_OUT_TC_OCC, /* u64, bytes */ + PSAMPLE_ATTR_LATENCY, /* u64, nanoseconds */ + PSAMPLE_ATTR_TIMESTAMP, /* u64, nanoseconds */ + PSAMPLE_ATTR_PROTO, /* u16 */ + + __PSAMPLE_ATTR_MAX +}; + +enum psample_command { + PSAMPLE_CMD_SAMPLE, + PSAMPLE_CMD_GET_GROUP, + PSAMPLE_CMD_NEW_GROUP, + PSAMPLE_CMD_DEL_GROUP, +}; + +enum psample_tunnel_key_attr { + PSAMPLE_TUNNEL_KEY_ATTR_ID, /* be64 Tunnel ID */ + PSAMPLE_TUNNEL_KEY_ATTR_IPV4_SRC, /* be32 src IP address. */ + PSAMPLE_TUNNEL_KEY_ATTR_IPV4_DST, /* be32 dst IP address. */ + PSAMPLE_TUNNEL_KEY_ATTR_TOS, /* u8 Tunnel IP ToS. */ + PSAMPLE_TUNNEL_KEY_ATTR_TTL, /* u8 Tunnel IP TTL. */ + PSAMPLE_TUNNEL_KEY_ATTR_DONT_FRAGMENT, /* No argument, set DF. */ + PSAMPLE_TUNNEL_KEY_ATTR_CSUM, /* No argument. CSUM packet. */ + PSAMPLE_TUNNEL_KEY_ATTR_OAM, /* No argument. OAM frame. */ + PSAMPLE_TUNNEL_KEY_ATTR_GENEVE_OPTS, /* Array of Geneve options. */ + PSAMPLE_TUNNEL_KEY_ATTR_TP_SRC, /* be16 src Transport Port. */ + PSAMPLE_TUNNEL_KEY_ATTR_TP_DST, /* be16 dst Transport Port. */ + PSAMPLE_TUNNEL_KEY_ATTR_VXLAN_OPTS, /* Nested VXLAN opts* */ + PSAMPLE_TUNNEL_KEY_ATTR_IPV6_SRC, /* struct in6_addr src IPv6 address. */ + PSAMPLE_TUNNEL_KEY_ATTR_IPV6_DST, /* struct in6_addr dst IPv6 address. */ + PSAMPLE_TUNNEL_KEY_ATTR_PAD, + PSAMPLE_TUNNEL_KEY_ATTR_ERSPAN_OPTS, /* struct erspan_metadata */ + PSAMPLE_TUNNEL_KEY_ATTR_IPV4_INFO_BRIDGE, /* No argument. IPV4_INFO_BRIDGE mode.*/ + __PSAMPLE_TUNNEL_KEY_ATTR_MAX +}; + +/* Can be overridden at runtime by module option */ +#define PSAMPLE_ATTR_MAX (__PSAMPLE_ATTR_MAX - 1) + +#define PSAMPLE_NL_MCGRP_CONFIG_NAME "config" +#define PSAMPLE_NL_MCGRP_SAMPLE_NAME "packets" +#define PSAMPLE_GENL_NAME "psample" +#define PSAMPLE_GENL_VERSION 1 + +#endif diff --git a/include/linux/tc_act/tc_sample.h b/include/linux/tc_act/tc_sample.h new file mode 100644 index 000000000..fee1bcc20 --- /dev/null +++ b/include/linux/tc_act/tc_sample.h @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __LINUX_TC_SAMPLE_H +#define __LINUX_TC_SAMPLE_H + +#include +#include +#include + +struct tc_sample { + tc_gen; +}; + +enum { + TCA_SAMPLE_UNSPEC, + TCA_SAMPLE_TM, + TCA_SAMPLE_PARMS, + TCA_SAMPLE_RATE, + TCA_SAMPLE_TRUNC_SIZE, + TCA_SAMPLE_PSAMPLE_GROUP, + TCA_SAMPLE_PAD, + __TCA_SAMPLE_MAX +}; +#define TCA_SAMPLE_MAX (__TCA_SAMPLE_MAX - 1) + +#endif From patchwork Mon Jun 19 05:05:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Mi X-Patchwork-Id: 1796312 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=XpSP+W/R; dkim-atps=neutral Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QkyR76R63z20Wk for ; Mon, 19 Jun 2023 15:06:27 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 19C1081FE7; Mon, 19 Jun 2023 05:06:26 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 19C1081FE7 Authentication-Results: smtp1.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=XpSP+W/R X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PsSjQCKbgHli; Mon, 19 Jun 2023 05:06:25 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 21D3581FBE; Mon, 19 Jun 2023 05:06:24 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 21D3581FBE Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id E9A3FC0088; Mon, 19 Jun 2023 05:06:23 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 99F71C0029 for ; Mon, 19 Jun 2023 05:06:21 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id CB8E360FB5 for ; Mon, 19 Jun 2023 05:06:19 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org CB8E360FB5 Authentication-Results: smtp3.osuosl.org; dkim=pass (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=XpSP+W/R X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sNsO7YFCi0QA for ; Mon, 19 Jun 2023 05:06:18 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 6772660B2E Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2060e.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5a::60e]) by smtp3.osuosl.org (Postfix) with ESMTPS id 6772660B2E for ; Mon, 19 Jun 2023 05:06:18 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iyPdCjvbXfCdaJ9kxzJiugJneF548NMxNiVZOuBGPwXxLE/wSNG/7PIpkWiZZeFbzLvJywMV3CGYlE/7LbAIOC3MTg22JtZinFCOU4LuYwY37VcZaMcRfUsTac3KiXwo/cPNerN39JQEVrOYmC4JvlvU4Yd3g4fi/NMCbyKOjdiWbkmrCXMHgPwY0InTN8df48uDWM9MgRRP1Lg8HauR1+3WEuHxzZZsP7AFVhTiGzTxo0O1lOfnzNDpMh7uEwANF7f4rxxvNtxFRYgzCZNFSddI8FN+QWX6eyg018PhTy/WrUc1SNKvUnWRWDuPnVVUlNY6mw72MB7LziDPysHFYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ol/bVZ/jkiZTV5fMK4ElSYc14fs0ViONNZedP3kh02U=; b=hM1IrK+LZIYCKzOXWf7zue4fUZgX9bhn14BrA2Cj6Sx3q2LLPGpUhzhRsuFoRpKpJCI3qt8Lcp9TZh3dyxv6MfOFFW/1wQLLWvfZjEH9O2LfGDg/9A+P/+jC7P4c9vPAcO9nZlpJDHF59HFMTS6Ap8CFTpS+Gyy/PvOrdRpsWEmqRkGQdEu6W889DD9HSLac5nBCuU0R3egjqwV0L09X7SdK/rdzgwVyIlIrLD3GzIB4wiqfs8daZNakZpptHRdmvSiTCykd9yjI71WQq57TV7k6qPSjBknHu3OgN0N5nIhbXo9V/EBJRJ8TeXwirw4YI/KE04flPYaCLvc9QNHsAw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=openvswitch.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ol/bVZ/jkiZTV5fMK4ElSYc14fs0ViONNZedP3kh02U=; b=XpSP+W/RwiOMXr5MABm8bL1TUCNbW3LX1cLGpSwOfIIx5VNSiJkBRSIjR0MQi6Grvqv5NNWgoIlvPzzol08os1jBrGtAwtYHe5D1X+cTM5guru7iou0WB9FRGhzTdealrSLwyhTahKf2ondUPEHlGQjJMweGwgJ8NaGRiDSG9z6gcE5qqzxh1xFLlAN7uY9VKLrl1b+Z5857y2Y4thWvlKcAcizyzh6Vjl2LhPqZZhTEkPEvgNBcq8/4g3Y9/OYbGWImUyuuAvLOeCEaAbEw46DDrhdlp79ce4l1XH9mJpOabM+PkWdud8EsCcyn335LiBi69YQiCmcjYWb8acEQrQ== Received: from BN0PR04CA0037.namprd04.prod.outlook.com (2603:10b6:408:e8::12) by MN2PR12MB4206.namprd12.prod.outlook.com (2603:10b6:208:1d5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.36; Mon, 19 Jun 2023 05:06:15 +0000 Received: from BN8NAM11FT037.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e8:cafe::26) by BN0PR04CA0037.outlook.office365.com (2603:10b6:408:e8::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.36 via Frontend Transport; Mon, 19 Jun 2023 05:06:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by BN8NAM11FT037.mail.protection.outlook.com (10.13.177.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.36 via Frontend Transport; Mon, 19 Jun 2023 05:06:15 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Sun, 18 Jun 2023 22:06:10 -0700 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Sun, 18 Jun 2023 22:06:09 -0700 Received: from c-237-115-160-164.mtl.labs.mlnx (10.127.8.13) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Sun, 18 Jun 2023 22:06:06 -0700 To: Date: Mon, 19 Jun 2023 08:05:51 +0300 Message-ID: <20230619050557.310690-3-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230619050557.310690-1-cmi@nvidia.com> References: <20230619050557.310690-1-cmi@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT037:EE_|MN2PR12MB4206:EE_ X-MS-Office365-Filtering-Correlation-Id: ce245411-3ef6-4356-3b87-08db7082e8ce X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8B4LRCKDKREkZgSa4HMs9QbdbFtYhpQTkeQNhygb+OSsjA7+duWBaj1f1A26ZO+8QlmbvJMYQcTACvBPQ8y3yXg8eIaRGvyoi04VgiKeHupLD1eIsWVeAIEsdzmu7q2vf8Qd3ECcWWuEFyJfuIqvUPKept3Xdftynys89DecGiN/8D7VjF51Tb40XBHZ1HTcfszV7Oomggrs9duIypc1ptRVTrPqbD2wFxhgiDFTmLisGsHTuOSkbulx2Uoa+/Wdx4aHpZzk5oHlm/ConCRWti3JO53YAvn6PiwBTv6h0zEpIBsDIP38M4e7+vB40k1124AQJM5DtyWw81DN6c+80GKV80ndi8JKWQ5qUJaYsYt/HUTMxXCH0Ucu2QIlhjsRUN7HsU1ZjWJlgSbXWQhPnjt6dnFJv55tXaWZmFAoh6GLSQnjv5U9DF/60gS2+AIEUbr9blBeAi1X3X2GZOKi8kEdzVcc/cwCgW/xgyLydo7ReyjecPqw9clfBMrsvISs86t09UFeFl/Bbv8IxVHDjSTbtVs1HoKrI7uxn7+AF+fDvSARghpvGkJUm/BxYqXQMWNlJDko9suJMyhuHqgYO+4PwZAiiau8yRHAZieS+x2f/ksy6jZFTGDBd9v3uanwhRr+kRFXMYTbq7tXtP6JW8nn9LFgiqn/+xjrPTmg6PNpVVj9x3lFSdOrtoP6CdvTf2xAsNjnguS7enl3qczdC/6tn2YwIxvu2gSgB8tsjEFuMHv/CSo+MAc+rmPZfBoe X-Forefront-Antispam-Report: CIP:216.228.118.232; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge1.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(136003)(346002)(376002)(396003)(39860400002)(451199021)(46966006)(40470700004)(36840700001)(41300700001)(70586007)(70206006)(6916009)(4326008)(82310400005)(316002)(2906002)(40460700003)(40480700001)(8936002)(8676002)(5660300002)(186003)(107886003)(26005)(1076003)(47076005)(83380400001)(36860700001)(2616005)(336012)(426003)(54906003)(478600001)(7636003)(356005)(82740400003)(6666004)(36756003)(86362001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2023 05:06:15.3665 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ce245411-3ef6-4356-3b87-08db7082e8ce X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.232]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT037.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4206 Cc: elibr@nvidia.com, simon.horman@corigine.com, roniba@nvidia.com, i.maximets@ovn.org, konguyen@redhat.com, majd@nvidia.com, maord@nvidia.com Subject: [ovs-dev] [PATCH v28 2/8] ovs-kmod-ctl: Load kernel module psample X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Chris Mi via dev From: Chris Mi Reply-To: Chris Mi Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Load kernel module psample to receive sampled packets from TC. Before removing kernel module psample, remove act_sample first. Signed-off-by: Chris Mi Reviewed-by: Roi Dayan Acked-by: Eelco Chaudron --- utilities/ovs-kmod-ctl.in | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/utilities/ovs-kmod-ctl.in b/utilities/ovs-kmod-ctl.in index 19f100964..6fa945a83 100644 --- a/utilities/ovs-kmod-ctl.in +++ b/utilities/ovs-kmod-ctl.in @@ -28,6 +28,14 @@ for dir in "$sbindir" "$bindir" /sbin /bin /usr/sbin /usr/bin; do done insert_mods () { + # Try loading psample kernel module. + modinfo psample > /dev/null 2>&1 + if test $? = 0; then + action "Inserting psample module" modprobe psample + else + log_warning_msg "No psample module, can't offload sFlow action" + fi + # Try loading openvswitch kernel module. action "Inserting openvswitch module" modprobe openvswitch } @@ -95,6 +103,12 @@ remove_kmods() { if test -e /sys/module/vxlan; then action "Forcing removal of vxlan module" rmmod vxlan fi + if test -e /sys/module/act_sample; then + action "Forcing removal of act_sample module" rmmod act_sample + fi + if test -e /sys/module/psample; then + action "Forcing removal of psample module" rmmod psample + fi } usage () { From patchwork Mon Jun 19 05:05:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Mi X-Patchwork-Id: 1796313 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=GQeEZ+lZ; dkim-atps=neutral Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QkyRF25J1z20Wk for ; Mon, 19 Jun 2023 15:06:33 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 2AB9E6112C; Mon, 19 Jun 2023 05:06:30 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 2AB9E6112C Authentication-Results: smtp3.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=GQeEZ+lZ X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id V9-wvx_tfOrU; Mon, 19 Jun 2023 05:06:28 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 4278360EFE; Mon, 19 Jun 2023 05:06:27 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 4278360EFE Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0E22EC008C; Mon, 19 Jun 2023 05:06:27 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 33098C0088 for ; Mon, 19 Jun 2023 05:06:26 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 91C9E416A4 for ; Mon, 19 Jun 2023 05:06:25 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 91C9E416A4 Authentication-Results: smtp4.osuosl.org; dkim=pass (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=GQeEZ+lZ X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id r4GIAwbBGM58 for ; Mon, 19 Jun 2023 05:06:24 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org E743141607 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on20613.outbound.protection.outlook.com [IPv6:2a01:111:f400:7ea9::613]) by smtp4.osuosl.org (Postfix) with ESMTPS id E743141607 for ; Mon, 19 Jun 2023 05:06:23 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RhxHZ4CqQ/OHa41B2349npDABhc10cF9DElGrmMyQPx7B8oM7LJ1+rpVAO+WEbxwUgm3ZGQzfaKL7DwjGXny5XpX5U4XSsCjirLu0hpI4QVSxJ/H3ExkV26958aLgYB2FVN3X+MfB7bnkV3lO7wWNDYtOpbPziJ+foUbSB2p1gm/K2JtT6UVJR0R4E6pX3kMXdiP7jgJdCYmTls6E0oxpWVTg6J5aagZ/lVTnyXLM6rab1k70VCE7GVlVpW2vchzlbGgt2s2/w9tjhAtv22haIWv6ib8Vjdp6B2mHg6JsN5kMTpg7xQteR4fyalKCd/woZKSTQLrHBVGLvHhT3rApg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=phLdLTXf6liHFdVRYlykiw4rurqUWkbpwRmLS5KeSiw=; b=mp+06qIrJyEFtBDxVx+oQc6vncf/6D71pncHmW2ABVex0fU9DV0dYqt/sF7qD/ydSaztRLskILBNDccZb5baqXpiov6W9bF1khErzY41GRjw9ElGBJlcFwqimKCT1hIK21OeaNkhoZM1vWCajvIHKYkwTfdNz1dKo+ocgLNvZoBS4RTQ1XVnS45r2ZMkYTBVpI9SuF0hWY6GGVM2YkhL0udVLw1wgJDSIqAxwchWhLRDJ0zSD1VpH6fF/X3biof1kQOL4hkgIkbVhaiL6SPWOKqLBeSTGFha/HZZvtCMSIBGfE/HBlNc6JmiGh661Krj+97WtAuqFDwZAgiq2diJlA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=openvswitch.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=phLdLTXf6liHFdVRYlykiw4rurqUWkbpwRmLS5KeSiw=; b=GQeEZ+lZ6IPlGsJ7pvAG0BppPYd1fsa1kKuH455MI3dt9IcAX/snWTw3KOVqtRygDHO2aTJCeQetG2tI9fdQF6/f/FDY1DKu3iQxHq2VPsAo9Tm6qwG/3ovDyYVyX0tP4FkkFHv0rr4gbOVCI4pIAOTQe5SaUxNjJ1VwwwQoexbnL/yYJPikL0p20N3toLoSsKy23IKhzb7XazMindDOhN0uyZ19yyRce9Siu4HhBTwEJ9Opk2uAQp93moaWOsidaQi+k65NUnvKwXEIadQmSB8EYnqgjLgAucM+g7tSceTx/ypyShdADYu/r/B+9hBQe66kAbdX4TZqaiFwyXPW6g== Received: from DS7PR05CA0026.namprd05.prod.outlook.com (2603:10b6:5:3b9::31) by CH0PR12MB5153.namprd12.prod.outlook.com (2603:10b6:610:b8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.36; Mon, 19 Jun 2023 05:06:21 +0000 Received: from DM6NAM11FT077.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b9:cafe::ed) by DS7PR05CA0026.outlook.office365.com (2603:10b6:5:3b9::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.21 via Frontend Transport; Mon, 19 Jun 2023 05:06:21 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by DM6NAM11FT077.mail.protection.outlook.com (10.13.173.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.29 via Frontend Transport; Mon, 19 Jun 2023 05:06:20 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Sun, 18 Jun 2023 22:06:13 -0700 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Sun, 18 Jun 2023 22:06:13 -0700 Received: from c-237-115-160-164.mtl.labs.mlnx (10.127.8.13) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Sun, 18 Jun 2023 22:06:10 -0700 To: Date: Mon, 19 Jun 2023 08:05:52 +0300 Message-ID: <20230619050557.310690-4-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230619050557.310690-1-cmi@nvidia.com> References: <20230619050557.310690-1-cmi@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT077:EE_|CH0PR12MB5153:EE_ X-MS-Office365-Filtering-Correlation-Id: e03579e0-94e7-47ff-9acf-08db7082ebfc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gYvg3Ddc5X2jghNHGsegEiO6AmkwtixcfHh7LSsuyyVPtaEX11+CmzwWRoO3Xr1ogAo/W7uniZ878NTHA5qbzwsks/HA2g4bqCsHQ8wKf9/loZqOT+02mEH7NHjbyO91AY6c2pXBnE3NV2dRztB/baPjWMJx3l/76ZYf6dggZ9OOji334CesEmilEueMMU8XrHg0qff9DEYCyhTvLGHnzxjsYBivCEpkBi+DAB7/AjnSFmyHC241dPxKiLsXpeP2PgvvvLtxzTjbdrKz/zKIv8OCq+fC7JV2fgvfI2pHyuksg6B4nZCP03NKyQVzBWLp6h16jaJajWfEFM8KzzvZmqJwCBGYbZl/LvgN+g3vuce1UeZgQYV2tLs9cSO259lG9S3suCtgWp8Ih4v4JO/4I7ooC8HJY/7chrRKjsxvWiY8Vn5znKK4dUIIGB9ikR5W+fZSiZWyT+d91DUQH1mU0sWmwTuFdu6Qo988zQh3m3cpIuL+Juzs630mlHoEcQ8annT4uAyS7vl8sIk8fpSaENOu+4fBpHgGZmDEnk8bkuPN97iaUtOF+i9pZjMqolwwlGy9l6T60pPcM05KtrH1e0F9Tx4QgnQruUrV7DXp+81ftQUFY1gscrx3B026o7htE6/37KMHyNJi2agGbV44zo4+LmkA3MIlTUKO0Lv5tE7KfyXIFkS83ApHo1rb9wK3bptrjHlz7ObWlWlRFwvXRsoQ0H5r6kv9YXnA4O64xuMzQdch6Uw1PngSzfzDhEGS X-Forefront-Antispam-Report: CIP:216.228.118.233; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge2.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(136003)(346002)(39860400002)(376002)(396003)(451199021)(40470700004)(36840700001)(46966006)(186003)(70586007)(70206006)(8676002)(8936002)(82740400003)(5660300002)(54906003)(40460700003)(4326008)(6666004)(316002)(478600001)(41300700001)(36756003)(26005)(1076003)(6916009)(40480700001)(82310400005)(107886003)(426003)(336012)(356005)(47076005)(86362001)(2906002)(83380400001)(7636003)(36860700001)(2616005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2023 05:06:20.8910 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e03579e0-94e7-47ff-9acf-08db7082ebfc X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.233]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT077.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5153 Cc: elibr@nvidia.com, simon.horman@corigine.com, roniba@nvidia.com, i.maximets@ovn.org, konguyen@redhat.com, majd@nvidia.com, maord@nvidia.com Subject: [ovs-dev] [PATCH v28 3/8] netdev-offload-tc: Introduce group ID management API X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Chris Mi via dev From: Chris Mi Reply-To: Chris Mi Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" When offloading sample action to TC, userspace creates a unique ID to map sample action and tunnel info and passes this ID to kernel instead of the sample info. Kernel will send this ID and sampled packet to userspace. Using the ID, userspace can recover the sample info and send sampled packet to the right sample monitoring host. Signed-off-by: Chris Mi Reviewed-by: Roi Dayan Acked-by: Eelco Chaudron --- lib/netdev-offload-tc.c | 156 +++++++++++++++++++++++++++++++++++++--- lib/util.c | 6 ++ lib/util.h | 1 + 3 files changed, 154 insertions(+), 9 deletions(-) diff --git a/lib/netdev-offload-tc.c b/lib/netdev-offload-tc.c index 4f26dd8cc..56726acf8 100644 --- a/lib/netdev-offload-tc.c +++ b/lib/netdev-offload-tc.c @@ -19,28 +19,29 @@ #include #include +#include "cmap.h" +#include "dpif-provider.h" #include "dpif.h" #include "hash.h" #include "id-pool.h" -#include "openvswitch/hmap.h" -#include "openvswitch/match.h" -#include "openvswitch/ofpbuf.h" -#include "openvswitch/thread.h" -#include "openvswitch/types.h" -#include "openvswitch/util.h" -#include "openvswitch/vlog.h" #include "netdev-linux.h" #include "netdev-offload-provider.h" #include "netdev-provider.h" #include "netdev-vport.h" -#include "netlink.h" #include "netlink-socket.h" +#include "netlink.h" #include "odp-netlink.h" #include "odp-util.h" +#include "openvswitch/hmap.h" +#include "openvswitch/match.h" +#include "openvswitch/ofpbuf.h" +#include "openvswitch/thread.h" +#include "openvswitch/types.h" +#include "openvswitch/util.h" +#include "openvswitch/vlog.h" #include "tc.h" #include "unaligned.h" #include "util.h" -#include "dpif-provider.h" VLOG_DEFINE_THIS_MODULE(netdev_offload_tc); @@ -103,6 +104,125 @@ static void parse_tc_flower_to_stats(struct tc_flower *flower, static int get_ufid_adjust_stats(const ovs_u128 *ufid, struct dpif_flow_stats *stats); +/* When offloading sample action to TC, userspace creates a unique ID + * to map sample action and tunnel info and passes this ID to kernel + * instead of the sample info. Kernel will send this ID and sampled + * packet to userspace. Using the ID, userspace can recover the sample + * info and send sampled packet to the right sample monitoring host. */ +struct offload_sample { + uint16_t type; /* enum user_action_cookie_type. */ + struct nlattr *action; /* Sample action. Used in flow_get. */ + struct nlattr *userdata; /* Struct user_action_cookie. */ + struct nlattr *userspace_actions; /* All actions to get output tunnel. */ + struct flow_tnl *tunnel; /* Input tunnel. */ + uint16_t ifindex; /* Input ifindex. */ +}; + +/* This maps a sample group ID to struct offload_sample. */ +struct sgid_node { + struct cmap_node id_node; + uint32_t id; + struct offload_sample sample; +}; + +/* The sgid_map mutex protects the sample_group_ids and the sgid_map for + * cmap_insert(), cmap_remove(), or cmap_replace() operations. */ +static struct ovs_mutex sgid_lock = OVS_MUTEX_INITIALIZER; +static struct cmap sgid_map = CMAP_INITIALIZER; +static struct id_pool *sample_group_ids OVS_GUARDED_BY(sgid_lock); + +static void +sgid_node_free(struct sgid_node *node) +{ + if (node) { + if (node->id) { + ovs_mutex_lock(&sgid_lock); + id_pool_free_id(sample_group_ids, node->id); + ovs_mutex_unlock(&sgid_lock); + } + free(node->sample.tunnel); + free(node->sample.action); + free(node->sample.userspace_actions); + free(node->sample.userdata); + free(node); + } +} + +static struct sgid_node * +sgid_find(uint32_t id) +{ + const struct cmap_node *node = cmap_find(&sgid_map, id); + + return node ? CONTAINER_OF(node, struct sgid_node, id_node) : NULL; +} + +static void +offload_sample_clone(struct offload_sample *dst, + const struct offload_sample *src, + bool steal_userspace_actions) +{ + dst->type = src->type; + dst->action = nullable_xmemdup(src->action, src->action ? + src->action->nla_len : 0); + if (steal_userspace_actions) { + dst->userspace_actions = src->userspace_actions; + } else { + dst->userspace_actions = src->userspace_actions + ? xmemdup(src->userspace_actions, + src->userspace_actions->nla_len) + : NULL; + } + dst->userdata = nullable_xmemdup(src->userdata, src->userdata ? + src->userdata->nla_len : + 0); + dst->tunnel = nullable_xmemdup(src->tunnel, sizeof *src->tunnel); + dst->ifindex = src->ifindex; +} + +/* Allocate a unique group id for the given set of flow metadata. The id + * space is 2^^32 - 1. 0 is reserved. */ +static uint32_t +sgid_alloc(const struct offload_sample *sample) +{ + struct sgid_node *node = xzalloc(sizeof *node); + + offload_sample_clone(&node->sample, sample, true); + + ovs_mutex_lock(&sgid_lock); + + if (id_pool_alloc_id(sample_group_ids, &node->id)) { + cmap_insert(&sgid_map, &node->id_node, node->id); + } else { + VLOG_ERR("Can't find a free sample group ID"); + sgid_node_free(node); + node = NULL; + } + + ovs_mutex_unlock(&sgid_lock); + + return node ? node->id : 0; +} + +static void +sgid_free(uint32_t id) +{ + struct sgid_node *node; + + if (!id) { + return; + } + + node = sgid_find(id); + if (node) { + ovs_mutex_lock(&sgid_lock); + cmap_remove(&sgid_map, &node->id_node, node->id); + ovs_mutex_unlock(&sgid_lock); + ovsrcu_postpone(sgid_node_free, node); + } else { + VLOG_ERR("Freeing nonexistent sample group ID: %"PRIu32, id); + } +} + static bool is_internal_port(const char *type) { @@ -192,12 +312,17 @@ static struct netlink_field set_flower_map[][4] = { static struct ovs_mutex ufid_lock = OVS_MUTEX_INITIALIZER; +#define MAX_TC_SAMPLES_PER_FLOW 1 + /** * struct ufid_tc_data - data entry for ufid-tc hashmaps. * @ufid_to_tc_node: Element in @ufid_to_tc hash table by ufid key. * @tc_to_ufid_node: Element in @tc_to_ufid hash table by tcf_id key. * @ufid: ufid assigned to the flow * @id: tc filter id (tcf_id) + * @sample_group_id: Mapping id for sample actions. Currently only supports + a single sFlow action. Use an array to support multiple + similar actions or additional sample types in the future. * @netdev: netdev associated with the tc rule * @adjust_stats: When flow gets updated with new actions, we need to adjust * the reported stats to include previous values as the hardware @@ -208,6 +333,7 @@ struct ufid_tc_data { struct hmap_node tc_to_ufid_node; ovs_u128 ufid; struct tcf_id id; + uint32_t sample_group_id[MAX_TC_SAMPLES_PER_FLOW]; struct netdev *netdev; struct dpif_flow_stats adjust_stats; }; @@ -231,6 +357,7 @@ del_ufid_tc_mapping_unlocked(const ovs_u128 *ufid) hmap_remove(&ufid_to_tc, &data->ufid_to_tc_node); hmap_remove(&tc_to_ufid, &data->tc_to_ufid_node); netdev_close(data->netdev); + sgid_free(data->sample_group_id[0]); free(data); } @@ -2133,6 +2260,14 @@ netdev_tc_parse_nl_actions(struct netdev *netdev, struct tc_flower *flower, if (err) { return err; } + } else if (nl_attr_type(nla) == OVS_ACTION_ATTR_SAMPLE) { + struct offload_sample sample; + uint32_t sgid; + + memset(&sample, 0, sizeof sample); + sgid = sgid_alloc(&sample); + sgid_free(sgid); + return EOPNOTSUPP; } else { VLOG_DBG_RL(&rl, "unsupported put action type: %d", nl_attr_type(nla)); @@ -2876,6 +3011,9 @@ netdev_tc_init_flow_api(struct netdev *netdev) tc_cleanup_policer_actions(meter_police_ids, METER_POLICE_IDS_BASE, METER_POLICE_IDS_MAX); ovs_mutex_unlock(&meter_police_ids_mutex); + ovs_mutex_lock(&sgid_lock); + sample_group_ids = id_pool_create(1, UINT32_MAX - 1); + ovs_mutex_unlock(&sgid_lock); ovsthread_once_done(&once); } diff --git a/lib/util.c b/lib/util.c index 3fb3a4b40..beac6c813 100644 --- a/lib/util.c +++ b/lib/util.c @@ -190,6 +190,12 @@ xmemdup(const void *p_, size_t size) return p; } +void * +nullable_xmemdup(const void *p_, size_t size) +{ + return p_ == NULL || size == 0 ? NULL : xmemdup(p_, size); +} + char * xmemdup0(const char *p_, size_t length) { diff --git a/lib/util.h b/lib/util.h index 62801e85f..815091edd 100644 --- a/lib/util.h +++ b/lib/util.h @@ -167,6 +167,7 @@ void *xcalloc(size_t, size_t) MALLOC_LIKE; void *xzalloc(size_t) MALLOC_LIKE; void *xrealloc(void *, size_t); void *xmemdup(const void *, size_t) MALLOC_LIKE; +void *nullable_xmemdup(const void *p_, size_t size) MALLOC_LIKE; char *xmemdup0(const char *, size_t) MALLOC_LIKE; char *xstrdup(const char *) MALLOC_LIKE; char *nullable_xstrdup(const char *) MALLOC_LIKE; From patchwork Mon Jun 19 05:05:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Mi X-Patchwork-Id: 1796314 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=QieOWzG/; dkim-atps=neutral Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QkyRl2Cjxz20Wk for ; Mon, 19 Jun 2023 15:06:59 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 65EC3611EA; Mon, 19 Jun 2023 05:06:57 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 65EC3611EA Authentication-Results: smtp3.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=QieOWzG/ X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zF1qDp_lnudP; Mon, 19 Jun 2023 05:06:56 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp3.osuosl.org (Postfix) with ESMTPS id 0A7DF611C5; Mon, 19 Jun 2023 05:06:55 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 0A7DF611C5 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id D76AEC007A; Mon, 19 Jun 2023 05:06:54 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 55D8DC0029 for ; Mon, 19 Jun 2023 05:06:53 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 95C60408FC for ; Mon, 19 Jun 2023 05:06:34 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 95C60408FC Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=QieOWzG/ X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NKuq93uC2Hwt for ; Mon, 19 Jun 2023 05:06:33 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 0C67E40B87 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on20617.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eab::617]) by smtp2.osuosl.org (Postfix) with ESMTPS id 0C67E40B87 for ; Mon, 19 Jun 2023 05:06:32 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZPgyzyeX6pzJyB8f8sPdaLCyW2OxJ4IfSvaU0rfxSa1mN7fnJLIN6yKZj0c0lPk6PTkVPiJIaKV7YE/F7dzt7uxbflesdsFrlNXo0CA4vVwpRHu0lq6wD9WOJln0OaVgWdgqXk8XtHTnlTwZTAjz81JvlcZ/TAyKrQvykAU6iSiE497p8ydibAvZZty+ch1n/sCROm84SlJ5TKbPIboQUTJfuDuk7oCdGbL0z+L0AJflkHK4sOrWYwRXQTUgI7SX3RyBmibiIarkwi8Cgp4Hy6HWFpueM4Qwkm2/B49/aqIoFie552Rr0yom46z8s4nL/SGWUXJtNJ45DUaxZ/JOuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lvbLZKNTR7tZoxiLc1WsSS7o2oDVAmYl8kBHDZ594HI=; b=D3v4K0ZOOsiJsEMR4Yal2/ciTNPP6tWixRxkQ5frcT4d+2qxQkrMF5yCPnWMYkao1fznJcwbghRy2diyy7h+u7IY83MvnOSLhUksi81j01mSU6XivECKJkkJET0L6ZTKeyXevNnb4XDwpl+3lvLujMaHO5fzEfKwvWYbVSGSacNByHFvdRvPNU1ZuqdxxMMuzcK0AvZdf9FSmvrTs7A2VRq1TQAQsvGm3YFoM8PjVAD9RnbFZRyqHdBtZh2E+Efy1qBp4+tl9DyIGHL2ICBjBx912n3e8C0rY5aekyAJw6/Sy42EOt2UjXvwXnuDuChFZPdZhFFmwh1YNxQ9sOqvDQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=openvswitch.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lvbLZKNTR7tZoxiLc1WsSS7o2oDVAmYl8kBHDZ594HI=; b=QieOWzG/4zljNO7Q3vms6kkAuDG20/J59tTe93TA3uIql85hCTY33oWEDkoGFF4f8N44MTecGeZ6MQHJUclls3UgQf4hQdHYh9ijslrSyhgSZrA8Q+4lYlpXMJnjOl2fs8QhGepFwnC3hPKQyuJLtA92ZBpd0ciXTHzrB25TK4zHlM3MM26mMZPx+2VcJ7qmgLbgkreFOoK0mSiCqdlnw7BMhWZuUc8E4g/VGU2kBskudCeV+uQlCe/pK70QiVv11x7ZZCub/9ip3csIZuiK8qC8jqKybPC5oMCb7Kn0vlx70cyNXb/6PQrUrhsxupdi/EQEnGI3Ouu0lry9EdhHeQ== Received: from BN1PR12CA0003.namprd12.prod.outlook.com (2603:10b6:408:e1::8) by DS0PR12MB8200.namprd12.prod.outlook.com (2603:10b6:8:f5::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.36; Mon, 19 Jun 2023 05:06:30 +0000 Received: from BN8NAM11FT023.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e1:cafe::fb) by BN1PR12CA0003.outlook.office365.com (2603:10b6:408:e1::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.36 via Frontend Transport; Mon, 19 Jun 2023 05:06:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by BN8NAM11FT023.mail.protection.outlook.com (10.13.177.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.36 via Frontend Transport; Mon, 19 Jun 2023 05:06:30 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Sun, 18 Jun 2023 22:06:16 -0700 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Sun, 18 Jun 2023 22:06:16 -0700 Received: from c-237-115-160-164.mtl.labs.mlnx (10.127.8.13) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Sun, 18 Jun 2023 22:06:13 -0700 To: Date: Mon, 19 Jun 2023 08:05:53 +0300 Message-ID: <20230619050557.310690-5-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230619050557.310690-1-cmi@nvidia.com> References: <20230619050557.310690-1-cmi@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT023:EE_|DS0PR12MB8200:EE_ X-MS-Office365-Filtering-Correlation-Id: bd3fab7b-ee3a-4242-c784-08db7082f188 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yaxW5act5rCDEKCc5ERdcw3W1VDkJihZUmRtsXpTYldCn/PE9PCojD+tlkyclwE0i1Ih3joaUd2C+6V2QyqEQSzWHT+D9vomZi2Pkt6YGTesM6ieUM7G53htx0Iql2KCQ5PzHl7pYBt4c9JVds6y9VloCQzxkuFWMFTDUPD34N+pH0TPgeE8mcdvSs40b8TCgx5c+TELx5C6Q6iDuUAM+ReMoJNp6rGvAQns2NlInXiIJp55JA62HI4C4Yl/fxLMXYWazmYfBs9zMWL0qzCD9dv0G4eXBfOb97DBEb67fHaBX8T6wrGwbDAK3AJ+DDLOo/VR3y/szPcX9yCijCPsPulvJveFL7TJSS6yrRB2Tz/ElMmpF/1P6LZVn8SOIOuLxfAngTQEYiIDJYDUrXCyhh0tZDc3QAQHD6wM0DKU/O6dSAU0wQ+VbVit/0ghWVAtJZeRqZHTgAcRZH0VS1vpZvke03IDZiHZHeGBHOE4H8nEIpMyjs4A4H3rriO9QETZ4Oqay9cVGJzMtV6CKL6r3un4+NkJniZYGALQly67jHHcOpIlvvupSeAOQiAFrnxIuvHxZ5+a6F4ttS+PGm37rQgj/Z+Jy0CFG9QrJjbpBYrs0bJH8+jApo2r+eW9kruvHVu+ZYhMT9H06F6/U0nFPpqTS8HgrN2RnyUzXuWTsaLAx0cBfxAnVajHYedfPL9IeudoX7zPuTzCpZSh7sHiWTvfoQGVFod45nEAdEviC2OQ1a9TEUiEIqpX29AnvTVJ X-Forefront-Antispam-Report: CIP:216.228.118.232; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge1.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(346002)(39860400002)(396003)(136003)(376002)(451199021)(36840700001)(40470700004)(46966006)(4326008)(478600001)(54906003)(1076003)(40460700003)(26005)(107886003)(186003)(40480700001)(6666004)(36756003)(30864003)(2906002)(8676002)(41300700001)(8936002)(70206006)(70586007)(6916009)(316002)(5660300002)(82310400005)(86362001)(83380400001)(47076005)(426003)(336012)(7636003)(356005)(2616005)(36860700001)(82740400003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2023 05:06:30.1514 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bd3fab7b-ee3a-4242-c784-08db7082f188 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.232]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT023.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8200 Cc: elibr@nvidia.com, simon.horman@corigine.com, roniba@nvidia.com, i.maximets@ovn.org, konguyen@redhat.com, majd@nvidia.com, maord@nvidia.com Subject: [ovs-dev] [PATCH v28 4/8] netdev-offload-tc: Add sample offload API for TC X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Chris Mi via dev From: Chris Mi Reply-To: Chris Mi Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Initialize psample socket. Add sample recv API to receive sampled packets from psample socket. Add sample recv wait API to add psample socket fd to poll list. Signed-off-by: Chris Mi Reviewed-by: Roi Dayan Acked-by: Eelco Chaudron --- lib/dpif.h | 6 +- lib/flow.h | 2 +- lib/netdev-offload-provider.h | 30 ++++++ lib/netdev-offload-tc.c | 172 ++++++++++++++++++++++++++++++++++ lib/netdev-offload.c | 3 +- lib/packets.h | 2 +- 6 files changed, 210 insertions(+), 5 deletions(-) diff --git a/lib/dpif.h b/lib/dpif.h index 129cbf6a1..f91295862 100644 --- a/lib/dpif.h +++ b/lib/dpif.h @@ -834,8 +834,10 @@ struct dpif_upcall { /* DPIF_UC_ACTION only. */ struct nlattr *userdata; /* Argument to OVS_ACTION_ATTR_USERSPACE. */ - struct nlattr *out_tun_key; /* Output tunnel key. */ - struct nlattr *actions; /* Argument to OVS_ACTION_ATTR_USERSPACE. */ + struct nlattr *out_tun_key; /* Output tunnel key. */ + struct nlattr *actions; /* Argument to OVS_ACTION_ATTR_USERSPACE. */ + struct flow flow; /* Caller provided 'flow' if the 'key' is not + available. */ }; /* A callback to notify higher layer of dpif about to be purged, so that diff --git a/lib/flow.h b/lib/flow.h index a9d026e1c..0974bfd42 100644 --- a/lib/flow.h +++ b/lib/flow.h @@ -970,7 +970,7 @@ pkt_metadata_from_flow(struct pkt_metadata *md, const struct flow *flow) md->recirc_id = flow->recirc_id; md->dp_hash = flow->dp_hash; - flow_tnl_copy__(&md->tunnel, &flow->tunnel); + flow_tnl_copy(&md->tunnel, &flow->tunnel); md->skb_priority = flow->skb_priority; md->pkt_mark = flow->pkt_mark; md->in_port = flow->in_port; diff --git a/lib/netdev-offload-provider.h b/lib/netdev-offload-provider.h index 9108856d1..a457556e5 100644 --- a/lib/netdev-offload-provider.h +++ b/lib/netdev-offload-provider.h @@ -28,6 +28,8 @@ extern "C" { #endif +struct dpif_upcall; + struct netdev_flow_api { char *type; /* Flush all offloaded flows from a netdev. @@ -121,6 +123,34 @@ struct netdev_flow_api { int (*meter_del)(ofproto_meter_id meter_id, struct ofputil_meter_stats *stats); + /* Polls for upcall offload packets for an upcall handler. If successful, + * stores the upcall into '*upcall', using 'buf' for storage. + * + * The implementation should point 'upcall->flow' and 'upcall->userdata' + * (if any) into data in the caller-provided 'buf'. The implementation may + * also use 'buf' for storing the data of 'upcall->packet'. If necessary + * to make room, the implementation may reallocate the data in 'buf'. + * + * The caller owns the data of 'upcall->packet' and may modify it. If + * packet's headroom is exhausted as it is manipulated, 'upcall->packet' + * will be reallocated. This requires the data of 'upcall->packet' to be + * released with ofpbuf_uninit() before 'upcall' is destroyed. However, + * when an error is returned, the 'upcall->packet' may be uninitialized + * and should not be released. + * + * This function must not block. If no upcall is pending when it is + * called, it should return EAGAIN without blocking. + * + * Return 0 if successful, otherwise returns a positive errno value. + */ + int (*recv)(struct dpif_upcall *upcall, struct ofpbuf *buf, + uint32_t handler_id); + + /* Arranges for the poll loop for an upcall handler to wake up when + * sample socket has a message queued to be received with the recv + * member functions. */ + void (*recv_wait)(uint32_t handler_id); + /* Initializies the netdev flow api. * Return 0 if successful, otherwise returns a positive errno value. */ int (*init_flow_api)(struct netdev *); diff --git a/lib/netdev-offload-tc.c b/lib/netdev-offload-tc.c index 56726acf8..8d571aca8 100644 --- a/lib/netdev-offload-tc.c +++ b/lib/netdev-offload-tc.c @@ -18,6 +18,8 @@ #include #include +#include +#include #include "cmap.h" #include "dpif-provider.h" @@ -125,6 +127,9 @@ struct sgid_node { struct offload_sample sample; }; +static struct nl_sock *psample_sock; +static int psample_family; + /* The sgid_map mutex protects the sample_group_ids and the sgid_map for * cmap_insert(), cmap_remove(), or cmap_replace() operations. */ static struct ovs_mutex sgid_lock = OVS_MUTEX_INITIALIZER; @@ -156,6 +161,14 @@ sgid_find(uint32_t id) return node ? CONTAINER_OF(node, struct sgid_node, id_node) : NULL; } +static struct offload_sample * +sample_find(uint32_t id) +{ + struct sgid_node *node = sgid_find(id); + + return node ? &node->sample: NULL; +} + static void offload_sample_clone(struct offload_sample *dst, const struct offload_sample *src, @@ -2955,6 +2968,55 @@ tc_cleanup_policer_actions(struct id_pool *police_ids, hmap_destroy(&map); } +static void +psample_init(void) +{ + unsigned int psample_mcgroup; + int err; + + if (!netdev_is_flow_api_enabled()) { + VLOG_DBG("Flow API is not enabled"); + return; + } + + if (psample_sock) { + VLOG_DBG("Psample socket is already initialized"); + return; + } + + err = nl_lookup_genl_family(PSAMPLE_GENL_NAME, + &psample_family); + if (err) { + VLOG_INFO("Generic Netlink family '%s' does not exist: %s\n" + "Please make sure the kernel module psample is loaded", + PSAMPLE_GENL_NAME, ovs_strerror(err)); + return; + } + + err = nl_lookup_genl_mcgroup(PSAMPLE_GENL_NAME, + PSAMPLE_NL_MCGRP_SAMPLE_NAME, + &psample_mcgroup); + if (err) { + VLOG_INFO("Failed to join Netlink multicast group '%s': %s", + PSAMPLE_NL_MCGRP_SAMPLE_NAME, ovs_strerror(err)); + return; + } + + err = nl_sock_create(NETLINK_GENERIC, &psample_sock); + if (err) { + VLOG_INFO("Failed to create psample socket: %s", ovs_strerror(err)); + return; + } + + err = nl_sock_join_mcgroup(psample_sock, psample_mcgroup); + if (err) { + VLOG_INFO("Failed to join psample mcgroup: %s", ovs_strerror(err)); + nl_sock_destroy(psample_sock); + psample_sock = NULL; + return; + } +} + static int netdev_tc_init_flow_api(struct netdev *netdev) { @@ -3014,6 +3076,7 @@ netdev_tc_init_flow_api(struct netdev *netdev) ovs_mutex_lock(&sgid_lock); sample_group_ids = id_pool_create(1, UINT32_MAX - 1); ovs_mutex_unlock(&sgid_lock); + psample_init(); ovsthread_once_done(&once); } @@ -3231,6 +3294,113 @@ meter_tc_del_policer(ofproto_meter_id meter_id, return err; } +struct offload_psample { + struct nlattr *packet; /* Packet data. */ + uint32_t group_id; /* Mapping id for sample offload. */ +}; + +static int +nl_parse_psample(struct offload_psample *psample, struct ofpbuf *buf) +{ + static const struct nl_policy ovs_psample_policy[] = { + [PSAMPLE_ATTR_SAMPLE_GROUP] = { .type = NL_A_U32 }, + [PSAMPLE_ATTR_DATA] = { .type = NL_A_UNSPEC }, + }; + struct nlattr *a[ARRAY_SIZE(ovs_psample_policy)]; + struct genlmsghdr *genl; + struct nlmsghdr *nlmsg; + struct ofpbuf b; + + b = ofpbuf_const_initializer(buf->data, buf->size); + nlmsg = ofpbuf_try_pull(&b, sizeof *nlmsg); + genl = ofpbuf_try_pull(&b, sizeof *genl); + if (!nlmsg || !genl || nlmsg->nlmsg_type != psample_family + || !nl_policy_parse(&b, 0, ovs_psample_policy, a, + ARRAY_SIZE(ovs_psample_policy))) { + return EINVAL; + } + + psample->group_id = nl_attr_get_u32(a[PSAMPLE_ATTR_SAMPLE_GROUP]); + psample->packet = a[PSAMPLE_ATTR_DATA]; + + return 0; +} + +static int +psample_parse_packet(struct offload_psample *psample, + struct dpif_upcall *upcall) +{ + struct flow *flow = &upcall->flow; + struct offload_sample *sample; + + memset(upcall, 0, sizeof *upcall); + dp_packet_use_const(&upcall->packet, + nl_attr_get(psample->packet), + nl_attr_get_size(psample->packet)); + + sample = sample_find(psample->group_id); + if (!sample) { + VLOG_ERR_RL(&error_rl, "Failed to get sample info via group id: %d", + psample->group_id); + return ENOENT; + } + + upcall->userdata = sample->userdata; + if (sample->tunnel) { + flow_tnl_copy(&flow->tunnel, sample->tunnel); + } + if (sample->userspace_actions) { + upcall->actions = sample->userspace_actions; + } + flow->in_port.odp_port = netdev_ifindex_to_odp_port(sample->ifindex); + upcall->type = DPIF_UC_ACTION; + + return 0; +} + +static int +netdev_tc_recv(struct dpif_upcall *upcall, struct ofpbuf *buf, + uint32_t handler_id) +{ + int read_tries = 0; + + if (handler_id || !psample_sock) { + return EAGAIN; + } + + for (;;) { + struct offload_psample psample; + int error; + + if (++read_tries > 50) { + return EAGAIN; + } + + error = nl_sock_recv(psample_sock, buf, NULL, false); + if (error == ENOBUFS) { + continue; + } + if (error) { + return error; + } + error = nl_parse_psample(&psample, buf); + + return error ? error : psample_parse_packet(&psample, upcall); + } + + return EAGAIN; +} + +static void +netdev_tc_recv_wait(uint32_t handler_id) +{ + /* For simplicity, i.e., using a single NetLink socket, only the first + * handler thread will be used. */ + if (!handler_id && psample_sock) { + nl_sock_wait(psample_sock, POLLIN); + } +} + const struct netdev_flow_api netdev_offload_tc = { .type = "linux_tc", .flow_flush = netdev_tc_flow_flush, @@ -3244,5 +3414,7 @@ const struct netdev_flow_api netdev_offload_tc = { .meter_set = meter_tc_set_policer, .meter_get = meter_tc_get_policer, .meter_del = meter_tc_del_policer, + .recv = netdev_tc_recv, + .recv_wait = netdev_tc_recv_wait, .init_flow_api = netdev_tc_init_flow_api, }; diff --git a/lib/netdev-offload.c b/lib/netdev-offload.c index a5fa62487..403315deb 100644 --- a/lib/netdev-offload.c +++ b/lib/netdev-offload.c @@ -38,6 +38,7 @@ #include "netdev-provider.h" #include "netdev-vport.h" #include "odp-netlink.h" +#include "odp-util.h" #include "openflow/openflow.h" #include "packets.h" #include "openvswitch/ofp-print.h" @@ -826,7 +827,7 @@ odp_port_t netdev_ifindex_to_odp_port(int ifindex) { struct port_to_netdev_data *data; - odp_port_t ret = 0; + odp_port_t ret = ODPP_NONE; ovs_rwlock_rdlock(&ifindex_to_port_rwlock); HMAP_FOR_EACH_WITH_HASH (data, ifindex_node, ifindex, &ifindex_to_port) { diff --git a/lib/packets.h b/lib/packets.h index ac4c28e47..f49c3822f 100644 --- a/lib/packets.h +++ b/lib/packets.h @@ -86,7 +86,7 @@ flow_tnl_size(const struct flow_tnl *src) * data in 'dst' is NOT cleared, so this must not be used in cases where the * uninitialized portion may be hashed over. */ static inline void -flow_tnl_copy__(struct flow_tnl *dst, const struct flow_tnl *src) +flow_tnl_copy(struct flow_tnl *dst, const struct flow_tnl *src) { memcpy(dst, src, flow_tnl_size(src)); } From patchwork Mon Jun 19 05:05:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Mi X-Patchwork-Id: 1796315 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=iarSaXKG; dkim-atps=neutral Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QkyRq75P2z20Wk for ; Mon, 19 Jun 2023 15:07:03 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 1BC2B40C10; Mon, 19 Jun 2023 05:07:02 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 1BC2B40C10 Authentication-Results: smtp2.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=iarSaXKG X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XxuQJRDp1vfc; Mon, 19 Jun 2023 05:07:01 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id 3AA7F40A21; Mon, 19 Jun 2023 05:07:00 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 3AA7F40A21 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 18A28C008C; Mon, 19 Jun 2023 05:07:00 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 2AF16C0088 for ; Mon, 19 Jun 2023 05:06:59 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 083A740BC2 for ; Mon, 19 Jun 2023 05:06:36 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 083A740BC2 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GMB_HcX22trk for ; Mon, 19 Jun 2023 05:06:35 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 29E9A40ACD Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2061b.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8a::61b]) by smtp2.osuosl.org (Postfix) with ESMTPS id 29E9A40ACD for ; Mon, 19 Jun 2023 05:06:35 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Iv1DjYYLwiVuyRMgRH7O9kbhtrF8eHMo0P6mjFNZSKefW5Vz5R5I2L2tNR6vEpRGeLjR7PmjqtSY5orfCZFkarHYChSgayeUUdT1cG6arn0Rjgjn6yEJpSk1CxDBoJ2/faVYQLAk25rD8Cx285jkb60mv13MrwQl4j3MtTpSenkaDR2Jxix7sjWuNBV3TtjIRYF4/7th3c0ZhfRfUNOSMXxO3fLtYthxeoHEjr5P6yciSrB3VQmUyKmGVMAETzCOl2oZccVANTvM8DbhPLXPfdabSbTZuQ2fo/fABNupDx+8lnXkRXPSeGhbuRjW1YEaWTBoIb9KxGWxUxFOvAqb4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=W3JePJ2Q1Kr555lx19NCLnnoBck/NdcKUeMJzs2Da84=; b=Png8DjK3WQzQhej4lVpGTc/gHR6WffoEOKqKus1zZu29NU1d287VmK3TkoHJXac78WK1xQg5gPZKUaQ8UEMeLpy3opBAkIHZEYVdMMEletU4tjFjnZ+/19TuyIXSupNM2tj+8NvsJds/ZmZE9X24tBFIK5111pmsCABgfHYLLNiMt+hZbReTlQKjZmrtqyuvXLD0EM512NGMRL8vXQw7XXFUhvErwyJezdAcGOH8f4kKzQ+3E0uqVcALIetyikKQR5Dj5KRZH2rY/N3/lNLsKYBTgXIzcX+KdpM2NkhZdwYfn30JW4CZbQU7Nd9YR3XfMZAloLlc3ygieLSe4d23sA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=openvswitch.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=W3JePJ2Q1Kr555lx19NCLnnoBck/NdcKUeMJzs2Da84=; b=iarSaXKGds+cMOkh9wyk9WRe+CYckPgEq+BZhI3b8JQehzEBgIHcYZHcypWHTyhUPHzLqrBCbyXmxoJRZqyA1sxfKi+vRAwtbu7G7RDRt3i0LrEMxKJmOhygY2gi7aEM5GqZRoJeCXswr3gokBQlpBa1dVGe7I/hV9/8oQF0JrNQHz5ZIZcm6zMhepdpvx0IQ+oG+kyakMQ1jR0Esk/7Uz5lzcjfKVwt66k1Ivs1dWRQbe5jHHOvWjQHbh/k0EHf+RONLcZIfDsSFECvRHoOiqQZ40Es1jmTltXNiXlPhVzXLqT5VLQ7cpiseQJhyMOrGlNexdhzKLrR9WaRWTZ9yw== Received: from BN1PR12CA0016.namprd12.prod.outlook.com (2603:10b6:408:e1::21) by MN0PR12MB5929.namprd12.prod.outlook.com (2603:10b6:208:37c::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.36; Mon, 19 Jun 2023 05:06:31 +0000 Received: from BN8NAM11FT023.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e1:cafe::45) by BN1PR12CA0016.outlook.office365.com (2603:10b6:408:e1::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.36 via Frontend Transport; Mon, 19 Jun 2023 05:06:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by BN8NAM11FT023.mail.protection.outlook.com (10.13.177.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.36 via Frontend Transport; Mon, 19 Jun 2023 05:06:31 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Sun, 18 Jun 2023 22:06:20 -0700 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Sun, 18 Jun 2023 22:06:19 -0700 Received: from c-237-115-160-164.mtl.labs.mlnx (10.127.8.13) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Sun, 18 Jun 2023 22:06:16 -0700 To: Date: Mon, 19 Jun 2023 08:05:54 +0300 Message-ID: <20230619050557.310690-6-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230619050557.310690-1-cmi@nvidia.com> References: <20230619050557.310690-1-cmi@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT023:EE_|MN0PR12MB5929:EE_ X-MS-Office365-Filtering-Correlation-Id: 85e63e8f-5204-4035-3071-08db7082f258 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oauZXEK841xSUrOanHr0uW93iqLG5mFaTGjtz376MnYeBmFn8nhANH7SwuREYC4DFOOPS4Zt20q7SpJjzbX8n2uVd2RI/tlidR/WXjmCBsn/8UTpQWlLXRvJQmFpX9OzlR4bk2TS5RKpJmxD8qg21OwuwNxNgAFHDftEw2yPAS0KazJwAx5t+wDupjGdjrOFKywZLK2LUgCzMGjmhXasmjhs1e0yZZVJTS2Yf6yFU/fXl93WpNKDqwjCSM127tBCWjja3VZ1BIG54qOqMJXy7k78jr4aF5XQOkwBgnELEq4oOUt93tiK6EajnsM0MTIEToK0sqlilqSL6orL5AD3Z/hxJdKwKmoYLBVHkWGBDqvRh5iZ6VH3V3ZCN73VXci77hbZuV1RTos+hYdq7CNKMucXKENx41OEJD85M7SBctXRgPIzOulmK4Fcn51022ZcEMIUj5SxS5MHcTt7YPVGAnyPM3w+qr3XDrfBuOwxuz7Q642IQCJexNdi1KGr64mhN5IAEy+9Ype2YnMxl/BmUI6r5HLrtbmC1VJUGYfFZcPvn6lVihSvUdu+hq0hZ50G7oIRWZGbwlFJ5TVSD7fOhgZQa1DpCXBwYs9wg76Gi5dS5EwhjpjjEB7Pt/+cf0lOwyiQmcM9JO4FwhGMQxfDPBwkZ3gtm2InR7NtHrPjfUw812A2PgJXp4Hb2xamYeRdHd7fC01DjK0v5xg5p3yMhd8VWbPMEf2uDQM4P3Qkdg+WaEOVoMJrno0N86dyU/my X-Forefront-Antispam-Report: CIP:216.228.118.232; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge1.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(376002)(396003)(346002)(39860400002)(136003)(451199021)(36840700001)(40470700004)(46966006)(7636003)(107886003)(356005)(82740400003)(40460700003)(478600001)(36860700001)(2906002)(40480700001)(6666004)(54906003)(316002)(47076005)(82310400005)(2616005)(336012)(426003)(5660300002)(41300700001)(6916009)(70206006)(70586007)(36756003)(1076003)(26005)(86362001)(8676002)(8936002)(186003)(4326008); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2023 05:06:31.4951 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 85e63e8f-5204-4035-3071-08db7082f258 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.232]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT023.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5929 Cc: elibr@nvidia.com, simon.horman@corigine.com, roniba@nvidia.com, i.maximets@ovn.org, konguyen@redhat.com, majd@nvidia.com, maord@nvidia.com Subject: [ovs-dev] [PATCH v28 5/8] netdev-offload: Add netdev offload recv and recv_wait APIs X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Chris Mi via dev From: Chris Mi Reply-To: Chris Mi Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Iterate each registered offload API. It's not a problem for today since we only have one implementation. Signed-off-by: Chris Mi Reviewed-by: Roi Dayan Acked-by: Eelco Chaudron --- lib/netdev-offload.c | 38 ++++++++++++++++++++++++++++++++++++++ lib/netdev-offload.h | 5 +++++ 2 files changed, 43 insertions(+) diff --git a/lib/netdev-offload.c b/lib/netdev-offload.c index 403315deb..1374aa8ac 100644 --- a/lib/netdev-offload.c +++ b/lib/netdev-offload.c @@ -257,6 +257,44 @@ meter_offload_del(ofproto_meter_id meter_id, struct ofputil_meter_stats *stats) return 0; } +int +netdev_offload_recv(struct dpif_upcall *upcall, struct ofpbuf *buf, + uint32_t handler_id) +{ + struct netdev_registered_flow_api *rfa; + int ret = EAGAIN; + + CMAP_FOR_EACH (rfa, cmap_node, &netdev_flow_apis) { + if (rfa->flow_api->recv) { + ret = rfa->flow_api->recv(upcall, buf, handler_id); + if (!ret) { + return 0; + } + + if (ret == EAGAIN) { + VLOG_DBG_RL(&rl, "Failed to receive offload packet, %s, " + "type: %s", ovs_strerror(ret), + rfa->flow_api->type); + } + } else { + ret = EAGAIN; + } + } + return ret; +} + +void +netdev_offload_recv_wait(uint32_t handler_id) +{ + struct netdev_registered_flow_api *rfa; + + CMAP_FOR_EACH (rfa, cmap_node, &netdev_flow_apis) { + if (rfa->flow_api->recv_wait) { + rfa->flow_api->recv_wait(handler_id); + } + } +} + int netdev_flow_flush(struct netdev *netdev) { diff --git a/lib/netdev-offload.h b/lib/netdev-offload.h index 47f8e6f48..d71e98418 100644 --- a/lib/netdev-offload.h +++ b/lib/netdev-offload.h @@ -33,6 +33,7 @@ extern "C" { struct dp_packet_batch; struct dp_packet; +struct dpif_upcall; struct netdev_class; struct netdev_rxq; struct netdev_saved_flags; @@ -162,6 +163,10 @@ void meter_offload_set(ofproto_meter_id, struct ofputil_meter_config *); int meter_offload_get(ofproto_meter_id, struct ofputil_meter_stats *); int meter_offload_del(ofproto_meter_id, struct ofputil_meter_stats *); +int netdev_offload_recv(struct dpif_upcall *upcall, struct ofpbuf *buf, + uint32_t handler_id); +void netdev_offload_recv_wait(uint32_t handler_id); + #ifdef __cplusplus } #endif From patchwork Mon Jun 19 05:05:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Mi X-Patchwork-Id: 1796317 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=M6kXb8GH; dkim-atps=neutral Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QkyS56HkYz20Wk for ; Mon, 19 Jun 2023 15:07:17 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id D59C282043; Mon, 19 Jun 2023 05:07:14 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org D59C282043 Authentication-Results: smtp1.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=M6kXb8GH X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hJDeaZqNsQr0; Mon, 19 Jun 2023 05:07:12 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTPS id 1F03F8206E; Mon, 19 Jun 2023 05:07:11 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 1F03F8206E Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id B19D4C008E; Mon, 19 Jun 2023 05:07:08 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 12765C007A for ; Mon, 19 Jun 2023 05:07:06 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id E2B1F40B98 for ; Mon, 19 Jun 2023 05:06:37 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org E2B1F40B98 Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=M6kXb8GH X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uL7w69YbhxaP for ; Mon, 19 Jun 2023 05:06:37 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org D2CE140BB1 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on20601.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eae::601]) by smtp2.osuosl.org (Postfix) with ESMTPS id D2CE140BB1 for ; Mon, 19 Jun 2023 05:06:36 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HgRUjeiAD8sEUKmgpCkXVCRGs9JHTEJhg2lKme4975udBx9rOJrhBdgTXLKdiZHy9urnwzALG89xyH2Pwx8PGB3iHusA1STjv5mxaXMdgWQxGh9h0TB6ozTox3//iNcTdlGjeQvD/JiP5batvkKPriK2G1WEwNiJmb+A1OgxWR5N8s5XrJ3H2u0eiPx3DYXwYbU1IZY2UE6meqQCUq99VsfvZ/VyUBCjHHsneNFJaFkoHbMW4PZcOjlNQ8dzjuFTDDEd01RWuRuI1IpfMkSka7oMb9Gl/XO2rJtWPnH3Y61u+dmH3zlXOe8eYercask3A67loGDhLkxMWiEHInt8xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hlI2SsuK1p2EBr02eQQfH+8+z9nAOu0o7Rbp3Na6dhc=; b=f64DGurZ2iVMKWXwA3ftOt8gqC+dT/Uy1O+uMm22aUzxqeTQgwF8ZXS1GJXGLN8xAn2quD+dRtsgK9nm6ReV8xtJkOfag4IMWcTIpzX1Irg9+ibsLRVajEA+OsGu6AO/Xy6/sdfSp4qx//mGY7gvmy9LMnnUheMmEDwueDP2CM8h9H1+Y8Z0OziPBZ1bC9T9eYBotQwkfhOriVnEuZ9MR6kf5N+RiszHXfeifeqs+XuepdZwfZVYLLTE805CoPws0s/uBGaK4eiqrDCqDs7AYz9SEvB38jDedfmj7TZctaQjVxm7TxKowwIW2w0u9e64vd1C4vFY4CIbK5ZwB8PYOQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=openvswitch.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hlI2SsuK1p2EBr02eQQfH+8+z9nAOu0o7Rbp3Na6dhc=; b=M6kXb8GHOoGjhE3YCbq8H9iJxJkznCrfYhO4Y3DE6Ny6YFbf6+2KO3srkRLjsTnifz+YrOV6505BOQvi5r/52Pk9I0OviPx+MiIiTQCjS8u3I51zi/kg0IhPbnS4oPX23xP/ITmFMTE70f4/OlVgsFABOPdrheA9GnVbLHs9LXHKh+0c+ISuTkBdpqFzOqnS43ylALXqp08P0JujfcjOeKGX9ivc/uVSwdsKMaHg5teoHq21z5ZX7VD2enPCTf14N0gjSYP9s+gUAvU5jXWywDyLDFklBrg4bpxWi5xF979PNSghoVu9syjnaeNFrTO9llKA2UHulHzBpw/sfT7iiw== Received: from BN1PR12CA0002.namprd12.prod.outlook.com (2603:10b6:408:e1::7) by IA1PR12MB6187.namprd12.prod.outlook.com (2603:10b6:208:3e5::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.37; Mon, 19 Jun 2023 05:06:34 +0000 Received: from BN8NAM11FT023.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e1:cafe::d) by BN1PR12CA0002.outlook.office365.com (2603:10b6:408:e1::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.37 via Frontend Transport; Mon, 19 Jun 2023 05:06:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by BN8NAM11FT023.mail.protection.outlook.com (10.13.177.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.36 via Frontend Transport; Mon, 19 Jun 2023 05:06:33 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Sun, 18 Jun 2023 22:06:23 -0700 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Sun, 18 Jun 2023 22:06:23 -0700 Received: from c-237-115-160-164.mtl.labs.mlnx (10.127.8.13) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Sun, 18 Jun 2023 22:06:20 -0700 To: Date: Mon, 19 Jun 2023 08:05:55 +0300 Message-ID: <20230619050557.310690-7-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230619050557.310690-1-cmi@nvidia.com> References: <20230619050557.310690-1-cmi@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT023:EE_|IA1PR12MB6187:EE_ X-MS-Office365-Filtering-Correlation-Id: a3827cfd-1669-429a-2d43-08db7082f3c0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QUUWVbZuQfrLAmWp2IRBfmN2LHeZfI9jzvUuRDN4FtAOsHnjzTYiV0KAAroxhppk+GQR19eGSbvesGLe3F5JfMN4VjraxXuRQR8c4PSVWDHgp54ZoO2uwiDkm6ZQxa2AacBtdN+Gilg5y0QyLZvgxL1okMafye6/OG1iQWlTZ4YjdHfy/QQ0k4zQik3fjZiU8utn9YQyKZ2bYqVyWiL6tSJr/nXnVLoZ+NpCfBpxXtjR/YzXJIv78h4Um/ho9JLtPuasKztjpohciwj4f57YCJt+wtaDXR1HghkVylvQ7x6QPdog8txBE6XHNGh/o6sEP1F9DgTk2W9yfINr4aScqyh7GqBtUcgN/e2ltsLpY8ZD3txP3tkslNJTaF1EWPZjp7XQfNeb7cGiQvWo3mmqhDjiDtjddkHt6gJqmE4yAqnvIYrs9h4j3cGItG2DcvfOUoDONZniwAob1LZeic2+pZr3Uy37MS5d1Du9OQX2DGy/Rq0f4VXN+aBipVYzTDC0nV90rKhCZy+jJD5ed7Qgj2y3jwyvNN+kc5XLS2EnjAeKgEueumNJXCZWETIDG+Npj4yisq5tCsCgb/EUpoXdnfjdB+Yk8ZIodQIKW+wrGSE4AlWBOIsaBvLuBgsSsmrMSI0XZENpb0bMFuAV/TJMK4vGR7cIyOK/KUhXWsEXvsLNbttC+oANm/M9d+tjKujOcdRuRtknvTaa8OnmhPYXzddUz0GzQYY54NKzx4B/nGQ11RxHNj1sqxq2dgcycNTQ X-Forefront-Antispam-Report: CIP:216.228.118.232; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge1.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(396003)(136003)(346002)(39860400002)(376002)(451199021)(46966006)(36840700001)(40470700004)(86362001)(54906003)(40480700001)(8676002)(26005)(40460700003)(41300700001)(186003)(2616005)(426003)(70206006)(70586007)(4326008)(6916009)(83380400001)(66899021)(82310400005)(316002)(5660300002)(1076003)(47076005)(36756003)(6666004)(107886003)(2906002)(36860700001)(336012)(82740400003)(7636003)(8936002)(478600001)(356005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2023 05:06:33.8543 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a3827cfd-1669-429a-2d43-08db7082f3c0 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.232]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT023.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6187 Cc: elibr@nvidia.com, simon.horman@corigine.com, roniba@nvidia.com, i.maximets@ovn.org, konguyen@redhat.com, majd@nvidia.com, maord@nvidia.com Subject: [ovs-dev] [PATCH v28 6/8] dpif-netlink: Add netdev offload recv in normal recv upcalls X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Chris Mi via dev From: Chris Mi Reply-To: Chris Mi Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" In thread handler 0, add netdev offload recv in normal recv upcalls. To avoid starvation, introduce a flag to alternate the order of receiving normal upcalls and offload upcalls based on that flag. Add similar change for recv_wait. Signed-off-by: Chris Mi Reviewed-by: Roi Dayan Acked-by: Eelco Chaudron --- lib/dpif-netlink.c | 41 ++++++++++++++++++++++++++++++----- ofproto/ofproto-dpif-upcall.c | 15 +++++++++---- 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c index 60bd39643..6e7b644e8 100644 --- a/lib/dpif-netlink.c +++ b/lib/dpif-netlink.c @@ -201,6 +201,11 @@ struct dpif_handler { struct nl_sock *sock; /* Each handler thread holds one netlink socket. */ + /* The receive handler thread deals with both normal and offload receive + * upcalls. To avoid starvation, the below flag is used to alternate the + * processing order. */ + bool recv_offload_first; + #ifdef _WIN32 /* Pool of sockets. */ struct dpif_windows_vport_sock *vport_sock_pool; @@ -3010,7 +3015,6 @@ dpif_netlink_recv_windows(struct dpif_netlink *dpif, uint32_t handler_id, static int dpif_netlink_recv_cpu_dispatch(struct dpif_netlink *dpif, uint32_t handler_id, struct dpif_upcall *upcall, struct ofpbuf *buf) - OVS_REQ_RDLOCK(dpif->upcall_lock) { struct dpif_handler *handler; int read_tries = 0; @@ -3061,7 +3065,6 @@ dpif_netlink_recv_vport_dispatch(struct dpif_netlink *dpif, uint32_t handler_id, struct dpif_upcall *upcall, struct ofpbuf *buf) - OVS_REQ_RDLOCK(dpif->upcall_lock) { struct dpif_handler *handler; int read_tries = 0; @@ -3135,13 +3138,12 @@ dpif_netlink_recv_vport_dispatch(struct dpif_netlink *dpif, #endif static int -dpif_netlink_recv(struct dpif *dpif_, uint32_t handler_id, - struct dpif_upcall *upcall, struct ofpbuf *buf) +dpif_netlink_recv__(struct dpif_netlink *dpif, uint32_t handler_id, + struct dpif_upcall *upcall, struct ofpbuf *buf) + OVS_REQ_RDLOCK(dpif->upcall_lock) { - struct dpif_netlink *dpif = dpif_netlink_cast(dpif_); int error; - fat_rwlock_rdlock(&dpif->upcall_lock); #ifdef _WIN32 error = dpif_netlink_recv_windows(dpif, handler_id, upcall, buf); #else @@ -3152,6 +3154,32 @@ dpif_netlink_recv(struct dpif *dpif_, uint32_t handler_id, handler_id, upcall, buf); } #endif + + return error; +} + +static int +dpif_netlink_recv(struct dpif *dpif_, uint32_t handler_id, + struct dpif_upcall *upcall, struct ofpbuf *buf) +{ + struct dpif_netlink *dpif = dpif_netlink_cast(dpif_); + struct dpif_handler *handler; + int error; + + fat_rwlock_rdlock(&dpif->upcall_lock); + handler = &dpif->handlers[handler_id]; + if (handler->recv_offload_first) { + error = netdev_offload_recv(upcall, buf, handler_id); + if (error == EAGAIN) { + error = dpif_netlink_recv__(dpif, handler_id, upcall, buf); + } + } else { + error = dpif_netlink_recv__(dpif, handler_id, upcall, buf); + if (error == EAGAIN) { + error = netdev_offload_recv(upcall, buf, handler_id); + } + } + handler->recv_offload_first = !handler->recv_offload_first; fat_rwlock_unlock(&dpif->upcall_lock); return error; @@ -3217,6 +3245,7 @@ dpif_netlink_recv_wait(struct dpif *dpif_, uint32_t handler_id) dpif_netlink_recv_wait_vport_dispatch(dpif, handler_id); } #endif + netdev_offload_recv_wait(handler_id); fat_rwlock_unlock(&dpif->upcall_lock); } diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c index 04b583f81..c1fad9a8f 100644 --- a/ofproto/ofproto-dpif-upcall.c +++ b/ofproto/ofproto-dpif-upcall.c @@ -855,10 +855,17 @@ recv_upcalls(struct handler *handler) break; } - upcall->fitness = odp_flow_key_to_flow(dupcall->key, dupcall->key_len, - flow, NULL); - if (upcall->fitness == ODP_FIT_ERROR) { - goto free_dupcall; + /* If key and key_len are available, use them to construct flow. + * Otherwise, use upcall->flow. */ + if (dupcall->key && dupcall->key_len) { + upcall->fitness = odp_flow_key_to_flow(dupcall->key, + dupcall->key_len, + flow, NULL); + if (upcall->fitness == ODP_FIT_ERROR) { + goto free_dupcall; + } + } else { + flow = &dupcall->flow; } if (dupcall->mru) { From patchwork Mon Jun 19 05:05:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Mi X-Patchwork-Id: 1796316 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=J0Auu3JJ; dkim-atps=neutral Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QkyS06qR5z20Wk for ; Mon, 19 Jun 2023 15:07:12 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id DC91F6124B; Mon, 19 Jun 2023 05:07:10 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org DC91F6124B Authentication-Results: smtp3.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=J0Auu3JJ X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WEXZg-ceoeHg; Mon, 19 Jun 2023 05:07:09 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp3.osuosl.org (Postfix) with ESMTPS id E92346123C; Mon, 19 Jun 2023 05:07:07 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org E92346123C Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id C9EC3C007A; Mon, 19 Jun 2023 05:07:07 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 06B42C0029 for ; Mon, 19 Jun 2023 05:07:06 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id E17A361188 for ; Mon, 19 Jun 2023 05:06:42 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org E17A361188 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id t2rO2ztwwxXn for ; Mon, 19 Jun 2023 05:06:39 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 249B561195 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on20606.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5a::606]) by smtp3.osuosl.org (Postfix) with ESMTPS id 249B561195 for ; Mon, 19 Jun 2023 05:06:38 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OF0blnCRStOcftsU2bP/xsXSjHibuIDd4nsojsK/KDMhTrHYH89R6Uxwe6VByKSIF8QITFoNP0FDp9GBDwywSOWg1Kc7vtSZrC3o9lzESVpoL9sDY3pMT0rJ2dyUuhOdbKtPsYLbX2YGOQQy0iiprP23Wz5mA3JQdUaSLiaknjmXepQBriPcLerbXC4k8Y9zwTOl7F/51IEuv8kXQ1XSyPVg8+a/E9pH3QLdB36/0wht2G0VFAi7H2svtgyvsMkKYI5nN51e2EibAp4qOM7Lu+g3G+a/oxE7ToPvrSte33lqikJ4X+aMmt5t5t0oqQ2Xw78Me7NPYkzubaBwgpgP1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hAg7jOBo/g2MZcQ1tOj9xbr/irc+imNXPFEeLaPMewY=; b=L2bswe6xIXriSqwJZUL4STwNBoHaYyzy6vgCWQ7obRfaMVT06MHCWOhbxLvq8hsNrXOcOfVhUu6cCul8kAFZaia1iaowzqDYNxNsRiPVSvEz85LHI6vkNpNxJzduiN1uWXcPYGj508afJg3GcBDQsS0Gg8Gn7qDJoAQlZWVSgTLre8O7mo+hZenmm+vH5imDNh9ZQnGgg7BckBP0MOGMlSRqDv0wC6K1DDIExXmRXtoK1eGXBv2OCijwSAiDKW0a/wvDUZEAlbUqXfHQNf2aSDvEj07Nt86Hq/jswfThAV6cJUkoux7UVqH09Msbo5CtiJPLcaun3mwHTpR++BUC4A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=openvswitch.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hAg7jOBo/g2MZcQ1tOj9xbr/irc+imNXPFEeLaPMewY=; b=J0Auu3JJNtcnvQ1QUDlPGPnrxJRvonRR1VAXwFhMPvRnqnKaXljX0moje0rqFXWgfJTKdfNIYzeT2Xg2SB953vxYnEZHg6+MdqzvWjLesLEvXsxuWev3+ckoYy0Y3sUBY40aZwcJQDwAaNE/mebg5lZNGjxtUA7Oz+44FWr/d1mESTJqHs0uOgiA07Lzn/XFZx0aqeauQAvJeYGWB0dGpBCUmZm3OrKotNsmjI3MGD5wn6S/vWeAa/4tFuCYrrx9UoUYxqciPl2bBllMDCeXYFsbby2eXkGZwG2WmKaeiobeTKA7/DhNM++umfvJBgi2/4QtV2sSpU3ORvIAfLeegw== Received: from BN1PR12CA0017.namprd12.prod.outlook.com (2603:10b6:408:e1::22) by SA1PR12MB7104.namprd12.prod.outlook.com (2603:10b6:806:29e::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.35; Mon, 19 Jun 2023 05:06:36 +0000 Received: from BN8NAM11FT023.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e1:cafe::ca) by BN1PR12CA0017.outlook.office365.com (2603:10b6:408:e1::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.36 via Frontend Transport; Mon, 19 Jun 2023 05:06:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by BN8NAM11FT023.mail.protection.outlook.com (10.13.177.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.36 via Frontend Transport; Mon, 19 Jun 2023 05:06:35 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Sun, 18 Jun 2023 22:06:27 -0700 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Sun, 18 Jun 2023 22:06:26 -0700 Received: from c-237-115-160-164.mtl.labs.mlnx (10.127.8.13) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Sun, 18 Jun 2023 22:06:23 -0700 To: Date: Mon, 19 Jun 2023 08:05:56 +0300 Message-ID: <20230619050557.310690-8-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230619050557.310690-1-cmi@nvidia.com> References: <20230619050557.310690-1-cmi@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT023:EE_|SA1PR12MB7104:EE_ X-MS-Office365-Filtering-Correlation-Id: a394e819-bada-4677-6b61-08db7082f4c6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mmu281If13kQnaKurYzbxsA0nmFXVNjKfvF+2gfV/mpHffZCCmHG1yYE4sr/gwCasii0wttXNKJavK+eWlzPNFFgat2G00nyrkUoRkqOqMGFO1Z1e+ZYVrLGLTsuog1PBZ1LGkZiQjff9X/Sn+RsSyRremnBX9Y2ICRMC1Aq1QjVi8y7Fy3kYJp/CVkqoZkTuX7Z+QA/BcnnJJjG1VCGGOpRdaQH2pKH11w6WpC0ZoSQOtKxaDOxUb4dyV41YTBM7csvVcoXGJ9Tpc1356PA0RYoUuLblwb6RU67TdWdjH3swh26hfIt8FD+mhod6/N5W7tB+IIZbrTqhtLCVrinPCDBuC5fnZuMO4E6/jDiMMrBTBBw+SKVqjg5njmOw3eP9U9hHJQtjjgzrdXzcohXtOHAOXrOPk+PBYmzkKwetxDpBUibWeEmnFuXRYt3gq45FkX7LQ9EtbW43+AvDzc0ghnsZA19/gjXAyWvtafgQcqNYg0EWW0nos/lO7Y+9nC+JPHJKE5NaAB13/Xqojj+hem0Y107N6Kd035R+V6sXY8PJ5yu99hGjzzD6813PbaXEjWy+pNpQ1Gw1Nc38E1C7cQMGuadegjiedI7Sm7WjEi0kXJ5a0pP5a/+F4sY39Sw7Ij6CGBwNvfA0sZ0Z5d9SwFtmhEvRHSysl7RXKoow+cfFaRKcejc89Rea223hd064Y0eZiiF/rBa1BasK/v1bEdQaUUvvG7Zpi8iYa0Q5qHbavm68xkVW29dMS0nLJbI X-Forefront-Antispam-Report: CIP:216.228.118.232; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge1.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(376002)(136003)(39860400002)(396003)(346002)(451199021)(46966006)(40470700004)(36840700001)(82310400005)(356005)(7636003)(82740400003)(40480700001)(40460700003)(36756003)(86362001)(6666004)(26005)(1076003)(107886003)(186003)(8936002)(8676002)(30864003)(5660300002)(478600001)(54906003)(316002)(41300700001)(4326008)(6916009)(70586007)(70206006)(2906002)(83380400001)(36860700001)(426003)(2616005)(336012)(47076005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2023 05:06:35.5729 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a394e819-bada-4677-6b61-08db7082f4c6 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.232]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT023.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7104 Cc: elibr@nvidia.com, simon.horman@corigine.com, roniba@nvidia.com, i.maximets@ovn.org, konguyen@redhat.com, majd@nvidia.com, maord@nvidia.com Subject: [ovs-dev] [PATCH v28 7/8] netdev-offload-tc: Add offload support for sFlow X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Chris Mi via dev From: Chris Mi Reply-To: Chris Mi Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Create a unique group ID to map the sFlow info when offloading sample action to TC. When showing the offloaded datapath flows, translate the group ID from TC sample action to sFlow info using the mapping. Signed-off-by: Chris Mi Reviewed-by: Roi Dayan Acked-by: Eelco Chaudron --- lib/netdev-offload-tc.c | 288 ++++++++++++++++++++++++++++++++++++---- lib/tc.c | 63 ++++++++- lib/tc.h | 6 + 3 files changed, 331 insertions(+), 26 deletions(-) diff --git a/lib/netdev-offload-tc.c b/lib/netdev-offload-tc.c index 8d571aca8..71ec8ef1f 100644 --- a/lib/netdev-offload-tc.c +++ b/lib/netdev-offload-tc.c @@ -95,6 +95,7 @@ static int police_idx_lookup(uint32_t police_idx, uint32_t *meter_id); static int netdev_tc_parse_nl_actions(struct netdev *netdev, struct tc_flower *flower, struct offload_info *info, + const struct flow_tnl *tnl, const struct nlattr *actions, size_t actions_len, bool *recirc_act, bool more_actions, @@ -136,6 +137,12 @@ static struct ovs_mutex sgid_lock = OVS_MUTEX_INITIALIZER; static struct cmap sgid_map = CMAP_INITIALIZER; static struct id_pool *sample_group_ids OVS_GUARDED_BY(sgid_lock); +static bool +psample_supported(void) +{ + return psample_sock != NULL; +} + static void sgid_node_free(struct sgid_node *node) { @@ -236,6 +243,30 @@ sgid_free(uint32_t id) } } +static void free_all_flower_sgids(struct tc_flower *flower) +{ + const struct tc_action *action = flower->actions; + + for (int i = 0; i < flower->action_count; i++, action++) { + if (action->type == TC_ACT_SAMPLE) { + sgid_free(action->sample.group_id); + } + } +} + +static unsigned int get_flower_sgid_count(struct tc_flower *flower) +{ + const struct tc_action *action = flower->actions; + unsigned int count = 0; + + for (int i = 0; i < flower->action_count; i++, action++) { + if (action->type == TC_ACT_SAMPLE && action->sample.group_id) { + count++; + } + } + return count; +} + static bool is_internal_port(const char *type) { @@ -370,7 +401,12 @@ del_ufid_tc_mapping_unlocked(const ovs_u128 *ufid) hmap_remove(&ufid_to_tc, &data->ufid_to_tc_node); hmap_remove(&tc_to_ufid, &data->tc_to_ufid_node); netdev_close(data->netdev); - sgid_free(data->sample_group_id[0]); + for (int i = 0; i < MAX_TC_SAMPLES_PER_FLOW; i++) { + if (!data->sample_group_id[i]) { + break; + } + sgid_free(data->sample_group_id[i]); + } free(data); } @@ -426,10 +462,12 @@ del_filter_and_ufid_mapping(struct tcf_id *id, const ovs_u128 *ufid, /* Add ufid entry to ufid_to_tc hashmap. */ static void add_ufid_tc_mapping(struct netdev *netdev, const ovs_u128 *ufid, - struct tcf_id *id, struct dpif_flow_stats *stats) + struct tcf_id *id, struct dpif_flow_stats *stats, + struct tc_flower *flower) { struct ufid_tc_data *new_data = xzalloc(sizeof *new_data); size_t ufid_hash = hash_bytes(ufid, sizeof *ufid, 0); + const struct tc_action *action = flower->actions; size_t tc_hash; tc_hash = hash_int(hash_int(id->prio, id->handle), id->ifindex); @@ -442,6 +480,15 @@ add_ufid_tc_mapping(struct netdev *netdev, const ovs_u128 *ufid, new_data->adjust_stats = *stats; } + for (int i = 0, si = 0; i < flower->action_count; i++, action++) { + if (action->type == TC_ACT_SAMPLE && action->sample.group_id) { + new_data->sample_group_id[si++] = action->sample.group_id; + if (si >= MAX_TC_SAMPLES_PER_FLOW) { + break; + } + } + } + ovs_mutex_lock(&ufid_lock); hmap_insert(&ufid_to_tc, &new_data->ufid_to_tc_node, ufid_hash); hmap_insert(&tc_to_ufid, &new_data->tc_to_ufid_node, tc_hash); @@ -908,6 +955,19 @@ parse_tc_flower_to_actions__(struct tc_flower *flower, struct ofpbuf *buf, action = &flower->actions[i]; switch (action->type) { + case TC_ACT_SAMPLE: { + const struct sgid_node *node; + + node = sgid_find(action->sample.group_id); + if (!node) { + VLOG_WARN("Can't find sample group ID data for ID: %u", + action->sample.group_id); + return ENOENT; + } + nl_msg_put(buf, node->sample.action, + node->sample.action->nla_len); + } + break; case TC_ACT_VLAN_POP: { nl_msg_put_flag(buf, OVS_ACTION_ATTR_POP_VLAN); } @@ -2023,11 +2083,164 @@ parse_match_ct_state_to_flower(struct tc_flower *flower, struct match *match) } } +static int +parse_userspace_attributes(const struct nlattr *actions, + struct offload_sample *sample) +{ + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20); + const struct nlattr *nla; + unsigned int left; + + NL_NESTED_FOR_EACH_UNSAFE (nla, left, actions) { + if (nl_attr_type(nla) == OVS_USERSPACE_ATTR_USERDATA) { + struct user_action_cookie cookie; + + memcpy(&cookie, nl_attr_get_unspec(nla, sizeof cookie), + sizeof cookie); + if (cookie.type == USER_ACTION_COOKIE_SFLOW) { + sample->type = USER_ACTION_COOKIE_SFLOW; + sample->userdata = CONST_CAST(struct nlattr *, nla); + return 0; + } + } + } + + VLOG_DBG_RL(&rl, "Can't offload userspace action other than sFlow"); + return EOPNOTSUPP; +} + +static int +parse_sample_actions_attribute(const struct nlattr *actions, + struct offload_sample *sample) +{ + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20); + const struct nlattr *nla; + unsigned int left; + int err = EINVAL; + + NL_NESTED_FOR_EACH_UNSAFE (nla, left, actions) { + if (nl_attr_type(nla) == OVS_ACTION_ATTR_USERSPACE) { + err = parse_userspace_attributes(nla, sample); + } else { + /* We can't offload other nested actions. */ + VLOG_DBG_RL(&rl, "Can only offload OVS_ACTION_ATTR_USERSPACE" + " attribute"); + return EINVAL; + } + } + + if (err) { + VLOG_ERR_RL(&error_rl, "No OVS_ACTION_ATTR_USERSPACE attribute"); + } + return err; +} + +static void +offload_sample_init(struct offload_sample *sample, + const struct nlattr *next_actions, + size_t next_actions_len, + struct tc_flower *flower, + const struct flow_tnl *tnl) +{ + memset(sample, 0, sizeof *sample); + if (flower->tunnel) { + sample->tunnel = CONST_CAST(struct flow_tnl *, tnl); + } + + sample->userspace_actions = xmalloc(next_actions_len + NLA_HDRLEN); + nullable_memcpy((char *) sample->userspace_actions + NLA_HDRLEN, + next_actions, next_actions_len); + sample->userspace_actions->nla_len = next_actions_len + NLA_HDRLEN; + sample->ifindex = flower->ifindex; +} + +static int +parse_sample_action(struct tc_flower *flower, struct tc_action *tc_action, + const struct nlattr *next_actions, size_t next_actions_len, + const struct nlattr *sample_action, + const struct flow_tnl *tnl) +{ + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20); + struct offload_sample sample; + const struct nlattr *nla; + unsigned int left; + uint32_t rate = 0; + int ret = EINVAL; + uint32_t sgid; + + offload_sample_init(&sample, next_actions, next_actions_len, flower, tnl); + sample.action = CONST_CAST(struct nlattr *, sample_action); + + NL_NESTED_FOR_EACH_UNSAFE (nla, left, sample_action) { + if (nl_attr_type(nla) == OVS_SAMPLE_ATTR_ACTIONS) { + ret = parse_sample_actions_attribute(nla, &sample); + } else if (nl_attr_type(nla) == OVS_SAMPLE_ATTR_PROBABILITY) { + rate = UINT32_MAX / nl_attr_get_u32(nla); + } else { + return EINVAL; + } + } + + /* This check makes sure both attributes above were present and valid. */ + if (!rate || ret) { + return EINVAL; + } + + sgid = sgid_alloc(&sample); + if (!sgid) { + VLOG_DBG_RL(&rl, "Failed allocating group id for sample action"); + return ENOENT; + } + + tc_action->type = TC_ACT_SAMPLE; + tc_action->sample.rate = rate; + tc_action->sample.group_id = sgid; + flower->action_count++; + + return 0; +} + +static int +parse_userspace_action(struct tc_flower *flower, struct tc_action *tc_action, + const struct nlattr *next_actions, + size_t next_actions_len, + const struct nlattr *userspace_action, + const struct flow_tnl *tnl) +{ + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20); + struct offload_sample sample; + uint32_t sgid; + int err; + + offload_sample_init(&sample, next_actions, next_actions_len, flower, tnl); + + /* If sampling rate is 1, there is only a sFlow cookie inside of a + * userspace action, but no sample attribute. That means we can + * only offload userspace actions for sFlow. */ + err = parse_userspace_attributes(userspace_action, &sample); + if (err) { + return err; + } + sample.action = (struct nlattr *) userspace_action; + sgid = sgid_alloc(&sample); + if (!sgid) { + VLOG_DBG_RL(&rl, "Failed allocating group id for sample action"); + return ENOENT; + } + tc_action->type = TC_ACT_SAMPLE; + tc_action->sample.group_id = sgid; + tc_action->sample.rate = 1; + flower->action_count++; + + return 0; +} static int parse_check_pkt_len_action(struct netdev *netdev, struct tc_flower *flower, - struct offload_info *info, struct tc_action *action, - const struct nlattr *nla, bool last_action, + struct offload_info *info, + const struct flow_tnl *tnl, + struct tc_action *action, const struct nlattr *nla, + bool last_action, struct tc_action **need_jump_update, bool *recirc_act) { @@ -2066,7 +2279,7 @@ parse_check_pkt_len_action(struct netdev *netdev, struct tc_flower *flower, * NOTE: The last_action parameter means that there are no more actions * after the if () then ... else () case. */ nl_actions = a[OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_GREATER]; - err = netdev_tc_parse_nl_actions(netdev, flower, info, + err = netdev_tc_parse_nl_actions(netdev, flower, info, tnl, nl_attr_get(nl_actions), nl_attr_get_size(nl_actions), recirc_act, !last_action, @@ -2082,7 +2295,7 @@ parse_check_pkt_len_action(struct netdev *netdev, struct tc_flower *flower, /* Parse and add the less than action(s). */ nl_actions = a[OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_LESS_EQUAL]; - err = netdev_tc_parse_nl_actions(netdev, flower, info, + err = netdev_tc_parse_nl_actions(netdev, flower, info, tnl, nl_attr_get(nl_actions), nl_attr_get_size(nl_actions), recirc_act, !last_action, @@ -2135,6 +2348,7 @@ parse_check_pkt_len_action(struct netdev *netdev, struct tc_flower *flower, static int netdev_tc_parse_nl_actions(struct netdev *netdev, struct tc_flower *flower, struct offload_info *info, + const struct flow_tnl *tnl, const struct nlattr *actions, size_t actions_len, bool *recirc_act, bool more_actions, struct tc_action **need_jump_update) @@ -2264,7 +2478,8 @@ netdev_tc_parse_nl_actions(struct netdev *netdev, struct tc_flower *flower, action->police.index = police_index; flower->action_count++; } else if (nl_attr_type(nla) == OVS_ACTION_ATTR_CHECK_PKT_LEN) { - err = parse_check_pkt_len_action(netdev, flower, info, action, nla, + err = parse_check_pkt_len_action(netdev, flower, info, tnl, + action, nla, nl_attr_len_pad(nla, left) >= left && !more_actions, @@ -2273,14 +2488,28 @@ netdev_tc_parse_nl_actions(struct netdev *netdev, struct tc_flower *flower, if (err) { return err; } - } else if (nl_attr_type(nla) == OVS_ACTION_ATTR_SAMPLE) { - struct offload_sample sample; - uint32_t sgid; - - memset(&sample, 0, sizeof sample); - sgid = sgid_alloc(&sample); - sgid_free(sgid); - return EOPNOTSUPP; + } else if (nl_attr_type(nla) == OVS_ACTION_ATTR_SAMPLE || + nl_attr_type(nla) == OVS_ACTION_ATTR_USERSPACE) { + if (!psample_supported()) { + VLOG_DBG_RL(&rl, "Unsupported put action type: %d, psample is " + "not initialized successfully", nl_attr_type(nla)); + return EOPNOTSUPP; + } + if (get_flower_sgid_count(flower) >= MAX_TC_SAMPLES_PER_FLOW) { + VLOG_ERR_RL(&error_rl, "Only %u TC_SAMPLE action per " + "flow is supported", MAX_TC_SAMPLES_PER_FLOW); + return EOPNOTSUPP; + } + if (nl_attr_type(nla) == OVS_ACTION_ATTR_SAMPLE) { + err = parse_sample_action(flower, action, actions, actions_len, + nla, tnl); + } else { + err = parse_userspace_action(flower, action, actions, + actions_len, nla, tnl); + } + if (err) { + return err; + } } else { VLOG_DBG_RL(&rl, "unsupported put action type: %d", nl_attr_type(nla)); @@ -2320,6 +2549,7 @@ netdev_tc_flow_put(struct netdev *netdev, struct match *match, } memset(&flower, 0, sizeof flower); + flower.ifindex = ifindex; chain = key->recirc_id; mask->recirc_id = 0; @@ -2585,16 +2815,17 @@ netdev_tc_flow_put(struct netdev *netdev, struct match *match, } /* Parse all (nested) actions. */ - err = netdev_tc_parse_nl_actions(netdev, &flower, info, + err = netdev_tc_parse_nl_actions(netdev, &flower, info, tnl, actions, actions_len, &recirc_act, false, NULL); if (err) { - return err; + goto error_out; } if ((chain || recirc_act) && !info->recirc_id_shared_with_tc) { VLOG_DBG_RL(&rl, "flow_put: recirc_id sharing not supported"); - return EOPNOTSUPP; + err = EOPNOTSUPP; + goto error_out; } memset(&adjust_stats, 0, sizeof adjust_stats); @@ -2608,7 +2839,8 @@ netdev_tc_flow_put(struct netdev *netdev, struct match *match, prio = get_prio_for_tc_flower(&flower); if (prio == 0) { VLOG_ERR_RL(&rl, "couldn't get tc prio: %s", ovs_strerror(ENOSPC)); - return ENOSPC; + err = ENOSPC; + goto error_out; } flower.act_cookie.data = ufid; @@ -2617,14 +2849,20 @@ netdev_tc_flow_put(struct netdev *netdev, struct match *match, block_id = get_block_id_from_netdev(netdev); id = tc_make_tcf_id_chain(ifindex, block_id, chain, prio, hook); err = tc_replace_flower(&id, &flower); - if (!err) { - if (stats) { - memset(stats, 0, sizeof *stats); - netdev_tc_adjust_stats(stats, &adjust_stats); - } - add_ufid_tc_mapping(netdev, ufid, &id, &adjust_stats); + if (err) { + goto error_out; } + if (stats) { + memset(stats, 0, sizeof *stats); + netdev_tc_adjust_stats(stats, &adjust_stats); + } + + add_ufid_tc_mapping(netdev, ufid, &id, &adjust_stats, &flower); + return 0; + +error_out: + free_all_flower_sgids(&flower); return err; } diff --git a/lib/tc.c b/lib/tc.c index 270dc95ce..361914525 100644 --- a/lib/tc.c +++ b/lib/tc.c @@ -23,14 +23,15 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include -#include #include #include #include @@ -1487,6 +1488,38 @@ nl_parse_act_police(const struct nlattr *options, struct tc_flower *flower) return 0; } +static const struct nl_policy sample_policy[] = { + [TCA_SAMPLE_PARMS] = { .type = NL_A_UNSPEC, + .min_len = sizeof(struct tc_sample), + .optional = false, }, + [TCA_SAMPLE_PSAMPLE_GROUP] = { .type = NL_A_U32, + .optional = false, }, + [TCA_SAMPLE_RATE] = { .type = NL_A_U32, + .optional = false, }, +}; + +static int +nl_parse_act_sample(struct nlattr *options, struct tc_flower *flower) +{ + struct nlattr *sample_attrs[ARRAY_SIZE(sample_policy)]; + struct tc_action *action; + + if (!nl_parse_nested(options, sample_policy, sample_attrs, + ARRAY_SIZE(sample_policy))) { + VLOG_ERR_RL(&error_rl, "Failed to parse sample action options"); + return EPROTO; + } + + action = &flower->actions[flower->action_count++]; + action->type = TC_ACT_SAMPLE; + action->sample.group_id = + nl_attr_get_u32(sample_attrs[TCA_SAMPLE_PSAMPLE_GROUP]); + action->sample.rate = + nl_attr_get_u32(sample_attrs[TCA_SAMPLE_RATE]); + + return 0; +} + static const struct nl_policy mirred_policy[] = { [TCA_MIRRED_PARMS] = { .type = NL_A_UNSPEC, .min_len = sizeof(struct tc_mirred), @@ -2002,6 +2035,8 @@ nl_parse_single_action(struct nlattr *action, struct tc_flower *flower, nl_parse_act_ct(act_options, flower); } else if (!strcmp(act_kind, "police")) { nl_parse_act_police(act_options, flower); + } else if (!strcmp(act_kind, "sample")) { + nl_parse_act_sample(act_options, flower); } else { VLOG_ERR_RL(&error_rl, "unknown tc action kind: %s", act_kind); err = EINVAL; @@ -2804,6 +2839,24 @@ nl_msg_put_act_mirred(struct ofpbuf *request, int ifindex, int action, nl_msg_end_nested(request, offset); } +static void +nl_msg_put_act_sample(struct ofpbuf *request, uint32_t rate, uint32_t group_id, + uint32_t action_pc) +{ + size_t offset; + + nl_msg_put_string(request, TCA_ACT_KIND, "sample"); + offset = nl_msg_start_nested(request, TCA_ACT_OPTIONS | NLA_F_NESTED); + { + struct tc_sample parm = { .action = action_pc }; + + nl_msg_put_unspec(request, TCA_SAMPLE_PARMS, &parm, sizeof parm); + nl_msg_put_u32(request, TCA_SAMPLE_RATE, rate); + nl_msg_put_u32(request, TCA_SAMPLE_PSAMPLE_GROUP, group_id); + } + nl_msg_end_nested(request, offset); +} + static inline void nl_msg_put_act_cookie(struct ofpbuf *request, struct tc_cookie *ck) { if (ck->len) { @@ -3116,6 +3169,7 @@ get_action_index_for_tc_actions(struct tc_flower *flower, uint16_t act_index, case TC_ACT_MPLS_SET: case TC_ACT_GOTO: case TC_ACT_CT: + case TC_ACT_SAMPLE: /* Increase act_index by one if we are sure this type of action * will only add one tc action in the kernel. */ act_index++; @@ -3323,6 +3377,13 @@ nl_msg_put_flower_acts(struct ofpbuf *request, struct tc_flower *flower) nl_msg_end_nested(request, act_offset); } break; + case TC_ACT_SAMPLE: { + act_offset = nl_msg_start_nested(request, act_index++); + nl_msg_put_act_sample(request, action->sample.rate, + action->sample.group_id, action_pc); + nl_msg_end_nested(request, act_offset); + } + break; case TC_ACT_OUTPUT: { if (!released && flower->tunnel) { nl_msg_put_flower_acts_release(request, act_index++); diff --git a/lib/tc.h b/lib/tc.h index cdd3b4f60..5f6e15d5c 100644 --- a/lib/tc.h +++ b/lib/tc.h @@ -192,6 +192,7 @@ enum tc_action_type { TC_ACT_CT, TC_ACT_POLICE, TC_ACT_POLICE_MTU, + TC_ACT_SAMPLE, }; enum nat_type { @@ -283,6 +284,10 @@ struct tc_action { uint32_t result_jump; uint16_t mtu; } police; + struct { + uint32_t rate; + uint32_t group_id; + } sample; }; enum tc_action_type type; @@ -380,6 +385,7 @@ struct tc_flower { enum tc_offloaded_state offloaded_state; /* Used to force skip_hw when probing tc features. */ enum tc_offload_policy tc_policy; + uint16_t ifindex; }; int tc_replace_flower(struct tcf_id *id, struct tc_flower *flower); From patchwork Mon Jun 19 05:05:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Mi X-Patchwork-Id: 1796318 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=B1fN0HBB; dkim-atps=neutral Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QkySQ01KDz20Wk for ; Mon, 19 Jun 2023 15:07:33 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 88E1882033; Mon, 19 Jun 2023 05:07:31 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 88E1882033 Authentication-Results: smtp1.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=B1fN0HBB X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8CK2ABGZ9ZVR; Mon, 19 Jun 2023 05:07:25 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTPS id 895C18202B; Mon, 19 Jun 2023 05:07:23 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 895C18202B Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4A5E9C008C; Mon, 19 Jun 2023 05:07:23 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 5F88AC0029 for ; Mon, 19 Jun 2023 05:07:22 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 1675540BB7 for ; Mon, 19 Jun 2023 05:06:42 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 1675540BB7 Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=B1fN0HBB X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MpI4HUL_gvwX for ; Mon, 19 Jun 2023 05:06:40 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 28C40409A6 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on20612.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e88::612]) by smtp2.osuosl.org (Postfix) with ESMTPS id 28C40409A6 for ; Mon, 19 Jun 2023 05:06:40 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F323vJn2B9SPtHXZg+YSg0UHE8W9ry7jTJt+yjVKJ5bEFBhHPNbg/mzmd45S9y6uvl831vreOFYYPXlY7liTEODun7VKIF2EpomxW2RwGZzsX6F4HP1iyAYAbmNcM8B1ev6lVB9ZaKt/i6G2XWuQQ+rn+ZXnlzAwv1wsP86wynrCA2/6oQAK95cqUcaTlmaXK/zqQ/V2frs9Wizd+9GuQbVE0cWEXb5tbetpvITFwkxWjDve5/+A7rfOB6RYqtOjMPyQLW4ukEpO0e7lsf2k0EjSHiUvUq0rTuvayAsaGPDs0qaNeYqoKZM1HrPrpzeF+VnQJMjUu7XR1m5oiWSZYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Ki7yTTVOWK4Z6v+oVYwk3gQwoG7g+L3THFgN+yPJxL4=; b=DTqfZeNexUE2y6YgnFJspxpKckHy/O8gX2/seqnvzXE78EqSjam8bKvMwikFwWUrDsfiV4sF7igvp7xVtJShzt7ooFj5iEzl+q/v/BEVZwmoBa754+rwQMt4bi1k916nnWvYPkKH0fuwmVa6MZpK/+gbDf2l6ayuzav96JT6fTHHA8n+eky5rOlCCPxA1A7knyaYP4nswNhyIUAitjQ9Xd0EzlyoEkoAmH64I7omu9ClnL8+9ayBvpgmxU9SHoMnI1POFrrw9iqC/EHxtLM0Hq7rIvyDedXRZIycrjuHJipZTEGBGpmNPaPZubNl0vDpEKf35oaX5N5MFIrLtKAUAQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=openvswitch.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ki7yTTVOWK4Z6v+oVYwk3gQwoG7g+L3THFgN+yPJxL4=; b=B1fN0HBBR/T540fkngrarTDYztQ0OqFPYKHjOl07SqnaJgfUdabeU7K3r4NGO51SHLUi8Q8mPDRRog3MFeK6FiopnPaopdL+TP37qDureQABGebi2FFIpoxXpErsXE3qDhqrYYJzvoRwvC3sonnl2jEhuafwqRo+WekWoYFuyVUbx0BhnMY1sGRPQERl4Op/9zb+9eAlvB5cDlmeLA76OGRDH4q0Q1x+7e01iaS+wy5F+lAZtpEys2fhAaAt83jc9SClPHjgfMSJ9WsnVAZtpMgojDiPuQ00Inb+y1frTl0IaCQX0b8595O/R6vCEkzcD1rGRNB8gZjYYyRBWdqnlw== Received: from BN1PR12CA0003.namprd12.prod.outlook.com (2603:10b6:408:e1::8) by BL0PR12MB5507.namprd12.prod.outlook.com (2603:10b6:208:1c4::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.36; Mon, 19 Jun 2023 05:06:37 +0000 Received: from BN8NAM11FT023.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e1:cafe::a4) by BN1PR12CA0003.outlook.office365.com (2603:10b6:408:e1::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.36 via Frontend Transport; Mon, 19 Jun 2023 05:06:37 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by BN8NAM11FT023.mail.protection.outlook.com (10.13.177.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.36 via Frontend Transport; Mon, 19 Jun 2023 05:06:37 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Sun, 18 Jun 2023 22:06:30 -0700 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Sun, 18 Jun 2023 22:06:29 -0700 Received: from c-237-115-160-164.mtl.labs.mlnx (10.127.8.13) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Sun, 18 Jun 2023 22:06:27 -0700 To: Date: Mon, 19 Jun 2023 08:05:57 +0300 Message-ID: <20230619050557.310690-9-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230619050557.310690-1-cmi@nvidia.com> References: <20230619050557.310690-1-cmi@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT023:EE_|BL0PR12MB5507:EE_ X-MS-Office365-Filtering-Correlation-Id: eee6412e-ff6f-45c0-5b8d-08db7082f5be X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QIXoQCIdKSJgbKbSPI+Vj3m+nMDDOrzTw7OWZYjd8gR3CL7+HHr38AIde20J5c280PcG1nRjTt5A/I7yZWq3yZxGDpWzX2FXBFmjK46ZdkMP2hvGWcN3R3Dba9asDOZFi1M7XYTwJQ5AM2st/qrwmkvz2C3K2q2GplYS1bMh9yY+a5ljxqZM9LTcyBuKbHyz4Tc+C7qrmdkGzjRqhdlWC+IbMuxF/tJttETi9+PVjUamP/+lRC7TWzQRUQq3HrIvaHxjpvgBCXipVCruDntAXV0dBcb80VudeYQK7o99ThUXj1WkwenUyVT9Pxgj7mK+6zsqvVIaWUBSyGBpTD5gb6Z3xLAGbvTeYoqUuXdshcsrNDRZQmFfiGJ1Bg1yW65G1Q09q8UethxQZeXo6TES5t1v4fklGulJ9MxzrvHU1E0ul6YsP3YaH1v/FMDgokTI957SkW6aJ5DO+xw4WOQmc6cXcTT5zFVifO97DTQn5El4gjB8XNaKByDOzs8+x14zinlNrmW16nkLV7p6hTqk9W0MSaUof5t1Yw7b39FdLTJbhNxG6INVpqLxL7u/QZn1NuHcw9Jowt9/XQ1m1O/owm72lZmHsAjAuFAoVvQ/GxCrJMt2bSubMVeyWWoq+poqvlZc5+et802ymsErVNvi4jCDfcepVZRbdZ5bl/nAsOed/UtGxa1zJKBRMFGTcsYM6joOlSDh6J2FDfgO27V8Jw== X-Forefront-Antispam-Report: CIP:216.228.118.232; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge1.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(346002)(39850400004)(396003)(136003)(376002)(451199021)(36840700001)(46966006)(4326008)(478600001)(54906003)(1076003)(26005)(107886003)(186003)(40480700001)(6666004)(36756003)(30864003)(2906002)(8676002)(41300700001)(8936002)(70206006)(70586007)(6916009)(316002)(5660300002)(82310400005)(86362001)(83380400001)(47076005)(426003)(336012)(7636003)(356005)(2616005)(36860700001)(82740400003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2023 05:06:37.2134 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: eee6412e-ff6f-45c0-5b8d-08db7082f5be X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.232]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT023.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB5507 Cc: elibr@nvidia.com, simon.horman@corigine.com, roniba@nvidia.com, i.maximets@ovn.org, konguyen@redhat.com, majd@nvidia.com, maord@nvidia.com Subject: [ovs-dev] [PATCH v28 8/8] system-offloads-traffic.at: Add sFlow offload test cases X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Chris Mi via dev From: Chris Mi Reply-To: Chris Mi Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Add three sFlow offload test cases: 3: offloads - sflow with sampling=1 - offloads enabled ok 4: offloads - sflow with sampling=2 - offloads enabled ok 5: offloads - ping over vxlan tunnel with sflow - offloads enabled ok Signed-off-by: Chris Mi Reviewed-by: Roi Dayan Acked-by: Eelco Chaudron Acked-by: Eelco Chaudron --- Documentation/howto/tc-offload.rst | 24 +++++ tests/system-common-macros.at | 13 +++ tests/system-offloads-traffic.at | 160 +++++++++++++++++++++++++++++ 3 files changed, 197 insertions(+) diff --git a/Documentation/howto/tc-offload.rst b/Documentation/howto/tc-offload.rst index 681dff13e..a50dc3c58 100644 --- a/Documentation/howto/tc-offload.rst +++ b/Documentation/howto/tc-offload.rst @@ -88,6 +88,30 @@ As you can see above the none-offload case reports 140 bytes more, which is 14 bytes per packet. This represents the L2 header, in this case, 2 * *Ethernet address* + *Ethertype*. +Tunnel offload +++++++++++++++ + +Current tunnel offload ignores DF and CSUM flags configuration requested by +the user. TC for now has no way to pass these flags in a flower key and their +masks are set by default. To make tunnel offload work, DF and CSUM flags +are cleared. So please be aware of the following differences. + +Dumping vxlan decap match without offload, it shows:: + + recirc_id(0),tunnel(tun_id=0x4,src=192.168.1.1,dst=192.168.1.2,flags(-df+csum+key)),in_port(vxlan_sys_4789) + +Dumping vxlan decap match with offload, it shows:: + + recirc_id(0),tunnel(tun_id=0x4,src=192.168.1.1,dst=192.168.1.2,tp_dst=4789,flags(+key)),in_port(vxlan_sys_4789) + +Dumping vxlan encap action without offload, it shows:: + + actions:set(tunnel(tun_id=0x4,dst=192.168.1.1,ttl=64,tp_dst=4789,flags(df|key))),vxlan_sys_4789 + +Dumping vxlan encap action with offload, it shows:: + + actions:set(tunnel(tun_id=0x4,dst=192.168.1.64,ttl=64,tp_dst=4789,flags(key))),vxlan_sys_4789 + TC Meter Offload ~~~~~~~~~~~~~~~~ diff --git a/tests/system-common-macros.at b/tests/system-common-macros.at index 0077a8609..55ec0bf1e 100644 --- a/tests/system-common-macros.at +++ b/tests/system-common-macros.at @@ -359,3 +359,16 @@ m4_define([OVS_CHECK_IPROUTE_ENCAP], # OVS_CHECK_CT_CLEAR() m4_define([OVS_CHECK_CT_CLEAR], [AT_SKIP_IF([! grep -q "Datapath supports ct_clear action" ovs-vswitchd.log])]) + +# LOAD_MODULE([name]) +# +# Tries to load specified kernel module and removes it after +# if it wasn't loaded before this call. +# +m4_define([LOAD_MODULE], + [if ! lsmod | grep -q $1; then + on_exit 'modprobe -q -r $1' + fi + AT_CHECK([modprobe $1]) + ] +) \ No newline at end of file diff --git a/tests/system-offloads-traffic.at b/tests/system-offloads-traffic.at index ae302a294..db287a86d 100644 --- a/tests/system-offloads-traffic.at +++ b/tests/system-offloads-traffic.at @@ -93,6 +93,166 @@ AT_CHECK([ovs-appctl upcall/show | grep -E "offloaded flows : [[1-9]]"], [0], [i OVS_TRAFFIC_VSWITCHD_STOP AT_CLEANUP + +AT_SETUP([offloads - sflow with sampling=1 - offloads enabled]) +LOAD_MODULE([psample]) +OVS_TRAFFIC_VSWITCHD_START([], [], [-- set Open_vSwitch . other_config:hw-offload=true]) + +on_exit 'kill `cat test-sflow.pid`' +AT_CHECK([ovstest test-sflow --log-file --detach --no-chdir --pidfile 0:127.0.0.1 > sflow.log], [0], [], [ignore]) +AT_CAPTURE_FILE([sflow.log]) +PARSE_LISTENING_PORT([test-sflow.log], [SFLOW_PORT]) + +AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"]) + +ADD_NAMESPACES(at_ns0, at_ns1) +ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") +ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") + +AT_CHECK([ovs-vsctl -- --id=@sflow create sflow agent=lo target=\"127.0.0.1:$SFLOW_PORT\" header=128 sampling=1 polling=100 -- set bridge br0 sflow=@sflow], [0], [ignore]) +NS_CHECK_EXEC([at_ns0], [ping -q -c 1000 -i 0.01 -w 12 10.1.1.2 | FORMAT_PING], [0], [dnl +1000 packets transmitted, 1000 received, 0% packet loss, time 0ms +]) + +p1_ifindex=$(cat /sys/class/net/ovs-p1/ifindex) +m4_define([DUMP_SFLOW], [sed -e "s/used:[[0-9]].[[0-9]]*s/used:0.001s/;s/eth(src=[[a-z0-9:]]*,dst=[[a-z0-9:]]*)/eth(macs)/;s/pid=[[0-9]]*/pid=1/;s/output=$p1_ifindex/output=1/"]) +AT_CHECK([ovs-appctl dpctl/dump-flows type=tc,offloaded | grep "in_port(2)" | grep "eth_type(0x0800)" | grep "actions:userspace" | grep "sFlow" | DUMP_SFLOW], [0], [dnl +recirc_id(0),in_port(2),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:999, bytes:83916, used:0.001s, actions:userspace(pid=1,sFlow(vid=0,pcp=0,output=1),actions),3 +]) + +p0_ifindex=$(cat /sys/class/net/ovs-p0/ifindex) +m4_define([DUMP_SFLOW], [sed -e "s/used:[[0-9]].[[0-9]]*s/used:0.001s/;s/eth(src=[[a-z0-9:]]*,dst=[[a-z0-9:]]*)/eth(macs)/;s/pid=[[0-9]]*/pid=1/;s/output=$p0_ifindex/output=1/"]) +AT_CHECK([ovs-appctl dpctl/dump-flows type=tc,offloaded | grep "in_port(3)" | grep "eth_type(0x0800)" | grep "actions:userspace" | grep "sFlow" | DUMP_SFLOW], [0], [dnl +recirc_id(0),in_port(3),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:999, bytes:83916, used:0.001s, actions:userspace(pid=1,sFlow(vid=0,pcp=0,output=1),actions),2 +]) + +hdr="in_ifindex=$p0_ifindex in_format=0 out_ifindex=$p1_ifindex out_format=0 hdr_prot=1 pkt_len=102 stripped=4 hdr_len=98" +count=`grep "$hdr" sflow.log | wc -l` +AT_CHECK([[[[ $count -ge 996 ]]]]) +hdr="in_ifindex=$p1_ifindex in_format=0 out_ifindex=$p0_ifindex out_format=0 hdr_prot=1 pkt_len=102 stripped=4 hdr_len=98" +count=`grep "$hdr" sflow.log | wc -l` +AT_CHECK([[[[ $count -ge 996 ]]]]) + +OVS_TRAFFIC_VSWITCHD_STOP +OVS_APP_EXIT_AND_WAIT([test-sflow]) +AT_CLEANUP + + +AT_SETUP([offloads - sflow with sampling=2 - offloads enabled]) +LOAD_MODULE([psample]) +OVS_TRAFFIC_VSWITCHD_START([], [], [-- set Open_vSwitch . other_config:hw-offload=true]) + +on_exit 'kill `cat test-sflow.pid`' +AT_CHECK([ovstest test-sflow --log-file --detach --no-chdir --pidfile 0:127.0.0.1 > sflow.log], [0], [], [ignore]) +AT_CAPTURE_FILE([sflow.log]) +PARSE_LISTENING_PORT([test-sflow.log], [SFLOW_PORT]) + +AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"]) + +ADD_NAMESPACES(at_ns0, at_ns1) +ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") +ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") + +AT_CHECK([ovs-vsctl -- --id=@sflow create sflow agent=lo target=\"127.0.0.1:$SFLOW_PORT\" header=128 sampling=2 polling=100 -- set bridge br0 sflow=@sflow], [0], [ignore]) +NS_CHECK_EXEC([at_ns0], [ping -q -c 1000 -i 0.01 -w 12 10.1.1.2 | FORMAT_PING], [0], [dnl +1000 packets transmitted, 1000 received, 0% packet loss, time 0ms +]) + +p1_ifindex=$(cat /sys/class/net/ovs-p1/ifindex) +m4_define([DUMP_SFLOW], [sed -e "s/used:[[0-9]].[[0-9]]*s/used:0.001s/;s/eth(src=[[a-z0-9:]]*,dst=[[a-z0-9:]]*)/eth(macs)/;s/pid=[[0-9]]*/pid=1/;s/output=$p1_ifindex/output=1/"]) +AT_CHECK([ovs-appctl dpctl/dump-flows type=tc,offloaded | grep "in_port(2)" | grep "eth_type(0x0800)" | grep "actions:sample" | grep "sFlow" | DUMP_SFLOW], [0], [dnl +recirc_id(0),in_port(2),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:999, bytes:83916, used:0.001s, actions:sample(sample=50.0%,actions(userspace(pid=1,sFlow(vid=0,pcp=0,output=1),actions))),3 +]) + +p0_ifindex=$(cat /sys/class/net/ovs-p0/ifindex) +m4_define([DUMP_SFLOW], [sed -e "s/used:[[0-9]].[[0-9]]*s/used:0.001s/;s/eth(src=[[a-z0-9:]]*,dst=[[a-z0-9:]]*)/eth(macs)/;s/pid=[[0-9]]*/pid=1/;s/output=$p0_ifindex/output=1/"]) +AT_CHECK([ovs-appctl dpctl/dump-flows type=tc,offloaded | grep "in_port(3)" | grep "eth_type(0x0800)" | grep "actions:sample" | grep "sFlow" | DUMP_SFLOW], [0], [dnl +recirc_id(0),in_port(3),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:999, bytes:83916, used:0.001s, actions:sample(sample=50.0%,actions(userspace(pid=1,sFlow(vid=0,pcp=0,output=1),actions))),2 +]) + +hdr="in_ifindex=$p0_ifindex in_format=0 out_ifindex=$p1_ifindex out_format=0 hdr_prot=1 pkt_len=102 stripped=4 hdr_len=98" +count=`grep "$hdr" sflow.log | wc -l` +AT_CHECK([[[[ $count -le 550 && $count -ge 450 ]]]]) +hdr="in_ifindex=$p1_ifindex in_format=0 out_ifindex=$p0_ifindex out_format=0 hdr_prot=1 pkt_len=102 stripped=4 hdr_len=98" +count=`grep "$hdr" sflow.log | wc -l` +AT_CHECK([[[[ $count -le 550 && $count -ge 450 ]]]]) + +OVS_TRAFFIC_VSWITCHD_STOP +OVS_APP_EXIT_AND_WAIT([test-sflow]) +AT_CLEANUP + + +AT_SETUP([offloads - ping over vxlan tunnel with sflow - offloads enabled]) +OVS_CHECK_TUNNEL_TSO() +OVS_CHECK_VXLAN() +LOAD_MODULE([psample]) + +OVS_TRAFFIC_VSWITCHD_START([], [], [-- set Open_vSwitch . other_config:hw-offload=true]) +ADD_BR([br-underlay]) + +AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"]) +AT_CHECK([ovs-ofctl add-flow br-underlay "actions=normal"]) + +ADD_NAMESPACES(at_ns0) + +dnl Set up underlay link from host into the namespace using veth pair. +ADD_VETH(p0, at_ns0, br-underlay, "172.31.1.1/24") +AT_CHECK([ip addr add dev br-underlay "172.31.1.100/24"]) +AT_CHECK([ip link set dev br-underlay up]) + +dnl Set up tunnel endpoints on OVS outside the namespace and with a native +dnl linux device inside the namespace. +ADD_OVS_TUNNEL([vxlan], [br0], [at_vxlan0], [172.31.1.1], [10.1.1.100/24]) +ADD_NATIVE_TUNNEL([vxlan], [at_vxlan1], [at_ns0], [172.31.1.100], [10.1.1.1/24], + [id 0 dstport 4789]) + +on_exit 'kill `cat test-sflow.pid`' +AT_CHECK([ovstest test-sflow --log-file --detach --no-chdir --pidfile 0:127.0.0.1 > sflow.log], [0], [], [ignore]) +AT_CAPTURE_FILE([sflow.log]) +PARSE_LISTENING_PORT([test-sflow.log], [SFLOW_PORT]) +AT_CHECK([ovs-vsctl -- --id=@sflow create sflow agent=lo target=\"127.0.0.1:$SFLOW_PORT\" header=128 sampling=1 polling=100 -- set bridge br0 sflow=@sflow], [0], [ignore]) + +dnl First, check the underlay. +NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 172.31.1.100 | FORMAT_PING], [0], [dnl +3 packets transmitted, 3 received, 0% packet loss, time 0ms +]) + +dnl Okay, now check the overlay. +NS_CHECK_EXEC([at_ns0], [ping -q -c 1000 -i 0.01 10.1.1.100 | FORMAT_PING], [0], [dnl +1000 packets transmitted, 1000 received, 0% packet loss, time 0ms +]) + +vxlan_sys_ifindex=$(cat /sys/class/net/vxlan_sys_4789/ifindex) +br0_ifindex=$(cat /sys/class/net/br0/ifindex) +br0_mac=$(cat /sys/class/net/br0/address) +vxlan1_mac=$(ip netns exec at_ns0 cat /sys/class/net/at_vxlan1/address) + +dnl Check the encap flow. +match="recirc_id(0),in_port(br0),eth(src=$br0_mac,dst=$vxlan1_mac),eth_type(0x0800),ipv4(tos=0/0x3,frag=no)" +action="actions:userspace(pid=4294967295,sFlow(vid=0,pcp=0,output=$vxlan_sys_ifindex),actions),set(tunnel(dst=172.31.1.1,ttl=64,tp_dst=4789,flags(0))),vxlan_sys_4789" +AT_CHECK([ovs-appctl dpctl/dump-flows --names | grep $match | grep $action > /dev/null]) + +dnl Check the decap flow. +match="recirc_id(0),tunnel(tun_id=0x0,src=172.31.1.1,dst=172.31.1.100,tp_dst=4789,flags(+key)),in_port(vxlan_sys_4789),eth(src=$vxlan1_mac,dst=$br0_mac),eth_type(0x0800),ipv4(frag=no)" +action="actions:userspace(pid=4294967295,sFlow(vid=0,pcp=0,output=$br0_ifindex),actions),br0" +AT_CHECK([ovs-appctl dpctl/dump-flows --names | grep $match | grep $action> /dev/null]) + +dnl Vni is 0, test-sflow doesn't show it. +out_tunnel_hdr="tunnel4_out_protocol=17 tunnel4_out_src=0.0.0.0 tunnel4_out_dst=172.31.1.1 tunnel4_out_src_port=0 tunnel4_out_dst_port=46354" +ifindex="in_ifindex=$br0_ifindex in_format=0 out_ifindex=$vxlan_sys_ifindex" +out_count=`grep "$out_tunnel_hdr" sflow.log | grep "$ifindex" | wc -l` +AT_CHECK([[[[ $out_count -ge 999 ]]]]) + +in_tunnel_hdr="tunnel4_in_protocol=17 tunnel4_in_src=172.31.1.1 tunnel4_in_dst=172.31.1.100" +ifindex="in_ifindex=$vxlan_sys_ifindex in_format=0 out_ifindex=$br0_ifindex" +in_count=`grep "$in_tunnel_hdr" sflow.log | grep "$ifindex" | wc -l` +AT_CHECK([[[[ $in_count -ge 999 ]]]]) + +OVS_TRAFFIC_VSWITCHD_STOP +OVS_APP_EXIT_AND_WAIT([test-sflow]) +AT_CLEANUP + + AT_SETUP([offloads - set ingress_policing_rate and ingress_policing_burst - offloads disabled]) AT_KEYWORDS([ingress_policing]) AT_SKIP_IF([test $HAVE_TC = "no"])