138062f954c637861348dd8078cefb73554e6f12cChristopher Ferris/****************************************************************************
238062f954c637861348dd8078cefb73554e6f12cChristopher Ferris ****************************************************************************
338062f954c637861348dd8078cefb73554e6f12cChristopher Ferris ***
438062f954c637861348dd8078cefb73554e6f12cChristopher Ferris ***   This header was automatically generated from a Linux kernel header
538062f954c637861348dd8078cefb73554e6f12cChristopher Ferris ***   of the same name, to make information necessary for userspace to
638062f954c637861348dd8078cefb73554e6f12cChristopher Ferris ***   call into the kernel available to libc.  It contains only constants,
738062f954c637861348dd8078cefb73554e6f12cChristopher Ferris ***   structures, and macros generated from the original header, and thus,
838062f954c637861348dd8078cefb73554e6f12cChristopher Ferris ***   contains no copyrightable information.
938062f954c637861348dd8078cefb73554e6f12cChristopher Ferris ***
1038062f954c637861348dd8078cefb73554e6f12cChristopher Ferris ***   To edit the content of this header, modify the corresponding
1138062f954c637861348dd8078cefb73554e6f12cChristopher Ferris ***   source file (e.g. under external/kernel-headers/original/) then
1238062f954c637861348dd8078cefb73554e6f12cChristopher Ferris ***   run bionic/libc/kernel/tools/update_all.py
1338062f954c637861348dd8078cefb73554e6f12cChristopher Ferris ***
1438062f954c637861348dd8078cefb73554e6f12cChristopher Ferris ***   Any manual change here will be lost the next time this script will
1538062f954c637861348dd8078cefb73554e6f12cChristopher Ferris ***   be run. You've been warned!
1638062f954c637861348dd8078cefb73554e6f12cChristopher Ferris ***
1738062f954c637861348dd8078cefb73554e6f12cChristopher Ferris ****************************************************************************
1838062f954c637861348dd8078cefb73554e6f12cChristopher Ferris ****************************************************************************/
1938062f954c637861348dd8078cefb73554e6f12cChristopher Ferris#ifndef __MIC_COMMON_H_
2038062f954c637861348dd8078cefb73554e6f12cChristopher Ferris#define __MIC_COMMON_H_
2138062f954c637861348dd8078cefb73554e6f12cChristopher Ferris#include <linux/virtio_ring.h>
22d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao#define __mic_align(a,x) (((a) + (x) - 1) & ~((x) - 1))
2338062f954c637861348dd8078cefb73554e6f12cChristopher Ferrisstruct mic_device_desc {
24d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  __s8 type;
25d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  __u8 num_vq;
26d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  __u8 feature_len;
27d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  __u8 config_len;
28d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  __u8 status;
29d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  __le64 config[0];
30d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao} __attribute__((aligned(8)));
3138062f954c637861348dd8078cefb73554e6f12cChristopher Ferrisstruct mic_device_ctrl {
32d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  __le64 vdev;
33d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  __u8 config_change;
34d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  __u8 vdev_reset;
35d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  __u8 guest_ack;
36d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  __u8 host_ack;
37d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  __u8 used_address_updated;
38d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  __s8 c2h_vdev_db;
39d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  __s8 h2c_vdev_db;
40d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao} __attribute__((aligned(8)));
4138062f954c637861348dd8078cefb73554e6f12cChristopher Ferrisstruct mic_bootparam {
42d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  __le32 magic;
43d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  __s8 h2c_config_db;
4405d08e9716b5974d6ed08973f44930804890b902Christopher Ferris  __u8 node_id;
4505d08e9716b5974d6ed08973f44930804890b902Christopher Ferris  __u8 h2c_scif_db;
4605d08e9716b5974d6ed08973f44930804890b902Christopher Ferris  __u8 c2h_scif_db;
4705d08e9716b5974d6ed08973f44930804890b902Christopher Ferris  __u64 scif_host_dma_addr;
4805d08e9716b5974d6ed08973f44930804890b902Christopher Ferris  __u64 scif_card_dma_addr;
49d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao} __attribute__((aligned(8)));
5038062f954c637861348dd8078cefb73554e6f12cChristopher Ferrisstruct mic_device_page {
5105d08e9716b5974d6ed08973f44930804890b902Christopher Ferris  struct mic_bootparam bootparam;
52d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  struct mic_device_desc desc[0];
5338062f954c637861348dd8078cefb73554e6f12cChristopher Ferris};
5438062f954c637861348dd8078cefb73554e6f12cChristopher Ferrisstruct mic_vqconfig {
5505d08e9716b5974d6ed08973f44930804890b902Christopher Ferris  __le64 address;
56d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  __le64 used_address;
57d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  __le16 num;
58d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao} __attribute__((aligned(8)));
5905d08e9716b5974d6ed08973f44930804890b902Christopher Ferris#define MIC_VIRTIO_RING_ALIGN 4096
6038062f954c637861348dd8078cefb73554e6f12cChristopher Ferris#define MIC_MAX_VRINGS 4
6138062f954c637861348dd8078cefb73554e6f12cChristopher Ferris#define MIC_VRING_ENTRIES 128
6238062f954c637861348dd8078cefb73554e6f12cChristopher Ferris#define MIC_MAX_VRING_ENTRIES 128
6305d08e9716b5974d6ed08973f44930804890b902Christopher Ferris#define MIC_MAX_DESC_BLK_SIZE 256
6438062f954c637861348dd8078cefb73554e6f12cChristopher Ferrisstruct _mic_vring_info {
65d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  __u16 avail_idx;
66d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  __le32 magic;
6705d08e9716b5974d6ed08973f44930804890b902Christopher Ferris};
6838062f954c637861348dd8078cefb73554e6f12cChristopher Ferrisstruct mic_vring {
69d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  struct vring vr;
70d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  struct _mic_vring_info * info;
7105d08e9716b5974d6ed08973f44930804890b902Christopher Ferris  void * va;
72d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  int len;
7338062f954c637861348dd8078cefb73554e6f12cChristopher Ferris};
7438062f954c637861348dd8078cefb73554e6f12cChristopher Ferris#define mic_aligned_desc_size(d) __mic_align(mic_desc_size(d), 8)
7505d08e9716b5974d6ed08973f44930804890b902Christopher Ferris#ifndef INTEL_MIC_CARD
7638062f954c637861348dd8078cefb73554e6f12cChristopher Ferris#endif
7738062f954c637861348dd8078cefb73554e6f12cChristopher Ferris#define MIC_DP_SIZE 4096
7838062f954c637861348dd8078cefb73554e6f12cChristopher Ferris#define MIC_MAGIC 0xc0ffee00
7905d08e9716b5974d6ed08973f44930804890b902Christopher Ferrisenum mic_states {
8005d08e9716b5974d6ed08973f44930804890b902Christopher Ferris  MIC_READY = 0,
8105d08e9716b5974d6ed08973f44930804890b902Christopher Ferris  MIC_BOOTING,
82d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  MIC_ONLINE,
83d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  MIC_SHUTTING_DOWN,
8405d08e9716b5974d6ed08973f44930804890b902Christopher Ferris  MIC_RESETTING,
85d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  MIC_RESET_FAILED,
86d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  MIC_LAST
8705d08e9716b5974d6ed08973f44930804890b902Christopher Ferris};
8838062f954c637861348dd8078cefb73554e6f12cChristopher Ferrisenum mic_status {
89d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  MIC_NOP = 0,
90d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  MIC_CRASHED,
9105d08e9716b5974d6ed08973f44930804890b902Christopher Ferris  MIC_HALTED,
92d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  MIC_POWER_OFF,
93d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  MIC_RESTART,
94d7db594b8d1dab36b711bd887a9dd21675c87243Tao Bao  MIC_STATUS_LAST
9505d08e9716b5974d6ed08973f44930804890b902Christopher Ferris};
9638062f954c637861348dd8078cefb73554e6f12cChristopher Ferris#endif
97