[openib-general] [PATCH] mthca: implement query_ah for MADs and memfree -- REMINDER

Jack Morgenstein jackm at mellanox.co.il
Sun Feb 26 01:41:59 PST 2006


Just a reminder: I submitted the patch on Feb 13.

Implement query_ah in provider layer (except for av's which are in HCA memory)
Needed for implementing RMPP duplicate session detection on sending side
(extraction of DGID/DLID and GRH flag from address handle).

Signed-off-by: Jack Morgenstein <jackm at mellanox.co.il>

Index: src/drivers/infiniband/hw/mthca/mthca_av.c
===================================================================
--- src.orig/drivers/infiniband/hw/mthca/mthca_av.c	2006-02-22 
09:45:11.621141000 +0200
+++ src/drivers/infiniband/hw/mthca/mthca_av.c	2006-02-22 09:48:39.762130000 
+0200
@@ -191,6 +191,34 @@ int mthca_read_ah(struct mthca_dev *dev,
 	return 0;
 }
 
+int mthca_query_ah(struct mthca_dev *dev, struct mthca_ah *ah,
+		   struct ib_ah_attr *ah_attr)
+{
+	/* Only implement for MAD and memfree ah for now. */
+	if (ah->type == MTHCA_AH_ON_HCA)
+		return -ENOSYS;
+
+	memset(ah_attr, 0, sizeof *ah_attr);
+	ah_attr->dlid = be16_to_cpu(ah->av->dlid);
+	ah_attr->sl = be32_to_cpu(ah->av->sl_tclass_flowlabel) >> 28;
+	ah_attr->static_rate = ah->av->msg_sr & 0x7;
+	ah_attr->src_path_bits = ah->av->g_slid & 0x7F;
+	ah_attr->port_num = be32_to_cpu(ah->av->port_pd) >> 24;
+	ah_attr->ah_flags =  mthca_ah_grh_present(ah) ? IB_AH_GRH : 0;
+
+	if (ah_attr->ah_flags) {
+		ah_attr->grh.traffic_class =
+			be32_to_cpu(ah->av->sl_tclass_flowlabel) >> 20;
+		ah_attr->grh.flow_label =
+			be32_to_cpu(ah->av->sl_tclass_flowlabel) & 0xfffff;
+		ah_attr->grh.hop_limit = ah->av->hop_limit;
+		ah_attr->grh.sgid_index = ah->av->gid_index &
+					  (dev->limits.gid_table_len - 1);
+		memcpy(ah_attr->grh.dgid.raw, ah->av->dgid, 16);
+	}
+	return 0;
+}
+
 int __devinit mthca_init_av_table(struct mthca_dev *dev)
 {
 	int err;
Index: src/drivers/infiniband/hw/mthca/mthca_dev.h
===================================================================
--- src.orig/drivers/infiniband/hw/mthca/mthca_dev.h	2006-02-22 
09:46:05.946574000 +0200
+++ src/drivers/infiniband/hw/mthca/mthca_dev.h	2006-02-22 09:48:39.781132000 
+0200
@@ -532,6 +532,8 @@ int mthca_create_ah(struct mthca_dev *de
 		    struct mthca_pd *pd,
 		    struct ib_ah_attr *ah_attr,
 		    struct mthca_ah *ah);
+int mthca_query_ah(struct mthca_dev *dev, struct mthca_ah *ah,
+		   struct ib_ah_attr *ah_attr);
 int mthca_destroy_ah(struct mthca_dev *dev, struct mthca_ah *ah);
 int mthca_read_ah(struct mthca_dev *dev, struct mthca_ah *ah,
 		  struct ib_ud_header *header);
Index: src/drivers/infiniband/hw/mthca/mthca_provider.c
===================================================================
--- src.orig/drivers/infiniband/hw/mthca/mthca_provider.c	2006-02-22 
09:46:06.020575000 +0200
+++ src/drivers/infiniband/hw/mthca/mthca_provider.c	2006-02-22 
09:48:39.803132000 +0200
@@ -446,6 +446,11 @@ static int mthca_ah_destroy(struct ib_ah
 	return 0;
 }
 
+static int mthca_ah_query(struct ib_ah *ah, struct ib_ah_attr *ah_attr)
+{
+	return mthca_query_ah(to_mdev(ah->device), to_mah(ah), ah_attr);
+}
+
 static struct ib_srq *mthca_create_srq(struct ib_pd *pd,
 				       struct ib_srq_init_attr *init_attr,
 				       struct ib_udata *udata)
@@ -1290,6 +1295,7 @@ int mthca_register_device(struct mthca_d
 	dev->ib_dev.dealloc_pd           = mthca_dealloc_pd;
 	dev->ib_dev.create_ah            = mthca_ah_create;
 	dev->ib_dev.destroy_ah           = mthca_ah_destroy;
+	dev->ib_dev.query_ah             = mthca_ah_query;
 
 	if (dev->mthca_flags & MTHCA_FLAG_SRQ) {
 		dev->ib_dev.create_srq           = mthca_create_srq;



More information about the general mailing list