You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Files: 

  • cpsw_buf.h
  • cpsw_buf.cc

Classes:

  • Public:
    • IBuf: Single buffer in a linked chain
    • IBufChain: Linked chain of IBufs
    • IBufQueue; Queue container for IBufChains
    • Buf (IBuf in shared pointer)
    • BufChain (IBufChain in shared pointer)
    • BufQueue (IBufQueue in shared pointer)
  • Private:
    • CBufImpl: Implementation of IBuf with ability to be a CFreeListNode
    • CBufChainImpl: Implementation of IBufChain with ability to be a CFreeListNode
    • BufImpl (CBufImpl in shared pointer)
    • BufChainImpl (CBufChainImpl in shared pointer)

IBuf class methods implemented in CBufImpl:

  • Buf getBuf(size_t capa, bool clip = false): Get a new buffer from free list or create new. Reduced to allowed size if size exceeds max available buffer when clip = true.
  • numBufsAlloced(): Buffers created from heap.
  • numBufsFree(): Total on free list.
  • numBufsInUse(): Number of buffers currently used

IBuf virtual methods implemented in CBufImpl:

  • size_t getCapacity(): Get max capacity of buffer as created
  • uint8_t * getPayload(): Get pointer to start of payload within the buffer
  • size_t getSize(): Get size of usable payload within the buffer
  • size_t getAvail(): Get amount of room left (capacity - end of payload)
  • size_t getHeadRoom(): Get available data before start of payload (not sure why this would be needed?)
  • void setSize(size_t s): Set size of payload in the buffer
  • void setPayload(uint8_t *p): Set start of payload within the buffer to *p
  • bool adjPayload(ssize_t delta): Shift the payload pointer by a specified amount, return false if shift exceeds payload
  • Buf getNext(): Get next entry in chain
  • Buf getPrev(): Get previous entry in chain
  • BufChain getChain(): Get pointer to head of chain????
  • void after(Buf buf): Insert this buffer after buf
  • void before(Buf buf): Insert this buffer before buf
  • void unlink(): Remove this buffer from the chain
  • void split(): Split the list at this entry. This buffer becomes the head of a new list, can not be on a chain

CBufImpl private variables:

  • weak_ptr<CBufChainImpl> chain_: Weak pointer to chain containing this buffer
  • BufImpl next_: Next entry (strong pointer)
  • weak_ptr<CBufImpl>: Previous entry (weak pointer)
  • unsigned short beg_, end_, capa_: Beginning of payload, end of payload and capacity
  • uint8_t data_[]: Array of bytes containing data

CBufImpl creator:

  • CBufImpl(CFreeListNodeKey<CbufImpl> k, unsigned short capa): Not sure???

Sets beginning and end pointers to HEADROOM which is hard coded to rssi / packetizer size

Sets capacity to passed value, passes k to CFreeListNode creator (adding to free list?)

CBufImpl virtual protected methods:

  • void addToChain(BufImpl p, bool before): Add to chain before or after p.
  • void delFromChain(); Remove entry from chain pointers (does not adjust list)

CBufImpl virtual methods:

  • void addToChain(BufChainImpl c); Add this buffer, and the rest of the list, to an empty chain
  • void reinit(): Reset the payload pointers (beg = end = HEADROOM)
  • BufImpl getNextImpl(): Get next entry
  • BufImpl getPrevImpl(): Get prev entry
  • BufChainImpl getChainImpl(): Get chain pointer
  • unlinkCheap(CBufChainImpl::key k): ?????

Questions:

Till,

I am going through the CPSW code and have some questions and comments, starting with the CPSW buffer implementation:

1. It appears you base the buffer size constants and container variables around the assumption that we will limit each buffer element size to 64K. I am not sure if that is a safe assumption once we add support for interfaces that are not TCP/IP or UDP. With PGP or axi-stream we can have much larger buffers. Also you seem to hardcode some ethernet based constants in the .h file and I am not sure that is the best place for a generic implementation.

2. In adjPayload you have this line:

if ( delta > beg || delta > old_size )
return false;

Why do you care if the shift size is greater than the beginning payload offset? 

3. In getBuf(size capa, bool clip) you adjust capa based upon maxcap and clip, but the resulting variable value is not used when calling the free list allocate. It seems you are just always allocating maxcap and not using the passed variable size. Maybe this is just a sanity check for the exception?

4. 



 

 

 

 

 

 

  • No labels