Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

Weird Ethernet problem

Premise: I don't know if this weird problem is related to TSE, sgdma or Nios code. Please help me to identify, or better, to solve it.

I'm using Nios II with tse mac and National Semi DP83640 phy. I trasmit and receive Ethernet frames and sometimes tx or rx frames are lost and I can't understand why.

I monitored both the Ethernet link and the TSE-phy signals and I'm testing with a system that immediately loops back the rx frame.

This is what I see:

- the txen signal from the mac is always correctly generated

- the rxen signal (same behavior for crs signal, carrier sense) sometimes is lost

- often, when rxen is missing, I can neither see any frame transmitted on the cable, although sometimes I do.

And now the weirdest part:

The error seems to be almost deterministic if a rx frame arrives just after I have transmitted a frame, say within a few microsec, while it never happens if the rx frame is superimposed to tx or even if it is delayed.

So, if I use a direct loopback I seldom have any error, while the error is systematic if I insert an Ethernet hub, which delays tx/rx frames about 20us

I simplified my tx function in the following way, in order to debug with a single constant data frame, but nothing has changed.


void test_frame(void)
{
   PACKET outpkt;
   int len;
  
    len = 40;
    
   LOCK_NET_RESOURCE(FREEQ_RESID);
   outpkt = pk_alloc(len+20);
   UNLOCK_NET_RESOURCE(FREEQ_RESID);
   if (!outpkt) {
      printf("Error: pk_alloc() failed");
      dtrap();
      return;
    }
   memset(outpkt->nb_buff, 0, len+ETHHDR_SIZE+ETHHDR_BIAS);
/*  
     here I init packet with my constant data
*/
   
   outpkt->nb_plen = ETHHDR_BIAS + len;
    
   if (outpkt->net->pkt_send)   {
      outpkt->nb_prot = outpkt->nb_buff;
      outpkt->net->pkt_send(outpkt);
     }
   else   {
      outpkt->net->raw_send(ecat_net, outpkt->nb_buff, outpkt->nb_plen);
      LOCK_NET_RESOURCE(FREEQ_RESID);
      pk_free(outpkt);
      UNLOCK_NET_RESOURCE(FREEQ_RESID);
   }
        
}

Thank you for any advice

Cris

11 Replies