From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by dpdk.org (Postfix) with ESMTP id 73364235 for ; Tue, 21 Nov 2017 14:22:42 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 26DE220994; Tue, 21 Nov 2017 08:22:42 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Tue, 21 Nov 2017 08:22:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fridaylinux.org; h=cc:date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=/pkGBkkbn6Es5Th00 mIkyQ3zs535jlTwAcseSdDxLIU=; b=kpLMSviVANRF+3l59+Qz/L/7YlwtNZ2De J6b2w0cHIU7RM3b4jUEOzArufDTD6N34YIZ9F3q8FXGB22ICqaGhiq/icMq95Q1U JcZQNXDSksncne+u2DvClD/N7pKYFNOXjKtZEiVrQjudaNYJvnqTnv8gEA8Tiocm xPXNRckmw9OA3udZVGyz9q7ihF3RqKOn6ZiAjI3t0leFjr3cLtkDNHOK3DlcyoVs Wx0eqmNi5pq81/PTjwqsEnbenMYpN4MJhDA2RybVfqGhPw3mTXpUeRnpe03JFaGf /RT1lID/BbYw7DW/Q4RVHGQhzp90cegdoUd9+E86kYRR41OUupUyQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=/pkGBkkbn6Es5Th00mIkyQ3zs535jlTwAcseSdDxLIU=; b=npT8iHbf dQ2hj6XuZocs8SjWca2/t07b8bl1daknYuIQrL6QNgl8zT22I2XvMXo3oZGb/1Aj 1I2mYwrdWonVI7Se4l7vKXBENf04ewPC2BmlKWb6n0NV38VIM8cDBA3R4zWgBRl1 shiP5gjf/auOCnAHgWCNxETmCEGQIZ8/1Y9uYUJSwIbm9MDJhDrMZU4x6/xiy65X +RHyn4E7vnrOG6tKqfJcyax+IiShn8bij2MtnhjcpBK0a+YiSZ+si3YxBv9oLWqb eHkNBZi5K82JlL4qfJUp0ZyVjuerOknef7jaF2NzBMMk1TKDquoRuGRS3RU7gYj/ Osho/FCw5UDVAg== X-ME-Sender: Received: from localhost.localdomain (unknown [180.158.62.0]) by mail.messagingengine.com (Postfix) with ESMTPA id EED3F243B9; Tue, 21 Nov 2017 08:22:38 -0500 (EST) From: Yuanhan Liu To: John Daley Cc: Aaron Conole , dpdk stable Date: Tue, 21 Nov 2017 21:16:32 +0800 Message-Id: <1511270333-31002-50-git-send-email-yliu@fridaylinux.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1511270333-31002-1-git-send-email-yliu@fridaylinux.org> References: <1511270333-31002-1-git-send-email-yliu@fridaylinux.org> Subject: [dpdk-stable] patch 'net/enic: fix multi-process operation' has been queued to stable release 17.08.1 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Nov 2017 13:22:42 -0000 Hi, FYI, your patch has been queued to stable release 17.08.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 11/24/17. So please shout if anyone has objections. Thanks. --yliu --- >>From 8dddd9ffeee9e9c4b03fbbf0cb02a8e2b187de12 Mon Sep 17 00:00:00 2001 From: John Daley Date: Mon, 11 Sep 2017 11:58:33 -0700 Subject: [PATCH] net/enic: fix multi-process operation [ upstream commit 0e804034dc9a5e27aa3bd9763457cd70e8970b81 ] - Use rte_malloc() instead of malloc() for the per device 'vdev' structure so that it can be shared across processes. - Only initialize the device if the process type is RTE_PROC_PRIMARY - Only allow the primary process to do queue setup, start/stop, promisc allmulticast, mac add/del, mtu. Fixes: fefed3d1e62c ("enic: new driver") Signed-off-by: John Daley Reviewed-by: Aaron Conole --- doc/guides/nics/features/enic.ini | 1 + drivers/net/enic/base/vnic_dev.c | 10 +++++++-- drivers/net/enic/enic_ethdev.c | 43 +++++++++++++++++++++++++++++++++++++++ drivers/net/enic/enic_main.c | 7 +++++++ 4 files changed, 59 insertions(+), 2 deletions(-) diff --git a/doc/guides/nics/features/enic.ini b/doc/guides/nics/features/enic.ini index 0de3ef5..498341f 100644 --- a/doc/guides/nics/features/enic.ini +++ b/doc/guides/nics/features/enic.ini @@ -25,6 +25,7 @@ L3 checksum offload = Y L4 checksum offload = Y Packet type parsing = Y Basic stats = Y +Multiprocess aware = Y BSD nic_uio = Y Linux UIO = Y Linux VFIO = Y diff --git a/drivers/net/enic/base/vnic_dev.c b/drivers/net/enic/base/vnic_dev.c index 49b3655..162e9c2 100644 --- a/drivers/net/enic/base/vnic_dev.c +++ b/drivers/net/enic/base/vnic_dev.c @@ -1063,7 +1063,7 @@ void vnic_dev_unregister(struct vnic_dev *vdev) vdev->free_consistent(vdev->priv, sizeof(struct vnic_devcmd_fw_info), vdev->fw_info, vdev->fw_info_pa); - kfree(vdev); + rte_free(vdev); } } @@ -1072,7 +1072,13 @@ struct vnic_dev *vnic_dev_register(struct vnic_dev *vdev, unsigned int num_bars) { if (!vdev) { - vdev = kzalloc(sizeof(struct vnic_dev), GFP_ATOMIC); + char name[NAME_MAX]; + snprintf((char *)name, sizeof(name), "%s-vnic", + pdev->device.name); + vdev = (struct vnic_dev *)rte_zmalloc_socket(name, + sizeof(struct vnic_dev), + RTE_CACHE_LINE_SIZE, + pdev->device.numa_node); if (!vdev) return NULL; } diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c index da8fec2..33a3f87 100644 --- a/drivers/net/enic/enic_ethdev.c +++ b/drivers/net/enic/enic_ethdev.c @@ -142,6 +142,10 @@ enicpmd_dev_filter_ctrl(struct rte_eth_dev *dev, static void enicpmd_dev_tx_queue_release(void *txq) { ENICPMD_FUNC_TRACE(); + + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return; + enic_free_wq(txq); } @@ -196,6 +200,9 @@ static int enicpmd_dev_tx_queue_setup(struct rte_eth_dev *eth_dev, int ret; struct enic *enic = pmd_priv(eth_dev); + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return -E_RTE_SECONDARY; + ENICPMD_FUNC_TRACE(); if (queue_idx >= ENIC_WQ_MAX) { dev_err(enic, @@ -272,6 +279,10 @@ static int enicpmd_dev_rx_queue_stop(struct rte_eth_dev *eth_dev, static void enicpmd_dev_rx_queue_release(void *rxq) { ENICPMD_FUNC_TRACE(); + + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return; + enic_free_rq(rxq); } @@ -310,6 +321,10 @@ static int enicpmd_dev_rx_queue_setup(struct rte_eth_dev *eth_dev, struct enic *enic = pmd_priv(eth_dev); ENICPMD_FUNC_TRACE(); + + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return -E_RTE_SECONDARY; + /* With Rx scatter support, two RQs are now used on VIC per RQ used * by the application. */ @@ -378,6 +393,9 @@ static int enicpmd_dev_configure(struct rte_eth_dev *eth_dev) int ret; struct enic *enic = pmd_priv(eth_dev); + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return -E_RTE_SECONDARY; + ENICPMD_FUNC_TRACE(); ret = enic_set_vnic_res(enic); if (ret) { @@ -404,6 +422,9 @@ static int enicpmd_dev_start(struct rte_eth_dev *eth_dev) { struct enic *enic = pmd_priv(eth_dev); + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return -E_RTE_SECONDARY; + ENICPMD_FUNC_TRACE(); return enic_enable(enic); } @@ -416,6 +437,9 @@ static void enicpmd_dev_stop(struct rte_eth_dev *eth_dev) struct rte_eth_link link; struct enic *enic = pmd_priv(eth_dev); + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return; + ENICPMD_FUNC_TRACE(); enic_disable(enic); memset(&link, 0, sizeof(link)); @@ -513,7 +537,11 @@ static void enicpmd_dev_promiscuous_enable(struct rte_eth_dev *eth_dev) { struct enic *enic = pmd_priv(eth_dev); + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return; + ENICPMD_FUNC_TRACE(); + enic->promisc = 1; enic_add_packet_filter(enic); } @@ -522,6 +550,9 @@ static void enicpmd_dev_promiscuous_disable(struct rte_eth_dev *eth_dev) { struct enic *enic = pmd_priv(eth_dev); + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return; + ENICPMD_FUNC_TRACE(); enic->promisc = 0; enic_add_packet_filter(enic); @@ -531,6 +562,9 @@ static void enicpmd_dev_allmulticast_enable(struct rte_eth_dev *eth_dev) { struct enic *enic = pmd_priv(eth_dev); + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return; + ENICPMD_FUNC_TRACE(); enic->allmulti = 1; enic_add_packet_filter(enic); @@ -540,6 +574,9 @@ static void enicpmd_dev_allmulticast_disable(struct rte_eth_dev *eth_dev) { struct enic *enic = pmd_priv(eth_dev); + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return; + ENICPMD_FUNC_TRACE(); enic->allmulti = 0; enic_add_packet_filter(enic); @@ -551,6 +588,9 @@ static int enicpmd_add_mac_addr(struct rte_eth_dev *eth_dev, { struct enic *enic = pmd_priv(eth_dev); + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return -E_RTE_SECONDARY; + ENICPMD_FUNC_TRACE(); return enic_set_mac_address(enic, mac_addr->addr_bytes); } @@ -559,6 +599,9 @@ static void enicpmd_remove_mac_addr(struct rte_eth_dev *eth_dev, uint32_t index) { struct enic *enic = pmd_priv(eth_dev); + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return; + ENICPMD_FUNC_TRACE(); enic_del_mac_address(enic, index); } diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c index 1d956cd..9b0439b 100644 --- a/drivers/net/enic/enic_main.c +++ b/drivers/net/enic/enic_main.c @@ -1181,6 +1181,9 @@ int enic_set_mtu(struct enic *enic, uint16_t new_mtu) old_mtu = eth_dev->data->mtu; config_mtu = enic->config.mtu; + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return -E_RTE_SECONDARY; + if (new_mtu > enic->max_mtu) { dev_err(enic, "MTU not updated: requested (%u) greater than max (%u)\n", @@ -1332,6 +1335,10 @@ int enic_probe(struct enic *enic) dev_debug(enic, " Initializing ENIC PMD\n"); + /* if this is a secondary process the hardware is already initialized */ + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return 0; + enic->bar0.vaddr = (void *)pdev->mem_resource[0].addr; enic->bar0.len = pdev->mem_resource[0].len; -- 2.7.4