net/ice: support L4 for QinQ switch filter
[dpdk.git] / drivers / net / txgbe / txgbe_regs_group.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2015-2020 Beijing WangXun Technology Co., Ltd.
3  * Copyright(c) 2010-2017 Intel Corporation
4  */
5
6 #ifndef _TXGBE_REGS_GROUP_H_
7 #define _TXGBE_REGS_GROUP_H_
8
9 #include "txgbe_ethdev.h"
10
11 struct txgbe_hw;
12 struct reg_info {
13         uint32_t base_addr;
14         uint32_t count;
15         uint32_t stride;
16         const char *name;
17 };
18
19 static inline int
20 txgbe_read_regs(struct txgbe_hw *hw, const struct reg_info *reg,
21         uint32_t *reg_buf)
22 {
23         unsigned int i;
24
25         for (i = 0; i < reg->count; i++)
26                 reg_buf[i] = rd32(hw,
27                                         reg->base_addr + i * reg->stride);
28         return reg->count;
29 };
30
31 static inline int
32 txgbe_regs_group_count(const struct reg_info *regs)
33 {
34         int count = 0;
35         int i = 0;
36
37         while (regs[i].count)
38                 count += regs[i++].count;
39         return count;
40 };
41
42 static inline int
43 txgbe_read_regs_group(struct rte_eth_dev *dev, uint32_t *reg_buf,
44                                           const struct reg_info *regs)
45 {
46         int count = 0;
47         int i = 0;
48         struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
49
50         while (regs[i].count)
51                 count += txgbe_read_regs(hw, &regs[i++], &reg_buf[count]);
52         return count;
53 };
54
55 #endif /* _TXGBE_REGS_GROUP_H_ */