1181834Sroberto/* 2181834Sroberto * Copyright 2007, Hugo Santos. All Rights Reserved. 3290001Sglebius * Distributed under the terms of the MIT License. 4181834Sroberto */ 5181834Sroberto#ifndef _FBSD_COMPAT_NET_IF_H_ 6290001Sglebius#define _FBSD_COMPAT_NET_IF_H_ 7181834Sroberto 8181834Sroberto 9181834Sroberto#include <posix/net/if.h> 10181834Sroberto 11181834Sroberto#include <sys/cdefs.h> 12181834Sroberto#include <sys/queue.h> 13181834Sroberto#include <sys/time.h> 14181834Sroberto 15181834Sroberto 16181834Sroberto#define IF_Kbps(x) ((uintmax_t)(x) * 1000) 17181834Sroberto#define IF_Mbps(x) (IF_Kbps((x) * 1000)) 18181834Sroberto#define IF_Gbps(x) (IF_Mbps((x) * 1000)) 19181834Sroberto 20181834Sroberto/* Capabilities that interfaces can advertise. */ 21181834Sroberto#define IFCAP_RXCSUM 0x00001 /* can offload checksum on RX */ 22181834Sroberto#define IFCAP_TXCSUM 0x00002 /* can offload checksum on TX */ 23181834Sroberto#define IFCAP_NETCONS 0x00004 /* can be a network console */ 24181834Sroberto#define IFCAP_VLAN_MTU 0x00008 /* VLAN-compatible MTU */ 25181834Sroberto#define IFCAP_VLAN_HWTAGGING 0x00010 /* hardware VLAN tag support */ 26181834Sroberto#define IFCAP_JUMBO_MTU 0x00020 /* 9000 byte MTU supported */ 27181834Sroberto#define IFCAP_POLLING 0x00040 /* driver supports polling */ 28181834Sroberto#define IFCAP_VLAN_HWCSUM 0x00080 /* can do IFCAP_HWCSUM on VLANs */ 29181834Sroberto#define IFCAP_TSO4 0x00100 /* can do TCP Segmentation Offload */ 30181834Sroberto#define IFCAP_TSO6 0x00200 /* can do TCP6 Segmentation Offload */ 31181834Sroberto#define IFCAP_LRO 0x00400 /* can do Large Receive Offload */ 32181834Sroberto#define IFCAP_WOL_UCAST 0x00800 /* wake on any unicast frame */ 33181834Sroberto#define IFCAP_WOL_MCAST 0x01000 /* wake on any multicast frame */ 34181834Sroberto#define IFCAP_WOL_MAGIC 0x02000 /* wake on any Magic Packet */ 35181834Sroberto#define IFCAP_TOE4 0x04000 /* interface can offload TCP */ 36181834Sroberto#define IFCAP_TOE6 0x08000 /* interface can offload TCP6 */ 37181834Sroberto#define IFCAP_VLAN_HWFILTER 0x10000 /* interface hw can filter vlan tag */ 38181834Sroberto/* available 0x20000 */ 39181834Sroberto#define IFCAP_VLAN_HWTSO 0x40000 /* can do IFCAP_TSO on VLANs */ 40181834Sroberto#define IFCAP_LINKSTATE 0x80000 /* the runtime link state is dynamic */ 41181834Sroberto#define IFCAP_NETMAP 0x100000 /* netmap mode supported/enabled */ 42181834Sroberto#define IFCAP_RXCSUM_IPV6 0x200000 /* can offload checksum on IPv6 RX */ 43181834Sroberto#define IFCAP_TXCSUM_IPV6 0x400000 /* can offload checksum on IPv6 TX */ 44181834Sroberto#define IFCAP_HWSTATS 0x800000 /* manages counters internally */ 45181834Sroberto#define IFCAP_TXRTLMT 0x1000000 /* hardware supports TX rate limiting */ 46181834Sroberto#define IFCAP_HWRXTSTMP 0x2000000 /* hardware rx timestamping */ 47181834Sroberto#define IFCAP_MEXTPG 0x4000000 /* understands M_EXTPG mbufs */ 48181834Sroberto#define IFCAP_TXTLS4 0x8000000 /* can do TLS encryption and segmentation for TCP */ 49181834Sroberto#define IFCAP_TXTLS6 0x10000000 /* can do TLS encryption and segmentation for TCP6 */ 50181834Sroberto#define IFCAP_VXLAN_HWCSUM 0x20000000 /* can do IFCAN_HWCSUM on VXLANs */ 51181834Sroberto#define IFCAP_VXLAN_HWTSO 0x40000000 /* can do IFCAP_TSO on VXLANs */ 52181834Sroberto#define IFCAP_TXTLS_RTLMT 0x80000000 /* can do TLS with rate limiting */ 53181834Sroberto 54181834Sroberto#define IFCAP_HWCSUM_IPV6 (IFCAP_RXCSUM_IPV6 | IFCAP_TXCSUM_IPV6) 55181834Sroberto 56181834Sroberto#define IFCAP_HWCSUM (IFCAP_RXCSUM | IFCAP_TXCSUM) 57181834Sroberto#define IFCAP_TSO (IFCAP_TSO4 | IFCAP_TSO6) 58181834Sroberto#define IFCAP_WOL (IFCAP_WOL_UCAST | IFCAP_WOL_MCAST | IFCAP_WOL_MAGIC) 59181834Sroberto#define IFCAP_TOE (IFCAP_TOE4 | IFCAP_TOE6) 60181834Sroberto 61181834Sroberto#define IFCAP_CANTCHANGE (IFCAP_NETMAP) 62181834Sroberto 63181834Sroberto/* interface flags -- these extend the Haiku-native ones from posix/net/if.h */ 64181834Sroberto#define IFF_DRV_RUNNING 0x00010000 65181834Sroberto#define IFF_DRV_OACTIVE 0x00020000 66181834Sroberto#define IFF_LINK0 0x00040000 /* per link layer defined bit */ 67181834Sroberto#define IFF_LINK1 0x00080000 /* per link layer defined bit */ 68181834Sroberto#define IFF_LINK2 0x00100000 /* per link layer defined bit */ 69181834Sroberto#define IFF_DEBUG 0x00200000 70181834Sroberto#define IFF_MONITOR 0x00400000 /* (n) user-requested monitor mode */ 71181834Sroberto#define IFF_PPROMISC 0x00800000 /* (n) user-requested promisc mode */ 72181834Sroberto#define IFF_NOGROUP 0x01000000 /* (n) interface is not part of any groups */ 73181834Sroberto#define IFF_NEEDSGIANT 0x02000000 /* (i) hold Giant over hook calls (OpenBSD compatibility) */ 74181834Sroberto 75181834Sroberto#define LINK_STATE_UNKNOWN 0 76181834Sroberto#define LINK_STATE_DOWN 1 77181834Sroberto#define LINK_STATE_UP 2 78181834Sroberto 79181834Sroberto#define IFQ_MAXLEN 50 80181834Sroberto 81181834Sroberto 82181834Sroberto/* 83181834Sroberto * Structure describing information about an interface 84181834Sroberto * which may be of interest to management entities. 85181834Sroberto */ 86181834Srobertostruct if_data { 87181834Sroberto /* generic interface information */ 88181834Sroberto uint8_t ifi_type; /* ethernet, tokenring, etc */ 89181834Sroberto uint8_t ifi_physical; /* e.g., AUI, Thinnet, 10base-T, etc */ 90181834Sroberto uint8_t ifi_addrlen; /* media address length */ 91181834Sroberto uint8_t ifi_hdrlen; /* media header length */ 92181834Sroberto uint8_t ifi_link_state; /* current link state */ 93181834Sroberto uint8_t ifi_recvquota; /* polling quota for receive intrs */ 94181834Sroberto uint8_t ifi_xmitquota; /* polling quota for xmit intrs */ 95181834Sroberto uint16_t ifi_datalen; /* length of this data struct */ 96181834Sroberto uint32_t ifi_mtu; /* maximum transmission unit */ 97181834Sroberto uint32_t ifi_metric; /* routing metric (external only) */ 98181834Sroberto uint64_t ifi_baudrate; /* linespeed */ 99181834Sroberto /* volatile statistics */ 100181834Sroberto uint64_t ifi_ipackets; /* packets received on interface */ 101181834Sroberto uint64_t ifi_ierrors; /* input errors on interface */ 102181834Sroberto uint64_t ifi_opackets; /* packets sent on interface */ 103181834Sroberto uint64_t ifi_oerrors; /* output errors on interface */ 104181834Sroberto uint64_t ifi_collisions; /* collisions on csma interfaces */ 105181834Sroberto uint64_t ifi_ibytes; /* total number of octets received */ 106181834Sroberto uint64_t ifi_obytes; /* total number of octets sent */ 107181834Sroberto uint64_t ifi_imcasts; /* packets received via multicast */ 108181834Sroberto uint64_t ifi_omcasts; /* packets sent via multicast */ 109181834Sroberto uint64_t ifi_iqdrops; /* dropped on input, this interface */ 110181834Sroberto uint64_t ifi_oqdrops; /* dropped on output, this interface */ 111181834Sroberto uint64_t ifi_noproto; /* destined for unsupported protocol */ 112181834Sroberto uint64_t ifi_hwassist; /* HW offload capabilities */ 113181834Sroberto time_t ifi_epoch; /* uptime at attach or stat reset */ 114181834Sroberto#ifdef __alpha__ 115181834Sroberto u_int ifi_timepad; /* time_t is int, not long on alpha */ 116181834Sroberto#endif 117181834Sroberto struct timeval ifi_lastchange; /* time of last administrative change */ 118181834Sroberto}; 119181834Sroberto 120181834Srobertostruct ifmediareq { 121181834Sroberto char ifm_name[IFNAMSIZ]; /* if name, e.g. "en0" */ 122181834Sroberto int ifm_current; /* current media options */ 123181834Sroberto int ifm_mask; /* don't care mask */ 124181834Sroberto int ifm_status; /* media status */ 125181834Sroberto int ifm_active; /* active options */ 126181834Sroberto int ifm_count; /* # entries in ifm_ulist array */ 127181834Sroberto int *ifm_ulist; /* media words */ 128181834Sroberto}; 129181834Sroberto 130181834Srobertostruct ifdrv { 131181834Sroberto char ifd_name[IFNAMSIZ]; /* if name, e.g. "en0" */ 132181834Sroberto unsigned long ifd_cmd; 133181834Sroberto size_t ifd_len; 134181834Sroberto void* ifd_data; 135181834Sroberto}; 136181834Sroberto 137181834Sroberto/* 138181834Sroberto * Structure used to request i2c data 139181834Sroberto * from interface transceivers. 140181834Sroberto */ 141181834Srobertostruct ifi2creq { 142181834Sroberto uint8_t dev_addr; /* i2c address (0xA0, 0xA2) */ 143181834Sroberto uint8_t offset; /* read offset */ 144181834Sroberto uint8_t len; /* read length */ 145181834Sroberto uint8_t spare0; 146181834Sroberto uint32_t spare1; 147181834Sroberto uint8_t data[8]; /* read buffer */ 148181834Sroberto}; 149181834Sroberto 150181834Sroberto#ifdef _KERNEL 151181834Sroberto/* TODO: this should go away soon. */ 152181834Sroberto# include <net/if_var.h> 153181834Sroberto#endif 154181834Sroberto 155181834Sroberto 156181834Sroberto#endif /* _FBSD_COMPAT_NET_IF_H_ */ 157181834Sroberto