Commit Graph

77 Commits

Author SHA1 Message Date
Avi Kivity
3aec580cbe Add L3 test
Listen for ARP packets and print something out when we see them.
2014-08-31 13:29:54 +03:00
Avi Kivity
4baf051763 net: add support for dispatching packets to L3 protocol handlers 2014-08-31 13:29:14 +03:00
Avi Kivity
607b3af7e6 net: add more helpers for playing with packets
trim_front() - remove a prefix from a packet
get_header() - linearize and return a section of a packet for direct access
2014-08-31 13:26:11 +03:00
Avi Kivity
28d50bbc7a net: define a type for ethernet_address 2014-08-31 13:23:10 +03:00
Avi Kivity
9f5c0dbf59 ip: improve endianness adjustment
Rather than hacking around the inability to bind references to unaligned
scalars, wrap them in a struct (which can then be marked as unaligned),
and use the wrapped values everywhere.  This ensures the code works on
platforms that need special instructions for unaligned access.

Adjust the forwarding functions to require references; passing by value
accidentally can lose the conversion.
2014-08-28 23:16:48 +03:00
Avi Kivity
00b462ef67 ip: fix checksum for odd-sized packets 2014-08-28 20:40:48 +03:00
Avi Kivity
71bef72332 virtio: correctly prepend net_hdr before transmitting packet
Instead of assuming there is room for a header in front of the packet, use
the packet prepending constructor to check for it and allocate it if missing.

This requires splitting the waiting into two parts: first acquiring the
packet, and only then, when we know how many fragments it has, waiting
for virtio dscriptors.  It also requires that we prepare a full buffer_chain
rather than one with exactly one fragment.
2014-08-28 20:07:36 +03:00
Avi Kivity
b89787eeda virtio: fix multi-buffer request
Set 'has_prev' after the first (really last) buffer.
2014-08-28 20:07:36 +03:00
Avi Kivity
859c99971c virtio: introduce net_hdr structure
Used by virtio to control offload.
2014-08-28 20:07:36 +03:00
Avi Kivity
82489025a1 net: don't forget to copy data when prepending a fragment to a packet 2014-08-28 20:07:36 +03:00
Avi Kivity
9e7dd74bfa net: fix build in debug mode due to missing static variable 2014-08-28 20:07:36 +03:00
Avi Kivity
a7930ffcaa net: rework packet class
1. Replace the completion promise<> with a custom deleter class; this
   is lighter weight, and we don't really need the destructor to be
   executed by the scheduler.
2. Add lots of consuctors for composing packets from existing packet,
   by appending or prepending packets
3. Over-allocate in some cases to accomodate for the common practice of
   prepending protocol headers.
2014-08-28 17:29:27 +03:00
Avi Kivity
e697091201 build: link with libtcmalloc
~14% improvement.
2014-08-27 20:25:53 +03:00
Tomasz Grabiec
9813207ed2 build: fix the build on Ubuntu
The build fails for me like this:

/tmp/ccOUUuiH.ltrans0.ltrans.o: In function `reactor::reactor()':
/home/tgrabiec/src/seastar/build/release/../../reactor.cc:41: undefined reference to `io_setup'
/tmp/ccOUUuiH.ltrans1.ltrans.o: In function `reactor::process_io()':
/home/tgrabiec/src/seastar/build/release/../../reactor.cc:133: undefined reference to `io_getevents'
collect2: error: ld returned 1 exit status
../../build.mk:27: recipe for target 'seastar' failed

The workaround was taken from
https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/1228201

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
[avi: move to separate line with comment to justify the ugliness]
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
2014-08-27 19:56:25 +03:00
Avi Kivity
b957650a03 build: simplify link rules 2014-08-27 19:17:03 +03:00
Avi Kivity
64c8302f39 Move more posix functions to posix.hh
This simplifies checking for errors, especially in constructors.
2014-08-27 18:26:54 +03:00
Avi Kivity
268d24170d Make posix.hh independent of reactor.hh
Move throw_system_error_on() and friends into it.
2014-08-27 17:37:10 +03:00
Tomasz Grabiec
34667e8dfe reactor: fix io_setup() failure
_io_context must be set to 0, otherwise io_setup fails with -EINVAL.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
2014-08-27 17:32:39 +03:00
Avi Kivity
462a285dc1 Add simple virtio test
Able to reply to broadcase ping (ping -b 192.168.122.2)
2014-08-27 17:25:42 +03:00
Avi Kivity
67952a24d4 Add IPv4 definitions and helpers 2014-08-27 17:25:19 +03:00
Avi Kivity
bdd0125116 build: don't unconditionally build with -flto
mode=release will do it itself.
2014-08-27 17:24:29 +03:00
Avi Kivity
888298778a build: pass mode to sub-make 2014-08-27 17:24:17 +03:00
Avi Kivity
5b27163071 Add rudimentary virtio support
Supported:
 - basic virtio ring pump
 - basic virtio-net driver (most features missing)
 - vhost interface (running as a privileged user process, not guest)
2014-08-27 17:22:13 +03:00
Avi Kivity
6b265e9c33 Add network stack interface definitions 2014-08-27 17:21:41 +03:00
Avi Kivity
85e3645866 Extend semaphore with try_wait() 2014-08-27 17:21:12 +03:00
Avi Kivity
1cfa018243 Add helper for creating structures ending with variable-length arrays 2014-08-27 17:20:34 +03:00
Avi Kivity
90b766db2e Add C++ wrappers of common posix functionality 2014-08-27 17:20:06 +03:00
Avi Kivity
344a4fe4bc Add Linux virtio interface definitions
The Linux virtio/vhost headers are too polluted to be included from C++
code, so create a local copy.
2014-08-27 17:18:38 +03:00
Avi Kivity
68a66b3c14 Add .gitignore 2014-08-25 09:28:55 +03:00
Avi Kivity
f7da882a40 build: generate objects in build directory 2014-08-25 09:26:53 +03:00
Avi Kivity
53dcf701b9 Encapsulate eventfd into classes
Typically one side (read or write) of the eventfd is used within the
framework, and the other side is used by an external process, so two
classes are provided, depending on which side is used in the framework.

The new classes are used with the thread pool.
2014-08-24 19:44:52 +03:00
Avi Kivity
745a420aea Move pollable_fd around for later reuse 2014-08-24 19:44:22 +03:00
Avi Kivity
7899894643 httpd: handle errors 2014-08-24 18:08:38 +03:00
Avi Kivity
547756ce95 Exception handling support
- If a .then() clause, whose chained function returns a future, throws an
  exception, then the returned future will contain the exception.  A chain
  of .then() clauses will propagae the exception until the end.
- Add a .rescue() clause that can be used to catch the exception
2014-08-24 15:52:18 +03:00
Avi Kivity
fedb0d787f fileiotest: flush after completing the test 2014-08-24 11:05:05 +03:00
Avi Kivity
754a245d59 Implement file::flush() 2014-08-24 11:04:59 +03:00
Avi Kivity
2bec091b9e Fix future chaining with 0-argument futures 2014-08-24 11:04:42 +03:00
Avi Kivity
3f1c383e46 Fix is_future<> for non-single-argument futures
is_future<> did not support zero-argument (future<>) and multiple argument
futures.
2014-08-24 11:03:27 +03:00
Avi Kivity
239f76c342 Implement open_file_dma() using the thread pool 2014-08-24 10:42:12 +03:00
Avi Kivity
ebd10bf349 Add a thread pool to augment kernel support for aio
Some operations cannot be done either non-blockingly or asynchronously, so
add a thread pool to execute them in.

Currently the thread pool has just one thread.
2014-08-24 10:42:10 +03:00
Avi Kivity
7f609a1959 fileiotest: limit concurrency
Otherwise, all of the writes are submitted at once, consuming tons of memory,
and preventing reads from happening in parallel to writes.

Add a semaphore to limit the amount of parallel I/O.
2014-08-24 10:30:54 +03:00
Avi Kivity
91f10b8a9c Add asynchronous I/O test
- launch 10,000 concurrent writes
 - when any one of these complete, launch a read for the same offset
 - compare read/write data
 - when all reads complete, terminate
2014-08-21 14:01:51 +03:00
Avi Kivity
ec7b440a99 Add asynchronous file I/O
- add dma read/write operations
 - open() is presently synchronous
2014-08-21 14:01:22 +03:00
Avi Kivity
f05e31dfc8 Asynchronous I/O infrastructure
Add integration with the Linux libaio framework:

 - an I/O context is initialized
 - all asynchronous I/Os request that the kernel notify an eventfd
 - a semaphore is used to guard access to the I/O context, so as not to
   exceed the maximum parallelism
 - an internal function submit_io() is used to submit I/O to the kernel,
   returning a future representing completion
 - an internal loop running process_io() is used to consume completions
   when the eventfd is signalled
2014-08-21 13:58:19 +03:00
Avi Kivity
cfeec3799e Add a an asynchronous semaphore class 2014-08-21 13:52:14 +03:00
Avi Kivity
f96b0d5b53 Move pollable_fd_state around
Allows using it inside class reactor.
2014-08-21 13:52:04 +03:00
Avi Kivity
10695644d7 Get rid of regex in http parser
It's slow.  Replacing it doubles throughput to 110K req/s.
2014-08-20 16:37:11 +03:00
Avi Kivity
26527252c5 Remove accept_result 2014-08-20 11:31:01 +03:00
Avi Kivity
b9148304b6 Make future<> and friends a variadic template
This removes the need to create a structure if a future has multiple
return values, and has the nice side effect of removing the specialization
future<void> (replacing it with future<>).
2014-08-20 11:24:32 +03:00
Avi Kivity
8b3690af80 Add apply(func, tuple)
Helper that calls a function with the tuple's components as arguments.
2014-08-20 11:18:23 +03:00