ath10k: cleanup
cover ath10k: cleanup
This is part 4 of 4 of a bigger patchset.
Split for easier review.
Note: it is not based on master branch.
Michal Kazior (2):
ath10k: embed HTC struct inside ath10k
ath10k: embed HTT struct inside ath10k
drivers/net/wireless/ath/ath10k/core.c | 40 ++++++++++++++---------------- drivers/net/wireless/ath/ath10k/core.h | 9 +++---- drivers/net/wireless/ath/ath10k/htc.c | 23 ++++------------- drivers/net/wireless/ath/ath10k/htc.h | 4 +-- drivers/net/wireless/ath/ath10k/htt.c | 26 ++++++++++--------- drivers/net/wireless/ath/ath10k/htt.h | 3 +-- drivers/net/wireless/ath/ath10k/htt_rx.c | 3 ++- drivers/net/wireless/ath/ath10k/htt_tx.c | 12 ++++----- drivers/net/wireless/ath/ath10k/mac.c | 16 ++++++------ drivers/net/wireless/ath/ath10k/wmi.c | 4 +-- 10 files changed, 61 insertions(+), 79 deletions(-)
Signature · 1 line
1.7.9.5
PATCH 1/2 ath10k: embed HTC struct inside ath10k
This reduces number of allocations and simplifies
memory managemnt.
--- drivers/net/wireless/ath/ath10k/core.c | 28 ++++++++++++---------------- drivers/net/wireless/ath/ath10k/core.h | 2 +- drivers/net/wireless/ath/ath10k/htc.c | 23 +++++------------------ drivers/net/wireless/ath/ath10k/htc.h | 4 +--- drivers/net/wireless/ath/ath10k/htt.c | 2 +- drivers/net/wireless/ath/ath10k/htt_tx.c | 10 +++++----- drivers/net/wireless/ath/ath10k/wmi.c | 4 ++-- 7 files changed, 27 insertions(+), 46 deletions(-)
drivers/net/wireless/ath/ath10k/core.c +12 -16
@@ -100,7 +100,7 @@ static int ath10k_init_connect_htc(struct ath10k *ar) goto conn_fail;/* Start HTC */ - status =ath10k_htc_start (ar->htc); + status =ath10k_htc_start (&ar->htc);if (status) goto conn_fail;
@@ -116,7 +116,7 @@ static int ath10k_init_connect_htc(struct ath10k *ar)return 0 ; timeout: -ath10k_htc_stop (ar->htc); +ath10k_htc_stop (&ar->htc); conn_fail:return status; }
@@ -538,7 +538,6 @@ EXPORT_SYMBOL(ath10k_core_destroy);int ath10k_core_init (struct ath10k *ar) { -struct ath10k_htc_ops htc_ops;int status; ar->bmi.done_sent = false;
@@ -557,26 +556,26 @@ int ath10k_core_init(struct ath10k *ar)if (status) 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); -if (IS_ERR (ar->htc)) { - status =PTR_ERR (ar->htc); -ath10k_err ("could not create HTC (%d)\n" , status); + status =ath10k_htc_init (ar); +if (status) { +ath10k_err ("could not init HTC (%d)\n" , status); goto err; } status =ath10k_bmi_done (ar);if (status) - goto err_htc_destroy; + goto err; status =ath10k_wmi_attach (ar);if (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) goto err_wmi_detach;
@@ -616,13 +615,11 @@ int ath10k_core_init(struct ath10k *ar)return 0 ; err_disconnect_htc: -ath10k_htc_stop (ar->htc); +ath10k_htc_stop (&ar->htc); err_htt_detach:ath10k_htt_detach (ar->htt); err_wmi_detach:ath10k_wmi_detach (ar); -err_htc_destroy: -ath10k_htc_destroy (ar->htc); err:return status; }
@@ -630,10 +627,9 @@ EXPORT_SYMBOL(ath10k_core_init);void ath10k_core_deinit (struct ath10k *ar) { -ath10k_htc_stop (ar->htc); +ath10k_htc_stop (&ar->htc);ath10k_htt_detach (ar->htt);ath10k_wmi_detach (ar); -ath10k_htc_destroy (ar->htc); }EXPORT_SYMBOL (ath10k_core_deinit);
drivers/net/wireless/ath/ath10k/core.h +1 -1
@@ -279,8 +279,8 @@ struct ath10k {bool is_target_paused;struct ath10k_bmi bmi; +struct ath10k_htc htc; -struct ath10k_htc *htc;struct ath10k_htt *htt;struct ath10k_hw_params {
drivers/net/wireless/ath/ath10k/htc.c +5 -18
@@ -265,7 +265,7 @@ static int ath10k_htc_tx_completion_handler(struct ath10k *ar, struct sk_buff *skb, unsigned int eid) { -struct ath10k_htc *htc = ar->htc; +struct ath10k_htc *htc = &ar->htc;struct ath10k_htc_ep *ep = &htc->endpoint[eid];bool stopping;
@@ -414,7 +414,7 @@ static int ath10k_htc_rx_completion_handler(struct ath10k *ar, u8 pipe_id) {int status =0 ; -struct ath10k_htc *htc = ar->htc; +struct ath10k_htc *htc = &ar->htc;struct ath10k_htc_hdr *hdr;struct ath10k_htc_ep *ep;u16 payload_len;
@@ -961,22 +961,14 @@ void ath10k_htc_stop(struct ath10k_htc *htc) }/* registered target arrival callback from the HIF layer */ -struct ath10k_htc *ath10k_htc_create (struct ath10k *ar, -struct ath10k_htc_ops *htc_ops) +int ath10k_htc_init (struct ath10k *ar) {struct ath10k_hif_cb htc_callbacks;struct ath10k_htc_ep *ep =NULL ; -struct ath10k_htc *htc =NULL ; - -/* FIXME: use struct ath10k instead */ - htc =kzalloc (sizeof (struct ath10k_htc ),GFP_KERNEL ); -if (!htc) -return ERR_PTR (-ENOMEM ); +struct ath10k_htc *htc = &ar->htc;spin_lock_init (&htc->tx_lock); -memcpy (&htc->htc_ops, htc_ops,sizeof (struct ath10k_htc_ops )); -ath10k_htc_reset_endpoint_states (htc);/* setup HIF layer callbacks */
@@ -992,10 +984,5 @@ struct ath10k_htc *ath10k_htc_create(struct ath10k *ar,init_completion (&htc->ctl_resp); -return htc; -} - -void ath10k_htc_destroy (struct ath10k_htc *htc) -{ -kfree (htc); +return 0 ; }
drivers/net/wireless/ath/ath10k/htc.h +1 -3
@@ -352,8 +352,7 @@ struct ath10k_htc {bool stopping; }; -struct ath10k_htc *ath10k_htc_create (struct ath10k *ar, -struct ath10k_htc_ops *htc_ops); +int ath10k_htc_init (struct ath10k *ar);int ath10k_htc_wait_target (struct ath10k_htc *htc);int ath10k_htc_start (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,int ath10k_htc_send (struct ath10k_htc *htc,enum ath10k_htc_ep_id eid,struct sk_buff *packet);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);#endif
drivers/net/wireless/ath/ath10k/htt.c +1 -1
@@ -36,7 +36,7 @@ static int ath10k_htt_htc_attach(struct ath10k_htt *htt)/* connect to control service */ 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);if (status)
drivers/net/wireless/ath/ath10k/htt_tx.c +5 -5
@@ -92,7 +92,7 @@ int ath10k_htt_tx_attach(struct ath10k_htt *htt)/* At the beginning free queue number should hint us the maximum * 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, pipe);
@@ -194,7 +194,7 @@ int ath10k_htt_h2t_ver_req_msg(struct ath10k_htt *htt)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) {dev_kfree_skb_any (skb);return ret;
@@ -281,7 +281,7 @@ int ath10k_htt_send_rx_ring_cfg_ll(struct ath10k_htt *htt)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) {dev_kfree_skb_any (skb);return ret;
@@ -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.msdu = msdu; - res =ath10k_htc_send (htt->ar->htc, htt->eid, txdesc); + res =ath10k_htc_send (&htt->ar->htc, htt->eid, txdesc);if (res) goto err;
@@ -486,7 +486,7 @@ int ath10k_htt_tx(struct ath10k_htt *htt, struct sk_buff *msdu) skb_cb->htt.txfrag = txfrag; 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) goto err;
drivers/net/wireless/ath/ath10k/wmi.c +2 -2
@@ -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); - status =ath10k_htc_send (ar->htc, ar->wmi.eid, skb); + status =ath10k_htc_send (&ar->htc, ar->wmi.eid, skb);if (status) {dev_kfree_skb_any (skb);atomic_dec (&ar->wmi.pending_tx_count);
@@ -1114,7 +1114,7 @@ int ath10k_wmi_connect_htc_service(struct ath10k *ar)/* connect to control service */ 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) {ath10k_warn ("failed to connect to WMI CONTROL service status: %d\n" , status);
Signature · 1 line
1.7.9.5
PATCH 2/2 ath10k: embed HTT struct inside ath10k
In reply to Michal KaziorThis reduces number of allocations and simplifies
memory managemnt.
--- drivers/net/wireless/ath/ath10k/core.c | 12 ++++++------ drivers/net/wireless/ath/ath10k/core.h | 7 +++---- drivers/net/wireless/ath/ath10k/htt.c | 24 +++++++++++++----------- drivers/net/wireless/ath/ath10k/htt.h | 3 +-- drivers/net/wireless/ath/ath10k/htt_rx.c | 3 ++- drivers/net/wireless/ath/ath10k/htt_tx.c | 2 +- drivers/net/wireless/ath/ath10k/mac.c | 16 ++++++++-------- 7 files changed, 34 insertions(+), 33 deletions(-)
drivers/net/wireless/ath/ath10k/core.c +6 -6
@@ -579,9 +579,9 @@ int ath10k_core_init(struct ath10k *ar)if (status) goto err_wmi_detach; - ar->htt =ath10k_htt_attach (ar); -if (!ar->htt) { - status = -ENOMEM ; + status =ath10k_htt_attach (ar); +if (status) { +ath10k_err ("could not attach htt (%d)\n" , status); goto err_wmi_detach; }
@@ -608,7 +608,7 @@ int ath10k_core_init(struct ath10k *ar) goto err_disconnect_htc; } - status =ath10k_htt_attach_target (ar->htt); + status =ath10k_htt_attach_target (&ar->htt);if (status) goto err_disconnect_htc;
@@ -617,7 +617,7 @@ int ath10k_core_init(struct ath10k *ar) err_disconnect_htc:ath10k_htc_stop (&ar->htc); err_htt_detach: -ath10k_htt_detach (ar->htt); +ath10k_htt_detach (&ar->htt); err_wmi_detach:ath10k_wmi_detach (ar); err:
@@ -628,7 +628,7 @@ EXPORT_SYMBOL(ath10k_core_init);void ath10k_core_deinit (struct ath10k *ar) {ath10k_htc_stop (&ar->htc); -ath10k_htt_detach (ar->htt); +ath10k_htt_detach (&ar->htt);ath10k_wmi_detach (ar); }EXPORT_SYMBOL (ath10k_core_deinit);
drivers/net/wireless/ath/ath10k/core.h +3 -4
@@ -23,6 +23,7 @@#include <linux/types.h> #include <linux/pci.h> +#include "htt.h" #include "htc.h" #include "hw.h" #include "targaddrs.h"
@@ -273,15 +274,13 @@ struct ath10k {const struct ath10k_hif_ops *ops; } hif; -struct ath10k_wmi wmi; -wait_queue_head_t event_queue;bool is_target_paused;struct ath10k_bmi bmi; +struct ath10k_wmi wmi;struct ath10k_htc htc; - -struct ath10k_htt *htt; +struct ath10k_htt htt;struct ath10k_hw_params {u32 id;
drivers/net/wireless/ath/ath10k/htt.c +13 -11
@@ -16,6 +16,7 @@*/ #include <linux/slab.h> +#include <linux/if_ether.h> #include "htt.h" #include "core.h"
@@ -47,15 +48,11 @@ static int ath10k_htt_htc_attach(struct ath10k_htt *htt)return 0 ; } -struct ath10k_htt *ath10k_htt_attach (struct ath10k *ar) +int ath10k_htt_attach (struct ath10k *ar) { -struct ath10k_htt *htt; +struct ath10k_htt *htt = &ar->htt;int ret; - htt =kzalloc (sizeof (*htt),GFP_KERNEL ); -if (!htt) -return NULL ; - htt->ar = ar; htt->max_throughput_mbps =800 ;
@@ -65,8 +62,11 @@ struct ath10k_htt *ath10k_htt_attach(struct ath10k *ar)* since ath10k_htt_rx_attach involves sending a rx ring configure * message to the target. */ -if (ath10k_htt_htc_attach (htt)) + ret =ath10k_htt_htc_attach (htt); +if (ret) { +ath10k_err ("could not attach htt htc (%d)\n" , ret); goto err_htc_attach; + } ret =ath10k_htt_tx_attach (htt);if (ret) {
@@ -74,8 +74,11 @@ struct ath10k_htt *ath10k_htt_attach(struct ath10k *ar) goto err_htc_attach; } -if (ath10k_htt_rx_attach (htt)) + ret =ath10k_htt_rx_attach (htt); +if (ret) { +ath10k_err ("could not attach htt rx (%d)\n" , ret); goto err_rx_attach; + }/* * Prefetch enough data to satisfy target
@@ -89,13 +92,13 @@ struct ath10k_htt *ath10k_htt_attach(struct ath10k *ar)8 +/* llc snap */ 2 ;/* ip4 dscp or ip6 priority */ -return htt; +return 0 ; err_rx_attach:ath10k_htt_tx_detach (htt); err_htc_attach:kfree (htt); -return NULL ; +return ret; }#define HTT_TARGET_VERSION_TIMEOUT_HZ (3*HZ)
@@ -148,5 +151,4 @@ void ath10k_htt_detach(struct ath10k_htt *htt) {ath10k_htt_rx_detach (htt);ath10k_htt_tx_detach (htt); -kfree (htt); }
drivers/net/wireless/ath/ath10k/htt.h +1 -2
@@ -20,7 +20,6 @@#include <linux/bug.h> -#include "core.h" #include "htc.h" #include "rx_desc.h"
@@ -1317,7 +1316,7 @@ struct htt_rx_desc {#define HTT_LOG2_MAX_CACHE_LINE_SIZE 7/* 2^7 = 128 */ #define HTT_MAX_CACHE_LINE_SIZE_MASK ((1 << HTT_LOG2_MAX_CACHE_LINE_SIZE) - 1) -struct ath10k_htt *ath10k_htt_attach (struct ath10k *ar); +int ath10k_htt_attach (struct ath10k *ar);int ath10k_htt_attach_target (struct ath10k_htt *htt);void ath10k_htt_detach (struct ath10k_htt *htt);
drivers/net/wireless/ath/ath10k/htt_rx.c +2 -1
@@ -15,6 +15,7 @@* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include "core.h" #include "htc.h" #include "htt.h" #include "txrx.h"
@@ -1036,7 +1037,7 @@ end:void ath10k_htt_t2h_msg_handler (struct ath10k *ar,struct sk_buff *skb) { -struct ath10k_htt *htt = ar->htt; +struct ath10k_htt *htt = &ar->htt;struct htt_resp *resp = (struct htt_resp *)skb->data;/* confirm alignment */
drivers/net/wireless/ath/ath10k/htt_tx.c +1 -1
@@ -153,7 +153,7 @@ void ath10k_htt_tx_detach(struct ath10k_htt *htt)void ath10k_htt_htc_tx_complete (struct ath10k *ar,struct sk_buff *skb) {struct ath10k_skb_cb *skb_cb =ATH10K_SKB_CB (skb); -struct ath10k_htt *htt = ar->htt; +struct ath10k_htt *htt = &ar->htt;if (skb_cb->htt.is_conf) {dev_kfree_skb_any (skb);
drivers/net/wireless/ath/ath10k/mac.c +8 -8
@@ -1418,15 +1418,15 @@ static void ath10k_tx_htt(struct ath10k *ar, struct sk_buff *skb)int ret;if (ieee80211_is_mgmt (hdr->frame_control)) - ret =ath10k_htt_mgmt_tx (ar->htt, skb); + ret =ath10k_htt_mgmt_tx (&ar->htt, skb);else if (ieee80211_is_nullfunc (hdr->frame_control))/* FW does not report tx status properly for NullFunc frames * unless they are sent through mgmt tx path. mac80211 sends * those frames when it detects link/beacon loss and depends on * the tx status to be correct. */ - ret =ath10k_htt_mgmt_tx (ar->htt, skb); + ret =ath10k_htt_mgmt_tx (&ar->htt, skb);else - ret =ath10k_htt_tx (ar->htt, skb); + ret =ath10k_htt_tx (&ar->htt, skb);if (ret) {ath10k_warn ("tx failed (%d). dropping packet.\n" , ret);
@@ -2709,12 +2709,12 @@ static void ath10k_flush(struct ieee80211_hw *hw, u32 queues, bool drop)if (drop)return ; - ret =wait_event_timeout (ar->htt->empty_tx_wq, ({ + ret =wait_event_timeout (ar->htt.empty_tx_wq, ({bool empty; -spin_lock_bh (&ar->htt->tx_lock); - empty =bitmap_empty (ar->htt->used_msdu_ids, - ar->htt->max_num_pending_tx); -spin_unlock_bh (&ar->htt->tx_lock); +spin_lock_bh (&ar->htt.tx_lock); + empty =bitmap_empty (ar->htt.used_msdu_ids, + ar->htt.max_num_pending_tx); +spin_unlock_bh (&ar->htt.tx_lock); (empty); }),ATH10K_FLUSH_TIMEOUT_HZ );if (ret <=0 )
Signature · 1 line
1.7.9.5
cover ath10k: cleanup
In reply to Michal KaziorQuoted 8 lines · Michal Kazior
This is part 4 of 4 of a bigger patchset.
Split for easier review.Note: it is not based on master branch.
Michal Kazior (2):
ath10k: embed HTC struct inside ath10k
ath10k: embed HTT struct inside ath10k
I get a lot of conflicts when applying this. Can you please rebase and resend?
Signature · 1 line
Kalle Valo