Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

RDMA/core: Reorganize create QP low-level functions

The low-level create QP function grew to be larger than any sensible
inline function should be. The inline attribute is not really needed for
that function and can be implemented as exported symbol.

Link: https://lore.kernel.org/r/2c08709d86f876c3dfb77684357b2a939e570ca4.1628014762.git.leonro@nvidia.com
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>

authored by

Leon Romanovsky and committed by
Jason Gunthorpe
8da9fe4e 20e2bcc4

+81 -67
+4 -54
drivers/infiniband/core/core_priv.h
··· 316 316 void nldev_init(void); 317 317 void nldev_exit(void); 318 318 319 - static inline struct ib_qp * 320 - _ib_create_qp(struct ib_device *dev, struct ib_pd *pd, 321 - struct ib_qp_init_attr *attr, struct ib_udata *udata, 322 - struct ib_uqp_object *uobj, const char *caller) 323 - { 324 - struct ib_qp *qp; 325 - int ret; 326 - 327 - if (!dev->ops.create_qp) 328 - return ERR_PTR(-EOPNOTSUPP); 329 - 330 - qp = rdma_zalloc_drv_obj_numa(dev, ib_qp); 331 - if (!qp) 332 - return ERR_PTR(-ENOMEM); 333 - 334 - qp->device = dev; 335 - qp->pd = pd; 336 - qp->uobject = uobj; 337 - qp->real_qp = qp; 338 - 339 - qp->qp_type = attr->qp_type; 340 - qp->rwq_ind_tbl = attr->rwq_ind_tbl; 341 - qp->srq = attr->srq; 342 - qp->event_handler = attr->event_handler; 343 - qp->port = attr->port_num; 344 - qp->qp_context = attr->qp_context; 345 - 346 - spin_lock_init(&qp->mr_lock); 347 - INIT_LIST_HEAD(&qp->rdma_mrs); 348 - INIT_LIST_HEAD(&qp->sig_mrs); 349 - 350 - rdma_restrack_new(&qp->res, RDMA_RESTRACK_QP); 351 - WARN_ONCE(!udata && !caller, "Missing kernel QP owner"); 352 - rdma_restrack_set_name(&qp->res, udata ? NULL : caller); 353 - ret = dev->ops.create_qp(qp, attr, udata); 354 - if (ret) 355 - goto err_create; 356 - 357 - /* 358 - * TODO: The mlx4 internally overwrites send_cq and recv_cq. 359 - * Unfortunately, it is not an easy task to fix that driver. 360 - */ 361 - qp->send_cq = attr->send_cq; 362 - qp->recv_cq = attr->recv_cq; 363 - 364 - rdma_restrack_add(&qp->res); 365 - return qp; 366 - 367 - err_create: 368 - rdma_restrack_put(&qp->res); 369 - kfree(qp); 370 - return ERR_PTR(ret); 371 - 372 - } 319 + struct ib_qp *_ib_create_qp(struct ib_device *dev, struct ib_pd *pd, 320 + struct ib_qp_init_attr *attr, 321 + struct ib_udata *udata, struct ib_uqp_object *uobj, 322 + const char *caller); 373 323 374 324 struct rdma_dev_addr; 375 325 int rdma_resolve_ip_route(struct sockaddr *src_addr,
+65 -9
drivers/infiniband/core/verbs.c
··· 1201 1201 } 1202 1202 1203 1203 /** 1204 - * ib_create_named_qp - Creates a kernel QP associated with the specified protection 1205 - * domain. 1204 + * _ib_create_qp - Creates a QP associated with the specified protection domain 1205 + * @dev: IB device 1206 1206 * @pd: The protection domain associated with the QP. 1207 - * @qp_init_attr: A list of initial attributes required to create the 1207 + * @attr: A list of initial attributes required to create the 1208 1208 * QP. If QP creation succeeds, then the attributes are updated to 1209 1209 * the actual capabilities of the created QP. 1210 + * @udata: User data 1211 + * @uobj: uverbs obect 1210 1212 * @caller: caller's build-time module name 1211 - * 1212 - * NOTE: for user qp use ib_create_qp_user with valid udata! 1213 1213 */ 1214 - struct ib_qp *ib_create_named_qp(struct ib_pd *pd, 1215 - struct ib_qp_init_attr *qp_init_attr, 1216 - const char *caller) 1214 + struct ib_qp *_ib_create_qp(struct ib_device *dev, struct ib_pd *pd, 1215 + struct ib_qp_init_attr *attr, 1216 + struct ib_udata *udata, struct ib_uqp_object *uobj, 1217 + const char *caller) 1218 + { 1219 + struct ib_qp *qp; 1220 + int ret; 1221 + 1222 + if (!dev->ops.create_qp) 1223 + return ERR_PTR(-EOPNOTSUPP); 1224 + 1225 + qp = rdma_zalloc_drv_obj_numa(dev, ib_qp); 1226 + if (!qp) 1227 + return ERR_PTR(-ENOMEM); 1228 + 1229 + qp->device = dev; 1230 + qp->pd = pd; 1231 + qp->uobject = uobj; 1232 + qp->real_qp = qp; 1233 + 1234 + qp->qp_type = attr->qp_type; 1235 + qp->rwq_ind_tbl = attr->rwq_ind_tbl; 1236 + qp->srq = attr->srq; 1237 + qp->event_handler = attr->event_handler; 1238 + qp->port = attr->port_num; 1239 + qp->qp_context = attr->qp_context; 1240 + 1241 + spin_lock_init(&qp->mr_lock); 1242 + INIT_LIST_HEAD(&qp->rdma_mrs); 1243 + INIT_LIST_HEAD(&qp->sig_mrs); 1244 + 1245 + rdma_restrack_new(&qp->res, RDMA_RESTRACK_QP); 1246 + WARN_ONCE(!udata && !caller, "Missing kernel QP owner"); 1247 + rdma_restrack_set_name(&qp->res, udata ? NULL : caller); 1248 + ret = dev->ops.create_qp(qp, attr, udata); 1249 + if (ret) 1250 + goto err_create; 1251 + 1252 + /* 1253 + * TODO: The mlx4 internally overwrites send_cq and recv_cq. 1254 + * Unfortunately, it is not an easy task to fix that driver. 1255 + */ 1256 + qp->send_cq = attr->send_cq; 1257 + qp->recv_cq = attr->recv_cq; 1258 + 1259 + rdma_restrack_add(&qp->res); 1260 + return qp; 1261 + 1262 + err_create: 1263 + rdma_restrack_put(&qp->res); 1264 + kfree(qp); 1265 + return ERR_PTR(ret); 1266 + 1267 + } 1268 + EXPORT_SYMBOL(_ib_create_qp); 1269 + 1270 + struct ib_qp *ib_create_qp_kernel(struct ib_pd *pd, 1271 + struct ib_qp_init_attr *qp_init_attr, 1272 + const char *caller) 1217 1273 { 1218 1274 struct ib_device *device = pd ? pd->device : qp_init_attr->xrcd->device; 1219 1275 struct ib_qp *qp; ··· 1336 1280 return ERR_PTR(ret); 1337 1281 1338 1282 } 1339 - EXPORT_SYMBOL(ib_create_named_qp); 1283 + EXPORT_SYMBOL(ib_create_qp_kernel); 1340 1284 1341 1285 static const struct { 1342 1286 int valid;
+12 -4
include/rdma/ib_verbs.h
··· 3688 3688 bad_recv_wr ? : &dummy); 3689 3689 } 3690 3690 3691 - struct ib_qp *ib_create_named_qp(struct ib_pd *pd, 3692 - struct ib_qp_init_attr *qp_init_attr, 3693 - const char *caller); 3691 + struct ib_qp *ib_create_qp_kernel(struct ib_pd *pd, 3692 + struct ib_qp_init_attr *qp_init_attr, 3693 + const char *caller); 3694 + /** 3695 + * ib_create_qp - Creates a kernel QP associated with the specific protection 3696 + * domain. 3697 + * @pd: The protection domain associated with the QP. 3698 + * @init_attr: A list of initial attributes required to create the 3699 + * QP. If QP creation succeeds, then the attributes are updated to 3700 + * the actual capabilities of the created QP. 3701 + */ 3694 3702 static inline struct ib_qp *ib_create_qp(struct ib_pd *pd, 3695 3703 struct ib_qp_init_attr *init_attr) 3696 3704 { 3697 - return ib_create_named_qp(pd, init_attr, KBUILD_MODNAME); 3705 + return ib_create_qp_kernel(pd, init_attr, KBUILD_MODNAME); 3698 3706 } 3699 3707 3700 3708 /**