feat: Improve tcp performance
This commit is contained in:
parent
a78ed0aa8b
commit
f39c6f6c06
|
@ -236,9 +236,9 @@ int fast_reply(uint8_t *buf, uint32_t length)
|
|||
|
||||
#if (USE_WINUSB == 1)
|
||||
uint32_t resLength = item->length;
|
||||
send_stage2_submit_data((usbip_stage2_header *)buf, 0, item->buf, resLength);
|
||||
send_stage2_submit_data_fast((usbip_stage2_header *)buf, 0, item->buf, resLength);
|
||||
#else
|
||||
send_stage2_submit_data((usbip_stage2_header *)buf, 0, item->buf, DAP_HANDLE_SIZE);
|
||||
send_stage2_submit_data_fast((usbip_stage2_header *)buf, 0, item->buf, DAP_HANDLE_SIZE);
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -190,7 +190,7 @@ int emulate(uint8_t *buffer, uint32_t length)
|
|||
int command = read_stage2_command((usbip_stage2_header *)buffer, length);
|
||||
if (command < 0)
|
||||
{
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (command)
|
||||
|
@ -229,7 +229,7 @@ static int read_stage2_command(usbip_stage2_header *header, uint32_t length)
|
|||
* - ret_submit
|
||||
* - cmd_unlink
|
||||
* - ret_unlink
|
||||
*
|
||||
*
|
||||
* @param data Point to packets header
|
||||
* @param size Packets header size
|
||||
*/
|
||||
|
@ -253,7 +253,7 @@ static void pack(void *data, int size)
|
|||
* - ret_submit
|
||||
* - cmd_unlink
|
||||
* - ret_unlink
|
||||
*
|
||||
*
|
||||
* @param data Point to packets header
|
||||
* @param size packets header size
|
||||
*/
|
||||
|
@ -355,6 +355,26 @@ void send_stage2_submit_data(usbip_stage2_header *req_header, int32_t status, co
|
|||
}
|
||||
}
|
||||
|
||||
void send_stage2_submit_data_fast(usbip_stage2_header *req_header, int32_t status, const void *const data, int32_t data_length)
|
||||
{
|
||||
const uint8_t * send_buf = (uint8_t *)req_header;
|
||||
|
||||
req_header->base.command = USBIP_STAGE2_RSP_SUBMIT;
|
||||
req_header->base.direction = !(req_header->base.direction);
|
||||
|
||||
memset(&(req_header->u.ret_submit), 0, sizeof(usbip_stage2_header_ret_submit));
|
||||
|
||||
req_header->u.ret_submit.status = status;
|
||||
req_header->u.ret_submit.data_length = data_length;
|
||||
|
||||
pack(req_header, sizeof(usbip_stage2_header));
|
||||
|
||||
// payload
|
||||
memcpy(&send_buf[sizeof(usbip_stage2_header)], data, data_length);
|
||||
send(kSock, send_buf, sizeof(usbip_stage2_header) + data_length, 0);
|
||||
}
|
||||
|
||||
|
||||
static void handle_unlink(usbip_stage2_header *header)
|
||||
{
|
||||
os_printf("s2 handling cmd unlink...\r\n");
|
||||
|
|
|
@ -15,5 +15,7 @@ int attach(uint8_t *buffer, uint32_t length);
|
|||
int emulate(uint8_t *buffer, uint32_t length);
|
||||
void send_stage2_submit_data(usbip_stage2_header *req_header, int32_t status, const void * const data, int32_t data_length);
|
||||
void send_stage2_submit(usbip_stage2_header *req_header, int32_t status, int32_t data_length);
|
||||
void send_stage2_submit_data_fast(usbip_stage2_header *req_header, int32_t status, const void *const data, int32_t data_length);
|
||||
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue