From nobody Tue Oct 28 04:17:46 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; dkim=fail; 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 1514921957025613.3753126063706; Tue, 2 Jan 2018 11:39:17 -0800 (PST) Received: from localhost ([::1]:52915 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eWSOz-0004ig-7L for importer@patchew.org; Tue, 02 Jan 2018 14:39:09 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58602) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eWSMd-0003Gu-Ou for qemu-devel@nongnu.org; Tue, 02 Jan 2018 14:36:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eWSMc-0000Ll-81 for qemu-devel@nongnu.org; Tue, 02 Jan 2018 14:36:43 -0500 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:35751) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eWSMZ-0000Hf-9h; Tue, 02 Jan 2018 14:36:39 -0500 Received: by mail-pg0-x243.google.com with SMTP id b70so1331922pga.2; Tue, 02 Jan 2018 11:36:39 -0800 (PST) Received: from squirtle.westlake.spaceflightindustries.com ([173.226.206.194]) by smtp.gmail.com with ESMTPSA id g9sm97905951pfk.0.2018.01.02.11.36.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jan 2018 11:36:37 -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=It4x0Ahssp/XGd0/NGkh3MzTC/1Zj0ZOsLASSpzjVgYBb/8bN0MpWomQVzuczzuHIq kYx4l1aReWeGp6y78iAx3VPHwndum4w7LppMepfw7r0RF9Pzve1DZvFoO3ropSeazzO9 IrFD4iR6kcBGWQn+297N7dy513yF6Bpe4NgqefI7Jyv9cjc5u7sw+WV6Gsh95sZz+YBP 0C42wF3X38VCM1rnwdGGnIEFVdNOuRdD4EoeysamWdnUklVF7xMsuTEA8EhSDdHMWK1V W6eZo5j5oz1MkEV3LPfP4qV7k19KFOgipFvGfOfEoM62Ec3vQIvyXI/wn/H7xwNY+1Nn zBdA== 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=WnjffdeXgkOtNkF21F9J/pph/ygkauXKAPsTLbKtjrWjssDNH5euJhGLyfSZ6erbYc uG6dFhWIqd+HpmxbgZTEQjwKZ1sOnu2A0pZ7vrV55md+wPpMcV3K/og38oOt9yqw5y+9 Xoi3P3UAGQii3TFWygOVvgTHOdhy0SbKY46ljTqAVu5MrHFWdVd4Dd/Hy8dZzg1LqBTn ZVVC4UXdKlvtpe3cgM1K67VuHMT01iWf7v7QpIJSwv2ohnDGxItSHh89MAVSKxP9wXRf tkGN20V5fLigQr1K20CvlSpOaZnT1dJEIuqP2AVgrfF54cNm/5lNNboeY9/u2I4oKnoo awqQ== X-Gm-Message-State: AKGB3mKwLTNMVnnXoKtrXhrDJk9aAx0rYm9NgrOq0Rod2T6EWT0g2k/b 2xaGCkhLVCf/tfMFNq7LwlAXFxbMv0Y= X-Google-Smtp-Source: ACJfBouVcccBaP4jaKrZSHP+6vDc/IOULsnipFrD6/WGMRTtZffOIzC8OYU9GRV+eRpMYSNRM2iGog== X-Received: by 10.98.223.4 with SMTP id u4mr45655274pfg.233.1514921798080; Tue, 02 Jan 2018 11:36:38 -0800 (PST) From: Andrey Smirnov To: qemu-arm@nongnu.org Date: Tue, 2 Jan 2018 11:36:15 -0800 Message-Id: <20180102193622.27215-5-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180102193622.27215-1-andrew.smirnov@gmail.com> References: <20180102193622.27215-1-andrew.smirnov@gmail.com> 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: 2607:f8b0:400e:c05::243 Subject: [Qemu-devel] [PATCH v3 04/11] 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 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 --- 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 =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; 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; =20 bool is_fec; + + /* Buffer used to assemble a Tx frame */ + uint8_t frame[ENET_MAX_FRAME_SIZE]; } IMXFECState; =20 #endif --=20 2.14.3