mempool/octeontx2: add build infra and device probe
[dpdk.git] / drivers / mempool / octeontx2 / otx2_mempool.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(C) 2019 Marvell International Ltd.
3  */
4
5 #include <rte_bus_pci.h>
6 #include <rte_common.h>
7 #include <rte_eal.h>
8 #include <rte_pci.h>
9
10 #include "otx2_common.h"
11
12 static int
13 npa_remove(struct rte_pci_device *pci_dev)
14 {
15         if (rte_eal_process_type() != RTE_PROC_PRIMARY)
16                 return 0;
17
18         RTE_SET_USED(pci_dev);
19         return 0;
20 }
21
22 static int
23 npa_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
24 {
25         RTE_SET_USED(pci_drv);
26
27         if (rte_eal_process_type() != RTE_PROC_PRIMARY)
28                 return 0;
29
30         RTE_SET_USED(pci_dev);
31         return 0;
32 }
33
34 static const struct rte_pci_id pci_npa_map[] = {
35         {
36                 RTE_PCI_DEVICE(PCI_VENDOR_ID_CAVIUM,
37                                         PCI_DEVID_OCTEONTX2_RVU_NPA_PF)
38         },
39         {
40                 RTE_PCI_DEVICE(PCI_VENDOR_ID_CAVIUM,
41                                         PCI_DEVID_OCTEONTX2_RVU_NPA_VF)
42         },
43         {
44                 .vendor_id = 0,
45         },
46 };
47
48 static struct rte_pci_driver pci_npa = {
49         .id_table = pci_npa_map,
50         .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_IOVA_AS_VA,
51         .probe = npa_probe,
52         .remove = npa_remove,
53 };
54
55 RTE_PMD_REGISTER_PCI(mempool_octeontx2, pci_npa);
56 RTE_PMD_REGISTER_PCI_TABLE(mempool_octeontx2, pci_npa_map);
57 RTE_PMD_REGISTER_KMOD_DEP(mempool_octeontx2, "vfio-pci");