ath10k: Remove duplicate UART init code
PATCH 1/20 ath10k: Remove duplicate UART init code
From: Sujith Manoharan <[email protected]>
--- drivers/net/wireless/ath/ath10k/core.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/net/wireless/ath/ath10k/core.c +0 -4
@@ -534,10 +534,6 @@ int ath10k_core_register(struct ath10k *ar)if (status) goto err; - status =ath10k_init_uart (ar); -if (status) - goto err; - htc_ops.target_send_suspend_complete = ath10k_send_suspend_complete; ar->htc =ath10k_htc_create (ar, &htc_ops);
Signature · 1 line
1.8.2.2
PATCH 2/20 ath10k: Merge mac.h with core.h
From: Sujith Manoharan <[email protected]>
--- drivers/net/wireless/ath/ath10k/core.c | 1 - drivers/net/wireless/ath/ath10k/core.h | 20 +++++++++++ drivers/net/wireless/ath/ath10k/htt_tx.c | 1 - drivers/net/wireless/ath/ath10k/mac.c | 20 +++++++++-- drivers/net/wireless/ath/ath10k/mac.h | 61 -------------------------------- drivers/net/wireless/ath/ath10k/txrx.c | 1 - drivers/net/wireless/ath/ath10k/wmi.c | 1 - 7 files changed, 38 insertions(+), 67 deletions(-) delete mode 100644 drivers/net/wireless/ath/ath10k/mac.h
drivers/net/wireless/ath/ath10k/core.c +0 -1
@@ -19,7 +19,6 @@#include <linux/firmware.h> #include "core.h" -#include "mac.h" #include "htc.h" #include "hif.h" #include "wmi.h"
drivers/net/wireless/ath/ath10k/core.h +20 -0
@@ -374,4 +374,24 @@ void ath10k_core_unregister(struct ath10k *ar);int ath10k_core_target_suspend (struct ath10k *ar);int ath10k_core_target_resume (struct ath10k *ar); +struct ath10k_generic_iter { +struct ath10k *ar; +int ret; +}; + +struct ath10k *ath10k_mac_create (void ); +void ath10k_mac_destroy (struct ath10k *ar); +int ath10k_mac_register (struct ath10k *ar); +void ath10k_mac_unregister (struct ath10k *ar); +struct ath10k_vif *ath10k_get_arvif (struct ath10k *ar,u32 vdev_id); +void ath10k_reset_scan (unsigned long ptr); +void ath10k_offchan_tx_purge (struct ath10k *ar); +void ath10k_offchan_tx_work (struct work_struct *work); +void ath10k_tx_h_seq_no (struct sk_buff *skb); + +static inline struct ath10k_vif *ath10k_vif_to_arvif (struct ieee80211_vif *vif) +{ +return (struct ath10k_vif *)vif->drv_priv; +} +#endif /* _CORE_H_ */
drivers/net/wireless/ath/ath10k/htt_tx.c +0 -1
@@ -17,7 +17,6 @@#include <linux/etherdevice.h> #include "htt.h" -#include "mac.h" #include "txrx.h" #include "debug.h"
drivers/net/wireless/ath/ath10k/mac.c +18 -2
@@ -15,8 +15,6 @@* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include "mac.h" -#include <net/mac80211.h> #include <linux/etherdevice.h>
@@ -218,6 +216,24 @@ static int ath10k_clear_vdev_key(struct ath10k_vif *arvif,/* General utilities */ /*********************/ +void ath10k_tx_h_seq_no (struct sk_buff *skb) +{ +struct ieee80211_tx_info *info =IEEE80211_SKB_CB (skb); +struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; +struct ieee80211_vif *vif = info->control.vif; +struct ath10k_vif *arvif =ath10k_vif_to_arvif (vif); + +if (info->flags &IEEE80211_TX_CTL_ASSIGN_SEQ ) { +if (arvif->tx_seq_no ==0 ) + arvif->tx_seq_no =0x1000 ; + +if (info->flags &IEEE80211_TX_CTL_FIRST_FRAGMENT ) + arvif->tx_seq_no +=0x10 ; + hdr->seq_ctrl &=cpu_to_le16 (IEEE80211_SCTL_FRAG ); + hdr->seq_ctrl |=cpu_to_le16 (arvif->tx_seq_no); + } +} +static inline enum wmi_phy_mode chan_to_phymode (struct ieee80211_channel *chan,enum nl80211_channel_type channel_type) {
drivers/net/wireless/ath/ath10k/mac.h deleted +0 -61
61 lines not on this page · raw message
drivers/net/wireless/ath/ath10k/txrx.c +0 -1
@@ -18,7 +18,6 @@#include "core.h" #include "txrx.h" #include "htt.h" -#include "mac.h" #include "debug.h" static void ath10k_report_offchan_tx (struct ath10k *ar,struct sk_buff *skb)
drivers/net/wireless/ath/ath10k/wmi.c +0 -1
@@ -21,7 +21,6 @@#include "htc.h" #include "debug.h" #include "wmi.h" -#include "mac.h" void ath10k_wmi_flush_tx (struct ath10k *ar) {
Signature · 1 line
1.8.2.2
PATCH 2/20 ath10k: Merge mac.h with core.h
Quoted 13 lines · Sujith Manoharan
From: Sujith Manoharan <[email protected]>
Signed-off-by Sujith Manoharan <[email protected]>--- drivers/net/wireless/ath/ath10k/core.c | 1 - drivers/net/wireless/ath/ath10k/core.h | 20 +++++++++++ drivers/net/wireless/ath/ath10k/htt_tx.c | 1 - drivers/net/wireless/ath/ath10k/mac.c | 20 +++++++++-- drivers/net/wireless/ath/ath10k/mac.h | 61 -------------------------------- drivers/net/wireless/ath/ath10k/txrx.c | 1 - drivers/net/wireless/ath/ath10k/wmi.c | 1 - 7 files changed, 38 insertions(+), 67 deletions(-) delete mode 100644 drivers/net/wireless/ath/ath10k/mac.h
Why do you want to delete mac.h? My idea was to avoid bloating core.h and that's why I wanted to have header files for each .c file.
Signature · 1 line
Kalle Valo
PATCH 2/20 ath10k: Merge mac.h with core.h
Quoted 2 lines · Kalle Valo
Why do you want to delete
mac.h? My idea was to avoid bloatingcore.hand that's why I wanted to have header files for each .c file.
mac.h contains a few prototypes and most of the data structures are in core.h. I don't think core.h is getting bloated, it has barely 300+ lines.
Sujith
PATCH 2/20 ath10k: Merge mac.h with core.h
Quoted 6 lines · Sujith Manoharan
Quoted 2 lines · Kalle Valo
Why do you want to delete
mac.h? My idea was to avoid bloatingcore.hand that's why I wanted to have header files for each .c file.
mac.hcontains a few prototypes and most of the data structures are incore.h. I don't thinkcore.his getting bloated, it has barely 300+ lines.
Yes, it has 300+ lines now as I have enforced that it's not abused. But if I I let everything go to core.h how long will it end up then?
Besides, I can't see what harm having mac.h brings?
Signature · 1 line
Kalle Valo
PATCH 2/20 ath10k: Merge mac.h with core.h
Quoted 6 lines · Kalle Valo
Quoted 4 lines · Sujith Manoharan
Quoted 2 lines · Kalle Valo
Why do you want to delete
mac.h? My idea was to avoid bloatingcore.hand that's why I wanted to have header files for each .c file.
Quoted 7 lines
Quoted 2 lines
mac.hcontains a few prototypes and most of the data structures are incore.h. I don't thinkcore.his getting bloated, it has barely 300+ lines.Yes, it has 300+ lines now as I have enforced that it's not abused. But if I I let everything go to
core.hhow long will it end up then?Besides, I can't see what harm having
mac.hbrings?
Please drop this patch.
PATCH 3/20 ath10k: Rename HIF callback post_init as init
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
--- drivers/net/wireless/ath/ath10k/hif.h | 10 +++++----- drivers/net/wireless/ath/ath10k/htc.c | 2 +- drivers/net/wireless/ath/ath10k/pci.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-)
drivers/net/wireless/ath/ath10k/hif.h +5 -5
@@ -66,8 +66,8 @@ struct ath10k_hif_ops {*/ void (*send_complete_check)(struct ath10k *ar,u8 pipe_id,int force); -void (*post_init)(struct ath10k *ar, -struct ath10k_hif_cb *callbacks); +void (*init)(struct ath10k *ar, +struct ath10k_hif_cb *callbacks);u16 (*get_free_queue_number)(struct ath10k *ar,u8 pipe_id); };
@@ -122,10 +122,10 @@ static inline void ath10k_hif_send_complete_check(struct ath10k *ar, ar->hif.ops->send_complete_check (ar, pipe_id, force); } -static inline void ath10k_hif_post_init (struct ath10k *ar, -struct ath10k_hif_cb *callbacks) +static inline void ath10k_hif_init (struct ath10k *ar, +struct ath10k_hif_cb *callbacks) { - ar->hif.ops->post_init (ar, callbacks); + ar->hif.ops->init (ar, callbacks); } static inline u16 ath10k_hif_get_free_queue_number(struct ath10k *ar,
drivers/net/wireless/ath/ath10k/htc.c +1 -1
@@ -1001,7 +1001,7 @@ struct ath10k_htc *ath10k_htc_create(struct ath10k *ar,/* Get HIF default pipe for HTC message exchange */ ep = &htc->endpoint[ATH10K_HTC_EP_0 ]; -ath10k_hif_post_init (ar, &htc_callbacks); +ath10k_hif_init (ar, &htc_callbacks);ath10k_hif_get_default_pipe (ar, &ep->ul_pipe_id, &ep->dl_pipe_id);init_completion (&htc->ctl_resp);
drivers/net/wireless/ath/ath10k/pci.c +1 -1
@@ -1673,7 +1673,7 @@ static const struct ath10k_hif_ops ath10k_pci_hif_ops = { .map_service_to_pipe = ath10k_pci_hif_map_service_to_pipe, .get_default_pipe = ath10k_pci_hif_get_default_pipe, .send_complete_check = ath10k_pci_hif_send_complete_check, - .post_init = ath10k_pci_hif_post_init, + .init = ath10k_pci_hif_post_init, .get_free_queue_number = ath10k_pci_hif_get_free_queue_number, };
Signature · 1 line
1.8.2.2
PATCH 4/20 ath10k: Remove "ar" inside WMI structure
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
--- drivers/net/wireless/ath/ath10k/core.h | 2 -- drivers/net/wireless/ath/ath10k/wmi.c | 1 - 2 files changed, 3 deletions(-)
drivers/net/wireless/ath/ath10k/core.h +0 -2
@@ -115,8 +115,6 @@ struct ath10k_bmi { };struct ath10k_wmi { -struct ath10k *ar; -enum ath10k_htc_ep_id eid;struct completion service_ready;struct completion unified_ready;
drivers/net/wireless/ath/ath10k/wmi.c +0 -1
@@ -1079,7 +1079,6 @@ static void ath10k_wmi_process_rx(void *ptr, struct sk_buff *skb)/* WMI Initialization functions */ int ath10k_wmi_attach (struct ath10k *ar) { - ar->wmi.ar = ar;init_completion (&ar->wmi.service_ready);init_completion (&ar->wmi.unified_ready);init_waitqueue_head (&ar->wmi.wq);
Signature · 1 line
1.8.2.2
PATCH 5/20 ath10k: Remove "htc" inside HTT struct
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
--- drivers/net/wireless/ath/ath10k/core.c | 2 +- drivers/net/wireless/ath/ath10k/htt.c | 5 ++--- drivers/net/wireless/ath/ath10k/htt.h | 4 +--- drivers/net/wireless/ath/ath10k/htt_tx.c | 8 ++++---- 4 files changed, 8 insertions(+), 11 deletions(-)
drivers/net/wireless/ath/ath10k/core.c +1 -1
@@ -555,7 +555,7 @@ int ath10k_core_register(struct ath10k *ar)if (status) goto err_wmi_detach; - ar->htt =ath10k_htt_attach (ar, ar->htc); + ar->htt =ath10k_htt_attach (ar);if (!ar->htt) { status = -ENOMEM ; goto err_wmi_detach;
drivers/net/wireless/ath/ath10k/htt.c +2 -3
@@ -57,7 +57,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->htc, &conn_req, &conn_resp); + status =ath10k_htc_connect_service (htt->ar->htc, &conn_req, &conn_resp);if (status)return status;
@@ -67,7 +67,7 @@ static int ath10k_htt_htc_attach(struct ath10k_htt *htt)return 0 ; } -struct ath10k_htt *ath10k_htt_attach (struct ath10k *ar,struct ath10k_htc *htc) +struct ath10k_htt *ath10k_htt_attach (struct ath10k *ar) {struct ath10k_htt *htt;
@@ -76,7 +76,6 @@ struct ath10k_htt *ath10k_htt_attach(struct ath10k *ar, struct ath10k_htc *htc)return NULL ; htt->ar = ar; - htt->htc = htc; htt->cfg.max_throughput_mbps =800 ;/*
drivers/net/wireless/ath/ath10k/htt.h +1 -3
@@ -1103,8 +1103,6 @@ struct htt_rx_info {struct ath10k_htt {struct ath10k *ar; -struct ath10k_htc *htc; -enum ath10k_htc_ep_id eid;struct {
@@ -1259,7 +1257,7 @@ struct htt_rx_desc {/* FIXME: add htt_tx_desc_init() */ -struct ath10k_htt *ath10k_htt_attach (struct ath10k *ar,struct ath10k_htc *htc); +struct ath10k_htt *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_tx.c +4 -4
@@ -130,7 +130,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->htc, htt->eid, skb); + ret =ath10k_htc_send (htt->ar->htc, htt->eid, skb);if (ret) {dev_kfree_skb_any (skb);return ret;
@@ -217,7 +217,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->htc, htt->eid, skb); + ret =ath10k_htc_send (htt->ar->htc, htt->eid, skb);if (ret) {dev_kfree_skb_any (skb);return ret;
@@ -277,7 +277,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->htc, htt->eid, txdesc); + res =ath10k_htc_send (htt->ar->htc, htt->eid, txdesc);if (res) goto err;
@@ -412,7 +412,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->htc, htt->eid, txdesc); + res =ath10k_htc_send (htt->ar->htc, htt->eid, txdesc);if (res) goto err;
Signature · 1 line
1.8.2.2
PATCH 6/20 ath10k: Move debug routines to debug.c
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
--- drivers/net/wireless/ath/ath10k/debug.c | 119 ++++++++++++++++++++++++++++++ drivers/net/wireless/ath/ath10k/debug.h | 124 ++------------------------------ 2 files changed, 124 insertions(+), 119 deletions(-)
drivers/net/wireless/ath/ath10k/debug.c +119 -0
@@ -99,6 +99,13 @@ EXPORT_SYMBOL(ath10k_warn);#ifdef CONFIG_ATH10K_DEBUGFS +void ath10k_debug_read_service_map (struct ath10k *ar, +void *service_map, +size_t map_size) +{ +memcpy (ar->debug.wmi_service_bitmap, service_map, map_size); +} +static ssize_t ath10k_read_wmi_services (struct file *file,char __user *user_buf,size_t count,loff_t *ppos)
@@ -147,6 +154,118 @@ static const struct file_operations fops_wmi_services = { .llseek = default_llseek, }; +void ath10k_debug_read_target_stats (struct ath10k *ar, +struct wmi_stats_event *ev) +{ +u8 *tmp = ev->data; +struct ath10k_target_stats *stats; +int num_pdev_stats, num_vdev_stats, num_peer_stats; +struct wmi_pdev_stats *ps; +int i; + +mutex_lock (&ar->conf_mutex); + + stats = &ar->debug.target_stats; + + num_pdev_stats =__le32_to_cpu (ev->num_pdev_stats);/* 0 or 1 */ + num_vdev_stats =__le32_to_cpu (ev->num_vdev_stats);/* 0 or max vdevs */ + num_peer_stats =__le32_to_cpu (ev->num_peer_stats);/* 0 or max peers */ + +if (num_pdev_stats) { + ps = (struct wmi_pdev_stats *)tmp; + + stats->ch_noise_floor =__le32_to_cpu (ps->chan_nf); + stats->tx_frame_count =__le32_to_cpu (ps->tx_frame_count); + stats->rx_frame_count =__le32_to_cpu (ps->rx_frame_count); + stats->rx_clear_count =__le32_to_cpu (ps->rx_clear_count); + stats->cycle_count =__le32_to_cpu (ps->cycle_count); + stats->phy_err_count =__le32_to_cpu (ps->phy_err_count); + stats->chan_tx_power =__le32_to_cpu (ps->chan_tx_pwr); + + stats->comp_queued =__le32_to_cpu (ps->wal.tx.comp_queued); + stats->comp_delivered = +__le32_to_cpu (ps->wal.tx.comp_delivered); + stats->msdu_enqued =__le32_to_cpu (ps->wal.tx.msdu_enqued); + stats->mpdu_enqued =__le32_to_cpu (ps->wal.tx.mpdu_enqued); + stats->wmm_drop =__le32_to_cpu (ps->wal.tx.wmm_drop); + stats->local_enqued =__le32_to_cpu (ps->wal.tx.local_enqued); + stats->local_freed =__le32_to_cpu (ps->wal.tx.local_freed); + stats->hw_queued =__le32_to_cpu (ps->wal.tx.hw_queued); + stats->hw_reaped =__le32_to_cpu (ps->wal.tx.hw_reaped); + stats->underrun =__le32_to_cpu (ps->wal.tx.underrun); + stats->tx_abort =__le32_to_cpu (ps->wal.tx.tx_abort); + stats->mpdus_requed =__le32_to_cpu (ps->wal.tx.mpdus_requed); + stats->tx_ko =__le32_to_cpu (ps->wal.tx.tx_ko); + stats->data_rc =__le32_to_cpu (ps->wal.tx.data_rc); + stats->self_triggers =__le32_to_cpu (ps->wal.tx.self_triggers); + stats->sw_retry_failure = +__le32_to_cpu (ps->wal.tx.sw_retry_failure); + stats->illgl_rate_phy_err = +__le32_to_cpu (ps->wal.tx.illgl_rate_phy_err); + stats->pdev_cont_xretry = +__le32_to_cpu (ps->wal.tx.pdev_cont_xretry); + stats->pdev_tx_timeout = +__le32_to_cpu (ps->wal.tx.pdev_tx_timeout); + stats->pdev_resets =__le32_to_cpu (ps->wal.tx.pdev_resets); + stats->phy_underrun =__le32_to_cpu (ps->wal.tx.phy_underrun); + stats->txop_ovf =__le32_to_cpu (ps->wal.tx.txop_ovf); + + stats->mid_ppdu_route_change = +__le32_to_cpu (ps->wal.rx.mid_ppdu_route_change); + stats->status_rcvd =__le32_to_cpu (ps->wal.rx.status_rcvd); + stats->r0_frags =__le32_to_cpu (ps->wal.rx.r0_frags); + stats->r1_frags =__le32_to_cpu (ps->wal.rx.r1_frags); + stats->r2_frags =__le32_to_cpu (ps->wal.rx.r2_frags); + stats->r3_frags =__le32_to_cpu (ps->wal.rx.r3_frags); + stats->htt_msdus =__le32_to_cpu (ps->wal.rx.htt_msdus); + stats->htt_mpdus =__le32_to_cpu (ps->wal.rx.htt_mpdus); + stats->loc_msdus =__le32_to_cpu (ps->wal.rx.loc_msdus); + stats->loc_mpdus =__le32_to_cpu (ps->wal.rx.loc_mpdus); + stats->oversize_amsdu = +__le32_to_cpu (ps->wal.rx.oversize_amsdu); + stats->phy_errs =__le32_to_cpu (ps->wal.rx.phy_errs); + stats->phy_err_drop =__le32_to_cpu (ps->wal.rx.phy_err_drop); + stats->mpdu_errs =__le32_to_cpu (ps->wal.rx.mpdu_errs); + + tmp +=sizeof (struct wmi_pdev_stats ); + } + +/* 0 or max vdevs */ +/* Currently firmware does not support VDEV stats */ +if (num_vdev_stats) { +struct wmi_vdev_stats *vdev_stats; + +for (i =0 ; i < num_vdev_stats; i++) { + vdev_stats = (struct wmi_vdev_stats *)tmp; + tmp +=sizeof (struct wmi_vdev_stats ); + } + } + +if (num_peer_stats) { +struct wmi_peer_stats *peer_stats; +struct ath10k_peer_stat *s; + + stats->peers = num_peer_stats; + +for (i =0 ; i < num_peer_stats; i++) { + peer_stats = (struct wmi_peer_stats *)tmp; + s = &stats->peer_stat[i]; + +WMI_MAC_ADDR_TO_CHAR_ARRAY (&peer_stats->peer_macaddr, + s->peer_macaddr); + s->peer_rssi =__le32_to_cpu (peer_stats->peer_rssi); + s->peer_tx_rate = +__le32_to_cpu (peer_stats->peer_tx_rate); + + tmp +=sizeof (struct wmi_peer_stats ); + } + } + +mutex_unlock (&ar->conf_mutex); +complete (&ar->debug.event_stats_compl); + +} +static ssize_t ath10k_read_fw_stats (struct file *file,char __user *user_buf,size_t count,loff_t *ppos) {
drivers/net/wireless/ath/ath10k/debug.h +5 -119
130 lines not on this page · raw message
Signature · 1 line
1.8.2.2
Kalle Valo
AppliedPATCH 6/20 ath10k: Move debug routines to debug.c
Quoted 3 lines · Sujith Manoharan
From: Sujith Manoharan <[email protected]>
Signed-off-by Sujith Manoharan <[email protected]>
Thanks, applied with conflicts. Please check that I didn't break anything.
Signature · 1 line
Kalle Valo
PATCH 7/20 ath10k: Remove void pointers in HTC endpoints
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
--- drivers/net/wireless/ath/ath10k/htc.c | 13 ++++++------- drivers/net/wireless/ath/ath10k/htc.h | 9 ++++----- drivers/net/wireless/ath/ath10k/htt.c | 11 ++++------- drivers/net/wireless/ath/ath10k/htt.h | 4 ++-- drivers/net/wireless/ath/ath10k/htt_rx.c | 4 ++-- drivers/net/wireless/ath/ath10k/htt_tx.c | 4 ++-- drivers/net/wireless/ath/ath10k/wmi.c | 8 ++------ 7 files changed, 22 insertions(+), 31 deletions(-)
drivers/net/wireless/ath/ath10k/htc.c +6 -7
@@ -29,7 +29,7 @@ static inline void ath10k_htc_stop_queue(struct ath10k_htc_ep *ep)return ;if (ep->ep_ops.stop_queue) - ep->ep_ops.stop_queue (ep->ep_ops.context); + ep->ep_ops.stop_queue (ep->htc->ar);ath10k_dbg (ATH10K_DBG_HTC ,"ep %d stop\n" , ep->eid); ep->tx_queue_stopped = true;
@@ -41,7 +41,7 @@ static inline void ath10k_htc_wake_queue(struct ath10k_htc_ep *ep)return ;if (ep->ep_ops.wake_queue) - ep->ep_ops.wake_queue (ep->ep_ops.context); + ep->ep_ops.wake_queue (ep->htc->ar);ath10k_dbg (ATH10K_DBG_HTC ,"ep %d wake\n" , ep->eid); ep->tx_queue_stopped = false;
@@ -74,7 +74,7 @@ static inline void ath10k_htc_send_complete_check(struct ath10k_htc_ep *ep,ath10k_hif_send_complete_check (ep->htc->ar, ep->ul_pipe_id, force); } -static void ath10k_htc_control_tx_complete (void *context,struct sk_buff *skb) +static void ath10k_htc_control_tx_complete (struct ath10k *ar,struct sk_buff *skb) {kfree_skb (skb); }
@@ -121,7 +121,7 @@ static void ath10k_htc_notify_tx_completion(struct ath10k_htc_ep *ep,return ; } - ep->ep_ops.ep_tx_complete (ep->ep_ops.context, skb); + ep->ep_ops.ep_tx_complete (ep->htc->ar, skb); }/* assumes tx_lock is held */
@@ -606,7 +606,7 @@ static int ath10k_htc_rx_completion_handler(struct ath10k *ar,ath10k_dbg (ATH10K_DBG_HTC ,"htc rx completion ep %d skb %p\n" , eid, skb); - ep->ep_ops.ep_rx_complete (ep->ep_ops.context, skb); + ep->ep_ops.ep_rx_complete (ar, skb);/* skb is now owned by the rx completion handler */ skb =NULL ;
@@ -616,7 +616,7 @@ out:return status; } -static void ath10k_htc_control_rx_complete (void *context,struct sk_buff *skb) +static void ath10k_htc_control_rx_complete (struct ath10k *ar,struct sk_buff *skb) {/* TODO, can't receive HTC control messages yet */ ath10k_dbg (ATH10K_DBG_HTC ,"Invalid call to %s\n" , __func__);
@@ -740,7 +740,6 @@ int ath10k_htc_wait_target(struct ath10k_htc *htc)/* setup our pseudo HTC control endpoint connection */ memset (&conn_req,0 ,sizeof (conn_req));memset (&conn_resp,0 ,sizeof (conn_resp)); - conn_req.ep_ops.context = htc; conn_req.ep_ops.ep_tx_complete = ath10k_htc_control_tx_complete; conn_req.ep_ops.ep_rx_complete = ath10k_htc_control_rx_complete; conn_req.max_send_queue_depth =ATH10K_NUM_CONTROL_TX_BUFFERS ;
drivers/net/wireless/ath/ath10k/htc.h +4 -5
@@ -274,11 +274,10 @@ struct ath10k_htc_ops { };struct ath10k_htc_ep_ops { -void *context; -void (*ep_tx_complete)(void *context,struct sk_buff *); -void (*ep_rx_complete)(void *context,struct sk_buff *); -void (*stop_queue)(void *context); -void (*wake_queue)(void *context); +void (*ep_tx_complete)(struct ath10k *,struct sk_buff *); +void (*ep_rx_complete)(struct ath10k *,struct sk_buff *); +void (*stop_queue)(struct ath10k *); +void (*wake_queue)(struct ath10k *); };/* service connection information */
drivers/net/wireless/ath/ath10k/htt.c +4 -7
@@ -21,16 +21,14 @@#include "core.h" #include "debug.h" -static void ath10k_htt_stop_queue (void *context) +static void ath10k_htt_stop_queue (struct ath10k *ar) { -struct ath10k_htt *htt = context; -ieee80211_stop_queues (htt->ar->hw); +ieee80211_stop_queues (ar->hw); } -static void ath10k_htt_wake_queue (void *context) +static void ath10k_htt_wake_queue (struct ath10k *ar) { -struct ath10k_htt *htt = context; -ieee80211_wake_queues (htt->ar->hw); +ieee80211_wake_queues (ar->hw); }static int ath10k_htt_htc_attach (struct ath10k_htt *htt)
@@ -42,7 +40,6 @@ static int ath10k_htt_htc_attach(struct ath10k_htt *htt)memset (&conn_req,0 ,sizeof (conn_req));memset (&conn_resp,0 ,sizeof (conn_resp)); - conn_req.ep_ops.context = htt; conn_req.ep_ops.ep_tx_complete = ath10k_htt_htc_tx_complete; conn_req.ep_ops.ep_rx_complete = ath10k_htt_t2h_msg_handler; conn_req.ep_ops.stop_queue = ath10k_htt_stop_queue;
drivers/net/wireless/ath/ath10k/htt.h +2 -2
@@ -1265,8 +1265,8 @@ void ath10k_htt_tx_attach(struct ath10k_htt *htt);void ath10k_htt_tx_detach (struct ath10k_htt *htt);int ath10k_htt_rx_attach (struct ath10k_htt *htt);void ath10k_htt_rx_detach (struct ath10k_htt *htt); -void ath10k_htt_htc_tx_complete (void *context,struct sk_buff *skb); -void ath10k_htt_t2h_msg_handler (void *context,struct sk_buff *skb); +void ath10k_htt_htc_tx_complete (struct ath10k *ar,struct sk_buff *skb); +void ath10k_htt_t2h_msg_handler (struct ath10k *ar,struct sk_buff *skb);int ath10k_htt_h2t_ver_req_msg (struct ath10k_htt *htt);int ath10k_htt_send_rx_ring_cfg_ll (struct ath10k_htt *htt);
drivers/net/wireless/ath/ath10k/htt_rx.c +2 -2
@@ -981,9 +981,9 @@ end: } } -void ath10k_htt_t2h_msg_handler (void *context,struct sk_buff *skb) +void ath10k_htt_t2h_msg_handler (struct ath10k *ar,struct sk_buff *skb) { -struct ath10k_htt *htt = (struct ath10k_htt *)context; +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 +2 -2
@@ -86,10 +86,10 @@ void ath10k_htt_tx_detach(struct ath10k_htt *htt)return ; } -void ath10k_htt_htc_tx_complete (void *context,struct sk_buff *skb) +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 = (struct ath10k_htt *)context; +struct ath10k_htt *htt = ar->htt;if (skb_cb->htt.is_conf) {dev_kfree_skb_any (skb);
drivers/net/wireless/ath/ath10k/wmi.c +2 -6
@@ -73,10 +73,8 @@ static struct sk_buff *ath10k_wmi_alloc_skb(u32 len)return skb; } -static void ath10k_wmi_htc_tx_complete (void *context,struct sk_buff *skb) +static void ath10k_wmi_htc_tx_complete (struct ath10k *ar,struct sk_buff *skb) { -struct ath10k *ar = context; -dev_kfree_skb (skb);if (atomic_sub_return (1 , &ar->wmi.pending_tx_count) ==0 )
@@ -1048,9 +1046,8 @@ static void ath10k_wmi_event_work(struct work_struct *work) } } -static void ath10k_wmi_process_rx (void *ptr,struct sk_buff *skb) +static void ath10k_wmi_process_rx (struct ath10k *ar,struct sk_buff *skb) { -struct ath10k *ar = ptr;struct wmi_cmd_hdr *cmd_hdr = (struct wmi_cmd_hdr *)skb->data;enum wmi_event_id event_id;
@@ -1109,7 +1106,6 @@ int ath10k_wmi_connect_htc_service(struct ath10k *ar)memset (&conn_resp,0 ,sizeof (conn_resp));/* these fields are the same for all service endpoints */ - conn_req.ep_ops.context = ar; conn_req.ep_ops.ep_tx_complete = ath10k_wmi_htc_tx_complete; conn_req.ep_ops.ep_rx_complete = ath10k_wmi_process_rx;
Signature · 1 line
1.8.2.2
PATCH 8/20 ath10k: Use lockless SKB queue routines
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
The HTC TX queue is protected by "tx_lock".
--- drivers/net/wireless/ath/ath10k/htc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/wireless/ath/ath10k/htc.c +5 -5
@@ -209,7 +209,7 @@ static struct sk_buff *ath10k_htc_get_skb_credit_based(struct ath10k_htc *htc,int remainder;unsigned int transfer_len; - skb =skb_dequeue (&ep->tx_queue); + skb =__skb_dequeue (&ep->tx_queue);if (!skb)return NULL ;
@@ -240,7 +240,7 @@ static struct sk_buff *ath10k_htc_get_skb_credit_based(struct ath10k_htc *htc, credits_required =0 ; else {if (ep->tx_credits < credits_required) { -skb_queue_head (&ep->tx_queue, skb); +__skb_queue_head (&ep->tx_queue, skb);ath10k_htc_recalc_queue (ep,1 );return NULL ; }
@@ -268,7 +268,7 @@ static struct sk_buff *ath10k_htc_get_skb(struct ath10k_htc *htc,if (!resources)return NULL ; - skb =skb_dequeue (&ep->tx_queue); + skb =__skb_dequeue (&ep->tx_queue);if (!skb)return NULL ;
@@ -325,7 +325,7 @@ int ath10k_htc_send(struct ath10k_htc *htc,skb_push (skb,sizeof (struct ath10k_htc_hdr ));spin_lock_bh (&htc->tx_lock); -skb_queue_tail (&ep->tx_queue, skb); +__skb_queue_tail (&ep->tx_queue, skb);ath10k_htc_recalc_queue (ep,1 );spin_unlock_bh (&htc->tx_lock);
@@ -369,7 +369,7 @@ static void ath10k_htc_flush_endpoint_tx(struct ath10k_htc *htc,spin_lock_bh (&htc->tx_lock);for (;;) { - skb =skb_dequeue (&ep->tx_queue); + skb =__skb_dequeue (&ep->tx_queue);if (!skb)break ;
Signature · 1 line
1.8.2.2
PATCH 9/20 ath10k: Optimize HTC queue handling
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
Credit based flow control is enabled only for WMI service and WMI doesn't register any handlers for queue stop/wake, so there is no point in calling recalc_queue() for it.
--- drivers/net/wireless/ath/ath10k/htc.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/wireless/ath/ath10k/htc.c +0 -2
@@ -214,8 +214,6 @@ static struct sk_buff *ath10k_htc_get_skb_credit_based(struct ath10k_htc *htc,return NULL ; skb_cb =ATH10K_SKB_CB (skb); -ath10k_htc_recalc_queue (ep,-1 ); - transfer_len = skb->len;if (transfer_len <= htc->target_credit_size)
Signature · 1 line
1.8.2.2
PATCH 10/20 ath10k: Remove "credits_used" from SKB CB
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
--- drivers/net/wireless/ath/ath10k/core.h | 4 ---- drivers/net/wireless/ath/ath10k/htc.c | 26 ++++++++++++-------------- 2 files changed, 12 insertions(+), 18 deletions(-)
drivers/net/wireless/ath/ath10k/core.h +0 -4
@@ -65,10 +65,6 @@ struct ath10k_skb_cb {struct sk_buff *msdu; }__packed htt; -struct { -u8 credits_used; - } __packed htc; -/* 4 bytes left on 64bit arch */ } __packed;
drivers/net/wireless/ath/ath10k/htc.c +12 -14
@@ -161,7 +161,8 @@ static int ath10k_htc_prepare_tx_skb(struct ath10k_htc_ep *ep,static int ath10k_htc_issue_skb (struct ath10k_htc *htc,struct ath10k_htc_ep *ep, -struct sk_buff *skb) +struct sk_buff *skb, +u8 credits) {struct ath10k_skb_cb *skb_cb =ATH10K_SKB_CB (skb);int ret;
@@ -190,7 +191,7 @@ err:ath10k_warn ("HTC issue failed: %d\n" , ret);spin_lock_bh (&htc->tx_lock); - ep->tx_credits += skb_cb->htc.credits_used; + ep->tx_credits += credits;spin_unlock_bh (&htc->tx_lock); skb_cb->is_aborted = true;
@@ -201,7 +202,8 @@ err:/* assumes tx_lock is held */ static struct sk_buff *ath10k_htc_get_skb_credit_based (struct ath10k_htc *htc, -struct ath10k_htc_ep *ep) +struct ath10k_htc_ep *ep, +u8 *credits) {struct sk_buff *skb;struct ath10k_skb_cb *skb_cb;
@@ -234,9 +236,9 @@ static struct sk_buff *ath10k_htc_get_skb_credit_based(struct ath10k_htc *htc,* EP 0 is special, it always has a credit and does not require * credit based flow control. */ -if (ep->eid ==ATH10K_HTC_EP_0 ) +if (ep->eid ==ATH10K_HTC_EP_0 ) { credits_required =0 ; -else { + }else {if (ep->tx_credits < credits_required) {__skb_queue_head (&ep->tx_queue, skb);ath10k_htc_recalc_queue (ep,1 );
@@ -246,12 +248,7 @@ static struct sk_buff *ath10k_htc_get_skb_credit_based(struct ath10k_htc *htc, ep->tx_credits -= credits_required; } -/* shouldn't happen, but print a warning just in case */ -if (credits_required >=1 << (8 *sizeof (skb_cb->htc.credits_used))) -ath10k_warn ("credits_required value overflow (%d)\n" , - credits_required); - - skb_cb->htc.credits_used = credits_required; + *credits = credits_required;return skb; }
@@ -273,7 +270,6 @@ static struct sk_buff *ath10k_htc_get_skb(struct ath10k_htc *htc, skb_cb =ATH10K_SKB_CB (skb);ath10k_htc_recalc_queue (ep,-1 ); - skb_cb->htc.credits_used =0 ;return skb; }
@@ -284,6 +280,7 @@ static void ath10k_htc_send_work(struct work_struct *work)struct ath10k_htc *htc = ep->htc;struct sk_buff *skb;int tx_resources =0 ; +u8 credits =0 ;while (true) {if (!ep->tx_credit_flow_enabled)
@@ -296,7 +293,8 @@ static void ath10k_htc_send_work(struct work_struct *work)spin_lock_bh (&htc->tx_lock);if (ep->tx_credit_flow_enabled) - skb =ath10k_htc_get_skb_credit_based (htc, ep); + skb =ath10k_htc_get_skb_credit_based (htc, ep, + &credits);else skb =ath10k_htc_get_skb (htc, ep, tx_resources);
@@ -305,7 +303,7 @@ static void ath10k_htc_send_work(struct work_struct *work)if (!skb)break ;/* tx_queue empty or out of resources */ -ath10k_htc_issue_skb (htc, ep, skb); +ath10k_htc_issue_skb (htc, ep, skb, credits); } }
Signature · 1 line
1.8.2.2
PATCH 10/20 ath10k: Remove "credits_used" from SKB CB
Quoted 13 lines · Sujith Manoharan
From: Sujith Manoharan <[email protected]>
Signed-off-by Sujith Manoharan <[email protected]>--- drivers/net/wireless/ath/ath10k/core.h | 4 ---- drivers/net/wireless/ath/ath10k/htc.c | 26 ++++++++++++-------------- 2 files changed, 12 insertions(+), 18 deletions(-)drivers/net/wireless/ath/ath10k/core.h +0
-0
drivers/net/wireless/ath/ath10k/core.h struct ath10k_skb_cb { · line 68
Quoted 8 lines
drivers/net/wireless/ath/ath10k/core.h +0
-4@@ -65,10 +65,6 @@ struct ath10k_skb_cb {struct sk_buff *msdu; }__packed htt; -struct { -u8 credits_used; - } __packed htc; -/* 4 bytes left on 64bit arch */
The comment could be updated too to reflect there's more space in the ath10k_skb_cb now.
-- Pozdrawiam / Best regards, Michal Kazior.
PATCH 10/20 ath10k: Remove "credits_used" from SKB CB
Quoted 2 lines · Michal Kazior
The comment could be updated too to reflect there's more space in the
ath10k_skb_cbnow.
Sure, I'll do that in a followup patch.
Sujith
PATCH 11/20 ath10k: Disable credit flow control for EP0
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
As the comment says, EP0 doesn't require flow control, so disable it explicitly.
--- drivers/net/wireless/ath/ath10k/htc.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-)
drivers/net/wireless/ath/ath10k/htc.c +6 -14
@@ -232,22 +232,13 @@ static struct sk_buff *ath10k_htc_get_skb_credit_based(struct ath10k_htc *htc,ath10k_dbg (ATH10K_DBG_HTC ,"%s: creds required %d got %d\n" , __func__, credits_required, ep->tx_credits); -/* -* EP 0 is special, it always has a credit and does not require -* credit based flow control. -*/ -if (ep->eid ==ATH10K_HTC_EP_0 ) { - credits_required =0 ; - }else { -if (ep->tx_credits < credits_required) { -__skb_queue_head (&ep->tx_queue, skb); -ath10k_htc_recalc_queue (ep,1 ); -return NULL ; - } - - ep->tx_credits -= credits_required; +if (ep->tx_credits < credits_required) { +__skb_queue_head (&ep->tx_queue, skb); +ath10k_htc_recalc_queue (ep,1 ); +return NULL ; } + ep->tx_credits -= credits_required; *credits = credits_required;return skb; }
@@ -767,6 +758,7 @@ int ath10k_htc_connect_service(struct ath10k_htc *htc,/* special case for HTC pseudo control service */ if (conn_req->service_id ==ATH10K_HTC_SVC_ID_RSVD_CTRL ) { + disable_credit_flow_ctrl = true; assigned_eid =ATH10K_HTC_EP_0 ; max_msg_size =ATH10K_HTC_MAX_CTRL_MSG_LEN ;memset (&resp_msg_dummy,0 ,sizeof (resp_msg_dummy));
Signature · 1 line
1.8.2.2
PATCH 12/20 ath10k: Optimize credit allocation
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
The chances of a WMI command exceeding the target credit size is low, so use likely() and friends.
--- drivers/net/wireless/ath/ath10k/htc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath10k/htc.c +4 -4
@@ -218,9 +218,9 @@ static struct sk_buff *ath10k_htc_get_skb_credit_based(struct ath10k_htc *htc, skb_cb =ATH10K_SKB_CB (skb); transfer_len = skb->len; -if (transfer_len <= htc->target_credit_size) +if (likely (transfer_len <= htc->target_credit_size)) { credits_required =1 ; -else { + }else {/* figure out how many credits this message requires */ credits_required = transfer_len / htc->target_credit_size; remainder = transfer_len % htc->target_credit_size;
@@ -229,8 +229,8 @@ static struct sk_buff *ath10k_htc_get_skb_credit_based(struct ath10k_htc *htc, credits_required++; } -ath10k_dbg (ATH10K_DBG_HTC ,"%s: creds required %d got %d\n" , - __func__, credits_required, ep->tx_credits); +ath10k_dbg (ATH10K_DBG_HTC ,"Credits required %d got %d\n" , + credits_required, ep->tx_credits);if (ep->tx_credits < credits_required) {__skb_queue_head (&ep->tx_queue, skb);
Signature · 1 line
1.8.2.2
PATCH 13/20 ath10k: Remove unused variable in processing credit report
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
--- drivers/net/wireless/ath/ath10k/htc.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/net/wireless/ath/ath10k/htc.c +1 -8
@@ -379,9 +379,7 @@ static void ath10k_htc_process_credit_report(struct ath10k_htc *htc, enum ath10k_htc_ep_id eid) {struct ath10k_htc_ep *ep; -int total_credits =0 ; -int n_reports; -int i; +int i, n_reports;if (len %sizeof (*report))ath10k_warn ("Uneven credit report len %d" , len);
@@ -401,13 +399,8 @@ static void ath10k_htc_process_credit_report(struct ath10k_htc *htc,if (ep->tx_credits && !skb_queue_empty (&ep->tx_queue))queue_work (htc->ar->workqueue, &ep->send_work); - - total_credits += report->credits; }spin_unlock_bh (&htc->tx_lock); - -ath10k_dbg (ATH10K_DBG_HTC ,"report indicated %d credits total\n" , - total_credits); } static int ath10k_htc_process_trailer(struct ath10k_htc *htc,
Signature · 1 line
1.8.2.2
PATCH 14/20 ath10k: Print HTC service name
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
--- drivers/net/wireless/ath/ath10k/htc.c | 54 ++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 10 deletions(-)
drivers/net/wireless/ath/ath10k/htc.c +44 -10
@@ -606,6 +606,36 @@ static void ath10k_htc_control_rx_complete(struct ath10k *ar, struct sk_buff *sk/* Init/Deinit */ /***************/ +static const char *htc_service_name (enum ath10k_htc_svc_id id) +{ +switch (id) { +case ATH10K_HTC_SVC_ID_RESERVED : +return "Reserved" ; +case ATH10K_HTC_SVC_ID_RSVD_CTRL : +return "Control" ; +case ATH10K_HTC_SVC_ID_WMI_CONTROL : +return "WMI" ; +case ATH10K_HTC_SVC_ID_WMI_DATA_BE : +return "DATA BE" ; +case ATH10K_HTC_SVC_ID_WMI_DATA_BK : +return "DATA BK" ; +case ATH10K_HTC_SVC_ID_WMI_DATA_VI : +return "DATA VI" ; +case ATH10K_HTC_SVC_ID_WMI_DATA_VO : +return "DATA VO" ; +case ATH10K_HTC_SVC_ID_NMI_CONTROL : +return "NMI Control" ; +case ATH10K_HTC_SVC_ID_NMI_DATA : +return "NMI Data" ; +case ATH10K_HTC_SVC_ID_HTT_DATA_MSG : +return "HTT Data" ; +case ATH10K_HTC_SVC_ID_TEST_RAW_STREAMS : +return "RAW" ; + } + +return "Unknown" ; +} +static void ath10k_htc_reset_endpoint_states (struct ath10k_htc *htc) {struct ath10k_htc_ep *ep;
@@ -759,8 +789,8 @@ int ath10k_htc_connect_service(struct ath10k_htc *htc, tx_alloc =ath10k_htc_get_credit_allocation (htc, conn_req->service_id);if (!tx_alloc) -ath10k_warn ("Service 0x%x does not allocate target credits\n" , - conn_req->service_id); +ath10k_warn ("HTC Service %s does not allocate target credits\n" , +htc_service_name (conn_req->service_id)); skb =ath10k_htc_build_tx_ctrl_skb (htc->ar);if (!skb) {
@@ -818,15 +848,15 @@ int ath10k_htc_connect_service(struct ath10k_htc *htc, }ath10k_dbg (ATH10K_DBG_HTC , -"Service 0x%x connect response from target: status: 0x%x, assigned ep: 0x%x\n" , - service_id, resp_msg->status, resp_msg->eid); +"HTC Service %s connect response: status: 0x%x, assigned ep: 0x%x\n" , +htc_service_name (service_id), resp_msg->status, resp_msg->eid); conn_resp->connect_resp_code = resp_msg->status;/* check response status */ if (resp_msg->status !=ATH10K_HTC_CONN_SVC_STATUS_SUCCESS ) { -ath10k_err ("Service 0x%x connect request failed with status: 0x%x)\n" , - service_id, resp_msg->status); +ath10k_err ("HTC Service %s connect request failed: 0x%x)\n" , +htc_service_name (service_id), resp_msg->status);return -EPROTO ; }
@@ -875,15 +905,19 @@ int ath10k_htc_connect_service(struct ath10k_htc *htc,return status;ath10k_dbg (ATH10K_DBG_HTC , -"HTC service: 0x%x UL pipe: %d DL pipe: %d eid: %d ready\n" , - ep->service_id, ep->ul_pipe_id, +"HTC service: %s UL pipe: %d DL pipe: %d eid: %d ready\n" , +htc_service_name (ep->service_id), ep->ul_pipe_id, ep->dl_pipe_id, ep->eid); +ath10k_dbg (ATH10K_DBG_HTC , +"EP %d UL polled: %d, DL polled: %d\n" , + ep->eid, ep->ul_is_polled, ep->dl_is_polled); +if (disable_credit_flow_ctrl && ep->tx_credit_flow_enabled) { ep->tx_credit_flow_enabled = false;ath10k_dbg (ATH10K_DBG_HTC , -"HTC service: 0x%x eid: %d TX flow control disabled\n" , - ep->service_id, assigned_eid); +"HTC service: %s eid: %d TX flow control disabled\n" , +htc_service_name (ep->service_id), assigned_eid); }return status;
Signature · 1 line
1.8.2.2
PATCH 15/20 ath10k: Fix typo
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
--- drivers/net/wireless/ath/ath10k/ce.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath10k/ce.c +3 -3
@@ -244,8 +244,8 @@ static inline void ath10k_ce_copy_complete_intr_disable(struct ath10k *ar, host_ie_addr & ~HOST_IE_COPY_COMPLETE_MASK); } -static inline void ath10k_ce_watermark_intr_diable (struct ath10k *ar, -u32 ce_ctrl_addr) +static inline void ath10k_ce_watermark_intr_disable (struct ath10k *ar, +u32 ce_ctrl_addr) {u32 host_ie_addr =ath10k_pci_read32 (ar, ce_ctrl_addr +HOST_IE_ADDRESS );
@@ -845,7 +845,7 @@ static void ath10k_ce_per_engine_handler_adjust(struct ce_state *ce_state,else ath10k_ce_copy_complete_intr_disable (ar, ctrl_addr); -ath10k_ce_watermark_intr_diable (ar, ctrl_addr); +ath10k_ce_watermark_intr_disable (ar, ctrl_addr);ath10k_pci_sleep (ar); }
Signature · 1 line
1.8.2.2
PATCH 16/20 ath10k: Merge txrx.c with HTT
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
--- drivers/net/wireless/ath/ath10k/Makefile | 1 - drivers/net/wireless/ath/ath10k/htt.c | 129 +++++++++- drivers/net/wireless/ath/ath10k/htt.h | 16 ++ drivers/net/wireless/ath/ath10k/htt_rx.c | 174 ++++++++++++- drivers/net/wireless/ath/ath10k/htt_tx.c | 104 +++++++- drivers/net/wireless/ath/ath10k/mac.c | 1 - drivers/net/wireless/ath/ath10k/txrx.c | 415 ------------------------------- drivers/net/wireless/ath/ath10k/txrx.h | 39 --- 8 files changed, 419 insertions(+), 460 deletions(-) delete mode 100644 drivers/net/wireless/ath/ath10k/txrx.c delete mode 100644 drivers/net/wireless/ath/ath10k/txrx.h
drivers/net/wireless/ath/ath10k/Makefile +0 -1
@@ -6,7 +6,6 @@ ath10k_core-y += mac.o \ htt.o \ htt_rx.o \ htt_tx.o \ - txrx.o \ wmi.o \ bmi.o
drivers/net/wireless/ath/ath10k/htt.c +127 -2
141 lines not on this page · raw message
drivers/net/wireless/ath/ath10k/htt.h +16 -0
@@ -26,6 +26,7 @@#define HTT_CURRENT_VERSION_MAJOR 2#define HTT_CURRENT_VERSION_MINOR 1 +#define HTT_TARGET_VERSION_TIMEOUT_HZ (3*HZ)enum htt_dbg_stats_type {HTT_DBG_STATS_WAL_PDEV_TXRX =1 <<0 ,
@@ -1274,4 +1275,19 @@ int ath10k_htt_tx_alloc_msdu_id(struct ath10k_htt *htt);void ath10k_htt_tx_free_msdu_id (struct ath10k_htt *htt,u16 msdu_id);int ath10k_htt_mgmt_tx (struct ath10k_htt *htt,struct sk_buff *);int ath10k_htt_tx (struct ath10k_htt *htt,struct sk_buff *); + +void ath10k_txrx_tx_unref (struct ath10k_htt *htt,struct sk_buff *txdesc); +void ath10k_txrx_tx_completed (struct ath10k_htt *htt, +const struct htt_tx_done *tx_done); +struct ath10k_peer *ath10k_peer_find (struct ath10k *ar,int vdev_id, +const u8 *addr); +int ath10k_wait_for_peer_created (struct ath10k *ar,int vdev_id, +const u8 *addr); +int ath10k_wait_for_peer_deleted (struct ath10k *ar,int vdev_id, +const u8 *addr); +void ath10k_peer_map_event (struct ath10k_htt *htt, +struct htt_peer_map_event *ev); +void ath10k_peer_unmap_event (struct ath10k_htt *htt, +struct htt_peer_unmap_event *ev); +#endif
drivers/net/wireless/ath/ath10k/htt_rx.c +173 -1
186 lines not on this page · raw message
drivers/net/wireless/ath/ath10k/htt_tx.c +103 -1
116 lines not on this page · raw message
drivers/net/wireless/ath/ath10k/mac.c +0 -1
@@ -22,7 +22,6 @@#include "debug.h" #include "wmi.h" #include "htt.h" -#include "txrx.h" /**********/ /* Crypto */
drivers/net/wireless/ath/ath10k/txrx.c deleted +0 -415
415 lines not on this page · raw message
drivers/net/wireless/ath/ath10k/txrx.h deleted +0 -39
@@ -1,39 +0,0 @@ -/* -* Copyright (c) 2005-2011 Atheros Communications Inc. -* Copyright (c) 2011-2013 Qualcomm Atheros, Inc. -* -* Permission to use, copy, modify, and/or distribute this software for any -* purpose with or without fee is hereby granted, provided that the above -* copyright notice and this permission notice appear in all copies. -* -* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -#ifndef _TXRX_H -#define _TXRX_H - -#include "htt.h" - -void ath10k_txrx_tx_unref (struct ath10k_htt *htt,struct sk_buff *txdesc); -void ath10k_txrx_tx_completed (struct ath10k_htt *htt, -const struct htt_tx_done *tx_done); -void ath10k_process_rx (struct ath10k *ar,struct htt_rx_info *info); - -struct ath10k_peer *ath10k_peer_find (struct ath10k *ar,int vdev_id, -const u8 *addr); -int ath10k_wait_for_peer_created (struct ath10k *ar,int vdev_id, -const u8 *addr); -int ath10k_wait_for_peer_deleted (struct ath10k *ar,int vdev_id, -const u8 *addr); - -void ath10k_peer_map_event (struct ath10k_htt *htt, -struct htt_peer_map_event *ev); -void ath10k_peer_unmap_event (struct ath10k_htt *htt, -struct htt_peer_unmap_event *ev); - -#endif
Signature · 1 line
1.8.2.2
PATCH 17/20 ath10k: Use IS_ALIGNED macro to check alignment
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
--- drivers/net/wireless/ath/ath10k/htc.c | 4 +++- drivers/net/wireless/ath/ath10k/htt_rx.c | 2 +- drivers/net/wireless/ath/ath10k/htt_tx.c | 4 ++-- drivers/net/wireless/ath/ath10k/pci.c | 3 ++- drivers/net/wireless/ath/ath10k/wmi.c | 3 ++- 5 files changed, 10 insertions(+), 6 deletions(-)
drivers/net/wireless/ath/ath10k/htc.c +3 -1
@@ -936,7 +936,9 @@ struct sk_buff *ath10k_htc_alloc_skb(int size)skb_reserve (skb,sizeof (struct ath10k_htc_hdr ));/* FW/HTC requires 4-byte aligned streams */ -WARN_ONCE ((unsigned long )skb->data &0x3 ,"unaligned skb" ); +if (!IS_ALIGNED ((unsigned long )skb->data,4 )) +ath10k_warn ("Unaligned HTC tx skb\n" ); +return skb; }
drivers/net/wireless/ath/ath10k/htt_rx.c +1 -1
@@ -1159,7 +1159,7 @@ void ath10k_htt_t2h_msg_handler(struct ath10k *ar, struct sk_buff *skb)struct htt_resp *resp = (struct htt_resp *)skb->data;/* confirm alignment */ -if ((((unsigned long )skb->data) &0x3 ) !=0 ) +if (!IS_ALIGNED ((unsigned long )skb->data,4 ))ath10k_warn ("unaligned htt message, expect trouble\n" ); ath10k_dbg(ATH10K_DBG_HTT, "HTT RX, msg_type: 0x%0X\n",
drivers/net/wireless/ath/ath10k/htt_tx.c +2 -2
@@ -153,7 +153,7 @@ int ath10k_htt_send_rx_ring_cfg_ll(struct ath10k_htt *htt)* the HW expects the buffer to be an integral number of 4-byte * "words" */ -BUILD_BUG_ON ((HTT_RX_BUF_SIZE &0x3 ) !=0 ); +BUILD_BUG_ON (!IS_ALIGNED (HTT_RX_BUF_SIZE ,4 ));BUILD_BUG_ON ((HTT_RX_BUF_SIZE &HTT_MAX_CACHE_LINE_SIZE_MASK ) !=0 ); len =sizeof (cmd->hdr) +sizeof (cmd->rx_setup.hdr)
@@ -435,7 +435,7 @@ int ath10k_htt_tx(struct ath10k_htt *htt, struct sk_buff *msdu) goto err; } -if ((unsigned long )txdesc->data &0x3 ) { +if (!IS_ALIGNED ((unsigned long )txdesc->data,4 )) {ath10k_warn ("htt alignment check failed. dropping packet.\n" ); res = -EIO ; goto err;
drivers/net/wireless/ath/ath10k/pci.c +2 -1
@@ -120,7 +120,8 @@ static int ath10k_pci_diag_read_mem(struct ath10k *ar, u32 address, void *data,* this fn */ if (address < DRAM_BASE_ADDRESS) { - if ((address & 0x3) || ((dma_addr_t)data & 0x3)) + if (!IS_ALIGNED(address, 4) || + !IS_ALIGNED((unsigned long)data, 4)) return -EIO; while ((nbytes >= 4) && ((ret = ath10k_pci_diag_read_access(
drivers/net/wireless/ath/ath10k/wmi.c +2 -1
@@ -65,7 +65,8 @@ static struct sk_buff *ath10k_wmi_alloc_skb(u32 len)return NULL ;skb_reserve (skb,WMI_SKB_HEADROOM ); -WARN_ONCE ((unsigned long )skb->data &0x3 ,"unaligned skb" ); +if (!IS_ALIGNED ((unsigned long )skb->data,4 )) +ath10k_warn ("Unaligned WMI skb\n" );skb_put (skb, round_len);memset (skb->data,0 , round_len);
Signature · 1 line
1.8.2.2
PATCH 18/20 ath10k: Move htt_rx_ind_get_mpdu_ranges to htt_rx.c
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
--- drivers/net/wireless/ath/ath10k/htt.h | 12 ------------ drivers/net/wireless/ath/ath10k/htt_rx.c | 12 ++++++++++++ 2 files changed, 12 insertions(+), 12 deletions(-)
drivers/net/wireless/ath/ath10k/htt.h +0 -12
@@ -478,18 +478,6 @@ struct htt_rx_indication {struct htt_rx_indication_mpdu_range mpdu_ranges[0 ]; } __packed; -static inline struct htt_rx_indication_mpdu_range * -htt_rx_ind_get_mpdu_ranges (struct htt_rx_indication *rx_ind) -{ -void *ptr = rx_ind; - - ptr +=sizeof (rx_ind->hdr) - +sizeof (rx_ind->ppdu) - +sizeof (rx_ind->prefix) - +roundup (__le16_to_cpu (rx_ind->prefix.fw_rx_desc_bytes),4 ); -return ptr; -} -enum htt_rx_flush_mpdu_status {HTT_RX_FLUSH_MPDU_DISCARD =0 ,HTT_RX_FLUSH_MPDU_REORDER =1 ,
drivers/net/wireless/ath/ath10k/htt_rx.c +12 -0
@@ -929,6 +929,18 @@ static bool ath10k_htt_rx_has_fcs_err(struct sk_buff *skb)return false; } +static inline struct htt_rx_indication_mpdu_range * +htt_rx_ind_get_mpdu_ranges (struct htt_rx_indication *rx_ind) +{ +void *ptr = rx_ind; + + ptr +=sizeof (rx_ind->hdr) + +sizeof (rx_ind->ppdu) + +sizeof (rx_ind->prefix) + +roundup (__le16_to_cpu (rx_ind->prefix.fw_rx_desc_bytes),4 ); +return ptr; +} +static void ath10k_htt_rx_handler (struct ath10k_htt *htt,struct htt_rx_indication *rx) {
Signature · 1 line
1.8.2.2
PATCH 18/20 ath10k: Move htt_rx_ind_get_mpdu_ranges to htt_rx.c
Quoted 18 lines · Sujith Manoharan
From: Sujith Manoharan <[email protected]>
Signed-off-by Sujith Manoharan <[email protected]>--- drivers/net/wireless/ath/ath10k/htt.h | 12 ------------ drivers/net/wireless/ath/ath10k/htt_rx.c | 12 ++++++++++++ 2 files changed, 12 insertions(+), 12 deletions(-)drivers/net/wireless/ath/ath10k/htt.h +0
-2@@ -478,18 +478,6 @@ struct htt_rx_indication {struct htt_rx_indication_mpdu_range mpdu_ranges[0 ]; } __packed; -static inline struct htt_rx_indication_mpdu_range * -htt_rx_ind_get_mpdu_ranges (struct htt_rx_indication *rx_ind)
drivers/net/wireless/ath/ath10k/htt.h struct htt_rx_indication { · line 492
Quoted 10 lines
drivers/net/wireless/ath/ath10k/htt.h +0
-10-{ -void *ptr = rx_ind; - - ptr +=sizeof (rx_ind->hdr) - +sizeof (rx_ind->ppdu) - +sizeof (rx_ind->prefix) - +roundup (__le16_to_cpu (rx_ind->prefix.fw_rx_desc_bytes),4 ); -return ptr; -} -
I'm not really convinced with this. The idea is the function defines how to access the variadic structure member position so it should stay close to the structure definition. This could as well be a #define but an inline function looks cleaner IMHO.
-- Pozdrawiam / Best regards, Michal Kazior.
PATCH 18/20 ath10k: Move htt_rx_ind_get_mpdu_ranges to htt_rx.c
Quoted 4 lines · Michal Kazior
I'm not really convinced with this. The idea is the function defines how to access the variadic structure member position so it should stay close to the structure definition. This could as well be a #define but an inline function looks cleaner IMHO.
Alright, we can keep it there. Kalle, please drop this patch.
Sujith
PATCH 19/20 ath10k: Simplify excessively nested HTT structure layout
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
There are various sructures inside HTT/RX_RING that contain very few elements. Simplify these.
--- drivers/net/wireless/ath/ath10k/htt.c | 2 +- drivers/net/wireless/ath/ath10k/htt.h | 48 +++++++++++++------------------- drivers/net/wireless/ath/ath10k/htt_rx.c | 37 ++++++++++++------------ 3 files changed, 40 insertions(+), 47 deletions(-)
drivers/net/wireless/ath/ath10k/htt.c +1 -1
@@ -200,7 +200,7 @@ struct ath10k_htt *ath10k_htt_attach(struct ath10k *ar)return NULL ; htt->ar = ar; - htt->cfg.max_throughput_mbps =800 ; + htt->max_throughput_mbps =800 ;/* * Connect to HTC service.
drivers/net/wireless/ath/ath10k/htt.h +20 -28
69 lines not on this page · raw message
drivers/net/wireless/ath/ath10k/htt_rx.c +19 -18
@@ -237,7 +237,7 @@ static int ath10k_htt_rx_ring_size(struct ath10k_htt *htt)/* 1e6 bps/mbps / 1e3 ms per sec = 1000 */ size = - htt->cfg.max_throughput_mbps + + htt->max_throughput_mbps +1000 / (8 *HTT_RX_AVG_FRM_BYTES ) *HTT_RX_HOST_LATENCY_MAX_MS ;
@@ -258,7 +258,7 @@ static int ath10k_htt_rx_ring_fill_level(struct ath10k_htt *htt)/* 1e6 bps/mbps / 1e3 ms per sec = 1000 */ size = - htt->cfg.max_throughput_mbps * + htt->max_throughput_mbps *1000 / (8 *HTT_RX_AVG_FRM_BYTES ) *HTT_RX_HOST_LATENCY_WORST_LIKELY_MS ;
@@ -316,8 +316,8 @@ static void ath10k_htt_rx_ring_fill_n(struct ath10k_htt *htt, int num) }ATH10K_SKB_CB (skb)->paddr = paddr; - htt->rx_ring.buf.netbufs_ring[idx] = skb; - htt->rx_ring.buf.paddrs_ring[idx] =__cpu_to_le32 (paddr); + htt->rx_ring.netbufs_ring[idx] = skb; + htt->rx_ring.paddrs_ring[idx] =__cpu_to_le32 (paddr); htt->rx_ring.fill_cnt++; num--;
@@ -360,21 +360,21 @@ void ath10k_htt_rx_detach(struct ath10k_htt *htt)while (sw_rd_idx !=__le32_to_cpu (*(htt->rx_ring.alloc_idx.vaddr))) {struct sk_buff *skb = - htt->rx_ring.buf.netbufs_ring[sw_rd_idx]; + htt->rx_ring.netbufs_ring[sw_rd_idx];struct ath10k_skb_cb *cb =ATH10K_SKB_CB (skb);dma_unmap_single (htt->ar->dev, cb->paddr, skb->len +skb_tailroom (skb),DMA_FROM_DEVICE ); -dev_kfree_skb_any (htt->rx_ring.buf.netbufs_ring[sw_rd_idx]); +dev_kfree_skb_any (htt->rx_ring.netbufs_ring[sw_rd_idx]); sw_rd_idx++; sw_rd_idx &= htt->rx_ring.size_mask; }dma_free_coherent (htt->ar->dev, (htt->rx_ring.size * -sizeof (htt->rx_ring.buf.paddrs_ring)), - htt->rx_ring.buf.paddrs_ring, +sizeof (htt->rx_ring.paddrs_ring)), + htt->rx_ring.paddrs_ring, htt->rx_ring.base_paddr); dma_free_coherent(htt->ar->dev,
@@ -382,7 +382,7 @@ void ath10k_htt_rx_detach(struct ath10k_htt *htt) htt->rx_ring.alloc_idx.vaddr, htt->rx_ring.alloc_idx.paddr); -kfree (htt->rx_ring.buf.netbufs_ring); +kfree (htt->rx_ring.netbufs_ring); }static inline struct sk_buff *ath10k_htt_rx_netbuf_pop (struct ath10k_htt *htt)
@@ -396,7 +396,7 @@ static inline struct sk_buff *ath10k_htt_rx_netbuf_pop(struct ath10k_htt *htt)ath10k_warn ("htt rx ring is empty!\n" ); idx = htt->rx_ring.sw_rd_idx.msdu_payld; - msdu = htt->rx_ring.buf.netbufs_ring[idx]; + msdu = htt->rx_ring.netbufs_ring[idx]; idx++; idx &= htt->rx_ring.size_mask;
@@ -611,19 +611,19 @@ int ath10k_htt_rx_attach(struct ath10k_htt *htt)*/ htt->rx_ring.fill_level =ath10k_htt_rx_ring_fill_level (htt); - htt->rx_ring.buf.netbufs_ring = + htt->rx_ring.netbufs_ring =kmalloc (htt->rx_ring.size *sizeof (struct sk_buff *),GFP_KERNEL ); -if (!htt->rx_ring.buf.netbufs_ring) +if (!htt->rx_ring.netbufs_ring) goto fail1; vaddr =dma_alloc_coherent (htt->ar->dev, - (htt->rx_ring.size *sizeof (htt->rx_ring.buf.paddrs_ring)), + (htt->rx_ring.size *sizeof (htt->rx_ring.paddrs_ring)), &paddr,GFP_DMA );if (!vaddr) goto fail2; - htt->rx_ring.buf.paddrs_ring = vaddr; + htt->rx_ring.paddrs_ring = vaddr; htt->rx_ring.base_paddr = paddr; vaddr = dma_alloc_coherent(htt->ar->dev,
@@ -646,16 +646,17 @@ int ath10k_htt_rx_attach(struct ath10k_htt *htt)ath10k_htt_rx_ring_fill_n (htt, htt->rx_ring.fill_level);spin_unlock_bh (&htt->rx_ring.lock); +ath10k_dbg (ATH10K_DBG_HTT ,"HTT RX ring size: %d, fill_level: %d\n" , + htt->rx_ring.size, htt->rx_ring.fill_level);return 0 ; - fail3:dma_free_coherent (htt->ar->dev, (htt->rx_ring.size * -sizeof (htt->rx_ring.buf.paddrs_ring)), - htt->rx_ring.buf.paddrs_ring, +sizeof (htt->rx_ring.paddrs_ring)), + htt->rx_ring.paddrs_ring, htt->rx_ring.base_paddr); fail2: -kfree (htt->rx_ring.buf.netbufs_ring); +kfree (htt->rx_ring.netbufs_ring); fail1:return -ENOMEM ; }
Signature · 1 line
1.8.2.2
PATCH 20/20 ath10k: Remove unneeded locks during HTT RX attach
In reply to Sujith ManoharanFrom: Sujith Manoharan <[email protected]>
We can dispense with the lockdep assert since the refill timer just calls the replenish routine which is held under the ring lock.
--- drivers/net/wireless/ath/ath10k/htt_rx.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath10k/htt_rx.c +2 -4
@@ -273,6 +273,7 @@ static int ath10k_htt_rx_ring_fill_level(struct ath10k_htt *htt)return size; } +/* RX ring lock must be held. */ static void ath10k_htt_rx_ring_fill_n (struct ath10k_htt *htt,int num) {struct htt_rx_desc *rx_desc;
@@ -280,8 +281,6 @@ static void ath10k_htt_rx_ring_fill_n(struct ath10k_htt *htt, int num)dma_addr_t paddr;int idx; -lockdep_assert_held (&htt->rx_ring.lock); - idx =__le32_to_cpu (*(htt->rx_ring.alloc_idx.vaddr));while (num >0 ) { skb =dev_alloc_skb (HTT_RX_BUF_SIZE +HTT_RX_DESC_ALIGN );
@@ -641,10 +640,9 @@ int ath10k_htt_rx_attach(struct ath10k_htt *htt)setup_timer (timer, ath10k_htt_rx_ring_refill_retry, (unsigned long )htt);spin_lock_init (&htt->rx_ring.lock); -spin_lock_bh (&htt->rx_ring.lock); + htt->rx_ring.fill_cnt =0 ;ath10k_htt_rx_ring_fill_n (htt, htt->rx_ring.fill_level); -spin_unlock_bh (&htt->rx_ring.lock);ath10k_dbg (ATH10K_DBG_HTT ,"HTT RX ring size: %d, fill_level: %d\n" , htt->rx_ring.size, htt->rx_ring.fill_level);
Signature · 1 line
1.8.2.2
PATCH 20/20 ath10k: Remove unneeded locks during HTT RX attach
Quoted 5 lines · Sujith Manoharan
From: Sujith Manoharan <[email protected]>
We can dispense with the lockdep assert since the refill timer just calls the replenish routine which is held under the ring lock.
Doesn't sound good to me.
The lockdep is there for a reason. This explicitly states the function must be under the htt rx lock and makes sure this is verified. This should not be removed.
If (which can be arguably near impossible) the initial ath10k_htt_rx_ring_fill_n() in htt rx attach fires of a timer and we get a crazy pre-emption between mod_timer() and goto we will corrupt the htt rx ring state without the lock here.
-- Pozdrawiam / Best regards, Michal Kazior.
PATCH 20/20 ath10k: Remove unneeded locks during HTT RX attach
Quoted 10 lines · Michal Kazior
Doesn't sound good to me.
The lockdep is there for a reason. This explicitly states the function must be under the htt rx lock and makes sure this is verified. This should not be removed.
If (which can be arguably near impossible) the initial
ath10k_htt_rx_ring_fill_n()in htt rx attach fires of a timer and we get a crazy pre-emption betweenmod_timer()and goto we will corrupt the htt rx ring state without the lock here.
If the system is so memory-starved that basic allocation during driver bring-up fails, we should just bail out gracefully and not jump through hoops, hoping that things might improve.
If this is done, the locks in attach() can be removed and the lockdep_assert() can stay. But yes, I missed this subtle race condition so this patch can't go in as is.
When the driver is operational, the simplest thing to do when RX overrun happens, is to drop incoming packets until the situation eases (drivers like ath9k do this, by re-using pre-allocated buffers). ath10k uses up the RX ring instead, until the driver effectively stalls. I am not sure which model is better.
Sujith
PATCH 20/20 ath10k: Remove unneeded locks during HTT RX attach
Quoted 3 lines · Sujith Manoharan
If the system is so memory-starved that basic allocation during driver bring-up fails, we should just bail out gracefully and not jump through hoops, hoping that things might improve.
...and it doesn't seem correct to proceed with init after htt_rx_attach() has failed due to memory allocation, since subsequent allocations would probably fail too.
Sujith
PATCH 20/20 ath10k: Remove unneeded locks during HTT RX attach
Quoted 3 lines · Sujith Manoharan
...and it doesn't seem correct to proceed with init after
htt_rx_attach()has failed due to memory allocation, since subsequent allocations would probably fail too.
How about something like this ?
[PATCH] ath10k: Remove unneeded locks during HTT RX attach
If buffer allocation fails during attach(), bail out properly so the replenish timer doesn't get fired.
--- drivers/net/wireless/ath/ath10k/htt_rx.c | 54 +++++++++++++++++++------------- 1 file changed, 32 insertions(+), 22 deletions(-)
drivers/net/wireless/ath/ath10k/htt_rx.c +32 -22
@@ -273,12 +273,12 @@ static int ath10k_htt_rx_ring_fill_level(struct ath10k_htt *htt)return size; } -static void ath10k_htt_rx_ring_fill_n (struct ath10k_htt *htt,int num) +static int ath10k_htt_rx_ring_fill_n (struct ath10k_htt *htt,int num) {struct htt_rx_desc *rx_desc;struct sk_buff *skb;dma_addr_t paddr; -int idx; +int ret =0 , idx;lockdep_assert_held (&htt->rx_ring.lock);
@@ -286,14 +286,7 @@ static void ath10k_htt_rx_ring_fill_n(struct ath10k_htt *htt, int num)while (num >0 ) { skb =dev_alloc_skb (HTT_RX_BUF_SIZE +HTT_RX_DESC_ALIGN );if (!skb) { -/* -* Failed to fill it to the desired level - -* we'll start a timer and try again next time. -* As long as enough buffers are left in the ring for -* another A-MPDU rx, no special recovery is needed. -*/ -mod_timer (&htt->rx_ring.refill_retry_timer, jiffies + -msecs_to_jiffies (HTT_RX_RING_REFILL_RETRY_MS )); + ret = -ENOMEM ; goto fail; }
@@ -312,6 +305,7 @@ static void ath10k_htt_rx_ring_fill_n(struct ath10k_htt *htt, int num)if (unlikely (dma_mapping_error (htt->ar->dev, paddr))) {dev_kfree_skb_any (skb); + ret = -ENOMEM ; goto fail; }
@@ -327,16 +321,26 @@ static void ath10k_htt_rx_ring_fill_n(struct ath10k_htt *htt, int num) fail: *(htt->rx_ring.alloc_idx.vaddr) =__cpu_to_le32 (idx); -return ; +return ret; }static void ath10k_htt_rx_msdu_buff_replenish (struct ath10k_htt *htt) { -int num_to_fill; +int ret, num_to_fill;spin_lock_bh (&htt->rx_ring.lock); num_to_fill = htt->rx_ring.fill_level - htt->rx_ring.fill_cnt; -ath10k_htt_rx_ring_fill_n (htt, num_to_fill); + ret =ath10k_htt_rx_ring_fill_n (htt, num_to_fill); +if (ret == -ENOMEM ) { +/* +* Failed to fill it to the desired level - +* we'll start a timer and try again next time. +* As long as enough buffers are left in the ring for +* another A-MPDU rx, no special recovery is needed. +*/ +mod_timer (&htt->rx_ring.refill_retry_timer, jiffies + +msecs_to_jiffies (HTT_RX_RING_REFILL_RETRY_MS )); + }spin_unlock_bh (&htt->rx_ring.lock); }
@@ -615,13 +619,13 @@ int ath10k_htt_rx_attach(struct ath10k_htt *htt)kmalloc (htt->rx_ring.size *sizeof (struct sk_buff *),GFP_KERNEL );if (!htt->rx_ring.netbufs_ring) - goto fail1; + goto err_netbuf; vaddr =dma_alloc_coherent (htt->ar->dev, (htt->rx_ring.size *sizeof (htt->rx_ring.paddrs_ring)), &paddr,GFP_DMA );if (!vaddr) - goto fail2; + goto err_dma_ring; htt->rx_ring.paddrs_ring = vaddr; htt->rx_ring.base_paddr = paddr;
@@ -630,7 +634,7 @@ int ath10k_htt_rx_attach(struct ath10k_htt *htt)sizeof (*htt->rx_ring.alloc_idx.vaddr), &paddr, GFP_DMA);if (!vaddr) - goto fail3; + goto err_dma_idx; htt->rx_ring.alloc_idx.vaddr = vaddr; htt->rx_ring.alloc_idx.paddr = paddr;
@@ -641,23 +645,29 @@ int ath10k_htt_rx_attach(struct ath10k_htt *htt)setup_timer (timer, ath10k_htt_rx_ring_refill_retry, (unsigned long )htt);spin_lock_init (&htt->rx_ring.lock); -spin_lock_bh (&htt->rx_ring.lock); + htt->rx_ring.fill_cnt =0 ; -ath10k_htt_rx_ring_fill_n (htt, htt->rx_ring.fill_level); -spin_unlock_bh (&htt->rx_ring.lock); +if (ath10k_htt_rx_ring_fill_n (htt, htt->rx_ring.fill_level)) + goto err_fill_ring;ath10k_dbg (ATH10K_DBG_HTT ,"HTT RX ring size: %d, fill_level: %d\n" , htt->rx_ring.size, htt->rx_ring.fill_level);return 0 ; -fail3: + +err_fill_ring: +dma_free_coherent (htt->ar->dev, +sizeof (*htt->rx_ring.alloc_idx.vaddr), + htt->rx_ring.alloc_idx.vaddr, + htt->rx_ring.alloc_idx.paddr); +err_dma_idx:dma_free_coherent (htt->ar->dev, (htt->rx_ring.size *sizeof (htt->rx_ring.paddrs_ring)), htt->rx_ring.paddrs_ring, htt->rx_ring.base_paddr); -fail2: +err_dma_ring:kfree (htt->rx_ring.netbufs_ring); -fail1: +err_netbuf:return -ENOMEM ; }
Signature · 1 line
1.8.2.2
PATCH 20/20 ath10k: Remove unneeded locks during HTT RX attach
Quoted 16 lines · Sujith Manoharan
Quoted 3 lines · Sujith Manoharan
...and it doesn't seem correct to proceed with init after
htt_rx_attach()has failed due to memory allocation, since subsequent allocations would probably fail too.How about something like this ?
[PATCH] ath10k: Remove unneeded locks during HTT RX attach
If buffer allocation fails during
attach(), bail out properly so the replenish timer doesn't get fired.Signed-off-by Sujith Manoharan <[email protected]>---
(...)
drivers/net/wireless/ath/ath10k/htt_rx.c int ath10k_htt_rx_attach(struct ath10k_htt *htt) · line 651
Quoted 10 lines
drivers/net/wireless/ath/ath10k/htt_rx.c +3
-3@@ -641,23 +645,29 @@ int ath10k_htt_rx_attach(struct ath10k_htt *htt)setup_timer (timer, ath10k_htt_rx_ring_refill_retry, (unsigned long )htt);spin_lock_init (&htt->rx_ring.lock); -spin_lock_bh (&htt->rx_ring.lock); + htt->rx_ring.fill_cnt =0 ; -ath10k_htt_rx_ring_fill_n (htt, htt->rx_ring.fill_level); -spin_unlock_bh (&htt->rx_ring.lock); +if (ath10k_htt_rx_ring_fill_n (htt, htt->rx_ring.fill_level)) + goto err_fill_ring;
Won't this still fail the lockdep assertion?
We're also leaking memory upon failure. We need to free up the skbuffs we successfully allocated & mapped.
If you want to check if the ath10k_htt_rx_ring_fill_n() failed you could simply compare fill_level and fill_cnt while (still) holding the spinlock:
spin_lock_bh(&htt->rx_ring.lock);
htt->rx_ring.fill_cnt = 0;
ath10k_htt_rx_ring_fill_n(htt, htt->rx_ring.fill_level);
if (htt->rx_ring.fill_cnt != htt->rx_ring.fill_level) {
// handle failure
}
spin_unlock_bh(&htt->rx_ring.lock);I'm not even sure if we should abort right away. We replenish htt rx buffers using GFP_ATOMIC allocation. This can fail under memory pressure more often (then, say, GFP_KERNEL). I wouldn't really consider this as fatal error. Although we could probably have a ath10k_warn/info if the initial allocation doesn't fill everything up. Perhaps we could fail only if the fill_cnt is still 0, or below a defined threshold?
We could also try and split the replenishing functions and use GFP_KERNEL allocation during htt rx attach.
-- Pozdrawiam / Best regards, Michal Kazior.
PATCH 20/20 ath10k: Remove unneeded locks during HTT RX attach
Quoted 23 lines · Michal Kazior
Won't this still fail the lockdep assertion?
We're also leaking memory upon failure. We need to free up the skbuffs we successfully allocated & mapped.
If you want to check if the
ath10k_htt_rx_ring_fill_n()failed you could simply comparefill_levelandfill_cntwhile (still) holding the spinlock:spin_lock_bh(&htt->rx_ring.lock); htt->rx_ring.fill_cnt = 0; ath10k_htt_rx_ring_fill_n(htt, htt->rx_ring.fill_level); if (htt->rx_ring.fill_cnt != htt->rx_ring.fill_level) { // handle failure } spin_unlock_bh(&htt->rx_ring.lock);I'm not even sure if we should abort right away. We replenish htt rx buffers using
GFP_ATOMICallocation. This can fail under memory pressure more often (then, say,GFP_KERNEL). I wouldn't really consider this as fatal error. Although we could probably have a ath10k_warn/info if the initial allocation doesn't fill everything up. Perhaps we could fail only if thefill_cntis still 0, or below a defined threshold?
Quoted 2 lines
We could also try and split the replenishing functions and use
GFP_KERNELallocation during htt rx attach.
We do a bunch of allocations using GFP_ATOMIC after htt_attach(). Proceeding with initialization at this point seems wrong and programming the FW with RX ring configuration via HTT_H2T_MSG_TYPE_RX_RING_CFG even though host setup failed is probably incorrect ?
IMHO, the simplest fix is to just die happily when the system is hosed at load-time.
An updated patch:
[PATCH] ath10k: Remove unneeded locks during HTT RX attach
Fix two issues:
* Bail out properly when RX buffer allocation fails at init time.
* Do not acquire the rx ring lock during attach() since we don't rearm the replenish timer.
--- drivers/net/wireless/ath/ath10k/htt_rx.c | 81 ++++++++++++++++++++++---------- 1 file changed, 57 insertions(+), 24 deletions(-)
drivers/net/wireless/ath/ath10k/htt_rx.c +57 -24
@@ -273,27 +273,36 @@ static int ath10k_htt_rx_ring_fill_level(struct ath10k_htt *htt)return size; } -static void ath10k_htt_rx_ring_fill_n (struct ath10k_htt *htt,int num) +static void ath10k_htt_rx_ring_free (struct ath10k_htt *htt) +{ +struct sk_buff *skb; +struct ath10k_skb_cb *cb; +int i; + +for (i =0 ; i < htt->rx_ring.fill_cnt; i++) { + skb = htt->rx_ring.netbufs_ring[i]; + cb =ATH10K_SKB_CB (skb); +dma_unmap_single (htt->ar->dev, cb->paddr, + skb->len +skb_tailroom (skb), +DMA_FROM_DEVICE ); +dev_kfree_skb_any (skb); + } + + htt->rx_ring.fill_cnt =0 ; +} + +static int __ath10k_htt_rx_ring_fill_n (struct ath10k_htt *htt,int num) {struct htt_rx_desc *rx_desc;struct sk_buff *skb;dma_addr_t paddr; -int idx; - -lockdep_assert_held (&htt->rx_ring.lock); +int ret =0 , idx; idx =__le32_to_cpu (*(htt->rx_ring.alloc_idx.vaddr));while (num >0 ) { skb =dev_alloc_skb (HTT_RX_BUF_SIZE +HTT_RX_DESC_ALIGN );if (!skb) { -/* -* Failed to fill it to the desired level - -* we'll start a timer and try again next time. -* As long as enough buffers are left in the ring for -* another A-MPDU rx, no special recovery is needed. -*/ -mod_timer (&htt->rx_ring.refill_retry_timer, jiffies + -msecs_to_jiffies (HTT_RX_RING_REFILL_RETRY_MS )); + ret = -ENOMEM ; goto fail; }
@@ -312,6 +321,7 @@ static void ath10k_htt_rx_ring_fill_n(struct ath10k_htt *htt, int num)if (unlikely (dma_mapping_error (htt->ar->dev, paddr))) {dev_kfree_skb_any (skb); + ret = -ENOMEM ; goto fail; }
@@ -327,16 +337,32 @@ static void ath10k_htt_rx_ring_fill_n(struct ath10k_htt *htt, int num) fail: *(htt->rx_ring.alloc_idx.vaddr) =__cpu_to_le32 (idx); -return ; +return ret; +} + +static int ath10k_htt_rx_ring_fill_n (struct ath10k_htt *htt,int num) +{ +lockdep_assert_held (&htt->rx_ring.lock); +return __ath10k_htt_rx_ring_fill_n (htt, num); }static void ath10k_htt_rx_msdu_buff_replenish (struct ath10k_htt *htt) { -int num_to_fill; +int ret, num_to_fill;spin_lock_bh (&htt->rx_ring.lock); num_to_fill = htt->rx_ring.fill_level - htt->rx_ring.fill_cnt; -ath10k_htt_rx_ring_fill_n (htt, num_to_fill); + ret =ath10k_htt_rx_ring_fill_n (htt, num_to_fill); +if (ret == -ENOMEM ) { +/* +* Failed to fill it to the desired level - +* we'll start a timer and try again next time. +* As long as enough buffers are left in the ring for +* another A-MPDU rx, no special recovery is needed. +*/ +mod_timer (&htt->rx_ring.refill_retry_timer, jiffies + +msecs_to_jiffies (HTT_RX_RING_REFILL_RETRY_MS )); + }spin_unlock_bh (&htt->rx_ring.lock); }
@@ -615,13 +641,13 @@ int ath10k_htt_rx_attach(struct ath10k_htt *htt)kmalloc (htt->rx_ring.size *sizeof (struct sk_buff *),GFP_KERNEL );if (!htt->rx_ring.netbufs_ring) - goto fail1; + goto err_netbuf; vaddr =dma_alloc_coherent (htt->ar->dev, (htt->rx_ring.size *sizeof (htt->rx_ring.paddrs_ring)), &paddr,GFP_DMA );if (!vaddr) - goto fail2; + goto err_dma_ring; htt->rx_ring.paddrs_ring = vaddr; htt->rx_ring.base_paddr = paddr;
@@ -630,7 +656,7 @@ int ath10k_htt_rx_attach(struct ath10k_htt *htt)sizeof (*htt->rx_ring.alloc_idx.vaddr), &paddr, GFP_DMA);if (!vaddr) - goto fail3; + goto err_dma_idx; htt->rx_ring.alloc_idx.vaddr = vaddr; htt->rx_ring.alloc_idx.paddr = paddr;
@@ -641,23 +667,30 @@ int ath10k_htt_rx_attach(struct ath10k_htt *htt)setup_timer (timer, ath10k_htt_rx_ring_refill_retry, (unsigned long )htt);spin_lock_init (&htt->rx_ring.lock); -spin_lock_bh (&htt->rx_ring.lock); + htt->rx_ring.fill_cnt =0 ; -ath10k_htt_rx_ring_fill_n (htt, htt->rx_ring.fill_level); -spin_unlock_bh (&htt->rx_ring.lock); +if (__ath10k_htt_rx_ring_fill_n (htt, htt->rx_ring.fill_level)) + goto err_fill_ring;ath10k_dbg (ATH10K_DBG_HTT ,"HTT RX ring size: %d, fill_level: %d\n" , htt->rx_ring.size, htt->rx_ring.fill_level);return 0 ; -fail3: + +err_fill_ring: +ath10k_htt_rx_ring_free (htt); +dma_free_coherent (htt->ar->dev, +sizeof (*htt->rx_ring.alloc_idx.vaddr), + htt->rx_ring.alloc_idx.vaddr, + htt->rx_ring.alloc_idx.paddr); +err_dma_idx:dma_free_coherent (htt->ar->dev, (htt->rx_ring.size *sizeof (htt->rx_ring.paddrs_ring)), htt->rx_ring.paddrs_ring, htt->rx_ring.base_paddr); -fail2: +err_dma_ring:kfree (htt->rx_ring.netbufs_ring); -fail1: +err_netbuf:return -ENOMEM ; }
Signature · 1 line
1.8.2.2
PATCH 20/20 ath10k: Remove unneeded locks during HTT RX attach
Quoted 8 lines · Sujith Manoharan
Quoted 7 lines · Michal Kazior
I'm not even sure if we should abort right away. We replenish htt rx buffers using
GFP_ATOMICallocation. This can fail under memory pressure more often (then, say,GFP_KERNEL). I wouldn't really consider this as fatal error. Although we could probably have a ath10k_warn/info if the initial allocation doesn't fill everything up. Perhaps we could fail only if thefill_cntis still 0, or below a defined threshold?
Quoted 7 lines
Quoted 2 lines
We could also try and split the replenishing functions and use
GFP_KERNELallocation during htt rx attach.We do a bunch of allocations using
GFP_ATOMICafterhtt_attach(). Proceeding with initialization at this point seems wrong and programming the FW with RX ring configuration viaHTT_H2T_MSG_TYPE_RX_RING_CFGeven though host setup failed is probably incorrect ?
You're right.
Quoted 4 lines
An updated patch:
[PATCH] ath10k: Remove unneeded locks during HTT RX attach
Quoted 8 lines
Fix two issues:
* Bail out properly when RX buffer allocation fails at init time.
* Do not acquire the rx ring lock duringattach()since we don't rearm the replenish timer.Signed-off-by Sujith Manoharan <[email protected]>---
Looks good to me now.
-- Pozdrawiam / Best regards, Michal Kazior.
PATCH 20/20 ath10k: Remove unneeded locks during HTT RX attach
Quoted 6 lines · Michal Kazior
Quoted 6 lines
An updated patch:
[PATCH] ath10k: Remove unneeded locks during HTT RX attach
Fix two issues:
Quoted 8 lines
Quoted 6 lines
* Bail out properly when RX buffer allocation fails at init time.
* Do not acquire the rx ring lock duringattach()since we don't rearm the replenish timer.Signed-off-by Sujith Manoharan <[email protected]>---
Looks good to me now.
Alright. Thanks for the review !
Sujith
PATCH 1/20 ath10k: Remove duplicate UART init code
In reply to Sujith ManoharanQuoted 3 lines · Sujith Manoharan
From: Sujith Manoharan <[email protected]>
Signed-off-by Sujith Manoharan <[email protected]>
I have applied these patches:
1, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 19
These are pending review:
2, 6, 16
These are dropped:
18, 20
I hope I didn't miss anything.
But in the future please don't send more than 12 patches at a time, it's way too much pain to handle this many unrelated patches.
Signature · 1 line
Kalle Valo
PATCH 1/20 ath10k: Remove duplicate UART init code
Quoted 5 lines · Kalle Valo
These are dropped:
18, 20
I hope I didn't miss anything.
An updated version of patch 20 (after addressing Michal's comments) was posted and is here:
Sujith
PATCH 1/20 ath10k: Remove duplicate UART init code
Quoted 11 lines · Sujith Manoharan
Quoted 5 lines · Kalle Valo
These are dropped:
18, 20
I hope I didn't miss anything.
An updated version of patch 20 (after addressing Michal's comments) was posted and is here:
Please resend it to the list.
Signature · 1 line
Kalle Valo
PATCH 1/20 ath10k: Remove duplicate UART init code
Quoted 1 line · Kalle Valo
Please resend it to the list.
Sent.
Sujith
PATCH 1/20 ath10k: Remove duplicate UART init code
In reply to Kalle ValoQuoted 2 lines · Kalle Valo
But in the future please don't send more than 12 patches at a time, it's way too much pain to handle this many unrelated patches.
Sure, though I am not sure what you mean by "unrelated patches". :-)
Sujith
PATCH 1/20 ath10k: Remove duplicate UART init code
Quoted 5 lines · Sujith Manoharan
Quoted 2 lines · Kalle Valo
But in the future please don't send more than 12 patches at a time, it's way too much pain to handle this many unrelated patches.
Sure, though I am not sure what you mean by "unrelated patches". :-)
I meant that they don't depend on each other and can be easily splitted into smaller patchsets.
Signature · 1 line
Kalle Valo