From patchwork Tue Sep 16 00:23:51 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandra Seetharaman X-Patchwork-Id: 22974 Return-Path: X-Original-To: yaboot-devel@ozlabs.org Delivered-To: yaboot-devel@ozlabs.org Received: from e33.co.us.ibm.com (e33.co.us.ibm.com [32.97.110.151]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "e33.co.us.ibm.com", Issuer "Equifax" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id AC013DDEDE for ; Tue, 16 Sep 2008 10:24:34 +1000 (EST) Received: from d03relay02.boulder.ibm.com (d03relay02.boulder.ibm.com [9.17.195.227]) by e33.co.us.ibm.com (8.13.8/8.13.8) with ESMTP id m8G0OUA6015619 for ; Mon, 15 Sep 2008 20:24:30 -0400 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay02.boulder.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id m8G0OU8w203134 for ; Mon, 15 Sep 2008 18:24:30 -0600 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id m8G6OUum027450 for ; Tue, 16 Sep 2008 00:24:30 -0600 Received: from [127.0.1.1] (chandra-ubuntu.beaverton.ibm.com [9.47.17.98]) by d03av02.boulder.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id m8G6OT8f027433; Tue, 16 Sep 2008 00:24:29 -0600 From: Chandra Seetharaman To: yaboot devel Date: Mon, 15 Sep 2008 17:23:51 -0700 Message-Id: <20080916002351.21364.52208.sendpatchset@chandra-ubuntu> In-Reply-To: <20080916002327.21364.99723.sendpatchset@chandra-ubuntu> References: <20080916002327.21364.99723.sendpatchset@chandra-ubuntu> Subject: [PATCH 4/4] Add ipv6 support X-BeenThere: yaboot-devel@ozlabs.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Technical and development discussion regarding yaboot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Sep 2008 00:24:35 -0000 This patch adds support for handling ipv6 boot parameters for POWER architecture. This is implementation derived. This follows the semantics defined in section 4.3.1 of http://www.power.org/apps/org/workgroup/parch/download.php/2380/latest (It is under the Members area of TSC - Platform Architecture committee). Signed-off-by: Chandra Seetharaman --- include/file.h | 5 +++++ include/prom.h | 1 + second/file.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- second/fs_of.c | 8 ++++++-- 4 files changed, 63 insertions(+), 3 deletions(-) Index: yaboot.git_head/include/file.h =================================================================== --- yaboot.git_head.orig/include/file.h +++ yaboot.git_head/include/file.h @@ -46,6 +46,11 @@ struct boot_fspec_t { char* bootp_retries; /* Bootp retries */ char* tftp_retries; /* TFTP retries */ char* addl_params; /* copy all additional parameters */ + + /* Following fields are used only in ipv6 format */ + int is_ipv6; /* is ipv6 specified ? */ + char* dhcpv6; /* dhcpv6 string */ + char* blksize; /* blksize string */ }; struct boot_file_t { Index: yaboot.git_head/include/prom.h =================================================================== --- yaboot.git_head.orig/include/prom.h +++ yaboot.git_head/include/prom.h @@ -37,6 +37,7 @@ typedef void *phandle; #define PROM_INVALID_HANDLE ((prom_handle)-1UL) #define BOOTDEVSZ (2048) /* iscsi args can be in excess of 1040 bytes */ #define TOK_ISCSI "iscsi" +#define TOK_IPV6 "ipv6" #define PROM_CLAIM_MAX_ADDR 0x8000000 #define BOOTLASTSZ 1024 #define FW_NBR_REBOOTSZ 4 Index: yaboot.git_head/second/file.c =================================================================== --- yaboot.git_head.orig/second/file.c +++ yaboot.git_head/second/file.c @@ -132,6 +132,50 @@ extract_ipv4_args(char *imagepath, struc } /* + * Extract all the ipv6 arguments from the bootpath provided and fill result + * Syntax: ipv6,[dhcpv6[=diaddr,]]ciaddr=c_iaddr,giaddr=g_iaddr,siaddr=s_iaddr, + * filename=file_name,tftp-retries=tftp_retries,blksize=block_size + * Returns 1 on success, 0 on failure. + */ +static int +extract_ipv6_args(char *imagepath, struct boot_fspec_t *result) +{ + char *str, *tmp; + int total_len; + + result->is_ipv6 = 1; + + /* Just allocate the max required size */ + total_len = strlen(imagepath) + 1; + str = malloc(total_len); + if (!str) + return 0; + + if ((tmp = strstr(imagepath, "dhcpv6=")) != NULL) + result->dhcpv6 = scopy(&str, &tmp); + + if ((tmp = strstr(imagepath, "ciaddr=")) != NULL) + result->ciaddr = scopy(&str, &tmp); + + if ((tmp = strstr(imagepath, "giaddr=")) != NULL) + result->giaddr = scopy(&str, &tmp); + + if ((tmp = strstr(imagepath, "siaddr=")) != NULL) + result->siaddr = scopy(&str, &tmp); + + if ((tmp = strstr(imagepath, "filename=")) != NULL) + result->file = scopy(&str, &tmp); + + if ((tmp = strstr(imagepath, "tftp-retries=")) != NULL) + result->tftp_retries = scopy(&str, &tmp); + + if ((tmp = strstr(imagepath, "blksize=")) != NULL) + result->blksize = scopy(&str, &tmp); + + return 1; +} + +/* * Extract all the arguments provided in the imagepath and fill it in result. * Returns 1 on success, 0 on failure. */ @@ -145,8 +189,12 @@ extract_args_from_netdev_path(char *imag if (!imagepath) return 1; - ret = extract_ipv4_args(imagepath, result); + if (strstr(imagepath, TOK_IPV6)) + ret = extract_ipv6_args(imagepath, result); + else + ret = extract_ipv4_args(imagepath, result); + DEBUG_F("ipv6 = <%d>\n", result->is_ipv6); DEBUG_F("siaddr = <%s>\n", result->siaddr); DEBUG_F("file = <%s>\n", result->file); DEBUG_F("ciaddr = <%s>\n", result->ciaddr); @@ -154,6 +202,8 @@ extract_args_from_netdev_path(char *imag DEBUG_F("bootp_retries = <%s>\n", result->bootp_retries); DEBUG_F("tftp_retries = <%s>\n", result->tftp_retries); DEBUG_F("addl_params = <%s>\n", result->addl_params); + DEBUG_F("dhcpv6 = <%s>\n", result->dhcpv6); + DEBUG_F("blksize = <%s>\n", result->blksize); return ret; } Index: yaboot.git_head/second/fs_of.c =================================================================== --- yaboot.git_head.orig/second/fs_of.c +++ yaboot.git_head/second/fs_of.c @@ -148,11 +148,15 @@ of_net_open(struct boot_file_t* file, *p = '\\'; } - DEBUG_F("siaddr <%s>; filename <%s>; ciaddr <%s>; giaddr <%s>;\n", - fspec->siaddr, filename, fspec->ciaddr, fspec->giaddr); + DEBUG_F("siaddr <%s>; filename <%s>; ciaddr <%s>; giaddr <%s>; ipv6 <%d>\n", + fspec->siaddr, filename, fspec->ciaddr, fspec->giaddr, fspec->is_ipv6); strncpy(buffer, fspec->dev, 768); + if (fspec->is_ipv6) + strcat(buffer, TOK_IPV6 ","); strcat(buffer, fspec->siaddr); strcat(buffer, ","); + if (fspec->is_ipv6 && (strstr(filename, "filename=") == NULL)) + strcat(buffer, "filename="); strcat(buffer, filename); strcat(buffer, ","); strcat(buffer, fspec->ciaddr);