/drivers/staging/brcm80211/brcmfmac/bcmcdc.h

https://bitbucket.org/wisechild/galaxy-nexus · C++ Header · 98 lines · 50 code · 16 blank · 32 comment · 0 complexity · 8ebd4d2fbf5303c9912fc2e128d24a0a MD5 · raw file

  1. /*
  2. * Copyright (c) 2010 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. #include <linux/if_ether.h>
  17. typedef struct cdc_ioctl {
  18. u32 cmd; /* ioctl command value */
  19. u32 len; /* lower 16: output buflen; upper 16:
  20. input buflen (excludes header) */
  21. u32 flags; /* flag defns given below */
  22. u32 status; /* status code returned from the device */
  23. } cdc_ioctl_t;
  24. /* Max valid buffer size that can be sent to the dongle */
  25. #define CDC_MAX_MSG_SIZE (ETH_FRAME_LEN+ETH_FCS_LEN)
  26. /* len field is divided into input and output buffer lengths */
  27. #define CDCL_IOC_OUTLEN_MASK 0x0000FFFF /* maximum or expected
  28. response length, */
  29. /* excluding IOCTL header */
  30. #define CDCL_IOC_OUTLEN_SHIFT 0
  31. #define CDCL_IOC_INLEN_MASK 0xFFFF0000 /* input buffer length,
  32. excluding IOCTL header */
  33. #define CDCL_IOC_INLEN_SHIFT 16
  34. /* CDC flag definitions */
  35. #define CDCF_IOC_ERROR 0x01 /* 0=success, 1=ioctl cmd failed */
  36. #define CDCF_IOC_SET 0x02 /* 0=get, 1=set cmd */
  37. #define CDCF_IOC_IF_MASK 0xF000 /* I/F index */
  38. #define CDCF_IOC_IF_SHIFT 12
  39. #define CDCF_IOC_ID_MASK 0xFFFF0000 /* used to uniquely id an ioctl
  40. req/resp pairing */
  41. #define CDCF_IOC_ID_SHIFT 16 /* # of bits of shift for ID Mask */
  42. #define CDC_IOC_IF_IDX(flags) \
  43. (((flags) & CDCF_IOC_IF_MASK) >> CDCF_IOC_IF_SHIFT)
  44. #define CDC_IOC_ID(flags) \
  45. (((flags) & CDCF_IOC_ID_MASK) >> CDCF_IOC_ID_SHIFT)
  46. #define CDC_GET_IF_IDX(hdr) \
  47. ((int)((((hdr)->flags) & CDCF_IOC_IF_MASK) >> CDCF_IOC_IF_SHIFT))
  48. #define CDC_SET_IF_IDX(hdr, idx) \
  49. ((hdr)->flags = (((hdr)->flags & ~CDCF_IOC_IF_MASK) | \
  50. ((idx) << CDCF_IOC_IF_SHIFT)))
  51. /*
  52. * BDC header
  53. *
  54. * The BDC header is used on data packets to convey priority across USB.
  55. */
  56. #define BDC_HEADER_LEN 4
  57. #define BDC_PROTO_VER 1 /* Protocol version */
  58. #define BDC_FLAG_VER_MASK 0xf0 /* Protocol version mask */
  59. #define BDC_FLAG_VER_SHIFT 4 /* Protocol version shift */
  60. #define BDC_FLAG__UNUSED 0x03 /* Unassigned */
  61. #define BDC_FLAG_SUM_GOOD 0x04 /* Dongle has verified good
  62. RX checksums */
  63. #define BDC_FLAG_SUM_NEEDED 0x08 /* Dongle needs to do TX checksums */
  64. #define BDC_PRIORITY_MASK 0x7
  65. #define BDC_FLAG2_FC_FLAG 0x10 /* flag to indicate if pkt contains */
  66. /* FLOW CONTROL info only */
  67. #define BDC_PRIORITY_FC_SHIFT 4 /* flow control info shift */
  68. #define BDC_FLAG2_IF_MASK 0x0f /* APSTA: interface on which the
  69. packet was received */
  70. #define BDC_FLAG2_IF_SHIFT 0
  71. #define BDC_GET_IF_IDX(hdr) \
  72. ((int)((((hdr)->flags2) & BDC_FLAG2_IF_MASK) >> BDC_FLAG2_IF_SHIFT))
  73. #define BDC_SET_IF_IDX(hdr, idx) \
  74. ((hdr)->flags2 = (((hdr)->flags2 & ~BDC_FLAG2_IF_MASK) | \
  75. ((idx) << BDC_FLAG2_IF_SHIFT)))
  76. struct bdc_header {
  77. u8 flags; /* Flags */
  78. u8 priority; /* 802.1d Priority 0:2 bits, 4:7 flow
  79. control info for usb */
  80. u8 flags2;
  81. u8 rssi;
  82. };