From patchwork Tue Apr 2 14:57:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Britstein X-Patchwork-Id: 1074547 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 44YXSr5hJvz9sTX for ; Wed, 3 Apr 2019 02:00:28 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 58CA5EB9; Tue, 2 Apr 2019 14:57:47 +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 C7D16E9E for ; Tue, 2 Apr 2019 14:57:45 +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 CBA497A6 for ; Tue, 2 Apr 2019 14:57:43 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from elibr@mellanox.com) with ESMTPS (AES256-SHA encrypted); 2 Apr 2019 17:57:35 +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 x32EvNDo025807; Tue, 2 Apr 2019 17:57:35 +0300 From: Eli Britstein To: dev@openvswitch.org Date: Tue, 2 Apr 2019 14:57:10 +0000 Message-Id: <20190402145712.7290-5-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 4/6] netdev-dpdk: Introduce peer name property for dpdk ports 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 Introduce peer name property for dpdk ports, as a pre-step towards accelarating peer port forwarding. Signed-off-by: Eli Britstein Reviewed-by: Oz Shlomo --- lib/netdev-dpdk.c | 55 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 67df3fc1a..8e02c37e4 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -430,7 +430,9 @@ struct netdev_dpdk { struct netdev_stats stats; /* Protects stats */ rte_spinlock_t stats_lock; - /* 44 pad bytes here. */ + /* 4 pad bytes here. */ + char *peer; + /* 32 pad bytes here. */ ); PADDED_MEMBERS(CACHE_LINE_SIZE, @@ -1622,6 +1624,9 @@ netdev_dpdk_get_config(const struct netdev *netdev, struct smap *args) smap_add(args, "lsc_interrupt_mode", dev->lsc_interrupt_mode ? "true" : "false"); } + if (dev->peer) { + smap_add(args, "peer", dev->peer); + } ovs_mutex_unlock(&dev->mutex); return 0; @@ -1759,6 +1764,27 @@ dpdk_process_queue_size(struct netdev *netdev, const struct smap *args, } } +static int +netdev_dpdk_set_peer_config(struct netdev *netdev, const struct smap *args) +{ + struct netdev_dpdk *dev = netdev_dpdk_cast(netdev); + const char *name = netdev_get_name(netdev); + const char *peer; + int err = 0; + + peer = smap_get(args, "peer"); + if (!strcmp(name, peer)) { + VLOG_ERR("%s: dpdk peer must not be self", name); + err = EINVAL; + } + if (!dev->peer || strcmp(dev->peer, peer)) { + free(dev->peer); + dev->peer = xstrdup(peer); + } + + return err; +} + static int netdev_dpdk_set_config(struct netdev *netdev, const struct smap *args, char **errp) @@ -1841,6 +1867,11 @@ netdev_dpdk_set_config(struct netdev *netdev, const struct smap *args, goto out; } + err = netdev_dpdk_set_peer_config(netdev, args); + if (err) { + goto out; + } + lsc_interrupt_mode = smap_get_bool(args, "dpdk-lsc-interrupt", false); if (dev->requested_lsc_interrupt_mode != lsc_interrupt_mode) { dev->requested_lsc_interrupt_mode = lsc_interrupt_mode; @@ -1891,6 +1922,7 @@ netdev_dpdk_vhost_client_set_config(struct netdev *netdev, { struct netdev_dpdk *dev = netdev_dpdk_cast(netdev); const char *path; + int err; ovs_mutex_lock(&dev->mutex); if (!(dev->vhost_driver_flags & RTE_VHOST_USER_CLIENT)) { @@ -1906,9 +1938,10 @@ netdev_dpdk_vhost_client_set_config(struct netdev *netdev, netdev_request_reconfigure(netdev); } } + err = netdev_dpdk_set_peer_config(netdev, args); ovs_mutex_unlock(&dev->mutex); - return 0; + return err; } static int @@ -4229,6 +4262,21 @@ netdev_dpdk_rte_flow_create(struct netdev *netdev, return flow; } +static char * +get_dpdk_peer_name(const struct netdev *netdev) +{ + struct netdev_dpdk *dev = netdev_dpdk_cast(netdev); + char *peer = NULL; + + ovs_mutex_lock(&dev->mutex); + if (dev->peer) { + peer = xstrdup(dev->peer); + } + ovs_mutex_unlock(&dev->mutex); + + return peer; +} + #define NETDEV_DPDK_CLASS_COMMON \ .is_pmd = true, \ .alloc = netdev_dpdk_alloc, \ @@ -4250,7 +4298,8 @@ netdev_dpdk_rte_flow_create(struct netdev *netdev, .rxq_alloc = netdev_dpdk_rxq_alloc, \ .rxq_construct = netdev_dpdk_rxq_construct, \ .rxq_destruct = netdev_dpdk_rxq_destruct, \ - .rxq_dealloc = netdev_dpdk_rxq_dealloc + .rxq_dealloc = netdev_dpdk_rxq_dealloc, \ + .get_peer_name = get_dpdk_peer_name #define NETDEV_DPDK_CLASS_BASE \ NETDEV_DPDK_CLASS_COMMON, \