From patchwork Tue Dec 15 03:38:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Mi X-Patchwork-Id: 1416274 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=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=nvidia.com 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 4Cw3rV0f5qz9sSC for ; Tue, 15 Dec 2020 14:38:34 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 5A4ED8739C; Tue, 15 Dec 2020 03:38:32 +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 njnvHr98byhk; Tue, 15 Dec 2020 03:38:25 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id CCFB887276; Tue, 15 Dec 2020 03:38:23 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id BB10DC163C; Tue, 15 Dec 2020 03:38:23 +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 7A58DC013B for ; Tue, 15 Dec 2020 03:38:22 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 773FF86968 for ; Tue, 15 Dec 2020 03:38:22 +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 NbwZ0g5tdNeM for ; Tue, 15 Dec 2020 03:38:21 +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 C274F86938 for ; Tue, 15 Dec 2020 03:38:20 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from cmi@nvidia.com) with SMTP; 15 Dec 2020 05:38:15 +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 0BF3cD8M009673; Tue, 15 Dec 2020 05:38:14 +0200 From: Chris Mi To: dev@openvswitch.org Date: Tue, 15 Dec 2020 11:38:01 +0800 Message-Id: <20201215033812.145975-1-cmi@nvidia.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Cc: elibr@nvidia.com, Chris Mi , roniba@nvidia.com, i.maximets@ovn.org Subject: [ovs-dev] [PATCH v9 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. GitHub Actions: v9: https://github.com/mishuang2017/ovs/actions/runs/422310251 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. 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 | 600 ++++++++++++++++++++++++++++++- lib/netdev-offload.c | 30 ++ lib/netdev-offload.h | 4 + lib/tc.c | 61 +++- lib/tc.h | 10 +- ofproto/ofproto-dpif-upcall.c | 42 +++ utilities/ovs-kmod-ctl.in | 14 + 17 files changed, 912 insertions(+), 12 deletions(-) create mode 100644 include/linux/psample.h create mode 100644 include/linux/tc_act/tc_sample.h