From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60057.outbound.protection.outlook.com [40.107.6.57]) by dpdk.org (Postfix) with ESMTP id 0DAFE5F2E for ; Thu, 4 Oct 2018 07:53:42 +0200 (CEST) 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=ddqnFnjm1ryrY7Wj3ra4njAf7P7c0nngEhPetzB0D3U=; b=mS+aakUoaUDZ2AiYZFbmyCXxAE544VoNaS3vO5lh8F5/Gk2GYOdKjUV61fkerycsJ9y/ywHPMAiORCDTp8Avdl3f+zP0sR9JGfWTq0/wmTl+Ee5nqOUsYG/lHrPu09IQerz5aMqXEL3d8pv/rKgGyTVN8KdZxA0wEa1MqPC1xrU= Received: from AM4PR05MB3425.eurprd05.prod.outlook.com (10.171.187.142) by AM4PR05MB3170.eurprd05.prod.outlook.com (10.171.186.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1185.25; Thu, 4 Oct 2018 05:53:40 +0000 Received: from AM4PR05MB3425.eurprd05.prod.outlook.com ([fe80::fdeb:3890:f0f0:2202]) by AM4PR05MB3425.eurprd05.prod.outlook.com ([fe80::fdeb:3890:f0f0:2202%4]) with mapi id 15.20.1207.022; Thu, 4 Oct 2018 05:53:40 +0000 From: Ori Kam To: Yongseok Koh , Shahaf Shuler CC: "dev@dpdk.org" , Ori Kam Thread-Topic: [PATCH v2] net/mlx5: fix Direct Verbs flow matcher caching Thread-Index: AQHUW6aZQWMk5+Yja0CLZRAxXissfw== Date: Thu, 4 Oct 2018 05:53:40 +0000 Message-ID: <1538632399-13135-1-git-send-email-orika@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM5PR0701CA0009.eurprd07.prod.outlook.com (2603:10a6:203:51::19) To AM4PR05MB3425.eurprd05.prod.outlook.com (2603:10a6:205:6::14) authentication-results: spf=none (sender IP is ) smtp.mailfrom=orika@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [37.142.13.130] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM4PR05MB3170; 6:69M542Y5I0+UCe/wRX+NYUBRpZ2ltF/gFMxF/taTO+J0pWKO0f9Wyj+5ZL4i4tuspFy6rhKVVszWOWPZVwYmvQIhabUzqza2apAU7KNCGGoYxWZvgn+0dx0DQ6OGWx8JMrsDpy9vOJyWfcizV1ceFQR+qNdPuaVoFqmxWvM2cbThOCZKq9S+6Ubxn/iU/cqDFpPBkfgrGRWyM39nE+oYfUm/aHrgAMEMEzulF7g35ejUuHc2yaV8mSkguKQl4CMeh5ThBNMRd3T5jybWnmSse2p4jbQZNuH8GOhQYna0ERSTjPnKBFrZg8HwxUy3c+Yd61gJhkOqRDV5o/9UycS561/LNXPs/7v3C9Gl8PLdcqkQZaF/kChB6rOfNOJK+1e0k8s1u1tGMnyvbgxU58Pczj1JOKTIp+NO7YaZmgymWFDH9iWVOgnA77UIuLuV/Y+UL1ROMHmuR61i+gMjMwtgZA==; 5:iSrXMwNDYiweW5TBziSgw5ibsPdHISAUT554ssSIhxP2L6LEnAvwtxUQtMk+WHQN5aYl5rVDrY8kGXZ8Kb/H09n33FRrTph923YJ10jwkBZaRjXDICFDut2IwufByH0v92UhzUn8Dh1pvsOlfumsenafNOg1wRFJ/HsVMKLNpf8=; 7:jd+nAaHm0dfIeehOAdxnEP72CvW/Yb6Jsiu4/3qPSKy0fXa8rb5DNhDG2iMmqGTDtiE1EYL5FbPdGniqvbeAaO1pGmb8AggJOGrWgmLGSuXRjFmN9+asLI3/st9W0yJv36RPGaIEk/S3Jt/oqUvUc93zAqwiWjsnxES2YMCYRwN7kuoaDYOs8mwGLbB8mY3HMCnrkMTD7z5FN10y9f3u2P6TGfJ6U6/CxB4mXUC/Mseb7+yzMslQtw4K42YsrFG6 x-ms-office365-filtering-correlation-id: ea1fded9-f7ed-48eb-4976-08d629bdbbe6 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM4PR05MB3170; x-ms-traffictypediagnostic: AM4PR05MB3170: 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)(5005006)(8121501046)(3231355)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(149066)(150057)(6041310)(20161123558120)(20161123564045)(20161123560045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051); SRVR:AM4PR05MB3170; BCL:0; PCL:0; RULEID:; SRVR:AM4PR05MB3170; x-forefront-prvs: 0815F8251E x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(376002)(39860400002)(136003)(346002)(396003)(366004)(189003)(199004)(81156014)(478600001)(386003)(26005)(25786009)(8936002)(6116002)(8676002)(81166006)(36756003)(102836004)(68736007)(6506007)(4326008)(2906002)(2616005)(52116002)(476003)(486006)(71190400001)(85306007)(3846002)(71200400001)(186003)(99286004)(110136005)(66066001)(316002)(256004)(97736004)(6486002)(7736002)(6436002)(14454004)(2900100001)(106356001)(107886003)(54906003)(105586002)(575784001)(86362001)(6636002)(53936002)(6512007)(5660300001)(305945005)(5250100002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR05MB3170; H:AM4PR05MB3425.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: h5+WavROecrehFD0w5i9nCeYbMJLzmdEN47BvxvtURuloS5XDUX1TNi16SjIsuyz8OmzFdjFsLIy/JdV4ft+RWh7oIXClDCoiTrGqCxQEJMlnBUsVfgUDyTjDHnaHmgkYz72i1kQNm5EvooTQgLN3CwBZ4iJKGZLLtnq9Y3oAuQk5tprmcLG0we48bw20ldTWXtz4N07D7r1/zuTgaR6vK2CxLctOinY8rHCvKZCKH10sof/HtQrJ2qjjT0Xk1a306NYUR6QEah+jy+t/yaFPCSJwEYXCotSp8NV1OTVnlNeKtYsir5AbXD+yAg3ASuOLARtiJwqR0Mey34DPsRmQXOc8/WYy2ej7tkksHYulu8= 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: ea1fded9-f7ed-48eb-4976-08d629bdbbe6 X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Oct 2018 05:53:40.2493 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB3170 Subject: [dpdk-dev] [PATCH v2] net/mlx5: fix Direct Verbs flow matcher caching 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: Thu, 04 Oct 2018 05:53:42 -0000 The Direct Verbs are using matcher object to filter flows, This object can be reused for all flows that are using the same flow items and masks. This was implemented with an issue, that the list pointer pointed to incorrect list type, this resulted in compilation error when using GCC greater then 4.8.5 This commit fixes this issue by setting that the matcher object will include the LIST required members directly and not as a subobject. Fixes: 8d21c3d7b237 ("net/mlx5: add Direct Verbs translate items") Signed-off-by: Ori Kam Acked-by: Yongseok Koh --- V2: * Some cosmetics based on Yongseok comments. --- drivers/net/mlx5/mlx5.h | 2 +- drivers/net/mlx5/mlx5_flow.h | 5 ++- drivers/net/mlx5/mlx5_flow_dv.c | 77 +++++++++++++++++++++----------------= ---- drivers/net/mlx5/mlx5_rxtx.h | 7 ---- 4 files changed, 45 insertions(+), 46 deletions(-) diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 8de0d74..4122e54 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -208,7 +208,7 @@ struct priv { LIST_HEAD(txqibv, mlx5_txq_ibv) txqsibv; /* Verbs Tx queues. */ /* Verbs Indirection tables. */ LIST_HEAD(ind_tables, mlx5_ind_table_ibv) ind_tbls; - LIST_HEAD(matcher, mlx5_cache) matchers; + LIST_HEAD(matchers, mlx5_flow_dv_matcher) matchers; uint32_t link_speed_capa; /* Link speed capabilities. */ struct mlx5_xstats_ctrl xstats_ctrl; /* Extended stats control. */ int primary_socket; /* Unix socket for primary process. */ diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 10d700a..a91f991 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -153,7 +153,10 @@ struct mlx5_flow_dv_match_params { =20 /* Matcher structure. */ struct mlx5_flow_dv_matcher { - struct mlx5_cache cache; /**< Cache to struct mlx5dv_flow_matcher. */ + LIST_ENTRY(mlx5_flow_dv_matcher) next; + /* Pointer to the next element. */ + rte_atomic32_t refcnt; /**< Reference counter. */ + void *matcher_object; /**< Pointer to DV matcher */ uint16_t crc; /**< CRC of key. */ uint16_t priority; /**< Priority of matcher. */ uint8_t egress; /**< Egress matcher. */ diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_d= v.c index cf663cd..7d32532 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -1060,54 +1060,56 @@ struct rte_flow_error *error) { struct priv *priv =3D dev->data->dev_private; - struct mlx5_flow_dv_matcher *cache; + struct mlx5_flow_dv_matcher *cache_matcher; struct mlx5dv_flow_matcher_attr dv_attr =3D { .type =3D IBV_FLOW_ATTR_NORMAL, .match_mask =3D (void *)&matcher->mask, }; =20 /* Lookup from cache. */ - LIST_FOREACH(cache, &priv->matchers, cache.next) { - if (matcher->crc =3D=3D cache->crc && - matcher->priority =3D=3D cache->priority && - matcher->egress =3D=3D cache->egress && + LIST_FOREACH(cache_matcher, &priv->matchers, next) { + if (matcher->crc =3D=3D cache_matcher->crc && + matcher->priority =3D=3D cache_matcher->priority && + matcher->egress =3D=3D cache_matcher->egress && !memcmp((const void *)matcher->mask.buf, - (const void *)cache->mask.buf, cache->mask.size)) { + (const void *)cache_matcher->mask.buf, + cache_matcher->mask.size)) { DRV_LOG(DEBUG, "priority %hd use %s matcher %p: refcnt %d++", - cache->priority, cache->egress ? "tx" : "rx", - (void *)cache, - rte_atomic32_read(&cache->cache.refcnt)); - rte_atomic32_inc(&cache->cache.refcnt); - dev_flow->dv.matcher =3D cache; + cache_matcher->priority, + cache_matcher->egress ? "tx" : "rx", + (void *)cache_matcher, + rte_atomic32_read(&cache_matcher->refcnt)); + rte_atomic32_inc(&cache_matcher->refcnt); + dev_flow->dv.matcher =3D cache_matcher; return 0; } } /* Register new matcher. */ - cache =3D rte_calloc(__func__, 1, sizeof(*cache), 0); - if (!cache) + cache_matcher =3D rte_calloc(__func__, 1, sizeof(*cache_matcher), 0); + if (!cache_matcher) return rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, "cannot allocate matcher memory"); - *cache =3D *matcher; + *cache_matcher =3D *matcher; dv_attr.match_criteria_enable =3D - flow_dv_matcher_enable(cache->mask.buf); + flow_dv_matcher_enable(cache_matcher->mask.buf); dv_attr.priority =3D matcher->priority; if (matcher->egress) dv_attr.flags |=3D IBV_FLOW_ATTR_FLAGS_EGRESS; - cache->cache.resource =3D + cache_matcher->matcher_object =3D mlx5_glue->dv_create_flow_matcher(priv->ctx, &dv_attr); - if (!cache->cache.resource) + if (!cache_matcher->matcher_object) return rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, "cannot create matcher"); - rte_atomic32_inc(&cache->cache.refcnt); - LIST_INSERT_HEAD(&priv->matchers, &cache->cache, next); - dev_flow->dv.matcher =3D cache; + rte_atomic32_inc(&cache_matcher->refcnt); + LIST_INSERT_HEAD(&priv->matchers, cache_matcher, next); + dev_flow->dv.matcher =3D cache_matcher; DRV_LOG(DEBUG, "priority %hd new %s matcher %p: refcnt %d", - cache->priority, - cache->egress ? "tx" : "rx", (void *)cache, - rte_atomic32_read(&cache->cache.refcnt)); + cache_matcher->priority, + cache_matcher->egress ? "tx" : "rx", (void *)cache_matcher, + rte_atomic32_read(&cache_matcher->refcnt)); return 0; } =20 @@ -1232,7 +1234,7 @@ n++; } dv->flow =3D - mlx5_glue->dv_create_flow(dv->matcher->cache.resource, + mlx5_glue->dv_create_flow(dv->matcher->matcher_object, (void *)&dv->value, n, dv->actions); if (!dv->flow) { @@ -1265,28 +1267,29 @@ * * @param dev * Pointer to Ethernet device. - * @param matcher - * Pointer to flow matcher. + * @param flow + * Pointer to mlx5_flow. * * @return * 1 while a reference on it exists, 0 when freed. */ static int flow_dv_matcher_release(struct rte_eth_dev *dev, - struct mlx5_flow_dv_matcher *matcher) + struct mlx5_flow *flow) { - struct mlx5_cache *cache =3D &matcher->cache; + struct mlx5_flow_dv_matcher *matcher =3D flow->dv.matcher; =20 - assert(cache->resource); + assert(matcher->matcher_object); DRV_LOG(DEBUG, "port %u matcher %p: refcnt %d--", - dev->data->port_id, (void *)cache, - rte_atomic32_read(&cache->refcnt)); - if (rte_atomic32_dec_and_test(&cache->refcnt)) { - claim_zero(mlx5_glue->dv_destroy_flow_matcher(cache->resource)); - LIST_REMOVE(cache, next); - rte_free(cache); + dev->data->port_id, (void *)matcher, + rte_atomic32_read(&matcher->refcnt)); + if (rte_atomic32_dec_and_test(&matcher->refcnt)) { + claim_zero(mlx5_glue->dv_destroy_flow_matcher + (matcher->matcher_object)); + LIST_REMOVE(matcher, next); + rte_free(matcher); DRV_LOG(DEBUG, "port %u matcher %p: removed", - dev->data->port_id, (void *)cache); + dev->data->port_id, (void *)matcher); return 0; } return 1; @@ -1346,7 +1349,7 @@ dev_flow =3D LIST_FIRST(&flow->dev_flows); LIST_REMOVE(dev_flow, next); if (dev_flow->dv.matcher) - flow_dv_matcher_release(dev, dev_flow->dv.matcher); + flow_dv_matcher_release(dev, dev_flow); rte_free(dev_flow); } } diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h index 02034a4..d225b9c 100644 --- a/drivers/net/mlx5/mlx5_rxtx.h +++ b/drivers/net/mlx5/mlx5_rxtx.h @@ -171,13 +171,6 @@ struct mlx5_hrxq { uint8_t rss_key[]; /* Hash key. */ }; =20 -/* List of cached objects. */ -struct mlx5_cache { - LIST_ENTRY(mlx5_cache) next; /* Pointer to the next element. */ - rte_atomic32_t refcnt; /* Reference counter. */ - void *resource; /* Cached resource */ -}; - /* TX queue descriptor. */ __extension__ struct mlx5_txq_data { --=20 1.8.3.1