nfp: support long reads and writes with the cpp helpers
authorJakub Kicinski <jakub.kicinski@netronome.com>
Mon, 29 May 2017 00:52:57 +0000 (17:52 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 30 May 2017 15:27:05 +0000 (11:27 -0400)
commit8b3d5a47ae6b93654e39b543e33ded07c06fa8a9
tree2dc5f7883ab3af37e48130e0dda71758f55dd75d
parent321b5e9afe2d2b31f78b60724d58a9d02888bb57
nfp: support long reads and writes with the cpp helpers

nfp_cpp_{read,write}() helpers perform device memory mapping (setting
the PCIe -> NOC translation BARs) and accessing it.  They, however,
currently implicitly expect that the length of entire operation will
fit in one BAR translation window.  There is a number of 16MB windows
available, and we don't really need to access such large areas today.

If the user, however, manages to trick the driver into making a big
mapping (e.g. by providing a huge fake FW file), the driver will
print a warning saying "No suitable BAR found for request" and a
stack trace - which most users find concerning.

To be future-proof and not scare users with warnings, make the
nfp_cpp_{read,write}() helpers do accesses chunk by chunk if the area
size is large.  Set the notion of "large" to 2MB, which is the size
of the smallest BAR window.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/netronome/nfp/nfpcore/nfp_cpp.h
drivers/net/ethernet/netronome/nfp/nfpcore/nfp_cppcore.c