Skip to content

Commit 9e54ba7

Browse files
Sudarsana Reddy Kallurudavem330
authored andcommitted
qed*: Fix size of config attribute dump.
Driver currently returns max-buf-size as size of the config attribute. This patch incorporates changes to read this value from MFW (if available) and provide it to the user. Also did a trivial clean up in this path. Fixes: d44a3ce ("qede: Add support for reading the config id attributes.") Signed-off-by: Sudarsana Reddy Kalluru <[email protected]> Signed-off-by: Ariel Elior <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2f2fa16 commit 9e54ba7

File tree

3 files changed

+42
-6
lines changed

3 files changed

+42
-6
lines changed

drivers/net/ethernet/qlogic/qed/qed_main.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2300,6 +2300,31 @@ static int qed_nvm_flash_cfg_write(struct qed_dev *cdev, const u8 **data)
23002300
return rc;
23012301
}
23022302

2303+
#define QED_MAX_NVM_BUF_LEN 32
2304+
static int qed_nvm_flash_cfg_len(struct qed_dev *cdev, u32 cmd)
2305+
{
2306+
struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
2307+
u8 buf[QED_MAX_NVM_BUF_LEN];
2308+
struct qed_ptt *ptt;
2309+
u32 len;
2310+
int rc;
2311+
2312+
ptt = qed_ptt_acquire(hwfn);
2313+
if (!ptt)
2314+
return QED_MAX_NVM_BUF_LEN;
2315+
2316+
rc = qed_mcp_nvm_get_cfg(hwfn, ptt, cmd, 0, QED_NVM_CFG_GET_FLAGS, buf,
2317+
&len);
2318+
if (rc || !len) {
2319+
DP_ERR(cdev, "Error %d reading %d\n", rc, cmd);
2320+
len = QED_MAX_NVM_BUF_LEN;
2321+
}
2322+
2323+
qed_ptt_release(hwfn, ptt);
2324+
2325+
return len;
2326+
}
2327+
23032328
static int qed_nvm_flash_cfg_read(struct qed_dev *cdev, u8 **data,
23042329
u32 cmd, u32 entity_id)
23052330
{
@@ -2657,6 +2682,7 @@ const struct qed_common_ops qed_common_ops_pass = {
26572682
.read_module_eeprom = &qed_read_module_eeprom,
26582683
.get_affin_hwfn_idx = &qed_get_affin_hwfn_idx,
26592684
.read_nvm_cfg = &qed_nvm_flash_cfg_read,
2685+
.read_nvm_cfg_len = &qed_nvm_flash_cfg_len,
26602686
.set_grc_config = &qed_set_grc_config,
26612687
};
26622688

drivers/net/ethernet/qlogic/qede/qede_ethtool.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949

5050
#define QEDE_SELFTEST_POLL_COUNT 100
5151
#define QEDE_DUMP_VERSION 0x1
52-
#define QEDE_DUMP_NVM_BUF_LEN 32
5352
#define QEDE_DUMP_NVM_ARG_COUNT 2
5453

5554
static const struct {
@@ -2026,7 +2025,8 @@ static int qede_get_dump_flag(struct net_device *dev,
20262025
switch (edev->dump_info.cmd) {
20272026
case QEDE_DUMP_CMD_NVM_CFG:
20282027
dump->flag = QEDE_DUMP_CMD_NVM_CFG;
2029-
dump->len = QEDE_DUMP_NVM_BUF_LEN;
2028+
dump->len = edev->ops->common->read_nvm_cfg_len(edev->cdev,
2029+
edev->dump_info.args[0]);
20302030
break;
20312031
case QEDE_DUMP_CMD_GRCDUMP:
20322032
dump->flag = QEDE_DUMP_CMD_GRCDUMP;
@@ -2051,9 +2051,8 @@ static int qede_get_dump_data(struct net_device *dev,
20512051

20522052
if (!edev->ops || !edev->ops->common) {
20532053
DP_ERR(edev, "Edev ops not populated\n");
2054-
edev->dump_info.cmd = QEDE_DUMP_CMD_NONE;
2055-
edev->dump_info.num_args = 0;
2056-
return -EINVAL;
2054+
rc = -EINVAL;
2055+
goto err;
20572056
}
20582057

20592058
switch (edev->dump_info.cmd) {
@@ -2062,7 +2061,8 @@ static int qede_get_dump_data(struct net_device *dev,
20622061
DP_ERR(edev, "Arg count = %d required = %d\n",
20632062
edev->dump_info.num_args,
20642063
QEDE_DUMP_NVM_ARG_COUNT);
2065-
return -EINVAL;
2064+
rc = -EINVAL;
2065+
goto err;
20662066
}
20672067
rc = edev->ops->common->read_nvm_cfg(edev->cdev, (u8 **)&buf,
20682068
edev->dump_info.args[0],
@@ -2078,8 +2078,10 @@ static int qede_get_dump_data(struct net_device *dev,
20782078
break;
20792079
}
20802080

2081+
err:
20812082
edev->dump_info.cmd = QEDE_DUMP_CMD_NONE;
20822083
edev->dump_info.num_args = 0;
2084+
memset(edev->dump_info.args, 0, sizeof(edev->dump_info.args));
20832085

20842086
return rc;
20852087
}

include/linux/qed/qed_if.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,14 @@ struct qed_common_ops {
11431143
*/
11441144
int (*read_nvm_cfg)(struct qed_dev *cdev, u8 **buf, u32 cmd,
11451145
u32 entity_id);
1146+
/**
1147+
* @brief read_nvm_cfg - Read NVM config attribute value.
1148+
* @param cdev
1149+
* @param cmd - NVM CFG command id
1150+
*
1151+
* @return config id length, 0 on error.
1152+
*/
1153+
int (*read_nvm_cfg_len)(struct qed_dev *cdev, u32 cmd);
11461154

11471155
/**
11481156
* @brief set_grc_config - Configure value for grc config id.

0 commit comments

Comments
 (0)