Make the gid argument to ibv_attach_mcast and ibv_detach_mcast const

ibv_attach_mcast() and ibv_detach_mcast() don't change the gid
argument, so the arguments should be const to allow applications to
pass in constant gids.  This constness flows through to the driver
call struct and into the drivers and back into
ibv_cmd_attach_mcast()/ibv_cmd_detach_mcast().

Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
diff --git a/include/infiniband/driver.h b/include/infiniband/driver.h
index 67a3bf8..e54e0e3 100644
--- a/include/infiniband/driver.h
+++ b/include/infiniband/driver.h
@@ -129,8 +129,8 @@
 int ibv_cmd_create_ah(struct ibv_pd *pd, struct ibv_ah *ah,
 		      struct ibv_ah_attr *attr);
 int ibv_cmd_destroy_ah(struct ibv_ah *ah);
-int ibv_cmd_attach_mcast(struct ibv_qp *qp, union ibv_gid *gid, uint16_t lid);
-int ibv_cmd_detach_mcast(struct ibv_qp *qp, union ibv_gid *gid, uint16_t lid);
+int ibv_cmd_attach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid);
+int ibv_cmd_detach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid);
 
 int ibv_dontfork_range(void *base, size_t size);
 int ibv_dofork_range(void *base, size_t size);
diff --git a/include/infiniband/verbs.h b/include/infiniband/verbs.h
index a04cc62..226d85e 100644
--- a/include/infiniband/verbs.h
+++ b/include/infiniband/verbs.h
@@ -676,9 +676,9 @@
 					     struct ibv_recv_wr **bad_wr);
 	struct ibv_ah *		(*create_ah)(struct ibv_pd *pd, struct ibv_ah_attr *attr);
 	int			(*destroy_ah)(struct ibv_ah *ah);
-	int			(*attach_mcast)(struct ibv_qp *qp, union ibv_gid *gid,
+	int			(*attach_mcast)(struct ibv_qp *qp, const union ibv_gid *gid,
 						uint16_t lid);
-	int			(*detach_mcast)(struct ibv_qp *qp, union ibv_gid *gid,
+	int			(*detach_mcast)(struct ibv_qp *qp, const union ibv_gid *gid,
 						uint16_t lid);
 	void			(*async_event)(struct ibv_async_event *event);
 };
@@ -1060,7 +1060,7 @@
  * the fabric appropriately.  The port associated with the specified
  * QP must also be a member of the multicast group.
  */
-int ibv_attach_mcast(struct ibv_qp *qp, union ibv_gid *gid, uint16_t lid);
+int ibv_attach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid);
 
 /**
  * ibv_detach_mcast - Detaches the specified QP from a multicast group.
@@ -1068,7 +1068,7 @@
  * @gid: Multicast group GID.
  * @lid: Multicast group LID in host byte order.
  */
-int ibv_detach_mcast(struct ibv_qp *qp, union ibv_gid *gid, uint16_t lid);
+int ibv_detach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid);
 
 /**
  * ibv_fork_init - Prepare data structures so that fork() may be used
diff --git a/man/ibv_attach_mcast.3 b/man/ibv_attach_mcast.3
index 7d83d56..722ac9f 100644
--- a/man/ibv_attach_mcast.3
+++ b/man/ibv_attach_mcast.3
@@ -8,10 +8,10 @@
 .nf
 .B #include <infiniband/verbs.h>
 .sp
-.BI "int ibv_attach_mcast(struct ibv_qp " "*qp" ", union ibv_gid " "*gid" ",
+.BI "int ibv_attach_mcast(struct ibv_qp " "*qp" ", const union ibv_gid " "*gid" ",
 .BI "                     uint16_t " "lid" ");
 .sp
-.BI "int ibv_detach_mcast(struct ibv_qp " "*qp" ", union ibv_gid " "*gid" ",
+.BI "int ibv_detach_mcast(struct ibv_qp " "*qp" ", const union ibv_gid " "*gid" ",
 .BI "                     uint16_t " "lid" ");
 .fi
 .SH "DESCRIPTION"
diff --git a/src/cmd.c b/src/cmd.c
index 66d7134..c2e76cf 100644
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -1091,7 +1091,7 @@
 	return 0;
 }
 
-int ibv_cmd_attach_mcast(struct ibv_qp *qp, union ibv_gid *gid, uint16_t lid)
+int ibv_cmd_attach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid)
 {
 	struct ibv_attach_mcast cmd;
 
@@ -1107,7 +1107,7 @@
 	return 0;
 }
 
-int ibv_cmd_detach_mcast(struct ibv_qp *qp, union ibv_gid *gid, uint16_t lid)
+int ibv_cmd_detach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid)
 {
 	struct ibv_detach_mcast cmd;
 
diff --git a/src/verbs.c b/src/verbs.c
index 9e370ce..477e412 100644
--- a/src/verbs.c
+++ b/src/verbs.c
@@ -532,13 +532,13 @@
 }
 default_symver(__ibv_destroy_ah, ibv_destroy_ah);
 
-int __ibv_attach_mcast(struct ibv_qp *qp, union ibv_gid *gid, uint16_t lid)
+int __ibv_attach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid)
 {
 	return qp->context->ops.attach_mcast(qp, gid, lid);
 }
 default_symver(__ibv_attach_mcast, ibv_attach_mcast);
 
-int __ibv_detach_mcast(struct ibv_qp *qp, union ibv_gid *gid, uint16_t lid)
+int __ibv_detach_mcast(struct ibv_qp *qp, const union ibv_gid *gid, uint16_t lid)
 {
 	return qp->context->ops.detach_mcast(qp, gid, lid);
 }