All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tomasz Duszynski <tdu@semihalf.com>
To: dev@dpdk.org
Cc: mw@semihalf.com, jck@semihalf.com, dima@marvell.com,
	nsamsono@marvell.com, jianbo.liu@arm.com,
	Tomasz Duszynski <tdu@semihalf.com>
Subject: [PATCH v3 4/7] net/mrvl: check if ppio is initialized
Date: Tue,  5 Dec 2017 10:39:19 +0100	[thread overview]
Message-ID: <1512466762-1982-5-git-send-email-tdu@semihalf.com> (raw)
In-Reply-To: <1512466762-1982-1-git-send-email-tdu@semihalf.com>

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 <tdu@semihalf.com>
Acked-by: Jianbo Liu <jianbo.liu@arm.com>
---
 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

  parent reply	other threads:[~2017-12-05  9:39 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-30 13:32 [PATCH 0/7] Sync with MUSDK-17.10 Tomasz Duszynski
2017-11-30 13:32 ` [PATCH 1/7] net/mrvl: sync compilation with musdk-17.10 Tomasz Duszynski
2017-12-01  3:29   ` Jianbo Liu
2017-12-01  9:03     ` Tomasz Duszynski
2017-11-30 13:32 ` [PATCH 2/7] net/mrvl: query link status using library API Tomasz Duszynski
2017-11-30 13:32 ` [PATCH 3/7] net/mrvl: do not enable port after setting MAC address Tomasz Duszynski
2017-11-30 13:32 ` [PATCH 4/7] net/mrvl: check if ppio is initialized Tomasz Duszynski
2017-11-30 13:32 ` [PATCH 5/7] net/mrvl: add extra error logs Tomasz Duszynski
2017-12-01  3:32   ` Jianbo Liu
2017-12-01  8:26     ` Tomasz Duszynski
2017-11-30 13:32 ` [PATCH 6/7] devtools/test-build: add MRVL NET PMD to test-build Tomasz Duszynski
2017-11-30 13:32 ` [PATCH 7/7] net/mrvl: update MRVL NET PMD documentation Tomasz Duszynski
2017-12-01 15:19 ` [PATCH 0/7] Sync with MUSDK-17.10 Tomasz Duszynski
2017-12-01 15:19   ` [PATCH 1/7] net/mrvl: sync compilation with musdk-17.10 Tomasz Duszynski
2017-12-01 15:19   ` [PATCH 2/7] net/mrvl: query link status using library API Tomasz Duszynski
2017-12-01 15:19   ` [PATCH 3/7] net/mrvl: do not enable port after setting MAC address Tomasz Duszynski
2017-12-01 15:19   ` [PATCH 4/7] net/mrvl: check if ppio is initialized Tomasz Duszynski
2017-12-01 15:19   ` [PATCH 5/7] net/mrvl: add extra error logs Tomasz Duszynski
2017-12-01 15:19   ` [PATCH 6/7] devtools/test-build: add MRVL NET PMD to test-build Tomasz Duszynski
2017-12-05  0:48     ` Ferruh Yigit
2017-12-05  8:38       ` Tomasz Duszynski
2017-12-01 15:19   ` [PATCH 7/7] net/mrvl: update MRVL NET PMD documentation Tomasz Duszynski
2017-12-04  2:25   ` [PATCH 0/7] Sync with MUSDK-17.10 Jianbo Liu
2017-12-05  9:39   ` [PATCH v3 " Tomasz Duszynski
2017-12-05  9:39     ` [PATCH v3 1/7] net/mrvl: sync compilation with musdk-17.10 Tomasz Duszynski
2017-12-05  9:39     ` [PATCH v3 2/7] net/mrvl: query link status using library API Tomasz Duszynski
2017-12-05  9:39     ` [PATCH v3 3/7] net/mrvl: do not enable port after setting MAC address Tomasz Duszynski
2017-12-05  9:39     ` Tomasz Duszynski [this message]
2017-12-05  9:39     ` [PATCH v3 5/7] net/mrvl: add extra error logs Tomasz Duszynski
2017-12-05  9:39     ` [PATCH v3 6/7] devtools/test-build: add MRVL NET PMD to test-build Tomasz Duszynski
2017-12-05  9:39     ` [PATCH v3 7/7] net/mrvl: update MRVL NET PMD documentation Tomasz Duszynski
2017-12-07  1:13     ` [PATCH v3 0/7] Sync with MUSDK-17.10 Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1512466762-1982-5-git-send-email-tdu@semihalf.com \
    --to=tdu@semihalf.com \
    --cc=dev@dpdk.org \
    --cc=dima@marvell.com \
    --cc=jck@semihalf.com \
    --cc=jianbo.liu@arm.com \
    --cc=mw@semihalf.com \
    --cc=nsamsono@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.