18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (C) 2002 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#ifndef __UM_VECTOR_USER_H
78c2ecf20Sopenharmony_ci#define __UM_VECTOR_USER_H
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#define MAXVARGS	20
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#define TOKEN_IFNAME "ifname"
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#define TRANS_RAW "raw"
148c2ecf20Sopenharmony_ci#define TRANS_RAW_LEN strlen(TRANS_RAW)
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci#define TRANS_TAP "tap"
178c2ecf20Sopenharmony_ci#define TRANS_TAP_LEN strlen(TRANS_TAP)
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#define TRANS_GRE "gre"
208c2ecf20Sopenharmony_ci#define TRANS_GRE_LEN strlen(TRANS_GRE)
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci#define TRANS_L2TPV3 "l2tpv3"
238c2ecf20Sopenharmony_ci#define TRANS_L2TPV3_LEN strlen(TRANS_L2TPV3)
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci#define TRANS_HYBRID "hybrid"
268c2ecf20Sopenharmony_ci#define TRANS_HYBRID_LEN strlen(TRANS_HYBRID)
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#define TRANS_BESS "bess"
298c2ecf20Sopenharmony_ci#define TRANS_BESS_LEN strlen(TRANS_BESS)
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci#define DEFAULT_BPF_LEN 6
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci#ifndef IPPROTO_GRE
348c2ecf20Sopenharmony_ci#define IPPROTO_GRE 0x2F
358c2ecf20Sopenharmony_ci#endif
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci#define GRE_MODE_CHECKSUM	cpu_to_be16(8 << 12)	/* checksum */
388c2ecf20Sopenharmony_ci#define GRE_MODE_RESERVED	cpu_to_be16(4 << 12)	/* unused */
398c2ecf20Sopenharmony_ci#define GRE_MODE_KEY		cpu_to_be16(2 << 12)	/* KEY present */
408c2ecf20Sopenharmony_ci#define GRE_MODE_SEQUENCE	cpu_to_be16(1 << 12)	/* sequence */
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci#define GRE_IRB cpu_to_be16(0x6558)
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci#define L2TPV3_DATA_PACKET 0x30000
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci/* IANA-assigned IP protocol ID for L2TPv3 */
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci#ifndef IPPROTO_L2TP
498c2ecf20Sopenharmony_ci#define IPPROTO_L2TP 0x73
508c2ecf20Sopenharmony_ci#endif
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_cistruct arglist {
538c2ecf20Sopenharmony_ci	int	numargs;
548c2ecf20Sopenharmony_ci	char	*tokens[MAXVARGS];
558c2ecf20Sopenharmony_ci	char	*values[MAXVARGS];
568c2ecf20Sopenharmony_ci};
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci/* Separating read and write FDs allows us to have different
598c2ecf20Sopenharmony_ci * rx and tx method. Example - read tap via raw socket using
608c2ecf20Sopenharmony_ci * recvmmsg, write using legacy tap write calls
618c2ecf20Sopenharmony_ci */
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_cistruct vector_fds {
648c2ecf20Sopenharmony_ci	int rx_fd;
658c2ecf20Sopenharmony_ci	int tx_fd;
668c2ecf20Sopenharmony_ci	void *remote_addr;
678c2ecf20Sopenharmony_ci	int remote_addr_size;
688c2ecf20Sopenharmony_ci};
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci#define VECTOR_READ	1
718c2ecf20Sopenharmony_ci#define VECTOR_WRITE	(1 < 1)
728c2ecf20Sopenharmony_ci#define VECTOR_HEADERS	(1 < 2)
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ciextern struct arglist *uml_parse_vector_ifspec(char *arg);
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ciextern struct vector_fds *uml_vector_user_open(
778c2ecf20Sopenharmony_ci	int unit,
788c2ecf20Sopenharmony_ci	struct arglist *parsed
798c2ecf20Sopenharmony_ci);
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ciextern char *uml_vector_fetch_arg(
828c2ecf20Sopenharmony_ci	struct arglist *ifspec,
838c2ecf20Sopenharmony_ci	char *token
848c2ecf20Sopenharmony_ci);
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ciextern int uml_vector_recvmsg(int fd, void *hdr, int flags);
878c2ecf20Sopenharmony_ciextern int uml_vector_sendmsg(int fd, void *hdr, int flags);
888c2ecf20Sopenharmony_ciextern int uml_vector_writev(int fd, void *hdr, int iovcount);
898c2ecf20Sopenharmony_ciextern int uml_vector_sendmmsg(
908c2ecf20Sopenharmony_ci	int fd, void *msgvec,
918c2ecf20Sopenharmony_ci	unsigned int vlen,
928c2ecf20Sopenharmony_ci	unsigned int flags
938c2ecf20Sopenharmony_ci);
948c2ecf20Sopenharmony_ciextern int uml_vector_recvmmsg(
958c2ecf20Sopenharmony_ci	int fd,
968c2ecf20Sopenharmony_ci	void *msgvec,
978c2ecf20Sopenharmony_ci	unsigned int vlen,
988c2ecf20Sopenharmony_ci	unsigned int flags
998c2ecf20Sopenharmony_ci);
1008c2ecf20Sopenharmony_ciextern void *uml_vector_default_bpf(void *mac);
1018c2ecf20Sopenharmony_ciextern void *uml_vector_user_bpf(char *filename);
1028c2ecf20Sopenharmony_ciextern int uml_vector_attach_bpf(int fd, void *bpf);
1038c2ecf20Sopenharmony_ciextern int uml_vector_detach_bpf(int fd, void *bpf);
1048c2ecf20Sopenharmony_ciextern bool uml_raw_enable_qdisc_bypass(int fd);
1058c2ecf20Sopenharmony_ciextern bool uml_raw_enable_vnet_headers(int fd);
1068c2ecf20Sopenharmony_ciextern bool uml_tap_enable_vnet_headers(int fd);
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ci#endif
110