diff options
author | Andrey Smirnov <andrew.smirnov@gmail.com> | 2018-09-17 22:21:18 -0700 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2018-09-19 09:55:54 +0200 |
commit | 78b1a4c1415a55789b6e18083b94c65f5f8667b9 (patch) | |
tree | fdefecd991c9f51f441623c7a5d0c3efbc3026e9 /drivers/net/fec_imx.c | |
parent | fb12695461738359430486f2694180fdad46c37c (diff) | |
download | barebox-78b1a4c1415a55789b6e18083b94c65f5f8667b9.tar.gz barebox-78b1a4c1415a55789b6e18083b94c65f5f8667b9.tar.xz |
net: fec_imx: Read data_length only once
Data length of a given Rx data descriptor isn't going to change until
that descriptor is processed and given back to HW. Re-work the code to
save and re-use that value instead.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/net/fec_imx.c')
-rw-r--r-- | drivers/net/fec_imx.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c index 25e2425d6e..36218f3c96 100644 --- a/drivers/net/fec_imx.c +++ b/drivers/net/fec_imx.c @@ -574,20 +574,23 @@ static int fec_recv(struct eth_device *dev) if (bd_status & FEC_RBD_ERR) { dev_warn(&dev->dev, "error frame: 0x%p 0x%08x\n", rbd, bd_status); - } else if ((bd_status & FEC_RBD_LAST) && - ((readw(&rbd->data_length) - 4) > 14)) { - if (fec_is_imx28(fec)) - imx28_fix_endianess_rd( - phys_to_virt(readl(&rbd->data_pointer)), - (readw(&rbd->data_length) + 3) >> 2); - - /* - * Get buffer address and size - */ - frame = phys_to_virt(readl(&rbd->data_pointer)); - frame_length = readw(&rbd->data_length) - 4; - net_receive(dev, frame->data, frame_length); - len = frame_length; + } else if (bd_status & FEC_RBD_LAST) { + const uint16_t data_length = readw(&rbd->data_length); + + if (data_length - 4 > 14) { + if (fec_is_imx28(fec)) + imx28_fix_endianess_rd( + phys_to_virt(readl(&rbd->data_pointer)), + (data_length + 3) >> 2); + + /* + * Get buffer address and size + */ + frame = phys_to_virt(readl(&rbd->data_pointer)); + frame_length = data_length - 4; + net_receive(dev, frame->data, frame_length); + len = frame_length; + } } /* * free the current buffer, restart the engine |