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

Changeset ff16da5f in mainline


Ignore:
Timestamp:
2017-12-21T14:37:30Z (4 years ago)
Author:
Petr Mánek <petr.manek@…>
Branches:
lfn, master
Children:
119a794
Parents:
74c0de0
git-author:
Petr Mánek <petr.manek@…> (2017-12-21 14:37:23)
git-committer:
Petr Mánek <petr.manek@…> (2017-12-21 14:37:30)
Message:

usbdiag: added isochronous test

Location:
uspace
Files:
8 edited

Legend:

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

    r74c0de0 rff16da5f  
    4242int tmon_stress_bulk_in(int, char **);
    4343int tmon_stress_bulk_out(int, char **);
     44int tmon_stress_isoch_in(int, char **);
     45int tmon_stress_isoch_out(int, char **);
    4446
    4547#endif /* TMON_COMMANDS_H_ */
  • uspace/app/tmon/main.c

    r74c0de0 rff16da5f  
    7373        },
    7474        {
     75                .name = "stress-isoch-in",
     76                .description = "Stress benchmark isochronous in endpoints of a device.",
     77                .action = tmon_stress_isoch_in,
     78        },
     79        {
     80                .name = "stress-isoch-out",
     81                .description = "Stress benchmark isochronous out endpoints of a device.",
     82                .action = tmon_stress_isoch_out,
     83        },
     84        {
    7585                .name = NULL
    7686        }
  • uspace/app/tmon/stress_test.c

    r74c0de0 rff16da5f  
    130130}
    131131
     132static int run_isoch_in(async_exch_t *exch, const tmon_test_params_t *generic_params)
     133{
     134        const tmon_stress_test_params_t *params = (tmon_stress_test_params_t *) generic_params;
     135        printf("Executing isochronous in stress test.\n"
     136            "      Packet count: %d\n"
     137            "      Packet size: %ld\n", params->cycles, params->size);
     138
     139        int rc = usbdiag_stress_isoch_in(exch, params->cycles, params->size);
     140        if (rc) {
     141                printf(NAME ": Test failed. %s\n", str_error(rc));
     142                return 1;
     143        }
     144
     145        return 0;
     146}
     147
     148static int run_isoch_out(async_exch_t *exch, const tmon_test_params_t *generic_params)
     149{
     150        const tmon_stress_test_params_t *params = (tmon_stress_test_params_t *) generic_params;
     151        printf("Executing isochronous out stress test.\n"
     152            "      Packet count: %d\n"
     153            "      Packet size: %ld\n", params->cycles, params->size);
     154
     155        int rc = usbdiag_stress_isoch_out(exch, params->cycles, params->size);
     156        if (rc) {
     157                printf(NAME ": Test failed. %s\n", str_error(rc));
     158                return 1;
     159        }
     160
     161        return 0;
     162}
     163
    132164int tmon_stress_intr_in(int argc, char *argv[])
    133165{
     
    170202}
    171203
     204int tmon_stress_isoch_in(int argc, char *argv[])
     205{
     206        static const tmon_test_ops_t ops = {
     207                .run = run_isoch_in,
     208                .read_params = read_params
     209        };
     210
     211        return tmon_test_main(argc, argv, &ops);
     212}
     213
     214int tmon_stress_isoch_out(int argc, char *argv[])
     215{
     216        static const tmon_test_ops_t ops = {
     217                .run = run_isoch_out,
     218                .read_params = read_params
     219        };
     220
     221        return tmon_test_main(argc, argv, &ops);
     222}
     223
    172224/** @}
    173225 */
  • uspace/drv/bus/usb/usbdiag/device.c

    r74c0de0 rff16da5f  
    5353        }
    5454
     55TRANSLATE_FUNC(usb_diag_stress_intr_out)
     56TRANSLATE_FUNC(usb_diag_stress_intr_in)
    5557TRANSLATE_FUNC(usb_diag_stress_bulk_out)
    5658TRANSLATE_FUNC(usb_diag_stress_bulk_in)
    57 TRANSLATE_FUNC(usb_diag_stress_intr_out)
    58 TRANSLATE_FUNC(usb_diag_stress_intr_in)
     59TRANSLATE_FUNC(usb_diag_stress_isoch_out)
     60TRANSLATE_FUNC(usb_diag_stress_isoch_in)
    5961
    6062static usbdiag_iface_t diag_interface = {
     63        .stress_intr_out = TRANSLATE_FUNC_NAME(usb_diag_stress_intr_out),
     64        .stress_intr_in = TRANSLATE_FUNC_NAME(usb_diag_stress_intr_in),
    6165        .stress_bulk_out = TRANSLATE_FUNC_NAME(usb_diag_stress_bulk_out),
    6266        .stress_bulk_in = TRANSLATE_FUNC_NAME(usb_diag_stress_bulk_in),
    63         .stress_intr_out = TRANSLATE_FUNC_NAME(usb_diag_stress_intr_out),
    64         .stress_intr_in = TRANSLATE_FUNC_NAME(usb_diag_stress_intr_in)
     67        .stress_isoch_out = TRANSLATE_FUNC_NAME(usb_diag_stress_isoch_out),
     68        .stress_isoch_in = TRANSLATE_FUNC_NAME(usb_diag_stress_isoch_in)
    6569};
    6670
  • uspace/drv/bus/usb/usbdiag/tests.c

    r74c0de0 rff16da5f  
    178178}
    179179
     180int usb_diag_stress_isoch_out(usb_diag_dev_t *dev, int cycles, size_t size)
     181{
     182        if (!dev)
     183                return EBADMEM;
     184
     185        char *buffer = (char *) malloc(size);
     186        if (!buffer)
     187                return ENOMEM;
     188
     189        memset(buffer, 42, size);
     190
     191        // TODO: Are we sure that no other test is running on this endpoint?
     192
     193        usb_log_info("Performing isochronous out stress test on device %s.", ddf_fun_get_name(dev->fun));
     194        int rc = EOK;
     195        for (int i = 0; i < cycles; ++i) {
     196                // Write buffer to device.
     197                if ((rc = usb_pipe_write(dev->isoch_out, buffer, size))) {
     198                        usb_log_error("Isochronous OUT write failed. %s\n", str_error(rc));
     199                        break;
     200                }
     201        }
     202
     203        free(buffer);
     204        return rc;
     205}
     206
     207int usb_diag_stress_isoch_in(usb_diag_dev_t *dev, int cycles, size_t size)
     208{
     209        if (!dev)
     210                return EBADMEM;
     211
     212        char *buffer = (char *) malloc(size);
     213        if (!buffer)
     214                return ENOMEM;
     215
     216        // TODO: Are we sure that no other test is running on this endpoint?
     217
     218        usb_log_info("Performing isochronous in stress test on device %s.", ddf_fun_get_name(dev->fun));
     219        int rc = EOK;
     220        for (int i = 0; i < cycles; ++i) {
     221                // Read device's response.
     222                size_t remaining = size;
     223                size_t transferred;
     224
     225                while (remaining > 0) {
     226                        if ((rc = usb_pipe_read(dev->isoch_in, buffer + size - remaining, remaining, &transferred))) {
     227                                usb_log_error("Isochronous IN read failed. %s\n", str_error(rc));
     228                                break;
     229                        }
     230
     231                        if (transferred > remaining) {
     232                                usb_log_error("Isochronous IN read more than expected.\n");
     233                                rc = EINVAL;
     234                                break;
     235                        }
     236
     237                        remaining -= transferred;
     238                }
     239
     240                if (rc)
     241                        break;
     242        }
     243
     244        free(buffer);
     245        return rc;
     246}
     247
    180248/**
    181249 * @}
  • uspace/drv/bus/usb/usbdiag/tests.h

    r74c0de0 rff16da5f  
    4343int usb_diag_stress_bulk_out(usb_diag_dev_t *, int, size_t);
    4444int usb_diag_stress_bulk_in(usb_diag_dev_t *, int, size_t);
     45int usb_diag_stress_isoch_out(usb_diag_dev_t *, int, size_t);
     46int usb_diag_stress_isoch_in(usb_diag_dev_t *, int, size_t);
    4547
    4648#endif /* USB_DIAG_TESTS_H_ */
  • uspace/lib/drv/generic/remote_usbdiag.c

    r74c0de0 rff16da5f  
    4646        IPC_M_USBDIAG_STRESS_INTR_OUT,
    4747        IPC_M_USBDIAG_STRESS_BULK_IN,
    48         IPC_M_USBDIAG_STRESS_BULK_OUT
     48        IPC_M_USBDIAG_STRESS_BULK_OUT,
     49        IPC_M_USBDIAG_STRESS_ISOCH_IN,
     50        IPC_M_USBDIAG_STRESS_ISOCH_OUT
    4951} usb_iface_funcs_t;
    5052
     
    9092
    9193        return async_req_3_0(exch, DEV_IFACE_ID(USBDIAG_DEV_IFACE), IPC_M_USBDIAG_STRESS_BULK_OUT, cycles, size);
     94}
     95
     96int usbdiag_stress_isoch_in(async_exch_t *exch, int cycles, size_t size)
     97{
     98        if (!exch)
     99                return EBADMEM;
     100
     101        return async_req_3_0(exch, DEV_IFACE_ID(USBDIAG_DEV_IFACE), IPC_M_USBDIAG_STRESS_ISOCH_IN, cycles, size);
     102}
     103
     104int usbdiag_stress_isoch_out(async_exch_t *exch, int cycles, size_t size)
     105{
     106        if (!exch)
     107                return EBADMEM;
     108
     109        return async_req_3_0(exch, DEV_IFACE_ID(USBDIAG_DEV_IFACE), IPC_M_USBDIAG_STRESS_ISOCH_OUT, cycles, size);
    92110}
    93111
     
    96114static void remote_usbdiag_stress_bulk_in(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    97115static void remote_usbdiag_stress_bulk_out(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     116static void remote_usbdiag_stress_isoch_in(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     117static void remote_usbdiag_stress_isoch_out(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    98118
    99119/** Remote USB diagnostic interface operations. */
    100120static const remote_iface_func_ptr_t remote_usbdiag_iface_ops [] = {
    101 [       IPC_M_USBDIAG_STRESS_INTR_IN] = remote_usbdiag_stress_intr_in,
     121        [IPC_M_USBDIAG_STRESS_INTR_IN] = remote_usbdiag_stress_intr_in,
    102122        [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
     123        [IPC_M_USBDIAG_STRESS_BULK_IN] = remote_usbdiag_stress_bulk_in,
     124        [IPC_M_USBDIAG_STRESS_BULK_OUT] = remote_usbdiag_stress_bulk_out,
     125        [IPC_M_USBDIAG_STRESS_ISOCH_IN] = remote_usbdiag_stress_isoch_in,
     126        [IPC_M_USBDIAG_STRESS_ISOCH_OUT] = remote_usbdiag_stress_isoch_out
    105127};
    106128
     
    171193}
    172194
     195void remote_usbdiag_stress_isoch_in(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
     196{
     197        const usbdiag_iface_t *diag_iface = (usbdiag_iface_t *) iface;
     198
     199        if (diag_iface->stress_isoch_in == NULL) {
     200                async_answer_0(callid, ENOTSUP);
     201                return;
     202        }
     203
     204        int cycles = DEV_IPC_GET_ARG1(*call);
     205        size_t size = DEV_IPC_GET_ARG2(*call);
     206        const int ret = diag_iface->stress_isoch_in(fun, cycles, size);
     207        async_answer_0(callid, ret);
     208}
     209
     210void remote_usbdiag_stress_isoch_out(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
     211{
     212        const usbdiag_iface_t *diag_iface = (usbdiag_iface_t *) iface;
     213
     214        if (diag_iface->stress_isoch_out == NULL) {
     215                async_answer_0(callid, ENOTSUP);
     216                return;
     217        }
     218
     219        int cycles = DEV_IPC_GET_ARG1(*call);
     220        size_t size = DEV_IPC_GET_ARG2(*call);
     221        const int ret = diag_iface->stress_isoch_out(fun, cycles, size);
     222        async_answer_0(callid, ret);
     223}
     224
    173225/**
    174226 * @}
  • uspace/lib/drv/include/usbdiag_iface.h

    r74c0de0 rff16da5f  
    4949int usbdiag_stress_bulk_in(async_exch_t*, int, size_t);
    5050int usbdiag_stress_bulk_out(async_exch_t*, int, size_t);
     51int usbdiag_stress_isoch_in(async_exch_t*, int, size_t);
     52int usbdiag_stress_isoch_out(async_exch_t*, int, size_t);
    5153
    5254/** USB diagnostic device communication interface. */
     
    5658        int (*stress_bulk_in)(ddf_fun_t*, int, size_t);
    5759        int (*stress_bulk_out)(ddf_fun_t*, int, size_t);
     60        int (*stress_isoch_in)(ddf_fun_t*, int, size_t);
     61        int (*stress_isoch_out)(ddf_fun_t*, int, size_t);
    5862} usbdiag_iface_t;
    5963
Note: See TracChangeset for help on using the changeset viewer.