예제 #1
0
static void poll()
{    
  uint32_t wrap = 0;
  uint32_t cur_bytes = 0;
  uint32_t total_bytes = 0;
  uint32_t cumulative_bytes = 0;
  MUHWI_PacketHeader_t *hdr = 0;

  while ((total_bytes = MUSPI_getAvailableBytes (_rfifoShadowPtr, &wrap)) != 0) 
  {
    if (wrap == 0) 
    {
      /* No fifo wrap.  Process each packet. */
      cumulative_bytes = 0;
      while (cumulative_bytes < total_bytes ) 
      {
	hdr = MUSPI_getNextPacketOptimized (_rfifoShadowPtr, &cur_bytes);

	/* Handle the packet by 
	 * - marking the associated request complete
	 * - if this is the last request (largest), increment iteration count
	 */
	handlePacket(hdr);
	
	cumulative_bytes += cur_bytes;
	/* Touch head for next packet. */
      }
    }
    else 
    {
      /* Packets wrap around to the top of the fifo.  Handle the one packet
       * that wraps.
       */
      hdr = MUSPI_getNextPacketWrap (_rfifoShadowPtr, &cur_bytes);
	/* Handle the packet by 
	 * - marking the associated request complete
	 * - if this is the last request (largest), increment iteration count
	 */
      handlePacket(hdr);
    }

    /* Store the updated fifo head. */
    MUSPI_syncRecFifoHwHead (_rfifoShadowPtr);
  }
}
예제 #2
0
static inline void* Forwarder_getNextPacket() {
	uint32_t wrap = 0;
	uint32_t cur_bytes = 0;
	uint32_t b = 0;
	void *clientdata = NULL;
	
	if (likely(recFifoState.proc < recFifoState.avail)) {
		clientdata = MUSPI_getNextPacketOptimized(RecFifoDma, &cur_bytes);

		recFifoState.proc += cur_bytes;
		if (recFifoState.proc >= recFifoState.avail)
			MUSPI_syncRecFifoHwHead(RecFifoDma);
	} else if ((b = MUSPI_getAvailableBytes(RecFifoDma, &wrap)) != 0) {
		if (wrap == 0) {
			/* No fifo wrap.  Process each packet. */
			recFifoState.all = b; // proc = 0, avail = b

			clientdata = MUSPI_getNextPacketOptimized(RecFifoDma, &cur_bytes);

			recFifoState.proc += cur_bytes;
			if (recFifoState.proc >= recFifoState.avail)
				MUSPI_syncRecFifoHwHead(RecFifoDma);

		} else {
			/* Packets wrap around to the top of the fifo.  Handle the one packet
			* that wraps.
			*/
			clientdata = MUSPI_getNextPacketWrap(RecFifoDma, &cur_bytes);

			/* Store the updated fifo head. */
			MUSPI_syncRecFifoHwHead(RecFifoDma);
			recFifoState.all = 0; // proc = 0, avail = 0
		}
	}
	return clientdata;
}