Commit graph

39380 commits

Author SHA1 Message Date
Vincenzo Maffione
56eeb84f10 em: skip rxcsum offload processing when disabled
Similarly to the other Intel drivers, don't try to process
RX checksum offloads when this feature (IFCAP_RXCSUM) is
disabled.

Reviewed by:	gallatin, kbowling, erj
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D33155

(cherry picked from commit d0633af765)
2021-12-18 12:00:25 +00:00
Vincenzo Maffione
a00d9c7f8c e1000: remove unused ifp backpointer
The ifp (struct ifnet) backpointer in the e1000 private ifnet
data is not used anymore since the iflib transition.
Remove it so that developers are not tempted to use it and
get a NULL pointer dereference.

Reviewed by:	markj, kbowling, erj
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D33157

(cherry picked from commit d91559564d)
2021-12-18 11:46:41 +00:00
Ram Kishore Vegesna
de7809c1ee ocs_fc: Remove unused function delarations.
Remove unused function declarations.
Changes required for internal tool.

Approved by: ken

(cherry picked from commit 6f78736cb1)
2021-12-17 16:01:06 +05:30
Ram Kishore Vegesna
161148e61f ocs_fc: Fix device lost timer where device is not getting deleted.
Issue: Devices wont go away after the link down.

Device lost timer functionality in ocs_fc is broken,
`is_target` flag is not set in the target database and target delete is skipped.

Fix: Remove unused flags and delete the device when timer expires.

Reported by: ken@kdm.org
Reviewed by: mav, ken

(cherry picked from commit 41e9466943)
2021-12-17 16:01:06 +05:30
Ram Kishore Vegesna
0fff02894f ocs_fc: When commands complete with an error, freeze the device queue.
Proper error recovery depends on freezing the device queue when an
error occurs, so we can recover from an error before sending
additional commands.

The ocs_fc(4) driver was not freezing the device queue for most
SCSI errors, and that broke error recovery.

sys/dev/ocs_fc/ocs_cam.c:
	In ocs_scsi_initiator_io_cb(), freeze the device queue if
        we're passing back status other than CAM_REQ_CMP.

Submitted by: ken@kdm.org
Reviewed by: mav, ken

(cherry picked from commit d063d1bc92)
2021-12-17 16:01:06 +05:30
Ram Kishore Vegesna
4821da88ab ocs_fc: Fix CAM status reporting in ocs_fc(4) when no data is returned.
In ocs_scsi_initiator_io_cb(), if the SCSI command that is
        getting completed had a residual equal to the transfer length,
        it was setting the CCB status to CAM_REQ_CMP.

        That breaks the expected behavior for commands like READ ATTRIBUTE.
        For READ ATTRIBUTE, if the first attribute requested doesn't exist,
        the command is supposed to return an error (Illegal Request,
        Invalid Field in CDB).  The broken behavior for READ ATTRIBUTE
        caused LTFS tape formatting to fail.  It looks for attribute
        0x1623, and expects to see an error if the attribute isn't present.

        In addition, if the residual is negative (indicating an overrun),
        only set the CCB status to CAM_DATA_RUN_ERR if we have not already
        reported an error.  The SCSI sense data will have more detail about
        what went wrong.

        sys/dev/ocs_fc/ocs_cam.c:
                In ocs_scsi_initiator_io_cb(), don't set the status to
                CAM_REQ_CMP if the residual is equal to the transfer length.

                Also, only set CAM_DATA_RUN_ERR if we didn't get SCSI
                status.

Submitted by: ken@kdm.org
Reviewed by: mav, ken

(cherry picked from commit 1af49c2eeb)
2021-12-17 16:01:05 +05:30
Ram Kishore Vegesna
661875cecb ocs_fc: Increase maximum supported SG elements to support larger transfer sizes.
Reported by: ken@kdm.org
Reviewed by: mav, ken

(cherry picked from commit 322dbb8ce8)
2021-12-17 16:01:05 +05:30
Ram Kishore Vegesna
ccd32c6513 ocs_fc: Emulex Gen 7 HBA support.
Emulex Gen7 adapter support in ocs_fc driver.

Reviewed by: mav, ken

(cherry picked from commit 3bf42363b0)
2021-12-17 16:01:05 +05:30
Ram Kishore Vegesna
44a78c21df ocs_fc: Add gendump and dump_to_host ioctl command support.
Support to generate firmware dump.

Approved by: mav(mentor)

(cherry picked from commit 29e2dbd42c)

Add ocs_gendump.c to the build, missed in 29e2dbd42c.

(cherry picked from commit d0732fa819)
2021-12-17 16:00:59 +05:30
Ram Kishore Vegesna
5749a57326 ocs_fc: Fix use after free bug in ocs_hw_async_call()
Freed ctx is used in the later callee ocs_hw_command(),
which is a use after free bug.

Return error if sli_cmd_common_nop() failed.

PR: 255865
Reported by: lylgood@foxmail.com
Approved by:: markj

(cherry picked from commit 7377d3831b)
2021-12-17 15:42:25 +05:30
Ram Kishore Vegesna
f7a7748afc ocs_fc: Fix a use after free in ocs_sport_free
Domain which could be freed is used while freeing the sport.
Use ocs from sport.

PR: 255866
Reported by: lylgood@foxmail.com
Approved by:: markj

(cherry picked from commit dd722ccd6e)
2021-12-17 15:42:09 +05:30
Ram Kishore Vegesna
92d579a9ae ocs_fc: Fix memory leak in ocs_scsi_io_alloc()
PR: 254690
Approved by: mav(mentor)
MFC after: 2 weeks

(cherry picked from commit fc620f9782)
2021-12-17 15:41:49 +05:30
Andriy Gapon
6820d578bb twsi: support more message combinations in transfers
Most prominently, add support for a transfer where a write with no-stop
flag is followed by a write with no-start flag.  Logically, it's a
single larger write, but consumers may want to split it like that
because one part can be a register ID and the other part can be data to
be written to (or starting at) that register.

Such a transfer can be created by i2c tool and iic(4) driver, e.g., for
an EEPROM write at specific offset:
    i2c -m tr -a 0x50 -d w -w 16 -o 0 -c 8 -v < /dev/random

This should be fixed by new code that handles the end of data transfer
for both reads and writes.  It handles two existing conditions and one
new.  Namely:
- the last message has been completed -- end of transfer;
- a message has been completed and the next one requires the start
  condition;
- a message has been completed and the next one should be sent without
  the start condition.

In the last case we simply switch to the next message and start sending
its data.  Reads without the start condition are not supported yet,
though.  That's because we NACK the last byte of the previous message,
so the device stops sending data.  To fix this we will need to add a
look-ahead at the next message when handling the penultimate byte of the
current one.

This change also fixed a bug where msg_idx was not incremented after a
read message.  Apparently, typically a read message is a last message in
a transfer, so the bug did not cause much trouble.

PR:		258994

(cherry picked from commit ff1e858180)
2021-12-17 09:30:58 +02:00
Andriy Gapon
86af87acd1 twsi: make data receiving code safer
Assert that we are not receiving data beyond the requested length.
Assert that we have not NACK-ed incoming data prematurely.
Abort the current transfer if the incoming data is NACK-ed or not
NACK-ed unexpectedly.

Add debug logging of received data to complement logging of sent data.

(cherry picked from commit 00c07d9559)
2021-12-17 09:30:54 +02:00
Andriy Gapon
74f175202c twsi: remove redundant write of control register
The write at the end of twsi_intr() already handles all cases, no need
to have another write for TWSI_STATUS_START / TWSI_STATUS_RPTD_START.

(cherry picked from commit aeacf172fd)
2021-12-17 09:30:48 +02:00
Andriy Gapon
c7bf34cfe5 twsi: move handling of TWSI_CONTROL_ACK into the state machine
Previously the code set TWSI_CONTROL_ACK in twsi_transfer() based on
whether the first message had a length of one.  That was done regardless
of whether the message was a read or write and what kind of messages
followed it.
Now the bit is set or cleared while handling TWSI_STATUS_ADDR_R_ACK
state transition based on the current (read) message.

The old code did not correctly work in a scenario where a single byte
was read from an EEPROM device with two byte addressing.
For example:
    i2c -m tr -a 0x50 -d r -w 16 -o 0 -c 1 -v
The reason is that the first message (a write) has two bytes, so
TWSI_CONTROL_ACK was set and never cleared.
Since the controller did not send NACK the EEPROM sent more data resulting
in a buffer overrun.

While working on TWSI_STATUS_ADDR_R_ACK I also added support for
the zero-length read access and then I did the same for zero-length write
access.
While rare, those types of I2C transactions are completely valid and are
used by some devices.

PR:		258994

(cherry picked from commit 04622a7f21)
2021-12-17 09:30:41 +02:00
Alexander Motin
b7da472979 APEI: Improve multiple error sources handling.
Some AMD systems I have report 8 NMI and 3591 polled error sources.
Previous code could handle only one NMI source and used separate
callout for each polled source.  New code can handle multiple NMIs
and groups polled sources by power of 2 of the polling period.

MFC after:	2 weeks

(cherry picked from commit 2dfc1f7355)
2021-12-15 21:32:36 -05:00
Kornel Duleba
77b3cf989f pci: Don't try to read cfg registers of non-existing devices
Instead of returning 0xffs some controllers, such as Layerscape generate
an external exception when someone attempts to read any register
of config space of a non-existing device other than PCIR_VENDOR.
This causes a kernel panic.
Fix it by bailing during device enumeration if a device vendor register
returns invalid value. (0xffff)
Use this opportunity to replace some hardcoded values with a macro.

I believe that this change won't have any unintended side-effects since
it is safe to assume that vendor == 0xffff -> hdr_type == 0xffff.

Sponsored by:		Alstom
Obtained from:		Semihalf
Reviewed by:		jhb
MFC after:		2 weeks
Differential revision:	https://reviews.freebsd.org/D33059

(cherry picked from commit 68cbe189fd)
2021-12-15 11:46:46 +01:00
Andreas Wetzel
99e934e6f1 rtwn/usb: add product ID for Asus USB N10 Nano Rev. B1
According to information found on the internet the following products
use exactly the same hardware but probably different USB IDs:
- Edimax EW-7811Un V2 (v2)
- Edimax EW-7811GLN 2.0A (v2)
I am not adding them as I cannot verify.

PR:		254280

(cherry picked from commit cd6f0b4769)
2021-12-13 08:35:49 +02:00
Alexander Motin
1fb199ffa6 xhci: Add PCI IDs for Thunderbolt 3/4 USB controllers.
MFC after:	2 weeks

(cherry picked from commit cfb0e4d76c)
2021-12-12 22:16:28 -05:00
Ed Maste
2f2988a3c7 bxe: tag files to skip clang-format formatting
bxe contains three files which are sets of constants or other data, and
might be auto-generated or have an upstream.  They are rather large
files and clang-format takes quite some time when run against them, so
just skip formatting.

MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D27806

(cherry picked from commit c3295781fd)
2021-12-12 17:18:31 -05:00
Alexander Motin
155748c1e7 xhci: Add PCI IDs from recent Intel CPUs.
MFC after:	2 weeks

(cherry picked from commit 83d7b2f335)
2021-12-11 00:17:16 -05:00
Mitchell Horne
06dc4eab74 ucom: s/sio/ucom/
Seems like a copy-paste error, or at least this made more sense when the
sio(4) driver still existed. This modifies the debug port name displayed
at boot, but otherwise has no functional change.

Reviewed by:	hselasky
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D33278

(cherry picked from commit e43d081f35)
2021-12-10 14:31:20 -04:00
Andriy Gapon
0f048f199e twsi: unify error handling, explicitly handle more conditions
twsi_error() is a new function that stops the current transfer and sets
up softc when an error condition is detected.
TWSI_STATUS_DATA_WR_NACK, TWSI_STATUS_BUS_ERROR and
TWSI_STATUS_ARBITRATION_LOST are now handled explicitly rather than
via the catch-all unknown status.

Also, twsi_intr() now calls wakeup() in a single place when the
transfer is finished.

(cherry picked from commit a4fe892208)
2021-12-10 14:30:12 +02:00
Andriy Gapon
22989451b4 twsi: improve a handful of debug messages
- use 0x prefix for hex values
- print indexes and counts as decimals
- break too long lines

(cherry picked from commit 578707ed4e)
2021-12-10 14:30:12 +02:00
Andriy Gapon
5efa75707b twsi: do not attempt transfer if bus is not idle
(cherry picked from commit cb167e1ae9)
2021-12-10 14:30:12 +02:00
Andriy Gapon
bb8fac1ee1 twsi: remove redundant enabling of the controller
(cherry picked from commit bc02583c4d)
2021-12-10 14:30:12 +02:00
Andriy Gapon
109000c32d twsi: protect interaction between twsi_transfer and twsi_intr
All accesses to softc are now done under a mutex to prevent data races
between the open context and the interrupt handler.
Additionally, the wait time in twsi_transfer is bounded now.
Previously we could get stuck there forever if an interrupt got lost.

(cherry picked from commit 69cfa60ddd)
2021-12-10 14:30:12 +02:00
Michael Tuexen
42cb69e147 Hyper-V: hn: Enter network epoch when required
PR:				254695
(cherry picked from commit 26d79d40a7)
2021-12-10 11:50:01 +01:00
Alexander Motin
f8aedfec5d ig4: Add PCI IDs for Intel Alder Lake I2C controller.
Submitted by:	Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after:	2 weeks

(cherry picked from commit e8e8d2290e)
2021-12-08 20:37:28 -05:00
Alexander Motin
447d2569d6 APEI: Fix Generic Error Data Entry revision 3.0 handling.
Since revision 3.0 this structure grown another field, breaking access
to the following data structures.  This change fixes the PCIe errors
decoding on newer systems.

MFC after:	2 weeks

(cherry picked from commit ba83762a62)
2021-12-08 20:35:21 -05:00
Alexander Motin
9e41bccace ichsmb: Add PCI IDs for Intel Alder Lake SMBus controller
Submitted by:	Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after:	2 weeks

(cherry picked from commit f29f6b2e1f)
2021-12-07 23:08:51 -05:00
Warner Losh
de8bb30885 mpr: fix freeze / release mismatch in timeout code
So, if we're processing a timeout, and we've sent an ABORT to the
firmware for that timeout, but not yet received the response from the
firmware, AND we get another timeout, we queue the timeout and freeze
the queue. However, when we've finally processed them all, we only
release the queue once. This causes all I/O to halt as the devq remains
frozen forever.

Instead, only freeze the queue when we start the process (eg set INRESET
on the target). This will allow the release when all the timed out I/Os
have finished ABORTing.

Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D33054

(cherry picked from commit a8837c77ef)
2021-12-06 08:56:00 -07:00
Elyes HAOUAS
27fceea98c Fix typo on "Celsius"
"Celcius" --> "Celsius"

Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
Pull Request: https://github.com/freebsd/freebsd-src/pull/551/files
(cherry picked from commit 9097ac9af4)
2021-12-06 08:55:55 -07:00
Colin Percival
d03a8d181c randomdev: Remove 100 ms sleep from write routine
This was introduced in 2014 along with the comment (which has since
been deleted):
	/* Introduce an annoying delay to stop swamping */

Modern cryptographic random number generators can ingest arbitrarily
large amounts of non-random (or even maliciously selected) input
without losing their security.

Depending on the number of "boot entropy files" present on the system,
this can speed up the boot process by up to 1 second.

Reviewed by:	cem
Sponsored by:	https://www.patreon.com/cperciva
Differential Revision:	https://reviews.freebsd.org/D32984

(cherry picked from commit 1580afcd6e)
2021-12-05 10:27:01 -08:00
Gordon Bergling
8460767ded mlx5: Correct a typo in a sysctl description
- s/parameteres/parameters/

(cherry picked from commit c937fb286f)
2021-12-05 10:08:07 +01:00
Gordon Bergling
abc50fc549 bce(4): Fix a typo in a sysctl description
- s/duirng/during/

(cherry picked from commit 25d0ccbe10)
2021-12-05 10:07:52 +01:00
Gordon Bergling
f51048b535 if_hn: Fix a few typos in comments and a sysctl description
- s/segement/segment/

(cherry picked from commit b15a632c41)
2021-12-03 16:54:11 +01:00
Gordon Bergling
d4c648f779 xen(4): Fix two typos in source code comments
- s/segement/segment/

(cherry picked from commit e3080a9cca)
2021-12-03 16:52:44 +01:00
Gordon Bergling
3f9dc7b20b mpr(4): Fix a typo in a source code comment
- s/segement/segment/

(cherry picked from commit ddeb702f7b)
2021-12-03 16:52:17 +01:00
Gordon Bergling
022814e08b nvme(4): Correct a typo in a sysctl description
- s/printting/printing/

(cherry picked from commit 5f8ccf6515)
2021-12-03 16:51:46 +01:00
Andriy Gapon
a138038f69 twsi: compile in support for debug messages, disabled by default
Debug messages can now be enabled per driver instance via a new sysctl.
Also, debug messages in TWSI_READ and TWSI_WRITE require debug level
greater than 1 as they are mostly redundant because callers of those
functions already log most interesting results.

NB: the twsi drivers call their device iichb, so the new sysctl will
appear under dev.iichb.N.

(cherry picked from commit a2793d6182)
2021-12-03 09:24:22 +02:00
Andriy Gapon
c141cad41d twsi: remove write-only softc field
(cherry picked from commit f00bc54f62)
2021-12-03 09:24:11 +02:00
Andriy Gapon
3b7478a7c4 twsi: add more of status definitions
For completeness and for future use.

(cherry picked from commit de86f339cd)
2021-12-03 09:23:58 +02:00
Andriy Gapon
bab53d3532 twsi: sort headers, remove unneeded
(cherry picked from commit 26559dd177)
2021-12-03 09:21:36 +02:00
Hans Petter Selasky
9e89269ee7 usb/u3g: Add support for Quectel EM05.
Pull Request:	https://github.com/freebsd/freebsd-src/pull/565
Sponsored by:	NVIDIA Networking

(cherry picked from commit 0229172a65)
2021-12-02 15:51:46 +01:00
Mark Johnston
aa5664c0f5 safexcel: Fix -Wunused-but-set-variable warnings
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 60c95f3163)
2021-12-01 07:40:49 -05:00
John Baldwin
1097f2f40d evdev: Add parentheses around '-' expression in operand of '&'.
This fixes a -Wparentheses error with GCC 9.

Reviewed by:	wulf
Differential Revision:	https://reviews.freebsd.org/D31947

(cherry picked from commit d99c87c8d5)
2021-12-01 00:45:30 +03:00
Wei Hu
d11e9de955 Hyper-V: vPCI: Prepopulate device bars
In recent Hyper-V releases on Windows Server 2022, vPCI code does not
initialize the last 4 bit of device bar registers. This behavior change
could result weird problems cuasing PCI code failure when configuring
bars.

Just write all 1's to those bars whose probed values are not the same
as current read ones. This seems to make Hyper-V vPCI and
pci_write_bar() to cooperate correctly on these releases.

Reported by:	khng@freebsd.org
Tested by:	khng@freebsd.org
MFC after:	2 weeks
Sponsored by:	Microsoft

(cherry picked from commit 75412a521f)
2021-11-30 07:43:32 +00:00
Gordon Bergling
18e627e9c7 ppbus(4): Fix a typo in source code comment
- s/quering/querying/

Obtained from:	NetBSD

(cherry picked from commit 975e2e3f84)
2021-11-28 12:43:11 +01:00