Commit graph

1183 commits

Author SHA1 Message Date
John Baldwin
62acf8a36a cxgbe tom: Compile fix for disabled KTR trace.
Sponsored by:	Chelsio Communications

(cherry picked from commit bca6e339ac)
2022-04-29 16:10:58 -07:00
John Baldwin
3b29ee793e cxgbe tom: Use VM_PAGE_TO_PHYS().
Sponsored by:	Chelsio Communications

(cherry picked from commit 87b0e7711f)
2022-04-29 16:10:43 -07:00
John Baldwin
64d35ef56a cxgbe tom: Use be64toh instead of htobe64 to convert to host order.
This is a no-op but more accurately conveys intent.

Sponsored by:	Chelsio Communications

(cherry picked from commit 44e7472d0e)
2022-04-29 16:10:34 -07:00
John Baldwin
05da0093a6 cxgbe tom: Use vm_paddr_t for physical addresses in page pod routines.
Sponsored by:	Chelsio Communications

(cherry picked from commit de414339c9)
2022-04-29 16:10:27 -07:00
John Baldwin
04e7565968 cxgbe: Move page pods KTR traces under VERBOSE_TRACES.
(cherry picked from commit 2753997438)
2022-04-29 16:09:53 -07:00
John Baldwin
ca0ad465d1 cxgbei: Replace worker thread pools with per-connection kthreads.
Having a single pool of worker threads adds extra complexity and
overhead.  The software backend also uses per-connection kthreads.

Sponsored by:	Chelsio Communications

(cherry picked from commit 511b83b167)
2022-04-29 16:09:02 -07:00
John Baldwin
17c0d2d43a cxgbei: Dispatch sent PDUs to the NIC asynchronously.
Previously the driver was called to send PDUs to the NIC synchronously
from the icl_conn_pdu_queue_cb callback.  However, this performed a
fair bit of work while holding the icl connection lock.  Instead,
change the callback to add sent PDUs to a STAILQ and defer dispatching
of PDUs to the NIC to a helper thread similar to the scheme used in
the TCP iSCSI backend.

- Replace rx_flags int and the sole RXF_ACTIVE flag with a simple
  rx_active bool.

- Add a pool of transmit worker threads for cxgbei.

- Fix worker thread exit to depend on the wakeup in kthread_exit()
  to fix a race with module unload.

Reported by:	mav
Sponsored by:	Chelsio Communications

(cherry picked from commit fd8f61d6e9)
2022-04-29 16:08:35 -07:00
John Baldwin
05d87fdb32 cxgbei: Rework parsing of pre-offload PDUs.
sbcut() returns mbufs in reverse order so is not suitable for reading
data from the socket buffer.  Instead, check for already-received data
in the receive worker thread before passing offload PDUs up to the
iSCSI layer.  This uses soreceive() to read data from the socket and
is also to use M_WAITOK since it now runs from a worker thread instead
of an interrupt thread.

Also, fix decoding of the data segment length for pre-offload PDUs.

Reported by:	Jithesh Arakkan @ Chelsio
Fixes:		a8c4147edc cxgbei: Parse all PDUs received prior to enabling offload mode.
Sponsored by:	Chelsio Communications

(cherry picked from commit 74fea8eb4f)
2022-04-29 16:06:48 -07:00
John Baldwin
b08a08f24d cxgbei: Parse all PDUs received prior to enabling offload mode.
Previously this would only handle a single PDU that did not contain
any data.  This should now handle an arbitrary number of PDUs.

While here check for these PDUs in the T6-specific CPL_RX_ISCSI_CMP
handler in addition to CPL_RX_ISCSI_DDP.

Reported by:	Jithesh Arakkan @ Chelsio
Sponsored by:	Chelsio Communications

(cherry picked from commit a8c4147edc)
2022-04-29 16:03:49 -07:00
John Baldwin
12978b1c99 ccr: Use a software OCF session for requests which fallback to software.
Previously the driver duplicated code from cryptosoft.c to handle
certain edge case AES-CCM and AES-GCM requests.  However, this
approach has a few downsides:

1) It only uses "plain" software and not accelerated software since it
   uses enc_xform directly.

2) It performs the operation synchronously even though the caller
   believes it is invoking an async driver.  This was fine for the
   original use case of requests with only AAD and no payload that
   execute quickly, but is a bit more disingenuous for large requests
   which fall back due to exceeding the size of a firmware work
   request (e.g. due to large scatter/gather lists).

3) It has required several updates since ccr(4) was added to the tree.

Instead, allocate a software session for AES-CCM and AES-GCM sessions
and dispatch a cloned request asynchronusly to the software session.

Reviewed by:	markj
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D33608

(cherry picked from commit e43cf698d9)
2022-04-29 15:50:29 -07:00
John Baldwin
745c280c89 cxgbei: Don't fail task setup if the socket is disconnected.
When the initiator is reconnecting to the target, the connection may
temporarily be marked disconnected or not have an associated socket.
New I/O requests received by the initiator in this state should not
fail with ECONNRESET as that results in an I/O error back to userland.
Instead, they need to still succeed so that CAM can queue the requests
and send them once the connection is re-established.

Setting up DDP for zero-copy receive requires a socket, so just punt
on using DDP for these transfers.

Reported by:	Jithesh Arakkan @ Chelsio
Sponsored by:	Chelsio Communications

(cherry picked from commit 752e211e64)
2022-04-29 14:18:22 -07:00
John Baldwin
fe0172025f ccr: Replace 'blkcipher' with just 'cipher'.
ccr(4) can handle requests for AES-CTR (a stream cipher), not just
block ciphers, so make the function and structure names more generic.

Sponsored by:	Chelsio Communications

(cherry picked from commit 762f1dcb1c)
2022-04-29 14:11:04 -07:00
John Baldwin
a41ff1661b crypto: Validate AES-GCM IV length in check_csp().
This centralizes the check for valid nonce lengths for AES-GCM.

While here, remove some duplicate checks for valid AES-GCM tag lengths
from ccp(4) and ccr(4).

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33194

(cherry picked from commit 6e17a2e00d)
2022-04-29 13:50:04 -07:00
Gordon Bergling
3d96164764 cxgbe(4): Fix a typo in a source code comment
- s/simultaniously/simultaneously/

(cherry picked from commit 8a1b8cf4be)
2022-04-14 08:12:50 +02:00
Gordon Bergling
5e25365d2b cxgbe(4): Fix a typo in a source code comment
- s/commmand/command/

(cherry picked from commit 5ee87525a8)
2022-04-09 08:13:42 +02:00
Andrew Gallatin
392d7f0269 cxgbe: fix enabling lro & rxtimestamps
A recent change caused iq flags, like LRO, to be set before
init_iq(). However, init_iq() clears those flags, so they
became effectively impossible to set.   This change moves
the initializion of these flags to after the call to init_iq().
This fixes LRO.

Differential Revision: https://reviews.freebsd.org/D30460
Reviewed by: np, rrs
Sponsored by: Netflix
Fixes: 43bbae1948

(cherry picked from commit df8437a93d)
2022-04-04 11:57:15 -07:00
Gordon Bergling
42a2373d22 cxgbe(4): Fix a typo in a source code comment
- s/begining/beginning/

(cherry picked from commit c9023cf7fe)
2022-04-02 15:29:40 +02:00
Navdeep Parhar
8c711d0aa2 cxgbe(4): Handle FORCE_FEC in pcaps correctly.
The firmware doesn't report FORCE_FEC in pcaps if the transceiver
plugged in at that time does not support a speed that may use FEC.  It
is incorrect for the driver to assume that the FORCE_FEC value it read
during attach (in init_link_config) is permanent.  Instead, it should
check pcaps just before issuing the L1CFG command.

Sponsored by:	Chelsio Communications

(cherry picked from commit 231f211240)
2022-04-01 18:49:43 -07:00
Navdeep Parhar
82386f825e cxgbe(4): Allow dump_cimla and dump_devlog to sleep.
This has been safe since e9e7bc8250, which moved parts of error
handling from the ithread to a taskqueue.

Sponsored by:	Chelsio Communications

(cherry picked from commit 41c4e1c7f7)
2022-04-01 18:48:52 -07:00
Navdeep Parhar
8824cbace3 cxgbe(4): dump_devlog should never fail silently.
Do the same thing as dump_cimla and log a warning on failure.

Sponsored by:	Chelsio Communications

(cherry picked from commit 9282f04ff0)
2022-03-09 14:45:11 -08:00
Navdeep Parhar
84195600d1 cxgbe(4): Dump some more debug registers in cim_dump_regs.
Sponsored by:	Chelsio Communications

(cherry picked from commit 17f564a784)
2022-03-04 16:37:28 -08:00
Navdeep Parhar
de6c7392d0 cxgbe(4): Changes to the fatal error handler.
* New error_flags that can be used from the error ithread and elsewhere
  without a synch_op.
* Stop the adapter immediately in t4_fatal_err but defer most of the
  rest of the handling to a task.  The task is allowed to sleep, unlike
  the ithread.  Remove async_event_task as it is no longer needed.
* Dump the devlog, CIMLA, and PCIE_FW exactly once on any fatal error
  involving the firmware or the CIM block.  While here, dump some
  additional info (see dump_cim_regs) for these errors.
* If both reset_on_fatal_err and panic_on_fatal_err are set then attempt
  a reset first and do not panic the system if it is successful.

Sponsored by:	Chelsio Communications

(cherry picked from commit e9e7bc8250)
2022-03-02 14:08:33 -08:00
Navdeep Parhar
d30946f4ad cxgbe(4): Fix build warning for LINT-NOIP.
MFC after:	1 week
Sponsored by:	Chelsio Communications

(cherry picked from commit 94e6b3fee1)
2022-03-02 13:28:40 -08:00
Navdeep Parhar
0a3ca84be1 cxgbe(4): Fix "set but not used [-Wunused-but-set-variable]" warnings.
Sponsored by:	Chelsio Communications

(cherry picked from commit 39d5cbdc1b)
2022-03-02 13:25:55 -08:00
Navdeep Parhar
2a13985312 cxgbe(4): Fix illegal hardware access in cxgbe_refresh_stats.
cxgbe_refresh_stats takes into account VI_SKIP_STATS but not
VI_INIT_DONE when deciding whether to read the hardware stats.  But
before this change VI_SKIP_STATS was set only for VIs with VI_INIT_DONE.
That meant that cxgbe_refresh_stats always accessed the hardware for
uninitialized VIs, and this is a problem if the adapter is suspended or
in the middle of a reset.

Fix this by setting VI_SKIP_STATS on all VIs during suspend.  While
here, ignore VI_INIT_DONE in vi_refresh_stats too to be consistent with
cxgbe_refresh_stats.

Sponsored by:	Chelsio Communications

(cherry picked from commit 08c7dc7fd4)
2022-02-27 22:51:51 -08:00
Navdeep Parhar
2f733c60ff cxgbe(4): Avoid unsafe hardware access in the ifmedia ioctls.
The hardware is unavailable when the device is suspended or in the
middle of a reset.

Sponsored by:	Chelsio Communications

(cherry picked from commit 39a36707bd)
2022-02-27 22:51:32 -08:00
Navdeep Parhar
e005d417a2 cxgbe(4): Fix bad races between sysctl and driver detach.
The default sysctl context setup by newbus for a device is eventually
freed by device_sysctl_fini, which runs after the device driver's detach
routine.  sysctl nodes associated with this context must not use any
resources (like driver locks, hardware access, counters, etc.) that are
released by driver detach.

There are a lot of sysctl nodes like this in cxgbe(4) and the fix is to
hang them off a context that is explicitly freed by the driver before it
releases any resource that might be used by a sysctl.

This fixes panics when running "sysctl dev.t6nex dev.cc" in a tight loop
and loading/unloading the driver in parallel.

Reported by:	Suhas Lokesha
Sponsored by:	Chelsio Communications

(cherry picked from commit a727d9531a)
2022-02-27 22:51:04 -08:00
Navdeep Parhar
c50239ee30 cxgbe(4): Fix regression in previous attempt to fix FEC selection.
Sponsored by:	Chelsio Communications

(cherry picked from commit d0ff9b029c)
2022-02-27 22:50:29 -08:00
Navdeep Parhar
509de5dc8a cxgbe(4): Do not ignore the return value of ifmedia_ioctl.
This ensures that the driver reports an error instead of failing
silently when an invalid media is requested.

Reported by:	Suhas Lokesha @ Chelsio
Sponsored by:	Chelsio Communications

(cherry picked from commit cdd7fe04cb)
2022-02-27 22:50:03 -08:00
Navdeep Parhar
438b835285 cxgbe(4): Do not request an FEC that is invalid for the requested speed.
This eliminates error messages like this from the driver when running at
50Gbps with 100G cables:
[3726] cc0: l1cfg failed: 71
[4407] cc0: l1cfg failed: 71

Note that link comes up anyway with or without this change.

Reported by:	Suhas Lokesha @ Chelsio
Sponsored by:	Chelsio Communications

(cherry picked from commit f3c2987f2f)
2022-02-27 22:48:49 -08:00
Navdeep Parhar
86b0782a37 cxgbe(4): Update firmwares to 1.26.6.0.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
CHANGES
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Version : 1.26.6.0
Date    : 01/03/2022
================================================================================

Fixes
-----
BASE:
- Fixed one module eeprom read failure.
- Fixed an issue with speed selection when 40G and 25G are advertised and
  supported.
- Fixed a random traffic hang when T5 receives invalid ets BW in dcbx
  messages from a switch.
- Fixed very long link up time with few switches.
================================================================================

Obtained from:	Chelsio Communications
Sponsored by:	Chelsio Communications

(cherry picked from commit 3b76242433)
2022-02-27 22:48:07 -08:00
Navdeep Parhar
cfe1193f5f cxgbe(4): Fix stats collection for ports with port_id != tx_chan
This fixes a driver panic during stats collection when a port's id does
not match its tx channel.  The bug affected only the T580 card running
with a non-default VPD.

Reported by:	Suhas Lokesha @ Chelsio
Sponsored by:	Chelsio Communications

(cherry picked from commit bbab9ab579)
2022-02-27 22:47:42 -08:00
Navdeep Parhar
b6c0d81f7d cxgbe(4): Fix panic on driver detach after a partially failed attach.
sge->ctrlq is not always allocated during attach (eg. if firmware
initialization fails) and detach should be able to deal with this.

Sponsored by:	Chelsio Communications

(cherry picked from commit b99651c52f)
2022-02-27 22:47:19 -08:00
Navdeep Parhar
6be5e07275 cxgbe(4): Update firmwares to 1.26.4.0
(Rest is from the README that came with the firmware)

Version : 1.26.4.0
Date    : 12/02/2021

Fixes
-----

BASE:
- Fixed error on setting 25G speed on 100G copper with multiple FEC set in
  firmware commands.
- Handle link of unknown optics modules by enabling module tx unconditionally.
- Fixed link not coming up for 25G CRS phys. Firmware incorrectly tried to
  bring up the link in RS-FEC but as per IEEE spec, it must be BASER FEC.
- Fixed an issue where firmware doesn't automatically retry next FEC if driver
  asks to bring up the link using RS-FEC and link doesn't come up.

Obtained from:	Chelsio Communications
Sponsored by:	Chelsio Communications

(cherry picked from commit 357ba2cf17)
2022-02-27 22:46:38 -08:00
Navdeep Parhar
e804d75c13 cxgbe(4): Change the way t4_shutdown_adapter brings the link(s) down.
Modify the GPIO pins only on the Base-T cards and even there drive all
of them low instead of putting them in hi-z state.  For the rest (this
is the common case), directly power off the PLLs of the high speed
serdes.  This is the simplest method that does not involve or conflict
with the firmware but still works with all T4-T6 cards regardless of
what's plugged into the port.

This fixes a problem where the peer wouldn't always see a link down if
it is connected to the device using a -CR4 copper cable.

Sponsored by:	Chelsio Communications

(cherry picked from commit a8eacf9329)
2022-02-27 22:45:48 -08:00
Navdeep Parhar
f4592cd2a4 cxgbe(4): Keep link configuration compatible with really old firmwares.
Sponsored by:	Chelsio Communications

(cherry picked from commit 8e76bae0b7)
2022-02-27 22:45:20 -08:00
Navdeep Parhar
3db50d924d cxgbe(4): internal knob for flexible control over FEC selection.
Recent firmwares have support for autonomous FEC selection and a "force"
knob to let the driver control this behavior (or not) in a fine grained
manner. This change adds a driver knob so that all the different ways of
configuring the link FEC can be exercised. Note that this controls the
internal driver/firmware interaction for link configuration and is not
meant for general use.

Sponsored by:	Chelsio Communications

(cherry picked from commit 448bcd01dc)
2022-02-27 22:44:51 -08:00
Navdeep Parhar
512eb6235f cxgbe(4): separate sysctls for user-requested and in-use FEC.
Recent firmwares have more leeway in FEC selection and there is a need
to track the FECs requested by the driver separately from the FEC in use
on the link. The existing dev.<port>.<inst>.fec sysctl can read both but
its behavior depends on the link state and it is sometimes hard to find
out what was requested when the link is up.

Split the fec sysctl into two (requested_fec and link_fec) to get access
to both pieces of information regardless of the link state.

Sponsored by:	Chelsio Communications

(cherry picked from commit f6a2e1100f)
2022-02-27 22:43:59 -08:00
Navdeep Parhar
5f328e9e3f cxgbe(4): sysctl to track the last L1_CFG32 requested by the driver.
dev.<port>.<inst>.rcaps

 # sysctl dev.cc | grep rcaps
 dev.cc.1.rcaps: 581107776
 dev.cc.0.rcaps: 582156414

Sponsored by:	Chelsio Communications

(cherry picked from commit d99b1d83b9)
2022-02-27 22:42:32 -08:00
John Baldwin
d8feb950a6 Move the ICL_CONN_*LOCK* macros to <dev/iscsi/icl.h>.
These macros are not backend-specific but reference a
backend-independent field in struct icl_conn.

Reviewed by:	mav
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D32858

(cherry picked from commit e900338c09)
2021-11-23 15:11:53 -08:00
John Baldwin
ff590791ff cxgbe: Only run ktls_tick when NIC TLS is enabled.
Previously the body of ktls_tick was a nop when NIC TLS was disabled,
but the callout was still scheduled consuming power on otherwise-idle
systems with Chelsio T6 adapters.  Now the callout only runs while NIC
TLS is enabled on at least one interface of an adapter.

Reported by:	mav
Reviewed by:	np, mav
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D32491

(cherry picked from commit ef3f98ae47)
2021-11-23 15:11:43 -08:00
John Baldwin
5767c8ca4c cxgbei: Only convert "plain" TCP connections to ISCSI.
Reject attempts to convert a connection using a different ULP
mode: (e.g. DDP or TLS) to ISCSI.

Reported by:	Jithesh Arakkan @ Chelsio
Sponsored by:	Chelsio Communications

(cherry picked from commit f63ddf465f)
2021-10-29 16:37:11 -07:00
John Baldwin
ed2a5ae6aa cxgbei: Return early for EBUSY error in icl_cxgbei_conn_handoff.
This permits unindenting almost half of the function.

Sponsored by:	Chelsio Communications

(cherry picked from commit b7caa81576)
2021-10-29 16:36:10 -07:00
John Baldwin
56bc3b1a95 cxgbei: Disable ISO for -SO cards without external memory.
Reported by:	Jithesh Arakkan @ Chelsio
Sponsored by:	Chelsio Communications

(cherry picked from commit 9b1bb0aee6)
2021-10-29 16:35:15 -07:00
John Baldwin
075c8d9db3 cxgbei: Handle errors in PDUs.
When a PDU with an error (bad padding, header digest, or data digest)
is received, log the error via ICL_WARN() and then reset the
connection via the ic_error callback.

While here, add per-rxq counters for errors.

Sponsored by:	Chelsio Communications

(cherry picked from commit 4d4cf62e29)
2021-10-29 16:34:01 -07:00
John Baldwin
a75428c375 cxgbei: Add sysctls to report the maximum data segment lengths.
These sysctls report the maximum data segment lengths supported by an
adapter.  These are the values advertised to the remote end during the
login phase.

Sponsored by:	Chelsio Communications

(cherry picked from commit d39e65b5bd)
2021-10-29 16:33:14 -07:00
John Baldwin
d724218a74 cxgbei: Limit T5 transmit data segments to 15k.
This avoids exceeding a limit in the firmware when using ISO with
jumbo frames.

Reported by:	Jithesh Arakkan @ Chelsio
Sponsored by:	Chelsio Communications

(cherry picked from commit 64f09f2346)
2021-10-29 16:32:24 -07:00
John Baldwin
51983604da iscsi: Teach the iSCSI stack about "large" received PDUs.
When using iSCSI PDU offload (cxgbei) on T6 adapters, a burst of
received PDUs can be reported via a single message to the driver.

Previously the driver passed these multi-PDU bursts up to the iSCSI
stack up as a single "large" PDU by rewriting the buffer offset, data
segment length, and DataSN fields in the iSCSI header.  The DataSN
field in particular was rewritten so that each of the "large" PDUs
used consecutively increasing values.  While this worked, the forged
DataSN values did not match the ExpDataSN value in the subsequent SCSI
Response PDU.  The initiator does not currently verify this value, but
the forged DataSN values prevent adding a check.

To avoid this, allow a logical iSCSI PDU (struct icl_pdu) to describe
a burst of PDUs via a new 'ip_additional_pdus' field.  Normally this
field is set to zero when 'struct icl_pdu' represents a single PDU.
If logical PDU represents a burst of on-the-wire PDUs, then 'ip_npdus'
contains the count of additional on-the-wire PDUs.  The header of this
"large" PDU is still modified, but the DataSN field now contains the
DataSN value of the first on-the-wire PDU in the burst.

Reviewed by:	mav
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D31577

(cherry picked from commit c261b6ea4e)
2021-10-29 16:30:51 -07:00
John Baldwin
0967aa717d cxgbei: Restrict received PDUs to 4 DDP pages in length.
Reviewed by:	np
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D31576

(cherry picked from commit d75b0870e5)
2021-10-29 16:30:43 -07:00
John Baldwin
da92c273d5 cxgbei: Only round PDU data segment lengths down by 512 on T5.
Reviewed by:	np
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D31575

(cherry picked from commit f28715fdc1)
2021-10-29 16:29:49 -07:00