From patchwork Thu Sep 16 08:53:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masami Hiramatsu X-Patchwork-Id: 512918 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp1009968jao; Thu, 16 Sep 2021 01:55:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3m6ORaW3+qMbcGRMZgwDFT0V0RpeoeQT92TYSkiOdKnvYmGh1NQhd5JG44tfmIMFYHrSt X-Received: by 2002:a05:6402:4cb:: with SMTP id n11mr5102983edw.292.1631782522722; Thu, 16 Sep 2021 01:55:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631782522; cv=none; d=google.com; s=arc-20160816; b=YM5dRdjfPUadzaPzlrvSOr2z7pPxS7K/V/zzt52XRcbRHSWmT4v65OWhBpNI14Pvhc HI6VI2LTHOOFnxh6u0etBhrx3lOgcuKwhT9vK7x1ahg9PStNT/pgvo4eYm5CDat/3ll+ lU70jcdtsXyiO2qrsACKApPOvS3bhh4SXYkKAzUoHzbI2XY7vIJ8KqvPPu+JKNGRVxho 0Lt8S0I3zYx0uoFPcEPzvC2ttCa++LuZvjKLWydHe/in9WckLLBg/QSFU8+3r4XEKlYC gjs/GdXQjDL9iUyZgHwLeL9hX2BjwrKAYayGsHG4/Z/uFcBtCnQNtb+6Px/W1dxCHE7j x+ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:user-agent:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=1so1I0L4lqnwZllaOfYrjC9h6O8GDDBGq3FKcLGCwLs=; b=Irz+6D1qD2pPqn637Xlwnft6OwBoJn6y5KAIaSFx1zmg0CqJ2IAc4kVY7tBXu0hi0G P0riMRskfjQmbQJYaKSE/ImLv/4LXXgOZi2bmUehR2GURUF0f9CT9h9eZ8DySRzBydkF pDZfiLuozTIllgY4wcdYecAZnRjR3fkkX4vy5oui7OEAcnSVazOiysKmZ2yAPz2ONuJW 29Xz4jgAQTPfYxxUyvTxyY9sEFocoDw+yLqOL0Tn1bCUX6Y0/pD6Oyuy9IbirpGjePaJ 2c/rFZ1mewvV0ugqA8cvCvpoi8joKGgnR8fB0JNEjRqM7I8le6k8NJoRoakHxsCVT6x0 EgMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fWuEt+tg; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id dp9si2593122ejc.163.2021.09.16.01.55.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Sep 2021 01:55:22 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fWuEt+tg; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 715F383208; Thu, 16 Sep 2021 10:54:41 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="fWuEt+tg"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7E3BA82F4D; Thu, 16 Sep 2021 10:54:10 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3F32D82E03 for ; Thu, 16 Sep 2021 10:53:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=masami.hiramatsu@linaro.org Received: by mail-pg1-x534.google.com with SMTP id g184so5502072pgc.6 for ; Thu, 16 Sep 2021 01:53:49 -0700 (PDT) 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 :user-agent:mime-version:content-transfer-encoding; bh=1so1I0L4lqnwZllaOfYrjC9h6O8GDDBGq3FKcLGCwLs=; b=fWuEt+tgsju4nx2FfPojyrvhojthwuHpkYmZhpd384COyi0xdiGcDhOWoo7rkkdAKo F3o/5ZSKEbc9X/pp7wGsSm6pqbBXDfCX99+dT6+Gijp7nJ4xx2DCrRODl7xN9QFxfziQ jrmv5lCkOl+X4c58SJ+G9e9V2mS3ZwwVfFeen7VQiKkOFm/XSPIPfj09GpOGfwKqdU6N mb0r3o0k1J+5R8MFt8lAyO58Sggg7mpndu3ZP7o8egdzBSL+EMwUuOCgNiqK9UF2HYkh otUI6wOXLaPWOjEXFO0cQYxxE2TGbtnbECpza6SEaGeKCHBen9SBi+YRTtl34hOrjQw+ zzSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=1so1I0L4lqnwZllaOfYrjC9h6O8GDDBGq3FKcLGCwLs=; b=mX/Qf0tcuMr1K298jAcNitJSSSXuDdZIy40mzEQxKk34yTpoNcK8ee7RZAcdT9Ggwc ydKwD7DcGTLIJPYfc6lORI6XQkv/+aFzUD4CpMB79TwJgAV1hvA+FgGvCu9ZMVgTb5cE rwkByc3PFkZYNxBv3GTVnfmVcpg5YrXqWCtqzRfbnZXge/lU+E1JI3d++L+Cwd9Jf9Bv X2u8WnTd/ue+IQZSYy7QA6sXmJlHOXeuFefs3tns95exawSvcbsZ+L6fuBiaVj558ZbM TLDwQggN4Fi8s6MCBoqSA5KCBMJ/w7r2oXZRsYG8zhhJxTH8TZ44WpLTkbIAQ1bkQ2I3 rK0Q== X-Gm-Message-State: AOAM533eFjsv1DNBKdn5aPW4XWPLOru7JAu8WHFpZV60pY3JmrHm4b7x n9JkUhowhUGSQxHrYO8aFOpRFw== X-Received: by 2002:a62:64d3:0:b0:43d:ba3:1e2c with SMTP id y202-20020a6264d3000000b0043d0ba31e2cmr3969677pfb.5.1631782427600; Thu, 16 Sep 2021 01:53:47 -0700 (PDT) Received: from localhost.localdomain (122x208x150x49.ap122.ftth.ucom.ne.jp. [122.208.150.49]) by smtp.gmail.com with ESMTPSA id d63sm7169317pjk.17.2021.09.16.01.53.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Sep 2021 01:53:47 -0700 (PDT) From: Masami Hiramatsu To: Heinrich Schuchardt Cc: Kazuhiko Sakamoto , Masami Hiramatsu , Jassi Brar , Ilias Apalodimas , u-boot@lists.denx.de Subject: [PATCH 3/3] efi_selftest: Recieve the packets until the receive buffer is empty Date: Thu, 16 Sep 2021 17:53:44 +0900 Message-Id: <163178242457.65790.16820317670072849950.stgit@localhost> X-Mailer: git-send-email 2.25.1 In-Reply-To: <163178239865.65790.17211919979018423637.stgit@localhost> References: <163178239865.65790.17211919979018423637.stgit@localhost> User-Agent: StGit/0.19 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Repeatedly receive the packets until the receive buffer is empty. If the buffer is empty, EFI_SIMPLE_NETWORK_PROTOCOL::Receive() returns EFI_NOT_READY. We don't need to use the wait_for_event() every time. Signed-off-by: Masami Hiramatsu --- lib/efi_selftest/efi_selftest_snp.c | 67 +++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 30 deletions(-) diff --git a/lib/efi_selftest/efi_selftest_snp.c b/lib/efi_selftest/efi_selftest_snp.c index c5366c872c..818cbfcacd 100644 --- a/lib/efi_selftest/efi_selftest_snp.c +++ b/lib/efi_selftest/efi_selftest_snp.c @@ -362,39 +362,46 @@ static int execute(void) continue; } /* - * Receive packet + * Receive packets until buffer is empty */ - buffer_size = sizeof(buffer); - ret = net->receive(net, NULL, &buffer_size, &buffer, - &srcaddr, &destaddr, NULL); - if (ret != EFI_SUCCESS) { - efi_st_error("Failed to receive packet"); - return EFI_ST_FAILURE; + for (;;) { + buffer_size = sizeof(buffer); + ret = net->receive(net, NULL, &buffer_size, &buffer, + &srcaddr, &destaddr, NULL); + if (ret == EFI_NOT_READY) { + /* The received buffer is empty. */ + break; + } + + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to receive packet"); + return EFI_ST_FAILURE; + } + /* + * Check the packet is meant for this system. + * Unfortunately QEMU ignores the broadcast flag. + * So we have to check for broadcasts too. + */ + if (memcmp(&destaddr, &net->mode->current_address, ARP_HLEN) && + memcmp(&destaddr, BROADCAST_MAC, ARP_HLEN)) + continue; + /* + * Check this is a DHCP reply + */ + if (buffer.p.eth_hdr.et_protlen != ntohs(PROT_IP) || + buffer.p.ip_udp.ip_hl_v != 0x45 || + buffer.p.ip_udp.ip_p != IPPROTO_UDP || + buffer.p.ip_udp.udp_src != ntohs(67) || + buffer.p.ip_udp.udp_dst != ntohs(68) || + buffer.p.dhcp_hdr.op != BOOTREPLY) + continue; + /* + * We successfully received a DHCP reply. + */ + goto received; } - /* - * Check the packet is meant for this system. - * Unfortunately QEMU ignores the broadcast flag. - * So we have to check for broadcasts too. - */ - if (memcmp(&destaddr, &net->mode->current_address, ARP_HLEN) && - memcmp(&destaddr, BROADCAST_MAC, ARP_HLEN)) - continue; - /* - * Check this is a DHCP reply - */ - if (buffer.p.eth_hdr.et_protlen != ntohs(PROT_IP) || - buffer.p.ip_udp.ip_hl_v != 0x45 || - buffer.p.ip_udp.ip_p != IPPROTO_UDP || - buffer.p.ip_udp.udp_src != ntohs(67) || - buffer.p.ip_udp.udp_dst != ntohs(68) || - buffer.p.dhcp_hdr.op != BOOTREPLY) - continue; - /* - * We successfully received a DHCP reply. - */ - break; } - +received: /* * Write a log message. */