Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ath6kl: add htc ops

In preparation for adding HTC pipe implementation add htc-ops.h to make
it possible dynamically choose which HTC type is used.

Needed for full USB support.

Based on the code by Ray Chen <raychen@qca.qualcomm.com>.

Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
Signed-off-by: Ray Chen <raychen@qca.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>

+219 -55
+1 -1
drivers/net/wireless/ath/ath6kl/Makefile
··· 25 25 obj-$(CONFIG_ATH6KL) += ath6kl_core.o 26 26 ath6kl_core-y += debug.o 27 27 ath6kl_core-y += hif.o 28 - ath6kl_core-y += htc.o 28 + ath6kl_core-y += htc_mbox.o 29 29 ath6kl_core-y += bmi.o 30 30 ath6kl_core-y += cfg80211.o 31 31 ath6kl_core-y += init.o
+11 -1
drivers/net/wireless/ath/ath6kl/core.c
··· 23 23 24 24 #include "debug.h" 25 25 #include "hif-ops.h" 26 + #include "htc-ops.h" 26 27 #include "cfg80211.h" 27 28 28 29 unsigned int debug_mask; ··· 40 39 module_param(ath6kl_p2p, uint, 0644); 41 40 module_param(testmode, uint, 0644); 42 41 43 - int ath6kl_core_init(struct ath6kl *ar) 42 + int ath6kl_core_init(struct ath6kl *ar, enum ath6kl_htc_type htc_type) 44 43 { 45 44 struct ath6kl_bmi_target_info targ_info; 46 45 struct net_device *ndev; 47 46 int ret = 0, i; 47 + 48 + switch (htc_type) { 49 + case ATH6KL_HTC_TYPE_MBOX: 50 + ath6kl_htc_mbox_attach(ar); 51 + break; 52 + default: 53 + WARN_ON(1); 54 + return -ENOMEM; 55 + } 48 56 49 57 ar->ath6kl_wq = create_singlethread_workqueue("ath6kl"); 50 58 if (!ar->ath6kl_wq)
+6 -1
drivers/net/wireless/ath/ath6kl/core.h
··· 462 462 ATH6KL_HIF_TYPE_USB, 463 463 }; 464 464 465 + enum ath6kl_htc_type { 466 + ATH6KL_HTC_TYPE_MBOX, 467 + }; 468 + 465 469 /* Max number of filters that hw supports */ 466 470 #define ATH6K_MAX_MC_FILTERS_PER_LIST 7 467 471 struct ath6kl_mc_filter { ··· 580 576 581 577 struct ath6kl_bmi bmi; 582 578 const struct ath6kl_hif_ops *hif_ops; 579 + const struct ath6kl_htc_ops *htc_ops; 583 580 struct wmi *wmi; 584 581 int tx_pending[ENDPOINT_MAX]; 585 582 int total_tx_data_pend; ··· 836 831 void ath6kl_check_wow_status(struct ath6kl *ar); 837 832 838 833 struct ath6kl *ath6kl_core_create(struct device *dev); 839 - int ath6kl_core_init(struct ath6kl *ar); 834 + int ath6kl_core_init(struct ath6kl *ar, enum ath6kl_htc_type htc_type); 840 835 void ath6kl_core_cleanup(struct ath6kl *ar); 841 836 void ath6kl_core_destroy(struct ath6kl *ar); 842 837
+113
drivers/net/wireless/ath/ath6kl/htc-ops.h
··· 1 + /* 2 + * Copyright (c) 2004-2011 Atheros Communications Inc. 3 + * 4 + * Permission to use, copy, modify, and/or distribute this software for any 5 + * purpose with or without fee is hereby granted, provided that the above 6 + * copyright notice and this permission notice appear in all copies. 7 + * 8 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 + */ 16 + 17 + #ifndef HTC_OPS_H 18 + #define HTC_OPS_H 19 + 20 + #include "htc.h" 21 + #include "debug.h" 22 + 23 + static inline void *ath6kl_htc_create(struct ath6kl *ar) 24 + { 25 + return ar->htc_ops->create(ar); 26 + } 27 + 28 + static inline int ath6kl_htc_wait_target(struct htc_target *target) 29 + { 30 + return target->dev->ar->htc_ops->wait_target(target); 31 + } 32 + 33 + static inline int ath6kl_htc_start(struct htc_target *target) 34 + { 35 + return target->dev->ar->htc_ops->start(target); 36 + } 37 + 38 + static inline int ath6kl_htc_conn_service(struct htc_target *target, 39 + struct htc_service_connect_req *req, 40 + struct htc_service_connect_resp *resp) 41 + { 42 + return target->dev->ar->htc_ops->conn_service(target, req, resp); 43 + } 44 + 45 + static inline int ath6kl_htc_tx(struct htc_target *target, 46 + struct htc_packet *packet) 47 + { 48 + return target->dev->ar->htc_ops->tx(target, packet); 49 + } 50 + 51 + static inline void ath6kl_htc_stop(struct htc_target *target) 52 + { 53 + return target->dev->ar->htc_ops->stop(target); 54 + } 55 + 56 + static inline void ath6kl_htc_cleanup(struct htc_target *target) 57 + { 58 + return target->dev->ar->htc_ops->cleanup(target); 59 + } 60 + 61 + static inline void ath6kl_htc_flush_txep(struct htc_target *target, 62 + enum htc_endpoint_id endpoint, 63 + u16 tag) 64 + { 65 + return target->dev->ar->htc_ops->flush_txep(target, endpoint, tag); 66 + } 67 + 68 + static inline void ath6kl_htc_flush_rx_buf(struct htc_target *target) 69 + { 70 + return target->dev->ar->htc_ops->flush_rx_buf(target); 71 + } 72 + 73 + static inline void ath6kl_htc_activity_changed(struct htc_target *target, 74 + enum htc_endpoint_id endpoint, 75 + bool active) 76 + { 77 + return target->dev->ar->htc_ops->activity_changed(target, endpoint, 78 + active); 79 + } 80 + 81 + static inline int ath6kl_htc_get_rxbuf_num(struct htc_target *target, 82 + enum htc_endpoint_id endpoint) 83 + { 84 + return target->dev->ar->htc_ops->get_rxbuf_num(target, endpoint); 85 + } 86 + 87 + static inline int ath6kl_htc_add_rxbuf_multiple(struct htc_target *target, 88 + struct list_head *pktq) 89 + { 90 + return target->dev->ar->htc_ops->add_rxbuf_multiple(target, pktq); 91 + } 92 + 93 + static inline int ath6kl_htc_credit_setup(struct htc_target *target, 94 + struct ath6kl_htc_credit_info *info) 95 + { 96 + return target->dev->ar->htc_ops->credit_setup(target, info); 97 + } 98 + 99 + static inline void ath6kl_htc_tx_complete(struct ath6kl *ar, 100 + struct sk_buff *skb) 101 + { 102 + ar->htc_ops->tx_complete(ar, skb); 103 + } 104 + 105 + 106 + static inline void ath6kl_htc_rx_complete(struct ath6kl *ar, 107 + struct sk_buff *skb, u8 pipe) 108 + { 109 + ar->htc_ops->rx_complete(ar, skb, pipe); 110 + } 111 + 112 + 113 + #endif
+54 -23
drivers/net/wireless/ath/ath6kl/htc.c drivers/net/wireless/ath/ath6kl/htc_mbox.c
··· 23 23 24 24 #define CALC_TXRX_PADDED_LEN(dev, len) (__ALIGN_MASK((len), (dev)->block_mask)) 25 25 26 + static void ath6kl_htc_mbox_cleanup(struct htc_target *target); 27 + static void ath6kl_htc_mbox_stop(struct htc_target *target); 28 + static int ath6kl_htc_mbox_add_rxbuf_multiple(struct htc_target *target, 29 + struct list_head *pkt_queue); 30 + static void ath6kl_htc_set_credit_dist(struct htc_target *target, 31 + struct ath6kl_htc_credit_info *cred_info, 32 + u16 svc_pri_order[], int len); 33 + 26 34 /* threshold to re-enable Tx bundling for an AC*/ 27 35 #define TX_RESUME_BUNDLE_THRESHOLD 1500 28 36 ··· 138 130 } 139 131 140 132 /* initialize and setup credit distribution */ 141 - int ath6kl_credit_setup(struct htc_target *htc_target, 142 - struct ath6kl_htc_credit_info *cred_info) 133 + static int ath6kl_htc_mbox_credit_setup(struct htc_target *htc_target, 134 + struct ath6kl_htc_credit_info *cred_info) 143 135 { 144 136 u16 servicepriority[5]; 145 137 ··· 1073 1065 return status; 1074 1066 } 1075 1067 1076 - void ath6kl_htc_set_credit_dist(struct htc_target *target, 1068 + static void ath6kl_htc_set_credit_dist(struct htc_target *target, 1077 1069 struct ath6kl_htc_credit_info *credit_info, 1078 1070 u16 srvc_pri_order[], int list_len) 1079 1071 { ··· 1101 1093 } 1102 1094 } 1103 1095 1104 - int ath6kl_htc_tx(struct htc_target *target, struct htc_packet *packet) 1096 + static int ath6kl_htc_mbox_tx(struct htc_target *target, 1097 + struct htc_packet *packet) 1105 1098 { 1106 1099 struct htc_endpoint *endpoint; 1107 1100 struct list_head queue; ··· 1130 1121 } 1131 1122 1132 1123 /* flush endpoint TX queue */ 1133 - void ath6kl_htc_flush_txep(struct htc_target *target, 1124 + static void ath6kl_htc_mbox_flush_txep(struct htc_target *target, 1134 1125 enum htc_endpoint_id eid, u16 tag) 1135 1126 { 1136 1127 struct htc_packet *packet, *tmp_pkt; ··· 1182 1173 if (endpoint->svc_id == 0) 1183 1174 /* not in use.. */ 1184 1175 continue; 1185 - ath6kl_htc_flush_txep(target, i, HTC_TX_PACKET_TAG_ALL); 1176 + ath6kl_htc_mbox_flush_txep(target, i, HTC_TX_PACKET_TAG_ALL); 1186 1177 } 1187 1178 } 1188 1179 1189 - void ath6kl_htc_indicate_activity_change(struct htc_target *target, 1190 - enum htc_endpoint_id eid, bool active) 1180 + static void ath6kl_htc_mbox_activity_changed(struct htc_target *target, 1181 + enum htc_endpoint_id eid, 1182 + bool active) 1191 1183 { 1192 1184 struct htc_endpoint *endpoint = &target->endpoint[eid]; 1193 1185 bool dist = false; ··· 1256 1246 1257 1247 INIT_LIST_HEAD(&queue); 1258 1248 list_add_tail(&packet->list, &queue); 1259 - return ath6kl_htc_add_rxbuf_multiple(target, &queue); 1249 + return ath6kl_htc_mbox_add_rxbuf_multiple(target, &queue); 1260 1250 } 1261 1251 1262 1252 static void htc_reclaim_rxbuf(struct htc_target *target, ··· 2300 2290 return NULL; 2301 2291 } 2302 2292 2303 - int ath6kl_htc_add_rxbuf_multiple(struct htc_target *target, 2293 + static int ath6kl_htc_mbox_add_rxbuf_multiple(struct htc_target *target, 2304 2294 struct list_head *pkt_queue) 2305 2295 { 2306 2296 struct htc_endpoint *endpoint; ··· 2362 2352 return status; 2363 2353 } 2364 2354 2365 - void ath6kl_htc_flush_rx_buf(struct htc_target *target) 2355 + static void ath6kl_htc_mbox_flush_rx_buf(struct htc_target *target) 2366 2356 { 2367 2357 struct htc_endpoint *endpoint; 2368 2358 struct htc_packet *packet, *tmp_pkt; ··· 2404 2394 } 2405 2395 } 2406 2396 2407 - int ath6kl_htc_conn_service(struct htc_target *target, 2397 + static int ath6kl_htc_mbox_conn_service(struct htc_target *target, 2408 2398 struct htc_service_connect_req *conn_req, 2409 2399 struct htc_service_connect_resp *conn_resp) 2410 2400 { ··· 2576 2566 INIT_LIST_HEAD(&target->cred_dist_list); 2577 2567 } 2578 2568 2579 - int ath6kl_htc_get_rxbuf_num(struct htc_target *target, 2569 + static int ath6kl_htc_mbox_get_rxbuf_num(struct htc_target *target, 2580 2570 enum htc_endpoint_id endpoint) 2581 2571 { 2582 2572 int num; ··· 2636 2626 } 2637 2627 } 2638 2628 2639 - int ath6kl_htc_wait_target(struct htc_target *target) 2629 + static int ath6kl_htc_mbox_wait_target(struct htc_target *target) 2640 2630 { 2641 2631 struct htc_packet *packet = NULL; 2642 2632 struct htc_ready_ext_msg *rdy_msg; ··· 2705 2695 connect.svc_id = HTC_CTRL_RSVD_SVC; 2706 2696 2707 2697 /* connect fake service */ 2708 - status = ath6kl_htc_conn_service((void *)target, &connect, &resp); 2698 + status = ath6kl_htc_mbox_conn_service((void *)target, &connect, &resp); 2709 2699 2710 2700 if (status) 2711 2701 /* 2712 2702 * FIXME: this call doesn't make sense, the caller should 2713 - * call ath6kl_htc_cleanup() when it wants remove htc 2703 + * call ath6kl_htc_mbox_cleanup() when it wants remove htc 2714 2704 */ 2715 2705 ath6kl_hif_cleanup_scatter(target->dev->ar); 2716 2706 ··· 2727 2717 * Start HTC, enable interrupts and let the target know 2728 2718 * host has finished setup. 2729 2719 */ 2730 - int ath6kl_htc_start(struct htc_target *target) 2720 + static int ath6kl_htc_mbox_start(struct htc_target *target) 2731 2721 { 2732 2722 struct htc_packet *packet; 2733 2723 int status; ··· 2764 2754 status = ath6kl_hif_unmask_intrs(target->dev); 2765 2755 2766 2756 if (status) 2767 - ath6kl_htc_stop(target); 2757 + ath6kl_htc_mbox_stop(target); 2768 2758 2769 2759 return status; 2770 2760 } ··· 2808 2798 } 2809 2799 2810 2800 /* htc_stop: stop interrupt reception, and flush all queued buffers */ 2811 - void ath6kl_htc_stop(struct htc_target *target) 2801 + static void ath6kl_htc_mbox_stop(struct htc_target *target) 2812 2802 { 2813 2803 spin_lock_bh(&target->htc_lock); 2814 2804 target->htc_flags |= HTC_OP_STATE_STOPPING; ··· 2823 2813 2824 2814 ath6kl_htc_flush_txep_all(target); 2825 2815 2826 - ath6kl_htc_flush_rx_buf(target); 2816 + ath6kl_htc_mbox_flush_rx_buf(target); 2827 2817 2828 2818 ath6kl_htc_reset(target); 2829 2819 } 2830 2820 2831 - void *ath6kl_htc_create(struct ath6kl *ar) 2821 + static void *ath6kl_htc_mbox_create(struct ath6kl *ar) 2832 2822 { 2833 2823 struct htc_target *target = NULL; 2834 2824 int status = 0; ··· 2869 2859 return target; 2870 2860 2871 2861 err_htc_cleanup: 2872 - ath6kl_htc_cleanup(target); 2862 + ath6kl_htc_mbox_cleanup(target); 2873 2863 2874 2864 return NULL; 2875 2865 } 2876 2866 2877 2867 /* cleanup the HTC instance */ 2878 - void ath6kl_htc_cleanup(struct htc_target *target) 2868 + static void ath6kl_htc_mbox_cleanup(struct htc_target *target) 2879 2869 { 2880 2870 struct htc_packet *packet, *tmp_packet; 2881 2871 ··· 2899 2889 2900 2890 kfree(target->dev); 2901 2891 kfree(target); 2892 + } 2893 + 2894 + static const struct ath6kl_htc_ops ath6kl_htc_mbox_ops = { 2895 + .create = ath6kl_htc_mbox_create, 2896 + .wait_target = ath6kl_htc_mbox_wait_target, 2897 + .start = ath6kl_htc_mbox_start, 2898 + .conn_service = ath6kl_htc_mbox_conn_service, 2899 + .tx = ath6kl_htc_mbox_tx, 2900 + .stop = ath6kl_htc_mbox_stop, 2901 + .cleanup = ath6kl_htc_mbox_cleanup, 2902 + .flush_txep = ath6kl_htc_mbox_flush_txep, 2903 + .flush_rx_buf = ath6kl_htc_mbox_flush_rx_buf, 2904 + .activity_changed = ath6kl_htc_mbox_activity_changed, 2905 + .get_rxbuf_num = ath6kl_htc_mbox_get_rxbuf_num, 2906 + .add_rxbuf_multiple = ath6kl_htc_mbox_add_rxbuf_multiple, 2907 + .credit_setup = ath6kl_htc_mbox_credit_setup, 2908 + }; 2909 + 2910 + void ath6kl_htc_mbox_attach(struct ath6kl *ar) 2911 + { 2912 + ar->htc_ops = &ath6kl_htc_mbox_ops; 2902 2913 }
+28 -25
drivers/net/wireless/ath/ath6kl/htc.h
··· 519 519 u8 *buf; 520 520 }; 521 521 522 + struct ath6kl_htc_ops { 523 + void* (*create)(struct ath6kl *ar); 524 + int (*wait_target)(struct htc_target *target); 525 + int (*start)(struct htc_target *target); 526 + int (*conn_service)(struct htc_target *target, 527 + struct htc_service_connect_req *req, 528 + struct htc_service_connect_resp *resp); 529 + int (*tx)(struct htc_target *target, struct htc_packet *packet); 530 + void (*stop)(struct htc_target *target); 531 + void (*cleanup)(struct htc_target *target); 532 + void (*flush_txep)(struct htc_target *target, 533 + enum htc_endpoint_id endpoint, u16 tag); 534 + void (*flush_rx_buf)(struct htc_target *target); 535 + void (*activity_changed)(struct htc_target *target, 536 + enum htc_endpoint_id endpoint, 537 + bool active); 538 + int (*get_rxbuf_num)(struct htc_target *target, 539 + enum htc_endpoint_id endpoint); 540 + int (*add_rxbuf_multiple)(struct htc_target *target, 541 + struct list_head *pktq); 542 + int (*credit_setup)(struct htc_target *target, 543 + struct ath6kl_htc_credit_info *cred_info); 544 + int (*tx_complete)(struct ath6kl *ar, struct sk_buff *skb); 545 + int (*rx_complete)(struct ath6kl *ar, struct sk_buff *skb, u8 pipe); 546 + }; 547 + 522 548 struct ath6kl_device; 523 549 524 550 /* our HTC target state */ ··· 595 569 u32 ac_tx_count[WMM_NUM_AC]; 596 570 }; 597 571 598 - void *ath6kl_htc_create(struct ath6kl *ar); 599 - void ath6kl_htc_set_credit_dist(struct htc_target *target, 600 - struct ath6kl_htc_credit_info *cred_info, 601 - u16 svc_pri_order[], int len); 602 - int ath6kl_htc_wait_target(struct htc_target *target); 603 - int ath6kl_htc_start(struct htc_target *target); 604 - int ath6kl_htc_conn_service(struct htc_target *target, 605 - struct htc_service_connect_req *req, 606 - struct htc_service_connect_resp *resp); 607 - int ath6kl_htc_tx(struct htc_target *target, struct htc_packet *packet); 608 - void ath6kl_htc_stop(struct htc_target *target); 609 - void ath6kl_htc_cleanup(struct htc_target *target); 610 - void ath6kl_htc_flush_txep(struct htc_target *target, 611 - enum htc_endpoint_id endpoint, u16 tag); 612 - void ath6kl_htc_flush_rx_buf(struct htc_target *target); 613 - void ath6kl_htc_indicate_activity_change(struct htc_target *target, 614 - enum htc_endpoint_id endpoint, 615 - bool active); 616 - int ath6kl_htc_get_rxbuf_num(struct htc_target *target, 617 - enum htc_endpoint_id endpoint); 618 - int ath6kl_htc_add_rxbuf_multiple(struct htc_target *target, 619 - struct list_head *pktq); 620 572 int ath6kl_htc_rxmsg_pending_handler(struct htc_target *target, 621 573 u32 msg_look_ahead, int *n_pkts); 622 - 623 - int ath6kl_credit_setup(struct htc_target *htc_target, 624 - struct ath6kl_htc_credit_info *cred_info); 625 574 626 575 static inline void set_htc_pkt_info(struct htc_packet *packet, void *context, 627 576 u8 *buf, unsigned int len, ··· 636 635 637 636 return depth; 638 637 } 638 + 639 + void ath6kl_htc_mbox_attach(struct ath6kl *ar); 639 640 640 641 #endif
+2 -1
drivers/net/wireless/ath/ath6kl/init.c
··· 27 27 #include "target.h" 28 28 #include "debug.h" 29 29 #include "hif-ops.h" 30 + #include "htc-ops.h" 30 31 31 32 static const struct ath6kl_hw hw_list[] = { 32 33 { ··· 1511 1510 } 1512 1511 1513 1512 /* setup credit distribution */ 1514 - ath6kl_credit_setup(ar->htc_target, &ar->credit_state_info); 1513 + ath6kl_htc_credit_setup(ar->htc_target, &ar->credit_state_info); 1515 1514 1516 1515 /* start HTC */ 1517 1516 ret = ath6kl_htc_start(ar->htc_target);
+1 -1
drivers/net/wireless/ath/ath6kl/sdio.c
··· 1362 1362 goto err_core_alloc; 1363 1363 } 1364 1364 1365 - ret = ath6kl_core_init(ar); 1365 + ret = ath6kl_core_init(ar, ATH6KL_HTC_TYPE_MBOX); 1366 1366 if (ret) { 1367 1367 ath6kl_err("Failed to init ath6kl core\n"); 1368 1368 goto err_core_alloc;
+2 -1
drivers/net/wireless/ath/ath6kl/txrx.c
··· 17 17 18 18 #include "core.h" 19 19 #include "debug.h" 20 + #include "htc-ops.h" 20 21 21 22 /* 22 23 * tid - tid_mux0..tid_mux3 ··· 573 572 574 573 notify_htc: 575 574 /* notify HTC, this may cause credit distribution changes */ 576 - ath6kl_htc_indicate_activity_change(ar->htc_target, eid, active); 575 + ath6kl_htc_activity_changed(ar->htc_target, eid, active); 577 576 } 578 577 579 578 enum htc_send_full_action ath6kl_tx_queue_full(struct htc_target *target,
+1 -1
drivers/net/wireless/ath/ath6kl/usb.c
··· 368 368 369 369 ar_usb->ar = ar; 370 370 371 - ret = ath6kl_core_init(ar); 371 + ret = ath6kl_core_init(ar, ATH6KL_HTC_TYPE_MBOX); 372 372 if (ret) { 373 373 ath6kl_err("Failed to init ath6kl core: %d\n", ret); 374 374 goto err_core_free;