Commit 058a6b25 authored by Ye Li's avatar Ye Li Committed by Jason Liu
Browse files

MLK-16369 eth: fec: Fix DM driver issue in recv

When using ethernet DM driver, the recv interface has a change with non-DM
interface, that driver needs to set the packet pointer and provide it to upper
layer to process.
In fec driver, the fecmxc_recv functions does not handle the packet pointer parameter.
This may cause crash in upper layer processing because the packet pointer is not set.

This patch allocates a buffer for the packet pointer and free it through free_pkt interface.
Signed-off-by: default avatarYe Li <>
Reviewed-by: default avatarPeng Fan <>
parent 10c55182
......@@ -808,7 +808,16 @@ static int fec_recv(struct eth_device *dev)
uint16_t bd_status;
ulong addr, size, end;
int i;
*packetp = memalign(ARCH_DMA_MINALIGN, FEC_MAX_PKT_SIZE);
if (*packetp == 0) {
printf("%s: error allocating packetp\n", __func__);
return -ENOMEM;
/* Check if any critical events have happened */
ievent = readl(&fec->eth->ievent);
......@@ -884,8 +893,13 @@ static int fec_recv(struct eth_device *dev)
swap_packet((uint32_t *)addr, frame_length);
memcpy(*packetp, (char *)addr, frame_length);
memcpy(buff, (char *)addr, frame_length);
net_process_received_packet(buff, frame_length);
len = frame_length;
} else {
if (bd_status & FEC_RBD_ERR)
......@@ -919,6 +933,16 @@ static int fec_recv(struct eth_device *dev)
return len;
static int fecmxc_free_pkt(struct udevice *dev, uchar *packet, int length)
if (packet)
return 0;
static void fec_set_dev_name(char *dest, int dev_id)
sprintf(dest, (dev_id == -1) ? "FEC" : "FEC%i", dev_id);
......@@ -1215,6 +1239,7 @@ static const struct eth_ops fecmxc_ops = {
.start = fecmxc_init,
.send = fecmxc_send,
.recv = fecmxc_recv,
.free_pkt = fecmxc_free_pkt,
.stop = fecmxc_halt,
.write_hwaddr = fecmxc_set_hwaddr,
.read_rom_hwaddr = fecmxc_read_rom_hwaddr,
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment