summaryrefslogtreecommitdiffstats
path: root/sys/dev
diff options
context:
space:
mode:
authorhselasky <hselasky@FreeBSD.org>2016-04-29 11:00:12 +0000
committerhselasky <hselasky@FreeBSD.org>2016-04-29 11:00:12 +0000
commit4383f6424070cddf19258290b1e54c5c80ba96a8 (patch)
treea59f695f98122a162708cc0157f4f9d1adbc5902 /sys/dev
parent798c273f049be68b6bccd10caaca41f8a0d7b718 (diff)
downloadFreeBSD-src-4383f6424070cddf19258290b1e54c5c80ba96a8.zip
FreeBSD-src-4383f6424070cddf19258290b1e54c5c80ba96a8.tar.gz
Add function to detect the presence of a port module and use this
function to error out early when no port module is present and doing eeprom access. This also prevents error codes from filling up in dmesg. Sponsored by: Mellanox Technologies Tested by: Netflix MFC after: 1 week
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/mlx5/driver.h2
-rw-r--r--sys/dev/mlx5/mlx5_core/mlx5_eq.c10
-rw-r--r--sys/dev/mlx5/mlx5_en/mlx5_en_main.c7
3 files changed, 18 insertions, 1 deletions
diff --git a/sys/dev/mlx5/driver.h b/sys/dev/mlx5/driver.h
index 83793d5..8136e57 100644
--- a/sys/dev/mlx5/driver.h
+++ b/sys/dev/mlx5/driver.h
@@ -542,6 +542,7 @@ struct mlx5_core_dev {
atomic_t num_qps;
u32 issi;
struct mlx5_special_contexts special_contexts;
+ unsigned int module_status[MLX5_MAX_PORTS];
};
enum {
@@ -835,6 +836,7 @@ int mlx5_set_port_mtu(struct mlx5_core_dev *dev, int mtu);
int mlx5_query_port_max_mtu(struct mlx5_core_dev *dev, int *max_mtu);
int mlx5_query_port_oper_mtu(struct mlx5_core_dev *dev, int *oper_mtu);
+unsigned int mlx5_query_module_status(struct mlx5_core_dev *dev, int module_num);
int mlx5_query_module_num(struct mlx5_core_dev *dev, int *module_num);
int mlx5_query_eeprom(struct mlx5_core_dev *dev, int i2c_addr, int page_num,
int device_addr, int size, int module_num, u32 *data,
diff --git a/sys/dev/mlx5/mlx5_core/mlx5_eq.c b/sys/dev/mlx5/mlx5_core/mlx5_eq.c
index dd407e8..8321342 100644
--- a/sys/dev/mlx5/mlx5_core/mlx5_eq.c
+++ b/sys/dev/mlx5/mlx5_core/mlx5_eq.c
@@ -579,6 +579,13 @@ 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];
+}
+
static void mlx5_port_module_event(struct mlx5_core_dev *dev,
struct mlx5_eqe *eqe)
{
@@ -612,5 +619,8 @@ static void mlx5_port_module_event(struct mlx5_core_dev *dev,
default:
device_printf((&pdev->dev)->bsddev, "INFO: ""Module %u, unknown status", module_num);
}
+ /* store module status */
+ if (module_num < MLX5_MAX_PORTS)
+ dev->module_status[module_num] = module_status;
}
diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
index 3676910..ec5dcfc 100644
--- a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
+++ b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
@@ -2561,7 +2561,12 @@ out:
"reading is not supported\n");
goto err_i2c;
}
-
+ /* Check if module is present before doing an access */
+ if (mlx5_query_module_status(priv->mdev, module_num) !=
+ MLX5_MODULE_STATUS_PLUGGED) {
+ error = EINVAL;
+ goto err_i2c;
+ }
/*
* Currently 0XA0 and 0xA2 are the only addresses permitted.
* The internal conversion is as follows:
OpenPOWER on IntegriCloud