2 * Connection oriented routing
3 * Copyright (C) 2007-2021 Michael Blizek
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
19 static const __u32 cor_log_64_11_table
[] = {0,
20 64, 68, 73, 77, 82, 88, 93, 99, 106, 113, 120,
21 128, 136, 145, 155, 165, 175, 187, 199, 212, 226, 240,
22 256, 273, 290, 309, 329, 351, 374, 398, 424, 451, 481,
23 512, 545, 581, 619, 659, 702, 747, 796, 848, 903, 961,
24 1024, 1091, 1162, 1237, 1318, 1403, 1495, 1592, 1695, 1805,
26 2048, 2181, 2323, 2474, 2635, 2806, 2989, 3183, 3390, 3611,
28 4096, 4362, 4646, 4948, 5270, 5613, 5978, 6367, 6781, 7222,
30 8192, 8725, 9292, 9897, 10540, 11226, 11956, 12734, 13562,
32 16384, 17450, 18585, 19793, 21081, 22452, 23912, 25467, 27124,
34 32768, 34899, 37169, 39587, 42161, 44904, 47824, 50935, 54248,
36 65536, 69799, 74338, 79173, 84323, 89807, 95648, 101870, 108495,
38 131072, 139597, 148677, 158347, 168646, 179615, 191297, 203739,
39 216991, 231104, 246135,
40 262144, 279194, 297353, 316693, 337291, 359229, 382594, 407478,
41 433981, 462208, 492270,
42 524288, 558388, 594706, 633387, 674583, 718459, 765188, 814957,
43 867962, 924415, 984540,
44 1048576, 1116777, 1189413, 1266774, 1349166, 1436917, 1530376,
45 1629913, 1735924, 1848831, 1969081,
46 2097152, 2233553, 2378826, 2533547, 2698332, 2873834, 3060752,
47 3259826, 3471849, 3697662, 3938162,
48 4194304, 4467106, 4757652, 5067094, 5396664, 5747669, 6121503,
49 6519652, 6943698, 7395323, 7876323,
50 8388608, 8934212, 9515303, 10134189, 10793327, 11495337,
51 12243006, 13039305, 13887396, 14790647,
53 16777216, 17868424, 19030606, 20268378, 21586655, 22990674,
54 24486013, 26078610, 27774791, 29581294,
56 33554432, 35736849, 38061212, 40536755, 43173310, 45981349,
57 48972026, 52157220, 55549582, 59162588,
59 67108864, 71473698, 76122425, 81073510, 86346620, 91962698,
60 97944052, 104314440, 111099165, 118325175,
62 134217728, 142947395, 152244850, 162147020, 172693239,
63 183925396, 195888104, 208628880, 222198329,
65 268435456, 285894791, 304489699, 324294041, 345386479,
66 367850791, 391776208, 417257759, 444396658,
68 536870912, 571789581};
70 __u8
__attribute__((const)) cor_enc_log_64_11(__u32 value
)
73 BUG_ON(cor_log_64_11_table
[255] != 571789581);
74 for (i
= 1; i
< 256; i
++) {
75 if (cor_log_64_11_table
[i
] > value
)
79 return (__u8
)(i
-1); /* round down */
82 __u32
__attribute__((const)) cor_dec_log_64_11(__u8 value
)
84 BUG_ON(cor_log_64_11_table
[255] != 571789581);
85 return cor_log_64_11_table
[value
];
88 static void __init
cor_check_log_64_11_table(void)
91 BUG_ON(cor_log_64_11_table
[0] != 0);
92 for (i
= 1; i
< 256; i
++) {
93 BUG_ON(cor_log_64_11_table
[i
] <= cor_log_64_11_table
[i
-1]);
98 void cor_swap_list_items(struct list_head
*lh1
, struct list_head
*lh2
)
100 struct list_head
*tmp
;
102 tmp
= (lh1
->next
== lh1
? lh2
: lh1
->next
);
103 lh1
->next
= (lh2
->next
== lh2
? lh1
: lh2
->next
);
106 tmp
= (lh1
->prev
== lh1
? lh2
: lh2
->prev
);
107 lh1
->prev
= (lh2
->prev
== lh2
? lh1
: lh2
->prev
);
110 lh1
->next
->prev
= lh1
;
111 lh1
->prev
->next
= lh1
;
113 lh2
->next
->prev
= lh2
;
114 lh2
->prev
->next
= lh2
;
117 void cor_kreffree_bug(struct kref
*ref
)
122 int __init
cor_util_init(void)
124 cor_check_log_64_11_table();
129 MODULE_LICENSE("GPL");