[openib-general] [PATCH] mthca: implement query_ah for MADs and memfree
Jack Morgenstein
jackm at mellanox.co.il
Mon Feb 13 02:07:05 PST 2006
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-09 12:46:06.560017000 +0200
+++ src/drivers/infiniband/hw/mthca/mthca_av.c 2006-02-13 11:44:35.552503000 +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-09 12:46:06.574016000 +0200
+++ src/drivers/infiniband/hw/mthca/mthca_dev.h 2006-02-09 12:46:29.484351000 +0200
@@ -529,6 +529,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-09 12:46:06.668020000 +0200
+++ src/drivers/infiniband/hw/mthca/mthca_provider.c 2006-02-09 12:46:29.496350000 +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)
@@ -1288,6 +1293,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