cmd.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * This file is part of wl18xx
  3. *
  4. * Copyright (C) 2011 Texas Instruments Inc.
  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. #include "../wlcore/cmd.h"
  22. #include "../wlcore/debug.h"
  23. #include "../wlcore/hw_ops.h"
  24. #include "cmd.h"
  25. int wl18xx_cmd_channel_switch(struct wl1271 *wl,
  26. struct wl12xx_vif *wlvif,
  27. struct ieee80211_channel_switch *ch_switch)
  28. {
  29. struct wl18xx_cmd_channel_switch *cmd;
  30. u32 supported_rates;
  31. int ret;
  32. wl1271_debug(DEBUG_ACX, "cmd channel switch");
  33. cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
  34. if (!cmd) {
  35. ret = -ENOMEM;
  36. goto out;
  37. }
  38. cmd->role_id = wlvif->role_id;
  39. cmd->channel = ch_switch->channel->hw_value;
  40. cmd->switch_time = ch_switch->count;
  41. cmd->stop_tx = ch_switch->block_tx;
  42. switch (ch_switch->channel->band) {
  43. case IEEE80211_BAND_2GHZ:
  44. cmd->band = WLCORE_BAND_2_4GHZ;
  45. break;
  46. case IEEE80211_BAND_5GHZ:
  47. cmd->band = WLCORE_BAND_5GHZ;
  48. break;
  49. default:
  50. wl1271_error("invalid channel switch band: %d",
  51. ch_switch->channel->band);
  52. ret = -EINVAL;
  53. goto out_free;
  54. }
  55. supported_rates = CONF_TX_ENABLED_RATES | CONF_TX_MCS_RATES |
  56. wlcore_hw_sta_get_ap_rate_mask(wl, wlvif);
  57. if (wlvif->p2p)
  58. supported_rates &= ~CONF_TX_CCK_RATES;
  59. cmd->local_supported_rates = cpu_to_le32(supported_rates);
  60. cmd->channel_type = wlvif->channel_type;
  61. ret = wl1271_cmd_send(wl, CMD_CHANNEL_SWITCH, cmd, sizeof(*cmd), 0);
  62. if (ret < 0) {
  63. wl1271_error("failed to send channel switch command");
  64. goto out_free;
  65. }
  66. out_free:
  67. kfree(cmd);
  68. out:
  69. return ret;
  70. }