From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10040.outbound.protection.outlook.com [40.107.1.40]) by dpdk.org (Postfix) with ESMTP id 5F1B12862 for ; Tue, 6 Nov 2018 08:42:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SOAwN+7MQeMdBEadX3Hb8VMb6QKcNTRK53XjGQHnsxk=; b=VtfSro4Zuq0RwGQhXR9odxMEvZed4NtYcrPyn1lzZgQgzIU16UmqBwkgunkfX5zI3vLkJAP2OMGTwgdROwSMRuMeafoKwAmv4IzO5Zr3DJB0ajfdN0z8qOed/6iPpTyJFFegsIku+JyRCT5bmK3EqXB8dHBjBO+2Un3ZvOfTBTk= Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com (52.134.72.27) by DB3PR0502MB3993.eurprd05.prod.outlook.com (52.134.70.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.20; Tue, 6 Nov 2018 07:42:49 +0000 Received: from DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::58e7:97d8:f9c1:4323]) by DB3PR0502MB3980.eurprd05.prod.outlook.com ([fe80::58e7:97d8:f9c1:4323%3]) with mapi id 15.20.1294.032; Tue, 6 Nov 2018 07:42:49 +0000 From: Yongseok Koh To: Shahaf Shuler CC: "dev@dpdk.org" , Yongseok Koh , Ori Kam Thread-Topic: [PATCH] net/mlx5: fix misuse of device flow reference Thread-Index: AQHUdaRRvLAVttdcpEqUWUed/S5kVg== Date: Tue, 6 Nov 2018 07:42:49 +0000 Message-ID: <20181106074237.484-1-yskoh@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR01CA0005.prod.exchangelabs.com (2603:10b6:a02:80::18) To DB3PR0502MB3980.eurprd05.prod.outlook.com (2603:10a6:8:10::27) authentication-results: spf=none (sender IP is ) smtp.mailfrom=yskoh@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [209.116.155.178] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB3PR0502MB3993; 6:5PU902Z+aw4DNAFKj9auliDBwB7jMnrwVm/sp20Cqus+dP842EdH9RWuKg7Dyn9nIsKqIPibmaoYNNdjFKO4Lf1AExM2Vxi//q76tYzXh8eheW0csMra52nwustEH2uXEidfRTyLPiR00MQAhNPhn7y5TF08kWXEgY8jE51Ktppp++mI72+QrrXnEEicSIRKr3bzSMRVdy+uHe1B8ZYe0IF2rNK/As5h5av+9i27pkk17tfqyYs13aKGYyhQGUu7mjvN++peZteyijVhqY0s0YJPCkPnf1JzJkRmkhGL02Trx/r4MzcLiGrSunC5D86znASOXoGT/AgVC7ZIzf0ZAEMP8Gj7zSLXrdUCtdA5Tb0vv8Sv/MAdtulTrEfbB8pQGl7ISIMoqPUWkZG/dIoXgYonNUpXxTCMRLf0ipcI7A0OcJhtgEQ24CjWytRiRzbZaS0fMNgYxMpVXK2t2ik3Yg==; 5:pGE3UwPFVybbteVrGMriB6/kj4ZgtoyKa+OV5MB+Ipli5t2BVASO3eBYOE1IJpihUt83WD+lLOV/djHGxpcn+O9IH2A3IkRmnCVaNirBYYVHH1gsbN5ArLjHVSANSTwcTRzXgnSQcebT4jHId/ArNA56A7ZgmFZo8VHR9piUNb8=; 7:6LVrVvNJCyReuxEubcLtIPcbCbGkWj/u7AUCnKeWMVloQkjFQ1FPXC5HUu0NgYwrmfVjjmyz6mUmcjw8DOVeZO8uWxWUQ4kQ9Gee/jArWgOplm8na7P7ptIg4k9HEgX4XNH7VmqZBCY4qVVsu9jNCg== x-ms-office365-filtering-correlation-id: 5ab04d24-5113-4e35-2d33-08d643bb7372 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:DB3PR0502MB3993; x-ms-traffictypediagnostic: DB3PR0502MB3993: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231382)(944501410)(52105095)(93006095)(93001095)(3002001)(10201501046)(6055026)(148016)(149066)(150057)(6041310)(20161123562045)(20161123560045)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:DB3PR0502MB3993; BCL:0; PCL:0; RULEID:; SRVR:DB3PR0502MB3993; x-forefront-prvs: 0848C1A6AA x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(136003)(396003)(39860400002)(376002)(346002)(199004)(189003)(6436002)(52116002)(102836004)(6636002)(71190400001)(6506007)(71200400001)(386003)(2616005)(186003)(54906003)(476003)(5660300001)(37006003)(486006)(316002)(478600001)(36756003)(97736004)(14444005)(2900100001)(26005)(6486002)(1857600001)(256004)(6512007)(25786009)(4326008)(14454004)(53936002)(6116002)(99286004)(305945005)(2906002)(107886003)(105586002)(86362001)(7736002)(3846002)(1076002)(8936002)(66066001)(68736007)(106356001)(6862004)(81156014)(81166006)(8676002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB3PR0502MB3993; H:DB3PR0502MB3980.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: XD+8gvztSbLWN7CmMGT7HULX7tlyiohsO2CTLZzXB+aVKDG/pkOSSNqnRcK+C48dHSrOblVKsmxUbHH8NOCwkHzCQQ3zvpGZOtmAg9HkmzmSfvbXo0DjpowcVo4V+GbrQV1Oxfh31Lan48wkwPs4ZFezbhhVrSTjyrUu58ZtHpUqy3tokvuEOodD+8pJd+ECt9TVi14Gn4AGctYrS2OL0Oo8P4eF2iIvIohWa2VXZj6ma8b1FqyRGAs8Iccm4mVHM2cEswN2/hUMuCn/bSfzSDgDFu+Yt5hrxzcvHCxguoQ4WmkUxEHCa19wxrnjKA5UhixD+k12ILJ1EId209lUHepG8x/yiADhmkqQwtdBefE= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5ab04d24-5113-4e35-2d33-08d643bb7372 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Nov 2018 07:42:49.8530 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0502MB3993 Subject: [dpdk-dev] [PATCH] net/mlx5: fix misuse of device flow reference 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: Tue, 06 Nov 2018 07:42:51 -0000 dev_flow->verbs is mistakenly used instead of dev_flow->dv. A sanity check is added for debugging purpose. Fixes: fc2c498ccb94 ("net/mlx5: add Direct Verbs translate items") Cc: orika@mellanox.com Signed-off-by: Yongseok Koh --- drivers/net/mlx5/mlx5_flow_dv.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_d= v.c index 7909615360..bbc86ba5e4 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -1041,6 +1041,39 @@ flow_dv_prepare(const struct rte_flow_attr *attr __r= te_unused, return flow; } =20 +#ifndef NDEBUG +/** + * Sanity check for match mask and value. Similar to check_valid_spec() in + * kernel driver. If unmasked bit is present in value, it returns failure. + * + * @param match_mask + * pointer to match mask buffer. + * @param match_value + * pointer to match value buffer. + * + * @return + * 0 if valid, -EINVAL otherwise. + */ +static int +flow_dv_check_valid_spec(void *match_mask, void *match_value) +{ + uint8_t *m =3D match_mask; + uint8_t *v =3D match_value; + unsigned int i; + + for (i =3D 0; i < MLX5_ST_SZ_DB(fte_match_param); ++i) { + if (v[i] & ~m[i]) { + DRV_LOG(ERR, + "match_value differs from match_criteria" + " %p[%u] !=3D %p[%u]", + match_value, i, match_mask, i); + return -EINVAL; + } + } + return 0; +} +#endif + /** * Add Ethernet item to matcher and to the value. * @@ -1812,7 +1845,7 @@ flow_dv_translate(struct rte_eth_dev *dev, flow_dv_translate_item_udp(match_mask, match_value, items, tunnel); matcher.priority =3D MLX5_PRIORITY_MAP_L4; - dev_flow->verbs.hash_fields |=3D + dev_flow->dv.hash_fields |=3D mlx5_flow_hashfields_adjust (dev_flow, tunnel, ETH_RSS_UDP, IBV_RX_HASH_SRC_PORT_UDP | @@ -1849,6 +1882,8 @@ flow_dv_translate(struct rte_eth_dev *dev, break; } } + assert(!flow_dv_check_valid_spec(matcher.mask.buf, + dev_flow->dv.value.buf)); dev_flow->layers =3D item_flags; /* Register matcher. */ matcher.crc =3D rte_raw_cksum((const void *)matcher.mask.buf, --=20 2.11.0