From patchwork Wed Jul 8 16:10:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Tu X-Patchwork-Id: 1325297 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.136; helo=silver.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=Uj2jOI/o; dkim-atps=neutral Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B246m06pyz9sTQ for ; Thu, 9 Jul 2020 02:11:11 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 4F86B2C7D3; Wed, 8 Jul 2020 16:11:09 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bCtUU9xb+3aX; Wed, 8 Jul 2020 16:11:06 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id 32DC22C339; Wed, 8 Jul 2020 16:11:06 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 19F62C077B; Wed, 8 Jul 2020 16:11:06 +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 27A99C0895 for ; Wed, 8 Jul 2020 16:11:05 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 11B8D87D42 for ; Wed, 8 Jul 2020 16:11:05 +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 bDhsDPkiIgnG for ; Wed, 8 Jul 2020 16:11:03 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 159C187D29 for ; Wed, 8 Jul 2020 16:11:03 +0000 (UTC) Received: by mail-pf1-f196.google.com with SMTP id i14so3680278pfu.13 for ; Wed, 08 Jul 2020 09:11:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HBRLVlkTTv5Yfmpz6Db/TexoFC6BCw11Ay4Y/rmCM8k=; b=Uj2jOI/oJG26ldZzzg2eDQzuXDQ38reYiopV/LDuN6ZZNyGYxeeokEgDcYXMbz3wYf U1rEwOqavQm/DFCh9VMLQ9R7ddjOu/qy2VtETz33rZmAsge9ncOUznJmMxEwhmcCFWZ4 hVSeRX61z87VutMhZ89DZ2fsBZoJpSNkuPzVIGPMz0EAPkC7imoDQTPB0E8bsEOemj1O mXY460gR3txRNWgtO0fqjvCegqP/EMXmFlaGlU3qEpzmvzof8ZkECMYIw5xeo4/LACA/ tO2HM6JtpfYX9uD3vpm99mPE1F2dKWVIRZoU5rbhikx25WqJODnbVHd00HFTpaqbOePX 0z1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=HBRLVlkTTv5Yfmpz6Db/TexoFC6BCw11Ay4Y/rmCM8k=; b=mqNOIrH7tv3u8yJLxWblUvaN1n8C/WNNSa54OZkYPEeRATSNvb5MZBv5d+KfB79cJp T/XhraL3ZPpZiBltGJWmFFfOqIQhFaX56ygbwtsD0dSjkkfwKZjNT17SQOlCEoOeSXgf NMh0OohakVOnl+TDTJKuq7MKSWbfHjrqO+J5dKnUoyBvgcrWE8NXuZWul6hqYEAu4GWC sFZE0kSDxL4bBondBWAToPEDZNBsdc2krEjrcz5N1oO5N681PYCviySLd1JlGmTCpfsL qjUKffWkctZbqL+1VqsEmRH+LrqONLsrKsbM/4HGUok13mng8CAXsbnjTuZqRyCXBpeR 2gDg== X-Gm-Message-State: AOAM5322qea0hYDnfNwzcSiArrj4QbIL8c0f+sGEry5icJTh4cUOE13x NDoQGcTQzmoyCfB3UiUIzfF8fN/H+gE= X-Google-Smtp-Source: ABdhPJwutgXALhvzsMnv39V9/jG8LynEgse03FaCngIRjSbn1C6p12XcKNPhfKI/jg7wyW2tlaFGFA== X-Received: by 2002:a65:64d8:: with SMTP id t24mr51622389pgv.286.1594224662364; Wed, 08 Jul 2020 09:11:02 -0700 (PDT) Received: from sc9-mailhost2.vmware.com (c-76-21-95-192.hsd1.ca.comcast.net. [76.21.95.192]) by smtp.gmail.com with ESMTPSA id j2sm6597707pjy.1.2020.07.08.09.11.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Jul 2020 09:11:01 -0700 (PDT) From: William Tu To: dev@openvswitch.org Date: Wed, 8 Jul 2020 09:10:34 -0700 Message-Id: <1594224636-42337-2-git-send-email-u9012063@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1594224636-42337-1-git-send-email-u9012063@gmail.com> References: <1594224636-42337-1-git-send-email-u9012063@gmail.com> Cc: Eli Britstein , Ilya Maximets Subject: [ovs-dev] [PATCH 1/3] netdev: Allow storing dpif type into netdev structure. 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: , MIME-Version: 1.0 Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Ilya Maximets Storing of the dpif type of the owning datapath interface will allow us to easily distinguish, for example, userspace tunneling ports from the system ones. This is required in terms of HW offloading to avoid offloading of userspace flows to kernel interfaces that doesn't belong to userspace datapath, but have same dpif_port names. Signed-off-by: Ilya Maximets Acked-by: Eli Britstein Acked-by: Roni Bar Yanai Acked-by: Ophir Munk Signed-off-by: Eli Britstein Signed-off-by: William Tu --- lib/netdev-provider.h | 3 ++- lib/netdev.c | 16 ++++++++++++++++ lib/netdev.h | 2 ++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/netdev-provider.h b/lib/netdev-provider.h index d9503adb0fb6..73dce2fcab8d 100644 --- a/lib/netdev-provider.h +++ b/lib/netdev-provider.h @@ -96,7 +96,8 @@ struct netdev { /* Functions to control flow offloading. */ OVSRCU_TYPE(const struct netdev_flow_api *) flow_api; - struct netdev_hw_info hw_info; /* offload-capable netdev info */ + const char *dpif_type; /* Type of dpif this netdev belongs to. */ + struct netdev_hw_info hw_info; /* Offload-capable netdev info. */ }; static inline void diff --git a/lib/netdev.c b/lib/netdev.c index 90962eec66cf..91e91955c09b 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -1984,6 +1984,22 @@ netdev_get_class(const struct netdev *netdev) return netdev->netdev_class; } +/* Set the type of 'dpif' this 'netdev' belongs to. */ +void +netdev_set_dpif_type(struct netdev *netdev, const char *type) +{ + netdev->dpif_type = type; +} + +/* Returns the type of 'dpif' this 'netdev' belongs to. + * + * The caller must not free the returned value. */ +const char * +netdev_get_dpif_type(const struct netdev *netdev) +{ + return netdev->dpif_type; +} + /* Returns the netdev with 'name' or NULL if there is none. * * The caller must free the returned netdev with netdev_close(). */ diff --git a/lib/netdev.h b/lib/netdev.h index fdbe0e1f58c5..fb50730569ea 100644 --- a/lib/netdev.h +++ b/lib/netdev.h @@ -179,6 +179,8 @@ bool netdev_mtu_is_user_config(struct netdev *); int netdev_get_ifindex(const struct netdev *); int netdev_set_tx_multiq(struct netdev *, unsigned int n_txq); enum netdev_pt_mode netdev_get_pt_mode(const struct netdev *); +void netdev_set_dpif_type(struct netdev *, const char *); +const char *netdev_get_dpif_type(const struct netdev *); /* Packet reception. */ int netdev_rxq_open(struct netdev *, struct netdev_rxq **, int id);