diff options
author | David S. Miller | 2019-09-11 15:15:23 +0100 |
---|---|---|
committer | David S. Miller | 2019-09-11 15:15:23 +0100 |
commit | c1609946b8b6485e1d405663004867ea9e92178a (patch) | |
tree | 1b499f18be04de16a40bb0cb7a7a4850ca2146a4 | |
parent | 2f2fa16e23816bded4b97117faf6e97a95ba9056 (diff) | |
parent | 2da244a5c4b5fdbb5ae6cc89f85421defed59a5b (diff) |
Merge branch 'qed-Fix-series'
Sudarsana Reddy Kalluru says:
====================
qed* Fix series.
The patch series addresses couple of issues in the recent commits.
Patch (1) populates the actual dump-size of config attribute instead of
providing a fixed size value.
Patch(2) updates frame format of flash config buffer as required by
management FW (MFW).
Please consider applying it to net-next.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/qlogic/qed/qed_main.c | 47 | ||||
-rw-r--r-- | drivers/net/ethernet/qlogic/qede/qede_ethtool.c | 14 | ||||
-rw-r--r-- | include/linux/qed/qed_if.h | 8 |
3 files changed, 53 insertions, 16 deletions
diff --git a/drivers/net/ethernet/qlogic/qed/qed_main.c b/drivers/net/ethernet/qlogic/qed/qed_main.c index ac1511a834d8..2ce70097d018 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_main.c +++ b/drivers/net/ethernet/qlogic/qed/qed_main.c @@ -2240,12 +2240,13 @@ static int qed_nvm_flash_image_validate(struct qed_dev *cdev, /* Binary file format - * /----------------------------------------------------------------------\ * 0B | 0x5 [command index] | - * 4B | Entity ID | Reserved | Number of config attributes | - * 8B | Config ID | Length | Value | + * 4B | Number of config attributes | Reserved | + * 4B | Config ID | Entity ID | Length | + * 4B | Value | * | | * \----------------------------------------------------------------------/ - * There can be several cfg_id-Length-Value sets as specified by 'Number of...'. - * Entity ID - A non zero entity value for which the config need to be updated. + * There can be several cfg_id-entity_id-Length-Value sets as specified by + * 'Number of config attributes'. * * The API parses config attributes from the user provided buffer and flashes * them to the respective NVM path using Management FW inerface. @@ -2265,18 +2266,17 @@ static int qed_nvm_flash_cfg_write(struct qed_dev *cdev, const u8 **data) /* NVM CFG ID attribute header */ *data += 4; - entity_id = **data; - *data += 2; count = *((u16 *)*data); - *data += 2; + *data += 4; DP_VERBOSE(cdev, NETIF_MSG_DRV, - "Read config ids: entity id %02x num _attrs = %0d\n", - entity_id, count); + "Read config ids: num_attrs = %0d\n", count); /* NVM CFG ID attributes */ for (i = 0; i < count; i++) { cfg_id = *((u16 *)*data); *data += 2; + entity_id = **data; + (*data)++; len = **data; (*data)++; memcpy(buf, *data, len); @@ -2286,7 +2286,8 @@ static int qed_nvm_flash_cfg_write(struct qed_dev *cdev, const u8 **data) QED_NVM_CFG_SET_FLAGS; DP_VERBOSE(cdev, NETIF_MSG_DRV, - "cfg_id = %d len = %d\n", cfg_id, len); + "cfg_id = %d entity = %d len = %d\n", cfg_id, + entity_id, len); rc = qed_mcp_nvm_set_cfg(hwfn, ptt, cfg_id, entity_id, flags, buf, len); if (rc) { @@ -2300,6 +2301,31 @@ static int qed_nvm_flash_cfg_write(struct qed_dev *cdev, const u8 **data) return rc; } +#define QED_MAX_NVM_BUF_LEN 32 +static int qed_nvm_flash_cfg_len(struct qed_dev *cdev, u32 cmd) +{ + struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev); + u8 buf[QED_MAX_NVM_BUF_LEN]; + struct qed_ptt *ptt; + u32 len; + int rc; + + ptt = qed_ptt_acquire(hwfn); + if (!ptt) + return QED_MAX_NVM_BUF_LEN; + + rc = qed_mcp_nvm_get_cfg(hwfn, ptt, cmd, 0, QED_NVM_CFG_GET_FLAGS, buf, + &len); + if (rc || !len) { + DP_ERR(cdev, "Error %d reading %d\n", rc, cmd); + len = QED_MAX_NVM_BUF_LEN; + } + + qed_ptt_release(hwfn, ptt); + + return len; +} + static int qed_nvm_flash_cfg_read(struct qed_dev *cdev, u8 **data, u32 cmd, u32 entity_id) { @@ -2657,6 +2683,7 @@ const struct qed_common_ops qed_common_ops_pass = { .read_module_eeprom = &qed_read_module_eeprom, .get_affin_hwfn_idx = &qed_get_affin_hwfn_idx, .read_nvm_cfg = &qed_nvm_flash_cfg_read, + .read_nvm_cfg_len = &qed_nvm_flash_cfg_len, .set_grc_config = &qed_set_grc_config, }; diff --git a/drivers/net/ethernet/qlogic/qede/qede_ethtool.c b/drivers/net/ethernet/qlogic/qede/qede_ethtool.c index ec27a43230d7..8a426afb6a55 100644 --- a/drivers/net/ethernet/qlogic/qede/qede_ethtool.c +++ b/drivers/net/ethernet/qlogic/qede/qede_ethtool.c @@ -49,7 +49,6 @@ #define QEDE_SELFTEST_POLL_COUNT 100 #define QEDE_DUMP_VERSION 0x1 -#define QEDE_DUMP_NVM_BUF_LEN 32 #define QEDE_DUMP_NVM_ARG_COUNT 2 static const struct { @@ -2026,7 +2025,8 @@ static int qede_get_dump_flag(struct net_device *dev, switch (edev->dump_info.cmd) { case QEDE_DUMP_CMD_NVM_CFG: dump->flag = QEDE_DUMP_CMD_NVM_CFG; - dump->len = QEDE_DUMP_NVM_BUF_LEN; + dump->len = edev->ops->common->read_nvm_cfg_len(edev->cdev, + edev->dump_info.args[0]); break; case QEDE_DUMP_CMD_GRCDUMP: dump->flag = QEDE_DUMP_CMD_GRCDUMP; @@ -2051,9 +2051,8 @@ static int qede_get_dump_data(struct net_device *dev, if (!edev->ops || !edev->ops->common) { DP_ERR(edev, "Edev ops not populated\n"); - edev->dump_info.cmd = QEDE_DUMP_CMD_NONE; - edev->dump_info.num_args = 0; - return -EINVAL; + rc = -EINVAL; + goto err; } switch (edev->dump_info.cmd) { @@ -2062,7 +2061,8 @@ static int qede_get_dump_data(struct net_device *dev, DP_ERR(edev, "Arg count = %d required = %d\n", edev->dump_info.num_args, QEDE_DUMP_NVM_ARG_COUNT); - return -EINVAL; + rc = -EINVAL; + goto err; } rc = edev->ops->common->read_nvm_cfg(edev->cdev, (u8 **)&buf, edev->dump_info.args[0], @@ -2078,8 +2078,10 @@ static int qede_get_dump_data(struct net_device *dev, break; } +err: edev->dump_info.cmd = QEDE_DUMP_CMD_NONE; edev->dump_info.num_args = 0; + memset(edev->dump_info.args, 0, sizeof(edev->dump_info.args)); return rc; } diff --git a/include/linux/qed/qed_if.h b/include/linux/qed/qed_if.h index e35463860c84..b5db1ee96d78 100644 --- a/include/linux/qed/qed_if.h +++ b/include/linux/qed/qed_if.h @@ -1143,6 +1143,14 @@ struct qed_common_ops { */ int (*read_nvm_cfg)(struct qed_dev *cdev, u8 **buf, u32 cmd, u32 entity_id); +/** + * @brief read_nvm_cfg - Read NVM config attribute value. + * @param cdev + * @param cmd - NVM CFG command id + * + * @return config id length, 0 on error. + */ + int (*read_nvm_cfg_len)(struct qed_dev *cdev, u32 cmd); /** * @brief set_grc_config - Configure value for grc config id. |