From 385edc9d217b8175e1c55b52302571b1d21d8d71 Mon Sep 17 00:00:00 2001 From: Jack Wang Date: Wed, 10 Aug 2016 10:50:53 +0200 Subject: [PATCH] cma: export function to set service level We want this for isolating network traffic with storage traffic. So extend cma to allow us to do it for QoS, to keep the old bahavior, only apply mask when sl_on is set. Signed-off-by: Jack Wang --- drivers/infiniband/core/cma.c | 17 +++++++++++++++++ include/rdma/rdma_cm.h | 13 +++++++++++++ 2 files changed, 30 insertions(+) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 66e8516..4b4d453 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -225,6 +225,8 @@ struct rdma_id_private { u32 options; u8 srq; u8 tos; + u8 sl; + bool sl_on; u8 reuseaddr; u8 afonly; enum ib_gid_type gid_type; @@ -2752,6 +2754,17 @@ static void cma_listen_on_all(struct rdma_id_private *id_priv) mutex_unlock(&lock); } +void rdma_set_service_level(struct rdma_cm_id *id, u8 sl) +{ + struct rdma_id_private *id_priv; + + id_priv = container_of(id, struct rdma_id_private, id); + id_priv->sl = sl; + id_priv->sl_on = true; +} +EXPORT_SYMBOL(rdma_set_service_level); + + void rdma_set_service_type(struct rdma_cm_id *id, int tos) { struct rdma_id_private *id_priv; @@ -2838,6 +2851,10 @@ static int cma_query_ib_route(struct rdma_id_private *id_priv, int timeout_ms, path_rec->pkey = cpu_to_be16(ib_addr_get_pkey(&addr->dev_addr)); path_rec->numb_path = 1; path_rec->reversible = 1; + if (id_priv->sl_on) { + path_rec->sl = id_priv->sl; + comp_mask |= IB_SA_PATH_REC_SL; + } path_rec->service_id = rdma_get_service_id(&id_priv->id, cma_dst_addr(id_priv)); comp_mask |= IB_SA_PATH_REC_PKEY | IB_SA_PATH_REC_NUMB_PATH | diff --git a/include/rdma/rdma_cm.h b/include/rdma/rdma_cm.h index b34ee4e..df7030e 100644 --- a/include/rdma/rdma_cm.h +++ b/include/rdma/rdma_cm.h @@ -374,6 +374,19 @@ int rdma_join_multicast(struct rdma_cm_id *id, struct sockaddr *addr, void rdma_leave_multicast(struct rdma_cm_id *id, struct sockaddr *addr); /** + * rdma_set_service_level - Set the level of service associated with a + * connection identifier. + * @id: Communication identifier to associated with service type. + * @sl: service level. + * + * The service level should be specified before + * performing route resolution, as existing communication on the + * connection identifier may be unaffected. The level of service + * requested may not be supported by the network to all destinations. + */ +void rdma_set_service_level(struct rdma_cm_id *id, u8 sl); + +/** * rdma_set_service_type - Set the type of service associated with a * connection identifier. * @id: Communication identifier to associated with service type. -- 2.7.4