From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id E835A11C5 for ; Tue, 21 Mar 2017 18:10:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1490116225; x=1521652225; h=subject:to:references:cc:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=s9Q+MlJZ1XVIK6dTpVIAqVD8w1wHuWPci7GmkdaLJCM=; b=H0+jO1fSluIAiRd/lgCutzlVcMWnYWW59dYtb3yya2423lx5ofwDE4yN Th7kbM/ZDdL4jRdv4Zl7+79j/yQTAg==; Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Mar 2017 10:10:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,200,1486454400"; d="scan'208";a="79493779" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.237.220.122]) ([10.237.220.122]) by fmsmga006.fm.intel.com with ESMTP; 21 Mar 2017 10:10:23 -0700 To: Pascal Mazon , keith.wiles@intel.com References: Cc: dev@dpdk.org From: Ferruh Yigit Message-ID: <75248f99-c164-9399-049c-6529d5255978@intel.com> Date: Tue, 21 Mar 2017 17:10:22 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH v5 4/4] net/tap: add basic flow API patterns and actions X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Mar 2017 17:10:25 -0000 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 > Acked-by: Olga Shern <...> > +/** > + * 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; > } <...>