From patchwork Wed Mar 29 07:20: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: 1762598 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=d2u55fi+; 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 4PmdK51pSLz1yYr for ; Wed, 29 Mar 2023 18:21:45 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 3D3DA41CB1; Wed, 29 Mar 2023 07:21:43 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 3D3DA41CB1 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=d2u55fi+ 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 0zfaz6eQTgai; Wed, 29 Mar 2023 07:21:41 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp2.osuosl.org (Postfix) with ESMTPS id B1E6941C58; Wed, 29 Mar 2023 07:21:40 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org B1E6941C58 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id B673AC008E; Wed, 29 Mar 2023 07:21:38 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 13B51C002F for ; Wed, 29 Mar 2023 07:21:37 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id E98A6403AA for ; Wed, 29 Mar 2023 07:21:34 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org E98A6403AA 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 CyKe27NAQDK7 for ; Wed, 29 Mar 2023 07:21:33 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org A5FFC40C19 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on20629.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8b::629]) by smtp2.osuosl.org (Postfix) with ESMTPS id A5FFC40C19 for ; Wed, 29 Mar 2023 07:21:33 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CLF8yzNPFRE4QJpSVepdC4IiNXqUkY0Z6QwMFhLLaOhiy85z0cRmbWQYsrPmcn/lrE2oAxmJyhEtysztYegGGFv30o6HrdDDZyJV3YFlie4VnkW0mXlsUn+Fo9aVNjzbnnkyanpfDZk8Q7A4eM0+wLwIzJ6QOyNyvXwMae3HzhSreLnjzZ9HPGRyY+KeEsB871yWOeVTNHW68MwT/0SRgF6IlgP9nNjctGJ2lCJM98B2k+MX9N181/cemNIsY+r69TuQXmyaQfC4OXnrx6Erckoo+kT3mQpdhC4YvlP59oLRQbOfpSNJerh8PatKhurIVdPji9+Ag8HuaATDQbmVeQ== 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=NEDBJVvoiFs/vRKNmWdYJzp0Jx4d5vWBIs1PxLpauUJqrS5IlSQ1oeHzPvS9A0ge13OVl8Y2PRJaGV8JpxSdGbUdRPAbf2UqngWkVRqchbCZ8MwQRfl9pkDimr45YElJWnHdz72lxYaNamTyAdsuPmOh6nlsve22SsqBWogrPVpf8K6xJ/wJc5HmRhRaMcxpjANjlQ6+e1cba6ETULsFKq7si2ofte+mMq6U/VvNf9ty/fqlZ5IwzPZA7oAqL4WFBVjeR0+ncX7ktdaQaOCBdDAOgKBNhPrKcfpDH0PSHjB5gyCi8IUeH/chtYH9iU/Km/cWwvxK/4JeP2a7wravgg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) 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=d2u55fi+nTk8oXTDNs2vRFPApUH/LUQv4PgjVyEC7tTLqXRVAhdb3yOVVilYO7qWL+POjcIiMJN5l8VUrU38UWoxY/uXC5eqCPOp1pUHvPIfzCsV97Ka2NrJlgVthlWwm0CPp0jphWbsxC6oncddNfReQHravbejq0shENupz+qdvVWY+dLGovjq3ZjWUkgaZ36EtGLn67OxBA3UKhJtGbZ+0sZj/6aijAkSj5KhU51SDll/o2Kkt4tuW9TMb28w0iO8BLhfaLbcCuS2TEmzEEqXCV/mw/nUW8DzITfAPdxxS9qiliDySTsE+vpBiVSfKi1aw06M+SfXcnVMiZGZaw== Received: from BL1PR13CA0359.namprd13.prod.outlook.com (2603:10b6:208:2c6::34) by BN9PR12MB5113.namprd12.prod.outlook.com (2603:10b6:408:136::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6222.35; Wed, 29 Mar 2023 07:21:31 +0000 Received: from BL02EPF000100D0.namprd05.prod.outlook.com (2603:10b6:208:2c6:cafe::34) by BL1PR13CA0359.outlook.office365.com (2603:10b6:208:2c6::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.20 via Frontend Transport; Wed, 29 Mar 2023 07:21:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BL02EPF000100D0.mail.protection.outlook.com (10.167.241.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.30 via Frontend Transport; Wed, 29 Mar 2023 07:21:29 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Wed, 29 Mar 2023 00:21:08 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail204.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 29 Mar 2023 00:21:08 -0700 Received: from c-237-115-60-065.mtl.labs.mlnx (10.127.8.10) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.986.5 via Frontend Transport; Wed, 29 Mar 2023 00:21:05 -0700 To: Date: Wed, 29 Mar 2023 10:20:52 +0300 Message-ID: <20230329072059.78569-2-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230329072059.78569-1-cmi@nvidia.com> References: <20230329072059.78569-1-cmi@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF000100D0:EE_|BN9PR12MB5113:EE_ X-MS-Office365-Filtering-Correlation-Id: 96632694-4893-484f-4dbd-08db3026377d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IafBYW3gpYVcUL/K0TP/r2MqTO2EDhADXgZcWZ+6sLrekV4vVbVfe323udSAH8HHBiZl6KO1YocdZHz83blv89Wr+89TJVCs+erksLulVo/UbIX1/fZuwpcrze+s7IvbS07BwYm+3KojKsWYVok1W3ePucjN//LbmHtIBYntfBdrp5wVzXpAj/Uuzo6F1A6dn55P96MBS7o3rFEPXnwL8vFObtcwGIrue4aLwQMYHVUli19Pjt1tecIDNZkX/1xJv98dPyw7C4anxGRzNgHUX6kC+FKxS7r9n9UpQyc65uxkVk2qMsHk6wH4MGs/AZi/4VbHSgraydjrzS4d7mFFslcymaAWfd/ss3ck+87PzAXj43ovlhkSYHEMpgE30BIPFirijLSaFu5DWiMPbrznaC/sB6B4+RIjzH3H74bTWxKYU0jEm8yWWU8SMuJO4ZbUSzhyNqWQOISPNpvttXQibUG8UtAcfwfq7rYoBqTmmaeuObO0nNE+NYCZE/bFoX9A+nEd6CcbAaXS/rklQ2CuHcS1jVaBcpYL5RFt9+DEBMzvjaTTA7QTkTWFw3rPkdAlSEzqvt5t8j/QD8qY+Bhej2i0EBV8B3lRbrp1S1EFMbc6Sf4/0wq9meHPilapx61HBZMpvHurkRDsVaK28mP7BLcxeZU16jt5Y8yiB5qSOtMbdAf04nd+9s0mSE/QHXM1dY5gYMuLF5HmaGvoA8HGtvBox1YApFd10yydYEUH6GdqQhxLeHpDtn3dZ+YZN99K X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(396003)(136003)(346002)(39860400002)(376002)(451199021)(46966006)(40470700004)(36840700001)(83380400001)(1076003)(26005)(6666004)(82740400003)(107886003)(7636003)(356005)(82310400005)(478600001)(54906003)(316002)(36756003)(70206006)(70586007)(8676002)(86362001)(40480700001)(6916009)(4326008)(41300700001)(2616005)(47076005)(8936002)(5660300002)(40460700003)(336012)(2906002)(426003)(36860700001)(186003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Mar 2023 07:21:29.9031 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 96632694-4893-484f-4dbd-08db3026377d X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF000100D0.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5113 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 v25 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 Wed Mar 29 07:20: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: 1762597 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=GuDF1kHS; 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 4PmdK1564sz1yYr for ; Wed, 29 Mar 2023 18:21:41 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id CB91E84084; Wed, 29 Mar 2023 07:21:39 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org CB91E84084 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=GuDF1kHS 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 MlfhWKrBCwXK; Wed, 29 Mar 2023 07:21:39 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 0BFA984074; Wed, 29 Mar 2023 07:21:37 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 0BFA984074 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id C5F8FC002F; Wed, 29 Mar 2023 07:21:37 +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 13118C0037 for ; Wed, 29 Mar 2023 07:21:36 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id B19AC41D86 for ; Wed, 29 Mar 2023 07:21:35 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org B19AC41D86 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=GuDF1kHS 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 twr4QiQdia2Y for ; Wed, 29 Mar 2023 07:21:34 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 6788741D84 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on20628.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eaa::628]) by smtp4.osuosl.org (Postfix) with ESMTPS id 6788741D84 for ; Wed, 29 Mar 2023 07:21:34 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VP8ZlCdXhZ7mTa/z4Wc8MYRRIMmeSl3w3YinVpQswLJjfkqlRnJrkmLAsSl7p6xUK6p/Ed0r/JmQw3pXDN2YmSEQey6ibj4v6ZC/zkCL4Hd178brAXXroJiGmCjeESsdKe3gsrJznROEu1v562QleDwcxe8JT7HezhhosiUYuNdmiCkE6GIyaM1yIbmNCJ8FLwHnzYeEfgQJyuZpgkYp7u1qfGOVxOBgGR7haql0gCfD/0Qf/q6CPVUjCQvTqGvq17EMHDR4L7y/zSNV2uk/o2fsgIUP/hAAcg8t//5EDee2OKb4lLdK1okQ8E/HEi5oip7I3b94sZkO9Obbc6s3Rg== 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=SBy1tC+zQ/W28ChOmbWMF/BnT9QdHPKkQmgaw42rEzQlgkMPgN/pNZyF4UUvYxfEkWK088SPyOzR9TgZOveT/d7JOqRnh8K5t7huwnkQpNlSIMuGPVvJbmC0HntW83q8UJZH/z6faRTEBM0DDjMyDy0/qW7vQphCFC68hOA+eLALvKP+HMpSMbbIeW/zFc8b9rtj7qhW0nykr4tFY/DVj1iyattPYYtdO+qGwCkkBuJlrfWwfyPo7c/jkA9+KKSFMmPtxl1XH/H80V2vEAnvYDl3dh6vs0Jf4cDXDg5poVpDgzU8an+dT82+qIUDiKLW3Ia0HzOozkjLP+Pj0zEfIg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) 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=GuDF1kHSFhe63MK2zZLaEFLaeSX7SUzm8pADS4JaiPAPW+BsRWP1yCUpgnlMMSgbNyWXl0UZzAJHXr4ddf9HUmMEPOc/3UcuMuTXb1Mml8O38b7EQ1xire9jSIju6CNMlWGXnZqCDgekJNvTnQ8Ad0v+UdaRIuCwXASh48gMQS5L9nffRtWkM1T0Ttk9yJ9mBJmfo2vA0TM+SIDtYbn8wwFSeGlAIyon2uyQojNmUlpDntHFbIHFltAkboBieDefM0Sg4gHcGL/7U0kfJwjxvEgFTacmywcF0UmOMrJsGzMc6+vMdsYLlReR54zKpWpqgRQ9OuWDig9/VcRPagkI0Q== Received: from BN0PR03CA0036.namprd03.prod.outlook.com (2603:10b6:408:e7::11) by CH3PR12MB8756.namprd12.prod.outlook.com (2603:10b6:610:17f::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6222.33; Wed, 29 Mar 2023 07:21:31 +0000 Received: from BN8NAM11FT015.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e7:cafe::f3) by BN0PR03CA0036.outlook.office365.com (2603:10b6:408:e7::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.20 via Frontend Transport; Wed, 29 Mar 2023 07:21:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by BN8NAM11FT015.mail.protection.outlook.com (10.13.176.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.20 via Frontend Transport; Wed, 29 Mar 2023 07:21:30 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Wed, 29 Mar 2023 00:21:12 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail204.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 29 Mar 2023 00:21:12 -0700 Received: from c-237-115-60-065.mtl.labs.mlnx (10.127.8.10) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.986.5 via Frontend Transport; Wed, 29 Mar 2023 00:21:09 -0700 To: Date: Wed, 29 Mar 2023 10:20:53 +0300 Message-ID: <20230329072059.78569-3-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230329072059.78569-1-cmi@nvidia.com> References: <20230329072059.78569-1-cmi@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT015:EE_|CH3PR12MB8756:EE_ X-MS-Office365-Filtering-Correlation-Id: 53852b3f-14de-4935-fbf6-08db30263802 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /vD4AR3pHCCEnPQNhnUKc+SbQKTzLdk2JVqAZqproy27iloArojGJiZ4DTHEdN4GkVOKvtCBPCvGBV73pwly8Pq8Qsl2CA8SPsZFok0f0hIsNFpbQnIP7wS9T/aCn2Qo8DmQ0ZCNTkyxssddXD/kRLw8njKq4EukCQzi90v8hyQcuEmDf+zIlKFm9sPFMw3Brw25/HsC3HIEocgurut4mdLQct+llnTK3dLtMd4RJAVHCBYXWhYSUlNOR1pJfhcGw6HOTCOPQXXjjdh23Tr4jGvoGd27V0ZIrRoFOX+jCeOJ7/6BXZAOLO2f/pX9CIM4DzRLVfvsD/KAiuVwVWteemY+K6S6VjI+bJDsrIFV2e0WLlJA6nHXAExN5lFsusKycrKQjRUA5MYlwgeK48xb808S+3QpYhwONsARyWM50DBqOaKl/Q7K3rPn5SQUENkqI6L2QiJldVZXaSBTndKmcIW93RkLZ+E4Bh01XWeDmSDuGisbgWSUMIT7gAAps4QQ+kBz04ya5geB9pTWAi+BVM00Cx7ilvZ7WROXy22gmC8kUkA0ytM0Jvur7SOWU4UjSJJ25pUTwI9YfhtPuwJgVpuOu1Cn9NciIrtxqR67pfezhrJlUS+d0SnEeryA12meW9JFa5UHIjvEDVsAFimDwoglTdzD5OoU8K1NaXALC27ALpd/nUU2r7n7a1t6tcWJSgru2L7gOmyzC0nEh4eSXWkuxDBllnjZQ5HsIZmqS3WyrOED00sBpXBZLnE4FWLK1KmEtt8KwzPRMVQNxwCd42KUulHws4cj1PQCgW/EkGw= X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(136003)(376002)(346002)(396003)(451199021)(40470700004)(46966006)(36840700001)(40480700001)(86362001)(8676002)(40460700003)(82310400005)(36756003)(70206006)(6916009)(70586007)(4326008)(5660300002)(426003)(186003)(336012)(8936002)(83380400001)(41300700001)(2616005)(478600001)(107886003)(6666004)(54906003)(356005)(316002)(26005)(36860700001)(34020700004)(7636003)(82740400003)(1076003)(2906002)(47076005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Mar 2023 07:21:30.7479 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 53852b3f-14de-4935-fbf6-08db30263802 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT015.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8756 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 v25 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 Wed Mar 29 07:20: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: 1762599 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=ZE5RcQzJ; 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 4PmdK84MqPz1yYr for ; Wed, 29 Mar 2023 18:21:48 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 6297341CCD; Wed, 29 Mar 2023 07:21:46 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 6297341CCD 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=ZE5RcQzJ 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 5HDem5RMC5Cn; Wed, 29 Mar 2023 07:21:44 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id DF8AF41CB0; Wed, 29 Mar 2023 07:21:42 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org DF8AF41CB0 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id AE64CC0037; Wed, 29 Mar 2023 07:21:42 +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 1D2DBC002F for ; Wed, 29 Mar 2023 07:21:42 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id D84A841D9B for ; Wed, 29 Mar 2023 07:21:40 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org D84A841D9B 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=ZE5RcQzJ 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 s7lbytHPNdt0 for ; Wed, 29 Mar 2023 07:21:39 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 3B2AB41D85 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2062e.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe59::62e]) by smtp4.osuosl.org (Postfix) with ESMTPS id 3B2AB41D85 for ; Wed, 29 Mar 2023 07:21:39 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aglqqshtLI6tbZ/zvRJnvEO4wmUFhukMdoJs28e1fhATy7plU+GbBbsFhRoXNo5kPUyYHvsFa0fQVaRkgsfB9jURFOfI4t8lBqs99aeWhBimPrXLaa81GtfTb6aHccHKYYXeCqI2l9U2ARtuJat+86xl69y5nF5/qxjpv4H+8L2Cdr1mRDy+Z5muDqdH5tA09HQ9sMbQgMkYfqfTNYBHIo3fn0+8XXXSqC6YocY+Wq7TTwik2hN0t976D/yh4OLVqEUj7n0/cNj47Su3ERqoRN7FNlVk5JTnISrG+fwnalo6jydmuqIMzLhBu4uT2VcJ1hF/A5McOEVcVGQ8Ynv4HA== 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=w+Hb87Y0fuqUeswDjZ0ZisNb8b/W9KxlCnQAK7k2DI8=; b=KILQ6RFpk6cQn2bS4WtoOOyKpjDl+qoKjMoWUQ8az5UcO0a2aPQzzFW+JTG6S5T4iDYf2lzPi3WY5XZYHZdDnpv77gzzw+BY6kcUsaqczcnGpn0x8z7naK5X8Wi6PsoegBPhmhMPyD8xM/g31wdIsoHXM3DFs2bF38Hh7Y8mr6MffGlWCXpVWAi+1AbobyoJ2v0ravKcn/eLW+B7qK7rQHHGh+ofR2LCQtg3Pp8GETNgAyB2HqX1TDE1bVhGBxKPJ5pj+1zpWgPvngNF0Vrvj3sBYnGfncfAJH/XJHHydEj7ewZ6m8eg3IEGWDqvuaxUoHmLjcaN2NhRZjvoFJaQ2g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) 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=w+Hb87Y0fuqUeswDjZ0ZisNb8b/W9KxlCnQAK7k2DI8=; b=ZE5RcQzJaido6lScyWqS/ahB+e8aQarfLQTFA30r1EUCAl6xou8f2r6K83UxyR7D1HEEkm7tvWTnTJ/3B9i6UR2nmtCKyIgl6gyYDSOGAe4LailT37MWAVHGvOsZ96mS//OQqxV6f6Fi/ZV276hDTe4lSlKKrCsjQ4PcjrytYJySLpmtsxiKAzMaSRrXa+5Wnt67hAc4sy8kOkd6dDkQq7dp/3wMwpIGlUlBQeNI7x7nzof4JD1HA5J+MieHRsEmXg+rSt2mKWsOhM4OqTXW4BWHEZ1QLaDMyb+ErVCOqMTr/mtrERZIhesQj7ngn4OvQfvAl51mabFvsm3/q+rumA== Received: from BLAPR03CA0024.namprd03.prod.outlook.com (2603:10b6:208:32b::29) by DS7PR12MB5981.namprd12.prod.outlook.com (2603:10b6:8:7c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6222.35; Wed, 29 Mar 2023 07:21:36 +0000 Received: from BL02EPF000100D3.namprd05.prod.outlook.com (2603:10b6:208:32b:cafe::35) by BLAPR03CA0024.outlook.office365.com (2603:10b6:208:32b::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.20 via Frontend Transport; Wed, 29 Mar 2023 07:21:36 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BL02EPF000100D3.mail.protection.outlook.com (10.167.241.207) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.30 via Frontend Transport; Wed, 29 Mar 2023 07:21:34 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Wed, 29 Mar 2023 00:21:16 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail204.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 29 Mar 2023 00:21:15 -0700 Received: from c-237-115-60-065.mtl.labs.mlnx (10.127.8.10) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.986.5 via Frontend Transport; Wed, 29 Mar 2023 00:21:12 -0700 To: Date: Wed, 29 Mar 2023 10:20:54 +0300 Message-ID: <20230329072059.78569-4-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230329072059.78569-1-cmi@nvidia.com> References: <20230329072059.78569-1-cmi@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF000100D3:EE_|DS7PR12MB5981:EE_ X-MS-Office365-Filtering-Correlation-Id: 84499ac6-67cc-4fc8-d421-08db30263a62 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0RljLN+danbt+D6kOCe+xxKnEnaDuafnIudV9oz6WMOOgWiASXmBkZdoMxRMFqgiba2PSt9dheJhXZrx8RVKyDxqidrpf1XGBqrT8fL6ey0GuM3CcmndEkW2XZmZUWkhj+IAGo8Q7sz7tTudO4BzhMT5cHNz4cgLaPI5tRILgffvMbvGo/p7c+Lt44459wbsIrdeWVnbQzKW61Qfot/aw+YOsfn2gk9Z9dVwlWoVbbxsPJ29U0iKDEQetU9xfOTWtARA6AU3Dbed4FoR7DLgkswL7jOF+aWalocdjxeg3Z1U3+8poiDGHHmn14MGC7H5upwn7TzC7mGHFtZ2UZrEGnCazmT7kQTNDCkZDyCVe8a542AOREj4pG1+LxTZRKIBUheTauGKEbp7KIoGNg5dzNZeLt8YvL8bTyLJT3czNZz3s/yg+QJkVKQA+7tn0+L1Sg8AQjzv7xQdWfw1ehPsjhPtVE3NJSu+7s5i2psj5N/B4QG5Yk7LrLYKL1RoZbn//NPv4RifSp+YVJFfwR4QsErduNL7OOglo8b6BgC+iHdRY/oKfhaQbwbG/PcH2b5LsERaVb+WcIPGZ+MLNwVRGfrb42K49/KqV1vvPJIsQWBDuHyNATe6iy+TQKoAnfL0HJY83GTLpbfyF5I1Tn/vE7VBcpj/HQfqEg3N7r8dhXfxEloUlQWSxn9kft276mdxB1aWwObz12GOQtfxpa6JMP7gz2sCI0mi6XsU1mDDodCGyy96ji4bgvTweMyi9lMT X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(396003)(376002)(346002)(136003)(451199021)(46966006)(36840700001)(40470700004)(426003)(83380400001)(2616005)(336012)(47076005)(26005)(40480700001)(1076003)(82310400005)(86362001)(186003)(356005)(7636003)(107886003)(82740400003)(36860700001)(41300700001)(8936002)(36756003)(5660300002)(6666004)(70586007)(478600001)(70206006)(4326008)(6916009)(8676002)(40460700003)(54906003)(316002)(2906002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Mar 2023 07:21:34.7471 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 84499ac6-67cc-4fc8-d421-08db30263a62 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF000100D3.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5981 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 v25 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 --- lib/netdev-offload-tc.c | 118 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) diff --git a/lib/netdev-offload-tc.c b/lib/netdev-offload-tc.c index 247c1ff8b..6ac40b663 100644 --- a/lib/netdev-offload-tc.c +++ b/lib/netdev-offload-tc.c @@ -41,6 +41,7 @@ #include "unaligned.h" #include "util.h" #include "dpif-provider.h" +#include "cmap.h" VLOG_DEFINE_THIS_MODULE(netdev_offload_tc); @@ -103,6 +104,107 @@ 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 *actions; /* All actions to get output tunnel. */ + struct flow_tnl *tunnel; /* Input tunnel. */ +}; + +/* 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; +}; + +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) { + free(node->sample.tunnel); + free(node->sample.action); + free(node->sample.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 *new, + const struct offload_sample *old) +{ + new->type = old->type; + new->action = xmemdup(old->action, old->action->nla_len); + new->actions = old->actions + ? xmemdup(old->actions, old->actions->nla_len) + : NULL; + new->userdata = xmemdup(old->userdata, old->userdata->nla_len); + new->tunnel = old->tunnel + ? xmemdup(old->tunnel, sizeof *old->tunnel) + : NULL; +} + +/* 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); + ovs_mutex_lock(&sgid_lock); + if (!id_pool_alloc_id(sample_group_ids, &node->id)) { + VLOG_ERR("Can't find a free sample group ID"); + sgid_node_free(node); + ovs_mutex_unlock(&sgid_lock); + return 0; + } + cmap_insert(&sgid_map, &node->id_node, node->id); + ovs_mutex_unlock(&sgid_lock); + + return node ? node->id : 0; +} + +static void +sgid_free(uint32_t id) +{ + struct sgid_node *node; + + if (!id) { + return; + } + + ovs_mutex_lock(&sgid_lock); + node = sgid_find(id); + if (node) { + id_pool_free_id(sample_group_ids, node->id); + cmap_remove(&sgid_map, &node->id_node, node->id); + ovsrcu_postpone(sgid_node_free, node); + } else { + VLOG_ERR("Freeing nonexistent sample group ID: %"PRIu32, id); + } + ovs_mutex_unlock(&sgid_lock); +} + static bool is_internal_port(const char *type) { @@ -192,12 +294,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 support + sFlow. Use array to support other 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 +315,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 +339,8 @@ 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]); + data->sample_group_id[0] = 0; free(data); } @@ -2128,6 +2238,11 @@ 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; + + memset(&sample, 0, sizeof sample); + sgid_alloc(&sample); } else { VLOG_DBG_RL(&rl, "unsupported put action type: %d", nl_attr_type(nla)); @@ -2871,6 +2986,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); } From patchwork Wed Mar 29 07:20: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: 1762602 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.137; helo=smtp4.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=WaONQJ2z; dkim-atps=neutral Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (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 4PmdKK0sKHz1yYr for ; Wed, 29 Mar 2023 18:21:57 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id D9C0F41DE5; Wed, 29 Mar 2023 07:21:53 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org D9C0F41DE5 Authentication-Results: smtp4.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=WaONQJ2z 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 dD1Zt_yui4NW; Wed, 29 Mar 2023 07:21:50 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTPS id F0B3141DCB; Wed, 29 Mar 2023 07:21:48 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org F0B3141DCB Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id BADB2C008A; Wed, 29 Mar 2023 07:21:48 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 23207C0091 for ; Wed, 29 Mar 2023 07:21:46 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id E86A084094 for ; Wed, 29 Mar 2023 07:21:40 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org E86A084094 Authentication-Results: smtp1.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=WaONQJ2z 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 q-xcNpvaRAq6 for ; Wed, 29 Mar 2023 07:21:39 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org B0BC884062 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2062f.outbound.protection.outlook.com [IPv6:2a01:111:f400:7ea9::62f]) by smtp1.osuosl.org (Postfix) with ESMTPS id B0BC884062 for ; Wed, 29 Mar 2023 07:21:39 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lIqAGZBbTCbYB6n3En52GUbHbVNlUVjOCAUDV/AhNzHQyy7eruQgXkB0FU62z/a9/jwdc6l3nyFh02Gipx/LeTnly6e9VQYyLZl30pkxKgpVef113chsHb1nTrtLbiQj9pplMq+kipVJ2TPlzVzTbCScXBR/KZDwu+DVOQzwIn3TCrNv7Tdi0K7c+WKB6+u+VvK2M51LjHM6oK/zspraEDEMbYLUZBX0xE759mmDd8AxM0w8DlO6JqOkqWmx4FIm42o3UGqB9JabwQILlFqADjI4XSnNwwYmWUz188AUxgyZQLpMEFb5PDz+Q24HDrlXpA8iqwkkupFxpoIv4yg0Yg== 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=xUNVn8elQtZ7Q9j48qtTxnYhAjqrs8uZCFYXZ3h9LcU=; b=Yr4JndCAHfuCjOZHgNl13uO3mjkb1fgBkDyGSFrifIsinpwHgXGtEkKOCDiJ6DOwb2kvstJrJ/52MQ/zmP8LKB4Ct7NmkH5V4zHjsisth4YMw1U1hVUHlPnEmEYpSgWFZVIfEhaIL66pV/70rqeuw5x+5zKR/VcwjSIXKQX2zH3sx31S4k7LqaJfYhDXN/ur6QK3yOrPt+ZgjdSOncPto6BerwSrpVvAoo6D1PwvDxradNe9t9Aj7ZmrwSqNNyCQYZCY9tv7hJKeEKuCgFU7vApQAEb/eRPBo+sXWarx9z4QvR3/DgWqOV/Dsw2PNF9kfSMOYUFew2f92cXdzyNz3w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) 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=xUNVn8elQtZ7Q9j48qtTxnYhAjqrs8uZCFYXZ3h9LcU=; b=WaONQJ2z3P7xVIVpzASZg5SSc4kKb//9rPICwVEc/O9GrFWD6hgy0RUMV6EdmTU0vubIqaszQWxq9x+BmwsRodyjlezoYgac0Od4DymJ55aHyzrUO0q6owNAoBGmSurT/YJSPjjwBwolqLHZt48PeuVBrIgvlYZWjCNUtloHJPc/93B4mewtZpEwAdiP4aQz+GURQSMFl45FUPU6A9hD4Cr6gvePRN2sJpppdrlz4js808OTgGThoCwoE1SJkkTKyiYRrhIAibi0by5eQYaHSJyUaD7yQfXhD+VISwBiNPzyzy895s/ToyHg+R4G2Zexg9FEWT/ZMHBeZK6efKusaw== Received: from BL1PR13CA0344.namprd13.prod.outlook.com (2603:10b6:208:2c6::19) by PH0PR12MB5435.namprd12.prod.outlook.com (2603:10b6:510:ed::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6222.33; Wed, 29 Mar 2023 07:21:36 +0000 Received: from BL02EPF000100D0.namprd05.prod.outlook.com (2603:10b6:208:2c6:cafe::1a) by BL1PR13CA0344.outlook.office365.com (2603:10b6:208:2c6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.20 via Frontend Transport; Wed, 29 Mar 2023 07:21:36 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BL02EPF000100D0.mail.protection.outlook.com (10.167.241.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.30 via Frontend Transport; Wed, 29 Mar 2023 07:21:36 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Wed, 29 Mar 2023 00:21:19 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 29 Mar 2023 00:21:19 -0700 Received: from c-237-115-60-065.mtl.labs.mlnx (10.127.8.10) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.986.5 via Frontend Transport; Wed, 29 Mar 2023 00:21:16 -0700 To: Date: Wed, 29 Mar 2023 10:20:55 +0300 Message-ID: <20230329072059.78569-5-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230329072059.78569-1-cmi@nvidia.com> References: <20230329072059.78569-1-cmi@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF000100D0:EE_|PH0PR12MB5435:EE_ X-MS-Office365-Filtering-Correlation-Id: 04601c43-2ba1-4dba-9759-08db30263b53 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: K/1IStTcRZhP6CDCf4ivCmq146QEH4d0qklKtStl5YnUG6x8ffbF/igiaOFaTAInvYyAvS+EkUGFxHoKlFQVaZ7HQ9Djmcv7Jfn1LZJ6rfhDDzkAErjHi4Lzdqw32qsffYl9KQNE5jdePeA84kB+U50Bz8ChBkaGUHa6aAtD/XSmyUdRUOU9iqRlwGY8HV5UiV0r8imRL7HrPyRrgbb7BqOIQLUaOxY5PXYvV4R0bbr/0hDa0jTnePXE92OG4JIwwyMwhZqj8vUmRUMaB8vHRpzfoHnhgXJVqGIqRi0jKs+RwR8jBOwKxxQyn1qlFE6Ng7ddOFc0nDKlq6SFfo5xGmYJkGrdkfoA0bP89k9OPMK4Cb/3ud9Hd5KSMR7sdO9z6tWXvyP02tKfvdJimtXvsLGUnJKId6v+TXGqzuOad+43B7R+HJ6WIlXGu+iqXxzjXy/F+cUlj5r1dMdFHcJCsS74U3RGBlZq01B8H6qcABhppracm1EwmisePwVZeW1Bl/0Z0U4WDDwOP+9vTjzTuJgBmuuOHI/9ecHkAuI/gL8275NKVTkPIDmirGnfJulCSU4kUUgmgpid6A8IHGR2nYQvKBWPjzWHjZyWr8EakZmEUyMlxtoJtvy+XP0qrMkoQkgFf582acERHgFuIXGHFc7/zS+W8rgCjXxnE5yjs1SlMJ0YGZRQyRbNkInkjd49NQoLWxhO/bFwNo2Pi1HR6zHI2y3sCH0NRFE2yJzMPetH6reLWMBJlnHXTeee/oHk X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(136003)(376002)(396003)(346002)(39860400002)(451199021)(36840700001)(46966006)(40470700004)(82310400005)(82740400003)(356005)(5660300002)(2906002)(8936002)(41300700001)(316002)(478600001)(47076005)(6916009)(70206006)(8676002)(70586007)(4326008)(54906003)(26005)(36756003)(83380400001)(107886003)(1076003)(186003)(6666004)(2616005)(336012)(426003)(36860700001)(7636003)(40460700003)(86362001)(40480700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Mar 2023 07:21:36.3406 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 04601c43-2ba1-4dba-9759-08db30263b53 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF000100D0.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB5435 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 v25 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 --- lib/dpif.h | 6 +- lib/netdev-offload-provider.h | 17 +++ lib/netdev-offload-tc.c | 192 ++++++++++++++++++++++++++++++++++ lib/netdev-offload.c | 3 +- 4 files changed, 215 insertions(+), 3 deletions(-) diff --git a/lib/dpif.h b/lib/dpif.h index 129cbf6a1..5b094ce68 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 provide 'flow' if 'key' is not + available. */ }; /* A callback to notify higher layer of dpif about to be purged, so that diff --git a/lib/netdev-offload-provider.h b/lib/netdev-offload-provider.h index 9108856d1..b3bf433d0 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,21 @@ struct netdev_flow_api { int (*meter_del)(ofproto_meter_id meter_id, struct ofputil_meter_stats *stats); + /* Polls for sample offload packets for an upcall handler. If successful, + * stores the upcall into '*upcall', using 'buf' for storage. + * + * Return 0 if successful, otherwise returns a positive errno value. + * + * This function must not block. If no upcall is pending when it is + * called, it should return EAGAIN without blocking. */ + 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 6ac40b663..8fa6e731b 100644 --- a/lib/netdev-offload-tc.c +++ b/lib/netdev-offload-tc.c @@ -18,6 +18,8 @@ #include #include +#include +#include #include "dpif.h" #include "hash.h" @@ -124,6 +126,9 @@ struct sgid_node { struct offload_sample sample; }; +static struct nl_sock *psample_sock; +static int psample_family; + 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); @@ -148,6 +153,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 *new, const struct offload_sample *old) @@ -2930,6 +2943,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) { @@ -2989,6 +3051,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); } @@ -3205,6 +3268,133 @@ 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. */ + uint16_t iifindex; /* Input ifindex. */ +}; + +static int +nl_parse_psample(struct offload_psample *psample, struct ofpbuf *buf) +{ + static const struct nl_policy ovs_psample_policy[] = { + [PSAMPLE_ATTR_IIFINDEX] = { .type = NL_A_U16, .optional = true, }, + [PSAMPLE_ATTR_SAMPLE_GROUP] = { .type = NL_A_U32 }, + [PSAMPLE_ATTR_GROUP_SEQ] = { .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; + } + + if (a[PSAMPLE_ATTR_IIFINDEX]) { + psample->iifindex = nl_attr_get_u16(a[PSAMPLE_ATTR_IIFINDEX]); + } + 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) { + memcpy(&flow->tunnel, sample->tunnel, sizeof flow->tunnel); + } + if (sample->actions) { + upcall->actions = sample->actions; + } + if (psample->iifindex) { + flow->in_port.odp_port = netdev_ifindex_to_odp_port(psample->iifindex); + } + 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) { + return EAGAIN; + } + + if (!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) { + if (error == EAGAIN) { + break; + } + return error; + } + + memset(&psample, 0, sizeof psample); + 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) +{ + if (handler_id) { + return; + } + + if (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, @@ -3218,5 +3408,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 4592262bd..84503ec8b 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" @@ -820,7 +821,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(&netdev_hmap_rwlock); HMAP_FOR_EACH_WITH_HASH (data, ifindex_node, ifindex, &ifindex_to_port) { From patchwork Wed Mar 29 07:20: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: 1762600 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=sUsY0XDA; 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 4PmdKB2C52z1yYr for ; Wed, 29 Mar 2023 18:21:50 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 0B5A5840AB; Wed, 29 Mar 2023 07:21:48 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 0B5A5840AB 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=sUsY0XDA 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 955iQWzkmtJw; Wed, 29 Mar 2023 07:21:47 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 0C7E4840AF; Wed, 29 Mar 2023 07:21:45 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 0C7E4840AF Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id DA1FDC008C; Wed, 29 Mar 2023 07:21:45 +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 2778DC0092 for ; Wed, 29 Mar 2023 07:21:45 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 41EE56102B for ; Wed, 29 Mar 2023 07:21:43 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 41EE56102B 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=sUsY0XDA 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 CMA8-oMTe8Hb for ; Wed, 29 Mar 2023 07:21:42 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 205E061127 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on20601.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eaa::601]) by smtp3.osuosl.org (Postfix) with ESMTPS id 205E061127 for ; Wed, 29 Mar 2023 07:21:42 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JshauaSonpjGDILwhazC/Kn0j/+9cTFiPZNrXG2MuvQ7/y1olwz0GLB6vKO/TqtfJ2Fbj0MTfopKsAcFvRKcwT7f9VRibhJYP3PGd63OSIk8Es4d9dDOmesJUk2KGtROzm1v2PRUB/FLVLBPvSmDrP8MJuhuSz98f4bhUeHA4QqED4UgaKs0g57plH/L7MpkUJu3NuzhUw+4sJv2eDY5mIfUnqyiOVNmzm1vllYMEB6c8h4tG3XxDzwQg+yibJUOL1ZFW6n2OjmwB4ljqI3gn28bFrXWaT3xivcg8QYiqu0/hgPfePU3qkRAseQOrPqunaQxaSfbs3DTiUo6GauQDA== 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=QrZQATRDKZtObKbcLaSjw7QIFVoN0O1hE1wDHwDdSjU=; b=g6q3iBzr0eKdUHjoMjcN8u/q02Q3n9hfKDSLDsPqXfyqQJCQZKTqgOQIdUcKuFnRCFprvVaS/k19BrpDGD/8cJPeYaMDMeWWBET4hhCSau6psRl2jLjt41/5BR0pbJK4O5A+o+oAzew+w3YfWicj96G1WT5HTxAfyhvkvyzbM54bZLaJOTrBhP7RbWa4qLNXs0kt7vaHoR/hRUHH7g6fi/O9Hm6O/OuejDATFkdn5FSSJRtmpFhaYjBIdvif7VAQY1Qi+ZqNWgiwiO/vB76l5HWAkS3SxgB2OljYKdmzJVeetMMETTIXwJ7F9BVtWy4vs1rCfd/Hz+qNNjnx0Hz3WA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) 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=QrZQATRDKZtObKbcLaSjw7QIFVoN0O1hE1wDHwDdSjU=; b=sUsY0XDAvFXFXH2lDQ44HZ86OrRhAWkd6TPFOFk3wGUzj0FM1qiMZKuW4Mcw0P/HqffhjAH0p5Um6BKtr3H7LKHmGOWw2vE0wZ7ddHreWEcmvdb2hate9WlE5v7Z29W7DRcmczHxPlUUZaEQKFVOFUyJBZe9HUuTumXUovo5+SYB3jnruH8sROP05GF3uj8ISusVblRZo9uijGckYwsEJc7YUIvb/hA3EeG+a+6b5HUBbox7o4mQy5Ct0bWqcV+qb5UWX2iLj9pWcxQHGUokHPGIyg77sOjNukTTn+jK9NfIEMI9XsUtTjwAHUjK0U2oCwxSgb/v4RNaGaGIbd0xNQ== Received: from BL1PR13CA0354.namprd13.prod.outlook.com (2603:10b6:208:2c6::29) by PH8PR12MB6676.namprd12.prod.outlook.com (2603:10b6:510:1c3::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6222.35; Wed, 29 Mar 2023 07:21:39 +0000 Received: from BL02EPF000100D0.namprd05.prod.outlook.com (2603:10b6:208:2c6:cafe::cb) by BL1PR13CA0354.outlook.office365.com (2603:10b6:208:2c6::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.18 via Frontend Transport; Wed, 29 Mar 2023 07:21:39 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BL02EPF000100D0.mail.protection.outlook.com (10.167.241.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.30 via Frontend Transport; Wed, 29 Mar 2023 07:21:39 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Wed, 29 Mar 2023 00:21:24 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 29 Mar 2023 00:21:23 -0700 Received: from c-237-115-60-065.mtl.labs.mlnx (10.127.8.10) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.986.5 via Frontend Transport; Wed, 29 Mar 2023 00:21:19 -0700 To: Date: Wed, 29 Mar 2023 10:20:56 +0300 Message-ID: <20230329072059.78569-6-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230329072059.78569-1-cmi@nvidia.com> References: <20230329072059.78569-1-cmi@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF000100D0:EE_|PH8PR12MB6676:EE_ X-MS-Office365-Filtering-Correlation-Id: 02a26bd0-152a-44be-8394-08db30263d05 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /G6yKleGPqqEYhnkS3HEo4R1BO+5LCInFWmp8RTEbobes5dn1+B9rLjIJGbsRaBoMEg4mpxTcwzAn/zixkwVGFY+6yzxFam/O9IcA5tWqBioqxTn4nnaVG9qDTCecsoaq/JADY7L4WABcwLnS7fHmrlI4WnERghTgr93EQHG/altSTr91R+vg+ESK2An/NVRAJqfkc1odE/x4dWD0HBgRdv+Xn5mNEzLaaEepr9jgNQf2xI5AcwdgkegP8AygobaeBSkvr8RkO8bdgl/g5LjXRm9Kc8Kaq3n7HjChPAC4/U0zKhEa7Q7lQq+uZmvOqqkjfYeFF9UaoakzpRPUAqvjK9KKZ91CdkymSdL50dcGdepEkq+IMsRscto8IGeefszAY3VU5mE8kKE8lkkMT+id7+cifLUuUPG3ugzVl1sp5t7YXRN4aHeOYfz4j+bDiOLFU3HPgCBI7pJLRvlym5bhMG/qdXX80Eiek6hxBLNpQZto3J0LYWiChaOxvDFkwBLa407nz4WJHs4HVTn5sEov1wm+qZ0Tu2RIuAdXaYourpv+kP4QQS/iB+HWaFJbeWw5gENBuCfv8DrayIKTfAzGHZSnX07xfZgg/cfnZ0Kl7kb5fTBWap28EL0A7/o4TRNkgQMqjuDccHEdJL/8q2l5zp9WVw+WDYNiX0Cg6RZB+vpl8XtM7GWjvE23V9yqohPgpZXWh6M7nSEka3mp0XOciYZt+R9XKbaquQIuwirtAXijDI87WjOHCxEh/R6a33v X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(136003)(346002)(396003)(376002)(39860400002)(451199021)(36840700001)(40470700004)(46966006)(7636003)(82740400003)(356005)(47076005)(2906002)(2616005)(336012)(426003)(8936002)(82310400005)(86362001)(186003)(40480700001)(36860700001)(107886003)(1076003)(6666004)(70206006)(70586007)(316002)(54906003)(41300700001)(5660300002)(4326008)(478600001)(6916009)(26005)(8676002)(36756003)(40460700003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Mar 2023 07:21:39.1844 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 02a26bd0-152a-44be-8394-08db30263d05 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF000100D0.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6676 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 v25 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 --- lib/netdev-offload.c | 35 +++++++++++++++++++++++++++++++++++ lib/netdev-offload.h | 5 +++++ 2 files changed, 40 insertions(+) diff --git a/lib/netdev-offload.c b/lib/netdev-offload.c index 84503ec8b..ec61e1cc0 100644 --- a/lib/netdev-offload.c +++ b/lib/netdev-offload.c @@ -257,6 +257,41 @@ 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) { + VLOG_DBG_RL(&rl, "Failed to receive offload packet, %s, " + "type: %s", ovs_strerror(ret), + rfa->flow_api->type); + } else { + return ret; + } + } + } + + 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 edc843cd9..09cdb6db2 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 Wed Mar 29 07:20: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: 1762603 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=PFFi29Mx; 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 4PmdKT08Kkz1yYr for ; Wed, 29 Mar 2023 18:22:05 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 26BA941D04; Wed, 29 Mar 2023 07:22:03 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 26BA941D04 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=PFFi29Mx 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 Jf1OZQAUv20a; Wed, 29 Mar 2023 07:22:01 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id C821041D06; Wed, 29 Mar 2023 07:21:59 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org C821041D06 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 857A0C0037; Wed, 29 Mar 2023 07:21:59 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 2D028C002F for ; Wed, 29 Mar 2023 07:21:58 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 1E32141CCE for ; Wed, 29 Mar 2023 07:21:49 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 1E32141CCE 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 aCuv5uLP8zw9 for ; Wed, 29 Mar 2023 07:21:48 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org D3F0241CC8 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2060a.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e88::60a]) by smtp2.osuosl.org (Postfix) with ESMTPS id D3F0241CC8 for ; Wed, 29 Mar 2023 07:21:47 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A0DQNRdHVJZKcQcrgDXWgSo/XHj0ZApDuHgL77zikMcd9frkpY1EU8PjBM03zpzgdqeSbob8RawIbTVpywhMzk1iBIJrBk9a439ZBwgfpp3ZZNKYr1I0yAPOkaGkydtdeDB4vku9D93ERERAe7F96JVwtErN6lf9miCRuqa1moElUrFqhqK+Z5yGCuq6rAI7vwHELK2FVbonV3AA/elsX+AGUfVOADqlyjVa4YiLkfMrnrogk7SKLb6p42m3xjHujFf8LLj1vDgCETwFr5FgKx6vRb50RRExhJqUwtsK3HvU1Uzu9kTHkOLdT5eAm2VHRhzVbnOGXSTGkli4pTjtew== 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=ChO+WxZuHavWAXQsDVbPCTd9Tet2WNiHREBGtXdnKUY=; b=jShS1r3mZkIzKYXeFiqoUXK+H2h14zHOJzzAfHf4BLrTX5kTYWrof9qoZUjYIri7rHL5NPkUIrIm9aAdQCZLyZEuz1NqSy7pXX/zMXZ2kqvscsVHI/KadwOKRWL6fhmAQdHNFXQcSMOTaNSjMWcJBcEPm2MF6M6yKGZQJL10KpZhQiDKyTGBTv1bCZRMts9b7yRlqzQyyHPpciH55mKaqO6TqS22HnYVt+mULh/GqTnw40ZTbEjzQbDWsApUt1ppbziRJZXvSGS3khyhEPCCCZYNaQnfBzDJGtuhZ85938wBAxgcDah9RKz45uDqGusNtg+A3wjpf4dy2yHoZXXXaA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) 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=ChO+WxZuHavWAXQsDVbPCTd9Tet2WNiHREBGtXdnKUY=; b=PFFi29MxjPoJkCJMpB5T1B/u4DAQbV+xFmHzRqp40IgB3V2jw3DVZZOvgwRQ9rtac8InWs6VPyoN+dLXmdKu/F3b7y4o4l7Tf2qQ+2EDCt1BAiHTTpJT5/13hFMmBkJpZ7w1Dalz3wuhtwEzB9OUPwKb5yvQv3W7wtrJ/9DU58DVYhXe2oPTtWxymSBObCwK7PwN11POqxZsKClZ1YjyCyMtB4OkCKxorZVU2A4DCpRLk+sWc4oywNn87wR0NNTgiNyNhWyfa0XprbEECIp4PkcVsNxdbKB/0Tudt0C2L8WHm9RYnaM0kI6HsyVnvHQvMAAsAlAdP+NHlghW0vFNow== Received: from BN9PR03CA0747.namprd03.prod.outlook.com (2603:10b6:408:110::32) by DS0PR12MB6583.namprd12.prod.outlook.com (2603:10b6:8:d1::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6222.29; Wed, 29 Mar 2023 07:21:43 +0000 Received: from BN8NAM11FT029.eop-nam11.prod.protection.outlook.com (2603:10b6:408:110:cafe::7c) by BN9PR03CA0747.outlook.office365.com (2603:10b6:408:110::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.39 via Frontend Transport; Wed, 29 Mar 2023 07:21:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by BN8NAM11FT029.mail.protection.outlook.com (10.13.177.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.19 via Frontend Transport; Wed, 29 Mar 2023 07:21:42 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Wed, 29 Mar 2023 00:21:27 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 29 Mar 2023 00:21:26 -0700 Received: from c-237-115-60-065.mtl.labs.mlnx (10.127.8.10) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.986.5 via Frontend Transport; Wed, 29 Mar 2023 00:21:23 -0700 To: Date: Wed, 29 Mar 2023 10:20:57 +0300 Message-ID: <20230329072059.78569-7-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230329072059.78569-1-cmi@nvidia.com> References: <20230329072059.78569-1-cmi@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT029:EE_|DS0PR12MB6583:EE_ X-MS-Office365-Filtering-Correlation-Id: 61d2b350-3db4-47d3-1a76-08db30263ebd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: egVseatpQcBW36c9ZA9pxc8pgW1I/cBZfT++gxlchyarcxFRRK5TmnGjuFvboeKRqCOCGQc+09EX2MEGmaoAY3Remp0geInznXHeo1CL2GoaQVGsAchkJAFflJ6rcNJE6nbM6br3I9xquoAjBLu3OdnZ+4a6+l8alCSCLf8un160Ht99uVQna9qL5FWMrqenLcaJtfIbmUSt4tUyf0UMXpzP0ufdDt8kosrO8oHtxDwybwHnUlvLAXX5XUAB2ja3DRb29Txv/8t+1XI+1L3rIp2SFjV4aC1u6fv966OCnbPj6FEY+LP7H/g4rXvISy1TI1MmaivD+3x0b+7KAdARxIOBAXpFXouh67vD9tByQGiwZRptcjBc7Nhc1K9IVbwaDw1SvGvfRtdHLnTnpqdi9jnHZcTc5/xXNlYp9omdUXskEiS0fQmQf/kXoK+97ScVrD3BUCwqJRgo6yyJdmD0IXm/yuyPRrs9cZDVPJYoZ99jOMMlf36mTVELilSp1bBQAvgUjJL65ywaLgjOdpjh3b0ZDVHhfVaYF+819+BKX+TfF3qLRPQ20i8mnejapJYwjKpSP6EwPo7XSO4MsFkKmFm1jNKJl28zoCJ4Hp8CP6zFE4OYEcnrJgUKx07kGk/qpeceXF3pdBDt3tEIcNXFg83wKCT+jGvZc5U9P9zoGlY8c4IKg8BJsnaR5qhcjMjf2exR+Xta3KtjUIPr9gRccmWYPr8cJ3/teTjccgg+ADFGcPJHM0xG5VxFFAkRwYcT9/XLj47g+zTZM07RX8VXvQYRtcRQwTf/ZNtGFvhB/5I= X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(346002)(39860400002)(376002)(396003)(136003)(451199021)(40470700004)(46966006)(36840700001)(8936002)(66899021)(2906002)(47076005)(336012)(83380400001)(426003)(2616005)(86362001)(36860700001)(41300700001)(36756003)(40460700003)(7636003)(5660300002)(82740400003)(356005)(40480700001)(34020700004)(54906003)(478600001)(8676002)(70586007)(6916009)(70206006)(4326008)(107886003)(6666004)(82310400005)(186003)(1076003)(26005)(316002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Mar 2023 07:21:42.0497 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 61d2b350-3db4-47d3-1a76-08db30263ebd X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT029.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6583 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 v25 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 --- 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 ebe7b5cb1..4e56922f8 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; @@ -3005,7 +3010,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; @@ -3056,7 +3060,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; @@ -3130,13 +3133,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 @@ -3147,6 +3149,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; @@ -3211,6 +3239,7 @@ dpif_netlink_recv_wait(struct dpif *dpif_, uint32_t handler_id) } else { dpif_netlink_recv_wait_vport_dispatch(dpif, handler_id); } + netdev_offload_recv_wait(handler_id); #endif fat_rwlock_unlock(&dpif->upcall_lock); } diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c index cd57fdbd9..0b3ef30a0 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 Wed Mar 29 07:20:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Mi X-Patchwork-Id: 1762604 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=EVA5movL; 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 4PmdKw4Vp0z1yYr for ; Wed, 29 Mar 2023 18:22:28 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id D64B141CC0; Wed, 29 Mar 2023 07:22:25 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org D64B141CC0 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=EVA5movL 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 WQNYc8gsopcC; Wed, 29 Mar 2023 07:22:24 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp2.osuosl.org (Postfix) with ESMTPS id 13F5141D1C; Wed, 29 Mar 2023 07:22:23 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 13F5141D1C Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id C172EC0037; Wed, 29 Mar 2023 07:22:22 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 29934C0037 for ; Wed, 29 Mar 2023 07:22:21 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 46FF840BAC for ; Wed, 29 Mar 2023 07:21:55 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 46FF840BAC 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 tx7pPj7zWyOh for ; Wed, 29 Mar 2023 07:21:52 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 89F6241CE8 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 89F6241CE8 for ; Wed, 29 Mar 2023 07:21:52 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=noqw+Gg5AYNBB15yYMrxDYQaKhtoiZ+4dIvoC7pVocmdDxSEjuPDUMsNvkaiEaE60TJb76HQN+zT1bvoKamc4H54vXl4k9rCoR0/bPgn+8QjwVFCcd7uxTrn1RybkFPQDl/6pZIL1+5BAu+PMkQ66ZDvj0wHyfR8L7BxJREwvanz1i8u7w5M3MSyZtkiWYVmY1M1bA+nhjmscaaMjvZgPsq+C6zEb0lM2SakkoL7xUUv7Y8bJ+Ba82Pp5BoYz5CNNtJmigaDpV/EyArt2TvOg804D0BIBdiTHFFfQEn8FXGhL3HJ3GVLohqCQCcQOSfWfYRolv9bAWH1g4dpkihE+Q== 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=j1dPG+KLLue1DHyxY6HcvbnvKaw8QsNQVhUsiHbg7Dw=; b=btlwRDlj/fGmufvMxVW6ET7+rw8XUqCKNaX1nBZw7fI1598999m9zqkKBnrpm9+8oxcPw5NzLSx2SvZ6mtsi0d85NGvEnaGCWiE9CX5QrUJQ9XKGKCjew+F5MJNz6d2JskYbp3vcice8fFgo9r9fDczROEBA/O7NOO2SnoJNAunbTJVvONq5a0VGAn92YjE9HemTVNpcflg0g+muQS871BBJKssqS+ns+WPVZ9LR8lC+7DtBX7I15NIDrSBstFvabWBFgcOECKKtu4qK+5edCyRr1E4YzTZiGWfOqEfMaz/mKKXjynFtHQm4J/kXPL75VpgX1IBYGhOWapMpsj/3AQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) 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=j1dPG+KLLue1DHyxY6HcvbnvKaw8QsNQVhUsiHbg7Dw=; b=EVA5movL+AC+niHIOApYLuYnqwCz1RXdNmA7JYegZJm+LZrRxzN3ifqlIg6P4aKc3TQyuOVX6KSQDJdeE2LdEMr7IP+7xIWr5icTJpRmMKQvk69Q/vUUztATlpUHia/vO+t4bnWyHfMImR37y8rYBCVevXRYmx6BcrZfhLq6sSv58GSmYoki+IG/wDyXKbJ1O/BUYGeD6nO8i/2WkF+lekc0dyIhxcEkOcM+i56ZE2cKy56jnhTSV1Y8ZnJ1G6iY/m3C+z+TVBQR6jOWFNZg/hn6PorvQw06GLG/7vgkYVBz3gPYbvtH+aa9lV12XtPzl1V+yRE5EDDCamL+oMnyLg== Received: from BN8PR03CA0029.namprd03.prod.outlook.com (2603:10b6:408:94::42) by BL1PR12MB5731.namprd12.prod.outlook.com (2603:10b6:208:386::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6222.31; Wed, 29 Mar 2023 07:21:49 +0000 Received: from BN8NAM11FT095.eop-nam11.prod.protection.outlook.com (2603:10b6:408:94:cafe::b3) by BN8PR03CA0029.outlook.office365.com (2603:10b6:408:94::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.43 via Frontend Transport; Wed, 29 Mar 2023 07:21:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by BN8NAM11FT095.mail.protection.outlook.com (10.13.176.206) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6222.22 via Frontend Transport; Wed, 29 Mar 2023 07:21:48 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Wed, 29 Mar 2023 00:21:31 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 29 Mar 2023 00:21:30 -0700 Received: from c-237-115-60-065.mtl.labs.mlnx (10.127.8.10) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.986.5 via Frontend Transport; Wed, 29 Mar 2023 00:21:27 -0700 To: Date: Wed, 29 Mar 2023 10:20:58 +0300 Message-ID: <20230329072059.78569-8-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230329072059.78569-1-cmi@nvidia.com> References: <20230329072059.78569-1-cmi@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT095:EE_|BL1PR12MB5731:EE_ X-MS-Office365-Filtering-Correlation-Id: 10ce662e-93b7-4017-66a0-08db302642d7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8vOEVzvW1WMHl/q6IqPo98ddWFFhd8c1Qxzi+8z+M7liWUtd4kGOZLfKSgIe9eQreFTDZbiS3mLpW6odg5Kl3mJpEqYdQvoJFwpURsOMOexchfxHDWfBR9hYxiOCHnJthW6Ipxxb8FxX/Zv12pFreT5A4wftrkVRDu2gy6o1pMaDV7rCXcMSF2PHShuWTdCNKAXLiCK03Jfs+1kp4fWsgTk3NnVsXSUNiyoNrCbvSdKlLIB/u+S1Y9gYaLZa2AYa8S+oXfZYTy1UU8DUqEPsgqrmdOPRMSy7gfyIKCq1Vfsul6d1775SEq6kf/lpzZayJYA0qWQV25V4pE6LGZWDKhBC54hxh7znMNSYjhcVTA8FEu/QR7eJncm5KfdrKmVsBOeEeYp0yxvqE9g7chNXnkLldLf9wEhG5+Nk7QglVHO+f7t5JDSG9cWgwq/9WMRhfQ4X1gSWMVcTRghhoDiddW1TcBmXkapr0aAfzxg2OlrIGRc/DBH97/U9yjEcju8BeGiiv8CHu3l/ASVjJIDr/apqpjyrZ8LVUyYaCd968pwCcLA82JBmus8XUp4AY0wYR9/6D5Avmc4Fk/ABWt1o3O6f6PfDEE0IjGfuiLoK6vnEabeLJlt9db7SJueF5ykUjs8YivJe0VFsbX/Ey7MMGaLMcIchrDWg6jDyLL82KLLhPLffMUuFWgXYTJBNTEWUvlR94vsw5TMdJWhKNVZYUsL1vmsk8z6KKKL9hjYlOSPCSdtD8VnSKBtucM2L60aBgWWtlzSlWWJU+GjXmmQ78rah9+jlAu/ninbb59UvIao= X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(136003)(346002)(396003)(376002)(451199021)(40470700004)(46966006)(36840700001)(86362001)(40480700001)(82310400005)(36756003)(2906002)(478600001)(40460700003)(107886003)(6666004)(426003)(336012)(1076003)(47076005)(83380400001)(2616005)(8676002)(30864003)(34020700004)(4326008)(70586007)(36860700001)(70206006)(5660300002)(316002)(82740400003)(7636003)(54906003)(26005)(186003)(6916009)(8936002)(41300700001)(356005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Mar 2023 07:21:48.9329 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 10ce662e-93b7-4017-66a0-08db302642d7 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT095.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5731 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 v25 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 --- lib/netdev-offload-tc.c | 276 +++++++++++++++++++++++++++++++++++++--- lib/tc.c | 62 ++++++++- lib/tc.h | 6 + 3 files changed, 322 insertions(+), 22 deletions(-) diff --git a/lib/netdev-offload-tc.c b/lib/netdev-offload-tc.c index 8fa6e731b..45bad2b77 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, @@ -133,6 +134,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) { @@ -408,7 +415,8 @@ 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, + uint32_t sample_group_id) { struct ufid_tc_data *new_data = xzalloc(sizeof *new_data); size_t ufid_hash = hash_bytes(ufid, sizeof *ufid, 0); @@ -423,6 +431,7 @@ add_ufid_tc_mapping(struct netdev *netdev, const ovs_u128 *ufid, if (stats) { new_data->adjust_stats = *stats; } + new_data->sample_group_id[0] = sample_group_id; ovs_mutex_lock(&ufid_lock); hmap_insert(&ufid_to_tc, &new_data->ufid_to_tc_node, ufid_hash); @@ -886,6 +895,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); } @@ -2001,11 +2023,179 @@ 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 int +offload_sample_init(struct offload_sample *sample, + const struct nlattr *actions, + size_t actions_len, bool tunnel, + const struct flow_tnl *tnl) +{ + memset(sample, 0, sizeof *sample); + if (tunnel) { + sample->tunnel = CONST_CAST(struct flow_tnl *, tnl); + } else { + sample->actions = xmalloc(actions_len + NLA_HDRLEN); + nullable_memcpy((char *) sample->actions + NLA_HDRLEN, actions, + actions_len); + sample->actions->nla_len = actions_len + NLA_HDRLEN; + } + + return 0; +} + +static int +parse_sample_action(struct tc_flower *flower, struct tc_action *tc_action, + const struct nlattr *actions, size_t 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; + int err = EINVAL; + uint32_t sgid; + + err = offload_sample_init(&sample, actions, actions_len, flower->tunnel, + tnl); + if (err) { + return err; + } + 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) { + err = parse_sample_actions_attribute(nla, &sample); + if (err) { + goto out; + } + } else if (nl_attr_type(nla) == OVS_SAMPLE_ATTR_PROBABILITY) { + tc_action->type = TC_ACT_SAMPLE; + tc_action->sample.rate = UINT32_MAX / nl_attr_get_u32(nla); + if (!tc_action->sample.rate) { + err = EINVAL; + goto out; + } + } else { + err = EINVAL; + goto out; + } + } + + sgid = sgid_alloc(&sample); + if (!sgid) { + VLOG_DBG_RL(&rl, "Failed allocating group id for sample action"); + err = ENOENT; + goto out; + } + tc_action->sample.group_id = sgid; + flower->action_count++; + flower->sample_count++; + +out: + free(sample.actions); + return err; +} + +static int +parse_userspace_action(struct tc_flower *flower, struct tc_action *tc_action, + const struct nlattr *actions, size_t 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; + + err = offload_sample_init(&sample, actions, actions_len, flower->tunnel, + tnl); + if (err) { + return err; + } + + /* 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) { + goto out; + } + sample.action = (struct nlattr *) userspace_action; + sgid = sgid_alloc(&sample); + if (!sgid) { + VLOG_DBG_RL(&rl, "Failed allocating group id for sample action"); + err = ENOENT; + goto out; + } + tc_action->type = TC_ACT_SAMPLE; + tc_action->sample.group_id = sgid; + tc_action->sample.rate = 1; + flower->action_count++; + flower->sample_count++; + +out: + free(sample.actions); + return err; +} 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) { @@ -2044,7 +2234,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, @@ -2060,7 +2250,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, @@ -2113,6 +2303,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) @@ -2242,7 +2433,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, @@ -2251,11 +2443,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; - - memset(&sample, 0, sizeof sample); - sgid_alloc(&sample); + } 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 (flower->sample_count) { + VLOG_ERR_RL(&error_rl, "Only a single TC_SAMPLE action per " + "flow is supported"); + 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)); @@ -2265,6 +2474,22 @@ netdev_tc_parse_nl_actions(struct netdev *netdev, struct tc_flower *flower, return 0; } +/* Currently only support one sample action. */ +static int get_tc_flower_sgid(struct tc_flower *flower) +{ + const struct tc_action *action; + int i; + + for (i = 0, action = flower->actions; i < flower->action_count; + i++, action++) { + if (action->type == TC_ACT_SAMPLE) { + return action->sample.group_id; + } + } + + return 0; +} + static int netdev_tc_flow_put(struct netdev *netdev, struct match *match, struct nlattr *actions, size_t actions_len, @@ -2560,16 +2785,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); @@ -2583,7 +2809,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; @@ -2592,14 +2819,21 @@ 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, + get_tc_flower_sgid(&flower)); + return 0; + +error_out: + sgid_free(get_tc_flower_sgid(&flower)); + return err; } diff --git a/lib/tc.c b/lib/tc.c index 4c07e2216..4bbecb26a 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 @@ -1484,6 +1485,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), @@ -1999,6 +2032,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; @@ -2789,6 +2824,23 @@ 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) +{ + 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 = TC_ACT_PIPE }; + + 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) { @@ -3101,6 +3153,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++; @@ -3308,6 +3361,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); + 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..8a721ae0c 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; @@ -364,6 +369,7 @@ struct tc_flower { int action_count; struct tc_action actions[TCA_ACT_MAX_NUM]; + int sample_count; struct ovs_flow_stats stats_sw; struct ovs_flow_stats stats_hw; From patchwork Wed Mar 29 07:20:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Mi X-Patchwork-Id: 1762605 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::137; helo=smtp4.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=GdAAFQ2K; dkim-atps=neutral Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (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 4PmdLg49kYz1yYr for ; Wed, 29 Mar 2023 18:23:07 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id D160D4087E; Wed, 29 Mar 2023 07:23:05 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org D160D4087E Authentication-Results: smtp4.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=GdAAFQ2K 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 gFTwmkTIUU4l; Wed, 29 Mar 2023 07:23:04 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTPS id 2C6B841D84; Wed, 29 Mar 2023 07:23:03 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 2C6B841D84 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id E115AC008C; Wed, 29 Mar 2023 07:23:02 +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 BFD9CC002F for ; Wed, 29 Mar 2023 07:23:01 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id F3A4C41E10 for ; Wed, 29 Mar 2023 07:22:04 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org F3A4C41E10 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 iS8j1F2E0BmM for ; Wed, 29 Mar 2023 07:22:03 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 595B141E01 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on20605.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eab::605]) by smtp4.osuosl.org (Postfix) with ESMTPS id 595B141E01 for ; Wed, 29 Mar 2023 07:22:00 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nYg2lIERI8PRiqCsbvj+6hNV6zOiYWbHdfyKs8NihgUqJCMv7M4Vp40//x/K+HMhbGrX14nT4qtQ9LUmCLSJaBpesbuiDll/Lq1d+eFAYLTfvMAgCczPl1Ci+ArYpQMtg5WqP1kSqBkaCLZhRv52uN36NMmhmyKPxFsS4clC3Ezp1qiWDwki7G6IIQRLwMoGL99kEX+XgE1hUDA/JYIeSCCdp6YFFnEwbubjCbb103+eCZuCmRYa96d2JpUNR67+TcV6jcWJdZYVDq6/jUXw7aerOIAjvQN+qL+s7SPTdMNgS4PUgT3eehYmsjIHDL3GO7pGs6SYWzyM155HhsPtYw== 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=g7dUjxZ5r+HgB0fxxh45dR8Z4ezeP75myphvBunt1Vg=; b=Aloja3lFMSfWAvFkhPHhYQY0pcQchYE46FxrKS5C3DmeQHPOEjKvXbgrFxLtzgKbDzsmId9uipVOanI22jGVGONzcvGT0i+NbGAfZPk69lllQsyfnPqWFafmLpCrzz2pQKVBrTYWnDrB6bFzVjudwKdPeVyw5n7oEc49fFk9lteLtNLk/QZ4vU0KlgrTYnG5sSh1wtZtuwmmNS5bHm2BLJjam4PLZ4rXvLIVliQeJFyzx8FNxlEwDpITfMJB/PSQEQxlo1yyYN227cA9ZSW/xeD9It97YXo9oTCUgMwS/ebh9Axu5UIe2AvCWLdPnrcIg8+H+gZpHch+cXSEb1ZoUg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) 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=g7dUjxZ5r+HgB0fxxh45dR8Z4ezeP75myphvBunt1Vg=; b=GdAAFQ2KgvmaN55WxQ9RYUPPLRvQIqN3qR0I5gHgDxMVtnjWCLmIllrG60VzeF3nGMHHjD3ijF2izIujX8lTvIMPPCZfFvvsT4vT3+M9QTwP76pozDN8PIUhCvl9mV57VyzHoDR10u0hOO1sTf/UnrSXa/xqll9r0iTkEWdoaWirSn7CtYMaaMLoavKRSaHbuDbnRr0xT4XOcXsPPZxHu8WxmW9VVWDEfqT3Lp1Yy+TZM5Nlb2rWL4M0jLiMmtGUAbKBvjbqEc6uw4cJNAsoNUNmCdFSbg4ZGsqxTp/I9gOQcLMUEJkhSxVSqc34tV6XygMZDyZQE4gMi+t87RlnwQ== Received: from MN2PR05CA0022.namprd05.prod.outlook.com (2603:10b6:208:c0::35) by SJ2PR12MB7823.namprd12.prod.outlook.com (2603:10b6:a03:4c9::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6222.33; Wed, 29 Mar 2023 07:21:57 +0000 Received: from BL02EPF000100D2.namprd05.prod.outlook.com (2603:10b6:208:c0:cafe::28) by MN2PR05CA0022.outlook.office365.com (2603:10b6:208:c0::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.20 via Frontend Transport; Wed, 29 Mar 2023 07:21:56 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BL02EPF000100D2.mail.protection.outlook.com (10.167.241.206) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.30 via Frontend Transport; Wed, 29 Mar 2023 07:21:55 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Wed, 29 Mar 2023 00:21:34 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 29 Mar 2023 00:21:34 -0700 Received: from c-237-115-60-065.mtl.labs.mlnx (10.127.8.10) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.986.5 via Frontend Transport; Wed, 29 Mar 2023 00:21:31 -0700 To: Date: Wed, 29 Mar 2023 10:20:59 +0300 Message-ID: <20230329072059.78569-9-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230329072059.78569-1-cmi@nvidia.com> References: <20230329072059.78569-1-cmi@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF000100D2:EE_|SJ2PR12MB7823:EE_ X-MS-Office365-Filtering-Correlation-Id: 89d74077-7715-4e1d-a8f0-08db30264689 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dsn1KlZsYXPsvGxWyAwSBn459s4MSoHdph6uMttxwF6PyKzZ/tYk6m2+Xxg55lEp5Vu78WmQJ3PubiY0W+oyZBFIq5t6pDEgizLANTHXdzomKt5RHwFzIDXl+v7rEDt9v5uSMtDq94nuW1paWOKApRVwoWCj8GTV+yxYTO/BFu8Gu/0XiVx2+lzN1Y/URH83HL3QhGwv5fnfy0xDu0ElfOc0gegibuFsbXHyrQdXzxy/q8oSucCWj7YJgaQdziuh1JnbvLQGhNeKn3+KuZWc2lDumf1gbhgibuvrfAzBgghZzkA8G/4UwRUs2PZghnQUu7kUpGmjT3CWX/n7q24bDdkeEAfIZVpcc8B0RPAHTCWRpupv72EWd72CbxaUPEeDay/UffJ6DcRc38qXxUvuUyGt1BFza0QfqmfsYrGTsuPCHFOId9Pqi1ccgyOayMCFHi6ldfCr5siSUdqK/5RRY5aCIFu1qMSd4xUrFp8aZ0uyl+Hjjwbjm2eVcjJcpu8MPOFXqD/PeRzr/YN/ImJzWsvms9wxoO0+pcR2pCEsa9AVyLQ92YwrNQpC9lBBzuPIMpKgHCxrDMSeJDEu4KJtkvtTRNT9eCUsWjvp6vbiVJX6BjcjhuWFh89PmMgEZw5DaHBSktMmiLuAladc/BS1h7KPjm8lqsXHLUxhp8J9kT6axEohJ2Ei0vUwvIO6H9hoPqmgFSdqQutIpEPdSb+kGty5zolemTlMbXPf+WnvBX3uA/11UjKC+WOfw28rbhwF X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(346002)(136003)(39860400002)(396003)(376002)(451199021)(40470700004)(46966006)(36840700001)(83380400001)(336012)(36756003)(2616005)(426003)(47076005)(186003)(107886003)(26005)(1076003)(82310400005)(6666004)(478600001)(86362001)(316002)(54906003)(36860700001)(6916009)(41300700001)(4326008)(40480700001)(40460700003)(356005)(82740400003)(7636003)(70586007)(70206006)(8676002)(8936002)(2906002)(5660300002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Mar 2023 07:21:55.1343 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 89d74077-7715-4e1d-a8f0-08db30264689 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF000100D2.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB7823 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 v25 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 --- tests/system-offloads-traffic.at | 121 +++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/tests/system-offloads-traffic.at b/tests/system-offloads-traffic.at index eb331d6ce..4cb076533 100644 --- a/tests/system-offloads-traffic.at +++ b/tests/system-offloads-traffic.at @@ -93,6 +93,127 @@ 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]) +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 +]) + +OVS_TRAFFIC_VSWITCHD_STOP +OVS_APP_EXIT_AND_WAIT([test-sflow]) +AT_CLEANUP + +AT_SETUP([offloads - sflow with sampling=2 - offloads enabled]) +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-appctl dpctl/dump-flows], [0], [ignore]) + +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 +]) + +OVS_TRAFFIC_VSWITCHD_STOP +OVS_APP_EXIT_AND_WAIT([test-sflow]) +count=`cat sflow.log | wc -l` +AT_CHECK([[[[ $count -le 1100 && $count -ge 900 ]]]]) +AT_CLEANUP + +AT_SETUP([offloads - ping over vxlan tunnel with sflow - offloads enabled]) +OVS_CHECK_TUNNEL_TSO() +OVS_CHECK_VXLAN() + +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 with different packet sizes +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 +]) + +dnl Vni is 0, test-sflow doesn't show it +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" +count=`grep "$tunnel_hdr" sflow.log | wc -l` +AT_CHECK([[[[ $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"])