Lines Matching defs:drv
68 #include "iwl-drv.h"
97 * struct iwl_drv - drv common data
98 * @list: list of drv structures using this opmode
135 /* Protects the table contents, i.e. the ops pointer & drv list */
140 struct list_head drv; /* list of devices using this op_mode */
158 static void iwl_free_fw_desc(struct iwl_drv *drv, struct fw_desc *desc)
165 static void iwl_free_fw_img(struct iwl_drv *drv, struct fw_img *img)
169 iwl_free_fw_desc(drv, &img->sec[i]);
173 static void iwl_dealloc_ucode(struct iwl_drv *drv)
177 kfree(drv->fw.dbg.dest_tlv);
178 for (i = 0; i < ARRAY_SIZE(drv->fw.dbg.conf_tlv); i++)
179 kfree(drv->fw.dbg.conf_tlv[i]);
180 for (i = 0; i < ARRAY_SIZE(drv->fw.dbg.trigger_tlv); i++)
181 kfree(drv->fw.dbg.trigger_tlv[i]);
182 kfree(drv->fw.dbg.mem_tlv);
183 kfree(drv->fw.iml);
184 kfree(drv->fw.ucode_capa.cmd_versions);
187 iwl_free_fw_img(drv, drv->fw.img + i);
190 memset(&drv->fw, 0, sizeof(drv->fw));
193 static int iwl_alloc_fw_desc(struct iwl_drv *drv, struct fw_desc *desc,
218 static int iwl_request_firmware(struct iwl_drv *drv, bool first)
220 const struct iwl_cfg *cfg = drv->trans->cfg;
223 if (drv->trans->trans_cfg->device_family == IWL_DEVICE_FAMILY_9000 &&
224 (CSR_HW_REV_STEP(drv->trans->hw_rev) != SILICON_B_STEP &&
225 CSR_HW_REV_STEP(drv->trans->hw_rev) != SILICON_C_STEP)) {
226 IWL_ERR(drv,
228 drv->trans->hw_rev);
233 drv->fw_index = cfg->ucode_api_max;
234 sprintf(tag, "%d", drv->fw_index);
236 drv->fw_index--;
237 sprintf(tag, "%d", drv->fw_index);
240 if (drv->fw_index < cfg->ucode_api_min) {
241 IWL_ERR(drv, "no suitable firmware found!\n");
244 IWL_ERR(drv, "%s%d is required\n", cfg->fw_name_pre,
247 IWL_ERR(drv, "minimum version required: %s%d\n",
249 IWL_ERR(drv, "maximum version supported: %s%d\n",
253 IWL_ERR(drv,
258 snprintf(drv->firmware_name, sizeof(drv->firmware_name), "%s%s.ucode",
261 IWL_DEBUG_FW_INFO(drv, "attempting to load firmware '%s'\n",
262 drv->firmware_name);
264 return request_firmware_nowait(THIS_MODULE, 1, drv->firmware_name,
265 drv->trans->dev,
266 GFP_KERNEL, drv, iwl_req_fw_callback);
441 static int iwl_set_default_calib(struct iwl_drv *drv, const u8 *data)
447 IWL_ERR(drv, "Wrong ucode_type %u for default calibration.\n",
451 drv->fw.default_calib[ucode_type].flow_trigger =
453 drv->fw.default_calib[ucode_type].event_trigger =
459 static void iwl_set_ucode_api_flags(struct iwl_drv *drv, const u8 *data,
468 IWL_WARN(drv,
480 static void iwl_set_ucode_capabilities(struct iwl_drv *drv, const u8 *data,
489 IWL_WARN(drv,
501 static const char *iwl_reduced_fw_name(struct iwl_drv *drv)
503 const char *name = drv->firmware_name;
511 static int iwl_parse_v1_v2_firmware(struct iwl_drv *drv,
520 drv->fw.ucode_ver = le32_to_cpu(ucode->ver);
521 api_ver = IWL_UCODE_API(drv->fw.ucode_ver);
527 IWL_ERR(drv, "File size too small!\n");
546 IWL_ERR(drv, "File size too small!\n");
567 snprintf(drv->fw.fw_version,
568 sizeof(drv->fw.fw_version),
570 IWL_UCODE_MAJOR(drv->fw.ucode_ver),
571 IWL_UCODE_MINOR(drv->fw.ucode_ver),
572 IWL_UCODE_API(drv->fw.ucode_ver),
573 IWL_UCODE_SERIAL(drv->fw.ucode_ver),
574 buildstr, iwl_reduced_fw_name(drv));
584 IWL_ERR(drv,
612 static int iwl_parse_tlv_firmware(struct iwl_drv *drv,
632 IWL_ERR(drv, "uCode has invalid length: %zd\n", len);
637 IWL_ERR(drv, "invalid uCode magic: 0X%x\n",
642 drv->fw.ucode_ver = le32_to_cpu(ucode->ver);
643 memcpy(drv->fw.human_readable, ucode->human_readable,
644 sizeof(drv->fw.human_readable));
652 snprintf(drv->fw.fw_version,
653 sizeof(drv->fw.fw_version),
655 IWL_UCODE_MAJOR(drv->fw.ucode_ver),
656 IWL_UCODE_MINOR(drv->fw.ucode_ver),
657 IWL_UCODE_API(drv->fw.ucode_ver),
658 IWL_UCODE_SERIAL(drv->fw.ucode_ver),
659 buildstr, iwl_reduced_fw_name(drv));
674 IWL_ERR(drv, "invalid TLV len: %zd/%u\n",
719 IWL_ERR(drv, "Found unexpected BOOT ucode\n");
751 iwl_set_ucode_api_flags(drv, tlv_data, capa);
756 iwl_set_ucode_capabilities(drv, tlv_data, capa);
797 drv->fw.enhance_sensitivity_table = true;
826 drv->fw.type = IWL_FW_MVM;
831 drv->fw.type = IWL_FW_MVM;
836 drv->fw.type = IWL_FW_MVM;
841 if (iwl_set_default_calib(drv, tlv_data))
847 drv->fw.phy_config = le32_to_cpup((__le32 *)tlv_data);
848 drv->fw.valid_tx_ant = (drv->fw.phy_config &
851 drv->fw.valid_rx_ant = (drv->fw.phy_config &
858 drv->fw.type = IWL_FW_MVM;
863 drv->fw.type = IWL_FW_MVM;
868 drv->fw.type = IWL_FW_MVM;
877 drv->fw.img[IWL_UCODE_REGULAR].is_dual_cpus =
879 drv->fw.img[IWL_UCODE_INIT].is_dual_cpus =
881 drv->fw.img[IWL_UCODE_WOWLAN].is_dual_cpus =
884 IWL_ERR(drv, "Driver support upto 2 CPUs\n");
889 if (iwl_store_cscheme(&drv->fw, tlv_data, tlv_len))
911 snprintf(drv->fw.fw_version,
912 sizeof(drv->fw.fw_version),
914 local_comp, iwl_reduced_fw_name(drv));
916 snprintf(drv->fw.fw_version,
917 sizeof(drv->fw.fw_version),
919 local_comp, iwl_reduced_fw_name(drv));
933 IWL_ERR(drv,
940 IWL_ERR(drv,
955 IWL_INFO(drv, "Found debug destination: %s\n",
958 drv->fw.dbg.n_dest_reg = (dest_v1) ?
966 drv->fw.dbg.n_dest_reg /=
967 sizeof(drv->fw.dbg.dest_tlv->reg_ops[0]);
975 IWL_ERR(drv,
981 if (conf->id >= ARRAY_SIZE(drv->fw.dbg.conf_tlv)) {
982 IWL_ERR(drv,
989 IWL_ERR(drv,
998 IWL_INFO(drv, "Found debug configuration: %d\n",
1010 if (trigger_id >= ARRAY_SIZE(drv->fw.dbg.trigger_tlv)) {
1011 IWL_ERR(drv,
1018 IWL_ERR(drv,
1024 IWL_INFO(drv, "Found debug trigger: %u\n", trigger->id);
1032 IWL_ERR(drv,
1037 drv->fw.dbg.dump_mask =
1052 IWL_DEBUG_FW(drv,
1057 IWL_ERR(drv,
1064 IWL_ERR(drv,
1070 drv->fw.img[IWL_UCODE_REGULAR].paging_mem_size =
1073 drv->fw.img[usniffer_img].paging_mem_size =
1088 IWL_DEBUG_INFO(drv, "Found debug memory segment: %u\n",
1102 drv->fw.iml_len = tlv_len;
1103 drv->fw.iml = kmemdup(tlv_data, tlv_len, GFP_KERNEL);
1104 if (!drv->fw.iml)
1130 IWL_INFO(drv, "TLV_FW_FSEQ_VERSION: %s\n",
1139 IWL_ERR(drv,
1153 if (drv->trans->trans_cfg->device_family <
1156 drv->trans->dbg.umac_error_event_table =
1159 drv->trans->dbg.error_event_table_tlv_status |=
1169 if (drv->trans->trans_cfg->device_family <
1172 drv->trans->dbg.lmac_error_event_table[0] =
1175 drv->trans->dbg.error_event_table_tlv_status |=
1185 iwl_dbg_tlv_alloc(drv->trans, tlv, false);
1189 IWL_ERR(drv,
1205 IWL_DEBUG_INFO(drv, "unknown TLV: %d\n", tlv_type);
1212 IWL_ERR(drv,
1218 IWL_ERR(drv, "invalid TLV after parsing: %zd\n", len);
1219 iwl_print_hex_dump(drv, IWL_DL_FW, (u8 *)data, len);
1226 IWL_ERR(drv, "TLV %d has invalid size: %u\n", tlv_type, tlv_len);
1228 iwl_print_hex_dump(drv, IWL_DL_FW, tlv_data, tlv_len);
1233 static int iwl_alloc_ucode(struct iwl_drv *drv,
1243 drv->fw.img[type].sec = sec;
1244 drv->fw.img[type].num_sec = pieces->img[type].sec_counter;
1247 if (iwl_alloc_fw_desc(drv, &sec[i], get_sec(pieces, type, i)))
1253 static int validate_sec_sizes(struct iwl_drv *drv,
1257 IWL_DEBUG_INFO(drv, "f/w package hdr runtime inst size = %zd\n",
1260 IWL_DEBUG_INFO(drv, "f/w package hdr runtime data size = %zd\n",
1263 IWL_DEBUG_INFO(drv, "f/w package hdr init inst size = %zd\n",
1265 IWL_DEBUG_INFO(drv, "f/w package hdr init data size = %zd\n",
1271 IWL_ERR(drv, "uCode instr len %zd too large to fit in\n",
1279 IWL_ERR(drv, "uCode data len %zd too large to fit in\n",
1287 IWL_ERR(drv, "uCode init instr len %zd too large to fit in\n",
1295 IWL_ERR(drv, "uCode init data len %zd too large to fit in\n",
1304 _iwl_op_mode_start(struct iwl_drv *drv, struct iwlwifi_opmode_table *op)
1314 drv->dbgfs_op_mode = debugfs_create_dir(op->name,
1315 drv->dbgfs_drv);
1316 dbgfs_dir = drv->dbgfs_op_mode;
1319 op_mode = ops->start(drv->trans, drv->trans->cfg,
1320 &drv->fw, dbgfs_dir);
1325 IWL_ERR(drv, "retry init count %d\n", retry);
1328 debugfs_remove_recursive(drv->dbgfs_op_mode);
1329 drv->dbgfs_op_mode = NULL;
1336 static void _iwl_op_mode_stop(struct iwl_drv *drv)
1339 if (drv->op_mode) {
1340 iwl_op_mode_stop(drv->op_mode);
1341 drv->op_mode = NULL;
1344 debugfs_remove_recursive(drv->dbgfs_op_mode);
1345 drv->dbgfs_op_mode = NULL;
1358 struct iwl_drv *drv = context;
1359 struct iwl_fw *fw = &drv->fw;
1364 const unsigned int api_max = drv->trans->cfg->ucode_api_max;
1365 const unsigned int api_min = drv->trans->cfg->ucode_api_min;
1388 IWL_DEBUG_FW_INFO(drv, "Loaded firmware file '%s' (%zd bytes).\n",
1389 drv->firmware_name, ucode_raw->size);
1393 IWL_ERR(drv, "File size way too small!\n");
1401 err = iwl_parse_v1_v2_firmware(drv, ucode_raw, pieces);
1403 err = iwl_parse_tlv_firmware(drv, ucode_raw, pieces,
1409 if (fw_has_api(&drv->fw.ucode_capa, IWL_UCODE_TLV_API_NEW_VERSION))
1410 api_ver = drv->fw.ucode_ver;
1412 api_ver = IWL_UCODE_API(drv->fw.ucode_ver);
1420 IWL_ERR(drv,
1431 if (fw->type == IWL_FW_DVM && validate_sec_sizes(drv, pieces,
1432 drv->trans->cfg))
1442 if (iwl_alloc_ucode(drv, pieces, i))
1446 size_t dbg_dest_size = sizeof(*drv->fw.dbg.dest_tlv) +
1447 sizeof(drv->fw.dbg.dest_tlv->reg_ops[0]) *
1448 drv->fw.dbg.n_dest_reg;
1450 drv->fw.dbg.dest_tlv = kmalloc(dbg_dest_size, GFP_KERNEL);
1452 if (!drv->fw.dbg.dest_tlv)
1456 memcpy(drv->fw.dbg.dest_tlv, pieces->dbg_dest_tlv_v1,
1460 drv->fw.dbg.dest_tlv;
1475 sizeof(drv->fw.dbg.dest_tlv->reg_ops[0]) *
1476 drv->fw.dbg.n_dest_reg);
1492 for (i = 0; i < ARRAY_SIZE(drv->fw.dbg.conf_tlv); i++) {
1494 drv->fw.dbg.conf_tlv[i] =
1498 if (!drv->fw.dbg.conf_tlv[i])
1525 for (i = 0; i < ARRAY_SIZE(drv->fw.dbg.trigger_tlv); i++) {
1538 drv->fw.dbg.trigger_tlv_len[i] =
1540 drv->fw.dbg.trigger_tlv[i] =
1542 drv->fw.dbg.trigger_tlv_len[i],
1544 if (!drv->fw.dbg.trigger_tlv[i])
1551 drv->fw.dbg.mem_tlv = pieces->dbg_mem_tlv;
1553 drv->fw.dbg.n_mem_tlv = pieces->n_mem_tlv;
1565 drv->trans->trans_cfg->base_params->max_event_log_size;
1572 drv->trans->trans_cfg->base_params->max_event_log_size;
1600 IWL_INFO(drv, "loaded firmware version %s op_mode %s\n",
1601 drv->fw.fw_version, op->name);
1603 iwl_dbg_tlv_load_bin(drv->trans->dev, drv->trans);
1606 list_add_tail(&drv->list, &op->drv);
1609 drv->op_mode = _iwl_op_mode_start(drv, op);
1611 if (!drv->op_mode) {
1625 complete(&drv->request_firmware_complete);
1640 if (iwl_request_firmware(drv, false))
1647 complete(&drv->request_firmware_complete);
1648 device_release_driver(drv->trans->dev);
1649 /* drv has just been freed by the release */
1653 iwl_dealloc_ucode(drv);
1665 struct iwl_drv *drv;
1668 drv = kzalloc(sizeof(*drv), GFP_KERNEL);
1669 if (!drv) {
1674 drv->trans = trans;
1675 drv->dev = trans->dev;
1677 init_completion(&drv->request_firmware_complete);
1678 INIT_LIST_HEAD(&drv->list);
1682 drv->dbgfs_drv = debugfs_create_dir(dev_name(trans->dev),
1686 drv->trans->dbgfs_dir = debugfs_create_dir("trans", drv->dbgfs_drv);
1689 drv->trans->dbg.domains_bitmap = IWL_TRANS_FW_DBG_DOMAIN(drv->trans);
1691 ret = iwl_request_firmware(drv, true);
1697 return drv;
1701 debugfs_remove_recursive(drv->dbgfs_drv);
1702 iwl_dbg_tlv_free(drv->trans);
1704 kfree(drv);
1709 void iwl_drv_stop(struct iwl_drv *drv)
1711 wait_for_completion(&drv->request_firmware_complete);
1713 _iwl_op_mode_stop(drv);
1715 iwl_dealloc_ucode(drv);
1723 if (!list_empty(&drv->list))
1724 list_del(&drv->list);
1728 drv->trans->ops->debugfs_cleanup(drv->trans);
1730 debugfs_remove_recursive(drv->dbgfs_drv);
1733 iwl_dbg_tlv_free(drv->trans);
1735 kfree(drv);
1753 struct iwl_drv *drv;
1763 list_for_each_entry(drv, &op->drv, list)
1764 drv->op_mode = _iwl_op_mode_start(drv, op);
1777 struct iwl_drv *drv;
1786 list_for_each_entry(drv, &iwlwifi_opmode_table[i].drv, list)
1787 _iwl_op_mode_stop(drv);
1803 INIT_LIST_HEAD(&iwlwifi_opmode_table[i].drv);