コード例 #1
0
ファイル: vmm_mbuf.c プロジェクト: IRT-SystemX/xvisor-next
int __init vmm_mbufpool_init(void)
{
	u32 slab, b_size, b_count, epool_sz;

	memset(&mbpctrl, 0, sizeof(mbpctrl));

	/* Create mbuf pool */
	b_size = sizeof(struct vmm_mbuf);
	b_count = CONFIG_NET_MBUF_POOL_SIZE;
	mbpctrl.mpool = mempool_ram_create(b_size,
					VMM_SIZE_TO_PAGE(b_size * b_count),
					VMM_MEMORY_FLAGS_NORMAL);
	if (!mbpctrl.mpool) {
		return VMM_ENOMEM;
	}

	/* Create ext slab pools */
	epool_sz = (CONFIG_NET_MBUF_EXT_POOL_SIZE_KB * 1024);
	for (slab = 0; slab < EPOOL_SLAB_COUNT; slab++) {
		b_size = epool_slab_buf_size(slab);
		b_count = epool_slab_buf_count(epool_sz, slab);
		if (b_count && b_size) {
			mbpctrl.epool_slabs[slab] = 
				mempool_ram_create(b_size,
					VMM_SIZE_TO_PAGE(b_size * b_count),
					VMM_MEMORY_FLAGS_NORMAL);
		} else {
			mbpctrl.epool_slabs[slab] = NULL;
		}
	}

	return VMM_OK;
}
コード例 #2
0
ファイル: vmm_mbuf.c プロジェクト: machinoid/xvisor-next
int __init vmm_mbufpool_init(void)
{
	u32 slab, buf_size, buf_count, epool_sz;

	memset(&mbpctrl, 0, sizeof(mbpctrl));

	/* Create mbuf pool */
	mbpctrl.mpool = mempool_create(sizeof(struct vmm_mbuf), 
					CONFIG_NET_MBUF_POOL_SIZE);
	if (!mbpctrl.mpool) {
		return VMM_ENOMEM;
	}

	/* Create ext slab pools */
	epool_sz = (CONFIG_NET_MBUF_EXT_POOL_KB * 1024);
	for (slab = 0; slab < EPOOL_SLAB_COUNT; slab++) {
		buf_size = epool_slab_buf_size(slab);
		buf_count = epool_slab_buf_count(epool_sz, slab);
		if (buf_count && buf_size) {
			mbpctrl.epool_slabs[slab] = 
					mempool_create(buf_size, buf_count);
		} else {
			mbpctrl.epool_slabs[slab] = NULL;
		}
	}

	return VMM_OK;
}