lib: remove unused libnvfru
[unleashed/lotheac.git] / include / sys / mac_flow.h
blobb90c14634dc17ce291966c3d3e12819535de1311
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 * Copyright 2013 Joyent, Inc. All rights reserved.
28 #ifndef _MAC_FLOW_H
29 #define _MAC_FLOW_H
32 * Main structure describing a flow of packets, for classification use
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
39 #include <sys/types.h>
40 #include <sys/param.h> /* for MAXPATHLEN */
41 #include <netinet/in.h> /* for IPPROTO_* constants */
42 #include <sys/ethernet.h>
43 #include <sys/param.h>
45 #define MAX_RINGS_PER_GROUP 128
48 * MAXFLOWNAMELEN defines the longest possible permitted flow name,
49 * including the terminating NUL.
51 #define MAXFLOWNAMELEN 128
53 /* need to use MAXMACADDRLEN from dld.h instead of this one */
54 #define MAXMACADDR 20
56 /* Bit-mask for the selectors carried in the flow descriptor */
57 typedef uint64_t flow_mask_t;
59 #define FLOW_LINK_DST 0x00000001 /* Destination MAC addr */
60 #define FLOW_LINK_SRC 0x00000002 /* Source MAC address */
61 #define FLOW_LINK_VID 0x00000004 /* VLAN ID */
62 #define FLOW_LINK_SAP 0x00000008 /* SAP value */
64 #define FLOW_IP_VERSION 0x00000010 /* V4 or V6 */
65 #define FLOW_IP_PROTOCOL 0x00000020 /* Protocol type */
66 #define FLOW_IP_LOCAL 0x00000040 /* Local address */
67 #define FLOW_IP_REMOTE 0x00000080 /* Remote address */
68 #define FLOW_IP_DSFIELD 0x00000100 /* DSfield value */
70 #define FLOW_ULP_PORT_LOCAL 0x00001000 /* ULP local port */
71 #define FLOW_ULP_PORT_REMOTE 0x00002000 /* ULP remote port */
73 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
74 #pragma pack(4)
75 #endif
77 typedef struct flow_desc_s {
78 flow_mask_t fd_mask;
79 uint32_t fd_mac_len;
80 uint8_t fd_dst_mac[MAXMACADDR];
81 uint8_t fd_src_mac[MAXMACADDR];
82 uint16_t fd_vid;
83 uint32_t fd_sap;
84 uint8_t fd_ipversion;
85 uint8_t fd_protocol;
86 in6_addr_t fd_local_addr;
87 in6_addr_t fd_local_netmask;
88 in6_addr_t fd_remote_addr;
89 in6_addr_t fd_remote_netmask;
90 in_port_t fd_local_port;
91 in_port_t fd_remote_port;
92 uint8_t fd_dsfield;
93 uint8_t fd_dsfield_mask;
94 } flow_desc_t;
96 #define MRP_NCPUS 128
99 * In MCM_CPUS mode, cpu bindings is user specified. In MCM_FANOUT mode,
100 * user only specifies a fanout count.
101 * mc_rx_fanout_cnt gives the number of CPUs used for fanout soft rings.
102 * mc_rx_fanout_cpus[] array stores the CPUs used for fanout soft rings.
104 typedef enum {
105 MCM_FANOUT = 1,
106 MCM_CPUS
107 } mac_cpu_mode_t;
110 * Structure to store the value of the CPUs to be used to re-target
111 * Tx interrupt.
113 typedef struct mac_tx_intr_cpus_s {
114 /* cpu value to re-target intr to */
115 int32_t mtc_intr_cpu[MRP_NCPUS];
116 /* re-targeted CPU or -1 if failed */
117 int32_t mtc_retargeted_cpu[MRP_NCPUS];
118 } mac_tx_intr_cpu_t;
120 typedef struct mac_cpus_props_s {
121 uint32_t mc_ncpus; /* num of cpus */
122 uint32_t mc_cpus[MRP_NCPUS]; /* cpu list */
123 uint32_t mc_rx_fanout_cnt; /* soft ring cpu cnt */
124 uint32_t mc_rx_fanout_cpus[MRP_NCPUS]; /* SR cpu list */
125 uint32_t mc_rx_pollid; /* poll thr binding */
126 uint32_t mc_rx_workerid; /* worker thr binding */
128 * interrupt cpu: mrp_intr_cpu less than 0 implies platform limitation
129 * in retargetting the interrupt assignment.
131 int32_t mc_rx_intr_cpu;
132 int32_t mc_tx_fanout_cpus[MRP_NCPUS];
133 mac_tx_intr_cpu_t mc_tx_intr_cpus;
134 mac_cpu_mode_t mc_fanout_mode; /* fanout mode */
135 } mac_cpus_t;
137 #define mc_tx_intr_cpu mc_tx_intr_cpus.mtc_intr_cpu
138 #define mc_tx_retargeted_cpu mc_tx_intr_cpus.mtc_retargeted_cpu
140 /* Priority values */
141 typedef enum {
142 MPL_LOW,
143 MPL_MEDIUM,
144 MPL_HIGH,
145 MPL_RESET
146 } mac_priority_level_t;
148 /* Protection types */
149 #define MPT_MACNOSPOOF 0x00000001
150 #define MPT_RESTRICTED 0x00000002
151 #define MPT_IPNOSPOOF 0x00000004
152 #define MPT_DHCPNOSPOOF 0x00000008
153 #define MPT_ALL 0x0000000f
154 #define MPT_RESET 0xffffffff
155 #define MPT_MAXCNT 32
156 #define MPT_MAXIPADDR MPT_MAXCNT
157 #define MPT_MAXCID MPT_MAXCNT
158 #define MPT_MAXCIDLEN 256
160 typedef struct mac_ipaddr_s {
161 uint32_t ip_version;
162 in6_addr_t ip_addr;
163 uint8_t ip_netmask;
164 } mac_ipaddr_t;
166 typedef enum {
167 CIDFORM_TYPED = 1,
168 CIDFORM_HEX,
169 CIDFORM_STR
170 } mac_dhcpcid_form_t;
172 typedef struct mac_dhcpcid_s {
173 uchar_t dc_id[MPT_MAXCIDLEN];
174 uint32_t dc_len;
175 mac_dhcpcid_form_t dc_form;
176 } mac_dhcpcid_t;
178 typedef struct mac_protect_s {
179 uint32_t mp_types;
180 uint32_t mp_ipaddrcnt;
181 mac_ipaddr_t mp_ipaddrs[MPT_MAXIPADDR];
182 uint32_t mp_cidcnt;
183 mac_dhcpcid_t mp_cids[MPT_MAXCID];
184 } mac_protect_t;
186 /* The default priority for links */
187 #define MPL_LINK_DEFAULT MPL_HIGH
189 /* The default priority for flows */
190 #define MPL_SUBFLOW_DEFAULT MPL_MEDIUM
192 #define MRP_MAXBW 0x00000001 /* Limit set */
193 #define MRP_CPUS 0x00000002 /* CPU/fanout set */
194 #define MRP_CPUS_USERSPEC 0x00000004 /* CPU/fanout from user */
195 #define MRP_PRIORITY 0x00000008 /* Priority set */
196 #define MRP_PROTECT 0x00000010 /* Protection set */
197 #define MRP_RX_RINGS 0x00000020 /* Rx rings */
198 #define MRP_TX_RINGS 0x00000040 /* Tx rings */
199 #define MRP_RXRINGS_UNSPEC 0x00000080 /* unspecified rings */
200 #define MRP_TXRINGS_UNSPEC 0x00000100 /* unspecified rings */
201 #define MRP_RINGS_RESET 0x00000200 /* resetting rings */
202 #define MRP_POOL 0x00000400 /* CPU pool */
204 #define MRP_THROTTLE MRP_MAXBW
206 /* 3 levels - low, medium, high */
207 #define MRP_PRIORITY_LEVELS 3
209 /* Special value denoting no bandwidth control */
210 #define MRP_MAXBW_RESETVAL -1ULL
213 * Until sub-megabit limit is implemented,
214 * reject values lower than 1 MTU per tick or 1.2Mbps
216 #define MRP_MAXBW_MINVAL 1200000
218 typedef struct mac_resource_props_s {
220 * Bit-mask for the network resource control types types
222 uint32_t mrp_mask;
223 uint64_t mrp_maxbw; /* bandwidth limit in bps */
224 mac_priority_level_t mrp_priority; /* relative flow priority */
225 mac_cpus_t mrp_cpus;
226 mac_protect_t mrp_protect;
227 uint32_t mrp_nrxrings;
228 uint32_t mrp_ntxrings;
229 char mrp_pool[MAXPATHLEN]; /* CPU pool */
230 } mac_resource_props_t;
232 #define mrp_ncpus mrp_cpus.mc_ncpus
233 #define mrp_cpu mrp_cpus.mc_cpus
234 #define mrp_rx_fanout_cnt mrp_cpus.mc_rx_fanout_cnt
235 #define mrp_rx_pollid mrp_cpus.mc_rx_pollid
236 #define mrp_rx_workerid mrp_cpus.mc_rx_workerid
237 #define mrp_rx_intr_cpu mrp_cpus.mc_rx_intr_cpu
238 #define mrp_fanout_mode mrp_cpus.mc_fanout_mode
240 #define MAC_COPY_CPUS(mrp, fmrp) { \
241 int ncpus; \
242 (fmrp)->mrp_ncpus = (mrp)->mrp_ncpus; \
243 (fmrp)->mrp_rx_fanout_cnt = (mrp)->mrp_rx_fanout_cnt; \
244 (fmrp)->mrp_rx_intr_cpu = (mrp)->mrp_rx_intr_cpu; \
245 (fmrp)->mrp_fanout_mode = (mrp)->mrp_fanout_mode; \
246 if ((mrp)->mrp_ncpus == 0) { \
247 (fmrp)->mrp_mask &= ~MRP_CPUS; \
248 (fmrp)->mrp_mask &= ~MRP_CPUS_USERSPEC; \
249 } else { \
250 for (ncpus = 0; ncpus < (fmrp)->mrp_ncpus; ncpus++) \
251 (fmrp)->mrp_cpu[ncpus] = (mrp)->mrp_cpu[ncpus];\
252 (fmrp)->mrp_mask |= MRP_CPUS; \
253 if ((mrp)->mrp_mask & MRP_CPUS_USERSPEC) \
254 (fmrp)->mrp_mask |= MRP_CPUS_USERSPEC; \
258 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
259 #pragma pack()
260 #endif
262 #ifdef __cplusplus
264 #endif
266 #endif /* _MAC_FLOW_H */