Commit 97167e81 authored by Easwar Hariharan's avatar Easwar Hariharan Committed by Doug Ledford

staging/rdma/hfi1: Tune for unknown channel if configuration file is absent

Currently, the driver fails to tune the SerDes and therefore prevents
link up if the configuration file is missing or fails parsing or
validation. This patch adds a fallback option so that the 8051 is asked
to tune for an unknown channel and possibly get the link up if tuning
succeeds. It also adds a user-friendly message to update the
configuration file if it is out-of-date.
Reviewed-by: default avatarMike Marciniszyn <mike.marciniszyn@intel.com>
Reviewed-by: default avatarDean Luick <dean.luick@intel.com>
Signed-off-by: default avatarEaswar Hariharan <easwar.hariharan@intel.com>
Signed-off-by: default avatarJubin John <jubin.john@intel.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent c3838b39
...@@ -390,6 +390,10 @@ ...@@ -390,6 +390,10 @@
#define LINK_QUALITY_INFO 0x14 #define LINK_QUALITY_INFO 0x14
#define REMOTE_DEVICE_ID 0x15 #define REMOTE_DEVICE_ID 0x15
/* 8051 lane specific register field IDs */
#define TX_EQ_SETTINGS 0x00
#define CHANNEL_LOSS_SETTINGS 0x05
/* Lane ID for general configuration registers */ /* Lane ID for general configuration registers */
#define GENERAL_CONFIG 4 #define GENERAL_CONFIG 4
......
...@@ -703,8 +703,6 @@ static int obtain_firmware(struct hfi1_devdata *dd) ...@@ -703,8 +703,6 @@ static int obtain_firmware(struct hfi1_devdata *dd)
&dd->pcidev->dev); &dd->pcidev->dev);
if (err) { if (err) {
platform_config = NULL; platform_config = NULL;
fw_state = FW_ERR;
fw_err = -ENOENT;
goto done; goto done;
} }
dd->platform_config.data = platform_config->data; dd->platform_config.data = platform_config->data;
...@@ -1470,12 +1468,51 @@ int hfi1_firmware_init(struct hfi1_devdata *dd) ...@@ -1470,12 +1468,51 @@ int hfi1_firmware_init(struct hfi1_devdata *dd)
return obtain_firmware(dd); return obtain_firmware(dd);
} }
/*
* This function is a helper function for parse_platform_config(...) and
* does not check for validity of the platform configuration cache
* (because we know it is invalid as we are building up the cache).
* As such, this should not be called from anywhere other than
* parse_platform_config
*/
static int check_meta_version(struct hfi1_devdata *dd, u32 *system_table)
{
u32 meta_ver, meta_ver_meta, ver_start, ver_len, mask;
struct platform_config_cache *pcfgcache = &dd->pcfg_cache;
if (!system_table)
return -EINVAL;
meta_ver_meta =
*(pcfgcache->config_tables[PLATFORM_CONFIG_SYSTEM_TABLE].table_metadata
+ SYSTEM_TABLE_META_VERSION);
mask = ((1 << METADATA_TABLE_FIELD_START_LEN_BITS) - 1);
ver_start = meta_ver_meta & mask;
meta_ver_meta >>= METADATA_TABLE_FIELD_LEN_SHIFT;
mask = ((1 << METADATA_TABLE_FIELD_LEN_LEN_BITS) - 1);
ver_len = meta_ver_meta & mask;
ver_start /= 8;
meta_ver = *((u8 *)system_table + ver_start) & ((1 << ver_len) - 1);
if (meta_ver < 5) {
dd_dev_info(
dd, "%s:Please update platform config\n", __func__);
return -EINVAL;
}
return 0;
}
int parse_platform_config(struct hfi1_devdata *dd) int parse_platform_config(struct hfi1_devdata *dd)
{ {
struct platform_config_cache *pcfgcache = &dd->pcfg_cache; struct platform_config_cache *pcfgcache = &dd->pcfg_cache;
u32 *ptr = NULL; u32 *ptr = NULL;
u32 header1 = 0, header2 = 0, magic_num = 0, crc = 0, file_length = 0; u32 header1 = 0, header2 = 0, magic_num = 0, crc = 0, file_length = 0;
u32 record_idx = 0, table_type = 0, table_length_dwords = 0; u32 record_idx = 0, table_type = 0, table_length_dwords = 0;
int ret = -EINVAL; /* assume failure */
if (!dd->platform_config.data) { if (!dd->platform_config.data) {
dd_dev_info(dd, "%s: Missing config file\n", __func__); dd_dev_info(dd, "%s: Missing config file\n", __func__);
...@@ -1499,7 +1536,8 @@ int parse_platform_config(struct hfi1_devdata *dd) ...@@ -1499,7 +1536,8 @@ int parse_platform_config(struct hfi1_devdata *dd)
__func__); __func__);
goto bail; goto bail;
} else if (file_length < dd->platform_config.size) { } else if (file_length < dd->platform_config.size) {
dd_dev_info(dd, "%s:File claims to be smaller than read size\n", dd_dev_info(dd,
"%s:File claims to be smaller than read size, continuing\n",
__func__); __func__);
} }
/* exactly equal, perfection */ /* exactly equal, perfection */
...@@ -1537,6 +1575,9 @@ int parse_platform_config(struct hfi1_devdata *dd) ...@@ -1537,6 +1575,9 @@ int parse_platform_config(struct hfi1_devdata *dd)
case PLATFORM_CONFIG_SYSTEM_TABLE: case PLATFORM_CONFIG_SYSTEM_TABLE:
pcfgcache->config_tables[table_type].num_table = pcfgcache->config_tables[table_type].num_table =
1; 1;
ret = check_meta_version(dd, ptr);
if (ret)
goto bail;
break; break;
case PLATFORM_CONFIG_PORT_TABLE: case PLATFORM_CONFIG_PORT_TABLE:
pcfgcache->config_tables[table_type].num_table = pcfgcache->config_tables[table_type].num_table =
...@@ -1609,7 +1650,7 @@ int parse_platform_config(struct hfi1_devdata *dd) ...@@ -1609,7 +1650,7 @@ int parse_platform_config(struct hfi1_devdata *dd)
return 0; return 0;
bail: bail:
memset(pcfgcache, 0, sizeof(struct platform_config_cache)); memset(pcfgcache, 0, sizeof(struct platform_config_cache));
return -EINVAL; return ret;
} }
static int get_platform_fw_field_metadata(struct hfi1_devdata *dd, int table, static int get_platform_fw_field_metadata(struct hfi1_devdata *dd, int table,
......
...@@ -498,14 +498,14 @@ static void apply_rx_amplitude_settings( ...@@ -498,14 +498,14 @@ static void apply_rx_amplitude_settings(
#define OPA_INVALID_INDEX 0xFFF #define OPA_INVALID_INDEX 0xFFF
static void apply_tx_lanes(struct hfi1_pportdata *ppd, u32 config_data, static void apply_tx_lanes(struct hfi1_pportdata *ppd, u8 field_id,
const char *message) u32 config_data, const char *message)
{ {
u8 i; u8 i;
int ret = HCMD_SUCCESS; int ret = HCMD_SUCCESS;
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
ret = load_8051_config(ppd->dd, 0, i, config_data); ret = load_8051_config(ppd->dd, field_id, i, config_data);
if (ret != HCMD_SUCCESS) { if (ret != HCMD_SUCCESS) {
dd_dev_err( dd_dev_err(
ppd->dd, ppd->dd,
...@@ -524,6 +524,7 @@ static void apply_tunings( ...@@ -524,6 +524,7 @@ static void apply_tunings(
u8 precur = 0, attn = 0, postcur = 0, external_device_config = 0; u8 precur = 0, attn = 0, postcur = 0, external_device_config = 0;
u8 *cache = ppd->qsfp_info.cache; u8 *cache = ppd->qsfp_info.cache;
/* Enable external device config if channel is limiting active */
read_8051_config(ppd->dd, LINK_OPTIMIZATION_SETTINGS, read_8051_config(ppd->dd, LINK_OPTIMIZATION_SETTINGS,
GENERAL_CONFIG, &config_data); GENERAL_CONFIG, &config_data);
config_data |= limiting_active; config_data |= limiting_active;
...@@ -536,6 +537,7 @@ static void apply_tunings( ...@@ -536,6 +537,7 @@ static void apply_tunings(
__func__); __func__);
config_data = 0; /* re-init */ config_data = 0; /* re-init */
/* Pass tuning method to 8051 */
read_8051_config(ppd->dd, LINK_TUNING_PARAMETERS, GENERAL_CONFIG, read_8051_config(ppd->dd, LINK_TUNING_PARAMETERS, GENERAL_CONFIG,
&config_data); &config_data);
config_data |= tuning_method; config_data |= tuning_method;
...@@ -545,47 +547,39 @@ static void apply_tunings( ...@@ -545,47 +547,39 @@ static void apply_tunings(
dd_dev_err(ppd->dd, "%s: Failed to set tuning method\n", dd_dev_err(ppd->dd, "%s: Failed to set tuning method\n",
__func__); __func__);
external_device_config = /* Set same channel loss for both TX and RX */
((cache[QSFP_MOD_PWR_OFFS] & 0x4) << 3) | config_data = 0 | (total_atten << 16) | (total_atten << 24);
((cache[QSFP_MOD_PWR_OFFS] & 0x8) << 2) | apply_tx_lanes(ppd, CHANNEL_LOSS_SETTINGS, config_data,
((cache[QSFP_EQ_INFO_OFFS] & 0x2) << 1) | "Setting channel loss");
(cache[QSFP_EQ_INFO_OFFS] & 0x4);
/* Inform 8051 of cable capabilities */
config_data = 0; /* re-init */ if (ppd->qsfp_info.cache_valid) {
read_8051_config(ppd->dd, DC_HOST_COMM_SETTINGS, GENERAL_CONFIG, external_device_config =
&config_data); ((cache[QSFP_MOD_PWR_OFFS] & 0x4) << 3) |
config_data |= (external_device_config << 24); ((cache[QSFP_MOD_PWR_OFFS] & 0x8) << 2) |
ret = load_8051_config(ppd->dd, DC_HOST_COMM_SETTINGS, GENERAL_CONFIG, ((cache[QSFP_EQ_INFO_OFFS] & 0x2) << 1) |
config_data); (cache[QSFP_EQ_INFO_OFFS] & 0x4);
if (ret != HCMD_SUCCESS) ret = read_8051_config(ppd->dd, DC_HOST_COMM_SETTINGS,
dd_dev_err( GENERAL_CONFIG, &config_data);
ppd->dd, /* Clear, then set the external device config field */
"%s: Failed to set external device config parameters\n", config_data &= ~(0xFF << 24);
__func__); config_data |= (external_device_config << 24);
ret = load_8051_config(ppd->dd, DC_HOST_COMM_SETTINGS,
config_data = 0; /* re-init */ GENERAL_CONFIG, config_data);
read_8051_config(ppd->dd, TX_SETTINGS, GENERAL_CONFIG, &config_data); if (ret != HCMD_SUCCESS)
if ((ppd->link_speed_supported & OPA_LINK_SPEED_25G) && dd_dev_info(ppd->dd,
(ppd->link_speed_enabled & OPA_LINK_SPEED_25G)) "%s: Failed set ext device config params\n",
config_data |= 0x02; __func__);
if ((ppd->link_speed_supported & OPA_LINK_SPEED_12_5G) && }
(ppd->link_speed_enabled & OPA_LINK_SPEED_12_5G))
config_data |= 0x01;
ret = load_8051_config(ppd->dd, TX_SETTINGS, GENERAL_CONFIG,
config_data);
if (ret != HCMD_SUCCESS)
dd_dev_err(
ppd->dd,
"%s: Failed to set external device config parameters\n",
__func__);
config_data = (total_atten << 8) | (total_atten);
apply_tx_lanes(ppd, config_data, "Setting channel loss");
if (tx_preset_index == OPA_INVALID_INDEX) if (tx_preset_index == OPA_INVALID_INDEX) {
if (ppd->port_type == PORT_TYPE_QSFP && limiting_active)
dd_dev_info(ppd->dd, "%s: Invalid Tx preset index\n",
__func__);
return; return;
}
/* Following for limiting active channels only */
get_platform_config_field( get_platform_config_field(
ppd->dd, PLATFORM_CONFIG_TX_PRESET_TABLE, tx_preset_index, ppd->dd, PLATFORM_CONFIG_TX_PRESET_TABLE, tx_preset_index,
TX_PRESET_TABLE_PRECUR, &tx_preset, 4); TX_PRESET_TABLE_PRECUR, &tx_preset, 4);
...@@ -603,7 +597,8 @@ static void apply_tunings( ...@@ -603,7 +597,8 @@ static void apply_tunings(
config_data = precur | (attn << 8) | (postcur << 16); config_data = precur | (attn << 8) | (postcur << 16);
apply_tx_lanes(ppd, config_data, "Applying TX settings"); apply_tx_lanes(ppd, TX_EQ_SETTINGS, config_data,
"Applying TX settings");
} }
static int tune_active_qsfp(struct hfi1_pportdata *ppd, u32 *ptr_tx_preset, static int tune_active_qsfp(struct hfi1_pportdata *ppd, u32 *ptr_tx_preset,
...@@ -766,7 +761,7 @@ void tune_serdes(struct hfi1_pportdata *ppd) ...@@ -766,7 +761,7 @@ void tune_serdes(struct hfi1_pportdata *ppd)
u32 total_atten = 0; u32 total_atten = 0;
u32 remote_atten = 0, platform_atten = 0; u32 remote_atten = 0, platform_atten = 0;
u32 rx_preset_index, tx_preset_index; u32 rx_preset_index, tx_preset_index;
u8 tuning_method = 0; u8 tuning_method = 0, limiting_active = 0;
struct hfi1_devdata *dd = ppd->dd; struct hfi1_devdata *dd = ppd->dd;
rx_preset_index = OPA_INVALID_INDEX; rx_preset_index = OPA_INVALID_INDEX;
...@@ -789,7 +784,7 @@ void tune_serdes(struct hfi1_pportdata *ppd) ...@@ -789,7 +784,7 @@ void tune_serdes(struct hfi1_pportdata *ppd)
PORT_TABLE_PORT_TYPE, &ppd->port_type, PORT_TABLE_PORT_TYPE, &ppd->port_type,
4); 4);
if (ret) if (ret)
goto bail; ppd->port_type = PORT_TYPE_UNKNOWN;
switch (ppd->port_type) { switch (ppd->port_type) {
case PORT_TYPE_DISCONNECTED: case PORT_TYPE_DISCONNECTED:
...@@ -853,6 +848,9 @@ void tune_serdes(struct hfi1_pportdata *ppd) ...@@ -853,6 +848,9 @@ void tune_serdes(struct hfi1_pportdata *ppd)
refresh_qsfp_cache(ppd, &ppd->qsfp_info); refresh_qsfp_cache(ppd, &ppd->qsfp_info);
if (ret) if (ret)
goto bail; goto bail;
limiting_active =
ppd->qsfp_info.limiting_active;
} else { } else {
dd_dev_err(dd, dd_dev_err(dd,
"%s: Reading QSFP memory failed\n", "%s: Reading QSFP memory failed\n",
...@@ -866,13 +864,18 @@ void tune_serdes(struct hfi1_pportdata *ppd) ...@@ -866,13 +864,18 @@ void tune_serdes(struct hfi1_pportdata *ppd)
break; break;
default: default:
dd_dev_info(ppd->dd, "%s: Unknown port type\n", __func__); dd_dev_info(ppd->dd, "%s: Unknown port type\n", __func__);
goto bail; ppd->port_type = PORT_TYPE_UNKNOWN;
tuning_method = OPA_UNKNOWN_TUNING;
total_atten = 0;
limiting_active = 0;
tx_preset_index = OPA_INVALID_INDEX;
break;
} }
if (ppd->offline_disabled_reason == if (ppd->offline_disabled_reason ==
HFI1_ODR_MASK(OPA_LINKDOWN_REASON_NONE)) HFI1_ODR_MASK(OPA_LINKDOWN_REASON_NONE))
apply_tunings(ppd, tx_preset_index, tuning_method, apply_tunings(ppd, tx_preset_index, tuning_method,
total_atten, total_atten, limiting_active);
ppd->qsfp_info.limiting_active);
if (!ret) if (!ret)
ppd->driver_link_ready = 1; ppd->driver_link_ready = 1;
......
...@@ -344,7 +344,6 @@ int refresh_qsfp_cache(struct hfi1_pportdata *ppd, struct qsfp_data *cp) ...@@ -344,7 +344,6 @@ int refresh_qsfp_cache(struct hfi1_pportdata *ppd, struct qsfp_data *cp)
ppd->qsfp_info.cache_valid = 0; ppd->qsfp_info.cache_valid = 0;
spin_unlock_irqrestore(&ppd->qsfp_info.qsfp_lock, flags); spin_unlock_irqrestore(&ppd->qsfp_info.qsfp_lock, flags);
dd_dev_info(ppd->dd, "%s called\n", __func__);
if (!qsfp_mod_present(ppd)) { if (!qsfp_mod_present(ppd)) {
ret = -ENODEV; ret = -ENODEV;
goto bail; goto bail;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment