summaryrefslogtreecommitdiff
path: root/utils/fwparam_ibft/fwparam_ibft.h
blob: 92968b3933b1ef2033acf4040e8cd42635ae23d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/*
 * 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
 * (at your option) 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, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
 * USA.
 *
 * Copyright (C) IBM Corporation, 2006,2007
 *
 * Authors: 	Doug Maxey <dwm@austin.ibm.com>
 * 		Patrick Mansfield <patmans@us.ibm.com>
 *
 */

#ifndef FWPARAM_IBFT_H_
#define FWPARAM_IBFT_H_

/* #include <sys/types.h> */
#include <stdint.h>
#include "fw_context.h"

/*
 * Structures here are is based on Doug's original code, and Patrick's
 * interpretation of the IBM internal design document title the "iSCSI
 * Boot Firmware Table (iBFT)".
 */
#define iBFTSTR "iBFT"
#define iBFT_SIG { 'i','B','F','T' }

#define iBFT_REV 1

/*
 * These macros are lower case to make the verify_hdr macro easier.
 */
#define version_control	1
#define version_initiator	1
#define version_nic	1
#define version_target	1
#define version_extensions	1

enum ibft_id {
	id_control = 1,
	id_initiator,
	id_nic,
	id_target,
	id_extensions,
};

struct ibft_hdr {
	uint8_t id;
	uint8_t version;
	uint16_t length;
	uint8_t ind;
	uint8_t flags;
};

struct ibft_table_hdr {
	uint8_t signature[4];
	uint32_t length;
	uint8_t revision;
	uint8_t checksum;
	uint8_t oemid[6];
	uint8_t oem_table_id[8];
	uint8_t rsvd1[24];
} __attribute__((__packed__));

struct ibft_control {
	struct ibft_hdr hdr;
	uint16_t extensions;
	uint16_t initiator_off;
	uint16_t nic0_off;
	uint16_t tgt0_off;
	uint16_t nic1_off;
	uint16_t tgt1_off;
} __attribute__((__packed__));

struct ibft_initiator {
#define INIT_FLAG_VALID 1
#define INIT_FLAG_FW_SEL_BOOT 2
	struct ibft_hdr hdr;
	uint8_t isns_server[16];
	uint8_t slp_server[16];
	uint8_t pri_radius_server[16];
	uint8_t sec_radius_server[16];
	uint16_t initiator_name_len;
	uint16_t initiator_name_off;
} __attribute__((__packed__));

struct ibft_nic {
#define NIC_FLAG_VALID 1
#define NIC_FLAG_FW_SEL_BOOT 2
	struct ibft_hdr hdr;
	uint8_t ip_addr[16];
	uint8_t subnet_mask_prefix;
	uint8_t origin;
	uint8_t gateway[16];
	uint8_t primary_dns[16];
	uint8_t secondary_dns[16];
	uint8_t dhcp[16];
	uint16_t vlan;
	uint8_t mac[6];
	uint16_t pci_bdf;
	uint16_t hostname_len;
	uint16_t hostname_off;
} __attribute__((__packed__));

struct ibft_tgt {
#define TGT_FLAG_VALID 1
#define TGT_FLAG_FW_SEL_BOOT 2
#define TGT_FLAG_USE_RADIUS_CHAT 4
#define TGT_FLAG_USE_RADIUS_RCHAT 8
	struct ibft_hdr hdr;
	uint8_t ip_addr[16];
	uint16_t port;
	uint8_t lun[8];
#define TGT_CHAP 1
#define TGT_MUTUAL_CHAP 2
	uint8_t chap_type;
	uint8_t nic_assoc;
	uint16_t tgt_name_len;
	uint16_t tgt_name_off;
	uint16_t chap_name_len;
	uint16_t chap_name_off;
	uint16_t chap_secret_len;
	uint16_t chap_secret_off;
	uint16_t rev_chap_name_len;
	uint16_t rev_chap_name_off;
	uint16_t rev_chap_secret_len;
	uint16_t rev_chap_secret_off;
} __attribute__((__packed__));

/* Common variables */
#define FILENAMESZ (1024)
extern char filename[FILENAMESZ];
#define X86_DEFAULT_FILENAME "/dev/mem"
extern int debug;
extern int dev_count;

extern int fwparam_ibft(struct boot_context *context, const char *filepath);
#endif /* FWPARAM_IBFT_H_ */