LCOV - code coverage report
Current view: top level - app/shared/commands/configure - mlx5.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 41 0.0 %
Date: 2026-11-08 04:25:05 Functions: 0 6 0.0 %

          Line data    Source code
       1             : #include "configure.h"
       2             : #include "fd_ethtool_ioctl.h"
       3             : #include "../../../platform/fd_sys_util.h"
       4             : #include "../../../../disco/net/mlx5/fd_mlx5.h"
       5             : 
       6             : #include <linux/capability.h>
       7             : 
       8             : static int
       9           0 : enabled( config_t const * config ) {
      10           0 :   return !strcmp( config->net.provider, "mlx5" );
      11           0 : }
      12             : 
      13             : static void
      14             : init_perm( fd_cap_chk_t   * chk,
      15           0 :            config_t const * config FD_PARAM_UNUSED ) {
      16           0 :   fd_cap_chk_root( chk, "mlx5", "configure mlx5 network devices and load the ib_uverbs kernel module" );
      17           0 :   if( !fd_mlx5_uverbs_avail() ) {
      18           0 :     fd_cap_chk_cap( chk, "mlx5", CAP_SYS_MODULE, "run modprobe to load the ib_uverbs kernel module" );
      19           0 :   }
      20           0 : }
      21             : 
      22             : static void
      23             : fini_perm( fd_cap_chk_t   * chk,
      24           0 :            config_t const * config FD_PARAM_UNUSED ) {
      25           0 :   fd_cap_chk_root( chk, "mlx5", "modify network device configuration with ethtool" );
      26           0 : }
      27             : 
      28             : static void
      29           0 : init( config_t const * config FD_PARAM_UNUSED ) {
      30           0 :   if( !fd_mlx5_uverbs_avail() ) {
      31           0 :     FD_LOG_NOTICE(( "%sRUN: `modprobe ib_uverbs`%s", fd_log_style_dim(), fd_log_style_normal() ));
      32           0 :     if( FD_UNLIKELY( -1==fd_sys_util_modprobe( "ib_uverbs", 0 ) ) ) {
      33           0 :       FD_LOG_ERR(( "failed to load ib_uverbs kernel module. "
      34           0 :                    "Run `sudo modprobe ib_uverbs` and retry" ));
      35           0 :     }
      36           0 :     if( FD_UNLIKELY( !fd_mlx5_uverbs_avail() ) ) {
      37           0 :       FD_LOG_ERR(( "failed to run mlx5 tile: uverbs interface still unavailable after trying to load ib_uverbs kernel module. "
      38           0 :                    "Please set [net.provider] to `xdp`" ));
      39           0 :     }
      40           0 :   }
      41           0 : }
      42             : 
      43             : static int
      44             : fini( config_t const * config,
      45           0 :       int              pre_init FD_PARAM_UNUSED ) {
      46           0 :   return fd_ethtool_ioctl_reset( config->net.interface );
      47           0 : }
      48             : 
      49             : static configure_result_t
      50             : check( config_t const * config,
      51           0 :        int              check_type ) {
      52           0 :   int is_modified = fd_ethtool_ioctl_is_modified( config->net.interface );
      53           0 :   if( FD_UNLIKELY( is_modified ) ) {
      54           0 :     PARTIALLY_CONFIGURED( "device `%s` has ethtool configuration left by the xdp provider", config->net.interface );
      55           0 :   }
      56             : 
      57           0 :   if( check_type==FD_CONFIGURE_CHECK_TYPE_FINI_PERM ||
      58           0 :       check_type==FD_CONFIGURE_CHECK_TYPE_PRE_FINI  ||
      59           0 :       check_type==FD_CONFIGURE_CHECK_TYPE_POST_FINI ) {
      60           0 :     NOT_CONFIGURED( "device `%s` has no ethtool configuration to clear", config->net.interface );
      61           0 :   }
      62             : 
      63           0 :   if( !fd_mlx5_uverbs_avail() ) NOT_CONFIGURED( "uverbs interface unavailable" );
      64           0 :   CONFIGURE_OK();
      65           0 : }
      66             : 
      67             : configure_stage_t fd_cfg_stage_mlx5 = {
      68             :   .name      = "mlx5",
      69             :   .enabled   = enabled,
      70             :   .init_perm = init_perm,
      71             :   .fini_perm = fini_perm,
      72             :   .init      = init,
      73             :   .fini      = fini,
      74             :   .check     = check,
      75             : };

Generated by: LCOV version 1.14