iPXE
ibft.c
Go to the documentation of this file.
1/*
2 * Copyright Fen Systems Ltd. 2007. Portions of this code are derived
3 * from IBM Corporation Sample Programs. Copyright IBM Corporation
4 * 2004, 2007. All rights reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person
7 * obtaining a copy of this software and associated documentation
8 * files (the "Software"), to deal in the Software without
9 * restriction, including without limitation the rights to use, copy,
10 * modify, merge, publish, distribute, sublicense, and/or sell copies
11 * of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be
15 * included in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 * SOFTWARE.
25 *
26 */
27
28FILE_LICENCE ( BSD2 );
29FILE_SECBOOT ( PERMITTED );
30
31#include <stdint.h>
32#include <stdlib.h>
33#include <stdio.h>
34#include <string.h>
35#include <errno.h>
36#include <byteswap.h>
37#include <ipxe/pci.h>
38#include <ipxe/acpi.h>
39#include <ipxe/in.h>
40#include <ipxe/netdevice.h>
41#include <ipxe/ethernet.h>
42#include <ipxe/vlan.h>
43#include <ipxe/tcpip.h>
44#include <ipxe/dhcp.h>
45#include <ipxe/iscsi.h>
46#include <ipxe/ibft.h>
47
48/** @file
49 *
50 * iSCSI boot firmware table
51 *
52 * The information in this file is originally derived from the document "iSCSI
53 * Boot Firmware Table (iBFT)" as published by IBM at:
54 *
55 * ftp://ftp.software.ibm.com/systems/support/system_x_pdf/ibm_iscsi_boot_firmware_table_v1.02.pdf
56 *
57 * That file is no longer available, but a more recent version is available:
58 *
59 * ftp://ftp.software.ibm.com/systems/support/bladecenter/iscsi_boot_firmware_table_v1.03.pdf
60 *
61 */
62
63/**
64 * iSCSI string buffer
65 *
66 * This is an internal structure that we use to keep track of the
67 * allocation of string data.
68 */
70 /** Strings data */
71 char *data;
72 /** Starting offset of strings */
73 size_t start;
74 /** Total length */
75 size_t len;
76};
77
78/**
79 * Align structure within iBFT
80 *
81 * @v len Unaligned length (or offset)
82 * @ret len Aligned length (or offset)
83 */
84static inline size_t ibft_align ( size_t len ) {
85
86 return ( ( len + IBFT_ALIGN - 1 ) & ~( IBFT_ALIGN - 1 ) );
87}
88
89/**
90 * Fill in an IP address field within iBFT
91 *
92 * @v ipaddr IP address field
93 * @v in IPv4 address
94 */
95static void ibft_set_ipaddr ( struct ibft_ipaddr *ipaddr, struct in_addr in ) {
96 memset ( ipaddr, 0, sizeof ( *ipaddr ) );
97 if ( in.s_addr ) {
98 ipaddr->in = in;
99 ipaddr->ones = 0xffff;
100 }
101}
102
103/**
104 * Fill in an IP address within iBFT from configuration setting
105 *
106 * @v settings Parent settings block, or NULL
107 * @v ipaddr IP address field
108 * @v setting Configuration setting
109 * @v count Maximum number of IP addresses
110 */
112 struct ibft_ipaddr *ipaddr,
113 const struct setting *setting,
114 unsigned int count ) {
115 struct in_addr in[count];
116 unsigned int i;
117
119 for ( i = 0 ; i < count ; i++ ) {
120 ibft_set_ipaddr ( &ipaddr[i], in[i] );
121 }
122}
123
124/**
125 * Read IP address from iBFT (for debugging)
126 *
127 * @v strings iBFT string block descriptor
128 * @v string String field
129 * @ret ipaddr IP address string
130 */
131static const char * ibft_ipaddr ( struct ibft_ipaddr *ipaddr ) {
132 return inet_ntoa ( ipaddr->in );
133}
134
135/**
136 * Allocate a string within iBFT
137 *
138 * @v strings iBFT string block descriptor
139 * @v string String field to fill in
140 * @v len Length of string to allocate (excluding NUL)
141 * @ret dest String destination, or NULL
142 */
143static char * ibft_alloc_string ( struct ibft_strings *strings,
144 struct ibft_string *string, size_t len ) {
145 size_t new_len;
146 char *new_data;
147 char *dest;
148
149 /* Extend string data buffer */
150 new_len = ( strings->len + len + 1 /* NUL */ );
151 new_data = realloc ( strings->data, new_len );
152 if ( ! new_data )
153 return NULL;
154 strings->data = new_data;
155
156 /* Fill in string field */
157 string->offset = cpu_to_le16 ( strings->start + strings->len );
158 string->len = cpu_to_le16 ( len );
159
160 /* Zero string */
161 dest = ( strings->data + strings->len );
162 memset ( dest, 0, ( len + 1 /* NUL */ ) );
163
164 /* Update allocated length */
165 strings->len = new_len;
166
167 return dest;
168}
169
170/**
171 * Fill in a string field within iBFT
172 *
173 * @v strings iBFT string block descriptor
174 * @v string String field
175 * @v data String to fill in, or NULL
176 * @ret rc Return status code
177 */
178static int ibft_set_string ( struct ibft_strings *strings,
179 struct ibft_string *string, const char *data ) {
180 char *dest;
181
182 if ( ! data )
183 return 0;
184
185 dest = ibft_alloc_string ( strings, string, strlen ( data ) );
186 if ( ! dest )
187 return -ENOBUFS;
188 strcpy ( dest, data );
189
190 return 0;
191}
192
193/**
194 * Fill in a string field within iBFT from configuration setting
195 *
196 * @v settings Parent settings block, or NULL
197 * @v strings iBFT string block descriptor
198 * @v string String field
199 * @v setting Configuration setting
200 * @ret rc Return status code
201 */
203 struct ibft_strings *strings,
204 struct ibft_string *string,
205 const struct setting *setting ) {
206 struct settings *origin;
207 struct setting fetched;
208 int len;
209 char *dest;
210
211 len = fetch_setting ( settings, setting, &origin, &fetched, NULL, 0 );
212 if ( len < 0 ) {
213 string->offset = 0;
214 string->len = 0;
215 return 0;
216 }
217
218 dest = ibft_alloc_string ( strings, string, len );
219 if ( ! dest )
220 return -ENOBUFS;
221 fetch_string_setting ( origin, &fetched, dest, ( len + 1 ));
222
223 return 0;
224}
225
226/**
227 * Read string from iBFT (for debugging)
228 *
229 * @v strings iBFT string block descriptor
230 * @v string String field
231 * @ret data String content (or "<empty>")
232 */
233static const char * ibft_string ( struct ibft_strings *strings,
234 struct ibft_string *string ) {
235 size_t offset = le16_to_cpu ( string->offset );
236
237 return ( offset ? ( strings->data + offset - strings->start ) : NULL );
238}
239
240/**
241 * Check if network device is required for the iBFT
242 *
243 * @v netdev Network device
244 * @ret is_required Network device is required
245 */
247 struct iscsi_session *iscsi;
248 struct sockaddr_tcpip *st_target;
249
250 list_for_each_entry ( iscsi, &ibft_model.descs, desc.list ) {
251 st_target = ( struct sockaddr_tcpip * ) &iscsi->target_sockaddr;
252 if ( tcpip_netdev ( st_target ) == netdev )
253 return 1;
254 }
255
256 return 0;
257}
258
259/**
260 * Fill in NIC portion of iBFT
261 *
262 * @v nic NIC portion of iBFT
263 * @v strings iBFT string block descriptor
264 * @v netdev Network device
265 * @ret rc Return status code
266 */
267static int ibft_fill_nic ( struct ibft_nic *nic,
268 struct ibft_strings *strings,
269 struct net_device *netdev ) {
270 struct ll_protocol *ll_protocol = netdev->ll_protocol;
271 struct in_addr netmask_addr = { 0 };
272 unsigned int netmask_count = 0;
274 struct settings *origin;
275 int rc;
276
277 /* Fill in common header */
278 nic->header.structure_id = IBFT_STRUCTURE_ID_NIC;
279 nic->header.version = 1;
280 nic->header.length = cpu_to_le16 ( sizeof ( *nic ) );
281 nic->header.flags = ( IBFT_FL_NIC_BLOCK_VALID |
283 DBG ( "iBFT NIC %d is %s\n", nic->header.index, netdev->name );
284
285 /* Determine origin of IP address */
287 nic->origin = ( ( origin == parent ) ?
289 DBG ( "iBFT NIC %d origin = %d\n", nic->header.index, nic->origin );
290
291 /* Extract values from configuration settings */
292 ibft_set_ipaddr_setting ( parent, &nic->ip_address, &ip_setting, 1 );
293 DBG ( "iBFT NIC %d IP = %s\n",
294 nic->header.index, ibft_ipaddr ( &nic->ip_address ) );
296 DBG ( "iBFT NIC %d gateway = %s\n",
297 nic->header.index, ibft_ipaddr ( &nic->gateway ) );
299 ( sizeof ( nic->dns ) /
300 sizeof ( nic->dns[0] ) ) );
301 ibft_set_ipaddr_setting ( parent, &nic->dhcp, &dhcp_server_setting, 1 );
302 DBG ( "iBFT NIC %d DNS = %s",
303 nic->header.index, ibft_ipaddr ( &nic->dns[0] ) );
304 DBG ( ", %s\n", ibft_ipaddr ( &nic->dns[1] ) );
305 if ( ( rc = ibft_set_string_setting ( NULL, strings, &nic->hostname,
306 &hostname_setting ) ) != 0 )
307 return rc;
308 DBG ( "iBFT NIC %d hostname = %s\n",
309 nic->header.index, ibft_string ( strings, &nic->hostname ) );
310
311 /* Derive subnet mask prefix from subnet mask */
312 fetch_ipv4_setting ( parent, &netmask_setting, &netmask_addr );
313 while ( netmask_addr.s_addr ) {
314 if ( netmask_addr.s_addr & 0x1 )
315 netmask_count++;
316 netmask_addr.s_addr >>= 1;
317 }
318 nic->subnet_mask_prefix = netmask_count;
319 DBG ( "iBFT NIC %d subnet = /%d\n",
320 nic->header.index, nic->subnet_mask_prefix );
321
322 /* Extract values from net-device configuration */
323 nic->vlan = cpu_to_le16 ( vlan_tag ( netdev ) );
324 DBG ( "iBFT NIC %d VLAN = %02x\n",
325 nic->header.index, le16_to_cpu ( nic->vlan ) );
326 if ( ( rc = ll_protocol->eth_addr ( netdev->ll_addr,
327 nic->mac_address ) ) != 0 ) {
328 DBG ( "Could not determine %s MAC: %s\n",
329 netdev->name, strerror ( rc ) );
330 return rc;
331 }
332 DBG ( "iBFT NIC %d MAC = %s\n",
333 nic->header.index, eth_ntoa ( nic->mac_address ) );
334 nic->pci_bus_dev_func = cpu_to_le16 ( netdev->dev->desc.location );
335 DBG ( "iBFT NIC %d PCI = %04x\n",
336 nic->header.index, le16_to_cpu ( nic->pci_bus_dev_func ) );
337
338 return 0;
339}
340
341/**
342 * Fill in Initiator portion of iBFT
343 *
344 * @v initiator Initiator portion of iBFT
345 * @v strings iBFT string block descriptor
346 * @v initiator_iqn Initiator IQN
347 * @ret rc Return status code
348 */
349static int ibft_fill_initiator ( struct ibft_initiator *initiator,
350 struct ibft_strings *strings,
351 const char *initiator_iqn ) {
352 int rc;
353
354 /* Fill in common header */
356 initiator->header.version = 1;
357 initiator->header.length = cpu_to_le16 ( sizeof ( *initiator ) );
360
361 /* Fill in initiator name */
362 if ( ( rc = ibft_set_string ( strings, &initiator->initiator_name,
363 initiator_iqn ) ) != 0 )
364 return rc;
365 DBG ( "iBFT initiator name = %s\n",
366 ibft_string ( strings, &initiator->initiator_name ) );
367
368 return 0;
369}
370
371/**
372 * Fill in Target NIC association
373 *
374 * @v target Target portion of iBFT
375 * @v iscsi iSCSI session
376 * @ret rc Return status code
377 */
379 struct iscsi_session *iscsi ) {
380 struct sockaddr_tcpip *st_target =
381 ( struct sockaddr_tcpip * ) &iscsi->target_sockaddr;
382 struct net_device *associated;
383 struct net_device *netdev;
384
385 /* Find network device used to reach target */
386 associated = tcpip_netdev ( st_target );
387 if ( ! associated ) {
388 DBG ( "iBFT target %d has no net device\n",
389 target->header.index );
390 return -EHOSTUNREACH;
391 }
392
393 /* Calculate association */
395 if ( netdev == associated ) {
396 DBG ( "iBFT target %d uses NIC %d (%s)\n",
397 target->header.index, target->nic_association,
398 netdev->name );
399 return 0;
400 }
402 continue;
403 target->nic_association++;
404 }
405
406 DBG ( "iBFT target %d has impossible NIC %s\n",
407 target->header.index, netdev->name );
408 return -EINVAL;
409}
410
411/**
412 * Fill in Target CHAP portion of iBFT
413 *
414 * @v target Target portion of iBFT
415 * @v strings iBFT string block descriptor
416 * @v iscsi iSCSI session
417 * @ret rc Return status code
418 */
419static int ibft_fill_target_chap ( struct ibft_target *target,
420 struct ibft_strings *strings,
421 struct iscsi_session *iscsi ) {
422 int rc;
423
424 if ( ! ( iscsi->status & ISCSI_STATUS_AUTH_FORWARD_REQUIRED ) )
425 return 0;
426
427 assert ( iscsi->initiator_username );
428 assert ( iscsi->initiator_password );
429
431 if ( ( rc = ibft_set_string ( strings, &target->chap_name,
432 iscsi->initiator_username ) ) != 0 )
433 return rc;
434 DBG ( "iBFT target %d username = %s\n", target->header.index,
435 ibft_string ( strings, &target->chap_name ) );
436 if ( ( rc = ibft_set_string ( strings, &target->chap_secret,
437 iscsi->initiator_password ) ) != 0 )
438 return rc;
439 DBG ( "iBFT target %d password = <redacted>\n", target->header.index );
440
441 return 0;
442}
443
444/**
445 * Fill in Target Reverse CHAP portion of iBFT
446 *
447 * @v target Target portion of iBFT
448 * @v strings iBFT string block descriptor
449 * @v iscsi iSCSI session
450 * @ret rc Return status code
451 */
452static int ibft_fill_target_reverse_chap ( struct ibft_target *target,
453 struct ibft_strings *strings,
454 struct iscsi_session *iscsi ) {
455 int rc;
456
457 if ( ! ( iscsi->status & ISCSI_STATUS_AUTH_REVERSE_REQUIRED ) )
458 return 0;
459
460 assert ( iscsi->initiator_username );
461 assert ( iscsi->initiator_password );
462 assert ( iscsi->target_username );
463 assert ( iscsi->target_password );
464
465 target->chap_type = IBFT_CHAP_MUTUAL;
466 if ( ( rc = ibft_set_string ( strings, &target->reverse_chap_name,
467 iscsi->target_username ) ) != 0 )
468 return rc;
469 DBG ( "iBFT target %d reverse username = %s\n", target->header.index,
470 ibft_string ( strings, &target->chap_name ) );
471 if ( ( rc = ibft_set_string ( strings, &target->reverse_chap_secret,
472 iscsi->target_password ) ) != 0 )
473 return rc;
474 DBG ( "iBFT target %d reverse password = <redacted>\n",
475 target->header.index );
476
477 return 0;
478}
479
480/**
481 * Fill in Target portion of iBFT
482 *
483 * @v target Target portion of iBFT
484 * @v strings iBFT string block descriptor
485 * @v iscsi iSCSI session
486 * @ret rc Return status code
487 */
488static int ibft_fill_target ( struct ibft_target *target,
489 struct ibft_strings *strings,
490 struct iscsi_session *iscsi ) {
491 struct sockaddr_tcpip *st_target =
492 ( struct sockaddr_tcpip * ) &iscsi->target_sockaddr;
493 struct sockaddr_in *sin_target =
494 ( struct sockaddr_in * ) &iscsi->target_sockaddr;
495 int rc;
496
497 /* Fill in common header */
499 target->header.version = 1;
500 target->header.length = cpu_to_le16 ( sizeof ( *target ) );
503
504 /* Fill in Target values */
505 ibft_set_ipaddr ( &target->ip_address, sin_target->sin_addr );
506 DBG ( "iBFT target %d IP = %s\n",
507 target->header.index, ibft_ipaddr ( &target->ip_address ) );
508 target->socket = cpu_to_le16 ( ntohs ( st_target->st_port ) );
509 DBG ( "iBFT target %d port = %d\n",
510 target->header.index, target->socket );
511 memcpy ( &target->boot_lun, &iscsi->lun, sizeof ( target->boot_lun ) );
512 DBG ( "iBFT target %d boot LUN = " SCSI_LUN_FORMAT "\n",
513 target->header.index, SCSI_LUN_DATA ( target->boot_lun ) );
514 if ( ( rc = ibft_set_string ( strings, &target->target_name,
515 iscsi->target_iqn ) ) != 0 )
516 return rc;
517 DBG ( "iBFT target %d name = %s\n", target->header.index,
518 ibft_string ( strings, &target->target_name ) );
519 if ( ( rc = ibft_fill_target_nic_association ( target, iscsi ) ) != 0 )
520 return rc;
521 if ( ( rc = ibft_fill_target_chap ( target, strings, iscsi ) ) != 0 )
522 return rc;
523 if ( ( rc = ibft_fill_target_reverse_chap ( target, strings,
524 iscsi ) ) != 0 )
525 return rc;
526
527 return 0;
528}
529
530/**
531 * Check if iBFT descriptor is complete
532 *
533 * @v desc ACPI descriptor
534 * @ret rc Return status code
535 */
536static int ibft_complete ( struct acpi_descriptor *desc ) {
537 struct iscsi_session *iscsi =
538 container_of ( desc, struct iscsi_session, desc );
539
540 /* Fail if we do not yet have the target address */
541 if ( ! iscsi->target_sockaddr.sa_family )
542 return -EAGAIN;
543
544 return 0;
545}
546
547/**
548 * Install iBFT
549 *
550 * @v install Installation method
551 * @ret rc Return status code
552 */
553static int ibft_install ( int ( * install ) ( struct acpi_header *acpi ) ) {
554 struct net_device *netdev;
555 struct iscsi_session *iscsi;
556 struct ibft_table *table;
557 struct ibft_initiator *initiator;
558 struct ibft_nic *nic;
559 struct ibft_target *target;
560 struct ibft_strings strings;
561 struct acpi_header *acpi;
562 void *data;
563 unsigned int targets = 0;
564 unsigned int pairs = 0;
565 size_t offset = 0;
566 size_t table_len;
567 size_t control_len;
568 size_t initiator_offset;
569 size_t nic_offset;
570 size_t target_offset;
571 size_t strings_offset;
572 size_t len;
573 unsigned int i;
574 int rc;
575
576 /* Calculate table sizes and offsets */
577 list_for_each_entry ( iscsi, &ibft_model.descs, desc.list )
578 targets++;
579 pairs = ( sizeof ( table->control.pair ) /
580 sizeof ( table->control.pair[0] ) );
581 if ( pairs < targets )
582 pairs = targets;
583 offset = offsetof ( typeof ( *table ), control.pair );
584 offset += ( pairs * sizeof ( table->control.pair[0] ) );
585 table_len = offset;
586 control_len = ( table_len - offsetof ( typeof ( *table ), control ) );
588 initiator_offset = offset;
589 offset += ibft_align ( sizeof ( *initiator ) );
590 nic_offset = offset;
591 offset += ( pairs * ibft_align ( sizeof ( *nic ) ) );
592 target_offset = offset;
593 offset += ( pairs * ibft_align ( sizeof ( *target ) ) );
594 strings_offset = offset;
595 strings.data = NULL;
596 strings.start = strings_offset;
597 strings.len = 0;
598 len = offset;
599
600 /* Do nothing if no targets exist */
601 if ( ! targets ) {
602 rc = 0;
603 goto no_targets;
604 }
605
606 /* Allocate table */
607 data = zalloc ( len );
608 if ( ! data ) {
609 rc = -ENOMEM;
610 goto err_alloc;
611 }
612
613 /* Fill in Control block */
614 table = data;
616 table->control.header.version = 1;
617 table->control.header.length = cpu_to_le16 ( control_len );
618
619 /* Fill in Initiator block */
620 initiator = ( data + initiator_offset );
621 table->control.initiator = cpu_to_le16 ( initiator_offset );
622 iscsi = list_first_entry ( &ibft_model.descs, struct iscsi_session,
623 desc.list );
624 if ( ( rc = ibft_fill_initiator ( initiator, &strings,
625 iscsi->initiator_iqn ) ) != 0 )
626 goto err_initiator;
627
628 /* Fill in NIC blocks */
629 i = 0;
632 continue;
633 assert ( i < pairs );
634 table->control.pair[i].nic = nic_offset;
635 nic = ( data + nic_offset );
636 nic->header.index = i;
637 if ( ( rc = ibft_fill_nic ( nic, &strings, netdev ) ) != 0 )
638 goto err_nic;
639 i++;
640 nic_offset += ibft_align ( sizeof ( *nic ) );
641 }
642
643 /* Fill in Target blocks */
644 i = 0;
645 list_for_each_entry ( iscsi, &ibft_model.descs, desc.list ) {
646 assert ( i < pairs );
647 table->control.pair[i].target = target_offset;
648 target = ( data + target_offset );
649 target->header.index = i;
650 if ( ( rc = ibft_fill_target ( target, &strings, iscsi ) ) != 0)
651 goto err_target;
652 i++;
653 target_offset += ibft_align ( sizeof ( *target ) );
654 }
655
656 /* Reallocate table to include space for strings */
657 len += strings.len;
658 acpi = realloc ( data, len );
659 if ( ! acpi )
660 goto err_realloc;
661 data = NULL;
662
663 /* Fill in ACPI header */
664 acpi->signature = cpu_to_le32 ( IBFT_SIG );
665 acpi->length = cpu_to_le32 ( len );
666 acpi->revision = 1;
667
668 /* Append strings */
669 memcpy ( ( ( ( void * ) acpi ) + strings_offset ), strings.data,
670 strings.len );
671
672 /* Install ACPI table */
673 if ( ( rc = install ( acpi ) ) != 0 ) {
674 DBG ( "iBFT could not install: %s\n", strerror ( rc ) );
675 goto err_install;
676 }
677
678 err_install:
679 free ( acpi );
680 err_realloc:
681 err_target:
682 err_nic:
683 err_initiator:
684 free ( data );
685 err_alloc:
686 no_targets:
687 free ( strings.data );
688 return rc;
689}
690
691/** iBFT model */
692struct acpi_model ibft_model __acpi_model = {
693 .descs = LIST_HEAD_INIT ( ibft_model.descs ),
694 .complete = ibft_complete,
695 .install = ibft_install,
696};
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
__be32 in[4]
Definition CIB_PRM.h:7
typeof(acpi_finder=acpi_find)
ACPI table finder.
Definition acpi.c:48
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
if(len >=6 *4) __asm__ __volatile__("movsl" if(len >=5 *4) __asm__ __volatile__("movsl" if(len >=4 *4) __asm__ __volatile__("movsl" if(len >=3 *4) __asm__ __volatile__("movsl" if(len >=2 *4) __asm__ __volatile__("movsl" if(len >=1 *4) __asm__ __volatile__("movsl" if((len % 4) >=2) __asm__ __volatile__("movsw" if((len % 2) >=1) __asm__ __volatile__("movsb" retur dest)
Definition string.h:151
#define assert(condition)
Assert a condition at run-time.
Definition assert.h:50
uint16_t offset
Offset to command line.
Definition bzimage.h:3
ring len
Length.
Definition dwmac.h:226
static EFI_ACPI_TABLE_PROTOCOL * acpi
ACPI table protocol protocol.
Definition efi_block.c:67
const struct setting ip_setting
const struct setting dns_setting
const struct setting netmask_setting
const struct setting gateway_setting
uint8_t data[48]
Additional event data.
Definition ena.h:11
struct ena_llq_option desc
Descriptor counts.
Definition ena.h:9
Error codes.
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition ethernet.c:176
Ethernet protocol.
static struct net_device * netdev
Definition gdbudp.c:53
#define DBG(...)
Print a debugging message.
Definition compiler.h:498
static unsigned int count
Number of entries.
Definition dwmac.h:220
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define EINVAL
Invalid argument.
Definition errno.h:429
#define EHOSTUNREACH
Host is unreachable.
Definition errno.h:404
#define ENOMEM
Not enough space.
Definition errno.h:535
#define ENOBUFS
No buffer space available.
Definition errno.h:499
#define EAGAIN
Resource temporarily unavailable.
Definition errno.h:319
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
static char * ibft_alloc_string(struct ibft_strings *strings, struct ibft_string *string, size_t len)
Allocate a string within iBFT.
Definition ibft.c:143
static int ibft_set_string(struct ibft_strings *strings, struct ibft_string *string, const char *data)
Fill in a string field within iBFT.
Definition ibft.c:178
static const char * ibft_string(struct ibft_strings *strings, struct ibft_string *string)
Read string from iBFT (for debugging)
Definition ibft.c:233
static int ibft_fill_target_chap(struct ibft_target *target, struct ibft_strings *strings, struct iscsi_session *iscsi)
Fill in Target CHAP portion of iBFT.
Definition ibft.c:419
static int ibft_install(int(*install)(struct acpi_header *acpi))
Install iBFT.
Definition ibft.c:553
static int ibft_netdev_is_required(struct net_device *netdev)
Check if network device is required for the iBFT.
Definition ibft.c:246
static const char * ibft_ipaddr(struct ibft_ipaddr *ipaddr)
Read IP address from iBFT (for debugging)
Definition ibft.c:131
static int ibft_fill_target_reverse_chap(struct ibft_target *target, struct ibft_strings *strings, struct iscsi_session *iscsi)
Fill in Target Reverse CHAP portion of iBFT.
Definition ibft.c:452
static int ibft_set_string_setting(struct settings *settings, struct ibft_strings *strings, struct ibft_string *string, const struct setting *setting)
Fill in a string field within iBFT from configuration setting.
Definition ibft.c:202
static int ibft_fill_nic(struct ibft_nic *nic, struct ibft_strings *strings, struct net_device *netdev)
Fill in NIC portion of iBFT.
Definition ibft.c:267
static int ibft_fill_target(struct ibft_target *target, struct ibft_strings *strings, struct iscsi_session *iscsi)
Fill in Target portion of iBFT.
Definition ibft.c:488
static int ibft_complete(struct acpi_descriptor *desc)
Check if iBFT descriptor is complete.
Definition ibft.c:536
static void ibft_set_ipaddr_setting(struct settings *settings, struct ibft_ipaddr *ipaddr, const struct setting *setting, unsigned int count)
Fill in an IP address within iBFT from configuration setting.
Definition ibft.c:111
static size_t ibft_align(size_t len)
Align structure within iBFT.
Definition ibft.c:84
static void ibft_set_ipaddr(struct ibft_ipaddr *ipaddr, struct in_addr in)
Fill in an IP address field within iBFT.
Definition ibft.c:95
static int ibft_fill_target_nic_association(struct ibft_target *target, struct iscsi_session *iscsi)
Fill in Target NIC association.
Definition ibft.c:378
static int ibft_fill_initiator(struct ibft_initiator *initiator, struct ibft_strings *strings, const char *initiator_iqn)
Fill in Initiator portion of iBFT.
Definition ibft.c:349
iSCSI boot firmware table
#define IBFT_FL_NIC_FIRMWARE_BOOT_SELECTED
NIC firmware boot selected.
Definition ibft.h:207
#define IBFT_FL_INITIATOR_FIRMWARE_BOOT_SELECTED
Initiator firmware boot selected.
Definition ibft.h:166
#define IBFT_FL_TARGET_FIRMWARE_BOOT_SELECTED
Target firmware boot selected.
Definition ibft.h:259
#define IBFT_CHAP_ONE_WAY
One-way CHAP.
Definition ibft.h:269
#define IBFT_STRUCTURE_ID_INITIATOR
Structure ID for Initiator section.
Definition ibft.h:160
#define IBFT_STRUCTURE_ID_TARGET
Structure ID for Target section.
Definition ibft.h:253
#define IBFT_ALIGN
Alignment of structures within iBFT.
Definition ibft.h:54
#define IBFT_STRUCTURE_ID_NIC
Structure ID for NIC section.
Definition ibft.h:201
#define IBFT_NIC_ORIGIN_DHCP
Definition ibft.h:216
#define IBFT_FL_INITIATOR_BLOCK_VALID
Initiator block valid.
Definition ibft.h:163
#define IBFT_SIG
iSCSI Boot Firmware Table signature
Definition ibft.h:51
#define IBFT_STRUCTURE_ID_CONTROL
Structure ID for Control section.
Definition ibft.h:134
#define IBFT_CHAP_MUTUAL
Mutual CHAP.
Definition ibft.h:270
#define IBFT_FL_NIC_BLOCK_VALID
NIC block valid.
Definition ibft.h:204
#define IBFT_FL_TARGET_BLOCK_VALID
Target block valid.
Definition ibft.h:256
#define IBFT_NIC_ORIGIN_MANUAL
Definition ibft.h:214
#define le16_to_cpu(value)
Definition byteswap.h:113
#define cpu_to_le32(value)
Definition byteswap.h:108
#define ntohs(value)
Definition byteswap.h:137
#define cpu_to_le16(value)
Definition byteswap.h:107
ACPI data structures.
#define __acpi_model
Declare an ACPI model.
Definition acpi.h:344
Dynamic Host Configuration Protocol.
uint64_t origin
Origin.
Definition hyperv.h:9
Transport-network layer interface.
String functions.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
void * memset(void *dest, int character, size_t len) __nonnull
char * inet_ntoa(struct in_addr in)
Convert IPv4 address to dotted-quad notation.
Definition ipv4.c:814
iSCSI protocol
#define ISCSI_STATUS_AUTH_FORWARD_REQUIRED
Target has requested forward (initiator) authentication.
Definition iscsi.h:706
#define ISCSI_STATUS_AUTH_REVERSE_REQUIRED
Initiator requires target (reverse) authentication.
Definition iscsi.h:709
#define list_first_entry(list, type, member)
Get the container of the first entry in a list.
Definition list.h:334
#define LIST_HEAD_INIT(list)
Initialise a static list head.
Definition list.h:31
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition list.h:432
void * realloc(void *old_ptr, size_t new_size)
Reallocate memory.
Definition malloc.c:607
void * zalloc(size_t size)
Allocate cleared memory.
Definition malloc.c:662
uint32_t string
Definition multiboot.h:2
uint32_t control
Control.
Definition myson.h:3
Network device management.
#define for_each_netdev(netdev)
Iterate over all network devices.
Definition netdevice.h:547
static struct settings * netdev_settings(struct net_device *netdev)
Get per-netdevice configuration settings block.
Definition netdevice.h:587
PCI bus.
static void(* free)(struct refcnt *refcnt))
Definition refcnt.h:55
#define SCSI_LUN_FORMAT
printf() format for dumping a scsi_lun
Definition scsi.h:241
#define SCSI_LUN_DATA(lun)
printf() parameters for dumping a scsi_lun
Definition scsi.h:244
int fetch_setting(struct settings *settings, const struct setting *setting, struct settings **origin, struct setting *fetched, void *data, size_t len)
Fetch setting.
Definition settings.c:667
int fetch_ipv4_array_setting(struct settings *settings, const struct setting *setting, struct in_addr *inp, unsigned int count)
Fetch value of IPv4 address setting.
Definition settings.c:891
int fetch_string_setting(struct settings *settings, const struct setting *setting, char *data, size_t len)
Fetch value of string setting.
Definition settings.c:842
int fetch_ipv4_setting(struct settings *settings, const struct setting *setting, struct in_addr *inp)
Fetch value of IPv4 address setting.
Definition settings.c:913
#define offsetof(type, field)
Get offset of a field within a structure.
Definition stddef.h:25
#define container_of(ptr, type, field)
Get containing structure.
Definition stddef.h:36
char * strerror(int errno)
Retrieve string representation of error number.
Definition strerror.c:79
char * strcpy(char *dest, const char *src)
Copy string.
Definition string.c:347
size_t strlen(const char *src)
Get length of string.
Definition string.c:244
An ACPI descriptor (used to construct ACPI tables)
Definition acpi.h:295
An ACPI description header.
Definition acpi.h:180
An ACPI table model.
Definition acpi.h:321
struct ibft_header header
Common header.
Definition ibft.h:124
struct ibft_offset_pair pair[2]
Offsets to NIC and Target structures.
Definition ibft.h:130
ibft_off_t initiator
Offset to Initiator structure.
Definition ibft.h:128
uint16_t length
Length, including this header.
Definition ibft.h:94
uint8_t flags
Flags.
Definition ibft.h:101
uint8_t version
Version (always 1)
Definition ibft.h:92
uint8_t index
Index.
Definition ibft.h:99
uint8_t structure_id
Structure ID.
Definition ibft.h:90
iBFT Initiator structure
Definition ibft.h:146
struct ibft_header header
Common header.
Definition ibft.h:148
struct ibft_string initiator_name
Initiator name.
Definition ibft.h:156
An IP address within the iBFT.
Definition ibft.h:71
struct in_addr in
The IPv4 address, or zero if not present.
Definition ibft.h:77
uint16_t ones
Must be 0xffff if IPv4 address is present, otherwise zero.
Definition ibft.h:75
iBFT NIC structure
Definition ibft.h:172
ibft_off_t nic
Offset to NIC structure.
Definition ibft.h:113
ibft_off_t target
Offset to Target structure.
Definition ibft.h:115
A string within the iBFT.
Definition ibft.h:63
iSCSI string buffer
Definition ibft.c:69
size_t len
Total length.
Definition ibft.c:75
size_t start
Starting offset of strings.
Definition ibft.c:73
char * data
Strings data.
Definition ibft.c:71
iSCSI Boot Firmware Table (iBFT)
Definition ibft.h:275
struct ibft_control control
Control structure.
Definition ibft.h:281
iBFT Target structure
Definition ibft.h:224
struct ibft_header header
Common header.
Definition ibft.h:226
struct ibft_string reverse_chap_name
Reverse CHAP name.
Definition ibft.h:247
struct ibft_ipaddr ip_address
IP address.
Definition ibft.h:228
uint8_t chap_type
CHAP type.
Definition ibft.h:237
struct ibft_string chap_secret
CHAP secret.
Definition ibft.h:245
struct ibft_string chap_name
CHAP name.
Definition ibft.h:243
struct ibft_string target_name
Target name.
Definition ibft.h:241
uint8_t nic_association
NIC association.
Definition ibft.h:239
struct scsi_lun boot_lun
Boot LUN.
Definition ibft.h:232
uint16_t socket
TCP port.
Definition ibft.h:230
struct ibft_string reverse_chap_secret
Reverse CHAP secret.
Definition ibft.h:249
IP address structure.
Definition in.h:42
uint32_t s_addr
Definition in.h:43
An iSCSI session.
Definition iscsi.h:545
char * target_iqn
Target IQN.
Definition iscsi.h:563
char * initiator_password
Initiator password (if any)
Definition iscsi.h:575
struct scsi_lun lun
SCSI LUN (for boot firmware table)
Definition iscsi.h:664
char * target_password
Target password (if any)
Definition iscsi.h:579
struct sockaddr target_sockaddr
Target socket address (for boot firmware table)
Definition iscsi.h:662
char * initiator_username
Initiator username (if any)
Definition iscsi.h:573
char * initiator_iqn
Initiator IQN.
Definition iscsi.h:557
char * target_username
Target username (if any)
Definition iscsi.h:577
int status
Session status.
Definition iscsi.h:570
A link-layer protocol.
Definition netdevice.h:115
int(* eth_addr)(const void *ll_addr, void *eth_addr)
Generate Ethernet-compatible compressed link-layer address.
Definition netdevice.h:182
A network device.
Definition netdevice.h:353
Definition nic.h:49
int flags
Definition nic.h:51
A setting.
Definition settings.h:24
A settings block.
Definition settings.h:133
struct settings * parent
Parent settings block.
Definition settings.h:139
IPv4 socket address.
Definition in.h:85
struct in_addr sin_addr
IPv4 address.
Definition in.h:101
TCP/IP socket address.
Definition tcpip.h:76
uint16_t st_port
TCP/IP port.
Definition tcpip.h:82
sa_family_t sa_family
Socket address family.
Definition socket.h:102
struct net_device * tcpip_netdev(struct sockaddr_tcpip *st_dest)
Determine transmitting network device.
Definition tcpip.c:115
Virtual LANs.
static unsigned int vlan_tag(struct net_device *netdev)
Get the VLAN tag.
Definition vlan.h:74