aboutsummaryrefslogtreecommitdiffstats
path: root/src/vlib/linux
AgeCommit message (Collapse)AuthorFilesLines
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>
2017-12-14pci: auto-detect right vfio/uio driverDamjan Marion1-0/+55
Change-Id: Ib4012ff598698924484525932d041988cc4c63f6 Signed-off-by: Damjan Marion <damarion@cisco.com>
2017-12-13physmem: fix bug in detection of cross page boundary allocationsDamjan Marion1-2/+2
Change-Id: I18e9227565243bce7d4102b1950eec9e019a097a Signed-off-by: Damjan Marion <damarion@cisco.com>
2017-12-10vlib: fix issues in the new pci code reported by coverityDamjan Marion1-6/+12
Change-Id: I8acc5c419b6ad01937c3aecec42801463d4a119a Signed-off-by: Damjan Marion <damarion@cisco.com>
2017-12-09vlib: PCI rework to support VFIODamjan Marion1-272/+646
Also fixes old ixge driver, so it works with recent physmem changes and vfio. Change-Id: Id4be74b34daed47cd281a77eec43d6692340d882 Signed-off-by: Damjan Marion <damarion@cisco.com>
2017-10-31physmem: register region with IOMMUDamjan Marion1-0/+57
VFIO file descriptor is extracted in a hackish way, as DPDK doesn't provide imethod to retrieve it. This fixes issue with DPDK drivers not working correctly when IOMMU is enabled and external buffer memory is used. Change-Id: I5eaa8e78741c50504d87d44e706b5997c8189554 Signed-off-by: Damjan Marion <damarion@cisco.com>
2017-10-25vlib: add support for multiple buffer poolsDamjan Marion1-5/+0
Change-Id: Icaf7d7ad47284aea7a56e8006b69f45874d64202 Signed-off-by: Damjan Marion <damarion@cisco.com>
2017-09-18Fixes for issues Coverity has reported (VPP-972)Chris Luke1-1/+1
177117: fstat() returns -1 on error; the code is checking for any positive value instead 175142: final return could never be reached; simple refactoring 175235,175236: Warning suppressed with an explicit cast to (void) 174817: Final return couldn't be reached; is is_in_order is 0 then 'rv' is already returned above 172095,172093: If is_is_set does not get set to 1, then return 0 has already been invoked 174405: Re-kill this (nothing sets rv) 171136: Looks like a cmd line flag to set test_bytes was missing; added it, and refactored the argc/argv processing to avoid two other potential segv's 176813: Add range checking for term width/height. First stab at a reasonable range is 1-512 for both. 175350: Fix implicit casting in shift operation 174272: Not a c+p error; try using a coverity annotation to ignore it 174273,175320: Annotated FORWARD_NULL Change-Id: I58d0f860fc2209f59f8d1b6b344d631b8d429ace Signed-off-by: Chris Luke <chrisy@flirble.org>