Changeset b7b7898 in mainline


Ignore:
Timestamp:
2017-12-22T12:03:16Z (6 years ago)
Author:
Petr Mánek <petr.manek@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
96c416a
Parents:
2986763
git-author:
Petr Mánek <petr.manek@…> (2017-12-22 12:02:50)
git-committer:
Petr Mánek <petr.manek@…> (2017-12-22 12:03:16)
Message:

usbdiag: refactoring

Reconciliated the usb_diag and usbdiag prefix in favor of the latter. Removed a ton of copy-pasta code for the burst tests in favor of single generic static burst test for every direction, which is then called by individual functions for different endpoint type. This also allowed to get rid of the ugly translation macros in device.c. Deleted unused usbdiag.h header file. Refactored the remote interface to comply with all aforementioned modifications.

Location:
uspace
Files:
1 deleted
7 edited

Legend:

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

    r2986763 rb7b7898  
    4545#define NAME "usbdiag"
    4646
    47 #define TRANSLATE_FUNC_NAME(fun) translate_##fun
    48 #define TRANSLATE_FUNC(fun) \
    49         static int TRANSLATE_FUNC_NAME(fun)(ddf_fun_t *f, int cycles, size_t size)\
    50         {\
    51                 usb_diag_dev_t *dev = ddf_fun_to_usb_diag_dev(f);\
    52                 return fun(dev, cycles, size);\
    53         }
    54 
    55 TRANSLATE_FUNC(usb_diag_stress_intr_out)
    56 TRANSLATE_FUNC(usb_diag_stress_intr_in)
    57 TRANSLATE_FUNC(usb_diag_stress_bulk_out)
    58 TRANSLATE_FUNC(usb_diag_stress_bulk_in)
    59 TRANSLATE_FUNC(usb_diag_stress_isoch_out)
    60 TRANSLATE_FUNC(usb_diag_stress_isoch_in)
    61 
    6247static 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),
    65         .stress_bulk_out = TRANSLATE_FUNC_NAME(usb_diag_stress_bulk_out),
    66         .stress_bulk_in = TRANSLATE_FUNC_NAME(usb_diag_stress_bulk_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)
     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
    6954};
    70 
    71 #undef TRANSLATE_FUNC_NAME
    72 #undef TRANSLATE_FUNC
    7355
    7456static ddf_dev_ops_t diag_ops = {
     
    7658};
    7759
    78 static int device_init(usb_diag_dev_t *dev)
     60static int device_init(usbdiag_dev_t *dev)
    7961{
    8062        int rc;
     
    8971
    9072#define _MAP_EP(target, ep_no) do {\
    91         usb_endpoint_mapping_t *epm = usb_device_get_mapped_ep(dev->usb_dev, USB_DIAG_EP_##ep_no);\
     73        usb_endpoint_mapping_t *epm = usb_device_get_mapped_ep(dev->usb_dev, USBDIAG_EP_##ep_no);\
    9274        if (!epm || !epm->present) {\
    9375                usb_log_error("Failed to map endpoint: " #ep_no ".\n");\
     
    11597}
    11698
    117 static void device_fini(usb_diag_dev_t *dev)
     99static void device_fini(usbdiag_dev_t *dev)
    118100{
    119101        ddf_fun_destroy(dev->fun);
    120102}
    121103
    122 int usb_diag_dev_create(usb_device_t *dev, usb_diag_dev_t **out_diag_dev)
     104int usbdiag_dev_create(usb_device_t *dev, usbdiag_dev_t **out_diag_dev)
    123105{
    124106        assert(dev);
    125107        assert(out_diag_dev);
    126108
    127         usb_diag_dev_t *diag_dev = usb_device_data_alloc(dev, sizeof(usb_diag_dev_t));
     109        usbdiag_dev_t *diag_dev = usb_device_data_alloc(dev, sizeof(usbdiag_dev_t));
    128110        if (!diag_dev)
    129111                return ENOMEM;
     
    143125}
    144126
    145 void usb_diag_dev_destroy(usb_diag_dev_t *dev)
     127void usbdiag_dev_destroy(usbdiag_dev_t *dev)
    146128{
    147129        assert(dev);
  • uspace/drv/bus/usb/usbdiag/device.h

    r2986763 rb7b7898  
    3434 */
    3535
    36 #ifndef USB_DIAG_DEVICE_H_
    37 #define USB_DIAG_DEVICE_H_
     36#ifndef USBDIAG_DEVICE_H_
     37#define USBDIAG_DEVICE_H_
    3838
    3939#include <usb/dev/device.h>
    4040
    41 #define USB_DIAG_EP_INTR_IN    1
    42 #define USB_DIAG_EP_INTR_OUT   2
    43 #define USB_DIAG_EP_BULK_IN    3
    44 #define USB_DIAG_EP_BULK_OUT   4
    45 #define USB_DIAG_EP_ISOCH_IN   5
    46 #define USB_DIAG_EP_ISOCH_OUT  6
     41#define USBDIAG_EP_INTR_IN    1
     42#define USBDIAG_EP_INTR_OUT   2
     43#define USBDIAG_EP_BULK_IN    3
     44#define USBDIAG_EP_BULK_OUT   4
     45#define USBDIAG_EP_ISOCH_IN   5
     46#define USBDIAG_EP_ISOCH_OUT  6
    4747
    4848/**
    4949 * USB diagnostic device.
    5050 */
    51 typedef struct usb_diag_dev {
     51typedef struct usbdiag_dev {
    5252        usb_device_t *usb_dev;
    5353        ddf_fun_t *fun;
     
    5858        usb_pipe_t *isoch_in;
    5959        usb_pipe_t *isoch_out;
    60 } usb_diag_dev_t;
     60} usbdiag_dev_t;
    6161
    62 int usb_diag_dev_create(usb_device_t *, usb_diag_dev_t **);
    63 void usb_diag_dev_destroy(usb_diag_dev_t *);
     62int usbdiag_dev_create(usb_device_t *, usbdiag_dev_t **);
     63void usbdiag_dev_destroy(usbdiag_dev_t *);
    6464
    65 static inline usb_diag_dev_t * usb_device_to_usb_diag_dev(usb_device_t *usb_dev)
     65static inline usbdiag_dev_t * usb_device_to_usbdiag_dev(usb_device_t *usb_dev)
    6666{
    6767        assert(usb_dev);
     
    6969}
    7070
    71 static inline usb_diag_dev_t * ddf_dev_to_usb_diag_dev(ddf_dev_t *ddf_dev)
     71static inline usbdiag_dev_t * ddf_dev_to_usbdiag_dev(ddf_dev_t *ddf_dev)
    7272{
    7373        assert(ddf_dev);
    74         return usb_device_to_usb_diag_dev(usb_device_get(ddf_dev));
     74        return usb_device_to_usbdiag_dev(usb_device_get(ddf_dev));
    7575}
    7676
    77 static inline usb_diag_dev_t * ddf_fun_to_usb_diag_dev(ddf_fun_t *ddf_fun)
     77static inline usbdiag_dev_t * ddf_fun_to_usbdiag_dev(ddf_fun_t *ddf_fun)
    7878{
    7979        assert(ddf_fun);
    80         return ddf_dev_to_usb_diag_dev(ddf_fun_get_dev(ddf_fun));
     80        return ddf_dev_to_usbdiag_dev(ddf_fun_get_dev(ddf_fun));
    8181}
    8282
    83 #endif /* USB_DIAG_USBDIAG_H_ */
     83#endif /* USBDIAG_USBDIAG_H_ */
    8484
    8585/**
  • uspace/drv/bus/usb/usbdiag/main.c

    r2986763 rb7b7898  
    4141#include <str_error.h>
    4242
    43 #include "usbdiag.h"
    4443#include "device.h"
    4544
     
    5150        usb_log_info("Adding device '%s'", usb_device_get_name(dev));
    5251
    53         usb_diag_dev_t *diag_dev;
    54         if ((rc = usb_diag_dev_create(dev, &diag_dev))) {
     52        usbdiag_dev_t *diag_dev;
     53        if ((rc = usbdiag_dev_create(dev, &diag_dev))) {
    5554                usb_log_error("Failed create device: %s.\n", str_error(rc));
    5655                goto err;
     
    7372        ddf_fun_unbind(diag_dev->fun);
    7473err_create:
    75         usb_diag_dev_destroy(diag_dev);
     74        usbdiag_dev_destroy(diag_dev);
    7675err:
    7776        return rc;
     
    8382        usb_log_info("Removing device '%s'", usb_device_get_name(dev));
    8483
    85         usb_diag_dev_t *diag_dev = usb_device_to_usb_diag_dev(dev);
     84        usbdiag_dev_t *diag_dev = usb_device_to_usbdiag_dev(dev);
    8685
    8786        /* TODO: Make sure nothing is going on with the device. */
     
    9291        }
    9392
    94         usb_diag_dev_destroy(diag_dev);
     93        usbdiag_dev_destroy(diag_dev);
    9594
    9695        return EOK;
     
    104103        usb_log_info("Device '%s' gone.", usb_device_get_name(dev));
    105104
    106         usb_diag_dev_t *diag_dev = usb_device_to_usb_diag_dev(dev);
     105        usbdiag_dev_t *diag_dev = usb_device_to_usbdiag_dev(dev);
    107106
    108107        /* TODO: Make sure nothing is going on with the device. */
     
    110109        /* TODO: Remove device from list */
    111110
    112         usb_diag_dev_destroy(diag_dev);
     111        usbdiag_dev_destroy(diag_dev);
    113112
    114113        return EOK;
     
    175174
    176175static const usb_endpoint_description_t *diag_endpoints[] = {
    177         [USB_DIAG_EP_INTR_IN] = &intr_in_ep,
    178         [USB_DIAG_EP_INTR_OUT] = &intr_out_ep,
    179         [USB_DIAG_EP_BULK_IN] = &bulk_in_ep,
    180         [USB_DIAG_EP_BULK_OUT] = &bulk_out_ep,
    181         [USB_DIAG_EP_ISOCH_IN] = &isoch_in_ep,
    182         [USB_DIAG_EP_ISOCH_OUT] = &isoch_out_ep,
     176        [USBDIAG_EP_INTR_IN] = &intr_in_ep,
     177        [USBDIAG_EP_INTR_OUT] = &intr_out_ep,
     178        [USBDIAG_EP_BULK_IN] = &bulk_in_ep,
     179        [USBDIAG_EP_BULK_OUT] = &bulk_out_ep,
     180        [USBDIAG_EP_ISOCH_IN] = &isoch_in_ep,
     181        [USBDIAG_EP_ISOCH_OUT] = &isoch_out_ep,
    183182        NULL
    184183};
  • uspace/drv/bus/usb/usbdiag/tests.c

    r2986763 rb7b7898  
    3737#include <str_error.h>
    3838#include <usb/debug.h>
     39#include "device.h"
    3940#include "tests.h"
    4041
    4142#define NAME "usbdiag"
    4243
     44static int burst_in_test(usb_pipe_t *pipe, int cycles, size_t size)
     45{
     46        if (!pipe)
     47                return EBADMEM;
    4348
    44 int usb_diag_stress_intr_out(usb_diag_dev_t *dev, int cycles, size_t size)
     49        char *buffer = (char *) malloc(size);
     50        if (!buffer)
     51                return ENOMEM;
     52
     53        // TODO: Are we sure that no other test is running on this endpoint?
     54
     55        usb_log_info("Performing %s IN burst test.", usb_str_transfer_type(pipe->desc.transfer_type));
     56        int rc = EOK;
     57        for (int i = 0; i < cycles; ++i) {
     58                // Read device's response.
     59                size_t remaining = size;
     60                size_t transferred;
     61
     62                while (remaining > 0) {
     63                        if ((rc = usb_pipe_read(pipe, buffer + size - remaining, remaining, &transferred))) {
     64                                usb_log_error("Read of %s IN endpoint failed with error: %s\n", usb_str_transfer_type(pipe->desc.transfer_type), str_error(rc));
     65                                break;
     66                        }
     67
     68                        if (transferred > remaining) {
     69                                usb_log_error("Read of %s IN endpoint returned more data than expected.\n", usb_str_transfer_type(pipe->desc.transfer_type));
     70                                rc = EINVAL;
     71                                break;
     72                        }
     73
     74                        remaining -= transferred;
     75                }
     76
     77                if (rc)
     78                        break;
     79        }
     80        usb_log_info("Burst test on %s IN endpoint completed.", usb_str_transfer_type(pipe->desc.transfer_type));
     81
     82        free(buffer);
     83        return rc;
     84}
     85
     86static int burst_out_test(usb_pipe_t *pipe, int cycles, size_t size)
    4587{
    46         if (!dev)
     88        if (!pipe)
    4789                return EBADMEM;
    4890
     
    5597        // TODO: Are we sure that no other test is running on this endpoint?
    5698
    57         usb_log_info("Performing interrupt out stress test on device %s.", ddf_fun_get_name(dev->fun));
     99        usb_log_info("Performing %s OUT burst test.", usb_str_transfer_type(pipe->desc.transfer_type));
    58100        int rc = EOK;
    59101        for (int i = 0; i < cycles; ++i) {
    60102                // 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));
     103                if ((rc = usb_pipe_write(pipe, buffer, size))) {
     104                        usb_log_error("Write to %s OUT endpoint failed with error: %s\n", usb_str_transfer_type(pipe->desc.transfer_type), str_error(rc));
    63105                        break;
    64106                }
    65107        }
     108        usb_log_info("Burst test on %s OUT endpoint completed.", usb_str_transfer_type(pipe->desc.transfer_type));
    66109
    67110        free(buffer);
     
    69112}
    70113
    71 int usb_diag_stress_intr_in(usb_diag_dev_t *dev, int cycles, size_t size)
     114int usbdiag_burst_test_intr_in(ddf_fun_t *fun, int cycles, size_t size)
    72115{
     116        usbdiag_dev_t *dev = ddf_fun_to_usbdiag_dev(fun);
    73117        if (!dev)
    74118                return EBADMEM;
    75119
    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;
     120        return burst_in_test(dev->intr_in, cycles, size);
    110121}
    111122
    112 int usb_diag_stress_bulk_out(usb_diag_dev_t *dev, int cycles, size_t size)
     123int usbdiag_burst_test_intr_out(ddf_fun_t *fun, int cycles, size_t size)
    113124{
     125        usbdiag_dev_t *dev = ddf_fun_to_usbdiag_dev(fun);
    114126        if (!dev)
    115127                return EBADMEM;
    116128
    117         char *buffer = (char *) malloc(size);
    118         if (!buffer)
    119                 return ENOMEM;
    120 
    121         memset(buffer, 42, size);
    122 
    123         // TODO: Are we sure that no other test is running on this endpoint?
    124 
    125         usb_log_info("Performing bulk out stress test on device %s.", ddf_fun_get_name(dev->fun));
    126         int rc = EOK;
    127         for (int i = 0; i < cycles; ++i) {
    128                 // Write buffer to device.
    129                 if ((rc = usb_pipe_write(dev->bulk_out, buffer, size))) {
    130                         usb_log_error("Bulk OUT write failed. %s\n", str_error(rc));
    131                         break;
    132                 }
    133         }
    134 
    135         free(buffer);
    136         return rc;
     129        return burst_out_test(dev->intr_out, cycles, size);
    137130}
    138131
    139 int usb_diag_stress_bulk_in(usb_diag_dev_t *dev, int cycles, size_t size)
     132int usbdiag_burst_test_bulk_in(ddf_fun_t *fun, int cycles, size_t size)
    140133{
     134        usbdiag_dev_t *dev = ddf_fun_to_usbdiag_dev(fun);
    141135        if (!dev)
    142136                return EBADMEM;
    143137
    144         char *buffer = (char *) malloc(size);
    145         if (!buffer)
    146                 return ENOMEM;
    147 
    148         // TODO: Are we sure that no other test is running on this endpoint?
    149 
    150         usb_log_info("Performing bulk in stress test on device %s.", ddf_fun_get_name(dev->fun));
    151         int rc = EOK;
    152         for (int i = 0; i < cycles; ++i) {
    153                 // Read device's response.
    154                 size_t remaining = size;
    155                 size_t transferred;
    156 
    157                 while (remaining > 0) {
    158                         if ((rc = usb_pipe_read(dev->bulk_in, buffer + size - remaining, remaining, &transferred))) {
    159                                 usb_log_error("Bulk IN read failed. %s\n", str_error(rc));
    160                                 break;
    161                         }
    162 
    163                         if (transferred > remaining) {
    164                                 usb_log_error("Bulk IN read more than expected.\n");
    165                                 rc = EINVAL;
    166                                 break;
    167                         }
    168 
    169                         remaining -= transferred;
    170                 }
    171 
    172                 if (rc)
    173                         break;
    174         }
    175 
    176         free(buffer);
    177         return rc;
     138        return burst_in_test(dev->bulk_in, cycles, size);
    178139}
    179140
    180 int usb_diag_stress_isoch_out(usb_diag_dev_t *dev, int cycles, size_t size)
     141int usbdiag_burst_test_bulk_out(ddf_fun_t *fun, int cycles, size_t size)
    181142{
     143        usbdiag_dev_t *dev = ddf_fun_to_usbdiag_dev(fun);
    182144        if (!dev)
    183145                return EBADMEM;
    184146
    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;
     147        return burst_out_test(dev->bulk_out, cycles, size);
    205148}
    206149
    207 int usb_diag_stress_isoch_in(usb_diag_dev_t *dev, int cycles, size_t size)
     150int usbdiag_burst_test_isoch_in(ddf_fun_t *fun, int cycles, size_t size)
    208151{
     152        usbdiag_dev_t *dev = ddf_fun_to_usbdiag_dev(fun);
    209153        if (!dev)
    210154                return EBADMEM;
    211155
    212         char *buffer = (char *) malloc(size);
    213         if (!buffer)
    214                 return ENOMEM;
     156        return burst_in_test(dev->isoch_in, cycles, size);
     157}
    215158
    216         // TODO: Are we sure that no other test is running on this endpoint?
     159int usbdiag_burst_test_isoch_out(ddf_fun_t *fun, int cycles, size_t size)
     160{
     161        usbdiag_dev_t *dev = ddf_fun_to_usbdiag_dev(fun);
     162        if (!dev)
     163                return EBADMEM;
    217164
    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;
     165        return burst_out_test(dev->isoch_out, cycles, size);
    246166}
    247167
  • uspace/drv/bus/usb/usbdiag/tests.h

    r2986763 rb7b7898  
    3434 */
    3535
    36 #ifndef USB_DIAG_TESTS_H_
    37 #define USB_DIAG_TESTS_H_
     36#ifndef USBDIAG_TESTS_H_
     37#define USBDIAG_TESTS_H_
    3838
    39 #include "device.h"
     39#include <ddf/driver.h>
    4040
    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);
    43 int usb_diag_stress_bulk_out(usb_diag_dev_t *, int, size_t);
    44 int usb_diag_stress_bulk_in(usb_diag_dev_t *, int, size_t);
    45 int usb_diag_stress_isoch_out(usb_diag_dev_t *, int, size_t);
    46 int usb_diag_stress_isoch_in(usb_diag_dev_t *, int, size_t);
     41int usbdiag_burst_test_intr_in(ddf_fun_t *, int, size_t);
     42int usbdiag_burst_test_intr_out(ddf_fun_t *, int, size_t);
     43int usbdiag_burst_test_bulk_in(ddf_fun_t *, int, size_t);
     44int usbdiag_burst_test_bulk_out(ddf_fun_t *, int, size_t);
     45int usbdiag_burst_test_isoch_in(ddf_fun_t *, int, size_t);
     46int usbdiag_burst_test_isoch_out(ddf_fun_t *, int, size_t);
    4747
    48 #endif /* USB_DIAG_TESTS_H_ */
     48#endif /* USBDIAG_TESTS_H_ */
    4949
    5050/**
  • uspace/lib/drv/generic/remote_usbdiag.c

    r2986763 rb7b7898  
    4343
    4444typedef enum {
    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,
    49         IPC_M_USBDIAG_STRESS_ISOCH_IN,
    50         IPC_M_USBDIAG_STRESS_ISOCH_OUT
     45        IPC_M_USBDIAG_BURST_INTR_IN,
     46        IPC_M_USBDIAG_BURST_INTR_OUT,
     47        IPC_M_USBDIAG_BURST_BULK_IN,
     48        IPC_M_USBDIAG_BURST_BULK_OUT,
     49        IPC_M_USBDIAG_BURST_ISOCH_IN,
     50        IPC_M_USBDIAG_BURST_ISOCH_OUT
    5151} usb_iface_funcs_t;
    5252
     
    6262}
    6363
    64 int usbdiag_stress_intr_in(async_exch_t *exch, int cycles, size_t size)
    65 {
    66         if (!exch)
    67                 return EBADMEM;
    68 
    69         return async_req_3_0(exch, DEV_IFACE_ID(USBDIAG_DEV_IFACE), IPC_M_USBDIAG_STRESS_INTR_IN, cycles, size);
    70 }
    71 
    72 int usbdiag_stress_intr_out(async_exch_t *exch, int cycles, size_t size)
    73 {
    74         if (!exch)
    75                 return EBADMEM;
    76 
    77         return async_req_3_0(exch, DEV_IFACE_ID(USBDIAG_DEV_IFACE), IPC_M_USBDIAG_STRESS_INTR_OUT, cycles, size);
    78 }
    79 
    80 int usbdiag_stress_bulk_in(async_exch_t *exch, int cycles, size_t size)
    81 {
    82         if (!exch)
    83                 return EBADMEM;
    84 
    85         return async_req_3_0(exch, DEV_IFACE_ID(USBDIAG_DEV_IFACE), IPC_M_USBDIAG_STRESS_BULK_IN, cycles, size);
    86 }
    87 
    88 int usbdiag_stress_bulk_out(async_exch_t *exch, int cycles, size_t size)
    89 {
    90         if (!exch)
    91                 return EBADMEM;
    92 
    93         return async_req_3_0(exch, DEV_IFACE_ID(USBDIAG_DEV_IFACE), IPC_M_USBDIAG_STRESS_BULK_OUT, cycles, size);
    94 }
    95 
    96 int 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 
    104 int 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);
    110 }
    111 
    112 static void remote_usbdiag_stress_intr_in(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    113 static void remote_usbdiag_stress_intr_out(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    114 static void remote_usbdiag_stress_bulk_in(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    115 static void remote_usbdiag_stress_bulk_out(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    116 static void remote_usbdiag_stress_isoch_in(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    117 static void remote_usbdiag_stress_isoch_out(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     64int usbdiag_burst_intr_in(async_exch_t *exch, int cycles, size_t size)
     65{
     66        if (!exch)
     67                return EBADMEM;
     68
     69        return async_req_3_0(exch, DEV_IFACE_ID(USBDIAG_DEV_IFACE), IPC_M_USBDIAG_BURST_INTR_IN, cycles, size);
     70}
     71
     72int usbdiag_burst_intr_out(async_exch_t *exch, int cycles, size_t size)
     73{
     74        if (!exch)
     75                return EBADMEM;
     76
     77        return async_req_3_0(exch, DEV_IFACE_ID(USBDIAG_DEV_IFACE), IPC_M_USBDIAG_BURST_INTR_OUT, cycles, size);
     78}
     79
     80int usbdiag_burst_bulk_in(async_exch_t *exch, int cycles, size_t size)
     81{
     82        if (!exch)
     83                return EBADMEM;
     84
     85        return async_req_3_0(exch, DEV_IFACE_ID(USBDIAG_DEV_IFACE), IPC_M_USBDIAG_BURST_BULK_IN, cycles, size);
     86}
     87
     88int usbdiag_burst_bulk_out(async_exch_t *exch, int cycles, size_t size)
     89{
     90        if (!exch)
     91                return EBADMEM;
     92
     93        return async_req_3_0(exch, DEV_IFACE_ID(USBDIAG_DEV_IFACE), IPC_M_USBDIAG_BURST_BULK_OUT, cycles, size);
     94}
     95
     96int usbdiag_burst_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_BURST_ISOCH_IN, cycles, size);
     102}
     103
     104int usbdiag_burst_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_BURST_ISOCH_OUT, cycles, size);
     110}
     111
     112static void remote_usbdiag_burst_intr_in(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     113static void remote_usbdiag_burst_intr_out(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     114static void remote_usbdiag_burst_bulk_in(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     115static void remote_usbdiag_burst_bulk_out(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     116static void remote_usbdiag_burst_isoch_in(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     117static void remote_usbdiag_burst_isoch_out(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    118118
    119119/** Remote USB diagnostic interface operations. */
    120120static const remote_iface_func_ptr_t remote_usbdiag_iface_ops [] = {
    121         [IPC_M_USBDIAG_STRESS_INTR_IN] = remote_usbdiag_stress_intr_in,
    122         [IPC_M_USBDIAG_STRESS_INTR_OUT] = remote_usbdiag_stress_intr_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
     121        [IPC_M_USBDIAG_BURST_INTR_IN] = remote_usbdiag_burst_intr_in,
     122        [IPC_M_USBDIAG_BURST_INTR_OUT] = remote_usbdiag_burst_intr_out,
     123        [IPC_M_USBDIAG_BURST_BULK_IN] = remote_usbdiag_burst_bulk_in,
     124        [IPC_M_USBDIAG_BURST_BULK_OUT] = remote_usbdiag_burst_bulk_out,
     125        [IPC_M_USBDIAG_BURST_ISOCH_IN] = remote_usbdiag_burst_isoch_in,
     126        [IPC_M_USBDIAG_BURST_ISOCH_OUT] = remote_usbdiag_burst_isoch_out
    127127};
    128128
     
    133133};
    134134
    135 void remote_usbdiag_stress_intr_in(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
    136 {
    137         const usbdiag_iface_t *diag_iface = (usbdiag_iface_t *) iface;
    138 
    139         if (diag_iface->stress_bulk_in == NULL) {
    140                 async_answer_0(callid, ENOTSUP);
    141                 return;
    142         }
    143 
    144         int cycles = DEV_IPC_GET_ARG1(*call);
    145         size_t size = DEV_IPC_GET_ARG2(*call);
    146         const int ret = diag_iface->stress_intr_in(fun, cycles, size);
    147         async_answer_0(callid, ret);
    148 }
    149 
    150 void remote_usbdiag_stress_intr_out(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
    151 {
    152         const usbdiag_iface_t *diag_iface = (usbdiag_iface_t *) iface;
    153 
    154         if (diag_iface->stress_bulk_out == NULL) {
    155                 async_answer_0(callid, ENOTSUP);
    156                 return;
    157         }
    158 
    159         int cycles = DEV_IPC_GET_ARG1(*call);
    160         size_t size = DEV_IPC_GET_ARG2(*call);
    161         const int ret = diag_iface->stress_intr_out(fun, cycles, size);
    162         async_answer_0(callid, ret);
    163 }
    164 
    165 void remote_usbdiag_stress_bulk_in(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
    166 {
    167         const usbdiag_iface_t *diag_iface = (usbdiag_iface_t *) iface;
    168 
    169         if (diag_iface->stress_bulk_in == NULL) {
    170                 async_answer_0(callid, ENOTSUP);
    171                 return;
    172         }
    173 
    174         int cycles = DEV_IPC_GET_ARG1(*call);
    175         size_t size = DEV_IPC_GET_ARG2(*call);
    176         const int ret = diag_iface->stress_bulk_in(fun, cycles, size);
    177         async_answer_0(callid, ret);
    178 }
    179 
    180 void remote_usbdiag_stress_bulk_out(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
    181 {
    182         const usbdiag_iface_t *diag_iface = (usbdiag_iface_t *) iface;
    183 
    184         if (diag_iface->stress_bulk_out == NULL) {
    185                 async_answer_0(callid, ENOTSUP);
    186                 return;
    187         }
    188 
    189         int cycles = DEV_IPC_GET_ARG1(*call);
    190         size_t size = DEV_IPC_GET_ARG2(*call);
    191         const int ret = diag_iface->stress_bulk_out(fun, cycles, size);
    192         async_answer_0(callid, ret);
    193 }
    194 
    195 void 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 
    210 void 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);
     135void remote_usbdiag_burst_intr_in(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
     136{
     137        const usbdiag_iface_t *diag_iface = (usbdiag_iface_t *) iface;
     138
     139        if (diag_iface->burst_bulk_in == NULL) {
     140                async_answer_0(callid, ENOTSUP);
     141                return;
     142        }
     143
     144        int cycles = DEV_IPC_GET_ARG1(*call);
     145        size_t size = DEV_IPC_GET_ARG2(*call);
     146        const int ret = diag_iface->burst_intr_in(fun, cycles, size);
     147        async_answer_0(callid, ret);
     148}
     149
     150void remote_usbdiag_burst_intr_out(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
     151{
     152        const usbdiag_iface_t *diag_iface = (usbdiag_iface_t *) iface;
     153
     154        if (diag_iface->burst_bulk_out == NULL) {
     155                async_answer_0(callid, ENOTSUP);
     156                return;
     157        }
     158
     159        int cycles = DEV_IPC_GET_ARG1(*call);
     160        size_t size = DEV_IPC_GET_ARG2(*call);
     161        const int ret = diag_iface->burst_intr_out(fun, cycles, size);
     162        async_answer_0(callid, ret);
     163}
     164
     165void remote_usbdiag_burst_bulk_in(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
     166{
     167        const usbdiag_iface_t *diag_iface = (usbdiag_iface_t *) iface;
     168
     169        if (diag_iface->burst_bulk_in == NULL) {
     170                async_answer_0(callid, ENOTSUP);
     171                return;
     172        }
     173
     174        int cycles = DEV_IPC_GET_ARG1(*call);
     175        size_t size = DEV_IPC_GET_ARG2(*call);
     176        const int ret = diag_iface->burst_bulk_in(fun, cycles, size);
     177        async_answer_0(callid, ret);
     178}
     179
     180void remote_usbdiag_burst_bulk_out(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
     181{
     182        const usbdiag_iface_t *diag_iface = (usbdiag_iface_t *) iface;
     183
     184        if (diag_iface->burst_bulk_out == NULL) {
     185                async_answer_0(callid, ENOTSUP);
     186                return;
     187        }
     188
     189        int cycles = DEV_IPC_GET_ARG1(*call);
     190        size_t size = DEV_IPC_GET_ARG2(*call);
     191        const int ret = diag_iface->burst_bulk_out(fun, cycles, size);
     192        async_answer_0(callid, ret);
     193}
     194
     195void remote_usbdiag_burst_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->burst_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->burst_isoch_in(fun, cycles, size);
     207        async_answer_0(callid, ret);
     208}
     209
     210void remote_usbdiag_burst_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->burst_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->burst_isoch_out(fun, cycles, size);
    222222        async_answer_0(callid, ret);
    223223}
  • uspace/lib/drv/include/usbdiag_iface.h

    r2986763 rb7b7898  
    4545async_sess_t *usbdiag_connect(devman_handle_t);
    4646void 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);
    49 int usbdiag_stress_bulk_in(async_exch_t*, int, size_t);
    50 int usbdiag_stress_bulk_out(async_exch_t*, int, size_t);
    51 int usbdiag_stress_isoch_in(async_exch_t*, int, size_t);
    52 int usbdiag_stress_isoch_out(async_exch_t*, int, size_t);
     47int usbdiag_burst_intr_in(async_exch_t*, int, size_t);
     48int usbdiag_burst_intr_out(async_exch_t*, int, size_t);
     49int usbdiag_burst_bulk_in(async_exch_t*, int, size_t);
     50int usbdiag_burst_bulk_out(async_exch_t*, int, size_t);
     51int usbdiag_burst_isoch_in(async_exch_t*, int, size_t);
     52int usbdiag_burst_isoch_out(async_exch_t*, int, size_t);
    5353
    5454/** USB diagnostic device communication interface. */
    5555typedef struct {
    56         int (*stress_intr_in)(ddf_fun_t*, int, size_t);
    57         int (*stress_intr_out)(ddf_fun_t*, int, size_t);
    58         int (*stress_bulk_in)(ddf_fun_t*, int, size_t);
    59         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);
     56        int (*burst_intr_in)(ddf_fun_t*, int, size_t);
     57        int (*burst_intr_out)(ddf_fun_t*, int, size_t);
     58        int (*burst_bulk_in)(ddf_fun_t*, int, size_t);
     59        int (*burst_bulk_out)(ddf_fun_t*, int, size_t);
     60        int (*burst_isoch_in)(ddf_fun_t*, int, size_t);
     61        int (*burst_isoch_out)(ddf_fun_t*, int, size_t);
    6262} usbdiag_iface_t;
    6363
Note: See TracChangeset for help on using the changeset viewer.