Commit 3587cb87 authored by Tomer Tayar's avatar Tomer Tayar Committed by David S. Miller

qed: Revise alloc/setup/free flow

Re-organize the logic that allocates and frees memory of various
sub-components of the hw-function -

 a. No need to pass pointers to said structure as parameters;
    The internal logic knows exactly where to find/set the data.

 b. Nullify pointers after cleanup to prevent possible errors to
    re-entrant code.
Signed-off-by: default avatarTomer Tayar <Tomer.Tayar@cavium.com>
Signed-off-by: default avatarYuval Mintz <Yuval.Mintz@cavium.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 492a1d98
...@@ -923,6 +923,7 @@ int qed_dcbx_info_alloc(struct qed_hwfn *p_hwfn) ...@@ -923,6 +923,7 @@ int qed_dcbx_info_alloc(struct qed_hwfn *p_hwfn)
void qed_dcbx_info_free(struct qed_hwfn *p_hwfn) void qed_dcbx_info_free(struct qed_hwfn *p_hwfn)
{ {
kfree(p_hwfn->p_dcbx_info); kfree(p_hwfn->p_dcbx_info);
p_hwfn->p_dcbx_info = NULL;
} }
static void qed_dcbx_update_protocol_data(struct protocol_dcb_data *p_data, static void qed_dcbx_update_protocol_data(struct protocol_dcb_data *p_data,
......
...@@ -161,6 +161,7 @@ void qed_resc_free(struct qed_dev *cdev) ...@@ -161,6 +161,7 @@ void qed_resc_free(struct qed_dev *cdev)
cdev->fw_data = NULL; cdev->fw_data = NULL;
kfree(cdev->reset_stats); kfree(cdev->reset_stats);
cdev->reset_stats = NULL;
for_each_hwfn(cdev, i) { for_each_hwfn(cdev, i) {
struct qed_hwfn *p_hwfn = &cdev->hwfns[i]; struct qed_hwfn *p_hwfn = &cdev->hwfns[i];
...@@ -168,18 +169,18 @@ void qed_resc_free(struct qed_dev *cdev) ...@@ -168,18 +169,18 @@ void qed_resc_free(struct qed_dev *cdev)
qed_cxt_mngr_free(p_hwfn); qed_cxt_mngr_free(p_hwfn);
qed_qm_info_free(p_hwfn); qed_qm_info_free(p_hwfn);
qed_spq_free(p_hwfn); qed_spq_free(p_hwfn);
qed_eq_free(p_hwfn, p_hwfn->p_eq); qed_eq_free(p_hwfn);
qed_consq_free(p_hwfn, p_hwfn->p_consq); qed_consq_free(p_hwfn);
qed_int_free(p_hwfn); qed_int_free(p_hwfn);
#ifdef CONFIG_QED_LL2 #ifdef CONFIG_QED_LL2
qed_ll2_free(p_hwfn, p_hwfn->p_ll2_info); qed_ll2_free(p_hwfn);
#endif #endif
if (p_hwfn->hw_info.personality == QED_PCI_FCOE) if (p_hwfn->hw_info.personality == QED_PCI_FCOE)
qed_fcoe_free(p_hwfn, p_hwfn->p_fcoe_info); qed_fcoe_free(p_hwfn);
if (p_hwfn->hw_info.personality == QED_PCI_ISCSI) { if (p_hwfn->hw_info.personality == QED_PCI_ISCSI) {
qed_iscsi_free(p_hwfn, p_hwfn->p_iscsi_info); qed_iscsi_free(p_hwfn);
qed_ooo_free(p_hwfn, p_hwfn->p_ooo_info); qed_ooo_free(p_hwfn);
} }
qed_iov_free(p_hwfn); qed_iov_free(p_hwfn);
qed_dmae_info_free(p_hwfn); qed_dmae_info_free(p_hwfn);
...@@ -843,15 +844,7 @@ static int qed_alloc_qm_data(struct qed_hwfn *p_hwfn) ...@@ -843,15 +844,7 @@ static int qed_alloc_qm_data(struct qed_hwfn *p_hwfn)
int qed_resc_alloc(struct qed_dev *cdev) int qed_resc_alloc(struct qed_dev *cdev)
{ {
struct qed_iscsi_info *p_iscsi_info;
struct qed_fcoe_info *p_fcoe_info;
struct qed_ooo_info *p_ooo_info;
#ifdef CONFIG_QED_LL2
struct qed_ll2_info *p_ll2_info;
#endif
u32 rdma_tasks, excess_tasks; u32 rdma_tasks, excess_tasks;
struct qed_consq *p_consq;
struct qed_eq *p_eq;
u32 line_count; u32 line_count;
int i, rc = 0; int i, rc = 0;
...@@ -956,45 +949,38 @@ int qed_resc_alloc(struct qed_dev *cdev) ...@@ -956,45 +949,38 @@ int qed_resc_alloc(struct qed_dev *cdev)
DP_ERR(p_hwfn, DP_ERR(p_hwfn,
"Cannot allocate 0x%x EQ elements. The maximum of a u16 chain is 0x%x\n", "Cannot allocate 0x%x EQ elements. The maximum of a u16 chain is 0x%x\n",
n_eqes, 0xFFFF); n_eqes, 0xFFFF);
rc = -EINVAL; goto alloc_no_mem;
goto alloc_err;
} }
p_eq = qed_eq_alloc(p_hwfn, (u16) n_eqes); rc = qed_eq_alloc(p_hwfn, (u16) n_eqes);
if (!p_eq) if (rc)
goto alloc_no_mem; goto alloc_err;
p_hwfn->p_eq = p_eq;
p_consq = qed_consq_alloc(p_hwfn); rc = qed_consq_alloc(p_hwfn);
if (!p_consq) if (rc)
goto alloc_no_mem; goto alloc_err;
p_hwfn->p_consq = p_consq;
#ifdef CONFIG_QED_LL2 #ifdef CONFIG_QED_LL2
if (p_hwfn->using_ll2) { if (p_hwfn->using_ll2) {
p_ll2_info = qed_ll2_alloc(p_hwfn); rc = qed_ll2_alloc(p_hwfn);
if (!p_ll2_info) if (rc)
goto alloc_no_mem; goto alloc_err;
p_hwfn->p_ll2_info = p_ll2_info;
} }
#endif #endif
if (p_hwfn->hw_info.personality == QED_PCI_FCOE) { if (p_hwfn->hw_info.personality == QED_PCI_FCOE) {
p_fcoe_info = qed_fcoe_alloc(p_hwfn); rc = qed_fcoe_alloc(p_hwfn);
if (!p_fcoe_info) if (rc)
goto alloc_no_mem; goto alloc_err;
p_hwfn->p_fcoe_info = p_fcoe_info;
} }
if (p_hwfn->hw_info.personality == QED_PCI_ISCSI) { if (p_hwfn->hw_info.personality == QED_PCI_ISCSI) {
p_iscsi_info = qed_iscsi_alloc(p_hwfn); rc = qed_iscsi_alloc(p_hwfn);
if (!p_iscsi_info) if (rc)
goto alloc_no_mem; goto alloc_err;
p_hwfn->p_iscsi_info = p_iscsi_info; rc = qed_ooo_alloc(p_hwfn);
p_ooo_info = qed_ooo_alloc(p_hwfn); if (rc)
if (!p_ooo_info) goto alloc_err;
goto alloc_no_mem;
p_hwfn->p_ooo_info = p_ooo_info;
} }
/* DMA info initialization */ /* DMA info initialization */
...@@ -1033,8 +1019,8 @@ void qed_resc_setup(struct qed_dev *cdev) ...@@ -1033,8 +1019,8 @@ void qed_resc_setup(struct qed_dev *cdev)
qed_cxt_mngr_setup(p_hwfn); qed_cxt_mngr_setup(p_hwfn);
qed_spq_setup(p_hwfn); qed_spq_setup(p_hwfn);
qed_eq_setup(p_hwfn, p_hwfn->p_eq); qed_eq_setup(p_hwfn);
qed_consq_setup(p_hwfn, p_hwfn->p_consq); qed_consq_setup(p_hwfn);
/* Read shadow of current MFW mailbox */ /* Read shadow of current MFW mailbox */
qed_mcp_read_mb(p_hwfn, p_hwfn->p_main_ptt); qed_mcp_read_mb(p_hwfn, p_hwfn->p_main_ptt);
...@@ -1047,14 +1033,14 @@ void qed_resc_setup(struct qed_dev *cdev) ...@@ -1047,14 +1033,14 @@ void qed_resc_setup(struct qed_dev *cdev)
qed_iov_setup(p_hwfn, p_hwfn->p_main_ptt); qed_iov_setup(p_hwfn, p_hwfn->p_main_ptt);
#ifdef CONFIG_QED_LL2 #ifdef CONFIG_QED_LL2
if (p_hwfn->using_ll2) if (p_hwfn->using_ll2)
qed_ll2_setup(p_hwfn, p_hwfn->p_ll2_info); qed_ll2_setup(p_hwfn);
#endif #endif
if (p_hwfn->hw_info.personality == QED_PCI_FCOE) if (p_hwfn->hw_info.personality == QED_PCI_FCOE)
qed_fcoe_setup(p_hwfn, p_hwfn->p_fcoe_info); qed_fcoe_setup(p_hwfn);
if (p_hwfn->hw_info.personality == QED_PCI_ISCSI) { if (p_hwfn->hw_info.personality == QED_PCI_ISCSI) {
qed_iscsi_setup(p_hwfn, p_hwfn->p_iscsi_info); qed_iscsi_setup(p_hwfn);
qed_ooo_setup(p_hwfn, p_hwfn->p_ooo_info); qed_ooo_setup(p_hwfn);
} }
} }
} }
...@@ -1968,6 +1954,7 @@ static void qed_hw_hwfn_free(struct qed_hwfn *p_hwfn) ...@@ -1968,6 +1954,7 @@ static void qed_hw_hwfn_free(struct qed_hwfn *p_hwfn)
{ {
qed_ptt_pool_free(p_hwfn); qed_ptt_pool_free(p_hwfn);
kfree(p_hwfn->hw_info.p_igu_info); kfree(p_hwfn->hw_info.p_igu_info);
p_hwfn->hw_info.p_igu_info = NULL;
} }
/* Setup bar access */ /* Setup bar access */
......
...@@ -538,7 +538,7 @@ static void __iomem *qed_fcoe_get_secondary_bdq_prod(struct qed_hwfn *p_hwfn, ...@@ -538,7 +538,7 @@ static void __iomem *qed_fcoe_get_secondary_bdq_prod(struct qed_hwfn *p_hwfn,
} }
} }
struct qed_fcoe_info *qed_fcoe_alloc(struct qed_hwfn *p_hwfn) int qed_fcoe_alloc(struct qed_hwfn *p_hwfn)
{ {
struct qed_fcoe_info *p_fcoe_info; struct qed_fcoe_info *p_fcoe_info;
...@@ -546,19 +546,21 @@ struct qed_fcoe_info *qed_fcoe_alloc(struct qed_hwfn *p_hwfn) ...@@ -546,19 +546,21 @@ struct qed_fcoe_info *qed_fcoe_alloc(struct qed_hwfn *p_hwfn)
p_fcoe_info = kzalloc(sizeof(*p_fcoe_info), GFP_KERNEL); p_fcoe_info = kzalloc(sizeof(*p_fcoe_info), GFP_KERNEL);
if (!p_fcoe_info) { if (!p_fcoe_info) {
DP_NOTICE(p_hwfn, "Failed to allocate qed_fcoe_info'\n"); DP_NOTICE(p_hwfn, "Failed to allocate qed_fcoe_info'\n");
return NULL; return -ENOMEM;
} }
INIT_LIST_HEAD(&p_fcoe_info->free_list); INIT_LIST_HEAD(&p_fcoe_info->free_list);
return p_fcoe_info;
p_hwfn->p_fcoe_info = p_fcoe_info;
return 0;
} }
void qed_fcoe_setup(struct qed_hwfn *p_hwfn, struct qed_fcoe_info *p_fcoe_info) void qed_fcoe_setup(struct qed_hwfn *p_hwfn)
{ {
struct fcoe_task_context *p_task_ctx = NULL; struct fcoe_task_context *p_task_ctx = NULL;
int rc; int rc;
u32 i; u32 i;
spin_lock_init(&p_fcoe_info->lock); spin_lock_init(&p_hwfn->p_fcoe_info->lock);
for (i = 0; i < p_hwfn->pf_params.fcoe_pf_params.num_tasks; i++) { for (i = 0; i < p_hwfn->pf_params.fcoe_pf_params.num_tasks; i++) {
rc = qed_cxt_get_task_ctx(p_hwfn, i, rc = qed_cxt_get_task_ctx(p_hwfn, i,
QED_CTX_WORKING_MEM, QED_CTX_WORKING_MEM,
...@@ -576,15 +578,15 @@ void qed_fcoe_setup(struct qed_hwfn *p_hwfn, struct qed_fcoe_info *p_fcoe_info) ...@@ -576,15 +578,15 @@ void qed_fcoe_setup(struct qed_hwfn *p_hwfn, struct qed_fcoe_info *p_fcoe_info)
} }
} }
void qed_fcoe_free(struct qed_hwfn *p_hwfn, struct qed_fcoe_info *p_fcoe_info) void qed_fcoe_free(struct qed_hwfn *p_hwfn)
{ {
struct qed_fcoe_conn *p_conn = NULL; struct qed_fcoe_conn *p_conn = NULL;
if (!p_fcoe_info) if (!p_hwfn->p_fcoe_info)
return; return;
while (!list_empty(&p_fcoe_info->free_list)) { while (!list_empty(&p_hwfn->p_fcoe_info->free_list)) {
p_conn = list_first_entry(&p_fcoe_info->free_list, p_conn = list_first_entry(&p_hwfn->p_fcoe_info->free_list,
struct qed_fcoe_conn, list_entry); struct qed_fcoe_conn, list_entry);
if (!p_conn) if (!p_conn)
break; break;
...@@ -592,7 +594,8 @@ void qed_fcoe_free(struct qed_hwfn *p_hwfn, struct qed_fcoe_info *p_fcoe_info) ...@@ -592,7 +594,8 @@ void qed_fcoe_free(struct qed_hwfn *p_hwfn, struct qed_fcoe_info *p_fcoe_info)
qed_fcoe_free_connection(p_hwfn, p_conn); qed_fcoe_free_connection(p_hwfn, p_conn);
} }
kfree(p_fcoe_info); kfree(p_hwfn->p_fcoe_info);
p_hwfn->p_fcoe_info = NULL;
} }
static int static int
......
...@@ -49,29 +49,21 @@ struct qed_fcoe_info { ...@@ -49,29 +49,21 @@ struct qed_fcoe_info {
}; };
#if IS_ENABLED(CONFIG_QED_FCOE) #if IS_ENABLED(CONFIG_QED_FCOE)
struct qed_fcoe_info *qed_fcoe_alloc(struct qed_hwfn *p_hwfn); int qed_fcoe_alloc(struct qed_hwfn *p_hwfn);
void qed_fcoe_setup(struct qed_hwfn *p_hwfn, struct qed_fcoe_info *p_fcoe_info); void qed_fcoe_setup(struct qed_hwfn *p_hwfn);
void qed_fcoe_free(struct qed_hwfn *p_hwfn, struct qed_fcoe_info *p_fcoe_info); void qed_fcoe_free(struct qed_hwfn *p_hwfn);
void qed_get_protocol_stats_fcoe(struct qed_dev *cdev, void qed_get_protocol_stats_fcoe(struct qed_dev *cdev,
struct qed_mcp_fcoe_stats *stats); struct qed_mcp_fcoe_stats *stats);
#else /* CONFIG_QED_FCOE */ #else /* CONFIG_QED_FCOE */
static inline struct qed_fcoe_info * static inline int qed_fcoe_alloc(struct qed_hwfn *p_hwfn)
qed_fcoe_alloc(struct qed_hwfn *p_hwfn)
{ {
return NULL; return -EINVAL;
} }
static inline void qed_fcoe_setup(struct qed_hwfn *p_hwfn, static inline void qed_fcoe_setup(struct qed_hwfn *p_hwfn) {}
struct qed_fcoe_info *p_fcoe_info) static inline void qed_fcoe_free(struct qed_hwfn *p_hwfn) {}
{
}
static inline void qed_fcoe_free(struct qed_hwfn *p_hwfn,
struct qed_fcoe_info *p_fcoe_info)
{
}
static inline void qed_get_protocol_stats_fcoe(struct qed_dev *cdev, static inline void qed_get_protocol_stats_fcoe(struct qed_dev *cdev,
struct qed_mcp_fcoe_stats *stats) struct qed_mcp_fcoe_stats *stats)
......
...@@ -158,6 +158,7 @@ int qed_init_alloc(struct qed_hwfn *p_hwfn) ...@@ -158,6 +158,7 @@ int qed_init_alloc(struct qed_hwfn *p_hwfn)
GFP_KERNEL); GFP_KERNEL);
if (!rt_data->init_val) { if (!rt_data->init_val) {
kfree(rt_data->b_valid); kfree(rt_data->b_valid);
rt_data->b_valid = NULL;
return -ENOMEM; return -ENOMEM;
} }
...@@ -167,7 +168,9 @@ int qed_init_alloc(struct qed_hwfn *p_hwfn) ...@@ -167,7 +168,9 @@ int qed_init_alloc(struct qed_hwfn *p_hwfn)
void qed_init_free(struct qed_hwfn *p_hwfn) void qed_init_free(struct qed_hwfn *p_hwfn)
{ {
kfree(p_hwfn->rt_data.init_val); kfree(p_hwfn->rt_data.init_val);
p_hwfn->rt_data.init_val = NULL;
kfree(p_hwfn->rt_data.b_valid); kfree(p_hwfn->rt_data.b_valid);
p_hwfn->rt_data.b_valid = NULL;
} }
static int qed_init_array_dmae(struct qed_hwfn *p_hwfn, static int qed_init_array_dmae(struct qed_hwfn *p_hwfn,
...@@ -525,6 +528,7 @@ int qed_init_run(struct qed_hwfn *p_hwfn, ...@@ -525,6 +528,7 @@ int qed_init_run(struct qed_hwfn *p_hwfn,
} }
kfree(p_hwfn->unzip_buf); kfree(p_hwfn->unzip_buf);
p_hwfn->unzip_buf = NULL;
return rc; return rc;
} }
......
...@@ -2328,6 +2328,7 @@ static void qed_int_sb_attn_free(struct qed_hwfn *p_hwfn) ...@@ -2328,6 +2328,7 @@ static void qed_int_sb_attn_free(struct qed_hwfn *p_hwfn)
SB_ATTN_ALIGNED_SIZE(p_hwfn), SB_ATTN_ALIGNED_SIZE(p_hwfn),
p_sb->sb_attn, p_sb->sb_phys); p_sb->sb_attn, p_sb->sb_phys);
kfree(p_sb); kfree(p_sb);
p_hwfn->p_sb_attn = NULL;
} }
static void qed_int_sb_attn_setup(struct qed_hwfn *p_hwfn, static void qed_int_sb_attn_setup(struct qed_hwfn *p_hwfn,
...@@ -2679,6 +2680,7 @@ static void qed_int_sp_sb_free(struct qed_hwfn *p_hwfn) ...@@ -2679,6 +2680,7 @@ static void qed_int_sp_sb_free(struct qed_hwfn *p_hwfn)
p_sb->sb_info.sb_virt, p_sb->sb_info.sb_virt,
p_sb->sb_info.sb_phys); p_sb->sb_info.sb_phys);
kfree(p_sb); kfree(p_sb);
p_hwfn->p_sp_sb = NULL;
} }
static int qed_int_sp_sb_alloc(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt) static int qed_int_sp_sb_alloc(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
...@@ -3157,6 +3159,7 @@ static int qed_int_sp_dpc_alloc(struct qed_hwfn *p_hwfn) ...@@ -3157,6 +3159,7 @@ static int qed_int_sp_dpc_alloc(struct qed_hwfn *p_hwfn)
static void qed_int_sp_dpc_free(struct qed_hwfn *p_hwfn) static void qed_int_sp_dpc_free(struct qed_hwfn *p_hwfn)
{ {
kfree(p_hwfn->sp_dpc); kfree(p_hwfn->sp_dpc);
p_hwfn->sp_dpc = NULL;
} }
int qed_int_alloc(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt) int qed_int_alloc(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
......
...@@ -818,29 +818,32 @@ void qed_iscsi_free_connection(struct qed_hwfn *p_hwfn, ...@@ -818,29 +818,32 @@ void qed_iscsi_free_connection(struct qed_hwfn *p_hwfn,
kfree(p_conn); kfree(p_conn);
} }
struct qed_iscsi_info *qed_iscsi_alloc(struct qed_hwfn *p_hwfn) int qed_iscsi_alloc(struct qed_hwfn *p_hwfn)
{ {
struct qed_iscsi_info *p_iscsi_info; struct qed_iscsi_info *p_iscsi_info;
p_iscsi_info = kzalloc(sizeof(*p_iscsi_info), GFP_KERNEL); p_iscsi_info = kzalloc(sizeof(*p_iscsi_info), GFP_KERNEL);
if (!p_iscsi_info) if (!p_iscsi_info)
return NULL; return -ENOMEM;
INIT_LIST_HEAD(&p_iscsi_info->free_list); INIT_LIST_HEAD(&p_iscsi_info->free_list);
return p_iscsi_info;
p_hwfn->p_iscsi_info = p_iscsi_info;
return 0;
} }
void qed_iscsi_setup(struct qed_hwfn *p_hwfn, void qed_iscsi_setup(struct qed_hwfn *p_hwfn)
struct qed_iscsi_info *p_iscsi_info)
{ {
spin_lock_init(&p_iscsi_info->lock); spin_lock_init(&p_hwfn->p_iscsi_info->lock);
} }
void qed_iscsi_free(struct qed_hwfn *p_hwfn, void qed_iscsi_free(struct qed_hwfn *p_hwfn)
struct qed_iscsi_info *p_iscsi_info)
{ {
struct qed_iscsi_conn *p_conn = NULL; struct qed_iscsi_conn *p_conn = NULL;
if (!p_hwfn->p_iscsi_info)
return;
while (!list_empty(&p_hwfn->p_iscsi_info->free_list)) { while (!list_empty(&p_hwfn->p_iscsi_info->free_list)) {
p_conn = list_first_entry(&p_hwfn->p_iscsi_info->free_list, p_conn = list_first_entry(&p_hwfn->p_iscsi_info->free_list,
struct qed_iscsi_conn, list_entry); struct qed_iscsi_conn, list_entry);
...@@ -850,7 +853,8 @@ void qed_iscsi_free(struct qed_hwfn *p_hwfn, ...@@ -850,7 +853,8 @@ void qed_iscsi_free(struct qed_hwfn *p_hwfn,
} }
} }
kfree(p_iscsi_info); kfree(p_hwfn->p_iscsi_info);
p_hwfn->p_iscsi_info = NULL;
} }
static void _qed_iscsi_get_tstats(struct qed_hwfn *p_hwfn, static void _qed_iscsi_get_tstats(struct qed_hwfn *p_hwfn,
......
...@@ -57,13 +57,11 @@ extern const struct qed_ll2_ops qed_ll2_ops_pass; ...@@ -57,13 +57,11 @@ extern const struct qed_ll2_ops qed_ll2_ops_pass;
#endif #endif
#if IS_ENABLED(CONFIG_QED_ISCSI) #if IS_ENABLED(CONFIG_QED_ISCSI)
struct qed_iscsi_info *qed_iscsi_alloc(struct qed_hwfn *p_hwfn); int qed_iscsi_alloc(struct qed_hwfn *p_hwfn);
void qed_iscsi_setup(struct qed_hwfn *p_hwfn, void qed_iscsi_setup(struct qed_hwfn *p_hwfn);
struct qed_iscsi_info *p_iscsi_info);
void qed_iscsi_free(struct qed_hwfn *p_hwfn, void qed_iscsi_free(struct qed_hwfn *p_hwfn);
struct qed_iscsi_info *p_iscsi_info);
/** /**
* @brief - Fills provided statistics struct with statistics. * @brief - Fills provided statistics struct with statistics.
...@@ -74,12 +72,15 @@ void qed_iscsi_free(struct qed_hwfn *p_hwfn, ...@@ -74,12 +72,15 @@ void qed_iscsi_free(struct qed_hwfn *p_hwfn,
void qed_get_protocol_stats_iscsi(struct qed_dev *cdev, void qed_get_protocol_stats_iscsi(struct qed_dev *cdev,
struct qed_mcp_iscsi_stats *stats); struct qed_mcp_iscsi_stats *stats);
#else /* IS_ENABLED(CONFIG_QED_ISCSI) */ #else /* IS_ENABLED(CONFIG_QED_ISCSI) */
static inline struct qed_iscsi_info *qed_iscsi_alloc( static inline int qed_iscsi_alloc(struct qed_hwfn *p_hwfn)
struct qed_hwfn *p_hwfn) { return NULL; } {
static inline void qed_iscsi_setup(struct qed_hwfn *p_hwfn, return -EINVAL;
struct qed_iscsi_info *p_iscsi_info) {} }
static inline void qed_iscsi_free(struct qed_hwfn *p_hwfn,
struct qed_iscsi_info *p_iscsi_info) {} static inline void qed_iscsi_setup(struct qed_hwfn *p_hwfn) {}
static inline void qed_iscsi_free(struct qed_hwfn *p_hwfn) {}
static inline void static inline void
qed_get_protocol_stats_iscsi(struct qed_dev *cdev, qed_get_protocol_stats_iscsi(struct qed_dev *cdev,
struct qed_mcp_iscsi_stats *stats) {} struct qed_mcp_iscsi_stats *stats) {}
......
...@@ -1920,7 +1920,7 @@ void qed_ll2_release_connection(struct qed_hwfn *p_hwfn, u8 connection_handle) ...@@ -1920,7 +1920,7 @@ void qed_ll2_release_connection(struct qed_hwfn *p_hwfn, u8 connection_handle)
mutex_unlock(&p_ll2_conn->mutex); mutex_unlock(&p_ll2_conn->mutex);
} }
struct qed_ll2_info *qed_ll2_alloc(struct qed_hwfn *p_hwfn) int qed_ll2_alloc(struct qed_hwfn *p_hwfn)
{ {
struct qed_ll2_info *p_ll2_connections; struct qed_ll2_info *p_ll2_connections;
u8 i; u8 i;
...@@ -1930,28 +1930,31 @@ struct qed_ll2_info *qed_ll2_alloc(struct qed_hwfn *p_hwfn) ...@@ -1930,28 +1930,31 @@ struct qed_ll2_info *qed_ll2_alloc(struct qed_hwfn *p_hwfn)
sizeof(struct qed_ll2_info), GFP_KERNEL); sizeof(struct qed_ll2_info), GFP_KERNEL);
if (!p_ll2_connections) { if (!p_ll2_connections) {
DP_NOTICE(p_hwfn, "Failed to allocate `struct qed_ll2'\n"); DP_NOTICE(p_hwfn, "Failed to allocate `struct qed_ll2'\n");
return NULL; return -ENOMEM;
} }
for (i = 0; i < QED_MAX_NUM_OF_LL2_CONNECTIONS; i++) for (i = 0; i < QED_MAX_NUM_OF_LL2_CONNECTIONS; i++)
p_ll2_connections[i].my_id = i; p_ll2_connections[i].my_id = i;
return p_ll2_connections; p_hwfn->p_ll2_info = p_ll2_connections;
return 0;
} }
void qed_ll2_setup(struct qed_hwfn *p_hwfn, void qed_ll2_setup(struct qed_hwfn *p_hwfn)
struct qed_ll2_info *p_ll2_connections)
{ {
int i; int i;
for (i = 0; i < QED_MAX_NUM_OF_LL2_CONNECTIONS; i++) for (i = 0; i < QED_MAX_NUM_OF_LL2_CONNECTIONS; i++)
mutex_init(&p_ll2_connections[i].mutex); mutex_init(&p_hwfn->p_ll2_info[i].mutex);
} }
void qed_ll2_free(struct qed_hwfn *p_hwfn, void qed_ll2_free(struct qed_hwfn *p_hwfn)
struct qed_ll2_info *p_ll2_connections)
{ {
kfree(p_ll2_connections); if (!p_hwfn->p_ll2_info)
return;
kfree(p_hwfn->p_ll2_info);
p_hwfn->p_ll2_info = NULL;
} }
static void _qed_ll2_get_tstats(struct qed_hwfn *p_hwfn, static void _qed_ll2_get_tstats(struct qed_hwfn *p_hwfn,
......
...@@ -306,27 +306,24 @@ int qed_ll2_get_stats(struct qed_hwfn *p_hwfn, ...@@ -306,27 +306,24 @@ int qed_ll2_get_stats(struct qed_hwfn *p_hwfn,
* *
* @param p_hwfn * @param p_hwfn
* *
* @return pointer to alocated qed_ll2_info or NULL * @return int
*/ */
struct qed_ll2_info *qed_ll2_alloc(struct qed_hwfn *p_hwfn); int qed_ll2_alloc(struct qed_hwfn *p_hwfn);
/** /**
* @brief qed_ll2_setup - Inits LL2 connections set * @brief qed_ll2_setup - Inits LL2 connections set
* *
* @param p_hwfn * @param p_hwfn
* @param p_ll2_connections
* *
*/ */
void qed_ll2_setup(struct qed_hwfn *p_hwfn, void qed_ll2_setup(struct qed_hwfn *p_hwfn);
struct qed_ll2_info *p_ll2_connections);
/** /**
* @brief qed_ll2_free - Releases LL2 connections set * @brief qed_ll2_free - Releases LL2 connections set
* *
* @param p_hwfn * @param p_hwfn
* @param p_ll2_connections
* *
*/ */
void qed_ll2_free(struct qed_hwfn *p_hwfn, void qed_ll2_free(struct qed_hwfn *p_hwfn);
struct qed_ll2_info *p_ll2_connections);
#endif #endif
...@@ -177,6 +177,7 @@ int qed_mcp_free(struct qed_hwfn *p_hwfn) ...@@ -177,6 +177,7 @@ int qed_mcp_free(struct qed_hwfn *p_hwfn)
} }
kfree(p_hwfn->mcp_info); kfree(p_hwfn->mcp_info);
p_hwfn->mcp_info = NULL;
return 0; return 0;
} }
......
...@@ -99,7 +99,7 @@ void qed_ooo_save_history_entry(struct qed_hwfn *p_hwfn, ...@@ -99,7 +99,7 @@ void qed_ooo_save_history_entry(struct qed_hwfn *p_hwfn,
p_history->head_idx++; p_history->head_idx++;
} }
struct qed_ooo_info *qed_ooo_alloc(struct qed_hwfn *p_hwfn) int qed_ooo_alloc(struct qed_hwfn *p_hwfn)
{ {
u16 max_num_archipelagos = 0, cid_base; u16 max_num_archipelagos = 0, cid_base;
struct qed_ooo_info *p_ooo_info; struct qed_ooo_info *p_ooo_info;
...@@ -109,7 +109,7 @@ struct qed_ooo_info *qed_ooo_alloc(struct qed_hwfn *p_hwfn) ...@@ -109,7 +109,7 @@ struct qed_ooo_info *qed_ooo_alloc(struct qed_hwfn *p_hwfn)
if (p_hwfn->hw_info.personality != QED_PCI_ISCSI) { if (p_hwfn->hw_info.personality != QED_PCI_ISCSI) {
DP_NOTICE(p_hwfn, DP_NOTICE(p_hwfn,
"Failed to allocate qed_ooo_info: unknown personality\n"); "Failed to allocate qed_ooo_info: unknown personality\n");
return NULL; return -EINVAL;
} }
max_num_archipelagos = p_hwfn->pf_params.iscsi_pf_params.num_cons; max_num_archipelagos = p_hwfn->pf_params.iscsi_pf_params.num_cons;
...@@ -119,12 +119,12 @@ struct qed_ooo_info *qed_ooo_alloc(struct qed_hwfn *p_hwfn) ...@@ -119,12 +119,12 @@ struct qed_ooo_info *qed_ooo_alloc(struct qed_hwfn *p_hwfn)
if (!max_num_archipelagos) { if (!max_num_archipelagos) {
DP_NOTICE(p_hwfn, DP_NOTICE(p_hwfn,
"Failed to allocate qed_ooo_info: unknown amount of connections\n"); "Failed to allocate qed_ooo_info: unknown amount of connections\n");
return NULL; return -EINVAL;
} }
p_ooo_info = kzalloc(sizeof(*p_ooo_info), GFP_KERNEL); p_ooo_info = kzalloc(sizeof(*p_ooo_info), GFP_KERNEL);
if (!p_ooo_info) if (!p_ooo_info)
return NULL; return -ENOMEM;
p_ooo_info->cid_base = cid_base; p_ooo_info->cid_base = cid_base;
p_ooo_info->max_num_archipelagos = max_num_archipelagos; p_ooo_info->max_num_archipelagos = max_num_archipelagos;
...@@ -164,7 +164,8 @@ struct qed_ooo_info *qed_ooo_alloc(struct qed_hwfn *p_hwfn) ...@@ -164,7 +164,8 @@ struct qed_ooo_info *qed_ooo_alloc(struct qed_hwfn *p_hwfn)
p_ooo_info->ooo_history.num_of_cqes = QED_MAX_NUM_OOO_HISTORY_ENTRIES; p_ooo_info->ooo_history.num_of_cqes = QED_MAX_NUM_OOO_HISTORY_ENTRIES;
return p_ooo_info; p_hwfn->p_ooo_info = p_ooo_info;
return 0;
no_history_mem: no_history_mem:
kfree(p_ooo_info->p_archipelagos_mem); kfree(p_ooo_info->p_archipelagos_mem);
...@@ -172,7 +173,7 @@ struct qed_ooo_info *qed_ooo_alloc(struct qed_hwfn *p_hwfn) ...@@ -172,7 +173,7 @@ struct qed_ooo_info *qed_ooo_alloc(struct qed_hwfn *p_hwfn)
kfree(p_ooo_info->p_isles_mem); kfree(p_ooo_info->p_isles_mem);
no_isles_mem: no_isles_mem:
kfree(p_ooo_info); kfree(p_ooo_info);
return NULL; return -ENOMEM;
} }
void qed_ooo_release_connection_isles(struct qed_hwfn *p_hwfn, void qed_ooo_release_connection_isles(struct qed_hwfn *p_hwfn,
...@@ -249,19 +250,23 @@ void qed_ooo_release_all_isles(struct qed_hwfn *p_hwfn, ...@@ -249,19 +250,23 @@ void qed_ooo_release_all_isles(struct qed_hwfn *p_hwfn,
&p_ooo_info->free_buffers_list); &p_ooo_info->free_buffers_list);
} }
void qed_ooo_setup(struct qed_hwfn *p_hwfn, struct qed_ooo_info *p_ooo_info) void qed_ooo_setup(struct qed_hwfn *p_hwfn)
{ {
qed_ooo_release_all_isles(p_hwfn, p_ooo_info); qed_ooo_release_all_isles(p_hwfn, p_hwfn->p_ooo_info);
memset(p_ooo_info->ooo_history.p_cqes, 0, memset(p_hwfn->p_ooo_info->ooo_history.p_cqes, 0,
p_ooo_info->ooo_history.num_of_cqes * p_hwfn->p_ooo_info->ooo_history.num_of_cqes *
sizeof(struct ooo_opaque)); sizeof(struct ooo_opaque));
p_ooo_info->ooo_history.head_idx = 0; p_hwfn->p_ooo_info->ooo_history.head_idx = 0;
} }
void qed_ooo_free(struct qed_hwfn *p_hwfn, struct qed_ooo_info *p_ooo_info) void qed_ooo_free(struct qed_hwfn *p_hwfn)
{ {
struct qed_ooo_info *p_ooo_info = p_hwfn->p_ooo_info;
struct qed_ooo_buffer *p_buffer; struct qed_ooo_buffer *p_buffer;
if (!p_ooo_info)
return;
qed_ooo_release_all_isles(p_hwfn, p_ooo_info); qed_ooo_release_all_isles(p_hwfn, p_ooo_info);
while (!list_empty(&p_ooo_info->free_buffers_list)) { while (!list_empty(&p_ooo_info->free_buffers_list)) {
p_buffer = list_first_entry(&p_ooo_info->free_buffers_list, p_buffer = list_first_entry(&p_ooo_info->free_buffers_list,
...@@ -282,6 +287,7 @@ void qed_ooo_free(struct qed_hwfn *p_hwfn, struct qed_ooo_info *p_ooo_info) ...@@ -282,6 +287,7 @@ void qed_ooo_free(struct qed_hwfn *p_hwfn, struct qed_ooo_info *p_ooo_info)
kfree(p_ooo_info->p_archipelagos_mem); kfree(p_ooo_info->p_archipelagos_mem);
kfree(p_ooo_info->ooo_history.p_cqes); kfree(p_ooo_info->ooo_history.p_cqes);
kfree(p_ooo_info); kfree(p_ooo_info);
p_hwfn->p_ooo_info = NULL;
} }
void qed_ooo_put_free_buffer(struct qed_hwfn *p_hwfn, void qed_ooo_put_free_buffer(struct qed_hwfn *p_hwfn,
......
...@@ -88,7 +88,11 @@ void qed_ooo_save_history_entry(struct qed_hwfn *p_hwfn, ...@@ -88,7 +88,11 @@ void qed_ooo_save_history_entry(struct qed_hwfn *p_hwfn,
struct qed_ooo_info *p_ooo_info, struct qed_ooo_info *p_ooo_info,
struct ooo_opaque *p_cqe); struct ooo_opaque *p_cqe);
struct qed_ooo_info *qed_ooo_alloc(struct qed_hwfn *p_hwfn); int qed_ooo_alloc(struct qed_hwfn *p_hwfn);
void qed_ooo_setup(struct qed_hwfn *p_hwfn);
void qed_ooo_free(struct qed_hwfn *p_hwfn);
void qed_ooo_release_connection_isles(struct qed_hwfn *p_hwfn, void qed_ooo_release_connection_isles(struct qed_hwfn *p_hwfn,
struct qed_ooo_info *p_ooo_info, struct qed_ooo_info *p_ooo_info,
...@@ -97,10 +101,6 @@ void qed_ooo_release_connection_isles(struct qed_hwfn *p_hwfn, ...@@ -97,10 +101,6 @@ void qed_ooo_release_connection_isles(struct qed_hwfn *p_hwfn,
void qed_ooo_release_all_isles(struct qed_hwfn *p_hwfn, void qed_ooo_release_all_isles(struct qed_hwfn *p_hwfn,
struct qed_ooo_info *p_ooo_info); struct qed_ooo_info *p_ooo_info);
void qed_ooo_setup(struct qed_hwfn *p_hwfn, struct qed_ooo_info *p_ooo_info);
void qed_ooo_free(struct qed_hwfn *p_hwfn, struct qed_ooo_info *p_ooo_info);
void qed_ooo_put_free_buffer(struct qed_hwfn *p_hwfn, void qed_ooo_put_free_buffer(struct qed_hwfn *p_hwfn,
struct qed_ooo_info *p_ooo_info, struct qed_ooo_info *p_ooo_info,
struct qed_ooo_buffer *p_buffer); struct qed_ooo_buffer *p_buffer);
...@@ -140,8 +140,14 @@ static inline void qed_ooo_save_history_entry(struct qed_hwfn *p_hwfn, ...@@ -140,8 +140,14 @@ static inline void qed_ooo_save_history_entry(struct qed_hwfn *p_hwfn,
struct qed_ooo_info *p_ooo_info, struct qed_ooo_info *p_ooo_info,
struct ooo_opaque *p_cqe) {} struct ooo_opaque *p_cqe) {}
static inline struct qed_ooo_info *qed_ooo_alloc( static inline int qed_ooo_alloc(struct qed_hwfn *p_hwfn)
struct qed_hwfn *p_hwfn) { return NULL; } {
return -EINVAL;
}
static inline void qed_ooo_setup(struct qed_hwfn *p_hwfn) {}
static inline void qed_ooo_free(struct qed_hwfn *p_hwfn) {}
static inline void static inline void
qed_ooo_release_connection_isles(struct qed_hwfn *p_hwfn, qed_ooo_release_connection_isles(struct qed_hwfn *p_hwfn,
...@@ -152,12 +158,6 @@ static inline void qed_ooo_release_all_isles(struct qed_hwfn *p_hwfn, ...@@ -152,12 +158,6 @@ static inline void qed_ooo_release_all_isles(struct qed_hwfn *p_hwfn,
struct qed_ooo_info *p_ooo_info) struct qed_ooo_info *p_ooo_info)
{} {}
static inline void qed_ooo_setup(struct qed_hwfn *p_hwfn,
struct qed_ooo_info *p_ooo_info) {}
static inline void qed_ooo_free(struct qed_hwfn *p_hwfn,
struct qed_ooo_info *p_ooo_info) {}
static inline void qed_ooo_put_free_buffer(struct qed_hwfn *p_hwfn, static inline void qed_ooo_put_free_buffer(struct qed_hwfn *p_hwfn,
struct qed_ooo_info *p_ooo_info, struct qed_ooo_info *p_ooo_info,
struct qed_ooo_buffer *p_buffer) {} struct qed_ooo_buffer *p_buffer) {}
......
...@@ -270,28 +270,23 @@ void qed_spq_return_entry(struct qed_hwfn *p_hwfn, ...@@ -270,28 +270,23 @@ void qed_spq_return_entry(struct qed_hwfn *p_hwfn,
* @param p_hwfn * @param p_hwfn
* @param num_elem number of elements in the eq * @param num_elem number of elements in the eq
* *
* @return struct qed_eq* - a newly allocated structure; NULL upon error. * @return int
*/ */
struct qed_eq *qed_eq_alloc(struct qed_hwfn *p_hwfn, int qed_eq_alloc(struct qed_hwfn *p_hwfn, u16 num_elem);
u16 num_elem);
/** /**
* @brief qed_eq_setup - Reset the SPQ to its start state. * @brief qed_eq_setup - Reset the EQ to its start state.
* *
* @param p_hwfn * @param p_hwfn
* @param p_eq
*/ */
void qed_eq_setup(struct qed_hwfn *p_hwfn, void qed_eq_setup(struct qed_hwfn *p_hwfn);
struct qed_eq *p_eq);
/** /**
* @brief qed_eq_deallocate - deallocates the given EQ struct. * @brief qed_eq_free - deallocates the given EQ struct.
* *
* @param p_hwfn * @param p_hwfn
* @param p_eq
*/ */
void qed_eq_free(struct qed_hwfn *p_hwfn, void qed_eq_free(struct qed_hwfn *p_hwfn);
struct qed_eq *p_eq);
/** /**
* @brief qed_eq_prod_update - update the FW with default EQ producer * @brief qed_eq_prod_update - update the FW with default EQ producer
...@@ -342,28 +337,23 @@ u32 qed_spq_get_cid(struct qed_hwfn *p_hwfn); ...@@ -342,28 +337,23 @@ u32 qed_spq_get_cid(struct qed_hwfn *p_hwfn);
* *
* @param p_hwfn * @param p_hwfn
* *
* @return struct qed_eq* - a newly allocated structure; NULL upon error. * @return int
*/ */
struct qed_consq *qed_consq_alloc(struct qed_hwfn *p_hwfn); int qed_consq_alloc(struct qed_hwfn *p_hwfn);
/** /**
* @brief qed_consq_setup - Reset the ConsQ to its start * @brief qed_consq_setup - Reset the ConsQ to its start state.
* state.
* *
* @param p_hwfn * @param p_hwfn
* @param p_eq
*/ */
void qed_consq_setup(struct qed_hwfn *p_hwfn, void qed_consq_setup(struct qed_hwfn *p_hwfn);
struct qed_consq *p_consq);
/** /**
* @brief qed_consq_free - deallocates the given ConsQ struct. * @brief qed_consq_free - deallocates the given ConsQ struct.
* *
* @param p_hwfn * @param p_hwfn
* @param p_eq
*/ */
void qed_consq_free(struct qed_hwfn *p_hwfn, void qed_consq_free(struct qed_hwfn *p_hwfn);
struct qed_consq *p_consq);
/** /**
* @file * @file
......
...@@ -403,14 +403,14 @@ int qed_eq_completion(struct qed_hwfn *p_hwfn, void *cookie) ...@@ -403,14 +403,14 @@ int qed_eq_completion(struct qed_hwfn *p_hwfn, void *cookie)
return rc; return rc;
} }
struct qed_eq *qed_eq_alloc(struct qed_hwfn *p_hwfn, u16 num_elem) int qed_eq_alloc(struct qed_hwfn *p_hwfn, u16 num_elem)
{ {
struct qed_eq *p_eq; struct qed_eq *p_eq;
/* Allocate EQ struct */ /* Allocate EQ struct */
p_eq = kzalloc(sizeof(*p_eq), GFP_KERNEL); p_eq = kzalloc(sizeof(*p_eq), GFP_KERNEL);
if (!p_eq) if (!p_eq)
return NULL; return -ENOMEM;
/* Allocate and initialize EQ chain*/ /* Allocate and initialize EQ chain*/
if (qed_chain_alloc(p_hwfn->cdev, if (qed_chain_alloc(p_hwfn->cdev,
...@@ -426,24 +426,28 @@ struct qed_eq *qed_eq_alloc(struct qed_hwfn *p_hwfn, u16 num_elem) ...@@ -426,24 +426,28 @@ struct qed_eq *qed_eq_alloc(struct qed_hwfn *p_hwfn, u16 num_elem)
qed_int_register_cb(p_hwfn, qed_eq_completion, qed_int_register_cb(p_hwfn, qed_eq_completion,
p_eq, &p_eq->eq_sb_index, &p_eq->p_fw_cons); p_eq, &p_eq->eq_sb_index, &p_eq->p_fw_cons);
return p_eq; p_hwfn->p_eq = p_eq;
return 0;
eq_allocate_fail: eq_allocate_fail:
qed_eq_free(p_hwfn, p_eq); kfree(p_eq);
return NULL; return -ENOMEM;
} }
void qed_eq_setup(struct qed_hwfn *p_hwfn, struct qed_eq *p_eq) void qed_eq_setup(struct qed_hwfn *p_hwfn)
{ {
qed_chain_reset(&p_eq->chain); qed_chain_reset(&p_hwfn->p_eq->chain);
} }
void qed_eq_free(struct qed_hwfn *p_hwfn, struct qed_eq *p_eq) void qed_eq_free(struct qed_hwfn *p_hwfn)
{ {
if (!p_eq) if (!p_hwfn->p_eq)
return; return;
qed_chain_free(p_hwfn->cdev, &p_eq->chain);
kfree(p_eq); qed_chain_free(p_hwfn->cdev, &p_hwfn->p_eq->chain);
kfree(p_hwfn->p_eq);
p_hwfn->p_eq = NULL;
} }
/*************************************************************************** /***************************************************************************
...@@ -583,8 +587,8 @@ void qed_spq_free(struct qed_hwfn *p_hwfn) ...@@ -583,8 +587,8 @@ void qed_spq_free(struct qed_hwfn *p_hwfn)
} }
qed_chain_free(p_hwfn->cdev, &p_spq->chain); qed_chain_free(p_hwfn->cdev, &p_spq->chain);
;
kfree(p_spq); kfree(p_spq);
p_hwfn->p_spq = NULL;
} }
int qed_spq_get_entry(struct qed_hwfn *p_hwfn, struct qed_spq_entry **pp_ent) int qed_spq_get_entry(struct qed_hwfn *p_hwfn, struct qed_spq_entry **pp_ent)
...@@ -934,14 +938,14 @@ int qed_spq_completion(struct qed_hwfn *p_hwfn, ...@@ -934,14 +938,14 @@ int qed_spq_completion(struct qed_hwfn *p_hwfn,
return rc; return rc;
} }
struct qed_consq *qed_consq_alloc(struct qed_hwfn *p_hwfn) int qed_consq_alloc(struct qed_hwfn *p_hwfn)
{ {
struct qed_consq *p_consq; struct qed_consq *p_consq;
/* Allocate ConsQ struct */ /* Allocate ConsQ struct */
p_consq = kzalloc(sizeof(*p_consq), GFP_KERNEL); p_consq = kzalloc(sizeof(*p_consq), GFP_KERNEL);
if (!p_consq) if (!p_consq)
return NULL; return -ENOMEM;
/* Allocate and initialize EQ chain*/ /* Allocate and initialize EQ chain*/
if (qed_chain_alloc(p_hwfn->cdev, if (qed_chain_alloc(p_hwfn->cdev,
...@@ -952,22 +956,26 @@ struct qed_consq *qed_consq_alloc(struct qed_hwfn *p_hwfn) ...@@ -952,22 +956,26 @@ struct qed_consq *qed_consq_alloc(struct qed_hwfn *p_hwfn)
0x80, &p_consq->chain)) 0x80, &p_consq->chain))
goto consq_allocate_fail; goto consq_allocate_fail;
return p_consq; p_hwfn->p_consq = p_consq;
return 0;
consq_allocate_fail: consq_allocate_fail:
qed_consq_free(p_hwfn, p_consq); kfree(p_consq);
return NULL; return -ENOMEM;
} }
void qed_consq_setup(struct qed_hwfn *p_hwfn, struct qed_consq *p_consq) void qed_consq_setup(struct qed_hwfn *p_hwfn)
{ {
qed_chain_reset(&p_consq->chain); qed_chain_reset(&p_hwfn->p_consq->chain);
} }
void qed_consq_free(struct qed_hwfn *p_hwfn, struct qed_consq *p_consq) void qed_consq_free(struct qed_hwfn *p_hwfn)
{ {
if (!p_consq) if (!p_hwfn->p_consq)
return; return;
qed_chain_free(p_hwfn->cdev, &p_consq->chain);
kfree(p_consq); qed_chain_free(p_hwfn->cdev, &p_hwfn->p_consq->chain);
kfree(p_hwfn->p_consq);
p_hwfn->p_consq = NULL;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment