1 /*- 2 * SPDX-License-Identifier: BSD-3-Clause 3 * 4 * Original copyright (c) 2016 genua mbH (OpenBSD version) 5 * 6 * Permission to use, copy, modify, and distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 * 18 * Copyright (c) 2022 ADISTA SAS (re-write for FreeBSD) 19 * 20 * Re-write for FreeBSD by Pierre Pronchery <pierre@defora.net> 21 * 22 * Redistribution and use in source and binary forms, with or without 23 * modification, are permitted provided that the following conditions are met: 24 * 25 * - Redistributions of source code must retain the above copyright notice, 26 * this list of conditions and the following disclaimer. 27 * - Redistributions in binary form must reproduce the above copyright notice, 28 * this list of conditions and the following disclaimer in the documentation 29 * and/or other materials provided with the distribution. 30 * - Neither the name of the copyright holder nor the names of its contributors 31 * may be used to endorse or promote products derived from this software 32 * without specific prior written permission. 33 * 34 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 35 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 36 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 37 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 38 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 39 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 40 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 41 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 42 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 43 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 44 * POSSIBILITY OF SUCH DAMAGE. 45 * 46 * $OpenBSD: mbim.h,v 1.4 2017/04/18 13:27:55 gerhard Exp $ 47 */ 48 49 /* 50 * Mobile Broadband Interface Model 51 * http://www.usb.org/developers/docs/devclass_docs/MBIM-Compliance-1.0.pdf 52 */ 53 54 #ifndef _MBIM_H_ 55 #define _MBIM_H_ 56 57 #define UDESCSUB_MBIM 27 58 #define MBIM_INTERFACE_ALTSETTING 1 59 60 #define MBIM_RESET_FUNCTION 0x05 61 62 /* 63 * Registration state (MBIM_REGISTER_STATE) 64 */ 65 #define MBIM_REGSTATE_UNKNOWN 0 66 #define MBIM_REGSTATE_DEREGISTERED 1 67 #define MBIM_REGSTATE_SEARCHING 2 68 #define MBIM_REGSTATE_HOME 3 69 #define MBIM_REGSTATE_ROAMING 4 70 #define MBIM_REGSTATE_PARTNER 5 71 #define MBIM_REGSTATE_DENIED 6 72 73 /* 74 * Data classes mask (MBIM_DATA_CLASS) 75 */ 76 #define MBIM_DATACLASS_NONE 0x00000000 77 #define MBIM_DATACLASS_GPRS 0x00000001 78 #define MBIM_DATACLASS_EDGE 0x00000002 79 #define MBIM_DATACLASS_UMTS 0x00000004 80 #define MBIM_DATACLASS_HSDPA 0x00000008 81 #define MBIM_DATACLASS_HSUPA 0x00000010 82 #define MBIM_DATACLASS_LTE 0x00000020 83 #define MBIM_DATACLASS_1XRTT 0x00010000 84 #define MBIM_DATACLASS_1XEVDO 0x00020000 85 #define MBIM_DATACLASS_1XEVDO_REV_A 0x00040000 86 #define MBIM_DATACLASS_1XEVDV 0x00080000 87 #define MBIM_DATACLASS_3XRTT 0x00100000 88 #define MBIM_DATACLASS_1XEVDO_REV_B 0x00200000 89 #define MBIM_DATACLASS_UMB 0x00400000 90 #define MBIM_DATACLASS_CUSTOM 0x80000000 91 92 /* 93 * Cell classes mask (MBIM_CELLULAR_CLASS) 94 */ 95 #define MBIM_CELLCLASS_GSM 0x00000001 96 #define MBIM_CELLCLASS_CDMA 0x00000002 97 98 /* 99 * UUIDs 100 */ 101 #define MBIM_UUID_LEN 16 102 103 #define MBIM_UUID_BASIC_CONNECT { \ 104 0xa2, 0x89, 0xcc, 0x33, 0xbc, 0xbb, 0x8b, 0x4f, \ 105 0xb6, 0xb0, 0x13, 0x3e, 0xc2, 0xaa, 0xe6, 0xdf \ 106 } 107 108 #define MBIM_UUID_CONTEXT_INTERNET { \ 109 0x7e, 0x5e, 0x2a, 0x7e, 0x4e, 0x6f, 0x72, 0x72, \ 110 0x73, 0x6b, 0x65, 0x6e, 0x7e, 0x5e, 0x2a, 0x7e \ 111 } 112 113 #define MBIM_UUID_CONTEXT_VPN { \ 114 0x9b, 0x9f, 0x7b, 0xbe, 0x89, 0x52, 0x44, 0xb7, \ 115 0x83, 0xac, 0xca, 0x41, 0x31, 0x8d, 0xf7, 0xa0 \ 116 } 117 118 #define MBIM_UUID_QMI_MBIM { \ 119 0xd1, 0xa3, 0x0b, 0xc2, 0xf9, 0x7a, 0x6e, 0x43, \ 120 0xbf, 0x65, 0xc7, 0xe2, 0x4f, 0xb0, 0xf0, 0xd3 \ 121 } 122 123 #define MBIM_CTRLMSG_MINLEN 64 124 #define MBIM_CTRLMSG_MAXLEN (4 * 1204) 125 126 #define MBIM_MAXSEGSZ_MINVAL (2 * 1024) 127 128 /* 129 * Control messages (host to function) 130 */ 131 #define MBIM_OPEN_MSG 1U 132 #define MBIM_CLOSE_MSG 2U 133 #define MBIM_COMMAND_MSG 3U 134 #define MBIM_HOST_ERROR_MSG 4U 135 136 /* 137 * Control messages (function to host) 138 */ 139 #define MBIM_OPEN_DONE 0x80000001U 140 #define MBIM_CLOSE_DONE 0x80000002U 141 #define MBIM_COMMAND_DONE 0x80000003U 142 #define MBIM_FUNCTION_ERROR_MSG 0x80000004U 143 #define MBIM_INDICATE_STATUS_MSG 0x80000007U 144 145 /* 146 * Generic status codes 147 */ 148 #define MBIM_STATUS_SUCCESS 0 149 #define MBIM_STATUS_BUSY 1 150 #define MBIM_STATUS_FAILURE 2 151 #define MBIM_STATUS_SIM_NOT_INSERTED 3 152 #define MBIM_STATUS_BAD_SIM 4 153 #define MBIM_STATUS_PIN_REQUIRED 5 154 #define MBIM_STATUS_PIN_DISABLED 6 155 #define MBIM_STATUS_NOT_REGISTERED 7 156 #define MBIM_STATUS_PROVIDERS_NOT_FOUND 8 157 #define MBIM_STATUS_NO_DEVICE_SUPPORT 9 158 #define MBIM_STATUS_PROVIDER_NOT_VISIBLE 10 159 #define MBIM_STATUS_DATA_CLASS_NOT_AVAILABLE 11 160 #define MBIM_STATUS_PACKET_SERVICE_DETACHED 12 161 #define MBIM_STATUS_MAX_ACTIVATED_CONTEXTS 13 162 #define MBIM_STATUS_NOT_INITIALIZED 14 163 #define MBIM_STATUS_VOICE_CALL_IN_PROGRESS 15 164 #define MBIM_STATUS_CONTEXT_NOT_ACTIVATED 16 165 #define MBIM_STATUS_SERVICE_NOT_ACTIVATED 17 166 #define MBIM_STATUS_INVALID_ACCESS_STRING 18 167 #define MBIM_STATUS_INVALID_USER_NAME_PWD 19 168 #define MBIM_STATUS_RADIO_POWER_OFF 20 169 #define MBIM_STATUS_INVALID_PARAMETERS 21 170 #define MBIM_STATUS_READ_FAILURE 22 171 #define MBIM_STATUS_WRITE_FAILURE 23 172 #define MBIM_STATUS_NO_PHONEBOOK 25 173 #define MBIM_STATUS_PARAMETER_TOO_LONG 26 174 #define MBIM_STATUS_STK_BUSY 27 175 #define MBIM_STATUS_OPERATION_NOT_ALLOWED 28 176 #define MBIM_STATUS_MEMORY_FAILURE 29 177 #define MBIM_STATUS_INVALID_MEMORY_INDEX 30 178 #define MBIM_STATUS_MEMORY_FULL 31 179 #define MBIM_STATUS_FILTER_NOT_SUPPORTED 32 180 #define MBIM_STATUS_DSS_INSTANCE_LIMIT 33 181 #define MBIM_STATUS_INVALID_DEVICE_SERVICE_OPERATION 34 182 #define MBIM_STATUS_AUTH_INCORRECT_AUTN 35 183 #define MBIM_STATUS_AUTH_SYNC_FAILURE 36 184 #define MBIM_STATUS_AUTH_AMF_NOT_SET 37 185 #define MBIM_STATUS_CONTEXT_NOT_SUPPORTED 38 186 #define MBIM_STATUS_SMS_UNKNOWN_SMSC_ADDRESS 100 187 #define MBIM_STATUS_SMS_NETWORK_TIMEOUT 101 188 #define MBIM_STATUS_SMS_LANG_NOT_SUPPORTED 102 189 #define MBIM_STATUS_SMS_ENCODING_NOT_SUPPORTED 103 190 #define MBIM_STATUS_SMS_FORMAT_NOT_SUPPORTED 104 191 192 /* 193 * Message formats 194 */ 195 struct mbim_msghdr { 196 /* Msg header */ 197 uint32_t type; /* message type */ 198 uint32_t len; /* message length */ 199 uint32_t tid; /* transaction id */ 200 } __packed; 201 202 struct mbim_fraghdr { 203 uint32_t nfrag; /* total # of fragments */ 204 uint32_t currfrag; /* current fragment */ 205 } __packed; 206 207 struct mbim_fragmented_msg_hdr { 208 struct mbim_msghdr hdr; 209 struct mbim_fraghdr frag; 210 } __packed; 211 212 struct mbim_h2f_openmsg { 213 struct mbim_msghdr hdr; 214 uint32_t maxlen; 215 } __packed; 216 217 struct mbim_h2f_closemsg { 218 struct mbim_msghdr hdr; 219 } __packed; 220 221 struct mbim_h2f_cmd { 222 struct mbim_msghdr hdr; 223 struct mbim_fraghdr frag; 224 uint8_t devid[MBIM_UUID_LEN]; 225 uint32_t cid; /* command id */ 226 #define MBIM_CMDOP_QRY 0 227 #define MBIM_CMDOP_SET 1 228 uint32_t op; 229 uint32_t infolen; 230 uint8_t info[]; 231 } __packed; 232 233 struct mbim_f2h_indicate_status { 234 struct mbim_msghdr hdr; 235 struct mbim_fraghdr frag; 236 uint8_t devid[MBIM_UUID_LEN]; 237 uint32_t cid; /* command id */ 238 uint32_t infolen; 239 uint8_t info[]; 240 } __packed; 241 242 struct mbim_f2h_hosterr { 243 struct mbim_msghdr hdr; 244 245 #define MBIM_ERROR_TIMEOUT_FRAGMENT 1 246 #define MBIM_ERROR_FRAGMENT_OUT_OF_SEQUENCE 2 247 #define MBIM_ERROR_LENGTH_MISMATCH 3 248 #define MBIM_ERROR_DUPLICATED_TID 4 249 #define MBIM_ERROR_NOT_OPENED 5 250 #define MBIM_ERROR_UNKNOWN 6 251 #define MBIM_ERROR_CANCEL 7 252 #define MBIM_ERROR_MAX_TRANSFER 8 253 uint32_t err; 254 } __packed; 255 256 struct mbim_f2h_openclosedone { 257 struct mbim_msghdr hdr; 258 int32_t status; 259 } __packed; 260 261 struct mbim_f2h_cmddone { 262 struct mbim_msghdr hdr; 263 struct mbim_fraghdr frag; 264 uint8_t devid[MBIM_UUID_LEN]; 265 uint32_t cid; /* command id */ 266 int32_t status; 267 uint32_t infolen; 268 uint8_t info[]; 269 } __packed; 270 271 /* 272 * Messages and commands for MBIM_UUID_BASIC_CONNECT 273 */ 274 #define MBIM_CID_DEVICE_CAPS 1 275 #define MBIM_CID_SUBSCRIBER_READY_STATUS 2 276 #define MBIM_CID_RADIO_STATE 3 277 #define MBIM_CID_PIN 4 278 #define MBIM_CID_PIN_LIST 5 279 #define MBIM_CID_HOME_PROVIDER 6 280 #define MBIM_CID_PREFERRED_PROVIDERS 7 281 #define MBIM_CID_VISIBLE_PROVIDERS 8 282 #define MBIM_CID_REGISTER_STATE 9 283 #define MBIM_CID_PACKET_SERVICE 10 284 #define MBIM_CID_SIGNAL_STATE 11 285 #define MBIM_CID_CONNECT 12 286 #define MBIM_CID_PROVISIONED_CONTEXTS 13 287 #define MBIM_CID_SERVICE_ACTIVATION 14 288 #define MBIM_CID_IP_CONFIGURATION 15 289 #define MBIM_CID_DEVICE_SERVICES 16 290 #define MBIM_CID_DEVICE_SERVICE_SUBSCRIBE_LIST 19 291 #define MBIM_CID_PACKET_STATISTICS 20 292 #define MBIM_CID_NETWORK_IDLE_HINT 21 293 #define MBIM_CID_EMERGENCY_MODE 22 294 #define MBIM_CID_IP_PACKET_FILTERS 23 295 #define MBIM_CID_MULTICARRIER_PROVIDERS 24 296 297 struct mbim_cid_subscriber_ready_info { 298 #define MBIM_SIMSTATE_NOTINITIALIZED 0 299 #define MBIM_SIMSTATE_INITIALIZED 1 300 #define MBIM_SIMSTATE_NOTINSERTED 2 301 #define MBIM_SIMSTATE_BADSIM 3 302 #define MBIM_SIMSTATE_FAILURE 4 303 #define MBIM_SIMSTATE_NOTACTIVATED 5 304 #define MBIM_SIMSTATE_LOCKED 6 305 uint32_t ready; 306 307 uint32_t sid_offs; 308 uint32_t sid_size; 309 310 uint32_t icc_offs; 311 uint32_t icc_size; 312 313 #define MBIM_SIMUNIQEID_NONE 0 314 #define MBIM_SIMUNIQEID_PROTECT 1 315 uint32_t info; 316 317 uint32_t no_pn; 318 struct { 319 uint32_t offs; 320 uint32_t size; 321 } 322 pn[]; 323 } __packed; 324 325 struct mbim_cid_radio_state { 326 #define MBIM_RADIO_STATE_OFF 0 327 #define MBIM_RADIO_STATE_ON 1 328 uint32_t state; 329 } __packed; 330 331 struct mbim_cid_radio_state_info { 332 uint32_t hw_state; 333 uint32_t sw_state; 334 } __packed; 335 336 struct mbim_cid_pin { 337 #define MBIM_PIN_TYPE_NONE 0 338 #define MBIM_PIN_TYPE_CUSTOM 1 339 #define MBIM_PIN_TYPE_PIN1 2 340 #define MBIM_PIN_TYPE_PIN2 3 341 #define MBIM_PIN_TYPE_DEV_SIM_PIN 4 342 #define MBIM_PIN_TYPE_DEV_FIRST_SIM_PIN 5 343 #define MBIM_PIN_TYPE_NETWORK_PIN 6 344 #define MBIM_PIN_TYPE_NETWORK_SUBSET_PIN 7 345 #define MBIM_PIN_TYPE_SERVICE_PROVIDER_PIN 8 346 #define MBIM_PIN_TYPE_CORPORATE_PIN 9 347 #define MBIM_PIN_TYPE_SUBSIDY_LOCK 10 348 #define MBIM_PIN_TYPE_PUK1 11 349 #define MBIM_PIN_TYPE_PUK2 12 350 #define MBIM_PIN_TYPE_DEV_FIRST_SIM_PUK 13 351 #define MBIM_PIN_TYPE_NETWORK_PUK 14 352 #define MBIM_PIN_TYPE_NETWORK_SUBSET_PUK 15 353 #define MBIM_PIN_TYPE_SERVICE_PROVIDER_PUK 16 354 #define MBIM_PIN_TYPE_CORPORATE_PUK 17 355 uint32_t type; 356 357 #define MBIM_PIN_OP_ENTER 0 358 #define MBIM_PIN_OP_ENABLE 1 359 #define MBIM_PIN_OP_DISABLE 2 360 #define MBIM_PIN_OP_CHANGE 3 361 uint32_t op; 362 uint32_t pin_offs; 363 uint32_t pin_size; 364 uint32_t newpin_offs; 365 uint32_t newpin_size; 366 #define MBIM_PIN_MAXLEN 32 367 uint8_t data[2 * MBIM_PIN_MAXLEN]; 368 } __packed; 369 370 struct mbim_cid_pin_info { 371 uint32_t type; 372 373 #define MBIM_PIN_STATE_UNLOCKED 0 374 #define MBIM_PIN_STATE_LOCKED 1 375 uint32_t state; 376 uint32_t remaining_attempts; 377 } __packed; 378 379 struct mbim_cid_pin_list_info { 380 struct mbim_pin_desc { 381 382 #define MBIM_PINMODE_NOTSUPPORTED 0 383 #define MBIM_PINMODE_ENABLED 1 384 #define MBIM_PINMODE_DISABLED 2 385 uint32_t mode; 386 387 #define MBIM_PINFORMAT_UNKNOWN 0 388 #define MBIM_PINFORMAT_NUMERIC 1 389 #define MBIM_PINFORMAT_ALPHANUMERIC 2 390 uint32_t format; 391 392 uint32_t minlen; 393 uint32_t maxlen; 394 } 395 pin1, 396 pin2, 397 dev_sim_pin, 398 first_dev_sim_pin, 399 net_pin, 400 net_sub_pin, 401 svp_pin, 402 corp_pin, 403 subsidy_lock, 404 custom; 405 } __packed; 406 407 struct mbim_cid_device_caps { 408 #define MBIM_DEVTYPE_UNKNOWN 0 409 #define MBIM_DEVTYPE_EMBEDDED 1 410 #define MBIM_DEVTYPE_REMOVABLE 2 411 #define MBIM_DEVTYPE_REMOTE 3 412 uint32_t devtype; 413 414 uint32_t cellclass; /* values: MBIM_CELLULAR_CLASS */ 415 uint32_t voiceclass; 416 uint32_t simclass; 417 uint32_t dataclass; /* values: MBIM_DATA_CLASS */ 418 uint32_t smscaps; 419 uint32_t cntrlcaps; 420 uint32_t max_sessions; 421 422 uint32_t custdataclass_offs; 423 uint32_t custdataclass_size; 424 425 uint32_t devid_offs; 426 uint32_t devid_size; 427 428 uint32_t fwinfo_offs; 429 uint32_t fwinfo_size; 430 431 uint32_t hwinfo_offs; 432 uint32_t hwinfo_size; 433 434 uint32_t data[]; 435 } __packed; 436 437 struct mbim_cid_registration_state { 438 uint32_t provid_offs; 439 uint32_t provid_size; 440 441 #define MBIM_REGACTION_AUTOMATIC 0 442 #define MBIM_REGACTION_MANUAL 1 443 uint32_t regaction; 444 uint32_t data_class; 445 446 uint32_t data[]; 447 } __packed; 448 449 struct mbim_cid_registration_state_info { 450 uint32_t nwerror; 451 452 uint32_t regstate; /* values: MBIM_REGISTER_STATE */ 453 454 #define MBIM_REGMODE_UNKNOWN 0 455 #define MBIM_REGMODE_AUTOMATIC 1 456 #define MBIM_REGMODE_MANUAL 2 457 uint32_t regmode; 458 459 uint32_t availclasses; /* values: MBIM_DATA_CLASS */ 460 uint32_t curcellclass; /* values: MBIM_CELLULAR_CLASS */ 461 462 uint32_t provid_offs; 463 uint32_t provid_size; 464 465 uint32_t provname_offs; 466 uint32_t provname_size; 467 468 uint32_t roamingtxt_offs; 469 uint32_t roamingtxt_size; 470 471 #define MBIM_REGFLAGS_NONE 0 472 #define MBIM_REGFLAGS_MANUAL_NOT_AVAILABLE 1 473 #define MBIM_REGFLAGS_PACKETSERVICE_AUTOATTACH 2 474 uint32_t regflag; 475 476 uint32_t data[]; 477 } __packed; 478 479 struct mbim_cid_packet_service { 480 #define MBIM_PKTSERVICE_ACTION_ATTACH 0 481 #define MBIM_PKTSERVICE_ACTION_DETACH 1 482 uint32_t action; 483 } __packed; 484 485 struct mbim_cid_packet_service_info { 486 uint32_t nwerror; 487 488 #define MBIM_PKTSERVICE_STATE_UNKNOWN 0 489 #define MBIM_PKTSERVICE_STATE_ATTACHING 1 490 #define MBIM_PKTSERVICE_STATE_ATTACHED 2 491 #define MBIM_PKTSERVICE_STATE_DETACHING 3 492 #define MBIM_PKTSERVICE_STATE_DETACHED 4 493 uint32_t state; 494 495 uint32_t highest_dataclass; 496 uint64_t uplink_speed; 497 uint64_t downlink_speed; 498 } __packed; 499 500 struct mbim_cid_signal_state { 501 uint32_t rssi; 502 uint32_t err_rate; 503 uint32_t ss_intvl; 504 uint32_t rssi_thr; 505 uint32_t err_thr; 506 } __packed; 507 508 struct mbim_cid_connect { 509 uint32_t sessionid; 510 511 #define MBIM_CONNECT_DEACTIVATE 0 512 #define MBIM_CONNECT_ACTIVATE 1 513 uint32_t command; 514 515 #define MBIM_ACCESS_MAXLEN 200 516 uint32_t access_offs; 517 uint32_t access_size; 518 519 #define MBIM_USER_MAXLEN 510 520 uint32_t user_offs; 521 uint32_t user_size; 522 523 #define MBIM_PASSWD_MAXLEN 510 524 uint32_t passwd_offs; 525 uint32_t passwd_size; 526 527 #define MBIM_COMPRESSION_NONE 0 528 #define MBIM_COMPRESSION_ENABLE 1 529 uint32_t compression; 530 531 #define MBIM_AUTHPROT_NONE 0 532 #define MBIM_AUTHPROT_PAP 1 533 #define MBIM_AUTHPROT_CHAP 2 534 #define MBIM_AUTHPROT_MSCHAP 3 535 uint32_t authprot; 536 537 #define MBIM_CONTEXT_IPTYPE_DEFAULT 0 538 #define MBIM_CONTEXT_IPTYPE_IPV4 1 539 #define MBIM_CONTEXT_IPTYPE_IPV6 2 540 #define MBIM_CONTEXT_IPTYPE_IPV4V6 3 541 #define MBIM_CONTEXT_IPTYPE_IPV4ANDV6 4 542 uint32_t iptype; 543 544 uint8_t context[MBIM_UUID_LEN]; 545 546 uint8_t data[MBIM_ACCESS_MAXLEN + MBIM_USER_MAXLEN + 547 MBIM_PASSWD_MAXLEN]; 548 549 } __packed; 550 551 struct mbim_cid_connect_info { 552 uint32_t sessionid; 553 554 #define MBIM_ACTIVATION_STATE_UNKNOWN 0 555 #define MBIM_ACTIVATION_STATE_ACTIVATED 1 556 #define MBIM_ACTIVATION_STATE_ACTIVATING 2 557 #define MBIM_ACTIVATION_STATE_DEACTIVATED 3 558 #define MBIM_ACTIVATION_STATE_DEACTIVATING 4 559 uint32_t activation; 560 561 uint32_t voice; 562 uint32_t iptype; 563 uint8_t context[MBIM_UUID_LEN]; 564 uint32_t nwerror; 565 } __packed; 566 567 struct mbim_cid_ipv4_element { 568 uint32_t prefixlen; 569 uint32_t addr; 570 } __packed; 571 572 struct mbim_cid_ipv6_element { 573 uint32_t prefixlen; 574 uint8_t addr[16]; 575 } __packed; 576 577 struct mbim_cid_ip_configuration_info { 578 uint32_t sessionid; 579 580 #define MBIM_IPCONF_HAS_ADDRINFO 0x0001 581 #define MBIM_IPCONF_HAS_GWINFO 0x0002 582 #define MBIM_IPCONF_HAS_DNSINFO 0x0004 583 #define MBIM_IPCONF_HAS_MTUINFO 0x0008 584 uint32_t ipv4_available; 585 uint32_t ipv6_available; 586 587 uint32_t ipv4_naddr; 588 uint32_t ipv4_addroffs; 589 uint32_t ipv6_naddr; 590 uint32_t ipv6_addroffs; 591 592 uint32_t ipv4_gwoffs; 593 uint32_t ipv6_gwoffs; 594 595 uint32_t ipv4_ndnssrv; 596 uint32_t ipv4_dnssrvoffs; 597 uint32_t ipv6_ndnssrv; 598 uint32_t ipv6_dnssrvoffs; 599 600 uint32_t ipv4_mtu; 601 uint32_t ipv6_mtu; 602 603 uint32_t data[]; 604 } __packed; 605 606 struct mbim_cid_packet_statistics_info { 607 uint32_t in_discards; 608 uint32_t in_errors; 609 uint64_t in_octets; 610 uint64_t in_packets; 611 uint64_t out_octets; 612 uint64_t out_packets; 613 uint32_t out_errors; 614 uint32_t out_discards; 615 } __packed; 616 617 618 #ifdef _KERNEL 619 620 struct mbim_descriptor { 621 uByte bLength; 622 uByte bDescriptorType; 623 uByte bDescriptorSubtype; 624 #define MBIM_VER_MAJOR(v) (((v) >> 8) & 0x0f) 625 #define MBIM_VER_MINOR(v) ((v) & 0x0f) 626 uWord bcdMBIMVersion; 627 uWord wMaxControlMessage; 628 uByte bNumberFilters; 629 uByte bMaxFilterSize; 630 uWord wMaxSegmentSize; 631 uByte bmNetworkCapabilities; 632 } __packed; 633 634 /* 635 * NCM Parameters 636 */ 637 #define NCM_GET_NTB_PARAMETERS 0x80 638 639 struct ncm_ntb_parameters { 640 uWord wLength; 641 uWord bmNtbFormatsSupported; 642 #define NCM_FORMAT_NTB16 0x0001 643 #define NCM_FORMAT_NTB32 0x0002 644 uDWord dwNtbInMaxSize; 645 uWord wNdpInDivisor; 646 uWord wNdpInPayloadRemainder; 647 uWord wNdpInAlignment; 648 uWord wReserved1; 649 uDWord dwNtbOutMaxSize; 650 uWord wNdpOutDivisor; 651 uWord wNdpOutPayloadRemainder; 652 uWord wNdpOutAlignment; 653 uWord wNtbOutMaxDatagrams; 654 } __packed; 655 656 /* 657 * NCM Encoding 658 */ 659 #define MBIM_HDR16_LEN \ 660 (sizeof(struct ncm_header16) + sizeof(struct ncm_pointer16)) 661 #define MBIM_HDR32_LEN \ 662 (sizeof(struct ncm_header32) + sizeof(struct ncm_pointer32)) 663 664 struct ncm_header16 { 665 #define NCM_HDR16_SIG 0x484d434e 666 uDWord dwSignature; 667 uWord wHeaderLength; 668 uWord wSequence; 669 uWord wBlockLength; 670 uWord wNdpIndex; 671 } __packed; 672 673 struct ncm_header32 { 674 #define NCM_HDR32_SIG 0x686d636e 675 uDWord dwSignature; 676 uWord wHeaderLength; 677 uWord wSequence; 678 uDWord dwBlockLength; 679 uDWord dwNdpIndex; 680 } __packed; 681 682 683 #define MBIM_NCM_NTH_SIDSHIFT 24 684 #define MBIM_NCM_NTH_GETSID(s) (((s) > MBIM_NCM_NTH_SIDSHIFT) & 0xff) 685 686 struct ncm_pointer16_dgram { 687 uWord wDatagramIndex; 688 uWord wDatagramLen; 689 } __packed; 690 691 struct ncm_pointer16 { 692 #define MBIM_NCM_NTH16_IPS 0x00535049 693 #define MBIM_NCM_NTH16_ISISG(s) (((s) & 0x00ffffff) == MBIM_NCM_NTH16_IPS) 694 #define MBIM_NCM_NTH16_SIG(s) \ 695 ((((s) & 0xff) << MBIM_NCM_NTH_SIDSHIFT) | MBIM_NCM_NTH16_IPS) 696 uDWord dwSignature; 697 uWord wLength; 698 uWord wNextNdpIndex; 699 700 /* Minimum is two datagrams, but can be more */ 701 struct ncm_pointer16_dgram dgram[2]; 702 } __packed; 703 704 struct ncm_pointer32_dgram { 705 uDWord dwDatagramIndex; 706 uDWord dwDatagramLen; 707 } __packed; 708 709 struct ncm_pointer32 { 710 #define MBIM_NCM_NTH32_IPS 0x00737069 711 #define MBIM_NCM_NTH32_ISISG(s) \ 712 (((s) & 0x00ffffff) == MBIM_NCM_NTH32_IPS) 713 #define MBIM_NCM_NTH32_SIG(s) \ 714 ((((s) & 0xff) << MBIM_NCM_NTH_SIDSHIFT) | MBIM_NCM_NTH32_IPS) 715 uDWord dwSignature; 716 uWord wLength; 717 uWord wReserved6; 718 uDWord dwNextNdpIndex; 719 uDWord dwReserved12; 720 721 /* Minimum is two datagrams, but can be more */ 722 struct ncm_pointer32_dgram dgram[2]; 723 } __packed; 724 725 #endif /* _KERNEL */ 726 727 #endif /* _MBIM_H_ */ 728