projects
/
oweals
/
u-boot.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
qoriq eth.c bugfix: handle received corrupted frames correctly
[oweals/u-boot.git]
/
drivers
/
net
/
fec_mxc.c
diff --git
a/drivers/net/fec_mxc.c
b/drivers/net/fec_mxc.c
index 549d6486136204ed644a2c2ecba101d25db303ef..c5dcbbbcedecf7302f0c68536c102af8aec6e77d 100644
(file)
--- a/
drivers/net/fec_mxc.c
+++ b/
drivers/net/fec_mxc.c
@@
-11,6
+11,7
@@
#include <common.h>
#include <malloc.h>
#include <net.h>
#include <common.h>
#include <malloc.h>
#include <net.h>
+#include <netdev.h>
#include <miiphy.h>
#include "fec_mxc.h"
#include <miiphy.h>
#include "fec_mxc.h"
@@
-66,13
+67,6
@@
DECLARE_GLOBAL_DATA_PTR;
#undef DEBUG
#undef DEBUG
-struct nbuf {
- uint8_t data[1500]; /**< actual data */
- int length; /**< actual length */
- int used; /**< buffer in use or not */
- uint8_t head[16]; /**< MAC header(6 + 6 + 2) + 2(aligned) */
-};
-
#ifdef CONFIG_FEC_MXC_SWAP_PACKET
static void swap_packet(uint32_t *packet, int length)
{
#ifdef CONFIG_FEC_MXC_SWAP_PACKET
static void swap_packet(uint32_t *packet, int length)
{
@@
-179,13
+173,14
@@
static int fec_mdio_write(struct ethernet_regs *eth, uint8_t phyAddr,
return 0;
}
return 0;
}
-int fec_phy_read(struct mii_dev *bus, int phyAddr, int dev_addr, int regAddr)
+static int fec_phy_read(struct mii_dev *bus, int phyAddr, int dev_addr,
+ int regAddr)
{
return fec_mdio_read(bus->priv, phyAddr, regAddr);
}
{
return fec_mdio_read(bus->priv, phyAddr, regAddr);
}
-
int fec_phy_write(struct mii_dev *bus, int phyAddr, int dev_addr, int regA
ddr,
- u16 data)
+
static int fec_phy_write(struct mii_dev *bus, int phyAddr, int dev_a
ddr,
+
int regAddr,
u16 data)
{
return fec_mdio_write(bus->priv, phyAddr, regAddr, data);
}
{
return fec_mdio_write(bus->priv, phyAddr, regAddr, data);
}
@@
-355,7
+350,7
@@
static int fec_get_hwaddr(struct eth_device *dev, int dev_id,
unsigned char *mac)
{
imx_get_mac_from_fuse(dev_id, mac);
unsigned char *mac)
{
imx_get_mac_from_fuse(dev_id, mac);
- return !is_valid_eth
er_
addr(mac);
+ return !is_valid_ethaddr(mac);
}
static int fec_set_hwaddr(struct eth_device *dev)
}
static int fec_set_hwaddr(struct eth_device *dev)
@@
-773,7
+768,6
@@
static int fec_recv(struct eth_device *dev)
struct fec_bd *rbd = &fec->rbd_base[fec->rbd_index];
unsigned long ievent;
int frame_length, len = 0;
struct fec_bd *rbd = &fec->rbd_base[fec->rbd_index];
unsigned long ievent;
int frame_length, len = 0;
- struct nbuf *frame;
uint16_t bd_status;
uint32_t addr, size, end;
int i;
uint16_t bd_status;
uint32_t addr, size, end;
int i;
@@
-833,12
+827,11
@@
static int fec_recv(struct eth_device *dev)
/*
* Get buffer address and size
*/
/*
* Get buffer address and size
*/
-
frame = (struct nbuf *)
readl(&rbd->data_pointer);
+
addr =
readl(&rbd->data_pointer);
frame_length = readw(&rbd->data_length) - 4;
/*
* Invalidate data cache over the buffer
*/
frame_length = readw(&rbd->data_length) - 4;
/*
* Invalidate data cache over the buffer
*/
- addr = (uint32_t)frame;
end = roundup(addr + frame_length, ARCH_DMA_MINALIGN);
addr &= ~(ARCH_DMA_MINALIGN - 1);
invalidate_dcache_range(addr, end);
end = roundup(addr + frame_length, ARCH_DMA_MINALIGN);
addr &= ~(ARCH_DMA_MINALIGN - 1);
invalidate_dcache_range(addr, end);
@@
-847,16
+840,15
@@
static int fec_recv(struct eth_device *dev)
* Fill the buffer and pass it to upper layers
*/
#ifdef CONFIG_FEC_MXC_SWAP_PACKET
* Fill the buffer and pass it to upper layers
*/
#ifdef CONFIG_FEC_MXC_SWAP_PACKET
- swap_packet((uint32_t *)
frame->data
, frame_length);
+ swap_packet((uint32_t *)
addr
, frame_length);
#endif
#endif
- memcpy(buff,
frame->data
, frame_length);
-
NetReceive
(buff, 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)
len = frame_length;
} else {
if (bd_status & FEC_RBD_ERR)
- printf("error frame: 0x%08lx 0x%08x\n",
- (ulong)rbd->data_pointer,
- bd_status);
+ printf("error frame: 0x%08x 0x%08x\n",
+ addr, bd_status);
}
/*
}
/*