xref: /xnu-12377.81.4/bsd/net/if_var_status.h (revision 043036a2b3718f7f0be807e2870f8f47d3fa0796)
1 /*
2  * Copyright (c) 2000-2021 Apple Inc. All rights reserved.
3  *
4  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5  *
6  * This file contains Original Code and/or Modifications of Original Code
7  * as defined in and that are subject to the Apple Public Source License
8  * Version 2.0 (the 'License'). You may not use this file except in
9  * compliance with the License. The rights granted to you under the License
10  * may not be used to create, or enable the creation or redistribution of,
11  * unlawful or unlicensed copies of an Apple operating system, or to
12  * circumvent, violate, or enable the circumvention or violation of, any
13  * terms of an Apple operating system software license agreement.
14  *
15  * Please obtain a copy of the License at
16  * http://www.opensource.apple.com/apsl/ and read it before using this file.
17  *
18  * The Original Code and all software distributed under the License are
19  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23  * Please see the License for the specific language governing rights and
24  * limitations under the License.
25  *
26  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27  */
28 /*
29  * Copyright (c) 1982, 1986, 1989, 1993
30  *    The Regents of the University of California.  All rights reserved.
31  *
32  * Redistribution and use in source and binary forms, with or without
33  * modification, are permitted provided that the following conditions
34  * are met:
35  * 1. Redistributions of source code must retain the above copyright
36  *    notice, this list of conditions and the following disclaimer.
37  * 2. Redistributions in binary form must reproduce the above copyright
38  *    notice, this list of conditions and the following disclaimer in the
39  *    documentation and/or other materials provided with the distribution.
40  * 3. All advertising materials mentioning features or use of this software
41  *    must display the following acknowledgement:
42  *    This product includes software developed by the University of
43  *    California, Berkeley and its contributors.
44  * 4. Neither the name of the University nor the names of its contributors
45  *    may be used to endorse or promote products derived from this software
46  *    without specific prior written permission.
47  *
48  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
49  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
52  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58  * SUCH DAMAGE.
59  *
60  *    From: @(#)if.h    8.1 (Berkeley) 6/10/93
61  * $FreeBSD: src/sys/net/if_var.h,v 1.18.2.7 2001/07/24 19:10:18 brooks Exp $
62  */
63 
64 #ifndef _NET_IF_VAR_STATUS_H_
65 #define _NET_IF_VAR_STATUS_H_
66 
67 #include <machine/types.h>
68 #include <stdint.h>
69 #include <net/ethernet.h>
70 
71 #pragma pack(4)
72 
73 /*
74  * Interface link status report -- includes statistics related to
75  * the link layer technology sent by the driver. The driver will monitor
76  * these statistics over an interval (3-4 secs) and will generate a report
77  * to the network stack. This will give first-hand information about the
78  * status of the first hop of the network path. The version and
79  * length values should be correct for the data to be processed correctly.
80  * The definitions are different for different kind of interfaces like
81  * Wifi, Cellular etc,.
82  */
83 #define IF_CELLULAR_STATUS_REPORT_VERSION_1     1
84 #define IF_WIFI_STATUS_REPORT_VERSION_1         1
85 #define IF_CELLULAR_STATUS_REPORT_CURRENT_VERSION       \
86 	                                IF_CELLULAR_STATUS_REPORT_VERSION_1
87 #define IF_WIFI_STATUS_REPORT_CURRENT_VERSION   IF_WIFI_STATUS_REPORT_VERSION_1
88 /*
89  * For cellular interface --
90  * There is no way to share common headers between the Baseband and
91  * the kernel. Any changes to this structure will need to be communicated
92  * to the Baseband team. It is better to use reserved space instead of
93  * changing the size or existing fields in the structure.
94  */
95 struct if_cellular_status_v1 {
96 	u_int32_t valid_bitmask;     /* indicates which fields are valid */
97 #define IF_CELL_LINK_QUALITY_METRIC_VALID       0x1
98 #define IF_CELL_UL_EFFECTIVE_BANDWIDTH_VALID    0x2
99 #define IF_CELL_UL_MAX_BANDWIDTH_VALID          0x4
100 #define IF_CELL_UL_MIN_LATENCY_VALID            0x8
101 #define IF_CELL_UL_EFFECTIVE_LATENCY_VALID      0x10
102 #define IF_CELL_UL_MAX_LATENCY_VALID            0x20
103 #define IF_CELL_UL_RETXT_LEVEL_VALID            0x40
104 #define IF_CELL_UL_BYTES_LOST_VALID             0x80
105 #define IF_CELL_UL_MIN_QUEUE_SIZE_VALID         0x100
106 #define IF_CELL_UL_AVG_QUEUE_SIZE_VALID         0x200
107 #define IF_CELL_UL_MAX_QUEUE_SIZE_VALID         0x400
108 #define IF_CELL_DL_EFFECTIVE_BANDWIDTH_VALID    0x800
109 #define IF_CELL_DL_MAX_BANDWIDTH_VALID          0x1000
110 #define IF_CELL_CONFIG_INACTIVITY_TIME_VALID    0x2000
111 #define IF_CELL_CONFIG_BACKOFF_TIME_VALID       0x4000
112 #define IF_CELL_UL_MSS_RECOMMENDED_VALID        0x8000
113 
114 	u_int32_t link_quality_metric;
115 	u_int32_t ul_effective_bandwidth; /* Measured uplink bandwidth based on current activity (bps) */
116 	u_int32_t ul_max_bandwidth; /* Maximum supported uplink bandwidth (bps) */
117 	u_int32_t ul_min_latency; /* min expected uplink latency for first hop (ms) */
118 	u_int32_t ul_effective_latency; /* current expected uplink latency for first hop (ms) */
119 	u_int32_t ul_max_latency; /* max expected uplink latency first hop (ms) */
120 	u_int32_t ul_retxt_level; /* Retransmission metric */
121 #define IF_CELL_UL_RETXT_LEVEL_NONE     1
122 #define IF_CELL_UL_RETXT_LEVEL_LOW      2
123 #define IF_CELL_UL_RETXT_LEVEL_MEDIUM   3
124 #define IF_CELL_UL_RETXT_LEVEL_HIGH     4
125 	u_int32_t ul_bytes_lost; /* % of total bytes lost on uplink in Q10 format */
126 	u_int32_t ul_min_queue_size; /* minimum bytes in queue */
127 	u_int32_t ul_avg_queue_size; /* average bytes in queue */
128 	u_int32_t ul_max_queue_size; /* maximum bytes in queue */
129 	u_int32_t dl_effective_bandwidth; /* Measured downlink bandwidth based on current activity (bps) */
130 	u_int32_t dl_max_bandwidth; /* Maximum supported downlink bandwidth (bps) */
131 	u_int32_t config_inactivity_time; /* ms */
132 	u_int32_t config_backoff_time; /* new connections backoff time in ms */
133 #define IF_CELL_UL_MSS_RECOMMENDED_NONE 0x0 /* Use default */
134 #define IF_CELL_UL_MSS_RECOMMENDED_MEDIUM 0x1 /* 1200 byte MSS */
135 #define IF_CELL_UL_MSS_RECOMMENDED_LOW  0x2 /* 512 byte MSS */
136 	u_int16_t mss_recommended;
137 	u_int16_t reserved_1;
138 	u_int32_t reserved_2;
139 	u_int64_t reserved_3;
140 	u_int64_t reserved_4;
141 	u_int64_t reserved_5;
142 	u_int64_t reserved_6;
143 } __attribute__((packed));
144 
145 struct if_cellular_status {
146 	union {
147 		struct if_cellular_status_v1 if_status_v1;
148 	} if_cell_u;
149 };
150 
151 /*
152  * These statistics will be provided by the Wifi driver periodically.
153  * After sending each report, the driver should start computing again
154  * for the next report duration so that the values represent the link
155  * status for one report duration.
156  */
157 
158 struct if_wifi_status_v1 {
159 	u_int32_t valid_bitmask;
160 #define IF_WIFI_LINK_QUALITY_METRIC_VALID       0x1
161 #define IF_WIFI_UL_EFFECTIVE_BANDWIDTH_VALID    0x2
162 #define IF_WIFI_UL_MAX_BANDWIDTH_VALID          0x4
163 #define IF_WIFI_UL_MIN_LATENCY_VALID            0x8
164 #define IF_WIFI_UL_EFFECTIVE_LATENCY_VALID      0x10
165 #define IF_WIFI_UL_MAX_LATENCY_VALID            0x20
166 #define IF_WIFI_UL_RETXT_LEVEL_VALID            0x40
167 #define IF_WIFI_UL_ERROR_RATE_VALID             0x80
168 #define IF_WIFI_UL_BYTES_LOST_VALID             0x100
169 #define IF_WIFI_DL_EFFECTIVE_BANDWIDTH_VALID    0x200
170 #define IF_WIFI_DL_MAX_BANDWIDTH_VALID          0x400
171 #define IF_WIFI_DL_MIN_LATENCY_VALID            0x800
172 #define IF_WIFI_DL_EFFECTIVE_LATENCY_VALID      0x1000
173 #define IF_WIFI_DL_MAX_LATENCY_VALID            0x2000
174 #define IF_WIFI_DL_ERROR_RATE_VALID             0x4000
175 #define IF_WIFI_CONFIG_FREQUENCY_VALID          0x8000
176 #define IF_WIFI_CONFIG_MULTICAST_RATE_VALID     0x10000
177 #define IF_WIFI_CONFIG_SCAN_COUNT_VALID         0x20000
178 #define IF_WIFI_CONFIG_SCAN_DURATION_VALID      0x40000
179 	u_int32_t link_quality_metric; /* link quality metric */
180 	u_int32_t ul_effective_bandwidth; /* Measured uplink bandwidth based on current activity (bps) */
181 	u_int32_t ul_max_bandwidth; /* Maximum supported uplink bandwidth (bps) */
182 	u_int32_t ul_min_latency; /* min expected uplink latency for first hop (ms) */
183 	u_int32_t ul_effective_latency; /* current expected uplink latency for first hop (ms) */
184 	u_int32_t ul_max_latency; /* max expected uplink latency for first hop (ms) */
185 	u_int32_t ul_retxt_level; /* Retransmission metric */
186 #define IF_WIFI_UL_RETXT_LEVEL_NONE     1
187 #define IF_WIFI_UL_RETXT_LEVEL_LOW      2
188 #define IF_WIFI_UL_RETXT_LEVEL_MEDIUM   3
189 #define IF_WIFI_UL_RETXT_LEVEL_HIGH     4
190 	u_int32_t ul_bytes_lost; /* % of total bytes lost on uplink in Q10 format */
191 	u_int32_t ul_error_rate; /* % of bytes dropped on uplink after many retransmissions in Q10 format */
192 	u_int32_t dl_effective_bandwidth; /* Measured downlink bandwidth based on current activity (bps) */
193 	u_int32_t dl_max_bandwidth; /* Maximum supported downlink bandwidth (bps) */
194 	/*
195 	 * The download latency values indicate the time AP may have to wait for the
196 	 * driver to receive the packet. These values give the range of expected latency
197 	 * mainly due to co-existence events and channel hopping where the interface
198 	 * becomes unavailable.
199 	 */
200 	u_int32_t dl_min_latency; /* min expected latency for first hop in ms */
201 	u_int32_t dl_effective_latency; /* current expected latency for first hop in ms */
202 	u_int32_t dl_max_latency; /* max expected latency for first hop in ms */
203 	u_int32_t dl_error_rate; /* % of CRC or other errors in Q10 format */
204 	u_int32_t config_frequency; /* 2.4 or 5 GHz */
205 #define IF_WIFI_CONFIG_FREQUENCY_2_4_GHZ        1
206 #define IF_WIFI_CONFIG_FREQUENCY_5_0_GHZ        2
207 	u_int32_t config_multicast_rate; /* bps */
208 	u_int32_t scan_count; /* scan count during the previous period */
209 	u_int32_t scan_duration; /* scan duration in ms */
210 	u_int64_t reserved_1;
211 	u_int64_t reserved_2;
212 	u_int64_t reserved_3;
213 	u_int64_t reserved_4;
214 } __attribute__((packed));
215 
216 struct if_wifi_status {
217 	union {
218 		struct if_wifi_status_v1 if_status_v1;
219 	} if_wifi_u;
220 };
221 
222 struct if_link_status {
223 	u_int32_t       ifsr_version;   /* version of this report */
224 	u_int32_t       ifsr_len;       /* length of the following struct */
225 	union {
226 		struct if_cellular_status ifsr_cell;
227 		struct if_wifi_status ifsr_wifi;
228 	} ifsr_u;
229 };
230 
231 /*
232  * This structure is used to define the parameters for advisory notifications
233  * on an interface.
234  */
235 #pragma pack(push, 1)
236 enum ifnet_interface_advisory_version : uint8_t {
237 	/*
238 	 * Initial version with interface advisory report for WiFi interface.
239 	 */
240 	IF_INTERFACE_ADVISORY_VERSION_1 = 1,
241 #if XNU_KERNEL_PRIVATE
242 	IF_INTERFACE_ADVISORY_VERSION_MIN = IF_INTERFACE_ADVISORY_VERSION_1,
243 #endif /* XNU_KERNEL_PRIVATE */
244 	/*
245 	 * Reorganized the interface advisory structure to separate out
246 	 * WiFi and Cellular interface specific reports.
247 	 */
248 	IF_INTERFACE_ADVISORY_VERSION_2 = 2,
249 	IF_INTERFACE_ADVISORY_VERSION_CURRENT = IF_INTERFACE_ADVISORY_VERSION_2,
250 #if XNU_KERNEL_PRIVATE
251 	IF_INTERFACE_ADVISORY_VERSION_MAX = IF_INTERFACE_ADVISORY_VERSION_2,
252 #endif /* XNU_KERNEL_PRIVATE */
253 };
254 
255 enum ifnet_interface_advisory_direction : uint8_t {
256 	IF_INTERFACE_ADVISORY_DIRECTION_TX = 1,
257 	IF_INTERFACE_ADVISORY_DIRECTION_RX = 2,
258 };
259 
260 enum ifnet_interface_advisory_interface_type : uint8_t {
261 	IF_INTERFACE_ADVISORY_INTERFACE_TYPE_WIFI = 1,
262 #if XNU_KERNEL_PRIVATE
263 	IF_INTERFACE_ADVISORY_INTERFACE_TYPE_MIN =
264 	    IF_INTERFACE_ADVISORY_INTERFACE_TYPE_WIFI,
265 #endif /* XNU_KERNEL_PRIVATE */
266 	IF_INTERFACE_ADVISORY_INTERFACE_TYPE_CELL = 2,
267 #if XNU_KERNEL_PRIVATE
268 	IF_INTERFACE_ADVISORY_INTERFACE_TYPE_MAX =
269 	    IF_INTERFACE_ADVISORY_INTERFACE_TYPE_CELL,
270 #endif /* XNU_KERNEL_PRIVATE */
271 };
272 
273 enum ifnet_interface_advisory_notification_type_cell : uint8_t {
274 	/* Reserved for MAV platform */
275 	IF_INTERFACE_ADVISORY_NOTIFICATION_TYPE_CELLULAR_DEFAULT= 0,
276 	/* Used when sending Codec Rate Adaptation related notifications */
277 	IF_INTERFACE_ADVISORY_NOTIFICATION_TYPE_CELLULAR_UPLINK_CRA,
278 	/*
279 	 * Used when sending periodic measurement of parameters (RSRP,RSSI etc.)
280 	 * during VoLTE/VoNR calls
281 	 */
282 	IF_INTERFACE_ADVISORY_NOTIFICATION_TYPE_CELLULAR_MEASUREMENT_UPDATE,
283 	/* Used when a TTI bundle enable/disable occurs during VoLTE/VoNR calls */
284 	IF_INTERFACE_ADVISORY_NOTIFICATION_TYPE_CELLULAR_BANDWIDTH_LIMITATION_EVENT,
285 	/* Used when a configuration change occurs in CDRx during VoLTE/VoNR calls */
286 	IF_INTERFACE_ADVISORY_NOTIFICATION_TYPE_CELLULAR_DISCONTINUOUS_RECEPTION_EVENT,
287 	/* Used when a handover start/end occurs during VoLTE/VoNR calls */
288 	IF_INTERFACE_ADVISORY_NOTIFICATION_TYPE_CELLULAR_OUTAGE_EVENT,
289 	/* Used for Thermal Codec Rate Adaptation Events */
290 	IF_INTERFACE_ADVISORY_NOTIFICATION_TYPE_CELLULAR_THERMAL_CRA_EVENT,
291 };
292 
293 enum ifnet_interface_advisory_notification_type_wifi : uint8_t {
294 	/* Unused for now */
295 	IF_INTERFACE_ADVISORY_NOTIFICATION_TYPE_WIFI_UNDEFINED = 0,
296 };
297 
298 typedef union {
299 	enum ifnet_interface_advisory_notification_type_cell cell;
300 	enum ifnet_interface_advisory_notification_type_wifi wifi;
301 } ifnet_interface_advisory_notification_type_t;
302 
303 struct ifnet_interface_advisory_header {
304 	/* The current structure version */
305 	enum ifnet_interface_advisory_version         version;
306 	/* Specifies if the advisory is for transmit or receive path */
307 	enum ifnet_interface_advisory_direction       direction;
308 	/* Interface type */
309 	enum ifnet_interface_advisory_interface_type  interface_type;
310 	/* Notification type */
311 	ifnet_interface_advisory_notification_type_t  notification_type;
312 };
313 
314 enum ifnet_interface_advisory_rate_trend : int32_t {
315 	IF_INTERFACE_ADVISORY_RATE_SUGGESTION_RAMP_UP = INT32_MAX,
316 	IF_INTERFACE_ADVISORY_RATE_SUGGESTION_RAMP_DOWN = INT32_MIN,
317 	IF_INTERFACE_ADVISORY_RATE_SUGGESTION_RAMP_NEUTRAL = 0,
318 };
319 
320 struct ifnet_interface_advisory_capacity {
321 	/*
322 	 * suggestion for data rate change to keep the latency low.
323 	 * unit: bits per second (bps)
324 	 * NOTE: if the interface cannot provide suggestions in
325 	 * terms of bps, it should use the following values:
326 	 * INT32_MAX : ramp up
327 	 * INT32_MIN : ramp down
328 	 * 0         : neutral
329 	 */
330 	enum ifnet_interface_advisory_rate_trend  rate_trend_suggestion;
331 	/*
332 	 * Time of the issue of advisory.
333 	 * Timestamp should be in the host domain.
334 	 * unit: mach absolute time
335 	 */
336 	uint64_t    timestamp;
337 	/*
338 	 * Maximum theoretical bandwidth of the interface.
339 	 * unit: bits per second (bps)
340 	 */
341 	uint64_t    max_bandwidth;
342 	/*
343 	 * Total bytes sent or received on the interface.
344 	 * wrap around possible and the application should account for that.
345 	 * unit: byte
346 	 */
347 	uint64_t    total_byte_count;
348 	/*
349 	 * average throughput observed at the driver stack.
350 	 * unit: bits per second (bps)
351 	 */
352 	uint64_t    average_throughput;
353 	/*
354 	 * flushable queue size at the driver.
355 	 * should be set to UINT32_MAX if not available.
356 	 * unit: byte
357 	 */
358 	uint32_t    flushable_queue_size;
359 	/*
360 	 * non flushable queue size at the driver.
361 	 * should be set to UINT32_MAX if not available.
362 	 * unit: byte
363 	 */
364 	uint32_t    non_flushable_queue_size;
365 	/*
366 	 * average delay observed at the interface.
367 	 * unit: milliseconds (ms)
368 	 */
369 	uint32_t    average_delay;
370 };
371 
372 enum ifnet_interface_advisory_wifi_freq_band : uint8_t {
373 	IF_INTERFACE_ADVISORY_FREQ_BAND_NOT_AVAIL =  0,
374 	IF_INTERFACE_ADVISORY_FREQ_BAND_WIFI_24GHZ = 1,
375 	IF_INTERFACE_ADVISORY_FREQ_BAND_WIFI_5GHZ =  2,
376 	IF_INTERFACE_ADVISORY_FREQ_BAND_WIFI_6GHZ =  3,
377 };
378 
379 /*
380  * This structure is used to define the parameters for advisory notifications
381  * that are specific for WiFi interface.
382  */
383 struct ifnet_interface_advisory_wifi_context {
384 	/*
385 	 * Current frequency band (enumeration).
386 	 */
387 	enum ifnet_interface_advisory_wifi_freq_band  frequency_band;
388 	/*
389 	 * Intermittent WiFi state [true(1)/false(0)]
390 	 */
391 	uint8_t     intermittent_state;
392 	/*
393 	 * Estimated period for which intermittent state is expected to last.
394 	 * 1 tick -> 1 ms UNDEF => UINT16_MAX
395 	 */
396 	uint16_t    estimated_intermittent_period;
397 	/*
398 	 * Expected wifi outage period during intermittent state
399 	 * 1 tick -> 1 ms UNDEF => UINT16_MAX
400 	 */
401 	uint16_t    single_outage_period;
402 	/*
403 	 * WiFi-BT coexistence, 1-ON, 0-OFF
404 	 */
405 	uint8_t     bt_coex;
406 	/*
407 	 * on scale of 1 to 5
408 	 */
409 	uint8_t     quality_score_delay;
410 	/*
411 	 * on scale of 1 to 5
412 	 */
413 	uint8_t     quality_score_loss;
414 	/*
415 	 * on scale of 1 to 5
416 	 */
417 	uint8_t     quality_score_channel;
418 	/*
419 	 * bitmap of all radio contenders.
420 	 */
421 #define IF_INTERFACE_ADVISORY_WIFI_RADIO_COEX_BT    0x01
422 #define IF_INTERFACE_ADVISORY_WIFI_RADIO_COEX_AWDL  0x02
423 	uint8_t     radio_coex;
424 	/*
425 	 * time available to WiFi since last notification (in ms).
426 	 */
427 	uint16_t    wlan_duty_cycle;
428 	/*
429 	 * bitrate information for each queue (in Kbps).
430 	 */
431 #define IF_INTERFACE_ADVISORY_WIFI_TX_QUEUE_COUNT  6
432 	uint32_t    wifi_observed_tx_bitrate[IF_INTERFACE_ADVISORY_WIFI_TX_QUEUE_COUNT];
433 };
434 
435 /*
436  * This structure is used to define the parameters for advisory notifications
437  * that are specific for Cellular interface.
438  */
439 struct ifnet_interface_advisory_cell_context {
440 	/*
441 	 * Radio Access Technology
442 	 */
443 	uint8_t     radio_access_technology;
444 	/*
445 	 * Received Reference Signal Received level (RSRP dBm)
446 	 */
447 	int16_t     reference_signal_level;
448 	/*
449 	 * Received Signal strength level (RSSI dBm)
450 	 */
451 	int16_t     signal_level;
452 	/*
453 	 * Received signal quality (SNR dB).
454 	 */
455 	int8_t      signal_quality;
456 	/*
457 	 * Uplink Block Error Rate %
458 	 */
459 	uint8_t     uplink_bler;
460 	/*
461 	 * Downlink Block Error Rate %
462 	 */
463 	uint8_t     downlink_bler;
464 	/*
465 	 * Bandwidth Limitation Type. I.e. TTI-B.
466 	 */
467 	uint8_t     bandwidth_limitation_indication;
468 	/*
469 	 * Discontinuous reception state: CDRX on/off.
470 	 */
471 	uint8_t     cdrx_state;
472 	/*
473 	 * Discontinuous reception cycle in ms.
474 	 */
475 	uint16_t    cdrx_cycle;
476 	/*
477 	 * Approximate outage period when not known
478 	 */
479 	uint16_t    estimated_outage_period;
480 	/*
481 	 * Cellular outage state: i.e. handover in progress.
482 	 *     0 - no outage
483 	 *     1 - outage.
484 	 */
485 #define IF_INTERFACE_ADVISORY_CELL_OUTAGE_STATE_NO     0
486 #define IF_INTERFACE_ADVISORY_CELL_OUTAGE_STATE_YES    1
487 	uint8_t     outage_state;
488 	/*
489 	 * padding for alignment.
490 	 */
491 	uint8_t     __pad;
492 };
493 
494 struct ifnet_interface_advisory {
495 	union {
496 		struct { /* version 1 structure (to be deprecated) */
497 			/* The current structure version */
498 			uint8_t     version;
499 			/*  Specifies if the advisory is for transmit or receive path */
500 			uint8_t     direction;
501 			/* reserved for future use */
502 			uint16_t    _reserved;
503 			/*
504 			 * suggestion for data rate change to keep the latency low.
505 			 * unit: bits per second (bps)
506 			 * NOTE: if the interface cannot provide suggestions in terms of bps,
507 			 * it should use the following values:
508 			 * INT32_MAX : ramp up
509 			 * INT32_MIN : ramp down
510 			 * 0         : neutral
511 			 */
512 			int32_t     rate_trend_suggestion;
513 			/*
514 			 * Time of the issue of advisory.
515 			 * Timestamp should be in the host domain.
516 			 * unit: mach absolute time
517 			 */
518 			uint64_t    timestamp;
519 			/*
520 			 * Maximum theoretical bandwidth of the interface.
521 			 * unit: bits per second (bps)
522 			 */
523 			uint64_t    max_bandwidth;
524 			/*
525 			 * Total bytes sent or received on the interface.
526 			 * wrap around possible and the application should account for that.
527 			 * unit: byte
528 			 */
529 			uint64_t    total_byte_count;
530 			/*
531 			 * average throughput observed at the driver stack.
532 			 * unit: bits per second (bps)
533 			 */
534 			uint64_t    average_throughput;
535 			/*
536 			 * flushable queue size at the driver.
537 			 * should be set to UINT32_MAX if not available.
538 			 * unit: byte
539 			 */
540 			uint32_t    flushable_queue_size;
541 			/*
542 			 * non flushable queue size at the driver.
543 			 * should be set to UINT32_MAX if not available.
544 			 * unit: byte
545 			 */
546 			uint32_t    non_flushable_queue_size;
547 			/*
548 			 * average delay observed at the interface.
549 			 * unit: milliseconds (ms)
550 			 */
551 			uint32_t    average_delay;
552 			/*
553 			 * Current frequency band (enumeration).
554 			 */
555 			uint8_t    frequency_band;
556 			/*
557 			 * Intermittent WiFi state [true(1)/false(0)]
558 			 */
559 			uint8_t     intermittent_state;
560 			/*
561 			 * Estimated period for which intermittent state is expected to last.
562 			 * 1 tick -> 1 ms UNDEF => UINT16_MAX
563 			 */
564 			uint16_t    estimated_intermittent_period;
565 			/*
566 			 * Expected wifi outage period during intermittent state
567 			 * 1 tick -> 1 ms UNDEF => UINT16_MAX
568 			 */
569 			uint16_t    single_outage_period;
570 
571 			/*
572 			 * WiFi-BT coexistence, 1-ON, 0-OFF
573 			 */
574 			uint8_t     bt_coex;
575 			/*
576 			 * on scale of 1 to 5
577 			 */
578 			uint8_t     quality_score_delay;
579 			/*
580 			 * on scale of 1 to 5
581 			 */
582 			uint8_t     quality_score_loss;
583 			/*
584 			 * on scale of 1 to 5
585 			 */
586 			uint8_t     quality_score_channel;
587 		};
588 
589 		struct { /* version 2 structure */
590 			struct ifnet_interface_advisory_header    header;
591 			struct ifnet_interface_advisory_capacity  capacity;
592 			union {
593 				struct ifnet_interface_advisory_wifi_context    wifi_context;
594 				struct ifnet_interface_advisory_cell_context    cell_context;
595 			};
596 		};
597 	};
598 } __attribute__((aligned(sizeof(uint64_t))));
599 #pragma pack(pop)
600 
601 /*
602  * Definitions related to traffic steering
603  */
604 #pragma pack(push, 1)
605 
606 /* Supported types */
607 #define IFNET_TRAFFIC_DESCRIPTOR_TYPE_ETH  1
608 #define IFNET_TRAFFIC_DESCRIPTOR_TYPE_INET 2
609 
610 /* Supported flags */
611 #define IFNET_TRAFFIC_DESCRIPTOR_FLAG_INBOUND  0x0001
612 #define IFNET_TRAFFIC_DESCRIPTOR_FLAG_OUTBOUND 0x0002
613 
614 struct ifnet_traffic_descriptor_common {
615 	uint8_t     itd_type;
616 	uint8_t     _reserved;
617 	uint16_t    itd_len; /* length of entire struct (common + td-specific) */
618 	uint32_t    itd_flags;
619 };
620 
621 #define IFNET_TRAFFIC_DESCRIPTOR_ETH_MASK_ETHER_TYPE  0x01
622 #define IFNET_TRAFFIC_DESCRIPTOR_ETH_MASK_RADDR 0x02
623 
624 struct ifnet_traffic_descriptor_eth {
625 	struct ifnet_traffic_descriptor_common eth_common;
626 	ether_addr_t    eth_raddr;
627 	uint16_t        eth_type;
628 	uint8_t         eth_mask;
629 };
630 
631 #define IFNET_TRAFFIC_DESCRIPTOR_INET_IPVER 0x01
632 #define IFNET_TRAFFIC_DESCRIPTOR_INET_PROTO 0x02
633 #define IFNET_TRAFFIC_DESCRIPTOR_INET_LADDR 0x04
634 #define IFNET_TRAFFIC_DESCRIPTOR_INET_RADDR 0x08
635 #define IFNET_TRAFFIC_DESCRIPTOR_INET_LPORT 0x10
636 #define IFNET_TRAFFIC_DESCRIPTOR_INET_RPORT 0x20
637 
638 struct ifnet_ip_addr {
639 	union {
640 		uint8_t  addr8[16];
641 		uint16_t addr16[8];
642 		uint32_t addr32[4];
643 	};
644 };
645 #define iia_v4addr addr32[3]
646 
647 struct ifnet_traffic_descriptor_inet {
648 	struct ifnet_traffic_descriptor_common inet_common;
649 	uint8_t     inet_mask;
650 	uint8_t     inet_ipver; /* IPVERSION or IPV6_VERSION */
651 	uint8_t     inet_proto; /* IPPROTO_TCP or IPPROTO_UDP */
652 	uint8_t     _reserved;
653 	struct ifnet_ip_addr inet_laddr;
654 	struct ifnet_ip_addr inet_raddr;
655 	uint16_t    inet_lport;
656 	uint16_t    inet_rport;
657 };
658 
659 #define IFNET_TRAFFIC_RULE_ACTION_STEER 1
660 struct ifnet_traffic_rule_action {
661 	uint8_t     ra_type;
662 	uint8_t     _reserved;
663 	uint16_t    ra_len;
664 };
665 
666 struct ifnet_traffic_rule_action_steer {
667 	struct ifnet_traffic_rule_action ras_common;
668 	uint64_t    ras_qset_id;
669 };
670 
671 #if KERNEL_PRIVATE
672 typedef enum {
673 	RX_FLOW_STEERING_ACTION_ADD_AOP = 1,
674 	RX_FLOW_STEERING_ACTION_REMOVE_AOP = 2,
675 } rx_flow_steering_action_t;
676 #endif /* KERNEL_PRIVATE */
677 
678 #pragma pack(pop)
679 
680 #pragma pack()
681 
682 #endif /* !_NET_IF_VAR_STATUS_H_ */
683