Lines Matching +full:device +full:- +full:id
1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /* Copyright(c) 2007-2022 Intel Corporation */
28 u32 id; member
35 * adf_get_vf_real_id() - Translate fake to real device id
37 * The "real" id is assigned to a device when it is initially
39 * The "fake" id is usually the same as the real id, but
41 * perhaps to assign the device to a guest.
51 if (ptr->fake_id == fake) in adf_get_vf_real_id()
52 return ptr->id; in adf_get_vf_real_id()
54 return -1; in adf_get_vf_real_id()
58 * adf_clean_vf_map() - Cleans VF id mapings
74 if (map->bdf != -1) { in adf_clean_vf_map()
75 id_map[map->id] = 0; in adf_clean_vf_map()
76 num_devices--; in adf_clean_vf_map()
79 if (vf && map->bdf == -1) in adf_clean_vf_map()
89 * adf_devmgr_update_class_index() - Update internal index
90 * @hw_data: Pointer to internal device data.
97 struct adf_hw_device_class *class = hw_data->dev_class; in adf_devmgr_update_class_index()
106 if (ptr->hw_device->dev_class == class) in adf_devmgr_update_class_index()
107 ptr->hw_device->instance_id = i++; in adf_devmgr_update_class_index()
109 if (i == class->instances) in adf_devmgr_update_class_index()
129 * adf_devmgr_add_dev() - Add accel_dev to the acceleration framework
130 * @accel_dev: Pointer to acceleration device.
133 * Function adds acceleration device to the acceleration framework.
134 * To be used by QAT device specific drivers.
154 if (!accel_dev->is_vf || (accel_dev->is_vf && !pf)) { in adf_devmgr_add_dev()
168 list_add_tail(&accel_dev->list, &accel_table); in adf_devmgr_add_dev()
169 accel_dev->accel_id = adf_find_free_id(); in adf_devmgr_add_dev()
170 if (accel_dev->accel_id > ADF_MAX_DEVICES) { in adf_devmgr_add_dev()
180 map->bdf = ~0; in adf_devmgr_add_dev()
181 map->id = accel_dev->accel_id; in adf_devmgr_add_dev()
182 map->fake_id = map->id; in adf_devmgr_add_dev()
183 map->attached = true; in adf_devmgr_add_dev()
184 list_add_tail(&map->list, &vfs_table); in adf_devmgr_add_dev()
185 } else if (accel_dev->is_vf && pf) { in adf_devmgr_add_dev()
201 * adf_devmgr_rm_dev() - Remove accel_dev from the acceleration framework.
202 * @accel_dev: Pointer to acceleration device.
205 * Function removes acceleration device from the acceleration framework.
206 * To be used by QAT device specific drivers.
214 if (!accel_dev->is_vf || (accel_dev->is_vf && !pf)) { in adf_devmgr_rm_dev()
215 id_map[accel_dev->accel_id] = 0; in adf_devmgr_rm_dev()
216 num_devices--; in adf_devmgr_rm_dev()
218 list_del(&accel_dev->list); in adf_devmgr_rm_dev()
234 * adf_devmgr_pci_to_accel_dev() - Get accel_dev associated with the pci_dev.
235 * @accel_dev: Pointer to pci device.
237 * Function returns acceleration device associated with the given pci device.
238 * To be used by QAT device specific drivers.
253 if (ptr->accel_pci_dev.pci_dev == pci_dev) { in adf_devmgr_pci_to_accel_dev()
263 adf_devmgr_get_dev_by_id(uint32_t id) in adf_devmgr_get_dev_by_id() argument
269 real_id = adf_get_vf_real_id(id); in adf_devmgr_get_dev_by_id()
273 id = real_id; in adf_devmgr_get_dev_by_id()
279 if (ptr->accel_id == id) { in adf_devmgr_get_dev_by_id()
290 adf_devmgr_verify_id(uint32_t *id) in adf_devmgr_verify_id() argument
294 if (*id == ADF_CFG_ALL_DEVICES) in adf_devmgr_verify_id()
297 accel_dev = adf_devmgr_get_dev_by_id(*id); in adf_devmgr_verify_id()
301 /* Correct the id if real and fake differ */ in adf_devmgr_verify_id()
302 *id = accel_dev->accel_id; in adf_devmgr_verify_id()
316 if (ptr->bdf != ~0 && !ptr->attached) in adf_get_num_dettached_vfs()
326 *num = num_devices - adf_get_num_dettached_vfs(); in adf_devmgr_get_num_dev()
330 * adf_dev_in_use() - Check whether accel_dev is currently in use
331 * @accel_dev: Pointer to acceleration device.
333 * To be used by QAT device specific drivers.
335 * Return: 1 when device is in use, 0 otherwise.
340 return atomic_read(&accel_dev->ref_count) != 0; in adf_dev_in_use()
344 * adf_dev_get() - Increment accel_dev reference count
345 * @accel_dev: Pointer to acceleration device.
350 * To be used by QAT device specific drivers.
357 if (atomic_add_return(1, &accel_dev->ref_count) == 1) in adf_dev_get()
362 * adf_dev_put() - Decrement accel_dev reference count
363 * @accel_dev: Pointer to acceleration device.
368 * To be used by QAT device specific drivers.
375 if (atomic_sub_return(1, &accel_dev->ref_count) == 0) in adf_dev_put()
380 * adf_devmgr_in_reset() - Check whether device is in reset
381 * @accel_dev: Pointer to acceleration device.
383 * To be used by QAT device specific drivers.
385 * Return: 1 when the device is being reset, 0 otherwise.
390 return test_bit(ADF_STATUS_RESTARTING, &accel_dev->status); in adf_devmgr_in_reset()
394 * adf_dev_started() - Check whether device has started
395 * @accel_dev: Pointer to acceleration device.
397 * To be used by QAT device specific drivers.
399 * Return: 1 when the device has started, 0 otherwise
404 return test_bit(ADF_STATUS_STARTED, &accel_dev->status); in adf_dev_started()