lkml.org 
[lkml]   [2022]   [Aug]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.15 042/136] ice: xsk: Force rings to be sized to power of 2
    Date
    From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>

    [ Upstream commit 296f13ff3854535009a185aaf8e3603266d39d94 ]

    With the upcoming introduction of batching to XSK data path,
    performance wise it will be the best to have the ring descriptor count
    to be aligned to power of 2.

    Check if ring sizes that user is going to attach the XSK socket fulfill
    the condition above. For Tx side, although check is being done against
    the Tx queue and in the end the socket will be attached to the XDP
    queue, it is fine since XDP queues get the ring->count setting from Tx
    queues.

    Suggested-by: Alexander Lobakin <alexandr.lobakin@intel.com>
    Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Reviewed-by: Alexander Lobakin <alexandr.lobakin@intel.com>
    Acked-by: Magnus Karlsson <magnus.karlsson@intel.com>
    Link: https://lore.kernel.org/bpf/20220125160446.78976-3-maciej.fijalkowski@intel.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    drivers/net/ethernet/intel/ice/ice_xsk.c | 8 ++++++++
    1 file changed, 8 insertions(+)

    diff --git a/drivers/net/ethernet/intel/ice/ice_xsk.c b/drivers/net/ethernet/intel/ice/ice_xsk.c
    index 5581747947e57..0348cc4265034 100644
    --- a/drivers/net/ethernet/intel/ice/ice_xsk.c
    +++ b/drivers/net/ethernet/intel/ice/ice_xsk.c
    @@ -321,6 +321,13 @@ int ice_xsk_pool_setup(struct ice_vsi *vsi, struct xsk_buff_pool *pool, u16 qid)
    bool if_running, pool_present = !!pool;
    int ret = 0, pool_failure = 0;

    + if (!is_power_of_2(vsi->rx_rings[qid]->count) ||
    + !is_power_of_2(vsi->tx_rings[qid]->count)) {
    + netdev_err(vsi->netdev, "Please align ring sizes to power of 2\n");
    + pool_failure = -EINVAL;
    + goto failure;
    + }
    +
    if_running = netif_running(vsi->netdev) && ice_is_xdp_ena_vsi(vsi);

    if (if_running) {
    @@ -343,6 +350,7 @@ int ice_xsk_pool_setup(struct ice_vsi *vsi, struct xsk_buff_pool *pool, u16 qid)
    netdev_err(vsi->netdev, "ice_qp_ena error = %d\n", ret);
    }

    +failure:
    if (pool_failure) {
    netdev_err(vsi->netdev, "Could not %sable buffer pool, error = %d\n",
    pool_present ? "en" : "dis", pool_failure);
    --
    2.35.1


    \
     
     \ /
      Last update: 2022-08-29 13:06    [W:2.975 / U:0.452 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site