This document contains some hints to test the function of the VCHIQ driver
without having additional hardware to the Raspberry Pi.

* Requirements & limitations

Testing the VCHIQ driver requires a Raspberry Pi with one of the following SoC:
  - BCM2835 ( e.g. Raspberry Pi Zero W )
  - BCM2836 ( e.g. Raspberry Pi 2 )
  - BCM2837 ( e.g. Raspberry Pi 3 B+ )

The BCM2711 used in the Raspberry Pi 4 is currently not supported in the
mainline kernel.

There are no specific requirements to the VideoCore firmware to get VCHIQ
working.

The test scenarios described in this document based on the tool vchiq_test.
Its source code is available here: https://github.com/raspberrypi/userland

* Configuration

Here are the most common kernel configurations:

 1. BCM2835 target SoC (ARM 32 bit)

    Just use bcm2835_defconfig which already has VCHIQ enabled.

 2. BCM2836/7 target SoC (ARM 32 bit)

    Use the multi_v7_defconfig as a base and then enable all VCHIQ options.

 3. BCM2837 target SoC (ARM 64 bit)

    Use the defconfig which has most of the VCHIQ options enabled.

* Scenarios

 * Initial test

   Check the driver is probed and /dev/vchiq is created

 * Functional test

   Command: vchiq_test -f 10

   Expected output:
   Functional test - iters:10
   ======== iteration 1 ========
   Testing bulk transfer for alignment.
   Testing bulk transfer at PAGE_SIZE.
   ...

 * Ping test

   Command: vchiq_test -p

   Expected output:
   Ping test - service:echo, iters:1000, version 3
   vchi ping (size 0) -> 57.000000us
   vchi ping (size 0, 0 async, 0 oneway) -> 122.000000us
   vchi bulk (size 0, 0 async, 0 oneway) -> 546.000000us
   vchi bulk (size 0, 0 oneway) -> 230.000000us
   vchi ping (size 0) -> 49.000000us
   vchi ping (size 0, 0 async, 0 oneway) -> 70.000000us
   vchi bulk (size 0, 0 async, 0 oneway) -> 296.000000us
   vchi bulk (size 0, 0 oneway) -> 266.000000us
   vchi ping (size 0, 1 async, 0 oneway) -> 65.000000us
   vchi bulk (size 0, 0 oneway) -> 456.000000us
   vchi ping (size 0, 2 async, 0 oneway) -> 74.000000us
   vchi bulk (size 0, 0 oneway) -> 640.000000us
   vchi ping (size 0, 10 async, 0 oneway) -> 125.000000us
   vchi bulk (size 0, 0 oneway) -> 2309.000000us
   vchi ping (size 0, 0 async, 1 oneway) -> 70.000000us
   vchi ping (size 0, 0 async, 2 oneway) -> 76.000000us
   vchi ping (size 0, 0 async, 10 oneway) -> 105.000000us
   vchi ping (size 0, 10 async, 10 oneway) -> 165.000000us
   vchi ping (size 0, 100 async, 0 oneway) -> nanus
   vchi bulk (size 0, 0 oneway) -> nanus
   vchi ping (size 0, 0 async, 100 oneway) -> nanus
   vchi ping (size 0, 100 async, 100 oneway) -> infus
   vchi ping (size 0, 200 async, 0 oneway) -> infus
   ...

 * Debugfs test

   Command: cat /sys/kernel/debug/vchiq/state

   Example output:
   State 0: CONNECTED
     tx_pos=0x1e8(@43b0acda), rx_pos=0x170(@05493af8)
     Version: 8 (min 3)
     Stats: ctrl_tx_count=7, ctrl_rx_count=7, error_count=0
     Slots: 30 available (29 data), 0 recyclable, 0 stalls (0 data)
     Platform: 2835 (VC master)
     Local: slots 34-64 tx_pos=0x1e8 recycle=0x1f
       Slots claimed:
       DEBUG: SLOT_HANDLER_COUNT = 20(0x14)
       DEBUG: SLOT_HANDLER_LINE = 1937(0x791)
       DEBUG: PARSE_LINE = 1864(0x748)
       DEBUG: PARSE_HEADER = -249155224(0xf1263168)
       DEBUG: PARSE_MSGID = 67362817(0x403e001)
       DEBUG: AWAIT_COMPLETION_LINE = 0(0x0)
       DEBUG: DEQUEUE_MESSAGE_LINE = 0(0x0)
       DEBUG: SERVICE_CALLBACK_LINE = 0(0x0)
       DEBUG: MSG_QUEUE_FULL_COUNT = 0(0x0)
       DEBUG: COMPLETION_QUEUE_FULL_COUNT = 0(0x0)
     Remote: slots 2-32 tx_pos=0x170 recycle=0x1f
       Slots claimed:
         2: 10/9
       DEBUG: SLOT_HANDLER_COUNT = 20(0x14)
       DEBUG: SLOT_HANDLER_LINE = 1851(0x73b)
       DEBUG: PARSE_LINE = 1827(0x723)
       DEBUG: PARSE_HEADER = -150330912(0xf70a21e0)
       DEBUG: PARSE_MSGID = 67113022(0x400103e)
       DEBUG: AWAIT_COMPLETION_LINE = 0(0x0)
       DEBUG: DEQUEUE_MESSAGE_LINE = 0(0x0)
       DEBUG: SERVICE_CALLBACK_LINE = 0(0x0)
       DEBUG: MSG_QUEUE_FULL_COUNT = 0(0x0)
       DEBUG: COMPLETION_QUEUE_FULL_COUNT = 0(0x0)
   Service 0: LISTENING (ref 1) 'PEEK little-endian (0x4b454550)' remote n/a (msg use 0/3840, slot use 0/15)
     Bulk: tx_pending=0 (size 0), rx_pending=0 (size 0)
     Ctrl: tx_count=0, tx_bytes=0, rx_count=0, rx_bytes=0
     Bulk: tx_count=0, tx_bytes=0, rx_count=0, rx_bytes=0
     0 quota stalls, 0 slot stalls, 0 bulk stalls, 0 aborted, 0 errors
     instance b511f60b
