Commit Graph

28 Commits

Author SHA1 Message Date
Gleb Natapov
12bce3f4fc net: make interface get packets from l3
Instead of l3 (arp/ipv4) pushing packets into interface's queue, make
them register functions that interface can use to ask l3 for packets.
2015-01-06 15:24:10 +02:00
Gleb Natapov
e5d0adb339 net: make qp poll for tx packets from networking stack
Packets are accumulated in interface's packet queue. The queue is polled
by qp to see if there is something to send.
2015-01-06 15:24:10 +02:00
Gleb Natapov
510171d083 net: add function to map packet's rss hash to a cpu
Provide a function that maps packet's rss hash to a cpu that should handle
it. This function is needed to find appropriate src port for outgoing
tcp/udp connection. Use this function to forward de-fragmented ip packet
to avoid one extra hop too.
2014-12-23 17:36:40 +02:00
Gleb Natapov
d8ddaeb104 net: forward reassembled ip packet to correct queue
To figure out a cpu that should handle reassembled TCP packet RSS
redirection table have to be consulted.
2014-12-16 10:53:41 +02:00
Gleb Natapov
fbef83beb0 net: support for num of cpus > num of queues
This patch introduce a logic to divide cpus between available hw queue
pairs. Each cpu with hw qp gets a set of cpus to distribute traffic
to. The algorithm doesn't take any topology considerations into account yet.
2014-12-16 10:53:41 +02:00
Gleb Natapov
7ac3ba901c net: rework packet forwarding logic
Instead of forward() deciding packet destination make it collect input
for RSS hash function depending on packet type. After data is collected
use toeplitz hash function to calculate packet's destination.
2014-12-16 10:53:41 +02:00
Gleb Natapov
bd9b0b8962 net: remove broadcast logic from forwarding path
No longer used.
2014-12-15 17:38:20 +02:00
Gleb Natapov
649210b5b6 net: rename net::distributed_device to net::device 2014-12-11 13:06:32 +02:00
Gleb Natapov
73f6d943e1 net: separate device initialization from queues initialization
This patch adds new class distributed_device which is responsible for
initializing HW device and it is shared between all cpus. Old device
class responsibility becomes managing rx/tx queue pair and it is local
per cpu. Each cpu have to call distributed_device::init_local_queue() to
create its own device. The logic to distribute cpus between available
queues (in case there is no enough queues for each cpu) is in the
distributed_device currently and not really implemented yet, so only one
queue or queues == cpus scenarios are supported currently, but this can
be fixed later.

The plan is to rename "distributed_device" to "device" and "device"
to "queue_pair" in later patches.
2014-12-09 18:55:14 +02:00
Gleb Natapov
7dbc333da6 core: Allow forwarding from/to any cpu 2014-12-03 17:47:29 +08:00
Gleb Natapov
bf46f9c948 net: Change how networking devices are created
Currently each cpu creates network device as part of native networking
stack creation and all cpus create native networking stack independently,
which makes it impossible to use data initialized by one cpu in another
cpu's networking device initialization. For multiqueue devices often some
parts of an initialization have to be handled by one cpu and all other
cpus should wait for the first one before creating their network devices.
Even without multiqueue proxy devices should be created after master
device is created so that proxy device may get a pointer to the master
at creation time (existing code uses global per cpu device pointer and
assume that master device is created on cpu 0 to compensate for the lack
of ordering).

This patch makes it possible to delay native networking stack creation
until network device is created. It allows one cpu to be responsible
for creation of network devices on multiple cpus. Single queue device
initialize master device on one cpu and call other cpus with a pointer
to master device and its cpu id which are used in proxy device creation.
This removes the need for per cpu device pointer and "master on cpu 0"
assumption from the code since now master device and slave devices know
about each other and can communicate directly.
2014-11-30 18:10:08 +02:00
Gleb Natapov
136a56859f net: limit the number of packets that are waiting to be sent to another cpu
If packet arrive faster than they can be forwarded we can run out of
memory.
2014-11-09 18:06:22 +02:00
Gleb Natapov
d698811bdd fix smp broadcast packet handling
Some packets, like arp replies, are broadcast to all cpus for handling,
but only packet structure is copied for each cpu, the actual packet data
is the same for all of them. Currently networking stack mangles a
packet data during its travel up the stack while doing ntoh()
translations which cannot obviously work for broadcaster packets. This
patches fixes the code to not modify packet data while doing ntoh(), but
do it in a stack allocated copy of a data instead.
2014-11-06 10:30:30 +02:00
Avi Kivity
7a1f84a556 reactor: replace references to reactor::_id by its accessor cpu_id() 2014-11-01 17:34:43 +02:00
Asias He
2625dd5944 net: Introduce eth_protocol_num 2014-10-13 11:37:56 +08:00
Gleb Natapov
2a662af092 Forward received packet according to classification 2014-10-07 11:04:05 +03:00
Gleb Natapov
4e7d8a8506 Introduce packet classification mechanism
Classifier returns what cpu a packets should be processed on. It may
return special broadcast identifier. The patch includes classifier for
tcp, udp and arp. Arp classifier broadcasts arp reply to all cpus. Default
classifier does not forward packet.
2014-10-07 11:03:57 +03:00
Gleb Natapov
0b59abafa7 Add net::device::l2inject function
Will need it later to handle forwarded packets. Also save net::device
pointer in thread local variable to get to device instance easily. When
we ill have more then one device per cpu we will have to change to
something more sophisticated.
2014-10-07 11:03:52 +03:00
Asias He
236418d262 net: Support TCP checksum offload
It gives ~5% httpd improvements on monster.

csum-offload option is added, e.g., to disable:

./httpd --network-stack native --csum-offload off
2014-09-24 11:03:39 +03:00
Avi Kivity
4ce192c3e0 net: drop 'dropping packet' message
No longer useful.
2014-09-22 11:55:37 +03:00
Avi Kivity
313768654a net: remove queuing from l2->l3 rx path
Use a subscription instead.  Queueing should be implemented at the highest
possible level (e.g. tcp), to avoid double-queueing.
2014-09-22 11:28:35 +03:00
Avi Kivity
4738f3f05c net: switch device rx to stream<packet>
Still have that internal rx queue.
2014-09-22 11:27:47 +03:00
Tomasz Grabiec
791797669f net: make offset == 0 by default in packet::get_header() to simplify call sites 2014-09-16 18:48:13 +03:00
Avi Kivity
812ac77d2f net: spit out packet class into its own files 2014-09-16 10:13:09 +03:00
Avi Kivity
8b86f9d93c net: increase queue length to 1000 2014-09-15 19:27:10 +03:00
Avi Kivity
4d28e910db net: queue packets at the L3 protocol level
If an L3 packet receiver is not able to register itself as a packet receiver
after processing a packet, or if it is simply not dispatched quickly enough,
then we will drop packets.

Add a queue at the protocol layer to buffer those packets.
2014-09-14 16:00:07 +03:00
Avi Kivity
1fbe325f63 net: add a helper to allocate a header in an existing packet
Use in IP and ethernet layers.
2014-09-02 23:29:43 +03:00
Avi Kivity
c77f77ee3f build: organize files into a directory structure 2014-08-31 21:29:13 +03:00