1/* 2 * This file is developed based on USBModemECMControl.h 3 * which is used by mac NDIS dail 2012.01.05 4 * this file only process the qmi data package,so hope for porting to other system easily. 5 * Copyright (C) 2012 by qiaoyongkang (longcheer Ltd.) 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will support Huawei data card devices for Linux networking, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 */ 21 22#ifndef __QMI_HEADER_H__ 23#define __QMI_HEADER_H__ 24#include <linux/ctype.h> 25 26typedef unsigned short UInt16; 27typedef unsigned char UInt8; 28typedef unsigned int UInt32; 29typedef unsigned long long UInt64; 30 31#define LDEBUG 0 // for debugging 32#define USE_ELG 0 // to Event LoG (via kprintf and Firewire) - LDEBUG must also be set 33#define USE_IOL 0 // to IOLog - LDEBUG must also be set 34#define LOG_DATA 0 // logs data to the appropriate log - LDEBUG must also be set 35#define DUMPALL 0 // Dumps all the data to the log - LOG_DATA must also be set 36 37#define Sleep_Time 20 38 39enum 40{ 41 kDataIn = 0, 42 kDataOut, 43 kDataOther, 44 kDataNone 45}; 46 47 // Reset states 48 49enum 50{ 51 kResetNormal = 0, 52 kResetNeeded, 53 kResetDone 54}; 55 56enum{ 57 IPv4 = 0, 58 IPv6, 59 IPv4v6 60}; 61 62enum 63{ 64 LC_DISCONNECTED = 0, //disconneted 65 LC_CONNECTING, //connecting 66 LC_GETTING_IP, //connecting 67 LC_IP_GETTED, //connected 68 LC_CONNECTED = LC_IP_GETTED, //connected 69 LC_DISCONNECTING, //connected 70}; 71 72typedef struct _QCQMI_HDR 73{ 74 UInt8 IFType; 75 UInt16 Length; 76 UInt8 CtlFlags; 77 UInt8 QMIType; 78 UInt8 ClientId; 79}__attribute__((packed)) QCQMI_HDR/*, *PQCQMI_HDR*/; 80 81typedef struct _QCQMI 82{ 83 UInt8 IFType; 84 UInt16 Length; 85 UInt8 CtlFlags; 86 UInt8 QMIType; 87 UInt8 ClientId; 88 UInt8 SDU; // point to qcqmux or qcqmictl_msg_hdr 89}__attribute__((packed)) QCQMI/*, *QCQMI**/ ; 90 91typedef struct _QCQMUX_HDR 92{ 93 UInt8 CtlFlags; 94 UInt16 TransactionId; 95}__attribute__((packed)) QCQMUX_HDR/*, *QCQMUX_HDR**/; 96 97typedef struct _QCQMUX 98{ 99 UInt8 CtlFlags; 100 UInt16 TransactionId; 101 UInt8 Message; // point to QCQMUX_MSG_HDR 102}__attribute__((packed)) QCQMUX; 103 104typedef struct _QCQMUX_MSG_HDR 105{ 106 UInt16 Type; 107 UInt16 Length; 108}__attribute__((packed)) QCQMUX_MSG_HDR, *PQCQMUX_MSG_HDR; 109 110typedef struct _QCQMICTL_MSG_HDR 111{ 112 UInt8 CtlFlag; 113 UInt8 TransactionId; 114 UInt16 QMICTLType; 115 UInt16 Length; 116}__attribute__((packed)) QCQMICTL_MSG_HDR; 117 118#define QMUX_BROADCAST_CID 0xFF 119 120enum 121{ 122 QMUX_TYPE_CTL = 0x00, 123 QMUX_TYPE_WDS = 0x01, 124 QMUX_TYPE_DMS = 0x02, 125 QMUX_TYPE_NAS = 0x03, 126 QMUX_TYPE_QOS = 0x04, 127 QMUX_TYPE_MAX, 128 QMUX_TYPE_ALL = 0xFF 129}; 130 131 132#define QCQMI_CTL_FLAG_SERVICE 0x80 133#define USB_CTL_MSG_TYPE_QMI 0x01 134 135// QMICTL Control Flags 136#define QMICTL_CTL_FLAG_CMD 0x00 137#define QMICTL_CTL_FLAG_RSP 0x01 138#define QMICTL_CTL_FLAG_IND 0x02 139 140#define QMICTL_SET_INSTANCE_ID_REQ 0x0020 141#define QMICTL_SET_INSTANCE_ID_RESP 0x0020 142#define QMICTL_GET_CLIENT_ID_REQ 0x0022 143#define QMICTL_GET_CLIENT_ID_RESP 0x0022 144#define QMICTL_RELEASE_CLIENT_ID_REQ 0x0023 145#define QMICTL_RELEASE_CLIENT_ID_RESP 0x0023 146#define QMICTL_REVOKE_CLIENT_IDIND 0x0024 147#define QMICTL_INVALID_CLIENT_ID_IND 0x0025 148#define QMICTL_GET_VERSION_REQ 0x0021 149#define QMICTL_GET_VERSION_RESP 0x0021 150#define QMICTL_SET_DATA_FORMAT_REQ 0x0026 151#define QMICTL_SET_DATA_FORMAT_RESP 0x0026 152 153 154 155// wds message 156#define QMI_WDS_MODIFY_PROFILE_SETTINGS_REQ 0x0028 157#define QMI_WDS_MODIFY_PROFILE_SETTINGS_RESP 0x0028 158#define QMIWDS_START_NETWORK_INTERFACE_REQ 0x0020 159#define QMIWDS_START_NETWORK_INTERFACE_RESP 0x0020 160#define QMIWDS_STOP_NETWORK_INTERFACE_REQ 0x0021 161#define QMIWDS_STOP_NETWORK_INTERFACE_RESP 0x0021 162#define QMIWDS_GET_RUNTIME_SETTINGS_REQ 0x002D 163#define QMIWDS_GET_RUNTIME_SETTINGS_RESP 0x002D 164 165// wds Indication 166#define QMIWDS_GET_PKT_SRVC_STATUS_IND 0x0022 167 168 169#define QMICTL_CTL_FLAG_REQUEST 0x00 170 171#define QMI_RESULT_SUCCESS 0x0000 172#define QMI_RESULT_FAILURE 0x0001 173 174#define QMUX_CTL_FLAG_SINGLE_MSG 0x00 175#define QMUX_CTL_FLAG_TYPE_CMD 0x00 176#define QMUX_CTL_FLAG_MASK_TYPE 0x06 177#define QMUX_CTL_FLAG_MASK_COMPOUND 0x01 178#define QMUX_CTL_FLAG_TYPE_RSP 0x02 179#define QMUX_CTL_FLAG_TYPE_IND 0x04 180 181typedef struct _QMICTL_GET_CLIENT_ID_REQ_MSG 182{ 183 UInt8 CtlFlags; 184 UInt8 TransactionId; 185 UInt16 QMICTLType; 186 UInt16 Length; 187 UInt8 TLVType; 188 UInt16 TLVLength; 189 UInt8 QMIType; 190}__attribute__((packed)) QMICTL_GET_CLIENT_ID_REQ_MSG; 191 192typedef struct _QMICTL_GET_CLIENT_ID_RESP_MSG 193{ 194 UInt8 CtlFlags; 195 UInt8 TransactionId; 196 UInt16 QMICTLType; 197 UInt16 Length; 198 UInt8 TLVType; 199 UInt16 TLVLength; 200 UInt16 QMIResult; 201 UInt16 QMIError; 202 UInt8 TLV2Type; 203 UInt16 TLV2Length; 204 UInt8 QMIType; 205 UInt8 ClientId; 206}__attribute__((packed)) QMICTL_GET_CLIENT_ID_RESP_MSG; 207 208typedef struct _QMICTL_RELEASE_CLIENT_ID_REQ_MSG 209{ 210 UInt8 CtlFlags; 211 UInt8 TransactionId; 212 UInt16 QMICTLType; 213 UInt16 Length; 214 UInt8 TLVType; 215 UInt16 TLVLength; 216 UInt8 QMIType; 217 UInt8 ClientId; 218}__attribute__((packed)) QMICTL_RELEASE_CLIENT_ID_REQ_MSG; 219 220typedef struct _QMICTL_RELEASE_CLIENT_ID_RESP_MSG 221{ 222 UInt8 CtlFlags; 223 UInt8 TransactionId; 224 UInt16 QMICTLType; 225 UInt16 Length; 226 UInt8 TLVType; 227 UInt16 TLVLength; 228 UInt16 QMIResult; 229 UInt16 QMIError; 230 UInt8 TLV2Type; 231 UInt16 TLV2Length; 232 UInt8 QMIType; 233 UInt8 ClientId; 234}__attribute__((packed)) QMICTL_RELEASE_CLIENT_ID_RESP_MSG; 235 236typedef struct _QMICTL_GET_VERSION_REQ_MSG 237{ 238 UInt8 CtlFlags; 239 UInt8 TransactionId; 240 UInt16 QMICTLType; 241 UInt16 Length; 242 UInt8 TLVType; 243 UInt16 TLVLength; 244 UInt8 QMIType; 245}__attribute__((packed)) QMICTL_GET_VERSION_REQ_MSG; 246 247typedef struct _QMUX_TYPE_VERSION_STRUCT 248{ 249 UInt8 QMUXType; 250 UInt16 MajorVersion; 251 UInt16 MinorVersion; 252}__attribute__((packed)) QMUX_TYPE_VERSION_STRUCT; 253 254typedef struct _QMICTL_GET_VERSION_RESP_MSG 255{ 256 UInt8 CtlFlags; 257 UInt8 TransactionId; 258 UInt16 QMICTLType; 259 UInt16 Length; 260 UInt8 TLVType; 261 UInt16 TLVLength; 262 UInt16 QMIResult; 263 UInt16 QMIError; 264 UInt8 TLV2Type; 265 UInt16 TLV2Length; 266 UInt8 NumElements; 267 QMUX_TYPE_VERSION_STRUCT TypeVersion; 268}__attribute__((packed)) QMICTL_GET_VERSION_RESP_MSG; 269 270typedef struct _QMI_TLV_HDR 271{ 272 UInt8 TLVType; 273 UInt16 TLVLength; 274}__attribute__((packed)) QMI_TLV_HDR; 275 276// set data format 277typedef struct _QMICTL_SET_DATA_FORMAT_TLV_LINK_PROT 278{ 279 UInt8 TLVType; 280 UInt16 TLVLength; 281 UInt16 LinkProt; 282}__attribute__((packed)) QMICTL_SET_DATA_FORMAT_TLV_LINK_PROT; 283 284typedef struct _QMICTL_SET_DATA_FORMAT_REQ_MSG 285{ 286 UInt8 CtlFlags; 287 UInt8 TransactionId; 288 UInt16 QMICTLType; 289 UInt16 Length; 290 UInt8 TLVType; 291 UInt16 TLVLength; 292 UInt8 DataFormat; 293 QMICTL_SET_DATA_FORMAT_TLV_LINK_PROT Proto; 294}__attribute__((packed)) QMICTL_SET_DATA_FORMAT_REQ_MSG; 295 296typedef struct _QMICTL_SET_DATA_FORMAT_RESP_MSG 297{ 298 UInt8 CtlFlags; 299 UInt8 TransactionId; 300 UInt16 QMICTLType; 301 UInt16 Length; 302 UInt8 TLVType; 303 UInt16 TLVLength; 304 UInt16 QMIResult; 305 UInt16 QMIError; 306 QMICTL_SET_DATA_FORMAT_TLV_LINK_PROT Proto; 307}__attribute__((packed)) QMICTL_SET_DATA_FORMAT_RESP_MSG; 308 309typedef struct _QMICTL_SET_INSTANCE_ID_REQ_MSG 310{ 311 UInt8 CtlFlags; 312 UInt8 TransactionId; 313 UInt16 QMICTLType; 314 UInt16 Length; 315 UInt8 TLVType; 316 UInt16 TLVLength; 317 UInt8 Value; 318}__attribute__((packed)) QMICTL_SET_INSTANCE_ID_REQ_MSG; 319 320typedef struct _QMICTL_SET_INSTANCE_ID_RESP_MSG 321{ 322 UInt8 CtlFlags; 323 UInt8 TransactionId; 324 UInt16 QMICTLType; 325 UInt16 Length; 326 UInt8 TLVType; 327 UInt16 TLVLength; 328 UInt16 QMIResult; 329 UInt16 QMIError; 330 UInt8 TLV2Type; 331 UInt16 TLV2Length; 332 UInt16 QMI_ID; 333}__attribute__((packed)) QMICTL_SET_INSTANCE_ID_RESP_MSG; 334 335 336#define QCTLV_TYPE_REQUIRED_PARAMETER 0x01 337#define QMICTL_GETVERSION_RSP_TLV_TYPE_ADD_VERSION 0x10 338 339#define SET_DATA_FORMAT_TLV_TYPE_LINK_PROTO 0x10 340#define SET_DATA_FORMAT_LINK_PROTO_ETH 0x0001 341#define SET_DATA_FORMAT_LINK_PROTO_IP 0x0002 342 343#define MP_INVALID_QMI_ID 0xF0000000 344 345#define QCTLV_TYPE_APN 0x14 346#define QCTLV_TYPE_AUTH_TYPE 0x16 347#define QCTLV_TYPE_USER_NAME 0x17 348#define QCTLV_TYPE_PASSWORD 0x18 349 350typedef struct _QMIWDS_RESP_MSG_HEADER 351{ 352 UInt16 Type; 353 UInt16 Length; 354 UInt8 TLVType; 355 UInt16 TLVLength; 356 UInt16 QMUXResult; 357 UInt16 QMUXError; 358}__attribute__((packed)) QMIWDS_RESP_MSG_HEADER, *PQMIWDS_RESP_MSG_HEADER; 359 360typedef struct _QMIWDS_START_NETWORK_INTERFACE_RESP_MSG 361{ 362 UInt16 Type; 363 UInt16 Length; 364 UInt8 TLVType; 365 UInt16 TLVLength; 366 UInt16 QMUXResult; 367 UInt16 QMUXError; 368 UInt8 TLVType2; 369 UInt16 TLVLength2; 370 UInt32 Pkt_Data_Handle; 371}__attribute__((packed)) QMIWDS_START_NETWORK_INTERFACE_RESP_MSG; 372 373typedef struct _QMIWDS_GET_PKT_SRVC_STATUS_IND_MSG 374{ 375 UInt16 Type; 376 UInt16 Length; 377 UInt8 TLVType; 378 UInt16 TLVLength; 379 UInt8 ConnectionStatus; 380 UInt8 ReconfigRequired; 381}__attribute__((packed)) QMIWDS_GET_PKT_SRVC_STATUS_IND_MSG; 382 383typedef struct _QMIWDS_STOP_NETWORK_INTERFACE_REQ_MSG 384{ 385 UInt16 Type; 386 UInt16 Length; 387 UInt8 TLVType; 388 UInt16 TLVLength; 389 UInt32 Packet_Handle; 390}__attribute__((packed)) QMIWDS_STOP_NETWORK_INTERFACE_REQ_MSG; 391 392typedef struct _QMIWDS_GET_RUNTIME_SETTINGS_REQ_MSG 393{ 394 UInt16 Type; 395 UInt16 Length; 396 UInt8 TLVType; 397 UInt16 TLVLength; 398 UInt32 Mask; 399}__attribute__((packed)) QMIWDS_GET_RUNTIME_SETTINGS_REQ_MSG; 400 401typedef struct _QMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV4_ADDR 402{ 403 UInt8 TLVType; 404 UInt16 TLVLength; 405 UInt32 IPV4Address; 406}__attribute__((packed)) QMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV4_ADDR; 407 408typedef struct _QMIWDS_GET_RUNTIME_SETTINGS_RESP_MSG 409{ 410 UInt16 Type; 411 UInt16 Length; 412 UInt8 TLVType; 413 UInt16 TLVLength; 414 UInt16 QMUXResult; 415 UInt16 QMUXError; 416}__attribute__((packed)) QMIWDS_GET_RUNTIME_SETTINGS_RESP_MSG; 417 418#define QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV4 0x1E 419#define QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV6 0x25 420 421#define QMIWDS_GET_RUNTIME_SETTINGS_MASK_IPV4_ADDR 0x0100 422 423 424// qmi error code 425#define QMI_ERR_CALL_FAILED 0x0E 426#define QMI_ERR_AUTHENTICATION_FAILED 0x22 427#define QMI_ERR_NO_NETWORK_FOUND 0x0D 428#define QMI_ERR_IP_FAILED 0xFF01 429 430 431// ethernet headers 432#define ETH_TYPE_ARP 0x0806 433#define ETH_TYPE_IPV4 0x0800 434#define ETH_TYPE_IPV6 0x86DD 435 436#define ETH_LENGTH_OF_ADDRESS 6 437 438typedef struct _QC_ETH_HDR 439{ 440 UInt8 DstMacAddress[ETH_LENGTH_OF_ADDRESS]; 441 UInt8 SrcMacAddress[ETH_LENGTH_OF_ADDRESS]; 442 UInt16 EtherType; 443}__attribute__((packed)) QC_ETH_HDR; 444 445typedef struct _QC_ARP_HDR 446{ 447 UInt16 HardwareType; 448 UInt16 ProtocolType; 449 UInt8 HLEN; 450 UInt8 PLEN; 451 UInt16 Operation; 452 UInt8 SenderHA[ETH_LENGTH_OF_ADDRESS]; 453 UInt32 SenderIP; 454 UInt8 TargetHA[ETH_LENGTH_OF_ADDRESS]; 455 UInt32 TargetIP; 456}__attribute__((packed)) QC_ARP_HDR; 457 458#define kUSBModem_Oper_Flag "ModemOper" 459#define kUSBModem_Connect_APN "APN" 460#define kUSBModem_Connect_UserName "UserName" 461#define kUSBModem_Connect_Password "PassWord" 462#define kUSBModem_Connect_Compression "Compression" 463#define kUSBModem_Connect_Error "ModemConnectionError" 464 465#define QWDS_PKT_DATA_DISCONNECTED 0x01 466#define QWDS_PKT_DATA_CONNECTED 0x02 467#define QWDS_PKT_DATA_SUSPENDED 0x03 468 469enum 470{ 471 WwanAuthProtocolNone = 0x00, 472 WwanAuthProtocolPap = 0x01, 473 WwanAuthProtocolChap = 0x02, 474 WwanAuthProtocolMax = 0xFF 475}; 476 477enum 478{ 479 WwanOperationQueryReady = 0x00, 480 WwanOperationConnect = 0x01, 481 WwanOperationDisconnect = 0x02, 482 WwanOperationState = 0x03, 483 WwanOperationCount = 0x04, 484 WwanOperationMax = 0xFF 485}; 486 487enum 488{ 489 WwanStateDisconnected = 0, 490 WwanStateConnecting = 1, 491 WwanStateConnected = 2, 492 WwanStateDisconnecting = 3 493}; 494 495#define WWAN_STRING_LEN 64 496 497 498typedef struct 499{ 500 char AccessString[WWAN_STRING_LEN]; 501 char UserName[WWAN_STRING_LEN]; 502 char Password[WWAN_STRING_LEN]; 503 UInt32 Commpression; 504 UInt32 ConnectIpMode; 505}__attribute__((packed)) WWAN_CONNECT_PARAMS; 506 507typedef struct _WWAN_FLOW_STATS 508{ 509 UInt32 ConnectState; 510 UInt64 UpLinkBytes; 511 UInt64 DownLinkBytes; 512}__attribute__((packed)) WWAN_FLOW_STATS; 513 514#endif 515