From patchwork Tue Feb 28 13:20:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Mi X-Patchwork-Id: 1749451 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=UBI4UCWU; 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 4PQyft0WMJz1yWy for ; Wed, 1 Mar 2023 00:20:53 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 595F58143C; Tue, 28 Feb 2023 13:20:51 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 595F58143C 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=UBI4UCWU 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 BF_eRojx2KyL; Tue, 28 Feb 2023 13:20:50 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id B987081F96; Tue, 28 Feb 2023 13:20:48 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org B987081F96 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 7638BC0070; Tue, 28 Feb 2023 13:20:48 +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 3D5B4C0070 for ; Tue, 28 Feb 2023 13:20:47 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 09E4440B6E for ; Tue, 28 Feb 2023 13:20:47 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 09E4440B6E 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=UBI4UCWU 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 BGrwn0v8gyGG for ; Tue, 28 Feb 2023 13:20:43 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 828D840144 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on20600.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eae::600]) by smtp2.osuosl.org (Postfix) with ESMTPS id 828D840144 for ; Tue, 28 Feb 2023 13:20:43 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GDKWCp0qG5GKiYcyWj874MSupW0dlQ5LFyQ+bp24P7B1C98ylDrzHTVQfsjsGELnRuTFY0ThAxcr43Q2TG1mBu4Z3qnTpvEbPnKWDZGh4BoA6/RupW5CI8Io5Ea5U88ApYcpg3WU7KFTtkCcnwLBQCvbq1hdgg/y5FbVSg3e3f1gYAsB2Lo6jHajOzk7uIF51eJ1w+p+3r6wMZz6iNPYMMdIE3lVsq+uUXwkynJaG319KYEC8MErNXbdsUBsH1bFjA8JU5Jjb+D49jyaUrMw4tdZw5a3MvWcXOTgbYr7U/YvTWkeSi87ACWzoo9EOSJN5D0TovDgFRqQij2X2X7MPA== 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=j5p1JthB2bul6xEl5ATAuG6D2gbaBGbpmebcUrKiSD8=; b=jlkVkH7d9Ii9rkR9HbvJH5ufw1f6oKnWRXebyC4KY9pq8OzIJ9j2YHO5FEYC0hm8qIvC6+isOhGfYGkCVi42Gth++Gwq0ZcpwpBIh2zAgjrpTnzFivbwGkwj5MyBA+ht5haDs296UpE0bb3q8FFP8r06FabVQxThYeoQv18kcDnsYP73lQxeJXEo2lZ7WuiiB2N1B7y966QleNxTyl7JJTPzsngVZM/yIN547PeN4b/1SojjFrNEo5zIVp2fkUSuubDH9IyJMID7Q78OSXX+lNXrAgNpSrMFTDJhUeC25539ZDNxBHa/FVOBL5c9GIRp2RxBAG7otEpOfB35Pl2E7A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=openvswitch.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=j5p1JthB2bul6xEl5ATAuG6D2gbaBGbpmebcUrKiSD8=; b=UBI4UCWUbxJvtRoXkX5jsHSIyUCPzKR7MVTLUinCNe4EPzTPHtOM+aubVOKMzzD/aE7Smwr3xVIQ9JOAPPdbScUuJkyUcGMWvF/k31ZJs3BeageAlkwzlvoNxA8agA9XkbhfVAvUUOWcxqcJGl0hds8e/zdwwk/oTzz8VcY45OSXpEzfdkwA+qbeonIJz1pQfVdmITB+2Pspesb8Z7LO6+3DfUy02P9SclfLbYYRJrjeR00Pi4kojU+Np0E0hATtTD5AUkI9xjJRFS7zutMF3jtrCkVCNgb4IvQfpIZXVWLwa5hCmj764UZrA5m9zO4lSSoeicnP102aUc3jtPWsiA== Received: from BN8PR03CA0012.namprd03.prod.outlook.com (2603:10b6:408:94::25) by IA0PR12MB8374.namprd12.prod.outlook.com (2603:10b6:208:40e::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.30; Tue, 28 Feb 2023 13:20:41 +0000 Received: from BN8NAM11FT008.eop-nam11.prod.protection.outlook.com (2603:10b6:408:94:cafe::4d) by BN8PR03CA0012.outlook.office365.com (2603:10b6:408:94::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.30 via Frontend Transport; Tue, 28 Feb 2023 13:20:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by BN8NAM11FT008.mail.protection.outlook.com (10.13.177.95) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.17 via Frontend Transport; Tue, 28 Feb 2023 13:20:40 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Tue, 28 Feb 2023 05:20:32 -0800 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Tue, 28 Feb 2023 05:20:32 -0800 Received: from c-237-115-60-065.mtl.labs.mlnx (10.127.8.10) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.5 via Frontend Transport; Tue, 28 Feb 2023 05:20:29 -0800 To: Date: Tue, 28 Feb 2023 15:20:17 +0200 Message-ID: <20230228132024.671271-2-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230228132024.671271-1-cmi@nvidia.com> References: <20230228132024.671271-1-cmi@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT008:EE_|IA0PR12MB8374:EE_ X-MS-Office365-Filtering-Correlation-Id: cacc14a6-5534-4a28-db59-08db198e96dc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GKHWjh/eOB6GdBjxZJpfoIK7YosIMpcv7JkmTP8AEUCo2qKH1Cp5i1MQbxxFhLx+bk3RYcLgyhmk4iN5eAJpU/fa89OJYAckXQdIBbGCrZbndXFdGqHcQ9PcDjz9MJAh40m3VnYCKRKAeV/r82M1Iu0bB466a13LLJYkB2875nPH1jQQsnk03mQXY/RUkJa0K7CyTbYiXRbqSEzGFiN187zOqRFP2UAK6MwOJa/ZvVBrjHhpYNOfhdqMQiLnHvUQ5cBfkPcXDbjHS3bOMvGP5pTe9snV9Lh8BL/YjSrRLm7Ozoy0tUJW6gKGXBj9Pyntk6x3NWrCChn6h33pi37uNVun0MZ9Co86LHw5EapxsUqhz+WP6xD1ikQFqhabiwgsGF8ImlyKQzrG3Yb7G2WojX1G4L/mngwI/qa5+wCWC4fLYiwruLIX1wCksMog6mm5nYd+ggOjbvoBxE7p5nOCFeBBGWT15thDPvrpKhtH0zuSwMDwznjNZj9Z2xovvTYeSAc/QDQfZkxb7BPO6HrzqKlsw8bKt0rOPjNSzJpnVKgwb9uvduGJEJi82UYIoeKVbzyUU4Ex8Q6Tv07FX+TZInL/lW2YxHBk6bgmIA62/Doi+f/UserWEtOEHqhQZEZzFaakmIKBRjITT5AETNWaGsqMkE1t3/GNmo7XK0gemoueJd3KZXdPVeJksqh6IS5exjS2WhEiGVhSIDh+0jnJPFvf5ZUlo9ebNjeQe6QDoOU= X-Forefront-Antispam-Report: CIP:216.228.118.233; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge2.nvidia.com; CAT:NONE; SFS:(13230025)(4636009)(136003)(376002)(346002)(39860400002)(396003)(451199018)(40470700004)(36840700001)(46966006)(8936002)(5660300002)(26005)(186003)(1076003)(316002)(8676002)(70586007)(70206006)(41300700001)(6916009)(4326008)(36756003)(54906003)(83380400001)(40460700003)(478600001)(40480700001)(86362001)(2906002)(107886003)(6666004)(336012)(426003)(47076005)(356005)(2616005)(82740400003)(82310400005)(7636003)(34020700004)(36860700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2023 13:20:40.8289 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cacc14a6-5534-4a28-db59-08db198e96dc X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.233]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT008.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8374 Cc: elibr@nvidia.com, simon.horman@corigine.com, roniba@nvidia.com, i.maximets@ovn.org, konguyen@redhat.com, majd@nvidia.com Subject: [ovs-dev] [PATCH v23 1/8] compat: Add psample and tc sample action defines for older kernels X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Chris Mi via dev From: Chris Mi Reply-To: Chris Mi Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Update kernel UAPI to support psample and the tc sample action. Signed-off-by: Chris Mi Reviewed-by: Roi Dayan Acked-by: Eelco Chaudron --- include/linux/automake.mk | 4 ++- include/linux/psample.h | 62 ++++++++++++++++++++++++++++++++ include/linux/tc_act/tc_sample.h | 25 +++++++++++++ 3 files changed, 90 insertions(+), 1 deletion(-) 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..0de7ff945 100644 --- a/include/linux/automake.mk +++ b/include/linux/automake.mk @@ -9,4 +9,6 @@ noinst_HEADERS += \ 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_ct.h \ + include/linux/tc_act/tc_sample.h \ + include/linux/psample.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 Tue Feb 28 13:20:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Mi X-Patchwork-Id: 1749452 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=o0g/tYWD; dkim-atps=neutral Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PQyfv2jPCz1yWy for ; Wed, 1 Mar 2023 00:20:55 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 79FA4418D4; Tue, 28 Feb 2023 13:20:53 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 79FA4418D4 Authentication-Results: smtp4.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=o0g/tYWD 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 9JU2KGNLVZTj; Tue, 28 Feb 2023 13:20:52 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTPS id 597964189C; Tue, 28 Feb 2023 13:20:50 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 597964189C Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4AFF3C007D; Tue, 28 Feb 2023 13:20:49 +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 BAA3AC0033 for ; Tue, 28 Feb 2023 13:20:47 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 911E1418BC for ; Tue, 28 Feb 2023 13:20:47 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 911E1418BC 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 0FGanxbI5QwP for ; Tue, 28 Feb 2023 13:20:45 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 63101418A6 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2061f.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5b::61f]) by smtp4.osuosl.org (Postfix) with ESMTPS id 63101418A6 for ; Tue, 28 Feb 2023 13:20:45 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hwTSkErjV2nmRI7QsAGaUeM+ukMqhEqlhUFGTRCh1MU9w9ogBMJR1tjzjbFDlH0IxpyW8/f8Ax9dWukkdVIG6ordGtRvuLhZeus4xf8MhC6spdch5nXmJuDmsM6sSxgoBnvmOBb6602fSk7D6iIU8VHzXeOcgaWfo5EA6bP94b0gPLC/Mktm5nEb0uFj+i1oXeRsuln/oQSu0NK1nQlOvTVYVxj0XQk3/O+TJmFEp48kBe2v+xxz1e6CkjrHFC7Cc0JQF/SX6kimNdRB8LGVl4fU/ONaw2KmUhU+sLwBuZcmw5qEc9qwPDaXPAY0wrVJrwwSz69K8DV4IsnwgsTxEA== 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=FO7zcqD6P/vyOfP9A760YtkwhJQWzpoS+4/MDh9LgbxVFdlXNHdIwU6fN2gQuXmH32EhqOQriFV0kP6NHG5J9h6YqNr+HPfQPFKukUP/qJjHnqyniqJiGQ40ZzNHKKJIoCQhmBryEwpXXaMDwC/SxV8B8oRQMMjaas09cUUGGH0MrDF4+CCEQ1W7ca/zV7BbFxSkLBQaFJ14ARs3R8xSNDMj/BD4U79GcLRfAVTOTA2i5NKTxvUjSY31XUrALeBr/6ldQHh7ziOD2HdPZTRaSmFAxoLD9hhcLPktKmly0Ax8ml4UoYmyKTobNVBomDdpaUtSB3LNnkOzzEPsAk0NyQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=openvswitch.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ol/bVZ/jkiZTV5fMK4ElSYc14fs0ViONNZedP3kh02U=; b=o0g/tYWDRrPIxrEdWz5cR658olDkSBsC4i2kd9vrud4QugHG3r+BSFrmsnielmz8tSeOHHWGBw3VTuElh83/eiF+wFTiUpOF2NhRhPEYTZZVu0vRnFS6k5xH3/Arj+wXyrISeIwqnUUbHbtGcEfAlaRU1/cdFRDluSgI1hjGlKTddDtyRvJgEswr7W3JRUymqqzWGxBRCNyeAGXDDhzCFKa2Hu9aG2HPu4erqZS/l+Zs5+r66YLs+bnRrROeWwdECHTu2aiC7ApCrqDXmjycCxOwJBYvHkoN0/Chh+Bl2MRcXJvC2MfPp8p7lmWvgGRjz+PPCvKM0SxrWqlIgmJUPQ== Received: from MW4PR04CA0217.namprd04.prod.outlook.com (2603:10b6:303:87::12) by SN7PR12MB6981.namprd12.prod.outlook.com (2603:10b6:806:263::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.30; Tue, 28 Feb 2023 13:20:42 +0000 Received: from CO1NAM11FT051.eop-nam11.prod.protection.outlook.com (2603:10b6:303:87:cafe::b5) by MW4PR04CA0217.outlook.office365.com (2603:10b6:303:87::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.30 via Frontend Transport; Tue, 28 Feb 2023 13:20:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by CO1NAM11FT051.mail.protection.outlook.com (10.13.174.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.17 via Frontend Transport; Tue, 28 Feb 2023 13:20:41 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Tue, 28 Feb 2023 05:20:35 -0800 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Tue, 28 Feb 2023 05:20:35 -0800 Received: from c-237-115-60-065.mtl.labs.mlnx (10.127.8.10) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.5 via Frontend Transport; Tue, 28 Feb 2023 05:20:32 -0800 To: Date: Tue, 28 Feb 2023 15:20:18 +0200 Message-ID: <20230228132024.671271-3-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230228132024.671271-1-cmi@nvidia.com> References: <20230228132024.671271-1-cmi@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT051:EE_|SN7PR12MB6981:EE_ X-MS-Office365-Filtering-Correlation-Id: 9f22899b-d6cf-4b44-c326-08db198e9749 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: He3t5dwF94p1GJQ+RXbowznRSrxDy7d/OlkA3QGOYSe7rQByvqy+MSMFn4bLkUrB4QBHpyblKI12/3dP66/GG1YT3IPgIIyhRvZKHx+YtNfwr5+Vn/wQIMulteOtuRWb350DOTprDWAsz/MPzZz2UWuIoDtWRg+ZJfBTWcv2xxxDfitJqiJvRH7KAH0MN02UVq0GeCRkclQnAsRM5lBCEJgiAEelsJa6zAzyLxwOqjSdvDtlWXkW+Nt/YPAu/2w4j8XlhFZ9zJgw5BalnXi7B/H4FMjEu/7n0eLMV3VHZYGJmJiAOpKBt15NFTkYAcNP/ykr84HCV4sRE4Hr3FCYev3wsFGjguUKU40okk8VQ9Fpko8SVfqyKivjisqkfHOduWs2URsvlV1EF7sg3qN+tQIEPyx+W0mKto4ri9YX4+vVR0GneOv5FeOYIoWEFfqNFcBd8rJyRdkhzXtuCIO3sLGUUEfWzGUk4OsH3VE6SbM6Lb421xcc6Xsr/VGwck1G7n/uKfe3TWvhQE6vIBn+6s0pIWozQZNuLeylQwe472QziSeqAepSwb8JjD60LswNcQofpEK8ElA1yHl22/K5mpPUlEqd7ONChnHHWbtJ9eYCuqqJJWSwcv35BUwBmUcpF9H4YHeogmL9YDgGMKW7QqIBqa2AIuSwu6HzikQRqwk2sOHDKWJs8OZtwZhuUidOnV5GIbnOKnaXzRaBSOxVdE8ZaiZ2m/ulHrUmcz91Bsc= X-Forefront-Antispam-Report: CIP:216.228.118.232; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge1.nvidia.com; CAT:NONE; SFS:(13230025)(4636009)(376002)(396003)(136003)(39860400002)(346002)(451199018)(40470700004)(46966006)(36840700001)(34020700004)(36860700001)(82740400003)(7636003)(356005)(86362001)(36756003)(2906002)(40480700001)(8676002)(70206006)(5660300002)(41300700001)(8936002)(4326008)(6916009)(82310400005)(70586007)(2616005)(40460700003)(1076003)(336012)(186003)(83380400001)(426003)(47076005)(26005)(478600001)(316002)(107886003)(6666004)(54906003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2023 13:20:41.6207 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9f22899b-d6cf-4b44-c326-08db198e9749 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.232]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT051.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6981 Cc: elibr@nvidia.com, simon.horman@corigine.com, roniba@nvidia.com, i.maximets@ovn.org, konguyen@redhat.com, majd@nvidia.com Subject: [ovs-dev] [PATCH v23 2/8] ovs-kmod-ctl: Load kernel module psample X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Chris Mi via dev From: Chris Mi Reply-To: Chris Mi Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Load kernel module psample to receive sampled packets from TC. Before removing kernel module psample, remove act_sample first. Signed-off-by: Chris Mi Reviewed-by: Roi Dayan Acked-by: Eelco Chaudron --- utilities/ovs-kmod-ctl.in | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/utilities/ovs-kmod-ctl.in b/utilities/ovs-kmod-ctl.in index 19f100964..6fa945a83 100644 --- a/utilities/ovs-kmod-ctl.in +++ b/utilities/ovs-kmod-ctl.in @@ -28,6 +28,14 @@ for dir in "$sbindir" "$bindir" /sbin /bin /usr/sbin /usr/bin; do done insert_mods () { + # Try loading psample kernel module. + modinfo psample > /dev/null 2>&1 + if test $? = 0; then + action "Inserting psample module" modprobe psample + else + log_warning_msg "No psample module, can't offload sFlow action" + fi + # Try loading openvswitch kernel module. action "Inserting openvswitch module" modprobe openvswitch } @@ -95,6 +103,12 @@ remove_kmods() { if test -e /sys/module/vxlan; then action "Forcing removal of vxlan module" rmmod vxlan fi + if test -e /sys/module/act_sample; then + action "Forcing removal of act_sample module" rmmod act_sample + fi + if test -e /sys/module/psample; then + action "Forcing removal of psample module" rmmod psample + fi } usage () { From patchwork Tue Feb 28 13:20:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Mi X-Patchwork-Id: 1749456 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=HzidbwUG; dkim-atps=neutral Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PQygT6Lklz1yWy for ; Wed, 1 Mar 2023 00:21:25 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 2EF37611C0; Tue, 28 Feb 2023 13:21:23 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 2EF37611C0 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=HzidbwUG 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 e-7iN3-eQkOG; Tue, 28 Feb 2023 13:21:19 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 1A45461150; Tue, 28 Feb 2023 13:21:13 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 1A45461150 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id BAE4DC0033; Tue, 28 Feb 2023 13:21:12 +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 1C006C0078 for ; Tue, 28 Feb 2023 13:21:12 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 0F28240BF6 for ; Tue, 28 Feb 2023 13:21:01 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 0F28240BF6 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=HzidbwUG 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 YMyud01SMfFh for ; Tue, 28 Feb 2023 13:20:56 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 9B69240BE1 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2062d.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8a::62d]) by smtp2.osuosl.org (Postfix) with ESMTPS id 9B69240BE1 for ; Tue, 28 Feb 2023 13:20:56 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Edsy8ePUbbULp0qeECr4ocZ2JVpM0giWOJvSJpehDZSvZAPwfAEjbF0/5wob9ZiCURGbjuY4mwl1T3I80tGAhIaYT4JQ7XpwHva+elJljhlzppOCSomvXSa6RM5CPijfCSY2CbDvCY38gYZ1UZP8JBcm3JS0q8H8745wR5CIqfGypkWiJgqWSBA5L2TtMASb6IB0+fQYJssJEmE0R085S3ezq9LNEfG24ZIMq66SQ4HRJVKe7wbkkXJRaMLQUQrPeXSfFWeJYbwp6NYNpPPqOzwKam/jjHfzAPXcyq7+gX3dMSPi5KUk3/8eG6oKhqrA6Ylp6h9b/yQsiT6ONxFj7g== 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=KbsUAa60kWq8eTmJf+7u0VpjbsLJtXH1gtDQ5V2WFMs=; b=S+7FVRx9RmZoEsVZK16x1ai9sI+d3b1dmrRXCd8Nhj5R7MUq2zonbMtuhlgpmMaM8oCP0EZmwt6SB8P+SbcTU3h9g5144byHTu5vj/qhQ14tjsGeMSAfdL+5DD/ogO0h35uWYFLPysOL0H1pe6YpQgKAyQgC4cmCQ42ZIRyrUuIdWIgVD8k4rd0/ANULRczI3570a5OuzVrtHj6RhEj+IJZ9KMDpoJoR7po9tu/Y4QnjDApDQnHWapdCkk2Zol/dCG0nRvDlu/SWEkidIcDCgA++2Z/moeduFohMd2jWACic+pGRwip0boV+hMRsBaKD5utt5E7u7WPHzSt8EYHjjg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=openvswitch.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KbsUAa60kWq8eTmJf+7u0VpjbsLJtXH1gtDQ5V2WFMs=; b=HzidbwUGMpPXzypKJ+dpOA2WrststRZFfhy1V2MvLUN9vDr2eSHIgzPwIbWMH7CCZ1l6LUOgGQFjhelANFVtDvSyKUqQ4NtvJ390mvueyFCTQJUfxUTkf7c7BtCuYVZaozAhY/1c4IyOyki/HaD3MTuAaUOnxS+UpxNHVWMCLyAsXJdO0QUrYhY60Bd0hWa8bk+TUukp2ZdtaDaAHg8wGBBPG9cKKKwwjlS6a1npEz/bkoTtJzWGKJURAGYbivi/CFZxTBncQqYEx9PeeOeCmqzR1NKWeexhIj2ToisqxITVgiUrLRFYABahvMg3yKnoEZFlXXYbKw42s2CGMXARtQ== Received: from BN8PR03CA0024.namprd03.prod.outlook.com (2603:10b6:408:94::37) by DS0PR12MB8072.namprd12.prod.outlook.com (2603:10b6:8:dd::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.29; Tue, 28 Feb 2023 13:20:46 +0000 Received: from BN8NAM11FT008.eop-nam11.prod.protection.outlook.com (2603:10b6:408:94:cafe::c6) by BN8PR03CA0024.outlook.office365.com (2603:10b6:408:94::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.30 via Frontend Transport; Tue, 28 Feb 2023 13:20:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by BN8NAM11FT008.mail.protection.outlook.com (10.13.177.95) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.17 via Frontend Transport; Tue, 28 Feb 2023 13:20:45 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Tue, 28 Feb 2023 05:20:38 -0800 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Tue, 28 Feb 2023 05:20:38 -0800 Received: from c-237-115-60-065.mtl.labs.mlnx (10.127.8.10) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.5 via Frontend Transport; Tue, 28 Feb 2023 05:20:35 -0800 To: Date: Tue, 28 Feb 2023 15:20:19 +0200 Message-ID: <20230228132024.671271-4-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230228132024.671271-1-cmi@nvidia.com> References: <20230228132024.671271-1-cmi@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT008:EE_|DS0PR12MB8072:EE_ X-MS-Office365-Filtering-Correlation-Id: ba747522-2548-430d-07c0-08db198e99e6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0W64docKOk/2ZKaZd6L7dn1AWBFccWS5BeDpSJiUPkgzscQLHtos3m+kuKU8umLYLkBcSsTxndn7UXeGUgLpAc6C58LHcNR3Y45KSzuYNi9qHK6iHrbUzgxqg7mJRwj0swg8d2cUw2IiQAQWS9FK5XinSdaVeMk6Eoan8zNQuUg+2eFFdfpa3a5vWfv0AwFJ9qZxeydgenAA/qUFG6nyIHDL2kv0yiogNLCih0vJOx33DQIoZxTim9RaY8g56OrUrwCCeFDhADnfc6nUFy8b8l1TiaOJO3zIlzwF3zmEXE1XsTow7zxKjekMbbOUKzp550V5/0G8d8HwNXHtRPjyb1tswtA9UEl56G2UM6L58MpdWoDe5ZqQS2bAc/ZT/zF9bvOtLCiUwkI3TiAy2M6nzhuaMu6EzApcfyc8Vykvj2WhvWHdRQd/3B4SXnwhNo0I3uzu+BHnTpKzY7175udsPJckjYQZvj9cDPgrvq191EM7jNpruythr+P1K8KfCrkZoy68B6M4pcjgLXcJbQblPvMn1/eZ0h3YMpCgLZg7AfKkXf2gVHgf3blKpWPHb2OdFhFcSTvtN7qNv2lY9HLlCUtFir/H5xj8lpTZ0emZRGcxlc5AGks2QMUQE8SgS6aU69pzdrYAzjsk5aJ8oQDmjcb1gS2/OhDwhBZfA3pjPw0nm4+Q6eFXP54kgtEn88yX7hNOpv2izU9/lin3c4P9RFXwnin1R+++8MNVrH81pmk= X-Forefront-Antispam-Report: CIP:216.228.118.233; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge2.nvidia.com; CAT:NONE; SFS:(13230025)(4636009)(346002)(396003)(376002)(39860400002)(136003)(451199018)(46966006)(36840700001)(40470700004)(5660300002)(40460700003)(36756003)(40480700001)(86362001)(8936002)(478600001)(47076005)(426003)(2616005)(336012)(83380400001)(82310400005)(6666004)(107886003)(26005)(4326008)(356005)(70206006)(70586007)(186003)(41300700001)(1076003)(8676002)(6916009)(54906003)(34020700004)(316002)(7636003)(82740400003)(36860700001)(2906002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2023 13:20:45.9065 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ba747522-2548-430d-07c0-08db198e99e6 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.233]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT008.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8072 Cc: elibr@nvidia.com, simon.horman@corigine.com, roniba@nvidia.com, i.maximets@ovn.org, konguyen@redhat.com, majd@nvidia.com Subject: [ovs-dev] [PATCH v23 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 sFlow action and tunnel info and passes this ID to kernel instead of the sFlow info. Psample will send this ID and sampled packet to userspace. Using the ID, userspace can recover the sFlow info and send sampled packet to the right sFlow monitoring host. Signed-off-by: Chris Mi Reviewed-by: Roi Dayan --- lib/netdev-offload-tc.c | 228 +++++++++++++++++++++++++++++++++++++++- lib/tc.h | 1 + 2 files changed, 227 insertions(+), 2 deletions(-) diff --git a/lib/netdev-offload-tc.c b/lib/netdev-offload-tc.c index 4fb9d9f21..29a3b91df 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,221 @@ 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 sFlow action and tunnel info and passes this ID to kernel + * instead of the sFlow info. Psample will send this ID and sampled + * packet to userspace. Using the ID, userspace can recover the sFlow + * info and send sampled packet to the right sFlow monitoring host. + */ +struct offload_sflow { + struct nlattr *action; /* SFlow action. Used in flow_get. */ + struct nlattr *userdata; /* Struct user_action_cookie. */ + struct nlattr *actions; /* All actions to get output tunnel. */ + struct flow_tnl *tunnel; /* Input tunnel. */ + ovs_u128 ufid; /* Flow ufid. */ +}; + +/* This maps a psample group ID to struct offload_sflow. */ +struct sgid_node { + struct cmap_node metadata_node; + struct cmap_node id_node; + struct ovs_refcount refcount; + uint32_t hash; + uint32_t id; + struct offload_sflow sflow; +}; + +static struct ovs_mutex sgid_lock = OVS_MUTEX_INITIALIZER; +static struct cmap sgid_map = CMAP_INITIALIZER; +static struct cmap sgid_metadata_map = CMAP_INITIALIZER; +static struct id_pool *sample_group_ids OVS_GUARDED_BY(sgid_lock); + +static void +sgid_node_free(struct sgid_node *node) +{ + if (node) { + if (node->sflow.tunnel) + free(node->sflow.tunnel); + if (node->sflow.action) + free(node->sflow.action); + if (node->sflow.actions) + free(node->sflow.actions); + if (node->sflow.userdata) + free(node->sflow.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 uint32_t +offload_sflow_hash(const struct offload_sflow *sflow) +{ + return hash_bytes(&sflow->ufid, sizeof sflow->ufid, 0); +} + +static bool +offload_sflow_equal(const struct offload_sflow *a, const struct offload_sflow *b) +{ + if (!ovs_u128_equals(a->ufid, b->ufid)) { + return false; + } + /* Action can't be NULL. */ + if (!a->action || !b->action) { + return false; + } + if (a->action->nla_len != b->action->nla_len + || memcmp(a->action, b->action, a->action->nla_len)) { + return false; + } + /* Actions is used to get output tunnel. It can be NULL. */ + if ((a->actions && !b->actions) || (!a->actions && b->actions)) { + return false; + } + if ((a->actions && b->actions && + a->actions->nla_len != b->actions->nla_len) + || memcmp(a->actions, b->actions, a->actions->nla_len)) { + return false; + } + /* Tunnel is used to get input tunnel. It can be NULL. */ + if (!a->tunnel && !b->tunnel) { + return true; + } + if (!a->tunnel || !b->tunnel) { + return false; + } + return !memcmp(a->tunnel, b->tunnel, sizeof *a->tunnel); +} + +static struct sgid_node * +sgid_find_equal(const struct offload_sflow *target, uint32_t hash) +{ + struct sgid_node *node; + + CMAP_FOR_EACH_WITH_HASH (node, metadata_node, hash, &sgid_metadata_map) { + if (offload_sflow_equal(&node->sflow, target)) { + return node; + } + } + return NULL; +} + +static struct sgid_node * +sgid_ref_equal(const struct offload_sflow *target, uint32_t hash) +{ + struct sgid_node *node; + + do { + node = sgid_find_equal(target, hash); + /* Try again if the node was released before we get the reference. */ + } while (node && !ovs_refcount_try_ref_rcu(&node->refcount)); + + return node; +} + +static void +offload_sflow_clone(struct offload_sflow *new, const struct offload_sflow *old) +{ + new->action = xmemdup(old->action, old->action->nla_len); + new->actions = old->actions + ? xmemdup(old->actions, old->actions->nla_len) + : NULL; + new->userdata = xmemdup(old->userdata, old->userdata->nla_len); + new->tunnel = old->tunnel + ? xmemdup(old->tunnel, sizeof *old->tunnel) + : NULL; + new->ufid = old->ufid; +} + +/* Allocate a unique group id for the given set of flow metadata. The id + * space is 2^^32 - 1. 0 is reserved. + */ +static struct sgid_node * +sgid_alloc(const struct offload_sflow *sflow, uint32_t hash) +{ + struct sgid_node *node = xzalloc(sizeof *node); + bool ret; + + node->hash = hash; + ovs_refcount_init(&node->refcount); + offload_sflow_clone(&node->sflow, sflow); + + ovs_mutex_lock(&sgid_lock); + ret = id_pool_alloc_id(sample_group_ids, &node->id); + if (!ret) { + VLOG_ERR("Can't find a free group ID"); + ovs_mutex_unlock(&sgid_lock); + sgid_node_free(node); + return NULL; + } + + cmap_insert(&sgid_map, &node->id_node, node->id); + cmap_insert(&sgid_metadata_map, &node->metadata_node, node->hash); + ovs_mutex_unlock(&sgid_lock); + return node; +} + +/* Allocate a unique group id for the given set of flow metadata and + * optional actions. + */ +static uint32_t +sgid_alloc_ctx(const struct offload_sflow *sflow) +{ + uint32_t hash = offload_sflow_hash(sflow); + struct sgid_node *node = sgid_ref_equal(sflow, hash); + + if (!node) { + node = sgid_alloc(sflow, hash); + } + + return node ? node->id : 0; +} + +static void +sgid_node_unref(struct sgid_node *node) + OVS_EXCLUDED(sgid_lock) +{ + ovs_mutex_lock(&sgid_lock); + if (node && ovs_refcount_unref(&node->refcount) == 1) { + id_pool_free_id(sample_group_ids, node->id); + cmap_remove(&sgid_metadata_map, &node->metadata_node, node->hash); + cmap_remove(&sgid_map, &node->id_node, node->id); + ovsrcu_postpone(sgid_node_free, node); + } + ovs_mutex_unlock(&sgid_lock); +} + +static void +sgid_free(uint32_t id) +{ + struct sgid_node *node; + + if (!id) { + return; + } + + node = sgid_find(id); + if (node) { + sgid_node_unref(node); + } else { + VLOG_ERR("Freeing nonexistent group ID: %"PRIu32, id); + } +} + +static int +tc_del_flower_filter_and_sgid(struct tcf_id *id) +{ + sgid_free(id->sample_group_id); + id->sample_group_id = 0; + return tc_del_flower_filter(id); +} + static bool is_internal_port(const char *type) { @@ -275,7 +491,7 @@ del_filter_and_ufid_mapping(struct tcf_id *id, const ovs_u128 *ufid, } } - err = tc_del_flower_filter(id); + err = tc_del_flower_filter_and_sgid(id); if (!err) { del_ufid_tc_mapping(ufid); } @@ -545,7 +761,7 @@ netdev_tc_flow_flush(struct netdev *netdev) continue; } - err = tc_del_flower_filter(&data->id); + err = tc_del_flower_filter_and_sgid(&data->id); if (!err) { del_ufid_tc_mapping_unlocked(&data->ufid); } @@ -2118,6 +2334,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_sflow sflow; + + memset(&sflow, 0, sizeof sflow); + sgid_alloc_ctx(&sflow); } else { VLOG_DBG_RL(&rl, "unsupported put action type: %d", nl_attr_type(nla)); @@ -2853,6 +3074,9 @@ netdev_tc_init_flow_api(struct netdev *netdev) tc_cleanup_policer_actions(meter_police_ids, METER_POLICE_IDS_BASE, METER_POLICE_IDS_MAX); ovs_mutex_unlock(&meter_police_ids_mutex); + ovs_mutex_lock(&sgid_lock); + sample_group_ids = id_pool_create(1, UINT32_MAX - 1); + ovs_mutex_unlock(&sgid_lock); ovsthread_once_done(&once); } diff --git a/lib/tc.h b/lib/tc.h index cdd3b4f60..0d9b1b8e7 100644 --- a/lib/tc.h +++ b/lib/tc.h @@ -312,6 +312,7 @@ struct tcf_id { uint32_t chain; uint16_t prio; uint32_t handle; + uint32_t sample_group_id; }; static inline struct tcf_id From patchwork Tue Feb 28 13:20:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Mi X-Patchwork-Id: 1749454 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=A50nEtuq; 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 4PQyg76Rnbz1yWy for ; Wed, 1 Mar 2023 00:21:07 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id ADEA540BCE; Tue, 28 Feb 2023 13:21:05 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org ADEA540BCE 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=A50nEtuq 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 ADSZa5Sw5ySW; Tue, 28 Feb 2023 13:21:01 +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 B07DB40BF2; Tue, 28 Feb 2023 13:20:59 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org B07DB40BF2 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 74010C0085; Tue, 28 Feb 2023 13:20:57 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 02AEFC002B for ; Tue, 28 Feb 2023 13:20:56 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 8D87160E46 for ; Tue, 28 Feb 2023 13:20:52 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 8D87160E46 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=A50nEtuq 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 99gN7yH3GPSz for ; Tue, 28 Feb 2023 13:20:51 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 1B2946114B Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on20607.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e88::607]) by smtp3.osuosl.org (Postfix) with ESMTPS id 1B2946114B for ; Tue, 28 Feb 2023 13:20:50 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mv+YdzgQuDHRvT2tnyg8EXx9aHgYaXs3398eICDZuqRQ7rajpfx+q++WR0n8wMm6XRocHoHLbxggHSLap9Gp1ErUokmMfqYg/vXv8E2Yet8SEXEdKvh+vb4lX4Pi9bO+0RQFDGv/TtUXIpXQfrd7UxxKoVAxRwNc6CiHW4f8fNrWacIHRRNI/bWFZNE4CsFT4IT7NagLfSG/L19LFAHKa6rxw5kj7Sg90cQy1Ka9dc3P4iN3klJiOd5caoHsb4UnJ3r8N+m346FNVTvptsDAPqrtRuZykz5xz5gcVnwv4MN9QiWntEGv63Zrrv/fvM9ikITAuoGhy5UILRuTjeKQ7Q== 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=dEUu2C2DXimtvHrmiL3WlfjdlBXttex1Ha2fZ2Dc0MA=; b=WuVDcrCmL7WT7V1eLHr5pYAzjDP266b7gTn15IvQMuoaOlWYFo8EiqO8QzeslE08fySi4E+SR8BIwtB2hFl8IafXm5hdHhZ+yff+TUvTX5KFMCs2SsYb2Ccdm5IGzNRDpqtRPi1+l/VUPRcgyVGoLv8WUWeNPr6I1jBtPwXld6WK7yyWLXQxGhO50o3Rw51XKlqnhcG9Npvjq7J+3mJdJlD2aN6xx4EqBM8NR2yO1IretCNdq1IJK0JOJZCRAaeaxFedQ4IBtFLadoYQyed2tWVsicxiI3ooQJ86NxmvGlKK/PNJgHMuOBzo1SpAE7mFlXrFRE3mxJa+yvb3rl/qQg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=openvswitch.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dEUu2C2DXimtvHrmiL3WlfjdlBXttex1Ha2fZ2Dc0MA=; b=A50nEtuqN9Xr4gh+fktCIzvZxmgoKFD01fw4qmPwOToNrQhe4r2hc65WiHbvg608kUqPApmeH+IZyi/GchDzRQNyMG4jDBHTejauaSHUpYL1RgOD3RAy/Cz5kX02fF4BxPrxOg2gX5evEQj6v/R1ZSS5KrW9sVTQydvfMvJgnLmG6znzgGL6XEezeaDZDXoOAObNLk5GyDBXIdJ4JY7xQB29tD6jaatVIvGuYQMaW24HKnNGOOTgu8n4lkHiJ3Esbk97gzIN6XxUKYN09n9i+a7Fh+weMIqrKsl41VFg/n8Df2dQNe5czKRJ0ewIz3U8QTJCvBaxBYunS+G5lMxTVw== Received: from BN9PR03CA0526.namprd03.prod.outlook.com (2603:10b6:408:131::21) by BN9PR12MB5338.namprd12.prod.outlook.com (2603:10b6:408:103::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.30; Tue, 28 Feb 2023 13:20:48 +0000 Received: from BN8NAM11FT034.eop-nam11.prod.protection.outlook.com (2603:10b6:408:131:cafe::bb) by BN9PR03CA0526.outlook.office365.com (2603:10b6:408:131::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.30 via Frontend Transport; Tue, 28 Feb 2023 13:20:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by BN8NAM11FT034.mail.protection.outlook.com (10.13.176.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.17 via Frontend Transport; Tue, 28 Feb 2023 13:20:47 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Tue, 28 Feb 2023 05:20:41 -0800 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Tue, 28 Feb 2023 05:20:41 -0800 Received: from c-237-115-60-065.mtl.labs.mlnx (10.127.8.10) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.5 via Frontend Transport; Tue, 28 Feb 2023 05:20:38 -0800 To: Date: Tue, 28 Feb 2023 15:20:20 +0200 Message-ID: <20230228132024.671271-5-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230228132024.671271-1-cmi@nvidia.com> References: <20230228132024.671271-1-cmi@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT034:EE_|BN9PR12MB5338:EE_ X-MS-Office365-Filtering-Correlation-Id: e1c6f82c-edd2-4b96-f3ec-08db198e9b00 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8lKGCjxgni3KwLMVf0AQhsjEuw00A1DslB90YjOD4yak6cIUe5tDVn3Rw3kJRMIbKRvp53dEbH+2VKhEptC9d+SLiYVnnelqLR5a6579FvOEkTPKCDb6W0sXZ8XAga/3n7Kf8y6h7VGvnliuYVFqjIuM/GW3v7DW8Lo/YVo1ZbyTzaOc/X5xuVMGqYvcd6hwdl069HJAaGL3yYvw5bqB9Q5ULS548p1NZ8IDXr41qYLJPA/kNuknluLCz+zOLg2xqGFZmoHyBRqftW5X9bPGNHELeBElaC3loaXAmC86z9iOw2+dMfqsVaHHYfuFf1u73DL0gLx/iFJjnM1mejIhV8tzpfNJraBeUb7a+pGKLltJqglth1f1QhwbJDgO7rPjNk6wHArjnDBGQc58DtQ+P2sb6qyiHTIUTCaVLxLNy2xh0fXd8RyhbdUbk4EAOAFWzvfcXI8yKo82FOwaIF8qBdVJOqLeNgsvMI+uk3fvOb4TEWFT3UldOH1gbrQb/Epg8Y4146D+VDAygpJFqdZO9rhPQgQ5ZZ05dWB6YKJTbI4srCJH1s5shUhZwnSLmwCszHBxvp+3MlDhJOJ2EJBI0PlpliKBmZVPK9usvAxEBOBX8jDZ3HEZZkFyh6FAfqg2XAv6gxITKSf2IkOQyDoi/lwVa+5zDpmpG/nc3lrlKeOKAz2A5FvqRxdFxgO6VfqJukdQp//PMp1n9JWGHgGC9ndg3t6IOP0XwxmdrCxDOeA= X-Forefront-Antispam-Report: CIP:216.228.118.233; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge2.nvidia.com; CAT:NONE; SFS:(13230025)(4636009)(396003)(376002)(136003)(39860400002)(346002)(451199018)(40470700004)(36840700001)(46966006)(36756003)(86362001)(6916009)(4326008)(41300700001)(8936002)(70586007)(70206006)(5660300002)(2906002)(8676002)(356005)(36860700001)(34020700004)(82740400003)(7636003)(316002)(478600001)(107886003)(6666004)(336012)(40480700001)(40460700003)(82310400005)(47076005)(426003)(54906003)(26005)(2616005)(186003)(83380400001)(1076003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2023 13:20:47.7607 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e1c6f82c-edd2-4b96-f3ec-08db198e9b00 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.233]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT034.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5338 Cc: elibr@nvidia.com, simon.horman@corigine.com, roniba@nvidia.com, i.maximets@ovn.org, konguyen@redhat.com, majd@nvidia.com Subject: [ovs-dev] [PATCH v23 4/8] netdev-offload-tc: Add sFlow 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 sFlow recv API to receive sampled packets from psample socket. Add sFow recv wait API to add psample socket fd to poll list. Signed-off-by: Chris Mi Reviewed-by: Roi Dayan --- lib/dpif.h | 2 + lib/netdev-offload-provider.h | 14 +++ lib/netdev-offload-tc.c | 201 ++++++++++++++++++++++++++++++++++ 3 files changed, 217 insertions(+) diff --git a/lib/dpif.h b/lib/dpif.h index 6cb4dae6d..9a9c6b32e 100644 --- a/lib/dpif.h +++ b/lib/dpif.h @@ -836,6 +836,8 @@ struct dpif_upcall { 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 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..f75a6d9f0 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,18 @@ struct netdev_flow_api { int (*meter_del)(ofproto_meter_id meter_id, struct ofputil_meter_stats *stats); + /* Receives offload packets in 'buf' and fill the necessary members in + * 'upcall'. Only process offload packets if 'handler_id' is 0. + * Return 0 if successful, otherwise returns a positive errno value. + */ + int (*recv)(struct dpif_upcall *upcall, struct ofpbuf *buf, + uint32_t handler_id); + + /* Add socket fd to poll list if 'handler_id' is 0. So upcall thread can + * be waken up to process it if there is any offload packets, + */ + 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 29a3b91df..ce57f37c8 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" @@ -104,6 +106,9 @@ 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); +static struct nl_sock *psample_sock; +static int psample_family; + /* When offloading sample action to TC, userspace creates a unique ID * to map sFlow action and tunnel info and passes this ID to kernel * instead of the sFlow info. Psample will send this ID and sampled @@ -157,6 +162,19 @@ sgid_find(uint32_t id) return node ? CONTAINER_OF(node, struct sgid_node, id_node) : NULL; } +static struct offload_sflow * +sflow_find(uint32_t id) +{ + struct sgid_node *node; + + node = sgid_find(id); + if (!node) { + return NULL; + } + + return &node->sflow; +} + static uint32_t offload_sflow_hash(const struct offload_sflow *sflow) { @@ -3018,6 +3036,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_WARN("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_WARN("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_WARN("Failed to create psample socket: %s", ovs_strerror(err)); + return; + } + + err = nl_sock_join_mcgroup(psample_sock, psample_mcgroup); + if (err) { + VLOG_WARN("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) { @@ -3077,6 +3144,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); } @@ -3293,6 +3361,137 @@ meter_tc_del_policer(ofproto_meter_id meter_id, return err; } +struct offload_psample { + struct nlattr *packet; /* Packet data. */ + int group_id; /* Mapping id for sFlow offload. */ + int iifindex; /* Input ifindex. */ +}; + +static int +psample_from_ofpbuf(struct offload_psample *psample, + struct ofpbuf *buf) +{ + static const struct nl_policy ovs_psample_policy[] = { + [PSAMPLE_ATTR_IIFINDEX] = { .type = NL_A_U16 }, + [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; + } + + 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_sflow *sflow; + + dp_packet_use_stub(&upcall->packet, + CONST_CAST(struct nlattr *, + nl_attr_get(psample->packet)) - 1, + nl_attr_get_size(psample->packet) + + sizeof(struct nlattr)); + dp_packet_set_data(&upcall->packet, + (char *) dp_packet_data(&upcall->packet) + + sizeof(struct nlattr)); + dp_packet_set_size(&upcall->packet, nl_attr_get_size(psample->packet)); + + sflow = sflow_find(psample->group_id); + if (!sflow) { + return ENOENT; + } + + upcall->key = NULL; + upcall->key_len = 0; + upcall->ufid = sflow->ufid; + upcall->userdata = sflow->userdata; + upcall->actions = sflow->actions; + memset(flow, 0, sizeof *flow); + if (sflow->tunnel) { + memcpy(&flow->tunnel, sflow->tunnel, sizeof flow->tunnel); + } + flow->in_port.odp_port = netdev_ifindex_to_odp_port(psample->iifindex); + upcall->type = DPIF_UC_ACTION; + + return 0; +} + +static int +offload_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 ENOENT; + } + + 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; + } + + error = psample_from_ofpbuf(&psample, buf); + if (!error) { + return psample_parse_packet(&psample, upcall); + } else if (error) { + return error; + } + } + + return EAGAIN; +} + +static void +offload_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, @@ -3306,5 +3505,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 = offload_recv, + .recv_wait = offload_recv_wait, .init_flow_api = netdev_tc_init_flow_api, }; From patchwork Tue Feb 28 13:20:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Mi X-Patchwork-Id: 1749453 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=W3Cf0Mix; dkim-atps=neutral Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PQyg24G10z1yWy for ; Wed, 1 Mar 2023 00:21:02 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 4D5D0418F3; Tue, 28 Feb 2023 13:21:00 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 4D5D0418F3 Authentication-Results: smtp4.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=W3Cf0Mix 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 dPxkRRvbODCx; Tue, 28 Feb 2023 13:20:57 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 5726B418D2; Tue, 28 Feb 2023 13:20:56 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 5726B418D2 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 1238AC007B; Tue, 28 Feb 2023 13:20:56 +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 12F1BC0033 for ; Tue, 28 Feb 2023 13:20:54 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 07FD240BD3 for ; Tue, 28 Feb 2023 13:20:53 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 07FD240BD3 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=W3Cf0Mix 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 Q71yPGlPVQBD for ; Tue, 28 Feb 2023 13:20:51 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org C06F340BB7 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on20602.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5b::602]) by smtp2.osuosl.org (Postfix) with ESMTPS id C06F340BB7 for ; Tue, 28 Feb 2023 13:20:50 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cK9WEXD6QaE7s6BqvlfMGPbTsmMCeRMgLU9kbPl2q3ftrSzQhIe09NeXVKH1yeIv/tndVMS6taxMxK4AmZethcAkkklRpuIN92ldFnTgF1wNy80Ttym3P8ioAN7mlwk5AyadSmmowjK8jx7cLiDOlVv5sJayrt1hGMmhc8Y9nGW0v91b0JO/n9LQjqJNhQTdIcUomG3Pf9Y6xNcmBp2A7VKcIeQxgGmcnZHUTDOV38IvaCeBdj1/5FQ7gsPrad7szv00Cgx3aY9K7h/IIg3vpJy8ugyS1pS5nqQ8cUoRxoCGGfttmQdv1Ho5DrUfJE+l49XQAYnsJs/DLsTvxS2QRg== 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=SDmUwihdDAFQaEp8421fgh2qyZ3BGg1bs9nQI9JZxBE=; b=PvrdONPSUL0OSnf0gK1rDIWUKRQQN3XoobrK60UYGC37MOCbApThtKjGkvbGCdn337HedhTtiD2lJNT2H+5V78RP1Gf8qVWtaTtUuip5jGvRTomu0rjIgSrMGWBD8c1nXw5X09CYD7lc79F9q2papS09VcW9gFm7kDzIjFChpUn0CyFF1+xBmIRaFzhxKOEZ7DPpsoQo8osuGbzFq5W0iiEkGMSNRIuAuYeVg0n7L59zQ4tDRhuB8f8YQRKR0XMNDfgF8Fk0cKNIBp/F0fzlIqFRzdzg8ZS/gLUamTyZN6cka9QcSyESpzUCrJdqgnlCXWAJO4xCysCa7jA5Htzi4g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=openvswitch.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SDmUwihdDAFQaEp8421fgh2qyZ3BGg1bs9nQI9JZxBE=; b=W3Cf0MixekH3Fn1Li9xHg20s2Ae2V81eQCz3bH/3fMU2wOmcpAJDgQevs0waWtZPYeoIHyh1J6ERj+EHEBLSAMZtnFGhT4f+UrIIbWCeW4FA8Bv+w6eMH1xznf9ZcMIUTH0TD/vW9W1mfu39KM/a0ykdgyypwXMwhpdHvcQJ118RHc13ZM2ZEfYgmqOph2LzDuQhDb38qkcl5kluuMEMZY+nu3tIX0uCer/e+pAayuYlkaYhTqs41B8k09qN0RsP3+0qRs8R1RWBsv6/1lRKAbngwGu5H3o4zkHr7gjCscQ4HU1QmKWSuxlo0Bz6u+SekIlHSqsHOlfJpwPDFShYag== Received: from MW4PR04CA0144.namprd04.prod.outlook.com (2603:10b6:303:84::29) by MW3PR12MB4489.namprd12.prod.outlook.com (2603:10b6:303:5e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.30; Tue, 28 Feb 2023 13:20:47 +0000 Received: from CO1NAM11FT060.eop-nam11.prod.protection.outlook.com (2603:10b6:303:84:cafe::8a) by MW4PR04CA0144.outlook.office365.com (2603:10b6:303:84::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.30 via Frontend Transport; Tue, 28 Feb 2023 13:20:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by CO1NAM11FT060.mail.protection.outlook.com (10.13.175.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.12 via Frontend Transport; Tue, 28 Feb 2023 13:20:47 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Tue, 28 Feb 2023 05:20:45 -0800 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Tue, 28 Feb 2023 05:20:44 -0800 Received: from c-237-115-60-065.mtl.labs.mlnx (10.127.8.10) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.5 via Frontend Transport; Tue, 28 Feb 2023 05:20:42 -0800 To: Date: Tue, 28 Feb 2023 15:20:21 +0200 Message-ID: <20230228132024.671271-6-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230228132024.671271-1-cmi@nvidia.com> References: <20230228132024.671271-1-cmi@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT060:EE_|MW3PR12MB4489:EE_ X-MS-Office365-Filtering-Correlation-Id: 7718c287-c596-4f01-bdd7-08db198e9af1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: m4MldNup0IEtfGzInUmIqK6iiOW2MRjsPcpWXQHKOfmC13x1aIgcYB0GuYdQenSpwxwtlte2x54CfFvtDZABGBoOSBDv6w91jIcdIKQiGiM1Vz63VXUV5WVDnRPLG0QUELphslHWihrWUMcy58xY8xJpkLHzUubnBWfjk9N4fokbeF8AfSVbVPDIwmNcY9tLCLdwHU+Nn0gnd1r/qkmSsCHB/71wF5THX+KiaLpVogMPQLynuTt4mdPyusfTQlMVVSArK6dSLu6ulmcjS+iOZzQhBCvEosXJVSgVF8y1I0qIsQa1q5ZGSipi+6KB8B/zeER38YfT4mihS/cDxp3N0RV+X/9anDlKa3Z/gGv3Df/kJmlY+I7zPVxMSQiAufEYt6TPEjcAhCH18qhjTJmmTbOEwzaK/bmGrEqTZDDZDK46lIX0xGIO6v/puQjSI5tjBZ8cO43ruNLQHJLg1VED/pTJGtzILHpXm3XONnKDQcijJIu7jndjuXOhZNeo4K0qFAvWyWQhEGgp9kWIIRQ9NW9gw4NgoV7oQ0nHKc6VwHOqyFT0L4KZxKDZtc/3Ob1rs0eTMKZhdLSVxByw7sQRhayMHUb2g4K8zQjY4PLPLaILpbhXthCZRZTMo5sADko6KeXmRVw+Z9czo4Jg0l41qTX+/Lfd//sPI9dVvx+IFnhNCA2Xkp47vY8yzTEKC6mvqbMmPUDihvCuGPlh4r1upCKmGescoYOTKWwZ2qI/VH4= X-Forefront-Antispam-Report: CIP:216.228.118.232; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge1.nvidia.com; CAT:NONE; SFS:(13230025)(4636009)(346002)(376002)(396003)(39860400002)(136003)(451199018)(36840700001)(46966006)(40470700004)(36756003)(86362001)(40480700001)(70206006)(8676002)(5660300002)(6916009)(4326008)(41300700001)(8936002)(2906002)(356005)(7636003)(82740400003)(34020700004)(36860700001)(107886003)(6666004)(478600001)(54906003)(316002)(70586007)(82310400005)(47076005)(26005)(426003)(2616005)(186003)(40460700003)(336012)(1076003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2023 13:20:47.7704 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7718c287-c596-4f01-bdd7-08db198e9af1 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.232]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT060.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4489 Cc: elibr@nvidia.com, simon.horman@corigine.com, roniba@nvidia.com, i.maximets@ovn.org, konguyen@redhat.com, majd@nvidia.com Subject: [ovs-dev] [PATCH v23 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 4592262bd..d6e3e4946 100644 --- a/lib/netdev-offload.c +++ b/lib/netdev-offload.c @@ -256,6 +256,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 Tue Feb 28 13:20:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Mi X-Patchwork-Id: 1749455 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=MTseNgE+; 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 4PQygD50HGz1yWy for ; Wed, 1 Mar 2023 00:21:12 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 6B75E82047; Tue, 28 Feb 2023 13:21:10 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 6B75E82047 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=MTseNgE+ 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 scsuAVJQqSJe; Tue, 28 Feb 2023 13:21:08 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id A12FC8206B; Tue, 28 Feb 2023 13:21:01 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org A12FC8206B Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 7DAC5C0078; Tue, 28 Feb 2023 13:21:00 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 035C3C0080 for ; Tue, 28 Feb 2023 13:20:59 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id F012C40BDB for ; Tue, 28 Feb 2023 13:20:55 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org F012C40BDB 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=MTseNgE+ 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 dMcjTZMASvbZ for ; Tue, 28 Feb 2023 13:20:55 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 0EF2D40BC9 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on20616.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5b::616]) by smtp2.osuosl.org (Postfix) with ESMTPS id 0EF2D40BC9 for ; Tue, 28 Feb 2023 13:20:54 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HkY60ZOCgrBI1vI4TCxtHon4DfPtaZhnQQ11IOgWLrQUTukHrhFspJv9/6zBcH61TLgIKr6N/aMp5rfereUg6HmNr0bbsZYpKO3oYOTA5bH4/i7qzY75g7Az4foyUaZXXQoFL58DUhca1awqJm6VvMXTdIyX0DmA8w4DYY+ViGIkMNJZzSradMGQi2Ww5FqArZW2fEZFriM+LNPbGNCkKX1bNNPp0nM5l2ezPt77vi51LByBqEOIt6rbgxqPj4ojhc9RmNTM9HXxab3y8qJEfFaQ8Kty8KdJWOZbO/NSCRsUeDucRxzOzS2SliwWz5ogESV5jOMeCAS+qTwby7RWTg== 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=IF/C8gT4miM8IPBVuIomOqChRafczgx0altptzEWLoU=; b=V9EwJoPIqBu7FvV2Q6f/jKlpRcGJdr8NstvkHZzBY90OPLLzy1rFD1oxXSceosCHkoFFOhyvVkeEgrB1U7AmBCtRw5YCeDu3ykyhsz3X66PJjapnw2iPdFllPSSJ7tNT37miemnFEla8ECbkszK1oEePaYlU5G9wQVTAX5mTNKTANehx54mbLyRoz/LCwTXkXnE3xg7dFYSAWmYutS4I4jWVCfgBkM4nfr8rQOfCVyjOpgiIsiG8ddKRp+NIDYZ8MokYNsLgFCq8ZozFzOjU4KQ4SzVxEkpwZTQNYTY/YdmaZHPP76wMT3SjAFjmE7csQw5MHUMcKo0ikcRImaOitQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=openvswitch.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IF/C8gT4miM8IPBVuIomOqChRafczgx0altptzEWLoU=; b=MTseNgE+g/A4wL92srNiXa+HbVBSSC5Kn1DoHyVXk5NV/XV4r+ephoLztMFJTHQ/JjBbbIJY4c3fifnEDxJs+HgUETreT0XIf9051uZJCIU/uid6MVsJY953tbi/0ktuiS2TJbwoVCF7O5xRO4+bQUSfWTwSz61W9lhpFioyrU7LdmAyUh53x9TxWr5rqrD9hvKuRGYTZEz5zlS7bww08o19rB/C95K/ocjUa+r06AnSRJQXdjlELqxu9ZK5XfHUQYrpGESGSaqM0icRlqKYz6v+mxsQwJ10IHicrqU0Rw0aFkk/CtWezrPaBZcTYGpNiSQWeGulrnMSAm0Iecmtlg== Received: from MW4PR04CA0128.namprd04.prod.outlook.com (2603:10b6:303:84::13) by CH0PR12MB5345.namprd12.prod.outlook.com (2603:10b6:610:d4::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.30; Tue, 28 Feb 2023 13:20:52 +0000 Received: from CO1NAM11FT060.eop-nam11.prod.protection.outlook.com (2603:10b6:303:84:cafe::52) by MW4PR04CA0128.outlook.office365.com (2603:10b6:303:84::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.30 via Frontend Transport; Tue, 28 Feb 2023 13:20:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by CO1NAM11FT060.mail.protection.outlook.com (10.13.175.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.12 via Frontend Transport; Tue, 28 Feb 2023 13:20:51 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Tue, 28 Feb 2023 05:20:48 -0800 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Tue, 28 Feb 2023 05:20:47 -0800 Received: from c-237-115-60-065.mtl.labs.mlnx (10.127.8.10) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.5 via Frontend Transport; Tue, 28 Feb 2023 05:20:45 -0800 To: Date: Tue, 28 Feb 2023 15:20:22 +0200 Message-ID: <20230228132024.671271-7-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230228132024.671271-1-cmi@nvidia.com> References: <20230228132024.671271-1-cmi@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT060:EE_|CH0PR12MB5345:EE_ X-MS-Office365-Filtering-Correlation-Id: e5d98951-1600-47b1-7283-08db198e9d56 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G/qcMHOnmaPv4PKGphoRsk+SNm0J5GvjJUwpabgv6SlcI9oXNVbyT40WZ/JRGVKyYG2zpjjhnNTO4JZYxw0yO6jEO67WzYFsX2GOsPcK10TziwDoeVvTNra6HRpANkGOd/nSL/TGoB25nw22k/VjvSJJjasAMCv3tPfFqcz+DDPfAXGrKzhi9dS1khbI30XPbCfSl8CUmJR/4tKpVJSaeLIxZ4dLQ7BMBD3csx0YYHDzeGpqR/8WOUHz+TqmSjaHzGcvqxpr45krCWcdPJlZCd4Jc6R9brAbtu/D4Hg8qWl281DU3YJ2Jq2IE401BBay6NUXnJS+mLMTURo/j1/XQbTpOpSuglW9GglzTQN2Kp0pPEpUZ950EbSJQkdK+XlppWZ4a8qJPIwxVw/Lb6Ozl+QQsNOWDQ+X316vx0BhSuknravUEPoHeFy6sRtTT6Ud1+0a3jgRRt1cRsKffYETM4alQzzlyTg08xlEsdXJW2fEFsKJW1j+puHJTkyOVI3kDsL4NlZdj2tXmAJv9nmViXOVcTVd8ggF1q/hj6FmJekWx4pSDXiqVqZOjIZM1+P2Tzv6BRVhRqV6fkh+Xv1j3ikV12Smp0yizosrVQWdpkDbkuprkCNxpYM0gJdr06DjrAEbhdSepmCesttQZtCWUh1oswNwxWk9h6/5brgrRmTKZDT982mTg849zJAAFNYQ6qRsPC2xrI3PP477xHR91o4cTRWq8kgFXpxQdI9xKnw= X-Forefront-Antispam-Report: CIP:216.228.118.232; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge1.nvidia.com; CAT:NONE; SFS:(13230025)(4636009)(136003)(39860400002)(346002)(396003)(376002)(451199018)(36840700001)(40470700004)(46966006)(66899018)(82310400005)(36860700001)(34020700004)(83380400001)(47076005)(426003)(36756003)(356005)(316002)(54906003)(82740400003)(478600001)(7636003)(2616005)(336012)(26005)(41300700001)(186003)(6666004)(1076003)(40460700003)(107886003)(8936002)(70206006)(5660300002)(86362001)(2906002)(40480700001)(70586007)(6916009)(4326008)(8676002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2023 13:20:51.7858 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e5d98951-1600-47b1-7283-08db198e9d56 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.232]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT060.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5345 Cc: elibr@nvidia.com, simon.horman@corigine.com, roniba@nvidia.com, i.maximets@ovn.org, konguyen@redhat.com, majd@nvidia.com Subject: [ovs-dev] [PATCH v23 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 | 42 ++++++++++++++++++++++++++++++----- ofproto/ofproto-dpif-upcall.c | 16 +++++++++---- 2 files changed, 48 insertions(+), 10 deletions(-) diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c index 586fb8893..c49b4e027 100644 --- a/lib/dpif-netlink.c +++ b/lib/dpif-netlink.c @@ -201,6 +201,12 @@ struct dpif_handler { struct nl_sock *sock; /* Each handler thread holds one netlink socket. */ + /* Now recv handler thread deals with both normal recv and offload + * recv upcalls. To avoid starvation, introduce a flag to alternate + * the order. + */ + bool recv_offload_first; + #ifdef _WIN32 /* Pool of sockets. */ struct dpif_windows_vport_sock *vport_sock_pool; @@ -3005,7 +3011,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 +3061,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 +3134,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 +3150,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 +3240,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 fc94078cb..3e1acf296 100644 --- a/ofproto/ofproto-dpif-upcall.c +++ b/ofproto/ofproto-dpif-upcall.c @@ -840,10 +840,18 @@ 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 Tue Feb 28 13:20:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Mi X-Patchwork-Id: 1749457 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=NoW1JJVw; 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 4PQygn3SwYz1yWy for ; Wed, 1 Mar 2023 00:21:41 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id E778D820EB; Tue, 28 Feb 2023 13:21:38 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org E778D820EB 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=NoW1JJVw 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 7eqPjYLlN72L; Tue, 28 Feb 2023 13:21:35 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 3BBAF81FA5; Tue, 28 Feb 2023 13:21:26 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 3BBAF81FA5 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id E72FFC0033; Tue, 28 Feb 2023 13:21:25 +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 11428C002B for ; Tue, 28 Feb 2023 13:21:25 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 8118D40BDE for ; Tue, 28 Feb 2023 13:21:08 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 8118D40BDE 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=NoW1JJVw 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 UdWOaBdM1RAh for ; Tue, 28 Feb 2023 13:21:05 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 3EDC940C0E Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on20627.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eab::627]) by smtp2.osuosl.org (Postfix) with ESMTPS id 3EDC940C0E for ; Tue, 28 Feb 2023 13:21:03 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g+R15bhoIqh6bCP4FdPgsrTJo/l2+8Nivpn7KgYE9PEzOLFZNxEW6941mFUD9S7OgKqewG5CgBfl4hrf36yXSUxIFgyvDrOYZ90W+D72okb+FTBRl1kNRuhsQIaxdpUq8oy8Jlv8XBmqWB7cdj8cp/FpE9/1CnQ1LziIEno8Xis+OxNe/MLEXDtY+zDBNKS72mpBAxmsxni0G1rW/mTVdEenlpW0Axo8AbGpHE9doVaJ3kQHRlUAgAch3j20P8YzKnFVPgGlzoqAfSGNYsYS07IyB7vZEa1X73Z7lBQZH9tHyAIukEE6Ckv7y7xabwUyfWkl8ouVNJSqnohix504SA== 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=BFkAmSam6G96Z6DAraKx0ghaEff6xyJnu5AHJ6pUTE0=; b=G+DQvwWfh5dIdUMFbg2GlDamUINv3btuQjjK5IKFOlCo5aFvo0yu2JDbsyIFc2tmKNpsnVyuCeA0bZPwOYvTfKJxVp8Xej9BeKJAFMsRaBWbHhALewqxZJgfLaWHSIyQIn/wfGoNbJ41mJub8u0txWQ3S0MMPodSD0a6EOyRVf2uwQVeyjiW4tNc0t6l+9l2ayhfdUJgGtNBe3xceZdyYcN99P/nk9X3nTjujmsKShiWZixkzX7Tmaq5PFMoYTmsRuLP6uTvdRFhCzoD7ex0FptmYXXDW/rmwjvD+irWrmv5ZCqL05d5fbtuI78lyBLfGveMj0Ixqn1xehO5hCE4sg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=openvswitch.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BFkAmSam6G96Z6DAraKx0ghaEff6xyJnu5AHJ6pUTE0=; b=NoW1JJVwG1m85bp/+a4hSdjNMXvm/sla9KVxtUK0kbu/DixIujC61i4jPQ/k5d364yQJdIt33rRZj5cRiUdHa4vQkzT4j2tP2bIl++6tQOJAKiHkjWidcLH9RbRnon2l8tIro0tgtSx8h9oGnU+4oDWm/OALU61qewh05SuwjCizOW4PJdDz3UoyNJJh9PbMbrE4MHu5SLmtT2S4SCWD/pNGGBlO/ndc+zu2GlsTn5wxiUrll9EQ5djRaig0uDRhb3q+jxQSeylGjf8CSiMIGXgrtOUHJL92pARG8niIm07GjvEAIXxFgeUmohgdmDgBbCjS6r+mA+1o9E4kIHcFfQ== Received: from DS7P222CA0013.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::22) by SA1PR12MB5672.namprd12.prod.outlook.com (2603:10b6:806:23c::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.30; Tue, 28 Feb 2023 13:21:00 +0000 Received: from DM6NAM11FT054.eop-nam11.prod.protection.outlook.com (2603:10b6:8:2e:cafe::e2) by DS7P222CA0013.outlook.office365.com (2603:10b6:8:2e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.30 via Frontend Transport; Tue, 28 Feb 2023 13:21:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by DM6NAM11FT054.mail.protection.outlook.com (10.13.173.95) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.17 via Frontend Transport; Tue, 28 Feb 2023 13:21:00 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Tue, 28 Feb 2023 05:20:51 -0800 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Tue, 28 Feb 2023 05:20:50 -0800 Received: from c-237-115-60-065.mtl.labs.mlnx (10.127.8.10) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.5 via Frontend Transport; Tue, 28 Feb 2023 05:20:48 -0800 To: Date: Tue, 28 Feb 2023 15:20:23 +0200 Message-ID: <20230228132024.671271-8-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230228132024.671271-1-cmi@nvidia.com> References: <20230228132024.671271-1-cmi@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT054:EE_|SA1PR12MB5672:EE_ X-MS-Office365-Filtering-Correlation-Id: dc76f9a4-4045-494f-eec0-08db198ea274 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 55ivNKmb1uQqVpLkx0IaWG5Q0Yz57Jh7/g/5N8mUllVVZUmDAo0KNP4WGgq19N+bjzdTiPq0sH/ilGGFMRwIJth+Hy7Nd758rwhKNMeRX6moxNxD17s4cbXVj6ysZ/Sa4qRxY2t+uZ4FggB4HxXN4fCqIaG0vSyQ1RA4Eo+fHfp1TQWHV0qdUdTGkvFjsFlkRzcoGOW8KvDxu4p3ub7utbFV39DyYY7WS9wd+EsFB06jDM/CjAkMGUigw3pnjo5NNTQyTFKRCjseHVe6zBbSSe5Nz8JZEpGhr2ym0XjwNNTejQsEc+jwa15b6+s3McJ07pyvzjmSk2HliFnEQhqV2DcOGqhIvu5M4wD511i7PqX8K/1cajOVgJfiNf6ci/Twh6DaUhdVac3lWtC2dmplsmYbEEZITd2ZWOwPWQ5IKhscFWdKrJ4Jll6mutjUf2Fp3SP2azTNYjjny/6lv81QXDDNoWDEaR1CsIhikBMcwEw8KCnkb/sqOe4I5H0H06eHFq79Xk8Q6cnFyb5AFdFCjccZeRMDeRb39cctFcxtlSc+j60KgBCteNSlxtkc9BF243a/sCdFz/s1M+9FXVqP4g32Bus2xkPORxzYIF2BVspkndXo5lKjHk8u+8bza4nlcPYd0nT3aRDXqSn2zqd5sbbrkvwbEN7pC1firrqaGzLTxiNa/plxgkJJyqae/swiTqQTfhnoK6jhrpLAfUgvQJdCcWnWcCRPUJthWjVi+ZI= X-Forefront-Antispam-Report: CIP:216.228.118.233; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge2.nvidia.com; CAT:NONE; SFS:(13230025)(4636009)(136003)(376002)(346002)(396003)(39860400002)(451199018)(40470700004)(46966006)(36840700001)(8936002)(5660300002)(30864003)(26005)(1076003)(186003)(8676002)(41300700001)(70206006)(70586007)(6916009)(4326008)(86362001)(316002)(36756003)(54906003)(83380400001)(40460700003)(478600001)(40480700001)(2906002)(107886003)(6666004)(336012)(426003)(47076005)(356005)(2616005)(82740400003)(82310400005)(7636003)(34020700004)(36860700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2023 13:21:00.3273 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dc76f9a4-4045-494f-eec0-08db198ea274 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.233]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT054.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB5672 Cc: elibr@nvidia.com, simon.horman@corigine.com, roniba@nvidia.com, i.maximets@ovn.org, konguyen@redhat.com, majd@nvidia.com Subject: [ovs-dev] [PATCH v23 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 | 267 +++++++++++++++++++++++++++++++++++++--- lib/netdev-offload.h | 1 + lib/tc.c | 62 +++++++++- lib/tc.h | 11 +- 4 files changed, 319 insertions(+), 22 deletions(-) diff --git a/lib/netdev-offload-tc.c b/lib/netdev-offload-tc.c index ce57f37c8..be5f4d2be 100644 --- a/lib/netdev-offload-tc.c +++ b/lib/netdev-offload-tc.c @@ -92,13 +92,23 @@ static struct hmap police_idx_to_meter_id OVS_GUARDED_BY(meter_mutex) static int meter_id_lookup(uint32_t meter_id, uint32_t *police_idx); static int police_idx_lookup(uint32_t police_idx, uint32_t *meter_id); +/* To avoid passing too many parameters when offloading sample action, + * aggregate them here. + */ +struct sample_param { + const struct flow_tnl *tnl; /* Tunnel info. */ + const ovs_u128 *ufid; /* Ufid. */ + uint32_t gid; /* Generated gid. */ +}; + static int netdev_tc_parse_nl_actions(struct netdev *netdev, struct tc_flower *flower, struct offload_info *info, const struct nlattr *actions, size_t actions_len, bool *recirc_act, bool more_actions, - struct tc_action **need_jump_update); + struct tc_action **need_jump_update, + struct sample_param *param); static void parse_tc_flower_to_stats(struct tc_flower *flower, struct dpif_flow_stats *stats); @@ -109,6 +119,12 @@ static int get_ufid_adjust_stats(const ovs_u128 *ufid, static struct nl_sock *psample_sock; static int psample_family; +static bool +psample_supported(void) +{ + return psample_sock != NULL; +} + /* When offloading sample action to TC, userspace creates a unique ID * to map sFlow action and tunnel info and passes this ID to kernel * instead of the sFlow info. Psample will send this ID and sampled @@ -997,6 +1013,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->sflow.action, + node->sflow.action->nla_len); + } + break; case TC_ACT_VLAN_POP: { nl_msg_put_flag(buf, OVS_ACTION_ATTR_POP_VLAN); } @@ -2102,6 +2131,174 @@ parse_match_ct_state_to_flower(struct tc_flower *flower, struct match *match) } } +static int +parse_userspace_attributes(const struct nlattr *actions, + struct offload_sflow *sflow) +{ + 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; + + cookie = (struct user_action_cookie *) nl_attr_get(nla); + if (cookie->type == USER_ACTION_COOKIE_SFLOW) { + sflow->userdata = (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_sflow *sflow) +{ + 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, sflow); + } 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_sflow_set(struct offload_sflow *sflow, const struct nlattr *actions, + size_t actions_len, bool tunnel, struct sample_param *param) +{ + if (param->gid) { + VLOG_ERR_RL(&error_rl, + "Only a single TC_SAMPLE action per flow is supported"); + return EOPNOTSUPP; + } + + memset(sflow, 0, sizeof *sflow); + sflow->ufid = *(param->ufid); + if (tunnel) { + sflow->tunnel = CONST_CAST(struct flow_tnl *, param->tnl); + } else { + sflow->actions = xmalloc(actions_len + NLA_HDRLEN); + nullable_memcpy((char *) sflow->actions + NLA_HDRLEN, actions, + actions_len); + sflow->actions->nla_len = actions_len + NLA_HDRLEN; + } + + return 0; +} + +static int +parse_sample_action(struct tc_flower *flower, struct tc_action *tc_action, + const struct nlattr *actions, size_t actions_len, + const struct nlattr *sample_action, + struct sample_param *param) +{ + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20); + struct offload_sflow sflow; + const struct nlattr *nla; + unsigned int left; + int err; + + err = offload_sflow_set(&sflow, actions, actions_len, flower->tunnel, + param); + if (err) { + return err; + } + sflow.action = (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, &sflow); + } 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); + } else { + err = EINVAL; + goto out; + } + } + + if (!tc_action->sample.rate || err) { + err = EINVAL; + goto out; + } + + param->gid = sgid_alloc_ctx(&sflow); + if (!param->gid) { + VLOG_DBG_RL(&rl, "Failed allocating group id for sample action"); + err = ENOENT; + goto out; + } + tc_action->sample.group_id = param->gid; + flower->action_count++; + +out: + if (sflow.actions) { + free(sflow.actions); + } + return err; +} + +static int +parse_userspace_action(struct tc_flower *flower, struct tc_action *tc_action, + const struct nlattr *actions, size_t actions_len, + const struct nlattr *userspace_action, + struct sample_param *param) +{ + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20); + struct offload_sflow sflow; + int err; + + err = offload_sflow_set(&sflow, actions, actions_len, flower->tunnel, + param); + 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, &sflow); + if (err) { + goto out; + } + sflow.action = (struct nlattr *) userspace_action; + param->gid = sgid_alloc_ctx(&sflow); + if (!param->gid) { + 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 = param->gid; + tc_action->sample.rate = 1; + flower->action_count++; + +out: + if (sflow.actions) { + free(sflow.actions); + } + return err; +} static int parse_check_pkt_len_action(struct netdev *netdev, struct tc_flower *flower, @@ -2149,7 +2346,7 @@ parse_check_pkt_len_action(struct netdev *netdev, struct tc_flower *flower, nl_attr_get(nl_actions), nl_attr_get_size(nl_actions), recirc_act, !last_action, - &ge_jump_update); + &ge_jump_update, NULL); if (err) { return err; } @@ -2165,7 +2362,7 @@ parse_check_pkt_len_action(struct netdev *netdev, struct tc_flower *flower, nl_attr_get(nl_actions), nl_attr_get_size(nl_actions), recirc_act, !last_action, - &le_jump_update); + &le_jump_update, NULL); if (gt_offset == flower->action_count && last_action) { /* No le actions where added, fix gt offset. */ @@ -2216,7 +2413,8 @@ netdev_tc_parse_nl_actions(struct netdev *netdev, struct tc_flower *flower, struct offload_info *info, const struct nlattr *actions, size_t actions_len, bool *recirc_act, bool more_actions, - struct tc_action **need_jump_update) + struct tc_action **need_jump_update, + struct sample_param *param) { static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20); const struct nlattr *nla; @@ -2353,10 +2551,27 @@ netdev_tc_parse_nl_actions(struct netdev *netdev, struct tc_flower *flower, return err; } } else if (nl_attr_type(nla) == OVS_ACTION_ATTR_SAMPLE) { - struct offload_sflow sflow; - - memset(&sflow, 0, sizeof sflow); - sgid_alloc_ctx(&sflow); + if (!psample_supported()) { + VLOG_DBG_RL(&rl, "Unsupported put action type: %d, psample is " + "not initialized successfully", nl_attr_type(nla)); + return EOPNOTSUPP; + } + err = parse_sample_action(flower, action, actions, actions_len, + nla, param); + if (err) { + return err; + } + } else if (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; + } + err = parse_userspace_action(flower, action, actions, actions_len, + nla, param); + if (err) { + return err; + } } else { VLOG_DBG_RL(&rl, "unsupported put action type: %d", nl_attr_type(nla)); @@ -2380,6 +2595,7 @@ netdev_tc_flow_put(struct netdev *netdev, struct match *match, const struct flow_tnl *tnl = &match->flow.tunnel; struct flow_tnl *tnl_mask = &mask->tunnel; struct dpif_flow_stats adjust_stats; + struct sample_param param; bool recirc_act = false; uint32_t block_id = 0; struct tcf_id id; @@ -2660,17 +2876,21 @@ netdev_tc_flow_put(struct netdev *netdev, struct match *match, return err; } + param.tnl = tnl; + param.ufid = ufid; + param.gid = 0; /* Parse all (nested) actions. */ err = netdev_tc_parse_nl_actions(netdev, &flower, info, actions, actions_len, &recirc_act, - false, NULL); + false, NULL, ¶m); if (err) { - return err; + goto 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 out; } memset(&adjust_stats, 0, sizeof adjust_stats); @@ -2684,21 +2904,30 @@ 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 out; } flower.act_cookie.data = ufid; flower.act_cookie.len = sizeof *ufid; block_id = get_block_id_from_netdev(netdev); - id = tc_make_tcf_id_chain(ifindex, block_id, chain, prio, hook); + id = tc_make_tcf_id_all(ifindex, block_id, chain, prio, hook, param.gid); 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 out; + } + + if (stats) { + memset(stats, 0, sizeof *stats); + netdev_tc_adjust_stats(stats, &adjust_stats); + } + add_ufid_tc_mapping(netdev, ufid, &id, &adjust_stats); + return 0; + +out: + if (param.gid) { + sgid_free(param.gid); } return err; diff --git a/lib/netdev-offload.h b/lib/netdev-offload.h index 09cdb6db2..1bf648c68 100644 --- a/lib/netdev-offload.h +++ b/lib/netdev-offload.h @@ -81,6 +81,7 @@ struct offload_info { bool tc_modify_flow_deleted; /* Indicate the tc modify flow put success * to delete the original flow. */ odp_port_t orig_in_port; /* Originating in_port for tnl flows. */ + }; DECLARE_EXTERN_PER_THREAD_DATA(unsigned int, netdev_offload_thread_id); 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 0d9b1b8e7..1892b98d6 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; @@ -330,12 +335,14 @@ tc_make_tcf_id(int ifindex, uint32_t block_id, uint16_t prio, } static inline struct tcf_id -tc_make_tcf_id_chain(int ifindex, uint32_t block_id, uint32_t chain, - uint16_t prio, enum tc_qdisc_hook hook) +tc_make_tcf_id_all(int ifindex, uint32_t block_id, uint32_t chain, + uint16_t prio, enum tc_qdisc_hook hook, + uint32_t sample_group_id) { struct tcf_id id = tc_make_tcf_id(ifindex, block_id, prio, hook); id.chain = chain; + id.sample_group_id = sample_group_id; return id; } From patchwork Tue Feb 28 13:20:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Mi X-Patchwork-Id: 1749458 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=Jn3xvOAg; 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 4PQyhC3D5Sz1yWy for ; Wed, 1 Mar 2023 00:22:03 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id A857240C3D; Tue, 28 Feb 2023 13:22:01 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org A857240C3D 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=Jn3xvOAg 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 P6KYtt1p0fgX; Tue, 28 Feb 2023 13:22:00 +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 77B2740B8E; Tue, 28 Feb 2023 13:21:59 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 77B2740B8E Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4F545C0033; Tue, 28 Feb 2023 13:21:59 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 3F33AC002B for ; Tue, 28 Feb 2023 13:21:58 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 4DC12611DF for ; Tue, 28 Feb 2023 13:21:17 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 4DC12611DF 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=Jn3xvOAg 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 4futIOse4fkU for ; Tue, 28 Feb 2023 13:21:11 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 19133611A3 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2061d.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e89::61d]) by smtp3.osuosl.org (Postfix) with ESMTPS id 19133611A3 for ; Tue, 28 Feb 2023 13:21:08 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Buz3HkR1JmzUpKVnY9UbjyexLwsbq2/m9TZ8sVgUeTZSfXj2OZefLhhzD7T/eRtCugXSL7Dt3JztJ8iuj+rN0B2OOaEat66yC3HBYNVo2KcSN0y9jVkwD4hdjfaW+bHLpTYS+r3I506ro497btsx24HXjovIP58YN+g+t4NoKbWPMpdBlCGfyypOL2aXLYuxJ/NO7Drxspx1oetP1UvihX1bNK+v4CUr6Bbe9/JmRvAYOV1YqD32kY3+wFYKSYp4SFTTC3qpXIDiMRzp2FQh7VDR8gGVEi4n7W16wheI4J9DxOpn+YoQFeD/8thiLD5H+8RUg0eMpI+B3s2+0ZfxSQ== 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=6XwsIGT5a7FK3Lu17f7EjZDHqh0ujaWo13D/NjXPCvs=; b=Hu639YaDgVV/ioeFRe9JmLbA1+D2WwBqkacbZtn+c0VtAa/YpC9XI9LlotuL7DXGMXIX9gqC3Bu4amMzEk5MXE0hPC2PIT/yreiV7ZKrQli48hUffrFLhhnB8BOmEdJa4QF6Yx5hEBaRVSam7B/YcHDjHGJwyB4J3wG7YkWWeexjIY/z19v6/v10EY45vblJb7X+yWr6gUnZ94RQsC6ne5WqiGBT9q8b/V7eovLwWQzIeQsVdWpRW6H/soqgS1x8YGWLNeap6Oo9iWcOWMQ21f7XqBUixeGk3vBeuSfD1X9K46qmZh99FWUv04MTSv34SFtoZE8LqmEuXYW1C+hylg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=openvswitch.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6XwsIGT5a7FK3Lu17f7EjZDHqh0ujaWo13D/NjXPCvs=; b=Jn3xvOAgFkXil2pznipnzTch/k+c6HOOXhYdfF8vm5ML16LoXtIVZGCk1vWLrAtaOfXf1m/lMI4Sd5g/uTVw0INsVOCliBYJuE8nWy4U7DEAxedgHhH8Si4DE7pi2oDs2pFmZ7NOzO6KrAJIp1E3gZzp3ixaWLyVCtbKzxpegsxGuoPnMVI/be2lJSVmKW3DiyYcSw+ses5vqM1TVrGGF5LyktTI1nTnpznNBy2LAIIz8rhJmSnCKaoO3vZB5D4dcMGlyEzFMaDhVTEjpw23V4mRWYrotDR5IfrhGJmYfjKptvIBck0DO2aDShPp9Gi72fCprTxXS+zLxTfGXna/ew== Received: from MW4PR03CA0133.namprd03.prod.outlook.com (2603:10b6:303:8c::18) by DM6PR12MB4123.namprd12.prod.outlook.com (2603:10b6:5:21f::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.30; Tue, 28 Feb 2023 13:21:05 +0000 Received: from CO1NAM11FT008.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8c:cafe::16) by MW4PR03CA0133.outlook.office365.com (2603:10b6:303:8c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.30 via Frontend Transport; Tue, 28 Feb 2023 13:21:05 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by CO1NAM11FT008.mail.protection.outlook.com (10.13.175.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.17 via Frontend Transport; Tue, 28 Feb 2023 13:21:05 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Tue, 28 Feb 2023 05:20:54 -0800 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Tue, 28 Feb 2023 05:20:54 -0800 Received: from c-237-115-60-065.mtl.labs.mlnx (10.127.8.10) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.5 via Frontend Transport; Tue, 28 Feb 2023 05:20:51 -0800 To: Date: Tue, 28 Feb 2023 15:20:24 +0200 Message-ID: <20230228132024.671271-9-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230228132024.671271-1-cmi@nvidia.com> References: <20230228132024.671271-1-cmi@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT008:EE_|DM6PR12MB4123:EE_ X-MS-Office365-Filtering-Correlation-Id: 7e0fe1e3-ef7d-4ef9-a158-08db198ea573 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kgR5Ip2xdr/YDb8z8oqToabSm11J/+0kSJNq31BtMoJjvnVrMC/diXxk6Uo+mQhsxo4hYkYcyJrAmg+djF67JiNbfkETYdg0GoFP7dJL39QeiURf6NVChakjoKcoewmloh7QjCk63Glon33ZmuihMHCHCHh8kI5NdkNa+lw1p5Fnqcc1gWW0tpg1aJQaT8kcIxiSQVlXzS/6VBIboAbBc3vmhd072K+b4RrLUl6D45/DThRJ02d5kwrotdX3bJlkpQ3zZfwUEhFk1cXulQcFqgzE4esIdMOl4+oLN1RIc9VjpxxQFFLcK5AuawVCeXOdQONBqcND+2KG77yMRq90eJwvax0zzOSXk9Sgzel95RkFRlNi+VfxqaXFgFEPPIAZ+CkoGjQUmcA0usPiV3USzzObuzzt3bAG+X2jaYIK5QvzcsF0dYba6NFejZwRv+vffDgli4XJSY/WSNjYveK2l1Td/8UFvQTiKDt3Sgyvwfebp7N4hbWoAaZXeOjOvfRGbqQglB8g5Hg7UlWm+Ai/SEM4fBnj5AdtpXGf+x+lL7scNK4DdoXD5vZtYYWFi957i3z5yXy6iCoEbiiI5aNnXFCOrfllnGbsXVgMKZ5yIxV//jp/ExVshi1CbRnuKzUlE9Mdw1DFpMfUEwYwPEcCDgU++jrcCaGXBsTh5kvf4RlOEw6KmNJeXhwaYObdmYI86U+qSvgR+NBMpuuxLoTMPbjTHNvpCms6F0lGitmdCbY= X-Forefront-Antispam-Report: CIP:216.228.118.232; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc7edge1.nvidia.com; CAT:NONE; SFS:(13230025)(4636009)(39860400002)(376002)(136003)(346002)(396003)(451199018)(40470700004)(36840700001)(46966006)(82740400003)(36860700001)(7636003)(34020700004)(356005)(86362001)(4326008)(36756003)(40480700001)(8676002)(8936002)(6916009)(70206006)(41300700001)(2906002)(5660300002)(82310400005)(70586007)(40460700003)(54906003)(2616005)(1076003)(26005)(336012)(83380400001)(47076005)(426003)(186003)(478600001)(316002)(107886003)(6666004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2023 13:21:05.3988 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7e0fe1e3-ef7d-4ef9-a158-08db198ea573 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.118.232]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT008.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4123 Cc: elibr@nvidia.com, simon.horman@corigine.com, roniba@nvidia.com, i.maximets@ovn.org, konguyen@redhat.com, majd@nvidia.com Subject: [ovs-dev] [PATCH v23 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 two sFlow offload test caes: 3: sflow offloads with sampling=1 - ping between two ports - offloads enabled ok 4: sflow offloads with sampling=2 - ping between two ports - offloads enabled ok Signed-off-by: Chris Mi Reviewed-by: Roi Dayan Acked-by: Eelco Chaudron --- tests/system-offloads-traffic.at | 101 +++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/tests/system-offloads-traffic.at b/tests/system-offloads-traffic.at index 7558812eb..057398e41 100644 --- a/tests/system-offloads-traffic.at +++ b/tests/system-offloads-traffic.at @@ -93,6 +93,107 @@ AT_CHECK([ovs-appctl upcall/show | grep -E "offloaded flows : [[1-9]]"], [0], [i OVS_TRAFFIC_VSWITCHD_STOP AT_CLEANUP +AT_SETUP([sflow offloads with sampling=1 - ping between two ports - offloads enabled]) +OVS_TRAFFIC_VSWITCHD_START() + +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 set Open_vSwitch . other_config:hw-offload=true]) + +AT_CHECK([ovs-appctl -t ovsdb-server exit]) +AT_CHECK([ovs-appctl -t ovs-vswitchd exit]) +AT_CHECK([rm -f ovsdb-server.pid]) +AT_CHECK([rm -f ovs-vswitchd.pid]) +AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --log-file --remote=punix:$OVS_RUNDIR/db.sock], [0], [], [stderr]) +AT_CHECK([ovs-vswitchd --detach --no-chdir --pidfile --log-file -vvconn -vofproto_dpif -vunixctl], [0], [], [stderr]) +on_exit "kill `cat ovsdb-server.pid`" +on_exit "kill_ovs_vswitchd `cat ovs-vswitchd.pid`" + +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]) + +NS_CHECK_EXEC([at_ns0], [ping -c 10 -w 12 10.1.1.2 | FORMAT_PING], [0], [dnl +10 packets transmitted, 10 received, 0% packet loss, time 0ms +]) +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 -c 10 -w 12 10.1.1.2 | FORMAT_PING], [0], [dnl +10 packets transmitted, 10 received, 0% packet loss, time 0ms +]) + +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/"]) +P1_IFINDEX=$(cat /sys/class/net/ovs-p1/ifindex) +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:10, bytes:840, used:0.001s, actions:userspace(pid=1,sFlow(vid=0,pcp=0,output=1),actions),3 +]) + +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/"]) +P0_IFINDEX=$(cat /sys/class/net/ovs-p0/ifindex) +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:10, bytes:840, 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]) +count=`cat sflow.log | wc -l` +AT_CHECK([[[[ $count -le 22 && $count -ge 18 ]]]]) +AT_CLEANUP + +AT_SETUP([sflow offloads with sampling=2 - ping between two ports - offloads enabled]) +OVS_TRAFFIC_VSWITCHD_START() + +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 set Open_vSwitch . other_config:hw-offload=true]) + +AT_CHECK([ovs-appctl -t ovsdb-server exit]) +AT_CHECK([ovs-appctl -t ovs-vswitchd exit]) +AT_CHECK([rm -f ovsdb-server.pid]) +AT_CHECK([rm -f ovs-vswitchd.pid]) +AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --log-file --remote=punix:$OVS_RUNDIR/db.sock], [0], [], [stderr]) +AT_CHECK([ovs-vswitchd --detach --no-chdir --pidfile --log-file -vvconn -vofproto_dpif -vunixctl], [0], [], [stderr]) +on_exit "kill `cat ovsdb-server.pid`" +on_exit "kill_ovs_vswitchd `cat ovs-vswitchd.pid`" + +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 -c 1000 -i 0.01 -w 12 10.1.1.2], [0], [ignore]) + +P1_IFINDEX=$(cat /sys/class/net/ovs-p1/ifindex) +m4_define([DUMP_SFLOW], [sed -e "s/packets:[[0-9]]*/packets:1/;s/bytes:[[0-9]]*/bytes:1/;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:1, bytes:1, 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/packets:[[0-9]]*/packets:1/;s/bytes:[[0-9]]*/bytes:1/;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:1, bytes:1, 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 - set ingress_policing_rate and ingress_policing_burst - offloads disabled]) AT_KEYWORDS([ingress_policing]) AT_SKIP_IF([test $HAVE_TC = "no"])