Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Aug 1995 09:34:39 -0400 (EDT)
From:      Peter Dufault <dufault@hda.com>
To:        joerg_wunsch@uriah.heep.sax.de
Cc:        scsi@freebsd.org
Subject:   Re: scsiconf change
Message-ID:  <199508211334.JAA07241@hda.com>
In-Reply-To: <199508200511.HAA10037@uriah.heep.sax.de> from "J Wunsch" at Aug 20, 95 07:11:48 am

next in thread | previous in thread | raw e-mail | index | archive | help
[I'm widening the audience a bit so we can get some more feedback, Joerg]

Joerg asked about how to match a driver when the device lies about
what type it is - that is, it says it is type 0 when it is really type X.
I wrote:

> > I thought you could do this now by matching directly on the inquiry
> > data.  I know that Julian has a device that reports the wrong device
> > type, so I thought we had some way of handling this.
> 

[Joerg]
> Perhaps i've overlooked this?

No, you haven't overlooked it.  Apparently it either never worked the
way I thought it did or it was broken at some time.  Note that we have
a type to use in the "scsidevs" structure (the matching structure),
and we carefully take the type out of that structure after a match:

>        *type_p = bestmatch->type;

But this is a NOP since the match fails when the type is different.

I think that the current matching tests are wrong; it is too inflexible.

I would keep NEW_SCSICONF (since that is all I've been running lately
and one of the two branches is getting musty)
and change scsi_selectdev to a scoring scheme:

    high_score = 0;
    bestmatch = 0;

    /* XXX: See commentary below about hunting through "knowndevs".
     */
    for ( thisentry = knowndevs; thisentry->manufacturer; thisentry++ ) {
	int score = 0;

        /* Choose the best match by a scoring system.  One point
         * for manufacturer and model, one point for revision,
         * one point for type, and one point for removable.
         */

        if (match(thisentry->manufacturer, manu) &&
        match(thisentry->model, model)) {
              score++;

            if (match(thisentry->version, rev))
                score++;
            if (type == thisentry->type)
                score++;
            if (remov == thisentry->removable)
                score++;

            if (score > high_score) {
                 high_score = score;
                 bestmatch = thisentry;
            }
        }
    }
...

Then after you match you copy the new info into the inquiry data,
effectively lieing about what you saw, something like:

(after return from match...)

    if (*type_p != bestmatch->type && bestmatch->type != -1) {
        sc_print_start(sc_link);
        printf("attaching as type %d", bestmatch->type);
        sc_print_finish();
        *type_p = bestmatch->type;
    }

I'd do the same thing for anything else we match on, so far, for
"removable" and "version".

If I actually did this, I'd generalize it so that you zapped the
stored away inquiry data with the synthetic information in the
"bestmatch" structure.

Commentary about hunting through "knowndevs":

The changes I outline here should give you what you want, and I
think would be an improvement.  However, instead of a single
structure we really should have a distributed structure where in
addition to a possible list of "knowndevs" in scsiconf.c we have
additional devices in each type driver (st.c, sd.c, etc) and a way
to add new ones via config and "boot -c".  Then your current problem
would be near zero:  you'd just config in a new "rogue".

Unfortunately I'm no longer running -current: I don't have a system
unimportant enough at the moment to do so!  If you'd like I'll make these
changes, get them to compile and then let you do some testing.  These
are pretty low risk changes.

Peter



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199508211334.JAA07241>