History log of /freebsd-current/sys/dev/isp/isp_target.c
Revision Date Author Comments
# 685dc743 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


# 156c1ebe 27-Nov-2020 Alexander Motin <mav@FreeBSD.org>

Some code reorganization.

- Remove code duplication by adding two new functions to execute prepared
queue entry via either mbox or request queue and wait for result.
- Since the new function executing via request queue sleeps any way, make
it sleep also in case of overflows or handle shortages. It should make it
more reliable and less affecting other less flexible request queue users.
- Turn isp_target_put_entry() into not target-specific isp_send_entry().
- Make handling of responses with control handles more universal.
- Move RQSTYPE_RPT_ID_ACQ handling into new function.
- Inline isp_handle_other_response(), becoming trivial after above.
- Clean the list of IOCBs from pre-24xx ones.


# df9c69d2 26-Nov-2020 Alexander Motin <mav@FreeBSD.org>

Restore break statement lost in r367857.


# 8cb0d414 25-Nov-2020 Alexander Motin <mav@FreeBSD.org>

Remove some more dead code from pre-24xx.


# b8e2395e 20-Nov-2020 Alexander Motin <mav@FreeBSD.org>

Increase queue depths from 1024/256 to 8192/1024 IOCBs.

Qlogic chips store S/G lists in the same queue as requests themselves. In
the worst case 1MB I/O may require up to 52 IOCBs, that means queue of 1024
IOCBs can store only 19 of such requests. The increase reduces chances of
overflow, while we should be able to afford additional 512KB of RAM per HBA.
The Linux driver uses comparable numbers.

While there, decouple ATIO queue size from response queue size. There is
no reason for them to be equal.


# f6854a0c 20-Nov-2020 Alexander Motin <mav@FreeBSD.org>

Cleanup DMA handling.

- Make isp_start() to set all the IOCB fields aside of S/G list, removing
extra information from isp_send_cmd(), now only doing S/G lists and sending.
- Turn DMA setup/free from being card and PCI-specific into OS-specific,
instead add new card-specific method for isp_send_cmd(). Previously this
function was a monster handling all the cards.
- Remove double error code translation.


# 1b760be4 19-Nov-2020 Alexander Motin <mav@FreeBSD.org>

Remove parallel SCSI and 1/2Gb FC support from isp(4).

This removes 288KB (36%) of the driver code and zillions of hacks and
workarounds, making single driver uniformly support several different
generations of hardware interfaces, not counting minor card variations.
After years of the hopeless fight, I don't think it worth to continue
support for hardware obsolete for 15-20 years. Instead much cleaner
now code should allow to move forward toward better locking, multiple
queues and other cool features.

All the remaining Qlogic cards starting from 4Gb 24xx to 32Gb 27xx use
the same hardware/firmware interface with minor incremental improvements,
so it seems to be a good new starting point. Except one PCI-X model all
all of them are PCIe and so still usable in modern systems.

Discussed with: ken, scottl, jpaetzel, imp
Relnotes: yes


# 718cf2cc 27-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

sys/dev: further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.


# 9c81a61e 19-Mar-2017 Alexander Motin <mav@FreeBSD.org>

Remove hackish code delaying ATIOs to unknown virtual port.

Since we support RQSTYPE_RPT_ID_ACQ, that functionality is only useful
in loop mode, which probably doesn't worth having this hack in 2017.

MFC after: 2 weeks


# e2a658cb 19-Mar-2017 Alexander Motin <mav@FreeBSD.org>

Move <= 23xx PDB workaround to generic code.

It is chip-specific and has nothing to do with platform.

MFC after: 2 weeks


# 5a5632c2 19-Mar-2017 Alexander Motin <mav@FreeBSD.org>

Move 24xx RQSTYPE_NOTIFY handling to generic code.

This code has nothing to do with specific platform.

MFC after: 2 weeks


# 87b04de6 18-Mar-2017 Alexander Motin <mav@FreeBSD.org>

Reorganize RQSTYPE_NOTIFY handling for chips <= 23xx.

There were two copies of the code: one in generic code was half-broken, and
another in platform code was never called. Leave only one in generic code
and working.

MFC after: 2 weeks


# 981ffc4e 18-Mar-2017 Alexander Motin <mav@FreeBSD.org>

Move RQSTYPE_ABTS_RCVD parsing into generic code.

MFC after: 2 weeks


# 15c62456 18-Mar-2017 Alexander Motin <mav@FreeBSD.org>

Extend nt_lun to full 8 byte.

MFC after: 2 weeks


# 98b08fbe 18-Mar-2017 Alexander Motin <mav@FreeBSD.org>

Remove dead remnants of SPI target.

MFC after: 2 weeks


# 782a8e7c 18-Mar-2017 Alexander Motin <mav@FreeBSD.org>

Use isp_target_put_entry() in places where it can be.

This unifies the code and removes some duplication.

MFC after: 2 weeks


# 44a2a27a 18-Mar-2017 Alexander Motin <mav@FreeBSD.org>

Do some notify acks cleanup.

ISPASYNC_TARGET_NOTIFY_ACK makes no sense without argument.

MFC after: 2 weeks


# 9c2e9bcf 14-Mar-2017 Alexander Motin <mav@FreeBSD.org>

Remove some dead/broken code paths around async handling

MFC after: 2 weeks


# 229203af 12-Mar-2017 Alexander Motin <mav@FreeBSD.org>

Remove code for unsupported FreeBSD versions.

MFC after: 2 weeks


# a6036a44 25-Feb-2017 Alexander Motin <mav@FreeBSD.org>

Fix residual length reporting in target mode.

This allows to properly handle cases when target wants to receive or send
more data then initiator wants to send or receive. Previously in such
cases isp(4) returned CAM_DATA_RUN_ERR, while now it returns resid > 0.

MFC after: 2 weeks


# 8290ea90 21-Feb-2017 Alexander Motin <mav@FreeBSD.org>

Fix multiple problems around LUN disable under load.

- Move private data about ATIOs/INOTs from per-LUN to per-channel data.
This allows active commands to continue operation after LUN destruction.
This also simplifies lookup of the data by tag in some situations.
- Unify three restart_queue processing implementations.
- Complete all ATIOs from restart_queue on LUN disable.
- Delete ATIO private data when command completed or aborted, not depending
on the ATIO being requeued, that was ugly hack and could never happen. CAM
should always call ether XPT_CONT_TARGET_IO with status or XPT_ABORT.
- Implement XPT_ABORT for queued ATIOs/INOTs to allow CAM do graceful
shutdown, not depending on LUN disable, as it is done in ahd(4)/targ(4).
- Unify isp_endcmd() arguments to make it more usable in generic code.
- Remove never really used LUN state reference counter.

MFC after: 2 weeks


# 352427b3 19-May-2016 Alexander Motin <mav@FreeBSD.org>

Add proper reporting for early task management errors.

This covers unknown requests and requests to unknown virtual ports.
Previously it "worked" only because of timeout handling on initiator.


# 93d07b9a 18-May-2016 Alexander Motin <mav@FreeBSD.org>

Unify Multi ID target code by reusing isp_find_chan_by_did().


# d2a2ccbc 13-May-2016 Alexander Motin <mav@FreeBSD.org>

Fix FCP_CMD LENGTH mask in ATIO7 IOCB.

This caused "long IU length (16384) ignored" errors following by others.

MFC after: 2 weeks


# 970ceb2f 25-Dec-2015 Alexander Motin <mav@FreeBSD.org>

Unify handles allocation for initiator and target IOCBs.

I am not sure why this was split long ago, but I see no reason for it.
At this point this unification just slightly reduces memory usage, but
as next step I plan to reuse shared handle space for other IOCB types.


# e2929f5f 24-Nov-2015 Alexander Motin <mav@FreeBSD.org>

Rename ASYNC_LIP_F8 to ASYNC_LIP_NOS_OLS_RECV.

New name better repsents its meaning for modern chips.


# 3e6deb33 23-Nov-2015 Alexander Motin <mav@FreeBSD.org>

Rip off target mode support for parallel SCSI QLogic adapters.

Hacks to enable target mode there complicated code, while didn't really
work. And for outdated hardware fixing it is not really interesting.

Initiator mode tested with Qlogic 1080 adapter is still working fine.


# c5fd36ed 18-Nov-2015 Alexander Motin <mav@FreeBSD.org>

Remove some confusions between loopid and nphdl.

Modern cards in most cases operate abstract port handles, that have no
any relation to real loop IDs. Leave loopid used only where it really
goes about local loop IDs.

While there, fix few more cases where LUNs were still printed in decimal.


# 33d34744 25-Oct-2015 Alexander Motin <mav@FreeBSD.org>

Deliver INOTs only to enabled virtual ports.


# 6af11b82 24-Oct-2015 Alexander Motin <mav@FreeBSD.org>

Add PIM_EXTLUNS support to isp(4) driver.

Now 24xx and above chips support full 8-byte LUN address space.
Older FC chips may support up to 16K LUNs when firmware allows.
Tested in both initiator and target modes for 23xx, 24xx and 25xx.


# c98d2b1f 23-Oct-2015 Alexander Motin <mav@FreeBSD.org>

Add partial support for QUERY TMF to CAM and isp(4).

This change allows to decode respective functions in isp(4) in target mode
and pass them through CAM to CTL. Unfortunately neither CAM nor isp(4)
support returning response info for those task management functions now.

On the other side I just have no initiator to test this functionality.


# 37a7daac 23-Oct-2015 Alexander Motin <mav@FreeBSD.org>

Improve INOTs handling for 24xx and above chips.


# 387d8239 28-Jul-2012 Matt Jacob <mjacob@FreeBSD.org>

-----------
MISC CHANGES

Add a new async event- ISP_TARGET_NOTIFY_ACK, that will guarantee
eventual delivery of a NOTIFY ACK. This is tons better than just
ignoring the return from isp_notify_ack and hoping for the best.

Clean up the lower level lun enable code to be a bit more sensible.

Fix a botch in isp_endcmd which was messing up the sense data.

Fix notify ack for SRR to use a sensible error code in the case
of a reject.

Clean up and make clear what kind of firmware we've loaded and
what capabilities it has.
-----------
FULL (252 byte) SENSE DATA

In CTIOs for the ISP, there's only a limimted amount of space
to load SENSE DATA for associated CHECK CONDITIONS (24 or 26
bytes). This makes it difficult to send full SENSE DATA that can
be up to 252 bytes.

Implement MODE 2 responses which have us build the FCP Response
in system memory which the ISP will put onto the wire directly.

On the initiator side, the same problem occurs in that a command
status response only has a limited amount of space for SENSE DATA.
This data is supplemented by status continuation responses that
the ISP pushes onto the response queue after the status response.
We now pull them all together so that full sense data can be
returned to the periph driver.

This is supported on 23XX, 24XX and 25XX cards.

This is also preparation for doing >16 byte CDBs.

-----------
FC TAPE

Implement full FC-TAPE on both initiator and target mode side. This
capability is driven by firmware loaded, board type, board NVRAM
settings, or hint configuration options to enable or disable. This
is supported for 23XX, 24XX and 25XX cards.

On the initiator side, we pretty much just have to generate a command
reference number for each command we send out. This is FCP-4 compliant
in that we do this per ITL nexus to generate the allowed 1 thru 255
CRN.

In order to support the target side of FC-TAPE, we now pay attention
to more of the PRLI word 3 parameters which will tell us whether
an initiator wants confirmed responses. While we're at it, we'll
pay attention to the initiator view too and report it.

On sending back CTIOs, we will notice whether the initiator wants
confirmed responses and we'll set up flags to do so.

If a response or data frame is lost the initiator sends us an SRR
(Sequence Retransmit Request) ELS which shows up as an SRR notify
and all outstanding CTIOs are nuked with SRR Received status. The
SRR notify contains the offset that the initiator wants us to restart
the data transfer from or to retransmit the response frame.

If the ISP driver still has the CCB around for which the data segment
or response applies, it will retransmit.

However, we typically don't know about a lost data frame until we
send the FCP Response and the initiator totes up counters for data
moved and notices missing segments. In this case we've already
completed the data CCBs already and sent themn back up to the periph
driver. Because there's no really clean mechanism yet in CAM to
handle this, a hack has been put into place to complete the CTIO
CCB with the CAM_MESSAGE_RECV status which will have a MODIFY DATA
POINTER extended message in it. The internal ISP target groks this
and ctl(8) will be modified to deal with this as well.

At any rate, the data is retransmitted and an an FCP response is
sent. The whole point here is to successfully complete a command
so that you don't have to depend on ULP (SCSI) to have to recover,
which in the case of tape is not really possible (hence the name
FC-TAPE).

Sponsored by: Spectralogic
MFC after: 1 month


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# 87aa0933 01-Mar-2010 Matt Jacob <mjacob@FreeBSD.org>

MFC of 204397: fix problems with fast posting handles


# 443e752d 26-Feb-2010 Matt Jacob <mjacob@FreeBSD.org>

Revamp the pieces of some of the stuff I forgot to do when shifting to
32 bit handles. The RIO (reduced interrupt operation) and fast posting
for the parallel SCSI cards were all 16 bit handles. Furthermore,
target mode parallel SCSI only can have 16 bit handles.

Use part of a supplied patch to switch over to using 32 bit handles.
Be a bit more conservative here and only do this for parallel SCSI
for the 12160 (Ultra3) cards. There were a lot of marginal Ultra2
cards, and, frankly, few are findable now for testing.

Fix the target handle routine to only do 16 bit handles for parallel
SCSI cards. This is okay because the upper sixteen bits of the new
32 bit handles is a sequence number to help protect against duplicate
completions. This would be very unlikely to happen with parallel
SCSI target mode, and wasn't present before, so we're no worse off
than we used to be.

While we're at it, finally split the async mailbox completion handlers
into FC and parallel SCSI functions. This makes it much cleaner and
easier to figure out what is or isn't a legal async mailbox completion
code for different card classes.

PR: kern/144250
Submitted partially by: Charles D
MFC after: 1 week


# 2df76c16 31-Jul-2009 Matt Jacob <mjacob@FreeBSD.org>

Add 8Gb support (isp_2500). Fix a fair number of configuration and
firmware loading bugs.

Target mode support has received some serious attention to make it
more usable and stable.

Some backward compatible additions to CAM have been made that make
target mode async events easier to deal with have also been put
into place.

Further refinement and better support for NP-IV (N-port Virtualization)
is now in place.

Code for release prior to RELENG_7 has been stripped away for code clarity.

Sponsored by: Copan Systems

Reviewed by: scottl, ken, jung-uk kim
Approved by: re


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 976b0106 12-Oct-2007 Kevin Lo <kevlo@FreeBSD.org>

Spelling fix for interupt -> interrupt


# e48b2487 09-Mar-2007 Matt Jacob <mjacob@FreeBSD.org>

Fix some stupid copyright mistakes that have been there for quite some time.


# 8ada6330 20-Jan-2007 Matt Jacob <mjacob@FreeBSD.org>

Grumble- let a linux-ism slip in and had an llx which
then choked on a 64 bit platforms. Oops.


# 6c81a0ae 19-Jan-2007 Matt Jacob <mjacob@FreeBSD.org>

MFP4: Move default setting to the end of isp_reset instead of the
front of isp_init so we can read NVRAM even if we're role ISP_NONE.
Prepare for reintroduction of channels (for FC) for N-Port
Virtualization.

Fix a botch in handle assignment that caused us to nuke one device
when a new one arrives and end up with two devices with the same
identity in the virtual target mapping table.


# 351c7054 05-Dec-2006 Matt Jacob <mjacob@FreeBSD.org>

Add a chip timeout to ENABLE/MODIFY/DISABLE lun calls.

MFC after: 1 month


# 10365e5a 01-Nov-2006 Matt Jacob <mjacob@FreeBSD.org>

Add 4Gb (24XX) support and lay the foundation for a lot of new stuff.


# b4110d46 04-Aug-2006 Matt Jacob <mjacob@FreeBSD.org>

Fix na_fcentry_t to not have a lun field. Fix indentation in handly
the notify structs. Fix messages in isp_got_msg_fc to print out the
loop id of the sender- not the wwpn which will be synthesized later,
if possible, in the outer layers. Put in debug printouts to pair
a notify ack to a notify so one can see the start/close of an
immediate notify event. Put in spsace for TASK MANAGEMENT response
flags (which we don't do yet).


# 799881e0 16-Jul-2006 Matt Jacob <mjacob@FreeBSD.org>

Some rearrangement of headers to minimize diffs with outside of
FreeBSD repository and to clean up the license header so as to
not pollute the license with file function.

Zero all mailbox structures prior to use (just in case). Change
the outgoing mailbox count for INIT_FIRMWARE to be correct.


# 99ece8d6 10-Jul-2006 Matt Jacob <mjacob@FreeBSD.org>

Put in some missing target mode for 2KLOGIN f/w spots.

MFC after: 1 month


# 8c4e89e2 21-Apr-2006 Matt Jacob <mjacob@FreeBSD.org>

Redo some code based upon issues found by Coverity.


# 9cd7268e 21-Apr-2006 Matt Jacob <mjacob@FreeBSD.org>

Some more gratuitous format and name changes.

Pull in some target mode changes from a private branch.
Pull in some more RELENG_4 compilation changes.

A lot of lines changed, but not much content change yet.


# 1dae40eb 14-Feb-2006 Matt Jacob <mjacob@FreeBSD.org>

a) clean up some declaration stuff (i.e., make more modern with respect
to getting rid u_int for uint and so on).

b) Turn back on 64 bit DAC support. Cheeze it a bit in that we have two
DMA callback functions- one when we have bus_addr_t > 4 bits in width and
the other which should be normal. Even Cheezier in that we turn off setting
up DMA maps to be BUS_SPACE_MAXADDR if we're in ISP_TARGET_MODE. More work
on this in a week or so.

c) Tested under amd64 and 1MB DFLTPHYS, sparc64, i386 (PAE, but insufficient
memory to really test > 4GB). LINT check under amd64.

MFC after: 1 month


# e5265237 22-Jan-2006 Matt Jacob <mjacob@FreeBSD.org>

First of several commits as this driver is dusted off and maybe brought
up to date. Principle changes for this reelase is to support 2K Port Login
firmware. This allows us to support the 2322 (and 2422 4Gb) cards which only
come with the 2K Port Login firmware. The 2322 should now work- but we don't
have firmware sets for it in ispfw (as the change to load 2K Port Login f/w
hasn't been made- that f/w is so big it has to be loaded in more than one
chunk).

Other changes are the beginnings of cleaning up some long standing target
mode issues. The next changes here will incorporate a lot of bug fixes
from others.

Finally, some copyright cleanup and attempts to make the parts of the
driver that are FreeBSD specific start conforming more to FreeBSD style.

MFC after: 1 month


# 182d1c03 22-Jan-2005 Matt Jacob <mjacob@FreeBSD.org>

Macroize the making of tag ids.

MFC after: 2 weeks


# 098ca2bd 05-Jan-2005 Warner Losh <imp@FreeBSD.org>

Start each of the license/copyright comments with /*-, minor shuffle of lines


# 51e23558 24-May-2004 Nate Lawson <njl@FreeBSD.org>

Store the target handles in a separate list from normal commands. Add a
CTIO fast post routine to handle CTIO completions.

Submitted by: mjacob


# eedb2dfe 28-Jan-2004 Matt Jacob <mjacob@FreeBSD.org>

Fix a bug where we never managed to include the sense data we wanted to send.


# ac9d0a02 28-Jan-2004 Matt Jacob <mjacob@FreeBSD.org>

Fix longstanding buglet- for centrally handled CTIO2s we were checking the wrong
bit for this being the last CTIO2. It didn't matter since it really was the
last CTIO2 and the resources recycled, but still....

Add in CTIO3 define for future DAC work.


# 2f9e7606 12-Sep-2003 Matt Jacob <mjacob@FreeBSD.org>

Some ridiculous target mode botches- like having the wrong definitions
for messages. Some spelling fixes. Some target mode structure cleanups
to reflect reality.


# a0fb4cf1 31-May-2003 Poul-Henning Kamp <phk@FreeBSD.org>

Remove unused variables
Add /* FALLTHROUGH */

Found by: FlexeLint


# e5824c5d 16-Feb-2003 Matt Jacob <mjacob@FreeBSD.org>

Pointy hat- bad commit.


# 03cf2fba 15-Feb-2003 Matt Jacob <mjacob@FreeBSD.org>

Make sure we propagate rxid && iid in isp_target_put_atio


# d64ada50 30-Dec-2002 Jens Schweikhardt <schweikh@FreeBSD.org>

Fix typos, mostly s/ an / a / where appropriate and a few s/an/and/
Add FreeBSD Id tag where missing.


# 413f5a8a 14-Oct-2002 Matt Jacob <mjacob@FreeBSD.org>

LINT related fixes (as noticed by bde)


# e63442b6 15-Jun-2002 Matt Jacob <mjacob@FreeBSD.org>

Change isp_target_async to a function returning an integer.

Roll most immediate notifies into something the platform has to handle.


# 75c1e828 04-Feb-2002 Matt Jacob <mjacob@FreeBSD.org>

+ A variety of 23XX changes:
disable MWI on 2300

based on function code, set an 'isp_port' for the 2312- it's a
separate instance, but the NVRAM is shared, and the second port's
NVRAM is at offset 256.

+ Enable RIO operation for LVD SCSI cards. This makes a *big* difference
as even under reasonable load we get batched completions of about 30
commands at a time on, say, an ISP1080.

+ Do 'continuation' mailbox commands- this allows us to specify a work
area within the softc and 'continue' repeated mailbox commands. This is
more or less on an ad hoc basis and is currently only used for firmware
loading (which f/w now loads substantially faster becuase the calling
thread is only woken when all the f/w words are loaded- not for each
one of the 40000 f/w words that gets loaded).

+ If we're about to return from isp_intr with a 'bogus interrupt' indication,
and we're not a 23XX card, check to see whether the semaphore register is
currently *2* (not *1* as it should be) and whether there's an async completion
sitting in outgoing mailbox0. This seems to capture cases of lost fast posting
and RIO interrupts that the 12160 && 1080 have been known to pump out under
extreme load (extreme, as in > 250 active commands).

+ FC_SCRATCH_ACQUIRE/FC_SCRATCH_RELEASE macros.

+ Endian correct swizzle/unswizzle of an ATIO2 that has a WWPN in it.

MFC after: 1 week


# 4fd13c1b 10-Dec-2001 Matt Jacob <mjacob@FreeBSD.org>

Major restructuring for swizzling to the request queue and unswizzling from
the response queue. Instead of the ad hoc ISP_SWIZZLE_REQUEST, we now have
a complete set of inline functions in isp_inline.h. Each platform is
responsible for providing just one of a set of ISP_IOX_{GET,PUT}{8,16,32}
macros.

The reason this needs to be done is that we need to have a single set of
functions that will work correctly on multiple architectures for both little
and big endian machines. It also needs to work correctly in the case that
we have the request or response queues in memory that has to be treated
specially (e.g., have ddi_dma_sync called on it for Solaris after we update
it or before we read from it). It also has to handle the SBus cards (for
platforms that have them) which, while on a Big Endian machine, do *not*
require *most* of the request/response queue entry fields to be swizzled
or unswizzled.

One thing that falls out of this is that we no longer build requests in the
request queue itself. Instead, we build the request locally (e.g., on the
stack) and then as part of the swizzling operation, copy it to the request
queue entry we've allocated. I thought long and hard about whether this was
too expensive a change to make as it in a lot of cases requires an extra
copy. On balance, the flexbility is worth it. With any luck, the entry that
we build locally stays in a processor writeback cache (after all, it's only
64 bytes) so that the cost of actually flushing it to the memory area that is
the shared queue with the PCI device is not all that expensive. We may examine
this again and try to get clever in the future to try and avoid copies.

Another change that falls out of this is that MEMORYBARRIER should be taken
a lot more seriously. The macro ISP_ADD_REQUEST does a MEMORYBARRIER on the
entry being added. But there had been many other places this had been missing.
It's now very important that it be done.

Additional changes:

Fix a longstanding buglet of sorts. When we get an entry via isp_getrqentry,
the iptr value that gets returned is the value we intend to eventually plug
into the ISP registers as the entry *one past* the last one we've written-
*not* the current entry we're updating. All along we've been calling sync
functions on the wrong index value. Argh. The 'fix' here is to rename all
'iptr' variables as 'nxti' to remember that this is the 'next' pointer-
not the current pointer.

Devote a single bit to mboxbsy- and set aside bits for output mbox registers
that we need to pick up- we can have at least one command which does not
have any defined output registers (MBOX_EXECUTE_FIRMWARE).

MFC after: 2 weeks


# 23ac1fce 04-Sep-2001 Matt Jacob <mjacob@FreeBSD.org>

Note for ATIOs returned because of BDRs or Bus Resets for which bus this
applies to. Do more bus # foo things.

Acknowledge Immediate Notifies right away prior to throwing events upstream
(where they're currently being ignored, *groan*)

Capture ASYNC_LIP_F8 as with ASYNC_LIP_OCCURRED. Don't percolate them
upstream as if they were BUS RESETS- they're not.


# d82b6503 02-Sep-2001 Matt Jacob <mjacob@FreeBSD.org>

Because we now store SCCLUN capabilities in firmware attributes, get
rid of the silly test of isp_maxluns > 16 and use the attibutes directly.

MFC after: 4 weeks


# 5d571944 28-May-2001 Matt Jacob <mjacob@FreeBSD.org>

Spring MegaChange #1.

----

Make a device for each ISP- really usable only with devfs and add an ioctl
entry point (this can be used to (re)set debug levels, reset the HBA,
rescan the fabric, issue lips, etc).

----

Add in a kernel thread for Fibre Channel cards. The purpose of this
thread is to be woken up to clean up after Fibre Channel events
block things. Basically, any FC event that casts doubt on the
location or identify of FC devices blocks the queues. When, and
if, we get the PORT DATABASE CHANGED or NAME SERVER DATABASE CHANGED
async event, we activate the kthread which will then, in full thread
context, re-evaluate the local loop and/or the fabric. When it's
satisfied that things are stable, it can then release the blocked
queues and let commands flow again.

The prior mechanism was a lazy evaluation. That is, the next command
to come down the pipe after change events would pay the full price
for re-evaluation. And if this was done off of a softcall, it really
could hang up the system.

These changes brings the FreeBSD port more in line with the Solaris,
Linux and NetBSD ports. It also, more importantly, gets us being
more proactive about topology changes which could then be reflected
upwards to CAM so that the periph driver can be informed sooner
rather than later when things arrive or depart.

---

Add in the (correct) usage of locking macros- we now have lock transition
macros which allow us to transition from holding the CAM lock (Giant)
and grabbing the softc lock and vice versa. Switch over to having this
HBA do real locking. Some folks claim this won't be a win. They're right.
But you have to start somewhere, and this will begin to teach us how
to DTRT for HBAs, etc.

--

Start putting in prototype 2300 support. Add back in LIP
and Loop Reset as async events that each platform will handle.
Add in another int_bogus instrumentation point.

Do some more substantial target mode cleanups.

MFC after: 8 weeks


# b25bcef8 04-Apr-2001 Matt Jacob <mjacob@FreeBSD.org>

Perform some more Ansification. Remove and then replace the isp_putback_atio
function- we did it a bit cleaner. We only use this if a CTIO completes with
!CT_OK state. We now have managed to get away without having to poke around
and trying to find the original ATIO- the csio we're using has the tag_id
and lun values with it which is mostly what we need when we do the putback.

Make sure we correctly propagate AT_TQAE->CT_TQAE for tags. Make sure
we call ISP_DMAFREE only if we had DATA to move.


# b0bd9b71 13-Mar-2001 Matt Jacob <mjacob@FreeBSD.org>

Clean up usage- ct_reserved is really ct_syshandle now.


# 5f5aafe1 01-Mar-2001 Matt Jacob <mjacob@FreeBSD.org>

Switch to using 16 bit handles instead of 32 bit handles.
This is a pretty invasive change, but there are three good
reasons to do this:

1. We'll never have > 16 bits of handle.
2. We can (eventually) enable the RIO (Reduced Interrupt Operation)
bits which return multiple completing 16 bit handles in mailbox
registers.
3. The !)$*)$*~)@$*~)$* Qlogic target mode for parallel SCSI spec
changed such that at_reserved (which was 32 bits) was split into
two pieces- and one of which was a 16 bit handle id that functions
like the at_rxid for Fibre Channel (a tag for the f/w to correlate
CTIOs with a particular command). Since we had to muck with that
and this changed the whole handler architecture, we might as well...

Propagate new at_handle on through int ct_fwhandle. Follow
implications of changing to 16 bit handles.

These above changes at least get Qlogic 1040 cards working in target
mode again. 1080/12160 cards don't work yet.

In isp.c:
Prepare for doing all loop management in outer layers.


# f09deb69 06-Feb-2001 Jeroen Ruigrok van der Werven <asmodai@FreeBSD.org>

Fix typo: wierd -> weird.

There is no such thing as wierd in the english language.


# aa57fd6f 21-Sep-2000 Matt Jacob <mjacob@FreeBSD.org>

some copyright cleanups


# b6b6ad2f 27-Aug-2000 Matt Jacob <mjacob@FreeBSD.org>

various fixes


# 10549c05 01-Aug-2000 Matt Jacob <mjacob@FreeBSD.org>

Remove isp_tdebug. Change all PRINTF macros to the now common
isp_prt logging function.


# d37162ca 18-Jul-2000 Matt Jacob <mjacob@FreeBSD.org>

If debugging set, zero out an incoming response entry
when we're done reading it (makes checking things easier).
Before calling isp_notify_ack make sure we're at RUNSTATE-
elsewise we can be responding to LIPs or SCSI bus resets
before we've finished some of the wiring.


# 2133e16f 17-Jun-2000 Matt Jacob <mjacob@FreeBSD.org>

Remove all ISP2100_SCCLUN define based code and replace it with runtime
comparisons against the tag isp_maxluns- if > 16, we're SCCLUN based.

On initial regular SCSI startup, disable auto-disconnect.


# 9dae8807 20-Apr-2000 Matt Jacob <mjacob@FreeBSD.org>

Some minor tweaklets.


# 14a37293 14-Feb-2000 Matt Jacob <mjacob@FreeBSD.org>

Correctly identify which bus of dual bus SCSI adapters some target mode
commands (enable/disable/modify lun && immediate notify) we're talking about.

Approved: jkh


# af4d0149 11-Feb-2000 Matt Jacob <mjacob@FreeBSD.org>

Correct a minor typo in error message.

Approved: jkh@freebsd.org


# 0c02c31b 14-Jan-2000 Matt Jacob <mjacob@FreeBSD.org>

cleanup- it was not MI code as it should have been


# 79e2d3b5 03-Jan-2000 Matt Jacob <mjacob@FreeBSD.org>

set default target mode debug to 0


# ea49c6e4 03-Jan-2000 Matt Jacob <mjacob@FreeBSD.org>

These are platform independent functions for target mode support.
This is just a first pass at this and is likely to change a bit
over the next month.