Commit Graph

63974 Commits

Author SHA1 Message Date
Augustin Cavalier
e6da31ae5d idualwifi7260: Add error to panic message.
Should help with diagnosing the KDLs seen in #14298.
2022-06-13 23:21:14 -04:00
Augustin Cavalier
73d88d4ee6 ifconfig: Add basic IEEE 802.11 media types to the list.
This requires using the FreeBSD if_media.h (for now, anyway)
and adding a subtype_mask to the data structures. But this
does work.

Now 802.11 media will be displayed in ifconfig and Network
preferences.
2022-06-13 22:47:30 -04:00
Augustin Cavalier
1adb712427 preferences/network: Use ifconfig's MediaTypes object instead of recompiling.
The next commit will make it depend on FreeBSD headers,
which we do not have available here.
2022-06-13 22:47:30 -04:00
Augustin Cavalier
850fc02fa2 kernel/vm: Specifiy the page as the object being waited on in VMCache.
I got a strange whole-system hang in file_cache_resize into this
function. Possibly the page was spuriously busy, perhaps it wasn't,
but not having function arguments on x86_64 in stack traces, I was
unable to deduce what page was actually being waited on.

In case it happens again, this should allow it to be debugged further
by placing the address of the vm_page structure in the thread wait
informations. (A string is not very useful here anyway.)
2022-06-13 22:43:15 -04:00
Augustin Cavalier
44fa45df3a net/if: Drop ifmediareq and just use the regular ifreq for SIOCGIFMEDIA.
This was introduced into the main API in 2010 (d72ede75fb),
but was actually only fully used for the past month (c2a9a890f3)
when SIOCGIFMEDIA was supported for all *BSD drivers and not just WiFi.
Most userland consumers of this structure did not use it correctly,
as was the case in #17770, and only worked because in the fallback case
the network stack just treated it as if it were an ifreq.

Nothing actually used the ifm_count/ifm_ulist (though tentative APIs
were exposed for it) as noted by previous commits; and the fact that
Haiku's IFM_* declarations are so spartan makes most of the returned
values unintelligible to userland without using FreeBSD compat headers.

If, in the future, we decide to implement ifmedia listing and selection
properly, that should likely be done with separate ioctls instead of
having multi-function ones like this.

This is technically an ABI break, but in practice it should not matter:
ifmediareq::ifm_current aligns with ifreq::ifr_media, so the things
that used this structure like our in-tree code did will continue to work.
Until this past May, the only other field that was usually set was
ifm_active, but in the absence of setting ifm_status all non-Haiku
consumers should ignore it completely.

The only consumer of this ioctl that I know of out of the tree,
wpa_supplicant, still works after these changes.
2022-06-13 22:31:33 -04:00
Augustin Cavalier
ecf18ba4c8 freebsd_network: Cleanup around ifmedia handling.
* Remove unused variable.

 * Use original value for IFM_AVALID, we do not need to remap this one.
   (Actually we do not need to remap IFM_ACTIVE here either, but it makes
    some things slightly easier to work with rather than remapping it
    in a different location.)
2022-06-13 20:34:05 -04:00
Augustin Cavalier
83ac9b727c network/stack: Do not invoke SIOCGIFMEDIA but just return the already-fetched media.
This functionally disables most of the functionality of the BSD-style
SIOCGIFMEDIA, but it was never used in userland (because if it had,
it would have triggered SMAP violations in the compatibility layer.)

SIOCGIFMEDIA returns BSD-style media values, which mostly overlap
with Haiku ones but have a few differences still. These are taken care
of in the compat layer by ETHER_GET_LINK_STATE, which is where this
media value comes from, but are not by SIOCGIFMEDIA which just passes
back whatever the drivers do.

Fixes #17770, at least for ethernet drivers.
2022-06-13 20:32:57 -04:00
Augustin Cavalier
b5fae38254 network/ethernet: Do not set IFM_ETHER in update_link_state.
All the drivers that support ETHER_GET_LINK_STATE set this correctly;
and more specifically, it should actually not be set on some devices
(WiFi devices, specifically). Since SIOCGIFMEDIA has always been
passed through directly to the driver if it supports it, WiFi
devices worked anyway because this value never made it to userland.
That will soon change, hence this needed to be fixed.
2022-06-13 20:24:17 -04:00
Augustin Cavalier
7de24641a4 freebsd_network: Adjust address validation in bus_dma code.
We need not (in fact, must not) revalidate addresses if we are just
going to coalesce with the previous segment; otherwise, we will incorrectly
reject buffers that are more than page-aligned.

Should fix #17798 and the new KDL in #14260.
2022-06-13 15:05:25 -04:00
Augustin Cavalier
73603a5163 freebsd_network: Clean up bus_dma code.
* Turn lastaddrp into a reference instead of a pointer.
 * Use PAGESIZE instead of B_PAGE_SIZE for consistency.
 * Rename "nsegs" variables to "seg" as it is an offset and not a count.

No functional change intended.
2022-06-13 14:54:40 -04:00
PulkoMandy
ed666fb497 usb_rndis: fix 32bit build 2022-06-11 21:33:14 +02:00
PulkoMandy
fb02142782 usb_rndis: fix handling of multiple packets in one USB transaction
I got my pointer math wrong because some things in RNDIS use uint32 as
the base, but some things are in bytes. Most of the time this would result
in an offset past the end of the USB buffer, so it would just lead to
ignoring all but the first packet. But if the first packet was small enough,
it would point somewhere still in the buffer, and we would read the wrong
data.

Fixes #17775

Change-Id: I32ec0081336b1f772d4dc3099a0ac2c691aa12f0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5377
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
2022-06-11 19:03:48 +00:00
PulkoMandy
4dda1c0369 usb_rndis: use the "data offset" field instead of hardcoding it
Not sure if other phones could use another value, but it's better to
follow the spec. Also add some bounds checks with traces for now if we
see something strange.

Change-Id: I5c7bc37c4730e6a08bf0bf10fed975bf2012102e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5376
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
2022-06-11 19:03:48 +00:00
Augustin Cavalier
802e16c55a freebsd_network: Add missing store of the passed buffer length.
This broke bouncing of anything not an mbuf.
Confirmed to fix #17778, and may fix other problems too.
2022-06-10 23:00:49 -04:00
Augustin Cavalier
ca76d4c336 freebsd_network: Add missing case for MCLBYTES in m_get2.
The first case is really just a standard mbuf without a cluster.
MCLBYTES should be the second case. This matches what FreeBSD does.
2022-06-10 14:33:05 -04:00
Augustin Cavalier
fe476826e7 freebsd_network: bus_size_t seems to always be no larger than void*.
FreeBSD seems to do this, too, and sets BUS_SPACE_MAXSIZE appropriately
(which it seems we already do.) Fixes 32-bit builds following previous
commits.
2022-06-10 14:06:49 -04:00
Augustin Cavalier
10f4c2bd71 Revert "nforce: Disable MTU changes."
This reverts commit 25742b78fb.

It was confirmed the MTU change introduction was unrelated to the
problems seen in this ticket.
2022-06-10 13:43:30 -04:00
Augustin Cavalier
30763b1e79 freebsd_network: Rewrite bus/vm headers to use Haiku phys_addr types directly.
Instead of redeclaring them, which it did so incorrectly on systems
with PAE in some cases. May fix problems on some 32-bit systems.
2022-06-10 13:38:08 -04:00
Augustin Cavalier
3c5b619e97 freebsd_network: Remove unneeded frees of if_l2com.
After 458c40fb27, if_l2com is not
allocated anymore, but I missed deleting these at that time.
2022-06-09 18:55:17 -04:00
Augustin Cavalier
9690b012b4 libroot/musl: Import riscv64 atomic_arch.h. 2022-06-09 18:46:09 -04:00
Augustin Cavalier
36ef2106b7 strace: Add second entry in TypeHandler for const msghdr*.
This way sendmsg's argument will also be traced.

Change-Id: I40b44ffc732d884393f944bc2b1ced7b0a551287
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5354
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
2022-06-09 22:36:38 +00:00
Augustin Cavalier
3b4737b9e5 headers: Remove bsd_mem.h.
This is a holdover from BeOS. All the functions in here we declare
in other headers, so this is not needed.
2022-06-09 18:31:08 -04:00
Augustin Cavalier
0d29def7d2 kernel/lib: Adjustments to use musl's ffs implementation.
This actually has another advantage: if we can use musl sources
in the kernel POSIX support, then we can drop some of the BSD
sources that are used only in the kernel and have a different
implementation in userland (e.g. strtod) and have just one
version for both.
2022-06-09 18:29:33 -04:00
Augustin Cavalier
0afb8a1b49 Move fts.h and functions from libroot to libbsd.
These are BSD extensions, not POSIX functions. They were needed
in libroot by the previous versions of the ftw/nftw implementations,
but the musl versions do not need them, and so we can move them to
libbsd.

This is a minor ABI break, but hopefully whatever was using them
in libroot also links to libbsd. If not, that's an easy enough fix.
(These were only added to libroot in 2013.)
2022-06-09 16:30:40 -04:00
Augustin Cavalier
9b2434d26f libroot: Replace ftw/nftw implemenations with their musl counterparts.
Rewrite ftw.h to be a Haiku header instead of a BSD one while at it.
2022-06-09 16:24:11 -04:00
Augustin Cavalier
22b1d791b2 libroot: Replace getsubopt implementation with musl's.
It looks to be a bit more optimized, and one less thing for
us to have to maintain from POSIX.
2022-06-09 16:06:56 -04:00
Augustin Cavalier
092b6d4a98 libroot: Replace custom ffs implementation with musl's.
It already has a per-arch implementation or a fallback in
musl's own arch_atomic.h, which we already imported so we
might as well leverage it.
2022-06-09 16:04:11 -04:00
Augustin Cavalier
2b609f8f66 openbsd_network: Add implementation of pci_intr_map.
This is not used anywhere, but X512 will need it for testing
some things on RISC-V.
2022-06-09 15:57:48 -04:00
PulkoMandy
d13068c148 iaxwifi200: add to regular image 2022-06-09 21:26:47 +02:00
PulkoMandy
d5af5c5521 iaxwifi200: disable background scans for now
It crashes the firmware after 40 scans. The issue has been reported to
OpenBSD, until then we can leave this disabled. The consequence is that
the wifi network list will not refresh while already connected to a
network. But at least the connection remains online.
2022-06-09 21:26:47 +02:00
Augustin Cavalier
5797a8dec5 graphics/nvidia: Fix another instance of missing READ/WRITE protection flags.
Related to #17766.
2022-06-09 13:53:49 -04:00
Augustin Cavalier
0bee9ee711 openbsd_wlan: Refactor implementation of IEEE80211_IOC_SCAN_RESULTS.
* Do not allocate an equally-sized buffer for all scan results,
   but just alloca() a buffer for a single result, and copy this
   back to userland at the end of each iteration.

 * Check remaining space correctly with respect to IE data.

May fix incorrect scan results or userland memory corruptions
seen with the previous code. Also should be faster since it
does not need to allocate large kernel-side temporary buffers.
2022-06-09 13:35:48 -04:00
Augustin Cavalier
5a4ad3a00d openbsd_wlan: Print state changes if bootverbose is enabled.
This will make debugging in nightly syslogs a bit easier when things
do not work as expected.
2022-06-09 01:28:56 -04:00
Augustin Cavalier
ea7c830790 openbsd_wlan: Implement IEEE80211_IOC_MLME for leaving networks. 2022-06-09 01:28:56 -04:00
Augustin Cavalier
2f7936a683 openbsd_wlan: Add a Haiku-specific "FreeBSD-style" ioctl for joining networks.
In the long run it may make more sense to have Haiku-style ioctls for
this purpose, but since we are currently coexisting with FreeBSD-style
ioctls, just add this as another FreeBSD-style ioctl for now (we already
have two custom ones anyway.)

This ioctl pretty much just consists of the same parameters we pass
to wpa_supplicant using the Haiku-specific constants already, with one
notable difference: the PSK must be in proper WPA format, i.e. already
hashed. Hence we will submit this ioctl, for now, from our own code in
our wpa_supplicant port.

WPS is not implemented in this commit, but it could be if someone actually
needs to connect to WPS networks for some reason...

Tested and verified as working along with the wpa_supplicant changes.
2022-06-09 01:28:56 -04:00
Augustin Cavalier
7cb5a6d24f NetworkDevice.h: Make it possible to include from _KERNEL_MODE and/or non-C++.
This file contains a set of constants and flags which are already passed
between applications, net_server, and wpa_supplicant to indicate network
security, connection modes, and a variety of other things.

As the OpenBSD net80211 stack does not need wpa_supplicant for WPA2/PSK,
it only makes sense that we would pass the same information we pass
to wpa_supplicant into the stack instead. Rather than expose yet another
set of constants and flags to userland besides the FreeBSD and these
Haiku native ones, just make it so this file can be included in the kernel,
and the constants thus used directly.
2022-06-09 01:28:56 -04:00
Augustin Cavalier
bcb089f6c3 openbsd_wlan (and FreeBSD ieee80211_ioctl.h): Initial ioctl compatibility.
* Introduce IEEE80211_IOCTLS_ABBREVIATED to FreeBSD's ieee80211_ioctl.h,
   so that the FreeBSD header can be included along with the OpenBSD
   net80211 stack without triggering lots of errors, so we can use
   these structs in openbsd_wlan ieee80211_haiku.cpp.

 * Implement basic ieee80211req handling machinery. We aren't going
   to handle anything but SIOCG80211 and SIOCS80211 in this method,
   so we can simplify it a bit at the same time.

 * Implement IEEE80211_IOC_SCAN_RESULTS to return scan results from
   the OpenBSD WiFi stack in FreeBSD ioctl format.

   This change adds two minor "features" (noted with #ifdefs) to the
   OpenBSD net80211 stack: one to specify what node index to return
   when returning known nodes (scan results), as this way we do not
   have to allocate a huge buffer to store the scan results in before
   sending them back to userland, but can instead get and convert
   a single one at a time.

   (We store the converted values in kernel mode all at once, though,
    so this is not as efficient as it could be. More improvement possible.)

 * Implement IEEE80211_IOC_BSSID and IEEE80211_IOC_SSID while we are at it.
   This actually may make joining open networks possible, but I didn't
   really test it. (They are used with SIOCG80211 to see what network
   the device is currently connecting/connected to.)
2022-06-09 01:28:56 -04:00
Augustin Cavalier
fba0315889 idualwifi7260 & iaxwifi200: Adaptations for FreeBSD/Haiku support.
Mostly a few #ifdefs for the dmamem API, if_alloc, probe, and attach hooks.
Basically the same changes in both drivers.

The firmware name map is not really needed anymore; the OpenBSD drivers
have unique firmware names and do not generally use ".ucode" extensions.
So just use the filenames as-is and drop the map.
2022-06-09 01:28:55 -04:00
Augustin Cavalier
eb56146603 openbsd_wlan: Basic adaptations to the net80211 layer.
The stack now compiles and links. Combining this with adaptations to
the driver gets things to the point where it runs scans, but we do
not yet implement ioctls so they can be returned to userland.
2022-06-09 01:28:55 -04:00
Augustin Cavalier
27a20680c5 iaxwifi200: Import ("iwx" from OpenBSD.)
Not yet modified to build nor wired into the build yet.
2022-06-09 01:28:55 -04:00
Augustin Cavalier
d87dd30a38 idualwifi7260: Delete FreeBSD driver, import OpenBSD driver.
Again not wired into the build, nor yet modified in any way.
2022-06-09 01:28:55 -04:00
Augustin Cavalier
04171cfc5c openbsd_wlan: Import OpenBSD net80211 layer and base dependencies.
Not yet wired into the build, of course.
2022-06-09 01:28:55 -04:00
Augustin Cavalier
668a169a62 OpenBSD-to-FreeBSD/Haiku compatibility headers.
OpenBSD's and FreeBSD's kernel APIs are very similar, but there are
still some differences. Fortunately these are small enough that we
can take care of most of them with a header-only shim layer.

(The files and functions implemented by this commit were implemented
and tested against the modules and drivers imported and adapted in
the following commits. Some of this took quite a bit of time to get
right, especially where the APIs have diverged in very subtle ways.)
2022-06-09 01:28:55 -04:00
Augustin Cavalier
8548a4adc6 freebsd_network: Adaptations in preparation for the OpenBSD layer.
Most of these changes however add things that FreeBSD has (with a few
exceptions noted in comments) which the OpenBSD shim layer merely needs
to make use of.

(FreeBSD used to have support for IFF_NEEDSGIANT but removed it. The
support instated here is very similar to what FreeBSD used to have.)
2022-06-09 01:28:54 -04:00
Jessica Hamilton
6a9406a172 loader/efi: fix handling of serial devices.
Fixes a regression introduced in hrev55297, fixes #17670.

Change-Id: Icc157e093b8fa3f5e0c2a59ab84c81b780933d46
2022-06-09 02:52:09 +00:00
Jim906
f386770953 Tracker: Restore search criteria when edit query
* Have FindPanel::AttachedToWindow check to see if a MIME type is
  already selected, before it sets MIME type to the default value.
* Fixes #14946.

Change-Id: Iab3b9058bbc3ef1f055475ed54a72d4032643632
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5357
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2022-06-08 21:31:01 +00:00
Jim906
c90d79f03a tracker/FindPanel: style cleanup
* No functional change.

Change-Id: I8e5e941fe626a77134036e3828f23ab245d2f5c7
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5358
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2022-06-08 21:30:34 +00:00
Augustin Cavalier
44d08ffc4a freebsd_network: Add another MTU to attempt to set devices to.
IEEE 802.11 has its own maximum MTU which is smaller than PAGESIZE
but larger than the ETHERMTU default. So we now attempt to set this
as well. In doing so, refactor the set into a loop based off an array
of possible MTUs.
2022-06-07 23:50:54 -04:00
Augustin Cavalier
d765574fdb freebsd_network: Adjust too-large packet handling in read().
Before ca6a44c133, this function returned
whatever amount of the buffer it could and silently discarded the rest.
After that change and before this one, it would refuse to return anything,
which meant that as soon as we got one packet too large to handle,
we would never receive any more packets (and the errors displayed in
e.g. ifconfig would go up forever.)

Now, we discard too-large packets so RX will not stall completely
and still return E2BIG (so error counts will go up), but we also
print an error to syslog, so that precisely what has gone wrong
will be easily known.
2022-06-07 23:49:17 -04:00
Augustin Cavalier
68f0117d83 freebsd_network: Disable IFMEDIA_DEBUG.
It is not really that useful to print most of this information
by default and it just fills up syslogs unnecessarily.
2022-06-07 23:46:25 -04:00