Changeset e9d600c2 in mainline
- Timestamp:
- 2017-12-21T09:03:55Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ad2a8b1
- Parents:
- cec130b
- Location:
- uspace
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/tmon/commands.h
rcec130b re9d600c2 38 38 39 39 int tmon_list(int, char **); 40 int tmon_stress_intr_in(int, char **); 41 int tmon_stress_intr_out(int, char **); 40 42 int tmon_stress_bulk_in(int, char **); 41 43 int tmon_stress_bulk_out(int, char **); -
uspace/app/tmon/main.c
rcec130b re9d600c2 53 53 }, 54 54 { 55 .name = "stress-intr-in", 56 .description = "Stress benchmark interrupt in endpoints of a diagnostic device.", 57 .action = tmon_stress_intr_in, 58 }, 59 { 60 .name = "stress-intr-out", 61 .description = "Stress benchmark interrupt out endpoints of a diagnostic device.", 62 .action = tmon_stress_intr_out, 63 }, 64 { 55 65 .name = "stress-bulk-in", 56 66 .description = "Stress benchmark bulk in endpoints of a diagnostic device.", … … 59 69 { 60 70 .name = "stress-bulk-out", 61 .description = " Benchmark bulk out endpoints of a diagnostic device.",71 .description = "Stress benchmark bulk out endpoints of a diagnostic device.", 62 72 .action = tmon_stress_bulk_out, 63 73 }, -
uspace/app/tmon/test.c
rcec130b re9d600c2 44 44 45 45 #define NAME "tmon" 46 #define MAX_PATH_LENGTH 1024 47 48 #define DEFAULT_CYCLES 1024 49 #define DEFAULT_SIZE 65432 46 50 47 51 static int resolve_default_fun(devman_handle_t *fun) … … 97 101 } 98 102 99 static int resolve_and_test(int argc, char *argv[], int (*test)(devman_handle_t )) {103 static int resolve_and_test(int argc, char *argv[], int (*test)(devman_handle_t, int, size_t)) { 100 104 devman_handle_t fun = -1; 101 105 … … 111 115 } 112 116 113 return test(fun); 114 } 115 116 static int stress_bulk_in(devman_handle_t fun) { 117 async_sess_t *sess = usbdiag_connect(fun); 118 async_exch_t *exch = async_exchange_begin(sess); 119 120 const int cycles = 1024; 121 const size_t size = 65432; 117 int rc; 118 char path[MAX_PATH_LENGTH]; 119 if ((rc = devman_fun_get_path(fun, path, sizeof(path)))) { 120 printf(NAME ": Error resolving path of device with handle %ld. %s\n", fun, str_error(rc)); 121 return 1; 122 } 123 124 printf("Using device: %s\n", path); 125 126 // TODO: Read options here. 127 128 return test(fun, DEFAULT_CYCLES, DEFAULT_SIZE); 129 } 130 131 static int stress_intr_in(devman_handle_t fun, int cycles, size_t size) { 132 async_sess_t *sess = usbdiag_connect(fun); 133 async_exch_t *exch = async_exchange_begin(sess); 134 135 int rc = usbdiag_stress_intr_in(exch, cycles, size); 136 int ec = 0; 137 138 if (rc) { 139 printf(NAME ": %s\n", str_error(rc)); 140 ec = 1; 141 } 142 143 async_exchange_end(exch); 144 usbdiag_disconnect(sess); 145 return ec; 146 } 147 148 static int stress_intr_out(devman_handle_t fun, int cycles, size_t size) { 149 async_sess_t *sess = usbdiag_connect(fun); 150 async_exch_t *exch = async_exchange_begin(sess); 151 152 int rc = usbdiag_stress_intr_out(exch, cycles, size); 153 int ec = 0; 154 155 if (rc) { 156 printf(NAME ": %s\n", str_error(rc)); 157 ec = 1; 158 } 159 160 async_exchange_end(exch); 161 usbdiag_disconnect(sess); 162 return ec; 163 } 164 165 static int stress_bulk_in(devman_handle_t fun, int cycles, size_t size) { 166 async_sess_t *sess = usbdiag_connect(fun); 167 async_exch_t *exch = async_exchange_begin(sess); 168 122 169 int rc = usbdiag_stress_bulk_in(exch, cycles, size); 123 124 if (rc) { 125 printf(NAME ": %s\n", str_error(rc));126 }127 128 async_exchange_end(exch);129 usbdiag_disconnect(sess); 130 return 0;131 } 132 133 static int stress_bulk_out(devman_handle_t fun) { 134 async_sess_t *sess = usbdiag_connect(fun); 135 async_exch_t *exch = async_exchange_begin(sess); 136 137 const int cycles = 1024;138 const size_t size = 65432; 170 int ec = 0; 171 172 if (rc) { 173 printf(NAME ": %s\n", str_error(rc)); 174 ec = 1; 175 } 176 177 async_exchange_end(exch); 178 usbdiag_disconnect(sess); 179 return ec; 180 } 181 182 static int stress_bulk_out(devman_handle_t fun, int cycles, size_t size) { 183 async_sess_t *sess = usbdiag_connect(fun); 184 async_exch_t *exch = async_exchange_begin(sess); 185 139 186 int rc = usbdiag_stress_bulk_out(exch, cycles, size); 140 141 if (rc) { 142 printf(NAME ": %s\n", str_error(rc)); 143 } 144 145 async_exchange_end(exch); 146 usbdiag_disconnect(sess); 147 return 0; 187 int ec = 0; 188 189 if (rc) { 190 printf(NAME ": %s\n", str_error(rc)); 191 ec = 1; 192 } 193 194 async_exchange_end(exch); 195 usbdiag_disconnect(sess); 196 return ec; 197 } 198 199 int tmon_stress_intr_in(int argc, char *argv[]) 200 { 201 return resolve_and_test(argc, argv, stress_intr_in); 202 } 203 204 int tmon_stress_intr_out(int argc, char *argv[]) 205 { 206 return resolve_and_test(argc, argv, stress_intr_out); 148 207 } 149 208 -
uspace/drv/bus/usb/usbdiag/tests.c
rcec130b re9d600c2 41 41 #define NAME "usbdiag" 42 42 43 44 int usb_diag_stress_intr_out(usb_diag_dev_t *dev, int cycles, size_t size) 45 { 46 if (!dev) 47 return EBADMEM; 48 49 char *buffer = (char *) malloc(size); 50 if (!buffer) 51 return ENOMEM; 52 53 memset(buffer, 42, size); 54 55 // TODO: Are we sure that no other test is running on this endpoint? 56 57 usb_log_info("Performing interrupt out stress test on device %s.", ddf_fun_get_name(dev->fun)); 58 int rc = EOK; 59 for (int i = 0; i < cycles; ++i) { 60 // Write buffer to device. 61 if ((rc = usb_pipe_write(dev->intr_out, buffer, size))) { 62 usb_log_error("Interrupt OUT write failed. %s\n", str_error(rc)); 63 break; 64 } 65 } 66 67 free(buffer); 68 return rc; 69 } 70 71 int usb_diag_stress_intr_in(usb_diag_dev_t *dev, int cycles, size_t size) 72 { 73 if (!dev) 74 return EBADMEM; 75 76 char *buffer = (char *) malloc(size); 77 if (!buffer) 78 return ENOMEM; 79 80 // TODO: Are we sure that no other test is running on this endpoint? 81 82 usb_log_info("Performing interrupt in stress test on device %s.", ddf_fun_get_name(dev->fun)); 83 int rc = EOK; 84 for (int i = 0; i < cycles; ++i) { 85 // Read device's response. 86 size_t remaining = size; 87 size_t transferred; 88 89 while (remaining > 0) { 90 if ((rc = usb_pipe_read(dev->intr_in, buffer + size - remaining, remaining, &transferred))) { 91 usb_log_error("Interrupt IN read failed. %s\n", str_error(rc)); 92 break; 93 } 94 95 if (transferred > remaining) { 96 usb_log_error("Interrupt IN read more than expected.\n"); 97 rc = EINVAL; 98 break; 99 } 100 101 remaining -= transferred; 102 } 103 104 if (rc) 105 break; 106 } 107 108 free(buffer); 109 return rc; 110 } 43 111 44 112 int usb_diag_stress_bulk_out(usb_diag_dev_t *dev, int cycles, size_t size) -
uspace/drv/bus/usb/usbdiag/tests.h
rcec130b re9d600c2 39 39 #include "device.h" 40 40 41 int usb_diag_stress_intr_out(usb_diag_dev_t *, int, size_t); 42 int usb_diag_stress_intr_in(usb_diag_dev_t *, int, size_t); 41 43 int usb_diag_stress_bulk_out(usb_diag_dev_t *, int, size_t); 42 44 int usb_diag_stress_bulk_in(usb_diag_dev_t *, int, size_t); -
uspace/lib/drv/generic/remote_usbdiag.c
rcec130b re9d600c2 43 43 44 44 typedef enum { 45 IPC_M_USBDIAG_STRESS_BULK_OUT, 46 IPC_M_USBDIAG_STRESS_BULK_IN 45 IPC_M_USBDIAG_STRESS_INTR_IN, 46 IPC_M_USBDIAG_STRESS_INTR_OUT, 47 IPC_M_USBDIAG_STRESS_BULK_IN, 48 IPC_M_USBDIAG_STRESS_BULK_OUT 47 49 } usb_iface_funcs_t; 48 50 … … 58 60 } 59 61 60 int usbdiag_stress_ bulk_out(async_exch_t *exch, int cycles, size_t size)62 int usbdiag_stress_intr_in(async_exch_t *exch, int cycles, size_t size) 61 63 { 62 64 if (!exch) 63 65 return EBADMEM; 64 66 65 return async_req_3_0(exch, DEV_IFACE_ID(USBDIAG_DEV_IFACE), IPC_M_USBDIAG_STRESS_BULK_OUT, cycles, size); 67 return async_req_3_0(exch, DEV_IFACE_ID(USBDIAG_DEV_IFACE), IPC_M_USBDIAG_STRESS_INTR_IN, cycles, size); 68 } 69 70 int usbdiag_stress_intr_out(async_exch_t *exch, int cycles, size_t size) 71 { 72 if (!exch) 73 return EBADMEM; 74 75 return async_req_3_0(exch, DEV_IFACE_ID(USBDIAG_DEV_IFACE), IPC_M_USBDIAG_STRESS_INTR_OUT, cycles, size); 66 76 } 67 77 … … 74 84 } 75 85 86 int usbdiag_stress_bulk_out(async_exch_t *exch, int cycles, size_t size) 87 { 88 if (!exch) 89 return EBADMEM; 90 91 return async_req_3_0(exch, DEV_IFACE_ID(USBDIAG_DEV_IFACE), IPC_M_USBDIAG_STRESS_BULK_OUT, cycles, size); 92 } 93 94 static void remote_usbdiag_stress_intr_in(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 95 static void remote_usbdiag_stress_intr_out(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 96 static void remote_usbdiag_stress_bulk_in(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 76 97 static void remote_usbdiag_stress_bulk_out(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *); 77 static void remote_usbdiag_stress_bulk_in(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);78 98 79 99 /** Remote USB diagnostic interface operations. */ 80 100 static const remote_iface_func_ptr_t remote_usbdiag_iface_ops [] = { 81 [IPC_M_USBDIAG_STRESS_BULK_OUT] = remote_usbdiag_stress_bulk_out, 82 [IPC_M_USBDIAG_STRESS_BULK_IN] = remote_usbdiag_stress_bulk_in, 101 [ IPC_M_USBDIAG_STRESS_INTR_IN] = remote_usbdiag_stress_intr_in, 102 [IPC_M_USBDIAG_STRESS_INTR_OUT] = remote_usbdiag_stress_intr_out, 103 [ IPC_M_USBDIAG_STRESS_BULK_IN] = remote_usbdiag_stress_bulk_in, 104 [IPC_M_USBDIAG_STRESS_BULK_OUT] = remote_usbdiag_stress_bulk_out 83 105 }; 84 106 … … 89 111 }; 90 112 91 void remote_usbdiag_stress_bulk_out(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call) 113 void remote_usbdiag_stress_intr_in(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call) 114 { 115 const usbdiag_iface_t *diag_iface = (usbdiag_iface_t *) iface; 116 117 if (diag_iface->stress_bulk_in == NULL) { 118 async_answer_0(callid, ENOTSUP); 119 return; 120 } 121 122 int cycles = DEV_IPC_GET_ARG1(*call); 123 size_t size = DEV_IPC_GET_ARG2(*call); 124 const int ret = diag_iface->stress_intr_in(fun, cycles, size); 125 async_answer_0(callid, ret); 126 } 127 128 void remote_usbdiag_stress_intr_out(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call) 92 129 { 93 130 const usbdiag_iface_t *diag_iface = (usbdiag_iface_t *) iface; … … 100 137 int cycles = DEV_IPC_GET_ARG1(*call); 101 138 size_t size = DEV_IPC_GET_ARG2(*call); 102 const int ret = diag_iface->stress_ bulk_out(fun, cycles, size);139 const int ret = diag_iface->stress_intr_out(fun, cycles, size); 103 140 async_answer_0(callid, ret); 104 141 } … … 119 156 } 120 157 158 void remote_usbdiag_stress_bulk_out(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call) 159 { 160 const usbdiag_iface_t *diag_iface = (usbdiag_iface_t *) iface; 161 162 if (diag_iface->stress_bulk_out == NULL) { 163 async_answer_0(callid, ENOTSUP); 164 return; 165 } 166 167 int cycles = DEV_IPC_GET_ARG1(*call); 168 size_t size = DEV_IPC_GET_ARG2(*call); 169 const int ret = diag_iface->stress_bulk_out(fun, cycles, size); 170 async_answer_0(callid, ret); 171 } 172 121 173 /** 122 174 * @} -
uspace/lib/drv/include/usbdiag_iface.h
rcec130b re9d600c2 45 45 async_sess_t *usbdiag_connect(devman_handle_t); 46 46 void usbdiag_disconnect(async_sess_t*); 47 int usbdiag_stress_intr_in(async_exch_t*, int, size_t); 48 int usbdiag_stress_intr_out(async_exch_t*, int, size_t); 47 49 int usbdiag_stress_bulk_in(async_exch_t*, int, size_t); 48 50 int usbdiag_stress_bulk_out(async_exch_t*, int, size_t); … … 50 52 /** USB diagnostic device communication interface. */ 51 53 typedef struct { 54 int (*stress_intr_in)(ddf_fun_t*, int, size_t); 55 int (*stress_intr_out)(ddf_fun_t*, int, size_t); 52 56 int (*stress_bulk_in)(ddf_fun_t*, int, size_t); 53 57 int (*stress_bulk_out)(ddf_fun_t*, int, size_t);
Note:
See TracChangeset
for help on using the changeset viewer.