From patchwork Sun Jun 21 11:19:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Britstein X-Patchwork-Id: 1313895 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.133; helo=hemlock.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=mellanox.com Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49qVSV64nMz9sRh for ; Sun, 21 Jun 2020 21:19:54 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 80AA38953F; Sun, 21 Jun 2020 11:19:52 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id V-nCZmklYmY6; Sun, 21 Jun 2020 11:19:51 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id AD0BA8943F; Sun, 21 Jun 2020 11:19:51 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 8C680C07FF; Sun, 21 Jun 2020 11:19:51 +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 3BF0EC016F for ; Sun, 21 Jun 2020 11:19:50 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 2CCE086F41 for ; Sun, 21 Jun 2020 11:19:50 +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 t__Dv5b-OcPR for ; Sun, 21 Jun 2020 11:19:49 +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 9387286F35 for ; Sun, 21 Jun 2020 11:19:48 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from elibr@mellanox.com) with SMTP; 21 Jun 2020 14:19:45 +0300 Received: from dev-r-vrt-215.mtr.labs.mlnx. (dev-r-vrt-215.mtr.labs.mlnx [10.212.215.1]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 05LBJirt013908; Sun, 21 Jun 2020 14:19:45 +0300 From: Eli Britstein To: dev@openvswitch.org, Ilya Maximets Date: Sun, 21 Jun 2020 11:19:17 +0000 Message-Id: <20200621111924.12397-6-elibr@mellanox.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20200621111924.12397-1-elibr@mellanox.com> References: <20200621111924.12397-1-elibr@mellanox.com> Cc: Eli Britstein , Ameer Mahagneh Subject: [ovs-dev] [PATCH V3 05/12] 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 --- 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 d9503adb0..73dce2fca 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 90962eec6..91e91955c 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 fdbe0e1f5..fb5073056 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);