lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] RE: [lwip] Word mode transfers in an ethernet driver


From: Michael Portmann
Subject: [lwip-users] RE: [lwip] Word mode transfers in an ethernet driver
Date: Thu, 09 Jan 2003 01:04:42 -0000

Dan,

  One snag you will hit, even though the PBUFs are word aligned, is the number 
of bytes in a single pbuf with a chain is not necessarily even !

  I encountered this problem with Leon's cs8900 driver when I implemented 
modnet. The odd pbuf seems to depend soley on how you write data to the stream, 
the httpd implemented always seems to generate 1 pbuf so the problem never 
occurs, my modnet generated a write for each incoming packet so quite often I 
would be generating several responses before the packet got sent through tcp/ip.

  I have included my modified code to Leon's cs8900 driver, I don't know if he 
has put this in his code yet, but here it is.

Regards,
Mike

if((cs8900_readpp(CS_PP_BUSSTATUS) & 0x0100U/*Rdy4TxNOW*/) != 0)
{
  struct pbuf *q;
  u16_t data;
  u16_t pos;

  pos = 0;
  for(q = p; q != NULL; q = q->next)
  {
    u16_t i;
    u8_t *ptr = (u8_t *)q->payload;
    /* Send the data from the pbuf to the interface, one pbuf at a
       time. The size of the data in each pbuf is kept in the ->len
       variable. */
    for(i = 0; i < q->len; i++)
    {
      if (pos % 2 == 0)
      {
        data = *ptr << 8;
      }
      else
      {
        data |= (u16_t) *ptr;
        cs8900_writed(&RXTXREG, data);
      }
      ptr++;
      pos++;
    }

#if (CS8900_STATS > 0)
    ((struct cs8900if *)netif->state)->sentbytes += q->len;
#endif
  }
  if (pos % 2 == 1)
    cs8900_writed(&RXTXREG, data);
#if (CS8900_STATS > 0)
  ((struct cs8900if *)netif->state)->sentpackets++;
#endif
}

[This message was sent through the lwip discussion list.]




reply via email to

[Prev in Thread] Current Thread [Next in Thread]