jtag/drivers/cmsis_dap: introduce packet_usable_size
USB bulk backend needs to avoid zero sized USB packets sent after each full sized packed for performance reasons. HID backend uses fixed size HID reports so the full size of the report can be utilized. Introduce packet_usable_size to reflect it. Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Change-Id: I34094c9edac5730624480711cbd6aa65883c47c7 Reviewed-on: https://review.openocd.org/c/openocd/+/7363 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
parent
600d0165cc
commit
3d3d35c9b8
|
@ -229,7 +229,7 @@ static int pending_scan_result_count;
|
|||
static struct pending_scan_result pending_scan_results[MAX_PENDING_SCAN_RESULTS];
|
||||
|
||||
/* queued JTAG sequences that will be executed on the next flush */
|
||||
#define QUEUED_SEQ_BUF_LEN (cmsis_dap_handle->packet_size - 3)
|
||||
#define QUEUED_SEQ_BUF_LEN (cmsis_dap_handle->packet_usable_size - 3)
|
||||
static int queued_seq_count;
|
||||
static int queued_seq_buf_end;
|
||||
static int queued_seq_tdo_ptr;
|
||||
|
|
|
@ -27,6 +27,7 @@ struct cmsis_dap {
|
|||
struct cmsis_dap_backend_data *bdata;
|
||||
const struct cmsis_dap_backend *backend;
|
||||
unsigned int packet_size;
|
||||
unsigned int packet_usable_size;
|
||||
unsigned int packet_buffer_size;
|
||||
uint8_t *packet_buffer;
|
||||
uint8_t *command;
|
||||
|
|
|
@ -352,25 +352,17 @@ static int cmsis_dap_usb_open(struct cmsis_dap *dap, uint16_t vids[], uint16_t p
|
|||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
dap->packet_size = packet_size;
|
||||
dap->packet_buffer_size = packet_size;
|
||||
dap->bdata->usb_ctx = ctx;
|
||||
dap->bdata->dev_handle = dev_handle;
|
||||
dap->bdata->ep_out = ep_out;
|
||||
dap->bdata->ep_in = ep_in;
|
||||
dap->bdata->interface = interface_num;
|
||||
|
||||
dap->packet_buffer = malloc(dap->packet_buffer_size);
|
||||
if (!dap->packet_buffer) {
|
||||
LOG_ERROR("unable to allocate memory");
|
||||
err = cmsis_dap_usb_alloc(dap, packet_size);
|
||||
if (err != ERROR_OK)
|
||||
cmsis_dap_usb_close(dap);
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
dap->command = dap->packet_buffer;
|
||||
dap->response = dap->packet_buffer;
|
||||
|
||||
return ERROR_OK;
|
||||
return err;
|
||||
}
|
||||
|
||||
libusb_close(dev_handle);
|
||||
|
@ -445,6 +437,8 @@ static int cmsis_dap_usb_alloc(struct cmsis_dap *dap, unsigned int pkt_sz)
|
|||
dap->packet_buffer = buf;
|
||||
dap->packet_size = pkt_sz;
|
||||
dap->packet_buffer_size = pkt_sz;
|
||||
/* Prevent sending zero size USB packets */
|
||||
dap->packet_usable_size = pkt_sz - 1;
|
||||
|
||||
dap->command = dap->packet_buffer;
|
||||
dap->response = dap->packet_buffer;
|
||||
|
|
|
@ -213,6 +213,7 @@ static int cmsis_dap_hid_alloc(struct cmsis_dap *dap, unsigned int pkt_sz)
|
|||
|
||||
dap->packet_buffer = buf;
|
||||
dap->packet_size = pkt_sz;
|
||||
dap->packet_usable_size = pkt_sz;
|
||||
dap->packet_buffer_size = packet_buffer_size;
|
||||
|
||||
dap->command = dap->packet_buffer + REPORT_ID_SIZE;
|
||||
|
|
Loading…
Reference in New Issue