Lines Matching refs:ar

20 static const void *carl9170_fw_find_desc(struct ar9170 *ar, const u8 descid[4],  in carl9170_fw_find_desc()  argument
25 carl9170fw_for_each_hdr(iter, ar->fw.desc) { in carl9170_fw_find_desc()
39 static int carl9170_fw_verify_descs(struct ar9170 *ar, in carl9170_fw_verify_descs() argument
82 static void carl9170_fw_info(struct ar9170 *ar) in carl9170_fw_info() argument
88 dev_info(&ar->udev->dev, "driver API: %s 2%03d-%02d-%02d [%d-%d]\n", in carl9170_fw_info()
93 motd_desc = carl9170_fw_find_desc(ar, MOTD_MAGIC, in carl9170_fw_info()
102 dev_info(&ar->udev->dev, "firmware API: %.*s 2%03d-%02d-%02d\n", in carl9170_fw_info()
108 strlcpy(ar->hw->wiphy->fw_version, motd_desc->release, in carl9170_fw_info()
109 sizeof(ar->hw->wiphy->fw_version)); in carl9170_fw_info()
131 static int carl9170_fw_checksum(struct ar9170 *ar, const __u8 *data, in carl9170_fw_checksum() argument
141 last_desc = carl9170_fw_find_desc(ar, LAST_MAGIC, in carl9170_fw_checksum()
146 otus_desc = carl9170_fw_find_desc(ar, OTUS_MAGIC, in carl9170_fw_checksum()
149 dev_err(&ar->udev->dev, "failed to find compatible firmware " in carl9170_fw_checksum()
154 chk_desc = carl9170_fw_find_desc(ar, CHK_MAGIC, in carl9170_fw_checksum()
158 dev_warn(&ar->udev->dev, "Unprotected firmware image.\n"); in carl9170_fw_checksum()
176 dev_err(&ar->udev->dev, "fw checksum test failed.\n"); in carl9170_fw_checksum()
182 dev_err(&ar->udev->dev, "descriptor check failed.\n"); in carl9170_fw_checksum()
188 static int carl9170_fw_tx_sequence(struct ar9170 *ar) in carl9170_fw_tx_sequence() argument
192 txsq_desc = carl9170_fw_find_desc(ar, TXSQ_MAGIC, sizeof(*txsq_desc), in carl9170_fw_tx_sequence()
195 ar->fw.tx_seq_table = le32_to_cpu(txsq_desc->seq_table_addr); in carl9170_fw_tx_sequence()
196 if (!valid_cpu_addr(ar->fw.tx_seq_table)) in carl9170_fw_tx_sequence()
199 ar->fw.tx_seq_table = 0; in carl9170_fw_tx_sequence()
205 static void carl9170_fw_set_if_combinations(struct ar9170 *ar, in carl9170_fw_set_if_combinations() argument
208 if (ar->fw.vif_num < 2) in carl9170_fw_set_if_combinations()
211 ar->if_comb_limits[0].max = ar->fw.vif_num; in carl9170_fw_set_if_combinations()
212 ar->if_comb_limits[0].types = if_comb_types; in carl9170_fw_set_if_combinations()
214 ar->if_combs[0].num_different_channels = 1; in carl9170_fw_set_if_combinations()
215 ar->if_combs[0].max_interfaces = ar->fw.vif_num; in carl9170_fw_set_if_combinations()
216 ar->if_combs[0].limits = ar->if_comb_limits; in carl9170_fw_set_if_combinations()
217 ar->if_combs[0].n_limits = ARRAY_SIZE(ar->if_comb_limits); in carl9170_fw_set_if_combinations()
219 ar->hw->wiphy->iface_combinations = ar->if_combs; in carl9170_fw_set_if_combinations()
220 ar->hw->wiphy->n_iface_combinations = ARRAY_SIZE(ar->if_combs); in carl9170_fw_set_if_combinations()
223 static int carl9170_fw(struct ar9170 *ar, const __u8 *data, size_t len) in carl9170_fw() argument
229 err = carl9170_fw_checksum(ar, data, len); in carl9170_fw()
233 otus_desc = carl9170_fw_find_desc(ar, OTUS_MAGIC, in carl9170_fw()
243 dev_err(&ar->udev->dev, "invalid firmware descriptor " in carl9170_fw()
248 ar->fw.api_version = otus_desc->api_ver; in carl9170_fw()
250 if (ar->fw.api_version < CARL9170FW_API_MIN_VER || in carl9170_fw()
251 ar->fw.api_version > CARL9170FW_API_MAX_VER) { in carl9170_fw()
252 dev_err(&ar->udev->dev, "unsupported firmware api version.\n"); in carl9170_fw()
258 dev_err(&ar->udev->dev, "firmware does support " in carl9170_fw()
265 dev_warn(&ar->udev->dev, "driver does not support all " in carl9170_fw()
270 dev_info(&ar->udev->dev, "crypto offloading is disabled " in carl9170_fw()
272 ar->fw.disable_offload_fw = true; in carl9170_fw()
276 ieee80211_hw_set(ar->hw, SUPPORTS_PS); in carl9170_fw()
279 dev_err(&ar->udev->dev, "firmware does not provide " in carl9170_fw()
285 ar->fw.offset = le16_to_cpu(otus_desc->miniboot_size); in carl9170_fw()
287 ar->fw.offset = 0; in carl9170_fw()
290 ar->hw->extra_tx_headroom += sizeof(struct ar9170_stream); in carl9170_fw()
291 ar->fw.tx_stream = true; in carl9170_fw()
295 ar->fw.rx_stream = true; in carl9170_fw()
298 ar->fw.rx_filter = true; in carl9170_fw()
299 ar->rx_filter_caps = FIF_FCSFAIL | FIF_PLCPFAIL | in carl9170_fw()
304 ar->fw.hw_counters = true; in carl9170_fw()
307 device_set_wakeup_enable(&ar->udev->dev, true); in carl9170_fw()
310 ar->fw.ba_filter = true; in carl9170_fw()
315 ar->fw.vif_num = otus_desc->vif_num; in carl9170_fw()
316 ar->fw.cmd_bufs = otus_desc->cmd_bufs; in carl9170_fw()
317 ar->fw.address = le32_to_cpu(otus_desc->fw_address); in carl9170_fw()
318 ar->fw.rx_size = le16_to_cpu(otus_desc->rx_max_frame_len); in carl9170_fw()
319 ar->fw.mem_blocks = min_t(unsigned int, otus_desc->tx_descs, 0xfe); in carl9170_fw()
320 atomic_set(&ar->mem_free_blocks, ar->fw.mem_blocks); in carl9170_fw()
321 ar->fw.mem_block_size = le16_to_cpu(otus_desc->tx_frag_len); in carl9170_fw()
323 if (ar->fw.vif_num >= AR9170_MAX_VIRTUAL_MAC || !ar->fw.vif_num || in carl9170_fw()
324 ar->fw.mem_blocks < 16 || !ar->fw.cmd_bufs || in carl9170_fw()
325 ar->fw.mem_block_size < 64 || ar->fw.mem_block_size > 512 || in carl9170_fw()
326 ar->fw.rx_size > 32768 || ar->fw.rx_size < 4096 || in carl9170_fw()
327 !valid_cpu_addr(ar->fw.address)) { in carl9170_fw()
328 dev_err(&ar->udev->dev, "firmware shows obvious signs of " in carl9170_fw()
333 ar->fw.beacon_addr = le32_to_cpu(otus_desc->bcn_addr); in carl9170_fw()
334 ar->fw.beacon_max_len = le16_to_cpu(otus_desc->bcn_len); in carl9170_fw()
336 if (valid_dma_addr(ar->fw.beacon_addr) && ar->fw.beacon_max_len >= in carl9170_fw()
338 ar->hw->wiphy->interface_modes |= BIT(NL80211_IFTYPE_ADHOC); in carl9170_fw()
350 carl9170_fw_set_if_combinations(ar, if_comb_types); in carl9170_fw()
352 ar->hw->wiphy->interface_modes |= if_comb_types; in carl9170_fw()
354 ar->hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; in carl9170_fw()
357 ar->hw->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL | in carl9170_fw()
361 return carl9170_fw_tx_sequence(ar); in carl9170_fw()
365 carl9170_find_fw_desc(struct ar9170 *ar, const __u8 *fw_data, const size_t len) in carl9170_find_fw_desc() argument
371 dev_err(&ar->udev->dev, "firmware size is out of bound.\n"); in carl9170_find_fw_desc()
394 int carl9170_parse_firmware(struct ar9170 *ar) in carl9170_parse_firmware() argument
397 const struct firmware *fw = ar->fw.fw; in carl9170_parse_firmware()
404 fw_desc = carl9170_find_fw_desc(ar, fw->data, fw->size); in carl9170_parse_firmware()
407 dev_err(&ar->udev->dev, "unsupported firmware.\n"); in carl9170_parse_firmware()
413 err = carl9170_fw_verify_descs(ar, fw_desc, fw->size - header_offset); in carl9170_parse_firmware()
415 dev_err(&ar->udev->dev, "damaged firmware (%d).\n", err); in carl9170_parse_firmware()
419 ar->fw.desc = fw_desc; in carl9170_parse_firmware()
421 carl9170_fw_info(ar); in carl9170_parse_firmware()
423 err = carl9170_fw(ar, fw->data, fw->size); in carl9170_parse_firmware()
425 dev_err(&ar->udev->dev, "failed to parse firmware (%d).\n", in carl9170_parse_firmware()