ccmni_pfp.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*****************************************************************************
  2. *
  3. * Filename:
  4. * ---------
  5. * ccmni_pfp.h
  6. *
  7. * Project:
  8. * --------
  9. * YuSu
  10. *
  11. * Description:
  12. * ------------
  13. * MT6516 Cross Chip Modem Network Interface - Packet Framing Protocol
  14. *
  15. * Author:
  16. * -------
  17. * Stanley Chou (mtk01411)
  18. *
  19. ****************************************************************************/
  20. #ifndef __CCCI_CCMNI_PFP_H__
  21. #define __CCCI_CCMNI_PFP_H__
  22. /* Compile Option to decide if DYNAMIC_MULTIPLE_FRAME encode/decode is supported or not */
  23. #define MAX_PDP_CONT_NUM 3
  24. #define PFP_FRAME_START_FLAG 0xF9
  25. #define PFP_FRAME_MAGIC_NUM 0x66
  26. /* MAX_PFP_LEN_FIELD_VALUE is the maximum size of one IP Packet */
  27. #define MAX_PFP_LEN_FIELD_VALUE 1500
  28. #define FREE_RAW_DATA_BUF_SIZE 2048
  29. #define FREE_COOKED_DATA_BUF_SIZE 2048
  30. #define SUPPORT_FRAME_NUM 1
  31. #define SUPPORT_PKT_NUM 1024
  32. enum frame_flag_t {
  33. FRAME_START = 0,
  34. FRAME_CONTINUOUS,
  35. FRAME_END
  36. };
  37. enum unframe_state_t {
  38. PARSE_PFP_FRAME_START_FLAG_STATE = 0,
  39. PARSE_PFP_FRAME_MAGIC_NUM_STATE,
  40. PARSE_PFP_FRAME_LENGTH_FIELD_STATE,
  41. PARSE_PFP_FRAME_GET_DATA_STATE
  42. };
  43. /* Following implementations are designed for PFP(Packet Frame Protocol) */
  44. struct frame_format_t {
  45. int frame_size;
  46. unsigned char *frame_data;
  47. };
  48. struct frame_info_t {
  49. int num_frames;
  50. int pending_data_flag;
  51. int consumed_length;
  52. #ifdef __SUPPORT_DYNAMIC_MULTIPLE_FRAME__
  53. struct frame_format_t *frame_list;
  54. #else
  55. struct frame_format_t frame_list[SUPPORT_FRAME_NUM];
  56. #endif
  57. };
  58. struct complete_ippkt_t {
  59. int pkt_size;
  60. unsigned char *pkt_data;
  61. #ifndef __SUPPORT_DYNAMIC_MULTIPLE_FRAME__
  62. int entry_used;
  63. #endif
  64. struct complete_ippkt_t *next;
  65. };
  66. struct packet_info_t {
  67. int num_complete_packets;
  68. int consumed_length;
  69. int try_decode_again;
  70. enum unframe_state_t parse_data_state;
  71. struct complete_ippkt_t *pkt_list;
  72. };
  73. struct ccmni_record_t {
  74. /* Next expected state to be parsed while entering the pfp_unframe() again */
  75. enum unframe_state_t unframe_state;
  76. /* Record the latest parsed Packet length for getting the data */
  77. int pkt_size;
  78. /* For fast to find the last node of pkt_list to insert a new parsed IP Pkt into this pkt_list */
  79. struct complete_ippkt_t *last_pkt_node;
  80. };
  81. extern struct ccmni_record_t ccmni_dev[];
  82. /* The following buffers are used for testing purpose */
  83. /* Store one IP Packet data */
  84. extern unsigned char frame_cooked_data[];
  85. /* Pack the IP Packet into a Frame sent to Modem */
  86. extern unsigned char frame_raw_data[];
  87. extern unsigned char unframe_raw_data[];
  88. extern unsigned char unframe_cooked_data[];
  89. void pfp_reset(int ccmni_inx);
  90. struct frame_info_t pfp_frame(unsigned char *raw_data, unsigned char *cooked_data,
  91. int cooked_size, int frame_flag, int ccmni_inx);
  92. struct packet_info_t pfp_unframe(unsigned char *cooked_data, int cooked_data_buf_size,
  93. unsigned char *raw_data, int raw_size, int ccmni_inx);
  94. void traverse_pkt_list(struct complete_ippkt_t *node);
  95. #ifndef __SUPPORT_DYNAMIC_MULTIPLE_FRAME__
  96. struct complete_ippkt_t *get_one_available_complete_ippkt_entry(void);
  97. void release_one_used_complete_ippkt_entry(struct complete_ippkt_t *entry);
  98. #endif
  99. #endif /* __CCCI_CCMNI_PFP_H__ */