Lines Matching refs:dev
47 int mlx4_pd_alloc(struct mlx4_dev *dev, u32 *pdn)
49 struct mlx4_priv *priv = mlx4_priv(dev);
59 void mlx4_pd_free(struct mlx4_dev *dev, u32 pdn)
61 mlx4_bitmap_free(&mlx4_priv(dev)->pd_bitmap, pdn, MLX4_USE_RR);
65 int __mlx4_xrcd_alloc(struct mlx4_dev *dev, u32 *xrcdn)
67 struct mlx4_priv *priv = mlx4_priv(dev);
76 int mlx4_xrcd_alloc(struct mlx4_dev *dev, u32 *xrcdn)
81 if (mlx4_is_mfunc(dev)) {
82 err = mlx4_cmd_imm(dev, 0, &out_param,
92 return __mlx4_xrcd_alloc(dev, xrcdn);
96 void __mlx4_xrcd_free(struct mlx4_dev *dev, u32 xrcdn)
98 mlx4_bitmap_free(&mlx4_priv(dev)->xrcd_bitmap, xrcdn, MLX4_USE_RR);
101 void mlx4_xrcd_free(struct mlx4_dev *dev, u32 xrcdn)
106 if (mlx4_is_mfunc(dev)) {
108 err = mlx4_cmd(dev, in_param, RES_XRCD,
112 mlx4_warn(dev, "Failed to release xrcdn %d\n", xrcdn);
114 __mlx4_xrcd_free(dev, xrcdn);
118 int mlx4_init_pd_table(struct mlx4_dev *dev)
120 struct mlx4_priv *priv = mlx4_priv(dev);
122 return mlx4_bitmap_init(&priv->pd_bitmap, dev->caps.num_pds,
124 dev->caps.reserved_pds, 0);
127 void mlx4_cleanup_pd_table(struct mlx4_dev *dev)
129 mlx4_bitmap_cleanup(&mlx4_priv(dev)->pd_bitmap);
132 int mlx4_init_xrcd_table(struct mlx4_dev *dev)
134 struct mlx4_priv *priv = mlx4_priv(dev);
137 (1 << 16) - 1, dev->caps.reserved_xrcds + 1, 0);
140 void mlx4_cleanup_xrcd_table(struct mlx4_dev *dev)
142 mlx4_bitmap_cleanup(&mlx4_priv(dev)->xrcd_bitmap);
145 int mlx4_uar_alloc(struct mlx4_dev *dev, struct mlx4_uar *uar)
149 uar->index = mlx4_bitmap_alloc(&mlx4_priv(dev)->uar_table.bitmap);
153 if (mlx4_is_slave(dev))
154 offset = uar->index % ((int) pci_resource_len(dev->pdev, 2) /
155 dev->caps.uar_page_size);
158 uar->pfn = (pci_resource_start(dev->pdev, 2) >> PAGE_SHIFT) + offset;
164 void mlx4_uar_free(struct mlx4_dev *dev, struct mlx4_uar *uar)
166 mlx4_bitmap_free(&mlx4_priv(dev)->uar_table.bitmap, uar->index, MLX4_USE_RR);
171 int mlx4_bf_alloc(struct mlx4_dev *dev, struct mlx4_bf *bf, int node)
173 struct mlx4_priv *priv = mlx4_priv(dev);
197 err = mlx4_uar_alloc(dev, uar);
221 bf->buf_size = dev->caps.bf_reg_size / 2;
222 bf->reg = uar->bf_map + idx * dev->caps.bf_reg_size;
223 if (uar->free_bf_bmap == (1 << dev->caps.bf_regs_per_page) - 1)
233 mlx4_uar_free(dev, uar);
244 void mlx4_bf_free(struct mlx4_dev *dev, struct mlx4_bf *bf)
246 struct mlx4_priv *priv = mlx4_priv(dev);
253 idx = (bf->reg - bf->uar->bf_map) / dev->caps.bf_reg_size;
261 mlx4_uar_free(dev, bf->uar);
271 int mlx4_bf_alloc(struct mlx4_dev *dev, struct mlx4_bf *bf, int node)
278 void mlx4_bf_free(struct mlx4_dev *dev, struct mlx4_bf *bf)
285 int mlx4_init_uar_table(struct mlx4_dev *dev)
287 if (dev->caps.num_uars <= 128) {
288 mlx4_err(dev, "Only %d UAR pages (need more than 128)\n",
289 dev->caps.num_uars);
290 mlx4_err(dev, "Increase firmware log2_uar_bar_megabytes?\n");
294 return mlx4_bitmap_init(&mlx4_priv(dev)->uar_table.bitmap,
295 dev->caps.num_uars, dev->caps.num_uars - 1,
296 dev->caps.reserved_uars, 0);
299 void mlx4_cleanup_uar_table(struct mlx4_dev *dev)
301 mlx4_bitmap_cleanup(&mlx4_priv(dev)->uar_table.bitmap);