Commit Graph

1081 Commits

Author SHA1 Message Date
John Baldwin
87bb5ed606 cxgbei: Use hardware RX flow control for offloaded iSCSI connections.
Forthcoming T6 iSCSI DDP support requires hardware RX flow control.

Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D29905
2021-05-14 12:16:51 -07:00
John Baldwin
4427ac3675 cxgbe tom: Set the tid in the work requests to program page pods for iSCSI.
As a result, CPL_FW4_ACK now returns credits for these work requests.
To support this, page pod work requests are now constructed in special
mbufs similar to "raw" mbufs used for NIC TLS in plain TX queues.
These special mbufs are stored in the ulp_pduq and dispatched in order
with PDU work requests.

Sponsored by:	Chelsio Communications
Discussed with:	np
Differential Revision:	https://reviews.freebsd.org/D29904
2021-05-14 12:16:40 -07:00
John Baldwin
4b6ed0758d cxgbe: Make the TOE ISCSI RX stats per-queue instead of per adapter.
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D29903
2021-05-14 12:16:33 -07:00
Navdeep Parhar
f4ba035bca 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.

MFC after:	1 week
Sponsored by:	Chelsio Communications
2021-05-04 20:16:25 -07:00
Navdeep Parhar
b9820bca18 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.

MFC after:	1 week
Sponsored by:	Chelsio Communications
2021-04-28 14:04:53 -07:00
Navdeep Parhar
83b5cda106 cxgbe(4): Add support for NIC suspend/resume and live reset.
Add suspend/resume callbacks to the driver and a live reset built around
them.  This commit covers the basic NIC and future commits will expand
this functionality to other stateful parts of the chip.  Suspend and
resume operate on the chip (the t?nex nexus device) and affect all its
ports.  It is not possible to suspend/resume or reset individual ports.
All these operations can be performed on a running NIC.  A reset will
look like a link bounce to the networking stack.

Here are some ways to exercise this functionality:

 /* Manual suspend and resume. */
 # devctl suspend t6nex0
 # devctl resume t6nex0

 /* Manual reset. */
 # devctl reset t6nex0

 /* Manual reset with driver sysctl. */
 # sysctl dev.t6nex.0.reset=1

 /* Automatic adapter reset on any fatal error. */
 # hw.cxgbe.reset_on_fatal_err=1

Suspend disables the adapter (DMA, interrupts, and the port PHYs) and
marks the hardware as unavailable to the driver.  All ifnets associated
with the adapter are still visible to the kernel but operations that
require hardware interaction will fail with ENXIO.  All ifnets report
link-down while the adapter is suspended.

Resume will reattach to the card, reconfigure it as before, and recreate
the queues servicing the existing ifnets.  The ifnets are able to send
and receive traffic as soon as the link comes back up.

Reset is roughly the same as a suspend and a resume with at least one of
these events in between: D0->D3Hot->D0, FLR, PCIe link retrain.

MFC after:	1 month
Relnotes:	yes
Sponsored by:	Chelsio Communications
2021-04-27 22:48:51 -07:00
Navdeep Parhar
43bbae1948 cxgbe(4): Separate the sw- and hw-specific parts of resource allocations
The driver uses both software resources (locks, callouts, memory for
descriptors and for bookkeeping, sysctls, etc.) and hardware resources
(VIs, DMA queues, TCAM entries, etc.) to operate the NIC.  This commit
splits the single *_ALLOCATED flag used to track all these resources
into separate *_SW_ALLOCATED and *_HW_ALLOCATED flags.

This is the simplified pseudocode that now applies to most queues (foo
can be ctrlq/txq/rxq/ofld_txq/ofld_rxq):

/* Idempotent */
alloc_foo
{
	if (!SW_ALLOCATED)
		init_iq/init_eq/init_fl		no-fail sw init
		alloc_iq_fl/alloc_eq/alloc_wrq	may-fail sw alloc
		add_foo_sysctls, etc.		no-fail post-alloc items
	if (!HW_ALLOCATED)
		alloc_iq_fl_hwq/alloc_eq_hwq	hw resource allocation
}

/* Idempotent */
free_foo
{
	if (!HW_ALLOCATED)
		free_iq_fl_hwq/free_eq_hwq	release hw resources
	if (!SW_ALLOCATED)
		free_iq_fl/free_eq/free_wrq	release sw resources
}

The routines that take the driver to FULL_INIT_DONE and VI_INIT_DONE and
back are now all idempotent.  The quiesce routines pay attention to the
HW_ALLOCATED flag and will not wait on the hardware for pidx/cidx
updates and other completions if this flag is not set.

MFC after:	1 month
Sponsored by:	Chelsio Communications
2021-04-26 14:09:59 -07:00
Navdeep Parhar
50f5d13eeb cxgbe(4): hw.cxgbe.panic_on_fatal_err can be changed any time.
MFC after:	2 weeks
Sponsored by:	Chelsio Communications
2021-04-23 12:17:54 -07:00
Navdeep Parhar
5f00292fe3 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.

MFC after:	2 weeks
Sponsored by:	Chelsio Communications
2021-04-23 00:26:47 -07:00
Navdeep Parhar
b47b28e5b2 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.

MFC after:	2 weeks
Sponsored by:	Chelsio Communications
2021-04-22 17:45:52 -07:00
Navdeep Parhar
dc77e79296 cxgbe(4): Fix minor nit in the display of MPS TCAM entries.
MFC after:	3 days
2021-04-22 15:36:51 -07:00
Navdeep Parhar
8f1bc78ef7 cxgbe(4): make the logging helpers a little more robust.
MFC after:	3 days
Sponsored by:	Chelsio Communications
2021-04-22 15:28:43 -07:00
Navdeep Parhar
557c4521bb cxgbe/t4_tom: Implement tod_pmtu_update.
tod_pmtu_update was added to the kernel in 01d74fe1ff.

Sponsored by:	Chelsio Communications
2021-04-22 14:48:57 -07:00
Navdeep Parhar
d107ee06f3 cxgbe(4): RSS hash for VXLAN traffic is computed from the inner frame.
Sponsored by:	Chelsio Communications
2021-04-13 16:50:12 -07:00
John Baldwin
774c4c82ff TOE: Use a read lock on the PCB for syncache_add().
Reviewed by:	np, glebius
Fixes:		08d9c92027
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D29739
2021-04-13 16:31:04 -07:00
John Baldwin
45d5c28439 cxgbe: Ignore doomed virtual interfaces when updating the clip table.
A doomed VI does not have a valid ifnet.

Reported by:	Jithesh Arakkan @ Chelsio
Reviewed by:	np
MFC after:	1 week
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D29662
2021-04-12 14:36:40 -07:00
John Baldwin
568e69e4eb cxgbe: Add counters for iSCSI PDUs transmitted via TOE.
Reviewed by:	np
MFC after:	1 week
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D29297
2021-04-12 13:57:45 -07:00
Navdeep Parhar
bf5057691b 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@
MFC after:	1 week
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D29579
2021-04-11 19:14:18 -07:00
Navdeep Parhar
516fe911a6 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
2021-04-01 14:24:29 -07:00
Navdeep Parhar
5394893269 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@
MFC after:	1 week
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D29503
2021-03-31 10:54:32 -07:00
John Baldwin
fe496dc02a 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.

Reviewed by:	np
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D29383
2021-03-26 15:19:58 -07:00
John Baldwin
077ba6a845 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.

Reviewed by:	np
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D29382
2021-03-26 15:19:58 -07:00
Bjoern A. Zeeb
0a7b99553f 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
MFC-after:	2 weeks
Reviewed-by:	np
X-D-R:		D29366 (extracted as further cleanup)
Differential Revision:	https://reviews.freebsd.org/D29432
2021-03-26 17:44:38 +00:00
Navdeep Parhar
15f3355567 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
MFC after:	2 weeks
Sponsored by:	Chelsio Communications
Reviewed by:	jhb@
Differential Revision: https://reviews.freebsd.org/D29291
2021-03-25 12:39:41 -07:00
John Baldwin
90c74b2b60 cxgbei: Enter network epoch and set vnet around t4_push_pdus().
Reviewed by:	np
MFC after:	2 weeks
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D29302
2021-03-22 10:05:02 -07:00
John Baldwin
017902fc5f 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.

Reviewed by:	np
MFC after:	2 weeks
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D29301
2021-03-22 10:05:02 -07:00
John Baldwin
8855ed61b5 cxgbei: Pass ULP submode directly to set_ulp_mode_iscsi().
Reviewed by:	np
MFC after:	2 weeks
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D29300
2021-03-22 10:05:02 -07:00
John Baldwin
45eed2331e cxgbei: Move some function prototypes to cxgbei.h.
Reviewed by:	np
MFC after:	2 weeks
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D29299
2021-03-22 10:05:02 -07:00
John Baldwin
52c11c3f74 cxgbei: Set vnet around tcp_drop() in do_rx_iscsi_ddp().
Reviewed by:	np
MFC after:	2 weeks
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D29298
2021-03-22 10:05:02 -07:00
Navdeep Parhar
3cc6f777be 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.

MFC after:	1 week
Sponsored by:	Chelsio Communications
2021-03-19 13:35:30 -07:00
Navdeep Parhar
a1d803c162 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.

MFC after:	1 week
Sponsored by:	Chelsio Communications
2021-03-19 12:37:44 -07:00
Navdeep Parhar
473f6163e3 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.

MFC after:	2 weeks
Sponsored by:	Chelsio Communications
2021-03-19 10:56:24 -07:00
Navdeep Parhar
0b373f26be cxgbe(4): catch up with the latest cryptocaps.
There are two crypto capabilities that the driver didn't know about.

MFC after:	1 week
Sponsored by:	Chelsio Communications
2021-03-16 10:53:52 -07:00
John Baldwin
5fe0cd6503 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.

Reviewed by:	np
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D26581
2021-03-12 10:59:35 -08:00
John Baldwin
9c5137beb5 ccr: Add per-port stats of queued and completed requests.
Reviewed by:	np
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D29176
2021-03-12 10:59:35 -08:00
John Baldwin
8f885fd1f3 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.

Reviewed by:	np
Reported by:	Chelsio QA
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D29175
2021-03-12 10:59:35 -08:00
Navdeep Parhar
765d623d60 cxgbe(4): Remove extra blank line.
No functional change.
2021-03-05 12:48:39 -08:00
Navdeep Parhar
4a4e9c516c 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.

MFC after:	1 week
Sponsored by:	Chelsio Communications
2021-03-05 11:28:18 -08:00
Navdeep Parhar
dfff1de729 cxgbe(4): Read the rx 'c' channel for a port and make it available.
MFC after:	1 week
Sponsored by:	Chelsio Communications
2021-02-25 23:46:14 -08:00
Navdeep Parhar
0460a45062 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).

MFC after:	2 weeks
Sponsored by:	Chelsio Communications
2021-02-19 14:23:58 -08:00
Navdeep Parhar
c91dda5ad9 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.

MFC after:	2 weeks
Sponsored by:	Chelsio Communications
2021-02-19 14:23:58 -08:00
Navdeep Parhar
7ac8040a99 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.

MFC after:	2 weeks
Sponsored by:	Chelsio Communications
2021-02-19 14:23:58 -08:00
Navdeep Parhar
fae028dd97 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.

MFC after:	1 week
Sponsored by:	Chelsio Communications
2021-02-18 01:22:42 -08:00
John Baldwin
1deaad9364 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
Reviewed by:	np
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D28243
2021-02-17 13:28:04 -08:00
Alexander Motin
294e62bebf 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
2021-02-16 21:15:28 -05:00
Navdeep Parhar
3447df8bc5 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.
2021-02-01 03:00:09 -08:00
Gleb Smirnoff
3f43ada98c 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.
2021-01-29 11:46:24 -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