From patchwork Fri Feb 8 08:15:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1038518 X-Patchwork-Delegate: agraf@suse.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="SBS0dLRB"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 43wp6B2wDtz9sML for ; Fri, 8 Feb 2019 19:20:50 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 0F196C2202C; Fri, 8 Feb 2019 08:18:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 6327AC22032; Fri, 8 Feb 2019 08:15:38 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id C7855C2201F; Fri, 8 Feb 2019 08:15:24 +0000 (UTC) Received: from mail-yw1-f52.google.com (mail-yw1-f52.google.com [209.85.161.52]) by lists.denx.de (Postfix) with ESMTPS id 28CC2C22012 for ; Fri, 8 Feb 2019 08:15:18 +0000 (UTC) Received: by mail-yw1-f52.google.com with SMTP id v201so1055808ywa.9 for ; Fri, 08 Feb 2019 00:15:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kre8nwshM6N+Wii5Yru84bxFU2KTYOuKwi1N7Z9RHoM=; b=SBS0dLRBO963RQGqDMJAK2r4gdii11yzuuCaoUDAB2ogg/yLDSN/TEyoLu7dt6ykH3 FU7PLnJY4QG02O++tP1FASazPBsHYviKGG1ElI6qj0oSIahDZHDWwGP2vZW4Kzi+S4i1 zNgjL2fr0vEL8qNrkF5Cf++KVIlxOwEJ7PMGf3HBrf6WhRCa8DM+cAfpgciL8WlzUBWo XrsguahqtEqddAKDULbKNA/80Zm+KMePQirxsWR9or7s873LtJ26yxDYgyDpzdf1ku8j JDNuNCX4jcroPsWnF8HqPqcIveOn7kLv9sFO3fa5LQMXd+0ApfqVRF7cyV+dGL6SvptI sgUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kre8nwshM6N+Wii5Yru84bxFU2KTYOuKwi1N7Z9RHoM=; b=QQiXjuDfiLPpmXfQJvARAm528HtAtNWqdTRmsWPpIFf1BCNCKdQjVhMVM/RE6Jvd3g 8mg4amlEN7pXKrvwVMo9soD3yfZjuhCkAtJ/8zi/eCxEuUfN05Hcwcsl3tJ44GFNPX4n JKnTIvYcrmO+VtXHO/OAf06bnu8uN5tclvEYUHrf3U2knZLEVjPrGckSeBa8DMlcqroE W2caMt/dGF5ZXZo/EzD5DypSQ9PNMdqQrVFrb1Qj+bnQLzC5ki1plPXJOK2ydz1PP6lb GCsMy7I8hqh9Gsl5VgvIZjQuh4qBPsxti2HS0rNhQvBkvwtOcCjN7nHPs8uWCJzNWweg 9f8Q== X-Gm-Message-State: AHQUAubS9TmhLlAG479rNLKY4BfbubkkDfGJ2ZAQQSyLTWrvElKzE6e3 i7Km6cc/3EId6IFrUv26ILxSwQ== X-Google-Smtp-Source: AHgI3IZ7X2ZtZGqZ6ZBKX52f/yU+gZJCuR/YSmCNw1tbDrhW/X8Ny9rZRA6eWpiMbNt650PQYLOYEg== X-Received: by 2002:a81:a381:: with SMTP id a123mr17036905ywh.295.1549613717096; Fri, 08 Feb 2019 00:15:17 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id w63sm552869ywc.46.2019.02.08.00.15.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Feb 2019 00:15:16 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, agraf@suse.de, xypron.glpk@gmx.de, sjg@chromium.org Date: Fri, 8 Feb 2019 17:15:36 +0900 Message-Id: <20190208081542.2813-10-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190208081542.2813-1-takahiro.akashi@linaro.org> References: <20190208081542.2813-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [RFC v2 09/15] efi_loader: net: convert efi_net_obj to DM X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Signed-off-by: AKASHI Takahiro --- lib/efi_loader/efi_net.c | 50 +++++++++++++++++++++++++++++++------- lib/efi_loader/efi_setup.c | 5 ---- net/eth-uclass.c | 5 ++++ 3 files changed, 46 insertions(+), 14 deletions(-) diff --git a/lib/efi_loader/efi_net.c b/lib/efi_loader/efi_net.c index c7d9da8521af..6c9b40293633 100644 --- a/lib/efi_loader/efi_net.c +++ b/lib/efi_loader/efi_net.c @@ -6,11 +6,12 @@ */ #include +#include #include #include -static const efi_guid_t efi_net_guid = EFI_SIMPLE_NETWORK_GUID; -static const efi_guid_t efi_pxe_guid = EFI_PXE_GUID; +const efi_guid_t efi_net_guid = EFI_SIMPLE_NETWORK_GUID; +const efi_guid_t efi_pxe_guid = EFI_PXE_GUID; static struct efi_pxe_packet *dhcp_ack; static bool new_rx_packet; static void *new_tx_packet; @@ -26,17 +27,16 @@ static struct efi_event *network_timer_event; */ static struct efi_event *wait_for_packet; +/* FIXME: move this to somewhere else, like struct eth_device? */ /** * struct efi_net_obj - EFI object representing a network interface * - * @header: EFI object header * @net: simple network protocol interface * @net_mode: status of the network interface * @pxe: PXE base code protocol interface * @pxe_mode: status of the PXE base code protocol */ struct efi_net_obj { - struct efi_object header; struct efi_simple_network net; struct efi_simple_network_mode net_mode; struct efi_pxe pxe; @@ -588,10 +588,12 @@ out: */ efi_status_t efi_net_register(void) { + struct udevice *dev; struct efi_net_obj *netobj = NULL; efi_status_t r; - if (!eth_get_dev()) { + dev = eth_get_dev(); + if (!dev) { /* No network device active, don't expose any */ return EFI_SUCCESS; } @@ -608,18 +610,22 @@ efi_status_t efi_net_register(void) transmit_buffer = (void *)ALIGN((uintptr_t)transmit_buffer, PKTALIGN); /* Hook net up to the device list */ - efi_add_handle(&netobj->header); + r = efi_add_handle(dev); + if (r != EFI_SUCCESS) { + printf("ERROR: Failure adding net handle\n"); + return r; + } /* Fill in object data */ - r = efi_add_protocol(&netobj->header, &efi_net_guid, + r = efi_add_protocol(dev, &efi_net_guid, &netobj->net); if (r != EFI_SUCCESS) goto failure_to_add_protocol; - r = efi_add_protocol(&netobj->header, &efi_guid_device_path, + r = efi_add_protocol(dev, &efi_guid_device_path, efi_dp_from_eth()); if (r != EFI_SUCCESS) goto failure_to_add_protocol; - r = efi_add_protocol(&netobj->header, &efi_pxe_guid, + r = efi_add_protocol(dev, &efi_pxe_guid, &netobj->pxe); if (r != EFI_SUCCESS) goto failure_to_add_protocol; @@ -691,3 +697,29 @@ out_of_resources: printf("ERROR: Out of memory\n"); return EFI_OUT_OF_RESOURCES; } + +static int efi_net_probe(struct udevice *dev) +{ + device_set_name(dev, "SIMPLE_NETWORK"); + + return 0; +} + +U_BOOT_DRIVER(efi_net) = { + .name = "efi_net", + .id = UCLASS_EFI_PROTOCOL, + .probe = efi_net_probe, +}; + +static int efi_pex_probe(struct udevice *dev) +{ + device_set_name(dev, "PXE"); + + return 0; +} + +U_BOOT_DRIVER(efi_pex) = { + .name = "efi_pex", + .id = UCLASS_EFI_PROTOCOL, + .probe = efi_pex_probe, +}; diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c index a0f80948c99c..ea65dec6c066 100644 --- a/lib/efi_loader/efi_setup.c +++ b/lib/efi_loader/efi_setup.c @@ -60,11 +60,6 @@ static efi_status_t efi_system_init(void) if (ret != EFI_SUCCESS) goto out; #endif -#ifdef CONFIG_NET - ret = efi_net_register(); - if (ret != EFI_SUCCESS) - goto out; -#endif #ifdef CONFIG_GENERATE_ACPI_TABLE ret = efi_acpi_register(); if (ret != EFI_SUCCESS) diff --git a/net/eth-uclass.c b/net/eth-uclass.c index 91d861be4136..85830a23de32 100644 --- a/net/eth-uclass.c +++ b/net/eth-uclass.c @@ -87,6 +87,11 @@ void eth_set_dev(struct udevice *dev) } eth_get_uclass_priv()->current = dev; +#if CONFIG_IS_ENABLED(EFI_LOADER) + extern int efi_net_register(void); + + efi_net_register(); +#endif } /*