xref: /freebsd-src/sys/dev/ice/ice_defs.h (revision 015f8cc5b0c10336a048f37a7071ea03516de242)
18923de59SPiotr Kubaj /* SPDX-License-Identifier: BSD-3-Clause */
2*015f8cc5SEric Joyner /*  Copyright (c) 2024, Intel Corporation
38923de59SPiotr Kubaj  *  All rights reserved.
48923de59SPiotr Kubaj  *
58923de59SPiotr Kubaj  *  Redistribution and use in source and binary forms, with or without
68923de59SPiotr Kubaj  *  modification, are permitted provided that the following conditions are met:
78923de59SPiotr Kubaj  *
88923de59SPiotr Kubaj  *   1. Redistributions of source code must retain the above copyright notice,
98923de59SPiotr Kubaj  *      this list of conditions and the following disclaimer.
108923de59SPiotr Kubaj  *
118923de59SPiotr Kubaj  *   2. Redistributions in binary form must reproduce the above copyright
128923de59SPiotr Kubaj  *      notice, this list of conditions and the following disclaimer in the
138923de59SPiotr Kubaj  *      documentation and/or other materials provided with the distribution.
148923de59SPiotr Kubaj  *
158923de59SPiotr Kubaj  *   3. Neither the name of the Intel Corporation nor the names of its
168923de59SPiotr Kubaj  *      contributors may be used to endorse or promote products derived from
178923de59SPiotr Kubaj  *      this software without specific prior written permission.
188923de59SPiotr Kubaj  *
198923de59SPiotr Kubaj  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
208923de59SPiotr Kubaj  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
218923de59SPiotr Kubaj  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
228923de59SPiotr Kubaj  *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
238923de59SPiotr Kubaj  *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
248923de59SPiotr Kubaj  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
258923de59SPiotr Kubaj  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
268923de59SPiotr Kubaj  *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
278923de59SPiotr Kubaj  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
288923de59SPiotr Kubaj  *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
298923de59SPiotr Kubaj  *  POSSIBILITY OF SUCH DAMAGE.
308923de59SPiotr Kubaj  */
318923de59SPiotr Kubaj 
328923de59SPiotr Kubaj #ifndef _ICE_DEFS_H_
338923de59SPiotr Kubaj #define _ICE_DEFS_H_
348923de59SPiotr Kubaj 
358923de59SPiotr Kubaj #define ETH_ALEN	6
368923de59SPiotr Kubaj 
378923de59SPiotr Kubaj #define ETH_HEADER_LEN	14
388923de59SPiotr Kubaj 
398923de59SPiotr Kubaj #define BIT(a) (1UL << (a))
408923de59SPiotr Kubaj #ifndef BIT_ULL
418923de59SPiotr Kubaj #define BIT_ULL(a) (1ULL << (a))
429c30461dSEric Joyner #endif /* !BIT_ULL */
438923de59SPiotr Kubaj 
448923de59SPiotr Kubaj #define BITS_PER_BYTE	8
458923de59SPiotr Kubaj 
468923de59SPiotr Kubaj #define _FORCE_
478923de59SPiotr Kubaj 
488923de59SPiotr Kubaj #define ICE_BYTES_PER_WORD	2
498923de59SPiotr Kubaj #define ICE_BYTES_PER_DWORD	4
508923de59SPiotr Kubaj #define ICE_MAX_TRAFFIC_CLASS	8
518923de59SPiotr Kubaj 
528923de59SPiotr Kubaj #ifndef MIN_T
538923de59SPiotr Kubaj #define MIN_T(_t, _a, _b)	min((_t)(_a), (_t)(_b))
549c30461dSEric Joyner #endif /* !MIN_T */
558923de59SPiotr Kubaj 
568923de59SPiotr Kubaj #define IS_ASCII(_ch)	((_ch) < 0x80)
578923de59SPiotr Kubaj 
588923de59SPiotr Kubaj #define STRUCT_HACK_VAR_LEN
598923de59SPiotr Kubaj /**
608923de59SPiotr Kubaj  * ice_struct_size - size of struct with C99 flexible array member
618923de59SPiotr Kubaj  * @ptr: pointer to structure
628923de59SPiotr Kubaj  * @field: flexible array member (last member of the structure)
638923de59SPiotr Kubaj  * @num: number of elements of that flexible array member
648923de59SPiotr Kubaj  */
658923de59SPiotr Kubaj #define ice_struct_size(ptr, field, num) \
668923de59SPiotr Kubaj 	(sizeof(*(ptr)) + sizeof(*(ptr)->field) * (num))
678923de59SPiotr Kubaj 
688923de59SPiotr Kubaj #define FLEX_ARRAY_SIZE(_ptr, _mem, cnt) ((cnt) * sizeof(_ptr->_mem[0]))
698923de59SPiotr Kubaj 
708923de59SPiotr Kubaj #endif /* _ICE_DEFS_H_ */
71