diff options
| author | Abdelkader Boudih <seuros@FreeBSD.org> | 2026-09-25 21:42:15 +0000 |
|---|---|---|
| committer | Abdelkader Boudih <seuros@FreeBSD.org> | 2026-09-25 21:42:15 +0000 |
| commit | 92dec9201bf9759fc760da49a175fc99f3277c6c (patch) | |
| tree | 7c05ff7d46bd3ba408ae1c1d6b205d895422d8af | |
| parent | 546d15061962a8c45c779210969015e30124fe8d (diff) | |
nvme: share one handler between the interrupt coalescing sysctls
The int_coal_time and int_coal_threshold handlers differed only in which
controller field they updated before reprogramming the feature.
Reviewed by: imp, adrian
Differential Revision: https://reviews.freebsd.org/D60018
| -rw-r--r-- | sys/dev/nvme/nvme_sysctl.c | 37 |
1 files changed, 10 insertions, 27 deletions
diff --git a/sys/dev/nvme/nvme_sysctl.c b/sys/dev/nvme/nvme_sysctl.c index d94bff15244f..6da1be02f4b2 100644 --- a/sys/dev/nvme/nvme_sysctl.c +++ b/sys/dev/nvme/nvme_sysctl.c @@ -93,36 +93,17 @@ nvme_sysctl_dump_debug(SYSCTL_HANDLER_ARGS) } static int -nvme_sysctl_int_coal_time(SYSCTL_HANDLER_ARGS) +nvme_sysctl_int_coal(SYSCTL_HANDLER_ARGS) { struct nvme_controller *ctrlr = arg1; - uint32_t oldval = ctrlr->int_coal_time; - int error = sysctl_handle_int(oidp, &ctrlr->int_coal_time, 0, - req); + uint32_t *valp = (uint32_t *)((char *)ctrlr + (size_t)arg2); + uint32_t oldval = *valp; + int error = sysctl_handle_int(oidp, valp, 0, req); if (error) return (error); - if (oldval != ctrlr->int_coal_time) - nvme_ctrlr_cmd_set_interrupt_coalescing(ctrlr, - ctrlr->int_coal_time, ctrlr->int_coal_threshold, NULL, - NULL); - - return (0); -} - -static int -nvme_sysctl_int_coal_threshold(SYSCTL_HANDLER_ARGS) -{ - struct nvme_controller *ctrlr = arg1; - uint32_t oldval = ctrlr->int_coal_threshold; - int error = sysctl_handle_int(oidp, &ctrlr->int_coal_threshold, 0, - req); - - if (error) - return (error); - - if (oldval != ctrlr->int_coal_threshold) + if (oldval != *valp) nvme_ctrlr_cmd_set_interrupt_coalescing(ctrlr, ctrlr->int_coal_time, ctrlr->int_coal_threshold, NULL, NULL); @@ -361,13 +342,15 @@ nvme_sysctl_initialize_ctrlr(struct nvme_controller *ctrlr) SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO, "int_coal_time", CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE, - ctrlr, 0, nvme_sysctl_int_coal_time, "IU", + ctrlr, offsetof(struct nvme_controller, int_coal_time), + nvme_sysctl_int_coal, "IU", "Interrupt coalescing timeout (in microseconds)"); SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO, "int_coal_threshold", - CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE, ctrlr, 0, - nvme_sysctl_int_coal_threshold, "IU", + CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE, ctrlr, + offsetof(struct nvme_controller, int_coal_threshold), + nvme_sysctl_int_coal, "IU", "Interrupt coalescing threshold"); SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO, |
