From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf0-f67.google.com (mail-lf0-f67.google.com [209.85.215.67]) by dpdk.org (Postfix) with ESMTP id DDE6A7D52 for ; Tue, 5 Dec 2017 10:39:40 +0100 (CET) Received: by mail-lf0-f67.google.com with SMTP id 74so22495407lfs.0 for ; Tue, 05 Dec 2017 01:39:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=z/fjWmy/KoHyrEhqOkoPdkvhGrcFqLPRiixTF9EgVE0=; b=hn9U1bm7eMuV/sfkvASUyUbQxL4275BqTFuT4fll5WgGeS5VB6RC9H9KG6bXz2/Xoa eCdwqB8vOoYdWFQzVyvV4kgX/d1XcoyfXSgBhwOUJAnqlVX/12zJ7IgwDdE5spRFg/eW QeUoDo5amDAUqv0eOmzaKqdhKBJk5tGe2T7DAXFnq94MzpOBhaldVDgRaAwJpc1c5oXS blVXAkuFiagl4AbOAhD31PUw0cWPM5ncDg9BvXvT6nzvSrdy41RHET72t6V8nIZiD4Y/ 2k8ws+t1aClJmdNuOKxVKaHkMaBUUC5MQJyqCBSR5mFhS8V6c+oJ0V/y/WB6IegJ+gxj J2CQ== 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; bh=z/fjWmy/KoHyrEhqOkoPdkvhGrcFqLPRiixTF9EgVE0=; b=kS5gGoNj/ZWeXLoHiMwVrBoS6wE8KOdB3AoKM3u20YKfSH03AFk1OGpI8hhxpyDPh/ Y3QOceIfdJmtIATJtfiAYCZDrOkozlkI4b3YOdC5f6dpd7d5JE9vlV2a1RPnepE1+kIS bBdh2P3/BDhJ9yZ4uM+exBI70SbkEMSlMr0cEiEePTF3pyxW0v7PzRWLsAYSSUKOkf8L LI20zTn6ariAMAQZqBwb8aKmAGfcViRAVDVGoK+xlLp696qtK1hdnua5A5WdpIvBVmkc CCsVFEIf4uhaZWwGltHDbPaN57HOsauAvYIXEdt+XOTR2Ly26fcjs1rvJFkR7otgK3HF FPBg== X-Gm-Message-State: AJaThX5ix6gLtKLFYq4YgHuyjt4JU0uC1sddIbNwQIX+42XLYF7OiHuT XsH9omLC2UiGY/kiqi8Cn7wCH9+FxVw= X-Google-Smtp-Source: AGs4zMbP05c8k9SvnSetnbd1/pTQa11S5+JDoR26IFlkTaSJzuN8QPt7HykmuaBkNNl0BEO4RZVDmQ== X-Received: by 10.46.4.16 with SMTP id 16mr10626047lje.4.1512466780321; Tue, 05 Dec 2017 01:39:40 -0800 (PST) Received: from tdu.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id p5sm3334975ljc.7.2017.12.05.01.39.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Dec 2017 01:39:39 -0800 (PST) From: Tomasz Duszynski To: dev@dpdk.org Cc: mw@semihalf.com, jck@semihalf.com, dima@marvell.com, nsamsono@marvell.com, jianbo.liu@arm.com, Tomasz Duszynski Date: Tue, 5 Dec 2017 10:39:19 +0100 Message-Id: <1512466762-1982-5-git-send-email-tdu@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1512466762-1982-1-git-send-email-tdu@semihalf.com> References: <1512141592-16695-1-git-send-email-tdu@semihalf.com> <1512466762-1982-1-git-send-email-tdu@semihalf.com> Subject: [dpdk-dev] [PATCH v3 4/7] net/mrvl: check if ppio is initialized 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: , X-List-Received-Date: Tue, 05 Dec 2017 09:39:41 -0000 Uninitialized ppio cannot be passed to MUSDK library routines as application will crash. Fix this by first checking whether ppio has been initialized. Signed-off-by: Tomasz Duszynski Acked-by: Jianbo Liu --- drivers/net/mrvl/mrvl_ethdev.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/drivers/net/mrvl/mrvl_ethdev.c b/drivers/net/mrvl/mrvl_ethdev.c index c44a2bc..40f2ead 100644 --- a/drivers/net/mrvl/mrvl_ethdev.c +++ b/drivers/net/mrvl/mrvl_ethdev.c @@ -324,6 +324,9 @@ mrvl_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) if (mtu < ETHER_MIN_MTU || mru > MRVL_PKT_SIZE_MAX) return -EINVAL; + if (!priv->ppio) + return -EPERM; + ret = pp2_ppio_set_mru(priv->ppio, mru); if (ret) return ret; @@ -346,6 +349,9 @@ mrvl_dev_set_link_up(struct rte_eth_dev *dev) struct mrvl_priv *priv = dev->data->dev_private; int ret; + if (!priv->ppio) + return -EPERM; + ret = pp2_ppio_enable(priv->ppio); if (ret) return ret; @@ -378,6 +384,9 @@ mrvl_dev_set_link_down(struct rte_eth_dev *dev) { struct mrvl_priv *priv = dev->data->dev_private; + if (!priv->ppio) + return -EPERM; + return pp2_ppio_disable(priv->ppio); } @@ -624,6 +633,9 @@ mrvl_link_update(struct rte_eth_dev *dev, int wait_to_complete __rte_unused) struct ifreq req; int ret, fd, link_up; + if (!priv->ppio) + return -EPERM; + edata.cmd = ETHTOOL_GSET; strcpy(req.ifr_name, dev->data->name); @@ -680,6 +692,9 @@ mrvl_promiscuous_enable(struct rte_eth_dev *dev) struct mrvl_priv *priv = dev->data->dev_private; int ret; + if (!priv->ppio) + return; + ret = pp2_ppio_set_promisc(priv->ppio, 1); if (ret) RTE_LOG(ERR, PMD, "Failed to enable promiscuous mode\n"); @@ -697,6 +712,9 @@ mrvl_allmulticast_enable(struct rte_eth_dev *dev) struct mrvl_priv *priv = dev->data->dev_private; int ret; + if (!priv->ppio) + return; + ret = pp2_ppio_set_mc_promisc(priv->ppio, 1); if (ret) RTE_LOG(ERR, PMD, "Failed enable all-multicast mode\n"); @@ -714,6 +732,9 @@ mrvl_promiscuous_disable(struct rte_eth_dev *dev) struct mrvl_priv *priv = dev->data->dev_private; int ret; + if (!priv->ppio) + return; + ret = pp2_ppio_set_promisc(priv->ppio, 0); if (ret) RTE_LOG(ERR, PMD, "Failed to disable promiscuous mode\n"); @@ -731,6 +752,9 @@ mrvl_allmulticast_disable(struct rte_eth_dev *dev) struct mrvl_priv *priv = dev->data->dev_private; int ret; + if (!priv->ppio) + return; + ret = pp2_ppio_set_mc_promisc(priv->ppio, 0); if (ret) RTE_LOG(ERR, PMD, "Failed to disable all-multicast mode\n"); @@ -751,6 +775,9 @@ mrvl_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index) char buf[ETHER_ADDR_FMT_SIZE]; int ret; + if (!priv->ppio) + return; + ret = pp2_ppio_remove_mac_addr(priv->ppio, dev->data->mac_addrs[index].addr_bytes); if (ret) { @@ -787,6 +814,9 @@ mrvl_mac_addr_add(struct rte_eth_dev *dev, struct ether_addr *mac_addr, /* For setting index 0, mrvl_mac_addr_set() should be used.*/ return -1; + if (!priv->ppio) + return -EPERM; + /* * Maximum number of uc addresses can be tuned via kernel module mvpp2x * parameter uc_filter_max. Maximum number of mc addresses is then @@ -824,6 +854,9 @@ mrvl_mac_addr_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr) struct mrvl_priv *priv = dev->data->dev_private; int ret; + if (!priv->ppio) + return; + ret = pp2_ppio_set_mac_addr(priv->ppio, mac_addr->addr_bytes); if (ret) { char buf[ETHER_ADDR_FMT_SIZE]; @@ -851,6 +884,9 @@ mrvl_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) uint64_t drop_mac = 0; unsigned int i, idx, ret; + if (!priv->ppio) + return -EPERM; + for (i = 0; i < dev->data->nb_rx_queues; i++) { struct mrvl_rxq *rxq = dev->data->rx_queues[i]; struct pp2_ppio_inq_statistics rx_stats; @@ -943,6 +979,9 @@ mrvl_stats_reset(struct rte_eth_dev *dev) struct mrvl_priv *priv = dev->data->dev_private; int i; + if (!priv->ppio) + return; + for (i = 0; i < dev->data->nb_rx_queues; i++) { struct mrvl_rxq *rxq = dev->data->rx_queues[i]; @@ -1099,6 +1138,9 @@ mrvl_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on) { struct mrvl_priv *priv = dev->data->dev_private; + if (!priv->ppio) + return -EPERM; + return on ? pp2_ppio_add_vlan(priv->ppio, vlan_id) : pp2_ppio_remove_vlan(priv->ppio, vlan_id); } -- 2.7.4