Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e76ac2bf authored by Kalle Valo's avatar Kalle Valo
Browse files

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: default avatarKalle Valo <kvalo@qca.qualcomm.com>
Signed-off-by: default avatarRay Chen <raychen@qca.qualcomm.com>
Signed-off-by: default avatarKalle Valo <kvalo@qca.qualcomm.com>
parent 048f24f6
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@
obj-$(CONFIG_ATH6KL) += ath6kl_core.o
ath6kl_core-y += debug.o
ath6kl_core-y += hif.o
ath6kl_core-y += htc.o
ath6kl_core-y += htc_mbox.o
ath6kl_core-y += bmi.o
ath6kl_core-y += cfg80211.o
ath6kl_core-y += init.o
+11 −1
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@

#include "debug.h"
#include "hif-ops.h"
#include "htc-ops.h"
#include "cfg80211.h"

unsigned int debug_mask;
@@ -39,12 +40,21 @@ module_param(uart_debug, uint, 0644);
module_param(ath6kl_p2p, uint, 0644);
module_param(testmode, uint, 0644);

int ath6kl_core_init(struct ath6kl *ar)
int ath6kl_core_init(struct ath6kl *ar, enum ath6kl_htc_type htc_type)
{
	struct ath6kl_bmi_target_info targ_info;
	struct net_device *ndev;
	int ret = 0, i;

	switch (htc_type) {
	case ATH6KL_HTC_TYPE_MBOX:
		ath6kl_htc_mbox_attach(ar);
		break;
	default:
		WARN_ON(1);
		return -ENOMEM;
	}

	ar->ath6kl_wq = create_singlethread_workqueue("ath6kl");
	if (!ar->ath6kl_wq)
		return -ENOMEM;
+6 −1
Original line number Diff line number Diff line
@@ -462,6 +462,10 @@ enum ath6kl_hif_type {
	ATH6KL_HIF_TYPE_USB,
};

enum ath6kl_htc_type {
	ATH6KL_HTC_TYPE_MBOX,
};

/* Max number of filters that hw supports */
#define ATH6K_MAX_MC_FILTERS_PER_LIST 7
struct ath6kl_mc_filter {
@@ -576,6 +580,7 @@ struct ath6kl {

	struct ath6kl_bmi bmi;
	const struct ath6kl_hif_ops *hif_ops;
	const struct ath6kl_htc_ops *htc_ops;
	struct wmi *wmi;
	int tx_pending[ENDPOINT_MAX];
	int total_tx_data_pend;
@@ -831,7 +836,7 @@ int ath6kl_init_hw_params(struct ath6kl *ar);
void ath6kl_check_wow_status(struct ath6kl *ar);

struct ath6kl *ath6kl_core_create(struct device *dev);
int ath6kl_core_init(struct ath6kl *ar);
int ath6kl_core_init(struct ath6kl *ar, enum ath6kl_htc_type htc_type);
void ath6kl_core_cleanup(struct ath6kl *ar);
void ath6kl_core_destroy(struct ath6kl *ar);

+113 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2004-2011 Atheros Communications 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 HTC_OPS_H
#define HTC_OPS_H

#include "htc.h"
#include "debug.h"

static inline void *ath6kl_htc_create(struct ath6kl *ar)
{
	return ar->htc_ops->create(ar);
}

static inline int ath6kl_htc_wait_target(struct htc_target *target)
{
	return target->dev->ar->htc_ops->wait_target(target);
}

static inline int ath6kl_htc_start(struct htc_target *target)
{
	return target->dev->ar->htc_ops->start(target);
}

static inline int ath6kl_htc_conn_service(struct htc_target *target,
					  struct htc_service_connect_req *req,
					  struct htc_service_connect_resp *resp)
{
	return target->dev->ar->htc_ops->conn_service(target, req, resp);
}

static inline int ath6kl_htc_tx(struct htc_target *target,
				struct htc_packet *packet)
{
	return target->dev->ar->htc_ops->tx(target, packet);
}

static inline void ath6kl_htc_stop(struct htc_target *target)
{
	return target->dev->ar->htc_ops->stop(target);
}

static inline void ath6kl_htc_cleanup(struct htc_target *target)
{
	return target->dev->ar->htc_ops->cleanup(target);
}

static inline void ath6kl_htc_flush_txep(struct htc_target *target,
					 enum htc_endpoint_id endpoint,
					 u16 tag)
{
	return target->dev->ar->htc_ops->flush_txep(target, endpoint, tag);
}

static inline void ath6kl_htc_flush_rx_buf(struct htc_target *target)
{
	return target->dev->ar->htc_ops->flush_rx_buf(target);
}

static inline void ath6kl_htc_activity_changed(struct htc_target *target,
					       enum htc_endpoint_id endpoint,
					       bool active)
{
	return target->dev->ar->htc_ops->activity_changed(target, endpoint,
							  active);
}

static inline int ath6kl_htc_get_rxbuf_num(struct htc_target *target,
					   enum htc_endpoint_id endpoint)
{
	return target->dev->ar->htc_ops->get_rxbuf_num(target, endpoint);
}

static inline int ath6kl_htc_add_rxbuf_multiple(struct htc_target *target,
						struct list_head *pktq)
{
	return target->dev->ar->htc_ops->add_rxbuf_multiple(target, pktq);
}

static inline int ath6kl_htc_credit_setup(struct htc_target *target,
					  struct ath6kl_htc_credit_info *info)
{
	return target->dev->ar->htc_ops->credit_setup(target, info);
}

static inline void ath6kl_htc_tx_complete(struct ath6kl *ar,
					  struct sk_buff *skb)
{
	ar->htc_ops->tx_complete(ar, skb);
}


static inline void ath6kl_htc_rx_complete(struct ath6kl *ar,
					  struct sk_buff *skb, u8 pipe)
{
	ar->htc_ops->rx_complete(ar, skb, pipe);
}


#endif
+28 −25
Original line number Diff line number Diff line
@@ -519,6 +519,32 @@ struct htc_control_buffer {
	u8 *buf;
};

struct ath6kl_htc_ops {
	void* (*create)(struct ath6kl *ar);
	int (*wait_target)(struct htc_target *target);
	int (*start)(struct htc_target *target);
	int (*conn_service)(struct htc_target *target,
			    struct htc_service_connect_req *req,
			    struct htc_service_connect_resp *resp);
	int  (*tx)(struct htc_target *target, struct htc_packet *packet);
	void (*stop)(struct htc_target *target);
	void (*cleanup)(struct htc_target *target);
	void (*flush_txep)(struct htc_target *target,
			   enum htc_endpoint_id endpoint, u16 tag);
	void (*flush_rx_buf)(struct htc_target *target);
	void (*activity_changed)(struct htc_target *target,
				 enum htc_endpoint_id endpoint,
				 bool active);
	int (*get_rxbuf_num)(struct htc_target *target,
			     enum htc_endpoint_id endpoint);
	int (*add_rxbuf_multiple)(struct htc_target *target,
				  struct list_head *pktq);
	int (*credit_setup)(struct htc_target *target,
			    struct ath6kl_htc_credit_info *cred_info);
	int (*tx_complete)(struct ath6kl *ar, struct sk_buff *skb);
	int (*rx_complete)(struct ath6kl *ar, struct sk_buff *skb, u8 pipe);
};

struct ath6kl_device;

/* our HTC target state */
@@ -569,34 +595,9 @@ struct htc_target {
	u32 ac_tx_count[WMM_NUM_AC];
};

void *ath6kl_htc_create(struct ath6kl *ar);
void ath6kl_htc_set_credit_dist(struct htc_target *target,
				struct ath6kl_htc_credit_info *cred_info,
				u16 svc_pri_order[], int len);
int ath6kl_htc_wait_target(struct htc_target *target);
int ath6kl_htc_start(struct htc_target *target);
int ath6kl_htc_conn_service(struct htc_target *target,
			    struct htc_service_connect_req *req,
			    struct htc_service_connect_resp *resp);
int ath6kl_htc_tx(struct htc_target *target, struct htc_packet *packet);
void ath6kl_htc_stop(struct htc_target *target);
void ath6kl_htc_cleanup(struct htc_target *target);
void ath6kl_htc_flush_txep(struct htc_target *target,
			   enum htc_endpoint_id endpoint, u16 tag);
void ath6kl_htc_flush_rx_buf(struct htc_target *target);
void ath6kl_htc_indicate_activity_change(struct htc_target *target,
					 enum htc_endpoint_id endpoint,
					 bool active);
int ath6kl_htc_get_rxbuf_num(struct htc_target *target,
			     enum htc_endpoint_id endpoint);
int ath6kl_htc_add_rxbuf_multiple(struct htc_target *target,
				  struct list_head *pktq);
int ath6kl_htc_rxmsg_pending_handler(struct htc_target *target,
				     u32 msg_look_ahead, int *n_pkts);

int ath6kl_credit_setup(struct htc_target *htc_target,
			struct ath6kl_htc_credit_info *cred_info);

static inline void set_htc_pkt_info(struct htc_packet *packet, void *context,
				    u8 *buf, unsigned int len,
				    enum htc_endpoint_id eid, u16 tag)
@@ -636,4 +637,6 @@ static inline int get_queue_depth(struct list_head *queue)
	return depth;
}

void ath6kl_htc_mbox_attach(struct ath6kl *ar);

#endif
Loading