Received: by 10.223.176.46 with SMTP id f43csp41876wra; Fri, 19 Jan 2018 13:28:55 -0800 (PST) X-Google-Smtp-Source: ACJfBovom4A2YKlr3JJK9UsYZjzg3YFRexJNxb8YT+iJmHuv8BzSRqbDEe/R5eodGnAObhqjF+7E X-Received: by 10.98.93.65 with SMTP id r62mr39399888pfb.55.1516397335280; Fri, 19 Jan 2018 13:28:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516397335; cv=none; d=google.com; s=arc-20160816; b=yFyHWr3qCt+de//TJa711JV/C3Im8+nhwILCM3MiLXE9lDZb/h5LWABXcTP0FEMKBh kiQWi58167tKksW4As9BX9J425On5Ro6aADXgEELqbT2dRZtqN5cejcakR5SvGCnc6Hn gIW72pTo0EEwZnDRzX/tUNP94Nm3BUD8x05spcrzj046mENMqXqucaC4Tw/WB/5FNpNA enm3/6peNV9vDJxr6btJbKms0+zz/USiwpTVYbwjlVoKEEi0SNWR3Nlc7PlAaTBxb2Px iC8l1x6VS8OjM4JBWIA6DeP/ZnAsrYR4M0ibJhMm2dDfS6RKD/icthC7CZ3bCOrePrHo Xl1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=RCXJwHxDRJ7pCoqIOTmlB4wFT75wGJovUR9BqjL1ckc=; b=YRBOP8k4QdPt/hDJq6rCKXhU5zFEdBXusB2KEhYQxP1AJdyLykKAu7ZZtiXiSZJeKk 0MhEgNJWrtIcWP02U00L+In3G+w43SOZvXB5K0Ho3TQ3rFdIk+TTIwqWxOZ0LLzis5I6 AeM4L0UhrCfd76ZOmNo6wMBJbTRJgU7rC3NdFWat3RuTvNZbXk8pMt347DkLTjhZvEtF 9FmbP34SlvoBjeBi5SPH6r7whhDzbTM93XtsnAvSjKJ8WkBp44+7lt22GvTZTUbjVFZL LKtuZfzQ7kkvLl3RpxHxYfnRZdzU2+oaemU3m2rdW2Hfcf0onh9kUAUjy4g9VQOnVwy5 2djQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=QIAEnUdI; 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 m11-v6si1110101pls.98.2018.01.19.13.28.40; Fri, 19 Jan 2018 13:28:55 -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=fail header.i=@gmail.com header.s=20161025 header.b=QIAEnUdI; 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 S1756563AbeASV0n (ORCPT + 99 others); Fri, 19 Jan 2018 16:26:43 -0500 Received: from mail-oi0-f65.google.com ([209.85.218.65]:35180 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754118AbeASV0i (ORCPT ); Fri, 19 Jan 2018 16:26:38 -0500 Received: by mail-oi0-f65.google.com with SMTP id b11so2072497oif.2 for ; Fri, 19 Jan 2018 13:26:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=RCXJwHxDRJ7pCoqIOTmlB4wFT75wGJovUR9BqjL1ckc=; b=QIAEnUdIfnxlccOXmk3kDN6jMAehSjRLqdnLUXruZ4THMAu2kCp8hynblefFf9JlAr TU60QNFjgT0DG6gd09SC8ks/kztNrFwyE8GVXFG4YWjWvBjpnJ8hJhtHoYEdrUYjIWNZ hFqXk3rafJi8npctOnbKwHNIjgstIcFO2+Nar+esXX46FvyBRP+o0uIXhITEs7caoCsj KtMk3JL3ywFFKcNIgN2g9oQn7rNqP1gWmLcKXbsyITT2SauXX3wQ4bbn97gPhbNkHYWK nelRZTrAD3AFWlK/tuZLpqOLpjdLTEWqAONKpGnLpTfzsKLN7POsTBKYQLAq9Kb7iqIX VNxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=RCXJwHxDRJ7pCoqIOTmlB4wFT75wGJovUR9BqjL1ckc=; b=aYVV3wfx2//I2cSb7CUlvRdzpal8lHWhoA4shFi9qU3i4SrQubsrEskKEeXTzLbl/y 46jb2yi3k7Sz51rTy1+YkV4dcBIl+K80DNdggwhtRKiZRDEUVDeTPxcV565EKsIzTB+5 Y47yTe2swEYcuve5AgsTwV3MkDC35I2dCkRVeG3YuIODWQ7pLWBf1IKBbq/PJgDkzCON lVckdln1B1qr5xocVuCpy6dQJvWa5xOXKcB48HbhbTJb9kFl3cLWCszX1NZSQPJYWAmV Xp15HliIaYx2CmjbI+6rhByIyRMi4EaxiIf7kZzqYLxwur/hLLIp/0m6MSsSqxH/23Oc j3DQ== X-Gm-Message-State: AKwxytf0pwKdSLw6X1m3nn4ubZB99xctO5AAAXlUk1Fz34MVnwbaR6oQ nRFfEm9t2mjALN+j3i+PdCfDwjMxnF2VKDYzr7U= X-Received: by 10.202.86.22 with SMTP id k22mr5266553oib.283.1516397198016; Fri, 19 Jan 2018 13:26:38 -0800 (PST) MIME-Version: 1.0 Received: by 10.157.68.119 with HTTP; Fri, 19 Jan 2018 13:26:37 -0800 (PST) In-Reply-To: <20180119210310.GA2284@mobilestation> References: <20180119173044.8013-1-fancer.lancer@gmail.com> <20180119210310.GA2284@mobilestation> From: Arnd Bergmann Date: Fri, 19 Jan 2018 22:26:37 +0100 X-Google-Sender-Auth: jUc9DlQdK_RezoW_AQtmhbo9eQ8 Message-ID: Subject: Re: [PATCH] NTB: ntb_perf: fix cast to restricted __le32 To: Serge Semin Cc: jdmason@kudzu.us, Dave Jiang , Allen.Hubbe@gmail.com, "Hook, Gary" , Sergey.Semin@t-platforms.ru, linux-ntb@googlegroups.com, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" 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: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? 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. 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