QemuEPC multi function verify for pci
Signed-off-by: yezhonghui <yezhonghui@xiaomi.com>
This commit is contained in:
parent
db19d00e64
commit
786dabfb13
|
@ -41,6 +41,8 @@
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define PCI_EPF_TEST_FUNCTIONS 2
|
||||||
|
|
||||||
#define PCI_EPF_TEST_IRQ_TYPE_LEGACY 0
|
#define PCI_EPF_TEST_IRQ_TYPE_LEGACY 0
|
||||||
#define PCI_EPF_TEST_IRQ_TYPE_MSI 1
|
#define PCI_EPF_TEST_IRQ_TYPE_MSI 1
|
||||||
#define PCI_EPF_TEST_IRQ_TYPE_MSIX 2
|
#define PCI_EPF_TEST_IRQ_TYPE_MSIX 2
|
||||||
|
@ -64,9 +66,6 @@
|
||||||
|
|
||||||
#define PCI_EPF_TEST_WORK_PERIOD MSEC2TICK(10)
|
#define PCI_EPF_TEST_WORK_PERIOD MSEC2TICK(10)
|
||||||
|
|
||||||
#define ALIGN_UP(x, m) (((x) + ((m) - 1)) \
|
|
||||||
& ~((uintptr_t)(m) - 1))
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Types
|
* Private Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
@ -118,10 +117,17 @@ static const struct pci_epf_ops_s g_pci_epf_test_ops =
|
||||||
|
|
||||||
static const struct pci_epf_device_id_s g_pci_epf_test_id_table[] =
|
static const struct pci_epf_device_id_s g_pci_epf_test_id_table[] =
|
||||||
{
|
{
|
||||||
{.name = "pci_epf_test", },
|
{.name = "pci_epf_test_0", },
|
||||||
|
{.name = "pci_epf_test_1", },
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static FAR const char *g_pci_epf_test_name[] =
|
||||||
|
{
|
||||||
|
"pci_epf_test_0",
|
||||||
|
"pci_epf_test_1",
|
||||||
|
};
|
||||||
|
|
||||||
static struct pci_epf_driver_s g_pci_epf_test_driver =
|
static struct pci_epf_driver_s g_pci_epf_test_driver =
|
||||||
{
|
{
|
||||||
.id_table = g_pci_epf_test_id_table,
|
.id_table = g_pci_epf_test_id_table,
|
||||||
|
@ -649,7 +655,7 @@ static int pci_epf_test_bind(FAR struct pci_epf_device_s *epf)
|
||||||
ret = pci_epc_start(epf->epc);
|
ret = pci_epc_start(epf->epc);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
pcierr("start error %d\n", ret);
|
pcierr("epc control start error\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -674,7 +680,7 @@ static int pci_epf_test_probe(FAR struct pci_epf_device_s *epf)
|
||||||
test->header.vendorid = 0x104c;
|
test->header.vendorid = 0x104c;
|
||||||
test->header.deviceid = 0xb500;
|
test->header.deviceid = 0xb500;
|
||||||
test->header.baseclass_code = PCI_CLASS_OTHERS;
|
test->header.baseclass_code = PCI_CLASS_OTHERS;
|
||||||
test->header.interrupt_pin = PCI_INTERRUPT_INTA;
|
test->header.interrupt_pin = PCI_INTERRUPT_INTA + epf->funcno;
|
||||||
test->bar_size[0] = 1024;
|
test->bar_size[0] = 1024;
|
||||||
test->bar_size[1] = 512;
|
test->bar_size[1] = 512;
|
||||||
test->bar_size[2] = 1024;
|
test->bar_size[2] = 1024;
|
||||||
|
@ -706,30 +712,41 @@ int pci_register_epf_test_device(FAR const char *epc_name)
|
||||||
{
|
{
|
||||||
FAR struct pci_epf_device_s *epf;
|
FAR struct pci_epf_device_s *epf;
|
||||||
int ret;
|
int ret;
|
||||||
|
int i;
|
||||||
|
|
||||||
epf = kmm_zalloc(sizeof(*epf));
|
epf = kmm_zalloc(sizeof(*epf) * PCI_EPF_TEST_FUNCTIONS);
|
||||||
if (NULL == epf)
|
if (NULL == epf)
|
||||||
{
|
{
|
||||||
pcierr("create epf error\n");
|
pcierr("create epf error\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
epf->name = "pci_epf_test";
|
for (i = 0; i < PCI_EPF_TEST_FUNCTIONS; i++)
|
||||||
epf->epc_name = epc_name;
|
|
||||||
epf->msi_interrupts = 1;
|
|
||||||
epf->msix_interrupts = 32;
|
|
||||||
nxmutex_init(&epf->lock);
|
|
||||||
ret = pci_epf_device_register(epf);
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
{
|
||||||
pcierr("link error");
|
epf[i].name = g_pci_epf_test_name[i];
|
||||||
goto err;
|
epf[i].epc_name = epc_name;
|
||||||
|
epf[i].msi_interrupts = 1;
|
||||||
|
epf[i].msix_interrupts = 32;
|
||||||
|
epf[i].funcno = i;
|
||||||
|
nxmutex_init(&epf[i].lock);
|
||||||
|
ret = pci_epf_device_register(&epf[i]);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
pcierr("func %d link error\n", i);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
nxmutex_destroy(&epf->lock);
|
nxmutex_destroy(&epf[i].lock);
|
||||||
|
while (i-- > 0)
|
||||||
|
{
|
||||||
|
pci_epf_device_unregister(&epf[i]);
|
||||||
|
nxmutex_destroy(&epf[i].lock);
|
||||||
|
}
|
||||||
|
|
||||||
kmm_free(epf);
|
kmm_free(epf);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue