xref: /freebsd/sys/dev/wtap/wtap_hal/hal.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
104d19802SAdrian Chadd /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3718cf2ccSPedro F. Giffuni  *
404d19802SAdrian Chadd  * Copyright (c) 2010-2011 Monthadar Al Jaberi, TerraNet AB
504d19802SAdrian Chadd  * All rights reserved.
604d19802SAdrian Chadd  *
704d19802SAdrian Chadd  * Redistribution and use in source and binary forms, with or without
804d19802SAdrian Chadd  * modification, are permitted provided that the following conditions
904d19802SAdrian Chadd  * are met:
1004d19802SAdrian Chadd  * 1. Redistributions of source code must retain the above copyright
1104d19802SAdrian Chadd  *    notice, this list of conditions and the following disclaimer,
1204d19802SAdrian Chadd  *    without modification.
1304d19802SAdrian Chadd  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
1404d19802SAdrian Chadd  *    similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
1504d19802SAdrian Chadd  *    redistribution must be conditioned upon including a substantially
1604d19802SAdrian Chadd  *    similar Disclaimer requirement for further binary redistribution.
1704d19802SAdrian Chadd  *
1804d19802SAdrian Chadd  * NO WARRANTY
1904d19802SAdrian Chadd  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2004d19802SAdrian Chadd  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2104d19802SAdrian Chadd  * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
2204d19802SAdrian Chadd  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
2304d19802SAdrian Chadd  * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
2404d19802SAdrian Chadd  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2504d19802SAdrian Chadd  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2604d19802SAdrian Chadd  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
2704d19802SAdrian Chadd  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2804d19802SAdrian Chadd  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
2904d19802SAdrian Chadd  * THE POSSIBILITY OF SUCH DAMAGES.
3004d19802SAdrian Chadd  */
3104d19802SAdrian Chadd 
3204d19802SAdrian Chadd #ifndef _WTAP_HAL_H_
3304d19802SAdrian Chadd #define _WTAP_HAL_H_
3404d19802SAdrian Chadd 
3504d19802SAdrian Chadd #include "../if_wtapvar.h"
3604d19802SAdrian Chadd #include "../plugins/wtap_plugin.h"
3704d19802SAdrian Chadd #include "handler.h"
3804d19802SAdrian Chadd 
39c0b65123SEn-Wei Wu #define	HAL_TIMER_INTVAL	50 /* in msecs */
40c0b65123SEn-Wei Wu 
4104d19802SAdrian Chadd struct wtap_hal {
4204d19802SAdrian Chadd 	struct wtap_medium	*hal_md;
4304d19802SAdrian Chadd 	struct mtx		hal_mtx;
4404d19802SAdrian Chadd 	struct wtap_plugin	*plugin;
4504d19802SAdrian Chadd 	struct wtap_softc 	*hal_devs[MAX_NBR_WTAP];
46c0b65123SEn-Wei Wu 	/* hardware information */
47c0b65123SEn-Wei Wu 	struct hw {
48c0b65123SEn-Wei Wu 		struct callout timer_intr;
49c0b65123SEn-Wei Wu 		uint32_t timer_intr_intval;
50c0b65123SEn-Wei Wu 		uint64_t tsf;
51c0b65123SEn-Wei Wu 	} hw;
5204d19802SAdrian Chadd };
5304d19802SAdrian Chadd 
5404d19802SAdrian Chadd void init_hal(struct wtap_hal *);
5504d19802SAdrian Chadd void deinit_hal(struct wtap_hal *);
5604d19802SAdrian Chadd void register_plugin(struct wtap_hal *, struct wtap_plugin *);
5704d19802SAdrian Chadd void deregister_plugin(struct wtap_hal *);
5804d19802SAdrian Chadd int32_t new_wtap(struct wtap_hal *, int32_t id);
5904d19802SAdrian Chadd int32_t free_wtap(struct wtap_hal *, int32_t id);
60c0b65123SEn-Wei Wu void wtap_hal_timer_intr(void *);
61c0b65123SEn-Wei Wu void wtap_hal_reset_tsf(struct wtap_hal *);
62c0b65123SEn-Wei Wu uint64_t wtap_hal_get_tsf(struct wtap_hal *);
6304d19802SAdrian Chadd 
6404d19802SAdrian Chadd #endif
65