src/dpdk/drivers/net/hinic/base/hinic_pmd_nicio.c
int hinic_init_qp_ctxts(struct hinic_hwdev *hwdev)
{
	struct hinic_nic_io *nic_io = hwdev->nic_io;
	struct hinic_sq_attr sq_attr;
	u16 q_id;
	int err, rx_buf_sz;

	/* set vat page size to max queue depth page_size */
	err = hinic_set_pagesize(hwdev, HINIC_PAGE_SIZE_DPDK);
	if (err != HINIC_OK) {
		PMD_DRV_LOG(ERR, "Set vat page size: %d failed, rc: %d",
			HINIC_PAGE_SIZE_DPDK, err);
		return err;
	}

	if (hwdev->cmdqs->status & HINIC_CMDQ_SET_FAIL) {
		err = hinic_reinit_cmdq_ctxts(hwdev);
		if (err) {
			PMD_DRV_LOG(ERR, "Reinit cmdq context failed when dev start, err: %d",
				err);
			return err;
		}
	}

	err = init_qp_ctxts(nic_io);
	if (err) {
		PMD_DRV_LOG(ERR, "Init QP ctxts failed, rc: %d", err);
		return err;
	}

	/* clean LRO/TSO context space */
	err = clean_qp_offload_ctxt(nic_io);
	if (err) {
		PMD_DRV_LOG(ERR, "Clean qp offload ctxts failed, rc: %d", err);
		return err;
	}

	rx_buf_sz = nic_io->rq_buf_size;

	/* update rx buf size to function table */
	err = hinic_set_rx_vhd_mode(hwdev, HINIC_VHD_TYPE_0B, rx_buf_sz);
	if (err) {
		PMD_DRV_LOG(ERR, "Set rx vhd mode failed, rc: %d", err);
		return err;
	}

	err = hinic_set_root_ctxt(hwdev, nic_io->rq_depth,
				  nic_io->sq_depth, rx_buf_sz);
	if (err) {
		PMD_DRV_LOG(ERR, "Set root context failed, rc: %d", err);
		return err;
	}

	for (q_id = 0; q_id < nic_io->num_sqs; q_id++) {
		sq_attr.ci_dma_base =
			HINIC_CI_PADDR(nic_io->ci_dma_base, q_id) >> 2;
		/* performance: sq ci update threshold as 8 */
		sq_attr.pending_limit = 1;
		sq_attr.coalescing_time = 1;
		sq_attr.intr_en = 0;
		sq_attr.l2nic_sqn = q_id;
		sq_attr.dma_attr_off = 0;
		err = hinic_set_ci_table(hwdev, q_id, &sq_attr);
		if (err) {
			PMD_DRV_LOG(ERR, "Set ci table failed, rc: %d", err);
			goto set_cons_idx_table_err;
		}
	}

	return 0;

set_cons_idx_table_err:
	(void)hinic_clean_root_ctxt(hwdev);
	return err;
}
/* init qps ctxt and set sq ci attr and arm all sq and set vat page_size */
init qps ctxt and set sq ci attr and arm all sq and set vat page_size
init qps ctxt and set sq ci attr and arm all sq and set vat page_size
int hinic_init_qp_ctxts(struct hinic_hwdev *hwdev)
{
	struct hinic_nic_io *nic_io = hwdev->nic_io;
	struct hinic_sq_attr sq_attr;
	u16 q_id;
	int err, rx_buf_sz;
	err = hinic_set_pagesize(hwdev, HINIC_PAGE_SIZE_DPDK);
	if (err != HINIC_OK) {
		PMD_DRV_LOG(ERR, "Set vat page size: %d failed, rc: %d",
			HINIC_PAGE_SIZE_DPDK, err);
		return err;
	}
	if (hwdev->cmdqs->status & HINIC_CMDQ_SET_FAIL) {
		err = hinic_reinit_cmdq_ctxts(hwdev);
		if (err) {
			PMD_DRV_LOG(ERR, "Reinit cmdq context failed when dev start, err: %d",
				err);
			return err;
		}
	}
	err = init_qp_ctxts(nic_io);
	if (err) {
		PMD_DRV_LOG(ERR, "Init QP ctxts failed, rc: %d", err);
		return err;
	}
	err = clean_qp_offload_ctxt(nic_io);
	if (err) {
		PMD_DRV_LOG(ERR, "Clean qp offload ctxts failed, rc: %d", err);
		return err;
	}
	rx_buf_sz = nic_io->rq_buf_size;
	err = hinic_set_rx_vhd_mode(hwdev, HINIC_VHD_TYPE_0B, rx_buf_sz);
	if (err) {
		PMD_DRV_LOG(ERR, "Set rx vhd mode failed, rc: %d", err);
		return err;
	}
	err = hinic_set_root_ctxt(hwdev, nic_io->rq_depth,
				  nic_io->sq_depth, rx_buf_sz);
	if (err) {
		PMD_DRV_LOG(ERR, "Set root context failed, rc: %d", err);
		return err;
	}
	for (q_id = 0; q_id < nic_io->num_sqs; q_id++) {
		sq_attr.ci_dma_base =
			HINIC_CI_PADDR(nic_io->ci_dma_base, q_id) >> 2;
		sq_attr.pending_limit = 1;
		sq_attr.coalescing_time = 1;
		sq_attr.intr_en = 0;
		sq_attr.l2nic_sqn = q_id;
		sq_attr.dma_attr_off = 0;
		err = hinic_set_ci_table(hwdev, q_id, &sq_attr);
		if (err) {
			PMD_DRV_LOG(ERR, "Set ci table failed, rc: %d", err);
			goto set_cons_idx_table_err;
		}
	}
	return 0;
set_cons_idx_table_err:
	(void)hinic_clean_root_ctxt(hwdev);
	return err;
}
int hinic_init_qp_ctxts ( struct hinic_hwdev * hwdev ) { struct hinic_nic_io * nic_io = hwdev -> nic_io ; struct hinic_sq_attr sq_attr ; u16 q_id ; int err , rx_buf_sz ; err = hinic_set_pagesize ( hwdev , HINIC_PAGE_SIZE_DPDK ) ; if ( err != HINIC_OK ) { PMD_DRV_LOG ( ERR , " " , HINIC_PAGE_SIZE_DPDK , err ) ; return err ; } if ( hwdev -> cmdqs -> status & HINIC_CMDQ_SET_FAIL ) { err = hinic_reinit_cmdq_ctxts ( hwdev ) ; if ( err ) { PMD_DRV_LOG ( ERR , " " , err ) ; return err ; } } err = init_qp_ctxts ( nic_io ) ; if ( err ) { PMD_DRV_LOG ( ERR , " " , err ) ; return err ; } err = clean_qp_offload_ctxt ( nic_io ) ; if ( err ) { PMD_DRV_LOG ( ERR , " " , err ) ; return err ; } rx_buf_sz = nic_io -> rq_buf_size ; err = hinic_set_rx_vhd_mode ( hwdev , HINIC_VHD_TYPE_0B , rx_buf_sz ) ; if ( err ) { PMD_DRV_LOG ( ERR , " " , err ) ; return err ; } err = hinic_set_root_ctxt ( hwdev , nic_io -> rq_depth , nic_io -> sq_depth , rx_buf_sz ) ; if ( err ) { PMD_DRV_LOG ( ERR , " " , err ) ; return err ; } for ( q_id = 0 ; q_id < nic_io -> num_sqs ; q_id ++ ) { sq_attr . ci_dma_base = HINIC_CI_PADDR ( nic_io -> ci_dma_base , q_id ) >> 2 ; sq_attr . pending_limit = 1 ; sq_attr . coalescing_time = 1 ; sq_attr . intr_en = 0 ; sq_attr . l2nic_sqn = q_id ; sq_attr . dma_attr_off = 0 ; err = hinic_set_ci_table ( hwdev , q_id , & sq_attr ) ; if ( err ) { PMD_DRV_LOG ( ERR , " " , err ) ; goto set_cons_idx_table_err ; } } return 0 ; set_cons_idx_table_err : ( void ) hinic_clean_root_ctxt ( hwdev ) ; return err ; }
init qps ctxt and set sq ci attr and arm all sq and set vat page_size
init qps ctxt and set sq ci attr and arm all sq and set vat page_size
/* set vat page size to max queue depth page_size */ /* clean LRO/TSO context space */ /* update rx buf size to function table */ /* performance: sq ci update threshold as 8 */