diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-07 18:37:24 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-07 18:37:24 -0500 |
commit | 7c7758f99d39d529a64d4f60d22129bbf2f16d74 (patch) | |
tree | 8847b5e56812fe4c4c812cfffc78e391a91f4ebe /include | |
parent | 67acd8b4b7a3f1b183ae358e1dfdb8a80e170736 (diff) | |
parent | 8a70da82edc50aa7a4b54864babf2d72538ba1bb (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6: (123 commits)
wimax/i2400m: add CREDITS and MAINTAINERS entries
wimax: export linux/wimax.h and linux/wimax/i2400m.h with headers_install
i2400m: Makefile and Kconfig
i2400m/SDIO: TX and RX path backends
i2400m/SDIO: firmware upload backend
i2400m/SDIO: probe/disconnect, dev init/shutdown and reset backends
i2400m/SDIO: header for the SDIO subdriver
i2400m/USB: TX and RX path backends
i2400m/USB: firmware upload backend
i2400m/USB: probe/disconnect, dev init/shutdown and reset backends
i2400m/USB: header for the USB bus driver
i2400m: debugfs controls
i2400m: various functions for device management
i2400m: RX and TX data/control paths
i2400m: firmware loading and bootrom initialization
i2400m: linkage to the networking stack
i2400m: Generic probe/disconnect, reset and message passing
i2400m: host/device procotol and core driver definitions
i2400m: documentation and instructions for usage
wimax: Makefile, Kconfig and docbook linkage for the stack
...
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/Kbuild | 2 | ||||
-rw-r--r-- | include/linux/debugfs.h | 2 | ||||
-rw-r--r-- | include/linux/oxu210hp.h | 7 | ||||
-rw-r--r-- | include/linux/usb.h | 30 | ||||
-rw-r--r-- | include/linux/usb/association.h | 22 | ||||
-rw-r--r-- | include/linux/usb/gpio_vbus.h | 30 | ||||
-rw-r--r-- | include/linux/usb/musb.h | 5 | ||||
-rw-r--r-- | include/linux/usb/otg.h | 1 | ||||
-rw-r--r-- | include/linux/usb_usual.h | 7 | ||||
-rw-r--r-- | include/linux/wimax.h | 234 | ||||
-rw-r--r-- | include/linux/wimax/Kbuild | 1 | ||||
-rw-r--r-- | include/linux/wimax/debug.h | 453 | ||||
-rw-r--r-- | include/linux/wimax/i2400m.h | 512 | ||||
-rw-r--r-- | include/net/wimax.h | 520 |
14 files changed, 1806 insertions, 20 deletions
diff --git a/include/linux/Kbuild b/include/linux/Kbuild index a3323f337e4d..12e9a2957caf 100644 --- a/include/linux/Kbuild +++ b/include/linux/Kbuild | |||
@@ -371,3 +371,5 @@ unifdef-y += xattr.h | |||
371 | unifdef-y += xfrm.h | 371 | unifdef-y += xfrm.h |
372 | 372 | ||
373 | objhdr-y += version.h | 373 | objhdr-y += version.h |
374 | header-y += wimax.h | ||
375 | header-y += wimax/ | ||
diff --git a/include/linux/debugfs.h b/include/linux/debugfs.h index e1a6c046cea3..23936b16426b 100644 --- a/include/linux/debugfs.h +++ b/include/linux/debugfs.h | |||
@@ -63,6 +63,8 @@ struct dentry *debugfs_create_x16(const char *name, mode_t mode, | |||
63 | struct dentry *parent, u16 *value); | 63 | struct dentry *parent, u16 *value); |
64 | struct dentry *debugfs_create_x32(const char *name, mode_t mode, | 64 | struct dentry *debugfs_create_x32(const char *name, mode_t mode, |
65 | struct dentry *parent, u32 *value); | 65 | struct dentry *parent, u32 *value); |
66 | struct dentry *debugfs_create_size_t(const char *name, mode_t mode, | ||
67 | struct dentry *parent, size_t *value); | ||
66 | struct dentry *debugfs_create_bool(const char *name, mode_t mode, | 68 | struct dentry *debugfs_create_bool(const char *name, mode_t mode, |
67 | struct dentry *parent, u32 *value); | 69 | struct dentry *parent, u32 *value); |
68 | 70 | ||
diff --git a/include/linux/oxu210hp.h b/include/linux/oxu210hp.h new file mode 100644 index 000000000000..0bf96eae5389 --- /dev/null +++ b/include/linux/oxu210hp.h | |||
@@ -0,0 +1,7 @@ | |||
1 | /* platform data for the OXU210HP HCD */ | ||
2 | |||
3 | struct oxu210hp_platform_data { | ||
4 | unsigned int bus16:1; | ||
5 | unsigned int use_hcd_otg:1; | ||
6 | unsigned int use_hcd_sph:1; | ||
7 | }; | ||
diff --git a/include/linux/usb.h b/include/linux/usb.h index f72aa51f7bcd..85ee9be9361e 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h | |||
@@ -108,6 +108,7 @@ enum usb_interface_condition { | |||
108 | * (in probe()), bound to a driver, or unbinding (in disconnect()) | 108 | * (in probe()), bound to a driver, or unbinding (in disconnect()) |
109 | * @is_active: flag set when the interface is bound and not suspended. | 109 | * @is_active: flag set when the interface is bound and not suspended. |
110 | * @sysfs_files_created: sysfs attributes exist | 110 | * @sysfs_files_created: sysfs attributes exist |
111 | * @ep_devs_created: endpoint child pseudo-devices exist | ||
111 | * @unregistering: flag set when the interface is being unregistered | 112 | * @unregistering: flag set when the interface is being unregistered |
112 | * @needs_remote_wakeup: flag set when the driver requires remote-wakeup | 113 | * @needs_remote_wakeup: flag set when the driver requires remote-wakeup |
113 | * capability during autosuspend. | 114 | * capability during autosuspend. |
@@ -120,6 +121,11 @@ enum usb_interface_condition { | |||
120 | * to the sysfs representation for that device. | 121 | * to the sysfs representation for that device. |
121 | * @pm_usage_cnt: PM usage counter for this interface; autosuspend is not | 122 | * @pm_usage_cnt: PM usage counter for this interface; autosuspend is not |
122 | * allowed unless the counter is 0. | 123 | * allowed unless the counter is 0. |
124 | * @reset_ws: Used for scheduling resets from atomic context. | ||
125 | * @reset_running: set to 1 if the interface is currently running a | ||
126 | * queued reset so that usb_cancel_queued_reset() doesn't try to | ||
127 | * remove from the workqueue when running inside the worker | ||
128 | * thread. See __usb_queue_reset_device(). | ||
123 | * | 129 | * |
124 | * USB device drivers attach to interfaces on a physical device. Each | 130 | * USB device drivers attach to interfaces on a physical device. Each |
125 | * interface encapsulates a single high level function, such as feeding | 131 | * interface encapsulates a single high level function, such as feeding |
@@ -164,14 +170,17 @@ struct usb_interface { | |||
164 | enum usb_interface_condition condition; /* state of binding */ | 170 | enum usb_interface_condition condition; /* state of binding */ |
165 | unsigned is_active:1; /* the interface is not suspended */ | 171 | unsigned is_active:1; /* the interface is not suspended */ |
166 | unsigned sysfs_files_created:1; /* the sysfs attributes exist */ | 172 | unsigned sysfs_files_created:1; /* the sysfs attributes exist */ |
173 | unsigned ep_devs_created:1; /* endpoint "devices" exist */ | ||
167 | unsigned unregistering:1; /* unregistration is in progress */ | 174 | unsigned unregistering:1; /* unregistration is in progress */ |
168 | unsigned needs_remote_wakeup:1; /* driver requires remote wakeup */ | 175 | unsigned needs_remote_wakeup:1; /* driver requires remote wakeup */ |
169 | unsigned needs_altsetting0:1; /* switch to altsetting 0 is pending */ | 176 | unsigned needs_altsetting0:1; /* switch to altsetting 0 is pending */ |
170 | unsigned needs_binding:1; /* needs delayed unbind/rebind */ | 177 | unsigned needs_binding:1; /* needs delayed unbind/rebind */ |
178 | unsigned reset_running:1; | ||
171 | 179 | ||
172 | struct device dev; /* interface specific device info */ | 180 | struct device dev; /* interface specific device info */ |
173 | struct device *usb_dev; | 181 | struct device *usb_dev; |
174 | int pm_usage_cnt; /* usage counter for autosuspend */ | 182 | int pm_usage_cnt; /* usage counter for autosuspend */ |
183 | struct work_struct reset_ws; /* for resets in atomic context */ | ||
175 | }; | 184 | }; |
176 | #define to_usb_interface(d) container_of(d, struct usb_interface, dev) | 185 | #define to_usb_interface(d) container_of(d, struct usb_interface, dev) |
177 | #define interface_to_usbdev(intf) \ | 186 | #define interface_to_usbdev(intf) \ |
@@ -329,7 +338,7 @@ struct usb_bus { | |||
329 | #endif | 338 | #endif |
330 | struct device *dev; /* device for this bus */ | 339 | struct device *dev; /* device for this bus */ |
331 | 340 | ||
332 | #if defined(CONFIG_USB_MON) | 341 | #if defined(CONFIG_USB_MON) || defined(CONFIG_USB_MON_MODULE) |
333 | struct mon_bus *mon_bus; /* non-null when associated */ | 342 | struct mon_bus *mon_bus; /* non-null when associated */ |
334 | int monitored; /* non-zero when monitored */ | 343 | int monitored; /* non-zero when monitored */ |
335 | #endif | 344 | #endif |
@@ -398,6 +407,7 @@ struct usb_tt; | |||
398 | * @urbnum: number of URBs submitted for the whole device | 407 | * @urbnum: number of URBs submitted for the whole device |
399 | * @active_duration: total time device is not suspended | 408 | * @active_duration: total time device is not suspended |
400 | * @autosuspend: for delayed autosuspends | 409 | * @autosuspend: for delayed autosuspends |
410 | * @autoresume: for autoresumes requested while in_interrupt | ||
401 | * @pm_mutex: protects PM operations | 411 | * @pm_mutex: protects PM operations |
402 | * @last_busy: time of last use | 412 | * @last_busy: time of last use |
403 | * @autosuspend_delay: in jiffies | 413 | * @autosuspend_delay: in jiffies |
@@ -476,6 +486,7 @@ struct usb_device { | |||
476 | 486 | ||
477 | #ifdef CONFIG_PM | 487 | #ifdef CONFIG_PM |
478 | struct delayed_work autosuspend; | 488 | struct delayed_work autosuspend; |
489 | struct work_struct autoresume; | ||
479 | struct mutex pm_mutex; | 490 | struct mutex pm_mutex; |
480 | 491 | ||
481 | unsigned long last_busy; | 492 | unsigned long last_busy; |
@@ -505,6 +516,7 @@ extern int usb_lock_device_for_reset(struct usb_device *udev, | |||
505 | 516 | ||
506 | /* USB port reset for device reinitialization */ | 517 | /* USB port reset for device reinitialization */ |
507 | extern int usb_reset_device(struct usb_device *dev); | 518 | extern int usb_reset_device(struct usb_device *dev); |
519 | extern void usb_queue_reset_device(struct usb_interface *dev); | ||
508 | 520 | ||
509 | extern struct usb_device *usb_find_device(u16 vendor_id, u16 product_id); | 521 | extern struct usb_device *usb_find_device(u16 vendor_id, u16 product_id); |
510 | 522 | ||
@@ -513,6 +525,8 @@ extern struct usb_device *usb_find_device(u16 vendor_id, u16 product_id); | |||
513 | extern int usb_autopm_set_interface(struct usb_interface *intf); | 525 | extern int usb_autopm_set_interface(struct usb_interface *intf); |
514 | extern int usb_autopm_get_interface(struct usb_interface *intf); | 526 | extern int usb_autopm_get_interface(struct usb_interface *intf); |
515 | extern void usb_autopm_put_interface(struct usb_interface *intf); | 527 | extern void usb_autopm_put_interface(struct usb_interface *intf); |
528 | extern int usb_autopm_get_interface_async(struct usb_interface *intf); | ||
529 | extern void usb_autopm_put_interface_async(struct usb_interface *intf); | ||
516 | 530 | ||
517 | static inline void usb_autopm_enable(struct usb_interface *intf) | 531 | static inline void usb_autopm_enable(struct usb_interface *intf) |
518 | { | 532 | { |
@@ -539,8 +553,13 @@ static inline int usb_autopm_set_interface(struct usb_interface *intf) | |||
539 | static inline int usb_autopm_get_interface(struct usb_interface *intf) | 553 | static inline int usb_autopm_get_interface(struct usb_interface *intf) |
540 | { return 0; } | 554 | { return 0; } |
541 | 555 | ||
556 | static inline int usb_autopm_get_interface_async(struct usb_interface *intf) | ||
557 | { return 0; } | ||
558 | |||
542 | static inline void usb_autopm_put_interface(struct usb_interface *intf) | 559 | static inline void usb_autopm_put_interface(struct usb_interface *intf) |
543 | { } | 560 | { } |
561 | static inline void usb_autopm_put_interface_async(struct usb_interface *intf) | ||
562 | { } | ||
544 | static inline void usb_autopm_enable(struct usb_interface *intf) | 563 | static inline void usb_autopm_enable(struct usb_interface *intf) |
545 | { } | 564 | { } |
546 | static inline void usb_autopm_disable(struct usb_interface *intf) | 565 | static inline void usb_autopm_disable(struct usb_interface *intf) |
@@ -1050,7 +1069,7 @@ struct usb_device_driver { | |||
1050 | void (*disconnect) (struct usb_device *udev); | 1069 | void (*disconnect) (struct usb_device *udev); |
1051 | 1070 | ||
1052 | int (*suspend) (struct usb_device *udev, pm_message_t message); | 1071 | int (*suspend) (struct usb_device *udev, pm_message_t message); |
1053 | int (*resume) (struct usb_device *udev); | 1072 | int (*resume) (struct usb_device *udev, pm_message_t message); |
1054 | struct usbdrv_wrap drvwrap; | 1073 | struct usbdrv_wrap drvwrap; |
1055 | unsigned int supports_autosuspend:1; | 1074 | unsigned int supports_autosuspend:1; |
1056 | }; | 1075 | }; |
@@ -1321,7 +1340,7 @@ struct urb { | |||
1321 | struct kref kref; /* reference count of the URB */ | 1340 | struct kref kref; /* reference count of the URB */ |
1322 | void *hcpriv; /* private data for host controller */ | 1341 | void *hcpriv; /* private data for host controller */ |
1323 | atomic_t use_count; /* concurrent submissions counter */ | 1342 | atomic_t use_count; /* concurrent submissions counter */ |
1324 | u8 reject; /* submissions will fail */ | 1343 | atomic_t reject; /* submissions will fail */ |
1325 | int unlinked; /* unlink error code */ | 1344 | int unlinked; /* unlink error code */ |
1326 | 1345 | ||
1327 | /* public: documented fields in the urb that can be used by drivers */ | 1346 | /* public: documented fields in the urb that can be used by drivers */ |
@@ -1466,6 +1485,7 @@ extern void usb_poison_urb(struct urb *urb); | |||
1466 | extern void usb_unpoison_urb(struct urb *urb); | 1485 | extern void usb_unpoison_urb(struct urb *urb); |
1467 | extern void usb_kill_anchored_urbs(struct usb_anchor *anchor); | 1486 | extern void usb_kill_anchored_urbs(struct usb_anchor *anchor); |
1468 | extern void usb_poison_anchored_urbs(struct usb_anchor *anchor); | 1487 | extern void usb_poison_anchored_urbs(struct usb_anchor *anchor); |
1488 | extern void usb_unpoison_anchored_urbs(struct usb_anchor *anchor); | ||
1469 | extern void usb_unlink_anchored_urbs(struct usb_anchor *anchor); | 1489 | extern void usb_unlink_anchored_urbs(struct usb_anchor *anchor); |
1470 | extern void usb_anchor_urb(struct urb *urb, struct usb_anchor *anchor); | 1490 | extern void usb_anchor_urb(struct urb *urb, struct usb_anchor *anchor); |
1471 | extern void usb_unanchor_urb(struct urb *urb); | 1491 | extern void usb_unanchor_urb(struct urb *urb); |
@@ -1722,10 +1742,6 @@ extern void usb_unregister_notify(struct notifier_block *nb); | |||
1722 | 1742 | ||
1723 | #define err(format, arg...) printk(KERN_ERR KBUILD_MODNAME ": " \ | 1743 | #define err(format, arg...) printk(KERN_ERR KBUILD_MODNAME ": " \ |
1724 | format "\n" , ## arg) | 1744 | format "\n" , ## arg) |
1725 | #define info(format, arg...) printk(KERN_INFO KBUILD_MODNAME ": " \ | ||
1726 | format "\n" , ## arg) | ||
1727 | #define warn(format, arg...) printk(KERN_WARNING KBUILD_MODNAME ": " \ | ||
1728 | format "\n" , ## arg) | ||
1729 | 1745 | ||
1730 | #endif /* __KERNEL__ */ | 1746 | #endif /* __KERNEL__ */ |
1731 | 1747 | ||
diff --git a/include/linux/usb/association.h b/include/linux/usb/association.h index 07c5e3cf5898..0a4a18b3c1bb 100644 --- a/include/linux/usb/association.h +++ b/include/linux/usb/association.h | |||
@@ -28,17 +28,17 @@ struct wusb_am_attr { | |||
28 | }; | 28 | }; |
29 | 29 | ||
30 | /* Different fields defined by the spec */ | 30 | /* Different fields defined by the spec */ |
31 | #define WUSB_AR_AssociationTypeId { .id = 0x0000, .len = 2 } | 31 | #define WUSB_AR_AssociationTypeId { .id = cpu_to_le16(0x0000), .len = cpu_to_le16(2) } |
32 | #define WUSB_AR_AssociationSubTypeId { .id = 0x0001, .len = 2 } | 32 | #define WUSB_AR_AssociationSubTypeId { .id = cpu_to_le16(0x0001), .len = cpu_to_le16(2) } |
33 | #define WUSB_AR_Length { .id = 0x0002, .len = 4 } | 33 | #define WUSB_AR_Length { .id = cpu_to_le16(0x0002), .len = cpu_to_le16(4) } |
34 | #define WUSB_AR_AssociationStatus { .id = 0x0004, .len = 4 } | 34 | #define WUSB_AR_AssociationStatus { .id = cpu_to_le16(0x0004), .len = cpu_to_le16(4) } |
35 | #define WUSB_AR_LangID { .id = 0x0008, .len = 2 } | 35 | #define WUSB_AR_LangID { .id = cpu_to_le16(0x0008), .len = cpu_to_le16(2) } |
36 | #define WUSB_AR_DeviceFriendlyName { .id = 0x000b, .len = 64 } /* max */ | 36 | #define WUSB_AR_DeviceFriendlyName { .id = cpu_to_le16(0x000b), .len = cpu_to_le16(64) } /* max */ |
37 | #define WUSB_AR_HostFriendlyName { .id = 0x000c, .len = 64 } /* max */ | 37 | #define WUSB_AR_HostFriendlyName { .id = cpu_to_le16(0x000c), .len = cpu_to_le16(64) } /* max */ |
38 | #define WUSB_AR_CHID { .id = 0x1000, .len = 16 } | 38 | #define WUSB_AR_CHID { .id = cpu_to_le16(0x1000), .len = cpu_to_le16(16) } |
39 | #define WUSB_AR_CDID { .id = 0x1001, .len = 16 } | 39 | #define WUSB_AR_CDID { .id = cpu_to_le16(0x1001), .len = cpu_to_le16(16) } |
40 | #define WUSB_AR_ConnectionContext { .id = 0x1002, .len = 48 } | 40 | #define WUSB_AR_ConnectionContext { .id = cpu_to_le16(0x1002), .len = cpu_to_le16(48) } |
41 | #define WUSB_AR_BandGroups { .id = 0x1004, .len = 2 } | 41 | #define WUSB_AR_BandGroups { .id = cpu_to_le16(0x1004), .len = cpu_to_le16(2) } |
42 | 42 | ||
43 | /* CBAF Control Requests (AMS1.0[T4-1] */ | 43 | /* CBAF Control Requests (AMS1.0[T4-1] */ |
44 | enum { | 44 | enum { |
diff --git a/include/linux/usb/gpio_vbus.h b/include/linux/usb/gpio_vbus.h new file mode 100644 index 000000000000..d9f03ccc2d60 --- /dev/null +++ b/include/linux/usb/gpio_vbus.h | |||
@@ -0,0 +1,30 @@ | |||
1 | /* | ||
2 | * A simple GPIO VBUS sensing driver for B peripheral only devices | ||
3 | * with internal transceivers. | ||
4 | * Optionally D+ pullup can be controlled by a second GPIO. | ||
5 | * | ||
6 | * Copyright (c) 2008 Philipp Zabel <philipp.zabel@gmail.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | /** | ||
15 | * struct gpio_vbus_mach_info - configuration for gpio_vbus | ||
16 | * @gpio_vbus: VBUS sensing GPIO | ||
17 | * @gpio_pullup: optional D+ or D- pullup GPIO (else negative/invalid) | ||
18 | * @gpio_vbus_inverted: true if gpio_vbus is active low | ||
19 | * @gpio_pullup_inverted: true if gpio_pullup is active low | ||
20 | * | ||
21 | * The VBUS sensing GPIO should have a pulldown, which will normally be | ||
22 | * part of a resistor ladder turning a 4.0V-5.25V level on VBUS into a | ||
23 | * value the GPIO detects as active. Some systems will use comparators. | ||
24 | */ | ||
25 | struct gpio_vbus_mach_info { | ||
26 | int gpio_vbus; | ||
27 | int gpio_pullup; | ||
28 | bool gpio_vbus_inverted; | ||
29 | bool gpio_pullup_inverted; | ||
30 | }; | ||
diff --git a/include/linux/usb/musb.h b/include/linux/usb/musb.h index 630962c04ca4..d6aad0ea6033 100644 --- a/include/linux/usb/musb.h +++ b/include/linux/usb/musb.h | |||
@@ -47,6 +47,11 @@ struct musb_hdrc_config { | |||
47 | u8 ram_bits; /* ram address size */ | 47 | u8 ram_bits; /* ram address size */ |
48 | 48 | ||
49 | struct musb_hdrc_eps_bits *eps_bits; | 49 | struct musb_hdrc_eps_bits *eps_bits; |
50 | #ifdef CONFIG_BLACKFIN | ||
51 | /* A GPIO controlling VRSEL in Blackfin */ | ||
52 | unsigned int gpio_vrsel; | ||
53 | #endif | ||
54 | |||
50 | }; | 55 | }; |
51 | 56 | ||
52 | struct musb_hdrc_platform_data { | 57 | struct musb_hdrc_platform_data { |
diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h index 1db25d152ad8..94df4fe6c6c0 100644 --- a/include/linux/usb/otg.h +++ b/include/linux/usb/otg.h | |||
@@ -84,6 +84,7 @@ extern int otg_set_transceiver(struct otg_transceiver *); | |||
84 | 84 | ||
85 | /* for usb host and peripheral controller drivers */ | 85 | /* for usb host and peripheral controller drivers */ |
86 | extern struct otg_transceiver *otg_get_transceiver(void); | 86 | extern struct otg_transceiver *otg_get_transceiver(void); |
87 | extern void otg_put_transceiver(struct otg_transceiver *); | ||
87 | 88 | ||
88 | static inline int | 89 | static inline int |
89 | otg_start_hnp(struct otg_transceiver *otg) | 90 | otg_start_hnp(struct otg_transceiver *otg) |
diff --git a/include/linux/usb_usual.h b/include/linux/usb_usual.h index d9a3bbe38e6b..1eea1ab68dc4 100644 --- a/include/linux/usb_usual.h +++ b/include/linux/usb_usual.h | |||
@@ -52,8 +52,11 @@ | |||
52 | US_FLAG(MAX_SECTORS_MIN,0x00002000) \ | 52 | US_FLAG(MAX_SECTORS_MIN,0x00002000) \ |
53 | /* Sets max_sectors to arch min */ \ | 53 | /* Sets max_sectors to arch min */ \ |
54 | US_FLAG(BULK_IGNORE_TAG,0x00004000) \ | 54 | US_FLAG(BULK_IGNORE_TAG,0x00004000) \ |
55 | /* Ignore tag mismatch in bulk operations */ | 55 | /* Ignore tag mismatch in bulk operations */ \ |
56 | 56 | US_FLAG(SANE_SENSE, 0x00008000) \ | |
57 | /* Sane Sense (> 18 bytes) */ \ | ||
58 | US_FLAG(CAPACITY_OK, 0x00010000) \ | ||
59 | /* READ CAPACITY response is correct */ | ||
57 | 60 | ||
58 | #define US_FLAG(name, value) US_FL_##name = value , | 61 | #define US_FLAG(name, value) US_FL_##name = value , |
59 | enum { US_DO_ALL_FLAGS }; | 62 | enum { US_DO_ALL_FLAGS }; |
diff --git a/include/linux/wimax.h b/include/linux/wimax.h new file mode 100644 index 000000000000..c89de7f4e5b9 --- /dev/null +++ b/include/linux/wimax.h | |||
@@ -0,0 +1,234 @@ | |||
1 | /* | ||
2 | * Linux WiMax | ||
3 | * API for user space | ||
4 | * | ||
5 | * | ||
6 | * Copyright (C) 2007-2008 Intel Corporation. All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * | ||
12 | * * Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer. | ||
14 | * * Redistributions in binary form must reproduce the above copyright | ||
15 | * notice, this list of conditions and the following disclaimer in | ||
16 | * the documentation and/or other materials provided with the | ||
17 | * distribution. | ||
18 | * * Neither the name of Intel Corporation nor the names of its | ||
19 | * contributors may be used to endorse or promote products derived | ||
20 | * from this software without specific prior written permission. | ||
21 | * | ||
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
25 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
26 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
33 | * | ||
34 | * | ||
35 | * Intel Corporation <linux-wimax@intel.com> | ||
36 | * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> | ||
37 | * - Initial implementation | ||
38 | * | ||
39 | * | ||
40 | * This file declares the user/kernel protocol that is spoken over | ||
41 | * Generic Netlink, as well as any type declaration that is to be used | ||
42 | * by kernel and user space. | ||
43 | * | ||
44 | * It is intended for user space to clone it verbatim to use it as a | ||
45 | * primary reference for definitions. | ||
46 | * | ||
47 | * Stuff intended for kernel usage as well as full protocol and stack | ||
48 | * documentation is rooted in include/net/wimax.h. | ||
49 | */ | ||
50 | |||
51 | #ifndef __LINUX__WIMAX_H__ | ||
52 | #define __LINUX__WIMAX_H__ | ||
53 | |||
54 | #include <linux/types.h> | ||
55 | |||
56 | enum { | ||
57 | /** | ||
58 | * Version of the interface (unsigned decimal, MMm, max 25.5) | ||
59 | * M - Major: change if removing or modifying an existing call. | ||
60 | * m - minor: change when adding a new call | ||
61 | */ | ||
62 | WIMAX_GNL_VERSION = 00, | ||
63 | /* Generic NetLink attributes */ | ||
64 | WIMAX_GNL_ATTR_INVALID = 0x00, | ||
65 | WIMAX_GNL_ATTR_MAX = 10, | ||
66 | }; | ||
67 | |||
68 | |||
69 | /* | ||
70 | * Generic NetLink operations | ||
71 | * | ||
72 | * Most of these map to an API call; _OP_ stands for operation, _RP_ | ||
73 | * for reply and _RE_ for report (aka: signal). | ||
74 | */ | ||
75 | enum { | ||
76 | WIMAX_GNL_OP_MSG_FROM_USER, /* User to kernel message */ | ||
77 | WIMAX_GNL_OP_MSG_TO_USER, /* Kernel to user message */ | ||
78 | WIMAX_GNL_OP_RFKILL, /* Run wimax_rfkill() */ | ||
79 | WIMAX_GNL_OP_RESET, /* Run wimax_rfkill() */ | ||
80 | WIMAX_GNL_RE_STATE_CHANGE, /* Report: status change */ | ||
81 | }; | ||
82 | |||
83 | |||
84 | /* Message from user / to user */ | ||
85 | enum { | ||
86 | WIMAX_GNL_MSG_IFIDX = 1, | ||
87 | WIMAX_GNL_MSG_PIPE_NAME, | ||
88 | WIMAX_GNL_MSG_DATA, | ||
89 | }; | ||
90 | |||
91 | |||
92 | /* | ||
93 | * wimax_rfkill() | ||
94 | * | ||
95 | * The state of the radio (ON/OFF) is mapped to the rfkill subsystem's | ||
96 | * switch state (DISABLED/ENABLED). | ||
97 | */ | ||
98 | enum wimax_rf_state { | ||
99 | WIMAX_RF_OFF = 0, /* Radio is off, rfkill on/enabled */ | ||
100 | WIMAX_RF_ON = 1, /* Radio is on, rfkill off/disabled */ | ||
101 | WIMAX_RF_QUERY = 2, | ||
102 | }; | ||
103 | |||
104 | /* Attributes */ | ||
105 | enum { | ||
106 | WIMAX_GNL_RFKILL_IFIDX = 1, | ||
107 | WIMAX_GNL_RFKILL_STATE, | ||
108 | }; | ||
109 | |||
110 | |||
111 | /* Attributes for wimax_reset() */ | ||
112 | enum { | ||
113 | WIMAX_GNL_RESET_IFIDX = 1, | ||
114 | }; | ||
115 | |||
116 | |||
117 | /* | ||
118 | * Attributes for the Report State Change | ||
119 | * | ||
120 | * For now we just have the old and new states; new attributes might | ||
121 | * be added later on. | ||
122 | */ | ||
123 | enum { | ||
124 | WIMAX_GNL_STCH_IFIDX = 1, | ||
125 | WIMAX_GNL_STCH_STATE_OLD, | ||
126 | WIMAX_GNL_STCH_STATE_NEW, | ||
127 | }; | ||
128 | |||
129 | |||
130 | /** | ||
131 | * enum wimax_st - The different states of a WiMAX device | ||
132 | * @__WIMAX_ST_NULL: The device structure has been allocated and zeroed, | ||
133 | * but still wimax_dev_add() hasn't been called. There is no state. | ||
134 | * | ||
135 | * @WIMAX_ST_DOWN: The device has been registered with the WiMAX and | ||
136 | * networking stacks, but it is not initialized (normally that is | ||
137 | * done with 'ifconfig DEV up' [or equivalent], which can upload | ||
138 | * firmware and enable communications with the device). | ||
139 | * In this state, the device is powered down and using as less | ||
140 | * power as possible. | ||
141 | * This state is the default after a call to wimax_dev_add(). It | ||
142 | * is ok to have drivers move directly to %WIMAX_ST_UNINITIALIZED | ||
143 | * or %WIMAX_ST_RADIO_OFF in _probe() after the call to | ||
144 | * wimax_dev_add(). | ||
145 | * It is recommended that the driver leaves this state when | ||
146 | * calling 'ifconfig DEV up' and enters it back on 'ifconfig DEV | ||
147 | * down'. | ||
148 | * | ||
149 | * @__WIMAX_ST_QUIESCING: The device is being torn down, so no API | ||
150 | * operations are allowed to proceed except the ones needed to | ||
151 | * complete the device clean up process. | ||
152 | * | ||
153 | * @WIMAX_ST_UNINITIALIZED: [optional] Communication with the device | ||
154 | * is setup, but the device still requires some configuration | ||
155 | * before being operational. | ||
156 | * Some WiMAX API calls might work. | ||
157 | * | ||
158 | * @WIMAX_ST_RADIO_OFF: The device is fully up; radio is off (wether | ||
159 | * by hardware or software switches). | ||
160 | * It is recommended to always leave the device in this state | ||
161 | * after initialization. | ||
162 | * | ||
163 | * @WIMAX_ST_READY: The device is fully up and radio is on. | ||
164 | * | ||
165 | * @WIMAX_ST_SCANNING: [optional] The device has been instructed to | ||
166 | * scan. In this state, the device cannot be actively connected to | ||
167 | * a network. | ||
168 | * | ||
169 | * @WIMAX_ST_CONNECTING: The device is connecting to a network. This | ||
170 | * state exists because in some devices, the connect process can | ||
171 | * include a number of negotiations between user space, kernel | ||
172 | * space and the device. User space needs to know what the device | ||
173 | * is doing. If the connect sequence in a device is atomic and | ||
174 | * fast, the device can transition directly to CONNECTED | ||
175 | * | ||
176 | * @WIMAX_ST_CONNECTED: The device is connected to a network. | ||
177 | * | ||
178 | * @__WIMAX_ST_INVALID: This is an invalid state used to mark the | ||
179 | * maximum numeric value of states. | ||
180 | * | ||
181 | * Description: | ||
182 | * | ||
183 | * Transitions from one state to another one are atomic and can only | ||
184 | * be caused in kernel space with wimax_state_change(). To read the | ||
185 | * state, use wimax_state_get(). | ||
186 | * | ||
187 | * States starting with __ are internal and shall not be used or | ||
188 | * referred to by drivers or userspace. They look ugly, but that's the | ||
189 | * point -- if any use is made non-internal to the stack, it is easier | ||
190 | * to catch on review. | ||
191 | * | ||
192 | * All API operations [with well defined exceptions] will take the | ||
193 | * device mutex before starting and then check the state. If the state | ||
194 | * is %__WIMAX_ST_NULL, %WIMAX_ST_DOWN, %WIMAX_ST_UNINITIALIZED or | ||
195 | * %__WIMAX_ST_QUIESCING, it will drop the lock and quit with | ||
196 | * -%EINVAL, -%ENOMEDIUM, -%ENOTCONN or -%ESHUTDOWN. | ||
197 | * | ||
198 | * The order of the definitions is important, so we can do numerical | ||
199 | * comparisons (eg: < %WIMAX_ST_RADIO_OFF means the device is not ready | ||
200 | * to operate). | ||
201 | */ | ||
202 | /* | ||
203 | * The allowed state transitions are described in the table below | ||
204 | * (states in rows can go to states in columns where there is an X): | ||
205 | * | ||
206 | * UNINI RADIO READY SCAN CONNEC CONNEC | ||
207 | * NULL DOWN QUIESCING TIALIZED OFF NING TING TED | ||
208 | * NULL - x | ||
209 | * DOWN - x x x | ||
210 | * QUIESCING x - | ||
211 | * UNINITIALIZED x - x | ||
212 | * RADIO_OFF x - x | ||
213 | * READY x x - x x x | ||
214 | * SCANNING x x x - x x | ||
215 | * CONNECTING x x x x - x | ||
216 | * CONNECTED x x x - | ||
217 | * | ||
218 | * This table not available in kernel-doc because the formatting messes it up. | ||
219 | */ | ||
220 | enum wimax_st { | ||
221 | __WIMAX_ST_NULL = 0, | ||
222 | WIMAX_ST_DOWN, | ||
223 | __WIMAX_ST_QUIESCING, | ||
224 | WIMAX_ST_UNINITIALIZED, | ||
225 | WIMAX_ST_RADIO_OFF, | ||
226 | WIMAX_ST_READY, | ||
227 | WIMAX_ST_SCANNING, | ||
228 | WIMAX_ST_CONNECTING, | ||
229 | WIMAX_ST_CONNECTED, | ||
230 | __WIMAX_ST_INVALID /* Always keep last */ | ||
231 | }; | ||
232 | |||
233 | |||
234 | #endif /* #ifndef __LINUX__WIMAX_H__ */ | ||
diff --git a/include/linux/wimax/Kbuild b/include/linux/wimax/Kbuild new file mode 100644 index 000000000000..3cb4f269bb09 --- /dev/null +++ b/include/linux/wimax/Kbuild | |||
@@ -0,0 +1 @@ | |||
header-y += i2400m.h | |||
diff --git a/include/linux/wimax/debug.h b/include/linux/wimax/debug.h new file mode 100644 index 000000000000..ba0c49399a83 --- /dev/null +++ b/include/linux/wimax/debug.h | |||
@@ -0,0 +1,453 @@ | |||
1 | /* | ||
2 | * Linux WiMAX | ||
3 | * Collection of tools to manage debug operations. | ||
4 | * | ||
5 | * | ||
6 | * Copyright (C) 2005-2007 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 | * Don't #include this file directly, read on! | ||
25 | * | ||
26 | * | ||
27 | * EXECUTING DEBUGGING ACTIONS OR NOT | ||
28 | * | ||
29 | * The main thing this framework provides is decission power to take a | ||
30 | * debug action (like printing a message) if the current debug level | ||
31 | * allows it. | ||
32 | * | ||
33 | * The decission power is at two levels: at compile-time (what does | ||
34 | * not make it is compiled out) and at run-time. The run-time | ||
35 | * selection is done per-submodule (as they are declared by the user | ||
36 | * of the framework). | ||
37 | * | ||
38 | * A call to d_test(L) (L being the target debug level) returns true | ||
39 | * if the action should be taken because the current debug levels | ||
40 | * allow it (both compile and run time). | ||
41 | * | ||
42 | * It follows that a call to d_test() that can be determined to be | ||
43 | * always false at compile time will get the code depending on it | ||
44 | * compiled out by optimization. | ||
45 | * | ||
46 | * | ||
47 | * DEBUG LEVELS | ||
48 | * | ||
49 | * It is up to the caller to define how much a debugging level is. | ||
50 | * | ||
51 | * Convention sets 0 as "no debug" (so an action marked as debug level 0 | ||
52 | * will always be taken). The increasing debug levels are used for | ||
53 | * increased verbosity. | ||
54 | * | ||
55 | * | ||
56 | * USAGE | ||
57 | * | ||
58 | * Group the code in modules and submodules inside each module [which | ||
59 | * in most cases maps to Linux modules and .c files that compose | ||
60 | * those]. | ||
61 | * | ||
62 | * | ||
63 | * For each module, there is: | ||
64 | * | ||
65 | * - a MODULENAME (single word, legal C identifier) | ||
66 | * | ||
67 | * - a debug-levels.h header file that declares the list of | ||
68 | * submodules and that is included by all .c files that use | ||
69 | * the debugging tools. The file name can be anything. | ||
70 | * | ||
71 | * - some (optional) .c code to manipulate the runtime debug levels | ||
72 | * through debugfs. | ||
73 | * | ||
74 | * The debug-levels.h file would look like: | ||
75 | * | ||
76 | * #ifndef __debug_levels__h__ | ||
77 | * #define __debug_levels__h__ | ||
78 | * | ||
79 | * #define D_MODULENAME modulename | ||
80 | * #define D_MASTER 10 | ||
81 | * | ||
82 | * #include <linux/wimax/debug.h> | ||
83 | * | ||
84 | * enum d_module { | ||
85 | * D_SUBMODULE_DECLARE(submodule_1), | ||
86 | * D_SUBMODULE_DECLARE(submodule_2), | ||
87 | * ... | ||
88 | * D_SUBMODULE_DECLARE(submodule_N) | ||
89 | * }; | ||
90 | * | ||
91 | * #endif | ||
92 | * | ||
93 | * D_MASTER is the maximum compile-time debug level; any debug actions | ||
94 | * above this will be out. D_MODULENAME is the module name (legal C | ||
95 | * identifier), which has to be unique for each module (to avoid | ||
96 | * namespace collisions during linkage). Note those #defines need to | ||
97 | * be done before #including debug.h | ||
98 | * | ||
99 | * We declare N different submodules whose debug level can be | ||
100 | * independently controlled during runtime. | ||
101 | * | ||
102 | * In a .c file of the module (and only in one of them), define the | ||
103 | * following code: | ||
104 | * | ||
105 | * struct d_level D_LEVEL[] = { | ||
106 | * D_SUBMODULE_DEFINE(submodule_1), | ||
107 | * D_SUBMODULE_DEFINE(submodule_2), | ||
108 | * ... | ||
109 | * D_SUBMODULE_DEFINE(submodule_N), | ||
110 | * }; | ||
111 | * size_t D_LEVEL_SIZE = ARRAY_SIZE(D_LEVEL); | ||
112 | * | ||
113 | * Externs for d_level_MODULENAME and d_level_size_MODULENAME are used | ||
114 | * and declared in this file using the D_LEVEL and D_LEVEL_SIZE macros | ||
115 | * #defined also in this file. | ||
116 | * | ||
117 | * To manipulate from user space the levels, create a debugfs dentry | ||
118 | * and then register each submodule with: | ||
119 | * | ||
120 | * result = d_level_register_debugfs("PREFIX_", submodule_X, parent); | ||
121 | * if (result < 0) | ||
122 | * goto error; | ||
123 | * | ||
124 | * Where PREFIX_ is a name of your chosing. This will create debugfs | ||
125 | * file with a single numeric value that can be use to tweak it. To | ||
126 | * remove the entires, just use debugfs_remove_recursive() on 'parent'. | ||
127 | * | ||
128 | * NOTE: remember that even if this will show attached to some | ||
129 | * particular instance of a device, the settings are *global*. | ||
130 | * | ||
131 | * | ||
132 | * On each submodule (for example, .c files), the debug infrastructure | ||
133 | * should be included like this: | ||
134 | * | ||
135 | * #define D_SUBMODULE submodule_x // matches one in debug-levels.h | ||
136 | * #include "debug-levels.h" | ||
137 | * | ||
138 | * after #including all your include files. | ||
139 | * | ||
140 | * | ||
141 | * Now you can use the d_*() macros below [d_test(), d_fnstart(), | ||
142 | * d_fnend(), d_printf(), d_dump()]. | ||
143 | * | ||
144 | * If their debug level is greater than D_MASTER, they will be | ||
145 | * compiled out. | ||
146 | * | ||
147 | * If their debug level is lower or equal than D_MASTER but greater | ||
148 | * than the current debug level of their submodule, they'll be | ||
149 | * ignored. | ||
150 | * | ||
151 | * Otherwise, the action will be performed. | ||
152 | */ | ||
153 | #ifndef __debug__h__ | ||
154 | #define __debug__h__ | ||
155 | |||
156 | #include <linux/types.h> | ||
157 | #include <linux/device.h> | ||
158 | |||
159 | |||
160 | /* Backend stuff */ | ||
161 | |||
162 | /* | ||
163 | * Debug backend: generate a message header from a 'struct device' | ||
164 | * | ||
165 | * @head: buffer where to place the header | ||
166 | * @head_size: length of @head | ||
167 | * @dev: pointer to device used to generate a header from. If NULL, | ||
168 | * an empty ("") header is generated. | ||
169 | */ | ||
170 | static inline | ||
171 | void __d_head(char *head, size_t head_size, | ||
172 | struct device *dev) | ||
173 | { | ||
174 | if (dev == NULL) | ||
175 | head[0] = 0; | ||
176 | else if ((unsigned long)dev < 4096) { | ||
177 | printk(KERN_ERR "E: Corrupt dev %p\n", dev); | ||
178 | WARN_ON(1); | ||
179 | } else | ||
180 | snprintf(head, head_size, "%s %s: ", | ||
181 | dev_driver_string(dev), dev->bus_id); | ||
182 | } | ||
183 | |||
184 | |||
185 | /* | ||
186 | * Debug backend: log some message if debugging is enabled | ||
187 | * | ||
188 | * @l: intended debug level | ||
189 | * @tag: tag to prefix the message with | ||
190 | * @dev: 'struct device' associated to this message | ||
191 | * @f: printf-like format and arguments | ||
192 | * | ||
193 | * Note this is optimized out if it doesn't pass the compile-time | ||
194 | * check; however, it is *always* compiled. This is useful to make | ||
195 | * sure the printf-like formats and variables are always checked and | ||
196 | * they don't get bit rot if you have all the debugging disabled. | ||
197 | */ | ||
198 | #define _d_printf(l, tag, dev, f, a...) \ | ||
199 | do { \ | ||
200 | char head[64]; \ | ||
201 | if (!d_test(l)) \ | ||
202 | break; \ | ||
203 | __d_head(head, sizeof(head), dev); \ | ||
204 | printk(KERN_ERR "%s%s%s: " f, head, __func__, tag, ##a); \ | ||
205 | } while (0) | ||
206 | |||
207 | |||
208 | /* | ||
209 | * CPP sintatic sugar to generate A_B like symbol names when one of | ||
210 | * the arguments is a a preprocessor #define. | ||
211 | */ | ||
212 | #define __D_PASTE__(varname, modulename) varname##_##modulename | ||
213 | #define __D_PASTE(varname, modulename) (__D_PASTE__(varname, modulename)) | ||
214 | #define _D_SUBMODULE_INDEX(_name) (D_SUBMODULE_DECLARE(_name)) | ||
215 | |||
216 | |||
217 | /* | ||
218 | * Store a submodule's runtime debug level and name | ||
219 | */ | ||
220 | struct d_level { | ||
221 | u8 level; | ||
222 | const char *name; | ||
223 | }; | ||
224 | |||
225 | |||
226 | /* | ||
227 | * List of available submodules and their debug levels | ||
228 | * | ||
229 | * We call them d_level_MODULENAME and d_level_size_MODULENAME; the | ||
230 | * macros D_LEVEL and D_LEVEL_SIZE contain the name already for | ||
231 | * convenience. | ||
232 | * | ||
233 | * This array and the size are defined on some .c file that is part of | ||
234 | * the current module. | ||
235 | */ | ||
236 | #define D_LEVEL __D_PASTE(d_level, D_MODULENAME) | ||
237 | #define D_LEVEL_SIZE __D_PASTE(d_level_size, D_MODULENAME) | ||
238 | |||
239 | extern struct d_level D_LEVEL[]; | ||
240 | extern size_t D_LEVEL_SIZE; | ||
241 | |||
242 | |||
243 | /* | ||
244 | * Frontend stuff | ||
245 | * | ||
246 | * | ||
247 | * Stuff you need to declare prior to using the actual "debug" actions | ||
248 | * (defined below). | ||
249 | */ | ||
250 | |||
251 | #ifndef D_MODULENAME | ||
252 | #error D_MODULENAME is not defined in your debug-levels.h file | ||
253 | /** | ||
254 | * D_MODULE - Name of the current module | ||
255 | * | ||
256 | * #define in your module's debug-levels.h, making sure it is | ||
257 | * unique. This has to be a legal C identifier. | ||
258 | */ | ||
259 | #define D_MODULENAME undefined_modulename | ||
260 | #endif | ||
261 | |||
262 | |||
263 | #ifndef D_MASTER | ||
264 | #warning D_MASTER not defined, but debug.h included! [see docs] | ||
265 | /** | ||
266 | * D_MASTER - Compile time maximum debug level | ||
267 | * | ||
268 | * #define in your debug-levels.h file to the maximum debug level the | ||
269 | * runtime code will be allowed to have. This allows you to provide a | ||
270 | * main knob. | ||
271 | * | ||
272 | * Anything above that level will be optimized out of the compile. | ||
273 | * | ||
274 | * Defaults to zero (no debug code compiled in). | ||
275 | * | ||
276 | * Maximum one definition per module (at the debug-levels.h file). | ||
277 | */ | ||
278 | #define D_MASTER 0 | ||
279 | #endif | ||
280 | |||
281 | #ifndef D_SUBMODULE | ||
282 | #error D_SUBMODULE not defined, but debug.h included! [see docs] | ||
283 | /** | ||
284 | * D_SUBMODULE - Name of the current submodule | ||
285 | * | ||
286 | * #define in your submodule .c file before #including debug-levels.h | ||
287 | * to the name of the current submodule as previously declared and | ||
288 | * defined with D_SUBMODULE_DECLARE() (in your module's | ||
289 | * debug-levels.h) and D_SUBMODULE_DEFINE(). | ||
290 | * | ||
291 | * This is used to provide runtime-control over the debug levels. | ||
292 | * | ||
293 | * Maximum one per .c file! Can be shared among different .c files | ||
294 | * (meaning they belong to the same submodule categorization). | ||
295 | */ | ||
296 | #define D_SUBMODULE undefined_module | ||
297 | #endif | ||
298 | |||
299 | |||
300 | /** | ||
301 | * D_SUBMODULE_DECLARE - Declare a submodule for runtime debug level control | ||
302 | * | ||
303 | * @_name: name of the submodule, restricted to the chars that make up a | ||
304 | * valid C identifier ([a-zA-Z0-9_]). | ||
305 | * | ||
306 | * Declare in the module's debug-levels.h header file as: | ||
307 | * | ||
308 | * enum d_module { | ||
309 | * D_SUBMODULE_DECLARE(submodule_1), | ||
310 | * D_SUBMODULE_DECLARE(submodule_2), | ||
311 | * D_SUBMODULE_DECLARE(submodule_3), | ||
312 | * }; | ||
313 | * | ||
314 | * Some corresponding .c file needs to have a matching | ||
315 | * D_SUBMODULE_DEFINE(). | ||
316 | */ | ||
317 | #define D_SUBMODULE_DECLARE(_name) __D_SUBMODULE_##_name | ||
318 | |||
319 | |||
320 | /** | ||
321 | * D_SUBMODULE_DEFINE - Define a submodule for runtime debug level control | ||
322 | * | ||
323 | * @_name: name of the submodule, restricted to the chars that make up a | ||
324 | * valid C identifier ([a-zA-Z0-9_]). | ||
325 | * | ||
326 | * Use once per module (in some .c file) as: | ||
327 | * | ||
328 | * static | ||
329 | * struct d_level d_level_SUBMODULENAME[] = { | ||
330 | * D_SUBMODULE_DEFINE(submodule_1), | ||
331 | * D_SUBMODULE_DEFINE(submodule_2), | ||
332 | * D_SUBMODULE_DEFINE(submodule_3), | ||
333 | * }; | ||
334 | * size_t d_level_size_SUBDMODULENAME = ARRAY_SIZE(d_level_SUBDMODULENAME); | ||
335 | * | ||
336 | * Matching D_SUBMODULE_DECLARE()s have to be present in a | ||
337 | * debug-levels.h header file. | ||
338 | */ | ||
339 | #define D_SUBMODULE_DEFINE(_name) \ | ||
340 | [__D_SUBMODULE_##_name] = { \ | ||
341 | .level = 0, \ | ||
342 | .name = #_name \ | ||
343 | } | ||
344 | |||
345 | |||
346 | |||
347 | /* The actual "debug" operations */ | ||
348 | |||
349 | |||
350 | /** | ||
351 | * d_test - Returns true if debugging should be enabled | ||
352 | * | ||
353 | * @l: intended debug level (unsigned) | ||
354 | * | ||
355 | * If the master debug switch is enabled and the current settings are | ||
356 | * higher or equal to the requested level, then debugging | ||
357 | * output/actions should be enabled. | ||
358 | * | ||
359 | * NOTE: | ||
360 | * | ||
361 | * This needs to be coded so that it can be evaluated in compile | ||
362 | * time; this is why the ugly BUG_ON() is placed in there, so the | ||
363 | * D_MASTER evaluation compiles all out if it is compile-time false. | ||
364 | */ | ||
365 | #define d_test(l) \ | ||
366 | ({ \ | ||
367 | unsigned __l = l; /* type enforcer */ \ | ||
368 | (D_MASTER) >= __l \ | ||
369 | && ({ \ | ||
370 | BUG_ON(_D_SUBMODULE_INDEX(D_SUBMODULE) >= D_LEVEL_SIZE);\ | ||
371 | D_LEVEL[_D_SUBMODULE_INDEX(D_SUBMODULE)].level >= __l; \ | ||
372 | }); \ | ||
373 | }) | ||
374 | |||
375 | |||
376 | /** | ||
377 | * d_fnstart - log message at function start if debugging enabled | ||
378 | * | ||
379 | * @l: intended debug level | ||
380 | * @_dev: 'struct device' pointer, NULL if none (for context) | ||
381 | * @f: printf-like format and arguments | ||
382 | */ | ||
383 | #define d_fnstart(l, _dev, f, a...) _d_printf(l, " FNSTART", _dev, f, ## a) | ||
384 | |||
385 | |||
386 | /** | ||
387 | * d_fnend - log message at function end if debugging enabled | ||
388 | * | ||
389 | * @l: intended debug level | ||
390 | * @_dev: 'struct device' pointer, NULL if none (for context) | ||
391 | * @f: printf-like format and arguments | ||
392 | */ | ||
393 | #define d_fnend(l, _dev, f, a...) _d_printf(l, " FNEND", _dev, f, ## a) | ||
394 | |||
395 | |||
396 | /** | ||
397 | * d_printf - log message if debugging enabled | ||
398 | * | ||
399 | * @l: intended debug level | ||
400 | * @_dev: 'struct device' pointer, NULL if none (for context) | ||
401 | * @f: printf-like format and arguments | ||
402 | */ | ||
403 | #define d_printf(l, _dev, f, a...) _d_printf(l, "", _dev, f, ## a) | ||
404 | |||
405 | |||
406 | /** | ||
407 | * d_dump - log buffer hex dump if debugging enabled | ||
408 | * | ||
409 | * @l: intended debug level | ||
410 | * @_dev: 'struct device' pointer, NULL if none (for context) | ||
411 | * @f: printf-like format and arguments | ||
412 | */ | ||
413 | #define d_dump(l, dev, ptr, size) \ | ||
414 | do { \ | ||
415 | char head[64]; \ | ||
416 | if (!d_test(l)) \ | ||
417 | break; \ | ||
418 | __d_head(head, sizeof(head), dev); \ | ||
419 | print_hex_dump(KERN_ERR, head, 0, 16, 1, \ | ||
420 | ((void *) ptr), (size), 0); \ | ||
421 | } while (0) | ||
422 | |||
423 | |||
424 | /** | ||
425 | * Export a submodule's debug level over debugfs as PREFIXSUBMODULE | ||
426 | * | ||
427 | * @prefix: string to prefix the name with | ||
428 | * @submodule: name of submodule (not a string, just the name) | ||
429 | * @dentry: debugfs parent dentry | ||
430 | * | ||
431 | * Returns: 0 if ok, < 0 errno on error. | ||
432 | * | ||
433 | * For removing, just use debugfs_remove_recursive() on the parent. | ||
434 | */ | ||
435 | #define d_level_register_debugfs(prefix, name, parent) \ | ||
436 | ({ \ | ||
437 | int rc; \ | ||
438 | struct dentry *fd; \ | ||
439 | struct dentry *verify_parent_type = parent; \ | ||
440 | fd = debugfs_create_u8( \ | ||
441 | prefix #name, 0600, verify_parent_type, \ | ||
442 | &(D_LEVEL[__D_SUBMODULE_ ## name].level)); \ | ||
443 | rc = PTR_ERR(fd); \ | ||
444 | if (IS_ERR(fd) && rc != -ENODEV) \ | ||
445 | printk(KERN_ERR "%s: Can't create debugfs entry %s: " \ | ||
446 | "%d\n", __func__, prefix #name, rc); \ | ||
447 | else \ | ||
448 | rc = 0; \ | ||
449 | rc; \ | ||
450 | }) | ||
451 | |||
452 | |||
453 | #endif /* #ifndef __debug__h__ */ | ||
diff --git a/include/linux/wimax/i2400m.h b/include/linux/wimax/i2400m.h new file mode 100644 index 000000000000..74198f5bb4dc --- /dev/null +++ b/include/linux/wimax/i2400m.h | |||
@@ -0,0 +1,512 @@ | |||
1 | /* | ||
2 | * Intel Wireless WiMax Connection 2400m | ||
3 | * Host-Device protocol interface definitions | ||
4 | * | ||
5 | * | ||
6 | * Copyright (C) 2007-2008 Intel Corporation. All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * | ||
12 | * * Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer. | ||
14 | * * Redistributions in binary form must reproduce the above copyright | ||
15 | * notice, this list of conditions and the following disclaimer in | ||
16 | * the documentation and/or other materials provided with the | ||
17 | * distribution. | ||
18 | * * Neither the name of Intel Corporation nor the names of its | ||
19 | * contributors may be used to endorse or promote products derived | ||
20 | * from this software without specific prior written permission. | ||
21 | * | ||
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
25 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
26 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
33 | * | ||
34 | * | ||
35 | * Intel Corporation <linux-wimax@intel.com> | ||
36 | * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> | ||
37 | * - Initial implementation | ||
38 | * | ||
39 | * | ||
40 | * This header defines the data structures and constants used to | ||
41 | * communicate with the device. | ||
42 | * | ||
43 | * BOOTMODE/BOOTROM/FIRMWARE UPLOAD PROTOCOL | ||
44 | * | ||
45 | * The firmware upload protocol is quite simple and only requires a | ||
46 | * handful of commands. See drivers/net/wimax/i2400m/fw.c for more | ||
47 | * details. | ||
48 | * | ||
49 | * The BCF data structure is for the firmware file header. | ||
50 | * | ||
51 | * | ||
52 | * THE DATA / CONTROL PROTOCOL | ||
53 | * | ||
54 | * This is the normal protocol spoken with the device once the | ||
55 | * firmware is uploaded. It transports data payloads and control | ||
56 | * messages back and forth. | ||
57 | * | ||
58 | * It consists 'messages' that pack one or more payloads each. The | ||
59 | * format is described in detail in drivers/net/wimax/i2400m/rx.c and | ||
60 | * tx.c. | ||
61 | * | ||
62 | * | ||
63 | * THE L3L4 PROTOCOL | ||
64 | * | ||
65 | * The term L3L4 refers to Layer 3 (the device), Layer 4 (the | ||
66 | * driver/host software). | ||
67 | * | ||
68 | * This is the control protocol used by the host to control the i2400m | ||
69 | * device (scan, connect, disconnect...). This is sent to / received | ||
70 | * as control frames. These frames consist of a header and zero or | ||
71 | * more TLVs with information. We call each control frame a "message". | ||
72 | * | ||
73 | * Each message is composed of: | ||
74 | * | ||
75 | * HEADER | ||
76 | * [TLV0 + PAYLOAD0] | ||
77 | * [TLV1 + PAYLOAD1] | ||
78 | * [...] | ||
79 | * [TLVN + PAYLOADN] | ||
80 | * | ||
81 | * The HEADER is defined by 'struct i2400m_l3l4_hdr'. The payloads are | ||
82 | * defined by a TLV structure (Type Length Value) which is a 'header' | ||
83 | * (struct i2400m_tlv_hdr) and then the payload. | ||
84 | * | ||
85 | * All integers are represented as Little Endian. | ||
86 | * | ||
87 | * - REQUESTS AND EVENTS | ||
88 | * | ||
89 | * The requests can be clasified as follows: | ||
90 | * | ||
91 | * COMMAND: implies a request from the host to the device requesting | ||
92 | * an action being performed. The device will reply with a | ||
93 | * message (with the same type as the command), status and | ||
94 | * no (TLV) payload. Execution of a command might cause | ||
95 | * events (of different type) to be sent later on as | ||
96 | * device's state changes. | ||
97 | * | ||
98 | * GET/SET: similar to COMMAND, but will not cause other | ||
99 | * EVENTs. The reply, in the case of GET, will contain | ||
100 | * TLVs with the requested information. | ||
101 | * | ||
102 | * EVENT: asynchronous messages sent from the device, maybe as a | ||
103 | * consequence of previous COMMANDs but disassociated from | ||
104 | * them. | ||
105 | * | ||
106 | * Only one request might be pending at the same time (ie: don't | ||
107 | * parallelize nor post another GET request before the previous | ||
108 | * COMMAND has been acknowledged with it's corresponding reply by the | ||
109 | * device). | ||
110 | * | ||
111 | * The different requests and their formats are described below: | ||
112 | * | ||
113 | * I2400M_MT_* Message types | ||
114 | * I2400M_MS_* Message status (for replies, events) | ||
115 | * i2400m_tlv_* TLVs | ||
116 | * | ||
117 | * data types are named 'struct i2400m_msg_OPNAME', OPNAME matching the | ||
118 | * operation. | ||
119 | */ | ||
120 | |||
121 | #ifndef __LINUX__WIMAX__I2400M_H__ | ||
122 | #define __LINUX__WIMAX__I2400M_H__ | ||
123 | |||
124 | #include <linux/types.h> | ||
125 | |||
126 | |||
127 | /* | ||
128 | * Host Device Interface (HDI) common to all busses | ||
129 | */ | ||
130 | |||
131 | /* Boot-mode (firmware upload mode) commands */ | ||
132 | |||
133 | /* Header for the firmware file */ | ||
134 | struct i2400m_bcf_hdr { | ||
135 | __le32 module_type; | ||
136 | __le32 header_len; | ||
137 | __le32 header_version; | ||
138 | __le32 module_id; | ||
139 | __le32 module_vendor; | ||
140 | __le32 date; /* BCD YYYMMDD */ | ||
141 | __le32 size; | ||
142 | __le32 key_size; /* in dwords */ | ||
143 | __le32 modulus_size; /* in dwords */ | ||
144 | __le32 exponent_size; /* in dwords */ | ||
145 | __u8 reserved[88]; | ||
146 | } __attribute__ ((packed)); | ||
147 | |||
148 | /* Boot mode opcodes */ | ||
149 | enum i2400m_brh_opcode { | ||
150 | I2400M_BRH_READ = 1, | ||
151 | I2400M_BRH_WRITE = 2, | ||
152 | I2400M_BRH_JUMP = 3, | ||
153 | I2400M_BRH_SIGNED_JUMP = 8, | ||
154 | I2400M_BRH_HASH_PAYLOAD_ONLY = 9, | ||
155 | }; | ||
156 | |||
157 | /* Boot mode command masks and stuff */ | ||
158 | enum i2400m_brh { | ||
159 | I2400M_BRH_SIGNATURE = 0xcbbc0000, | ||
160 | I2400M_BRH_SIGNATURE_MASK = 0xffff0000, | ||
161 | I2400M_BRH_SIGNATURE_SHIFT = 16, | ||
162 | I2400M_BRH_OPCODE_MASK = 0x0000000f, | ||
163 | I2400M_BRH_RESPONSE_MASK = 0x000000f0, | ||
164 | I2400M_BRH_RESPONSE_SHIFT = 4, | ||
165 | I2400M_BRH_DIRECT_ACCESS = 0x00000400, | ||
166 | I2400M_BRH_RESPONSE_REQUIRED = 0x00000200, | ||
167 | I2400M_BRH_USE_CHECKSUM = 0x00000100, | ||
168 | }; | ||
169 | |||
170 | |||
171 | /* Constants for bcf->module_id */ | ||
172 | enum i2400m_bcf_mod_id { | ||
173 | /* Firmware file carries its own pokes -- pokes are a set of | ||
174 | * magical values that have to be written in certain memory | ||
175 | * addresses to get the device up and ready for firmware | ||
176 | * download when it is in non-signed boot mode. */ | ||
177 | I2400M_BCF_MOD_ID_POKES = 0x000000001, | ||
178 | }; | ||
179 | |||
180 | |||
181 | /** | ||
182 | * i2400m_bootrom_header - Header for a boot-mode command | ||
183 | * | ||
184 | * @cmd: the above command descriptor | ||
185 | * @target_addr: where on the device memory should the action be performed. | ||
186 | * @data_size: for read/write, amount of data to be read/written | ||
187 | * @block_checksum: checksum value (if applicable) | ||
188 | * @payload: the beginning of data attached to this header | ||
189 | */ | ||
190 | struct i2400m_bootrom_header { | ||
191 | __le32 command; /* Compose with enum i2400_brh */ | ||
192 | __le32 target_addr; | ||
193 | __le32 data_size; | ||
194 | __le32 block_checksum; | ||
195 | char payload[0]; | ||
196 | } __attribute__ ((packed)); | ||
197 | |||
198 | |||
199 | /* | ||
200 | * Data / control protocol | ||
201 | */ | ||
202 | |||
203 | /* Packet types for the host-device interface */ | ||
204 | enum i2400m_pt { | ||
205 | I2400M_PT_DATA = 0, | ||
206 | I2400M_PT_CTRL, | ||
207 | I2400M_PT_TRACE, /* For device debug */ | ||
208 | I2400M_PT_RESET_WARM, /* device reset */ | ||
209 | I2400M_PT_RESET_COLD, /* USB[transport] reset, like reconnect */ | ||
210 | I2400M_PT_ILLEGAL | ||
211 | }; | ||
212 | |||
213 | |||
214 | /* | ||
215 | * Payload for a data packet | ||
216 | * | ||
217 | * This is prefixed to each and every outgoing DATA type. | ||
218 | */ | ||
219 | struct i2400m_pl_data_hdr { | ||
220 | __le32 reserved; | ||
221 | } __attribute__((packed)); | ||
222 | |||
223 | |||
224 | /* Misc constants */ | ||
225 | enum { | ||
226 | I2400M_PL_PAD = 16, /* Payload data size alignment */ | ||
227 | I2400M_PL_SIZE_MAX = 0x3EFF, | ||
228 | I2400M_MAX_PLS_IN_MSG = 60, | ||
229 | /* protocol barkers: sync sequences; for notifications they | ||
230 | * are sent in groups of four. */ | ||
231 | I2400M_H2D_PREVIEW_BARKER = 0xcafe900d, | ||
232 | I2400M_COLD_RESET_BARKER = 0xc01dc01d, | ||
233 | I2400M_WARM_RESET_BARKER = 0x50f750f7, | ||
234 | I2400M_NBOOT_BARKER = 0xdeadbeef, | ||
235 | I2400M_SBOOT_BARKER = 0x0ff1c1a1, | ||
236 | I2400M_ACK_BARKER = 0xfeedbabe, | ||
237 | I2400M_D2H_MSG_BARKER = 0xbeefbabe, | ||
238 | }; | ||
239 | |||
240 | |||
241 | /* | ||
242 | * Hardware payload descriptor | ||
243 | * | ||
244 | * Bitfields encoded in a struct to enforce typing semantics. | ||
245 | * | ||
246 | * Look in rx.c and tx.c for a full description of the format. | ||
247 | */ | ||
248 | struct i2400m_pld { | ||
249 | __le32 val; | ||
250 | } __attribute__ ((packed)); | ||
251 | |||
252 | #define I2400M_PLD_SIZE_MASK 0x00003fff | ||
253 | #define I2400M_PLD_TYPE_SHIFT 16 | ||
254 | #define I2400M_PLD_TYPE_MASK 0x000f0000 | ||
255 | |||
256 | /* | ||
257 | * Header for a TX message or RX message | ||
258 | * | ||
259 | * @barker: preamble | ||
260 | * @size: used for management of the FIFO queue buffer; before | ||
261 | * sending, this is converted to be a real preamble. This | ||
262 | * indicates the real size of the TX message that starts at this | ||
263 | * point. If the highest bit is set, then this message is to be | ||
264 | * skipped. | ||
265 | * @sequence: sequence number of this message | ||
266 | * @offset: offset where the message itself starts -- see the comments | ||
267 | * in the file header about message header and payload descriptor | ||
268 | * alignment. | ||
269 | * @num_pls: number of payloads in this message | ||
270 | * @padding: amount of padding bytes at the end of the message to make | ||
271 | * it be of block-size aligned | ||
272 | * | ||
273 | * Look in rx.c and tx.c for a full description of the format. | ||
274 | */ | ||
275 | struct i2400m_msg_hdr { | ||
276 | union { | ||
277 | __le32 barker; | ||
278 | __u32 size; /* same size type as barker!! */ | ||
279 | }; | ||
280 | union { | ||
281 | __le32 sequence; | ||
282 | __u32 offset; /* same size type as barker!! */ | ||
283 | }; | ||
284 | __le16 num_pls; | ||
285 | __le16 rsv1; | ||
286 | __le16 padding; | ||
287 | __le16 rsv2; | ||
288 | struct i2400m_pld pld[0]; | ||
289 | } __attribute__ ((packed)); | ||
290 | |||
291 | |||
292 | |||
293 | /* | ||
294 | * L3/L4 control protocol | ||
295 | */ | ||
296 | |||
297 | enum { | ||
298 | /* Interface version */ | ||
299 | I2400M_L3L4_VERSION = 0x0100, | ||
300 | }; | ||
301 | |||
302 | /* Message types */ | ||
303 | enum i2400m_mt { | ||
304 | I2400M_MT_RESERVED = 0x0000, | ||
305 | I2400M_MT_INVALID = 0xffff, | ||
306 | I2400M_MT_REPORT_MASK = 0x8000, | ||
307 | |||
308 | I2400M_MT_GET_SCAN_RESULT = 0x4202, | ||
309 | I2400M_MT_SET_SCAN_PARAM = 0x4402, | ||
310 | I2400M_MT_CMD_RF_CONTROL = 0x4602, | ||
311 | I2400M_MT_CMD_SCAN = 0x4603, | ||
312 | I2400M_MT_CMD_CONNECT = 0x4604, | ||
313 | I2400M_MT_CMD_DISCONNECT = 0x4605, | ||
314 | I2400M_MT_CMD_EXIT_IDLE = 0x4606, | ||
315 | I2400M_MT_GET_LM_VERSION = 0x5201, | ||
316 | I2400M_MT_GET_DEVICE_INFO = 0x5202, | ||
317 | I2400M_MT_GET_LINK_STATUS = 0x5203, | ||
318 | I2400M_MT_GET_STATISTICS = 0x5204, | ||
319 | I2400M_MT_GET_STATE = 0x5205, | ||
320 | I2400M_MT_GET_MEDIA_STATUS = 0x5206, | ||
321 | I2400M_MT_SET_INIT_CONFIG = 0x5404, | ||
322 | I2400M_MT_CMD_INIT = 0x5601, | ||
323 | I2400M_MT_CMD_TERMINATE = 0x5602, | ||
324 | I2400M_MT_CMD_MODE_OF_OP = 0x5603, | ||
325 | I2400M_MT_CMD_RESET_DEVICE = 0x5604, | ||
326 | I2400M_MT_CMD_MONITOR_CONTROL = 0x5605, | ||
327 | I2400M_MT_CMD_ENTER_POWERSAVE = 0x5606, | ||
328 | I2400M_MT_GET_TLS_OPERATION_RESULT = 0x6201, | ||
329 | I2400M_MT_SET_EAP_SUCCESS = 0x6402, | ||
330 | I2400M_MT_SET_EAP_FAIL = 0x6403, | ||
331 | I2400M_MT_SET_EAP_KEY = 0x6404, | ||
332 | I2400M_MT_CMD_SEND_EAP_RESPONSE = 0x6602, | ||
333 | I2400M_MT_REPORT_SCAN_RESULT = 0xc002, | ||
334 | I2400M_MT_REPORT_STATE = 0xd002, | ||
335 | I2400M_MT_REPORT_POWERSAVE_READY = 0xd005, | ||
336 | I2400M_MT_REPORT_EAP_REQUEST = 0xe002, | ||
337 | I2400M_MT_REPORT_EAP_RESTART = 0xe003, | ||
338 | I2400M_MT_REPORT_ALT_ACCEPT = 0xe004, | ||
339 | I2400M_MT_REPORT_KEY_REQUEST = 0xe005, | ||
340 | }; | ||
341 | |||
342 | |||
343 | /* | ||
344 | * Message Ack Status codes | ||
345 | * | ||
346 | * When a message is replied-to, this status is reported. | ||
347 | */ | ||
348 | enum i2400m_ms { | ||
349 | I2400M_MS_DONE_OK = 0, | ||
350 | I2400M_MS_DONE_IN_PROGRESS = 1, | ||
351 | I2400M_MS_INVALID_OP = 2, | ||
352 | I2400M_MS_BAD_STATE = 3, | ||
353 | I2400M_MS_ILLEGAL_VALUE = 4, | ||
354 | I2400M_MS_MISSING_PARAMS = 5, | ||
355 | I2400M_MS_VERSION_ERROR = 6, | ||
356 | I2400M_MS_ACCESSIBILITY_ERROR = 7, | ||
357 | I2400M_MS_BUSY = 8, | ||
358 | I2400M_MS_CORRUPTED_TLV = 9, | ||
359 | I2400M_MS_UNINITIALIZED = 10, | ||
360 | I2400M_MS_UNKNOWN_ERROR = 11, | ||
361 | I2400M_MS_PRODUCTION_ERROR = 12, | ||
362 | I2400M_MS_NO_RF = 13, | ||
363 | I2400M_MS_NOT_READY_FOR_POWERSAVE = 14, | ||
364 | I2400M_MS_THERMAL_CRITICAL = 15, | ||
365 | I2400M_MS_MAX | ||
366 | }; | ||
367 | |||
368 | |||
369 | /** | ||
370 | * i2400m_tlv - enumeration of the different types of TLVs | ||
371 | * | ||
372 | * TLVs stand for type-length-value and are the header for a payload | ||
373 | * composed of almost anything. Each payload has a type assigned | ||
374 | * and a length. | ||
375 | */ | ||
376 | enum i2400m_tlv { | ||
377 | I2400M_TLV_L4_MESSAGE_VERSIONS = 129, | ||
378 | I2400M_TLV_SYSTEM_STATE = 141, | ||
379 | I2400M_TLV_MEDIA_STATUS = 161, | ||
380 | I2400M_TLV_RF_OPERATION = 162, | ||
381 | I2400M_TLV_RF_STATUS = 163, | ||
382 | I2400M_TLV_DEVICE_RESET_TYPE = 132, | ||
383 | I2400M_TLV_CONFIG_IDLE_PARAMETERS = 601, | ||
384 | }; | ||
385 | |||
386 | |||
387 | struct i2400m_tlv_hdr { | ||
388 | __le16 type; | ||
389 | __le16 length; /* payload's */ | ||
390 | __u8 pl[0]; | ||
391 | } __attribute__((packed)); | ||
392 | |||
393 | |||
394 | struct i2400m_l3l4_hdr { | ||
395 | __le16 type; | ||
396 | __le16 length; /* payload's */ | ||
397 | __le16 version; | ||
398 | __le16 resv1; | ||
399 | __le16 status; | ||
400 | __le16 resv2; | ||
401 | struct i2400m_tlv_hdr pl[0]; | ||
402 | } __attribute__((packed)); | ||
403 | |||
404 | |||
405 | /** | ||
406 | * i2400m_system_state - different states of the device | ||
407 | */ | ||
408 | enum i2400m_system_state { | ||
409 | I2400M_SS_UNINITIALIZED = 1, | ||
410 | I2400M_SS_INIT, | ||
411 | I2400M_SS_READY, | ||
412 | I2400M_SS_SCAN, | ||
413 | I2400M_SS_STANDBY, | ||
414 | I2400M_SS_CONNECTING, | ||
415 | I2400M_SS_WIMAX_CONNECTED, | ||
416 | I2400M_SS_DATA_PATH_CONNECTED, | ||
417 | I2400M_SS_IDLE, | ||
418 | I2400M_SS_DISCONNECTING, | ||
419 | I2400M_SS_OUT_OF_ZONE, | ||
420 | I2400M_SS_SLEEPACTIVE, | ||
421 | I2400M_SS_PRODUCTION, | ||
422 | I2400M_SS_CONFIG, | ||
423 | I2400M_SS_RF_OFF, | ||
424 | I2400M_SS_RF_SHUTDOWN, | ||
425 | I2400M_SS_DEVICE_DISCONNECT, | ||
426 | I2400M_SS_MAX, | ||
427 | }; | ||
428 | |||
429 | |||
430 | /** | ||
431 | * i2400m_tlv_system_state - report on the state of the system | ||
432 | * | ||
433 | * @state: see enum i2400m_system_state | ||
434 | */ | ||
435 | struct i2400m_tlv_system_state { | ||
436 | struct i2400m_tlv_hdr hdr; | ||
437 | __le32 state; | ||
438 | } __attribute__((packed)); | ||
439 | |||
440 | |||
441 | struct i2400m_tlv_l4_message_versions { | ||
442 | struct i2400m_tlv_hdr hdr; | ||
443 | __le16 major; | ||
444 | __le16 minor; | ||
445 | __le16 branch; | ||
446 | __le16 reserved; | ||
447 | } __attribute__((packed)); | ||
448 | |||
449 | |||
450 | struct i2400m_tlv_detailed_device_info { | ||
451 | struct i2400m_tlv_hdr hdr; | ||
452 | __u8 reserved1[400]; | ||
453 | __u8 mac_address[6]; | ||
454 | __u8 reserved2[2]; | ||
455 | } __attribute__((packed)); | ||
456 | |||
457 | |||
458 | enum i2400m_rf_switch_status { | ||
459 | I2400M_RF_SWITCH_ON = 1, | ||
460 | I2400M_RF_SWITCH_OFF = 2, | ||
461 | }; | ||
462 | |||
463 | struct i2400m_tlv_rf_switches_status { | ||
464 | struct i2400m_tlv_hdr hdr; | ||
465 | __u8 sw_rf_switch; /* 1 ON, 2 OFF */ | ||
466 | __u8 hw_rf_switch; /* 1 ON, 2 OFF */ | ||
467 | __u8 reserved[2]; | ||
468 | } __attribute__((packed)); | ||
469 | |||
470 | |||
471 | enum { | ||
472 | i2400m_rf_operation_on = 1, | ||
473 | i2400m_rf_operation_off = 2 | ||
474 | }; | ||
475 | |||
476 | struct i2400m_tlv_rf_operation { | ||
477 | struct i2400m_tlv_hdr hdr; | ||
478 | __le32 status; /* 1 ON, 2 OFF */ | ||
479 | } __attribute__((packed)); | ||
480 | |||
481 | |||
482 | enum i2400m_tlv_reset_type { | ||
483 | I2400M_RESET_TYPE_COLD = 1, | ||
484 | I2400M_RESET_TYPE_WARM | ||
485 | }; | ||
486 | |||
487 | struct i2400m_tlv_device_reset_type { | ||
488 | struct i2400m_tlv_hdr hdr; | ||
489 | __le32 reset_type; | ||
490 | } __attribute__((packed)); | ||
491 | |||
492 | |||
493 | struct i2400m_tlv_config_idle_parameters { | ||
494 | struct i2400m_tlv_hdr hdr; | ||
495 | __le32 idle_timeout; /* 100 to 300000 ms [5min], 100 increments | ||
496 | * 0 disabled */ | ||
497 | __le32 idle_paging_interval; /* frames */ | ||
498 | } __attribute__((packed)); | ||
499 | |||
500 | |||
501 | enum i2400m_media_status { | ||
502 | I2400M_MEDIA_STATUS_LINK_UP = 1, | ||
503 | I2400M_MEDIA_STATUS_LINK_DOWN, | ||
504 | I2400M_MEDIA_STATUS_LINK_RENEW, | ||
505 | }; | ||
506 | |||
507 | struct i2400m_tlv_media_status { | ||
508 | struct i2400m_tlv_hdr hdr; | ||
509 | __le32 media_status; | ||
510 | } __attribute__((packed)); | ||
511 | |||
512 | #endif /* #ifndef __LINUX__WIMAX__I2400M_H__ */ | ||
diff --git a/include/net/wimax.h b/include/net/wimax.h new file mode 100644 index 000000000000..1602614fdaf9 --- /dev/null +++ b/include/net/wimax.h | |||
@@ -0,0 +1,520 @@ | |||
1 | /* | ||
2 | * Linux WiMAX | ||
3 | * Kernel space API for accessing WiMAX devices | ||
4 | * | ||
5 | * | ||
6 | * Copyright (C) 2007-2008 Intel Corporation <linux-wimax@intel.com> | ||
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 | * The WiMAX stack provides an API for controlling and managing the | ||
25 | * system's WiMAX devices. This API affects the control plane; the | ||
26 | * data plane is accessed via the network stack (netdev). | ||
27 | * | ||
28 | * Parts of the WiMAX stack API and notifications are exported to | ||
29 | * user space via Generic Netlink. In user space, libwimax (part of | ||
30 | * the wimax-tools package) provides a shim layer for accessing those | ||
31 | * calls. | ||
32 | * | ||
33 | * The API is standarized for all WiMAX devices and different drivers | ||
34 | * implement the backend support for it. However, device-specific | ||
35 | * messaging pipes are provided that can be used to issue commands and | ||
36 | * receive notifications in free form. | ||
37 | * | ||
38 | * Currently the messaging pipes are the only means of control as it | ||
39 | * is not known (due to the lack of more devices in the market) what | ||
40 | * will be a good abstraction layer. Expect this to change as more | ||
41 | * devices show in the market. This API is designed to be growable in | ||
42 | * order to address this problem. | ||
43 | * | ||
44 | * USAGE | ||
45 | * | ||
46 | * Embed a `struct wimax_dev` at the beginning of the the device's | ||
47 | * private structure, initialize and register it. For details, see | ||
48 | * `struct wimax_dev`s documentation. | ||
49 | * | ||
50 | * Once this is done, wimax-tools's libwimaxll can be used to | ||
51 | * communicate with the driver from user space. You user space | ||
52 | * application does not have to forcibily use libwimaxll and can talk | ||
53 | * the generic netlink protocol directly if desired. | ||
54 | * | ||
55 | * Remember this is a very low level API that will to provide all of | ||
56 | * WiMAX features. Other daemons and services running in user space | ||
57 | * are the expected clients of it. They offer a higher level API that | ||
58 | * applications should use (an example of this is the Intel's WiMAX | ||
59 | * Network Service for the i2400m). | ||
60 | * | ||
61 | * DESIGN | ||
62 | * | ||
63 | * Although not set on final stone, this very basic interface is | ||
64 | * mostly completed. Remember this is meant to grow as new common | ||
65 | * operations are decided upon. New operations will be added to the | ||
66 | * interface, intent being on keeping backwards compatibility as much | ||
67 | * as possible. | ||
68 | * | ||
69 | * This layer implements a set of calls to control a WiMAX device, | ||
70 | * exposing a frontend to the rest of the kernel and user space (via | ||
71 | * generic netlink) and a backend implementation in the driver through | ||
72 | * function pointers. | ||
73 | * | ||
74 | * WiMAX devices have a state, and a kernel-only API allows the | ||
75 | * drivers to manipulate that state. State transitions are atomic, and | ||
76 | * only some of them are allowed (see `enum wimax_st`). | ||
77 | * | ||
78 | * Most API calls will set the state automatically; in most cases | ||
79 | * drivers have to only report state changes due to external | ||
80 | * conditions. | ||
81 | * | ||
82 | * All API operations are 'atomic', serialized thorough a mutex in the | ||
83 | * `struct wimax_dev`. | ||
84 | * | ||
85 | * EXPORTING TO USER SPACE THROUGH GENERIC NETLINK | ||
86 | * | ||
87 | * The API is exported to user space using generic netlink (other | ||
88 | * methods can be added as needed). | ||
89 | * | ||
90 | * There is a Generic Netlink Family named "WiMAX", where interfaces | ||
91 | * supporting the WiMAX interface receive commands and broadcast their | ||
92 | * signals over a multicast group named "msg". | ||
93 | * | ||
94 | * Mapping to the source/destination interface is done by an interface | ||
95 | * index attribute. | ||
96 | * | ||
97 | * For user-to-kernel traffic (commands) we use a function call | ||
98 | * marshalling mechanism, where a message X with attributes A, B, C | ||
99 | * sent from user space to kernel space means executing the WiMAX API | ||
100 | * call wimax_X(A, B, C), sending the results back as a message. | ||
101 | * | ||
102 | * Kernel-to-user (notifications or signals) communication is sent | ||
103 | * over multicast groups. This allows to have multiple applications | ||
104 | * monitoring them. | ||
105 | * | ||
106 | * Each command/signal gets assigned it's own attribute policy. This | ||
107 | * way the validator will verify that all the attributes in there are | ||
108 | * only the ones that should be for each command/signal. Thing of an | ||
109 | * attribute mapping to a type+argumentname for each command/signal. | ||
110 | * | ||
111 | * If we had a single policy for *all* commands/signals, after running | ||
112 | * the validator we'd have to check "does this attribute belong in | ||
113 | * here"? for each one. It can be done manually, but it's just easier | ||
114 | * to have the validator do that job with multiple policies. As well, | ||
115 | * it makes it easier to later expand each command/signal signature | ||
116 | * without affecting others and keeping the namespace more or less | ||
117 | * sane. Not that it is too complicated, but it makes it even easier. | ||
118 | * | ||
119 | * No state information is maintained in the kernel for each user | ||
120 | * space connection (the connection is stateless). | ||
121 | * | ||
122 | * TESTING FOR THE INTERFACE AND VERSIONING | ||
123 | * | ||
124 | * If network interface X is a WiMAX device, there will be a Generic | ||
125 | * Netlink family named "WiMAX X" and the device will present a | ||
126 | * "wimax" directory in it's network sysfs directory | ||
127 | * (/sys/class/net/DEVICE/wimax) [used by HAL]. | ||
128 | * | ||
129 | * The inexistence of any of these means the device does not support | ||
130 | * this WiMAX API. | ||
131 | * | ||
132 | * By querying the generic netlink controller, versioning information | ||
133 | * and the multicast groups available can be found. Applications using | ||
134 | * the interface can either rely on that or use the generic netlink | ||
135 | * controller to figure out which generic netlink commands/signals are | ||
136 | * supported. | ||
137 | * | ||
138 | * NOTE: this versioning is a last resort to avoid hard | ||
139 | * incompatibilities. It is the intention of the design of this | ||
140 | * stack not to introduce backward incompatible changes. | ||
141 | * | ||
142 | * The version code has to fit in one byte (restrictions imposed by | ||
143 | * generic netlink); we use `version / 10` for the major version and | ||
144 | * `version % 10` for the minor. This gives 9 minors for each major | ||
145 | * and 25 majors. | ||
146 | * | ||
147 | * The version change protocol is as follow: | ||
148 | * | ||
149 | * - Major versions: needs to be increased if an existing message/API | ||
150 | * call is changed or removed. Doesn't need to be changed if a new | ||
151 | * message is added. | ||
152 | * | ||
153 | * - Minor version: needs to be increased if new messages/API calls are | ||
154 | * being added or some other consideration that doesn't impact the | ||
155 | * user-kernel interface too much (like some kind of bug fix) and | ||
156 | * that is kind of left up in the air to common sense. | ||
157 | * | ||
158 | * User space code should not try to work if the major version it was | ||
159 | * compiled for differs from what the kernel offers. As well, if the | ||
160 | * minor version of the kernel interface is lower than the one user | ||
161 | * space is expecting (the one it was compiled for), the kernel | ||
162 | * might be missing API calls; user space shall be ready to handle | ||
163 | * said condition. Use the generic netlink controller operations to | ||
164 | * find which ones are supported and which not. | ||
165 | * | ||
166 | * libwimaxll:wimaxll_open() takes care of checking versions. | ||
167 | * | ||
168 | * THE OPERATIONS: | ||
169 | * | ||
170 | * Each operation is defined in its on file (drivers/net/wimax/op-*.c) | ||
171 | * for clarity. The parts needed for an operation are: | ||
172 | * | ||
173 | * - a function pointer in `struct wimax_dev`: optional, as the | ||
174 | * operation might be implemented by the stack and not by the | ||
175 | * driver. | ||
176 | * | ||
177 | * All function pointers are named wimax_dev->op_*(), and drivers | ||
178 | * must implement them except where noted otherwise. | ||
179 | * | ||
180 | * - When exported to user space, a `struct nla_policy` to define the | ||
181 | * attributes of the generic netlink command and a `struct genl_ops` | ||
182 | * to define the operation. | ||
183 | * | ||
184 | * All the declarations for the operation codes (WIMAX_GNL_OP_<NAME>) | ||
185 | * and generic netlink attributes (WIMAX_GNL_<NAME>_*) are declared in | ||
186 | * include/linux/wimax.h; this file is intended to be cloned by user | ||
187 | * space to gain access to those declarations. | ||
188 | * | ||
189 | * A few caveats to remember: | ||
190 | * | ||
191 | * - Need to define attribute numbers starting in 1; otherwise it | ||
192 | * fails. | ||
193 | * | ||
194 | * - the `struct genl_family` requires a maximum attribute id; when | ||
195 | * defining the `struct nla_policy` for each message, it has to have | ||
196 | * an array size of WIMAX_GNL_ATTR_MAX+1. | ||
197 | * | ||
198 | * THE PIPE INTERFACE: | ||
199 | * | ||
200 | * This interface is kept intentionally simple. The driver can send | ||
201 | * and receive free-form messages to/from user space through a | ||
202 | * pipe. See drivers/net/wimax/op-msg.c for details. | ||
203 | * | ||
204 | * The kernel-to-user messages are sent with | ||
205 | * wimax_msg(). user-to-kernel messages are delivered via | ||
206 | * wimax_dev->op_msg_from_user(). | ||
207 | * | ||
208 | * RFKILL: | ||
209 | * | ||
210 | * RFKILL support is built into the wimax_dev layer; the driver just | ||
211 | * needs to call wimax_report_rfkill_{hw,sw}() to inform of changes in | ||
212 | * the hardware or software RF kill switches. When the stack wants to | ||
213 | * turn the radio off, it will call wimax_dev->op_rfkill_sw_toggle(), | ||
214 | * which the driver implements. | ||
215 | * | ||
216 | * User space can set the software RF Kill switch by calling | ||
217 | * wimax_rfkill(). | ||
218 | * | ||
219 | * The code for now only supports devices that don't require polling; | ||
220 | * If the device needs to be polled, create a self-rearming delayed | ||
221 | * work struct for polling or look into adding polled support to the | ||
222 | * WiMAX stack. | ||
223 | * | ||
224 | * When initializing the hardware (_probe), after calling | ||
225 | * wimax_dev_add(), query the device for it's RF Kill switches status | ||
226 | * and feed it back to the WiMAX stack using | ||
227 | * wimax_report_rfkill_{hw,sw}(). If any switch is missing, always | ||
228 | * report it as ON. | ||
229 | * | ||
230 | * NOTE: the wimax stack uses an inverted terminology to that of the | ||
231 | * RFKILL subsystem: | ||
232 | * | ||
233 | * - ON: radio is ON, RFKILL is DISABLED or OFF. | ||
234 | * - OFF: radio is OFF, RFKILL is ENABLED or ON. | ||
235 | * | ||
236 | * MISCELLANEOUS OPS: | ||
237 | * | ||
238 | * wimax_reset() can be used to reset the device to power on state; by | ||
239 | * default it issues a warm reset that maintains the same device | ||
240 | * node. If that is not possible, it falls back to a cold reset | ||
241 | * (device reconnect). The driver implements the backend to this | ||
242 | * through wimax_dev->op_reset(). | ||
243 | */ | ||
244 | |||
245 | #ifndef __NET__WIMAX_H__ | ||
246 | #define __NET__WIMAX_H__ | ||
247 | #ifdef __KERNEL__ | ||
248 | |||
249 | #include <linux/wimax.h> | ||
250 | #include <net/genetlink.h> | ||
251 | #include <linux/netdevice.h> | ||
252 | |||
253 | struct net_device; | ||
254 | struct genl_info; | ||
255 | struct wimax_dev; | ||
256 | struct input_dev; | ||
257 | |||
258 | /** | ||
259 | * struct wimax_dev - Generic WiMAX device | ||
260 | * | ||
261 | * @net_dev: [fill] Pointer to the &struct net_device this WiMAX | ||
262 | * device implements. | ||
263 | * | ||
264 | * @op_msg_from_user: [fill] Driver-specific operation to | ||
265 | * handle a raw message from user space to the driver. The | ||
266 | * driver can send messages to user space using with | ||
267 | * wimax_msg_to_user(). | ||
268 | * | ||
269 | * @op_rfkill_sw_toggle: [fill] Driver-specific operation to act on | ||
270 | * userspace (or any other agent) requesting the WiMAX device to | ||
271 | * change the RF Kill software switch (WIMAX_RF_ON or | ||
272 | * WIMAX_RF_OFF). | ||
273 | * If such hardware support is not present, it is assumed the | ||
274 | * radio cannot be switched off and it is always on (and the stack | ||
275 | * will error out when trying to switch it off). In such case, | ||
276 | * this function pointer can be left as NULL. | ||
277 | * | ||
278 | * @op_reset: [fill] Driver specific operation to reset the | ||
279 | * device. | ||
280 | * This operation should always attempt first a warm reset that | ||
281 | * does not disconnect the device from the bus and return 0. | ||
282 | * If that fails, it should resort to some sort of cold or bus | ||
283 | * reset (even if it implies a bus disconnection and device | ||
284 | * dissapearance). In that case, -ENODEV should be returned to | ||
285 | * indicate the device is gone. | ||
286 | * This operation has to be synchronous, and return only when the | ||
287 | * reset is complete. In case of having had to resort to bus/cold | ||
288 | * reset implying a device disconnection, the call is allowed to | ||
289 | * return inmediately. | ||
290 | * NOTE: wimax_dev->mutex is NOT locked when this op is being | ||
291 | * called; however, wimax_dev->mutex_reset IS locked to ensure | ||
292 | * serialization of calls to wimax_reset(). | ||
293 | * See wimax_reset()'s documentation. | ||
294 | * | ||
295 | * @name: [fill] A way to identify this device. We need to register a | ||
296 | * name with many subsystems (input for RFKILL, workqueue | ||
297 | * creation, etc). We can't use the network device name as that | ||
298 | * might change and in some instances we don't know it yet (until | ||
299 | * we don't call register_netdev()). So we generate an unique one | ||
300 | * using the driver name and device bus id, place it here and use | ||
301 | * it across the board. Recommended naming: | ||
302 | * DRIVERNAME-BUSNAME:BUSID (dev->bus->name, dev->bus_id). | ||
303 | * | ||
304 | * @id_table_node: [private] link to the list of wimax devices kept by | ||
305 | * id-table.c. Protected by it's own spinlock. | ||
306 | * | ||
307 | * @mutex: [private] Serializes all concurrent access and execution of | ||
308 | * operations. | ||
309 | * | ||
310 | * @mutex_reset: [private] Serializes reset operations. Needs to be a | ||
311 | * different mutex because as part of the reset operation, the | ||
312 | * driver has to call back into the stack to do things such as | ||
313 | * state change, that require wimax_dev->mutex. | ||
314 | * | ||
315 | * @state: [private] Current state of the WiMAX device. | ||
316 | * | ||
317 | * @rfkill: [private] integration into the RF-Kill infrastructure. | ||
318 | * | ||
319 | * @rfkill_input: [private] virtual input device to process the | ||
320 | * hardware RF Kill switches. | ||
321 | * | ||
322 | * @rf_sw: [private] State of the software radio switch (OFF/ON) | ||
323 | * | ||
324 | * @rf_hw: [private] State of the hardware radio switch (OFF/ON) | ||
325 | * | ||
326 | * Description: | ||
327 | * This structure defines a common interface to access all WiMAX | ||
328 | * devices from different vendors and provides a common API as well as | ||
329 | * a free-form device-specific messaging channel. | ||
330 | * | ||
331 | * Usage: | ||
332 | * 1. Embed a &struct wimax_dev at *the beginning* the network | ||
333 | * device structure so that netdev_priv() points to it. | ||
334 | * | ||
335 | * 2. memset() it to zero | ||
336 | * | ||
337 | * 3. Initialize with wimax_dev_init(). This will leave the WiMAX | ||
338 | * device in the %__WIMAX_ST_NULL state. | ||
339 | * | ||
340 | * 4. Fill all the fields marked with [fill]; once called | ||
341 | * wimax_dev_add(), those fields CANNOT be modified. | ||
342 | * | ||
343 | * 5. Call wimax_dev_add() *after* registering the network | ||
344 | * device. This will leave the WiMAX device in the %WIMAX_ST_DOWN | ||
345 | * state. | ||
346 | * Protect the driver's net_device->open() against succeeding if | ||
347 | * the wimax device state is lower than %WIMAX_ST_DOWN. | ||
348 | * | ||
349 | * 6. Select when the device is going to be turned on/initialized; | ||
350 | * for example, it could be initialized on 'ifconfig up' (when the | ||
351 | * netdev op 'open()' is called on the driver). | ||
352 | * | ||
353 | * When the device is initialized (at `ifconfig up` time, or right | ||
354 | * after calling wimax_dev_add() from _probe(), make sure the | ||
355 | * following steps are taken | ||
356 | * | ||
357 | * a. Move the device to %WIMAX_ST_UNINITIALIZED. This is needed so | ||
358 | * some API calls that shouldn't work until the device is ready | ||
359 | * can be blocked. | ||
360 | * | ||
361 | * b. Initialize the device. Make sure to turn the SW radio switch | ||
362 | * off and move the device to state %WIMAX_ST_RADIO_OFF when | ||
363 | * done. When just initialized, a device should be left in RADIO | ||
364 | * OFF state until user space devices to turn it on. | ||
365 | * | ||
366 | * c. Query the device for the state of the hardware rfkill switch | ||
367 | * and call wimax_rfkill_report_hw() and wimax_rfkill_report_sw() | ||
368 | * as needed. See below. | ||
369 | * | ||
370 | * wimax_dev_rm() undoes before unregistering the network device. Once | ||
371 | * wimax_dev_add() is called, the driver can get called on the | ||
372 | * wimax_dev->op_* function pointers | ||
373 | * | ||
374 | * CONCURRENCY: | ||
375 | * | ||
376 | * The stack provides a mutex for each device that will disallow API | ||
377 | * calls happening concurrently; thus, op calls into the driver | ||
378 | * through the wimax_dev->op*() function pointers will always be | ||
379 | * serialized and *never* concurrent. | ||
380 | * | ||
381 | * For locking, take wimax_dev->mutex is taken; (most) operations in | ||
382 | * the API have to check for wimax_dev_is_ready() to return 0 before | ||
383 | * continuing (this is done internally). | ||
384 | * | ||
385 | * REFERENCE COUNTING: | ||
386 | * | ||
387 | * The WiMAX device is reference counted by the associated network | ||
388 | * device. The only operation that can be used to reference the device | ||
389 | * is wimax_dev_get_by_genl_info(), and the reference it acquires has | ||
390 | * to be released with dev_put(wimax_dev->net_dev). | ||
391 | * | ||
392 | * RFKILL: | ||
393 | * | ||
394 | * At startup, both HW and SW radio switchess are assumed to be off. | ||
395 | * | ||
396 | * At initialization time [after calling wimax_dev_add()], have the | ||
397 | * driver query the device for the status of the software and hardware | ||
398 | * RF kill switches and call wimax_report_rfkill_hw() and | ||
399 | * wimax_rfkill_report_sw() to indicate their state. If any is | ||
400 | * missing, just call it to indicate it is ON (radio always on). | ||
401 | * | ||
402 | * Whenever the driver detects a change in the state of the RF kill | ||
403 | * switches, it should call wimax_report_rfkill_hw() or | ||
404 | * wimax_report_rfkill_sw() to report it to the stack. | ||
405 | */ | ||
406 | struct wimax_dev { | ||
407 | struct net_device *net_dev; | ||
408 | struct list_head id_table_node; | ||
409 | struct mutex mutex; /* Protects all members and API calls */ | ||
410 | struct mutex mutex_reset; | ||
411 | enum wimax_st state; | ||
412 | |||
413 | int (*op_msg_from_user)(struct wimax_dev *wimax_dev, | ||
414 | const char *, | ||
415 | const void *, size_t, | ||
416 | const struct genl_info *info); | ||
417 | int (*op_rfkill_sw_toggle)(struct wimax_dev *wimax_dev, | ||
418 | enum wimax_rf_state); | ||
419 | int (*op_reset)(struct wimax_dev *wimax_dev); | ||
420 | |||
421 | struct rfkill *rfkill; | ||
422 | struct input_dev *rfkill_input; | ||
423 | unsigned rf_hw; | ||
424 | unsigned rf_sw; | ||
425 | char name[32]; | ||
426 | |||
427 | struct dentry *debugfs_dentry; | ||
428 | }; | ||
429 | |||
430 | |||
431 | |||
432 | /* | ||
433 | * WiMAX stack public API for device drivers | ||
434 | * ----------------------------------------- | ||
435 | * | ||
436 | * These functions are not exported to user space. | ||
437 | */ | ||
438 | extern void wimax_dev_init(struct wimax_dev *); | ||
439 | extern int wimax_dev_add(struct wimax_dev *, struct net_device *); | ||
440 | extern void wimax_dev_rm(struct wimax_dev *); | ||
441 | |||
442 | static inline | ||
443 | struct wimax_dev *net_dev_to_wimax(struct net_device *net_dev) | ||
444 | { | ||
445 | return netdev_priv(net_dev); | ||
446 | } | ||
447 | |||
448 | static inline | ||
449 | struct device *wimax_dev_to_dev(struct wimax_dev *wimax_dev) | ||
450 | { | ||
451 | return wimax_dev->net_dev->dev.parent; | ||
452 | } | ||
453 | |||
454 | extern void wimax_state_change(struct wimax_dev *, enum wimax_st); | ||
455 | extern enum wimax_st wimax_state_get(struct wimax_dev *); | ||
456 | |||
457 | /* | ||
458 | * Radio Switch state reporting. | ||
459 | * | ||
460 | * enum wimax_rf_state is declared in linux/wimax.h so the exports | ||
461 | * to user space can use it. | ||
462 | */ | ||
463 | extern void wimax_report_rfkill_hw(struct wimax_dev *, enum wimax_rf_state); | ||
464 | extern void wimax_report_rfkill_sw(struct wimax_dev *, enum wimax_rf_state); | ||
465 | |||
466 | |||
467 | /* | ||
468 | * Free-form messaging to/from user space | ||
469 | * | ||
470 | * Sending a message: | ||
471 | * | ||
472 | * wimax_msg(wimax_dev, pipe_name, buf, buf_size, GFP_KERNEL); | ||
473 | * | ||
474 | * Broken up: | ||
475 | * | ||
476 | * skb = wimax_msg_alloc(wimax_dev, pipe_name, buf_size, GFP_KERNEL); | ||
477 | * ...fill up skb... | ||
478 | * wimax_msg_send(wimax_dev, pipe_name, skb); | ||
479 | * | ||
480 | * Be sure not to modify skb->data in the middle (ie: don't use | ||
481 | * skb_push()/skb_pull()/skb_reserve() on the skb). | ||
482 | * | ||
483 | * "pipe_name" is any string, than can be interpreted as the name of | ||
484 | * the pipe or destinatary; the interpretation of it is driver | ||
485 | * specific, so the recipient can multiplex it as wished. It can be | ||
486 | * NULL, it won't be used - an example is using a "diagnostics" tag to | ||
487 | * send diagnostics information that a device-specific diagnostics | ||
488 | * tool would be interested in. | ||
489 | */ | ||
490 | extern struct sk_buff *wimax_msg_alloc(struct wimax_dev *, const char *, | ||
491 | const void *, size_t, gfp_t); | ||
492 | extern int wimax_msg_send(struct wimax_dev *, struct sk_buff *); | ||
493 | extern int wimax_msg(struct wimax_dev *, const char *, | ||
494 | const void *, size_t, gfp_t); | ||
495 | |||
496 | extern const void *wimax_msg_data_len(struct sk_buff *, size_t *); | ||
497 | extern const void *wimax_msg_data(struct sk_buff *); | ||
498 | extern ssize_t wimax_msg_len(struct sk_buff *); | ||
499 | |||
500 | |||
501 | /* | ||
502 | * WiMAX stack user space API | ||
503 | * -------------------------- | ||
504 | * | ||
505 | * This API is what gets exported to user space for general | ||
506 | * operations. As well, they can be called from within the kernel, | ||
507 | * (with a properly referenced `struct wimax_dev`). | ||
508 | * | ||
509 | * Properly referenced means: the 'struct net_device' that embeds the | ||
510 | * device's control structure and (as such) the 'struct wimax_dev' is | ||
511 | * referenced by the caller. | ||
512 | */ | ||
513 | extern int wimax_rfkill(struct wimax_dev *, enum wimax_rf_state); | ||
514 | extern int wimax_reset(struct wimax_dev *); | ||
515 | |||
516 | #else | ||
517 | /* You might be looking for linux/wimax.h */ | ||
518 | #error This file should not be included from user space. | ||
519 | #endif /* #ifdef __KERNEL__ */ | ||
520 | #endif /* #ifndef __NET__WIMAX_H__ */ | ||