Bluetooth: Add opcode parameter to hci_req_complete_t callback
Subsystems (2)
Marcel Holtmann
maintainerPATCH 1/1 Bluetooth: Add opcode parameter to hci_req_complete_t callback
When hci_req_run() calls its provided complete function and one of the HCI commands in the sequence fails, then provide the opcode of failing command. In case of success HCI_OP_NOP is provided since all commands completed.
This patch fixes the prototype of hci_req_complete_t and all its users.
--- include/net/bluetooth/bluetooth.h | 2 +- net/bluetooth/hci_conn.c | 2 +- net/bluetooth/hci_core.c | 9 ++++---- net/bluetooth/hci_request.c | 3 ++- net/bluetooth/mgmt.c | 44 ++++++++++++++++++++++----------------- 5 files changed, 34 insertions(+), 26 deletions(-)
include/net/bluetooth/bluetooth.h +1 -1
@@ -273,7 +273,7 @@ struct l2cap_ctrl {struct hci_dev ; -typedef void (*hci_req_complete_t )(struct hci_dev *hdev,u8 status); +typedef void (*hci_req_complete_t )(struct hci_dev *hdev,u8 status,u16 opcode);struct hci_req_ctrl {bool start;
net/bluetooth/hci_conn.c +1 -1
@@ -633,7 +633,7 @@ void hci_le_conn_failed(struct hci_conn *conn, u8 status)mgmt_reenable_advertising (hdev); } -static void create_le_conn_complete (struct hci_dev *hdev,u8 status) +static void create_le_conn_complete (struct hci_dev *hdev,u8 status,u16 opcode) {struct hci_conn *conn;
net/bluetooth/hci_core.c +5 -4
@@ -141,7 +141,7 @@ static const struct file_operations dut_mode_fops = {/* ---- HCI requests ---- */ -static void hci_req_sync_complete (struct hci_dev *hdev,u8 result) +static void hci_req_sync_complete (struct hci_dev *hdev,u8 result,u16 opcode) {BT_DBG ("%s result 0x%2.2x" , hdev->name, result);
@@ -2762,7 +2762,7 @@ void hci_conn_params_clear_all(struct hci_dev *hdev)BT_DBG ("All LE connection parameters were removed" ); } -static void inquiry_complete (struct hci_dev *hdev,u8 status) +static void inquiry_complete (struct hci_dev *hdev,u8 status,u16 opcode) {if (status) {BT_ERR ("Failed to start inquiry: status %d" , status);
@@ -2774,7 +2774,8 @@ static void inquiry_complete(struct hci_dev *hdev, u8 status) } } -static void le_scan_disable_work_complete (struct hci_dev *hdev,u8 status) +static void le_scan_disable_work_complete (struct hci_dev *hdev,u8 status, +u16 opcode) {/* General inquiry access code (GIAC) */ u8 lap[3 ] = {0x33 ,0x8b ,0x9e };
@@ -4167,7 +4168,7 @@ void hci_req_cmd_complete(struct hci_dev *hdev, u16 opcode, u8 status) call_complete:if (req_complete) -req_complete (hdev, status); +req_complete (hdev, status, status ? opcode :HCI_OP_NOP ); }static void hci_rx_work (struct work_struct *work)
net/bluetooth/hci_request.c +2 -1
@@ -533,7 +533,8 @@ void __hci_update_background_scan(struct hci_request *req) } } -static void update_background_scan_complete (struct hci_dev *hdev,u8 status) +static void update_background_scan_complete (struct hci_dev *hdev,u8 status, +u16 opcode) {if (status) BT_DBG("HCI request failed to update background scanning: "
net/bluetooth/mgmt.c +25 -19
158 lines not on this page · raw message
Signature · 1 line
2.1.0
Johan Hedberg
AppliedHi Marcel,
Quoted 7 lines · Marcel Holtmann
When
hci_req_run()calls its provided complete function and one of the HCI commands in the sequence fails, then provide the opcode of failing command. In case of successHCI_OP_NOPis provided since all commands completed.This patch fixes the prototype of
hci_req_complete_tand all its users.
Quoted 8 lines
Signed-off-by Marcel Holtmann <[email protected]>--- include/net/bluetooth/bluetooth.h | 2 +- net/bluetooth/hci_conn.c | 2 +- net/bluetooth/hci_core.c | 9 ++++---- net/bluetooth/hci_request.c | 3 ++- net/bluetooth/mgmt.c | 44 ++++++++++++++++++++++----------------- 5 files changed, 34 insertions(+), 26 deletions(-)
Applied to bluetooth-next. Thanks.
Would it make sense to also change the return value of the callback from void to bool. That way the callback could let the request handling code know whether to proceed even after a single command failure or to abort the request.
Johan
Marcel Holtmann
maintainerHi Johan,
Quoted 16 lines
Quoted 7 lines
When
hci_req_run()calls its provided complete function and one of the HCI commands in the sequence fails, then provide the opcode of failing command. In case of successHCI_OP_NOPis provided since all commands completed.This patch fixes the prototype of
hci_req_complete_tand all its users.Quoted 8 lines
Signed-off-by Marcel Holtmann <[email protected]>---
include/net/bluetooth/bluetooth.h | 2 +- net/bluetooth/hci_conn.c | 2 +- net/bluetooth/hci_core.c | 9 ++++---- net/bluetooth/hci_request.c | 3 ++- net/bluetooth/mgmt.c | 44 ++++++++++++++++++++++----------------- 5 files changed, 34 insertions(+), 26 deletions(-)
Quoted 6 lines
Applied to bluetooth-next. Thanks.
Would it make sense to also change the return value of the callback from void to bool. That way the callback could let the request handling code know whether to proceed even after a single command failure or to abort the request.
do we need this actually? Is there a case where we can continue if one of the commands fails.
I think what we actually need is to have a way to revert the actions taken by an earlier command. So if a command in sequence configured something, we might want to revert that action when a later command fails.
Regards
Marcel
Hi Marcel,
Quoted 18 lines · Marcel Holtmann
Quoted 18 lines
Quoted 7 lines
When
hci_req_run()calls its provided complete function and one of the HCI commands in the sequence fails, then provide the opcode of failing command. In case of successHCI_OP_NOPis provided since all commands completed.This patch fixes the prototype of
hci_req_complete_tand all its users.Quoted 8 lines
Signed-off-by Marcel Holtmann <[email protected]>---
include/net/bluetooth/bluetooth.h | 2 +- net/bluetooth/hci_conn.c | 2 +- net/bluetooth/hci_core.c | 9 ++++---- net/bluetooth/hci_request.c | 3 ++- net/bluetooth/mgmt.c | 44 ++++++++++++++++++++++----------------- 5 files changed, 34 insertions(+), 26 deletions(-)Applied to bluetooth-next. Thanks.
Quoted 7 lines
Quoted 4 lines
Would it make sense to also change the return value of the callback from void to bool. That way the callback could let the request handling code know whether to proceed even after a single command failure or to abort the request.
do we need this actually? Is there a case where we can continue if one of the commands fails.
I was mainly thinking of the various quirks we have for not issuing certain commands for adapters that don't properly support them - another way would be to simply ignore the errors from failing commands and proceed with the init sequence anyway. But you're right, this may not be a very useful feature.
Quoted 4 lines
I think what we actually need is to have a way to revert the actions taken by an earlier command. So if a command in sequence configured something, we might want to revert that action when a later command fails.
In theory sounds like a nice feature, but doubt this will work out very well in the end, at least not in a generic way. If an HCI command fails there's no guarantee that the "undo" HCI command wont fail too.
Johan
Marcel Holtmann
maintainerHi Johan,
Quoted 23 lines
Quoted 23 lines
Quoted 22 lines
Quoted 7 lines
When
hci_req_run()calls its provided complete function and one of the HCI commands in the sequence fails, then provide the opcode of failing command. In case of successHCI_OP_NOPis provided since all commands completed.This patch fixes the prototype of
hci_req_complete_tand all its users.Quoted 8 lines
Signed-off-by Marcel Holtmann <[email protected]>---
include/net/bluetooth/bluetooth.h | 2 +- net/bluetooth/hci_conn.c | 2 +- net/bluetooth/hci_core.c | 9 ++++---- net/bluetooth/hci_request.c | 3 ++- net/bluetooth/mgmt.c | 44 ++++++++++++++++++++++----------------- 5 files changed, 34 insertions(+), 26 deletions(-)Applied to bluetooth-next. Thanks.
Would it make sense to also change the return value of the callback from void to bool. That way the callback could let the request handling code know whether to proceed even after a single command failure or to abort the request.
Quoted 8 lines
Quoted 2 lines
do we need this actually? Is there a case where we can continue if one of the commands fails.
I was mainly thinking of the various quirks we have for not issuing certain commands for adapters that don't properly support them - another way would be to simply ignore the errors from failing commands and proceed with the init sequence anyway. But you're right, this may not be a very useful feature.
initially we did ignore failing commands if we did not consider them crucial. I think that was a big mistake. Actually having controller init fail and people having to dig out why these vendors screwed it up is a good idea. That way we know exactly what is going on. So I really want to keep it that way.
Quoted 8 lines
Quoted 4 lines
I think what we actually need is to have a way to revert the actions taken by an earlier command. So if a command in sequence configured something, we might want to revert that action when a later command fails.
In theory sounds like a nice feature, but doubt this will work out very well in the end, at least not in a generic way. If an HCI command fails there's no guarantee that the "undo" HCI command wont fail too.
Agreed. You can not convert all of it. However we could worst case just reset the whole stack. Which is a feature that we need anyway to handle the Hardware Error event.
Regards
Marcel