iPXE
ib_service.c
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2016 Michael Brown <mbrown@fensystems.co.uk>.
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License as
00006  * published by the Free Software Foundation; either version 2 of the
00007  * License, or any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017  * 02110-1301, USA.
00018  *
00019  * You can also choose to distribute this program under the terms of
00020  * the Unmodified Binary Distribution Licence (as given in the file
00021  * COPYING.UBDL), provided that you have satisfied its requirements.
00022  */
00023 
00024 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00025 
00026 #include <string.h>
00027 #include <stdio.h>
00028 #include <byteswap.h>
00029 #include <ipxe/infiniband.h>
00030 #include <ipxe/ib_mi.h>
00031 #include <ipxe/ib_service.h>
00032 
00033 /** @file
00034  *
00035  * Infiniband service records
00036  *
00037  */
00038 
00039 /**
00040  * Create service record management transaction
00041  *
00042  * @v ibdev             Infiniband device
00043  * @v mi                Management interface
00044  * @v name              Service name
00045  * @v op                Management transaction operations
00046  * @ret madx            Management transaction, or NULL on error
00047  */
00048 struct ib_mad_transaction *
00049 ib_create_service_madx ( struct ib_device *ibdev,
00050                          struct ib_mad_interface *mi, const char *name,
00051                          struct ib_mad_transaction_operations *op ) {
00052         union ib_mad mad;
00053         struct ib_mad_sa *sa = &mad.sa;
00054         struct ib_service_record *svc = &sa->sa_data.service_record;
00055 
00056         /* Construct service record request */
00057         memset ( sa, 0, sizeof ( *sa ) );
00058         sa->mad_hdr.mgmt_class = IB_MGMT_CLASS_SUBN_ADM;
00059         sa->mad_hdr.class_version = IB_SA_CLASS_VERSION;
00060         sa->mad_hdr.method = IB_MGMT_METHOD_GET;
00061         sa->mad_hdr.attr_id = htons ( IB_SA_ATTR_SERVICE_REC );
00062         sa->sa_hdr.comp_mask[1] = htonl ( IB_SA_SERVICE_REC_NAME );
00063         snprintf ( svc->name, sizeof ( svc->name ), "%s", name );
00064 
00065         /* Create management transaction */
00066         return ib_create_madx ( ibdev, mi, &mad, NULL, op );
00067 }