diff options
author | Eliad Peller <eliad@wizery.com> | 2012-11-22 11:06:19 -0500 |
---|---|---|
committer | Luciano Coelho <coelho@ti.com> | 2012-11-27 03:49:29 -0500 |
commit | c50a282515dc7092f7318708a0f3ae7ca7342b9f (patch) | |
tree | 1e0f6973d6382a00c88f5a544f8672e1e50dc148 /drivers/net/wireless/ti/wl12xx | |
parent | fcab189027cdd68df7f97474d1419aaa4a82130c (diff) |
wlcore: update events enum/struct to new fw api
The event mailbox in wl18xx has a different
(non-compatible) structure.
Create common functions in wlcore to handle the
events, and call them from the chip-specific
event mailbox parsers.
This way, each driver (wl12xx/wl18xx) extracts
the event mailbox by itself according to its
own structure, and then calls the common
wlcore functions to handle it.
Signed-off-by: Eliad Peller <eliad@wizery.com>
Signed-off-by: Luciano Coelho <coelho@ti.com>
Diffstat (limited to 'drivers/net/wireless/ti/wl12xx')
-rw-r--r-- | drivers/net/wireless/ti/wl12xx/Makefile | 2 | ||||
-rw-r--r-- | drivers/net/wireless/ti/wl12xx/event.c | 112 | ||||
-rw-r--r-- | drivers/net/wireless/ti/wl12xx/event.h | 111 | ||||
-rw-r--r-- | drivers/net/wireless/ti/wl12xx/main.c | 24 |
4 files changed, 246 insertions, 3 deletions
diff --git a/drivers/net/wireless/ti/wl12xx/Makefile b/drivers/net/wireless/ti/wl12xx/Makefile index 8d9afd238adc..e6a24056b3c8 100644 --- a/drivers/net/wireless/ti/wl12xx/Makefile +++ b/drivers/net/wireless/ti/wl12xx/Makefile | |||
@@ -1,3 +1,3 @@ | |||
1 | wl12xx-objs = main.o cmd.o acx.o debugfs.o scan.o | 1 | wl12xx-objs = main.o cmd.o acx.o debugfs.o scan.o event.o |
2 | 2 | ||
3 | obj-$(CONFIG_WL12XX) += wl12xx.o | 3 | obj-$(CONFIG_WL12XX) += wl12xx.o |
diff --git a/drivers/net/wireless/ti/wl12xx/event.c b/drivers/net/wireless/ti/wl12xx/event.c new file mode 100644 index 000000000000..6437dac12e70 --- /dev/null +++ b/drivers/net/wireless/ti/wl12xx/event.c | |||
@@ -0,0 +1,112 @@ | |||
1 | /* | ||
2 | * This file is part of wl12xx | ||
3 | * | ||
4 | * Copyright (C) 2012 Texas Instruments. All rights reserved. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * version 2 as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, but | ||
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | * General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
18 | * 02110-1301 USA | ||
19 | * | ||
20 | */ | ||
21 | |||
22 | #include "event.h" | ||
23 | #include "scan.h" | ||
24 | #include "../wlcore/cmd.h" | ||
25 | #include "../wlcore/debug.h" | ||
26 | |||
27 | int wl12xx_wait_for_event(struct wl1271 *wl, enum wlcore_wait_event event, | ||
28 | bool *timeout) | ||
29 | { | ||
30 | u32 local_event; | ||
31 | |||
32 | switch (event) { | ||
33 | case WLCORE_EVENT_ROLE_STOP_COMPLETE: | ||
34 | local_event = ROLE_STOP_COMPLETE_EVENT_ID; | ||
35 | break; | ||
36 | |||
37 | case WLCORE_EVENT_PEER_REMOVE_COMPLETE: | ||
38 | local_event = PEER_REMOVE_COMPLETE_EVENT_ID; | ||
39 | break; | ||
40 | |||
41 | default: | ||
42 | /* event not implemented */ | ||
43 | return 0; | ||
44 | } | ||
45 | return wlcore_cmd_wait_for_event_or_timeout(wl, local_event, timeout); | ||
46 | } | ||
47 | |||
48 | int wl12xx_process_mailbox_events(struct wl1271 *wl) | ||
49 | { | ||
50 | struct wl12xx_event_mailbox *mbox = wl->mbox; | ||
51 | u32 vector; | ||
52 | |||
53 | |||
54 | vector = le32_to_cpu(mbox->events_vector); | ||
55 | vector &= ~(le32_to_cpu(mbox->events_mask)); | ||
56 | |||
57 | wl1271_debug(DEBUG_EVENT, "MBOX vector: 0x%x", vector); | ||
58 | |||
59 | if (vector & SCAN_COMPLETE_EVENT_ID) { | ||
60 | wl1271_debug(DEBUG_EVENT, "status: 0x%x", | ||
61 | mbox->scheduled_scan_status); | ||
62 | |||
63 | if (wl->scan_wlvif) | ||
64 | wl12xx_scan_completed(wl, wl->scan_wlvif); | ||
65 | } | ||
66 | |||
67 | if (vector & PERIODIC_SCAN_REPORT_EVENT_ID) | ||
68 | wlcore_event_sched_scan_report(wl, | ||
69 | mbox->scheduled_scan_status); | ||
70 | |||
71 | if (vector & PERIODIC_SCAN_COMPLETE_EVENT_ID) | ||
72 | wlcore_event_sched_scan_completed(wl, | ||
73 | mbox->scheduled_scan_status); | ||
74 | if (vector & SOFT_GEMINI_SENSE_EVENT_ID) | ||
75 | wlcore_event_soft_gemini_sense(wl, | ||
76 | mbox->soft_gemini_sense_info); | ||
77 | |||
78 | if (vector & BSS_LOSE_EVENT_ID) | ||
79 | wlcore_event_beacon_loss(wl, 0xff); | ||
80 | |||
81 | if (vector & RSSI_SNR_TRIGGER_0_EVENT_ID) | ||
82 | wlcore_event_rssi_trigger(wl, mbox->rssi_snr_trigger_metric); | ||
83 | |||
84 | if (vector & BA_SESSION_RX_CONSTRAINT_EVENT_ID) | ||
85 | wlcore_event_ba_rx_constraint(wl, | ||
86 | BIT(mbox->role_id), | ||
87 | mbox->rx_ba_allowed); | ||
88 | |||
89 | if (vector & CHANNEL_SWITCH_COMPLETE_EVENT_ID) | ||
90 | wlcore_event_channel_switch(wl, 0xff, | ||
91 | mbox->channel_switch_status); | ||
92 | |||
93 | if (vector & DUMMY_PACKET_EVENT_ID) | ||
94 | wlcore_event_dummy_packet(wl); | ||
95 | |||
96 | /* | ||
97 | * "TX retries exceeded" has a different meaning according to mode. | ||
98 | * In AP mode the offending station is disconnected. | ||
99 | */ | ||
100 | if (vector & MAX_TX_RETRY_EVENT_ID) | ||
101 | wlcore_event_max_tx_failure(wl, | ||
102 | le16_to_cpu(mbox->sta_tx_retry_exceeded)); | ||
103 | |||
104 | if (vector & INACTIVE_STA_EVENT_ID) | ||
105 | wlcore_event_inactive_sta(wl, | ||
106 | le16_to_cpu(mbox->sta_aging_status)); | ||
107 | |||
108 | if (vector & REMAIN_ON_CHANNEL_COMPLETE_EVENT_ID) | ||
109 | wlcore_event_roc_complete(wl); | ||
110 | |||
111 | return 0; | ||
112 | } | ||
diff --git a/drivers/net/wireless/ti/wl12xx/event.h b/drivers/net/wireless/ti/wl12xx/event.h new file mode 100644 index 000000000000..a5cc3fcd9eea --- /dev/null +++ b/drivers/net/wireless/ti/wl12xx/event.h | |||
@@ -0,0 +1,111 @@ | |||
1 | /* | ||
2 | * This file is part of wl12xx | ||
3 | * | ||
4 | * Copyright (C) 2012 Texas Instruments. All rights reserved. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * version 2 as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, but | ||
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | * General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
18 | * 02110-1301 USA | ||
19 | * | ||
20 | */ | ||
21 | |||
22 | #ifndef __WL12XX_EVENT_H__ | ||
23 | #define __WL12XX_EVENT_H__ | ||
24 | |||
25 | #include "../wlcore/wlcore.h" | ||
26 | |||
27 | enum { | ||
28 | MEASUREMENT_START_EVENT_ID = BIT(8), | ||
29 | MEASUREMENT_COMPLETE_EVENT_ID = BIT(9), | ||
30 | SCAN_COMPLETE_EVENT_ID = BIT(10), | ||
31 | WFD_DISCOVERY_COMPLETE_EVENT_ID = BIT(11), | ||
32 | AP_DISCOVERY_COMPLETE_EVENT_ID = BIT(12), | ||
33 | RESERVED1 = BIT(13), | ||
34 | PSPOLL_DELIVERY_FAILURE_EVENT_ID = BIT(14), | ||
35 | ROLE_STOP_COMPLETE_EVENT_ID = BIT(15), | ||
36 | RADAR_DETECTED_EVENT_ID = BIT(16), | ||
37 | CHANNEL_SWITCH_COMPLETE_EVENT_ID = BIT(17), | ||
38 | BSS_LOSE_EVENT_ID = BIT(18), | ||
39 | REGAINED_BSS_EVENT_ID = BIT(19), | ||
40 | MAX_TX_RETRY_EVENT_ID = BIT(20), | ||
41 | DUMMY_PACKET_EVENT_ID = BIT(21), | ||
42 | SOFT_GEMINI_SENSE_EVENT_ID = BIT(22), | ||
43 | CHANGE_AUTO_MODE_TIMEOUT_EVENT_ID = BIT(23), | ||
44 | SOFT_GEMINI_AVALANCHE_EVENT_ID = BIT(24), | ||
45 | PLT_RX_CALIBRATION_COMPLETE_EVENT_ID = BIT(25), | ||
46 | INACTIVE_STA_EVENT_ID = BIT(26), | ||
47 | PEER_REMOVE_COMPLETE_EVENT_ID = BIT(27), | ||
48 | PERIODIC_SCAN_COMPLETE_EVENT_ID = BIT(28), | ||
49 | PERIODIC_SCAN_REPORT_EVENT_ID = BIT(29), | ||
50 | BA_SESSION_RX_CONSTRAINT_EVENT_ID = BIT(30), | ||
51 | REMAIN_ON_CHANNEL_COMPLETE_EVENT_ID = BIT(31), | ||
52 | }; | ||
53 | |||
54 | struct wl12xx_event_mailbox { | ||
55 | __le32 events_vector; | ||
56 | __le32 events_mask; | ||
57 | __le32 reserved_1; | ||
58 | __le32 reserved_2; | ||
59 | |||
60 | u8 number_of_scan_results; | ||
61 | u8 scan_tag; | ||
62 | u8 completed_scan_status; | ||
63 | u8 reserved_3; | ||
64 | |||
65 | u8 soft_gemini_sense_info; | ||
66 | u8 soft_gemini_protective_info; | ||
67 | s8 rssi_snr_trigger_metric[NUM_OF_RSSI_SNR_TRIGGERS]; | ||
68 | u8 change_auto_mode_timeout; | ||
69 | u8 scheduled_scan_status; | ||
70 | u8 reserved4; | ||
71 | /* tuned channel (roc) */ | ||
72 | u8 roc_channel; | ||
73 | |||
74 | __le16 hlid_removed_bitmap; | ||
75 | |||
76 | /* bitmap of aged stations (by HLID) */ | ||
77 | __le16 sta_aging_status; | ||
78 | |||
79 | /* bitmap of stations (by HLID) which exceeded max tx retries */ | ||
80 | __le16 sta_tx_retry_exceeded; | ||
81 | |||
82 | /* discovery completed results */ | ||
83 | u8 discovery_tag; | ||
84 | u8 number_of_preq_results; | ||
85 | u8 number_of_prsp_results; | ||
86 | u8 reserved_5; | ||
87 | |||
88 | /* rx ba constraint */ | ||
89 | u8 role_id; /* 0xFF means any role. */ | ||
90 | u8 rx_ba_allowed; | ||
91 | u8 reserved_6[2]; | ||
92 | |||
93 | /* Channel switch results */ | ||
94 | |||
95 | u8 channel_switch_role_id; | ||
96 | u8 channel_switch_status; | ||
97 | u8 reserved_7[2]; | ||
98 | |||
99 | u8 ps_poll_delivery_failure_role_ids; | ||
100 | u8 stopped_role_ids; | ||
101 | u8 started_role_ids; | ||
102 | |||
103 | u8 reserved_8[9]; | ||
104 | } __packed; | ||
105 | |||
106 | int wl12xx_wait_for_event(struct wl1271 *wl, enum wlcore_wait_event event, | ||
107 | bool *timeout); | ||
108 | int wl12xx_process_mailbox_events(struct wl1271 *wl); | ||
109 | |||
110 | #endif | ||
111 | |||
diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c index b93de04ccd6a..7138fe49c63d 100644 --- a/drivers/net/wireless/ti/wl12xx/main.c +++ b/drivers/net/wireless/ti/wl12xx/main.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include "cmd.h" | 39 | #include "cmd.h" |
40 | #include "acx.h" | 40 | #include "acx.h" |
41 | #include "scan.h" | 41 | #include "scan.h" |
42 | #include "event.h" | ||
42 | #include "debugfs.h" | 43 | #include "debugfs.h" |
43 | 44 | ||
44 | static char *fref_param; | 45 | static char *fref_param; |
@@ -1229,6 +1230,23 @@ static int wl12xx_boot(struct wl1271 *wl) | |||
1229 | if (ret < 0) | 1230 | if (ret < 0) |
1230 | goto out; | 1231 | goto out; |
1231 | 1232 | ||
1233 | wl->event_mask = BSS_LOSE_EVENT_ID | | ||
1234 | REGAINED_BSS_EVENT_ID | | ||
1235 | SCAN_COMPLETE_EVENT_ID | | ||
1236 | ROLE_STOP_COMPLETE_EVENT_ID | | ||
1237 | RSSI_SNR_TRIGGER_0_EVENT_ID | | ||
1238 | PSPOLL_DELIVERY_FAILURE_EVENT_ID | | ||
1239 | SOFT_GEMINI_SENSE_EVENT_ID | | ||
1240 | PERIODIC_SCAN_REPORT_EVENT_ID | | ||
1241 | PERIODIC_SCAN_COMPLETE_EVENT_ID | | ||
1242 | DUMMY_PACKET_EVENT_ID | | ||
1243 | PEER_REMOVE_COMPLETE_EVENT_ID | | ||
1244 | BA_SESSION_RX_CONSTRAINT_EVENT_ID | | ||
1245 | REMAIN_ON_CHANNEL_COMPLETE_EVENT_ID | | ||
1246 | INACTIVE_STA_EVENT_ID | | ||
1247 | MAX_TX_RETRY_EVENT_ID | | ||
1248 | CHANNEL_SWITCH_COMPLETE_EVENT_ID; | ||
1249 | |||
1232 | ret = wlcore_boot_run_firmware(wl); | 1250 | ret = wlcore_boot_run_firmware(wl); |
1233 | if (ret < 0) | 1251 | if (ret < 0) |
1234 | goto out; | 1252 | goto out; |
@@ -1609,6 +1627,8 @@ static struct wlcore_ops wl12xx_ops = { | |||
1609 | .plt_init = wl12xx_plt_init, | 1627 | .plt_init = wl12xx_plt_init, |
1610 | .trigger_cmd = wl12xx_trigger_cmd, | 1628 | .trigger_cmd = wl12xx_trigger_cmd, |
1611 | .ack_event = wl12xx_ack_event, | 1629 | .ack_event = wl12xx_ack_event, |
1630 | .wait_for_event = wl12xx_wait_for_event, | ||
1631 | .process_mailbox_events = wl12xx_process_mailbox_events, | ||
1612 | .calc_tx_blocks = wl12xx_calc_tx_blocks, | 1632 | .calc_tx_blocks = wl12xx_calc_tx_blocks, |
1613 | .set_tx_desc_blocks = wl12xx_set_tx_desc_blocks, | 1633 | .set_tx_desc_blocks = wl12xx_set_tx_desc_blocks, |
1614 | .set_tx_desc_data_len = wl12xx_set_tx_desc_data_len, | 1634 | .set_tx_desc_data_len = wl12xx_set_tx_desc_data_len, |
@@ -1627,7 +1647,6 @@ static struct wlcore_ops wl12xx_ops = { | |||
1627 | .debugfs_init = wl12xx_debugfs_add_files, | 1647 | .debugfs_init = wl12xx_debugfs_add_files, |
1628 | .scan_start = wl12xx_scan_start, | 1648 | .scan_start = wl12xx_scan_start, |
1629 | .scan_stop = wl12xx_scan_stop, | 1649 | .scan_stop = wl12xx_scan_stop, |
1630 | .scan_completed = wl12xx_scan_completed, | ||
1631 | .sched_scan_start = wl12xx_sched_scan_start, | 1650 | .sched_scan_start = wl12xx_sched_scan_start, |
1632 | .sched_scan_stop = wl12xx_scan_sched_scan_stop, | 1651 | .sched_scan_stop = wl12xx_scan_sched_scan_stop, |
1633 | .get_spare_blocks = wl12xx_get_spare_blocks, | 1652 | .get_spare_blocks = wl12xx_get_spare_blocks, |
@@ -1719,7 +1738,8 @@ static int __devinit wl12xx_probe(struct platform_device *pdev) | |||
1719 | int ret; | 1738 | int ret; |
1720 | 1739 | ||
1721 | hw = wlcore_alloc_hw(sizeof(struct wl12xx_priv), | 1740 | hw = wlcore_alloc_hw(sizeof(struct wl12xx_priv), |
1722 | WL12XX_AGGR_BUFFER_SIZE); | 1741 | WL12XX_AGGR_BUFFER_SIZE, |
1742 | sizeof(struct wl12xx_event_mailbox)); | ||
1723 | if (IS_ERR(hw)) { | 1743 | if (IS_ERR(hw)) { |
1724 | wl1271_error("can't allocate hw"); | 1744 | wl1271_error("can't allocate hw"); |
1725 | ret = PTR_ERR(hw); | 1745 | ret = PTR_ERR(hw); |