firmware.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. #include "wcn36xx.h"
  3. #include "firmware.h"
  4. #define DEFINE(s)[s] = #s
  5. static const char * const wcn36xx_firmware_caps_names[] = {
  6. DEFINE(MCC),
  7. DEFINE(P2P),
  8. DEFINE(DOT11AC),
  9. DEFINE(SLM_SESSIONIZATION),
  10. DEFINE(DOT11AC_OPMODE),
  11. DEFINE(SAP32STA),
  12. DEFINE(TDLS),
  13. DEFINE(P2P_GO_NOA_DECOUPLE_INIT_SCAN),
  14. DEFINE(WLANACTIVE_OFFLOAD),
  15. DEFINE(BEACON_OFFLOAD),
  16. DEFINE(SCAN_OFFLOAD),
  17. DEFINE(ROAM_OFFLOAD),
  18. DEFINE(BCN_MISS_OFFLOAD),
  19. DEFINE(STA_POWERSAVE),
  20. DEFINE(STA_ADVANCED_PWRSAVE),
  21. DEFINE(AP_UAPSD),
  22. DEFINE(AP_DFS),
  23. DEFINE(BLOCKACK),
  24. DEFINE(PHY_ERR),
  25. DEFINE(BCN_FILTER),
  26. DEFINE(RTT),
  27. DEFINE(RATECTRL),
  28. DEFINE(WOW),
  29. DEFINE(WLAN_ROAM_SCAN_OFFLOAD),
  30. DEFINE(SPECULATIVE_PS_POLL),
  31. DEFINE(SCAN_SCH),
  32. DEFINE(IBSS_HEARTBEAT_OFFLOAD),
  33. DEFINE(WLAN_SCAN_OFFLOAD),
  34. DEFINE(WLAN_PERIODIC_TX_PTRN),
  35. DEFINE(ADVANCE_TDLS),
  36. DEFINE(BATCH_SCAN),
  37. DEFINE(FW_IN_TX_PATH),
  38. DEFINE(EXTENDED_NSOFFLOAD_SLOT),
  39. DEFINE(CH_SWITCH_V1),
  40. DEFINE(HT40_OBSS_SCAN),
  41. DEFINE(UPDATE_CHANNEL_LIST),
  42. DEFINE(WLAN_MCADDR_FLT),
  43. DEFINE(WLAN_CH144),
  44. DEFINE(NAN),
  45. DEFINE(TDLS_SCAN_COEXISTENCE),
  46. DEFINE(LINK_LAYER_STATS_MEAS),
  47. DEFINE(MU_MIMO),
  48. DEFINE(EXTENDED_SCAN),
  49. DEFINE(DYNAMIC_WMM_PS),
  50. DEFINE(MAC_SPOOFED_SCAN),
  51. DEFINE(BMU_ERROR_GENERIC_RECOVERY),
  52. DEFINE(DISA),
  53. DEFINE(FW_STATS),
  54. DEFINE(WPS_PRBRSP_TMPL),
  55. DEFINE(BCN_IE_FLT_DELTA),
  56. DEFINE(TDLS_OFF_CHANNEL),
  57. DEFINE(RTT3),
  58. DEFINE(MGMT_FRAME_LOGGING),
  59. DEFINE(ENHANCED_TXBD_COMPLETION),
  60. DEFINE(LOGGING_ENHANCEMENT),
  61. DEFINE(EXT_SCAN_ENHANCED),
  62. DEFINE(MEMORY_DUMP_SUPPORTED),
  63. DEFINE(PER_PKT_STATS_SUPPORTED),
  64. DEFINE(EXT_LL_STAT),
  65. DEFINE(WIFI_CONFIG),
  66. DEFINE(ANTENNA_DIVERSITY_SELECTION),
  67. };
  68. #undef DEFINE
  69. const char *wcn36xx_firmware_get_cap_name(enum wcn36xx_firmware_feat_caps x)
  70. {
  71. if (x >= ARRAY_SIZE(wcn36xx_firmware_caps_names))
  72. return "UNKNOWN";
  73. return wcn36xx_firmware_caps_names[x];
  74. }
  75. void wcn36xx_firmware_set_feat_caps(u32 *bitmap,
  76. enum wcn36xx_firmware_feat_caps cap)
  77. {
  78. int arr_idx, bit_idx;
  79. if (cap < 0 || cap > 127) {
  80. wcn36xx_warn("error cap idx %d\n", cap);
  81. return;
  82. }
  83. arr_idx = cap / 32;
  84. bit_idx = cap % 32;
  85. bitmap[arr_idx] |= (1 << bit_idx);
  86. }
  87. int wcn36xx_firmware_get_feat_caps(u32 *bitmap,
  88. enum wcn36xx_firmware_feat_caps cap)
  89. {
  90. int arr_idx, bit_idx;
  91. if (cap < 0 || cap > 127) {
  92. wcn36xx_warn("error cap idx %d\n", cap);
  93. return -EINVAL;
  94. }
  95. arr_idx = cap / 32;
  96. bit_idx = cap % 32;
  97. return (bitmap[arr_idx] & (1 << bit_idx)) ? 1 : 0;
  98. }
  99. void wcn36xx_firmware_clear_feat_caps(u32 *bitmap,
  100. enum wcn36xx_firmware_feat_caps cap)
  101. {
  102. int arr_idx, bit_idx;
  103. if (cap < 0 || cap > 127) {
  104. wcn36xx_warn("error cap idx %d\n", cap);
  105. return;
  106. }
  107. arr_idx = cap / 32;
  108. bit_idx = cap % 32;
  109. bitmap[arr_idx] &= ~(1 << bit_idx);
  110. }