All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
tashtable.h
Go to the documentation of this file.
1 /*
2  * tashtable.h
3  *
4  * Created on: Apr 29, 2011
5  * Author: root
6  */
7 
8 #pragma once
9 
10 #include <cvmx.h>
11 #include <cvmx-coremask.h>
12 #include <cvmx-fpa.h>
13 #include <cvmx-spinlock.h>
14 #include <cvmx-pip.h>
15 #include <cvmx-malloc.h>
16 #include <cvmx-pow.h>
17 #include <cvmx-atomic.h>
18 #include <cvmx-version.h>
19 #include "bootmem.h"
20 
24 {
27 };
28 
30 
34 template<typename TmplIndexId, unsigned int N> class CTashTable
35 {
36 public:
39  {
44  };
45 
46 
48  //CTashTable()
49  //{
50  // m_ptFirstIndex = NULL;
51  //}
52 
54 
62  EErrorCodes Init(char *pcMemName, uint32_t ui32LogNrOfEntries, uint16_t ui32FPAPool, bool bDoTagCheck, CCoremask* pcCoreMask = NULL)
63  {
64  // Get coremask
65  if (pcCoreMask == NULL) {
66  m_cCoreMask.Set();
67  }
68  else
69  {
70  m_cCoreMask.SetMask(pcCoreMask->GetMask());
71  }
72  m_ui32NrOfEntries = 1 << ui32LogNrOfEntries; // Nr of entries is 2 ^ lognrofentries
73  m_ui64PoolSize = cvmx_fpa_get_block_size(ui32FPAPool);
74  m_ui32IndexMask = m_ui32NrOfEntries-1;
75  m_ui32RequiredSize = sizeof(TTableEntry);
76  if (m_ui64PoolSize > CVMX_CACHE_LINE_SIZE)
77  {
78  m_ui32RequiredSize = N + CVMX_CACHE_LINE_SIZE;
79  }
80  m_ui16PoolNumber = ui32FPAPool;
81  m_bDoTagCheck = bDoTagCheck;
82 
83  // Check if TNextPrev fits in one cache line
84  if (sizeof(TNextPrev) > CVMX_CACHE_LINE_SIZE)
85  {
86  printf("TNextPrev does not fit in CACHE LINE SIZE!\n");
87  exit(-1);
88  }
89 
90  m_ui32SkipSize = sizeof(TNextPrev);
91 
92  // Check if pool size large enough to store struct
93  if (m_ui32RequiredSize >=m_ui64PoolSize)
94  {
95  printf("Pool %d with size %ld is too small for %s to contain requested data with size %d\n", ui32FPAPool, m_ui64PoolSize, pcMemName, m_ui32RequiredSize);
96  exit(-1);
97  }
98  snprintf(m_cMemName, sizeof(m_cMemName), "%s", pcMemName);
99  uint32_t ulTotalSize = m_ui32NrOfEntries * sizeof (TFirstIndex) + sizeof (TGlobalVar);
100  uint8_t* pucMemory = (uint8_t*)CBootMem::Instance()->Alloc(&m_cCoreMask, m_cMemName, ulTotalSize);
101 
102  m_ptFirstIndex = (TFirstIndex*)pucMemory;
103  m_pGlobalVarStorage = (TGlobalVar*)(m_ptFirstIndex + m_ui32NrOfEntries);
104  m_ptTableRWSpinLock = (cvmx_rwlock_wp_lock_t *)(m_pGlobalVarStorage + 1);
105 
106  // Init all the spinlocks
107  for (uint32_t i = 0; i < m_ui32NrOfEntries; i++) cvmx_rwlock_wp_init(&m_ptFirstIndex[i].tRowRWSpinLock);
108  cvmx_rwlock_wp_init(m_ptTableRWSpinLock);
109 
110  CVMX_SYNCWS;
111  m_cCoreMask.BarrierSync();
112  return ErrorOk;
113  }
114 
116 
120  {
121  if ((m_ptFirstIndex != NULL) && m_cCoreMask.IsFirstCore())
122  {
123  // Release all allocated memory
124  for (unsigned int i = 0; i <= m_ui32NrOfEntries-1; i++)
125  {
126  cvmx_pow_tag_sw_full(NULL, 0xff0000 | i, CVMX_POW_TAG_TYPE_ATOMIC,0);cvmx_pow_tag_sw_wait();
127  if (m_ptFirstIndex[i].ui64ChainLength)
128  {
129  uint64_t ui64PhysPointer = m_ptFirstIndex[i].ui64FirstPointer;
130  while (ui64PhysPointer)
131  {
132  TNextPrev *ptCurrentPointer;
133  ptCurrentPointer = (TNextPrev *)cvmx_phys_to_ptr(ui64PhysPointer);
134  ui64PhysPointer = ptCurrentPointer->ui64NextPointer;
135  cvmx_fpa_free(cvmx_phys_to_ptr(ui64PhysPointer), m_ui16PoolNumber, 0);
136  }
137  }
138  }
139  // Release FirstIndex array
140  CBootMem::Instance()->Free(m_cMemName);
141  m_ptFirstIndex = NULL;
142  }
143  CVMX_SYNCWS;
144  m_cCoreMask.BarrierSync();
145  return ErrorOk;
146  }
147 
149 
155  void *Insert(uint32_t ui32Tag, const TmplIndexId &tmplIndexId, void *pStorage=NULL)
156  {
157  if (m_bDoTagCheck && !CheckForValidTag(ui32Tag)) return NULL;
158 
159  ui32Tag &= m_ui32IndexMask;
160 
161  TTableEntry *ptData;
162  if (pStorage == NULL)
163  {
164  // Allocate memory. First struct (TNextPrev) is used for bookkeeping and will not be given to user
165  ptData = (TTableEntry *)cvmx_fpa_alloc(m_ui16PoolNumber);
166 
167  if (ptData == NULL)
168  {
169  printf("CTashTable::Insert::Could not alloc memory from pool %d\n", m_ui16PoolNumber);
170  return NULL;
171  }
172  memset(ptData, 0, m_ui64PoolSize);
173  }
174  else
175  {
176  // No need to allocate storage, user has supplied it. Just use it.
177  ptData = (TTableEntry *)(((char *)pStorage) - m_ui32SkipSize);
178  ptData->tNextPrev.ui64NextPointer = 0;
179  }
180 
181  ptData->tNextPrev.tmplIndexId = tmplIndexId;
182  ptData->tNextPrev.ui32Tag = ui32Tag;
183  uint64_t ui64PhysPointer = m_ptFirstIndex[ui32Tag].ui64FirstPointer; // Get first index
184  TTableEntry *ptCurrentPointer = NULL;
185  if (cvmx_likely(!ui64PhysPointer)) // If list is empty
186  {
187  m_ptFirstIndex[ui32Tag].ui64LastPointer = m_ptFirstIndex[ui32Tag].ui64FirstPointer = cvmx_ptr_to_phys(ptData); // Make entry in FirstIndex
188  m_ptFirstIndex[ui32Tag].ui64ChainLength = 1;
189  }
190  else // Add to end of list
191  {
192  ptCurrentPointer = (TTableEntry *)cvmx_phys_to_ptr(m_ptFirstIndex[ui32Tag].ui64LastPointer);
193  m_ptFirstIndex[ui32Tag].ui64LastPointer = ptCurrentPointer->tNextPrev.ui64NextPointer = cvmx_ptr_to_phys(ptData); // Add entry to end of list
194  m_ptFirstIndex[ui32Tag].ui64ChainLength++;
195  }
196  cvmx_atomic_add32(&m_pGlobalVarStorage->iNrOfEntries, 1);
197  CVMX_SYNCWS;
198  return (void *)ptData->cUserStorage; // Return available memory
199  }
200 
202 
208  void *InsertAtBegin(uint32_t ui32Tag, const TmplIndexId &tmplIndexId, void *pStorage=NULL)
209  {
210  if (m_bDoTagCheck && !CheckForValidTag(ui32Tag)) return NULL;
211 
212  ui32Tag &= m_ui32IndexMask;
213 
214  TTableEntry *ptData;
215  if (pStorage == NULL)
216  {
217  // Allocate memory. First struct (TNextPrev) is used for bookkeeping and will not be given to user
218  ptData = (TTableEntry *)cvmx_fpa_alloc(m_ui16PoolNumber);
219 
220  if (ptData == NULL)
221  {
222  printf("CTashTable::Insert::Could not alloc memory from pool %d\n", m_ui16PoolNumber);
223  return NULL;
224  }
225  memset(ptData, 0, m_ui64PoolSize);
226  }
227  else
228  {
229  // No need to allocate storage, user has supplied it. Just use it.
230  ptData = (TTableEntry *)(((char *)pStorage) - m_ui32SkipSize);
231  ptData->tNextPrev.ui64NextPointer = 0;
232  }
233 
234  ptData->tNextPrev.tmplIndexId = tmplIndexId;
235  ptData->tNextPrev.ui32Tag = ui32Tag;
236  uint64_t ui64PhysPointer = m_ptFirstIndex[ui32Tag].ui64FirstPointer; // Get first index
237  if (cvmx_likely(!ui64PhysPointer)) // If list is empty
238  {
239  m_ptFirstIndex[ui32Tag].ui64LastPointer = m_ptFirstIndex[ui32Tag].ui64FirstPointer = cvmx_ptr_to_phys(ptData); // Make entry in FirstIndex
240  m_ptFirstIndex[ui32Tag].ui64ChainLength = 1;
241  }
242  else
243  {
244  m_ptFirstIndex[ui32Tag].ui64FirstPointer = cvmx_ptr_to_phys(ptData); // Let first entry point to new entry
245  ptData->tNextPrev.ui64NextPointer = ui64PhysPointer; // Let new first entry point to old first entry
246  m_ptFirstIndex[ui32Tag].ui64ChainLength++;
247  }
248  cvmx_atomic_add32(&m_pGlobalVarStorage->iNrOfEntries, 1);
249  CVMX_SYNCWS;
250  return (void *)ptData->cUserStorage; // Return available memory
251  }
252 
254 
259  EErrorCodes Remove(const TmplIndexId &tmplIndexId, uint32_t ui32Tag, bool bFreeResource=true)
260  {
261  if (m_bDoTagCheck && !CheckForValidTag(ui32Tag)) return ErrorInvalidTag;
262 
263  ui32Tag &= m_ui32IndexMask;
264 
265  EErrorCodes eErrorCode = ErrorOk;
266  uint64_t ui64PhysPointer = m_ptFirstIndex[ui32Tag].ui64FirstPointer;
267  if (cvmx_unlikely(m_ptFirstIndex[ui32Tag].ui64ChainLength == 0))
268  {
269  printf ("CTashTable::Remove: Chainlength is zero!! for index at address %p and tag %x\n", &tmplIndexId, ui32Tag);
270  return ErrorEntryNotFound; // Entry is empty
271  }
272  if (m_ptFirstIndex[ui32Tag].ui64ChainLength == 1)
273  {
274  TTableEntry *ptCurrentPointer = (TTableEntry *)cvmx_phys_to_ptr(ui64PhysPointer);
275  if (cvmx_unlikely(ptCurrentPointer->tNextPrev.tmplIndexId != tmplIndexId))
276  {
277  printf ("CTashTable::Remove: Only entry in chain does not match entry searched for!\n");
278  return ErrorEntryNotFound; // Entry is empty
279  }
280  // Test if current tag is tag in hash table
281  if (cvmx_unlikely(m_ui32NrOfEntries > 1 && ui32Tag != ptCurrentPointer->tNextPrev.ui32Tag))
282  {
283  printf ("CTashTable::Remove: Invalid Tag when chainlength == 1!\n");
284  }
285  if (bFreeResource)
286  {
287  cvmx_fpa_free(ptCurrentPointer, m_ui16PoolNumber, 0);
288  }
289  m_ptFirstIndex[ui32Tag].ui64ChainLength = m_ptFirstIndex[ui32Tag].ui64FirstPointer = m_ptFirstIndex[ui32Tag].ui64LastPointer = 0;
290  }
291  else
292  {
293  TTableEntry *ptCurrentPointer = NULL, *ptPreviousPointer = NULL;
294  bool bFound = false;
295  while (ui64PhysPointer)
296  {
297  ptPreviousPointer = ptCurrentPointer;
298  ptCurrentPointer = (TTableEntry *)cvmx_phys_to_ptr(ui64PhysPointer);
299  if (ptCurrentPointer->tNextPrev.tmplIndexId == tmplIndexId)
300  {
301  bFound = true;
302  break;
303  }
304  ui64PhysPointer = ptCurrentPointer->tNextPrev.ui64NextPointer; // Get next in list
305  };
306  if (cvmx_unlikely(!bFound))
307  {
308  printf ("CTashTable::Remove: Could not find connection for index at address %p\n", &tmplIndexId);
309  return ErrorEntryNotFound;
310  }
311  if (ui64PhysPointer == m_ptFirstIndex[ui32Tag].ui64FirstPointer) // If entry is first entry in list modify FirstEntry
312  {
313  m_ptFirstIndex[ui32Tag].ui64FirstPointer = ptCurrentPointer->tNextPrev.ui64NextPointer;
314  }
315  else
316  {
317  // If memory to delete is last member in list
318  if (ui64PhysPointer == m_ptFirstIndex[ui32Tag].ui64LastPointer)
319  {
320  m_ptFirstIndex[ui32Tag].ui64LastPointer = cvmx_ptr_to_phys(ptPreviousPointer);
321  }
322  ptPreviousPointer->tNextPrev.ui64NextPointer = ptCurrentPointer->tNextPrev.ui64NextPointer;
323  }
324  if (cvmx_unlikely(m_ui32NrOfEntries > 1 && ui32Tag != ptCurrentPointer->tNextPrev.ui32Tag))
325  {
326  printf ("CTashTable::Remove: Invalid Tag!\n");
327  }
328  if (bFreeResource)
329  {
330  cvmx_fpa_free(ptCurrentPointer, m_ui16PoolNumber, 0);
331  }
332  m_ptFirstIndex[ui32Tag].ui64ChainLength--;
333  }
334  cvmx_atomic_add32(&m_pGlobalVarStorage->iNrOfEntries, -1l);
335  CVMX_SYNCWS;
336  return eErrorCode;
337  }
338 
340 
344  void *Search(const TmplIndexId &tmplIndexId, uint32_t ui32Tag)
345  {
346  if (m_bDoTagCheck && !CheckForValidTag(ui32Tag)) return NULL;
347 
348  ui32Tag &= m_ui32IndexMask;
349 
350  TTableEntry *ptCurrentPointer = (m_ptFirstIndex[ui32Tag].ui64FirstPointer) ? (TTableEntry *)(cvmx_phys_to_ptr(m_ptFirstIndex[ui32Tag].ui64FirstPointer)) : NULL;
351  while (ptCurrentPointer)
352  {
353  if (cvmx_likely(ptCurrentPointer->tNextPrev.tmplIndexId == tmplIndexId))
354  {
355  break;
356  }
357  ptCurrentPointer = (ptCurrentPointer->tNextPrev.ui64NextPointer) ? (TTableEntry *)cvmx_phys_to_ptr(ptCurrentPointer->tNextPrev.ui64NextPointer) : NULL;
358  }
359  if (cvmx_unlikely(m_ui32NrOfEntries > 1 && ptCurrentPointer && ptCurrentPointer->tNextPrev.ui32Tag != ui32Tag))
360  {
361  printf ("CTashTable::Search: Invalid Tag!\n");
362  }
363  if (ptCurrentPointer)
364  return (void *)ptCurrentPointer->cUserStorage;
365  else
366  return NULL;
367  }
368 
369 
371 
374  int32_t GetAndAddNrOfEntries(int iIncrement)
375  {
376  return cvmx_atomic_fetch_and_add32(&m_pGlobalVarStorage->iNrOfEntries, iIncrement);
377  }
378 
380 
383  void *GetFirst(uint32_t ui32Tag)
384  {
385  if (cvmx_unlikely(!m_ptFirstIndex)) return NULL; // If not initiated yet, exit
386 
387  if (m_bDoTagCheck && !CheckForValidTag(ui32Tag)) return NULL;
388 
389  ui32Tag &= m_ui32IndexMask;
390 
391  if (m_ptFirstIndex[ui32Tag].ui64FirstPointer)
392  {
393  TTableEntry *pRet = (TTableEntry *)(cvmx_phys_to_ptr(m_ptFirstIndex[ui32Tag].ui64FirstPointer));
394  return (void *)pRet->cUserStorage;
395  }
396  else
397  {
398  return NULL;
399  }
400  }
401 
403 
406  void *GetNext(void *pCurrentPointer)
407  {
408  if (cvmx_unlikely(pCurrentPointer == NULL)) return NULL;
409 
410  TTableEntry *ptBookkeeping = (TTableEntry *)((char *)pCurrentPointer - m_ui32SkipSize);
411  if (ptBookkeeping->tNextPrev.ui64NextPointer)
412  {
413  TTableEntry *pReturnVal = (TTableEntry *)cvmx_phys_to_ptr(ptBookkeeping->tNextPrev.ui64NextPointer);
414  return (void *)pReturnVal->cUserStorage;
415  }
416  else
417  {
418  return NULL;
419  }
420  }
421 
423 
427  void SetAuxilary(uint32_t ui32Tag, uint64_t ui64Auxilary)
428  {
429  ui32Tag &= m_ui32IndexMask;
430  m_ptFirstIndex[ui32Tag].ui64Auxiliary = ui64Auxilary;
431  CVMX_SYNCWS;
432  }
433 
435 
439  uint64_t GetAuxilary(uint32_t ui32Tag)
440  {
441  ui32Tag &= m_ui32IndexMask;
442  return m_ptFirstIndex[ui32Tag].ui64Auxiliary;
443  }
444 
446 
450  void *GetIndexIdArea(void *pCurrentPointer)
451  {
452  TTableEntry *ptBookkeeping = (TTableEntry *)((char *)pCurrentPointer - m_ui32SkipSize);
453  return (void *)&ptBookkeeping->tNextPrev.tmplIndexId;
454  }
455 
456  inline void WriteLock(uint32_t ui32Index)
457  {
458  uint32_t ui32IndexMasked = ui32Index & m_ui32IndexMask;
459  cvmx_rwlock_wp_write_lock(&m_ptFirstIndex[ui32IndexMasked].tRowRWSpinLock);
460  }
461 
462  inline void WriteUnlock(uint32_t ui32Index)
463  {
464  uint32_t ui32IndexMasked = ui32Index & m_ui32IndexMask;
465  cvmx_rwlock_wp_write_unlock(&m_ptFirstIndex[ui32IndexMasked].tRowRWSpinLock);
466  }
467 
468  inline void ReadLock(uint32_t ui32Index)
469  {
470  uint32_t ui32IndexMasked = ui32Index & m_ui32IndexMask;
471  cvmx_rwlock_wp_read_lock(&m_ptFirstIndex[ui32IndexMasked].tRowRWSpinLock);
472  }
473 
474  inline void ReadUnlock(uint32_t ui32Index)
475  {
476  uint32_t ui32IndexMasked = ui32Index & m_ui32IndexMask;
477  cvmx_rwlock_wp_read_unlock(&m_ptFirstIndex[ui32IndexMasked].tRowRWSpinLock);
478  }
479 
480  inline void ReadWriteLock(uint32_t ui32Index, ELockCommand eCommand)
481  {
482  uint32_t ui32IndexMasked = ui32Index & m_ui32IndexMask;
483  if (eCommand == ELockWrite)
484  cvmx_rwlock_wp_write_lock(&m_ptFirstIndex[ui32IndexMasked].tRowRWSpinLock);
485  else
486  cvmx_rwlock_wp_read_lock(&m_ptFirstIndex[ui32IndexMasked].tRowRWSpinLock);
487  }
488 
489  inline void ReadWriteUnlock(uint32_t ui32Index, ELockCommand eCommand)
490  {
491  uint32_t ui32IndexMasked = ui32Index & m_ui32IndexMask;
492  if (eCommand == ELockWrite)
493  cvmx_rwlock_wp_write_unlock(&m_ptFirstIndex[ui32IndexMasked].tRowRWSpinLock);
494  else
495  cvmx_rwlock_wp_read_unlock(&m_ptFirstIndex[ui32IndexMasked].tRowRWSpinLock);
496  }
497 
498  inline void WriteLockTable()
499  {
500  cvmx_rwlock_wp_write_lock(m_ptTableRWSpinLock);
501  }
502 
503  inline void WriteUnlockTable()
504  {
505  cvmx_rwlock_wp_write_unlock(m_ptTableRWSpinLock);
506  }
507 
508  inline void ReadLockTable()
509  {
510  cvmx_rwlock_wp_read_lock(m_ptTableRWSpinLock);
511  }
512 
513  inline void ReadUnlockTable()
514  {
515  cvmx_rwlock_wp_read_unlock(m_ptTableRWSpinLock);
516  }
517 
518  inline void ReadWriteLockTable(ELockCommand eCommand)
519  {
520  if (eCommand == ELockWrite)
521  cvmx_rwlock_wp_write_lock(m_ptTableRWSpinLock);
522  else
523  cvmx_rwlock_wp_read_lock(m_ptTableRWSpinLock);
524  }
525 
526  inline void ReadWriteUnlockTable(ELockCommand eCommand)
527  {
528  if (eCommand == ELockWrite)
529  cvmx_rwlock_wp_write_unlock(m_ptTableRWSpinLock);
530  else
531  cvmx_rwlock_wp_read_unlock(m_ptTableRWSpinLock);
532  }
533 
534  void *Allocate(bool bOnCacheLine)
535  {
536  TTableEntry *pMem = (TTableEntry *)cvmx_fpa_alloc(m_ui16PoolNumber);
537  uint64_t ui64Pointer;
538  if (bOnCacheLine)
539  {
540  ui64Pointer = (uint64_t)pMem + CVMX_CACHE_LINE_SIZE;
541  pMem = (TTableEntry *)(ui64Pointer - sizeof(TNextPrev));
542  pMem->tNextPrev.bOnCacheLine = true;
543  }
544  else
545  {
546  ui64Pointer = (uint64_t)pMem->cUserStorage;
547  }
548  return (void *)ui64Pointer;
549  }
550 
551  void Free(void *pMemory)
552  {
553  if (pMemory == NULL) return;
554  uint64_t ui64Pointer = (uint64_t)pMemory - m_ui32SkipSize;
555  if ((*((TTableEntry *)ui64Pointer)).tNextPrev.bOnCacheLine)
556  {
557  ui64Pointer = (uint64_t)pMemory - CVMX_CACHE_LINE_SIZE;
558  }
559  cvmx_fpa_free((void *)ui64Pointer, m_ui16PoolNumber, 0);
560  }
561 
562 private:
563  struct TFirstIndex
564  {
565  uint64_t ui64FirstPointer;
566  uint64_t ui64LastPointer;
567  uint64_t ui64ChainLength;
568  uint64_t ui64Auxiliary;
569  cvmx_rwlock_wp_lock_t tRowRWSpinLock;
570  };
571 
572  struct TNextPrev
573  {
574  TmplIndexId tmplIndexId;
575  uint32_t ui32Tag;
576  bool bOnCacheLine;
577  uint64_t ui64NextPointer;
578  };
579 
580  struct TTableEntry
581  {
582  TNextPrev tNextPrev;
583  char cUserStorage[N];
584  };
585 
586  struct TGlobalVar // Global area
587  {
588  int iNrOfEntries; // Nr of entries in this table
589  };
590 
591  uint32_t m_ui32NrOfEntries;
592  uint32_t m_ui32IndexMask;
593  uint32_t m_ui32RequiredSize;
594  uint32_t m_ui32SkipSize;
595  CCoremask m_cCoreMask;
596  uint16_t m_ui16PoolNumber;
597  uint64_t m_ui64PoolSize;
598  char m_cMemName[80];
599  TGlobalVar *m_pGlobalVarStorage;
600  TFirstIndex *m_ptFirstIndex;
601  bool m_bDoTagCheck;
602  cvmx_rwlock_wp_lock_t *m_ptTableRWSpinLock;
603 
604  bool CheckForValidTag(uint32_t ui32Tag)
605  {
606  cvmx_pow_tag_info_t tTagInfo = cvmx_pow_get_current_tag();
607  if (cvmx_unlikely((tTagInfo.tag_type != CVMX_POW_TAG_TYPE_ATOMIC)))
608  {
609  printf("CTashTable::CheckForValidTag::Tag type not atomic!\n");
610  return false;
611  }
612  else if (cvmx_unlikely((tTagInfo.tag & 0x00ff0000) != 0x00ff0000))
613  {
614  printf("CTashTable::CheckForValidTag::Current tag does not start with 0x00ff\n");
615  return false;
616  }
617  else if (cvmx_unlikely((tTagInfo.tag & m_ui32IndexMask) != (m_ui32IndexMask & ui32Tag)))
618  {
619  printf("CTashTable::CheckForValidTag::Tag not equal to %x\n", ui32Tag);
620  return false;
621  }
622  return true;
623  }
624 };
EErrorCodes Close()
Close the tash table.
Definition: tashtable.h:119
void ReadUnlockTable()
Definition: tashtable.h:513
void * GetFirst(uint32_t ui32Tag)
Get the first entry at the index.
Definition: tashtable.h:383
void * GetNext(void *pCurrentPointer)
Get the next entry at the index.
Definition: tashtable.h:406
void ReadLock(uint32_t ui32Index)
Definition: tashtable.h:468
void * Alloc(CCoremask *pcCoreMask, const char *pcName, uint64_t uxSize, uint64_t uxAlignment=CVMX_CACHE_LINE_SIZE)
Definition: bootmem.h:68
static CBootMem * Instance()
Definition: bootmem.h:13
void * Allocate(bool bOnCacheLine)
Definition: tashtable.h:534
ELockCommand
Definition: tashtable.h:23
void ReadWriteLock(uint32_t ui32Index, ELockCommand eCommand)
Definition: tashtable.h:480
void * Search(const TmplIndexId &tmplIndexId, uint32_t ui32Tag)
Search for an entry in the tash table.
Definition: tashtable.h:344
void WriteUnlock(uint32_t ui32Index)
Definition: tashtable.h:462
void WriteUnlockTable()
Definition: tashtable.h:503
void ReadWriteUnlockTable(ELockCommand eCommand)
Definition: tashtable.h:526
Removing an entry that does not exist.
Definition: tashtable.h:42
void WriteLockTable()
Definition: tashtable.h:498
EErrorCodes Remove(const TmplIndexId &tmplIndexId, uint32_t ui32Tag, bool bFreeResource=true)
Remove an entry from the tash table.
Definition: tashtable.h:259
bool Free(const char *pcName)
Definition: bootmem.h:221
void * InsertAtBegin(uint32_t ui32Tag, const TmplIndexId &tmplIndexId, void *pStorage=NULL)
Insert an entry of type TmplIndexId at index ui32Tag to the tash table.
Definition: tashtable.h:208
bool IsFirstCore(void)
Definition: coremask.h:40
void Free(void *pMemory)
Definition: tashtable.h:551
void BarrierSync(void)
Definition: coremask.h:71
No memory available from the CBootMem class.
Definition: tashtable.h:41
uint64_t GetAuxilary(uint32_t ui32Tag)
Get the Auxiliary field of an index.
Definition: tashtable.h:439
void ReadUnlock(uint32_t ui32Index)
Definition: tashtable.h:474
void Set(void)
Definition: coremask.h:13
void SetMask(uint16_t uiCoremask)
Definition: coremask.h:90
void ReadWriteUnlock(uint32_t ui32Index, ELockCommand eCommand)
Definition: tashtable.h:489
void * GetIndexIdArea(void *pCurrentPointer)
Get a pointer to the unique ID area of the member.
Definition: tashtable.h:450
void ReadWriteLockTable(ELockCommand eCommand)
Definition: tashtable.h:518
All went well.
Definition: tashtable.h:40
void * Insert(uint32_t ui32Tag, const TmplIndexId &tmplIndexId, void *pStorage=NULL)
Insert an entry of type TmplIndexId at index ui32Tag to the tash table.
Definition: tashtable.h:155
EErrorCodes Init(char *pcMemName, uint32_t ui32LogNrOfEntries, uint16_t ui32FPAPool, bool bDoTagCheck, CCoremask *pcCoreMask=NULL)
Constructor.
Definition: tashtable.h:62
int32_t GetAndAddNrOfEntries(int iIncrement)
Get the number of entries that are stored in this tash table (diagnostic function) ...
Definition: tashtable.h:374
void WriteLock(uint32_t ui32Index)
Definition: tashtable.h:456
Hash table that uses atomic locking of OCTEON processor (Tagged Hash Table = TashTable :-) ...
Definition: tashtable.h:34
Removing an entry with an invalid tag.
Definition: tashtable.h:43
void ReadLockTable()
Definition: tashtable.h:508
EErrorCodes
Definitions of return codes.
Definition: tashtable.h:38
void SetAuxilary(uint32_t ui32Tag, uint64_t ui64Auxilary)
Set the Auxiliary field of an index.
Definition: tashtable.h:427