From patchwork Thu Jun 1 11:16:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Mi X-Patchwork-Id: 1788989 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=SeLw9kSa; 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 4QX3Ww20KGz20QJ for ; Thu, 1 Jun 2023 21:17:48 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 89B90424E0; Thu, 1 Jun 2023 11:17:45 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 89B90424E0 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=SeLw9kSa 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 Qz2xAB2Ybdkj; Thu, 1 Jun 2023 11:17:42 +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 62EAE424D7; Thu, 1 Jun 2023 11:17:39 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 62EAE424D7 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id F387CC0094; Thu, 1 Jun 2023 11:17:36 +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 179E2C0029 for ; Thu, 1 Jun 2023 11:17:35 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 30D9B614FE for ; Thu, 1 Jun 2023 11:17:34 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 30D9B614FE 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=SeLw9kSa 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 5Gb09zLYxwna for ; Thu, 1 Jun 2023 11:17:33 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 4C53D60A7B Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on20615.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eb2::615]) by smtp3.osuosl.org (Postfix) with ESMTPS id 4C53D60A7B for ; Thu, 1 Jun 2023 11:17:33 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Po1uVp0TpA/W0CHm+ebSLxeP/oTX6toXyP97rSquCGVbgWh8zpYG/73a7mGy0GD6JlFR8qq4m9DVV3tk2Me1lB4p+Vk9fod/rKNh4io01Avn20o5tOulVjJNQJmcoMuZXcdbq1d71XhYYrxdGhZHuGALU6ccy4qq+oP1pFnW337xhfkANiAqmWkIF2olpuJsapaeYJ/OXiAx+xc0VHBkBwKRrkW+nhDdIraNsvx8cOQXsgkOdhwcujOT7XmC87XBevPXvaJi19jPZoK81RDJB2hDTSfEVf7zJrWPa2P6GeCn9c0+45PbUZCqnI0SXxpmR9Dz5kyJoaD0dh9JfOQp1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=eo6HWp+kXlXk46W30de3ve8rjPXSXif89pFW/3qvQRk=; b=Ro87YpcJr3ptFRRk5WeIeCEUbnD2bHvLz5f9fNnRe7N1MA8TMzWHOrUZk/D2Jcw0mAW2iqTyILHBitkLvvou61UDQrsEHXAymQfc9WZs/iPBsB2lOXyNx+ax+WPTGRvIvXlcFHl4ct2fZVhTSBXCwE7byUFI2ihIJQIHJwdYDSqUZRIAhO2x1vExyPIfUJLUWqWPIvwvpPiCOBYvkyPOCF+Zbav72EWdOszyXQyEOjdOk+9P4CAdmEPy4eWy2YqS0xvnd+u0zE1LS7yj/+V17YNTwiFKqu52Afism72UNu6Y5HCN7dOO04qY1VRLldoG0/hXdcsVDZIaRDWFH/IavQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=openvswitch.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eo6HWp+kXlXk46W30de3ve8rjPXSXif89pFW/3qvQRk=; b=SeLw9kSafbRjYQXSxcEbSZnk11fcWpoMFlrSigph4DJBtlaAmSBnsdiAE/jK578BzofcDv3MPpl6Ai+lQjTZXV+UqGlBh5pnv7c/1ToRk+EIXN3g+2dHtNwCajTDXdchQ+kLriy+hveduaF1CL+dak811OrTLRDY31r3zl8laQ93/IeEPvw9LStxxG/aKCL14HtJHqLpePnos5bpVemDz2oc8e9HbAsb+andS+Dk7xfxGpM/701dxv6mkCeuwBCxS3hWigRKTAc1xNFSk95vW2nn8gLHAl6xW4S0c3ePtJSfKOcFRgOo1+NWY+IyEeDMIPSAuHpjhtm3v+l07a72ZQ== Received: from MW3PR06CA0003.namprd06.prod.outlook.com (2603:10b6:303:2a::8) by CY8PR12MB7732.namprd12.prod.outlook.com (2603:10b6:930:87::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23; Thu, 1 Jun 2023 11:17:29 +0000 Received: from CO1PEPF000044FA.namprd21.prod.outlook.com (2603:10b6:303:2a:cafe::8d) by MW3PR06CA0003.outlook.office365.com (2603:10b6:303:2a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.23 via Frontend Transport; Thu, 1 Jun 2023 11:17:29 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CO1PEPF000044FA.mail.protection.outlook.com (10.167.241.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.3 via Frontend Transport; Thu, 1 Jun 2023 11:17:29 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Thu, 1 Jun 2023 04:17:07 -0700 Received: from rnnvmail201.nvidia.com (10.129.68.8) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Thu, 1 Jun 2023 04:17:07 -0700 Received: from c-237-115-160-163.mtl.labs.mlnx (10.127.8.12) by mail.nvidia.com (10.129.68.8) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Thu, 1 Jun 2023 04:17:03 -0700 To: Date: Thu, 1 Jun 2023 14:16:51 +0300 Message-ID: <20230601111658.113144-2-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230601111658.113144-1-cmi@nvidia.com> References: <20230601111658.113144-1-cmi@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044FA:EE_|CY8PR12MB7732:EE_ X-MS-Office365-Filtering-Correlation-Id: da058d67-9209-4e86-da01-08db6291c989 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QfgVs0wnaygRjPVlEExO8//V1dYx8ku7xWunjmnwL+qkFD+/mDYTsWRRG5RenEttf08Z+85X2M+B7gyktYpbL2h1+EmRu53o9dPxo3TwUxrm7dn6X2nulcVvxz2kBG3ZwMW9WsdKkQca4SFy51rshwDt/nX2ZjCxMMN6JMzWHd/SJQjR0rjN+65uD8h+Wv0vOIlgkqsuHcWEcTvFwHjltwce2aUL8rHFctyVb9T96zegBT17NJOXqlWMwYo6589UV0IWRV43EbjKy3tk8RXB/2TVx/2qGIO2HNDb7BUXoBs96TeACCvTjRoGum+GBfIrL72jvLRK7M7ywJEuOu6eP5JsuBRJOIkMTPza26B7EnX+u58jXTMyNS9qKg1iKSk0ytIz0RTKOtsLQHYhxE6vseXBn9B2eCnNuq6To1ZKXbmpVjT99IGTbffWfgPjQzKHqs0E4XzUGQarN8U2b7DTeNy3PKAB/RJzrNgKUix8q+IC7p0tIFBJzSdou0AdS+t5GhmlaVuKX0CGNr5N5Phd/g0X1TFvMSlXLLHZb9CdE66vKebx5Qd014RgCiqtlr6iy1C1x8OQWYiV+OOHgeoHAW/nlw0VMpA5k3y01hACy0Tn5sg1LRxSHrWkj/FyLF5fhxFBHVY7un2UH5XEgD9iHvgJ9UCXpORPTFMp6kzEcdFwTigLI+AUFD/7xTZTqBPVXhI/lg1PMW3faevSNrjwHG+9yRYu+PPUY80CwJXkirE= X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(136003)(346002)(396003)(376002)(39860400002)(451199021)(36840700001)(46966006)(40470700004)(186003)(107886003)(41300700001)(2616005)(336012)(426003)(83380400001)(26005)(1076003)(6666004)(47076005)(36860700001)(40460700003)(54906003)(478600001)(6916009)(82740400003)(70206006)(70586007)(7636003)(40480700001)(316002)(356005)(2906002)(8936002)(5660300002)(8676002)(82310400005)(4326008)(36756003)(86362001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2023 11:17:29.2685 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: da058d67-9209-4e86-da01-08db6291c989 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044FA.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7732 Cc: elibr@nvidia.com, simon.horman@corigine.com, roniba@nvidia.com, i.maximets@ovn.org, konguyen@redhat.com, majd@nvidia.com, maord@nvidia.com Subject: [ovs-dev] [PATCH v27 1/8] compat: Add psample and tc sample action defines for older kernels X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Chris Mi via dev From: Chris Mi Reply-To: Chris Mi Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Update kernel UAPI to support psample and the tc sample action. Signed-off-by: Chris Mi Reviewed-by: Roi Dayan Acked-by: Eelco Chaudron --- include/linux/automake.mk | 10 +++--- include/linux/psample.h | 62 ++++++++++++++++++++++++++++++++ include/linux/tc_act/tc_sample.h | 25 +++++++++++++ 3 files changed, 93 insertions(+), 4 deletions(-) create mode 100644 include/linux/psample.h create mode 100644 include/linux/tc_act/tc_sample.h diff --git a/include/linux/automake.mk b/include/linux/automake.mk index cdae5eedc..a397562c0 100644 --- a/include/linux/automake.mk +++ b/include/linux/automake.mk @@ -1,12 +1,14 @@ noinst_HEADERS += \ - include/linux/netlink.h \ + include/linux/gen_stats.h \ include/linux/netfilter/nf_conntrack_sctp.h \ + include/linux/netlink.h \ include/linux/openvswitch.h \ include/linux/pkt_cls.h \ - include/linux/gen_stats.h \ + include/linux/psample.h \ + include/linux/tc_act/tc_ct.h \ include/linux/tc_act/tc_mpls.h \ include/linux/tc_act/tc_pedit.h \ + include/linux/tc_act/tc_sample.h \ include/linux/tc_act/tc_skbedit.h \ include/linux/tc_act/tc_tunnel_key.h \ - include/linux/tc_act/tc_vlan.h \ - include/linux/tc_act/tc_ct.h + include/linux/tc_act/tc_vlan.h diff --git a/include/linux/psample.h b/include/linux/psample.h new file mode 100644 index 000000000..e585db5bf --- /dev/null +++ b/include/linux/psample.h @@ -0,0 +1,62 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __UAPI_PSAMPLE_H +#define __UAPI_PSAMPLE_H + +enum { + PSAMPLE_ATTR_IIFINDEX, + PSAMPLE_ATTR_OIFINDEX, + PSAMPLE_ATTR_ORIGSIZE, + PSAMPLE_ATTR_SAMPLE_GROUP, + PSAMPLE_ATTR_GROUP_SEQ, + PSAMPLE_ATTR_SAMPLE_RATE, + PSAMPLE_ATTR_DATA, + PSAMPLE_ATTR_GROUP_REFCOUNT, + PSAMPLE_ATTR_TUNNEL, + + PSAMPLE_ATTR_PAD, + PSAMPLE_ATTR_OUT_TC, /* u16 */ + PSAMPLE_ATTR_OUT_TC_OCC, /* u64, bytes */ + PSAMPLE_ATTR_LATENCY, /* u64, nanoseconds */ + PSAMPLE_ATTR_TIMESTAMP, /* u64, nanoseconds */ + PSAMPLE_ATTR_PROTO, /* u16 */ + + __PSAMPLE_ATTR_MAX +}; + +enum psample_command { + PSAMPLE_CMD_SAMPLE, + PSAMPLE_CMD_GET_GROUP, + PSAMPLE_CMD_NEW_GROUP, + PSAMPLE_CMD_DEL_GROUP, +}; + +enum psample_tunnel_key_attr { + PSAMPLE_TUNNEL_KEY_ATTR_ID, /* be64 Tunnel ID */ + PSAMPLE_TUNNEL_KEY_ATTR_IPV4_SRC, /* be32 src IP address. */ + PSAMPLE_TUNNEL_KEY_ATTR_IPV4_DST, /* be32 dst IP address. */ + PSAMPLE_TUNNEL_KEY_ATTR_TOS, /* u8 Tunnel IP ToS. */ + PSAMPLE_TUNNEL_KEY_ATTR_TTL, /* u8 Tunnel IP TTL. */ + PSAMPLE_TUNNEL_KEY_ATTR_DONT_FRAGMENT, /* No argument, set DF. */ + PSAMPLE_TUNNEL_KEY_ATTR_CSUM, /* No argument. CSUM packet. */ + PSAMPLE_TUNNEL_KEY_ATTR_OAM, /* No argument. OAM frame. */ + PSAMPLE_TUNNEL_KEY_ATTR_GENEVE_OPTS, /* Array of Geneve options. */ + PSAMPLE_TUNNEL_KEY_ATTR_TP_SRC, /* be16 src Transport Port. */ + PSAMPLE_TUNNEL_KEY_ATTR_TP_DST, /* be16 dst Transport Port. */ + PSAMPLE_TUNNEL_KEY_ATTR_VXLAN_OPTS, /* Nested VXLAN opts* */ + PSAMPLE_TUNNEL_KEY_ATTR_IPV6_SRC, /* struct in6_addr src IPv6 address. */ + PSAMPLE_TUNNEL_KEY_ATTR_IPV6_DST, /* struct in6_addr dst IPv6 address. */ + PSAMPLE_TUNNEL_KEY_ATTR_PAD, + PSAMPLE_TUNNEL_KEY_ATTR_ERSPAN_OPTS, /* struct erspan_metadata */ + PSAMPLE_TUNNEL_KEY_ATTR_IPV4_INFO_BRIDGE, /* No argument. IPV4_INFO_BRIDGE mode.*/ + __PSAMPLE_TUNNEL_KEY_ATTR_MAX +}; + +/* Can be overridden at runtime by module option */ +#define PSAMPLE_ATTR_MAX (__PSAMPLE_ATTR_MAX - 1) + +#define PSAMPLE_NL_MCGRP_CONFIG_NAME "config" +#define PSAMPLE_NL_MCGRP_SAMPLE_NAME "packets" +#define PSAMPLE_GENL_NAME "psample" +#define PSAMPLE_GENL_VERSION 1 + +#endif diff --git a/include/linux/tc_act/tc_sample.h b/include/linux/tc_act/tc_sample.h new file mode 100644 index 000000000..fee1bcc20 --- /dev/null +++ b/include/linux/tc_act/tc_sample.h @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __LINUX_TC_SAMPLE_H +#define __LINUX_TC_SAMPLE_H + +#include +#include +#include + +struct tc_sample { + tc_gen; +}; + +enum { + TCA_SAMPLE_UNSPEC, + TCA_SAMPLE_TM, + TCA_SAMPLE_PARMS, + TCA_SAMPLE_RATE, + TCA_SAMPLE_TRUNC_SIZE, + TCA_SAMPLE_PSAMPLE_GROUP, + TCA_SAMPLE_PAD, + __TCA_SAMPLE_MAX +}; +#define TCA_SAMPLE_MAX (__TCA_SAMPLE_MAX - 1) + +#endif From patchwork Thu Jun 1 11:16:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Mi X-Patchwork-Id: 1788990 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=QAV9Amlb; 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 4QX3Wy1wlXz20QB for ; Thu, 1 Jun 2023 21:17:50 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 665186151F; Thu, 1 Jun 2023 11:17:48 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 665186151F 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=QAV9Amlb 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 ga5fnOyMhv5j; Thu, 1 Jun 2023 11:17:47 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id B67BC61546; Thu, 1 Jun 2023 11:17:45 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org B67BC61546 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 7BA31C007A; Thu, 1 Jun 2023 11:17:45 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 154F2C008B for ; Thu, 1 Jun 2023 11:17:45 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id A5121424A5 for ; Thu, 1 Jun 2023 11:17:40 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org A5121424A5 Authentication-Results: smtp4.osuosl.org; dkim=pass (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=QAV9Amlb 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 bUdhC2CD2ex0 for ; Thu, 1 Jun 2023 11:17:39 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 22AF2424D3 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on20621.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8c::621]) by smtp4.osuosl.org (Postfix) with ESMTPS id 22AF2424D3 for ; Thu, 1 Jun 2023 11:17:39 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A3juRXkKDe68mMjfh3CowpluoDhtRkeEr40He4IGJHWEOZf0BcV6VYQSfKaFTYkwHH8a1MLeaeQMeeWsspDmxmGvAkenvd/fdlkiTciDlpAzs2b0q6MOfWc6MZTwJKORuOgDLRXJgdvwRjh5h0P1FzKdNsb2rZwcyFY568xKhimM9M3n/PTYcEob8Mf0dkhIZxCFFHPRC7ECJ2dm3O+LMsK5WE7fTXw4C+IZ5vuoQYNDEQfeX4N53vH1D3cSIP4PoQHHS86YwpF4A5BjVXpqnS1ZjgtlMNbcdbXvyxjK6xQH2NJKchBL3UJl6ds/qLuekD+pHKuS+zRtQn6KMMFmZw== 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=SoQ6ZY04QpkV7JdmSOGPiS7uSBVjzovxr+WSHB7XvmXSBZQQgot02CarzG0PJ2+HUUEOtXQrbrooz5hJm3W6P/J+aHaq9ik/QytyHO4KGryvXW5Yl2oMu3H2F6M1BOK4WiabyfGh//suZ+JVXbwuChUff9LsGOtAQHBiipom6n97w8ZG8rO4uY4CSEdMV6uBH7HeAl/qf6SMMfJlnHm6hZqhILVx3EtkRlT9rpqzmOD3fDqoxv0P2G6VxUThutJd1iyBxZgpTF2zTu6Bx0Hablg4dxidyyPfG3wAu0MZ19fI2W58c3iMqBetkAnOsDJae7hLpBddA/d/WzEj1q/ctA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=openvswitch.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ol/bVZ/jkiZTV5fMK4ElSYc14fs0ViONNZedP3kh02U=; b=QAV9AmlbKVQMArSf8V3wANUfn3pmBNpWZGzwcHKOynHvHmzI9eUDhCttqMBAChaSl3ImZvwSifOjlx+61WYsn9v84IzBc49fuiU5cYRGnkETEAWc7HR0oE2mdpHMXXDzXYKe5iVzIcy3at5lad8lWX8Ped5OTq4fQqtTjksphn2ExZAuGef+6zdQrlAJzZMqPeUvxELpXsuzdc1yKCH0CvDV9Im6jqE9da+unbdgSYfaxcD1NZ47MqjPBZ0uDSLdrQterJ81YPxj64g0JwRr3kmFYhAZc9mNBcQbCN0ydjTyf5jc2Auu6I1AhukaxoMIRVrqO1g8tY+7qUZY5ivTgA== Received: from MW4P221CA0027.NAMP221.PROD.OUTLOOK.COM (2603:10b6:303:8b::32) by PH7PR12MB6833.namprd12.prod.outlook.com (2603:10b6:510:1af::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.27; Thu, 1 Jun 2023 11:17:36 +0000 Received: from CO1PEPF000044FC.namprd21.prod.outlook.com (2603:10b6:303:8b:cafe::f6) by MW4P221CA0027.outlook.office365.com (2603:10b6:303:8b::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.23 via Frontend Transport; Thu, 1 Jun 2023 11:17:36 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CO1PEPF000044FC.mail.protection.outlook.com (10.167.241.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.3 via Frontend Transport; Thu, 1 Jun 2023 11:17:34 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Thu, 1 Jun 2023 04:17:11 -0700 Received: from rnnvmail201.nvidia.com (10.129.68.8) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Thu, 1 Jun 2023 04:17:11 -0700 Received: from c-237-115-160-163.mtl.labs.mlnx (10.127.8.12) by mail.nvidia.com (10.129.68.8) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Thu, 1 Jun 2023 04:17:08 -0700 To: Date: Thu, 1 Jun 2023 14:16:52 +0300 Message-ID: <20230601111658.113144-3-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230601111658.113144-1-cmi@nvidia.com> References: <20230601111658.113144-1-cmi@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044FC:EE_|PH7PR12MB6833:EE_ X-MS-Office365-Filtering-Correlation-Id: 3dceecb8-791f-42b1-4164-08db6291ccd7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iJIEPriFh6x8TlRUQBVMjWuvZwFswsUyJAaeXGSBRivwym1uo096BJSpthy4SVB9lk1K11Xb8DqLmJr6CRYMsMK6P5F6gBZu2XzOODTQJ32Fd1YhS75F5tWEbfjAfVALjEWS+eLfQwXE1xCWpwDVw6oOLouMjhwOg/CCFbAu9aQ7PayqVwpACrpUyVnSEb4TAKnCYUc8L4LWpkhDHqW6MEuZWIjYGyWr4EuoMQOHiH54mcv5zuCJk7TyTmAPduK/TlsfjdFuk+a0l+9C0TDUyNLG5/BMIqJKhW1dd+onBWbWFH4cfy0eew8s2zgD9uN+JOgDl5wCvGcnyKkOauR7igVSnlgm2aSRzj5hF32q13eWaBrNP3j1bOLD697BEHdmGO4Wvj5/uFH5gThMSfXKUK4ifJPvs2AzSXrArwRa+3d39JgOIs5W5LMAcbyItnwwROicmquyBKYv4DFALKDwlzMy67bYn4xu5aWITcuOTiVUZ+6eIO/3eZee1FCp3wsbxHHDcdzM8VDCSZVHSLUoLK7zqQDN2fxELUVxhBbjup8bG391Sa5ch3IHA/eEJbp6P5RxSW69ay49gvn2n8a/nnfUV9NDlADYM/UkvOU7bJcVLG2hycgr6LIOjBSw9V4+px+JJtYn4lgjDqFODGuYjJdweeKDTcnU1mStQYjFrAClJlzh64SmeasLNlD47XSfGu0uR9ToYevq4m+jKvp9E24jiobDGWKeMuPjtX1yBe2PrjsWLygTCTY2/U5N1Fud X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(376002)(39860400002)(346002)(136003)(396003)(451199021)(40470700004)(36840700001)(46966006)(54906003)(478600001)(7636003)(36860700001)(70206006)(356005)(82310400005)(6916009)(47076005)(4326008)(83380400001)(70586007)(336012)(426003)(82740400003)(2616005)(6666004)(316002)(26005)(186003)(1076003)(86362001)(2906002)(40480700001)(107886003)(40460700003)(36756003)(8936002)(8676002)(41300700001)(5660300002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2023 11:17:34.7933 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3dceecb8-791f-42b1-4164-08db6291ccd7 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044FC.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6833 Cc: elibr@nvidia.com, simon.horman@corigine.com, roniba@nvidia.com, i.maximets@ovn.org, konguyen@redhat.com, majd@nvidia.com, maord@nvidia.com Subject: [ovs-dev] [PATCH v27 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 Thu Jun 1 11:16:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Mi X-Patchwork-Id: 1788987 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=aYhfg3Wv; dkim-atps=neutral Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QX3Wp1Skgz20QB for ; Thu, 1 Jun 2023 21:17:42 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 9EBBB6151B; Thu, 1 Jun 2023 11:17:38 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 9EBBB6151B 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=aYhfg3Wv 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 jqXC7wBv4jB0; Thu, 1 Jun 2023 11:17:37 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 312DF60597; Thu, 1 Jun 2023 11:17:36 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 312DF60597 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0CF9BC0087; Thu, 1 Jun 2023 11:17:36 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 8DC65C0029 for ; Thu, 1 Jun 2023 11:17:34 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 75B6340BCC for ; Thu, 1 Jun 2023 11:17:34 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 75B6340BCC 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=aYhfg3Wv 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 4Kch-Pkcsddw for ; Thu, 1 Jun 2023 11:17:33 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 6840B4032A Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on20613.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5a::613]) by smtp2.osuosl.org (Postfix) with ESMTPS id 6840B4032A for ; Thu, 1 Jun 2023 11:17:33 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AdRMHTk2tzO0iAmfDz4GgcvsOzibNHTWiuyhJiBSNPx4PTprMhtMXyDIqZDjRv5XjVhRKAlRZrirO8LVTaP1mmuxIdD9aDXmF2pCXrDdhGFRVWGQolSEjV2eNoAtdaW7vdWjoNXX6bLS813ozie4NNoNKCOKxTnaX3eG4FKw8QpQ8rocp0TEd+VI0SYtFbXzk0YD3tYXI0XVvUhXH4ydrvzXv6imGd01VTOQrN9+5zgki43a3U9+7fiudnVGKML2zVDfNzbGD1S8dJ9e8PNCjKZO2eYoRqz6WH6pMADLAWiTzY7nLtsCOJRFCS1fovSj3rgAsgx1429uWmeXRR01/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kGINxzFK0N03RlVYkFc4+Cl3SUvQe9lZ7bYLcZKlFjg=; b=OT0rmU0E5ao/gFz6+Kta/d3SvQt35TBO6Wr6KIr8enGSEmayptPZllY0vH8Va0hy9+Tl6btOCP+IC5nmCfmtCYxI+QDyzBZCjkJIMJDQGL+m8x3VwpeQYAQKj60SFBZl36lv1PtWOCPF1G/mDSy/ByYD5FxL63dDq02iR4H5HHmibXqY7gxgbdCEKgb8qDI92F+uKlFyIZ9Cw/jVkAy8lmmDgnkN2A091me1ZvfEIv4yqOSUGlBdm1pPp/AeTJLi4u6Fwk1u3b4wdwFl2aFMNmbSmb1HLQc8QWBgWg3msiclhe+bo7x6CHQsC6XTsi8Zq64/6Ve3l+ebw8ljDtzDpg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=openvswitch.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kGINxzFK0N03RlVYkFc4+Cl3SUvQe9lZ7bYLcZKlFjg=; b=aYhfg3WvTXwd0AVa1JllOmzAjAJdOIhR2qZ8e+9dnSWACmljeLgCCSpKSKSnodA17KWybzdoKqTU4ZCC1WoMQP6iUcDDmqgaKcsgID3whVSNt4Dg/B0IWBuHhkzUitQm/D8KW7AaSqxUCL7WIhGj/pj/leU4uRahlmG3Qr5plIl6SDiveYNky3J7mcij+vdXGYqT6dSPLXnEAz/Fh/1Znqh7RfOU3k6Pg/P/BCxJlXJ19Q7sCYu+iC+0BHRvQw1k3TlTYCP5UG9ZOaAaAlI8A/iOkPC6H/jAiKlE0PppUf7ScYV9fKMiCuUuLIpi0od32zyLjAGNgBqiHkw77Pel/w== Received: from SA9PR13CA0131.namprd13.prod.outlook.com (2603:10b6:806:27::16) by CH3PR12MB9250.namprd12.prod.outlook.com (2603:10b6:610:1ae::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.24; Thu, 1 Jun 2023 11:17:30 +0000 Received: from SA2PEPF00001504.namprd04.prod.outlook.com (2603:10b6:806:27:cafe::bd) by SA9PR13CA0131.outlook.office365.com (2603:10b6:806:27::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.10 via Frontend Transport; Thu, 1 Jun 2023 11:17:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by SA2PEPF00001504.mail.protection.outlook.com (10.167.242.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.18 via Frontend Transport; Thu, 1 Jun 2023 11:17:29 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Thu, 1 Jun 2023 04:17:16 -0700 Received: from rnnvmail201.nvidia.com (10.129.68.8) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Thu, 1 Jun 2023 04:17:15 -0700 Received: from c-237-115-160-163.mtl.labs.mlnx (10.127.8.12) by mail.nvidia.com (10.129.68.8) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Thu, 1 Jun 2023 04:17:12 -0700 To: Date: Thu, 1 Jun 2023 14:16:53 +0300 Message-ID: <20230601111658.113144-4-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230601111658.113144-1-cmi@nvidia.com> References: <20230601111658.113144-1-cmi@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00001504:EE_|CH3PR12MB9250:EE_ X-MS-Office365-Filtering-Correlation-Id: 0146a833-6dbe-407b-f889-08db6291c9c7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: e8Z60gWsx8sukWJ++pUHvBynRnpoUUd4EAh4FnKYCwYhUqOVLqj3DgsSBP48oAOAHheaco0+uBh2T/cUtZiSk225o9/RPivT99DN3y3hDq8bs6j+uNQdq5pfmOBuxWu7RuP45Rc1iUHQ34JN9eUMIdnyqiwkSIzloEH8dPcvDL7T/k+uUT64yUr/rB5dnLV9JaKpFiI9xgc9j9c5tgMiD/TE56IszGGvHsK4n11f9RISvc0rj4rrAOXxHqcJ6sLalG91Vy0C4h4jwqmP/Utgc8VORJzzyQXSazrcLEYOOgN88LmFOBaQgMQteqfApnOG+H6SpImdcqXaTyA9off9Xdz6dfxnMXtSf8fmSyJqKefTdPCw2tY1cpdrJeh2pxpLtr8frpZtE3OTwe3mf7EDnTtiIAFCThIRRDiRoSHPfkcX9vWwRAR9lA/z5UscxRFTtc1z9q7cacxOkuAVSm75pjL8k/s1o1AVMYqBfd7xnv0PcFqwQt+GYLBKyaoM3Hvu+Pa18SZs7A9A7EmcnnZD9YQNXEYILptHNpPNSROEvDy14ivBLugp2wAbBeVXKofbUOIgRahhPlBwJh9/f0qkEa6KKakDLE4aa6JzWDYhrxr3YpLS3B5qyuN1Nyk6H8EJYpIB3VVP8RSbk21cuQaDSaKnY/Ak1/V+CxjmGp3bsRctyh+/WVAIWWsCohzQQVtQGzi6XArIq3gO7axk91c/VBDlY4TeZTjRF5EktVL0+I1vMx7JeGBOkSCK2meMUF/4 X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(346002)(39860400002)(376002)(136003)(396003)(451199021)(46966006)(40470700004)(36840700001)(54906003)(6666004)(5660300002)(6916009)(316002)(70206006)(4326008)(70586007)(478600001)(1076003)(2616005)(426003)(26005)(336012)(2906002)(8936002)(41300700001)(8676002)(107886003)(186003)(83380400001)(47076005)(36860700001)(356005)(82740400003)(7636003)(82310400005)(36756003)(40480700001)(40460700003)(86362001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2023 11:17:29.6444 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0146a833-6dbe-407b-f889-08db6291c9c7 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00001504.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9250 Cc: elibr@nvidia.com, simon.horman@corigine.com, roniba@nvidia.com, i.maximets@ovn.org, konguyen@redhat.com, majd@nvidia.com, maord@nvidia.com Subject: [ovs-dev] [PATCH v27 3/8] netdev-offload-tc: Introduce group ID management API X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Chris Mi via dev From: Chris Mi Reply-To: Chris Mi Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" When offloading sample action to TC, userspace creates a unique ID to map sample action and tunnel info and passes this ID to kernel instead of the sample info. Kernel will send this ID and sampled packet to userspace. Using the ID, userspace can recover the sample info and send sampled packet to the right sample monitoring host. Signed-off-by: Chris Mi Reviewed-by: Roi Dayan --- lib/netdev-offload-tc.c | 160 +++++++++++++++++++++++++++++++++++++--- lib/util.c | 6 ++ lib/util.h | 1 + 3 files changed, 158 insertions(+), 9 deletions(-) diff --git a/lib/netdev-offload-tc.c b/lib/netdev-offload-tc.c index 4f26dd8cc..79bc3225a 100644 --- a/lib/netdev-offload-tc.c +++ b/lib/netdev-offload-tc.c @@ -19,28 +19,29 @@ #include #include +#include "cmap.h" +#include "dpif-provider.h" #include "dpif.h" #include "hash.h" #include "id-pool.h" -#include "openvswitch/hmap.h" -#include "openvswitch/match.h" -#include "openvswitch/ofpbuf.h" -#include "openvswitch/thread.h" -#include "openvswitch/types.h" -#include "openvswitch/util.h" -#include "openvswitch/vlog.h" #include "netdev-linux.h" #include "netdev-offload-provider.h" #include "netdev-provider.h" #include "netdev-vport.h" -#include "netlink.h" #include "netlink-socket.h" +#include "netlink.h" #include "odp-netlink.h" #include "odp-util.h" +#include "openvswitch/hmap.h" +#include "openvswitch/match.h" +#include "openvswitch/ofpbuf.h" +#include "openvswitch/thread.h" +#include "openvswitch/types.h" +#include "openvswitch/util.h" +#include "openvswitch/vlog.h" #include "tc.h" #include "unaligned.h" #include "util.h" -#include "dpif-provider.h" VLOG_DEFINE_THIS_MODULE(netdev_offload_tc); @@ -103,6 +104,129 @@ static void parse_tc_flower_to_stats(struct tc_flower *flower, static int get_ufid_adjust_stats(const ovs_u128 *ufid, struct dpif_flow_stats *stats); +/* When offloading sample action to TC, userspace creates a unique ID + * to map sample action and tunnel info and passes this ID to kernel + * instead of the sample info. Kernel will send this ID and sampled + * packet to userspace. Using the ID, userspace can recover the sample + * info and send sampled packet to the right sample monitoring host. */ +struct offload_sample { + uint16_t type; /* enum user_action_cookie_type. */ + struct nlattr *action; /* Sample action. Used in flow_get. */ + struct nlattr *userdata; /* Struct user_action_cookie. */ + struct nlattr *userspace_actions; /* All actions to get output tunnel. */ + size_t userspace_actions_len; /* All actions length without nla + header. */ + struct flow_tnl *tunnel; /* Input tunnel. */ + uint16_t ifindex; /* Input ifindex. */ +}; + +/* This maps a sample group ID to struct offload_sample. */ +struct sgid_node { + struct cmap_node id_node; + uint32_t id; + struct offload_sample sample; +}; + +/* The sgid_map mutex protects the sample_group_ids and the sgid_map for + * cmap_insert(), cmap_remove(), or cmap_replace() operations. */ +static struct ovs_mutex sgid_lock = OVS_MUTEX_INITIALIZER; +static struct cmap sgid_map = CMAP_INITIALIZER; +static struct id_pool *sample_group_ids OVS_GUARDED_BY(sgid_lock); + +static void +sgid_node_free(struct sgid_node *node) +{ + if (node) { + if (node->id) { + ovs_mutex_lock(&sgid_lock); + id_pool_free_id(sample_group_ids, node->id); + ovs_mutex_unlock(&sgid_lock); + } + free(node->sample.tunnel); + free(node->sample.action); + free(node->sample.userspace_actions); + free(node->sample.userdata); + free(node); + } +} + +static struct sgid_node * +sgid_find(uint32_t id) +{ + const struct cmap_node *node = cmap_find(&sgid_map, id); + + return node ? CONTAINER_OF(node, struct sgid_node, id_node) : NULL; +} + +static void +offload_sample_clone(struct offload_sample *dst, + const struct offload_sample *src, + bool steal_userspace_actions) +{ + dst->type = src->type; + dst->action = nullable_xmemdup(src->action, src->action ? + src->action->nla_len : 0); + if (steal_userspace_actions) { + dst->userspace_actions = src->userspace_actions; + } else { + uint16_t len = src->userspace_actions_len; + + dst->userspace_actions = xmalloc(len + NLA_HDRLEN); + nullable_memcpy((char *) dst->userspace_actions + NLA_HDRLEN, + src->userspace_actions, len); + dst->userspace_actions->nla_len = len + NLA_HDRLEN; + } + dst->userdata = nullable_xmemdup(src->userdata, src->userdata ? + src->userdata->nla_len : + 0); + dst->tunnel = nullable_xmemdup(src->tunnel, sizeof *src->tunnel); + dst->ifindex = src->ifindex; +} + +/* Allocate a unique group id for the given set of flow metadata. The id + * space is 2^^32 - 1. 0 is reserved. */ +static uint32_t +sgid_alloc(const struct offload_sample *sample) +{ + struct sgid_node *node = xzalloc(sizeof *node); + + offload_sample_clone(&node->sample, sample, false); + + ovs_mutex_lock(&sgid_lock); + + if (id_pool_alloc_id(sample_group_ids, &node->id)) { + cmap_insert(&sgid_map, &node->id_node, node->id); + } else { + VLOG_ERR("Can't find a free sample group ID"); + sgid_node_free(node); + node = NULL; + } + + ovs_mutex_unlock(&sgid_lock); + + return node ? node->id : 0; +} + +static void +sgid_free(uint32_t id) +{ + struct sgid_node *node; + + if (!id) { + return; + } + + node = sgid_find(id); + if (node) { + ovs_mutex_lock(&sgid_lock); + cmap_remove(&sgid_map, &node->id_node, node->id); + ovs_mutex_unlock(&sgid_lock); + ovsrcu_postpone(sgid_node_free, node); + } else { + VLOG_ERR("Freeing nonexistent sample group ID: %"PRIu32, id); + } +} + static bool is_internal_port(const char *type) { @@ -192,12 +316,17 @@ static struct netlink_field set_flower_map[][4] = { static struct ovs_mutex ufid_lock = OVS_MUTEX_INITIALIZER; +#define MAX_TC_SAMPLES_PER_FLOW 1 + /** * struct ufid_tc_data - data entry for ufid-tc hashmaps. * @ufid_to_tc_node: Element in @ufid_to_tc hash table by ufid key. * @tc_to_ufid_node: Element in @tc_to_ufid hash table by tcf_id key. * @ufid: ufid assigned to the flow * @id: tc filter id (tcf_id) + * @sample_group_id: Mapping id for sample actions. Currently only supports + a single sFlow action. Use an array to support multiple + similar actions or additional sample types in the future. * @netdev: netdev associated with the tc rule * @adjust_stats: When flow gets updated with new actions, we need to adjust * the reported stats to include previous values as the hardware @@ -208,6 +337,7 @@ struct ufid_tc_data { struct hmap_node tc_to_ufid_node; ovs_u128 ufid; struct tcf_id id; + uint32_t sample_group_id[MAX_TC_SAMPLES_PER_FLOW]; struct netdev *netdev; struct dpif_flow_stats adjust_stats; }; @@ -231,6 +361,7 @@ del_ufid_tc_mapping_unlocked(const ovs_u128 *ufid) hmap_remove(&ufid_to_tc, &data->ufid_to_tc_node); hmap_remove(&tc_to_ufid, &data->tc_to_ufid_node); netdev_close(data->netdev); + sgid_free(data->sample_group_id[0]); free(data); } @@ -2133,6 +2264,14 @@ netdev_tc_parse_nl_actions(struct netdev *netdev, struct tc_flower *flower, if (err) { return err; } + } else if (nl_attr_type(nla) == OVS_ACTION_ATTR_SAMPLE) { + struct offload_sample sample; + uint32_t sgid; + + memset(&sample, 0, sizeof sample); + sgid = sgid_alloc(&sample); + sgid_free(sgid); + return EOPNOTSUPP; } else { VLOG_DBG_RL(&rl, "unsupported put action type: %d", nl_attr_type(nla)); @@ -2876,6 +3015,9 @@ netdev_tc_init_flow_api(struct netdev *netdev) tc_cleanup_policer_actions(meter_police_ids, METER_POLICE_IDS_BASE, METER_POLICE_IDS_MAX); ovs_mutex_unlock(&meter_police_ids_mutex); + ovs_mutex_lock(&sgid_lock); + sample_group_ids = id_pool_create(1, UINT32_MAX - 1); + ovs_mutex_unlock(&sgid_lock); ovsthread_once_done(&once); } diff --git a/lib/util.c b/lib/util.c index 3fb3a4b40..beac6c813 100644 --- a/lib/util.c +++ b/lib/util.c @@ -190,6 +190,12 @@ xmemdup(const void *p_, size_t size) return p; } +void * +nullable_xmemdup(const void *p_, size_t size) +{ + return p_ == NULL || size == 0 ? NULL : xmemdup(p_, size); +} + char * xmemdup0(const char *p_, size_t length) { diff --git a/lib/util.h b/lib/util.h index 62801e85f..815091edd 100644 --- a/lib/util.h +++ b/lib/util.h @@ -167,6 +167,7 @@ void *xcalloc(size_t, size_t) MALLOC_LIKE; void *xzalloc(size_t) MALLOC_LIKE; void *xrealloc(void *, size_t); void *xmemdup(const void *, size_t) MALLOC_LIKE; +void *nullable_xmemdup(const void *p_, size_t size) MALLOC_LIKE; char *xmemdup0(const char *, size_t) MALLOC_LIKE; char *xstrdup(const char *) MALLOC_LIKE; char *nullable_xstrdup(const char *) MALLOC_LIKE; From patchwork Thu Jun 1 11:16:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Mi X-Patchwork-Id: 1788988 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=BUM+R32n; 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 4QX3Ww1HByz20QB for ; Thu, 1 Jun 2023 21:17:47 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 17FC0841F2; Thu, 1 Jun 2023 11:17:46 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 17FC0841F2 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=BUM+R32n 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 PaXxN_dZVZob; Thu, 1 Jun 2023 11:17:44 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTPS id D31E88421E; Thu, 1 Jun 2023 11:17:43 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org D31E88421E Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id AB82FC007A; Thu, 1 Jun 2023 11:17:43 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 1AFCAC007A for ; Thu, 1 Jun 2023 11:17:43 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 2A811424C7 for ; Thu, 1 Jun 2023 11:17:38 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 2A811424C7 Authentication-Results: smtp4.osuosl.org; dkim=pass (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=BUM+R32n 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 Tcy0xK1wSpru for ; Thu, 1 Jun 2023 11:17:36 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org BFDF8424C2 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2061e.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e89::61e]) by smtp4.osuosl.org (Postfix) with ESMTPS id BFDF8424C2 for ; Thu, 1 Jun 2023 11:17:36 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cYj2SAZw/gJUgj8GRe7zq/VewQUVFr6OgaluO9WstoBz2dH8vL2ooClpgFSvPYqbSDAOjbpWGulTp1P5U/wbNYG+yjodDoDleTsi63P/GIRxRzod3ZniWFxVPX7OwaZ/QlgTX6lzbzEXVRXDNQCbocyRW7dogC3GD8QD0FG9uxauDG639WK7ZOglqa4aRBiQizNJomacsaolB3oj6eUg1qnn8l9d7aOO23y3zJChpGRp0FJ47AQxopebs8B9ekVHJbGFdXXBI1SVFUOgQiMyHj3rLMlefxH2X4WVAKx1kt5msESoZdggRHChL8GdHPJT6OEy9+3+Z4kaFffEiuqEbw== 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=ItNJser8cAMhOk+ZxVlWPzRvWNgjeARkFAnHTRQaeVM=; b=RFRjKExFpAg3HtwgUFHkUsTFvlEZnQinHHElxK5PV4deZnnZBzG3JUC0Vw1bIYbx8yR9+kh5YhDAhizMBHP1yRI9uTly0quyH93ZT0gfPWjStpTDmMe6wgALv4ujyBDcfQZw3AHOj7qM6ol53Jq+xKXhlpDo4j2paRIxv8yQdXgWlRpXdRXywDcH6NukdQUQ+QHbo2E7wwJGucIJ4J35py8Xhd3fLZcheX54HOosDahBeIpEZAzYJAQKxo4+oSaeY4hL9u2GZB36B0GvMLKexAOL1N8IuTsfpdBX2X8ldKpbrQxZ2XFQhgy04Wl1wtCZUO37JOij+HS7odcP4d/XJA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=openvswitch.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ItNJser8cAMhOk+ZxVlWPzRvWNgjeARkFAnHTRQaeVM=; b=BUM+R32noo9lNaxokRibJ4KtrTm9KrxNYQNWwteEtZNp/k+K9VMkn9niak8GBlcL4APZPNs1uy7bUWiRDZGPtZKGMJ/hWnSsAjnGZvULOPfOvCoZEFEIUnOY25l1DFw5VRx+kP95ZHwy39dtw7dWTYF8ity5fZu6O49L+8Ed8cWV6WqCB+7f2J+tnGcJDpwtJp14SKxlznAdngpDwINkqMYeZzkPsENgDrckRui7ci+mVvTmyqoSCxC9utJaejeITIIwYAtgV+8amZAMbeHFYBrYUon8ZtW2oyGTFkOXzLWjY+8yfL5wBeOJq9NNA9IThpAAUYR57A/JTrya/g+JSw== Received: from SA1P222CA0143.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:3c2::19) by PH7PR12MB5877.namprd12.prod.outlook.com (2603:10b6:510:1d5::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.16; Thu, 1 Jun 2023 11:17:33 +0000 Received: from SA2PEPF0000150B.namprd04.prod.outlook.com (2603:10b6:806:3c2:cafe::1c) by SA1P222CA0143.outlook.office365.com (2603:10b6:806:3c2::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.23 via Frontend Transport; Thu, 1 Jun 2023 11:17:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by SA2PEPF0000150B.mail.protection.outlook.com (10.167.242.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.18 via Frontend Transport; Thu, 1 Jun 2023 11:17:33 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Thu, 1 Jun 2023 04:17:20 -0700 Received: from rnnvmail201.nvidia.com (10.129.68.8) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Thu, 1 Jun 2023 04:17:19 -0700 Received: from c-237-115-160-163.mtl.labs.mlnx (10.127.8.12) by mail.nvidia.com (10.129.68.8) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Thu, 1 Jun 2023 04:17:16 -0700 To: Date: Thu, 1 Jun 2023 14:16:54 +0300 Message-ID: <20230601111658.113144-5-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230601111658.113144-1-cmi@nvidia.com> References: <20230601111658.113144-1-cmi@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF0000150B:EE_|PH7PR12MB5877:EE_ X-MS-Office365-Filtering-Correlation-Id: 53f36e06-6952-4e4c-8b3a-08db6291cc02 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eiwn9SMupcEU5eTgoNTJl9g2oyAW9tQb1D9J3xCHJ+xjb6919crRoriM37nnfYvIQYSzLwfZk5/1K8joxs8sSePEuOuqVUSKm2+lhJX7ac+tUF8rgEIWMbp2YFCfRREutB9p90h3ybro/ZOkax3/gIGLJ9AwL751Tt9xTIHGRuz7klW7ThX+XvZVscCvox2dLMQDc5bf7kHlYz8Mi0tn261aWWppC1LBWuNbbCsoy7TRET1Q9ve3CsM3J+3BQVHSDu4zJCuVj6ZXQHoDoXflkC3mgAmBCRp6tBZ7Q/s2OqbquehYsWdnJuFnLDzMr+bEyWAlYi8WLWdWasfuSbBIj1GNmdzdZsrrno9qWZURPiLOieERhP3vwizDEvXq2F2cyQz1FnGgU2bUzVJ2ns0/AYZZDNcwU/8f2cXII3iCsr5fxmG/mdeuBo1SYQjQvIGws5n+XPh537fl7pk5bSPi36eC42cf00srNL8FQBi7wEViecrID0/81Jp4kPkdevOu+vQb9oJ9Hv5FEC/av97A1zXUjIw8SCmfpIQuqsRVVfNHXcdX3w714ooDNHMVwsImUJ/pFzi+r9JhnJ4jyxufmTu7bKT9hv7FqWTPR6EqFvwnzzUQJ6XV+1pTscyt6w4Xs4XKSWeyqp+fmDhQ17JysbxMyaR7hn3037IuqCX8ugLziwCogZazTXBtC6MpCapxImAJTQ9lulYDq9e97tNlXQvA7B1M44BI+0vTvrfMA+sEU2KxYU0GktxsHv6AWNVS X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(136003)(376002)(396003)(346002)(451199021)(40470700004)(46966006)(36840700001)(40460700003)(6916009)(54906003)(70586007)(4326008)(316002)(70206006)(478600001)(36756003)(86362001)(426003)(47076005)(6666004)(336012)(107886003)(83380400001)(1076003)(186003)(2616005)(2906002)(82310400005)(5660300002)(30864003)(8936002)(7636003)(26005)(356005)(82740400003)(8676002)(36860700001)(41300700001)(40480700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2023 11:17:33.3993 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 53f36e06-6952-4e4c-8b3a-08db6291cc02 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF0000150B.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5877 Cc: elibr@nvidia.com, simon.horman@corigine.com, roniba@nvidia.com, i.maximets@ovn.org, konguyen@redhat.com, majd@nvidia.com, maord@nvidia.com Subject: [ovs-dev] [PATCH v27 4/8] netdev-offload-tc: Add sample offload API for TC X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Chris Mi via dev From: Chris Mi Reply-To: Chris Mi Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Initialize psample socket. Add sample recv API to receive sampled packets from psample socket. Add sample recv wait API to add psample socket fd to poll list. Signed-off-by: Chris Mi Reviewed-by: Roi Dayan Acked-by: Eelco Chaudron --- lib/dpif.h | 6 +- lib/flow.h | 2 +- lib/netdev-offload-provider.h | 30 ++++++ lib/netdev-offload-tc.c | 172 ++++++++++++++++++++++++++++++++++ lib/netdev-offload.c | 3 +- lib/packets.h | 2 +- 6 files changed, 210 insertions(+), 5 deletions(-) diff --git a/lib/dpif.h b/lib/dpif.h index 129cbf6a1..f91295862 100644 --- a/lib/dpif.h +++ b/lib/dpif.h @@ -834,8 +834,10 @@ struct dpif_upcall { /* DPIF_UC_ACTION only. */ struct nlattr *userdata; /* Argument to OVS_ACTION_ATTR_USERSPACE. */ - struct nlattr *out_tun_key; /* Output tunnel key. */ - struct nlattr *actions; /* Argument to OVS_ACTION_ATTR_USERSPACE. */ + struct nlattr *out_tun_key; /* Output tunnel key. */ + struct nlattr *actions; /* Argument to OVS_ACTION_ATTR_USERSPACE. */ + struct flow flow; /* Caller provided 'flow' if the 'key' is not + available. */ }; /* A callback to notify higher layer of dpif about to be purged, so that diff --git a/lib/flow.h b/lib/flow.h index a9d026e1c..0974bfd42 100644 --- a/lib/flow.h +++ b/lib/flow.h @@ -970,7 +970,7 @@ pkt_metadata_from_flow(struct pkt_metadata *md, const struct flow *flow) md->recirc_id = flow->recirc_id; md->dp_hash = flow->dp_hash; - flow_tnl_copy__(&md->tunnel, &flow->tunnel); + flow_tnl_copy(&md->tunnel, &flow->tunnel); md->skb_priority = flow->skb_priority; md->pkt_mark = flow->pkt_mark; md->in_port = flow->in_port; diff --git a/lib/netdev-offload-provider.h b/lib/netdev-offload-provider.h index 9108856d1..a457556e5 100644 --- a/lib/netdev-offload-provider.h +++ b/lib/netdev-offload-provider.h @@ -28,6 +28,8 @@ extern "C" { #endif +struct dpif_upcall; + struct netdev_flow_api { char *type; /* Flush all offloaded flows from a netdev. @@ -121,6 +123,34 @@ struct netdev_flow_api { int (*meter_del)(ofproto_meter_id meter_id, struct ofputil_meter_stats *stats); + /* Polls for upcall offload packets for an upcall handler. If successful, + * stores the upcall into '*upcall', using 'buf' for storage. + * + * The implementation should point 'upcall->flow' and 'upcall->userdata' + * (if any) into data in the caller-provided 'buf'. The implementation may + * also use 'buf' for storing the data of 'upcall->packet'. If necessary + * to make room, the implementation may reallocate the data in 'buf'. + * + * The caller owns the data of 'upcall->packet' and may modify it. If + * packet's headroom is exhausted as it is manipulated, 'upcall->packet' + * will be reallocated. This requires the data of 'upcall->packet' to be + * released with ofpbuf_uninit() before 'upcall' is destroyed. However, + * when an error is returned, the 'upcall->packet' may be uninitialized + * and should not be released. + * + * This function must not block. If no upcall is pending when it is + * called, it should return EAGAIN without blocking. + * + * Return 0 if successful, otherwise returns a positive errno value. + */ + int (*recv)(struct dpif_upcall *upcall, struct ofpbuf *buf, + uint32_t handler_id); + + /* Arranges for the poll loop for an upcall handler to wake up when + * sample socket has a message queued to be received with the recv + * member functions. */ + void (*recv_wait)(uint32_t handler_id); + /* Initializies the netdev flow api. * Return 0 if successful, otherwise returns a positive errno value. */ int (*init_flow_api)(struct netdev *); diff --git a/lib/netdev-offload-tc.c b/lib/netdev-offload-tc.c index 79bc3225a..d2fe7489a 100644 --- a/lib/netdev-offload-tc.c +++ b/lib/netdev-offload-tc.c @@ -18,6 +18,8 @@ #include #include +#include +#include #include "cmap.h" #include "dpif-provider.h" @@ -127,6 +129,9 @@ struct sgid_node { struct offload_sample sample; }; +static struct nl_sock *psample_sock; +static int psample_family; + /* The sgid_map mutex protects the sample_group_ids and the sgid_map for * cmap_insert(), cmap_remove(), or cmap_replace() operations. */ static struct ovs_mutex sgid_lock = OVS_MUTEX_INITIALIZER; @@ -158,6 +163,14 @@ sgid_find(uint32_t id) return node ? CONTAINER_OF(node, struct sgid_node, id_node) : NULL; } +static struct offload_sample * +sample_find(uint32_t id) +{ + struct sgid_node *node = sgid_find(id); + + return node ? &node->sample: NULL; +} + static void offload_sample_clone(struct offload_sample *dst, const struct offload_sample *src, @@ -2959,6 +2972,55 @@ tc_cleanup_policer_actions(struct id_pool *police_ids, hmap_destroy(&map); } +static void +psample_init(void) +{ + unsigned int psample_mcgroup; + int err; + + if (!netdev_is_flow_api_enabled()) { + VLOG_DBG("Flow API is not enabled"); + return; + } + + if (psample_sock) { + VLOG_DBG("Psample socket is already initialized"); + return; + } + + err = nl_lookup_genl_family(PSAMPLE_GENL_NAME, + &psample_family); + if (err) { + VLOG_INFO("Generic Netlink family '%s' does not exist: %s\n" + "Please make sure the kernel module psample is loaded", + PSAMPLE_GENL_NAME, ovs_strerror(err)); + return; + } + + err = nl_lookup_genl_mcgroup(PSAMPLE_GENL_NAME, + PSAMPLE_NL_MCGRP_SAMPLE_NAME, + &psample_mcgroup); + if (err) { + VLOG_INFO("Failed to join Netlink multicast group '%s': %s", + PSAMPLE_NL_MCGRP_SAMPLE_NAME, ovs_strerror(err)); + return; + } + + err = nl_sock_create(NETLINK_GENERIC, &psample_sock); + if (err) { + VLOG_INFO("Failed to create psample socket: %s", ovs_strerror(err)); + return; + } + + err = nl_sock_join_mcgroup(psample_sock, psample_mcgroup); + if (err) { + VLOG_INFO("Failed to join psample mcgroup: %s", ovs_strerror(err)); + nl_sock_destroy(psample_sock); + psample_sock = NULL; + return; + } +} + static int netdev_tc_init_flow_api(struct netdev *netdev) { @@ -3018,6 +3080,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); } @@ -3235,6 +3298,113 @@ meter_tc_del_policer(ofproto_meter_id meter_id, return err; } +struct offload_psample { + struct nlattr *packet; /* Packet data. */ + uint32_t group_id; /* Mapping id for sample offload. */ +}; + +static int +nl_parse_psample(struct offload_psample *psample, struct ofpbuf *buf) +{ + static const struct nl_policy ovs_psample_policy[] = { + [PSAMPLE_ATTR_SAMPLE_GROUP] = { .type = NL_A_U32 }, + [PSAMPLE_ATTR_DATA] = { .type = NL_A_UNSPEC }, + }; + struct nlattr *a[ARRAY_SIZE(ovs_psample_policy)]; + struct genlmsghdr *genl; + struct nlmsghdr *nlmsg; + struct ofpbuf b; + + b = ofpbuf_const_initializer(buf->data, buf->size); + nlmsg = ofpbuf_try_pull(&b, sizeof *nlmsg); + genl = ofpbuf_try_pull(&b, sizeof *genl); + if (!nlmsg || !genl || nlmsg->nlmsg_type != psample_family + || !nl_policy_parse(&b, 0, ovs_psample_policy, a, + ARRAY_SIZE(ovs_psample_policy))) { + return EINVAL; + } + + psample->group_id = nl_attr_get_u32(a[PSAMPLE_ATTR_SAMPLE_GROUP]); + psample->packet = a[PSAMPLE_ATTR_DATA]; + + return 0; +} + +static int +psample_parse_packet(struct offload_psample *psample, + struct dpif_upcall *upcall) +{ + struct flow *flow = &upcall->flow; + struct offload_sample *sample; + + memset(upcall, 0, sizeof *upcall); + dp_packet_use_const(&upcall->packet, + nl_attr_get(psample->packet), + nl_attr_get_size(psample->packet)); + + sample = sample_find(psample->group_id); + if (!sample) { + VLOG_ERR_RL(&error_rl, "Failed to get sample info via group id: %d", + psample->group_id); + return ENOENT; + } + + upcall->userdata = sample->userdata; + if (sample->tunnel) { + flow_tnl_copy(&flow->tunnel, sample->tunnel); + } + if (sample->userspace_actions) { + upcall->actions = sample->userspace_actions; + } + flow->in_port.odp_port = netdev_ifindex_to_odp_port(sample->ifindex); + upcall->type = DPIF_UC_ACTION; + + return 0; +} + +static int +netdev_tc_recv(struct dpif_upcall *upcall, struct ofpbuf *buf, + uint32_t handler_id) +{ + int read_tries = 0; + + if (handler_id || !psample_sock) { + return EAGAIN; + } + + for (;;) { + struct offload_psample psample; + int error; + + if (++read_tries > 50) { + return EAGAIN; + } + + error = nl_sock_recv(psample_sock, buf, NULL, false); + if (error == ENOBUFS) { + continue; + } + if (error) { + return error; + } + error = nl_parse_psample(&psample, buf); + + return error ? error : psample_parse_packet(&psample, upcall); + } + + return EAGAIN; +} + +static void +netdev_tc_recv_wait(uint32_t handler_id) +{ + /* For simplicity, i.e., using a single NetLink socket, only the first + * handler thread will be used. */ + if (!handler_id && psample_sock) { + nl_sock_wait(psample_sock, POLLIN); + } +} + const struct netdev_flow_api netdev_offload_tc = { .type = "linux_tc", .flow_flush = netdev_tc_flow_flush, @@ -3248,5 +3418,7 @@ const struct netdev_flow_api netdev_offload_tc = { .meter_set = meter_tc_set_policer, .meter_get = meter_tc_get_policer, .meter_del = meter_tc_del_policer, + .recv = netdev_tc_recv, + .recv_wait = netdev_tc_recv_wait, .init_flow_api = netdev_tc_init_flow_api, }; diff --git a/lib/netdev-offload.c b/lib/netdev-offload.c index a5fa62487..403315deb 100644 --- a/lib/netdev-offload.c +++ b/lib/netdev-offload.c @@ -38,6 +38,7 @@ #include "netdev-provider.h" #include "netdev-vport.h" #include "odp-netlink.h" +#include "odp-util.h" #include "openflow/openflow.h" #include "packets.h" #include "openvswitch/ofp-print.h" @@ -826,7 +827,7 @@ odp_port_t netdev_ifindex_to_odp_port(int ifindex) { struct port_to_netdev_data *data; - odp_port_t ret = 0; + odp_port_t ret = ODPP_NONE; ovs_rwlock_rdlock(&ifindex_to_port_rwlock); HMAP_FOR_EACH_WITH_HASH (data, ifindex_node, ifindex, &ifindex_to_port) { diff --git a/lib/packets.h b/lib/packets.h index ac4c28e47..f49c3822f 100644 --- a/lib/packets.h +++ b/lib/packets.h @@ -86,7 +86,7 @@ flow_tnl_size(const struct flow_tnl *src) * data in 'dst' is NOT cleared, so this must not be used in cases where the * uninitialized portion may be hashed over. */ static inline void -flow_tnl_copy__(struct flow_tnl *dst, const struct flow_tnl *src) +flow_tnl_copy(struct flow_tnl *dst, const struct flow_tnl *src) { memcpy(dst, src, flow_tnl_size(src)); } From patchwork Thu Jun 1 11:16:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Mi X-Patchwork-Id: 1788991 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=K7v/3Rlh; dkim-atps=neutral Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QX3X23mBCz20QB for ; Thu, 1 Jun 2023 21:17:54 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 684FA6152A; Thu, 1 Jun 2023 11:17:52 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 684FA6152A 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=K7v/3Rlh 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 hSIukGt-gjNr; Thu, 1 Jun 2023 11:17:49 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp3.osuosl.org (Postfix) with ESMTPS id D9EBA61544; Thu, 1 Jun 2023 11:17:47 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org D9EBA61544 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 963F8C008A; Thu, 1 Jun 2023 11:17:46 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 07D26C0090 for ; Thu, 1 Jun 2023 11:17:46 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 04F47841F2 for ; Thu, 1 Jun 2023 11:17:43 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 04F47841F2 Authentication-Results: smtp1.osuosl.org; dkim=pass (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=K7v/3Rlh 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 5PldDxzwUVDB for ; Thu, 1 Jun 2023 11:17:41 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 88D6184212 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on20607.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8d::607]) by smtp1.osuosl.org (Postfix) with ESMTPS id 88D6184212 for ; Thu, 1 Jun 2023 11:17:41 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F1Mhi8TB5EalDnYuerBY5MHTV0Chp95/Xk0MY5+BUoWXrMubH1Kl6WFmDtLUxqla48pgdcrz2CI2Nh2YeapCDoCKoH5amqc9Tdjo9RObfPa7NarCtKoU5MvAnB2X8qB3b1FZUqyo2MXDLYWNWczLKFHnQu6Z0QQqyttE1AE5xWVWk+4fTib3stOItxMbM25JGo9KStUbUX91lz9ppYY3amqNpaO+kg8kw5+IDF5lc4OzMbeVc7NVSfBcrUTBqzLibOZhQelJqrK1TM0KKuZAP21ife8w4ik1O6CS8Uohdwxbjnz8cZkmNM4slpOkoqg43baHgTxAAbnLfQiTTDiUIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=W3JePJ2Q1Kr555lx19NCLnnoBck/NdcKUeMJzs2Da84=; b=VfQRN/Nn0/+KMk+w9cM0voEiR33hJsWzBsGKDKNJzxuGXzNk0GoGoRYqHy5pXOQJurZx3/dNGJxfL5i9jKlWutLOl88k+beRk3qddNrv4vGFUEqcL+47vj6yqUH4biWf4LEdnxU6AmMGq3h7+8Z/YkYNylYK4Rik2/8KZTlrZFJWct3maRx9wTQgYU4iVQIvIOYzVkBg6FJXXVCibPfRfxxCpMXd6DlV2kFsPQlSloRZS34Z/F5fsf74HtejkkqMp4uzq+Nq+KLmYk3PwGK/D8/iSHBjbmzmqEaT1blTELE4VwxLxVw2prKRYNhDzPBxBYbG8BHtV4k4hzvjSd0jKQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=openvswitch.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=W3JePJ2Q1Kr555lx19NCLnnoBck/NdcKUeMJzs2Da84=; b=K7v/3RlhC2IW9otU1kp65Gqg5l0jgZS+2OHZfLZNsQ3GqdTleQmNp6/2pvV2+ok4YBeiUOqWB04SP9VD2UfHl/6jTUNJEHag060qHOjjZxy9L5DDkXNpm7JX2jPkCyg8wk6C19Vy+RVteaDrAH5kKWAzUHThx1fKRkFOOlmu53d0cXwmxEsi7zpgAxthHzjuuheMyiedi4pWWSKiryWCsdXwykGlucWhvfqC4gw9Bx7OduqyYNbIS8ICWr5KpImNjgIR4qP1De583vABlbvmJcFHC8wJhAk3z8pG69IF3xWpA0AXa8m8QbBBZ6E6aVpR2gFE29rItjaDIBojzO4MHQ== Received: from SN7P220CA0003.NAMP220.PROD.OUTLOOK.COM (2603:10b6:806:123::8) by DM6PR12MB5520.namprd12.prod.outlook.com (2603:10b6:5:208::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.24; Thu, 1 Jun 2023 11:17:37 +0000 Received: from SA2PEPF00001508.namprd04.prod.outlook.com (2603:10b6:806:123:cafe::ea) by SN7P220CA0003.outlook.office365.com (2603:10b6:806:123::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.23 via Frontend Transport; Thu, 1 Jun 2023 11:17:37 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by SA2PEPF00001508.mail.protection.outlook.com (10.167.242.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.18 via Frontend Transport; Thu, 1 Jun 2023 11:17:36 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Thu, 1 Jun 2023 04:17:23 -0700 Received: from rnnvmail201.nvidia.com (10.129.68.8) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Thu, 1 Jun 2023 04:17:23 -0700 Received: from c-237-115-160-163.mtl.labs.mlnx (10.127.8.12) by mail.nvidia.com (10.129.68.8) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Thu, 1 Jun 2023 04:17:20 -0700 To: Date: Thu, 1 Jun 2023 14:16:55 +0300 Message-ID: <20230601111658.113144-6-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230601111658.113144-1-cmi@nvidia.com> References: <20230601111658.113144-1-cmi@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00001508:EE_|DM6PR12MB5520:EE_ X-MS-Office365-Filtering-Correlation-Id: a07959b4-0bce-4c44-800a-08db6291ce00 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3Rb9G6XM62mR+1S+bdfVAtN6rcqdrGAn8UHPqncABYy6v1VzOb+kFr7kxZ7liuilCLlulzhyryfediD8QEcarboR5mj6ludn4e3ET4p6ad7Z2uXnFcMTWxAEBYbx2tzTbwH7n0v2nPHpwM++kq81tb6Sw1kb6fK+zPYyaoccLHf7xko0Qr2tTEY76TS8Lj3cxO2jrn/zUGyOmCgnv4Eb0XPTkrJ7I+GGBn4bmCSat4ZOVv9nQrUxDA9ylq5LQVzUXa5cA4rwHBeTqCWGhgf+5lpyWY8O/xvaPEWQ4vZZAbF1skVIK6iWGVJoaHUzwStbyj6nmN8u4jP2qQD6AElakr45MsUQ9P2DO+YwWHCsCcVcVvPxjOYG/Sq89D5MHRnwMAuig8NAPwGmrTvSnQGfdcA/ZqIXJ1h359J+8MhBhvJnMTCrfXg9pNt2mZVJeuFBqKClfcvpdjMa9k7pY/fnaTSv81lumoflFRQm5ANoTc4Stt+AcMuSz9s3zl+cjqrvsX84HiwCBWzwdvm/8pRpeQ8gBiNH198qRZZR3R53+hquBbwXHMNDzztBprSdTK4VferacvlVnxFIyohj5dklpGOsDunbFVADWUPMByXUz+A71zjW3bvrqHoluocvmBhXgc4AUh6N+WiQF/EsbIFqbQLBWMO7tebPuiS4QOAAyAi/lByp7o9O/fviz092sMtTjDg0fgJTEDZtfdUEnAFhR/U8TojYBAgl10DurQi04e9khgZpgJLd1w7mZS6CH0j4 X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(136003)(396003)(376002)(346002)(39860400002)(451199021)(36840700001)(46966006)(40470700004)(40460700003)(478600001)(36860700001)(6666004)(336012)(186003)(36756003)(426003)(47076005)(86362001)(2616005)(82310400005)(7636003)(40480700001)(356005)(26005)(82740400003)(1076003)(107886003)(316002)(41300700001)(4326008)(70586007)(70206006)(6916009)(8676002)(5660300002)(2906002)(54906003)(8936002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2023 11:17:36.7570 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a07959b4-0bce-4c44-800a-08db6291ce00 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00001508.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB5520 Cc: elibr@nvidia.com, simon.horman@corigine.com, roniba@nvidia.com, i.maximets@ovn.org, konguyen@redhat.com, majd@nvidia.com, maord@nvidia.com Subject: [ovs-dev] [PATCH v27 5/8] netdev-offload: Add netdev offload recv and recv_wait APIs X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Chris Mi via dev From: Chris Mi Reply-To: Chris Mi Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Iterate each registered offload API. It's not a problem for today since we only have one implementation. Signed-off-by: Chris Mi Reviewed-by: Roi Dayan Acked-by: Eelco Chaudron --- lib/netdev-offload.c | 38 ++++++++++++++++++++++++++++++++++++++ lib/netdev-offload.h | 5 +++++ 2 files changed, 43 insertions(+) diff --git a/lib/netdev-offload.c b/lib/netdev-offload.c index 403315deb..1374aa8ac 100644 --- a/lib/netdev-offload.c +++ b/lib/netdev-offload.c @@ -257,6 +257,44 @@ meter_offload_del(ofproto_meter_id meter_id, struct ofputil_meter_stats *stats) return 0; } +int +netdev_offload_recv(struct dpif_upcall *upcall, struct ofpbuf *buf, + uint32_t handler_id) +{ + struct netdev_registered_flow_api *rfa; + int ret = EAGAIN; + + CMAP_FOR_EACH (rfa, cmap_node, &netdev_flow_apis) { + if (rfa->flow_api->recv) { + ret = rfa->flow_api->recv(upcall, buf, handler_id); + if (!ret) { + return 0; + } + + if (ret == EAGAIN) { + VLOG_DBG_RL(&rl, "Failed to receive offload packet, %s, " + "type: %s", ovs_strerror(ret), + rfa->flow_api->type); + } + } else { + ret = EAGAIN; + } + } + return ret; +} + +void +netdev_offload_recv_wait(uint32_t handler_id) +{ + struct netdev_registered_flow_api *rfa; + + CMAP_FOR_EACH (rfa, cmap_node, &netdev_flow_apis) { + if (rfa->flow_api->recv_wait) { + rfa->flow_api->recv_wait(handler_id); + } + } +} + int netdev_flow_flush(struct netdev *netdev) { diff --git a/lib/netdev-offload.h b/lib/netdev-offload.h index 47f8e6f48..d71e98418 100644 --- a/lib/netdev-offload.h +++ b/lib/netdev-offload.h @@ -33,6 +33,7 @@ extern "C" { struct dp_packet_batch; struct dp_packet; +struct dpif_upcall; struct netdev_class; struct netdev_rxq; struct netdev_saved_flags; @@ -162,6 +163,10 @@ void meter_offload_set(ofproto_meter_id, struct ofputil_meter_config *); int meter_offload_get(ofproto_meter_id, struct ofputil_meter_stats *); int meter_offload_del(ofproto_meter_id, struct ofputil_meter_stats *); +int netdev_offload_recv(struct dpif_upcall *upcall, struct ofpbuf *buf, + uint32_t handler_id); +void netdev_offload_recv_wait(uint32_t handler_id); + #ifdef __cplusplus } #endif From patchwork Thu Jun 1 11:16:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Mi X-Patchwork-Id: 1788992 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=gCMRKZYO; 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 4QX3X44yfzz20QB for ; Thu, 1 Jun 2023 21:17:56 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id A95DD84291; Thu, 1 Jun 2023 11:17:54 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org A95DD84291 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=gCMRKZYO 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 P5NOsHJeu9BX; Thu, 1 Jun 2023 11:17:52 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 6A50B8423C; Thu, 1 Jun 2023 11:17:50 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 6A50B8423C Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 3267AC007A; Thu, 1 Jun 2023 11:17:50 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 26AF3C0088 for ; Thu, 1 Jun 2023 11:17:49 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 771C1416F0 for ; Thu, 1 Jun 2023 11:17:45 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 771C1416F0 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=gCMRKZYO 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 tqEp0ToOQszS for ; Thu, 1 Jun 2023 11:17:43 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org B5CF7416C7 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on20625.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eab::625]) by smtp2.osuosl.org (Postfix) with ESMTPS id B5CF7416C7 for ; Thu, 1 Jun 2023 11:17:43 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=czAHqYiyBFR8+e39lu+3PSuC7wgcl09aqr5qhHESPFm6joy+WA1Hp61Zyb1FCduOSuvcjfjJJuTDYpEw/zTfP1VcIxeudKKf1jK26wWJcDDWQWySIjT1Q/gxdFIvqy2diqDrBPEego0G8l7Ksnzbi8T8LnjAWJ9gnftlWIY7KRMx9AvKZjFUwZ01dgXDwcV63PGmlinXboHKLeXbWCvavvwWM2b8dX9p4H4gugyfIVDNrhl9BP7W1VOnxkJtqAyprVlw4mfQoYAd5QYYnRY0zP3FJ45gdhiNp+9KKHZtzwBwCWxGWcgCnI+fH6J2zrrrZgF6BX+HGR0PetWjpczHVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hlI2SsuK1p2EBr02eQQfH+8+z9nAOu0o7Rbp3Na6dhc=; b=E0GM4nIlccDa+5NTFYZtGT9vQG3/PUZhKQ4i+7gzV2qTi57bTCzrpntvzGRpj9fn1PKrVX526FIfB/dKAbGaOejMfVjWFKYjoZQSs0QY+PMmEs9hwFq6Kz17qGChyosObbhS40mcg10FFMe464iHyvU71nH0+sF8xlHlocPN79gtbqGL5ZTc6WyoK9fIYOjyx3bnsQMDn7rs0fvcPu2d3dIrZly7r5et7tcJZRaGMd2zoH2DiiqDrk7m6o5xJH5NJG8s2twzRYEl8ofm9qSPOWaVy7qo4lJuXppVnqGxo5+zwsZUwDbhBPQrirLDj40pptgEDyjUa796bIX3ynN31Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=openvswitch.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hlI2SsuK1p2EBr02eQQfH+8+z9nAOu0o7Rbp3Na6dhc=; b=gCMRKZYOpI54mOgxNKZR0yiJ9di2BqxncyEZIpz1JjvPSDdEy4SgoovbI9HT+Q7JJnDN4enygPlQgW4L5fGQZGUA6/hVVUo/yhLDqgL92fa0JVtTAIsxRPMoDFqdMHskrVWgDETdt02SkIrwzsQUtRb1LWX91d6OG2e98d+CIYPYyRWmM46BEElRWLFUe9sDuMAJct7mInIQomQOc2859hwh4YQTitguihbvC/j2ELh/2vV4HhH7MDhJdonUKG0myAha08l/hufM+TBmxiPn9fLt8gGKrxwCkky18VXaHt+KYF+B5BKg7QVrMye027oOcKJ4q8pDmJ+Mc4Jg8Uk0Yg== Received: from SN7P220CA0010.NAMP220.PROD.OUTLOOK.COM (2603:10b6:806:123::15) by LV2PR12MB5848.namprd12.prod.outlook.com (2603:10b6:408:173::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.22; Thu, 1 Jun 2023 11:17:40 +0000 Received: from SA2PEPF00001508.namprd04.prod.outlook.com (2603:10b6:806:123:cafe::22) by SN7P220CA0010.outlook.office365.com (2603:10b6:806:123::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.23 via Frontend Transport; Thu, 1 Jun 2023 11:17:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by SA2PEPF00001508.mail.protection.outlook.com (10.167.242.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.18 via Frontend Transport; Thu, 1 Jun 2023 11:17:40 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Thu, 1 Jun 2023 04:17:27 -0700 Received: from rnnvmail201.nvidia.com (10.129.68.8) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Thu, 1 Jun 2023 04:17:26 -0700 Received: from c-237-115-160-163.mtl.labs.mlnx (10.127.8.12) by mail.nvidia.com (10.129.68.8) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Thu, 1 Jun 2023 04:17:24 -0700 To: Date: Thu, 1 Jun 2023 14:16:56 +0300 Message-ID: <20230601111658.113144-7-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230601111658.113144-1-cmi@nvidia.com> References: <20230601111658.113144-1-cmi@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00001508:EE_|LV2PR12MB5848:EE_ X-MS-Office365-Filtering-Correlation-Id: 916a12e0-9ac8-4d49-651d-08db6291d04d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DwlQWoTJUlgeHjiyYZkZMuxuY2S2EXm5HrhKmx6ncucmDZ0Ctwjl9U59EEsIq+V42OU27fTqefocrMz1SI+zCAqzvYQuv5FUXH6RWYbw4p6tdiDlKpu2hv2pUPRQy0YdPhNLDQ0cuqP2ik/6WGxvk6dPIsxYKx/yjZ+okSPEFdo2MBcf6f/pLjH2E+1H7hHd2RD8eZH6fxKyXdoaq/garCrX6HffhGJMLdIK+FJFznPQzne3fhcMGrpsjM+Jfv8VG59Ofm2soEsG7/SktO0miAsE9hbsjn0C+GgdmIfOXicD6t1S+Vh9dIAhYs6Ncg8qF/78vgZm7VMJNr992Wrz8DOPlbpdVwrh/PRwabkzT9Ho3ELOMdnK9+2MP5YGziYj3ezNNu+yozuKGIJzLgOLuE0kKmtAKVOLmrtCNsVvjA2uE3xv8U4sG+QwXyswNiuspqMNd1OINNKGJnfiCjuf6+wS2RQSXGY7aWyt+AWCmdBSls5f0iMawi4oRtbmXnUb62n4EraoM2KzV7EEAmdkZL/2IKvV3VyqiErOAJMVkf1VK78+Eu/YCxW7ZW7Szah9+sj7fGcyv3JZs196bP9UsmoJaF4w9FWgcMvoeO+WB8i7t6Uafkn+2cn1X2QbcnLJXq0RQURICO7ES2XjOxJhgqkSuxjriaqBJLfgIR4idiNUaI30WbeI1Ua9bs0+rRBleaXtC+pIXqTgBKKtEY/UdoMDrUhmCZZG0oBxdulum1sAW11b18gZCvIW5es/a01R X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(136003)(376002)(346002)(396003)(451199021)(36840700001)(40470700004)(46966006)(82310400005)(40460700003)(6666004)(478600001)(36860700001)(26005)(36756003)(47076005)(336012)(83380400001)(186003)(426003)(86362001)(82740400003)(2616005)(107886003)(7636003)(356005)(40480700001)(1076003)(41300700001)(316002)(70586007)(6916009)(70206006)(4326008)(8676002)(5660300002)(2906002)(54906003)(66899021)(8936002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2023 11:17:40.6163 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 916a12e0-9ac8-4d49-651d-08db6291d04d X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00001508.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5848 Cc: elibr@nvidia.com, simon.horman@corigine.com, roniba@nvidia.com, i.maximets@ovn.org, konguyen@redhat.com, majd@nvidia.com, maord@nvidia.com Subject: [ovs-dev] [PATCH v27 6/8] dpif-netlink: Add netdev offload recv in normal recv upcalls X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Chris Mi via dev From: Chris Mi Reply-To: Chris Mi Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" In thread handler 0, add netdev offload recv in normal recv upcalls. To avoid starvation, introduce a flag to alternate the order of receiving normal upcalls and offload upcalls based on that flag. Add similar change for recv_wait. Signed-off-by: Chris Mi Reviewed-by: Roi Dayan Acked-by: Eelco Chaudron --- lib/dpif-netlink.c | 41 ++++++++++++++++++++++++++++++----- ofproto/ofproto-dpif-upcall.c | 15 +++++++++---- 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c index 60bd39643..6e7b644e8 100644 --- a/lib/dpif-netlink.c +++ b/lib/dpif-netlink.c @@ -201,6 +201,11 @@ struct dpif_handler { struct nl_sock *sock; /* Each handler thread holds one netlink socket. */ + /* The receive handler thread deals with both normal and offload receive + * upcalls. To avoid starvation, the below flag is used to alternate the + * processing order. */ + bool recv_offload_first; + #ifdef _WIN32 /* Pool of sockets. */ struct dpif_windows_vport_sock *vport_sock_pool; @@ -3010,7 +3015,6 @@ dpif_netlink_recv_windows(struct dpif_netlink *dpif, uint32_t handler_id, static int dpif_netlink_recv_cpu_dispatch(struct dpif_netlink *dpif, uint32_t handler_id, struct dpif_upcall *upcall, struct ofpbuf *buf) - OVS_REQ_RDLOCK(dpif->upcall_lock) { struct dpif_handler *handler; int read_tries = 0; @@ -3061,7 +3065,6 @@ dpif_netlink_recv_vport_dispatch(struct dpif_netlink *dpif, uint32_t handler_id, struct dpif_upcall *upcall, struct ofpbuf *buf) - OVS_REQ_RDLOCK(dpif->upcall_lock) { struct dpif_handler *handler; int read_tries = 0; @@ -3135,13 +3138,12 @@ dpif_netlink_recv_vport_dispatch(struct dpif_netlink *dpif, #endif static int -dpif_netlink_recv(struct dpif *dpif_, uint32_t handler_id, - struct dpif_upcall *upcall, struct ofpbuf *buf) +dpif_netlink_recv__(struct dpif_netlink *dpif, uint32_t handler_id, + struct dpif_upcall *upcall, struct ofpbuf *buf) + OVS_REQ_RDLOCK(dpif->upcall_lock) { - struct dpif_netlink *dpif = dpif_netlink_cast(dpif_); int error; - fat_rwlock_rdlock(&dpif->upcall_lock); #ifdef _WIN32 error = dpif_netlink_recv_windows(dpif, handler_id, upcall, buf); #else @@ -3152,6 +3154,32 @@ dpif_netlink_recv(struct dpif *dpif_, uint32_t handler_id, handler_id, upcall, buf); } #endif + + return error; +} + +static int +dpif_netlink_recv(struct dpif *dpif_, uint32_t handler_id, + struct dpif_upcall *upcall, struct ofpbuf *buf) +{ + struct dpif_netlink *dpif = dpif_netlink_cast(dpif_); + struct dpif_handler *handler; + int error; + + fat_rwlock_rdlock(&dpif->upcall_lock); + handler = &dpif->handlers[handler_id]; + if (handler->recv_offload_first) { + error = netdev_offload_recv(upcall, buf, handler_id); + if (error == EAGAIN) { + error = dpif_netlink_recv__(dpif, handler_id, upcall, buf); + } + } else { + error = dpif_netlink_recv__(dpif, handler_id, upcall, buf); + if (error == EAGAIN) { + error = netdev_offload_recv(upcall, buf, handler_id); + } + } + handler->recv_offload_first = !handler->recv_offload_first; fat_rwlock_unlock(&dpif->upcall_lock); return error; @@ -3217,6 +3245,7 @@ dpif_netlink_recv_wait(struct dpif *dpif_, uint32_t handler_id) dpif_netlink_recv_wait_vport_dispatch(dpif, handler_id); } #endif + netdev_offload_recv_wait(handler_id); fat_rwlock_unlock(&dpif->upcall_lock); } diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c index 04b583f81..c1fad9a8f 100644 --- a/ofproto/ofproto-dpif-upcall.c +++ b/ofproto/ofproto-dpif-upcall.c @@ -855,10 +855,17 @@ recv_upcalls(struct handler *handler) break; } - upcall->fitness = odp_flow_key_to_flow(dupcall->key, dupcall->key_len, - flow, NULL); - if (upcall->fitness == ODP_FIT_ERROR) { - goto free_dupcall; + /* If key and key_len are available, use them to construct flow. + * Otherwise, use upcall->flow. */ + if (dupcall->key && dupcall->key_len) { + upcall->fitness = odp_flow_key_to_flow(dupcall->key, + dupcall->key_len, + flow, NULL); + if (upcall->fitness == ODP_FIT_ERROR) { + goto free_dupcall; + } + } else { + flow = &dupcall->flow; } if (dupcall->mru) { From patchwork Thu Jun 1 11:16:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Mi X-Patchwork-Id: 1788993 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=HjqtrPED; 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 4QX3XV4834z20QB for ; Thu, 1 Jun 2023 21:18:18 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 45E8484223; Thu, 1 Jun 2023 11:18:16 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 45E8484223 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=HjqtrPED 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 fkbiPGg6Fdxe; Thu, 1 Jun 2023 11:18:13 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 9B56A84299; Thu, 1 Jun 2023 11:18:03 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 9B56A84299 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4BA7AC007A; Thu, 1 Jun 2023 11:18:03 +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 26322C0087 for ; Thu, 1 Jun 2023 11:18:02 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 7438261544 for ; Thu, 1 Jun 2023 11:17:53 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 7438261544 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=HjqtrPED 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 1Kbv-J3XKmAU for ; Thu, 1 Jun 2023 11:17:50 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 2EE306155D Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on20620.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e89::620]) by smtp3.osuosl.org (Postfix) with ESMTPS id 2EE306155D for ; Thu, 1 Jun 2023 11:17:50 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ei6DDdysVgn1LHbi70jk3Dt8DiXQ4e8J/0n1ipKGY3dE2kMxtnx9ZKO87BUYhWeufjwjATmNBBZ4wF5RsQeYwfgFfHj5rpk7sJaaJJZr/V4Iyf80Ax9k3Q9tSsed+U/brKJYkJax/1XB2xqLxqQfvvmHI3dd6eBcTMcL3c9S+T75XnqehJVVjF4BwyF1rGX84Qj3SEHFm+JXhXWQAKw1BjTfZYdyNvhmcROVoKcTxQt0gPBQWmRGigWKGOEEWsX+Ol/JPNeC+XwZLCddCJksY0Vun4ifR38v7yMFxjYO/DY7kwZ1SJIzQJXt20Kfva+Ccm1GNOMgISqQkDeFzOtFQw== 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=nRo2rYAT8fKuK+F9Z+dW8UVdtGpYwxrPKzsHPHYD3r8=; b=dvMOCtgOTh1GRee4F2Pybiz3vxYKBMM0EDcq5jDgahXHP2NKmr13ErAM+rdTPWbYzks+fRoYASiSU1aJeUqoj6enw+dN5Q6zGkP2GV5aDQDckQ9rA0HzxXwstEFN0FcWYa+iCzbub2qEUSPqgYpej9FFKFb5xYqv7n4mkkYzZuyLTP9ZdPjkIfOuiYFx/D2qr1R7+zLelyXor4eWnXO95HN3gFIrQSbYrZrP6/FsRo9IIU2+3CXiC5roSpTBEeqkkS9zOWFHToCEJM8clM9UT8Z6e0Ytf2OoU3WgeEsfsa8wWxOKfrfHFMknYYWA7jQMsph+Gz5qhx6ylu8KHoEuNA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=openvswitch.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nRo2rYAT8fKuK+F9Z+dW8UVdtGpYwxrPKzsHPHYD3r8=; b=HjqtrPEDnDuEMajEpZKOKQv3tY4nuKk5U9lFw+SEW/THpOsWEhNtgoJyN5Uj2AL+blq8RxHVoTMCt7a5BjfsdJ2xoOYsWh3qhhAQsnr2oxRtq+8Lai9q3K6lRflqBu4Wwi/V5rw7gmSUB1AdsrXNmEsUqgXKNukdqWfcb9WfKOcOME0KN8XR/IqpcgBp1jhbzQVZTL2ykfPqRPu0sb0vuUJmxOiskT7gC1DQw1hO+flfw482q5Zhdvfi3rSfenQfGW1ZTVhvdWQlAiIlj2eHkzfwFi6h0uH23pORlpDsgqaNnLZKQDE/scXlZu6BFIdxmLAK87ZrepNTbCQZdM3p5Q== Received: from DM6PR03CA0055.namprd03.prod.outlook.com (2603:10b6:5:100::32) by MW6PR12MB8913.namprd12.prod.outlook.com (2603:10b6:303:247::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23; Thu, 1 Jun 2023 11:17:47 +0000 Received: from CO1PEPF000044F7.namprd21.prod.outlook.com (2603:10b6:5:100:cafe::80) by DM6PR03CA0055.outlook.office365.com (2603:10b6:5:100::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.24 via Frontend Transport; Thu, 1 Jun 2023 11:17:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CO1PEPF000044F7.mail.protection.outlook.com (10.167.241.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.3 via Frontend Transport; Thu, 1 Jun 2023 11:17:46 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Thu, 1 Jun 2023 04:17:31 -0700 Received: from rnnvmail201.nvidia.com (10.129.68.8) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Thu, 1 Jun 2023 04:17:30 -0700 Received: from c-237-115-160-163.mtl.labs.mlnx (10.127.8.12) by mail.nvidia.com (10.129.68.8) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Thu, 1 Jun 2023 04:17:27 -0700 To: Date: Thu, 1 Jun 2023 14:16:57 +0300 Message-ID: <20230601111658.113144-8-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230601111658.113144-1-cmi@nvidia.com> References: <20230601111658.113144-1-cmi@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F7:EE_|MW6PR12MB8913:EE_ X-MS-Office365-Filtering-Correlation-Id: cda384e4-9068-4122-e7c8-08db6291d3e4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BQop18DiEJjbavZ/JMoQeSMZT1pjHXdLevRBsNfM36g55dBoy6TVRHet1eyt9S9qI8/TEl9FmL8MY4O0YT3Sc9E38K9iq8DnOmEjln20amh2DlHR5OQ1xpeqnx610quj3AFlG3rTzv83LyEkVtBRSjhGCTJrz1/++skQkbDTa06ONGAYdAK+fpZUmVlACrQHeHJ064KpIfzsL21ARL2/YcU6sTitl8UhhVApZWqAzHBOKNtrgLOuwQFuOpQ3YkueURN3sktSsxrsQXqoeSlUpR7mCO1XgU/wYAE4SV/V6YiogO0TkAUwtcQRKXO3/nhtU77cFgE24gTAfYJAI+XJ3Ggwz5rOO+D4Ylq8ki/liAQ73a3qXfeYWS7xxKcLWhZHDa8o4sDYUf7c71cDiKcJNy5UpFwV6HukizOxNXjHxQrWKK8uL7pVo8WH90Pwh1KCinJRU3S+5N/K2DWm0QXgkxeF7OFyv4JUgMpxkfQ1fXbbOLF9OXhCI98kblClEmMDZONhssh74m0qpVR+WfyBKhpVHSQ8wOdSZXhLNOljG2DLuTkIsFYdPQCa+GXmWsVT0z4J9ByGqjk5l8dJ89sdOs8DKtEhAZG1Clutf8zxxgjri11rkCb9KT11h+QUl8r3zD4yexheyTJQBZK3/JT+ENvGeAA9Q+fIjCQgs0nDXIqX0yFSIsDsH9e4UdkvoTy+69pPPvS69QNi83bNS8EipUrrvjsO4s4WpAbgbvULBrA= X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(376002)(346002)(39860400002)(136003)(396003)(451199021)(40470700004)(46966006)(36840700001)(36756003)(86362001)(316002)(6916009)(4326008)(478600001)(54906003)(70206006)(107886003)(70586007)(6666004)(40480700001)(82310400005)(41300700001)(8676002)(5660300002)(8936002)(30864003)(2906002)(7636003)(82740400003)(356005)(186003)(2616005)(26005)(1076003)(426003)(47076005)(36860700001)(83380400001)(336012)(40460700003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2023 11:17:46.6268 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cda384e4-9068-4122-e7c8-08db6291d3e4 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F7.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR12MB8913 Cc: elibr@nvidia.com, simon.horman@corigine.com, roniba@nvidia.com, i.maximets@ovn.org, konguyen@redhat.com, majd@nvidia.com, maord@nvidia.com Subject: [ovs-dev] [PATCH v27 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 | 288 ++++++++++++++++++++++++++++++++++++---- lib/tc.c | 63 ++++++++- lib/tc.h | 6 + 3 files changed, 331 insertions(+), 26 deletions(-) diff --git a/lib/netdev-offload-tc.c b/lib/netdev-offload-tc.c index d2fe7489a..fbe29d08d 100644 --- a/lib/netdev-offload-tc.c +++ b/lib/netdev-offload-tc.c @@ -95,6 +95,7 @@ static int police_idx_lookup(uint32_t police_idx, uint32_t *meter_id); static int netdev_tc_parse_nl_actions(struct netdev *netdev, struct tc_flower *flower, struct offload_info *info, + const struct flow_tnl *tnl, const struct nlattr *actions, size_t actions_len, bool *recirc_act, bool more_actions, @@ -138,6 +139,12 @@ static struct ovs_mutex sgid_lock = OVS_MUTEX_INITIALIZER; static struct cmap sgid_map = CMAP_INITIALIZER; static struct id_pool *sample_group_ids OVS_GUARDED_BY(sgid_lock); +static bool +psample_supported(void) +{ + return psample_sock != NULL; +} + static void sgid_node_free(struct sgid_node *node) { @@ -240,6 +247,30 @@ sgid_free(uint32_t id) } } +static void free_all_flower_sgids(struct tc_flower *flower) +{ + const struct tc_action *action = flower->actions; + + for (int i = 0; i < flower->action_count; i++, action++) { + if (action->type == TC_ACT_SAMPLE) { + sgid_free(action->sample.group_id); + } + } +} + +static unsigned int get_flower_sgid_count(struct tc_flower *flower) +{ + const struct tc_action *action = flower->actions; + unsigned int count = 0; + + for (int i = 0; i < flower->action_count; i++, action++) { + if (action->type == TC_ACT_SAMPLE && action->sample.group_id) { + count++; + } + } + return count; +} + static bool is_internal_port(const char *type) { @@ -374,7 +405,12 @@ del_ufid_tc_mapping_unlocked(const ovs_u128 *ufid) hmap_remove(&ufid_to_tc, &data->ufid_to_tc_node); hmap_remove(&tc_to_ufid, &data->tc_to_ufid_node); netdev_close(data->netdev); - sgid_free(data->sample_group_id[0]); + for (int i = 0; i < MAX_TC_SAMPLES_PER_FLOW; i++) { + if (!data->sample_group_id[i]) { + break; + } + sgid_free(data->sample_group_id[i]); + } free(data); } @@ -430,10 +466,12 @@ del_filter_and_ufid_mapping(struct tcf_id *id, const ovs_u128 *ufid, /* Add ufid entry to ufid_to_tc hashmap. */ static void add_ufid_tc_mapping(struct netdev *netdev, const ovs_u128 *ufid, - struct tcf_id *id, struct dpif_flow_stats *stats) + struct tcf_id *id, struct dpif_flow_stats *stats, + struct tc_flower *flower) { struct ufid_tc_data *new_data = xzalloc(sizeof *new_data); size_t ufid_hash = hash_bytes(ufid, sizeof *ufid, 0); + const struct tc_action *action = flower->actions; size_t tc_hash; tc_hash = hash_int(hash_int(id->prio, id->handle), id->ifindex); @@ -446,6 +484,15 @@ add_ufid_tc_mapping(struct netdev *netdev, const ovs_u128 *ufid, new_data->adjust_stats = *stats; } + for (int i = 0, si = 0; i < flower->action_count; i++, action++) { + if (action->type == TC_ACT_SAMPLE && action->sample.group_id) { + new_data->sample_group_id[si++] = action->sample.group_id; + if (si >= MAX_TC_SAMPLES_PER_FLOW) { + break; + } + } + } + ovs_mutex_lock(&ufid_lock); hmap_insert(&ufid_to_tc, &new_data->ufid_to_tc_node, ufid_hash); hmap_insert(&tc_to_ufid, &new_data->tc_to_ufid_node, tc_hash); @@ -912,6 +959,19 @@ parse_tc_flower_to_actions__(struct tc_flower *flower, struct ofpbuf *buf, action = &flower->actions[i]; switch (action->type) { + case TC_ACT_SAMPLE: { + const struct sgid_node *node; + + node = sgid_find(action->sample.group_id); + if (!node) { + VLOG_WARN("Can't find sample group ID data for ID: %u", + action->sample.group_id); + return ENOENT; + } + nl_msg_put(buf, node->sample.action, + node->sample.action->nla_len); + } + break; case TC_ACT_VLAN_POP: { nl_msg_put_flag(buf, OVS_ACTION_ATTR_POP_VLAN); } @@ -2027,11 +2087,164 @@ parse_match_ct_state_to_flower(struct tc_flower *flower, struct match *match) } } +static int +parse_userspace_attributes(const struct nlattr *actions, + struct offload_sample *sample) +{ + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20); + const struct nlattr *nla; + unsigned int left; + + NL_NESTED_FOR_EACH_UNSAFE (nla, left, actions) { + if (nl_attr_type(nla) == OVS_USERSPACE_ATTR_USERDATA) { + struct user_action_cookie cookie; + + memcpy(&cookie, nl_attr_get_unspec(nla, sizeof cookie), + sizeof cookie); + if (cookie.type == USER_ACTION_COOKIE_SFLOW) { + sample->type = USER_ACTION_COOKIE_SFLOW; + sample->userdata = CONST_CAST(struct nlattr *, nla); + return 0; + } + } + } + + VLOG_DBG_RL(&rl, "Can't offload userspace action other than sFlow"); + return EOPNOTSUPP; +} + +static int +parse_sample_actions_attribute(const struct nlattr *actions, + struct offload_sample *sample) +{ + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20); + const struct nlattr *nla; + unsigned int left; + int err = EINVAL; + + NL_NESTED_FOR_EACH_UNSAFE (nla, left, actions) { + if (nl_attr_type(nla) == OVS_ACTION_ATTR_USERSPACE) { + err = parse_userspace_attributes(nla, sample); + } else { + /* We can't offload other nested actions. */ + VLOG_DBG_RL(&rl, "Can only offload OVS_ACTION_ATTR_USERSPACE" + " attribute"); + return EINVAL; + } + } + + if (err) { + VLOG_ERR_RL(&error_rl, "No OVS_ACTION_ATTR_USERSPACE attribute"); + } + return err; +} + +static void +offload_sample_init(struct offload_sample *sample, + const struct nlattr *next_actions, + size_t next_actions_len, + struct tc_flower *flower, + const struct flow_tnl *tnl) +{ + memset(sample, 0, sizeof *sample); + if (flower->tunnel) { + sample->tunnel = CONST_CAST(struct flow_tnl *, tnl); + } + sample->userspace_actions = CONST_CAST(struct nlattr *, next_actions); + sample->userspace_actions_len = next_actions_len; + sample->ifindex = flower->ifindex; +} + +static int +parse_sample_action(struct tc_flower *flower, struct tc_action *tc_action, + const struct nlattr *next_actions, size_t next_actions_len, + const struct nlattr *sample_action, + const struct flow_tnl *tnl) +{ + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20); + struct offload_sample sample; + const struct nlattr *nla; + unsigned int left; + uint32_t sgid; + int err; + + offload_sample_init(&sample, next_actions, next_actions_len, flower, tnl); + sample.action = CONST_CAST(struct nlattr *, sample_action); + + err = EINVAL; + NL_NESTED_FOR_EACH_UNSAFE (nla, left, sample_action) { + if (nl_attr_type(nla) == OVS_SAMPLE_ATTR_ACTIONS) { + err = parse_sample_actions_attribute(nla, &sample); + if (err) { + break; + } + } else if (nl_attr_type(nla) == OVS_SAMPLE_ATTR_PROBABILITY) { + tc_action->type = TC_ACT_SAMPLE; + tc_action->sample.rate = UINT32_MAX / nl_attr_get_u32(nla); + if (!tc_action->sample.rate) { + break; + } + } else { + break; + } + } + + if (!tc_action->sample.rate || err) { + return EINVAL; + } + + sgid = sgid_alloc(&sample); + if (!sgid) { + VLOG_DBG_RL(&rl, "Failed allocating group id for sample action"); + return ENOENT; + } + tc_action->sample.group_id = sgid; + flower->action_count++; + + return err; +} + +static int +parse_userspace_action(struct tc_flower *flower, struct tc_action *tc_action, + const struct nlattr *next_actions, + size_t next_actions_len, + const struct nlattr *userspace_action, + const struct flow_tnl *tnl) +{ + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20); + struct offload_sample sample; + uint32_t sgid; + int err; + + offload_sample_init(&sample, next_actions, next_actions_len, flower, tnl); + + /* If sampling rate is 1, there is only a sFlow cookie inside of a + * userspace action, but no sample attribute. That means we can + * only offload userspace actions for sFlow. */ + err = parse_userspace_attributes(userspace_action, &sample); + if (err) { + return err; + } + sample.action = (struct nlattr *) userspace_action; + sgid = sgid_alloc(&sample); + if (!sgid) { + VLOG_DBG_RL(&rl, "Failed allocating group id for sample action"); + return ENOENT; + } + tc_action->type = TC_ACT_SAMPLE; + tc_action->sample.group_id = sgid; + tc_action->sample.rate = 1; + flower->action_count++; + + return err; +} static int parse_check_pkt_len_action(struct netdev *netdev, struct tc_flower *flower, - struct offload_info *info, struct tc_action *action, - const struct nlattr *nla, bool last_action, + struct offload_info *info, + const struct flow_tnl *tnl, + struct tc_action *action, const struct nlattr *nla, + bool last_action, struct tc_action **need_jump_update, bool *recirc_act) { @@ -2070,7 +2283,7 @@ parse_check_pkt_len_action(struct netdev *netdev, struct tc_flower *flower, * NOTE: The last_action parameter means that there are no more actions * after the if () then ... else () case. */ nl_actions = a[OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_GREATER]; - err = netdev_tc_parse_nl_actions(netdev, flower, info, + err = netdev_tc_parse_nl_actions(netdev, flower, info, tnl, nl_attr_get(nl_actions), nl_attr_get_size(nl_actions), recirc_act, !last_action, @@ -2086,7 +2299,7 @@ parse_check_pkt_len_action(struct netdev *netdev, struct tc_flower *flower, /* Parse and add the less than action(s). */ nl_actions = a[OVS_CHECK_PKT_LEN_ATTR_ACTIONS_IF_LESS_EQUAL]; - err = netdev_tc_parse_nl_actions(netdev, flower, info, + err = netdev_tc_parse_nl_actions(netdev, flower, info, tnl, nl_attr_get(nl_actions), nl_attr_get_size(nl_actions), recirc_act, !last_action, @@ -2139,6 +2352,7 @@ parse_check_pkt_len_action(struct netdev *netdev, struct tc_flower *flower, static int netdev_tc_parse_nl_actions(struct netdev *netdev, struct tc_flower *flower, struct offload_info *info, + const struct flow_tnl *tnl, const struct nlattr *actions, size_t actions_len, bool *recirc_act, bool more_actions, struct tc_action **need_jump_update) @@ -2268,7 +2482,8 @@ netdev_tc_parse_nl_actions(struct netdev *netdev, struct tc_flower *flower, action->police.index = police_index; flower->action_count++; } else if (nl_attr_type(nla) == OVS_ACTION_ATTR_CHECK_PKT_LEN) { - err = parse_check_pkt_len_action(netdev, flower, info, action, nla, + err = parse_check_pkt_len_action(netdev, flower, info, tnl, + action, nla, nl_attr_len_pad(nla, left) >= left && !more_actions, @@ -2277,14 +2492,28 @@ netdev_tc_parse_nl_actions(struct netdev *netdev, struct tc_flower *flower, if (err) { return err; } - } else if (nl_attr_type(nla) == OVS_ACTION_ATTR_SAMPLE) { - struct offload_sample sample; - uint32_t sgid; - - memset(&sample, 0, sizeof sample); - sgid = sgid_alloc(&sample); - sgid_free(sgid); - return EOPNOTSUPP; + } else if (nl_attr_type(nla) == OVS_ACTION_ATTR_SAMPLE || + nl_attr_type(nla) == OVS_ACTION_ATTR_USERSPACE) { + if (!psample_supported()) { + VLOG_DBG_RL(&rl, "Unsupported put action type: %d, psample is " + "not initialized successfully", nl_attr_type(nla)); + return EOPNOTSUPP; + } + if (get_flower_sgid_count(flower) >= MAX_TC_SAMPLES_PER_FLOW) { + VLOG_ERR_RL(&error_rl, "Only %u TC_SAMPLE action per " + "flow is supported", MAX_TC_SAMPLES_PER_FLOW); + return EOPNOTSUPP; + } + if (nl_attr_type(nla) == OVS_ACTION_ATTR_SAMPLE) { + err = parse_sample_action(flower, action, actions, actions_len, + nla, tnl); + } else { + err = parse_userspace_action(flower, action, actions, + actions_len, nla, tnl); + } + if (err) { + return err; + } } else { VLOG_DBG_RL(&rl, "unsupported put action type: %d", nl_attr_type(nla)); @@ -2324,6 +2553,7 @@ netdev_tc_flow_put(struct netdev *netdev, struct match *match, } memset(&flower, 0, sizeof flower); + flower.ifindex = ifindex; chain = key->recirc_id; mask->recirc_id = 0; @@ -2589,16 +2819,17 @@ netdev_tc_flow_put(struct netdev *netdev, struct match *match, } /* Parse all (nested) actions. */ - err = netdev_tc_parse_nl_actions(netdev, &flower, info, + err = netdev_tc_parse_nl_actions(netdev, &flower, info, tnl, actions, actions_len, &recirc_act, false, NULL); if (err) { - return err; + goto error_out; } if ((chain || recirc_act) && !info->recirc_id_shared_with_tc) { VLOG_DBG_RL(&rl, "flow_put: recirc_id sharing not supported"); - return EOPNOTSUPP; + err = EOPNOTSUPP; + goto error_out; } memset(&adjust_stats, 0, sizeof adjust_stats); @@ -2612,7 +2843,8 @@ netdev_tc_flow_put(struct netdev *netdev, struct match *match, prio = get_prio_for_tc_flower(&flower); if (prio == 0) { VLOG_ERR_RL(&rl, "couldn't get tc prio: %s", ovs_strerror(ENOSPC)); - return ENOSPC; + err = ENOSPC; + goto error_out; } flower.act_cookie.data = ufid; @@ -2621,14 +2853,20 @@ netdev_tc_flow_put(struct netdev *netdev, struct match *match, block_id = get_block_id_from_netdev(netdev); id = tc_make_tcf_id_chain(ifindex, block_id, chain, prio, hook); err = tc_replace_flower(&id, &flower); - if (!err) { - if (stats) { - memset(stats, 0, sizeof *stats); - netdev_tc_adjust_stats(stats, &adjust_stats); - } - add_ufid_tc_mapping(netdev, ufid, &id, &adjust_stats); + if (err) { + goto error_out; } + if (stats) { + memset(stats, 0, sizeof *stats); + netdev_tc_adjust_stats(stats, &adjust_stats); + } + + add_ufid_tc_mapping(netdev, ufid, &id, &adjust_stats, &flower); + return 0; + +error_out: + free_all_flower_sgids(&flower); return err; } diff --git a/lib/tc.c b/lib/tc.c index 5c32c6f97..28ca6325a 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; @@ -2791,6 +2826,24 @@ nl_msg_put_act_mirred(struct ofpbuf *request, int ifindex, int action, nl_msg_end_nested(request, offset); } +static void +nl_msg_put_act_sample(struct ofpbuf *request, uint32_t rate, uint32_t group_id, + uint32_t action_pc) +{ + size_t offset; + + nl_msg_put_string(request, TCA_ACT_KIND, "sample"); + offset = nl_msg_start_nested(request, TCA_ACT_OPTIONS | NLA_F_NESTED); + { + struct tc_sample parm = { .action = action_pc }; + + nl_msg_put_unspec(request, TCA_SAMPLE_PARMS, &parm, sizeof parm); + nl_msg_put_u32(request, TCA_SAMPLE_RATE, rate); + nl_msg_put_u32(request, TCA_SAMPLE_PSAMPLE_GROUP, group_id); + } + nl_msg_end_nested(request, offset); +} + static inline void nl_msg_put_act_cookie(struct ofpbuf *request, struct tc_cookie *ck) { if (ck->len) { @@ -3103,6 +3156,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++; @@ -3310,6 +3364,13 @@ nl_msg_put_flower_acts(struct ofpbuf *request, struct tc_flower *flower) nl_msg_end_nested(request, act_offset); } break; + case TC_ACT_SAMPLE: { + act_offset = nl_msg_start_nested(request, act_index++); + nl_msg_put_act_sample(request, action->sample.rate, + action->sample.group_id, action_pc); + nl_msg_end_nested(request, act_offset); + } + break; case TC_ACT_OUTPUT: { if (!released && flower->tunnel) { nl_msg_put_flower_acts_release(request, act_index++); diff --git a/lib/tc.h b/lib/tc.h index cdd3b4f60..5f6e15d5c 100644 --- a/lib/tc.h +++ b/lib/tc.h @@ -192,6 +192,7 @@ enum tc_action_type { TC_ACT_CT, TC_ACT_POLICE, TC_ACT_POLICE_MTU, + TC_ACT_SAMPLE, }; enum nat_type { @@ -283,6 +284,10 @@ struct tc_action { uint32_t result_jump; uint16_t mtu; } police; + struct { + uint32_t rate; + uint32_t group_id; + } sample; }; enum tc_action_type type; @@ -380,6 +385,7 @@ struct tc_flower { enum tc_offloaded_state offloaded_state; /* Used to force skip_hw when probing tc features. */ enum tc_offload_policy tc_policy; + uint16_t ifindex; }; int tc_replace_flower(struct tcf_id *id, struct tc_flower *flower); From patchwork Thu Jun 1 11:16:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Mi X-Patchwork-Id: 1788994 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=nhX1h2gF; 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 4QX3Xt4K7gz20QB for ; Thu, 1 Jun 2023 21:18:38 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id AFD2681263; Thu, 1 Jun 2023 11:18:36 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org AFD2681263 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=nhX1h2gF 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 ga9jXJgtPvqw; Thu, 1 Jun 2023 11:18:35 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 97CEF80A5A; Thu, 1 Jun 2023 11:18:32 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 97CEF80A5A Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 5DCDFC007A; Thu, 1 Jun 2023 11:18:32 +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 432D4C007A for ; Thu, 1 Jun 2023 11:18:31 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id CFDBA6158A for ; Thu, 1 Jun 2023 11:18:01 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org CFDBA6158A 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=nhX1h2gF 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 tQ0ztQSIn0kC for ; Thu, 1 Jun 2023 11:17:58 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 4EB896155A Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2062e.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8a::62e]) by smtp3.osuosl.org (Postfix) with ESMTPS id 4EB896155A for ; Thu, 1 Jun 2023 11:17:55 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kfG+bTpHVQ56OUETw+uvaj7KqBucN20+N8LtgGhcgneiFc1L2qdndlndmbLBgtUuddriQ/nV1TpLBYOGQIRgiUsruyeKgXG8SpT3e6uTt42pgtB375pnerUF4LyqAtQJZFqG/mmWShWmZPi2M1a42ZYVrAMvDsN6pdExPtu+0iXQ+c2/ZftE6PlOKFfHa4uAH6hjWGg5C2HZenv9qqOKFKohO6BYrpxaZCR9SMXOBIgzZo/D+FpfCv2c4XcrJK49RIMbpmdsM41WhbMy56F2M0uPqole77ek7z2J8hDHa1F8FG+nWODHA9LQFkkgC5424yPjdQkS1j+plTl4SddRCg== 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=KxFRpxwCyPQBBXoCJW/i5UllhaT/p4G9cOaa0g4A4uQ=; b=SpVUGy5iaUI9ghiCLtfqIzzqIh5ml8NHmdmJLWv7uwQ8guudz3PI3fdm0U9vvYa4nhUaJDH4tcZoBYBfoGR7OF3vU5oYHYbrcK97W1Smcuhher0djKPCU/rFxvNCVOqmtUNQoRjqLAKnqeIK9lfrfHE9jlGkX2KKJURWTEgesRuuMCkMnloLWxJcJh4/FA+QSiOtvmnta2ZHzv9q8F8sIG+LIzEuYRuzWJZ7UIx4cMzBxaNqKgn8hqyrmR+m9kM6uMCE19sHfDxAn5vCSY0YELMWhW7AeVXARtWPcYT74Zs9wJ66XtLM/DGAlcYRN5z3th0YrTnGmxKD9IaLvsYPFg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=openvswitch.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KxFRpxwCyPQBBXoCJW/i5UllhaT/p4G9cOaa0g4A4uQ=; b=nhX1h2gFdhor5dnAdS28ElumL6HWcy5fNCRJtaI9opFyGHI84l+lCX4sEAw2ID6lmmyd8OSAMK0eepv6K50pSaRLrKiikByyJjHQhIiM8EmNjD20R/DCYa0Nd8axoCtKIOzprA3Gyi8rX6tjKoAdD8edo1pUspv7GjRCwo72L8Uf/5wur5tkoLLpn9m55N8AqVTwJ7up9Ixwww1jPhAI39S01UupeKQgw54ysxdXRe4IkIbdQbFPggq7RYyyQcJPW+vK+1PEYRp7n480iM/382CR0cD51m2QNdFK1X/XsJ6IvC58/0GfHP/XYRRm+FXzVM+mSKnlkgjTuuu4aVocag== Received: from DM6PR03CA0055.namprd03.prod.outlook.com (2603:10b6:5:100::32) by IA1PR12MB6603.namprd12.prod.outlook.com (2603:10b6:208:3a1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.22; Thu, 1 Jun 2023 11:17:51 +0000 Received: from CO1PEPF000044F7.namprd21.prod.outlook.com (2603:10b6:5:100:cafe::80) by DM6PR03CA0055.outlook.office365.com (2603:10b6:5:100::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.24 via Frontend Transport; Thu, 1 Jun 2023 11:17:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CO1PEPF000044F7.mail.protection.outlook.com (10.167.241.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.3 via Frontend Transport; Thu, 1 Jun 2023 11:17:51 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Thu, 1 Jun 2023 04:17:34 -0700 Received: from rnnvmail201.nvidia.com (10.129.68.8) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Thu, 1 Jun 2023 04:17:34 -0700 Received: from c-237-115-160-163.mtl.labs.mlnx (10.127.8.12) by mail.nvidia.com (10.129.68.8) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Thu, 1 Jun 2023 04:17:31 -0700 To: Date: Thu, 1 Jun 2023 14:16:58 +0300 Message-ID: <20230601111658.113144-9-cmi@nvidia.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20230601111658.113144-1-cmi@nvidia.com> References: <20230601111658.113144-1-cmi@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F7:EE_|IA1PR12MB6603:EE_ X-MS-Office365-Filtering-Correlation-Id: 74860be8-7b38-4115-b10f-08db6291d6b9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G2ONF6K6IR4nx1GJOPehrqQ0s+vKhwJ3W6t4JCoMOl41B3rXjHtKLPiK8UaqQ8P0gcYM2zUfOuLOXVrcttXx6cxis6IFcfNqZg+05yE/msFYzyuGpP+v16L8SarKsn3xI1dpKeEGwB3CNOAFI+Yvbs9Cp8nFQUTgp7RHLOqpDwzyzYWWoJC0WvkflVUL3yeASFbEP2Vf96KeGhd4RYnaSQGmQfHfXkuoSf/IEwoSvapuchWXcBWBzs0+xXbd7wXP1kuThi32KsyY58AExwTkBA0RfMPTBnGg91j91rNot3zUiBZTk5xAUMMhBooQZnkRDZFt8y1VWSbpn0CmTDjdg0qcIUYxzkHyIEtHmyeiZLtWWEVhKvt+Ms3qIK9EzMRM+BkgeMz4P3QWrh74QuBvlRDmlAQ2L+8E+MiSCAD/I1CyMUM9CoxBqiyqJKwIpNpcvKkO1qh/44v7o+drHE3Bosr8CTtFOdl1G20wenAtm/HJt7vDHF3j6AazSJ2hA0FFrUU8A/yUjwbmvI4VBXlWK7Fj03JJg7dz7rnrPze2m9iFOAI0CNhdYhKoPitckYS7grzs6DXiLt74LyO0vQlnwQ1KlPV63tVGJbyyryx1xYksX24mIayNN7KSqpBxBJtF3r0KCSu6rL37u9f1f3YkOSpjzfPBUjHars6hquHeT06WDAX7nCbyRqwU1E6BBPDMc9MM+NwuaJsX/3qqtSKv7Yh65omr/hYryc54epcHo3IVv9fwg8kLMJU69jDr6C/8 X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(376002)(396003)(136003)(346002)(39860400002)(451199021)(40470700004)(36840700001)(46966006)(6666004)(4326008)(2616005)(6916009)(1076003)(26005)(7636003)(54906003)(70586007)(70206006)(316002)(478600001)(41300700001)(336012)(47076005)(36860700001)(426003)(186003)(107886003)(83380400001)(8676002)(5660300002)(40460700003)(30864003)(2906002)(8936002)(40480700001)(356005)(82740400003)(36756003)(82310400005)(86362001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2023 11:17:51.3768 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 74860be8-7b38-4115-b10f-08db6291d6b9 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F7.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6603 Cc: elibr@nvidia.com, simon.horman@corigine.com, roniba@nvidia.com, i.maximets@ovn.org, konguyen@redhat.com, majd@nvidia.com, maord@nvidia.com Subject: [ovs-dev] [PATCH v27 8/8] system-offloads-traffic.at: Add sFlow offload test cases X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Chris Mi via dev From: Chris Mi Reply-To: Chris Mi Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Add three sFlow offload test cases: 3: offloads - sflow with sampling=1 - offloads enabled ok 4: offloads - sflow with sampling=2 - offloads enabled ok 5: offloads - ping over vxlan tunnel with sflow - offloads enabled ok Signed-off-by: Chris Mi Reviewed-by: Roi Dayan Acked-by: Eelco Chaudron --- Documentation/howto/tc-offload.rst | 24 +++++ tests/system-offloads-traffic.at | 152 +++++++++++++++++++++++++++++ 2 files changed, 176 insertions(+) diff --git a/Documentation/howto/tc-offload.rst b/Documentation/howto/tc-offload.rst index 681dff13e..a50dc3c58 100644 --- a/Documentation/howto/tc-offload.rst +++ b/Documentation/howto/tc-offload.rst @@ -88,6 +88,30 @@ As you can see above the none-offload case reports 140 bytes more, which is 14 bytes per packet. This represents the L2 header, in this case, 2 * *Ethernet address* + *Ethertype*. +Tunnel offload +++++++++++++++ + +Current tunnel offload ignores DF and CSUM flags configuration requested by +the user. TC for now has no way to pass these flags in a flower key and their +masks are set by default. To make tunnel offload work, DF and CSUM flags +are cleared. So please be aware of the following differences. + +Dumping vxlan decap match without offload, it shows:: + + recirc_id(0),tunnel(tun_id=0x4,src=192.168.1.1,dst=192.168.1.2,flags(-df+csum+key)),in_port(vxlan_sys_4789) + +Dumping vxlan decap match with offload, it shows:: + + recirc_id(0),tunnel(tun_id=0x4,src=192.168.1.1,dst=192.168.1.2,tp_dst=4789,flags(+key)),in_port(vxlan_sys_4789) + +Dumping vxlan encap action without offload, it shows:: + + actions:set(tunnel(tun_id=0x4,dst=192.168.1.1,ttl=64,tp_dst=4789,flags(df|key))),vxlan_sys_4789 + +Dumping vxlan encap action with offload, it shows:: + + actions:set(tunnel(tun_id=0x4,dst=192.168.1.64,ttl=64,tp_dst=4789,flags(key))),vxlan_sys_4789 + TC Meter Offload ~~~~~~~~~~~~~~~~ diff --git a/tests/system-offloads-traffic.at b/tests/system-offloads-traffic.at index ae302a294..0704ea491 100644 --- a/tests/system-offloads-traffic.at +++ b/tests/system-offloads-traffic.at @@ -93,6 +93,158 @@ AT_CHECK([ovs-appctl upcall/show | grep -E "offloaded flows : [[1-9]]"], [0], [i OVS_TRAFFIC_VSWITCHD_STOP AT_CLEANUP + +AT_SETUP([offloads - sflow with sampling=1 - offloads enabled]) +OVS_TRAFFIC_VSWITCHD_START([], [], [-- set Open_vSwitch . other_config:hw-offload=true]) + +on_exit 'kill `cat test-sflow.pid`' +AT_CHECK([ovstest test-sflow --log-file --detach --no-chdir --pidfile 0:127.0.0.1 > sflow.log], [0], [], [ignore]) +AT_CAPTURE_FILE([sflow.log]) +PARSE_LISTENING_PORT([test-sflow.log], [SFLOW_PORT]) + +AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"]) + +ADD_NAMESPACES(at_ns0, at_ns1) +ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") +ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") + +AT_CHECK([ovs-vsctl -- --id=@sflow create sflow agent=lo target=\"127.0.0.1:$SFLOW_PORT\" header=128 sampling=1 polling=100 -- set bridge br0 sflow=@sflow], [0], [ignore]) +NS_CHECK_EXEC([at_ns0], [ping -q -c 1000 -i 0.01 -w 12 10.1.1.2 | FORMAT_PING], [0], [dnl +1000 packets transmitted, 1000 received, 0% packet loss, time 0ms +]) + +p1_ifindex=$(cat /sys/class/net/ovs-p1/ifindex) +m4_define([DUMP_SFLOW], [sed -e "s/used:[[0-9]].[[0-9]]*s/used:0.001s/;s/eth(src=[[a-z0-9:]]*,dst=[[a-z0-9:]]*)/eth(macs)/;s/pid=[[0-9]]*/pid=1/;s/output=$p1_ifindex/output=1/"]) +AT_CHECK([ovs-appctl dpctl/dump-flows type=tc,offloaded | grep "in_port(2)" | grep "eth_type(0x0800)" | grep "actions:userspace" | grep "sFlow" | DUMP_SFLOW], [0], [dnl +recirc_id(0),in_port(2),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:999, bytes:83916, used:0.001s, actions:userspace(pid=1,sFlow(vid=0,pcp=0,output=1),actions),3 +]) + +p0_ifindex=$(cat /sys/class/net/ovs-p0/ifindex) +m4_define([DUMP_SFLOW], [sed -e "s/used:[[0-9]].[[0-9]]*s/used:0.001s/;s/eth(src=[[a-z0-9:]]*,dst=[[a-z0-9:]]*)/eth(macs)/;s/pid=[[0-9]]*/pid=1/;s/output=$p0_ifindex/output=1/"]) +AT_CHECK([ovs-appctl dpctl/dump-flows type=tc,offloaded | grep "in_port(3)" | grep "eth_type(0x0800)" | grep "actions:userspace" | grep "sFlow" | DUMP_SFLOW], [0], [dnl +recirc_id(0),in_port(3),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:999, bytes:83916, used:0.001s, actions:userspace(pid=1,sFlow(vid=0,pcp=0,output=1),actions),2 +]) + +hdr="in_ifindex=$p0_ifindex in_format=0 out_ifindex=$p1_ifindex out_format=0 hdr_prot=1 pkt_len=102 stripped=4 hdr_len=98" +count=`grep "$hdr" sflow.log | wc -l` +AT_CHECK([[[[ $count -ge 996 ]]]]) +hdr="in_ifindex=$p1_ifindex in_format=0 out_ifindex=$p0_ifindex out_format=0 hdr_prot=1 pkt_len=102 stripped=4 hdr_len=98" +count=`grep "$hdr" sflow.log | wc -l` +AT_CHECK([[[[ $count -ge 996 ]]]]) + +OVS_TRAFFIC_VSWITCHD_STOP +OVS_APP_EXIT_AND_WAIT([test-sflow]) +AT_CLEANUP + + +AT_SETUP([offloads - sflow with sampling=2 - offloads enabled]) +OVS_TRAFFIC_VSWITCHD_START([], [], [-- set Open_vSwitch . other_config:hw-offload=true]) + +on_exit 'kill `cat test-sflow.pid`' +AT_CHECK([ovstest test-sflow --log-file --detach --no-chdir --pidfile 0:127.0.0.1 > sflow.log], [0], [], [ignore]) +AT_CAPTURE_FILE([sflow.log]) +PARSE_LISTENING_PORT([test-sflow.log], [SFLOW_PORT]) + +AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"]) + +ADD_NAMESPACES(at_ns0, at_ns1) +ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") +ADD_VETH(p1, at_ns1, br0, "10.1.1.2/24") + +AT_CHECK([ovs-vsctl -- --id=@sflow create sflow agent=lo target=\"127.0.0.1:$SFLOW_PORT\" header=128 sampling=2 polling=100 -- set bridge br0 sflow=@sflow], [0], [ignore]) +NS_CHECK_EXEC([at_ns0], [ping -q -c 1000 -i 0.01 -w 12 10.1.1.2 | FORMAT_PING], [0], [dnl +1000 packets transmitted, 1000 received, 0% packet loss, time 0ms +]) + +p1_ifindex=$(cat /sys/class/net/ovs-p1/ifindex) +m4_define([DUMP_SFLOW], [sed -e "s/used:[[0-9]].[[0-9]]*s/used:0.001s/;s/eth(src=[[a-z0-9:]]*,dst=[[a-z0-9:]]*)/eth(macs)/;s/pid=[[0-9]]*/pid=1/;s/output=$p1_ifindex/output=1/"]) +AT_CHECK([ovs-appctl dpctl/dump-flows type=tc,offloaded | grep "in_port(2)" | grep "eth_type(0x0800)" | grep "actions:sample" | grep "sFlow" | DUMP_SFLOW], [0], [dnl +recirc_id(0),in_port(2),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:999, bytes:83916, used:0.001s, actions:sample(sample=50.0%,actions(userspace(pid=1,sFlow(vid=0,pcp=0,output=1),actions))),3 +]) + +p0_ifindex=$(cat /sys/class/net/ovs-p0/ifindex) +m4_define([DUMP_SFLOW], [sed -e "s/used:[[0-9]].[[0-9]]*s/used:0.001s/;s/eth(src=[[a-z0-9:]]*,dst=[[a-z0-9:]]*)/eth(macs)/;s/pid=[[0-9]]*/pid=1/;s/output=$p0_ifindex/output=1/"]) +AT_CHECK([ovs-appctl dpctl/dump-flows type=tc,offloaded | grep "in_port(3)" | grep "eth_type(0x0800)" | grep "actions:sample" | grep "sFlow" | DUMP_SFLOW], [0], [dnl +recirc_id(0),in_port(3),eth(macs),eth_type(0x0800),ipv4(frag=no), packets:999, bytes:83916, used:0.001s, actions:sample(sample=50.0%,actions(userspace(pid=1,sFlow(vid=0,pcp=0,output=1),actions))),2 +]) + +OVS_TRAFFIC_VSWITCHD_STOP +OVS_APP_EXIT_AND_WAIT([test-sflow]) +count=`cat sflow.log | wc -l` +AT_CHECK([[[[ $count -le 1100 && $count -ge 900 ]]]]) +AT_CLEANUP + + +AT_SETUP([offloads - ping over vxlan tunnel with sflow - offloads enabled]) +OVS_CHECK_TUNNEL_TSO() +OVS_CHECK_VXLAN() + +OVS_TRAFFIC_VSWITCHD_START([], [], [-- set Open_vSwitch . other_config:hw-offload=true]) +ADD_BR([br-underlay]) + +AT_CHECK([ovs-ofctl add-flow br0 "actions=normal"]) +AT_CHECK([ovs-ofctl add-flow br-underlay "actions=normal"]) + +ADD_NAMESPACES(at_ns0) + +dnl Set up underlay link from host into the namespace using veth pair. +ADD_VETH(p0, at_ns0, br-underlay, "172.31.1.1/24") +AT_CHECK([ip addr add dev br-underlay "172.31.1.100/24"]) +AT_CHECK([ip link set dev br-underlay up]) + +dnl Set up tunnel endpoints on OVS outside the namespace and with a native +dnl linux device inside the namespace. +ADD_OVS_TUNNEL([vxlan], [br0], [at_vxlan0], [172.31.1.1], [10.1.1.100/24]) +ADD_NATIVE_TUNNEL([vxlan], [at_vxlan1], [at_ns0], [172.31.1.100], [10.1.1.1/24], + [id 0 dstport 4789]) + +on_exit 'kill `cat test-sflow.pid`' +AT_CHECK([ovstest test-sflow --log-file --detach --no-chdir --pidfile 0:127.0.0.1 > sflow.log], [0], [], [ignore]) +AT_CAPTURE_FILE([sflow.log]) +PARSE_LISTENING_PORT([test-sflow.log], [SFLOW_PORT]) +AT_CHECK([ovs-vsctl -- --id=@sflow create sflow agent=lo target=\"127.0.0.1:$SFLOW_PORT\" header=128 sampling=1 polling=100 -- set bridge br0 sflow=@sflow], [0], [ignore]) + +dnl First, check the underlay +NS_CHECK_EXEC([at_ns0], [ping -q -c 3 -i 0.3 -w 2 172.31.1.100 | FORMAT_PING], [0], [dnl +3 packets transmitted, 3 received, 0% packet loss, time 0ms +]) + +dnl Okay, now check the overlay +NS_CHECK_EXEC([at_ns0], [ping -q -c 1000 -i 0.01 10.1.1.100 | FORMAT_PING], [0], [dnl +1000 packets transmitted, 1000 received, 0% packet loss, time 0ms +]) + +vxlan_sys_ifindex=$(cat /sys/class/net/vxlan_sys_4789/ifindex) +br0_ifindex=$(cat /sys/class/net/br0/ifindex) +br0_mac=$(cat /sys/class/net/br0/address) +vxlan1_mac=$(ip netns exec at_ns0 cat /sys/class/net/at_vxlan1/address) + +dnl Check encap flow +match="recirc_id(0),in_port(br0),eth(src=$br0_mac,dst=$vxlan1_mac),eth_type(0x0800),ipv4(tos=0/0x3,frag=no)" +action="actions:userspace(pid=4294967295,sFlow(vid=0,pcp=0,output=$vxlan_sys_ifindex),actions),set(tunnel(dst=172.31.1.1,ttl=64,tp_dst=4789,flags(0))),vxlan_sys_4789" +AT_CHECK([ovs-appctl dpctl/dump-flows --names | grep $match | grep $action > /dev/null]) + +dnl Check decap flow +match="recirc_id(0),tunnel(tun_id=0x0,src=172.31.1.1,dst=172.31.1.100,tp_dst=4789,flags(+key)),in_port(vxlan_sys_4789),eth(src=$vxlan1_mac,dst=$br0_mac),eth_type(0x0800),ipv4(frag=no)" +action="actions:userspace(pid=4294967295,sFlow(vid=0,pcp=0,output=$br0_ifindex),actions),br0" +AT_CHECK([ovs-appctl dpctl/dump-flows --names | grep $match | grep $action> /dev/null]) + +dnl Vni is 0, test-sflow doesn't show it +out_tunnel_hdr="tunnel4_out_protocol=17 tunnel4_out_src=0.0.0.0 tunnel4_out_dst=172.31.1.1 tunnel4_out_src_port=0 tunnel4_out_dst_port=46354" +ifindex="in_ifindex=$br0_ifindex in_format=0 out_ifindex=$vxlan_sys_ifindex" +out_count=`grep "$out_tunnel_hdr" sflow.log | grep "$ifindex" | wc -l` +AT_CHECK([[[[ $out_count -ge 999 ]]]]) + +in_tunnel_hdr="tunnel4_in_protocol=17 tunnel4_in_src=172.31.1.1 tunnel4_in_dst=172.31.1.100" +ifindex="in_ifindex=$vxlan_sys_ifindex in_format=0 out_ifindex=$br0_ifindex" +in_count=`grep "$in_tunnel_hdr" sflow.log | grep "$ifindex" | wc -l` +AT_CHECK([[[[ $in_count -ge 999 ]]]]) + +OVS_TRAFFIC_VSWITCHD_STOP +OVS_APP_EXIT_AND_WAIT([test-sflow]) +AT_CLEANUP + + AT_SETUP([offloads - set ingress_policing_rate and ingress_policing_burst - offloads disabled]) AT_KEYWORDS([ingress_policing]) AT_SKIP_IF([test $HAVE_TC = "no"])