Commit Graph

8 Commits

Author SHA1 Message Date
Michal Schmidt a4fa64a452 ethtool: provide customized dim profile management
JIRA: https://issues.redhat.com/browse/RHEL-57750

commit f750dfe825b904164688adeb147950e0e0c4d262
Author: Heng Qi <hengqi@linux.alibaba.com>
Date:   Fri Jun 21 18:13:51 2024 +0800

    ethtool: provide customized dim profile management

    The NetDIM library, currently leveraged by an array of NICs, delivers
    excellent acceleration benefits. Nevertheless, NICs vary significantly
    in their dim profile list prerequisites.

    Specifically, virtio-net backends may present diverse sw or hw device
    implementation, making a one-size-fits-all parameter list impractical.
    On Alibaba Cloud, the virtio DPU's performance under the default DIM
    profile falls short of expectations, partly due to a mismatch in
    parameter configuration.

    I also noticed that ice/idpf/ena and other NICs have customized
    profilelist or placed some restrictions on dim capabilities.

    Motivated by this, I tried adding new params for "ethtool -C" that provides
    a per-device control to modify and access a device's interrupt parameters.

    Usage
    ========
    The target NIC is named ethx.

    Assume that ethx only declares support for rx profile setting
    (with DIM_PROFILE_RX flag set in profile_flags) and supports modification
    of usec and pkt fields.

    1. Query the currently customized list of the device

    $ ethtool -c ethx
    ...
    rx-profile:
    {.usec =   1, .pkts = 256, .comps = n/a,},
    {.usec =   8, .pkts = 256, .comps = n/a,},
    {.usec =  64, .pkts = 256, .comps = n/a,},
    {.usec = 128, .pkts = 256, .comps = n/a,},
    {.usec = 256, .pkts = 256, .comps = n/a,}
    tx-profile:   n/a

    2. Tune
    $ ethtool -C ethx rx-profile 1,1,n_2,n,n_3,3,n_4,4,n_n,5,n
    "n" means do not modify this field.
    $ ethtool -c ethx
    ...
    rx-profile:
    {.usec =   1, .pkts =   1, .comps = n/a,},
    {.usec =   2, .pkts = 256, .comps = n/a,},
    {.usec =   3, .pkts =   3, .comps = n/a,},
    {.usec =   4, .pkts =   4, .comps = n/a,},
    {.usec = 256, .pkts =   5, .comps = n/a,}
    tx-profile:   n/a

    3. Hint
    If the device does not support some type of customized dim profiles,
    the corresponding "n/a" will display.

    If the "n/a" field is being modified, -EOPNOTSUPP will be reported.

    Signed-off-by: Heng Qi <hengqi@linux.alibaba.com>
    Reviewed-by: Simon Horman <horms@kernel.org>
    Link: https://patch.msgid.link/20240621101353.107425-4-hengqi@linux.alibaba.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Conflicts:
	include/linux/netdevice.h - RH_KABI_RESERVEs at the end.

Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
2024-10-01 12:19:13 +02:00
Michal Schmidt f557ebe8ea linux/dim: move useful macros to .h file
JIRA: https://issues.redhat.com/browse/RHEL-57750

commit 0e942053e4dc42a760f48c1981f3239825430f15
Author: Heng Qi <hengqi@linux.alibaba.com>
Date:   Fri Jun 21 18:13:49 2024 +0800

    linux/dim: move useful macros to .h file

    Useful macros will be used effectively elsewhere.
    These will be utilized in subsequent patches.

    Signed-off-by: Heng Qi <hengqi@linux.alibaba.com>
    Reviewed-by: Simon Horman <horms@kernel.org>
    Link: https://patch.msgid.link/20240621101353.107425-2-hengqi@linux.alibaba.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
2024-10-01 12:19:13 +02:00
Michal Schmidt 5104c0f65f dim: initialize all struct fields
JIRA: https://issues.redhat.com/browse/RHEL-57750

commit ee1444b5e1df4155b591d0d9b1e72853a99ea861
Author: Jesse Brandeburg <jesse.brandeburg@intel.com>
Date:   Fri May 6 18:10:38 2022 -0700

    dim: initialize all struct fields

    The W=2 build pointed out that the code wasn't initializing all the
    variables in the dim_cq_moder declarations with the struct initializers.
    The net change here is zero since these structs were already static
    const globals and were initialized with zeros by the compiler, but
    removing compiler warnings has value in and of itself.

    lib/dim/net_dim.c: At top level:
    lib/dim/net_dim.c:54:9: warning: missing initializer for field ‘comps’ of ‘const struct dim_cq_moder’ [-Wmissing-field-initializers]
       54 |         NET_DIM_RX_EQE_PROFILES,
          |         ^~~~~~~~~~~~~~~~~~~~~~~
    In file included from lib/dim/net_dim.c:6:
    ./include/linux/dim.h:45:13: note: ‘comps’ declared here
       45 |         u16 comps;
          |             ^~~~~

    and repeats for the tx struct, and once you fix the comps entry then
    the cq_period_mode field needs the same treatment.

    Use the commonly accepted style to indicate to the compiler that we
    know what we're doing, and add a comma at the end of each struct
    initializer to clean up the issue, and use explicit initializers
    for the fields we are initializing which makes the compiler happy.

    While here and fixing these lines, clean up the code slightly with
    a fix for the super long lines by removing the word "_MODERATION" from a
    couple defines only used in this file.

    Fixes: f8be17b81d ("lib/dim: Fix -Wunused-const-variable warnings")
    Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
    Link: https://lore.kernel.org/r/20220507011038.14568-1-jesse.brandeburg@intel.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
2024-10-01 12:19:12 +02:00
Nick Desaulniers 4c1ca831ad Revert "lib: Revert use of fallthrough pseudo-keyword in lib/"
This reverts commit 6a9dc5fd61 ("lib: Revert use of fallthrough
pseudo-keyword in lib/")

Now that we can build arch/powerpc/boot/ free of -Wimplicit-fallthrough,
re-enable these fixes for lib/.

Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Miguel Ojeda <ojeda@kernel.org>
Link: https://github.com/ClangBuiltLinux/linux/issues/236
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
2020-11-18 14:15:17 -06:00
Gustavo A. R. Silva 6a9dc5fd61 lib: Revert use of fallthrough pseudo-keyword in lib/
The following build error for powerpc64 was reported by Nathan Chancellor:

  "$ scripts/config --file arch/powerpc/configs/powernv_defconfig -e KERNEL_XZ

   $ make -skj"$(nproc)" ARCH=powerpc CROSS_COMPILE=powerpc64le-linux- distclean powernv_defconfig zImage
   ...
   In file included from arch/powerpc/boot/../../../lib/decompress_unxz.c:234,
                    from arch/powerpc/boot/decompress.c:38:
   arch/powerpc/boot/../../../lib/xz/xz_dec_stream.c: In function 'dec_main':
   arch/powerpc/boot/../../../lib/xz/xz_dec_stream.c:586:4: error: 'fallthrough' undeclared (first use in this function)
     586 |    fallthrough;
         |    ^~~~~~~~~~~

   This will end up affecting distribution configurations such as Debian
   and OpenSUSE according to my testing. I am not sure what the solution
   is, the PowerPC wrapper does not set -D__KERNEL__ so I am not sure
   that compiler_attributes.h can be safely included."

In order to avoid these sort of problems, it seems that the best
solution is to use /* fall through */ comments instead of the
fallthrough pseudo-keyword macro in lib/, for now.

Reported-by: Nathan Chancellor <natechancellor@gmail.com>
Fixes: df561f6688 ("treewide: Use fallthrough pseudo-keyword")
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-and-tested-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-08-24 14:17:44 -07:00
Gustavo A. R. Silva df561f6688 treewide: Use fallthrough pseudo-keyword
Replace the existing /* fall through */ comments and its variants with
the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
fall-through markings when it is the case.

[1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
2020-08-23 17:36:59 -05:00
Leon Romanovsky f8be17b81d lib/dim: Fix -Wunused-const-variable warnings
DIM causes to the following warnings during kernel compilation
which indicates that tx_profile and rx_profile are supposed to
be declared in *.c and not in *.h files.

In file included from ./include/rdma/ib_verbs.h:64,
                 from ./include/linux/mlx5/device.h:37,
                 from ./include/linux/mlx5/driver.h:51,
                 from ./include/linux/mlx5/vport.h:36,
                 from drivers/infiniband/hw/mlx5/ib_virt.c:34:
./include/linux/dim.h:326:1: warning: _tx_profile_ defined but not used [-Wunused-const-variable=]
  326 | tx_profile[DIM_CQ_PERIOD_NUM_MODES][NET_DIM_PARAMS_NUM_PROFILES] = {
      | ^~~~~~~~~~
./include/linux/dim.h:320:1: warning: _rx_profile_ defined but not used [-Wunused-const-variable=]
  320 | rx_profile[DIM_CQ_PERIOD_NUM_MODES][NET_DIM_PARAMS_NUM_PROFILES] = {
      | ^~~~~~~~~~

Fixes: 4f75da3666 ("linux/dim: Move implementation to .c files")
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Acked-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-07-25 11:34:39 -07:00
Tal Gilboa 4f75da3666 linux/dim: Move implementation to .c files
Moved all logic from dim.h and net_dim.h to dim.c and net_dim.c.
This is both more structurally appealing and would allow to only
expose externally used functions.

Signed-off-by: Tal Gilboa <talgi@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
2019-06-25 13:46:39 -07:00