We can move the pcibios code to its own module
and just provide a stub pcibiosinit() function
for pc64 so we do not have to pull in that code
and the data structures.
also lets us clean up mkdevlist hacks.
we should properly zero-pad the ethernet frames we send out
instead of sending random garbage.
for ppp -> ethernet, the ethernet header is fixed, so we
can generate it once before the read()/write() loop.
Use a 1514 byte buffer for all ethernet frames as the
maximum, and limit the mtu to 1514-14-8 -> 1492.
ndb/query -a already returns the value without
the attribute name when given a single rattr
so sed pipeline can be avoided.
also use -c flag to query ndb/cs, which has
a cache of the network database.
For xhci, we want to keep the hubs around until all its
attached devices have been released, so have the Udev
take a reference to its parent hubs ep0.
This also means that we can now use just a pointer
to the tthub instead of duplicating the properties
needed for xhci and ythe code becomes trivial.
Do a non-recursive implementation of putep() to
conserve stack space.
For device detaches, we want to immediately cancel
all I/O so that the driver can release the device
as soon as possible.
For this, we add epstop callback in the Hci struct.
Implement prefix delegation by requesting a
prefix and populate ipnet=val entry (val
passed from -i option).
Before, DHCPv6 was just implemented for stateless
one-shot operation, just exiting once we got out
IA address.
Moodies mediacom-enterprise-enterprise-ISP...
... they actually do enterprise-grade dyanmic dhcpv6
so here we are, implementing renewals...
The IA options where not parsed properly, assuming option 5
is the first option.
For managed networks, we might not get any prefix info
options, but dhcpv6 needs a gateway, so use source address
of the RA.
The Routehint is embedded into the Translation struct
at an offset, so setting the Translation *q pointer to
nil results in a non-nil Routehint* pointer passed to
ipoput4() generating a crash.
When a low/full speed device is connected to a USB2.0 hub,
the USB2.0 hub needs to be send special split transaction
protocol messages to communicate with the device below.
This also applies if the fullspeed/lowspeed device is not
directly connected to the USB2.0 hub, but has a fullspeed
hub in between like:
rootport -> usb2.0 hub -> usb1.1 hub -> fs/ls device
In this case, the tranaction translator is actually
the first hub, nut the direct parent of the device.
This was all totally wrong in the hci drivers drivers.
Also, with the new interface, usbd passes number of
ports, and TT properties in the "hub" ctl message,
so the port-count, TT Think-Time and Multi-TT properties
can be properly applied by the xhci driver.
Another bug was that the xhci route string was not
correct if a hub has more than 15 ports. A USB2.0
hub can have more than 15 ports and the standard sais
that in this case a value of 15 should be used in
its bit routestring nibble.
Also, check the hub depth. We should not exceed more
than 5 hubs.
For xhci, it turns out the hub parameters where
actually never properly applied, as the spec sais
only the first "create endpoint" command applies
the hub parameters. The "evaluate context" command
does not work.
Some pikeshedding in devusb:
- fix the freaking locking.
- remove redundant parameters (isroot -> depth < 0, ishub -> nports > 0)
- add TT properties to usb device struct
With these changes, the wired "middle port" issues
on mnt-reform xhci are gone.
In an upcoming commit, the interface for how to create hubs
and how to update endpoint parameters is going to change.
Device/endpoint properties should not be modified while
the data file is open (device is being used).
This also applies to control endpoint when changing
packet size.
The motivation here is to clean up the xhci driver
and not do these stupid hacks like parsing control
messages. It is easier to just have the hci drivers
apply everything at open time and being guaranteed
that properties do not change under them.
For this we need to make sure to only do these devctl's
while the data file is not open.
For hubs, the command changes and some parameters.
Primarily the number of ports (required for xhci) which
will let devusb do some error checking and the
USB2.0 -> USB1.1 transaction translator properties.
In usb/lib, the "isroot" property is redundant and is
replaced by depth < 0.
For usb3.0 hub descriptor, the led indicator fields are
different from usb2.0 descriptors.
Rest is pikeshedding.
This is an error probably when converting from libthread
to classid plan9 procs. umsrequest() used to just sysfatal()
once the error counter reached some value. But this leaves
9p procs (created by srvrelease()) around keeping the
device hanging around.
Instead, reply first, then attempt some recovery.
If that fails, kill our notegroup.
Also, for upcoming devusb changes, make sure we do
devctl() while the endpoint is not in use.
Instead of having the driver allocate the temporary
READSTR buffer (and messing up the error handling),
allocate it in devether (netif) and pass the driver
start and end pointers to it.
Also, systematically check that the ifstat()
function checks the zero-length read (meaning
it is supposed to just update statistics counters
for a stats file read).
Drivers where allocating a READSTR size buffer,
then readstr() it. But readstr() can raise an
error on pagefault, resulting in the buffer to
be leaked.
Instead, we change the interface and allocate
the buffer in devuart read handler, passing
the driver start and end pointers into it.
Also, provide a default implementation (when
status == nil), avoiding some duplication.
A user can create a large demand paged segment
and then do write to a ctl file with a very large buffer
driving the kernel into an out-of-memory condition.
For all practcal purposes, limit the input buffer size
to something reasonable. READSTR is 8000 bytes, which
would be enougth for even the largest ctl messages.
We have to ensure that we do the putep() loop
only once for detach, so serialize the state
transition using ep0 qlock().
Furthermore, once the state is Ddetach, we
must ensure never to set it to something else
(such as Dreset or Denabled).