1
2
3
4
5
6
7
8
9
10
11#include <linux/module.h>
12#include <linux/pci.h>
13
14#include "rvu_struct.h"
15#include "common.h"
16#include "mbox.h"
17#include "rvu.h"
18
19struct reg_range {
20 u64 start;
21 u64 end;
22};
23
24struct hw_reg_map {
25 u8 regblk;
26 u8 num_ranges;
27 u64 mask;
28#define MAX_REG_RANGES 8
29 struct reg_range range[MAX_REG_RANGES];
30};
31
32static struct hw_reg_map txsch_reg_map[NIX_TXSCH_LVL_CNT] = {
33 {NIX_TXSCH_LVL_SMQ, 2, 0xFFFF, {{0x0700, 0x0708}, {0x1400, 0x14C8} } },
34 {NIX_TXSCH_LVL_TL4, 3, 0xFFFF, {{0x0B00, 0x0B08}, {0x0B10, 0x0B18},
35 {0x1200, 0x12E0} } },
36 {NIX_TXSCH_LVL_TL3, 3, 0xFFFF, {{0x1000, 0x10E0}, {0x1600, 0x1608},
37 {0x1610, 0x1618} } },
38 {NIX_TXSCH_LVL_TL2, 2, 0xFFFF, {{0x0E00, 0x0EE0}, {0x1700, 0x17B0} } },
39 {NIX_TXSCH_LVL_TL1, 1, 0xFFFF, {{0x0C00, 0x0D98} } },
40};
41
42bool rvu_check_valid_reg(int regmap, int regblk, u64 reg)
43{
44 int idx;
45 struct hw_reg_map *map;
46
47
48 if (reg & 0x07)
49 return false;
50
51 if (regmap == TXSCHQ_HWREGMAP) {
52 if (regblk >= NIX_TXSCH_LVL_CNT)
53 return false;
54 map = &txsch_reg_map[regblk];
55 } else {
56 return false;
57 }
58
59
60 if (map->regblk != regblk)
61 return false;
62
63 reg &= map->mask;
64
65 for (idx = 0; idx < map->num_ranges; idx++) {
66 if (reg >= map->range[idx].start &&
67 reg < map->range[idx].end)
68 return true;
69 }
70 return false;
71}
72