1ff550d0eSmasputra /* 2ff550d0eSmasputra * CDDL HEADER START 3ff550d0eSmasputra * 4ff550d0eSmasputra * The contents of this file are subject to the terms of the 5592d29abSja97890 * Common Development and Distribution License (the "License"). 6592d29abSja97890 * You may not use this file except in compliance with the License. 7ff550d0eSmasputra * 8ff550d0eSmasputra * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9ff550d0eSmasputra * or http://www.opensolaris.org/os/licensing. 10ff550d0eSmasputra * See the License for the specific language governing permissions 11ff550d0eSmasputra * and limitations under the License. 12ff550d0eSmasputra * 13ff550d0eSmasputra * When distributing Covered Code, include this CDDL HEADER in each 14ff550d0eSmasputra * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15ff550d0eSmasputra * If applicable, add the following below this CDDL HEADER, with the 16ff550d0eSmasputra * fields enclosed by brackets "[]" replaced with your own identifying 17ff550d0eSmasputra * information: Portions Copyright [yyyy] [name of copyright owner] 18ff550d0eSmasputra * 19ff550d0eSmasputra * CDDL HEADER END 20ff550d0eSmasputra */ 21ff550d0eSmasputra /* 22*6e91bba0SGirish Moodalbail * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 23ff550d0eSmasputra * Use is subject to license terms. 24ff550d0eSmasputra */ 25ff550d0eSmasputra 26ff550d0eSmasputra #ifndef _INET_IP_IMPL_H 27ff550d0eSmasputra #define _INET_IP_IMPL_H 28ff550d0eSmasputra 29ff550d0eSmasputra /* 30ff550d0eSmasputra * IP implementation private declarations. These interfaces are 31ff550d0eSmasputra * used to build the IP module and are not meant to be accessed 32ff550d0eSmasputra * by any modules except IP itself. They are undocumented and are 33ff550d0eSmasputra * subject to change without notice. 34ff550d0eSmasputra */ 35ff550d0eSmasputra 36ff550d0eSmasputra #ifdef __cplusplus 37ff550d0eSmasputra extern "C" { 38ff550d0eSmasputra #endif 39ff550d0eSmasputra 40ff550d0eSmasputra #ifdef _KERNEL 41ff550d0eSmasputra 42381a2a9aSdr146992 #include <sys/sdt.h> 43da14cebeSEric Cheng #include <sys/dld.h> 44*6e91bba0SGirish Moodalbail #include <inet/tunables.h> 45381a2a9aSdr146992 46ff550d0eSmasputra #define IP_MOD_ID 5701 47ff550d0eSmasputra 480f1702c5SYu Xiangning #define INET_NAME "ip" 490f1702c5SYu Xiangning 50ff550d0eSmasputra #ifdef _BIG_ENDIAN 51ff550d0eSmasputra #define IP_HDR_CSUM_TTL_ADJUST 256 52ff550d0eSmasputra #define IP_TCP_CSUM_COMP IPPROTO_TCP 53ff550d0eSmasputra #define IP_UDP_CSUM_COMP IPPROTO_UDP 54bd670b35SErik Nordmark #define IP_ICMPV6_CSUM_COMP IPPROTO_ICMPV6 55ff550d0eSmasputra #else 56ff550d0eSmasputra #define IP_HDR_CSUM_TTL_ADJUST 1 57ff550d0eSmasputra #define IP_TCP_CSUM_COMP (IPPROTO_TCP << 8) 58ff550d0eSmasputra #define IP_UDP_CSUM_COMP (IPPROTO_UDP << 8) 59bd670b35SErik Nordmark #define IP_ICMPV6_CSUM_COMP (IPPROTO_ICMPV6 << 8) 60ff550d0eSmasputra #endif 61ff550d0eSmasputra 62ff550d0eSmasputra #define TCP_CHECKSUM_OFFSET 16 63ff550d0eSmasputra #define TCP_CHECKSUM_SIZE 2 64ff550d0eSmasputra 65ff550d0eSmasputra #define UDP_CHECKSUM_OFFSET 6 66ff550d0eSmasputra #define UDP_CHECKSUM_SIZE 2 67ff550d0eSmasputra 68bd670b35SErik Nordmark #define ICMPV6_CHECKSUM_OFFSET 2 69bd670b35SErik Nordmark #define ICMPV6_CHECKSUM_SIZE 2 70bd670b35SErik Nordmark 71ff550d0eSmasputra #define IPH_TCPH_CHECKSUMP(ipha, hlen) \ 72ff550d0eSmasputra ((uint16_t *)(((uchar_t *)(ipha)) + ((hlen) + TCP_CHECKSUM_OFFSET))) 73ff550d0eSmasputra 74ff550d0eSmasputra #define IPH_UDPH_CHECKSUMP(ipha, hlen) \ 75ff550d0eSmasputra ((uint16_t *)(((uchar_t *)(ipha)) + ((hlen) + UDP_CHECKSUM_OFFSET))) 76ff550d0eSmasputra 77bd670b35SErik Nordmark #define IPH_ICMPV6_CHECKSUMP(ipha, hlen) \ 78bd670b35SErik Nordmark ((uint16_t *)(((uchar_t *)(ipha)) + ((hlen) + ICMPV6_CHECKSUM_OFFSET))) 79bd670b35SErik Nordmark 80ff550d0eSmasputra #define ILL_HCKSUM_CAPABLE(ill) \ 81ff550d0eSmasputra (((ill)->ill_capabilities & ILL_CAPAB_HCKSUM) != 0) 82ff550d0eSmasputra 83ff550d0eSmasputra /* 84ff550d0eSmasputra * Macro to adjust a given checksum value depending on any prepended 85ff550d0eSmasputra * or postpended data on the packet. It expects the start offset to 86ff550d0eSmasputra * begin at an even boundary and that the packet consists of at most 87ff550d0eSmasputra * two mblks. 88ff550d0eSmasputra */ 89ff550d0eSmasputra #define IP_ADJCKSUM_PARTIAL(cksum_start, mp, mp1, len, adj) { \ 90ff550d0eSmasputra /* \ 91ff550d0eSmasputra * Prepended extraneous data; adjust checksum. \ 92ff550d0eSmasputra */ \ 93ff550d0eSmasputra if ((len) > 0) \ 94ff550d0eSmasputra (adj) = IP_BCSUM_PARTIAL(cksum_start, len, 0); \ 95ff550d0eSmasputra else \ 96ff550d0eSmasputra (adj) = 0; \ 97ff550d0eSmasputra /* \ 98ff550d0eSmasputra * len is now the total length of mblk(s) \ 99ff550d0eSmasputra */ \ 100ff550d0eSmasputra (len) = MBLKL(mp); \ 101ff550d0eSmasputra if ((mp1) == NULL) \ 102ff550d0eSmasputra (mp1) = (mp); \ 103ff550d0eSmasputra else \ 104ff550d0eSmasputra (len) += MBLKL(mp1); \ 105ff550d0eSmasputra /* \ 106ff550d0eSmasputra * Postpended extraneous data; adjust checksum. \ 107ff550d0eSmasputra */ \ 108ff550d0eSmasputra if (((len) = (DB_CKSUMEND(mp) - len)) > 0) { \ 109ff550d0eSmasputra uint32_t _pad; \ 110ff550d0eSmasputra \ 111ff550d0eSmasputra _pad = IP_BCSUM_PARTIAL((mp1)->b_wptr, len, 0); \ 112ff550d0eSmasputra /* \ 113ff550d0eSmasputra * If the postpended extraneous data was odd \ 114ff550d0eSmasputra * byte aligned, swap resulting checksum bytes. \ 115ff550d0eSmasputra */ \ 116ff550d0eSmasputra if ((uintptr_t)(mp1)->b_wptr & 1) \ 117ff550d0eSmasputra (adj) += ((_pad << 8) & 0xFFFF) | (_pad >> 8); \ 118ff550d0eSmasputra else \ 119ff550d0eSmasputra (adj) += _pad; \ 120ff550d0eSmasputra (adj) = ((adj) & 0xFFFF) + ((int)(adj) >> 16); \ 121ff550d0eSmasputra } \ 122ff550d0eSmasputra } 123ff550d0eSmasputra 124bd670b35SErik Nordmark #define IS_SIMPLE_IPH(ipha) \ 125bd670b35SErik Nordmark ((ipha)->ipha_version_and_hdr_length == IP_SIMPLE_HDR_VERSION) 126ff550d0eSmasputra 127ff550d0eSmasputra /* 128bd670b35SErik Nordmark * Currently supported flags for LSO. 129ff550d0eSmasputra */ 130bd670b35SErik Nordmark #define LSO_BASIC_TCP_IPV4 DLD_LSO_BASIC_TCP_IPV4 131bd670b35SErik Nordmark #define LSO_BASIC_TCP_IPV6 DLD_LSO_BASIC_TCP_IPV6 132ff550d0eSmasputra 1338347601bSyl150051 #define ILL_LSO_CAPABLE(ill) \ 134bd670b35SErik Nordmark (((ill)->ill_capabilities & ILL_CAPAB_LSO) != 0) 1358347601bSyl150051 1368347601bSyl150051 #define ILL_LSO_USABLE(ill) \ 1378347601bSyl150051 (ILL_LSO_CAPABLE(ill) && \ 138bd670b35SErik Nordmark ill->ill_lso_capab != NULL) 1398347601bSyl150051 140bd670b35SErik Nordmark #define ILL_LSO_TCP_IPV4_USABLE(ill) \ 1418347601bSyl150051 (ILL_LSO_USABLE(ill) && \ 142bd670b35SErik Nordmark ill->ill_lso_capab->ill_lso_flags & LSO_BASIC_TCP_IPV4) 1438347601bSyl150051 144bd670b35SErik Nordmark #define ILL_LSO_TCP_IPV6_USABLE(ill) \ 145bd670b35SErik Nordmark (ILL_LSO_USABLE(ill) && \ 146bd670b35SErik Nordmark ill->ill_lso_capab->ill_lso_flags & LSO_BASIC_TCP_IPV6) 147ff550d0eSmasputra 148bd670b35SErik Nordmark #define ILL_ZCOPY_CAPABLE(ill) \ 149bd670b35SErik Nordmark (((ill)->ill_capabilities & ILL_CAPAB_ZEROCOPY) != 0) 150ff550d0eSmasputra 151bd670b35SErik Nordmark #define ILL_ZCOPY_USABLE(ill) \ 152bd670b35SErik Nordmark (ILL_ZCOPY_CAPABLE(ill) && (ill->ill_zerocopy_capab != NULL) && \ 153bd670b35SErik Nordmark (ill->ill_zerocopy_capab->ill_zerocopy_flags != 0)) 154ff550d0eSmasputra 155ff550d0eSmasputra 156da14cebeSEric Cheng /* Macro that follows definitions of flags for mac_tx() (see mac_client.h) */ 157da14cebeSEric Cheng #define IP_DROP_ON_NO_DESC 0x01 /* Equivalent to MAC_DROP_ON_NO_DESC */ 158ff550d0eSmasputra 159da14cebeSEric Cheng #define ILL_DIRECT_CAPABLE(ill) \ 160da14cebeSEric Cheng (((ill)->ill_capabilities & ILL_CAPAB_DLD_DIRECT) != 0) 161da14cebeSEric Cheng 162bd670b35SErik Nordmark /* This macro is used by the mac layer */ 163da14cebeSEric Cheng #define MBLK_RX_FANOUT_SLOWPATH(mp, ipha) \ 164da14cebeSEric Cheng (DB_TYPE(mp) != M_DATA || DB_REF(mp) != 1 || !OK_32PTR(ipha) || \ 165da14cebeSEric Cheng (((uchar_t *)ipha + IP_SIMPLE_HDR_LENGTH) >= (mp)->b_wptr)) 166da14cebeSEric Cheng 167b127ac41SPhilip Kirk /* 168b127ac41SPhilip Kirk * In non-global zone exclusive IP stacks, data structures such as IRE 169b127ac41SPhilip Kirk * entries pretend that they're in the global zone. The following 170b127ac41SPhilip Kirk * macro evaluates to the real zoneid instead of a pretend 171b127ac41SPhilip Kirk * GLOBAL_ZONEID. 172b127ac41SPhilip Kirk */ 173b127ac41SPhilip Kirk #define IP_REAL_ZONEID(zoneid, ipst) \ 174b127ac41SPhilip Kirk (((zoneid) == GLOBAL_ZONEID) ? \ 175b127ac41SPhilip Kirk netstackid_to_zoneid((ipst)->ips_netstack->netstack_stackid) : \ 176b127ac41SPhilip Kirk (zoneid)) 177b127ac41SPhilip Kirk 178da14cebeSEric Cheng extern void ill_flow_enable(void *, ip_mac_tx_cookie_t); 179bd670b35SErik Nordmark extern zoneid_t ip_get_zoneid_v4(ipaddr_t, mblk_t *, ip_recv_attr_t *, 180bd670b35SErik Nordmark zoneid_t); 181b127ac41SPhilip Kirk extern zoneid_t ip_get_zoneid_v6(in6_addr_t *, mblk_t *, const ill_t *, 182bd670b35SErik Nordmark ip_recv_attr_t *, zoneid_t); 183*6e91bba0SGirish Moodalbail extern void conn_ire_revalidate(conn_t *, void *); 184*6e91bba0SGirish Moodalbail extern void ip_ire_unbind_walker(ire_t *, void *); 185*6e91bba0SGirish Moodalbail extern void ip_ire_rebind_walker(ire_t *, void *); 186ff550d0eSmasputra 1870f1702c5SYu Xiangning /* 1880f1702c5SYu Xiangning * flag passed in by IP based protocols to get a private ip stream with 1890f1702c5SYu Xiangning * no conn_t. Note this flag has the same value as SO_FALLBACK 1900f1702c5SYu Xiangning */ 1910f1702c5SYu Xiangning #define IP_HELPER_STR SO_FALLBACK 1920f1702c5SYu Xiangning 1930f1702c5SYu Xiangning #define IP_MOD_MINPSZ 1 1940f1702c5SYu Xiangning #define IP_MOD_MAXPSZ INFPSZ 1950f1702c5SYu Xiangning #define IP_MOD_HIWAT 65536 1960f1702c5SYu Xiangning #define IP_MOD_LOWAT 1024 1970f1702c5SYu Xiangning 1980f1702c5SYu Xiangning #define DEV_IP "/devices/pseudo/ip@0:ip" 1990f1702c5SYu Xiangning #define DEV_IP6 "/devices/pseudo/ip6@0:ip6" 2000f1702c5SYu Xiangning 201ff550d0eSmasputra #endif /* _KERNEL */ 202ff550d0eSmasputra 203ff550d0eSmasputra #ifdef __cplusplus 204ff550d0eSmasputra } 205ff550d0eSmasputra #endif 206ff550d0eSmasputra 207ff550d0eSmasputra #endif /* _INET_IP_IMPL_H */ 208