1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0) */
2 /* Copyright (C) 2014-2017 aQuantia Corporation. */
4 /* File aq_hw_utils.h: Declaration of helper functions used across hardware
11 #include <rte_common.h>
13 #include <rte_byteorder.h>
14 #include <rte_random.h>
15 #include <rte_cycles.h>
16 #include "atl_common.h"
17 #include "atl_types.h"
21 #define LODWORD(_qw) ((u32)(_qw))
22 #define HIDWORD(_qw) ((u32)(((_qw) >> 32) & 0xffffffff))
25 #define AQ_HW_SLEEP(_US_) rte_delay_ms(_US_)
27 #define mdelay rte_delay_ms
28 #define udelay rte_delay_us
29 #define ARRAY_SIZE(arr) RTE_DIM(arr)
30 #define BIT(x) (1UL << (x))
32 #define AQ_HW_WAIT_FOR(_B_, _US_, _N_) \
34 unsigned int AQ_HW_WAIT_FOR_i; \
35 for (AQ_HW_WAIT_FOR_i = _N_; (!(_B_)) && (AQ_HW_WAIT_FOR_i);\
36 --AQ_HW_WAIT_FOR_i) {\
39 if (!AQ_HW_WAIT_FOR_i) {\
44 #define ATL_WRITE_FLUSH(aq_hw) { (void)aq_hw_read_reg(aq_hw, 0x10); }
46 void aq_hw_write_reg_bit(struct aq_hw_s *aq_hw, u32 addr, u32 msk,
48 u32 aq_hw_read_reg_bit(struct aq_hw_s *aq_hw, u32 addr, u32 msk, u32 shift);
49 u32 aq_hw_read_reg(struct aq_hw_s *hw, u32 reg);
50 void aq_hw_write_reg(struct aq_hw_s *hw, u32 reg, u32 value);
51 int aq_hw_err_from_flags(struct aq_hw_s *hw);
53 #endif /* AQ_HW_UTILS_H */