• Amit Cohen's avatar
    mlxsw: pci: Use fragmented buffers · 36437f46
    Amit Cohen authored
    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: default avatarAmit Cohen <amcohen@nvidia.com>
    Reviewed-by: default avatarIdo Schimmel <idosch@nvidia.com>
    Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
    Link: https://patch.msgid.link/ee38898c692e7f644a7f3ea4d33aeddb4dd917d2.1719321422.git.petrm@nvidia.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
    36437f46
pci.c 66.6 KB