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)
Tue, Dec 17, 5:29 AM
Unknown Object (File)
Mon, Dec 2, 10:04 AM
Unknown Object (File)
Sat, Nov 30, 2:12 PM
Unknown Object (File)
Nov 23 2024, 11:36 AM
Unknown Object (File)
Nov 23 2024, 11:36 AM
Unknown Object (File)
Nov 23 2024, 11:36 AM
Unknown Object (File)
Nov 23 2024, 11:35 AM
Unknown Object (File)
Nov 23 2024, 11:21 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 57183
Build 54071: 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.