c224a883ae115874d21f7910bb23d01be3c8cbdb
[dpdk.git] / drivers / bus / fslmc / portal / dpaa2_hw_dpio.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  *
3  *   Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved.
4  *   Copyright 2016-2019 NXP
5  *
6  */
7 #include <unistd.h>
8 #include <stdio.h>
9 #include <string.h>
10 #include <stdlib.h>
11 #include <fcntl.h>
12 #include <errno.h>
13 #include <stdarg.h>
14 #include <inttypes.h>
15 #include <signal.h>
16 #include <pthread.h>
17 #include <sys/types.h>
18 #include <sys/queue.h>
19 #include <sys/ioctl.h>
20 #include <sys/stat.h>
21 #include <sys/mman.h>
22 #include <sys/epoll.h>
23 #include<sys/eventfd.h>
24
25 #include <rte_mbuf.h>
26 #include <ethdev_driver.h>
27 #include <rte_malloc.h>
28 #include <rte_memcpy.h>
29 #include <rte_string_fns.h>
30 #include <rte_cycles.h>
31 #include <rte_kvargs.h>
32 #include <rte_dev.h>
33
34 #include <fslmc_logs.h>
35 #include <rte_fslmc.h>
36 #include "dpaa2_hw_pvt.h"
37 #include "dpaa2_hw_dpio.h"
38 #include <mc/fsl_dpmng.h>
39
40 #define NUM_HOST_CPUS RTE_MAX_LCORE
41
42 struct dpaa2_io_portal_t dpaa2_io_portal[RTE_MAX_LCORE];
43 RTE_DEFINE_PER_LCORE(struct dpaa2_io_portal_t, _dpaa2_io);
44
45 struct swp_active_dqs rte_global_active_dqs_list[NUM_MAX_SWP];
46
47 TAILQ_HEAD(dpio_dev_list, dpaa2_dpio_dev);
48 static struct dpio_dev_list dpio_dev_list
49         = TAILQ_HEAD_INITIALIZER(dpio_dev_list); /*!< DPIO device list */
50 static uint32_t io_space_count;
51
52 /* Variable to store DPAA2 platform type */
53 uint32_t dpaa2_svr_family;
54
55 /* Variable to store DPAA2 DQRR size */
56 uint8_t dpaa2_dqrr_size;
57 /* Variable to store DPAA2 EQCR size */
58 uint8_t dpaa2_eqcr_size;
59
60 /* Variable to hold the portal_key, once created.*/
61 static pthread_key_t dpaa2_portal_key;
62
63 /*Stashing Macros default for LS208x*/
64 static int dpaa2_core_cluster_base = 0x04;
65 static int dpaa2_cluster_sz = 2;
66
67 /* For LS208X platform There are four clusters with following mapping:
68  * Cluster 1 (ID = x04) : CPU0, CPU1;
69  * Cluster 2 (ID = x05) : CPU2, CPU3;
70  * Cluster 3 (ID = x06) : CPU4, CPU5;
71  * Cluster 4 (ID = x07) : CPU6, CPU7;
72  */
73 /* For LS108X platform There are two clusters with following mapping:
74  * Cluster 1 (ID = x02) : CPU0, CPU1, CPU2, CPU3;
75  * Cluster 2 (ID = x03) : CPU4, CPU5, CPU6, CPU7;
76  */
77 /* For LX2160 platform There are four clusters with following mapping:
78  * Cluster 1 (ID = x00) : CPU0, CPU1;
79  * Cluster 2 (ID = x01) : CPU2, CPU3;
80  * Cluster 3 (ID = x02) : CPU4, CPU5;
81  * Cluster 4 (ID = x03) : CPU6, CPU7;
82  * Cluster 1 (ID = x04) : CPU8, CPU9;
83  * Cluster 2 (ID = x05) : CPU10, CP11;
84  * Cluster 3 (ID = x06) : CPU12, CPU13;
85  * Cluster 4 (ID = x07) : CPU14, CPU15;
86  */
87
88 static int
89 dpaa2_get_core_id(void)
90 {
91         rte_cpuset_t cpuset;
92         int i, ret, cpu_id = -1;
93
94         ret = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t),
95                 &cpuset);
96         if (ret) {
97                 DPAA2_BUS_ERR("pthread_getaffinity_np() failed");
98                 return ret;
99         }
100
101         for (i = 0; i < RTE_MAX_LCORE; i++) {
102                 if (CPU_ISSET(i, &cpuset)) {
103                         if (cpu_id == -1)
104                                 cpu_id = i;
105                         else
106                                 /* Multiple cpus are affined */
107                                 return -1;
108                 }
109         }
110
111         return cpu_id;
112 }
113
114 static int
115 dpaa2_core_cluster_sdest(int cpu_id)
116 {
117         int x = cpu_id / dpaa2_cluster_sz;
118
119         return dpaa2_core_cluster_base + x;
120 }
121
122 #ifdef RTE_EVENT_DPAA2
123 static void
124 dpaa2_affine_dpio_intr_to_respective_core(int32_t dpio_id, int cpu_id)
125 {
126 #define STRING_LEN      28
127 #define COMMAND_LEN     50
128         uint32_t cpu_mask = 1;
129         int ret;
130         size_t len = 0;
131         char *temp = NULL, *token = NULL;
132         char string[STRING_LEN], command[COMMAND_LEN];
133         FILE *file;
134
135         snprintf(string, STRING_LEN, "dpio.%d", dpio_id);
136         file = fopen("/proc/interrupts", "r");
137         if (!file) {
138                 DPAA2_BUS_WARN("Failed to open /proc/interrupts file");
139                 return;
140         }
141         while (getline(&temp, &len, file) != -1) {
142                 if ((strstr(temp, string)) != NULL) {
143                         token = strtok(temp, ":");
144                         break;
145                 }
146         }
147
148         if (!token) {
149                 DPAA2_BUS_WARN("Failed to get interrupt id for dpio.%d",
150                                dpio_id);
151                 if (temp)
152                         free(temp);
153                 fclose(file);
154                 return;
155         }
156
157         cpu_mask = cpu_mask << cpu_id;
158         snprintf(command, COMMAND_LEN, "echo %X > /proc/irq/%s/smp_affinity",
159                  cpu_mask, token);
160         ret = system(command);
161         if (ret < 0)
162                 DPAA2_BUS_DEBUG(
163                         "Failed to affine interrupts on respective core");
164         else
165                 DPAA2_BUS_DEBUG(" %s command is executed", command);
166
167         free(temp);
168         fclose(file);
169 }
170
171 static int dpaa2_dpio_intr_init(struct dpaa2_dpio_dev *dpio_dev, int cpu_id)
172 {
173         struct epoll_event epoll_ev;
174         int eventfd, dpio_epoll_fd, ret;
175         int threshold = 0x3, timeout = 0xFF;
176
177         dpio_epoll_fd = epoll_create(1);
178         ret = rte_dpaa2_intr_enable(&dpio_dev->intr_handle, 0);
179         if (ret) {
180                 DPAA2_BUS_ERR("Interrupt registeration failed");
181                 return -1;
182         }
183
184         if (getenv("DPAA2_PORTAL_INTR_THRESHOLD"))
185                 threshold = atoi(getenv("DPAA2_PORTAL_INTR_THRESHOLD"));
186
187         if (getenv("DPAA2_PORTAL_INTR_TIMEOUT"))
188                 sscanf(getenv("DPAA2_PORTAL_INTR_TIMEOUT"), "%x", &timeout);
189
190         qbman_swp_interrupt_set_trigger(dpio_dev->sw_portal,
191                                         QBMAN_SWP_INTERRUPT_DQRI);
192         qbman_swp_interrupt_clear_status(dpio_dev->sw_portal, 0xffffffff);
193         qbman_swp_interrupt_set_inhibit(dpio_dev->sw_portal, 0);
194         qbman_swp_dqrr_thrshld_write(dpio_dev->sw_portal, threshold);
195         qbman_swp_intr_timeout_write(dpio_dev->sw_portal, timeout);
196
197         eventfd = dpio_dev->intr_handle.fd;
198         epoll_ev.events = EPOLLIN | EPOLLPRI | EPOLLET;
199         epoll_ev.data.fd = eventfd;
200
201         ret = epoll_ctl(dpio_epoll_fd, EPOLL_CTL_ADD, eventfd, &epoll_ev);
202         if (ret < 0) {
203                 DPAA2_BUS_ERR("epoll_ctl failed");
204                 return -1;
205         }
206         dpio_dev->epoll_fd = dpio_epoll_fd;
207
208         dpaa2_affine_dpio_intr_to_respective_core(dpio_dev->hw_id, cpu_id);
209
210         return 0;
211 }
212
213 static void dpaa2_dpio_intr_deinit(struct dpaa2_dpio_dev *dpio_dev)
214 {
215         int ret;
216
217         ret = rte_dpaa2_intr_disable(&dpio_dev->intr_handle, 0);
218         if (ret)
219                 DPAA2_BUS_ERR("DPIO interrupt disable failed");
220
221         close(dpio_dev->epoll_fd);
222 }
223 #endif
224
225 static int
226 dpaa2_configure_stashing(struct dpaa2_dpio_dev *dpio_dev, int cpu_id)
227 {
228         int sdest, ret;
229
230         /* Set the STASH Destination depending on Current CPU ID.
231          * Valid values of SDEST are 4,5,6,7. Where,
232          */
233         sdest = dpaa2_core_cluster_sdest(cpu_id);
234         DPAA2_BUS_DEBUG("Portal= %d  CPU= %u SDEST= %d",
235                         dpio_dev->index, cpu_id, sdest);
236
237         ret = dpio_set_stashing_destination(dpio_dev->dpio, CMD_PRI_LOW,
238                                             dpio_dev->token, sdest);
239         if (ret) {
240                 DPAA2_BUS_ERR("%d ERROR in SDEST",  ret);
241                 return -1;
242         }
243
244 #ifdef RTE_EVENT_DPAA2
245         if (dpaa2_dpio_intr_init(dpio_dev, cpu_id)) {
246                 DPAA2_BUS_ERR("Interrupt registration failed for dpio");
247                 return -1;
248         }
249 #endif
250
251         return 0;
252 }
253
254 static void dpaa2_put_qbman_swp(struct dpaa2_dpio_dev *dpio_dev)
255 {
256         if (dpio_dev) {
257 #ifdef RTE_EVENT_DPAA2
258                 dpaa2_dpio_intr_deinit(dpio_dev);
259 #endif
260                 rte_atomic16_clear(&dpio_dev->ref_count);
261         }
262 }
263
264 static struct dpaa2_dpio_dev *dpaa2_get_qbman_swp(void)
265 {
266         struct dpaa2_dpio_dev *dpio_dev = NULL;
267         int cpu_id;
268         int ret;
269
270         /* Get DPIO dev handle from list using index */
271         TAILQ_FOREACH(dpio_dev, &dpio_dev_list, next) {
272                 if (dpio_dev && rte_atomic16_test_and_set(&dpio_dev->ref_count))
273                         break;
274         }
275         if (!dpio_dev) {
276                 DPAA2_BUS_ERR("No software portal resource left");
277                 return NULL;
278         }
279
280         DPAA2_BUS_DEBUG("New Portal %p (%d) affined thread - %u",
281                         dpio_dev, dpio_dev->index, rte_gettid());
282
283         /* Set the Stashing Destination */
284         cpu_id = dpaa2_get_core_id();
285         if (cpu_id < 0) {
286                 DPAA2_BUS_WARN("Thread not affined to a single core");
287                 if (dpaa2_svr_family != SVR_LX2160A)
288                         qbman_swp_update(dpio_dev->sw_portal, 1);
289         } else {
290                 ret = dpaa2_configure_stashing(dpio_dev, cpu_id);
291                 if (ret) {
292                         DPAA2_BUS_ERR("dpaa2_configure_stashing failed");
293                         rte_atomic16_clear(&dpio_dev->ref_count);
294                         return NULL;
295                 }
296         }
297
298         ret = pthread_setspecific(dpaa2_portal_key, (void *)dpio_dev);
299         if (ret) {
300                 DPAA2_BUS_ERR("pthread_setspecific failed with ret: %d", ret);
301                 dpaa2_put_qbman_swp(dpio_dev);
302                 return NULL;
303         }
304
305         return dpio_dev;
306 }
307
308 int
309 dpaa2_affine_qbman_swp(void)
310 {
311         struct dpaa2_dpio_dev *dpio_dev;
312         uint64_t tid = rte_gettid();
313
314         /* Populate the dpaa2_io_portal structure */
315         if (!RTE_PER_LCORE(_dpaa2_io).dpio_dev) {
316                 dpio_dev = dpaa2_get_qbman_swp();
317                 if (!dpio_dev) {
318                         DPAA2_BUS_ERR("Error in software portal allocation");
319                         return -1;
320                 }
321                 RTE_PER_LCORE(_dpaa2_io).dpio_dev = dpio_dev;
322
323                 DPAA2_BUS_INFO(
324                         "DPAA Portal=%p (%d) is affined to thread %" PRIu64,
325                         dpio_dev, dpio_dev->index, tid);
326         }
327         return 0;
328 }
329
330 int
331 dpaa2_affine_qbman_ethrx_swp(void)
332 {
333         struct dpaa2_dpio_dev *dpio_dev;
334         uint64_t tid = rte_gettid();
335
336         /* Populate the dpaa2_io_portal structure */
337         if (!RTE_PER_LCORE(_dpaa2_io).ethrx_dpio_dev) {
338                 dpio_dev = dpaa2_get_qbman_swp();
339                 if (!dpio_dev) {
340                         DPAA2_BUS_ERR("Error in software portal allocation");
341                         return -1;
342                 }
343                 RTE_PER_LCORE(_dpaa2_io).ethrx_dpio_dev = dpio_dev;
344
345                 DPAA2_BUS_INFO(
346                         "DPAA Portal=%p (%d) is affined for eth rx to thread %"
347                         PRIu64, dpio_dev, dpio_dev->index, tid);
348         }
349         return 0;
350 }
351
352 static void dpaa2_portal_finish(void *arg)
353 {
354         RTE_SET_USED(arg);
355
356         dpaa2_put_qbman_swp(RTE_PER_LCORE(_dpaa2_io).dpio_dev);
357         dpaa2_put_qbman_swp(RTE_PER_LCORE(_dpaa2_io).ethrx_dpio_dev);
358
359         pthread_setspecific(dpaa2_portal_key, NULL);
360 }
361
362 static int
363 dpaa2_create_dpio_device(int vdev_fd,
364                          struct vfio_device_info *obj_info,
365                          int object_id)
366 {
367         struct dpaa2_dpio_dev *dpio_dev = NULL;
368         struct vfio_region_info reg_info = { .argsz = sizeof(reg_info)};
369         struct qbman_swp_desc p_des;
370         struct dpio_attr attr;
371         int ret;
372
373         if (obj_info->num_regions < NUM_DPIO_REGIONS) {
374                 DPAA2_BUS_ERR("Not sufficient number of DPIO regions");
375                 return -1;
376         }
377
378         dpio_dev = rte_zmalloc(NULL, sizeof(struct dpaa2_dpio_dev),
379                               RTE_CACHE_LINE_SIZE);
380         if (!dpio_dev) {
381                 DPAA2_BUS_ERR("Memory allocation failed for DPIO Device");
382                 return -1;
383         }
384
385         dpio_dev->dpio = NULL;
386         dpio_dev->hw_id = object_id;
387         rte_atomic16_init(&dpio_dev->ref_count);
388         /* Using single portal  for all devices */
389         dpio_dev->mc_portal = dpaa2_get_mcp_ptr(MC_PORTAL_INDEX);
390
391         dpio_dev->dpio = rte_zmalloc(NULL, sizeof(struct fsl_mc_io),
392                                      RTE_CACHE_LINE_SIZE);
393         if (!dpio_dev->dpio) {
394                 DPAA2_BUS_ERR("Memory allocation failure");
395                 goto err;
396         }
397
398         dpio_dev->dpio->regs = dpio_dev->mc_portal;
399         if (dpio_open(dpio_dev->dpio, CMD_PRI_LOW, dpio_dev->hw_id,
400                       &dpio_dev->token)) {
401                 DPAA2_BUS_ERR("Failed to allocate IO space");
402                 goto err;
403         }
404
405         if (dpio_reset(dpio_dev->dpio, CMD_PRI_LOW, dpio_dev->token)) {
406                 DPAA2_BUS_ERR("Failed to reset dpio");
407                 goto err;
408         }
409
410         if (dpio_enable(dpio_dev->dpio, CMD_PRI_LOW, dpio_dev->token)) {
411                 DPAA2_BUS_ERR("Failed to Enable dpio");
412                 goto err;
413         }
414
415         if (dpio_get_attributes(dpio_dev->dpio, CMD_PRI_LOW,
416                                 dpio_dev->token, &attr)) {
417                 DPAA2_BUS_ERR("DPIO Get attribute failed");
418                 goto err;
419         }
420
421         /* find the SoC type for the first time */
422         if (!dpaa2_svr_family) {
423                 struct mc_soc_version mc_plat_info = {0};
424
425                 if (mc_get_soc_version(dpio_dev->dpio,
426                                        CMD_PRI_LOW, &mc_plat_info)) {
427                         DPAA2_BUS_ERR("Unable to get SoC version information");
428                 } else if ((mc_plat_info.svr & 0xffff0000) == SVR_LS1080A) {
429                         dpaa2_core_cluster_base = 0x02;
430                         dpaa2_cluster_sz = 4;
431                         DPAA2_BUS_DEBUG("LS108x (A53) Platform Detected");
432                 } else if ((mc_plat_info.svr & 0xffff0000) == SVR_LX2160A) {
433                         dpaa2_core_cluster_base = 0x00;
434                         dpaa2_cluster_sz = 2;
435                         DPAA2_BUS_DEBUG("LX2160 Platform Detected");
436                 }
437                 dpaa2_svr_family = (mc_plat_info.svr & 0xffff0000);
438
439                 if (dpaa2_svr_family == SVR_LX2160A) {
440                         dpaa2_dqrr_size = DPAA2_LX2_DQRR_RING_SIZE;
441                         dpaa2_eqcr_size = DPAA2_LX2_EQCR_RING_SIZE;
442                 } else {
443                         dpaa2_dqrr_size = DPAA2_DQRR_RING_SIZE;
444                         dpaa2_eqcr_size = DPAA2_EQCR_RING_SIZE;
445                 }
446         }
447
448         if (dpaa2_svr_family == SVR_LX2160A)
449                 reg_info.index = DPAA2_SWP_CENA_MEM_REGION;
450         else
451                 reg_info.index = DPAA2_SWP_CENA_REGION;
452
453         if (ioctl(vdev_fd, VFIO_DEVICE_GET_REGION_INFO, &reg_info)) {
454                 DPAA2_BUS_ERR("vfio: error getting region info");
455                 goto err;
456         }
457
458         dpio_dev->ce_size = reg_info.size;
459         dpio_dev->qbman_portal_ce_paddr = (size_t)mmap(NULL, reg_info.size,
460                                 PROT_WRITE | PROT_READ, MAP_SHARED,
461                                 vdev_fd, reg_info.offset);
462
463         reg_info.index = DPAA2_SWP_CINH_REGION;
464         if (ioctl(vdev_fd, VFIO_DEVICE_GET_REGION_INFO, &reg_info)) {
465                 DPAA2_BUS_ERR("vfio: error getting region info");
466                 goto err;
467         }
468
469         dpio_dev->ci_size = reg_info.size;
470         dpio_dev->qbman_portal_ci_paddr = (size_t)mmap(NULL, reg_info.size,
471                                 PROT_WRITE | PROT_READ, MAP_SHARED,
472                                 vdev_fd, reg_info.offset);
473
474         /* Configure & setup SW portal */
475         p_des.block = NULL;
476         p_des.idx = attr.qbman_portal_id;
477         p_des.cena_bar = (void *)(dpio_dev->qbman_portal_ce_paddr);
478         p_des.cinh_bar = (void *)(dpio_dev->qbman_portal_ci_paddr);
479         p_des.irq = -1;
480         p_des.qman_version = attr.qbman_version;
481         p_des.eqcr_mode = qman_eqcr_vb_ring;
482         p_des.cena_access_mode = qman_cena_fastest_access;
483
484         dpio_dev->sw_portal = qbman_swp_init(&p_des);
485         if (dpio_dev->sw_portal == NULL) {
486                 DPAA2_BUS_ERR("QBMan SW Portal Init failed");
487                 goto err;
488         }
489
490         io_space_count++;
491         dpio_dev->index = io_space_count;
492
493         if (rte_dpaa2_vfio_setup_intr(&dpio_dev->intr_handle, vdev_fd, 1)) {
494                 DPAA2_BUS_ERR("Fail to setup interrupt for %d",
495                               dpio_dev->hw_id);
496                 goto err;
497         }
498
499         dpio_dev->eqresp = rte_zmalloc(NULL, MAX_EQ_RESP_ENTRIES *
500                                      (sizeof(struct qbman_result) +
501                                      sizeof(struct eqresp_metadata)),
502                                      RTE_CACHE_LINE_SIZE);
503         if (!dpio_dev->eqresp) {
504                 DPAA2_BUS_ERR("Memory allocation failed for eqresp");
505                 goto err;
506         }
507         dpio_dev->eqresp_meta = (struct eqresp_metadata *)(dpio_dev->eqresp +
508                                 MAX_EQ_RESP_ENTRIES);
509
510
511         TAILQ_INSERT_TAIL(&dpio_dev_list, dpio_dev, next);
512
513         if (!dpaa2_portal_key) {
514                 /* create the key, supplying a function that'll be invoked
515                  * when a portal affined thread will be deleted.
516                  */
517                 ret = pthread_key_create(&dpaa2_portal_key,
518                                          dpaa2_portal_finish);
519                 if (ret) {
520                         DPAA2_BUS_DEBUG("Unable to create pthread key (%d)",
521                                         ret);
522                         goto err;
523                 }
524         }
525
526         return 0;
527
528 err:
529         if (dpio_dev->dpio) {
530                 if (dpio_dev->token) {
531                         dpio_disable(dpio_dev->dpio, CMD_PRI_LOW,
532                                      dpio_dev->token);
533                         dpio_close(dpio_dev->dpio, CMD_PRI_LOW,
534                                    dpio_dev->token);
535                 }
536
537                 rte_free(dpio_dev->eqresp);
538                 rte_free(dpio_dev->dpio);
539         }
540
541         rte_free(dpio_dev);
542
543         /* For each element in the list, cleanup */
544         TAILQ_FOREACH(dpio_dev, &dpio_dev_list, next) {
545                 if (dpio_dev->dpio) {
546                         dpio_disable(dpio_dev->dpio, CMD_PRI_LOW,
547                                 dpio_dev->token);
548                         dpio_close(dpio_dev->dpio, CMD_PRI_LOW,
549                                 dpio_dev->token);
550                         rte_free(dpio_dev->dpio);
551                 }
552                 rte_free(dpio_dev);
553         }
554
555         /* Preventing re-use of the list with old entries */
556         TAILQ_INIT(&dpio_dev_list);
557
558         return -1;
559 }
560
561 void
562 dpaa2_free_dq_storage(struct queue_storage_info_t *q_storage)
563 {
564         int i = 0;
565
566         for (i = 0; i < NUM_DQS_PER_QUEUE; i++) {
567                 if (q_storage->dq_storage[i])
568                         rte_free(q_storage->dq_storage[i]);
569         }
570 }
571
572 int
573 dpaa2_alloc_dq_storage(struct queue_storage_info_t *q_storage)
574 {
575         int i = 0;
576
577         for (i = 0; i < NUM_DQS_PER_QUEUE; i++) {
578                 q_storage->dq_storage[i] = rte_malloc(NULL,
579                         dpaa2_dqrr_size * sizeof(struct qbman_result),
580                         RTE_CACHE_LINE_SIZE);
581                 if (!q_storage->dq_storage[i])
582                         goto fail;
583         }
584         return 0;
585 fail:
586         while (--i >= 0)
587                 rte_free(q_storage->dq_storage[i]);
588
589         return -1;
590 }
591
592 uint32_t
593 dpaa2_free_eq_descriptors(void)
594 {
595         struct dpaa2_dpio_dev *dpio_dev = DPAA2_PER_LCORE_DPIO;
596         struct qbman_result *eqresp;
597         struct eqresp_metadata *eqresp_meta;
598         struct dpaa2_queue *txq;
599
600         while (dpio_dev->eqresp_ci != dpio_dev->eqresp_pi) {
601                 eqresp = &dpio_dev->eqresp[dpio_dev->eqresp_ci];
602                 eqresp_meta = &dpio_dev->eqresp_meta[dpio_dev->eqresp_ci];
603
604                 if (!qbman_result_eqresp_rspid(eqresp))
605                         break;
606
607                 if (qbman_result_eqresp_rc(eqresp)) {
608                         txq = eqresp_meta->dpaa2_q;
609                         txq->cb_eqresp_free(dpio_dev->eqresp_ci);
610                 }
611                 qbman_result_eqresp_set_rspid(eqresp, 0);
612
613                 dpio_dev->eqresp_ci + 1 < MAX_EQ_RESP_ENTRIES ?
614                         dpio_dev->eqresp_ci++ : (dpio_dev->eqresp_ci = 0);
615         }
616
617         /* Return 1 less entry so that PI and CI are never same in a
618          * case there all the EQ responses are in use.
619          */
620         if (dpio_dev->eqresp_ci > dpio_dev->eqresp_pi)
621                 return dpio_dev->eqresp_ci - dpio_dev->eqresp_pi - 1;
622         else
623                 return dpio_dev->eqresp_ci - dpio_dev->eqresp_pi +
624                         MAX_EQ_RESP_ENTRIES - 1;
625 }
626
627 static struct rte_dpaa2_object rte_dpaa2_dpio_obj = {
628         .dev_type = DPAA2_IO,
629         .create = dpaa2_create_dpio_device,
630 };
631
632 RTE_PMD_REGISTER_DPAA2_OBJECT(dpio, rte_dpaa2_dpio_obj);