Commit graph

1076 commits

Author SHA1 Message Date
Navdeep Parhar
6e405dd9e4 cxgbe(4): Remove some dead code.
(cherry picked from commit 3965469eaa)
2021-07-26 10:49:25 -07:00
Hans Petter Selasky
47f7e8e423 ibcore: Declare ib_post_send() and ib_post_recv() arguments const
Since neither ib_post_send() nor ib_post_recv() modify the data structure
their second argument points at, declare that argument const. This change
makes it necessary to declare the 'bad_wr' argument const too and also to
modify all ULPs that call ib_post_send(), ib_post_recv() or
ib_post_srq_recv(). This patch does not change any functionality but makes
it possible for the compiler to verify whether the
ib_post_(send|recv|srq_recv) really do not modify the posted work request.

Linux commit:
f696bf6d64b195b83ca1bdb7cd33c999c9dcf514
7bb1fafc2f163ad03a2007295bb2f57cfdbfb630
d34ac5cd3a73aacd11009c4fc3ba15d7ea62c411

Reviewed by:	kib
Sponsored by:	Mellanox Technologies // NVIDIA Networking

(cherry picked from commit c3987b8ea7)
2021-07-26 18:04:32 +02:00
Bjoern A. Zeeb
0bbb50ec87 cxgbe: remove unused linux headers
Remove unused #includes of LinuxKPI headers noticed while trying to
solve LinuxKPI struct net_device and related functions.
Neither netdevice.h nor inetdevice.h nor notifier.h seem to be needed.
This takes cxgbe(4) out of the picture of D29366.

Sponsored by:	The FreeBSD Foundation
Reviewed by:	np
Differential Revision:	https://reviews.freebsd.org/D29432

(cherry picked from commit 0a7b99553f)
2021-07-18 00:34:59 +00:00
Navdeep Parhar
1f9df724eb cxgbe(4): Use ifaddr_event_ext instead of ifaddr_event for CLIP management.
The _ext event notification includes the address being added/removed and
that gives the driver an easy way to ignore non-IPv6 addresses.  Remove
'tom' from the handler's name while here, it was moved out of t4_tom a
long time ago.

Sponsored by:	Chelsio Communications

(cherry picked from commit f4ba035bca)
2021-05-15 20:45:59 -07:00
Navdeep Parhar
8f7d958766 cxgbe(4): Do not panic when tx is called with invalid checksum requests.
There is no need to panic in if_transmit if the checksums requested are
inconsistent with the frame being transmitted.  This typically indicates
that the kernel and driver were built with different INET/INET6 options,
or there is some other kernel bug.  The driver should just throw away
the requests that it doesn't understand and move on.

Sponsored by:	Chelsio Communications

(cherry picked from commit b9820bca18)
2021-05-15 20:44:46 -07:00
Navdeep Parhar
1c0a5613ac cxgbe(4): hw.cxgbe.panic_on_fatal_err can be changed any time.
Sponsored by:	Chelsio Communications

(cherry picked from commit 50f5d13eeb)
2021-05-15 20:37:37 -07:00
Navdeep Parhar
294591a4b7 cxgbe(4): Move the hw-specific parts of VXLAN setup to a separate function.
It can be called to (re)apply the settings in the driver softc to the
hardware.

Sponsored by:	Chelsio Communications

(cherry picked from commit 5f00292fe3)
2021-05-15 20:36:13 -07:00
Navdeep Parhar
7d984fe000 cxgbe(4): Add flag to reliably stop the driver from accessing hw stats.
There are two kinds of routines in the driver that read statistics from
the hardware: the cxgbe_* variants read the per-port MPS/MAC registers
and the vi_* variants read the per-VI registers.  They can be called
from the 1Hz callout or if_get_counter.  All stats collection now takes
place under the callout lock and there is a new flag to indicate that
these routines should not access any hardware register.

Sponsored by:	Chelsio Communications

(cherry picked from commit b47b28e5b2)
2021-05-15 20:34:01 -07:00
Navdeep Parhar
8b8b659f39 cxgbe(4): RSS hash for VXLAN traffic is computed from the inner frame.
Sponsored by:	Chelsio Communications

(cherry picked from commit d107ee06f3)
2021-05-15 20:28:50 -07:00
Navdeep Parhar
b7259437d5 cxgbe(4): Fix minor nit in the display of MPS TCAM entries.
(cherry picked from commit dc77e79296)
2021-05-15 20:26:58 -07:00
Navdeep Parhar
9b107d9ef4 cxgbe(4): make the logging helpers a little more robust.
Sponsored by:	Chelsio Communications

(cherry picked from commit 8f1bc78ef7)
2021-05-15 20:26:22 -07:00
Navdeep Parhar
81ec0d0546 cxgbe/tom: Fix potential leak in t4_aiotx_process_job.
The mbuf allocated could be a chain and must be freed with m_freem.

Reviewed by:	jhb@
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D29579

(cherry picked from commit bf5057691b)
2021-05-15 20:24:06 -07:00
Navdeep Parhar
e0897d6669 cxgbe(4): Always use the per-VI callout to read interface stats.
There is no change in the source of the stats (t4_get_port_stats or
t4_get_vi_stats) but the per-port callout is gone.

Sponsored by:	Chelsio Communications
Reviewed by:	jhb@
Differential Revision:	https://reviews.freebsd.org/D29527

(cherry picked from commit 516fe911a6)
2021-05-15 20:21:58 -07:00
Navdeep Parhar
248bc9784a cxgbe/t4_tom: restore socket's protosw before entering TIME_WAIT.
This fixes a panic due to stale so->so_proto if t4_tom is unloaded and
one or more connections that were previously offloaded are still around
in TIME_WAIT state.

Reviewed by:	jhb@
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D29503

(cherry picked from commit 5394893269)
2021-05-15 20:18:42 -07:00
Navdeep Parhar
95a3005326 cxgbe(4): Allow a T6 adapter to switch between TOE and NIC TLS mode.
The hw.cxgbe.kern_tls tunable was used for this in the past and if it
was set then all T6 adapters would be configured for NIC TLS operation
and could not be reconfigured for TOE without a reload.  With this
change ifconfig can be used to manipulate toe and txtls caps like any
other caps.  hw.cxgbe.kern_tls continues to work as usual but its
effects are not permanent any more.

* Enable nic_ktls_ofld in the default configuration file and use the
  firmware instead of direct register manipulation to apply/rollback
  NIC TLS configuration.  This allows the driver to switch the hardware
  between TOE and NIC TLS mode in a safe manner.  Note that the
  configuration is adapter-wide and not per-port.

* Remove the kern_tls config file as it works with 100G T6 cards only
  and leads to firmware crashes with 25G cards.  The configurations
  included with the driver (with the exception of the FPGA configs) are
  supposed to work with all adapters.

Reported by:	Veeresh U.K. at Chelsio
Sponsored by:	Chelsio Communications
Reviewed by:	jhb@
Differential Revision: https://reviews.freebsd.org/D29291

(cherry picked from commit 15f3355567)
2021-05-15 20:12:11 -07:00
Navdeep Parhar
139c8bd6f3 cxgbe(4): create a separate helper routine to write the global RSS key.
While here, make sure only the PF driver attempts to program the global
RSS key (with options RSS).  The VF driver doesn't have access to those
device registers.

Sponsored by:	Chelsio Communications

(cherry picked from commit 3cc6f777be)
2021-05-15 20:10:57 -07:00
Navdeep Parhar
d9eb1e0c90 cxgbe(4): make it safe to call setup_memwin repeatedly.
A repeat call will recreate the memory windows in the hardware and move
them to their last-known positions without repeating any of the software
initialization.

Sponsored by:	Chelsio Communications

(cherry picked from commit a1d803c162)
2021-05-15 20:08:51 -07:00
Navdeep Parhar
564d1f6aef cxgbe(4): use standard sysctl routines to deal with 16b values.
These routines to handle 8b and 16b types were added in r289773 5+ years
ago.

Sponsored by:	Chelsio Communications

(cherry picked from commit 473f6163e3)
2021-05-15 20:06:35 -07:00
Navdeep Parhar
af1edd87f6 cxgbe(4): catch up with the latest cryptocaps.
There are two crypto capabilities that the driver didn't know about.

Sponsored by:	Chelsio Communications

(cherry picked from commit 0b373f26be)
2021-05-15 20:02:40 -07:00
Navdeep Parhar
9b9bd93450 cxgbe(4): Remove extra blank line.
No functional change.

(cherry picked from commit 765d623d60)
2021-05-15 20:01:55 -07:00
Navdeep Parhar
7f68191760 cxgbe(4): Fix an assertion that is not valid during attach.
Firmware access from t4_attach takes place without any synchronization.
The driver should not panic (debug kernels) if something goes wrong in
early communication with the firmware.  It should still load so that
it's possible to poke around with cxgbetool.

Sponsored by:	Chelsio Communications

(cherry picked from commit 4a4e9c516c)
2021-05-15 20:01:07 -07:00
Navdeep Parhar
d314a9f279 cxgbe(4): Use the correct filter width for T5+.
T5 and above have extra bits for the optional filter fields.  This is a
correctness issue and not just a waste because a filter mode valid on a
T4 (36b) may not be valid on a T5+ (40b).

Sponsored by:	Chelsio Communications

(cherry picked from commit 0460a45062)
2021-05-15 19:54:17 -07:00
Navdeep Parhar
a8076e0afd cxgbe(4): Add a driver ioctl to set the filter mask.
Allow the filter mask (aka the hashfilter mode when hashfilters are
in use) to be set any time it is safe to do so.  The requested mask
must be a subset of the filter mode already.  The driver will not change
the mode or ingress config just to support a new mask.

Sponsored by:	Chelsio Communications

(cherry picked from commit c91dda5ad9)
2021-05-15 19:53:07 -07:00
Navdeep Parhar
191894573b cxgbe(4): Use firmware commands to get/set filter configuration.
1. Query the firmware for filter mode, mask, and related ingress config
   instead of trying to figure them out from hardware registers.  Read
   configuration from the registers only when the firmware does not
   support this query.

2. Use the firmware to set the filter mode.  This is the correct way to
   do it and is more flexible as well.  The filter mode (and associated
   ingress config) can now be changed any time it is safe to do so.

   The user can specify a subset of a valid mode and the driver will
   enable enough bits to make sure that the mode is maxed out -- that
   is, it is not possible to set another bit without exceeding the
   total width for optional filter fields.  This is a hardware
   requirement that was not enforced by the driver previously.

Sponsored by:	Chelsio Communications

(cherry picked from commit 7ac8040a99)
2021-05-15 19:50:36 -07:00
Navdeep Parhar
e99210ab63 cxgbe(4): Break up t4_read_chip_settings.
Read the PF-only hardware settings directly in get_params__post_init.
Split the rest into two routines used by both the PF and VF drivers: one
that reads the SGE rx buffer configuration and another that verifies
miscellaneous hardware configuration.

Sponsored by:	Chelsio Communications

(cherry picked from commit fae028dd97)
2021-05-15 19:45:16 -07:00
John Baldwin
57d9ae2a44 cxgbe: Ignore doomed virtual interfaces when updating the clip table.
A doomed VI does not have a valid ifnet.

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

(cherry picked from commit 45d5c28439)
2021-04-26 12:02:28 -07:00
John Baldwin
c2e295647e cxgbe: Add counters for iSCSI PDUs transmitted via TOE.
Sponsored by:	Chelsio Communications

(cherry picked from commit 568e69e4eb)
2021-04-26 12:02:16 -07:00
John Baldwin
27395a69d1 cxgbe: Make the TOE TLS stats per-queue instead of per-port.
This avoids some atomics by using counter_u64 for TX and relying on
existing single-threading (single ithread per rxq) for RX.

Sponsored by:	Chelsio Communications

(cherry picked from commit fe496dc02a)
2021-04-26 12:02:12 -07:00
John Baldwin
4e4ec8a9cc cxgbe: Add a struct sge_ofld_txq type.
This type mirrors struct sge_ofld_rxq and holds state for TCP offload
transmit queues.  Currently it only holds a work queue but will
include additional state in future changes.

Sponsored by:	Chelsio Communications

(cherry picked from commit 077ba6a845)
2021-04-26 12:02:06 -07:00
John Baldwin
d6ee411d42 cxgbei: Enter network epoch and set vnet around t4_push_pdus().
Sponsored by:	Chelsio Communications

(cherry picked from commit 90c74b2b60)
2021-04-26 12:02:02 -07:00
John Baldwin
bcd7b64748 cxgbe ddp: Use CPL_COOKIE_DDP* instead of DDP_BUF*_INVALIDATED.
This avoids mixing the use of two different enums which modern C
compilers warn about.

Sponsored by:	Chelsio Communications

(cherry picked from commit 017902fc5f)
2021-04-26 12:01:57 -07:00
John Baldwin
345bf0b368 cxgbei: Pass ULP submode directly to set_ulp_mode_iscsi().
Sponsored by:	Chelsio Communications

(cherry picked from commit 8855ed61b5)
2021-04-26 12:01:52 -07:00
John Baldwin
278db4ba3c cxgbei: Move some function prototypes to cxgbei.h.
Sponsored by:	Chelsio Communications

(cherry picked from commit 45eed2331e)
2021-04-26 12:01:47 -07:00
John Baldwin
483bcffad7 cxgbei: Set vnet around tcp_drop() in do_rx_iscsi_ddp().
Sponsored by:	Chelsio Communications

(cherry picked from commit 52c11c3f74)
2021-04-26 12:01:40 -07:00
John Baldwin
c0b22e1468 ccr: Disable requests on port 1 when needed to workaround a firmware bug.
Completions for crypto requests on port 1 can sometimes return a stale
cookie value due to a firmware bug.  Disable requests on port 1 by
default on affected firmware.

Sponsored by:	Chelsio Communications

(cherry picked from commit 5fe0cd6503)
2021-04-26 12:01:32 -07:00
John Baldwin
ea511d5a5b ccr: Add per-port stats of queued and completed requests.
Sponsored by:	Chelsio Communications

(cherry picked from commit 9c5137beb5)
2021-04-26 12:01:27 -07:00
John Baldwin
9cdd43808c ccr: Set the RX channel ID correctly in work requests.
These fixes are only relevant for requests on the second port.  In
some cases, the crypto completion data, completion message, and
receive descriptor could be written in the wrong order.

- Add a separate rx_channel_id that is a copy of the port's rx_c_chan
  and use it when an RX channel ID is required in crypto requests
  instead of using the tx_channel_id.

- Set the correct rx_channel_id in the CPL_RX_PHYS_ADDR used to write
  the crypto result.

- Set the FID to the first rx queue ID on the adapter rather than the
  queue ID of the first rx queue for the port.

- While here, use tx_chan to set the tx_channel_id though this is
  identical to the previous value.

Reported by:	Chelsio QA
Sponsored by:	Chelsio Communications

(cherry picked from commit 8f885fd1f3)
2021-04-26 12:01:15 -07:00
Navdeep Parhar
cc76018cdd cxgbe(4): Read the rx 'c' channel for a port and make it available.
Sponsored by:	Chelsio Communications

(cherry picked from commit dfff1de729)
2021-04-26 12:01:10 -07:00
John Baldwin
8130bdab38 Handle negative return values from syncache_expand().
These errors do not clear so to NULL, so the existing check was
treating these failures as success.  The rest of do_pass_establish()
then tried to use the listen socket as if it was a connection socket
newly created by syncache_expand().

In addition, for negative return values, do not send a RST to the
peer.

Reported by:	Sony Arpita Das @ Chelsio
Sponsored by:	Chelsio Communications

(cherry picked from commit 1deaad9364)
2021-04-26 12:01:00 -07:00
Alexander Motin
c930816b76 cxgbe(4): Save proper zone index on low memory in refill_fl().
When refill_fl() fails to allocate large (9/16KB) mbuf cluster, it
falls back to safe (4KB) ones.  But it still saved into sd->zidx
the original fl->zidx instead of fl->safe_zidx.  It caused problems
with the later use of that cluster, including memory and/or data
corruption.

While there, make refill_fl() to use the safe zone for all following
clusters for the call, since it is unlikely that large succeed.

MFC after:	3 days
Sponsored by:	iXsystems, Inc.
Reviewed by:	np, jhb
Differential Revision:	https://reviews.freebsd.org/D28716

(cherry picked from commit 294e62bebf)
2021-02-22 15:51:58 -08:00
Gleb Smirnoff
97ded49cae Catch up with 6edfd179c8: mechanically rename IFCAP_NOMAP to IFCAP_MEXTPG.
Originally IFCAP_NOMAP meant that the mbuf has external storage pointer
that points to unmapped address.  Then, this was extended to array of
such pointers.  Then, such mbufs were augmented with header/trailer.
Basically, extended mbufs are extended, and set of features is subject
to change.  The new name should be generic enough to avoid further
renaming.

(cherry-picked from commit 3f43ada98c)
2021-02-08 14:33:35 -08:00
Navdeep Parhar
397aaa3bcc cxgbe(4): Fixes to tx coalescing.
- The behavior implemented in r362905 resulted in delayed transmission
  of packets in some cases, causing performance issues.  Use a different
  heuristic to predict tx requests.

- Add a tunable/sysctl (hw.cxgbe.tx_coalesce) to disable tx coalescing
  entirely.  It can be changed at any time.  There is no change in
  default behavior.

(cherry picked from commit 3447df8bc5)
2021-02-04 09:43:36 -08:00
Mateusz Guzik
6b3a9a0f3d Convert remaining cap_rights_init users to cap_rights_init_one
semantic patch:

@@

expression rights, r;

@@

- cap_rights_init(&rights, r)
+ cap_rights_init_one(&rights, r)
2021-01-12 13:16:10 +00:00
John Baldwin
6727847500 Don't try to adjust a TLS TOE socket that has been closed.
The handshake timer can race with another thread sending a FIN or RST
to close a TOE TLS socket.  Just bail from the timer without
rescheduling if the connection is closed when the timer fires.

Reported by:	Sony Arpita Das @ Chelsio QA
Reviewed by:	np
Differential Revision:	https://reviews.freebsd.org/D27583
2020-12-30 09:56:24 -08:00
Toomas Soome
40c4557bee cxgbe: replace zero sized array by flexible array
The issue was found while building cxgbe with gcc 10 (in illumos),
the array subscription check is warning us about outside the bounds
access.

See also: https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
2020-12-29 23:09:15 +02:00
John Baldwin
0082e479ef Clear TLS offload mode if a TLS socket hangs without receiving data.
By default, if a TOE TLS socket stops receiving data for more than 5
seconds, revert the connection back to plain TOE mode.  This provides
a fallback if the userland SSL library does not support KTLS.  In
addition, for client TLS 1.3 sockets using connect(), the TOE socket
blocks before the handshake has completed since the socket option is
only invoked for the final handshake.

The timeout defaults to 5 seconds, but can be changed at boot via the
hw.cxgbe.toe.tls_rx_timeout tunable or for an individual interface via
the dev.<nexus>.toe.tls_rx_timeout sysctl.

Reviewed by:	np
MFC after:	2 weeks
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D27470
2020-12-03 22:06:08 +00:00
Navdeep Parhar
180c2dca4e cxgbe(4): Fix vertical alignment in sysctl_cpl_stats.
MFC after:	3 days
Sponsored by:	Chelsio Communications
2020-12-03 22:04:23 +00:00
John Baldwin
99963f5343 Don't transmit mbufs that aren't yet ready on TOE sockets.
This includes mbufs waiting for data from sendfile() I/O requests, or
mbufs awaiting encryption for KTLS.

Reviewed by:	np
MFC after:	2 weeks
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D27469
2020-12-03 22:01:13 +00:00
Navdeep Parhar
dbc5c85c66 cxgbe(4): two new debug sysctls.
dev.<nexus>.<instance>.misc.tid_stats
dev.<nexus>.<instance>.misc.tnl_stats

MFC after:	3 days
Sponsored by:	Chelsio Communications
2020-12-03 22:00:41 +00:00
John Baldwin
a42f096821 Clear TLS offload mode for unsupported cipher suites and versions.
If TOE TLS is requested for an unsupported cipher suite or TLS
version, disable TLS processing and fall back to plain TOE.  In
addition, if an error occurs when saving the decryption keys in the
card's memory, disable TLS processing and fall back to plain TOE.

Reviewed by:	np
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D27468
2020-12-03 21:59:47 +00:00