- 
                Notifications
    You must be signed in to change notification settings 
- Fork 8.2k
Bluetooth: controller: Add/Remove ACAD on create/terminate BIG #32622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
7a8e72f    to
    7730b6b      
    Compare
  
    7730b6b    to
    0f89b17      
    Compare
  
    There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assumes that "sizeof(void *)" is 4 bytes, which is not guaranteed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
 sizeof(value) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incrementing by sizeof(uint32) would match what is stored above and would work if sizeof(void *) <= sizeof(uint32). If sizeof(void *) > sizeof(uint32), storing the pointer as uint32_t is broken in the first place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic to pass a length and return a pointer via field_data to then fill in the actual ACAD data is pretty convoluted. Wouldn't it be easier to just pass down the data to be filled into the ACAD?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is where it is going in terms of implementation: 02e62ba#diff-46edd4480ca72c05f7bb026bdac384a2d48b03317361f2ea6ccdf70d15dc6769R197-R241
Passing by parameters or filling into a structure or passing the whole LLL context to fill inside set_clear, all have their disadvantage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think having dedicated parameters or fields for passing the length and returning the address instead of reusing field_data would clear up a lot. Maybe the general pattern should be that field_data does not hold the data to be filled in on the way down, but the address where to write data on the way up.
So instead of writing (just as an example):
                cte_info.type = df_cfg->cte_type;
                cte_info.time = df_cfg->cte_length;
                pdu_data.field_data = (uint8_t *)&cte_info;
                ...
                err = ull_adv_sync_pdu_set_clear(adv, ULL_ADV_PDU_HDR_FIELD_CTE_INFO, 0, &pdu_data, &ter_idx);
the pattern could be
                err = ull_adv_sync_pdu_set_clear(adv, ULL_ADV_PDU_HDR_FIELD_CTE_INFO, 0, &pdu_data, &ter_idx);
                cte_info = pdu_data.field_data;                
                cte_info->type = df_cfg->cte_type;
                cte_info->time = df_cfg->cte_length;
This would then also fit the use case for the somewhat bigger big_info struct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The intention is to use the ull_adv_aux_hdr_set_clear and ull_adv_sync_pdu_set_clear (in the future combine them into one function) to take-in variable number of data for numerous header fields (bitmap for set/clear, say adding adv and init addresses, may be other parameters together). Hence the field_data is length encoded (like the AD data format, length-data). This is done to save on execution time updating the PDU.
Let me review so far, if array of lengths can be passed and then return array of pointers that can be used to fill in. (But this will not happen until I get to the point I have an initial samples of ISO broadcaster and ISO receiver)
The current implementation of passing length+value for simple values (AdvA, TargetA, ADI, AuxPtr, TxPower and Host AD Data) and returning pointers for struct values (CTEInfo, SyncInfo, and ACAD).
This means, we keep as-is for AdvA, TargetA, ADI, AuxPtr, TxPower and Host AD Data; and CTEInfo and SyncInfo be ported to populating the return address, do you agree?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to use the same pattern for everything and I think it would eventually lead to simpler, more efficient code. But I can live with distinguishing between "simple" and "complex" cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wopu-ot as communicated to you few weeks back in our status meeting, I tend to agree with passing down field bitmap and passing up address as stated in your comment here #32622 (comment)
@andrzej-kaczmarek FYI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Problems making consistent for the below mentioned fields (these are all the fields in the current code base):
- ULL_ADV_PDU_HDR_FIELD_ADVA
 -- Address type and address are in different locations, will need two pointers and bit offset, i.e. pointer return for the byte and offset to the bit, a pointer to the 6 byte address in the PDU; to be returned to caller so as to set the advertising address.
- ULL_ADV_PDU_HDR_FIELD_AD_DATA
 -- LE Set Extended Advertising Data command can be used to set legacy advertising PDU data, moving the code that set the legacy advertising outsideull_adv_aux_hdr_set_clearadds (a little bit repeated) overhead code to peek into the current PDU.
- ULL_ADV_PDU_HDR_FIELD_AUX_PTR
 -- Currently only the PHY is assigned, and is not directed called anywhere with this flag; PHY which is easily available in the passed advertising set structure, making this be assigned by the caller is added code and CPU cycles.
- ULL_ADV_PDU_HDR_FIELD_CTE_INFO
 -- it is just one byte value, for which returning a pointer and being assigned by caller seems a bit of overhead.
The only field besides BIGInfo can be made to be caller assigned is:
- ULL_ADV_PDU_HDR_FIELD_SYNC_INFO
I will work this week on extracting the sync_info outside to caller.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wopu-ot Updated with the sync_info population by caller. Please review.
a7b89bf    to
    17947a1      
    Compare
  
    17947a1    to
    b7d50e6      
    Compare
  
    There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some possible readability additions that could be applied, but since there's not really any precedence set for the controller for the specified lines I don't think it's strictly necessary to change, but something to keep in mind.
| @wopu-ot Could you take another look. | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change still passes pointers through a 4-byte/uint32_t value, which may work right now but is a bug that will manifest sooner or later. Please update to use appropriately typed fields and variables.
6b36b19    to
    1c24001      
    Compare
  
    | 
 I have replaced to use memcpy, please review. | 
| Also converted to draft as I want #31875 to be merged before this, to ensure I can rebase this PR thereafter | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wopu-ot This should cover pointer size, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hard-coded assumption that sizeof(void *) == sizeof(uint32_t)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will fix this and send updates
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hard-coded assumption that sizeof(void *) == sizeof(uint32_t)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will fix this and send updates
Added implementation to add/remove ACAD field in the common extended header format of the periodic advertising PDU on create/terminate BIG. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1c24001    to
    903a4e8      
    Compare
  
    Use the set/clear function to modify the common extended header format in the PDU to add/remove ACAD. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
903a4e8    to
    2e24bd1      
    Compare
  
    Based on review comments, refactor out sync_info population to be performed by the caller of the function that prepares the extended advertising PDU. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
Updated ISO test to demonstrate ACAD field in periodic advertising PDUs. Here, test changing the periodic advertising data. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
Use the name adv_handle instead of index to store advertising handle. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
Minor fix to channel map mask used in debug message to print sync info fields. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
Use macros to access SCA and Channel Map fields in the Sync Info structure in advertising PDUs. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
2e24bd1    to
    d8aad76      
    Compare
  
    
Added implementation to add/remove ACAD field in the common
extended header format of the periodic advertising PDU on
create/terminate BIG.
Signed-off-by: Vinayak Kariappa Chettimada [email protected]