Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset e9d600c2 in mainline


Ignore:
Timestamp:
2017-12-21T09:03:55Z (4 years ago)
Author:
Petr Mánek <petr.manek@…>
Branches:
lfn, master
Children:
ad2a8b1
Parents:
cec130b
Message:

usbdiag: added interrupt endpoint tests, printing tmon device path

Location:
uspace
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/tmon/commands.h

    rcec130b re9d600c2  
    3838
    3939int tmon_list(int, char **);
     40int tmon_stress_intr_in(int, char **);
     41int tmon_stress_intr_out(int, char **);
    4042int tmon_stress_bulk_in(int, char **);
    4143int tmon_stress_bulk_out(int, char **);
  • uspace/app/tmon/main.c

    rcec130b re9d600c2  
    5353        },
    5454        {
     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        {
    5565                .name = "stress-bulk-in",
    5666                .description = "Stress benchmark bulk in endpoints of a diagnostic device.",
     
    5969        {
    6070                .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.",
    6272                .action = tmon_stress_bulk_out,
    6373        },
  • uspace/app/tmon/test.c

    rcec130b re9d600c2  
    4444
    4545#define NAME "tmon"
     46#define MAX_PATH_LENGTH 1024
     47
     48#define DEFAULT_CYCLES  1024
     49#define DEFAULT_SIZE    65432
    4650
    4751static int resolve_default_fun(devman_handle_t *fun)
     
    97101}
    98102
    99 static int resolve_and_test(int argc, char *argv[], int (*test)(devman_handle_t)) {
     103static int resolve_and_test(int argc, char *argv[], int (*test)(devman_handle_t, int, size_t)) {
    100104        devman_handle_t fun = -1;
    101105
     
    111115        }
    112116
    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
     131static 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
     148static 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
     165static 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
    122169        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
     182static 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
    139186        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
     199int tmon_stress_intr_in(int argc, char *argv[])
     200{
     201        return resolve_and_test(argc, argv, stress_intr_in);
     202}
     203
     204int tmon_stress_intr_out(int argc, char *argv[])
     205{
     206        return resolve_and_test(argc, argv, stress_intr_out);
    148207}
    149208
  • uspace/drv/bus/usb/usbdiag/tests.c

    rcec130b re9d600c2  
    4141#define NAME "usbdiag"
    4242
     43
     44int 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
     71int 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}
    43111
    44112int usb_diag_stress_bulk_out(usb_diag_dev_t *dev, int cycles, size_t size)
  • uspace/drv/bus/usb/usbdiag/tests.h

    rcec130b re9d600c2  
    3939#include "device.h"
    4040
     41int usb_diag_stress_intr_out(usb_diag_dev_t *, int, size_t);
     42int usb_diag_stress_intr_in(usb_diag_dev_t *, int, size_t);
    4143int usb_diag_stress_bulk_out(usb_diag_dev_t *, int, size_t);
    4244int usb_diag_stress_bulk_in(usb_diag_dev_t *, int, size_t);
  • uspace/lib/drv/generic/remote_usbdiag.c

    rcec130b re9d600c2  
    4343
    4444typedef 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
    4749} usb_iface_funcs_t;
    4850
     
    5860}
    5961
    60 int usbdiag_stress_bulk_out(async_exch_t *exch, int cycles, size_t size)
     62int usbdiag_stress_intr_in(async_exch_t *exch, int cycles, size_t size)
    6163{
    6264        if (!exch)
    6365                return EBADMEM;
    6466
    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
     70int 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);
    6676}
    6777
     
    7484}
    7585
     86int 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
     94static void remote_usbdiag_stress_intr_in(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     95static void remote_usbdiag_stress_intr_out(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     96static void remote_usbdiag_stress_bulk_in(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    7697static 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 *);
    7898
    7999/** Remote USB diagnostic interface operations. */
    80100static 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
    83105};
    84106
     
    89111};
    90112
    91 void remote_usbdiag_stress_bulk_out(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
     113void 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
     128void remote_usbdiag_stress_intr_out(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
    92129{
    93130        const usbdiag_iface_t *diag_iface = (usbdiag_iface_t *) iface;
     
    100137        int cycles = DEV_IPC_GET_ARG1(*call);
    101138        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);
    103140        async_answer_0(callid, ret);
    104141}
     
    119156}
    120157
     158void 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
    121173/**
    122174 * @}
  • uspace/lib/drv/include/usbdiag_iface.h

    rcec130b re9d600c2  
    4545async_sess_t *usbdiag_connect(devman_handle_t);
    4646void usbdiag_disconnect(async_sess_t*);
     47int usbdiag_stress_intr_in(async_exch_t*, int, size_t);
     48int usbdiag_stress_intr_out(async_exch_t*, int, size_t);
    4749int usbdiag_stress_bulk_in(async_exch_t*, int, size_t);
    4850int usbdiag_stress_bulk_out(async_exch_t*, int, size_t);
     
    5052/** USB diagnostic device communication interface. */
    5153typedef struct {
     54        int (*stress_intr_in)(ddf_fun_t*, int, size_t);
     55        int (*stress_intr_out)(ddf_fun_t*, int, size_t);
    5256        int (*stress_bulk_in)(ddf_fun_t*, int, size_t);
    5357        int (*stress_bulk_out)(ddf_fun_t*, int, size_t);
Note: See TracChangeset for help on using the changeset viewer.