mlx5: Fix handling of port_module_event
Some checks are pending
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-14, /usr/lib/llvm-14/bin, ubuntu-22.04, bmake libarchive-dev clang-14 lld-14, amd64, amd64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-14, /usr/lib/llvm-14/bin, ubuntu-22.04, bmake libarchive-dev clang-14 lld-14, arm64, aarch64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-18, /opt/homebrew/opt/llvm@18/bin, macos-latest, bmake libarchive llvm@18, amd64, amd64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-18, /opt/homebrew/opt/llvm@18/bin, macos-latest, bmake libarchive llvm@18, arm64, aarch64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-18, /usr/lib/llvm-18/bin, ubuntu-24.04, bmake libarchive-dev clang-18 lld-18, amd64, amd64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-18, /usr/lib/llvm-18/bin, ubuntu-24.04, bmake libarchive-dev clang-18 lld-18, arm64, aarch64) (push) Waiting to run

Remove the array of port module status and instead save module status
and module number.

At boot, for each PCI function driver get event from fw about module
status. The event contains module number and module status. Driver
stores module number and module status..  When user (ifconfig) ask for
modules information, for each pci function driver first queries fw to
get module number of current pci function, then driver compares the
module number to the module number it stored before and if it matches
and module status is "plugged and enabled" then driver queries fw for
the eprom information of that module number and return it to the
caller.

In fact fw could have concluded that required module number of the
current pci function, but fw is not implemented this way. current
design of PRM/FW is that MCIA register handling is only aware of
modules, not the pci function->module connections.  FW is designed to
take the module number written to MCIA and write/read the content
to/from the associated module's EPROM.

So, based on current FW design, we must supply the module num so fw
can find the corresponding I2C interface of the module to write/read.

Sponsored by:	NVidia networking
MFC after:	1 week
This commit is contained in:
Ariel Ehrenberg 2024-10-31 11:18:26 +02:00 committed by Konstantin Belousov
parent 0d38b0bc8f
commit 253a1fa16b
2 changed files with 7 additions and 6 deletions

View File

@ -723,7 +723,8 @@ struct mlx5_core_dev {
u32 vsc_addr;
u32 issi;
struct mlx5_special_contexts special_contexts;
unsigned int module_status[MLX5_MAX_PORTS];
unsigned int module_status;
unsigned int module_num;
struct mlx5_flow_root_namespace *root_ns;
struct mlx5_flow_root_namespace *fdb_root_ns;
struct mlx5_flow_root_namespace *esw_egress_root_ns;

View File

@ -690,9 +690,9 @@ static const char *mlx5_port_module_event_error_type_to_string(u8 error_type)
unsigned int mlx5_query_module_status(struct mlx5_core_dev *dev, int module_num)
{
if (module_num < 0 || module_num >= MLX5_MAX_PORTS)
return 0; /* undefined */
return dev->module_status[module_num];
if (module_num != dev->module_num)
return 0; /* module num doesn't equal to what FW reported */
return dev->module_status;
}
static void mlx5_port_module_event(struct mlx5_core_dev *dev,
@ -740,8 +740,8 @@ static void mlx5_port_module_event(struct mlx5_core_dev *dev,
"Module %u, unknown status %d\n", module_num, module_status);
}
/* store module status */
if (module_num < MLX5_MAX_PORTS)
dev->module_status[module_num] = module_status;
dev->module_status = module_status;
dev->module_num = module_num;
}
static void mlx5_port_general_notification_event(struct mlx5_core_dev *dev,