[dpdk-dev] [PATCH v5 4/4] net/tap: add basic flow API patterns and actions

Ferruh Yigit ferruh.yigit at intel.com
Tue Mar 21 18:10:22 CET 2017


On 3/15/2017 2:54 PM, Pascal Mazon wrote:
> Supported flow rules are now mapped to TC rules on the tap netdevice.
> The netlink message used for creating the TC rule is stored in struct
> rte_flow. That way, by simply changing a metadata in it, we can require
> for the rule deletion without further parsing.
> 
> Supported items:
> - eth: src and dst (with variable masks), and eth_type (0xffff mask).
> - vlan: vid, pcp, tpid, but not eid.
> - ipv4/6: src and dst (with variable masks), and ip_proto (0xffff mask).
> - udp/tcp: src and dst port (0xffff) mask.
> 
> Supported actions:
> - DROP
> - QUEUE
> - PASSTHRU
> 
> It is generally not possible to provide a "last" item. However, if the
> "last" item, once masked, is identical to the masked spec, then it is
> supported.
> 
> Only IPv4/6 and MAC addresses can use a variable mask. All other
> items need a full mask (exact match).
> 
> Support for VLAN requires kernel headers >= 4.9, checked using
> auto-config.sh.
> 
> Signed-off-by: Pascal Mazon <pascal.mazon at 6wind.com>
> Acked-by: Olga Shern <olgas at mellanox.com>

<...>

> +/**
> + * Set a unique handle in a flow.
> + *
> + * The kernel supports TC rules with equal priority, as long as they use the
> + * same matching fields (e.g.: dst mac and ipv4) with different values (and
> + * full mask to ensure no collision is possible).
> + * In those rules, the handle (uint32_t) is the part that would identify
> + * specifically each rule.
> + *
> + * On 32-bit architectures, the handle can simply be the flow's pointer address.
> + * On 64-bit architectures, we rely on jhash(flow) to find a (sufficiently)
> + * unique handle.
> + *
> + * @param[in, out] flow
> + *   The flow that needs its handle set.
> + */
> +static void
> +tap_flow_set_handle(struct rte_flow *flow)
> +{
> +	uint32_t handle = 0;
> +
> +#if !defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ == 8
> +	handle = rte_jhash(&flow, sizeof(flow), 1);
> +#else
> +	if (sizeof(flow) == 4) {
> +		/* 32-bits arch */
> +		uint64_t h = (uint64_t)flow;

This line is causing build error for i686 target:

.../drivers/net/tap/tap_flow.c: In function ‘tap_flow_set_handle’:
.../drivers/net/tap/tap_flow.c:917:16:
error: cast from pointer to integer of different size
[-Werror=pointer-to-int-cast]
   uint64_t h = (uint64_t)flow;
                ^

> +
> +		handle = (uint32_t)h;
> +	} else {
> +		handle = rte_jhash(&flow, sizeof(flow), 1);
> +	}
> +#endif
> +	/* must be at least 1 to avoid letting the kernel choose one for us */
> +	if (!handle)
> +		handle = 1;
> +	flow->msg.t.tcm_handle = handle;
>  }

<...>


More information about the dev mailing list