Commit cd003fad authored by Michal Kazior's avatar Michal Kazior Committed by Kalle Valo

ath10k: embed HTC struct inside ath10k

This reduces number of allocations and simplifies
memory managemnt.
Signed-off-by: default avatarMichal Kazior <michal.kazior@tieto.com>
Signed-off-by: default avatarKalle Valo <kvalo@qca.qualcomm.com>
parent e799bbff
...@@ -100,7 +100,7 @@ static int ath10k_init_connect_htc(struct ath10k *ar) ...@@ -100,7 +100,7 @@ static int ath10k_init_connect_htc(struct ath10k *ar)
goto conn_fail; goto conn_fail;
/* Start HTC */ /* Start HTC */
status = ath10k_htc_start(ar->htc); status = ath10k_htc_start(&ar->htc);
if (status) if (status)
goto conn_fail; goto conn_fail;
...@@ -116,7 +116,7 @@ static int ath10k_init_connect_htc(struct ath10k *ar) ...@@ -116,7 +116,7 @@ static int ath10k_init_connect_htc(struct ath10k *ar)
return 0; return 0;
timeout: timeout:
ath10k_htc_stop(ar->htc); ath10k_htc_stop(&ar->htc);
conn_fail: conn_fail:
return status; return status;
} }
...@@ -505,7 +505,6 @@ EXPORT_SYMBOL(ath10k_core_destroy); ...@@ -505,7 +505,6 @@ EXPORT_SYMBOL(ath10k_core_destroy);
int ath10k_core_register(struct ath10k *ar) int ath10k_core_register(struct ath10k *ar)
{ {
struct ath10k_htc_ops htc_ops;
struct bmi_target_info target_info; struct bmi_target_info target_info;
int status; int status;
...@@ -534,26 +533,26 @@ int ath10k_core_register(struct ath10k *ar) ...@@ -534,26 +533,26 @@ int ath10k_core_register(struct ath10k *ar)
if (status) if (status)
goto err; goto err;
htc_ops.target_send_suspend_complete = ath10k_send_suspend_complete; ar->htc.htc_ops.target_send_suspend_complete =
ath10k_send_suspend_complete;
ar->htc = ath10k_htc_create(ar, &htc_ops); status = ath10k_htc_init(ar);
if (IS_ERR(ar->htc)) { if (status) {
status = PTR_ERR(ar->htc); ath10k_err("could not init HTC (%d)\n", status);
ath10k_err("could not create HTC (%d)\n", status);
goto err; goto err;
} }
status = ath10k_bmi_done(ar); status = ath10k_bmi_done(ar);
if (status) if (status)
goto err_htc_destroy; goto err;
status = ath10k_wmi_attach(ar); status = ath10k_wmi_attach(ar);
if (status) { if (status) {
ath10k_err("WMI attach failed: %d\n", status); ath10k_err("WMI attach failed: %d\n", status);
goto err_htc_destroy; goto err;
} }
status = ath10k_htc_wait_target(ar->htc); status = ath10k_htc_wait_target(&ar->htc);
if (status) if (status)
goto err_wmi_detach; goto err_wmi_detach;
...@@ -605,13 +604,11 @@ int ath10k_core_register(struct ath10k *ar) ...@@ -605,13 +604,11 @@ int ath10k_core_register(struct ath10k *ar)
err_unregister_mac: err_unregister_mac:
ath10k_mac_unregister(ar); ath10k_mac_unregister(ar);
err_disconnect_htc: err_disconnect_htc:
ath10k_htc_stop(ar->htc); ath10k_htc_stop(&ar->htc);
err_htt_detach: err_htt_detach:
ath10k_htt_detach(ar->htt); ath10k_htt_detach(ar->htt);
err_wmi_detach: err_wmi_detach:
ath10k_wmi_detach(ar); ath10k_wmi_detach(ar);
err_htc_destroy:
ath10k_htc_destroy(ar->htc);
err: err:
return status; return status;
} }
...@@ -623,10 +620,9 @@ void ath10k_core_unregister(struct ath10k *ar) ...@@ -623,10 +620,9 @@ void ath10k_core_unregister(struct ath10k *ar)
* Otherwise we will fail to submit commands to FW and mac80211 will be * Otherwise we will fail to submit commands to FW and mac80211 will be
* unhappy about callback failures. */ * unhappy about callback failures. */
ath10k_mac_unregister(ar); ath10k_mac_unregister(ar);
ath10k_htc_stop(ar->htc); ath10k_htc_stop(&ar->htc);
ath10k_htt_detach(ar->htt); ath10k_htt_detach(ar->htt);
ath10k_wmi_detach(ar); ath10k_wmi_detach(ar);
ath10k_htc_destroy(ar->htc);
} }
EXPORT_SYMBOL(ath10k_core_unregister); EXPORT_SYMBOL(ath10k_core_unregister);
......
...@@ -279,8 +279,8 @@ struct ath10k { ...@@ -279,8 +279,8 @@ struct ath10k {
bool is_target_paused; bool is_target_paused;
struct ath10k_bmi bmi; struct ath10k_bmi bmi;
struct ath10k_htc htc;
struct ath10k_htc *htc;
struct ath10k_htt *htt; struct ath10k_htt *htt;
struct ath10k_hw_params { struct ath10k_hw_params {
......
...@@ -265,7 +265,7 @@ static int ath10k_htc_tx_completion_handler(struct ath10k *ar, ...@@ -265,7 +265,7 @@ static int ath10k_htc_tx_completion_handler(struct ath10k *ar,
struct sk_buff *skb, struct sk_buff *skb,
unsigned int eid) unsigned int eid)
{ {
struct ath10k_htc *htc = ar->htc; struct ath10k_htc *htc = &ar->htc;
struct ath10k_htc_ep *ep = &htc->endpoint[eid]; struct ath10k_htc_ep *ep = &htc->endpoint[eid];
bool stopping; bool stopping;
...@@ -414,7 +414,7 @@ static int ath10k_htc_rx_completion_handler(struct ath10k *ar, ...@@ -414,7 +414,7 @@ static int ath10k_htc_rx_completion_handler(struct ath10k *ar,
u8 pipe_id) u8 pipe_id)
{ {
int status = 0; int status = 0;
struct ath10k_htc *htc = ar->htc; struct ath10k_htc *htc = &ar->htc;
struct ath10k_htc_hdr *hdr; struct ath10k_htc_hdr *hdr;
struct ath10k_htc_ep *ep; struct ath10k_htc_ep *ep;
u16 payload_len; u16 payload_len;
...@@ -961,22 +961,14 @@ void ath10k_htc_stop(struct ath10k_htc *htc) ...@@ -961,22 +961,14 @@ void ath10k_htc_stop(struct ath10k_htc *htc)
} }
/* registered target arrival callback from the HIF layer */ /* registered target arrival callback from the HIF layer */
struct ath10k_htc *ath10k_htc_create(struct ath10k *ar, int ath10k_htc_init(struct ath10k *ar)
struct ath10k_htc_ops *htc_ops)
{ {
struct ath10k_hif_cb htc_callbacks; struct ath10k_hif_cb htc_callbacks;
struct ath10k_htc_ep *ep = NULL; struct ath10k_htc_ep *ep = NULL;
struct ath10k_htc *htc = NULL; struct ath10k_htc *htc = &ar->htc;
/* FIXME: use struct ath10k instead */
htc = kzalloc(sizeof(struct ath10k_htc), GFP_KERNEL);
if (!htc)
return ERR_PTR(-ENOMEM);
spin_lock_init(&htc->tx_lock); spin_lock_init(&htc->tx_lock);
memcpy(&htc->htc_ops, htc_ops, sizeof(struct ath10k_htc_ops));
ath10k_htc_reset_endpoint_states(htc); ath10k_htc_reset_endpoint_states(htc);
/* setup HIF layer callbacks */ /* setup HIF layer callbacks */
...@@ -992,10 +984,5 @@ struct ath10k_htc *ath10k_htc_create(struct ath10k *ar, ...@@ -992,10 +984,5 @@ struct ath10k_htc *ath10k_htc_create(struct ath10k *ar,
init_completion(&htc->ctl_resp); init_completion(&htc->ctl_resp);
return htc; return 0;
}
void ath10k_htc_destroy(struct ath10k_htc *htc)
{
kfree(htc);
} }
...@@ -352,8 +352,7 @@ struct ath10k_htc { ...@@ -352,8 +352,7 @@ struct ath10k_htc {
bool stopping; bool stopping;
}; };
struct ath10k_htc *ath10k_htc_create(struct ath10k *ar, int ath10k_htc_init(struct ath10k *ar);
struct ath10k_htc_ops *htc_ops);
int ath10k_htc_wait_target(struct ath10k_htc *htc); int ath10k_htc_wait_target(struct ath10k_htc *htc);
int ath10k_htc_start(struct ath10k_htc *htc); int ath10k_htc_start(struct ath10k_htc *htc);
int ath10k_htc_connect_service(struct ath10k_htc *htc, int ath10k_htc_connect_service(struct ath10k_htc *htc,
...@@ -362,7 +361,6 @@ int ath10k_htc_connect_service(struct ath10k_htc *htc, ...@@ -362,7 +361,6 @@ int ath10k_htc_connect_service(struct ath10k_htc *htc,
int ath10k_htc_send(struct ath10k_htc *htc, enum ath10k_htc_ep_id eid, int ath10k_htc_send(struct ath10k_htc *htc, enum ath10k_htc_ep_id eid,
struct sk_buff *packet); struct sk_buff *packet);
void ath10k_htc_stop(struct ath10k_htc *htc); void ath10k_htc_stop(struct ath10k_htc *htc);
void ath10k_htc_destroy(struct ath10k_htc *htc);
struct sk_buff *ath10k_htc_alloc_skb(int size); struct sk_buff *ath10k_htc_alloc_skb(int size);
#endif #endif
...@@ -36,7 +36,7 @@ static int ath10k_htt_htc_attach(struct ath10k_htt *htt) ...@@ -36,7 +36,7 @@ static int ath10k_htt_htc_attach(struct ath10k_htt *htt)
/* connect to control service */ /* connect to control service */
conn_req.service_id = ATH10K_HTC_SVC_ID_HTT_DATA_MSG; conn_req.service_id = ATH10K_HTC_SVC_ID_HTT_DATA_MSG;
status = ath10k_htc_connect_service(htt->ar->htc, &conn_req, status = ath10k_htc_connect_service(&htt->ar->htc, &conn_req,
&conn_resp); &conn_resp);
if (status) if (status)
......
...@@ -92,7 +92,7 @@ int ath10k_htt_tx_attach(struct ath10k_htt *htt) ...@@ -92,7 +92,7 @@ int ath10k_htt_tx_attach(struct ath10k_htt *htt)
/* At the beginning free queue number should hint us the maximum /* At the beginning free queue number should hint us the maximum
* queue length */ * queue length */
pipe = htt->ar->htc->endpoint[htt->eid].ul_pipe_id; pipe = htt->ar->htc.endpoint[htt->eid].ul_pipe_id;
htt->max_num_pending_tx = ath10k_hif_get_free_queue_number(htt->ar, htt->max_num_pending_tx = ath10k_hif_get_free_queue_number(htt->ar,
pipe); pipe);
...@@ -194,7 +194,7 @@ int ath10k_htt_h2t_ver_req_msg(struct ath10k_htt *htt) ...@@ -194,7 +194,7 @@ int ath10k_htt_h2t_ver_req_msg(struct ath10k_htt *htt)
ATH10K_SKB_CB(skb)->htt.is_conf = true; ATH10K_SKB_CB(skb)->htt.is_conf = true;
ret = ath10k_htc_send(htt->ar->htc, htt->eid, skb); ret = ath10k_htc_send(&htt->ar->htc, htt->eid, skb);
if (ret) { if (ret) {
dev_kfree_skb_any(skb); dev_kfree_skb_any(skb);
return ret; return ret;
...@@ -281,7 +281,7 @@ int ath10k_htt_send_rx_ring_cfg_ll(struct ath10k_htt *htt) ...@@ -281,7 +281,7 @@ int ath10k_htt_send_rx_ring_cfg_ll(struct ath10k_htt *htt)
ATH10K_SKB_CB(skb)->htt.is_conf = true; ATH10K_SKB_CB(skb)->htt.is_conf = true;
ret = ath10k_htc_send(htt->ar->htc, htt->eid, skb); ret = ath10k_htc_send(&htt->ar->htc, htt->eid, skb);
if (ret) { if (ret) {
dev_kfree_skb_any(skb); dev_kfree_skb_any(skb);
return ret; return ret;
...@@ -346,7 +346,7 @@ int ath10k_htt_mgmt_tx(struct ath10k_htt *htt, struct sk_buff *msdu) ...@@ -346,7 +346,7 @@ int ath10k_htt_mgmt_tx(struct ath10k_htt *htt, struct sk_buff *msdu)
skb_cb->htt.refcount = 2; skb_cb->htt.refcount = 2;
skb_cb->htt.msdu = msdu; skb_cb->htt.msdu = msdu;
res = ath10k_htc_send(htt->ar->htc, htt->eid, txdesc); res = ath10k_htc_send(&htt->ar->htc, htt->eid, txdesc);
if (res) if (res)
goto err; goto err;
...@@ -486,7 +486,7 @@ int ath10k_htt_tx(struct ath10k_htt *htt, struct sk_buff *msdu) ...@@ -486,7 +486,7 @@ int ath10k_htt_tx(struct ath10k_htt *htt, struct sk_buff *msdu)
skb_cb->htt.txfrag = txfrag; skb_cb->htt.txfrag = txfrag;
skb_cb->htt.msdu = msdu; skb_cb->htt.msdu = msdu;
res = ath10k_htc_send(htt->ar->htc, htt->eid, txdesc); res = ath10k_htc_send(&htt->ar->htc, htt->eid, txdesc);
if (res) if (res)
goto err; goto err;
......
...@@ -111,7 +111,7 @@ static int ath10k_wmi_cmd_send(struct ath10k *ar, struct sk_buff *skb, ...@@ -111,7 +111,7 @@ static int ath10k_wmi_cmd_send(struct ath10k *ar, struct sk_buff *skb,
trace_ath10k_wmi_cmd(cmd_id, skb->data, skb->len); trace_ath10k_wmi_cmd(cmd_id, skb->data, skb->len);
status = ath10k_htc_send(ar->htc, ar->wmi.eid, skb); status = ath10k_htc_send(&ar->htc, ar->wmi.eid, skb);
if (status) { if (status) {
dev_kfree_skb_any(skb); dev_kfree_skb_any(skb);
atomic_dec(&ar->wmi.pending_tx_count); atomic_dec(&ar->wmi.pending_tx_count);
...@@ -1114,7 +1114,7 @@ int ath10k_wmi_connect_htc_service(struct ath10k *ar) ...@@ -1114,7 +1114,7 @@ int ath10k_wmi_connect_htc_service(struct ath10k *ar)
/* connect to control service */ /* connect to control service */
conn_req.service_id = ATH10K_HTC_SVC_ID_WMI_CONTROL; conn_req.service_id = ATH10K_HTC_SVC_ID_WMI_CONTROL;
status = ath10k_htc_connect_service(ar->htc, &conn_req, &conn_resp); status = ath10k_htc_connect_service(&ar->htc, &conn_req, &conn_resp);
if (status) { if (status) {
ath10k_warn("failed to connect to WMI CONTROL service status: %d\n", ath10k_warn("failed to connect to WMI CONTROL service status: %d\n",
status); status);
......
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