net/mvpp2: align checking order
authorYuri Chipchev <yuric@marvell.com>
Wed, 27 Jan 2021 16:09:22 +0000 (18:09 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 29 Jan 2021 17:16:11 +0000 (18:16 +0100)
First check for 'isolated' and then for '!ppio'

Signed-off-by: Yuri Chipchev <yuric@marvell.com>
Reviewed-by: Liron Himi <lironh@marvell.com>
drivers/net/mvpp2/mrvl_ethdev.c

index e28dcc0..3c8eac2 100644 (file)
@@ -995,10 +995,10 @@ mrvl_promiscuous_enable(struct rte_eth_dev *dev)
        struct mrvl_priv *priv = dev->data->dev_private;
        int ret;
 
-       if (!priv->ppio)
-               return 0;
-
        if (priv->isolated)
+               return -ENOTSUP;
+
+       if (!priv->ppio)
                return 0;
 
        ret = pp2_ppio_set_promisc(priv->ppio, 1);
@@ -1025,10 +1025,10 @@ mrvl_allmulticast_enable(struct rte_eth_dev *dev)
        struct mrvl_priv *priv = dev->data->dev_private;
        int ret;
 
-       if (!priv->ppio)
-               return 0;
-
        if (priv->isolated)
+               return -ENOTSUP;
+
+       if (!priv->ppio)
                return 0;
 
        ret = pp2_ppio_set_mc_promisc(priv->ppio, 1);
@@ -1055,6 +1055,9 @@ mrvl_promiscuous_disable(struct rte_eth_dev *dev)
        struct mrvl_priv *priv = dev->data->dev_private;
        int ret;
 
+       if (priv->isolated)
+               return -ENOTSUP;
+
        if (!priv->ppio)
                return 0;
 
@@ -1082,6 +1085,9 @@ mrvl_allmulticast_disable(struct rte_eth_dev *dev)
        struct mrvl_priv *priv = dev->data->dev_private;
        int ret;
 
+       if (priv->isolated)
+               return -ENOTSUP;
+
        if (!priv->ppio)
                return 0;
 
@@ -1109,10 +1115,10 @@ mrvl_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
        char buf[RTE_ETHER_ADDR_FMT_SIZE];
        int ret;
 
-       if (!priv->ppio)
+       if (priv->isolated)
                return;
 
-       if (priv->isolated)
+       if (!priv->ppio)
                return;
 
        ret = pp2_ppio_remove_mac_addr(priv->ppio,
@@ -1150,13 +1156,13 @@ mrvl_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr,
        if (priv->isolated)
                return -ENOTSUP;
 
+       if (!priv->ppio)
+               return 0;
+
        if (index == 0)
                /* For setting index 0, mrvl_mac_addr_set() should be used.*/
                return -1;
 
-       if (!priv->ppio)
-               return 0;
-
        /*
         * Maximum number of uc addresses can be tuned via kernel module mvpp2x
         * parameter uc_filter_max. Maximum number of mc addresses is then
@@ -1197,12 +1203,12 @@ mrvl_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr)
        struct mrvl_priv *priv = dev->data->dev_private;
        int ret;
 
-       if (!priv->ppio)
-               return 0;
-
        if (priv->isolated)
                return -ENOTSUP;
 
+       if (!priv->ppio)
+               return 0;
+
        ret = pp2_ppio_set_mac_addr(priv->ppio, mac_addr->addr_bytes);
        if (ret) {
                char buf[RTE_ETHER_ADDR_FMT_SIZE];
@@ -1578,12 +1584,12 @@ 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;
-
        if (priv->isolated)
                return -ENOTSUP;
 
+       if (!priv->ppio)
+               return 0;
+
        return on ? pp2_ppio_add_vlan(priv->ppio, vlan_id) :
                    pp2_ppio_remove_vlan(priv->ppio, vlan_id);
 }