|
@@ -22,8 +22,19 @@
|
|
|
|
|
|
#define CALC_TXRX_PADDED_LEN(dev, len) (__ALIGN_MASK((len), (dev)->block_mask))
|
|
#define CALC_TXRX_PADDED_LEN(dev, len) (__ALIGN_MASK((len), (dev)->block_mask))
|
|
|
|
|
|
-static void htc_prep_send_pkt(struct htc_packet *packet, u8 flags, int ctrl0,
|
|
|
|
- int ctrl1)
|
|
|
|
|
|
+static void ath6kl_htc_tx_buf_align(u8 **buf, unsigned long len)
|
|
|
|
+{
|
|
|
|
+ u8 *align_addr;
|
|
|
|
+
|
|
|
|
+ if (!IS_ALIGNED((unsigned long) *buf, 4)) {
|
|
|
|
+ align_addr = PTR_ALIGN(*buf - 4, 4);
|
|
|
|
+ memmove(align_addr, *buf, len);
|
|
|
|
+ *buf = align_addr;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void ath6kl_htc_tx_prep_pkt(struct htc_packet *packet, u8 flags,
|
|
|
|
+ int ctrl0, int ctrl1)
|
|
{
|
|
{
|
|
struct htc_frame_hdr *hdr;
|
|
struct htc_frame_hdr *hdr;
|
|
|
|
|
|
@@ -167,7 +178,8 @@ static void htc_async_tx_scat_complete(struct htc_target *target,
|
|
htc_tx_complete(endpoint, &tx_compq);
|
|
htc_tx_complete(endpoint, &tx_compq);
|
|
}
|
|
}
|
|
|
|
|
|
-static int htc_issue_send(struct htc_target *target, struct htc_packet *packet)
|
|
|
|
|
|
+static int ath6kl_htc_tx_issue(struct htc_target *target,
|
|
|
|
+ struct htc_packet *packet)
|
|
{
|
|
{
|
|
int status;
|
|
int status;
|
|
bool sync = false;
|
|
bool sync = false;
|
|
@@ -196,7 +208,7 @@ static int htc_issue_send(struct htc_target *target, struct htc_packet *packet)
|
|
HIF_WR_SYNC_BLOCK_INC);
|
|
HIF_WR_SYNC_BLOCK_INC);
|
|
|
|
|
|
packet->status = status;
|
|
packet->status = status;
|
|
- packet->buf += HTC_HDR_LENGTH;
|
|
|
|
|
|
+ packet->buf += HTC_HDR_LENGTH;
|
|
} else
|
|
} else
|
|
status = hif_write_async(target->dev->ar,
|
|
status = hif_write_async(target->dev->ar,
|
|
target->dev->ar->mbox_info.htc_addr,
|
|
target->dev->ar->mbox_info.htc_addr,
|
|
@@ -265,9 +277,9 @@ static int htc_check_credits(struct htc_target *target,
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
-static void htc_tx_pkts_get(struct htc_target *target,
|
|
|
|
- struct htc_endpoint *endpoint,
|
|
|
|
- struct list_head *queue)
|
|
|
|
|
|
+static void ath6kl_htc_tx_pkts_get(struct htc_target *target,
|
|
|
|
+ struct htc_endpoint *endpoint,
|
|
|
|
+ struct list_head *queue)
|
|
{
|
|
{
|
|
int req_cred;
|
|
int req_cred;
|
|
u8 flags;
|
|
u8 flags;
|
|
@@ -346,11 +358,11 @@ static int htc_get_credit_padding(unsigned int cred_sz, int *len,
|
|
return cred_pad;
|
|
return cred_pad;
|
|
}
|
|
}
|
|
|
|
|
|
-static int htc_setup_send_scat_list(struct htc_target *target,
|
|
|
|
- struct htc_endpoint *endpoint,
|
|
|
|
- struct hif_scatter_req *scat_req,
|
|
|
|
- int n_scat,
|
|
|
|
- struct list_head *queue)
|
|
|
|
|
|
+static int ath6kl_htc_tx_setup_scat_list(struct htc_target *target,
|
|
|
|
+ struct htc_endpoint *endpoint,
|
|
|
|
+ struct hif_scatter_req *scat_req,
|
|
|
|
+ int n_scat,
|
|
|
|
+ struct list_head *queue)
|
|
{
|
|
{
|
|
struct htc_packet *packet;
|
|
struct htc_packet *packet;
|
|
int i, len, rem_scat, cred_pad;
|
|
int i, len, rem_scat, cred_pad;
|
|
@@ -370,27 +382,23 @@ static int htc_setup_send_scat_list(struct htc_target *target,
|
|
|
|
|
|
cred_pad = htc_get_credit_padding(target->tgt_cred_sz,
|
|
cred_pad = htc_get_credit_padding(target->tgt_cred_sz,
|
|
&len, endpoint);
|
|
&len, endpoint);
|
|
- if (cred_pad < 0) {
|
|
|
|
- status = -EINVAL;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (rem_scat < len) {
|
|
|
|
- /* exceeds what we can transfer */
|
|
|
|
|
|
+ if (cred_pad < 0 || rem_scat < len) {
|
|
status = -ENOSPC;
|
|
status = -ENOSPC;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
rem_scat -= len;
|
|
rem_scat -= len;
|
|
/* now remove it from the queue */
|
|
/* now remove it from the queue */
|
|
- packet = list_first_entry(queue, struct htc_packet, list);
|
|
|
|
list_del(&packet->list);
|
|
list_del(&packet->list);
|
|
|
|
|
|
scat_req->scat_list[i].packet = packet;
|
|
scat_req->scat_list[i].packet = packet;
|
|
/* prepare packet and flag message as part of a send bundle */
|
|
/* prepare packet and flag message as part of a send bundle */
|
|
- htc_prep_send_pkt(packet,
|
|
|
|
|
|
+ ath6kl_htc_tx_prep_pkt(packet,
|
|
packet->info.tx.flags | HTC_FLAGS_SEND_BUNDLE,
|
|
packet->info.tx.flags | HTC_FLAGS_SEND_BUNDLE,
|
|
cred_pad, packet->info.tx.seqno);
|
|
cred_pad, packet->info.tx.seqno);
|
|
|
|
+ /* Make sure the buffer is 4-byte aligned */
|
|
|
|
+ ath6kl_htc_tx_buf_align(&packet->buf,
|
|
|
|
+ packet->act_len + HTC_HDR_LENGTH);
|
|
scat_req->scat_list[i].buf = packet->buf;
|
|
scat_req->scat_list[i].buf = packet->buf;
|
|
scat_req->scat_list[i].len = len;
|
|
scat_req->scat_list[i].len = len;
|
|
|
|
|
|
@@ -402,7 +410,7 @@ static int htc_setup_send_scat_list(struct htc_target *target,
|
|
}
|
|
}
|
|
|
|
|
|
/* Roll back scatter setup in case of any failure */
|
|
/* Roll back scatter setup in case of any failure */
|
|
- if (status || (scat_req->scat_entries < HTC_MIN_HTC_MSGS_TO_BUNDLE)) {
|
|
|
|
|
|
+ if (scat_req->scat_entries < HTC_MIN_HTC_MSGS_TO_BUNDLE) {
|
|
for (i = scat_req->scat_entries - 1; i >= 0; i--) {
|
|
for (i = scat_req->scat_entries - 1; i >= 0; i--) {
|
|
packet = scat_req->scat_list[i].packet;
|
|
packet = scat_req->scat_list[i].packet;
|
|
if (packet) {
|
|
if (packet) {
|
|
@@ -410,31 +418,32 @@ static int htc_setup_send_scat_list(struct htc_target *target,
|
|
list_add(&packet->list, queue);
|
|
list_add(&packet->list, queue);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return -EINVAL;
|
|
|
|
|
|
+ return -EAGAIN;
|
|
}
|
|
}
|
|
|
|
|
|
- return 0;
|
|
|
|
|
|
+ return status;
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
- * htc_issue_send_bundle: drain a queue and send as bundles
|
|
|
|
- * this function may return without fully draining the queue
|
|
|
|
- * when
|
|
|
|
|
|
+ * Drain a queue and send as bundles this function may return without fully
|
|
|
|
+ * draining the queue when
|
|
*
|
|
*
|
|
* 1. scatter resources are exhausted
|
|
* 1. scatter resources are exhausted
|
|
* 2. a message that will consume a partial credit will stop the
|
|
* 2. a message that will consume a partial credit will stop the
|
|
* bundling process early
|
|
* bundling process early
|
|
* 3. we drop below the minimum number of messages for a bundle
|
|
* 3. we drop below the minimum number of messages for a bundle
|
|
*/
|
|
*/
|
|
-static void htc_issue_send_bundle(struct htc_endpoint *endpoint,
|
|
|
|
- struct list_head *queue,
|
|
|
|
- int *sent_bundle, int *n_bundle_pkts)
|
|
|
|
|
|
+static void ath6kl_htc_tx_bundle(struct htc_endpoint *endpoint,
|
|
|
|
+ struct list_head *queue,
|
|
|
|
+ int *sent_bundle, int *n_bundle_pkts)
|
|
{
|
|
{
|
|
struct htc_target *target = endpoint->target;
|
|
struct htc_target *target = endpoint->target;
|
|
struct hif_scatter_req *scat_req = NULL;
|
|
struct hif_scatter_req *scat_req = NULL;
|
|
int n_scat, n_sent_bundle = 0, tot_pkts_bundle = 0;
|
|
int n_scat, n_sent_bundle = 0, tot_pkts_bundle = 0;
|
|
|
|
+ int status;
|
|
|
|
|
|
while (true) {
|
|
while (true) {
|
|
|
|
+ status = 0;
|
|
n_scat = get_queue_depth(queue);
|
|
n_scat = get_queue_depth(queue);
|
|
n_scat = min(n_scat, target->msg_per_bndl_max);
|
|
n_scat = min(n_scat, target->msg_per_bndl_max);
|
|
|
|
|
|
@@ -457,8 +466,10 @@ static void htc_issue_send_bundle(struct htc_endpoint *endpoint,
|
|
scat_req->len = 0;
|
|
scat_req->len = 0;
|
|
scat_req->scat_entries = 0;
|
|
scat_req->scat_entries = 0;
|
|
|
|
|
|
- if (htc_setup_send_scat_list(target, endpoint, scat_req,
|
|
|
|
- n_scat, queue)) {
|
|
|
|
|
|
+ status = ath6kl_htc_tx_setup_scat_list(target, endpoint,
|
|
|
|
+ scat_req, n_scat,
|
|
|
|
+ queue);
|
|
|
|
+ if (status == -EAGAIN) {
|
|
hif_scatter_req_add(target->dev->ar, scat_req);
|
|
hif_scatter_req_add(target->dev->ar, scat_req);
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -472,18 +483,21 @@ static void htc_issue_send_bundle(struct htc_endpoint *endpoint,
|
|
"send scatter total bytes: %d , entries: %d\n",
|
|
"send scatter total bytes: %d , entries: %d\n",
|
|
scat_req->len, scat_req->scat_entries);
|
|
scat_req->len, scat_req->scat_entries);
|
|
ath6kldev_submit_scat_req(target->dev, scat_req, false);
|
|
ath6kldev_submit_scat_req(target->dev, scat_req, false);
|
|
|
|
+
|
|
|
|
+ if (status)
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
|
|
|
|
*sent_bundle = n_sent_bundle;
|
|
*sent_bundle = n_sent_bundle;
|
|
*n_bundle_pkts = tot_pkts_bundle;
|
|
*n_bundle_pkts = tot_pkts_bundle;
|
|
- ath6kl_dbg(ATH6KL_DBG_HTC_SEND, "htc_issue_send_bundle (sent:%d)\n",
|
|
|
|
- n_sent_bundle);
|
|
|
|
|
|
+ ath6kl_dbg(ATH6KL_DBG_HTC_SEND, "%s (sent:%d)\n",
|
|
|
|
+ __func__, n_sent_bundle);
|
|
|
|
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
-static void htc_tx_from_ep_txq(struct htc_target *target,
|
|
|
|
- struct htc_endpoint *endpoint)
|
|
|
|
|
|
+static void ath6kl_htc_tx_from_queue(struct htc_target *target,
|
|
|
|
+ struct htc_endpoint *endpoint)
|
|
{
|
|
{
|
|
struct list_head txq;
|
|
struct list_head txq;
|
|
struct htc_packet *packet;
|
|
struct htc_packet *packet;
|
|
@@ -511,7 +525,7 @@ static void htc_tx_from_ep_txq(struct htc_target *target,
|
|
if (list_empty(&endpoint->txq))
|
|
if (list_empty(&endpoint->txq))
|
|
break;
|
|
break;
|
|
|
|
|
|
- htc_tx_pkts_get(target, endpoint, &txq);
|
|
|
|
|
|
+ ath6kl_htc_tx_pkts_get(target, endpoint, &txq);
|
|
|
|
|
|
if (list_empty(&txq))
|
|
if (list_empty(&txq))
|
|
break;
|
|
break;
|
|
@@ -528,8 +542,8 @@ static void htc_tx_from_ep_txq(struct htc_target *target,
|
|
HTC_MIN_HTC_MSGS_TO_BUNDLE)) {
|
|
HTC_MIN_HTC_MSGS_TO_BUNDLE)) {
|
|
int temp1 = 0, temp2 = 0;
|
|
int temp1 = 0, temp2 = 0;
|
|
|
|
|
|
- htc_issue_send_bundle(endpoint, &txq,
|
|
|
|
- &temp1, &temp2);
|
|
|
|
|
|
+ ath6kl_htc_tx_bundle(endpoint, &txq,
|
|
|
|
+ &temp1, &temp2);
|
|
bundle_sent += temp1;
|
|
bundle_sent += temp1;
|
|
n_pkts_bundle += temp2;
|
|
n_pkts_bundle += temp2;
|
|
}
|
|
}
|
|
@@ -541,9 +555,9 @@ static void htc_tx_from_ep_txq(struct htc_target *target,
|
|
list);
|
|
list);
|
|
list_del(&packet->list);
|
|
list_del(&packet->list);
|
|
|
|
|
|
- htc_prep_send_pkt(packet, packet->info.tx.flags,
|
|
|
|
- 0, packet->info.tx.seqno);
|
|
|
|
- htc_issue_send(target, packet);
|
|
|
|
|
|
+ ath6kl_htc_tx_prep_pkt(packet, packet->info.tx.flags,
|
|
|
|
+ 0, packet->info.tx.seqno);
|
|
|
|
+ ath6kl_htc_tx_issue(target, packet);
|
|
}
|
|
}
|
|
|
|
|
|
spin_lock_bh(&target->tx_lock);
|
|
spin_lock_bh(&target->tx_lock);
|
|
@@ -556,9 +570,9 @@ static void htc_tx_from_ep_txq(struct htc_target *target,
|
|
spin_unlock_bh(&target->tx_lock);
|
|
spin_unlock_bh(&target->tx_lock);
|
|
}
|
|
}
|
|
|
|
|
|
-static bool htc_try_send(struct htc_target *target,
|
|
|
|
- struct htc_endpoint *endpoint,
|
|
|
|
- struct htc_packet *tx_pkt)
|
|
|
|
|
|
+static bool ath6kl_htc_tx_try(struct htc_target *target,
|
|
|
|
+ struct htc_endpoint *endpoint,
|
|
|
|
+ struct htc_packet *tx_pkt)
|
|
{
|
|
{
|
|
struct htc_ep_callbacks ep_cb;
|
|
struct htc_ep_callbacks ep_cb;
|
|
int txq_depth;
|
|
int txq_depth;
|
|
@@ -594,7 +608,7 @@ static bool htc_try_send(struct htc_target *target,
|
|
list_add_tail(&tx_pkt->list, &endpoint->txq);
|
|
list_add_tail(&tx_pkt->list, &endpoint->txq);
|
|
spin_unlock_bh(&target->tx_lock);
|
|
spin_unlock_bh(&target->tx_lock);
|
|
|
|
|
|
- htc_tx_from_ep_txq(target, endpoint);
|
|
|
|
|
|
+ ath6kl_htc_tx_from_queue(target, endpoint);
|
|
|
|
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -628,7 +642,7 @@ static void htc_chk_ep_txq(struct htc_target *target)
|
|
* chance to reclaim credits from lower priority
|
|
* chance to reclaim credits from lower priority
|
|
* ones.
|
|
* ones.
|
|
*/
|
|
*/
|
|
- htc_tx_from_ep_txq(target, endpoint);
|
|
|
|
|
|
+ ath6kl_htc_tx_from_queue(target, endpoint);
|
|
spin_lock_bh(&target->tx_lock);
|
|
spin_lock_bh(&target->tx_lock);
|
|
}
|
|
}
|
|
spin_unlock_bh(&target->tx_lock);
|
|
spin_unlock_bh(&target->tx_lock);
|
|
@@ -680,8 +694,8 @@ static int htc_setup_tx_complete(struct htc_target *target)
|
|
|
|
|
|
/* we want synchronous operation */
|
|
/* we want synchronous operation */
|
|
send_pkt->completion = NULL;
|
|
send_pkt->completion = NULL;
|
|
- htc_prep_send_pkt(send_pkt, 0, 0, 0);
|
|
|
|
- status = htc_issue_send(target, send_pkt);
|
|
|
|
|
|
+ ath6kl_htc_tx_prep_pkt(send_pkt, 0, 0, 0);
|
|
|
|
+ status = ath6kl_htc_tx_issue(target, send_pkt);
|
|
|
|
|
|
if (send_pkt != NULL)
|
|
if (send_pkt != NULL)
|
|
htc_reclaim_txctrl_buf(target, send_pkt);
|
|
htc_reclaim_txctrl_buf(target, send_pkt);
|
|
@@ -733,7 +747,7 @@ int ath6kl_htc_tx(struct htc_target *target, struct htc_packet *packet)
|
|
|
|
|
|
endpoint = &target->endpoint[packet->endpoint];
|
|
endpoint = &target->endpoint[packet->endpoint];
|
|
|
|
|
|
- if (!htc_try_send(target, endpoint, packet)) {
|
|
|
|
|
|
+ if (!ath6kl_htc_tx_try(target, endpoint, packet)) {
|
|
packet->status = (target->htc_flags & HTC_OP_STATE_STOPPING) ?
|
|
packet->status = (target->htc_flags & HTC_OP_STATE_STOPPING) ?
|
|
-ECANCELED : -ENOSPC;
|
|
-ECANCELED : -ENOSPC;
|
|
INIT_LIST_HEAD(&queue);
|
|
INIT_LIST_HEAD(&queue);
|
|
@@ -846,8 +860,8 @@ void ath6kl_htc_indicate_activity_change(struct htc_target *target,
|
|
|
|
|
|
/* HTC Rx */
|
|
/* HTC Rx */
|
|
|
|
|
|
-static inline void htc_update_rx_stats(struct htc_endpoint *endpoint,
|
|
|
|
- int n_look_ahds)
|
|
|
|
|
|
+static inline void ath6kl_htc_rx_update_stats(struct htc_endpoint *endpoint,
|
|
|
|
+ int n_look_ahds)
|
|
{
|
|
{
|
|
endpoint->ep_st.rx_pkts++;
|
|
endpoint->ep_st.rx_pkts++;
|
|
if (n_look_ahds == 1)
|
|
if (n_look_ahds == 1)
|
|
@@ -894,8 +908,9 @@ static void reclaim_rx_ctrl_buf(struct htc_target *target,
|
|
spin_unlock_bh(&target->htc_lock);
|
|
spin_unlock_bh(&target->htc_lock);
|
|
}
|
|
}
|
|
|
|
|
|
-static int dev_rx_pkt(struct htc_target *target, struct htc_packet *packet,
|
|
|
|
- u32 rx_len)
|
|
|
|
|
|
+static int ath6kl_htc_rx_packet(struct htc_target *target,
|
|
|
|
+ struct htc_packet *packet,
|
|
|
|
+ u32 rx_len)
|
|
{
|
|
{
|
|
struct ath6kl_device *dev = target->dev;
|
|
struct ath6kl_device *dev = target->dev;
|
|
u32 padded_len;
|
|
u32 padded_len;
|
|
@@ -929,9 +944,9 @@ static int dev_rx_pkt(struct htc_target *target, struct htc_packet *packet,
|
|
* "hint" that there are more single-packets to fetch
|
|
* "hint" that there are more single-packets to fetch
|
|
* on this endpoint.
|
|
* on this endpoint.
|
|
*/
|
|
*/
|
|
-static void set_rxpkt_indication_flag(u32 lk_ahd,
|
|
|
|
- struct htc_endpoint *endpoint,
|
|
|
|
- struct htc_packet *packet)
|
|
|
|
|
|
+static void ath6kl_htc_rx_set_indicate(u32 lk_ahd,
|
|
|
|
+ struct htc_endpoint *endpoint,
|
|
|
|
+ struct htc_packet *packet)
|
|
{
|
|
{
|
|
struct htc_frame_hdr *htc_hdr = (struct htc_frame_hdr *)&lk_ahd;
|
|
struct htc_frame_hdr *htc_hdr = (struct htc_frame_hdr *)&lk_ahd;
|
|
|
|
|
|
@@ -942,7 +957,7 @@ static void set_rxpkt_indication_flag(u32 lk_ahd,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-static void chk_rx_water_mark(struct htc_endpoint *endpoint)
|
|
|
|
|
|
+static void ath6kl_htc_rx_chk_water_mark(struct htc_endpoint *endpoint)
|
|
{
|
|
{
|
|
struct htc_ep_callbacks ep_cb = endpoint->ep_cb;
|
|
struct htc_ep_callbacks ep_cb = endpoint->ep_cb;
|
|
|
|
|
|
@@ -959,8 +974,9 @@ static void chk_rx_water_mark(struct htc_endpoint *endpoint)
|
|
}
|
|
}
|
|
|
|
|
|
/* This function is called with rx_lock held */
|
|
/* This function is called with rx_lock held */
|
|
-static int htc_setup_rxpkts(struct htc_target *target, struct htc_endpoint *ep,
|
|
|
|
- u32 *lk_ahds, struct list_head *queue, int n_msg)
|
|
|
|
|
|
+static int ath6kl_htc_rx_setup(struct htc_target *target,
|
|
|
|
+ struct htc_endpoint *ep,
|
|
|
|
+ u32 *lk_ahds, struct list_head *queue, int n_msg)
|
|
{
|
|
{
|
|
struct htc_packet *packet;
|
|
struct htc_packet *packet;
|
|
/* FIXME: type of lk_ahds can't be right */
|
|
/* FIXME: type of lk_ahds can't be right */
|
|
@@ -1060,10 +1076,10 @@ static int htc_setup_rxpkts(struct htc_target *target, struct htc_endpoint *ep,
|
|
return status;
|
|
return status;
|
|
}
|
|
}
|
|
|
|
|
|
-static int alloc_and_prep_rxpkts(struct htc_target *target,
|
|
|
|
- u32 lk_ahds[], int msg,
|
|
|
|
- struct htc_endpoint *endpoint,
|
|
|
|
- struct list_head *queue)
|
|
|
|
|
|
+static int ath6kl_htc_rx_alloc(struct htc_target *target,
|
|
|
|
+ u32 lk_ahds[], int msg,
|
|
|
|
+ struct htc_endpoint *endpoint,
|
|
|
|
+ struct list_head *queue)
|
|
{
|
|
{
|
|
int status = 0;
|
|
int status = 0;
|
|
struct htc_packet *packet, *tmp_pkt;
|
|
struct htc_packet *packet, *tmp_pkt;
|
|
@@ -1129,8 +1145,8 @@ static int alloc_and_prep_rxpkts(struct htc_target *target,
|
|
n_msg = 1;
|
|
n_msg = 1;
|
|
|
|
|
|
/* Setup packet buffers for each message */
|
|
/* Setup packet buffers for each message */
|
|
- status = htc_setup_rxpkts(target, endpoint, &lk_ahds[i], queue,
|
|
|
|
- n_msg);
|
|
|
|
|
|
+ status = ath6kl_htc_rx_setup(target, endpoint, &lk_ahds[i],
|
|
|
|
+ queue, n_msg);
|
|
|
|
|
|
/*
|
|
/*
|
|
* This is due to unavailabilty of buffers to rx entire data.
|
|
* This is due to unavailabilty of buffers to rx entire data.
|
|
@@ -1176,9 +1192,9 @@ static void htc_ctrl_rx(struct htc_target *context, struct htc_packet *packets)
|
|
packets->act_len + HTC_HDR_LENGTH);
|
|
packets->act_len + HTC_HDR_LENGTH);
|
|
|
|
|
|
ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES,
|
|
ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES,
|
|
- "Unexpected ENDPOINT 0 Message",
|
|
|
|
- packets->buf - HTC_HDR_LENGTH,
|
|
|
|
- packets->act_len + HTC_HDR_LENGTH);
|
|
|
|
|
|
+ "Unexpected ENDPOINT 0 Message", "",
|
|
|
|
+ packets->buf - HTC_HDR_LENGTH,
|
|
|
|
+ packets->act_len + HTC_HDR_LENGTH);
|
|
}
|
|
}
|
|
|
|
|
|
htc_reclaim_rxbuf(context, packets, &context->endpoint[0]);
|
|
htc_reclaim_rxbuf(context, packets, &context->endpoint[0]);
|
|
@@ -1312,7 +1328,7 @@ static int htc_parse_trailer(struct htc_target *target,
|
|
memcpy((u8 *)&next_lk_ahds[0], lk_ahd->lk_ahd, 4);
|
|
memcpy((u8 *)&next_lk_ahds[0], lk_ahd->lk_ahd, 4);
|
|
|
|
|
|
ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, "Next Look Ahead",
|
|
ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, "Next Look Ahead",
|
|
- next_lk_ahds, 4);
|
|
|
|
|
|
+ "", next_lk_ahds, 4);
|
|
|
|
|
|
*n_lk_ahds = 1;
|
|
*n_lk_ahds = 1;
|
|
}
|
|
}
|
|
@@ -1331,7 +1347,7 @@ static int htc_parse_trailer(struct htc_target *target,
|
|
(struct htc_bundle_lkahd_rpt *) record_buf;
|
|
(struct htc_bundle_lkahd_rpt *) record_buf;
|
|
|
|
|
|
ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, "Bundle lk_ahd",
|
|
ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, "Bundle lk_ahd",
|
|
- record_buf, record->len);
|
|
|
|
|
|
+ "", record_buf, record->len);
|
|
|
|
|
|
for (i = 0; i < len; i++) {
|
|
for (i = 0; i < len; i++) {
|
|
memcpy((u8 *)&next_lk_ahds[i],
|
|
memcpy((u8 *)&next_lk_ahds[i],
|
|
@@ -1364,7 +1380,8 @@ static int htc_proc_trailer(struct htc_target *target,
|
|
|
|
|
|
ath6kl_dbg(ATH6KL_DBG_HTC_RECV, "+htc_proc_trailer (len:%d)\n", len);
|
|
ath6kl_dbg(ATH6KL_DBG_HTC_RECV, "+htc_proc_trailer (len:%d)\n", len);
|
|
|
|
|
|
- ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, "Recv Trailer", buf, len);
|
|
|
|
|
|
+ ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, "Recv Trailer", "",
|
|
|
|
+ buf, len);
|
|
|
|
|
|
orig_buf = buf;
|
|
orig_buf = buf;
|
|
orig_len = len;
|
|
orig_len = len;
|
|
@@ -1402,14 +1419,14 @@ static int htc_proc_trailer(struct htc_target *target,
|
|
|
|
|
|
if (status)
|
|
if (status)
|
|
ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, "BAD Recv Trailer",
|
|
ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, "BAD Recv Trailer",
|
|
- orig_buf, orig_len);
|
|
|
|
|
|
+ "", orig_buf, orig_len);
|
|
|
|
|
|
return status;
|
|
return status;
|
|
}
|
|
}
|
|
|
|
|
|
-static int htc_proc_rxhdr(struct htc_target *target,
|
|
|
|
- struct htc_packet *packet,
|
|
|
|
- u32 *next_lkahds, int *n_lkahds)
|
|
|
|
|
|
+static int ath6kl_htc_rx_process_hdr(struct htc_target *target,
|
|
|
|
+ struct htc_packet *packet,
|
|
|
|
+ u32 *next_lkahds, int *n_lkahds)
|
|
{
|
|
{
|
|
int status = 0;
|
|
int status = 0;
|
|
u16 payload_len;
|
|
u16 payload_len;
|
|
@@ -1419,8 +1436,8 @@ static int htc_proc_rxhdr(struct htc_target *target,
|
|
if (n_lkahds != NULL)
|
|
if (n_lkahds != NULL)
|
|
*n_lkahds = 0;
|
|
*n_lkahds = 0;
|
|
|
|
|
|
- ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, "HTC Recv PKT", packet->buf,
|
|
|
|
- packet->act_len);
|
|
|
|
|
|
+ ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, "HTC Recv PKT", "htc ",
|
|
|
|
+ packet->buf, packet->act_len);
|
|
|
|
|
|
/*
|
|
/*
|
|
* NOTE: we cannot assume the alignment of buf, so we use the safe
|
|
* NOTE: we cannot assume the alignment of buf, so we use the safe
|
|
@@ -1461,12 +1478,12 @@ static int htc_proc_rxhdr(struct htc_target *target,
|
|
}
|
|
}
|
|
|
|
|
|
if (lk_ahd != packet->info.rx.exp_hdr) {
|
|
if (lk_ahd != packet->info.rx.exp_hdr) {
|
|
- ath6kl_err("htc_proc_rxhdr, lk_ahd mismatch! (pPkt:0x%p flags:0x%X)\n",
|
|
|
|
- packet, packet->info.rx.rx_flags);
|
|
|
|
|
|
+ ath6kl_err("%s(): lk_ahd mismatch! (pPkt:0x%p flags:0x%X)\n",
|
|
|
|
+ __func__, packet, packet->info.rx.rx_flags);
|
|
ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, "Expected Message lk_ahd",
|
|
ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, "Expected Message lk_ahd",
|
|
- &packet->info.rx.exp_hdr, 4);
|
|
|
|
|
|
+ "", &packet->info.rx.exp_hdr, 4);
|
|
ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, "Current Frame Header",
|
|
ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, "Current Frame Header",
|
|
- (u8 *)&lk_ahd, sizeof(lk_ahd));
|
|
|
|
|
|
+ "", (u8 *)&lk_ahd, sizeof(lk_ahd));
|
|
status = -ENOMEM;
|
|
status = -ENOMEM;
|
|
goto fail_rx;
|
|
goto fail_rx;
|
|
}
|
|
}
|
|
@@ -1474,8 +1491,8 @@ static int htc_proc_rxhdr(struct htc_target *target,
|
|
if (htc_hdr->flags & HTC_FLG_RX_TRAILER) {
|
|
if (htc_hdr->flags & HTC_FLG_RX_TRAILER) {
|
|
if (htc_hdr->ctrl[0] < sizeof(struct htc_record_hdr) ||
|
|
if (htc_hdr->ctrl[0] < sizeof(struct htc_record_hdr) ||
|
|
htc_hdr->ctrl[0] > payload_len) {
|
|
htc_hdr->ctrl[0] > payload_len) {
|
|
- ath6kl_err("htc_proc_rxhdr, invalid hdr (payload len should be :%d, CB[0] is:%d)\n",
|
|
|
|
- payload_len, htc_hdr->ctrl[0]);
|
|
|
|
|
|
+ ath6kl_err("%s(): invalid hdr (payload len should be :%d, CB[0] is:%d)\n",
|
|
|
|
+ __func__, payload_len, htc_hdr->ctrl[0]);
|
|
status = -ENOMEM;
|
|
status = -ENOMEM;
|
|
goto fail_rx;
|
|
goto fail_rx;
|
|
}
|
|
}
|
|
@@ -1502,20 +1519,20 @@ static int htc_proc_rxhdr(struct htc_target *target,
|
|
fail_rx:
|
|
fail_rx:
|
|
if (status)
|
|
if (status)
|
|
ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, "BAD HTC Recv PKT",
|
|
ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, "BAD HTC Recv PKT",
|
|
- packet->buf,
|
|
|
|
|
|
+ "", packet->buf,
|
|
packet->act_len < 256 ? packet->act_len : 256);
|
|
packet->act_len < 256 ? packet->act_len : 256);
|
|
else {
|
|
else {
|
|
if (packet->act_len > 0)
|
|
if (packet->act_len > 0)
|
|
ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES,
|
|
ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES,
|
|
- "HTC - Application Msg",
|
|
|
|
|
|
+ "HTC - Application Msg", "",
|
|
packet->buf, packet->act_len);
|
|
packet->buf, packet->act_len);
|
|
}
|
|
}
|
|
|
|
|
|
return status;
|
|
return status;
|
|
}
|
|
}
|
|
|
|
|
|
-static void do_rx_completion(struct htc_endpoint *endpoint,
|
|
|
|
- struct htc_packet *packet)
|
|
|
|
|
|
+static void ath6kl_htc_rx_complete(struct htc_endpoint *endpoint,
|
|
|
|
+ struct htc_packet *packet)
|
|
{
|
|
{
|
|
ath6kl_dbg(ATH6KL_DBG_HTC_RECV,
|
|
ath6kl_dbg(ATH6KL_DBG_HTC_RECV,
|
|
"htc calling ep %d recv callback on packet 0x%p\n",
|
|
"htc calling ep %d recv callback on packet 0x%p\n",
|
|
@@ -1523,10 +1540,10 @@ static void do_rx_completion(struct htc_endpoint *endpoint,
|
|
endpoint->ep_cb.rx(endpoint->target, packet);
|
|
endpoint->ep_cb.rx(endpoint->target, packet);
|
|
}
|
|
}
|
|
|
|
|
|
-static int htc_issue_rxpkt_bundle(struct htc_target *target,
|
|
|
|
- struct list_head *rxq,
|
|
|
|
- struct list_head *sync_compq,
|
|
|
|
- int *n_pkt_fetched, bool part_bundle)
|
|
|
|
|
|
+static int ath6kl_htc_rx_bundle(struct htc_target *target,
|
|
|
|
+ struct list_head *rxq,
|
|
|
|
+ struct list_head *sync_compq,
|
|
|
|
+ int *n_pkt_fetched, bool part_bundle)
|
|
{
|
|
{
|
|
struct hif_scatter_req *scat_req;
|
|
struct hif_scatter_req *scat_req;
|
|
struct htc_packet *packet;
|
|
struct htc_packet *packet;
|
|
@@ -1548,15 +1565,15 @@ static int htc_issue_rxpkt_bundle(struct htc_target *target,
|
|
* This would only happen if the target ignored our max
|
|
* This would only happen if the target ignored our max
|
|
* bundle limit.
|
|
* bundle limit.
|
|
*/
|
|
*/
|
|
- ath6kl_warn("htc_issue_rxpkt_bundle : partial bundle detected num:%d , %d\n",
|
|
|
|
- get_queue_depth(rxq), n_scat_pkt);
|
|
|
|
|
|
+ ath6kl_warn("%s(): partial bundle detected num:%d , %d\n",
|
|
|
|
+ __func__, get_queue_depth(rxq), n_scat_pkt);
|
|
}
|
|
}
|
|
|
|
|
|
len = 0;
|
|
len = 0;
|
|
|
|
|
|
ath6kl_dbg(ATH6KL_DBG_HTC_RECV,
|
|
ath6kl_dbg(ATH6KL_DBG_HTC_RECV,
|
|
- "htc_issue_rxpkt_bundle (numpackets: %d , actual : %d)\n",
|
|
|
|
- get_queue_depth(rxq), n_scat_pkt);
|
|
|
|
|
|
+ "%s(): (numpackets: %d , actual : %d)\n",
|
|
|
|
+ __func__, get_queue_depth(rxq), n_scat_pkt);
|
|
|
|
|
|
scat_req = hif_scatter_req_get(target->dev->ar);
|
|
scat_req = hif_scatter_req_get(target->dev->ar);
|
|
|
|
|
|
@@ -1616,9 +1633,10 @@ fail_rx_pkt:
|
|
return status;
|
|
return status;
|
|
}
|
|
}
|
|
|
|
|
|
-static int htc_proc_fetched_rxpkts(struct htc_target *target,
|
|
|
|
- struct list_head *comp_pktq, u32 lk_ahds[],
|
|
|
|
- int *n_lk_ahd)
|
|
|
|
|
|
+static int ath6kl_htc_rx_process_packets(struct htc_target *target,
|
|
|
|
+ struct list_head *comp_pktq,
|
|
|
|
+ u32 lk_ahds[],
|
|
|
|
+ int *n_lk_ahd)
|
|
{
|
|
{
|
|
struct htc_packet *packet, *tmp_pkt;
|
|
struct htc_packet *packet, *tmp_pkt;
|
|
struct htc_endpoint *ep;
|
|
struct htc_endpoint *ep;
|
|
@@ -1629,7 +1647,8 @@ static int htc_proc_fetched_rxpkts(struct htc_target *target,
|
|
ep = &target->endpoint[packet->endpoint];
|
|
ep = &target->endpoint[packet->endpoint];
|
|
|
|
|
|
/* process header for each of the recv packet */
|
|
/* process header for each of the recv packet */
|
|
- status = htc_proc_rxhdr(target, packet, lk_ahds, n_lk_ahd);
|
|
|
|
|
|
+ status = ath6kl_htc_rx_process_hdr(target, packet, lk_ahds,
|
|
|
|
+ n_lk_ahd);
|
|
if (status)
|
|
if (status)
|
|
return status;
|
|
return status;
|
|
|
|
|
|
@@ -1639,8 +1658,8 @@ static int htc_proc_fetched_rxpkts(struct htc_target *target,
|
|
* based on the lookahead.
|
|
* based on the lookahead.
|
|
*/
|
|
*/
|
|
if (*n_lk_ahd > 0)
|
|
if (*n_lk_ahd > 0)
|
|
- set_rxpkt_indication_flag(lk_ahds[0],
|
|
|
|
- ep, packet);
|
|
|
|
|
|
+ ath6kl_htc_rx_set_indicate(lk_ahds[0],
|
|
|
|
+ ep, packet);
|
|
} else
|
|
} else
|
|
/*
|
|
/*
|
|
* Packets in a bundle automatically have
|
|
* Packets in a bundle automatically have
|
|
@@ -1649,20 +1668,20 @@ static int htc_proc_fetched_rxpkts(struct htc_target *target,
|
|
packet->info.rx.indicat_flags |=
|
|
packet->info.rx.indicat_flags |=
|
|
HTC_RX_FLAGS_INDICATE_MORE_PKTS;
|
|
HTC_RX_FLAGS_INDICATE_MORE_PKTS;
|
|
|
|
|
|
- htc_update_rx_stats(ep, *n_lk_ahd);
|
|
|
|
|
|
+ ath6kl_htc_rx_update_stats(ep, *n_lk_ahd);
|
|
|
|
|
|
if (packet->info.rx.rx_flags & HTC_RX_PKT_PART_OF_BUNDLE)
|
|
if (packet->info.rx.rx_flags & HTC_RX_PKT_PART_OF_BUNDLE)
|
|
ep->ep_st.rx_bundl += 1;
|
|
ep->ep_st.rx_bundl += 1;
|
|
|
|
|
|
- do_rx_completion(ep, packet);
|
|
|
|
|
|
+ ath6kl_htc_rx_complete(ep, packet);
|
|
}
|
|
}
|
|
|
|
|
|
return status;
|
|
return status;
|
|
}
|
|
}
|
|
|
|
|
|
-static int htc_fetch_rxpkts(struct htc_target *target,
|
|
|
|
- struct list_head *rx_pktq,
|
|
|
|
- struct list_head *comp_pktq)
|
|
|
|
|
|
+static int ath6kl_htc_rx_fetch(struct htc_target *target,
|
|
|
|
+ struct list_head *rx_pktq,
|
|
|
|
+ struct list_head *comp_pktq)
|
|
{
|
|
{
|
|
int fetched_pkts;
|
|
int fetched_pkts;
|
|
bool part_bundle = false;
|
|
bool part_bundle = false;
|
|
@@ -1678,10 +1697,10 @@ static int htc_fetch_rxpkts(struct htc_target *target,
|
|
* bundle transfer and recv bundling is
|
|
* bundle transfer and recv bundling is
|
|
* allowed.
|
|
* allowed.
|
|
*/
|
|
*/
|
|
- status = htc_issue_rxpkt_bundle(target, rx_pktq,
|
|
|
|
- comp_pktq,
|
|
|
|
- &fetched_pkts,
|
|
|
|
- part_bundle);
|
|
|
|
|
|
+ status = ath6kl_htc_rx_bundle(target, rx_pktq,
|
|
|
|
+ comp_pktq,
|
|
|
|
+ &fetched_pkts,
|
|
|
|
+ part_bundle);
|
|
if (status)
|
|
if (status)
|
|
return status;
|
|
return status;
|
|
|
|
|
|
@@ -1710,7 +1729,8 @@ static int htc_fetch_rxpkts(struct htc_target *target,
|
|
HTC_RX_PKT_IGNORE_LOOKAHEAD;
|
|
HTC_RX_PKT_IGNORE_LOOKAHEAD;
|
|
|
|
|
|
/* go fetch the packet */
|
|
/* go fetch the packet */
|
|
- status = dev_rx_pkt(target, packet, packet->act_len);
|
|
|
|
|
|
+ status = ath6kl_htc_rx_packet(target, packet,
|
|
|
|
+ packet->act_len);
|
|
if (status)
|
|
if (status)
|
|
return status;
|
|
return status;
|
|
|
|
|
|
@@ -1764,9 +1784,9 @@ int ath6kl_htc_rxmsg_pending_handler(struct htc_target *target,
|
|
* Try to allocate as many HTC RX packets indicated by the
|
|
* Try to allocate as many HTC RX packets indicated by the
|
|
* look_aheads.
|
|
* look_aheads.
|
|
*/
|
|
*/
|
|
- status = alloc_and_prep_rxpkts(target, look_aheads,
|
|
|
|
- num_look_ahead, endpoint,
|
|
|
|
- &rx_pktq);
|
|
|
|
|
|
+ status = ath6kl_htc_rx_alloc(target, look_aheads,
|
|
|
|
+ num_look_ahead, endpoint,
|
|
|
|
+ &rx_pktq);
|
|
if (status)
|
|
if (status)
|
|
break;
|
|
break;
|
|
|
|
|
|
@@ -1781,14 +1801,15 @@ int ath6kl_htc_rxmsg_pending_handler(struct htc_target *target,
|
|
|
|
|
|
num_look_ahead = 0;
|
|
num_look_ahead = 0;
|
|
|
|
|
|
- status = htc_fetch_rxpkts(target, &rx_pktq, &comp_pktq);
|
|
|
|
|
|
+ status = ath6kl_htc_rx_fetch(target, &rx_pktq, &comp_pktq);
|
|
|
|
|
|
if (!status)
|
|
if (!status)
|
|
- chk_rx_water_mark(endpoint);
|
|
|
|
|
|
+ ath6kl_htc_rx_chk_water_mark(endpoint);
|
|
|
|
|
|
/* Process fetched packets */
|
|
/* Process fetched packets */
|
|
- status = htc_proc_fetched_rxpkts(target, &comp_pktq,
|
|
|
|
- look_aheads, &num_look_ahead);
|
|
|
|
|
|
+ status = ath6kl_htc_rx_process_packets(target, &comp_pktq,
|
|
|
|
+ look_aheads,
|
|
|
|
+ &num_look_ahead);
|
|
|
|
|
|
if (!num_look_ahead || status)
|
|
if (!num_look_ahead || status)
|
|
break;
|
|
break;
|
|
@@ -1881,14 +1902,14 @@ static struct htc_packet *htc_wait_for_ctrl_msg(struct htc_target *target)
|
|
packet->completion = NULL;
|
|
packet->completion = NULL;
|
|
|
|
|
|
/* get the message from the device, this will block */
|
|
/* get the message from the device, this will block */
|
|
- if (dev_rx_pkt(target, packet, packet->act_len))
|
|
|
|
|
|
+ if (ath6kl_htc_rx_packet(target, packet, packet->act_len))
|
|
goto fail_ctrl_rx;
|
|
goto fail_ctrl_rx;
|
|
|
|
|
|
/* process receive header */
|
|
/* process receive header */
|
|
- packet->status = htc_proc_rxhdr(target, packet, NULL, NULL);
|
|
|
|
|
|
+ packet->status = ath6kl_htc_rx_process_hdr(target, packet, NULL, NULL);
|
|
|
|
|
|
if (packet->status) {
|
|
if (packet->status) {
|
|
- ath6kl_err("htc_wait_for_ctrl_msg, htc_proc_rxhdr failed (status = %d)\n",
|
|
|
|
|
|
+ ath6kl_err("htc_wait_for_ctrl_msg, ath6kl_htc_rx_process_hdr failed (status = %d)\n",
|
|
packet->status);
|
|
packet->status);
|
|
goto fail_ctrl_rx;
|
|
goto fail_ctrl_rx;
|
|
}
|
|
}
|
|
@@ -1935,7 +1956,7 @@ int ath6kl_htc_add_rxbuf_multiple(struct htc_target *target,
|
|
list_for_each_entry_safe(packet, tmp_pkt, pkt_queue, list) {
|
|
list_for_each_entry_safe(packet, tmp_pkt, pkt_queue, list) {
|
|
packet->status = -ECANCELED;
|
|
packet->status = -ECANCELED;
|
|
list_del(&packet->list);
|
|
list_del(&packet->list);
|
|
- do_rx_completion(endpoint, packet);
|
|
|
|
|
|
+ ath6kl_htc_rx_complete(endpoint, packet);
|
|
}
|
|
}
|
|
|
|
|
|
return status;
|
|
return status;
|
|
@@ -2034,8 +2055,8 @@ int ath6kl_htc_conn_service(struct htc_target *target,
|
|
|
|
|
|
/* we want synchronous operation */
|
|
/* we want synchronous operation */
|
|
tx_pkt->completion = NULL;
|
|
tx_pkt->completion = NULL;
|
|
- htc_prep_send_pkt(tx_pkt, 0, 0, 0);
|
|
|
|
- status = htc_issue_send(target, tx_pkt);
|
|
|
|
|
|
+ ath6kl_htc_tx_prep_pkt(tx_pkt, 0, 0, 0);
|
|
|
|
+ status = ath6kl_htc_tx_issue(target, tx_pkt);
|
|
|
|
|
|
if (status)
|
|
if (status)
|
|
goto fail_tx;
|
|
goto fail_tx;
|