]> www.infradead.org Git - nvme.git/commit
mlxsw: pci: Use fragmented buffers
authorAmit Cohen <amcohen@nvidia.com>
Tue, 25 Jun 2024 13:47:35 +0000 (15:47 +0200)
committerJakub Kicinski <kuba@kernel.org>
Wed, 26 Jun 2024 14:43:57 +0000 (07:43 -0700)
commit36437f469d7e92635c8e07b63bd490f0c14c3cba
tree37ed8f9072561ee2f0c5c52b1562bb6dcb5afe7b
parent8f8cea8f3ddbd8f64d4f08c2d8525989c4fb44d4
mlxsw: pci: Use fragmented buffers

WQE (Work Queue Element) includes 3 scatter/gather entries for buffers.
The buffer can be split into 3 parts, software should set address and byte
count of each part.

A previous patch-set used page pool to allocate buffers, to simplify the
change, we first used one continuous buffer, which was allocated with
order > 0. This patch improves page pool usage to allocate the exact
number of pages which are required for packet.

As part of init, fill WQE.address[x] and WQE.byte_count* with pages which
are allocated from the pool. Fill x entries according to number of
scatter/gather entries which are required for maximum packet size. When a
packet is received, check the actual size and replace only the used pages.
Save bytes for software overhead only as part of the first entry.

This change also requires using fragmented SKB, till now all the buffer
was in the linear part. Note that 'skb->truesize' is decreased for small
packets.

For now the maximum buffer size is 3 * PAGE_SIZE which is enough, in
case that the driver will support larger MTU, we can use 'order' to
allocate more than one page per scatter/gather entry.

This change significantly reduces memory consumption of mlxsw driver. The
footprint is reduced by 26%.

Signed-off-by: Amit Cohen <amcohen@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
Link: https://patch.msgid.link/ee38898c692e7f644a7f3ea4d33aeddb4dd917d2.1719321422.git.petrm@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlxsw/pci.c