ethdev: expose flow API error helper
[dpdk.git] / drivers / net / mlx4 / mlx4_flow.c
index 5616b83..018843b 100644 (file)
  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+/**
+ * @file
+ * Flow API operations for mlx4 driver.
+ */
+
 #include <arpa/inet.h>
 #include <assert.h>
 #include <errno.h>
@@ -686,7 +691,8 @@ mlx4_flow_prepare(struct priv *priv,
                                (const struct rte_flow_action_queue *)
                                actions->conf;
 
-                       if (!queue || (queue->index > (priv->rxqs_n - 1)))
+                       if (!queue || (queue->index >
+                                      (priv->dev->data->nb_rx_queues - 1)))
                                goto exit_action_not_supported;
                        action.queue = 1;
                } else {
@@ -836,7 +842,7 @@ mlx4_flow_create_action_queue(struct priv *priv,
        if (action->drop) {
                qp = priv->flow_drop_queue ? priv->flow_drop_queue->qp : NULL;
        } else {
-               struct rxq *rxq = (*priv->rxqs)[action->queue_id];
+               struct rxq *rxq = priv->dev->data->rx_queues[action->queue_id];
 
                qp = rxq->qp;
                rte_flow->qp = qp;
@@ -930,20 +936,10 @@ exit:
 }
 
 /**
- * @see rte_flow_isolate()
- *
- * Must be done before calling dev_configure().
- *
- * @param dev
- *   Pointer to the ethernet device structure.
- * @param enable
- *   Nonzero to enter isolated mode, attempt to leave it otherwise.
- * @param[out] error
- *   Perform verbose error reporting if not NULL. PMDs initialize this
- *   structure in case of error only.
+ * Configure isolated mode.
  *
- * @return
- *   0 on success, a negative value on error.
+ * @see rte_flow_isolate()
+ * @see rte_flow_ops
  */
 static int
 mlx4_flow_isolate(struct rte_eth_dev *dev,
@@ -952,14 +948,17 @@ mlx4_flow_isolate(struct rte_eth_dev *dev,
 {
        struct priv *priv = dev->data->dev_private;
 
-       if (priv->rxqs) {
-               rte_flow_error_set(error, ENOTSUP,
-                                  RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
-                                  NULL, "isolated mode must be set"
-                                  " before configuring the device");
-               return -rte_errno;
-       }
+       if (!!enable == !!priv->isolated)
+               return 0;
        priv->isolated = !!enable;
+       if (enable) {
+               mlx4_mac_addr_del(priv);
+       } else if (mlx4_mac_addr_add(priv) < 0) {
+               priv->isolated = 1;
+               return rte_flow_error_set(error, rte_errno,
+                                         RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+                                         NULL, "cannot leave isolated mode");
+       }
        return 0;
 }