From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80087.outbound.protection.outlook.com [40.107.8.87]) by dpdk.org (Postfix) with ESMTP id ADEC11B43F for ; Thu, 12 Jul 2018 14:01:54 +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=XGNwiLVmJZguqKvdjSUXUdqSfoH/DUouHONMyX4k2P4=; b=Ig+Zou90uKpignWIejoCoCV7XivxTmeO6II3TGd03Uls9XIIRf8sBBkmOB7v8bmnfO14K5w9Yt7iwDSeXH/9cfpGilP/+52FK4MFx2412DsvyCScBFSalKg5dmrZT9USJ0uLkefvl8pIJhs+r0cgXW/OIqSzCEYa2tnRrQKIx+w= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=motih@mellanox.com; Received: from localhost.localdomain (37.142.13.130) by DB7PR05MB4443.eurprd05.prod.outlook.com (2603:10a6:5:1b::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.930.21; Thu, 12 Jul 2018 12:01:51 +0000 From: Moti Haimovsky To: shahafs@mellanox.com Cc: yskoh@mellanox.com, dev@dpdk.org, Moti Haimovsky Date: Thu, 12 Jul 2018 15:01:31 +0300 Message-Id: <1531396891-23874-1-git-send-email-motih@mellanox.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1530529900-27859-1-git-send-email-motih@mellanox.com> References: <1530529900-27859-1-git-send-email-motih@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: HE1PR08CA0071.eurprd08.prod.outlook.com (2603:10a6:7:2a::42) To DB7PR05MB4443.eurprd05.prod.outlook.com (2603:10a6:5:1b::20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2a478d4e-611c-49e5-1e9f-08d5e7ef41d2 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600053)(711020)(48565401081)(2017052603328)(7153060)(7193020); SRVR:DB7PR05MB4443; X-Microsoft-Exchange-Diagnostics: 1; DB7PR05MB4443; 3:PgZGtVFDBE53cnS5RIENBXAQJH/ADJciknwWItx9bbrKpgL/EYK5wJIrKgUZYFu7NQP7NtkTpHiuB/0JlUavUC6HVbaUknnjK926nWm3jEZTxgmbjW6wTBrGeEdxiZc9BV3BpUhZVoSlZYZ07sVz7EIULQhwE403thSzXWJpNnAj1PR4LfYwUSaqwZrDYJNP6KFl84S+gwg3BTP9xG3RsBlqEbYiXuFOheoDd+fBHvzu/XkYKtYpcdy8udx2spYr; 25:/9WkPwpv6Z/DWv4TcYn03PEh2HYWsHlMspEq93OLZw7LDWI8TnWHFELeXHo0uGoOPFbV2KwvlrRIFqy4it+AsMtq5FUSJK2v8MoAuYbl8uR+73nAdblGrIN0NPZ8qoL91RLkasSsqroUrKZICbHsegvSrTrW29C+CpYiu6TdObYgUXztWD3nWO38QSCYdsu9v0lKKX076fjm0NxnKxuqap9Hle8fbUrRpvLgf5N1KiZMlyj6FG3fBsupdrtZAYLNPMHJ0lz4pOfnwZvzEWIS+eUYIILKdzcd0UHl1L8vwGQANRlcS7pOxm2aTMT+e5ftfXwpAsX7AWxionzRj08HTA==; 31:FMvMaPRmAOHZEXEbGITEuSzrHs64Z3fI1PSymFFwGHY7xHhqefNHHVRdzinlhd7XH2/YKDmhAeZig3DnjmZ8Yz4YZ0PqP2q4ax6PkmQXrusvA5Gr4Lp/VawLDENxcrk2fUph7MchAz8wwVdBUbLWw1FNyh+dGOsbWZ4hdWeMscOne5ux7EdGJnp5SoYVgHQoaX2WGqXcLY4oqa4SobpZzso9SmNXVKHZ/vsAwhwDXz0= X-MS-TrafficTypeDiagnostic: DB7PR05MB4443: X-Microsoft-Exchange-Diagnostics: 1; DB7PR05MB4443; 20:rfQ733B7eVGTFgT2KmTLok5EmtE50/8/7smogidvMGgwHiAsM2v1ZaSppLVgCryh8T/+MU8R+WX2jv1pf9/9CNUy2RLKJnFndv+xxL/A0r+XEPaqbGh2wB+Bka8gUaNpwR89l0+LNwacoMpWTZGodM3FLTcf+9FCQVYmpxj8qOdfCA7Je13Xun+P7VB3WYg+mv95Y5PfxnGhEzpqDRVOqn+ALlx/IebnUfsSibFfhKzaAbl0r97w0Iqshv8+Fr6vn31tsCUB0HHASNQiBkDZxjX12mwmOJXmCqT7o26nieautNcmkLt7w81DHA48khfbV2rz8DR/hwUkpGUdzqfYPocExZN27aXHSsp1nxPdeRaqVzA00qHj5nDshxDC7ZM4C4Ix1f4Xs9+qwshULaHbvw/94ybpbFnXH+oY6bSMO9hZDRFFTiSVfw0V551LXOC9+qtJDtaslFXjxfaAQfbif81aUuYWdc9W69lIWt3Qy/mchHwgv3Oi6Jtqv+TrZA2n; 4:3l7sHjshH4ML6BWJzDsI931zpvexhbmn3gg3s1LwkGVRAJTrfV24e0QmMuGahZH6zT0fO9sAYplJxcJEYbMHoYzSHxKC1+izEeVicDSBh6SeecrJnUEW+/QQlNQNCDtih4CloDcwUdsOC88uUpUUuTi8PAxdR2OQnqkMAd61cU0ieYcPj2fbMF6MgeOGb6LttiQz7VVbVubIOxb4ItAozQ012kUpy1I4eEE+JhNk1s93J7NZuOC4eVfypy7dUJ9wNIfWRQcLB2YYsiYXSZq2Qzg+vqmgDvXRUWvsGmWXuzxJdBiss7s7nwxX18lGYkfyz+Rro5G6+1ppXdrKDuT/inPywc/SKU/YeOvNBgatEQBxEfdH+XgNZx30dFMbMaqm X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(275740015457677)(111885846020525)(84791874153150); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(10201501046)(3002001)(3231311)(944501410)(52105095)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123560045)(20161123558120)(6072148)(201708071742011)(7699016); SRVR:DB7PR05MB4443; BCL:0; PCL:0; RULEID:; SRVR:DB7PR05MB4443; X-Forefront-PRVS: 0731AA2DE6 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(979002)(6069001)(396003)(136003)(366004)(376002)(346002)(39860400002)(199004)(189003)(5660300001)(47776003)(6636002)(16526019)(6666003)(25786009)(3846002)(386003)(68736007)(48376002)(36756003)(4326008)(26005)(6116002)(8936002)(34206002)(14444005)(6506007)(97736004)(105586002)(2361001)(52116002)(76176011)(107886003)(37006003)(966005)(50466002)(956004)(16586007)(6486002)(50226002)(86362001)(575784001)(51416003)(106356001)(446003)(316002)(7736002)(81156014)(476003)(2616005)(6512007)(486006)(305945005)(11346002)(53936002)(66066001)(8676002)(6306002)(81166006)(2906002)(2351001)(478600001)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB7PR05MB4443; H:localhost.localdomain; 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-Exchange-Diagnostics: =?us-ascii?Q?1; DB7PR05MB4443; 23:wBMzN3rFlsWqthR1Co093NdpY1pYQG1p0LLqjTZdk?= =?us-ascii?Q?T7e1AJsM5HYs+C9xuHqM8n/ee5OnK88PRf0oAJXNHid0q8qzmOyOL29qxO3N?= =?us-ascii?Q?3bAxH3MXYkrqwUYLk5P7fyDFzvGpgy2Jwh/n0McTFX//ii1uIsN/vI80n1lM?= =?us-ascii?Q?Kq/G+IBJm9FpPK14gsHgn+8t6luy/+64i+G9IKjMKctXmrgkM1oYBlfd72os?= =?us-ascii?Q?6OROmLbibgaWND+Fwxe7rd4AOu2YmCt3Pub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IRO+RyxUhFmFwPmi56siwCKKbJxXozKcV3oG/ErQoBzVFhYwq+3yQivtjHSIdFz1ahbcMeJbIIPB0sZ2RJj8CCrhRYgHz9SmJmj7IWsLeCheG4iXK7kXqQPKTfrM5yUXYPdAqSRwNC5EGvypONzEDT+JsRDQwmoJ22q3cdOamlH8K/qbnhB7XgRsj2xO5zbaGB4XrZKhA9fLdECutAKSVCSCDuz6Q0Q==; 5:UIxmuoN8oy/L96AAgC/9wFJK1qOJ3h5r4yQbFgFC44UzMCgu37crjlATSVbObXK6qkSboH577vyAoM1ki9uvfU6ut9KrXzrk7FTM+vPC6knVPahZYqxVi5smNOTWPsAPHPP9MbHofpxZ5RfY22y//yt/RvcDKLdGiq+8XUHP3No=; 24:M5xhTaAvypt7ww3BI3nyJggcIqTeyUO9KeULyoK9h9/UKsPl7X9qjXnkJtvL7fuA0GuoXlrPdT7alG6vh++TcJtC0IJ4jR43Qqi0uqMNHXo= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DB7PR05MB4443; 7:XGw64dxc4QxXaBXrRPTTSesArh7Tzx2gZWQ6gh1sn40JNX2FF45VxndlIB9hVxhQmaIALJTDsvkP7UE1u4nTrgZsT5aQVJCpGslfxY4GXiPAMtgLVDOE3JMhzdcWvnBa9Jn20LT9FtKRcTagMWUj8VNl4fT/2FrrzU/YCbSPyUbho56j9TmJmrI6Oi5eLRadNSsgyENgduS1iti2/QSqlRhOYEVbeGOGQI6jqKNm7VFtNtR8i2zghqrlmGst7bCR X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2018 12:01:51.8801 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2a478d4e-611c-49e5-1e9f-08d5e7ef41d2 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR05MB4443 Subject: [dpdk-dev] [PATCH v3] net/mlx5: add support for 32bit systems 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, 12 Jul 2018 12:01:58 -0000 This patch adds support for building and running mlx5 PMD on 32bit systems such as i686. The main issue to tackle was handling the 32bit access to the UAR as quoted from the mlx5 PRM: QP and CQ DoorBells require 64-bit writes. For best performance, it is recommended to execute the QP/CQ DoorBell as a single 64-bit write operation. For platforms that do not support 64 bit writes, it is possible to issue the 64 bits DoorBells through two consecutive writes, each write 32 bits, as described below: * The order of writing each of the Dwords is from lower to upper addresses. * No other DoorBell can be rung (or even start ringing) in the midst of an on-going write of a DoorBell over a given UAR page. The last rule implies that in a multi-threaded environment, the access to a UAR page (which can be accessible by all threads in the process) must be synchronized (for example, using a semaphore) unless an atomic write of 64 bits in a single bus operation is guaranteed. Such a synchronization is not required for when ringing DoorBells on different UAR pages. Signed-off-by: Moti Haimovsky --- v3: * Rebased upon latest changes in mlx5 PMD and rdma-core. v2: * Fixed coding style issues. * Modified documentation according to review inputs. * Fixed merge conflicts. --- doc/guides/nics/features/mlx5.ini | 1 + doc/guides/nics/mlx5.rst | 6 +++- drivers/net/mlx5/mlx5.c | 8 ++++- drivers/net/mlx5/mlx5.h | 5 +++ drivers/net/mlx5/mlx5_defs.h | 18 ++++++++-- drivers/net/mlx5/mlx5_rxq.c | 6 +++- drivers/net/mlx5/mlx5_rxtx.c | 22 +++++++------ drivers/net/mlx5/mlx5_rxtx.h | 69 ++++++++++++++++++++++++++++++++++++++- drivers/net/mlx5/mlx5_txq.c | 13 +++++++- 9 files changed, 131 insertions(+), 17 deletions(-) diff --git a/doc/guides/nics/features/mlx5.ini b/doc/guides/nics/features/mlx5.ini index e75b14b..b28b43e 100644 --- a/doc/guides/nics/features/mlx5.ini +++ b/doc/guides/nics/features/mlx5.ini @@ -43,5 +43,6 @@ Multiprocess aware = Y Other kdrv = Y ARMv8 = Y Power8 = Y +x86-32 = Y x86-64 = Y Usage doc = Y diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst index 0d0d217..ebf2336 100644 --- a/doc/guides/nics/mlx5.rst +++ b/doc/guides/nics/mlx5.rst @@ -49,7 +49,7 @@ libibverbs. Features -------- -- Multi arch support: x86_64, POWER8, ARMv8. +- Multi arch support: x86_64, POWER8, ARMv8, i686. - Multiple TX and RX queues. - Support for scattered TX and RX frames. - IPv4, IPv6, TCPv4, TCPv6, UDPv4 and UDPv6 RSS on any number of queues. @@ -489,6 +489,10 @@ RMDA Core with Linux Kernel - Minimal kernel version : v4.14 or the most recent 4.14-rc (see `Linux installation documentation`_) - Minimal rdma-core version: v15+ commit 0c5f5765213a ("Merge pull request #227 from yishaih/tm") (see `RDMA Core installation documentation`_) +- When building for i686 use: + + - rdma-core version 18.0 or above built with 32bit support. + - Kernel version 4.14.41 or above. .. _`Linux installation documentation`: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/plain/Documentation/admin-guide/README.rst .. _`RDMA Core installation documentation`: https://raw.githubusercontent.com/linux-rdma/rdma-core/master/README.md diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index dda50b8..15f1a17 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -598,7 +598,7 @@ rte_memseg_walk(find_lower_va_bound, &addr); /* keep distance to hugepages to minimize potential conflicts. */ - addr = RTE_PTR_SUB(addr, MLX5_UAR_OFFSET + MLX5_UAR_SIZE); + addr = RTE_PTR_SUB(addr, (uintptr_t)(MLX5_UAR_OFFSET + MLX5_UAR_SIZE)); /* anonymous mmap, no real memory consumption. */ addr = mmap(addr, MLX5_UAR_SIZE, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); @@ -939,6 +939,12 @@ priv->device_attr = attr; priv->pd = pd; priv->mtu = ETHER_MTU; +#ifndef RTE_ARCH_64 + /* Initialize UAR access locks for 32bit implementations. */ + rte_spinlock_init(&priv->uar_lock_cq); + for (i = 0; i < MLX5_UAR_PAGE_NUM_MAX; i++) + rte_spinlock_init(&priv->uar_lock[i]); +#endif /* Some internal functions rely on Netlink sockets, open them now. */ priv->nl_socket_rdma = mlx5_nl_init(0, NETLINK_RDMA); priv->nl_socket_route = mlx5_nl_init(RTMGRP_LINK, NETLINK_ROUTE); diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 131be33..896158a 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -215,6 +215,11 @@ struct priv { int nl_socket_rdma; /* Netlink socket (NETLINK_RDMA). */ int nl_socket_route; /* Netlink socket (NETLINK_ROUTE). */ uint32_t nl_sn; /* Netlink message sequence number. */ +#ifndef RTE_ARCH_64 + rte_spinlock_t uar_lock_cq; /* CQs share a common distinct UAR */ + rte_spinlock_t uar_lock[MLX5_UAR_PAGE_NUM_MAX]; + /* UAR same-page access control required in 32bit implementations. */ +#endif }; #define PORT_ID(priv) ((priv)->dev_data->port_id) diff --git a/drivers/net/mlx5/mlx5_defs.h b/drivers/net/mlx5/mlx5_defs.h index 5bbbec2..f6ec415 100644 --- a/drivers/net/mlx5/mlx5_defs.h +++ b/drivers/net/mlx5/mlx5_defs.h @@ -87,14 +87,28 @@ #define MLX5_LINK_STATUS_TIMEOUT 10 /* Reserved address space for UAR mapping. */ -#define MLX5_UAR_SIZE (1ULL << 32) +#define MLX5_UAR_SIZE (1ULL << (sizeof(uintptr_t) * 4)) /* Offset of reserved UAR address space to hugepage memory. Offset is used here * to minimize possibility of address next to hugepage being used by other code * in either primary or secondary process, failing to map TX UAR would make TX * packets invisible to HW. */ -#define MLX5_UAR_OFFSET (1ULL << 32) +#define MLX5_UAR_OFFSET (1ULL << (sizeof(uintptr_t) * 4)) + +/* Maximum number of UAR pages used by a port, + * These are the size and mask for an array of mutexes used to synchronize + * the access to port's UARs on platforms that do not support 64 bit writes. + * In such systems it is possible to issue the 64 bits DoorBells through two + * consecutive writes, each write 32 bits. The access to a UAR page (which can + * be accessible by all threads in the process) must be synchronized + * (for example, using a semaphore). Such a synchronization is not required + * when ringing DoorBells on different UAR pages. + * A port with 512 Tx queues uses 8, 4kBytes, UAR pages which are shared + * among the ports. + */ +#define MLX5_UAR_PAGE_NUM_MAX 64 +#define MLX5_UAR_PAGE_NUM_MASK ((MLX5_UAR_PAGE_NUM_MAX) - 1) /* Log 2 of the default number of strides per WQE for Multi-Packet RQ. */ #define MLX5_MPRQ_STRIDE_NUM_N 6U diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index 071740b..16e1641 100644 --- a/drivers/net/mlx5/mlx5_rxq.c +++ b/drivers/net/mlx5/mlx5_rxq.c @@ -647,7 +647,8 @@ doorbell = (uint64_t)doorbell_hi << 32; doorbell |= rxq->cqn; rxq->cq_db[MLX5_CQ_ARM_DB] = rte_cpu_to_be_32(doorbell_hi); - rte_write64(rte_cpu_to_be_64(doorbell), cq_db_reg); + mlx5_uar_write64(rte_cpu_to_be_64(doorbell), + cq_db_reg, rxq->uar_lock_cq); } /** @@ -1449,6 +1450,9 @@ struct mlx5_rxq_ctrl * tmpl->rxq.elts_n = log2above(desc); tmpl->rxq.elts = (struct rte_mbuf *(*)[1 << tmpl->rxq.elts_n])(tmpl + 1); +#ifndef RTE_ARCH_64 + tmpl->rxq.uar_lock_cq = &priv->uar_lock_cq; +#endif tmpl->idx = idx; rte_atomic32_inc(&tmpl->refcnt); LIST_INSERT_HEAD(&priv->rxqsctrl, tmpl, next); diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c index a7ed8d8..52a1074 100644 --- a/drivers/net/mlx5/mlx5_rxtx.c +++ b/drivers/net/mlx5/mlx5_rxtx.c @@ -495,6 +495,7 @@ volatile struct mlx5_wqe_ctrl *last_wqe = NULL; unsigned int segs_n = 0; const unsigned int max_inline = txq->max_inline; + uint64_t addr_64; if (unlikely(!pkts_n)) return 0; @@ -711,12 +712,12 @@ ds = 3; use_dseg: /* Add the remaining packet as a simple ds. */ - addr = rte_cpu_to_be_64(addr); + addr_64 = rte_cpu_to_be_64(addr); *dseg = (rte_v128u32_t){ rte_cpu_to_be_32(length), mlx5_tx_mb2mr(txq, buf), - addr, - addr >> 32, + addr_64, + addr_64 >> 32, }; ++ds; if (!segs_n) @@ -750,12 +751,12 @@ total_length += length; #endif /* Store segment information. */ - addr = rte_cpu_to_be_64(rte_pktmbuf_mtod(buf, uintptr_t)); + addr_64 = rte_cpu_to_be_64(rte_pktmbuf_mtod(buf, uintptr_t)); *dseg = (rte_v128u32_t){ rte_cpu_to_be_32(length), mlx5_tx_mb2mr(txq, buf), - addr, - addr >> 32, + addr_64, + addr_64 >> 32, }; (*txq->elts)[++elts_head & elts_m] = buf; if (--segs_n) @@ -1450,6 +1451,7 @@ unsigned int mpw_room = 0; unsigned int inl_pad = 0; uint32_t inl_hdr; + uint64_t addr_64; struct mlx5_mpw mpw = { .state = MLX5_MPW_STATE_CLOSED, }; @@ -1586,13 +1588,13 @@ ((uintptr_t)mpw.data.raw + inl_pad); (*txq->elts)[elts_head++ & elts_m] = buf; - addr = rte_cpu_to_be_64(rte_pktmbuf_mtod(buf, - uintptr_t)); + addr_64 = rte_cpu_to_be_64(rte_pktmbuf_mtod(buf, + uintptr_t)); *dseg = (rte_v128u32_t) { rte_cpu_to_be_32(length), mlx5_tx_mb2mr(txq, buf), - addr, - addr >> 32, + addr_64, + addr_64 >> 32, }; mpw.data.raw = (volatile void *)(dseg + 1); mpw.total_len += (inl_pad + sizeof(*dseg)); diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h index a04a84f..992e977 100644 --- a/drivers/net/mlx5/mlx5_rxtx.h +++ b/drivers/net/mlx5/mlx5_rxtx.h @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include "mlx5_utils.h" #include "mlx5.h" @@ -118,6 +120,10 @@ struct mlx5_rxq_data { void *cq_uar; /* CQ user access region. */ uint32_t cqn; /* CQ number. */ uint8_t cq_arm_sn; /* CQ arm seq number. */ +#ifndef RTE_ARCH_64 + rte_spinlock_t *uar_lock_cq; + /* CQ (UAR) access lock required for 32bit implementations */ +#endif uint32_t tunnel; /* Tunnel information. */ } __rte_cache_aligned; @@ -198,6 +204,10 @@ struct mlx5_txq_data { volatile void *bf_reg; /* Blueflame register remapped. */ struct rte_mbuf *(*elts)[]; /* TX elements. */ struct mlx5_txq_stats stats; /* TX queue counters. */ +#ifndef RTE_ARCH_64 + rte_spinlock_t *uar_lock; + /* UAR access lock required for 32bit implementations */ +#endif } __rte_cache_aligned; /* Verbs Rx queue elements. */ @@ -353,6 +363,63 @@ uint16_t mlx5_rx_burst_vec(void *dpdk_txq, struct rte_mbuf **pkts, uint32_t mlx5_rx_addr2mr_bh(struct mlx5_rxq_data *rxq, uintptr_t addr); uint32_t mlx5_tx_addr2mr_bh(struct mlx5_txq_data *txq, uintptr_t addr); +/** + * Provide safe 64bit store operation to mlx5 UAR region for both 32bit and + * 64bit architectures. + * + * @param val + * value to write in CPU endian format. + * @param addr + * Address to write to. + * @param lock + * Address of the lock to use for that UAR access. + */ +static __rte_always_inline void +__mlx5_uar_write64_relaxed(uint64_t val, volatile void *addr, + rte_spinlock_t *lock __rte_unused) +{ +#ifdef RTE_ARCH_64 + rte_write64_relaxed(val, addr); +#else /* !RTE_ARCH_64 */ + rte_spinlock_lock(lock); + rte_write32_relaxed(val, addr); + rte_io_wmb(); + rte_write32_relaxed(val >> 32, + (volatile void *)((volatile char *)addr + 4)); + rte_spinlock_unlock(lock); +#endif +} + +/** + * Provide safe 64bit store operation to mlx5 UAR region for both 32bit and + * 64bit architectures while guaranteeing the order of execution with the + * code being executed. + * + * @param val + * value to write in CPU endian format. + * @param addr + * Address to write to. + * @param lock + * Address of the lock to use for that UAR access. + */ +static __rte_always_inline void +__mlx5_uar_write64(uint64_t val, volatile void *addr, rte_spinlock_t *lock) +{ + rte_io_wmb(); + __mlx5_uar_write64_relaxed(val, addr, lock); +} + +/* Assist macros, used instead of directly calling the functions they wrap. */ +#ifdef RTE_ARCH_64 +#define mlx5_uar_write64_relaxed(val, dst, lock) \ + __mlx5_uar_write64_relaxed(val, dst, NULL) +#define mlx5_uar_write64(val, dst, lock) __mlx5_uar_write64(val, dst, NULL) +#else +#define mlx5_uar_write64_relaxed(val, dst, lock) \ + __mlx5_uar_write64_relaxed(val, dst, lock) +#define mlx5_uar_write64(val, dst, lock) __mlx5_uar_write64(val, dst, lock) +#endif + #ifndef NDEBUG /** * Verify or set magic value in CQE. @@ -619,7 +686,7 @@ uint16_t mlx5_rx_burst_vec(void *dpdk_txq, struct rte_mbuf **pkts, *txq->qp_db = rte_cpu_to_be_32(txq->wqe_ci); /* Ensure ordering between DB record and BF copy. */ rte_wmb(); - *dst = *src; + mlx5_uar_write64_relaxed(*src, dst, txq->uar_lock); if (cond) rte_wmb(); } diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c index 5057561..f9bc473 100644 --- a/drivers/net/mlx5/mlx5_txq.c +++ b/drivers/net/mlx5/mlx5_txq.c @@ -255,6 +255,9 @@ struct mlx5_txq_ctrl *txq_ctrl; int already_mapped; size_t page_size = sysconf(_SC_PAGESIZE); +#ifndef RTE_ARCH_64 + unsigned int lock_idx; +#endif memset(pages, 0, priv->txqs_n * sizeof(uintptr_t)); /* @@ -281,7 +284,7 @@ } /* new address in reserved UAR address space. */ addr = RTE_PTR_ADD(priv->uar_base, - uar_va & (MLX5_UAR_SIZE - 1)); + uar_va & (uintptr_t)(MLX5_UAR_SIZE - 1)); if (!already_mapped) { pages[pages_n++] = uar_va; /* fixed mmap to specified address in reserved @@ -305,6 +308,12 @@ else assert(txq_ctrl->txq.bf_reg == RTE_PTR_ADD((void *)addr, off)); +#ifndef RTE_ARCH_64 + /* Assign a UAR lock according to UAR page number */ + lock_idx = (txq_ctrl->uar_mmap_offset / page_size) & + MLX5_UAR_PAGE_NUM_MASK; + txq->uar_lock = &priv->uar_lock[lock_idx]; +#endif } return 0; } @@ -511,6 +520,8 @@ struct mlx5_txq_ibv * rte_atomic32_inc(&txq_ibv->refcnt); if (qp.comp_mask & MLX5DV_QP_MASK_UAR_MMAP_OFFSET) { txq_ctrl->uar_mmap_offset = qp.uar_mmap_offset; + DRV_LOG(DEBUG, "port %u: uar_mmap_offset 0x%lx", + dev->data->port_id, txq_ctrl->uar_mmap_offset); } else { DRV_LOG(ERR, "port %u failed to retrieve UAR info, invalid" -- 1.8.3.1