* [PATCH 2/4] net: Pass eth_device to net_receive
2014-05-15 6:32 [PATCH] Multi network device improvements Sascha Hauer
2014-05-15 6:32 ` [PATCH 1/4] net: ifup: Set current ethernet device when doing ifup Sascha Hauer
@ 2014-05-15 6:32 ` Sascha Hauer
2014-05-15 6:32 ` [PATCH 3/4] net: Allow to use multiple network interfaces at once Sascha Hauer
2014-05-15 6:32 ` [PATCH 4/4] net: phy: Print ethernet device in the link information Sascha Hauer
3 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2014-05-15 6:32 UTC (permalink / raw)
To: barebox
So that barebox has the information which interface a packet
came from.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/net/altera_tse.c | 2 +-
drivers/net/ar231x.c | 2 +-
drivers/net/arc_emac.c | 2 +-
drivers/net/at91_ether.c | 2 +-
drivers/net/cpsw.c | 2 +-
drivers/net/cs8900.c | 2 +-
drivers/net/davinci_emac.c | 2 +-
drivers/net/designware.c | 2 +-
drivers/net/dm9k.c | 2 +-
drivers/net/ep93xx.c | 2 +-
drivers/net/ethoc.c | 2 +-
drivers/net/fec_imx.c | 2 +-
drivers/net/fec_mpc5200.c | 2 +-
drivers/net/gianfar.c | 2 +-
drivers/net/ks8851_mll.c | 2 +-
drivers/net/macb.c | 4 ++--
drivers/net/netx_eth.c | 2 +-
drivers/net/orion-gbe.c | 2 +-
drivers/net/smc91111.c | 2 +-
drivers/net/smc911x.c | 2 +-
drivers/net/tap.c | 2 +-
drivers/net/usb/asix.c | 2 +-
drivers/net/usb/smsc95xx.c | 4 ++--
drivers/net/usb/usbnet.c | 2 +-
drivers/net/xgmac.c | 2 +-
include/net.h | 2 +-
net/net.c | 2 +-
27 files changed, 29 insertions(+), 29 deletions(-)
diff --git a/drivers/net/altera_tse.c b/drivers/net/altera_tse.c
index 6978e2a..4bbf595 100644
--- a/drivers/net/altera_tse.c
+++ b/drivers/net/altera_tse.c
@@ -402,7 +402,7 @@ static int tse_eth_rx(struct eth_device *edev)
ALT_SGDMA_DESCRIPTOR_STATUS_TERMINATED_BY_EOP_MSK) {
packet_length = rx_desc->actual_bytes_transferred;
- net_receive(NetRxPackets[0], packet_length);
+ net_receive(edev, NetRxPackets[0], packet_length);
/* Clear Run */
rx_sgdma->control = (rx_sgdma->control & (~ALT_SGDMA_CONTROL_RUN_MSK));
diff --git a/drivers/net/ar231x.c b/drivers/net/ar231x.c
index 515de17..572008a 100644
--- a/drivers/net/ar231x.c
+++ b/drivers/net/ar231x.c
@@ -217,7 +217,7 @@ static int ar231x_eth_recv(struct eth_device *edev)
u16 length =
((status >> DMA_RX_LEN_SHIFT) & 0x3fff)
- CRC_LEN;
- net_receive((void *)rxdsc->buffer_ptr, length);
+ net_receive(edev, (void *)rxdsc->buffer_ptr, length);
}
/* Clean descriptor. now it is owned by DMA. */
priv->next_rxdsc = (struct ar231x_descr *)rxdsc->next_dsc_ptr;
diff --git a/drivers/net/arc_emac.c b/drivers/net/arc_emac.c
index 1f1e889..3f6f814 100644
--- a/drivers/net/arc_emac.c
+++ b/drivers/net/arc_emac.c
@@ -304,7 +304,7 @@ static int arc_emac_recv(struct eth_device *edev)
dma_inv_range((unsigned long)rxbd->data,
(unsigned long)rxbd->data + pktlen);
- net_receive((unsigned char *)rxbd->data, pktlen);
+ net_receive(edev, (unsigned char *)rxbd->data, pktlen);
rxbd->info = cpu_to_le32(FOR_EMAC | PKTSIZE);
}
diff --git a/drivers/net/at91_ether.c b/drivers/net/at91_ether.c
index bf2f957..e09ea83 100644
--- a/drivers/net/at91_ether.c
+++ b/drivers/net/at91_ether.c
@@ -224,7 +224,7 @@ static int at91_ether_rx(struct eth_device *edev)
size = rbfp->size & RBF_SIZE;
- net_receive((unsigned char *)(rbfp->addr & RBF_ADDR), size);
+ net_receive(edev, (unsigned char *)(rbfp->addr & RBF_ADDR), size);
rbfp->addr &= ~RBF_OWNER;
if (rbfp->addr & RBF_WRAP)
diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
index ec3263d..a5cbacf 100644
--- a/drivers/net/cpsw.c
+++ b/drivers/net/cpsw.c
@@ -895,7 +895,7 @@ static int cpsw_recv(struct eth_device *edev)
while (cpdma_process(priv, &priv->rx_chan, &buffer, &len) >= 0) {
dma_inv_range((ulong)buffer, (ulong)buffer + len);
- net_receive(buffer, len);
+ net_receive(edev, buffer, len);
cpdma_submit(priv, &priv->rx_chan, buffer, PKTSIZE);
}
diff --git a/drivers/net/cs8900.c b/drivers/net/cs8900.c
index aa9d9a0..dccb808 100644
--- a/drivers/net/cs8900.c
+++ b/drivers/net/cs8900.c
@@ -309,7 +309,7 @@ static int cs8900_recv(struct eth_device *dev)
if (len & 1) {
*addr++ = readw(priv->regs + CS8900_RTDATA0);
}
- net_receive(NetRxPackets[0], len);
+ net_receive(dev, NetRxPackets[0], len);
return len;
}
diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c
index 7848f50..ce367a3 100644
--- a/drivers/net/davinci_emac.c
+++ b/drivers/net/davinci_emac.c
@@ -462,7 +462,7 @@ static int davinci_emac_recv(struct eth_device *edev)
dev_dbg(priv->dev, "| emac_recv got packet (length %i)\n", len);
dma_inv_range((ulong)pkt,
(ulong)readl(rx_curr_desc + EMAC_DESC_BUFFER) + len);
- net_receive(pkt, len);
+ net_receive(edev, pkt, len);
ret = len;
}
diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index e706f54..ac2eca5 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -356,7 +356,7 @@ static int dwc_ether_rx(struct eth_device *dev)
dma_inv_range((unsigned long)desc_p->dmamac_addr,
(unsigned long)desc_p->dmamac_addr + length);
- net_receive(desc_p->dmamac_addr, length);
+ net_receive(dev, desc_p->dmamac_addr, length);
desc_p->txrx_status |= DESC_RXSTS_OWNBYDMA;
diff --git a/drivers/net/dm9k.c b/drivers/net/dm9k.c
index 4c28870..e98b8f4 100644
--- a/drivers/net/dm9k.c
+++ b/drivers/net/dm9k.c
@@ -633,7 +633,7 @@ static int dm9k_eth_rx(struct eth_device *edev)
dev_dbg(dev, "Receiving packet\n");
dm9k_rd(priv->buswidth, priv->iodata, priv->pckt, rx_len);
dev_dbg(dev, "passing %u bytes packet to upper layer\n", rx_len);
- net_receive(priv->pckt, rx_len);
+ net_receive(edev, priv->pckt, rx_len);
} else {
dev_dbg(dev, "Discarding packet\n");
dm9k_dump(priv->buswidth, priv->iodata, rx_len); /* discard packet */
diff --git a/drivers/net/ep93xx.c b/drivers/net/ep93xx.c
index 1ecef13..4b73abf 100644
--- a/drivers/net/ep93xx.c
+++ b/drivers/net/ep93xx.c
@@ -344,7 +344,7 @@ static int ep93xx_eth_rcv_packet(struct eth_device *edev)
* used when we pass the data off to the protocol
* layer via net_receive().
*/
- net_receive((uchar *)priv->rx_dq.current->word1,
+ net_receive(edev, (uchar *)priv->rx_dq.current->word1,
RX_STATUS_FRAME_LEN(priv->rx_sq.current));
pr_debug("reporting %d bytes...\n",
RX_STATUS_FRAME_LEN(priv->rx_sq.current));
diff --git a/drivers/net/ethoc.c b/drivers/net/ethoc.c
index b000875..ced84df 100644
--- a/drivers/net/ethoc.c
+++ b/drivers/net/ethoc.c
@@ -369,7 +369,7 @@ static int ethoc_rx(struct eth_device *edev, int limit)
size -= 4; /* strip the CRC */
invalidate_dcache_range(bd.addr, bd.addr + PKTSIZE);
- net_receive((unsigned char *)bd.addr, size);
+ net_receive(edev, (unsigned char *)bd.addr, size);
}
/* clear the buffer descriptor so it can be reused */
diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
index 72e689d..88f9e75 100644
--- a/drivers/net/fec_imx.c
+++ b/drivers/net/fec_imx.c
@@ -581,7 +581,7 @@ static int fec_recv(struct eth_device *dev)
*/
frame = phys_to_virt(readl(&rbd->data_pointer));
frame_length = readw(&rbd->data_length) - 4;
- net_receive(frame->data, frame_length);
+ net_receive(dev, frame->data, frame_length);
len = frame_length;
} else {
if (bd_status & FEC_RBD_ERR) {
diff --git a/drivers/net/fec_mpc5200.c b/drivers/net/fec_mpc5200.c
index acad20c..41a3b58 100644
--- a/drivers/net/fec_mpc5200.c
+++ b/drivers/net/fec_mpc5200.c
@@ -622,7 +622,7 @@ static int mpc5xxx_fec_recv(struct eth_device *dev)
*/
memcpy(buff, frame->head, 14);
memcpy(buff + 14, frame->data, frame_length);
- net_receive(buff, frame_length);
+ net_receive(dev, buff, frame_length);
len = frame_length;
}
/*
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index f944c6c..3370b5c 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -413,7 +413,7 @@ static int gfar_recv(struct eth_device *edev)
/* Send the packet up if there were no errors */
if (!(priv->rxbd[priv->rxidx].status & RXBD_STATS)) {
- net_receive(NetRxPackets[priv->rxidx], length - 4);
+ net_receive(edev, NetRxPackets[priv->rxidx], length - 4);
} else {
dev_err(dev, "Got error %x\n",
(priv->rxbd[priv->rxidx].status & RXBD_STATS));
diff --git a/drivers/net/ks8851_mll.c b/drivers/net/ks8851_mll.c
index 9c0e5a7..83d1b02 100644
--- a/drivers/net/ks8851_mll.c
+++ b/drivers/net/ks8851_mll.c
@@ -693,7 +693,7 @@ static int ks8851_rx_frame(struct ks_net *ks)
if (RxStatus & RXFSHR_RXFV) {
/* Pass to upper layer */
dev_dbg(dev, "passing packet to upper layer\n\n");
- net_receive(NetRxPackets[0], RxLen);
+ net_receive(&ks->edev, NetRxPackets[0], RxLen);
return RxLen;
} else if (RxStatus & RXFSHR_ERR) {
dev_err(dev, "RxStatus error 0x%04x\n", RxStatus & RXFSHR_ERR);
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index d8523ce..12a2a3c 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -187,7 +187,7 @@ static int gem_recv(struct eth_device *edev)
status = macb->rx_ring[macb->rx_tail].ctrl;
length = MACB_BFEXT(RX_FRMLEN, status);
buffer = macb->rx_buffer + macb->rx_buffer_size * macb->rx_tail;
- net_receive(buffer, length);
+ net_receive(edev, buffer, length);
macb->rx_ring[macb->rx_tail].addr &= ~MACB_BIT(RX_USED);
barrier();
@@ -237,7 +237,7 @@ static int macb_recv(struct eth_device *edev)
buffer = (void *)NetRxPackets[0];
}
- net_receive(buffer, length);
+ net_receive(edev, buffer, length);
if (++rx_tail >= macb->rx_ring_size)
rx_tail = 0;
reclaim_rx_buffers(macb, rx_tail);
diff --git a/drivers/net/netx_eth.c b/drivers/net/netx_eth.c
index 309f4cb..96dbc7c 100644
--- a/drivers/net/netx_eth.c
+++ b/drivers/net/netx_eth.c
@@ -110,7 +110,7 @@ static int netx_eth_rx (struct eth_device *edev)
/* get data */
memcpy((void*)NetRxPackets[0], (void *)(SRAM_BASE(seg) + frameno * 1560), len);
/* pass to barebox */
- net_receive(NetRxPackets[0], len);
+ net_receive(edev, NetRxPackets[0], len);
PFIFO_REG(PFIFO_BASE(EMPTY_PTR_FIFO(xcno))) =
FIFO_PTR_SEGMENT(seg) |
diff --git a/drivers/net/orion-gbe.c b/drivers/net/orion-gbe.c
index 00f5e54..1749704 100644
--- a/drivers/net/orion-gbe.c
+++ b/drivers/net/orion-gbe.c
@@ -303,7 +303,7 @@ static int port_recv(struct eth_device *edev)
ALIGN(PKTSIZE, 8));
/* received packet is padded with two null bytes */
- net_receive(rxdesc->buf_ptr + 0x2, rxdesc->byte_cnt - 0x2);
+ net_receive(edev, rxdesc->buf_ptr + 0x2, rxdesc->byte_cnt - 0x2);
ret = 0;
recv_err:
diff --git a/drivers/net/smc91111.c b/drivers/net/smc91111.c
index ba81e24..7baa749 100644
--- a/drivers/net/smc91111.c
+++ b/drivers/net/smc91111.c
@@ -1169,7 +1169,7 @@ static int smc91c111_eth_rx(struct eth_device *edev)
if (!is_error) {
/* Pass the packet up to the protocol layers. */
- net_receive(NetRxPackets[0], packet_length);
+ net_receive(edev, NetRxPackets[0], packet_length);
return 0;
}
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index e0d78d0..9977ae3 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -478,7 +478,7 @@ static int smc911x_eth_rx(struct eth_device *edev)
dev_err(&edev->dev, "dropped bad packet. Status: 0x%08x\n",
status);
else
- net_receive(NetRxPackets[0], pktlen);
+ net_receive(edev, NetRxPackets[0], pktlen);
}
return 0;
diff --git a/drivers/net/tap.c b/drivers/net/tap.c
index 436b0e0..2458fb5 100644
--- a/drivers/net/tap.c
+++ b/drivers/net/tap.c
@@ -45,7 +45,7 @@ int tap_eth_rx (struct eth_device *edev)
length = linux_read_nonblock(priv->fd, NetRxPackets[0], PKTSIZE);
if (length > 0)
- net_receive(NetRxPackets[0], length);
+ net_receive(edev, NetRxPackets[0], length);
return 0;
}
diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c
index 2145d3f..d6ac322 100644
--- a/drivers/net/usb/asix.c
+++ b/drivers/net/usb/asix.c
@@ -431,7 +431,7 @@ static int asix_rx_fixup(struct usbnet *dev, void *buf, int len)
return 0;
}
- net_receive(buf, size);
+ net_receive(&dev->edev, buf, size);
buf += ((size + 1) & 0xfffe);
len -= ((size + 1) & 0xfffe);
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index eb8f0be..053da18 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -793,11 +793,11 @@ static int smsc95xx_rx_fixup(struct usbnet *dev, void *buf, int len)
/* last frame in this batch */
if (len == size) {
- net_receive(buf, len - 4);
+ net_receive(&dev->edev, buf, len - 4);
return 1;
}
- net_receive(packet, len - 4);
+ net_receive(&dev->edev, packet, len - 4);
}
len -= size;
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index 80b4ae7..13f58e3 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -138,7 +138,7 @@ static int usbnet_recv(struct eth_device *edev)
if (info->rx_fixup)
return info->rx_fixup(dev, rx_buf, alen);
else
- net_receive(rx_buf, alen);
+ net_receive(edev, rx_buf, alen);
}
return 0;
diff --git a/drivers/net/xgmac.c b/drivers/net/xgmac.c
index b4bfd08..cc22d0e 100644
--- a/drivers/net/xgmac.c
+++ b/drivers/net/xgmac.c
@@ -617,7 +617,7 @@ static int xgmac_recv(struct eth_device *edev)
length = desc_get_rx_frame_len(rxdesc);
- net_receive(desc_get_buf_addr(rxdesc), length);
+ net_receive(edev, desc_get_buf_addr(rxdesc), length);
/* set descriptor back to owned by XGMAC */
desc_set_rx_owner(rxdesc);
diff --git a/include/net.h b/include/net.h
index 3b800b7..a166552 100644
--- a/include/net.h
+++ b/include/net.h
@@ -413,7 +413,7 @@ struct eth_device *eth_get_byname(const char *name);
*
* Return 0 if the packet is successfully handled. Can be ignored
*/
-int net_receive(unsigned char *pkt, int len);
+int net_receive(struct eth_device *edev, unsigned char *pkt, int len);
struct net_connection {
struct ethernet *et;
diff --git a/net/net.c b/net/net.c
index 20051bc..e43a3ab 100644
--- a/net/net.c
+++ b/net/net.c
@@ -619,7 +619,7 @@ bad:
return 0;
}
-int net_receive(unsigned char *pkt, int len)
+int net_receive(struct eth_device *edev, unsigned char *pkt, int len)
{
struct ethernet *et = (struct ethernet *)pkt;
int et_protlen = ntohs(et->et_protlen);
--
2.0.0.rc0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 3/4] net: Allow to use multiple network interfaces at once
2014-05-15 6:32 [PATCH] Multi network device improvements Sascha Hauer
2014-05-15 6:32 ` [PATCH 1/4] net: ifup: Set current ethernet device when doing ifup Sascha Hauer
2014-05-15 6:32 ` [PATCH 2/4] net: Pass eth_device to net_receive Sascha Hauer
@ 2014-05-15 6:32 ` Sascha Hauer
2014-05-15 6:32 ` [PATCH 4/4] net: phy: Print ethernet device in the link information Sascha Hauer
3 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2014-05-15 6:32 UTC (permalink / raw)
To: barebox
In barebox network packets always go out at the current ethernet
device and are expected to be received from the current interface.
This has some side effects. When for example an NFS is mounted when
one interface is active and the interface is changed afterwards the
NFS packets leave the new interface, but the NFS server won't be
reachable there.
Instead of changing the whole network traffic to the current ethernet
interface we now initialize a network connection with the current
network interface, but then the connection will continue to use that
interface even when the current interface is changed.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
include/net.h | 3 ++-
net/eth.c | 58 +++++++++++++++++++++++++++++++---------------------------
net/net.c | 19 +++++++++----------
3 files changed, 42 insertions(+), 38 deletions(-)
diff --git a/include/net.h b/include/net.h
index a166552..c0f7517 100644
--- a/include/net.h
+++ b/include/net.h
@@ -68,7 +68,7 @@ struct eth_device {
int eth_register(struct eth_device* dev); /* Register network device */
void eth_unregister(struct eth_device* dev); /* Unregister network device */
-int eth_send(void *packet, int length); /* Send a packet */
+int eth_send(struct eth_device *edev, void *packet, int length); /* Send a packet */
int eth_rx(void); /* Check for received packets */
/* associate a MAC address to a ethernet device. Should be called by
@@ -419,6 +419,7 @@ struct net_connection {
struct ethernet *et;
struct iphdr *ip;
struct udphdr *udp;
+ struct eth_device *edev;
struct icmphdr *icmp;
unsigned char *packet;
struct list_head list;
diff --git a/net/eth.c b/net/eth.c
index 3ced3cd..26a5ff7 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -131,11 +131,6 @@ void of_eth_register_ethaddr(struct device_node *node, const char *ethaddr)
void eth_set_current(struct eth_device *eth)
{
- if (eth_current && eth_current->active) {
- eth_current->halt(eth_current);
- eth_current->active = 0;
- }
-
eth_current = eth;
}
@@ -178,83 +173,92 @@ int eth_complete(struct string_list *sl, char *instr)
/*
* Check for link if we haven't done so for longer.
*/
-static int eth_carrier_check(int force)
+static int eth_carrier_check(struct eth_device *edev, int force)
{
int ret;
if (!IS_ENABLED(CONFIG_PHYLIB))
return 0;
- if (!eth_current->phydev)
+ if (!edev->phydev)
return 0;
if (force)
- phy_wait_aneg_done(eth_current->phydev);
+ phy_wait_aneg_done(edev->phydev);
if (force || is_timeout(last_link_check, 5 * SECOND) ||
- !eth_current->phydev->link) {
- ret = phy_update_status(eth_current->phydev);
+ !edev->phydev->link) {
+ ret = phy_update_status(edev->phydev);
if (ret)
return ret;
last_link_check = get_time_ns();
}
- return eth_current->phydev->link ? 0 : -ENETDOWN;
+ return edev->phydev->link ? 0 : -ENETDOWN;
}
/*
* Check if we have a current ethernet device and
* eventually open it if we have to.
*/
-static int eth_check_open(void)
+static int eth_check_open(struct eth_device *edev)
{
int ret;
- if (!eth_current)
- return -ENODEV;
-
- if (eth_current->active)
+ if (edev->active)
return 0;
- ret = eth_current->open(eth_current);
+ ret = edev->open(eth_current);
if (ret)
return ret;
- eth_current->active = 1;
+ edev->active = 1;
- return eth_carrier_check(1);
+ return eth_carrier_check(edev, 1);
}
-int eth_send(void *packet, int length)
+int eth_send(struct eth_device *edev, void *packet, int length)
{
int ret;
- ret = eth_check_open();
+ ret = eth_check_open(edev);
if (ret)
return ret;
- ret = eth_carrier_check(0);
+ ret = eth_carrier_check(edev, 0);
if (ret)
return ret;
led_trigger_network(LED_TRIGGER_NET_TX);
- return eth_current->send(eth_current, packet, length);
+ return edev->send(eth_current, packet, length);
}
-int eth_rx(void)
+static int __eth_rx(struct eth_device *edev)
{
int ret;
- ret = eth_check_open();
+ ret = eth_check_open(edev);
if (ret)
return ret;
- ret = eth_carrier_check(0);
+ ret = eth_carrier_check(edev, 0);
if (ret)
return ret;
- return eth_current->recv(eth_current);
+ return edev->recv(eth_current);
+}
+
+int eth_rx(void)
+{
+ struct eth_device *edev;
+
+ list_for_each_entry(edev, &netdev_list, list) {
+ if (edev->active)
+ __eth_rx(edev);
+ }
+
+ return 0;
}
static int eth_set_ethaddr(struct param_d *param, void *priv)
diff --git a/net/net.c b/net/net.c
index e43a3ab..f54267a 100644
--- a/net/net.c
+++ b/net/net.c
@@ -241,7 +241,7 @@ static int arp_request(IPaddr_t dest, unsigned char *ether)
arp_ether = ether;
- ret = eth_send(arp_packet, ETHER_HDR_SIZE + ARP_HDR_SIZE);
+ ret = eth_send(edev, arp_packet, ETHER_HDR_SIZE + ARP_HDR_SIZE);
if (ret)
return ret;
arp_start = get_time_ns();
@@ -253,7 +253,7 @@ static int arp_request(IPaddr_t dest, unsigned char *ether)
if (is_timeout(arp_start, 3 * SECOND)) {
printf("T ");
arp_start = get_time_ns();
- ret = eth_send(arp_packet, ETHER_HDR_SIZE + ARP_HDR_SIZE);
+ ret = eth_send(edev, arp_packet, ETHER_HDR_SIZE + ARP_HDR_SIZE);
if (ret)
return ret;
retries++;
@@ -358,6 +358,7 @@ static struct net_connection *net_new(IPaddr_t dest, rx_handler_f *handler,
con = xzalloc(sizeof(*con));
con->packet = net_alloc_packet();
con->priv = ctx;
+ con->edev = edev;
memset(con->packet, 0, PKTSIZE);
con->et = (struct ethernet *)con->packet;
@@ -437,7 +438,7 @@ static int net_ip_send(struct net_connection *con, int len)
con->ip->check = 0;
con->ip->check = ~net_checksum((unsigned char *)con->ip, sizeof(struct iphdr));
- return eth_send(con->packet, ETHER_HDR_SIZE + sizeof(struct iphdr) + len);
+ return eth_send(con->edev, con->packet, ETHER_HDR_SIZE + sizeof(struct iphdr) + len);
}
int net_udp_send(struct net_connection *con, int len)
@@ -480,7 +481,7 @@ static int net_answer_arp(unsigned char *pkt, int len)
if (!packet)
return 0;
memcpy(packet, pkt, ETHER_HDR_SIZE + ARP_HDR_SIZE);
- ret = eth_send(packet, ETHER_HDR_SIZE + ARP_HDR_SIZE);
+ ret = eth_send(edev, packet, ETHER_HDR_SIZE + ARP_HDR_SIZE);
free(packet);
return ret;
@@ -497,9 +498,8 @@ static void net_bad_packet(unsigned char *pkt, int len)
#endif
}
-static int net_handle_arp(unsigned char *pkt, int len)
+static int net_handle_arp(struct eth_device *edev, unsigned char *pkt, int len)
{
- struct eth_device *edev = eth_get_current();
struct arprequest *arp;
debug("%s: got arp\n", __func__);
@@ -580,10 +580,9 @@ static int net_handle_icmp(unsigned char *pkt, int len)
return 0;
}
-static int net_handle_ip(unsigned char *pkt, int len)
+static int net_handle_ip(struct eth_device *edev, unsigned char *pkt, int len)
{
struct iphdr *ip = (struct iphdr *)(pkt + ETHER_HDR_SIZE);
- struct eth_device *edev = eth_get_current();
IPaddr_t tmp;
debug("%s\n", __func__);
@@ -634,10 +633,10 @@ int net_receive(struct eth_device *edev, unsigned char *pkt, int len)
switch (et_protlen) {
case PROT_ARP:
- ret = net_handle_arp(pkt, len);
+ ret = net_handle_arp(edev, pkt, len);
break;
case PROT_IP:
- ret = net_handle_ip(pkt, len);
+ ret = net_handle_ip(edev, pkt, len);
break;
default:
debug("%s: got unknown protocol type: %d\n", __func__, et_protlen);
--
2.0.0.rc0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 5+ messages in thread