@@ -14,6 +14,3 @@ sources += files(
'nitrox_logs.c',
'nitrox_qp.c',
)
-
-includes += include_directories('../../crypto/nitrox')
-includes += include_directories('../../compress/nitrox')
@@ -6,8 +6,6 @@
#include "nitrox_device.h"
#include "nitrox_hal.h"
-#include "nitrox_sym.h"
-#include "nitrox_comp.h"
#define PCI_VENDOR_ID_CAVIUM 0x177d
#define NITROX_V_PCI_VF_DEV_ID 0x13
@@ -63,11 +61,21 @@ ndev_release(struct nitrox_device *ndev)
rte_free(ndev);
}
+TAILQ_HEAD(ndrv_list, nitrox_driver);
+static struct ndrv_list ndrv_list = TAILQ_HEAD_INITIALIZER(ndrv_list);
+
+void
+nitrox_register_driver(struct nitrox_driver *ndrv)
+{
+ TAILQ_INSERT_TAIL(&ndrv_list, ndrv, next);
+}
+
static int
nitrox_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
struct rte_pci_device *pdev)
{
struct nitrox_device *ndev;
+ struct nitrox_driver *ndrv;
int err = -1;
/* Nitrox CSR space */
@@ -79,19 +87,21 @@ nitrox_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
return -ENOMEM;
ndev_init(ndev, pdev);
- err = nitrox_sym_pmd_create(ndev);
- if (err)
- goto sym_pmd_err;
-
- err = nitrox_comp_pmd_create(ndev);
- if (err)
- goto comp_pmd_err;
+ TAILQ_FOREACH(ndrv, &ndrv_list, next) {
+ err = ndrv->create(ndev);
+ if (err)
+ goto drv_err;
+ }
return 0;
-comp_pmd_err:
- nitrox_sym_pmd_destroy(ndev);
-sym_pmd_err:
+drv_err:
+ ndrv = TAILQ_PREV(ndrv, ndrv_list, next);
+ while (ndrv != NULL) {
+ ndrv->destroy(ndev);
+ ndrv = TAILQ_PREV(ndrv, ndrv_list, next);
+ }
+
ndev_release(ndev);
return err;
}
@@ -100,19 +110,18 @@ static int
nitrox_pci_remove(struct rte_pci_device *pdev)
{
struct nitrox_device *ndev;
+ struct nitrox_driver *ndrv;
int err;
ndev = find_ndev(pdev);
if (!ndev)
return -ENODEV;
- err = nitrox_sym_pmd_destroy(ndev);
- if (err)
- return err;
-
- err = nitrox_comp_pmd_destroy(ndev);
- if (err)
- return err;
+ TAILQ_FOREACH(ndrv, &ndrv_list, next) {
+ err = ndrv->destroy(ndev);
+ if (err)
+ return err;
+ }
ndev_release(ndev);
return 0;
@@ -133,33 +142,5 @@ static struct rte_pci_driver nitrox_pmd = {
.remove = nitrox_pci_remove,
};
-__rte_weak int
-nitrox_sym_pmd_create(struct nitrox_device *ndev)
-{
- RTE_SET_USED(ndev);
- return 0;
-}
-
-__rte_weak int
-nitrox_sym_pmd_destroy(struct nitrox_device *ndev)
-{
- RTE_SET_USED(ndev);
- return 0;
-}
-
-__rte_weak int
-nitrox_comp_pmd_create(struct nitrox_device *ndev)
-{
- RTE_SET_USED(ndev);
- return 0;
-}
-
-__rte_weak int
-nitrox_comp_pmd_destroy(struct nitrox_device *ndev)
-{
- RTE_SET_USED(ndev);
- return 0;
-}
-
RTE_PMD_REGISTER_PCI(nitrox, nitrox_pmd);
RTE_PMD_REGISTER_PCI_TABLE(nitrox, pci_id_nitrox_map);
@@ -6,6 +6,7 @@
#define _NITROX_DEVICE_H_
#include <bus_pci_driver.h>
+#include <rte_compat.h>
struct nitrox_sym_device;
struct nitrox_comp_device;
@@ -21,4 +22,19 @@ struct nitrox_device {
uint16_t nr_queues;
};
+struct nitrox_driver {
+ TAILQ_ENTRY(nitrox_driver) next;
+ int (*create)(struct nitrox_device *ndev);
+ int (*destroy)(struct nitrox_device *ndev);
+};
+
+__rte_internal
+void nitrox_register_driver(struct nitrox_driver *ndrv);
+
+#define NITROX_REGISTER_DRIVER(ndrv) \
+RTE_INIT(ndrv ## _register) \
+{ \
+ nitrox_register_driver(&ndrv); \
+}
+
#endif /* _NITROX_DEVICE_H_ */
@@ -4,6 +4,7 @@ INTERNAL {
nitrox_logtype;
nitrox_qp_release;
nitrox_qp_setup;
+ nitrox_register_driver;
local: *;
};
@@ -12,5 +12,3 @@ sources += files(
'nitrox_comp.c',
'nitrox_comp_reqmgr.c',
)
-
-includes += include_directories('../../common/nitrox')
@@ -602,3 +602,9 @@ nitrox_comp_pmd_destroy(struct nitrox_device *ndev)
ndev->comp_dev = NULL;
return 0;
}
+
+static struct nitrox_driver comp_drv = {
+ .create = nitrox_comp_pmd_create,
+ .destroy = nitrox_comp_pmd_destroy,
+};
+NITROX_REGISTER_DRIVER(comp_drv);
@@ -13,5 +13,3 @@ sources += files(
'nitrox_sym_capabilities.c',
'nitrox_sym_reqmgr.c',
)
-
-includes += include_directories('../../common/nitrox')
@@ -798,6 +798,12 @@ nitrox_sym_pmd_destroy(struct nitrox_device *ndev)
return rte_cryptodev_pmd_destroy(ndev->sym_dev->cdev);
}
+static struct nitrox_driver sym_drv = {
+ .create = nitrox_sym_pmd_create,
+ .destroy = nitrox_sym_pmd_destroy,
+};
+NITROX_REGISTER_DRIVER(sym_drv);
+
static struct cryptodev_driver nitrox_crypto_drv;
RTE_PMD_REGISTER_CRYPTO_DRIVER(nitrox_crypto_drv,
nitrox_rte_sym_drv,