xref: /illumos-gate/usr/src/uts/common/sys/cyclic.h (revision f06dce2c1f0f3af78581e7574f65bfba843ddb6e)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
587a18d3fSMadhavan Venkataraman  * Common Development and Distribution License (the "License").
687a18d3fSMadhavan Venkataraman  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
2287a18d3fSMadhavan Venkataraman  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
2387a18d3fSMadhavan Venkataraman  * Use is subject to license terms.
24*f06dce2cSAndrew Stormont  *
25*f06dce2cSAndrew Stormont  * Copyright 2017 RackTop Systems.
267c478bd9Sstevel@tonic-gate  */
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate #ifndef _SYS_CYCLIC_H
297c478bd9Sstevel@tonic-gate #define	_SYS_CYCLIC_H
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
327c478bd9Sstevel@tonic-gate extern "C" {
337c478bd9Sstevel@tonic-gate #endif
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #ifndef _ASM
367c478bd9Sstevel@tonic-gate #include <sys/time.h>
377c478bd9Sstevel@tonic-gate #include <sys/cpuvar.h>
387c478bd9Sstevel@tonic-gate #include <sys/cpupart.h>
397c478bd9Sstevel@tonic-gate #endif /* !_ASM */
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate #define	CY_LOW_LEVEL		0
427c478bd9Sstevel@tonic-gate #define	CY_LOCK_LEVEL		1
437c478bd9Sstevel@tonic-gate #define	CY_HIGH_LEVEL		2
447c478bd9Sstevel@tonic-gate #define	CY_SOFT_LEVELS		2
457c478bd9Sstevel@tonic-gate #define	CY_LEVELS		3
467c478bd9Sstevel@tonic-gate 
477c478bd9Sstevel@tonic-gate #ifndef _ASM
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate typedef uintptr_t cyclic_id_t;
507c478bd9Sstevel@tonic-gate typedef int cyc_index_t;
517c478bd9Sstevel@tonic-gate typedef int cyc_cookie_t;
527c478bd9Sstevel@tonic-gate typedef uint16_t cyc_level_t;
537c478bd9Sstevel@tonic-gate typedef void (*cyc_func_t)(void *);
547c478bd9Sstevel@tonic-gate typedef void *cyb_arg_t;
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate #define	CYCLIC_NONE		((cyclic_id_t)0)
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate typedef struct cyc_handler {
597c478bd9Sstevel@tonic-gate 	cyc_func_t cyh_func;
607c478bd9Sstevel@tonic-gate 	void *cyh_arg;
617c478bd9Sstevel@tonic-gate 	cyc_level_t cyh_level;
627c478bd9Sstevel@tonic-gate } cyc_handler_t;
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate typedef struct cyc_time {
657c478bd9Sstevel@tonic-gate 	hrtime_t cyt_when;
667c478bd9Sstevel@tonic-gate 	hrtime_t cyt_interval;
677c478bd9Sstevel@tonic-gate } cyc_time_t;
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate typedef struct cyc_omni_handler {
707c478bd9Sstevel@tonic-gate 	void (*cyo_online)(void *, cpu_t *, cyc_handler_t *, cyc_time_t *);
717c478bd9Sstevel@tonic-gate 	void (*cyo_offline)(void *, cpu_t *, void *);
727c478bd9Sstevel@tonic-gate 	void *cyo_arg;
737c478bd9Sstevel@tonic-gate } cyc_omni_handler_t;
747c478bd9Sstevel@tonic-gate 
7587a18d3fSMadhavan Venkataraman #define	CY_INFINITY	INT64_MAX
7687a18d3fSMadhavan Venkataraman 
77*f06dce2cSAndrew Stormont #if defined(_KERNEL) || defined(_FAKE_KERNEL)
787c478bd9Sstevel@tonic-gate 
797c478bd9Sstevel@tonic-gate extern cyclic_id_t cyclic_add(cyc_handler_t *, cyc_time_t *);
807c478bd9Sstevel@tonic-gate extern cyclic_id_t cyclic_add_omni(cyc_omni_handler_t *);
817c478bd9Sstevel@tonic-gate extern void cyclic_remove(cyclic_id_t);
827c478bd9Sstevel@tonic-gate extern void cyclic_bind(cyclic_id_t, cpu_t *, cpupart_t *);
8387a18d3fSMadhavan Venkataraman extern int cyclic_reprogram(cyclic_id_t, hrtime_t);
847c478bd9Sstevel@tonic-gate extern hrtime_t cyclic_getres();
857c478bd9Sstevel@tonic-gate 
867c478bd9Sstevel@tonic-gate extern int cyclic_offline(cpu_t *cpu);
877c478bd9Sstevel@tonic-gate extern void cyclic_online(cpu_t *cpu);
887c478bd9Sstevel@tonic-gate extern int cyclic_juggle(cpu_t *cpu);
897c478bd9Sstevel@tonic-gate extern void cyclic_move_in(cpu_t *);
907c478bd9Sstevel@tonic-gate extern int cyclic_move_out(cpu_t *);
917c478bd9Sstevel@tonic-gate extern void cyclic_suspend();
927c478bd9Sstevel@tonic-gate extern void cyclic_resume();
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate extern void cyclic_fire(cpu_t *cpu);
957c478bd9Sstevel@tonic-gate extern void cyclic_softint(cpu_t *cpu, cyc_level_t level);
967c478bd9Sstevel@tonic-gate 
97*f06dce2cSAndrew Stormont #endif /* _KERNEL || _FAKE_KERNEL */
987c478bd9Sstevel@tonic-gate 
997c478bd9Sstevel@tonic-gate #endif /* !_ASM */
1007c478bd9Sstevel@tonic-gate 
1017c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1027c478bd9Sstevel@tonic-gate }
1037c478bd9Sstevel@tonic-gate #endif
1047c478bd9Sstevel@tonic-gate 
1057c478bd9Sstevel@tonic-gate #endif /* _SYS_CYCLIC_H */
106