2 * Connection oriented routing
3 * Copyright (C) 2007-2010 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.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 #include <linux/mutex.h>
25 DEFINE_MUTEX(cor_bindnodes
);
26 DEFINE_SPINLOCK(conn_free
);
28 DEFINE_MUTEX(connid_gen
);
39 struct kmem_cache
*conn_slab
;
41 struct htable connid_table
;
42 struct htable reverse_connid_table
;
46 struct kmem_cache
*bindnode_slab
;
47 struct kmem_cache
*connlistener_slab
;
49 /* see cor.h/KP_ACK_CONN */
50 static const __u32 log_64_11_table
[] = {0,
51 64, 68, 73, 77, 82, 88, 93, 99, 106, 113, 120,
52 128, 136, 145, 155, 165, 175, 187, 199, 212, 226, 240,
53 256, 273, 290, 309, 329, 351, 374, 398, 424, 451, 481,
54 512, 545, 581, 619, 659, 702, 747, 796, 848, 903, 961,
55 1024, 1091, 1162, 1237, 1318, 1403, 1495, 1592, 1695, 1805,
57 2048, 2181, 2323, 2474, 2635, 2806, 2989, 3183, 3390, 3611,
59 4096, 4362, 4646, 4948, 5270, 5613, 5978, 6367, 6781, 7222,
61 8192, 8725, 9292, 9897, 10540, 11226, 11956, 12734, 13562,
63 16384, 17450, 18585, 19793, 21081, 22452, 23912, 25467, 27124,
65 32768, 34899, 37169, 39587, 42161, 44904, 47824, 50935, 54248,
67 65536, 69799, 74338, 79173, 84323, 89807, 95648, 101870, 108495,
69 131072, 139597, 148677, 158347, 168646, 179615, 191297, 203739,
70 216991, 231104, 246135,
71 262144, 279194, 297353, 316693, 337291, 359229, 382594, 407478,
72 433981, 462208, 492270,
73 524288, 558388, 594706, 633387, 674583, 718459, 765188, 814957,
74 867962, 924415, 984540,
75 1048576, 1116777, 1189413, 1266774, 1349166, 1436917, 1530376,
76 1629913, 1735924, 1848831, 1969081,
77 2097152, 2233553, 2378826, 2533547, 2698332, 2873834, 3060752,
78 3259826, 3471849, 3697662, 3938162,
79 4194304, 4467106, 4757652, 5067094, 5396664, 5747669, 6121503,
80 6519652, 6943698, 7395323, 7876323,
81 8388608, 8934212, 9515303, 10134189, 10793327, 11495337,
82 12243006, 13039305, 13887396, 14790647,
84 16777216, 17868424, 19030606, 20268378, 21586655, 22990674,
85 24486013, 26078610, 27774791, 29581294,
87 33554432, 35736849, 38061212, 40536755, 43173310, 45981349,
88 48972026, 52157220, 55549582, 59162588,
90 67108864, 71473698, 76122425, 81073510, 86346620, 91962698,
91 97944052, 104314440, 111099165, 118325175,
93 134217728, 142947395, 152244850, 162147020, 172693239,
94 183925396, 195888104, 208628880, 222198329,
96 268435456, 285894791, 304489699, 324294041, 345386479,
97 367850791, 391776208, 417257759, 444396658,
99 536870912, 571789581};
101 static const __u64 log_300_24_table
[] = {0LL,
102 300LL, 308LL, 317LL, 327LL, 336LL, 346LL, 356LL, 367LL, 377LL,
103 389LL, 400LL, 412LL, 424LL, 436LL, 449LL, 462LL, 476LL,
104 490LL, 504LL, 519LL, 534LL, 550LL, 566LL, 582LL,
105 600LL, 617LL, 635LL, 654LL, 673LL, 693LL, 713LL, 734LL, 755LL,
106 778LL, 800LL, 824LL, 848LL, 873LL, 898LL, 925LL, 952LL,
107 980LL, 1009LL, 1038LL, 1069LL, 1100LL, 1132LL, 1165LL,
108 1200LL, 1235LL, 1271LL, 1308LL, 1346LL, 1386LL, 1427LL, 1468LL,
109 1511LL, 1556LL, 1601LL, 1648LL, 1697LL, 1746LL, 1797LL,
110 1850LL, 1904LL, 1960LL, 2018LL, 2077LL, 2138LL, 2200LL,
112 2400LL, 2470LL, 2542LL, 2617LL, 2693LL, 2772LL, 2854LL, 2937LL,
113 3023LL, 3112LL, 3203LL, 3297LL, 3394LL, 3493LL, 3595LL,
114 3701LL, 3809LL, 3921LL, 4036LL, 4154LL, 4276LL, 4401LL,
116 4800LL, 4940LL, 5085LL, 5234LL, 5387LL, 5545LL, 5708LL, 5875LL,
117 6047LL, 6224LL, 6407LL, 6594LL, 6788LL, 6987LL, 7191LL,
118 7402LL, 7619LL, 7842LL, 8072LL, 8309LL, 8552LL, 8803LL,
120 9600LL, 9881LL, 10170LL, 10468LL, 10775LL, 11091LL, 11416LL,
121 11750LL, 12095LL, 12449LL, 12814LL, 13189LL, 13576LL,
122 13974LL, 14383LL, 14805LL, 15239LL, 15685LL, 16145LL,
123 16618LL, 17105LL, 17606LL, 18122LL, 18653LL,
124 19200LL, 19762LL, 20341LL, 20937LL, 21551LL, 22182LL, 22832LL,
125 23501LL, 24190LL, 24899LL, 25628LL, 26379LL, 27152LL,
126 27948LL, 28767LL, 29610LL, 30478LL, 31371LL, 32290LL,
127 33236LL, 34210LL, 35212LL, 36244LL, 37306LL,
128 38400LL, 39525LL, 40683LL, 41875LL, 43102LL, 44365LL, 45665LL,
129 47003LL, 48380LL, 49798LL, 51257LL, 52759LL, 54305LL,
130 55897LL, 57534LL, 59220LL, 60956LL, 62742LL, 64580LL,
131 66473LL, 68421LL, 70425LL, 72489LL, 74613LL,
132 76800LL, 79050LL, 81366LL, 83750LL, 86205LL, 88731LL, 91331LL,
133 94007LL, 96761LL, 99597LL, 102515LL, 105519LL, 108611LL,
134 111794LL, 115069LL, 118441LL, 121912LL, 125484LL,
135 129161LL, 132946LL, 136842LL, 140851LL, 144979LL,
137 153600LL, 158100LL, 162733LL, 167501LL, 172410LL, 177462LL,
138 182662LL, 188014LL, 193523LL, 199194LL, 205031LL,
139 211039LL, 217223LL, 223588LL, 230139LL, 236883LL,
140 243824LL, 250969LL, 258323LL, 265892LL, 273684LL,
141 281703LL, 289958LL, 298454LL,
142 307200LL, 316201LL, 325467LL, 335003LL, 344820LL, 354924LL,
143 365324LL, 376029LL, 387047LL, 398389LL, 410062LL,
144 422078LL, 434446LL, 447176LL, 460279LL, 473767LL,
145 487649LL, 501938LL, 516646LL, 531785LL, 547368LL,
146 563407LL, 579916LL, 596909LL,
147 614400LL, 632403LL, 650934LL, 670007LL, 689640LL, 709848LL,
148 730648LL, 752058LL, 774095LL, 796778LL, 820125LL,
149 844157LL, 868892LL, 894353LL, 920559LL, 947534LL,
150 975299LL, 1003877LL, 1033293LL, 1063571LL, 1094736LL,
151 1126814LL, 1159832LL, 1193818LL,
152 1228800LL, 1264806LL, 1301868LL, 1340015LL, 1379281LL,
153 1419697LL, 1461297LL, 1504116LL, 1548190LL, 1593556LL,
154 1640251LL, 1688314LL, 1737785LL, 1788706LL, 1841119LL,
155 1895068LL, 1950598LL, 2007755LL, 2066587LL, 2127142LL,
156 2189472LL, 2253629LL, 2319665LL, 2387636LL,
157 2457600LL, 2529613LL, 2603736LL, 2680031LL, 2758562LL,
158 2839394LL, 2922595LL, 3008233LL, 3096381LL, 3187112LL,
159 3280502LL, 3376628LL, 3475571LL, 3577413LL, 3682239LL,
160 3790137LL, 3901196LL, 4015510LL, 4133174LL, 4254285LL,
161 4378945LL, 4507258LL, 4639331LL, 4775273LL,
162 4915200LL, 5059226LL, 5207473LL, 5360063LL, 5517125LL,
163 5678789LL, 5845190LL, 6016467LL, 6192763LL, 6374225LL,
164 6561004LL, 6753256LL, 6951142LL, 7154826LL, 7364478LL,
165 7580274LL, 7802393LL, 8031021LL, 8266348LL, 8508570LL,
166 8757890LL, 9014516LL, 9278662LL, 9550547LL,
167 9830400LL, 10118452LL, 10414946LL, 10720127LL, 11034250LL,
168 11357579LL, 11690381LL, 12032935LL, 12385527LL,
169 12748451LL, 13122009LL, 13506513LL, 13902285LL,
170 14309653LL, 14728957LL, 15160549LL, 15604787LL,
171 16062042LL, 16532696LL, 17017141LL, 17515781LL,
172 18029033LL, 18557324LL, 19101095LL,
173 19660800LL, 20236905LL, 20829892LL, 21440254LL, 22068501LL,
174 22715158LL, 23380763LL, 24065871LL, 24771055LL,
175 25496903LL, 26244019LL, 27013027LL, 27804570LL,
176 28619306LL, 29457915LL, 30321098LL, 31209574LL,
177 32124084LL, 33065392LL, 34034282LL, 35031563LL,
178 36058066LL, 37114648LL, 38202190LL,
179 39321600LL, 40473810LL, 41659784LL, 42880508LL, 44137003LL,
180 45430316LL, 46761526LL, 48131743LL, 49542111LL,
181 50993806LL, 52488038LL, 54026055LL, 55609140LL,
182 57238612LL, 58915831LL, 60642197LL, 62419149LL,
183 64248169LL, 66130784LL, 68068564LL, 70063126LL,
184 72116132LL, 74229296LL, 76404380LL,
185 78643200LL, 80947621LL, 83319568LL, 85761017LL, 88274007LL,
186 90860633LL, 93523052LL, 96263487LL, 99084223LL,
187 101987612LL, 104976077LL, 108052111LL, 111218280LL,
188 114477224LL, 117831663LL, 121284394LL, 124838298LL,
189 128496339LL, 132261569LL, 136137129LL, 140126252LL,
190 144232264LL, 148458592LL, 152808761LL,
191 157286400LL, 161895243LL, 166639136LL, 171522035LL, 176548014LL,
192 181721266LL, 187046105LL, 192526975LL, 198168446LL,
193 203975224LL, 209952155LL, 216104222LL, 222436560LL,
194 228954448LL, 235663326LL, 242568788LL, 249676596LL,
195 256992679LL, 264523139LL, 272274259LL, 280252504LL,
196 288464529LL, 296917185LL, 305617523LL,
197 314572800LL, 323790486LL, 333278272LL, 343044070LL, 353096029LL,
198 363442532LL, 374092211LL, 385053950LL, 396336892LL,
199 407950449LL, 419904310LL, 432208445LL, 444873120LL,
200 457908897LL, 471326652LL, 485137577LL, 499353193LL,
201 513985359LL, 529046279LL, 544548518LL, 560505008LL,
202 576929058LL, 593834370LL, 611235046LL,
203 629145600LL, 647580973LL, 666556544LL, 686088141LL,
204 706192058LL, 726885065LL, 748184423LL, 770107900LL,
205 792673784LL, 815900899LL, 839808620LL, 864416891LL,
206 889746240LL, 915817795LL, 942653304LL, 970275155LL,
207 998706387LL, 1027970718LL, 1058092559LL, 1089097037LL,
208 1121010017LL, 1153858117LL, 1187668741LL, 1222470092LL,
209 1258291200LL, 1295161946LL, 1333113088LL, 1372176283LL,
210 1412384117LL, 1453770131LL, 1496368847LL, 1540215801LL,
211 1585347569LL, 1631801799LL, 1679617241LL, 1728833783LL,
212 1779492480LL, 1831635590LL, 1885306609LL, 1940550310LL,
213 1997412774LL, 2055941436LL, 2116185118LL, 2178194075LL,
214 2242020034LL, 2307716235LL, 2375337483LL, 2444940184LL,
215 2516582400LL, 2590323893LL, 2666226176LL, 2744352567LL,
216 2824768235LL, 2907540262LL, 2992737695LL, 3080431603LL,
217 3170695139LL, 3263603598LL, 3359234483LL, 3457667567LL,
218 3558984960LL, 3663271180LL, 3770613219LL, 3881100620LL,
219 3994825549LL, 4111882872LL, 4232370237LL, 4356388151LL,
220 4484040068LL, 4615432471LL, 4750674966LL, 4889880368LL,
221 5033164800LL, 5180647786LL, 5332452353LL, 5488705134LL,
222 5649536470LL, 5815080525LL, 5985475391LL, 6160863207LL,
223 6341390279LL, 6527207197LL, 6718468967LL, 6915335135LL,
224 7117969921LL, 7326542360LL, 7541226438LL, 7762201240LL,
225 7989651098LL, 8223765745LL, 8464740475LL, 8712776303LL,
226 8968080137LL, 9230864943LL, 9501349932LL, 9779760736LL,
227 10066329600LL, 10361295572LL, 10664904706LL, 10977410268LL,
228 11299072941LL, 11630161050LL, 11970950782LL,
229 12321726414LL, 12682780558LL, 13054414395LL,
230 13436937935LL, 13830670270LL, 14235939843LL,
231 14653084721LL, 15082452877LL, 15524402481LL,
232 15979302196LL, 16447531490LL, 16929480950LL,
233 17425552607LL, 17936160274LL, 18461729886LL,
234 19002699864LL, 19559521473LL,
235 20132659200LL, 20722591144LL, 21329809413LL, 21954820536LL,
236 22598145883LL, 23260322101LL, 23941901564LL,
237 24643452829LL, 25365561116LL, 26108828790LL,
238 26873875870LL, 27661340540LL, 28471879687LL,
239 29306169443LL, 30164905755LL, 31048804962LL,
240 31958604392LL, 32895062981LL, 33858961901LL,
241 34851105215LL, 35872320548LL, 36923459773LL,
242 38005399729LL, 39119042946LL,
243 40265318400LL, 41445182288LL,42659618827LL,43909641073LL,
244 45196291767LL, 46520644203LL, 47883803129LL,
245 49286905659LL, 50731122232LL, 52217657581LL,
246 53747751741LL, 55322681081LL, 56943759374LL,
247 58612338887LL, 60329811511LL, 62097609924LL,
248 63917208785LL, 65790125963LL, 67717923803LL,
249 69702210431LL, 71744641096LL, 73846919547LL,
250 76010799459LL, 78238085892LL,
251 80530636800LL, 82890364576LL, 85319237654LL, 87819282146LL,
252 90392583534LL, 93041288407LL, 95767606258LL,
253 98573811319LL, 101462244465LL, 104435315163LL,
254 107495503482LL, 110645362163LL, 113887518749LL,
255 117224677774LL, 120659623022LL, 124195219849LL,
256 127834417571LL, 131580251926LL, 135435847606LL,
257 139404420863LL, 143489282192LL, 147693839094LL,
258 152021598918LL, 156476171785LL,
259 161061273600LL, 165780729153LL, 170638475309LL, 175638564293LL,
260 180785167068LL, 186082576815LL, 191535212516LL,
261 197147622639LL, 202924488931LL, 208870630326LL,
262 214991006964LL, 221290724326LL, 227775037498LL,
263 234449355548LL, 241319246045LL, 248390439699LL,
264 255668835143LL, 263160503853LL, 270871695212LL,
265 278808841726LL, 286978564384LL, 295387678189LL,
266 304043197837LL, 312952343570LL,
267 322122547200LL, 331561458306LL, 341276950619LL, 351277128587LL,
268 361570334136LL, 372165153630LL, 383070425033LL,
269 394295245278LL, 405848977863LL, 417741260653LL,
270 429982013929LL, 442581448653LL, 455550074996LL,
271 468898711096LL, 482638492091LL, 496780879399LL,
272 511337670287LL, 526321007707LL, 541743390425LL,
273 557617683452LL, 573957128769LL, 590775356379LL,
274 608086395675LL, 625904687141LL,
275 644245094400LL, 663122916612LL, 682553901238LL, 702554257174LL,
276 723140668273LL, 744330307261LL, 766140850066LL,
277 788590490556LL, 811697955726LL, 835482521307LL,
278 859964027858LL, 885162897307LL, 911100149992LL,
279 937797422193LL, 965276984182LL, 993561758799LL,
280 1022675340575LL, 1052642015414LL, 1083486780851LL,
281 1115235366904LL, 1147914257538LL, 1181550712759LL,
282 1216172791350LL, 1251809374282LL,
283 1288490188800LL, 1326245833225LL, 1365107802477LL,
284 1405108514349LL, 1446281336546LL, 1488660614523LL,
285 1532281700132LL, 1577180981113LL, 1623395911452LL,
286 1670965042615LL, 1719928055717LL, 1770325794615LL,
287 1822200299985LL, 1875594844387LL, 1930553968365LL,
288 1987123517599LL, 2045350681151LL, 2105284030829LL,
289 2166973561703LL, 2230470733808LL, 2295828515076LL,
290 2363101425518LL, 2432345582701LL, 2503618748564LL,
291 2576980377600LL, 2652491666450LL, 2730215604955LL,
292 2810217028699LL, 2892562673093LL, 2977321229047LL,
293 3064563400264LL, 3154361962227LL, 3246791822904LL,
294 3341930085231LL, 3439856111434LL, 3540651589231LL,
295 3644400599971LL, 3751189688775LL, 3861107936730LL,
296 3974247035198LL, 4090701362303LL, 4210568061659LL,
297 4333947123406LL, 4460941467616LL, 4591657030153LL,
298 4726202851036LL, 4864691165402LL, 5007237497128LL,
299 5153960755200LL, 5304983332900LL, 5460431209910LL,
300 5620434057398LL, 5785125346187LL, 5954642458094LL,
301 6129126800528LL, 6308723924455LL, 6493583645808LL,
302 6683860170462LL, 6879712222869LL, 7081303178462LL,
303 7288801199942LL, 7502379377550LL, 7722215873460LL,
304 7948494070397LL, 8181402724607LL, 8421136123319LL,
305 8667894246812LL, 8921882935232LL, 9183314060306LL,
306 9452405702073LL, 9729382330805LL, 10014474994257LL,
307 10307921510400LL, 10609966665800LL, 10920862419821LL,
308 11240868114797LL, 11570250692375LL, 11909284916188LL,
309 12258253601057LL, 12617447848911LL, 12987167291617LL,
310 13367720340924LL, 13759424445738LL, 14162606356925LL,
311 14577602399885LL, 15004758755101LL, 15444431746921LL,
312 15896988140794LL, 16362805449214LL, 16842272246638LL,
313 17335788493624LL, 17843765870465LL, 18366628120613LL,
314 18904811404146LL, 19458764661611LL, 20028949988515LL,
315 20615843020800LL, 21219933331600LL, 21841724839642LL,
316 22481736229595LL, 23140501384751LL, 23818569832376LL,
317 24516507202114LL, 25234895697822LL, 25974334583234LL,
318 26735440681849LL, 27518848891476LL, 28325212713851LL,
319 29155204799770LL, 30009517510202LL, 30888863493843LL,
320 31793976281588LL, 32725610898429LL, 33684544493277LL,
321 34671576987248LL, 35687531740931LL, 36733256241226LL,
322 37809622808292LL, 38917529323222LL, 40057899977031LL,
323 41231686041600LL, 42439866663201LL, 43683449679284LL,
324 44963472459190LL, 46281002769503LL, 47637139664753LL,
325 49033014404229LL, 50469791395645LL, 51948669166468LL,
326 53470881363698LL, 55037697782953LL, 56650425427703LL,
327 58310409599540LL, 60019035020404LL, 61777726987686LL,
328 63587952563177LL, 65451221796858LL, 67369088986555LL,
329 69343153974496LL, 71375063481862LL, 73466512482452LL,
330 75619245616585LL, 77835058646445LL, 80115799954063LL,
331 82463372083200LL, 84879733326402LL, 87366899358568LL,
332 89926944918381LL, 92562005539006LL, 95274279329506LL,
333 98066028808458LL, 100939582791291LL, 103897338332936LL,
334 106941762727397LL, 110075395565907LL, 113300850855406LL,
335 116620819199080LL, 120038070040809LL, 123555453975373LL,
336 127175905126354LL, 130902443593716LL, 134738177973111LL,
337 138686307948992LL, 142750126963725LL, 146933024964905LL,
338 151238491233171LL, 155670117292890LL, 160231599908126LL,
339 164926744166400LL, 169759466652804LL, 174733798717137LL,
340 179853889836763LL, 185124011078013LL, 190548558659013LL,
341 196132057616916LL, 201879165582582LL, 207794676665873LL,
342 213883525454795LL, 220150791131815LL, 226601701710812LL,
343 233241638398160LL, 240076140081619LL, 247110907950747LL,
344 254351810252708LL, 261804887187433LL, 269476355946222LL,
345 277372615897984LL, 285500253927451LL, 293866049929810LL,
346 302476982466342LL, 311340234585780LL, 320463199816253LL,
347 329853488332800LL, 339518933305609LL, 349467597434275LL,
348 359707779673527LL, 370248022156026LL, 381097117318027LL,
349 392264115233832LL, 403758331165164LL, 415589353331747LL,
350 427767050909590LL, 440301582263631LL, 453203403421624LL,
351 466483276796321LL, 480152280163238LL, 494221815901494LL,
352 508703620505416LL, 523609774374866LL, 538952711892444LL,
353 554745231795968LL, 571000507854903LL, 587732099859621LL,
354 604953964932684LL, 622680469171561LL, 640926399632506LL,
355 659706976665600LL, 679037866611218LL, 698935194868551LL,
356 719415559347055LL, 740496044312053LL, 762194234636054LL,
357 784528230467665LL, 807516662330329LL, 831178706663495LL,
358 855534101819180LL, 880603164527263LL, 906406806843249LL,
359 932966553592642LL, 960304560326477LL, 988443631802988LL,
360 1017407241010832LL, 1047219548749733LL,
361 1077905423784889LL, 1109490463591937LL,
362 1142001015709806LL, 1175464199719243LL,
363 1209907929865369LL, 1245360938343122LL,
365 1319413953331200LL, 1358075733222436LL, 1397870389737103LL,
366 1438831118694110LL, 1480992088624106LL,
367 1524388469272109LL, 1569056460935331LL,
368 1615033324660658LL, 1662357413326990LL,
369 1711068203638361LL, 1761206329054527LL,
370 1812813613686499LL, 1865933107185284LL,
371 1920609120652954LL, 1976887263605976LL};
374 #warning todo add constant keyword
375 __u8
enc_log_64_11(__u32 value
)
378 BUG_ON(log_64_11_table
[255] != 571789581);
379 for (i
=1;i
<256;i
++) {
380 if (log_64_11_table
[i
] > value
)
384 return (__u8
)(i
-1); /* round down */
387 __u32
dec_log_64_11(__u8 value
)
389 BUG_ON(log_64_11_table
[255] != 571789581);
390 return log_64_11_table
[value
];
393 #warning todo table checks (only ascending)
394 __u16
enc_log_300_24(__u64 value
)
397 BUG_ON(log_300_24_table
[1023] != 1976887263605976LL);
398 for (i
=1;i
<1024;i
++) {
399 if (log_300_24_table
[i
] > value
)
403 return (__u16
)(i
-1); /* round down */
406 __u64
dec_log_300_24(__u16 value
)
408 BUG_ON(value
>= 1024);
409 BUG_ON(log_300_24_table
[1023] != 1976887263605976LL);
410 return log_300_24_table
[value
];
413 static inline __u64
mul_saturated(__u64 a
, __u64 b
)
416 if (unlikely(res
/ a
!= b
))
421 static inline int numdigits(__u64 value
)
424 for (;value
!= 0;value
= (value
>> 1)) {
430 /* approximate (a*b) / c without overflowing a*b */
431 __u64
multiply_div(__u64 a
, __u64 b
, __u64 c
)
433 int alen
= numdigits(a
);
434 int blen
= numdigits(b
);
435 int clen
= numdigits(c
);
437 BUG_ON(alen
< 0 || alen
> 64);
438 BUG_ON(blen
< 0 || blen
> 64);
439 BUG_ON(clen
< 0 || clen
> 64);
441 BUG_ON((a
== 0 && alen
!= 0) || (a
!= 0 && alen
== 0));
442 BUG_ON((b
== 0 && blen
!= 0) || (b
!= 0 && blen
== 0));
443 BUG_ON((c
== 0 && clen
!= 0) || (c
!= 0 && clen
== 0));
445 BUG_ON(a
>= b
&& alen
< blen
);
446 BUG_ON(a
>= c
&& alen
< clen
);
447 BUG_ON(b
>= a
&& blen
< alen
);
448 BUG_ON(b
>= c
&& blen
< clen
);
449 BUG_ON(c
>= a
&& clen
< alen
);
450 BUG_ON(c
>= b
&& clen
< blen
);
452 if (alen
== 0 || blen
== 0)
457 if (alen
+ blen
<= 64)
460 if (a
>= b
&& alen
> clen
+ 16)
461 return mul_saturated(a
/c
, b
);
462 else if (a
< b
&& blen
> clen
+ 16)
463 return mul_saturated(b
/c
, a
);
465 while (alen
+ blen
> 64) {
466 if (alen
> blen
|| (alen
== blen
&& a
> b
)) {
480 static inline int hdr_size(void)
482 return ((sizeof(struct cell_hdr
) + sizeof(void *) - 1) / sizeof(void *)
486 static inline int elements_per_cell(int cell_size
)
488 return (cell_size
- hdr_size())/sizeof(void *);
491 static inline struct cell_hdr
*cell_addr(struct htable
*ht
, __u32 id
)
493 int idx
= (id
%ht
->htable_size
) / (elements_per_cell(ht
->cell_size
));
494 return (struct cell_hdr
*) (((char *)ht
->htable
) + ht
->cell_size
* idx
);
497 static inline char **element_addr(struct htable
*ht
, __u32 id
)
499 int idx
= (id
%ht
->htable_size
) % (elements_per_cell(ht
->cell_size
));
501 ( ((char *)cell_addr(ht
, id
)) +
502 hdr_size() + idx
*sizeof(void *) );
506 static inline char **next_element(struct htable
*ht
, char *element
)
508 return (char **)(element
+ ht
->entry_offset
);
511 static inline struct kref
*element_kref(struct htable
*ht
, char *element
)
513 return (struct kref
*)(element
+ ht
->kref_offset
);
517 static inline void unlock_element(struct htable
*ht
, __u32 key
)
519 struct cell_hdr
*hdr
= cell_addr(ht
, key
);
520 spin_unlock( &(hdr
->lock
) );
524 static char **get_element_nounlock(struct htable
*ht
, __u32 key
,
527 struct cell_hdr
*hdr
= cell_addr(ht
, key
);
528 char **element
= element_addr(ht
, key
);
530 BUG_ON(0 == element
);
532 spin_lock( &(hdr
->lock
) );
537 if (searcheditem
!= 0 && ht
->matches(*element
, searcheditem
))
539 element
= next_element(ht
, *element
);
545 char *htable_get(struct htable
*ht
, __u32 key
, void *searcheditem
)
547 unsigned long iflags
;
550 if (unlikely(ht
->htable
== 0))
553 local_irq_save(iflags
);
554 element
= *(get_element_nounlock(ht
, key
, searcheditem
));
555 if (likely(element
!= 0))
556 kref_get(element_kref(ht
, element
));
557 unlock_element(ht
, key
);
558 local_irq_restore(iflags
);
563 int htable_delete(struct htable
*ht
, __u32 key
,
564 void *searcheditem
, void (*free
) (struct kref
*ref
))
566 unsigned long iflags
;
571 if (unlikely(ht
->htable
== 0))
574 local_irq_save(iflags
);
576 element
= get_element_nounlock(ht
, key
, searcheditem
);
577 BUG_ON(0 == element
);
579 if (unlikely(*element
== 0)) {
580 /* key not in table */
585 next
= next_element(ht
, *element
);
586 kref_put(element_kref(ht
, *element
), free
);
590 unlock_element(ht
, key
);
591 local_irq_restore(iflags
);
596 void htable_insert(struct htable
*ht
, char *newelement
, __u32 key
)
598 unsigned long iflags
;
601 if (unlikely(ht
->htable
== 0))
604 BUG_ON(*next_element(ht
, newelement
) != 0);
605 local_irq_save(iflags
);
607 element
= get_element_nounlock(ht
, key
, 0);
609 BUG_ON(element
== 0);
610 BUG_ON(*element
!= 0);
612 *element
= newelement
;
613 kref_get(element_kref(ht
, newelement
));
615 unlock_element(ht
, key
);
616 local_irq_restore(iflags
);
620 void htable_init(struct htable
*ht
, int (*matches
)(void *htentry
,
621 void *searcheditem
), __u32 entry_offset
, __u32 kref_offset
)
628 ht
->htable
= kmalloc(PAGE_SIZE
, GFP_KERNEL
);
629 if (unlikely(ht
->htable
== 0)) {
630 printk(KERN_CRIT
"cor: error allocating htable (out of "
634 memset(ht
->htable
, 0, PAGE_SIZE
);
637 num_cells
= PAGE_SIZE
/ht
->cell_size
;
639 for (j
=0;j
<num_cells
;j
++) {
640 struct cell_hdr
*hdr
= (struct cell_hdr
*)
641 ( ((char *) ht
->htable
) + j
* ht
->cell_size
);
642 spin_lock_init(&(hdr
->lock
));
645 ht
->htable_size
= num_cells
* elements_per_cell(ht
->cell_size
);
646 ht
->num_elements
= 0;
648 ht
->matches
= matches
;
649 ht
->entry_offset
= entry_offset
;
650 ht
->kref_offset
= kref_offset
;
653 struct reverse_connid_matchparam
{
658 static __u32
rcm_to_key(struct reverse_connid_matchparam
*rcm
)
660 return (((__u32
) rcm
->nb
) ^ rcm
->conn_id
);
663 static int matches_reverse_connid(void *htentry
, void *searcheditem
)
665 struct conn
*conn
= (struct conn
*) htentry
;
666 struct reverse_connid_matchparam
*rcm
=
667 (struct reverse_connid_matchparam
*) searcheditem
;
668 BUG_ON(conn
->targettype
!= TARGET_OUT
);
669 return (conn
->target
.out
.nb
== rcm
->nb
) &&
670 (conn
->target
.out
.conn_id
== rcm
->conn_id
);
673 struct conn
*get_conn_reverse(struct neighbor
*nb
, __u32 conn_id
)
675 struct reverse_connid_matchparam rcm
;
677 rcm
.conn_id
= conn_id
;
679 return (struct conn
*) htable_get(&reverse_connid_table
,
680 rcm_to_key(&rcm
), &rcm
);
683 void insert_reverse_connid(struct conn
*rconn
)
685 struct reverse_connid_matchparam rcm
;
687 BUG_ON(rconn
->targettype
!= TARGET_OUT
);
689 rcm
.nb
= rconn
->target
.out
.nb
;
690 rcm
.conn_id
= rconn
->target
.out
.conn_id
;
691 htable_insert(&reverse_connid_table
, (char *) rconn
, rcm_to_key(&rcm
));
694 struct conn
*get_conn(__u32 conn_id
)
696 return (struct conn
*) htable_get(&connid_table
, conn_id
, &conn_id
);
699 static int connid_alloc(struct conn
*sconn
)
704 BUG_ON(sconn
->sourcetype
!= SOURCE_IN
);
706 mutex_lock(&connid_gen
);
711 get_random_bytes((char *) &conn_id
, sizeof(conn_id
));
713 if (unlikely(conn_id
== 0))
716 tmp
= get_conn(conn_id
);
717 if (unlikely(tmp
!= 0)) {
718 kref_put(&(tmp
->ref
), free_conn
);
724 mutex_unlock(&connid_gen
);
729 sconn
->source
.in
.conn_id
= conn_id
;
730 htable_insert(&connid_table
, (char *) sconn
, conn_id
);
731 mutex_unlock(&connid_gen
);
735 void free_conn(struct kref
*ref
)
737 unsigned long iflags
;
738 struct conn
*conn
= container_of(ref
, struct conn
, ref
);
739 struct conn
*reversedir
= 0;
741 BUG_ON(atomic_read(&(conn
->isreset
)) == 0);
743 spin_lock_irqsave(&conn_free
, iflags
);
745 if (conn
->reversedir
!= 0)
746 atomic_set(&(conn
->reversedir
->isreset
), 3);
748 if (atomic_read(&(conn
->isreset
)) != 3)
751 if (conn
->reversedir
!= 0) {
752 conn
->reversedir
->reversedir
= 0;
753 reversedir
= conn
->reversedir
;
754 conn
->reversedir
= 0;
757 if (conn
->sourcetype
== SOURCE_IN
) {
758 kref_put(&(conn
->source
.in
.nb
->ref
), neighbor_free
);
759 conn
->source
.in
.nb
= 0;
762 if (conn
->targettype
== TARGET_OUT
) {
763 kref_put(&(conn
->target
.out
.nb
->ref
), neighbor_free
);
764 conn
->target
.out
.nb
= 0;
767 BUG_ON(conn
->data_buf
.totalsize
!= 0);
768 BUG_ON(conn
->data_buf
.overhead
!= 0);
770 kmem_cache_free(conn_slab
, conn
);
773 spin_unlock_irqrestore(&conn_free
, iflags
);
776 free_conn(&(reversedir
->ref
));
780 * rconn ==> the connection we received the commend from
781 * ==> init rconn->target.out + rconn->reversedir->source.in
783 * rc == 1 ==> connid allocation failed
785 * NOTE: call to this func *must* be protected by rcv_lock
787 int conn_init_out(struct conn
*rconn
, struct neighbor
*nb
)
790 struct conn
*sconn
= rconn
->reversedir
;
792 mutex_lock(&(sconn
->rcv_lock
));
794 BUG_ON(rconn
->targettype
!= TARGET_UNCONNECTED
);
796 BUG_ON(sconn
->sourcetype
!= SOURCE_NONE
);
798 memset(&(rconn
->target
.out
), 0, sizeof(rconn
->target
.out
));
799 memset(&(sconn
->source
.in
), 0, sizeof(sconn
->source
.in
));
801 rconn
->targettype
= TARGET_OUT
;
802 sconn
->sourcetype
= SOURCE_IN
;
804 rconn
->target
.out
.nb
= nb
;
805 sconn
->source
.in
.nb
= nb
;
807 /* neighbor pointer */
808 kref_get(&(nb
->ref
));
809 kref_get(&(nb
->ref
));
811 skb_queue_head_init(&(sconn
->source
.in
.reorder_queue
));
812 atomic_set(&(sconn
->source
.in
.pong_awaiting
), 0);
814 if (unlikely(connid_alloc(sconn
))) {
819 INIT_LIST_HEAD(&(rconn
->target
.out
.retrans_list
));
821 reset_seqno(rconn
, 0);
822 get_random_bytes((char *) &(sconn
->source
.in
.next_seqno
),
823 sizeof(sconn
->source
.in
.next_seqno
));
825 mutex_lock(&(nb
->conn_list_lock
));
826 list_add_tail(&(sconn
->source
.in
.nb_list
), &(nb
->rcv_conn_list
));
827 list_add_tail(&(rconn
->target
.out
.nb_list
), &(nb
->snd_conn_list
));
828 nb
->num_send_conns
++;
829 mutex_unlock(&(nb
->conn_list_lock
));
832 kref_get(&(rconn
->ref
));
833 kref_get(&(sconn
->ref
));
835 atomic_inc(&num_conns
);
838 mutex_unlock(&(sconn
->rcv_lock
));
840 #warning todo initial send credits
845 void conn_init_sock_source(struct conn
*conn
)
848 conn
->sourcetype
= SOURCE_SOCK
;
849 memset(&(conn
->source
.sock
), 0, sizeof(conn
->source
.sock
));
850 init_waitqueue_head(&(conn
->source
.sock
.wait
));
853 void conn_init_sock_target(struct conn
*conn
)
856 conn
->targettype
= TARGET_SOCK
;
857 memset(&(conn
->target
.sock
), 0, sizeof(conn
->target
.sock
));
858 init_waitqueue_head(&(conn
->target
.sock
.wait
));
859 reset_seqno(conn
, 0);
862 struct conn
* alloc_conn(gfp_t allocflags
)
864 struct conn
*rconn
= 0;
865 struct conn
*sconn
= 0;
867 rconn
= kmem_cache_alloc(conn_slab
, allocflags
);
868 if (unlikely(rconn
== 0))
871 sconn
= kmem_cache_alloc(conn_slab
, allocflags
);
872 if (unlikely(sconn
== 0))
875 memset(rconn
, 0, sizeof(struct conn
));
876 memset(sconn
, 0, sizeof(struct conn
));
878 rconn
->reversedir
= sconn
;
879 sconn
->reversedir
= rconn
;
881 kref_init(&(rconn
->ref
));
882 kref_init(&(sconn
->ref
));
884 rconn
->sockstate
= SOCKSTATE_CONN
;
885 sconn
->sockstate
= SOCKSTATE_CONN
;
887 rconn
->sourcetype
= SOURCE_NONE
;
888 sconn
->sourcetype
= SOURCE_NONE
;
889 rconn
->targettype
= TARGET_UNCONNECTED
;
890 sconn
->targettype
= TARGET_UNCONNECTED
;
892 atomic_set(&(rconn
->isreset
), 0);
893 atomic_set(&(sconn
->isreset
), 0);
895 mutex_init(&(rconn
->rcv_lock
));
896 mutex_init(&(sconn
->rcv_lock
));
898 rconn
->jiffies_credit_update
= jiffies
;
899 sconn
->jiffies_credit_update
= rconn
->jiffies_credit_update
;
901 rconn
->crate_forward
= ((1 << 31) - (((__u32
) 1 << 31) / 10));
902 sconn
->crate_forward
= ((1 << 31) - (((__u32
) 1 << 31) / 10));
910 kmem_cache_free(conn_slab
, rconn
);
915 static struct connlistener
*get_connlistener(__be64 port
)
917 struct list_head
*curr
= openports
.next
;
919 while (curr
!= &openports
) {
920 struct bindnode
*currnode
= ((struct bindnode
*)
921 (((char *)curr
) - offsetof(struct bindnode
, lh
)));
922 if (currnode
->port
== port
) {
923 BUG_ON(currnode
->owner
== 0);
924 return currnode
->owner
;
933 void close_port(struct connlistener
*listener
)
935 mutex_lock(&cor_bindnodes
);
937 if (listener
->bn
!= 0) {
938 list_del(&(listener
->bn
->lh
));
939 kmem_cache_free(bindnode_slab
, listener
->bn
);
943 while (list_empty(&(listener
->conn_queue
)) == 0) {
944 struct conn
*rconn
= container_of(listener
->conn_queue
.next
,
945 struct conn
, source
.sock
.cl_list
);
946 list_del(&(rconn
->source
.sock
.cl_list
));
947 atomic_cmpxchg(&(rconn
->reversedir
->isreset
), 0, 1);
949 kref_put(&(rconn
->ref
), free_conn
);
952 kmem_cache_free(connlistener_slab
, listener
);
954 mutex_unlock(&cor_bindnodes
);
957 struct connlistener
*open_port(__be64 port
)
960 struct bindnode
*bn
= 0;
961 struct connlistener
*listener
= 0;
963 mutex_lock(&cor_bindnodes
);
964 if (get_connlistener(port
) != 0)
968 bn
= kmem_cache_alloc(bindnode_slab
, GFP_KERNEL
);
969 listener
= kmem_cache_alloc(connlistener_slab
, GFP_KERNEL
);
971 memset(bn
, 0, sizeof(struct bindnode
));
972 memset(listener
, 0, sizeof(struct connlistener
));
974 bn
->owner
= listener
;
977 /* kref is not actually used */
978 listener
->sockstate
= SOCKSTATE_LISTENER
;
980 mutex_init(&(listener
->lock
));
981 INIT_LIST_HEAD(&(listener
->conn_queue
));
982 init_waitqueue_head(&(listener
->wait
));
984 list_add_tail((struct list_head
*) &(bn
->lh
), &openports
);
987 mutex_unlock(&cor_bindnodes
);
994 * rc == 2 port not open
995 * rc == 3 listener queue full
997 int connect_port(struct conn
*rconn
, __be64 port
)
1000 struct connlistener
*listener
;
1003 mutex_lock(&cor_bindnodes
);
1005 listener
= get_connlistener(port
);
1006 if (listener
== 0) {
1011 mutex_lock(&(listener
->lock
));
1013 if (unlikely(listener
->queue_len
>= listener
->queue_maxlen
)) {
1014 if (listener
->queue_maxlen
<= 0)
1022 kref_get(&(rconn
->reversedir
->ref
));
1024 mutex_lock(&(rconn
->reversedir
->rcv_lock
));
1025 conn_init_sock_target(rconn
);
1026 conn_init_sock_source(rconn
->reversedir
);
1027 mutex_unlock(&(rconn
->reversedir
->rcv_lock
));
1029 list_add_tail(&(rconn
->reversedir
->source
.sock
.cl_list
),
1030 &(listener
->conn_queue
));
1031 listener
->queue_len
++;
1032 wake_up_interruptible(&(listener
->wait
));
1035 mutex_unlock(&(listener
->lock
));
1038 mutex_unlock(&cor_bindnodes
);
1044 * rc == 2 addrtype not found
1045 * rc == 3 addr not found
1046 * rc == 4 ==> connid allocation failed
1047 * rc == 5 ==> control msg alloc failed
1049 int connect_neigh(struct conn
*rconn
,
1050 __u16 addrtypelen
, __u8
*addrtype
,
1051 __u16 addrlen
, __u8
*addr
)
1054 struct control_msg_out
*cm
;
1055 struct neighbor
*nb
= find_neigh(addrtypelen
, addrtype
, addrlen
, addr
);
1059 if (unlikely(conn_init_out(rconn
, nb
))) {
1064 cm
= alloc_control_msg(nb
, ACM_PRIORITY_HIGH
);
1065 if (unlikely(cm
== 0)) {
1070 send_connect_nb(cm
, rconn
->reversedir
->source
.in
.conn_id
,
1071 rconn
->reversedir
->source
.in
.next_seqno
,
1075 kref_put(&(nb
->ref
), neighbor_free
);
1080 void reset_ping(struct conn
*rconn
)
1082 struct neighbor
*nb
= rconn
->source
.in
.nb
;
1083 if (atomic_read(&(rconn
->source
.in
.pong_awaiting
)) != 0) {
1084 mutex_lock(&(nb
->conn_list_lock
));
1085 if (atomic_read(&(rconn
->source
.in
.pong_awaiting
)) == 0)
1088 atomic_set(&(rconn
->source
.in
.pong_awaiting
), 0);
1089 nb
->pong_conns_expected
--;
1091 mutex_unlock(&(nb
->conn_list_lock
));
1095 static int _reset_conn(struct conn
*conn
)
1098 * aktive conns have an additional ref to make sure that they are not
1099 * freed when only one direction is referenced by the connid hashtable
1102 int isreset
= atomic_cmpxchg(&(conn
->isreset
), 0, 2);
1104 isreset
= atomic_cmpxchg(&(conn
->isreset
), 1, 2);
1106 if (isreset
== 2 || isreset
== 3)
1109 /* lock sourcetype/targettype */
1110 mutex_lock(&(conn
->rcv_lock
));
1112 if (conn
->sourcetype
== SOURCE_IN
) {
1113 mutex_lock(&(conn
->source
.in
.nb
->conn_list_lock
));
1114 list_del(&(conn
->source
.in
.nb_list
));
1115 mutex_unlock(&(conn
->source
.in
.nb
->conn_list_lock
));
1119 if (conn
->source
.in
.conn_id
!= 0) {
1120 if (htable_delete(&connid_table
,
1121 conn
->source
.in
.conn_id
,
1122 &(conn
->source
.in
.conn_id
), free_conn
)){
1123 printk(KERN_ERR
"error in _reset_conn: "
1124 "htable_delete src_in failed");
1126 conn
->source
.in
.conn_id
= 0;
1131 atomic_dec(&num_conns
);
1132 BUG_ON(atomic_read(&num_conns
) < 0);
1133 } else if (conn
->sourcetype
== SOURCE_SOCK
) {
1134 wake_up_interruptible(&(conn
->source
.sock
.wait
));
1137 if (conn
->targettype
== TARGET_UNCONNECTED
) {
1138 connreset_cpacket_buffer(conn
);
1139 } else if (conn
->targettype
== TARGET_OUT
) {
1140 mutex_lock(&(conn
->target
.out
.nb
->conn_list_lock
));
1141 list_del(&(conn
->target
.out
.nb_list
));
1142 conn
->target
.out
.nb
->num_send_conns
--;
1143 BUG_ON(conn
->target
.out
.nb
->num_send_conns
< 0);
1144 mutex_unlock(&(conn
->target
.out
.nb
->conn_list_lock
));
1148 if (conn
->target
.out
.conn_id
!= 0) {
1149 struct reverse_connid_matchparam rcm
;
1150 rcm
.nb
= conn
->target
.out
.nb
;
1151 rcm
.conn_id
= conn
->target
.out
.conn_id
;
1152 if (htable_delete(&reverse_connid_table
,
1155 printk(KERN_ERR
"error in _reset_conn: "
1156 "htable_delete target_out "
1161 if (isreset
== 0 && conn
->target
.out
.conn_id
!= 0) {
1162 struct control_msg_out
*cm
= alloc_control_msg(
1163 conn
->target
.out
.nb
, ACM_PRIORITY_HIGH
);
1164 if (unlikely(cm
== 0))
1165 send_ping_all_conns(conn
->target
.out
.nb
);
1167 send_reset_conn(cm
, conn
->target
.out
.conn_id
);
1170 conn
->target
.out
.conn_id
= 0;
1172 cancel_retrans(conn
);
1173 } else if (conn
->targettype
== TARGET_SOCK
) {
1174 wake_up_interruptible(&(conn
->target
.sock
.wait
));
1179 mutex_unlock(&(conn
->rcv_lock
));
1181 qos_remove_conn(conn
);
1182 reset_bufferusage(conn
);
1183 unreserve_sock_buffer(conn
);
1184 connreset_credits(conn
);
1186 mutex_lock(&(conn
->rcv_lock
));
1187 if (conn
->sourcetype
!= SOURCE_SOCK
) {
1188 mutex_unlock(&(conn
->rcv_lock
));
1189 goto skipbufferlimits
;
1191 mutex_unlock(&(conn
->rcv_lock
));
1193 mutex_lock(&sock_bufferlimits_lock
);
1194 mutex_lock(&(conn
->rcv_lock
));
1195 if (conn
->sourcetype
== SOURCE_SOCK
) {
1196 BUG_ON(conn
->source
.sock
.in_alwait_list
);
1197 conn
->source
.sock
.sbt
->usage
-= conn
->source
.sock
.alloclimit
;
1198 if (conn
->source
.sock
.delay_flush
) {
1199 conn
->source
.sock
.delay_flush
= 0;
1200 list_del(&(conn
->source
.sock
.delflush_list
));
1202 kref_put(&(conn
->source
.sock
.sbt
->ref
), free_sbt
);
1203 conn
->source
.sock
.sbt
= 0;
1205 mutex_unlock(&(conn
->rcv_lock
));
1206 mutex_unlock(&sock_bufferlimits_lock
);
1212 /* warning: do not hold the rcv_lock while calling this! */
1213 void reset_conn(struct conn
*conn
)
1215 int put1
= _reset_conn(conn
);
1216 int put2
= _reset_conn(conn
->reversedir
);
1218 /* free_conn may not be called, before both _reset_conn have finished */
1220 kref_put(&(conn
->ref
), free_conn
);
1225 kref_put(&(conn
->reversedir
->ref
), free_conn
);
1230 static int matches_connid_in(void *htentry
, void *searcheditem
)
1232 struct conn
*conn
= (struct conn
*) htentry
;
1233 __u32 conn_id
= *((__u32
*) searcheditem
);
1234 BUG_ON(conn
->sourcetype
!= SOURCE_IN
);
1235 return (conn
->source
.in
.conn_id
== conn_id
);
1238 static int __init
cor_common_init(void)
1244 printk(KERN_ERR
"sizeof conn: %d", sizeof(c
));
1245 printk(KERN_ERR
" conn.source: %d", sizeof(c
.source
));
1246 printk(KERN_ERR
" conn.target: %d", sizeof(c
.target
));
1247 printk(KERN_ERR
" conn.target.out: %d", sizeof(c
.target
.out
));
1248 printk(KERN_ERR
" conn.buf: %d", sizeof(c
.data_buf
));
1250 printk(KERN_ERR
" mutex: %d", sizeof(struct mutex
));
1251 printk(KERN_ERR
" spinlock: %d", sizeof(spinlock_t
));
1252 printk(KERN_ERR
" kref: %d", sizeof(struct kref
));
1254 conn_slab
= kmem_cache_create("cor_conn", sizeof(struct conn
), 8, 0, 0);
1255 htable_init(&connid_table
, matches_connid_in
,
1256 offsetof(struct conn
, source
.in
.htab_entry
),
1257 offsetof(struct conn
, ref
));
1259 htable_init(&reverse_connid_table
, matches_reverse_connid
,
1260 offsetof(struct conn
, target
.out
.htab_entry
),
1261 offsetof(struct conn
, ref
));
1263 bindnode_slab
= kmem_cache_create("cor_bindnode",
1264 sizeof(struct bindnode
), 8, 0, 0);
1265 connlistener_slab
= kmem_cache_create("cor_connlistener",
1266 sizeof(struct connlistener
), 8, 0, 0);
1268 atomic_set(&num_conns
, 0);
1275 rc
= cor_snd_init();
1276 if (unlikely(rc
!= 0))
1279 rc
= cor_neighbor_init();
1280 if (unlikely(rc
!= 0))
1283 rc
= cor_rcv_init();
1284 if (unlikely(rc
!= 0))
1290 module_init(cor_common_init
);
1291 MODULE_LICENSE("GPL");