Skip to content

Commit

Permalink
ath10k: register per copy engine receive callbacks
Browse files Browse the repository at this point in the history
Register receive callbacks for every copy engines (CE) separately
instead of having common receive handler. Some of the copy engines
receives different type of messages (i.e HTT/HTC/pktlog) from target.
Hence to service them accordingly, register per copy engine receive
callbacks.

Reviewed-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Rajkumar Manoharan <rmanohar@qti.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
  • Loading branch information
Rajkumar Manoharan authored and Kalle Valo committed Oct 16, 2015
1 parent 0e5b295 commit 9d9bdbb
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 51 deletions.
5 changes: 2 additions & 3 deletions drivers/net/wireless/ath/ath10k/ce.c
Original file line number Diff line number Diff line change
Expand Up @@ -1076,8 +1076,7 @@ void ath10k_ce_deinit_pipe(struct ath10k *ar, unsigned int ce_id)
}

int ath10k_ce_alloc_pipe(struct ath10k *ar, int ce_id,
const struct ce_attr *attr,
void (*recv_cb)(struct ath10k_ce_pipe *))
const struct ce_attr *attr)
{
struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
struct ath10k_ce_pipe *ce_state = &ar_pci->ce_states[ce_id];
Expand Down Expand Up @@ -1106,7 +1105,7 @@ int ath10k_ce_alloc_pipe(struct ath10k *ar, int ce_id,
ce_state->send_cb = attr->send_cb;

if (attr->dest_nentries)
ce_state->recv_cb = recv_cb;
ce_state->recv_cb = attr->recv_cb;

if (attr->src_nentries) {
ce_state->src_ring = ath10k_ce_alloc_src_ring(ar, ce_id, attr);
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/wireless/ath/ath10k/ce.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,7 @@ int ath10k_ce_init_pipe(struct ath10k *ar, unsigned int ce_id,
const struct ce_attr *attr);
void ath10k_ce_deinit_pipe(struct ath10k *ar, unsigned int ce_id);
int ath10k_ce_alloc_pipe(struct ath10k *ar, int ce_id,
const struct ce_attr *attr,
void (*recv_cb)(struct ath10k_ce_pipe *));
const struct ce_attr *attr);
void ath10k_ce_free_pipe(struct ath10k *ar, int ce_id);

/*==================CE Engine Shutdown=======================*/
Expand Down Expand Up @@ -278,6 +277,7 @@ struct ce_attr {
unsigned int dest_nentries;

void (*send_cb)(struct ath10k_ce_pipe *);
void (*recv_cb)(struct ath10k_ce_pipe *);
};

#define SR_BA_ADDRESS 0x0000
Expand Down
14 changes: 0 additions & 14 deletions drivers/net/wireless/ath/ath10k/hif.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ struct ath10k_hif_sg_item {
u16 len;
};

struct ath10k_hif_cb {
int (*rx_completion)(struct ath10k *ar,
struct sk_buff *wbuf);
};

struct ath10k_hif_ops {
/* send a scatter-gather list to the target */
int (*tx_sg)(struct ath10k *ar, u8 pipe_id,
Expand Down Expand Up @@ -78,9 +73,6 @@ struct ath10k_hif_ops {
*/
void (*send_complete_check)(struct ath10k *ar, u8 pipe_id, int force);

void (*set_callbacks)(struct ath10k *ar,
struct ath10k_hif_cb *callbacks);

u16 (*get_free_queue_number)(struct ath10k *ar, u8 pipe_id);

u32 (*read32)(struct ath10k *ar, u32 address);
Expand Down Expand Up @@ -161,12 +153,6 @@ 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_set_callbacks(struct ath10k *ar,
struct ath10k_hif_cb *callbacks)
{
ar->hif.ops->set_callbacks(ar, callbacks);
}

static inline u16 ath10k_hif_get_free_queue_number(struct ath10k *ar,
u8 pipe_id)
{
Expand Down
13 changes: 1 addition & 12 deletions drivers/net/wireless/ath/ath10k/htc.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ static int ath10k_htc_process_trailer(struct ath10k_htc *htc,
return status;
}

int ath10k_htc_rx_completion_handler(struct ath10k *ar, struct sk_buff *skb)
void ath10k_htc_rx_completion_handler(struct ath10k *ar, struct sk_buff *skb)
{
int status = 0;
struct ath10k_htc *htc = &ar->htc;
Expand All @@ -323,7 +323,6 @@ int ath10k_htc_rx_completion_handler(struct ath10k *ar, struct sk_buff *skb)
ath10k_warn(ar, "HTC Rx: invalid eid %d\n", eid);
ath10k_dbg_dump(ar, ATH10K_DBG_HTC, "htc bad header", "",
hdr, sizeof(*hdr));
status = -EINVAL;
goto out;
}

Expand All @@ -345,7 +344,6 @@ int ath10k_htc_rx_completion_handler(struct ath10k *ar, struct sk_buff *skb)
payload_len + sizeof(*hdr));
ath10k_dbg_dump(ar, ATH10K_DBG_HTC, "htc bad rx pkt len", "",
hdr, sizeof(*hdr));
status = -EINVAL;
goto out;
}

Expand All @@ -355,7 +353,6 @@ int ath10k_htc_rx_completion_handler(struct ath10k *ar, struct sk_buff *skb)
skb->len, payload_len);
ath10k_dbg_dump(ar, ATH10K_DBG_HTC, "htc bad rx pkt len",
"", hdr, sizeof(*hdr));
status = -EINVAL;
goto out;
}

Expand All @@ -371,7 +368,6 @@ int ath10k_htc_rx_completion_handler(struct ath10k *ar, struct sk_buff *skb)
(trailer_len > payload_len)) {
ath10k_warn(ar, "Invalid trailer length: %d\n",
trailer_len);
status = -EPROTO;
goto out;
}

Expand Down Expand Up @@ -404,7 +400,6 @@ int ath10k_htc_rx_completion_handler(struct ath10k *ar, struct sk_buff *skb)
* sending unsolicited messages on the ep 0
*/
ath10k_warn(ar, "HTC rx ctrl still processing\n");
status = -EINVAL;
complete(&htc->ctl_resp);
goto out;
}
Expand Down Expand Up @@ -436,8 +431,6 @@ int ath10k_htc_rx_completion_handler(struct ath10k *ar, struct sk_buff *skb)
skb = NULL;
out:
kfree_skb(skb);

return status;
}
EXPORT_SYMBOL(ath10k_htc_rx_completion_handler);

Expand Down Expand Up @@ -839,22 +832,18 @@ int ath10k_htc_start(struct ath10k_htc *htc)
/* registered target arrival callback from the HIF layer */
int ath10k_htc_init(struct ath10k *ar)
{
struct ath10k_hif_cb htc_callbacks;
struct ath10k_htc_ep *ep = NULL;
struct ath10k_htc *htc = &ar->htc;

spin_lock_init(&htc->tx_lock);

ath10k_htc_reset_endpoint_states(htc);

/* setup HIF layer callbacks */
htc_callbacks.rx_completion = ath10k_htc_rx_completion_handler;
htc->ar = ar;

/* Get HIF default pipe for HTC message exchange */
ep = &htc->endpoint[ATH10K_HTC_EP_0];

ath10k_hif_set_callbacks(ar, &htc_callbacks);
ath10k_hif_get_default_pipe(ar, &ep->ul_pipe_id, &ep->dl_pipe_id);

init_completion(&htc->ctl_resp);
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/ath/ath10k/htc.h
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,6 @@ int ath10k_htc_send(struct ath10k_htc *htc, enum ath10k_htc_ep_id eid,
struct sk_buff *packet);
struct sk_buff *ath10k_htc_alloc_skb(struct ath10k *ar, int size);
void ath10k_htc_tx_completion_handler(struct ath10k *ar, struct sk_buff *skb);
int ath10k_htc_rx_completion_handler(struct ath10k *ar, struct sk_buff *skb);
void ath10k_htc_rx_completion_handler(struct ath10k *ar, struct sk_buff *skb);

#endif
23 changes: 6 additions & 17 deletions drivers/net/wireless/ath/ath10k/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ static int ath10k_pci_bmi_wait(struct ath10k_ce_pipe *tx_pipe,
struct bmi_xfer *xfer);
static int ath10k_pci_qca99x0_chip_reset(struct ath10k *ar);
static void ath10k_pci_htc_tx_cb(struct ath10k_ce_pipe *ce_state);
static void ath10k_pci_htc_rx_cb(struct ath10k_ce_pipe *ce_state);

static const struct ce_attr host_ce_config_wlan[] = {
/* CE0: host->target HTC control and raw streams */
Expand All @@ -122,6 +123,7 @@ static const struct ce_attr host_ce_config_wlan[] = {
.src_nentries = 0,
.src_sz_max = 2048,
.dest_nentries = 512,
.recv_cb = ath10k_pci_htc_rx_cb,
},

/* CE2: target->host WMI */
Expand All @@ -130,6 +132,7 @@ static const struct ce_attr host_ce_config_wlan[] = {
.src_nentries = 0,
.src_sz_max = 2048,
.dest_nentries = 128,
.recv_cb = ath10k_pci_htc_rx_cb,
},

/* CE3: host->target WMI */
Expand Down Expand Up @@ -1123,12 +1126,11 @@ static void ath10k_pci_htc_tx_cb(struct ath10k_ce_pipe *ce_state)
}

/* Called by lower (CE) layer when data is received from the Target. */
static void ath10k_pci_ce_recv_data(struct ath10k_ce_pipe *ce_state)
static void ath10k_pci_htc_rx_cb(struct ath10k_ce_pipe *ce_state)
{
struct ath10k *ar = ce_state->ar;
struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
struct ath10k_pci_pipe *pipe_info = &ar_pci->pipe_info[ce_state->id];
struct ath10k_hif_cb *cb = &ar_pci->msg_callbacks_current;
struct sk_buff *skb;
struct sk_buff_head list;
void *transfer_context;
Expand Down Expand Up @@ -1163,7 +1165,7 @@ static void ath10k_pci_ce_recv_data(struct ath10k_ce_pipe *ce_state)
ath10k_dbg_dump(ar, ATH10K_DBG_PCI_DUMP, NULL, "pci rx: ",
skb->data, skb->len);

cb->rx_completion(ar, skb);
ath10k_htc_rx_completion_handler(ar, skb);
}

ath10k_pci_rx_post_pipe(pipe_info);
Expand Down Expand Up @@ -1338,17 +1340,6 @@ static void ath10k_pci_hif_send_complete_check(struct ath10k *ar, u8 pipe,
ath10k_ce_per_engine_service(ar, pipe);
}

static void ath10k_pci_hif_set_callbacks(struct ath10k *ar,
struct ath10k_hif_cb *callbacks)
{
struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);

ath10k_dbg(ar, ATH10K_DBG_PCI, "pci hif set callbacks\n");

memcpy(&ar_pci->msg_callbacks_current, callbacks,
sizeof(ar_pci->msg_callbacks_current));
}

static void ath10k_pci_kill_tasklet(struct ath10k *ar)
{
struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
Expand Down Expand Up @@ -1995,8 +1986,7 @@ static int ath10k_pci_alloc_pipes(struct ath10k *ar)
pipe->pipe_num = i;
pipe->hif_ce_state = ar;

ret = ath10k_ce_alloc_pipe(ar, i, &host_ce_config_wlan[i],
ath10k_pci_ce_recv_data);
ret = ath10k_ce_alloc_pipe(ar, i, &host_ce_config_wlan[i]);
if (ret) {
ath10k_err(ar, "failed to allocate copy engine pipe %d: %d\n",
i, ret);
Expand Down Expand Up @@ -2416,7 +2406,6 @@ 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,
.set_callbacks = ath10k_pci_hif_set_callbacks,
.get_free_queue_number = ath10k_pci_hif_get_free_queue_number,
.power_up = ath10k_pci_hif_power_up,
.power_down = ath10k_pci_hif_power_down,
Expand Down
2 changes: 0 additions & 2 deletions drivers/net/wireless/ath/ath10k/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,6 @@ struct ath10k_pci {

struct ath10k_pci_pipe pipe_info[CE_COUNT_MAX];

struct ath10k_hif_cb msg_callbacks_current;

/* Copy Engine used for Diagnostic Accesses */
struct ath10k_ce_pipe *ce_diag;

Expand Down

0 comments on commit 9d9bdbb

Please sign in to comment.