/* Support function for RXFIFO_ALLOC macro. 
This function allocates up to 'max' number of MFIFO elements by enqueuing pointers to memory elements with associated memq links.  */
void ull_rxfifo_alloc(uint8_t s, uint8_t n, uint8_t f, uint8_t *l, uint8_t *m, void *mem_free, void *link_free, uint8_t max)
/* Support function for RXFIFO_ALLOC macro. 
This function allocates up to 'max' number of MFIFO elements by enqueuing pointers to memory elements with associated memq links.  */
void ull_rxfifo_alloc(uint8_t s, uint8_t n, uint8_t f, uint8_t *l, uint8_t *m, void *mem_free, void *link_free, uint8_t max)
{
	uint8_t idx;
	while ((max--) && mfifo_enqueue_idx_get(n, f, *l, &idx)) {
		memq_link_t *link;
		struct node_rx_hdr *rx;
		link = mem_acquire(link_free);
		if (!link) {
			break;
		}
		rx = mem_acquire(mem_free);
		if (!rx) {
			mem_release(link, link_free);
			break;
		}
		link->mem = NULL;
		rx->link = link;
		mfifo_by_idx_enqueue(m, s, idx, rx, l);
	}
}