aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/mvm/power.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/iwlwifi/mvm/power.c')
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/power.c54
1 files changed, 34 insertions, 20 deletions
diff --git a/drivers/net/wireless/iwlwifi/mvm/power.c b/drivers/net/wireless/iwlwifi/mvm/power.c
index ac6d2c86e75c..2eea5b374ece 100644
--- a/drivers/net/wireless/iwlwifi/mvm/power.c
+++ b/drivers/net/wireless/iwlwifi/mvm/power.c
@@ -439,14 +439,17 @@ static int _iwl_mvm_power_mac_update_mode(struct iwl_mvm *mvm,
439 sizeof(cmd), &cmd); 439 sizeof(cmd), &cmd);
440} 440}
441 441
442static int iwl_mvm_power_mac_update_mode(struct iwl_mvm *mvm, 442int iwl_mvm_power_mac_update_mode(struct iwl_mvm *mvm,
443 struct ieee80211_vif *vif) 443 struct ieee80211_vif *vif)
444 444
445{ 445{
446 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); 446 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
447 bool ba_enable; 447 bool ba_enable;
448 int ret; 448 int ret;
449 449
450 if (!(mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_PM_CMD_SUPPORT))
451 return 0;
452
450 ret = _iwl_mvm_power_mac_update_mode(mvm, vif); 453 ret = _iwl_mvm_power_mac_update_mode(mvm, vif);
451 if (ret) 454 if (ret)
452 return ret; 455 return ret;
@@ -458,13 +461,15 @@ static int iwl_mvm_power_mac_update_mode(struct iwl_mvm *mvm,
458 return iwl_mvm_update_beacon_abort(mvm, vif, ba_enable); 461 return iwl_mvm_update_beacon_abort(mvm, vif, ba_enable);
459} 462}
460 463
461static int iwl_mvm_power_mac_disable(struct iwl_mvm *mvm, 464int iwl_mvm_power_mac_disable(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
462 struct ieee80211_vif *vif)
463{ 465{
464 struct iwl_mac_power_cmd cmd = {}; 466 struct iwl_mac_power_cmd cmd = {};
465 struct iwl_mvm_vif *mvmvif __maybe_unused = 467 struct iwl_mvm_vif *mvmvif __maybe_unused =
466 iwl_mvm_vif_from_mac80211(vif); 468 iwl_mvm_vif_from_mac80211(vif);
467 469
470 if (!(mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_PM_CMD_SUPPORT))
471 return 0;
472
468 if (vif->type != NL80211_IFTYPE_STATION || vif->p2p) 473 if (vif->type != NL80211_IFTYPE_STATION || vif->p2p)
469 return 0; 474 return 0;
470 475
@@ -513,8 +518,11 @@ static int _iwl_mvm_power_update_device(struct iwl_mvm *mvm, bool force_disable)
513 &cmd); 518 &cmd);
514} 519}
515 520
516static int iwl_mvm_power_update_device(struct iwl_mvm *mvm) 521int iwl_mvm_power_update_device(struct iwl_mvm *mvm)
517{ 522{
523 if (!(mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_PM_CMD_SUPPORT))
524 return 0;
525
518 return _iwl_mvm_power_update_device(mvm, false); 526 return _iwl_mvm_power_update_device(mvm, false);
519} 527}
520 528
@@ -577,9 +585,8 @@ static void iwl_mvm_power_binding_iterator(void *_data, u8 *mac,
577 WARN_ONCE(ret, "Failed to update power parameters on a specific vif\n"); 585 WARN_ONCE(ret, "Failed to update power parameters on a specific vif\n");
578} 586}
579 587
580static void _iwl_mvm_power_update_binding(struct iwl_mvm *mvm, 588void iwl_mvm_power_update_binding(struct iwl_mvm *mvm,
581 struct ieee80211_vif *vif, 589 struct ieee80211_vif *vif, bool assign)
582 bool assign)
583{ 590{
584 bool ba_enable; 591 bool ba_enable;
585 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); 592 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
@@ -589,6 +596,9 @@ static void _iwl_mvm_power_update_binding(struct iwl_mvm *mvm,
589 596
590 lockdep_assert_held(&mvm->mutex); 597 lockdep_assert_held(&mvm->mutex);
591 598
599 if (!(mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_PM_CMD_SUPPORT))
600 return;
601
592 if (vif->type == NL80211_IFTYPE_MONITOR) { 602 if (vif->type == NL80211_IFTYPE_MONITOR) {
593 int ret = _iwl_mvm_power_update_device(mvm, assign); 603 int ret = _iwl_mvm_power_update_device(mvm, assign);
594 mvm->ps_prevented = assign; 604 mvm->ps_prevented = assign;
@@ -615,14 +625,18 @@ static void _iwl_mvm_power_update_binding(struct iwl_mvm *mvm,
615} 625}
616 626
617#ifdef CONFIG_IWLWIFI_DEBUGFS 627#ifdef CONFIG_IWLWIFI_DEBUGFS
618static int iwl_mvm_power_mac_dbgfs_read(struct iwl_mvm *mvm, 628int iwl_mvm_power_mac_dbgfs_read(struct iwl_mvm *mvm,
619 struct ieee80211_vif *vif, char *buf, 629 struct ieee80211_vif *vif, char *buf,
620 int bufsz) 630 int bufsz)
621{ 631{
622 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); 632 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
623 struct iwl_mac_power_cmd cmd = {}; 633 struct iwl_mac_power_cmd cmd = {};
624 int pos = 0; 634 int pos = 0;
625 635
636 if (WARN_ON(!(mvm->fw->ucode_capa.flags &
637 IWL_UCODE_TLV_FLAGS_PM_CMD_SUPPORT)))
638 return 0;
639
626 mutex_lock(&mvm->mutex); 640 mutex_lock(&mvm->mutex);
627 memcpy(&cmd, &mvmvif->mac_pwr_cmd, sizeof(cmd)); 641 memcpy(&cmd, &mvmvif->mac_pwr_cmd, sizeof(cmd));
628 mutex_unlock(&mvm->mutex); 642 mutex_unlock(&mvm->mutex);
@@ -863,12 +877,12 @@ int iwl_mvm_update_beacon_filter(struct iwl_mvm *mvm,
863 return iwl_mvm_enable_beacon_filter(mvm, vif, flags); 877 return iwl_mvm_enable_beacon_filter(mvm, vif, flags);
864} 878}
865 879
866const struct iwl_mvm_power_ops pm_mac_ops = { 880int iwl_power_legacy_set_cam_mode(struct iwl_mvm *mvm)
867 .power_update_mode = iwl_mvm_power_mac_update_mode, 881{
868 .power_update_device_mode = iwl_mvm_power_update_device, 882 struct iwl_powertable_cmd cmd = {
869 .power_disable = iwl_mvm_power_mac_disable, 883 .keep_alive_seconds = POWER_KEEP_ALIVE_PERIOD_SEC,
870 .power_update_binding = _iwl_mvm_power_update_binding, 884 };
871#ifdef CONFIG_IWLWIFI_DEBUGFS 885
872 .power_dbgfs_read = iwl_mvm_power_mac_dbgfs_read, 886 return iwl_mvm_send_cmd_pdu(mvm, POWER_TABLE_CMD, CMD_SYNC,
873#endif 887 sizeof(cmd), &cmd);
874}; 888}