Commit Graph

82 Commits

Author SHA1 Message Date
Nate Lawson
a7e5261e30 Add PERIPH and XPT debug options to camcontrol. This makes all CAM debug
options tunable from userland.

Approved by:	ken
MFC after:	3 days
2002-12-17 06:05:21 +00:00
Matthew N. Dodd
d4e731a642 Split cam_argmask and move "commands" into cam_cmdmask. This addresses
the issue of not having any free bits left for additional commands.

Approved by:	 ken
MFC after:	 4 weeks
2002-09-08 05:39:36 +00:00
Matthew N. Dodd
f9cecca2d4 Add 'camcontrol load' as a complement to 'camcontrol eject'.
Approved by:	 ken
MFC after:	 4 weeks
2002-09-06 18:16:26 +00:00
Johan Karlsson
72abe188fb Take care of WARNS=3 warnings by using unsigned/signed variable
as needed.

Approved by:	ken, sheldonh (mentor)
2002-08-20 20:54:03 +00:00
Johan Karlsson
0319a6a43b Remove unused variable. camcontrol is now WARNS=2 clean on i386.
Approved by: 	ken, sheldonh (mentor)
2002-08-18 21:46:32 +00:00
Philippe Charnier
e1205e80e5 The .Nm utility 2002-07-06 19:34:18 +00:00
Garrett Wollman
b055b157dc Fix syntax errors (labels with no statement). 2002-05-30 21:38:58 +00:00
Kenneth D. Merry
515f06ebc0 Fix a bzero length calculation. sizeof(struct ccb_getdev) should have been
sizeof(struct ccb_getdevstats).

MFC after:	3 days
2002-04-01 03:58:51 +00:00
David E. O'Brien
3d438ad61f Remove 'register' keyword.
It does not help modern compilers, and some may take some hit from it.
(I also found several functions that listed *every* of its 10 local vars with
 "register" -- just how many free registers do people think machines have?)
2002-03-20 17:55:10 +00:00
Maxim Konovalov
e9ef556dd8 Correct an out of date device node name. We do not have /dev/rsd0.ctl
nowadays.

Spotted by:	Sergey Osokin <osa@freebsd.org.ru>
Reviewed by:	ken, ru
Approved by:	ken, ru
MFC after:	1 week
2002-02-11 14:35:28 +00:00
Ruslan Ermilov
485318d4d8 Style.
Approved by:	ken
2002-01-24 16:53:08 +00:00
Joerg Wunsch
7f3aade047 By popular demand, also include the "devlist" subcommand into the set
of commands available in the boot floppy environment.

MFC after:	1 week
2002-01-18 22:42:51 +00:00
Joerg Wunsch
075828a91a Well, RELEASE_BUILD_FIXIT has now been renamed into RELEASE_CRUNCH.
At least, the old version is still good for the MFC though (where
everything is still going the old way). ;-)
2002-01-18 22:17:35 +00:00
Kenneth D. Merry
5710d224b6 Add 'camcontrol rescan all' and 'camcontrol reset all' functionality to
camcontrol.

This enables rescanning all busses or resetting all busses in a system.
The current implementation is not the ideal way to do it -- the ideal way
to do it would be for the transport layer to handle wildcarded busses on
bus rescan and reset operations.  The current implementation enumerates all
the busses and sends a rescan or reset CCB individually.  Handling this
behavior in the transport layer will happen later.

Reviewed by:	imp
Tested by:	joerg
MFC after:	1 week
2002-01-18 18:00:00 +00:00
Joerg Wunsch
6437601ca1 Provide an option to make camcontrol `minimalistic': if the (env/make)
variable RELEASE_BUILD_FIXIT is defined, a camcontrol binary will be
built that only knows the "rescan" and "reset" subcommands.  The
resulting code is small enough to still fit onto the boot floppy.

Reviewed by:	ken
MFC after:	1 week
2002-01-17 20:26:14 +00:00
Kenneth D. Merry
8a8e67f308 Fix breakage in 'camcontrol defects' introduced in rev 1.34 (the new error
recovery code) back in March, 2001.

In effect, this brain-o would cause 'camcontrol defects' to always return
an error.

Pointed out by:	joerg
Tested by:	mdodd
2001-12-05 03:41:40 +00:00
David E. O'Brien
2d68bf45bf Default to WARNS=2.
Binary builds that cannot handle this must explicitly set WARNS=0.

Reviewed by:	mike
2001-12-04 02:19:58 +00:00
Ruslan Ermilov
9916c5d299 mdoc(7) police: replace \*(Ba' with a simple |', it's handled specially. 2001-08-16 11:09:00 +00:00
Ruslan Ermilov
753d686d34 mdoc(7) police: s/BSD/.Bx/ where appropriate. 2001-08-14 10:01:54 +00:00
Ruslan Ermilov
c4d9468ea0 mdoc(7) police:
Avoid using parenthesis enclosure macros (.Pq and .Po/.Pc) with plain text.
Not only this slows down the mdoc(7) processing significantly, but it also
has an undesired (in this case) effect of disabling hyphenation within the
entire enclosed block.
2001-08-07 15:48:51 +00:00
Sheldon Hearn
e1b4d8d074 Use STD{ERR,IN,OUT}_FILENO instead of their numeric values. The
definitions are more readable, and it's possible that they're
more portable to pathalogical platforms.

Submitted by:   David Hill <david@phobia.ms>
2001-07-26 11:02:39 +00:00
Dima Dorfman
7ebcc426ef Remove whitespace at EOL. 2001-07-15 07:53:42 +00:00
Kenneth D. Merry
3393f8daa3 Rewrite of the CAM error recovery code.
Some of the major changes include:

	- The SCSI error handling portion of cam_periph_error() has
	  been broken out into a number of subfunctions to better
	  modularize the code that handles the hierarchy of SCSI errors.
	  As a result, the code is now much easier to read.

	- String handling and error printing has been significantly
	  revamped.  We now use sbufs to do string formatting instead
	  of using printfs (for the kernel) and snprintf/strncat (for
	  userland) as before.

	  There is a new catchall error printing routine,
	  cam_error_print() and its string-based counterpart,
	  cam_error_string() that allow the kernel and userland
	  applications to pass in a CCB and have errors printed out
	  properly, whether or not they're SCSI errors.  Among other
	  things, this helped eliminate a fair amount of duplicate code
	  in camcontrol.

	  We now print out more information than before, including
	  the CAM status and SCSI status and the error recovery action
	  taken to remedy the problem.

	- sbufs are now available in userland, via libsbuf.  This
	  change was necessary since most of the error printing code
	  is shared between libcam and the kernel.

	- A new transfer settings interface is included in this checkin.
	  This code is #ifdef'ed out, and is primarily intended to aid
	  discussion with HBA driver authors on the final form the
	  interface should take.  There is example code in the ahc(4)
	  driver that implements the HBA driver side of the new
	  interface.  The new transfer settings code won't be enabled
	  until we're ready to switch all HBA drivers over to the new
	  interface.

src/Makefile.inc1,
lib/Makefile:		Add libsbuf.  It must be built before libcam,
			since libcam uses sbuf routines.

libcam/Makefile:	libcam now depends on libsbuf.

libsbuf/Makefile:	Add a makefile for libsbuf.  This pulls in the
			sbuf sources from sys/kern.

bsd.libnames.mk:	Add LIBSBUF.

camcontrol/Makefile:	Add -lsbuf.  Since camcontrol is statically
			linked, we can't depend on the dynamic linker
			to pull in libsbuf.

camcontrol.c:		Use cam_error_print() instead of checking for
			CAM_SCSI_STATUS_ERROR on every failed CCB.

sbuf.9:			Change the prototypes for sbuf_cat() and
			sbuf_cpy() so that the source string is now a
			const char *.  This is more in line wth the
			standard system string functions, and helps
			eliminate warnings when dealing with a const
			source buffer.

			Fix a typo.

cam.c:			Add description strings for the various CAM
			error status values, as well as routines to
			look up those strings.

			Add new cam_error_string() and
			cam_error_print() routines for userland and
			the kernel.

cam.h:			Add a new CAM flag, CAM_RETRY_SELTO.

			Add enumerated types for the various options
			available with cam_error_print() and
			cam_error_string().

cam_ccb.h:		Add new transfer negotiation structures/types.

			Change inq_len in the ccb_getdev structure to
			be "reserved".  This field has never been
			filled in, and will be removed when we next
			bump the CAM version.

cam_debug.h:		Fix typo.

cam_periph.c:		Modularize cam_periph_error().  The SCSI error
			handling part of cam_periph_error() is now
			in camperiphscsistatuserror() and
			camperiphscsisenseerror().

			In cam_periph_lock(), increase the reference
			count on the periph while we wait for our lock
			attempt to succeed so that the periph won't go
			away while we're sleeping.

cam_xpt.c:		Add new transfer negotiation code.  (ifdefed
			out)

			Add a new function, xpt_path_string().  This
			is a string/sbuf analog to xpt_print_path().

scsi_all.c:		Revamp string handing and error printing code.
			We now use sbufs for much of the string
			formatting code.  More of that code is shared
			between userland the kernel.

scsi_all.h:		Get rid of SS_TURSTART, it wasn't terribly
			useful in the first place.

			Add a new error action, SS_REQSENSE.  (Send a
			request sense and then retry the command.)
			This is useful when the controller hasn't
			performed autosense for some reason.

			Change the default actions around a bit.

scsi_cd.c,
scsi_da.c,
scsi_pt.c,
scsi_ses.c:		SF_RETRY_SELTO -> CAM_RETRY_SELTO.  Selection
			timeouts shouldn't be covered by a sense flag.

scsi_pass.[ch]:		SF_RETRY_SELTO -> CAM_RETRY_SELTO.

			Get rid of the last vestiges of a read/write
			interface.

libkern/bsearch.c,
sys/libkern.h,
conf/files:		Add bsearch.c, which is needed for some of the
			new table lookup routines.

aic7xxx_freebsd.c:	Define AHC_NEW_TRAN_SETTINGS if
			CAM_NEW_TRAN_CODE is defined.

sbuf.h,
subr_sbuf.c:		Add the appropriate #ifdefs so sbufs can
			compile and run in userland.

			Change sbuf_printf() to use vsnprintf()
			instead of kvprintf(), which is only available
			in the kernel.

			Change the source string for sbuf_cpy() and
			sbuf_cat() to be a const char *.

			Add __BEGIN_DECLS and __END_DECLS around
			function prototypes since they're now exported
			to userland.

kdump/mkioctls:		Include stdio.h before cam.h since cam.h now
			includes a function with a FILE * argument.

Submitted by:	gibbs (mostly)
Reviewed by:	jdp, marcel (libsbuf makefile changes)
Reviewed by:	des (sbuf changes)
Reviewed by:	ken
2001-03-27 05:45:52 +00:00
Ruslan Ermilov
0a5779d45b - Backout botched attempt to introduce MANSECT feature.
- MAN[1-9] -> MAN.
2001-03-26 14:33:27 +00:00
Ruslan Ermilov
fe655281c5 Set the default manual section for sbin/ to 8. 2001-03-20 18:13:31 +00:00
Ruslan Ermilov
1252c1bb05 Prepare for mdoc(7)NG. 2000-12-18 15:16:24 +00:00
Chris D. Faulhaber
b673f44d6d Properly check malloc(3) return values
Approved by:	ken
2000-12-01 12:02:16 +00:00
Kris Kennaway
797376317f Fix format string warnings 2000-11-27 07:28:15 +00:00
Ruslan Ermilov
7c7fb079b9 mdoc(7) police: use the new features of the Nm macro. 2000-11-20 16:52:27 +00:00
Kenneth D. Merry
de2464d3bc Adjust 'camcontrol negotiate -v' so it prints out the initiator ID from the
Path Inquiry CCB.
2000-09-17 20:42:28 +00:00
Warner Losh
fdcd5596ff optreset is declared in unistd.h, so we don't need to declare it here again.
Reviews by: ken
2000-08-16 15:36:14 +00:00
Kelly Yancey
354a0adabf Fix an order-of-operations bug and properly shift page_control values for
comparison with SMS_PAGE_CTRL_* macros.
2000-08-10 01:20:43 +00:00
Kelly Yancey
d996f0a884 Include new modepage list (-l) option in the verbose usage. 2000-08-09 21:29:22 +00:00
John Baldwin
34f71eeb3c Fix a typo in the last commit so that this compiles. 2000-08-09 00:28:09 +00:00
Kelly Yancey
cb498c18f8 Fix some whitespace errors.
Pointed out by:		ps
2000-08-08 09:27:55 +00:00
Kelly Yancey
9402dd9932 Replace -l with .Fl l
Pointed out by: sheldonh
2000-08-08 09:03:48 +00:00
Kelly Yancey
7e32b20d95 This is an overhaul of the mode page handling in camcontrol as well as
related patches. These include:
	* Mode page editting can be scripted. This involves two
	  things: first, if stdin is not a tty, changes are read from
	  stdin rather than invoking $EDITOR. Second, and more
	  importantly, not all modepage entries must be included in the
	  change set. This means that camcontrol can now gracefully handle
	  more intrusive editting from the $EDITOR, including removal or
	  rearrangement of lines. It also means that you can do stuff
	  like:
		# echo "WCE: 1" | camcontrol modepage da3 -m 8 -e
		# newfs /dev/da3
		# echo "WCE: 0" | camcontrol modepage da3 -m 8 -e
	* Range-checking on user-supplied input values. modeedit.c now
	  uses the field width specifiers to determine the maximum
	  allowable value for a field. If the user enters a value larger
	  than the maximum, it clips the value to the max and warns the
	  user. This also involved patching cam_cmdparse.c to be more
	  consistent with regards to the "count" parameter to arg_put
	  (previously is was the length of strings and 1 for all integral
	  types). The cam_cdbparse(3) man page was also updated to reflect
	  the revised semantics.
	* In the process, I removed the 64 entry limit on mode pages (not
	  that we were even close to hitting that limit). This was a nice
	  side-effect of the other changes.
	* Technically, the new mode editting functionality allows editting
	  of character array entries in mode pages (type 'c' or 'z'),
	  however since buff_encode doesn't grok them it is currently
	  useless.
	* Camcontrol gained two new options related to mode pages: -l and
	  -b. The former lists all available mode pages for a given
	  device. The latter forces mode page display in binary format
	  (the default when no mode page definition was found in
	  scsi_modes).
	* Added support for mode page names to scsi_modes. Allows names to
	  be displayed alongside mode numbers in the mode page
	  listing. Updated scsi_modes to use the new functionality. This
	  also adds the semicolon into the scsi_modes syntax as an
	  optional mode page definition terminator. This is needed to name
	  pages without providing a page format definition.
	* Updated scsi_all.h to include a structure describing mode page
	  headers.
	* Added $FreeBSD$ line to scsi_modes.

Inspired by:	dwhite
Reviewed by:	ken
2000-08-08 06:24:17 +00:00
Nick Hibma
f1f05bbb10 Print the correct speed when speed is less than 1MB/s.
Fixed in cam_xpt.c, r1.81

Submitted by:           Gerd Knops <gerti@bitart.com>
2000-07-01 21:28:49 +00:00
Kenneth D. Merry
9f4285439a When printing out the transfer rate display for 'camcontrol inquiry',
use the current setting for tagged queueing when deciding whether or not to
print "Tagged Queueing Enabled" instead of using the device's actual
capabilities.

This is more consistent with the rest of the transfer rate display, which
relies on current settings, and is more consistent with the way we display
things on boot.

Reported by:	Gustavo Vieira Goncalves Coelho Rios <kernel@tdnet.com.br>
Reviewed by:	mjacob
2000-06-28 02:48:31 +00:00
Kenneth D. Merry
b3550398d3 Eliminate the default device name (da) and unit number (0) in camcontrol.
This may break some scripts, but with the number of ways users can damage
a system with this tool, it's important to make sure they specify which
device they want to talk to.

Suggested by:	joerg
2000-06-04 02:43:55 +00:00
Kenneth D. Merry
33fab22e1c Use the Ic (Internal command) mdoc macro to denote camcontrol subcommands.
Submitted by:	sheldonh
2000-06-03 22:16:00 +00:00
Kenneth D. Merry
cee3fcd1a2 Send 'camcontrol help' usage output to stdout instead of stderr, so it
can be viewed more easily with a pager.

Regular (i.e. short) usage output is still sent to stderr.

PR:		bin/12358
Submitted by:	Christian Weisgerber <naddy@mips.rhein-neckar.de>
2000-06-03 22:07:56 +00:00
Kenneth D. Merry
96a93c63a8 Implement a new camcontrol function, 'camcontrol format'.
libcam/Makefile:	Add scsi_da.c to libcam for the new
			scsi_format_unit() function.

camcontrol.8:		Update the man page for the new format
			functionality, and take out the examples section
			describing how to do it with 'camcontrol cmd'.

camcontrol.c:		New format functionality.  Note that unlike the
			rest of the camcontrol subcommands, this one is
			interactive by default.  Because of the potential
			destructiveness of the format command, I thought
			it necessary to get confirmation from the user
			before spamming a disk.  You can disable the
			interactive behavior, and the status meter with
			command line arguments.

scsi_da.c:		Add the new scsi_format_unit() cdb building
			function and use #ifdef _KERNEL to make this file
			compile in both the kernel and userland.  The
			format unit function is currently only defined in
			the non-kernel case, because nothing in the kernel
			is using it.  If that changes, it should be
			un-ifdefed and compiled in both cases.

scsi_da.h:		New function declaration, CDB structure and format
			data structures.

Thanks to Nick Hibma for providing some valuable input on these changes.
2000-05-21 23:57:52 +00:00
Mike Pritchard
c793874313 Correct the usage of the ".Bd -literal -offset xxx" macro to use
a proper offset.  This silences warnings when the man page is
formated with groff.

PR:		bin/14534
2000-05-05 01:59:21 +00:00
Matthew Hunt
5beb2d87ea Typo ("frequencey"). 2000-03-15 20:48:01 +00:00
Sheldon Hearn
ef8f7ac935 Remove single-space hard sentence breaks. These degrade the quality
of the typeset output, tend to make diffs harder to read and provide
bad examples for new-comers to mdoc.
2000-03-01 11:27:47 +00:00
Kenneth D. Merry
955f7e7474 Fix 'camcontrol inquiry'. The inquiry data structure changes (increased to
256 bytes) caused it to break on many devices.

The SCSI spec says that for commands with 8-bit length fields, a value of 0
means 256 bytes.  As it turns out, many devices don't deal with that
properly.  Some interpret the 0 as 0, and return no data.  Others return
more than 256 bytes of data, and cause an overrun.

The fix is to tell the device we've only allocated SHORT_INQUIRY_LENGTH (36
bytes) of inquiry data, instead of sizeof(struct scsi_inquiry_data).

camcontrol.c:		Change inq_len in the call to scsi_inquiry() to
			SHORT_INQUIRY_LENGTH, and add a long comment
			explaining the reason for the change.

scsi_all.h:		Add a comment above the definitinon of
			SHORT_INQUIRY_LENGTH alerting people that it is
			both the initial probe inquiry length, and the
			minimum amount of data needed for scsi_print_inquiry()
			to function.

scsi_all.c:		Add a comment about SHORT_INQUIRY_LENGTH being the
			minimum amount of data needed for
			scsi_print_inquiry() to function.

Reviewed by:	gibbs
Approved by:	jkh
Reported by:	"John W. DeBoskey" <jwd@unx.sas.com>
2000-02-20 04:42:44 +00:00
Kenneth D. Merry
b932a03c79 Fix a couple of typos in the 'camcontrol negotiate' output.
Submitted by:	T-Om <tom@iki.fi>
Approved by:	jkh
2000-02-04 07:30:27 +00:00
Matt Jacob
68a9f39184 Do some intptr_t casting for alpha.
Reviewed by:	ken@freebsd.org
2000-01-21 23:19:30 +00:00
Matt Jacob
cfe090e1fa Specify the system directory for which we put in our include path
as a separate line so we can override it on the command line if
we need to.

Reviewed by:	ken@freebsd.org
2000-01-21 23:18:08 +00:00