Fixed up and made work a PBUF_REF type. Most of the code uses this now
instead of PBUF_ROM. This addition allows support of copy-on-demand where the lower layers can call pbuf_unref() which tests for any PBUF_REF buffers and replaces them with PBUF_POOL buffers. This is now used everywhere. pbuf_unref() is called in ARP queueing and in the coldfire driver, which puts frames on a DMA queue and frees them later. Along with this change pbuf_free() now goes through the entire chain of buffers and tests all the ref counters, not just the first one. Generally now pbuf_ref_chain() should be called and not pbuf_ref(). This change was made because it is possible for the head of the pbuf chain to have a different count than the payload pbuf which might have been passed by the application. Coldfire ethernet driver also had some minor other updates and STATS was changed to LWIP_STATS.
This commit is contained in:
parent
0749599eab
commit
0a46ef6af4
|
@ -363,7 +363,7 @@ low_level_output(struct netif *netif, struct pbuf *p)
|
|||
|
||||
} else {
|
||||
/* Increment use count on pbuf */
|
||||
pbuf_ref(p);
|
||||
pbuf_ref_chain(p);
|
||||
|
||||
/* Put buffers on descriptor ring, but don't mark them as ready yet */
|
||||
tx_insert_eof = tx_insert_sof = mcf5272->tx_insert;
|
||||
|
@ -670,8 +670,8 @@ low_level_init(struct netif *netif)
|
|||
|
||||
/* Set the tranceiver interface to MII mode */
|
||||
MCF5272_WR_FEC_RCR(imm, 0
|
||||
| MCF5272_FEC_RCR_MII_MODE);
|
||||
/* | MCF5272_FEC_RCR_DRT); */ /* half duplex */
|
||||
| MCF5272_FEC_RCR_MII_MODE
|
||||
| MCF5272_FEC_RCR_DRT); /* half duplex */
|
||||
|
||||
/* Only operate in half-duplex, no heart beat control */
|
||||
MCF5272_WR_FEC_TCR(imm, 0);
|
||||
|
|
|
@ -183,9 +183,9 @@ a lot of data that needs to be copied, this should be set high. */
|
|||
|
||||
|
||||
/* ---------- Statistics options ---------- */
|
||||
#define STATS
|
||||
#define LWIP_STATS 1
|
||||
|
||||
#ifdef STATS
|
||||
#ifdef LWIP_STATS
|
||||
#define LINK_STATS
|
||||
#define IP_STATS
|
||||
#define ICMP_STATS
|
||||
|
|
|
@ -62,7 +62,6 @@ static int num_sem = 0; // Number of semaphores created
|
|||
static int num_mbox = 0; // Number of mailboxes created
|
||||
static int num_thread = 0; // Number of threads created
|
||||
static int num_hisr = 0; // Number of hisrs created
|
||||
static sys_sem_t thread_sem; // Protect thread structure
|
||||
static struct sys_thread *threads = NULL;
|
||||
static struct sys_hisr *hisrs = NULL;
|
||||
|
||||
|
@ -78,7 +77,6 @@ static struct sys_hisr *hisrs = NULL;
|
|||
void
|
||||
sys_init(void)
|
||||
{
|
||||
thread_sem = sys_sem_new(1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -97,18 +95,19 @@ static struct sys_thread *
|
|||
introduce_thread(NU_TASK *id, void (*function)(void *arg), void *arg)
|
||||
{
|
||||
struct sys_thread *thread;
|
||||
sys_prot_t old_level;
|
||||
|
||||
thread = (struct sys_thread *) calloc(1,sizeof(struct sys_thread));
|
||||
|
||||
if(thread) {
|
||||
sys_arch_sem_wait(thread_sem, 0); //Wait to obtain the semaphore
|
||||
old_level = sys_arch_protect();
|
||||
thread->next = threads;
|
||||
thread->timeouts.next = NULL;
|
||||
thread->pthread = id;
|
||||
thread->function = function;
|
||||
thread->arg = arg;
|
||||
threads = thread;
|
||||
sys_sem_signal(thread_sem); //Release semaphore
|
||||
sys_arch_unprotect(old_level);
|
||||
}
|
||||
|
||||
return thread;
|
||||
|
@ -165,23 +164,22 @@ static struct sys_thread *
|
|||
current_thread(void)
|
||||
{
|
||||
struct sys_thread *st;
|
||||
sys_prot_t old_level;
|
||||
NU_TASK *pt;
|
||||
|
||||
pt = NU_Current_Task_Pointer();
|
||||
sys_arch_sem_wait(thread_sem, 0);
|
||||
old_level = sys_arch_protect();
|
||||
|
||||
for(st = threads; st != NULL; st = st->next)
|
||||
{
|
||||
if(st->pthread == pt)
|
||||
{
|
||||
sys_sem_signal(thread_sem);
|
||||
|
||||
sys_arch_unprotect(old_level);
|
||||
return st;
|
||||
}
|
||||
}
|
||||
|
||||
sys_sem_signal(thread_sem);
|
||||
|
||||
sys_arch_unprotect(old_level);
|
||||
st = introduce_thread(pt, 0, 0);
|
||||
|
||||
if(!st) {
|
||||
|
|
|
@ -293,7 +293,7 @@ unixif_output(struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr)
|
|||
buf->payload = p->payload;
|
||||
|
||||
if(list_elems(unixif->q) == 0) {
|
||||
pbuf_ref(p);
|
||||
pbuf_ref_chain(p);
|
||||
list_push(unixif->q, buf);
|
||||
sys_timeout((double)p->tot_len * 8000.0 / UNIXIF_BPS, unixif_output_timeout,
|
||||
netif);
|
||||
|
@ -301,7 +301,7 @@ unixif_output(struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr)
|
|||
DEBUGF(UNIXIF_DEBUG, ("unixif_output: first on list\n"));
|
||||
|
||||
} else {
|
||||
pbuf_ref(p);
|
||||
pbuf_ref_chain(p);
|
||||
if(list_push(unixif->q, buf) == 0) {
|
||||
#ifdef UNIXIF_DROP_FIRST
|
||||
struct unixif_buf *buf2;
|
||||
|
|
Loading…
Reference in New Issue