MCPcopy Create free account
hub / github.com/F-Stack/f-stack / dpaa_qdma_init

Function dpaa_qdma_init

dpdk/drivers/dma/dpaa/dpaa_qdma.c:925–1013  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

923};
924
925static int
926dpaa_qdma_init(struct rte_dma_dev *dmadev)
927{
928 struct fsl_qdma_engine *fsl_qdma = dmadev->data->dev_private;
929 struct fsl_qdma_chan *fsl_chan;
930 uint64_t phys_addr;
931 unsigned int len;
932 int ccsr_qdma_fd;
933 int regs_size;
934 int ret;
935 u32 i;
936
937 fsl_qdma->desc_allocated = 0;
938 fsl_qdma->n_chans = VIRT_CHANNELS;
939 fsl_qdma->n_queues = QDMA_QUEUES;
940 fsl_qdma->num_blocks = QDMA_BLOCKS;
941 fsl_qdma->block_offset = QDMA_BLOCK_OFFSET;
942
943 len = sizeof(*fsl_chan) * fsl_qdma->n_chans;
944 fsl_qdma->chans = rte_zmalloc("qdma: fsl chans", len, 0);
945 if (!fsl_qdma->chans)
946 return -1;
947
948 len = sizeof(struct fsl_qdma_queue *) * fsl_qdma->num_blocks;
949 fsl_qdma->status = rte_zmalloc("qdma: fsl status", len, 0);
950 if (!fsl_qdma->status) {
951 rte_free(fsl_qdma->chans);
952 return -1;
953 }
954
955 for (i = 0; i < fsl_qdma->num_blocks; i++) {
956 rte_atomic32_init(&wait_task[i]);
957 fsl_qdma->status[i] = fsl_qdma_prep_status_queue();
958 if (!fsl_qdma->status[i])
959 goto err;
960 }
961
962 ccsr_qdma_fd = open("/dev/mem", O_RDWR);
963 if (unlikely(ccsr_qdma_fd < 0)) {
964 DPAA_QDMA_ERR("Can not open /dev/mem for qdma CCSR map");
965 goto err;
966 }
967
968 regs_size = fsl_qdma->block_offset * (fsl_qdma->num_blocks + 2);
969 phys_addr = QDMA_CCSR_BASE;
970 fsl_qdma->ctrl_base = mmap(NULL, regs_size, PROT_READ |
971 PROT_WRITE, MAP_SHARED,
972 ccsr_qdma_fd, phys_addr);
973
974 close(ccsr_qdma_fd);
975 if (fsl_qdma->ctrl_base == MAP_FAILED) {
976 DPAA_QDMA_ERR("Can not map CCSR base qdma: Phys: %08" PRIx64
977 "size %d", phys_addr, regs_size);
978 goto err;
979 }
980
981 fsl_qdma->status_base = fsl_qdma->ctrl_base + QDMA_BLOCK_OFFSET;
982 fsl_qdma->block_base = fsl_qdma->status_base + QDMA_BLOCK_OFFSET;

Callers 1

dpaa_qdma_probeFunction · 0.85

Calls 7

rte_zmallocFunction · 0.85
rte_freeFunction · 0.85
rte_atomic32_initFunction · 0.85
fsl_qdma_reg_initFunction · 0.85
closeFunction · 0.50

Tested by

no test coverage detected