net/qede/base: support driver attribute repository
authorRasesh Mody <rasesh.mody@cavium.com>
Tue, 19 Sep 2017 01:51:34 +0000 (18:51 -0700)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 6 Oct 2017 00:49:49 +0000 (02:49 +0200)
Add support for driver attributes repository in MFW and base driver.

Signed-off-by: Rasesh Mody <rasesh.mody@cavium.com>
drivers/net/qede/base/ecore_mcp.c
drivers/net/qede/base/ecore_mcp.h
drivers/net/qede/base/mcp_public.h

index 6b5d755..89c9864 100644 (file)
@@ -3674,3 +3674,76 @@ enum _ecore_status_t ecore_mcp_set_capabilities(struct ecore_hwfn *p_hwfn,
        return ecore_mcp_cmd(p_hwfn, p_ptt, DRV_MSG_CODE_FEATURE_SUPPORT,
                             features, &mcp_resp, &mcp_param);
 }
+
+enum _ecore_status_t
+ecore_mcp_drv_attribute(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
+                       struct ecore_mcp_drv_attr *p_drv_attr)
+{
+       struct attribute_cmd_write_stc attr_cmd_write;
+       enum _attribute_commands_e mfw_attr_cmd;
+       struct ecore_mcp_mb_params mb_params;
+       enum _ecore_status_t rc;
+
+       switch (p_drv_attr->attr_cmd) {
+       case ECORE_MCP_DRV_ATTR_CMD_READ:
+               mfw_attr_cmd = ATTRIBUTE_CMD_READ;
+               break;
+       case ECORE_MCP_DRV_ATTR_CMD_WRITE:
+               mfw_attr_cmd = ATTRIBUTE_CMD_WRITE;
+               break;
+       case ECORE_MCP_DRV_ATTR_CMD_READ_CLEAR:
+               mfw_attr_cmd = ATTRIBUTE_CMD_READ_CLEAR;
+               break;
+       case ECORE_MCP_DRV_ATTR_CMD_CLEAR:
+               mfw_attr_cmd = ATTRIBUTE_CMD_CLEAR;
+               break;
+       default:
+               DP_NOTICE(p_hwfn, false, "Unknown attribute command %d\n",
+                         p_drv_attr->attr_cmd);
+               return ECORE_INVAL;
+       }
+
+       OSAL_MEM_ZERO(&mb_params, sizeof(mb_params));
+       mb_params.cmd = DRV_MSG_CODE_ATTRIBUTE;
+       SET_MFW_FIELD(mb_params.param, DRV_MB_PARAM_ATTRIBUTE_KEY,
+                     p_drv_attr->attr_num);
+       SET_MFW_FIELD(mb_params.param, DRV_MB_PARAM_ATTRIBUTE_CMD,
+                     mfw_attr_cmd);
+       if (p_drv_attr->attr_cmd == ECORE_MCP_DRV_ATTR_CMD_WRITE) {
+               OSAL_MEM_ZERO(&attr_cmd_write, sizeof(attr_cmd_write));
+               attr_cmd_write.val = p_drv_attr->val;
+               attr_cmd_write.mask = p_drv_attr->mask;
+               attr_cmd_write.offset = p_drv_attr->offset;
+
+               mb_params.p_data_src = &attr_cmd_write;
+               mb_params.data_src_size = sizeof(attr_cmd_write);
+       }
+
+       rc = ecore_mcp_cmd_and_union(p_hwfn, p_ptt, &mb_params);
+       if (rc != ECORE_SUCCESS)
+               return rc;
+
+       if (mb_params.mcp_resp == FW_MSG_CODE_UNSUPPORTED) {
+               DP_INFO(p_hwfn,
+                       "The attribute command is not supported by the MFW\n");
+               return ECORE_NOTIMPL;
+       } else if (mb_params.mcp_resp != FW_MSG_CODE_OK) {
+               DP_INFO(p_hwfn,
+                       "Failed to send an attribute command [mcp_resp 0x%x, attr_cmd %d, attr_num %d]\n",
+                       mb_params.mcp_resp, p_drv_attr->attr_cmd,
+                       p_drv_attr->attr_num);
+               return ECORE_INVAL;
+       }
+
+       DP_VERBOSE(p_hwfn, ECORE_MSG_SP,
+                  "Attribute Command: cmd %d [mfw_cmd %d], num %d, in={val 0x%08x, mask 0x%08x, offset 0x%08x}, out={val 0x%08x}\n",
+                  p_drv_attr->attr_cmd, mfw_attr_cmd, p_drv_attr->attr_num,
+                  p_drv_attr->val, p_drv_attr->mask, p_drv_attr->offset,
+                  mb_params.mcp_param);
+
+       if (p_drv_attr->attr_cmd == ECORE_MCP_DRV_ATTR_CMD_READ ||
+           p_drv_attr->attr_cmd == ECORE_MCP_DRV_ATTR_CMD_READ_CLEAR)
+               p_drv_attr->val = mb_params.mcp_param;
+
+       return ECORE_SUCCESS;
+}
index 7f12a0a..875b205 100644 (file)
@@ -521,6 +521,41 @@ enum _ecore_status_t ecore_mcp_get_capabilities(struct ecore_hwfn *p_hwfn,
 enum _ecore_status_t ecore_mcp_set_capabilities(struct ecore_hwfn *p_hwfn,
                                                struct ecore_ptt *p_ptt);
 
+enum ecore_mcp_drv_attr_cmd {
+       ECORE_MCP_DRV_ATTR_CMD_READ,
+       ECORE_MCP_DRV_ATTR_CMD_WRITE,
+       ECORE_MCP_DRV_ATTR_CMD_READ_CLEAR,
+       ECORE_MCP_DRV_ATTR_CMD_CLEAR,
+};
+
+struct ecore_mcp_drv_attr {
+       enum ecore_mcp_drv_attr_cmd attr_cmd;
+       u32 attr_num;
+
+       /* R/RC - will be set with the read value
+        * W - should hold the required value to be written
+        * C - DC
+        */
+       u32 val;
+
+       /* W - mask/offset to be applied on the given value
+        * R/RC/C - DC
+        */
+       u32 mask;
+       u32 offset;
+};
+
+/**
+ * @brief Handle the drivers' attributes that are kept by the MFW.
+ *
+ * @param p_hwfn
+ * @param p_ptt
+ * @param p_drv_attr
+ */
+enum _ecore_status_t
+ecore_mcp_drv_attribute(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
+                       struct ecore_mcp_drv_attr *p_drv_attr);
+
 /**
  * @brief Read ufp config from the shared memory.
  *
index 5153f25..e2145ab 100644 (file)
@@ -475,6 +475,18 @@ struct dcb_dscp_map {
        u32 dscp_pri_map[8];
 };
 
+/**************************************
+ *     Attributes commands
+ **************************************/
+
+enum _attribute_commands_e {
+       ATTRIBUTE_CMD_READ = 0,
+       ATTRIBUTE_CMD_WRITE,
+       ATTRIBUTE_CMD_READ_CLEAR,
+       ATTRIBUTE_CMD_CLEAR,
+       ATTRIBUTE_NUM_OF_COMMANDS
+};
+
 /**************************************/
 /*                                    */
 /*     P U B L I C      G L O B A L   */
@@ -1149,6 +1161,12 @@ struct mdump_retain_data_stc {
        u32 status;
 };
 
+struct attribute_cmd_write_stc {
+       u32 val;
+       u32 mask;
+       u32 offset;
+};
+
 union drv_union_data {
        struct mcp_mac wol_mac; /* UNLOAD_DONE */
 
@@ -1180,6 +1198,7 @@ union drv_union_data {
        struct load_req_stc load_req;
        struct load_rsp_stc load_rsp;
        struct mdump_retain_data_stc mdump_retain;
+       struct attribute_cmd_write_stc attribute_cmd_write;
        /* ... */
 };
 
@@ -1414,6 +1433,8 @@ struct public_drv_mb {
 #define DRV_MSG_CODE_FEATURE_SUPPORT            0x00300000
 /* return FW_MB_PARAM_FEATURE_SUPPORT_*  */
 #define DRV_MSG_CODE_GET_MFW_FEATURE_SUPPORT   0x00310000
+/* Param: [0:23] Attribute key, [24:31] Attribute sub command */
+#define DRV_MSG_CODE_ATTRIBUTE                 0x00350000
 
 #define DRV_MSG_SEQ_NUMBER_MASK                 0x0000ffff
 
@@ -1573,6 +1594,11 @@ struct public_drv_mb {
 #define DRV_MB_PARAM_FEATURE_SUPPORT_PORT_EEE       0x00000002
 #define DRV_MB_PARAM_FEATURE_SUPPORT_FUNC_MASK      0xFFFF0000
 #define DRV_MB_PARAM_FEATURE_SUPPORT_FUNC_OFFSET     16
+       /* Driver attributes params */
+#define DRV_MB_PARAM_ATTRIBUTE_KEY_OFFSET               0
+#define DRV_MB_PARAM_ATTRIBUTE_KEY_MASK                0x00FFFFFF
+#define DRV_MB_PARAM_ATTRIBUTE_CMD_OFFSET              24
+#define DRV_MB_PARAM_ATTRIBUTE_CMD_MASK                0xFF000000
 
        u32 fw_mb_header;
 #define FW_MSG_CODE_MASK                        0xffff0000
@@ -1686,6 +1712,8 @@ struct public_drv_mb {
 
 #define FW_MSG_SEQ_NUMBER_MASK                  0x0000ffff
 
+#define FW_MSG_CODE_ATTRIBUTE_INVALID_KEY      0x00020000
+#define FW_MSG_CODE_ATTRIBUTE_INVALID_CMD      0x00030000
 
        u32 fw_mb_param;
 /* Resource Allocation params - MFW  version support */