xref: /freebsd/sys/dev/ice/ice_features.h (revision f2635e844dd138ac9dfba676f27d41750049af26)
1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /*  Copyright (c) 2024, Intel Corporation
3  *  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 are met:
7  *
8  *   1. Redistributions of source code must retain the above copyright notice,
9  *      this list of conditions and the following disclaimer.
10  *
11  *   2. Redistributions in binary form must reproduce the above copyright
12  *      notice, this list of conditions and the following disclaimer in the
13  *      documentation and/or other materials provided with the distribution.
14  *
15  *   3. Neither the name of the Intel Corporation nor the names of its
16  *      contributors may be used to endorse or promote products derived from
17  *      this software without specific prior written permission.
18  *
19  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23  *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  *  POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 /**
33  * @file ice_features.h
34  * @brief device feature controls
35  *
36  * Contains a list of various device features which could be enabled or
37  * disabled.
38  */
39 
40 #ifndef _ICE_FEATURES_H_
41 #define _ICE_FEATURES_H_
42 
43 /**
44  * @enum feat_list
45  * @brief driver feature enumeration
46  *
47  * Enumeration of possible device driver features that can be enabled or
48  * disabled. Each possible value represents a different feature which can be
49  * enabled or disabled.
50  *
51  * The driver stores a bitmap of the features that the device and OS are
52  * capable of, as well as another bitmap indicating which features are
53  * currently enabled for that device.
54  */
55 enum feat_list {
56 	ICE_FEATURE_SRIOV,
57 	ICE_FEATURE_RSS,
58 	ICE_FEATURE_NETMAP,
59 	ICE_FEATURE_FDIR,
60 	ICE_FEATURE_MSI,
61 	ICE_FEATURE_MSIX,
62 	ICE_FEATURE_RDMA,
63 	ICE_FEATURE_SAFE_MODE,
64 	ICE_FEATURE_LENIENT_LINK_MODE,
65 	ICE_FEATURE_LINK_MGMT_VER_1,
66 	ICE_FEATURE_LINK_MGMT_VER_2,
67 	ICE_FEATURE_HEALTH_STATUS,
68 	ICE_FEATURE_FW_LOGGING,
69 	ICE_FEATURE_HAS_PBA,
70 	ICE_FEATURE_DCB,
71 	ICE_FEATURE_TX_BALANCE,
72 	ICE_FEATURE_DUAL_NAC,
73 	ICE_FEATURE_TEMP_SENSOR,
74 	ICE_FEATURE_NEXT_CLUSTER_ID,
75 	ICE_FEATURE_PHY_STATISTICS,
76 	/* Must be last entry */
77 	ICE_FEATURE_COUNT
78 };
79 
80 /**
81  * ice_disable_unsupported_features - Disable features not enabled by OS
82  * @bitmap: the feature bitmap
83  *
84  * Check for OS support of various driver features. Clear the feature bit for
85  * any feature which is not enabled by the OS. This should be called early
86  * during driver attach after setting up the feature bitmap.
87  *
88  * @remark the bitmap parameter is marked as unused in order to avoid an
89  * unused parameter warning in case none of the features need to be disabled.
90  */
91 static inline void
92 ice_disable_unsupported_features(ice_bitmap_t __unused *bitmap)
93 {
94 	ice_clear_bit(ICE_FEATURE_SRIOV, bitmap);
95 #ifndef DEV_NETMAP
96 	ice_clear_bit(ICE_FEATURE_NETMAP, bitmap);
97 #endif
98 }
99 
100 #endif
101