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

IB/cma: Define option to set ack timeout and pack tos_set

Define new option in 'rdma_set_option' to override calculated QP timeout
when requested to provide QP attributes to modify a QP.

At the same time, pack tos_set to be bitfield.

Signed-off-by: Danit Goldberg <danitg@mellanox.com>
Reviewed-by: Moni Shoua <monis@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Reviewed-by: Parav Pandit <parav@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>

authored by

Danit Goldberg and committed by
Jason Gunthorpe
2c1619ed ecb53feb

+47 -1
+32
drivers/infiniband/core/cma.c
··· 888 888 id_priv->id.ps = ps; 889 889 id_priv->id.qp_type = qp_type; 890 890 id_priv->tos_set = false; 891 + id_priv->timeout_set = false; 891 892 id_priv->gid_type = IB_GID_TYPE_IB; 892 893 spin_lock_init(&id_priv->lock); 893 894 mutex_init(&id_priv->qp_mutex); ··· 1130 1129 *qp_attr_mask |= IB_QP_PORT; 1131 1130 } else 1132 1131 ret = -ENOSYS; 1132 + 1133 + if ((*qp_attr_mask & IB_QP_TIMEOUT) && id_priv->timeout_set) 1134 + qp_attr->timeout = id_priv->timeout; 1133 1135 1134 1136 return ret; 1135 1137 } ··· 2493 2489 id_priv->tos_set = true; 2494 2490 } 2495 2491 EXPORT_SYMBOL(rdma_set_service_type); 2492 + 2493 + /** 2494 + * rdma_set_ack_timeout() - Set the ack timeout of QP associated 2495 + * with a connection identifier. 2496 + * @id: Communication identifier to associated with service type. 2497 + * @timeout: Ack timeout to set a QP, expressed as 4.096 * 2^(timeout) usec. 2498 + * 2499 + * This function should be called before rdma_connect() on active side, 2500 + * and on passive side before rdma_accept(). It is applicable to primary 2501 + * path only. The timeout will affect the local side of the QP, it is not 2502 + * negotiated with remote side and zero disables the timer. 2503 + * 2504 + * Return: 0 for success 2505 + */ 2506 + int rdma_set_ack_timeout(struct rdma_cm_id *id, u8 timeout) 2507 + { 2508 + struct rdma_id_private *id_priv; 2509 + 2510 + if (id->qp_type != IB_QPT_RC) 2511 + return -EINVAL; 2512 + 2513 + id_priv = container_of(id, struct rdma_id_private, id); 2514 + id_priv->timeout = timeout; 2515 + id_priv->timeout_set = true; 2516 + 2517 + return 0; 2518 + } 2519 + EXPORT_SYMBOL(rdma_set_ack_timeout); 2496 2520 2497 2521 static void cma_query_handler(int status, struct sa_path_rec *path_rec, 2498 2522 void *context)
+3 -1
drivers/infiniband/core/cma_priv.h
··· 84 84 u32 options; 85 85 u8 srq; 86 86 u8 tos; 87 - bool tos_set; 87 + u8 tos_set:1; 88 + u8 timeout_set:1; 88 89 u8 reuseaddr; 89 90 u8 afonly; 91 + u8 timeout; 90 92 enum ib_gid_type gid_type; 91 93 92 94 /*
+7
drivers/infiniband/core/ucma.c
··· 1236 1236 } 1237 1237 ret = rdma_set_afonly(ctx->cm_id, *((int *) optval) ? 1 : 0); 1238 1238 break; 1239 + case RDMA_OPTION_ID_ACK_TIMEOUT: 1240 + if (optlen != sizeof(u8)) { 1241 + ret = -EINVAL; 1242 + break; 1243 + } 1244 + ret = rdma_set_ack_timeout(ctx->cm_id, *((u8 *)optval)); 1245 + break; 1239 1246 default: 1240 1247 ret = -ENOSYS; 1241 1248 }
+1
include/rdma/rdma_cm.h
··· 374 374 */ 375 375 int rdma_set_afonly(struct rdma_cm_id *id, int afonly); 376 376 377 + int rdma_set_ack_timeout(struct rdma_cm_id *id, u8 timeout); 377 378 /** 378 379 * rdma_get_service_id - Return the IB service ID for a specified address. 379 380 * @id: Communication identifier associated with the address.
+4
include/uapi/rdma/rdma_user_cm.h
··· 300 300 RDMA_OPTION_ID_TOS = 0, 301 301 RDMA_OPTION_ID_REUSEADDR = 1, 302 302 RDMA_OPTION_ID_AFONLY = 2, 303 + RDMA_OPTION_ID_ACK_TIMEOUT = 3 304 + }; 305 + 306 + enum { 303 307 RDMA_OPTION_IB_PATH = 1 304 308 }; 305 309