net/qede/base: initialize resc lock/unlock params
[dpdk.git] / drivers / net / qede / base / ecore_mcp.c
index 24f65cf..7169b55 100644 (file)
@@ -3401,6 +3401,38 @@ ecore_mcp_resc_lock(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
        return ECORE_SUCCESS;
 }
 
+void
+ecore_mcp_resc_lock_default_init(struct ecore_hwfn *p_hwfn,
+                                struct ecore_resc_lock_params *p_lock,
+                                struct ecore_resc_unlock_params *p_unlock,
+                                enum ecore_resc_lock resource,
+                                bool b_is_permanent)
+{
+       if (p_lock != OSAL_NULL) {
+               OSAL_MEM_ZERO(p_lock, sizeof(*p_lock));
+
+               /* Permanent resources don't require aging, and there's no
+                * point in trying to acquire them more than once since it's
+                * unexpected another entity would release them.
+                */
+               if (b_is_permanent) {
+                       p_lock->timeout = ECORE_MCP_RESC_LOCK_TO_NONE;
+               } else {
+                       p_lock->retry_num = ECORE_MCP_RESC_LOCK_RETRY_CNT_DFLT;
+                       p_lock->retry_interval =
+                                       ECORE_MCP_RESC_LOCK_RETRY_VAL_DFLT;
+                       p_lock->sleep_b4_retry = true;
+               }
+
+               p_lock->resource = resource;
+       }
+
+       if (p_unlock != OSAL_NULL) {
+               OSAL_MEM_ZERO(p_unlock, sizeof(*p_unlock));
+               p_unlock->resource = resource;
+       }
+}
+
 enum _ecore_status_t
 ecore_mcp_resc_unlock(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
                      struct ecore_resc_unlock_params *p_params)