void mlx4_cleanup_cq_table(struct mlx4_dev *dev) { if (mlx4_is_slave(dev)) return; /* Nothing to do to clean up radix_tree */ mlx4_bitmap_cleanup(&mlx4_priv(dev)->cq_table.bitmap); }
void mlx4_hugetlb_mem_free(struct mlx4_hugetlb_mem *hmem) { mlx4_bitmap_cleanup(&hmem->bitmap); if (shmdt((const void *)hmem->shmaddr) != 0) { if (mlx4_trace) perror("Detach shm failure"); } free(hmem); }
void mlx4_cleanup_xrcd_table(struct mlx4_dev *dev) { mlx4_bitmap_cleanup(&mlx4_priv(dev)->xrcd_bitmap); }
void mlx4_cleanup_cq_table(struct mlx4_dev *dev) { /* Nothing to do to clean up radix_tree */ mlx4_bitmap_cleanup(&mlx4_priv(dev)->cq_table.bitmap); }
void mlx4_cleanup_srq_table(struct mlx4_dev *dev) { mlx4_bitmap_cleanup(&mlx4_priv(dev)->srq_table.bitmap); }
void mlx4_cleanup_srq_table(struct mlx4_dev *dev) { if (mlx4_is_slave(dev)) return; mlx4_bitmap_cleanup(&mlx4_priv(dev)->srq_table.bitmap); }
void mlx4_cleanup_uar_table(struct mlx4_dev *dev) { if (mlx4_is_master(dev)) return; mlx4_bitmap_cleanup(&mlx4_priv(dev)->uar_table.bitmap); }
/* void mlx4_free_eq_table(struct mlx4_priv *priv) { kfree(mlx4_priv(&priv->dev)->eq_table.eq); } */ int mlx4_init_eq_table(struct mlx4_priv *priv) { int err; int i; priv->eq_table.uar_map = calloc(mlx4_num_eq_uar(&priv->dev), sizeof *priv->eq_table.uar_map); if (!priv->eq_table.uar_map) { err = -ENOMEM; goto err_out_free; } err = mlx4_bitmap_init(&priv->eq_table.bitmap, priv->dev.caps.num_eqs, priv->dev.caps.num_eqs - 1, priv->dev.caps.reserved_eqs, 0); if (err) goto err_out_free; for (i = 0; i < mlx4_num_eq_uar(&priv->dev); ++i) priv->eq_table.uar_map[i] = NULL; if (!mlx4_is_slave(&priv->dev)) { err = mlx4_map_clr_int(priv); if (err) goto err_out_bitmap; priv->eq_table.clr_mask = swab32(1 << (priv->eq_table.inta_pin & 31)); priv->eq_table.clr_int = priv->clr_base + (priv->eq_table.inta_pin < 32 ? 4 : 0); } priv->eq_table.irq_names = malloc( MLX4_IRQNAME_SIZE * (priv->dev.caps.num_comp_vectors + 1 + priv->dev.caps.comp_pool)); if (!priv->eq_table.irq_names) { err = -ENOMEM; goto err_out_clr_int; } for (i = 0; i < priv->dev.caps.num_comp_vectors; ++i) { err = mlx4_create_eq(priv, priv->dev.caps.num_cqs - priv->dev.caps.reserved_cqs + MLX4_NUM_SPARE_EQE, (priv->dev.flags & MLX4_FLAG_MSI_X) ? i : 0, &priv->eq_table.eq[i]); if (err) { --i; goto err_out_unmap; } } err = mlx4_create_eq(priv, MLX4_NUM_ASYNC_EQE + MLX4_NUM_SPARE_EQE, (priv->dev.flags & MLX4_FLAG_MSI_X) ? priv->dev.caps.num_comp_vectors : 0, &priv->eq_table.eq[priv->dev.caps.num_comp_vectors]); if (err) goto err_out_comp; /*if additional completion vectors poolsize is 0 this loop will not run*/ for (i = priv->dev.caps.num_comp_vectors + 1; i < priv->dev.caps.num_comp_vectors + priv->dev.caps.comp_pool + 1; ++i) { err = mlx4_create_eq(priv, priv->dev.caps.num_cqs - priv->dev.caps.reserved_cqs + MLX4_NUM_SPARE_EQE, (priv->dev.flags & MLX4_FLAG_MSI_X) ? i : 0, &priv->eq_table.eq[i]); if (err) { --i; goto err_out_unmap; } } if (priv->dev.flags & MLX4_FLAG_MSI_X) { assert(!"not implemented!"); /*const char *eq_name; for (i = 0; i < priv->dev.caps.num_comp_vectors + 1; ++i) { if (i < priv->dev.caps.num_comp_vectors) { snprintf(priv->eq_table.irq_names + i * MLX4_IRQNAME_SIZE, MLX4_IRQNAME_SIZE, "mlx4-comp-%d@pci:", i pci_name(priv->dev.pdev)); } else { snprintf(priv->eq_table.irq_names + i * MLX4_IRQNAME_SIZE, MLX4_IRQNAME_SIZE, "mlx4-async@pci:" pci_name(priv->dev.pdev)); } eq_name = priv->eq_table.irq_names + i * MLX4_IRQNAME_SIZE; err = request_irq(priv->eq_table.eq[i].irq, mlx4_msi_x_interrupt, 0, eq_name, priv->eq_table.eq + i); if (err) goto err_out_async; priv->eq_table.eq[i].have_irq = 1; }*/ } else { snprintf(priv->eq_table.irq_names, MLX4_IRQNAME_SIZE, DRV_NAME "@pci:"/*, pci_name(priv->dev.pdev)*/); /*err = request_irq(priv->dev.pdev->irq, mlx4_interrupt, IRQF_SHARED, priv->eq_table.irq_names, dev); if (err) goto err_out_async;*/ priv->eq_table.have_irq = 1; } err = mlx4_MAP_EQ(priv, get_async_ev_mask(priv), 0, priv->eq_table.eq[priv->dev.caps.num_comp_vectors].eqn); if (err) MLX4_DEBUG("MAP_EQ for async EQ %d failed (%d)\n", priv->eq_table.eq[priv->dev.caps.num_comp_vectors].eqn, err); for (i = 0; i < priv->dev.caps.num_comp_vectors + 1; ++i) eq_set_ci(&priv->eq_table.eq[i], 1); return 0; /*TODO*/ /*err_out_async:*//*mlx4_free_eq(&priv->dev, &priv->eq_table.eq[priv->dev.caps.num_comp_vectors]);*/ err_out_comp: i = priv->dev.caps.num_comp_vectors - 1; err_out_unmap: /*while (i >= 0) { mlx4_free_eq(&priv->dev, &priv->eq_table.eq[i]); --i; } mlx4_free_irqs(&priv->dev);*/ err_out_clr_int: /*if (!mlx4_is_slave(&priv->dev)) mlx4_unmap_clr_int(&priv->dev);*/ err_out_bitmap: /*mlx4_unmap_uar(&priv->dev);*/ mlx4_bitmap_cleanup(&priv->eq_table.bitmap); err_out_free: free(priv->eq_table.uar_map); return err; }