2 * Connection oriented routing
3 * Copyright (C) 2007-2011 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 __u8
__attribute__((const)) enc_log_64_11(__u32 value
)
377 BUG_ON(log_64_11_table
[255] != 571789581);
378 for (i
=1;i
<256;i
++) {
379 if (log_64_11_table
[i
] > value
)
383 return (__u8
)(i
-1); /* round down */
386 __u32
__attribute__((const)) dec_log_64_11(__u8 value
)
388 BUG_ON(log_64_11_table
[255] != 571789581);
389 return log_64_11_table
[value
];
392 static void check_log_64_11_table(void)
395 BUG_ON(log_64_11_table
[0] != 0);
396 for (i
=1;i
<256;i
++) {
397 BUG_ON(log_64_11_table
[i
] <= log_64_11_table
[i
-1]);
401 __u16
__attribute__((const)) enc_log_300_24(__u64 value
)
404 BUG_ON(log_300_24_table
[1023] != 1976887263605976LL);
405 for (i
=1;i
<1024;i
++) {
406 if (log_300_24_table
[i
] > value
)
410 return (__u16
)(i
-1); /* round down */
413 __u64
__attribute__((const)) dec_log_300_24(__u16 value
)
415 BUG_ON(value
>= 1024);
416 BUG_ON(log_300_24_table
[1023] != 1976887263605976LL);
417 return log_300_24_table
[value
];
420 static void check_log_300_24_table(void)
423 BUG_ON(log_300_24_table
[0] != 0);
424 for (i
=1;i
<1024;i
++) {
425 BUG_ON(log_300_24_table
[i
] <= log_300_24_table
[i
-1]);
429 static inline __u64
mul_saturated(__u64 a
, __u64 b
)
432 if (unlikely(res
/ a
!= b
))
437 static inline int numdigits(__u64 value
)
440 for (;value
!= 0;value
= (value
>> 1)) {
446 /* approximate (a*b) / c without overflowing a*b */
447 __u64
__attribute__((const)) multiply_div(__u64 a
, __u64 b
, __u64 c
)
449 int alen
= numdigits(a
);
450 int blen
= numdigits(b
);
451 int clen
= numdigits(c
);
453 BUG_ON(alen
< 0 || alen
> 64);
454 BUG_ON(blen
< 0 || blen
> 64);
455 BUG_ON(clen
< 0 || clen
> 64);
457 BUG_ON((a
== 0 && alen
!= 0) || (a
!= 0 && alen
== 0));
458 BUG_ON((b
== 0 && blen
!= 0) || (b
!= 0 && blen
== 0));
459 BUG_ON((c
== 0 && clen
!= 0) || (c
!= 0 && clen
== 0));
461 BUG_ON(a
>= b
&& alen
< blen
);
462 BUG_ON(a
>= c
&& alen
< clen
);
463 BUG_ON(b
>= a
&& blen
< alen
);
464 BUG_ON(b
>= c
&& blen
< clen
);
465 BUG_ON(c
>= a
&& clen
< alen
);
466 BUG_ON(c
>= b
&& clen
< blen
);
468 if (alen
== 0 || blen
== 0)
473 if (alen
+ blen
<= 64)
476 if (a
>= b
&& alen
> clen
+ 16)
477 return mul_saturated(a
/c
, b
);
478 else if (a
< b
&& blen
> clen
+ 16)
479 return mul_saturated(b
/c
, a
);
481 while (alen
+ blen
> 64) {
482 if (alen
> blen
|| (alen
== blen
&& a
> b
)) {
496 static inline int hdr_size(void)
498 return ((sizeof(struct cell_hdr
) + sizeof(void *) - 1) / sizeof(void *)
502 static inline int elements_per_cell(int cell_size
)
504 return (cell_size
- hdr_size())/sizeof(void *);
507 static inline struct cell_hdr
*cell_addr(struct htable
*ht
, __u32 id
)
509 int idx
= (id
%ht
->htable_size
) / (elements_per_cell(ht
->cell_size
));
510 return (struct cell_hdr
*) (((char *)ht
->htable
) + ht
->cell_size
* idx
);
513 static inline char **element_addr(struct htable
*ht
, __u32 id
)
515 int idx
= (id
%ht
->htable_size
) % (elements_per_cell(ht
->cell_size
));
517 ( ((char *)cell_addr(ht
, id
)) +
518 hdr_size() + idx
*sizeof(void *));
522 static inline char **next_element(struct htable
*ht
, char *element
)
524 return (char **)(element
+ ht
->entry_offset
);
527 static inline struct kref
*element_kref(struct htable
*ht
, char *element
)
529 return (struct kref
*)(element
+ ht
->kref_offset
);
533 static inline void unlock_element(struct htable
*ht
, __u32 key
)
535 struct cell_hdr
*hdr
= cell_addr(ht
, key
);
536 spin_unlock(&(hdr
->lock
));
540 static char **get_element_nounlock(struct htable
*ht
, __u32 key
,
543 struct cell_hdr
*hdr
= cell_addr(ht
, key
);
544 char **element
= element_addr(ht
, key
);
546 BUG_ON(0 == element
);
548 spin_lock(&(hdr
->lock
));
553 if (searcheditem
!= 0 && ht
->matches(*element
, searcheditem
))
555 element
= next_element(ht
, *element
);
561 char *htable_get(struct htable
*ht
, __u32 key
, void *searcheditem
)
563 unsigned long iflags
;
566 if (unlikely(ht
->htable
== 0))
569 local_irq_save(iflags
);
570 element
= *(get_element_nounlock(ht
, key
, searcheditem
));
571 if (likely(element
!= 0))
572 kref_get(element_kref(ht
, element
));
573 unlock_element(ht
, key
);
574 local_irq_restore(iflags
);
579 int htable_delete(struct htable
*ht
, __u32 key
,
580 void *searcheditem
, void (*free
) (struct kref
*ref
))
582 unsigned long iflags
;
587 if (unlikely(ht
->htable
== 0))
590 local_irq_save(iflags
);
592 element
= get_element_nounlock(ht
, key
, searcheditem
);
593 BUG_ON(0 == element
);
595 if (unlikely(*element
== 0)) {
596 /* key not in table */
601 next
= next_element(ht
, *element
);
602 kref_put(element_kref(ht
, *element
), free
);
606 unlock_element(ht
, key
);
607 local_irq_restore(iflags
);
612 void htable_insert(struct htable
*ht
, char *newelement
, __u32 key
)
614 unsigned long iflags
;
617 if (unlikely(ht
->htable
== 0))
620 BUG_ON(*next_element(ht
, newelement
) != 0);
621 local_irq_save(iflags
);
623 element
= get_element_nounlock(ht
, key
, 0);
625 BUG_ON(element
== 0);
626 BUG_ON(*element
!= 0);
628 *element
= newelement
;
629 kref_get(element_kref(ht
, newelement
));
631 unlock_element(ht
, key
);
632 local_irq_restore(iflags
);
636 void htable_init(struct htable
*ht
, int (*matches
)(void *htentry
,
637 void *searcheditem
), __u32 entry_offset
, __u32 kref_offset
)
644 ht
->htable
= kmalloc(PAGE_SIZE
, GFP_KERNEL
);
645 if (unlikely(ht
->htable
== 0)) {
646 printk(KERN_CRIT
"cor: error allocating htable (out of "
650 memset(ht
->htable
, 0, PAGE_SIZE
);
653 num_cells
= PAGE_SIZE
/ht
->cell_size
;
655 for (j
=0;j
<num_cells
;j
++) {
656 struct cell_hdr
*hdr
= (struct cell_hdr
*)
657 ( ((char *) ht
->htable
) + j
* ht
->cell_size
);
658 spin_lock_init(&(hdr
->lock
));
661 ht
->htable_size
= num_cells
* elements_per_cell(ht
->cell_size
);
662 ht
->num_elements
= 0;
664 ht
->matches
= matches
;
665 ht
->entry_offset
= entry_offset
;
666 ht
->kref_offset
= kref_offset
;
669 struct reverse_connid_matchparam
{
674 static __u32
rcm_to_key(struct reverse_connid_matchparam
*rcm
)
676 return (((__u32
) rcm
->nb
) ^ rcm
->conn_id
);
679 static int matches_reverse_connid(void *htentry
, void *searcheditem
)
681 struct conn
*conn
= (struct conn
*) htentry
;
682 struct reverse_connid_matchparam
*rcm
=
683 (struct reverse_connid_matchparam
*) searcheditem
;
684 BUG_ON(conn
->targettype
!= TARGET_OUT
);
685 return (conn
->target
.out
.nb
== rcm
->nb
) &&
686 (conn
->target
.out
.conn_id
== rcm
->conn_id
);
689 struct conn
*get_conn_reverse(struct neighbor
*nb
, __u32 conn_id
)
691 struct reverse_connid_matchparam rcm
;
693 rcm
.conn_id
= conn_id
;
695 return (struct conn
*) htable_get(&reverse_connid_table
,
696 rcm_to_key(&rcm
), &rcm
);
699 void insert_reverse_connid(struct conn
*trgt_out_ll
)
701 struct reverse_connid_matchparam rcm
;
703 BUG_ON(trgt_out_ll
->targettype
!= TARGET_OUT
);
705 rcm
.nb
= trgt_out_ll
->target
.out
.nb
;
706 rcm
.conn_id
= trgt_out_ll
->target
.out
.conn_id
;
707 htable_insert(&reverse_connid_table
, (char *) trgt_out_ll
,
711 struct conn
*get_conn(__u32 conn_id
)
713 return (struct conn
*) htable_get(&connid_table
, conn_id
, &conn_id
);
716 void _set_last_act(struct conn
*src_in_l
)
718 unsigned long iflags
;
719 spin_lock_irqsave(&(src_in_l
->source
.in
.nb
->conn_list_lock
), iflags
);
720 list_del(&(src_in_l
->source
.in
.nb_list
));
721 list_add_tail(&(src_in_l
->source
.in
.nb_list
),
722 &(src_in_l
->source
.in
.nb
->rcv_conn_list
));
723 spin_unlock_irqrestore(&(src_in_l
->source
.in
.nb
->conn_list_lock
),
727 #warning todo connid reuse protection
728 static int connid_alloc(struct conn
*src_in_ll
)
733 BUG_ON(src_in_ll
->sourcetype
!= SOURCE_IN
);
735 mutex_lock(&connid_gen
);
740 get_random_bytes((char *) &conn_id
, sizeof(conn_id
));
742 if (unlikely(conn_id
== 0))
745 tmp
= get_conn(conn_id
);
746 if (unlikely(tmp
!= 0)) {
747 kref_put(&(tmp
->ref
), free_conn
);
753 mutex_unlock(&connid_gen
);
758 src_in_ll
->source
.in
.conn_id
= conn_id
;
759 htable_insert(&connid_table
, (char *) src_in_ll
, conn_id
);
760 mutex_unlock(&connid_gen
);
764 void free_conn(struct kref
*ref
)
766 unsigned long iflags
;
767 struct conn
*cn
= container_of(ref
, struct conn
, ref
);
768 struct conn
*reversedir
= 0;
770 BUG_ON(atomic_read(&(cn
->isreset
)) == 0);
772 spin_lock_irqsave(&conn_free
, iflags
);
774 if (cn
->reversedir
!= 0)
775 atomic_set(&(cn
->reversedir
->isreset
), 3);
777 if (atomic_read(&(cn
->isreset
)) != 3)
780 if (cn
->reversedir
!= 0) {
781 cn
->reversedir
->reversedir
= 0;
782 reversedir
= cn
->reversedir
;
786 if (cn
->sourcetype
== SOURCE_IN
) {
787 kref_put(&(cn
->source
.in
.nb
->ref
), neighbor_free
);
788 cn
->source
.in
.nb
= 0;
791 if (cn
->targettype
== TARGET_OUT
) {
792 kref_put(&(cn
->target
.out
.nb
->ref
), neighbor_free
);
793 cn
->target
.out
.nb
= 0;
796 BUG_ON(cn
->data_buf
.totalsize
!= 0);
797 BUG_ON(cn
->data_buf
.overhead
!= 0);
799 kmem_cache_free(conn_slab
, cn
);
802 spin_unlock_irqrestore(&conn_free
, iflags
);
805 free_conn(&(reversedir
->ref
));
810 * rc == 1 ==> connid allocation failed
812 int conn_init_out(struct conn
*trgt_unconn_ll
, struct neighbor
*nb
)
814 unsigned long iflags
;
816 struct conn
*src_none_ll
= trgt_unconn_ll
->reversedir
;
818 BUG_ON(trgt_unconn_ll
->targettype
!= TARGET_UNCONNECTED
);
819 BUG_ON(src_none_ll
== 0);
820 BUG_ON(src_none_ll
->sourcetype
!= SOURCE_NONE
);
822 memset(&(trgt_unconn_ll
->target
.out
), 0,
823 sizeof(trgt_unconn_ll
->target
.out
));
824 memset(&(src_none_ll
->source
.in
), 0, sizeof(src_none_ll
->source
.in
));
826 trgt_unconn_ll
->targettype
= TARGET_OUT
;
827 src_none_ll
->sourcetype
= SOURCE_IN
;
829 trgt_unconn_ll
->target
.out
.nb
= nb
;
830 src_none_ll
->source
.in
.nb
= nb
;
832 /* neighbor pointer */
833 kref_get(&(nb
->ref
));
834 kref_get(&(nb
->ref
));
836 skb_queue_head_init(&(src_none_ll
->source
.in
.reorder_queue
));
838 INIT_LIST_HEAD(&(src_none_ll
->source
.in
.acks_pending
));
840 if (unlikely(connid_alloc(src_none_ll
))) {
845 INIT_LIST_HEAD(&(trgt_unconn_ll
->target
.out
.retrans_list
));
847 reset_seqno(trgt_unconn_ll
, 0);
848 get_random_bytes((char *) &(src_none_ll
->source
.in
.next_seqno
),
849 sizeof(src_none_ll
->source
.in
.next_seqno
));
851 get_random_bytes((char *) &(trgt_unconn_ll
->target
.out
.decaytime_seqno
),
853 trgt_unconn_ll
->target
.out
.decaytime_seqno
=
854 trgt_unconn_ll
->target
.out
.decaytime_seqno
% 64;
855 trgt_unconn_ll
->source
.in
.decaytime_seqno
= 255;
857 src_none_ll
->source
.in
.jiffies_last_act
= jiffies
;
859 spin_lock_irqsave(&(nb
->conn_list_lock
), iflags
);
860 list_add_tail(&(src_none_ll
->source
.in
.nb_list
), &(nb
->rcv_conn_list
));
861 spin_unlock_irqrestore(&(nb
->conn_list_lock
), iflags
);
864 kref_get(&(src_none_ll
->ref
));
866 atomic_inc(&num_conns
);
869 refresh_conn_credits(trgt_unconn_ll
, 0, 1);
875 void conn_init_sock_source(struct conn
*cn
)
878 cn
->sourcetype
= SOURCE_SOCK
;
879 memset(&(cn
->source
.sock
), 0, sizeof(cn
->source
.sock
));
880 init_waitqueue_head(&(cn
->source
.sock
.wait
));
883 void conn_init_sock_target(struct conn
*cn
)
886 cn
->targettype
= TARGET_SOCK
;
887 memset(&(cn
->target
.sock
), 0, sizeof(cn
->target
.sock
));
888 init_waitqueue_head(&(cn
->target
.sock
.wait
));
892 struct conn
* alloc_conn(gfp_t allocflags
)
894 struct conn
*cn1
= 0;
895 struct conn
*cn2
= 0;
897 cn1
= kmem_cache_alloc(conn_slab
, allocflags
);
898 if (unlikely(cn1
== 0))
901 cn2
= kmem_cache_alloc(conn_slab
, allocflags
);
902 if (unlikely(cn2
== 0))
905 memset(cn1
, 0, sizeof(struct conn
));
906 memset(cn2
, 0, sizeof(struct conn
));
908 cn1
->reversedir
= cn2
;
909 cn2
->reversedir
= cn1
;
911 kref_init(&(cn1
->ref
));
912 kref_init(&(cn2
->ref
));
914 cn1
->sockstate
= SOCKSTATE_CONN
;
915 cn2
->sockstate
= SOCKSTATE_CONN
;
917 cn1
->sourcetype
= SOURCE_NONE
;
918 cn2
->sourcetype
= SOURCE_NONE
;
919 cn1
->targettype
= TARGET_UNCONNECTED
;
920 cn2
->targettype
= TARGET_UNCONNECTED
;
922 atomic_set(&(cn1
->isreset
), 0);
923 atomic_set(&(cn2
->isreset
), 0);
925 mutex_init(&(cn1
->rcv_lock
));
926 mutex_init(&(cn2
->rcv_lock
));
928 cn1
->jiffies_credit_update
= jiffies
;
929 cn2
->jiffies_credit_update
= cn1
->jiffies_credit_update
;
931 cn1
->crate_forward
= ((1 << 31) - (((__u32
) 1 << 31) / 10));
932 cn2
->crate_forward
= ((1 << 31) - (((__u32
) 1 << 31) / 10));
940 kmem_cache_free(conn_slab
, cn1
);
945 static struct connlistener
*get_connlistener(__be64 port
)
947 struct list_head
*curr
= openports
.next
;
949 while (curr
!= &openports
) {
950 struct bindnode
*currnode
= ((struct bindnode
*)
951 (((char *)curr
) - offsetof(struct bindnode
, lh
)));
952 if (currnode
->port
== port
) {
953 BUG_ON(currnode
->owner
== 0);
954 return currnode
->owner
;
963 void close_port(struct connlistener
*listener
)
965 mutex_lock(&cor_bindnodes
);
967 if (listener
->bn
!= 0) {
968 list_del(&(listener
->bn
->lh
));
969 kmem_cache_free(bindnode_slab
, listener
->bn
);
973 while (list_empty(&(listener
->conn_queue
)) == 0) {
974 struct conn
*src_sock_o
= container_of(
975 listener
->conn_queue
.next
,
976 struct conn
, source
.sock
.cl_list
);
977 list_del(&(src_sock_o
->source
.sock
.cl_list
));
978 atomic_cmpxchg(&(src_sock_o
->reversedir
->isreset
), 0, 1);
979 reset_conn(src_sock_o
);
980 kref_put(&(src_sock_o
->ref
), free_conn
);
983 kmem_cache_free(connlistener_slab
, listener
);
985 mutex_unlock(&cor_bindnodes
);
988 struct connlistener
*open_port(__be64 port
)
991 struct bindnode
*bn
= 0;
992 struct connlistener
*listener
= 0;
994 mutex_lock(&cor_bindnodes
);
995 if (get_connlistener(port
) != 0)
999 bn
= kmem_cache_alloc(bindnode_slab
, GFP_KERNEL
);
1000 listener
= kmem_cache_alloc(connlistener_slab
, GFP_KERNEL
);
1002 memset(bn
, 0, sizeof(struct bindnode
));
1003 memset(listener
, 0, sizeof(struct connlistener
));
1005 bn
->owner
= listener
;
1008 /* kref is not actually used */
1009 listener
->sockstate
= SOCKSTATE_LISTENER
;
1011 mutex_init(&(listener
->lock
));
1012 INIT_LIST_HEAD(&(listener
->conn_queue
));
1013 init_waitqueue_head(&(listener
->wait
));
1015 list_add_tail((struct list_head
*) &(bn
->lh
), &openports
);
1018 mutex_unlock(&cor_bindnodes
);
1025 * rc == 2 port not open
1026 * rc == 3 listener queue full
1028 int connect_port(struct conn
*trtg_unconn_l
, __be64 port
)
1031 struct connlistener
*listener
;
1034 mutex_lock(&cor_bindnodes
);
1036 listener
= get_connlistener(port
);
1037 if (listener
== 0) {
1042 mutex_lock(&(listener
->lock
));
1044 if (unlikely(listener
->queue_len
>= listener
->queue_maxlen
)) {
1045 if (listener
->queue_maxlen
<= 0)
1053 kref_get(&(trtg_unconn_l
->reversedir
->ref
));
1055 BUG_ON(trtg_unconn_l
->is_client
!= 1);
1056 mutex_lock(&(trtg_unconn_l
->reversedir
->rcv_lock
));
1057 conn_init_sock_target(trtg_unconn_l
);
1058 conn_init_sock_source(trtg_unconn_l
->reversedir
);
1059 mutex_unlock(&(trtg_unconn_l
->reversedir
->rcv_lock
));
1061 list_add_tail(&(trtg_unconn_l
->reversedir
->source
.sock
.cl_list
),
1062 &(listener
->conn_queue
));
1063 listener
->queue_len
++;
1064 wake_up_interruptible(&(listener
->wait
));
1067 mutex_unlock(&(listener
->lock
));
1070 mutex_unlock(&cor_bindnodes
);
1076 * rc == 2 addrtype not found
1077 * rc == 3 addr not found
1078 * rc == 4 ==> connid allocation failed
1079 * rc == 5 ==> control msg alloc failed
1081 int connect_neigh(struct conn
*trtg_unconn_l
,
1082 __u16 addrtypelen
, __u8
*addrtype
,
1083 __u16 addrlen
, __u8
*addr
)
1087 struct control_msg_out
*cm
;
1088 struct neighbor
*nb
= find_neigh(addrtypelen
, addrtype
, addrlen
, addr
);
1093 mutex_lock(&(trtg_unconn_l
->reversedir
->rcv_lock
));
1094 ciorc
= conn_init_out(trtg_unconn_l
, nb
);
1095 mutex_unlock(&(trtg_unconn_l
->reversedir
->rcv_lock
));
1096 if (unlikely(ciorc
)) {
1101 cm
= alloc_control_msg(nb
, ACM_PRIORITY_HIGH
);
1102 if (unlikely(cm
== 0)) {
1107 send_connect_nb(cm
, trtg_unconn_l
->reversedir
->source
.in
.conn_id
,
1108 trtg_unconn_l
->reversedir
->source
.in
.next_seqno
,
1109 trtg_unconn_l
->reversedir
);
1112 kref_put(&(nb
->ref
), neighbor_free
);
1117 static int _reset_conn(struct conn
*cn
)
1120 * active conns have an additional ref to make sure that they are not
1121 * freed when only one direction is referenced by the connid hashtable
1124 int isreset
= atomic_cmpxchg(&(cn
->isreset
), 0, 2);
1126 isreset
= atomic_cmpxchg(&(cn
->isreset
), 1, 2);
1128 if (isreset
== 2 || isreset
== 3)
1131 /* lock sourcetype/targettype */
1132 mutex_lock(&(cn
->rcv_lock
));
1134 if (cn
->sourcetype
== SOURCE_IN
) {
1135 unsigned long iflags
;
1137 spin_lock_irqsave(&(cn
->source
.in
.nb
->conn_list_lock
), iflags
);
1138 list_del(&(cn
->source
.in
.nb_list
));
1139 spin_unlock_irqrestore(&(cn
->source
.in
.nb
->conn_list_lock
),
1142 set_busy_till(cn
->source
.in
.nb
, 0);
1146 if (cn
->source
.in
.conn_id
!= 0) {
1147 if (htable_delete(&connid_table
,
1148 cn
->source
.in
.conn_id
,
1149 &(cn
->source
.in
.conn_id
), free_conn
)){
1150 printk(KERN_ERR
"error in _reset_conn: "
1151 "htable_delete src_in failed");
1153 cn
->source
.in
.conn_id
= 0;
1156 atomic_dec(&num_conns
);
1157 BUG_ON(atomic_read(&num_conns
) < 0);
1158 } else if (cn
->sourcetype
== SOURCE_SOCK
) {
1159 wake_up_interruptible(&(cn
->source
.sock
.wait
));
1162 if (cn
->targettype
== TARGET_UNCONNECTED
) {
1163 connreset_cpacket_buffer(cn
);
1164 } else if (cn
->targettype
== TARGET_OUT
) {
1165 if (isreset
== 0 && cn
->target
.out
.conn_id
!= 0) {
1166 send_reset_conn(cn
->target
.out
.nb
,
1167 cn
->target
.out
.conn_id
,
1168 cn
->reversedir
->source
.in
.conn_id
, 0);
1171 if (cn
->target
.out
.conn_id
!= 0) {
1172 struct reverse_connid_matchparam rcm
;
1173 rcm
.nb
= cn
->target
.out
.nb
;
1174 rcm
.conn_id
= cn
->target
.out
.conn_id
;
1175 if (htable_delete(&reverse_connid_table
,
1178 printk(KERN_ERR
"error in _reset_conn: "
1179 "htable_delete target_out "
1184 cn
->target
.out
.conn_id
= 0;
1187 } else if (cn
->targettype
== TARGET_SOCK
) {
1188 wake_up_interruptible(&(cn
->target
.sock
.wait
));
1193 mutex_unlock(&(cn
->rcv_lock
));
1195 qos_remove_conn(cn
);
1196 reset_bufferusage(cn
);
1197 connreset_credits(cn
);
1199 mutex_lock(&(cn
->rcv_lock
));
1200 if (cn
->sourcetype
!= SOURCE_SOCK
) {
1201 mutex_unlock(&(cn
->rcv_lock
));
1202 goto skipbufferlimits
;
1204 mutex_unlock(&(cn
->rcv_lock
));
1212 /* warning: do not hold the rcv_lock while calling this! */
1213 void reset_conn(struct conn
*cn
)
1215 int put1
= _reset_conn(cn
);
1216 int put2
= _reset_conn(cn
->reversedir
);
1218 /* free_conn may not be called, before both _reset_conn have finished */
1220 kref_put(&(cn
->ref
), free_conn
);
1225 kref_put(&(cn
->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 check_log_64_11_table();
1245 check_log_300_24_table();
1247 printk(KERN_ERR
"sizeof conn: %d", sizeof(c
));
1248 printk(KERN_ERR
" conn.source: %d", sizeof(c
.source
));
1249 printk(KERN_ERR
" conn.target: %d", sizeof(c
.target
));
1250 printk(KERN_ERR
" conn.target.out: %d", sizeof(c
.target
.out
));
1251 printk(KERN_ERR
" conn.buf: %d", sizeof(c
.data_buf
));
1253 printk(KERN_ERR
" mutex: %d", sizeof(struct mutex
));
1254 printk(KERN_ERR
" spinlock: %d", sizeof(spinlock_t
));
1255 printk(KERN_ERR
" kref: %d", sizeof(struct kref
));
1257 conn_slab
= kmem_cache_create("cor_conn", sizeof(struct conn
), 8, 0, 0);
1258 htable_init(&connid_table
, matches_connid_in
,
1259 offsetof(struct conn
, source
.in
.htab_entry
),
1260 offsetof(struct conn
, ref
));
1262 htable_init(&reverse_connid_table
, matches_reverse_connid
,
1263 offsetof(struct conn
, target
.out
.htab_entry
),
1264 offsetof(struct conn
, ref
));
1266 bindnode_slab
= kmem_cache_create("cor_bindnode",
1267 sizeof(struct bindnode
), 8, 0, 0);
1268 connlistener_slab
= kmem_cache_create("cor_connlistener",
1269 sizeof(struct connlistener
), 8, 0, 0);
1271 atomic_set(&num_conns
, 0);
1278 rc
= cor_snd_init();
1279 if (unlikely(rc
!= 0))
1282 rc
= cor_neighbor_init();
1283 if (unlikely(rc
!= 0))
1286 rc
= cor_rcv_init();
1287 if (unlikely(rc
!= 0))
1293 module_init(cor_common_init
);
1294 MODULE_LICENSE("GPL");