proto.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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);
  30. int (*set_dcmd)(struct brcmf_pub *drvr, int ifidx, uint cmd, void *buf,
  31. uint len);
  32. int (*txdata)(struct brcmf_pub *drvr, int ifidx, u8 offset,
  33. struct sk_buff *skb);
  34. void (*configure_addr_mode)(struct brcmf_pub *drvr, int ifidx,
  35. enum proto_addr_mode addr_mode);
  36. void (*delete_peer)(struct brcmf_pub *drvr, int ifidx,
  37. u8 peer[ETH_ALEN]);
  38. void (*add_tdls_peer)(struct brcmf_pub *drvr, int ifidx,
  39. u8 peer[ETH_ALEN]);
  40. void (*rxreorder)(struct brcmf_if *ifp, struct sk_buff *skb);
  41. void *pd;
  42. };
  43. int brcmf_proto_attach(struct brcmf_pub *drvr);
  44. void brcmf_proto_detach(struct brcmf_pub *drvr);
  45. static inline int brcmf_proto_hdrpull(struct brcmf_pub *drvr, bool do_fws,
  46. struct sk_buff *skb,
  47. struct brcmf_if **ifp)
  48. {
  49. struct brcmf_if *tmp = NULL;
  50. /* assure protocol is always called with
  51. * non-null initialized pointer.
  52. */
  53. if (ifp)
  54. *ifp = NULL;
  55. else
  56. ifp = &tmp;
  57. return drvr->proto->hdrpull(drvr, do_fws, skb, ifp);
  58. }
  59. static inline int brcmf_proto_query_dcmd(struct brcmf_pub *drvr, int ifidx,
  60. uint cmd, void *buf, uint len)
  61. {
  62. return drvr->proto->query_dcmd(drvr, ifidx, cmd, buf, len);
  63. }
  64. static inline int brcmf_proto_set_dcmd(struct brcmf_pub *drvr, int ifidx,
  65. uint cmd, void *buf, uint len)
  66. {
  67. return drvr->proto->set_dcmd(drvr, ifidx, cmd, buf, len);
  68. }
  69. static inline int brcmf_proto_txdata(struct brcmf_pub *drvr, int ifidx,
  70. u8 offset, struct sk_buff *skb)
  71. {
  72. return drvr->proto->txdata(drvr, ifidx, offset, skb);
  73. }
  74. static inline void
  75. brcmf_proto_configure_addr_mode(struct brcmf_pub *drvr, int ifidx,
  76. enum proto_addr_mode addr_mode)
  77. {
  78. drvr->proto->configure_addr_mode(drvr, ifidx, addr_mode);
  79. }
  80. static inline void
  81. brcmf_proto_delete_peer(struct brcmf_pub *drvr, int ifidx, u8 peer[ETH_ALEN])
  82. {
  83. drvr->proto->delete_peer(drvr, ifidx, peer);
  84. }
  85. static inline void
  86. brcmf_proto_add_tdls_peer(struct brcmf_pub *drvr, int ifidx, u8 peer[ETH_ALEN])
  87. {
  88. drvr->proto->add_tdls_peer(drvr, ifidx, peer);
  89. }
  90. static inline bool brcmf_proto_is_reorder_skb(struct sk_buff *skb)
  91. {
  92. struct brcmf_skb_reorder_data *rd;
  93. rd = (struct brcmf_skb_reorder_data *)skb->cb;
  94. return !!rd->reorder;
  95. }
  96. static inline void
  97. brcmf_proto_rxreorder(struct brcmf_if *ifp, struct sk_buff *skb)
  98. {
  99. ifp->drvr->proto->rxreorder(ifp, skb);
  100. }
  101. #endif /* BRCMFMAC_PROTO_H */