History

Merge tag 'usb-5.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb

Pull USB updates from Greg KH: "Here is the big set of USB patches for 5.4-rc1. Two major chunks of code are moving out of the tree and into the staging directory, uwb and wusb (wireless USB support), because there are no devices that actually use this protocol anymore, and what we have today probably doesn't work at all given that the maintainers left many many years ago. So move it to staging where it will be removed in a few releases if no one screams. Other than that, lots of little things. The usual gadget and xhci and usb serial driver updates, along with a bunch of sysfs file cleanups due to the driver core changes to support that. Nothing really major, just constant forward progress. All of these have been in linux-next for a while with no reported issues" * tag 'usb-5.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (159 commits) USB: usbcore: Fix slab-out-of-bounds bug during device reset usb: cdns3: Remove redundant dev_err call in cdns3_probe() USB: rio500: Fix lockdep violation USB: rio500: simplify locking usb: mtu3: register a USB Role Switch for dual role mode usb: common: add USB GPIO based connection detection driver usb: common: create Kconfig file usb: roles: get usb-role-switch from parent usb: roles: Add fwnode_usb_role_switch_get() function device connection: Add fwnode_connection_find_match() usb: roles: Introduce stubs for the exiting functions in role.h dt-bindings: usb: mtu3: add properties about USB Role Switch dt-bindings: usb: add binding for USB GPIO based connection detection driver dt-bindings: connector: add optional properties for Type-B dt-binding: usb: add usb-role-switch property usbip: Implement SG support to vhci-hcd and stub driver usb: roles: intel: Enable static DRD mode for role switch xhci-ext-caps.c: Add property to disable Intel SW switch usb: dwc3: remove generic PHY calibrate() calls usb: core: phy: add support for PHY calibration ...

Linus Torvalds committed 7 years ago

Commit c6b48da2 parents 1f7d290 fb9617e310 files · +10289 −2442Browse files

Showing the changes to include/linux (19 of 310 files). Show all

Unified · Split

19 files
  1. include/linux/device.h +7 −3
  2. include/linux/dma-mapping.h +0 −5
  3. include/linux/oxu210hp.h +0 −8
  4. include/linux/platform_data/dwc3-omap.h +0 −43
  5. include/linux/platform_device.h +1 −1
  6. include/linux/usb.h +6 −1
  7. include/linux/usb/association.h +0 −151
  8. include/linux/usb/ch9.h +27 −0
  9. include/linux/usb/gadget.h +3 −0
  10. include/linux/usb/hcd.h +9 −2
  11. include/linux/usb/role.h +37 −0
  12. include/linux/usb/usb338x.h +25 −10
  13. include/linux/usb/wusb-wa.h +0 −304
  14. include/linux/usb/wusb.h +0 −362
  15. include/linux/uwb.h +0 −817
  16. include/linux/uwb/debug-cmd.h +0 −57
  17. include/linux/uwb/spec.h +0 −767
  18. include/linux/uwb/umc.h +0 −192
  19. include/linux/uwb/whci.h +0 −102
include/linux/device.h+7−3
@@ -1014,10 +1014,14 @@ struct device_connection { · 1013 unmodified lines
10141014 struct list_head list;
10151015 };
10161016
1017+typedef void *(*devcon_match_fn_t)(struct device_connection *con, int ep,
1018+ void *data);
1019+
1020+void *fwnode_connection_find_match(struct fwnode_handle *fwnode,
1021+ const char *con_id, void *data,
1022+ devcon_match_fn_t match);
10171023 void *device_connection_find_match(struct device *dev, const char *con_id,
1018− void *data,
1019− void *(*match)(struct device_connection *con,
1020− int ep, void *data));
1024+ void *data, devcon_match_fn_t match);
10211025
10221026 struct device *device_connection_find(struct device *dev, const char *con_id);
10231027
include/linux/dma-mapping.h+0−5
@@ -149,11 +149,6 @@ static inline int valid_dma_direction(int dma_direction) · 148 unmodified lines
149149 (dma_direction == DMA_FROM_DEVICE));
150150 }
151151
152−static inline int is_device_dma_capable(struct device *dev)
153−{
154− return dev->dma_mask != NULL && *dev->dma_mask != DMA_MASK_NONE;
155−}
156−
157152 #ifdef CONFIG_DMA_DECLARE_COHERENT
158153 /*
159154 * These three functions are only for dma allocator.
include/linux/oxu210hp.h+0−8
@@ -1,8 +0,0 @@
1−/* SPDX-License-Identifier: GPL-2.0 */
2−/* platform data for the OXU210HP HCD */
3−
4−struct oxu210hp_platform_data {
5− unsigned int bus16:1;
6− unsigned int use_hcd_otg:1;
7− unsigned int use_hcd_sph:1;
8−};
include/linux/platform_data/dwc3-omap.h+0−43
@@ -1,43 +0,0 @@
1−/**
2− * dwc3-omap.h - OMAP Specific Glue layer, header.
3− *
4− * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com
5− * All rights reserved.
6− *
7− * Author: Felipe Balbi <balbi@ti.com>
8− *
9− * Redistribution and use in source and binary forms, with or without
10− * modification, are permitted provided that the following conditions
11− * are met:
12− * 1. Redistributions of source code must retain the above copyright
13− * notice, this list of conditions, and the following disclaimer,
14− * without modification.
15− * 2. Redistributions in binary form must reproduce the above copyright
16− * notice, this list of conditions and the following disclaimer in the
17− * documentation and/or other materials provided with the distribution.
18− * 3. The names of the above-listed copyright holders may not be used
19− * to endorse or promote products derived from this software without
20− * specific prior written permission.
21− *
22− * ALTERNATIVELY, this software may be distributed under the terms of the
23− * GNU General Public License ("GPL") version 2, as published by the Free
24− * Software Foundation.
25− *
26− * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
27− * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
28− * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29− * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
30− * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31− * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32− * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33− * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34− * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35− * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36− * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37− */
38−
39−enum dwc3_omap_utmi_mode {
40− DWC3_OMAP_UTMI_MODE_UNKNOWN = 0,
41− DWC3_OMAP_UTMI_MODE_HW,
42− DWC3_OMAP_UTMI_MODE_SW,
43−};
include/linux/platform_device.h+1−1
@@ -24,6 +24,7 @@ struct platform_device { · 23 unmodified lines
2424 int id;
2525 bool id_auto;
2626 struct device dev;
27+ u64 dma_mask;
2728 u32 num_resources;
2829 struct resource *resource;
2930
@@ -48,7 +49,6 @@ extern void platform_device_unregister(struct platform_device *); · 18 unmodified lines
4849 extern struct bus_type platform_bus_type;
4950 extern struct device platform_bus;
5051
51−extern void arch_setup_pdev_archdata(struct platform_device *);
5252 extern struct resource *platform_get_resource(struct platform_device *,
5353 unsigned int, unsigned int);
5454 extern struct device *
include/linux/usb.h+6−1
@@ -426,7 +426,6 @@ struct usb_bus { · 425 unmodified lines
426426 struct device *sysdev; /* as seen from firmware or bus */
427427 int busnum; /* Bus number (in order of reg) */
428428 const char *bus_name; /* stable id (PCI slot_name etc) */
429− u8 uses_dma; /* Does the host controller use DMA? */
430429 u8 uses_pio_for_control; /*
431430 * Does the host controller use PIO
432431 * for control transfers?
@@ -1151,6 +1150,8 @@ struct usbdrv_wrap { · 718 unmodified lines
11511150 * @id_table: USB drivers use ID table to support hotplugging.
11521151 * Export this with MODULE_DEVICE_TABLE(usb,...). This must be set
11531152 * or your driver's probe function will never get called.
1153+ * @dev_groups: Attributes attached to the device that will be created once it
1154+ * is bound to the driver.
11541155 * @dynids: used internally to hold the list of dynamically added device
11551156 * ids for this driver.
11561157 * @drvwrap: Driver-model core structure wrapper.
@@ -1198,6 +1199,7 @@ struct usb_driver { · 41 unmodified lines
11981199 int (*post_reset)(struct usb_interface *intf);
11991200
12001201 const struct usb_device_id *id_table;
1202+ const struct attribute_group **dev_groups;
12011203
12021204 struct usb_dynids dynids;
12031205 struct usbdrv_wrap drvwrap;
@@ -1221,6 +1223,8 @@ struct usb_driver { · 17 unmodified lines
12211223 * module is being unloaded.
12221224 * @suspend: Called when the device is going to be suspended by the system.
12231225 * @resume: Called when the device is being resumed by the system.
1226+ * @dev_groups: Attributes attached to the device that will be created once it
1227+ * is bound to the driver.
12241228 * @drvwrap: Driver-model core structure wrapper.
12251229 * @supports_autosuspend: if set to 0, the USB core will not allow autosuspend
12261230 * for devices bound to this driver.
@@ -1235,6 +1239,7 @@ struct usb_device_driver { · 8 unmodified lines
12351239
12361240 int (*suspend) (struct usb_device *udev, pm_message_t message);
12371241 int (*resume) (struct usb_device *udev, pm_message_t message);
1242+ const struct attribute_group **dev_groups;
12381243 struct usbdrv_wrap drvwrap;
12391244 unsigned int supports_autosuspend:1;
12401245 };
include/linux/usb/association.h+0−151
@@ -1,151 +0,0 @@
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−
17−/*
18− * Association attributes
19− *
20− * Association Models Supplement to WUSB 1.0 T[3-1]
21− *
22− * Each field in the structures has it's ID, it's length and then the
23− * value. This is the actual definition of the field's ID and its
24− * length.
25− */
26−struct wusb_am_attr {
27− __u8 id;
28− __u8 len;
29−};
30−
31−/* Different fields defined by the spec */
32−#define WUSB_AR_AssociationTypeId { .id = cpu_to_le16(0x0000), .len = cpu_to_le16(2) }
33−#define WUSB_AR_AssociationSubTypeId { .id = cpu_to_le16(0x0001), .len = cpu_to_le16(2) }
34−#define WUSB_AR_Length { .id = cpu_to_le16(0x0002), .len = cpu_to_le16(4) }
35−#define WUSB_AR_AssociationStatus { .id = cpu_to_le16(0x0004), .len = cpu_to_le16(4) }
36−#define WUSB_AR_LangID { .id = cpu_to_le16(0x0008), .len = cpu_to_le16(2) }
37−#define WUSB_AR_DeviceFriendlyName { .id = cpu_to_le16(0x000b), .len = cpu_to_le16(64) } /* max */
38−#define WUSB_AR_HostFriendlyName { .id = cpu_to_le16(0x000c), .len = cpu_to_le16(64) } /* max */
39−#define WUSB_AR_CHID { .id = cpu_to_le16(0x1000), .len = cpu_to_le16(16) }
40−#define WUSB_AR_CDID { .id = cpu_to_le16(0x1001), .len = cpu_to_le16(16) }
41−#define WUSB_AR_ConnectionContext { .id = cpu_to_le16(0x1002), .len = cpu_to_le16(48) }
42−#define WUSB_AR_BandGroups { .id = cpu_to_le16(0x1004), .len = cpu_to_le16(2) }
43−
44−/* CBAF Control Requests (AMS1.0[T4-1] */
45−enum {
46− CBAF_REQ_GET_ASSOCIATION_INFORMATION = 0x01,
47− CBAF_REQ_GET_ASSOCIATION_REQUEST,
48− CBAF_REQ_SET_ASSOCIATION_RESPONSE
49−};
50−
51−/*
52− * CBAF USB-interface defitions
53− *
54− * No altsettings, one optional interrupt endpoint.
55− */
56−enum {
57− CBAF_IFACECLASS = 0xef,
58− CBAF_IFACESUBCLASS = 0x03,
59− CBAF_IFACEPROTOCOL = 0x01,
60−};
61−
62−/* Association Information (AMS1.0[T4-3]) */
63−struct wusb_cbaf_assoc_info {
64− __le16 Length;
65− __u8 NumAssociationRequests;
66− __le16 Flags;
67− __u8 AssociationRequestsArray[];
68−} __attribute__((packed));
69−
70−/* Association Request (AMS1.0[T4-4]) */
71−struct wusb_cbaf_assoc_request {
72− __u8 AssociationDataIndex;
73− __u8 Reserved;
74− __le16 AssociationTypeId;
75− __le16 AssociationSubTypeId;
76− __le32 AssociationTypeInfoSize;
77−} __attribute__((packed));
78−
79−enum {
80− AR_TYPE_WUSB = 0x0001,
81− AR_TYPE_WUSB_RETRIEVE_HOST_INFO = 0x0000,
82− AR_TYPE_WUSB_ASSOCIATE = 0x0001,
83−};
84−
85−/* Association Attribute header (AMS1.0[3.8]) */
86−struct wusb_cbaf_attr_hdr {
87− __le16 id;
88− __le16 len;
89−} __attribute__((packed));
90−
91−/* Host Info (AMS1.0[T4-7]) (yeah, more headers and fields...) */
92−struct wusb_cbaf_host_info {
93− struct wusb_cbaf_attr_hdr AssociationTypeId_hdr;
94− __le16 AssociationTypeId;
95− struct wusb_cbaf_attr_hdr AssociationSubTypeId_hdr;
96− __le16 AssociationSubTypeId;
97− struct wusb_cbaf_attr_hdr CHID_hdr;
98− struct wusb_ckhdid CHID;
99− struct wusb_cbaf_attr_hdr LangID_hdr;
100− __le16 LangID;
101− struct wusb_cbaf_attr_hdr HostFriendlyName_hdr;
102− __u8 HostFriendlyName[];
103−} __attribute__((packed));
104−
105−/* Device Info (AMS1.0[T4-8])
106− *
107− * I still don't get this tag'n'header stuff for each goddamn
108− * field...
109− */
110−struct wusb_cbaf_device_info {
111− struct wusb_cbaf_attr_hdr Length_hdr;
112− __le32 Length;
113− struct wusb_cbaf_attr_hdr CDID_hdr;
114− struct wusb_ckhdid CDID;
115− struct wusb_cbaf_attr_hdr BandGroups_hdr;
116− __le16 BandGroups;
117− struct wusb_cbaf_attr_hdr LangID_hdr;
118− __le16 LangID;
119− struct wusb_cbaf_attr_hdr DeviceFriendlyName_hdr;
120− __u8 DeviceFriendlyName[];
121−} __attribute__((packed));
122−
123−/* Connection Context; CC_DATA - Success case (AMS1.0[T4-9]) */
124−struct wusb_cbaf_cc_data {
125− struct wusb_cbaf_attr_hdr AssociationTypeId_hdr;
126− __le16 AssociationTypeId;
127− struct wusb_cbaf_attr_hdr AssociationSubTypeId_hdr;
128− __le16 AssociationSubTypeId;
129− struct wusb_cbaf_attr_hdr Length_hdr;
130− __le32 Length;
131− struct wusb_cbaf_attr_hdr ConnectionContext_hdr;
132− struct wusb_ckhdid CHID;
133− struct wusb_ckhdid CDID;
134− struct wusb_ckhdid CK;
135− struct wusb_cbaf_attr_hdr BandGroups_hdr;
136− __le16 BandGroups;
137−} __attribute__((packed));
138−
139−/* CC_DATA - Failure case (AMS1.0[T4-10]) */
140−struct wusb_cbaf_cc_data_fail {
141− struct wusb_cbaf_attr_hdr AssociationTypeId_hdr;
142− __le16 AssociationTypeId;
143− struct wusb_cbaf_attr_hdr AssociationSubTypeId_hdr;
144− __le16 AssociationSubTypeId;
145− struct wusb_cbaf_attr_hdr Length_hdr;
146− __le16 Length;
147− struct wusb_cbaf_attr_hdr AssociationStatus_hdr;
148− __u32 AssociationStatus;
149−} __attribute__((packed));
150−
151−#endif /* __LINUX_USB_ASSOCIATION_H */
include/linux/usb/ch9.h+27−0
@@ -70,4 +70,31 @@ extern enum usb_device_speed usb_get_maximum_speed(struct device *dev); · 69 unmodified lines
7070 */
7171 extern const char *usb_state_string(enum usb_device_state state);
7272
73+#ifdef CONFIG_TRACING
74+/**
75+ * usb_decode_ctrl - Returns human readable representation of control request.
76+ * @str: buffer to return a human-readable representation of control request.
77+ * This buffer should have about 200 bytes.
78+ * @size: size of str buffer.
79+ * @bRequestType: matches the USB bmRequestType field
80+ * @bRequest: matches the USB bRequest field
81+ * @wValue: matches the USB wValue field (CPU byte order)
82+ * @wIndex: matches the USB wIndex field (CPU byte order)
83+ * @wLength: matches the USB wLength field (CPU byte order)
84+ *
85+ * Function returns decoded, formatted and human-readable description of
86+ * control request packet.
87+ *
88+ * The usage scenario for this is for tracepoints, so function as a return
89+ * use the same value as in parameters. This approach allows to use this
90+ * function in TP_printk
91+ *
92+ * Important: wValue, wIndex, wLength parameters before invoking this function
93+ * should be processed by le16_to_cpu macro.
94+ */
95+extern const char *usb_decode_ctrl(char *str, size_t size, __u8 bRequestType,
96+ __u8 bRequest, __u16 wValue, __u16 wIndex,
97+ __u16 wLength);
98+#endif
99+
73100 #endif /* __LINUX_USB_CH9_H */
include/linux/usb/gadget.h+3−0
@@ -291,6 +291,9 @@ struct usb_dcd_config_params { · 290 unmodified lines
291291 #define USB_DEFAULT_U1_DEV_EXIT_LAT 0x01 /* Less then 1 microsec */
292292 __le16 bU2DevExitLat; /* U2 Device exit Latency */
293293 #define USB_DEFAULT_U2_DEV_EXIT_LAT 0x1F4 /* Less then 500 microsec */
294+ __u8 besl_baseline; /* Recommended baseline BESL (0-15) */
295+ __u8 besl_deep; /* Recommended deep BESL (0-15) */
296+#define USB_DEFAULT_BESL_UNSPECIFIED 0xFF /* No recommended value */
294297 };
295298
296299
include/linux/usb/hcd.h+9−2
@@ -256,6 +256,7 @@ struct hc_driver { · 255 unmodified lines
256256
257257 int flags;
258258 #define HCD_MEMORY 0x0001 /* HC regs use memory (else I/O) */
259+#define HCD_DMA 0x0002 /* HC uses DMA */
259260 #define HCD_SHARED 0x0004 /* Two (or more) usb_hcds share HW */
260261 #define HCD_USB11 0x0010 /* USB 1.1 */
261262 #define HCD_USB2 0x0020 /* USB 2.0 */
@@ -422,8 +423,10 @@ static inline bool hcd_periodic_completion_in_progress(struct usb_hcd *hcd, · 160 unmodified lines
422423 return hcd->high_prio_bh.completing_ep == ep;
423424 }
424425
425−#define hcd_uses_dma(hcd) \
426− (IS_ENABLED(CONFIG_HAS_DMA) && (hcd)->self.uses_dma)
426+static inline bool hcd_uses_dma(struct usb_hcd *hcd)
427+{
428+ return IS_ENABLED(CONFIG_HAS_DMA) && (hcd->driver->flags & HCD_DMA);
429+}
427430
428431 extern int usb_hcd_link_urb_to_ep(struct usb_hcd *hcd, struct urb *urb);
429432 extern int usb_hcd_check_unlink_urb(struct usb_hcd *hcd, struct urb *urb,
@@ -594,6 +597,10 @@ extern void usb_ep0_reinit(struct usb_device *); · 164 unmodified lines
594597 #define GetPortStatus HUB_CLASS_REQ(USB_DIR_IN, USB_RT_PORT, USB_REQ_GET_STATUS)
595598 #define SetHubFeature HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_HUB, USB_REQ_SET_FEATURE)
596599 #define SetPortFeature HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, USB_REQ_SET_FEATURE)
600+#define ClearTTBuffer HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, HUB_CLEAR_TT_BUFFER)
601+#define ResetTT HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, HUB_RESET_TT)
602+#define GetTTState HUB_CLASS_REQ(USB_DIR_IN, USB_RT_PORT, HUB_GET_TT_STATE)
603+#define StopTT HUB_CLASS_REQ(USB_DIR_OUT, USB_RT_PORT, HUB_STOP_TT)
597604
598605
599606 /*-------------------------------------------------------------------------*/
include/linux/usb/role.h+37−0
@@ -42,14 +42,51 @@ struct usb_role_switch_desc { · 41 unmodified lines
4242 bool allow_userspace_control;
4343 };
4444
45+
46+#if IS_ENABLED(CONFIG_USB_ROLE_SWITCH)
4547 int usb_role_switch_set_role(struct usb_role_switch *sw, enum usb_role role);
4648 enum usb_role usb_role_switch_get_role(struct usb_role_switch *sw);
4749 struct usb_role_switch *usb_role_switch_get(struct device *dev);
50+struct usb_role_switch *fwnode_usb_role_switch_get(struct fwnode_handle *node);
4851 void usb_role_switch_put(struct usb_role_switch *sw);
4952
5053 struct usb_role_switch *
5154 usb_role_switch_register(struct device *parent,
5255 const struct usb_role_switch_desc *desc);
5356 void usb_role_switch_unregister(struct usb_role_switch *sw);
57+#else
58+static inline int usb_role_switch_set_role(struct usb_role_switch *sw,
59+ enum usb_role role)
60+{
61+ return 0;
62+}
63+
64+static inline enum usb_role usb_role_switch_get_role(struct usb_role_switch *sw)
65+{
66+ return USB_ROLE_NONE;
67+}
68+
69+static inline struct usb_role_switch *usb_role_switch_get(struct device *dev)
70+{
71+ return ERR_PTR(-ENODEV);
72+}
73+
74+static inline struct usb_role_switch *
75+fwnode_usb_role_switch_get(struct fwnode_handle *node)
76+{
77+ return ERR_PTR(-ENODEV);
78+}
79+
80+static inline void usb_role_switch_put(struct usb_role_switch *sw) { }
81+
82+static inline struct usb_role_switch *
83+usb_role_switch_register(struct device *parent,
84+ const struct usb_role_switch_desc *desc)
85+{
86+ return ERR_PTR(-ENODEV);
87+}
88+
89+static inline void usb_role_switch_unregister(struct usb_role_switch *sw) { }
90+#endif
5491
5592 #endif /* __LINUX_USB_ROLE_H */
include/linux/usb/usb338x.h+25−10
@@ -113,7 +113,10 @@ struct usb338x_ll_regs { · 112 unmodified lines
113113 u32 ll_ltssm_ctrl1;
114114 u32 ll_ltssm_ctrl2;
115115 u32 ll_ltssm_ctrl3;
116− u32 unused[2];
116+ u32 unused1;
117+
118+ /* 0x710 */
119+ u32 unused2;
117120 u32 ll_general_ctrl0;
118121 u32 ll_general_ctrl1;
119122 #define PM_U3_AUTO_EXIT 29
@@ -136,29 +139,41 @@ struct usb338x_ll_regs { · 16 unmodified lines
136139 u32 ll_general_ctrl2;
137140 #define SELECT_INVERT_LANE_POLARITY 7
138141 #define FORCE_INVERT_LANE_POLARITY 6
142+
143+ /* 0x720 */
139144 u32 ll_general_ctrl3;
140145 u32 ll_general_ctrl4;
141146 u32 ll_error_gen;
142−} __packed;
147+ u32 unused3;
148+
149+ /* 0x730 */
150+ u32 unused4[4];
143151
144−struct usb338x_ll_lfps_regs {
145− /* offset 0x748 */
152+ /* 0x740 */
153+ u32 unused5[2];
146154 u32 ll_lfps_5;
147155 #define TIMER_LFPS_6US 16
148156 u32 ll_lfps_6;
149157 #define TIMER_LFPS_80US 0
150−} __packed;
151158
152−struct usb338x_ll_tsn_regs {
153− /* offset 0x77C */
159+ /* 0x750 */
160+ u32 unused6[8];
161+
162+ /* 0x770 */
163+ u32 unused7[3];
154164 u32 ll_tsn_counters_2;
155165 #define HOT_TX_NORESET_TS2 24
166+
167+ /* 0x780 */
156168 u32 ll_tsn_counters_3;
157169 #define HOT_RX_RESET_TS2 0
158−} __packed;
170+ u32 unused8[3];
159171
160−struct usb338x_ll_chi_regs {
161− /* offset 0x79C */
172+ /* 0x790 */
173+ u32 unused9;
174+ u32 ll_lfps_timers_2;
175+#define LFPS_TIMERS_2_WORKAROUND_VALUE 0x084d
176+ u32 unused10;
162177 u32 ll_tsn_chicken_bit;
163178 #define RECOVERY_IDLE_TO_RECOVER_FMW 3
164179 } __packed;
include/linux/usb/wusb-wa.h+0−304
@@ -1,304 +0,0 @@
1−// SPDX-License-Identifier: GPL-2.0
2−/*
3− * Wireless USB Wire Adapter constants and structures.
4− *
5− * Copyright (C) 2005-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− * This program is distributed in the hope that it will be useful,
13− * but WITHOUT ANY WARRANTY; without even the implied warranty of
14− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15− * GNU General Public License for more details.
16− *
17− * You should have received a copy of the GNU General Public License
18− * along with this program; if not, write to the Free Software
19− * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20− * 02110-1301, USA.
21− *
22− *
23− * FIXME: docs
24− * FIXME: organize properly, group logically
25− *
26− * All the event structures are defined in uwb/spec.h, as they are
27− * common to the WHCI and WUSB radio control interfaces.
28− *
29− * References:
30− * [WUSB] Wireless Universal Serial Bus Specification, revision 1.0, ch8
31− */
32−#ifndef __LINUX_USB_WUSB_WA_H
33−#define __LINUX_USB_WUSB_WA_H
34−
35−/**
36− * Radio Command Request for the Radio Control Interface
37− *
38− * Radio Control Interface command and event codes are the same as
39− * WHCI, and listed in include/linux/uwb.h:UWB_RC_{CMD,EVT}_*
40− */
41−enum {
42− WA_EXEC_RC_CMD = 40, /* Radio Control command Request */
43−};
44−
45−/* Wireless Adapter Requests ([WUSB] table 8-51) */
46−enum {
47− WUSB_REQ_ADD_MMC_IE = 20,
48− WUSB_REQ_REMOVE_MMC_IE = 21,
49− WUSB_REQ_SET_NUM_DNTS = 22,
50− WUSB_REQ_SET_CLUSTER_ID = 23,
51− WUSB_REQ_SET_DEV_INFO = 24,
52− WUSB_REQ_GET_TIME = 25,
53− WUSB_REQ_SET_STREAM_IDX = 26,
54− WUSB_REQ_SET_WUSB_MAS = 27,
55− WUSB_REQ_CHAN_STOP = 28,
56−};
57−
58−
59−/* Wireless Adapter WUSB Channel Time types ([WUSB] table 8-52) */
60−enum {
61− WUSB_TIME_ADJ = 0,
62− WUSB_TIME_BPST = 1,
63− WUSB_TIME_WUSB = 2,
64−};
65−
66−enum {
67− WA_ENABLE = 0x01,
68− WA_RESET = 0x02,
69− RPIPE_PAUSE = 0x1,
70− RPIPE_STALL = 0x2,
71−};
72−
73−/* Responses from Get Status request ([WUSB] section 8.3.1.6) */
74−enum {
75− WA_STATUS_ENABLED = 0x01,
76− WA_STATUS_RESETTING = 0x02
77−};
78−
79−enum rpipe_crs {
80− RPIPE_CRS_CTL = 0x01,
81− RPIPE_CRS_ISO = 0x02,
82− RPIPE_CRS_BULK = 0x04,
83− RPIPE_CRS_INTR = 0x08
84−};
85−
86−/**
87− * RPipe descriptor ([WUSB] section 8.5.2.11)
88− *
89− * FIXME: explain rpipes
90− */
91−struct usb_rpipe_descriptor {
92− u8 bLength;
93− u8 bDescriptorType;
94− __le16 wRPipeIndex;
95− __le16 wRequests;
96− __le16 wBlocks; /* rw if 0 */
97− __le16 wMaxPacketSize; /* rw */
98− union {
99− u8 dwa_bHSHubAddress; /* rw: DWA. */
100− u8 hwa_bMaxBurst; /* rw: HWA. */
101− };
102− union {
103− u8 dwa_bHSHubPort; /* rw: DWA. */
104− u8 hwa_bDeviceInfoIndex; /* rw: HWA. */
105− };
106− u8 bSpeed; /* rw: xfer rate 'enum uwb_phy_rate' */
107− union {
108− u8 dwa_bDeviceAddress; /* rw: DWA Target device address. */
109− u8 hwa_reserved; /* rw: HWA. */
110− };
111− u8 bEndpointAddress; /* rw: Target EP address */
112− u8 bDataSequence; /* ro: Current Data sequence */
113− __le32 dwCurrentWindow; /* ro */
114− u8 bMaxDataSequence; /* ro?: max supported seq */
115− u8 bInterval; /* rw: */
116− u8 bOverTheAirInterval; /* rw: */
117− u8 bmAttribute; /* ro? */
118− u8 bmCharacteristics; /* ro? enum rpipe_attr, supported xsactions */
119− u8 bmRetryOptions; /* rw? */
120− __le16 wNumTransactionErrors; /* rw */
121−} __attribute__ ((packed));
122−
123−/**
124− * Wire Adapter Notification types ([WUSB] sections 8.4.5 & 8.5.4)
125− *
126− * These are the notifications coming on the notification endpoint of
127− * an HWA and a DWA.
128− */
129−enum wa_notif_type {
130− DWA_NOTIF_RWAKE = 0x91,
131− DWA_NOTIF_PORTSTATUS = 0x92,
132− WA_NOTIF_TRANSFER = 0x93,
133− HWA_NOTIF_BPST_ADJ = 0x94,
134− HWA_NOTIF_DN = 0x95,
135−};
136−
137−/**
138− * Wire Adapter notification header
139− *
140− * Notifications coming from a wire adapter use a common header
141− * defined in [WUSB] sections 8.4.5 & 8.5.4.
142− */
143−struct wa_notif_hdr {
144− u8 bLength;
145− u8 bNotifyType; /* enum wa_notif_type */
146−} __packed;
147−
148−/**
149− * HWA DN Received notification [(WUSB] section 8.5.4.2)
150− *
151− * The DNData is specified in WUSB1.0[7.6]. For each device
152− * notification we received, we just need to dispatch it.
153− *
154− * @dndata: this is really an array of notifications, but all start
155− * with the same header.
156− */
157−struct hwa_notif_dn {
158− struct wa_notif_hdr hdr;
159− u8 bSourceDeviceAddr; /* from errata 2005/07 */
160− u8 bmAttributes;
161− struct wusb_dn_hdr dndata[];
162−} __packed;
163−
164−/* [WUSB] section 8.3.3 */
165−enum wa_xfer_type {
166− WA_XFER_TYPE_CTL = 0x80,
167− WA_XFER_TYPE_BI = 0x81, /* bulk/interrupt */
168− WA_XFER_TYPE_ISO = 0x82,
169− WA_XFER_RESULT = 0x83,
170− WA_XFER_ABORT = 0x84,
171− WA_XFER_ISO_PACKET_INFO = 0xA0,
172− WA_XFER_ISO_PACKET_STATUS = 0xA1,
173−};
174−
175−/* [WUSB] section 8.3.3 */
176−struct wa_xfer_hdr {
177− u8 bLength; /* 0x18 */
178− u8 bRequestType; /* 0x80 WA_REQUEST_TYPE_CTL */
179− __le16 wRPipe; /* RPipe index */
180− __le32 dwTransferID; /* Host-assigned ID */
181− __le32 dwTransferLength; /* Length of data to xfer */
182− u8 bTransferSegment;
183−} __packed;
184−
185−struct wa_xfer_ctl {
186− struct wa_xfer_hdr hdr;
187− u8 bmAttribute;
188− __le16 wReserved;
189− struct usb_ctrlrequest baSetupData;
190−} __packed;
191−
192−struct wa_xfer_bi {
193− struct wa_xfer_hdr hdr;
194− u8 bReserved;
195− __le16 wReserved;
196−} __packed;
197−
198−/* [WUSB] section 8.5.5 */
199−struct wa_xfer_hwaiso {
200− struct wa_xfer_hdr hdr;
201− u8 bReserved;
202− __le16 wPresentationTime;
203− __le32 dwNumOfPackets;
204−} __packed;
205−
206−struct wa_xfer_packet_info_hwaiso {
207− __le16 wLength;
208− u8 bPacketType;
209− u8 bReserved;
210− __le16 PacketLength[0];
211−} __packed;
212−
213−struct wa_xfer_packet_status_len_hwaiso {
214− __le16 PacketLength;
215− __le16 PacketStatus;
216−} __packed;
217−
218−struct wa_xfer_packet_status_hwaiso {
219− __le16 wLength;
220− u8 bPacketType;
221− u8 bReserved;
222− struct wa_xfer_packet_status_len_hwaiso PacketStatus[0];
223−} __packed;
224−
225−/* [WUSB] section 8.3.3.5 */
226−struct wa_xfer_abort {
227− u8 bLength;
228− u8 bRequestType;
229− __le16 wRPipe; /* RPipe index */
230− __le32 dwTransferID; /* Host-assigned ID */
231−} __packed;
232−
233−/**
234− * WA Transfer Complete notification ([WUSB] section 8.3.3.3)
235− *
236− */
237−struct wa_notif_xfer {
238− struct wa_notif_hdr hdr;
239− u8 bEndpoint;
240− u8 Reserved;
241−} __packed;
242−
243−/** Transfer result basic codes [WUSB] table 8-15 */
244−enum {
245− WA_XFER_STATUS_SUCCESS,
246− WA_XFER_STATUS_HALTED,
247− WA_XFER_STATUS_DATA_BUFFER_ERROR,
248− WA_XFER_STATUS_BABBLE,
249− WA_XFER_RESERVED,
250− WA_XFER_STATUS_NOT_FOUND,
251− WA_XFER_STATUS_INSUFFICIENT_RESOURCE,
252− WA_XFER_STATUS_TRANSACTION_ERROR,
253− WA_XFER_STATUS_ABORTED,
254− WA_XFER_STATUS_RPIPE_NOT_READY,
255− WA_XFER_INVALID_FORMAT,
256− WA_XFER_UNEXPECTED_SEGMENT_NUMBER,
257− WA_XFER_STATUS_RPIPE_TYPE_MISMATCH,
258−};
259−
260−/** [WUSB] section 8.3.3.4 */
261−struct wa_xfer_result {
262− struct wa_notif_hdr hdr;
263− __le32 dwTransferID;
264− __le32 dwTransferLength;
265− u8 bTransferSegment;
266− u8 bTransferStatus;
267− __le32 dwNumOfPackets;
268−} __packed;
269−
270−/**
271− * Wire Adapter Class Descriptor ([WUSB] section 8.5.2.7).
272− *
273− * NOTE: u16 fields are read Little Endian from the hardware.
274− *
275− * @bNumPorts is the original max number of devices that the host can
276− * connect; we might chop this so the stack can handle
277− * it. In case you need to access it, use wusbhc->ports_max
278− * if it is a Wireless USB WA.
279− */
280−struct usb_wa_descriptor {
281− u8 bLength;
282− u8 bDescriptorType;
283− __le16 bcdWAVersion;
284− u8 bNumPorts; /* don't use!! */
285− u8 bmAttributes; /* Reserved == 0 */
286− __le16 wNumRPipes;
287− __le16 wRPipeMaxBlock;
288− u8 bRPipeBlockSize;
289− u8 bPwrOn2PwrGood;
290− u8 bNumMMCIEs;
291− u8 DeviceRemovable; /* FIXME: in DWA this is up to 16 bytes */
292−} __packed;
293−
294−/**
295− * HWA Device Information Buffer (WUSB1.0[T8.54])
296− */
297−struct hwa_dev_info {
298− u8 bmDeviceAvailability[32]; /* FIXME: ignored for now */
299− u8 bDeviceAddress;
300− __le16 wPHYRates;
301− u8 bmDeviceAttribute;
302−} __packed;
303−
304−#endif /* #ifndef __LINUX_USB_WUSB_WA_H */
include/linux/usb/wusb.h+0−362
@@ -1,362 +0,0 @@
1−// SPDX-License-Identifier: GPL-2.0
2−/*
3− * Wireless USB Standard Definitions
4− * Event Size Tables
5− *
6− * Copyright (C) 2005-2006 Intel Corporation
7− * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
8− *
9− * This program is free software; you can redistribute it and/or
10− * modify it under the terms of the GNU General Public License version
11− * 2 as published by the Free Software Foundation.
12− *
13− * This program is distributed in the hope that it will be useful,
14− * but WITHOUT ANY WARRANTY; without even the implied warranty of
15− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16− * GNU General Public License for more details.
17− *
18− * You should have received a copy of the GNU General Public License
19− * along with this program; if not, write to the Free Software
20− * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21− * 02110-1301, USA.
22− *
23− *
24− * FIXME: docs
25− * FIXME: organize properly, group logically
26− *
27− * All the event structures are defined in uwb/spec.h, as they are
28− * common to the WHCI and WUSB radio control interfaces.
29− */
30−
31−#ifndef __WUSB_H__
32−#define __WUSB_H__
33−
34−#include <linux/types.h>
35−#include <linux/kernel.h>
36−#include <linux/uwb/spec.h>
37−#include <linux/usb/ch9.h>
38−#include <linux/param.h>
39−
40−/**
41− * WUSB Information Element header
42− *
43− * I don't know why, they decided to make it different to the MBOA MAC
44− * IE Header; beats me.
45− */
46−struct wuie_hdr {
47− u8 bLength;
48− u8 bIEIdentifier;
49−} __attribute__((packed));
50−
51−enum {
52− WUIE_ID_WCTA = 0x80,
53− WUIE_ID_CONNECTACK,
54− WUIE_ID_HOST_INFO,
55− WUIE_ID_CHANGE_ANNOUNCE,
56− WUIE_ID_DEVICE_DISCONNECT,
57− WUIE_ID_HOST_DISCONNECT,
58− WUIE_ID_KEEP_ALIVE = 0x89,
59− WUIE_ID_ISOCH_DISCARD,
60− WUIE_ID_RESET_DEVICE,
61−};
62−
63−/**
64− * Maximum number of array elements in a WUSB IE.
65− *
66− * WUSB1.0[7.5 before table 7-38] says that in WUSB IEs that
67− * are "arrays" have to limited to 4 elements. So we define it
68− * like that to ease up and submit only the neeed size.
69− */
70−#define WUIE_ELT_MAX 4
71−
72−/**
73− * Wrapper for the data that defines a CHID, a CDID or a CK
74− *
75− * WUSB defines that CHIDs, CDIDs and CKs are a 16 byte string of
76− * data. In order to avoid confusion and enforce types, we wrap it.
77− *
78− * Make it packed, as we use it in some hw definitions.
79− */
80−struct wusb_ckhdid {
81− u8 data[16];
82−} __attribute__((packed));
83−
84−static const struct wusb_ckhdid wusb_ckhdid_zero = { .data = { 0 } };
85−
86−#define WUSB_CKHDID_STRSIZE (3 * sizeof(struct wusb_ckhdid) + 1)
87−
88−/**
89− * WUSB IE: Host Information (WUSB1.0[7.5.2])
90− *
91− * Used to provide information about the host to the Wireless USB
92− * devices in range (CHID can be used as an ASCII string).
93− */
94−struct wuie_host_info {
95− struct wuie_hdr hdr;
96− __le16 attributes;
97− struct wusb_ckhdid CHID;
98−} __attribute__((packed));
99−
100−/**
101− * WUSB IE: Connect Ack (WUSB1.0[7.5.1])
102− *
103− * Used to acknowledge device connect requests. See note for
104− * WUIE_ELT_MAX.
105− */
106−struct wuie_connect_ack {
107− struct wuie_hdr hdr;
108− struct {
109− struct wusb_ckhdid CDID;
110− u8 bDeviceAddress; /* 0 means unused */
111− u8 bReserved;
112− } blk[WUIE_ELT_MAX];
113−} __attribute__((packed));
114−
115−/**
116− * WUSB IE Host Information Element, Connect Availability
117− *
118− * WUSB1.0[7.5.2], bmAttributes description
119− */
120−enum {
121− WUIE_HI_CAP_RECONNECT = 0,
122− WUIE_HI_CAP_LIMITED,
123− WUIE_HI_CAP_RESERVED,
124− WUIE_HI_CAP_ALL,
125−};
126−
127−/**
128− * WUSB IE: Channel Stop (WUSB1.0[7.5.8])
129− *
130− * Tells devices the host is going to stop sending MMCs and will disappear.
131− */
132−struct wuie_channel_stop {
133− struct wuie_hdr hdr;
134− u8 attributes;
135− u8 timestamp[3];
136−} __attribute__((packed));
137−
138−/**
139− * WUSB IE: Keepalive (WUSB1.0[7.5.9])
140− *
141− * Ask device(s) to send keepalives.
142− */
143−struct wuie_keep_alive {
144− struct wuie_hdr hdr;
145− u8 bDeviceAddress[WUIE_ELT_MAX];
146−} __attribute__((packed));
147−
148−/**
149− * WUSB IE: Reset device (WUSB1.0[7.5.11])
150− *
151− * Tell device to reset; in all truth, we can fit 4 CDIDs, but we only
152− * use it for one at the time...
153− *
154− * In any case, this request is a wee bit silly: why don't they target
155− * by address??
156− */
157−struct wuie_reset {
158− struct wuie_hdr hdr;
159− struct wusb_ckhdid CDID;
160−} __attribute__((packed));
161−
162−/**
163− * WUSB IE: Disconnect device (WUSB1.0[7.5.11])
164− *
165− * Tell device to disconnect; we can fit 4 addresses, but we only use
166− * it for one at the time...
167− */
168−struct wuie_disconnect {
169− struct wuie_hdr hdr;
170− u8 bDeviceAddress;
171− u8 padding;
172−} __attribute__((packed));
173−
174−/**
175− * WUSB IE: Host disconnect ([WUSB] section 7.5.5)
176− *
177− * Tells all connected devices to disconnect.
178− */
179−struct wuie_host_disconnect {
180− struct wuie_hdr hdr;
181−} __attribute__((packed));
182−
183−/**
184− * WUSB Device Notification header (WUSB1.0[7.6])
185− */
186−struct wusb_dn_hdr {
187− u8 bType;
188− u8 notifdata[];
189−} __attribute__((packed));
190−
191−/** Device Notification codes (WUSB1.0[Table 7-54]) */
192−enum WUSB_DN {
193− WUSB_DN_CONNECT = 0x01,
194− WUSB_DN_DISCONNECT = 0x02,
195− WUSB_DN_EPRDY = 0x03,
196− WUSB_DN_MASAVAILCHANGED = 0x04,
197− WUSB_DN_RWAKE = 0x05,
198− WUSB_DN_SLEEP = 0x06,
199− WUSB_DN_ALIVE = 0x07,
200−};
201−
202−/** WUSB Device Notification Connect */
203−struct wusb_dn_connect {
204− struct wusb_dn_hdr hdr;
205− __le16 attributes;
206− struct wusb_ckhdid CDID;
207−} __attribute__((packed));
208−
209−static inline int wusb_dn_connect_prev_dev_addr(const struct wusb_dn_connect *dn)
210−{
211− return le16_to_cpu(dn->attributes) & 0xff;
212−}
213−
214−static inline int wusb_dn_connect_new_connection(const struct wusb_dn_connect *dn)
215−{
216− return (le16_to_cpu(dn->attributes) >> 8) & 0x1;
217−}
218−
219−static inline int wusb_dn_connect_beacon_behavior(const struct wusb_dn_connect *dn)
220−{
221− return (le16_to_cpu(dn->attributes) >> 9) & 0x03;
222−}
223−
224−/** Device is alive (aka: pong) (WUSB1.0[7.6.7]) */
225−struct wusb_dn_alive {
226− struct wusb_dn_hdr hdr;
227−} __attribute__((packed));
228−
229−/** Device is disconnecting (WUSB1.0[7.6.2]) */
230−struct wusb_dn_disconnect {
231− struct wusb_dn_hdr hdr;
232−} __attribute__((packed));
233−
234−/* General constants */
235−enum {
236− WUSB_TRUST_TIMEOUT_MS = 4000, /* [WUSB] section 4.15.1 */
237−};
238−
239−/*
240− * WUSB Crypto stuff (WUSB1.0[6])
241− */
242−
243−extern const char *wusb_et_name(u8);
244−
245−/**
246− * WUSB key index WUSB1.0[7.3.2.4], for usage when setting keys for
247− * the host or the device.
248− */
249−static inline u8 wusb_key_index(int index, int type, int originator)
250−{
251− return (originator << 6) | (type << 4) | index;
252−}
253−
254−#define WUSB_KEY_INDEX_TYPE_PTK 0 /* for HWA only */
255−#define WUSB_KEY_INDEX_TYPE_ASSOC 1
256−#define WUSB_KEY_INDEX_TYPE_GTK 2
257−#define WUSB_KEY_INDEX_ORIGINATOR_HOST 0
258−#define WUSB_KEY_INDEX_ORIGINATOR_DEVICE 1
259−/* bits 0-3 used for the key index. */
260−#define WUSB_KEY_INDEX_MAX 15
261−
262−/* A CCM Nonce, defined in WUSB1.0[6.4.1] */
263−struct aes_ccm_nonce {
264− u8 sfn[6]; /* Little Endian */
265− u8 tkid[3]; /* LE */
266− struct uwb_dev_addr dest_addr;
267− struct uwb_dev_addr src_addr;
268−} __attribute__((packed));
269−
270−/* A CCM operation label, defined on WUSB1.0[6.5.x] */
271−struct aes_ccm_label {
272− u8 data[14];
273−} __attribute__((packed));
274−
275−/*
276− * Input to the key derivation sequence defined in
277− * WUSB1.0[6.5.1]. Rest of the data is in the CCM Nonce passed to the
278− * PRF function.
279− */
280−struct wusb_keydvt_in {
281− u8 hnonce[16];
282− u8 dnonce[16];
283−} __attribute__((packed));
284−
285−/*
286− * Output from the key derivation sequence defined in
287− * WUSB1.0[6.5.1].
288− */
289−struct wusb_keydvt_out {
290− u8 kck[16];
291− u8 ptk[16];
292−} __attribute__((packed));
293−
294−/* Pseudo Random Function WUSB1.0[6.5] */
295−extern int wusb_crypto_init(void);
296−extern void wusb_crypto_exit(void);
297−extern ssize_t wusb_prf(void *out, size_t out_size,
298− const u8 key[16], const struct aes_ccm_nonce *_n,
299− const struct aes_ccm_label *a,
300− const void *b, size_t blen, size_t len);
301−
302−static inline int wusb_prf_64(void *out, size_t out_size, const u8 key[16],
303− const struct aes_ccm_nonce *n,
304− const struct aes_ccm_label *a,
305− const void *b, size_t blen)
306−{
307− return wusb_prf(out, out_size, key, n, a, b, blen, 64);
308−}
309−
310−static inline int wusb_prf_128(void *out, size_t out_size, const u8 key[16],
311− const struct aes_ccm_nonce *n,
312− const struct aes_ccm_label *a,
313− const void *b, size_t blen)
314−{
315− return wusb_prf(out, out_size, key, n, a, b, blen, 128);
316−}
317−
318−static inline int wusb_prf_256(void *out, size_t out_size, const u8 key[16],
319− const struct aes_ccm_nonce *n,
320− const struct aes_ccm_label *a,
321− const void *b, size_t blen)
322−{
323− return wusb_prf(out, out_size, key, n, a, b, blen, 256);
324−}
325−
326−/* Key derivation WUSB1.0[6.5.1] */
327−static inline int wusb_key_derive(struct wusb_keydvt_out *keydvt_out,
328− const u8 key[16],
329− const struct aes_ccm_nonce *n,
330− const struct wusb_keydvt_in *keydvt_in)
331−{
332− const struct aes_ccm_label a = { .data = "Pair-wise keys" };
333− return wusb_prf_256(keydvt_out, sizeof(*keydvt_out), key, n, &a,
334− keydvt_in, sizeof(*keydvt_in));
335−}
336−
337−/*
338− * Out-of-band MIC Generation WUSB1.0[6.5.2]
339− *
340− * Compute the MIC over @key, @n and @hs and place it in @mic_out.
341− *
342− * @mic_out: Where to place the 8 byte MIC tag
343− * @key: KCK from the derivation process
344− * @n: CCM nonce, n->sfn == 0, TKID as established in the
345− * process.
346− * @hs: Handshake struct for phase 2 of the 4-way.
347− * hs->bStatus and hs->bReserved are zero.
348− * hs->bMessageNumber is 2 (WUSB1.0[7.3.2.5.2]
349− * hs->dest_addr is the device's USB address padded with 0
350− * hs->src_addr is the hosts's UWB device address
351− * hs->mic is ignored (as we compute that value).
352− */
353−static inline int wusb_oob_mic(u8 mic_out[8], const u8 key[16],
354− const struct aes_ccm_nonce *n,
355− const struct usb_handshake *hs)
356−{
357− const struct aes_ccm_label a = { .data = "out-of-bandMIC" };
358− return wusb_prf_64(mic_out, 8, key, n, &a,
359− hs, sizeof(*hs) - sizeof(hs->MIC));
360−}
361−
362−#endif /* #ifndef __WUSB_H__ */
include/linux/uwb.h+0−817
@@ -1,817 +0,0 @@
1−/* SPDX-License-Identifier: GPL-2.0-only */
2−/*
3− * Ultra Wide Band
4− * UWB API
5− *
6− * Copyright (C) 2005-2006 Intel Corporation
7− * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
8− *
9− * FIXME: doc: overview of the API, different parts and pointers
10− */
11−
12−#ifndef __LINUX__UWB_H__
13−#define __LINUX__UWB_H__
14−
15−#include <linux/limits.h>
16−#include <linux/device.h>
17−#include <linux/mutex.h>
18−#include <linux/timer.h>
19−#include <linux/wait.h>
20−#include <linux/workqueue.h>
21−#include <linux/uwb/spec.h>
22−#include <asm/page.h>
23−
24−struct uwb_dev;
25−struct uwb_beca_e;
26−struct uwb_rc;
27−struct uwb_rsv;
28−struct uwb_dbg;
29−
30−/**
31− * struct uwb_dev - a UWB Device
32− * @rc: UWB Radio Controller that discovered the device (kind of its
33− * parent).
34− * @bce: a beacon cache entry for this device; or NULL if the device
35− * is a local radio controller.
36− * @mac_addr: the EUI-48 address of this device.
37− * @dev_addr: the current DevAddr used by this device.
38− * @beacon_slot: the slot number the beacon is using.
39− * @streams: bitmap of streams allocated to reservations targeted at
40− * this device. For an RC, this is the streams allocated for
41− * reservations targeted at DevAddrs.
42− *
43− * A UWB device may either by a neighbor or part of a local radio
44− * controller.
45− */
46−struct uwb_dev {
47− struct mutex mutex;
48− struct list_head list_node;
49− struct device dev;
50− struct uwb_rc *rc; /* radio controller */
51− struct uwb_beca_e *bce; /* Beacon Cache Entry */
52−
53− struct uwb_mac_addr mac_addr;
54− struct uwb_dev_addr dev_addr;
55− int beacon_slot;
56− DECLARE_BITMAP(streams, UWB_NUM_STREAMS);
57− DECLARE_BITMAP(last_availability_bm, UWB_NUM_MAS);
58−};
59−#define to_uwb_dev(d) container_of(d, struct uwb_dev, dev)
60−
61−/**
62− * UWB HWA/WHCI Radio Control {Command|Event} Block context IDs
63− *
64− * RC[CE]Bs have a 'context ID' field that matches the command with
65− * the event received to confirm it.
66− *
67− * Maximum number of context IDs
68− */
69−enum { UWB_RC_CTX_MAX = 256 };
70−
71−
72−/** Notification chain head for UWB generated events to listeners */
73−struct uwb_notifs_chain {
74− struct list_head list;
75− struct mutex mutex;
76−};
77−
78−/* Beacon cache list */
79−struct uwb_beca {
80− struct list_head list;
81− size_t entries;
82− struct mutex mutex;
83−};
84−
85−/* Event handling thread. */
86−struct uwbd {
87− int pid;
88− struct task_struct *task;
89− wait_queue_head_t wq;
90− struct list_head event_list;
91− spinlock_t event_list_lock;
92−};
93−
94−/**
95− * struct uwb_mas_bm - a bitmap of all MAS in a superframe
96− * @bm: a bitmap of length #UWB_NUM_MAS
97− */
98−struct uwb_mas_bm {
99− DECLARE_BITMAP(bm, UWB_NUM_MAS);
100− DECLARE_BITMAP(unsafe_bm, UWB_NUM_MAS);
101− int safe;
102− int unsafe;
103−};
104−
105−/**
106− * uwb_rsv_state - UWB Reservation state.
107− *
108− * NONE - reservation is not active (no DRP IE being transmitted).
109− *
110− * Owner reservation states:
111− *
112− * INITIATED - owner has sent an initial DRP request.
113− * PENDING - target responded with pending Reason Code.
114− * MODIFIED - reservation manager is modifying an established
115− * reservation with a different MAS allocation.
116− * ESTABLISHED - the reservation has been successfully negotiated.
117− *
118− * Target reservation states:
119− *
120− * DENIED - request is denied.
121− * ACCEPTED - request is accepted.
122− * PENDING - PAL has yet to make a decision to whether to accept or
123− * deny.
124− *
125− * FIXME: further target states TBD.
126− */
127−enum uwb_rsv_state {
128− UWB_RSV_STATE_NONE = 0,
129− UWB_RSV_STATE_O_INITIATED,
130− UWB_RSV_STATE_O_PENDING,
131− UWB_RSV_STATE_O_MODIFIED,
132− UWB_RSV_STATE_O_ESTABLISHED,
133− UWB_RSV_STATE_O_TO_BE_MOVED,
134− UWB_RSV_STATE_O_MOVE_EXPANDING,
135− UWB_RSV_STATE_O_MOVE_COMBINING,
136− UWB_RSV_STATE_O_MOVE_REDUCING,
137− UWB_RSV_STATE_T_ACCEPTED,
138− UWB_RSV_STATE_T_DENIED,
139− UWB_RSV_STATE_T_CONFLICT,
140− UWB_RSV_STATE_T_PENDING,
141− UWB_RSV_STATE_T_EXPANDING_ACCEPTED,
142− UWB_RSV_STATE_T_EXPANDING_CONFLICT,
143− UWB_RSV_STATE_T_EXPANDING_PENDING,
144− UWB_RSV_STATE_T_EXPANDING_DENIED,
145− UWB_RSV_STATE_T_RESIZED,
146−
147− UWB_RSV_STATE_LAST,
148−};
149−
150−enum uwb_rsv_target_type {
151− UWB_RSV_TARGET_DEV,
152− UWB_RSV_TARGET_DEVADDR,
153−};
154−
155−/**
156− * struct uwb_rsv_target - the target of a reservation.
157− *
158− * Reservations unicast and targeted at a single device
159− * (UWB_RSV_TARGET_DEV); or (e.g., in the case of WUSB) targeted at a
160− * specific (private) DevAddr (UWB_RSV_TARGET_DEVADDR).
161− */
162−struct uwb_rsv_target {
163− enum uwb_rsv_target_type type;
164− union {
165− struct uwb_dev *dev;
166− struct uwb_dev_addr devaddr;
167− };
168−};
169−
170−struct uwb_rsv_move {
171− struct uwb_mas_bm final_mas;
172− struct uwb_ie_drp *companion_drp_ie;
173− struct uwb_mas_bm companion_mas;
174−};
175−
176−/*
177− * Number of streams reserved for reservations targeted at DevAddrs.
178− */
179−#define UWB_NUM_GLOBAL_STREAMS 1
180−
181−typedef void (*uwb_rsv_cb_f)(struct uwb_rsv *rsv);
182−
183−/**
184− * struct uwb_rsv - a DRP reservation
185− *
186− * Data structure management:
187− *
188− * @rc: the radio controller this reservation is for
189− * (as target or owner)
190− * @rc_node: a list node for the RC
191− * @pal_node: a list node for the PAL
192− *
193− * Owner and target parameters:
194− *
195− * @owner: the UWB device owning this reservation
196− * @target: the target UWB device
197− * @type: reservation type
198− *
199− * Owner parameters:
200− *
201− * @max_mas: maxiumum number of MAS
202− * @min_mas: minimum number of MAS
203− * @sparsity: owner selected sparsity
204− * @is_multicast: true iff multicast
205− *
206− * @callback: callback function when the reservation completes
207− * @pal_priv: private data for the PAL making the reservation
208− *
209− * Reservation status:
210− *
211− * @status: negotiation status
212− * @stream: stream index allocated for this reservation
213− * @tiebreaker: conflict tiebreaker for this reservation
214− * @mas: reserved MAS
215− * @drp_ie: the DRP IE
216− * @ie_valid: true iff the DRP IE matches the reservation parameters
217− *
218− * DRP reservations are uniquely identified by the owner, target and
219− * stream index. However, when using a DevAddr as a target (e.g., for
220− * a WUSB cluster reservation) the responses may be received from
221− * devices with different DevAddrs. In this case, reservations are
222− * uniquely identified by just the stream index. A number of stream
223− * indexes (UWB_NUM_GLOBAL_STREAMS) are reserved for this.
224− */
225−struct uwb_rsv {
226− struct uwb_rc *rc;
227− struct list_head rc_node;
228− struct list_head pal_node;
229− struct kref kref;
230−
231− struct uwb_dev *owner;
232− struct uwb_rsv_target target;
233− enum uwb_drp_type type;
234− int max_mas;
235− int min_mas;
236− int max_interval;
237− bool is_multicast;
238−
239− uwb_rsv_cb_f callback;
240− void *pal_priv;
241−
242− enum uwb_rsv_state state;
243− bool needs_release_companion_mas;
244− u8 stream;
245− u8 tiebreaker;
246− struct uwb_mas_bm mas;
247− struct uwb_ie_drp *drp_ie;
248− struct uwb_rsv_move mv;
249− bool ie_valid;
250− struct timer_list timer;
251− struct work_struct handle_timeout_work;
252−};
253−
254−static const
255−struct uwb_mas_bm uwb_mas_bm_zero = { .bm = { 0 } };
256−
257−static inline void uwb_mas_bm_copy_le(void *dst, const struct uwb_mas_bm *mas)
258−{
259− bitmap_copy_le(dst, mas->bm, UWB_NUM_MAS);
260−}
261−
262−/**
263− * struct uwb_drp_avail - a radio controller's view of MAS usage
264− * @global: MAS unused by neighbors (excluding reservations targeted
265− * or owned by the local radio controller) or the beaon period
266− * @local: MAS unused by local established reservations
267− * @pending: MAS unused by local pending reservations
268− * @ie: DRP Availability IE to be included in the beacon
269− * @ie_valid: true iff @ie is valid and does not need to regenerated from
270− * @global and @local
271− *
272− * Each radio controller maintains a view of MAS usage or
273− * availability. MAS available for a new reservation are determined
274− * from the intersection of @global, @local, and @pending.
275− *
276− * The radio controller must transmit a DRP Availability IE that's the
277− * intersection of @global and @local.
278− *
279− * A set bit indicates the MAS is unused and available.
280− *
281− * rc->rsvs_mutex should be held before accessing this data structure.
282− *
283− * [ECMA-368] section 17.4.3.
284− */
285−struct uwb_drp_avail {
286− DECLARE_BITMAP(global, UWB_NUM_MAS);
287− DECLARE_BITMAP(local, UWB_NUM_MAS);
288− DECLARE_BITMAP(pending, UWB_NUM_MAS);
289− struct uwb_ie_drp_avail ie;
290− bool ie_valid;
291−};
292−
293−struct uwb_drp_backoff_win {
294− u8 window;
295− u8 n;
296− int total_expired;
297− struct timer_list timer;
298− bool can_reserve_extra_mases;
299−};
300−
301−const char *uwb_rsv_state_str(enum uwb_rsv_state state);
302−const char *uwb_rsv_type_str(enum uwb_drp_type type);
303−
304−struct uwb_rsv *uwb_rsv_create(struct uwb_rc *rc, uwb_rsv_cb_f cb,
305− void *pal_priv);
306−void uwb_rsv_destroy(struct uwb_rsv *rsv);
307−
308−int uwb_rsv_establish(struct uwb_rsv *rsv);
309−int uwb_rsv_modify(struct uwb_rsv *rsv,
310− int max_mas, int min_mas, int sparsity);
311−void uwb_rsv_terminate(struct uwb_rsv *rsv);
312−
313−void uwb_rsv_accept(struct uwb_rsv *rsv, uwb_rsv_cb_f cb, void *pal_priv);
314−
315−void uwb_rsv_get_usable_mas(struct uwb_rsv *orig_rsv, struct uwb_mas_bm *mas);
316−
317−/**
318− * Radio Control Interface instance
319− *
320− *
321− * Life cycle rules: those of the UWB Device.
322− *
323− * @index: an index number for this radio controller, as used in the
324− * device name.
325− * @version: version of protocol supported by this device
326− * @priv: Backend implementation; rw with uwb_dev.dev.sem taken.
327− * @cmd: Backend implementation to execute commands; rw and call
328− * only with uwb_dev.dev.sem taken.
329− * @reset: Hardware reset of radio controller and any PAL controllers.
330− * @filter: Backend implementation to manipulate data to and from device
331− * to be compliant to specification assumed by driver (WHCI
332− * 0.95).
333− *
334− * uwb_dev.dev.mutex is used to execute commands and update
335− * the corresponding structures; can't use a spinlock
336− * because rc->cmd() can sleep.
337− * @ies: This is a dynamically allocated array cacheing the
338− * IEs (settable by the host) that the beacon of this
339− * radio controller is currently sending.
340− *
341− * In reality, we store here the full command we set to
342− * the radio controller (which is basically a command
343− * prefix followed by all the IEs the beacon currently
344− * contains). This way we don't have to realloc and
345− * memcpy when setting it.
346− *
347− * We set this up in uwb_rc_ie_setup(), where we alloc
348− * this struct, call get_ie() [so we know which IEs are
349− * currently being sent, if any].
350− *
351− * @ies_capacity:Amount of space (in bytes) allocated in @ies. The
352− * amount used is given by sizeof(*ies) plus ies->wIELength
353− * (which is a little endian quantity all the time).
354− * @ies_mutex: protect the IE cache
355− * @dbg: information for the debug interface
356− */
357−struct uwb_rc {
358− struct uwb_dev uwb_dev;
359− int index;
360− u16 version;
361−
362− struct module *owner;
363− void *priv;
364− int (*start)(struct uwb_rc *rc);
365− void (*stop)(struct uwb_rc *rc);
366− int (*cmd)(struct uwb_rc *, const struct uwb_rccb *, size_t);
367− int (*reset)(struct uwb_rc *rc);
368− int (*filter_cmd)(struct uwb_rc *, struct uwb_rccb **, size_t *);
369− int (*filter_event)(struct uwb_rc *, struct uwb_rceb **, const size_t,
370− size_t *, size_t *);
371−
372− spinlock_t neh_lock; /* protects neh_* and ctx_* */
373− struct list_head neh_list; /* Open NE handles */
374− unsigned long ctx_bm[UWB_RC_CTX_MAX / 8 / sizeof(unsigned long)];
375− u8 ctx_roll;
376−
377− int beaconing; /* Beaconing state [channel number] */
378− int beaconing_forced;
379− int scanning;
380− enum uwb_scan_type scan_type:3;
381− unsigned ready:1;
382− struct uwb_notifs_chain notifs_chain;
383− struct uwb_beca uwb_beca;
384−
385− struct uwbd uwbd;
386−
387− struct uwb_drp_backoff_win bow;
388− struct uwb_drp_avail drp_avail;
389− struct list_head reservations;
390− struct list_head cnflt_alien_list;
391− struct uwb_mas_bm cnflt_alien_bitmap;
392− struct mutex rsvs_mutex;
393− spinlock_t rsvs_lock;
394− struct workqueue_struct *rsv_workq;
395−
396− struct delayed_work rsv_update_work;
397− struct delayed_work rsv_alien_bp_work;
398− int set_drp_ie_pending;
399− struct mutex ies_mutex;
400− struct uwb_rc_cmd_set_ie *ies;
401− size_t ies_capacity;
402−
403− struct list_head pals;
404− int active_pals;
405−
406− struct uwb_dbg *dbg;
407−};
408−
409−
410−/**
411− * struct uwb_pal - a UWB PAL
412− * @name: descriptive name for this PAL (wusbhc, wlp, etc.).
413− * @device: a device for the PAL. Used to link the PAL and the radio
414− * controller in sysfs.
415− * @rc: the radio controller the PAL uses.
416− * @channel_changed: called when the channel used by the radio changes.
417− * A channel of -1 means the channel has been stopped.
418− * @new_rsv: called when a peer requests a reservation (may be NULL if
419− * the PAL cannot accept reservation requests).
420− * @channel: channel being used by the PAL; 0 if the PAL isn't using
421− * the radio; -1 if the PAL wishes to use the radio but
422− * cannot.
423− * @debugfs_dir: a debugfs directory which the PAL can use for its own
424− * debugfs files.
425− *
426− * A Protocol Adaptation Layer (PAL) is a user of the WiMedia UWB
427− * radio platform (e.g., WUSB, WLP or Bluetooth UWB AMP).
428− *
429− * The PALs using a radio controller must register themselves to
430− * permit the UWB stack to coordinate usage of the radio between the
431− * various PALs or to allow PALs to response to certain requests from
432− * peers.
433− *
434− * A struct uwb_pal should be embedded in a containing structure
435− * belonging to the PAL and initialized with uwb_pal_init()). Fields
436− * should be set appropriately by the PAL before registering the PAL
437− * with uwb_pal_register().
438− */
439−struct uwb_pal {
440− struct list_head node;
441− const char *name;
442− struct device *device;
443− struct uwb_rc *rc;
444−
445− void (*channel_changed)(struct uwb_pal *pal, int channel);
446− void (*new_rsv)(struct uwb_pal *pal, struct uwb_rsv *rsv);
447−
448− int channel;
449− struct dentry *debugfs_dir;
450−};
451−
452−void uwb_pal_init(struct uwb_pal *pal);
453−int uwb_pal_register(struct uwb_pal *pal);
454−void uwb_pal_unregister(struct uwb_pal *pal);
455−
456−int uwb_radio_start(struct uwb_pal *pal);
457−void uwb_radio_stop(struct uwb_pal *pal);
458−
459−/*
460− * General public API
461− *
462− * This API can be used by UWB device drivers or by those implementing
463− * UWB Radio Controllers
464− */
465−struct uwb_dev *uwb_dev_get_by_devaddr(struct uwb_rc *rc,
466− const struct uwb_dev_addr *devaddr);
467−struct uwb_dev *uwb_dev_get_by_rc(struct uwb_dev *, struct uwb_rc *);
468−static inline void uwb_dev_get(struct uwb_dev *uwb_dev)
469−{
470− get_device(&uwb_dev->dev);
471−}
472−static inline void uwb_dev_put(struct uwb_dev *uwb_dev)
473−{
474− put_device(&uwb_dev->dev);
475−}
476−struct uwb_dev *uwb_dev_try_get(struct uwb_rc *rc, struct uwb_dev *uwb_dev);
477−
478−/**
479− * Callback function for 'uwb_{dev,rc}_foreach()'.
480− *
481− * @dev: Linux device instance
482− * 'uwb_dev = container_of(dev, struct uwb_dev, dev)'
483− * @priv: Data passed by the caller to 'uwb_{dev,rc}_foreach()'.
484− *
485− * @returns: 0 to continue the iterations, any other val to stop
486− * iterating and return the value to the caller of
487− * _foreach().
488− */
489−typedef int (*uwb_dev_for_each_f)(struct device *dev, void *priv);
490−int uwb_dev_for_each(struct uwb_rc *rc, uwb_dev_for_each_f func, void *priv);
491−
492−struct uwb_rc *uwb_rc_alloc(void);
493−struct uwb_rc *uwb_rc_get_by_dev(const struct uwb_dev_addr *);
494−struct uwb_rc *uwb_rc_get_by_grandpa(const struct device *);
495−void uwb_rc_put(struct uwb_rc *rc);
496−
497−typedef void (*uwb_rc_cmd_cb_f)(struct uwb_rc *rc, void *arg,
498− struct uwb_rceb *reply, ssize_t reply_size);
499−
500−int uwb_rc_cmd_async(struct uwb_rc *rc, const char *cmd_name,
501− struct uwb_rccb *cmd, size_t cmd_size,
502− u8 expected_type, u16 expected_event,
503− uwb_rc_cmd_cb_f cb, void *arg);
504−ssize_t uwb_rc_cmd(struct uwb_rc *rc, const char *cmd_name,
505− struct uwb_rccb *cmd, size_t cmd_size,
506− struct uwb_rceb *reply, size_t reply_size);
507−ssize_t uwb_rc_vcmd(struct uwb_rc *rc, const char *cmd_name,
508− struct uwb_rccb *cmd, size_t cmd_size,
509− u8 expected_type, u16 expected_event,
510− struct uwb_rceb **preply);
511−
512−size_t __uwb_addr_print(char *, size_t, const unsigned char *, int);
513−
514−int uwb_rc_dev_addr_set(struct uwb_rc *, const struct uwb_dev_addr *);
515−int uwb_rc_dev_addr_get(struct uwb_rc *, struct uwb_dev_addr *);
516−int uwb_rc_mac_addr_set(struct uwb_rc *, const struct uwb_mac_addr *);
517−int uwb_rc_mac_addr_get(struct uwb_rc *, struct uwb_mac_addr *);
518−int __uwb_mac_addr_assigned_check(struct device *, void *);
519−int __uwb_dev_addr_assigned_check(struct device *, void *);
520−
521−/* Print in @buf a pretty repr of @addr */
522−static inline size_t uwb_dev_addr_print(char *buf, size_t buf_size,
523− const struct uwb_dev_addr *addr)
524−{
525− return __uwb_addr_print(buf, buf_size, addr->data, 0);
526−}
527−
528−/* Print in @buf a pretty repr of @addr */
529−static inline size_t uwb_mac_addr_print(char *buf, size_t buf_size,
530− const struct uwb_mac_addr *addr)
531−{
532− return __uwb_addr_print(buf, buf_size, addr->data, 1);
533−}
534−
535−/* @returns 0 if device addresses @addr2 and @addr1 are equal */
536−static inline int uwb_dev_addr_cmp(const struct uwb_dev_addr *addr1,
537− const struct uwb_dev_addr *addr2)
538−{
539− return memcmp(addr1, addr2, sizeof(*addr1));
540−}
541−
542−/* @returns 0 if MAC addresses @addr2 and @addr1 are equal */
543−static inline int uwb_mac_addr_cmp(const struct uwb_mac_addr *addr1,
544− const struct uwb_mac_addr *addr2)
545−{
546− return memcmp(addr1, addr2, sizeof(*addr1));
547−}
548−
549−/* @returns !0 if a MAC @addr is a broadcast address */
550−static inline int uwb_mac_addr_bcast(const struct uwb_mac_addr *addr)
551−{
552− struct uwb_mac_addr bcast = {
553− .data = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }
554− };
555− return !uwb_mac_addr_cmp(addr, &bcast);
556−}
557−
558−/* @returns !0 if a MAC @addr is all zeroes*/
559−static inline int uwb_mac_addr_unset(const struct uwb_mac_addr *addr)
560−{
561− struct uwb_mac_addr unset = {
562− .data = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
563− };
564− return !uwb_mac_addr_cmp(addr, &unset);
565−}
566−
567−/* @returns !0 if the address is in use. */
568−static inline unsigned __uwb_dev_addr_assigned(struct uwb_rc *rc,
569− struct uwb_dev_addr *addr)
570−{
571− return uwb_dev_for_each(rc, __uwb_dev_addr_assigned_check, addr);
572−}
573−
574−/*
575− * UWB Radio Controller API
576− *
577− * This API is used (in addition to the general API) to implement UWB
578− * Radio Controllers.
579− */
580−void uwb_rc_init(struct uwb_rc *);
581−int uwb_rc_add(struct uwb_rc *, struct device *dev, void *rc_priv);
582−void uwb_rc_rm(struct uwb_rc *);
583−void uwb_rc_neh_grok(struct uwb_rc *, void *, size_t);
584−void uwb_rc_neh_error(struct uwb_rc *, int);
585−void uwb_rc_reset_all(struct uwb_rc *rc);
586−void uwb_rc_pre_reset(struct uwb_rc *rc);
587−int uwb_rc_post_reset(struct uwb_rc *rc);
588−
589−/**
590− * uwb_rsv_is_owner - is the owner of this reservation the RC?
591− * @rsv: the reservation
592− */
593−static inline bool uwb_rsv_is_owner(struct uwb_rsv *rsv)
594−{
595− return rsv->owner == &rsv->rc->uwb_dev;
596−}
597−
598−/**
599− * enum uwb_notifs - UWB events that can be passed to any listeners
600− * @UWB_NOTIF_ONAIR: a new neighbour has joined the beacon group.
601− * @UWB_NOTIF_OFFAIR: a neighbour has left the beacon group.
602− *
603− * Higher layers can register callback functions with the radio
604− * controller using uwb_notifs_register(). The radio controller
605− * maintains a list of all registered handlers and will notify all
606− * nodes when an event occurs.
607− */
608−enum uwb_notifs {
609− UWB_NOTIF_ONAIR,
610− UWB_NOTIF_OFFAIR,
611−};
612−
613−/* Callback function registered with UWB */
614−struct uwb_notifs_handler {
615− struct list_head list_node;
616− void (*cb)(void *, struct uwb_dev *, enum uwb_notifs);
617− void *data;
618−};
619−
620−int uwb_notifs_register(struct uwb_rc *, struct uwb_notifs_handler *);
621−int uwb_notifs_deregister(struct uwb_rc *, struct uwb_notifs_handler *);
622−
623−
624−/**
625− * UWB radio controller Event Size Entry (for creating entry tables)
626− *
627− * WUSB and WHCI define events and notifications, and they might have
628− * fixed or variable size.
629− *
630− * Each event/notification has a size which is not necessarily known
631− * in advance based on the event code. As well, vendor specific
632− * events/notifications will have a size impossible to determine
633− * unless we know about the device's specific details.
634− *
635− * It was way too smart of the spec writers not to think that it would
636− * be impossible for a generic driver to skip over vendor specific
637− * events/notifications if there are no LENGTH fields in the HEADER of
638− * each message...the transaction size cannot be counted on as the
639− * spec does not forbid to pack more than one event in a single
640− * transaction.
641− *
642− * Thus, we guess sizes with tables (or for events, when you know the
643− * size ahead of time you can use uwb_rc_neh_extra_size*()). We
644− * register tables with the known events and their sizes, and then we
645− * traverse those tables. For those with variable length, we provide a
646− * way to lookup the size inside the event/notification's
647− * payload. This allows device-specific event size tables to be
648− * registered.
649− *
650− * @size: Size of the payload
651− *
652− * @offset: if != 0, at offset @offset-1 starts a field with a length
653− * that has to be added to @size. The format of the field is
654− * given by @type.
655− *
656− * @type: Type and length of the offset field. Most common is LE 16
657− * bits (that's why that is zero); others are there mostly to
658− * cover for bugs and weirdos.
659− */
660−struct uwb_est_entry {
661− size_t size;
662− unsigned offset;
663− enum { UWB_EST_16 = 0, UWB_EST_8 = 1 } type;
664−};
665−
666−int uwb_est_register(u8 type, u8 code_high, u16 vendor, u16 product,
667− const struct uwb_est_entry *, size_t entries);
668−int uwb_est_unregister(u8 type, u8 code_high, u16 vendor, u16 product,
669− const struct uwb_est_entry *, size_t entries);
670−ssize_t uwb_est_find_size(struct uwb_rc *rc, const struct uwb_rceb *rceb,
671− size_t len);
672−
673−/* -- Misc */
674−
675−enum {
676− EDC_MAX_ERRORS = 10,
677− EDC_ERROR_TIMEFRAME = HZ,
678−};
679−
680−/* error density counter */
681−struct edc {
682− unsigned long timestart;
683− u16 errorcount;
684−};
685−
686−static inline
687−void edc_init(struct edc *edc)
688−{
689− edc->timestart = jiffies;
690−}
691−
692−/* Called when an error occurred.
693− * This is way to determine if the number of acceptable errors per time
694− * period has been exceeded. It is not accurate as there are cases in which
695− * this scheme will not work, for example if there are periodic occurrences
696− * of errors that straddle updates to the start time. This scheme is
697− * sufficient for our usage.
698− *
699− * @returns 1 if maximum acceptable errors per timeframe has been exceeded.
700− */
701−static inline int edc_inc(struct edc *err_hist, u16 max_err, u16 timeframe)
702−{
703− unsigned long now;
704−
705− now = jiffies;
706− if (now - err_hist->timestart > timeframe) {
707− err_hist->errorcount = 1;
708− err_hist->timestart = now;
709− } else if (++err_hist->errorcount > max_err) {
710− err_hist->errorcount = 0;
711− err_hist->timestart = now;
712− return 1;
713− }
714− return 0;
715−}
716−
717−
718−/* Information Element handling */
719−
720−struct uwb_ie_hdr *uwb_ie_next(void **ptr, size_t *len);
721−int uwb_rc_ie_add(struct uwb_rc *uwb_rc, const struct uwb_ie_hdr *ies, size_t size);
722−int uwb_rc_ie_rm(struct uwb_rc *uwb_rc, enum uwb_ie element_id);
723−
724−/*
725− * Transmission statistics
726− *
727− * UWB uses LQI and RSSI (one byte values) for reporting radio signal
728− * strength and line quality indication. We do quick and dirty
729− * averages of those. They are signed values, btw.
730− *
731− * For 8 bit quantities, we keep the min, the max, an accumulator
732− * (@sigma) and a # of samples. When @samples gets to 255, we compute
733− * the average (@sigma / @samples), place it in @sigma and reset
734− * @samples to 1 (so we use it as the first sample).
735− *
736− * Now, statistically speaking, probably I am kicking the kidneys of
737− * some books I have in my shelves collecting dust, but I just want to
738− * get an approx, not the Nobel.
739− *
740− * LOCKING: there is no locking per se, but we try to keep a lockless
741− * schema. Only _add_samples() modifies the values--as long as you
742− * have other locking on top that makes sure that no two calls of
743− * _add_sample() happen at the same time, then we are fine. Now, for
744− * resetting the values we just set @samples to 0 and that makes the
745− * next _add_sample() to start with defaults. Reading the values in
746− * _show() currently can race, so you need to make sure the calls are
747− * under the same lock that protects calls to _add_sample(). FIXME:
748− * currently unlocked (It is not ultraprecise but does the trick. Bite
749− * me).
750− */
751−struct stats {
752− s8 min, max;
753− s16 sigma;
754− atomic_t samples;
755−};
756−
757−static inline
758−void stats_init(struct stats *stats)
759−{
760− atomic_set(&stats->samples, 0);
761− wmb();
762−}
763−
764−static inline
765−void stats_add_sample(struct stats *stats, s8 sample)
766−{
767− s8 min, max;
768− s16 sigma;
769− unsigned samples = atomic_read(&stats->samples);
770− if (samples == 0) { /* it was zero before, so we initialize */
771− min = 127;
772− max = -128;
773− sigma = 0;
774− } else {
775− min = stats->min;
776− max = stats->max;
777− sigma = stats->sigma;
778− }
779−
780− if (sample < min) /* compute new values */
781− min = sample;
782− else if (sample > max)
783− max = sample;
784− sigma += sample;
785−
786− stats->min = min; /* commit */
787− stats->max = max;
788− stats->sigma = sigma;
789− if (atomic_add_return(1, &stats->samples) > 255) {
790− /* wrapped around! reset */
791− stats->sigma = sigma / 256;
792− atomic_set(&stats->samples, 1);
793− }
794−}
795−
796−static inline ssize_t stats_show(struct stats *stats, char *buf)
797−{
798− int min, max, avg;
799− int samples = atomic_read(&stats->samples);
800− if (samples == 0)
801− min = max = avg = 0;
802− else {
803− min = stats->min;
804− max = stats->max;
805− avg = stats->sigma / samples;
806− }
807− return scnprintf(buf, PAGE_SIZE, "%d %d %d\n", min, max, avg);
808−}
809−
810−static inline ssize_t stats_store(struct stats *stats, const char *buf,
811− size_t size)
812−{
813− stats_init(stats);
814− return size;
815−}
816−
817−#endif /* #ifndef __LINUX__UWB_H__ */
include/linux/uwb/debug-cmd.h+0−57
@@ -1,57 +0,0 @@
1−/* SPDX-License-Identifier: GPL-2.0-only */
2−/*
3− * Ultra Wide Band
4− * Debug interface commands
5− *
6− * Copyright (C) 2008 Cambridge Silicon Radio Ltd.
7− */
8−#ifndef __LINUX__UWB__DEBUG_CMD_H__
9−#define __LINUX__UWB__DEBUG_CMD_H__
10−
11−#include <linux/types.h>
12−
13−/*
14− * Debug interface commands
15− *
16− * UWB_DBG_CMD_RSV_ESTABLISH: Establish a new unicast reservation.
17− *
18− * UWB_DBG_CMD_RSV_TERMINATE: Terminate the Nth reservation.
19− */
20−
21−enum uwb_dbg_cmd_type {
22− UWB_DBG_CMD_RSV_ESTABLISH = 1,
23− UWB_DBG_CMD_RSV_TERMINATE = 2,
24− UWB_DBG_CMD_IE_ADD = 3,
25− UWB_DBG_CMD_IE_RM = 4,
26− UWB_DBG_CMD_RADIO_START = 5,
27− UWB_DBG_CMD_RADIO_STOP = 6,
28−};
29−
30−struct uwb_dbg_cmd_rsv_establish {
31− __u8 target[6];
32− __u8 type;
33− __u16 max_mas;
34− __u16 min_mas;
35− __u8 max_interval;
36−};
37−
38−struct uwb_dbg_cmd_rsv_terminate {
39− int index;
40−};
41−
42−struct uwb_dbg_cmd_ie {
43− __u8 data[128];
44− int len;
45−};
46−
47−struct uwb_dbg_cmd {
48− __u32 type;
49− union {
50− struct uwb_dbg_cmd_rsv_establish rsv_establish;
51− struct uwb_dbg_cmd_rsv_terminate rsv_terminate;
52− struct uwb_dbg_cmd_ie ie_add;
53− struct uwb_dbg_cmd_ie ie_rm;
54− };
55−};
56−
57−#endif /* #ifndef __LINUX__UWB__DEBUG_CMD_H__ */
include/linux/uwb/spec.h+0−767
@@ -1,767 +0,0 @@
1−/* SPDX-License-Identifier: GPL-2.0-only */
2−/*
3− * Ultra Wide Band
4− * UWB Standard definitions
5− *
6− * Copyright (C) 2005-2006 Intel Corporation
7− * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
8− *
9− * All these definitions are based on the ECMA-368 standard.
10− *
11− * Note all definitions are Little Endian in the wire, and we will
12− * convert them to host order before operating on the bitfields (that
13− * yes, we use extensively).
14− */
15−
16−#ifndef __LINUX__UWB_SPEC_H__
17−#define __LINUX__UWB_SPEC_H__
18−
19−#include <linux/types.h>
20−#include <linux/bitmap.h>
21−#include <linux/if_ether.h>
22−
23−#define i1480_FW 0x00000303
24−/* #define i1480_FW 0x00000302 */
25−
26−/**
27− * Number of Medium Access Slots in a superframe.
28− *
29− * UWB divides time in SuperFrames, each one divided in 256 pieces, or
30− * Medium Access Slots. See MBOA MAC[5.4.5] for details. The MAS is the
31− * basic bandwidth allocation unit in UWB.
32− */
33−enum { UWB_NUM_MAS = 256 };
34−
35−/**
36− * Number of Zones in superframe.
37− *
38− * UWB divides the superframe into zones with numbering starting from BPST.
39− * See MBOA MAC[16.8.6]
40− */
41−enum { UWB_NUM_ZONES = 16 };
42−
43−/*
44− * Number of MAS in a zone.
45− */
46−#define UWB_MAS_PER_ZONE (UWB_NUM_MAS / UWB_NUM_ZONES)
47−
48−/*
49− * Number of MAS required before a row can be considered available.
50− */
51−#define UWB_USABLE_MAS_PER_ROW (UWB_NUM_ZONES - 1)
52−
53−/*
54− * Number of streams per DRP reservation between a pair of devices.
55− *
56− * [ECMA-368] section 16.8.6.
57− */
58−enum { UWB_NUM_STREAMS = 8 };
59−
60−/*
61− * mMasLength
62− *
63− * The length of a MAS in microseconds.
64− *
65− * [ECMA-368] section 17.16.
66− */
67−enum { UWB_MAS_LENGTH_US = 256 };
68−
69−/*
70− * mBeaconSlotLength
71− *
72− * The length of the beacon slot in microseconds.
73− *
74− * [ECMA-368] section 17.16
75− */
76−enum { UWB_BEACON_SLOT_LENGTH_US = 85 };
77−
78−/*
79− * mMaxLostBeacons
80− *
81− * The number beacons missing in consecutive superframes before a
82− * device can be considered as unreachable.
83− *
84− * [ECMA-368] section 17.16
85− */
86−enum { UWB_MAX_LOST_BEACONS = 3 };
87−
88−/*
89− * mDRPBackOffWinMin
90− *
91− * The minimum number of superframes to wait before trying to reserve
92− * extra MAS.
93− *
94− * [ECMA-368] section 17.16
95− */
96−enum { UWB_DRP_BACKOFF_WIN_MIN = 2 };
97−
98−/*
99− * mDRPBackOffWinMax
100− *
101− * The maximum number of superframes to wait before trying to reserve
102− * extra MAS.
103− *
104− * [ECMA-368] section 17.16
105− */
106−enum { UWB_DRP_BACKOFF_WIN_MAX = 16 };
107−
108−/*
109− * Length of a superframe in microseconds.
110− */
111−#define UWB_SUPERFRAME_LENGTH_US (UWB_MAS_LENGTH_US * UWB_NUM_MAS)
112−
113−/**
114− * UWB MAC address
115− *
116− * It is *imperative* that this struct is exactly 6 packed bytes (as
117− * it is also used to define headers sent down and up the wire/radio).
118− */
119−struct uwb_mac_addr {
120− u8 data[ETH_ALEN];
121−} __attribute__((packed));
122−
123−
124−/**
125− * UWB device address
126− *
127− * It is *imperative* that this struct is exactly 6 packed bytes (as
128− * it is also used to define headers sent down and up the wire/radio).
129− */
130−struct uwb_dev_addr {
131− u8 data[2];
132−} __attribute__((packed));
133−
134−
135−/**
136− * Types of UWB addresses
137− *
138− * Order matters (by size).
139− */
140−enum uwb_addr_type {
141− UWB_ADDR_DEV = 0,
142− UWB_ADDR_MAC = 1,
143−};
144−
145−
146−/** Size of a char buffer for printing a MAC/device address */
147−enum { UWB_ADDR_STRSIZE = 32 };
148−
149−
150−/** UWB WiMedia protocol IDs. */
151−enum uwb_prid {
152− UWB_PRID_WLP_RESERVED = 0x0000,
153− UWB_PRID_WLP = 0x0001,
154− UWB_PRID_WUSB_BOT = 0x0010,
155− UWB_PRID_WUSB = 0x0010,
156− UWB_PRID_WUSB_TOP = 0x001F,
157−};
158−
159−
160−/** PHY Rate (MBOA MAC[7.8.12, Table 61]) */
161−enum uwb_phy_rate {
162− UWB_PHY_RATE_53 = 0,
163− UWB_PHY_RATE_80,
164− UWB_PHY_RATE_106,
165− UWB_PHY_RATE_160,
166− UWB_PHY_RATE_200,
167− UWB_PHY_RATE_320,
168− UWB_PHY_RATE_400,
169− UWB_PHY_RATE_480,
170− UWB_PHY_RATE_INVALID
171−};
172−
173−
174−/**
175− * Different ways to scan (MBOA MAC[6.2.2, Table 8], WUSB[Table 8-78])
176− */
177−enum uwb_scan_type {
178− UWB_SCAN_ONLY = 0,
179− UWB_SCAN_OUTSIDE_BP,
180− UWB_SCAN_WHILE_INACTIVE,
181− UWB_SCAN_DISABLED,
182− UWB_SCAN_ONLY_STARTTIME,
183− UWB_SCAN_TOP
184−};
185−
186−
187−/** ACK Policy types (MBOA MAC[7.2.1.3]) */
188−enum uwb_ack_pol {
189− UWB_ACK_NO = 0,
190− UWB_ACK_INM = 1,
191− UWB_ACK_B = 2,
192− UWB_ACK_B_REQ = 3,
193−};
194−
195−
196−/** DRP reservation types ([ECMA-368 table 106) */
197−enum uwb_drp_type {
198− UWB_DRP_TYPE_ALIEN_BP = 0,
199− UWB_DRP_TYPE_HARD,
200− UWB_DRP_TYPE_SOFT,
201− UWB_DRP_TYPE_PRIVATE,
202− UWB_DRP_TYPE_PCA,
203−};
204−
205−
206−/** DRP Reason Codes ([ECMA-368] table 107) */
207−enum uwb_drp_reason {
208− UWB_DRP_REASON_ACCEPTED = 0,
209− UWB_DRP_REASON_CONFLICT,
210− UWB_DRP_REASON_PENDING,
211− UWB_DRP_REASON_DENIED,
212− UWB_DRP_REASON_MODIFIED,
213−};
214−
215−/** Relinquish Request Reason Codes ([ECMA-368] table 113) */
216−enum uwb_relinquish_req_reason {
217− UWB_RELINQUISH_REQ_REASON_NON_SPECIFIC = 0,
218− UWB_RELINQUISH_REQ_REASON_OVER_ALLOCATION,
219−};
220−
221−/**
222− * DRP Notification Reason Codes (WHCI 0.95 [3.1.4.9])
223− */
224−enum uwb_drp_notif_reason {
225− UWB_DRP_NOTIF_DRP_IE_RCVD = 0,
226− UWB_DRP_NOTIF_CONFLICT,
227− UWB_DRP_NOTIF_TERMINATE,
228−};
229−
230−
231−/** Allocation of MAS slots in a DRP request MBOA MAC[7.8.7] */
232−struct uwb_drp_alloc {
233− __le16 zone_bm;
234− __le16 mas_bm;
235−} __attribute__((packed));
236−
237−
238−/** General MAC Header format (ECMA-368[16.2]) */
239−struct uwb_mac_frame_hdr {
240− __le16 Frame_Control;
241− struct uwb_dev_addr DestAddr;
242− struct uwb_dev_addr SrcAddr;
243− __le16 Sequence_Control;
244− __le16 Access_Information;
245−} __attribute__((packed));
246−
247−
248−/**
249− * uwb_beacon_frame - a beacon frame including MAC headers
250− *
251− * [ECMA] section 16.3.
252− */
253−struct uwb_beacon_frame {
254− struct uwb_mac_frame_hdr hdr;
255− struct uwb_mac_addr Device_Identifier; /* may be a NULL EUI-48 */
256− u8 Beacon_Slot_Number;
257− u8 Device_Control;
258− u8 IEData[];
259−} __attribute__((packed));
260−
261−
262−/** Information Element codes (MBOA MAC[T54]) */
263−enum uwb_ie {
264− UWB_PCA_AVAILABILITY = 2,
265− UWB_IE_DRP_AVAILABILITY = 8,
266− UWB_IE_DRP = 9,
267− UWB_BP_SWITCH_IE = 11,
268− UWB_MAC_CAPABILITIES_IE = 12,
269− UWB_PHY_CAPABILITIES_IE = 13,
270− UWB_APP_SPEC_PROBE_IE = 15,
271− UWB_IDENTIFICATION_IE = 19,
272− UWB_MASTER_KEY_ID_IE = 20,
273− UWB_RELINQUISH_REQUEST_IE = 21,
274− UWB_IE_WLP = 250, /* WiMedia Logical Link Control Protocol WLP 0.99 */
275− UWB_APP_SPEC_IE = 255,
276−};
277−
278−
279−/**
280− * Header common to all Information Elements (IEs)
281− */
282−struct uwb_ie_hdr {
283− u8 element_id; /* enum uwb_ie */
284− u8 length;
285−} __attribute__((packed));
286−
287−
288−/** Dynamic Reservation Protocol IE (MBOA MAC[7.8.6]) */
289−struct uwb_ie_drp {
290− struct uwb_ie_hdr hdr;
291− __le16 drp_control;
292− struct uwb_dev_addr dev_addr;
293− struct uwb_drp_alloc allocs[];
294−} __attribute__((packed));
295−
296−static inline int uwb_ie_drp_type(struct uwb_ie_drp *ie)
297−{
298− return (le16_to_cpu(ie->drp_control) >> 0) & 0x7;
299−}
300−
301−static inline int uwb_ie_drp_stream_index(struct uwb_ie_drp *ie)
302−{
303− return (le16_to_cpu(ie->drp_control) >> 3) & 0x7;
304−}
305−
306−static inline int uwb_ie_drp_reason_code(struct uwb_ie_drp *ie)
307−{
308− return (le16_to_cpu(ie->drp_control) >> 6) & 0x7;
309−}
310−
311−static inline int uwb_ie_drp_status(struct uwb_ie_drp *ie)
312−{
313− return (le16_to_cpu(ie->drp_control) >> 9) & 0x1;
314−}
315−
316−static inline int uwb_ie_drp_owner(struct uwb_ie_drp *ie)
317−{
318− return (le16_to_cpu(ie->drp_control) >> 10) & 0x1;
319−}
320−
321−static inline int uwb_ie_drp_tiebreaker(struct uwb_ie_drp *ie)
322−{
323− return (le16_to_cpu(ie->drp_control) >> 11) & 0x1;
324−}
325−
326−static inline int uwb_ie_drp_unsafe(struct uwb_ie_drp *ie)
327−{
328− return (le16_to_cpu(ie->drp_control) >> 12) & 0x1;
329−}
330−
331−static inline void uwb_ie_drp_set_type(struct uwb_ie_drp *ie, enum uwb_drp_type type)
332−{
333− u16 drp_control = le16_to_cpu(ie->drp_control);
334− drp_control = (drp_control & ~(0x7 << 0)) | (type << 0);
335− ie->drp_control = cpu_to_le16(drp_control);
336−}
337−
338−static inline void uwb_ie_drp_set_stream_index(struct uwb_ie_drp *ie, int stream_index)
339−{
340− u16 drp_control = le16_to_cpu(ie->drp_control);
341− drp_control = (drp_control & ~(0x7 << 3)) | (stream_index << 3);
342− ie->drp_control = cpu_to_le16(drp_control);
343−}
344−
345−static inline void uwb_ie_drp_set_reason_code(struct uwb_ie_drp *ie,
346− enum uwb_drp_reason reason_code)
347−{
348− u16 drp_control = le16_to_cpu(ie->drp_control);
349− drp_control = (ie->drp_control & ~(0x7 << 6)) | (reason_code << 6);
350− ie->drp_control = cpu_to_le16(drp_control);
351−}
352−
353−static inline void uwb_ie_drp_set_status(struct uwb_ie_drp *ie, int status)
354−{
355− u16 drp_control = le16_to_cpu(ie->drp_control);
356− drp_control = (drp_control & ~(0x1 << 9)) | (status << 9);
357− ie->drp_control = cpu_to_le16(drp_control);
358−}
359−
360−static inline void uwb_ie_drp_set_owner(struct uwb_ie_drp *ie, int owner)
361−{
362− u16 drp_control = le16_to_cpu(ie->drp_control);
363− drp_control = (drp_control & ~(0x1 << 10)) | (owner << 10);
364− ie->drp_control = cpu_to_le16(drp_control);
365−}
366−
367−static inline void uwb_ie_drp_set_tiebreaker(struct uwb_ie_drp *ie, int tiebreaker)
368−{
369− u16 drp_control = le16_to_cpu(ie->drp_control);
370− drp_control = (drp_control & ~(0x1 << 11)) | (tiebreaker << 11);
371− ie->drp_control = cpu_to_le16(drp_control);
372−}
373−
374−static inline void uwb_ie_drp_set_unsafe(struct uwb_ie_drp *ie, int unsafe)
375−{
376− u16 drp_control = le16_to_cpu(ie->drp_control);
377− drp_control = (drp_control & ~(0x1 << 12)) | (unsafe << 12);
378− ie->drp_control = cpu_to_le16(drp_control);
379−}
380−
381−/** Dynamic Reservation Protocol IE (MBOA MAC[7.8.7]) */
382−struct uwb_ie_drp_avail {
383− struct uwb_ie_hdr hdr;
384− DECLARE_BITMAP(bmp, UWB_NUM_MAS);
385−} __attribute__((packed));
386−
387−/* Relinqish Request IE ([ECMA-368] section 16.8.19). */
388−struct uwb_relinquish_request_ie {
389− struct uwb_ie_hdr hdr;
390− __le16 relinquish_req_control;
391− struct uwb_dev_addr dev_addr;
392− struct uwb_drp_alloc allocs[];
393−} __attribute__((packed));
394−
395−static inline int uwb_ie_relinquish_req_reason_code(struct uwb_relinquish_request_ie *ie)
396−{
397− return (le16_to_cpu(ie->relinquish_req_control) >> 0) & 0xf;
398−}
399−
400−static inline void uwb_ie_relinquish_req_set_reason_code(struct uwb_relinquish_request_ie *ie,
401− int reason_code)
402−{
403− u16 ctrl = le16_to_cpu(ie->relinquish_req_control);
404− ctrl = (ctrl & ~(0xf << 0)) | (reason_code << 0);
405− ie->relinquish_req_control = cpu_to_le16(ctrl);
406−}
407−
408−/**
409− * The Vendor ID is set to an OUI that indicates the vendor of the device.
410− * ECMA-368 [16.8.10]
411− */
412−struct uwb_vendor_id {
413− u8 data[3];
414−} __attribute__((packed));
415−
416−/**
417− * The device type ID
418− * FIXME: clarify what this means
419− * ECMA-368 [16.8.10]
420− */
421−struct uwb_device_type_id {
422− u8 data[3];
423−} __attribute__((packed));
424−
425−
426−/**
427− * UWB device information types
428− * ECMA-368 [16.8.10]
429− */
430−enum uwb_dev_info_type {
431− UWB_DEV_INFO_VENDOR_ID = 0,
432− UWB_DEV_INFO_VENDOR_TYPE,
433− UWB_DEV_INFO_NAME,
434−};
435−
436−/**
437− * UWB device information found in Identification IE
438− * ECMA-368 [16.8.10]
439− */
440−struct uwb_dev_info {
441− u8 type; /* enum uwb_dev_info_type */
442− u8 length;
443− u8 data[];
444−} __attribute__((packed));
445−
446−/**
447− * UWB Identification IE
448− * ECMA-368 [16.8.10]
449− */
450−struct uwb_identification_ie {
451− struct uwb_ie_hdr hdr;
452− struct uwb_dev_info info[];
453−} __attribute__((packed));
454−
455−/*
456− * UWB Radio Controller
457− *
458− * These definitions are common to the Radio Control layers as
459− * exported by the WUSB1.0 HWA and WHCI interfaces.
460− */
461−
462−/** Radio Control Command Block (WUSB1.0[Table 8-65] and WHCI 0.95) */
463−struct uwb_rccb {
464− u8 bCommandType; /* enum hwa_cet */
465− __le16 wCommand; /* Command code */
466− u8 bCommandContext; /* Context ID */
467−} __attribute__((packed));
468−
469−
470−/** Radio Control Event Block (WUSB[table 8-66], WHCI 0.95) */
471−struct uwb_rceb {
472− u8 bEventType; /* enum hwa_cet */
473− __le16 wEvent; /* Event code */
474− u8 bEventContext; /* Context ID */
475−} __attribute__((packed));
476−
477−
478−enum {
479− UWB_RC_CET_GENERAL = 0, /* General Command/Event type */
480− UWB_RC_CET_EX_TYPE_1 = 1, /* Extended Type 1 Command/Event type */
481−};
482−
483−/* Commands to the radio controller */
484−enum uwb_rc_cmd {
485− UWB_RC_CMD_CHANNEL_CHANGE = 16,
486− UWB_RC_CMD_DEV_ADDR_MGMT = 17, /* Device Address Management */
487− UWB_RC_CMD_GET_IE = 18, /* GET Information Elements */
488− UWB_RC_CMD_RESET = 19,
489− UWB_RC_CMD_SCAN = 20, /* Scan management */
490− UWB_RC_CMD_SET_BEACON_FILTER = 21,
491− UWB_RC_CMD_SET_DRP_IE = 22, /* Dynamic Reservation Protocol IEs */
492− UWB_RC_CMD_SET_IE = 23, /* Information Element management */
493− UWB_RC_CMD_SET_NOTIFICATION_FILTER = 24,
494− UWB_RC_CMD_SET_TX_POWER = 25,
495− UWB_RC_CMD_SLEEP = 26,
496− UWB_RC_CMD_START_BEACON = 27,
497− UWB_RC_CMD_STOP_BEACON = 28,
498− UWB_RC_CMD_BP_MERGE = 29,
499− UWB_RC_CMD_SEND_COMMAND_FRAME = 30,
500− UWB_RC_CMD_SET_ASIE_NOTIF = 31,
501−};
502−
503−/* Notifications from the radio controller */
504−enum uwb_rc_evt {
505− UWB_RC_EVT_IE_RCV = 0,
506− UWB_RC_EVT_BEACON = 1,
507− UWB_RC_EVT_BEACON_SIZE = 2,
508− UWB_RC_EVT_BPOIE_CHANGE = 3,
509− UWB_RC_EVT_BP_SLOT_CHANGE = 4,
510− UWB_RC_EVT_BP_SWITCH_IE_RCV = 5,
511− UWB_RC_EVT_DEV_ADDR_CONFLICT = 6,
512− UWB_RC_EVT_DRP_AVAIL = 7,
513− UWB_RC_EVT_DRP = 8,
514− UWB_RC_EVT_BP_SWITCH_STATUS = 9,
515− UWB_RC_EVT_CMD_FRAME_RCV = 10,
516− UWB_RC_EVT_CHANNEL_CHANGE_IE_RCV = 11,
517− /* Events (command responses) use the same code as the command */
518− UWB_RC_EVT_UNKNOWN_CMD_RCV = 65535,
519−};
520−
521−enum uwb_rc_extended_type_1_cmd {
522− UWB_RC_SET_DAA_ENERGY_MASK = 32,
523− UWB_RC_SET_NOTIFICATION_FILTER_EX = 33,
524−};
525−
526−enum uwb_rc_extended_type_1_evt {
527− UWB_RC_DAA_ENERGY_DETECTED = 0,
528−};
529−
530−/* Radio Control Result Code. [WHCI] table 3-3. */
531−enum {
532− UWB_RC_RES_SUCCESS = 0,
533− UWB_RC_RES_FAIL,
534− UWB_RC_RES_FAIL_HARDWARE,
535− UWB_RC_RES_FAIL_NO_SLOTS,
536− UWB_RC_RES_FAIL_BEACON_TOO_LARGE,
537− UWB_RC_RES_FAIL_INVALID_PARAMETER,
538− UWB_RC_RES_FAIL_UNSUPPORTED_PWR_LEVEL,
539− UWB_RC_RES_FAIL_INVALID_IE_DATA,
540− UWB_RC_RES_FAIL_BEACON_SIZE_EXCEEDED,
541− UWB_RC_RES_FAIL_CANCELLED,
542− UWB_RC_RES_FAIL_INVALID_STATE,
543− UWB_RC_RES_FAIL_INVALID_SIZE,
544− UWB_RC_RES_FAIL_ACK_NOT_RECEIVED,
545− UWB_RC_RES_FAIL_NO_MORE_ASIE_NOTIF,
546− UWB_RC_RES_FAIL_TIME_OUT = 255,
547−};
548−
549−/* Confirm event. [WHCI] section 3.1.3.1 etc. */
550−struct uwb_rc_evt_confirm {
551− struct uwb_rceb rceb;
552− u8 bResultCode;
553−} __attribute__((packed));
554−
555−/* Device Address Management event. [WHCI] section 3.1.3.2. */
556−struct uwb_rc_evt_dev_addr_mgmt {
557− struct uwb_rceb rceb;
558− u8 baAddr[ETH_ALEN];
559− u8 bResultCode;
560−} __attribute__((packed));
561−
562−
563−/* Get IE Event. [WHCI] section 3.1.3.3. */
564−struct uwb_rc_evt_get_ie {
565− struct uwb_rceb rceb;
566− __le16 wIELength;
567− u8 IEData[];
568−} __attribute__((packed));
569−
570−/* Set DRP IE Event. [WHCI] section 3.1.3.7. */
571−struct uwb_rc_evt_set_drp_ie {
572− struct uwb_rceb rceb;
573− __le16 wRemainingSpace;
574− u8 bResultCode;
575−} __attribute__((packed));
576−
577−/* Set IE Event. [WHCI] section 3.1.3.8. */
578−struct uwb_rc_evt_set_ie {
579− struct uwb_rceb rceb;
580− __le16 RemainingSpace;
581− u8 bResultCode;
582−} __attribute__((packed));
583−
584−/* Scan command. [WHCI] 3.1.3.5. */
585−struct uwb_rc_cmd_scan {
586− struct uwb_rccb rccb;
587− u8 bChannelNumber;
588− u8 bScanState;
589− __le16 wStartTime;
590−} __attribute__((packed));
591−
592−/* Set DRP IE command. [WHCI] section 3.1.3.7. */
593−struct uwb_rc_cmd_set_drp_ie {
594− struct uwb_rccb rccb;
595− __le16 wIELength;
596− struct uwb_ie_drp IEData[];
597−} __attribute__((packed));
598−
599−/* Set IE command. [WHCI] section 3.1.3.8. */
600−struct uwb_rc_cmd_set_ie {
601− struct uwb_rccb rccb;
602− __le16 wIELength;
603− u8 IEData[];
604−} __attribute__((packed));
605−
606−/* Set DAA Energy Mask event. [WHCI 0.96] section 3.1.3.17. */
607−struct uwb_rc_evt_set_daa_energy_mask {
608− struct uwb_rceb rceb;
609− __le16 wLength;
610− u8 result;
611−} __attribute__((packed));
612−
613−/* Set Notification Filter Extended event. [WHCI 0.96] section 3.1.3.18. */
614−struct uwb_rc_evt_set_notification_filter_ex {
615− struct uwb_rceb rceb;
616− __le16 wLength;
617− u8 result;
618−} __attribute__((packed));
619−
620−/* IE Received notification. [WHCI] section 3.1.4.1. */
621−struct uwb_rc_evt_ie_rcv {
622− struct uwb_rceb rceb;
623− struct uwb_dev_addr SrcAddr;
624− __le16 wIELength;
625− u8 IEData[];
626−} __attribute__((packed));
627−
628−/* Type of the received beacon. [WHCI] section 3.1.4.2. */
629−enum uwb_rc_beacon_type {
630− UWB_RC_BEACON_TYPE_SCAN = 0,
631− UWB_RC_BEACON_TYPE_NEIGHBOR,
632− UWB_RC_BEACON_TYPE_OL_ALIEN,
633− UWB_RC_BEACON_TYPE_NOL_ALIEN,
634−};
635−
636−/* Beacon received notification. [WHCI] 3.1.4.2. */
637−struct uwb_rc_evt_beacon {
638− struct uwb_rceb rceb;
639− u8 bChannelNumber;
640− u8 bBeaconType;
641− __le16 wBPSTOffset;
642− u8 bLQI;
643− u8 bRSSI;
644− __le16 wBeaconInfoLength;
645− u8 BeaconInfo[];
646−} __attribute__((packed));
647−
648−
649−/* Beacon Size Change notification. [WHCI] section 3.1.4.3 */
650−struct uwb_rc_evt_beacon_size {
651− struct uwb_rceb rceb;
652− __le16 wNewBeaconSize;
653−} __attribute__((packed));
654−
655−
656−/* BPOIE Change notification. [WHCI] section 3.1.4.4. */
657−struct uwb_rc_evt_bpoie_change {
658− struct uwb_rceb rceb;
659− __le16 wBPOIELength;
660− u8 BPOIE[];
661−} __attribute__((packed));
662−
663−
664−/* Beacon Slot Change notification. [WHCI] section 3.1.4.5. */
665−struct uwb_rc_evt_bp_slot_change {
666− struct uwb_rceb rceb;
667− u8 slot_info;
668−} __attribute__((packed));
669−
670−static inline int uwb_rc_evt_bp_slot_change_slot_num(
671− const struct uwb_rc_evt_bp_slot_change *evt)
672−{
673− return evt->slot_info & 0x7f;
674−}
675−
676−static inline int uwb_rc_evt_bp_slot_change_no_slot(
677− const struct uwb_rc_evt_bp_slot_change *evt)
678−{
679− return (evt->slot_info & 0x80) >> 7;
680−}
681−
682−/* BP Switch IE Received notification. [WHCI] section 3.1.4.6. */
683−struct uwb_rc_evt_bp_switch_ie_rcv {
684− struct uwb_rceb rceb;
685− struct uwb_dev_addr wSrcAddr;
686− __le16 wIELength;
687− u8 IEData[];
688−} __attribute__((packed));
689−
690−/* DevAddr Conflict notification. [WHCI] section 3.1.4.7. */
691−struct uwb_rc_evt_dev_addr_conflict {
692− struct uwb_rceb rceb;
693−} __attribute__((packed));
694−
695−/* DRP notification. [WHCI] section 3.1.4.9. */
696−struct uwb_rc_evt_drp {
697− struct uwb_rceb rceb;
698− struct uwb_dev_addr src_addr;
699− u8 reason;
700− u8 beacon_slot_number;
701− __le16 ie_length;
702− u8 ie_data[];
703−} __attribute__((packed));
704−
705−static inline enum uwb_drp_notif_reason uwb_rc_evt_drp_reason(struct uwb_rc_evt_drp *evt)
706−{
707− return evt->reason & 0x0f;
708−}
709−
710−
711−/* DRP Availability Change notification. [WHCI] section 3.1.4.8. */
712−struct uwb_rc_evt_drp_avail {
713− struct uwb_rceb rceb;
714− DECLARE_BITMAP(bmp, UWB_NUM_MAS);
715−} __attribute__((packed));
716−
717−/* BP switch status notification. [WHCI] section 3.1.4.10. */
718−struct uwb_rc_evt_bp_switch_status {
719− struct uwb_rceb rceb;
720− u8 status;
721− u8 slot_offset;
722− __le16 bpst_offset;
723− u8 move_countdown;
724−} __attribute__((packed));
725−
726−/* Command Frame Received notification. [WHCI] section 3.1.4.11. */
727−struct uwb_rc_evt_cmd_frame_rcv {
728− struct uwb_rceb rceb;
729− __le16 receive_time;
730− struct uwb_dev_addr wSrcAddr;
731− struct uwb_dev_addr wDstAddr;
732− __le16 control;
733− __le16 reserved;
734− __le16 dataLength;
735− u8 data[];
736−} __attribute__((packed));
737−
738−/* Channel Change IE Received notification. [WHCI] section 3.1.4.12. */
739−struct uwb_rc_evt_channel_change_ie_rcv {
740− struct uwb_rceb rceb;
741− struct uwb_dev_addr wSrcAddr;
742− __le16 wIELength;
743− u8 IEData[];
744−} __attribute__((packed));
745−
746−/* DAA Energy Detected notification. [WHCI 0.96] section 3.1.4.14. */
747−struct uwb_rc_evt_daa_energy_detected {
748− struct uwb_rceb rceb;
749− __le16 wLength;
750− u8 bandID;
751− u8 reserved;
752− u8 toneBmp[16];
753−} __attribute__((packed));
754−
755−
756−/**
757− * Radio Control Interface Class Descriptor
758− *
759− * WUSB 1.0 [8.6.1.2]
760− */
761−struct uwb_rc_control_intf_class_desc {
762− u8 bLength;
763− u8 bDescriptorType;
764− __le16 bcdRCIVersion;
765−} __attribute__((packed));
766−
767−#endif /* #ifndef __LINUX__UWB_SPEC_H__ */
include/linux/uwb/umc.h+0−192
@@ -1,192 +0,0 @@
1−/* SPDX-License-Identifier: GPL-2.0-only */
2−/*
3− * UWB Multi-interface Controller support.
4− *
5− * Copyright (C) 2007 Cambridge Silicon Radio Ltd.
6− *
7− * UMC (UWB Multi-interface Controller) capabilities (e.g., radio
8− * controller, host controller) are presented as devices on the "umc"
9− * bus.
10− *
11− * The radio controller is not strictly a UMC capability but it's
12− * useful to present it as such.
13− *
14− * References:
15− *
16− * [WHCI] Wireless Host Controller Interface Specification for
17− * Certified Wireless Universal Serial Bus, revision 0.95.
18− *
19− * How this works is kind of convoluted but simple. The whci.ko driver
20− * loads when WHCI devices are detected. These WHCI devices expose
21− * many devices in the same PCI function (they couldn't have reused
22− * functions, no), so for each PCI function that exposes these many
23− * devices, whci ceates a umc_dev [whci_probe() -> whci_add_cap()]
24− * with umc_device_create() and adds it to the bus with
25− * umc_device_register().
26− *
27− * umc_device_register() calls device_register() which will push the
28− * bus management code to load your UMC driver's somehting_probe()
29− * that you have registered for that capability code.
30− *
31− * Now when the WHCI device is removed, whci_remove() will go over
32− * each umc_dev assigned to each of the PCI function's capabilities
33− * and through whci_del_cap() call umc_device_unregister() each
34− * created umc_dev. Of course, if you are bound to the device, your
35− * driver's something_remove() will be called.
36− */
37−
38−#ifndef _LINUX_UWB_UMC_H_
39−#define _LINUX_UWB_UMC_H_
40−
41−#include <linux/device.h>
42−#include <linux/pci.h>
43−
44−/*
45− * UMC capability IDs.
46− *
47− * 0x00 is reserved so use it for the radio controller device.
48− *
49− * [WHCI] table 2-8
50− */
51−#define UMC_CAP_ID_WHCI_RC 0x00 /* radio controller */
52−#define UMC_CAP_ID_WHCI_WUSB_HC 0x01 /* WUSB host controller */
53−
54−/**
55− * struct umc_dev - UMC capability device
56− *
57− * @version: version of the specification this capability conforms to.
58− * @cap_id: capability ID.
59− * @bar: PCI Bar (64 bit) where the resource lies
60− * @resource: register space resource.
61− * @irq: interrupt line.
62− */
63−struct umc_dev {
64− u16 version;
65− u8 cap_id;
66− u8 bar;
67− struct resource resource;
68− unsigned irq;
69− struct device dev;
70−};
71−
72−#define to_umc_dev(d) container_of(d, struct umc_dev, dev)
73−
74−/**
75− * struct umc_driver - UMC capability driver
76− * @cap_id: supported capability ID.
77− * @match: driver specific capability matching function.
78− * @match_data: driver specific data for match() (e.g., a
79− * table of pci_device_id's if umc_match_pci_id() is used).
80− */
81−struct umc_driver {
82− char *name;
83− u8 cap_id;
84− int (*match)(struct umc_driver *, struct umc_dev *);
85− const void *match_data;
86−
87− int (*probe)(struct umc_dev *);
88− void (*remove)(struct umc_dev *);
89− int (*pre_reset)(struct umc_dev *);
90− int (*post_reset)(struct umc_dev *);
91−
92− struct device_driver driver;
93−};
94−
95−#define to_umc_driver(d) container_of(d, struct umc_driver, driver)
96−
97−extern struct bus_type umc_bus_type;
98−
99−struct umc_dev *umc_device_create(struct device *parent, int n);
100−int __must_check umc_device_register(struct umc_dev *umc);
101−void umc_device_unregister(struct umc_dev *umc);
102−
103−int __must_check __umc_driver_register(struct umc_driver *umc_drv,
104− struct module *mod,
105− const char *mod_name);
106−
107−/**
108− * umc_driver_register - register a UMC capabiltity driver.
109− * @umc_drv: pointer to the driver.
110− */
111−#define umc_driver_register(umc_drv) \
112− __umc_driver_register(umc_drv, THIS_MODULE, KBUILD_MODNAME)
113−
114−void umc_driver_unregister(struct umc_driver *umc_drv);
115−
116−/*
117− * Utility function you can use to match (umc_driver->match) against a
118− * null-terminated array of 'struct pci_device_id' in
119− * umc_driver->match_data.
120− */
121−int umc_match_pci_id(struct umc_driver *umc_drv, struct umc_dev *umc);
122−
123−/**
124− * umc_parent_pci_dev - return the UMC's parent PCI device or NULL if none
125− * @umc_dev: UMC device whose parent PCI device we are looking for
126− *
127− * DIRTY!!! DON'T RELY ON THIS
128− *
129− * FIXME: This is as dirty as it gets, but we need some way to check
130− * the correct type of umc_dev->parent (so that for example, we can
131− * cast to pci_dev). Casting to pci_dev is necessary because at some
132− * point we need to request resources from the device. Mapping is
133− * easily over come (ioremap and stuff are bus agnostic), but hooking
134− * up to some error handlers (such as pci error handlers) might need
135− * this.
136− *
137− * THIS might (probably will) be removed in the future, so don't count
138− * on it.
139− */
140−static inline struct pci_dev *umc_parent_pci_dev(struct umc_dev *umc_dev)
141−{
142− struct pci_dev *pci_dev = NULL;
143− if (dev_is_pci(umc_dev->dev.parent))
144− pci_dev = to_pci_dev(umc_dev->dev.parent);
145− return pci_dev;
146−}
147−
148−/**
149− * umc_dev_get() - reference a UMC device.
150− * @umc_dev: Pointer to UMC device.
151− *
152− * NOTE: we are assuming in this whole scheme that the parent device
153− * is referenced at _probe() time and unreferenced at _remove()
154− * time by the parent's subsystem.
155− */
156−static inline struct umc_dev *umc_dev_get(struct umc_dev *umc_dev)
157−{
158− get_device(&umc_dev->dev);
159− return umc_dev;
160−}
161−
162−/**
163− * umc_dev_put() - unreference a UMC device.
164− * @umc_dev: Pointer to UMC device.
165− */
166−static inline void umc_dev_put(struct umc_dev *umc_dev)
167−{
168− put_device(&umc_dev->dev);
169−}
170−
171−/**
172− * umc_set_drvdata - set UMC device's driver data.
173− * @umc_dev: Pointer to UMC device.
174− * @data: Data to set.
175− */
176−static inline void umc_set_drvdata(struct umc_dev *umc_dev, void *data)
177−{
178− dev_set_drvdata(&umc_dev->dev, data);
179−}
180−
181−/**
182− * umc_get_drvdata - recover UMC device's driver data.
183− * @umc_dev: Pointer to UMC device.
184− */
185−static inline void *umc_get_drvdata(struct umc_dev *umc_dev)
186−{
187− return dev_get_drvdata(&umc_dev->dev);
188−}
189−
190−int umc_controller_reset(struct umc_dev *umc);
191−
192−#endif /* #ifndef _LINUX_UWB_UMC_H_ */
include/linux/uwb/whci.h+0−102
@@ -1,102 +0,0 @@
1−/* SPDX-License-Identifier: GPL-2.0-only */
2−/*
3− * Wireless Host Controller Interface for Ultra-Wide-Band and Wireless USB
4− *
5− * Copyright (C) 2005-2006 Intel Corporation
6− * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
7− *
8− * References:
9− * [WHCI] Wireless Host Controller Interface Specification for
10− * Certified Wireless Universal Serial Bus, revision 0.95.
11− */
12−#ifndef _LINUX_UWB_WHCI_H_
13−#define _LINUX_UWB_WHCI_H_
14−
15−#include <linux/pci.h>
16−
17−/*
18− * UWB interface capability registers (offsets from UWBBASE)
19− *
20− * [WHCI] section 2.2
21− */
22−#define UWBCAPINFO 0x00 /* == UWBCAPDATA(0) */
23−# define UWBCAPINFO_TO_N_CAPS(c) (((c) >> 0) & 0xFull)
24−#define UWBCAPDATA(n) (8*(n))
25−# define UWBCAPDATA_TO_VERSION(c) (((c) >> 32) & 0xFFFFull)
26−# define UWBCAPDATA_TO_OFFSET(c) (((c) >> 18) & 0x3FFFull)
27−# define UWBCAPDATA_TO_BAR(c) (((c) >> 16) & 0x3ull)
28−# define UWBCAPDATA_TO_SIZE(c) ((((c) >> 8) & 0xFFull) * sizeof(u32))
29−# define UWBCAPDATA_TO_CAP_ID(c) (((c) >> 0) & 0xFFull)
30−
31−/* Size of the WHCI capability data (including the RC capability) for
32− a device with n capabilities. */
33−#define UWBCAPDATA_SIZE(n) (8 + 8*(n))
34−
35−
36−/*
37− * URC registers (offsets from URCBASE)
38− *
39− * [WHCI] section 2.3
40− */
41−#define URCCMD 0x00
42−# define URCCMD_RESET (1 << 31) /* UMC Hardware reset */
43−# define URCCMD_RS (1 << 30) /* Run/Stop */
44−# define URCCMD_EARV (1 << 29) /* Event Address Register Valid */
45−# define URCCMD_ACTIVE (1 << 15) /* Command is active */
46−# define URCCMD_IWR (1 << 14) /* Interrupt When Ready */
47−# define URCCMD_SIZE_MASK 0x00000fff /* Command size mask */
48−#define URCSTS 0x04
49−# define URCSTS_EPS (1 << 17) /* Event Processing Status */
50−# define URCSTS_HALTED (1 << 16) /* RC halted */
51−# define URCSTS_HSE (1 << 10) /* Host System Error...fried */
52−# define URCSTS_ER (1 << 9) /* Event Ready */
53−# define URCSTS_RCI (1 << 8) /* Ready for Command Interrupt */
54−# define URCSTS_INT_MASK 0x00000700 /* URC interrupt sources */
55−# define URCSTS_ISI 0x000000ff /* Interrupt Source Identification */
56−#define URCINTR 0x08
57−# define URCINTR_EN_ALL 0x000007ff /* Enable all interrupt sources */
58−#define URCCMDADDR 0x10
59−#define URCEVTADDR 0x18
60−# define URCEVTADDR_OFFSET_MASK 0xfff /* Event pointer offset mask */
61−
62−
63−/** Write 32 bit @value to little endian register at @addr */
64−static inline
65−void le_writel(u32 value, void __iomem *addr)
66−{
67− iowrite32(value, addr);
68−}
69−
70−
71−/** Read from 32 bit little endian register at @addr */
72−static inline
73−u32 le_readl(void __iomem *addr)
74−{
75− return ioread32(addr);
76−}
77−
78−
79−/** Write 64 bit @value to little endian register at @addr */
80−static inline
81−void le_writeq(u64 value, void __iomem *addr)
82−{
83− iowrite32(value, addr);
84− iowrite32(value >> 32, addr + 4);
85−}
86−
87−
88−/** Read from 64 bit little endian register at @addr */
89−static inline
90−u64 le_readq(void __iomem *addr)
91−{
92− u64 value;
93− value = ioread32(addr);
94− value |= (u64)ioread32(addr + 4) << 32;
95− return value;
96−}
97−
98−extern int whci_wait_for(struct device *dev, u32 __iomem *reg,
99− u32 mask, u32 result,
100− unsigned long max_ms, const char *tag);
101−
102−#endif /* #ifndef _LINUX_UWB_WHCI_H_ */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t