drivers: net: Fix build errors in skeleton.c

Summary:
- This commit fixes build errors in skeleton.c
- Also, add CONFIG_NET_SKELETON to Kconfig and Make.defs

Impact:
- None

Testing:
- Build with sabre-6quad:netnsh (will be updated later)

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
This commit is contained in:
Masayuki Ishikawa 2022-10-07 08:57:38 +09:00 committed by Xiang Xiao
parent a875e13105
commit 9930ad3279
3 changed files with 53 additions and 26 deletions

View File

@ -342,6 +342,23 @@ menuconfig NET_LAN91C111
if NET_LAN91C111
endif # NET_LAN91C111
menuconfig NET_SKELETON
bool "Skeleton network support"
default n
select ARCH_HAVE_NETDEV_STATISTICS
---help---
NuttX skeleton network driver
if NET_SKELETON
config NET_SKELETON_IRQ
int "Skeleton IRQ number"
default 0
config NET_SKELETON_NINTERFACES
int "Number of physical skeleton devices"
default 1
endif
menuconfig NET_W5500
bool "WIZnet W5500 Support"
default n

View File

@ -64,6 +64,10 @@ ifeq ($(CONFIG_NET_LAN91C111),y)
CSRCS += lan91c111.c
endif
ifeq ($(CONFIG_NET_SKELETON),y)
CSRCS += skeleton.c
endif
ifeq ($(CONFIG_NET_W5500),y)
CSRCS += w5500.c
endif

View File

@ -45,7 +45,7 @@
# include <nuttx/net/pkt.h>
#endif
#ifdef CONFIG_NET_skeleton
#ifdef CONFIG_NET_SKELETON
/****************************************************************************
* Pre-processor Definitions
@ -68,12 +68,12 @@
#define ETHWORK LPWORK
/* CONFIG_SKELETON_NINTERFACES determines the number of physical interfaces
* that will be supported.
/* CONFIG_NET_SKELETON_NINTERFACES determines the number of
* physical interfaces that will be supported.
*/
#ifndef CONFIG_SKELETON_NINTERFACES
# define CONFIG_SKELETON_NINTERFACES 1
#ifndef CONFIG_NET_SKELETON_NINTERFACES
# define CONFIG_NET_SKELETON_NINTERFACES 1
#endif
/* TX timeout = 1 minute */
@ -123,16 +123,18 @@ struct skel_driver_s
* descriptors in rings to implement such a pipeline. This example assumes
* much simpler hardware that simply handles one packet at a time.
*
* NOTE that if CONFIG_SKELETON_NINTERFACES were greater than 1, you would
* need a minimum on one packet buffer per instance. Much better to be
* allocated dynamically in cases where more than one are needed.
* NOTE that if CONFIG_NET_SKELETON_NINTERFACES were greater than 1,
* you would need a minimum on one packet buffer per instance.
* Much better to be allocated dynamically in cases where more than
* one are needed.
*/
static uint16_t g_pktbuf[CONFIG_SKELETON_NINTERFACES][(PKTBUF_SIZE + 1) / 2];
static uint16_t
g_pktbuf[CONFIG_NET_SKELETON_NINTERFACES][(PKTBUF_SIZE + 1) / 2];
/* Driver state structure */
static struct skel_driver_s g_skel[CONFIG_SKELETON_NINTERFACES];
static struct skel_driver_s g_skel[CONFIG_NET_SKELETON_NINTERFACES];
/****************************************************************************
* Private Function Prototypes
@ -145,7 +147,7 @@ static int skel_txpoll(FAR struct net_driver_s *dev);
/* Interrupt handling */
static void skel_reply(struct skel_driver_s *priv)
static void skel_reply(struct skel_driver_s *priv);
static void skel_receive(FAR struct skel_driver_s *priv);
static void skel_txdone(FAR struct skel_driver_s *priv);
@ -352,7 +354,7 @@ static void skel_reply(struct skel_driver_s *priv)
else
#endif
{
neighbor_out(&skel->sk_dev);
neighbor_out(&priv->sk_dev);
}
#endif
@ -464,7 +466,7 @@ static void skel_receive(FAR struct skel_driver_s *priv)
NETDEV_RXDROPPED(&priv->sk_dev);
}
}
while (); /* While there are more packets to be processed */
while (true); /* While there are more packets to be processed */
}
/****************************************************************************
@ -486,8 +488,6 @@ static void skel_receive(FAR struct skel_driver_s *priv)
static void skel_txdone(FAR struct skel_driver_s *priv)
{
int delay;
/* Check for errors and update statistics */
NETDEV_TXDONE(priv->sk_dev);
@ -556,7 +556,7 @@ static void skel_interrupt_work(FAR void *arg)
/* Re-enable Ethernet interrupts */
up_enable_irq(CONFIG_SKELETON_IRQ);
up_enable_irq(CONFIG_NET_SKELETON_IRQ);
}
/****************************************************************************
@ -589,7 +589,7 @@ static int skel_interrupt(int irq, FAR void *context, FAR void *arg)
* condition here.
*/
up_disable_irq(CONFIG_SKELETON_IRQ);
up_disable_irq(CONFIG_NET_SKELETON_IRQ);
/* TODO: Determine if a TX transfer just completed */
@ -674,7 +674,7 @@ static void skel_txtimeout_expiry(wdparm_t arg)
* condition with interrupt work that is already queued and in progress.
*/
up_disable_irq(CONFIG_SKELETON_IRQ);
up_disable_irq(CONFIG_NET_SKELETON_IRQ);
/* Schedule to perform the TX timeout processing on the worker thread. */
@ -706,8 +706,10 @@ static int skel_ifup(FAR struct net_driver_s *dev)
#ifdef CONFIG_NET_IPv4
ninfo("Bringing up: %d.%d.%d.%d\n",
dev->d_ipaddr & 0xff, (dev->d_ipaddr >> 8) & 0xff,
(dev->d_ipaddr >> 16) & 0xff, dev->d_ipaddr >> 24);
(int)dev->d_ipaddr & 0xff,
(int)(dev->d_ipaddr >> 8) & 0xff,
(int)(dev->d_ipaddr >> 16) & 0xff,
(int)dev->d_ipaddr >> 24);
#endif
#ifdef CONFIG_NET_IPv6
ninfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
@ -729,7 +731,7 @@ static int skel_ifup(FAR struct net_driver_s *dev)
/* Enable the Ethernet interrupt */
priv->sk_bifup = true;
up_enable_irq(CONFIG_SKELETON_IRQ);
up_enable_irq(CONFIG_NET_SKELETON_IRQ);
return OK;
}
@ -759,7 +761,7 @@ static int skel_ifdown(FAR struct net_driver_s *dev)
/* Disable the Ethernet interrupt */
flags = enter_critical_section();
up_disable_irq(CONFIG_SKELETON_IRQ);
up_disable_irq(CONFIG_NET_SKELETON_IRQ);
/* Cancel the TX timeout timers */
@ -883,6 +885,7 @@ static int skel_addmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac)
/* Add the MAC address to the hardware multicast routing table */
UNUSED(priv);
return OK;
}
#endif
@ -911,6 +914,7 @@ static int skel_rmmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac)
/* Add the MAC address to the hardware multicast routing table */
UNUSED(priv);
return OK;
}
#endif
@ -951,7 +955,7 @@ static void skel_ipv6multicast(FAR struct skel_driver_s *priv)
mac[0] = 0x33;
mac[1] = 0x33;
dev = &priv->dev;
dev = &priv->sk_dev;
tmp16 = dev->d_ipv6addr[6];
mac[2] = 0xff;
mac[3] = tmp16 >> 8;
@ -1057,14 +1061,14 @@ int skel_initialize(int intf)
/* Get the interface structure associated with this interface number. */
DEBUGASSERT(intf < CONFIG_SKELETON_NINTERFACES);
DEBUGASSERT(intf < CONFIG_NET_SKELETON_NINTERFACES);
priv = &g_skel[intf];
/* Check if a Ethernet chip is recognized at its I/O base */
/* Attach the IRQ to the driver */
if (irq_attach(CONFIG_SKELETON_IRQ, skel_interrupt, priv))
if (irq_attach(CONFIG_NET_SKELETON_IRQ, skel_interrupt, priv))
{
/* We could not attach the ISR to the interrupt */
@ -1102,4 +1106,6 @@ int skel_initialize(int intf)
return OK;
}
#endif /* CONFIG_NET_skeleton */
#endif /* !defined(CONFIG_SCHED_WORKQUEUE) */
#endif /* CONFIG_NET_SKELETON */