Software APIs
stream_test.h
1 // Copyright lowRISC contributors (OpenTitan project).
2 // Licensed under the Apache License, Version 2.0, see LICENSE for details.
3 // SPDX-License-Identifier: Apache-2.0
4 #ifndef OPENTITAN_SW_HOST_TESTS_USBDEV_USBDEV_STREAM_STREAM_TEST_H_
5 #define OPENTITAN_SW_HOST_TESTS_USBDEV_USBDEV_STREAM_STREAM_TEST_H_
6 #include <cstdint>
7 
8 // Maximum number of concurrent streams, leaving at least one endpoint for
9 // the Default Control Pipe.
10 #ifdef USBDEV_NUM_ENDPOINTS
11 #define STREAMS_MAX (USBDEV_NUM_ENDPOINTS - 1U)
12 #else
13 #define STREAMS_MAX 11U
14 #endif
15 
16 /**
17  * Simple container for test configuration.
18  */
19 struct TestConfig {
20  /**
21  * Initialize test settings; see descriptions below.
22  */
23  TestConfig(bool init_verb, bool init_retr, bool init_chk, bool init_send)
24  : verbose(init_verb),
25  retrieve(init_retr),
26  check(init_chk),
27  send(init_send),
28 #if STREAMTEST_LIBUSB
29  serial(false),
30 #else
31  serial(true),
32 #endif
33  suspending(false) {
34  }
35  /**
36  * Verbose logging/diagnostic reporting.
37  */
38  bool verbose;
39  /**
40  * Override the stream flags using the command line arguments?
41  */
43  /**
44  * Retrieve data from the device.
45  */
46  bool retrieve;
47  /**
48  * Check the retrieved data against expectations.
49  */
50  bool check;
51  /**
52  * Send data to the device.
53  */
54  bool send;
55  /**
56  * Favor serial ports over libusb for Bulk Transfer streams?
57  */
58  bool serial;
59  /**
60  * Are we performing suspend-resume testing whilst streaming?
61  */
62  bool suspending;
63 };
64 
65 // Has any data yet been received from the device?
66 extern bool received;
67 
68 // Time of first data reception.
69 extern uint64_t start_time;
70 
71 // Configuration settings for the test.
72 extern TestConfig cfg;
73 
74 /**
75  * Report command line syntax.
76  */
77 void ReportSyntax(void);
78 
79 #endif // OPENTITAN_SW_HOST_TESTS_USBDEV_USBDEV_STREAM_STREAM_TEST_H_