aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firmware
diff options
context:
space:
mode:
authorMike Christie <michaelc@cs.wisc.edu>2010-04-12 14:06:18 -0400
committerKonrad Rzeszutek Wilk <konrad@kernel.org>2010-05-11 13:02:38 -0400
commitb33a84a384776fb2593dac4d77c72050f9e181b0 (patch)
tree4499d398d243b6ea2b4681a57cfc96c74ba2a00e /drivers/firmware
parentba4ee30c6c797de148dcc7254cf6d531aba71d9b (diff)
ibft: convert iscsi_ibft module to iscsi boot lib
This patch just converts the iscsi_ibft module to the iscsi boot sysfs lib module. Signed-off-by: Mike Christie <michaelc@cs.wisc.edu> Signed-off-by: Konrad Rzeszutek Wilk <konrad@kernel.org> Signed-off-by: Peter Jones <pjones@redhat.com>
Diffstat (limited to 'drivers/firmware')
-rw-r--r--drivers/firmware/Kconfig1
-rw-r--r--drivers/firmware/iscsi_ibft.c698
2 files changed, 248 insertions, 451 deletions
<
diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig
index 571d2182613d..a6c670b8ce52 100644
--- a/drivers/firmware/Kconfig
+++ b/drivers/firmware/Kconfig
@@ -132,6 +132,7 @@ config ISCSI_BOOT_SYSFS
132 132
133config ISCSI_IBFT 133config ISCSI_IBFT
134 tristate "iSCSI Boot Firmware Table Attributes module" 134 tristate "iSCSI Boot Firmware Table Attributes module"
135 select ISCSI_BOOT_SYSFS
135 depends on ISCSI_IBFT_FIND 136 depends on ISCSI_IBFT_FIND
136 default n 137 default n
137 help 138 help
diff --git a/drivers/firmware/iscsi_ibft.c b/drivers/firmware/iscsi_ibft.c
index b3ab24f9d78f..4f04ec0410a0 100644
--- a/drivers/firmware/iscsi_ibft.c
+++ b/drivers/firmware/iscsi_ibft.c
@@ -82,6 +82,7 @@
82#include <linux/string.h> 82#include <linux/string.h>
83#include <linux/types.h> 83#include <linux/types.h>
84#include <linux/acpi.h> 84#include <linux/acpi.h>
85#include <linux/iscsi_boot_sysfs.h>
85 86
86#define IBFT_ISCSI_VERSION "0.5.0" 87#define IBFT_ISCSI_VERSION "0.5.0"
87#define IBFT_ISCSI_DATE "2010-Feb-25" 88#define IBFT_ISCSI_DATE "2010-Feb-25"
@@ -170,74 +171,6 @@ enum ibft_id {
170}; 171};
171 172
172/* 173/*
173 * We do not support the other types, hence the usage of NULL.
174 * This maps to the enum ibft_id.
175 */
176static const char *ibft_id_names[] =
177 {NULL, NULL, "initiator", "ethernet%d", "target%d", NULL, NULL};
178
179/*
180 * The text attributes names for each of the kobjects.
181*/
182enum ibft_eth_properties_enum {
183 ibft_eth_index,
184 ibft_eth_flags,
185 ibft_eth_ip_addr,
186 ibft_eth_subnet_mask,
187 ibft_eth_origin,
188 ibft_eth_gateway,
189 ibft_eth_primary_dns,
190 ibft_eth_secondary_dns,
191 ibft_eth_dhcp,
192 ibft_eth_vlan,
193 ibft_eth_mac,
194 /* ibft_eth_pci_bdf - this is replaced by link to the device itself. */
195 ibft_eth_hostname,
196 ibft_eth_end_marker,
197};
198
199static const char *ibft_eth_properties[] =
200 {"index", "flags", "ip-addr", "subnet-mask", "origin", "gateway",
201 "primary-dns", "secondary-dns", "dhcp", "vlan", "mac", "hostname",
202 NULL};
203
204enum ibft_tgt_properties_enum {
205 ibft_tgt_index,
206 ibft_tgt_flags,
207 ibft_tgt_ip_addr,
208 ibft_tgt_port,
209 ibft_tgt_lun,
210 ibft_tgt_chap_type,
211 ibft_tgt_nic_assoc,
212 ibft_tgt_name,
213 ibft_tgt_chap_name,
214 ibft_tgt_chap_secret,
215 ibft_tgt_rev_chap_name,
216 ibft_tgt_rev_chap_secret,
217 ibft_tgt_end_marker,
218};
219
220static const char *ibft_tgt_properties[] =
221 {"index", "flags", "ip-addr", "port", "lun", "chap-type", "nic-assoc",
222 "target-name", "chap-name", "chap-secret", "rev-chap-name",
223 "rev-chap-name-secret", NULL};
224
225enum ibft_initiator_properties_enum {
226 ibft_init_index,
227 ibft_init_flags,
228 ibft_init_isns_server,
229 ibft_init_slp_server,
230 ibft_init_pri_radius_server,
231 ibft_init_sec_radius_server,
232 ibft_init_initiator_name,
233 ibft_init_end_marker,
234};
235
236static const char *ibft_initiator_properties[] =
237 {"index", "flags", "isns-server", "slp-server", "pri-radius-server",
238 "sec-radius-server", "initiator-name", NULL};
239
240/*
241 * The kobject and attribute structures. 174 * The kobject and attribute structures.
242 */ 175 */
243 176
@@ -249,29 +182,9 @@ struct ibft_kobject {
249 struct ibft_tgt *tgt; 182 struct ibft_tgt *tgt;
250 struct ibft_hdr *hdr; 183 struct ibft_hdr *hdr;
251 }; 184 };
252 struct kobject kobj;
253 struct list_head node;
254}; 185};
255 186
256struct ibft_attribute { 187static struct iscsi_boot_kset *boot_kset;
257 struct attribute attr;
258 ssize_t (*show) (struct ibft_kobject *entry,
259 struct ibft_attribute *attr, char *buf);
260 union {
261 struct ibft_initiator *initiator;
262 struct ibft_nic *nic;
263 struct ibft_tgt *tgt;
264 struct ibft_hdr *hdr;
265 };
266 struct kobject *kobj;
267 int type; /* The enum of the type. This can be any value of:
268 ibft_eth_properties_enum, ibft_tgt_properties_enum,
269 or ibft_initiator_properties_enum. */
270 struct list_head node;
271};
272
273static LIST_HEAD(ibft_attr_list);
274static LIST_HEAD(ibft_kobject_list);
275 188
276static const char nulls[16]; 189static const char nulls[16];
277 190
@@ -310,35 +223,27 @@ static ssize_t sprintf_string(char *str, int len, char *buf)
310static int ibft_verify_hdr(char *t, struct ibft_hdr *hdr, int id, int length) 223static int ibft_verify_hdr(char *t, struct ibft_hdr *hdr, int id, int length)
311{ 224{
312 if (hdr->id != id) { 225 if (hdr->id != id) {
313 printk(KERN_ERR "iBFT error: We expected the " \ 226 printk(KERN_ERR "iBFT error: We expected the %s " \
314 "field header.id to have %d but " \ 227 "field header.id to have %d but " \
315 "found %d instead!\n", id, hdr->id); 228 "found %d instead!\n", t, id, hdr->id);
316 return -ENODEV; 229 return -ENODEV;
317 } 230 }
318 if (hdr->length != length) { 231 if (hdr->length != length) {
319 printk(KERN_ERR "iBFT error: We expected the " \ 232 printk(KERN_ERR "iBFT error: We expected the %s " \
320 "field header.length to have %d but " \ 233 "field header.length to have %d but " \
321 "found %d instead!\n", length, hdr->length); 234 "found %d instead!\n", t, length, hdr->length);
322 return -ENODEV; 235 return -ENODEV;
323 } 236 }
324 237
325 return 0; 238 return 0;
326} 239}
327 240
328static void ibft_release(struct kobject *kobj)
329{
330 struct ibft_kobject *ibft =
331 container_of(kobj, struct ibft_kobject, kobj);
332 kfree(ibft);
333}
334
335/* 241/*
336 * Routines for parsing the iBFT data to be human readable. 242 * Routines for parsing the iBFT data to be human readable.
337 */ 243 */
338static ssize_t ibft_attr_show_initiator(struct ibft_kobject *entry, 244static ssize_t ibft_attr_show_initiator(void *data, int type, char *buf)
339 struct ibft_attribute *attr,
340 char *buf)
341{ 245{
246 struct ibft_kobject *entry = data;
342 struct ibft_initiator *initiator = entry->initiator; 247 struct ibft_initiator *initiator = entry->initiator;
343 void *ibft_loc = entry->header; 248 void *ibft_loc = entry->header;
344 char *str = buf; 249 char *str = buf;
@@ -346,26 +251,26 @@ static ssize_t ibft_attr_show_initiator(struct ibft_kobject *entry,
346 if (!initiator) 251 if (!initiator)
347 return 0; 252 return 0;
348 253
349