proto.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*
  2. * Copyright (c) 2013 Broadcom Corporation
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  11. * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  13. * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  14. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef BRCMFMAC_PROTO_H
  17. #define BRCMFMAC_PROTO_H
  18. enum proto_addr_mode {
  19. ADDR_INDIRECT = 0,
  20. ADDR_DIRECT
  21. };
  22. struct brcmf_skb_reorder_data {
  23. u8 *reorder;
  24. };
  25. struct brcmf_proto {
  26. int (*hdrpull)(struct brcmf_pub *drvr, bool do_fws,
  27. struct sk_buff *skb, struct brcmf_if **ifp);
  28. int (*query_dcmd)(struct brcmf_pub *drvr, int ifidx, uint cmd,
  29. void *buf, uint len, int *fwerr);
  30. int (*set_dcmd)(struct brcmf_pub *drvr, int ifidx, uint cmd, void *buf,
  31. uint len, int *fwerr);
  32. int (*tx_queue_data)(struct brcmf_pub *drvr, int ifidx,
  33. struct sk_buff *skb);
  34. int (*txdata)(struct brcmf_pub *drvr, int ifidx, u8 offset,
  35. struct sk_buff *skb);
  36. void (*configure_addr_mode)(struct brcmf_pub *drvr, int ifidx,
  37. enum proto_addr_mode addr_mode);
  38. void (*delete_peer)(struct brcmf_pub *drvr, int ifidx,
  39. u8 peer[ETH_ALEN]);
  40. void (*add_tdls_peer)(struct brcmf_pub *drvr, int ifidx,
  41. u8 peer[ETH_ALEN]);
  42. void (*rxreorder)(struct brcmf_if *ifp, struct sk_buff *skb);
  43. void (*add_if)(struct brcmf_if *ifp);
  44. void (*del_if)(struct brcmf_if *ifp);
  45. void (*reset_if)(struct brcmf_if *ifp);
  46. int (*init_done)(struct brcmf_pub *drvr);
  47. void (*debugfs_create)(struct brcmf_pub *drvr);
  48. void *pd;
  49. };
  50. int brcmf_proto_attach(struct brcmf_pub *drvr);
  51. void brcmf_proto_detach_pre_delif(struct brcmf_pub *drvr);
  52. void brcmf_proto_detach_post_delif(struct brcmf_pub *drvr);
  53. static inline int brcmf_proto_hdrpull(struct brcmf_pub *drvr, bool do_fws,
  54. struct sk_buff *skb,
  55. struct brcmf_if **ifp)
  56. {
  57. struct brcmf_if *tmp = NULL;
  58. /* assure protocol is always called with
  59. * non-null initialized pointer.
  60. */
  61. if (ifp)
  62. *ifp = NULL;
  63. else
  64. ifp = &tmp;
  65. return drvr->proto->hdrpull(drvr, do_fws, skb, ifp);
  66. }
  67. static inline int brcmf_proto_query_dcmd(struct brcmf_pub *drvr, int ifidx,
  68. uint cmd, void *buf, uint len,
  69. int *fwerr)
  70. {
  71. return drvr->proto->query_dcmd(drvr, ifidx, cmd, buf, len,fwerr);
  72. }
  73. static inline int brcmf_proto_set_dcmd(struct brcmf_pub *drvr, int ifidx,
  74. uint cmd, void *buf, uint len,
  75. int *fwerr)
  76. {
  77. return drvr->proto->set_dcmd(drvr, ifidx, cmd, buf, len, fwerr);
  78. }
  79. static inline int brcmf_proto_tx_queue_data(struct brcmf_pub *drvr, int ifidx,
  80. struct sk_buff *skb)
  81. {
  82. return drvr->proto->tx_queue_data(drvr, ifidx, skb);
  83. }
  84. static inline int brcmf_proto_txdata(struct brcmf_pub *drvr, int ifidx,
  85. u8 offset, struct sk_buff *skb)
  86. {
  87. return drvr->proto->txdata(drvr, ifidx, offset, skb);
  88. }
  89. static inline void
  90. brcmf_proto_configure_addr_mode(struct brcmf_pub *drvr, int ifidx,
  91. enum proto_addr_mode addr_mode)
  92. {
  93. drvr->proto->configure_addr_mode(drvr, ifidx, addr_mode);
  94. }
  95. static inline void
  96. brcmf_proto_delete_peer(struct brcmf_pub *drvr, int ifidx, u8 peer[ETH_ALEN])
  97. {
  98. drvr->proto->delete_peer(drvr, ifidx, peer);
  99. }
  100. static inline void
  101. brcmf_proto_add_tdls_peer(struct brcmf_pub *drvr, int ifidx, u8 peer[ETH_ALEN])
  102. {
  103. drvr->proto->add_tdls_peer(drvr, ifidx, peer);
  104. }
  105. static inline bool brcmf_proto_is_reorder_skb(struct sk_buff *skb)
  106. {
  107. struct brcmf_skb_reorder_data *rd;
  108. rd = (struct brcmf_skb_reorder_data *)skb->cb;
  109. return !!rd->reorder;
  110. }
  111. static inline void
  112. brcmf_proto_rxreorder(struct brcmf_if *ifp, struct sk_buff *skb)
  113. {
  114. ifp->drvr->proto->rxreorder(ifp, skb);
  115. }
  116. static inline void
  117. brcmf_proto_add_if(struct brcmf_pub *drvr, struct brcmf_if *ifp)
  118. {
  119. if (!drvr->proto->add_if)
  120. return;
  121. drvr->proto->add_if(ifp);
  122. }
  123. static inline void
  124. brcmf_proto_del_if(struct brcmf_pub *drvr, struct brcmf_if *ifp)
  125. {
  126. if (!drvr->proto->del_if)
  127. return;
  128. drvr->proto->del_if(ifp);
  129. }
  130. static inline void
  131. brcmf_proto_reset_if(struct brcmf_pub *drvr, struct brcmf_if *ifp)
  132. {
  133. if (!drvr->proto->reset_if)
  134. return;
  135. drvr->proto->reset_if(ifp);
  136. }
  137. static inline int
  138. brcmf_proto_init_done(struct brcmf_pub *drvr)
  139. {
  140. if (!drvr->proto->init_done)
  141. return 0;
  142. return drvr->proto->init_done(drvr);
  143. }
  144. static inline void
  145. brcmf_proto_debugfs_create(struct brcmf_pub *drvr)
  146. {
  147. drvr->proto->debugfs_create(drvr);
  148. }
  149. #endif /* BRCMFMAC_PROTO_H */