From patchwork Wed Mar 29 11:42: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: 1762715 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=az2QN0Xc; 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 4Pml7F65Hnz1yYr for ; Wed, 29 Mar 2023 22:43:37 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 26F2D80FFE; Wed, 29 Mar 2023 11:43:35 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 26F2D80FFE 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=az2QN0Xc 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 rMazQgkCXKT5; Wed, 29 Mar 2023 11:43:34 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 294E481099; Wed, 29 Mar 2023 11:43:33 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 294E481099 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id F1B0AC008C; Wed, 29 Mar 2023 11:43:32 +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 2FFDFC008E for ; Wed, 29 Mar 2023 11:43:32 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 5B6AA40192 for ; Wed, 29 Mar 2023 11:43:29 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 5B6AA40192 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=az2QN0Xc 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 I7r8VvB8N-cU for ; Wed, 29 Mar 2023 11:43:28 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 3B606403CA Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on20608.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eab::608]) by smtp4.osuosl.org (Postfix) with ESMTPS id 3B606403CA for ; Wed, 29 Mar 2023 11:43:28 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=le3CagdKcm1IesXCHzc1L/JhJG026BmJCZgzQpaadaH7NpKfH7W9pGLaMoIza8RtjlQ7VSXYC3msRryk5fE6Uk8QIMwmWVJ9N3YL8iy6/5kvUvny1vxIH0M9d51TTD6gdJenAKCiUZZ78+6g0BvVz3hLber7lacX04Q42O2UC9FnfKAQI5Tfon15gNU2S5X4d3DNHUWdgJdPT50Yjjjl1LLbrIt7fIsTz2ZRo/hRTW9Qz/WY1wEiboq6yVQr9OXD7zPdRe5NZPr3x8Fbve1oJl34ATyKV736Sl7+vxSKd/O8xg6ff9RRlZIiOS3zjIKeSIf3QECDPdqjVoylWulIzA== 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=jLIWB5QnNS6s9PDAnKvKHIYu4aZ+7pvdnhdCSOkQl/Kq+cikPn+7AVtz74cHOkzj16CtjdGLgvioVvkv5Og+6jvRXb0Lzxeyear4OkNZdtHwMV0tQHg7n3SOllua5qNcDUTMbNW75YjwDSOF71ZRjmzP1T9daZdWUwkgS7W5NEOyitwc/w8MnO1W0NULKagxOI9i1oJ6AR3o3YoRCxhdbAbUlpswzKPRk1DejbIYiQ+8ZUzzMDOI2gcBct2ro0cSUIc0l55JPCg/mfrlzk5mIjP0ZDTbbIfe8A7yu63q2zI2eHu8IejI3+bJgbEh7RT45KYUwLvLSKzmARlicgxxrA== 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=eo6HWp+kXlXk46W30de3ve8rjPXSXif89pFW/3qvQRk=; b=az2QN0Xc/Einoj1bLMid7d9ifT8yYwSN+UxP+SLqF2f8h1B9hfT5Juomfns/WttIda1h7ZDVZ2lg268LPdRHCwpzbGMslONxOklHlFg7US7bSqrlRt/M1qCeaLm3TJiGo7O7NeEoM5841giRGSYkLkkfLOgD+riJrn0XCupeJLJYBj8lqSc3JrQwZ7nwgowQ1BvYq5UT4ROv2NpEup1RxqvAIxsWBrSnjhlheoEJbLulStuD3nMHskbhMtRNdqQJrA2I1fR5Qjwbx5EMztBWRqztSc3KD8dyKN9J2agiz0j/BcNgFR+WO4IBa7ILxqjzla8+wKt/n7rx5sru6Lg5hA== Received: from MW4PR03CA0307.namprd03.prod.outlook.com (2603:10b6:303:dd::12) by DS0PR12MB7512.namprd12.prod.outlook.com (2603:10b6:8:13a::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6222.30; Wed, 29 Mar 2023 11:43:23 +0000 Received: from CO1NAM11FT017.eop-nam11.prod.protection.outlook.com (2603:10b6:303:dd:cafe::11) by MW4PR03CA0307.outlook.office365.com (2603:10b6:303:dd::12) 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 11:43:23 +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 CO1NAM11FT017.mail.protection.outlook.com (10.13.175.108) 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 11:43:23 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) 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 04:43:08 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail202.nvidia.com (10.129.68.7) 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 04:43:07 -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 04:43:05 -0700 To: Date: Wed, 29 Mar 2023 14:42:52 +0300 Message-ID: <20230329114259.110297-2-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230329114259.110297-1-cmi@nvidia.com> References: <20230329114259.110297-1-cmi@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT017:EE_|DS0PR12MB7512:EE_ X-MS-Office365-Filtering-Correlation-Id: 2d64fecb-9fb4-4959-2637-08db304acd3f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TqfL0M8ABED8gTRhvmWwq6Q/a4FHeIFxyrN36D0Sixnn+Tssv/pqRZdqjm18ljKC1fW2ovRbP56QmBQk9Tda9DGteccvSS/J7lHiF2m6GtrHcJl0xpQK7ifbtpaiUl9f2Q42/3DQKapFshNThdsTAYYPdzLCz+ss4iMN/V4HdQmNTzBng5vUENRPBDy+fjT2eq4z3L9pczoF8QZCtKZhzWC/Sr3ZOmq9GEaV6zZt6j3PoEKEWFIx8o4SYHAVO8dg45IiJpnH/JRv5prcxpfokb9IFkyxF4uvnrbsg05q86EuMnoxMpliggJLFS87y5TkjSLrdkg7QNfmofwl+UwkRiuAn4ukVMeMw6PHdwKLeFbidlVkXigTPy3e47Ix5DaSDtVsDGcg7t/RfxsFu06gu6LwMnPPXTgSixKuLSVDuf3Ms1I8WFHkgWDywMGTJxl3zRAzuO41qegIOoXXk6f6TJK62CESRkQ7Mg5dnbWtXSQhvN2UGneADo4/hLyzMBT375+KWDXblpQ5zp0IpjPMf3srME/ZDqE/GnJ44aj6CzSQvINvQ5saEvtDCLaiTqRO7vMhsCjwmNdxU6rlya7ry67z/tOOgmYMUfwt81OZLvNV84PG7lGJ4gK1aW31Jvyy1XxvNEoKMSmL0AzopkLGEvsRBsZwi4HKA5SVItKpZaJex+G2GURUvulnHaYkOmXzHRJvPf4EMIJHADPtOlcHMS3Nvndt78demy5Qb1PD+mmNhCJbKVsAQtdd2xJf3UgSC5fje4p+dA9efTzVZp8hFg== 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)(376002)(346002)(396003)(136003)(451199021)(46966006)(36840700001)(40470700004)(34020700004)(6916009)(4326008)(36860700001)(70586007)(40480700001)(70206006)(316002)(54906003)(40460700003)(478600001)(8676002)(2906002)(47076005)(186003)(5660300002)(1076003)(26005)(83380400001)(2616005)(426003)(336012)(36756003)(82310400005)(86362001)(6666004)(41300700001)(107886003)(7636003)(356005)(82740400003)(8936002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Mar 2023 11:43:23.1300 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2d64fecb-9fb4-4959-2637-08db304acd3f 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: CO1NAM11FT017.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7512 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 v26 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 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 11:42: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: 1762714 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=f/CQoSwY; dkim-atps=neutral Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Pml7B0Q1Mz1yYr for ; Wed, 29 Mar 2023 22:43:34 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 5121E61481; Wed, 29 Mar 2023 11:43:32 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 5121E61481 Authentication-Results: smtp3.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=f/CQoSwY 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 ht757q3HIkdG; Wed, 29 Mar 2023 11:43:31 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 6E3EE61475; Wed, 29 Mar 2023 11:43:30 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 6E3EE61475 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 3D72AC008D; Wed, 29 Mar 2023 11:43:30 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 1E314C002F for ; Wed, 29 Mar 2023 11:43:29 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id A2D138124D for ; Wed, 29 Mar 2023 11:43:28 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org A2D138124D 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=f/CQoSwY 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 h9QmvaFFh5Zu for ; Wed, 29 Mar 2023 11:43:28 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org EC0C281220 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on20608.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8c::608]) by smtp1.osuosl.org (Postfix) with ESMTPS id EC0C281220 for ; Wed, 29 Mar 2023 11:43:27 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XOW1ZYFAEe0M2uZSDh9jQJ2cPZ+z5gKwzpgYO1f2ws7klLQKOwBUpfOoJmTY4YnrbqVtsUxQX4qfQawzlXBn0ymfjWYMQ8xpzp1thoK4lFDgvH8RnTVc3zw+2Pj+KkwfZXXH/SNeHpd0sWNXjja7X1ysbQWmkh6RzoKBnbRMLTJmzC7hGvk6V2WLcapy0Oez3+DbwH7AH3NOEi3XtPEgYQ4OdT54GBZE2NBSx5tTKHJyyDvJq1WRbUS9HRpxO6DNEOqe2UgBlRn0mguFVCrSGDl9wlP0mUd/o6M0Q3qFTZ/c3r+pnvVUjwMsPbFsroctGg7cYkPfNWO/cRLwYjofeQ== 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=EQ8TV4d245ycIoM1jzAeaEGRZQbAzoP7uH6SsadtqncSZddsb41kvtkOza6lLhG+v8gY+5IUbU9T3iNI1L4hZcUM06EvJIllTf/34FbwTjmZrcxECfoxowdNaRD78k+lI0nxmFGvVH2PJAsP1GQbODrMW44t49kdZWHy0O3KeGkdr1R9N1FehBkmPPdDoSCH2rSUaGryyzlcPI5FE133J2fmhWh2ZSiiBZ4ER/3ucixXplBWH7vehFg04b8bV4WnM1kXKrsETijJUVm5ucl3dg5IaBi45moSDWtaJZcJOHgLZmuK9fXojXB7nDFSOXxCRlnUYRb3JK6koqDUrcg4Xg== 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=f/CQoSwYEzp48Xl0mB5shfv+eJIOao7md4Qqr4kJ61LhB0QLLa1MlE4WJ/nefOrpCV1+/3MF/tITTdbDtKEOLM0sgXRAllzuQBzmjNVJB8Omt2rVLXAEPRCp92u9gyy8jeHQPgIMVoh6boxqk7WmeTJI73km9ja4tQWkpGpe4ZNs00Zu+49yBRDR2d3jWUcvS3YScFjj2IKJB/OcCq6aiC/VJgnOOXdhmsOtuG5MezToapG9HVNqn8jgLztR1zSb53bK4V53+WDBrlyv1Z3XnLHYL1keTbHwxO4lFMAxiy3k5kBlClvLpli2TZFNkDUW+23THdhWcTaexQcu6ud4zQ== Received: from MW4PR04CA0329.namprd04.prod.outlook.com (2603:10b6:303:82::34) by MW6PR12MB8999.namprd12.prod.outlook.com (2603:10b6:303:247::8) 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 11:43:25 +0000 Received: from CO1NAM11FT094.eop-nam11.prod.protection.outlook.com (2603:10b6:303:82:cafe::2b) by MW4PR04CA0329.outlook.office365.com (2603:10b6:303:82::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 11:43:25 +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 CO1NAM11FT094.mail.protection.outlook.com (10.13.174.161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6222.17 via Frontend Transport; Wed, 29 Mar 2023 11:43:24 +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 04:43:11 -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 04:43:11 -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 04:43:08 -0700 To: Date: Wed, 29 Mar 2023 14:42:53 +0300 Message-ID: <20230329114259.110297-3-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230329114259.110297-1-cmi@nvidia.com> References: <20230329114259.110297-1-cmi@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT094:EE_|MW6PR12MB8999:EE_ X-MS-Office365-Filtering-Correlation-Id: 181d98a7-0fee-4f5d-50ac-08db304ace3f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FNjR5vXA++x/XZ6x6WLoLtNYg+eS/IDqBy7I7/P3Id0yPmAPREHPocS5D417VhkoOrvbGCSaAw0SLbsED/Y1bSTm3qePpXDQs1bUNnwXy4qMlPHaeixGDx+Pn8zHqsfqCV+VjO+g+pk5E5eaad6xJ9g0VfTeg+xK0IIe0VnoPgU88ibxDJCSs7qWY16BKTdhFvsl+GZxntPAcCRrijcW9tyH5T75QqQLuyzjdDnP0uelRRQfmwSFR0bejPOKJVj2ydHZTt/9WvOxOulVBatPP/jw9cS9A3L8SjXxeuMlpi4qzaw/wY1LV9zeVw/RQ7z5MNfROC+BJnXGC6fjjGRm3p2uNLDyz8/pnR/91H49MHbOAWGvLiZYu9jYX3dbvWnp21o1CCSId0Zmgq93UN9A/Ai+rwP8dTNJ5Mz5qx10nRjhkjGlb6xw3sukQdhJOgp8HZCE5Ni+MzHiMtyyY/J8X4TVkKko54brlNxdDhSwjhzXLF7xp+vjYe/5iGvByJbU9NDQCMm8lO7CxHS34NnRl0atSGsbcnAtIk/lQ+INVcuqVcK4sbMjMD6wfgyDJtRC9hC5Uet1Y0DTkmh0dbEiTZnZpzl3otmQHTY+yVN6RN47o8yUONugxNTdpyvQ8lKPyw9GsvNXzMarXATNEaBbw8Zv0hNRYpDJVDmcRGbSVx/zWrYb+aWCsImHors7i/aKMxcBO349KsvPd4KzcB483H5xt3NQqH6bXjJi22BEL387zxZSJmQaU8Y7o2AsnJzTGsIXc+IBeQmDSjFvWuHxGe+WWlNhiK8YPAEduBKGQv8= 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)(376002)(136003)(396003)(346002)(39860400002)(451199021)(40470700004)(46966006)(36840700001)(336012)(83380400001)(47076005)(40460700003)(8936002)(7636003)(36756003)(82310400005)(86362001)(356005)(82740400003)(8676002)(70206006)(40480700001)(70586007)(6916009)(41300700001)(4326008)(5660300002)(6666004)(36860700001)(2616005)(426003)(34020700004)(478600001)(186003)(2906002)(54906003)(107886003)(26005)(1076003)(316002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Mar 2023 11:43:24.8088 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 181d98a7-0fee-4f5d-50ac-08db304ace3f 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: CO1NAM11FT094.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR12MB8999 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 v26 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 Acked-by: Eelco Chaudron 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 11:42: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: 1762716 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=KlBiB2zw; 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 4Pml7P6RTSz1yYr for ; Wed, 29 Mar 2023 22:43:45 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 1579F41D50; Wed, 29 Mar 2023 11:43:43 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 1579F41D50 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=KlBiB2zw 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 X8wSysEIjW3A; Wed, 29 Mar 2023 11:43:40 +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 33A4B41CF0; Wed, 29 Mar 2023 11:43:37 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 33A4B41CF0 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id E45FAC0036; Wed, 29 Mar 2023 11:43:36 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 05378C002F for ; Wed, 29 Mar 2023 11:43:35 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 787C741D0A for ; Wed, 29 Mar 2023 11:43:32 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 787C741D0A 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 8G5jLYiYHmeQ for ; Wed, 29 Mar 2023 11:43:31 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 82E0141CF1 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2061e.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8b::61e]) by smtp2.osuosl.org (Postfix) with ESMTPS id 82E0141CF1 for ; Wed, 29 Mar 2023 11:43:31 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V4ntdRRv/9Fd/K5rZFUUIlTdfoexYqA2A1HB+s+j0CqIc/0e6SKBqyWE8V0p9u+dHa4WNJC56BFxvwbSJ2XYJjompJyAgHwUpsy8V5cSXeuLmVzwkNsyc+nl/omqDGtB+Trijh2T85aqQzSkQuVQz5woH6UyTGSu7Ft4gcMFHWfdRJLX1+R5ft5CU4bzhRTM9W8TCJuA+MI6hUNAbwQNi5PqQ08BIDci6nJttnKVSMsUpj3exs+naWEo0Jnoi7vl+/3v5fbSY5kfRCtamV01hsmAPUOczC28vwRznTdqTJSXoZcZvqwHxf8xme5zGImRXPGC4nztLgO9iWx049vUtg== 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=tQsXPjInCXITwIsp72zTjzYImTX8Pegyp2ynQShVPD8=; b=PpIzLuTZMIIAef2oMjbk+v+PIlA886ogxlHqlFLvu2hpabapKCyOLJmDUYD7lJDgRiPl+St3GHkZ39SBVnXDxKygfFJ53j2mJI+Lr5aP2I9tUDbjC95E8t8kM8W7pZPPyEhzYbk/DUAMPaLliwIwteVncfkUMoeoDNCA8VaYv1vcG9kC2uMUSeLFGF2MJpNfnNYgEWrOnL7K2BefzMg3I0mxYQ4TwZ75k5kUMgrJXmLKKnzFFwJoGHGZ3HkaDVDHoG+agUQnyXtIj5mz/p+XRQjk0O03r6EgvWh8RTZKt0BycmVnakPeth+6Rn//3Iq3/OIaW39LonNzNBVLi+CBsg== 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=tQsXPjInCXITwIsp72zTjzYImTX8Pegyp2ynQShVPD8=; b=KlBiB2zwZMqPwnt9yWCnZxGeJrxF1RIe+PAOjPtgb8o7xPiZH8fqO+eC0D6kOR/iRRkkB/2E5OZOBwTLqNJcfOWSUF+MjGzQLlcMROqqusDjgTbo4dkLpeAPxQGCzaCPeK7XWditNwPyVpKaJPhX6/hzf4QspGunqkGJocB/43jNL/QasaP2xH9Erl/vvgKgb0iLQCQ7DJE3Z4HcsUSx5NW3z40JdBBQN7LhUZZGThKUan62CGvfC/SDIw5MdivYSxXu4QnwaOP3WqvwR7CaL7u3iWsGLwqLd45+NT3HoiT7qRKbol7he2lGHIbAktmx8lDtt++hi/VupmIDmh+c0Q== Received: from MW4PR03CA0083.namprd03.prod.outlook.com (2603:10b6:303:b6::28) by SJ2PR12MB7866.namprd12.prod.outlook.com (2603:10b6:a03:4cc::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.41; Wed, 29 Mar 2023 11:43:29 +0000 Received: from CO1NAM11FT025.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b6:cafe::8b) by MW4PR03CA0083.outlook.office365.com (2603:10b6:303:b6::28) 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 11:43:29 +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 CO1NAM11FT025.mail.protection.outlook.com (10.13.175.232) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.9 via Frontend Transport; Wed, 29 Mar 2023 11:43:28 +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 04:43:15 -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 04:43:14 -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 04:43:11 -0700 To: Date: Wed, 29 Mar 2023 14:42:54 +0300 Message-ID: <20230329114259.110297-4-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230329114259.110297-1-cmi@nvidia.com> References: <20230329114259.110297-1-cmi@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT025:EE_|SJ2PR12MB7866:EE_ X-MS-Office365-Filtering-Correlation-Id: a821f996-08db-453d-7814-08db304ad04a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: F3x7a6hSdg2MOglKxS86e7v3bKuApCPhaKhxc9AOQmHD5epivv0nkbIXzr62TjPq/QRkeCkMUqEv/oGTRzYq2h4wyl1o0f3Oc9Bxqtdn8tsd9/Mu+s56N8nkipAErby7Gsun+dw5d5KxQMYW+aqXjv8eZVdnika1NFSrW0N0MpBmaQ0gDBXButb8TeTaPFF/X93LFDXWXXzzsu08HTd7aYMsMXu+9PTnCcaTccv1R+ZwXBEt1VXAvLncGwM7djbZz3GrX3rHNKe7pV05NeZ1TYK9BoSqw63xMK5S7WCjvWPu68bvAPj9pJQ2nolcAcqnbFZ+qabOOFunJwr0sgF3FTroxFgee8bjDWRettX965NiW/qVGd4gCXOjN2E4dSED2Sa/917CvWGcpCUIoQD+/VtyvciEJkUbS7W0SKnCzmvYsWshXZ58+injVXpxT0MURJS3vO4ChaYtUR68ycbny3VsUAjgTbEKD9cRBumzZndIjidulG8KcSWXkEnOLEeN8eFXwR9skCb9kwTcgBFboIYrdd68+6jwDIJofAsGYOXbZNHy6HkXaukFqLTzRYpyLQO4zYyCbK+1MDMDbbhLB26BOUQKfw4iukkB7eoRXGUsKlZBFvdUepAGp2MmImZSb4Wp2zixtqBLZ7BJqohZEuyfiyDOvqiwRTpiHZBtQTKQFGV87ZQxGSJr1cRLAHuTDR8Y5Y6OvMGz7OwXHf8U6c36TRVPqVruleUekrM7+oPC9Hiaw5cBtT1HwtVNENrn/1dluq6zSx3WFyzIjfSxbC2gEYkfhPklhHTK7DKyxOY= 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)(396003)(346002)(376002)(136003)(39860400002)(451199021)(46966006)(40470700004)(36840700001)(54906003)(70206006)(5660300002)(70586007)(316002)(478600001)(8936002)(41300700001)(8676002)(4326008)(6916009)(107886003)(2906002)(1076003)(26005)(186003)(83380400001)(2616005)(336012)(40460700003)(47076005)(6666004)(426003)(7636003)(36860700001)(40480700001)(34020700004)(86362001)(36756003)(82740400003)(82310400005)(356005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Mar 2023 11:43:28.2217 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a821f996-08db-453d-7814-08db304ad04a 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: CO1NAM11FT025.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB7866 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 v26 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 | 119 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) diff --git a/lib/netdev-offload-tc.c b/lib/netdev-offload-tc.c index 247c1ff8b..c53ea5588 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,108 @@ static void parse_tc_flower_to_stats(struct tc_flower *flower, static int get_ufid_adjust_stats(const ovs_u128 *ufid, struct dpif_flow_stats *stats); +/* When offloading sample action to TC, userspace creates a unique ID + * to map sample action and tunnel info and passes this ID to kernel + * instead of the sample info. Kernel will send this ID and sampled + * packet to userspace. Using the ID, userspace can recover the sample + * info and send sampled packet to the right sample monitoring host. */ +struct offload_sample { + uint16_t type; /* enum user_action_cookie_type. */ + struct nlattr *action; /* Sample action. Used in flow_get. */ + struct nlattr *userdata; /* Struct user_action_cookie. */ + struct nlattr *userspace_actions; /* All actions to get output tunnel. */ + struct flow_tnl *tunnel; /* Input tunnel. */ +}; + +/* 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.userspace_actions); + free(node->sample.userdata); + free(node); + } +} + +static struct sgid_node * +sgid_find(uint32_t id) +{ + const struct cmap_node *node = cmap_find(&sgid_map, id); + + return node ? CONTAINER_OF(node, struct sgid_node, id_node) : NULL; +} + +static void +offload_sample_clone(struct offload_sample *new, + const struct offload_sample *old) +{ + new->type = old->type; + new->action = xmemdup(old->action, old->action->nla_len); + new->userspace_actions = old->userspace_actions + ? xmemdup(old->userspace_actions, + old->userspace_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 +295,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 +316,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 +340,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 +2239,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 +2987,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 11:42: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: 1762719 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=QX/3K+tL; 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 4Pml7t0JW3z1yYr for ; Wed, 29 Mar 2023 22:44:10 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id C71B5841C2; Wed, 29 Mar 2023 11:44:07 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org C71B5841C2 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=QX/3K+tL 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 cijAPpkrkArA; Wed, 29 Mar 2023 11:44:05 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTPS id 1623A84192; Wed, 29 Mar 2023 11:44:03 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 1623A84192 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id DBFBBC007A; Wed, 29 Mar 2023 11:44:02 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 515B0C0036 for ; Wed, 29 Mar 2023 11:44:01 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 1F5DF614A4 for ; Wed, 29 Mar 2023 11:43:43 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 1F5DF614A4 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=QX/3K+tL 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 uiFaqaH9XRzN for ; Wed, 29 Mar 2023 11:43:40 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 9E77860AD6 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on20621.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eb2::621]) by smtp3.osuosl.org (Postfix) with ESMTPS id 9E77860AD6 for ; Wed, 29 Mar 2023 11:43:40 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=neMF+pvgWEhUMe2fK4B2L0RJfKxpKH0xgqtf0KKsD886nHLZhmQQSOzzHEYf+LExcuaGeNUFxASFeHPBYfKbO5MXsE+EOIY0iYABMOhFz+m7lGwfDuE2u9S1GnIsDYhgYvMtbWGxehrc7bS1/4NR8NxqtBSrwYMwMC2+Y0+BbQNOWhwW4qSCfN0fDccWyQCr585TkRwTf/nfrPY9i/adgYMeUArWp/MLq72f74MpiPZ2HpIp8BT21QFSl8bOtaCWMOh98g/u9IjqolVFSIBhszMAgBuqY8xdTxV6h77/FlUPR5eys30WXppk8RQgURbUG6/Dx+XgT7KjdGp7Zz0bpQ== 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=YPjhitau9OzM221bPH2PkGrEQdDtNTbJubQEsY2CtQ0=; b=lMw4sIoQ7S97QslDKiTj5TVW/q8B1fax90v2V7c8/4JEePG9qtOcVUnK65VEjBy0+7StVJQs05gL37wEumaiJuxf+wnA/djxRWy96NyACAku+blAH8t22ze4x719gq2IEq1wukqSqYOaxbOKgKwSM15RQMEz7R0uF2gRvJVjCGqxRxqsGu5DVgTXK8gH27rid20B4GXQtJJ/ZkZO1wUyLtFyBvyt9Q/1896vmohG1lyzjwDRPDtg8D+ReCj69/hDvsmGLtJX9I+boORYtdx77VJQgZMlLvsq65t+ud7cdU8iDXjvOOk5gHPKfiE2JDswwGar2YQ9rz0IHd/HxoA+8w== 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=YPjhitau9OzM221bPH2PkGrEQdDtNTbJubQEsY2CtQ0=; b=QX/3K+tLXpo0ZewGvTu+sk5Vvvi5u+9ml5+a39gPeMXdxwu+3BqUkN9lcmNior53NQDCJ/qE2vxFxdF2RCA3vQ+ElGuYkDSCQjYrSJTbk+VpI9N8wgfTd0YTX8632mI0Cm4XfpIPq4iYXXk7RjfxBKgYM+mL7d/aAC160cNHc0wkPVyGOvX9bQwVWPqlYGP3I1VMtuyKHXGfJP/8dk2dC41W0ftJ1oYO1u5nyUTCYem55g1Km7G5/xOhdqrMq2ZcAjCWm4q2sdsHJAPgOfJS5qTMxkNe3kRuLhLXkE5BZZzRv3hIbr32k9CjNoRKMaU9I8CW3PUt4i4IMhPCSLKrmQ== Received: from MN2PR01CA0028.prod.exchangelabs.com (2603:10b6:208:10c::41) by BN9PR12MB5114.namprd12.prod.outlook.com (2603:10b6:408:137::21) 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 11:43:37 +0000 Received: from BL02EPF000100D1.namprd05.prod.outlook.com (2603:10b6:208:10c:cafe::fa) by MN2PR01CA0028.outlook.office365.com (2603:10b6:208:10c::41) 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 11:43:37 +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 BL02EPF000100D1.mail.protection.outlook.com (10.167.241.205) 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 11:43:36 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) 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 04:43:18 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail202.nvidia.com (10.129.68.7) 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 04:43:18 -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 04:43:15 -0700 To: Date: Wed, 29 Mar 2023 14:42:55 +0300 Message-ID: <20230329114259.110297-5-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230329114259.110297-1-cmi@nvidia.com> References: <20230329114259.110297-1-cmi@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF000100D1:EE_|BN9PR12MB5114:EE_ X-MS-Office365-Filtering-Correlation-Id: 68b03706-c015-4a2a-9053-08db304ad50e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +cou+EvIzDMAAa17X2IlirQog6wbENShrxXxCWU5FsDroXeI3MVUxrj2jPr/w5JbRvGpxBBfR+dJe0mzaleez5wgQ8RcWloyVrouPT4eoF5OZ2OFgm2jN6ap6+vsm3dZneFR7uoVp4DzSQ6PJYM9nLVQdOnQwzGgyb87brv6iH5Q4bKXyCTHHKL8IYOb4OWFqvFQuTVUO6sjzmWM5ZOX2MNiDJSNFbAEXo/ko3JHZ2qvY1cdv7keh4LbQdzKg5A2l+V/b7ji88AClxtHrGhLu+CT9vnOR+6lIaXecG+wTryjwCKRs4UJs+VyOcmituoALU+sjIxjSTV7kFRMjxH+8ueBoy4gkLw6z+scijjHUEAxQMIpEK0XYpShxmeQY4xP2FmvBanHVB7bXPSVv/iAu1iJcmCZefJ264GY6cUC//0LbSaogWRT6jXOFheT/FzYZ8/1aurN8YcRTyDohK6WOcfTBxFn9ULg4PFWL8uMd52WszNolPz2qrn0QrPDTn0Ho/Bs1SbQEkXNtAco7LnI4fAJUtEnhKEtjgmtXFjPJQ2KMYhSwPQEYocwu7i77DrTLH//QyN365Lgorq4rVq4Yjn2SOewGaOYSnoxCOw6uY9npZrLb3S2Iw3+0VgNsdk5HMc9AQoMnWrrnWDnttMjRCvgBBxXRsM0mAKYdsZvDmrPLEzp/1O44tQKm7/pCnYM9QZfNQIVVBNst0rYCUUhiFgfN0EXj7iXABHs29Ge2/FWrXmaT7JuSEPVrYJ15sm/ 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)(376002)(396003)(39860400002)(451199021)(46966006)(36840700001)(40470700004)(83380400001)(356005)(6666004)(107886003)(82740400003)(26005)(7636003)(1076003)(54906003)(478600001)(82310400005)(316002)(36756003)(70206006)(70586007)(8676002)(6916009)(41300700001)(40480700001)(4326008)(86362001)(2616005)(47076005)(336012)(426003)(40460700003)(5660300002)(8936002)(2906002)(36860700001)(186003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Mar 2023 11:43:36.1084 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 68b03706-c015-4a2a-9053-08db304ad50e 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: BL02EPF000100D1.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5114 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 v26 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 c53ea5588..8c8f29af7 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) @@ -2931,6 +2944,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) { @@ -2990,6 +3052,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); } @@ -3206,6 +3269,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->userspace_actions) { + upcall->actions = sample->userspace_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, @@ -3219,5 +3409,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 11:42: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: 1762717 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=XKP/VNpv; dkim-atps=neutral Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Pml7d1WLfz1yYr for ; Wed, 29 Mar 2023 22:43:57 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 8C1AA6148C; Wed, 29 Mar 2023 11:43:55 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 8C1AA6148C Authentication-Results: smtp3.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=XKP/VNpv 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 sF7P0aQAecsx; Wed, 29 Mar 2023 11:43:53 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 5C8BD614A9; Wed, 29 Mar 2023 11:43:52 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 5C8BD614A9 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id F1FFBC0036; Wed, 29 Mar 2023 11:43:51 +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 055CDC002F for ; Wed, 29 Mar 2023 11:43:50 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id CE28B84130 for ; Wed, 29 Mar 2023 11:43:42 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org CE28B84130 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=XKP/VNpv 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 oFPgq7GS5biG for ; Wed, 29 Mar 2023 11:43:42 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 10ABF84149 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on20601.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eab::601]) by smtp1.osuosl.org (Postfix) with ESMTPS id 10ABF84149 for ; Wed, 29 Mar 2023 11:43:41 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZTash7SVp0YaSVU6BGvq3QHNS5b8W21PeJlo4eh2kjXjPdea4rDs+0tKs9R1NAxx1ptqcJ9mahsiL1w9VUgK9XwVbBTGgVQTdxj06G3EqSJXZb1eDn1PrWpnhSnXOzLNxiyesi76I69iMXWQYvdjfXlYyJp0+lmRKJV5y87762dfsPPkpn0LIvzmEy6lr1B91S399mKfaUv98MEHg2jwtGHGYCex8uwEDztd8NO2B83+bK1TShZecgIMkd1V4Hdcgpe6p1ss8EppARP6aCAzUd85Gx8vZko1stn3KywulahBKf6jMgwZA2/JIODTzpDNFc4xGkhCU2QfcQkOqJcjYg== 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=l4sqkcjY93sNXZOlsKYLcYUcD7S9aZf3jFDlLrF3hGjL3pd5B4Ycbh32KoXX2g9wLK2fB9L/LDteWCmeXkB3jMD3m5NCYBRDRCvqRX9V1EEnvRDioO6RWIU4ya5gRa9Ag5ccnz05g2uM+k0qRH4QfhfttwCfMWUYDHAVBkPoH2z/mKlgvvTUPmUNlkOM5VeuXQW4buihuFrgKhLQXm5UH7pm1ZRonU8yec0MtrzN5kK4THKE9jzKmPjFWxJRhRaTWhRTw42aJ9KF+dbmgfGkMo0zi38nCpynkSDXsET46YHXS865lYfN4GSshPnZLCALhP7rtWqBH2y8Qj2CAPXtOg== 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=XKP/VNpvEdl3m/bo2ORuOKlO82HUPK4/nvMu3ILEzRGyyz8vIE3T4XG3umhC/QOja450MkKwPsn/gj7zUprTJRfRsrPbF0VqIjuuhhyi36BvSYnjNjVz6v4QeNbdRCWtBTwiDzgRfhbLLXNIUkxBYoTDWxIl8PYvnGb7blbUA+sLSdt07YOXW6vwyFErf0kTmiU8WNrbhZBkyZI9veLWdgZAWtbxiSv1lMj3TUcQ/BcxWMCfge3OV+J3h3swnlpaXJtpord3Ni6yMfaq4FnSuVcNWJngYQE7IUbgnCqb1xYlBWtOsrc0Nvs14Bo9n8/dEyNsLBQigUAp5fqYHtJFwA== Received: from MN2PR01CA0013.prod.exchangelabs.com (2603:10b6:208:10c::26) by SA0PR12MB4480.namprd12.prod.outlook.com (2603:10b6:806:99::10) 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 11:43:39 +0000 Received: from BL02EPF000100D1.namprd05.prod.outlook.com (2603:10b6:208:10c:cafe::48) by MN2PR01CA0013.outlook.office365.com (2603:10b6:208:10c::26) 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 11:43: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 BL02EPF000100D1.mail.protection.outlook.com (10.167.241.205) 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 11:43:38 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) 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 04:43:22 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail202.nvidia.com (10.129.68.7) 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 04:43:21 -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 04:43:18 -0700 To: Date: Wed, 29 Mar 2023 14:42:56 +0300 Message-ID: <20230329114259.110297-6-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230329114259.110297-1-cmi@nvidia.com> References: <20230329114259.110297-1-cmi@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF000100D1:EE_|SA0PR12MB4480:EE_ X-MS-Office365-Filtering-Correlation-Id: 39410b4e-810e-4f4d-300b-08db304ad6b2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Bc+ZvLIooOJpL0edWiRc0JYWf9uTx+2JFK2ejlDGXblg20Zr/Y+AAGDcz+e7geNv66g4CuMEDeO07wmSi2YNdHUJ0hyJiJSOGe00W4F8J8ogQ9LpRaH1QxP4KOWAgN3ujZ8t2pyFm4WK4RloxgpJGawGcChbdsSXCoaUmGv1lLnYqBfWSxZsydUyFG+1WutROWNhq54d+aKg05xvg1I6ApBmoPT0PoF9Vk1blkGTp5iK2yt9Q5BaOYTDeZQYeihTyHhGJ4xxpA4sFElVwxCxhdgbH1eZm1wEyHeOtKX4iNuzkvTmKCJemZRlg2A6qFzksmMXzLqXNb9KbHzx+ZYE2iLiJd7o//HdiJXpUxuxnBg0S9qViuK9qMTQ1W3nU2zkfSYC0luwm+ev5b2c/izAU6Jh4xMwzlnJcCTid3KCSYtPhTfDcA+oGXR9MQk0G5oBKe4rFvZYQeg91zhbYMzKmwVO89i3yljym6emZWIKFNLBQ3l+Iagy0QsvuvL1NPj+KxWiS+a5UUjS7EzgcZT3W6BhyqluTAy1CWitXNg2DxrioYH8FN0vNq4WGwjYAv+5E2yNX9BpJi2yLlAO7c5ygrTgxfcIJgc1K98ODhciMFCR+rQeuPrOcbGa9b+plG0Q93f5/Bcz50HNLigYt4uDwyMvjVj3iwMukGxDkHBIcPX2oHTmYwiNNLH084Yv5u6hbt2Hn0hxdrHBB+ikjpXwPD5ZWiem2ok+PNGaxKUB5pyp/88wa6MSQe9V7tvug9SpJ0caP5FM43iXXahh+CCkayCrJ7dp/W44D9qJw8UZM6E= 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)(39860400002)(376002)(396003)(136003)(451199021)(36840700001)(46966006)(40470700004)(82310400005)(5660300002)(8936002)(41300700001)(4326008)(86362001)(70206006)(2616005)(70586007)(6916009)(8676002)(54906003)(316002)(26005)(1076003)(186003)(6666004)(107886003)(2906002)(356005)(40480700001)(36860700001)(426003)(36756003)(47076005)(336012)(478600001)(7636003)(82740400003)(40460700003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Mar 2023 11:43:38.8740 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 39410b4e-810e-4f4d-300b-08db304ad6b2 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: BL02EPF000100D1.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4480 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 v26 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 11:42: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: 1762718 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=kGvMmoF/; dkim-atps=neutral Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Pml7l70Ybz1yYr for ; Wed, 29 Mar 2023 22:44:03 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 3C69A614C9; Wed, 29 Mar 2023 11:44:02 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 3C69A614C9 Authentication-Results: smtp3.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=kGvMmoF/ 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 AzSQ4rDLlIBI; Wed, 29 Mar 2023 11:44:01 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 34B6A614A3; Wed, 29 Mar 2023 11:44:00 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 34B6A614A3 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id E5843C0036; Wed, 29 Mar 2023 11:43:59 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 14D08C002F for ; Wed, 29 Mar 2023 11:43:58 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 1093F41D4F for ; Wed, 29 Mar 2023 11:43:43 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 1093F41D4F Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=kGvMmoF/ 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 53RDkIDzoF-o for ; Wed, 29 Mar 2023 11:43:41 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org BC25F41D40 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 BC25F41D40 for ; Wed, 29 Mar 2023 11:43:40 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A1TRsQxCSKgnNipLGc8FmIuypSm0fU13qHQhBb7IVMXebMtxOB/LmHY18bWCtUi2hlijlMHVBw2re9hUMTWO2scwZ2kYLLzMex1Yy1by1MbHSirurPqarZZbyKBgcieBm0MRyXC6bqfK9GGA1fBep/QBVx8ZAu6faL905VZhOD79IuWA2Xa15O1BBZokFsuYrh7Md+RaplK1pI5GoX9zQS3yJNKRrw99uoxDeBdWt20FlUld7DXb/rth/9euhEkJw4G4lm9/w4OAoKdl++e4KNDp080/eNNPZwgpYkREoruah1JV9qtH19Cj4BshMRHtLUy3aaPBXUQsBGvMZ8M3ng== 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=Zz+toGdWmOk4tyCKxZ08HSu4u2hyfrhKrImUZE8Aw5F35sk0JbCCx9fEsEMSEiWjz4MUO4/hBe/u1i3/TjplIszL+kb6diDzxshfUdOSk99UNLAbAZrMidAfUIjBMsazS9360GaaahnhsDUZ0uJRqSs9x584G0lqkKWIkw74qKtzAjidAV3u8wwaJCW6XOG6njBQnehZeKW6Xh2WTjv8wcbIYDIlh/xUHdbU8YTAhXvTIwGnX+jq+8ThbUq8eSRuDouUojgSbqAfI+D06N36M/Qsqdu6b5d8zVZKFcBsc2rXNykOHfDIZ7CjARKAbTB/kS6CRnpxRIGFGmDiWuQ57g== 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=kGvMmoF/R+SRfI6hOXxNyf4kpFwAXL6Xd011PQjpBuEk08OPio+UA9ZOgxrSo1K9gxCD/N1DTzXj2ssom0HBV6XvcYaYpbz0o+ZlGSJ7UtUapdEnBMDp5uWE0X+riP94rMBGCtgTr4tRP2yzsPwmy2T9oWxx2Br1o4ve/HLjnHD5ueqI8gjz3aNHIGFNP7916aejnc0uG1IJBJxukY2Oz9bTwlhqO1DAiOyq1/SHUj1w5UHkfqU8fJpKfoYwjJ8dNBBA3rmZh8z9DWk/aIHAYJ4fOsNbxqJ8PXZEgqBFRZNJAsYFG51KNowZJLbuuHDyCjqLYtCcWnPwsCoIDdOTnw== Received: from MW4PR03CA0132.namprd03.prod.outlook.com (2603:10b6:303:8c::17) by SN7PR12MB7276.namprd12.prod.outlook.com (2603:10b6:806:2af::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6222.30; Wed, 29 Mar 2023 11:43:37 +0000 Received: from CO1NAM11FT016.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8c:cafe::fc) by MW4PR03CA0132.outlook.office365.com (2603:10b6:303:8c::17) 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 11:43:37 +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 CO1NAM11FT016.mail.protection.outlook.com (10.13.175.141) 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 11:43:37 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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 04:43:25 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail205.nvidia.com (10.129.68.10) 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 04:43:25 -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 04:43:22 -0700 To: Date: Wed, 29 Mar 2023 14:42:57 +0300 Message-ID: <20230329114259.110297-7-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230329114259.110297-1-cmi@nvidia.com> References: <20230329114259.110297-1-cmi@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT016:EE_|SN7PR12MB7276:EE_ X-MS-Office365-Filtering-Correlation-Id: ec62a03f-13f7-4d99-4a03-08db304ad5c0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Zs7MTiRZk01UxFMSFXXfNQ1YFdxAsRyI9BLYvjJoAD8ZYLY3Er60MfYcM1U/SbHWLUcgS9VDDrtmhvbUsrs9dc5c4Qy6YemvBgUfr7qTrZ6kPjbHBKRE6boyGhFd/UB6Mv6rDfsNsNrIX4TXIjIU9ECzHPgXcrKIifCmRz7G3CQFPWRGA1ZzsZqplWX1qah/wCtkERB09hkthxNuqJvZRxRfeUJlmFRcCS6+z1ueY8R4LuDI6Jt4Qw1V/uG6f2kGuwnk3HZxV81MvCwlICRQU+REJThR25mfer0qVzkG7i5XN2iZkO7FJYs2zkFq/k1JmtAejD/n8Hm7jwhejqkT3g3wYRx3zmrOBVBkPfMCK6vpV/3whS404IiTCubxNX9Fs4JYDn4q9c5ChK0teyN+TAqeXog2edG2badnLVlRy8Vfqf1a7Z+0w5EybX3qhUVFYfhFv+MgF/hf57IHbjNmaz43h6awj1qanCXBFlLH9mg+/0GjXenGeQvD2F3RpBYM399Ap7mRM2Ya7KJbFIg95Ic/gJKQMF/p0DDNQdTvI7HiEVezX+PYL0QRUzcNFOog0p8Yg7DhIHZzinHpHqpsGIAidHUMEalRexvQtXkT+KM51XeQRNmPmXYtPB1tdXIFad6lZywV05/eKIKojKPPpb+QkjdBr94FHMqvssL6PnNixY49T+UYGL82dDs5vRGfCw3YX84etUOATjV8iAJp716k8i/wjManM6BPVwUPDIVbThmdkXZ48w7GIHtG8Psk+24mm7WlmLOZn8YsyKaWGrCqoHY+1tADL+R+LzeMmTY= 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)(396003)(376002)(346002)(39860400002)(136003)(451199021)(46966006)(40470700004)(36840700001)(478600001)(40460700003)(41300700001)(8676002)(36860700001)(6916009)(34020700004)(70206006)(316002)(70586007)(5660300002)(82740400003)(7636003)(8936002)(186003)(356005)(26005)(47076005)(54906003)(2616005)(336012)(6666004)(107886003)(426003)(83380400001)(1076003)(4326008)(86362001)(2906002)(36756003)(82310400005)(40480700001)(66899021); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Mar 2023 11:43:37.3981 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ec62a03f-13f7-4d99-4a03-08db304ad5c0 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: CO1NAM11FT016.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7276 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 v26 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 11:42: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: 1762721 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=Cj+EjB8S; 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 4Pml8K3tj7z1yYr for ; Wed, 29 Mar 2023 22:44:33 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id A79A680E63; Wed, 29 Mar 2023 11:44:31 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org A79A680E63 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=Cj+EjB8S 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 wZybluMax13Z; Wed, 29 Mar 2023 11:44:30 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id AB831841C3; Wed, 29 Mar 2023 11:44:28 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org AB831841C3 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 81496C0036; Wed, 29 Mar 2023 11:44:28 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id B2526C002F for ; Wed, 29 Mar 2023 11:44:27 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 428D041D4A for ; Wed, 29 Mar 2023 11:43:49 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 428D041D4A Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=Cj+EjB8S 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 jEn42zvkewTc for ; Wed, 29 Mar 2023 11:43:47 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org B6B3841D3A Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2060e.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5a::60e]) by smtp2.osuosl.org (Postfix) with ESMTPS id B6B3841D3A for ; Wed, 29 Mar 2023 11:43:47 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CIxXwZ6KPmG8AdjsdYgL6AAb7LCg7ZfmWZ8BCbSOobyiTgrrj7/z1XEQmQveuy4ENW5wlSKi5dgNvtzpVB/7HaMKHupkUBGP6JRF86hHBZ4UPnwf8cdsqRrM9LK+e2weDckRyNOHhpJB7yjXzTfPB4a3vTsISpYUsnyDLyxJmXvDCtkqUiQ8+39UOM9Co6yiIbYdMh2MqncbrnRaFYLHVls3RPEcfX2hMyDskmE+nIflGW+jK0bKX7ncl4H2hI5MRSpMoZXeM19S5xkJl/uPgMSZmZ2c/Ny3J8tJJ4F0IgBE2goUN2W/aKdgc6UGc1oilMLa5dslTlLScHGVnqJmEQ== 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=VDCN+MPkMjo4aOlN2psRXYaT5GRBAY6k6lCz9tlxhb8=; b=HMvS369MCfYXNPHIvXsvwQBvOCetjV80WIqpdzHMjtz2K1UpFThtjXjrW/3yHbCvDrk+fr/K1iVR54lXAHgSuLni4ymH/uelDNZj/w1nGhqB8WpdHz48wlZ9F9IZlnrU4uHr9GqwOEHHgsOkSqWv6tkUo67riP0SYb2Xt8NiWlL6P8eMJSy/7aGJxyea3mieE8YDeEoU5nBXq2BZ2lwY7fAtlc98gB7kdXP1R/o3PvQ7aKbEP38PNtEr2FNkw7LVI+RwHUnU3qMGn8E3g5cdJ5XB1fg+9cZYyEVT26SIpA1G84EZ50Bsr2rKSjR/GQZPKEpvS6w10K4m4H0hrUPFNQ== 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=VDCN+MPkMjo4aOlN2psRXYaT5GRBAY6k6lCz9tlxhb8=; b=Cj+EjB8SDPZu1WQ5rwAIPGszT6rBJVPUubjIGZ3cLlURPwkszm/7+UfPMCqzQwof/82UVk2MOl3zxGIiTcrXa4/x7oZN+JUH5LzLCeqrhjJTfcSIGwGEvr3zKOKCCD1tJrWdiP2yafIdnjM8fbaYQe1Pu3Ddwo85AaVnAYrd6e3LpjTHAaFEacedRdi8GCFqb7c5IEtd1KjnzCbhxjnoY23UIozgBWLbrsQovgkviBHw76KFobIhFoaMW8gH3tmefbm3MXjGSz72aDsw5iwaXQ8JWJFMrGEZPLHZiJB9Pa+nQZXQkRJNnMTvNheOG5TGWdssU/Tks4LCz4dkLebIuQ== Received: from MN2PR01CA0028.prod.exchangelabs.com (2603:10b6:208:10c::41) by BN9PR12MB5114.namprd12.prod.outlook.com (2603:10b6:408:137::21) 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 11:43:45 +0000 Received: from BL02EPF000100D1.namprd05.prod.outlook.com (2603:10b6:208:10c:cafe::fc) by MN2PR01CA0028.outlook.office365.com (2603:10b6:208:10c::41) 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 11:43:45 +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 BL02EPF000100D1.mail.protection.outlook.com (10.167.241.205) 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 11:43:44 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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 04:43:29 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail205.nvidia.com (10.129.68.10) 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 04:43:28 -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 04:43:25 -0700 To: Date: Wed, 29 Mar 2023 14:42:58 +0300 Message-ID: <20230329114259.110297-8-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230329114259.110297-1-cmi@nvidia.com> References: <20230329114259.110297-1-cmi@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF000100D1:EE_|BN9PR12MB5114:EE_ X-MS-Office365-Filtering-Correlation-Id: 6f6ad616-1fb7-4c81-1d61-08db304ada48 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LT9rFRkk6APQmcMwGk0M3Cltxd0jJSsN+SjP7d6zS13huBMMv39GCSAQZvf6ylbz6JQpG4/RRUnuGhMSy0j5RDlGDohukqup3Bo5sojnLEmF0VkAHBDtmg/m9VAmZhuD4LhqdWpXR5VRVZALYuUYughBE8z8bs4mZOMaJgyPz17+5D5tZBrIiJYy02TzmP9jgYN27TrrRtjICZ1TZySbURrfQpdjPY6tsULm0/3scrlnsAjWKcPtSUpJVqcg2708IGw2bbd92MBKS4f+u+/hrZqwJun/eE9GXMxx5bz7SS8CiwPAa5bKOMfoG+eYgpnF2mIxIC9Dvk8BW+grGhpOhGqKx1cAq89VSvluRVvV2LX7IL6vMuP5MKS/qnPG6heXM35jvZn4qlfZ5lHwaETrz7goLCGxq7VuXC2vhTqLCS/4ltbfSmIdX1UTaJlKaQKQQjr9YjqieLUM+dDMHsoCUekeGGm9x+xCxujClWoHscHndrLDdMptzjbQtm3AgIYpgsmuiIcY7RWcvADdfoM0gYcXTlSuDxfeT8yaSu8xYSzG2sPr4PFmXOeUEVQPOsgZMk552aKc4LuNaKLiracDx9VlYVmk8VSvkIj/s1DR4uwZC3lwFALcdQuneyFcvgd7mdw18+Poxh7+jllkScO4Fj4STZvMWzSH7l37KHW939/qzAbN9UXZa/+rKXqVwNT0hMyP3bHYGadjGKVFP/3ux3M/hNY1+u4BodYzz5xQ7fLugytfsrkx+uZKTzCHMwWU 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)(376002)(396003)(39860400002)(451199021)(46966006)(36840700001)(40470700004)(83380400001)(356005)(6666004)(107886003)(82740400003)(26005)(7636003)(1076003)(54906003)(478600001)(82310400005)(316002)(36756003)(70206006)(70586007)(8676002)(6916009)(41300700001)(40480700001)(4326008)(86362001)(2616005)(47076005)(336012)(30864003)(426003)(40460700003)(5660300002)(8936002)(2906002)(36860700001)(186003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Mar 2023 11:43:44.8898 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6f6ad616-1fb7-4c81-1d61-08db304ada48 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: BL02EPF000100D1.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5114 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 v26 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 | 277 +++++++++++++++++++++++++++++++++++++--- lib/tc.c | 62 ++++++++- lib/tc.h | 6 + 3 files changed, 323 insertions(+), 22 deletions(-) diff --git a/lib/netdev-offload-tc.c b/lib/netdev-offload-tc.c index 8c8f29af7..8357b6d7b 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) { @@ -409,7 +416,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); @@ -424,6 +432,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); @@ -887,6 +896,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); } @@ -2002,11 +2024,180 @@ 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 *next_actions, + size_t next_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->userspace_actions = xmalloc(next_actions_len + NLA_HDRLEN); + nullable_memcpy((char *) sample->userspace_actions + NLA_HDRLEN, + next_actions, next_actions_len); + sample->userspace_actions->nla_len = next_actions_len + NLA_HDRLEN; + } + + return 0; +} + +static int +parse_sample_action(struct tc_flower *flower, struct tc_action *tc_action, + const struct nlattr *next_actions, size_t next_actions_len, + const struct nlattr *sample_action, + const struct flow_tnl *tnl) +{ + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20); + struct offload_sample sample; + const struct nlattr *nla; + unsigned int left; + int err = EINVAL; + uint32_t sgid; + + err = offload_sample_init(&sample, next_actions, next_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.userspace_actions); + return err; +} + +static int +parse_userspace_action(struct tc_flower *flower, struct tc_action *tc_action, + const struct nlattr *next_actions, + size_t next_actions_len, + const struct nlattr *userspace_action, + const struct flow_tnl *tnl) +{ + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20); + struct offload_sample sample; + uint32_t sgid; + int err; + + err = offload_sample_init(&sample, next_actions, next_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.userspace_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) { @@ -2045,7 +2236,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, @@ -2061,7 +2252,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, @@ -2114,6 +2305,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) @@ -2243,7 +2435,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, @@ -2252,11 +2445,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)); @@ -2266,6 +2476,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, @@ -2561,16 +2787,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); @@ -2584,7 +2811,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; @@ -2593,14 +2821,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 11:42: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: 1762722 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=FPjGAj64; 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 4Pml8S3L1yz1yYr for ; Wed, 29 Mar 2023 22:44:40 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id AFE358415A; Wed, 29 Mar 2023 11:44:38 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org AFE358415A 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=FPjGAj64 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 YoQP3b2YridU; Wed, 29 Mar 2023 11:44:37 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 7B22E812F8; Wed, 29 Mar 2023 11:44:36 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 7B22E812F8 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 5E12BC0036; Wed, 29 Mar 2023 11:44:36 +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 20660C008C for ; Wed, 29 Mar 2023 11:44:35 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id E6CAA840A0 for ; Wed, 29 Mar 2023 11:43:55 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org E6CAA840A0 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 RleJWpofqphU for ; Wed, 29 Mar 2023 11:43:52 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 797048415A Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2062b.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eab::62b]) by smtp1.osuosl.org (Postfix) with ESMTPS id 797048415A for ; Wed, 29 Mar 2023 11:43:52 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UkVP8YPV0jurlSHZXyEalbusaGQI2SwBSwcC8lKvw06zppxFQvg6z3gnVbwVvHxAa4N17rSvwMlzl4F+mNmyS/2hlKb/30IG0LBAxrnOgrGEpo0Y3vzxpDNZ8EAYroiEIs6X17uAmQIh4WOIl7SMDfG4zjx/mmJkOvABoUfj6G2lV9ANiPGDy/cyfnQmXC3t6Cn4O5Nk90+5mK7RGtlyhZ7r08Jl9DXb8np5CL/6dhgL3+woP8Wi+9G0syoe2eKBXyDJY8Na4mhJJcAOBaWjcrlpzr0x+39Z1SKU0BqguWhz0m1SJPNkaEFSr1gWQfNrZFFZuIS026OXhhpA58b3/g== 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=aFK3X3BxlLx5AZ+ej0oI/0MxpZfH9ub+lt8YETyHZUg=; b=IufTQjkcYyTsIbGwK5Cbei7Fa6m+u+ldcGJfngi4VKcejqMYXmfV5NkZwwgFXAWD5DKZIVAH4MLV2RuXYK99a+XQjxVkFTBoki1R7MNjrtvLzmLXFcAtujAtbkf7T+gBAt64AX8nmxF/zvoA/yTS2y+VJivwRSQDcOIwQRzay0Ge5TPtRNvdluolNHkeJ1RWWXFUNufmU1I7mef2j118DYyQG+2od50OxqwcXz29ptVybwFp/XnENzgyzAW6Sgf5PW476Rcxnhv0hTlXqF8HIjmy2Vcyuy0hEHEJjQoZnKwiRx4UNn8oXNYgHYHQtg41JUz67eS2MPNojLVopRFeiw== 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=aFK3X3BxlLx5AZ+ej0oI/0MxpZfH9ub+lt8YETyHZUg=; b=FPjGAj64P+xXfHe0ErD+ZsPzjsph6gPMjiTrE8Os+wXgopk04o44AKOPVtSskVZqR31FLo/nFAmPuuM4wwCFBUpmbNL9Ma7WCgp09JBZZtyonA5BU9bxcwRWEYrDB3Y+JL46M63Jb7HGJWJy9jlxpRff/BhTDlFkKcvjXK//YGyeM66Plq3BVh89w4CmJGY9kuPmNBZMiV8ttpe28XyBO0rNv9EIJCmE9YKEiM/w6zkj07QhdLIyHhg0QfnogzzUKF8n9uhd93I683+SJF2rCuuT9Vd0yqhqdQuDvgAIShcVGbSqyfL9H6Va1zyMqJm/BCiriu5tqboMEjj88yVfhw== Received: from BN9PR03CA0900.namprd03.prod.outlook.com (2603:10b6:408:13c::35) by DS7PR12MB8249.namprd12.prod.outlook.com (2603:10b6:8:ea::16) 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 11:43:48 +0000 Received: from BL02EPF000100D0.namprd05.prod.outlook.com (2603:10b6:408:13c:cafe::f8) by BN9PR03CA0900.outlook.office365.com (2603:10b6:408:13c::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 11:43:47 +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 11:43:47 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) 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 04:43:32 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail202.nvidia.com (10.129.68.7) 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 04:43:32 -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 04:43:29 -0700 To: Date: Wed, 29 Mar 2023 14:42:59 +0300 Message-ID: <20230329114259.110297-9-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230329114259.110297-1-cmi@nvidia.com> References: <20230329114259.110297-1-cmi@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF000100D0:EE_|DS7PR12MB8249:EE_ X-MS-Office365-Filtering-Correlation-Id: 7f050b00-3926-4a1d-134d-08db304adbcc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wFGp+GWtLtR4CeIbSnfKT4JfcJdQFK5EcB5F8NW0qc/APoLMVk2ecJJ4OEFTB34wyIJo6vw+Yj7Qu7XaBpRaSKL/xaiew5H/J6FtZedrFaR/1eANHeST8wyzukthPc/NNwO21bcFJjEVDTNPU/qF0PfMCjxMUm0ifDAmACETKCjNO/9YsppRmUo/5Hc6hEXYAsuejQxB7isjCRMY3u+1ljjPgrmDqLEkE1Uvu6vRQAdEFyt0t5etiiCoCXhyKw/ed7mrEosCGr2xUef0v18Y/438ryYagSa5DwFvk8e1sglAM6JvZFxR0McUKdWCMtmDyg5s0l8U5FUtBVJtQZ1v6YwAR0e0UbRNC7IBAafOf5FnKutc9c5PvosZ0YtWH/N7GNxd8Ef8ejbXK/IV+vcP62ydAAJ5psoc2sy6HRCehBwneMbjUVOglDkDxE+aKD1zpMDtAhyqVUk7A9suLS4lcQ9pflpz1ES8m2HwH3IU7x5NGt/mqcCjOsWzuMTOAh79Fz0zhxlQ9Cis9AKxXyWKFFfU6L5BsZXqyP3UBQXi7Z2AlKUj3Q+FJNh7INs/uheCuz82O5Vrm414h9ShD5tDhFGNHts+4t7AQS/jicdwuXZkDTe8fPUXMF0ZcSANEKtrur+bbxdJW41G4Cg81VXgvcUR1NnAuX6qlXIo2SqTDcRqOaAKruGSHobh6ysxVjvXyZD7eNGkd7jP2DJ1yesrjv5izfmnPXf0mwYXsKcrv7Dp7CFoi4o8kuEbVCmebw1Z 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)(36840700001)(46966006)(40470700004)(47076005)(83380400001)(36756003)(426003)(336012)(186003)(26005)(82310400005)(2616005)(6666004)(107886003)(478600001)(54906003)(316002)(36860700001)(86362001)(1076003)(41300700001)(4326008)(6916009)(8676002)(40460700003)(82740400003)(40480700001)(8936002)(356005)(70586007)(7636003)(70206006)(5660300002)(2906002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Mar 2023 11:43:47.4323 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7f050b00-3926-4a1d-134d-08db304adbcc 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: DS7PR12MB8249 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 v26 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 | 125 +++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) diff --git a/tests/system-offloads-traffic.at b/tests/system-offloads-traffic.at index eb331d6ce..3a596eb19 100644 --- a/tests/system-offloads-traffic.at +++ b/tests/system-offloads-traffic.at @@ -93,6 +93,131 @@ 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 +out_tunnel_hdr="tunnel4_out_protocol=17 tunnel4_out_src=0.0.0.0 tunnel4_out_dst=172.31.1.1 tunnel4_out_src_port=0 tunnel4_out_dst_port=46354" +out_count=`grep "$out_tunnel_hdr" sflow.log | wc -l` +AT_CHECK([[[[ $out_count -ge 999 ]]]]) + +in_tunnel_hdr="tunnel4_in_protocol=17 tunnel4_in_src=172.31.1.1 tunnel4_in_dst=172.31.1.100" +in_count=`grep "$in_tunnel_hdr" sflow.log | wc -l` +AT_CHECK([[[[ $in_count -ge 999 ]]]]) + +OVS_TRAFFIC_VSWITCHD_STOP +OVS_APP_EXIT_AND_WAIT([test-sflow]) +AT_CLEANUP + AT_SETUP([offloads - set ingress_policing_rate and ingress_policing_burst - offloads disabled]) AT_KEYWORDS([ingress_policing]) AT_SKIP_IF([test $HAVE_TC = "no"])