Changeset 8393c73b in mainline for uspace/drv/bus


Ignore:
Timestamp:
2018-02-01T16:10:12Z (8 years ago)
Author:
Petr Manek <petr.manek@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3b5a5e3
Parents:
24c41ba1
git-author:
Petr Manek <petr.manek@…> (2018-02-01 16:09:15)
git-committer:
Petr Manek <petr.manek@…> (2018-02-01 16:10:12)
Message:

drv: refactor usbdiag interface

Location:
uspace/drv/bus/usb/usbdiag
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/usbdiag/device.c

    r24c41ba1 r8393c73b  
    4646
    4747static usbdiag_iface_t diag_interface = {
    48         .burst_intr_in = usbdiag_burst_test_intr_in,
    49         .burst_intr_out = usbdiag_burst_test_intr_out,
    50         .burst_bulk_in = usbdiag_burst_test_bulk_in,
    51         .burst_bulk_out = usbdiag_burst_test_bulk_out,
    52         .burst_isoch_in = usbdiag_burst_test_isoch_in,
    53         .burst_isoch_out = usbdiag_burst_test_isoch_out,
    54         .data_intr_in = usbdiag_data_test_intr_in,
    55         .data_intr_out = usbdiag_data_test_intr_out,
    56         .data_bulk_in = usbdiag_data_test_bulk_in,
    57         .data_bulk_out = usbdiag_data_test_bulk_out,
    58         .data_isoch_in = usbdiag_data_test_isoch_in,
    59         .data_isoch_out = usbdiag_data_test_isoch_out
     48        .test_in = usbdiag_dev_test_in,
     49        .test_out = usbdiag_dev_test_out,
    6050};
    6151
     
    8676        } while (0);
    8777
    88         _MAP_EP(dev->intr_in, INTR_IN);
    89         _MAP_EP(dev->intr_out, INTR_OUT);
    90         _MAP_EP(dev->bulk_in, BULK_IN);
    91         _MAP_EP(dev->bulk_out, BULK_OUT);
    92         _MAP_EP(dev->isoch_in, ISOCH_IN);
    93         _MAP_EP(dev->isoch_out, ISOCH_OUT);
     78        _MAP_EP(dev->burst_intr_in, BURST_INTR_IN);
     79        _MAP_EP(dev->burst_intr_out, BURST_INTR_OUT);
     80        _MAP_EP(dev->burst_bulk_in, BURST_BULK_IN);
     81        _MAP_EP(dev->burst_bulk_out, BURST_BULK_OUT);
     82        _MAP_EP(dev->burst_isoch_in, BURST_ISOCH_IN);
     83        _MAP_EP(dev->burst_isoch_out, BURST_ISOCH_OUT);
     84        _MAP_EP(dev->data_intr_in, DATA_INTR_IN);
     85        _MAP_EP(dev->data_intr_out, DATA_INTR_OUT);
     86        _MAP_EP(dev->data_bulk_in, DATA_BULK_IN);
     87        _MAP_EP(dev->data_bulk_out, DATA_BULK_OUT);
     88        _MAP_EP(dev->data_isoch_in, DATA_ISOCH_IN);
     89        _MAP_EP(dev->data_isoch_out, DATA_ISOCH_OUT);
    9490
    9591#undef _MAP_EP
  • uspace/drv/bus/usb/usbdiag/device.h

    r24c41ba1 r8393c73b  
    4040#include <usb/dev/driver.h>
    4141
    42 #define USBDIAG_EP_INTR_IN    1
    43 #define USBDIAG_EP_INTR_OUT   2
    44 #define USBDIAG_EP_BULK_IN    3
    45 #define USBDIAG_EP_BULK_OUT   4
    46 #define USBDIAG_EP_ISOCH_IN   5
    47 #define USBDIAG_EP_ISOCH_OUT  6
     42#define USBDIAG_EP_BURST_INTR_IN    1
     43#define USBDIAG_EP_BURST_INTR_OUT   2
     44#define USBDIAG_EP_BURST_BULK_IN    3
     45#define USBDIAG_EP_BURST_BULK_OUT   4
     46#define USBDIAG_EP_BURST_ISOCH_IN   5
     47#define USBDIAG_EP_BURST_ISOCH_OUT  6
     48
     49#define USBDIAG_EP_DATA_INTR_IN     7
     50#define USBDIAG_EP_DATA_INTR_OUT    8
     51#define USBDIAG_EP_DATA_BULK_IN     9
     52#define USBDIAG_EP_DATA_BULK_OUT   10
     53#define USBDIAG_EP_DATA_ISOCH_IN   11
     54#define USBDIAG_EP_DATA_ISOCH_OUT  12
    4855
    4956/**
     
    5360        usb_device_t *usb_dev;
    5461        ddf_fun_t *fun;
    55         usb_pipe_t *intr_in;
    56         usb_pipe_t *intr_out;
    57         usb_pipe_t *bulk_in;
    58         usb_pipe_t *bulk_out;
    59         usb_pipe_t *isoch_in;
    60         usb_pipe_t *isoch_out;
     62
     63        usb_pipe_t *burst_intr_in;
     64        usb_pipe_t *burst_intr_out;
     65        usb_pipe_t *burst_bulk_in;
     66        usb_pipe_t *burst_bulk_out;
     67        usb_pipe_t *burst_isoch_in;
     68        usb_pipe_t *burst_isoch_out;
     69
     70        usb_pipe_t *data_intr_in;
     71        usb_pipe_t *data_intr_out;
     72        usb_pipe_t *data_bulk_in;
     73        usb_pipe_t *data_bulk_out;
     74        usb_pipe_t *data_isoch_in;
     75        usb_pipe_t *data_isoch_out;
     76
    6177} usbdiag_dev_t;
    6278
  • uspace/drv/bus/usb/usbdiag/main.c

    r24c41ba1 r8393c73b  
    139139}
    140140
    141 static const usb_endpoint_description_t intr_in_ep = {
    142         .transfer_type = USB_TRANSFER_INTERRUPT,
    143         .direction = USB_DIRECTION_IN,
    144         .interface_class = USB_CLASS_DIAGNOSTIC,
    145         .interface_subclass = 0x00,
    146         .interface_protocol = 0x01,
    147         .flags = 0
    148 };
    149 static const usb_endpoint_description_t intr_out_ep = {
    150         .transfer_type = USB_TRANSFER_INTERRUPT,
    151         .direction = USB_DIRECTION_OUT,
    152         .interface_class = USB_CLASS_DIAGNOSTIC,
    153         .interface_subclass = 0x00,
    154         .interface_protocol = 0x01,
    155         .flags = 0
    156 };
    157 static const usb_endpoint_description_t bulk_in_ep = {
    158         .transfer_type = USB_TRANSFER_BULK,
    159         .direction = USB_DIRECTION_IN,
    160         .interface_class = USB_CLASS_DIAGNOSTIC,
    161         .interface_subclass = 0x00,
    162         .interface_protocol = 0x01,
    163         .flags = 0
    164 };
    165 static const usb_endpoint_description_t bulk_out_ep = {
    166         .transfer_type = USB_TRANSFER_BULK,
    167         .direction = USB_DIRECTION_OUT,
    168         .interface_class = USB_CLASS_DIAGNOSTIC,
    169         .interface_subclass = 0x00,
    170         .interface_protocol = 0x01,
    171         .flags = 0
    172 };
    173 static const usb_endpoint_description_t isoch_in_ep = {
    174         .transfer_type = USB_TRANSFER_ISOCHRONOUS,
    175         .direction = USB_DIRECTION_IN,
    176         .interface_class = USB_CLASS_DIAGNOSTIC,
    177         .interface_subclass = 0x00,
    178         .interface_protocol = 0x01,
    179         .flags = 0
    180 };
    181 static const usb_endpoint_description_t isoch_out_ep = {
     141static const usb_endpoint_description_t burst_intr_in_ep = {
     142        .transfer_type = USB_TRANSFER_INTERRUPT,
     143        .direction = USB_DIRECTION_IN,
     144        .interface_class = USB_CLASS_DIAGNOSTIC,
     145        .interface_subclass = 0x00,
     146        .interface_protocol = 0x01,
     147        .flags = 0
     148};
     149static const usb_endpoint_description_t burst_intr_out_ep = {
     150        .transfer_type = USB_TRANSFER_INTERRUPT,
     151        .direction = USB_DIRECTION_OUT,
     152        .interface_class = USB_CLASS_DIAGNOSTIC,
     153        .interface_subclass = 0x00,
     154        .interface_protocol = 0x01,
     155        .flags = 0
     156};
     157static const usb_endpoint_description_t burst_bulk_in_ep = {
     158        .transfer_type = USB_TRANSFER_BULK,
     159        .direction = USB_DIRECTION_IN,
     160        .interface_class = USB_CLASS_DIAGNOSTIC,
     161        .interface_subclass = 0x00,
     162        .interface_protocol = 0x01,
     163        .flags = 0
     164};
     165static const usb_endpoint_description_t burst_bulk_out_ep = {
     166        .transfer_type = USB_TRANSFER_BULK,
     167        .direction = USB_DIRECTION_OUT,
     168        .interface_class = USB_CLASS_DIAGNOSTIC,
     169        .interface_subclass = 0x00,
     170        .interface_protocol = 0x01,
     171        .flags = 0
     172};
     173static const usb_endpoint_description_t burst_isoch_in_ep = {
     174        .transfer_type = USB_TRANSFER_ISOCHRONOUS,
     175        .direction = USB_DIRECTION_IN,
     176        .interface_class = USB_CLASS_DIAGNOSTIC,
     177        .interface_subclass = 0x00,
     178        .interface_protocol = 0x01,
     179        .flags = 0
     180};
     181static const usb_endpoint_description_t burst_isoch_out_ep = {
     182        .transfer_type = USB_TRANSFER_ISOCHRONOUS,
     183        .direction = USB_DIRECTION_OUT,
     184        .interface_class = USB_CLASS_DIAGNOSTIC,
     185        .interface_subclass = 0x00,
     186        .interface_protocol = 0x01,
     187        .flags = 0
     188};
     189static const usb_endpoint_description_t data_intr_in_ep = {
     190        .transfer_type = USB_TRANSFER_INTERRUPT,
     191        .direction = USB_DIRECTION_IN,
     192        .interface_class = USB_CLASS_DIAGNOSTIC,
     193        .interface_subclass = 0x00,
     194        .interface_protocol = 0x01,
     195        .flags = 0
     196};
     197static const usb_endpoint_description_t data_intr_out_ep = {
     198        .transfer_type = USB_TRANSFER_INTERRUPT,
     199        .direction = USB_DIRECTION_OUT,
     200        .interface_class = USB_CLASS_DIAGNOSTIC,
     201        .interface_subclass = 0x00,
     202        .interface_protocol = 0x01,
     203        .flags = 0
     204};
     205static const usb_endpoint_description_t data_bulk_in_ep = {
     206        .transfer_type = USB_TRANSFER_BULK,
     207        .direction = USB_DIRECTION_IN,
     208        .interface_class = USB_CLASS_DIAGNOSTIC,
     209        .interface_subclass = 0x00,
     210        .interface_protocol = 0x01,
     211        .flags = 0
     212};
     213static const usb_endpoint_description_t data_bulk_out_ep = {
     214        .transfer_type = USB_TRANSFER_BULK,
     215        .direction = USB_DIRECTION_OUT,
     216        .interface_class = USB_CLASS_DIAGNOSTIC,
     217        .interface_subclass = 0x00,
     218        .interface_protocol = 0x01,
     219        .flags = 0
     220};
     221static const usb_endpoint_description_t data_isoch_in_ep = {
     222        .transfer_type = USB_TRANSFER_ISOCHRONOUS,
     223        .direction = USB_DIRECTION_IN,
     224        .interface_class = USB_CLASS_DIAGNOSTIC,
     225        .interface_subclass = 0x00,
     226        .interface_protocol = 0x01,
     227        .flags = 0
     228};
     229static const usb_endpoint_description_t data_isoch_out_ep = {
    182230        .transfer_type = USB_TRANSFER_ISOCHRONOUS,
    183231        .direction = USB_DIRECTION_OUT,
     
    189237
    190238static const usb_endpoint_description_t *diag_endpoints[] = {
    191         [USBDIAG_EP_INTR_IN] = &intr_in_ep,
    192         [USBDIAG_EP_INTR_OUT] = &intr_out_ep,
    193         [USBDIAG_EP_BULK_IN] = &bulk_in_ep,
    194         [USBDIAG_EP_BULK_OUT] = &bulk_out_ep,
    195         [USBDIAG_EP_ISOCH_IN] = &isoch_in_ep,
    196         [USBDIAG_EP_ISOCH_OUT] = &isoch_out_ep,
     239        [USBDIAG_EP_BURST_INTR_IN] = &burst_intr_in_ep,
     240        [USBDIAG_EP_BURST_INTR_OUT] = &burst_intr_out_ep,
     241        [USBDIAG_EP_BURST_BULK_IN] = &burst_bulk_in_ep,
     242        [USBDIAG_EP_BURST_BULK_OUT] = &burst_bulk_out_ep,
     243        [USBDIAG_EP_BURST_ISOCH_IN] = &burst_isoch_in_ep,
     244        [USBDIAG_EP_BURST_ISOCH_OUT] = &burst_isoch_out_ep,
     245        [USBDIAG_EP_DATA_INTR_IN] = &data_intr_in_ep,
     246        [USBDIAG_EP_DATA_INTR_OUT] = &data_intr_out_ep,
     247        [USBDIAG_EP_DATA_BULK_IN] = &data_bulk_in_ep,
     248        [USBDIAG_EP_DATA_BULK_OUT] = &data_bulk_out_ep,
     249        [USBDIAG_EP_DATA_ISOCH_IN] = &data_isoch_in_ep,
     250        [USBDIAG_EP_DATA_ISOCH_OUT] = &data_isoch_out_ep,
    197251        NULL
    198252};
  • uspace/drv/bus/usb/usbdiag/tests.c

    r24c41ba1 r8393c73b  
    4444#define NAME "usbdiag"
    4545
    46 static int burst_in_test(usb_pipe_t *pipe, int cycles, size_t size, usbdiag_dur_t *duration)
     46static const uint32_t test_data_src = 0xDEADBEEF;
     47
     48static int test_in(usb_pipe_t *pipe, const usbdiag_test_params_t *params, usbdiag_test_results_t *results)
    4749{
    4850        if (!pipe)
    4951                return EBADMEM;
     52
     53        bool validate = params->validate_data;
     54        size_t size = params->transfer_size;
     55        if (!size)
     56                size = pipe->desc.max_transfer_size;
     57
     58        const uint32_t test_data = uint32_host2usb(test_data_src);
     59        if (validate && size % sizeof(test_data))
     60                return EINVAL;
    5061
    5162        char *buffer = (char *) malloc(size);
     
    5566        // TODO: Are we sure that no other test is running on this endpoint?
    5667
    57         usb_log_info("Performing %s IN burst test.", usb_str_transfer_type(pipe->desc.transfer_type));
     68        usb_log_info("Performing %s IN test with duration %ld ms.", usb_str_transfer_type(pipe->desc.transfer_type), params->min_duration);
    5869
    5970        int rc = EOK;
    60         struct timeval start_time;
     71        uint32_t transfer_count = 0;
     72
     73        struct timeval start_time, final_time, stop_time;
    6174        gettimeofday(&start_time, NULL);
    62 
    63         for (int i = 0; i < cycles; ++i) {
     75        gettimeofday(&stop_time, NULL);
     76
     77        tv_add_diff(&stop_time, params->min_duration * 1000);
     78        gettimeofday(&final_time, NULL);
     79
     80        while (!tv_gt(&final_time, &stop_time)) {
     81                ++transfer_count;
     82
    6483                // Read device's response.
    6584                size_t remaining = size;
     
    83102                if (rc)
    84103                        break;
    85         }
    86 
    87         struct timeval final_time;
    88         gettimeofday(&final_time, NULL);
     104
     105                if (validate) {
     106                        for (size_t i = 0; i < size; i += sizeof(test_data)) {
     107                                if (*(uint32_t *)(buffer + i) != test_data) {
     108                                        usb_log_error("Read of %s IN endpoint returned "
     109                                                "invald data at address %zu.",
     110                                                usb_str_transfer_type(pipe->desc.transfer_type), i);
     111                                        rc = EINVAL;
     112                                        break;
     113                                }
     114                        }
     115
     116                        if (rc)
     117                                break;
     118                }
     119
     120                gettimeofday(&final_time, NULL);
     121        }
     122
    89123        usbdiag_dur_t in_duration = ((final_time.tv_usec - start_time.tv_usec) / 1000) +
    90124            ((final_time.tv_sec - start_time.tv_sec) * 1000);
    91125
    92         usb_log_info("Burst test on %s IN endpoint completed in %lu ms.", usb_str_transfer_type(pipe->desc.transfer_type), in_duration);
     126        usb_log_info("Test on %s IN endpoint completed in %lu ms.", usb_str_transfer_type(pipe->desc.transfer_type), in_duration);
     127
     128        results->act_duration = in_duration;
     129        results->transfer_count = transfer_count;
     130        results->transfer_size = size;
    93131
    94132        free(buffer);
    95         if (duration)
    96                 *duration = in_duration;
    97133
    98134        return rc;
    99135}
    100136
    101 static int burst_out_test(usb_pipe_t *pipe, int cycles, size_t size, usbdiag_dur_t *duration)
     137static int test_out(usb_pipe_t *pipe, const usbdiag_test_params_t *params, usbdiag_test_results_t *results)
    102138{
    103139        if (!pipe)
    104140                return EBADMEM;
     141
     142        bool validate = params->validate_data;
     143        size_t size = params->transfer_size;
     144        if (!size)
     145                size = pipe->desc.max_transfer_size;
     146
     147        const uint32_t test_data = uint32_host2usb(test_data_src);
     148
     149        if (validate && size % sizeof(test_data))
     150                return EINVAL;
    105151
    106152        char *buffer = (char *) malloc(size);
     
    108154                return ENOMEM;
    109155
    110         memset(buffer, 42, size);
     156        if (validate) {
     157                for (size_t i = 0; i < size; i += sizeof(test_data)) {
     158                        memcpy(buffer + i, &test_data, sizeof(test_data));
     159                }
     160        }
    111161
    112162        // TODO: Are we sure that no other test is running on this endpoint?
    113163
    114         usb_log_info("Performing %s OUT burst test.", usb_str_transfer_type(pipe->desc.transfer_type));
     164        usb_log_info("Performing %s OUT test.", usb_str_transfer_type(pipe->desc.transfer_type));
    115165
    116166        int rc = EOK;
    117         struct timeval start_time;
     167        uint32_t transfer_count = 0;
     168
     169        struct timeval start_time, final_time, stop_time;
    118170        gettimeofday(&start_time, NULL);
    119 
    120         for (int i = 0; i < cycles; ++i) {
     171        gettimeofday(&stop_time, NULL);
     172
     173        tv_add_diff(&stop_time, params->min_duration * 1000);
     174        gettimeofday(&final_time, NULL);
     175
     176        while (!tv_gt(&final_time, &stop_time)) {
     177                ++transfer_count;
     178
    121179                // Write buffer to device.
    122180                if ((rc = usb_pipe_write(pipe, buffer, size))) {
     
    124182                        break;
    125183                }
    126         }
    127 
    128         struct timeval final_time;
    129         gettimeofday(&final_time, NULL);
     184
     185                gettimeofday(&final_time, NULL);
     186        }
     187
    130188        usbdiag_dur_t in_duration = ((final_time.tv_usec - start_time.tv_usec) / 1000) +
    131189            ((final_time.tv_sec - start_time.tv_sec) * 1000);
    132190
    133         usb_log_info("Burst test on %s OUT endpoint completed in %ld ms.", usb_str_transfer_type(pipe->desc.transfer_type), in_duration);
     191        usb_log_info("Test on %s OUT endpoint completed in %ld ms.", usb_str_transfer_type(pipe->desc.transfer_type), in_duration);
     192
     193        results->act_duration = in_duration;
     194        results->transfer_count = transfer_count;
     195        results->transfer_size = size;
    134196
    135197        free(buffer);
    136         if (duration)
    137                 *duration = in_duration;
    138198
    139199        return rc;
    140200}
    141201
    142 static const uint32_t test_data_src = 0xDEADBEEF;
    143 
    144 static int data_in_test(usb_pipe_t *pipe, int cycles, size_t size, usbdiag_dur_t *duration)
    145 {
    146         if (!pipe)
    147                 return EBADMEM;
    148 
    149         const uint32_t test_data = uint32_host2usb(test_data_src);
    150 
    151         if (size % sizeof(test_data))
    152                 return EINVAL;
    153 
    154         char *buffer = (char *) malloc(size);
    155         if (!buffer)
    156                 return ENOMEM;
    157 
    158         // TODO: Are we sure that no other test is running on this endpoint?
    159 
    160         usb_log_info("Performing %s IN data test.", usb_str_transfer_type(pipe->desc.transfer_type));
    161 
    162         int rc = EOK;
    163         struct timeval start_time;
    164         gettimeofday(&start_time, NULL);
    165 
    166         for (int i = 0; i < cycles; ++i) {
    167                 // Read device's response.
    168                 size_t remaining = size;
    169                 size_t transferred;
    170 
    171                 while (remaining > 0) {
    172                         if ((rc = usb_pipe_read(pipe, buffer + size - remaining, remaining, &transferred))) {
    173                                 usb_log_error("Read of %s IN endpoint failed with error: %s", usb_str_transfer_type(pipe->desc.transfer_type), str_error(rc));
    174                                 break;
    175                         }
    176 
    177                         if (transferred > remaining) {
    178                                 usb_log_error("Read of %s IN endpoint returned more data than expected.", usb_str_transfer_type(pipe->desc.transfer_type));
    179                                 rc = EINVAL;
    180                                 break;
    181                         }
    182 
    183                         remaining -= transferred;
    184                 }
    185 
    186                 if (rc)
    187                         break;
    188 
    189                 for (size_t i = 0; i < size; i += sizeof(test_data)) {
    190                         if (*(uint32_t *)(buffer + i) != test_data) {
    191                                 usb_log_error("Read of %s IN endpoint returned "
    192                                     "invald data at address %zu.",
    193                                     usb_str_transfer_type(pipe->desc.transfer_type), i);
    194                                 rc = EINVAL;
    195                                 break;
    196                         }
    197                 }
    198 
    199                 if (rc)
    200                         break;
    201         }
    202 
    203         struct timeval final_time;
    204         gettimeofday(&final_time, NULL);
    205         usbdiag_dur_t in_duration = ((final_time.tv_usec - start_time.tv_usec) / 1000) +
    206             ((final_time.tv_sec - start_time.tv_sec) * 1000);
    207 
    208         usb_log_info("Data test on %s IN endpoint completed in %lu ms.", usb_str_transfer_type(pipe->desc.transfer_type), in_duration);
    209 
    210         free(buffer);
    211         if (duration)
    212                 *duration = in_duration;
    213 
    214         return rc;
    215 }
    216 
    217 static int data_out_test(usb_pipe_t *pipe, int cycles, size_t size, usbdiag_dur_t *duration)
    218 {
    219         if (!pipe)
    220                 return EBADMEM;
    221 
    222         const uint32_t test_data = uint32_host2usb(test_data_src);
    223 
    224         if (size % sizeof(test_data))
    225                 return EINVAL;
    226 
    227         char *buffer = (char *) malloc(size);
    228         if (!buffer)
    229                 return ENOMEM;
    230 
    231         for (size_t i = 0; i < size; i += sizeof(test_data)) {
    232                 memcpy(buffer + i, &test_data, sizeof(test_data));
    233         }
    234 
    235         // TODO: Are we sure that no other test is running on this endpoint?
    236 
    237         usb_log_info("Performing %s OUT data test.", usb_str_transfer_type(pipe->desc.transfer_type));
    238 
    239         int rc = EOK;
    240         struct timeval start_time;
    241         gettimeofday(&start_time, NULL);
    242 
    243         for (int i = 0; i < cycles; ++i) {
    244                 // Write buffer to device.
    245                 if ((rc = usb_pipe_write(pipe, buffer, size))) {
    246                         usb_log_error("Write to %s OUT endpoint failed with error: %s", usb_str_transfer_type(pipe->desc.transfer_type), str_error(rc));
    247                         break;
    248                 }
    249         }
    250 
    251         struct timeval final_time;
    252         gettimeofday(&final_time, NULL);
    253         usbdiag_dur_t in_duration = ((final_time.tv_usec - start_time.tv_usec) / 1000) +
    254             ((final_time.tv_sec - start_time.tv_sec) * 1000);
    255 
    256         usb_log_info("Data test on %s OUT endpoint completed in %ld ms.", usb_str_transfer_type(pipe->desc.transfer_type), in_duration);
    257 
    258         free(buffer);
    259         if (duration)
    260                 *duration = in_duration;
    261 
    262         return rc;
    263 }
    264 
    265 int usbdiag_burst_test_intr_in(ddf_fun_t *fun, int cycles, size_t size, usbdiag_dur_t *duration)
     202int usbdiag_dev_test_in(ddf_fun_t *fun, const usbdiag_test_params_t *params, usbdiag_test_results_t *results)
    266203{
    267204        usbdiag_dev_t *dev = ddf_fun_to_usbdiag_dev(fun);
     
    269206                return EBADMEM;
    270207
    271         return burst_in_test(dev->intr_in, cycles, size, duration);
    272 }
    273 
    274 int usbdiag_burst_test_intr_out(ddf_fun_t *fun, int cycles, size_t size, usbdiag_dur_t *duration)
     208        usb_pipe_t *pipe;
     209
     210        switch (params->transfer_type) {
     211        case USB_TRANSFER_INTERRUPT:
     212                pipe = params->validate_data ? dev->data_intr_in : dev->burst_intr_in;
     213                break;
     214        case USB_TRANSFER_BULK:
     215                pipe = params->validate_data ? dev->data_bulk_in : dev->burst_bulk_in;
     216                break;
     217        case USB_TRANSFER_ISOCHRONOUS:
     218                pipe = params->validate_data ? dev->data_isoch_in : dev->burst_isoch_in;
     219                break;
     220        default:
     221                return ENOTSUP;
     222        }
     223
     224        return test_in(pipe, params, results);
     225}
     226
     227int usbdiag_dev_test_out(ddf_fun_t *fun, const usbdiag_test_params_t *params, usbdiag_test_results_t *results)
    275228{
    276229        usbdiag_dev_t *dev = ddf_fun_to_usbdiag_dev(fun);
     
    278231                return EBADMEM;
    279232
    280         return burst_out_test(dev->intr_out, cycles, size, duration);
    281 }
    282 
    283 int usbdiag_burst_test_bulk_in(ddf_fun_t *fun, int cycles, size_t size, usbdiag_dur_t *duration)
    284 {
    285         usbdiag_dev_t *dev = ddf_fun_to_usbdiag_dev(fun);
    286         if (!dev)
    287                 return EBADMEM;
    288 
    289         return burst_in_test(dev->bulk_in, cycles, size, duration);
    290 }
    291 
    292 int usbdiag_burst_test_bulk_out(ddf_fun_t *fun, int cycles, size_t size, usbdiag_dur_t *duration)
    293 {
    294         usbdiag_dev_t *dev = ddf_fun_to_usbdiag_dev(fun);
    295         if (!dev)
    296                 return EBADMEM;
    297 
    298         return burst_out_test(dev->bulk_out, cycles, size, duration);
    299 }
    300 
    301 int usbdiag_burst_test_isoch_in(ddf_fun_t *fun, int cycles, size_t size, usbdiag_dur_t *duration)
    302 {
    303         usbdiag_dev_t *dev = ddf_fun_to_usbdiag_dev(fun);
    304         if (!dev)
    305                 return EBADMEM;
    306 
    307         return burst_in_test(dev->isoch_in, cycles, size, duration);
    308 }
    309 
    310 int usbdiag_burst_test_isoch_out(ddf_fun_t *fun, int cycles, size_t size, usbdiag_dur_t *duration)
    311 {
    312         usbdiag_dev_t *dev = ddf_fun_to_usbdiag_dev(fun);
    313         if (!dev)
    314                 return EBADMEM;
    315 
    316         return burst_out_test(dev->isoch_out, cycles, size, duration);
    317 }
    318 
    319 int usbdiag_data_test_intr_in(ddf_fun_t *fun, int cycles, size_t size, usbdiag_dur_t *duration)
    320 {
    321         usbdiag_dev_t *dev = ddf_fun_to_usbdiag_dev(fun);
    322         if (!dev)
    323                 return EBADMEM;
    324 
    325         return data_in_test(dev->intr_in, cycles, size, duration);
    326 }
    327 
    328 int usbdiag_data_test_intr_out(ddf_fun_t *fun, int cycles, size_t size, usbdiag_dur_t *duration)
    329 {
    330         usbdiag_dev_t *dev = ddf_fun_to_usbdiag_dev(fun);
    331         if (!dev)
    332                 return EBADMEM;
    333 
    334         return data_out_test(dev->intr_out, cycles, size, duration);
    335 }
    336 
    337 int usbdiag_data_test_bulk_in(ddf_fun_t *fun, int cycles, size_t size, usbdiag_dur_t *duration)
    338 {
    339         usbdiag_dev_t *dev = ddf_fun_to_usbdiag_dev(fun);
    340         if (!dev)
    341                 return EBADMEM;
    342 
    343         return data_in_test(dev->bulk_in, cycles, size, duration);
    344 }
    345 
    346 int usbdiag_data_test_bulk_out(ddf_fun_t *fun, int cycles, size_t size, usbdiag_dur_t *duration)
    347 {
    348         usbdiag_dev_t *dev = ddf_fun_to_usbdiag_dev(fun);
    349         if (!dev)
    350                 return EBADMEM;
    351 
    352         return data_out_test(dev->bulk_out, cycles, size, duration);
    353 }
    354 
    355 int usbdiag_data_test_isoch_in(ddf_fun_t *fun, int cycles, size_t size, usbdiag_dur_t *duration)
    356 {
    357         usbdiag_dev_t *dev = ddf_fun_to_usbdiag_dev(fun);
    358         if (!dev)
    359                 return EBADMEM;
    360 
    361         return data_in_test(dev->isoch_in, cycles, size, duration);
    362 }
    363 
    364 int usbdiag_data_test_isoch_out(ddf_fun_t *fun, int cycles, size_t size, usbdiag_dur_t *duration)
    365 {
    366         usbdiag_dev_t *dev = ddf_fun_to_usbdiag_dev(fun);
    367         if (!dev)
    368                 return EBADMEM;
    369 
    370         return data_out_test(dev->isoch_out, cycles, size, duration);
     233        usb_pipe_t *pipe;
     234
     235        switch (params->transfer_type) {
     236        case USB_TRANSFER_INTERRUPT:
     237                pipe = params->validate_data ? dev->data_intr_out : dev->burst_intr_out;
     238                break;
     239        case USB_TRANSFER_BULK:
     240                pipe = params->validate_data ? dev->data_bulk_out : dev->burst_bulk_out;
     241                break;
     242        case USB_TRANSFER_ISOCHRONOUS:
     243                pipe = params->validate_data ? dev->data_isoch_out : dev->burst_isoch_out;
     244                break;
     245        default:
     246                return ENOTSUP;
     247        }
     248
     249        return test_out(pipe, params, results);
    371250}
    372251
  • uspace/drv/bus/usb/usbdiag/tests.h

    r24c41ba1 r8393c73b  
    3939#include <ddf/driver.h>
    4040
    41 int usbdiag_burst_test_intr_in(ddf_fun_t *, int, size_t, usbdiag_dur_t *);
    42 int usbdiag_burst_test_intr_out(ddf_fun_t *, int, size_t, usbdiag_dur_t *);
    43 int usbdiag_burst_test_bulk_in(ddf_fun_t *, int, size_t, usbdiag_dur_t *);
    44 int usbdiag_burst_test_bulk_out(ddf_fun_t *, int, size_t, usbdiag_dur_t *);
    45 int usbdiag_burst_test_isoch_in(ddf_fun_t *, int, size_t, usbdiag_dur_t *);
    46 int usbdiag_burst_test_isoch_out(ddf_fun_t *, int, size_t, usbdiag_dur_t *);
    47 
    48 int usbdiag_data_test_intr_in(ddf_fun_t *, int, size_t, usbdiag_dur_t *);
    49 int usbdiag_data_test_intr_out(ddf_fun_t *, int, size_t, usbdiag_dur_t *);
    50 int usbdiag_data_test_bulk_in(ddf_fun_t *, int, size_t, usbdiag_dur_t *);
    51 int usbdiag_data_test_bulk_out(ddf_fun_t *, int, size_t, usbdiag_dur_t *);
    52 int usbdiag_data_test_isoch_in(ddf_fun_t *, int, size_t, usbdiag_dur_t *);
    53 int usbdiag_data_test_isoch_out(ddf_fun_t *, int, size_t, usbdiag_dur_t *);
     41int usbdiag_dev_test_in(ddf_fun_t *, const usbdiag_test_params_t *, usbdiag_test_results_t *);
     42int usbdiag_dev_test_out(ddf_fun_t *, const usbdiag_test_params_t *, usbdiag_test_results_t *);
    5443
    5544#endif /* USBDIAG_TESTS_H_ */
Note: See TracChangeset for help on using the changeset viewer.