Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/mlx5/mlx5_ib/mlx5_ib_mr.c
/*- | /*- | ||||
* Copyright (c) 2013-2015, Mellanox Technologies, Ltd. All rights reserved. | * Copyright (c) 2013-2021, Mellanox Technologies, Ltd. All rights reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
* modification, are permitted provided that the following conditions | * modification, are permitted provided that the following conditions | ||||
* are met: | * are met: | ||||
* 1. Redistributions of source code must retain the above copyright | * 1. Redistributions of source code must retain the above copyright | ||||
* notice, this list of conditions and the following disclaimer. | * notice, this list of conditions and the following disclaimer. | ||||
* 2. Redistributions in binary form must reproduce the above copyright | * 2. Redistributions in binary form must reproduce the above copyright | ||||
* notice, this list of conditions and the following disclaimer in the | * notice, this list of conditions and the following disclaimer in the | ||||
▲ Show 20 Lines • Show All 1,287 Lines • ▼ Show 20 Lines | static int clean_mr(struct mlx5_ib_mr *mr) | ||||
} | } | ||||
if (!umred) | if (!umred) | ||||
kfree(mr); | kfree(mr); | ||||
return 0; | return 0; | ||||
} | } | ||||
int mlx5_ib_dereg_mr(struct ib_mr *ibmr) | int mlx5_ib_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata) | ||||
{ | { | ||||
struct mlx5_ib_dev *dev = to_mdev(ibmr->device); | struct mlx5_ib_dev *dev = to_mdev(ibmr->device); | ||||
struct mlx5_ib_mr *mr = to_mmr(ibmr); | struct mlx5_ib_mr *mr = to_mmr(ibmr); | ||||
int npages = mr->npages; | int npages = mr->npages; | ||||
struct ib_umem *umem = mr->umem; | struct ib_umem *umem = mr->umem; | ||||
#ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING | #ifdef CONFIG_INFINIBAND_ON_DEMAND_PAGING | ||||
if (umem && umem->odp_data) { | if (umem && umem->odp_data) { | ||||
Show All 24 Lines | if (umem) { | ||||
atomic_sub(npages, &dev->mdev->priv.reg_pages); | atomic_sub(npages, &dev->mdev->priv.reg_pages); | ||||
} | } | ||||
return 0; | return 0; | ||||
} | } | ||||
struct ib_mr *mlx5_ib_alloc_mr(struct ib_pd *pd, | struct ib_mr *mlx5_ib_alloc_mr(struct ib_pd *pd, | ||||
enum ib_mr_type mr_type, | enum ib_mr_type mr_type, | ||||
u32 max_num_sg) | u32 max_num_sg, struct ib_udata *udata) | ||||
{ | { | ||||
struct mlx5_ib_dev *dev = to_mdev(pd->device); | struct mlx5_ib_dev *dev = to_mdev(pd->device); | ||||
int inlen = MLX5_ST_SZ_BYTES(create_mkey_in); | int inlen = MLX5_ST_SZ_BYTES(create_mkey_in); | ||||
int ndescs = ALIGN(max_num_sg, 4); | int ndescs = ALIGN(max_num_sg, 4); | ||||
struct mlx5_ib_mr *mr; | struct mlx5_ib_mr *mr; | ||||
void *mkc; | void *mkc; | ||||
u32 *in; | u32 *in; | ||||
int err; | int err; | ||||
Show All 28 Lines | if (mr_type == IB_MR_TYPE_MEM_REG) { | ||||
mr->access_mode = MLX5_ACCESS_MODE_KLM; | mr->access_mode = MLX5_ACCESS_MODE_KLM; | ||||
err = mlx5_alloc_priv_descs(pd->device, mr, | err = mlx5_alloc_priv_descs(pd->device, mr, | ||||
ndescs, sizeof(struct mlx5_klm)); | ndescs, sizeof(struct mlx5_klm)); | ||||
if (err) | if (err) | ||||
goto err_free_in; | goto err_free_in; | ||||
mr->desc_size = sizeof(struct mlx5_klm); | mr->desc_size = sizeof(struct mlx5_klm); | ||||
mr->max_descs = ndescs; | mr->max_descs = ndescs; | ||||
} else if (mr_type == IB_MR_TYPE_SIGNATURE) { | } else if (mr_type == IB_MR_TYPE_INTEGRITY) { | ||||
u32 psv_index[2]; | u32 psv_index[2]; | ||||
MLX5_SET(mkc, mkc, bsf_en, 1); | MLX5_SET(mkc, mkc, bsf_en, 1); | ||||
MLX5_SET(mkc, mkc, bsf_octword_size, MLX5_MKEY_BSF_OCTO_SIZE); | MLX5_SET(mkc, mkc, bsf_octword_size, MLX5_MKEY_BSF_OCTO_SIZE); | ||||
mr->sig = kzalloc(sizeof(*mr->sig), GFP_KERNEL); | mr->sig = kzalloc(sizeof(*mr->sig), GFP_KERNEL); | ||||
if (!mr->sig) { | if (!mr->sig) { | ||||
err = -ENOMEM; | err = -ENOMEM; | ||||
goto err_free_in; | goto err_free_in; | ||||
▲ Show 20 Lines • Show All 254 Lines • Show Last 20 Lines |