Skip to content

Commit 2d4c849

Browse files
Sudarsana Reddy Kallurudavem330
authored andcommitted
qed: Add APIs for reading config id attributes.
The patch adds driver support for reading the config id attributes from NVM flash partition. 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 b0274eb commit 2d4c849

File tree

4 files changed

+82
-0
lines changed

4 files changed

+82
-0
lines changed

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@
6969
#define QED_RDMA_SRQS QED_ROCE_QPS
7070
#define QED_NVM_CFG_SET_FLAGS 0xE
7171
#define QED_NVM_CFG_SET_PF_FLAGS 0x1E
72+
#define QED_NVM_CFG_GET_FLAGS 0xA
73+
#define QED_NVM_CFG_GET_PF_FLAGS 0x1A
7274

7375
static char version[] =
7476
"QLogic FastLinQ 4xxxx Core Module qed " DRV_MODULE_VERSION "\n";
@@ -2298,6 +2300,30 @@ static int qed_nvm_flash_cfg_write(struct qed_dev *cdev, const u8 **data)
22982300
return rc;
22992301
}
23002302

2303+
static int qed_nvm_flash_cfg_read(struct qed_dev *cdev, u8 **data,
2304+
u32 cmd, u32 entity_id)
2305+
{
2306+
struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
2307+
struct qed_ptt *ptt;
2308+
u32 flags, len;
2309+
int rc = 0;
2310+
2311+
ptt = qed_ptt_acquire(hwfn);
2312+
if (!ptt)
2313+
return -EAGAIN;
2314+
2315+
DP_VERBOSE(cdev, NETIF_MSG_DRV,
2316+
"Read config cmd = %d entity id %d\n", cmd, entity_id);
2317+
flags = entity_id ? QED_NVM_CFG_GET_PF_FLAGS : QED_NVM_CFG_GET_FLAGS;
2318+
rc = qed_mcp_nvm_get_cfg(hwfn, ptt, cmd, entity_id, flags, *data, &len);
2319+
if (rc)
2320+
DP_ERR(cdev, "Error %d reading %d\n", rc, cmd);
2321+
2322+
qed_ptt_release(hwfn, ptt);
2323+
2324+
return rc;
2325+
}
2326+
23012327
static int qed_nvm_flash(struct qed_dev *cdev, const char *name)
23022328
{
23032329
const struct firmware *image;
@@ -2610,6 +2636,7 @@ const struct qed_common_ops qed_common_ops_pass = {
26102636
.db_recovery_del = &qed_db_recovery_del,
26112637
.read_module_eeprom = &qed_read_module_eeprom,
26122638
.get_affin_hwfn_idx = &qed_get_affin_hwfn_idx,
2639+
.read_nvm_cfg = &qed_nvm_flash_cfg_read,
26132640
};
26142641

26152642
void qed_get_protocol_stats(struct qed_dev *cdev,

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3751,6 +3751,35 @@ int qed_mcp_get_ppfid_bitmap(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
37513751
return 0;
37523752
}
37533753

3754+
int qed_mcp_nvm_get_cfg(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
3755+
u16 option_id, u8 entity_id, u16 flags, u8 *p_buf,
3756+
u32 *p_len)
3757+
{
3758+
u32 mb_param = 0, resp, param;
3759+
int rc;
3760+
3761+
QED_MFW_SET_FIELD(mb_param, DRV_MB_PARAM_NVM_CFG_OPTION_ID, option_id);
3762+
if (flags & QED_NVM_CFG_OPTION_INIT)
3763+
QED_MFW_SET_FIELD(mb_param,
3764+
DRV_MB_PARAM_NVM_CFG_OPTION_INIT, 1);
3765+
if (flags & QED_NVM_CFG_OPTION_FREE)
3766+
QED_MFW_SET_FIELD(mb_param,
3767+
DRV_MB_PARAM_NVM_CFG_OPTION_FREE, 1);
3768+
if (flags & QED_NVM_CFG_OPTION_ENTITY_SEL) {
3769+
QED_MFW_SET_FIELD(mb_param,
3770+
DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_SEL, 1);
3771+
QED_MFW_SET_FIELD(mb_param,
3772+
DRV_MB_PARAM_NVM_CFG_OPTION_ENTITY_ID,
3773+
entity_id);
3774+
}
3775+
3776+
rc = qed_mcp_nvm_rd_cmd(p_hwfn, p_ptt,
3777+
DRV_MSG_CODE_GET_NVM_CFG_OPTION,
3778+
mb_param, &resp, &param, p_len, (u32 *)p_buf);
3779+
3780+
return rc;
3781+
}
3782+
37543783
int qed_mcp_nvm_set_cfg(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
37553784
u16 option_id, u8 entity_id, u16 flags, u8 *p_buf,
37563785
u32 len)

drivers/net/ethernet/qlogic/qed/qed_mcp.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,6 +1208,21 @@ int qed_mcp_get_engine_config(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
12081208
*/
12091209
int qed_mcp_get_ppfid_bitmap(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
12101210

1211+
/**
1212+
* @brief Get NVM config attribute value.
1213+
*
1214+
* @param p_hwfn
1215+
* @param p_ptt
1216+
* @param option_id
1217+
* @param entity_id
1218+
* @param flags
1219+
* @param p_buf
1220+
* @param p_len
1221+
*/
1222+
int qed_mcp_nvm_get_cfg(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
1223+
u16 option_id, u8 entity_id, u16 flags, u8 *p_buf,
1224+
u32 *p_len);
1225+
12111226
/**
12121227
* @brief Set NVM config attribute value.
12131228
*

include/linux/qed/qed_if.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,6 +1132,17 @@ struct qed_common_ops {
11321132
* @param cdev
11331133
*/
11341134
u8 (*get_affin_hwfn_idx)(struct qed_dev *cdev);
1135+
1136+
/**
1137+
* @brief read_nvm_cfg - Read NVM config attribute value.
1138+
* @param cdev
1139+
* @param buf - buffer
1140+
* @param cmd - NVM CFG command id
1141+
* @param entity_id - Entity id
1142+
*
1143+
*/
1144+
int (*read_nvm_cfg)(struct qed_dev *cdev, u8 **buf, u32 cmd,
1145+
u32 entity_id);
11351146
};
11361147

11371148
#define MASK_FIELD(_name, _value) \

0 commit comments

Comments
 (0)