diff options
author | Wey-Yi Guy <wey-yi.w.guy@intel.com> | 2011-07-08 11:46:26 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2011-07-11 15:02:08 -0400 |
commit | e98a1939a2d75354631487328339fe8d2117fce9 (patch) | |
tree | 9e5c81aaa7eacf23295fe6c20db132d714c73018 /drivers/net/wireless | |
parent | c7c1115b8ff485d3a48b70bb7135776a696778ad (diff) |
iwlagn: allow application own the uCode operation
Since we open the door to allow application control the device behavior through
testmode, add command to allow application request the ownership of the uCode
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-dev.h | 8 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-sv-open.c | 42 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-testmode.h | 14 |
3 files changed, 62 insertions, 2 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index b7e9fd1efb6e..fa0827f4d243 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h | |||
@@ -1263,6 +1263,10 @@ struct iwl_trans { | |||
1263 | const struct iwl_trans_ops *ops; | 1263 | const struct iwl_trans_ops *ops; |
1264 | }; | 1264 | }; |
1265 | 1265 | ||
1266 | /* uCode ownership */ | ||
1267 | #define IWL_OWNERSHIP_DRIVER 0 | ||
1268 | #define IWL_OWNERSHIP_TM 1 | ||
1269 | |||
1266 | struct iwl_priv { | 1270 | struct iwl_priv { |
1267 | 1271 | ||
1268 | /* ieee device used by generic ieee processing code */ | 1272 | /* ieee device used by generic ieee processing code */ |
@@ -1351,6 +1355,10 @@ struct iwl_priv { | |||
1351 | int fw_index; /* firmware we're trying to load */ | 1355 | int fw_index; /* firmware we're trying to load */ |
1352 | u32 ucode_ver; /* version of ucode, copy of | 1356 | u32 ucode_ver; /* version of ucode, copy of |
1353 | iwl_ucode.ver */ | 1357 | iwl_ucode.ver */ |
1358 | |||
1359 | /* uCode owner: default: IWL_OWNERSHIP_DRIVER */ | ||
1360 | u8 ucode_owner; | ||
1361 | |||
1354 | struct fw_img ucode_rt; | 1362 | struct fw_img ucode_rt; |
1355 | struct fw_img ucode_init; | 1363 | struct fw_img ucode_init; |
1356 | 1364 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-sv-open.c b/drivers/net/wireless/iwlwifi/iwl-sv-open.c index 653b7870adc1..ed9bd91ece7a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-sv-open.c +++ b/drivers/net/wireless/iwlwifi/iwl-sv-open.c | |||
@@ -105,6 +105,7 @@ struct nla_policy iwl_testmode_gnl_msg_policy[IWL_TM_ATTR_MAX] = { | |||
105 | 105 | ||
106 | [IWL_TM_ATTR_FIXRATE] = { .type = NLA_U32, }, | 106 | [IWL_TM_ATTR_FIXRATE] = { .type = NLA_U32, }, |
107 | 107 | ||
108 | [IWL_TM_ATTR_UCODE_OWNER] = { .type = NLA_U8, }, | ||
108 | }; | 109 | }; |
109 | 110 | ||
110 | /* | 111 | /* |
@@ -587,6 +588,42 @@ static int iwl_testmode_trace_dump(struct ieee80211_hw *hw, struct nlattr **tb, | |||
587 | return -ENOBUFS; | 588 | return -ENOBUFS; |
588 | } | 589 | } |
589 | 590 | ||
591 | /* | ||
592 | * This function handles the user application switch ucode ownership. | ||
593 | * | ||
594 | * It retrieves the mandatory fields IWL_TM_ATTR_UCODE_OWNER and | ||
595 | * decide who the current owner of the uCode | ||
596 | * | ||
597 | * If the current owner is OWNERSHIP_TM, then the only host command | ||
598 | * can deliver to uCode is from testmode, all the other host commands | ||
599 | * will dropped. | ||
600 | * | ||
601 | * default driver is the owner of uCode in normal operational mode | ||
602 | * | ||
603 | * @hw: ieee80211_hw object that represents the device | ||
604 | * @tb: gnl message fields from the user space | ||
605 | */ | ||
606 | static int iwl_testmode_ownership(struct ieee80211_hw *hw, struct nlattr **tb) | ||
607 | { | ||
608 | struct iwl_priv *priv = hw->priv; | ||
609 | u8 owner; | ||
610 | |||
611 | if (!tb[IWL_TM_ATTR_UCODE_OWNER]) { | ||
612 | IWL_DEBUG_INFO(priv, "Error finding ucode owner\n"); | ||
613 | return -ENOMSG; | ||
614 | } | ||
615 | |||
616 | owner = nla_get_u8(tb[IWL_TM_ATTR_UCODE_OWNER]); | ||
617 | if ((owner == IWL_OWNERSHIP_DRIVER) || (owner == IWL_OWNERSHIP_TM)) | ||
618 | priv->ucode_owner = owner; | ||
619 | else { | ||
620 | IWL_DEBUG_INFO(priv, "Invalid owner\n"); | ||
621 | return -EINVAL; | ||
622 | } | ||
623 | return 0; | ||
624 | } | ||
625 | |||
626 | |||
590 | /* The testmode gnl message handler that takes the gnl message from the | 627 | /* The testmode gnl message handler that takes the gnl message from the |
591 | * user space and parses it per the policy iwl_testmode_gnl_msg_policy, then | 628 | * user space and parses it per the policy iwl_testmode_gnl_msg_policy, then |
592 | * invoke the corresponding handlers. | 629 | * invoke the corresponding handlers. |
@@ -656,6 +693,11 @@ int iwl_testmode_cmd(struct ieee80211_hw *hw, void *data, int len) | |||
656 | result = iwl_testmode_trace(hw, tb); | 693 | result = iwl_testmode_trace(hw, tb); |
657 | break; | 694 | break; |
658 | 695 | ||
696 | case IWL_TM_CMD_APP2DEV_OWNERSHIP: | ||
697 | IWL_DEBUG_INFO(priv, "testmode change uCode ownership\n"); | ||
698 | result = iwl_testmode_ownership(hw, tb); | ||
699 | break; | ||
700 | |||
659 | default: | 701 | default: |
660 | IWL_DEBUG_INFO(priv, "Unknown testmode command\n"); | 702 | IWL_DEBUG_INFO(priv, "Unknown testmode command\n"); |
661 | result = -ENOSYS; | 703 | result = -ENOSYS; |
diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.h b/drivers/net/wireless/iwlwifi/iwl-testmode.h index d825188e5215..b980bda4b0f8 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.h +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.h | |||
@@ -103,6 +103,10 @@ | |||
103 | * @IWL_TM_CMD_DEV2APP_EEPROM_RSP: | 103 | * @IWL_TM_CMD_DEV2APP_EEPROM_RSP: |
104 | * commands from kernel space to carry the eeprom response | 104 | * commands from kernel space to carry the eeprom response |
105 | * to user application | 105 | * to user application |
106 | * @IWL_TM_CMD_APP2DEV_OWNERSHIP: | ||
107 | * commands from user application to own change the ownership of the uCode | ||
108 | * if application has the ownership, the only host command from | ||
109 | * testmode will deliver to uCode. Default owner is driver | ||
106 | */ | 110 | */ |
107 | enum iwl_tm_cmd_t { | 111 | enum iwl_tm_cmd_t { |
108 | IWL_TM_CMD_APP2DEV_UCODE = 1, | 112 | IWL_TM_CMD_APP2DEV_UCODE = 1, |
@@ -121,7 +125,8 @@ enum iwl_tm_cmd_t { | |||
121 | IWL_TM_CMD_DEV2APP_SYNC_RSP = 14, | 125 | IWL_TM_CMD_DEV2APP_SYNC_RSP = 14, |
122 | IWL_TM_CMD_DEV2APP_UCODE_RX_PKT = 15, | 126 | IWL_TM_CMD_DEV2APP_UCODE_RX_PKT = 15, |
123 | IWL_TM_CMD_DEV2APP_EEPROM_RSP = 16, | 127 | IWL_TM_CMD_DEV2APP_EEPROM_RSP = 16, |
124 | IWL_TM_CMD_MAX = 17, | 128 | IWL_TM_CMD_APP2DEV_OWNERSHIP = 17, |
129 | IWL_TM_CMD_MAX = 18, | ||
125 | }; | 130 | }; |
126 | 131 | ||
127 | /* | 132 | /* |
@@ -187,6 +192,10 @@ enum iwl_tm_cmd_t { | |||
187 | * The mandatory fields are: | 192 | * The mandatory fields are: |
188 | * IWL_TM_ATTR_FIXRATE for the fixed rate | 193 | * IWL_TM_ATTR_FIXRATE for the fixed rate |
189 | * | 194 | * |
195 | * @IWL_TM_ATTR_UCODE_OWNER: | ||
196 | * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_OWNERSHIP, | ||
197 | * The mandatory fields are: | ||
198 | * IWL_TM_ATTR_UCODE_OWNER for the new owner | ||
190 | */ | 199 | */ |
191 | enum iwl_tm_attr_t { | 200 | enum iwl_tm_attr_t { |
192 | IWL_TM_ATTR_NOT_APPLICABLE = 0, | 201 | IWL_TM_ATTR_NOT_APPLICABLE = 0, |
@@ -203,7 +212,8 @@ enum iwl_tm_attr_t { | |||
203 | IWL_TM_ATTR_TRACE_SIZE = 11, | 212 | IWL_TM_ATTR_TRACE_SIZE = 11, |
204 | IWL_TM_ATTR_TRACE_DUMP = 12, | 213 | IWL_TM_ATTR_TRACE_DUMP = 12, |
205 | IWL_TM_ATTR_FIXRATE = 13, | 214 | IWL_TM_ATTR_FIXRATE = 13, |
206 | IWL_TM_ATTR_MAX = 14, | 215 | IWL_TM_ATTR_UCODE_OWNER = 14, |
216 | IWL_TM_ATTR_MAX = 15, | ||
207 | }; | 217 | }; |
208 | 218 | ||
209 | /* uCode trace buffer */ | 219 | /* uCode trace buffer */ |