-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Bluetooth: HCI: Add utility to extract PB and BC flags from data header #20767
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: HCI: Add utility to extract PB and BC flags from data header #20767
Conversation
jhedberg
left a comment
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.
Did you intend to use these somewhere in the code also? That seems to be missing. In the absence of actual use, you're failing to answer the most important question a commit message should answer, i.e. "why?" 😄
include/bluetooth/hci.h
Outdated
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.
Could you fix the alignment to match the other lines? It seems you're using some tabs, which the other lines don't have
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 alignment seems to be correct. But sometimes the diff shows it differently, I think it is the + sign in front line that eats up some of the tab-width. Should I replace all the tabs and only use space perhaps? It's what I'd normally do but checkpatch requires 8 spaces to be tab.
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.
All the existing bt_acl_* definitions use spaces for the alignment of the values, so please just follow that. The general rule we try to follow (since it makes presentation fairly consistent across different UIs) is tabs for indentation and spaces for alignment, i.e. tabs should only ever exist in the beginning of a line. And yes, as per Linux coding style (which Zephyr inherits) a tab width equals 8 spaces 😃
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.
Fixed. Thank you. Just assumed that it was tabs on the other ones.
I know the rule, but I have had issued with checkpatch complaining. But I think that was because I tried to align from the beginning of the line.
I'm using it here out of the zephyr tree. |
2a04d0c to
87f7b70
Compare
include/bluetooth/hci.h
Outdated
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.
Sorry, one more thing (the alignment it fine now). To make the evaluation order completely clear, could you add an extra parenthesis around (h) >> 12 and (h) >> 14. E.g. I wouldn't know by heart if bit-shifts or binary operators take precedence over the other.
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.
.. that'd actually also make the parenthesis usage consistent with the next line, i.e. the definition of bt_acl_handle_pack()
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.
Btw this imply that the value would be extracted from the bare header and not after bt_acl_flags which is what we normally pass around.
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.
@Vudentz That is a good point. Actually looking here it seems like we should actually extract the separate flags. Because right now we use a combination and check with ==
flags = bt_acl_flags(handle);
handle = bt_acl_handle(handle);
node_tx = ll_tx_mem_acquire();
if (!node_tx) {
BT_ERR("Tx Buffer Overflow");
data_buf_overflow(evt);
return -ENOBUFS;
}
pdu_data = (void *)node_tx->pdu;
if (flags == BT_ACL_START_NO_FLUSH || flags == BT_ACL_START) {
pdu_data->ll_id = PDU_DATA_LLID_DATA_START;
} else {
pdu_data->ll_id = PDU_DATA_LLID_DATA_CONTINUE;
}
If it is best to have a 2 step get function I'm not sure. It seems convoluted to have to do pb_flag(flags(handle));
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.
Maybe Im confusing with BlueZ then, I though the flags was passed over to another function as is, but yes it seems we are assuming the only pb is set when comparing so that would indeed need fixing, though that could be done with pb_flag(flags) if you don't want to create another variable to store them.
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.
@Vudentz You are right, we do pass around flags. So your suggestion was easier to use, mostly because we overwrite handle with flags masked out.
87f7b70 to
abd9dc2
Compare
|
@joerchan I'm not completely sure it's appropriate for me to merge this during the stabilisation period since it's not a fix. On the other hand, it's trivial and I find it hard to imagine any way that this could cause regressions since the macros don't have any users upstream (for now). @dleach02 any thoughts? |
No no, I wasn't expecting it either. Just creating the PR so that I don't forget this. It's a nice to have anyway so no rush. |
Add utility to extract the flags Packet Boundary and Broadcast to the hci.h together with the rest of the ACL data header definitions. Signed-off-by: Joakim Andersson <[email protected]>
abd9dc2 to
51733f8
Compare
|
@jhedberg Now I'm using it :) The flags was not properly checked over HCI. Although the only issue I could see was that the BT controller would allow being sent a "flushable" packet. So it is not a big deal I think. |
carlescufi
left a comment
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.
LGTM
Handle invalid ACL flags in HCI transport. Only Point to Point is supported over HCI in both directions. Fix flushable start HCI ACL packets not allowed on LE-U connections from Host to controller. Signed-off-by: Joakim Andersson <[email protected]>
51733f8 to
6bef109
Compare
|
@jhedberg Can we merge this one? |
Add utility to extract the flags Packet Boundary and Broadcast to the
hci.h together with the rest of the ACL data header definitions.
Signed-off-by: Joakim Andersson [email protected]