[dpdk-dev] [PATCH] port: add file descriptor SWX port

Stephen Hemminger stephen at networkplumber.org
Tue Mar 23 19:29:05 CET 2021


On Fri, 19 Mar 2021 08:02:06 -0400
Venkata Suresh Kumar P <venkata.suresh.kumar.p at intel.com> wrote:

> +/*
> + * FD Reader
> + */
> +struct reader {
> +	struct {
> +		int fd;
> +		uint32_t mtu;
> +		uint32_t burst_size;
> +		struct rte_mempool *mempool;
> +	} params;
> +
> +	struct rte_swx_port_in_stats stats;
> +	struct rte_mbuf **pkts;
> +	uint32_t n_pkts;
> +	uint32_t pos;
> +};
> +

You could save one allocation (and get better cache locality)
by using a dynamic array here.

struct reader {
	struct {
		int fd;
		uint32_t mtu;
		uint32_t burst_size;
		struct rte_mempool *mempool;
	} params;

	struct rte_swx_port_in_stats stats;

	uint32_t n_pkts;
	uint32_t pos;
	struct rte_mbuf *pkts[];
};

Then change the allocation to size it based on number of packets.


More information about the dev mailing list