udp: Make udp pcbinfo and portinfo per-cpu; greatly improve performance

MAJOR CHANGES:

- Add token to protect pcbinfo's inpcb list and wildcard hash table.
  Currently only udp per-cpu pcbinfo sets this token.  udp serializer
  and netisr barrier are nuked.

  o  udp inpcb list:

     Under most cases, udp inpcb list is operated in its owner netisr.
     However, it is also accessed and modified (no effiective udp inpcb
     will be unlinked though) in netisr0 to adjust multicast options if
     one interface is to be detached.  So protecting udp inpcb list
     accessing and modification w/ token is necessary.

     At udp inpcb detach time, the udp inpcb is first removed from the
     udp inpcb list, then a message will go through all netisrs, which
     makes sure that no netisrs are using or can find this udp inpcb
     from the udp inpcb list.  After all these, this udp inpcb is
     destroyed in its owner netisr.

     In netisrs, it is MP safe to find a udp inpcb from udp inpcb list,
     then release the token and process the found udp inpcb.

     In other threads, it is MP safe to find a udp inpcb from udp inpcb
     list, then release the token and process the found udp inpcb in
     non-blocking fashion.

     See also the usage of inpcb marker.

  o  udp wildcard hash table:

     On input path, udp wildcard hash table is searched in its owner
     netisr.  In order to ease implicit binding (bind during send),
     connect after binding, and disconnect, udp inpcb are inserted
     into and removed from other udp pcbinfos' wildcard hash table in
     its owner netisr.  Thus the udp wildcard hash table must be
     protected w/ token.

     At udp inpcb detach time, a message will go through all netisrs,
     and this udp inpcb will be removed from the udp wildcard hash
     table belonging to the current netisr.  This makes sure that once
     the current netisr runs the message handler, this udp inpcb will
     not be used and be found in the current netisr.  When the message
     reaches the last netisr, this udp inpcb is redispatched to its
     owner netisr to be destroyed.

     In netisrs, it is MP safe to find a udp inpcb from udp wildcard
     hash table, then release the token and process the found udp inpcb,
     e.g. use udp inpcb found by in_pcblookuphash().

     In other threads, it is MP safe to find a udp inpcb from udp
     wildcard hash table, then release the token and process the found
     udp inpcb in non-blocking fashion.

     See also the usage of inpcb container marker.

  o  udp connect hash table:

     It is lockless MP safe, and only accessed and modified in its owner
     netisr.

- During inpcb iteration through inpcb list, use inpcb marker when
  calling functions, which may block, e.g. in_pcbpurgeif0(), so the
  inpcb iteration will not stop prematurely, if the inpcb being
  processed is removed from the inpcb list.

- Use udp inpcb wildcard table and udp inpcb connect hash table to
  dispatch input multicast and broadcast udp datagrams.  Using udp inpcb
  list could be time consume, since we need to check udp inpcb lists on
  all cpus; and secondly, once udp inpcb has a local port, it will be in
  either udp wildcard hash table or udp connect hash table.

  Since the socket buffer operation on input path may block, inpcb
  container marker is used when iterating inpcbs from udp inpcb wildcard
  hash table.  in_pcblookup_pkthash() is adjusted to skip inpcb
  container marker.

- udp socket so_port is no longer fixed to netisr0 msgport
  o  Initial udp socket so_port is the current cpu's netisr msgport.
  o  Bound but unconnected udp socket so_port is selected according to
     local port hash.
  o  Connected udp socket so_port is selected according to the udp hash,
     i.e. laddr/faddr toeplitz hash (exception: multicast laddr or
     multicast faddr, is hashed to netisr0).
  o  Multicast socket options are forced to be handled in netisr0, since
     udp socket so_port may not be netisr0 msgport.

- In order to support asynchronized udp inpcb detach:
  o  EJUSTRETURN from pru_detach method now means protocol will call
     sodiscard() and sofree() for soclose().  udp pru_detach method
     returns EJUSTRETURN as of this commit.
  o  SS_ISCLOSING socket state is set before calling pru_detach method,
     so protocol could avoid certain expensive, unnecessary or
     disallowed operation in pru_disconnect or pru_detach method, e.g.
     udp pru_disconnect method avoids putting udp inpcb back to udp
     wildcard hash table, if SS_ISCLOSING is set.

MISC CHANGES:

- pcbinfo's cpu id must be set now; -1 is disallowed.
- udp pru_abort method should never be called; it panicks now.
- Restore traditional BSD behaviour, if unbound udp socket connect
  fails: if local port of the udp socket has been selected, its inpcb
  should be in wildcard hash table, i.e. the udp inpcb should be visible
  on udp datagrams input path.
- Make sure multicast stuffs are adjusted only in netisr0 for inet6, if
  one interface is about to be detached.

PERFORMANCE IMPROVEMENT:

For 'kq_connect_client -u' test, this commit gives 400% performance
improvement (31Kconns/s -> 160Kconns/s).
drm: struct drm_driver.max_ioctl doesn't exist

Use num_ioctls like in Linux.
drm/i915: Reduce differences with Linux 3.8.13

No functional changes.
build - Update Makefile.usr to use new pkg-static

* Update to _02.  The old pkg-static doesn't understand more recent repos.

* Remove the ABIVERS prefix when ABIVERS is not manually specified,
  uname -P doesn't generate the correct results for 3.9 -> 3.10 (it
  says 4.0).

* We still allow ABIVERS to be specified in the make.
drm: Stop building the mach64 driver

It doesn't compile anymore with some drm changes from Linux 3.8.
wpa_supplicant(8): Fix struct ieee80211req_scan_result parsing in driver_bsd.c

* Since commit 32176cfd8803dac7f65c423373f231a378375c86 there is an
  additional isr_meshid_len field in struct ieee80211req_scan_result.
  We have to add this additional offset, when calculating the address
  of the IE data buffer.
kernel/vtnet: Replace recursion with a loop to avoid a stack overflow.
pf - clear M_HASH in a few more places, cleanups, structure size change!

* Clear the M_HASH flag in a few more places where headers get rewritten.

* bzero the key before populating it.  Shouldn't be necessary but add as a
  safety for possible future use cases.

* Add more fields to struct pfsync_state.  This requires pfvar.h to be
  reinstalled, the pf module and the pfctl program to be rebuilt.
  (suggest buildworld + buildkernel).

  pickup_mode and cpuid added.  Also added reserved fields so future
  additions can be made without changing the structure size again.

* Other minor cleanups.

* WARNING ON RDR, PASS IN / PASS OUT combinations.  RDR rules create state
  on the input path.  Further packets on the input path match the RDR
  state on input, but the *return* packet path will match the RDR state on
  output.

  This means that if you have a PASS OUT rule that matches the RDR input path
  on the output side of the translation, it will also create state, and if
  you have a PASS IN rule that matches the RDR return packet path, it will
  also create state on the input path for that packet.

  PF users must be sure that if such rules exist, they are either specified
  to not create keep state, use the default keep state (which allows pickups
  and sloppy tcp tests), or explicitly specify keep state with sloppy tcp
  tests.  This is because these PASS rules will only see one side of the
  TCP connection because the RDR state will suck up the other side.
udp: For connected socket, don't rehash sending datagram

Since it has already been in the correct netisr.
Fix buildkernel without INVARIANTS.

Reported-by: Andrey Oktyabrskiy <ano@bestmx.net>
usb4bsd: make uaudio work

Submitted-By: Vasily Postnicov <shamaz.mazum@gmail.com>
Update devd(8)'s usb.conf for uaudio(4).
snd_uaudio.4: Sync with FreeBSD for a few changes.
Create snd_blah.4 -> blah.4 MLINKS.

Suggested-by: profmakx
Make uaudio(4) compilable into the kernel.
PF - Force 'sloppy' when establishing conflicting state

* Check whether a PASS IN or PASS OUT conflicts with established translation
  state in the opposite direction.  When this situation is detected, one
  of the PASS rules can establish state (and with recent SMP work, both
  PASS rules will establish state).  This causes problems because the PASS
  rules may only see one direction of the connection due to the RDR or NAT.
  If strict TCP sequence space checking occurs the PASS state can generate
  RSTs.

  To fix this we force the SLOPPY flag to be set for any PASS state being
  established in the face of a conflict against a translation rule.  This
  allows packet flow to short-cut through the state table and is preferable
  to disallowing establishment of the state because that would force a
  full rules scan (and repeated conflict/failure) for every packet.

				History

* PASS IN and PASS OUT rules can interfere with a RDR rule when strict
  sequence space tests are made for established TCP state.

  In pre-SMP PF, including in FreeBSD and probably also in other BSDs,
  two active states are generally established, one for RDR and one for the
  PASS IN.  PF attempts to establish state for the PASS OUT but hits a
  conflict against the established RDR state and fails.

  However, in this situation no short-cut state is established in one
  direction and ALL packets that would have matched the failed PASS OUT
  will cause a full rules scan.

* With the SMP work, the PASS OUT conflict was no longer detected because
  the RDR state is on a different RBTREE than the PASS OUT state.  This
  allowed conflicting state for both PASS IN and PASS OUT to be established.

* Conflicting state in either direction is capable of generating spurious
  RSTs against the RDR rule.  One direction for sure, the other will generate
  RSTs but possibly be obscured by the translation rule (that is, the RST
  ends up going somewhere unexpected), so the RDR rule still works.  But
  the problem remains.
tools/netrate: Use ncpus as # of instance by default
tcp: Fix getcred

- Migrate to the target cpu before looking up tcp inpcb.
- Save a copy of the ucred then do SYSCTL_OUT, which could block.
  It is not MPSAFE to do the SYSCTL_OUT even on the target CPU;
  the socket might be ripped when SYSCTL_OUT blocked.
udp: Simplify getcred

- No need to compare cpuid before calling lwkt_migratecpu(), which
  does necessary check itself.
- Streamline the code path a little bit.
Remove csa.4. It is really snd_csa.4 and a csa.4 MLINK will be created.