[dpdk-dev] [RFC] mbuf: support dynamic fields and flags

Olivier Matz olivier.matz at 6wind.com
Fri Jul 12 11:18:09 CEST 2019


On Thu, Jul 11, 2019 at 08:31:19AM -0700, Stephen Hemminger wrote:
> On Thu, 11 Jul 2019 09:26:19 +0200
> Olivier Matz <olivier.matz at 6wind.com> wrote:
> 
> > For generic fields, I think they should be declared in this file. For
> > instance, if we decide to replace the current m->timestamp field by a
> > dynamic field, we should add like this:
> > 
> > #define RTE_MBUF_DYN_TIMESTAMP_ID "rte_timestamp"
> > #define RTE_MBUF_DYN_TIMESTAMP_SIZE sizeof(uint64_t)
> > #define RTE_MBUF_DYN_TIMESTAMP_ALIGN __alignof__(uint64_t)
> 
> 
> Let's use  structures (like rte_flow) rather that macros for
> this?

The purpose of having defines is:
- to avoid typos when registering dynamic fields/flags
- to avoid name conflicts (because define names are derived from identifier)
- associate a known size and alignment to a given dynamic field

Using strings instead of numeric identifiers is also done on
purpose, to facilitate the definition of unique identifiers outside
the dpdk subtree (as soon as we respect contraints on namespace).

Instead of defines, are you suggesting something like this?

	struct rte_mbuf_dynfield {
		const char *id;
		size_t size;
		size_t align;
	};

	/* definition of a dynamic field */
	static const struct rte_mbuf_dynfield rte_mbuf_dynfield_timestamp {
		.id = "rte_mbuf_dynfield_timestamp",
		.size = sizeof(uint64_t),
		.size = __alignof__(uint64_t),
	};

	/* ...and same for dynamic flags... */

And change the registration API to have one argument of type (struct
rte_mbuf_dynfield *) ?

I agree it could be quite nice with structs.


More information about the dev mailing list