Commit Graph

128 Commits

Author SHA1 Message Date
Bruce Richardson
6c9457c279 build: replace license text with SPDX tag
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Reviewed-by: Luca Boccassi <bluca@debian.org>
2018-01-30 21:58:59 +01:00
Bruce Richardson
1842d194c9 examples: enable linking both static and shared
Since the DPDK build now includes both static and shared libraries, we need
a new way to enable building the examples using either method from the one
installation. To do this, we add in a default "shared" target, and a
separate "static" target which links in the DPDK static libraries. In both
cases, the final application name is symlinked to the last-built static or
shared target, with both binaries able to co-exist in the build directory.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Luca Boccassi <bluca@debian.org>
2018-01-30 21:58:59 +01:00
Bruce Richardson
22119c4591 examples: use pkg-config in makefiles
Change the example app Makefiles to query if DPDK is installed and
registered using pkg-config. If so, build directly using pkg-config info,
otherwise fall back to using the original build system with RTE_SDK and
RTE_TARGET

This commit changes the makefiles for the basic examples, i.e. those which
do not have multiple subdirectories underneath the main examples dir.
Examples not covered are:

* ethtool
* multi_process
* performance-thread
* quota_watermark
* netmap_compat
* server_node_efd
* vm_power_manager

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Reviewed-by: Luca Boccassi <bluca@debian.org>
2018-01-30 21:58:59 +01:00
Bruce Richardson
0eba4ade65 examples: put app name and sources at top of makefiles
Reorder the text in the makefiles, so that the app name and the source
files are listed first. This then will allow them to be shared later in a
combined makefile building with pkg-config and RTE_SDK-based build system.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Reviewed-by: Luca Boccassi <bluca@debian.org>
2018-01-30 21:58:59 +01:00
Bruce Richardson
89f0711f9d examples: build some samples with meson
Add support for having selected example apps built as part of a meson,
ninja build. By default none are built, and those to be built should be
named directly in the -Dexamples='' meson configuration argument.

This is useful for developers working on a feature who want to use a
suitable example, or examples, to test that feature, as they can compile
everything up in one go, and run the example without having to do a ninja
install first.

This commit adds examples which don't consist of multiple apps in
subdirectories to the meson build, so they can be built by default by
passing -Dexamples parameter to meson.

Not included are the following examples:
* ethtool
* multi-process
* netmap_compat
* performance-thread
* quota_watermark
* server_node_efd
* vm_power_manager

To test the apps added here, use the following command, merged to one line,
to add them to your meson build (command to be run inside the build
directory):

meson configure -Dexamples=bbdev_app,bond,cmdline,distributor,\
	eventdev_pipeline_sw_pmd, exception_path,helloworld,\
	ip_fragmentation,ip_pipeline,ip_reassembly, ipsec-secgw,\
	ipv4_multicast,kni,l2fwd-cat,l2fwd-crypto,l2fwd-jobstats,\
	l2fwd-keepalive,l2fwd,l3fwd-acl,l3fwd-power,l3fwd-vf,l3fwd,\
	link_status_interrupt,load_balancer,packet_ordering,ptpclient,\
	qos_meter,qos_sched,rxtx_callbacks,skeleton,tep_termination,\
	timer,vhost,vhost_scsi,vmdq,vmdq_dcb

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Reviewed-by: Luca Boccassi <bluca@debian.org>
2018-01-30 21:58:59 +01:00
Shahaf Shuler
cc22d8cae0 examples/vhost: convert to new ethdev offloads API
Ethdev offloads API has changed since:

commit ce17eddefc ("ethdev: introduce Rx queue offloads API")
commit cba7f53b71 ("ethdev: introduce Tx queue offloads API")

This commit support the new API.

Signed-off-by: Shahaf Shuler <shahafs@mellanox.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
2018-01-16 18:47:49 +01:00
Zhiyong Yang
61e99293f6 examples/vhost: fix startup check
For vhost sample, the operation if (dev_info.max_rx_queues >
MAX_QUEUES) in the function port_init causes startup failure
when using X710(i40e driver). X710 requires that MAX_QUEUES
should be defined no less than 320, however it is defined as
128 currently.

Such checking is overkill and Removal don't affect any
functionality (have already validated ixgbe and i40e).

The removal can avoid similar issue when introduing new physical NIC.

Fixes: 8bd6c395a5 ("examples/vhost: increase maximum queue number")
Cc: stable@dpdk.org

Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>
Acked-by: Yuanhan Liu <yliu@fridaylinux.org>
2018-01-16 18:47:49 +01:00
Junjie Chen
a3fdb53270 examples/vhost: fix sending ARP packet to self
ARP packets are not dropped when dest vdev is itself, which breaks
RX ring inconspicuously.

Fixes: 9c5ef51207 ("examples/vhost: handle broadcast packet")
Cc: stable@dpdk.org

Signed-off-by: Junjie Chen <junjie.j.chen@intel.com>
Acked-by: Yuanhan Liu <yliu@fridaylinux.org>
2018-01-16 18:47:49 +01:00
Stefan Hajnoczi
6c299bb732 vhost: introduce vring call API
Users of librte_vhost currently implement the vring call operation
themselves.  Each caller performs the operation slightly differently.

This patch introduces a new librte_vhost API called
rte_vhost_vring_call() that performs the operation so that vhost-user
applications don't have to duplicate it.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Acked-by: Yuanhan Liu <yliu@fridaylinux.org>
2018-01-16 18:47:49 +01:00
Bruce Richardson
3998e2a072 examples: use SPDX tag for Intel copyright files
Replace the BSD license header with the SPDX tag for files
with only an Intel copyright on them.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
2018-01-04 22:41:39 +01:00
Zhiyong Yang
f8244c6399 ethdev: increase port id range
Extend port_id definition from uint8_t to uint16_t in lib and drivers
data structures, specifically rte_eth_dev_data. Modify the APIs,
drivers and app using port_id at the same time.

Fix some checkpatch issues from the original code and remove some
unnecessary cast operations.

release_17_11 and deprecation docs have been updated in this patch.

Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>
Acked-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
2017-10-06 18:23:25 +02:00
Roman Zhukov
60efb44f73 examples: adjust Rx and Tx descriptors to device limits
Signed-off-by: Roman Zhukov <roman.zhukov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
2017-07-08 18:47:00 +02:00
Jerin Jacob
577329e66b eal: switch to architecture specific pause function
Remove rte_pause() definition from rte_common.h and
switchover to architecture specific rte_pause.h

Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
2017-07-03 23:58:51 +02:00
Jerin Jacob
98a7ea332b fix typos using codespell utility
Fixing typos across dpdk source code using codespell utility.
Skipped the ethdev driver's base code fixes to keep the base
code intact.

Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
Acked-by: John McNamara <john.mcnamara@intel.com>
2017-06-14 23:54:13 +02:00
Jerin Jacob
c0583d98a9 eal: introduce macro for always inline
Different drivers use internal macros like force_inline for compiler
always inline feature.
Standardizing it through __rte_always_inline macro.

Verified the change by comparing the output binary file.
No difference found in the output binary file with this change.

Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
2017-06-06 17:21:55 +02:00
Jerin Jacob
62a0e941b5 examples/vhost: fix uninitialized descriptor indexes
Fixing the below error by returning from the function early
when count == 0.

Issue flagged by GCC 7.1.1

examples/vhost/virtio_net.c:370:38: error: ‘desc_indexes[0]’ may be used
uninitialized in this function [-Werror=maybe-uninitialized]
  rte_prefetch0(&vr->desc[desc_indexes[0]]);

Fixes: ca059fa5e2 ("examples/vhost: demonstrate the new generic APIs")
Cc: stable@dpdk.org

Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
2017-06-05 14:28:32 +02:00
Gang Jiang
fa81d3b970 examples/vhost: fix socket path parsing
The return value of strnlen(s, maxlen) is never bigger than maxlen.

Fixes: 4796ad63ba ("examples/vhost: import userspace vhost application")

Signed-off-by: Gang Jiang <jiangg@mail.ustc.edu.cn>
2017-05-10 19:05:59 +02:00
Jeff Guo
60da774e6e examples: enable HW CRC strip by default
Since VF can not disable/enable HW CRC strip for non-DPDK PF drivers,
and kernel driver almost default enable that feature, if disable it in
example app's rxmode, VF driver will report the VF launch failure. So
this patch default to enable HW CRC strip to let VF launch successful.

Cc: stable@dpdk.org

Signed-off-by: Jeff Guo <jia.guo@intel.com>
Acked-by: Jingjing Wu <jingjing.wu@intel.com>
2017-04-10 22:36:37 +02:00
Yuanhan Liu
ca059fa5e2 examples/vhost: demonstrate the new generic APIs
Now DPDK vhost lib has been generic enough, that it can be used to
implement any vhost-user drivers.

For example, this patch implements a very simple vhost-user net driver,
mainly for demonstrating how to use those generic vhost APIs.

And when the --builtin-net-driver option is used, the example virtio-net
driver code will be invoked, instead of the one provided from the vhost
library.

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
2017-04-01 10:49:47 +02:00
Yuanhan Liu
a798beb47c vhost: rename header file
Rename "rte_virtio_net.h" to "rte_vhost.h", to not let it be virtio
net specific.

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
2017-04-01 10:42:44 +02:00
Yuanhan Liu
af14759181 vhost: introduce API to start a specific driver
We used to use rte_vhost_driver_session_start() to trigger the vhost-user
session. It takes no argument, thus it's a global trigger. And it could
be problematic.

The issue is, currently, rte_vhost_driver_register(path, flags) actually
tries to put it into the session loop (by fdset_add). However, it needs
a set of APIs to set a vhost-user driver properly:
  * rte_vhost_driver_register(path, flags);
  * rte_vhost_driver_set_features(path, features);
  * rte_vhost_driver_callback_register(path, vhost_device_ops);

If a new vhost-user driver is registered after the trigger (think OVS-DPDK
that could add a port dynamically from cmdline), the current code will
effectively starts the session for the new driver just after the first
API rte_vhost_driver_register() is invoked, leaving later calls taking
no effect at all.

To handle the case properly, this patch introduce a new API,
rte_vhost_driver_start(path), to trigger a specific vhost-user driver.
To do that, the rte_vhost_driver_register(path, flags) is simplified
to create the socket only and let rte_vhost_driver_start(path) to
actually put it into the session loop.

Meanwhile, the rte_vhost_driver_session_start is removed: we could hide
the session thread internally (create the thread if it has not been
created). This would also simplify the application.

NOTE: the API order in prog guide is slightly adjusted for showing the
correct invoke order.

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
2017-04-01 10:42:44 +02:00
Yuanhan Liu
7c12903746 vhost: rename device ops struct
rename "virtio_net_device_ops" to "vhost_device_ops", to not let it
be virtio-net specific.

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
2017-04-01 10:42:44 +02:00
Yuanhan Liu
aca49772f6 vhost: do not include net specific headers
Include it internally, at vhost.h.

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
2017-04-01 10:42:44 +02:00
Yuanhan Liu
f53cf83980 vhost: drop the Rx and Tx queue macro
They are virtio-net specific and should be defined inside the virtio-net
driver.

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
2017-04-01 10:42:44 +02:00
Yuanhan Liu
93433b639d vhost: make notify ops per vhost driver
Assume there is an application both support vhost-user net and
vhost-user scsi, the callback should be different. Making notify
ops per vhost driver allow application define different set of
callbacks for different driver.

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
2017-04-01 10:40:13 +02:00
Yuanhan Liu
0917f9d1f0 vhost: use new APIs to handle features
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
2017-04-01 10:40:13 +02:00
Yong Wang
b3bee7d87d examples/vhost: fix lcore initialization
when "TAILQ_INIT()" was added to the loop of "for (lcore_id = 0; ...)"
statement, the assignment to "lcore_ids" was removed out of the loop.
It changed the original initialization of "lcore_ids".

Fix it by introducing two braces.

Fixes: 45657a5c68 ("examples/vhost: use tailq to link vhost devices")
Cc: stable@dpdk.org

Signed-off-by: Yong Wang <wang.yong19@zte.com.cn>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
2017-01-17 09:20:18 +01:00
Yong Wang
12ee45a362 examples/vhost: fix calculation of mbuf count
When calculating 'nr_mbufs_per_core', 'MAX_PKT_BURST' was mutiplied
twice. Fix it by removing one of them.

Fixes: bdb19b771e ("examples/vhost: fix mbuf allocation failure")
Cc: stable@dpdk.org

Signed-off-by: Yong Wang <wang.yong19@zte.com.cn>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
2017-01-17 09:20:18 +01:00
Olivier Matz
5d8f0baf69 log: do not drop debug logs at compile time
Today, all logs whose level is lower than INFO are dropped at
compile-time. This prevents from enabling debug logs at runtime using
--log-level=8.

The rationale was to remove debug logs from the data path at
compile-time, avoiding a test at run-time.

This patch changes the behavior of RTE_LOG() to avoid the compile-time
optimization, and introduces the RTE_LOG_DP() macro that has the same
behavior than the previous RTE_LOG(), for the rare cases where debug
logs are in the data path.

So it is now possible to enable debug logs at run-time by just
specifying --log-level=8. Some drivers still have special compile-time
options to enable more debug log. Maintainers may consider to
remove/reduce them.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
2016-12-01 18:09:13 +01:00
Yuanhan Liu
164a601b52 vhost: remove references to vhost-cuse
vhost-cuse is removed, update corresponding comments that are still
referencing it.

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: John McNamara <john.mcnamara@intel.com>
2016-11-07 15:59:21 +01:00
Yuanhan Liu
00b8b70666 examples/vhost: add --dequeue-zero-copy option
Add an option, --dequeue-zero-copy, to enable dequeue zero copy.

One thing worth noting while using dequeue zero copy is the nb_tx_desc
has to be small enough so that the eth driver will hit the mbuf free
threshold easily and thus free mbuf more frequently.

The reason behind that is, when dequeue zero copy is enabled, guest Tx
used vring will be updated only when corresponding mbuf is freed. If mbuf
is not freed frequently, the guest Tx vring could be starved.

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Tested-by: Qian Xu <qian.q.xu@intel.com>
2016-10-13 10:29:31 +02:00
Jianfeng Tan
6545392887 examples/vhost: remove VLAN strip option
When VMDQ is enabled, different NICs have different behaviors for
disabling VLAN strip. In detail, i40e only enables/disables it of
PF's main vsi; fm10k cannot disable VLAN strip, etc. We now remove
this option, --vlan-strip, to reduce any confusion. And now, VLAN
strip will be enabled and cannot be disabled.

Reported-by: Qian Xu <qian.q.xu@intel.com>
Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
2016-09-13 05:25:08 +02:00
Jiayu Hu
ad0eef4d22 examples/vhost: support multiple socket files
When examples/vhost runs in client mode, only one QEMU can be connected.
This is because that examples/vhost just supports one socket file. This
patch is to add multiple sockets support for examples/vhost.

Signed-off-by: Jiayu Hu <jiayu.hu@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
2016-09-13 05:25:08 +02:00
Jiayu Hu
bde19a4d4b examples/vhost: rename --dev-basename to --socket-file
In examples/vhost, "dev-basename" is a program option, which is to set
the vhost-net socket used by vhost-user, or the character device used
by vhost-cuse. Since vhost-cuse should be dropped, and "dev-basename"
is not a suitable name for the vhost-net socket. Therefore, this patch
is to change this option name for examples/vhost.

Signed-off-by: Jiayu Hu <jiayu.hu@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
2016-09-13 05:25:08 +02:00
Jianfeng Tan
56c9ff8e3e examples/vhost: fix performance
We find significant perfermance drop introduced by below commit,
when vhost example is started with --mergeable 0 and inside vm,
kernel virtio-net driver is used to do ip based forwarding.

The commit, 859b480d5a ("vhost: add guest offload setting"), adds
support for VIRTIO_NET_F_GUEST_TSO4 and VIRTIO_NET_F_GUEST_TSO6,
in vhost lib. But inside vhost example, the way to disable tso only
excludes the direction from virtio to vhost, but not the opposite
direction. When mergeable is disabled, it triggers big_packets path
of virtio-net driver to prepare to receive possible big packets with
size of 64K. Because mergeable is off, for each entry of avail ring,
virtio driver uses 19 desc chained together, with one desc pointing
to header, other 18 desc pointing to 4K-sized pages. But QEMU only
creates 256 desc entries for each vq, which results in that only 13
packets can be received. VM kernel can quickly handle those packets
and go to sleep (HLT).

As QEMU has no option to set the desc entries of a vq, so here,
we disable VIRTIO_NET_F_GUEST_TSO4 and VIRTIO_NET_F_GUEST_TSO6
with VIRTIO_NET_F_HOST_TSO4 and VIRTIO_NET_F_HOST_TSO6 when we
disable tso of vhost example, to avoid VM kernel virtio driver
go into big_packets path.

Fixes: 9fd72e3cbd ("examples/vhost: add virtio offload")

Reported-by: Qian Xu <qian.q.xu@intel.com>
Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
Tested-by: Qian Xu <qian.q.xu@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
2016-07-22 12:40:26 +02:00
Jianfeng Tan
bb7085b46a examples/vhost: print error logs on failure
When the specified cores and memory lie on different NUMA socket with
physical NIC, vhost fails to set up Rx queue, and exits without any
hints. This could leads to confusion of users.

This patch fixes it by adding some error messages when calling ether
APIs returns errors.

Suggested-by: Yulong Pei <yulong.pei@intel.com>
Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
2016-07-11 04:57:15 +02:00
Yuanhan Liu
2345e3be86 examples/vhost: add client option
Add --client option to let vhost-switch acts as the client.

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
2016-06-22 09:47:12 +02:00
Yuanhan Liu
64ab701c3d vhost: add vhost-user client mode
Add a new paramter (flags) to rte_vhost_driver_register(). DPDK
vhost-user acts as client mode when RTE_VHOST_USER_CLIENT flag
is set.  The flags would also allow future extensions without
breaking the API (again).

The rest is straingfoward then: allocate a unix socket, and
bind/listen for server, connect for client.

This extension is for vhost-user only, therefore we simply quit
and report error when any flags are given for vhost-cuse.

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
2016-06-22 09:47:07 +02:00
Yuanhan Liu
4ecf22e356 vhost: export device id as the interface to applications
With all the previous prepare works, we are just one step away from
the final ABI refactoring. That is, to change current API to let them
stick to vid instead of the old virtio_net dev.

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
2016-06-22 09:42:57 +02:00
Yuanhan Liu
16ae8abe1c vhost: remove dependency on device private field
This change could let us avoid the dependency of "virtio_net"
struct, to prepare for the ABI refactoring.

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
2016-06-22 09:07:36 +02:00
Yuanhan Liu
a67f286a65 vhost: export queue free entries
The new API rte_vhost_avail_entries() is actually a rename of
rte_vring_available_entries(), with the "vring" to "vhost" name
change to keep the consistency of other vhost exported APIs.

This change could let us avoid the dependency of "virtio_net"
struct, to prepare for the ABI refactoring.

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
2016-06-22 09:02:58 +02:00
Yuanhan Liu
e2a1dd1275 vhost: rename device id variable
I failed to figure out what does "fh" mean here for a long while.
The only guess I could have had is "file handle". So, you get the
point that it's not well named.

I then figured it out that "fh" is derived from the fuse lib, and
my above guess is right. However, device_fh represents a virtio
net device ID. Therefore, here I rename it to vid (Virtio-net device
ID, or Vhost device ID; choose one you prefer) to make it easier for
understanding.

This name (vid) then will be considered to the only interface to
applications. That's another reason to do the rename: it's our
interface, make it more understandable.

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
2016-06-22 09:01:25 +02:00
Yuanhan Liu
7f262239ab examples/vhost: make a copy of virtio device id
Make a copy of virtio device id (device_fh) from the virtio_net struct,
so that we could have less dependency on the virtio_net struct.

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
2016-06-22 09:00:00 +02:00
Yuanhan Liu
c08a349006 vhost: declare device id as int
device_fh repsents the device id for a specific virtio net device.
Firstly, "int" would be big enough: we don't need 64 bit. Secondly,
this could let us avoid the ugly "%" PRIu64 ".." stuff.

And since ctx.fh is derived from device_fh, declare it as int, too.

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
2016-06-22 08:59:54 +02:00
Yuanhan Liu
550c9d27d1 vhost: set/reset device flags internally
It does not make sense to ask the application to set/unset the flag
VIRTIO_DEV_RUNNING (that used internal only) at new_device()/
destroy_device() callback.

Instead, it should be set after new_device() succeeds and reset before
destroy_device() is invoked inside vhost lib. This patch fixes it.

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Tested-by: Rich Lane <rich.lane@bigswitch.com>
Acked-by: Rich Lane <rich.lane@bigswitch.com>
2016-06-22 06:10:54 +02:00
Yuanhan Liu
97daf19e99 examples/vhost: fix corrupted vdev tailq list
There are two tailq lists, one for logging all vhost devices, another
one for logging vhost devices distributed on a specific core. However,
there is just one tailq entry, named "next", to chain the two list,
which is wrong and could result to a corrupted tailq list, that the
tailq list might always be non-empty: the entry is still there even
after you have invoked TAILQ_REMOVE several times.

Fix it by introducing two tailq entries, one for each list.

Fixes: 45657a5c68 ("examples/vhost: use tailq to link vhost devices")

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
2016-06-22 06:10:54 +02:00
Thomas Monjalon
3901ed99c2 eal: fix thread naming on FreeBSD
rte_thread_setname was a macro defined only for Linux.
The function rte_thread_setname() can now be used on FreeBSD
as well on Linux.
It is required to build librte_pdump.

The macro was 0 for old glibc. The function is now returning -1.
The related logs are decreased from error to debug level because
it is not an important failure, just a debug inconvenience.

Fixes: 278f945402 ("pdump: add new library for packet capture")

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Acked-by: David Marchand <david.marchand@6wind.com>
2016-06-17 18:04:22 +02:00
Mauricio Vasquez B
b4e0f64ff2 examples: remove useless check of port count
The rte_eth_dev_count() function will never return a value greater
than RTE_MAX_ETHPORTS, so that checking is useless.

Signed-off-by: Mauricio Vasquez B <mauricio.vasquezbernal@studenti.polito.it>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
2016-05-16 21:01:51 +02:00
Yuanhan Liu
56fe86f8dc examples/vhost: embed statistics into device structure
Embed dev_statistics into vhost_dev struct, which could clean
the code a bit.

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
2016-05-10 20:22:40 +02:00
Yuanhan Liu
273ecdbc06 examples/vhost: clean switch worker
switch_worker() is the last piece of code that is messy yet it touches
virtio/vhost device.

Here do a cleanup, so that we will be less painful for later vhost ABI
refactoring.

The cleanup is straight forward: break long lines, move some code into
functions. The last, comment a bit on switch_worker().

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
2016-05-10 20:22:40 +02:00