diff options
| -rw-r--r-- | drivers/net/mlx4/alloc.c | 46 | ||||
| -rw-r--r-- | include/linux/mlx4/device.h | 11 |
2 files changed, 57 insertions, 0 deletions
diff --git a/drivers/net/mlx4/alloc.c b/drivers/net/mlx4/alloc.c index 43c6d04bb880..f9d6b4dca180 100644 --- a/drivers/net/mlx4/alloc.c +++ b/drivers/net/mlx4/alloc.c | |||
| @@ -307,3 +307,49 @@ void mlx4_db_free(struct mlx4_dev *dev, struct mlx4_db *db) | |||
| 307 | mutex_unlock(&priv->pgdir_mutex); | 307 | mutex_unlock(&priv->pgdir_mutex); |
| 308 | } | 308 | } |
| 309 | EXPORT_SYMBOL_GPL(mlx4_db_free); | 309 | EXPORT_SYMBOL_GPL(mlx4_db_free); |
| 310 | |||
| 311 | int mlx4_alloc_hwq_res(struct mlx4_dev *dev, struct mlx4_hwq_resources *wqres, | ||
| 312 | int size, int max_direct) | ||
| 313 | { | ||
| 314 | int err; | ||
| 315 | |||
| 316 | err = mlx4_db_alloc(dev, &wqres->db, 1); | ||
| 317 | if (err) | ||
| 318 | return err; | ||
| 319 | |||
| 320 | *wqres->db.db = 0; | ||
| 321 | |||
| 322 | err = mlx4_buf_alloc(dev, size, max_direct, &wqres->buf); | ||
| 323 | if (err) | ||
| 324 | goto err_db; | ||
| 325 | |||
| 326 | err = mlx4_mtt_init(dev, wqres->buf.npages, wqres->buf.page_shift, | ||
| 327 | &wqres->mtt); | ||
| 328 | if (err) | ||
| 329 | goto err_buf; | ||
| 330 | |||
| 331 | err = mlx4_buf_write_mtt(dev, &wqres->mtt, &wqres->buf); | ||
| 332 | if (err) | ||
| 333 | goto err_mtt; | ||
| 334 | |||
| 335 | return 0; | ||
| 336 | |||
| 337 | err_mtt: | ||
| 338 | mlx4_mtt_cleanup(dev, &wqres->mtt); | ||
| 339 | err_buf: | ||
| 340 | mlx4_buf_free(dev, size, &wqres->buf); | ||
| 341 | err_db: | ||
| 342 | mlx4_db_free(dev, &wqres->db); | ||
| 343 | |||
| 344 | return err; | ||
| 345 | } | ||
| 346 | EXPORT_SYMBOL_GPL(mlx4_alloc_hwq_res); | ||
| 347 | |||
| 348 | void mlx4_free_hwq_res(struct mlx4_dev *dev, struct mlx4_hwq_resources *wqres, | ||
| 349 | int size) | ||
| 350 | { | ||
| 351 | mlx4_mtt_cleanup(dev, &wqres->mtt); | ||
| 352 | mlx4_buf_free(dev, size, &wqres->buf); | ||
| 353 | mlx4_db_free(dev, &wqres->db); | ||
| 354 | } | ||
| 355 | EXPORT_SYMBOL_GPL(mlx4_free_hwq_res); | ||
diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h index 0a47457931ac..9fa1a8002ce2 100644 --- a/include/linux/mlx4/device.h +++ b/include/linux/mlx4/device.h | |||
| @@ -234,6 +234,12 @@ struct mlx4_db { | |||
| 234 | int order; | 234 | int order; |
| 235 | }; | 235 | }; |
| 236 | 236 | ||
| 237 | struct mlx4_hwq_resources { | ||
| 238 | struct mlx4_db db; | ||
| 239 | struct mlx4_mtt mtt; | ||
| 240 | struct mlx4_buf buf; | ||
| 241 | }; | ||
| 242 | |||
| 237 | struct mlx4_mr { | 243 | struct mlx4_mr { |
| 238 | struct mlx4_mtt mtt; | 244 | struct mlx4_mtt mtt; |
| 239 | u64 iova; | 245 | u64 iova; |
| @@ -370,6 +376,11 @@ int mlx4_buf_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt, | |||
| 370 | int mlx4_db_alloc(struct mlx4_dev *dev, struct mlx4_db *db, int order); | 376 | int mlx4_db_alloc(struct mlx4_dev *dev, struct mlx4_db *db, int order); |
| 371 | void mlx4_db_free(struct mlx4_dev *dev, struct mlx4_db *db); | 377 | void mlx4_db_free(struct mlx4_dev *dev, struct mlx4_db *db); |
| 372 | 378 | ||
| 379 | int mlx4_alloc_hwq_res(struct mlx4_dev *dev, struct mlx4_hwq_resources *wqres, | ||
| 380 | int size, int max_direct); | ||
| 381 | void mlx4_free_hwq_res(struct mlx4_dev *mdev, struct mlx4_hwq_resources *wqres, | ||
| 382 | int size); | ||
| 383 | |||
| 373 | int mlx4_cq_alloc(struct mlx4_dev *dev, int nent, struct mlx4_mtt *mtt, | 384 | int mlx4_cq_alloc(struct mlx4_dev *dev, int nent, struct mlx4_mtt *mtt, |
| 374 | struct mlx4_uar *uar, u64 db_rec, struct mlx4_cq *cq); | 385 | struct mlx4_uar *uar, u64 db_rec, struct mlx4_cq *cq); |
| 375 | void mlx4_cq_free(struct mlx4_dev *dev, struct mlx4_cq *cq); | 386 | void mlx4_cq_free(struct mlx4_dev *dev, struct mlx4_cq *cq); |
