iPXE
ib_service.c
Go to the documentation of this file.
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 *
50  struct ib_mad_interface *mi, const char *name,
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 }
#define IB_SA_CLASS_VERSION
Definition: ib_mad.h:207
#define IB_MGMT_METHOD_GET
Definition: ib_mad.h:569
Infiniband management interfaces.
const char * name
Definition: ath9k_hw.c:1984
Infiniband protocol.
char name[64]
Definition: ib_mad.h:233
An Infiniband management interface.
Definition: ib_mi.h:88
#define htonl(value)
Definition: byteswap.h:133
An Infiniband device.
Definition: infiniband.h:398
An Infiniband management transaction.
Definition: ib_mi.h:70
struct ib_mad_transaction * ib_create_madx(struct ib_device *ibdev, struct ib_mad_interface *mi, union ib_mad *mad, struct ib_address_vector *av, struct ib_mad_transaction_operations *op)
Create management transaction.
Definition: ib_mi.c:287
struct sockaddr sa
Definition: syslog.c:55
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)
Create service record management transaction.
Definition: ib_service.c:49
struct ib_mad_sa sa
Definition: ib_mad.h:613
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
#define IB_SA_ATTR_SERVICE_REC
Definition: ib_mad.h:222
#define IB_MGMT_CLASS_SUBN_ADM
Definition: ib_mad.h:557
struct ib_mad_interface * mi
Associated management interface.
Definition: ib_mi.h:72
A management datagram.
Definition: ib_mad.h:610
#define IB_SA_SERVICE_REC_NAME
Definition: ib_mad.h:240
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
Definition: vsprintf.c:382
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
Infiniband service records.
Infiniband management transaction operations.
Definition: ib_mi.h:49
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
A subnet administration MAD.
Definition: ib_mad.h:596
String functions.
#define htons(value)
Definition: byteswap.h:135
union ib_mad mad
Definition: arbel.h:12
void * memset(void *dest, int character, size_t len) __nonnull