From patchwork Thu Mar 17 01:12:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Mi X-Patchwork-Id: 1606337 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=tzsaaJBp; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KJpzy1sqLz9sCD for ; Thu, 17 Mar 2022 12:13:18 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 8DB448473E; Thu, 17 Mar 2022 01:13:15 +0000 (UTC) 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 V7nUiUlHJX4U; Thu, 17 Mar 2022 01:13:14 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 847CF84749; Thu, 17 Mar 2022 01:13:13 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 522B0C0073; Thu, 17 Mar 2022 01:13:13 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 15BAAC0012 for ; Thu, 17 Mar 2022 01:13:12 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 05F26402A2 for ; Thu, 17 Mar 2022 01:13:09 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp4.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=nvidia.com 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 L0ChMUCNhN2a for ; Thu, 17 Mar 2022 01:13:08 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2060b.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5b::60b]) by smtp4.osuosl.org (Postfix) with ESMTPS id 817564182D for ; Thu, 17 Mar 2022 01:13:07 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BVNGFei1MVnT4lEzfiPWP6s6jR2eGDZt9AAK4g9dpzWLwEtK9FE8Pn8JNN/orLjQx7H2+SEtE8cwlZvwk/mUTcAN4GNcQ9xaDeUkMmCWGEWEUPUVqEuWEqHScKx7lfEfXoKBBUdGXae0kilFyqllcAuBLG3OQgaW8Oa5puN+KaJVsBE/BLKbtzjTwrUeHbL3hqE6CBc6vBJ1vowzxgYrV7XiuXyOvnIEASZm1mwsNU2m3mj3enFep8Vj/WVVXLSCTBqNeVjRsJQ+pCEENKWsL5U9I0/e1jtlj1qP3rzRLmKetMdONdbYM/arwGR+mmwazTlSuDUS92P4kzqORZDhRA== 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=vkHyFTQJFdhHtUfKc7ggK0ezK17ZcoY2HvgZ42oqrpk=; b=G0iOHohcgu7Nk0CaLNd3PGhUv+d3mOuzxoYRwADKmaKY1cs+q4lsCchVxR9N8EKrUZvazt0IGzxbk11zTt61L3qCnuMCQ2Hpy+iEZij7UIvK30eRlVxDC3JLeu3bkxYWJmMQm2Bbf1pSje0T1Ijh4BvqRzLU/5OnIqp+aWFeM5zUmQeepaNJx4EsWLZwFYERYPJAC8d6at44VC3K7lCx4s7jREgcsTK8DYMRfbAy0WZxZFxwi5PPm/gBIsZLcWOTm8ZNYVdwND9mMFVuVekr6I15w2aD0pG6SaKDYhNqRKZs8DJdRU+CcgFXXWrrn4/1h7piOOinNThJbuB1YbjbLg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.234) smtp.rcpttodomain=ovn.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=vkHyFTQJFdhHtUfKc7ggK0ezK17ZcoY2HvgZ42oqrpk=; b=tzsaaJBpZexaPTWFPPTQNYBNQIos7953q93Qcjo2kKBqVWZmcSL65Ojsbqtj0pJLKMO5NJ4dd1Z5rJc3lBw5GxQBGfdZHbTh2xvgzZDqQo9/svCOrETfibwdBcZ1NM5xNXBU/SftnI/8WLPINE4QfW0uZI+bGhQMeFglt3P1zcCZnVQrdc3pr1n0Zs35HViFKo5FUmmudiYB9zAstyAMDWsWj+GpVYQFAdjfV8v2seyT3IsYycYRX8xak4pDzJypO116eH3qh2V0PYFflT/WOL5SmW0F51zU4pzswDzZM7Mr4a9Z5SDymreRcPF+2W2Iv9MsxO7voPpomnMCFVxzYw== Received: from DM5PR10CA0003.namprd10.prod.outlook.com (2603:10b6:4:2::13) by MWHPR12MB1247.namprd12.prod.outlook.com (2603:10b6:300:10::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5061.25; Thu, 17 Mar 2022 01:13:03 +0000 Received: from DM6NAM11FT047.eop-nam11.prod.protection.outlook.com (2603:10b6:4:2:cafe::92) by DM5PR10CA0003.outlook.office365.com (2603:10b6:4:2::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.16 via Frontend Transport; Thu, 17 Mar 2022 01:13:03 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.234) 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 12.22.5.234 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.234; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.234) by DM6NAM11FT047.mail.protection.outlook.com (10.13.172.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5081.14 via Frontend Transport; Thu, 17 Mar 2022 01:13:03 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by DRHQMAIL101.nvidia.com (10.27.9.10) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Thu, 17 Mar 2022 01:13:02 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Wed, 16 Mar 2022 18:13:01 -0700 Received: from dev-r630-03.lab.mtl.com (10.127.8.12) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.986.22 via Frontend Transport; Wed, 16 Mar 2022 18:12:59 -0700 To: Date: Thu, 17 Mar 2022 09:12:44 +0800 Message-ID: <20220317011249.46787-4-cmi@nvidia.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220317011249.46787-1-cmi@nvidia.com> References: <20220317011249.46787-1-cmi@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 390c0abf-8626-48ee-281e-08da07b348fe X-MS-TrafficTypeDiagnostic: MWHPR12MB1247:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eKQgLoDM/3ylCAVOyLT9lDKNxIfHXXGdjIL1V9QDu9qFmH/OzKaFFDk9bc6iSQlJ/q1BJaOwUYayH7RD+X0sW1T4Vfg+PJY8Of+4jg+pbPtwOslpaqfcdZRfuWVb6YF+/WWwzgPwqFnFijycTLHXF7ZodvcWJmAX3kwVAIXVW0uXUHhyQQR1IN9+bosU9z/vblRUstcrIx2qz0q1gYTDbyE56GX3Fm33Gx/RTwlVOAqObqAockLKqSnhUIoJMOlHUmsuE3Lr7XkvbW7j4PMHPtuxX7iiUKon0EhJDW2IWExYdpYFKHGq9ZWXf75uHdYA+xVaQMhFFtp4Yp0L5wDhK1XBzCYQZ/x4xYG1X3ROvoXUnY61w8bJprds7olqSBoo38h7AyLN0grqU/+PMjTZHYbEFuQx3+cg8tOVMkjBqxe+6AVTLBceUYY3KqMN5pNio5Xt7IOHvlqtHpcGKwZm+S52eG5fLCne+/9vI5laK8lJY/gnJdBzUnI+3sEliKkT52HE9sqNkSPO+Hz2YfCLyfnVjbR9QOfahM4mf2Ke3fnhv9r7a6uPeIabBCoILwZJksO819aNWUOWHKhBRvye4/wrOUbP1M83KNo3KMFeopgiL98ugMt+Wnq9s/2Uagipzi2gpECXT+nRUeB7QJvqO5ysYOkk8Y7s+kqlkkzfCWKvoGI/Ju43VmcTY2pNnwdt9G/OzvSVUpw+70Vj27A3LOEnz0RxdKG3yC4/EVgDP9iXy9V6tL7fFCwyBnC/j9sxkKZfq7ntQRLDcy1RiC4fGk6wvI8Q30ZzxZia/bj9bp8= X-Forefront-Antispam-Report: CIP:12.22.5.234; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(86362001)(107886003)(8676002)(426003)(6666004)(70586007)(26005)(186003)(70206006)(336012)(966005)(1076003)(2906002)(40460700003)(5660300002)(508600001)(8936002)(356005)(4326008)(82310400004)(81166007)(2616005)(6916009)(36860700001)(54906003)(83380400001)(47076005)(36756003)(316002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Mar 2022 01:13:03.0409 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 390c0abf-8626-48ee-281e-08da07b348fe X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.234]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT047.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1247 Cc: elibr@nvidia.com, simon.horman@netronome.com, roniba@nvidia.com, i.maximets@ovn.org Subject: [ovs-dev] [PATCH v21 3/8] dpif-offload-provider: Introduce dpif-offload-provider layer 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" Some offload actions require functionality that is not netdev based, but dpif. For example, sFlow action requires to create a psample netlink socket to receive the sampled packets from TC or kernel driver. Create dpif-offload-provider layer to support such actions. Signed-off-by: Chris Mi Reviewed-by: Eli Britstein --- lib/automake.mk | 2 ++ lib/dpif-offload-provider.h | 52 +++++++++++++++++++++++++++++++++++++ lib/dpif-offload.c | 43 ++++++++++++++++++++++++++++++ lib/dpif-provider.h | 4 ++- 4 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 lib/dpif-offload-provider.h create mode 100644 lib/dpif-offload.c diff --git a/lib/automake.mk b/lib/automake.mk index a23cdc4ad..781fba47a 100644 --- a/lib/automake.mk +++ b/lib/automake.mk @@ -129,6 +129,8 @@ lib_libopenvswitch_la_SOURCES = \ lib/dpif-netdev-private.h \ lib/dpif-netdev-perf.c \ lib/dpif-netdev-perf.h \ + lib/dpif-offload.c \ + lib/dpif-offload-provider.h \ lib/dpif-provider.h \ lib/dpif.c \ lib/dpif.h \ diff --git a/lib/dpif-offload-provider.h b/lib/dpif-offload-provider.h new file mode 100644 index 000000000..3b94740df --- /dev/null +++ b/lib/dpif-offload-provider.h @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef DPIF_OFFLOAD_PROVIDER_H +#define DPIF_OFFLOAD_PROVIDER_H + +struct dpif; +struct dpif_offload_sflow; + +/* Datapath interface offload structure, to be defined by each implementation + * of a datapath interface. + */ +struct dpif_offload_class { + /* Type of dpif offload in this class, e.g. "system", "netdev", etc. + * + * One of the providers should supply a "system" type, since this is + * the type assumed if no type is specified when opening a dpif. */ + const char *type; + + /* Called when the dpif offload provider is registered. */ + int (*init)(void); + + /* Free all dpif offload resources. */ + void (*destroy)(void); + + /* Arranges for the poll loop for an upcall handler to wake up when psample + * has a message queued to be received. */ + void (*sflow_recv_wait)(void); + + /* Polls for an upcall from psample for an upcall handler. + * Return 0 for success. */ + int (*sflow_recv)(struct dpif_offload_sflow *sflow); +}; + +void dpif_offload_sflow_recv_wait(const struct dpif *dpif); +int dpif_offload_sflow_recv(const struct dpif *dpif, + struct dpif_offload_sflow *sflow); + +#endif /* DPIF_OFFLOAD_PROVIDER_H */ diff --git a/lib/dpif-offload.c b/lib/dpif-offload.c new file mode 100644 index 000000000..f2bf3e634 --- /dev/null +++ b/lib/dpif-offload.c @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include "dpif-provider.h" + +void +dpif_offload_sflow_recv_wait(const struct dpif *dpif) +{ + const struct dpif_offload_class *offload_class = dpif->offload_class; + + if (offload_class && offload_class->sflow_recv_wait) { + offload_class->sflow_recv_wait(); + } +} + +int +dpif_offload_sflow_recv(const struct dpif *dpif, + struct dpif_offload_sflow *sflow) +{ + const struct dpif_offload_class *offload_class = dpif->offload_class; + + if (offload_class && offload_class->sflow_recv) { + return offload_class->sflow_recv(sflow); + } + + return EOPNOTSUPP; +} diff --git a/lib/dpif-provider.h b/lib/dpif-provider.h index 12477a24f..99009722a 100644 --- a/lib/dpif-provider.h +++ b/lib/dpif-provider.h @@ -22,8 +22,9 @@ * exposed over OpenFlow as a single switch. Datapaths and the collections of * ports that they contain may be fixed or dynamic. */ -#include "openflow/openflow.h" #include "dpif.h" +#include "dpif-offload-provider.h" +#include "openflow/openflow.h" #include "util.h" #ifdef __cplusplus @@ -35,6 +36,7 @@ extern "C" { * This structure should be treated as opaque by dpif implementations. */ struct dpif { const struct dpif_class *dpif_class; + const struct dpif_offload_class *offload_class; char *base_name; char *full_name; uint8_t netflow_engine_type;