From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by dpdk.org (Postfix) with ESMTP id A9F2B1BFBD for ; Wed, 27 Jun 2018 17:07:44 +0200 (CEST) Received: by mail-wm0-f67.google.com with SMTP id v16-v6so6258393wmv.5 for ; Wed, 27 Jun 2018 08:07:44 -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=Frq/IvDC/kZVPBS4+K4m6e76igHSD27sGRakRKDd7dc=; b=beh8fQWkfTOjdgPy+J1QMkiZJweqzsez3+zYg3YRHjEqqrQFJfsEmTj3oKGq7MqxlD O62tynaK2BcSIyohvcICYLWg7p8IapHwhrHZyh65ZgpZbI8Dw/wwDtmuoio3wAy8Lqdo Lp6Z14X6lB4YWKOJnSnv6zIm3tky5ojFRx0Mafd7yI3J0uEdRTAQnJ3xvw7t4GoCQeck TdkUXVuJbdIJnFT/uBtCCMmhnYJOD5XDUtyQSfR5qOBxjhtlVVwcCo5TCE+bhkZTN8y5 RYhep1O7RiLdxdSLBomxZqf384muElGkdD7skC93hTR8J0EHxkXNJkhKvjr91j6h+FFq 1C5Q== 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=Frq/IvDC/kZVPBS4+K4m6e76igHSD27sGRakRKDd7dc=; b=e7JVpPgAkiF3FjADxYVLc3QFng6an475CjKfMM//Kr35OZbrQyd3BlvJ+4wS0owwSv 32Qn2I7kLN/vUA6vdQtTV+e3/dNCSz8yaCVauTd8JJj7PoVvrL1q6XikybJ5ehnsAEja VX5tRb9+AfD7s2uk0rb03c9sPRmmEVWxQxW5/kgiOZpqqS3SC5x6hrESX+slDyMFBWov 6otSQUszsiOuJCeUPP4ZRGOim7drJhzLsITLT7nEK3O9Yzw/2d0PYnhlpWJDXiabUWiQ JIdu48zcnY63UOb9UM1ps4zA9K0xT4XaUDGpnmrLdPac6s+3Ay+ffUfTZ4TBNvlnwtwK paLA== X-Gm-Message-State: APt69E1xe40aqJc08ylb52RCPRzDOEj7n5PIM4adfIt7mzS/5A6MrSrw L4eQxZ8TPKPndBEV+V8TBZURAfzXAQ== X-Google-Smtp-Source: AAOMgpeg/p/WDC5nwrC8y6dJ5k0n+xLmhkUGeoEYLXipzQxNeeVFTLJXOtD3ssyhmzYr76fyyNWIjQ== X-Received: by 2002:a1c:4405:: with SMTP id r5-v6mr4984882wma.62.1530112064230; Wed, 27 Jun 2018 08:07:44 -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.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jun 2018 08:07:43 -0700 (PDT) From: Nelio Laranjeiro To: dev@dpdk.org, Adrien Mazarguil , Yongseok Koh Date: Wed, 27 Jun 2018 17:07:43 +0200 Message-Id: <2e0decb7243290b23f782e7e4d9a4f689d9afbd4.1530111623.git.nelio.laranjeiro@6wind.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2 11/20] net/mlx5: add flow TCP 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 06b4b7f41..57f072c03 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -787,6 +787,68 @@ mlx5_flow_item_udp(const struct rte_flow_item *item, struct rte_flow *flow, return size; } +/** + * Validate TCP 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_tcp(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_tcp *spec = item->spec; + const struct rte_flow_item_tcp *mask = item->mask; + unsigned int size = sizeof(struct ibv_flow_spec_tcp_udp); + struct ibv_flow_spec_tcp_udp tcp = { + .type = IBV_FLOW_SPEC_TCP, + .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_tcp_mask; + ret = mlx5_flow_item_validate(item, (const uint8_t *)mask, + (const uint8_t *)&rte_flow_item_tcp_mask, + sizeof(struct rte_flow_item_tcp), error); + if (ret < 0) + return ret; + flow->layers |= MLX5_FLOW_LAYER_OUTER_L4_TCP; + if (size > flow_size) + return size; + if (spec) { + tcp.val.dst_port = spec->hdr.dst_port; + tcp.val.src_port = spec->hdr.src_port; + tcp.mask.dst_port = mask->hdr.dst_port; + tcp.mask.src_port = mask->hdr.src_port; + /* Remove unwanted bits from values. */ + tcp.val.src_port &= tcp.mask.src_port; + tcp.val.dst_port &= tcp.mask.dst_port; + } + mlx5_flow_spec_verbs_add(flow, &tcp, size); + return size; +} + /** * Validate items provided by the user. * @@ -832,6 +894,9 @@ mlx5_flow_items(const struct rte_flow_item items[], case RTE_FLOW_ITEM_TYPE_UDP: ret = mlx5_flow_item_udp(items, flow, remain, error); break; + case RTE_FLOW_ITEM_TYPE_TCP: + ret = mlx5_flow_item_tcp(items, flow, remain, error); + break; default: return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ITEM, -- 2.18.0