Page MenuHomeFreeBSD

ctl: Add CTL_IO_ASSERT wrapper macro
ClosedPublic

Authored by jhb on Apr 18 2024, 5:45 PM.
Tags
None
Referenced Files
F86572842: D44844.diff
Sat, Jun 22, 10:12 AM
Unknown Object (File)
Fri, Jun 14, 4:01 AM
Unknown Object (File)
Thu, Jun 13, 6:28 PM
Unknown Object (File)
Mon, May 27, 2:12 AM
Unknown Object (File)
Sun, May 26, 10:49 AM
Unknown Object (File)
Thu, May 23, 3:01 PM
Unknown Object (File)
May 21 2024, 5:20 AM
Unknown Object (File)
May 7 2024, 7:46 PM
Subscribers
None

Details

Summary

Currently, this pattern is commonly used to assert that a union ctl_io
is a SCSI request. In the future it will be used to assert other
types.

Suggested by: imp
Sponsored by: Chelsio Communications

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

jhb requested review of this revision.Apr 18 2024, 5:45 PM
sys/cam/ctl/ctl_io.h
595

I also added a CTL_IO_ASSERT_NVME(io) that I use later in this series.

However, I still end up with a few places that want to assert the io_type is 2 different types (e.g. NVME or NVME_ADMIN, or NVME or SCSI). I wonder if it makes sense to get a bit fancy and instead add a couple of helper macros that take a VA_ARGS number of types so you can say something like:

CTL_IO_ASSERT_TYPE(SCSI);
CTL_IO_ASSERT_TYPE(NVME);
CTL_IO_ASSERT_TYPE(SCSI, NVME);

Where the last one asserts that the type is either SCSI or NVME. Under the hood there would be a CTL_IO_ASSERT_TYPE_1 and CTL_IO_ASSERT_TYPE_2 and CTL_IO_ASSERT would pick the right backing macro based on the number of arguments passed similar to how CTR maps to CTRn.

imp added inline comments.
sys/cam/ctl/ctl_io.h
595

It would be cool if we could...

This revision is now accepted and ready to land.Apr 19 2024, 2:10 AM
jhb retitled this revision from ctl: Add CTL_IO_ASSERT_SCSI wrapper macro to ctl: Add CTL_IO_ASSERT wrapper macro.May 1 2024, 8:27 PM
jhb edited the summary of this revision. (Show Details)

Rework macro to allow for one or more types as var-args

This revision now requires review to proceed.May 1 2024, 8:28 PM
This revision was not accepted when it landed; it landed in state Needs Review.May 3 2024, 12:16 AM
This revision was automatically updated to reflect the committed changes.