From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by dpdk.org (Postfix) with ESMTP id E7D251BB30 for ; Fri, 13 Apr 2018 15:31:37 +0200 (CEST) Received: by mail-wm0-f66.google.com with SMTP id r191so5206997wmg.4 for ; Fri, 13 Apr 2018 06:31:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=uPEob3ibpGhy0MjtSGJcGsZ2Mlwa4Z74RM6ziaagnSg=; b=nhbwdL8vbIOH2ZssZNYfGGizoRytPp8enxIj7JkYXi1btLPoiZSpG5+QHDPqMpjrWO Gsbo2f5hk6n9XrFPZ5UWKdecN2Hu/i2QW4JGC3Qh1S037m83ZygaRF6xGOEYQvGBv+zO SqCy7/l+UvdGHTaMOCLeOuKaaSm3RX7zIqMo0P5d4XIzY9R5PxWlqhdjdecrJg9Woxs7 RbATbpaOz5KWZrqDjNA1JiiROmoat8ZBq2yqJuDbZ1yTIzLZXxmjF5DAIMHrXJZwbXOY CyCloZOT6ubNWkS6ywo8iyYLCtSF1xTcnw5z/+z8M1Rhxi4XNaHDo/90jr76SGAJvyoW mXqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=uPEob3ibpGhy0MjtSGJcGsZ2Mlwa4Z74RM6ziaagnSg=; b=kEUht/XnlRvZr5UGoOuzYpzfHj2nBLL3xZWr5nf+kzQXAKNDGamXXDOK8P7WLykUER zg9box9nCyCS3AD+39B0JNCR5iPPpGu9IiCs8D5aIdra4+dplLeOZ4Wv14j3T5cW4t1g uPvCS6IViTwfmSqRVUOLnuihSpWfZDOyDhIAxOstrvAtO7wi5R1W0YthZbeec3nknoDQ MpZAgm8ih4t0AGnymdN419Q+3AE67CCVOPukgUa/sz+ulPoOtaneVq8/P5I73ZaajzGE nfnUYn3WL94I/1xM66HeKQ4W2maIHM5C7wIlab7MFx5fjZyxly41HiVn8zp+HDjvIrXR HcNQ== X-Gm-Message-State: ALQs6tCJtT/ktsBCXApAHfVQCMmMoHcthpV748dVrHS93aq0ZJuN06hJ GPWSdfd59f7vk9gAqpmEkJ1R X-Google-Smtp-Source: AIpwx49A+ccRejydsuEz057/OeYv3Q9+1XlgU15a0HlxsSbzNONRsQWOT8JfH4x1NC7B6v+nrBs3pg== X-Received: by 10.28.224.194 with SMTP id x185mr3890230wmg.130.1523626297654; Fri, 13 Apr 2018 06:31:37 -0700 (PDT) Received: from laranjeiro-vm.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id 24sm8388276wrt.60.2018.04.13.06.31.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Apr 2018 06:31:37 -0700 (PDT) Date: Fri, 13 Apr 2018 15:32:01 +0200 From: =?iso-8859-1?Q?N=E9lio?= Laranjeiro To: Xueming Li Cc: Shahaf Shuler , dev@dpdk.org Message-ID: <20180413133201.me2murq4kgdcp4xy@laranjeiro-vm.dev.6wind.com> References: <20180410133415.189905-1-xuemingl%40mellanox.com> <20180413112023.106420-10-xuemingl@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180413112023.106420-10-xuemingl@mellanox.com> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [dpdk-dev] [PATCH v3 09/14] net/mlx5: introduce VXLAN-GPE tunnel type 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: Fri, 13 Apr 2018 13:31:38 -0000 Small nit, On Fri, Apr 13, 2018 at 07:20:18PM +0800, Xueming Li wrote: > Add VXLAN-GPE support to rte flow. Duplicating the title in the body seems not useful ;) > > Signed-off-by: Xueming Li > --- > drivers/net/mlx5/mlx5_flow.c | 95 +++++++++++++++++++++++++++++++++++++++++++- > drivers/net/mlx5/mlx5_rxtx.c | 3 +- > 2 files changed, 95 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c > index c99722770..19973b13c 100644 > --- a/drivers/net/mlx5/mlx5_flow.c > +++ b/drivers/net/mlx5/mlx5_flow.c > @@ -91,6 +91,11 @@ mlx5_flow_create_vxlan(const struct rte_flow_item *item, > struct mlx5_flow_data *data); > > static int > +mlx5_flow_create_vxlan_gpe(const struct rte_flow_item *item, > + const void *default_mask, > + struct mlx5_flow_data *data); > + > +static int > mlx5_flow_create_gre(const struct rte_flow_item *item, > const void *default_mask, > struct mlx5_flow_data *data); > @@ -241,10 +246,12 @@ struct rte_flow { > > #define IS_TUNNEL(type) ( \ > (type) == RTE_FLOW_ITEM_TYPE_VXLAN || \ > + (type) == RTE_FLOW_ITEM_TYPE_VXLAN_GPE || \ > (type) == RTE_FLOW_ITEM_TYPE_GRE) > > const uint32_t flow_ptype[] = { > [RTE_FLOW_ITEM_TYPE_VXLAN] = RTE_PTYPE_TUNNEL_VXLAN, > + [RTE_FLOW_ITEM_TYPE_VXLAN_GPE] = RTE_PTYPE_TUNNEL_VXLAN_GPE, > [RTE_FLOW_ITEM_TYPE_GRE] = RTE_PTYPE_TUNNEL_GRE, > }; > > @@ -253,6 +260,8 @@ const uint32_t flow_ptype[] = { > const uint32_t ptype_ext[] = { > [PTYPE_IDX(RTE_PTYPE_TUNNEL_VXLAN)] = RTE_PTYPE_TUNNEL_VXLAN | > RTE_PTYPE_L4_UDP, > + [PTYPE_IDX(RTE_PTYPE_TUNNEL_VXLAN_GPE)] = RTE_PTYPE_TUNNEL_VXLAN_GPE | > + RTE_PTYPE_L4_UDP, > [PTYPE_IDX(RTE_PTYPE_TUNNEL_GRE)] = RTE_PTYPE_TUNNEL_GRE, > }; > > @@ -310,6 +319,7 @@ static const struct mlx5_flow_items mlx5_flow_items[] = { > [RTE_FLOW_ITEM_TYPE_END] = { > .items = ITEMS(RTE_FLOW_ITEM_TYPE_ETH, > RTE_FLOW_ITEM_TYPE_VXLAN, > + RTE_FLOW_ITEM_TYPE_VXLAN_GPE, > RTE_FLOW_ITEM_TYPE_GRE), > }, > [RTE_FLOW_ITEM_TYPE_ETH] = { > @@ -388,7 +398,8 @@ static const struct mlx5_flow_items mlx5_flow_items[] = { > .dst_sz = sizeof(struct ibv_flow_spec_ipv6), > }, > [RTE_FLOW_ITEM_TYPE_UDP] = { > - .items = ITEMS(RTE_FLOW_ITEM_TYPE_VXLAN), > + .items = ITEMS(RTE_FLOW_ITEM_TYPE_VXLAN, > + RTE_FLOW_ITEM_TYPE_VXLAN_GPE), > .actions = valid_actions, > .mask = &(const struct rte_flow_item_udp){ > .hdr = { > @@ -440,6 +451,19 @@ static const struct mlx5_flow_items mlx5_flow_items[] = { > .convert = mlx5_flow_create_vxlan, > .dst_sz = sizeof(struct ibv_flow_spec_tunnel), > }, > + [RTE_FLOW_ITEM_TYPE_VXLAN_GPE] = { > + .items = ITEMS(RTE_FLOW_ITEM_TYPE_ETH, > + RTE_FLOW_ITEM_TYPE_IPV4, > + RTE_FLOW_ITEM_TYPE_IPV6), > + .actions = valid_actions, > + .mask = &(const struct rte_flow_item_vxlan_gpe){ > + .vni = "\xff\xff\xff", > + }, > + .default_mask = &rte_flow_item_vxlan_gpe_mask, > + .mask_sz = sizeof(struct rte_flow_item_vxlan_gpe), > + .convert = mlx5_flow_create_vxlan_gpe, > + .dst_sz = sizeof(struct ibv_flow_spec_tunnel), > + }, > }; > > /** Structure to pass to the conversion function. */ > @@ -1786,6 +1810,75 @@ mlx5_flow_create_vxlan(const struct rte_flow_item *item, > } > > /** > + * Convert VXLAN-GPE item to Verbs specification. > + * > + * @param item[in] > + * Item specification. > + * @param default_mask[in] > + * Default bit-masks to use when item->mask is not provided. > + * @param data[in, out] > + * User structure. > + * > + * @return > + * 0 on success, a negative errno value otherwise and rte_errno is set. > + */ > +static int > +mlx5_flow_create_vxlan_gpe(const struct rte_flow_item *item, > + const void *default_mask, > + struct mlx5_flow_data *data) > +{ > + const struct rte_flow_item_vxlan_gpe *spec = item->spec; > + const struct rte_flow_item_vxlan_gpe *mask = item->mask; > + struct mlx5_flow_parse *parser = data->parser; > + unsigned int size = sizeof(struct ibv_flow_spec_tunnel); > + struct ibv_flow_spec_tunnel vxlan = { > + .type = parser->inner | IBV_FLOW_SPEC_VXLAN_TUNNEL, > + .size = size, > + }; > + union vni { > + uint32_t vlan_id; > + uint8_t vni[4]; > + } id; > + int r; > + > + id.vni[0] = 0; > + parser->inner = IBV_FLOW_SPEC_INNER; > + parser->tunnel = ptype_ext[PTYPE_IDX(RTE_PTYPE_TUNNEL_VXLAN_GPE)]; > + parser->out_layer = parser->layer; > + parser->layer = HASH_RXQ_TUNNEL; > + if (spec) { > + if (!mask) > + mask = default_mask; > + memcpy(&id.vni[1], spec->vni, 3); > + vxlan.val.tunnel_id = id.vlan_id; > + memcpy(&id.vni[1], mask->vni, 3); > + vxlan.mask.tunnel_id = id.vlan_id; > + if (spec->protocol) { > + r = EINVAL; > + return r; rte_errno is not set and the returned value is positive. > + } > + /* Remove unwanted bits from values. */ > + vxlan.val.tunnel_id &= vxlan.mask.tunnel_id; > + } > + /* > + * Tunnel id 0 is equivalent as not adding a VXLAN layer, if only this > + * layer is defined in the Verbs specification it is interpreted as > + * wildcard and all packets will match this rule, if it follows a full > + * stack layer (ex: eth / ipv4 / udp), all packets matching the layers > + * before will also match this rule. > + * To avoid such situation, VNI 0 is currently refused. > + */ > + /* Only allow tunnel w/o tunnel id pattern after proper outer spec. */ > + if (parser->out_layer == HASH_RXQ_ETH && !vxlan.val.tunnel_id) > + return rte_flow_error_set(data->error, EINVAL, > + RTE_FLOW_ERROR_TYPE_ITEM, > + item, > + "VxLAN-GPE vni cannot be 0"); > + mlx5_flow_create_copy(parser, &vxlan, size); > + return 0; > +} > + > +/** > * Convert GRE item to Verbs specification. > * > * @param item[in] > diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c > index 285b2dbf0..c9342d659 100644 > --- a/drivers/net/mlx5/mlx5_rxtx.c > +++ b/drivers/net/mlx5/mlx5_rxtx.c > @@ -466,8 +466,7 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n) > uint8_t vlan_sz = > (buf->ol_flags & PKT_TX_VLAN_PKT) ? 4 : 0; > const uint64_t is_tunneled = > - buf->ol_flags & (PKT_TX_TUNNEL_GRE | > - PKT_TX_TUNNEL_VXLAN); > + buf->ol_flags & (PKT_TX_TUNNEL_MASK); > > tso_header_sz = buf->l2_len + vlan_sz + > buf->l3_len + buf->l4_len; > -- > 2.13.3 > Thanks, -- Nélio Laranjeiro 6WIND