net/i40e: remove redundant queue id checks
authorFerruh Yigit <ferruh.yigit@intel.com>
Wed, 18 Jul 2018 12:35:23 +0000 (13:35 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 23 Jul 2018 21:55:26 +0000 (23:55 +0200)
remove queue id checks from dev_ops
i40e_dev_[rx/tx]_queue_[start/stop]
i40evf_dev_[rx/tx]_queue_[start/stop]

queue id checks already done by ethdev APIs that are calling these
dev_ops

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
drivers/net/i40e/i40e_ethdev_vf.c
drivers/net/i40e/i40e_rxtx.c

index 3796c91..001c301 100644 (file)
@@ -1583,37 +1583,35 @@ static int
 i40evf_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
 {
        struct i40e_rx_queue *rxq;
-       int err = 0;
+       int err;
        struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
        PMD_INIT_FUNC_TRACE();
 
-       if (rx_queue_id < dev->data->nb_rx_queues) {
-               rxq = dev->data->rx_queues[rx_queue_id];
+       rxq = dev->data->rx_queues[rx_queue_id];
 
-               err = i40e_alloc_rx_queue_mbufs(rxq);
-               if (err) {
-                       PMD_DRV_LOG(ERR, "Failed to allocate RX queue mbuf");
-                       return err;
-               }
-
-               rte_wmb();
+       err = i40e_alloc_rx_queue_mbufs(rxq);
+       if (err) {
+               PMD_DRV_LOG(ERR, "Failed to allocate RX queue mbuf");
+               return err;
+       }
 
-               /* Init the RX tail register. */
-               I40E_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
-               I40EVF_WRITE_FLUSH(hw);
+       rte_wmb();
 
-               /* Ready to switch the queue on */
-               err = i40evf_switch_queue(dev, TRUE, rx_queue_id, TRUE);
+       /* Init the RX tail register. */
+       I40E_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
+       I40EVF_WRITE_FLUSH(hw);
 
-               if (err)
-                       PMD_DRV_LOG(ERR, "Failed to switch RX queue %u on",
-                                   rx_queue_id);
-               else
-                       dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
+       /* Ready to switch the queue on */
+       err = i40evf_switch_queue(dev, TRUE, rx_queue_id, TRUE);
+       if (err) {
+               PMD_DRV_LOG(ERR, "Failed to switch RX queue %u on",
+                           rx_queue_id);
+               return err;
        }
+       dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
 
-       return err;
+       return 0;
 }
 
 static int
@@ -1622,45 +1620,39 @@ i40evf_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
        struct i40e_rx_queue *rxq;
        int err;
 
-       if (rx_queue_id < dev->data->nb_rx_queues) {
-               rxq = dev->data->rx_queues[rx_queue_id];
-
-               err = i40evf_switch_queue(dev, TRUE, rx_queue_id, FALSE);
-
-               if (err) {
-                       PMD_DRV_LOG(ERR, "Failed to switch RX queue %u off",
-                                   rx_queue_id);
-                       return err;
-               }
+       rxq = dev->data->rx_queues[rx_queue_id];
 
-               i40e_rx_queue_release_mbufs(rxq);
-               i40e_reset_rx_queue(rxq);
-               dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
+       err = i40evf_switch_queue(dev, TRUE, rx_queue_id, FALSE);
+       if (err) {
+               PMD_DRV_LOG(ERR, "Failed to switch RX queue %u off",
+                           rx_queue_id);
+               return err;
        }
 
+       i40e_rx_queue_release_mbufs(rxq);
+       i40e_reset_rx_queue(rxq);
+       dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
+
        return 0;
 }
 
 static int
 i40evf_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
 {
-       int err = 0;
+       int err;
 
        PMD_INIT_FUNC_TRACE();
 
-       if (tx_queue_id < dev->data->nb_tx_queues) {
-
-               /* Ready to switch the queue on */
-               err = i40evf_switch_queue(dev, FALSE, tx_queue_id, TRUE);
-
-               if (err)
-                       PMD_DRV_LOG(ERR, "Failed to switch TX queue %u on",
-                                   tx_queue_id);
-               else
-                       dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
+       /* Ready to switch the queue on */
+       err = i40evf_switch_queue(dev, FALSE, tx_queue_id, TRUE);
+       if (err) {
+               PMD_DRV_LOG(ERR, "Failed to switch TX queue %u on",
+                           tx_queue_id);
+               return err;
        }
+       dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
 
-       return err;
+       return 0;
 }
 
 static int
@@ -1669,22 +1661,19 @@ i40evf_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
        struct i40e_tx_queue *txq;
        int err;
 
-       if (tx_queue_id < dev->data->nb_tx_queues) {
-               txq = dev->data->tx_queues[tx_queue_id];
-
-               err = i40evf_switch_queue(dev, FALSE, tx_queue_id, FALSE);
+       txq = dev->data->tx_queues[tx_queue_id];
 
-               if (err) {
-                       PMD_DRV_LOG(ERR, "Failed to switch TX queue %u off",
-                                   tx_queue_id);
-                       return err;
-               }
-
-               i40e_tx_queue_release_mbufs(txq);
-               i40e_reset_tx_queue(txq);
-               dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
+       err = i40evf_switch_queue(dev, FALSE, tx_queue_id, FALSE);
+       if (err) {
+               PMD_DRV_LOG(ERR, "Failed to switch TX queue %u off",
+                           tx_queue_id);
+               return err;
        }
 
+       i40e_tx_queue_release_mbufs(txq);
+       i40e_reset_tx_queue(txq);
+       dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
+
        return 0;
 }
 
index 65518ad..59a6a8a 100644 (file)
@@ -1531,38 +1531,36 @@ int
 i40e_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
 {
        struct i40e_rx_queue *rxq;
-       int err = -1;
+       int err;
        struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
        PMD_INIT_FUNC_TRACE();
 
-       if (rx_queue_id < dev->data->nb_rx_queues) {
-               rxq = dev->data->rx_queues[rx_queue_id];
-
-               err = i40e_alloc_rx_queue_mbufs(rxq);
-               if (err) {
-                       PMD_DRV_LOG(ERR, "Failed to allocate RX queue mbuf");
-                       return err;
-               }
+       rxq = dev->data->rx_queues[rx_queue_id];
 
-               rte_wmb();
+       err = i40e_alloc_rx_queue_mbufs(rxq);
+       if (err) {
+               PMD_DRV_LOG(ERR, "Failed to allocate RX queue mbuf");
+               return err;
+       }
 
-               /* Init the RX tail regieter. */
-               I40E_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
+       rte_wmb();
 
-               err = i40e_switch_rx_queue(hw, rxq->reg_idx, TRUE);
+       /* Init the RX tail regieter. */
+       I40E_PCI_REG_WRITE(rxq->qrx_tail, rxq->nb_rx_desc - 1);
 
-               if (err) {
-                       PMD_DRV_LOG(ERR, "Failed to switch RX queue %u on",
-                                   rx_queue_id);
+       err = i40e_switch_rx_queue(hw, rxq->reg_idx, TRUE);
+       if (err) {
+               PMD_DRV_LOG(ERR, "Failed to switch RX queue %u on",
+                           rx_queue_id);
 
-                       i40e_rx_queue_release_mbufs(rxq);
-                       i40e_reset_rx_queue(rxq);
-               } else
-                       dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
+               i40e_rx_queue_release_mbufs(rxq);
+               i40e_reset_rx_queue(rxq);
+               return err;
        }
+       dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
 
-       return err;
+       return 0;
 }
 
 int
@@ -1572,24 +1570,21 @@ i40e_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
        int err;
        struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-       if (rx_queue_id < dev->data->nb_rx_queues) {
-               rxq = dev->data->rx_queues[rx_queue_id];
+       rxq = dev->data->rx_queues[rx_queue_id];
 
-               /*
-               * rx_queue_id is queue id application refers to, while
-               * rxq->reg_idx is the real queue index.
-               */
-               err = i40e_switch_rx_queue(hw, rxq->reg_idx, FALSE);
-
-               if (err) {
-                       PMD_DRV_LOG(ERR, "Failed to switch RX queue %u off",
-                                   rx_queue_id);
-                       return err;
-               }
-               i40e_rx_queue_release_mbufs(rxq);
-               i40e_reset_rx_queue(rxq);
-               dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
+       /*
+        * rx_queue_id is queue id application refers to, while
+        * rxq->reg_idx is the real queue index.
+        */
+       err = i40e_switch_rx_queue(hw, rxq->reg_idx, FALSE);
+       if (err) {
+               PMD_DRV_LOG(ERR, "Failed to switch RX queue %u off",
+                           rx_queue_id);
+               return err;
        }
+       i40e_rx_queue_release_mbufs(rxq);
+       i40e_reset_rx_queue(rxq);
+       dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
 
        return 0;
 }
@@ -1597,28 +1592,27 @@ i40e_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
 int
 i40e_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
 {
-       int err = -1;
+       int err;
        struct i40e_tx_queue *txq;
        struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
        PMD_INIT_FUNC_TRACE();
 
-       if (tx_queue_id < dev->data->nb_tx_queues) {
-               txq = dev->data->tx_queues[tx_queue_id];
+       txq = dev->data->tx_queues[tx_queue_id];
 
-               /*
-               * tx_queue_id is queue id application refers to, while
-               * rxq->reg_idx is the real queue index.
-               */
-               err = i40e_switch_tx_queue(hw, txq->reg_idx, TRUE);
-               if (err)
-                       PMD_DRV_LOG(ERR, "Failed to switch TX queue %u on",
-                                   tx_queue_id);
-               else
-                       dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
+       /*
+        * tx_queue_id is queue id application refers to, while
+        * rxq->reg_idx is the real queue index.
+        */
+       err = i40e_switch_tx_queue(hw, txq->reg_idx, TRUE);
+       if (err) {
+               PMD_DRV_LOG(ERR, "Failed to switch TX queue %u on",
+                           tx_queue_id);
+               return err;
        }
+       dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
 
-       return err;
+       return 0;
 }
 
 int
@@ -1628,26 +1622,23 @@ i40e_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
        int err;
        struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
-       if (tx_queue_id < dev->data->nb_tx_queues) {
-               txq = dev->data->tx_queues[tx_queue_id];
+       txq = dev->data->tx_queues[tx_queue_id];
 
-               /*
-               * tx_queue_id is queue id application refers to, while
-               * txq->reg_idx is the real queue index.
-               */
-               err = i40e_switch_tx_queue(hw, txq->reg_idx, FALSE);
-
-               if (err) {
-                       PMD_DRV_LOG(ERR, "Failed to switch TX queue %u of",
-                                   tx_queue_id);
-                       return err;
-               }
-
-               i40e_tx_queue_release_mbufs(txq);
-               i40e_reset_tx_queue(txq);
-               dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
+       /*
+        * tx_queue_id is queue id application refers to, while
+        * txq->reg_idx is the real queue index.
+        */
+       err = i40e_switch_tx_queue(hw, txq->reg_idx, FALSE);
+       if (err) {
+               PMD_DRV_LOG(ERR, "Failed to switch TX queue %u of",
+                           tx_queue_id);
+               return err;
        }
 
+       i40e_tx_queue_release_mbufs(txq);
+       i40e_reset_tx_queue(txq);
+       dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
+
        return 0;
 }