Skip to content

Commit

Permalink
qed: Provide MBI information in dev_info
Browse files Browse the repository at this point in the history
Pass additional information about package installed on persistent memory
so that protocol drivers would be able to log it.

Signed-off-by: Tomer Tayar <[email protected]>
Signed-off-by: Yuval Mintz <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Tomer Tayar authored and davem330 committed May 24, 2017
1 parent f855df2 commit ae33666
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/net/ethernet/qlogic/qed/qed_hsi.h
Original file line number Diff line number Diff line change
Expand Up @@ -11782,6 +11782,12 @@ struct nvm_cfg1_glob {
u32 led_global_settings;
u32 generic_cont1;
u32 mbi_version;
#define NVM_CFG1_GLOB_MBI_VERSION_0_MASK 0x000000FF
#define NVM_CFG1_GLOB_MBI_VERSION_0_OFFSET 0
#define NVM_CFG1_GLOB_MBI_VERSION_1_MASK 0x0000FF00
#define NVM_CFG1_GLOB_MBI_VERSION_1_OFFSET 8
#define NVM_CFG1_GLOB_MBI_VERSION_2_MASK 0x00FF0000
#define NVM_CFG1_GLOB_MBI_VERSION_2_OFFSET 16
u32 mbi_date;
u32 misc_sig;
u32 device_capabilities;
Expand Down
3 changes: 3 additions & 0 deletions drivers/net/ethernet/qlogic/qed/qed_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@ int qed_fill_dev_info(struct qed_dev *cdev,
qed_mcp_get_mfw_ver(QED_LEADING_HWFN(cdev), ptt,
&dev_info->mfw_rev, NULL);

qed_mcp_get_mbi_ver(QED_LEADING_HWFN(cdev), ptt,
&dev_info->mbi_version);

qed_mcp_get_flash_size(QED_LEADING_HWFN(cdev), ptt,
&dev_info->flash_size);

Expand Down
30 changes: 30 additions & 0 deletions drivers/net/ethernet/qlogic/qed/qed_mcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1523,6 +1523,36 @@ int qed_mcp_get_mfw_ver(struct qed_hwfn *p_hwfn,
return 0;
}

int qed_mcp_get_mbi_ver(struct qed_hwfn *p_hwfn,
struct qed_ptt *p_ptt, u32 *p_mbi_ver)
{
u32 nvm_cfg_addr, nvm_cfg1_offset, mbi_ver_addr;

if (IS_VF(p_hwfn->cdev))
return -EINVAL;

/* Read the address of the nvm_cfg */
nvm_cfg_addr = qed_rd(p_hwfn, p_ptt, MISC_REG_GEN_PURP_CR0);
if (!nvm_cfg_addr) {
DP_NOTICE(p_hwfn, "Shared memory not initialized\n");
return -EINVAL;
}

/* Read the offset of nvm_cfg1 */
nvm_cfg1_offset = qed_rd(p_hwfn, p_ptt, nvm_cfg_addr + 4);

mbi_ver_addr = MCP_REG_SCRATCH + nvm_cfg1_offset +
offsetof(struct nvm_cfg1, glob) +
offsetof(struct nvm_cfg1_glob, mbi_version);
*p_mbi_ver = qed_rd(p_hwfn, p_ptt,
mbi_ver_addr) &
(NVM_CFG1_GLOB_MBI_VERSION_0_MASK |
NVM_CFG1_GLOB_MBI_VERSION_1_MASK |
NVM_CFG1_GLOB_MBI_VERSION_2_MASK);

return 0;
}

int qed_mcp_get_media_type(struct qed_dev *cdev, u32 *p_media_type)
{
struct qed_hwfn *p_hwfn = &cdev->hwfns[0];
Expand Down
12 changes: 12 additions & 0 deletions drivers/net/ethernet/qlogic/qed/qed_mcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,18 @@ int qed_mcp_get_mfw_ver(struct qed_hwfn *p_hwfn,
struct qed_ptt *p_ptt,
u32 *p_mfw_ver, u32 *p_running_bundle_id);

/**
* @brief Get the MBI version value
*
* @param p_hwfn
* @param p_ptt
* @param p_mbi_ver - A pointer to a variable to be filled with the MBI version.
*
* @return int - 0 - operation was successful.
*/
int qed_mcp_get_mbi_ver(struct qed_hwfn *p_hwfn,
struct qed_ptt *p_ptt, u32 *p_mbi_ver);

/**
* @brief Get media type value of the port.
*
Expand Down
17 changes: 17 additions & 0 deletions include/linux/qed/qed_if.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,14 @@ struct qed_dev_info {

/* MFW version */
u32 mfw_rev;
#define QED_MFW_VERSION_0_MASK 0x000000FF
#define QED_MFW_VERSION_0_OFFSET 0
#define QED_MFW_VERSION_1_MASK 0x0000FF00
#define QED_MFW_VERSION_1_OFFSET 8
#define QED_MFW_VERSION_2_MASK 0x00FF0000
#define QED_MFW_VERSION_2_OFFSET 16
#define QED_MFW_VERSION_3_MASK 0xFF000000
#define QED_MFW_VERSION_3_OFFSET 24

u32 flash_size;
u8 mf_mode;
Expand All @@ -337,6 +345,15 @@ struct qed_dev_info {

bool wol_support;

/* MBI version */
u32 mbi_version;
#define QED_MBI_VERSION_0_MASK 0x000000FF
#define QED_MBI_VERSION_0_OFFSET 0
#define QED_MBI_VERSION_1_MASK 0x0000FF00
#define QED_MBI_VERSION_1_OFFSET 8
#define QED_MBI_VERSION_2_MASK 0x00FF0000
#define QED_MBI_VERSION_2_OFFSET 16

enum qed_dev_type dev_type;

/* Output parameters for qede */
Expand Down

0 comments on commit ae33666

Please sign in to comment.