c1e32177d0d0d3fc387ff7177f63c506620a2980
[dpdk.git] / drivers / net / igc / igc_ethdev.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2019-2020 Intel Corporation
3  */
4
5 #ifndef _IGC_ETHDEV_H_
6 #define _IGC_ETHDEV_H_
7
8 #include <rte_ethdev.h>
9
10 #include "base/igc_osdep.h"
11 #include "base/igc_hw.h"
12 #include "base/igc_i225.h"
13 #include "base/igc_api.h"
14
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18
19 #define IGC_QUEUE_PAIRS_NUM             4
20
21 /* structure for interrupt relative data */
22 struct igc_interrupt {
23         uint32_t flags;
24         uint32_t mask;
25 };
26
27 /*
28  * Structure to store private data for each driver instance (for each port).
29  */
30 struct igc_adapter {
31         struct igc_hw           hw;
32         struct igc_interrupt    intr;
33         bool            stopped;
34 };
35
36 #define IGC_DEV_PRIVATE(_dev)   ((_dev)->data->dev_private)
37
38 #define IGC_DEV_PRIVATE_HW(_dev) \
39         (&((struct igc_adapter *)(_dev)->data->dev_private)->hw)
40
41 #define IGC_DEV_PRIVATE_INTR(_dev) \
42         (&((struct igc_adapter *)(_dev)->data->dev_private)->intr)
43
44 static inline void
45 igc_read_reg_check_set_bits(struct igc_hw *hw, uint32_t reg, uint32_t bits)
46 {
47         uint32_t reg_val = IGC_READ_REG(hw, reg);
48
49         bits |= reg_val;
50         if (bits == reg_val)
51                 return; /* no need to write back */
52
53         IGC_WRITE_REG(hw, reg, bits);
54 }
55
56 static inline void
57 igc_read_reg_check_clear_bits(struct igc_hw *hw, uint32_t reg, uint32_t bits)
58 {
59         uint32_t reg_val = IGC_READ_REG(hw, reg);
60
61         bits = reg_val & ~bits;
62         if (bits == reg_val)
63                 return; /* no need to write back */
64
65         IGC_WRITE_REG(hw, reg, bits);
66 }
67
68 #ifdef __cplusplus
69 }
70 #endif
71
72 #endif /* _IGC_ETHDEV_H_ */