From patchwork Mon Dec 3 03:00:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 203269 X-Patchwork-Delegate: joe.hershberger@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id BBB0B2C00B5 for ; Mon, 3 Dec 2012 14:01:21 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E21EE4A030; Mon, 3 Dec 2012 04:01:14 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MgsLZSitpEGd; Mon, 3 Dec 2012 04:01:14 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2FFBF4A03C; Mon, 3 Dec 2012 04:00:57 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4FE724A032 for ; Mon, 3 Dec 2012 04:00:51 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VY9XBj6nhi5w for ; Mon, 3 Dec 2012 04:00:50 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-oa0-f44.google.com (mail-oa0-f44.google.com [209.85.219.44]) by theia.denx.de (Postfix) with ESMTPS id 097A54A030 for ; Mon, 3 Dec 2012 04:00:48 +0100 (CET) Received: by mail-oa0-f44.google.com with SMTP id n5so2178098oag.3 for ; Sun, 02 Dec 2012 19:00:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=UGjSh1tWvTxU/BFOTsk5tAWWiEvWpty3bxV38OUTxY8=; b=jN6X2RVEAwUTU4RJH/v52qffSRHZYaf9qHxZvLCPgPHZ3ZDy+itLbpu+vpziZrHo8k zHLhpSRho6jZS6K8+mk5R4wWESSxzVwFlj94Bq4aZTTDof3oZBoW2t5Q9LVqRmB/FEt4 /BeN4rtraG7Kwmi/39h2vYMaJI658KSpZM+nOX+2Mq2vzg575cYUj4FwPdKFlejG1rxm cU5+FAsYeSM6HkPxbqhEuVz6vRFZIlS9UlO92m/+5rqlxMTwfxRfovWdH8TYY0TXVYPi jV2F9SpnzrTYnOrC+H5StMMaKYGg9P+9sCvvkwSF4/Q+4AkqKKcDnuu8YWyQFd2etco0 BHLg== Received: by 10.60.23.200 with SMTP id o8mr6925899oef.48.1354503648199; Sun, 02 Dec 2012 19:00:48 -0800 (PST) Received: from rob-laptop.grandenetworks.net (65-36-73-129.dyn.grandenetworks.net. [65.36.73.129]) by mx.google.com with ESMTPS id vq7sm9420855oeb.13.2012.12.02.19.00.44 (version=SSLv3 cipher=OTHER); Sun, 02 Dec 2012 19:00:46 -0800 (PST) From: Rob Herring To: u-boot@lists.denx.de Date: Sun, 2 Dec 2012 21:00:20 -0600 Message-Id: <1354503629-25621-2-git-send-email-robherring2@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1354503629-25621-1-git-send-email-robherring2@gmail.com> References: <1354503629-25621-1-git-send-email-robherring2@gmail.com> Cc: trini@ti.com, Rob Herring Subject: [U-Boot] [PATCH 01/10] pxe: Use ethact setting for pxe X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de From: Rob Herring Get the MAC address using eth_getenv_enetaddr_by_index so that the MAC address of ethact is used. This enables using the a NIC other than the first one for PXE boot. Signed-off-by: Rob Herring --- common/cmd_pxe.c | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/common/cmd_pxe.c b/common/cmd_pxe.c index ee75db9..306c483 100644 --- a/common/cmd_pxe.c +++ b/common/cmd_pxe.c @@ -55,37 +55,21 @@ static char *from_env(char *envvar) */ static int format_mac_pxe(char *outbuf, size_t outbuf_len) { - size_t ethaddr_len; - char *p, *ethaddr; + uchar ethaddr[6]; - ethaddr = from_env("ethaddr"); - - if (!ethaddr) - return -ENOENT; - - ethaddr_len = strlen(ethaddr); - - /* - * ethaddr_len + 4 gives room for "01-", ethaddr, and a NUL byte at - * the end. - */ - if (outbuf_len < ethaddr_len + 4) { - printf("outbuf is too small (%d < %d)\n", - outbuf_len, ethaddr_len + 4); + if (outbuf_len < 21) { + printf("outbuf is too small (%d < 21)\n", outbuf_len); return -EINVAL; } - strcpy(outbuf, "01-"); - - for (p = outbuf + 3; *ethaddr; ethaddr++, p++) { - if (*ethaddr == ':') - *p = '-'; - else - *p = tolower(*ethaddr); - } + if (!eth_getenv_enetaddr_by_index("eth", eth_get_dev_index(), + ethaddr)) + return -ENOENT; - *p = '\0'; + sprintf(outbuf, "01-%02x-%02x-%02x-%02x-%02x-%02x", + ethaddr[0], ethaddr[1], ethaddr[2], + ethaddr[3], ethaddr[4], ethaddr[5]); return 1; }