Skip to content

Commit

Permalink
Merge branch 'for-linville' of git://github.com/kvalo/ath
Browse files Browse the repository at this point in the history
  • Loading branch information
John W. Linville committed Sep 26, 2014
2 parents d3d3e00 + b25f32c commit 687b930
Show file tree
Hide file tree
Showing 28 changed files with 1,017 additions and 440 deletions.
2 changes: 1 addition & 1 deletion drivers/net/wireless/ath/ath10k/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ config ATH10K_DEBUG

config ATH10K_DEBUGFS
bool "Atheros ath10k debugfs support"
depends on ATH10K
depends on ATH10K && DEBUG_FS
select RELAY
---help---
Enabled debugfs support
Expand Down
1 change: 1 addition & 0 deletions drivers/net/wireless/ath/ath10k/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ ath10k_core-y += mac.o \
bmi.o

ath10k_core-$(CONFIG_ATH10K_DEBUGFS) += spectral.o
ath10k_core-$(CONFIG_NL80211_TESTMODE) += testmode.o
ath10k_core-$(CONFIG_ATH10K_TRACING) += trace.o

obj-$(CONFIG_ATH10K_PCI) += ath10k_pci.o
Expand Down
1 change: 0 additions & 1 deletion drivers/net/wireless/ath/ath10k/bmi.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ struct bmi_target_info {
u32 type;
};


/* in msec */
#define BMI_COMMUNICATION_TIMEOUT_HZ (1*HZ)

Expand Down
2 changes: 0 additions & 2 deletions drivers/net/wireless/ath/ath10k/ce.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ static inline void ath10k_ce_engine_int_status_clear(struct ath10k *ar,
ath10k_pci_write32(ar, ce_ctrl_addr + HOST_IS_ADDRESS, mask);
}


/*
* Guts of ath10k_ce_send, used by both ath10k_ce_send and
* ath10k_ce_sendlist_send.
Expand Down Expand Up @@ -385,7 +384,6 @@ int ath10k_ce_num_free_src_entries(struct ath10k_ce_pipe *pipe)
return delta;
}


int __ath10k_ce_rx_num_free_bufs(struct ath10k_ce_pipe *pipe)
{
struct ath10k *ar = pipe->ar;
Expand Down
13 changes: 5 additions & 8 deletions drivers/net/wireless/ath/ath10k/ce.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

#include "hif.h"


/* Maximum number of Copy Engine's supported */
#define CE_COUNT_MAX 8
#define CE_HTT_H2T_MSG_SRC_NENTRIES 4096
Expand All @@ -37,7 +36,6 @@

struct ath10k_ce_pipe;


#define CE_DESC_FLAGS_GATHER (1 << 0)
#define CE_DESC_FLAGS_BYTE_SWAP (1 << 1)
#define CE_DESC_FLAGS_META_DATA_MASK 0xFFFC
Expand Down Expand Up @@ -189,10 +187,10 @@ int ath10k_ce_completed_recv_next(struct ath10k_ce_pipe *ce_state,
* Pops 1 completed send buffer from Source ring.
*/
int ath10k_ce_completed_send_next(struct ath10k_ce_pipe *ce_state,
void **per_transfer_contextp,
u32 *bufferp,
unsigned int *nbytesp,
unsigned int *transfer_idp);
void **per_transfer_contextp,
u32 *bufferp,
unsigned int *nbytesp,
unsigned int *transfer_idp);

/*==================CE Engine Initialization=======================*/

Expand All @@ -202,7 +200,7 @@ int ath10k_ce_init_pipe(struct ath10k *ar, unsigned int ce_id,
void (*recv_cb)(struct ath10k_ce_pipe *));
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);
const struct ce_attr *attr);
void ath10k_ce_free_pipe(struct ath10k *ar, int ce_id);

/*==================CE Engine Shutdown=======================*/
Expand Down Expand Up @@ -383,7 +381,6 @@ struct ce_attr {
#define DST_WATERMARK_HIGH_RESET 0
#define DST_WATERMARK_ADDRESS 0x0050


static inline u32 ath10k_ce_base_address(unsigned int ce_id)
{
return CE0_BASE_ADDRESS + (CE1_BASE_ADDRESS - CE0_BASE_ADDRESS) * ce_id;
Expand Down
106 changes: 76 additions & 30 deletions drivers/net/wireless/ath/ath10k/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "bmi.h"
#include "debug.h"
#include "htt.h"
#include "testmode.h"

unsigned int ath10k_debug_mask;
static bool uart_print;
Expand Down Expand Up @@ -257,21 +258,42 @@ static int ath10k_download_and_run_otp(struct ath10k *ar)
return 0;
}

static int ath10k_download_fw(struct ath10k *ar)
static int ath10k_download_fw(struct ath10k *ar, enum ath10k_firmware_mode mode)
{
u32 address;
u32 address, data_len;
const char *mode_name;
const void *data;
int ret;

address = ar->hw_params.patch_load_addr;

ret = ath10k_bmi_fast_download(ar, address, ar->firmware_data,
ar->firmware_len);
switch (mode) {
case ATH10K_FIRMWARE_MODE_NORMAL:
data = ar->firmware_data;
data_len = ar->firmware_len;
mode_name = "normal";
break;
case ATH10K_FIRMWARE_MODE_UTF:
data = ar->testmode.utf->data;
data_len = ar->testmode.utf->size;
mode_name = "utf";
break;
default:
ath10k_err(ar, "unknown firmware mode: %d\n", mode);
return -EINVAL;
}

ath10k_dbg(ar, ATH10K_DBG_BOOT,
"boot uploading firmware image %p len %d mode %s\n",
data, data_len, mode_name);

ret = ath10k_bmi_fast_download(ar, address, data, data_len);
if (ret) {
ath10k_err(ar, "could not write fw (%d)\n", ret);
goto exit;
ath10k_err(ar, "failed to download %s firmware: %d\n",
mode_name, ret);
return ret;
}

exit:
return ret;
}

Expand Down Expand Up @@ -567,7 +589,8 @@ static int ath10k_core_fetch_firmware_files(struct ath10k *ar)
return 0;
}

static int ath10k_init_download_firmware(struct ath10k *ar)
static int ath10k_init_download_firmware(struct ath10k *ar,
enum ath10k_firmware_mode mode)
{
int ret;

Expand All @@ -583,7 +606,7 @@ static int ath10k_init_download_firmware(struct ath10k *ar)
return ret;
}

ret = ath10k_download_fw(ar);
ret = ath10k_download_fw(ar, mode);
if (ret) {
ath10k_err(ar, "failed to download firmware: %d\n", ret);
return ret;
Expand Down Expand Up @@ -685,12 +708,15 @@ static void ath10k_core_restart(struct work_struct *work)
case ATH10K_STATE_WEDGED:
ath10k_warn(ar, "device is wedged, will not restart\n");
break;
case ATH10K_STATE_UTF:
ath10k_warn(ar, "firmware restart in UTF mode not supported\n");
break;
}

mutex_unlock(&ar->conf_mutex);
}

int ath10k_core_start(struct ath10k *ar)
int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode)
{
int status;

Expand All @@ -703,7 +729,7 @@ int ath10k_core_start(struct ath10k *ar)
goto err;
}

status = ath10k_init_download_firmware(ar);
status = ath10k_init_download_firmware(ar, mode);
if (status)
goto err;

Expand Down Expand Up @@ -760,10 +786,12 @@ int ath10k_core_start(struct ath10k *ar)
goto err_hif_stop;
}

status = ath10k_htt_connect(&ar->htt);
if (status) {
ath10k_err(ar, "failed to connect htt (%d)\n", status);
goto err_hif_stop;
if (mode == ATH10K_FIRMWARE_MODE_NORMAL) {
status = ath10k_htt_connect(&ar->htt);
if (status) {
ath10k_err(ar, "failed to connect htt (%d)\n", status);
goto err_hif_stop;
}
}

status = ath10k_wmi_connect(ar);
Expand All @@ -778,11 +806,13 @@ int ath10k_core_start(struct ath10k *ar)
goto err_hif_stop;
}

status = ath10k_wmi_wait_for_service_ready(ar);
if (status <= 0) {
ath10k_warn(ar, "wmi service ready event not received");
status = -ETIMEDOUT;
goto err_hif_stop;
if (mode == ATH10K_FIRMWARE_MODE_NORMAL) {
status = ath10k_wmi_wait_for_service_ready(ar);
if (status <= 0) {
ath10k_warn(ar, "wmi service ready event not received");
status = -ETIMEDOUT;
goto err_hif_stop;
}
}

ath10k_dbg(ar, ATH10K_DBG_BOOT, "firmware %s booted\n",
Expand All @@ -802,10 +832,13 @@ int ath10k_core_start(struct ath10k *ar)
goto err_hif_stop;
}

status = ath10k_htt_setup(&ar->htt);
if (status) {
ath10k_err(ar, "failed to setup htt: %d\n", status);
goto err_hif_stop;
/* we don't care about HTT in UTF mode */
if (mode == ATH10K_FIRMWARE_MODE_NORMAL) {
status = ath10k_htt_setup(&ar->htt);
if (status) {
ath10k_err(ar, "failed to setup htt: %d\n", status);
goto err_hif_stop;
}
}

status = ath10k_debug_start(ar);
Expand Down Expand Up @@ -861,7 +894,8 @@ void ath10k_core_stop(struct ath10k *ar)
lockdep_assert_held(&ar->conf_mutex);

/* try to suspend target */
if (ar->state != ATH10K_STATE_RESTARTING)
if (ar->state != ATH10K_STATE_RESTARTING &&
ar->state != ATH10K_STATE_UTF)
ath10k_wait_for_suspend(ar, WMI_PDEV_SUSPEND_AND_DISABLE_INTR);

ath10k_debug_stop(ar);
Expand Down Expand Up @@ -914,7 +948,7 @@ static int ath10k_core_probe_fw(struct ath10k *ar)

mutex_lock(&ar->conf_mutex);

ret = ath10k_core_start(ar);
ret = ath10k_core_start(ar, ATH10K_FIRMWARE_MODE_NORMAL);
if (ret) {
ath10k_err(ar, "could not init core (%d)\n", ret);
ath10k_core_free_firmware_files(ar);
Expand Down Expand Up @@ -977,7 +1011,7 @@ static void ath10k_core_register_work(struct work_struct *work)
goto err_release_fw;
}

status = ath10k_debug_create(ar);
status = ath10k_debug_register(ar);
if (status) {
ath10k_err(ar, "unable to initialize debugfs\n");
goto err_unregister_mac;
Expand Down Expand Up @@ -1041,16 +1075,19 @@ void ath10k_core_unregister(struct ath10k *ar)
* unhappy about callback failures. */
ath10k_mac_unregister(ar);

ath10k_testmode_destroy(ar);

ath10k_core_free_firmware_files(ar);

ath10k_debug_destroy(ar);
ath10k_debug_unregister(ar);
}
EXPORT_SYMBOL(ath10k_core_unregister);

struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
const struct ath10k_hif_ops *hif_ops)
{
struct ath10k *ar;
int ret;

ar = ath10k_mac_create(priv_size);
if (!ar)
Expand All @@ -1076,7 +1113,7 @@ struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,

ar->workqueue = create_singlethread_workqueue("ath10k_wq");
if (!ar->workqueue)
goto err_wq;
goto err_free_mac;

mutex_init(&ar->conf_mutex);
spin_lock_init(&ar->data_lock);
Expand All @@ -1094,10 +1131,18 @@ struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
INIT_WORK(&ar->register_work, ath10k_core_register_work);
INIT_WORK(&ar->restart_work, ath10k_core_restart);

ret = ath10k_debug_create(ar);
if (ret)
goto err_free_wq;

return ar;

err_wq:
err_free_wq:
destroy_workqueue(ar->workqueue);

err_free_mac:
ath10k_mac_destroy(ar);

return NULL;
}
EXPORT_SYMBOL(ath10k_core_create);
Expand All @@ -1107,6 +1152,7 @@ void ath10k_core_destroy(struct ath10k *ar)
flush_workqueue(ar->workqueue);
destroy_workqueue(ar->workqueue);

ath10k_debug_destroy(ar);
ath10k_mac_destroy(ar);
}
EXPORT_SYMBOL(ath10k_core_destroy);
Expand Down
25 changes: 22 additions & 3 deletions drivers/net/wireless/ath/ath10k/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ struct ath10k_debug {
struct dentry *debugfs_phy;

struct ath10k_target_stats target_stats;
DECLARE_BITMAP(wmi_service_bitmap, WMI_SERVICE_BM_SIZE);
DECLARE_BITMAP(wmi_service_bitmap, WMI_SERVICE_MAX);

struct completion event_stats_compl;

Expand Down Expand Up @@ -330,6 +330,17 @@ enum ath10k_state {
* prevents completion timeouts and makes the driver more responsive to
* userspace commands. This is also prevents recursive recovery. */
ATH10K_STATE_WEDGED,

/* factory tests */
ATH10K_STATE_UTF,
};

enum ath10k_firmware_mode {
/* the default mode, standard 802.11 functionality */
ATH10K_FIRMWARE_MODE_NORMAL,

/* factory tests etc */
ATH10K_FIRMWARE_MODE_UTF,
};

enum ath10k_fw_features {
Expand Down Expand Up @@ -472,7 +483,6 @@ struct ath10k {
struct cfg80211_chan_def chandef;

int free_vdev_map;
bool promisc;
bool monitor;
int monitor_vdev_id;
bool monitor_started;
Expand Down Expand Up @@ -544,6 +554,15 @@ struct ath10k {
struct ath10k_spec_scan config;
} spectral;

struct {
/* protected by conf_mutex */
const struct firmware *utf;
DECLARE_BITMAP(orig_fw_features, ATH10K_FW_FEATURE_COUNT);

/* protected by data_lock */
bool utf_monitor;
} testmode;

/* must be last */
u8 drv_priv[0] __aligned(sizeof(void *));
};
Expand All @@ -552,7 +571,7 @@ struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
const struct ath10k_hif_ops *hif_ops);
void ath10k_core_destroy(struct ath10k *ar);

int ath10k_core_start(struct ath10k *ar);
int ath10k_core_start(struct ath10k *ar, enum ath10k_firmware_mode mode);
int ath10k_wait_for_suspend(struct ath10k *ar, u32 suspend_opt);
void ath10k_core_stop(struct ath10k *ar);
int ath10k_core_register(struct ath10k *ar, u32 chip_id);
Expand Down
Loading

0 comments on commit 687b930

Please sign in to comment.