net/mlx5: implement CQ for Rx using DevX API
[dpdk.git] / drivers / net / mlx5 / mlx5_vlan.c
index fc1a91c..89983a4 100644 (file)
@@ -5,27 +5,9 @@
 
 #include <stddef.h>
 #include <errno.h>
-#include <assert.h>
 #include <stdint.h>
 #include <unistd.h>
 
-
-/*
- * Not needed by this file; included to work around the lack of off_t
- * definition for mlx5dv.h with unpatched rdma-core versions.
- */
-#include <sys/types.h>
-
-/* Verbs headers do not support -pedantic. */
-#ifdef PEDANTIC
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-#include <infiniband/mlx5dv.h>
-#include <infiniband/verbs.h>
-#ifdef PEDANTIC
-#pragma GCC diagnostic error "-Wpedantic"
-#endif
-
 #include <rte_ethdev_driver.h>
 #include <rte_common.h>
 #include <rte_malloc.h>
 
 #include <mlx5_glue.h>
 #include <mlx5_devx_cmds.h>
+#include <mlx5_nl.h>
+#include <mlx5_malloc.h>
 
 #include "mlx5.h"
 #include "mlx5_autoconf.h"
 #include "mlx5_rxtx.h"
-#include "mlx5_nl.h"
 #include "mlx5_utils.h"
 
 /**
@@ -61,7 +44,7 @@ mlx5_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
 
        DRV_LOG(DEBUG, "port %u %s VLAN filter ID %" PRIu16,
                dev->data->port_id, (on ? "enable" : "disable"), vlan_id);
-       assert(priv->vlan_filter_n <= RTE_DIM(priv->vlan_filter));
+       MLX5_ASSERT(priv->vlan_filter_n <= RTE_DIM(priv->vlan_filter));
        for (i = 0; (i != priv->vlan_filter_n); ++i)
                if (priv->vlan_filter[i] == vlan_id)
                        break;
@@ -71,7 +54,7 @@ mlx5_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
                return -rte_errno;
        }
        if (i < priv->vlan_filter_n) {
-               assert(priv->vlan_filter_n != 0);
+               MLX5_ASSERT(priv->vlan_filter_n != 0);
                /* Enabling an existing VLAN filter has no effect. */
                if (on)
                        goto out;
@@ -83,7 +66,7 @@ mlx5_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
                        (priv->vlan_filter_n - i));
                priv->vlan_filter[priv->vlan_filter_n] = 0;
        } else {
-               assert(i == priv->vlan_filter_n);
+               MLX5_ASSERT(i == priv->vlan_filter_n);
                /* Disabling an unknown VLAN filter has no effect. */
                if (!on)
                        goto out;
@@ -214,12 +197,12 @@ void mlx5_vlan_vmwa_release(struct rte_eth_dev *dev,
        struct mlx5_nl_vlan_vmwa_context *vmwa = priv->vmwa_context;
        struct mlx5_nl_vlan_dev *vlan_dev = &vmwa->vlan_dev[0];
 
-       assert(vlan->created);
-       assert(priv->vmwa_context);
+       MLX5_ASSERT(vlan->created);
+       MLX5_ASSERT(priv->vmwa_context);
        if (!vlan->created || !vmwa)
                return;
        vlan->created = 0;
-       assert(vlan_dev[vlan->tag].refcnt);
+       MLX5_ASSERT(vlan_dev[vlan->tag].refcnt);
        if (--vlan_dev[vlan->tag].refcnt == 0 &&
            vlan_dev[vlan->tag].ifindex) {
                mlx5_nl_vlan_vmwa_delete(vmwa, vlan_dev[vlan->tag].ifindex);
@@ -242,12 +225,12 @@ void mlx5_vlan_vmwa_acquire(struct rte_eth_dev *dev,
        struct mlx5_nl_vlan_vmwa_context *vmwa = priv->vmwa_context;
        struct mlx5_nl_vlan_dev *vlan_dev = &vmwa->vlan_dev[0];
 
-       assert(!vlan->created);
-       assert(priv->vmwa_context);
+       MLX5_ASSERT(!vlan->created);
+       MLX5_ASSERT(priv->vmwa_context);
        if (vlan->created || !vmwa)
                return;
        if (vlan_dev[vlan->tag].refcnt == 0) {
-               assert(!vlan_dev[vlan->tag].ifindex);
+               MLX5_ASSERT(!vlan_dev[vlan->tag].ifindex);
                vlan_dev[vlan->tag].ifindex =
                        mlx5_nl_vlan_vmwa_create(vmwa, vmwa->vf_ifindex,
                                                 vlan->tag);
@@ -289,7 +272,8 @@ mlx5_vlan_vmwa_init(struct rte_eth_dev *dev, uint32_t ifindex)
                 */
                return NULL;
        }
-       vmwa = rte_zmalloc(__func__, sizeof(*vmwa), sizeof(uint32_t));
+       vmwa = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*vmwa), sizeof(uint32_t),
+                          SOCKET_ID_ANY);
        if (!vmwa) {
                DRV_LOG(WARNING,
                        "Can not allocate memory"
@@ -301,7 +285,7 @@ mlx5_vlan_vmwa_init(struct rte_eth_dev *dev, uint32_t ifindex)
                DRV_LOG(WARNING,
                        "Can not create Netlink socket"
                        " for VLAN workaround context");
-               rte_free(vmwa);
+               mlx5_free(vmwa);
                return NULL;
        }
        vmwa->vf_ifindex = ifindex;
@@ -324,5 +308,5 @@ void mlx5_vlan_vmwa_exit(struct mlx5_nl_vlan_vmwa_context *vmwa)
        }
        if (vmwa->nl_socket >= 0)
                close(vmwa->nl_socket);
-       rte_free(vmwa);
+       mlx5_free(vmwa);
 }