2012-06-19 17:15:42 -06:00
|
|
|
/*****************************************************************************
|
|
|
|
|
|
|
|
(c) Cambridge Silicon Radio Limited 2011
|
|
|
|
All rights reserved and confidential information of CSR
|
|
|
|
|
|
|
|
Refer to LICENSE.txt included with this source for details
|
|
|
|
on the license terms.
|
|
|
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ---------------------------------------------------------------------------
|
|
|
|
* FILE: csr_wifi_hip_card_udi.c
|
|
|
|
*
|
|
|
|
* PURPOSE:
|
|
|
|
* Maintain a list of callbacks to log UniFi exchanges to one or more
|
|
|
|
* debug/monitoring client applications.
|
|
|
|
*
|
|
|
|
* NOTES:
|
|
|
|
* Just call the UDI driver log fn directly for now.
|
|
|
|
* When done properly, each open() on the UDI device will install
|
|
|
|
* a log function. We will call all log fns whenever a signal is written
|
|
|
|
* to or read form the UniFi.
|
|
|
|
*
|
|
|
|
* ---------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#include "csr_wifi_hip_unifi.h"
|
|
|
|
#include "csr_wifi_hip_card.h"
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ---------------------------------------------------------------------------
|
|
|
|
* unifi_print_status
|
|
|
|
*
|
|
|
|
* Print status info to given character buffer.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* None.
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* None.
|
|
|
|
* ---------------------------------------------------------------------------
|
|
|
|
*/
|
2012-07-20 13:22:32 -06:00
|
|
|
s32 unifi_print_status(card_t *card, char *str, s32 *remain)
|
2012-06-19 17:15:42 -06:00
|
|
|
{
|
2012-07-20 13:22:32 -06:00
|
|
|
char *p = str;
|
2012-06-19 17:15:42 -06:00
|
|
|
sdio_config_data_t *cfg;
|
2012-07-20 13:00:10 -06:00
|
|
|
u16 i, n;
|
2012-07-20 13:07:25 -06:00
|
|
|
s32 remaining = *remain;
|
|
|
|
s32 written;
|
2012-06-19 17:15:42 -06:00
|
|
|
#ifdef CSR_UNSAFE_SDIO_ACCESS
|
2012-07-20 13:07:25 -06:00
|
|
|
s32 iostate;
|
2012-06-19 17:15:42 -06:00
|
|
|
CsrResult r;
|
2012-07-20 13:22:32 -06:00
|
|
|
static const char *const states[] = {
|
2012-06-19 17:15:42 -06:00
|
|
|
"AWAKE", "DROWSY", "TORPID"
|
|
|
|
};
|
|
|
|
#define SHARED_READ_RETRY_LIMIT 10
|
2012-07-20 12:51:01 -06:00
|
|
|
u8 b;
|
2012-06-19 17:15:42 -06:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (remaining <= 0)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
i = n = 0;
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "Chip ID %u\n",
|
2012-07-20 13:00:10 -06:00
|
|
|
(u16)card->chip_id);
|
2012-06-19 17:15:42 -06:00
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "Chip Version %04X\n",
|
2012-06-19 17:15:42 -06:00
|
|
|
card->chip_version);
|
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "HIP v%u.%u\n",
|
2012-06-19 17:15:42 -06:00
|
|
|
(card->config_data.version >> 8) & 0xFF,
|
|
|
|
card->config_data.version & 0xFF);
|
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "Build %u: %s\n",
|
2012-06-19 17:15:42 -06:00
|
|
|
card->build_id, card->build_id_string);
|
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
|
|
|
|
|
|
|
cfg = &card->config_data;
|
|
|
|
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "sdio ctrl offset %u\n",
|
2012-06-19 17:15:42 -06:00
|
|
|
cfg->sdio_ctrl_offset);
|
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "fromhost sigbuf handle %u\n",
|
2012-06-19 17:15:42 -06:00
|
|
|
cfg->fromhost_sigbuf_handle);
|
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "tohost_sigbuf_handle %u\n",
|
2012-06-19 17:15:42 -06:00
|
|
|
cfg->tohost_sigbuf_handle);
|
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "num_fromhost_sig_frags %u\n",
|
2012-06-19 17:15:42 -06:00
|
|
|
cfg->num_fromhost_sig_frags);
|
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "num_tohost_sig_frags %u\n",
|
2012-06-19 17:15:42 -06:00
|
|
|
cfg->num_tohost_sig_frags);
|
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "num_fromhost_data_slots %u\n",
|
2012-06-19 17:15:42 -06:00
|
|
|
cfg->num_fromhost_data_slots);
|
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "num_tohost_data_slots %u\n",
|
2012-06-19 17:15:42 -06:00
|
|
|
cfg->num_tohost_data_slots);
|
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "data_slot_size %u\n",
|
2012-06-19 17:15:42 -06:00
|
|
|
cfg->data_slot_size);
|
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
|
|
|
|
|
|
|
/* Added by protocol version 0x0001 */
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "overlay_size %u\n",
|
2012-07-20 13:00:10 -06:00
|
|
|
(u16)cfg->overlay_size);
|
2012-06-19 17:15:42 -06:00
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
|
|
|
|
|
|
|
/* Added by protocol version 0x0300 */
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "data_slot_round %u\n",
|
2012-06-19 17:15:42 -06:00
|
|
|
cfg->data_slot_round);
|
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "sig_frag_size %u\n",
|
2012-06-19 17:15:42 -06:00
|
|
|
cfg->sig_frag_size);
|
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
|
|
|
|
|
|
|
/* Added by protocol version 0x0300 */
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "tohost_sig_pad %u\n",
|
2012-06-19 17:15:42 -06:00
|
|
|
cfg->tohost_signal_padding);
|
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
|
|
|
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "\nInternal state:\n");
|
2012-06-19 17:15:42 -06:00
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
|
|
|
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "Last PHY PANIC: %04x:%04x\n",
|
2012-06-19 17:15:42 -06:00
|
|
|
card->last_phy_panic_code, card->last_phy_panic_arg);
|
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "Last MAC PANIC: %04x:%04x\n",
|
2012-06-19 17:15:42 -06:00
|
|
|
card->last_mac_panic_code, card->last_mac_panic_arg);
|
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
|
|
|
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "fhsr: %u\n",
|
2012-07-20 13:00:10 -06:00
|
|
|
(u16)card->from_host_signals_r);
|
2012-06-19 17:15:42 -06:00
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "fhsw: %u\n",
|
2012-07-20 13:00:10 -06:00
|
|
|
(u16)card->from_host_signals_w);
|
2012-06-19 17:15:42 -06:00
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "thsr: %u\n",
|
2012-07-20 13:00:10 -06:00
|
|
|
(u16)card->to_host_signals_r);
|
2012-06-19 17:15:42 -06:00
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "thsw: %u\n",
|
2012-07-20 13:00:10 -06:00
|
|
|
(u16)card->to_host_signals_w);
|
2012-06-19 17:15:42 -06:00
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining,
|
2012-09-17 11:33:18 -06:00
|
|
|
"fh buffer contains: %d signals, %td bytes\n",
|
2012-06-19 17:15:42 -06:00
|
|
|
card->fh_buffer.count,
|
|
|
|
card->fh_buffer.ptr - card->fh_buffer.buf);
|
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
|
|
|
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "paused: ");
|
2012-06-19 17:15:42 -06:00
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
|
|
|
for (i = 0; i < sizeof(card->tx_q_paused_flag) / sizeof(card->tx_q_paused_flag[0]); i++)
|
|
|
|
{
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, card->tx_q_paused_flag[i]?"1" : "0");
|
2012-06-19 17:15:42 -06:00
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
|
|
|
}
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "\n");
|
2012-06-19 17:15:42 -06:00
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
|
|
|
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining,
|
2012-06-19 17:15:42 -06:00
|
|
|
"fh command q: %u waiting, %u free of %u:\n",
|
|
|
|
CSR_WIFI_HIP_Q_SLOTS_USED(&card->fh_command_queue),
|
|
|
|
CSR_WIFI_HIP_Q_SLOTS_FREE(&card->fh_command_queue),
|
|
|
|
UNIFI_SOFT_COMMAND_Q_LENGTH);
|
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
|
|
|
for (i = 0; i < UNIFI_NO_OF_TX_QS; i++)
|
|
|
|
{
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining,
|
2012-06-19 17:15:42 -06:00
|
|
|
"fh traffic q[%u]: %u waiting, %u free of %u:\n",
|
|
|
|
i,
|
|
|
|
CSR_WIFI_HIP_Q_SLOTS_USED(&card->fh_traffic_queue[i]),
|
|
|
|
CSR_WIFI_HIP_Q_SLOTS_FREE(&card->fh_traffic_queue[i]),
|
|
|
|
UNIFI_SOFT_TRAFFIC_Q_LENGTH);
|
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
|
|
|
}
|
|
|
|
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "fh data slots free: %u\n",
|
2012-06-19 17:15:42 -06:00
|
|
|
card->from_host_data?CardGetFreeFromHostDataSlots(card) : 0);
|
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
|
|
|
|
|
|
|
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "From host data slots:");
|
2012-06-19 17:15:42 -06:00
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
|
|
|
n = card->config_data.num_fromhost_data_slots;
|
|
|
|
for (i = 0; i < n && card->from_host_data; i++)
|
|
|
|
{
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, " %u",
|
2012-07-20 13:00:10 -06:00
|
|
|
(u16)card->from_host_data[i].bd.data_length);
|
2012-06-19 17:15:42 -06:00
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
|
|
|
}
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "\n");
|
2012-06-19 17:15:42 -06:00
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
|
|
|
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "To host data slots:");
|
2012-06-19 17:15:42 -06:00
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
|
|
|
n = card->config_data.num_tohost_data_slots;
|
|
|
|
for (i = 0; i < n && card->to_host_data; i++)
|
|
|
|
{
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, " %u",
|
2012-07-20 13:00:10 -06:00
|
|
|
(u16)card->to_host_data[i].data_length);
|
2012-06-19 17:15:42 -06:00
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
|
|
|
}
|
|
|
|
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "\n");
|
2012-06-19 17:15:42 -06:00
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
|
|
|
|
|
|
|
#ifdef CSR_UNSAFE_SDIO_ACCESS
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "Host State: %s\n", states[card->host_state]);
|
2012-06-19 17:15:42 -06:00
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
|
|
|
|
|
|
|
r = unifi_check_io_status(card, &iostate);
|
|
|
|
if (iostate == 1)
|
|
|
|
{
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "I/O Check: F1 disabled\n");
|
2012-06-19 17:15:42 -06:00
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (iostate == 1)
|
|
|
|
{
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "I/O Check: pending interrupt\n");
|
2012-06-19 17:15:42 -06:00
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
|
|
|
}
|
|
|
|
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "BH reason interrupt = %d\n",
|
2012-06-19 17:15:42 -06:00
|
|
|
card->bh_reason_unifi);
|
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "BH reason host = %d\n",
|
2012-06-19 17:15:42 -06:00
|
|
|
card->bh_reason_host);
|
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
|
|
|
|
|
|
|
for (i = 0; i < SHARED_READ_RETRY_LIMIT; i++)
|
|
|
|
{
|
|
|
|
r = unifi_read_8_or_16(card, card->sdio_ctrl_addr + 2, &b);
|
|
|
|
if ((r == CSR_RESULT_SUCCESS) && (!(b & 0x80)))
|
|
|
|
{
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "fhsr: %u (driver thinks is %u)\n",
|
2012-06-19 17:15:42 -06:00
|
|
|
b, card->from_host_signals_r);
|
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
iostate = unifi_read_shared_count(card, card->sdio_ctrl_addr + 4);
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "thsw: %u (driver thinks is %u)\n",
|
2012-06-19 17:15:42 -06:00
|
|
|
iostate, card->to_host_signals_w);
|
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "\nStats:\n");
|
2012-06-19 17:15:42 -06:00
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "Total SDIO bytes: R=%u W=%u\n",
|
2012-06-19 17:15:42 -06:00
|
|
|
card->sdio_bytes_read, card->sdio_bytes_written);
|
|
|
|
|
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
2012-08-16 10:20:03 -06:00
|
|
|
written = scnprintf(p, remaining, "Interrupts generated on card: %u\n",
|
2012-06-19 17:15:42 -06:00
|
|
|
card->unifi_interrupt_seq);
|
|
|
|
UNIFI_SNPRINTF_RET(p, remaining, written);
|
|
|
|
|
|
|
|
*remain = remaining;
|
|
|
|
return (p - str);
|
|
|
|
} /* unifi_print_status() */
|
|
|
|
|
|
|
|
|