From patchwork Fri Jul 12 20:54:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 56416 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5C0EB1B9C6; Sat, 13 Jul 2019 00:15:36 +0200 (CEST) Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by dpdk.org (Postfix) with ESMTP id A7210493D for ; Sat, 13 Jul 2019 00:15:33 +0200 (CEST) Received: by mail-pf1-f194.google.com with SMTP id f17so901865pfn.6 for ; Fri, 12 Jul 2019 15:15:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wHTA/UahFFiXRjhF6KAoNij6ilTyeDmN4umCwpXLCNk=; b=rL9DmUAJuxN7sjBb0eVw4vw50+gnrMRYjJrga7srZr7MKLsZSujYJ6LnBbPFa36oCW Pg4u0+SckEoa9i2MolTTUBGfArNI3GKNQwUWjuEDN2BiYSNxOJixiWUX9Wrpfe6aLOBT j8RJMjd58xJjCwvV0t74nUsM3fW1+Br6tm9F/73SAdRKNVn702DavmoSeyarbUQn43g1 /qckOR/7k+jXZ7of4a9DagqtJWgI9j32GdGmJApSI6kn0LH/AiPajde2zTVQGegiUsNP 2GBAczCzWdc+DU5BdOwTxbIbZtTkDoB4bEeGzw4Kp6HRUxfzNTuDY6hK6Gh1IoP8IZTQ R3nQ== 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:mime-version:content-transfer-encoding; bh=wHTA/UahFFiXRjhF6KAoNij6ilTyeDmN4umCwpXLCNk=; b=Yj/eWE0IYQbRd4HcxsxuKRa7PfA0K7J10+uTGuAJH9zf1xP3QfZrAl/svRY34U6noT NWBC5J/lnxVi8/qH8nRfaFNlWeBwJDRJmtJZ0b0L1ZETsQeDE9QKFDJ35jegcDg6oCjW hIzQkN8Vm08c16AYzfL0ky+HW2Tx9j46QBJW51dloIT0L1vffRjt/taamzqwxoX5O7ie Wnhp44XtoWrV6RlLEUQmZTrD1mZpOG4GBUj/RsW5h7GHZh5E4qYT1/SR8wleTYjhjYjF 2YWLvTGRcYDe0QwzrgKVbW7SUEiaMuziH781ZJjbm3zbBG8C4i6MuPTdchW7rOnKiVDn rRIw== X-Gm-Message-State: APjAAAXHIln9yym3tsCL6Min+cLZCMHgaD8CEQuWAGqathMcNxMJc3EA IexmK2N1xh5iltH/KE4yPgY= X-Google-Smtp-Source: APXvYqzrGF2R8/g6MTZ6/bqc/HjRmlWhOdJkWydxyOoQYCIxlUPM4J4aKFdTAIaCA/xKR7tBzGhP6Q== X-Received: by 2002:a17:90a:2525:: with SMTP id j34mr15191994pje.11.1562969732840; Fri, 12 Jul 2019 15:15:32 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id q69sm16634170pjb.0.2019.07.12.15.15.31 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 12 Jul 2019 15:15:32 -0700 (PDT) From: Stephen Hemminger To: matan@mellanox.com, shahafs@mellanox.com, yskoh@mellanox.com, viacheslavo@mellanox.com Cc: dev@dpdk.org, sju@paloaltonetworks.com, Stephen Hemminger , stable@dpdk.org Date: Fri, 12 Jul 2019 13:54:24 -0700 Message-Id: <20190712205425.17781-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190712205425.17781-1-stephen@networkplumber.org> References: <20190712205425.17781-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 1/2] net/mlx4: fix crash in dev_info_get in secondary process X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" mlx4_dev_info_get calls mlx4_get_ifname, but mlx4_get_ifname uses priv->ctx which is not a valid pointer in a secondary process. The fix is to cache the value in primary. In the primary process, get and store the interface index of the device so that secondary process can see it. Bugzilla ID:320 Fixes: 61cbdd419478 ("net/mlx4: separate device control functions") Cc: stable@dpdk.org Reported-by: Suyang Ju Signed-off-by: Stephen Hemminger Acked-by: Matan Azrad --- drivers/net/mlx4/mlx4.c | 19 +++++++++---------- drivers/net/mlx4/mlx4.h | 1 + drivers/net/mlx4/mlx4_ethdev.c | 4 +--- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index 2e169b0887a7..bab2cadbe519 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -763,6 +763,7 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) }; unsigned int vf; int i; + char ifname[IF_NAMESIZE]; (void)pci_drv; err = mlx4_init_once(); @@ -1002,17 +1003,15 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) mac.addr_bytes[4], mac.addr_bytes[5]); /* Register MAC address. */ priv->mac[0] = mac; -#ifndef NDEBUG - { - char ifname[IF_NAMESIZE]; - - if (mlx4_get_ifname(priv, &ifname) == 0) - DEBUG("port %u ifname is \"%s\"", - priv->port, ifname); - else - DEBUG("port %u ifname is unknown", priv->port); + + if (mlx4_get_ifname(priv, &ifname) == 0) { + DEBUG("port %u ifname is \"%s\"", + priv->port, ifname); + priv->if_index = if_nametoindex(ifname); + } else { + DEBUG("port %u ifname is unknown", priv->port); } -#endif + /* Get actual MTU if possible. */ mlx4_mtu_get(priv, &priv->mtu); DEBUG("port %u MTU is %u", priv->port, priv->mtu); diff --git a/drivers/net/mlx4/mlx4.h b/drivers/net/mlx4/mlx4.h index cd0d637ac2bf..81b529ee8030 100644 --- a/drivers/net/mlx4/mlx4.h +++ b/drivers/net/mlx4/mlx4.h @@ -159,6 +159,7 @@ struct mlx4_priv { struct ibv_device_attr device_attr; /**< Device properties. */ struct ibv_pd *pd; /**< Protection Domain. */ /* Device properties. */ + unsigned int if_index; /**< Associated network device index */ uint16_t mtu; /**< Configured MTU. */ uint8_t port; /**< Physical port number. */ uint32_t started:1; /**< Device started, flows enabled. */ diff --git a/drivers/net/mlx4/mlx4_ethdev.c b/drivers/net/mlx4/mlx4_ethdev.c index ceef921620a8..5d28c0116d21 100644 --- a/drivers/net/mlx4/mlx4_ethdev.c +++ b/drivers/net/mlx4/mlx4_ethdev.c @@ -616,7 +616,6 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info) { struct mlx4_priv *priv = dev->data->dev_private; unsigned int max; - char ifname[IF_NAMESIZE]; /* FIXME: we should ask the device for these values. */ info->min_rx_bufsize = 32; @@ -637,8 +636,7 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info) info->rx_queue_offload_capa = mlx4_get_rx_queue_offloads(priv); info->rx_offload_capa = (mlx4_get_rx_port_offloads(priv) | info->rx_queue_offload_capa); - if (mlx4_get_ifname(priv, &ifname) == 0) - info->if_index = if_nametoindex(ifname); + info->if_index = priv->if_index; info->hash_key_size = MLX4_RSS_HASH_KEY_SIZE; info->speed_capa = ETH_LINK_SPEED_1G | From patchwork Fri Jul 12 20:54:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 56417 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C0EF51B9D6; Sat, 13 Jul 2019 00:15:38 +0200 (CEST) Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by dpdk.org (Postfix) with ESMTP id A8047493D for ; Sat, 13 Jul 2019 00:15:34 +0200 (CEST) Received: by mail-pf1-f196.google.com with SMTP id r7so4895038pfl.3 for ; Fri, 12 Jul 2019 15:15:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=54EOHvWBIhAMDoysqV18ltcmurAzdmDB+sntQ/SnKXc=; b=q8izaBv+BQe3Vj27Itord8GJFSFZ+H7u3XHxIRBU8qlezZQkbnZm7d5JjhdXCQSTr7 0TCzpBMuKn6cP2+SqraDBGTTAZLp+cfAi4zeXdoRImgm/qpJVNxmtPrlFN1IicFabH2+ 1Ikz1YxD7Nqbb/xIymKYjorCriAmw2evjwqQLJRVjC7yXdqSXRp0zzTim5X4DJkjPuYh qkyXyQC0x8JV178ogqJgw5Xem12XuRcjCfzG9bBJOD6lqk0eKaUUmXKGGl3gpYxm0IKi hsynir76d7+JxmjBowK/Zk03vXcXmORYbeC+0yodENRTQY10+08ogx1kQkooGDaumDo5 GE8g== 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:mime-version:content-transfer-encoding; bh=54EOHvWBIhAMDoysqV18ltcmurAzdmDB+sntQ/SnKXc=; b=KcAi0RbG0AczsxGHfIWA4CkMEBb6VH46widXxDfkg6Kk/RMZxYr5BbUYOuxAnSS11H bZRmAtfC/cevviXjk6T3ZoKN2iqXcLEmpGs5h7V43XD2PrW1rX2qcRLSPw8nGSOB2Con EPiZy44SoPKZrR9Kf/6pD7oaXr1wFGW2HiHN4qdSlG/enep4FscvGrqyRPLsr0UyevDV SFV32CsWWF1jXSA+8it11D+TMp2/5Bgi8uxIcbmILLj4+sBQccx4WZieVdHDC0Wls2+B 8JXRsmX9qfBWaWTFEYwR1OoZFUHsthhDVRQmS4G1BWLGK4ZdnULrKsoJigchAZMeK5y4 UVgw== X-Gm-Message-State: APjAAAVUfcjqAM2x1kSQCFJ6TWD6FugmChkyLu+b6NKTlwXcr1Na1CZz RF0aIIhspZjMQCqM+icr7jE= X-Google-Smtp-Source: APXvYqyQtWaPeLAno8aTJ+O4HWnoa7/L2gQIYNZ0R+kCeHR+F0QcMSgrhsoek4JIpXzIVxzGli2e4A== X-Received: by 2002:a63:3f84:: with SMTP id m126mr13900380pga.213.1562969733813; Fri, 12 Jul 2019 15:15:33 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id q69sm16634170pjb.0.2019.07.12.15.15.32 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 12 Jul 2019 15:15:33 -0700 (PDT) From: Stephen Hemminger To: matan@mellanox.com, shahafs@mellanox.com, yskoh@mellanox.com, viacheslavo@mellanox.com Cc: dev@dpdk.org, sju@paloaltonetworks.com, Stephen Hemminger Date: Fri, 12 Jul 2019 13:54:25 -0700 Message-Id: <20190712205425.17781-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190712205425.17781-1-stephen@networkplumber.org> References: <20190712205425.17781-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 2/2] net/mlx5: fix crash in dev_info_get in secondary process X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" mlx5_dev_info_get calls mlx5_get_ifname, but mlx5_get_ifname uses priv->ctx which is not a valid pointer in a secondary process. The fix is to cache the value in primary. In the primary process, get and store the interface index of the device so that secondary process can see it. Fixes: e60fbd5b24fc ("mlx5: add device configure/start/stop") Signed-off-by: Stephen Hemminger --- drivers/net/mlx5/mlx5.c | 17 ++++++++--------- drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_ethdev.c | 4 +--- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index d93f92db56b5..27c5ef9b1763 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -1105,6 +1105,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, int own_domain_id = 0; uint16_t port_id; unsigned int i; + char ifname[IF_NAMESIZE]; /* Determine if this port representor is supposed to be spawned. */ if (switch_info->representor && dpdk_dev->devargs) { @@ -1479,18 +1480,16 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, mac.addr_bytes[0], mac.addr_bytes[1], mac.addr_bytes[2], mac.addr_bytes[3], mac.addr_bytes[4], mac.addr_bytes[5]); -#ifndef NDEBUG - { - char ifname[IF_NAMESIZE]; - if (mlx5_get_ifname(eth_dev, &ifname) == 0) - DRV_LOG(DEBUG, "port %u ifname is \"%s\"", + if (mlx5_get_ifname(eth_dev, &ifname) == 0) { + priv->if_index = if_nametoindex(ifname); + DRV_LOG(DEBUG, "port %u ifname is \"%s\"", eth_dev->data->port_id, ifname); - else - DRV_LOG(DEBUG, "port %u ifname is unknown", - eth_dev->data->port_id); + } else { + DRV_LOG(DEBUG, "port %u ifname is unknown", + eth_dev->data->port_id); } -#endif + /* Get actual MTU if possible. */ err = mlx5_get_mtu(eth_dev, &priv->mtu); if (err) { diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 5af3f413cdcb..a06ffd444255 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -342,6 +342,7 @@ struct mlx5_priv { uint16_t vlan_filter[MLX5_MAX_VLAN_IDS]; /* VLAN filters table. */ unsigned int vlan_filter_n; /* Number of configured VLAN filters. */ /* Device properties. */ + unsigned int if_index; /* Associated kernel network device index. */ uint16_t mtu; /* Configured MTU. */ unsigned int isolated:1; /* Whether isolated mode is enabled. */ unsigned int representor:1; /* Device is a port representor. */ diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c index eeefe4df3cd4..41e58db5e573 100644 --- a/drivers/net/mlx5/mlx5_ethdev.c +++ b/drivers/net/mlx5/mlx5_ethdev.c @@ -605,7 +605,6 @@ mlx5_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info) struct mlx5_priv *priv = dev->data->dev_private; struct mlx5_dev_config *config = &priv->config; unsigned int max; - char ifname[IF_NAMESIZE]; /* FIXME: we should ask the device for these values. */ info->min_rx_bufsize = 32; @@ -626,8 +625,7 @@ mlx5_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info) info->rx_offload_capa = (mlx5_get_rx_port_offloads() | info->rx_queue_offload_capa); info->tx_offload_capa = mlx5_get_tx_port_offloads(dev); - if (mlx5_get_ifname(dev, &ifname) == 0) - info->if_index = if_nametoindex(ifname); + info->if_index = priv->if_index; info->reta_size = priv->reta_idx_n ? priv->reta_idx_n : config->ind_table_max_size; info->hash_key_size = MLX5_RSS_HASH_KEY_LEN;