Lines Matching refs:queue

29 #include <dev/nxge/include/xge-queue.h>
38 * user-defined portion of the queue item.
46 * __queue_consume - (Lockless) dequeue an item from the specified queue.
48 * @queue: Event queue.
52 __queue_consume(xge_queue_t *queue, int data_max_size, xge_queue_item_t *item)
57 if (xge_list_is_empty(&queue->list_head))
60 elem = (xge_queue_item_t *)queue->list_head.next;
66 if (queue->head_ptr == elem) {
67 queue->head_ptr = (char *)queue->head_ptr + real_size;
73 (u64)(ulong_t)queue->start_ptr,
74 (u64)(ulong_t)queue->head_ptr,
75 (u64)(ulong_t)queue->tail_ptr,
76 (u64)(ulong_t)queue->end_ptr,
79 } else if ((char *)queue->tail_ptr - real_size == (char*)elem) {
80 queue->tail_ptr = (char *)queue->tail_ptr - real_size;
86 (u64)(ulong_t)queue->start_ptr,
87 (u64)(ulong_t)queue->head_ptr,
88 (u64)(ulong_t)queue->tail_ptr,
89 (u64)(ulong_t)queue->end_ptr,
98 (u64)(ulong_t)queue->start_ptr,
99 (u64)(ulong_t)queue->head_ptr,
100 (u64)(ulong_t)queue->tail_ptr,
101 (u64)(ulong_t)queue->end_ptr,
105 xge_assert(queue->tail_ptr >= queue->head_ptr);
106 xge_assert(queue->tail_ptr >= queue->start_ptr &&
107 queue->tail_ptr <= queue->end_ptr);
108 xge_assert(queue->head_ptr >= queue->start_ptr &&
109 queue->head_ptr < queue->end_ptr);
114 if (xge_list_is_empty(&queue->list_head)) {
116 queue->head_ptr = queue->tail_ptr = queue->start_ptr;
123 * into the specified queue.
132 * the new queue item (see xge_queue_item_t{}). Upon return
147 xge_queue_t *queue = (xge_queue_t *)queueh;
154 xge_os_spin_lock_irq(&queue->lock, flags);
156 if (is_critical && !queue->has_critical_event) {
163 while (__queue_consume(queue,
170 if ((char *)queue->tail_ptr + real_size <= (char *)queue->end_ptr) {
171 elem = (xge_queue_item_t *) queue->tail_ptr;
172 queue->tail_ptr = (void *)((char *)queue->tail_ptr + real_size);
178 (u64)(ulong_t)queue->start_ptr,
179 (u64)(ulong_t)queue->head_ptr,
180 (u64)(ulong_t)queue->tail_ptr,
181 (u64)(ulong_t)queue->end_ptr,
184 } else if ((char *)queue->head_ptr - real_size >=
185 (char *)queue->start_ptr) {
186 elem = (xge_queue_item_t *) ((char *)queue->head_ptr - real_size);
187 queue->head_ptr = elem;
193 (u64)(ulong_t)queue->start_ptr,
194 (u64)(ulong_t)queue->head_ptr,
195 (u64)(ulong_t)queue->tail_ptr,
196 (u64)(ulong_t)queue->end_ptr,
201 if (queue->pages_current >= queue->pages_max) {
202 xge_os_spin_unlock_irq(&queue->lock, flags);
206 if (queue->has_critical_event) {
207 xge_os_spin_unlock_irq(&queue->lock, flags);
214 xge_os_spin_unlock_irq(&queue->lock, flags);
220 xge_assert(queue->tail_ptr >= queue->head_ptr);
221 xge_assert(queue->tail_ptr >= queue->start_ptr &&
222 queue->tail_ptr <= queue->end_ptr);
223 xge_assert(queue->head_ptr >= queue->start_ptr &&
224 queue->head_ptr < queue->end_ptr);
229 queue->has_critical_event = 1;
232 xge_list_insert_before(&elem->item, &queue->list_head);
233 xge_os_spin_unlock_irq(&queue->lock, flags);
236 queue->queued_func(queue->queued_data, event_type);
243 * xge_queue_create - Create protected first-in-first-out queue.
247 * time of queue creation.
248 * @pages_max: Max number of pages that can be allocated in the queue.
250 * added to the queue.
253 * Create protected (fifo) queue.
264 xge_queue_t *queue;
266 if ((queue = (xge_queue_t *) xge_os_malloc(pdev, sizeof(xge_queue_t))) == NULL)
269 queue->queued_func = queued;
270 queue->queued_data = queued_data;
271 queue->pdev = pdev;
272 queue->irqh = irqh;
273 queue->pages_current = pages_initial;
274 queue->start_ptr = xge_os_malloc(pdev, queue->pages_current *
276 if (queue->start_ptr == NULL) {
277 xge_os_free(pdev, queue, sizeof(xge_queue_t));
280 queue->head_ptr = queue->tail_ptr = queue->start_ptr;
281 queue->end_ptr = (char *)queue->start_ptr +
282 queue->pages_current * XGE_QUEUE_BUF_SIZE;
283 xge_os_spin_lock_init_irq(&queue->lock, irqh);
284 queue->pages_initial = pages_initial;
285 queue->pages_max = pages_max;
286 xge_list_init(&queue->list_head);
288 return queue;
301 xge_queue_t *queue = (xge_queue_t *)queueh;
302 xge_os_spin_lock_destroy_irq(&queue->lock, queue->irqh);
303 if (!xge_list_is_empty(&queue->list_head)) {
304 xge_debug_queue(XGE_ERR, "destroying non-empty queue 0x"
305 XGE_OS_LLXFMT, (u64)(ulong_t)queue);
307 xge_os_free(queue->pdev, queue->start_ptr, queue->pages_current *
310 xge_os_free(queue->pdev, queue, sizeof(xge_queue_t));
314 * __io_queue_grow - Dynamically increases the size of the queue.
317 * This function is called in the case of no slot avaialble in the queue
319 * Note that queue cannot grow beyond the max size specified for the
320 * queue.
328 xge_queue_t *queue = (xge_queue_t *)queueh;
333 xge_debug_queue(XGE_TRACE, "queue 0x"XGE_OS_LLXFMT":%d is growing",
334 (u64)(ulong_t)queue, queue->pages_current);
336 newbuf = xge_os_malloc(queue->pdev,
337 (queue->pages_current + 1) * XGE_QUEUE_BUF_SIZE);
341 xge_os_memcpy(newbuf, queue->start_ptr,
342 queue->pages_current * XGE_QUEUE_BUF_SIZE);
343 oldbuf = queue->start_ptr;
345 /* adjust queue sizes */
346 queue->start_ptr = newbuf;
347 queue->end_ptr = (char *)newbuf +
348 (queue->pages_current + 1) * XGE_QUEUE_BUF_SIZE;
349 queue->tail_ptr = (char *)newbuf + ((char *)queue->tail_ptr -
351 queue->head_ptr = (char *)newbuf + ((char *)queue->head_ptr -
353 xge_assert(!xge_list_is_empty(&queue->list_head));
354 queue->list_head.next = (xge_list_t *) (void *)((char *)newbuf +
355 ((char *)queue->list_head.next - (char *)oldbuf));
356 queue->list_head.prev = (xge_list_t *) (void *)((char *)newbuf +
357 ((char *)queue->list_head.prev - (char *)oldbuf));
358 /* adjust queue list */
359 xge_list_for_each(item, &queue->list_head) {
361 if (elem->item.next != &queue->list_head) {
366 if (elem->item.prev != &queue->list_head) {
372 xge_os_free(queue->pdev, oldbuf,
373 queue->pages_current * XGE_QUEUE_BUF_SIZE);
374 queue->pages_current++;
380 * xge_queue_consume - Dequeue an item from the specified queue.
386 * Dequeue an item from the queue. The caller is required to provide
392 * is too small to accomodate an item from the queue.
399 xge_queue_t *queue = (xge_queue_t *)queueh;
403 xge_os_spin_lock_irq(&queue->lock, flags);
404 status = __queue_consume(queue, data_max_size, item);
405 xge_os_spin_unlock_irq(&queue->lock, flags);
412 * xge_queue_flush - Flush, or empty, the queue.
415 * Flush the queue, i.e. make it empty by consuming all events
426 /* flush queue by consuming all enqueued items */
438 * __queue_get_reset_critical - Check for critical events in the queue,
441 * Check for critical event(s) in the queue, and reset the
443 * Returns: 1 - if the queue contains atleast one critical event.
444 * 0 - If there are no critical events in the queue.
447 xge_queue_t* queue = (xge_queue_t*)qh;
448 int c = queue->has_critical_event;
450 queue->has_critical_event = 0;