cam probe sequence

Jack jacks.1785 at gmail.com
Wed Nov 7 14:05:32 UTC 2012


Hi,

On Sun, Nov 4, 2012 at 2:40 PM, Jack <jacks.1785 at gmail.com> wrote:
> Hello all,
>
> I'm trying to understand the probe sequence of a scsi device, say
> a scsi hard drive( with SPI/SAS/FC interface).
>
> I'm particularly interested in probe sequence of a device which is
> attached to the system _after_ FreeBSD has booted completely.
> (ie post-boot probing.)
>
> While going through the source of cam subsystem,  a few
> questions arose in my understanding.
>
> ( The relevant files I found are cam/cam_xpt.c, cam/cam_periph.c
>   and cam/scsi/scsi_xpt.c or cam/ata/ata_xpt.c in case of (S)ATA
>  drives. )
>
> As far as I could got till now, it seems that struct cam_et and
> struct cam_ed are _always_ created even _before_ the probing of
> device commences.
>
> But how does cam sub-system get to know that a device got
> attached to the system, so that it creates struct cam_et and
> struct cam_ed in advance, and _then_ probes the device.
>
> Is it something like a event notfication at hardware level that
> the HBA driver passes to cam sub-system which notifies cam
> sub-system that a device has recently been attached.
>
> If it is true, then does all SPI/SAS/FC/(S)ATA  HBAs support
> such event notification -- something like a standard thing
> in SPI/SAS/FC/(S)ATA world.
>
> If it is not so, then does userland have to intiate a scan after
> device is attached, so that during scanning the cam-subsystem
>  get to know that Oh! there is a device we are meeting first time.
> In other words, _until_ userland instructs cam subsystem to scan
> all the buses by XPT_SCAN_BUS ccb through CAMIOCOMMAND
> ioctl of /dev/xpt0, the struct cam_et and struct cam_ed will not
> get created. Is it so?
> But in this case also,  does cam-subsystem creates
> struct cam_et and struct cam_ed before probing the device?.
>
> In case of SPI/SAS/FC hard drives the probe code is in
> cam/scsi/scsi_xpt.c  While reading this source file it
> also seems to me that a struct cam_periph is also created
> as soon as struct cam_et and struct cam_ed are created.
> This also happens before probing of device commences.
> Is it the pass device that is created even before probing begins.
> Then after probing and determining the type of device - e.g. disk,
> cd-rom, etc, then the appropriate peripheral device(da, cd, etc. ) is
>  created for the probed device. Is it so?
>
>
> It would be really helpful if someone could clear these things,
> specially from the instant the device -say a hard disk; is attached,
> to the instant the pass device and da device are created and
> probing of this hard disk commences or finishes.
>
>
>
> Regards
> --
> Jack

Going through sources of cam,  I still can't figure out the
the invocation of probeschedule() and proberegister().
Actually I am trying to figure out the relation of probe device
with xpt layer.

a)  What exactly is the purpose of "probe" device. It is not shown
     in /dev , so I guess it is for internal use only.
     Is there only one instance of "probe" device for each instance
     of xpt ? or,
     for each instance of struct cam_ed, a probe  device is
     created, or
     I am missing something.


b) Can anyone point me as where and  how is probeschedule() or
    proberegister()  got invoked from xptioctl(). ?
    (For the case of CAMIOCOMMAND and XPT_SCAN_LUN ccb.)
    I only know that this causes scsi_scan_lun() to be invoked, but
    then how is probeschedule() or proberegister() got invoked from it.

c )It seems to me that there is no way for cam to automatically
    detect the presence/attachement of a device on some bus.
    Ofcourse, usb mass and firewire are exceptions,
     where the device removal event is triggered at hardware level.
    In case of SPI/SAS/FC/(S)ATA, this is not the case.

    So, the only way to determine the presence of recently attached
    device is to instruct cam to rescan the bus/lun.
    And this instruction is CAMIOCOMMAND ioctl with XPT_SCAN_xxx
    ccbs. of pass driver.

    But then why is xpt_rescan() ?
     I'm not sure what exactly is the purpose of xpt_rescan() .
     I guess it is intended to be used from within the kernel,
     as from within the kernel, xptioctl() can't be invoked.


Any clarifications or pointers would be really appreciated.


Thanks

-- 
Jack


More information about the freebsd-scsi mailing list