Browse Source

[infiniband] Pass GMA as a parameter to GMA MAD handlers

tags/v0.9.8
Michael Brown 15 years ago
parent
commit
8a852280eb

+ 9
- 8
src/include/gpxe/ib_gma.h View File

@@ -17,9 +17,10 @@ struct ib_device;
17 17
 struct ib_completion_queue;
18 18
 struct ib_queue_pair;
19 19
 union ib_mad;
20
+struct ib_gma;
20 21
 
21
-/** A MAD attribute handler */
22
-struct ib_mad_handler {
22
+/** A GMA attribute handler */
23
+struct ib_gma_handler {
23 24
 	/** Management class */
24 25
 	uint8_t mgmt_class;
25 26
 	/** Class version */
@@ -32,7 +33,7 @@ struct ib_mad_handler {
32 33
 	uint16_t attr_id;
33 34
 	/** Handle attribute
34 35
 	 *
35
-	 * @v ibdev	Infiniband device
36
+	 * @v gma	General management agent
36 37
 	 * @v mad	MAD
37 38
 	 * @ret rc	Return status code
38 39
 	 *
@@ -40,14 +41,14 @@ struct ib_mad_handler {
40 41
 	 * handler returns with a non-zero value in the MAD's @c
41 42
 	 * method field, it will be sent as a response.
42 43
 	 */
43
-	int ( * handle ) ( struct ib_device *ibdev, union ib_mad *mad );
44
+	int ( * handle ) ( struct ib_gma *gma, union ib_mad *mad );
44 45
 };
45 46
 
46
-/** MAD attribute handlers */
47
-#define IB_MAD_HANDLERS __table ( struct ib_mad_handler, "ib_mad_handlers" )
47
+/** GMA attribute handlers */
48
+#define IB_GMA_HANDLERS __table ( struct ib_gma_handler, "ib_gma_handlers" )
48 49
 
49
-/** Declare a MAD attribute handler */
50
-#define __ib_mad_handler __table_entry ( IB_MAD_HANDLERS, 01 )
50
+/** Declare a GMA attribute handler */
51
+#define __ib_gma_handler __table_entry ( IB_GMA_HANDLERS, 01 )
51 52
 
52 53
 /** An Infiniband General Management Agent */
53 54
 struct ib_gma {

+ 9
- 12
src/net/infiniband/ib_gma.c View File

@@ -75,26 +75,23 @@ struct ib_mad_request {
75 75
 static unsigned int next_request_tid;
76 76
 
77 77
 /**
78
- * Identify attribute handler
78
+ * Call attribute handler
79 79
  *
80
- * @v mgmt_class	Management class
81
- * @v class_version	Class version
82
- * @v method		Method
83
- * @v attr_id		Attribute ID (in network byte order)
84
- * @ret handler		Attribute handler (or NULL)
80
+ * @v gma		General management agent
81
+ * @v mad		MAD
82
+ * @ret rc		Return status code
85 83
  */
86
-static int ib_handle_mad ( struct ib_device *ibdev,
87
-			   union ib_mad *mad ) {
84
+static int ib_handle_mad ( struct ib_gma *gma, union ib_mad *mad ) {
88 85
 	struct ib_mad_hdr *hdr = &mad->hdr;
89
-	struct ib_mad_handler *handler;
86
+	struct ib_gma_handler *handler;
90 87
 
91
-	for_each_table_entry ( handler, IB_MAD_HANDLERS ) {
88
+	for_each_table_entry ( handler, IB_GMA_HANDLERS ) {
92 89
 		if ( ( handler->mgmt_class == hdr->mgmt_class ) &&
93 90
 		     ( handler->class_version == hdr->class_version ) &&
94 91
 		     ( handler->method == hdr->method ) &&
95 92
 		     ( handler->attr_id == hdr->attr_id ) ) {
96 93
 			hdr->method = handler->resp_method;
97
-			return handler->handle ( ibdev, mad );
94
+			return handler->handle ( gma, mad );
98 95
 		}
99 96
 	}
100 97
 
@@ -163,7 +160,7 @@ static void ib_gma_complete_recv ( struct ib_device *ibdev,
163 160
 	}
164 161
 
165 162
 	/* Handle MAD, if possible */
166
-	if ( ( rc = ib_handle_mad ( ibdev, mad ) ) != 0 ) {
163
+	if ( ( rc = ib_handle_mad ( gma, mad ) ) != 0 ) {
167 164
 		DBGC ( gma, "GMA %p could not handle TID %08x%08x: %s\n",
168 165
 		       gma, ntohl ( hdr->tid[0] ), ntohl ( hdr->tid[1] ),
169 166
 		       strerror ( rc ) );

+ 35
- 35
src/net/infiniband/ib_mcast.c View File

@@ -36,12 +36,12 @@ FILE_LICENCE ( GPL2_OR_LATER );
36 36
 /**
37 37
  * Transmit multicast group membership request
38 38
  *
39
- * @v ibdev		Infiniband device
39
+ * @v gma		General management agent
40 40
  * @v gid		Multicast GID
41 41
  * @v join		Join (rather than leave) group
42 42
  * @ret rc		Return status code
43 43
  */
44
-static int ib_mc_member_request ( struct ib_device *ibdev, struct ib_gid *gid,
44
+static int ib_mc_member_request ( struct ib_gma *gma, struct ib_gid *gid,
45 45
 				  int join ) {
46 46
 	union ib_mad mad;
47 47
 	struct ib_mad_sa *sa = &mad.sa;
@@ -61,14 +61,13 @@ static int ib_mc_member_request ( struct ib_device *ibdev, struct ib_gid *gid,
61 61
 	sa->sa_data.mc_member_record.scope__join_state = 1;
62 62
 	memcpy ( &sa->sa_data.mc_member_record.mgid, gid,
63 63
 		 sizeof ( sa->sa_data.mc_member_record.mgid ) );
64
-	memcpy ( &sa->sa_data.mc_member_record.port_gid, &ibdev->gid,
64
+	memcpy ( &sa->sa_data.mc_member_record.port_gid, &gma->ibdev->gid,
65 65
 		 sizeof ( sa->sa_data.mc_member_record.port_gid ) );
66 66
 
67 67
 	/* Issue multicast membership record request */
68
-	if ( ( rc = ib_gma_request ( &ibdev->gma, &mad, NULL,
69
-				     join ) ) != 0 ) {
70
-		DBGC ( ibdev, "IBDEV %p could not join group: %s\n",
71
-		       ibdev, strerror ( rc ) );
68
+	if ( ( rc = ib_gma_request ( gma, &mad, NULL, join ) ) != 0 ) {
69
+		DBGC ( gma, "GMA %p could not join group: %s\n",
70
+		       gma, strerror ( rc ) );
72 71
 		return rc;
73 72
 	}
74 73
 
@@ -85,22 +84,23 @@ static int ib_mc_member_request ( struct ib_device *ibdev, struct ib_gid *gid,
85 84
  */
86 85
 int ib_mcast_join ( struct ib_device *ibdev, struct ib_queue_pair *qp,
87 86
 		    struct ib_gid *gid ) {
87
+	struct ib_gma *gma = &ibdev->gma;
88 88
 	int rc;
89 89
 
90
-	DBGC ( ibdev, "IBDEV %p QPN %lx joining %08x:%08x:%08x:%08x\n",
91
-	       ibdev, qp->qpn, ntohl ( gid->u.dwords[0] ),
90
+	DBGC ( gma, "GMA %p QPN %lx joining %08x:%08x:%08x:%08x\n",
91
+	       gma, qp->qpn, ntohl ( gid->u.dwords[0] ),
92 92
 	       ntohl ( gid->u.dwords[1] ), ntohl ( gid->u.dwords[2] ),
93 93
 	       ntohl ( gid->u.dwords[3] ) );
94 94
 
95 95
 	/* Attach queue pair to multicast GID */
96 96
 	if ( ( rc = ib_mcast_attach ( ibdev, qp, gid ) ) != 0 ) {
97
-		DBGC ( ibdev, "IBDEV %p could not attach: %s\n",
98
-		       ibdev, strerror ( rc ) );
97
+		DBGC ( gma, "GMA %p could not attach: %s\n",
98
+		       gma, strerror ( rc ) );
99 99
 		goto err_mcast_attach;
100 100
 	}
101 101
 
102 102
 	/* Initiate multicast membership join */
103
-	if ( ( rc = ib_mc_member_request ( ibdev, gid, 1 ) ) != 0 )
103
+	if ( ( rc = ib_mc_member_request ( gma, gid, 1 ) ) != 0 )
104 104
 		goto err_mc_member_record;
105 105
 
106 106
 	return 0;
@@ -120,9 +120,10 @@ int ib_mcast_join ( struct ib_device *ibdev, struct ib_queue_pair *qp,
120 120
  */
121 121
 void ib_mcast_leave ( struct ib_device *ibdev, struct ib_queue_pair *qp,
122 122
 		      struct ib_gid *gid ) {
123
+	struct ib_gma *gma = &ibdev->gma;
123 124
 
124
-	DBGC ( ibdev, "IBDEV %p QPN %lx leaving %08x:%08x:%08x:%08x\n",
125
-	       ibdev, qp->qpn, ntohl ( gid->u.dwords[0] ),
125
+	DBGC ( gma, "GMA %p QPN %lx leaving %08x:%08x:%08x:%08x\n",
126
+	       gma, qp->qpn, ntohl ( gid->u.dwords[0] ),
126 127
 	       ntohl ( gid->u.dwords[1] ), ntohl ( gid->u.dwords[2] ),
127 128
 	       ntohl ( gid->u.dwords[3] ) );
128 129
 
@@ -130,18 +131,19 @@ void ib_mcast_leave ( struct ib_device *ibdev, struct ib_queue_pair *qp,
130 131
 	ib_mcast_detach ( ibdev, qp, gid );
131 132
 
132 133
 	/* Initiate multicast membership leave */
133
-	ib_mc_member_request ( ibdev, gid, 0 );
134
+	ib_mc_member_request ( gma, gid, 0 );
134 135
 }
135 136
 
136 137
 /**
137 138
  * Handle multicast membership record join response
138 139
  *
139
- * @v ibdev		Infiniband device
140
+ * @v gma		General management agent
140 141
  * @v mad		MAD
141 142
  * @ret rc		Return status code
142 143
  */
143
-static int ib_handle_mc_member_join ( struct ib_device *ibdev,
144
+static int ib_handle_mc_member_join ( struct ib_gma *gma,
144 145
 				      union ib_mad *mad ) {
146
+	struct ib_device *ibdev = gma->ibdev;
145 147
 	struct ib_mc_member_record *mc_member_record =
146 148
 		&mad->sa.sa_data.mc_member_record;
147 149
 	struct ib_queue_pair *qp;
@@ -151,8 +153,8 @@ static int ib_handle_mc_member_join ( struct ib_device *ibdev,
151 153
 
152 154
 	/* Ignore if not a success */
153 155
 	if ( mad->hdr.status != htons ( IB_MGMT_STATUS_OK ) ) {
154
-		DBGC ( ibdev, "IBDEV %p join failed with status %04x\n",
155
-		       ibdev, ntohs ( mad->hdr.status ) );
156
+		DBGC ( gma, "GMA %p join failed with status %04x\n",
157
+		       gma, ntohs ( mad->hdr.status ) );
156 158
 		return -EINVAL;
157 159
 	}
158 160
 
@@ -163,24 +165,22 @@ static int ib_handle_mc_member_join ( struct ib_device *ibdev,
163 165
 	/* Locate matching queue pair */
164 166
 	qp = ib_find_qp_mgid ( ibdev, gid );
165 167
 	if ( ! qp ) {
166
-		DBGC ( ibdev, "IBDEV %p has no QP to join "
167
-		       "%08x:%08x:%08x:%08x\n", ibdev,
168
-		       ntohl ( gid->u.dwords[0] ),
168
+		DBGC ( gma, "GMA %p has no QP to join %08x:%08x:%08x:%08x\n",
169
+		       gma, ntohl ( gid->u.dwords[0] ),
169 170
 		       ntohl ( gid->u.dwords[1] ),
170 171
 		       ntohl ( gid->u.dwords[2] ),
171 172
 		       ntohl ( gid->u.dwords[3] ) );
172 173
 		return -ENOENT;
173 174
 	}
174
-	DBGC ( ibdev, "IBDEV %p QPN %lx joined %08x:%08x:%08x:%08x qkey "
175
-	       "%lx\n", ibdev, qp->qpn,
176
-	       ntohl ( gid->u.dwords[0] ), ntohl ( gid->u.dwords[1] ),
177
-	       ntohl ( gid->u.dwords[2] ), ntohl ( gid->u.dwords[3] ),
178
-	       qkey );
175
+	DBGC ( gma, "GMA %p QPN %lx joined %08x:%08x:%08x:%08x qkey %lx\n",
176
+	       gma, qp->qpn, ntohl ( gid->u.dwords[0] ),
177
+	       ntohl ( gid->u.dwords[1] ), ntohl ( gid->u.dwords[2] ),
178
+	       ntohl ( gid->u.dwords[3] ), qkey );
179 179
 
180 180
 	/* Set queue key */
181 181
 	if ( ( rc = ib_modify_qp ( ibdev, qp, IB_MODIFY_QKEY, qkey ) ) != 0 ) {
182
-		DBGC ( ibdev, "IBDEV %p QPN %lx could not modify qkey: %s\n",
183
-		       ibdev, qp->qpn, strerror ( rc ) );
182
+		DBGC ( gma, "GMA %p QPN %lx could not modify qkey: %s\n",
183
+		       gma, qp->qpn, strerror ( rc ) );
184 184
 		return rc;
185 185
 	}
186 186
 
@@ -190,11 +190,11 @@ static int ib_handle_mc_member_join ( struct ib_device *ibdev,
190 190
 /**
191 191
  * Handle multicast membership record leave response
192 192
  *
193
- * @v ibdev		Infiniband device
193
+ * @v gma		General management agent
194 194
  * @v mad		MAD
195 195
  * @ret rc		Return status code
196 196
  */
197
-static int ib_handle_mc_member_leave ( struct ib_device *ibdev,
197
+static int ib_handle_mc_member_leave ( struct ib_gma *gma,
198 198
 				       union ib_mad *mad ) {
199 199
 	struct ib_mc_member_record *mc_member_record =
200 200
 		&mad->sa.sa_data.mc_member_record;
@@ -202,14 +202,14 @@ static int ib_handle_mc_member_leave ( struct ib_device *ibdev,
202 202
 
203 203
 	/* Ignore if not a success */
204 204
 	if ( mad->hdr.status != htons ( IB_MGMT_STATUS_OK ) ) {
205
-		DBGC ( ibdev, "IBDEV %p leave failed with status %04x\n",
206
-		       ibdev, ntohs ( mad->hdr.status ) );
205
+		DBGC ( gma, "GMA %p leave failed with status %04x\n",
206
+		       gma, ntohs ( mad->hdr.status ) );
207 207
 		return -EINVAL;
208 208
 	}
209 209
 
210 210
 	/* Extract MAD parameters */
211 211
 	gid = &mc_member_record->mgid;
212
-	DBGC ( ibdev, "IBDEV %p left %08x:%08x:%08x:%08x\n", ibdev,
212
+	DBGC ( gma, "GMA %p left %08x:%08x:%08x:%08x\n", gma,
213 213
 	       ntohl ( gid->u.dwords[0] ), ntohl ( gid->u.dwords[1] ),
214 214
 	       ntohl ( gid->u.dwords[2] ), ntohl ( gid->u.dwords[3] ) );
215 215
 
@@ -217,7 +217,7 @@ static int ib_handle_mc_member_leave ( struct ib_device *ibdev,
217 217
 }
218 218
 
219 219
 /** Multicast membership record response handler */
220
-struct ib_mad_handler ib_mc_member_record_handlers[] __ib_mad_handler = {
220
+struct ib_gma_handler ib_mc_member_record_handlers[] __ib_gma_handler = {
221 221
 	{
222 222
 		.mgmt_class = IB_MGMT_CLASS_SUBN_ADM,
223 223
 		.class_version = IB_SA_CLASS_VERSION,

+ 19
- 17
src/net/infiniband/ib_pathrec.c View File

@@ -98,6 +98,7 @@ ib_find_path_cache_entry ( struct ib_device *ibdev, struct ib_gid *dgid ) {
98 98
  */
99 99
 int ib_resolve_path ( struct ib_device *ibdev,
100 100
 		      struct ib_address_vector *av ) {
101
+	struct ib_gma *gma = &ibdev->gma;
101 102
 	struct ib_gid *gid = &av->gid;
102 103
 	struct ib_cached_path_record *cached;
103 104
 	union ib_mad mad;
@@ -107,8 +108,8 @@ int ib_resolve_path ( struct ib_device *ibdev,
107 108
 
108 109
 	/* Sanity check */
109 110
 	if ( ! av->gid_present ) {
110
-		DBGC ( ibdev, "IBDEV %p attempt to look up path record "
111
-		       "without GID\n", ibdev );
111
+		DBGC ( gma, "GMA %p attempt to look up path record "
112
+		       "without GID\n", gma );
112 113
 		return -EINVAL;
113 114
 	}
114 115
 
@@ -119,13 +120,13 @@ int ib_resolve_path ( struct ib_device *ibdev,
119 120
 		av->lid = cached->dlid;
120 121
 		av->rate = cached->rate;
121 122
 		av->sl = cached->sl;
122
-		DBGC2 ( ibdev, "IBDEV %p cache hit for %08x:%08x:%08x:%08x\n",
123
-			ibdev, htonl ( gid->u.dwords[0] ),
123
+		DBGC2 ( gma, "GMA %p cache hit for %08x:%08x:%08x:%08x\n",
124
+			gma, htonl ( gid->u.dwords[0] ),
124 125
 			htonl ( gid->u.dwords[1] ), htonl ( gid->u.dwords[2] ),
125 126
 			htonl ( gid->u.dwords[3] ) );
126 127
 		return 0;
127 128
 	}
128
-	DBGC ( ibdev, "IBDEV %p cache miss for %08x:%08x:%08x:%08x%s\n", ibdev,
129
+	DBGC ( gma, "GMA %p cache miss for %08x:%08x:%08x:%08x%s\n", gma,
129 130
 	       htonl ( gid->u.dwords[0] ), htonl ( gid->u.dwords[1] ),
130 131
 	       htonl ( gid->u.dwords[2] ), htonl ( gid->u.dwords[3] ),
131 132
 	       ( cached ? " (in progress)" : "" ) );
@@ -154,9 +155,9 @@ int ib_resolve_path ( struct ib_device *ibdev,
154 155
 		 sizeof ( sa->sa_data.path_record.sgid ) );
155 156
 
156 157
 	/* Issue path record request */
157
-	if ( ( rc = ib_gma_request ( &ibdev->gma, &mad, NULL, 1 ) ) != 0 ) {
158
-		DBGC ( ibdev, "IBDEV %p could not get path record: %s\n",
159
-		       ibdev, strerror ( rc ) );
158
+	if ( ( rc = ib_gma_request ( gma, &mad, NULL, 1 ) ) != 0 ) {
159
+		DBGC ( gma, "GMA %p could not get path record: %s\n",
160
+		       gma, strerror ( rc ) );
160 161
 		return rc;
161 162
 	}
162 163
 
@@ -167,12 +168,13 @@ int ib_resolve_path ( struct ib_device *ibdev,
167 168
 /**
168 169
  * Handle path record response
169 170
  *
170
- * @v ibdev		Infiniband device
171
+ * @v gma		General management agent
171 172
  * @v mad		MAD
172 173
  * @ret rc		Return status code
173 174
  */
174
-static int ib_handle_path_record ( struct ib_device *ibdev,
175
+static int ib_handle_path_record ( struct ib_gma *gma,
175 176
 				   union ib_mad *mad ) {
177
+	struct ib_device *ibdev = gma->ibdev;
176 178
 	struct ib_path_record *path_record = &mad->sa.sa_data.path_record;
177 179
 	struct ib_gid *dgid = &path_record->dgid;
178 180
 	struct ib_cached_path_record *cached;
@@ -182,8 +184,8 @@ static int ib_handle_path_record ( struct ib_device *ibdev,
182 184
 
183 185
 	/* Ignore if not a success */
184 186
 	if ( mad->hdr.status != htons ( IB_MGMT_STATUS_OK ) ) {
185
-		DBGC ( ibdev, "IBDEV %p path record lookup failed with status "
186
-		       "%04x\n", ibdev, ntohs ( mad->hdr.status ) );
187
+		DBGC ( gma, "GMA %p path record lookup failed with status "
188
+		       "%04x\n", gma, ntohs ( mad->hdr.status ) );
187 189
 		return -EINVAL;
188 190
 	}
189 191
 
@@ -191,15 +193,15 @@ static int ib_handle_path_record ( struct ib_device *ibdev,
191 193
 	dlid = ntohs ( path_record->dlid );
192 194
 	sl = ( path_record->reserved__sl & 0x0f );
193 195
 	rate = ( path_record->rate_selector__rate & 0x3f );
194
-	DBGC ( ibdev, "IBDEV %p path to %08x:%08x:%08x:%08x is %04x sl %d "
195
-	       "rate %d\n", ibdev, htonl ( dgid->u.dwords[0] ),
196
+	DBGC ( gma, "GMA %p path to %08x:%08x:%08x:%08x is %04x sl %d "
197
+	       "rate %d\n", gma, htonl ( dgid->u.dwords[0] ),
196 198
 	       htonl ( dgid->u.dwords[1] ), htonl ( dgid->u.dwords[2] ),
197 199
 	       htonl ( dgid->u.dwords[3] ), dlid, sl, rate );
198 200
 
199 201
 	/* Look for a matching cache entry to fill in */
200 202
 	if ( ( cached = ib_find_path_cache_entry ( ibdev, dgid ) ) != NULL ) {
201
-		DBGC ( ibdev, "IBDEV %p cache add for %08x:%08x:%08x:%08x\n",
202
-		       ibdev, htonl ( dgid->u.dwords[0] ),
203
+		DBGC ( gma, "GMA %p cache add for %08x:%08x:%08x:%08x\n",
204
+		       gma, htonl ( dgid->u.dwords[0] ),
203 205
 		       htonl ( dgid->u.dwords[1] ),
204 206
 		       htonl ( dgid->u.dwords[2] ),
205 207
 		       htonl ( dgid->u.dwords[3] ) );
@@ -212,7 +214,7 @@ static int ib_handle_path_record ( struct ib_device *ibdev,
212 214
 }
213 215
 
214 216
 /** Path record response handler */
215
-struct ib_mad_handler ib_path_record_handler __ib_mad_handler = {
217
+struct ib_gma_handler ib_path_record_handler __ib_gma_handler = {
216 218
 	.mgmt_class = IB_MGMT_CLASS_SUBN_ADM,
217 219
 	.class_version = IB_SA_CLASS_VERSION,
218 220
 	.method = IB_MGMT_METHOD_GET_RESP,

Loading…
Cancel
Save