Commit Graph

552 Commits

Author SHA1 Message Date
Jan Blunck
bb30369dc1 eal: allow passing const interrupt handle
Both register/unregister and enable/disable don't necessarily require the
rte_intr_handle to be modifiable. Therefore lets constify it.

Signed-off-by: Jan Blunck <jblunck@infradead.org>
2016-12-24 18:45:50 +01:00
Stephen Hemminger
3030127eb2 pci: remove unused unbind support
No device driver sets the unbind flag in current public code base.
Therefore it is good time to remove the unused dead code.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2016-12-21 16:13:46 +01:00
Jerin Jacob
f4ce209a8c eal: postpone vdev initialization
Some platform like octeontx may use pci and
vdev based combined device to represent a logical
dpdk functional device.In such case, postponing the
vdev initialization after pci device
initialization will provide the better view of
the pci device resources in the system in
vdev's probe function, and it allows better
functional subsystem registration in vdev probe
function.

As a bonus, This patch fixes a bond device
initialization use case.

example command to reproduce the issue:
./testpmd -c 0x2  --vdev 'eth_bond0,mode=0,
slave=0000:02:00.0,slave=0000:03:00.0' --
--port-topology=chained

root cause:
In existing case(vdev initialization and then pci
initialization), creates three Ethernet ports with
following port ids
0 - Bond device
1 - PCI device 0
2 - PCI devive 1

Since testpmd, calls the configure/start on all the ports on
start up,it will translate to following illegal setup sequence

1)bond device configure/start
1.1) pci device0 stop/configure/start
1.2) pci device1 stop/configure/start
2)pci device 0 configure(illegal setup case,
as device in start state)

The fix changes the initialization sequence and
allow initialization in following valid setup order
1) pcie device 0 configure/start
2) pcie device 1 configure/start
3) bond device 2 configure/start
3.1) pcie device 0/stop/configure/start
3.2) pcie device 1/stop/configure/start

Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
2016-12-21 15:41:17 +01:00
Robin Jarry
51c0c01b70 kni: avoid using lsb_release script
The lsb_release script is part of an optional package which is not
always installed. On the other hand, /etc/lsb-release is always present
even on minimal Ubuntu installations.

    root@ubuntu1604:~# dpkg -S /etc/lsb-release
    base-files: /etc/lsb-release

Read the file if present and use the variables defined in it.

Signed-off-by: Robin Jarry <robin.jarry@6wind.com>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
2016-12-07 18:36:05 +01:00
Wei Dai
f1d54e6dfb pci: fix check of mknod
In function pci_mknod_uio_dev() in lib/librte_eal/eal/eal_pci_uio.c,
The return value of mknod() is ret, not f got by fopen().
So the value of ret should be checked for mknod().

Fixes: f7f97c1604 ("pci: add option --create-uio-dev to run without hotplug")

Signed-off-by: Wei Dai <wei.dai@intel.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
2016-12-06 11:59:39 +01:00
Ferruh Yigit
6445198f80 kni: fix build with kernel 4.9
compile error:
  CC [M]  .../lib/librte_eal/linuxapp/kni/igb_main.o
.../lib/librte_eal/linuxapp/kni/igb_main.c:2317:21:
error: initialization from incompatible pointer type
	[-Werror=incompatible-pointer-types]
  .ndo_set_vf_vlan = igb_ndo_set_vf_vlan,
                     ^~~~~~~~~~~~~~~~~~~

Linux kernel 4.9 updates API for ndo_set_vf_vlan:
Linux: 79aab093a0b5 ("net: Update API for VF vlan protocol 802.1ad support")

Use new API for Linux kernels >= 4.9

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
Tested-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
2016-10-25 16:20:43 +02:00
Ferruh Yigit
1735110509 kni: fix build with kernel < 3.1
compile error:
  CC [M]  .../lib/librte_eal/linuxapp/kni/kni_misc.o
cc1: warnings being treated as errors
.../lib/librte_eal/linuxapp/kni/kni_misc.c: In function ‘kni_exit_net’:
.../lib/librte_eal/linuxapp/kni/kni_misc.c:113:18:
error: unused variable ‘knet’

For kernel versions < v3.1 mutex_destroy() is a macro and does nothing,
this cause an unused variable warning for knet which used in the
mutex_destroy()

mutex_destroy() converted into static inline function with commit:
Linux: 4582c0a4866e ("mutex: Make mutex_destroy() an inline function")

To fix the warning unused attribute added to the knet variable.

Fixes: 93a298b34e ("kni: support core id parameter in single threaded mode")

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
2016-10-14 22:21:28 +02:00
Ferruh Yigit
473c4957a4 kni: move kernel version ifdefs to compat header
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
2016-10-13 23:12:26 +02:00
Ferruh Yigit
dd6d3570c8 kni: prefer uint32_t to unsigned int
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
2016-10-13 23:12:11 +02:00
Ferruh Yigit
e4728a1cfa kni: update log messages
Remove some function entrance logs and changed log level of some logs.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
2016-10-13 23:12:00 +02:00
Ferruh Yigit
f13fbc033a kni: remove compile time debug configuration
Since switched to kernel dynamic debugging it is possible to remove
compile time debug log configuration.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
2016-10-13 23:11:26 +02:00
Ferruh Yigit
dec1ffcae7 kni: move functions to eliminate declarations
Function implementations kept same.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
2016-10-13 23:11:12 +02:00
Ferruh Yigit
d2d7d6fc5f kni: remove unnecessary messages for out of memory
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
2016-10-13 23:09:12 +02:00
Ferruh Yigit
dd3e4e36d4 kni: update kernel logging
Switch to dynamic logging functions. Depending kernel configuration this
may cause previously visible logs disappear.

How to enable dynamic logging:
https://www.kernel.org/doc/Documentation/dynamic-debug-howto.txt

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
2016-10-13 23:09:02 +02:00
Ferruh Yigit
05788ff054 kni: prefer ether_addr_copy to memcpy
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
2016-10-13 23:08:44 +02:00
Ferruh Yigit
e479813505 kni: prefer min_t to min
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
2016-10-13 23:08:40 +02:00
Ferruh Yigit
88b7a2a7bd kni: enclose macros with complex values in parens
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
2016-10-13 23:08:14 +02:00
Ferruh Yigit
59b36980e4 kni: do not use assignment in if condition
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
2016-10-13 23:08:04 +02:00
Ferruh Yigit
50e25e4049 kni: move trailing statement on next line
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
2016-10-13 23:07:16 +02:00
Ferruh Yigit
fa34b39dfd kni: move comparison constants on the right
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
2016-10-13 23:06:42 +02:00
Ferruh Yigit
e227435ec0 kni: remove useless return
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
2016-10-13 23:06:38 +02:00
Ferruh Yigit
0861751c93 kni: prefer unsigned int to unsigned
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
2016-10-13 23:06:30 +02:00
Ferruh Yigit
1b9190aff3 kni: fix spacing and line lenghts
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
2016-10-13 23:05:31 +02:00
Ferruh Yigit
9afcc5bc74 kni: make static struct const
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
2016-10-13 23:05:28 +02:00
Ferruh Yigit
fbd71b623f kni: uninitialize global variables
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
2016-10-13 23:05:20 +02:00
Ferruh Yigit
f60c4df6bb kni: move externs to the header file
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
2016-10-13 22:49:41 +02:00
Vladyslav Buslov
93a298b34e kni: support core id parameter in single threaded mode
Allow binding KNI thread to specific core in single threaded mode
by setting core_id and force_bind config parameters.

Signed-off-by: Vladyslav Buslov <vladyslav.buslov@harmonicinc.com>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
Tested-by: Ferruh Yigit <ferruh.yigit@intel.com>
2016-10-13 22:24:45 +02:00
John Ousterhout
844bd77c03 log: respect logger configured before EAL init
Before this patch, application-specific loggers could not be
installed before rte_eal_init completed (the initialization process
called rte_openlog_stream, overwriting any previously installed
logger). This made it impossible for an application to capture the
initial log messages generated during rte_eal_init. This patch changes
initialization so that information from a previous call to
rte_openlog_stream is not lost. Specifically:
* The default log stream is now maintained separately from an
  application-specific log stream installed with rte_openlog_stream.
* rte_eal_common_log_init has been renamed to eal_log_set_default,
  since this is all it does. It no longer invokes rte_openlog_stream; it
  just updates the default stream. Also, this method now returns void,
  rather than int, since there are no errors.

This patch also removes the "early log" mechanism and cleans up the
log initialization mechanism:
* The default log stream defaults to stderr on all platforms if
  eal_log_set_default hasn't been invoked (Linux used to use stdout
  during the first part of initialization).
* Removed rte_eal_log_early_init; all of the desired functionality can
  be achieved by calling eal_log_set_default.
* Removed lib/librte_eal/bsdapp/eal/eal_log.c: it contained only one
  function, rte_eal_log_init, which is not needed or invoked for BSD.
* Removed declaration for eal_default_log_stream in rte_log.h (it's now
  private to eal_common_log.c).
* Moved call to rte_eal_log_init earlier in rte_eal_init for Linux, so
  that it starts using the preferrred log ASAP.

Signed-off-by: John Ousterhout <ouster@cs.stanford.edu>
2016-10-13 22:13:18 +02:00
Olivier Matz
11fd19f764 mem: fix build with -O1
When compiled with EXTRA_CFLAGS="-O1", the compiler is not
able to detect that size is always initialized when used, and
issues a wrong warning:

  eal_memory.c: In function ‘rte_eal_hugepage_attach’:
  eal_memory.c:1684:3: error: ‘size’ may be used uninitialized in this
                       function [-Werror=maybe-uninitialized]
     munmap(hp, size);
     ^

Workaround this issue by initializing size to 0.
Seen on gcc (Debian 5.4.1-1) 5.4.1 20160803.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
2016-10-06 15:23:53 +02:00
Ferruh Yigit
094be9925d kni: remove unnecessary ethtool files
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
2016-10-05 15:45:21 +02:00
Ferruh Yigit
7550f1201f kni: remove unused ethtool files
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
2016-10-05 15:45:11 +02:00
Jean Tourrilhes
db8c96c551 mem: fix hugepage mapping error messages
Running secondary is tricky due to the need to map the memory region
at the right place in VM, which is whatever primary has chosen. If the
base address for primary happens to by already mapped in the
secondary, we will hit precisely these error messages (depending if we
fail on the config region or the hugepages). This is why there is
already a comment about ASLR.

The issue is that in most cases, remapping does not happen and "errno"
is not changed and therefore stale. In our case, we got a "permission
denied", which sent us down the wrong track. It's such a common error
for secondary that I feel this error message should be unambiguous and
helpful.
The call to close was also moved because close() may override errno.

Signed-off-by: Jean Tourrilhes <jt@labs.hpe.com>
2016-10-05 11:42:45 +02:00
Jan Viktorin
13a1317d3b pci: create device list and fallback on its members
Now that rte_device is available, drivers can start using its members
(numa, name) as well as link themselves into another rte_device list.

As of now no one is using this list, but can be used for moving over all
devices (pdev/vdev/Xdev) and perform bulk actions (like cleanup).

Signed-off-by: Jan Viktorin <viktorin@rehivetech.com>
[Shreyansh: Reword commit log for extra rte_device list]
Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
Acked-by: David Marchand <david.marchand@6wind.com>
2016-10-03 16:34:03 +02:00
Jan Viktorin
a160404539 eal: extract vdev infra
Move all PMD_VDEV-specific code into a separate module and header
file to not polute the generic code anymore. There is now a list
of virtual devices available.

The rte_vdev_driver integrates the original rte_driver inside
(C inheritance). The rte_driver will be however change in the
future to serve as a common base for all other types of drivers.

The existing PMDs (PMD_VDEV) are to be modified later (there is
no change for them at the moment).

Signed-off-by: Jan Viktorin <viktorin@rehivetech.com>
Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
Acked-by: David Marchand <david.marchand@6wind.com>
2016-10-03 16:33:42 +02:00
David Marchand
e8c528cb92 eal: add hotplug operations for PCI and vdev
Hotplug invocations, which deals with devices, should come from the layer
that already handles them, i.e. EAL.

For both attach and detach operations, 'name' is used to select the bus
that will handle the request.

Signed-off-by: David Marchand <david.marchand@6wind.com>
Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
2016-10-03 16:33:32 +02:00
David Marchand
affe1cdc00 pci: introduce helpers for device name parsing/update
- Move rte_eth_dev_create_unique_device_name() from ether/rte_ethdev.c to
  common/include/rte_pci.h as rte_eal_pci_device_name(). Being a common
  method, can be used across crypto/net PCI PMDs.
- Remove crypto specific routine and fallback to common name function.
- Introduce a eal private Update function for PCI device naming.

Signed-off-by: David Marchand <david.marchand@6wind.com>
[Shreyansh: Merge crypto/pci helper patches]
Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
2016-10-03 16:33:26 +02:00
David Marchand
3c1405b2f1 pci: initialize lists statically
These lists can be initialized once and for all at build time.
With this, those lists are only manipulated in a common place
(and we could even make them private).

A nice side effect is that pci drivers can now register in constructors.

Signed-off-by: David Marchand <david.marchand@6wind.com>
Reviewed-by: Jan Viktorin <viktorin@rehivetech.com>
Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
2016-10-03 16:32:49 +02:00
David Marchand
3071e0aaa8 eal: remove duplicate function declaration
rte_eal_dev_init is declared in both eal_private.h and rte_dev.h since its
introduction.
This function has been exported in ABI, so remove it from eal_private.h

Fixes: e57f20e051 ("eal: make vdev init path generic for both virtual and pci devices")

Signed-off-by: David Marchand <david.marchand@6wind.com>
Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
Reviewed-by: Jan Viktorin <viktorin@rehivetech.com>
2016-10-03 16:32:43 +02:00
Flavio Leitner
4757d06634 eal: move CPU flags check from constructor to init
An application might be linked to DPDK but not really use it,
so move the cpu flag check to the EAL initialization instead.

Signed-off-by: Flavio Leitner <fbl@sysclose.org>
Acked-by: Aaron Conole <aconole@redhat.com>
2016-10-03 16:13:36 +02:00
Maciej Czekaj
c00ae961ff mem: fix crash on hugepage mapping error
In ASLR-enabled system, it is possible that selected
virtual space is occupied by program segments. Therefore,
error path should not blindly unmap all memmory segments
but only those already mapped.

Steps that lead to crash:
1. memeseg 0 in secondary process overlaps with libc.so
2. mmap of /dev/zero fails for virtual space of memseg 0
3. munmap of memseg 0 leads to unmapping libc.so itself
4. app gets SIGSEGV after returning from syscall to libc

Fixes: ea329d7f8e ("mem: fix leak after mapping failure")

Signed-off-by: Maciej Czekaj <maciej.czekaj@caviumnetworks.com>
2016-10-03 16:06:27 +02:00
Yuanhan Liu
016a23a81e mem: remove single file segments
RTE_EAL_SINGLE_FILE_SEGMENTS was introduced with ivshmem integration.
Now that ivshmem was removed (commit c711ccb309)
and a simple git grep shows no one else references it;
I think we can now remove it.

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
2016-10-03 15:20:51 +02:00
Jozef Martiniak
b4d63fb622 eal: customize delay function
When running single-core, some drivers tend to call rte_delay_us for a
long time, and that is causing packet drops.
To avoid this, rte_delay_us can be replaced with user-defined delay
function with:

void rte_delay_us_callback_register(void(*userfunc)(unsigned));

When userfunc==rte_delay_us_block build-in blocking delay function is
restored.

Signed-off-by: Jozef Martiniak <jozmarti@cisco.com>
2016-09-26 14:48:42 +02:00
Ferruh Yigit
6bbfb64b4e kni: fix large stack frame size
Compile error:
.../lib/librte_eal/linuxapp/kni/kni_net.c:
In function ‘kni_net_rx_lo_fifo’:
.../lib/librte_eal/linuxapp/kni/kni_net.c:331:1:
error: the frame size of 1056 bytes is larger than 1024 bytes
[-Werror=frame-larger-than=]

This compile error seen with some compiler / kernel combinations.

Moved some local variables to the kni_dev struct.

Fixes: 8451269e6d ("kni: remove continuous memory restriction")

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
2016-09-22 17:46:39 +02:00
Ferruh Yigit
8451269e6d kni: remove continuous memory restriction
Use mempool buf_addr and buf_physaddr fields for address translation.

Since each mbuf address calculated separately, the restriction of all
mbufs should come from a continuous memory restriction is no more valid.

mbuf related FIFO's content changed, rx_q and alloc_q now carries
physical address of mbufs. tx_q and free_q content not changed, they
still carries virtual address of mbufs.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
2016-09-21 19:18:44 +02:00
Yangchao Zhou
f503b8cff5 kni: fix error rollback kernel crash
Fixes: 9c61145ff6 ("kni: allow multiple threads")

Signed-off-by: Yangchao Zhou <zhouyates@gmail.com>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
2016-09-21 18:36:23 +02:00
Ferruh Yigit
7f5565592c kni: fix build with kernel 4.8
Linux kernel v4.8 removes macro DEFINE_PCI_DEVICE_TABLE

Linux: 7e9321599011 ("treewide: remove references to the now unnecessary
DEFINE_PCI_DEVICE_TABLE")

Replaced macro with its value in kni ethtool drivers.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
2016-09-21 18:15:18 +02:00
Ferruh Yigit
ac11f6e84a kni: fix build with kernel < 3.0
Compile error:
  CC [M]  .../build/lib/librte_eal/linuxapp/kni/igb_main.o
.../build/lib/librte_eal/linuxapp/kni/igb_main.c:
In function ‘igb_check_swap_media’:
.../build/lib/librte_eal/linuxapp/kni/igb_main.c:1556:7:
error: variable ‘link’ set but not used [-Werror=unused-but-set-variable]
  bool link;
       ^

With Linux kernel >= v3.0 this warning disabled:
Linux: 8417da6f2128 ("kbuild: Fix passing -Wno-* options to gcc 4.4+")

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
2016-09-21 18:14:34 +02:00
Pablo de Lara
e30a0178d2 kni: support RHEL 7.3
Add support for RHEL 7.3, which uses kernel 3.10,
but backported features from newer kernels.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
2016-09-21 18:10:15 +02:00
Ferruh Yigit
d12bb41359 kni: fix debug build
Fix build error with Linux kernel >= v4.7

Fix compile error because of Linux API change, 'trans_start' field
removed from 'struct net_device'.

Linux: 9b36627acecd ("net: remove dev->trans_start")

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
2016-09-21 18:06:08 +02:00
Robin Jarry
da5d107207 mem: use more restrictive permissions on hugepages
There is no need for the page files to be readable (and executable) by
other users. This can be exploited by non-privileged users to access the
working memory of a DPDK app.

Open the files with 0600.

Signed-off-by: Robin Jarry <robin.jarry@6wind.com>
2016-09-16 14:51:27 +02:00