From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by dpdk.org (Postfix) with ESMTP id 4CEA537B0 for ; Mon, 28 May 2018 13:21:47 +0200 (CEST) Received: by mail-wm0-f68.google.com with SMTP id q4-v6so23668968wmq.1 for ; Mon, 28 May 2018 04:21:47 -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:in-reply-to :references; bh=Lu1VixRzqVGn5sQef3sGBEZYgiXGw/+TA6a1G6CDHTM=; b=PYfZGRcuAwH9wNVGm7G8/n8yrqImEEyZPVzmB2+Ca1pOkqdunedSSR7mEFuzF0LlQT HWaZviRF5bSI7BtLuvTFiqc+alcVHJdpnMMr8TX6GsbMcxbMlyCz0KbEqLbyGiHKF3X3 kx23X+gbO9rqXMx0weBCHhrTHQefizXT/KrTUvvdztBaJ8QOGRNa7sBzkTI4fRFiYQvw 9J7IsSfNNz1uY4reP1kGAcmiShX/prOb+7WC4SIg0HGi7SQYicfMmYMzW+fX1ZbEMa6h RBgLZzzzWs+RqH5jxWhx9hoXC4NAWw2D71od3fsXjvw6G4YcNnVzn230qCoa/1aQgFIw hQNQ== 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:in-reply-to:references; bh=Lu1VixRzqVGn5sQef3sGBEZYgiXGw/+TA6a1G6CDHTM=; b=F3Dhtm89lUHVxbaAQMrb5433guN7l3kF+spGAQVGj6Iyh58jdq26gWOXVhrOzBKyUo +40M00adV+hvIVkr19zzgVpfk4K0QGAiKb1VxA3/QG0NMzykiDytjp73qZK0oBLQQ5JP ztdJ7KIrgXGdJS/wQjHSvVA2tCvXOYASL5LOn1P17wkJ5XNUkQ6PFcxWACwy/FF30Vrb CW9potKjKH0FwSyDGrtTiq18H1QI0dkPAa8YFquAi3Fpf8jg+ObHX+In6PZNkEgkP9kI Sp7GaRFlSut+Q+R3V72W4P1pS6vuEfmZQUVchsrRmMOqwE1uUfx05uiL/FOqFxJbRlyy 3eeQ== X-Gm-Message-State: ALKqPweEHo3CIXBQ6NOoZ4EHPYbCFtamHB4IKafTwzl6V/ocD8E4yx6A 4TQTqHRzoZXAqbDg1npsnWZPzgSueg== X-Google-Smtp-Source: ADUXVKJ8Lk18Gq/8vi5g5/e1Jy1AlULWeSZ7blVYd3RG11nM+vRMv673QrTqSWcOAH3P+HRRQoZ9rA== X-Received: by 2002:a1c:95d3:: with SMTP id x202-v6mr9479710wmd.52.1527506506872; Mon, 28 May 2018 04:21:46 -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 q81-v6sm20755444wmd.14.2018.05.28.04.21.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 May 2018 04:21:46 -0700 (PDT) From: Nelio Laranjeiro To: dev@dpdk.org, Adrien Mazarguil , Yongseok Koh Date: Mon, 28 May 2018 13:21:42 +0200 Message-Id: X-Mailer: git-send-email 2.17.0 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [DPDK 18.08 v1 09/12] 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: Mon, 28 May 2018 11:21:47 -0000 Signed-off-by: Nelio Laranjeiro --- drivers/net/mlx5/mlx5_flow.c | 55 ++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 6f3e50452..66ebe6d36 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -654,6 +654,58 @@ mlx5_flow_item_ipv6(const struct rte_flow_item *item, struct rte_flow *flow, return 0; } +/** + * Validate UDP layer and possibly create the Verbs specification. + * + * @param item[in] + * Item specification. + * @param flow[in, out] + * Pointer to flow structure. + * @param error + * Pointer to error structure. + * + * @return + * 0 on success, 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, + 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->verbs.layers & MLX5_FLOW_LAYER_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; + 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); + flow->verbs.layers |= MLX5_FLOW_LAYER_L4_UDP; + return 0; +} + /** * Validate items provided by the user. * @@ -690,6 +742,9 @@ mlx5_flow_items(const struct rte_flow_item items[], case RTE_FLOW_ITEM_TYPE_IPV6: ret = mlx5_flow_item_ipv6(items, flow, error); break; + case RTE_FLOW_ITEM_TYPE_UDP: + ret = mlx5_flow_item_udp(items, flow, error); + break; default: return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ITEM, -- 2.17.0