drivers/net/: Adapt all Ethernet drivers to work as though CONFIG_NET_MULTIBUFFER were set. Remove all references to CONFIG_NET_MULTIBUFFER
This commit is contained in:
parent
00beb665f5
commit
96be43b270
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* drivers/net/cs89x0.c
|
||||
*
|
||||
* Copyright (C) 2009-2011, 2014-2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2009-2011, 2014-2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -93,9 +93,7 @@
|
||||
# define cs89x0_mapirq(irq) g_cs89x0[0]
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
#define PKTBUF_SIZE (MAX_NET_DEV_MTU + CONFIG_NET_GUARDSIZE)
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
@ -1008,6 +1006,8 @@ static int cs89x0_rmmac(struct net_driver_s *dev, FAR const uint8_t *mac)
|
||||
|
||||
int cs89x0_initialize(FAR const cs89x0_driver_s *cs89x0, int devno)
|
||||
{
|
||||
FAR uint8_t *pktbuf;
|
||||
|
||||
/* Sanity checks -- only performed with debug enabled */
|
||||
|
||||
#ifdef CONFIG_DEBUG_FEATURES
|
||||
@ -1030,9 +1030,18 @@ int cs89x0_initialize(FAR const cs89x0_driver_s *cs89x0, int devno)
|
||||
return -EAGAIN;
|
||||
}
|
||||
|
||||
/* Allocate a packet buffer */
|
||||
|
||||
pktbuf = (FAR uint_t *)kmm_alloc(MAX_NET_DEV_MTU + CONFIG_NET_GUARDSIZE);
|
||||
if (pktbuf == NULL)
|
||||
{
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
/* Initialize the driver structure */
|
||||
|
||||
g_cs89x[devno] = cs89x0; /* Used to map IRQ back to instance */
|
||||
cs89x0->cs_dev.d_buf = g_pktbuf; /* Single packet buffer */
|
||||
cs89x0->cs_dev.d_ifup = cs89x0_ifup; /* I/F down callback */
|
||||
cs89x0->cs_dev.d_ifdown = cs89x0_ifdown; /* I/F up (new IP address) callback */
|
||||
cs89x0->cs_dev.d_txavail = cs89x0_txavail; /* New TX data callback */
|
||||
@ -1056,4 +1065,3 @@ int cs89x0_initialize(FAR const cs89x0_driver_s *cs89x0, int devno)
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET && CONFIG_NET_CS89x0 */
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* drivers/net/dm9x.c
|
||||
*
|
||||
* Copyright (C) 2007-2010, 2014-2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2010, 2014-2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* References: Davicom data sheets (DM9000-DS-F03-041906.pdf,
|
||||
@ -318,6 +318,10 @@ struct dm9x_driver_s
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/* A single packet buffer is used */
|
||||
|
||||
static uint8_t g_pktbuf[MAX_NET_DEV_MTU + CONFIG_NET_GUARDSIZE];
|
||||
|
||||
/* At present, only a single DM90x0 device is supported. */
|
||||
|
||||
static struct dm9x_driver_s g_dm9x[CONFIG_DM9X_NINTERFACES];
|
||||
@ -1746,6 +1750,7 @@ int dm9x_initialize(void)
|
||||
/* Initialize the driver structure */
|
||||
|
||||
memset(g_dm9x, 0, CONFIG_DM9X_NINTERFACES*sizeof(struct dm9x_driver_s));
|
||||
g_dm9x[0].dm_dev.d_buf = g_pktbuf; /* Single packet buffer */
|
||||
g_dm9x[0].dm_dev.d_ifup = dm9x_ifup; /* I/F down callback */
|
||||
g_dm9x[0].dm_dev.d_ifdown = dm9x_ifdown; /* I/F up (new IP address) callback */
|
||||
g_dm9x[0].dm_dev.d_txavail = dm9x_txavail; /* New TX data callback */
|
||||
|
@ -6,7 +6,7 @@
|
||||
*
|
||||
* This file is a part of NuttX:
|
||||
*
|
||||
* Copyright (C) 2011, 2014 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2011, 2014, 2016 Gregory Nutt. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -83,6 +83,10 @@
|
||||
|
||||
#define E1000_TXTIMEOUT (60*CLK_TCK)
|
||||
|
||||
/* Size of one packet */
|
||||
|
||||
#define PKTBUF_SIZE (MAX_NET_DEV_MTU + CONFIG_NET_GUARDSIZE)
|
||||
|
||||
/* This is a helper pointer for accessing the contents of the Ethernet header */
|
||||
|
||||
#define BUF ((struct eth_hdr_s *)e1000->netdev.d_buf)
|
||||
@ -1087,18 +1091,26 @@ static pci_id_t e1000_id_table[] =
|
||||
|
||||
static int e1000_probe(uint16_t addr, pci_id_t id)
|
||||
{
|
||||
uint32_t mmio_base, mmio_size;
|
||||
FAR struct e1000_dev *dev;
|
||||
uint32_t mmio_base;
|
||||
uint32_t mmio_size;
|
||||
uint32_t size;
|
||||
FAR uint8_t *pktbuf
|
||||
FAR void *kmem;
|
||||
FAR void *omem;
|
||||
int errcode;
|
||||
void *kmem;
|
||||
void *omem;
|
||||
struct e1000_dev *dev;
|
||||
|
||||
/* alloc e1000_dev memory */
|
||||
/* Allocate e1000_dev memory */
|
||||
|
||||
if ((dev = kmm_zalloc(sizeof(struct e1000_dev))) == NULL)
|
||||
if ((dev = (FAR struct e1000_dev *)kmm_zalloc(sizeof(struct e1000_dev))) == NULL)
|
||||
{
|
||||
return -1;
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if ((pktbuf = (FAR uint8_t *)kmm_zalloc(PKTBUF_SIZE)) == NULL)
|
||||
{
|
||||
errcode = -ENOMEM;
|
||||
goto errout_with_dev;
|
||||
}
|
||||
|
||||
/* save pci addr */
|
||||
@ -1109,7 +1121,7 @@ static int e1000_probe(uint16_t addr, pci_id_t id)
|
||||
|
||||
if ((errcode = pci_enable_device(addr, PCI_BUS_MASTER)) < 0)
|
||||
{
|
||||
goto error;
|
||||
goto errout_with_pktbuf;
|
||||
}
|
||||
|
||||
/* get e1000 device type */
|
||||
@ -1123,12 +1135,12 @@ static int e1000_probe(uint16_t addr, pci_id_t id)
|
||||
errcode = rgmp_memmap_nocache(mmio_base, mmio_size, mmio_base);
|
||||
if (errcode)
|
||||
{
|
||||
goto error;
|
||||
goto errout_with_pktbuf;
|
||||
}
|
||||
|
||||
dev->phy_mem_base = mmio_base;
|
||||
dev->io_mem_base = mmio_base;
|
||||
dev->mem_size = mmio_size;
|
||||
dev->io_mem_base = mmio_base;
|
||||
dev->mem_size = mmio_size;
|
||||
|
||||
/* MAC address */
|
||||
|
||||
@ -1141,7 +1153,7 @@ static int e1000_probe(uint16_t addr, pci_id_t id)
|
||||
dev->int_desc.dev_id = dev;
|
||||
if ((errcode = pci_request_irq(addr, &dev->int_desc, 0)) < 0)
|
||||
{
|
||||
goto err0;
|
||||
goto errout_with_memmap;
|
||||
}
|
||||
|
||||
/* Here we alloc a big block of memory once and make it
|
||||
@ -1161,11 +1173,12 @@ static int e1000_probe(uint16_t addr, pci_id_t id)
|
||||
CONFIG_E1000_N_RX_DESC * sizeof(struct rx_desc) +
|
||||
CONFIG_E1000_N_RX_DESC * CONFIG_E1000_BUFF_SIZE;
|
||||
size = ROUNDUP(size, PGSIZE);
|
||||
|
||||
omem = kmem = memalign(PGSIZE, size);
|
||||
if (kmem == NULL)
|
||||
{
|
||||
errcode = -ENOMEM;
|
||||
goto err1;
|
||||
goto errout_with_pci;
|
||||
}
|
||||
|
||||
rgmp_memremap_nocache((uintptr_t)kmem, size);
|
||||
@ -1185,6 +1198,7 @@ static int e1000_probe(uint16_t addr, pci_id_t id)
|
||||
|
||||
/* Initialize the driver structure */
|
||||
|
||||
dev->netdev.d_buf = pktbuf; /* Single packet buffer */
|
||||
dev->netdev.d_ifup = e1000_ifup; /* I/F up (new IP address) callback */
|
||||
dev->netdev.d_ifdown = e1000_ifdown; /* I/F down callback */
|
||||
dev->netdev.d_txavail = e1000_txavail; /* New TX data callback */
|
||||
@ -1214,7 +1228,7 @@ static int e1000_probe(uint16_t addr, pci_id_t id)
|
||||
errcode = netdev_register(&dev->netdev, NET_LL_ETHERNET);
|
||||
if (errcode)
|
||||
{
|
||||
goto err2;
|
||||
goto errout_with_omem;
|
||||
}
|
||||
|
||||
/* insert into e1000_list */
|
||||
@ -1225,14 +1239,16 @@ static int e1000_probe(uint16_t addr, pci_id_t id)
|
||||
|
||||
return 0;
|
||||
|
||||
err2:
|
||||
errout_with_omem:
|
||||
rgmp_memremap((uintptr_t)omem, size);
|
||||
free(omem);
|
||||
err1:
|
||||
errout_with_pci:
|
||||
pci_free_irq(addr);
|
||||
err0:
|
||||
errout_with_memmap:
|
||||
rgmp_memunmap(mmio_base, mmio_size);
|
||||
error:
|
||||
errout_with_pktbuf:
|
||||
kmm_free(pktbuf);
|
||||
errout_with_dev:
|
||||
kmm_free(dev);
|
||||
cprintf("e1000 device probe fail: %d\n", errcode);
|
||||
return errcode;
|
||||
@ -1268,6 +1284,7 @@ void e1000_mod_exit(void)
|
||||
free(dev->tx_ring.desc);
|
||||
pci_free_irq(dev->pci_addr);
|
||||
rgmp_memunmap((uintptr_t)dev->io_mem_base, dev->mem_size);
|
||||
kmm_free(dev->netdev.d_buf);
|
||||
kmm_free(dev);
|
||||
}
|
||||
|
||||
|
@ -269,6 +269,12 @@ struct enc_driver_s
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/* A single packet buffer is used */
|
||||
|
||||
static uint8_t g_pktbuf[MAX_NET_DEV_MTU + CONFIG_NET_GUARDSIZE];
|
||||
|
||||
/* Driver status structure */
|
||||
|
||||
static struct enc_driver_s g_enc28j60[CONFIG_ENC28J60_NINTERFACES];
|
||||
|
||||
/****************************************************************************
|
||||
@ -2631,6 +2637,7 @@ int enc_initialize(FAR struct spi_dev_s *spi,
|
||||
/* Initialize the driver structure */
|
||||
|
||||
memset(g_enc28j60, 0, CONFIG_ENC28J60_NINTERFACES*sizeof(struct enc_driver_s));
|
||||
priv->dev.d_buf = g_pktbuf; /* Single packet buffer */
|
||||
priv->dev.d_ifup = enc_ifup; /* I/F down callback */
|
||||
priv->dev.d_ifdown = enc_ifdown; /* I/F up (new IP address) callback */
|
||||
priv->dev.d_txavail = enc_txavail; /* New TX data callback */
|
||||
|
@ -282,6 +282,12 @@ struct enc_driver_s
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/* A single packet buffer is used */
|
||||
|
||||
static uint8_t g_pktbuf[MAX_NET_DEV_MTU + CONFIG_NET_GUARDSIZE];
|
||||
|
||||
/* Driver status structure */
|
||||
|
||||
static struct enc_driver_s g_encx24j600[CONFIG_ENCX24J600_NINTERFACES];
|
||||
|
||||
/****************************************************************************
|
||||
@ -2866,6 +2872,7 @@ int enc_initialize(FAR struct spi_dev_s *spi,
|
||||
/* Initialize the driver structure */
|
||||
|
||||
memset(g_encx24j600, 0, CONFIG_ENCX24J600_NINTERFACES*sizeof(struct enc_driver_s));
|
||||
priv->dev.d_buf = g_pktbuf; /* Single packet buffer */
|
||||
priv->dev.d_ifup = enc_ifup; /* I/F up (new IP address) callback */
|
||||
priv->dev.d_ifdown = enc_ifdown; /* I/F down callback */
|
||||
priv->dev.d_txavail = enc_txavail; /* New TX data callback */
|
||||
|
@ -192,6 +192,12 @@ struct ftmac100_driver_s
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/* A single packet buffer is used */
|
||||
|
||||
static uint8_t g_pktbuf[MAX_NET_DEV_MTU + CONFIG_NET_GUARDSIZE];
|
||||
|
||||
/* Driver state structure. */
|
||||
|
||||
static struct ftmac100_driver_s g_ftmac100[CONFIG_FTMAC100_NINTERFACES]
|
||||
__attribute__((aligned(16)));
|
||||
|
||||
@ -1738,6 +1744,7 @@ int ftmac100_initialize(int intf)
|
||||
/* Initialize the driver structure */
|
||||
|
||||
memset(priv, 0, sizeof(struct ftmac100_driver_s));
|
||||
priv->ft_dev.d_buf = g_pktbuf; /* Single packet buffer */
|
||||
priv->ft_dev.d_ifup = ftmac100_ifup; /* I/F up (new IP address) callback */
|
||||
priv->ft_dev.d_ifdown = ftmac100_ifdown; /* I/F down callback */
|
||||
priv->ft_dev.d_txavail = ftmac100_txavail; /* New TX data callback */
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* drivers/net/loopback.c
|
||||
*
|
||||
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2015-2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -121,10 +121,7 @@ struct lo_driver_s
|
||||
****************************************************************************/
|
||||
|
||||
static struct lo_driver_s g_loopback;
|
||||
|
||||
#ifdef CONFIG_NET_MULTIBUFFER
|
||||
static uint8_t g_iobuffer[MAX_NET_DEV_MTU + CONFIG_NET_GUARDSIZE];
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
@ -555,9 +552,7 @@ int localhost_initialize(void)
|
||||
priv->lo_dev.d_addmac = lo_addmac; /* Add multicast MAC address */
|
||||
priv->lo_dev.d_rmmac = lo_rmmac; /* Remove multicast MAC address */
|
||||
#endif
|
||||
#ifdef CONFIG_NET_MULTIBUFFER
|
||||
priv->lo_dev.d_buf = g_iobuffer; /* Attach the IO buffer */
|
||||
#endif
|
||||
priv->lo_dev.d_private = (FAR void *)priv; /* Used to recover private state from dev */
|
||||
|
||||
/* Create a watchdog for timing polling for and timing of transmissions */
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* drivers/net/skeleton.c
|
||||
*
|
||||
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -133,6 +133,19 @@ struct skel_driver_s
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/* These statically allocated structur would mean that only a single
|
||||
* instance of the device could be supported. In order to support multiple
|
||||
* devices instances, this data would have to be allocated dynamically.
|
||||
*/
|
||||
|
||||
/* A single packet buffer per device is used here. There might be multiple
|
||||
* packet buffers in a more complex, pipelined design.
|
||||
*/
|
||||
|
||||
static uint8_t g_pktbuf[MAX_NET_DEV_MTU + CONFIG_NET_GUARDSIZE];
|
||||
|
||||
/* Driver state structure */
|
||||
|
||||
static struct skel_driver_s g_skel[CONFIG_skeleton_NINTERFACES];
|
||||
|
||||
/****************************************************************************
|
||||
@ -1234,6 +1247,7 @@ int skel_initialize(int intf)
|
||||
/* Initialize the driver structure */
|
||||
|
||||
memset(priv, 0, sizeof(struct skel_driver_s));
|
||||
priv->sk_dev.d_buf = g_pktbuf; /* Single packet buffer */
|
||||
priv->sk_dev.d_ifup = skel_ifup; /* I/F up (new IP address) callback */
|
||||
priv->sk_dev.d_ifdown = skel_ifdown; /* I/F down callback */
|
||||
priv->sk_dev.d_txavail = skel_txavail; /* New TX data callback */
|
||||
|
@ -80,10 +80,6 @@
|
||||
# warning "CONFIG_NET_NOINTS must be set"
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NET_MULTIBUFFER
|
||||
# warning "CONFIG_NET_MULTIBUFFER must be set"
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NET_SLIP_STACKSIZE
|
||||
# define CONFIG_NET_SLIP_STACKSIZE 2048
|
||||
#endif
|
||||
|
@ -88,7 +88,9 @@
|
||||
|
||||
/* This is a helper pointer for accessing the contents of the Ethernet header */
|
||||
|
||||
#define BUF ((struct eth_hdr_s *)vnet->sk_dev.d_buf)
|
||||
#define BUF ((struct eth_hdr_s *)vnet->vn_dev.d_buf)
|
||||
|
||||
#define PKTBUF_SIZE (MAX_NET_DEV_MTU + CONFIG_NET_GUARDSIZE)
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
@ -100,19 +102,25 @@
|
||||
|
||||
struct vnet_driver_s
|
||||
{
|
||||
bool sk_bifup; /* true:ifup false:ifdown */
|
||||
WDOG_ID sk_txpoll; /* TX poll timer */
|
||||
bool vn_bifup; /* true:ifup false:ifdown */
|
||||
WDOG_ID vn_txpoll; /* TX poll timer */
|
||||
struct rgmp_vnet *vnet;
|
||||
|
||||
/* This holds the information visible to the NuttX */
|
||||
|
||||
struct net_driver_s sk_dev; /* Interface understood by the network */
|
||||
struct net_driver_s vn_dev; /* Interface understood by the network */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/* A single packet buffer per driver is used */
|
||||
|
||||
static uint8_t g_pktbuf[PKTBUF_SIZE * CONFIG_VNET_NINTERFACES];
|
||||
|
||||
/* Driver state structure instancs */
|
||||
|
||||
static struct vnet_driver_s g_vnet[CONFIG_VNET_NINTERFACES];
|
||||
|
||||
/****************************************************************************
|
||||
@ -176,9 +184,9 @@ static int vnet_transmit(FAR struct vnet_driver_s *vnet)
|
||||
* must have assured that there is not transmission in progress.
|
||||
*/
|
||||
|
||||
/* Send the packet: address=vnet->sk_dev.d_buf, length=vnet->sk_dev.d_len */
|
||||
/* Send the packet: address=vnet->vn_dev.d_buf, length=vnet->vn_dev.d_len */
|
||||
|
||||
errcode = vnet_xmit(vnet->vnet, (char *)vnet->sk_dev.d_buf, vnet->sk_dev.d_len);
|
||||
errcode = vnet_xmit(vnet->vnet, (char *)vnet->vn_dev.d_buf, vnet->vn_dev.d_len);
|
||||
if (errcode)
|
||||
{
|
||||
/* When vnet_xmit fail, it means TX buffer is full. Watchdog
|
||||
@ -234,7 +242,7 @@ static int vnet_txpoll(struct net_driver_s *dev)
|
||||
* the field d_len is set to a value > 0.
|
||||
*/
|
||||
|
||||
if (vnet->sk_dev.d_len > 0)
|
||||
if (vnet->vn_dev.d_len > 0)
|
||||
{
|
||||
/* Look up the destination MAC address and add it to the Ethernet
|
||||
* header.
|
||||
@ -242,10 +250,10 @@ static int vnet_txpoll(struct net_driver_s *dev)
|
||||
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
if (IFF_IS_IPv4(vnet->sk_dev.d_flags))
|
||||
if (IFF_IS_IPv4(vnet->vn_dev.d_flags))
|
||||
#endif
|
||||
{
|
||||
arp_out(&vnet->sk_dev);
|
||||
arp_out(&vnet->vn_dev);
|
||||
}
|
||||
#endif /* CONFIG_NET_IPv4 */
|
||||
|
||||
@ -254,7 +262,7 @@ static int vnet_txpoll(struct net_driver_s *dev)
|
||||
else
|
||||
#endif
|
||||
{
|
||||
neighbor_out(&vnet->sk_dev);
|
||||
neighbor_out(&vnet->vn_dev);
|
||||
}
|
||||
#endif /* CONFIG_NET_IPv6 */
|
||||
|
||||
@ -314,17 +322,17 @@ void rtos_vnet_recv(struct rgmp_vnet *rgmp_vnet, char *data, int len)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Copy the data data from the hardware to vnet->sk_dev.d_buf. Set
|
||||
* amount of data in vnet->sk_dev.d_len
|
||||
/* Copy the data data from the hardware to vnet->vn_dev.d_buf. Set
|
||||
* amount of data in vnet->vn_dev.d_len
|
||||
*/
|
||||
|
||||
memcpy(vnet->sk_dev.d_buf, data, len);
|
||||
vnet->sk_dev.d_len = len;
|
||||
memcpy(vnet->vn_dev.d_buf, data, len);
|
||||
vnet->vn_dev.d_len = len;
|
||||
|
||||
#ifdef CONFIG_NET_PKT
|
||||
/* When packet sockets are enabled, feed the frame into the packet tap */
|
||||
|
||||
pkt_input(&vnet->sk_dev);
|
||||
pkt_input(&vnet->vn_dev);
|
||||
#endif
|
||||
|
||||
/* We only accept IP packets of the configured type and ARP packets */
|
||||
@ -338,27 +346,27 @@ void rtos_vnet_recv(struct rgmp_vnet *rgmp_vnet, char *data, int len)
|
||||
* layer
|
||||
*/
|
||||
|
||||
arp_ipin(&vnet->sk_dev);
|
||||
ipv4_input(&vnet->sk_dev);
|
||||
arp_ipin(&vnet->vn_dev);
|
||||
ipv4_input(&vnet->vn_dev);
|
||||
|
||||
/* If the above function invocation resulted in data that should be
|
||||
* sent out on the network, the field d_len will set to a value > 0.
|
||||
*/
|
||||
|
||||
if (vnet->sk_dev.d_len > 0)
|
||||
if (vnet->vn_dev.d_len > 0)
|
||||
{
|
||||
/* Update the Ethernet header with the correct MAC address */
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
if (IFF_IS_IPv4(vnet->sk_dev.d_flags))
|
||||
if (IFF_IS_IPv4(vnet->vn_dev.d_flags))
|
||||
#endif
|
||||
{
|
||||
arp_out(&vnet->sk_dev);
|
||||
arp_out(&vnet->vn_dev);
|
||||
}
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
else
|
||||
{
|
||||
neighbor_out(&vnet->sk_dev);
|
||||
neighbor_out(&vnet->vn_dev);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -376,26 +384,26 @@ void rtos_vnet_recv(struct rgmp_vnet *rgmp_vnet, char *data, int len)
|
||||
|
||||
/* Give the IPv6 packet to the network layer */
|
||||
|
||||
ipv6_input(&vnet->sk_dev);
|
||||
ipv6_input(&vnet->vn_dev);
|
||||
|
||||
/* If the above function invocation resulted in data that should be
|
||||
* sent out on the network, the field d_len will set to a value > 0.
|
||||
*/
|
||||
|
||||
if (vnet->sk_dev.d_len > 0)
|
||||
if (vnet->vn_dev.d_len > 0)
|
||||
{
|
||||
/* Update the Ethernet header with the correct MAC address */
|
||||
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
if (IFF_IS_IPv4(vnet->sk_dev.d_flags))
|
||||
if (IFF_IS_IPv4(vnet->vn_dev.d_flags))
|
||||
{
|
||||
arp_out(&vnet->sk_dev);
|
||||
arp_out(&vnet->vn_dev);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
{
|
||||
neighbor_out(&vnet->sk_dev);
|
||||
neighbor_out(&vnet->vn_dev);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -409,14 +417,14 @@ void rtos_vnet_recv(struct rgmp_vnet *rgmp_vnet, char *data, int len)
|
||||
#ifdef CONFIG_NET_ARP
|
||||
if (BUF->type == htons(ETHTYPE_ARP))
|
||||
{
|
||||
arp_arpin(&vnet->sk_dev);
|
||||
arp_arpin(&vnet->vn_dev);
|
||||
|
||||
/* If the above function invocation resulted in data that should
|
||||
* be sent out on the network, the field d_len will set to a
|
||||
* value > 0.
|
||||
*/
|
||||
|
||||
if (vnet->sk_dev.d_len > 0)
|
||||
if (vnet->vn_dev.d_len > 0)
|
||||
{
|
||||
vnet_transmit(vnet);
|
||||
}
|
||||
@ -447,7 +455,7 @@ static void vnet_txdone(FAR struct vnet_driver_s *vnet)
|
||||
{
|
||||
/* Poll the network for new XMIT data */
|
||||
|
||||
(void)devif_poll(&vnet->sk_dev, vnet_txpoll);
|
||||
(void)devif_poll(&vnet->vn_dev, vnet_txpoll);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -475,7 +483,7 @@ static void vnet_txtimeout(int argc, uint32_t arg, ...)
|
||||
|
||||
/* Poll the network for new XMIT data */
|
||||
|
||||
(void)devif_poll(&vnet->sk_dev, vnet_txpoll);
|
||||
(void)devif_poll(&vnet->vn_dev, vnet_txpoll);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -517,11 +525,11 @@ static void vnet_polltimer(int argc, uint32_t arg, ...)
|
||||
* progress, we will missing TCP time state updates?
|
||||
*/
|
||||
|
||||
(void)devif_timer(&vnet->sk_dev, vnet_txpoll);
|
||||
(void)devif_timer(&vnet->vn_dev, vnet_txpoll);
|
||||
|
||||
/* Setup the watchdog poll timer again */
|
||||
|
||||
(void)wd_start(vnet->sk_txpoll, VNET_WDDELAY, vnet_polltimer, 1,
|
||||
(void)wd_start(vnet->vn_txpoll, VNET_WDDELAY, vnet_polltimer, 1,
|
||||
(wdparm_t)arg);
|
||||
}
|
||||
|
||||
@ -554,10 +562,10 @@ static int vnet_ifup(struct net_driver_s *dev)
|
||||
|
||||
/* Set and activate a timer process */
|
||||
|
||||
(void)wd_start(vnet->sk_txpoll, VNET_WDDELAY, vnet_polltimer, 1,
|
||||
(void)wd_start(vnet->vn_txpoll, VNET_WDDELAY, vnet_polltimer, 1,
|
||||
(wdparm_t)vnet);
|
||||
|
||||
vnet->sk_bifup = true;
|
||||
vnet->vn_bifup = true;
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -588,7 +596,7 @@ static int vnet_ifdown(struct net_driver_s *dev)
|
||||
|
||||
/* Cancel the TX poll timer and TX timeout timers */
|
||||
|
||||
wd_cancel(vnet->sk_txpoll);
|
||||
wd_cancel(vnet->vn_txpoll);
|
||||
|
||||
/* Put the EMAC is its reset, non-operational state. This should be
|
||||
* a known configuration that will guarantee the vnet_ifup() always
|
||||
@ -597,7 +605,7 @@ static int vnet_ifdown(struct net_driver_s *dev)
|
||||
|
||||
/* Mark the device "down" */
|
||||
|
||||
vnet->sk_bifup = false;
|
||||
vnet->vn_bifup = false;
|
||||
leave_critical_section(flags);
|
||||
return OK;
|
||||
}
|
||||
@ -634,7 +642,7 @@ static int vnet_txavail(struct net_driver_s *dev)
|
||||
|
||||
/* Ignore the notification if the interface is not yet up */
|
||||
|
||||
if (vnet->sk_bifup)
|
||||
if (vnet->vn_bifup)
|
||||
{
|
||||
/* Check if there is room in the hardware to hold another outgoing packet. */
|
||||
|
||||
@ -648,7 +656,7 @@ static int vnet_txavail(struct net_driver_s *dev)
|
||||
|
||||
/* If so, then poll the network for new XMIT data */
|
||||
|
||||
(void)devif_poll(&vnet->sk_dev, vnet_txpoll);
|
||||
(void)devif_poll(&vnet->vn_dev, vnet_txpoll);
|
||||
}
|
||||
|
||||
out:
|
||||
@ -735,9 +743,10 @@ static int vnet_rmmac(struct net_driver_s *dev, FAR const uint8_t *mac)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int vnet_init(struct rgmp_vnet *vnet)
|
||||
int vnet_init(FAR struct rgmp_vnet *vnet)
|
||||
{
|
||||
struct vnet_driver_s *priv;
|
||||
FAR struct vnet_driver_s *priv;
|
||||
FAR uint8_t *pktbuf;
|
||||
static int i = 0;
|
||||
|
||||
if (i >= CONFIG_VNET_NINTERFACES)
|
||||
@ -745,30 +754,34 @@ int vnet_init(struct rgmp_vnet *vnet)
|
||||
return -1;
|
||||
}
|
||||
|
||||
priv = &g_vnet[i++];
|
||||
/* Get the packet buffer associated with this instance */
|
||||
|
||||
pktbuf = &g_pktbuf[PKTBUF_SIZE * i];
|
||||
priv = &g_vnet[i++];
|
||||
|
||||
/* Initialize the driver structure */
|
||||
|
||||
memset(priv, 0, sizeof(struct vnet_driver_s));
|
||||
priv->sk_dev.d_ifup = vnet_ifup; /* I/F down callback */
|
||||
priv->sk_dev.d_ifdown = vnet_ifdown; /* I/F up (new IP address) callback */
|
||||
priv->sk_dev.d_txavail = vnet_txavail; /* New TX data callback */
|
||||
priv->vn_dev.d_buf = pktbuf; /* Single packet buffer */
|
||||
priv->vn_dev.d_ifup = vnet_ifup; /* I/F down callback */
|
||||
priv->vn_dev.d_ifdown = vnet_ifdown; /* I/F up (new IP address) callback */
|
||||
priv->vn_dev.d_txavail = vnet_txavail; /* New TX data callback */
|
||||
#ifdef CONFIG_NET_IGMP
|
||||
priv->sk_dev.d_addmac = vnet_addmac; /* Add multicast MAC address */
|
||||
priv->sk_dev.d_rmmac = vnet_rmmac; /* Remove multicast MAC address */
|
||||
priv->vn_dev.d_addmac = vnet_addmac; /* Add multicast MAC address */
|
||||
priv->vn_dev.d_rmmac = vnet_rmmac; /* Remove multicast MAC address */
|
||||
#endif
|
||||
priv->sk_dev.d_private = (FAR void *)priv; /* Used to recover private state from dev */
|
||||
priv->vn_dev.d_private = (FAR void *)priv; /* Used to recover private state from dev */
|
||||
|
||||
/* Create a watchdog for timing polling for and timing of transmisstions */
|
||||
|
||||
priv->sk_txpoll = wd_create(); /* Create periodic poll timer */
|
||||
priv->vn_txpoll = wd_create(); /* Create periodic poll timer */
|
||||
|
||||
priv->vnet = vnet;
|
||||
vnet->priv = priv;
|
||||
|
||||
/* Register the device with the OS */
|
||||
|
||||
(void)netdev_register(&priv->sk_dev), NET_LL_ETHERNET;
|
||||
(void)netdev_register(&priv->vn_dev), NET_LL_ETHERNET;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user