This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Issue with PA LLD "Pa_addCustomLUT1" on K2L

Other Parts Discussed in Thread: 66AK2L06
We are having a problem trying to setup a custom lookup rule in the Packet Accelerator using the PA LLD (Processor Linux SDK 03.00.00.04 on 66AK2L06 EVM).  When we make the following sequence of calls into the PA LLD, we are getting a segmentation fault (in Linux).  Below is the sequence we are using with snippets of code that we think are causing the problem.
 
1. Pa_addMac(..., paHandleL2L3_t *handle, ...)
    ...
    /* The handle is just a pointer to the table entry */
    *handle = (paLnkHandle_t)pa_CONV_BASE_TO_OFFSET(paLObj.cfg.instPoolBaseAddr,&l2Table[i]);
    ...
 
2. Pa_forwardResult
3. Pa_setCustomLUT1
4. Pa_forwardResult
 
5. Pa_addCustomLUT1(..., pHandleL2l3_t prevLink, ...)
    ...
    if (prevLink != NULL)
        l3Entry.pHandle    = (paLnkHandle_t)pa_CONV_BASE_TO_OFFSET(paLObj.cfg.instPoolBaseAddr, prevLink);
    ...
 
6. Pa_forwardResult
    ...
    if (l3e && l3e->pHandle && (origStatus != PA_TBL_STAT_ACTIVE)) {
      hdr = (paL2L3Header_t *)pa_CONV_OFFSET_TO_BASE(paLObj.cfg.instPoolBaseAddr,l3e->pHandle);
      hdr->lnkCnt++;
    <Segmentation Fault>
 
 
Step 1, we call Pa_addMac to set our initial MAC rule, and it returns a L2 handle which is just an offset into
the PA LLDs internal L2 table.
 
Steps 2-4 complete with no issues.
 
Step 5 we call Pa_addCustomLUT1 to add our custom rule, and we pass in the L2 handle from step 1 as "prevLink".
Pa_addCustomLUT1 takes prevLink (which is already an offset into L2 table) and calls pa_CONV_BASE_TO_OFFSET() which generates some invalid value and saves it into "pHandle" in the L3 table entry.  It doesn't make sense to convert prevLink into an offset since it already is an offset, right?
 
Step 6 we then call Pa_forwardResult, which the PA command response returned from step 5.  Within forwardResult, the code gets the pHandle value from the L3 table which was stored in step 5, and attempts to access the header of the L2 entry pointed by pHandle, but since this is an invalid value, the conversion done by pa_CONV_OFFSET_TO_BASE generates an invalid address (it actually ends up returing the offset into the L2 table, not the absolute address).  The dereferencing of the hdr pointer, "hdr->lnkCnt++", then causes the seg fault.
 
 
So to fix this issue we changed the code in #5 (Pa_addCustomLUT1) to look like this instead:
    if (prevLink != NULL)
        l3Entry.pHandle    = prevLink;
 
 
After making the change above, we are able to create the custom lookup rule successfully and it appears to be functioning properly.
Can you confirm that we are making the correct sequence of calls into the PA LLDs to setup a custom lookup rule?  If we are doing this correctly, then can you confirm that this is an issue in the PA LLD code?