#include "ccp_pci.h"
#include "ccp_pmd_private.h"
+int iommu_mode;
struct ccp_list ccp_list = TAILQ_HEAD_INITIALIZER(ccp_list);
static int ccp_dev_id;
CCP_WRITE_REG(vaddr, CMD_CLK_GATE_CTL_OFFSET, 0x00108823);
}
- CCP_WRITE_REG(vaddr, CMD_REQID_CONFIG_OFFSET, 0x00001249);
+ CCP_WRITE_REG(vaddr, CMD_REQID_CONFIG_OFFSET, 0x0);
/* Copy the private LSB mask to the public registers */
status_lo = CCP_READ_REG(vaddr, LSB_PRIVATE_MASK_LO_OFFSET);
cmd_q->qsize, SOCKET_ID_ANY);
cmd_q->qbase_addr = (void *)q_mz->addr;
cmd_q->qbase_desc = (void *)q_mz->addr;
- cmd_q->qbase_phys_addr = q_mz->phys_addr;
+ cmd_q->qbase_phys_addr = q_mz->iova;
cmd_q->qcontrol = 0;
/* init control reg to zero */
}
static int
-ccp_probe_device(const char *dirname, uint16_t domain,
- uint8_t bus, uint8_t devid,
- uint8_t function, int ccp_type)
+ccp_probe_device(int ccp_type, struct rte_pci_device *pci_dev)
{
struct ccp_device *ccp_dev = NULL;
- struct rte_pci_device *pci;
- char filename[PATH_MAX];
- unsigned long tmp;
- int uio_fd = -1, i, uio_num;
- char uio_devname[PATH_MAX];
- void *map_addr;
+ int uio_fd = -1;
ccp_dev = rte_zmalloc("ccp_device", sizeof(*ccp_dev),
RTE_CACHE_LINE_SIZE);
if (ccp_dev == NULL)
goto fail;
- pci = &(ccp_dev->pci);
-
- pci->addr.domain = domain;
- pci->addr.bus = bus;
- pci->addr.devid = devid;
- pci->addr.function = function;
-
- /* get vendor id */
- snprintf(filename, sizeof(filename), "%s/vendor", dirname);
- if (ccp_pci_parse_sysfs_value(filename, &tmp) < 0)
- goto fail;
- pci->id.vendor_id = (uint16_t)tmp;
-
- /* get device id */
- snprintf(filename, sizeof(filename), "%s/device", dirname);
- if (ccp_pci_parse_sysfs_value(filename, &tmp) < 0)
- goto fail;
- pci->id.device_id = (uint16_t)tmp;
-
- /* get subsystem_vendor id */
- snprintf(filename, sizeof(filename), "%s/subsystem_vendor",
- dirname);
- if (ccp_pci_parse_sysfs_value(filename, &tmp) < 0)
- goto fail;
- pci->id.subsystem_vendor_id = (uint16_t)tmp;
-
- /* get subsystem_device id */
- snprintf(filename, sizeof(filename), "%s/subsystem_device",
- dirname);
- if (ccp_pci_parse_sysfs_value(filename, &tmp) < 0)
- goto fail;
- pci->id.subsystem_device_id = (uint16_t)tmp;
-
- /* get class_id */
- snprintf(filename, sizeof(filename), "%s/class",
- dirname);
- if (ccp_pci_parse_sysfs_value(filename, &tmp) < 0)
- goto fail;
- /* the least 24 bits are valid: class, subclass, program interface */
- pci->id.class_id = (uint32_t)tmp & RTE_CLASS_ANY_ID;
- /* parse resources */
- snprintf(filename, sizeof(filename), "%s/resource", dirname);
- if (ccp_pci_parse_sysfs_resource(filename, pci) < 0)
- goto fail;
-
- uio_num = ccp_find_uio_devname(dirname);
- if (uio_num < 0) {
- /*
- * It may take time for uio device to appear,
- * wait here and try again
- */
- usleep(100000);
- uio_num = ccp_find_uio_devname(dirname);
- if (uio_num < 0)
- goto fail;
- }
- snprintf(uio_devname, sizeof(uio_devname), "/dev/uio%u", uio_num);
-
- uio_fd = open(uio_devname, O_RDWR | O_NONBLOCK);
- if (uio_fd < 0)
- goto fail;
- if (flock(uio_fd, LOCK_EX | LOCK_NB))
- goto fail;
-
- /* Map the PCI memory resource of device */
- for (i = 0; i < PCI_MAX_RESOURCE; i++) {
-
- char devname[PATH_MAX];
- int res_fd;
-
- if (pci->mem_resource[i].phys_addr == 0)
- continue;
- snprintf(devname, sizeof(devname), "%s/resource%d", dirname, i);
- res_fd = open(devname, O_RDWR);
- if (res_fd < 0)
- goto fail;
- map_addr = mmap(NULL, pci->mem_resource[i].len,
- PROT_READ | PROT_WRITE,
- MAP_SHARED, res_fd, 0);
- if (map_addr == MAP_FAILED)
- goto fail;
-
- pci->mem_resource[i].addr = map_addr;
- }
+ ccp_dev->pci = *pci_dev;
/* device is valid, add in list */
if (ccp_add_device(ccp_dev, ccp_type)) {
return 0;
fail:
CCP_LOG_ERR("CCP Device probe failed");
- if (uio_fd > 0)
+ if (uio_fd >= 0)
close(uio_fd);
- if (ccp_dev)
- rte_free(ccp_dev);
+ rte_free(ccp_dev);
return -1;
}
int
-ccp_probe_devices(const struct rte_pci_id *ccp_id)
+ccp_probe_devices(struct rte_pci_device *pci_dev,
+ const struct rte_pci_id *ccp_id)
{
int dev_cnt = 0;
int ccp_type = 0;
if (module_idx < 0)
return -1;
+ iommu_mode = module_idx;
TAILQ_INIT(&ccp_list);
dir = opendir(SYSFS_PCI_DEVICES);
if (dir == NULL)
if (is_ccp_device(dirname, ccp_id, &ccp_type)) {
printf("CCP : Detected CCP device with ID = 0x%x\n",
ccp_id[ccp_type].device_id);
- ret = ccp_probe_device(dirname, domain, bus, devid,
- function, ccp_type);
+ ret = ccp_probe_device(ccp_type, pci_dev);
if (ret == 0)
dev_cnt++;
}