Skip to content

Commit

Permalink
aic7xxx: make target mode enable a device hint
Browse files Browse the repository at this point in the history
Previously this was a compile-time option through AHC_TMODE_ENABLE and
AHD_TMODE_ENABLE, which took a bitmap of units to enable target mode on.
Replace this with a simple device hint in the form of:

hint.ahc.<unit>.tmode_enable=0/1
hint.ahd.<unit>.tmode_enable=0/1

There does not seem to be any space-saving in the driver with
AH{C,D}_TMODE_ENABLE=0 or unset. So this shouldn't impact driver size
negatively.

Signed-off-by: HP van Braam <hp@tmm.cx>
  • Loading branch information
hpvb committed Apr 27, 2024
1 parent 9718d4a commit fa4396e
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 58 deletions.
22 changes: 10 additions & 12 deletions share/man/man4/ahc.4
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ For one or more PCI cards:
.Pp
To allow PCI adapters to use memory mapped I/O if enabled:
.Cd options AHC_ALLOW_MEMIO
.Pp
To configure one or more controllers to assume the target role:
.Cd options AHC_TMODE_ENABLE <bitmask of units>
.Ed
.Pp
Alternatively, to load the driver as a
Expand Down Expand Up @@ -80,15 +77,6 @@ is attempted.
Most modern motherboards perform the initialization correctly and work fine
with this option enabled.
.Pp
Individual controllers may be configured to operate in the target role
through the
.Dq Dv AHC_TMODE_ENABLE
configuration option.
The value assigned to this option should be a bitmap
of all units where target mode is desired.
For example, a value of 0x25, would enable target mode on units 0, 2, and 5.
A value of 0x8a enables it for units 1, 3, and 7.
.Pp
Per target configuration performed in the
.Tn SCSI-Select
menu, accessible at boot
Expand Down Expand Up @@ -156,6 +144,16 @@ Multiple Target IDs - Allows the controller to respond to selection as a
target on multiple SCSI IDs.
.El
.Ed
.Sh BOOT OPTIONS
The following options are switchable by setting values in
.Pa /boot/device.hints .
.Pp
They are:
.Bl -tag -width indent
.It Va hint.ahc. Ns Ar N Ns Va .tmode_enable
A hint to define whether the SCSI target mode is enabled (0 -- disabled, 1 -- enabled).
.El
.Ed
.Sh HARDWARE
The
.Nm
Expand Down
22 changes: 10 additions & 12 deletions share/man/man4/ahd.4
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ To compile in debugging code:
.Cd options AHD_DEBUG
.Cd options AHD_DEBUG_OPTS=<bitmask of options>
.Cd options AHD_REG_PRETTY_PRINT
.Pp
To configure one or more controllers to assume the target role:
.Cd options AHD_TMODE_ENABLE=<bitmask of units>
.Ed
.Pp
Alternatively, to load the driver as a
Expand Down Expand Up @@ -99,15 +96,6 @@ that is printed by the debugging code.
However, it also bloats the compiled
size of the driver by approximately 215KB.
.Pp
Individual controllers may be configured to operate in the target role
through the
.Dv AHD_TMODE_ENABLE
configuration option.
The value assigned to this option should be a bitmap
of all units where target mode is desired.
For example, a value of 0x25 would enable target mode on units 0, 2, and 5.
Note that target mode is only supported for ultra160 speeds and below.
.Pp
Per target configuration performed in the
.Tn SCSI-Select
menu, accessible at boot,
Expand All @@ -119,6 +107,16 @@ disconnection,
and the host adapter's
.Tn SCSI
ID.
.Sh BOOT OPTIONS
The following options are switchable by setting values in
.Pa /boot/device.hints .
.Pp
They are:
.Bl -tag -width indent
.It Va hint.ahd. Ns Ar N Ns Va .tmode_enable
A hint to define whether the SCSI target mode is enabled (0 -- disabled, 1 -- enabled).
.El
.Ed
.Sh HARDWARE
The
.Nm
Expand Down
6 changes: 0 additions & 6 deletions sys/conf/NOTES
Original file line number Diff line number Diff line change
Expand Up @@ -1606,9 +1606,6 @@ options AHC_ALLOW_MEMIO
# Dump the contents of the ahc controller configuration PROM.
options AHC_DUMP_EEPROM

# Bitmap of units to enable targetmode operations.
options AHC_TMODE_ENABLE

# Compile in Aic7xxx Debugging code.
options AHC_DEBUG

Expand All @@ -1628,9 +1625,6 @@ options AHD_DEBUG_OPTS=0xFFFFFFFF
# Print human-readable register definitions when debugging
options AHD_REG_PRETTY_PRINT

# Bitmap of units to enable targetmode operations.
options AHD_TMODE_ENABLE

# Options used in dev/isp/ (Qlogic SCSI/FC driver).
#
# ISP_TARGET_MODE - enable target mode operation
Expand Down
2 changes: 0 additions & 2 deletions sys/conf/options
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,12 @@
AAC_DEBUG opt_aac.h
AACRAID_DEBUG opt_aacraid.h
AHC_ALLOW_MEMIO opt_aic7xxx.h
AHC_TMODE_ENABLE opt_aic7xxx.h
AHC_DUMP_EEPROM opt_aic7xxx.h
AHC_DEBUG opt_aic7xxx.h
AHC_DEBUG_OPTS opt_aic7xxx.h
AHC_REG_PRETTY_PRINT opt_aic7xxx.h
AHD_DEBUG opt_aic79xx.h
AHD_DEBUG_OPTS opt_aic79xx.h
AHD_TMODE_ENABLE opt_aic79xx.h
AHD_REG_PRETTY_PRINT opt_aic79xx.h

# Debugging options.
Expand Down
29 changes: 28 additions & 1 deletion sys/dev/aic7xxx/aic79xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -6229,6 +6229,9 @@ ahd_init(struct ahd_softc *ahd)
size_t driver_data_size;
int i;
int error;
#ifdef AHD_TARGET_MODE
int tmode_enable;
#endif
u_int warn_user;
uint8_t current_sensing;
uint8_t fstat;
Expand Down Expand Up @@ -6261,8 +6264,32 @@ ahd_init(struct ahd_softc *ahd)
/*
* Only allow target mode features if this unit has them enabled.
*/
if ((AHD_TMODE_ENABLE & (0x1 << ahd->unit)) == 0)
#ifdef AHD_TARGET_MODE
if (resource_int_value(device_get_name(ahd->dev_softc),
device_get_unit(ahd->dev_softc),
"tmode_enable", &tmode_enable) != 0) {
if (bootverbose)
printf("%s: No ahd.%i.tmode_enable hint found\n",
ahd_name(ahd), ahd->unit);
tmode_enable = 0;
} else {
if (bootverbose)
printf("%s: Using hint tmode_enable=%i\n",
ahd_name(ahd), tmode_enable);
}

if (tmode_enable == 0) {
if (bootverbose)
printf("%s: not enabling target mode\n", ahd_name(ahd));
ahd->features &= ~AHD_TARGETMODE;
} else {
if (bootverbose)
printf("%s: enabling target mode\n", ahd_name(ahd));
}

#else
ahd->features &= ~AHD_TARGETMODE;
#endif

/* DMA tag for mapping buffers into device visible space. */
if (aic_dma_tag_create(ahd, ahd->parent_dmat, /*alignment*/1,
Expand Down
8 changes: 0 additions & 8 deletions sys/dev/aic7xxx/aic79xx.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,6 @@ struct scb_platform_data;
#define SCB_GET_TAG(scb) \
aic_le16toh(scb->hscb->tag)

#ifndef AHD_TARGET_MODE
#undef AHD_TMODE_ENABLE
#define AHD_TMODE_ENABLE 0
#endif

#define AHD_BUILD_COL_IDX(target, lun) \
(((lun) << 4) | target)

Expand Down Expand Up @@ -1544,9 +1539,6 @@ cam_status ahd_find_tmode_devs(struct ahd_softc *ahd,
struct ahd_tmode_tstate **tstate,
struct ahd_tmode_lstate **lstate,
int notfound_failure);
#ifndef AHD_TMODE_ENABLE
#define AHD_TMODE_ENABLE 0
#endif
#endif
/******************************* Debug ***************************************/
#ifdef AHD_DEBUG
Expand Down
4 changes: 0 additions & 4 deletions sys/dev/aic7xxx/aic79xx_osm.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@
#include <ddb/ddb.h>
#endif

#ifndef AHD_TMODE_ENABLE
#define AHD_TMODE_ENABLE 0
#endif

#include <dev/aic7xxx/aic_osm_lib.c>

#define ccb_scb_ptr spriv_ptr0
Expand Down
28 changes: 27 additions & 1 deletion sys/dev/aic7xxx/aic7xxx.c
Original file line number Diff line number Diff line change
Expand Up @@ -4774,6 +4774,7 @@ ahc_init(struct ahc_softc *ahc)
{
int max_targ;
int error;
int tmode_enable;
u_int i;
u_int scsi_conf;
u_int ultraenb;
Expand Down Expand Up @@ -4826,8 +4827,33 @@ ahc_init(struct ahc_softc *ahc)
/*
* Only allow target mode features if this unit has them enabled.
*/
if ((AHC_TMODE_ENABLE & (0x1 << ahc->unit)) == 0)
#ifdef AHC_TARGET_MODE

if (resource_int_value(device_get_name(ahc->dev_softc),
device_get_unit(ahc->dev_softc),
"tmode_enable", &tmode_enable) != 0) {
if (bootverbose)
printf("%s: No ahc.%i.tmode_enable hint found\n",
ahc_name(ahc), ahc->unit);
tmode_enable = 0;
} else {
if (bootverbose)
printf("%s: Using hint tmode_enable=%i\n",
ahc_name(ahc), tmode_enable);
}

if (tmode_enable == 0) {
if (bootverbose)
printf("%s: not enabling target mode\n", ahc_name(ahc));
ahc->features &= ~AHC_TARGETMODE;
} else {
if (bootverbose)
printf("%s: enabling target mode\n", ahc_name(ahc));
}

#else
ahc->features &= ~AHC_TARGETMODE;
#endif

/* DMA tag for mapping buffers into device visible space. */
if (aic_dma_tag_create(ahc, ahc->parent_dmat, /*alignment*/1,
Expand Down
8 changes: 0 additions & 8 deletions sys/dev/aic7xxx/aic7xxx.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,6 @@ struct seeprom_descriptor;
#define BUILD_TCL(scsiid, lun) \
((lun) | (((scsiid) & TID) << 4))

#ifndef AHC_TARGET_MODE
#undef AHC_TMODE_ENABLE
#define AHC_TMODE_ENABLE 0
#endif

/**************************** Driver Constants ********************************/
/*
* The maximum number of supported targets.
Expand Down Expand Up @@ -1335,9 +1330,6 @@ cam_status ahc_find_tmode_devs(struct ahc_softc *ahc,
struct ahc_tmode_tstate **tstate,
struct ahc_tmode_lstate **lstate,
int notfound_failure);
#ifndef AHC_TMODE_ENABLE
#define AHC_TMODE_ENABLE 0
#endif
#endif
/******************************* Debug ***************************************/
#ifdef AHC_DEBUG
Expand Down
4 changes: 0 additions & 4 deletions sys/dev/aic7xxx/aic7xxx_osm.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@

#include <sys/kthread.h>

#ifndef AHC_TMODE_ENABLE
#define AHC_TMODE_ENABLE 0
#endif

#include <dev/aic7xxx/aic_osm_lib.c>

#define ccb_scb_ptr spriv_ptr0
Expand Down

0 comments on commit fa4396e

Please sign in to comment.