firewire: Add function to get speed from opaque struct fw_request
RFC PATCH 1/1 firewire: Add function to get speed from opaque struct fw_request
[ Would something like the following be acceptable as an addition to the FireWire stack? This would be enough for me to get the speed of the request for my work on the SBP-2 target code. ]
Sometimes it's useful to know the FireWire speed of the request that has just come in to a fw_address_handler callback. As struct fw_request is opaque we can't peek inside to get the speed out of the struct fw_packet that's just inside. For example, the SBP-2 spec says:
"The speed at which the block write request to the MANAGEMENT_AGENT register is received shall determine the speed used by the target for all subsequent requests to read the initiator’s configuration ROM, fetch ORB’s from initiator memory or store status at the initiator’s status_FIFO. Command block ORB’s separately specify the speed for requests addressed to the data buffer or page table."
[ ANSI T10/1155D Revision 4 page 53/54 ]
--- drivers/firewire/core-transaction.c | 6 ++++++ include/linux/firewire.h | 1 + 2 files changed, 7 insertions(+), 0 deletions(-)
drivers/firewire/core-transaction.c +6 -0
@@ -820,6 +820,12 @@ void fw_send_response(struct fw_card *card, }EXPORT_SYMBOL (fw_send_response); +int fw_request_speed (struct fw_request *request) +{ +return request->response.speed; +} +EXPORT_SYMBOL (fw_request_speed); + static void handle_exclusive_region_request(struct fw_card *card, struct fw_packet *p, struct fw_request *request,
include/linux/firewire.h +1 -0
@@ -340,6 +340,7 @@ int fw_core_add_address_handler(struct fw_address_handler *handler,void fw_core_remove_address_handler (struct fw_address_handler *handler);void fw_send_response (struct fw_card *card,struct fw_request *request,int rcode); +int fw_request_speed (struct fw_request *request); void fw_send_request(struct fw_card *card, struct fw_transaction *t, int tcode, int destination_id, int generation, int speed, unsigned long long offset, void *payload, size_t length,
Signature · 1 line
1.7.8.3
Quoted 3 lines · On Feb 06 Chris Boot wrote:
[ Would something like the following be acceptable as an addition to the FireWire stack? This would be enough for me to get the speed of the request for my work on the SBP-2 target code. ]
[...]
Quoted 20 lines
drivers/firewire/core-transaction.c +6
-0@@ -820,6 +820,12 @@ void fw_send_response(struct fw_card *card, }EXPORT_SYMBOL (fw_send_response); +int fw_request_speed (struct fw_request *request) +{ +return request->response.speed; +} +EXPORT_SYMBOL (fw_request_speed); + static void handle_exclusive_region_request(struct fw_card *card, struct fw_packet *p, struct fw_request *request,include/linux/firewire.h +0
-0
include/linux/firewire.h int fw_core_add_address_handler(struct fw_address_handler *handler, · line 346
Quoted 7 lines
include/linux/firewire.h +1
-0@@ -340,6 +340,7 @@ int fw_core_add_address_handler(struct fw_address_handler *handler,void fw_core_remove_address_handler (struct fw_address_handler *handler);void fw_send_response (struct fw_card *card,struct fw_request *request,int rcode); +int fw_request_speed (struct fw_request *request); void fw_send_request(struct fw_card *card, struct fw_transaction *t, int tcode, int destination_id, int generation, int speed, unsigned long long offset, void *payload, size_t length,
Whenever you add a new exported function, please add a brief kerneldoc comment right above its definition. Can be a one-liner in this case. Apart from this,
You can queue this via your SBP-2 target patch series (at which I haven't looked yet), followed right away by a change to your driver which uses the new symbol. Or even better, fold these two changes into one.
Not sure if four more characters should be spent on the symbol's name (fw_get_request_speed). If you already thought about it and preferred fw_request_speed, keep it that way.
There are at least two alternatives to your proposal:
- We could move the definition of struct fw_request from drivers/firewire/core-transaction.c to include/linux/firewire.h. That would make for a rather bad driver API though.
- We could expand the function type fw_address_callback_t() by a speed argument. The other users of the API (firewire-core itself, firewire-sbp2, firewire-net, firedtv, snd-firewire-lib, and other as yet unmerged firewire sound drivers) and any other perceivable future user of the API would not care of that speed though.
I.e. the proposed "get speed of request" helper seems better.
Signature · 3 lines
Stefan Richter -=====-===-- --=- --=== http://arcgraph.de/sr/
Quoted 37 lines · Stefan Richter
Quoted 3 lines · On Feb 06 Chris Boot wrote:
[ Would something like the following be acceptable as an addition to the FireWire stack? This would be enough for me to get the speed of the request for my work on the SBP-2 target code. ]
[...]
Quoted 20 lines
drivers/firewire/core-transaction.c +6
-0@@ -820,6 +820,12 @@ void fw_send_response(struct fw_card *card, }EXPORT_SYMBOL (fw_send_response); +int fw_request_speed (struct fw_request *request) +{ +return request->response.speed; +} +EXPORT_SYMBOL (fw_request_speed); + static void handle_exclusive_region_request(struct fw_card *card, struct fw_packet *p, struct fw_request *request,include/linux/firewire.h +0
-0include/linux/firewire.h int fw_core_add_address_handler(struct fw_address_handler *handler, · line 346
Quoted 7 lines
include/linux/firewire.h +1
-0@@ -340,6 +340,7 @@ int fw_core_add_address_handler(struct fw_address_handler *handler,void fw_core_remove_address_handler (struct fw_address_handler *handler);void fw_send_response (struct fw_card *card,struct fw_request *request,int rcode); +int fw_request_speed (struct fw_request *request); void fw_send_request(struct fw_card *card, struct fw_transaction *t, int tcode, int destination_id, int generation, int speed, unsigned long long offset, void *payload, size_t length,Whenever you add a new exported function, please add a brief kerneldoc comment right above its definition. Can be a one-liner in this case. Apart from this,
Quoted 5 lines
Acked-by Stefan Richter <[email protected]>You can queue this via your SBP-2 target patch series (at which I haven't looked yet), followed right away by a change to your driver which uses the new symbol. Or even better, fold these two changes into one.
I'll add some kerneldoc to it before I make it part of my series, it might as well be part of the same thing. Thanks for the ack!
Quoted 3 lines
Not sure if four more characters should be spent on the symbol's name (
fw_get_request_speed). If you already thought about it and preferredfw_request_speed, keep it that way.
I did briefly consider it but I came up with 'fw_request_get_speed()' and didn't like it. fw_get_request_speed() makes sense to me though so I'll make the change before I send it out again.
Quoted 6 lines
There are at least two alternatives to your proposal:
- We could move the definition of struct
fw_requestfromdrivers/firewire/core-transaction.ctoinclude/linux/firewire.h. That would make for a rather bad driver API though.
Quoted 7 lines
- We could expand the function type
fw_address_callback_t()by a speed argument. The other users of the API (firewire-core itself, firewire-sbp2, firewire-net, firedtv, snd-firewire-lib, and other as yet unmerged firewire sound drivers) and any other perceivable future user of the API would not care of that speed though.I.e. the proposed "get speed of request" helper seems better.
Great!
Thanks,
Chris
Signature · 2 lines
Chris Boot [email protected]