Linux LITE MBIM  MBPL_SDK_R25_ENG3
MbimTransport.h
Go to the documentation of this file.
1 
6 #ifndef __MBIM_TRANSPORT_H__
7 #define __MBIM_TRANSPORT_H__
8 
9 
10 #include <stdint.h>
11 #include <pthread.h>
12 #include "MbimIndicator.h"
13 #include "MbimTransaction.h"
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 
20 #define MBIM_UUID_SIZE 16
22 #define MBIM_MAX_CIDS 64
24 // TODO: determine at runtime by quering USB descriptor or ioctl to driver.
25 #define MBIM_MAX_CTRL_TRANSFER 4096
28 #define MBIM_COMMAND_TYPE_QUERY 0
29 #define MBIM_COMMAND_TYPE_SET 1
31 #define MBIM_STATUS_SUCCESS 0
32 #define MBIM_STATUS_FAILURE 2
33 #define MBIM_STATUS_INVALID_PARAMETERS 21
34 #define MBIM_STATUS_READ_FAILURE 22
35 #define MBIM_STATUS_WRITE_FAILURE 23
36 #define MBIM_STATUS_CUSTOM_BUILD_FAILURE 0xfffffff0
37 #define MBIM_STATUS_CUSTOM_PARSE_FAILURE 0xfffffff1
44 typedef enum
45 {
46  MBIM_TRANSPORT_ERR_UNKNOWN, // Unknown error type
47  MBIM_TRANSPORT_ERR_READ, // Error occurred during read() operation
48  MBIM_TRANSPORT_ERR_WRITE, // Error occurred during write() operation
50 
62 typedef struct
63 {
64  MBIM_TRANSPORT_ERR_TYPE err_type;
65  int errno_val;
67 
79 typedef void (*MBIM_TRANSPORT_ERR_CALLBACK)(void * pErrCallbackContext, MBIM_TRANSPORT_ERR_INFO err_info);
80 
136 typedef struct MbimTransport
137 {
138  int deviceFd; // FD of device.
139  bool devRemoved; // Flag indicating device has been removed.
140 #ifndef EVENT_FD_UNSUPPORTED
141  int shutdownFd; // FD of shutdown event.
142 #else
143  int shutdownFd[2]; // FDs of shutdown pipe.
144 #endif
145  pthread_mutex_t writeLock; // Protect write operations.
146  pthread_t readThread;
147  uint32_t transactionId;
148  pthread_mutex_t transactionIdLock;
149  MbimTransaction* transactionList; // Head of list of outstanding transactions.
150  pthread_mutex_t transactionListLock;
151  struct MultiFragmentMessage* pIncomingMessage; // Workspace to assemble incoming fragments.
152  MbimIndicator* indicatorList; // Head of list of indicators.
153  pthread_mutex_t indicatorListLock;
154  MBIM_TRANSPORT_ERR_CALLBACK pErrCallback;
155  void * pErrCallbackContext;
156  int initRetry;
157  time_t timeOut;
158 } MbimTransport;
159 
174 int MbimTransport_Initialize(MbimTransport* pThis, char *devicePath, uint32_t maxExpectedInformationLength);
175 
184 
204  MbimTransport* pThis,
205  const uint8_t* deviceServiceId,
206  uint32_t cid,
207  uint32_t commandType,
208  uint8_t* informationBuffer,
209  uint16_t informationBufferLength,
210  MbimTransaction* pTransaction
211  );
212 
222 
231 void MbimTransport_CancelTransaction(MbimTransport* pThis, uint32_t transactionId);
232 
242 
252 
265 typedef uint32_t (*MBIM_PARSE_CALLBACK)(
266  uint8_t* informationBuffer,
267  uint32_t informationBufferLength,
268  void* pParseCallbackContext
269  );
270 
292  MbimTransport* pTransport,
293  const uint8_t* deviceService,
294  uint32_t cid,
295  uint32_t commandType,
296  uint8_t* informationBuffer,
297  uint16_t informationBufferLength,
298  MBIM_PARSE_CALLBACK pParseCallback,
299  void* pParseCallbackContext,
300  time_t timeout
301 );
302 
318  MbimTransport * pThis,
319  MBIM_TRANSPORT_ERR_CALLBACK pErrCallback,
320  void * pErrCallbackContext
321 );
322 
323 #ifdef __cplusplus
324 } /* extern "C" { */
325 #endif
326 
327 #endif //__MBIM_TRANSPORT_H__
MBIM_TRANSPORT_ERR_TYPE
Definition: MbimTransport.h:44
void MbimTransport_ShutDown(MbimTransport *pThis)
void(* MBIM_TRANSPORT_ERR_CALLBACK)(void *pErrCallbackContext, MBIM_TRANSPORT_ERR_INFO err_info)
Definition: MbimTransport.h:79
struct MbimTransport MbimTransport
Definition: MbimTransport.h:136
void MbimTransport_AttachIndicator(MbimTransport *pThis, MbimIndicator *pIndicator)
void MbimTransport_DetachIndicator(MbimTransport *pThis, MbimIndicator *pIndicator)
Definition: MbimTransport.h:62
Definition: MbimTransaction.h:72
uint32_t(* MBIM_PARSE_CALLBACK)(uint8_t *informationBuffer, uint32_t informationBufferLength, void *pParseCallbackContext)
Definition: MbimTransport.h:265
Definition: MbimIndicator.h:62
uint32_t MbimTransport_ExecuteCommandSynchronously(MbimTransport *pTransport, const uint8_t *deviceService, uint32_t cid, uint32_t commandType, uint8_t *informationBuffer, uint16_t informationBufferLength, MBIM_PARSE_CALLBACK pParseCallback, void *pParseCallbackContext, time_t timeout)
int MbimTransport_SendCommand(MbimTransport *pThis, const uint8_t *deviceServiceId, uint32_t cid, uint32_t commandType, uint8_t *informationBuffer, uint16_t informationBufferLength, MbimTransaction *pTransaction)
int MbimTransport_Initialize(MbimTransport *pThis, char *devicePath, uint32_t maxExpectedInformationLength)
void MbimTransport_RegisterErrCallback(MbimTransport *pThis, MBIM_TRANSPORT_ERR_CALLBACK pErrCallback, void *pErrCallbackContext)
void MbimTransport_CancelTransaction(MbimTransport *pThis, uint32_t transactionId)
uint32_t MbimTransport_GetNextTransactionId(MbimTransport *pThis)

Copyright (c) 2011-2020 Sierra Wireless, Inc. All rights reserved