]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[infiniband] Add support for performing service record lookups
authorMichael Brown <mcb30@ipxe.org>
Tue, 1 Mar 2016 09:41:11 +0000 (09:41 +0000)
committerMichael Brown <mcb30@ipxe.org>
Tue, 8 Mar 2016 12:08:58 +0000 (12:08 +0000)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/include/ipxe/ib_mad.h
src/include/ipxe/ib_service.h [new file with mode: 0644]
src/net/infiniband/ib_service.c [new file with mode: 0644]

index 454eda1f55e18837fc989dd9320fbca9b698d827..96e460eddcebf55efd72a44955c636348efdc91a 100644 (file)
@@ -219,8 +219,25 @@ struct ib_sa_hdr {
        uint32_t comp_mask[2];
 } __attribute__ (( packed ));
 
-#define IB_SA_ATTR_MC_MEMBER_REC               0x38
+#define IB_SA_ATTR_SERVICE_REC                 0x31
 #define IB_SA_ATTR_PATH_REC                    0x35
+#define IB_SA_ATTR_MC_MEMBER_REC               0x38
+
+struct ib_service_record {
+       uint64_t id;
+       union ib_gid gid;
+       uint16_t pkey;
+       uint16_t reserved;
+       uint32_t lease;
+       uint8_t key[16];
+       char name[64];
+       uint8_t data8[16];
+       uint16_t data16[8];
+       uint32_t data32[4];
+       uint64_t data64[2];
+} __attribute__ (( packed ));
+
+#define IB_SA_SERVICE_REC_NAME                 (1<<6)
 
 struct ib_path_record {
        uint32_t reserved0[2];
@@ -278,6 +295,7 @@ struct ib_mc_member_record {
 #define IB_SA_MCMEMBER_REC_PROXY_JOIN          (1<<17)
 
 union ib_sa_data {
+       struct ib_service_record service_record;
        struct ib_path_record path_record;
        struct ib_mc_member_record mc_member_record;
 } __attribute__ (( packed ));
diff --git a/src/include/ipxe/ib_service.h b/src/include/ipxe/ib_service.h
new file mode 100644 (file)
index 0000000..88afe4e
--- /dev/null
@@ -0,0 +1,20 @@
+#ifndef _IPXE_IB_SERVICE_H
+#define _IPXE_IB_SERVICE_H
+
+/** @file
+ *
+ * Infiniband service records
+ *
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
+
+#include <ipxe/infiniband.h>
+#include <ipxe/ib_mi.h>
+
+extern struct ib_mad_transaction *
+ib_create_service_madx ( struct ib_device *ibdev,
+                        struct ib_mad_interface *mi, const char *name,
+                        struct ib_mad_transaction_operations *op );
+
+#endif /* _IPXE_IB_SERVICE_H */
diff --git a/src/net/infiniband/ib_service.c b/src/net/infiniband/ib_service.c
new file mode 100644 (file)
index 0000000..f035382
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2016 Michael Brown <mbrown@fensystems.co.uk>.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ * You can also choose to distribute this program under the terms of
+ * the Unmodified Binary Distribution Licence (as given in the file
+ * COPYING.UBDL), provided that you have satisfied its requirements.
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
+
+#include <string.h>
+#include <stdio.h>
+#include <byteswap.h>
+#include <ipxe/infiniband.h>
+#include <ipxe/ib_mi.h>
+#include <ipxe/ib_service.h>
+
+/** @file
+ *
+ * Infiniband service records
+ *
+ */
+
+/**
+ * Create service record management transaction
+ *
+ * @v ibdev            Infiniband device
+ * @v mi               Management interface
+ * @v name             Service name
+ * @v op               Management transaction operations
+ * @ret madx           Management transaction, or NULL on error
+ */
+struct ib_mad_transaction *
+ib_create_service_madx ( struct ib_device *ibdev,
+                        struct ib_mad_interface *mi, const char *name,
+                        struct ib_mad_transaction_operations *op ) {
+       union ib_mad mad;
+       struct ib_mad_sa *sa = &mad.sa;
+       struct ib_service_record *svc = &sa->sa_data.service_record;
+
+       /* Construct service record request */
+       memset ( sa, 0, sizeof ( *sa ) );
+       sa->mad_hdr.mgmt_class = IB_MGMT_CLASS_SUBN_ADM;
+       sa->mad_hdr.class_version = IB_SA_CLASS_VERSION;
+       sa->mad_hdr.method = IB_MGMT_METHOD_GET;
+       sa->mad_hdr.attr_id = htons ( IB_SA_ATTR_SERVICE_REC );
+       sa->sa_hdr.comp_mask[1] = htonl ( IB_SA_SERVICE_REC_NAME );
+       snprintf ( svc->name, sizeof ( svc->name ), "%s", name );
+
+       /* Create management transaction */
+       return ib_create_madx ( ibdev, mi, &mad, NULL, op );
+}