1 /* Note : this particular snipset of code is available under
2 * the LGPL, MPL or BSD license (at your choice).
6 /* Backward compatibility for Wireless Extension 9 */
7 #ifndef IW_POWER_MODIFIER
8 #define IW_POWER_MODIFIER 0x000F /* Modify a parameter */
9 #define IW_POWER_MIN 0x0001 /* Value is a minimum */
10 #define IW_POWER_MAX 0x0002 /* Value is a maximum */
11 #define IW_POWER_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
12 #endif IW_POWER_MODIFIER
15 int pm_on; // Power Management enabled
16 int pm_multi; // Receive multicasts
17 int pm_period; // Power Management period
18 int pm_period_auto; // Power Management auto mode
19 int pm_max_period; // Power Management max period
20 int pm_min_period; // Power Management min period
21 int pm_timeout; // Power Management timeout
24 /* Set the desired Power Management mode */
27 if(wrq->u.power.disabled)
30 local->need_commit = 1;
35 switch(wrq->u.power.flags & IW_POWER_MODE)
37 case IW_POWER_UNICAST_R:
39 local->need_commit = 1;
43 local->need_commit = 1;
45 case IW_POWER_ON: /* None = ok */
47 default: /* Invalid */
51 if(wrq->u.power.flags & IW_POWER_PERIOD)
53 int period = wrq->u.power.value/1000000;
54 /* Hum: check if within bounds... */
58 local->need_commit = 1;
61 if(wrq->u.power.flags & IW_POWER_MIN)
63 local->pm_min_period = period;
64 local->pm_period_auto = 1;
68 if(wrq->u.power.flags & IW_POWER_MAX)
70 local->pm_max_period = period;
71 local->pm_period_auto = 1;
76 local->pm_period = period;
77 local->pm_period_auto = 0;
81 if(wrq->u.power.flags & IW_POWER_TIMEOUT)
85 local->need_commit = 1;
86 /* Fixed value in ms */
87 local->pm_timeout = wrq->u.power.value/1000;
92 /* Get the power management settings */
94 wrq->u.power.disabled = !local->pm_on;
95 /* By default, display the period */
96 if(!(wrq->u.power.flags & IW_POWER_TIMEOUT))
98 int inc_flags = wrq->u.power.flags;
99 wrq->u.power.flags = IW_POWER_PERIOD | IW_POWER_RELATIVE;
101 if(local->pm_period_auto)
103 /* By default, the min */
104 if(!(inc_flags & IW_POWER_MAX))
106 wrq->u.power.value = local->pm_min_period * 1000000;
107 wrq->u.power.flags |= IW_POWER_MIN;
111 wrq->u.power.value = local->pm_max_period * 1000000;
112 wrq->u.power.flags |= IW_POWER_MAX;
117 /* Fixed value. Check the flags */
118 if(inc_flags & (IW_POWER_MIN | IW_POWER_MAX))
121 wrq->u.power.value = local->pm_period * 1000000;
126 /* Deal with the timeout - always fixed */
127 wrq->u.power.flags = IW_POWER_TIMEOUT;
128 wrq->u.power.value = local->pm_timeout * 1000;
131 wrq->u.power.flags |= IW_POWER_ALL_R;
133 wrq->u.power.flags |= IW_POWER_UNICAST_R;
135 #endif /* WIRELESS_EXT > 8 */
138 range.min_pmp = 1000000; /* 1 units */
139 range.max_pmp = 12000000; /* 12 units */
140 range.min_pmt = 1000; /* 1 ms */
141 range.max_pmt = 1000000; /* 1 s */
142 range.pmp_flags = IW_POWER_PERIOD | IW_POWER_RELATIVE |
143 IW_POWER_MIN | IW_POWER_MAX;
144 range.pmt_flags = IW_POWER_TIMEOUT;
145 range.pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_UNICAST_R;
146 #endif /* WIRELESS_EXT > 9 */