Commit graph

71 commits

Author SHA1 Message Date
Gordon Bergling 2b1e4e5be3 atse(4): Fix a typo in a source code comment
- s/addresss/address/

MFC after:	3 days
2024-01-20 17:35:51 +01:00
Warner Losh fdafd315ad sys: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by:		Netflix
2023-11-26 22:24:00 -07:00
Emmanuel Vadot 432ae724e6 dwc: Move every sub drivers to dev/dwc
It makes it easier to find all the sub drivers and change them if needed.
While here do not gate dwc_rk with soc options, dwc_rk is made for all rockchip
SoCs. Same thing for dwc_socfpga
2023-10-05 17:34:38 +02:00
Warner Losh 031beb4e23 sys: Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:54:58 -06:00
Warner Losh 685dc743dc sys: Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:36 -06:00
Warner Losh 95ee2897e9 sys: Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:11 -06:00
Warner Losh 4d846d260e spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:03 -06:00
Justin Hibbits 343c112dfe altera: Fix build from 068f2c0e10
Missed the altera dwc driver in the conversion.

Fixes:		068f2c0e10
Sponsored by:	Juniper Networks, Inc.
2023-03-07 12:00:00 -05:00
Justin Hibbits b4ad37f693 Mechanically convert atse(4) to IfAPI
Reviewed by:	zlei
Sponsored by:	Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D37795
2023-02-07 14:15:04 -05:00
John Baldwin b08b5f558b altera drivers: Remove unused devclass arguments to DRIVER_MODULE. 2022-05-09 14:26:46 -07:00
John Baldwin 3e38757d4c Remove unused miibus_devclass and miibus_fdt_devclass. 2022-05-06 15:39:28 -07:00
Mateusz Guzik a3e2cdf8a6 altera: clean up empty lines in .c and .h files 2020-09-01 21:38:18 +00:00
Michal Meloun 188aee740f Finish renaming in if_dwc.
By using DWC TRM terminology, normal descriptor format should be named
extended and alternate descriptor format should be named normal.

Should not been functional change.

MFC after:	4 weeks
2020-06-19 18:34:27 +00:00
Kyle Evans 23d5326823 tty: convert tty_lock_assert to tty_assert_locked to hide lock type
A later change, currently being iterated on in D24459, will in-fact change
the lock type to an sx so that TTY drivers can sleep on it if they need to.
Committing this ahead of time to make the review in question a little more
palatable.

tty_lock_assert() is unfortunately still needed for now in two places to
make sure that the tty lock has not been recursed upon, for those scenarios
where it's supplied by the TTY driver and possibly a mutex that is allowed
to recurse.

Suggested by:	markj
2020-04-17 18:34:49 +00:00
Pawel Biernacki 7029da5c36 Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)
r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are
still not MPSAFE (or already are but aren’t properly marked).
Use it in preparation for a general review of all nodes.

This is non-functional change that adds annotations to SYSCTL_NODE and
SYSCTL_PROC nodes using one of the soon-to-be-required flags.

Mark all obvious cases as MPSAFE.  All entries that haven't been marked
as MPSAFE before are by default marked as NEEDGIANT

Approved by:	kib (mentor, blanket)
Commented by:	kib, gallatin, melifaro
Differential Revision:	https://reviews.freebsd.org/D23718
2020-02-26 14:26:36 +00:00
Scott Long 332e6e31c2 Fix syntax error from r357647. Adjust a variable name to make the use more
clear.

Reported by:	dim
2020-02-17 20:12:34 +00:00
Ruslan Bukin d987842d1e Enter the network epoch in the xdma interrupt handler if required
by a peripheral device driver.

Sponsored by:	DARPA, AFRL
2020-02-08 23:07:29 +00:00
Scott Long d176b8039e Ever since the block layer expanded its command syntax beyond just
BIO_READ and BIO_WRITE, we've handled this expanded syntax poorly in
drivers when the driver doesn't support a particular command.  Do a
sweep and fix that.

Reported by:	imp
2020-02-07 09:22:08 +00:00
Gleb Smirnoff 0921628ddc Introduce flag IFF_NEEDSEPOCH that marks Ethernet interfaces that
supposedly may call into ether_input() without network epoch.

They all need to be reviewed before 13.0-RELEASE.  Some may need
be fixed.  The flag is not planned to be used in the kernel for
a long time.
2020-01-23 01:41:09 +00:00
Gleb Smirnoff 5b7a9eab16 Convert to if_foreach_llmaddr() KPI. 2019-10-21 18:10:46 +00:00
Ruslan Bukin 4be6714234 Add glue driver for Altera SOCFPGA Ethernet MAC (EMAC) found in
Terasic DE10-Pro (an Intel Stratix 10 GX/SX FPGA Development Kit).

The Altera EMAC is an instance of Synopsys DesignWare Gigabit MAC.

This driver sets correct clock range for MDIO interface on Intel Stratix 10
platform.

This is required due to lack of support for clock manager device for
this platform that could tell us the clock frequency value for ethernet
clock domain.

Sponsored by:	DARPA, AFRL
2019-07-29 16:32:23 +00:00
Ruslan Bukin 951e058411 o Add support for BERI IOMMU device
o Add an experimental IOMMU support to xDMA framework

The BERI IOMMU device is the part of CHERI device-model project [1]. It
translates memory addresses for various BERI peripherals modelled in
software. It accepts FreeBSD/mips64 page directories format and manages
BERI TLB.

1. https://github.com/CTSRD-CHERI/device-model

Sponsored by:	DARPA, AFRL
2019-07-22 16:01:20 +00:00
Ruslan Bukin 0c340d7ed9 Negate the logic of XCHAN_CAP_NOBUFS macro and rename it to
XCHAN_CAP_BOUNCE.

The only application that uses bounce buffering for now is the Government
Furnished Equipment (GFE) P2's dma core (AXIDMA) with its own dedicated
cacheless bounce buffer.

Sponsored by:	DARPA, AFRL
2019-07-04 14:04:08 +00:00
Ruslan Bukin 2593e9dcb2 Add support for extended descriptor format to Altera mSGDMA driver.
The format to use depends on hardware configuration (synthesis-time),
so make it compile-time kernel option.

Extended format allows DMA engine to operate with 64-bit memory addresses.

Sponsored by:	DARPA, AFRL
2019-06-27 18:08:18 +00:00
Ruslan Bukin 5a51e5e49d o Rewrite softdma_process_tx() of Altera SoftDMA engine driver
so it does not require a bounce buffer. The only need for this was
  to align the buffer address. Implement unaligned access and we don't
  need to copy data twice.
o Remove contigmalloc-based bounce buffer from xDMA code since it is
  not suitable for arbitrary memory provided by platform, which is
  sometimes a dedicated piece of memory that is not managed by OS at all.

Sponsored by:	DARPA, AFRL
2019-04-29 16:27:15 +00:00
Konstantin Belousov b8c20c02cc Fix off-by-one (page) errors in checks in d_mmap methods of several drivers.
Reported by:	C Turt <ecturt@gmail.com>
Reviewed by:	alc, markj
admbug:		781
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2018-12-02 18:30:58 +00:00
Matt Macy d7c5a620e2 ifnet: Replace if_addr_lock rwlock with epoch + mutex
Run on LLNW canaries and tested by pho@

gallatin:
Using a 14-core, 28-HTT single socket E5-2697 v3 with a 40GbE MLX5
based ConnectX 4-LX NIC, I see an almost 12% improvement in received
packet rate, and a larger improvement in bytes delivered all the way
to userspace.

When the host receiving 64 streams of netperf -H $DUT -t UDP_STREAM -- -m 1,
I see, using nstat -I mce0 1 before the patch:

InMpps OMpps  InGbs  OGbs err TCP Est %CPU syscalls csw     irq GBfree
4.98   0.00   4.42   0.00 4235592     33   83.80 4720653 2149771   1235 247.32
4.73   0.00   4.20   0.00 4025260     33   82.99 4724900 2139833   1204 247.32
4.72   0.00   4.20   0.00 4035252     33   82.14 4719162 2132023   1264 247.32
4.71   0.00   4.21   0.00 4073206     33   83.68 4744973 2123317   1347 247.32
4.72   0.00   4.21   0.00 4061118     33   80.82 4713615 2188091   1490 247.32
4.72   0.00   4.21   0.00 4051675     33   85.29 4727399 2109011   1205 247.32
4.73   0.00   4.21   0.00 4039056     33   84.65 4724735 2102603   1053 247.32

After the patch

InMpps OMpps  InGbs  OGbs err TCP Est %CPU syscalls csw     irq GBfree
5.43   0.00   4.20   0.00 3313143     33   84.96 5434214 1900162   2656 245.51
5.43   0.00   4.20   0.00 3308527     33   85.24 5439695 1809382   2521 245.51
5.42   0.00   4.19   0.00 3316778     33   87.54 5416028 1805835   2256 245.51
5.42   0.00   4.19   0.00 3317673     33   90.44 5426044 1763056   2332 245.51
5.42   0.00   4.19   0.00 3314839     33   88.11 5435732 1792218   2499 245.52
5.44   0.00   4.19   0.00 3293228     33   91.84 5426301 1668597   2121 245.52

Similarly, netperf reports 230Mb/s before the patch, and 270Mb/s after the patch

Reviewed by:	gallatin
Sponsored by:	Limelight Networks
Differential Revision:	https://reviews.freebsd.org/D15366
2018-05-18 20:13:34 +00:00
Ruslan Bukin b8f915ab24 Convert atse(4) driver for Altera Triple-Speed Ethernet MegaCore to use
xdma(4) interface.

This allows us to switch between Altera mSGDMA or SoftDMA engines used by
atse(4) device.

This also makes atse(4) driver become 25% smaller.

Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D9618
2018-04-13 15:59:24 +00:00
Ruslan Bukin 8f89e7db08 Add driver for Altera SoftDMA® device.
SoftDMA is a software implementation of DMA engine built using Altera
FIFO component.

Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D9620
2018-04-13 14:18:04 +00:00
Ruslan Bukin 4be5a951f6 Add driver for Altera modular Scatter-Gather DMA engine (mSGDMA).
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D9619
2018-04-13 13:23:31 +00:00
Oleksandr Tymoshenko 217d17bcd3 Clean up OF_getprop_alloc API
OF_getprop_alloc takes element size argument and returns number of
elements in the property. There are valid use cases for such behavior
but mostly API consumers pass 1 as element size to get string
properties. What API users would expect from OF_getprop_alloc is to be
a combination of malloc + OF_getprop with the same semantic of return
value. This patch modifies API signature to match these expectations.

For the valid use cases with element size != 1 and to reduce
modification scope new OF_getprop_alloc_multi function has been
introduced that behaves the same way OF_getprop_alloc behaved prior to
this patch.

Reviewed by:	ian, manu
Differential Revision:	https://reviews.freebsd.org/D14850
2018-04-08 22:59:34 +00:00
Pedro F. Giffuni 718cf2ccb9 sys/dev: further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.
2017-11-27 14:52:40 +00:00
Robert Watson f00e79c847 Merge enhancements to the ALTERA Avalon bus generic device attachment
driver to support exposing a GEOM device, which can be used to mount
Avalon-attached ROMs, reserved areas of DRAM, etc, as a filesystem:

commit 9deb1e60ea
Author: Robert N. M. Watson <robert.watson@cl.cam.ac.uk>
Date:   Sat Mar 5 20:33:12 2016 +0000

    Use format strings with make_dev(9) in avgen(4).

commit 0bf2176c23
Author: Robert N. M. Watson <robert.watson@cl.cam.ac.uk>
Date:   Tue Mar 1 10:23:23 2016 +0000

    Implement a new "geomio" configuration argument to altera_avgen(4),
    the generic I/O device we attach to various BERI peripherals.  The new
    option requests that, instead of exposing the underlying device via a
    special device node in /dev, it instead be exposed via geom(4),
    allowing it to be used with filesystems.  The current implementation
    does not allow a device to be exposed both for file/mmap and geom, so
    one of the two models must be selected when configuring it via FDT or
    device.hints.  A typical use of the new option will be:

      sri-cambridge,geomio = "rw";

MFC after:	1 week
Sponsored by:	DARPA, AFRL
2017-01-28 13:25:06 +00:00
Robert Watson 95fadd99d5 Merge robustness improvements for the ALTERA JTAG UART driver from
CheriBSD, which attempt to work around an inherent race in the UART's
control-register design in detecting whether JTAG is currently,
present, which will otherwise lead to moderately frequent output
drops when running in polled rather than interrupt-driven operation.
Now, these drops are quite infrequent.

commit 9f33fddac9
Author: Robert N. M. Watson <robert.watson@cl.cam.ac.uk>
Date:   Thu Jul 16 17:34:12 2015 +0000

    Add a new sysctl, hw.altera_jtag_uart.ac_poll_delay, which allows the
    (default 10ms) delay associated with a full JTAG UART buffer combined
    with a lack of a JTAG-present flag to be tuned.  Setting this higher
    may cause some JTAG configurations to be more reliable when printing
    out low-level console output at a speed greater than the JTAG UART is
    willing to carry data.  Or it may not.

commit 73992ef760
Author: Robert N. M. Watson <robert.watson@cl.cam.ac.uk>
Date:   Sun Jan 1 15:13:07 2017 +0000

    Minor improvements to the Altera JTAG UART device driver:

    - Minor rework to the logic to detect JTAG presence in order to be a bit
      more resilient to inevitable races: increase the retry period from two
      seconds to four seconds for trying to find JTAG, and more agressively
      clear the miss counter if JTAG has been reconnected.  Once JTAG has
      vanished, stop prodding the miss counter.

    - Do a bit of reworking of the output code to frob the control register
      less by checking whether write interrupts are enabled/disabled before
      changing their state.  This should reduce the opportunity for races
      with JTAG discovery (which are inherent to the Altera
      hardware-software interface, but can at least be minimised).

    - Add statistics relating to interrupt enable/disable/JTAG
      discovery/etc.

    With these changes, polled-mode JTAG UART ttys appear substantially
    more robust.

MFC after:	1 week
Sponsored by:	DARPA, AFRL
2017-01-28 12:43:19 +00:00
Ruslan Bukin f73b677d04 o Fix style.
o Remove set but not used variable.

Sponsored by:	DARPA, AFRL
2016-12-28 14:10:33 +00:00
Oleksandr Tymoshenko 27b917c85e Use OF_prop_free instead of direct call to free(9) 2016-05-14 18:44:30 +00:00
Pedro F. Giffuni 453130d9bf sys/dev: minor spelling fixes.
Most affect comments, very few have user-visible effects.
2016-05-03 03:41:25 +00:00
Pedro F. Giffuni 73a1170a8c sys/dev: use our nitems() macro when it is avaliable through param.h.
No functional change, only trivial cases are done in this sweep,
Drivers that can get further enhancements will be done independently.

Discussed in:	freebsd-current
2016-04-19 23:37:24 +00:00
Svatopluk Kraus b352b10400 As <machine/vm.h> is included from <vm/vm.h>, there is no need to
include it explicitly when <vm/vm.h> is already included.

Reviewed by:	alc, kib
Differential Revision:	https://reviews.freebsd.org/D5380
2016-02-22 09:10:23 +00:00
Jung-uk Kim fd90e2ed54 CALLOUT_MPSAFE has lost its meaning since r141428, i.e., for more than ten
years for head.  However, it is continuously misused as the mpsafe argument
for callout_init(9).  Deprecate the flag and clean up callout_init() calls
to make them more consistent.

Differential Revision:	https://reviews.freebsd.org/D2613
Reviewed by:	jhb
MFC after:	2 weeks
2015-05-22 17:05:21 +00:00
Ruslan Bukin 2499610b9a Do not configure Altera PIO device on ARM startup.
PIO is a device implemented in soft-core and becomes
available after flashing FPGA only.
2015-01-04 23:14:04 +00:00
Brooks Davis a1f76946d5 Merge from CheriBSD:
commit d0c7d235c0
    Make the Altera JTAG UART device driver slightly more forgiving of
    the foibles of a sub-par hrdware interface by increasing the timeout
    for spotting JTAG polling from one to two seconds.

commit 19ed45a188
    Update comment.

commit 8edfe803f0
    Add a comment about a device-driver race condition that could cause the BERI
    pipeline to wedge awaiting JTAG in the event that both the low-level console
    and the tty layer decide to write to the JTAG FIFO just before JTAG is
    disconnected.  Resolving this race is a bit tricky as it looks like there
    isn't a way to 'give the character back' to the tty layer when we discover
    the race.  The easy fix is to drop the character, which we don't yet do, but
    perhaps should as that is a better outcome than wedging the pipeline.

commit 2ea26cf579
    Add a comment about an inherent race with hardware in the Altera JTAG
    UART's low-level console code.

Submitted by:	rwatson
MFC after:	1 week
Sponsored by:	DARPA, AFRL
2014-11-21 21:14:05 +00:00
Brooks Davis 9d88fc7ce3 Merge from CheriBSD (2e28d2a309)
Remove initalized, but unused devname variable

MFC after:	1 week
Sponsored by:	DARPA, AFRL
2014-11-21 21:10:02 +00:00
Ruslan Bukin 707aef95a0 Add Altera Parallel IO (PIO) device driver.
Sponsored by:	DARPA, AFRL
2014-11-18 14:12:19 +00:00
Gleb Smirnoff c8dfaf382f Mechanically convert to if_inc_counter(). 2014-09-19 03:51:26 +00:00
Bjoern A. Zeeb dcceaf9f3c Merge atse(4) interrupt handling and race condition fixes from cheribsd:
commit 8bd88585ed

    Rework atse_rx_cycles handling: count packets instead of fills, and use the
    limit only when polling, not when in interrupt mode.  Otherwise, we may
    stop reading the FIFO midpacket and clear the event mask even though the
    FIFO still has data to read, which could stall receive when a large packet
    arrives.  Add a comment about races in the Altera FIFO interface: we may
    need to do a little more work to handle races than we are.

commit 20b39086cc

    Use 'sizeof(data)' rather than '4' when checking an mbuf bound, as is the
    case for adjusting length/etc.

commit e18953174a

    Break out atse_intr() into two separate routines, one for each of the two
    interrupt sources: receive and transmit.

commit 6deedb4324

    For the RX interrupt, take interest only in ALMOSTEMPTY and OVERFLOW.
    For the TX interrupt, take interest only in ALMOSTFULL and UNDERFLOW.

    Perform TX atse_start_locked() once rather than twice in TX interrupt
    handling -- and only if !FULL, rather than unconditionally.

commit 12601972ba

    Experimentation suggests that the Altera Triple-Speed Ethernet documentation
    is incorrect and bits in the event and interrupt-enable registers are not
    irrationally rearranged relative to the status register.

commit 3cff2ffad7

    Substantially rework interrupt handling in the atse(4) driver:

    - Introduce a new macro ATSE_TX_PENDING() which checks whether there is
      any pending data to transmit, either in an in-progress packet or in
      the TX queue.
    - Introduce new ATSE_RX_STATUS_READ() and ATSE_TX_STAUTS_WRITE() macros
      that query the FIFO status registers rather than event registers,
      offering level- rather than edge-triggered FIFO conditions.
    - For RX, interrupt only on full/overflow/underflow; for TX, interrupt
      only on empty/overflow/underflow.
    - Add new ATSE_RX_INTR_READ() and ATSE_RX_INTR_WRITE() macros useful for
      debugging interrupt behaviour.
    - Add a debug.atse_intr_debug_enable sysctl that causes various pieces
      of FIFO state to be printed out on each RX or TX interrupt.  This is
      disabled by default but good to turn on if the interface appears to
      wedge.  Also print debugging information when polling.
    - In the watchdog handler, do receive, not just transmit, processing, to
      ensure that the rx, not just tx, queue is being handled -- and, in
      particular, will be drained such that interrupts can resume.
    - Rework both atse_rx_intr() and atse_tx_intr() to eliminate many race
      conditions, and add comments on why various things are in various
      orders.  Interactions between modifications to the event and interrupt
      masks are quite subtle indeed, and we must actively check for a number
      of races (e.g., event mask cleared; packet arrives; interrupts enabled).
      We also now use the status registers rather than event registers for
      FIFO status checks to avoid other races; we continue to use event
      registers for underflow/overflow.

    With this change, interrupt-driven operation of atse appears (for the
    time being) robust.

commit 3393bbff5c

    atse: Fix build after 3cff2ffa

Obtained from:	cheribsd
Submitted by:	rwatson, emaste
Sponsored by:	DARPA/AFRL
MFC after:	3 days
2014-09-16 15:45:53 +00:00
Gleb Smirnoff 1bffa9511f Use define from if_var.h to access a field inside struct if_data,
that resides in struct ifnet.

Sponsored by:	Nginx, Inc.
2014-08-30 19:55:54 +00:00
Bjoern A. Zeeb 5cb35d896d Use ETHER_ALIGN as argument to m_adj() to offset the beginning of packet
rather than the magic number 2.

While here fix a typo in a comment.

No functional changes.

MFC after:	1 week
Sponsored by:	DARPA/AFRL
2014-04-16 15:28:17 +00:00
Ian Lepore add35ed5b8 Follow r261352 by updating all drivers which are children of simplebus
to check the status property in their probe routines.

Simplebus used to only instantiate its children whose status="okay"
but that was improper behavior, fixed in r261352.  Now that it doesn't
check anymore and probes all its children; the children all have to
do the check because really only the children know how to properly
interpret their status property strings.

Right now all existing drivers only understand "okay" versus something-
that's-not-okay, so they all use the new ofw_bus_status_okay() helper.
2014-02-02 19:17:28 +00:00
Gleb Smirnoff b8c83a1957 Another round of removing historical mbuf(9) allocator flags.
They are breeding! New ones arouse since last round.

Sponsored by:	Nginx, Inc.
2014-01-16 13:44:47 +00:00