Selaa lähdekoodia

[infiniband] Add support for performing service record lookups

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 8 vuotta sitten
vanhempi
commit
ff13eeb747
3 muutettua tiedostoa jossa 106 lisäystä ja 1 poistoa
  1. 19
    1
      src/include/ipxe/ib_mad.h
  2. 20
    0
      src/include/ipxe/ib_service.h
  3. 67
    0
      src/net/infiniband/ib_service.c

+ 19
- 1
src/include/ipxe/ib_mad.h Näytä tiedosto

@@ -219,8 +219,25 @@ struct ib_sa_hdr {
219 219
 	uint32_t comp_mask[2];
220 220
 } __attribute__ (( packed ));
221 221
 
222
-#define IB_SA_ATTR_MC_MEMBER_REC		0x38
222
+#define IB_SA_ATTR_SERVICE_REC			0x31
223 223
 #define IB_SA_ATTR_PATH_REC			0x35
224
+#define IB_SA_ATTR_MC_MEMBER_REC		0x38
225
+
226
+struct ib_service_record {
227
+	uint64_t id;
228
+	union ib_gid gid;
229
+	uint16_t pkey;
230
+	uint16_t reserved;
231
+	uint32_t lease;
232
+	uint8_t key[16];
233
+	char name[64];
234
+	uint8_t data8[16];
235
+	uint16_t data16[8];
236
+	uint32_t data32[4];
237
+	uint64_t data64[2];
238
+} __attribute__ (( packed ));
239
+
240
+#define IB_SA_SERVICE_REC_NAME			(1<<6)
224 241
 
225 242
 struct ib_path_record {
226 243
 	uint32_t reserved0[2];
@@ -278,6 +295,7 @@ struct ib_mc_member_record {
278 295
 #define IB_SA_MCMEMBER_REC_PROXY_JOIN		(1<<17)
279 296
 
280 297
 union ib_sa_data {
298
+	struct ib_service_record service_record;
281 299
 	struct ib_path_record path_record;
282 300
 	struct ib_mc_member_record mc_member_record;
283 301
 } __attribute__ (( packed ));

+ 20
- 0
src/include/ipxe/ib_service.h Näytä tiedosto

@@ -0,0 +1,20 @@
1
+#ifndef _IPXE_IB_SERVICE_H
2
+#define _IPXE_IB_SERVICE_H
3
+
4
+/** @file
5
+ *
6
+ * Infiniband service records
7
+ *
8
+ */
9
+
10
+FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11
+
12
+#include <ipxe/infiniband.h>
13
+#include <ipxe/ib_mi.h>
14
+
15
+extern struct ib_mad_transaction *
16
+ib_create_service_madx ( struct ib_device *ibdev,
17
+			 struct ib_mad_interface *mi, const char *name,
18
+			 struct ib_mad_transaction_operations *op );
19
+
20
+#endif /* _IPXE_IB_SERVICE_H */

+ 67
- 0
src/net/infiniband/ib_service.c Näytä tiedosto

@@ -0,0 +1,67 @@
1
+/*
2
+ * Copyright (C) 2016 Michael Brown <mbrown@fensystems.co.uk>.
3
+ *
4
+ * This program is free software; you can redistribute it and/or
5
+ * modify it under the terms of the GNU General Public License as
6
+ * published by the Free Software Foundation; either version 2 of the
7
+ * License, or any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful, but
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
+ * General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU General Public License
15
+ * along with this program; if not, write to the Free Software
16
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17
+ * 02110-1301, USA.
18
+ *
19
+ * You can also choose to distribute this program under the terms of
20
+ * the Unmodified Binary Distribution Licence (as given in the file
21
+ * COPYING.UBDL), provided that you have satisfied its requirements.
22
+ */
23
+
24
+FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
25
+
26
+#include <string.h>
27
+#include <stdio.h>
28
+#include <byteswap.h>
29
+#include <ipxe/infiniband.h>
30
+#include <ipxe/ib_mi.h>
31
+#include <ipxe/ib_service.h>
32
+
33
+/** @file
34
+ *
35
+ * Infiniband service records
36
+ *
37
+ */
38
+
39
+/**
40
+ * Create service record management transaction
41
+ *
42
+ * @v ibdev		Infiniband device
43
+ * @v mi		Management interface
44
+ * @v name		Service name
45
+ * @v op		Management transaction operations
46
+ * @ret madx		Management transaction, or NULL on error
47
+ */
48
+struct ib_mad_transaction *
49
+ib_create_service_madx ( struct ib_device *ibdev,
50
+			 struct ib_mad_interface *mi, const char *name,
51
+			 struct ib_mad_transaction_operations *op ) {
52
+	union ib_mad mad;
53
+	struct ib_mad_sa *sa = &mad.sa;
54
+	struct ib_service_record *svc = &sa->sa_data.service_record;
55
+
56
+	/* Construct service record request */
57
+	memset ( sa, 0, sizeof ( *sa ) );
58
+	sa->mad_hdr.mgmt_class = IB_MGMT_CLASS_SUBN_ADM;
59
+	sa->mad_hdr.class_version = IB_SA_CLASS_VERSION;
60
+	sa->mad_hdr.method = IB_MGMT_METHOD_GET;
61
+	sa->mad_hdr.attr_id = htons ( IB_SA_ATTR_SERVICE_REC );
62
+	sa->sa_hdr.comp_mask[1] = htonl ( IB_SA_SERVICE_REC_NAME );
63
+	snprintf ( svc->name, sizeof ( svc->name ), "%s", name );
64
+
65
+	/* Create management transaction */
66
+	return ib_create_madx ( ibdev, mi, &mad, NULL, op );
67
+}

Loading…
Peruuta
Tallenna