|
#ifndef STELLARIS_NUM_PBUF_QUEUE
#define STELLARIS_NUM_PBUF_QUEUE 20
#endif
/* Helper struct to hold a queue of pbufs for transmit and receive. 数据缓冲队列*/
struct pbufq {
struct pbuf *pbuf[STELLARIS_NUM_PBUF_QUEUE];
unsigned long qwrite;
unsigned long qread;
unsigned long overflow;
};
/* Helper macros for accessing pbuf queues. */
#define PBUF_QUEUE_EMPTY(q) \
(((q)->qwrite == (q)->qread) ? true : false)
#define PBUF_QUEUE_FULL(q) \
((((((q)->qwrite + 1) % STELLARIS_NUM_PBUF_QUEUE)) == (q)->qread) ? \
true : false )
/*
从缓冲区读数据处理
*/
static struct pbuf *
dequeue_packet(struct pbufq *q)
{
struct pbuf *pBuf;
/**
* This entire function must run within a "critical section" to preserve
* the integrity of the transmit pbuf queue.
*
*/
OS_ENTER_CRITICAL();
if(PBUF_QUEUE_EMPTY(q)) { //在这就跳到static void FaultISR(void);循环了
/* Return a NULL pointer if the queue is empty. */
pBuf = (struct pbuf *)NULL;
}
else {
/**
* The queue is not empty so return the next frame from it
* and adjust the read pointer accordingly.
*
*/
pBuf = q->pbuf[q->qread];
q->qread = ((q->qread + 1) % STELLARIS_NUM_PBUF_QUEUE);
}
/* Return to prior interrupt state and return the pbuf pointer. */
OS_EXIT_CRITICAL();
return(pBuf);
}
void
ethernetif_input(void *arg)
{
struct netif *netif = (struct netif *)arg;
struct ethernetif *ethernetif;
struct eth_hdr *ethhdr;
struct pbuf *p;
//ethernetif = netif->state;
while(1)
{
/* move received packet into a new pbuf */
/* move received packet into a new pbuf */
p = dequeue_packet(ðernetif->rxq);
/* no packet could be read, silently ignore this */
if (p != NULL)
{
/* points to packet payload, which starts with an Ethernet header */
ethhdr = p->payload;
switch (htons(ethhdr->type)) {
/* IP or ARP packet? */
case ETHTYPE_IP:
#if ETHARP_TRUST_IP_MAC
/* update ARP table */
etharp_ip_input(netif, p);
#endif /* ETHARP_TRUST_IP_MAC */
/* skip Ethernet header */
if(pbuf_header(p, -(s16_t)sizeof(struct eth_hdr))) {
LWIP_ASSERT("Can't move over header in packet", 0);
pbuf_free(p);
p = NULL;
} else {
/* pass to IP layer */
ip_input(p, netif);
}
break;
case ETHTYPE_ARP:
#if PPPOE_SUPPORT
/* pass p to ARP module */
etharp_arp_input(netif, (struct eth_addr*)(netif->hwaddr), p);
break;
case ETHTYPE_PPPOEDISC:
pppoe_disc_input(netif, p);
break;
case ETHTYPE_PPPOE:
pppoe_data_input(netif, p);
#endif /* PPPOE_SUPPORT */
/* full packet send to tcpip_thread to process */
if (netif->input(p, netif)!=ERR_OK)
{ LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n"));
pbuf_free(p);
p = NULL;
}
break;
default:
pbuf_free(p);
p = NULL;
break;
}
}
}
}
各位高手帮我看看是什么问题??
谢谢 |
阿莫论坛20周年了!感谢大家的支持与爱护!!
曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……
|