bus/fslmc: support dynamic logging

Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
This commit is contained in:
Shreyansh Jain 2018-04-02 19:35:55 +05:30 committed by Thomas Monjalon
parent db2ed70bbb
commit ce9efbf5bb
7 changed files with 213 additions and 173 deletions

View File

@ -10,13 +10,8 @@ include $(RTE_SDK)/mk/rte.vars.mk
LIB = librte_bus_fslmc.a
CFLAGS += -DALLOW_EXPERIMENTAL_API
ifeq ($(CONFIG_RTE_LIBRTE_DPAA2_DEBUG_INIT),y)
CFLAGS += -O0 -g
CFLAGS += "-Wno-error"
else
CFLAGS += -O3
CFLAGS += $(WERROR_FLAGS)
endif
CFLAGS += -I$(RTE_SDK)/drivers/bus/fslmc
CFLAGS += -I$(RTE_SDK)/drivers/bus/fslmc/mc

View File

@ -18,9 +18,9 @@
#include <rte_fslmc.h>
#include <fslmc_vfio.h>
#include "fslmc_logs.h"
#define FSLMC_BUS_LOG(level, fmt, args...) \
RTE_LOG(level, EAL, fmt "\n", ##args)
int dpaa2_logtype_bus;
#define VFIO_IOMMU_GROUP_PATH "/sys/kernel/iommu_groups"
@ -93,6 +93,25 @@ insert_in_device_list(struct rte_dpaa2_device *newdev)
TAILQ_INSERT_TAIL(&rte_fslmc_bus.device_list, newdev, next);
}
static void
dump_device_list(void)
{
struct rte_dpaa2_device *dev;
uint32_t global_log_level;
int local_log_level;
/* Only if the log level has been set to Debugging, print list */
global_log_level = rte_log_get_global_level();
local_log_level = rte_log_get_level(dpaa2_logtype_bus);
if (global_log_level == RTE_LOG_DEBUG ||
local_log_level == RTE_LOG_DEBUG) {
DPAA2_BUS_DEBUG("List of devices scanned on bus:");
TAILQ_FOREACH(dev, &rte_fslmc_bus.device_list, next) {
DPAA2_BUS_DEBUG("%s", dev->device.name);
}
}
}
static int
scan_one_fslmc_device(char *dev_name)
{
@ -109,7 +128,7 @@ scan_one_fslmc_device(char *dev_name)
/* Creating a temporary copy to perform cut-parse over string */
dup_dev_name = strdup(dev_name);
if (!dup_dev_name) {
FSLMC_BUS_LOG(ERR, "Out of memory.");
DPAA2_BUS_ERR("Unable to allocate device name memory");
return -ENOMEM;
}
@ -120,7 +139,7 @@ scan_one_fslmc_device(char *dev_name)
*/
dev = calloc(1, sizeof(struct rte_dpaa2_device));
if (!dev) {
FSLMC_BUS_LOG(ERR, "Out of memory.");
DPAA2_BUS_ERR("Unable to allocate device object");
free(dup_dev_name);
return -ENOMEM;
}
@ -128,7 +147,7 @@ scan_one_fslmc_device(char *dev_name)
/* Parse the device name and ID */
t_ptr = strtok(dup_dev_name, ".");
if (!t_ptr) {
FSLMC_BUS_LOG(ERR, "Incorrect device string observed.");
DPAA2_BUS_ERR("Incorrect device name observed");
goto cleanup;
}
if (!strncmp("dpni", t_ptr, 4))
@ -153,15 +172,14 @@ scan_one_fslmc_device(char *dev_name)
t_ptr = strtok(NULL, ".");
if (!t_ptr) {
FSLMC_BUS_LOG(ERR, "Incorrect device string observed (%s).",
t_ptr);
DPAA2_BUS_ERR("Incorrect device string observed (%s)", t_ptr);
goto cleanup;
}
sscanf(t_ptr, "%hu", &dev->object_id);
dev->device.name = strdup(dev_name);
if (!dev->device.name) {
FSLMC_BUS_LOG(ERR, "Out of memory.");
DPAA2_BUS_ERR("Unable to clone device name. Out of memory");
goto cleanup;
}
@ -193,8 +211,7 @@ rte_fslmc_scan(void)
int groupid;
if (process_once) {
FSLMC_BUS_LOG(DEBUG,
"Fslmc bus already scanned. Not rescanning");
DPAA2_BUS_DEBUG("Fslmc bus already scanned. Not rescanning");
return 0;
}
process_once = 1;
@ -208,7 +225,7 @@ rte_fslmc_scan(void)
groupid);
dir = opendir(fslmc_dirpath);
if (!dir) {
FSLMC_BUS_LOG(ERR, "Unable to open VFIO group dir.");
DPAA2_BUS_ERR("Unable to open VFIO group directory");
goto scan_fail;
}
@ -224,9 +241,12 @@ rte_fslmc_scan(void)
device_count += 1;
}
FSLMC_BUS_LOG(INFO, "fslmc: Bus scan completed");
closedir(dir);
DPAA2_BUS_INFO("FSLMC Bus scan completed");
/* If debugging is enabled, device list is dumped to log output */
dump_device_list();
return 0;
scan_fail_cleanup:
@ -235,7 +255,7 @@ scan_fail_cleanup:
/* Remove all devices in the list */
cleanup_fslmc_device_list();
scan_fail:
FSLMC_BUS_LOG(DEBUG, "FSLMC Bus Not Available. Skipping.");
DPAA2_BUS_INFO("FSLMC Bus Not Available. Skipping");
/* Irrespective of failure, scan only return success */
return 0;
}
@ -262,13 +282,13 @@ rte_fslmc_probe(void)
ret = fslmc_vfio_setup_group();
if (ret) {
FSLMC_BUS_LOG(ERR, "Unable to setup VFIO %d", ret);
DPAA2_BUS_ERR("Unable to setup VFIO %d", ret);
return 0;
}
ret = fslmc_vfio_process_group();
if (ret) {
FSLMC_BUS_LOG(ERR, "Unable to setup devices %d", ret);
DPAA2_BUS_ERR("Unable to setup devices %d", ret);
return 0;
}
@ -283,7 +303,7 @@ rte_fslmc_probe(void)
ret = drv->probe(drv, dev);
if (ret)
FSLMC_BUS_LOG(ERR, "Unable to probe.\n");
DPAA2_BUS_ERR("Unable to probe");
break;
}
}
@ -399,3 +419,13 @@ struct rte_fslmc_bus rte_fslmc_bus = {
};
RTE_REGISTER_BUS(fslmc, rte_fslmc_bus.bus);
RTE_INIT(fslmc_init_log);
static void
fslmc_init_log(void)
{
/* Bus level logs */
dpaa2_logtype_bus = rte_log_register("bus.fslmc");
if (dpaa2_logtype_bus >= 0)
rte_log_set_level(dpaa2_logtype_bus, RTE_LOG_NOTICE);
}

View File

@ -7,6 +7,37 @@
#ifndef _FSLMC_LOGS_H_
#define _FSLMC_LOGS_H_
extern int dpaa2_logtype_bus;
#define DPAA2_BUS_LOG(level, fmt, args...) \
rte_log(RTE_LOG_ ## level, dpaa2_logtype_bus, "fslmc: " fmt "\n", \
##args)
/* Debug logs are with Function names */
#define DPAA2_BUS_DEBUG(fmt, args...) \
rte_log(RTE_LOG_DEBUG, dpaa2_logtype_bus, "fslmc: %s(): " fmt "\n", \
__func__, ##args)
#define BUS_INIT_FUNC_TRACE() DPAA2_BUS_LOG(DEBUG, " >>")
#define DPAA2_BUS_INFO(fmt, args...) \
DPAA2_BUS_LOG(INFO, fmt, ## args)
#define DPAA2_BUS_ERR(fmt, args...) \
DPAA2_BUS_LOG(ERR, fmt, ## args)
#define DPAA2_BUS_WARN(fmt, args...) \
DPAA2_BUS_LOG(WARNING, fmt, ## args)
/* DP Logs, toggled out at compile time if level lower than current level */
#define DPAA2_BUS_DP_LOG(level, fmt, args...) \
RTE_LOG_DP(level, PMD, fmt, ## args)
#define DPAA2_BUS_DP_DEBUG(fmt, args...) \
DPAA2_BUS_DP_LOG(DEBUG, fmt, ## args)
#define DPAA2_BUS_DP_INFO(fmt, args...) \
DPAA2_BUS_DP_LOG(INFO, fmt, ## args)
#define DPAA2_BUS_DP_WARN(fmt, args...) \
DPAA2_BUS_DP_LOG(WARNING, fmt, ## args)
#define PMD_INIT_LOG(level, fmt, args...) \
RTE_LOG(level, PMD, "%s(): " fmt "\n", __func__, ##args)

View File

@ -33,14 +33,12 @@
#include "rte_fslmc.h"
#include "fslmc_vfio.h"
#include "fslmc_logs.h"
#include <mc/fsl_dpmng.h>
#include "portal/dpaa2_hw_pvt.h"
#include "portal/dpaa2_hw_dpio.h"
#define FSLMC_VFIO_LOG(level, fmt, args...) \
RTE_LOG(level, EAL, fmt "\n", ##args)
/** Pathname of FSL-MC devices directory. */
#define SYSFS_FSL_MC_DEVICES "/sys/bus/fsl-mc/devices"
@ -76,19 +74,18 @@ fslmc_get_container_group(int *groupid)
if (!g_container) {
container = getenv("DPRC");
if (container == NULL) {
RTE_LOG(DEBUG, EAL, "DPAA2: DPRC not available\n");
DPAA2_BUS_INFO("DPAA2: DPRC not available");
return -EINVAL;
}
if (strlen(container) >= FSLMC_CONTAINER_MAX_LEN) {
FSLMC_VFIO_LOG(ERR, "Invalid container name: %s\n",
container);
DPAA2_BUS_ERR("Invalid container name: %s", container);
return -1;
}
g_container = strdup(container);
if (!g_container) {
FSLMC_VFIO_LOG(ERR, "Out of memory.");
DPAA2_BUS_ERR("Mem alloc failure; Container name");
return -ENOMEM;
}
}
@ -96,13 +93,12 @@ fslmc_get_container_group(int *groupid)
/* get group number */
ret = vfio_get_group_no(SYSFS_FSL_MC_DEVICES, g_container, groupid);
if (ret <= 0) {
FSLMC_VFIO_LOG(ERR, "Unable to find %s IOMMU group",
g_container);
DPAA2_BUS_ERR("Unable to find %s IOMMU group", g_container);
return -1;
}
FSLMC_VFIO_LOG(DEBUG, "Container: %s has VFIO iommu group id = %d",
g_container, *groupid);
DPAA2_BUS_DEBUG("Container: %s has VFIO iommu group id = %d",
g_container, *groupid);
return 0;
}
@ -113,14 +109,14 @@ vfio_connect_container(void)
int fd, ret;
if (vfio_container.used) {
FSLMC_VFIO_LOG(DEBUG, "No container available.");
DPAA2_BUS_DEBUG("No container available");
return -1;
}
/* Try connecting to vfio container if already created */
if (!ioctl(vfio_group.fd, VFIO_GROUP_SET_CONTAINER,
&vfio_container.fd)) {
FSLMC_VFIO_LOG(INFO,
DPAA2_BUS_DEBUG(
"Container pre-exists with FD[0x%x] for this group",
vfio_container.fd);
vfio_group.container = &vfio_container;
@ -130,7 +126,7 @@ vfio_connect_container(void)
/* Opens main vfio file descriptor which represents the "container" */
fd = vfio_get_container_fd();
if (fd < 0) {
FSLMC_VFIO_LOG(ERR, "Failed to open VFIO container");
DPAA2_BUS_ERR("Failed to open VFIO container");
return -errno;
}
@ -139,19 +135,19 @@ vfio_connect_container(void)
/* Connect group to container */
ret = ioctl(vfio_group.fd, VFIO_GROUP_SET_CONTAINER, &fd);
if (ret) {
FSLMC_VFIO_LOG(ERR, "Failed to setup group container");
DPAA2_BUS_ERR("Failed to setup group container");
close(fd);
return -errno;
}
ret = ioctl(fd, VFIO_SET_IOMMU, VFIO_TYPE1_IOMMU);
if (ret) {
FSLMC_VFIO_LOG(ERR, "Failed to setup VFIO iommu");
DPAA2_BUS_ERR("Failed to setup VFIO iommu");
close(fd);
return -errno;
}
} else {
FSLMC_VFIO_LOG(ERR, "No supported IOMMU available");
DPAA2_BUS_ERR("No supported IOMMU available");
close(fd);
return -EINVAL;
}
@ -179,7 +175,7 @@ static int vfio_map_irq_region(struct fslmc_vfio_group *group)
vaddr = (unsigned long *)mmap(NULL, 0x1000, PROT_WRITE |
PROT_READ, MAP_SHARED, container_device_fd, 0x6030000);
if (vaddr == MAP_FAILED) {
FSLMC_VFIO_LOG(ERR, "Unable to map region (errno = %d)", errno);
DPAA2_BUS_ERR("Unable to map region (errno = %d)", errno);
return -errno;
}
@ -189,7 +185,7 @@ static int vfio_map_irq_region(struct fslmc_vfio_group *group)
if (ret == 0)
return 0;
FSLMC_VFIO_LOG(ERR, "VFIO_IOMMU_MAP_DMA fails (errno = %d)", errno);
DPAA2_BUS_ERR("Unable to map DMA address (errno = %d)", errno);
return -errno;
}
@ -210,13 +206,13 @@ int rte_fslmc_vfio_dmamap(void)
memseg = rte_eal_get_physmem_layout();
if (memseg == NULL) {
FSLMC_VFIO_LOG(ERR, "Cannot get physical layout.");
DPAA2_BUS_ERR("Cannot get physical layout");
return -ENODEV;
}
for (i = 0; i < RTE_MAX_MEMSEG; i++) {
if (memseg[i].addr == NULL && memseg[i].len == 0) {
FSLMC_VFIO_LOG(DEBUG, "Total %d segments found.", i);
DPAA2_BUS_DEBUG("Total %d segments found", i);
break;
}
@ -235,25 +231,25 @@ int rte_fslmc_vfio_dmamap(void)
group = &vfio_group;
if (!group->container) {
FSLMC_VFIO_LOG(ERR, "Container is not connected ");
DPAA2_BUS_ERR("Container is not connected");
return -1;
}
FSLMC_VFIO_LOG(DEBUG, "-->Initial SHM Virtual ADDR %llX",
dma_map.vaddr);
FSLMC_VFIO_LOG(DEBUG, "-----> DMA size 0x%llX", dma_map.size);
DPAA2_BUS_DEBUG("-->Initial SHM Virtual ADDR %llX",
dma_map.vaddr);
DPAA2_BUS_DEBUG("-----> DMA size 0x%llX", dma_map.size);
ret = ioctl(group->container->fd, VFIO_IOMMU_MAP_DMA,
&dma_map);
if (ret) {
FSLMC_VFIO_LOG(ERR, "VFIO_IOMMU_MAP_DMA API(errno = %d)",
errno);
DPAA2_BUS_ERR("Unable to map DMA address (errno = %d)",
errno);
return ret;
}
}
/* Verifying that at least single segment is available */
if (i <= 0) {
FSLMC_VFIO_LOG(ERR, "No Segments found for VFIO Mapping");
DPAA2_BUS_ERR("No Segments found for VFIO Mapping");
return -1;
}
@ -279,27 +275,27 @@ static int64_t vfio_map_mcp_obj(struct fslmc_vfio_group *group, char *mcp_obj)
/* getting the mcp object's fd*/
mc_fd = ioctl(group->fd, VFIO_GROUP_GET_DEVICE_FD, mcp_obj);
if (mc_fd < 0) {
FSLMC_VFIO_LOG(ERR, "error in VFIO get dev %s fd from group %d",
mcp_obj, group->fd);
DPAA2_BUS_ERR("Error in VFIO get dev %s fd from group %d",
mcp_obj, group->fd);
return v_addr;
}
/* getting device info*/
ret = ioctl(mc_fd, VFIO_DEVICE_GET_INFO, &d_info);
if (ret < 0) {
FSLMC_VFIO_LOG(ERR, "error in VFIO getting DEVICE_INFO");
DPAA2_BUS_ERR("Error in VFIO getting DEVICE_INFO");
goto MC_FAILURE;
}
/* getting device region info*/
ret = ioctl(mc_fd, VFIO_DEVICE_GET_REGION_INFO, &reg_info);
if (ret < 0) {
FSLMC_VFIO_LOG(ERR, "error in VFIO getting REGION_INFO");
DPAA2_BUS_ERR("Error in VFIO getting REGION_INFO");
goto MC_FAILURE;
}
FSLMC_VFIO_LOG(DEBUG, "region offset = %llx , region size = %llx",
reg_info.offset, reg_info.size);
DPAA2_BUS_DEBUG("Region offset = %llx , region size = %llx",
reg_info.offset, reg_info.size);
v_addr = (size_t)mmap(NULL, reg_info.size,
PROT_WRITE | PROT_READ, MAP_SHARED,
@ -334,8 +330,8 @@ int rte_dpaa2_intr_enable(struct rte_intr_handle *intr_handle, int index)
ret = ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);
if (ret) {
RTE_LOG(ERR, EAL, "Error:dpaa2 SET IRQs fd=%d, err = %d(%s)\n",
intr_handle->fd, errno, strerror(errno));
DPAA2_BUS_ERR("Error:dpaa2 SET IRQs fd=%d, err = %d(%s)",
intr_handle->fd, errno, strerror(errno));
return ret;
}
@ -359,8 +355,8 @@ int rte_dpaa2_intr_disable(struct rte_intr_handle *intr_handle, int index)
ret = ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);
if (ret)
RTE_LOG(ERR, EAL,
"Error disabling dpaa2 interrupts for fd %d\n",
DPAA2_BUS_ERR(
"Error disabling dpaa2 interrupts for fd %d",
intr_handle->fd);
return ret;
@ -383,9 +379,8 @@ rte_dpaa2_vfio_setup_intr(struct rte_intr_handle *intr_handle,
ret = ioctl(vfio_dev_fd, VFIO_DEVICE_GET_IRQ_INFO, &irq_info);
if (ret < 0) {
FSLMC_VFIO_LOG(ERR,
"cannot get IRQ(%d) info, error %i (%s)",
i, errno, strerror(errno));
DPAA2_BUS_ERR("Cannot get IRQ(%d) info, error %i (%s)",
i, errno, strerror(errno));
return -1;
}
@ -399,9 +394,8 @@ rte_dpaa2_vfio_setup_intr(struct rte_intr_handle *intr_handle,
/* set up an eventfd for interrupts */
fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
if (fd < 0) {
FSLMC_VFIO_LOG(ERR,
"cannot set up eventfd, error %i (%s)\n",
errno, strerror(errno));
DPAA2_BUS_ERR("Cannot set up eventfd, error %i (%s)",
errno, strerror(errno));
return -1;
}
@ -430,13 +424,14 @@ fslmc_process_iodevices(struct rte_dpaa2_device *dev)
dev_fd = ioctl(vfio_group.fd, VFIO_GROUP_GET_DEVICE_FD,
dev->device.name);
if (dev_fd <= 0) {
FSLMC_VFIO_LOG(ERR, "Unable to obtain device FD for device:%s",
dev->device.name);
DPAA2_BUS_ERR("Unable to obtain device FD for device:%s",
dev->device.name);
return -1;
}
if (ioctl(dev_fd, VFIO_DEVICE_GET_INFO, &device_info)) {
FSLMC_VFIO_LOG(ERR, "DPAA2 VFIO_DEVICE_GET_INFO fail");
DPAA2_BUS_ERR("Unable to obtain information for device:%s",
dev->device.name);
return -1;
}
@ -461,8 +456,8 @@ fslmc_process_iodevices(struct rte_dpaa2_device *dev)
break;
}
FSLMC_VFIO_LOG(DEBUG, "Device (%s) abstracted from VFIO",
dev->device.name);
DPAA2_BUS_DEBUG("Device (%s) abstracted from VFIO",
dev->device.name);
return 0;
}
@ -476,13 +471,13 @@ fslmc_process_mcp(struct rte_dpaa2_device *dev)
rte_mcp_ptr_list = malloc(sizeof(void *) * 1);
if (!rte_mcp_ptr_list) {
FSLMC_VFIO_LOG(ERR, "Out of memory");
DPAA2_BUS_ERR("Unable to allocate MC portal memory");
return -ENOMEM;
}
dev_name = strdup(dev->device.name);
if (!dev_name) {
FSLMC_VFIO_LOG(ERR, "Out of memory.");
DPAA2_BUS_ERR("Unable to allocate MC device name memory");
free(rte_mcp_ptr_list);
rte_mcp_ptr_list = NULL;
return -ENOMEM;
@ -490,8 +485,7 @@ fslmc_process_mcp(struct rte_dpaa2_device *dev)
v_addr = vfio_map_mcp_obj(&vfio_group, dev_name);
if (v_addr == (intptr_t)MAP_FAILED) {
FSLMC_VFIO_LOG(ERR, "Error mapping region (errno = %d)",
errno);
DPAA2_BUS_ERR("Error mapping region (errno = %d)", errno);
free(rte_mcp_ptr_list);
rte_mcp_ptr_list = NULL;
return -1;
@ -499,16 +493,18 @@ fslmc_process_mcp(struct rte_dpaa2_device *dev)
/* check the MC version compatibility */
dpmng.regs = (void *)v_addr;
if (mc_get_version(&dpmng, CMD_PRI_LOW, &mc_ver_info))
RTE_LOG(WARNING, PMD, "\tmc_get_version failed\n");
if (mc_get_version(&dpmng, CMD_PRI_LOW, &mc_ver_info)) {
DPAA2_BUS_ERR("Unable to obtain MC version");
return -1;
}
if ((mc_ver_info.major != MC_VER_MAJOR) ||
(mc_ver_info.minor < MC_VER_MINOR)) {
RTE_LOG(ERR, PMD, "DPAA2 MC version not compatible!"
" Expected %d.%d.x, Detected %d.%d.%d\n",
MC_VER_MAJOR, MC_VER_MINOR,
mc_ver_info.major, mc_ver_info.minor,
mc_ver_info.revision);
DPAA2_BUS_ERR("DPAA2 MC version not compatible!"
" Expected %d.%d.x, Detected %d.%d.%d",
MC_VER_MAJOR, MC_VER_MINOR,
mc_ver_info.major, mc_ver_info.minor,
mc_ver_info.revision);
free(rte_mcp_ptr_list);
rte_mcp_ptr_list = NULL;
return -1;
@ -530,7 +526,7 @@ fslmc_vfio_process_group(void)
if (dev->dev_type == DPAA2_MPORTAL) {
ret = fslmc_process_mcp(dev);
if (ret) {
FSLMC_VFIO_LOG(DEBUG, "Unable to map Portal.");
DPAA2_BUS_ERR("Unable to map MC Portal");
return -1;
}
if (!found_mportal)
@ -547,8 +543,7 @@ fslmc_vfio_process_group(void)
/* Cannot continue if there is not even a single mportal */
if (!found_mportal) {
FSLMC_VFIO_LOG(DEBUG,
"No MC Portal device found. Not continuing.");
DPAA2_BUS_ERR("No MC Portal device found. Not continuing");
return -1;
}
@ -561,9 +556,8 @@ fslmc_vfio_process_group(void)
case DPAA2_CRYPTO:
ret = fslmc_process_iodevices(dev);
if (ret) {
FSLMC_VFIO_LOG(DEBUG,
"Dev (%s) init failed.",
dev->device.name);
DPAA2_BUS_DEBUG("Dev (%s) init failed",
dev->device.name);
return ret;
}
break;
@ -576,9 +570,8 @@ fslmc_vfio_process_group(void)
*/
ret = fslmc_process_iodevices(dev);
if (ret) {
FSLMC_VFIO_LOG(DEBUG,
"Dev (%s) init failed.",
dev->device.name);
DPAA2_BUS_DEBUG("Dev (%s) init failed",
dev->device.name);
return -1;
}
@ -592,8 +585,8 @@ fslmc_vfio_process_group(void)
case DPAA2_UNKNOWN:
default:
/* Unknown - ignore */
FSLMC_VFIO_LOG(DEBUG, "Found unknown device (%s).",
dev->device.name);
DPAA2_BUS_DEBUG("Found unknown device (%s)",
dev->device.name);
TAILQ_REMOVE(&rte_fslmc_bus.device_list, dev, next);
free(dev);
dev = NULL;
@ -622,7 +615,7 @@ fslmc_vfio_setup_group(void)
* processing.
*/
if (vfio_group.groupid == groupid) {
FSLMC_VFIO_LOG(ERR, "groupid already exists %d", groupid);
DPAA2_BUS_ERR("groupid already exists %d", groupid);
return 0;
}
@ -635,14 +628,14 @@ fslmc_vfio_setup_group(void)
/* Check group viability */
ret = ioctl(vfio_group.fd, VFIO_GROUP_GET_STATUS, &status);
if (ret) {
FSLMC_VFIO_LOG(ERR, "VFIO error getting group status");
DPAA2_BUS_ERR("VFIO error getting group status");
close(vfio_group.fd);
rte_vfio_clear_group(vfio_group.fd);
return ret;
}
if (!(status.flags & VFIO_GROUP_FLAGS_VIABLE)) {
FSLMC_VFIO_LOG(ERR, "VFIO group not viable");
DPAA2_BUS_ERR("VFIO group not viable");
close(vfio_group.fd);
rte_vfio_clear_group(vfio_group.fd);
return -EPERM;
@ -655,7 +648,7 @@ fslmc_vfio_setup_group(void)
/* Now connect this IOMMU group to given container */
ret = vfio_connect_container();
if (ret) {
FSLMC_VFIO_LOG(ERR,
DPAA2_BUS_ERR(
"Error connecting container with groupid %d",
groupid);
close(vfio_group.fd);
@ -667,15 +660,15 @@ fslmc_vfio_setup_group(void)
/* Get Device information */
ret = ioctl(vfio_group.fd, VFIO_GROUP_GET_DEVICE_FD, g_container);
if (ret < 0) {
FSLMC_VFIO_LOG(ERR, "Error getting device %s fd from group %d",
g_container, vfio_group.groupid);
DPAA2_BUS_ERR("Error getting device %s fd from group %d",
g_container, vfio_group.groupid);
close(vfio_group.fd);
rte_vfio_clear_group(vfio_group.fd);
return ret;
}
container_device_fd = ret;
FSLMC_VFIO_LOG(DEBUG, "VFIO Container FD is [0x%X]",
container_device_fd);
DPAA2_BUS_DEBUG("VFIO Container FD is [0x%X]",
container_device_fd);
return 0;
}

View File

@ -44,7 +44,7 @@ dpaa2_create_dpbp_device(int vdev_fd __rte_unused,
/* Allocate DPAA2 dpbp handle */
dpbp_node = rte_malloc(NULL, sizeof(struct dpaa2_dpbp_dev), 0);
if (!dpbp_node) {
PMD_INIT_LOG(ERR, "Memory allocation failed for DPBP Device");
DPAA2_BUS_ERR("Memory allocation failed for DPBP Device");
return -1;
}
@ -53,8 +53,8 @@ dpaa2_create_dpbp_device(int vdev_fd __rte_unused,
ret = dpbp_open(&dpbp_node->dpbp,
CMD_PRI_LOW, dpbp_id, &dpbp_node->token);
if (ret) {
PMD_INIT_LOG(ERR, "Resource alloc failure with err code: %d",
ret);
DPAA2_BUS_ERR("Unable to open buffer pool object: err(%d)",
ret);
rte_free(dpbp_node);
return -1;
}
@ -62,8 +62,8 @@ dpaa2_create_dpbp_device(int vdev_fd __rte_unused,
/* Clean the device first */
ret = dpbp_reset(&dpbp_node->dpbp, CMD_PRI_LOW, dpbp_node->token);
if (ret) {
PMD_INIT_LOG(ERR, "Failure cleaning dpbp device with"
" error code %d\n", ret);
DPAA2_BUS_ERR("Unable to reset buffer pool device. err(%d)",
ret);
dpbp_close(&dpbp_node->dpbp, CMD_PRI_LOW, dpbp_node->token);
rte_free(dpbp_node);
return -1;
@ -74,8 +74,6 @@ dpaa2_create_dpbp_device(int vdev_fd __rte_unused,
TAILQ_INSERT_TAIL(&dpbp_dev_list, dpbp_node, next);
RTE_LOG(DEBUG, PMD, "DPAA2: Added [dpbp.%d]\n", dpbp_id);
if (!register_once) {
rte_mbuf_set_platform_mempool_ops(DPAA2_MEMPOOL_OPS_NAME);
register_once = 1;

View File

@ -44,7 +44,7 @@ rte_dpaa2_create_dpci_device(int vdev_fd __rte_unused,
/* Allocate DPAA2 dpci handle */
dpci_node = rte_malloc(NULL, sizeof(struct dpaa2_dpci_dev), 0);
if (!dpci_node) {
PMD_INIT_LOG(ERR, "Memory allocation failed for DPCI Device");
DPAA2_BUS_ERR("Memory allocation failed for DPCI Device");
return -1;
}
@ -53,8 +53,7 @@ rte_dpaa2_create_dpci_device(int vdev_fd __rte_unused,
ret = dpci_open(&dpci_node->dpci,
CMD_PRI_LOW, dpci_id, &dpci_node->token);
if (ret) {
PMD_INIT_LOG(ERR, "Resource alloc failure with err code: %d",
ret);
DPAA2_BUS_ERR("Resource alloc failure with err code: %d", ret);
rte_free(dpci_node);
return -1;
}
@ -63,8 +62,7 @@ rte_dpaa2_create_dpci_device(int vdev_fd __rte_unused,
ret = dpci_get_attributes(&dpci_node->dpci,
CMD_PRI_LOW, dpci_node->token, &attr);
if (ret != 0) {
PMD_INIT_LOG(ERR, "Reading device failed with err code: %d",
ret);
DPAA2_BUS_ERR("Reading device failed with err code: %d", ret);
rte_free(dpci_node);
return -1;
}
@ -76,8 +74,8 @@ rte_dpaa2_create_dpci_device(int vdev_fd __rte_unused,
dpci_node->token,
0, &rx_queue_cfg);
if (ret) {
PMD_INIT_LOG(ERR, "Setting Rx queue failed with err code: %d",
ret);
DPAA2_BUS_ERR("Setting Rx queue failed with err code: %d",
ret);
rte_free(dpci_node);
return -1;
}
@ -86,8 +84,7 @@ rte_dpaa2_create_dpci_device(int vdev_fd __rte_unused,
ret = dpci_enable(&dpci_node->dpci,
CMD_PRI_LOW, dpci_node->token);
if (ret != 0) {
PMD_INIT_LOG(ERR, "Enabling device failed with err code: %d",
ret);
DPAA2_BUS_ERR("Enabling device failed with err code: %d", ret);
rte_free(dpci_node);
return -1;
}
@ -99,9 +96,8 @@ rte_dpaa2_create_dpci_device(int vdev_fd __rte_unused,
dpci_node->token, i,
&rx_attr);
if (ret != 0) {
PMD_INIT_LOG(ERR,
"Reading device failed with err code: %d",
ret);
DPAA2_BUS_ERR("Rx queue fetch failed with err code:"
" %d", ret);
rte_free(dpci_node);
return -1;
}
@ -114,8 +110,6 @@ rte_dpaa2_create_dpci_device(int vdev_fd __rte_unused,
TAILQ_INSERT_TAIL(&dpci_dev_list, dpci_node, next);
RTE_LOG(DEBUG, PMD, "DPAA2: Added [dpci.%d]\n", dpci_id);
return 0;
}

View File

@ -101,7 +101,7 @@ static void dpaa2_affine_dpio_intr_to_respective_core(int32_t dpio_id)
snprintf(string, STRING_LEN, "dpio.%d", dpio_id);
file = fopen("/proc/interrupts", "r");
if (!file) {
PMD_DRV_LOG(WARNING, "Failed to open /proc/interrupts file\n");
DPAA2_BUS_WARN("Failed to open /proc/interrupts file");
return;
}
while (getline(&temp, &len, file) != -1) {
@ -112,8 +112,8 @@ static void dpaa2_affine_dpio_intr_to_respective_core(int32_t dpio_id)
}
if (!token) {
PMD_DRV_LOG(WARNING, "Failed to get interrupt id for dpio.%d\n",
dpio_id);
DPAA2_BUS_WARN("Failed to get interrupt id for dpio.%d",
dpio_id);
if (temp)
free(temp);
fclose(file);
@ -125,10 +125,10 @@ static void dpaa2_affine_dpio_intr_to_respective_core(int32_t dpio_id)
cpu_mask, token);
ret = system(command);
if (ret < 0)
PMD_DRV_LOG(WARNING,
"Failed to affine interrupts on respective core\n");
DPAA2_BUS_WARN(
"Failed to affine interrupts on respective core");
else
PMD_DRV_LOG(WARNING, " %s command is executed\n", command);
DPAA2_BUS_DEBUG(" %s command is executed", command);
free(temp);
fclose(file);
@ -143,7 +143,7 @@ static int dpaa2_dpio_intr_init(struct dpaa2_dpio_dev *dpio_dev)
dpio_epoll_fd = epoll_create(1);
ret = rte_dpaa2_intr_enable(&dpio_dev->intr_handle, 0);
if (ret) {
PMD_DRV_LOG(ERR, "Interrupt registeration failed\n");
DPAA2_BUS_ERR("Interrupt registeration failed");
return -1;
}
@ -166,7 +166,7 @@ static int dpaa2_dpio_intr_init(struct dpaa2_dpio_dev *dpio_dev)
ret = epoll_ctl(dpio_epoll_fd, EPOLL_CTL_ADD, eventfd, &epoll_ev);
if (ret < 0) {
PMD_DRV_LOG(ERR, "epoll_ctl failed\n");
DPAA2_BUS_ERR("epoll_ctl failed");
return -1;
}
dpio_dev->epoll_fd = dpio_epoll_fd;
@ -185,28 +185,28 @@ configure_dpio_qbman_swp(struct dpaa2_dpio_dev *dpio_dev)
dpio_dev->dpio = malloc(sizeof(struct fsl_mc_io));
if (!dpio_dev->dpio) {
PMD_INIT_LOG(ERR, "Memory allocation failure\n");
DPAA2_BUS_ERR("Memory allocation failure");
return -1;
}
PMD_DRV_LOG(DEBUG, "Allocated DPIO Portal[%p]", dpio_dev->dpio);
DPAA2_BUS_DEBUG("Allocated DPIO Portal[%p]", dpio_dev->dpio);
dpio_dev->dpio->regs = dpio_dev->mc_portal;
if (dpio_open(dpio_dev->dpio, CMD_PRI_LOW, dpio_dev->hw_id,
&dpio_dev->token)) {
PMD_INIT_LOG(ERR, "Failed to allocate IO space\n");
DPAA2_BUS_ERR("Failed to allocate IO space");
free(dpio_dev->dpio);
return -1;
}
if (dpio_reset(dpio_dev->dpio, CMD_PRI_LOW, dpio_dev->token)) {
PMD_INIT_LOG(ERR, "Failed to reset dpio\n");
DPAA2_BUS_ERR("Failed to reset dpio");
dpio_close(dpio_dev->dpio, CMD_PRI_LOW, dpio_dev->token);
free(dpio_dev->dpio);
return -1;
}
if (dpio_enable(dpio_dev->dpio, CMD_PRI_LOW, dpio_dev->token)) {
PMD_INIT_LOG(ERR, "Failed to Enable dpio\n");
DPAA2_BUS_ERR("Failed to Enable dpio");
dpio_close(dpio_dev->dpio, CMD_PRI_LOW, dpio_dev->token);
free(dpio_dev->dpio);
return -1;
@ -214,7 +214,7 @@ configure_dpio_qbman_swp(struct dpaa2_dpio_dev *dpio_dev)
if (dpio_get_attributes(dpio_dev->dpio, CMD_PRI_LOW,
dpio_dev->token, &attr)) {
PMD_INIT_LOG(ERR, "DPIO Get attribute failed\n");
DPAA2_BUS_ERR("DPIO Get attribute failed");
dpio_disable(dpio_dev->dpio, CMD_PRI_LOW, dpio_dev->token);
dpio_close(dpio_dev->dpio, CMD_PRI_LOW, dpio_dev->token);
free(dpio_dev->dpio);
@ -231,7 +231,7 @@ configure_dpio_qbman_swp(struct dpaa2_dpio_dev *dpio_dev)
dpio_dev->sw_portal = qbman_swp_init(&p_des);
if (dpio_dev->sw_portal == NULL) {
PMD_DRV_LOG(ERR, " QBMan SW Portal Init failed\n");
DPAA2_BUS_ERR("QBMan SW Portal Init failed");
dpio_close(dpio_dev->dpio, CMD_PRI_LOW, dpio_dev->token);
free(dpio_dev->dpio);
return -1;
@ -249,7 +249,7 @@ dpaa2_configure_stashing(struct dpaa2_dpio_dev *dpio_dev, int cpu_id)
if (cpu_id < 0) {
cpu_id = rte_get_master_lcore();
if (cpu_id < 0) {
RTE_LOG(ERR, PMD, "\tGetting CPU Index failed\n");
DPAA2_BUS_ERR("Getting CPU Index failed");
return -1;
}
}
@ -258,19 +258,19 @@ dpaa2_configure_stashing(struct dpaa2_dpio_dev *dpio_dev, int cpu_id)
*/
sdest = dpaa2_core_cluster_sdest(cpu_id);
PMD_DRV_LOG(DEBUG, "Portal= %d CPU= %u SDEST= %d",
dpio_dev->index, cpu_id, sdest);
DPAA2_BUS_DEBUG("Portal= %d CPU= %u SDEST= %d",
dpio_dev->index, cpu_id, sdest);
ret = dpio_set_stashing_destination(dpio_dev->dpio, CMD_PRI_LOW,
dpio_dev->token, sdest);
if (ret) {
PMD_DRV_LOG(ERR, "%d ERROR in SDEST\n", ret);
DPAA2_BUS_ERR("%d ERROR in SDEST", ret);
return -1;
}
#ifdef RTE_LIBRTE_PMD_DPAA2_EVENTDEV
if (dpaa2_dpio_intr_init(dpio_dev)) {
PMD_DRV_LOG(ERR, "Interrupt registration failed for dpio\n");
DPAA2_BUS_ERR("Interrupt registration failed for dpio");
return -1;
}
#endif
@ -291,12 +291,12 @@ struct dpaa2_dpio_dev *dpaa2_get_qbman_swp(int cpu_id)
if (!dpio_dev)
return NULL;
PMD_DRV_LOG(DEBUG, "New Portal %p (%d) affined thread - %lu",
dpio_dev, dpio_dev->index, syscall(SYS_gettid));
DPAA2_BUS_DEBUG("New Portal %p (%d) affined thread - %lu",
dpio_dev, dpio_dev->index, syscall(SYS_gettid));
ret = dpaa2_configure_stashing(dpio_dev, cpu_id);
if (ret)
PMD_DRV_LOG(ERR, "dpaa2_configure_stashing failed");
DPAA2_BUS_ERR("dpaa2_configure_stashing failed");
return dpio_dev;
}
@ -314,7 +314,7 @@ dpaa2_affine_qbman_swp(void)
return -1;
if (dpaa2_io_portal[lcore_id].dpio_dev) {
PMD_DRV_LOG(INFO, "DPAAPortal=%p (%d) is being shared"
DPAA2_BUS_DP_INFO("DPAA Portal=%p (%d) is being shared"
" between thread %" PRIu64 " and current "
"%" PRIu64 "\n",
dpaa2_io_portal[lcore_id].dpio_dev,
@ -327,8 +327,8 @@ dpaa2_affine_qbman_swp(void)
[lcore_id].dpio_dev->ref_count);
dpaa2_io_portal[lcore_id].net_tid = tid;
PMD_DRV_LOG(DEBUG, "Old Portal=%p (%d)"
"affined thread - %" PRIu64 "\n",
DPAA2_BUS_DP_DEBUG("Old Portal=%p (%d) affined thread - "
"%" PRIu64 "\n",
dpaa2_io_portal[lcore_id].dpio_dev,
dpaa2_io_portal[lcore_id].dpio_dev->index,
tid);
@ -362,24 +362,25 @@ dpaa2_affine_qbman_swp_sec(void)
return -1;
if (dpaa2_io_portal[lcore_id].sec_dpio_dev) {
PMD_DRV_LOG(INFO, "DPAAPortal=%p (%d) is being shared"
" between thread %" PRIu64 " and current "
"%" PRIu64 "\n",
dpaa2_io_portal[lcore_id].sec_dpio_dev,
dpaa2_io_portal[lcore_id].sec_dpio_dev->index,
dpaa2_io_portal[lcore_id].sec_tid,
tid);
DPAA2_BUS_DP_INFO(
"DPAA Portal=%p (%d) is being shared between thread"
" %" PRIu64 " and current %" PRIu64 "\n",
dpaa2_io_portal[lcore_id].sec_dpio_dev,
dpaa2_io_portal[lcore_id].sec_dpio_dev->index,
dpaa2_io_portal[lcore_id].sec_tid,
tid);
RTE_PER_LCORE(_dpaa2_io).sec_dpio_dev
= dpaa2_io_portal[lcore_id].sec_dpio_dev;
rte_atomic16_inc(&dpaa2_io_portal
[lcore_id].sec_dpio_dev->ref_count);
dpaa2_io_portal[lcore_id].sec_tid = tid;
PMD_DRV_LOG(DEBUG, "Old Portal=%p (%d) "
"affined thread - %" PRIu64 "\n",
dpaa2_io_portal[lcore_id].sec_dpio_dev,
dpaa2_io_portal[lcore_id].sec_dpio_dev->index,
tid);
DPAA2_BUS_DP_DEBUG(
"Old Portal=%p (%d) affined thread"
" - %" PRIu64 "\n",
dpaa2_io_portal[lcore_id].sec_dpio_dev,
dpaa2_io_portal[lcore_id].sec_dpio_dev->index,
tid);
return 0;
}
@ -405,15 +406,14 @@ dpaa2_create_dpio_device(int vdev_fd,
struct vfio_region_info reg_info = { .argsz = sizeof(reg_info)};
if (obj_info->num_regions < NUM_DPIO_REGIONS) {
PMD_INIT_LOG(ERR, "ERROR, Not sufficient number "
"of DPIO regions.\n");
DPAA2_BUS_ERR("Not sufficient number of DPIO regions");
return -1;
}
dpio_dev = rte_malloc(NULL, sizeof(struct dpaa2_dpio_dev),
RTE_CACHE_LINE_SIZE);
if (!dpio_dev) {
PMD_INIT_LOG(ERR, "Memory allocation failed for DPIO Device\n");
DPAA2_BUS_ERR("Memory allocation failed for DPIO Device");
return -1;
}
@ -425,7 +425,7 @@ dpaa2_create_dpio_device(int vdev_fd,
reg_info.index = 0;
if (ioctl(vdev_fd, VFIO_DEVICE_GET_REGION_INFO, &reg_info)) {
PMD_INIT_LOG(ERR, "vfio: error getting region info\n");
DPAA2_BUS_ERR("vfio: error getting region info");
rte_free(dpio_dev);
return -1;
}
@ -437,7 +437,7 @@ dpaa2_create_dpio_device(int vdev_fd,
reg_info.index = 1;
if (ioctl(vdev_fd, VFIO_DEVICE_GET_REGION_INFO, &reg_info)) {
PMD_INIT_LOG(ERR, "vfio: error getting region info\n");
DPAA2_BUS_ERR("vfio: error getting region info");
rte_free(dpio_dev);
return -1;
}
@ -448,8 +448,8 @@ dpaa2_create_dpio_device(int vdev_fd,
vdev_fd, reg_info.offset);
if (configure_dpio_qbman_swp(dpio_dev)) {
PMD_INIT_LOG(ERR,
"Fail to configure the dpio qbman portal for %d\n",
DPAA2_BUS_ERR(
"Fail to configure the dpio qbman portal for %d",
dpio_dev->hw_id);
rte_free(dpio_dev);
return -1;
@ -459,8 +459,8 @@ dpaa2_create_dpio_device(int vdev_fd,
dpio_dev->index = io_space_count;
if (rte_dpaa2_vfio_setup_intr(&dpio_dev->intr_handle, vdev_fd, 1)) {
PMD_INIT_LOG(ERR, "Fail to setup interrupt for %d\n",
dpio_dev->hw_id);
DPAA2_BUS_ERR("Fail to setup interrupt for %d",
dpio_dev->hw_id);
rte_free(dpio_dev);
}
@ -470,21 +470,20 @@ dpaa2_create_dpio_device(int vdev_fd,
if (mc_get_soc_version(dpio_dev->dpio,
CMD_PRI_LOW, &mc_plat_info)) {
PMD_INIT_LOG(ERR, "\tmc_get_soc_version failed\n");
DPAA2_BUS_ERR("Unable to get SoC version information");
} else if ((mc_plat_info.svr & 0xffff0000) == SVR_LS1080A) {
dpaa2_core_cluster_base = 0x02;
dpaa2_cluster_sz = 4;
PMD_INIT_LOG(DEBUG, "\tLS108x (A53) Platform Detected");
DPAA2_BUS_DEBUG("LS108x (A53) Platform Detected");
} else if ((mc_plat_info.svr & 0xffff0000) == SVR_LX2160A) {
dpaa2_core_cluster_base = 0x00;
dpaa2_cluster_sz = 2;
PMD_INIT_LOG(DEBUG, "\tLX2160 Platform Detected");
DPAA2_BUS_DEBUG("LX2160 Platform Detected");
}
dpaa2_svr_family = (mc_plat_info.svr & 0xffff0000);
}
TAILQ_INSERT_TAIL(&dpio_dev_list, dpio_dev, next);
RTE_LOG(DEBUG, PMD, "DPAA2: Added [dpio.%d]\n", object_id);
return 0;
}