| 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 | |
| 70 | #pragma pack(4) |
| 71 | |
| 72 | /* |
| 73 | * Interface link status report -- includes statistics related to |
| 74 | * the link layer technology sent by the driver. The driver will monitor |
| 75 | * these statistics over an interval (3-4 secs) and will generate a report |
| 76 | * to the network stack. This will give first-hand information about the |
| 77 | * status of the first hop of the network path. The version and |
| 78 | * length values should be correct for the data to be processed correctly. |
| 79 | * The definitions are different for different kind of interfaces like |
| 80 | * Wifi, Cellular etc,. |
| 81 | */ |
| 82 | #define IF_CELLULAR_STATUS_REPORT_VERSION_1 1 |
| 83 | #define IF_WIFI_STATUS_REPORT_VERSION_1 1 |
| 84 | #define IF_CELLULAR_STATUS_REPORT_CURRENT_VERSION \ |
| 85 | IF_CELLULAR_STATUS_REPORT_VERSION_1 |
| 86 | #define IF_WIFI_STATUS_REPORT_CURRENT_VERSION IF_WIFI_STATUS_REPORT_VERSION_1 |
| 87 | /* |
| 88 | * For cellular interface -- |
| 89 | * There is no way to share common headers between the Baseband and |
| 90 | * the kernel. Any changes to this structure will need to be communicated |
| 91 | * to the Baseband team. It is better to use reserved space instead of |
| 92 | * changing the size or existing fields in the structure. |
| 93 | */ |
| 94 | struct if_cellular_status_v1 { |
| 95 | u_int32_t valid_bitmask; /* indicates which fields are valid */ |
| 96 | #define IF_CELL_LINK_QUALITY_METRIC_VALID 0x1 |
| 97 | #define IF_CELL_UL_EFFECTIVE_BANDWIDTH_VALID 0x2 |
| 98 | #define IF_CELL_UL_MAX_BANDWIDTH_VALID 0x4 |
| 99 | #define IF_CELL_UL_MIN_LATENCY_VALID 0x8 |
| 100 | #define IF_CELL_UL_EFFECTIVE_LATENCY_VALID 0x10 |
| 101 | #define IF_CELL_UL_MAX_LATENCY_VALID 0x20 |
| 102 | #define IF_CELL_UL_RETXT_LEVEL_VALID 0x40 |
| 103 | #define IF_CELL_UL_BYTES_LOST_VALID 0x80 |
| 104 | #define IF_CELL_UL_MIN_QUEUE_SIZE_VALID 0x100 |
| 105 | #define IF_CELL_UL_AVG_QUEUE_SIZE_VALID 0x200 |
| 106 | #define IF_CELL_UL_MAX_QUEUE_SIZE_VALID 0x400 |
| 107 | #define IF_CELL_DL_EFFECTIVE_BANDWIDTH_VALID 0x800 |
| 108 | #define IF_CELL_DL_MAX_BANDWIDTH_VALID 0x1000 |
| 109 | #define IF_CELL_CONFIG_INACTIVITY_TIME_VALID 0x2000 |
| 110 | #define IF_CELL_CONFIG_BACKOFF_TIME_VALID 0x4000 |
| 111 | #define IF_CELL_UL_MSS_RECOMMENDED_VALID 0x8000 |
| 112 | |
| 113 | u_int32_t link_quality_metric; |
| 114 | u_int32_t ul_effective_bandwidth; /* Measured uplink bandwidth based on current activity (bps) */ |
| 115 | u_int32_t ul_max_bandwidth; /* Maximum supported uplink bandwidth (bps) */ |
| 116 | u_int32_t ul_min_latency; /* min expected uplink latency for first hop (ms) */ |
| 117 | u_int32_t ul_effective_latency; /* current expected uplink latency for first hop (ms) */ |
| 118 | u_int32_t ul_max_latency; /* max expected uplink latency first hop (ms) */ |
| 119 | u_int32_t ul_retxt_level; /* Retransmission metric */ |
| 120 | #define IF_CELL_UL_RETXT_LEVEL_NONE 1 |
| 121 | #define IF_CELL_UL_RETXT_LEVEL_LOW 2 |
| 122 | #define IF_CELL_UL_RETXT_LEVEL_MEDIUM 3 |
| 123 | #define IF_CELL_UL_RETXT_LEVEL_HIGH 4 |
| 124 | u_int32_t ul_bytes_lost; /* % of total bytes lost on uplink in Q10 format */ |
| 125 | u_int32_t ul_min_queue_size; /* minimum bytes in queue */ |
| 126 | u_int32_t ul_avg_queue_size; /* average bytes in queue */ |
| 127 | u_int32_t ul_max_queue_size; /* maximum bytes in queue */ |
| 128 | u_int32_t dl_effective_bandwidth; /* Measured downlink bandwidth based on current activity (bps) */ |
| 129 | u_int32_t dl_max_bandwidth; /* Maximum supported downlink bandwidth (bps) */ |
| 130 | u_int32_t config_inactivity_time; /* ms */ |
| 131 | u_int32_t config_backoff_time; /* new connections backoff time in ms */ |
| 132 | #define IF_CELL_UL_MSS_RECOMMENDED_NONE 0x0 /* Use default */ |
| 133 | #define IF_CELL_UL_MSS_RECOMMENDED_MEDIUM 0x1 /* 1200 byte MSS */ |
| 134 | #define IF_CELL_UL_MSS_RECOMMENDED_LOW 0x2 /* 512 byte MSS */ |
| 135 | u_int16_t mss_recommended; |
| 136 | u_int16_t reserved_1; |
| 137 | u_int32_t reserved_2; |
| 138 | u_int64_t reserved_3; |
| 139 | u_int64_t reserved_4; |
| 140 | u_int64_t reserved_5; |
| 141 | u_int64_t reserved_6; |
| 142 | } __attribute__((packed)); |
| 143 | |
| 144 | struct if_cellular_status { |
| 145 | union { |
| 146 | struct if_cellular_status_v1 if_status_v1; |
| 147 | } if_cell_u; |
| 148 | }; |
| 149 | |
| 150 | /* |
| 151 | * These statistics will be provided by the Wifi driver periodically. |
| 152 | * After sending each report, the driver should start computing again |
| 153 | * for the next report duration so that the values represent the link |
| 154 | * status for one report duration. |
| 155 | */ |
| 156 | |
| 157 | struct if_wifi_status_v1 { |
| 158 | u_int32_t valid_bitmask; |
| 159 | #define IF_WIFI_LINK_QUALITY_METRIC_VALID 0x1 |
| 160 | #define IF_WIFI_UL_EFFECTIVE_BANDWIDTH_VALID 0x2 |
| 161 | #define IF_WIFI_UL_MAX_BANDWIDTH_VALID 0x4 |
| 162 | #define IF_WIFI_UL_MIN_LATENCY_VALID 0x8 |
| 163 | #define IF_WIFI_UL_EFFECTIVE_LATENCY_VALID 0x10 |
| 164 | #define IF_WIFI_UL_MAX_LATENCY_VALID 0x20 |
| 165 | #define IF_WIFI_UL_RETXT_LEVEL_VALID 0x40 |
| 166 | #define IF_WIFI_UL_ERROR_RATE_VALID 0x80 |
| 167 | #define IF_WIFI_UL_BYTES_LOST_VALID 0x100 |
| 168 | #define IF_WIFI_DL_EFFECTIVE_BANDWIDTH_VALID 0x200 |
| 169 | #define IF_WIFI_DL_MAX_BANDWIDTH_VALID 0x400 |
| 170 | #define IF_WIFI_DL_MIN_LATENCY_VALID 0x800 |
| 171 | #define IF_WIFI_DL_EFFECTIVE_LATENCY_VALID 0x1000 |
| 172 | #define IF_WIFI_DL_MAX_LATENCY_VALID 0x2000 |
| 173 | #define IF_WIFI_DL_ERROR_RATE_VALID 0x4000 |
| 174 | #define IF_WIFI_CONFIG_FREQUENCY_VALID 0x8000 |
| 175 | #define IF_WIFI_CONFIG_MULTICAST_RATE_VALID 0x10000 |
| 176 | #define IF_WIFI_CONFIG_SCAN_COUNT_VALID 0x20000 |
| 177 | #define IF_WIFI_CONFIG_SCAN_DURATION_VALID 0x40000 |
| 178 | u_int32_t link_quality_metric; /* link quality metric */ |
| 179 | u_int32_t ul_effective_bandwidth; /* Measured uplink bandwidth based on current activity (bps) */ |
| 180 | u_int32_t ul_max_bandwidth; /* Maximum supported uplink bandwidth (bps) */ |
| 181 | u_int32_t ul_min_latency; /* min expected uplink latency for first hop (ms) */ |
| 182 | u_int32_t ul_effective_latency; /* current expected uplink latency for first hop (ms) */ |
| 183 | u_int32_t ul_max_latency; /* max expected uplink latency for first hop (ms) */ |
| 184 | u_int32_t ul_retxt_level; /* Retransmission metric */ |
| 185 | #define IF_WIFI_UL_RETXT_LEVEL_NONE 1 |
| 186 | #define IF_WIFI_UL_RETXT_LEVEL_LOW 2 |
| 187 | #define IF_WIFI_UL_RETXT_LEVEL_MEDIUM 3 |
| 188 | #define IF_WIFI_UL_RETXT_LEVEL_HIGH 4 |
| 189 | u_int32_t ul_bytes_lost; /* % of total bytes lost on uplink in Q10 format */ |
| 190 | u_int32_t ul_error_rate; /* % of bytes dropped on uplink after many retransmissions in Q10 format */ |
| 191 | u_int32_t dl_effective_bandwidth; /* Measured downlink bandwidth based on current activity (bps) */ |
| 192 | u_int32_t dl_max_bandwidth; /* Maximum supported downlink bandwidth (bps) */ |
| 193 | /* |
| 194 | * The download latency values indicate the time AP may have to wait for the |
| 195 | * driver to receive the packet. These values give the range of expected latency |
| 196 | * mainly due to co-existence events and channel hopping where the interface |
| 197 | * becomes unavailable. |
| 198 | */ |
| 199 | u_int32_t dl_min_latency; /* min expected latency for first hop in ms */ |
| 200 | u_int32_t dl_effective_latency; /* current expected latency for first hop in ms */ |
| 201 | u_int32_t dl_max_latency; /* max expected latency for first hop in ms */ |
| 202 | u_int32_t dl_error_rate; /* % of CRC or other errors in Q10 format */ |
| 203 | u_int32_t config_frequency; /* 2.4 or 5 GHz */ |
| 204 | #define IF_WIFI_CONFIG_FREQUENCY_2_4_GHZ 1 |
| 205 | #define IF_WIFI_CONFIG_FREQUENCY_5_0_GHZ 2 |
| 206 | u_int32_t config_multicast_rate; /* bps */ |
| 207 | u_int32_t scan_count; /* scan count during the previous period */ |
| 208 | u_int32_t scan_duration; /* scan duration in ms */ |
| 209 | u_int64_t reserved_1; |
| 210 | u_int64_t reserved_2; |
| 211 | u_int64_t reserved_3; |
| 212 | u_int64_t reserved_4; |
| 213 | } __attribute__((packed)); |
| 214 | |
| 215 | struct if_wifi_status { |
| 216 | union { |
| 217 | struct if_wifi_status_v1 if_status_v1; |
| 218 | } if_wifi_u; |
| 219 | }; |
| 220 | |
| 221 | struct if_link_status { |
| 222 | u_int32_t ifsr_version; /* version of this report */ |
| 223 | u_int32_t ifsr_len; /* length of the following struct */ |
| 224 | union { |
| 225 | struct if_cellular_status ifsr_cell; |
| 226 | struct if_wifi_status ifsr_wifi; |
| 227 | } ifsr_u; |
| 228 | }; |
| 229 | |
| 230 | /* |
| 231 | * This structure is used to define the parameters for advisory notifications |
| 232 | * on an interface. |
| 233 | */ |
| 234 | #pragma pack(push, 1) |
| 235 | enum ifnet_interface_advisory_version : uint8_t { |
| 236 | /* |
| 237 | * Initial version with interface advisory report for WiFi interface. |
| 238 | */ |
| 239 | IF_INTERFACE_ADVISORY_VERSION_1 = 1, |
| 240 | #if XNU_KERNEL_PRIVATE |
| 241 | IF_INTERFACE_ADVISORY_VERSION_MIN = IF_INTERFACE_ADVISORY_VERSION_1, |
| 242 | #endif /* XNU_KERNEL_PRIVATE */ |
| 243 | /* |
| 244 | * Reorganized the interface advisory structure to separate out |
| 245 | * WiFi and Cellular interface specific reports. |
| 246 | */ |
| 247 | IF_INTERFACE_ADVISORY_VERSION_2 = 2, |
| 248 | IF_INTERFACE_ADVISORY_VERSION_CURRENT = IF_INTERFACE_ADVISORY_VERSION_2, |
| 249 | #if XNU_KERNEL_PRIVATE |
| 250 | IF_INTERFACE_ADVISORY_VERSION_MAX = IF_INTERFACE_ADVISORY_VERSION_2, |
| 251 | #endif /* XNU_KERNEL_PRIVATE */ |
| 252 | }; |
| 253 | |
| 254 | enum ifnet_interface_advisory_direction : uint8_t { |
| 255 | IF_INTERFACE_ADVISORY_DIRECTION_TX = 1, |
| 256 | IF_INTERFACE_ADVISORY_DIRECTION_RX = 2, |
| 257 | }; |
| 258 | |
| 259 | enum ifnet_interface_advisory_interface_type : uint8_t { |
| 260 | IF_INTERFACE_ADVISORY_INTERFACE_TYPE_WIFI = 1, |
| 261 | #if XNU_KERNEL_PRIVATE |
| 262 | IF_INTERFACE_ADVISORY_INTERFACE_TYPE_MIN = |
| 263 | IF_INTERFACE_ADVISORY_INTERFACE_TYPE_WIFI, |
| 264 | #endif /* XNU_KERNEL_PRIVATE */ |
| 265 | IF_INTERFACE_ADVISORY_INTERFACE_TYPE_CELL = 2, |
| 266 | #if XNU_KERNEL_PRIVATE |
| 267 | IF_INTERFACE_ADVISORY_INTERFACE_TYPE_MAX = |
| 268 | IF_INTERFACE_ADVISORY_INTERFACE_TYPE_CELL, |
| 269 | #endif /* XNU_KERNEL_PRIVATE */ |
| 270 | }; |
| 271 | |
| 272 | struct { |
| 273 | /* The current structure version */ |
| 274 | enum ifnet_interface_advisory_version ; |
| 275 | /* Specifies if the advisory is for transmit or receive path */ |
| 276 | enum ifnet_interface_advisory_direction ; |
| 277 | /* Interface type */ |
| 278 | enum ifnet_interface_advisory_interface_type ; |
| 279 | /* reserved for future use */ |
| 280 | uint8_t ; |
| 281 | }; |
| 282 | |
| 283 | enum ifnet_interface_advisory_rate_trend : int32_t { |
| 284 | IF_INTERFACE_ADVISORY_RATE_SUGGESTION_RAMP_UP = INT32_MAX, |
| 285 | IF_INTERFACE_ADVISORY_RATE_SUGGESTION_RAMP_DOWN = INT32_MIN, |
| 286 | IF_INTERFACE_ADVISORY_RATE_SUGGESTION_RAMP_NEUTRAL = 0, |
| 287 | }; |
| 288 | |
| 289 | struct ifnet_interface_advisory_capacity { |
| 290 | /* |
| 291 | * suggestion for data rate change to keep the latency low. |
| 292 | * unit: bits per second (bps) |
| 293 | * NOTE: if the interface cannot provide suggestions in |
| 294 | * terms of bps, it should use the following values: |
| 295 | * INT32_MAX : ramp up |
| 296 | * INT32_MIN : ramp down |
| 297 | * 0 : neutral |
| 298 | */ |
| 299 | enum ifnet_interface_advisory_rate_trend rate_trend_suggestion; |
| 300 | /* |
| 301 | * Time of the issue of advisory. |
| 302 | * Timestamp should be in the host domain. |
| 303 | * unit: mach absolute time |
| 304 | */ |
| 305 | uint64_t timestamp; |
| 306 | /* |
| 307 | * Maximum theoretical bandwidth of the interface. |
| 308 | * unit: bits per second (bps) |
| 309 | */ |
| 310 | uint64_t max_bandwidth; |
| 311 | /* |
| 312 | * Total bytes sent or received on the interface. |
| 313 | * wrap around possible and the application should account for that. |
| 314 | * unit: byte |
| 315 | */ |
| 316 | uint64_t total_byte_count; |
| 317 | /* |
| 318 | * average throughput observed at the driver stack. |
| 319 | * unit: bits per second (bps) |
| 320 | */ |
| 321 | uint64_t average_throughput; |
| 322 | /* |
| 323 | * flushable queue size at the driver. |
| 324 | * should be set to UINT32_MAX if not available. |
| 325 | * unit: byte |
| 326 | */ |
| 327 | uint32_t flushable_queue_size; |
| 328 | /* |
| 329 | * non flushable queue size at the driver. |
| 330 | * should be set to UINT32_MAX if not available. |
| 331 | * unit: byte |
| 332 | */ |
| 333 | uint32_t non_flushable_queue_size; |
| 334 | /* |
| 335 | * average delay observed at the interface. |
| 336 | * unit: milliseconds (ms) |
| 337 | */ |
| 338 | uint32_t average_delay; |
| 339 | }; |
| 340 | |
| 341 | enum ifnet_interface_advisory_wifi_freq_band : uint8_t { |
| 342 | IF_INTERFACE_ADVISORY_FREQ_BAND_NOT_AVAIL = 0, |
| 343 | IF_INTERFACE_ADVISORY_FREQ_BAND_WIFI_24GHZ = 1, |
| 344 | IF_INTERFACE_ADVISORY_FREQ_BAND_WIFI_5GHZ = 2, |
| 345 | IF_INTERFACE_ADVISORY_FREQ_BAND_WIFI_6GHZ = 3, |
| 346 | }; |
| 347 | |
| 348 | /* |
| 349 | * This structure is used to define the parameters for advisory notifications |
| 350 | * that are specific for WiFi interface. |
| 351 | */ |
| 352 | struct ifnet_interface_advisory_wifi_context { |
| 353 | /* |
| 354 | * Current frequency band (enumeration). |
| 355 | */ |
| 356 | enum ifnet_interface_advisory_wifi_freq_band frequency_band; |
| 357 | /* |
| 358 | * Intermittent WiFi state [true(1)/false(0)] |
| 359 | */ |
| 360 | uint8_t intermittent_state; |
| 361 | /* |
| 362 | * Estimated period for which intermittent state is expected to last. |
| 363 | * 1 tick -> 1 ms UNDEF => UINT16_MAX |
| 364 | */ |
| 365 | uint16_t estimated_intermittent_period; |
| 366 | /* |
| 367 | * Expected wifi outage period during intermittent state |
| 368 | * 1 tick -> 1 ms UNDEF => UINT16_MAX |
| 369 | */ |
| 370 | uint16_t single_outage_period; |
| 371 | /* |
| 372 | * WiFi-BT coexistence, 1-ON, 0-OFF |
| 373 | */ |
| 374 | uint8_t bt_coex; |
| 375 | /* |
| 376 | * on scale of 1 to 5 |
| 377 | */ |
| 378 | uint8_t quality_score_delay; |
| 379 | /* |
| 380 | * on scale of 1 to 5 |
| 381 | */ |
| 382 | uint8_t quality_score_loss; |
| 383 | /* |
| 384 | * on scale of 1 to 5 |
| 385 | */ |
| 386 | uint8_t quality_score_channel; |
| 387 | /* |
| 388 | * bitmap of all radio contenders. |
| 389 | */ |
| 390 | #define IF_INTERFACE_ADVISORY_WIFI_RADIO_COEX_BT 0x01 |
| 391 | #define IF_INTERFACE_ADVISORY_WIFI_RADIO_COEX_AWDL 0x02 |
| 392 | uint8_t radio_coex; |
| 393 | /* |
| 394 | * time available to WiFi since last notification (in ms). |
| 395 | */ |
| 396 | uint16_t wlan_duty_cycle; |
| 397 | /* |
| 398 | * bitrate information for each queue (in Kbps). |
| 399 | */ |
| 400 | #define IF_INTERFACE_ADVISORY_WIFI_TX_QUEUE_COUNT 6 |
| 401 | uint32_t wifi_observed_tx_bitrate[IF_INTERFACE_ADVISORY_WIFI_TX_QUEUE_COUNT]; |
| 402 | }; |
| 403 | |
| 404 | /* |
| 405 | * This structure is used to define the parameters for advisory notifications |
| 406 | * that are specific for Cellular interface. |
| 407 | */ |
| 408 | struct ifnet_interface_advisory_cell_context { |
| 409 | /* |
| 410 | * Radio Access Technology |
| 411 | */ |
| 412 | uint8_t radio_access_technology; |
| 413 | /* |
| 414 | * Received Reference Signal Received level (RSRP dBm) |
| 415 | */ |
| 416 | int16_t reference_signal_level; |
| 417 | /* |
| 418 | * Received Signal strength level (RSSI dBm) |
| 419 | */ |
| 420 | int16_t signal_level; |
| 421 | /* |
| 422 | * Received signal quality (SNR dB). |
| 423 | */ |
| 424 | int8_t signal_quality; |
| 425 | /* |
| 426 | * Uplink Block Error Rate % |
| 427 | */ |
| 428 | uint8_t uplink_bler; |
| 429 | /* |
| 430 | * Downlink Block Error Rate % |
| 431 | */ |
| 432 | uint8_t downlink_bler; |
| 433 | /* |
| 434 | * Bandwidth Limitation Type. I.e. TTI-B. |
| 435 | */ |
| 436 | uint8_t bandwidth_limitation_indication; |
| 437 | /* |
| 438 | * Discontinuous reception state: CDRX on/off. |
| 439 | */ |
| 440 | uint8_t cdrx_state; |
| 441 | /* |
| 442 | * Discontinuous reception cycle in ms. |
| 443 | */ |
| 444 | uint16_t cdrx_cycle; |
| 445 | /* |
| 446 | * Approximate outage period when not known |
| 447 | */ |
| 448 | uint16_t estimated_outage_period; |
| 449 | /* |
| 450 | * Cellular outage state: i.e. handover in progress. |
| 451 | * 0 - no outage |
| 452 | * 1 - outage. |
| 453 | */ |
| 454 | #define IF_INTERFACE_ADVISORY_CELL_OUTAGE_STATE_NO 0 |
| 455 | #define IF_INTERFACE_ADVISORY_CELL_OUTAGE_STATE_YES 1 |
| 456 | uint8_t outage_state; |
| 457 | /* |
| 458 | * padding for alignment. |
| 459 | */ |
| 460 | uint8_t __pad; |
| 461 | }; |
| 462 | |
| 463 | struct ifnet_interface_advisory { |
| 464 | union { |
| 465 | struct { /* version 1 structure (to be deprecated) */ |
| 466 | /* The current structure version */ |
| 467 | uint8_t version; |
| 468 | /* Specifies if the advisory is for transmit or receive path */ |
| 469 | uint8_t direction; |
| 470 | /* reserved for future use */ |
| 471 | uint16_t _reserved; |
| 472 | /* |
| 473 | * suggestion for data rate change to keep the latency low. |
| 474 | * unit: bits per second (bps) |
| 475 | * NOTE: if the interface cannot provide suggestions in terms of bps, |
| 476 | * it should use the following values: |
| 477 | * INT32_MAX : ramp up |
| 478 | * INT32_MIN : ramp down |
| 479 | * 0 : neutral |
| 480 | */ |
| 481 | int32_t rate_trend_suggestion; |
| 482 | /* |
| 483 | * Time of the issue of advisory. |
| 484 | * Timestamp should be in the host domain. |
| 485 | * unit: mach absolute time |
| 486 | */ |
| 487 | uint64_t timestamp; |
| 488 | /* |
| 489 | * Maximum theoretical bandwidth of the interface. |
| 490 | * unit: bits per second (bps) |
| 491 | */ |
| 492 | uint64_t max_bandwidth; |
| 493 | /* |
| 494 | * Total bytes sent or received on the interface. |
| 495 | * wrap around possible and the application should account for that. |
| 496 | * unit: byte |
| 497 | */ |
| 498 | uint64_t total_byte_count; |
| 499 | /* |
| 500 | * average throughput observed at the driver stack. |
| 501 | * unit: bits per second (bps) |
| 502 | */ |
| 503 | uint64_t average_throughput; |
| 504 | /* |
| 505 | * flushable queue size at the driver. |
| 506 | * should be set to UINT32_MAX if not available. |
| 507 | * unit: byte |
| 508 | */ |
| 509 | uint32_t flushable_queue_size; |
| 510 | /* |
| 511 | * non flushable queue size at the driver. |
| 512 | * should be set to UINT32_MAX if not available. |
| 513 | * unit: byte |
| 514 | */ |
| 515 | uint32_t non_flushable_queue_size; |
| 516 | /* |
| 517 | * average delay observed at the interface. |
| 518 | * unit: milliseconds (ms) |
| 519 | */ |
| 520 | uint32_t average_delay; |
| 521 | /* |
| 522 | * Current frequency band (enumeration). |
| 523 | */ |
| 524 | uint8_t frequency_band; |
| 525 | /* |
| 526 | * Intermittent WiFi state [true(1)/false(0)] |
| 527 | */ |
| 528 | uint8_t intermittent_state; |
| 529 | /* |
| 530 | * Estimated period for which intermittent state is expected to last. |
| 531 | * 1 tick -> 1 ms UNDEF => UINT16_MAX |
| 532 | */ |
| 533 | uint16_t estimated_intermittent_period; |
| 534 | /* |
| 535 | * Expected wifi outage period during intermittent state |
| 536 | * 1 tick -> 1 ms UNDEF => UINT16_MAX |
| 537 | */ |
| 538 | uint16_t single_outage_period; |
| 539 | |
| 540 | /* |
| 541 | * WiFi-BT coexistence, 1-ON, 0-OFF |
| 542 | */ |
| 543 | uint8_t bt_coex; |
| 544 | /* |
| 545 | * on scale of 1 to 5 |
| 546 | */ |
| 547 | uint8_t quality_score_delay; |
| 548 | /* |
| 549 | * on scale of 1 to 5 |
| 550 | */ |
| 551 | uint8_t quality_score_loss; |
| 552 | /* |
| 553 | * on scale of 1 to 5 |
| 554 | */ |
| 555 | uint8_t quality_score_channel; |
| 556 | }; |
| 557 | |
| 558 | struct { /* version 2 structure */ |
| 559 | struct ifnet_interface_advisory_header ; |
| 560 | struct ifnet_interface_advisory_capacity capacity; |
| 561 | union { |
| 562 | struct ifnet_interface_advisory_wifi_context wifi_context; |
| 563 | struct ifnet_interface_advisory_cell_context cell_context; |
| 564 | }; |
| 565 | }; |
| 566 | }; |
| 567 | } __attribute__((aligned(sizeof(uint64_t)))); |
| 568 | #pragma pack(pop) |
| 569 | |
| 570 | /* |
| 571 | * Definitions related to traffic steering |
| 572 | */ |
| 573 | #pragma pack(push, 1) |
| 574 | |
| 575 | /* Supported types */ |
| 576 | /* Reserving 1 for link layer */ |
| 577 | #define IFNET_TRAFFIC_DESCRIPTOR_TYPE_INET 2 |
| 578 | |
| 579 | /* Supported flags */ |
| 580 | #define IFNET_TRAFFIC_DESCRIPTOR_FLAG_INBOUND 0x0001 |
| 581 | #define IFNET_TRAFFIC_DESCRIPTOR_FLAG_OUTBOUND 0x0002 |
| 582 | |
| 583 | struct ifnet_traffic_descriptor_common { |
| 584 | uint8_t itd_type; |
| 585 | uint8_t _reserved; |
| 586 | uint16_t itd_len; /* length of entire struct (common + td-specific) */ |
| 587 | uint32_t itd_flags; |
| 588 | }; |
| 589 | |
| 590 | #define IFNET_TRAFFIC_DESCRIPTOR_INET_IPVER 0x01 |
| 591 | #define IFNET_TRAFFIC_DESCRIPTOR_INET_PROTO 0x02 |
| 592 | #define IFNET_TRAFFIC_DESCRIPTOR_INET_LADDR 0x04 |
| 593 | #define IFNET_TRAFFIC_DESCRIPTOR_INET_RADDR 0x08 |
| 594 | #define IFNET_TRAFFIC_DESCRIPTOR_INET_LPORT 0x10 |
| 595 | #define IFNET_TRAFFIC_DESCRIPTOR_INET_RPORT 0x20 |
| 596 | |
| 597 | struct ifnet_ip_addr { |
| 598 | union { |
| 599 | uint8_t addr8[16]; |
| 600 | uint16_t addr16[8]; |
| 601 | uint32_t addr32[4]; |
| 602 | }; |
| 603 | }; |
| 604 | #define iia_v4addr addr32[3] |
| 605 | |
| 606 | struct ifnet_traffic_descriptor_inet { |
| 607 | struct ifnet_traffic_descriptor_common inet_common; |
| 608 | uint8_t inet_mask; |
| 609 | uint8_t inet_ipver; /* IPVERSION or IPV6_VERSION */ |
| 610 | uint8_t inet_proto; /* IPPROTO_TCP or IPPROTO_UDP */ |
| 611 | uint8_t _reserved; |
| 612 | struct ifnet_ip_addr inet_laddr; |
| 613 | struct ifnet_ip_addr inet_raddr; |
| 614 | uint16_t inet_lport; |
| 615 | uint16_t inet_rport; |
| 616 | }; |
| 617 | |
| 618 | #define IFNET_TRAFFIC_RULE_ACTION_STEER 1 |
| 619 | struct ifnet_traffic_rule_action { |
| 620 | uint8_t ra_type; |
| 621 | uint8_t _reserved; |
| 622 | uint16_t ra_len; |
| 623 | }; |
| 624 | |
| 625 | struct ifnet_traffic_rule_action_steer { |
| 626 | struct ifnet_traffic_rule_action ras_common; |
| 627 | uint64_t ras_qset_id; |
| 628 | }; |
| 629 | #pragma pack(pop) |
| 630 | |
| 631 | #pragma pack() |
| 632 | |
| 633 | #endif /* !_NET_IF_VAR_STATUS_H_ */ |
| 634 | |