Received: by 10.223.176.46 with SMTP id f43csp265586wra; Tue, 23 Jan 2018 20:37:48 -0800 (PST) X-Google-Smtp-Source: AH8x226pOisTlt2vtXzL46OJK7BA7ol0yrk/PPltsV3q9hlAIYXq890Pga3m1AJcD/rwu4lzPcK3 X-Received: by 10.98.228.5 with SMTP id r5mr12127620pfh.193.1516768668579; Tue, 23 Jan 2018 20:37:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516768668; cv=none; d=google.com; s=arc-20160816; b=T9HwJv7+Og6z+Ir8ZRmSWPU5MC0og00lPVPo404jUhwBhWXtDwUzUIJtSe+AD66HM7 jQtMQe1SiIDN5pAmQnMjyAmEFWyr0uQuv8vSIPnL2CjuarqM2Pdmtmfl/sNKacbSFCnl +AnnzE1xkTf8+j3nwqknE/VsL8NFrVsJVQOPhqfPvr719t+AajQhdGoFFTSbpE+GfiiI SExG/ezz/9ERKOCI5VAR7oePidByeorOoeVL4akIv5XzaYG4hag/jfLx2ySXEy4Q+5sG hrdqbFapV+ilXsiVaga67HmEXw+qmblW5SnrCEY7wgg0mnZhHFUKYPUj5q9QHu1Th+Yl zTZw== 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=5QK4j05+5RlIrkbUm0lswEjENN3Q/aImjDcRY1acG4Y=; b=Wl8+CMxBO4/01fqIHncgXE1677Boyc646Qo477993HrYnXIx0jFhMhQTysyIlS5JBk 3N/kg0nojcwSqZLbwql78CrmvaODHHAsfSybsUsYI0ghFcLpWfED4nespH2NItGXoduP cBs8864ay9potr3GoKZ3s4vKBa+tp9r2ml7MtW4PS5j8lbnicmD6lmYZXtDp7gQNd4Nj 5Hbxt4RzreM4IXvUDKoa99Rth9PXFBT4qB0TPO9osPHpGlmiX9tsnVxl4pHwTjU8ZALl QrtzD+83W5K4v0ChvHkwpLVr8LgoNNeScu3VTOuL4hO8IQxOXw/Zvw81V4KRiFrDlmAS sitw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kudzu-us.20150623.gappssmtp.com header.s=20150623 header.b=P1ElOHfe; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c2-v6si2983517plb.439.2018.01.23.20.37.35; Tue, 23 Jan 2018 20:37:48 -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=@kudzu-us.20150623.gappssmtp.com header.s=20150623 header.b=P1ElOHfe; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933075AbeAXEhN (ORCPT + 99 others); Tue, 23 Jan 2018 23:37:13 -0500 Received: from mail-qt0-f193.google.com ([209.85.216.193]:35965 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932979AbeAXESJ (ORCPT ); Tue, 23 Jan 2018 23:18:09 -0500 Received: by mail-qt0-f193.google.com with SMTP id z11so7247794qtm.3 for ; Tue, 23 Jan 2018 20:18:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kudzu-us.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=5QK4j05+5RlIrkbUm0lswEjENN3Q/aImjDcRY1acG4Y=; b=P1ElOHfe/+UcHNZeGpHrG4b5nO/ZBsvw90SNj9Jp10XC3JIxR2VchI+Lgnr5vPEjMo NYex1HHUP3ildsqTRdPqTNnSxcKcSpZU6eVyG+noVWCWRg5pbaNo00riF514KH+9n2IP ioAvioBoGwMcZ0Fu9rHBOk1gWQN8u7A4pTV2nAsNtVgPw2Dy7fx0vad3tOUHWes+wgJN 1J/8gUzu99rt2g4rY3T4yXoCTjrdqVBJioJAl/9s0znw+V8KVjRhnbWG6siNAKB70D7E YqwKk2TgUrFAbSEeNkGc0DX9LB7wYurkGnVFJAkNOxPRvs3FdQMXEGmSlBmDEE88Lw0+ e5BA== 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=5QK4j05+5RlIrkbUm0lswEjENN3Q/aImjDcRY1acG4Y=; b=HSwkeVAURlHwCmDGN1MQf+fGVZfH/ekoU+jt/k9cAFf9fz2z3yEUdjB3PfffgjGFv8 HeLgartnLaVPJdBXbXjL8rety7Uq1wois8SAQ4B6whR7T+07Etisv7ZfsqxExB8wFcDt c7iTutK0iunDAhi+W/c+A0xme3MBEbE7U123A2sBsku3BbkUs5fGnGmowLcoeMH++74+ 4N0l6Kt/enc6Eb+Oxi7KnTq0YV6XGQoOmORBNKN2bls1+yJbM70+rwVrVNZCdtt2miE5 IjDWvdL0or+7l+Auy0GjD5jXtTufWot35eiKRt2itJwthyhtw0iCxf17f2MMXH+bjUwl 6yEA== X-Gm-Message-State: AKwxytev77unFHi92pMRaA3abUWFBDn0uJFRT4j0MzYf0CiHgyivl0Ae scx2FM/2rJAfMCgvcvB91o1fBGxGkJg= X-Received: by 10.237.51.69 with SMTP id u63mr7623734qtd.285.1516767488752; Tue, 23 Jan 2018 20:18:08 -0800 (PST) Received: from kudzu.us ([98.122.141.161]) by smtp.gmail.com with ESMTPSA id o5sm1659966qtc.72.2018.01.23.20.18.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Jan 2018 20:18:08 -0800 (PST) Date: Tue, 23 Jan 2018 23:18:06 -0500 From: Jon Mason To: Arnd Bergmann Cc: Serge Semin , 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: <20180124041805.GD20474@kudzu.us> References: <20180119173044.8013-1-fancer.lancer@gmail.com> <20180119210310.GA2284@mobilestation> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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