[ovs-dev] [PATCH 24/41] ofp-util: Rewrite async config encoding and decoding to be table-driven.
Ben Pfaff
blp at ovn.org
Wed Jan 20 17:47:38 UTC 2016
Thanks, I improved that and applied this to master.
On Tue, Jan 19, 2016 at 03:57:38PM -0800, Jarno Rajahalme wrote:
> With a small nit below,
>
> Acked-by: Jarno Rajahalme <jarno at ovn.org>
>
> > On Jan 18, 2016, at 11:27 PM, Ben Pfaff <blp at ovn.org> wrote:
> >
>
> (snip)
>
> > +struct ofp14_async_prop {
> > + uint64_t prop_type;
> > + enum ofputil_async_msg_type oam;
> > + bool master;
> > + uint32_t allowed10, allowed14;
> > +};
> > +
> > +#define AP_PAIR(SLAVE_PROP_TYPE, OAM, A10, A14) \
> > + { SLAVE_PROP_TYPE, OAM, false, A10, (A14) ? (A14) : (A10) }, \
> > + { (SLAVE_PROP_TYPE + 1), OAM, true, A10, (A14) ? (A14) : (A10) }
> > +
> > +static const struct ofp14_async_prop async_props[] = {
> > + AP_PAIR( 0, OAM_PACKET_IN, OFPR10_BITS, OFPR14_BITS),
> > + AP_PAIR( 2, OAM_PORT_STATUS, (1 << OFPPR_N_REASONS) - 1, 0),
> > + AP_PAIR( 4, OAM_FLOW_REMOVED, (1 << OVS_OFPRR_NONE) - 1, 0),
> > + AP_PAIR( 6, OAM_ROLE_STATUS, (1 << OFPCRR_N_REASONS) - 1, 0),
> > + AP_PAIR( 8, OAM_TABLE_STATUS, OFPTR_BITS, 0),
> > + AP_PAIR(10, OAM_REQUESTFORWARD, (1 << OFPRFR_N_REASONS) - 1, 0),
> > +};
> > +
> > +static const struct ofp14_async_prop *
> > +get_ofp14_async_config_prop_by_prop_type(uint64_t prop_type)
> > +{
> > + for (const struct ofp14_async_prop *ap = async_props;
> > + ap < &async_props[ARRAY_SIZE(async_props)]; ap++) {
>
> There are at least three uses for this for-loop, maybe define a macro for this and use it instead?
OK, I defined:
#define FOR_EACH_ASYNC_PROP(VAR) \
for (const struct ofp14_async_prop *VAR = async_props; \
VAR < &async_props[ARRAY_SIZE(async_props)]; VAR++)
and used this in each case.
More information about the dev
mailing list