aboutsummaryrefslogtreecommitdiffstats
path: root/src/vlib/linux
AgeCommit message (Collapse)AuthorFilesLines
2020-09-17vppinfra: support main heap with different page sizesDamjan Marion1-3/+5
Type: improvement Change-Id: I381fc3dec8580208d0e24637d791af69011aa83b Signed-off-by: Damjan Marion <damarion@cisco.com>
2020-07-24pci: fix non NULL-terminated vector used as C string overflowBenoît Ganne1-4/+5
Type: fix Change-Id: Iab512ba8c72c9e20aeba2d4265276bcabf095d46 Signed-off-by: Benoît Ganne <bganne@cisco.com>
2020-05-26pci: improve vfio loggingDamjan Marion3-20/+77
Type: improvement Change-Id: Ic49a43651b80b79fa278e29964da5cb2ead2a818 Signed-off-by: Damjan Marion <damarion@cisco.com>
2020-05-06misc: fix coverity warningsDave Barach1-1/+1
Type: fix Ticket: VPP-1837 Signed-off-by: Dave Barach <dave@barachs.net> Change-Id: I51660e4b02f449bd2db12a8cfd395c6c343d2dee
2020-03-21vlib: fix error when creating avf interface on SMP systemJieqiang Wang1-1/+13
On SMP architecture, '/sys/bus/pci/devices/<devices id>/numa_node' file will return -1 as a valid value if it does not have any NUMA node information. Using -1 as a valid node id to access data structures will cause memory issue. Fix the error by setting the value of numa_node to 0 if '/sys/bus/pci/devices/ <devices id>/numa_node' returns -1 and it is a SMP system. Type: fix Change-Id: Ib60e79c3656fe5b17e08fd9011122683e8b08b6f Signed-off-by: Jieqiang Wang <jieqiang.wang@arm.com>
2019-11-20vlib: pci: fix non-NULL terminated C-stringBenoît Ganne1-2/+2
Type: fix Change-Id: I6f25d9295b973ab7133071b6dc325ecd86386898 Signed-off-by: Benoît Ganne <bganne@cisco.com>
2019-10-20vlib: linux: fix wrong iommu_group value issue when using dpdk-pluginYulong Pei1-22/+19
When VPP work with dpdk-plugin, linux_vfio_main_t->container_fd is always -1 since it never have chance to run open("/dev/vfio/vfio") to get the fd. But this lead to a potential issue of VPP, that is, when start VPP without uio-driver field setup in /etc/vpp/startup.conf, VPP will run to automatical select uio driver in vlib_pci_bind_to_uio() and the function depend on iommu_group value to decide to work on vfio or vfio-noiommu mode. Since in vlib_pci_get_device_info() have the condition container_fd != -1, so the iommu_group value will be always -1 at this scenario, this caused that VPP mistake to run with vfio-noiommu driver on intel_iommu=on state. Actually in order to get iommu_group and iommu_group/name value, no need to depend on linux_vfio_main_t->container_fd value, so the fix remove the condition lvm->container_fd != -1, then it can get the correct iommu_group value. Type: fix Change-Id: I3f162fc4971b9a2b8717205f8f3b52e30c5e5b69 Signed-off-by: Yulong Pei <yulong.pei@intel.com>
2019-10-05vlib: pci: set pci driver name to none when no driver is loadedBenoît Ganne1-0/+2
If no Linux PCI driver module is loaded, then the driver_name in the PCI info struct is NULL. This can triggers crash when checking driver name eg. in vlib_pci_device_open(). Default to "<NONE>" as driver name, which should never match. Type: fix Change-Id: I9e69889a7566467bd8220b92bbbaa72ada957257 Signed-off-by: Benoît Ganne <bganne@cisco.com>
2019-08-22vlib: fix null pointer crash on strncmpSteven Luong1-2/+2
Program received signal SIGSEGV, Segmentation fault. 0x00007ffff4b71de0 in __strncmp_sse42 () from /lib64/libc.so.6 (gdb) up up vm=0x7ffff6664d40 <vlib_global_main>, addr=0x7fffb4bec6d0, ids=0x7fffb31675f0 <avf_pci_device_ids>, handle=0x7fffb4bec594) at /usr/src/debug/vpp-20.01/src/vlib/linux/pci.c:1250 1250 if (strncmp ("vfio-pci", (char *) di->driver_name, 8) == 0) (gdb) p di p di $1 = (vlib_pci_device_info_t *) 0x7fffb6446164 (gdb) p di->driver_name p di->driver_name $2 = (u8 *) 0x0 (gdb) driver_name may be null. strncmp is not forgiving. Change to use C11 safeC version. Type: fix Signed-off-by: Steven Luong <sluong@cisco.com> Change-Id: I1777a5966ceee7409d7bde86c30b14dc75534a5a
2019-05-16init / exit function orderingDave Barach2-8/+14
The vlib init function subsystem now supports a mix of procedural and formally-specified ordering constraints. We should eliminate procedural knowledge wherever possible. The following schemes are *roughly* equivalent: static clib_error_t *init_runs_first (vlib_main_t *vm) { clib_error_t *error; ... do some stuff... if ((error = vlib_call_init_function (init_runs_next))) return error; ... } VLIB_INIT_FUNCTION (init_runs_first); and static clib_error_t *init_runs_first (vlib_main_t *vm) { ... do some stuff... } VLIB_INIT_FUNCTION (init_runs_first) = { .runs_before = VLIB_INITS("init_runs_next"), }; The first form will [most likely] call "init_runs_next" on the spot. The second form means that "init_runs_first" runs before "init_runs_next," possibly much earlier in the sequence. Please DO NOT construct sets of init functions where A before B actually means A *right before* B. It's not necessary - simply combine A and B - and it leads to hugely annoying debugging exercises when trying to switch from ad-hoc procedural ordering constraints to formal ordering constraints. Change-Id: I5e4353503bf43b4acb11a45fb33c79a5ade8426c Signed-off-by: Dave Barach <dave@barachs.net>
2019-04-03pci: Fix the crash on deleting the pci deviceMohsin Kazmi1-2/+5
clib_file_index is 0 if it is not initialized result in following assertion on deleteing the pci device. vpp/src/vppinfra/file.h:122 (clib_file_del_by_index) assertion `! pool_is_free (um->file_pool, _e)' fails This patch fixes the issue by initializing the clib_file_index to -1. Change-Id: I51d23f18e7ccf3143a4765d05aafc1363a007737 Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
2019-03-13VPP-1576: fix a set of coverity warningsDave Barach1-1/+4
Change-Id: Ifd34aed8692d5acaa370d4976d974ac573e43705 Signed-off-by: Dave Barach <dave@barachs.net>
2019-03-13vmbus: not having uio_hv_generic is not an errorStephen Hemminger1-7/+20
If uio_hv_generic is not loaded, then the startup code will fallback to the older failsafe/tap method of initialization in DPDK. Therefore don't put out scary message in the log. Also, reorder startup to avoid manipulating lower device until/unless uio is going to work. Change-Id: Ie1cc77b4b5359c04f00a93d01a772eccf3bbab37 Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2019-03-06vmbus: fix bug that breaks multiple netvsc vdevsMatthew Smith1-2/+2
VPP supports two DPDK drivers for managing netvsc devices on Azure/Hyper-V. The new netvsc PMD looks a lot like other PCI-based PMDs but it requires recently added kernel support (>=4.17). The older vdev_netvsc is an abstraction that manages the mlx4 VF and tap device underlying the netvsc interface using the failsafe PMD. Distros with older kernels (e.g. RHEL/CentOS 7.x) have to use vdev_netvsc. At startup, netvsc devices are processed and an attempt is made to initialize them for management by the netvsc PMD. If that fails, then vlib_vmbus_bind_to_uio() returns early and the device can be initialized for management by vdev_netvsc. The operation that is supposed to fail if the netvsc PMD cannot be used is registration of the netvsc device type ID with the uio_hv_generic driver. This operation is attempted exactly once so it does not fail for netvsc devices processed after the first one and they end up in a state where they cannot be initialized for use by vdev_netvsc. Only unset uio_new_id_needed if uio_hv_generic registration succeeds. Change-Id: I6be925d422b87ed24e0f4611304cc3a6b07a34fd Signed-off-by: Matthew Smith <mgsmith@netgate.com>
2019-01-31pci: get the number of interruptsMohsin Kazmi1-0/+18
Change-Id: I2cfb81b3c8809d027a3ee5f5f570668e60be08ef Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
2019-01-20buffers: keep buffer_main in vlib_main_tDamjan Marion1-1/+1
Change-Id: I3bb1d9f83dd08f4b93acd4a281bfec0674e39c2e Signed-off-by: Damjan Marion <damarion@cisco.com>
2019-01-18Fix GCC 8 compiler warnings on strncpy's truncated copy on debian distroSteven Luong1-2/+2
For some reason, GCC 8 in debian is pickier than GCC 8 in ubuntu. It complains about things in strncpy like this /home/sluong/vpp/src/vlib/linux/pci.c:485:7: error: ‘strncpy’ output may be truncated copying 15 bytes from a string of length 255 [-Werror=stringop-truncation] strncpy (ifr.ifr_name, e->d_name, sizeof (ifr.ifr_name) - 1); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/sluong/vpp/src/vlib/linux/pci.c: At top level: It also complains similar things in string_test.c The fix in pci.c is to convert strncpy to use clib_strncpy The fix in string_test.c is condiational compile the complained code for GCC 8. Change-Id: Ic9341ca54ed7407210502197a28283bc42c26662 Signed-off-by: Steven Luong <sluong@cisco.com>
2019-01-17vmbus: fix strncpy related warningsStephen Hemminger1-4/+4
The code that was manipulating interface names with ifreq was causing warnings about possible truncation and non terminated strings. These are warnings only since kernel would allow a interface name > 15 characters anyway. Change-Id: I794a94fe310b8568403d4e3523c61d53468a6f02 Reported-by: Burt Silverman <burtms@gmail.com> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2019-01-17pci: fix strncpy warningsStephen Hemminger1-4/+4
Doing strncpy(ifr.ifr_name, s, sizeof(ifr.ifr_name)) will cause a warning about string truncation with GCC 8 (and other tools). Fix this by using sizeof(ifr.ifr_name) - 1. Also, there is no need to manually zero the end of the string since the whole ifr structure is already zeroed by memset. Change-Id: I9440d602ecdd9f8592b69bab2e77479146d00d76 Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2019-01-07avf: allocate descriptor memory from local numaDamjan Marion1-0/+9
Change-Id: Ic56ee4ce83b282a5f0f5aed500721fe639b941b3 Signed-off-by: Damjan Marion <damarion@cisco.com>
2018-12-19vlib: support Hyper-v/Azure VMBusStephen Hemminger1-0/+405
This patch adds support for VMBus to the VPP infrastructure. Since the only device that matters is the netvsc Poll Mode Driver in DPDK, the infrastructure is much simpler than PCI. Change-Id: Ie96c897ad9c426716c2398e4528688ce2217419b Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2018-11-14Remove c-11 memcpy checks from perf-critical codeDave Barach1-1/+1
Change-Id: Id4f37f5d4a03160572954a416efa1ef9b3d79ad1 Signed-off-by: Dave Barach <dave@barachs.net>
2018-10-25pmalloc: support for 4K pagesDamjan Marion1-1/+1
Change-Id: Iecceffe06a92660976ebb58cd3cbec4be8931db0 Signed-off-by: Damjan Marion <damarion@cisco.com>
2018-10-24vlib: Fix pci io bar read/write fd leakMohsin Kazmi1-0/+6
Few devices provide PCI bar region(s) through I/O. If any such device driver opens I/O "fd" to read and write, needs to close it, when pci device is going to be deleted. Change-Id: Iba104e56f76c6bf9ccd27bf2223bad39b1301763 Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
2018-10-23vlib: Add support for pci io read/writeMohsin Kazmi1-19/+79
Change-Id: I9d96e7782a12c2e19eacbb75edb1fb450cf33bed Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
2018-10-23Numa-aware, growable physical memory allocator (pmalloc)Damjan Marion4-345/+68
Change-Id: Ic4c46bc733afae8bf0d8146623ed15633928de30 Signed-off-by: Damjan Marion <damarion@cisco.com>
2018-10-23c11 safe string handling supportDave Barach2-9/+9
Change-Id: Ied34720ca5a6e6e717eea4e86003e854031b6eab Signed-off-by: Dave Barach <dave@barachs.net>
2018-10-22vlib: pci improvementsDamjan Marion3-106/+150
- logging - pass vlib_main_t to all APIs - open vfio container only when needed Change-Id: I897e53e0af3f91c3a99f0c827401d1c0ec2e478a Signed-off-by: Damjan Marion <damarion@cisco.com>
2018-10-16Fix coverity issue for potentially overflowing of page sizeHaiyang Tan2-3/+3
Change-Id: I2779626d745badb63386efcf729da7a094a4f297 Signed-off-by: Haiyang Tan <haiyangtan@tencent.com>
2018-10-05vfio: don't display error if no pci devices are assigned to containerDamjan Marion1-3/+4
Change-Id: I21429ce084cfd39af6a9997b4c1e459f5a6ef672 Signed-off-by: Damjan Marion <damarion@cisco.com>
2018-09-27Add logging to vfio codeDamjan Marion2-3/+23
Change-Id: Iacdff0a5006a0617e3c9559ce7b258f26e256abb Signed-off-by: Damjan Marion <damarion@cisco.com>
2018-07-20physmem: fix alloc when dlmaloc is usedDamjan Marion1-1/+5
Change-Id: I4b6cdf95ac694c8408eb6cf3259b335a8148b5aa Signed-off-by: Damjan Marion <damarion@cisco.com>
2018-07-18Add config option to use dlmalloc instead of mheapDave Barach1-1/+24
Configure w/ --enable-dlmalloc, see .../build-data/platforms/vpp.mk src/vppinfra/dlmalloc.[ch] are slightly modified versions of the well-known Doug Lea malloc. Main advantage: dlmalloc mspaces have no inherent size limit. Change-Id: I19b3f43f3c65bcfb82c1a265a97922d01912446e Signed-off-by: Dave Barach <dave@barachs.net>
2018-06-27gcc8 and Wstringop-truncationMarco Varlese1-2/+4
gcc8 introduced a new warning (Wstringop-truncation) which in our case is being treated as error. Disabling the warning globally might introduce bugs related to string truncation which are not desired by the developer (e.g. bug). Instead, this patch disables the warning only for those occurences which have been verified to be non-bugs but the desired behaviour as per developer will. Change-Id: I0f04ff6b4fad44061e80a65af633fd7e0148a0c5 Signed-off-by: Marco Varlese <marco.varlese@suse.com>
2018-06-13add end of string for format name in unix_physmem_region_alloclollita liu1-1/+1
Change-Id: I8cb4d5d90fb321de6e5037a3d0440507db79ec75 Signed-off-by: lollita liu <lollita.liu@ericsson.com>
2018-03-29Coverity fixes (VPP-1204)Chris Luke1-1/+2
Minor bug fixes CID 183000: double close CID 180996: dead code CID 180995: NULL deref CID 181957: NULL deref CID 182676: NULL deref CID 182675: NULL deref Change-Id: Id35e391c95fafb8cd771984ee8a1a6e597056d37 Signed-off-by: Chris Luke <chrisy@flirble.org>
2018-03-26vlib: add support for vfio no-iommu modeDamjan Marion3-33/+48
Change-Id: Ic83971d8d9d8d0bb90a35932e60761cd728457f3 Signed-off-by: Damjan Marion <damarion@cisco.com>
2018-03-09Correct address calculation for VPP-1168Lee Roberts1-1/+1
Use (u64) cast to ensure proper address calculations. Change-Id: I6bad50010b140189f1b0af177e55da0045bd7a93 Signed-off-by: Lee Roberts <lee.roberts@hpe.com>
2018-03-09dpdk: move DPDK vfio hack to dpdk pluginDamjan Marion3-48/+3
Change-Id: I806cbf8c6c49643fe6c317bcceab93c1b9d441ab Signed-off-by: Damjan Marion <damarion@cisco.com>
2018-03-07fix physmem mappingsDamjan Marion1-0/+2
Change-Id: Ie0763e20c36a29a8ef866511903c85027dd133c3 Signed-off-by: Damjan Marion <damarion@cisco.com>
2018-03-05physmem: keep only one physmem_mainDamjan Marion2-5/+5
We don't need per vlib_main physmem_main, so keep it separatelly instead of trying to keep them in sync. Change-Id: I0fbeecf4d9672d31af7a43c640a7d8f05dd6e46f Signed-off-by: Damjan Marion <damarion@cisco.com>
2018-03-05vlib: add functions to dynamically open/close PCI deviceDamjan Marion1-3/+121
Old code was only allowing PCIdevices to be scanned during startup, now driver can open and close device without restart of vpp. Change-Id: I1a06511e3f16f896101b43dac2bad420b6e6c35e Signed-off-by: Damjan Marion <damarion@cisco.com>
2018-03-05vlib: vfio code reworkDamjan Marion4-210/+387
Change-Id: I99cf3e7cc991aa7d32385a155c707a6516516117 Signed-off-by: Damjan Marion <damarion@cisco.com>
2018-03-05vlib: rework PCI INTx supportDamjan Marion1-96/+72
Change-Id: I6df5a01416993c213e06645a6d9b48dfe77c8227 Signed-off-by: Damjan Marion <damarion@cisco.com>
2018-03-04vlib: add PCI MSI-X interrupt support (vfio only)Damjan Marion1-5/+183
Change-Id: Iae2ddf93d1705354175e3dcae26b66e6f98a5c32 Signed-off-by: Damjan Marion <damarion@cisco.com>
2018-03-04vlib: map pci region by using vfio FD when vfio is usedDamjan Marion1-41/+83
Change-Id: Ib94e9e9e9fcdad9cdb0e3402b3de7d78bd644abe Signed-off-by: Damjan Marion <damarion@cisco.com>
2018-03-04vlib: fix vlib_pci_get_device_info on when not running as rootDamjan Marion1-4/+2
While comment properly says that only first 64 bytes can be read, actual code was returning error instead being happy with 64 bytes received. Change-Id: I09c0d1d5c9fc8e1f6c59c093d81bb1ce1924281b Signed-off-by: Damjan Marion <damarion@cisco.com>
2018-02-26vlib: use vfio fd for accessing PCI config spaceDamjan Marion1-32/+29
Change-Id: Id5c76a529ab9969334207790babcdc420a9c58ad Signed-off-by: Damjan Marion <damarion@cisco.com>
2018-02-18vlib: fix pci initDamjan Marion1-2/+1
Change-Id: I2b8c1ad5c594aeca5dc44647ab8f8061362c9284 Signed-off-by: Damjan Marion <damarion@cisco.com>
2018-01-09physmem: fix physmem allocation on kernels without NUMA supportDamjan Marion1-2/+2
Change-Id: I056598a1818a39c2da73e252600c14585e5aae83 Signed-off-by: Damjan Marion <damarion@cisco.com>