From patchwork Tue Apr 2 14:57:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Britstein X-Patchwork-Id: 1074543 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.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 mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44YXQh29cHz9sTX for ; Wed, 3 Apr 2019 01:58:36 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 9165FDE0; Tue, 2 Apr 2019 14:57:35 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 3A35CE2F for ; Tue, 2 Apr 2019 14:57:34 +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 smtp1.linuxfoundation.org (Postfix) with ESMTP id 478986E0 for ; Tue, 2 Apr 2019 14:57:33 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from elibr@mellanox.com) with ESMTPS (AES256-SHA encrypted); 2 Apr 2019 17:57:31 +0300 Received: from dev-r-vrt-214.mtr.labs.mlnx. (dev-r-vrt-214.mtr.labs.mlnx [10.212.214.1]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x32EvNDl025807; Tue, 2 Apr 2019 17:57:31 +0300 From: Eli Britstein To: dev@openvswitch.org Date: Tue, 2 Apr 2019 14:57:07 +0000 Message-Id: <20190402145712.7290-2-elibr@mellanox.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190402145712.7290-1-elibr@mellanox.com> References: <20190402145712.7290-1-elibr@mellanox.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Oz Shlomo , Simon Horman , Eli Britstein Subject: [ovs-dev] [PATCH 1/6] netdev: Introduce peer port name as a netdevice class property X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Currently peer port is defined as a patch port property. However, peer ports can be used as generic netdevice property to accelerate peer ports forwarding. Introduce a generic method for retreiving peer port name. Signed-off-by: Eli Britstein Reviewed-by: Oz Shlomo --- lib/netdev-provider.h | 6 ++++++ lib/netdev.c | 13 +++++++++++++ lib/netdev.h | 1 + 3 files changed, 20 insertions(+) diff --git a/lib/netdev-provider.h b/lib/netdev-provider.h index fb0c27e6e..967760fb3 100644 --- a/lib/netdev-provider.h +++ b/lib/netdev-provider.h @@ -775,6 +775,12 @@ struct netdev_class { * used to send and receive packets until a successful configuration is * applied. */ int (*reconfigure)(struct netdev *netdev); + + /* If the netdev class of 'netdev' supports peer option, returns the name + * of its peer as a malloc()'d string that the caller must free. + * + * If peer is not supported, returns NULL. */ + char *(*get_peer_name)(const struct netdev *netdev); /* ## -------------------- ## */ /* ## netdev_rxq Functions ## */ /* ## -------------------- ## */ diff --git a/lib/netdev.c b/lib/netdev.c index 7d7ecf6f0..c6b9c7e96 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -913,6 +913,19 @@ netdev_get_name(const struct netdev *netdev) return netdev->name; } +char * +netdev_get_peer_name(const struct netdev *netdev) +{ + const struct netdev_class *class = netdev->netdev_class; + char *peer = NULL; + + if (class->get_peer_name) { + peer = class->get_peer_name(netdev); + } + + return peer; +} + /* Retrieves the MTU of 'netdev'. The MTU is the maximum size of transmitted * (and received) packets, in bytes, not including the hardware header; thus, * this is typically 1500 bytes for Ethernet devices. diff --git a/lib/netdev.h b/lib/netdev.h index d94817fb6..d65b1ffcf 100644 --- a/lib/netdev.h +++ b/lib/netdev.h @@ -170,6 +170,7 @@ int netdev_get_numa_id(const struct netdev *); /* Basic properties. */ const char *netdev_get_name(const struct netdev *); +char *netdev_get_peer_name(const struct netdev *); const char *netdev_get_type(const struct netdev *); const char *netdev_get_type_from_name(const char *); int netdev_get_mtu(const struct netdev *, int *mtup);