[readline] Extend maximum read line length to 1024 characters
[ipxe.git] / src / net / infiniband / ib_service.c
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 }