Revision: linuxbios@linuxbios.org--devel/freebios--devel--2.0--patch-51
[coreboot.git] / src / northbridge / amd / amdk8 / incoherent_ht.c
1 /*
2         This should be done by Eric
3         2004.12 yhlu add multi ht chain dynamically support
4 */
5 #include <device/pci_def.h>
6 #include <device/pci_ids.h>
7 #include <device/hypertransport_def.h>
8
9 #ifndef K8_HT_FREQ_1G_SUPPORT
10         #define K8_HT_FREQ_1G_SUPPORT 0
11 #endif
12
13 static inline void print_linkn_in (const char *strval, uint8_t byteval)
14 {
15 #if 1
16 #if CONFIG_USE_INIT
17         printk_debug("%s%02x\r\n", strval, byteval); 
18 #else
19         print_debug(strval); print_debug_hex8(byteval); print_debug("\r\n");
20 #endif
21 #endif
22 }
23
24 static uint8_t ht_lookup_slave_capability(device_t dev)
25 {
26         uint8_t pos;
27         uint8_t hdr_type;
28
29         hdr_type = pci_read_config8(dev, PCI_HEADER_TYPE);
30         pos = 0;
31         hdr_type &= 0x7f;
32
33         if ((hdr_type == PCI_HEADER_TYPE_NORMAL) ||
34             (hdr_type == PCI_HEADER_TYPE_BRIDGE)) {
35                 pos = PCI_CAPABILITY_LIST;
36         }
37         if (pos > PCI_CAP_LIST_NEXT) {
38                 pos = pci_read_config8(dev, pos);
39         }
40         while(pos != 0) { /* loop through the linked list */
41                 uint8_t cap;
42                 cap = pci_read_config8(dev, pos + PCI_CAP_LIST_ID);
43                 if (cap == PCI_CAP_ID_HT) {
44                         uint16_t flags;
45
46                         flags = pci_read_config16(dev, pos + PCI_CAP_FLAGS);
47                         if ((flags >> 13) == 0) {
48                                 /* Entry is a Slave secondary, success... */
49                                 break;
50                         }
51                 }
52                 pos = pci_read_config8(dev, pos + PCI_CAP_LIST_NEXT);
53         }
54         return pos;
55 }
56
57 static void ht_collapse_previous_enumeration(uint8_t bus)
58 {
59         device_t dev;
60         uint32_t id;
61
62         /* Check if is already collapsed */
63         dev = PCI_DEV(bus, 0, 0);
64         id = pci_read_config32(dev, PCI_VENDOR_ID);
65         if ( ! ( (id == 0xffffffff) || (id == 0x00000000) ||
66             (id == 0x0000ffff) || (id == 0xffff0000) ) ) {
67                      return;
68         }
69
70         /* Spin through the devices and collapse any previous
71          * hypertransport enumeration.
72          */
73         for(dev = PCI_DEV(bus, 1, 0); dev <= PCI_DEV(bus, 0x1f, 0x7); dev += PCI_DEV(0, 1, 0)) {
74                 uint32_t id;
75                 uint8_t pos;
76                 uint16_t flags;
77                 
78                 id = pci_read_config32(dev, PCI_VENDOR_ID);
79                 if ((id == 0xffffffff) || (id == 0x00000000) ||
80                     (id == 0x0000ffff) || (id == 0xffff0000)) {
81                         continue;
82                 }
83 #if 0
84 #if CK804_DEVN_BASE==0 
85                 //CK804 workaround: 
86                 // CK804 UnitID changes not use
87                 if(id == 0x005e10de) {
88                         break;
89                 }
90 #endif
91 #endif
92                 
93                 pos = ht_lookup_slave_capability(dev);
94                 if (!pos) {
95                         continue;
96                 }
97
98                 /* Clear the unitid */
99                 flags = pci_read_config16(dev, pos + PCI_CAP_FLAGS);
100                 flags &= ~0x1f;
101                 pci_write_config16(dev, pos + PCI_CAP_FLAGS, flags);
102         }
103 }
104
105 static uint16_t ht_read_freq_cap(device_t dev, uint8_t pos)
106 {
107         /* Handle bugs in valid hypertransport frequency reporting */
108         uint16_t freq_cap;
109         uint32_t id;
110
111         freq_cap = pci_read_config16(dev, pos);
112         freq_cap &= ~(1 << HT_FREQ_VENDOR); /* Ignore Vendor HT frequencies */
113
114         id = pci_read_config32(dev, 0);
115
116         /* AMD 8131 Errata 48 */
117         if (id == (PCI_VENDOR_ID_AMD | (PCI_DEVICE_ID_AMD_8131_PCIX << 16))) {
118                 freq_cap &= ~(1 << HT_FREQ_800Mhz);
119                 return freq_cap;
120         } 
121
122         /* AMD 8151 Errata 23 */
123         if (id == (PCI_VENDOR_ID_AMD | (PCI_DEVICE_ID_AMD_8151_SYSCTRL << 16))) {
124                 freq_cap &= ~(1 << HT_FREQ_800Mhz);
125                 return freq_cap;
126         } 
127         
128         /* AMD K8 Unsupported 1Ghz? */
129         if (id == (PCI_VENDOR_ID_AMD | (0x1100 << 16))) {
130         #if K8_HT_FREQ_1G_SUPPORT == 1  
131                 if (is_cpu_pre_e0())  // CK804 support 1G?
132         #endif  
133                         freq_cap &= ~(1 << HT_FREQ_1000Mhz);
134         }
135
136         return freq_cap;
137 }
138
139 #define LINK_OFFS(WIDTH,FREQ,FREQ_CAP)                                  \
140         (((WIDTH & 0xff) << 16) | ((FREQ & 0xff) << 8) | (FREQ_CAP & 0xFF))
141
142 #define LINK_WIDTH(OFFS)    ((OFFS >> 16) & 0xFF)
143 #define LINK_FREQ(OFFS)     ((OFFS >> 8) & 0xFF)
144 #define LINK_FREQ_CAP(OFFS) ((OFFS) & 0xFF)
145
146 #define PCI_HT_HOST_OFFS LINK_OFFS(             \
147                 PCI_HT_CAP_HOST_WIDTH,          \
148                 PCI_HT_CAP_HOST_FREQ,           \
149                 PCI_HT_CAP_HOST_FREQ_CAP)
150
151 #define PCI_HT_SLAVE0_OFFS LINK_OFFS(           \
152                 PCI_HT_CAP_SLAVE_WIDTH0,        \
153                 PCI_HT_CAP_SLAVE_FREQ0,         \
154                 PCI_HT_CAP_SLAVE_FREQ_CAP0)
155
156 #define PCI_HT_SLAVE1_OFFS LINK_OFFS(           \
157                 PCI_HT_CAP_SLAVE_WIDTH1,        \
158                 PCI_HT_CAP_SLAVE_FREQ1,         \
159                 PCI_HT_CAP_SLAVE_FREQ_CAP1)
160
161 static int ht_optimize_link(
162         device_t dev1, uint8_t pos1, unsigned offs1,
163         device_t dev2, uint8_t pos2, unsigned offs2)
164 {
165         static const uint8_t link_width_to_pow2[]= { 3, 4, 0, 5, 1, 2, 0, 0 };
166         static const uint8_t pow2_to_link_width[] = { 0x7, 4, 5, 0, 1, 3 };
167         uint16_t freq_cap1, freq_cap2, freq_cap, freq_mask;
168         uint8_t width_cap1, width_cap2, width_cap, width, old_width, ln_width1, ln_width2;
169         uint8_t freq, old_freq;
170         int needs_reset;
171         /* Set link width and frequency */
172
173         /* Initially assume everything is already optimized and I don't need a reset */
174         needs_reset = 0;
175
176         /* Get the frequency capabilities */
177         freq_cap1 = ht_read_freq_cap(dev1, pos1 + LINK_FREQ_CAP(offs1));
178         freq_cap2 = ht_read_freq_cap(dev2, pos2 + LINK_FREQ_CAP(offs2));
179
180         /* Calculate the highest possible frequency */
181         freq = log2(freq_cap1 & freq_cap2);
182
183         /* See if I am changing the link freqency */
184         old_freq = pci_read_config8(dev1, pos1 + LINK_FREQ(offs1));
185         needs_reset |= old_freq != freq;
186         old_freq = pci_read_config8(dev2, pos2 + LINK_FREQ(offs2));
187         needs_reset |= old_freq != freq;
188
189         /* Set the Calulcated link frequency */
190         pci_write_config8(dev1, pos1 + LINK_FREQ(offs1), freq);
191         pci_write_config8(dev2, pos2 + LINK_FREQ(offs2), freq);
192
193         /* Get the width capabilities */
194         width_cap1 = pci_read_config8(dev1, pos1 + LINK_WIDTH(offs1));
195         width_cap2 = pci_read_config8(dev2, pos2 + LINK_WIDTH(offs2));
196
197         /* Calculate dev1's input width */
198         ln_width1 = link_width_to_pow2[width_cap1 & 7];
199         ln_width2 = link_width_to_pow2[(width_cap2 >> 4) & 7];
200         if (ln_width1 > ln_width2) {
201                 ln_width1 = ln_width2;
202         }
203         width = pow2_to_link_width[ln_width1];
204         /* Calculate dev1's output width */
205         ln_width1 = link_width_to_pow2[(width_cap1 >> 4) & 7];
206         ln_width2 = link_width_to_pow2[width_cap2 & 7];
207         if (ln_width1 > ln_width2) {
208                 ln_width1 = ln_width2;
209         }
210         width |= pow2_to_link_width[ln_width1] << 4;
211
212         /* See if I am changing dev1's width */
213         old_width = pci_read_config8(dev1, pos1 + LINK_WIDTH(offs1) + 1);
214         needs_reset |= old_width != width;
215
216         /* Set dev1's widths */
217         pci_write_config8(dev1, pos1 + LINK_WIDTH(offs1) + 1, width);
218
219         /* Calculate dev2's width */
220         width = ((width & 0x70) >> 4) | ((width & 0x7) << 4);
221
222         /* See if I am changing dev2's width */
223         old_width = pci_read_config8(dev2, pos2 + LINK_WIDTH(offs2) + 1);
224         needs_reset |= old_width != width;
225
226         /* Set dev2's widths */
227         pci_write_config8(dev2, pos2 + LINK_WIDTH(offs2) + 1, width);
228
229         return needs_reset;
230 }
231 static int ht_setup_chain(device_t udev, uint8_t upos)
232 {
233         /* Assumption the HT chain that is bus 0 has the HT I/O Hub on it.
234          * On most boards this just happens.  If a cpu has multiple
235          * non Coherent links the appropriate bus registers for the
236          * links needs to be programed to point at bus 0.
237          */
238         uint8_t next_unitid, last_unitid;
239         int reset_needed;
240         unsigned uoffs;
241
242         /* Make certain the HT bus is not enumerated */
243         ht_collapse_previous_enumeration(0);
244
245         reset_needed = 0;
246         uoffs = PCI_HT_HOST_OFFS;
247         next_unitid = 1;
248         do {
249                 uint32_t id;
250                 uint8_t pos;
251                 uint16_t flags;
252                 uint8_t count;
253                 unsigned offs;
254
255                 device_t dev = PCI_DEV(0, 0, 0);
256                 last_unitid = next_unitid;
257
258                 id = pci_read_config32(dev, PCI_VENDOR_ID);
259                 /* If the chain is enumerated quit */
260                 if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) ||
261                     (((id >> 16) & 0xffff) == 0xffff) ||
262                     (((id >> 16) & 0xffff) == 0x0000)) {
263                         break;
264                 }
265
266                 pos = ht_lookup_slave_capability(dev);
267                 if (!pos) {
268                         print_err("HT link capability not found\r\n");
269                         break;
270                 }
271 #if CK804_DEVN_BASE==0 
272                 //CK804 workaround: 
273                 // CK804 UnitID changes not use
274                 id = pci_read_config32(dev, PCI_VENDOR_ID);
275                 if(id != 0x005e10de) {
276 #endif
277
278                 /* Update the Unitid of the current device */
279                 flags = pci_read_config16(dev, pos + PCI_CAP_FLAGS);
280                 flags &= ~0x1f; /* mask out the bse Unit ID */
281                 flags |= next_unitid & 0x1f;
282                 pci_write_config16(dev, pos + PCI_CAP_FLAGS, flags);
283
284                 dev = PCI_DEV(0, next_unitid, 0);
285 #if CK804_DEVN_BASE==0  
286                 }
287                 else {
288                         dev = PCI_DEV(0, 0, 0);
289                 }
290 #endif
291
292                 /* Compute the number of unitids consumed */
293                 count = (flags >> 5) & 0x1f;
294                 next_unitid += count;
295
296                 /* get ht direction */
297                 flags = pci_read_config16(dev, pos + PCI_CAP_FLAGS); // double read ??
298
299                 offs = ((flags>>10) & 1) ? PCI_HT_SLAVE1_OFFS : PCI_HT_SLAVE0_OFFS;
300
301                 /* Setup the Hypertransport link */
302                 reset_needed |= ht_optimize_link(udev, upos, uoffs, dev, pos, offs);
303
304 #if CK804_DEVN_BASE==0
305                 if(id == 0x005e10de) {
306                         break;
307                 }
308 #endif
309
310                 /* Remeber the location of the last device */
311                 udev = dev;
312                 upos = pos;
313                 uoffs = (offs != PCI_HT_SLAVE0_OFFS) ? PCI_HT_SLAVE0_OFFS : PCI_HT_SLAVE1_OFFS;
314
315         } while((last_unitid != next_unitid) && (next_unitid <= 0x1f));
316         return reset_needed;
317 }
318
319 static int ht_setup_chainx(device_t udev, uint8_t upos, uint8_t bus)
320 {
321         uint8_t next_unitid, last_unitid;
322         unsigned uoffs;
323         int reset_needed=0;
324
325         uoffs = PCI_HT_HOST_OFFS;
326         next_unitid = 1;
327
328         do {
329                 uint32_t id;
330                 uint8_t pos;
331                 uint16_t flags;
332                 uint8_t count;
333                 unsigned offs;
334                 
335                 device_t dev = PCI_DEV(bus, 0, 0);
336                 last_unitid = next_unitid;
337
338                 id = pci_read_config32(dev, PCI_VENDOR_ID);
339
340                 /* If the chain is enumerated quit */
341                 if (((id & 0xffff) == 0x0000) || ((id & 0xffff) == 0xffff) ||
342                     (((id >> 16) & 0xffff) == 0xffff) ||
343                     (((id >> 16) & 0xffff) == 0x0000)) {
344                         break;
345                 }
346
347                 pos = ht_lookup_slave_capability(dev);
348                 if (!pos) {
349                         print_err(" HT link capability not found\r\n");
350                         break;
351                 }
352
353 #if CK804_DEVN_BASE==0 
354                 //CK804 workaround: 
355                 // CK804 UnitID changes not use
356                 id = pci_read_config32(dev, PCI_VENDOR_ID);
357                 if(id != 0x005e10de) {
358 #endif
359
360                 /* Update the Unitid of the current device */
361                 flags = pci_read_config16(dev, pos + PCI_CAP_FLAGS);
362                 flags &= ~0x1f; /* mask out the bse Unit ID */
363                 flags |= next_unitid & 0x1f;
364                 pci_write_config16(dev, pos + PCI_CAP_FLAGS, flags);
365
366                 dev = PCI_DEV(bus, next_unitid, 0);
367 #if CK804_DEVN_BASE==0  
368                 } 
369                 else {
370                         dev = PCI_DEV(bus, 0, 0);
371                 }
372 #endif
373
374                 /* Compute the number of unitids consumed */
375                 count = (flags >> 5) & 0x1f;
376                 next_unitid += count;
377
378                 /* get ht direction */
379                 flags = pci_read_config16(dev, pos + PCI_CAP_FLAGS); // double read ??
380
381                 offs = ((flags>>10) & 1) ? PCI_HT_SLAVE1_OFFS : PCI_HT_SLAVE0_OFFS;
382                 
383                 /* Setup the Hypertransport link */
384                 reset_needed |= ht_optimize_link(udev, upos, uoffs, dev, pos, offs);
385
386 #if CK804_DEVN_BASE==0
387                 if(id == 0x005e10de) {
388                         break;
389                 }
390 #endif
391
392                 /* Remeber the location of the last device */
393                 udev = dev;
394                 upos = pos;
395                 uoffs = ( offs != PCI_HT_SLAVE0_OFFS ) ? PCI_HT_SLAVE0_OFFS : PCI_HT_SLAVE1_OFFS;
396
397         } while((last_unitid != next_unitid) && (next_unitid <= 0x1f));
398         return reset_needed;
399 }
400
401 static int optimize_link_read_pointer(uint8_t node, uint8_t linkn, uint8_t linkt, uint8_t val)
402 {
403         uint32_t dword, dword_old;
404         uint8_t link_type;
405         
406         /* This works on an Athlon64 because unimplemented links return 0 */
407         dword = pci_read_config32(PCI_DEV(0,0x18+node,0), 0x98 + (linkn * 0x20));
408         link_type = dword & 0xff;
409         
410         dword_old = dword = pci_read_config32(PCI_DEV(0,0x18+node,3), 0xdc);
411         
412         if ( (link_type & 7) == linkt ) { /* Coherent Link only linkt = 3, ncoherent = 7*/
413                 dword &= ~( 0xff<<(linkn *8) );
414                 dword |= val << (linkn *8);
415         }
416         
417         if (dword != dword_old) {
418                 pci_write_config32(PCI_DEV(0,0x18+node,3), 0xdc, dword);
419                 return 1;
420         }
421         
422         return 0;
423 }
424
425 static int optimize_link_in_coherent(uint8_t ht_c_num)
426 {
427         int reset_needed; 
428         uint8_t i;
429
430         reset_needed = 0;
431
432         for (i = 0; i < ht_c_num; i++) {
433                 uint32_t reg;
434                 uint8_t nodeid, linkn;
435                 uint8_t busn;
436                 uint8_t val;
437
438                 reg = pci_read_config32(PCI_DEV(0,0x18,1), 0xe0 + i * 4);
439                 
440                 nodeid = ((reg & 0xf0)>>4); // nodeid
441                 linkn = ((reg & 0xf00)>>8); // link n
442                 busn = (reg & 0xff0000)>>16; //busn
443         
444                 reg = pci_read_config32( PCI_DEV(busn, 1, 0), PCI_VENDOR_ID);
445                 if ( (reg & 0xffff) == PCI_VENDOR_ID_AMD) {
446                         val = 0x25;
447                 } else if ( (reg & 0xffff) == 0x10de ) {
448                         val = 0x25;//???
449                 } else {
450                         continue;
451                 }
452
453                 reset_needed |= optimize_link_read_pointer(nodeid, linkn, 0x07, val);
454
455         }
456
457         return reset_needed;
458 }
459
460 static int ht_setup_chains(uint8_t ht_c_num)
461 {
462         /* Assumption the HT chain that is bus 0 has the HT I/O Hub on it. 
463          * On most boards this just happens.  If a cpu has multiple
464          * non Coherent links the appropriate bus registers for the
465          * links needs to be programed to point at bus 0.
466          */
467         int reset_needed; 
468         uint8_t upos;
469         device_t udev;
470         uint8_t i;
471
472         reset_needed = 0;
473
474         for (i = 0; i < ht_c_num; i++) {
475                 uint32_t reg;
476                 uint8_t devpos;
477                 unsigned regpos;
478                 uint32_t dword;
479                 uint8_t busn;
480                 
481                 reg = pci_read_config32(PCI_DEV(0,0x18,1), 0xe0 + i * 4);
482
483                 //We need setup 0x94, 0xb4, and 0xd4 according to the reg
484                 devpos = ((reg & 0xf0)>>4)+0x18; // nodeid; it will decide 0x18 or 0x19
485                 regpos = ((reg & 0xf00)>>8) * 0x20 + 0x94; // link n; it will decide 0x94 or 0xb4, 0x0xd4;
486                 busn = (reg & 0xff0000)>>16;
487                 
488                 dword = pci_read_config32( PCI_DEV(0, devpos, 0), regpos) ;
489                 dword &= ~(0xffff<<8);
490                 dword |= (reg & 0xffff0000)>>8;
491                 pci_write_config32( PCI_DEV(0, devpos,0), regpos , dword);
492                 
493                 /* Make certain the HT bus is not enumerated */
494                 ht_collapse_previous_enumeration(busn);
495
496                 upos = ((reg & 0xf00)>>8) * 0x20 + 0x80;
497                 udev =  PCI_DEV(0, devpos, 0);
498                 
499                 reset_needed |= ht_setup_chainx(udev,upos,busn);
500
501
502         }
503
504         reset_needed |= optimize_link_in_coherent(ht_c_num);            
505         
506         return reset_needed;
507 }
508
509 static int ht_setup_chains_x(void)
510 {               
511         uint8_t nodeid;
512         uint32_t reg; 
513         uint32_t tempreg;
514         uint8_t next_busn;
515         uint8_t ht_c_num;
516         uint8_t nodes;
517       
518         /* read PCI_DEV(0,0x18,0) 0x64 bit [8:9] to find out SbLink m */
519         reg = pci_read_config32(PCI_DEV(0, 0x18, 0), 0x64);
520         /* update PCI_DEV(0, 0x18, 1) 0xe0 to 0x05000m03, and next_busn=5+1 */
521         print_linkn_in("SBLink=", ((reg>>8) & 3) );
522         tempreg = 3 | ( 0<<4) | (((reg>>8) & 3)<<8) | (0<<16)| (5<<24);
523         pci_write_config32(PCI_DEV(0, 0x18, 1), 0xe0, tempreg);
524
525         next_busn=5+1; /* 0 will be used ht chain with SB we need to keep SB in bus0 in auto stage*/
526         /* clean others */
527         for(ht_c_num=1;ht_c_num<4; ht_c_num++) {
528                 pci_write_config32(PCI_DEV(0, 0x18, 1), 0xe0 + ht_c_num * 4, 0);
529         }
530  
531         nodes = ((pci_read_config32(PCI_DEV(0, 0x18, 0), 0x60)>>4) & 7) + 1;
532
533         for(nodeid=0; nodeid<nodes; nodeid++) {
534                 device_t dev; 
535                 uint8_t linkn;
536                 dev = PCI_DEV(0, 0x18+nodeid,0);
537                 for(linkn = 0; linkn<3; linkn++) {
538                         unsigned regpos;
539                         regpos = 0x98 + 0x20 * linkn;
540                         reg = pci_read_config32(dev, regpos);
541                         if ((reg & 0x17) != 7) continue; /* it is not non conherent or not connected*/
542                         print_linkn_in("NC node|link=", ((nodeid & 0xf)<<4)|(linkn & 0xf));
543                         tempreg = 3 | (nodeid <<4) | (linkn<<8);
544                         /*compare (temp & 0xffff), with (PCI(0, 0x18, 1) 0xe0 to 0xec & 0xfffff) */
545                         for(ht_c_num=0;ht_c_num<4; ht_c_num++) {
546                                 reg = pci_read_config32(PCI_DEV(0, 0x18, 1), 0xe0 + ht_c_num * 4);
547                                 if(((reg & 0xffff) == (tempreg & 0xffff)) || ((reg & 0xffff) == 0x0000)) {  /*we got it*/
548                                         break;
549                                 }
550                         }
551                         if(ht_c_num == 4) break; /*used up onle 4 non conherent allowed*/
552                         /*update to 0xe0...*/
553                         if((reg & 0xf) == 3) continue; /*SbLink so don't touch it */
554                         print_linkn_in("\tbusn=", next_busn);
555                         tempreg |= (next_busn<<16)|((next_busn+5)<<24);
556                         pci_write_config32(PCI_DEV(0, 0x18, 1), 0xe0 + ht_c_num * 4, tempreg);
557                         next_busn+=5+1;
558                 }
559         }
560         /*update 0xe0, 0xe4, 0xe8, 0xec from PCI_DEV(0, 0x18,1) to PCI_DEV(0, 0x19,1) to PCI_DEV(0, 0x1f,1);*/
561
562         for(nodeid = 1; nodeid<nodes; nodeid++) {
563                 int i;
564                 device_t dev;
565                 dev = PCI_DEV(0, 0x18+nodeid,1);
566                 for(i = 0; i< 4; i++) {
567                         unsigned regpos;
568                         regpos = 0xe0 + i * 4;
569                         reg = pci_read_config32(PCI_DEV(0, 0x18, 1), regpos);
570                         pci_write_config32(dev, regpos, reg);
571
572                 }
573         }
574         
575         /* recount ht_c_num*/
576         uint8_t i=0;
577         for(ht_c_num=0;ht_c_num<4; ht_c_num++) {
578                 reg = pci_read_config32(PCI_DEV(0, 0x18, 1), 0xe0 + ht_c_num * 4);
579                 if(((reg & 0xf) != 0x0)) {
580                         i++;
581                 }
582         }
583
584         return ht_setup_chains(i);
585
586 }