vio_eavb.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserved.
  4. */
  5. #ifndef __VDEV_VIRTIO_EAVB_H__
  6. #define __VDEV_VIRTIO_EAVB_H__
  7. #define IF_NAMESIZE 16
  8. #define STATION_ADDR_SIZE 8
  9. #define MAX_STREAM_NUM 8
  10. #define MAX_CONFIG_FILE_PATH 512
  11. #define VERSION_MAJOR 1
  12. #define VERSION_MINOR 1
  13. #define VIRTIO_EAVB_T_CREATE_STREAM 0
  14. #define VIRTIO_EAVB_T_GET_STREAM_INFO 1
  15. #define VIRTIO_EAVB_T_CONNECT_STREAM 2
  16. #define VIRTIO_EAVB_T_RECEIVE 3
  17. #define VIRTIO_EAVB_T_TRANSMIT 4
  18. #define VIRTIO_EAVB_T_DISCONNECT_STREAM 5
  19. #define VIRTIO_EAVB_T_DESTROY_STREAM 6
  20. #define VIRTIO_EAVB_T_CREATE_STREAM_PATH 7
  21. #define VIRTIO_EAVB_T_VERSION 8
  22. #define VIRTIO_EAVB_T_MMAP 9
  23. #define VIRTIO_EAVB_T_MUNMAP 10
  24. #define VIRTIO_EAVB_T_UPDATE_CLK 11
  25. struct vio_msg_hdr {
  26. uint16_t msgid; /* unique message id */
  27. uint16_t len; /* command total length */
  28. uint32_t cmd; /* command */
  29. uint64_t streamctx_hdl;/* streamCtx handle */
  30. int32_t stream_idx; /* streamCtx idx in BE */
  31. int32_t result; /* command result */
  32. } __packed;
  33. /*
  34. * EAVB_IOCTL_CREATE_STREAM
  35. */
  36. struct vio_stream_config {
  37. uint16_t stream_id;
  38. char eth_interface[IF_NAMESIZE];
  39. uint16_t vlan_id;
  40. uint16_t ring_buffer_elem_count;
  41. int ring_buffer_mode;
  42. int avb_role; /* talker = 0 or listener = 1 */
  43. uint8_t dest_macaddr[STATION_ADDR_SIZE];
  44. uint8_t stream_addr[STATION_ADDR_SIZE];
  45. /* "crf_macaddr" or "crf_dest_macaddr" */
  46. uint8_t crf_dest_macaddr[STATION_ADDR_SIZE];
  47. uint8_t crf_stream_addr[STATION_ADDR_SIZE];
  48. int mapping_type;
  49. int wakeup_interval; /* "wakeup_interval" or "tx_interval" */
  50. int tx_pkts_per_sec; /* if not set, do default */
  51. int max_stale_ms; /* int max_stale_ns = max_stale_ms*1000 */
  52. int presentation_time_ms; /* if not set, do default */
  53. int enforce_presentation_time;
  54. int sr_class_type; /* A = 0 B = 1 AAF = 2 */
  55. /* sets number of items to se sent on each tx / rx */
  56. int packing_factor;
  57. int bandwidth;
  58. /* H.264 */
  59. int max_payload; /* "max_payload" or "max_video_payload" */
  60. int mrp_enabled;
  61. /* Audio Specific */
  62. int pcm_bit_depth;
  63. int pcm_channels;
  64. int sample_rate; /* in hz */
  65. unsigned char endianness; /* 0 = big 1 = little */
  66. int ieee1722_standard;
  67. /* Thread priority in QNX side */
  68. int talker_priority;
  69. int listener_priority;
  70. int crf_priority;
  71. /* CRF */
  72. /* 0 - disabled
  73. * 1 - CRF talker (listener drives reference)
  74. * 2 - CRF with talker reference (talker has CRF talker)
  75. */
  76. int crf_mode;
  77. /* 0 - custom
  78. * 1- audio
  79. * 2- video frame
  80. * 3 - video line
  81. * 4 - machine cycle
  82. */
  83. int crf_type;
  84. /* time interval after how many events timestamp is to be produced
  85. * (base_frequency * pull) / timestamp_interval =
  86. * # of timestamps per second
  87. */
  88. int crf_timestamping_interval;
  89. int crf_timestamping_interval_remote;
  90. int crf_timestamping_interval_local;
  91. /* enables/disables dynamic IPG adjustments */
  92. int crf_allow_dynamic_tx_adjust;
  93. /* indicates how many CRF timestamps per each CRF packet */
  94. int crf_num_timestamps_per_pkt;
  95. int64_t crf_mcr_adjust_min_ppm;
  96. int64_t crf_mcr_adjust_max_ppm;
  97. uint16_t crf_stream_id; /* CRF stream ID */
  98. int32_t crf_base_frequency; /* CRF base frequency */
  99. int32_t crf_listener_ts_smoothing;
  100. int32_t crf_talker_ts_smoothing;
  101. /* multiplier for the base frequency; */
  102. int crf_pull;
  103. /* indicates how often to issue MCR callback events
  104. * how many packets will generate one callback.
  105. */
  106. int crf_event_callback_interval;
  107. /* Indicates how often to update IPG */
  108. int crf_dynamic_tx_adjust_interval;
  109. /* stats */
  110. int32_t enable_stats_reporting;
  111. int32_t stats_reporting_interval;
  112. int32_t stats_reporting_samples;
  113. /* packet tracking */
  114. int32_t enable_packet_tracking;
  115. int32_t packet_tracking_interval;
  116. int blocking_write_enabled;
  117. double blocking_write_fill_level;
  118. int app_tx_block_enabled;
  119. int stream_interleaving_enabled;
  120. int create_talker_thread;
  121. int create_crf_threads;
  122. int listener_bpf_pkts_per_buff;
  123. } __packed;
  124. struct vio_create_stream_msg {
  125. struct vio_msg_hdr mhdr;
  126. struct vio_stream_config cfg;
  127. uint64_t streamCtx;
  128. int32_t stream_idx;
  129. } __packed;
  130. struct vio_create_stream_path_msg {
  131. struct vio_msg_hdr mhdr;
  132. char path[MAX_CONFIG_FILE_PATH];
  133. uint64_t streamCtx;
  134. int32_t stream_idx;
  135. } __packed;
  136. /*
  137. * EAVB_IOCTL_GET_STREAM_INFO
  138. */
  139. struct eavb_stream_info {
  140. int role;
  141. int mapping_type;
  142. /* Max packet payload size */
  143. unsigned int max_payload;
  144. /* Number of packets sent per wake */
  145. unsigned int pkts_per_wake;
  146. /* Time to sleep between wakes */
  147. unsigned int wakeup_period_us;
  148. /* Audio Specific */
  149. /* Audio bit depth 8/16/24/32 */
  150. int pcm_bit_depth;
  151. /* Audio channels 1/2 */
  152. int num_pcm_channels;
  153. /* Audio sample rate in hz */
  154. int sample_rate;
  155. /* Audio sample endianness 0(big)/1(little) */
  156. unsigned char endianness;
  157. /* Max buffer size (Bytes) allowed */
  158. unsigned int max_buffer_size;
  159. /* qavb ring buffer size*/
  160. uint32_t ring_buffer_size;
  161. } __packed;
  162. struct vio_get_stream_info_msg {
  163. struct vio_msg_hdr mhdr;
  164. struct eavb_stream_info stream_info;
  165. } __packed;
  166. /*
  167. * EAVB_IOCTL_CONNECT_STREAM
  168. */
  169. struct vio_connect_stream_msg {
  170. struct vio_msg_hdr mhdr;
  171. } __packed;
  172. /*
  173. * EAVB_IOCTL_RECEIVE
  174. */
  175. struct eavb_buf_hdr {
  176. /* This flag is used for H.264 and MJPEG streams:
  177. * 1. H.264: Set for the very last packet of an access unit.
  178. * 2. MJPEG Set the last packet of a video frame.
  179. */
  180. uint32_t flag_end_of_frame:1;
  181. /* This flag is used in file transfer only:
  182. * Set for the last packet in the file
  183. */
  184. uint32_t flag_end_of_file:1;
  185. uint32_t flag_reserved:30;
  186. /* Audio event Layout D3scription Valid Channels
  187. * event value
  188. * 0 Static layout Based on config
  189. * 1 Mono 0
  190. * 2 Stereo 0, 1
  191. * 3 5.1 0,1,2,3,4,5
  192. * 4 7.1 0,1,2,3,4,5,6,7
  193. * 5-15 Custom Defined by System
  194. * Integrator
  195. */
  196. uint32_t event;
  197. uint32_t reserved;
  198. uint32_t payload_size; /* Size of the payload (bytes) */
  199. uint32_t buf_ele_count;
  200. } __packed;
  201. struct eavb_buf_data {
  202. struct eavb_buf_hdr hdr;
  203. uint64_t gpa; /* GVM physical address of buffer */
  204. } __packed;
  205. struct vio_receive_msg {
  206. struct vio_msg_hdr mhdr;
  207. struct eavb_buf_data data; /* IN/OUT */
  208. int32_t received;
  209. } __packed;
  210. /*
  211. * EAVB_IOCTL_TRANSMIT
  212. */
  213. struct vio_transmit_msg {
  214. struct vio_msg_hdr mhdr;
  215. struct eavb_buf_data data; /* IN/OUT */
  216. int32_t written;
  217. uint32_t mapping_size;
  218. } __packed;
  219. /*
  220. * EAVB_IOCTL_DISCONNECT_STREAM
  221. */
  222. struct vio_disconnect_stream_msg {
  223. struct vio_msg_hdr mhdr;
  224. } __packed;
  225. /*
  226. * EAVB_IOCTL_DESTROY_STREAM
  227. */
  228. struct vio_destroy_stream_msg {
  229. struct vio_msg_hdr mhdr;
  230. } __packed;
  231. /*
  232. * EAVB_IOCTL_VERSION
  233. */
  234. struct vio_version_msg {
  235. struct vio_msg_hdr mhdr; /* IN */
  236. uint16_t major; /* IN */
  237. uint16_t minor; /* IN */
  238. } __packed;
  239. /*
  240. * EAVB_IOCTL_MMAP
  241. */
  242. struct vio_mmap_msg {
  243. struct vio_msg_hdr mhdr; /* IN */
  244. uint32_t size; /* IN */
  245. uint64_t gpa; /* IN */
  246. } __packed;
  247. /*
  248. * EAVB_IOCTL_MUNMAP
  249. */
  250. struct vio_munmap_msg {
  251. struct vio_msg_hdr mhdr; /* IN */
  252. uint64_t gpa; /* IN */
  253. } __packed;
  254. /*
  255. * EAVB_IOCTL_UPDATE_CLK
  256. */
  257. struct vio_update_clk_msg {
  258. struct vio_msg_hdr mhdr; /* IN */
  259. uint64_t clk; /* IN */
  260. } __packed;
  261. #endif /* __VDEV_VIRTIO_EAVB_H__ */