Beispiel #1
0
/*
 * Reset TX queue when errors are detected
 */
static void tx_error_handler(Gmac *gmac, struct gmac_queue *queue)
{
	struct net_pkt *pkt;
	struct ring_buf *tx_frames = &queue->tx_frames;

	queue->err_tx_flushed_count++;

	/* Stop transmission, clean transmit pipeline and control registers */
	gmac->GMAC_NCR &= ~GMAC_NCR_TXEN;

	/* Free all pkt resources in the TX path */
	while (tx_frames->tail != tx_frames->head) {
		/* Release net buffer to the buffer pool */
		pkt = UINT_TO_POINTER(tx_frames->buf[tx_frames->tail]);
		net_pkt_unref(pkt);
		SYS_LOG_DBG("Dropping pkt %p", pkt);
		MODULO_INC(tx_frames->tail, tx_frames->len);
	}

	/* Reinitialize TX descriptor list */
	k_sem_reset(&queue->tx_desc_sem);
	tx_descriptors_init(gmac, queue);
	for (int i = 0; i < queue->tx_desc_list.len - 1; i++) {
		k_sem_give(&queue->tx_desc_sem);
	}

	/* Restart transmission */
	gmac->GMAC_NCR |=  GMAC_NCR_TXEN;
}
Beispiel #2
0
static void rx_queue_drop(struct stream *stream)
{
	size_t size;
	void *mem_block;

	while (queue_get(&stream->mem_block_queue, &mem_block, &size) == 0) {
		k_mem_slab_free(stream->cfg.mem_slab, &mem_block);
	}

	k_sem_reset(&stream->sem);
}
void test_sema_reset(void)
{
	k_sem_init(&sema, SEM_INITIAL, SEM_LIMIT);
	k_sem_give(&sema);
	k_sem_reset(&sema);
	zassert_false(k_sem_count_get(&sema), NULL);
	/**TESTPOINT: sem take return -EBUSY*/
	zassert_equal(k_sem_take(&sema, K_NO_WAIT), -EBUSY, NULL);
	/**TESTPOINT: sem take return -EAGAIN*/
	zassert_equal(k_sem_take(&sema, TIMEOUT), -EAGAIN, NULL);
	k_sem_give(&sema);
	zassert_false(k_sem_take(&sema, K_FOREVER), NULL);
}
Beispiel #4
0
/**
 *
 * @brief Mailbox transfer speed test
 *
 * @return N/A
 */
void mailbox_test(void)
{
	u32_t putsize;
	u32_t puttime;
	int putcount;
	unsigned int EmptyMsgPutTime;
	GetInfo getinfo;

	PRINT_STRING(dashline, output_file);
	PRINT_STRING("|                "
				 "M A I L B O X   M E A S U R E M E N T S"
				 "                      |\n", output_file);
	PRINT_STRING(dashline, output_file);
	PRINT_STRING("| Send mailbox message to waiting high "
		 "priority task and wait                 |\n", output_file);
	PRINT_F(output_file, "| repeat for %4d times and take the "
			"average                                  |\n",
			NR_OF_MBOX_RUNS);
	PRINT_STRING(dashline, output_file);
	PRINT_HEADER();
	PRINT_STRING(dashline, output_file);
	k_sem_reset(&SEM0);
	k_sem_give(&STARTRCV);

	putcount = NR_OF_MBOX_RUNS;

	putsize = 0;
	mailbox_put(putsize, putcount, &puttime);
	/* waiting for ack */
	k_msgq_get(&MB_COMM, &getinfo, K_FOREVER);
	PRINT_ONE_RESULT();
	EmptyMsgPutTime = puttime;
	for (putsize = 8; putsize <= MESSAGE_SIZE; putsize <<= 1) {
		mailbox_put(putsize, putcount, &puttime);
		/* waiting for ack */
		k_msgq_get(&MB_COMM, &getinfo, K_FOREVER);
		PRINT_ONE_RESULT();
	}
	PRINT_STRING(dashline, output_file);
	PRINT_OVERHEAD();
	PRINT_XFER_RATE();
}