DPDK logo

Elixir Cross Referencer

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
/* SPDX-License-Identifier: BSD-3-Clause
 * Copyright(c) 2016-2020 Intel Corporation
 */

#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <sys/mman.h>
#include <sys/fcntl.h>
#include <sys/time.h>
#include <errno.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <rte_debug.h>
#include <rte_log.h>
#include <rte_dev.h>
#include <rte_devargs.h>
#include <rte_mbuf.h>
#include <rte_ring.h>
#include <rte_errno.h>
#include <rte_kvargs.h>
#include <rte_malloc.h>
#include <rte_cycles.h>
#include <rte_io.h>
#include <rte_pci.h>
#include <rte_bus_pci.h>
#include <rte_eventdev.h>
#include <eventdev_pmd.h>
#include <eventdev_pmd_pci.h>
#include <rte_memory.h>
#include <rte_string_fns.h>

#include "../dlb2_priv.h"
#include "../dlb2_iface.h"
#include "../dlb2_inline_fns.h"
#include "dlb2_main.h"
#include "base/dlb2_hw_types.h"
#include "base/dlb2_osdep.h"
#include "base/dlb2_resource.h"

static const char *event_dlb2_pf_name = RTE_STR(EVDEV_DLB2_NAME_PMD);

static void
dlb2_pf_low_level_io_init(void)
{
	int i;
	/* Addresses will be initialized at port create */
	for (i = 0; i < DLB2_MAX_NUM_PORTS; i++) {
		/* First directed ports */
		dlb2_port[i][DLB2_DIR_PORT].pp_addr = NULL;
		dlb2_port[i][DLB2_DIR_PORT].cq_base = NULL;
		dlb2_port[i][DLB2_DIR_PORT].mmaped = true;

		/* Now load balanced ports */
		dlb2_port[i][DLB2_LDB_PORT].pp_addr = NULL;
		dlb2_port[i][DLB2_LDB_PORT].cq_base = NULL;
		dlb2_port[i][DLB2_LDB_PORT].mmaped = true;
	}
}

static int
dlb2_pf_open(struct dlb2_hw_dev *handle, const char *name)
{
	RTE_SET_USED(handle);
	RTE_SET_USED(name);

	return 0;
}

static int
dlb2_pf_get_device_version(struct dlb2_hw_dev *handle,
			   uint8_t *revision)
{
	struct dlb2_dev *dlb2_dev = (struct dlb2_dev *)handle->pf_dev;

	*revision = dlb2_dev->revision;

	return 0;
}

static void
dlb2_pf_hardware_init(struct dlb2_hw_dev *handle)
{
	struct dlb2_dev *dlb2_dev = (struct dlb2_dev *)handle->pf_dev;

	dlb2_hw_enable_sparse_ldb_cq_mode(&dlb2_dev->hw);
	dlb2_hw_enable_sparse_dir_cq_mode(&dlb2_dev->hw);
}

static int
dlb2_pf_get_num_resources(struct dlb2_hw_dev *handle,
			  struct dlb2_get_num_resources_args *rsrcs)
{
	struct dlb2_dev *dlb2_dev = (struct dlb2_dev *)handle->pf_dev;

	return dlb2_hw_get_num_resources(&dlb2_dev->hw, rsrcs, false, 0);
}

static int
dlb2_pf_get_cq_poll_mode(struct dlb2_hw_dev *handle,
			 enum dlb2_cq_poll_modes *mode)
{
	RTE_SET_USED(handle);

	*mode = DLB2_CQ_POLL_MODE_SPARSE;

	return 0;
}

static int
dlb2_pf_sched_domain_create(struct dlb2_hw_dev *handle,
			    struct dlb2_create_sched_domain_args *arg)
{
	struct dlb2_dev *dlb2_dev = (struct dlb2_dev *)handle->pf_dev;
	struct dlb2_cmd_response response = {0};
	int ret;

	DLB2_INFO(dev->dlb2_device, "Entering %s()\n", __func__);

	if (dlb2_dev->domain_reset_failed) {
		response.status = DLB2_ST_DOMAIN_RESET_FAILED;
		ret = -EINVAL;
		goto done;
	}

	ret = dlb2_pf_create_sched_domain(&dlb2_dev->hw, arg, &response);
	if (ret)
		goto done;

done:

	arg->response = response;

	DLB2_INFO(dev->dlb2_device, "Exiting %s() with ret=%d\n",
		  __func__, ret);

	return ret;
}

static void
dlb2_pf_domain_reset(struct dlb2_eventdev *dlb2)
{
	struct dlb2_dev *dlb2_dev;
	int ret;

	dlb2_dev = (struct dlb2_dev *)dlb2->qm_instance.pf_dev;
	ret = dlb2_pf_reset_domain(&dlb2_dev->hw, dlb2->qm_instance.domain_id);
	if (ret)
		DLB2_LOG_ERR("dlb2_pf_reset_domain err %d", ret);
}

static int
dlb2_pf_ldb_queue_create(struct dlb2_hw_dev *handle,
			 struct dlb2_create_ldb_queue_args *cfg)
{
	struct dlb2_dev *dlb2_dev = (struct dlb2_dev *)handle->pf_dev;
	struct dlb2_cmd_response response = {0};
	int ret;

	DLB2_INFO(dev->dlb2_device, "Entering %s()\n", __func__);

	ret = dlb2_pf_create_ldb_queue(&dlb2_dev->hw,
				       handle->domain_id,
				       cfg,
				       &response);

	cfg->response = response;

	DLB2_INFO(dev->dlb2_device, "Exiting %s() with ret=%d\n",
		  __func__, ret);

	return ret;
}

static int
dlb2_pf_get_sn_occupancy(struct dlb2_hw_dev *handle,
			 struct dlb2_get_sn_occupancy_args *args)
{
	struct dlb2_dev *dlb2_dev = (struct dlb2_dev *)handle->pf_dev;
	struct dlb2_cmd_response response = {0};
	int ret;

	ret = dlb2_get_group_sequence_number_occupancy(&dlb2_dev->hw,
						       args->group);

	response.id = ret;
	response.status = 0;

	args->response = response;

	return ret;
}

static int
dlb2_pf_get_sn_allocation(struct dlb2_hw_dev *handle,
			  struct dlb2_get_sn_allocation_args *args)
{
	struct dlb2_dev *dlb2_dev = (struct dlb2_dev *)handle->pf_dev;
	struct dlb2_cmd_response response = {0};
	int ret;

	ret = dlb2_get_group_sequence_numbers(&dlb2_dev->hw, args->group);

	response.id = ret;
	response.status = 0;

	args->response = response;

	return ret;
}

static int
dlb2_pf_set_sn_allocation(struct dlb2_hw_dev *handle,
			  struct dlb2_set_sn_allocation_args *args)
{
	struct dlb2_dev *dlb2_dev = (struct dlb2_dev *)handle->pf_dev;
	struct dlb2_cmd_response response = {0};
	int ret;

	ret = dlb2_set_group_sequence_numbers(&dlb2_dev->hw, args->group,
					      args->num);

	response.status = 0;

	args->response = response;

	return ret;
}

static void *
dlb2_alloc_coherent_aligned(const struct rte_memzone **mz, uintptr_t *phys,
			    size_t size, int align)
{
	char mz_name[RTE_MEMZONE_NAMESIZE];
	uint32_t core_id = rte_lcore_id();
	unsigned int socket_id;

	snprintf(mz_name, sizeof(mz_name) - 1, "event_dlb2_pf_%lx",
		 (unsigned long)rte_get_timer_cycles());
	if (core_id == (unsigned int)LCORE_ID_ANY)
		core_id = rte_get_main_lcore();
	socket_id = rte_lcore_to_socket_id(core_id);
	*mz = rte_memzone_reserve_aligned(mz_name, size, socket_id,
					 RTE_MEMZONE_IOVA_CONTIG, align);
	if (*mz == NULL) {
		DLB2_LOG_DBG("Unable to allocate DMA memory of size %zu bytes - %s\n",
			     size, rte_strerror(rte_errno));
		*phys = 0;
		return NULL;
	}
	*phys = (*mz)->iova;
	return (*mz)->addr;
}

static int
dlb2_pf_ldb_port_create(struct dlb2_hw_dev *handle,
			struct dlb2_create_ldb_port_args *cfg,
			enum dlb2_cq_poll_modes poll_mode)
{
	struct dlb2_dev *dlb2_dev = (struct dlb2_dev *)handle->pf_dev;
	struct dlb2_cmd_response response = {0};
	struct dlb2_port_memory port_memory;
	int ret, cq_alloc_depth;
	uint8_t *port_base;
	const struct rte_memzone *mz;
	int alloc_sz, qe_sz;
	phys_addr_t cq_base;
	phys_addr_t pp_base;
	int is_dir = false;

	DLB2_INFO(dev->dlb2_device, "Entering %s()\n", __func__);

	if (poll_mode == DLB2_CQ_POLL_MODE_STD)
		qe_sz = sizeof(struct dlb2_dequeue_qe);
	else
		qe_sz = RTE_CACHE_LINE_SIZE;

	/* Calculate the port memory required, and round up to the nearest
	 * cache line.
	 */
	cq_alloc_depth = RTE_MAX(cfg->cq_depth, DLB2_MIN_HARDWARE_CQ_DEPTH);
	alloc_sz = cq_alloc_depth * qe_sz;
	alloc_sz = RTE_CACHE_LINE_ROUNDUP(alloc_sz);

	port_base = dlb2_alloc_coherent_aligned(&mz, &cq_base, alloc_sz,
						PAGE_SIZE);
	if (port_base == NULL)
		return -ENOMEM;

	/* Lock the page in memory */
	ret = rte_mem_lock_page(port_base);
	if (ret < 0) {
		DLB2_LOG_ERR("dlb2 pf pmd could not lock page for device i/o\n");
		goto create_port_err;
	}

	memset(port_base, 0, alloc_sz);

	ret = dlb2_pf_create_ldb_port(&dlb2_dev->hw,
				      handle->domain_id,
				      cfg,
				      cq_base,
				      &response);
	if (ret)
		goto create_port_err;

	pp_base = (uintptr_t)dlb2_dev->hw.func_kva + PP_BASE(is_dir);
	dlb2_port[response.id][DLB2_LDB_PORT].pp_addr =
		(void *)(pp_base + (PAGE_SIZE * response.id));

	dlb2_port[response.id][DLB2_LDB_PORT].cq_base = (void *)(port_base);
	memset(&port_memory, 0, sizeof(port_memory));

	dlb2_port[response.id][DLB2_LDB_PORT].mz = mz;

	dlb2_list_init_head(&port_memory.list);

	cfg->response = response;

	return 0;

create_port_err:

	rte_memzone_free(mz);

	DLB2_INFO(dev->dlb2_device, "Exiting %s() with ret=%d\n",
		  __func__, ret);
	return ret;
}

static int
dlb2_pf_dir_port_create(struct dlb2_hw_dev *handle,
			struct dlb2_create_dir_port_args *cfg,
			enum dlb2_cq_poll_modes poll_mode)
{
	struct dlb2_dev *dlb2_dev = (struct dlb2_dev *)handle->pf_dev;
	struct dlb2_cmd_response response = {0};
	struct dlb2_port_memory port_memory;
	int ret;
	uint8_t *port_base;
	const struct rte_memzone *mz;
	int alloc_sz, qe_sz;
	phys_addr_t cq_base;
	phys_addr_t pp_base;
	int is_dir = true;

	DLB2_INFO(dev->dlb2_device, "Entering %s()\n", __func__);

	if (poll_mode == DLB2_CQ_POLL_MODE_STD)
		qe_sz = sizeof(struct dlb2_dequeue_qe);
	else
		qe_sz = RTE_CACHE_LINE_SIZE;

	/* Calculate the port memory required, and round up to the nearest
	 * cache line.
	 */
	alloc_sz = cfg->cq_depth * qe_sz;
	alloc_sz = RTE_CACHE_LINE_ROUNDUP(alloc_sz);

	port_base = dlb2_alloc_coherent_aligned(&mz, &cq_base, alloc_sz,
						PAGE_SIZE);
	if (port_base == NULL)
		return -ENOMEM;

	/* Lock the page in memory */
	ret = rte_mem_lock_page(port_base);
	if (ret < 0) {
		DLB2_LOG_ERR("dlb2 pf pmd could not lock page for device i/o\n");
		goto create_port_err;
	}

	memset(port_base, 0, alloc_sz);

	ret = dlb2_pf_create_dir_port(&dlb2_dev->hw,
				      handle->domain_id,
				      cfg,
				      cq_base,
				      &response);
	if (ret)
		goto create_port_err;

	pp_base = (uintptr_t)dlb2_dev->hw.func_kva + PP_BASE(is_dir);
	dlb2_port[response.id][DLB2_DIR_PORT].pp_addr =
		(void *)(pp_base + (PAGE_SIZE * response.id));

	dlb2_port[response.id][DLB2_DIR_PORT].cq_base =
		(void *)(port_base);
	memset(&port_memory, 0, sizeof(port_memory));

	dlb2_port[response.id][DLB2_DIR_PORT].mz = mz;

	dlb2_list_init_head(&port_memory.list);

	cfg->response = response;

	return 0;

create_port_err:

	rte_memzone_free(mz);

	DLB2_INFO(dev->dlb2_device, "Exiting %s() with ret=%d\n",
		  __func__, ret);

	return ret;
}

static int
dlb2_pf_dir_queue_create(struct dlb2_hw_dev *handle,
			 struct dlb2_create_dir_queue_args *cfg)
{
	struct dlb2_dev *dlb2_dev = (struct dlb2_dev *)handle->pf_dev;
	struct dlb2_cmd_response response = {0};
	int ret;

	DLB2_INFO(dev->dlb2_device, "Entering %s()\n", __func__);

	ret = dlb2_pf_create_dir_queue(&dlb2_dev->hw,
				       handle->domain_id,
				       cfg,
				       &response);

	cfg->response = response;

	DLB2_INFO(dev->dlb2_device, "Exiting %s() with ret=%d\n",
		  __func__, ret);

	return ret;
}

static int
dlb2_pf_map_qid(struct dlb2_hw_dev *handle,
		struct dlb2_map_qid_args *cfg)
{
	struct dlb2_dev *dlb2_dev = (struct dlb2_dev *)handle->pf_dev;
	struct dlb2_cmd_response response = {0};
	int ret;

	DLB2_INFO(dev->dlb2_device, "Entering %s()\n", __func__);

	ret = dlb2_hw_map_qid(&dlb2_dev->hw,
			      handle->domain_id,
			      cfg,
			      &response,
			      false,
			      0);

	cfg->response = response;

	DLB2_INFO(dev->dlb2_device, "Exiting %s() with ret=%d\n",
		  __func__, ret);

	return ret;
}

static int
dlb2_pf_unmap_qid(struct dlb2_hw_dev *handle,
		  struct dlb2_unmap_qid_args *cfg)
{
	struct dlb2_dev *dlb2_dev = (struct dlb2_dev *)handle->pf_dev;
	struct dlb2_cmd_response response = {0};
	int ret;

	DLB2_INFO(dev->dlb2_device, "Entering %s()\n", __func__);

	ret = dlb2_hw_unmap_qid(&dlb2_dev->hw,
				handle->domain_id,
				cfg,
				&response,
				false,
				0);

	cfg->response = response;

	DLB2_INFO(dev->dlb2_device, "Exiting %s() with ret=%d\n",
		  __func__, ret);

	return ret;
}

static int
dlb2_pf_pending_port_unmaps(struct dlb2_hw_dev *handle,
			    struct dlb2_pending_port_unmaps_args *args)
{
	struct dlb2_dev *dlb2_dev = (struct dlb2_dev *)handle->pf_dev;
	struct dlb2_cmd_response response = {0};
	int ret;

	DLB2_INFO(dev->dlb2_device, "Entering %s()\n", __func__);

	ret = dlb2_hw_pending_port_unmaps(&dlb2_dev->hw,
					  handle->domain_id,
					  args,
					  &response,
					  false,
					  0);

	args->response = response;

	DLB2_INFO(dev->dlb2_device, "Exiting %s() with ret=%d\n",
		  __func__, ret);

	return ret;
}

static int
dlb2_pf_sched_domain_start(struct dlb2_hw_dev *handle,
			   struct dlb2_start_domain_args *cfg)
{
	struct dlb2_dev *dlb2_dev = (struct dlb2_dev *)handle->pf_dev;
	struct dlb2_cmd_response response = {0};
	int ret;

	DLB2_INFO(dev->dlb2_device, "Entering %s()\n", __func__);

	ret = dlb2_pf_start_domain(&dlb2_dev->hw,
				   handle->domain_id,
				   cfg,
				   &response);

	cfg->response = response;

	DLB2_INFO(dev->dlb2_device, "Exiting %s() with ret=%d\n",
		  __func__, ret);

	return ret;
}

static int
dlb2_pf_get_ldb_queue_depth(struct dlb2_hw_dev *handle,
			    struct dlb2_get_ldb_queue_depth_args *args)
{
	struct dlb2_dev *dlb2_dev = (struct dlb2_dev *)handle->pf_dev;
	struct dlb2_cmd_response response = {0};
	int ret;

	DLB2_INFO(dev->dlb2_device, "Entering %s()\n", __func__);

	ret = dlb2_hw_get_ldb_queue_depth(&dlb2_dev->hw,
					  handle->domain_id,
					  args,
					  &response,
					  false,
					  0);

	args->response = response;

	DLB2_INFO(dev->dlb2_device, "Exiting %s() with ret=%d\n",
		  __func__, ret);

	return ret;
}

static int
dlb2_pf_get_dir_queue_depth(struct dlb2_hw_dev *handle,
			    struct dlb2_get_dir_queue_depth_args *args)
{
	struct dlb2_dev *dlb2_dev = (struct dlb2_dev *)handle->pf_dev;
	struct dlb2_cmd_response response = {0};
	int ret = 0;

	DLB2_INFO(dev->dlb2_device, "Entering %s()\n", __func__);

	ret = dlb2_hw_get_dir_queue_depth(&dlb2_dev->hw,
					  handle->domain_id,
					  args,
					  &response,
					  false,
					  0);

	args->response = response;

	DLB2_INFO(dev->dlb2_device, "Exiting %s() with ret=%d\n",
		  __func__, ret);

	return ret;
}

static void
dlb2_pf_iface_fn_ptrs_init(void)
{
	dlb2_iface_low_level_io_init = dlb2_pf_low_level_io_init;
	dlb2_iface_open = dlb2_pf_open;
	dlb2_iface_domain_reset = dlb2_pf_domain_reset;
	dlb2_iface_get_device_version = dlb2_pf_get_device_version;
	dlb2_iface_hardware_init = dlb2_pf_hardware_init;
	dlb2_iface_get_num_resources = dlb2_pf_get_num_resources;
	dlb2_iface_get_cq_poll_mode = dlb2_pf_get_cq_poll_mode;
	dlb2_iface_sched_domain_create = dlb2_pf_sched_domain_create;
	dlb2_iface_ldb_queue_create = dlb2_pf_ldb_queue_create;
	dlb2_iface_ldb_port_create = dlb2_pf_ldb_port_create;
	dlb2_iface_dir_queue_create = dlb2_pf_dir_queue_create;
	dlb2_iface_dir_port_create = dlb2_pf_dir_port_create;
	dlb2_iface_map_qid = dlb2_pf_map_qid;
	dlb2_iface_unmap_qid = dlb2_pf_unmap_qid;
	dlb2_iface_get_ldb_queue_depth = dlb2_pf_get_ldb_queue_depth;
	dlb2_iface_get_dir_queue_depth = dlb2_pf_get_dir_queue_depth;
	dlb2_iface_sched_domain_start = dlb2_pf_sched_domain_start;
	dlb2_iface_pending_port_unmaps = dlb2_pf_pending_port_unmaps;
	dlb2_iface_get_sn_allocation = dlb2_pf_get_sn_allocation;
	dlb2_iface_set_sn_allocation = dlb2_pf_set_sn_allocation;
	dlb2_iface_get_sn_occupancy = dlb2_pf_get_sn_occupancy;
}

/* PCI DEV HOOKS */
static int
dlb2_eventdev_pci_init(struct rte_eventdev *eventdev)
{
	int ret = 0;
	struct rte_pci_device *pci_dev;
	struct dlb2_devargs dlb2_args = {
		.socket_id = rte_socket_id(),
		.max_num_events = DLB2_MAX_NUM_LDB_CREDITS,
		.num_dir_credits_override = -1,
		.qid_depth_thresholds = { {0} },
		.cos_id = DLB2_COS_DEFAULT
	};
	struct dlb2_eventdev *dlb2;

	DLB2_LOG_DBG("Enter with dev_id=%d socket_id=%d",
		     eventdev->data->dev_id, eventdev->data->socket_id);

	dlb2_pf_iface_fn_ptrs_init();

	pci_dev = RTE_DEV_TO_PCI(eventdev->dev);

	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
		dlb2 = dlb2_pmd_priv(eventdev); /* rte_zmalloc_socket mem */

		/* Probe the DLB2 PF layer */
		dlb2->qm_instance.pf_dev = dlb2_probe(pci_dev);

		if (dlb2->qm_instance.pf_dev == NULL) {
			DLB2_LOG_ERR("DLB2 PF Probe failed with error %d\n",
				     rte_errno);
			ret = -rte_errno;
			goto dlb2_probe_failed;
		}

		/* Were we invoked with runtime parameters? */
		if (pci_dev->device.devargs) {
			ret = dlb2_parse_params(pci_dev->device.devargs->args,
						pci_dev->device.devargs->name,
						&dlb2_args);
			if (ret) {
				DLB2_LOG_ERR("PFPMD failed to parse args ret=%d, errno=%d\n",
					     ret, rte_errno);
				goto dlb2_probe_failed;
			}
		}

		ret = dlb2_primary_eventdev_probe(eventdev,
						  event_dlb2_pf_name,
						  &dlb2_args);
	} else {
		ret = dlb2_secondary_eventdev_probe(eventdev,
						    event_dlb2_pf_name);
	}
	if (ret)
		goto dlb2_probe_failed;

	DLB2_LOG_INFO("DLB2 PF Probe success\n");

	return 0;

dlb2_probe_failed:

	DLB2_LOG_INFO("DLB2 PF Probe failed, ret=%d\n", ret);

	return ret;
}

#define EVENTDEV_INTEL_VENDOR_ID 0x8086

static const struct rte_pci_id pci_id_dlb2_map[] = {
	{
		RTE_PCI_DEVICE(EVENTDEV_INTEL_VENDOR_ID,
			       PCI_DEVICE_ID_INTEL_DLB2_PF)
	},
	{
		.vendor_id = 0,
	},
};

static int
event_dlb2_pci_probe(struct rte_pci_driver *pci_drv,
		     struct rte_pci_device *pci_dev)
{
	int ret;

	ret = rte_event_pmd_pci_probe_named(pci_drv, pci_dev,
					     sizeof(struct dlb2_eventdev),
					     dlb2_eventdev_pci_init,
					     event_dlb2_pf_name);
	if (ret) {
		DLB2_LOG_INFO("rte_event_pmd_pci_probe_named() failed, "
				"ret=%d\n", ret);
	}

	return ret;
}

static int
event_dlb2_pci_remove(struct rte_pci_device *pci_dev)
{
	int ret;

	ret = rte_event_pmd_pci_remove(pci_dev, NULL);

	if (ret) {
		DLB2_LOG_INFO("rte_event_pmd_pci_remove() failed, "
				"ret=%d\n", ret);
	}

	return ret;

}

static struct rte_pci_driver pci_eventdev_dlb2_pmd = {
	.id_table = pci_id_dlb2_map,
	.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
	.probe = event_dlb2_pci_probe,
	.remove = event_dlb2_pci_remove,
};

RTE_PMD_REGISTER_PCI(event_dlb2_pf, pci_eventdev_dlb2_pmd);
RTE_PMD_REGISTER_PCI_TABLE(event_dlb2_pf, pci_id_dlb2_map);