On 9 March 2017 at 14:50, Andy Zhou <az...@ovn.org> wrote:
> Add logics to detect the max level of nesting allowed by the
> sample action implemented in the datapath.
>
> Future patch allows xlate code to generate different odp actions
> based on this information.
>
> Signed-off-by: Andy Zhou <az...@ovn.org>

Acked-by: Joe Stringer <j...@ovn.org>

Couple of minor comments below..

<snip>

> diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
> index 5289693..4b88d4b 100644
> --- a/ofproto/ofproto-dpif.c
> +++ b/ofproto/ofproto-dpif.c
> @@ -983,6 +983,65 @@ check_max_mpls_depth(struct dpif_backer *backer)
>      return n;
>  }
>
> +static void
> +add_sample_actions(struct ofpbuf *actions, int nesting)
> +{
> +    if (nesting == 0) {
> +        nl_msg_put_odp_port(actions, OVS_ACTION_ATTR_OUTPUT, u32_to_odp(1));
> +        return;
> +    }
> +
> +    size_t start, actions_start;
> +
> +    start = nl_msg_start_nested(actions, OVS_ACTION_ATTR_SAMPLE);
> +    actions_start = nl_msg_start_nested(actions, OVS_SAMPLE_ATTR_ACTIONS);
> +    add_sample_actions(actions, nesting - 1);
> +    nl_msg_end_nested(actions, actions_start);
> +    nl_msg_put_u32(actions, OVS_SAMPLE_ATTR_PROBABILITY, UINT32_MAX);
> +    nl_msg_end_nested(actions, start);
> +}
> +
> +/* Tests the nested sample actions levels supported by 'backer''s datapath.
> + *
> + * Returns the number of nested sample actions accepted by the datapath
> + * Otherwise returns the number of MPLS push actions supported by
> + * the datapath. */

Huh? What does MPLS have to do with sampling?

> +static size_t
> +check_max_sample_nesting(struct dpif_backer *backer)
> +{
> +    struct odputil_keybuf keybuf;
> +    struct ofpbuf key;
> +    struct flow flow;
> +    int n;
> +
> +    struct odp_flow_key_parms odp_parms = {
> +        .flow = &flow,
> +    };
> +
> +    memset(&flow, 0, sizeof flow);
> +    ofpbuf_use_stack(&key, &keybuf, sizeof keybuf);
> +    odp_flow_key_from_flow(&odp_parms, &key);
> +
> +    /* OVS datapath has always supported at least 3 nested leves.  */

*levels
_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to