1/* SPDX-License-Identifier: BSD-3-Clause */
2/*  Copyright (c) 2021, 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/*$FreeBSD$*/
32
33/**
34 * @file ice_features.h
35 * @brief device feature controls
36 *
37 * Contains a list of various device features which could be enabled or
38 * disabled.
39 */
40
41#ifndef _ICE_FEATURES_H_
42#define _ICE_FEATURES_H_
43
44/**
45 * @enum feat_list
46 * @brief driver feature enumeration
47 *
48 * Enumeration of possible device driver features that can be enabled or
49 * disabled. Each possible value represents a different feature which can be
50 * enabled or disabled.
51 *
52 * The driver stores a bitmap of the features that the device and OS are
53 * capable of, as well as another bitmap indicating which features are
54 * currently enabled for that device.
55 */
56enum feat_list {
57	ICE_FEATURE_SRIOV,
58	ICE_FEATURE_RSS,
59	ICE_FEATURE_NETMAP,
60	ICE_FEATURE_FDIR,
61	ICE_FEATURE_MSI,
62	ICE_FEATURE_MSIX,
63	ICE_FEATURE_RDMA,
64	ICE_FEATURE_SAFE_MODE,
65	ICE_FEATURE_LENIENT_LINK_MODE,
66	ICE_FEATURE_DEFAULT_OVERRIDE,
67	/* Must be last entry */
68	ICE_FEATURE_COUNT
69};
70
71/**
72 * ice_disable_unsupported_features - Disable features not enabled by OS
73 * @bitmap: the feature bitmap
74 *
75 * Check for OS support of various driver features. Clear the feature bit for
76 * any feature which is not enabled by the OS. This should be called early
77 * during driver attach after setting up the feature bitmap.
78 *
79 * @remark the bitmap parameter is marked as unused in order to avoid an
80 * unused parameter warning in case none of the features need to be disabled.
81 */
82static inline void
83ice_disable_unsupported_features(ice_bitmap_t __unused *bitmap)
84{
85	ice_clear_bit(ICE_FEATURE_SRIOV, bitmap);
86#ifndef DEV_NETMAP
87	ice_clear_bit(ICE_FEATURE_NETMAP, bitmap);
88#endif
89}
90
91#endif
92