net/ngbe: support link update
[dpdk.git] / drivers / net / ngbe / ngbe_ethdev.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2018-2021 Beijing WangXun Technology Co., Ltd.
3  * Copyright(c) 2010-2017 Intel Corporation
4  */
5
6 #ifndef _NGBE_ETHDEV_H_
7 #define _NGBE_ETHDEV_H_
8
9 /* need update link, bit flag */
10 #define NGBE_FLAG_NEED_LINK_UPDATE  ((uint32_t)(1 << 0))
11 #define NGBE_FLAG_MAILBOX           ((uint32_t)(1 << 1))
12 #define NGBE_FLAG_PHY_INTERRUPT     ((uint32_t)(1 << 2))
13 #define NGBE_FLAG_MACSEC            ((uint32_t)(1 << 3))
14 #define NGBE_FLAG_NEED_LINK_CONFIG  ((uint32_t)(1 << 4))
15
16 #define NGBE_MISC_VEC_ID               RTE_INTR_VEC_ZERO_OFFSET
17
18 /* structure for interrupt relative data */
19 struct ngbe_interrupt {
20         uint32_t flags;
21         uint32_t mask_misc;
22         uint32_t mask_misc_orig; /* save mask during delayed handler */
23         uint64_t mask;
24         uint64_t mask_orig; /* save mask during delayed handler */
25 };
26
27 /*
28  * Structure to store private data for each driver instance (for each port).
29  */
30 struct ngbe_adapter {
31         struct ngbe_hw             hw;
32         struct ngbe_interrupt      intr;
33 };
34
35 static inline struct ngbe_adapter *
36 ngbe_dev_adapter(struct rte_eth_dev *dev)
37 {
38         struct ngbe_adapter *ad = dev->data->dev_private;
39
40         return ad;
41 }
42
43 static inline struct ngbe_hw *
44 ngbe_dev_hw(struct rte_eth_dev *dev)
45 {
46         struct ngbe_adapter *ad = ngbe_dev_adapter(dev);
47         struct ngbe_hw *hw = &ad->hw;
48
49         return hw;
50 }
51
52 static inline struct ngbe_interrupt *
53 ngbe_dev_intr(struct rte_eth_dev *dev)
54 {
55         struct ngbe_adapter *ad = ngbe_dev_adapter(dev);
56         struct ngbe_interrupt *intr = &ad->intr;
57
58         return intr;
59 }
60
61 int
62 ngbe_dev_link_update_share(struct rte_eth_dev *dev,
63                 int wait_to_complete);
64
65 #define NGBE_LINK_DOWN_CHECK_TIMEOUT 4000 /* ms */
66 #define NGBE_LINK_UP_CHECK_TIMEOUT   1000 /* ms */
67 #define NGBE_VMDQ_NUM_UC_MAC         4096 /* Maximum nb. of UC MAC addr. */
68
69 #endif /* _NGBE_ETHDEV_H_ */