1bc49d816SJeremy Kerr /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2bc49d816SJeremy Kerr /* 3bc49d816SJeremy Kerr * Management Component Transport Protocol (MCTP) 4bc49d816SJeremy Kerr * 5bc49d816SJeremy Kerr * Copyright (c) 2021 Code Construct 6bc49d816SJeremy Kerr * Copyright (c) 2021 Google 7bc49d816SJeremy Kerr */ 8bc49d816SJeremy Kerr 9bc49d816SJeremy Kerr #ifndef __UAPI_MCTP_H 10bc49d816SJeremy Kerr #define __UAPI_MCTP_H 11bc49d816SJeremy Kerr 1260fc6398SJeremy Kerr #include <linux/types.h> 13b416beb2SJeremy Kerr #include <linux/socket.h> 1499ce45d5SJeremy Kerr #include <linux/netdevice.h> 1560fc6398SJeremy Kerr 1660fc6398SJeremy Kerr typedef __u8 mctp_eid_t; 1760fc6398SJeremy Kerr 1860fc6398SJeremy Kerr struct mctp_addr { 1960fc6398SJeremy Kerr mctp_eid_t s_addr; 20bc49d816SJeremy Kerr }; 21bc49d816SJeremy Kerr 2260fc6398SJeremy Kerr struct sockaddr_mctp { 23b416beb2SJeremy Kerr __kernel_sa_family_t smctp_family; 245a20dd46SJeremy Kerr __u16 __smctp_pad0; 25b416beb2SJeremy Kerr unsigned int smctp_network; 2660fc6398SJeremy Kerr struct mctp_addr smctp_addr; 2760fc6398SJeremy Kerr __u8 smctp_type; 2860fc6398SJeremy Kerr __u8 smctp_tag; 295a20dd46SJeremy Kerr __u8 __smctp_pad1; 3060fc6398SJeremy Kerr }; 3160fc6398SJeremy Kerr 3299ce45d5SJeremy Kerr struct sockaddr_mctp_ext { 3399ce45d5SJeremy Kerr struct sockaddr_mctp smctp_base; 3499ce45d5SJeremy Kerr int smctp_ifindex; 3599ce45d5SJeremy Kerr __u8 smctp_halen; 3699ce45d5SJeremy Kerr __u8 __smctp_pad0[3]; 3799ce45d5SJeremy Kerr __u8 smctp_haddr[MAX_ADDR_LEN]; 3899ce45d5SJeremy Kerr }; 3999ce45d5SJeremy Kerr 4060fc6398SJeremy Kerr #define MCTP_NET_ANY 0x0 4160fc6398SJeremy Kerr 4260fc6398SJeremy Kerr #define MCTP_ADDR_NULL 0x00 4360fc6398SJeremy Kerr #define MCTP_ADDR_ANY 0xff 4460fc6398SJeremy Kerr 4560fc6398SJeremy Kerr #define MCTP_TAG_MASK 0x07 4660fc6398SJeremy Kerr #define MCTP_TAG_OWNER 0x08 4763ed1aabSMatt Johnston #define MCTP_TAG_PREALLOC 0x10 4860fc6398SJeremy Kerr 4999ce45d5SJeremy Kerr #define MCTP_OPT_ADDR_EXT 1 5099ce45d5SJeremy Kerr 5163ed1aabSMatt Johnston #define SIOCMCTPALLOCTAG (SIOCPROTOPRIVATE + 0) 5263ed1aabSMatt Johnston #define SIOCMCTPDROPTAG (SIOCPROTOPRIVATE + 1) 53*c16d2380SJeremy Kerr #define SIOCMCTPALLOCTAG2 (SIOCPROTOPRIVATE + 2) 54*c16d2380SJeremy Kerr #define SIOCMCTPDROPTAG2 (SIOCPROTOPRIVATE + 3) 5563ed1aabSMatt Johnston 56*c16d2380SJeremy Kerr /* Deprecated: use mctp_ioc_tag_ctl2 / TAG2 ioctls instead, which defines the 57*c16d2380SJeremy Kerr * MCTP network ID as part of the allocated tag. Using this assumes the default 58*c16d2380SJeremy Kerr * net ID for allocated tags, which may not give correct behaviour on system 59*c16d2380SJeremy Kerr * with multiple networks configured. 60*c16d2380SJeremy Kerr */ 6163ed1aabSMatt Johnston struct mctp_ioc_tag_ctl { 6263ed1aabSMatt Johnston mctp_eid_t peer_addr; 6363ed1aabSMatt Johnston 6463ed1aabSMatt Johnston /* For SIOCMCTPALLOCTAG: must be passed as zero, kernel will 6563ed1aabSMatt Johnston * populate with the allocated tag value. Returned tag value will 6663ed1aabSMatt Johnston * always have TO and PREALLOC set. 6763ed1aabSMatt Johnston * 6863ed1aabSMatt Johnston * For SIOCMCTPDROPTAG: userspace provides tag value to drop, from 6963ed1aabSMatt Johnston * a prior SIOCMCTPALLOCTAG call (and so must have TO and PREALLOC set). 7063ed1aabSMatt Johnston */ 7163ed1aabSMatt Johnston __u8 tag; 7263ed1aabSMatt Johnston __u16 flags; 7363ed1aabSMatt Johnston }; 7463ed1aabSMatt Johnston 75*c16d2380SJeremy Kerr struct mctp_ioc_tag_ctl2 { 76*c16d2380SJeremy Kerr /* Peer details: network ID, peer EID, local EID. All set by the 77*c16d2380SJeremy Kerr * caller. 78*c16d2380SJeremy Kerr * 79*c16d2380SJeremy Kerr * Local EID must be MCTP_ADDR_NULL or MCTP_ADDR_ANY in current 80*c16d2380SJeremy Kerr * kernels. 81*c16d2380SJeremy Kerr */ 82*c16d2380SJeremy Kerr unsigned int net; 83*c16d2380SJeremy Kerr mctp_eid_t peer_addr; 84*c16d2380SJeremy Kerr mctp_eid_t local_addr; 85*c16d2380SJeremy Kerr 86*c16d2380SJeremy Kerr /* Set by caller, but no flags defined currently. Must be 0 */ 87*c16d2380SJeremy Kerr __u16 flags; 88*c16d2380SJeremy Kerr 89*c16d2380SJeremy Kerr /* For SIOCMCTPALLOCTAG2: must be passed as zero, kernel will 90*c16d2380SJeremy Kerr * populate with the allocated tag value. Returned tag value will 91*c16d2380SJeremy Kerr * always have TO and PREALLOC set. 92*c16d2380SJeremy Kerr * 93*c16d2380SJeremy Kerr * For SIOCMCTPDROPTAG2: userspace provides tag value to drop, from 94*c16d2380SJeremy Kerr * a prior SIOCMCTPALLOCTAG2 call (and so must have TO and PREALLOC set). 95*c16d2380SJeremy Kerr */ 96*c16d2380SJeremy Kerr __u8 tag; 97*c16d2380SJeremy Kerr 98*c16d2380SJeremy Kerr }; 99*c16d2380SJeremy Kerr 100bc49d816SJeremy Kerr #endif /* __UAPI_MCTP_H */ 101