aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/libertas/cmd.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2011-05-05 17:09:28 -0400
committerDavid S. Miller <davem@davemloft.net>2011-05-05 17:09:28 -0400
commit90864fbc7639d7a2300c67a18c9fb9fbcf7d51d2 (patch)
tree6951c8d0e529dbfc7c4cec75d4cec63350e39b7c /drivers/net/wireless/libertas/cmd.c
parent228e548e602061b08ee8e8966f567c12aa079682 (diff)
parenta70171dce9cd44cb06c7d299eba9fa87a8933045 (diff)
Merge branch 'for-davem' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next-2.6
Diffstat (limited to 'drivers/net/wireless/libertas/cmd.c')
-rw-r--r--drivers/net/wireless/libertas/cmd.c245
1 files changed, 127 insertions, 118 deletions
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c
index 7e8a658b7670..6a96fc9c1cea 100644
--- a/drivers/net/wireless/libertas/cmd.c
+++ b/drivers/net/wireless/libertas/cmd.c
@@ -1,7 +1,7 @@
1/** 1/*
2 * This file contains the handling of command. 2 * This file contains the handling of command.
3 * It prepares command and sends it to firmware when it is ready. 3 * It prepares command and sends it to firmware when it is ready.
4 */ 4 */
5 5
6#include <linux/kfifo.h> 6#include <linux/kfifo.h>
7#include <linux/sched.h> 7#include <linux/sched.h>
@@ -16,14 +16,14 @@
16#define CAL_RSSI(snr, nf) ((s32)((s32)(snr) + CAL_NF(nf))) 16#define CAL_RSSI(snr, nf) ((s32)((s32)(snr) + CAL_NF(nf)))
17 17
18/** 18/**
19 * @brief Simple callback that copies response back into command 19 * lbs_cmd_copyback - Simple callback that copies response back into command
20 * 20 *
21 * @param priv A pointer to struct lbs_private structure 21 * @priv: A pointer to &struct lbs_private structure
22 * @param extra A pointer to the original command structure for which 22 * @extra: A pointer to the original command structure for which
23 * 'resp' is a response 23 * 'resp' is a response
24 * @param resp A pointer to the command response 24 * @resp: A pointer to the command response
25 * 25 *
26 * @return 0 on success, error on failure 26 * returns: 0 on success, error on failure
27 */ 27 */
28int lbs_cmd_copyback(struct lbs_private *priv, unsigned long extra, 28int lbs_cmd_copyback(struct lbs_private *priv, unsigned long extra,
29 struct cmd_header *resp) 29 struct cmd_header *resp)
@@ -38,15 +38,15 @@ int lbs_cmd_copyback(struct lbs_private *priv, unsigned long extra,
38EXPORT_SYMBOL_GPL(lbs_cmd_copyback); 38EXPORT_SYMBOL_GPL(lbs_cmd_copyback);
39 39
40/** 40/**
41 * @brief Simple callback that ignores the result. Use this if 41 * lbs_cmd_async_callback - Simple callback that ignores the result.
42 * you just want to send a command to the hardware, but don't 42 * Use this if you just want to send a command to the hardware, but don't
43 * care for the result. 43 * care for the result.
44 * 44 *
45 * @param priv ignored 45 * @priv: ignored
46 * @param extra ignored 46 * @extra: ignored
47 * @param resp ignored 47 * @resp: ignored
48 * 48 *
49 * @return 0 for success 49 * returns: 0 for success
50 */ 50 */
51static int lbs_cmd_async_callback(struct lbs_private *priv, unsigned long extra, 51static int lbs_cmd_async_callback(struct lbs_private *priv, unsigned long extra,
52 struct cmd_header *resp) 52 struct cmd_header *resp)
@@ -56,10 +56,11 @@ static int lbs_cmd_async_callback(struct lbs_private *priv, unsigned long extra,
56 56
57 57
58/** 58/**
59 * @brief Checks whether a command is allowed in Power Save mode 59 * is_command_allowed_in_ps - tests if a command is allowed in Power Save mode
60 *
61 * @cmd: the command ID
60 * 62 *
61 * @param command the command ID 63 * returns: 1 if allowed, 0 if not allowed
62 * @return 1 if allowed, 0 if not allowed
63 */ 64 */
64static u8 is_command_allowed_in_ps(u16 cmd) 65static u8 is_command_allowed_in_ps(u16 cmd)
65{ 66{
@@ -75,11 +76,12 @@ static u8 is_command_allowed_in_ps(u16 cmd)
75} 76}
76 77
77/** 78/**
78 * @brief Updates the hardware details like MAC address and regulatory region 79 * lbs_update_hw_spec - Updates the hardware details like MAC address
80 * and regulatory region
79 * 81 *
80 * @param priv A pointer to struct lbs_private structure 82 * @priv: A pointer to &struct lbs_private structure
81 * 83 *
82 * @return 0 on success, error on failure 84 * returns: 0 on success, error on failure
83 */ 85 */
84int lbs_update_hw_spec(struct lbs_private *priv) 86int lbs_update_hw_spec(struct lbs_private *priv)
85{ 87{
@@ -217,14 +219,14 @@ int lbs_host_sleep_cfg(struct lbs_private *priv, uint32_t criteria,
217EXPORT_SYMBOL_GPL(lbs_host_sleep_cfg); 219EXPORT_SYMBOL_GPL(lbs_host_sleep_cfg);
218 220
219/** 221/**
220 * @brief Sets the Power Save mode 222 * lbs_set_ps_mode - Sets the Power Save mode
221 * 223 *
222 * @param priv A pointer to struct lbs_private structure 224 * @priv: A pointer to &struct lbs_private structure
223 * @param cmd_action The Power Save operation (PS_MODE_ACTION_ENTER_PS or 225 * @cmd_action: The Power Save operation (PS_MODE_ACTION_ENTER_PS or
224 * PS_MODE_ACTION_EXIT_PS) 226 * PS_MODE_ACTION_EXIT_PS)
225 * @param block Whether to block on a response or not 227 * @block: Whether to block on a response or not
226 * 228 *
227 * @return 0 on success, error on failure 229 * returns: 0 on success, error on failure
228 */ 230 */
229int lbs_set_ps_mode(struct lbs_private *priv, u16 cmd_action, bool block) 231int lbs_set_ps_mode(struct lbs_private *priv, u16 cmd_action, bool block)
230{ 232{
@@ -417,13 +419,13 @@ int lbs_set_host_sleep(struct lbs_private *priv, int host_sleep)
417} 419}
418 420
419/** 421/**
420 * @brief Set an SNMP MIB value 422 * lbs_set_snmp_mib - Set an SNMP MIB value
421 * 423 *
422 * @param priv A pointer to struct lbs_private structure 424 * @priv: A pointer to &struct lbs_private structure
423 * @param oid The OID to set in the firmware 425 * @oid: The OID to set in the firmware
424 * @param val Value to set the OID to 426 * @val: Value to set the OID to
425 * 427 *
426 * @return 0 on success, error on failure 428 * returns: 0 on success, error on failure
427 */ 429 */
428int lbs_set_snmp_mib(struct lbs_private *priv, u32 oid, u16 val) 430int lbs_set_snmp_mib(struct lbs_private *priv, u32 oid, u16 val)
429{ 431{
@@ -467,13 +469,13 @@ out:
467} 469}
468 470
469/** 471/**
470 * @brief Get an SNMP MIB value 472 * lbs_get_snmp_mib - Get an SNMP MIB value
471 * 473 *
472 * @param priv A pointer to struct lbs_private structure 474 * @priv: A pointer to &struct lbs_private structure
473 * @param oid The OID to retrieve from the firmware 475 * @oid: The OID to retrieve from the firmware
474 * @param out_val Location for the returned value 476 * @out_val: Location for the returned value
475 * 477 *
476 * @return 0 on success, error on failure 478 * returns: 0 on success, error on failure
477 */ 479 */
478int lbs_get_snmp_mib(struct lbs_private *priv, u32 oid, u16 *out_val) 480int lbs_get_snmp_mib(struct lbs_private *priv, u32 oid, u16 *out_val)
479{ 481{
@@ -510,14 +512,14 @@ out:
510} 512}
511 513
512/** 514/**
513 * @brief Get the min, max, and current TX power 515 * lbs_get_tx_power - Get the min, max, and current TX power
514 * 516 *
515 * @param priv A pointer to struct lbs_private structure 517 * @priv: A pointer to &struct lbs_private structure
516 * @param curlevel Current power level in dBm 518 * @curlevel: Current power level in dBm
517 * @param minlevel Minimum supported power level in dBm (optional) 519 * @minlevel: Minimum supported power level in dBm (optional)
518 * @param maxlevel Maximum supported power level in dBm (optional) 520 * @maxlevel: Maximum supported power level in dBm (optional)
519 * 521 *
520 * @return 0 on success, error on failure 522 * returns: 0 on success, error on failure
521 */ 523 */
522int lbs_get_tx_power(struct lbs_private *priv, s16 *curlevel, s16 *minlevel, 524int lbs_get_tx_power(struct lbs_private *priv, s16 *curlevel, s16 *minlevel,
523 s16 *maxlevel) 525 s16 *maxlevel)
@@ -545,12 +547,12 @@ int lbs_get_tx_power(struct lbs_private *priv, s16 *curlevel, s16 *minlevel,
545} 547}
546 548
547/** 549/**
548 * @brief Set the TX power 550 * lbs_set_tx_power - Set the TX power
549 * 551 *
550 * @param priv A pointer to struct lbs_private structure 552 * @priv: A pointer to &struct lbs_private structure
551 * @param dbm The desired power level in dBm 553 * @dbm: The desired power level in dBm
552 * 554 *
553 * @return 0 on success, error on failure 555 * returns: 0 on success, error on failure
554 */ 556 */
555int lbs_set_tx_power(struct lbs_private *priv, s16 dbm) 557int lbs_set_tx_power(struct lbs_private *priv, s16 dbm)
556{ 558{
@@ -573,12 +575,13 @@ int lbs_set_tx_power(struct lbs_private *priv, s16 dbm)
573} 575}
574 576
575/** 577/**
576 * @brief Enable or disable monitor mode (only implemented on OLPC usb8388 FW) 578 * lbs_set_monitor_mode - Enable or disable monitor mode
579 * (only implemented on OLPC usb8388 FW)
577 * 580 *
578 * @param priv A pointer to struct lbs_private structure 581 * @priv: A pointer to &struct lbs_private structure
579 * @param enable 1 to enable monitor mode, 0 to disable 582 * @enable: 1 to enable monitor mode, 0 to disable
580 * 583 *
581 * @return 0 on success, error on failure 584 * returns: 0 on success, error on failure
582 */ 585 */
583int lbs_set_monitor_mode(struct lbs_private *priv, int enable) 586int lbs_set_monitor_mode(struct lbs_private *priv, int enable)
584{ 587{
@@ -604,11 +607,11 @@ int lbs_set_monitor_mode(struct lbs_private *priv, int enable)
604} 607}
605 608
606/** 609/**
607 * @brief Get the radio channel 610 * lbs_get_channel - Get the radio channel
608 * 611 *
609 * @param priv A pointer to struct lbs_private structure 612 * @priv: A pointer to &struct lbs_private structure
610 * 613 *
611 * @return The channel on success, error on failure 614 * returns: The channel on success, error on failure
612 */ 615 */
613static int lbs_get_channel(struct lbs_private *priv) 616static int lbs_get_channel(struct lbs_private *priv)
614{ 617{
@@ -650,12 +653,12 @@ int lbs_update_channel(struct lbs_private *priv)
650} 653}
651 654
652/** 655/**
653 * @brief Set the radio channel 656 * lbs_set_channel - Set the radio channel
654 * 657 *
655 * @param priv A pointer to struct lbs_private structure 658 * @priv: A pointer to &struct lbs_private structure
656 * @param channel The desired channel, or 0 to clear a locked channel 659 * @channel: The desired channel, or 0 to clear a locked channel
657 * 660 *
658 * @return 0 on success, error on failure 661 * returns: 0 on success, error on failure
659 */ 662 */
660int lbs_set_channel(struct lbs_private *priv, u8 channel) 663int lbs_set_channel(struct lbs_private *priv, u8 channel)
661{ 664{
@@ -686,12 +689,13 @@ out:
686} 689}
687 690
688/** 691/**
689 * @brief Get current RSSI and noise floor 692 * lbs_get_rssi - Get current RSSI and noise floor
690 * 693 *
691 * @param priv A pointer to struct lbs_private structure 694 * @priv: A pointer to &struct lbs_private structure
692 * @param rssi On successful return, signal level in mBm 695 * @rssi: On successful return, signal level in mBm
696 * @nf: On successful return, Noise floor
693 * 697 *
694 * @return The channel on success, error on failure 698 * returns: The channel on success, error on failure
695 */ 699 */
696int lbs_get_rssi(struct lbs_private *priv, s8 *rssi, s8 *nf) 700int lbs_get_rssi(struct lbs_private *priv, s8 *rssi, s8 *nf)
697{ 701{
@@ -719,13 +723,14 @@ int lbs_get_rssi(struct lbs_private *priv, s8 *rssi, s8 *nf)
719} 723}
720 724
721/** 725/**
722 * @brief Send regulatory and 802.11d domain information to the firmware 726 * lbs_set_11d_domain_info - Send regulatory and 802.11d domain information
727 * to the firmware
723 * 728 *
724 * @param priv pointer to struct lbs_private 729 * @priv: pointer to &struct lbs_private
725 * @param request cfg80211 regulatory request structure 730 * @request: cfg80211 regulatory request structure
726 * @param bands the device's supported bands and channels 731 * @bands: the device's supported bands and channels
727 * 732 *
728 * @return 0 on success, error code on failure 733 * returns: 0 on success, error code on failure
729*/ 734*/
730int lbs_set_11d_domain_info(struct lbs_private *priv, 735int lbs_set_11d_domain_info(struct lbs_private *priv,
731 struct regulatory_request *request, 736 struct regulatory_request *request,
@@ -842,15 +847,15 @@ int lbs_set_11d_domain_info(struct lbs_private *priv,
842} 847}
843 848
844/** 849/**
845 * @brief Read a MAC, Baseband, or RF register 850 * lbs_get_reg - Read a MAC, Baseband, or RF register
846 * 851 *
847 * @param priv pointer to struct lbs_private 852 * @priv: pointer to &struct lbs_private
848 * @param cmd register command, one of CMD_MAC_REG_ACCESS, 853 * @reg: register command, one of CMD_MAC_REG_ACCESS,
849 * CMD_BBP_REG_ACCESS, or CMD_RF_REG_ACCESS 854 * CMD_BBP_REG_ACCESS, or CMD_RF_REG_ACCESS
850 * @param offset byte offset of the register to get 855 * @offset: byte offset of the register to get
851 * @param value on success, the value of the register at 'offset' 856 * @value: on success, the value of the register at 'offset'
852 * 857 *
853 * @return 0 on success, error code on failure 858 * returns: 0 on success, error code on failure
854*/ 859*/
855int lbs_get_reg(struct lbs_private *priv, u16 reg, u16 offset, u32 *value) 860int lbs_get_reg(struct lbs_private *priv, u16 reg, u16 offset, u32 *value)
856{ 861{
@@ -886,15 +891,15 @@ out:
886} 891}
887 892
888/** 893/**
889 * @brief Write a MAC, Baseband, or RF register 894 * lbs_set_reg - Write a MAC, Baseband, or RF register
890 * 895 *
891 * @param priv pointer to struct lbs_private 896 * @priv: pointer to &struct lbs_private
892 * @param cmd register command, one of CMD_MAC_REG_ACCESS, 897 * @reg: register command, one of CMD_MAC_REG_ACCESS,
893 * CMD_BBP_REG_ACCESS, or CMD_RF_REG_ACCESS 898 * CMD_BBP_REG_ACCESS, or CMD_RF_REG_ACCESS
894 * @param offset byte offset of the register to set 899 * @offset: byte offset of the register to set
895 * @param value the value to write to the register at 'offset' 900 * @value: the value to write to the register at 'offset'
896 * 901 *
897 * @return 0 on success, error code on failure 902 * returns: 0 on success, error code on failure
898*/ 903*/
899int lbs_set_reg(struct lbs_private *priv, u16 reg, u16 offset, u32 value) 904int lbs_set_reg(struct lbs_private *priv, u16 reg, u16 offset, u32 value)
900{ 905{
@@ -1023,7 +1028,7 @@ static void lbs_submit_command(struct lbs_private *priv,
1023 lbs_deb_leave(LBS_DEB_HOST); 1028 lbs_deb_leave(LBS_DEB_HOST);
1024} 1029}
1025 1030
1026/** 1031/*
1027 * This function inserts command node to cmdfreeq 1032 * This function inserts command node to cmdfreeq
1028 * after cleans it. Requires priv->driver_lock held. 1033 * after cleans it. Requires priv->driver_lock held.
1029 */ 1034 */
@@ -1125,11 +1130,12 @@ void lbs_set_mac_control(struct lbs_private *priv)
1125} 1130}
1126 1131
1127/** 1132/**
1128 * @brief This function allocates the command buffer and link 1133 * lbs_allocate_cmd_buffer - allocates the command buffer and links
1129 * it to command free queue. 1134 * it to command free queue
1135 *
1136 * @priv: A pointer to &struct lbs_private structure
1130 * 1137 *
1131 * @param priv A pointer to struct lbs_private structure 1138 * returns: 0 for success or -1 on error
1132 * @return 0 or -1
1133 */ 1139 */
1134int lbs_allocate_cmd_buffer(struct lbs_private *priv) 1140int lbs_allocate_cmd_buffer(struct lbs_private *priv)
1135{ 1141{
@@ -1171,10 +1177,11 @@ done:
1171} 1177}
1172 1178
1173/** 1179/**
1174 * @brief This function frees the command buffer. 1180 * lbs_free_cmd_buffer - free the command buffer
1175 * 1181 *
1176 * @param priv A pointer to struct lbs_private structure 1182 * @priv: A pointer to &struct lbs_private structure
1177 * @return 0 or -1 1183 *
1184 * returns: 0 for success
1178 */ 1185 */
1179int lbs_free_cmd_buffer(struct lbs_private *priv) 1186int lbs_free_cmd_buffer(struct lbs_private *priv)
1180{ 1187{
@@ -1211,11 +1218,13 @@ done:
1211} 1218}
1212 1219
1213/** 1220/**
1214 * @brief This function gets a free command node if available in 1221 * lbs_get_free_cmd_node - gets a free command node if available in
1215 * command free queue. 1222 * command free queue
1223 *
1224 * @priv: A pointer to &struct lbs_private structure
1216 * 1225 *
1217 * @param priv A pointer to struct lbs_private structure 1226 * returns: A pointer to &cmd_ctrl_node structure on success
1218 * @return cmd_ctrl_node A pointer to cmd_ctrl_node structure or NULL 1227 * or %NULL on error
1219 */ 1228 */
1220static struct cmd_ctrl_node *lbs_get_free_cmd_node(struct lbs_private *priv) 1229static struct cmd_ctrl_node *lbs_get_free_cmd_node(struct lbs_private *priv)
1221{ 1230{
@@ -1245,12 +1254,12 @@ static struct cmd_ctrl_node *lbs_get_free_cmd_node(struct lbs_private *priv)
1245} 1254}
1246 1255
1247/** 1256/**
1248 * @brief This function executes next command in command 1257 * lbs_execute_next_command - execute next command in command
1249 * pending queue. It will put firmware back to PS mode 1258 * pending queue. Will put firmware back to PS mode if applicable.
1250 * if applicable.
1251 * 1259 *
1252 * @param priv A pointer to struct lbs_private structure 1260 * @priv: A pointer to &struct lbs_private structure
1253 * @return 0 or -1 1261 *
1262 * returns: 0 on success or -1 on error
1254 */ 1263 */
1255int lbs_execute_next_command(struct lbs_private *priv) 1264int lbs_execute_next_command(struct lbs_private *priv)
1256{ 1265{
@@ -1454,12 +1463,12 @@ out:
1454} 1463}
1455 1464
1456/** 1465/**
1457 * @brief This function checks condition and prepares to 1466 * lbs_ps_confirm_sleep - checks condition and prepares to
1458 * send sleep confirm command to firmware if ok. 1467 * send sleep confirm command to firmware if ok
1468 *
1469 * @priv: A pointer to &struct lbs_private structure
1459 * 1470 *
1460 * @param priv A pointer to struct lbs_private structure 1471 * returns: n/a
1461 * @param psmode Power Saving mode
1462 * @return n/a
1463 */ 1472 */
1464void lbs_ps_confirm_sleep(struct lbs_private *priv) 1473void lbs_ps_confirm_sleep(struct lbs_private *priv)
1465{ 1474{
@@ -1499,16 +1508,16 @@ void lbs_ps_confirm_sleep(struct lbs_private *priv)
1499 1508
1500 1509
1501/** 1510/**
1502 * @brief Configures the transmission power control functionality. 1511 * lbs_set_tpc_cfg - Configures the transmission power control functionality
1503 * 1512 *
1504 * @param priv A pointer to struct lbs_private structure 1513 * @priv: A pointer to &struct lbs_private structure
1505 * @param enable Transmission power control enable 1514 * @enable: Transmission power control enable
1506 * @param p0 Power level when link quality is good (dBm). 1515 * @p0: Power level when link quality is good (dBm).
1507 * @param p1 Power level when link quality is fair (dBm). 1516 * @p1: Power level when link quality is fair (dBm).
1508 * @param p2 Power level when link quality is poor (dBm). 1517 * @p2: Power level when link quality is poor (dBm).
1509 * @param usesnr Use Signal to Noise Ratio in TPC 1518 * @usesnr: Use Signal to Noise Ratio in TPC
1510 * 1519 *
1511 * @return 0 on success 1520 * returns: 0 on success
1512 */ 1521 */
1513int lbs_set_tpc_cfg(struct lbs_private *priv, int enable, int8_t p0, int8_t p1, 1522int lbs_set_tpc_cfg(struct lbs_private *priv, int enable, int8_t p0, int8_t p1,
1514 int8_t p2, int usesnr) 1523 int8_t p2, int usesnr)
@@ -1531,15 +1540,15 @@ int lbs_set_tpc_cfg(struct lbs_private *priv, int enable, int8_t p0, int8_t p1,
1531} 1540}
1532 1541
1533/** 1542/**
1534 * @brief Configures the power adaptation settings. 1543 * lbs_set_power_adapt_cfg - Configures the power adaptation settings
1535 * 1544 *
1536 * @param priv A pointer to struct lbs_private structure 1545 * @priv: A pointer to &struct lbs_private structure
1537 * @param enable Power adaptation enable 1546 * @enable: Power adaptation enable
1538 * @param p0 Power level for 1, 2, 5.5 and 11 Mbps (dBm). 1547 * @p0: Power level for 1, 2, 5.5 and 11 Mbps (dBm).
1539 * @param p1 Power level for 6, 9, 12, 18, 22, 24 and 36 Mbps (dBm). 1548 * @p1: Power level for 6, 9, 12, 18, 22, 24 and 36 Mbps (dBm).
1540 * @param p2 Power level for 48 and 54 Mbps (dBm). 1549 * @p2: Power level for 48 and 54 Mbps (dBm).
1541 * 1550 *
1542 * @return 0 on Success 1551 * returns: 0 on Success
1543 */ 1552 */
1544 1553
1545int lbs_set_power_adapt_cfg(struct lbs_private *priv, int enable, int8_t p0, 1554int lbs_set_power_adapt_cfg(struct lbs_private *priv, int enable, int8_t p0,