xref: /freebsd/sys/dev/aq/aq_common.h (revision e2afbc45258f2fa4bdcf126e959ac660e76fc802)
1 /*
2  * aQuantia Corporation Network Driver
3  * Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  *   (1) Redistributions of source code must retain the above
10  *   copyright notice, this list of conditions and the following
11  *   disclaimer.
12  *
13  *   (2) Redistributions in binary form must reproduce the above
14  *   copyright notice, this list of conditions and the following
15  *   disclaimer in the documentation and/or other materials provided
16  *   with the distribution.
17  *
18  *   (3)The name of the author may not be used to endorse or promote
19  *   products derived from this software without specific prior
20  *   written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
23  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
26  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
28  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 #ifndef _AQ_COMMON_H_
36 #define _AQ_COMMON_H_
37 
38 #include <sys/types.h>
39 
40 #define s8       __int8_t
41 #define u8       __uint8_t
42 #define u16      __uint16_t
43 #define s16      __int16_t
44 #define u32      __uint32_t
45 #define u64      __uint64_t
46 #define s64      __int64_t
47 #define s32      int
48 
49 #define ETIME ETIMEDOUT
50 #define EOK 0
51 
52 #define BIT(nr) (1UL << (nr))
53 
54 #define usec_delay(x) DELAY(x)
55 
56 #ifndef msec_delay
57 #define msec_delay(x) DELAY(x*1000)
58 #define msec_delay_irq(x) DELAY(x*1000)
59 #endif
60 
61 #define AQ_HW_WAIT_FOR(_B_, _US_, _N_) \
62     do { \
63         unsigned int i; \
64         for (i = _N_; (!(_B_)) && i; --i) { \
65             usec_delay(_US_); \
66         } \
67         if (!i) { \
68             err = -1; \
69         } \
70     } while (0)
71 
72 
73 #define LOWORD(a) ((u16)(a))
74 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
75 
76 #define AQ_VER        "0.0.5"
77 
78 #endif //_AQ_COMMON_H_
79 
80