Commit graph

1372 commits

Author SHA1 Message Date
Navdeep Parhar
52e5a66eac cxgbe(4): Use correct synchronization when marking the adapter offline.
adapter->flags are guarded by a synch_op, as noted in the comment in
adapter.h where the flags are defined.

Fixes:	5241b210a4 cxgbe(4): Basic infrastructure for ULDs to participate in adapter reset.
MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-10-07 10:25:53 -07:00
Navdeep Parhar
9ba8670a8b cxgbe(4): Allow t4_tom to be unloaded safely.
* Disable IFCAP_TOE automatically on all ifnets on all adapters during
  unload.  This is user-friendly and avoids panics due to stale ifnet
  state after t4_tom is unloaded.
* Do not allow unload if tids are in use by the TOE on any adapter.

Reported by:	Bimal Abraham @ Chelsio
MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-09-29 17:38:11 -07:00
Navdeep Parhar
cc110bbec6 cxgbe/t4_tom: Remove duplicate unlock in t4_tom_deactivate.
Fixes:	c1c524852f cxgbe/t4_tom: Implement uld_stop and uld_restart for ULD_TOM.
MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-09-29 17:38:11 -07:00
Navdeep Parhar
ee3da604dd cxgbe(4): Clobber all tracer state on stop and redo only traceq on restart.
Tracers have to be recreated after a restart but that's okay given that
they are used for debugging only.

MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-09-24 16:52:22 -07:00
Navdeep Parhar
3883300afe cxgbe/t4_tom: Do not set unresolved entries to STALE in t4_l2t_update.
An L2 entry in the driver's hash was marked STALE unconditionally if it
changed in the kernel when its driver refcount is 0.  Fix the driver to
do this for VALID entries only.

MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-09-24 08:53:11 -07:00
Navdeep Parhar
07f47e8850 cxgbe/t4_tom: completely avoid L2T entries during stop/suspend.
1. Mark the L2T entry valid only if t4_write_l2e succeeds, which won't
   happen if the adapter is stopped.  This prevents L2T entries from
   sometimes getting (re)promoted to VALID on Tx activity during stop.
2. Discard a work request immediately instead of enqueueing it to the
   arp queue if the adapter is stopped.

Fixes:	c1c524852f cxgbe/t4_tom: Implement uld_stop and uld_restart for ULD_TOM.
MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-09-16 10:24:32 -07:00
Navdeep Parhar
d82cb5c608 cxgbe(4): Make sure that the tracing filters are usable after restart.
The destination queue for tracing filters is destroyed during stop or
suspend and the software state needs to reflect this.  A new destination
queue will be setup when the adapter resumes operation.

MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-09-11 12:12:32 -07:00
Navdeep Parhar
171e57967b cxgbe/t4_tom: Demote STALE L2 table entries to RESOLVING in uld_stop.
The STALE state means the L2T entry is valid in hardware but needs to be
refreshed (ARP/NDP) in software.  But stop/suspend wipes the hardware
L2T and STALE entries need to be updated just like VALID entries to match
actual hardware state.

Fixes:	c1c524852f cxgbe/t4_tom: Implement uld_stop and uld_restart for ULD_TOM.
MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-09-11 12:09:48 -07:00
Navdeep Parhar
674cbf38f6 cxgbe/t4_tom: Add synq entry to the list before calling send_synack.
This fixes a panic where the peer's ack to the synack arrives on a
different queue and do_pass_establish tries to remove the synqe from
synqe_list before it has been added by do_pass_accept_req.

Reported by:	Sony Arpita Das @ Chelsio
Fixes:	283333c0e3 cxgbe/t4_tom: Track all synq entries in a per-adapter list.
MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-09-05 23:21:59 -07:00
Navdeep Parhar
7aeec281b8 cxgbe(4): Always report link-down on an abrupt stop.
This fixes a regression in 5241b210a4 where the driver stopped
reporting link down after a fatal error unless t4_reset_on_fatal_err was
also set.

Fixes:	5241b210a4 cxgbe(4): Basic infrastructure for ULDs to participate in adapter reset.
MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-09-04 21:54:30 -07:00
Zhenlei Huang
955b380365 cxgbe(4): Stop checking for failures from malloc/mb_alloc_ext_pgs(M_WAITOK)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D45852
2024-09-03 18:25:26 +08:00
Navdeep Parhar
9fdb683d92 cxgbe/iw_cxgbe: Fail early in some callbacks when the RNIC is stopped.
Stop allocating new resources when the RNIC is stopped but continue to
allow previously allocated resources to be freed.  Note that t4_tom's
uld_stop tears down all TOE connections, including those being used for
iWARP, and that triggers the cleanup of iWARP resources.

Fail post_send/post_recv early too to avoid the SQ doorbell.

MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-08-30 08:31:45 -07:00
Navdeep Parhar
3b4dcc0feb cxgbe/iw_cxgbe: c4iw_connect should return a negative errno.
Avoid a pointless assignment while here.

MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-08-29 17:58:36 -07:00
Navdeep Parhar
3f250bb6f0 cxgbe/iw_cxgbe: Tidy up a couple of CTRs in c4iw_create_listen.
backlog is an int and not a string.  While here, fix an adjacent CTR
that was spread over two lines even though it fits in one.

MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-08-28 19:40:04 -07:00
Navdeep Parhar
8254a276ad cxgbe/iw_cxgbe: Replace the fatal error flag with a stopped flag.
Now that suspend/resume is supported by the base driver, a fatal error
isn't the only reason that the RNIC can stop abruptly.  Also, this state
is no longer permanent as it's possible to resume operations after a
stop.  Rename the flag and associated routines to match the new state of
affairs.

MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-08-28 12:19:23 -07:00
Navdeep Parhar
1e584ca30e cxgbe(4): Export the core suspend/resume functionality to other modules.
MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-08-28 11:20:26 -07:00
Navdeep Parhar
d668a0b0ab cxgbe(4): reset routine for general use.
Add a reset_adapter wrapper that picks the most suitable reset routine
internally.  Use it in the fatal error handler as well as the sysctl
based reset.

MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-08-21 11:47:15 -07:00
Navdeep Parhar
0a9d1da6e6 cxgbe(4): Stop work request queues in a reliable manner.
Clear the EQ_HW_ALLOCATED flag with the wrq lock held and discard all
work requests, pending or new, when it's not set.

MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-08-17 11:23:32 -07:00
Navdeep Parhar
b5332809c6 cxgbe/iw_cxgbe: Fix typo in assertion.
eanbled -> enabled

MFC after:	3 days
2024-08-17 10:38:36 -07:00
Navdeep Parhar
fef0e39f64 cxgbe/t4_tom: bugfixes in stop/restart.
1. Remove toepcb from the toep_list on active open failure.
2. Purge the wr_list for an L2T entry on an adpater stop.

Fixes:	c1c524852f cxgbe/t4_tom: Implement uld_stop and uld_restart for ULD_TOM.
MFC after:	2 weeks
Sponsored by:	Chelsio Communications
2024-08-05 05:56:22 -07:00
Bjoern A. Zeeb
d1bdc2821f Deprecate contigfree(9) in favour of free(9)
As of 9e6544dd6e contigfree(9) is no longer
needed and should not be used anymore.  We leave a wrapper for 3rd party
code in at least 15.x but remove (almost) all other cases from the tree.

This leaves one use of contigfree(9) untouched; that was the original
trigger for 9e6544dd6e and is handled in D45813 (to be committed
seperately later).

Sponsored by:	The FreeBSD Foundation
Reviewed by:	markj, kib
Tested by:	pho (10h stress test run)
Differential Revision: https://reviews.freebsd.org/D46099
2024-07-26 10:45:01 +00:00
Warner Losh
5b56413d04 newbus: globally replace device_add_child(..., -1) with DEVICE_UNIT_ANY
Sponsored by:		Netflix
2024-07-24 22:22:58 -06:00
Navdeep Parhar
f1c4ed1503 cxgbe/iw_cxgbe: Add a placeholder uld_restart.
MFC after:	1 month
Sponsored by:	Chelsio Communications
2024-07-21 22:25:08 -07:00
Navdeep Parhar
c1c524852f cxgbe/t4_tom: Implement uld_stop and uld_restart for ULD_TOM.
This allows the adapter to be suspended or reset even when stateful TOE is
active, in some limited configurations.

The LLD has already stopped the adapter hardware and all its queues by the time
these ULD routines get called.  The general approach in t4_tom is to purge the
lookup tables immediately so that they are ready for operation by the time the
adapter resumes, and park all the resources left hanging by the stopped hardware
into separate "stranded" queues that can be dealt with at leisure.

Outstanding active opens, live connections, and synq entries (for connections in
the middle of the 3-way handshake) are all treated as if the hardware had
reported an abrupt error for the tid.  The servers/listeners are a bit different
in that no error is reported.  They're just noted as non-functional when the
hardware stops and are recreated by the driver during restart.

MFC after:	1 month
Sponsored by:	Chelsio Communications
2024-07-21 22:20:21 -07:00
Navdeep Parhar
283333c0e3 cxgbe/t4_tom: Track all synq entries in a per-adapter list.
Live tid entries in tid_tab are either full fledged connections or synq
entries.  toep_list tracks the connections already and this change adds
a synqe_list to track the synq entries.  These two lists can be used to
enumerate and iterate over all live tids.

MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-07-21 21:02:34 -07:00
Navdeep Parhar
cd93fdee5c cxgbe(4): Stop and restart the L2T allocator with the LLD.
L2T entries are used by both filters and TOE and the L2T is shared
between the base driver (LLD) and the TOM ULD.  Add a flag to indicate
that the L2T is stopped, which means:
* t4_alloc_l2e and t4_l2t_alloc_switching will not allocate new entries.
* t4_tom will ignore all ARP/NDP updates from the kernel.
* Previously allocated L2T entries can still be freed.

MFC after:      1 month
Sponsored by:   Chelsio Communications
2024-07-21 20:29:26 -07:00
Navdeep Parhar
fd3aca5b41 cxgbe(4): Stop and restart the atid allocator with the LLD.
atids are used by both filters and TOE and the atid table is in the base
driver (LLD).  New atids cannot be allocated when the allocator is
stopped but existing ones can still be freed.  It is expected that the
owners of outstanding atids will release them in their own stop
processing, before the adapter is restarted.

MFC after:	1 month
Sponsored by:	Chelsio Communications
2024-07-21 20:26:42 -07:00
Navdeep Parhar
5241b210a4 cxgbe(4): Basic infrastructure for ULDs to participate in adapter reset.
The suspend/resume/reset implementation in the base driver (LLD)
currently works when only stateless features are in use.  This commit
adds basic infrastructure for stateful upper layer drivers (ULDs) to
participate in suspend/resume/reset.

* Add a uld_restart to indicate that the adapter has been restarted
  after a stop and the ULD should resume operations.
* Move the existing functionality in t4_suspend/t4_resume to stop_lld and
  restart_lld.  Use these and the new uld restart routines everywhere the
  adapter has to be stopped abruptly and restarted, namely:
  1. PCIE bus suspend/resume/reset methods invoked by the kernel.
  2. Manual internal-reset using driver sysctl.
  3. Automatic internal-reset on a fatal error.
* Implement an alternate internal-reset for use in VMs and for testing.

Typical reset sequence is:
stop_adapter(sc);
stop_lld(sc);
stop_all_uld(sc);
set_adapter_hwstatus(sc, false);

/* hw reset takes place here. */

restart_adapter(sc);
restart_lld(sc);
  set_adapter_hwstatus(sc, true);
restart_all_uld(sc);

MFC after:	1 month
Sponsored by:	Chelsio Communications
2024-07-21 20:24:03 -07:00
Navdeep Parhar
cf5e6370f1 cxgbe(4): Changes to ULD list management.
* Convert t4_uld_list to an array.  There will be at most 3 items in the
  list and it's simpler to track them in an array with a fixed slot for
  each ULD.
* There is no need to refcount ULDs so stop doing that.
* Add uld_ prefix to all members of uld_info.
* Rename async_event to uld_stop to match its actual purpose.  Call it
  for all ULDs and not just ULD_IWARP.

Reviewed by:	jhb
MFC after:	1 week
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D46029
2024-07-19 09:12:49 -07:00
Navdeep Parhar
cfcfd3c7bf cxgbe(4): Make no assumptions about the start and size of the L2T table.
Do not assume that the table starts at index 0 and is typically 4K in
size.  The only thing the driver needs to verify is that its use of
F_SYNC_WR doesn't collide with the L2T hwidx range.

Reviewed by:	jhb
MFC after:	1 week
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D46028
2024-07-19 09:12:46 -07:00
Navdeep Parhar
27479403a7 cxgbe/t4_tom: Free up hardware resources when the final CPL is received.
Final CPL means the tid is done in the hardware and other resources
associated with it can be freed right away.  There is no need to wait
for the kernel to detach the toepcb.

Reviewed by:	jhb
MFC after:	1 week
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D45991
2024-07-19 09:12:36 -07:00
Navdeep Parhar
bbc326241d cxgbe/t4_tom: Detach the toep from the tcpcb when entering TIME_WAIT.
The kernel used to call tod_pcb_detach when entering TIME_WAIT but that
seems to have changed, likely with the TIME_WAIT overhaul in the kernel
some time ago.  Catch up by having the driver perform the detach.

The hardware does not handle TIME_WAIT so it's important to detach and
let the kernel arm the 2MSL timer to deal with it.

Reported by:	Sony Arpita Das @ Chelsio
Reviewed by:	jhb
MFC after:	1 week
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D45990
2024-07-19 09:12:31 -07:00
Navdeep Parhar
b3bbc6cc79 cxgbe(4): Tidy up t4_l2t.h
Align the comment for if_t with the rest and remove the declaration of
t4_l2t_set_switching, which was removed in 061bbaf7e7.

No functional change.

MFC after:	3 days
Sponsored by:	Chelsio Communications
2024-07-17 10:53:16 -07:00
Mark Johnston
6af3d59962 cxgbe: Flush transmitted packets more regularly in netmap mode
Previously, when transmitting short runs of packets via cxgbe_nm_tx(),
we would wait until a large number of packets were buffered before
scheduling a task to clean transmit buffers.

Obtained from:	np
2024-07-15 11:26:59 -04:00
Navdeep Parhar
dc20d49aa9 cxgbe(4): Do not report link state change during interface detach.
This fixes a panic when multiple VIs are configured on an interface and
only the non-primary VI is up at the time of driver detach.  The problem
was that the driver would queue a link state change notification for an
interface about to be freed.

To reproduce the panic, add "hw.cxgbe.num_vis=2" to loader.conf and

 # kldload if_cxgbe
 # ifconfig vcc0 up
 # devctl detach t6nex0

  trap 0x9, rip = 0xffffffff8107db70, rsp = 0xfffffe0055263d60, rbp = 0xfffffe0055263dd0
  taskqueue_run_locked() at taskqueue_run_locked+0x2a0/frame 0xfffffe0055263dd0
  taskqueue_run() at taskqueue_run+0x72/frame 0xfffffe0055263df0
  taskqueue_swi_run() at taskqueue_swi_run+0x18/frame 0xfffffe0055263e10
  intr_event_execute_handlers() at intr_event_execute_handlers+0x249/frame 0xfffffe0055263e50
  ithread_execute_handlers() at ithread_execute_handlers+0x9e/frame 0xfffffe0055263e70

Reviewed by:	jhb
MFC after:	1 week
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D45864
2024-07-10 12:05:48 -07:00
John Baldwin
1edf61f395 cxgbe: Add a 'show t4 memdump' DDB command
Reviewed by:	np
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D45187
2024-07-03 08:05:11 -07:00
John Baldwin
61089df814 cxgbe: Remove most uses of sysctl_wire_old_buffer
Most of these sysctls don't call sbuf_* while holding any locks.  Of
the ones that do hold locks, all but one can be fixed to drop the lock
before calling sbuf_*.

Reviewed by:	np
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D45186
2024-07-03 08:04:52 -07:00
Zhenlei Huang
aa3860851b net: Remove unneeded NULL check for the allocated ifnet
Change 4787572d05 made if_alloc_domain() never fail, then also do the
wrappers if_alloc(), if_alloc_dev(), and if_gethandle().

No functional change intended.

Reviewed by:	kp, imp, glebius, stevek
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D45740
2024-06-28 18:16:29 +08:00
Doug Moore
7d37fcbf52 cxgbe: replace a loop with rounddown_pow_of_two
Replace a loop with a function call.

Reviewed by:	np, alc
Differential Revision:	https://reviews.freebsd.org/D45716
2024-06-26 03:19:16 -05:00
Doug Moore
5fc42387d7 cxgbe: use order_base_2
Use order_base_2 in place of an expression.

Reviewed by:	alc, markj
Differential Revision:	https://reviews.freebsd.org/D45536
2024-06-24 02:18:42 -05:00
Kristof Provost
1389314d53 cxgbe: handle vlan PF restrictions
Co-Authored-by:	Navdeep Parhar <np@FreeBSD.org>
MFC after:	2 weeks
Sponsored by:	Orange Business Services
Differential Revision:	https://reviews.freebsd.org/D45428
2024-06-17 23:42:08 +02:00
Navdeep Parhar
2d0a012712 cxgbev(4): Pay attention to the VLAN configuration for the VF.
Make sure that the transmit traffic is tagged correctly or else the
firmware will refuse to transmit and will report an ACL violation.

On receive the hardware will make sure that tagged traffic is delivered
to the appropriate VM.  The driver only asserts that the VLAN id that
was extracted from the wire traffic matches the VF's configuration.

All this works when associating a specific VLAN id with a VF.  The
'trunk' setting likely needs more work.

MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-06-17 10:35:14 -07:00
Navdeep Parhar
4471ff1196 cxgbev(4): Shared code for the VF driver to query a VF's VLAN config.
MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-06-17 10:29:17 -07:00
Navdeep Parhar
ba95b4aea7 cxgbe(4): New knob to limit driver to the specified types of doorbells.
hw.cxgbe.doorbells_allowed="0xf"

The adapter's doorbells bitmap is clipped to the value specified in the
tunable, which is meant for debug and workarounds only.  There is no
change in default behavior.

MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-06-16 18:54:02 -07:00
Navdeep Parhar
d72db09005 cxgbe(4): Do not issue an L1CFG command from a VF.
It is pointless to attempt an operation that is not permitted.  It spams
the firmware devlog with "insufficient caps" errors that distract from
real errors.

78 2463625358 ERR CORE insufficient caps to process mailbox cmd: pfn 0x0 vfn 0x1; r_caps 0x86 wx_caps 0x82 required r_caps 0x81 w_caps 0x5

MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-06-16 18:54:02 -07:00
Navdeep Parhar
d0fdafdb0e cxgbev(4): Use the correct source pf for T6 in the VF driver.
MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-06-16 18:54:02 -07:00
Doug Moore
f0a0420dfd powerof2: replace loops with fls or ilog2
In several places, a loop tests for powers of two, or iterates through
powers of two.  In those places, replace the loop with an invocation
of fls or ilog2 without changing the meaning of the code.

Reviewed by:	alc, markj, kib, np, erj, avg (previous version)
Differential Revision:	https://reviews.freebsd.org/D45494
2024-06-12 05:00:48 -05:00
Doug Moore
b0056b31e9 libkern: add ilog2 macro
The kernel source contains several definitions of an ilog2 function;
some are slower than necessary, and one of them is incorrect.
Elimininate them all and define an ilog2 macro in libkern to replace
them, in a way that is fast, correct for all argument types, and, in a
GENERIC kernel, includes a check for an invalid zero parameter.

Folks at Microsoft have verified that having a correct ilog2
definition for their MANA driver doesn't break it.

Reviewed by:	alc, markj, mhorne (older version), jhibbits (older version)
Differential Revision:	https://reviews.freebsd.org/D45170
Differential Revision:	https://reviews.freebsd.org/D45235
2024-06-03 11:37:55 -05:00
Mark Johnston
a1b8445115 cxgbe: Use device_set_descf()
No functional change intended.

MFC after:	1 week
2024-06-02 19:38:40 -04:00
Navdeep Parhar
64a00f877f cxgbe(4): Consolidate all mk_set_tcb_field_ulp in one place.
MFC after:      1 week
Sponsored by:   Chelsio Communications
2024-05-17 15:52:33 -07:00