From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8474DA0A0F; Wed, 30 Jun 2021 09:05:27 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7F7784123F; Wed, 30 Jun 2021 09:05:20 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2081.outbound.protection.outlook.com [40.107.244.81]) by mails.dpdk.org (Postfix) with ESMTP id 818194123D for ; Wed, 30 Jun 2021 09:05:19 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CGSlghrik9exRJGsB0e9WLqiuhhqd38Y31dxRy2NfFDcEdTX+9g+b3WDkxZfK1u40fMocE/maPH0WJdy9d0D/PKLpjXwyz0rTHPk9ZE4VpLF6I/pJKiDvlyTgfywV7+1PnlM/h7qkzCuDaXCvQ/OBTHX6A9noP5jBy/rTRx/0UgMgkUdUzwjeDeVqi2ce3qrullvLu6MVFUV/MNYDfiSkOR4QKY7Jsrk4BO1EeEAOZMHe5bNrzgzPFdspWGD4sSSouggXAFQbCCwRsjcgijxQuZ6b+u6hStZbhssv0T447Fii0SbNBt1oTFVvLvUhzjQn+3ZT1IUGkE3zsgjI6hL3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=c4kHAliesll5IZPjPkMlO7/HME/lRZ0VXa81mD07OBU=; b=Zqzo4vqHZ+LSfmN8z8HcWJqdxMqNr89ELCiusRfoMtXhRhXCWjgsOjoUlrpOGW2wwxmfX58TaCZPqg05MXVrstTBmOGscyysDS6v1luMDJId3E30Gdy99YpRmXcLEwzkFTDrifWReqZXCkQpo0Z3ttp8SWTDwDRDiNSqo5rQc5QEBU4qMUIJmuA0Pf5fIJ4vZ5r60IqKLw/YRib8SnJnzDAQ6T0ipYeHFlQBh80vW9UYi4tzUFUEuTjHsDs1rhMNy0jZc2ChmuHAJ0+EatWUCo9CosqiFITqDJK8BTUWaBJRAX1uIIoOxUu7sZNE4iirAVVo4bJGeEOdIO3aBsV2Fg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=c4kHAliesll5IZPjPkMlO7/HME/lRZ0VXa81mD07OBU=; b=rqbaVWcq24ih93Z6geAB2Z6vw3Elea3IQlQXD9Qtdvro9qIFybWmcUtGwngoZszYNo2VirLEAgs1fQKxyIpT4/g+6xKyUXQUf70kCiaXGUs/RBzEbxJ6MJ7nRZ/Wyb9FdAGj8S52iwp7t2ltqByNXeqjt/5abiqdRzMpFzyX61R5PZT4+dWJaKxs2yqzLpyLb0yPGwaZFmN933OrxaaM7GpOjOcKgShxWAXSCjG56H0FEwyrM5ykPU2kklnEyHiMwSawMRusAChHSg/8SRD+u9xoFkqI30kfSg1S01d64HaLprM+BAQIlKJleBSPgh9NasDS2RKU4QFPP0zExnlqHw== Received: from DM6PR02CA0089.namprd02.prod.outlook.com (2603:10b6:5:1f4::30) by MN2PR12MB3309.namprd12.prod.outlook.com (2603:10b6:208:106::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.23; Wed, 30 Jun 2021 07:05:18 +0000 Received: from DM6NAM11FT040.eop-nam11.prod.protection.outlook.com (2603:10b6:5:1f4:cafe::a3) by DM6PR02CA0089.outlook.office365.com (2603:10b6:5:1f4::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.23 via Frontend Transport; Wed, 30 Jun 2021 07:05:18 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by DM6NAM11FT040.mail.protection.outlook.com (10.13.173.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4287.22 via Frontend Transport; Wed, 30 Jun 2021 07:05:17 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 30 Jun 2021 07:05:14 +0000 From: Gregory Etelson To: CC: , , , Viacheslav Ovsiienko , Shahaf Shuler Date: Wed, 30 Jun 2021 10:04:51 +0300 Message-ID: <20210630070452.14055-3-getelson@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210630070452.14055-1-getelson@nvidia.com> References: <20210630070452.14055-1-getelson@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2f163ead-d77a-4ea1-6130-08d93b956aeb X-MS-TrafficTypeDiagnostic: MN2PR12MB3309: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:478; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uZupsu19J7+8wuQjpjt88uAqMOvEC/Y6H01AdLY80955AE1BMG7KH4hoxD1DXN8ImLQcuugZNANzdevrkE3Vpa3UXiPwFdsvusfhH6mwg9GW/9oAhz6iZskKV6NqrF+nBJUKttCMrraUjG7jdI55AZYXj/bXwRg3L4GPksXbvxCLTvo/PZR5THISoUM/inip5vYjuSNKxKlG0F9GRyKuIqWAM1vPB1xbBzf0q2T6wZfhlCYUO6AAucnstg5Fn+spNZ0ywDiU6HdVFiFQ4tIEqQ7sI58CWOIwITxpb1/vJNI+JqnZd46MbSH3XqMReiICX+T/djyh5lzxBC+uggOW6LAFDI1t7FywYFAG9RtD/6TCy6wfq2/MWN5vv5+LriVgae89QHeFf8O1Dh7z/z/eij7mqy/n6WfpJJn2FG48bttwtpXRnWZxqsvGkSF5LECaJQs+rQY+gxpDx8C1MJxqKW0hoJfqoQNPDgLpsRXFag5N8894kf+kzXce4XvF+PAtTztoOm7P3NKtn7+hnaWNZQPnGvYno76EYGL7yTRABBhbbIUolag20fnB1C+loN9rwVdPMwaHhyYi8zhmJx+O/FgM6f4u2jUVOlKxolILsi7rP6ZhUDEcV65afSD13/uOhT1pErXBzGmZIvcbootvqp1kDK/MPKuxWnjfF9Jy1RWmVsoxE9Q78U1tQ2Im90hGogo5oxgd9Uu/f8Ks6AsCVQ== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(39860400002)(396003)(376002)(346002)(136003)(36840700001)(46966006)(83380400001)(7636003)(356005)(6666004)(54906003)(8936002)(82740400003)(5660300002)(478600001)(26005)(1076003)(36860700001)(55016002)(2616005)(186003)(7696005)(86362001)(6916009)(16526019)(316002)(6286002)(107886003)(36756003)(8676002)(426003)(47076005)(70586007)(70206006)(2906002)(36906005)(82310400003)(336012)(4326008); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2021 07:05:17.8503 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2f163ead-d77a-4ea1-6130-08d93b956aeb X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT040.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3309 Subject: [dpdk-dev] [PATCH 2/3] net/mlx5: add flow rule match for IPv4 IHL field X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Provide flow rules capability to match on IPv4 IHL field. Minimal HCA firmware version requiredto offload IPv4 IHL is xx_30_2000. Signed-off-by: Gregory Etelson Acked-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5_flow_dv.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index c5d4b01e57..155f686ad1 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -2451,19 +2451,19 @@ flow_dv_validate_item_gtp_psc(const struct rte_flow_item *item, * 0 on success, a negative errno value otherwise and rte_errno is set. */ static int -flow_dv_validate_item_ipv4(const struct rte_flow_item *item, - uint64_t item_flags, - uint64_t last_item, - uint16_t ether_type, - struct rte_flow_error *error) +flow_dv_validate_item_ipv4(struct rte_eth_dev *dev, + const struct rte_flow_item *item, + uint64_t item_flags, uint64_t last_item, + uint16_t ether_type, struct rte_flow_error *error) { int ret; + struct mlx5_priv *priv = dev->data->dev_private; const struct rte_flow_item_ipv4 *spec = item->spec; const struct rte_flow_item_ipv4 *last = item->last; const struct rte_flow_item_ipv4 *mask = item->mask; rte_be16_t fragment_offset_spec = 0; rte_be16_t fragment_offset_last = 0; - const struct rte_flow_item_ipv4 nic_ipv4_mask = { + struct rte_flow_item_ipv4 nic_ipv4_mask = { .hdr = { .src_addr = RTE_BE32(0xffffffff), .dst_addr = RTE_BE32(0xffffffff), @@ -2474,6 +2474,17 @@ flow_dv_validate_item_ipv4(const struct rte_flow_item *item, }, }; + if (mask && (mask->hdr.version_ihl & RTE_IPV4_HDR_IHL_MASK)) { + int tunnel = !!(item_flags & MLX5_FLOW_LAYER_TUNNEL); + bool ihl_cap = !tunnel ? priv->config.hca_attr.outer_ipv4_ihl : + priv->config.hca_attr.inner_ipv4_ihl; + if (!ihl_cap) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, + item, + "IPV4 ihl offload not supported"); + nic_ipv4_mask.hdr.version_ihl = mask->hdr.version_ihl; + } ret = mlx5_flow_validate_item_ipv4(item, item_flags, last_item, ether_type, &nic_ipv4_mask, MLX5_ITEM_RANGE_ACCEPTED, error); @@ -6771,7 +6782,7 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, case RTE_FLOW_ITEM_TYPE_IPV4: mlx5_flow_tunnel_ip_check(items, next_protocol, &item_flags, &tunnel); - ret = flow_dv_validate_item_ipv4(items, item_flags, + ret = flow_dv_validate_item_ipv4(dev, items, item_flags, last_item, ether_type, error); if (ret < 0) @@ -8154,7 +8165,7 @@ flow_dv_translate_item_ipv4(void *matcher, void *key, void *headers_v; char *l24_m; char *l24_v; - uint8_t tos; + uint8_t tos, ihl_m, ihl_v; if (inner) { headers_m = MLX5_ADDR_OF(fte_match_param, matcher, @@ -8183,6 +8194,10 @@ flow_dv_translate_item_ipv4(void *matcher, void *key, *(uint32_t *)l24_m = ipv4_m->hdr.src_addr; *(uint32_t *)l24_v = ipv4_m->hdr.src_addr & ipv4_v->hdr.src_addr; tos = ipv4_m->hdr.type_of_service & ipv4_v->hdr.type_of_service; + ihl_m = ipv4_m->hdr.version_ihl & RTE_IPV4_HDR_IHL_MASK; + ihl_v = ipv4_v->hdr.version_ihl & RTE_IPV4_HDR_IHL_MASK; + MLX5_SET(fte_match_set_lyr_2_4, headers_m, ipv4_ihl, ihl_m); + MLX5_SET(fte_match_set_lyr_2_4, headers_v, ipv4_ihl, ihl_m & ihl_v); MLX5_SET(fte_match_set_lyr_2_4, headers_m, ip_ecn, ipv4_m->hdr.type_of_service); MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_ecn, tos); -- 2.31.1