[openib-general] [PATCH RFC 2 of 5] IB/cma: QoS support

Michael S. Tsirkin mst at mellanox.co.il
Mon Jan 22 06:45:00 PST 2007


QoS support according to the proposed LWG2 QoS Annex:
pass sevice ID in SA query, add option to set priority.

Signed-off-by: Michael S. Tsirkin <mst at mellanox.co.il>

---

Index: linux-2.6/drivers/infiniband/core/cma.c
===================================================================
--- linux-2.6.orig/drivers/infiniband/core/cma.c
+++ linux-2.6/drivers/infiniband/core/cma.c
@@ -53,6 +53,10 @@ MODULE_LICENSE("Dual BSD/GPL");
 #define CMA_CM_RESPONSE_TIMEOUT 20
 #define CMA_MAX_CM_RETRIES 15
 
+static int cma_qos_support = 0;
+module_param_named(qos_support, cma_qos_support, int, 0644);
+MODULE_PARM_DESC(qos_support, "Enable QoS support if > 0");
+
 static void cma_add_one(struct ib_device *device);
 static void cma_remove_one(struct ib_device *device);
 
@@ -135,6 +139,7 @@ struct rdma_id_private {
 	u32			seq_num;
 	u32			qp_num;
 	u8			srq;
+	u8			priority;
 };
 
 struct cma_work {
@@ -1397,7 +1402,24 @@ static int cma_query_ib_route(struct rdm
 	path_rec.pkey = cpu_to_be16(ib_addr_get_pkey(addr));
 	path_rec.numb_path = 1;
 
-	id_priv->query_id = ib_sa_path_rec_get(&sa_client, id_priv->id.device,
+	if (cma_qos_support) {
+		ib_sa_comp_mask m = IB_SA_PATH_REC_DGID | IB_SA_PATH_REC_SGID |
+			IB_SA_PATH_REC_PKEY | IB_SA_PATH_REC_NUMB_PATH;
+		struct sockaddr *sockaddr = &id_priv->id.route.addr.dst_addr;
+		__be64 svc_id = cma_get_service_id(id_priv->id.ps, sockaddr);
+
+		path_rec.service_id = svc_id;
+		m |= IB_SA_PATH_REC_SERVICE_ID;
+		if (id_priv->priority) {
+			path_rec.priority = __cpu_to_be16(id_priv->priority);
+			m |= IB_SA_PATH_REC_PRIORITY;
+		}
+		id_priv->query_id = ib_sa_path_rec_get(&sa_client, id_priv->id.device,
+				id_priv->id.port_num, &path_rec, m,
+				timeout_ms, GFP_KERNEL,
+				cma_query_handler, work, &id_priv->query);
+	} else
+		id_priv->query_id = ib_sa_path_rec_get(&sa_client, id_priv->id.device,
 				id_priv->id.port_num, &path_rec,
 				IB_SA_PATH_REC_DGID | IB_SA_PATH_REC_SGID |
 				IB_SA_PATH_REC_PKEY | IB_SA_PATH_REC_NUMB_PATH,
@@ -1464,6 +1486,19 @@ err1:
 	return ret;
 }
 
+int rdma_set_priority(struct rdma_cm_id *id, u8 priority)
+{
+	struct rdma_id_private *id_priv;
+
+	id_priv = container_of(id, struct rdma_id_private, id);
+	if (!cma_comp(id_priv, CMA_ADDR_RESOLVED))
+		return -EINVAL;
+
+	id_priv->priority = priority;
+	return 0;
+}
+EXPORT_SYMBOL(rdma_set_priority);
+
 int rdma_set_ib_paths(struct rdma_cm_id *id,
 		      struct ib_sa_path_rec *path_rec, int num_paths)
 {
Index: linux-2.6/include/rdma/rdma_cm.h
===================================================================
--- linux-2.6.orig/include/rdma/rdma_cm.h
+++ linux-2.6/include/rdma/rdma_cm.h
@@ -177,6 +177,15 @@ int rdma_resolve_addr(struct rdma_cm_id 
 		      struct sockaddr *dst_addr, int timeout_ms);
 
 /**
+ * rdma_set_priority - Set traffice class for connection.
+ * Must be set before rdma_resolve_route is called.
+ *
+ * @id: RDMA identifier.
+ * @priority: priority value to use. 0 is the default (wildcard) value.
+ */
+int rdma_set_priority(struct rdma_cm_id *id, u8 priority);
+
+/**
  * rdma_resolve_route - Resolve the RDMA address bound to the RDMA identifier
  *   into route information needed to establish a connection.
  *

-- 
MST




More information about the general mailing list