Lines Matching +full:cmd +full:- +full:db

1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
3 * Copyright (C) 2005-2014, 2020-2021 Intel Corporation
10 #include "iwl-drv.h"
11 #include "iwl-phy-db.h"
12 #include "iwl-debug.h"
13 #include "iwl-op-mode.h"
14 #include "iwl-trans.h"
22 * struct iwl_phy_db - stores phy configuration and calibration data.
68 phy_db->trans = trans; in iwl_phy_db_init()
70 phy_db->n_group_txp = -1; in iwl_phy_db_init()
71 phy_db->n_group_papd = -1; in iwl_phy_db_init()
73 /* TODO: add default values of the phy db. */ in iwl_phy_db_init()
79 * get phy db section: returns a pointer to a phy db section specified by
92 return &phy_db->cfg; in iwl_phy_db_get_section()
94 return &phy_db->calib_nch; in iwl_phy_db_get_section()
96 if (chg_id >= phy_db->n_group_papd) in iwl_phy_db_get_section()
98 return &phy_db->calib_ch_group_papd[chg_id]; in iwl_phy_db_get_section()
100 if (chg_id >= phy_db->n_group_txp) in iwl_phy_db_get_section()
102 return &phy_db->calib_ch_group_txp[chg_id]; in iwl_phy_db_get_section()
118 kfree(entry->data); in iwl_phy_db_free_section()
119 entry->data = NULL; in iwl_phy_db_free_section()
120 entry->size = 0; in iwl_phy_db_free_section()
133 for (i = 0; i < phy_db->n_group_papd; i++) in iwl_phy_db_free()
135 kfree(phy_db->calib_ch_group_papd); in iwl_phy_db_free()
137 for (i = 0; i < phy_db->n_group_txp; i++) in iwl_phy_db_free()
139 kfree(phy_db->calib_ch_group_txp); in iwl_phy_db_free()
150 (struct iwl_calib_res_notif_phy_db *)pkt->data; in iwl_phy_db_set_section()
157 return -EINVAL; in iwl_phy_db_set_section()
159 type = le16_to_cpu(phy_db_notif->type); in iwl_phy_db_set_section()
160 size = le16_to_cpu(phy_db_notif->length); in iwl_phy_db_set_section()
163 return -EINVAL; in iwl_phy_db_set_section()
166 return -EINVAL; in iwl_phy_db_set_section()
169 chg_id = le16_to_cpup((__le16 *)phy_db_notif->data); in iwl_phy_db_set_section()
170 if (phy_db && !phy_db->calib_ch_group_papd) { in iwl_phy_db_set_section()
175 phy_db->calib_ch_group_papd = kcalloc(chg_id + 1, in iwl_phy_db_set_section()
178 if (!phy_db->calib_ch_group_papd) in iwl_phy_db_set_section()
179 return -ENOMEM; in iwl_phy_db_set_section()
180 phy_db->n_group_papd = chg_id + 1; in iwl_phy_db_set_section()
183 chg_id = le16_to_cpup((__le16 *)phy_db_notif->data); in iwl_phy_db_set_section()
184 if (phy_db && !phy_db->calib_ch_group_txp) { in iwl_phy_db_set_section()
189 phy_db->calib_ch_group_txp = kcalloc(chg_id + 1, in iwl_phy_db_set_section()
192 if (!phy_db->calib_ch_group_txp) in iwl_phy_db_set_section()
193 return -ENOMEM; in iwl_phy_db_set_section()
194 phy_db->n_group_txp = chg_id + 1; in iwl_phy_db_set_section()
200 return -EINVAL; in iwl_phy_db_set_section()
202 kfree(entry->data); in iwl_phy_db_set_section()
203 entry->data = kmemdup(phy_db_notif->data, size, GFP_ATOMIC); in iwl_phy_db_set_section()
204 if (!entry->data) { in iwl_phy_db_set_section()
205 entry->size = 0; in iwl_phy_db_set_section()
206 return -ENOMEM; in iwl_phy_db_set_section()
209 entry->size = size; in iwl_phy_db_set_section()
211 IWL_DEBUG_INFO(phy_db->trans, in iwl_phy_db_set_section()
235 return ch_id - 1; in ch_id_to_ch_index()
239 return (ch_id - 12) / 4; in ch_id_to_ch_index()
240 return (ch_id - 13) / 4; in ch_id_to_ch_index()
266 for (i = 0; i < phy_db->n_group_txp; i++) { in channel_id_to_txp()
267 txp_chg = (void *)phy_db->calib_ch_group_txp[i].data; in channel_id_to_txp()
274 if (le16_to_cpu(txp_chg->max_channel_idx) >= ch_index) in channel_id_to_txp()
287 return -EINVAL; in iwl_phy_db_get_section_data()
297 return -EINVAL; in iwl_phy_db_get_section_data()
299 *data = entry->data; in iwl_phy_db_get_section_data()
300 *size = entry->size; in iwl_phy_db_get_section_data()
302 IWL_DEBUG_INFO(phy_db->trans, in iwl_phy_db_get_section_data()
313 struct iwl_host_cmd cmd = { in iwl_send_phy_db_cmd() local
317 IWL_DEBUG_INFO(phy_db->trans, in iwl_send_phy_db_cmd()
318 "Sending PHY-DB hcmd of type %d, of length %d\n", in iwl_send_phy_db_cmd()
321 /* Set phy db cmd variables */ in iwl_send_phy_db_cmd()
326 cmd.data[0] = &phy_db_cmd; in iwl_send_phy_db_cmd()
327 cmd.len[0] = sizeof(struct iwl_phy_db_cmd); in iwl_send_phy_db_cmd()
328 cmd.data[1] = data; in iwl_send_phy_db_cmd()
329 cmd.len[1] = length; in iwl_send_phy_db_cmd()
330 cmd.dataflags[1] = IWL_HCMD_DFL_NOCOPY; in iwl_send_phy_db_cmd()
332 return iwl_trans_send_cmd(phy_db->trans, &cmd); in iwl_send_phy_db_cmd()
350 return -EINVAL; in iwl_phy_db_send_all_channel_groups()
352 if (!entry->size) in iwl_phy_db_send_all_channel_groups()
355 /* Send the requested PHY DB section */ in iwl_phy_db_send_all_channel_groups()
358 entry->size, in iwl_phy_db_send_all_channel_groups()
359 entry->data); in iwl_phy_db_send_all_channel_groups()
361 IWL_ERR(phy_db->trans, in iwl_phy_db_send_all_channel_groups()
367 IWL_DEBUG_INFO(phy_db->trans, in iwl_phy_db_send_all_channel_groups()
381 IWL_DEBUG_INFO(phy_db->trans, in iwl_send_phy_db_data()
382 "Sending phy db data and configuration to runtime image\n"); in iwl_send_phy_db_data()
384 /* Send PHY DB CFG section */ in iwl_send_phy_db_data()
388 IWL_ERR(phy_db->trans, "Cannot get Phy DB cfg section\n"); in iwl_send_phy_db_data()
394 IWL_ERR(phy_db->trans, in iwl_send_phy_db_data()
395 "Cannot send HCMD of Phy DB cfg section\n"); in iwl_send_phy_db_data()
402 IWL_ERR(phy_db->trans, in iwl_send_phy_db_data()
403 "Cannot get Phy DB non specific channel section\n"); in iwl_send_phy_db_data()
409 IWL_ERR(phy_db->trans, in iwl_send_phy_db_data()
410 "Cannot send HCMD of Phy DB non specific channel section\n"); in iwl_send_phy_db_data()
417 phy_db->n_group_papd); in iwl_send_phy_db_data()
419 IWL_ERR(phy_db->trans, in iwl_send_phy_db_data()
427 phy_db->n_group_txp); in iwl_send_phy_db_data()
429 IWL_ERR(phy_db->trans, in iwl_send_phy_db_data()
434 IWL_DEBUG_INFO(phy_db->trans, in iwl_send_phy_db_data()
435 "Finished sending phy db non channel data\n"); in iwl_send_phy_db_data()