net/mlx5: prefix Tx structures and functions
[dpdk.git] / drivers / net / mlx5 / mlx5.c
index f0e1099..7aea5a4 100644 (file)
@@ -131,6 +131,52 @@ mlx5_getenv_int(const char *name)
        return atoi(val);
 }
 
+/**
+ * Verbs callback to allocate a memory. This function should allocate the space
+ * according to the size provided residing inside a huge page.
+ * Please note that all allocation must respect the alignment from libmlx5
+ * (i.e. currently sysconf(_SC_PAGESIZE)).
+ *
+ * @param[in] size
+ *   The size in bytes of the memory to allocate.
+ * @param[in] data
+ *   A pointer to the callback data.
+ *
+ * @return
+ *   a pointer to the allocate space.
+ */
+static void *
+mlx5_alloc_verbs_buf(size_t size, void *data)
+{
+       struct priv *priv = data;
+       void *ret;
+       size_t alignment = sysconf(_SC_PAGESIZE);
+
+       assert(data != NULL);
+       assert(!mlx5_is_secondary());
+       ret = rte_malloc_socket(__func__, size, alignment,
+                               priv->dev->device->numa_node);
+       DEBUG("Extern alloc size: %lu, align: %lu: %p", size, alignment, ret);
+       return ret;
+}
+
+/**
+ * Verbs callback to free a memory.
+ *
+ * @param[in] ptr
+ *   A pointer to the memory to free.
+ * @param[in] data
+ *   A pointer to the callback data.
+ */
+static void
+mlx5_free_verbs_buf(void *ptr, void *data __rte_unused)
+{
+       assert(data != NULL);
+       assert(!mlx5_is_secondary());
+       DEBUG("Extern free request: %p", ptr);
+       rte_free(ptr);
+}
+
 /**
  * DPDK callback to close the device.
  *
@@ -155,10 +201,6 @@ mlx5_dev_close(struct rte_eth_dev *dev)
        priv_mac_addrs_disable(priv);
        priv_destroy_hash_rxqs(priv);
 
-       /* Remove flow director elements. */
-       priv_fdir_disable(priv);
-       priv_fdir_delete_filters_list(priv);
-
        /* Prevent crashes when queues are still in use. */
        dev->rx_pkt_burst = removed_rx_burst;
        dev->tx_pkt_burst = removed_tx_burst;
@@ -166,14 +208,14 @@ mlx5_dev_close(struct rte_eth_dev *dev)
                /* XXX race condition if mlx5_rx_burst() is still running. */
                usleep(1000);
                for (i = 0; (i != priv->rxqs_n); ++i) {
-                       struct rxq *rxq = (*priv->rxqs)[i];
-                       struct rxq_ctrl *rxq_ctrl;
+                       struct mlx5_rxq_data *rxq = (*priv->rxqs)[i];
+                       struct mlx5_rxq_ctrl *rxq_ctrl;
 
                        if (rxq == NULL)
                                continue;
-                       rxq_ctrl = container_of(rxq, struct rxq_ctrl, rxq);
+                       rxq_ctrl = container_of(rxq, struct mlx5_rxq_ctrl, rxq);
                        (*priv->rxqs)[i] = NULL;
-                       rxq_cleanup(rxq_ctrl);
+                       mlx5_rxq_cleanup(rxq_ctrl);
                        rte_free(rxq_ctrl);
                }
                priv->rxqs_n = 0;
@@ -183,14 +225,14 @@ mlx5_dev_close(struct rte_eth_dev *dev)
                /* XXX race condition if mlx5_tx_burst() is still running. */
                usleep(1000);
                for (i = 0; (i != priv->txqs_n); ++i) {
-                       struct txq *txq = (*priv->txqs)[i];
-                       struct txq_ctrl *txq_ctrl;
+                       struct mlx5_txq_data *txq = (*priv->txqs)[i];
+                       struct mlx5_txq_ctrl *txq_ctrl;
 
                        if (txq == NULL)
                                continue;
-                       txq_ctrl = container_of(txq, struct txq_ctrl, txq);
+                       txq_ctrl = container_of(txq, struct mlx5_txq_ctrl, txq);
                        (*priv->txqs)[i] = NULL;
-                       txq_cleanup(txq_ctrl);
+                       mlx5_txq_cleanup(txq_ctrl);
                        rte_free(txq_ctrl);
                }
                priv->txqs_n = 0;
@@ -257,6 +299,18 @@ static const struct eth_dev_ops mlx5_dev_ops = {
        .rx_queue_intr_disable = mlx5_rx_intr_disable,
 };
 
+
+static const struct eth_dev_ops mlx5_dev_sec_ops = {
+       .stats_get = mlx5_stats_get,
+       .stats_reset = mlx5_stats_reset,
+       .xstats_get = mlx5_xstats_get,
+       .xstats_reset = mlx5_xstats_reset,
+       .xstats_get_names = mlx5_xstats_get_names,
+       .dev_infos_get = mlx5_dev_infos_get,
+       .rx_descriptor_status = mlx5_rx_descriptor_status,
+       .tx_descriptor_status = mlx5_tx_descriptor_status,
+};
+
 static struct {
        struct rte_pci_addr pci_addr; /* associated PCI address */
        uint32_t ports; /* physical ports bitfield. */
@@ -594,7 +648,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
                                goto error;
                        }
                        eth_dev->device = &pci_dev->device;
-                       eth_dev->dev_ops = NULL;
+                       eth_dev->dev_ops = &mlx5_dev_sec_ops;
                        priv = eth_dev->data->dev_private;
                        /* Receive command fd from primary process */
                        err = priv_socket_connect(priv);
@@ -661,6 +715,8 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
                }
 
                priv->ctx = ctx;
+               strncpy(priv->ibdev_path, priv->ctx->device->ibdev_path,
+                       sizeof(priv->ibdev_path));
                priv->device_attr = device_attr;
                priv->port = port;
                priv->pd = pd;
@@ -784,10 +840,6 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
                claim_zero(priv_mac_addr_add(priv, 0,
                                             (const uint8_t (*)[ETHER_ADDR_LEN])
                                             mac.addr_bytes));
-               /* Initialize FD filters list. */
-               err = fdir_init_filters_list(priv);
-               if (err)
-                       goto port_error;
 #ifndef NDEBUG
                {
                        char ifname[IF_NAMESIZE];
@@ -826,6 +878,15 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
                eth_dev->dev_ops = &mlx5_dev_ops;
                TAILQ_INIT(&priv->flows);
 
+               /* Hint libmlx5 to use PMD allocator for data plane resources */
+               struct mlx5dv_ctx_allocators alctr = {
+                       .alloc = &mlx5_alloc_verbs_buf,
+                       .free = &mlx5_free_verbs_buf,
+                       .data = priv,
+               };
+               mlx5dv_set_context_attr(ctx, MLX5DV_CTX_ATTR_BUF_ALLOCATORS,
+                                       (void *)((uintptr_t)&alctr));
+
                /* Bring Ethernet device up. */
                DEBUG("forcing Ethernet interface up");
                priv_set_flags(priv, ~IFF_UP, IFF_UP);