Zynq BSP progress

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Apr 12 07:12:26 UTC 2013


On 04/12/2013 04:43 AM, Claus, Ric wrote:
>
> On Apr 11, 2013, at 12:49 PM, Claus, Ric wrote:
>
>> I am getting close to being comfortable with letting my RTEMS 4.11 BSP for Xilinx Zynq-based boards out into the wild.  However, I am still facing a few problems.
>>
>> The first is that the network driver continues to be unstable.  The latest issue seems to be due to the fact that the DMA engine absconds with the lower two bits of the buffer address to indicate ownership and the ring buffer wrap point, so the minimum buffer alignment granularity is a longword.  Because an ethernet header is 14 bytes long, this forces the data payload of a received buffer to be word (16 bit) aligned.  For reasons I have yet to understand, this is not a problem for small payloads, but for larger ones (~500+ bytes, I think) I get alignment exceptions in udp_input().  Has anyone encountered this and know what to do about it?
>>
>> The second is that neither DHCP nor NFS seems to work.  Still have to figure out why.  This is based on results with the network-demos package.
>
> The above issues appear to be due to the same problem.  The specific code where the problem occurs is in udp_input at the line (159 in the git head of udp_usrreq.c):
>
> 	/*
> 	 * Save a copy of the IP header in case we want restore it
> 	 * for sending an ICMP error message in response.
> 	 */
> 	save_ip = *ip;
>
> ip doesn't point to the 14 byte ethernet header, but just past it because the the arguments given to ether_input() provide the frame as per the ether_input() man page comment:  "The frame is in the mbuf chain without  the ether_header structure, which is provided separately."  If one comments this line out or subtracts iphlen from the ip pointer, things seem to work correctly.
>
> Does anyone have any comments or suggestions on the proper way to fix this?

You have to make sure that the IP header structure is properly aligned.  Example:

http://git.rtems.org/rtems/tree/c/src/lib/libbsp/arm/shared/lpc/network/lpc-ethernet.c

#define LPC_ETH_RX_DATA_OFFSET 2

static struct mbuf *lpc_eth_new_mbuf(struct ifnet *ifp, bool wait)
{
   struct mbuf *m = NULL;
   int mw = wait ? M_WAIT : M_DONTWAIT;

   MGETHDR(m, mw, MT_DATA);
   if (m != NULL) {
     MCLGET(m, mw);
     if ((m->m_flags & M_EXT) != 0) {
       /* Set receive interface */
       m->m_pkthdr.rcvif = ifp;

       /* Adjust by two bytes for proper IP header alignment */
       m->m_data = mtod(m, char *) + LPC_ETH_RX_DATA_OFFSET;

       return m;
     } else {
       m_free(m);
     }
   }

   return NULL;
}

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.



More information about the devel mailing list