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 1FDBE37B7 for ; Mon, 28 May 2018 13:21:48 +0200 (CEST) Received: by mail-wm0-f66.google.com with SMTP id r15-v6so3675410wmc.1 for ; Mon, 28 May 2018 04:21:48 -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=UEBPNfuoJupVx8QvO99ADweAyJWlfkeFGC1YbSe+gFA=; b=1nesHfjwI4k7cT5dUhgnu8RYd8yqOk1yWViqZzJGjGwFZUC6jUp5ya1jytvqLcDBJi fatUt5F+Toux5mmugbuseU/8wvov5T7SG/uK+KSyHE7pI86ESKNJau+5oW/JtFucVK6M 4NHvaDjBt6U2n/WM3w8GnlDLP8wDZbTJUzY7pd8oSbYaj0yz/Pzddtx9yk6aC5eXQsFw Jq8TjGH609TveTxFdCROoMgsXoiDFEpHn4U1j2A4bXYE22N0xfk47BqPK+VYRxF83BCl 6NnQ6KrAbJV4pR7PHxON/ThkUytVsvlru2/gzM9I+yiSNHepoNZruJ3FoBRNSNfFJyIc w8Wg== 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=UEBPNfuoJupVx8QvO99ADweAyJWlfkeFGC1YbSe+gFA=; b=s9RhmIHoYEEVnkP4mfX+CTBtQprR6vw+AFD64w49i3fwu2Tzyq5vuInFvocPocwNBQ qnYcqwSALCxMwTFpwOUrkTMKlS86ML0zyn9VZSYgNXAn9o+xGtcpvWIaM8SPriRGEG/y 6bxIas/zR/+KVFaHN9Gpyhz4ROB7jxPOc/wY7ePr5cSJ2OOnc1p11FPxkMBzXvp+g0ls iZLj996693qWJb7j4hmLy4N3R2iT4AXsFt1+MPfGOFbWU2B8cEY6XH+vt1KqNJSIOvsZ y/qx/S8xj0A4zRaCA8sD2n8d1JejmPueLwk8PGKDRVL4T8lf1NLoDKTht/hPvFah1AF7 6Lyg== X-Gm-Message-State: ALKqPwfQMrsta5YMab4Tqo9+IZ49qojwPgU3tPcR9HDtlgUJBXe5vONL r1IaQ5oGkpDcIygG1dUbjV+ZLvI6aQ== X-Google-Smtp-Source: ADUXVKJI3dLW410SAJ8RWWqKwWlT2xf30p5783T/l0XXb0CuE1noa/sgpzZmUSp0rs8eEhzQbyO1Ew== X-Received: by 2002:a1c:1c85:: with SMTP id c127-v6mr9491299wmc.69.1527506507727; Mon, 28 May 2018 04:21:47 -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.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 May 2018 04:21:47 -0700 (PDT) From: Nelio Laranjeiro To: dev@dpdk.org, Adrien Mazarguil , Yongseok Koh Date: Mon, 28 May 2018 13:21:43 +0200 Message-Id: <1905b9674c6f3988aad149e86d85ecd809e78ece.1527506071.git.nelio.laranjeiro@6wind.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [DPDK 18.08 v1 10/12] 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: Mon, 28 May 2018 11:21:48 -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 66ebe6d36..ce1b4e94b 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -706,6 +706,58 @@ mlx5_flow_item_udp(const struct rte_flow_item *item, struct rte_flow *flow, return 0; } +/** + * Validate TCP 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_tcp(const struct rte_flow_item *item, struct rte_flow *flow, + 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->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_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; + 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); + flow->verbs.layers |= MLX5_FLOW_LAYER_L4_TCP; + return 0; +} + /** * Validate items provided by the user. * @@ -745,6 +797,9 @@ mlx5_flow_items(const struct rte_flow_item items[], case RTE_FLOW_ITEM_TYPE_UDP: ret = mlx5_flow_item_udp(items, flow, error); break; + case RTE_FLOW_ITEM_TYPE_TCP: + ret = mlx5_flow_item_tcp(items, flow, error); + break; default: return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ITEM, -- 2.17.0