/*** * rtskb_pool_release */ int rtskb_pool_release(void) { int err = 0; if ( rt_free_srq (dec_pool_srq)<0 ) { rt_printk("RTnet: deallocating 'dec_pool_srq=%d' failed.\n", dec_pool_srq); return dec_pool_srq; } if ( rt_free_srq (inc_pool_srq)<0 ) { rt_printk("RTnet: deallocating 'inc_pool_srq=%d' failed.\n", inc_pool_srq); return inc_pool_srq; } if ( rtskb_pool.qlen>0 ) { int i; for (i=rtskb_pool.qlen; i>0; i--) dispose_rtskb(__rtskb_dequeue(&rtskb_pool)); } if ( rtskb_data_cache && kmem_cache_destroy (rtskb_data_cache) ) { rt_printk("RTnet: deallocating 'rtskb_data_cache' failed.\n"); } if ( rtskb_cache && kmem_cache_destroy (rtskb_cache) ) { rt_printk("RTnet: deallocating 'rtnet_skb_cache' failed.\n"); } return err; }
/*** * rtskb_dequeue * @list rtskb_head */ struct rtskb *rtskb_dequeue(struct rtskb_head *list) { unsigned long flags; struct rtskb *result; flags = rt_spin_lock_irqsave(&list->lock); result = __rtskb_dequeue(list); rt_spin_unlock_irqrestore(flags, &list->lock); return result; }
static struct rtskb *__rtskb_pool_dequeue(struct rtskb_pool *pool) { struct rtskb_queue *queue = &pool->queue; struct rtskb *skb; if (pool->lock_count == 0 && !pool->lock_ops->trylock(pool->lock_cookie)) return NULL; skb = __rtskb_dequeue(queue); if (skb == NULL) { if (pool->lock_count == 0) /* This can only happen if pool has 0 packets */ pool->lock_ops->unlock(pool->lock_cookie); } else ++pool->lock_count; return skb; }
/*** * __rtskb_queue_purge * @rtskb_head */ void __rtskb_queue_purge(struct rtskb_head *list) { struct rtskb *skb; while ( (skb=__rtskb_dequeue(list))!=NULL ) kfree_rtskb(skb); }