About "nbuf.c", Ethernet driver, all MCF

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

About "nbuf.c", Ethernet driver, all MCF

909 Views
francois_boucha
Contributor III

Hi all,

 

I noticed that nbuf.c/.h is spread amongst user to develop Ethernet driver.  Me too I use this file as my FEC buffer ring module.

 

I got doubt about the following function code.  When a RxBD (Buffer Descriptor) is already used, it will return NULL, but it does'nt restablish the old interrupt level.  I think it the level should be restablished prior returning NULL.

 

 

NBUF * nbuf_rx_allocate (void){ /* This routine alters shared data. Disable interrupts! */ int old_ipl = asm_set_ipl(6); /* Return a pointer to the next empty Rx Buffer Descriptor */ int i = iRxbd;//#if 0 /* Check to see if the ring of BDs is full */ if (RxNBUF[i].status & RX_BD_INUSE)  return NULL; /* Mark the buffer as in use */ RxNBUF[i].status |= RX_BD_INUSE;//#endif  /* increment the circular index */ iRxbd = (uint8)((iRxbd + 1) % NUM_RXBDS); /* Restore previous IPL */ asm_set_ipl((uint32)(old_ipl)); return &RxNBUF[i];}

What do you think,

 

I'm working with mcf5282, but also mcf52259

CW7.1.21a

 

FB

Labels (1)
0 Kudos
Reply
1 Reply

441 Views
scifi
Senior Contributor I
I think you are right. Looks like someone forgot to re-enable interrupts. If this was intentional, then it would be very bad coding practice.
0 Kudos
Reply