association.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Wireless USB - Cable Based Association
  4. *
  5. * Copyright (C) 2006 Intel Corporation
  6. * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License version
  10. * 2 as published by the Free Software Foundation.
  11. *
  12. */
  13. #ifndef __LINUX_USB_ASSOCIATION_H
  14. #define __LINUX_USB_ASSOCIATION_H
  15. /*
  16. * Association attributes
  17. *
  18. * Association Models Supplement to WUSB 1.0 T[3-1]
  19. *
  20. * Each field in the structures has it's ID, it's length and then the
  21. * value. This is the actual definition of the field's ID and its
  22. * length.
  23. */
  24. struct wusb_am_attr {
  25. __u8 id;
  26. __u8 len;
  27. };
  28. /* Different fields defined by the spec */
  29. #define WUSB_AR_AssociationTypeId { .id = cpu_to_le16(0x0000), .len = cpu_to_le16(2) }
  30. #define WUSB_AR_AssociationSubTypeId { .id = cpu_to_le16(0x0001), .len = cpu_to_le16(2) }
  31. #define WUSB_AR_Length { .id = cpu_to_le16(0x0002), .len = cpu_to_le16(4) }
  32. #define WUSB_AR_AssociationStatus { .id = cpu_to_le16(0x0004), .len = cpu_to_le16(4) }
  33. #define WUSB_AR_LangID { .id = cpu_to_le16(0x0008), .len = cpu_to_le16(2) }
  34. #define WUSB_AR_DeviceFriendlyName { .id = cpu_to_le16(0x000b), .len = cpu_to_le16(64) } /* max */
  35. #define WUSB_AR_HostFriendlyName { .id = cpu_to_le16(0x000c), .len = cpu_to_le16(64) } /* max */
  36. #define WUSB_AR_CHID { .id = cpu_to_le16(0x1000), .len = cpu_to_le16(16) }
  37. #define WUSB_AR_CDID { .id = cpu_to_le16(0x1001), .len = cpu_to_le16(16) }
  38. #define WUSB_AR_ConnectionContext { .id = cpu_to_le16(0x1002), .len = cpu_to_le16(48) }
  39. #define WUSB_AR_BandGroups { .id = cpu_to_le16(0x1004), .len = cpu_to_le16(2) }
  40. /* CBAF Control Requests (AMS1.0[T4-1] */
  41. enum {
  42. CBAF_REQ_GET_ASSOCIATION_INFORMATION = 0x01,
  43. CBAF_REQ_GET_ASSOCIATION_REQUEST,
  44. CBAF_REQ_SET_ASSOCIATION_RESPONSE
  45. };
  46. /*
  47. * CBAF USB-interface defitions
  48. *
  49. * No altsettings, one optional interrupt endpoint.
  50. */
  51. enum {
  52. CBAF_IFACECLASS = 0xef,
  53. CBAF_IFACESUBCLASS = 0x03,
  54. CBAF_IFACEPROTOCOL = 0x01,
  55. };
  56. /* Association Information (AMS1.0[T4-3]) */
  57. struct wusb_cbaf_assoc_info {
  58. __le16 Length;
  59. __u8 NumAssociationRequests;
  60. __le16 Flags;
  61. __u8 AssociationRequestsArray[];
  62. } __attribute__((packed));
  63. /* Association Request (AMS1.0[T4-4]) */
  64. struct wusb_cbaf_assoc_request {
  65. __u8 AssociationDataIndex;
  66. __u8 Reserved;
  67. __le16 AssociationTypeId;
  68. __le16 AssociationSubTypeId;
  69. __le32 AssociationTypeInfoSize;
  70. } __attribute__((packed));
  71. enum {
  72. AR_TYPE_WUSB = 0x0001,
  73. AR_TYPE_WUSB_RETRIEVE_HOST_INFO = 0x0000,
  74. AR_TYPE_WUSB_ASSOCIATE = 0x0001,
  75. };
  76. /* Association Attribute header (AMS1.0[3.8]) */
  77. struct wusb_cbaf_attr_hdr {
  78. __le16 id;
  79. __le16 len;
  80. } __attribute__((packed));
  81. /* Host Info (AMS1.0[T4-7]) (yeah, more headers and fields...) */
  82. struct wusb_cbaf_host_info {
  83. struct wusb_cbaf_attr_hdr AssociationTypeId_hdr;
  84. __le16 AssociationTypeId;
  85. struct wusb_cbaf_attr_hdr AssociationSubTypeId_hdr;
  86. __le16 AssociationSubTypeId;
  87. struct wusb_cbaf_attr_hdr CHID_hdr;
  88. struct wusb_ckhdid CHID;
  89. struct wusb_cbaf_attr_hdr LangID_hdr;
  90. __le16 LangID;
  91. struct wusb_cbaf_attr_hdr HostFriendlyName_hdr;
  92. __u8 HostFriendlyName[];
  93. } __attribute__((packed));
  94. /* Device Info (AMS1.0[T4-8])
  95. *
  96. * I still don't get this tag'n'header stuff for each goddamn
  97. * field...
  98. */
  99. struct wusb_cbaf_device_info {
  100. struct wusb_cbaf_attr_hdr Length_hdr;
  101. __le32 Length;
  102. struct wusb_cbaf_attr_hdr CDID_hdr;
  103. struct wusb_ckhdid CDID;
  104. struct wusb_cbaf_attr_hdr BandGroups_hdr;
  105. __le16 BandGroups;
  106. struct wusb_cbaf_attr_hdr LangID_hdr;
  107. __le16 LangID;
  108. struct wusb_cbaf_attr_hdr DeviceFriendlyName_hdr;
  109. __u8 DeviceFriendlyName[];
  110. } __attribute__((packed));
  111. /* Connection Context; CC_DATA - Success case (AMS1.0[T4-9]) */
  112. struct wusb_cbaf_cc_data {
  113. struct wusb_cbaf_attr_hdr AssociationTypeId_hdr;
  114. __le16 AssociationTypeId;
  115. struct wusb_cbaf_attr_hdr AssociationSubTypeId_hdr;
  116. __le16 AssociationSubTypeId;
  117. struct wusb_cbaf_attr_hdr Length_hdr;
  118. __le32 Length;
  119. struct wusb_cbaf_attr_hdr ConnectionContext_hdr;
  120. struct wusb_ckhdid CHID;
  121. struct wusb_ckhdid CDID;
  122. struct wusb_ckhdid CK;
  123. struct wusb_cbaf_attr_hdr BandGroups_hdr;
  124. __le16 BandGroups;
  125. } __attribute__((packed));
  126. /* CC_DATA - Failure case (AMS1.0[T4-10]) */
  127. struct wusb_cbaf_cc_data_fail {
  128. struct wusb_cbaf_attr_hdr AssociationTypeId_hdr;
  129. __le16 AssociationTypeId;
  130. struct wusb_cbaf_attr_hdr AssociationSubTypeId_hdr;
  131. __le16 AssociationSubTypeId;
  132. struct wusb_cbaf_attr_hdr Length_hdr;
  133. __le16 Length;
  134. struct wusb_cbaf_attr_hdr AssociationStatus_hdr;
  135. __u32 AssociationStatus;
  136. } __attribute__((packed));
  137. #endif /* __LINUX_USB_ASSOCIATION_H */