Browse Source

[infiniband] Add support for the SRP Boot Firmware Table

The SRP Boot Firmware Table serves a similar role to the iSCSI and AoE
Boot Firmware Tables; it provides information required by the loaded
OS in order to establish a connection back to the SRP boot device.
tags/v0.9.8
Michael Brown 14 years ago
parent
commit
e5f14e5a32

+ 125
- 0
src/arch/i386/include/gpxe/sbft.h View File

@@ -0,0 +1,125 @@
1
+#ifndef _GPXE_SBFT_H
2
+#define _GPXE_SBFT_H
3
+
4
+/*
5
+ * Copyright (C) 2009 Fen Systems Ltd <mbrown@fensystems.co.uk>.
6
+ * All rights reserved.
7
+ *
8
+ * Redistribution and use in source and binary forms, with or without
9
+ * modification, are permitted provided that the following conditions
10
+ * are met:
11
+ *
12
+ *   Redistributions of source code must retain the above copyright
13
+ *   notice, this list of conditions and the following disclaimer.
14
+ *
15
+ *   Redistributions in binary form must reproduce the above copyright
16
+ *   notice, this list of conditions and the following disclaimer in
17
+ *   the documentation and/or other materials provided with the
18
+ *   distribution.
19
+ *
20
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
25
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
31
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
32
+ */
33
+
34
+FILE_LICENCE ( BSD2 );
35
+
36
+/** @file
37
+ *
38
+ * SRP boot firmware table
39
+ *
40
+ * The working draft specification for the SRP boot firmware table can
41
+ * be found at
42
+ *
43
+ *   http://etherboot.org/wiki/srp/sbft
44
+ *
45
+ */
46
+
47
+#include <stdint.h>
48
+#include <gpxe/acpi.h>
49
+#include <gpxe/scsi.h>
50
+#include <gpxe/srp.h>
51
+#include <gpxe/ib_srp.h>
52
+
53
+/** SRP Boot Firmware Table signature */
54
+#define SBFT_SIG "sBFT"
55
+
56
+/** An offset from the start of the sBFT */
57
+typedef uint16_t sbft_off_t;
58
+
59
+/**
60
+ * SRP Boot Firmware Table
61
+ */
62
+struct sbft_table {
63
+	/** ACPI header */
64
+	struct acpi_description_header acpi;
65
+	/** Offset to SCSI subtable */
66
+	sbft_off_t scsi_offset;
67
+	/** Offset to SRP subtable */
68
+	sbft_off_t srp_offset;
69
+	/** Offset to IB subtable, if present */
70
+	sbft_off_t ib_offset;
71
+	/** Reserved */
72
+	uint8_t reserved[6];
73
+} __attribute__ (( packed ));
74
+
75
+/**
76
+ * sBFT SCSI subtable
77
+ */
78
+struct sbft_scsi_subtable {
79
+	/** LUN */
80
+	struct scsi_lun lun;
81
+} __attribute__ (( packed ));
82
+
83
+/**
84
+ * sBFT SRP subtable
85
+ */
86
+struct sbft_srp_subtable {
87
+	/** Initiator and target ports */
88
+	struct srp_port_ids port_ids;
89
+} __attribute__ (( packed ));
90
+
91
+/**
92
+ * sBFT IB subtable
93
+ */
94
+struct sbft_ib_subtable {
95
+	/** Source GID */
96
+	struct ib_gid sgid;
97
+	/** Destination GID */
98
+	struct ib_gid dgid;
99
+	/** Service ID */
100
+	struct ib_gid_half service_id;
101
+	/** Partition key */
102
+	uint16_t pkey;
103
+	/** Reserved */
104
+	uint8_t reserved[6];
105
+} __attribute__ (( packed ));
106
+
107
+/**
108
+ * An sBFT created by gPXE
109
+ */
110
+struct gpxe_sbft {
111
+	/** The table header */
112
+	struct sbft_table table;
113
+	/** The SCSI subtable */
114
+	struct sbft_scsi_subtable scsi;
115
+	/** The SRP subtable */
116
+	struct sbft_srp_subtable srp;
117
+	/** The IB subtable */
118
+	struct sbft_ib_subtable ib;
119
+} __attribute__ (( packed, aligned ( 16 ) ));
120
+
121
+struct srp_device;
122
+
123
+extern int sbft_fill_data ( struct srp_device *srp );
124
+
125
+#endif /* _GPXE_SBFT_H */

+ 6
- 0
src/arch/i386/interface/pcbios/ib_srpboot.c View File

@@ -6,6 +6,7 @@
6 6
 #include <gpxe/sanboot.h>
7 7
 #include <int13.h>
8 8
 #include <gpxe/srp.h>
9
+#include <gpxe/sbft.h>
9 10
 
10 11
 FILE_LICENCE ( GPL2_OR_LATER );
11 12
 
@@ -38,6 +39,11 @@ static int ib_srpboot ( const char *root_path ) {
38 39
 
39 40
 	drive->blockdev = &scsi->blockdev;
40 41
 
42
+	/* FIXME: ugly, ugly hack */
43
+	struct srp_device *srp =
44
+		container_of ( scsi->backend, struct srp_device, refcnt );
45
+	sbft_fill_data ( srp );
46
+
41 47
 	register_int13_drive ( drive );
42 48
 	printf ( "Registered as BIOS drive %#02x\n", drive->drive );
43 49
 	printf ( "Booting from BIOS drive %#02x\n", drive->drive );

+ 105
- 0
src/arch/i386/interface/pcbios/sbft.c View File

@@ -0,0 +1,105 @@
1
+/*
2
+ * Copyright (C) 2009 Fen Systems Ltd <mbrown@fensystems.co.uk>.
3
+ * All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without
6
+ * modification, are permitted provided that the following conditions
7
+ * are met:
8
+ *
9
+ *   Redistributions of source code must retain the above copyright
10
+ *   notice, this list of conditions and the following disclaimer.
11
+ *
12
+ *   Redistributions in binary form must reproduce the above copyright
13
+ *   notice, this list of conditions and the following disclaimer in
14
+ *   the documentation and/or other materials provided with the
15
+ *   distribution.
16
+ *
17
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
29
+ */
30
+
31
+FILE_LICENCE ( BSD2 );
32
+
33
+/** @file
34
+ *
35
+ * SRP boot firmware table
36
+ *
37
+ */
38
+
39
+#include <assert.h>
40
+#include <realmode.h>
41
+#include <gpxe/srp.h>
42
+#include <gpxe/ib_srp.h>
43
+#include <gpxe/acpi.h>
44
+#include <gpxe/sbft.h>
45
+
46
+#define sbftab __use_data16 ( sbftab )
47
+/** The sBFT used by gPXE */
48
+struct gpxe_sbft __data16 ( sbftab ) = {
49
+	/* Table header */
50
+	.table = {
51
+		/* ACPI header */
52
+		.acpi = {
53
+			.signature = SBFT_SIG,
54
+			.length = sizeof ( sbftab ),
55
+			.revision = 1,
56
+			.oem_id = "FENSYS",
57
+			.oem_table_id = "gPXE",
58
+		},
59
+		.scsi_offset = offsetof ( typeof ( sbftab ), scsi ),
60
+		.srp_offset = offsetof ( typeof ( sbftab ), srp ),
61
+		.ib_offset = offsetof ( typeof ( sbftab ), ib ),
62
+	},
63
+};
64
+
65
+/**
66
+ * Fill in all variable portions of sBFT
67
+ *
68
+ * @v srp		SRP device
69
+ * @ret rc		Return status code
70
+ */
71
+int sbft_fill_data ( struct srp_device *srp ) {
72
+	struct sbft_scsi_subtable *sbft_scsi = &sbftab.scsi;
73
+	struct sbft_srp_subtable *sbft_srp = &sbftab.srp;
74
+	struct sbft_ib_subtable *sbft_ib = &sbftab.ib;
75
+	struct ib_srp_parameters *ib_params;
76
+	struct segoff rm_sbftab = {
77
+		.segment = rm_ds,
78
+		.offset = __from_data16 ( &sbftab ),
79
+	};
80
+
81
+	/* Fill in the SCSI subtable */
82
+	memcpy ( &sbft_scsi->lun, &srp->lun, sizeof ( sbft_scsi->lun ) );
83
+
84
+	/* Fill in the SRP subtable */
85
+	memcpy ( &sbft_srp->port_ids, &srp->port_ids,
86
+		 sizeof ( sbft_srp->port_ids ) );
87
+
88
+	/* Fill in the IB subtable */
89
+	assert ( srp->transport == &ib_srp_transport );
90
+	ib_params = ib_srp_params ( srp );
91
+	memcpy ( &sbft_ib->sgid, &ib_params->sgid, sizeof ( sbft_ib->sgid ) );
92
+	memcpy ( &sbft_ib->dgid, &ib_params->dgid, sizeof ( sbft_ib->dgid ) );
93
+	memcpy ( &sbft_ib->service_id, &ib_params->service_id,
94
+		 sizeof ( sbft_ib->service_id ) );
95
+	sbft_ib->pkey = ib_params->pkey;
96
+
97
+	/* Update checksum */
98
+	acpi_fix_checksum ( &sbftab.table.acpi );
99
+
100
+	DBGC ( &sbftab, "SRP Boot Firmware Table at %04x:%04x:\n",
101
+	       rm_sbftab.segment, rm_sbftab.offset );
102
+	DBGC_HDA ( &sbftab, rm_sbftab, &sbftab, sizeof ( sbftab ) );
103
+
104
+	return 0;
105
+}

Loading…
Cancel
Save