PASS(4)

πŸ’– PASS(4) β€” CAM application passthrough driver πŸ’–

okay bestie, gather round, because this is pass(4), a Kernel Interfaces Manual page, and it's genuinely one of those "with great power comes great responsibility" situations. sit down, hydrate, let's go 🫢


✨ NAME ✨

pass β€” the CAM application passthrough driver


🌸 SYNOPSIS 🌸

device pass

yes, that's it. one line. iconic behaviour, honestly πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so the pass driver is literally the way for userland applications to hand CAM CCBs straight to the kernel. it's the plug, it's the portal, it's giving backstage pass energy πŸŽ€

⚠️ bestie. listen. since pass allows direct access to the CAM subsystem, system administrators should exercise caution when granting access to this driver. if it's used improperly, this driver can let userland applications crash a machine or cause data loss. no cap. that's a real sentence in the real manpage and we are not sugarcoating it πŸ’€

the pass driver attaches to every SCSI and ATA device found in the system. and because it attaches to every single one of them, it gives you a generic means of accessing SCSI and ATA devices β€” which means it also lets you access devices that have no "standard" peripheral driver associated with them. it's the friend who gets into every party πŸ‘‘


πŸŽ€ KERNEL CONFIGURATION πŸŽ€

it is only necessary to configure one pass device in the kernel. that's it. one.

pass devices are automatically allocated as SCSI and ATA devices are found. so you don't have to do the work, the kernel does it for you. slay ✨


πŸ’… IOCTLS πŸ’…

here's where it gets juicy. four ioctls, four moods.

  • CAMIOCOMMAND *union ccb ** β€” this ioctl takes most kinds of CAM CCBs and passes them through to the CAM transport layer for action. heads up though: some CCB types are not allowed through the passthrough device, and must be sent through the xpt(4) device instead. some examples of xpt-only CCBs are XPT_SCAN_BUS, XPT_DEV_MATCH, XPT_RESET_BUS, XPT_SCAN_LUN, XPT_ENG_INQ, and XPT_ENG_EXEC. these CCB types have various attributes that make it illogical or impossible to service them through the passthrough interface. πŸ™…β™€οΈ

if the user would like the kernel to do error recovery, the CAM_PASS_ERR_RECOVER flag must be set on the CCB, and the retry_count field set to the number of retries.

  • CAMGETPASSTHRU *union ccb ** β€” this ioctl takes an XPT_GDEVLIST CCB, and returns the passthrough device corresponding to the device in question. although this ioctl is available through the pass driver, it is of limited use, since the caller must already know that the device in question is a passthrough device if they are issuing this ioctl. it is probably more useful to issue this ioctl through the xpt(4) device instead. like, it's giving "you already had to know the answer to ask the question" 🫠
  • CAMIOQUEUE *union ccb ** β€” queue a CCB to the pass driver to be executed asynchronously. the caller may use select(2), poll(2) or kevent(2) to receive notification when the CCB has completed. very much the "drop it and we'll text you" vibe πŸ’Œ

this ioctl takes most CAM CCBs, but some CCB types are not allowed through the pass device, and must be sent through the xpt(4) device instead. some examples of xpt-only CCBs are XPT_SCAN_BUS, XPT_DEV_MATCH, XPT_RESET_BUS, XPT_SCAN_LUN, XPT_ENG_INQ, and XPT_ENG_EXEC. these CCB types have various attributes that make it illogical or impossible to service them through the passthrough interface.

although the CAMIOQUEUE ioctl is not defined to take an argument, it does require a pointer to a union ccb. it is not defined to take an argument to avoid an extra malloc and copy inside the generic ioctl(2) handler. efficiency queen πŸ’…

the completed CCB will be returned via the CAMIOGET ioctl. an error will only be returned from the CAMIOQUEUE ioctl if there is an error allocating memory for the request or copying memory from userland. all other errors will be reported as standard CAM CCB status errors. and because the CCB is not copied back to the user process from the pass driver in the CAMIOQUEUE ioctl, the user's passed-in CCB will not be modified β€” this is the case even with immediate CCBs. instead, the completed CCB must be retrieved via the CAMIOGET ioctl and the status examined. so don't go reading your own CCB expecting an update, bestie, that's not the move πŸ™ˆ

multiple CCBs may be queued via the CAMIOQUEUE ioctl at any given time, and they may complete in a different order than the order that they were submitted. the caller must take steps to identify CCBs that are queued and completed. the periph_priv structure inside struct ccb_hdr is available for userland use with the CAMIOQUEUE and CAMIOGET ioctls, and will be preserved across calls. also, the periph_links linked list pointers inside struct ccb_hdr are available for userland use with the CAMIOQUEUE and CAMIOGET ioctls and will be preserved across calls. keep track of your own children, essentially 🌈

if the user would like the kernel to do error recovery, the CAM_PASS_ERR_RECOVER flag must be set on the CCB, and the retry_count field set to the number of retries.

  • CAMIOGET *union ccb ** β€” retrieve completed CAM CCBs queued via the CAMIOQUEUE ioctl. an error will only be returned from the CAMIOGET ioctl if the pass driver fails to copy data to the user process or if there are no completed CCBs available to retrieve. if no CCBs are available to retrieve, errno will be set to ENOENT.

all other errors will be reported as standard CAM CCB status errors.

although the CAMIOGET ioctl is not defined to take an argument, it does require a pointer to a union ccb. it is not defined to take an argument to avoid an extra malloc and copy inside the generic ioctl(2) handler.

the pass driver will report via select(2), poll(2) or kevent(2) when a CCB has completed. one CCB may be retrieved per CAMIOGET call. CCBs may be returned in an order different than the order they were submitted. so the caller should use the periph_priv area inside the CCB header to store pointers to identifying information. yes this is the same advice as before, no it did not stop being true ⭐


πŸ“ FILES πŸ“

  • /dev/passn β€” character device nodes for the pass driver. there should be one of these for each device accessed through the CAM subsystem.

🧚 DIAGNOSTICS 🧚

None. (nothing. silence. a rare peaceful moment 😌)


πŸ‘‘ SEE ALSO πŸ‘‘

kqueue(2), poll(2), select(2), cam(3), cam_cdbparse(3), cam(4), cd(4), ctl(4), da(4), sa(4), xpt(4), camcontrol(8), camdd(8)

go read xpt(4) too, bestie, it keeps coming up for a reason πŸ’œ


🌟 HISTORY 🌟

the CAM passthrough driver first appeared in FreeBSD 3.0. vintage. retro. ate. πŸ”₯


πŸ’– AUTHORS πŸ’–

Kenneth Merry <ken@FreeBSD.org> β€” thank you for your service, king 🫑


and that's the whole page!! this one came from the Debian build of the manual, dated May 3, 2017, and it's PASS(4) from the Kernel Interfaces Manual. mwah, go forth and pass CCBs responsibly, ily, don't crash the machine πŸ’‹βœ¨

πŸ“¦ where this page comes from