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 4E61937B7 for ; Mon, 28 May 2018 13:21:46 +0200 (CEST) Received: by mail-wm0-f67.google.com with SMTP id r15-v6so3675237wmc.1 for ; Mon, 28 May 2018 04:21:46 -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=mb4lZcHUYjdm4sR7EnGlzzIjNrzVj3sV824+XjUBzkE=; b=wJ3/ZRAAnmDzh3Rr0JV7Y3Why/GJe7NHXL45M2Ujhf8A9XDAkdgwIY8HPU0AUT5GQ/ +aqZXJlYxkr5rduVS6TeDd45BPNs1/EBns64pW24B+IClRtjvUP92FskIRuCRAbcac74 4fwW2SmozqYGRKfghfCwjbcfTBm0cBTwvsojNCjzXncYrKIparnIx447zY6CWfF7tlw6 TAlvqXe4znSnmQOCD3ikLkMwEzXTEq3eG/yilIYdt8qyN6HJsNNTpW9qFfJOYwH1WXO4 5oNAkJL+oNXJ0h7YdF7mTF/7V+pixXo4YwPXzNJZsd6+J678+OuSVWhTe7Zwoz2dySoP eeAg== 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=mb4lZcHUYjdm4sR7EnGlzzIjNrzVj3sV824+XjUBzkE=; b=po1HQVsE38dhZ+7yaD8unPkUEu2YpPDcNz2Gml2TOG66R3jN+k/yXY6RkWPYD28Hg2 /9qDpzTLqwEhtN/X4mFMyJYQs8y2GINqZd6hi44WSujU8IVca5yDJOUKmrs+4HdxZTl0 UJ9K2fQfJPmR5PK+JPAGv5c1tmuLzGkCW6MpdNOSNfXjnL2ZomW9gXUWGI0sjY8XCr+n MrDD9KVjjUy/7IzYWs2+MMW6Txzs5FQsHcgv2F/TjrzYKBljhYUi46dUg+a79eeD8C2P egvQ5Tw+TLnacJE2bl1C8aBb74huKVLJW9PSFqvu9XjKBGIOZiVFQtKIZ31mM8y4WNCg 8dlQ== X-Gm-Message-State: ALKqPwe3lhXhXT/28rhfB87ZQPmkh5PTjW3kJ80rafKxggvXRqq19/ld 6qQ83nqi/4aF6yey99OcLe9gydZ6aQ== X-Google-Smtp-Source: ADUXVKI8kdJDvzS6t8wxOdFQznHauQiqI0spgZyF6lD3+FEKP7NobV9e/rZ+TycCELCbYhksL8Et8Q== X-Received: by 2002:a1c:5ec9:: with SMTP id s192-v6mr7667500wmb.54.1527506505873; Mon, 28 May 2018 04:21:45 -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:45 -0700 (PDT) From: Nelio Laranjeiro To: dev@dpdk.org, Adrien Mazarguil , Yongseok Koh Date: Mon, 28 May 2018 13:21:41 +0200 Message-Id: <7c69c571880e8596a6dba3ae7961f7550626c376.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 08/12] net/mlx5: add flow IPv6 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:46 -0000 Signed-off-by: Nelio Laranjeiro --- drivers/net/mlx5/mlx5_flow.c | 103 +++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 003c4aadd..6f3e50452 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -554,6 +554,106 @@ mlx5_flow_item_ipv4(const struct rte_flow_item *item, struct rte_flow *flow, return 0; } +/** + * Validate IPv6 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_ipv6(const struct rte_flow_item *item, struct rte_flow *flow, + struct rte_flow_error *error) +{ + const struct rte_flow_item_ipv6 *spec = item->spec; + const struct rte_flow_item_ipv6 *mask = item->mask; + const struct rte_flow_item_ipv6 nic_mask = { + .hdr = { + .src_addr = + "\xff\xff\xff\xff\xff\xff\xff\xff" + "\xff\xff\xff\xff\xff\xff\xff\xff", + .dst_addr = + "\xff\xff\xff\xff\xff\xff\xff\xff" + "\xff\xff\xff\xff\xff\xff\xff\xff", + .vtc_flow = RTE_BE32(0xffffffff), + .proto = 0xff, + .hop_limits = 0xff, + }, + }; + unsigned int size = sizeof(struct ibv_flow_spec_ipv6); + struct ibv_flow_spec_ipv6 ipv6 = { + .type = IBV_FLOW_SPEC_IPV6, + .size = size, + }; + int ret; + + if (flow->verbs.layers & MLX5_FLOW_LAYER_L3) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "multiple L3 layers not supported"); + else if (flow->verbs.layers & MLX5_FLOW_LAYER_L4) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "L3 cannot follow an L4 layer."); + if (!mask) + mask = &rte_flow_item_ipv6_mask; + ret = mlx5_flow_item_validate(item, (const uint8_t *)mask, + (const uint8_t *)&nic_mask, + sizeof(struct rte_flow_item_ipv6), error); + if (ret < 0) + return ret; + if (spec) { + unsigned int i; + uint32_t vtc_flow_val; + uint32_t vtc_flow_mask; + + memcpy(&ipv6.val.src_ip, spec->hdr.src_addr, + RTE_DIM(ipv6.val.src_ip)); + memcpy(&ipv6.val.dst_ip, spec->hdr.dst_addr, + RTE_DIM(ipv6.val.dst_ip)); + memcpy(&ipv6.mask.src_ip, mask->hdr.src_addr, + RTE_DIM(ipv6.mask.src_ip)); + memcpy(&ipv6.mask.dst_ip, mask->hdr.dst_addr, + RTE_DIM(ipv6.mask.dst_ip)); + vtc_flow_val = rte_be_to_cpu_32(spec->hdr.vtc_flow); + vtc_flow_mask = rte_be_to_cpu_32(mask->hdr.vtc_flow); + ipv6.val.flow_label = + rte_cpu_to_be_32((vtc_flow_val & IPV6_HDR_FL_MASK) >> + IPV6_HDR_FL_SHIFT); + ipv6.val.traffic_class = (vtc_flow_val & IPV6_HDR_TC_MASK) >> + IPV6_HDR_TC_SHIFT; + ipv6.val.next_hdr = spec->hdr.proto; + ipv6.val.hop_limit = spec->hdr.hop_limits; + ipv6.mask.flow_label = + rte_cpu_to_be_32((vtc_flow_mask & IPV6_HDR_FL_MASK) >> + IPV6_HDR_FL_SHIFT); + ipv6.mask.traffic_class = (vtc_flow_mask & IPV6_HDR_TC_MASK) >> + IPV6_HDR_TC_SHIFT; + ipv6.mask.next_hdr = mask->hdr.proto; + ipv6.mask.hop_limit = mask->hdr.hop_limits; + /* Remove unwanted bits from values. */ + for (i = 0; i < RTE_DIM(ipv6.val.src_ip); ++i) { + ipv6.val.src_ip[i] &= ipv6.mask.src_ip[i]; + ipv6.val.dst_ip[i] &= ipv6.mask.dst_ip[i]; + } + ipv6.val.flow_label &= ipv6.mask.flow_label; + ipv6.val.traffic_class &= ipv6.mask.traffic_class; + ipv6.val.next_hdr &= ipv6.mask.next_hdr; + ipv6.val.hop_limit &= ipv6.mask.hop_limit; + } + mlx5_flow_spec_verbs_add(flow, &ipv6, size); + flow->verbs.layers |= MLX5_FLOW_LAYER_L3_IPV6; + return 0; +} + /** * Validate items provided by the user. * @@ -587,6 +687,9 @@ mlx5_flow_items(const struct rte_flow_item items[], case RTE_FLOW_ITEM_TYPE_IPV4: ret = mlx5_flow_item_ipv4(items, flow, error); break; + case RTE_FLOW_ITEM_TYPE_IPV6: + ret = mlx5_flow_item_ipv6(items, flow, error); + break; default: return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ITEM, -- 2.17.0