{"id":817980,"url":"http://patchwork.ozlabs.org/api/patches/817980/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/20170924195716.3433-11-xypron.glpk@gmx.de/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170924195716.3433-11-xypron.glpk@gmx.de>","list_archive_url":null,"date":"2017-09-24T19:57:09","name":"[U-Boot,10/17] efi_loader: use events for efi_net_receive","commit_ref":null,"pull_url":null,"state":"superseded","archived":true,"hash":"90d4a47f6ecc8af9db2c5bcd061bc5cf5a563f49","submitter":{"id":61270,"url":"http://patchwork.ozlabs.org/api/people/61270/?format=json","name":"Heinrich Schuchardt","email":"xypron.glpk@gmx.de"},"delegate":{"id":3400,"url":"http://patchwork.ozlabs.org/api/users/3400/?format=json","username":"agraf","first_name":"Alexander","last_name":"Graf","email":"agraf@suse.de"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/20170924195716.3433-11-xypron.glpk@gmx.de/mbox/","series":[{"id":4841,"url":"http://patchwork.ozlabs.org/api/series/4841/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/list/?series=4841","date":"2017-09-24T19:57:03","name":"efi_loader: Simple Network Protocol","version":1,"mbox":"http://patchwork.ozlabs.org/series/4841/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/817980/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/817980/checks/","tags":{},"related":[],"headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3y0dXd5fb0z9t3R\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 25 Sep 2017 06:06:57 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 6F065C22149; Sun, 24 Sep 2017 20:00:49 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 2338CC2212D;\n\tSun, 24 Sep 2017 19:58:48 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 31742C22150; Sun, 24 Sep 2017 19:58:16 +0000 (UTC)","from mout.gmx.net (mout.gmx.net [212.227.17.21])\n\tby lists.denx.de (Postfix) with ESMTPS id 42D9DC2210F\n\tfor <u-boot@lists.denx.de>; Sun, 24 Sep 2017 19:58:13 +0000 (UTC)","from workstation4.fritz.box ([84.118.154.110]) by mail.gmx.com\n\t(mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id\n\t0M4B71-1d6RYd1RMB-00rmOz; Sun, 24 Sep 2017 21:57:32 +0200"],"X-Spam-Checker-Version":"SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=-0.7 required=5.0 tests=FREEMAIL_FROM,\n\tRCVD_IN_DNSWL_LOW,\n\tRCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no\n\tversion=3.4.0","From":"Heinrich Schuchardt <xypron.glpk@gmx.de>","To":"Alexander Graf <agraf@suse.de>","Date":"Sun, 24 Sep 2017 21:57:09 +0200","Message-Id":"<20170924195716.3433-11-xypron.glpk@gmx.de>","X-Mailer":"git-send-email 2.14.1","In-Reply-To":"<20170924195716.3433-1-xypron.glpk@gmx.de>","References":"<20170924195716.3433-1-xypron.glpk@gmx.de>","X-Provags-ID":"V03:K0:KRiHEP7Qh3udrDLsVppPRXZUeZD0iaWLYzZW84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g9DlWUTFQeSM+52HvvwZM+WHyG7\n\t0ISEwT1myseAwSOPxJXhI2nDfFyGA==","Cc":"Heinrich Schuchardt <xypron.glpk@gmx.de>, u-boot@lists.denx.de","Subject":"[U-Boot] [PATCH 10/17] efi_loader: use events for efi_net_receive","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"},"content":"A timer event is defined. The timer handler cares for receiving new\npackets.\n\nefi_timer_check is called both in efi_net_transmit and efi_net_receive\nto enable events during network communication.\n\nCalling efi_timer_check in efi_net_get_status is implemented in a\nseparate patch.\n\nSigned-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>\n---\n lib/efi_loader/efi_net.c | 53 +++++++++++++++++++++++++++++++++++++++++++++---\n 1 file changed, 50 insertions(+), 3 deletions(-)","diff":"diff --git a/lib/efi_loader/efi_net.c b/lib/efi_loader/efi_net.c\nindex 569bf367a8..3498b96f7a 100644\n--- a/lib/efi_loader/efi_net.c\n+++ b/lib/efi_loader/efi_net.c\n@@ -19,6 +19,11 @@ static const efi_guid_t efi_pxe_guid = EFI_PXE_GUID;\n static struct efi_pxe_packet *dhcp_ack;\n static bool new_rx_packet;\n static void *new_tx_packet;\n+/*\n+ * The notification function of this event is called in every timer cycle\n+ * to check if a new network packet has been received.\n+ */\n+static struct efi_event *network_timer_event;\n \n struct efi_net_obj {\n \t/* Generic EFI object parent class data */\n@@ -143,6 +148,8 @@ static efi_status_t EFIAPI efi_net_transmit(struct efi_simple_network *this,\n \tEFI_ENTRY(\"%p, %lx, %lx, %p, %p, %p, %p\", this, header_size,\n \t\t  buffer_size, buffer, src_addr, dest_addr, protocol);\n \n+\tefi_timer_check();\n+\n \tif (header_size) {\n \t\t/* We would need to create the header if header_size != 0 */\n \t\treturn EFI_EXIT(EFI_INVALID_PARAMETER);\n@@ -174,9 +181,7 @@ static efi_status_t EFIAPI efi_net_receive(struct efi_simple_network *this,\n \tEFI_ENTRY(\"%p, %p, %p, %p, %p, %p, %p\", this, header_size,\n \t\t  buffer_size, buffer, src_addr, dest_addr, protocol);\n \n-\tpush_packet = efi_net_push;\n-\teth_rx();\n-\tpush_packet = NULL;\n+\tefi_timer_check();\n \n \tif (!new_rx_packet)\n \t\treturn EFI_EXIT(EFI_NOT_READY);\n@@ -204,10 +209,32 @@ void efi_net_set_dhcp_ack(void *pkt, int len)\n \tmemcpy(dhcp_ack, pkt, min(len, maxsize));\n }\n \n+/*\n+ * Check if a new network packet has been received.\n+ *\n+ * This notification function is called in every timer cycle.\n+ *\n+ * @event\tthe event for which this notification function is registered\n+ * @context\tevent context - not used in this function\n+ */\n+static void EFIAPI efi_network_timer_notify(struct efi_event *event,\n+\t\t\t\t\t    void *context)\n+{\n+\tEFI_ENTRY(\"%p, %p\", event, context);\n+\n+\tif (!new_rx_packet) {\n+\t\tpush_packet = efi_net_push;\n+\t\teth_rx();\n+\t\tpush_packet = NULL;\n+\t}\n+\tEFI_EXIT(EFI_SUCCESS);\n+}\n+\n /* This gets called from do_bootefi_exec(). */\n int efi_net_register(void)\n {\n \tstruct efi_net_obj *netobj;\n+\tefi_status_t r;\n \n \tif (!eth_get_dev()) {\n \t\t/* No eth device active, don't expose any */\n@@ -253,5 +280,25 @@ int efi_net_register(void)\n \t/* Hook net up to the device list */\n \tlist_add_tail(&netobj->parent.link, &efi_obj_list);\n \n+\t/*\n+\t * Create a timer event.\n+\t *\n+\t * The notification function is used to check if an new networkd packet\n+\t * has been received.\n+\t */\n+\tr = efi_create_event(EVT_TIMER | EVT_NOTIFY_SIGNAL, TPL_CALLBACK,\n+\t\t\t     efi_network_timer_notify, NULL,\n+\t\t\t     &network_timer_event);\n+\tif (r != EFI_SUCCESS) {\n+\t\tprintf(\"ERROR: Failed to register network event\\n\");\n+\t\treturn r;\n+\t}\n+\t/* Network is time critical, create event in every timer cyle */\n+\tr = efi_set_timer(network_timer_event, EFI_TIMER_PERIODIC, 0);\n+\tif (r != EFI_SUCCESS) {\n+\t\tprintf(\"ERROR: Failed to set network timer\\n\");\n+\t\treturn r;\n+\t}\n+\n \treturn 0;\n }\n","prefixes":["U-Boot","10/17"]}