1*dbddf429SAlex Dewar /* SPDX-License-Identifier: GPL-2.0 */ 249da7e64SAnton Ivanov /* 349da7e64SAnton Ivanov * Copyright (C) 2002 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) 449da7e64SAnton Ivanov */ 549da7e64SAnton Ivanov 649da7e64SAnton Ivanov #ifndef __UM_VECTOR_USER_H 749da7e64SAnton Ivanov #define __UM_VECTOR_USER_H 849da7e64SAnton Ivanov 949da7e64SAnton Ivanov #define MAXVARGS 20 1049da7e64SAnton Ivanov 1149da7e64SAnton Ivanov #define TOKEN_IFNAME "ifname" 1249da7e64SAnton Ivanov 1349da7e64SAnton Ivanov #define TRANS_RAW "raw" 1449da7e64SAnton Ivanov #define TRANS_RAW_LEN strlen(TRANS_RAW) 1549da7e64SAnton Ivanov 1649da7e64SAnton Ivanov #define TRANS_TAP "tap" 1749da7e64SAnton Ivanov #define TRANS_TAP_LEN strlen(TRANS_TAP) 1849da7e64SAnton Ivanov 1949da7e64SAnton Ivanov #define TRANS_GRE "gre" 2049da7e64SAnton Ivanov #define TRANS_GRE_LEN strlen(TRANS_RAW) 2149da7e64SAnton Ivanov 2249da7e64SAnton Ivanov #define TRANS_L2TPV3 "l2tpv3" 2349da7e64SAnton Ivanov #define TRANS_L2TPV3_LEN strlen(TRANS_L2TPV3) 2449da7e64SAnton Ivanov 25b3b8ca2aSAnton Ivanov #define TRANS_HYBRID "hybrid" 26b3b8ca2aSAnton Ivanov #define TRANS_HYBRID_LEN strlen(TRANS_HYBRID) 27b3b8ca2aSAnton Ivanov 2877f1073cSAnton Ivanov #define TRANS_BESS "bess" 2977f1073cSAnton Ivanov #define TRANS_BESS_LEN strlen(TRANS_BESS) 3077f1073cSAnton Ivanov 3149da7e64SAnton Ivanov #ifndef IPPROTO_GRE 3249da7e64SAnton Ivanov #define IPPROTO_GRE 0x2F 3349da7e64SAnton Ivanov #endif 3449da7e64SAnton Ivanov 3549da7e64SAnton Ivanov #define GRE_MODE_CHECKSUM cpu_to_be16(8 << 12) /* checksum */ 3649da7e64SAnton Ivanov #define GRE_MODE_RESERVED cpu_to_be16(4 << 12) /* unused */ 3749da7e64SAnton Ivanov #define GRE_MODE_KEY cpu_to_be16(2 << 12) /* KEY present */ 3849da7e64SAnton Ivanov #define GRE_MODE_SEQUENCE cpu_to_be16(1 << 12) /* sequence */ 3949da7e64SAnton Ivanov 4049da7e64SAnton Ivanov #define GRE_IRB cpu_to_be16(0x6558) 4149da7e64SAnton Ivanov 4249da7e64SAnton Ivanov #define L2TPV3_DATA_PACKET 0x30000 4349da7e64SAnton Ivanov 4449da7e64SAnton Ivanov /* IANA-assigned IP protocol ID for L2TPv3 */ 4549da7e64SAnton Ivanov 4649da7e64SAnton Ivanov #ifndef IPPROTO_L2TP 4749da7e64SAnton Ivanov #define IPPROTO_L2TP 0x73 4849da7e64SAnton Ivanov #endif 4949da7e64SAnton Ivanov 5049da7e64SAnton Ivanov struct arglist { 5149da7e64SAnton Ivanov int numargs; 5249da7e64SAnton Ivanov char *tokens[MAXVARGS]; 5349da7e64SAnton Ivanov char *values[MAXVARGS]; 5449da7e64SAnton Ivanov }; 5549da7e64SAnton Ivanov 5649da7e64SAnton Ivanov /* Separating read and write FDs allows us to have different 5749da7e64SAnton Ivanov * rx and tx method. Example - read tap via raw socket using 5849da7e64SAnton Ivanov * recvmmsg, write using legacy tap write calls 5949da7e64SAnton Ivanov */ 6049da7e64SAnton Ivanov 6149da7e64SAnton Ivanov struct vector_fds { 6249da7e64SAnton Ivanov int rx_fd; 6349da7e64SAnton Ivanov int tx_fd; 6449da7e64SAnton Ivanov void *remote_addr; 6549da7e64SAnton Ivanov int remote_addr_size; 6649da7e64SAnton Ivanov }; 6749da7e64SAnton Ivanov 6849da7e64SAnton Ivanov #define VECTOR_READ 1 6949da7e64SAnton Ivanov #define VECTOR_WRITE (1 < 1) 7049da7e64SAnton Ivanov #define VECTOR_HEADERS (1 < 2) 7149da7e64SAnton Ivanov 7249da7e64SAnton Ivanov extern struct arglist *uml_parse_vector_ifspec(char *arg); 7349da7e64SAnton Ivanov 7449da7e64SAnton Ivanov extern struct vector_fds *uml_vector_user_open( 7549da7e64SAnton Ivanov int unit, 7649da7e64SAnton Ivanov struct arglist *parsed 7749da7e64SAnton Ivanov ); 7849da7e64SAnton Ivanov 7949da7e64SAnton Ivanov extern char *uml_vector_fetch_arg( 8049da7e64SAnton Ivanov struct arglist *ifspec, 8149da7e64SAnton Ivanov char *token 8249da7e64SAnton Ivanov ); 8349da7e64SAnton Ivanov 8449da7e64SAnton Ivanov extern int uml_vector_recvmsg(int fd, void *hdr, int flags); 8549da7e64SAnton Ivanov extern int uml_vector_sendmsg(int fd, void *hdr, int flags); 8649da7e64SAnton Ivanov extern int uml_vector_writev(int fd, void *hdr, int iovcount); 8749da7e64SAnton Ivanov extern int uml_vector_sendmmsg( 8849da7e64SAnton Ivanov int fd, void *msgvec, 8949da7e64SAnton Ivanov unsigned int vlen, 9049da7e64SAnton Ivanov unsigned int flags 9149da7e64SAnton Ivanov ); 9249da7e64SAnton Ivanov extern int uml_vector_recvmmsg( 9349da7e64SAnton Ivanov int fd, 9449da7e64SAnton Ivanov void *msgvec, 9549da7e64SAnton Ivanov unsigned int vlen, 9649da7e64SAnton Ivanov unsigned int flags 9749da7e64SAnton Ivanov ); 9849da7e64SAnton Ivanov extern void *uml_vector_default_bpf(int fd, void *mac); 9949da7e64SAnton Ivanov extern int uml_vector_attach_bpf(int fd, void *bpf, int bpf_len); 100e40238deSAnton Ivanov extern bool uml_raw_enable_qdisc_bypass(int fd); 10149da7e64SAnton Ivanov extern bool uml_raw_enable_vnet_headers(int fd); 10249da7e64SAnton Ivanov extern bool uml_tap_enable_vnet_headers(int fd); 10349da7e64SAnton Ivanov 10449da7e64SAnton Ivanov 10549da7e64SAnton Ivanov #endif 106