From patchwork Wed Jan 27 06:23:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Mi X-Patchwork-Id: 1432033 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DQYTW4xSmz9sWH for ; Wed, 27 Jan 2021 17:23:59 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id D8FD686838; Wed, 27 Jan 2021 06:23:57 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Qw5hY+u3eUtL; Wed, 27 Jan 2021 06:23:56 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id 2615C86519; Wed, 27 Jan 2021 06:23:56 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id EA687C0FA7; Wed, 27 Jan 2021 06:23:55 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id D2D70C013A for ; Wed, 27 Jan 2021 06:23:53 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id C18E485039 for ; Wed, 27 Jan 2021 06:23:53 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CMNcxRe619Nt for ; Wed, 27 Jan 2021 06:23:52 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by fraxinus.osuosl.org (Postfix) with ESMTP id DEB9084FC9 for ; Wed, 27 Jan 2021 06:23:51 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from cmi@nvidia.com) with SMTP; 27 Jan 2021 08:23:48 +0200 Received: from dev-r630-03.mtbc.labs.mlnx (dev-r630-03.mtbc.labs.mlnx [10.75.205.13]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 10R6NkMG004930; Wed, 27 Jan 2021 08:23:47 +0200 From: Chris Mi To: dev@openvswitch.org Date: Wed, 27 Jan 2021 14:23:33 +0800 Message-Id: <20210127062344.194230-1-cmi@nvidia.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Cc: elibr@nvidia.com, roniba@nvidia.com, i.maximets@ovn.org Subject: [ovs-dev] [PATCH v12 00/11] 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: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" This patch set adds offload support for sFlow. Psample is a genetlink channel for packet sampling. TC action act_sample uses psample to send sampled packets to userspace. When offloading sample action to TC, userspace creates a unique ID to map sFlow action and tunnel info and passes this ID to kernel instead of the sFlow info. psample will send this ID and sampled packet to userspace. Using the ID, userspace can recover the sFlow info and send sampled packet to the right sFlow monitoring host. v2-v1: - Fix robot errors. v3-v2: - Remove Gerrit Change-Id. - Add patch #9 to fix older kernels build issue. - Add travis test result. v4-v3: - Fix offload issue when sampling rate is 1. v5-v4: - Move polling thread from ofproto to netdev-offload-tc. v6-v5: - Rebase. - Add GitHub Actions test result. v7-v6: - Remove Gerrit Change-Id. - Fix "ERROR: Inappropriate spacing around cast" v8-v7 - Address Eelco Chaudron's comment for patch #11. v9-v8 - Remove sflow_len from struct dpif_sflow_attr. - Log a debug message for other userspace actions. v10-v9 - Address Eelco Chaudron's comments on v9. v11-v10 - Fix a bracing error. v12-v11 - Add duplicate sample group id check. Chris Mi (11): compat: Add psample and tc sample action defines for older kernels ovs-kmod-ctl: Load kernel module psample dpif: Introduce register sFlow upcall callback API ofproto: Add upcall callback to process sFlow packet netdev-offload: Introduce register sFlow upcall callback API netdev-offload-tc: Implement register sFlow upcall callback API dpif-netlink: Implement register sFlow upcall callback API netdev-offload-tc: Introduce group ID management API netdev-offload-tc: Create psample netlink socket netdev-offload-tc: Add psample receive handler netdev-offload-tc: Add offload support for sFlow include/linux/automake.mk | 4 +- include/linux/psample.h | 58 +++ include/linux/tc_act/tc_sample.h | 25 ++ lib/dpif-netdev.c | 1 + lib/dpif-netlink.c | 27 ++ lib/dpif-netlink.h | 4 + lib/dpif-provider.h | 10 + lib/dpif.c | 8 + lib/dpif.h | 23 ++ lib/netdev-offload-provider.h | 3 + lib/netdev-offload-tc.c | 659 ++++++++++++++++++++++++++++++- lib/netdev-offload.c | 30 ++ lib/netdev-offload.h | 4 + lib/tc.c | 61 ++- lib/tc.h | 16 +- ofproto/ofproto-dpif-upcall.c | 42 ++ utilities/ovs-kmod-ctl.in | 14 + 17 files changed, 973 insertions(+), 16 deletions(-) create mode 100644 include/linux/psample.h create mode 100644 include/linux/tc_act/tc_sample.h