usbip: add USBIP_URB_* URB transfer flags
Subsystems (3)
Shuah Khan
maintainerPATCH v2 1/1 usbip: add USBIP_URB_* URB transfer flags
USBIP driver packs URB transfer flags in network packets that are exchanged between Server (usbip_host) and Client (vhci_hcd).
URB_* flags are internal to kernel and could change. Where as USBIP URB flags exchanged in network packets are USBIP user API must not change.
Add USBIP_URB* flags to make this an explicit API and change the client and server to map them. Details as follows:
Client tx path (USBIP_CMD_SUBMIT):
- Maps URB_* to USBIP_URB_* when it sends USBIP_CMD_SUBMIT packet.
Server rx path (USBIP_CMD_SUBMIT):
- Maps USBIP_URB_* to URB_* when it receives USBIP_CMD_SUBMIT packet.
Flags aren't included in USBIP_CMD_UNLINK and USBIP_RET_SUBMIT packets and no special handling is needed for them in the following cases:
- Server rx path (USBIP_CMD_UNLINK)
- Client rx path & Server tx path (USBIP_RET_SUBMIT)
Update protocol documentation to reflect the change.
---
Changes since v1: addressed review comments
Documentation/usb/usbip_protocol.rst | 13 ++-- drivers/usb/usbip/stub_rx.c | 4 +- drivers/usb/usbip/usbip_common.c | 91 +++++++++++++++++++++++++++- include/uapi/linux/usbip.h | 26 ++++++++ 4 files changed, 122 insertions(+), 12 deletions(-)
Documentation/usb/usbip_protocol.rst +6 -7
@@ -340,13 +340,12 @@ USBIP_CMD_SUBMIT: | 0 | 20 | usbip_header_basic, 'command' shall be 0x00000001 | +-----------+--------+---------------------------------------------------+ | 0x14 | 4 | transfer_flags: possible values depend on the | -| | | URB transfer_flags (refer to URB doc in | -| | | Documentation/driver-api/usb/URB.rst) | -| | | but with URB_NO_TRANSFER_DMA_MAP masked. Refer to | -| | | function usbip_pack_cmd_submit and function | -| | | tweak_transfer_flags in drivers/usb/usbip/ | -| | | usbip_common.c. The following fields may also ref | -| | | to function usbip_pack_cmd_submit and URB doc | +| | | USBIP_URB transfer_flags. | +| | | Refer to include/uapi/linux/usbip.h and | +| | | Documentation/driver-api/usb/URB.rst. | +| | | Refer to usbip_pack_cmd_submit() and | +| | | tweak_transfer_flags() in drivers/usb/usbip/ | +| | | usbip_common.c. | +-----------+--------+---------------------------------------------------+ | 0x18 | 4 | transfer_buffer_length: | | | | use URB transfer_buffer_length |
drivers/usb/usbip/stub_rx.c +2 -2
@@ -464,7 +464,7 @@ static void stub_recv_cmd_submit(struct stub_device *sdev,int nents;int num_urbs =1 ;int pipe =get_pipe (sdev, pdu); -int use_sg = pdu->u.cmd_submit.transfer_flags &URB_DMA_MAP_SG ; +int use_sg = pdu->u.cmd_submit.transfer_flags &USBIP_URB_DMA_MAP_SG ;int support_sg =1 ;int np =0 ;int ret, i;
@@ -514,7 +514,7 @@ static void stub_recv_cmd_submit(struct stub_device *sdev, num_urbs = nents; priv->completed_urbs =0 ; pdu->u.cmd_submit.transfer_flags &= - ~URB_DMA_MAP_SG ; + ~USBIP_URB_DMA_MAP_SG ; } }else { buffer =kzalloc (buf_len,GFP_KERNEL );
drivers/usb/usbip/usbip_common.c +88 -3
108 lines not on this page · raw message
include/uapi/linux/usbip.h +26 -0
@@ -24,4 +24,30 @@ enum usbip_device_status {VDEV_ST_USED ,VDEV_ST_ERROR }; + +/* USB URB Transfer flags: +* +* USBIP server and client (vchi) pack URBs in TCP packets. The following +* are the transfer type defines used in USBIP protocol. +*/ + +#define USBIP_URB_SHORT_NOT_OK 0x0001 +#define USBIP_URB_ISO_ASAP 0x0002 +#define USBIP_URB_NO_TRANSFER_DMA_MAP 0x0004 +#define USBIP_URB_ZERO_PACKET 0x0040 +#define USBIP_URB_NO_INTERRUPT 0x0080 +#define USBIP_URB_FREE_BUFFER 0x0100 +#define USBIP_URB_DIR_IN 0x0200 +#define USBIP_URB_DIR_OUT 0 +#define USBIP_URB_DIR_MASK USBIP_URB_DIR_IN + +#define USBIP_URB_DMA_MAP_SINGLE 0x00010000 +#define USBIP_URB_DMA_MAP_PAGE 0x00020000 +#define USBIP_URB_DMA_MAP_SG 0x00040000 +#define USBIP_URB_MAP_LOCAL 0x00080000 +#define USBIP_URB_SETUP_MAP_SINGLE 0x00100000 +#define USBIP_URB_SETUP_MAP_LOCAL 0x00200000 +#define USBIP_URB_DMA_SG_COMBINED 0x00400000 +#define USBIP_URB_ALIGNED_TEMP_BUFFER 0x00800000 +#endif /* _UAPI_LINUX_USBIP_H */
Signature · 1 line
2.34.1