Thomas Gleixner | 4e43d77 | 2019-05-29 07:18:04 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Caz Yokoyama | 8d49751 | 2013-09-05 16:42:39 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Intel MIC Platform Software Stack (MPSS) |
| 4 | * |
| 5 | * Copyright(c) 2013 Intel Corporation. |
| 6 | * |
Caz Yokoyama | 8d49751 | 2013-09-05 16:42:39 -0700 | [diff] [blame] | 7 | * Intel MIC User Space Tools. |
| 8 | */ |
| 9 | #ifndef _MPSSD_H_ |
| 10 | #define _MPSSD_H_ |
| 11 | |
| 12 | #include <stdio.h> |
| 13 | #include <stdlib.h> |
| 14 | #include <string.h> |
| 15 | #include <fcntl.h> |
| 16 | #include <unistd.h> |
| 17 | #include <dirent.h> |
| 18 | #include <libgen.h> |
| 19 | #include <pthread.h> |
| 20 | #include <stdarg.h> |
| 21 | #include <time.h> |
| 22 | #include <errno.h> |
| 23 | #include <sys/dir.h> |
| 24 | #include <sys/ioctl.h> |
| 25 | #include <sys/poll.h> |
| 26 | #include <sys/types.h> |
| 27 | #include <sys/socket.h> |
| 28 | #include <sys/stat.h> |
Caz Yokoyama | 8d49751 | 2013-09-05 16:42:39 -0700 | [diff] [blame] | 29 | #include <sys/mman.h> |
| 30 | #include <sys/utsname.h> |
| 31 | #include <sys/wait.h> |
| 32 | #include <netinet/in.h> |
| 33 | #include <arpa/inet.h> |
| 34 | #include <netdb.h> |
Caz Yokoyama | 8d49751 | 2013-09-05 16:42:39 -0700 | [diff] [blame] | 35 | #include <signal.h> |
| 36 | #include <limits.h> |
| 37 | #include <syslog.h> |
| 38 | #include <getopt.h> |
| 39 | #include <net/if.h> |
| 40 | #include <linux/if_tun.h> |
Caz Yokoyama | 8d49751 | 2013-09-05 16:42:39 -0700 | [diff] [blame] | 41 | #include <linux/virtio_ids.h> |
| 42 | |
| 43 | #define MICSYSFSDIR "/sys/class/mic" |
| 44 | #define LOGFILE_NAME "/var/log/mpssd" |
| 45 | #define PAGE_SIZE 4096 |
| 46 | |
| 47 | struct mic_console_info { |
| 48 | pthread_t console_thread; |
| 49 | int virtio_console_fd; |
| 50 | void *console_dp; |
| 51 | }; |
| 52 | |
| 53 | struct mic_net_info { |
| 54 | pthread_t net_thread; |
| 55 | int virtio_net_fd; |
| 56 | int tap_fd; |
| 57 | void *net_dp; |
| 58 | }; |
| 59 | |
| 60 | struct mic_virtblk_info { |
| 61 | pthread_t block_thread; |
| 62 | int virtio_block_fd; |
| 63 | void *block_dp; |
| 64 | volatile sig_atomic_t signaled; |
| 65 | char *backend_file; |
| 66 | int backend; |
| 67 | void *backend_addr; |
| 68 | long backend_size; |
| 69 | }; |
| 70 | |
| 71 | struct mic_info { |
| 72 | int id; |
| 73 | char *name; |
| 74 | pthread_t config_thread; |
Ashutosh Dixit | f4a66c2 | 2015-09-29 18:14:30 -0700 | [diff] [blame] | 75 | pthread_t init_thread; |
Caz Yokoyama | 8d49751 | 2013-09-05 16:42:39 -0700 | [diff] [blame] | 76 | pid_t pid; |
| 77 | struct mic_console_info mic_console; |
| 78 | struct mic_net_info mic_net; |
| 79 | struct mic_virtblk_info mic_virtblk; |
| 80 | int restart; |
Dasaratharaman Chandramouli | af19049 | 2013-10-03 18:06:23 -0700 | [diff] [blame] | 81 | int boot_on_resume; |
Caz Yokoyama | 8d49751 | 2013-09-05 16:42:39 -0700 | [diff] [blame] | 82 | struct mic_info *next; |
| 83 | }; |
| 84 | |
Sudeep Dutt | 6078e0b | 2013-10-02 16:09:00 -0700 | [diff] [blame] | 85 | __attribute__((format(printf, 1, 2))) |
Caz Yokoyama | 8d49751 | 2013-09-05 16:42:39 -0700 | [diff] [blame] | 86 | void mpsslog(char *format, ...); |
| 87 | char *readsysfs(char *dir, char *entry); |
| 88 | int setsysfs(char *dir, char *entry, char *value); |
| 89 | #endif |