From patchwork Thu Dec 29 15:15:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?N=C3=A9lio_Laranjeiro?= X-Patchwork-Id: 18673 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 92821F618; Thu, 29 Dec 2016 16:16:48 +0100 (CET) Received: from mail-wj0-f182.google.com (mail-wj0-f182.google.com [209.85.210.182]) by dpdk.org (Postfix) with ESMTP id 0084137A8 for ; Thu, 29 Dec 2016 16:15:44 +0100 (CET) Received: by mail-wj0-f182.google.com with SMTP id c11so155159579wjx.3 for ; Thu, 29 Dec 2016 07:15:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=2f7zUpPJVdG4lhJawpOCkn4+PkoE6+l+kdeksS4t7ic=; b=o4NjP6jlI/z0tqcD3k1LlgBovl9/O7PdFV5ia9pecgJG2QGKki92Tb+zFwLEcp2cE9 KgKJ2axnEswN1K1G6S/BcIkv3hfjkzaJ2VebmeTqStKnObNz+vOof+AJ625RhrtwxRe8 MTa0oE0/b8zQ3ehTvZpBI/ZsMv/NV9K8r+Jj3jEQAGzBfk/a4uEY+phIJWE8eaz2QiD+ lVo9lGiyavrKyvfEZYnb/bT8Wre4UwPHuf3BYGhdDMjMMxchSx9tLAUnOqV1kGB3IhMC aJG2TLQtAkLl7aPF9O3RV2f7t6LLMAHOwzKWHllz+H+mNvn7YT3/3uZ0NMpF7F+GMeue v4gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=2f7zUpPJVdG4lhJawpOCkn4+PkoE6+l+kdeksS4t7ic=; b=YBFuw5ODio82FYkdK0kZxUfyAthTXbBSclReMi53BMDcyrdVAd5xjMyFaVQZpZQGrZ fLf0BDPkIkoSfMQEInoiKlyb9sn4lnv6CnHuPhKUHUdFjUtth0URw9Zt3Ffgvy27tCc6 HfcCj8n2/4751E8aTJYJvHjWSajkxaPdNGb/4tR9UXOIy8FRFW//iJ8Q8srIzmPHIZYL YxsPxCyqpZVkuUvFE92CZnueH5qL0fOLrFy0HwR1mzaF2GupS6aZotl8Jnefk2MnuXA5 RrMiHY0IlUX/z1Io6G3whGaDWKxtue4u3+Hdf2+Sc+o+G93hb3iIeMiTHriJT+rturQn W3sw== X-Gm-Message-State: AIkVDXJD5XI+aN1oh4YVvEL+PK0tmfG2ElP2QuQQD4vJKorFhG1Bbv5eeoPZtCX/L4YyPcGZ X-Received: by 10.194.178.170 with SMTP id cz10mr36045919wjc.224.1483024544404; Thu, 29 Dec 2016 07:15:44 -0800 (PST) Received: from ping.vm.6wind.com (guy78-3-82-239-227-177.fbx.proxad.net. [82.239.227.177]) by smtp.gmail.com with ESMTPSA id o3sm69289997wjx.39.2016.12.29.07.15.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Dec 2016 07:15:43 -0800 (PST) From: Nelio Laranjeiro To: dev@dpdk.org, Ferruh Yigit Cc: Adrien Mazarguil Date: Thu, 29 Dec 2016 16:15:22 +0100 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v5 6/6] net/mlx5: extend IPv4 flow item 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This commits adds: - Type of service - Next protocol ID Signed-off-by: Nelio Laranjeiro Acked-by: Adrien Mazarguil --- drivers/net/mlx5/mlx5_flow.c | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 0e7ea99..d7ed686 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -111,6 +111,12 @@ struct mlx5_flow_items { const enum rte_flow_action_type *const actions; /** Bit-masks corresponding to the possibilities for the item. */ const void *mask; + /** + * Default bit-masks to use when item->mask is not provided. When + * \default_mask is also NULL, the full supported bit-mask (\mask) is + * used instead. + */ + const void *default_mask; /** Bit-masks size in bytes. */ const unsigned int mask_sz; /** @@ -181,11 +187,19 @@ static const struct mlx5_flow_items mlx5_flow_items[] = { .hdr = { .src_addr = -1, .dst_addr = -1, + .type_of_service = -1, + .next_proto_id = -1, + }, + }, + .default_mask = &(const struct rte_flow_item_ipv4){ + .hdr = { + .src_addr = -1, + .dst_addr = -1, }, }, .mask_sz = sizeof(struct rte_flow_item_ipv4), .convert = mlx5_flow_create_ipv4, - .dst_sz = sizeof(struct ibv_exp_flow_spec_ipv4), + .dst_sz = sizeof(struct ibv_exp_flow_spec_ipv4_ext), }, [RTE_FLOW_ITEM_TYPE_IPV6] = { .items = ITEMS(RTE_FLOW_ITEM_TYPE_UDP, @@ -425,7 +439,11 @@ priv_flow_validate(struct priv *priv, if (err) goto exit_item_not_supported; if (flow->ibv_attr && cur_item->convert) { - err = cur_item->convert(items, cur_item->mask, flow); + err = cur_item->convert(items, + (cur_item->default_mask ? + cur_item->default_mask : + cur_item->mask), + flow); if (err) goto exit_item_not_supported; } @@ -598,31 +616,37 @@ mlx5_flow_create_ipv4(const struct rte_flow_item *item, const struct rte_flow_item_ipv4 *spec = item->spec; const struct rte_flow_item_ipv4 *mask = item->mask; struct mlx5_flow *flow = (struct mlx5_flow *)data; - struct ibv_exp_flow_spec_ipv4 *ipv4; - unsigned int ipv4_size = sizeof(struct ibv_exp_flow_spec_ipv4); + struct ibv_exp_flow_spec_ipv4_ext *ipv4; + unsigned int ipv4_size = sizeof(struct ibv_exp_flow_spec_ipv4_ext); ++flow->ibv_attr->num_of_specs; flow->ibv_attr->priority = 1; ipv4 = (void *)((uintptr_t)flow->ibv_attr + flow->offset); - *ipv4 = (struct ibv_exp_flow_spec_ipv4) { - .type = flow->inner | IBV_EXP_FLOW_SPEC_IPV4, + *ipv4 = (struct ibv_exp_flow_spec_ipv4_ext) { + .type = flow->inner | IBV_EXP_FLOW_SPEC_IPV4_EXT, .size = ipv4_size, }; if (!spec) return 0; if (!mask) mask = default_mask; - ipv4->val = (struct ibv_exp_flow_ipv4_filter){ + ipv4->val = (struct ibv_exp_flow_ipv4_ext_filter){ .src_ip = spec->hdr.src_addr, .dst_ip = spec->hdr.dst_addr, + .proto = spec->hdr.next_proto_id, + .tos = spec->hdr.type_of_service, }; - ipv4->mask = (struct ibv_exp_flow_ipv4_filter){ + ipv4->mask = (struct ibv_exp_flow_ipv4_ext_filter){ .src_ip = mask->hdr.src_addr, .dst_ip = mask->hdr.dst_addr, + .proto = mask->hdr.next_proto_id, + .tos = mask->hdr.type_of_service, }; /* Remove unwanted bits from values. */ ipv4->val.src_ip &= ipv4->mask.src_ip; ipv4->val.dst_ip &= ipv4->mask.dst_ip; + ipv4->val.proto &= ipv4->mask.proto; + ipv4->val.tos &= ipv4->mask.tos; return 0; }