From nobody Tue Apr 8 22:22:42 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1515678041376149.08304167277015; Thu, 11 Jan 2018 05:40:41 -0800 (PST) Received: from localhost ([::1]:43951 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZd60-0000Yz-FL for importer@patchew.org; Thu, 11 Jan 2018 08:40:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52171) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZd41-0007Rp-JT for qemu-devel@nongnu.org; Thu, 11 Jan 2018 08:38:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZd40-00006B-77 for qemu-devel@nongnu.org; Thu, 11 Jan 2018 08:38:37 -0500 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:45846) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eZd3z-0008Ve-VS for qemu-devel@nongnu.org; Thu, 11 Jan 2018 08:38:36 -0500 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1eZd3y-0005gH-Kv for qemu-devel@nongnu.org; Thu, 11 Jan 2018 13:38:34 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 11 Jan 2018 13:38:09 +0000 Message-Id: <1515677902-23436-14-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515677902-23436-1-git-send-email-peter.maydell@linaro.org> References: <1515677902-23436-1-git-send-email-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 13/26] 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 From: Andrey Smirnov 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=C3=A9 Cc: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Cc: yurovsky@gmail.com Signed-off-by: Andrey Smirnov Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- include/hw/net/imx_fec.h | 3 +++ hw/net/imx_fec.c | 22 +++++++++++----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/include/hw/net/imx_fec.h b/include/hw/net/imx_fec.h index 62ad473..6799387 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; =20 bool is_fec; + + /* Buffer used to assemble a Tx frame */ + uint8_t frame[ENET_MAX_FRAME_SIZE]; } IMXFECState; =20 #endif diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c index eb034ff..56cb722 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 =3D 0, descnt =3D 0; - uint8_t frame[ENET_MAX_FRAME_SIZE]; - uint8_t *ptr =3D frame; + uint8_t *ptr =3D s->frame; uint32_t addr =3D s->tx_descriptor; =20 while (descnt++ < IMX_MAX_DESC) { @@ -431,8 +430,8 @@ static void imx_fec_do_tx(IMXFECState *s) frame_size +=3D len; if (bd.flags & ENET_BD_L) { /* Last buffer in frame. */ - qemu_send_packet(qemu_get_queue(s->nic), frame, frame_size); - ptr =3D frame; + qemu_send_packet(qemu_get_queue(s->nic), s->frame, frame_size); + ptr =3D s->frame; frame_size =3D 0; s->regs[ENET_EIR] |=3D 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 =3D 0, descnt =3D 0; - uint8_t frame[ENET_MAX_FRAME_SIZE]; - uint8_t *ptr =3D frame; + uint8_t *ptr =3D s->frame; uint32_t addr =3D s->tx_descriptor; =20 while (descnt++ < IMX_MAX_DESC) { @@ -482,13 +480,13 @@ static void imx_enet_do_tx(IMXFECState *s) frame_size +=3D len; if (bd.flags & ENET_BD_L) { if (bd.option & ENET_BD_PINS) { - struct ip_header *ip_hd =3D PKT_GET_IP_HDR(frame); + struct ip_header *ip_hd =3D PKT_GET_IP_HDR(s->frame); if (IP_HEADER_VERSION(ip_hd) =3D=3D 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 =3D PKT_GET_IP_HDR(frame); + struct ip_header *ip_hd =3D PKT_GET_IP_HDR(s->frame); /* We compute checksum only for IPv4 frames */ if (IP_HEADER_VERSION(ip_hd) =3D=3D 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 =3D frame; + + qemu_send_packet(qemu_get_queue(s->nic), s->frame, len); + ptr =3D s->frame; + frame_size =3D 0; if (bd.option & ENET_BD_TX_INT) { s->regs[ENET_EIR] |=3D ENET_INT_TXF; --=20 2.7.4