2 * Intel Wireless WiMAX Connection 2400m
3 * Miscellaneous control functions for managing the device
6 * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
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
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.
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.
35 * Intel Corporation <linux-wimax@intel.com>
36 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
37 * - Initial implementation
39 * This is a collection of functions used to control the device (plus
42 * There are utilities for handling TLV buffers, hooks on the device's
43 * reports to act on device changes of state [i2400m_report_hook()],
44 * on acks to commands [i2400m_msg_ack_hook()], a helper for sending
45 * commands to the device and blocking until a reply arrives
46 * [i2400m_msg_to_dev()], a few high level commands for manipulating
47 * the device state, powersving mode and configuration plus the
48 * routines to setup the device once communication is stablished with
49 * it [i2400m_dev_initialize()].
53 * i2400m_dev_initalize() Called by i2400m_dev_start()
54 * i2400m_set_init_config()
55 * i2400m_cmd_get_state()
56 * i2400m_dev_shutdown() Called by i2400m_dev_stop()
59 * i2400m_{cmd,get,set}_*()
61 * i2400m_msg_check_status()
63 * i2400m_report_hook() Called on reception of an event
64 * i2400m_report_state_hook()
65 * i2400m_tlv_buffer_walk()
67 * i2400m_report_tlv_system_state()
68 * i2400m_report_tlv_rf_switches_status()
69 * i2400m_report_tlv_media_status()
70 * i2400m_cmd_enter_powersave()
72 * i2400m_msg_ack_hook() Called on reception of a reply to a
78 #include <linux/kernel.h>
79 #include <linux/slab.h>
80 #include <linux/wimax/i2400m.h>
83 #define D_SUBMODULE control
84 #include "debug-levels.h"
86 int i2400m_passive_mode
; /* 0 (passive mode disabled) by default */
87 module_param_named(passive_mode
, i2400m_passive_mode
, int, 0644);
88 MODULE_PARM_DESC(passive_mode
,
89 "If true, the driver will not do any device setup "
90 "and leave it up to user space, who must be properly "
95 * Return if a TLV is of a give type and size
97 * @tlv_hdr: pointer to the TLV
98 * @tlv_type: type of the TLV we are looking for
99 * @tlv_size: expected size of the TLV we are looking for (if -1,
100 * don't check the size). This includes the header
101 * Returns: 0 if the TLV matches
102 * < 0 if it doesn't match at all
103 * > 0 total TLV + payload size, if the type matches, but not
107 ssize_t
i2400m_tlv_match(const struct i2400m_tlv_hdr
*tlv
,
108 enum i2400m_tlv tlv_type
, ssize_t tlv_size
)
110 if (le16_to_cpu(tlv
->type
) != tlv_type
) /* Not our type? skip */
113 && le16_to_cpu(tlv
->length
) + sizeof(*tlv
) != tlv_size
) {
114 size_t size
= le16_to_cpu(tlv
->length
) + sizeof(*tlv
);
115 printk(KERN_WARNING
"W: tlv type 0x%x mismatched because of "
116 "size (got %zu vs %zu expected)\n",
117 tlv_type
, size
, tlv_size
);
125 * Given a buffer of TLVs, iterate over them
127 * @i2400m: device instance
128 * @tlv_buf: pointer to the beginning of the TLV buffer
129 * @buf_size: buffer size in bytes
130 * @tlv_pos: seek position; this is assumed to be a pointer returned
131 * by i2400m_tlv_buffer_walk() [and thus, validated]. The
132 * TLV returned will be the one following this one.
137 * while (tlv_itr = i2400m_tlv_buffer_walk(i2400m, buf, size, tlv_itr)) {
139 * // Do stuff with tlv_itr, DON'T MODIFY IT
144 const struct i2400m_tlv_hdr
*i2400m_tlv_buffer_walk(
145 struct i2400m
*i2400m
,
146 const void *tlv_buf
, size_t buf_size
,
147 const struct i2400m_tlv_hdr
*tlv_pos
)
149 struct device
*dev
= i2400m_dev(i2400m
);
150 const struct i2400m_tlv_hdr
*tlv_top
= tlv_buf
+ buf_size
;
151 size_t offset
, length
, avail_size
;
154 if (tlv_pos
== NULL
) /* Take the first one? */
156 else /* Nope, the next one */
157 tlv_pos
= (void *) tlv_pos
158 + le16_to_cpu(tlv_pos
->length
) + sizeof(*tlv_pos
);
159 if (tlv_pos
== tlv_top
) { /* buffer done */
161 goto error_beyond_end
;
163 if (tlv_pos
> tlv_top
) {
166 goto error_beyond_end
;
168 offset
= (void *) tlv_pos
- (void *) tlv_buf
;
169 avail_size
= buf_size
- offset
;
170 if (avail_size
< sizeof(*tlv_pos
)) {
171 dev_err(dev
, "HW BUG? tlv_buf %p [%zu bytes], tlv @%zu: "
172 "short header\n", tlv_buf
, buf_size
, offset
);
173 goto error_short_header
;
175 type
= le16_to_cpu(tlv_pos
->type
);
176 length
= le16_to_cpu(tlv_pos
->length
);
177 if (avail_size
< sizeof(*tlv_pos
) + length
) {
178 dev_err(dev
, "HW BUG? tlv_buf %p [%zu bytes], "
179 "tlv type 0x%04x @%zu: "
180 "short data (%zu bytes vs %zu needed)\n",
181 tlv_buf
, buf_size
, type
, offset
, avail_size
,
182 sizeof(*tlv_pos
) + length
);
183 goto error_short_header
;
192 * Find a TLV in a buffer of sequential TLVs
194 * @i2400m: device descriptor
195 * @tlv_hdr: pointer to the first TLV in the sequence
196 * @size: size of the buffer in bytes; all TLVs are assumed to fit
197 * fully in the buffer (otherwise we'll complain).
198 * @tlv_type: type of the TLV we are looking for
199 * @tlv_size: expected size of the TLV we are looking for (if -1,
200 * don't check the size). This includes the header
202 * Returns: NULL if the TLV is not found, otherwise a pointer to
203 * it. If the sizes don't match, an error is printed and NULL
207 const struct i2400m_tlv_hdr
*i2400m_tlv_find(
208 struct i2400m
*i2400m
,
209 const struct i2400m_tlv_hdr
*tlv_hdr
, size_t size
,
210 enum i2400m_tlv tlv_type
, ssize_t tlv_size
)
213 struct device
*dev
= i2400m_dev(i2400m
);
214 const struct i2400m_tlv_hdr
*tlv
= NULL
;
215 while ((tlv
= i2400m_tlv_buffer_walk(i2400m
, tlv_hdr
, size
, tlv
))) {
216 match
= i2400m_tlv_match(tlv
, tlv_type
, tlv_size
);
217 if (match
== 0) /* found it :) */
220 dev_warn(dev
, "TLV type 0x%04x found with size "
221 "mismatch (%zu vs %zu needed)\n",
222 tlv_type
, match
, tlv_size
);
232 } ms_to_errno
[I2400M_MS_MAX
] = {
233 [I2400M_MS_DONE_OK
] = { "", 0 },
234 [I2400M_MS_DONE_IN_PROGRESS
] = { "", 0 },
235 [I2400M_MS_INVALID_OP
] = { "invalid opcode", -ENOSYS
},
236 [I2400M_MS_BAD_STATE
] = { "invalid state", -EILSEQ
},
237 [I2400M_MS_ILLEGAL_VALUE
] = { "illegal value", -EINVAL
},
238 [I2400M_MS_MISSING_PARAMS
] = { "missing parameters", -ENOMSG
},
239 [I2400M_MS_VERSION_ERROR
] = { "bad version", -EIO
},
240 [I2400M_MS_ACCESSIBILITY_ERROR
] = { "accesibility error", -EIO
},
241 [I2400M_MS_BUSY
] = { "busy", -EBUSY
},
242 [I2400M_MS_CORRUPTED_TLV
] = { "corrupted TLV", -EILSEQ
},
243 [I2400M_MS_UNINITIALIZED
] = { "not unitialized", -EILSEQ
},
244 [I2400M_MS_UNKNOWN_ERROR
] = { "unknown error", -EIO
},
245 [I2400M_MS_PRODUCTION_ERROR
] = { "production error", -EIO
},
246 [I2400M_MS_NO_RF
] = { "no RF", -EIO
},
247 [I2400M_MS_NOT_READY_FOR_POWERSAVE
] =
248 { "not ready for powersave", -EACCES
},
249 [I2400M_MS_THERMAL_CRITICAL
] = { "thermal critical", -EL3HLT
},
254 * i2400m_msg_check_status - translate a message's status code
256 * @i2400m: device descriptor
257 * @l3l4_hdr: message header
258 * @strbuf: buffer to place a formatted error message (unless NULL).
259 * @strbuf_size: max amount of available space; larger messages will
262 * Returns: errno code corresponding to the status code in @l3l4_hdr
263 * and a message in @strbuf describing the error.
265 int i2400m_msg_check_status(const struct i2400m_l3l4_hdr
*l3l4_hdr
,
266 char *strbuf
, size_t strbuf_size
)
269 enum i2400m_ms status
= le16_to_cpu(l3l4_hdr
->status
);
274 if (status
>= ARRAY_SIZE(ms_to_errno
)) {
275 str
= "unknown status code";
278 str
= ms_to_errno
[status
].msg
;
279 result
= ms_to_errno
[status
].errno
;
282 snprintf(strbuf
, strbuf_size
, "%s (%d)", str
, status
);
288 * Act on a TLV System State reported by the device
290 * @i2400m: device descriptor
291 * @ss: validated System State TLV
294 void i2400m_report_tlv_system_state(struct i2400m
*i2400m
,
295 const struct i2400m_tlv_system_state
*ss
)
297 struct device
*dev
= i2400m_dev(i2400m
);
298 struct wimax_dev
*wimax_dev
= &i2400m
->wimax_dev
;
299 enum i2400m_system_state i2400m_state
= le32_to_cpu(ss
->state
);
301 d_fnstart(3, dev
, "(i2400m %p ss %p [%u])\n", i2400m
, ss
, i2400m_state
);
303 if (i2400m
->state
!= i2400m_state
) {
304 i2400m
->state
= i2400m_state
;
305 wake_up_all(&i2400m
->state_wq
);
307 switch (i2400m_state
) {
308 case I2400M_SS_UNINITIALIZED
:
310 case I2400M_SS_CONFIG
:
311 case I2400M_SS_PRODUCTION
:
312 wimax_state_change(wimax_dev
, WIMAX_ST_UNINITIALIZED
);
315 case I2400M_SS_RF_OFF
:
316 case I2400M_SS_RF_SHUTDOWN
:
317 wimax_state_change(wimax_dev
, WIMAX_ST_RADIO_OFF
);
320 case I2400M_SS_READY
:
321 case I2400M_SS_STANDBY
:
322 case I2400M_SS_SLEEPACTIVE
:
323 wimax_state_change(wimax_dev
, WIMAX_ST_READY
);
326 case I2400M_SS_CONNECTING
:
327 case I2400M_SS_WIMAX_CONNECTED
:
328 wimax_state_change(wimax_dev
, WIMAX_ST_READY
);
332 case I2400M_SS_OUT_OF_ZONE
:
333 wimax_state_change(wimax_dev
, WIMAX_ST_SCANNING
);
337 d_printf(1, dev
, "entering BS-negotiated idle mode\n");
338 case I2400M_SS_DISCONNECTING
:
339 case I2400M_SS_DATA_PATH_CONNECTED
:
340 wimax_state_change(wimax_dev
, WIMAX_ST_CONNECTED
);
344 /* Huh? just in case, shut it down */
345 dev_err(dev
, "HW BUG? unknown state %u: shutting down\n",
347 i2400m_reset(i2400m
, I2400M_RT_WARM
);
350 d_fnend(3, dev
, "(i2400m %p ss %p [%u]) = void\n",
351 i2400m
, ss
, i2400m_state
);
356 * Parse and act on a TLV Media Status sent by the device
358 * @i2400m: device descriptor
359 * @ms: validated Media Status TLV
361 * This will set the carrier up on down based on the device's link
362 * report. This is done asides of what the WiMAX stack does based on
363 * the device's state as sometimes we need to do a link-renew (the BS
364 * wants us to renew a DHCP lease, for example).
366 * In fact, doc says that everytime we get a link-up, we should do a
367 * DHCP negotiation...
370 void i2400m_report_tlv_media_status(struct i2400m
*i2400m
,
371 const struct i2400m_tlv_media_status
*ms
)
373 struct device
*dev
= i2400m_dev(i2400m
);
374 struct wimax_dev
*wimax_dev
= &i2400m
->wimax_dev
;
375 struct net_device
*net_dev
= wimax_dev
->net_dev
;
376 enum i2400m_media_status status
= le32_to_cpu(ms
->media_status
);
378 d_fnstart(3, dev
, "(i2400m %p ms %p [%u])\n", i2400m
, ms
, status
);
381 case I2400M_MEDIA_STATUS_LINK_UP
:
382 netif_carrier_on(net_dev
);
384 case I2400M_MEDIA_STATUS_LINK_DOWN
:
385 netif_carrier_off(net_dev
);
388 * This is the network telling us we need to retrain the DHCP
389 * lease -- so far, we are trusting the WiMAX Network Service
390 * in user space to pick this up and poke the DHCP client.
392 case I2400M_MEDIA_STATUS_LINK_RENEW
:
393 netif_carrier_on(net_dev
);
396 dev_err(dev
, "HW BUG? unknown media status %u\n",
399 d_fnend(3, dev
, "(i2400m %p ms %p [%u]) = void\n",
405 * Process a TLV from a 'state report'
407 * @i2400m: device descriptor
408 * @tlv: pointer to the TLV header; it has been already validated for
410 * @tag: for error messages
412 * Act on the TLVs from a 'state report'.
415 void i2400m_report_state_parse_tlv(struct i2400m
*i2400m
,
416 const struct i2400m_tlv_hdr
*tlv
,
419 struct device
*dev
= i2400m_dev(i2400m
);
420 const struct i2400m_tlv_media_status
*ms
;
421 const struct i2400m_tlv_system_state
*ss
;
422 const struct i2400m_tlv_rf_switches_status
*rfss
;
424 if (0 == i2400m_tlv_match(tlv
, I2400M_TLV_SYSTEM_STATE
, sizeof(*ss
))) {
425 ss
= container_of(tlv
, typeof(*ss
), hdr
);
426 d_printf(2, dev
, "%s: system state TLV "
427 "found (0x%04x), state 0x%08x\n",
428 tag
, I2400M_TLV_SYSTEM_STATE
,
429 le32_to_cpu(ss
->state
));
430 i2400m_report_tlv_system_state(i2400m
, ss
);
432 if (0 == i2400m_tlv_match(tlv
, I2400M_TLV_RF_STATUS
, sizeof(*rfss
))) {
433 rfss
= container_of(tlv
, typeof(*rfss
), hdr
);
434 d_printf(2, dev
, "%s: RF status TLV "
435 "found (0x%04x), sw 0x%02x hw 0x%02x\n",
436 tag
, I2400M_TLV_RF_STATUS
,
437 le32_to_cpu(rfss
->sw_rf_switch
),
438 le32_to_cpu(rfss
->hw_rf_switch
));
439 i2400m_report_tlv_rf_switches_status(i2400m
, rfss
);
441 if (0 == i2400m_tlv_match(tlv
, I2400M_TLV_MEDIA_STATUS
, sizeof(*ms
))) {
442 ms
= container_of(tlv
, typeof(*ms
), hdr
);
443 d_printf(2, dev
, "%s: Media Status TLV: %u\n",
444 tag
, le32_to_cpu(ms
->media_status
));
445 i2400m_report_tlv_media_status(i2400m
, ms
);
451 * Parse a 'state report' and extract information
453 * @i2400m: device descriptor
454 * @l3l4_hdr: pointer to message; it has been already validated for
456 * @size: size of the message (header + payload). The header length
457 * declaration is assumed to be congruent with @size (as in
458 * sizeof(*l3l4_hdr) + l3l4_hdr->length == size)
460 * Walk over the TLVs in a report state and act on them.
463 void i2400m_report_state_hook(struct i2400m
*i2400m
,
464 const struct i2400m_l3l4_hdr
*l3l4_hdr
,
465 size_t size
, const char *tag
)
467 struct device
*dev
= i2400m_dev(i2400m
);
468 const struct i2400m_tlv_hdr
*tlv
;
469 size_t tlv_size
= le16_to_cpu(l3l4_hdr
->length
);
471 d_fnstart(4, dev
, "(i2400m %p, l3l4_hdr %p, size %zu, %s)\n",
472 i2400m
, l3l4_hdr
, size
, tag
);
475 while ((tlv
= i2400m_tlv_buffer_walk(i2400m
, &l3l4_hdr
->pl
,
477 i2400m_report_state_parse_tlv(i2400m
, tlv
, tag
);
478 d_fnend(4, dev
, "(i2400m %p, l3l4_hdr %p, size %zu, %s) = void\n",
479 i2400m
, l3l4_hdr
, size
, tag
);
484 * i2400m_report_hook - (maybe) act on a report
486 * @i2400m: device descriptor
487 * @l3l4_hdr: pointer to message; it has been already validated for
489 * @size: size of the message (header + payload). The header length
490 * declaration is assumed to be congruent with @size (as in
491 * sizeof(*l3l4_hdr) + l3l4_hdr->length == size)
493 * Extract information we might need (like carrien on/off) from a
496 void i2400m_report_hook(struct i2400m
*i2400m
,
497 const struct i2400m_l3l4_hdr
*l3l4_hdr
, size_t size
)
499 struct device
*dev
= i2400m_dev(i2400m
);
502 d_fnstart(3, dev
, "(i2400m %p l3l4_hdr %p size %zu)\n",
503 i2400m
, l3l4_hdr
, size
);
504 /* Chew on the message, we might need some information from
506 msg_type
= le16_to_cpu(l3l4_hdr
->type
);
508 case I2400M_MT_REPORT_STATE
: /* carrier detection... */
509 i2400m_report_state_hook(i2400m
,
510 l3l4_hdr
, size
, "REPORT STATE");
512 /* If the device is ready for power save, then ask it to do
514 case I2400M_MT_REPORT_POWERSAVE_READY
: /* zzzzz */
515 if (l3l4_hdr
->status
== cpu_to_le16(I2400M_MS_DONE_OK
)) {
516 if (i2400m_power_save_disabled
)
517 d_printf(1, dev
, "ready for powersave, "
518 "not requesting (disabled by module "
521 d_printf(1, dev
, "ready for powersave, "
523 i2400m_cmd_enter_powersave(i2400m
);
528 d_fnend(3, dev
, "(i2400m %p l3l4_hdr %p size %zu) = void\n",
529 i2400m
, l3l4_hdr
, size
);
534 * i2400m_msg_ack_hook - process cmd/set/get ack for internal status
536 * @i2400m: device descriptor
537 * @l3l4_hdr: pointer to message; it has been already validated for
539 * @size: size of the message
541 * Extract information we might need from acks to commands and act on
542 * it. This is akin to i2400m_report_hook(). Note most of this
543 * processing should be done in the function that calls the
544 * command. This is here for some cases where it can't happen...
546 void i2400m_msg_ack_hook(struct i2400m
*i2400m
,
547 const struct i2400m_l3l4_hdr
*l3l4_hdr
, size_t size
)
550 struct device
*dev
= i2400m_dev(i2400m
);
551 unsigned ack_type
, ack_status
;
554 /* Chew on the message, we might need some information from
556 ack_type
= le16_to_cpu(l3l4_hdr
->type
);
557 ack_status
= le16_to_cpu(l3l4_hdr
->status
);
559 case I2400M_MT_CMD_ENTER_POWERSAVE
:
560 /* This is just left here for the sake of example, as
561 * the processing is done somewhere else. */
563 result
= i2400m_msg_check_status(
564 l3l4_hdr
, strerr
, sizeof(strerr
));
566 d_printf(1, dev
, "ready for power save: %zd\n",
576 * i2400m_msg_size_check() - verify message size and header are congruent
578 * It is ok if the total message size is larger than the expected
579 * size, as there can be padding.
581 int i2400m_msg_size_check(struct i2400m
*i2400m
,
582 const struct i2400m_l3l4_hdr
*l3l4_hdr
,
586 struct device
*dev
= i2400m_dev(i2400m
);
587 size_t expected_size
;
588 d_fnstart(4, dev
, "(i2400m %p l3l4_hdr %p msg_size %zu)\n",
589 i2400m
, l3l4_hdr
, msg_size
);
590 if (msg_size
< sizeof(*l3l4_hdr
)) {
591 dev_err(dev
, "bad size for message header "
592 "(expected at least %zu, got %zu)\n",
593 (size_t) sizeof(*l3l4_hdr
), msg_size
);
597 expected_size
= le16_to_cpu(l3l4_hdr
->length
) + sizeof(*l3l4_hdr
);
598 if (msg_size
< expected_size
) {
599 dev_err(dev
, "bad size for message code 0x%04x (expected %zu, "
600 "got %zu)\n", le16_to_cpu(l3l4_hdr
->type
),
601 expected_size
, msg_size
);
607 "(i2400m %p l3l4_hdr %p msg_size %zu) = %d\n",
608 i2400m
, l3l4_hdr
, msg_size
, result
);
615 * Cancel a wait for a command ACK
617 * @i2400m: device descriptor
618 * @code: [negative] errno code to cancel with (don't use
621 * If there is an ack already filled out, free it.
623 void i2400m_msg_to_dev_cancel_wait(struct i2400m
*i2400m
, int code
)
625 struct sk_buff
*ack_skb
;
628 spin_lock_irqsave(&i2400m
->rx_lock
, flags
);
629 ack_skb
= i2400m
->ack_skb
;
630 if (ack_skb
&& !IS_ERR(ack_skb
))
632 i2400m
->ack_skb
= ERR_PTR(code
);
633 spin_unlock_irqrestore(&i2400m
->rx_lock
, flags
);
638 * i2400m_msg_to_dev - Send a control message to the device and get a response
640 * @i2400m: device descriptor
644 * @buf: pointer to the buffer containing the message to be sent; it
645 * has to start with a &struct i2400M_l3l4_hdr and then
646 * followed by the payload. Once this function returns, the
647 * buffer can be reused.
649 * @buf_len: buffer size
653 * Pointer to skb containing the ack message. You need to check the
654 * pointer with IS_ERR(), as it might be an error code. Error codes
655 * could happen because:
657 * - the message wasn't formatted correctly
658 * - couldn't send the message
659 * - failed waiting for a response
660 * - the ack message wasn't formatted correctly
662 * The returned skb has been allocated with wimax_msg_to_user_alloc(),
663 * it contains the reponse in a netlink attribute and is ready to be
664 * passed up to user space with wimax_msg_to_user_send(). To access
665 * the payload and its length, use wimax_msg_{data,len}() on the skb.
667 * The skb has to be freed with kfree_skb() once done.
671 * This function delivers a message/command to the device and waits
672 * for an ack to be received. The format is described in
673 * linux/wimax/i2400m.h. In summary, a command/get/set is followed by an
676 * This function will not check the ack status, that's left up to the
677 * caller. Once done with the ack skb, it has to be kfree_skb()ed.
679 * The i2400m handles only one message at the same time, thus we need
680 * the mutex to exclude other players.
682 * We write the message and then wait for an answer to come back. The
683 * RX path intercepts control messages and handles them in
684 * i2400m_rx_ctl(). Reports (notifications) are (maybe) processed
685 * locally and then forwarded (as needed) to user space on the WiMAX
686 * stack message pipe. Acks are saved and passed back to us through an
687 * skb in i2400m->ack_skb which is ready to be given to generic
688 * netlink if need be.
690 struct sk_buff
*i2400m_msg_to_dev(struct i2400m
*i2400m
,
691 const void *buf
, size_t buf_len
)
694 struct device
*dev
= i2400m_dev(i2400m
);
695 const struct i2400m_l3l4_hdr
*msg_l3l4_hdr
;
696 struct sk_buff
*ack_skb
;
697 const struct i2400m_l3l4_hdr
*ack_l3l4_hdr
;
703 d_fnstart(3, dev
, "(i2400m %p buf %p len %zu)\n",
704 i2400m
, buf
, buf_len
);
706 rmb(); /* Make sure we see what i2400m_dev_reset_handle() */
707 if (i2400m
->boot_mode
)
708 return ERR_PTR(-EL3RST
);
711 /* Check msg & payload consistency */
712 result
= i2400m_msg_size_check(i2400m
, msg_l3l4_hdr
, buf_len
);
715 msg_type
= le16_to_cpu(msg_l3l4_hdr
->type
);
716 d_printf(1, dev
, "CMD/GET/SET 0x%04x %zu bytes\n",
718 d_dump(2, dev
, buf
, buf_len
);
720 /* Setup the completion, ack_skb ("we are waiting") and send
721 * the message to the device */
722 mutex_lock(&i2400m
->msg_mutex
);
723 spin_lock_irqsave(&i2400m
->rx_lock
, flags
);
724 i2400m
->ack_skb
= ERR_PTR(-EINPROGRESS
);
725 spin_unlock_irqrestore(&i2400m
->rx_lock
, flags
);
726 init_completion(&i2400m
->msg_completion
);
727 result
= i2400m_tx(i2400m
, buf
, buf_len
, I2400M_PT_CTRL
);
729 dev_err(dev
, "can't send message 0x%04x: %d\n",
730 le16_to_cpu(msg_l3l4_hdr
->type
), result
);
734 /* Some commands take longer to execute because of crypto ops,
735 * so we give them some more leeway on timeout */
737 case I2400M_MT_GET_TLS_OPERATION_RESULT
:
738 case I2400M_MT_CMD_SEND_EAP_RESPONSE
:
739 ack_timeout
= 5 * HZ
;
745 if (unlikely(i2400m
->trace_msg_from_user
))
746 wimax_msg(&i2400m
->wimax_dev
, "echo", buf
, buf_len
, GFP_KERNEL
);
747 /* The RX path in rx.c will put any response for this message
748 * in i2400m->ack_skb and wake us up. If we cancel the wait,
749 * we need to change the value of i2400m->ack_skb to something
750 * not -EINPROGRESS so RX knows there is no one waiting. */
751 result
= wait_for_completion_interruptible_timeout(
752 &i2400m
->msg_completion
, ack_timeout
);
754 dev_err(dev
, "timeout waiting for reply to message 0x%04x\n",
757 i2400m_msg_to_dev_cancel_wait(i2400m
, result
);
758 goto error_wait_for_completion
;
759 } else if (result
< 0) {
760 dev_err(dev
, "error waiting for reply to message 0x%04x: %d\n",
762 i2400m_msg_to_dev_cancel_wait(i2400m
, result
);
763 goto error_wait_for_completion
;
766 /* Pull out the ack data from i2400m->ack_skb -- see if it is
767 * an error and act accordingly */
768 spin_lock_irqsave(&i2400m
->rx_lock
, flags
);
769 ack_skb
= i2400m
->ack_skb
;
771 result
= PTR_ERR(ack_skb
);
774 i2400m
->ack_skb
= NULL
;
775 spin_unlock_irqrestore(&i2400m
->rx_lock
, flags
);
777 goto error_ack_status
;
778 ack_l3l4_hdr
= wimax_msg_data_len(ack_skb
, &ack_len
);
780 /* Check the ack and deliver it if it is ok */
781 if (unlikely(i2400m
->trace_msg_from_user
))
782 wimax_msg(&i2400m
->wimax_dev
, "echo",
783 ack_l3l4_hdr
, ack_len
, GFP_KERNEL
);
784 result
= i2400m_msg_size_check(i2400m
, ack_l3l4_hdr
, ack_len
);
786 dev_err(dev
, "HW BUG? reply to message 0x%04x: %d\n",
788 goto error_bad_ack_len
;
790 if (msg_type
!= le16_to_cpu(ack_l3l4_hdr
->type
)) {
791 dev_err(dev
, "HW BUG? bad reply 0x%04x to message 0x%04x\n",
792 le16_to_cpu(ack_l3l4_hdr
->type
), msg_type
);
794 goto error_bad_ack_type
;
796 i2400m_msg_ack_hook(i2400m
, ack_l3l4_hdr
, ack_len
);
797 mutex_unlock(&i2400m
->msg_mutex
);
798 d_fnend(3, dev
, "(i2400m %p buf %p len %zu) = %p\n",
799 i2400m
, buf
, buf_len
, ack_skb
);
806 error_wait_for_completion
:
808 mutex_unlock(&i2400m
->msg_mutex
);
810 d_fnend(3, dev
, "(i2400m %p buf %p len %zu) = %d\n",
811 i2400m
, buf
, buf_len
, result
);
812 return ERR_PTR(result
);
817 * Definitions for the Enter Power Save command
819 * The Enter Power Save command requests the device to go into power
820 * saving mode. The device will ack or nak the command depending on it
821 * being ready for it. If it acks, we tell the USB subsystem to
823 * As well, the device might request to go into power saving mode by
824 * sending a report (REPORT_POWERSAVE_READY), in which case, we issue
825 * this command. The hookups in the RX coder allow
828 I2400M_WAKEUP_ENABLED
= 0x01,
829 I2400M_WAKEUP_DISABLED
= 0x02,
830 I2400M_TLV_TYPE_WAKEUP_MODE
= 144,
833 struct i2400m_cmd_enter_power_save
{
834 struct i2400m_l3l4_hdr hdr
;
835 struct i2400m_tlv_hdr tlv
;
837 } __attribute__((packed
));
841 * Request entering power save
843 * This command is (mainly) executed when the device indicates that it
844 * is ready to go into powersave mode via a REPORT_POWERSAVE_READY.
846 int i2400m_cmd_enter_powersave(struct i2400m
*i2400m
)
849 struct device
*dev
= i2400m_dev(i2400m
);
850 struct sk_buff
*ack_skb
;
851 struct i2400m_cmd_enter_power_save
*cmd
;
855 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
858 cmd
->hdr
.type
= cpu_to_le16(I2400M_MT_CMD_ENTER_POWERSAVE
);
859 cmd
->hdr
.length
= cpu_to_le16(sizeof(*cmd
) - sizeof(cmd
->hdr
));
860 cmd
->hdr
.version
= cpu_to_le16(I2400M_L3L4_VERSION
);
861 cmd
->tlv
.type
= cpu_to_le16(I2400M_TLV_TYPE_WAKEUP_MODE
);
862 cmd
->tlv
.length
= cpu_to_le16(sizeof(cmd
->val
));
863 cmd
->val
= cpu_to_le32(I2400M_WAKEUP_ENABLED
);
865 ack_skb
= i2400m_msg_to_dev(i2400m
, cmd
, sizeof(*cmd
));
866 result
= PTR_ERR(ack_skb
);
867 if (IS_ERR(ack_skb
)) {
868 dev_err(dev
, "Failed to issue 'Enter power save' command: %d\n",
870 goto error_msg_to_dev
;
872 result
= i2400m_msg_check_status(wimax_msg_data(ack_skb
),
873 strerr
, sizeof(strerr
));
874 if (result
== -EACCES
)
875 d_printf(1, dev
, "Cannot enter power save mode\n");
877 dev_err(dev
, "'Enter power save' (0x%04x) command failed: "
878 "%d - %s\n", I2400M_MT_CMD_ENTER_POWERSAVE
,
881 d_printf(1, dev
, "device ready to power save\n");
888 EXPORT_SYMBOL_GPL(i2400m_cmd_enter_powersave
);
892 * Definitions for getting device information
895 I2400M_TLV_DETAILED_DEVICE_INFO
= 140
899 * i2400m_get_device_info - Query the device for detailed device information
901 * @i2400m: device descriptor
903 * Returns: an skb whose skb->data points to a 'struct
904 * i2400m_tlv_detailed_device_info'. When done, kfree_skb() it. The
905 * skb is *guaranteed* to contain the whole TLV data structure.
907 * On error, IS_ERR(skb) is true and ERR_PTR(skb) is the error
910 struct sk_buff
*i2400m_get_device_info(struct i2400m
*i2400m
)
913 struct device
*dev
= i2400m_dev(i2400m
);
914 struct sk_buff
*ack_skb
;
915 struct i2400m_l3l4_hdr
*cmd
;
916 const struct i2400m_l3l4_hdr
*ack
;
918 const struct i2400m_tlv_hdr
*tlv
;
919 const struct i2400m_tlv_detailed_device_info
*ddi
;
922 ack_skb
= ERR_PTR(-ENOMEM
);
923 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
926 cmd
->type
= cpu_to_le16(I2400M_MT_GET_DEVICE_INFO
);
928 cmd
->version
= cpu_to_le16(I2400M_L3L4_VERSION
);
930 ack_skb
= i2400m_msg_to_dev(i2400m
, cmd
, sizeof(*cmd
));
931 if (IS_ERR(ack_skb
)) {
932 dev_err(dev
, "Failed to issue 'get device info' command: %ld\n",
934 goto error_msg_to_dev
;
936 ack
= wimax_msg_data_len(ack_skb
, &ack_len
);
937 result
= i2400m_msg_check_status(ack
, strerr
, sizeof(strerr
));
939 dev_err(dev
, "'get device info' (0x%04x) command failed: "
940 "%d - %s\n", I2400M_MT_GET_DEVICE_INFO
, result
,
942 goto error_cmd_failed
;
944 tlv
= i2400m_tlv_find(i2400m
, ack
->pl
, ack_len
- sizeof(*ack
),
945 I2400M_TLV_DETAILED_DEVICE_INFO
, sizeof(*ddi
));
947 dev_err(dev
, "GET DEVICE INFO: "
948 "detailed device info TLV not found (0x%04x)\n",
949 I2400M_TLV_DETAILED_DEVICE_INFO
);
953 skb_pull(ack_skb
, (void *) tlv
- (void *) ack_skb
->data
);
963 return ERR_PTR(result
);
967 /* Firmware interface versions we support */
969 I2400M_HDIv_MAJOR
= 9,
970 I2400M_HDIv_MINOR
= 1,
971 I2400M_HDIv_MINOR_2
= 2,
976 * i2400m_firmware_check - check firmware versions are compatible with
979 * @i2400m: device descriptor
981 * Returns: 0 if ok, < 0 errno code an error and a message in the
984 * Long function, but quite simple; first chunk launches the command
985 * and double checks the reply for the right TLV. Then we process the
986 * TLV (where the meat is).
988 * Once we process the TLV that gives us the firmware's interface
989 * version, we encode it and save it in i2400m->fw_version for future
992 int i2400m_firmware_check(struct i2400m
*i2400m
)
995 struct device
*dev
= i2400m_dev(i2400m
);
996 struct sk_buff
*ack_skb
;
997 struct i2400m_l3l4_hdr
*cmd
;
998 const struct i2400m_l3l4_hdr
*ack
;
1000 const struct i2400m_tlv_hdr
*tlv
;
1001 const struct i2400m_tlv_l4_message_versions
*l4mv
;
1003 unsigned major
, minor
, branch
;
1006 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
1009 cmd
->type
= cpu_to_le16(I2400M_MT_GET_LM_VERSION
);
1011 cmd
->version
= cpu_to_le16(I2400M_L3L4_VERSION
);
1013 ack_skb
= i2400m_msg_to_dev(i2400m
, cmd
, sizeof(*cmd
));
1014 if (IS_ERR(ack_skb
)) {
1015 result
= PTR_ERR(ack_skb
);
1016 dev_err(dev
, "Failed to issue 'get lm version' command: %-d\n",
1018 goto error_msg_to_dev
;
1020 ack
= wimax_msg_data_len(ack_skb
, &ack_len
);
1021 result
= i2400m_msg_check_status(ack
, strerr
, sizeof(strerr
));
1023 dev_err(dev
, "'get lm version' (0x%04x) command failed: "
1024 "%d - %s\n", I2400M_MT_GET_LM_VERSION
, result
,
1026 goto error_cmd_failed
;
1028 tlv
= i2400m_tlv_find(i2400m
, ack
->pl
, ack_len
- sizeof(*ack
),
1029 I2400M_TLV_L4_MESSAGE_VERSIONS
, sizeof(*l4mv
));
1031 dev_err(dev
, "get lm version: TLV not found (0x%04x)\n",
1032 I2400M_TLV_L4_MESSAGE_VERSIONS
);
1036 l4mv
= container_of(tlv
, typeof(*l4mv
), hdr
);
1037 major
= le16_to_cpu(l4mv
->major
);
1038 minor
= le16_to_cpu(l4mv
->minor
);
1039 branch
= le16_to_cpu(l4mv
->branch
);
1041 if (major
!= I2400M_HDIv_MAJOR
) {
1042 dev_err(dev
, "unsupported major fw version "
1043 "%u.%u.%u\n", major
, minor
, branch
);
1044 goto error_bad_major
;
1047 if (minor
< I2400M_HDIv_MINOR_2
&& minor
> I2400M_HDIv_MINOR
)
1048 dev_warn(dev
, "untested minor fw version %u.%u.%u\n",
1049 major
, minor
, branch
);
1050 /* Yes, we ignore the branch -- we don't have to track it */
1051 i2400m
->fw_version
= major
<< 16 | minor
;
1052 dev_info(dev
, "firmware interface version %u.%u.%u\n",
1053 major
, minor
, branch
);
1066 * Send an DoExitIdle command to the device to ask it to go out of
1067 * basestation-idle mode.
1069 * @i2400m: device descriptor
1071 * This starts a renegotiation with the basestation that might involve
1072 * another crypto handshake with user space.
1074 * Returns: 0 if ok, < 0 errno code on error.
1076 int i2400m_cmd_exit_idle(struct i2400m
*i2400m
)
1079 struct device
*dev
= i2400m_dev(i2400m
);
1080 struct sk_buff
*ack_skb
;
1081 struct i2400m_l3l4_hdr
*cmd
;
1085 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
1088 cmd
->type
= cpu_to_le16(I2400M_MT_CMD_EXIT_IDLE
);
1090 cmd
->version
= cpu_to_le16(I2400M_L3L4_VERSION
);
1092 ack_skb
= i2400m_msg_to_dev(i2400m
, cmd
, sizeof(*cmd
));
1093 result
= PTR_ERR(ack_skb
);
1094 if (IS_ERR(ack_skb
)) {
1095 dev_err(dev
, "Failed to issue 'exit idle' command: %d\n",
1097 goto error_msg_to_dev
;
1099 result
= i2400m_msg_check_status(wimax_msg_data(ack_skb
),
1100 strerr
, sizeof(strerr
));
1111 * Query the device for its state, update the WiMAX stack's idea of it
1113 * @i2400m: device descriptor
1115 * Returns: 0 if ok, < 0 errno code on error.
1117 * Executes a 'Get State' command and parses the returned
1120 * Because this is almost identical to a 'Report State', we use
1121 * i2400m_report_state_hook() to parse the answer. This will set the
1122 * carrier state, as well as the RF Kill switches state.
1124 int i2400m_cmd_get_state(struct i2400m
*i2400m
)
1127 struct device
*dev
= i2400m_dev(i2400m
);
1128 struct sk_buff
*ack_skb
;
1129 struct i2400m_l3l4_hdr
*cmd
;
1130 const struct i2400m_l3l4_hdr
*ack
;
1135 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
1138 cmd
->type
= cpu_to_le16(I2400M_MT_GET_STATE
);
1140 cmd
->version
= cpu_to_le16(I2400M_L3L4_VERSION
);
1142 ack_skb
= i2400m_msg_to_dev(i2400m
, cmd
, sizeof(*cmd
));
1143 if (IS_ERR(ack_skb
)) {
1144 dev_err(dev
, "Failed to issue 'get state' command: %ld\n",
1146 result
= PTR_ERR(ack_skb
);
1147 goto error_msg_to_dev
;
1149 ack
= wimax_msg_data_len(ack_skb
, &ack_len
);
1150 result
= i2400m_msg_check_status(ack
, strerr
, sizeof(strerr
));
1152 dev_err(dev
, "'get state' (0x%04x) command failed: "
1153 "%d - %s\n", I2400M_MT_GET_STATE
, result
, strerr
);
1154 goto error_cmd_failed
;
1156 i2400m_report_state_hook(i2400m
, ack
, ack_len
- sizeof(*ack
),
1166 EXPORT_SYMBOL_GPL(i2400m_cmd_get_state
);
1170 * Set basic configuration settings
1172 * @i2400m: device descriptor
1173 * @args: array of pointers to the TLV headers to send for
1174 * configuration (each followed by its payload).
1175 * TLV headers and payloads must be properly initialized, with the
1176 * right endianess (LE).
1177 * @arg_size: number of pointers in the @args array
1179 int i2400m_set_init_config(struct i2400m
*i2400m
,
1180 const struct i2400m_tlv_hdr
**arg
, size_t args
)
1183 struct device
*dev
= i2400m_dev(i2400m
);
1184 struct sk_buff
*ack_skb
;
1185 struct i2400m_l3l4_hdr
*cmd
;
1187 unsigned argc
, argsize
, tlv_size
;
1188 const struct i2400m_tlv_hdr
*tlv_hdr
;
1191 d_fnstart(3, dev
, "(i2400m %p arg %p args %zu)\n", i2400m
, arg
, args
);
1195 /* Compute the size of all the TLVs, so we can alloc a
1196 * contiguous command block to copy them. */
1198 for (argc
= 0; argc
< args
; argc
++) {
1199 tlv_hdr
= arg
[argc
];
1200 argsize
+= sizeof(*tlv_hdr
) + le16_to_cpu(tlv_hdr
->length
);
1202 WARN_ON(argc
>= 9); /* As per hw spec */
1204 /* Alloc the space for the command and TLVs*/
1206 buf
= kzalloc(sizeof(*cmd
) + argsize
, GFP_KERNEL
);
1210 cmd
->type
= cpu_to_le16(I2400M_MT_SET_INIT_CONFIG
);
1211 cmd
->length
= cpu_to_le16(argsize
);
1212 cmd
->version
= cpu_to_le16(I2400M_L3L4_VERSION
);
1215 itr
= buf
+ sizeof(*cmd
);
1216 for (argc
= 0; argc
< args
; argc
++) {
1217 tlv_hdr
= arg
[argc
];
1218 tlv_size
= sizeof(*tlv_hdr
) + le16_to_cpu(tlv_hdr
->length
);
1219 memcpy(itr
, tlv_hdr
, tlv_size
);
1223 /* Send the message! */
1224 ack_skb
= i2400m_msg_to_dev(i2400m
, buf
, sizeof(*cmd
) + argsize
);
1225 result
= PTR_ERR(ack_skb
);
1226 if (IS_ERR(ack_skb
)) {
1227 dev_err(dev
, "Failed to issue 'init config' command: %d\n",
1230 goto error_msg_to_dev
;
1232 result
= i2400m_msg_check_status(wimax_msg_data(ack_skb
),
1233 strerr
, sizeof(strerr
));
1235 dev_err(dev
, "'init config' (0x%04x) command failed: %d - %s\n",
1236 I2400M_MT_SET_INIT_CONFIG
, result
, strerr
);
1242 d_fnend(3, dev
, "(i2400m %p arg %p args %zu) = %d\n",
1243 i2400m
, arg
, args
, result
);
1247 EXPORT_SYMBOL_GPL(i2400m_set_init_config
);
1251 * i2400m_set_idle_timeout - Set the device's idle mode timeout
1253 * @i2400m: i2400m device descriptor
1255 * @msecs: milliseconds for the timeout to enter idle mode. Between
1256 * 100 to 300000 (5m); 0 to disable. In increments of 100.
1258 * After this @msecs of the link being idle (no data being sent or
1259 * received), the device will negotiate with the basestation entering
1260 * idle mode for saving power. The connection is maintained, but
1261 * getting out of it (done in tx.c) will require some negotiation,
1262 * possible crypto re-handshake and a possible DHCP re-lease.
1264 * Only available if fw_version >= 0x00090002.
1266 * Returns: 0 if ok, < 0 errno code on error.
1268 int i2400m_set_idle_timeout(struct i2400m
*i2400m
, unsigned msecs
)
1271 struct device
*dev
= i2400m_dev(i2400m
);
1272 struct sk_buff
*ack_skb
;
1274 struct i2400m_l3l4_hdr hdr
;
1275 struct i2400m_tlv_config_idle_timeout cit
;
1277 const struct i2400m_l3l4_hdr
*ack
;
1282 if (i2400m_le_v1_3(i2400m
))
1285 cmd
= kzalloc(sizeof(*cmd
), GFP_KERNEL
);
1288 cmd
->hdr
.type
= cpu_to_le16(I2400M_MT_GET_STATE
);
1289 cmd
->hdr
.length
= cpu_to_le16(sizeof(*cmd
) - sizeof(cmd
->hdr
));
1290 cmd
->hdr
.version
= cpu_to_le16(I2400M_L3L4_VERSION
);
1293 cpu_to_le16(I2400M_TLV_CONFIG_IDLE_TIMEOUT
);
1294 cmd
->cit
.hdr
.length
= cpu_to_le16(sizeof(cmd
->cit
.timeout
));
1295 cmd
->cit
.timeout
= cpu_to_le32(msecs
);
1297 ack_skb
= i2400m_msg_to_dev(i2400m
, cmd
, sizeof(*cmd
));
1298 if (IS_ERR(ack_skb
)) {
1299 dev_err(dev
, "Failed to issue 'set idle timeout' command: "
1300 "%ld\n", PTR_ERR(ack_skb
));
1301 result
= PTR_ERR(ack_skb
);
1302 goto error_msg_to_dev
;
1304 ack
= wimax_msg_data_len(ack_skb
, &ack_len
);
1305 result
= i2400m_msg_check_status(ack
, strerr
, sizeof(strerr
));
1307 dev_err(dev
, "'set idle timeout' (0x%04x) command failed: "
1308 "%d - %s\n", I2400M_MT_GET_STATE
, result
, strerr
);
1309 goto error_cmd_failed
;
1322 * i2400m_dev_initialize - Initialize the device once communications are ready
1324 * @i2400m: device descriptor
1326 * Returns: 0 if ok, < 0 errno code on error.
1328 * Configures the device to work the way we like it.
1330 * At the point of this call, the device is registered with the WiMAX
1331 * and netdev stacks, firmware is uploaded and we can talk to the
1334 int i2400m_dev_initialize(struct i2400m
*i2400m
)
1337 struct device
*dev
= i2400m_dev(i2400m
);
1338 struct i2400m_tlv_config_idle_parameters idle_params
;
1339 struct i2400m_tlv_config_idle_timeout idle_timeout
;
1340 struct i2400m_tlv_config_d2h_data_format df
;
1341 struct i2400m_tlv_config_dl_host_reorder dlhr
;
1342 const struct i2400m_tlv_hdr
*args
[9];
1345 d_fnstart(3, dev
, "(i2400m %p)\n", i2400m
);
1346 if (i2400m_passive_mode
)
1348 /* Disable idle mode? (enabled by default) */
1349 if (i2400m_idle_mode_disabled
) {
1350 if (i2400m_le_v1_3(i2400m
)) {
1351 idle_params
.hdr
.type
=
1352 cpu_to_le16(I2400M_TLV_CONFIG_IDLE_PARAMETERS
);
1353 idle_params
.hdr
.length
= cpu_to_le16(
1354 sizeof(idle_params
) - sizeof(idle_params
.hdr
));
1355 idle_params
.idle_timeout
= 0;
1356 idle_params
.idle_paging_interval
= 0;
1357 args
[argc
++] = &idle_params
.hdr
;
1359 idle_timeout
.hdr
.type
=
1360 cpu_to_le16(I2400M_TLV_CONFIG_IDLE_TIMEOUT
);
1361 idle_timeout
.hdr
.length
= cpu_to_le16(
1362 sizeof(idle_timeout
) - sizeof(idle_timeout
.hdr
));
1363 idle_timeout
.timeout
= 0;
1364 args
[argc
++] = &idle_timeout
.hdr
;
1367 if (i2400m_ge_v1_4(i2400m
)) {
1368 /* Enable extended RX data format? */
1370 cpu_to_le16(I2400M_TLV_CONFIG_D2H_DATA_FORMAT
);
1371 df
.hdr
.length
= cpu_to_le16(
1372 sizeof(df
) - sizeof(df
.hdr
));
1374 args
[argc
++] = &df
.hdr
;
1376 /* Enable RX data reordering?
1377 * (switch flipped in rx.c:i2400m_rx_setup() after fw upload) */
1378 if (i2400m
->rx_reorder
) {
1380 cpu_to_le16(I2400M_TLV_CONFIG_DL_HOST_REORDER
);
1381 dlhr
.hdr
.length
= cpu_to_le16(
1382 sizeof(dlhr
) - sizeof(dlhr
.hdr
));
1384 args
[argc
++] = &dlhr
.hdr
;
1387 result
= i2400m_set_init_config(i2400m
, args
, argc
);
1392 * Update state: Here it just calls a get state; parsing the
1393 * result (System State TLV and RF Status TLV [done in the rx
1394 * path hooks]) will set the hardware and software RF-Kill
1397 result
= i2400m_cmd_get_state(i2400m
);
1400 dev_err(dev
, "failed to initialize the device: %d\n", result
);
1401 d_fnend(3, dev
, "(i2400m %p) = %d\n", i2400m
, result
);
1407 * i2400m_dev_shutdown - Shutdown a running device
1409 * @i2400m: device descriptor
1411 * Release resources acquired during the running of the device; in
1412 * theory, should also tell the device to go to sleep, switch off the
1413 * radio, all that, but at this point, in most cases (driver
1414 * disconnection, reset handling) we can't even talk to the device.
1416 void i2400m_dev_shutdown(struct i2400m
*i2400m
)
1418 struct device
*dev
= i2400m_dev(i2400m
);
1420 d_fnstart(3, dev
, "(i2400m %p)\n", i2400m
);
1421 d_fnend(3, dev
, "(i2400m %p) = void\n", i2400m
);