Skip to content

Commit 2c1619e

Browse files
Danit Goldbergjgunthorpe
authored andcommitted
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>
1 parent ecb53fe commit 2c1619e

5 files changed

Lines changed: 47 additions & 1 deletion

File tree

‎drivers/infiniband/core/cma.c‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,7 @@ struct rdma_cm_id *__rdma_create_id(struct net *net,
888888
id_priv->id.ps = ps;
889889
id_priv->id.qp_type = qp_type;
890890
id_priv->tos_set = false;
891+
id_priv->timeout_set = false;
891892
id_priv->gid_type = IB_GID_TYPE_IB;
892893
spin_lock_init(&id_priv->lock);
893894
mutex_init(&id_priv->qp_mutex);
@@ -1130,6 +1131,9 @@ int rdma_init_qp_attr(struct rdma_cm_id *id, struct ib_qp_attr *qp_attr,
11301131
} else
11311132
ret = -ENOSYS;
11321133

1134+
if ((*qp_attr_mask & IB_QP_TIMEOUT) && id_priv->timeout_set)
1135+
qp_attr->timeout = id_priv->timeout;
1136+
11331137
return ret;
11341138
}
11351139
EXPORT_SYMBOL(rdma_init_qp_attr);
@@ -2490,6 +2494,34 @@ void rdma_set_service_type(struct rdma_cm_id *id, int tos)
24902494
}
24912495
EXPORT_SYMBOL(rdma_set_service_type);
24922496

2497+
/**
2498+
* rdma_set_ack_timeout() - Set the ack timeout of QP associated
2499+
* with a connection identifier.
2500+
* @id: Communication identifier to associated with service type.
2501+
* @timeout: Ack timeout to set a QP, expressed as 4.096 * 2^(timeout) usec.
2502+
*
2503+
* This function should be called before rdma_connect() on active side,
2504+
* and on passive side before rdma_accept(). It is applicable to primary
2505+
* path only. The timeout will affect the local side of the QP, it is not
2506+
* negotiated with remote side and zero disables the timer.
2507+
*
2508+
* Return: 0 for success
2509+
*/
2510+
int rdma_set_ack_timeout(struct rdma_cm_id *id, u8 timeout)
2511+
{
2512+
struct rdma_id_private *id_priv;
2513+
2514+
if (id->qp_type != IB_QPT_RC)
2515+
return -EINVAL;
2516+
2517+
id_priv = container_of(id, struct rdma_id_private, id);
2518+
id_priv->timeout = timeout;
2519+
id_priv->timeout_set = true;
2520+
2521+
return 0;
2522+
}
2523+
EXPORT_SYMBOL(rdma_set_ack_timeout);
2524+
24932525
static void cma_query_handler(int status, struct sa_path_rec *path_rec,
24942526
void *context)
24952527
{

‎drivers/infiniband/core/cma_priv.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,11 @@ struct rdma_id_private {
8484
u32 options;
8585
u8 srq;
8686
u8 tos;
87-
bool tos_set;
87+
u8 tos_set:1;
88+
u8 timeout_set:1;
8889
u8 reuseaddr;
8990
u8 afonly;
91+
u8 timeout;
9092
enum ib_gid_type gid_type;
9193

9294
/*

‎drivers/infiniband/core/ucma.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,6 +1236,13 @@ static int ucma_set_option_id(struct ucma_context *ctx, int optname,
12361236
}
12371237
ret = rdma_set_afonly(ctx->cm_id, *((int *) optval) ? 1 : 0);
12381238
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;
12391246
default:
12401247
ret = -ENOSYS;
12411248
}

‎include/rdma/rdma_cm.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ int rdma_set_reuseaddr(struct rdma_cm_id *id, int reuse);
374374
*/
375375
int rdma_set_afonly(struct rdma_cm_id *id, int afonly);
376376

377+
int rdma_set_ack_timeout(struct rdma_cm_id *id, u8 timeout);
377378
/**
378379
* rdma_get_service_id - Return the IB service ID for a specified address.
379380
* @id: Communication identifier associated with the address.

‎include/uapi/rdma/rdma_user_cm.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,10 @@ enum {
300300
RDMA_OPTION_ID_TOS = 0,
301301
RDMA_OPTION_ID_REUSEADDR = 1,
302302
RDMA_OPTION_ID_AFONLY = 2,
303+
RDMA_OPTION_ID_ACK_TIMEOUT = 3
304+
};
305+
306+
enum {
303307
RDMA_OPTION_IB_PATH = 1
304308
};
305309

0 commit comments

Comments
 (0)