pfzio: complete implementation, but still with some bugs

This commit is the result of squashing several commits.
The last squash after a rebase to a newer ZIO master (version 1.0
of the control) comes from the following (branch pfzio-121102, in
our backups):

   6441045 include: rename pf-zio.h to zio-sock.h
   3523fd4 pf-zio: moved header to include/linux/ and fixed other details
   2542956 pf-zio.h: define sockaddr_zio for users
   c8eac35 buffer-sock: define a missing spinlock and init it
   49e47d8 pfzio: complete implementation, but still with some bugs

The first of them was the result of squashing of several commits. There are
some bugs, even serious, to be addressed, and we'd better not have a
non-working code base in master when we merge.  So this is a complete
squash of these commits (branch "pfzio-beta2", still in our backups):

  e0f5f6b buffers: split pf-zio buffer in three parts (still dirty)
  e1d4341 pfzio: fix block allocation inside skbuf in zn_alloc_block()
  8e515a1 pfzio: added ethernet header.
  de957ec pfzio: __zn_get_skb_block: sk_buff pointer isn't needed anymore
  8a7a2e6 pfzio: trivial fix in zn_poll - check comes before everything now
  52daea9 pfzio: added stats update in zn_hard_start_xmit() in case of error
  f263ee4 pfzio: added compile-time padding calculation for struct zio_cb
  e1d3003 pfzio: bind() can now be used on stream sockets.
  945477e pfzio: added a simple client to send data using PF_ZIO
  5743b41 pfzio: Fixed a bug in zn_getname().
  ac86d9d pfzio: A couple style fixes
  f6d970d pfzio: Some style fixes to code
  d2cc052 pfzio: added queue for output block.
  5106c98 pfzio: added a simple (so simple) reading tool.
  6edbe0b tools/.gitignore added pfzio tools
  146ea2d pfzio: added a couple simple style fixes.
  9056e92 pfzio: added bind().
  4824c26 pfzio: added simple logic to deliver blocks to the socket
  9632f3b pfzio: Variuos fixes to improve code style.
  121f483 pfzio: added poll() support.
  753659f pfzio: added support for getpeername()
  d957b16 pfzio: added support for recvfrom for stream, datagram and raw socket.
  735f390 pfzio: Removed partial block read from SOCK_RAW and SOCK_DGRAM
  742f19f pfzio: Continued from previous commit.
  89097af pfzio: Various style fixes and checkpatch stuff.
  2c5c30d pfzio: added sendto() management
  5938280 pfzio: Modified zio_sock struct member to allow further development.
  b25e4eb pfzio: added sendmsg for SOCK_STREAM.
  c96a28f pfzio: added sendmsg for SOCK_RAW
  8449f33 pfzio: Hopefully improved code quality and style here and there
  7a7a028 pfzio: SQUASH added a simple check to sendmsg for DGRAM socket
  facaa5a pfzio: added sendmsg for SOCK_DGRAM: complete and partial blocks
  aa5b1b0 pfzio: recvmsg_stream: added MSG_TRUNC
  9baeeb9 pfzio: recvmsg_stream: added flag MSG_PEEK
  6d82de9 pfzio: added a recvmsg for SOCK_STREAM
  bc060a4 pfzio: recvmsg_raw: added flag MSG_TRUNC
  1cd229b pfzio: recvmsg_raw: added flag MSG_PEEK
  3673dc9 pfzio: added basic recvmsg for SOCK_RAW
  de08a39 pfzio: recvmsg_dgram: added MSG_TRUNC
  8e7bb51 pfzio: recvmsg_dgram: added MSG_PEEK
  c5fdab3 pfzio: recv_dgram: added partial block read.
  3b4e134 pfzio: first semi-working implementation

Signed-off-by: Simone Nellaga <snellaga@gmail.com>
Acked-by: Alessandro Rubini <rubini@gnudd.com>

more fixes

Signed-off-by: Alessandro Rubini <rubini@gnudd.com>

Conflicts:
	tools/.gitignore
	tools/Makefile
pfzio: all names now use zn_as a prefix

Signed-off-by: Alessandro Rubini <rubini@gnudd.com>

Conflicts:

	buffers/sock-buffer.c
	buffers/sock-syscall.c
	include/linux/zio-sock.h
pfzio: minor cleanup step

PF_ZIO etc are defined in the header

Some comment reformat in the header

Use struct __zio_cb inside struct zio_cb to ease code and allow me to
review its use by means of compiler errors (now look for zcb)

Remove "struct netdev" from the private structure

Signed-off-by: Alessandro Rubini <rubini@gnudd.com>

Conflicts:

	buffers/sock-buffer.c
	buffers/sock-syscall.c
pfzio: more cleanup and some rename

Signed-off-by: Alessandro Rubini <rubini@gnudd.com>

Conflicts:

	buffers/sock-syscall.c
sock-nic.c: cleanup

Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
sock-buffer: cleanup

Signed-off-by: Alessandro Rubini <rubini@gnudd.com>

Conflicts:

	buffers/sock-buffer.c
sock-syscall: cleanup

Signed-off-by: Alessandro Rubini <rubini@gnudd.com>

Conflicts:

	buffers/sock-syscall.c
tools: mostly rewritten pfzio-receive

Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
Acked-by: Federico Vaga <federico.vaga@gmail.com>
tools/pfzio-send.c: rewritten: same structure as pfzio-receive

Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
Acked-by: Federico Vaga <federico.vaga@gmail.com>
tools: added two perfomance reporters

Signed-off-by: Alessandro Rubini <rubini@gnudd.com>

Conflicts:
	tools/.gitignore
TEMP: buffers/sock-buffer.c
TEMP: zio-sock.h

Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
buffers/sock-syscall.c: replace ZIO_CONTROL_SIZE with zio_control_size()

Signed-off-by: Federico Vaga <federico.vaga@gmail.com>
Acked-by: Alessandro Rubini <rubini@gnudd.com>
buffer/sock-syscall.c: alloc_block() does not require control param anymore

Since 65b98d18b73dfc41c14b3c5ecac61968f1b94aea the zio_control parameter
was dropped

Signed-off-by: Federico Vaga <federico.vaga@gmail.com>
Acked-by: Alessandro Rubini <rubini@gnudd.com>
buffers/sock-syscall.c: kernel v3.7: replace spin_lock_bh() with mutex_lock()

Since 0fa7fa98dbcc2789409ed24e885485e645803d7f sklist_lock become a
mutex

Signed-off-by: Federico Vaga <federico.vaga@gmail.com>
Acked-by: Alessandro Rubini <rubini@gnudd.com>
buffers/sock-syscall.c: code style: replace 'ziodev' with 'zdev'

Signed-off-by: Federico Vaga <federico.vaga@gmail.com>
Acked-by: Alessandro Rubini <rubini@gnudd.com>
buffers/sock-buffer.c: fix error handling

Signed-off-by: Federico Vaga <federico.vaga@gmail.com>
Acked-by: Alessandro Rubini <rubini@gnudd.com>
buffers/sock-buffer.c: replace kmem_cache_create() with KMEM_CACHE()

Signed-off-by: Federico Vaga <federico.vaga@gmail.com>
Acked-by: Alessandro Rubini <rubini@gnudd.com>
buffers/sock-buffer.c: ZIO_DIR is only 1 bit, remove useless if

A ZIO channel (buffer) is mono directional, it can be input or output.
It is useless to have two different if statement for both direction: if
it is not input, then it is output.

Signed-off-by: Federico Vaga <federico.vaga@gmail.com>
Acked-by: Alessandro Rubini <rubini@gnudd.com>
buffers/sock-buffer.c: trivial: remove ret variable

Signed-off-by: Federico Vaga <federico.vaga@gmail.com>
Acked-by: Alessandro Rubini <rubini@gnudd.com>