DPDK apps can be executed as non-root users but current NFP lock
file for avoiding concurrent accesses to CPP interface is precluding
this option or requires to modify system file permissions.
When the NFP device is bound to VFIO, this driver does not allow this
concurrent access, so the lock file is not required at all.
OVS-DPDK as executed in RedHat distributions is the main NFP user
needing this fix.
Fixes:
c7e9729da6b5 ("net/nfp: support CPP")
Signed-off-by: Alejandro Lucero <alejandro.lucero@netronome.com>
if (!dev)
return ret;
- cpp = nfp_cpp_from_device_name(dev->device.name);
+ /*
+ * When device bound to UIO, the device could be used, by mistake,
+ * by two DPDK apps, and the UIO driver does not avoid it. This
+ * could lead to a serious problem when configuring the NFP CPP
+ * interface. Here we avoid this telling to the CPP init code to
+ * use a lock file if UIO is being used.
+ */
+ if (dev->kdrv == RTE_KDRV_VFIO)
+ cpp = nfp_cpp_from_device_name(dev->device.name, 0);
+ else
+ cpp = nfp_cpp_from_device_name(dev->device.name, 1);
+
if (!cpp) {
PMD_DRV_LOG(ERR, "A CPP handle can not be obtained");
ret = -EIO;
* island XPB CSRs.
*/
uint32_t imb_cat_table[16];
+
+ int driver_lock_needed;
};
/*
*
* @return NFP CPP handle, or NULL on failure (and set errno accordingly).
*/
-struct nfp_cpp *nfp_cpp_from_device_name(const char *devname);
+struct nfp_cpp *nfp_cpp_from_device_name(const char *devname,
+ int driver_lock_needed);
/*
* Free a NFP CPP handle
memset(desc->busdev, 0, BUSDEV_SZ);
strlcpy(desc->busdev, devname, sizeof(desc->busdev));
- ret = nfp_acquire_process_lock(desc);
- if (ret)
- return -1;
+ if (cpp->driver_lock_needed) {
+ ret = nfp_acquire_process_lock(desc);
+ if (ret)
+ return -1;
+ }
snprintf(tmp_str, sizeof(tmp_str), "%s/%s/driver", PCI_DEVICES,
desc->busdev);
if (desc->bar[x - 1].iomem)
munmap(desc->bar[x - 1].iomem, 1 << (desc->barsz - 3));
}
- close(desc->lock);
+ if (cpp->driver_lock_needed)
+ close(desc->lock);
close(desc->device);
free(desc);
}
}
static struct nfp_cpp *
-nfp_cpp_alloc(const char *devname)
+nfp_cpp_alloc(const char *devname, int driver_lock_needed)
{
const struct nfp_cpp_operations *ops;
struct nfp_cpp *cpp;
return NULL;
cpp->op = ops;
+ cpp->driver_lock_needed = driver_lock_needed;
if (cpp->op->init) {
err = cpp->op->init(cpp, devname);
}
struct nfp_cpp *
-nfp_cpp_from_device_name(const char *devname)
+nfp_cpp_from_device_name(const char *devname, int driver_lock_needed)
{
- return nfp_cpp_alloc(devname);
+ return nfp_cpp_alloc(devname, driver_lock_needed);
}
/*