[ovs-dev] [PATCH 24/41] ofp-util: Rewrite async config encoding and decoding to be table-driven.
Jarno Rajahalme
jarno at ovn.org
Tue Jan 19 23:57:38 UTC 2016
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?
> + if (prop_type == ap->prop_type) {
> + return ap;
> + }
> + }
> + return NULL;
> +}
> +
> +static const struct ofp14_async_prop *
> +get_ofp14_async_config_prop_by_oam(enum ofputil_async_msg_type oam,
> + bool master)
> +{
> + for (const struct ofp14_async_prop *ap = async_props;
> + ap < &async_props[ARRAY_SIZE(async_props)]; ap++) {
> + if (ap->oam == oam && ap->master == master) {
> + return ap;
> + }
> + }
> + return NULL;
> +}
> +
(snip)
More information about the dev
mailing list