|
|
@@ -1,8 +1,8 @@
|
|
|
/* Intel 7265D/3165/8265 firmware command layer: see iwl_mvm.h.
|
|
|
*
|
|
|
* Follows Linux iwlmvm for the 7265D-29 API (no unified image, LMAC scan,
|
|
|
- * DQA queues, old station API, ADD_STA v7, ADD_STA_KEY v1, PHY context v1,
|
|
|
- * MAC context v1, TX_CMD v6, legacy RX_PHY + RX_MPDU). The 8265 uses the
|
|
|
+ * DQA queues, old station API, ADD_STA v7 (v10 on the 8265), ADD_STA_KEY
|
|
|
+ * v1, PHY context v1, MAC context v1, TX_CMD v6, legacy RX_PHY + RX_MPDU). The 8265 uses the
|
|
|
* same command layer with its 8000-family firmware; the transport handles
|
|
|
* the secure section loader and the MAC comes from the extended NVM.
|
|
|
*
|
|
|
@@ -42,12 +42,17 @@
|
|
|
#define PHY_DB_CMD 0x6c
|
|
|
#define SCAN_OFFLOAD_COMPLETE 0x6d
|
|
|
#define POWER_TABLE_CMD 0x77
|
|
|
+#define FW_PAGING_BLOCK_CMD 0x4f
|
|
|
#define NVM_ACCESS_CMD 0x88
|
|
|
#define TX_ANT_CONFIGURATION_CMD 0x98
|
|
|
#define BT_CONFIG 0x9b
|
|
|
#define REPLY_RX_PHY_CMD 0xc0
|
|
|
#define REPLY_RX_MPDU_CMD 0xc1
|
|
|
#define MCC_UPDATE_CMD 0xc8
|
|
|
+/* UMAC scan (IWL_ALWAYS_LONG_GROUP, sent with the wide header as group 1) */
|
|
|
+#define SCAN_CFG_CMD 0x0c
|
|
|
+#define SCAN_REQ_UMAC 0x0d
|
|
|
+#define SCAN_COMPLETE_UMAC 0x0f
|
|
|
#define DQA_ENABLE_CMD ((5u << 8) | 0x00) /* DATA_PATH_GROUP */
|
|
|
|
|
|
#define ACTION_ADD 1
|
|
|
@@ -102,11 +107,7 @@ struct binding_cmd { /* BINDING_CMD_API_S_VER_1 */
|
|
|
unsigned int id_and_color, action, macs[3], phy;
|
|
|
} PACKED;
|
|
|
|
|
|
-struct quota_cmd { /* TIME_QUOTA_ALLOCATION_CMD v1 */
|
|
|
- struct { unsigned int id_and_color, quota, max_duration; } q[4];
|
|
|
-} PACKED;
|
|
|
-
|
|
|
-struct add_sta_cmd { /* ADD_STA_CMD_API_S_VER_7 */
|
|
|
+struct add_sta_cmd { /* ADD_STA_CMD_API_S_VER_10 */
|
|
|
unsigned char add_modify, awake_acs;
|
|
|
unsigned short tid_disable_tx;
|
|
|
unsigned int mac_id_n_color;
|
|
|
@@ -116,9 +117,12 @@ struct add_sta_cmd { /* ADD_STA_CMD_API_S_VER_7 */
|
|
|
unsigned short res3;
|
|
|
unsigned int station_flags, station_flags_msk;
|
|
|
unsigned char add_ba_tid, remove_ba_tid;
|
|
|
- unsigned short add_ba_ssn, sleep_tx_count, sleep_state_flags;
|
|
|
+ unsigned short add_ba_ssn, sleep_tx_count;
|
|
|
+ unsigned char sleep_state_flags, station_type; /* v7: u16 flags */
|
|
|
unsigned short assoc_id, beamform_flags;
|
|
|
unsigned int tfd_queue_msk;
|
|
|
+ unsigned short rx_ba_window; /* v10 only: v7 ends here (44) */
|
|
|
+ unsigned char sp_length, uapsd_acs;
|
|
|
} PACKED;
|
|
|
|
|
|
struct sta_key_cmd { /* ADD_MODIFY_STA_KEY_API_S_VER_1 */
|
|
|
@@ -183,7 +187,7 @@ typedef char chk1a[__builtin_offsetof(struct mac_ctx_cmd, filter_flags) == 52
|
|
|
? 1 : -1];
|
|
|
typedef char chk1b[__builtin_offsetof(struct mac_ctx_cmd, is_assoc) == 100
|
|
|
? 1 : -1];
|
|
|
-typedef char chk2[sizeof(struct add_sta_cmd) == 44 ? 1 : -1];
|
|
|
+typedef char chk2[sizeof(struct add_sta_cmd) == 48 ? 1 : -1];
|
|
|
typedef char chk2a[__builtin_offsetof(struct add_sta_cmd, addr) == 8 ? 1 : -1];
|
|
|
typedef char chk2b[__builtin_offsetof(struct add_sta_cmd, tfd_queue_msk) == 40
|
|
|
? 1 : -1];
|
|
|
@@ -207,7 +211,9 @@ static struct {
|
|
|
unsigned int chan; /* current PHY context channel */
|
|
|
int bound; /* binding + quota active */
|
|
|
int ap_sta; /* AP station added */
|
|
|
- unsigned int alive_status, scd_base, err_table;
|
|
|
+ unsigned int alive_status, scd_base, err_table, umac_err;
|
|
|
+ unsigned int pg_css, pg_base;
|
|
|
+ int err_dumped; /* error tables printed for this load */ /* 8265 paging DRAM (CSS, 32 KB blocks) */
|
|
|
int alive;
|
|
|
int init_complete;
|
|
|
unsigned char *phydb; /* [type u16][chg u16][len u16][pad][data] */
|
|
|
@@ -249,6 +255,11 @@ static void put16(unsigned char *p, unsigned int v)
|
|
|
p[0] = v; p[1] = v >> 8;
|
|
|
}
|
|
|
|
|
|
+static void put32(unsigned char *p, unsigned int v)
|
|
|
+{
|
|
|
+ put16(p, v); put16(p + 2, v >> 16);
|
|
|
+}
|
|
|
+
|
|
|
static unsigned int get16(const unsigned char *p)
|
|
|
{
|
|
|
return p[0] | (p[1] << 8);
|
|
|
@@ -259,9 +270,15 @@ static unsigned int get32(const unsigned char *p)
|
|
|
return p[0] | (p[1] << 8) | (p[2] << 16) | ((unsigned int)p[3] << 24);
|
|
|
}
|
|
|
|
|
|
+static void dump_error_log(void);
|
|
|
+
|
|
|
static int cmd(unsigned int id, const void *data, unsigned int len)
|
|
|
{
|
|
|
- return iwl_send_cmd(id, data, len, 0, 0) < 0 ? -1 : 0;
|
|
|
+ if (iwl_send_cmd(id, data, len, 0, 0) >= 0)
|
|
|
+ return 0;
|
|
|
+ if (iwl_fatal()) /* firmware assert: print why, once */
|
|
|
+ dump_error_log();
|
|
|
+ return -1;
|
|
|
}
|
|
|
|
|
|
/* Command with a 32-bit status response (iwl_mvm_send_cmd_pdu_status). */
|
|
|
@@ -389,6 +406,10 @@ static void rx_handler(const struct iwl_pkt *pkt)
|
|
|
M.alive_status = get16(d);
|
|
|
M.err_table = get32(d + 20);
|
|
|
M.scd_base = get32(d + 40);
|
|
|
+ /* alive v3: umac error_info_addr at 60 (68 bytes);
|
|
|
+ * v4 has two LMACs and puts it at 108 (116). */
|
|
|
+ M.umac_err = n >= 68 ? get32(d + (n >= 116 ? 108 : 60))
|
|
|
+ : 0;
|
|
|
M.alive = 1;
|
|
|
}
|
|
|
break;
|
|
|
@@ -429,8 +450,12 @@ static void rx_handler(const struct iwl_pkt *pkt)
|
|
|
}
|
|
|
break;
|
|
|
case SCAN_OFFLOAD_COMPLETE:
|
|
|
+ case SCAN_COMPLETE_UMAC:
|
|
|
+ /* lmac: status at 2; iwl_umac_scan_complete: status at 6.
|
|
|
+ * IWL_SCAN_OFFLOAD_COMPLETED = 1 in both. */
|
|
|
M.scanning = 0;
|
|
|
- M.scan_ok = n >= 3 && d[2] == 1;
|
|
|
+ M.scan_ok = pkt->cmd == SCAN_COMPLETE_UMAC ? n >= 7 && d[6] == 1
|
|
|
+ : n >= 3 && d[2] == 1;
|
|
|
wifi_scan_done(M.scan_ok);
|
|
|
break;
|
|
|
case TIME_EVENT_NOTIFICATION:
|
|
|
@@ -458,25 +483,77 @@ int iwl_mvm_poll(void)
|
|
|
}
|
|
|
|
|
|
/* ---- bring-up ---------------------------------------------------------- */
|
|
|
-static void dump_error_log(void)
|
|
|
+/* LMAC table (struct iwl_error_event_table): [1] error_id, [20] log_pc,
|
|
|
+ * [23] hcmd (last host command). UMAC table (iwl_umac_error_event_table):
|
|
|
+ * [1] error_id, [2..5] blink/ilink, [6..8] data, [13] cmd_header. */
|
|
|
+static void dump_table(const char *tag, unsigned int a, unsigned int n)
|
|
|
{
|
|
|
unsigned int i;
|
|
|
|
|
|
- if (!M.err_table || M.err_table >= 0x01000000u)
|
|
|
+ if (!a)
|
|
|
return;
|
|
|
- serial_puts(SERIAL_COM1, "iwl: error log:");
|
|
|
- for (i = 0; i < 16; i++) {
|
|
|
+ serial_puts(SERIAL_COM1, tag);
|
|
|
+ for (i = 0; i < n; i++) {
|
|
|
serial_puts(SERIAL_COM1, " ");
|
|
|
- serial_puthex(SERIAL_COM1, iwl_mem_rd32(M.err_table + i * 4));
|
|
|
+ serial_puthex(SERIAL_COM1, iwl_mem_rd32(a + i * 4));
|
|
|
}
|
|
|
serial_puts(SERIAL_COM1, "\n");
|
|
|
}
|
|
|
|
|
|
+static void dump_error_log(void)
|
|
|
+{
|
|
|
+ if (M.err_dumped)
|
|
|
+ return;
|
|
|
+ M.err_dumped = 1;
|
|
|
+ if (M.err_table < 0x01000000u)
|
|
|
+ dump_table("iwl: error log:", M.err_table, 24);
|
|
|
+ if (M.umac_err >= 0x00800000u)
|
|
|
+ dump_table("iwl: umac log:", M.umac_err, 16);
|
|
|
+}
|
|
|
+
|
|
|
+/* 8265 runtime image: the UMAC pages part of its code from host DRAM
|
|
|
+ * (Linux iwl_init_paging(): only IWL_UCODE_REGULAR has paging_mem_size).
|
|
|
+ * Block 0 is the 4 KB CSS, blocks 1..n are 32 KB (8 pages); the last one
|
|
|
+ * may be short. FW_PAGING_BLOCK_CMD v1 takes 4 KB page numbers. */
|
|
|
+static int send_paging(void)
|
|
|
+{
|
|
|
+ const unsigned char *css, *pg;
|
|
|
+ unsigned int css_len, pg_len, pages, nblk, i, c[3 + 33];
|
|
|
+
|
|
|
+ if (iwl_fw_paging(IWL_IMG_RT, &css, &css_len, &pg, &pg_len) < 0)
|
|
|
+ return 0;
|
|
|
+ pages = pg_len >> 12;
|
|
|
+ nblk = (pages + 7) >> 3;
|
|
|
+ if ((pg_len & 0xfff) || !nblk || nblk > 32 || css_len > 4096)
|
|
|
+ return -1;
|
|
|
+ if (!M.pg_css) {
|
|
|
+ M.pg_css = mm_alloc_page();
|
|
|
+ M.pg_base = mm_alloc_pages(nblk * 8 + 7);
|
|
|
+ if (!M.pg_css || !M.pg_base)
|
|
|
+ return -1;
|
|
|
+ M.pg_base = (M.pg_base + 0x7fffu) & ~0x7fffu; /* order-3 */
|
|
|
+ }
|
|
|
+ /* Fresh copy on every load: the firmware writes dirty pages back. */
|
|
|
+ iwl_memzero((void *)M.pg_css, 4096);
|
|
|
+ iwl_memcpy((void *)M.pg_css, css, css_len);
|
|
|
+ iwl_memcpy((void *)M.pg_base, pg, pg_len);
|
|
|
+ iwl_memzero(c, sizeof(c));
|
|
|
+ /* IS_SECURED | IS_ENABLED | pages in the last block; 2^15 blocks */
|
|
|
+ c[0] = (1u << 9) | (1u << 8) | (pages - (nblk - 1) * 8);
|
|
|
+ c[1] = 15;
|
|
|
+ c[2] = nblk;
|
|
|
+ c[3] = M.pg_css >> 12;
|
|
|
+ for (i = 0; i < nblk; i++)
|
|
|
+ c[4 + i] = (M.pg_base + i * 0x8000u) >> 12;
|
|
|
+ return cmd(FW_PAGING_BLOCK_CMD, c, sizeof(c));
|
|
|
+}
|
|
|
+
|
|
|
static int load_and_wait_alive(int img)
|
|
|
{
|
|
|
unsigned int t;
|
|
|
|
|
|
M.alive = 0;
|
|
|
+ M.err_dumped = 0;
|
|
|
if (iwl_load_fw(img) < 0)
|
|
|
return -1;
|
|
|
for (t = 0; t < 2000 && !M.alive; t++) {
|
|
|
@@ -494,6 +571,10 @@ static int load_and_wait_alive(int img)
|
|
|
return -1;
|
|
|
}
|
|
|
iwl_fw_alive(M.scd_base);
|
|
|
+ if (img == IWL_IMG_RT && send_paging() < 0) {
|
|
|
+ M.state = "rt: paging";
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
@@ -622,16 +703,32 @@ static int run_init_image(void)
|
|
|
return -1;
|
|
|
M.phydb_len = 0;
|
|
|
M.init_complete = 0;
|
|
|
+ M.state = "init: ALIVE";
|
|
|
if (load_and_wait_alive(IWL_IMG_INIT) < 0)
|
|
|
return -1;
|
|
|
- if (send_bt_config() < 0 || read_nvm() < 0)
|
|
|
+ /* Linux's iwl_run_init_mvm_ucode() sends BT_CONFIG only for device
|
|
|
+ * families below 8000. The 8265's INIT image asserts on it (the
|
|
|
+ * runtime image sends it later, iwl_mvm_up()), so skip it here. */
|
|
|
+ if (iwl_subfamily() != IWL_SUB_8265) {
|
|
|
+ M.state = "init: BT config";
|
|
|
+ if (send_bt_config() < 0)
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ M.state = "init: NVM";
|
|
|
+ if (read_nvm() < 0)
|
|
|
return -1;
|
|
|
if (iwl_rfkill()) {
|
|
|
+ M.state = "init: RF-kill";
|
|
|
logs("radio is off (hardware RF-kill)");
|
|
|
return -1;
|
|
|
}
|
|
|
- if (send_tx_ant() < 0 || send_phy_cfg(IWL_IMG_INIT) < 0)
|
|
|
+ M.state = "init: TX antennas";
|
|
|
+ if (send_tx_ant() < 0)
|
|
|
+ return -1;
|
|
|
+ M.state = "init: PHY config";
|
|
|
+ if (send_phy_cfg(IWL_IMG_INIT) < 0)
|
|
|
return -1;
|
|
|
+ M.state = "init: calibration";
|
|
|
for (t = 0; t < 2000 && !M.init_complete; t++) {
|
|
|
if (iwl_rx_poll() < 0)
|
|
|
break;
|
|
|
@@ -666,8 +763,12 @@ static int enable_queue(int q, unsigned int sta, unsigned int tid,
|
|
|
static int add_sta(struct add_sta_cmd *c)
|
|
|
{
|
|
|
unsigned int status = 0;
|
|
|
+ /* IWL_UCODE_TLV_API_STA_TYPE (api[0] bit 30, the 8265): v10. */
|
|
|
+ int v10 = (iwl_fw()->api[0] >> 30) & 1;
|
|
|
|
|
|
- if (cmd_status(ADD_STA, c, sizeof(*c), &status) < 0)
|
|
|
+ if (!v10)
|
|
|
+ c->station_type = 0;
|
|
|
+ if (cmd_status(ADD_STA, c, v10 ? sizeof(*c) : 44, &status) < 0)
|
|
|
return -1;
|
|
|
if ((status & 0xff) != 1) {
|
|
|
iwl_loghex("ADD_STA failed, status", status);
|
|
|
@@ -687,6 +788,7 @@ static int add_aux_sta(void)
|
|
|
c.mac_id_n_color = MAC_INDEX_AUX;
|
|
|
c.tfd_queue_msk = 1u << IWL_Q_AUX;
|
|
|
c.tid_disable_tx = 0xffff;
|
|
|
+ c.station_type = 4; /* IWL_STA_AUX_ACTIVITY */
|
|
|
return add_sta(&c);
|
|
|
}
|
|
|
|
|
|
@@ -774,6 +876,52 @@ static int mac_ctx(unsigned int action, int assoc, unsigned short aid,
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+static const unsigned char scan_channels[] = {
|
|
|
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
|
|
|
+ 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120,
|
|
|
+ 124, 128, 132, 136, 140, 149, 153, 157, 161, 165,
|
|
|
+};
|
|
|
+
|
|
|
+/* Firmware with IWL_UCODE_TLV_CAPA_UMAC_SCAN (capa[0] bit 2: the 8265)
|
|
|
+ * asserts on the LMAC SCAN_OFFLOAD_REQUEST; Linux uses the UMAC scan. */
|
|
|
+static int umac_scan(void)
|
|
|
+{
|
|
|
+ return (iwl_fw()->capa[0] >> 2) & 1;
|
|
|
+}
|
|
|
+
|
|
|
+static unsigned int n_scan_ch(void)
|
|
|
+{
|
|
|
+ unsigned int n = iwl_fw()->n_scan_ch;
|
|
|
+
|
|
|
+ return n >= sizeof(scan_channels) && n <= 64 ? n : 40;
|
|
|
+}
|
|
|
+
|
|
|
+/* SCAN_CFG_CMD, struct iwl_scan_config_v1 (Linux iwl_mvm_config_scan()
|
|
|
+ * for a non-CDB device), once after the runtime image is up. */
|
|
|
+static int scan_config(void)
|
|
|
+{
|
|
|
+ unsigned char *c = M.scratch;
|
|
|
+ unsigned int n = sizeof(scan_channels), nsc = n_scan_ch();
|
|
|
+
|
|
|
+ if (!umac_scan())
|
|
|
+ return 0;
|
|
|
+ iwl_memzero(c, 36 + nsc);
|
|
|
+ /* ACTIVATE | ALLOW_CHUB_REQS | SET_TX/RX_CHAINS | SET_AUX_STA_ID |
|
|
|
+ * SET_ALL_TIMES | SET_CHANNEL_FLAGS | SET_LEGACY_RATES |
|
|
|
+ * SET_MAC_ADDR | CLEAR_FRAGMENTED | N_CHANNELS(n) */
|
|
|
+ put32(c, 0x0002ef09u | (n << 26));
|
|
|
+ put32(c + 4, M.valid_tx_ant);
|
|
|
+ put32(c + 8, M.valid_rx_ant);
|
|
|
+ put32(c + 12, 0x0fff0fffu); /* all CCK+OFDM, basic+supported */
|
|
|
+ /* out_of_channel_time / suspend_time: 0 (IWL_SCAN_TYPE_UNASSOC) */
|
|
|
+ c[24] = 10; c[25] = 110; c[26] = 44; c[27] = 90; /* dwells */
|
|
|
+ iwl_memcpy(c + 28, M.mac, 6);
|
|
|
+ c[34] = IWL_STA_AUX; /* bcast_sta_id */
|
|
|
+ c[35] = 0x0f; /* EBS | ACCURATE | ADD | P2A */
|
|
|
+ iwl_memcpy(c + 36, scan_channels, n);
|
|
|
+ return cmd(SCAN_CFG_CMD, c, 36 + nsc);
|
|
|
+}
|
|
|
+
|
|
|
static int run_rt_image(void)
|
|
|
{
|
|
|
unsigned int one = 0;
|
|
|
@@ -783,30 +931,46 @@ static int run_rt_image(void)
|
|
|
iwl_stop_device();
|
|
|
if (iwl_start_hw() < 0)
|
|
|
return -1;
|
|
|
+ M.state = "rt: ALIVE";
|
|
|
if (load_and_wait_alive(IWL_IMG_RT) < 0)
|
|
|
return -1;
|
|
|
+ M.state = "rt: TX antennas";
|
|
|
if (send_tx_ant() < 0)
|
|
|
return -1;
|
|
|
+ M.state = "rt: PHY DB";
|
|
|
if (phydb_send_type(1) < 0 || phydb_send_type(2) < 0 ||
|
|
|
phydb_send_type(4) < 0 || phydb_send_type(5) < 0)
|
|
|
return -1;
|
|
|
- if (send_phy_cfg(IWL_IMG_RT) < 0 || send_bt_config() < 0)
|
|
|
+ M.state = "rt: PHY config";
|
|
|
+ if (send_phy_cfg(IWL_IMG_RT) < 0)
|
|
|
+ return -1;
|
|
|
+ M.state = "rt: BT config";
|
|
|
+ if (send_bt_config() < 0)
|
|
|
return -1;
|
|
|
+ M.state = "rt: DQA";
|
|
|
if (cmd(DQA_ENABLE_CMD, &one, 4) < 0) /* cmd_queue = 0 */
|
|
|
return -1;
|
|
|
+ M.state = "rt: aux station";
|
|
|
if (add_aux_sta() < 0)
|
|
|
return -1;
|
|
|
+ M.state = "rt: PHY context";
|
|
|
if (phy_ctx(ACTION_ADD, 1) < 0)
|
|
|
return -1;
|
|
|
one = 0; /* device power: CAM */
|
|
|
+ M.state = "rt: power table";
|
|
|
if (cmd(POWER_TABLE_CMD, &one, 4) < 0)
|
|
|
return -1;
|
|
|
/* LAR: ask for the current (NVM default) regulatory domain. */
|
|
|
iwl_memzero(mcc, sizeof(mcc));
|
|
|
mcc[0] = 'Z'; mcc[1] = 'Z'; /* le16: 'Z' << 8 | 'Z' */
|
|
|
mcc[2] = 0x10; /* MCC_SOURCE_GET_CURRENT */
|
|
|
+ M.state = "rt: MCC";
|
|
|
if (iwl_send_cmd(MCC_UPDATE_CMD, mcc, sizeof(mcc), 0, 0) < 0)
|
|
|
logs("MCC update failed (continuing)");
|
|
|
+ M.state = "rt: scan config";
|
|
|
+ if (scan_config() < 0)
|
|
|
+ return -1;
|
|
|
+ M.state = "rt: MAC context";
|
|
|
if (mac_ctx(ACTION_ADD, 0, 0, 100, 1) < 0)
|
|
|
return -1;
|
|
|
return 0;
|
|
|
@@ -845,11 +1009,9 @@ int iwl_mvm_up(unsigned char mac[6])
|
|
|
M.valid_rx_ant = 1;
|
|
|
iwl_set_rx_handler(rx_handler);
|
|
|
if (run_init_image() < 0 || run_rt_image() < 0) {
|
|
|
+ logs(M.state ? M.state : "bring-up failed");
|
|
|
dump_error_log();
|
|
|
iwl_stop_device();
|
|
|
- if (M.state && M.state[0] != 'r' && M.state[0] != 'i')
|
|
|
- return -1;
|
|
|
- M.state = "firmware start failed";
|
|
|
return -1;
|
|
|
}
|
|
|
M.up = 1;
|
|
|
@@ -882,95 +1044,120 @@ void iwl_mvm_down(void)
|
|
|
}
|
|
|
|
|
|
/* ---- scan -------------------------------------------------------------- */
|
|
|
-static const unsigned char scan_channels[] = {
|
|
|
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
|
|
|
- 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120,
|
|
|
- 124, 128, 132, 136, 140, 149, 153, 157, 161, 165,
|
|
|
-};
|
|
|
|
|
|
int iwl_mvm_scan_running(void)
|
|
|
{
|
|
|
return M.scanning;
|
|
|
}
|
|
|
|
|
|
-int iwl_mvm_scan_start(void)
|
|
|
+/* struct iwl_scan_probe_req_v1: mac_header, band_data[2] and
|
|
|
+ * common_data segments, then the 512-byte template. */
|
|
|
+static void build_preq(unsigned char *preq)
|
|
|
{
|
|
|
- struct scan_req_lmac *c;
|
|
|
- struct scan_chan_lmac *ch;
|
|
|
- unsigned char *preq, *buf;
|
|
|
- unsigned int i, n = sizeof(scan_channels), total, rx = M.valid_rx_ant;
|
|
|
static const unsigned char rates24[] = { 1, 8, 0x82, 0x84, 0x8b, 0x96,
|
|
|
0x0c, 0x12, 0x18, 0x24,
|
|
|
50, 4, 0x30, 0x48, 0x60, 0x6c };
|
|
|
static const unsigned char rates5[] = { 1, 8, 0x8c, 0x12, 0x98, 0x24,
|
|
|
0xb0, 0x48, 0x60, 0x6c };
|
|
|
+ unsigned char *f = preq + 16;
|
|
|
+ unsigned int i, o;
|
|
|
+
|
|
|
+ f[0] = 0x40; /* probe request */
|
|
|
+ for (i = 0; i < 6; i++) {
|
|
|
+ f[4 + i] = 0xff;
|
|
|
+ f[10 + i] = M.mac[i];
|
|
|
+ f[16 + i] = 0xff;
|
|
|
+ }
|
|
|
+ /* f[24..25]: empty SSID IE, filled by the firmware */
|
|
|
+ put16(preq + 0, 0); /* mac_header offset */
|
|
|
+ put16(preq + 2, 26); /* + empty SSID */
|
|
|
+ o = 26;
|
|
|
+ iwl_memcpy(f + o, rates24, sizeof(rates24));
|
|
|
+ put16(preq + 4, o);
|
|
|
+ put16(preq + 6, sizeof(rates24));
|
|
|
+ o += sizeof(rates24);
|
|
|
+ iwl_memcpy(f + o, rates5, sizeof(rates5));
|
|
|
+ put16(preq + 8, o);
|
|
|
+ put16(preq + 10, sizeof(rates5));
|
|
|
+ o += sizeof(rates5);
|
|
|
+ put16(preq + 12, o); /* common data: none */
|
|
|
+ put16(preq + 14, 0);
|
|
|
+}
|
|
|
+
|
|
|
+int iwl_mvm_scan_start(void)
|
|
|
+{
|
|
|
+ struct scan_req_lmac *c;
|
|
|
+ struct scan_chan_lmac *ch;
|
|
|
+ unsigned char *buf, *p;
|
|
|
+ unsigned int i, n = sizeof(scan_channels), total, rx = M.valid_rx_ant;
|
|
|
+ unsigned int nsc = n_scan_ch(), id;
|
|
|
|
|
|
if (!M.up || M.scanning)
|
|
|
return -1;
|
|
|
- if (n > 40)
|
|
|
- n = 40; /* n_scan_channels TLV */
|
|
|
buf = M.scratch;
|
|
|
iwl_memzero(buf, 4096);
|
|
|
- c = (struct scan_req_lmac *)buf;
|
|
|
- c->n_channels = n;
|
|
|
- c->active_dwell = 10;
|
|
|
- c->passive_dwell = 110;
|
|
|
- c->fragmented_dwell = 44;
|
|
|
- c->extended_dwell = 90;
|
|
|
- c->rx_chain_select = (rx << 1) | (rx << 7) | (rx << 4) | 1;
|
|
|
- /* PASS_ALL | EXTENDED_DWELL */
|
|
|
- c->scan_flags = (1u << 0) | (1u << 7);
|
|
|
- c->flags = 1; /* first channel: 2.4 GHz */
|
|
|
- c->filter_flags = (1u << 2) | (1u << 6); /* ACCEPT_GRP | IN_BEACON */
|
|
|
- c->tx_cmd[0].tx_flags = TX_FLG_SEQ_CTL | TX_FLG_BT_DIS;
|
|
|
- c->tx_cmd[0].rate_n_flags = PLCP_1M | RATE_CCK | RATE_ANT_A;
|
|
|
- c->tx_cmd[0].sta_id = IWL_STA_AUX;
|
|
|
- c->tx_cmd[1].tx_flags = TX_FLG_SEQ_CTL | TX_FLG_BT_DIS;
|
|
|
- c->tx_cmd[1].rate_n_flags = PLCP_6M | RATE_ANT_A;
|
|
|
- c->tx_cmd[1].sta_id = IWL_STA_AUX;
|
|
|
- c->scan_prio = 6; /* IWL_SCAN_PRIORITY_EXT_6 */
|
|
|
- c->iter_num = 1;
|
|
|
- c->schedule[0].iterations = 1;
|
|
|
- c->schedule[0].full_scan_mul = 1;
|
|
|
- ch = (struct scan_chan_lmac *)(buf + sizeof(*c));
|
|
|
- for (i = 0; i < n; i++) {
|
|
|
- ch[i].channel_num = scan_channels[i];
|
|
|
- ch[i].iter_count = 1;
|
|
|
- ch[i].flags = 1u << 28; /* UNIFIED_SCAN_CHANNEL_PARTIAL */
|
|
|
- }
|
|
|
- /* struct iwl_scan_probe_req_v1 after n_scan_channels (40) entries:
|
|
|
- * mac_header, band_data[2], common_data segments, then 512 bytes. */
|
|
|
- preq = buf + sizeof(*c) + 40 * sizeof(struct scan_chan_lmac);
|
|
|
- {
|
|
|
- unsigned char *f = preq + 16;
|
|
|
- unsigned int o = 0;
|
|
|
-
|
|
|
- f[0] = 0x40; /* probe request */
|
|
|
- for (i = 0; i < 6; i++) {
|
|
|
- f[4 + i] = 0xff;
|
|
|
- f[10 + i] = M.mac[i];
|
|
|
- f[16 + i] = 0xff;
|
|
|
+ if (umac_scan()) {
|
|
|
+ /* SCAN_REQ_UMAC v7 (IWL_UCODE_TLV_API_ADAPTIVE_DWELL, which
|
|
|
+ * the 8265-36 has): 48-byte header, n_scan_ch channel
|
|
|
+ * configs, tail v1 (schedule, delay, probe request, 20
|
|
|
+ * direct-scan SSIDs; slot 0 all zero = the wildcard). */
|
|
|
+ put32(buf + 8, 6); /* ooc_priority EXT_6 */
|
|
|
+ put16(buf + 12, (1u << 2) | (1u << 13)); /* PASS_ALL|ADWELL */
|
|
|
+ buf[16] = 10; /* active dwell */
|
|
|
+ buf[17] = 110; /* passive dwell */
|
|
|
+ buf[18] = 44; /* fragmented dwell */
|
|
|
+ buf[19] = 2; /* adwell_default_n_aps */
|
|
|
+ buf[20] = 10; /* ... _social */
|
|
|
+ put16(buf + 22, 300); /* adwell max budget (full) */
|
|
|
+ put32(buf + 40, 6); /* scan_priority EXT_6 */
|
|
|
+ buf[45] = n; /* channel param count */
|
|
|
+ for (i = 0; i < n; i++) {
|
|
|
+ p = buf + 48 + i * 8;
|
|
|
+ p[0] = 1; /* probe direct_scan[0] */
|
|
|
+ p[4] = scan_channels[i];
|
|
|
+ p[5] = 1; /* iter_count */
|
|
|
}
|
|
|
- f[24] = 0; /* SSID IE, filled by fw */
|
|
|
- f[25] = 0;
|
|
|
- put16(preq + 0, 0); /* mac_header offset */
|
|
|
- put16(preq + 2, 26); /* + empty SSID */
|
|
|
- o = 26;
|
|
|
- iwl_memcpy(f + o, rates24, sizeof(rates24));
|
|
|
- put16(preq + 4, o);
|
|
|
- put16(preq + 6, sizeof(rates24));
|
|
|
- o += sizeof(rates24);
|
|
|
- iwl_memcpy(f + o, rates5, sizeof(rates5));
|
|
|
- put16(preq + 8, o);
|
|
|
- put16(preq + 10, sizeof(rates5));
|
|
|
- o += sizeof(rates5);
|
|
|
- put16(preq + 12, o); /* common data: none */
|
|
|
- put16(preq + 14, 0);
|
|
|
+ p = buf + 48 + nsc * 8;
|
|
|
+ p[2] = 1; /* schedule[0].iter_count */
|
|
|
+ build_preq(p + 12);
|
|
|
+ total = 48 + nsc * 8 + 12 + 16 + 512 + 20 * 34;
|
|
|
+ id = SCAN_REQ_UMAC;
|
|
|
+ } else {
|
|
|
+ c = (struct scan_req_lmac *)buf;
|
|
|
+ c->n_channels = n;
|
|
|
+ c->active_dwell = 10;
|
|
|
+ c->passive_dwell = 110;
|
|
|
+ c->fragmented_dwell = 44;
|
|
|
+ c->extended_dwell = 90;
|
|
|
+ c->rx_chain_select = (rx << 1) | (rx << 7) | (rx << 4) | 1;
|
|
|
+ /* PASS_ALL | EXTENDED_DWELL */
|
|
|
+ c->scan_flags = (1u << 0) | (1u << 7);
|
|
|
+ c->flags = 1; /* first channel: 2.4 GHz */
|
|
|
+ c->filter_flags = (1u << 2) | (1u << 6); /* GRP | IN_BEACON */
|
|
|
+ c->tx_cmd[0].tx_flags = TX_FLG_SEQ_CTL | TX_FLG_BT_DIS;
|
|
|
+ c->tx_cmd[0].rate_n_flags = PLCP_1M | RATE_CCK | RATE_ANT_A;
|
|
|
+ c->tx_cmd[0].sta_id = IWL_STA_AUX;
|
|
|
+ c->tx_cmd[1].tx_flags = TX_FLG_SEQ_CTL | TX_FLG_BT_DIS;
|
|
|
+ c->tx_cmd[1].rate_n_flags = PLCP_6M | RATE_ANT_A;
|
|
|
+ c->tx_cmd[1].sta_id = IWL_STA_AUX;
|
|
|
+ c->scan_prio = 6; /* IWL_SCAN_PRIORITY_EXT_6 */
|
|
|
+ c->iter_num = 1;
|
|
|
+ c->schedule[0].iterations = 1;
|
|
|
+ c->schedule[0].full_scan_mul = 1;
|
|
|
+ ch = (struct scan_chan_lmac *)(buf + sizeof(*c));
|
|
|
+ for (i = 0; i < n; i++) {
|
|
|
+ ch[i].channel_num = scan_channels[i];
|
|
|
+ ch[i].iter_count = 1;
|
|
|
+ ch[i].flags = 1u << 28; /* UNIFIED_SCAN_CHANNEL_PARTIAL */
|
|
|
+ }
|
|
|
+ /* the probe request follows n_scan_ch channel entries */
|
|
|
+ build_preq(buf + sizeof(*c) + nsc * sizeof(*ch));
|
|
|
+ total = sizeof(*c) + nsc * sizeof(*ch) + 16 + 512;
|
|
|
+ id = SCAN_OFFLOAD_REQUEST_CMD;
|
|
|
}
|
|
|
- total = sizeof(*c) + 40 * sizeof(struct scan_chan_lmac) + 16 + 512;
|
|
|
M.scanning = 1;
|
|
|
M.scan_ok = 0;
|
|
|
- if (cmd(SCAN_OFFLOAD_REQUEST_CMD, buf, total) < 0) {
|
|
|
+ if (cmd(id, buf, total) < 0) {
|
|
|
M.scanning = 0;
|
|
|
return -1;
|
|
|
}
|
|
|
@@ -978,23 +1165,33 @@ int iwl_mvm_scan_start(void)
|
|
|
}
|
|
|
|
|
|
/* ---- connection --------------------------------------------------------- */
|
|
|
+/* TIME_QUOTA_CMD for the four bindings: v1 entries are id_and_color,
|
|
|
+ * quota, max_duration; v2 (IWL_UCODE_TLV_API_QUOTA_LOW_LATENCY, api 38 =
|
|
|
+ * api[1] bit 6: the 8265) adds a low_latency dword. `on` gives binding 0
|
|
|
+ * the whole IWL_MVM_MAX_QUOTA (128); the other entries are invalid. */
|
|
|
+static int send_quota(int on)
|
|
|
+{
|
|
|
+ unsigned int q[16], i, st = (iwl_fw()->api[1] >> 6) & 1 ? 4 : 3;
|
|
|
+
|
|
|
+ iwl_memzero(q, sizeof(q));
|
|
|
+ for (i = 0; i < 4; i++)
|
|
|
+ q[i * st] = CTXT_INVALID;
|
|
|
+ if (on) {
|
|
|
+ q[0] = 0;
|
|
|
+ q[1] = 128;
|
|
|
+ }
|
|
|
+ return cmd(TIME_QUOTA_CMD, q, 16 * st);
|
|
|
+}
|
|
|
+
|
|
|
static int bind_and_quota(unsigned int action)
|
|
|
{
|
|
|
struct binding_cmd b;
|
|
|
- struct quota_cmd q;
|
|
|
- unsigned int status = 0, i;
|
|
|
+ unsigned int status = 0;
|
|
|
|
|
|
/* Removal: drop the quota first, then the binding (Linux order in
|
|
|
* iwl_mvm_unassign_vif_chanctx()). */
|
|
|
- if (action == ACTION_REMOVE) {
|
|
|
- for (i = 0; i < 4; i++) {
|
|
|
- q.q[i].id_and_color = CTXT_INVALID;
|
|
|
- q.q[i].quota = 0;
|
|
|
- q.q[i].max_duration = 0;
|
|
|
- }
|
|
|
- if (cmd(TIME_QUOTA_CMD, &q, sizeof(q)) < 0)
|
|
|
- return -1;
|
|
|
- }
|
|
|
+ if (action == ACTION_REMOVE && send_quota(0) < 0)
|
|
|
+ return -1;
|
|
|
b.id_and_color = 0; /* binding id = PHY context 0 */
|
|
|
b.action = action;
|
|
|
b.macs[0] = action == ACTION_REMOVE ? CTXT_INVALID : 0;
|
|
|
@@ -1006,14 +1203,7 @@ static int bind_and_quota(unsigned int action)
|
|
|
}
|
|
|
if (action == ACTION_REMOVE)
|
|
|
return 0;
|
|
|
- for (i = 0; i < 4; i++) {
|
|
|
- q.q[i].id_and_color = CTXT_INVALID;
|
|
|
- q.q[i].quota = 0;
|
|
|
- q.q[i].max_duration = 0;
|
|
|
- }
|
|
|
- q.q[0].id_and_color = 0;
|
|
|
- q.q[0].quota = 128;
|
|
|
- return cmd(TIME_QUOTA_CMD, &q, sizeof(q));
|
|
|
+ return send_quota(1);
|
|
|
}
|
|
|
|
|
|
static int add_ap_sta(int modify, unsigned short aid)
|