In this commit, we introduce defines for tipc address size, offset and mask specification for Zone.Cluster.Node. There is no functional change in this commit.
Showing the changes to include/uapi/linux (1 of 3 files). Show all
Unified · Split
| @@ -60,26 +60,48 @@ struct tipc_name_seq { · 59 unmodified lines | ||
| 60 | 60 | __u32 upper; |
| 61 | 61 | }; |
| 62 | 62 | |
| 63 | +/* TIPC Address Size, Offset, Mask specification for Z.C.N | |
| 64 | + */ | |
| 65 | +#define TIPC_NODE_BITS 12 | |
| 66 | +#define TIPC_CLUSTER_BITS 12 | |
| 67 | +#define TIPC_ZONE_BITS 8 | |
| 68 | + | |
| 69 | +#define TIPC_NODE_OFFSET 0 | |
| 70 | +#define TIPC_CLUSTER_OFFSET TIPC_NODE_BITS | |
| 71 | +#define TIPC_ZONE_OFFSET (TIPC_CLUSTER_OFFSET + TIPC_CLUSTER_BITS) | |
| 72 | + | |
| 73 | +#define TIPC_NODE_SIZE ((1UL << TIPC_NODE_BITS) - 1) | |
| 74 | +#define TIPC_CLUSTER_SIZE ((1UL << TIPC_CLUSTER_BITS) - 1) | |
| 75 | +#define TIPC_ZONE_SIZE ((1UL << TIPC_ZONE_BITS) - 1) | |
| 76 | + | |
| 77 | +#define TIPC_NODE_MASK (TIPC_NODE_SIZE << TIPC_NODE_OFFSET) | |
| 78 | +#define TIPC_CLUSTER_MASK (TIPC_CLUSTER_SIZE << TIPC_CLUSTER_OFFSET) | |
| 79 | +#define TIPC_ZONE_MASK (TIPC_ZONE_SIZE << TIPC_ZONE_OFFSET) | |
| 80 | + | |
| 81 | +#define TIPC_ZONE_CLUSTER_MASK (TIPC_ZONE_MASK | TIPC_CLUSTER_MASK) | |
| 82 | + | |
| 63 | 83 | static inline __u32 tipc_addr(unsigned int zone, |
| 64 | 84 | unsigned int cluster, |
| 65 | 85 | unsigned int node) |
| 66 | 86 | { |
| 67 | − return (zone << 24) | (cluster << 12) | node; | |
| 87 | + return (zone << TIPC_ZONE_OFFSET) | | |
| 88 | + (cluster << TIPC_CLUSTER_OFFSET) | | |
| 89 | + node; | |
| 68 | 90 | } |
| 69 | 91 | |
| 70 | 92 | static inline unsigned int tipc_zone(__u32 addr) |
| 71 | 93 | { |
| 72 | − return addr >> 24; | |
| 94 | + return addr >> TIPC_ZONE_OFFSET; | |
| 73 | 95 | } |
| 74 | 96 | |
| 75 | 97 | static inline unsigned int tipc_cluster(__u32 addr) |
| 76 | 98 | { |
| 77 | − return (addr >> 12) & 0xfff; | |
| 99 | + return (addr & TIPC_CLUSTER_MASK) >> TIPC_CLUSTER_OFFSET; | |
| 78 | 100 | } |
| 79 | 101 | |
| 80 | 102 | static inline unsigned int tipc_node(__u32 addr) |
| 81 | 103 | { |
| 82 | − return addr & 0xfff; | |
| 104 | + return addr & TIPC_NODE_MASK; | |
| 83 | 105 | } |
| 84 | 106 | |
| 85 | 107 | /* |