Skip to content
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

Bluetooth: controller: split: Fix DLE duplicate requests #23707

Merged

Conversation

cvinayak
Copy link
Contributor

Fix implementation to handle back-to-back and duplicate
LENGTH_REQ PDU reception.

Signed-off-by: Vinayak Kariappa Chettimada vich@nordicsemi.no

Simplify the Data Length Update Procedure state check when
processing incoming LENGTH_REQ/RSP PDUs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix implementation to handle back-to-back and duplicate
LENGTH_REQ PDU reception.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
@cvinayak cvinayak requested review from kruithofa and dagbja March 24, 2020 08:37
@cvinayak cvinayak added backport v2.2-branch bug The issue is a bug, or the PR is fixing a bug labels Mar 24, 2020
@@ -4501,26 +4501,20 @@ static inline int length_req_rsp_recv(struct ll_conn *conn, memq_link_t *link,
if (/* Local idle, and Peer request then complete the Peer procedure
* with response.
*/
((conn->llcp_length.req == conn->llcp_length.ack) &&
(pdu_rx->llctrl.opcode == PDU_DATA_LLCTRL_TYPE_LENGTH_REQ)) ||
((conn->llcp_length.req == conn->llcp_length.ack) && tx) ||
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The criteria is that opcode equals PDU_DATA_LLCTRL_TYPE_LENGTH_REQ, not that tx!=NULL
Even though tx!=NULL when the opcode is correct, this is not immediately obvious, you need to scroll back in the code.
IMHO the original was easier to follow.
Are there significant reductions in code-size and/or execution time?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compare and branch on zero take less instructions and CPU cycles, in compare to load two values compare it and branch set of instructions.

Before simplification:

Memory region         Used Size  Region Size  %age Used
           FLASH:      251093 B         1 MB     23.95%
            SRAM:       33652 B       256 KB     12.84%
        IDT_LIST:         136 B         2 KB      6.64%

After simplification:

Memory region         Used Size  Region Size  %age Used
           FLASH:      251029 B         1 MB     23.94%
            SRAM:       33652 B       256 KB     12.84%
        IDT_LIST:         136 B         2 KB      6.64%

PDU_DATA_LLCTRL_TYPE_LENGTH_RSP) ||
(pdu_rx->llctrl.opcode ==
PDU_DATA_LLCTRL_TYPE_LENGTH_REQ)))))) {
(conn->llcp_length.state == LLCP_LENGTH_STATE_RSP_WAIT)))) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why the test for PDU_DATA_LLCTRL_TYPE_LENGTH_RSP not is required?
I think the comment must be updated as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function enters either for PDU_DATA_LLCTRL_TYPE_LENGTH_RSP or PDU_DATA_LLCTRL_TYPE_LENGTH_REQ, and it is redundant to check for the same (||) here.

cvinayak added a commit to cvinayak/zephyr that referenced this pull request Mar 31, 2020
Fix implementation to handle back-to-back and duplicate
LENGTH_REQ PDU reception.

Relates to zephyrproject-rtos#23707.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
@carlescufi carlescufi merged commit 45500f3 into zephyrproject-rtos:master Apr 1, 2020
jhedberg pushed a commit that referenced this pull request Apr 22, 2020
Fix implementation to handle back-to-back and duplicate
LENGTH_REQ PDU reception.

Relates to #23707.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
pkral78 pushed a commit to cloudfieldcz/zephyr that referenced this pull request Aug 4, 2020
Fix implementation to handle back-to-back and duplicate
LENGTH_REQ PDU reception.

Relates to zephyrproject-rtos#23707.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
@cvinayak cvinayak deleted the github_dle_dup_split_fix branch March 1, 2021 00:32
@JiaDuo
Copy link

JiaDuo commented Apr 14, 2021

@cvinayak
I am using zephyr, the version is 2.2.0, this bug exists. For testing purposes, I tried to trigger this bug. I repeated LL_LENGTH_REQ twice but no error was triggered.
What conditions need to be met to trigger this bug?What requirements need to be met by the data packet field? Can you explain it in detail?

thank you~~

@cvinayak
Copy link
Contributor Author

@JiaDuo Your tester should send two LL_LENGTH_REQ PDU, one after the other in the same connection interval while not receiving the LL_LENGTH_RSP (nack the reception). This is an invalid behavior testing.

@JiaDuo
Copy link

JiaDuo commented Apr 14, 2021

Thank you very much!

@JiaDuo
Copy link

JiaDuo commented Apr 14, 2021

@cvinayak
Still, I can't trigger this bug. I'm using "peripherals_ HR" as a case. Send connect_ind first, and then send two LL_ LENGTH_ Req, I don't know how to ensure that two REQ are in the same connection interval .

Can you give me more suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Bluetooth bug The issue is a bug, or the PR is fixing a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants