Exemple #1
0
static void
attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
	  struct spdk_nvme_ctrlr *ctrlr, const struct spdk_nvme_ctrlr_opts *opts)
{
	printf("Attached to %s\n", trid->traddr);

	register_ctrlr(ctrlr);
}
Exemple #2
0
static void
attach_cb(void *cb_ctx, struct spdk_pci_device *dev, struct spdk_nvme_ctrlr *ctrlr,
	  const struct spdk_nvme_ctrlr_opts *opts)
{
	printf("Attached to %04x:%02x:%02x.%02x\n",
	       spdk_pci_device_get_domain(dev),
	       spdk_pci_device_get_bus(dev),
	       spdk_pci_device_get_dev(dev),
	       spdk_pci_device_get_func(dev));

	register_ctrlr(ctrlr);
}
Exemple #3
0
static int
register_controllers(void)
{
    struct pci_device_iterator	*pci_dev_iter;
    struct pci_device		*pci_dev;
    struct pci_id_match		match;
    int				rc;

    printf("Initializing NVMe Controllers\n");

    pci_system_init();

    match.vendor_id =	PCI_MATCH_ANY;
    match.subvendor_id =	PCI_MATCH_ANY;
    match.subdevice_id =	PCI_MATCH_ANY;
    match.device_id =	PCI_MATCH_ANY;
    match.device_class =	NVME_CLASS_CODE;
    match.device_class_mask = 0xFFFFFF;

    pci_dev_iter = pci_id_match_iterator_create(&match);

    rc = 0;
    while ((pci_dev = pci_device_next(pci_dev_iter))) {
        struct nvme_controller *ctrlr;

        if (pci_device_has_non_null_driver(pci_dev)) {
            fprintf(stderr, "non-null kernel driver attached to nvme\n");
            fprintf(stderr, " controller at pci bdf %d:%d:%d\n",
                    pci_dev->bus, pci_dev->dev, pci_dev->func);
            fprintf(stderr, " skipping...\n");
            continue;
        }

        pci_device_probe(pci_dev);

        ctrlr = nvme_attach(pci_dev);
        if (ctrlr == NULL) {
            fprintf(stderr, "nvme_attach failed for controller at pci bdf %d:%d:%d\n",
                    pci_dev->bus, pci_dev->dev, pci_dev->func);
            rc = 1;
            continue;
        }

        register_ctrlr(ctrlr, pci_dev);
    }

    pci_iterator_destroy(pci_dev_iter);

    return rc;
}
Exemple #4
0
static void
attach_cb(void *cb_ctx, struct spdk_pci_device *pci_dev, struct spdk_nvme_ctrlr *ctrlr)
{
	register_ctrlr(ctrlr);
}