caif_dev.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * Copyright (C) ST-Ericsson AB 2010
  3. * Author: Sjur Brendeland
  4. * License terms: GNU General Public License (GPL) version 2
  5. */
  6. #ifndef CAIF_DEV_H_
  7. #define CAIF_DEV_H_
  8. #include <net/caif/caif_layer.h>
  9. #include <net/caif/cfcnfg.h>
  10. #include <net/caif/caif_device.h>
  11. #include <linux/caif/caif_socket.h>
  12. #include <linux/if.h>
  13. #include <linux/net.h>
  14. /**
  15. * struct caif_param - CAIF parameters.
  16. * @size: Length of data
  17. * @data: Binary Data Blob
  18. */
  19. struct caif_param {
  20. u16 size;
  21. u8 data[256];
  22. };
  23. /**
  24. * struct caif_connect_request - Request data for CAIF channel setup.
  25. * @protocol: Type of CAIF protocol to use (at, datagram etc)
  26. * @sockaddr: Socket address to connect.
  27. * @priority: Priority of the connection.
  28. * @link_selector: Link selector (high bandwidth or low latency)
  29. * @ifindex: kernel index of the interface.
  30. * @param: Connect Request parameters (CAIF_SO_REQ_PARAM).
  31. *
  32. * This struct is used when connecting a CAIF channel.
  33. * It contains all CAIF channel configuration options.
  34. */
  35. struct caif_connect_request {
  36. enum caif_protocol_type protocol;
  37. struct sockaddr_caif sockaddr;
  38. enum caif_channel_priority priority;
  39. enum caif_link_selector link_selector;
  40. int ifindex;
  41. struct caif_param param;
  42. };
  43. /**
  44. * caif_connect_client - Connect a client to CAIF Core Stack.
  45. * @config: Channel setup parameters, specifying what address
  46. * to connect on the Modem.
  47. * @client_layer: User implementation of client layer. This layer
  48. * MUST have receive and control callback functions
  49. * implemented.
  50. * @ifindex: Link layer interface index used for this connection.
  51. * @headroom: Head room needed by CAIF protocol.
  52. * @tailroom: Tail room needed by CAIF protocol.
  53. *
  54. * This function connects a CAIF channel. The Client must implement
  55. * the struct cflayer. This layer represents the Client layer and holds
  56. * receive functions and control callback functions. Control callback
  57. * function will receive information about connect/disconnect responses,
  58. * flow control etc (see enum caif_control).
  59. * E.g. CAIF Socket will call this function for each socket it connects
  60. * and have one client_layer instance for each socket.
  61. */
  62. int caif_connect_client(struct net *net,
  63. struct caif_connect_request *conn_req,
  64. struct cflayer *client_layer, int *ifindex,
  65. int *headroom, int *tailroom);
  66. /**
  67. * caif_disconnect_client - Disconnects a client from the CAIF stack.
  68. *
  69. * @client_layer: Client layer to be disconnected.
  70. */
  71. int caif_disconnect_client(struct net *net, struct cflayer *client_layer);
  72. /**
  73. * caif_client_register_refcnt - register ref-count functions provided by client.
  74. *
  75. * @adapt_layer: Client layer using CAIF Stack.
  76. * @hold: Function provided by client layer increasing ref-count
  77. * @put: Function provided by client layer decreasing ref-count
  78. *
  79. * Client of the CAIF Stack must register functions for reference counting.
  80. * These functions are called by the CAIF Stack for every upstream packet,
  81. * and must therefore be implemented efficiently.
  82. *
  83. * Client should call caif_free_client when reference count degrease to zero.
  84. */
  85. void caif_client_register_refcnt(struct cflayer *adapt_layer,
  86. void (*hold)(struct cflayer *lyr),
  87. void (*put)(struct cflayer *lyr));
  88. /**
  89. * caif_free_client - Free memory used to manage the client in the CAIF Stack.
  90. *
  91. * @client_layer: Client layer to be removed.
  92. *
  93. * This function must be called from client layer in order to free memory.
  94. * Caller must guarantee that no packets are in flight upstream when calling
  95. * this function.
  96. */
  97. void caif_free_client(struct cflayer *adap_layer);
  98. /**
  99. * struct caif_enroll_dev - Enroll a net-device as a CAIF Link layer
  100. * @dev: Network device to enroll.
  101. * @caifdev: Configuration information from CAIF Link Layer
  102. * @link_support: Link layer support layer
  103. * @head_room: Head room needed by link support layer
  104. * @layer: Lowest layer in CAIF stack
  105. * @rcv_fun: Receive function for CAIF stack.
  106. *
  107. * This function enroll a CAIF link layer into CAIF Stack and
  108. * expects the interface to be able to handle CAIF payload.
  109. * The link_support layer is used to add any Link Layer specific
  110. * framing.
  111. */
  112. void caif_enroll_dev(struct net_device *dev, struct caif_dev_common *caifdev,
  113. struct cflayer *link_support, int head_room,
  114. struct cflayer **layer, int (**rcv_func)(
  115. struct sk_buff *, struct net_device *,
  116. struct packet_type *, struct net_device *));
  117. #endif /* CAIF_DEV_H_ */