ozpd.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /* -----------------------------------------------------------------------------
  2. * Copyright (c) 2011 Ozmo Inc
  3. * Released under the GNU General Public License Version 2 (GPLv2).
  4. * -----------------------------------------------------------------------------
  5. */
  6. #ifndef _OZPD_H_
  7. #define _OZPD_H_
  8. #include <linux/interrupt.h>
  9. #include "ozeltbuf.h"
  10. /* PD state
  11. */
  12. #define OZ_PD_S_IDLE 0x1
  13. #define OZ_PD_S_CONNECTED 0x2
  14. #define OZ_PD_S_SLEEP 0x4
  15. #define OZ_PD_S_STOPPED 0x8
  16. /* Timer event types.
  17. */
  18. #define OZ_TIMER_TOUT 1
  19. #define OZ_TIMER_HEARTBEAT 2
  20. #define OZ_TIMER_STOP 3
  21. /*
  22. *External spinlock variable
  23. */
  24. extern spinlock_t g_polling_lock;
  25. /* Data structure that hold information on a frame for transmisson. This is
  26. * built when the frame is first transmitted and is used to rebuild the frame
  27. * if a re-transmission is required.
  28. */
  29. struct oz_tx_frame {
  30. struct list_head link;
  31. struct list_head elt_list;
  32. struct oz_hdr hdr;
  33. struct sk_buff *skb;
  34. int total_size;
  35. };
  36. struct oz_isoc_stream {
  37. struct list_head link;
  38. u8 ep_num;
  39. u8 frame_num;
  40. u8 nb_units;
  41. int size;
  42. struct sk_buff *skb;
  43. struct oz_hdr *oz_hdr;
  44. };
  45. struct oz_farewell {
  46. struct list_head link;
  47. u8 ep_num;
  48. u8 index;
  49. u8 len;
  50. u8 report[0];
  51. };
  52. /* Data structure that holds information on a specific peripheral device (PD).
  53. */
  54. struct oz_pd {
  55. struct list_head link;
  56. atomic_t ref_count;
  57. u8 mac_addr[ETH_ALEN];
  58. unsigned state;
  59. unsigned state_flags;
  60. unsigned send_flags;
  61. u16 total_apps;
  62. u16 paused_apps;
  63. u8 session_id;
  64. u8 param_rsp_status;
  65. u8 pd_info;
  66. u8 isoc_sent;
  67. u32 last_rx_pkt_num;
  68. u32 last_tx_pkt_num;
  69. struct timespec last_rx_timestamp;
  70. u32 trigger_pkt_num;
  71. unsigned long pulse_time;
  72. unsigned long pulse_period;
  73. unsigned long presleep;
  74. unsigned long keep_alive;
  75. struct oz_elt_buf elt_buff;
  76. void *app_ctx[OZ_NB_APPS];
  77. spinlock_t app_lock[OZ_NB_APPS];
  78. int max_tx_size;
  79. u8 mode;
  80. u8 ms_per_isoc;
  81. unsigned isoc_latency;
  82. unsigned max_stream_buffering;
  83. int nb_queued_frames;
  84. int nb_queued_isoc_frames;
  85. spinlock_t tx_frame_lock;
  86. struct list_head *last_sent_frame;
  87. struct list_head tx_queue;
  88. struct list_head farewell_list;
  89. spinlock_t stream_lock;
  90. struct list_head stream_list;
  91. struct net_device *net_dev;
  92. struct hrtimer heartbeat;
  93. struct hrtimer timeout;
  94. u8 timeout_type;
  95. struct tasklet_struct heartbeat_tasklet;
  96. struct tasklet_struct timeout_tasklet;
  97. struct work_struct workitem;
  98. };
  99. #define OZ_MAX_QUEUED_FRAMES 4
  100. struct oz_pd *oz_pd_alloc(const u8 *mac_addr);
  101. void oz_pd_destroy(struct oz_pd *pd);
  102. void oz_pd_get(struct oz_pd *pd);
  103. void oz_pd_put(struct oz_pd *pd);
  104. void oz_pd_set_state(struct oz_pd *pd, unsigned state);
  105. void oz_pd_indicate_farewells(struct oz_pd *pd);
  106. int oz_pd_sleep(struct oz_pd *pd);
  107. void oz_pd_stop(struct oz_pd *pd);
  108. void oz_pd_heartbeat(struct oz_pd *pd, u16 apps);
  109. int oz_services_start(struct oz_pd *pd, u16 apps, int resume);
  110. void oz_services_stop(struct oz_pd *pd, u16 apps, int pause);
  111. int oz_prepare_frame(struct oz_pd *pd, int empty);
  112. void oz_send_queued_frames(struct oz_pd *pd, int backlog);
  113. void oz_retire_tx_frames(struct oz_pd *pd, u8 lpn);
  114. int oz_isoc_stream_create(struct oz_pd *pd, u8 ep_num);
  115. int oz_isoc_stream_delete(struct oz_pd *pd, u8 ep_num);
  116. int oz_send_isoc_unit(struct oz_pd *pd, u8 ep_num, const u8 *data, int len);
  117. void oz_handle_app_elt(struct oz_pd *pd, u8 app_id, struct oz_elt *elt);
  118. void oz_apps_init(void);
  119. void oz_apps_term(void);
  120. extern struct kmem_cache *oz_elt_info_cache;
  121. extern struct kmem_cache *oz_tx_frame_cache;
  122. #endif /* Sentry */