proto.h 3.0 KB

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