mirror of
https://github.com/apache/nuttx.git
synced 2026-05-21 04:52:02 +08:00
Use small lock to protect resources related to ethernet.
Build Documentation / build-html (push) Has been cancelled
Build Documentation / build-html (push) Has been cancelled
Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
This commit is contained in:
@@ -40,7 +40,7 @@
|
||||
#include <net/ethernet.h>
|
||||
|
||||
#include <nuttx/wdog.h>
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/spinlock.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/wqueue.h>
|
||||
#include <nuttx/net/ip.h>
|
||||
@@ -299,6 +299,7 @@ struct c5471_driver_s
|
||||
struct wdog_s c_txtimeout; /* TX timeout timer */
|
||||
struct work_s c_irqwork; /* For deferring interrupt work to the work queue */
|
||||
struct work_s c_pollwork; /* For deferring poll work to the work queue */
|
||||
spinlock_t c_lock; /* Spinlock */
|
||||
|
||||
/* Note: According to the C547x documentation: "The software has to
|
||||
* maintain two pointers to the current RX-CPU and TX-CPU descriptors.
|
||||
@@ -1786,7 +1787,7 @@ static int c5471_ifdown(struct net_driver_s *dev)
|
||||
|
||||
/* Disable the Ethernet interrupt */
|
||||
|
||||
flags = enter_critical_section();
|
||||
flags = spin_lock_irqsave(&priv->c_lock);
|
||||
up_disable_irq(C5471_IRQ_ETHER);
|
||||
|
||||
/* Disable interrupts going from EIM Module to Interrupt Module. */
|
||||
@@ -1809,7 +1810,7 @@ static int c5471_ifdown(struct net_driver_s *dev)
|
||||
/* Reset the device */
|
||||
|
||||
priv->c_bifup = false;
|
||||
leave_critical_section(flags);
|
||||
spin_unlock_irqrestore(&priv->c_lock, flags);
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -2335,6 +2336,8 @@ void arm_netinitialize(void)
|
||||
#endif
|
||||
g_c5471[0].c_dev.d_private = g_c5471; /* Used to recover private state from dev */
|
||||
|
||||
spin_lock_init(&g_c5471[0].c_lock); /* Initialize spinlock */
|
||||
|
||||
/* Register the device with the OS so that socket IOCTLs can be performed */
|
||||
|
||||
netdev_register(&g_c5471[0].c_dev, NET_LL_ETHERNET);
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <nuttx/wdog.h>
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/spinlock.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/wqueue.h>
|
||||
#include <nuttx/signal.h>
|
||||
@@ -298,6 +298,7 @@ struct lpc17_40_driver_s
|
||||
struct work_s lp_rxwork; /* RX work continuation */
|
||||
struct work_s lp_pollwork; /* Poll work continuation */
|
||||
uint32_t status;
|
||||
spinlock_t lp_lock; /* Spinlock */
|
||||
|
||||
/* This holds the information visible to the NuttX networking layer */
|
||||
|
||||
@@ -424,6 +425,7 @@ static inline void lpc17_40_txdescinit(struct lpc17_40_driver_s *priv);
|
||||
static inline void lpc17_40_rxdescinit(struct lpc17_40_driver_s *priv);
|
||||
static inline void lpc17_40_macmode(uint8_t mode);
|
||||
static void lpc17_40_ethreset(struct lpc17_40_driver_s *priv);
|
||||
static void lpc17_40_ethreset_nolock(struct lpc17_40_driver_s *priv);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
@@ -1003,14 +1005,14 @@ static void lpc17_40_rxdone_work(void *arg)
|
||||
* lp-txpending TX underrun state is in effect.
|
||||
*/
|
||||
|
||||
flags = enter_critical_section();
|
||||
flags = spin_lock_irqsave(&priv->lp_lock);
|
||||
if (!priv->lp_txpending)
|
||||
{
|
||||
priv->lp_inten |= ETH_RXINTS;
|
||||
lpc17_40_putreg(priv->lp_inten, LPC17_40_ETH_INTEN);
|
||||
}
|
||||
|
||||
leave_critical_section(flags);
|
||||
spin_unlock_irqrestore(&priv->lp_lock, flags);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -1534,7 +1536,7 @@ static int lpc17_40_ifdown(struct net_driver_s *dev)
|
||||
|
||||
/* Disable the Ethernet interrupt */
|
||||
|
||||
flags = enter_critical_section();
|
||||
flags = spin_lock_irqsave(&priv->lp_lock);
|
||||
up_disable_irq(LPC17_40_IRQ_ETH);
|
||||
|
||||
/* Cancel the TX timeout timers */
|
||||
@@ -1543,9 +1545,9 @@ static int lpc17_40_ifdown(struct net_driver_s *dev)
|
||||
|
||||
/* Reset the device and mark it as down. */
|
||||
|
||||
lpc17_40_ethreset(priv);
|
||||
lpc17_40_ethreset_nolock(priv);
|
||||
priv->lp_ifup = false;
|
||||
leave_critical_section(flags);
|
||||
spin_unlock_irqrestore(&priv->lp_lock, flags);
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -2909,14 +2911,8 @@ static inline void lpc17_40_macmode(uint8_t mode)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void lpc17_40_ethreset(struct lpc17_40_driver_s *priv)
|
||||
static void lpc17_40_ethreset_nolock(struct lpc17_40_driver_s *priv)
|
||||
{
|
||||
irqstate_t flags;
|
||||
|
||||
/* Reset the MAC */
|
||||
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Put the MAC into the reset state */
|
||||
|
||||
lpc17_40_putreg((ETH_MAC1_TXRST | ETH_MAC1_MCSTXRST | ETH_MAC1_RXRST |
|
||||
@@ -2965,7 +2961,15 @@ static void lpc17_40_ethreset(struct lpc17_40_driver_s *priv)
|
||||
/* Clear any pending interrupts (shouldn't be any) */
|
||||
|
||||
lpc17_40_putreg(0xffffffff, LPC17_40_ETH_INTCLR);
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
static void lpc17_40_ethreset(struct lpc17_40_driver_s *priv)
|
||||
{
|
||||
irqstate_t flags;
|
||||
|
||||
flags = spin_lock_irqsave(&priv->lp_lock);
|
||||
lpc17_40_ethreset_nolock(priv);
|
||||
spin_unlock_irqrestore(&priv->lp_lock, flags);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -3033,6 +3037,8 @@ static inline int lpc17_40_ethinitialize(int intf)
|
||||
#endif
|
||||
priv->lp_dev.d_private = priv; /* Used to recover private state from dev */
|
||||
|
||||
spin_lock_init(&priv->lp_lock); /* Initialize spinlock */
|
||||
|
||||
#if CONFIG_LPC17_40_NINTERFACES > 1
|
||||
# error "A mechanism to associate base address an IRQ with an interface is needed"
|
||||
priv->lp_base = ??; /* Ethernet controller base address */
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/spinlock.h>
|
||||
#include <nuttx/queue.h>
|
||||
#include <nuttx/wdog.h>
|
||||
#include <nuttx/wqueue.h>
|
||||
@@ -512,6 +512,7 @@ struct lpc43_ethmac_s
|
||||
struct wdog_s txtimeout; /* TX timeout timer */
|
||||
struct work_s irqwork; /* For deferring work to the work queue */
|
||||
struct work_s pollwork; /* For deferring work to the work queue */
|
||||
spinlock_t lock; /* Spinlock */
|
||||
|
||||
/* This holds the information visible to the NuttX network */
|
||||
|
||||
@@ -2126,7 +2127,7 @@ static int lpc43_ifdown(struct net_driver_s *dev)
|
||||
|
||||
/* Disable the Ethernet interrupt */
|
||||
|
||||
flags = enter_critical_section();
|
||||
flags = spin_lock_irqsave(&priv->lock);
|
||||
up_disable_irq(LPC43M4_IRQ_ETHERNET);
|
||||
|
||||
/* Cancel the TX timeout timers */
|
||||
@@ -2143,7 +2144,7 @@ static int lpc43_ifdown(struct net_driver_s *dev)
|
||||
/* Mark the device "down" */
|
||||
|
||||
priv->ifup = false;
|
||||
leave_critical_section(flags);
|
||||
spin_unlock_irqrestore(&priv->lock, flags);
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -3607,6 +3608,8 @@ static inline int lpc43_ethinitialize(void)
|
||||
#endif
|
||||
priv->dev.d_private = &g_lpc43ethmac; /* Used to recover private state from dev */
|
||||
|
||||
spin_lock_init(&priv->lock); /* Initialize spinlock */
|
||||
|
||||
/* Configure GPIO pins to support Ethernet */
|
||||
|
||||
lpc43_ethgpioconfig(priv);
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/spinlock.h>
|
||||
#include <nuttx/queue.h>
|
||||
#include <nuttx/wdog.h>
|
||||
#include <nuttx/wqueue.h>
|
||||
@@ -297,6 +297,7 @@ struct lpc54_ethdriver_s
|
||||
struct work_s eth_pollwork; /* For deferring poll work to the work queue */
|
||||
struct work_s eth_timeoutwork; /* For deferring timeout work to the work queue */
|
||||
struct sq_queue_s eth_freebuf; /* Free packet buffers */
|
||||
spinlock_t lock; /* Spinlock */
|
||||
|
||||
/* Ring state */
|
||||
|
||||
@@ -1450,7 +1451,7 @@ static void lpc54_eth_interrupt_work(void *arg)
|
||||
lpc54_eth_channel_work(priv, 1);
|
||||
}
|
||||
|
||||
/* Un-lock the network and re-enable Ethernet interrupts */
|
||||
/* Un-eth_lock the network and re-enable Ethernet interrupts */
|
||||
|
||||
net_unlock();
|
||||
up_enable_irq(LPC54_IRQ_ETHERNET);
|
||||
@@ -2001,7 +2002,7 @@ static int lpc54_eth_ifdown(struct net_driver_s *dev)
|
||||
|
||||
/* Disable the Ethernet interrupt */
|
||||
|
||||
flags = enter_critical_section();
|
||||
flags = spin_lock_irqsave(&priv->eth_lock);
|
||||
up_disable_irq(LPC54_IRQ_ETHERNET);
|
||||
|
||||
/* Cancel the TX timeout timers */
|
||||
@@ -2040,14 +2041,14 @@ static int lpc54_eth_ifdown(struct net_driver_s *dev)
|
||||
if (ret < 0)
|
||||
{
|
||||
nerr("ERROR: lpc54_phy_reset failed: %d\n", ret);
|
||||
leave_critical_section(flags);
|
||||
spin_unlock_irqrestore(&priv->eth_lock, flags);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Mark the device "down" */
|
||||
|
||||
priv->eth_bifup = 0;
|
||||
leave_critical_section(flags);
|
||||
spin_unlock_irqrestore(&priv->eth_lock, flags);
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -2881,6 +2882,8 @@ void arm_netinitialize(void)
|
||||
#endif
|
||||
priv->eth_dev.d_private = &g_ethdriver; /* Used to recover private state from dev */
|
||||
|
||||
spin_lock_init(&priv->eth_lock); /* Initialize spinlock */
|
||||
|
||||
/* Configure GPIO pins to support Ethernet */
|
||||
|
||||
/* Common MIIM interface */
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/spinlock.h>
|
||||
#include <nuttx/queue.h>
|
||||
#include <nuttx/wdog.h>
|
||||
#include <nuttx/wqueue.h>
|
||||
@@ -614,6 +614,7 @@ struct stm32_ethmac_s
|
||||
struct wdog_s txtimeout; /* TX timeout timer */
|
||||
struct work_s irqwork; /* For deferring interrupt work to the work queue */
|
||||
struct work_s pollwork; /* For deferring poll work to the work queue */
|
||||
spinlock_t lock; /* Spinlock */
|
||||
|
||||
/* This holds the information visible to the NuttX network */
|
||||
|
||||
@@ -2359,7 +2360,7 @@ static int stm32_ifdown(struct net_driver_s *dev)
|
||||
|
||||
/* Disable the Ethernet interrupt */
|
||||
|
||||
flags = enter_critical_section();
|
||||
flags = spin_lock_irqsave(&priv->lock);
|
||||
up_disable_irq(STM32_IRQ_ETH);
|
||||
|
||||
/* Cancel the TX timeout timers */
|
||||
@@ -2376,7 +2377,7 @@ static int stm32_ifdown(struct net_driver_s *dev)
|
||||
/* Mark the device "down" */
|
||||
|
||||
priv->ifup = false;
|
||||
leave_critical_section(flags);
|
||||
spin_unlock_irqrestore(&priv->lock, flags);
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -3931,6 +3932,8 @@ int stm32_ethinitialize(int intf)
|
||||
priv->dev.d_private = g_stm32ethmac; /* Used to recover private state from dev */
|
||||
priv->intf = intf; /* Remember the interface number */
|
||||
|
||||
spin_lock_init(&priv->lock); /* Initialize spinlock */
|
||||
|
||||
stm32_get_uniqueid(uid);
|
||||
crc = crc64(uid, 12);
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/spinlock.h>
|
||||
#include <nuttx/queue.h>
|
||||
#include <nuttx/wdog.h>
|
||||
#include <nuttx/wqueue.h>
|
||||
@@ -613,6 +613,7 @@ struct stm32_ethmac_s
|
||||
struct wdog_s txtimeout; /* TX timeout timer */
|
||||
struct work_s irqwork; /* For deferring interrupt work to the work queue */
|
||||
struct work_s pollwork; /* For deferring poll work to the work queue */
|
||||
spinlock_t lock; /* Spinlock */
|
||||
|
||||
/* This holds the information visible to the NuttX network */
|
||||
|
||||
@@ -2472,7 +2473,7 @@ static int stm32_ifdown(struct net_driver_s *dev)
|
||||
|
||||
/* Disable the Ethernet interrupt */
|
||||
|
||||
flags = enter_critical_section();
|
||||
flags = spin_lock_irqsave(&priv->lock);
|
||||
up_disable_irq(STM32_IRQ_ETH);
|
||||
|
||||
/* Cancel the TX timeout timers */
|
||||
@@ -2489,7 +2490,7 @@ static int stm32_ifdown(struct net_driver_s *dev)
|
||||
/* Mark the device "down" */
|
||||
|
||||
priv->ifup = false;
|
||||
leave_critical_section(flags);
|
||||
spin_unlock_irqrestore(&priv->lock, flags);
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -4192,6 +4193,8 @@ static inline int stm32_ethinitialize(int intf)
|
||||
priv->dev.d_private = g_stm32ethmac; /* Used to recover private state */
|
||||
priv->intf = intf; /* Remember the interface number */
|
||||
|
||||
spin_lock_init(&priv->lock); /* Initialize spinlock */
|
||||
|
||||
stm32_get_uniqueid(uid);
|
||||
crc = crc64(uid, 12);
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/spinlock.h>
|
||||
#include <nuttx/queue.h>
|
||||
#include <nuttx/wdog.h>
|
||||
#include <nuttx/wqueue.h>
|
||||
@@ -614,6 +614,7 @@ struct stm32_ethmac_s
|
||||
struct wdog_s txtimeout; /* TX timeout timer */
|
||||
struct work_s irqwork; /* For deferring interrupt work to the work queue */
|
||||
struct work_s pollwork; /* For deferring poll work to the work queue */
|
||||
spinlock_t lock; /* Spinlock */
|
||||
|
||||
/* This holds the information visible to the NuttX network */
|
||||
|
||||
@@ -2473,7 +2474,7 @@ static int stm32_ifdown(struct net_driver_s *dev)
|
||||
|
||||
/* Disable the Ethernet interrupt */
|
||||
|
||||
flags = enter_critical_section();
|
||||
flags = spin_lock_irqsave(&priv->lock);
|
||||
up_disable_irq(STM32_IRQ_ETH);
|
||||
|
||||
/* Cancel the TX timeout timers */
|
||||
@@ -2490,7 +2491,7 @@ static int stm32_ifdown(struct net_driver_s *dev)
|
||||
/* Mark the device "down" */
|
||||
|
||||
priv->ifup = false;
|
||||
leave_critical_section(flags);
|
||||
spin_unlock_irqrestore(&priv->lock, flags);
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -4191,6 +4192,8 @@ static inline int stm32_ethinitialize(int intf)
|
||||
priv->dev.d_private = g_stm32ethmac; /* Used to recover private state */
|
||||
priv->intf = intf; /* Remember the interface number */
|
||||
|
||||
spin_lock_init(&priv->lock); /* Initialize spinlock */
|
||||
|
||||
stm32_get_uniqueid(uid);
|
||||
crc = crc64(uid, 12);
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/wdog.h>
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/spinlock.h>
|
||||
#include <nuttx/wqueue.h>
|
||||
#include <nuttx/net/ip.h>
|
||||
#include <nuttx/net/netdev.h>
|
||||
@@ -191,6 +191,7 @@ struct tiva_driver_s
|
||||
struct wdog_s ld_txtimeout; /* TX timeout timer */
|
||||
struct work_s ld_irqwork; /* For deferring interrupt work to the work queue */
|
||||
struct work_s ld_pollwork; /* For deferring poll work to the work queue */
|
||||
spinlock_t ld_lock; /* Spinlock */
|
||||
|
||||
/* This holds the information visible to the NuttX network */
|
||||
|
||||
@@ -353,7 +354,7 @@ static void tiva_ethreset(struct tiva_driver_s *priv)
|
||||
|
||||
/* Make sure that clocking is enabled for the Ethernet&PHY peripherals */
|
||||
|
||||
flags = enter_critical_section();
|
||||
flags = spin_lock_irqsave(&priv->ld_lock);
|
||||
regval = getreg32(TIVA_SYSCON_RCGC2);
|
||||
regval |= (SYSCON_RCGC2_EMAC0 | SYSCON_RCGC2_EPHY0);
|
||||
putreg32(regval, TIVA_SYSCON_RCGC2);
|
||||
@@ -400,7 +401,7 @@ static void tiva_ethreset(struct tiva_driver_s *priv)
|
||||
|
||||
regval = tiva_ethin(priv, TIVA_MAC_RIS_OFFSET);
|
||||
tiva_ethout(priv, TIVA_MAC_IACK_OFFSET, regval);
|
||||
leave_critical_section(flags);
|
||||
spin_unlock_irqrestore(&priv->ld_lock, flags);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -510,7 +511,7 @@ static int tiva_transmit(struct tiva_driver_s *priv)
|
||||
|
||||
/* Verify that the hardware is ready to send another packet */
|
||||
|
||||
flags = enter_critical_section();
|
||||
flags = spin_lock_irqsave(&priv->ld_lock);
|
||||
if ((tiva_ethin(priv, TIVA_MAC_TR_OFFSET) & MAC_TR_NEWTX) == 0)
|
||||
{
|
||||
/* Increment statistics */
|
||||
@@ -582,7 +583,7 @@ static int tiva_transmit(struct tiva_driver_s *priv)
|
||||
ret = OK;
|
||||
}
|
||||
|
||||
leave_critical_section(flags);
|
||||
spin_unlock_irqrestore(&priv->ld_lock, flags);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1140,7 +1141,7 @@ static int tiva_ifup(struct net_driver_s *dev)
|
||||
|
||||
/* Enable and reset the Ethernet controller */
|
||||
|
||||
flags = enter_critical_section();
|
||||
flags = spin_lock_irqsave(&priv->ld_lock);
|
||||
tiva_ethreset(priv);
|
||||
|
||||
/* Set the management clock divider register for access to the PHY
|
||||
@@ -1259,7 +1260,7 @@ static int tiva_ifup(struct net_driver_s *dev)
|
||||
tiva_ethout(priv, TIVA_MAC_IA1_OFFSET, regval);
|
||||
|
||||
priv->ld_bifup = true;
|
||||
leave_critical_section(flags);
|
||||
spin_unlock_irqrestore(&priv->ld_lock, flags);
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -1292,7 +1293,7 @@ static int tiva_ifdown(struct net_driver_s *dev)
|
||||
|
||||
/* Cancel the TX timeout timers */
|
||||
|
||||
flags = enter_critical_section();
|
||||
flags = spin_lock_irqsave(&priv->ld_lock);
|
||||
wd_cancel(&priv->ld_txtimeout);
|
||||
|
||||
/* Disable the Ethernet interrupt */
|
||||
@@ -1341,7 +1342,7 @@ static int tiva_ifdown(struct net_driver_s *dev)
|
||||
/* The interface is now DOWN */
|
||||
|
||||
priv->ld_bifup = false;
|
||||
leave_critical_section(flags);
|
||||
spin_unlock_irqrestore(&priv->ld_lock, flags);
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -1547,6 +1548,8 @@ static inline int tiva_ethinitialize(int intf)
|
||||
priv->ld_irq = ??; /* Ethernet controller IRQ number */
|
||||
#endif
|
||||
|
||||
spin_lock_init(&priv->ld_lock); /* Initialize spinlock */
|
||||
|
||||
#ifdef CONFIG_TIVA_BOARDMAC
|
||||
/* If the board can provide us with a MAC address, get the address
|
||||
* from the board now. The MAC will not be applied until tiva_ifup()
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/spinlock.h>
|
||||
#include <nuttx/wdog.h>
|
||||
#include <nuttx/net/ip.h>
|
||||
#include <nuttx/net/netdev.h>
|
||||
@@ -79,6 +79,7 @@ struct emac_driver_s
|
||||
{
|
||||
bool d_bifup; /* true:ifup false:ifdown */
|
||||
struct wdog_s d_txtimeout; /* TX timeout timer */
|
||||
spinlock_t d_lock; /* Spinlock */
|
||||
|
||||
/* This holds the information visible to the NuttX network */
|
||||
|
||||
@@ -475,7 +476,7 @@ static int emac_ifdown(struct net_driver_s *dev)
|
||||
|
||||
/* Disable the Ethernet interrupt */
|
||||
|
||||
flags = enter_critical_section();
|
||||
flags = spin_lock_irqsave(&priv->d_lock);
|
||||
up_disable_irq(CONFIG_HCS12_IRQ);
|
||||
|
||||
/* Cancel the TX timeout timers */
|
||||
@@ -490,7 +491,7 @@ static int emac_ifdown(struct net_driver_s *dev)
|
||||
/* Mark the device "down" */
|
||||
|
||||
priv->d_bifup = false;
|
||||
leave_critical_section(flags);
|
||||
spin_unlock_irqrestore(&priv->d_lock, flags);
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -523,7 +524,7 @@ static int emac_txavail(struct net_driver_s *dev)
|
||||
* level processing.
|
||||
*/
|
||||
|
||||
flags = enter_critical_section();
|
||||
flags = spin_lock_irqsave(&priv->d_lock);
|
||||
|
||||
/* Ignore the notification if the interface is not yet up */
|
||||
|
||||
@@ -536,7 +537,7 @@ static int emac_txavail(struct net_driver_s *dev)
|
||||
devif_poll(&priv->d_dev, emac_txpoll);
|
||||
}
|
||||
|
||||
leave_critical_section(flags);
|
||||
spin_unlock_irqrestore(&priv->d_lock, flags);
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -654,6 +655,8 @@ int emac_initialize(int intf)
|
||||
#endif
|
||||
priv->d_dev.d_private = priv; /* Used to recover private state from dev */
|
||||
|
||||
spin_lock_init(&priv->d_lock); /* Initialize spinlock */
|
||||
|
||||
/* Put the interface in the down state. This usually amounts to resetting
|
||||
* the device and/or calling emac_ifdown().
|
||||
*/
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/spinlock.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/wdog.h>
|
||||
#include <nuttx/wqueue.h>
|
||||
@@ -304,6 +304,7 @@ struct pic32mx_driver_s
|
||||
struct wdog_s pd_txtimeout; /* TX timeout timer */
|
||||
struct work_s pd_irqwork; /* For deferring interrupt work to the work queue */
|
||||
struct work_s pd_pollwork; /* For deferring poll work to the work queue */
|
||||
spinlock_t pd_lock; /* Spinlock */
|
||||
|
||||
sq_queue_t pd_freebuffers; /* The free buffer list */
|
||||
|
||||
@@ -2217,7 +2218,7 @@ static int pic32mx_ifdown(struct net_driver_s *dev)
|
||||
|
||||
/* Disable the Ethernet interrupt */
|
||||
|
||||
flags = enter_critical_section();
|
||||
flags = spin_lock_irqsave(&priv->pd_lock);
|
||||
#if CONFIG_PIC32MX_NINTERFACES > 1
|
||||
up_disable_irq(priv->pd_irqsrc);
|
||||
#else
|
||||
@@ -2232,7 +2233,7 @@ static int pic32mx_ifdown(struct net_driver_s *dev)
|
||||
|
||||
pic32mx_ethreset(priv);
|
||||
priv->pd_ifup = false;
|
||||
leave_critical_section(flags);
|
||||
spin_unlock_irqrestore(&priv->pd_lock, flags);
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -3082,7 +3083,7 @@ static void pic32mx_ethreset(struct pic32mx_driver_s *priv)
|
||||
|
||||
/* Reset the MAC */
|
||||
|
||||
flags = enter_critical_section();
|
||||
flags = spin_lock_irqsave(&priv->pd_lock);
|
||||
|
||||
/* Ethernet Controller Initialization *************************************/
|
||||
|
||||
@@ -3146,7 +3147,7 @@ static void pic32mx_ethreset(struct pic32mx_driver_s *priv)
|
||||
|
||||
up_udelay(50);
|
||||
pic32mx_putreg(0, PIC32MX_EMAC1_CFG1);
|
||||
leave_critical_section(flags);
|
||||
spin_unlock_irqrestore(&priv->pd_lock, flags);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -3200,6 +3201,8 @@ static inline int pic32mx_ethinitialize(int intf)
|
||||
priv->pd_irqsrc = ??; /* Ethernet controller IRQ source number */
|
||||
#endif
|
||||
|
||||
spin_lock_init(&priv->pd_lock); /* Initialize spinlock */
|
||||
|
||||
/* Reset the Ethernet controller and leave in the ifdown state. The
|
||||
* Ethernet controller will be properly re-initialized each time
|
||||
* pic32mx_ifup() is called.
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/spinlock.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/wdog.h>
|
||||
#include <nuttx/wqueue.h>
|
||||
@@ -366,6 +366,7 @@ struct pic32mz_driver_s
|
||||
struct wdog_s pd_txtimeout; /* TX timeout timer */
|
||||
struct work_s pd_irqwork; /* For deferring interrupt work to the work queue */
|
||||
struct work_s pd_pollwork; /* For deferring poll work to the work queue */
|
||||
spinlock_t pd_lock; /* Spinlock */
|
||||
|
||||
sq_queue_t pd_freebuffers; /* The free buffer list */
|
||||
|
||||
@@ -2366,7 +2367,7 @@ static int pic32mz_ifdown(struct net_driver_s *dev)
|
||||
|
||||
/* Disable the Ethernet interrupt */
|
||||
|
||||
flags = enter_critical_section();
|
||||
flags = spin_lock_irqsave(&priv->pd_lock);
|
||||
#if CONFIG_PIC32MZ_NINTERFACES > 1
|
||||
up_disable_irq(priv->pd_irqsrc);
|
||||
#else
|
||||
@@ -2381,7 +2382,7 @@ static int pic32mz_ifdown(struct net_driver_s *dev)
|
||||
|
||||
pic32mz_ethreset(priv);
|
||||
priv->pd_ifup = false;
|
||||
leave_critical_section(flags);
|
||||
spin_unlock_irqrestore(&priv->pd_lock, flags);
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -3248,7 +3249,7 @@ static void pic32mz_ethreset(struct pic32mz_driver_s *priv)
|
||||
|
||||
/* Reset the MAC */
|
||||
|
||||
flags = enter_critical_section();
|
||||
flags = spin_lock_irqsave(&priv->pd_lock);
|
||||
|
||||
/* Ethernet Controller Initialization *************************************/
|
||||
|
||||
@@ -3313,7 +3314,7 @@ static void pic32mz_ethreset(struct pic32mz_driver_s *priv)
|
||||
|
||||
up_udelay(50);
|
||||
pic32mz_putreg(0, PIC32MZ_EMAC1_CFG1);
|
||||
leave_critical_section(flags);
|
||||
spin_unlock_irqrestore(&priv->pd_lock, flags);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -3367,6 +3368,8 @@ static inline int pic32mz_ethinitialize(int intf)
|
||||
priv->pd_irqsrc = ; /* Ethernet controller IRQ source number */
|
||||
#endif
|
||||
|
||||
spin_lock_init(&priv->pd_lock); /* Initialize spinlock */
|
||||
|
||||
/* Configure Ethernet peripheral pin selections */
|
||||
|
||||
/* Controlled by DEVCFG FMIIEN and FETHIO settings */
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/irq.h>
|
||||
#include <nuttx/spinlock.h>
|
||||
#include <nuttx/wdog.h>
|
||||
#include <nuttx/wqueue.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
@@ -272,6 +272,7 @@ struct mpfs_ethmac_s
|
||||
struct wdog_s txtimeout; /* TX timeout timer */
|
||||
struct work_s irqwork; /* For deferring interrupt work to the work queue */
|
||||
struct work_s pollwork; /* For deferring poll work to the work queue */
|
||||
spinlock_t lock; /* Spinlock */
|
||||
|
||||
/* This holds the information visible to the NuttX network */
|
||||
|
||||
@@ -1588,7 +1589,7 @@ static int mpfs_ifdown(struct net_driver_s *dev)
|
||||
|
||||
/* Disable the Ethernet interrupt */
|
||||
|
||||
flags = enter_critical_section();
|
||||
flags = spin_lock_irqsave(&priv->lock);
|
||||
up_disable_irq(priv->mac_q_int[0]);
|
||||
up_disable_irq(priv->mac_q_int[1]);
|
||||
up_disable_irq(priv->mac_q_int[2]);
|
||||
@@ -1613,7 +1614,7 @@ static int mpfs_ifdown(struct net_driver_s *dev)
|
||||
/* Mark the device "down" */
|
||||
|
||||
priv->ifup = false;
|
||||
leave_critical_section(flags);
|
||||
spin_unlock_irqrestore(&priv->lock, flags);
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -3608,6 +3609,8 @@ int mpfs_ethinitialize(int intf)
|
||||
priv->queue[2].dma_rxbuf_size = (uint32_t *)(base + DMA_RXBUF_SIZE_Q2);
|
||||
priv->queue[3].dma_rxbuf_size = (uint32_t *)(base + DMA_RXBUF_SIZE_Q3);
|
||||
|
||||
spin_lock_init(&priv->lock); /* Initialize spinlock */
|
||||
|
||||
/* Generate a locally administrated MAC address for this ethernet if */
|
||||
|
||||
/* Set first byte to 0x02 or 0x06 acc. to the intf */
|
||||
|
||||
Reference in New Issue
Block a user