1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _SYS_AGGR_H 27 #define _SYS_AGGR_H 28 29 #pragma ident "@(#)aggr.h 1.5 07/06/29 SMI" 30 31 #include <sys/types.h> 32 #include <sys/ethernet.h> 33 #include <sys/param.h> 34 #include <sys/dld_ioc.h> 35 36 #ifdef __cplusplus 37 extern "C" { 38 #endif 39 40 /* 41 * Transmit load balancing policies. 42 */ 43 44 #define AGGR_POLICY_L2 0x01 45 #define AGGR_POLICY_L3 0x02 46 #define AGGR_POLICY_L4 0x04 47 48 /* 49 * LACP mode and timer. 50 */ 51 52 typedef enum { 53 AGGR_LACP_OFF = 0, 54 AGGR_LACP_ACTIVE = 1, 55 AGGR_LACP_PASSIVE = 2 56 } aggr_lacp_mode_t; 57 58 typedef enum { 59 AGGR_LACP_TIMER_LONG = 0, 60 AGGR_LACP_TIMER_SHORT = 1 61 } aggr_lacp_timer_t; 62 63 /* 64 * MAC port state. 65 */ 66 typedef enum { 67 AGGR_PORT_STATE_STANDBY = 1, 68 AGGR_PORT_STATE_ATTACHED = 2 69 } aggr_port_state_t; 70 71 /* Maximum number of ports per aggregation. */ 72 #define AGGR_MAX_PORTS 256 73 74 /* 75 * LACP port state. 76 */ 77 typedef union { 78 struct { 79 #if defined(_BIT_FIELDS_HTOL) 80 uint8_t expired: 1; 81 uint8_t defaulted: 1; 82 uint8_t distributing: 1; 83 uint8_t collecting: 1; 84 uint8_t sync: 1; 85 uint8_t aggregation: 1; 86 uint8_t timeout: 1; 87 uint8_t activity: 1; 88 #elif defined(_BIT_FIELDS_LTOH) 89 uint8_t activity: 1; 90 uint8_t timeout: 1; 91 uint8_t aggregation: 1; 92 uint8_t sync: 1; 93 uint8_t collecting: 1; 94 uint8_t distributing: 1; 95 uint8_t defaulted: 1; 96 uint8_t expired: 1; 97 #else 98 #error "unknown bit fields ordering" 99 #endif 100 } bit; 101 uint8_t state; 102 } aggr_lacp_state_t; 103 104 /* one of the ports of a link aggregation group */ 105 typedef struct laioc_port { 106 char lp_devname[MAXNAMELEN + 1]; 107 } laioc_port_t; 108 109 #define LAIOC_CREATE AGGRIOC(1) 110 111 typedef struct laioc_create { 112 uint32_t lc_key; 113 uint32_t lc_nports; 114 uint32_t lc_policy; 115 uchar_t lc_mac[ETHERADDRL]; 116 boolean_t lc_mac_fixed; 117 aggr_lacp_mode_t lc_lacp_mode; 118 aggr_lacp_timer_t lc_lacp_timer; 119 } laioc_create_t; 120 121 #define LAIOC_DELETE AGGRIOC(2) 122 123 typedef struct laioc_delete { 124 uint32_t ld_key; 125 } laioc_delete_t; 126 127 #define LAIOC_INFO AGGRIOC(3) 128 129 typedef enum aggr_link_duplex { 130 AGGR_LINK_DUPLEX_FULL = 1, 131 AGGR_LINK_DUPLEX_HALF = 2, 132 AGGR_LINK_DUPLEX_UNKNOWN = 3 133 } aggr_link_duplex_t; 134 135 typedef enum aggr_link_state { 136 AGGR_LINK_STATE_UP = 1, 137 AGGR_LINK_STATE_DOWN = 2, 138 AGGR_LINK_STATE_UNKNOWN = 3 139 } aggr_link_state_t; 140 141 typedef struct laioc_info_port { 142 char lp_devname[MAXNAMELEN + 1]; 143 uchar_t lp_mac[ETHERADDRL]; 144 aggr_port_state_t lp_state; 145 aggr_lacp_state_t lp_lacp_state; 146 } laioc_info_port_t; 147 148 typedef struct laioc_info_group { 149 uint32_t lg_key; 150 uchar_t lg_mac[ETHERADDRL]; 151 boolean_t lg_mac_fixed; 152 uint32_t lg_policy; 153 uint32_t lg_nports; 154 aggr_lacp_mode_t lg_lacp_mode; 155 aggr_lacp_timer_t lg_lacp_timer; 156 } laioc_info_group_t; 157 158 typedef struct laioc_info { 159 uint32_t li_ngroups; 160 uint32_t li_group_key; /* 0 returns all */ 161 uint32_t li_bufsize; 162 } laioc_info_t; 163 164 #define LAIOC_ADD AGGRIOC(4) 165 #define LAIOC_REMOVE AGGRIOC(5) 166 167 typedef struct laioc_add_rem { 168 uint32_t la_key; 169 uint32_t la_nports; 170 } laioc_add_rem_t; 171 172 #define LAIOC_MODIFY AGGRIOC(6) 173 174 #define LAIOC_MODIFY_POLICY 0x01 175 #define LAIOC_MODIFY_MAC 0x02 176 #define LAIOC_MODIFY_LACP_MODE 0x04 177 #define LAIOC_MODIFY_LACP_TIMER 0x08 178 179 typedef struct laioc_modify { 180 uint32_t lu_key; 181 uint8_t lu_modify_mask; 182 uint32_t lu_policy; 183 uchar_t lu_mac[ETHERADDRL]; 184 boolean_t lu_mac_fixed; 185 aggr_lacp_mode_t lu_lacp_mode; 186 aggr_lacp_timer_t lu_lacp_timer; 187 } laioc_modify_t; 188 189 #ifdef __cplusplus 190 } 191 #endif 192 193 #endif /* _SYS_AGGR_H */ 194