cfctrl.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * Copyright (C) ST-Ericsson AB 2010
  3. * Author: Sjur Brendeland/sjur.brandeland@stericsson.com
  4. * License terms: GNU General Public License (GPL) version 2
  5. */
  6. #ifndef CFCTRL_H_
  7. #define CFCTRL_H_
  8. #include <net/caif/caif_layer.h>
  9. #include <net/caif/cfsrvl.h>
  10. /* CAIF Control packet commands */
  11. enum cfctrl_cmd {
  12. CFCTRL_CMD_LINK_SETUP = 0,
  13. CFCTRL_CMD_LINK_DESTROY = 1,
  14. CFCTRL_CMD_LINK_ERR = 2,
  15. CFCTRL_CMD_ENUM = 3,
  16. CFCTRL_CMD_SLEEP = 4,
  17. CFCTRL_CMD_WAKE = 5,
  18. CFCTRL_CMD_LINK_RECONF = 6,
  19. CFCTRL_CMD_START_REASON = 7,
  20. CFCTRL_CMD_RADIO_SET = 8,
  21. CFCTRL_CMD_MODEM_SET = 9,
  22. CFCTRL_CMD_MASK = 0xf
  23. };
  24. /* Channel types */
  25. enum cfctrl_srv {
  26. CFCTRL_SRV_DECM = 0,
  27. CFCTRL_SRV_VEI = 1,
  28. CFCTRL_SRV_VIDEO = 2,
  29. CFCTRL_SRV_DBG = 3,
  30. CFCTRL_SRV_DATAGRAM = 4,
  31. CFCTRL_SRV_RFM = 5,
  32. CFCTRL_SRV_UTIL = 6,
  33. CFCTRL_SRV_MASK = 0xf
  34. };
  35. #define CFCTRL_RSP_BIT 0x20
  36. #define CFCTRL_ERR_BIT 0x10
  37. struct cfctrl_rsp {
  38. void (*linksetup_rsp)(struct cflayer *layer, u8 linkid,
  39. enum cfctrl_srv serv, u8 phyid,
  40. struct cflayer *adapt_layer);
  41. void (*linkdestroy_rsp)(struct cflayer *layer, u8 linkid);
  42. void (*linkerror_ind)(void);
  43. void (*enum_rsp)(void);
  44. void (*sleep_rsp)(void);
  45. void (*wake_rsp)(void);
  46. void (*restart_rsp)(void);
  47. void (*radioset_rsp)(void);
  48. void (*reject_rsp)(struct cflayer *layer, u8 linkid,
  49. struct cflayer *client_layer);
  50. };
  51. /* Link Setup Parameters for CAIF-Links. */
  52. struct cfctrl_link_param {
  53. enum cfctrl_srv linktype;/* (T3,T0) Type of Channel */
  54. u8 priority; /* (P4,P0) Priority of the channel */
  55. u8 phyid; /* (U2-U0) Physical interface to connect */
  56. u8 endpoint; /* (E1,E0) Endpoint for data channels */
  57. u8 chtype; /* (H1,H0) Channel-Type, applies to
  58. * VEI, DEBUG */
  59. union {
  60. struct {
  61. u8 connid; /* (D7,D0) Video LinkId */
  62. } video;
  63. struct {
  64. u32 connid; /* (N31,Ngit0) Connection ID used
  65. * for Datagram */
  66. } datagram;
  67. struct {
  68. u32 connid; /* Connection ID used for RFM */
  69. char volume[20]; /* Volume to mount for RFM */
  70. } rfm; /* Configuration for RFM */
  71. struct {
  72. u16 fifosize_kb; /* Psock FIFO size in KB */
  73. u16 fifosize_bufs; /* Psock # signal buffers */
  74. char name[16]; /* Name of the PSOCK service */
  75. u8 params[255]; /* Link setup Parameters> */
  76. u16 paramlen; /* Length of Link Setup
  77. * Parameters */
  78. } utility; /* Configuration for Utility Links (Psock) */
  79. } u;
  80. };
  81. /* This structure is used internally in CFCTRL */
  82. struct cfctrl_request_info {
  83. int sequence_no;
  84. enum cfctrl_cmd cmd;
  85. u8 channel_id;
  86. struct cfctrl_link_param param;
  87. struct cflayer *client_layer;
  88. struct list_head list;
  89. };
  90. struct cfctrl {
  91. struct cfsrvl serv;
  92. struct cfctrl_rsp res;
  93. atomic_t req_seq_no;
  94. atomic_t rsp_seq_no;
  95. struct list_head list;
  96. /* Protects from simultaneous access to first_req list */
  97. spinlock_t info_list_lock;
  98. #ifndef CAIF_NO_LOOP
  99. u8 loop_linkid;
  100. int loop_linkused[256];
  101. /* Protects simultaneous access to loop_linkid and loop_linkused */
  102. spinlock_t loop_linkid_lock;
  103. #endif
  104. };
  105. void cfctrl_enum_req(struct cflayer *cfctrl, u8 physlinkid);
  106. int cfctrl_linkup_request(struct cflayer *cfctrl,
  107. struct cfctrl_link_param *param,
  108. struct cflayer *user_layer);
  109. int cfctrl_linkdown_req(struct cflayer *cfctrl, u8 linkid,
  110. struct cflayer *client);
  111. struct cflayer *cfctrl_create(void);
  112. struct cfctrl_rsp *cfctrl_get_respfuncs(struct cflayer *layer);
  113. int cfctrl_cancel_req(struct cflayer *layr, struct cflayer *adap_layer);
  114. void cfctrl_remove(struct cflayer *layr);
  115. #endif /* CFCTRL_H_ */