src/dpdk/drivers/net/hinic/base/hinic_pmd_eqs.c
static int alloc_eq_pages(struct hinic_eq *eq)
{
	struct hinic_hwif *hwif = eq->hwdev->hwif;
	u32 init_val;
	u64 dma_addr_size, virt_addr_size;
	u16 pg_num, i;
	int err;

	dma_addr_size = eq->num_pages * sizeof(*eq->dma_addr);
	virt_addr_size = eq->num_pages * sizeof(*eq->virt_addr);

	eq->dma_addr = kzalloc(dma_addr_size, GFP_KERNEL);
	if (!eq->dma_addr) {
		PMD_DRV_LOG(ERR, "Allocate dma addr array failed");
		return -ENOMEM;
	}

	eq->virt_addr = kzalloc(virt_addr_size, GFP_KERNEL);
	if (!eq->virt_addr) {
		PMD_DRV_LOG(ERR, "Allocate virt addr array failed");
		err = -ENOMEM;
		goto virt_addr_alloc_err;
	}

	for (pg_num = 0; pg_num < eq->num_pages; pg_num++) {
		eq->virt_addr[pg_num] =
			(u8 *)dma_zalloc_coherent_aligned(eq->hwdev,
					eq->page_size, &eq->dma_addr[pg_num],
					SOCKET_ID_ANY);
		if (!eq->virt_addr[pg_num]) {
			err = -ENOMEM;
			goto dma_alloc_err;
		}

		hinic_hwif_write_reg(hwif,
				     HINIC_EQ_HI_PHYS_ADDR_REG(eq->type,
				     eq->q_id, pg_num),
				     upper_32_bits(eq->dma_addr[pg_num]));

		hinic_hwif_write_reg(hwif,
				     HINIC_EQ_LO_PHYS_ADDR_REG(eq->type,
				     eq->q_id, pg_num),
				     lower_32_bits(eq->dma_addr[pg_num]));
	}

	init_val = EQ_WRAPPED(eq);

	aeq_elements_init(eq, init_val);

	return 0;

dma_alloc_err:
	for (i = 0; i < pg_num; i++)
		dma_free_coherent(eq->hwdev, eq->page_size,
				  eq->virt_addr[i], eq->dma_addr[i]);

virt_addr_alloc_err:
	kfree(eq->dma_addr);
	return err;
}
/**
 * alloc_eq_pages - allocate the pages for the queue
 * @eq: the event queue
 */
allocate the pages for the queue
@eq: the event queue
allocate the pages for the queue @eq : the event queue
static int alloc_eq_pages(struct hinic_eq *eq)
{
	struct hinic_hwif *hwif = eq->hwdev->hwif;
	u32 init_val;
	u64 dma_addr_size, virt_addr_size;
	u16 pg_num, i;
	int err;
	dma_addr_size = eq->num_pages * sizeof(*eq->dma_addr);
	virt_addr_size = eq->num_pages * sizeof(*eq->virt_addr);
	eq->dma_addr = kzalloc(dma_addr_size, GFP_KERNEL);
	if (!eq->dma_addr) {
		PMD_DRV_LOG(ERR, "Allocate dma addr array failed");
		return -ENOMEM;
	}
	eq->virt_addr = kzalloc(virt_addr_size, GFP_KERNEL);
	if (!eq->virt_addr) {
		PMD_DRV_LOG(ERR, "Allocate virt addr array failed");
		err = -ENOMEM;
		goto virt_addr_alloc_err;
	}
	for (pg_num = 0; pg_num < eq->num_pages; pg_num++) {
		eq->virt_addr[pg_num] =
			(u8 *)dma_zalloc_coherent_aligned(eq->hwdev,
					eq->page_size, &eq->dma_addr[pg_num],
					SOCKET_ID_ANY);
		if (!eq->virt_addr[pg_num]) {
			err = -ENOMEM;
			goto dma_alloc_err;
		}
		hinic_hwif_write_reg(hwif,
				     HINIC_EQ_HI_PHYS_ADDR_REG(eq->type,
				     eq->q_id, pg_num),
				     upper_32_bits(eq->dma_addr[pg_num]));
		hinic_hwif_write_reg(hwif,
				     HINIC_EQ_LO_PHYS_ADDR_REG(eq->type,
				     eq->q_id, pg_num),
				     lower_32_bits(eq->dma_addr[pg_num]));
	}
	init_val = EQ_WRAPPED(eq);
	aeq_elements_init(eq, init_val);
	return 0;
dma_alloc_err:
	for (i = 0; i < pg_num; i++)
		dma_free_coherent(eq->hwdev, eq->page_size,
				  eq->virt_addr[i], eq->dma_addr[i]);
virt_addr_alloc_err:
	kfree(eq->dma_addr);
	return err;
}
static int alloc_eq_pages ( struct hinic_eq * eq ) { struct hinic_hwif * hwif = eq -> hwdev -> hwif ; u32 init_val ; u64 dma_addr_size , virt_addr_size ; u16 pg_num , i ; int err ; dma_addr_size = eq -> num_pages * sizeof ( * eq -> dma_addr ) ; virt_addr_size = eq -> num_pages * sizeof ( * eq -> virt_addr ) ; eq -> dma_addr = kzalloc ( dma_addr_size , GFP_KERNEL ) ; if ( ! eq -> dma_addr ) { PMD_DRV_LOG ( ERR , " " ) ; return - ENOMEM ; } eq -> virt_addr = kzalloc ( virt_addr_size , GFP_KERNEL ) ; if ( ! eq -> virt_addr ) { PMD_DRV_LOG ( ERR , " " ) ; err = - ENOMEM ; goto virt_addr_alloc_err ; } for ( pg_num = 0 ; pg_num < eq -> num_pages ; pg_num ++ ) { eq -> virt_addr [ pg_num ] = ( u8 * ) dma_zalloc_coherent_aligned ( eq -> hwdev , eq -> page_size , & eq -> dma_addr [ pg_num ] , SOCKET_ID_ANY ) ; if ( ! eq -> virt_addr [ pg_num ] ) { err = - ENOMEM ; goto dma_alloc_err ; } hinic_hwif_write_reg ( hwif , HINIC_EQ_HI_PHYS_ADDR_REG ( eq -> type , eq -> q_id , pg_num ) , upper_32_bits ( eq -> dma_addr [ pg_num ] ) ) ; hinic_hwif_write_reg ( hwif , HINIC_EQ_LO_PHYS_ADDR_REG ( eq -> type , eq -> q_id , pg_num ) , lower_32_bits ( eq -> dma_addr [ pg_num ] ) ) ; } init_val = EQ_WRAPPED ( eq ) ; aeq_elements_init ( eq , init_val ) ; return 0 ; dma_alloc_err : for ( i = 0 ; i < pg_num ; i ++ ) dma_free_coherent ( eq -> hwdev , eq -> page_size , eq -> virt_addr [ i ] , eq -> dma_addr [ i ] ) ; virt_addr_alloc_err : kfree ( eq -> dma_addr ) ; return err ; }
alloc_eq_pages - allocate the pages for the queue
 @eq: the event queue
alloc_eq_pages - allocate the pages for the queue @eq : the event queue