Commit Graph

927 Commits

Author SHA1 Message Date
Will Andrews
1d0a1de2aa Fix a kernel panic when unloading isp(4).
In the current implementation, the isp_kthread() threads never exit.

The target threads do have an exit mode from isp_attach(), but it is
not invoked from isp_detach().

Ensure isp_detach() notifies threads started for each channel, such
that they exit before their parent device softc detaches, and thus
before the module does.  Otherwise, a page fault panic occurs later in:

sysctl_kern_proc
  sysctl_out_proc
    kern_proc_out
      fill_kinfo_proc
        fill_kinfo_thread
          strlcpy(kp->ki_wmesg, td->td_wmesg, sizeof(kp->ki_wmesg));

For isp_kthread() (and isp(4) target threads), td->td_wmesg references
now-unmapped memory after the module has been unloaded.  These threads
are typically msleep()ing at the time of unload, but they could also
attempt to execute now-unmapped code segments.

MFC after:	1 month
Sponsored by:	Spectra Logic
MFSpectraBSD:	r1070921 on 2014/06/22 13:01:17
2014-09-18 02:01:36 +00:00
Alexander Motin
950b6e126b Pass correct command that should be aborted to ISPCTL_ABORT_CMD.
This makes XPT_ABORT to work for me on initiator side of isp(4).
Previous code was trying to abort the XPT_ABORT itself and failed.

MFC after:	1 week
2014-07-08 13:01:36 +00:00
John Baldwin
aced5239b2 Add missing calls to bus_dmamap_unload() when freeing static DMA
allocations.

Reviewed by:	scottl
2014-06-13 18:20:44 +00:00
Alexander Motin
718724fd0d Fix I/O freezes in some cases, caused by r257916.
Delaying isp_reqodx update, we should be ready to update it every time
we read it.  Otherwise requests using several indexes may be requeued
ndefinitely without ever updating the variable.

MFC after:	3 days
2014-02-05 16:22:02 +00:00
Matt Jacob
c3167cabe6 Harvest one no longer used constant string.
Remove another and place it into play in the
normally ifdef protected zone it would be used
int.

Noticed by:	dim
2013-12-25 04:51:56 +00:00
Alexander Motin
07d925fa2f Use relaxed (write-only) memory barriers when writing some of queue index
registers (for now on ISP2400+).  We never read those registers back and
AFAIK their semantics does not require any immediate reaction on write.
2013-11-10 23:48:16 +00:00
Alexander Motin
748d188e18 Some more registers access optimizations:
- Process ATIO queue only if interrupt status tells so;
 - Do not update queue out pointers after each processed command, do it
only once at the end of the loop.
2013-11-10 23:34:32 +00:00
Alexander Motin
d00fd0a920 Save one more register read per command by not reading rqstoutrp register
every time.  The purpose of that register is unlikely output queue overflow
detection, so read it only when its last known (and probably stale now)
value signals overflow.

This reduces CPU load and lock congestion and rises bottleneck in CTL
while doing target mode via two 8Gbps ports from 100K to 120K IOPS.
2013-11-10 13:37:44 +00:00
Nathan Whitehorn
123055f01f Adjust various SCSI drivers to handle either a 32-bit or 64-bit lun_id_t,
mostly by adjustments to debugging printf() format specifiers. For high
numbered LUNs, also switch to printing them in hex as per SAM-5.

MFC after: 2 weeks
2013-10-30 14:04:47 +00:00
Alexander Motin
227d67aa54 Merge CAM locking changes from the projects/camlock branch to radically
reduce lock congestion and improve SMP scalability of the SCSI/ATA stack,
preparing the ground for the coming next GEOM direct dispatch support.

Replace big per-SIM locks with bunch of smaller ones:
 - per-LUN locks to protect device and peripheral drivers state;
 - per-target locks to protect list of LUNs on target;
 - per-bus locks to protect reference counting;
 - per-send queue locks to protect queue of CCBs to be sent;
 - per-done queue locks to protect queue of completed CCBs;
 - remaining per-SIM locks now protect only HBA driver internals.

While holding LUN lock it is allowed (while not recommended for performance
reasons) to take SIM lock.  The opposite acquisition order is forbidden.
All the other locks are leaf locks, that can be taken anywhere, but should
not be cascaded.  Many functions, such as: xpt_action(), xpt_done(),
xpt_async(), xpt_create_path(), etc. are no longer require (but allow) SIM
lock to be held.

To keep compatibility and solve cases where SIM lock can't be dropped, all
xpt_async() calls in addition to xpt_done() calls are queued to completion
threads for async processing in clean environment without SIM lock held.

Instead of single CAM SWI thread, used for commands completion processing
before, use multiple (depending on number of CPUs) threads.  Load balanced
between them using "hash" of the device B:T:L address.

HBA drivers that can drop SIM lock during completion processing and have
sufficient number of completion threads to efficiently scale to multiple
CPUs can use new function xpt_done_direct() to avoid extra context switch.
Make ahci(4) driver to use this mechanism depending on hardware setup.

Sponsored by:	iXsystems, Inc.
MFC after:	2 months
2013-10-21 12:00:26 +00:00
Alexander Motin
5e63cdb457 Partial MFproject/camlock r256671:
Fix several target mode SIMs to not blindly clear ccb_h.flags field of
ATIO CCBs.  Not all CCB flags there belong to them.
2013-10-21 06:04:39 +00:00
Alexander Motin
523ea374b6 Optimize isp(4) to reduce CPU usage, especially in target mode:
- Remove two excessive and slow register reads from isp_intr().  Instead
of rereading value every time, assume that registers contain what we have
written there.
 - Avoid sequential search through 4096 array elements when looking for
command tag.  Use hash of lists to store active tags separately from free
ones and so greatly speedup the searches.

Reviewed by:	mjacob
2013-10-17 20:19:15 +00:00
Kenneth D. Merry
7bf825d1d3 Export the maxio field in the CAM XPT_PATH_INQ CCB in the isp(4)
driver.

This tells consumers up the stack the maximum I/O size that the
controller can handle.

The I/O size is bounded by the number of scatter/gather segments
the controller can handle and the page size.  For an amd64 system,
it works out to around 5MB.

Reviewed by:	mjacob
MFC after:	3 days
Sponsored by:	Spectra Logic
2013-08-15 16:41:27 +00:00
Scott Long
c68534f1d5 Update PCI drivers to no longer look at the MEMIO-enabled bit in the PCI
command register.  The lazy BAR allocation code in FreeBSD sometimes
disables this bit when it detects a range conflict, and will re-enable
it on demand when a driver allocates the BAR.  Thus, the bit is no longer
a reliable indication of capability, and should not be checked.  This
results in the elimination of a lot of code from drivers, and also gives
the opportunity to simplify a lot of drivers to use a helper API to set
the busmaster enable bit.

This changes fixes some recent reports of disk controllers and their
associated drives/enclosures disappearing during boot.

Submitted by:	jhb
Reviewed by:	jfv, marius, achadd, achim
MFC after:	1 day
2013-08-12 23:30:01 +00:00
Matt Jacob
22629d2996 When fiddling with options of which registers to copy out for
a mailbox command and which registers to copy back in when
the command completes, the bits being set need to not only
specify what bits you want to add from the default from the
table but also what bits you want *subtract* (mask) from the
default from the table.

A failing ISP2200 command pointed this out.

Much appreciation to: marius, who persisted and narrowed down what
the failure delta was, and shamed me into actually fixing it.
MFC after:	1 week
2013-07-13 21:24:25 +00:00
Marius Strobl
ab1aa38b02 Flag isp(4) as supporting unmapped I/O; all necessary conversion actually
already has been done as part of r246713.

Reviewed by:	mjacob
2013-06-04 11:05:57 +00:00
Alexander Motin
e5dfa058da MFprojects/camlock r248982:
Stop abusing xpt_periph in random plases that really have no periph related
to CCB, for example, bus scanning.  NULL value is fine in such cases and it
is correctly logged in debug messages as "noperiph".  If at some point we
need some real XPT periphs (alike to pmpX now), quite likely they will be
per-bus, and not a single global instance as xpt_periph now.
2013-04-14 09:55:48 +00:00
Matt Jacob
3e0e2e2026 Remove redundant xpt_alloc_ccb in isp_target_thread that was causing leakage.
Pointed out by:	Sascha Wildner of DragonFly BSD
MFC after:	1 week
2013-02-26 21:37:12 +00:00
Matt Jacob
5bba9b9f69 Turn off fast posting for the ISP2100- I'd forgotten that it actually
might have been enabled for them- now that we use all 32 bits of handle.
Fast Posting doesn't pass the full 32 bits.

Noticed by: Bugs in NetBSD. Only a NetBSD user might actually still use such old hardware.
MFC after:	1 week
2013-02-25 11:22:54 +00:00
Konstantin Belousov
dd0b4fb6d5 Reform the busdma API so that new types may be added without modifying
every architecture's busdma_machdep.c.  It is done by unifying the
bus_dmamap_load_buffer() routines so that they may be called from MI
code.  The MD busdma is then given a chance to do any final processing
in the complete() callback.

The cam changes unify the bus_dmamap_load* handling in cam drivers.

The arm and mips implementations are updated to track virtual
addresses for sync().  Previously this was done in a type specific
way.  Now it is done in a generic way by recording the list of
virtuals in the map.

Submitted by:	jeff (sponsored by EMC/Isilon)
Reviewed by:	kan (previous version), scottl,
	mjacob (isp(4), no objections for target mode changes)
Discussed with:	     ian (arm changes)
Tested by:	marius (sparc64), mips (jmallet), isci(4) on x86 (jharris),
	amd64 (Fabian Keil <freebsd-listen@fabiankeil.de>)
2013-02-12 16:57:20 +00:00
Matt Jacob
5ac438d68c Don't allow for more than one segment for the control space since
we're not set up to deal with that.

X-MFC:	242479
MFC after:	1 week
2012-11-02 14:38:57 +00:00
Matt Jacob
8e1b6e7aec Don't allow for more than one segment for the control space since
we're not set up to deal with that.

MFC after:	1 week
2012-11-02 14:37:21 +00:00
Matt Jacob
6f7aeb5fe3 Minor correction.
MFC after:	1 day
2012-09-17 02:50:16 +00:00
Matt Jacob
8b382bc2b5 Add some edits to the changed comments so that they make more sense.
MFC after:	1 day
2012-09-17 02:49:02 +00:00
Eitan Adler
96240c89f0 Correct double "the the"
Approved by:	cperciva
MFC after:	3 days
2012-09-14 21:28:56 +00:00
Matt Jacob
10bf42c215 Remove useless extra test.
Pointed out by:	Sascha of DragonFly BSD
MFC after:	2 weeks
2012-09-07 22:45:31 +00:00
Matt Jacob
662daadde0 Remove dependence on MAXPHYS.
MFC after:	1 month
2012-08-21 16:18:11 +00:00
Matt Jacob
344aebe2c2 On lun disable, complete all INOTs and ATIOs with CAM_REQ_ABORTED.
Reviewed by:	ken (silently), chuck
MFC after:	3 weeks
2012-08-16 15:32:16 +00:00
Matt Jacob
64f202fc7d Remove extraneous newline.
MFC after:	1 month
2012-08-12 20:49:25 +00:00
Matt Jacob
405b7a2903 Fix an oops where we wiped out DMA maps. Don't allocate extended
command space for anything less than a 2300.

MFC after:	1 month
X-MFC:		238869
2012-08-12 20:45:47 +00:00
Matt Jacob
94dff77179 More rototilling with target mode in an attemp to get multiple
CCB at a time outstanding reliable. It's not there yet, but this
is the direction to go in so might as well commit. So far,
multiple at a time CCBs work (see ISP_INTERNAL_TARGET test mode),
but it fails if there are more downstream than the SIM wants
to handle and SRR is sort of confused when this happens, plus
it is not entirely quite clear what one does if a CCB/CTIO fails
and you have more in flight (that don't fail, say) and more queued
up at the SIM level that haven't been started yet.

Some of this is driven because there apparently is no flow control
to requeue XPT_CONTINUE_IO requests like there are for XPT_SCSI_IO
requests. It is also more driven in that the few target mode
periph drivers there are are not really set up for handling pushback-
heck most of them don't even check for errors (and what would they
really do with them anyway? It's the initiator's problem, really....).

The data transfer arithmetic has been worked over again to handle
multiple outstanding commands, so you have a notion of what's been
moved already as well as what's currently in flight. It turns that
this led to uncovering a REPORT_LUNS bug in the ISP_INTERNAL_TARGET
code which was sending back 24 bytes of rpl data instead of the
specified 16. What happened furthermore here is that sending back
16 bytes and reporting an overrun of 8 bytes made the initiator
(running FC-Tape aware f/w) mad enough to request, and keep
requesting, another FCP response (I guess it didn't like the answer
so kept asking for it again).

Sponsored by: Spectralogic
MFC after:	1 month
2012-08-08 18:24:33 +00:00
Matt Jacob
2468ec31b3 Add detach logic to SBus variant.
Obtained from:	Marius
MFC after:	1 month
2012-08-04 00:00:30 +00:00
Matt Jacob
de0627d021 Oops. We only do allocate room for extended commands
and responses for 2300 cards are newer.

Sponsored by:	Spectralogic
Noticed by:	Our Friend Manfred
MFC after:	1 month
X-MFC: 238869
2012-08-03 14:25:35 +00:00
Matt Jacob
767a02fb40 Grr.!$()!$$ I missed checking this in even though I *did* run
a tinderbox myself and caught the error.

Change to isp_send_cmd needs a final ecmd argument.

Sponsored by: Spectralogic
MFC after:	1 month
X-MFC: 238869
2012-07-29 14:21:42 +00:00
Matt Jacob
387d8239fb -----------
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
2012-07-28 20:06:29 +00:00
Christian Brueffer
80ad0053bc Fix typo in a message.
Obtained from:	DragonFly BSD (change 7a817ab191e4898404a9037c55850e47d177308c)
MFC after:	3 days
2012-07-15 14:40:49 +00:00
Matt Jacob
d42f4bedba Unbreak register tests for parallel SCSI.
You can't overwrite registers 7 and 8.
MFC after:	3 days
2012-06-25 03:06:29 +00:00
Matt Jacob
9e7d423d23 Clean up multi-id mode so it's driven by the f/w loaded,
not by some hint setting.  Do more preparations for FC-Tape.
Clean up resource counting for 24XX or later chipsets so
we find out after EXEC_FIRMWARE what is actually supported.
Set target mode exchange count based upon whether or not
we are supporting simultaneous target/initiator mode. Clean
up some old (pre-24XX) xfwoption and zfwoption issues.

Sponsored by:	Spectralogic
MFC after:	3 days
2012-06-24 17:30:54 +00:00
Matt Jacob
ad0ab75379 Prepare for FC-Tape support. This involved doing a lot of little cleanups
and crosschecks against firmware documentation. We now check and report
FC firmware attributes and at least are now prepared for the upper 48 bits
of f/w attributes (which are probably for the 8100 or later cards). This
involed changing how inbits and outbits are calculated for varios commands,
hopefully clearer and cleaner. This also caused me to clean up the actual
mailbox register usage. Finally, we are now unconditionally using a CRN
for initiator mode.

A longstanding issue with the 2400/2500 is that they do *not* support
a "Prefer PTP followed by loop", which explains why enabling that
caused the f/w to crash.

A slightly more invasive change is to let the firmware load entirely
drive whether multi_id support is enabled or not.

Sponsored by:	Spectralogic
MFC after:	1 week
2012-06-17 21:39:40 +00:00
Matt Jacob
2c82e3bb5f If debug values were set, the default from tval floated
down and triggered an attempt to set multiple virtual
ports whether you wanted them or not.

MFC after:	3 days
2012-06-15 15:28:15 +00:00
Matt Jacob
e2873b76a6 Clean up and complete the incomplete deferred enable code.
Make the default role NONE if target mode is selected. This
allows ctl(8) to switch to/from target mode via knob settings.
If we default to role 'none', this causes a reset of the
24XX f/w which then causes initiators to wake up and notice
when we come online.

Reviewed by:    kdm
MFC after:      2 weeks
Sponsored by:   Spectralogic
2012-06-01 23:29:48 +00:00
Eitan Adler
d45ce511db Adding missing dependancies for loading hptiop(4), hptmv(4) and isp(4) as modules.
PR:		kern/166239
Submitted by:	Pavel Timofeev <timp87@gmail.com>
Discussed on:	-stable, -scsi
Reviewed by:	scottl
No objection from: mjacob
Approved by:	cperciva
MFC after:	3 days
2012-06-01 04:34:49 +00:00
Kevin Lo
10e777b0f4 Fix memset sizeof 2012-02-22 01:08:59 +00:00
Matt Jacob
f6683e5594 Fix target mode compilation issues that arose after a change
in the sense data structures.

MFC after:	1 week
2011-12-27 14:59:24 +00:00
Alexander Motin
45210a2512 Fix few bugs in isp(4) target mode support:
- in destroy_lun_state() assert hold == 1 instead of 0, as it should
receive hold taken by the create_lun_state() or get_lun_statep() before;
 - fix hold count leak inside rls_lun_statep() that also fired above assert;
 - in destroy_lun_state() use SIM bus number instead of SIM path id for
ISP_GET_PC_ADDR(), as it was before r196008;
 - make isp_disable_lun() to set status in CCB;
 - make isp_target_mark_aborted() set status into the proper CCB.

Reviewed by:	mjacob
Sponsored by:	iXsystems, inc.
MFC after:	1 month
2011-12-13 09:58:05 +00:00
Matt Jacob
7d3cea3137 Was chasing down a failure to load f/w on a 2400. It turns out that the card
is actually broken, or needs a BIOS upgrade for 64 bit loads, but this uncovered
a couple of misplaced opcode definitions and some missing continual mbox command
cases, so might as well update them here.
2011-11-16 02:52:24 +00:00
Eitan Adler
14517324d0 - add a missing "be" and "in"
- fix other errors introduced when committing r226436
- add 'function' to a sentence where it makes sense

Submitted by:	delphij
Submitted by:	dougb
Submitted by:	jhb
Approved by:	dougb
Approved by:	jhb
2011-11-11 22:27:09 +00:00
Matt Jacob
a0ec8e99ae Implement the sysctl's for fibre channel that are listed in the man page.
MFC after:	3 days
2011-11-06 00:44:40 +00:00
Eitan Adler
36daf0495a - change "is is" to "is" or "it is"
- change "the the" to "the"

Approved by:	lstewart
Approved by:	sahil (mentor)
MFC after:	3 days
2011-10-16 14:30:28 +00:00
Marius Strobl
50e66535b9 Sync with ahc(4)/ahd(4)/sym(4) etc:
Zero any sense not transferred by the device as the SCSI specification
mandates that any untransferred data should be assumed to be zero.

Reviewed by:	ken
2011-10-07 21:23:42 +00:00
Kenneth D. Merry
1cc052e80f Add descriptor sense support to CAM, and honor sense residuals properly in
CAM.

Desriptor sense is a new sense data format that originated in SPC-3.  Among
other things, it allows for an 8-byte info field, which is necessary to
pass back block numbers larger than 4 bytes.

This change adds a number of new functions to scsi_all.c (and therefore
libcam) that abstract out most access to sense data.

This includes a bump of CAM_VERSION, because the CCB ABI has changed.
Userland programs that use the CAM pass(4) driver will need to be
recompiled.

camcontrol.c:	Change uses of scsi_extract_sense() to use
		scsi_extract_sense_len().

		Use scsi_get_sks() instead of accessing sense key specific
		data directly.

scsi_modes:	Update the control mode page to the latest version (SPC-4).

scsi_cmds.c,
scsi_target.c:	Change references to struct scsi_sense_data to struct
		scsi_sense_data_fixed.  This should be changed to allow the
		user to specify fixed or descriptor sense, and then use
		scsi_set_sense_data() to build the sense data.

ps3cdrom.c:	Use scsi_set_sense_data() instead of setting sense data
		manually.

cam_periph.c:	Use scsi_extract_sense_len() instead of using
		scsi_extract_sense() or accessing sense data directly.

cam_ccb.h:	Bump the CAM_VERSION from 0x15 to 0x16.  The change of
		struct scsi_sense_data from 32 to 252 bytes changes the
		size of struct ccb_scsiio, but not the size of union ccb.
		So the version must be bumped to prevent structure
		mis-matches.

scsi_all.h:	Lots of updated SCSI sense data and other structures.

		Add function prototypes for the new sense data functions.

		Take out the inline implementation of scsi_extract_sense().
		It is now too large to put in a header file.

		Add macros to calculate whether fields are present and
		filled in fixed and descriptor sense data

scsi_all.c:	In scsi_op_desc(), allow the user to pass in NULL inquiry
		data, and we'll assume a direct access device in that case.

		Changed the SCSI RESERVED sense key name and description
		to COMPLETED, as it is now defined in the spec.

		Change the error recovery action for a number of read errors
		to prevent lots of retries when the drive has said that the
		block isn't accessible.  This speeds up reconstruction of
		the block by any RAID software running on top of the drive
		(e.g. ZFS).

		In scsi_sense_desc(), allow for invalid sense key numbers.
		This allows calling this routine without checking the input
		values first.

		Change scsi_error_action() to use scsi_extract_sense_len(),
		and handle things when invalid asc/ascq values are
		encountered.

		Add a new routine, scsi_desc_iterate(), that will call the
		supplied function for every descriptor in descriptor format
		sense data.

		Add scsi_set_sense_data(), and scsi_set_sense_data_va(),
		which build descriptor and fixed format sense data.  They
		currently default to fixed format sense data.

		Add a number of scsi_get_*() functions, which get different
		types of sense data fields from either fixed or descriptor
		format sense data, if the data is present.

		Add a number of scsi_*_sbuf() functions, which print
		formatted versions of various sense data fields.  These
		functions work for either fixed or descriptor sense.

		Add a number of scsi_sense_*_sbuf() functions, which have a
		standard calling interface and print the indicated field.
		These functions take descriptors only.

		Add scsi_sense_desc_sbuf(), which will print a formatted
		version of the given sense descriptor.

		Pull out a majority of the scsi_sense_sbuf() function and
		put it into scsi_sense_only_sbuf().  This allows callers
		that don't use struct ccb_scsiio to easily utilize the
		printing routines.  Revamp that function to handle
		descriptor sense and use the new sense fetching and
		printing routines.

		Move scsi_extract_sense() into scsi_all.c, and implement it
		in terms of the new function, scsi_extract_sense_len().
		The _len() version takes a length (which should be the
		sense length - residual) and can indicate which fields are
		present and valid in the sense data.

		Add a couple of new scsi_get_*() routines to get the sense
		key, asc, and ascq only.

mly.c:		Rename struct scsi_sense_data to struct
		scsi_sense_data_fixed.

sbp_targ.c:	Use the new sense fetching routines to get sense data
		instead of accessing it directly.

sbp.c:		Change the firewire/SCSI sense data transformation code to
		use struct scsi_sense_data_fixed instead of struct
		scsi_sense_data.  This should be changed later to use
		scsi_set_sense_data().

ciss.c:		Calculate the sense residual properly.  Use
		scsi_get_sense_key() to fetch the sense key.

mps_sas.c,
mpt_cam.c:	Set the sense residual properly.

iir.c:		Use scsi_set_sense_data() instead of building sense data by
		hand.

iscsi_subr.c:	Use scsi_extract_sense_len() instead of grabbing sense data
		directly.

umass.c:	Use scsi_set_sense_data() to build sense data.

		Grab the sense key using scsi_get_sense_key().

		Calculate the sense residual properly.

isp_freebsd.h:	Use scsi_get_*() routines to grab asc, ascq, and sense key
		values.

		Calculate and set the sense residual.

MFC after:	3 days
Sponsored by:	Spectra Logic Corporation
2011-10-03 20:32:55 +00:00
Matt Jacob
e95725cb76 Most of these changes to isp are to allow for isp.ko unloading.
We also revive loop down freezes. We also externaliz within isp
isp_prt_endcmd so something outside the core module can print
something about a command completing. Also some work in progress to
assist in handling timed out commands better.

Partially Sponsored by: Panasas
Approved by:	re (kib)
MFC after:	1 month
2011-08-13 23:34:17 +00:00
Matt Jacob
de46193396 Fixes zombie device and loop down timers so that they work more than
once. Use taskqueues to do the actual work.

Fix an offset line.

Fix isp_prt so that prints from just one buffer, which makes it
appear cleanly cleanly in logs on SMP systems.

Approved by:	re (kib)
MFC after:	1 month
2011-08-12 19:51:28 +00:00
Matt Jacob
a959d92134 Add support QLE220 card- an 2500 lookalike.
Obtained mostly from:	Roman && Konstantin
MFC after:	1 week
2011-03-10 23:53:01 +00:00
Matt Jacob
1d05c65118 Flush both reads *and* writes to registers.
Obtained from:	Miod Vallat in OpenBSD
MFC after:	1 week
2011-03-05 00:59:34 +00:00
Matt Jacob
898899d9dd Sync FreeBSD ISP with mercurial tree. Minor changes having to do with
a macro for minima.
2011-02-28 15:58:30 +00:00
Marius Strobl
37bb79f173 - Use the correct DMA tag/map pair for synchronize the FC scratch area.
- Allocate coherent DMA memory for the request/response queue area and
  and the FC scratch area.

These changes allow isp(4) to work properly on sparc64 with usage of the
IOMMU streaming buffers enabled.

Approved by:	mjacob
MFC after:	2 weeks
2011-02-14 21:50:51 +00:00
Matt Jacob
c4f65bca0b Partially revert 208119. We were overwriting tunable settings.
Obtained from:	Oleg Sharoyko
MFC after:	1 week
2010-11-27 20:33:08 +00:00
Rebecca Cran
b1ce21c6ef Fix typos.
PR:	bin/148894
Submitted by:	olgeni
2010-11-09 10:59:09 +00:00
Matt Jacob
8340692f44 Don't pass a buffer directly as a printflike format string.
Found by: clang
MFC after:	1 month
2010-06-10 19:38:07 +00:00
Matt Jacob
95f7dfb2fa Fix XPT_GET_TRAN_SETTING for FC which has been broken for while so that
it will figure out the correct target to handle index and be able to find
things like WWPN, etc.

MFC after:	2 weeks
2010-06-07 17:39:36 +00:00
Matt Jacob
54b2e8ad07 Be more specific about which CDB length we're going to use. Not really a likely
bug but we might as well be clearer.

Found with:	Coverity Prevent(tm)
CID:		3981

MFC after:	2 weeks
2010-06-05 20:37:40 +00:00
Matt Jacob
0a100e5b0b Make the internal target > SPC2 (so REPORT LUNS can be tested).
Give the NIL inquiry data real values other than just plain 0x7f
in the first byte.

MFC after:	2 weeks
2010-06-05 00:56:15 +00:00
Matt Jacob
4962e51b0c I was getting panics in sleepq_add for the second sleep in isp_kthread.
I don't know why- but it occurred to me in looking at the second sleep
is that all I want is a pause- not an actual sleep. So do that instead.

MFC after:	2 weeks
2010-06-05 00:55:21 +00:00
Matt Jacob
a035b0afa0 Various minor and not so minor fixes suggested by Coverity.
In at least one case, it's amazing that target mode worked at all.

Found by: Coverity.
MFC after:	2 weeks
2010-06-02 23:31:27 +00:00
Matt Jacob
0e85f214e3 Add a new primitive, XPT_SCAN_TGT, to cover the range between scanning a
whole bus (XPT_SCAN_BUS) and a single lun on that bus (XPT_SCAN_LUN).

It's less resource comsumptive than scanning a whole bus when the
caller knows only one target has changes.

Reviewed by:	scsi@
Sponsored by:	Panasas
MFC after:	1 month
2010-05-26 22:49:42 +00:00
Matt Jacob
1c0a1eb299 Don't leak CCBs for every ABORT.
Submitted by:	Ken Merry
MFC after:	One week
2010-05-25 20:19:45 +00:00
Matt Jacob
331c6a355a Remove extra break left by hand editing.
X-MFC: 208542
MFC after:	One Month
2010-05-25 16:50:35 +00:00
Matt Jacob
dad286235e Treat PRLI the same as PLOGI and make a database entry for it (target mode).
Obtained from:	Ken Merry
MFC after:	One Month
2010-05-25 16:46:29 +00:00
Matt Jacob
a6119ff634 Correct compilation error introduced in last commit.
X-MFC:		208119
MFC after:      1 week
Sponsored By:   Panasas
Pointy Hat to:	Me
Noticed by:	Rob
2010-05-16 06:40:05 +00:00
Matt Jacob
427fa8f9fe Whap. Hook up some wires that were forgotten a few months ago and restore
the zombie device timeout code and the loop down time code and the fabric
hysteresis code.
MFC after:	1 week
Sponsored By:	Panasas
2010-05-15 20:26:10 +00:00
Marius Strobl
17bc427d0b On sparc64 obtain the initiator ID from the Open Firmware device tree
in order to match what the PROM built-in driver uses.

Approved by:	mjacob
2010-05-03 18:39:40 +00:00
Matt Jacob
739fd8c533 D'oh- isp_handle_index' logic was reversed (not used in FreeBSD).
MFC after:	1 week
2010-03-26 20:22:18 +00:00
Matt Jacob
670508b16a Clean up some printing stuff so that we can have a bit finer control
on debug output. Add a new platform function requirement to allow
for printing based upon the ITL nexus instead of the isp unit plus
channel, target and lun. This allows some printouts and error messages
from the core code to appear in the same format as the platform's
subsystem (in FreeBSD's case, CAM path).

MFC after:	1 week
2010-03-26 15:13:31 +00:00
Matt Jacob
4ecb1d4aa1 Put gone device timer into a structure tag that can hold more than 32 seconds. Oops.
Untangle some of the confusion about what role means when it's in the FCPARAM/SDPARAM
or isp_fc/isp_spi structures. This fixed a problem about seeing targets appear if you've
turned off autologin and find them, or rather don't, via camcontrol rescan.

MFC after:	1 month
2010-03-17 02:48:14 +00:00
Matt Jacob
443e752d97 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
2010-02-27 05:41:23 +00:00
Matt Jacob
32b3ec7df1 Fix misallocation error in target mode.
MFC after:	1 day
2010-02-27 01:58:41 +00:00
Matt Jacob
940907907b xpt_rescan only honors a wildcard in the target field. Revert the previous
change and have isp_make_here scan the whole bus which will then scan all
luns.

I think xpt_rescan needs to be fixed, but that's a separable issue.

Suggested by: Alexander
2010-02-23 14:35:44 +00:00
Matt Jacob
75c1db5d67 When we rescan, just scan from logical unit 0. In other words, don't
specify a wildcard lun here.

This unbreaks disk re-arrival.

MFC after:	2 days
2010-02-23 00:34:20 +00:00
Matt Jacob
ee3e6d9906 Don't try and re-use a handle, even if the firmware tells you that's what is logged in.
PR:		kern/144026
MFC after:	1 week
2010-02-18 18:35:09 +00:00
Matt Jacob
54e81dece7 Yet another target mode compilation error. 2010-02-04 06:45:14 +00:00
Matt Jacob
97efa6dde8 Fix target mode compilation problem with previous delta 2010-02-04 00:40:12 +00:00
Matt Jacob
c8b8a2c4e6 Redo how commands handles are created and managed and implement sequence
numbers and handle types in rational way. This will better protect from
(unwittingly) dealing with stale handles/commands.

Fix the watchdog timeout code to better protect itself from mistakes.

If we run an abort on a putatively timed out command, the command
may in fact get completed, so check to make sure the command we're
timing it out is still around. If the abort succeeds, btw, the command
should get returned via a different path.
2010-02-03 21:09:32 +00:00
Matt Jacob
78a235dd3f Amazingly we've been freeing a handle and using that which it refers to
for years. Bad!

MFC after:	1 week
2010-01-15 20:08:08 +00:00
Martin Blapp
c2ede4b379 Remove extraneous semicolons, no functional changes.
Submitted by:	Marc Balmer <marc@msys.ch>
MFC after:	1 week
2010-01-07 21:01:37 +00:00
Matt Jacob
1943fd192a Make sure that the WWNN is also created for 2100..2300 cards.
MFC after:	1 day
2010-01-03 02:43:46 +00:00
Matt Jacob
1d52a1ad42 Create a Node WWN from the *Port* WWN, not vice versa, for 2400s.
If the NAA is type 2, the Node WWN is the Port WWN with the 12 bits
of port (48..60) cleared. This iff a wwn fetched from NVRAM is zero.

MFC after:	1 week
2009-12-31 04:16:18 +00:00
Matt Jacob
a01f5aeb09 Fix cases where we've managed to get a Loop UP event prior to initializing
the loop down counter, as well as other things. This was brought to my
attention with a different fix, more for RELENG_7- this one covers the
multiple channel case.

PR:		140438
MFC after:	1 month
2009-12-04 03:34:12 +00:00
Matt Jacob
0bd051b869 Unbreak SBus cards which have been broken (apparently) for a while.
Most of the pieces came from Marius- correct settings for channels
and resource management. The one piece missing was that you cannot
for SBus cards replace 32 bit operations with A64 operations- not
supported.

Submitted by:	marius
MFC after:	3 days
2009-11-02 21:22:30 +00:00
Matt Jacob
cb8461c836 (semiforced commit to add comment missed in last delta)
Add a maximum response length for FCP RSPNS IUs.

Clarify some of the FC option words for setting parameters
and try and disable automatic PRLI when in target mode- this
should correct some cases of N-port topologies with 23XX cards
where we put out an illegal PRLI (in target mode only we're
not supposed to put out a PRLI).
2009-09-21 01:41:19 +00:00
Matt Jacob
e3ec25e2aa Remove file unused in freebsd. 2009-09-21 01:38:22 +00:00
Matt Jacob
ae5db1186f Accomodate old style XPT_IMMED_NOTIFY and XPT_NOTIFY_ACK so that
we at least don't panic.

We don't really support dual role mode (INITIATOR/TARGET) any more. We
should but it's broken and will take a fair amount of effort to fix
and correctly manage both initiator and target roles sharing the port
database. So, for now, disallow it.
2009-09-15 02:25:03 +00:00
Matt Jacob
5cc3786c64 Have at least *some* default WWN to fall back on,
otherwise Sun branded FC cards won't configure.

Reviewed by:	Ken, Scott
Approved by:	re
2009-08-13 01:17:26 +00:00
Matt Jacob
2df76c160b 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
2009-08-01 01:04:26 +00:00
Scott Long
52c9ce25d8 Separate the parallel scsi knowledge out of the core of the XPT, and
modularize it so that new transports can be created.

Add a transport for SATA

Add a periph+protocol layer for ATA

Add a driver for AHCI-compliant hardware.

Add a maxio field to CAM so that drivers can advertise their max
I/O capability.  Modify various drivers so that they are insulated
from the value of MAXPHYS.

The new ATA/SATA code supports AHCI-compliant hardware, and will override
the classic ATA driver if it is loaded as a module at boot time or compiled
into the kernel.  The stack now support NCQ (tagged queueing) for increased
performance on modern SATA drives.  It also supports port multipliers.

ATA drives are accessed via 'ada' device nodes.  ATAPI drives are
accessed via 'cd' device nodes.  They can all be enumerated and manipulated
via camcontrol, just like SCSI drives.  SCSI commands are not translated to
their ATA equivalents; ATA native commands are used throughout the entire
stack, including camcontrol.  See the camcontrol manpage for further
details.  Testing this code may require that you update your fstab, and
possibly modify your BIOS to enable AHCI functionality, if available.

This code is very experimental at the moment.  The userland ABI/API has
changed, so applications will need to be recompiled.  It may change
further in the near future.  The 'ada' device name may also change as
more infrastructure is completed in this project.  The goal is to
eventually put all CAM busses and devices until newbus, allowing for
interesting topology and management options.

Few functional changes will be seen with existing SCSI/SAS/FC drivers,
though the userland ABI has still changed.  In the future, transports
specific modules for SAS and FC may appear in order to better support
the topologies and capabilities of these technologies.

The modularization of CAM and the addition of the ATA/SATA modules is
meant to break CAM out of the mold of being specific to SCSI, letting it
grow to be a framework for arbitrary transports and protocols.  It also
allows drivers to be written to support discrete hardware without
jeopardizing the stability of non-related hardware.  While only an AHCI
driver is provided now, a Silicon Image driver is also in the works.
Drivers for ICH1-4, ICH5-6, PIIX, classic IDE, and any other hardware
is possible and encouraged.  Help with new transports is also encouraged.

Submitted by:	scottl, mav
Approved by:	re
2009-07-10 08:18:08 +00:00
Marius Strobl
0ec607133b Change uses of the struct ccb_hdr timeout_ch missed when isp(4) was
adapted to MPSAFE cam(4) to a isp(4) specific callout structure.
Thanks to Florian Smeets for providing access to a machine exhibiting
this problem for debugging.

Approved by:	mjacob
MFC after:	3 days
2009-05-10 20:14:19 +00:00
Marius Strobl
cde74953ae Don't try reading the SXP_PINS_DIFF on the 10160 and 12160 SCSI
controllers. Reading this register, for which there are indications
that it doesn't really exist, returns 0 on at least some 12160
and doing so on Sun Fire V880 causes a data access error exception.

Reported and tested by:	Beat Gaetzi
Approved by:		mjacob
Obtained from:		OpenBSD (modulo setting isp_lvdmode)
2008-12-15 21:42:38 +00:00
Ed Schouten
6bfa9a2d66 Replace all calls to minor() with dev2unit().
After I removed all the unit2minor()/minor2unit() calls from the kernel
yesterday, I realised calling minor() everywhere is quite confusing.
Character devices now only have the ability to store a unit number, not
a minor number. Remove the confusion by using dev2unit() everywhere.

This commit could also be considered as a bug fix. A lot of drivers call
minor(), while they should actually be calling dev2unit(). In -CURRENT
this isn't a problem, but it turns out we never had any problem reports
related to that issue in the past. I suspect not many people connect
more than 256 pieces of the same hardware.

Reviewed by:	kib
2008-09-27 08:51:18 +00:00
Scott Long
762d6411cf Add missing locking for SBus controllers. 2007-11-05 11:22:18 +00:00
Julian Elischer
3745c395ec Rename the kthread_xxx (e.g. kthread_create()) calls
to kproc_xxx as they actually make whole processes.
Thos makes way for us to add REAL kthread_create() and friends
that actually make theads. it turns out that most of these
calls actually end up being moved back to the thread version
when it's added. but we need to make this cosmetic change first.

I'd LOVE to do this rename in 7.0  so that we can eventually MFC the
new kthread_xxx() calls.
2007-10-20 23:23:23 +00:00
Kevin Lo
976b010645 Spelling fix for interupt -> interrupt 2007-10-12 06:03:46 +00:00
Jung-uk Kim
8553cd622c Fix off-by-two errors.
Both WWNN and WWPN are 64-bit unsigned integers and they are prefixed
with "0x", which requires two more bytes each.

Submitted by:	Danny Braniss (danny at cs dot huji dot ac dot il)
		via Matthew Jacob (lydianconcepts at gmail dot com)
Approved by:	re (bmah)
MFC after:	3 days
2007-08-28 00:09:12 +00:00
Jung-uk Kim
fada2376b8 Export 4Gbps Fibre Channel link speed correctly with inquiry commands.
Approved by:	re (kensmith)
MFC after:	3 days
2007-08-23 15:57:13 +00:00
Matt Jacob
2e4637cd75 Get rid of a couple of Coverity found sign comparison errors.
Approved by:	re (Ken)
MFC after:	3 days
2007-07-10 07:55:59 +00:00
Matt Jacob
bb4f528dd8 Be more conservative- turn off fast posting and RIO for 22XX cards.
Approved by:	re (ken)
MFC after:	3 days
2007-07-10 07:55:04 +00:00
Matt Jacob
4607e8eed3 Recover from some major omissions/problems with the 24XX port.
First, we were never correctly checking for a 24XX Status Type 0
response- that cased us to fall through to evaluate status for
commands as if this were a 2100/2200/2300 Status Type 0 response.
This is *close*, but not quite the same. This has been reported
to be apparent with some wierd lun configuration problems with
some arrays. It became glaringly apparent on sparc64 where none
of the correct byte swap things were done.

Fixing this omission then caused a whole universe shifting debug
cycle of endian issues for the 2400. The manual for 24XX f/w turns
out to be wrong about the endianness of a couple of entities. The
lun and cdb fields for the type 7 request are *not* unconditionally
big endian- they happen to be opposite of whatever the endian of
the current machine type is. Same with the sense data for the
24XX type 0 response.

While we're at it investigate and resolve some NVRAM endian
issues.

Approved by:	re (ken)
MFC after:	3 days
2007-07-02 20:08:20 +00:00
Matt Jacob
baa219ed6f Pointy hat to me. Committed with building.
Approved by:	re (ken, implicit)
2007-06-26 23:08:57 +00:00
Matt Jacob
458570f736 Extension of previous commit- when we have 2k login firmware, we need to
put out a ispreqt2e_t structure onto the request queue- not a ispreqt2_t
structure. I forgot that the 23XX can use a t2 structure.

Approved by:    re (ken, implicitly)
MFC after:	3 days
2007-06-26 20:53:07 +00:00
Matt Jacob
16dbcac063 Yet another bug- when we have 2k login firmware, we need
to put out a ispreqt3e_t structure onto the request queue-
not a ispreqt3_t structure. We weren't. This turns out only
to really matter for big endian machines.

Approved by:	re (ken)
MFC after:	3 days
2007-06-25 17:21:16 +00:00
Matt Jacob
530755ca2d If we're going to (for 23XX and 24XX cards) DMA firmware from the
request queues rather than shove it down a word at a time, we have
to remember to put it into little endian format. Use the macros
ISP_IOXPUT_{16,32} for this purpose. Otherwise, on sparc the firmware
is loaded garbled and we get a (not surprisingly) firmware checksum
failure and the card won't start and we don't attach it.

Approved by:	re (bruce)
MFC after:	3 days
2007-06-24 01:41:16 +00:00
Scott Long
b50569b71d Prepare for future integration between CAM and newbus. xpt_bus_register
now takes a device_t to be the parent of the bus that is being created.
Most SIMs have been updated with a reasonable argument, but a few exceptions
just pass NULL for now.  This argument isn't used yet and the newbus
integration likely won't be ready until after 7.0-RELEASE.
2007-06-17 05:55:54 +00:00
Matt Jacob
511ced9b7c Remove some ioctls that were ill-thought out. There is no user
impact as no softwware using these ioctls was ever committed.

Redo locking for ispioctl.
2007-06-11 19:15:49 +00:00
Matt Jacob
9b434ede5c Only try and set a segment lim size to 1 << 32 iff bus_size_t > 4. 2007-06-11 17:56:17 +00:00
Matt Jacob
1fd47020d8 Quiet GCC 4.2 warning. 2007-06-08 01:39:04 +00:00
Matt Jacob
abeda21e8d Temp workaround for config_intrhook_establish running the hook
right away.
2007-05-13 17:45:00 +00:00
Matt Jacob
f58a08937b Bad merge. 2007-05-11 13:47:28 +00:00
Matt Jacob
0230a28bf4 Fix pointy-hat problem with BUS_DMA_ROOTARG macro that caused problems for sparc64.
Candidate for immediate MFC.

Noticed by: Everyone-maxim contacted.
2007-05-11 06:28:26 +00:00
Matt Jacob
0a70657fcc Make this an MP safe driver but also still be multi-release.
Seems to work on RELENG_4 through -current and also on sparc64
now. There may still be some issues with the auto attach/detach
code to sort out.

MFC after:	3 days
2007-05-05 20:17:23 +00:00
Scott Long
8008a935a7 Revert a driver API change to xpt_alloc_ccb that isn't necessary. Fix a
couple of associated error checks.
2007-04-18 04:58:53 +00:00
Scott Long
2b83592fdc Remove Giant from CAM. Drivers (SIMs) now register a mutex that CAM will
use to synchornize and protect all data objects that are used for that
SIM.  Drivers that are not yet MPSAFE register Giant and operate as
usual.  RIght now, no drivers are MPSAFE, though a few will be changed
in the coming week as this work settles down.

The driver API has changed, so all CAM drivers will need to be recompiled.
The userland API has not changed, so tools like camcontrol do not need to
be recompiled.
2007-04-15 08:49:19 +00:00
Matt Jacob
9a1b0d43c2 Temporarily desupport simultaneous target and initiator mode.
When the linux port changes were imported which split the
target command list to be separate from the initiator command
list and the handle format changed to encode a type in the handle
the implications to the function isp_handle_index (which only
the NetBSD/OpenBSD/FreeBSD ports use) were overlooked.

The fault is twofold: first, the index into the DMA maps
in  isp_pci is wrong because a target command handle with
the type bit left in place caused a bad index (and panic)
into dma map. Secondly, the assumption of the array
of DMA maps in either PCS or SBUS attachment structures is
that there is a linear mapping between handle index and
DMA map index. This can no longer be true if there are
overlapping index spaces for initiator mode and target
mode commands.

These changes bandaid around the problem by forcing us
to not have simultaneous dual roles and doing the appropriate
masking to make sure things are indexed correctly. A longer
term fix is being devloped.
2007-04-02 01:04:20 +00:00
Matt Jacob
9f9e9ae3a7 Fix compilation problem (add a const) for pre-7.0 compiles. 2007-03-31 21:01:35 +00:00
Matt Jacob
c6048aee5d some minor error message cleanups 2007-03-29 21:29:26 +00:00
Matt Jacob
2e35504d71 Don't derference a pointer before setting it.
Very Pointy Dunce Cap T o: me.
Submitted by:	Marcel
MFC after:	3 days
2007-03-28 16:34:11 +00:00
Matt Jacob
5f634111fa MFP4: a) Some constification from NetBSD (gcc 4.1.2)
b) Split default param fetching/setting into scsi and fibre functions
and retry the fibre fetch more than once.

MFC after:	1 week
2007-03-22 23:38:32 +00:00
Matt Jacob
f6a6ae8f5c Don't call isp_intr from isp_start- this seems to, in rare cases,
cause confusion with at least the 23XX chipsets where the output
queue index pointer just gets a bit whacko.

MFC after:	1 day
2007-03-14 05:58:07 +00:00
Matt Jacob
6a7d12e1a8 Move bus_space_tag and bus_space_handle register access
tokens into the common isp_osinfo structure instead of being
in bus specific structures. This allows us to implement
a SYNC_REG MEMORYBARRIER call (using bus_space_barrier)
and also reduce the amount of bus specific wrapper structure
usages in isp_pci && isp_sbus.

MFC after:	3 days
2007-03-13 06:46:08 +00:00
Matt Jacob
9418a60cb0 Restore optr if you trash it for 24XX target mode.
MFC after:	3 days
2007-03-13 06:44:07 +00:00
Matt Jacob
70273f9064 Fix compilation issues found in RELENG_4 port and merge the
diffs back to -current to keep versions identical.
2007-03-12 04:54:30 +00:00
Matt Jacob
e48b2487a0 Fix some stupid copyright mistakes that have been there for quite some time. 2007-03-10 02:39:54 +00:00
Matt Jacob
5f53837698 Redo previous newbus related change to be kinder to
multi-release support.
2007-02-23 23:13:46 +00:00
Matt Jacob
af4394d40a Don't attempt to load illegal hard loop addresses into
an ICB. This shows up on card restarts, and usually for
2200-2300 cards. What happens is that we start up,
attempting to acquire a hard address. We end up instead
being an F-port topology, which reports out a loop id
of 0xff (or 0xffff for 2K Login f/w). Then, if we restart,
we end up telling the card to go off an acquire this loop
address, which the card then rejects. Bah.

Compilation fixes from Solaris port.
2007-02-23 21:59:21 +00:00
Paolo Pisati
ef544f6312 o break newbus api: add a new argument of type driver_filter_t to
bus_setup_intr()

o add an int return code to all fast handlers

o retire INTR_FAST/IH_FAST

For more info: http://docs.freebsd.org/cgi/getmsg.cgi?fetch=465712+0+current/freebsd-current

Reviewed by: many
Approved by: re@
2007-02-23 12:19:07 +00:00
Matt Jacob
ffcf6651a0 Use the new xpt_rescan function to truly now have dynamic
attachment of new devices that arrive (and we notice them
via async Fibre Channel events). We've always had the
right thing (of sorts) happen when devices go away- this
is the corollary function that makes multipath failover
actually work.

MFC after:	2 weeks
2007-02-23 05:51:57 +00:00
Matt Jacob
336b56124b There is a problem in setting/getting 'options'- if we check things
early, we haven't set board type, so we can't correctly check for
some options.  Fix this by splitting option setting/getting into
generic, pci and then later board specific, option setting/getting.

This was noticed when setting 'iid' (or 'hard loop id') didn't work
all of a sudden.

Noticed by: Mike Drangula (thanks!) via Jung-uk Kim (thanks!)
2007-02-23 05:42:41 +00:00
Matt Jacob
1b960c0b77 Be a bit more restrictive about printing out 'bad' pdb entries
during loop rescans. They're not bad so much as unstable, so
don't print this stuff out unless ISP_LOGSANCFG is set.
2007-02-23 05:39:58 +00:00
Luigi Rizzo
33d5497079 Cleanup and document the implementation of firmware(9) based on
a version that i posted earlier on the -current mailing list,
and subsequent feedback received.

The core of the change is just in sys/firmware.h and kern/subr_firmware.c,
while other files are just adaptation of the clients to the ABI change
(const-ification of some parameters and hiding of internal info,
so this is fully compatible at the binary level).

In detail:
- reduce the amount of information exported to clients in struct firmware,
  and constify the pointer;

- internally, document and simplify the implementation of the various
  functions, and make sure error conditions are dealt with properly.

The diffs are large, but the code is really straightforward now (i hope).

Note also that there is a subtle issue with the implementation of
firmware_register(): currently, as in the previous version, we just
store a reference to the 'imagename' argument, but we should rather
copy it because there is no guarantee that this is a static string.
I realised this while testing this code, but i prefer to fix it in
a later commit -- there is no regression with respect to the past.

Note, too, that the version in RELENG_6 has various bugs including
missing locks around the module release calls, mishandling of modules
loaded by /boot/loader, and so on, so an MFC is absolutely necessary
there.  I was just postponing it until this cleanup to avoid doing
things twice.

MFC after: 1 week
2007-02-15 17:21:31 +00:00
Matt Jacob
392695e05c add a missing piece for 2432 2007-02-10 04:00:57 +00:00
Matt Jacob
41675df008 Putative untested 2432 (PCI-E) support. 2007-02-10 03:33:09 +00:00
Matt Jacob
f9734398e3 Clean up some of the various platform and release specific dma tag
stuff so it is centralized in isp_freebsd.h.

Take out PCI posting flushed in qla2100/2200 register reads except for
2100s.
2007-01-23 00:02:29 +00:00
Marius Strobl
c2175ff5ca Change the remainder of the drivers for DMA'ing devices enabled in the
sparc64 GENERIC and the sound device drivers known working on sparc64
to use bus_get_dma_tag() to obtain the parent DMA tag so we can get rid
of the sparc64_root_dma_tag kludge eventually. Except for ath(4), sk(4),
stge(4) and ti(4) these changes are runtime tested (unless I booted up
the wrong kernels again...).
2007-01-21 19:32:51 +00:00
Matt Jacob
8ada63303e Grumble- let a linux-ism slip in and had an llx which
then choked on a 64 bit platforms. Oops.
2007-01-20 07:38:31 +00:00
Matt Jacob
6c81a0aecb 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.
2007-01-20 04:00:21 +00:00
Matt Jacob
d4c8377f6c RELENG_6 compilation 2007-01-05 23:01:54 +00:00
Matt Jacob
5ccae6a508 error print cleanup && turn off ints if RISC is paused 2007-01-05 23:01:35 +00:00
Matt Jacob
450ca4603d Check the return from registering FC4 types with the fabric name
server.

Don't complain about a hard loop id of 0xffff- we get this in
point-to-point topologies with the 2300 and 2K Login firmware.

Up the timeout on register FC4 types commands.
2007-01-05 22:59:26 +00:00
Matt Jacob
06cacb29ca Restore revision 1.126 that got accidentally nuked. 2006-12-18 23:53:39 +00:00
Matt Jacob
805e1f828c Add back some CAM_NEW_TRAN code to make backporting to RELENG_6 easier. 2006-12-18 23:50:30 +00:00
Matt Jacob
a4f3a2bef4 Try an experiment with using DMA to load firmware into a 2200- VERIFY
CHECKSUM fails. Oh well, but keep a couple of the changes.

Avoid overflow in usec counters when waiting for mailbox completion.
2006-12-17 16:59:19 +00:00
Matt Jacob
3bda7a83b0 Implement ISP_RESET0 for PCI and SBUS attachments- isp_reset has
been modified to call ISP_RESET0 if it fails to do a reset. This
gives us a chance to disable interrupts.
2006-12-16 05:54:29 +00:00
Matt Jacob
3cce220cba Remove dependency on ispfw and firmware as modules.
Either they're there early and the ispfw sets have
registered themselves, or they're not.

The module dependency stuff isn't quite what we want
anyway. If the user doesn't want the load placed on
system memory by loading the firmware, they don't
specify it to be loaded (either by being linked in
or via being a module to be loaded and then hooked
in with firmware(9)). It doesn't then make sense to
then override what they want by pulling it in anyway.

This might be able to work if we were able to pull in
just exactly what we needed for the card we have- but
that's an optimization left for the future.
2006-12-10 03:41:48 +00:00
Matt Jacob
6890d7af94 clarify a comment slightly 2006-12-09 01:33:55 +00:00
Matt Jacob
9b03492a7d Find another spot where tagged command queueing got
accidentally nuked.
2006-12-09 01:30:05 +00:00
Matt Jacob
dd9fc7c319 Make ISPCTL_PLOGX find a handle to log into the management server
with- not hope for the best. Change some things which were gated
off of 24XX to be gated off of 2K login support. Convert some
isp_prt calls to xpt_print calls.
2006-12-05 07:50:23 +00:00
Matt Jacob
351c7054ea Add a chip timeout to ENABLE/MODIFY/DISABLE lun calls.
MFC after:	1 month
2006-12-05 07:49:15 +00:00
Matt Jacob
b61386a482 Fix XPT_GET_TRANSPORT_SETTINGS to zero validity and flags-
this was causing us to not negotiate sync at all, or at
random.
2006-12-03 07:22:15 +00:00
Matt Jacob
04697f7aa3 Make the SAN login/logout stuff more common between different chipsets
and provied an isp_control entry point so that the outer layers can
do PLOGI/LOGO explicitly. Add MS IOCB support. This completes the cycle
for base support for SMI-S.
2006-11-18 03:53:16 +00:00
Matt Jacob
6301ffe515 Disable code to set max read byte count on the 2400.
It caused a panic in writing the config register on a system. Turn
it off until we take the time to understand it.

Reported by and Testing by: Anton
2006-11-17 17:32:45 +00:00
Matt Jacob
2cad1d9857 Increase the timeout for some SAN commands.
Only complain about FC Reponse errors if they're nonzero.

Shorten some PortID printouts for local loop.

Add an internal isp_xcmd_t data structure which we'll use for some
CT-Passthru support as part of adding SMI-S.
2006-11-16 00:39:56 +00:00
Matt Jacob
e49f99cd9f minor change to reduce some diff noise 2006-11-16 00:31:46 +00:00
Matt Jacob
f7c631bcf0 Push things closer to path failover by implementing loop down and
gone device timers and zombie state entries. There are tunables
that can be used to select a number of parameters.

loop_down_limit - how long to wait for loop to come back up before
declaring
all devices dead (default 300 seconds)

gone_device_time- how long to wait for a device that has appeared
to leave the loop or fabric to reappear (default 30 seconds)

Internal tunables include (which should be externalized):

quick_boot_time- how long to wait when booting for loop to come up

change_is_bad- whether or not to accept devices with the same
WWNN/WWPN that reappear at a different PortID as being the 'same'
device.

Keen students of some of the subtle issues here will ask how
one can keep devices from being re-accepted at all (the answer
is to set a gone_device_time to zero- that effectively would
be the same thing).
2006-11-14 08:45:48 +00:00
Matt Jacob
10365e5a68 Add 4Gb (24XX) support and lay the foundation for a lot of new stuff. 2006-11-02 03:21:32 +00:00
Matt Jacob
bd3fd815a7 2nd and final commit that moves us to CAM_NEW_TRAN_CODE
as the default.

Reviewed by multitudes.
2006-11-02 00:54:38 +00:00
Matt Jacob
fa9ed86506 The first of 3 major steps to move the CAM layer forward to using
the CAM_NEW_TRAN_CODE that has been in the tree for some years now.

This first step consists solely of adding to or correcting
CAM_NEW_TRAN_CODE pieces in the kernel source tree such
that a both a GENERIC (at least on i386) and a LINT build
with CAM_NEW_TRAN_CODE as an option will compile correctly
and run (at least with some the h/w I have).

After a short settle time, the other pieces (making
CAM_NEW_TRAN_CODE the default and updating libcam
and camcontrol) will be brought in.

This will be an incompatible change in that the size of structures
related to XPT_PATH_INQ and XPT_{GET,SET}_TRAN_SETTINGS change
in both size and content. However, basic system operation and
basic system utilities work well enough with this change.

Reviewed by:	freebsd-scsi and specific stakeholders
2006-10-31 05:53:29 +00:00
Matt Jacob
9311717d79 Begin the process of moving info to sysctl stuff for FreeBSD
by providing OIDs for WWNN/WWPN and Initiator ID.
2006-09-26 04:59:52 +00:00
Matt Jacob
198b33587b Restore multi-version cleanliness. 2006-09-03 01:26:55 +00:00
John-Mark Gurney
378f231e7d add a newbus method for obtaining the bus's bus_dma_tag_t... This is
required by arches like sparc64 (not yet implemented) and sun4v where there
are seperate IOMMU's for each PCI bus...  For all other arches, it will
end up returning NULL, which makes it a no-op...

Convert a few drivers (the ones we've been working w/ on sun4v) to the
new convection...  Eventually all drivers will need to replace the parent
tag of NULL, w/ bus_get_dma_tag(dev), though dev is usually different for
each driver, and will require hand inspection...

Reviewed by:	scottl (earlier version)
2006-09-03 00:27:42 +00:00
Matt Jacob
8070de6398 More ispfwfunc definitions funnies which break pre-7.0 builds. 2006-09-01 05:03:42 +00:00
Matt Jacob
784ed7076c Add missing pre-7.0 firmware pointer. Oops. 2006-09-01 04:57:14 +00:00
Matt Jacob
54256b0109 fix bug in 2322 receive sequencer f/w load 2006-09-01 04:18:17 +00:00
Matt Jacob
2298c14c62 Fix RELENG_4 code version- isp_roles wasn't getting initialized so
it ended up defaulting to ISP_ROLE_NONE. My testing hadn't caught it
because I was deliberatly setting role via ioctl.

Thanks to user Toni for lending me an alpha to test this on.

MFC after:	0 days
2006-08-21 00:46:10 +00:00
Matt Jacob
1e6fdb7e32 Fix 2KLOGIN code to specify *ibits* (not *obits*) so that the
options field in register 10 will be deterministic, not random.

Correct the number of input bits for EXECUTE_FIRMWARE 0..1 to
0..2- the 2322 and 24XX cards use mailbox register 2 to specify
whether the f/w being executed is freshly loaded or not.

Correct the number of input bits for {READ,WRITE}_RAM_WORD_EXTENDED
so that register 8 gets picked up.

Fix the indexing and offset for the 2322 f/w download so that it
correctly puts the different code segments where they belong.

Move VERIFY_CHECKSUM to be the 'else' clause to 2322 f/w downloads-
the EXECUTE_FIRMWARE command for 2322 and 24XX cards will tell you
if the f/w checksum is incorrect and VERIFY_CHECKSUM only works for
RISC SRAM address < 64K so you can only do a VERIFY_CHECKSUM on the
first of the 3 f/w segments for the 2322.

Shorten the delay for the continuation mailbox commands- 1ms is
ridiculous (100us is more likely).

All of the more or less is really only for the 2322/6322 cards.
2006-08-14 05:42:46 +00:00
Matt Jacob
4cc9e3e7cc The register offset is within 4K, not 256 bytes, for some QLogic cards. 2006-08-14 05:36:26 +00:00
Matt Jacob
6322f5abb7 The macro IS_23XX should not mistakenly include 24XX cards. 2006-08-14 05:35:41 +00:00
Matt Jacob
92fcaeee9b Remove reference to PTI cards. They haven't been functioning
or around for probably at least 5 years.
2006-08-05 04:21:20 +00:00
Matt Jacob
bcec98969f Increase local reserved (high && low) storage in each command
structure from 2 to 3 words.
2006-08-04 20:20:55 +00:00
Matt Jacob
b4110d4604 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).
2006-08-04 20:20:00 +00:00
Matt Jacob
4177525533 Initialize 2300 request/response pointers in isp_reset- not in
isp_fibre_init.
2006-08-04 20:14:52 +00:00
Matt Jacob
f0f536d1ae Rename ioctl driven task management functions so they
don't collide with task management definitions on other
platforms.
2006-08-04 20:14:03 +00:00
Matt Jacob
799881e094 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.
2006-07-16 20:11:50 +00:00
Matt Jacob
a887f1a657 Don't attach 2422's yet. It just confuses everyone. 2006-07-14 05:16:00 +00:00
Matt Jacob
ddf6c7dadd Add some missing braces.
Add MEMORY_BARRIER for the few scratch dma ops that were missing
them plus add a couple of hi 32 bit dma ops (we could probably
allow 64 bit scratch and request/response queue dma now).
2006-07-14 05:14:48 +00:00
Matt Jacob
99ece8d676 Put in some missing target mode for 2KLOGIN f/w spots.
MFC after:	1 month
2006-07-10 22:40:21 +00:00
Matt Jacob
02e2b2d961 Clean up the ioctl to not process nonsense on SCSI isp cards.
MFC after:	1 month
2006-07-10 22:39:32 +00:00
Matt Jacob
9a5af41076 Convert isp(4) and ispfw(4) to use firmware(9) to manage firmware
loading for the QLogic cards.

Because isp(4) exists before the root is mounted, it's not really
possible for us to use the kernel's linker to load modules directly
from disk- that's really too bad.

However, the this is still a net win in in that the firmware has
been split up on a per chip (and in some cases, functionality)
basis, so the amount of stuff loaded *can* be substantially less
than the 1.5MB of firmware images that ispfw now manages. That is,
each specific f/w set is now also built as a module. For example,
QLogic 2322 f/w is built as isp_2322.ko and Initiator/Target 1080
firmware is built as isp_1080_it.ko.

For compatibility purposes (i.e., to perturb folks the least), we
also still build all of the firmware as one ispfw.ko module.

This allows us to let 'ispfw_LOAD' keep on working in existing
loader.conf files. If you now want to strip this down to just
the firmware for your h/w, you can then change loader.conf to
load the f/w you specifically want.

We also still allow for ispfw to be statically built (e.g., for
PAE and sparc64).

Future changes will look at f/w unloading and also role switching
that then uses the kernel linker to load different ips f/w sets.
MFC after:	2 months
2006-07-09 17:50:20 +00:00
Matt Jacob
6cc12d1bb6 What the heck - make the last (most recent) 2200 f/w also do
Hard Loop acquisition.
2006-07-03 20:56:48 +00:00
Matt Jacob
8a97c03a7a Do various fixes to support firmware loading for the 2322
(and by extension, the 2422).

One peculiar thing I've found with the 2322 is that if you
don't force it to do Hard LoopID acquisition, the firmware
crashes. This took a while to figure out.

While we're at it, fix various bugs having to do with NVRAM
reading and option setting with respect to pieces of NVRAM.
2006-07-03 08:24:09 +00:00
Matt Jacob
9b58ff9636 allow this to compile cleanly under RELENG_4 2006-06-03 07:19:44 +00:00
Matt Jacob
6b5ec766e9 Don't set CAM_DEV_QFRZN when we get an ABORT_TASK. Just
by itself, this makes no sense.
2006-05-30 17:43:04 +00:00
Matt Jacob
d4a6993a58 Add missing case for RQSTYPE_CTIO3- neede for 64 bit target mode. 2006-05-22 07:07:30 +00:00
Matt Jacob
099348678f Remove bzero/bcopy vestiges
Be cognizant as to whether we're running 2KLogin f/w in target mode and
do the appropriate loopid load based upon that.

Do a first cut (seems to work, at least for amd64) at 64 bit target
mode for fibre channel cards. We could probably also do it for SPI
cards, but that's not supported right now.
2006-05-22 06:51:48 +00:00
Matt Jacob
29f7667573 Remove bzero/bcopy vestiges.
Be cognizant as to whether we're running 2KLogin f/w in target mode and
do the appropriate loopid load based upon that.
2006-05-22 06:49:49 +00:00
Matt Jacob
8f725bae42 remove bzero/bcopy vestiges 2006-05-22 06:48:40 +00:00
Matt Jacob
4f43135c60 add TGT_ANY define 2006-05-22 06:47:42 +00:00
Matt Jacob
f1c6617ad4 Fix longstanding bug where exec throttle is 16 bits- not 8. 2006-05-22 06:47:20 +00:00
Matt Jacob
452de53a54 Move a define depending on __FreeBSD_versoin to after where it
would be defined.

Submitted by:   Ruslan Ermilov
2006-05-16 16:31:58 +00:00
Poul-Henning Kamp
c40da00ca3 Since DELAY() was moved, most <machine/clock.h> #includes have been
unnecessary.
2006-05-16 14:37:58 +00:00
Matt Jacob
8c4e89e249 Redo some code based upon issues found by Coverity. 2006-04-21 18:46:35 +00:00
Matt Jacob
9cd7268e5a 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.
2006-04-21 18:30:01 +00:00
Matt Jacob
c1504bc00d micro fix from justin 2006-03-03 07:04:43 +00:00
Matt Jacob
c6435ff3dd propagate role of device for ISP_GET_PDBINFO 2006-02-26 22:40:56 +00:00
Matt Jacob
1dae40eb49 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
2006-02-15 00:31:48 +00:00
Matt Jacob
51effc8cd5 Actually, no, I had it wrong in 1.109. The arguments to bus_dma_create_tag
are bus_addr_t, not bus_size_t.

In any case, turn off DAC support entirely until it is revamped to actually
work *correctly* for 64 bit platforms (not using a PAE definition and for
both initiator and target mode).
2006-02-04 08:39:02 +00:00
Scott Long
4b2dc3c447 i386/PAE defines bus_size_t to be 32-bits when it likely should be 64-bits.
Fixing it is left for another day, so just hack around it for now.
2006-02-04 03:41:48 +00:00
Marius Strobl
8d727356c6 - Don't shift the clock frequency in MHz left by 8 before assigning it
to sbus_mdvec.dv_clock as sbus_mdvec.dv_clock is meant to be specified
  in MHz. While this was a bug it shouldn't have affected FreeBSD/sparc64
  as sbus_mdvec.dv_clock is used to limit the clock rate of chips when
  a machine isn't able to support them at maximum speed which isn't the
  case for sun4u machines.
- Remove the code that checks whether the clock frequency returned by
  sbus_get_clockfreq() is 0 and falls back to 25MHz if it is as that's
  already done in sbus(4).

Approved by:	mjacob
MFC after:	3 days
2006-02-03 12:35:42 +00:00
Matt Jacob
53af7d226e Remove use of inlines and use the functions as a library.
Larger code space, possibly performance hit, but more portable.
Certainly less questionable use of inlining.

Suggested by: des
2006-02-02 21:31:34 +00:00
Matt Jacob
b7918ba53a Make sure we don't pick up a loopid that's larger than our
current portdb max (MAX_FC_TARG == 256) now that we support
2K Login f/w.

MFC after:	3 days
2006-02-02 09:02:16 +00:00
Matt Jacob
09ae127f7d Hackamatic: turn off target mode on Sparc64 with KLD_MODULE- this triggers
a compiler error I have no idea what its about.

This should unbreak tinderbox for now.
2006-01-27 00:46:10 +00:00
Matt Jacob
6c4266852d oops 2006-01-26 06:15:58 +00:00
Matt Jacob
8872e3d7e5 Put in at least an attempt to ID the 2422 (4Gb part) 2006-01-26 05:04:35 +00:00
Matt Jacob
e526523707 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
2006-01-23 06:23:37 +00:00
John Baldwin
74a96f4337 Use uintmax_t and %j to print bus dma segment members rather than casting
to long long and using %ll.
2005-12-15 22:12:27 +00:00
Ruslan Ermilov
f4e9888107 Fix -Wundef. 2005-12-04 02:12:43 +00:00
Matt Jacob
8e62a8ac99 Add an ioctl framework for doing FC task management functions from
a user space tool- useful for doing FC target mode certification.
2005-10-29 02:46:59 +00:00
Matt Jacob
9f242f7893 AT_MAKE_TAGID needs an instance as the 2nd arg- not just a 0. 2005-07-31 23:21:19 +00:00
Yoshihiro Takahashi
d4fcf3cba5 Remove bus_{mem,p}io.h and related code for a micro-optimization on i386
and amd64.  The optimization is a trivial on recent machines.

Reviewed by:	-arch (imp, marcel, dfr)
2005-05-29 04:42:30 +00:00
Matt Jacob
b49c46747a Fix some incorrectly swapped fields in an ICB.
Access a PCI register with correct width.

Obtained from:	Dmitry Valeryevich Trikoz
2005-05-11 03:00:50 +00:00
Matt Jacob
547725be50 Refactor isp_prt declaration so that platform
requirements can stay in platform files.
2005-05-11 00:22:17 +00:00
Stefan Farfeleder
e68c6390f4 Prefer <sys/cdefs.h>'s __printflike() macro to the recently added
__GNUCLIKE_ATTRIBUTE_PRINTF.

Approved by:	mjacob
2005-03-07 15:29:11 +00:00
Warner Losh
b77e575e1d Use BUS_PROBE_DEFAULT for pci probe return value 2005-03-05 18:17:35 +00:00
Joerg Wunsch
a5f50ef9e4 netchild's mega-patch to isolate compiler dependencies into a central
place.

This moves the dependency on GCC's and other compiler's features into
the central sys/cdefs.h file, while the individual source files can
then refer to #ifdef __COMPILER_FEATURE_FOO where they by now used to
refer to #if __GNUC__ > 3.1415 && __BARC__ <= 42.

By now, GCC and ICC (the Intel compiler) have been actively tested on
IA32 platforms by netchild.  Extension to other compilers is supposed
to be possible, of course.

Submitted by:	netchild
Reviewed by:	various developers on arch@, some time ago
2005-03-02 21:33:29 +00:00
Scott Long
da6297fcf9 Provide a needed argument to AT_MAKE_TAGID. 2005-01-23 22:33:59 +00:00
Matt Jacob
1b94141649 Add some macros for inserting tag ids.
MFC after:	2 weeks
2005-01-23 06:28:49 +00:00
Matt Jacob
182d1c037e Macroize the making of tag ids.
MFC after:	2 weeks
2005-01-23 06:28:08 +00:00
Matt Jacob
99334b0de4 Roll minor number.
MFC after:	2 weeks
2005-01-23 06:27:05 +00:00
Matt Jacob
f2e4186204 Don't set ZIO for 23XX for target mode (use fast posting instead).
Use the correct number of handles for multihandle returns.

Very, very, rarely on some SMP systems we've seen an 'unstable' type
in the response queue. I dunno whether or not it's a bug in our
handling, or whether there's a cache incoherency issue, but
try to guard against it.

MFC after:	2 weeks
2005-01-23 06:26:45 +00:00
Matt Jacob
dd1419abe1 Support the DELL OEM 2312 cards (1077,6312).
Many thanks to Stormweb for making the h/w available for testing.

MFC after:	2 days
2005-01-23 06:23:55 +00:00
Warner Losh
098ca2bda9 Start each of the license/copyright comments with /*-, minor shuffle of lines 2005-01-06 01:43:34 +00:00
Matt Jacob
6976709916 PAE support changes that included at least some minimal actual testing
with a kernel that booted.
2004-09-23 05:25:22 +00:00
Matt Jacob
6de9bf776e Do the small amount of tweaking to support PAE for at least initiator mode.
I was unable to test this as the PAE kernel crashed with a "cannot copy
LDT" before coming up. When this gets a bit more testing, I'll fix the PAE
conf file to allow isp devices.

PR:		59728
2004-09-07 08:04:09 +00:00
Matt Jacob
e3e49f7e32 Until I can get a clearer architecture from PHK about why he wants
the geometry code to grab a mutex that prohibits any driver on the
stack below it from sleeping, it's not safe to allow anything in
the top half of isp to sleep (excepting the thread that Fibre Channel
instances use to re-scan loops/fabrics).
2004-08-23 19:04:19 +00:00
Marius Strobl
26280d88d7 - Introduce an ofw_bus kobj-interface for retrieving the OFW node and a
subset ("compatible", "device_type", "model" and "name") of the standard
  properties in drivers for devices on Open Firmware supported busses. The
  standard properties "reg", "interrupts" und "address" are not covered by
  this interface because they are only of interest in the respective bridge
  code. There's a remaining standard property "status" which is unclear how
  to support properly but which also isn't used in FreeBSD at present.
  This ofw_bus kobj-interface allows to replace the various (ebus_get_node(),
  ofw_pci_get_node(), etc.) and partially inconsistent (central_get_type()
  vs. sbus_get_device_type(), etc.) existing IVAR ones with a common one.
  This in turn allows to simplify and remove code-duplication in drivers for
  devices that can hang off of more than one OFW supported bus.
- Convert the sparc64 Central, EBus, FHC, PCI and SBus bus drivers and the
  drivers for their children to use the ofw_bus kobj-interface. The IVAR-
  interfaces of the Central, EBus and FHC are entirely replaced by this. The
  PCI bus driver used its own kobj-interface and now also uses the ofw_bus
  one. The IVARs special to the SBus, e.g. for retrieving the burst size,
  remain.
  Beware: this causes an ABI-breakage for modules of drivers which used the
  IVAR-interfaces, i.e. esp(4), hme(4), isp(4) and uart(4), which need to be
  recompiled.
  The style-inconsistencies introduced in some of the bus drivers will be
  fixed by tmm@ in a generic clean-up of the respective drivers later (he
  requested to add the changes in the "new" style).
- Convert the powerpc MacIO bus driver and the drivers for its children to
  use the ofw_bus kobj-interface. This invloves removing the IVARs related
  to the "reg" property which were unused and a leftover from the NetBSD
  origini of the code. There's no ABI-breakage caused by this because none
  of these driver are currently built as modules.
  There are other powerpc bus drivers which can be converted to the ofw_bus
  kobj-interface, e.g. the PCI bus driver, which should be done together
  with converting powerpc to use the OFW PCI code from sparc64.
- Make the SBus and FHC front-end of zs(4) and the sparc64 eeprom(4) take
  advantage of the ofw_bus kobj-interface and simplify them a bit.

Reviewed by:	grehan, tmm
Approved by:	re (scottl)
Discussed with:	tmm
Tested with:	Sun AX1105, AXe, Ultra 2, Ultra 60; PPC cross-build on i386
2004-08-12 17:41:33 +00:00
Poul-Henning Kamp
89c9c53da0 Do the dreaded s/dev_t/struct cdev */
Bump __FreeBSD_version accordingly.
2004-06-16 09:47:26 +00:00
Poul-Henning Kamp
186f2b9e04 Add missing <sys/module.h> includes currently relying on nested include
in <sys/kernel.h>
2004-06-03 06:10:02 +00:00
Nate Lawson
51e2355882 Store the target handles in a separate list from normal commands. Add a
CTIO fast post routine to handle CTIO completions.

Submitted by:	mjacob
2004-05-24 07:02:25 +00:00
Thomas Moestl
eb01b42587 Correct the boundary parameter to the bus_dma_tag_create() calls (it was
(1 << 24) - 2 instead of 1 << 24, which it was obviously intended to
be). This fixes SBus isp(4)s on sparc64 machines.

Report and testing:  Marius Strobl <marius@alchemy.franken.de>
2004-03-23 23:41:39 +00:00
Nate Lawson
5f96beb9e0 Convert callers to the new bus_alloc_resource_any(9) API.
Submitted by:	Mark Santcroos <marks@ripe.net>
Reviewed by:	imp, dfr, bde
2004-03-17 17:50:55 +00:00
Tom Rhodes
a122cca953 These are changes to allow to use the Intel C/C++ compiler (lang/icc)
to build the kernel. It doesn't affect the operation if gcc.

Most of the changes are just adding __INTEL_COMPILER to #ifdef's, as
icc v8 may define __GNUC__ some parts may look strange but are
necessary.

Additional changes:
 - in_cksum.[ch]:
   * use a generic C version instead of the assembly version in the !gcc
     case (ASM code breaks with the optimizations icc does)
     -> no bad checksums with an icc compiled kernel
     Help from:		andre, grehan, das
     Stolen from: 	alpha version via ppc version
     The entire checksum code should IMHO be replaced with the DragonFly
     version (because it isn't guaranteed future revisions of gcc will
     include similar optimizations) as in:
        ---snip---
          Revision  Changes    Path
          1.12      +1 -0      src/sys/conf/files.i386
          1.4       +142 -558  src/sys/i386/i386/in_cksum.c
          1.5       +33 -69    src/sys/i386/include/in_cksum.h
          1.5       +2 -0      src/sys/netinet/igmp.c
          1.6       +0 -1      src/sys/netinet/in.h
          1.6       +2 -0      src/sys/netinet/ip_icmp.c

          1.4       +3 -4      src/contrib/ipfilter/ip_compat.h
          1.3       +1 -2      src/sbin/natd/icmp.c
          1.4       +0 -1      src/sbin/natd/natd.c
          1.48      +1 -0      src/sys/conf/files
          1.2       +0 -1      src/sys/conf/files.amd64
          1.13      +0 -1      src/sys/conf/files.i386
          1.5       +0 -1      src/sys/conf/files.pc98
          1.7       +1 -1      src/sys/contrib/ipfilter/netinet/fil.c
          1.10      +2 -3      src/sys/contrib/ipfilter/netinet/ip_compat.h
          1.10      +1 -1      src/sys/contrib/ipfilter/netinet/ip_fil.c
          1.7       +1 -1      src/sys/dev/netif/txp/if_txp.c
          1.7       +1 -1      src/sys/net/ip_mroute/ip_mroute.c
          1.7       +1 -2      src/sys/net/ipfw/ip_fw2.c
          1.6       +1 -2      src/sys/netinet/igmp.c
          1.4       +158 -116  src/sys/netinet/in_cksum.c
          1.6       +1 -1      src/sys/netinet/ip_gre.c
          1.7       +1 -2      src/sys/netinet/ip_icmp.c
          1.10      +1 -1      src/sys/netinet/ip_input.c
          1.10      +1 -2      src/sys/netinet/ip_output.c
          1.13      +1 -2      src/sys/netinet/tcp_input.c
          1.9       +1 -2      src/sys/netinet/tcp_output.c
          1.10      +1 -1      src/sys/netinet/tcp_subr.c
          1.10      +1 -1      src/sys/netinet/tcp_syncache.c
          1.9       +1 -2      src/sys/netinet/udp_usrreq.c

          1.5       +1 -2      src/sys/netinet6/ipsec.c
          1.5       +1 -2      src/sys/netproto/ipsec/ipsec.c
          1.5       +1 -1      src/sys/netproto/ipsec/ipsec_input.c
          1.4       +1 -2      src/sys/netproto/ipsec/ipsec_output.c

          and finally remove
            sys/i386/i386        in_cksum.c
            sys/i386/include     in_cksum.h
        ---snip---
 - endian.h:
   * DTRT in C++ mode
 - quad.h:
   * we don't use gcc v1 anymore, remove support for it
   Suggested by:	bde (long ago)
 - assym.h:
   * avoid zero-length arrays (remove dependency on a gcc specific
     feature)
     This change changes the contents of the object file, but as it's
     only used to generate some values for a header, and the generator
     knows how to handle this, there's no impact in the gcc case.
   Explained by:	bde
   Submitted by:	Marius Strobl <marius@alchemy.franken.de>
 - aicasm.c:
   * minor change to teach it about the way icc spells "-nostdinc"
   Not approved by:	gibbs (no reply to my mail)
 - bump __FreeBSD_version (lang/icc needs to know about the changes)

Incarnations of this patch survive gcc compiles since a loooong time,
I use it on my desktop. An icc compiled kernel works since Nov. 2003
(exceptions: snd_* if used as modules), it survives a build of the
entire ports collection with icc.

Parts of this commit contains suggestions or submissions from
Marius Strobl <marius@alchemy.franken.de>.

Reviewed by:	-arch
Submitted by:	netchild
2004-03-12 21:45:33 +00:00
Poul-Henning Kamp
dc08ffec87 Device megapatch 4/6:
Introduce d_version field in struct cdevsw, this must always be
initialized to D_VERSION.

Flip sense of D_NOGIANT flag to D_NEEDGIANT, this involves removing
four D_NOGIANT flags and adding 145 D_NEEDGIANT flags.
2004-02-21 21:10:55 +00:00
Poul-Henning Kamp
c9c7976f7f Device megapatch 1/6:
Free approx 86 major numbers with a mostly automatically generated patch.

A number of strategic drivers have been left behind by caution, and a few
because they still (ab)use their major number.
2004-02-21 19:42:58 +00:00
Matt Jacob
9b81514d7d We aren't D_TAPE. We aren't anything. The reasons why this was ever set
at all is lost in the mists of time.
2004-02-16 17:43:57 +00:00
Matt Jacob
67ff51f150 Remove condition variables and status associated with target mode
enabling. Instead, go to an interrupt/polled model.

Fix get_lun_statep so we don't panic if there are no wildcard luns enabled.

MFC after:	6 days
2004-02-08 19:17:56 +00:00
Matt Jacob
c98d7aa472 Remove condition variables and status associated with target mode
enabling. Instead, go to an interrupt/polled model.

MFC after:	6 days
2004-02-08 19:16:01 +00:00
Matt Jacob
746e9c8540 Checkpoint of work in progress in cleaning up target mode. It actually
seems to work well in RELENG_4. However, 5.X locking foo means that I'll
have to do some quick redesign.

Add ioctl handlers for ISP_GETROLE and ISP_SETROLE ioctls.
2004-02-07 03:47:33 +00:00
Matt Jacob
2cd44270e5 add a count for inotifies as well as atios.
MFC after:	1 week
2004-02-07 03:44:43 +00:00
Matt Jacob
4e8a2b48a7 Reverse role defines for initiator and target mode to better match the
class 3 service parameters we'd get.

Steal 8 bits out of the portid u_int32_t for role information (port ids
are 24 bits anyway).

MFC after:	1 week
2004-02-07 03:43:27 +00:00
Matt Jacob
cc330eadff Add case to handle ISPCTL_GET_PDB.
MFC after:	1 week
2004-02-07 03:42:17 +00:00
Matt Jacob
87ab7d39a4 If we're defined to have a default role for target mode, make it
just ISP_ROLE_TARGET- not both.

MFC after:	1 week
2004-02-07 03:39:42 +00:00
Matt Jacob
e0d3cfb7be Change role defines so that they better match class 3 service parameters.
Add ISPCTL_GET_PDB isp_control operation.

MFC after:	1 week
2004-02-07 03:38:39 +00:00
Matt Jacob
eedb2dfec3 Fix a bug where we never managed to include the sense data we wanted to send. 2004-01-29 06:36:30 +00:00