[dpdk-dev] [PATCH v3 4/4] eventdev: Add tests for event eth Rx adapter APIs

santosh santosh.shukla at caviumnetworks.com
Fri Sep 15 08:07:18 CEST 2017


Hi Nikhil,

On Tuesday 12 September 2017 05:59 PM, Nikhil Rao wrote:
> Add unit tests for rte_event_eth_rx_adapter_xxx() APIs
>
> Signed-off-by: Nikhil Rao <nikhil.rao at intel.com>
> ---
>  test/test/test_event_eth_rx_adapter.c | 385 ++++++++++++++++++++++++++++++++++
>  test/test/Makefile                    |   1 +
>  2 files changed, 386 insertions(+)
>  create mode 100644 test/test/test_event_eth_rx_adapter.c

patch breaks build:
http://dpdk.org/ml/archives/test-report/2017-September/029088.html

> diff --git a/test/test/test_event_eth_rx_adapter.c b/test/test/test_event_eth_rx_adapter.c
> new file mode 100644
> index 0000000..d338b0b
> --- /dev/null
> +++ b/test/test/test_event_eth_rx_adapter.c
> @@ -0,0 +1,385 @@
> +/*-
> + *   BSD LICENSE
> + *
> + *   Copyright(c) 2017 Intel Corporation. All rights reserved.
> + *
> + *   Redistribution and use in source and binary forms, with or without
> + *   modification, are permitted provided that the following conditions
> + *   are met:
> + *
> + *     * Redistributions of source code must retain the above copyright
> + *       notice, this list of conditions and the following disclaimer.
> + *     * Redistributions in binary form must reproduce the above copyright
> + *       notice, this list of conditions and the following disclaimer in
> + *       the documentation and/or other materials provided with the
> + *       distribution.
> + *     * Neither the name of Intel Corporation nor the names of its
> + *       contributors may be used to endorse or promote products derived
> + *       from this software without specific prior written permission.
> + *
> + *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
> + *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
> + *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
> + *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
> + *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> + *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
> + *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
> + *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
> + *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
> + *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
> + *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> + */
> +#include <string.h>
> +#include <rte_common.h>
> +#include <rte_mempool.h>
> +#include <rte_mbuf.h>
> +#include <rte_ethdev.h>
> +#include <rte_eventdev.h>
> +
> +#include <rte_event_eth_rx_adapter.h>
> +
> +#include "test.h"
> +
> +/* i40e limits max to 64 */
> +#define MAX_NUM_RX_QUEUE	64
> +struct rte_mempool *mp;

Pl. avoid globals for mempool, I did similar cleanup
for mempool tests in past. And in your test case, few functions are
are pool consumer so I suggest to add mempool * arg to those
function.

> +uint16_t rx_rings, tx_rings;
> +uint32_t cap;
> +
> +static inline int
> +port_init(uint8_t port, struct rte_mempool *mp)
> +{
> +	static const struct rte_eth_conf port_conf_default = {
> +		.rxmode = {
> +			.mq_mode = ETH_MQ_RX_RSS,
> +			.max_rx_pkt_len = ETHER_MAX_LEN
> +		},
> +		.rx_adv_conf = {
> +			.rss_conf = {
> +				.rss_hf = ETH_RSS_IP |
> +					  ETH_RSS_TCP |
> +					  ETH_RSS_UDP,
> +			}
> +		}
> +	};
> +	const uint16_t rx_ring_size = 512, tx_ring_size = 512;
> +	struct rte_eth_conf port_conf = port_conf_default;
> +	int retval;
> +	uint16_t q;
> +	struct rte_eth_dev_info dev_info;
> +
> +	if (port >= rte_eth_dev_count())
> +		return -1;
> +
> +	rte_eth_dev_info_get(port, &dev_info);
> +	rx_rings = RTE_MIN(MAX_NUM_RX_QUEUE, dev_info.max_rx_queues);
> +
> +	/* Configure the Ethernet device. */
> +	retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
> +	if (retval != 0)
> +		return retval;
> +
> +	for (q = 0; q < rx_rings; q++) {
> +		retval = rte_eth_rx_queue_setup(port, q, rx_ring_size,
> +				rte_eth_dev_socket_id(port), NULL, mp);
> +		if (retval < 0)
> +			return retval;
> +	}
> +
> +	/* Allocate and set up 1 TX queue per Ethernet port. */
> +	for (q = 0; q < tx_rings; q++) {
> +		retval = rte_eth_tx_queue_setup(port, q, tx_ring_size,
> +				rte_eth_dev_socket_id(port), NULL);
> +		if (retval < 0)
> +			return retval;
> +	}
> +
> +	/* Start the Ethernet port. */
> +	retval = rte_eth_dev_start(port);
> +	if (retval < 0)
> +		return retval;
> +
> +	/* Display the port MAC address. */
> +	struct ether_addr addr;
> +	rte_eth_macaddr_get(port, &addr);
> +	printf("Port %u MAC: %02" PRIx8 " %02" PRIx8 " %02" PRIx8
> +			   " %02" PRIx8 " %02" PRIx8 " %02" PRIx8 "\n",
> +			(unsigned int)port,
> +			addr.addr_bytes[0], addr.addr_bytes[1],
> +			addr.addr_bytes[2], addr.addr_bytes[3],
> +			addr.addr_bytes[4], addr.addr_bytes[5]);
> +
> +	/* Enable RX in promiscuous mode for the Ethernet device. */
> +	rte_eth_promiscuous_enable(port);
> +
> +	return 0;
> +}
> +
> +static int
> +init_ports(int num_ports)
> +{
> +	uint8_t portid;
> +
> +	mp = rte_pktmbuf_pool_create("packet_pool",
> +			/* mbufs */ 8192 * num_ports * MAX_NUM_RX_QUEUE,
> +			/* cache_size */ 512,

Use macro for cache_size value, same comment for mbufs.
Something like,
for cache_size: RTE_MEMPOOL_CACHE_MAX_SIZE,

Local test macro for mbuf could be:
MBUF_xxx, see test/test/test_mbuf.c.

Thanks.



More information about the dev mailing list