Skip to content

Commit b05c1af

Browse files
binbinwu1deb-intel
authored andcommitted
doc: add doxygen style comments to ptdev
Add doxygen style comments to ptdev public APIs. Add these API descriptions to group acrn_passthrough. Tracked-On: #3882 Signed-off-by: Binbin Wu <binbin.wu@intel.com>
1 parent b6c0558 commit b05c1af

File tree

1 file changed

+111
-1
lines changed

1 file changed

+111
-1
lines changed

hypervisor/include/common/ptdev.h

Lines changed: 111 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,126 @@ static inline bool is_entry_active(const struct ptirq_remapping_info *entry)
139139
extern struct ptirq_remapping_info ptirq_entries[CONFIG_MAX_PT_IRQ_ENTRIES];
140140
extern spinlock_t ptdev_lock;
141141

142+
/**
143+
* @file ptdev.h
144+
*
145+
* @brief public APIs for ptdev
146+
*/
147+
148+
/**
149+
* @brief ptdev
150+
*
151+
* @addtogroup acrn_passthrough
152+
* @{
153+
*/
154+
155+
156+
/**
157+
* @brief Handler of softirq for passthrough device.
158+
*
159+
* When hypervisor receive a physcial interrupt from passthrough device, it
160+
* will enqueue a ptirq entry and raise softirq SOFTIRQ_PTDEV. This function
161+
* is the handler of the softirq, it handles the interrupt and injects the
162+
* virtual into VM.
163+
* The handler is reigstered by calling @ref ptdev_init during hypervisor
164+
* intialization.
165+
*
166+
* @param[in] pcpu_id physcial cpu id of the soft irq
167+
*
168+
*/
142169
void ptirq_softirq(uint16_t pcpu_id);
170+
/**
171+
* @brief Passthrough device global data structure initialization.
172+
*
173+
* During the hypervisor cpu initialization stage, this function:
174+
* - init global spinlock for ptdev (on BSP)
175+
* - register SOFTIRQ_PTDEV handler (on BSP)
176+
* - init the softirq entry list for each CPU
177+
*
178+
*/
143179
void ptdev_init(void);
180+
/**
181+
* @brief Deactiveate and release all ptirq entries for a VM.
182+
*
183+
* This function deactiveates and releases all ptirq entries for a VM. The function
184+
* should only be called after the VM is already down.
185+
*
186+
* @param[in] vm acrn_vm on which the ptirq entries will be released
187+
*
188+
* @pre VM is realdy down
189+
*
190+
*/
144191
void ptdev_release_all_entries(const struct acrn_vm *vm);
145192

193+
/**
194+
* @brief Dequeue an entry from per cpu ptdev softirq queue.
195+
*
196+
* Dequeue an entry from the ptdev softirq queue on the specific physcial cpu.
197+
*
198+
* @param[in] pcpu_id physcial cpu id
199+
*
200+
* @retval NULL when \p when the queue is empty
201+
* @retval !NULL when \p there is available ptirq_remapping_info entry in the queue
202+
*
203+
*/
146204
struct ptirq_remapping_info *ptirq_dequeue_softirq(uint16_t pcpu_id);
205+
/**
206+
* @brief Allocate a ptirq_remapping_info entry.
207+
*
208+
* Allocate a ptirq_remapping_info entry for hypervisor to store the remapping information.
209+
* The total number of the entries is statically defined as CONFIG_MAX_PT_IRQ_ENTRIES.
210+
* Appropriate number should be configured on different platforms.
211+
*
212+
* @param[in] vm acrn_vm that the entry allocated for.
213+
* @param[in] interrupt type: PTDEV_INTR_MSI or PTDEV_INTR_INTX
214+
*
215+
* @retval NULL when \p the number of entries allocated is CONFIG_MAX_PT_IRQ_ENTRIES
216+
* @retval !NULL when \p the number of entries allocated is less than CONFIG_MAX_PT_IRQ_ENTRIES
217+
*
218+
*/
147219
struct ptirq_remapping_info *ptirq_alloc_entry(struct acrn_vm *vm, uint32_t intr_type);
220+
/**
221+
* @brief Release a ptirq_remapping_info entry.
222+
*
223+
* @param[in] entry the ptirq_remapping_info entry to release.
224+
*
225+
*/
148226
void ptirq_release_entry(struct ptirq_remapping_info *entry);
227+
/**
228+
* @brief Activate a irq for the associated passthrough device.
229+
*
230+
* After activating the ptirq entry, the physcial interrupt irq of passthrough device will be handled
231+
* by the handler ptirq_interrupt_handler.
232+
*
233+
* @param[in] entry the ptirq_remapping_info entry that will be associated with the physcial irq.
234+
* @param[in] phys_irq physcial interrupt irq for the entry
235+
*
236+
* @retval success when \p return value >=0
237+
* @retval success when \p return <0
238+
*
239+
*/
149240
int32_t ptirq_activate_entry(struct ptirq_remapping_info *entry, uint32_t phys_irq);
241+
/**
242+
* @brief De-activate a irq for the associated passthrough device.
243+
*
244+
* @param[in] entry the ptirq_remapping_info entry that will be de-activated.
245+
*
246+
*/
150247
void ptirq_deactivate_entry(struct ptirq_remapping_info *entry);
151-
248+
/**
249+
* @brief Get the interrupt information and store to the buffer provided.
250+
*
251+
* @param[in] target_vm the VM to get the interrupt information.
252+
* @param[out] buffer the buffer to interrupt information stored to.
253+
* @param[in] buffer_cnt the size of the buffer.
254+
*
255+
* @retval the actural size the buffer filled with the interrupt information
256+
*
257+
*/
152258
uint32_t ptirq_get_intr_data(const struct acrn_vm *target_vm, uint64_t *buffer, uint32_t buffer_cnt);
153259

260+
/**
261+
* @}
262+
*/
263+
154264
#endif /* PTDEV_H */

0 commit comments

Comments
 (0)