A minimal update to the device wiring code so that it looks at the
dynamic resource tables rather than relying on a duplicated cam-specific table generated by config(8) in ioconf.c. This was a major holdup to getting loader / userconfig driven configuration of scsi wiring.
This commit is contained in:
parent
a9d84bd07c
commit
75f51904b5
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=56470
@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Data structures and definitions for linking CAM into the autoconf system.
|
||||
*
|
||||
* Copyright (c) 1997 Justin T. Gibbs.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions, and the following disclaimer,
|
||||
* without modification, immediately at the beginning of the file.
|
||||
* 2. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _CAM_CAM_CONF_H
|
||||
#define _CAM_CAM_CONF_H 1
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
#define CAMCONF_UNSPEC 255
|
||||
#define CAMCONF_ANY 254
|
||||
|
||||
/*
|
||||
* Macro that lets us know something is specified.
|
||||
*/
|
||||
#define IS_SPECIFIED(ARG) (ARG != CAMCONF_UNSPEC && ARG != CAMCONF_ANY)
|
||||
|
||||
struct cam_sim_config
|
||||
{
|
||||
int pathid;
|
||||
char *sim_name;
|
||||
int sim_unit;
|
||||
int sim_bus;
|
||||
};
|
||||
|
||||
struct cam_periph_config
|
||||
{
|
||||
char *periph_name;
|
||||
int periph_unit; /* desired device unit */
|
||||
int pathid; /* Controller unit */
|
||||
int target;
|
||||
int lun;
|
||||
int flags; /* Flags from config */
|
||||
};
|
||||
|
||||
extern struct cam_sim_config cam_sinit[];
|
||||
extern struct cam_periph_config cam_pinit[];
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _CAM_CAM_CONF_H */
|
@ -37,11 +37,11 @@
|
||||
#include <sys/buf.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/devicestat.h>
|
||||
#include <sys/bus.h>
|
||||
#include <vm/vm.h>
|
||||
#include <vm/vm_extern.h>
|
||||
|
||||
#include <cam/cam.h>
|
||||
#include <cam/cam_conf.h>
|
||||
#include <cam/cam_ccb.h>
|
||||
#include <cam/cam_xpt_periph.h>
|
||||
#include <cam/cam_periph.h>
|
||||
@ -264,9 +264,10 @@ static u_int
|
||||
camperiphnextunit(struct periph_driver *p_drv, u_int newunit, int wired)
|
||||
{
|
||||
struct cam_periph *periph;
|
||||
struct cam_periph_config *periph_conf;
|
||||
char *periph_name;
|
||||
char *periph_name, *strval;
|
||||
int s;
|
||||
int i, val, dunit;
|
||||
const char *dname;
|
||||
|
||||
s = splsoftcam();
|
||||
periph_name = p_drv->driver_name;
|
||||
@ -287,25 +288,27 @@ camperiphnextunit(struct periph_driver *p_drv, u_int newunit, int wired)
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (wired)
|
||||
break;
|
||||
|
||||
for (periph_conf = cam_pinit;
|
||||
wired == 0 && periph_conf->periph_name != NULL;
|
||||
periph_conf++) {
|
||||
|
||||
/*
|
||||
* Don't match entries like "da 4" as a wired down
|
||||
* device, but do match entries like "da 4 target 5"
|
||||
* or even "da 4 scbus 1".
|
||||
*/
|
||||
if (IS_SPECIFIED(periph_conf->periph_unit)
|
||||
&& (!strcmp(periph_name, periph_conf->periph_name))
|
||||
&& (IS_SPECIFIED(periph_conf->target)
|
||||
|| IS_SPECIFIED(periph_conf->pathid))
|
||||
&& (newunit == periph_conf->periph_unit))
|
||||
/*
|
||||
* Don't match entries like "da 4" as a wired down
|
||||
* device, but do match entries like "da 4 target 5"
|
||||
* or even "da 4 scbus 1".
|
||||
*/
|
||||
i = -1;
|
||||
while ((i = resource_locate(i, periph_name)) != -1) {
|
||||
dname = resource_query_name(i);
|
||||
dunit = resource_query_unit(i);
|
||||
/* if no "target" and no specific scbus, skip */
|
||||
if (resource_int_value(dname, dunit, "target", &val) &&
|
||||
(resource_string_value(dname, dunit, "at",&strval)||
|
||||
strcmp(strval, "scbus") == 0))
|
||||
continue;
|
||||
if (newunit == dunit)
|
||||
break;
|
||||
}
|
||||
|
||||
if (wired != 0 || periph_conf->periph_name == NULL)
|
||||
if (i == -1)
|
||||
break;
|
||||
}
|
||||
splx(s);
|
||||
@ -316,51 +319,44 @@ static u_int
|
||||
camperiphunit(struct periph_driver *p_drv, path_id_t pathid,
|
||||
target_id_t target, lun_id_t lun)
|
||||
{
|
||||
struct cam_periph_config *periph_conf;
|
||||
u_int unit;
|
||||
int hit;
|
||||
u_int unit;
|
||||
int hit, i, val, dunit;
|
||||
const char *dname;
|
||||
char pathbuf[32], *strval, *periph_name;
|
||||
|
||||
unit = 0;
|
||||
hit = 0;
|
||||
|
||||
for (periph_conf = cam_pinit;
|
||||
periph_conf->periph_name != NULL;
|
||||
periph_conf++, hit = 0) {
|
||||
|
||||
if (!strcmp(p_drv->driver_name, periph_conf->periph_name)
|
||||
&& IS_SPECIFIED(periph_conf->periph_unit)) {
|
||||
|
||||
if (IS_SPECIFIED(periph_conf->pathid)) {
|
||||
|
||||
if (pathid != periph_conf->pathid)
|
||||
continue;
|
||||
hit++;
|
||||
}
|
||||
|
||||
if (IS_SPECIFIED(periph_conf->target)) {
|
||||
|
||||
if (target != periph_conf->target)
|
||||
continue;
|
||||
hit++;
|
||||
}
|
||||
|
||||
if (IS_SPECIFIED(periph_conf->lun)) {
|
||||
|
||||
if (lun != periph_conf->lun)
|
||||
continue;
|
||||
hit++;
|
||||
}
|
||||
|
||||
if (hit != 0) {
|
||||
unit = periph_conf->periph_unit;
|
||||
break;
|
||||
}
|
||||
periph_name = p_drv->driver_name;
|
||||
snprintf(pathbuf, sizeof(pathbuf), "scbus%d", pathid);
|
||||
i = -1;
|
||||
while ((i = resource_locate(i, periph_name)) != -1) {
|
||||
dname = resource_query_name(i);
|
||||
dunit = resource_query_unit(i);
|
||||
if (resource_string_value(dname, dunit, "at", &strval) == 0) {
|
||||
if (strcmp(strval, pathbuf) != 0)
|
||||
continue;
|
||||
hit++;
|
||||
}
|
||||
if (resource_int_value(dname, dunit, "target", &val) == 0) {
|
||||
if (val != target)
|
||||
continue;
|
||||
hit++;
|
||||
}
|
||||
if (resource_int_value(dname, dunit, "lun", &val) == 0) {
|
||||
if (val != lun)
|
||||
continue;
|
||||
hit++;
|
||||
}
|
||||
if (hit != 0) {
|
||||
unit = dunit;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Either start from 0 looking for the next unit or from
|
||||
* the unit number given in the periph_conf. This way,
|
||||
* the unit number given in the resource config. This way,
|
||||
* if we have wildcard matches, we don't return the same
|
||||
* unit number twice.
|
||||
*/
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include <sys/md5.h>
|
||||
#include <sys/devicestat.h>
|
||||
#include <sys/interrupt.h>
|
||||
#include <sys/bus.h>
|
||||
|
||||
#ifdef PC98
|
||||
#include <pc98/pc98/pc98_machdep.h> /* geometry translation */
|
||||
@ -48,7 +49,6 @@
|
||||
#include <machine/ipl.h>
|
||||
|
||||
#include <cam/cam.h>
|
||||
#include <cam/cam_conf.h>
|
||||
#include <cam/cam_ccb.h>
|
||||
#include <cam/cam_periph.h>
|
||||
#include <cam/cam_sim.h>
|
||||
@ -4088,7 +4088,7 @@ xptnextfreepathid(void)
|
||||
{
|
||||
struct cam_eb *bus;
|
||||
path_id_t pathid;
|
||||
struct cam_sim_config *sim_conf;
|
||||
char *strval;
|
||||
|
||||
pathid = 0;
|
||||
bus = TAILQ_FIRST(&xpt_busses);
|
||||
@ -4105,17 +4105,10 @@ xptnextfreepathid(void)
|
||||
* Ensure that this pathid is not reserved for
|
||||
* a bus that may be registered in the future.
|
||||
*/
|
||||
sim_conf = cam_sinit;
|
||||
while (sim_conf->sim_name != NULL) {
|
||||
|
||||
if (IS_SPECIFIED(sim_conf->pathid)
|
||||
&& (pathid == sim_conf->pathid)) {
|
||||
++pathid;
|
||||
/* Start the search over */
|
||||
goto retry;
|
||||
} else {
|
||||
sim_conf++;
|
||||
}
|
||||
if (resource_string_value("scbus", pathid, "at", &strval) == 0) {
|
||||
++pathid;
|
||||
/* Start the search over */
|
||||
goto retry;
|
||||
}
|
||||
return (pathid);
|
||||
}
|
||||
@ -4123,37 +4116,38 @@ xptnextfreepathid(void)
|
||||
static path_id_t
|
||||
xptpathid(const char *sim_name, int sim_unit, int sim_bus)
|
||||
{
|
||||
struct cam_sim_config *sim_conf;
|
||||
path_id_t pathid;
|
||||
int i, dunit, val;
|
||||
char buf[32], *strval;
|
||||
|
||||
pathid = CAM_XPT_PATH_ID;
|
||||
for (sim_conf = cam_sinit; sim_conf->sim_name != NULL; sim_conf++) {
|
||||
|
||||
if (!IS_SPECIFIED(sim_conf->pathid))
|
||||
snprintf(buf, sizeof(buf), "%s%d", sim_name, sim_unit);
|
||||
i = -1;
|
||||
while ((i = resource_locate(i, "scbus")) != -1) {
|
||||
dunit = resource_query_unit(i);
|
||||
if (dunit < 0) /* unwired?! */
|
||||
continue;
|
||||
|
||||
if (!strcmp(sim_name, sim_conf->sim_name)
|
||||
&& (sim_unit == sim_conf->sim_unit)) {
|
||||
|
||||
if (IS_SPECIFIED(sim_conf->sim_bus)) {
|
||||
if (sim_bus == sim_conf->sim_bus) {
|
||||
pathid = sim_conf->pathid;
|
||||
break;
|
||||
}
|
||||
} else if (sim_bus == 0) {
|
||||
/* Unspecified matches bus 0 */
|
||||
pathid = sim_conf->pathid;
|
||||
if (resource_string_value("scbus", dunit, "at", &strval) != 0)
|
||||
continue;
|
||||
if (strcmp(buf, strval) != 0)
|
||||
continue;
|
||||
if (resource_int_value("scbus", dunit, "bus", &val) == 0) {
|
||||
if (sim_bus == val) {
|
||||
pathid = dunit;
|
||||
break;
|
||||
} else {
|
||||
printf("Ambiguous scbus configuration for %s%d "
|
||||
"bus %d, cannot wire down. The kernel "
|
||||
"config entry for scbus%d should "
|
||||
"specify a controller bus.\n"
|
||||
"Scbus will be assigned dynamically.\n",
|
||||
sim_name, sim_unit, sim_bus,
|
||||
sim_conf->pathid);
|
||||
break;
|
||||
}
|
||||
} else if (sim_bus == 0) {
|
||||
/* Unspecified matches bus 0 */
|
||||
pathid = dunit;
|
||||
break;
|
||||
} else {
|
||||
printf("Ambiguous scbus configuration for %s%d "
|
||||
"bus %d, cannot wire down. The kernel "
|
||||
"config entry for scbus%d should "
|
||||
"specify a controller bus.\n"
|
||||
"Scbus will be assigned dynamically.\n",
|
||||
sim_name, sim_unit, sim_bus, dunit);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user