pep.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * File: pep.h
  4. *
  5. * Phonet Pipe End Point sockets definitions
  6. *
  7. * Copyright (C) 2008 Nokia Corporation.
  8. */
  9. #ifndef NET_PHONET_PEP_H
  10. #define NET_PHONET_PEP_H
  11. #include <linux/skbuff.h>
  12. #include <net/phonet/phonet.h>
  13. struct pep_sock {
  14. struct pn_sock pn_sk;
  15. /* XXX: union-ify listening vs connected stuff ? */
  16. /* Listening socket stuff: */
  17. struct hlist_head hlist;
  18. /* Connected socket stuff: */
  19. struct sock *listener;
  20. struct sk_buff_head ctrlreq_queue;
  21. #define PNPIPE_CTRLREQ_MAX 10
  22. atomic_t tx_credits;
  23. int ifindex;
  24. u16 peer_type; /* peer type/subtype */
  25. u8 pipe_handle;
  26. u8 rx_credits;
  27. u8 rx_fc; /* RX flow control */
  28. u8 tx_fc; /* TX flow control */
  29. u8 init_enable; /* auto-enable at creation */
  30. u8 aligned;
  31. };
  32. static inline struct pep_sock *pep_sk(struct sock *sk)
  33. {
  34. return (struct pep_sock *)sk;
  35. }
  36. extern const struct proto_ops phonet_stream_ops;
  37. /* Pipe protocol definitions */
  38. struct pnpipehdr {
  39. u8 utid; /* transaction ID */
  40. u8 message_id;
  41. u8 pipe_handle;
  42. union {
  43. u8 state_after_connect; /* connect request */
  44. u8 state_after_reset; /* reset request */
  45. u8 error_code; /* any response */
  46. u8 pep_type; /* status indication */
  47. u8 data0; /* anything else */
  48. };
  49. u8 data[];
  50. };
  51. #define other_pep_type data[0]
  52. static inline struct pnpipehdr *pnp_hdr(struct sk_buff *skb)
  53. {
  54. return (struct pnpipehdr *)skb_transport_header(skb);
  55. }
  56. #define MAX_PNPIPE_HEADER (MAX_PHONET_HEADER + 4)
  57. enum {
  58. PNS_PIPE_CREATE_REQ = 0x00,
  59. PNS_PIPE_CREATE_RESP,
  60. PNS_PIPE_REMOVE_REQ,
  61. PNS_PIPE_REMOVE_RESP,
  62. PNS_PIPE_DATA = 0x20,
  63. PNS_PIPE_ALIGNED_DATA,
  64. PNS_PEP_CONNECT_REQ = 0x40,
  65. PNS_PEP_CONNECT_RESP,
  66. PNS_PEP_DISCONNECT_REQ,
  67. PNS_PEP_DISCONNECT_RESP,
  68. PNS_PEP_RESET_REQ,
  69. PNS_PEP_RESET_RESP,
  70. PNS_PEP_ENABLE_REQ,
  71. PNS_PEP_ENABLE_RESP,
  72. PNS_PEP_CTRL_REQ,
  73. PNS_PEP_CTRL_RESP,
  74. PNS_PEP_DISABLE_REQ = 0x4C,
  75. PNS_PEP_DISABLE_RESP,
  76. PNS_PEP_STATUS_IND = 0x60,
  77. PNS_PIPE_CREATED_IND,
  78. PNS_PIPE_RESET_IND = 0x63,
  79. PNS_PIPE_ENABLED_IND,
  80. PNS_PIPE_REDIRECTED_IND,
  81. PNS_PIPE_DISABLED_IND = 0x66,
  82. };
  83. #define PN_PIPE_INVALID_HANDLE 0xff
  84. #define PN_PEP_TYPE_COMMON 0x00
  85. /* Phonet pipe status indication */
  86. enum {
  87. PN_PEP_IND_FLOW_CONTROL,
  88. PN_PEP_IND_ID_MCFC_GRANT_CREDITS,
  89. };
  90. /* Phonet pipe error codes */
  91. enum {
  92. PN_PIPE_NO_ERROR,
  93. PN_PIPE_ERR_INVALID_PARAM,
  94. PN_PIPE_ERR_INVALID_HANDLE,
  95. PN_PIPE_ERR_INVALID_CTRL_ID,
  96. PN_PIPE_ERR_NOT_ALLOWED,
  97. PN_PIPE_ERR_PEP_IN_USE,
  98. PN_PIPE_ERR_OVERLOAD,
  99. PN_PIPE_ERR_DEV_DISCONNECTED,
  100. PN_PIPE_ERR_TIMEOUT,
  101. PN_PIPE_ERR_ALL_PIPES_IN_USE,
  102. PN_PIPE_ERR_GENERAL,
  103. PN_PIPE_ERR_NOT_SUPPORTED,
  104. };
  105. /* Phonet pipe states */
  106. enum {
  107. PN_PIPE_DISABLE,
  108. PN_PIPE_ENABLE,
  109. };
  110. /* Phonet pipe sub-block types */
  111. enum {
  112. PN_PIPE_SB_CREATE_REQ_PEP_SUB_TYPE,
  113. PN_PIPE_SB_CONNECT_REQ_PEP_SUB_TYPE,
  114. PN_PIPE_SB_REDIRECT_REQ_PEP_SUB_TYPE,
  115. PN_PIPE_SB_NEGOTIATED_FC,
  116. PN_PIPE_SB_REQUIRED_FC_TX,
  117. PN_PIPE_SB_PREFERRED_FC_RX,
  118. PN_PIPE_SB_ALIGNED_DATA,
  119. };
  120. /* Phonet pipe flow control models */
  121. enum {
  122. PN_NO_FLOW_CONTROL,
  123. PN_LEGACY_FLOW_CONTROL,
  124. PN_ONE_CREDIT_FLOW_CONTROL,
  125. PN_MULTI_CREDIT_FLOW_CONTROL,
  126. PN_MAX_FLOW_CONTROL,
  127. };
  128. #define pn_flow_safe(fc) ((fc) >> 1)
  129. /* Phonet pipe flow control states */
  130. enum {
  131. PEP_IND_EMPTY,
  132. PEP_IND_BUSY,
  133. PEP_IND_READY,
  134. };
  135. #endif