Received: by 10.223.176.46 with SMTP id f43csp404095wra; Tue, 23 Jan 2018 23:32:17 -0800 (PST) X-Google-Smtp-Source: AH8x227zT9mLSLpz2tN41yzmkg7D1K4dQ+RtQVm+9Xh1mC7GAiT9GZsjh9OOtIJQnZLIeUGKQByA X-Received: by 10.98.72.19 with SMTP id v19mr12348186pfa.107.1516779137695; Tue, 23 Jan 2018 23:32:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516779137; cv=none; d=google.com; s=arc-20160816; b=pfZ4CxmYlwXoiGoXKjF55mSxCIpAy506A+luHV4vQ21ALuB5wvz99ysylb2XgaLJwA eb9aBWrxANlNGuSoonTAi7ADUqaH06yDqckIheiyUb1rN565BHJuh0VUNOJLaTtHciDj 7KJrcXHb6JweEid5oVRTycr4ZbOGcq5yqZAuuluJQ6i/KK7BQYaxrWOTweUSNNKCR6Gq oNWINkbWknDNqdwsEm7+o1v6gNJmlJO+gCd633HanhvbVngsucPxO/txf+nSdoft1uA7 B/66wu/mtOOIPNbs06cY3Y4W6uWrQ97vjv5JK5KwiUNazdWTTHav7D8FNmzKtm5errX0 iztA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=8XTfZbCo9C3lWD+N/og4CM5ZmiWtLuNcAy03PXoIr74=; b=kliW8lzSlGpd8bQOWUdbPJ3XuQvOJCoLLMnlO/i/bB6P5r8L9bO9SK2nGnq+RdmyEl MgyehAYWkbHBYcbEFA4hCVTFY9rjgCnN3OtuTtcLbNuR6zTlgPGuSpXTDdYGF8Cr6cHj cbavuwhw+QYvlodkVxrxg8GOlUNtbXH1mXKkc9IVgsBYtz+iBdaP/G8wIg0jm2eQuxyY TEyk8k20khNeR+bkyLHss0ciOPLUh1bflzlhLUoSHAewrU/JWmd3uBLBpRLkXjTy4pnh G8tNadEErWbMKMpcirpFzaBW5Z0ez4QwRK/cweMr91t2ZphZ/2QLGgdiE0/h8y9uQabC CgAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qLU6xmRN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f64-v6si5828211plf.473.2018.01.23.23.32.03; Tue, 23 Jan 2018 23:32:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qLU6xmRN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932257AbeAXHbk (ORCPT + 99 others); Wed, 24 Jan 2018 02:31:40 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:46225 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932095AbeAXHbj (ORCPT ); Wed, 24 Jan 2018 02:31:39 -0500 Received: by mail-lf0-f66.google.com with SMTP id q194so3856371lfe.13 for ; Tue, 23 Jan 2018 23:31:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=8XTfZbCo9C3lWD+N/og4CM5ZmiWtLuNcAy03PXoIr74=; b=qLU6xmRNJE7YEnKvDk6cWCWosxsirhWFrE3KwWn7KGbFJzpdW04cKubpq/ZWkhFiQb WLCuyL4utWB5Xcqw3HZ3JCUB1A67dph/ZtnX0Bre88RVVfbtYuYHQVoYxqCai0lXRoWS 8cuuxDMRLZ6VE7QmziFKLK6wOd0tcALdSzfp/ESUZacQfDvbZVDmagthbOoPC8x8qV0A lQZwmtfh7HMttZ+VRkAeGoIxswG8UzHAGV4MopEV9O0Pqt7yt5xoS2hpu7/4beJPuSIh 1VY4m4eq52woCxFixv4j783tZtmRppcIyiz1dzenNPRAnsEO0mEaFeNjDrUuvABTn78m skUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=8XTfZbCo9C3lWD+N/og4CM5ZmiWtLuNcAy03PXoIr74=; b=djz0n3MW0Cyn+/MsZGKHIcg/9dPlvJxCcy0sYjoIqltJTZYkRqtDRDH5AvSnrq8ua0 5odcst1jIwM6AOn2mdN+G9K1yQHHW012qOvQqLBoMfmkcJA+5j4cHtnCRZfoA3Iy1rh3 lOQ2amaSr1TLFxDaSRu73bB5AA+7mbWSZIE02QdpbUFmRhLBIjaJdm5CJIBYHgFghIqX gnefxkoYvOomZ/EFkNihBT/Dfo7KxpwtMbGOyQcxH1dC0NH8ZpouLemdYb6rauxf/KiO A5Hp6/9Ir6oU08B3hudFjr4L6IHSBQsqSy/PaeZM7+ePzAsYxoXWRMXAOVd9J+LksYuF fySg== X-Gm-Message-State: AKwxytekLzeIsR53mA6unH4dHYZYdv8NYYp6w30NUhmB3bUVD/8XT/Fa 1pytODdEVDtwSu6WWZVqQM0/Ajxy X-Received: by 10.25.74.87 with SMTP id x84mr2805785lfa.109.1516779097460; Tue, 23 Jan 2018 23:31:37 -0800 (PST) Received: from mobilestation ([95.79.164.146]) by smtp.gmail.com with ESMTPSA id j89sm429824lfk.54.2018.01.23.23.31.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Jan 2018 23:31:36 -0800 (PST) Date: Wed, 24 Jan 2018 10:31:51 +0300 From: Serge Semin To: Jon Mason Cc: Arnd Bergmann , Dave Jiang , Allen.Hubbe@gmail.com, "Hook, Gary" , Sergey.Semin@t-platforms.ru, linux-ntb@googlegroups.com, Linux Kernel Mailing List Subject: Re: [PATCH] NTB: ntb_perf: fix cast to restricted __le32 Message-ID: <20180124073151.GB31120@mobilestation> References: <20180119173044.8013-1-fancer.lancer@gmail.com> <20180119210310.GA2284@mobilestation> <20180124041805.GD20474@kudzu.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180124041805.GD20474@kudzu.us> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 23, 2018 at 11:18:06PM -0500, Jon Mason wrote: > On Fri, Jan 19, 2018 at 10:26:37PM +0100, Arnd Bergmann wrote: > > On Fri, Jan 19, 2018 at 10:03 PM, Serge Semin wrote: > > > > > > Actually the provided patch is the best solution I could come up with. > > > The thing is, that the methods can't be changed. Those functions are > > > the part of the NTB API methods used by many drivers. So basically they > > > are like pci_{read,write}_config_{byte,word,dword}() methods. We can't > > > change their prototypes only because it's suit some driver. The methods > > > give an access to the NTB device dummy u32-sized registers, nothing > > > else. So endianness is the transmitted data settings in this case. > > > > > > NTB is the technology to interconnect some two systems with possibly > > > different endianness (unlike PCI, which interconnect CPU with LE devices). > > > In this case I'd need to set some agreement up between two systems about > > > the endianness of the exchanged data like host and network types in > > > Linux networking. I've chosen the network data to be little-endian, > > > that's why I needed first to convert them from CPU to le32, then on > > > remote side convert them back from le32 to CPU. > > > > > > If you have any better suggestion how the warning can be fixed, I'd > > > be glad to stick to it. > > > > I don't think your description matches what you actually do: The > > underlying ntb hardware drivers (amd, idt, intel, mscc) all treat the > > incoming data as CPU-endian and convert it to little-endian on > > the register side, so the framework already assumes that whatever > > you do here uses a little-endian wire-level protocol. > > > > On a little-endian kernel/CPU, nothing is ever swapped here, neither > > in the ntb_perf front-end nor in the back-ends. On a big-endian > > kernel/CPU, they both swap, so you end up with CPU-endian > > data on the wire, so it should be impossible for a big-endian > > system to talk to a little-endian one. Have you actually tried that > > combination with the current code? > > I do not believe anyone has every tried NTB on a big endien system, > let alone tried it with one side LE and the other BE. To my > knowledge, this has only ever been used on x86 to x86. > > > If my interpretation is correct, then the best solution would be to > > completely remove the cpu_to_le32/le32_to_cpu conversions > > from ntb_perf, and just define that it works like any other PCI > > device, exchanging little-endian data. > > Yes, this would be the best solution. Thank you for the insight. > > Serge, when you get a chance, please make this change and resumbit. > Ok. I'll do it in an hour. Regards, -Sergey > Thanks, > Jon > > > > > > There are two interesting cases to consider though: > > > > - if someone wants to implement an NTB based protocol > > using big-endian data on the wire, you probably want to add > > a ntb_peer_spad_read_be()/ntb_peer_msg_write_be() > > set of interfaces, to go along with ioread32_be()/iowrite32_be() > > the same way that ntb_peer_spad_read()/ntb_peer_msg_write() > > ends up doing ioread32()/iowrite32() with the implied little-endian > > behavior. > > > > - memcpy_toio()/memcpy_fromio() and ioread32_rep()/iowrite32_rep > > importantly do not do any byteswap, they are meant to > > transfer byte streams. > > > > Arnd