From patchwork Thu Dec 14 14:52:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 10112381 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 277236019C for ; Thu, 14 Dec 2017 14:57:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1688B28F31 for ; Thu, 14 Dec 2017 14:57:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 09E1E28F6A; Thu, 14 Dec 2017 14:57:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EBB3328F31 for ; Thu, 14 Dec 2017 14:57:23 +0000 (UTC) Received: from localhost ([::1]:41389 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePUwt-0004es-3k for patchwork-qemu-devel@patchwork.kernel.org; Thu, 14 Dec 2017 09:57:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55154) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePUt6-0001PT-U3 for qemu-devel@nongnu.org; Thu, 14 Dec 2017 09:53:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePUt5-0000PO-Re for qemu-devel@nongnu.org; Thu, 14 Dec 2017 09:53:28 -0500 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:45309) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ePUt3-0000Ji-CM; Thu, 14 Dec 2017 09:53:25 -0500 Received: by mail-pf0-x241.google.com with SMTP id u19so3752620pfa.12; Thu, 14 Dec 2017 06:53:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=o0B8caNespqWoZFU8fH9V1pRE4+ngVW5SMovMv0JMfk=; b=i4M+ywCqIZllH8KbXZJ9cKu6eqQhWd1Uks/sJDlaqr0CjqJtYRMlrnqTTT/vWJDfz9 pyg8cIfNR2Y/CS2dpTpalss1TwtDgG/WJVt1wal5DTEvuC+uzMuZwqua7C5mv5miHGG2 YdFOzr0MW7eKCC2kR7tbd/lfSxXUDussUIwGkhfYCjW8Dc2NX+RUXSj0uZA+RCmKXjBS qyiB5/xjzu99myernsw5/ItSs3lGJXNCVQMeDrp6BinI6kLGJjMX5Qd5+quISWwWzJWb 9x3VceJ9D934Y2sq7dYtlX8MRynYbo1e617tYQd0rtnkNvbzUd3KOyn5L8xOXf937a0e 6RqA== 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=o0B8caNespqWoZFU8fH9V1pRE4+ngVW5SMovMv0JMfk=; b=NQFH9G7RspdUXy+LYTOrov3Wdze5i1s3QDwToizatbGu2ubP6n4c9OtJB9sY8q/Huu teVnJcfE/ej0iW/6l5zfkDDC5gRjrrGT9UMZ5QAuL8bzRBG2DQqKrFXgF9vcXnDBcN94 ZXYh4J/AMc6lohSRPj/HDWq15gU8rz4Ds+Ka+OIZ7i1RAxdqWKB52Q++HyqQW4Fmzfru o+MKDCMjbZHEDB5IKwPh9iBjl7PNAYs5qEcK7Ur/fWazj4wLDv9ch7bdBj1SKXl1Fwsx wKhQntsNINpnDMrNNpW3IwjA7Ue/M/zcD/mAGO7D3/LU4mnPedqm01ZsrmdXoQGux9BL q8VQ== X-Gm-Message-State: AKGB3mKpCTO8gxp/0LudxNAnwWYBZpVs9Bq2dAyGBG/Ke5husHEJuCSE LLxdJgyUiDTjDPtyS9vtmbTHPwD2 X-Google-Smtp-Source: ACJfBosN07KheB6JZHnUrKRtZrn/s7nZ+NkDpZStXMD610PXYnpBtfFJVdABxi6JmRZGtamLRhqVsQ== X-Received: by 10.84.173.1 with SMTP id o1mr9993434plb.135.1513263204084; Thu, 14 Dec 2017 06:53:24 -0800 (PST) Received: from squirtle.lan (c-24-22-235-96.hsd1.wa.comcast.net. [24.22.235.96]) by smtp.gmail.com with ESMTPSA id e7sm8757439pfj.44.2017.12.14.06.53.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Dec 2017 06:53:23 -0800 (PST) From: Andrey Smirnov To: qemu-arm@nongnu.org Date: Thu, 14 Dec 2017 06:52:44 -0800 Message-Id: <20171214145255.31545-5-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171214145255.31545-1-andrew.smirnov@gmail.com> References: <20171214145255.31545-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::241 Subject: [Qemu-devel] [PATCH v2 04/15] imx_fec: Move Tx frame buffer away from the stack X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Andrey Smirnov , Jason Wang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, yurovsky@gmail.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Make Tx frame assembly buffer to be a paort of IMXFECState structure to avoid a concern about having large data buffer on the stack. Cc: Peter Maydell Cc: Jason Wang Cc: Philippe Mathieu-Daudé Cc: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Cc: yurovsky@gmail.com Signed-off-by: Andrey Smirnov --- hw/net/imx_fec.c | 22 +++++++++++----------- include/hw/net/imx_fec.h | 3 +++ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c index eb034ffd0c..56cb72273c 100644 --- a/hw/net/imx_fec.c +++ b/hw/net/imx_fec.c @@ -405,8 +405,7 @@ static void imx_eth_update(IMXFECState *s) static void imx_fec_do_tx(IMXFECState *s) { int frame_size = 0, descnt = 0; - uint8_t frame[ENET_MAX_FRAME_SIZE]; - uint8_t *ptr = frame; + uint8_t *ptr = s->frame; uint32_t addr = s->tx_descriptor; while (descnt++ < IMX_MAX_DESC) { @@ -431,8 +430,8 @@ static void imx_fec_do_tx(IMXFECState *s) frame_size += len; if (bd.flags & ENET_BD_L) { /* Last buffer in frame. */ - qemu_send_packet(qemu_get_queue(s->nic), frame, frame_size); - ptr = frame; + qemu_send_packet(qemu_get_queue(s->nic), s->frame, frame_size); + ptr = s->frame; frame_size = 0; s->regs[ENET_EIR] |= ENET_INT_TXF; } @@ -456,8 +455,7 @@ static void imx_fec_do_tx(IMXFECState *s) static void imx_enet_do_tx(IMXFECState *s) { int frame_size = 0, descnt = 0; - uint8_t frame[ENET_MAX_FRAME_SIZE]; - uint8_t *ptr = frame; + uint8_t *ptr = s->frame; uint32_t addr = s->tx_descriptor; while (descnt++ < IMX_MAX_DESC) { @@ -482,13 +480,13 @@ static void imx_enet_do_tx(IMXFECState *s) frame_size += len; if (bd.flags & ENET_BD_L) { if (bd.option & ENET_BD_PINS) { - struct ip_header *ip_hd = PKT_GET_IP_HDR(frame); + struct ip_header *ip_hd = PKT_GET_IP_HDR(s->frame); if (IP_HEADER_VERSION(ip_hd) == 4) { - net_checksum_calculate(frame, frame_size); + net_checksum_calculate(s->frame, frame_size); } } if (bd.option & ENET_BD_IINS) { - struct ip_header *ip_hd = PKT_GET_IP_HDR(frame); + struct ip_header *ip_hd = PKT_GET_IP_HDR(s->frame); /* We compute checksum only for IPv4 frames */ if (IP_HEADER_VERSION(ip_hd) == 4) { uint16_t csum; @@ -498,8 +496,10 @@ static void imx_enet_do_tx(IMXFECState *s) } } /* Last buffer in frame. */ - qemu_send_packet(qemu_get_queue(s->nic), frame, len); - ptr = frame; + + qemu_send_packet(qemu_get_queue(s->nic), s->frame, len); + ptr = s->frame; + frame_size = 0; if (bd.option & ENET_BD_TX_INT) { s->regs[ENET_EIR] |= ENET_INT_TXF; diff --git a/include/hw/net/imx_fec.h b/include/hw/net/imx_fec.h index 62ad473b05..67993870a2 100644 --- a/include/hw/net/imx_fec.h +++ b/include/hw/net/imx_fec.h @@ -252,6 +252,9 @@ typedef struct IMXFECState { uint32_t phy_int_mask; bool is_fec; + + /* Buffer used to assemble a Tx frame */ + uint8_t frame[ENET_MAX_FRAME_SIZE]; } IMXFECState; #endif