Page MenuHomeFreeBSD

ctl: Add CTL_IO_ASSERT wrapper macro
ClosedPublic

Authored by jhb on Apr 18 2024, 5:45 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Oct 31, 4:04 PM
Unknown Object (File)
Fri, Oct 18, 10:31 AM
Unknown Object (File)
Fri, Oct 18, 10:31 AM
Unknown Object (File)
Thu, Oct 17, 9:38 AM
Unknown Object (File)
Wed, Oct 16, 7:58 AM
Unknown Object (File)
Oct 15 2024, 3:32 AM
Unknown Object (File)
Oct 14 2024, 3:34 PM
Unknown Object (File)
Oct 13 2024, 2:43 AM
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 Skipped
Unit
Tests Skipped
Build Status
Buildable 57504
Build 54392: arc lint + arc unit

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.