grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
From: Keng-Yu Lin <kengyu@hpe.com>
To: grub-devel@gnu.org
Cc: mchang@suse.com, ken.lin@hpe.com, ljk@hpe.com,
	michael.ruan@hpe.com, clayc@hpe.com, kengyu@hpe.com
Subject: [PATCH 5/9] efinet: UEFI IPv6 PXE support
Date: Fri, 23 Dec 2016 16:54:08 +0800	[thread overview]
Message-ID: <1482483252-8710-6-git-send-email-kengyu@hpe.com> (raw)
In-Reply-To: <1482483252-8710-1-git-send-email-kengyu@hpe.com>

From: Michael Chang <mchang@suse.com>

When grub2 image is booted from UEFI IPv6 PXE, the DHCPv6 Reply packet is
cached in firmware buffer which can be obtained by PXE Base Code protocol. The
network interface can be setup through the parameters in that obtained packet.

Signed-off-by: Michael Chang <mchang@suse.com>
Signed-off-by: Ken Lin <ken.lin@hpe.com>
---
 grub-core/net/drivers/efi/efinet.c | 24 +++++++++++++----
 include/grub/efi/api.h             | 55 +++++++++++++++++++++++++++++++++++++-
 2 files changed, 73 insertions(+), 6 deletions(-)

diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c
index 5388f95..fc90415 100644
--- a/grub-core/net/drivers/efi/efinet.c
+++ b/grub-core/net/drivers/efi/efinet.c
@@ -378,11 +378,25 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device,
     if (! pxe)
       continue;
     pxe_mode = pxe->mode;
-    grub_net_configure_by_dhcp_ack (card->name, card, 0,
-				    (struct grub_net_bootp_packet *)
-				    &pxe_mode->dhcp_ack,
-				    sizeof (pxe_mode->dhcp_ack),
-				    1, device, path);
+
+    if (pxe_mode->using_ipv6)
+      {
+	grub_net_configure_by_dhcpv6_reply (card->name, card, 0,
+					    (struct grub_net_dhcp6_packet *)
+					    &pxe_mode->dhcp_ack,
+					    sizeof (pxe_mode->dhcp_ack),
+					    1, device, path);
+	if (grub_errno)
+	  grub_print_error ();
+      }
+    else
+      {
+	grub_net_configure_by_dhcp_ack (card->name, card, 0,
+					(struct grub_net_bootp_packet *)
+					&pxe_mode->dhcp_ack,
+					sizeof (pxe_mode->dhcp_ack),
+					1, device, path);
+      }
     return;
   }
 }
diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h
index c7c9f0e..92f9b5a 100644
--- a/include/grub/efi/api.h
+++ b/include/grub/efi/api.h
@@ -1452,14 +1452,67 @@ typedef struct grub_efi_simple_text_output_interface grub_efi_simple_text_output
 
 typedef grub_uint8_t grub_efi_pxe_packet_t[1472];
 
+typedef struct {
+  grub_uint8_t addr[4];
+} grub_efi_pxe_ipv4_address_t;
+
+typedef struct {
+  grub_uint8_t addr[16];
+} grub_efi_pxe_ipv6_address_t;
+
+typedef struct {
+  grub_uint8_t addr[32];
+} grub_efi_pxe_mac_address_t;
+
+typedef union {
+    grub_uint32_t addr[4];
+    grub_efi_pxe_ipv4_address_t v4;
+    grub_efi_pxe_ipv6_address_t v6;
+} grub_efi_pxe_ip_address_t;
+
+#define GRUB_EFI_PXE_BASE_CODE_MAX_IPCNT 8
+typedef struct {
+    grub_uint8_t filters;
+    grub_uint8_t ip_cnt;
+    grub_uint16_t reserved;
+    grub_efi_pxe_ip_address_t ip_list[GRUB_EFI_PXE_BASE_CODE_MAX_IPCNT];
+} grub_efi_pxe_ip_filter_t;
+
+typedef struct {
+    grub_efi_pxe_ip_address_t ip_addr;
+    grub_efi_pxe_mac_address_t mac_addr;
+} grub_efi_pxe_arp_entry_t;
+
+typedef struct {
+    grub_efi_pxe_ip_address_t ip_addr;
+    grub_efi_pxe_ip_address_t subnet_mask;
+    grub_efi_pxe_ip_address_t gw_addr;
+} grub_efi_pxe_route_entry_t;
+
+
+#define GRUB_EFI_PXE_BASE_CODE_MAX_ARP_ENTRIES 8
+#define GRUB_EFI_PXE_BASE_CODE_MAX_ROUTE_ENTRIES 8
+
 typedef struct grub_efi_pxe_mode
 {
-  grub_uint8_t unused[52];
+  grub_uint8_t started;
+  grub_uint8_t ipv6_available;
+  grub_uint8_t ipv6_supported;
+  grub_uint8_t using_ipv6;
+  grub_uint8_t unused[16];
+  grub_efi_pxe_ip_address_t station_ip;
+  grub_efi_pxe_ip_address_t subnet_mask;
   grub_efi_pxe_packet_t dhcp_discover;
   grub_efi_pxe_packet_t dhcp_ack;
   grub_efi_pxe_packet_t proxy_offer;
   grub_efi_pxe_packet_t pxe_discover;
   grub_efi_pxe_packet_t pxe_reply;
+  grub_efi_pxe_packet_t pxe_bis_reply;
+  grub_efi_pxe_ip_filter_t ip_filter;
+  grub_uint32_t arp_cache_entries;
+  grub_efi_pxe_arp_entry_t arp_cache[GRUB_EFI_PXE_BASE_CODE_MAX_ARP_ENTRIES];
+  grub_uint32_t route_table_entries;
+  grub_efi_pxe_route_entry_t route_table[GRUB_EFI_PXE_BASE_CODE_MAX_ROUTE_ENTRIES];
 } grub_efi_pxe_mode_t;
 
 typedef struct grub_efi_pxe
-- 
2.7.4



  parent reply	other threads:[~2016-12-23  8:54 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-23  8:54 [PATCH v2 0/9] Add UEFI HTTP Boot support for IPv4 and IPv6 Keng-Yu Lin
2016-12-23  8:54 ` [PATCH 1/9] strtoull: Fix behaviour on chars between '9' and 'a' Keng-Yu Lin
2016-12-23  8:54 ` [PATCH 2/9] net: read bracketed ipv6 addrs and port numbers Keng-Yu Lin
2016-12-23  8:54 ` [PATCH v2 3/9] Add default port in grub_net_app_protocol Keng-Yu Lin
2016-12-23  8:54 ` [PATCH 4/9] bootp: New net_bootp6 command Keng-Yu Lin
2016-12-23  8:54 ` Keng-Yu Lin [this message]
2016-12-23  8:54 ` [PATCH 6/9] grub.texi: Add net_bootp6 doument Keng-Yu Lin
2016-12-23  8:54 ` [PATCH 7/9] bootp: Add processing DHCPACK packet from HTTP Boot Keng-Yu Lin
2016-12-23  8:54 ` [PATCH 8/9] efinet: Setting network from UEFI device path Keng-Yu Lin
2016-12-23  8:54 ` [PATCH 9/9] efinet: Setting DNS server from UEFI protocol Keng-Yu Lin
2017-01-16  9:07 ` [PATCH v2 0/9] Add UEFI HTTP Boot support for IPv4 and IPv6 Lin, Keng-Yu (HPS OE-Linux TDC)
2017-01-16 10:12   ` Daniel Kiper
2017-07-06  6:52     ` Lin, Keng-Yu
2017-07-10 10:10       ` Michael Chang
2017-07-11  7:39         ` Lin, Keng-Yu
2017-07-11  9:48           ` Michael Chang
2017-07-10 20:41       ` Daniel Kiper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1482483252-8710-6-git-send-email-kengyu@hpe.com \
    --to=kengyu@hpe.com \
    --cc=clayc@hpe.com \
    --cc=grub-devel@gnu.org \
    --cc=ken.lin@hpe.com \
    --cc=ljk@hpe.com \
    --cc=mchang@suse.com \
    --cc=michael.ruan@hpe.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).