qed: Add support for MBI upgrade over MFW.
authorSudarsana Reddy Kalluru <sudarsana.kalluru@cavium.com>
Mon, 26 Nov 2018 10:27:00 +0000 (02:27 -0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 28 Nov 2018 00:17:20 +0000 (16:17 -0800)
The patch adds driver support for MBI image update through MFW.

Signed-off-by: Sudarsana Reddy Kalluru <Sudarsana.Kalluru@cavium.com>
Signed-off-by: Ariel Elior <Ariel.Elior@cavium.com>
Signed-off-by: Michal Kalderon <Michal.Kalderon@cavium.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/qlogic/qed/qed_hsi.h
drivers/net/ethernet/qlogic/qed/qed_main.c
drivers/net/ethernet/qlogic/qed/qed_mcp.c
drivers/net/ethernet/qlogic/qed/qed_mcp.h

index 5c221ebaa7b34fa863f6f424d22c82cf4d54514d..7e120b58ac587087bdb47339c725e20f837b4f40 100644 (file)
@@ -12655,6 +12655,7 @@ struct public_drv_mb {
 #define DRV_MB_PARAM_DCBX_NOTIFY_MASK          0x000000FF
 #define DRV_MB_PARAM_DCBX_NOTIFY_SHIFT         3
 
+#define DRV_MB_PARAM_NVM_PUT_FILE_BEGIN_MBI     0x3
 #define DRV_MB_PARAM_NVM_LEN_OFFSET            24
 
 #define DRV_MB_PARAM_CFG_VF_MSIX_VF_ID_SHIFT   0
@@ -12814,6 +12815,11 @@ struct public_drv_mb {
        union drv_union_data union_data;
 };
 
+#define FW_MB_PARAM_NVM_PUT_FILE_REQ_OFFSET_MASK       0x00ffffff
+#define FW_MB_PARAM_NVM_PUT_FILE_REQ_OFFSET_SHIFT      0
+#define FW_MB_PARAM_NVM_PUT_FILE_REQ_SIZE_MASK         0xff000000
+#define FW_MB_PARAM_NVM_PUT_FILE_REQ_SIZE_SHIFT                24
+
 enum MFW_DRV_MSG_TYPE {
        MFW_DRV_MSG_LINK_CHANGE,
        MFW_DRV_MSG_FLR_FW_ACK_FAILED,
index fff7f04d4525c51f15f7e349670a698354edc0f3..4b3e6821750227f4f1eb116c3e31818d35459a57 100644 (file)
@@ -1939,21 +1939,30 @@ exit:
  * 0B  |                       0x3 [command index]                            |
  * 4B  | b'0: check_response?   | b'1-31  reserved                            |
  * 8B  | File-type |                   reserved                               |
+ * 12B |                    Image length in bytes                             |
  *     \----------------------------------------------------------------------/
  *     Start a new file of the provided type
  */
 static int qed_nvm_flash_image_file_start(struct qed_dev *cdev,
                                          const u8 **data, bool *check_resp)
 {
+       u32 file_type, file_size = 0;
        int rc;
 
        *data += 4;
        *check_resp = !!(**data & BIT(0));
        *data += 4;
+       file_type = **data;
 
        DP_VERBOSE(cdev, NETIF_MSG_DRV,
-                  "About to start a new file of type %02x\n", **data);
-       rc = qed_mcp_nvm_put_file_begin(cdev, **data);
+                  "About to start a new file of type %02x\n", file_type);
+       if (file_type == DRV_MB_PARAM_NVM_PUT_FILE_BEGIN_MBI) {
+               *data += 4;
+               file_size = *((u32 *)(*data));
+       }
+
+       rc = qed_mcp_nvm_write(cdev, QED_PUT_FILE_BEGIN, file_type,
+                              (u8 *)(&file_size), 4);
        *data += 4;
 
        return rc;
index 34ed75744566ac9cde23dfe2b0348c25249736ac..e7f18e34ff0dc4c34855387467657128e8a60969 100644 (file)
@@ -2745,24 +2745,6 @@ int qed_mcp_nvm_resp(struct qed_dev *cdev, u8 *p_buf)
        return 0;
 }
 
-int qed_mcp_nvm_put_file_begin(struct qed_dev *cdev, u32 addr)
-{
-       struct qed_hwfn *p_hwfn = QED_LEADING_HWFN(cdev);
-       struct qed_ptt *p_ptt;
-       u32 resp, param;
-       int rc;
-
-       p_ptt = qed_ptt_acquire(p_hwfn);
-       if (!p_ptt)
-               return -EBUSY;
-       rc = qed_mcp_cmd(p_hwfn, p_ptt, DRV_MSG_CODE_NVM_PUT_FILE_BEGIN, addr,
-                        &resp, &param);
-       cdev->mcp_nvm_resp = resp;
-       qed_ptt_release(p_hwfn, p_ptt);
-
-       return rc;
-}
-
 int qed_mcp_nvm_write(struct qed_dev *cdev,
                      u32 cmd, u32 addr, u8 *p_buf, u32 len)
 {
@@ -2776,6 +2758,9 @@ int qed_mcp_nvm_write(struct qed_dev *cdev,
                return -EBUSY;
 
        switch (cmd) {
+       case QED_PUT_FILE_BEGIN:
+               nvm_cmd = DRV_MSG_CODE_NVM_PUT_FILE_BEGIN;
+               break;
        case QED_PUT_FILE_DATA:
                nvm_cmd = DRV_MSG_CODE_NVM_PUT_FILE_DATA;
                break;
@@ -2788,10 +2773,14 @@ int qed_mcp_nvm_write(struct qed_dev *cdev,
                goto out;
        }
 
+       buf_size = min_t(u32, (len - buf_idx), MCP_DRV_NVM_BUF_LEN);
        while (buf_idx < len) {
-               buf_size = min_t(u32, (len - buf_idx), MCP_DRV_NVM_BUF_LEN);
-               nvm_offset = ((buf_size << DRV_MB_PARAM_NVM_LEN_OFFSET) |
-                             addr) + buf_idx;
+               if (cmd == QED_PUT_FILE_BEGIN)
+                       nvm_offset = addr;
+               else
+                       nvm_offset = ((buf_size <<
+                                      DRV_MB_PARAM_NVM_LEN_OFFSET) | addr) +
+                                      buf_idx;
                rc = qed_mcp_nvm_wr_cmd(p_hwfn, p_ptt, nvm_cmd, nvm_offset,
                                        &resp, &param, buf_size,
                                        (u32 *)&p_buf[buf_idx]);
@@ -2816,7 +2805,19 @@ int qed_mcp_nvm_write(struct qed_dev *cdev,
                if (buf_idx % 0x1000 > (buf_idx + buf_size) % 0x1000)
                        usleep_range(1000, 2000);
 
-               buf_idx += buf_size;
+               /* For MBI upgrade, MFW response includes the next buffer offset
+                * to be delivered to MFW.
+                */
+               if (param && cmd == QED_PUT_FILE_DATA) {
+                       buf_idx = QED_MFW_GET_FIELD(param,
+                                       FW_MB_PARAM_NVM_PUT_FILE_REQ_OFFSET);
+                       buf_size = QED_MFW_GET_FIELD(param,
+                                        FW_MB_PARAM_NVM_PUT_FILE_REQ_SIZE);
+               } else {
+                       buf_idx += buf_size;
+                       buf_size = min_t(u32, (len - buf_idx),
+                                        MCP_DRV_NVM_BUF_LEN);
+               }
        }
 
        cdev->mcp_nvm_resp = resp;
index 1adfe52b39058cd70c033cc18162555778d2b087..eddf67798d6fd57d38d68a3a0bf3ad95fa404cd3 100644 (file)
@@ -542,16 +542,6 @@ int qed_mcp_nvm_read(struct qed_dev *cdev, u32 addr, u8 *p_buf, u32 len);
 int qed_mcp_nvm_write(struct qed_dev *cdev,
                      u32 cmd, u32 addr, u8 *p_buf, u32 len);
 
-/**
- * @brief Put file begin
- *
- *  @param cdev
- *  @param addr - nvm offset
- *
- * @return int - 0 - operation was successful.
- */
-int qed_mcp_nvm_put_file_begin(struct qed_dev *cdev, u32 addr);
-
 /**
  * @brief Check latest response
  *