[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-arm] [PATCH v3 04/11] imx_fec: Move Tx frame buffer away from the
From: |
Andrey Smirnov |
Subject: |
[Qemu-arm] [PATCH v3 04/11] imx_fec: Move Tx frame buffer away from the stack |
Date: |
Tue, 2 Jan 2018 11:36:15 -0800 |
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 <address@hidden>
Cc: Jason Wang <address@hidden>
Cc: Philippe Mathieu-Daudé <address@hidden>
Cc: address@hidden
Cc: address@hidden
Cc: address@hidden
Signed-off-by: Andrey Smirnov <address@hidden>
---
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
--
2.14.3
- [Qemu-arm] [PATCH v3 00/11] i.MX FEC changes, Andrey Smirnov, 2018/01/02
- [Qemu-arm] [PATCH v3 02/11] imx_fec: Refactor imx_eth_enable_rx(), Andrey Smirnov, 2018/01/02
- [Qemu-arm] [PATCH v3 01/11] imx_fec: Do not link to netdev, Andrey Smirnov, 2018/01/02
- [Qemu-arm] [PATCH v3 03/11] imx_fec: Change queue flushing heuristics, Andrey Smirnov, 2018/01/02
- [Qemu-arm] [PATCH v3 04/11] imx_fec: Move Tx frame buffer away from the stack,
Andrey Smirnov <=
- [Qemu-arm] [PATCH v3 05/11] imx_fec: Use ENET_FTRL to determine truncation length, Andrey Smirnov, 2018/01/02
- [Qemu-arm] [PATCH v3 07/11] imx_fec: Emulate SHIFT16 in ENETx_RACC, Andrey Smirnov, 2018/01/02
- [Qemu-arm] [PATCH v3 06/11] imx_fec: Use MIN instead of explicit ternary operator, Andrey Smirnov, 2018/01/02
- [Qemu-arm] [PATCH v3 08/11] imx_fec: Add support for multiple Tx DMA rings, Andrey Smirnov, 2018/01/02
- [Qemu-arm] [PATCH v3 10/11] imx_fec: Fix a typo in imx_enet_receive(), Andrey Smirnov, 2018/01/02
- [Qemu-arm] [PATCH v3 11/11] imx_fec: Reserve full FSL_IMX25_FEC_SIZE page for the register file, Andrey Smirnov, 2018/01/02
- [Qemu-arm] [PATCH v3 09/11] imx_fec: Use correct length for packet size, Andrey Smirnov, 2018/01/02
- Re: [Qemu-arm] [PATCH v3 00/11] i.MX FEC changes, Peter Maydell, 2018/01/08