File:  [NetBSD Developer Wiki] / wikisrc / projects / project / fast_protocol.mdwn
Revision 1.1: download - view: text, annotated - select for diffs
Thu Nov 10 03:06:51 2011 UTC (6 years, 6 months ago) by jmmv
Branches: MAIN
CVS tags: HEAD
Add a specific proposal for the SMP networking project.

This proposal is built on top of several individual, smaller projects, all
of which are related to achieve the goals of SMP support and modularity on
the network stack.  Keep in mind that this is just that: a proposal.
Applicants could still come up with their own ideas.

The text of all these new pages is mostly a copy/paste of the original
document written by matt@ (see
I have done some minor edits (hopefully not changing any of the technical
details) and added some preliminary texts to the pages.  (I was unable to
parse some of the sentences though, so they remain "as is"...)

[[!template id=project

title="Fast protocol and port demultiplexing"


funded="The NetBSD Foundation"

This project proposal is a subtask of [[smp_networking]] and is elegible
for funding independently.

The goal of this project is to enhance the networking protocols to process
incoming packets more efficiently.  The basic idea is the following: when a
packet is received and it is destined for a socket, simply place the packet
in the socket's receive PCQ (see [[atomic_pcq]]) and wake the blocking
socket.  Then, the protocol is able to process the next packet.

The typical packet flow from `ip_input` is to `{rip,tcp,udp}_input` which:

* Does the lookup to locate the socket which takes a reader lock on the
  appropriate pcbtable's hash bucket.
* If found and in the proper state:
  * Do not lock the socket since that would might block and therefore stop
    packet demultiplexing.
  * `pcq_put` the packet to the pcb's pcq.
  * `kcont_schedule` the worker continuation with small delay (~100ms).
    See [[kernel_continuations]].
  * Lock the socket's `cvmutex`.
  * Release the pcbtable lock.
  * If TCP and in sequence, then if we need to send an immediate ACK:
    * Try to lock the socket.
    * If successful, send an ACK.
  * Set a flag to process the PCQ.
  * `cv_signal` the socket's cv.
  * Release the cvmutex.
* If not found or not in the proper state:
  * Release the pcb hash table lock.

[[!tag smp_networking]]

CVSweb for NetBSD wikisrc <> software: FreeBSD-CVSweb