10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 52074Smeem * Common Development and Distribution License (the "License"). 62074Smeem * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 228485SPeter.Memishian@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _MPD_TABLES_H 270Sstevel@tonic-gate #define _MPD_TABLES_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #ifdef __cplusplus 300Sstevel@tonic-gate extern "C" { 310Sstevel@tonic-gate #endif 320Sstevel@tonic-gate 330Sstevel@tonic-gate /* 340Sstevel@tonic-gate * Terminology: 350Sstevel@tonic-gate * 360Sstevel@tonic-gate * phyint: A NIC eg. hme0. This is represented as 'struct phyint' 370Sstevel@tonic-gate * 380Sstevel@tonic-gate * phyint instance: A protocol instance of a phyint. Eg. the IPv4 instance of 390Sstevel@tonic-gate * hme0 or the IPv6 instance of hme0. (struct phyint_instance) 400Sstevel@tonic-gate * 410Sstevel@tonic-gate * logint: A logical interface eg. hme0:1 (struct logint) 420Sstevel@tonic-gate * 430Sstevel@tonic-gate * phyint_group: A group of phyints i.e. physical interfaces that are 440Sstevel@tonic-gate * (i) connected to the same level 2 topology e.g. the same ethernet 450Sstevel@tonic-gate * switch AND 460Sstevel@tonic-gate * (ii) share the same phyint group name. 470Sstevel@tonic-gate * Load spreading and failover occur across members of the same phyint group. 488485SPeter.Memishian@Sun.COM * phyint group members must be homogeneous. i.e. if a phyint belonging to a 490Sstevel@tonic-gate * phyint group has a IPv6 protocol instance, then all members of the phyint 500Sstevel@tonic-gate * group, must have IPv6 protocol instances. (struct phyint_group) 510Sstevel@tonic-gate */ 520Sstevel@tonic-gate 530Sstevel@tonic-gate #define MAXDEFERREDRTT 1 /* Maximum number of deferred rtts */ 540Sstevel@tonic-gate 550Sstevel@tonic-gate /* 560Sstevel@tonic-gate * Status of the phyint, expressed by the return code of failure_state() 570Sstevel@tonic-gate */ 580Sstevel@tonic-gate #define PHYINT_OK 0 /* No failure detected */ 590Sstevel@tonic-gate #define PHYINT_FAILURE 1 /* NIC failure detected */ 600Sstevel@tonic-gate #define GROUP_FAILURE 2 /* All NICs have failed */ 610Sstevel@tonic-gate 620Sstevel@tonic-gate /* 630Sstevel@tonic-gate * Return values of phyint_inst_update_from_k() 640Sstevel@tonic-gate */ 650Sstevel@tonic-gate #define PI_OK 1 /* Phyint matches in the kernel */ 660Sstevel@tonic-gate #define PI_DELETED 2 /* Phyint has vanished in the kernel */ 670Sstevel@tonic-gate #define PI_IFINDEX_CHANGED 3 /* Phyint's ifindex has changed */ 680Sstevel@tonic-gate #define PI_IOCTL_ERROR 4 /* Some ioctl error */ 690Sstevel@tonic-gate #define PI_GROUP_CHANGED 5 /* The phyint has changed group. */ 700Sstevel@tonic-gate 710Sstevel@tonic-gate #define PHYINT_FLAGS(flags) \ 728485SPeter.Memishian@Sun.COM (((flags) & (IFF_STANDBY | IFF_INACTIVE | IFF_FAILED | IFF_OFFLINE | \ 738485SPeter.Memishian@Sun.COM IFF_RUNNING)) | (handle_link_notifications ? 0 : IFF_RUNNING)) 740Sstevel@tonic-gate 750Sstevel@tonic-gate /* A Phyint can have up to 2 instances, the IPv4 and the IPv6 instance */ 760Sstevel@tonic-gate #define PHYINT_INSTANCE(pi, af) \ 770Sstevel@tonic-gate ((af) == AF_INET ? (pi)->pi_v4 : (pi)->pi_v6) 780Sstevel@tonic-gate 790Sstevel@tonic-gate /* 802496Smeem * A phyint instance is probe *enabled* if it has been configured with a 812496Smeem * unique probe address (i.e., an IFF_NOFAILOVER address). It is probe 822496Smeem * *capable* if it is also able to send probes (i.e., has one or more 832496Smeem * targets available). 840Sstevel@tonic-gate */ 850Sstevel@tonic-gate #define PROBE_ENABLED(pii) \ 862496Smeem (((pii) != NULL) && ((pii)->pii_probe_sock != -1) && \ 872496Smeem ((pii)->pii_probe_logint != NULL) && \ 882496Smeem (((pii)->pii_probe_logint->li_dupaddr == 0))) 890Sstevel@tonic-gate 900Sstevel@tonic-gate #define PROBE_CAPABLE(pii) \ 910Sstevel@tonic-gate (PROBE_ENABLED(pii) && ((pii)->pii_ntargets != 0)) 920Sstevel@tonic-gate 930Sstevel@tonic-gate /* Subtract b from a modulo n. i.e. (a - b) mod n */ 940Sstevel@tonic-gate #define MOD_SUB(a, b, n) \ 950Sstevel@tonic-gate ((((a) + (n)) - (b)) % (n)) 960Sstevel@tonic-gate 970Sstevel@tonic-gate /* Increment modulo n */ 980Sstevel@tonic-gate #define MOD_INCR(a, n) \ 990Sstevel@tonic-gate (((a) + 1) % (n)) 1000Sstevel@tonic-gate 1010Sstevel@tonic-gate /* Decrement modulo n */ 1020Sstevel@tonic-gate #define MOD_DCR(a, n) \ 1030Sstevel@tonic-gate MOD_SUB(a, 1, n) 1040Sstevel@tonic-gate 1050Sstevel@tonic-gate /* 1060Sstevel@tonic-gate * 'index' represents an index into the circular probe stats array of 1070Sstevel@tonic-gate * size PROBE_STATS_COUNT. 0 <= index < PROBE_STATS_COUNT. This is used 1080Sstevel@tonic-gate * to access members of the pii_probes[] array defined in the phyint_instance 1090Sstevel@tonic-gate * structure. 1100Sstevel@tonic-gate */ 1110Sstevel@tonic-gate #define PROBE_INDEX_PREV(index) \ 1120Sstevel@tonic-gate MOD_DCR(index, PROBE_STATS_COUNT) 1130Sstevel@tonic-gate 1140Sstevel@tonic-gate #define PROBE_INDEX_NEXT(index) \ 1150Sstevel@tonic-gate MOD_INCR(index, PROBE_STATS_COUNT) 1160Sstevel@tonic-gate 1170Sstevel@tonic-gate 1180Sstevel@tonic-gate /* 1190Sstevel@tonic-gate * If we receive more than LINK_UP_PERMIN "link up" notifications in a minute, 1200Sstevel@tonic-gate * then don't actually perform the repair operation until we've dropped back 1210Sstevel@tonic-gate * below the threshold (or we have a probe address and our probes indicate 1220Sstevel@tonic-gate * that the link is functioning again). This is to prevent link flapping in 1230Sstevel@tonic-gate * the case where we don't have a probe address. 1240Sstevel@tonic-gate */ 1250Sstevel@tonic-gate #define LINK_UP_PERMIN 2 1260Sstevel@tonic-gate 1270Sstevel@tonic-gate #define LINK_DOWN(pi) ((pi)->pi_link_state == 0) 1280Sstevel@tonic-gate #define LINK_UP(pi) (!LINK_DOWN(pi)) 1290Sstevel@tonic-gate #define FLAGS_TO_LINK_STATE(pi) (((pi)->pi_flags & IFF_RUNNING) != 0) 1300Sstevel@tonic-gate #define UPDATE_LINK_STATE(pi) ((pi)->pi_link_state = \ 1310Sstevel@tonic-gate FLAGS_TO_LINK_STATE(pi) ? 1 : 0) 1320Sstevel@tonic-gate #define INIT_LINK_STATE(pi) ((pi)->pi_link_state = 1) 1330Sstevel@tonic-gate 1340Sstevel@tonic-gate /* 1350Sstevel@tonic-gate * Phyint group states; see below for the phyint group definition. 1360Sstevel@tonic-gate */ 1370Sstevel@tonic-gate enum pg_state { 1388485SPeter.Memishian@Sun.COM PG_OK = 1, /* all interfaces in the group are working */ 1398485SPeter.Memishian@Sun.COM PG_DEGRADED, /* some interfaces in the group are unusable */ 1408485SPeter.Memishian@Sun.COM PG_FAILED /* all interfaces in the group are unusable */ 1410Sstevel@tonic-gate }; 1420Sstevel@tonic-gate 1430Sstevel@tonic-gate /* 1440Sstevel@tonic-gate * Convenience macro to check if the whole group has failed. 1450Sstevel@tonic-gate */ 1468485SPeter.Memishian@Sun.COM #define GROUP_FAILED(pg) ((pg)->pg_state == PG_FAILED) 1470Sstevel@tonic-gate 1480Sstevel@tonic-gate /* 1490Sstevel@tonic-gate * A doubly linked list of all phyint groups in the system. 1500Sstevel@tonic-gate * A phyint group is identified by its group name. 1510Sstevel@tonic-gate */ 1520Sstevel@tonic-gate struct phyint_group { 1538485SPeter.Memishian@Sun.COM char pg_name[LIFGRNAMSIZ]; /* Phyint group name */ 1540Sstevel@tonic-gate struct phyint *pg_phyint; /* List of phyints in this group */ 1550Sstevel@tonic-gate struct phyint_group *pg_next; /* Next phyint group */ 1560Sstevel@tonic-gate struct phyint_group *pg_prev; /* Prev phyint group */ 1578485SPeter.Memishian@Sun.COM uint64_t pg_sig; /* Current signature of this group */ 1588485SPeter.Memishian@Sun.COM int pg_probeint; /* Interval between probes */ 1598485SPeter.Memishian@Sun.COM int pg_fdt; /* Time needed to detect failure */ 1608485SPeter.Memishian@Sun.COM enum pg_state pg_state; /* Current group state */ 1618485SPeter.Memishian@Sun.COM boolean_t pg_in_use; /* To detect removed groups */ 1628485SPeter.Memishian@Sun.COM struct addrlist *pg_addrs; /* Data addresses in this group */ 1638485SPeter.Memishian@Sun.COM boolean_t pg_failmsg_printed; /* Group failure msg printed */ 1640Sstevel@tonic-gate }; 1650Sstevel@tonic-gate 1660Sstevel@tonic-gate /* 1670Sstevel@tonic-gate * Phyint states; see below for the phyint definition. 1680Sstevel@tonic-gate */ 1690Sstevel@tonic-gate enum pi_state { 17010290SPeter.Memishian@Sun.COM PI_INIT = 0, /* Phyint is being initialized */ 1710Sstevel@tonic-gate PI_NOTARGETS = 1, /* Phyint has no targets */ 1720Sstevel@tonic-gate PI_RUNNING = 2, /* Phyint is functioning */ 1730Sstevel@tonic-gate PI_FAILED = 3, /* Phyint is failed */ 1740Sstevel@tonic-gate PI_OFFLINE = 4 /* Phyint is offline */ 1750Sstevel@tonic-gate }; 1760Sstevel@tonic-gate 1770Sstevel@tonic-gate /* 1780Sstevel@tonic-gate * Representation of a NIC or a phyint. There is a list of all known phyints. 1790Sstevel@tonic-gate * There is also a list of phyints belonging to a phyint group, one list 1800Sstevel@tonic-gate * per phyint group. 1810Sstevel@tonic-gate */ 1820Sstevel@tonic-gate struct phyint { 1830Sstevel@tonic-gate char pi_name[LIFNAMSIZ + 1]; /* Phyint name eg. le0 */ 1840Sstevel@tonic-gate struct phyint_instance *pi_v4; /* The IPv4 instance */ 1850Sstevel@tonic-gate struct phyint_instance *pi_v6; /* The IPv6 instance */ 1860Sstevel@tonic-gate struct phyint_group *pi_group; /* Pointer to the group */ 1870Sstevel@tonic-gate struct phyint *pi_next; /* List of all phyints */ 1880Sstevel@tonic-gate struct phyint *pi_prev; /* List of all phyints */ 1890Sstevel@tonic-gate struct phyint *pi_pgnext; /* List of phyints in this group */ 1900Sstevel@tonic-gate struct phyint *pi_pgprev; /* List of phyints in this group */ 1910Sstevel@tonic-gate uint_t pi_ifindex; /* interface index */ 1920Sstevel@tonic-gate enum pi_state pi_state; /* State of the phyint */ 1930Sstevel@tonic-gate uint64_t pi_flags; /* Phyint flags from kernel */ 1940Sstevel@tonic-gate uint16_t pi_icmpid; /* icmp id in icmp echo request */ 1954770Smeem uint64_t pi_taddrthresh; /* time (in secs) to delay logging */ 1964770Smeem /* about missing test addresses */ 1978485SPeter.Memishian@Sun.COM dlpi_handle_t pi_dh; /* DLPI handle to underlying link */ 1988485SPeter.Memishian@Sun.COM uint_t pi_notes; /* enabled DLPI notifications */ 1998485SPeter.Memishian@Sun.COM uchar_t pi_hwaddr[DLPI_PHYSADDR_MAX]; /* phyint's hw address */ 2008485SPeter.Memishian@Sun.COM size_t pi_hwaddrlen; /* phyint's hw address length */ 2018485SPeter.Memishian@Sun.COM 2020Sstevel@tonic-gate /* 2030Sstevel@tonic-gate * The pi_whenup array is a circular buffer of the most recent 2040Sstevel@tonic-gate * times (in milliseconds since some arbitrary point of time in 2050Sstevel@tonic-gate * the past) that the interface was brought up; pi_whendx identifies 2060Sstevel@tonic-gate * the oldest element of the array. 2070Sstevel@tonic-gate */ 2080Sstevel@tonic-gate uint_t pi_whenup[LINK_UP_PERMIN]; 2090Sstevel@tonic-gate unsigned int pi_whendx; 2100Sstevel@tonic-gate 2110Sstevel@tonic-gate uint_t 2120Sstevel@tonic-gate pi_taddrmsg_printed : 1, /* testaddr msg printed */ 2134770Smeem pi_duptaddrmsg_printed : 1, /* dup testaddr msg printed */ 2140Sstevel@tonic-gate pi_cfgmsg_printed : 1, /* bad config msg printed */ 2150Sstevel@tonic-gate pi_lfmsg_printed : 1, /* link-flapping msg printed */ 2168485SPeter.Memishian@Sun.COM pi_link_state : 1, /* interface link state */ 2178485SPeter.Memishian@Sun.COM pi_hwaddrdup : 1; /* disabled due to dup hw address */ 2180Sstevel@tonic-gate }; 2190Sstevel@tonic-gate 2200Sstevel@tonic-gate /* 2210Sstevel@tonic-gate * A doubly linked list of all phyint_instances each of which contains a 2220Sstevel@tonic-gate * doubly linked list of logical interfaces and targets. For eg. if both 2230Sstevel@tonic-gate * IPv4 and IPv6 are used over hme0, we have 2 phyint instances, 1 for each 2240Sstevel@tonic-gate * protocol. 2250Sstevel@tonic-gate */ 2260Sstevel@tonic-gate struct phyint_instance { 2270Sstevel@tonic-gate struct phyint_instance *pii_next; /* List of all phyint insts */ 2280Sstevel@tonic-gate struct phyint_instance *pii_prev; /* List of all phyint insts */ 2290Sstevel@tonic-gate 2300Sstevel@tonic-gate struct phyint *pii_phyint; /* Back pointer to the phyint */ 2310Sstevel@tonic-gate struct target *pii_targets; /* List of targets on this link */ 2320Sstevel@tonic-gate struct logint *pii_probe_logint; /* IFF_NOFAILOVER addr for probing */ 2330Sstevel@tonic-gate struct logint *pii_logint; /* Doubly linked list of logical ifs */ 2340Sstevel@tonic-gate 2350Sstevel@tonic-gate int pii_probe_sock; /* Socket for ICMP Probe packets */ 2360Sstevel@tonic-gate int pii_af; /* Address family */ 2370Sstevel@tonic-gate uint16_t pii_rack; /* highest acknowledged seq number */ 2380Sstevel@tonic-gate uint16_t pii_snxt; /* sequence number of next probe */ 2390Sstevel@tonic-gate uint_t pii_snxt_time; /* actual next probe time that */ 2400Sstevel@tonic-gate /* includes some randomness */ 2410Sstevel@tonic-gate 2420Sstevel@tonic-gate uint_t pii_snxt_basetime; /* strictly periodic base probe time */ 2430Sstevel@tonic-gate /* for all periodic probes */ 2440Sstevel@tonic-gate uint_t pii_fd_snxt_basetime; /* strictly periodic base probe time */ 2450Sstevel@tonic-gate /* for failure detection probes */ 2460Sstevel@tonic-gate 2470Sstevel@tonic-gate hrtime_t pii_fd_hrtime; /* hrtime_t before which we should */ 2480Sstevel@tonic-gate /* not send probes out this pii */ 2490Sstevel@tonic-gate 2500Sstevel@tonic-gate uint64_t pii_flags; /* Phyint flags from kernel */ 2510Sstevel@tonic-gate 2520Sstevel@tonic-gate struct probe_stats { 2538485SPeter.Memishian@Sun.COM uint_t pr_id; /* Full ID of probe */ 2548485SPeter.Memishian@Sun.COM struct target *pr_target; /* Probe Target */ 2558485SPeter.Memishian@Sun.COM uint_t pr_time_lost; /* Time probe declared lost */ 2568485SPeter.Memishian@Sun.COM struct timeval pr_tv_sent; /* Wall time probe was sent */ 2578485SPeter.Memishian@Sun.COM hrtime_t pr_hrtime_start; /* hrtime probe op started */ 2588485SPeter.Memishian@Sun.COM hrtime_t pr_hrtime_sent; /* hrtime probe was sent */ 2598485SPeter.Memishian@Sun.COM hrtime_t pr_hrtime_ackrecv; /* hrtime probe ack received */ 2608485SPeter.Memishian@Sun.COM hrtime_t pr_hrtime_ackproc; /* hrtime probe ack processed */ 2610Sstevel@tonic-gate uint_t pr_status; /* probe status as below */ 2620Sstevel@tonic-gate #define PR_UNUSED 0 /* Probe slot unused */ 2630Sstevel@tonic-gate #define PR_UNACKED 1 /* Probe is unacknowledged */ 2640Sstevel@tonic-gate #define PR_ACKED 2 /* Probe has been acknowledged */ 2650Sstevel@tonic-gate #define PR_LOST 3 /* Probe is declared lost */ 2660Sstevel@tonic-gate } pii_probes[PROBE_STATS_COUNT]; 2670Sstevel@tonic-gate 2680Sstevel@tonic-gate uint_t 2690Sstevel@tonic-gate pii_in_use : 1, /* To detect removed phyints */ 2700Sstevel@tonic-gate pii_basetime_inited : 1, /* probe time initialized */ 2710Sstevel@tonic-gate pii_targets_are_routers : 1; /* routers or hosts ? */ 2720Sstevel@tonic-gate 2730Sstevel@tonic-gate uint_t pii_probe_next; /* next index to use in pii_probes[] */ 2740Sstevel@tonic-gate struct target *pii_target_next; /* next target for probing */ 2750Sstevel@tonic-gate struct target *pii_rtt_target_next; 2760Sstevel@tonic-gate /* next target for rtt probes */ 2770Sstevel@tonic-gate 2780Sstevel@tonic-gate int pii_ntargets; /* Number of active targets */ 2790Sstevel@tonic-gate struct stats { /* Cumulative statistics */ 2800Sstevel@tonic-gate uint64_t lost; /* Number of probes lost */ 2810Sstevel@tonic-gate uint64_t acked; /* Number of probes acked */ 2820Sstevel@tonic-gate uint64_t sent; /* Number of probes sent */ 2830Sstevel@tonic-gate uint64_t unknown; /* Number of ambiguous */ 2840Sstevel@tonic-gate /* probe acks */ 2850Sstevel@tonic-gate } pii_cum_stats; 2860Sstevel@tonic-gate }; 2870Sstevel@tonic-gate 2880Sstevel@tonic-gate #define pii_name pii_phyint->pi_name 2890Sstevel@tonic-gate #define pii_ifindex pii_phyint->pi_ifindex 2900Sstevel@tonic-gate #define pii_state pii_phyint->pi_state 2910Sstevel@tonic-gate #define pii_icmpid pii_phyint->pi_icmpid 2920Sstevel@tonic-gate 2930Sstevel@tonic-gate #define PR_STATUS_VALID(status) ((status) <= PR_LOST) 2940Sstevel@tonic-gate 2950Sstevel@tonic-gate 2960Sstevel@tonic-gate /* 2970Sstevel@tonic-gate * A doubly linked list of prefixes or logicals, hanging off the 2980Sstevel@tonic-gate * phyint instance. 2990Sstevel@tonic-gate */ 3000Sstevel@tonic-gate struct logint { 3010Sstevel@tonic-gate struct logint *li_next; /* Next logint of this phyint inst. */ 3020Sstevel@tonic-gate struct logint *li_prev; /* Prev logint of this phyint inst. */ 3030Sstevel@tonic-gate struct phyint_instance *li_phyint_inst; 3040Sstevel@tonic-gate /* Back pointer to phyint inst. */ 3050Sstevel@tonic-gate 3060Sstevel@tonic-gate char li_name[LIFNAMSIZ + 1]; /* name Eg. hme0:1 */ 3070Sstevel@tonic-gate struct in6_addr li_addr; /* IP address */ 3080Sstevel@tonic-gate struct in6_addr li_dstaddr; /* Dst IP address for pointopoint */ 3090Sstevel@tonic-gate struct in6_addr li_subnet; /* prefix / subnet */ 3100Sstevel@tonic-gate uint_t li_subnet_len; /* prefix / subnet length */ 3110Sstevel@tonic-gate uint64_t li_flags; /* IFF_* flags */ 3120Sstevel@tonic-gate uint_t 3130Sstevel@tonic-gate li_in_use : 1, /* flag to detect deleted logints */ 3144770Smeem li_dupaddr : 1; /* test address is not unique */ 3150Sstevel@tonic-gate }; 3160Sstevel@tonic-gate 3170Sstevel@tonic-gate 3180Sstevel@tonic-gate /* 3190Sstevel@tonic-gate * Doubly-linked list of probe targets on a phyint instance. Probe targets are 3200Sstevel@tonic-gate * usually onlink routers. If no onlink routers can be found, onlink hosts 3210Sstevel@tonic-gate * are used. 3220Sstevel@tonic-gate */ 3230Sstevel@tonic-gate struct target { 3240Sstevel@tonic-gate struct target *tg_next; /* Next target for this phyint inst. */ 3250Sstevel@tonic-gate struct target *tg_prev; /* Prev target for this phyint inst. */ 3260Sstevel@tonic-gate struct phyint_instance *tg_phyint_inst; 3270Sstevel@tonic-gate /* Back pointer to phyint instance */ 3280Sstevel@tonic-gate 3290Sstevel@tonic-gate struct in6_addr tg_address; /* Target IP address */ 3300Sstevel@tonic-gate int tg_status; /* Status of the target below */ 3310Sstevel@tonic-gate #define TG_ACTIVE 1 /* active probe target */ 3320Sstevel@tonic-gate #define TG_UNUSED 2 /* target not in use now */ 3330Sstevel@tonic-gate #define TG_SLOW 3 /* rtt is high - Not in use now */ 3340Sstevel@tonic-gate #define TG_DEAD 4 /* Target is not responding */ 3350Sstevel@tonic-gate 3360Sstevel@tonic-gate hrtime_t tg_latime; /* Target's last active time */ 3378485SPeter.Memishian@Sun.COM int64_t tg_rtt_sa; /* Scaled RTT average (in ns) */ 3388485SPeter.Memishian@Sun.COM int64_t tg_rtt_sd; /* Scaled RTT deviation (in ns) */ 3398485SPeter.Memishian@Sun.COM int tg_crtt; /* Conservative RTT = A + 4D (in ms) */ 3400Sstevel@tonic-gate uint32_t 3410Sstevel@tonic-gate tg_in_use : 1; /* In use flag */ 3428485SPeter.Memishian@Sun.COM int64_t tg_deferred[MAXDEFERREDRTT + 1]; 3430Sstevel@tonic-gate /* Deferred rtt data points */ 3440Sstevel@tonic-gate int tg_num_deferred; 3450Sstevel@tonic-gate /* Number of deferred rtt data points */ 3460Sstevel@tonic-gate }; 3470Sstevel@tonic-gate 3480Sstevel@tonic-gate #define TG_STATUS_VALID(status) \ 3490Sstevel@tonic-gate (((status) >= TG_ACTIVE) && ((status) <= TG_DEAD)) 3500Sstevel@tonic-gate 3510Sstevel@tonic-gate /* 3520Sstevel@tonic-gate * Statistics about consecutive probe failures are passed around between 3530Sstevel@tonic-gate * functions in this structure. 3540Sstevel@tonic-gate */ 3550Sstevel@tonic-gate struct probe_fail_count 3560Sstevel@tonic-gate { 3570Sstevel@tonic-gate uint_t pf_tff; /* Earliest time of failure in a series */ 3580Sstevel@tonic-gate int pf_nfail; /* Number of consecutive probe failures */ 3590Sstevel@tonic-gate int pf_nfail_tg; /* Number of consecutive probe fails for */ 3600Sstevel@tonic-gate /* some given target 'tg' */ 3610Sstevel@tonic-gate }; 3620Sstevel@tonic-gate 3630Sstevel@tonic-gate /* 3640Sstevel@tonic-gate * Statistics about consecutive probe successes is passed around between 3650Sstevel@tonic-gate * functions in this structure. 3660Sstevel@tonic-gate */ 3670Sstevel@tonic-gate struct probe_success_count 3680Sstevel@tonic-gate { 3690Sstevel@tonic-gate uint_t ps_tls; /* Most recent time of probe success */ 3700Sstevel@tonic-gate boolean_t ps_tls_valid; /* is ps_tls valid */ 3710Sstevel@tonic-gate int ps_nsucc; /* Number of consecutive probe successes */ 3720Sstevel@tonic-gate /* starting from the most recent */ 3730Sstevel@tonic-gate int ps_nsucc_tg; /* Number of consecutive probe successes */ 3740Sstevel@tonic-gate /* for some given target 'tg' */ 3750Sstevel@tonic-gate }; 3760Sstevel@tonic-gate 3770Sstevel@tonic-gate /* 3780Sstevel@tonic-gate * Statistics about missed probes that were never sent. 3790Sstevel@tonic-gate * Happens due to scheduling delay. 3800Sstevel@tonic-gate */ 3810Sstevel@tonic-gate 3820Sstevel@tonic-gate struct probes_missed 3830Sstevel@tonic-gate { 3840Sstevel@tonic-gate uint_t pm_nprobes; /* Cumulative number of missed probes */ 3858485SPeter.Memishian@Sun.COM uint_t pm_ntimes; /* Total number of occasions */ 3860Sstevel@tonic-gate }; 3870Sstevel@tonic-gate 3888485SPeter.Memishian@Sun.COM typedef struct addrlist { 3898485SPeter.Memishian@Sun.COM struct addrlist *al_next; /* next address */ 3908485SPeter.Memishian@Sun.COM char al_name[LIFNAMSIZ]; /* address lif name */ 3918485SPeter.Memishian@Sun.COM uint64_t al_flags; /* address flags */ 3928485SPeter.Memishian@Sun.COM struct sockaddr_storage al_addr; /* address */ 3938485SPeter.Memishian@Sun.COM } addrlist_t; 3942250Srk129064 3950Sstevel@tonic-gate /* 3960Sstevel@tonic-gate * Globals 3970Sstevel@tonic-gate */ 3988485SPeter.Memishian@Sun.COM extern addrlist_t *localaddrs; 3992250Srk129064 /* List of all local addresses, including local zones */ 4000Sstevel@tonic-gate extern struct phyint *phyints; /* List of all phyints */ 4010Sstevel@tonic-gate extern struct phyint_group *phyint_groups; /* List of all phyint groups */ 4020Sstevel@tonic-gate extern struct phyint_group *phyint_anongroup; /* Pointer to the anon group */ 4030Sstevel@tonic-gate extern struct phyint_instance *phyint_instances; 4040Sstevel@tonic-gate /* List of all phyint instances */ 4050Sstevel@tonic-gate extern struct probes_missed probes_missed; 4060Sstevel@tonic-gate /* statistics about missed probes */ 4070Sstevel@tonic-gate 4080Sstevel@tonic-gate /* 4090Sstevel@tonic-gate * Function prototypes 4100Sstevel@tonic-gate */ 4110Sstevel@tonic-gate extern int phyint_init(void); 4120Sstevel@tonic-gate extern struct phyint *phyint_lookup(const char *name); 4130Sstevel@tonic-gate extern struct phyint_instance *phyint_inst_lookup(int af, char *name); 4140Sstevel@tonic-gate extern struct phyint_instance *phyint_inst_init_from_k(int af, char *name); 4150Sstevel@tonic-gate extern struct phyint_instance *phyint_inst_other(struct phyint_instance *pii); 4160Sstevel@tonic-gate extern int phyint_inst_update_from_k(struct phyint_instance *pii); 4170Sstevel@tonic-gate extern void phyint_inst_delete(struct phyint_instance *pii); 4180Sstevel@tonic-gate extern uint_t phyint_inst_timer(struct phyint_instance *pii); 4190Sstevel@tonic-gate extern boolean_t phyint_inst_sockinit(struct phyint_instance *pii); 4200Sstevel@tonic-gate 4218485SPeter.Memishian@Sun.COM extern void phyint_changed(struct phyint *pi); 4220Sstevel@tonic-gate extern void phyint_chstate(struct phyint *pi, enum pi_state state); 4230Sstevel@tonic-gate extern void phyint_group_chstate(struct phyint_group *pg, enum pg_state state); 4248485SPeter.Memishian@Sun.COM extern struct phyint_group *phyint_group_create(const char *pg_name); 4258485SPeter.Memishian@Sun.COM extern struct phyint_group *phyint_group_lookup(const char *pg_name); 4268485SPeter.Memishian@Sun.COM extern void phyint_group_insert(struct phyint_group *pg); 4278485SPeter.Memishian@Sun.COM extern void phyint_group_delete(struct phyint_group *pg); 4288485SPeter.Memishian@Sun.COM extern void phyint_group_refresh_state(struct phyint_group *pg); 429*10649SPeter.Memishian@Sun.COM extern void phyint_standby_refresh_inactive(struct phyint *pi); 4300Sstevel@tonic-gate extern void phyint_check_for_repair(struct phyint *pi); 4318485SPeter.Memishian@Sun.COM extern void phyint_transition_to_running(struct phyint *pi); 4328485SPeter.Memishian@Sun.COM extern void phyint_activate_another(struct phyint *pi); 4338485SPeter.Memishian@Sun.COM extern int phyint_offline(struct phyint *pi, unsigned int); 4348485SPeter.Memishian@Sun.COM extern int phyint_undo_offline(struct phyint *pi); 435*10649SPeter.Memishian@Sun.COM extern boolean_t phyint_is_functioning(struct phyint *pi); 4360Sstevel@tonic-gate 4370Sstevel@tonic-gate extern void logint_init_from_k(struct phyint_instance *pii, char *li_name); 4380Sstevel@tonic-gate extern void logint_delete(struct logint *li); 4390Sstevel@tonic-gate 4400Sstevel@tonic-gate extern struct target *target_lookup(struct phyint_instance *pii, 4410Sstevel@tonic-gate struct in6_addr addr); 4420Sstevel@tonic-gate extern void target_create(struct phyint_instance *pii, 4430Sstevel@tonic-gate struct in6_addr addr, boolean_t is_router); 4440Sstevel@tonic-gate extern void target_delete(struct target *tg); 4450Sstevel@tonic-gate extern struct target *target_next(struct target *tg); 4460Sstevel@tonic-gate extern void target_add(struct phyint_instance *pii, struct in6_addr addr, 4470Sstevel@tonic-gate boolean_t is_router); 4480Sstevel@tonic-gate 4490Sstevel@tonic-gate extern void in_data(struct phyint_instance *pii); 4500Sstevel@tonic-gate extern void in6_data(struct phyint_instance *pii); 4510Sstevel@tonic-gate 4526578Smeem extern void logperror_pii(struct phyint_instance *pii, const char *str); 4536578Smeem extern void logperror_li(struct logint *li, const char *str); 4540Sstevel@tonic-gate extern char *pr_addr(int af, struct in6_addr addr, char *abuf, int len); 4558485SPeter.Memishian@Sun.COM extern void addr2storage(int af, const struct in6_addr *addr, 4568485SPeter.Memishian@Sun.COM struct sockaddr_storage *ssp); 4570Sstevel@tonic-gate extern void phyint_inst_print_all(void); 4588485SPeter.Memishian@Sun.COM extern boolean_t prefix_equal(struct in6_addr, struct in6_addr, uint_t); 4590Sstevel@tonic-gate 4600Sstevel@tonic-gate extern void reset_crtt_all(struct phyint *pi); 4610Sstevel@tonic-gate extern int failure_state(struct phyint_instance *pii); 4620Sstevel@tonic-gate extern void process_link_state_changes(void); 4630Sstevel@tonic-gate extern void clear_pii_probe_stats(struct phyint_instance *pii); 4640Sstevel@tonic-gate extern void start_timer(struct phyint_instance *pii); 4658485SPeter.Memishian@Sun.COM extern void stop_probing(struct phyint *pi); 4660Sstevel@tonic-gate 4672250Srk129064 extern boolean_t own_address(struct in6_addr addr); 4688485SPeter.Memishian@Sun.COM extern boolean_t change_pif_flags(struct phyint *pi, uint64_t set, 4698485SPeter.Memishian@Sun.COM uint64_t clear); 4700Sstevel@tonic-gate 4710Sstevel@tonic-gate extern void close_probe_socket(struct phyint_instance *pii, boolean_t flag); 4728485SPeter.Memishian@Sun.COM extern int probe_state_event(struct probe_stats *, struct phyint_instance *); 4738485SPeter.Memishian@Sun.COM extern void probe_chstate(struct probe_stats *, struct phyint_instance *, int); 4740Sstevel@tonic-gate 4758485SPeter.Memishian@Sun.COM extern unsigned int getgraddrinfo(const char *, struct sockaddr_storage *, 4768485SPeter.Memishian@Sun.COM ipmp_addrinfo_t **); 4770Sstevel@tonic-gate extern unsigned int getifinfo(const char *, ipmp_ifinfo_t **); 4780Sstevel@tonic-gate extern unsigned int getgroupinfo(const char *, ipmp_groupinfo_t **); 4790Sstevel@tonic-gate extern unsigned int getgrouplist(ipmp_grouplist_t **); 4800Sstevel@tonic-gate extern unsigned int getsnap(ipmp_snap_t **); 4810Sstevel@tonic-gate 4828485SPeter.Memishian@Sun.COM extern boolean_t addrlist_add(addrlist_t **, const char *, uint64_t, 4838485SPeter.Memishian@Sun.COM struct sockaddr_storage *); 4848485SPeter.Memishian@Sun.COM extern void addrlist_free(addrlist_t **); 4858485SPeter.Memishian@Sun.COM 4860Sstevel@tonic-gate #ifdef __cplusplus 4870Sstevel@tonic-gate } 4880Sstevel@tonic-gate #endif 4890Sstevel@tonic-gate 4900Sstevel@tonic-gate #endif /* _MPD_TABLES_H */ 491