0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #ifndef HTC_HST_H
0018 #define HTC_HST_H
0019
0020 struct ath9k_htc_priv;
0021 struct htc_target;
0022 struct ath9k_htc_tx_ctl;
0023
0024 enum ath9k_hif_transports {
0025 ATH9K_HIF_USB,
0026 };
0027
0028 struct ath9k_htc_hif {
0029 struct list_head list;
0030 const enum ath9k_hif_transports transport;
0031 const char *name;
0032
0033 u8 control_dl_pipe;
0034 u8 control_ul_pipe;
0035
0036 void (*start) (void *hif_handle);
0037 void (*stop) (void *hif_handle);
0038 void (*sta_drain) (void *hif_handle, u8 idx);
0039 int (*send) (void *hif_handle, u8 pipe, struct sk_buff *buf);
0040 };
0041
0042 enum htc_endpoint_id {
0043 ENDPOINT_UNUSED = -1,
0044 ENDPOINT0 = 0,
0045 ENDPOINT1 = 1,
0046 ENDPOINT2 = 2,
0047 ENDPOINT3 = 3,
0048 ENDPOINT4 = 4,
0049 ENDPOINT5 = 5,
0050 ENDPOINT6 = 6,
0051 ENDPOINT7 = 7,
0052 ENDPOINT8 = 8,
0053 ENDPOINT_MAX = 22
0054 };
0055
0056
0057 #define HTC_FLAGS_RECV_TRAILER (1 << 1)
0058
0059 struct htc_frame_hdr {
0060 u8 endpoint_id;
0061 u8 flags;
0062 __be16 payload_len;
0063 u8 control[4];
0064 } __packed;
0065
0066 struct htc_ready_msg {
0067 __be16 message_id;
0068 __be16 credits;
0069 __be16 credit_size;
0070 u8 max_endpoints;
0071 u8 pad;
0072 } __packed;
0073
0074 struct htc_config_pipe_msg {
0075 __be16 message_id;
0076 u8 pipe_id;
0077 u8 credits;
0078 } __packed;
0079
0080 struct htc_panic_bad_vaddr {
0081 __be32 pattern;
0082 __be32 exccause;
0083 __be32 pc;
0084 __be32 badvaddr;
0085 } __packed;
0086
0087 struct htc_panic_bad_epid {
0088 __be32 pattern;
0089 __be32 epid;
0090 } __packed;
0091
0092 struct htc_ep_callbacks {
0093 void *priv;
0094 void (*tx) (void *, struct sk_buff *, enum htc_endpoint_id, bool txok);
0095 void (*rx) (void *, struct sk_buff *, enum htc_endpoint_id);
0096 };
0097
0098 struct htc_endpoint {
0099 u16 service_id;
0100
0101 struct htc_ep_callbacks ep_callbacks;
0102 u32 max_txqdepth;
0103 int max_msglen;
0104
0105 u8 ul_pipeid;
0106 u8 dl_pipeid;
0107 };
0108
0109 #define HTC_MAX_CONTROL_MESSAGE_LENGTH 255
0110 #define HTC_CONTROL_BUFFER_SIZE \
0111 (HTC_MAX_CONTROL_MESSAGE_LENGTH + sizeof(struct htc_frame_hdr))
0112
0113 #define HTC_OP_START_WAIT BIT(0)
0114 #define HTC_OP_CONFIG_PIPE_CREDITS BIT(1)
0115
0116 struct htc_target {
0117 void *hif_dev;
0118 struct ath9k_htc_priv *drv_priv;
0119 struct device *dev;
0120 struct ath9k_htc_hif *hif;
0121 struct htc_endpoint endpoint[ENDPOINT_MAX];
0122 struct completion target_wait;
0123 struct completion cmd_wait;
0124 struct list_head list;
0125 enum htc_endpoint_id conn_rsp_epid;
0126 u16 credits;
0127 u16 credit_size;
0128 u8 htc_flags;
0129 atomic_t tgt_ready;
0130 };
0131
0132 enum htc_msg_id {
0133 HTC_MSG_READY_ID = 1,
0134 HTC_MSG_CONNECT_SERVICE_ID,
0135 HTC_MSG_CONNECT_SERVICE_RESPONSE_ID,
0136 HTC_MSG_SETUP_COMPLETE_ID,
0137 HTC_MSG_CONFIG_PIPE_ID,
0138 HTC_MSG_CONFIG_PIPE_RESPONSE_ID,
0139 };
0140
0141 struct htc_service_connreq {
0142 u16 service_id;
0143 u16 con_flags;
0144 u32 max_send_qdepth;
0145 struct htc_ep_callbacks ep_callbacks;
0146 };
0147
0148
0149
0150 enum htc_service_group_ids{
0151 RSVD_SERVICE_GROUP = 0,
0152 WMI_SERVICE_GROUP = 1,
0153
0154 HTC_SERVICE_GROUP_LAST = 255
0155 };
0156
0157 #define MAKE_SERVICE_ID(group, index) \
0158 (int)(((int)group << 8) | (int)(index))
0159
0160
0161 #define HTC_CTRL_RSVD_SVC MAKE_SERVICE_ID(RSVD_SERVICE_GROUP, 1)
0162 #define HTC_LOOPBACK_RSVD_SVC MAKE_SERVICE_ID(RSVD_SERVICE_GROUP, 2)
0163
0164 #define WMI_CONTROL_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 0)
0165 #define WMI_BEACON_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 1)
0166 #define WMI_CAB_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 2)
0167 #define WMI_UAPSD_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 3)
0168 #define WMI_MGMT_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 4)
0169 #define WMI_DATA_VO_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 5)
0170 #define WMI_DATA_VI_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 6)
0171 #define WMI_DATA_BE_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 7)
0172 #define WMI_DATA_BK_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 8)
0173
0174 struct htc_conn_svc_msg {
0175 __be16 msg_id;
0176 __be16 service_id;
0177 __be16 con_flags;
0178 u8 dl_pipeid;
0179 u8 ul_pipeid;
0180 u8 svc_meta_len;
0181 u8 pad;
0182 } __packed;
0183
0184
0185 #define HTC_SERVICE_SUCCESS 0
0186 #define HTC_SERVICE_NOT_FOUND 1
0187 #define HTC_SERVICE_FAILED 2
0188 #define HTC_SERVICE_NO_RESOURCES 3
0189 #define HTC_SERVICE_NO_MORE_EP 4
0190
0191 struct htc_conn_svc_rspmsg {
0192 __be16 msg_id;
0193 __be16 service_id;
0194 u8 status;
0195 u8 endpoint_id;
0196 __be16 max_msg_len;
0197 u8 svc_meta_len;
0198 u8 pad;
0199 } __packed;
0200
0201 struct htc_comp_msg {
0202 __be16 msg_id;
0203 } __packed;
0204
0205 int htc_init(struct htc_target *target);
0206 int htc_connect_service(struct htc_target *target,
0207 struct htc_service_connreq *service_connreq,
0208 enum htc_endpoint_id *conn_rsp_eid);
0209 int htc_send(struct htc_target *target, struct sk_buff *skb);
0210 int htc_send_epid(struct htc_target *target, struct sk_buff *skb,
0211 enum htc_endpoint_id epid);
0212 void htc_stop(struct htc_target *target);
0213 void htc_start(struct htc_target *target);
0214 void htc_sta_drain(struct htc_target *target, u8 idx);
0215
0216 void ath9k_htc_rx_msg(struct htc_target *htc_handle,
0217 struct sk_buff *skb, u32 len, u8 pipe_id);
0218 void ath9k_htc_txcompletion_cb(struct htc_target *htc_handle,
0219 struct sk_buff *skb, bool txok);
0220
0221 struct htc_target *ath9k_htc_hw_alloc(void *hif_handle,
0222 struct ath9k_htc_hif *hif,
0223 struct device *dev);
0224 void ath9k_htc_hw_free(struct htc_target *htc);
0225 int ath9k_htc_hw_init(struct htc_target *target,
0226 struct device *dev, u16 devid, char *product,
0227 u32 drv_info);
0228 void ath9k_htc_hw_deinit(struct htc_target *target, bool hot_unplug);
0229
0230 #endif