Lines Matching refs:queue

132 #error Not enough RX buffers to allocate descriptors for each HW queue
246 static int rx_descriptors_init(Gmac *gmac, struct gmac_queue *queue);
247 static void tx_descriptors_init(Gmac *gmac, struct gmac_queue *queue);
248 static int nonpriority_queue_init(Gmac *gmac, struct gmac_queue *queue);
252 struct gmac_queue *queue) in set_receive_buf_queue_pointer() argument
255 if (queue->que_idx == GMAC_QUE_0) { in set_receive_buf_queue_pointer()
256 gmac->GMAC_RBQB = (uint32_t)queue->rx_desc_list.buf; in set_receive_buf_queue_pointer()
258 gmac->GMAC_RBQBAPQ[queue->que_idx - 1] = in set_receive_buf_queue_pointer()
259 (uint32_t)queue->rx_desc_list.buf; in set_receive_buf_queue_pointer()
273 static int priority_queue_init(Gmac *gmac, struct gmac_queue *queue) in priority_queue_init() argument
278 __ASSERT_NO_MSG(queue->rx_desc_list.len > 0); in priority_queue_init()
279 __ASSERT_NO_MSG(queue->tx_desc_list.len > 0); in priority_queue_init()
280 __ASSERT(!((uint32_t)queue->rx_desc_list.buf & ~GMAC_RBQB_ADDR_Msk), in priority_queue_init()
282 __ASSERT(!((uint32_t)queue->tx_desc_list.buf & ~GMAC_TBQB_ADDR_Msk), in priority_queue_init()
286 queue_index = queue->que_idx - 1; in priority_queue_init()
289 result = rx_descriptors_init(gmac, queue); in priority_queue_init()
294 tx_descriptors_init(gmac, queue); in priority_queue_init()
297 k_sem_init(&queue->tx_sem, 0, 1); in priority_queue_init()
299 k_sem_init(&queue->tx_desc_sem, queue->tx_desc_list.len - 1, in priority_queue_init()
300 queue->tx_desc_list.len - 1); in priority_queue_init()
308 gmac->GMAC_RBQBAPQ[queue_index] = (uint32_t)queue->rx_desc_list.buf; in priority_queue_init()
310 gmac->GMAC_TBQBAPQ[queue_index] = (uint32_t)queue->tx_desc_list.buf; in priority_queue_init()
315 queue->err_rx_frames_dropped = 0U; in priority_queue_init()
316 queue->err_rx_flushed_count = 0U; in priority_queue_init()
317 queue->err_tx_flushed_count = 0U; in priority_queue_init()
319 LOG_INF("Queue %d activated", queue->que_idx); in priority_queue_init()
324 static int priority_queue_init_as_idle(Gmac *gmac, struct gmac_queue *queue) in priority_queue_init_as_idle() argument
326 struct gmac_desc_list *rx_desc_list = &queue->rx_desc_list; in priority_queue_init_as_idle()
327 struct gmac_desc_list *tx_desc_list = &queue->tx_desc_list; in priority_queue_init_as_idle()
347 gmac->GMAC_RBQBAPQ[queue->que_idx - 1] = (uint32_t)rx_desc_list->buf; in priority_queue_init_as_idle()
349 gmac->GMAC_TBQBAPQ[queue->que_idx - 1] = (uint32_t)tx_desc_list->buf; in priority_queue_init_as_idle()
351 LOG_INF("Queue %d set to idle", queue->que_idx); in priority_queue_init_as_idle()
356 static int queue_init(Gmac *gmac, struct gmac_queue *queue) in queue_init() argument
358 if (queue->que_idx == GMAC_QUE_0) { in queue_init()
359 return nonpriority_queue_init(gmac, queue); in queue_init()
360 } else if (queue->que_idx <= GMAC_ACTIVE_PRIORITY_QUEUE_NUM) { in queue_init()
361 return priority_queue_init(gmac, queue); in queue_init()
363 return priority_queue_init_as_idle(gmac, queue); in queue_init()
370 struct gmac_queue *queue) in set_receive_buf_queue_pointer() argument
372 gmac->GMAC_RBQB = (uint32_t)queue->rx_desc_list.buf; in set_receive_buf_queue_pointer()
375 static int queue_init(Gmac *gmac, struct gmac_queue *queue) in queue_init() argument
377 return nonpriority_queue_init(gmac, queue); in queue_init()
473 static int rx_descriptors_init(Gmac *gmac, struct gmac_queue *queue) in rx_descriptors_init() argument
475 struct gmac_desc_list *rx_desc_list = &queue->rx_desc_list; in rx_descriptors_init()
476 struct net_buf **rx_frag_list = queue->rx_frag_list; in rx_descriptors_init()
514 static void tx_descriptors_init(Gmac *gmac, struct gmac_queue *queue) in tx_descriptors_init() argument
516 struct gmac_desc_list *tx_desc_list = &queue->tx_desc_list; in tx_descriptors_init()
531 ring_buf_reset(&queue->tx_frag_list); in tx_descriptors_init()
533 ring_buf_reset(&queue->tx_frames); in tx_descriptors_init()
698 static void tx_completed(Gmac *gmac, struct gmac_queue *queue) in tx_completed() argument
701 k_sem_give(&queue->tx_sem); in tx_completed()
703 struct gmac_desc_list *tx_desc_list = &queue->tx_desc_list; in tx_completed()
710 CONTAINER_OF(queue, struct eth_sam_dev_data, in tx_completed()
711 queue_list[queue->que_idx]); in tx_completed()
721 k_sem_give(&queue->tx_desc_sem); in tx_completed()
724 frag = UINT_TO_POINTER(ring_buf_get(&queue->tx_frag_list)); in tx_completed()
731 pkt = UINT_TO_POINTER(ring_buf_get(&queue->tx_frames)); in tx_completed()
755 static void tx_error_handler(Gmac *gmac, struct gmac_queue *queue) in tx_error_handler() argument
759 struct ring_buf *tx_frag_list = &queue->tx_frag_list; in tx_error_handler()
762 struct ring_buf *tx_frames = &queue->tx_frames; in tx_error_handler()
766 queue->err_tx_flushed_count++; in tx_error_handler()
793 k_sem_reset(&queue->tx_desc_sem); in tx_error_handler()
794 for (int i = 0; i < queue->tx_desc_list.len - 1; i++) { in tx_error_handler()
795 k_sem_give(&queue->tx_desc_sem); in tx_error_handler()
798 tx_descriptors_init(gmac, queue); in tx_error_handler()
802 k_sem_give(&queue->tx_sem); in tx_error_handler()
812 static void rx_error_handler(Gmac *gmac, struct gmac_queue *queue) in rx_error_handler() argument
814 queue->err_rx_flushed_count++; in rx_error_handler()
819 queue->rx_desc_list.tail = 0U; in rx_error_handler()
821 for (int i = 0; i < queue->rx_desc_list.len; i++) { in rx_error_handler()
822 queue->rx_desc_list.buf[i].w1 = 0U; in rx_error_handler()
823 queue->rx_desc_list.buf[i].w0 &= ~GMAC_RXW0_OWNERSHIP; in rx_error_handler()
826 set_receive_buf_queue_pointer(gmac, queue); in rx_error_handler()
1157 static int nonpriority_queue_init(Gmac *gmac, struct gmac_queue *queue) in nonpriority_queue_init() argument
1161 __ASSERT_NO_MSG(queue->rx_desc_list.len > 0); in nonpriority_queue_init()
1162 __ASSERT_NO_MSG(queue->tx_desc_list.len > 0); in nonpriority_queue_init()
1163 __ASSERT(!((uint32_t)queue->rx_desc_list.buf & ~GMAC_RBQB_ADDR_Msk), in nonpriority_queue_init()
1165 __ASSERT(!((uint32_t)queue->tx_desc_list.buf & ~GMAC_TBQB_ADDR_Msk), in nonpriority_queue_init()
1169 result = rx_descriptors_init(gmac, queue); in nonpriority_queue_init()
1174 tx_descriptors_init(gmac, queue); in nonpriority_queue_init()
1180 k_sem_init(&queue->tx_sem, 0, 1); in nonpriority_queue_init()
1186 k_sem_init(&queue->tx_desc_sem, queue->tx_desc_list.len - 1, in nonpriority_queue_init()
1187 queue->tx_desc_list.len - 1); in nonpriority_queue_init()
1191 gmac->GMAC_RBQB = (uint32_t)queue->rx_desc_list.buf; in nonpriority_queue_init()
1193 gmac->GMAC_TBQB = (uint32_t)queue->tx_desc_list.buf; in nonpriority_queue_init()
1211 queue->err_rx_frames_dropped = 0U; in nonpriority_queue_init()
1212 queue->err_rx_flushed_count = 0U; in nonpriority_queue_init()
1213 queue->err_tx_flushed_count = 0U; in nonpriority_queue_init()
1215 LOG_INF("Queue %d activated", queue->que_idx); in nonpriority_queue_init()
1220 static struct net_pkt *frame_get(struct gmac_queue *queue) in frame_get() argument
1222 struct gmac_desc_list *rx_desc_list = &queue->rx_desc_list; in frame_get()
1224 struct net_buf **rx_frag_list = queue->rx_frag_list; in frame_get()
1296 queue->err_rx_frames_dropped++; in frame_get()
1333 static void eth_rx(struct gmac_queue *queue) in eth_rx() argument
1336 CONTAINER_OF(queue, struct eth_sam_dev_data, in eth_rx()
1337 queue_list[queue->que_idx]); in eth_rx()
1349 rx_frame = frame_get(queue); in eth_rx()
1368 rx_frame = frame_get(queue); in eth_rx()
1407 struct gmac_queue *queue; in eth_tx() local
1435 queue = &dev_data->queue_list[CONFIG_ETH_SAM_GMAC_FORCED_QUEUE]; in eth_tx()
1438 queue = &dev_data->queue_list[net_tx_priority2tc(pkt_prio)]; in eth_tx()
1441 queue = &dev_data->queue_list[priority2queue(pkt_prio)]; in eth_tx()
1444 tx_desc_list = &queue->tx_desc_list; in eth_tx()
1445 err_tx_flushed_count_at_entry = queue->err_tx_flushed_count; in eth_tx()
1460 k_sem_take(&queue->tx_desc_sem, K_FOREVER); in eth_tx()
1469 if (queue->err_tx_flushed_count != in eth_tx()
1498 ring_buf_put(&queue->tx_frag_list, POINTER_TO_UINT(frag)); in eth_tx()
1514 if (queue->err_tx_flushed_count != err_tx_flushed_count_at_entry) { in eth_tx()
1536 ring_buf_put(&queue->tx_frames, POINTER_TO_UINT(pkt)); in eth_tx()
1555 k_sem_take(&queue->tx_sem, K_FOREVER); in eth_tx()
1558 if (queue->err_tx_flushed_count != err_tx_flushed_count_at_entry) { in eth_tx()
1580 struct gmac_queue *queue; in queue0_isr() local
1590 queue = &dev_data->queue_list[0]; in queue0_isr()
1591 rx_desc_list = &queue->rx_desc_list; in queue0_isr()
1592 tx_desc_list = &queue->tx_desc_list; in queue0_isr()
1596 rx_error_handler(gmac, queue); in queue0_isr()
1602 eth_rx(queue); in queue0_isr()
1607 tx_error_handler(gmac, queue); in queue0_isr()
1616 tx_completed(gmac, queue); in queue0_isr()
1631 struct gmac_queue *queue; in priority_queue_isr() local
1640 queue = &dev_data->queue_list[queue_idx]; in priority_queue_isr()
1641 rx_desc_list = &queue->rx_desc_list; in priority_queue_isr()
1642 tx_desc_list = &queue->tx_desc_list; in priority_queue_isr()
1646 rx_error_handler(gmac, queue); in priority_queue_isr()
1652 eth_rx(queue); in priority_queue_isr()
1657 tx_error_handler(gmac, queue); in priority_queue_isr()
1666 tx_completed(gmac, queue); in priority_queue_isr()