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 CF1A51BFB0 for ; Wed, 27 Jun 2018 17:07:43 +0200 (CEST) Received: by mail-wm0-f66.google.com with SMTP id v16-v6so6258343wmv.5 for ; Wed, 27 Jun 2018 08:07:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=TrmUpaRcs/BmUCmQW9OU8vetXvfYA1JJPh7xJYIuHlI=; b=k5VhVdROHLF704R4o9HSK9vzSC9vWBzrp2eIFiCyPDwYttuEy2zbe2qg98Q4SQiEyA +dHtyAg/h9UWD5D4QHlVEzl91WjtioHWEinzjj+E9idPMcfL4x1kVkX17Hex/srnr/50 htCdaAeBeyqwmHsj0vw/6ig0mK7QvHBrLctLYv83VSnu0P9W97ZX89ZH7IqeupPM8hNu keVXJY2moT+dkmsn3YNPtMogOVGMWqH95oDsIeVF/FAH+X44xEWy28oo2K77eqVfQXEf 82rr/aROnwBS4SDOVhpLTrzIBbOCDeW/GHTn5od1wJepQ/JTPfPiqEXzF/IVKq0uIuhR 8baw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=TrmUpaRcs/BmUCmQW9OU8vetXvfYA1JJPh7xJYIuHlI=; b=EcsJEkxsgRGmTIaBCtSOI5psc6Z9sTuCLQDZHJ7awra691SF6jD04UX4x6hCNh78og Tlv2Rj+QnIzpZd//X4x4SxGJKguMolnNZdZMNhPIrjrIbRlsk7GTEV0+DpYZO4yIOoZb JI0uEg1yx5v22rjxd2K8JW4Lzur8lQtRpSJ1FkDCYcAjYz0NnNaEF5Czu8qJNPYL2MmF K1yBGirqPSvsVkE4j8/WV90axJzs5spGxtYxKkCMFVWYjWktN8wAVnLcXSwXv/N60lzc 2kofkAF9ptB0UgBefD6HMcXh2qMON35Stqxfb8170gIjoxL8ubMYNy05orI/LcL+Zr10 k8vw== X-Gm-Message-State: APt69E0pIgSZ3De02/3EsNuHdno7YSPawO3PUFRXe7OjTeeHPmPMADbw kzsUZkhB367w837HvxMqT/P/IJuJnA== X-Google-Smtp-Source: AAOMgpfmv5Xq75prgQDkyJIHbHC198uycVm1vFQIHPOuMOuinSuOcV7AHM/rOV07bnJ9XmK0Aes+1A== X-Received: by 2002:a1c:34c9:: with SMTP id b192-v6mr5478103wma.21.1530112063368; Wed, 27 Jun 2018 08:07:43 -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 k17-v6sm4872513wrp.19.2018.06.27.08.07.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jun 2018 08:07:42 -0700 (PDT) From: Nelio Laranjeiro To: dev@dpdk.org, Adrien Mazarguil , Yongseok Koh Date: Wed, 27 Jun 2018 17:07:42 +0200 Message-Id: X-Mailer: git-send-email 2.18.0 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2 10/20] net/mlx5: add flow UDP 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: , X-List-Received-Date: Wed, 27 Jun 2018 15:07:44 -0000 Signed-off-by: Nelio Laranjeiro --- drivers/net/mlx5/mlx5_flow.c | 65 ++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 4e018400a..06b4b7f41 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -725,6 +725,68 @@ mlx5_flow_item_ipv6(const struct rte_flow_item *item, struct rte_flow *flow, return size; } +/** + * Validate UDP layer and possibly create the Verbs specification. + * + * @param item[in] + * Item specification. + * @param flow[in, out] + * Pointer to flow structure. + * @param flow_size[in] + * Size in bytes of the available space for to store the flow information. + * @param error + * Pointer to error structure. + * + * @return + * size in bytes necessary for the conversion, a negative errno value + * otherwise and rte_errno is set. + */ +static int +mlx5_flow_item_udp(const struct rte_flow_item *item, struct rte_flow *flow, + const size_t flow_size, struct rte_flow_error *error) +{ + const struct rte_flow_item_udp *spec = item->spec; + const struct rte_flow_item_udp *mask = item->mask; + unsigned int size = sizeof(struct ibv_flow_spec_tcp_udp); + struct ibv_flow_spec_tcp_udp udp = { + .type = IBV_FLOW_SPEC_UDP, + .size = size, + }; + int ret; + + if (!(flow->layers & MLX5_FLOW_LAYER_OUTER_L3)) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "L3 is mandatory to filter on L4"); + if (flow->layers & MLX5_FLOW_LAYER_OUTER_L4) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "L4 layer is already present"); + if (!mask) + mask = &rte_flow_item_udp_mask; + ret = mlx5_flow_item_validate(item, (const uint8_t *)mask, + (const uint8_t *)&rte_flow_item_udp_mask, + sizeof(struct rte_flow_item_udp), error); + if (ret < 0) + return ret; + flow->layers |= MLX5_FLOW_LAYER_OUTER_L4_UDP; + if (size > flow_size) + return size; + if (spec) { + udp.val.dst_port = spec->hdr.dst_port; + udp.val.src_port = spec->hdr.src_port; + udp.mask.dst_port = mask->hdr.dst_port; + udp.mask.src_port = mask->hdr.src_port; + /* Remove unwanted bits from values. */ + udp.val.src_port &= udp.mask.src_port; + udp.val.dst_port &= udp.mask.dst_port; + } + mlx5_flow_spec_verbs_add(flow, &udp, size); + return size; +} + /** * Validate items provided by the user. * @@ -767,6 +829,9 @@ mlx5_flow_items(const struct rte_flow_item items[], case RTE_FLOW_ITEM_TYPE_IPV6: ret = mlx5_flow_item_ipv6(items, flow, remain, error); break; + case RTE_FLOW_ITEM_TYPE_UDP: + ret = mlx5_flow_item_udp(items, flow, remain, error); + break; default: return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ITEM, -- 2.18.0