Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    2)  * Intel Wireless WiMAX Connection 2400m
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    3)  * Miscellaneous control functions for managing the device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    6)  * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    8)  * Redistribution and use in source and binary forms, with or without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    9)  * modification, are permitted provided that the following conditions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   10)  * are met:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   11)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   12)  *   * Redistributions of source code must retain the above copyright
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   13)  *     notice, this list of conditions and the following disclaimer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   14)  *   * Redistributions in binary form must reproduce the above copyright
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   15)  *     notice, this list of conditions and the following disclaimer in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   16)  *     the documentation and/or other materials provided with the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   17)  *     distribution.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   18)  *   * Neither the name of Intel Corporation nor the names of its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   19)  *     contributors may be used to endorse or promote products derived
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   20)  *     from this software without specific prior written permission.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   21)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   22)  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   23)  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   24)  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   25)  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   26)  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   27)  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   28)  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   29)  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   30)  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   31)  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   32)  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   33)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   34)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   35)  * Intel Corporation <linux-wimax@intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   36)  * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   37)  *  - Initial implementation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   38)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   39)  * This is a collection of functions used to control the device (plus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   40)  * a few helpers).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   41)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   42)  * There are utilities for handling TLV buffers, hooks on the device's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   43)  * reports to act on device changes of state [i2400m_report_hook()],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   44)  * on acks to commands [i2400m_msg_ack_hook()], a helper for sending
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   45)  * commands to the device and blocking until a reply arrives
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   46)  * [i2400m_msg_to_dev()], a few high level commands for manipulating
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   47)  * the device state, powersving mode and configuration plus the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   48)  * routines to setup the device once communication is stablished with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   49)  * it [i2400m_dev_initialize()].
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   50)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   51)  * ROADMAP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   52)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   53)  * i2400m_dev_initialize()       Called by i2400m_dev_start()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   54)  *   i2400m_set_init_config()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   55)  *   i2400m_cmd_get_state()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   56)  * i2400m_dev_shutdown()        Called by i2400m_dev_stop()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   57)  *   i2400m_reset()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   58)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   59)  * i2400m_{cmd,get,set}_*()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   60)  *   i2400m_msg_to_dev()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   61)  *   i2400m_msg_check_status()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   62)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   63)  * i2400m_report_hook()         Called on reception of an event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   64)  *   i2400m_report_state_hook()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   65)  *     i2400m_tlv_buffer_walk()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   66)  *     i2400m_tlv_match()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   67)  *     i2400m_report_tlv_system_state()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   68)  *     i2400m_report_tlv_rf_switches_status()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   69)  *     i2400m_report_tlv_media_status()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   70)  *   i2400m_cmd_enter_powersave()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   71)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   72)  * i2400m_msg_ack_hook()        Called on reception of a reply to a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   73)  *                              command, get or set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   74)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   76) #include <stdarg.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   77) #include "i2400m.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   78) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   79) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   80) #include <linux/wimax/i2400m.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   81) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   82) #include <linux/moduleparam.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   85) #define D_SUBMODULE control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   86) #include "debug-levels.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   88) static int i2400m_idle_mode_disabled;/* 0 (idle mode enabled) by default */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   89) module_param_named(idle_mode_disabled, i2400m_idle_mode_disabled, int, 0644);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   90) MODULE_PARM_DESC(idle_mode_disabled,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   91) 		 "If true, the device will not enable idle mode negotiation "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   92) 		 "with the base station (when connected) to save power.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   94) /* 0 (power saving enabled) by default */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   95) static int i2400m_power_save_disabled;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   96) module_param_named(power_save_disabled, i2400m_power_save_disabled, int, 0644);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   97) MODULE_PARM_DESC(power_save_disabled,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   98) 		 "If true, the driver will not tell the device to enter "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   99) 		 "power saving mode when it reports it is ready for it. "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  100) 		 "False by default (so the device is told to do power "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  101) 		 "saving).");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  103) static int i2400m_passive_mode;	/* 0 (passive mode disabled) by default */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  104) module_param_named(passive_mode, i2400m_passive_mode, int, 0644);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  105) MODULE_PARM_DESC(passive_mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  106) 		 "If true, the driver will not do any device setup "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  107) 		 "and leave it up to user space, who must be properly "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  108) 		 "setup.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  111) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  112)  * Return if a TLV is of a give type and size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  113)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  114)  * @tlv_hdr: pointer to the TLV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  115)  * @tlv_type: type of the TLV we are looking for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  116)  * @tlv_size: expected size of the TLV we are looking for (if -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  117)  *            don't check the size). This includes the header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  118)  * Returns: 0 if the TLV matches
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  119)  *          < 0 if it doesn't match at all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  120)  *          > 0 total TLV + payload size, if the type matches, but not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  121)  *              the size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  122)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  123) static
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  124) ssize_t i2400m_tlv_match(const struct i2400m_tlv_hdr *tlv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  125) 		     enum i2400m_tlv tlv_type, ssize_t tlv_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  126) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  127) 	if (le16_to_cpu(tlv->type) != tlv_type)	/* Not our type? skip */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  128) 		return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  129) 	if (tlv_size != -1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  130) 	    && le16_to_cpu(tlv->length) + sizeof(*tlv) != tlv_size) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  131) 		size_t size = le16_to_cpu(tlv->length) + sizeof(*tlv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  132) 		printk(KERN_WARNING "W: tlv type 0x%x mismatched because of "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  133) 		       "size (got %zu vs %zd expected)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  134) 		       tlv_type, size, tlv_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  135) 		return size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  136) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  137) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  138) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  141) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  142)  * Given a buffer of TLVs, iterate over them
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  143)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  144)  * @i2400m: device instance
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  145)  * @tlv_buf: pointer to the beginning of the TLV buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  146)  * @buf_size: buffer size in bytes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  147)  * @tlv_pos: seek position; this is assumed to be a pointer returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  148)  *           by i2400m_tlv_buffer_walk() [and thus, validated]. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  149)  *           TLV returned will be the one following this one.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  150)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  151)  * Usage:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  152)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  153)  * tlv_itr = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  154)  * while (tlv_itr = i2400m_tlv_buffer_walk(i2400m, buf, size, tlv_itr))  {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  155)  *         ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  156)  *         // Do stuff with tlv_itr, DON'T MODIFY IT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  157)  *         ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  158)  * }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  159)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  160) static
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  161) const struct i2400m_tlv_hdr *i2400m_tlv_buffer_walk(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  162) 	struct i2400m *i2400m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  163) 	const void *tlv_buf, size_t buf_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  164) 	const struct i2400m_tlv_hdr *tlv_pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  165) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  166) 	struct device *dev = i2400m_dev(i2400m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  167) 	const struct i2400m_tlv_hdr *tlv_top = tlv_buf + buf_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  168) 	size_t offset, length, avail_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  169) 	unsigned type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  171) 	if (tlv_pos == NULL)	/* Take the first one? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  172) 		tlv_pos = tlv_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  173) 	else			/* Nope, the next one */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  174) 		tlv_pos = (void *) tlv_pos
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  175) 			+ le16_to_cpu(tlv_pos->length) + sizeof(*tlv_pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  176) 	if (tlv_pos == tlv_top) {	/* buffer done */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  177) 		tlv_pos = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  178) 		goto error_beyond_end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  179) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  180) 	if (tlv_pos > tlv_top) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  181) 		tlv_pos = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  182) 		WARN_ON(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  183) 		goto error_beyond_end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  184) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  185) 	offset = (void *) tlv_pos - (void *) tlv_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  186) 	avail_size = buf_size - offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  187) 	if (avail_size < sizeof(*tlv_pos)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  188) 		dev_err(dev, "HW BUG? tlv_buf %p [%zu bytes], tlv @%zu: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  189) 			"short header\n", tlv_buf, buf_size, offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  190) 		goto error_short_header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  191) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  192) 	type = le16_to_cpu(tlv_pos->type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  193) 	length = le16_to_cpu(tlv_pos->length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  194) 	if (avail_size < sizeof(*tlv_pos) + length) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  195) 		dev_err(dev, "HW BUG? tlv_buf %p [%zu bytes], "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  196) 			"tlv type 0x%04x @%zu: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  197) 			"short data (%zu bytes vs %zu needed)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  198) 			tlv_buf, buf_size, type, offset, avail_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  199) 			sizeof(*tlv_pos) + length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  200) 		goto error_short_header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  201) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  202) error_short_header:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  203) error_beyond_end:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  204) 	return tlv_pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  205) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  208) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  209)  * Find a TLV in a buffer of sequential TLVs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  210)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  211)  * @i2400m: device descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  212)  * @tlv_hdr: pointer to the first TLV in the sequence
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  213)  * @size: size of the buffer in bytes; all TLVs are assumed to fit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  214)  *        fully in the buffer (otherwise we'll complain).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  215)  * @tlv_type: type of the TLV we are looking for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  216)  * @tlv_size: expected size of the TLV we are looking for (if -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  217)  *            don't check the size). This includes the header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  218)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  219)  * Returns: NULL if the TLV is not found, otherwise a pointer to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  220)  *          it. If the sizes don't match, an error is printed and NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  221)  *          returned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  222)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  223) static
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  224) const struct i2400m_tlv_hdr *i2400m_tlv_find(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  225) 	struct i2400m *i2400m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  226) 	const struct i2400m_tlv_hdr *tlv_hdr, size_t size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  227) 	enum i2400m_tlv tlv_type, ssize_t tlv_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  228) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  229) 	ssize_t match;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  230) 	struct device *dev = i2400m_dev(i2400m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  231) 	const struct i2400m_tlv_hdr *tlv = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  232) 	while ((tlv = i2400m_tlv_buffer_walk(i2400m, tlv_hdr, size, tlv))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  233) 		match = i2400m_tlv_match(tlv, tlv_type, tlv_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  234) 		if (match == 0)		/* found it :) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  235) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  236) 		if (match > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  237) 			dev_warn(dev, "TLV type 0x%04x found with size "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  238) 				 "mismatch (%zu vs %zd needed)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  239) 				 tlv_type, match, tlv_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  240) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  241) 	return tlv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  242) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  243) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  245) static const struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  246) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  247) 	char *msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  248) 	int errno;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  249) } ms_to_errno[I2400M_MS_MAX] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  250) 	[I2400M_MS_DONE_OK] = { "", 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  251) 	[I2400M_MS_DONE_IN_PROGRESS] = { "", 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  252) 	[I2400M_MS_INVALID_OP] = { "invalid opcode", -ENOSYS },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  253) 	[I2400M_MS_BAD_STATE] = { "invalid state", -EILSEQ },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  254) 	[I2400M_MS_ILLEGAL_VALUE] = { "illegal value", -EINVAL },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  255) 	[I2400M_MS_MISSING_PARAMS] = { "missing parameters", -ENOMSG },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  256) 	[I2400M_MS_VERSION_ERROR] = { "bad version", -EIO },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  257) 	[I2400M_MS_ACCESSIBILITY_ERROR] = { "accesibility error", -EIO },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  258) 	[I2400M_MS_BUSY] = { "busy", -EBUSY },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  259) 	[I2400M_MS_CORRUPTED_TLV] = { "corrupted TLV", -EILSEQ },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  260) 	[I2400M_MS_UNINITIALIZED] = { "uninitialized", -EILSEQ },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  261) 	[I2400M_MS_UNKNOWN_ERROR] = { "unknown error", -EIO },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  262) 	[I2400M_MS_PRODUCTION_ERROR] = { "production error", -EIO },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  263) 	[I2400M_MS_NO_RF] = { "no RF", -EIO },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  264) 	[I2400M_MS_NOT_READY_FOR_POWERSAVE] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  265) 		{ "not ready for powersave", -EACCES },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  266) 	[I2400M_MS_THERMAL_CRITICAL] = { "thermal critical", -EL3HLT },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  267) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  268) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  270) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  271)  * i2400m_msg_check_status - translate a message's status code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  272)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  273)  * @i2400m: device descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  274)  * @l3l4_hdr: message header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  275)  * @strbuf: buffer to place a formatted error message (unless NULL).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  276)  * @strbuf_size: max amount of available space; larger messages will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  277)  * be truncated.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  278)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  279)  * Returns: errno code corresponding to the status code in @l3l4_hdr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  280)  *          and a message in @strbuf describing the error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  281)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  282) int i2400m_msg_check_status(const struct i2400m_l3l4_hdr *l3l4_hdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  283) 			    char *strbuf, size_t strbuf_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  284) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  285) 	int result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  286) 	enum i2400m_ms status = le16_to_cpu(l3l4_hdr->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  287) 	const char *str;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  288) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  289) 	if (status == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  290) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  291) 	if (status >= ARRAY_SIZE(ms_to_errno)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  292) 		str = "unknown status code";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  293) 		result = -EBADR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  294) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  295) 		str = ms_to_errno[status].msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  296) 		result = ms_to_errno[status].errno;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  297) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  298) 	if (strbuf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  299) 		snprintf(strbuf, strbuf_size, "%s (%d)", str, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  300) 	return result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  301) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  302) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  303) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  304) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  305)  * Act on a TLV System State reported by the device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  306)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  307)  * @i2400m: device descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  308)  * @ss: validated System State TLV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  309)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  310) static
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  311) void i2400m_report_tlv_system_state(struct i2400m *i2400m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  312) 				    const struct i2400m_tlv_system_state *ss)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  313) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  314) 	struct device *dev = i2400m_dev(i2400m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  315) 	struct wimax_dev *wimax_dev = &i2400m->wimax_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  316) 	enum i2400m_system_state i2400m_state = le32_to_cpu(ss->state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  317) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  318) 	d_fnstart(3, dev, "(i2400m %p ss %p [%u])\n", i2400m, ss, i2400m_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  319) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  320) 	if (i2400m->state != i2400m_state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  321) 		i2400m->state = i2400m_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  322) 		wake_up_all(&i2400m->state_wq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  323) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  324) 	switch (i2400m_state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  325) 	case I2400M_SS_UNINITIALIZED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  326) 	case I2400M_SS_INIT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  327) 	case I2400M_SS_CONFIG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  328) 	case I2400M_SS_PRODUCTION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  329) 		wimax_state_change(wimax_dev, WIMAX_ST_UNINITIALIZED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  330) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  331) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  332) 	case I2400M_SS_RF_OFF:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  333) 	case I2400M_SS_RF_SHUTDOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  334) 		wimax_state_change(wimax_dev, WIMAX_ST_RADIO_OFF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  335) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  336) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  337) 	case I2400M_SS_READY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  338) 	case I2400M_SS_STANDBY:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  339) 	case I2400M_SS_SLEEPACTIVE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  340) 		wimax_state_change(wimax_dev, WIMAX_ST_READY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  341) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  342) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  343) 	case I2400M_SS_CONNECTING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  344) 	case I2400M_SS_WIMAX_CONNECTED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  345) 		wimax_state_change(wimax_dev, WIMAX_ST_READY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  346) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  347) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  348) 	case I2400M_SS_SCAN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  349) 	case I2400M_SS_OUT_OF_ZONE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  350) 		wimax_state_change(wimax_dev, WIMAX_ST_SCANNING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  351) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  352) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  353) 	case I2400M_SS_IDLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  354) 		d_printf(1, dev, "entering BS-negotiated idle mode\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  355) 		fallthrough;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  356) 	case I2400M_SS_DISCONNECTING:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  357) 	case I2400M_SS_DATA_PATH_CONNECTED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  358) 		wimax_state_change(wimax_dev, WIMAX_ST_CONNECTED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  359) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  360) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  361) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  362) 		/* Huh? just in case, shut it down */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  363) 		dev_err(dev, "HW BUG? unknown state %u: shutting down\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  364) 			i2400m_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  365) 		i2400m_reset(i2400m, I2400M_RT_WARM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  366) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  367) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  368) 	d_fnend(3, dev, "(i2400m %p ss %p [%u]) = void\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  369) 		i2400m, ss, i2400m_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  370) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  371) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  372) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  373) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  374)  * Parse and act on a TLV Media Status sent by the device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  375)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  376)  * @i2400m: device descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  377)  * @ms: validated Media Status TLV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  378)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  379)  * This will set the carrier up on down based on the device's link
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  380)  * report. This is done asides of what the WiMAX stack does based on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  381)  * the device's state as sometimes we need to do a link-renew (the BS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  382)  * wants us to renew a DHCP lease, for example).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  383)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  384)  * In fact, doc says that every time we get a link-up, we should do a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  385)  * DHCP negotiation...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  386)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  387) static
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  388) void i2400m_report_tlv_media_status(struct i2400m *i2400m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  389) 				    const struct i2400m_tlv_media_status *ms)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  390) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  391) 	struct device *dev = i2400m_dev(i2400m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  392) 	struct wimax_dev *wimax_dev = &i2400m->wimax_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  393) 	struct net_device *net_dev = wimax_dev->net_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  394) 	enum i2400m_media_status status = le32_to_cpu(ms->media_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  395) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  396) 	d_fnstart(3, dev, "(i2400m %p ms %p [%u])\n", i2400m, ms, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  397) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  398) 	switch (status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  399) 	case I2400M_MEDIA_STATUS_LINK_UP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  400) 		netif_carrier_on(net_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  401) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  402) 	case I2400M_MEDIA_STATUS_LINK_DOWN:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  403) 		netif_carrier_off(net_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  404) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  405) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  406) 	 * This is the network telling us we need to retrain the DHCP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  407) 	 * lease -- so far, we are trusting the WiMAX Network Service
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  408) 	 * in user space to pick this up and poke the DHCP client.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  409) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  410) 	case I2400M_MEDIA_STATUS_LINK_RENEW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  411) 		netif_carrier_on(net_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  412) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  413) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  414) 		dev_err(dev, "HW BUG? unknown media status %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  415) 			status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  416) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  417) 	d_fnend(3, dev, "(i2400m %p ms %p [%u]) = void\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  418) 		i2400m, ms, status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  419) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  420) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  421) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  422) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  423)  * Process a TLV from a 'state report'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  424)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  425)  * @i2400m: device descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  426)  * @tlv: pointer to the TLV header; it has been already validated for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  427)  *     consistent size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  428)  * @tag: for error messages
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  429)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  430)  * Act on the TLVs from a 'state report'.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  431)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  432) static
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  433) void i2400m_report_state_parse_tlv(struct i2400m *i2400m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  434) 				   const struct i2400m_tlv_hdr *tlv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  435) 				   const char *tag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  436) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  437) 	struct device *dev = i2400m_dev(i2400m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  438) 	const struct i2400m_tlv_media_status *ms;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  439) 	const struct i2400m_tlv_system_state *ss;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  440) 	const struct i2400m_tlv_rf_switches_status *rfss;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  441) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  442) 	if (0 == i2400m_tlv_match(tlv, I2400M_TLV_SYSTEM_STATE, sizeof(*ss))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  443) 		ss = container_of(tlv, typeof(*ss), hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  444) 		d_printf(2, dev, "%s: system state TLV "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  445) 			 "found (0x%04x), state 0x%08x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  446) 			 tag, I2400M_TLV_SYSTEM_STATE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  447) 			 le32_to_cpu(ss->state));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  448) 		i2400m_report_tlv_system_state(i2400m, ss);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  449) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  450) 	if (0 == i2400m_tlv_match(tlv, I2400M_TLV_RF_STATUS, sizeof(*rfss))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  451) 		rfss = container_of(tlv, typeof(*rfss), hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  452) 		d_printf(2, dev, "%s: RF status TLV "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  453) 			 "found (0x%04x), sw 0x%02x hw 0x%02x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  454) 			 tag, I2400M_TLV_RF_STATUS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  455) 			 le32_to_cpu(rfss->sw_rf_switch),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  456) 			 le32_to_cpu(rfss->hw_rf_switch));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  457) 		i2400m_report_tlv_rf_switches_status(i2400m, rfss);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  458) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  459) 	if (0 == i2400m_tlv_match(tlv, I2400M_TLV_MEDIA_STATUS, sizeof(*ms))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  460) 		ms = container_of(tlv, typeof(*ms), hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  461) 		d_printf(2, dev, "%s: Media Status TLV: %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  462) 			 tag, le32_to_cpu(ms->media_status));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  463) 		i2400m_report_tlv_media_status(i2400m, ms);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  464) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  465) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  466) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  467) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  468) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  469)  * Parse a 'state report' and extract information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  470)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  471)  * @i2400m: device descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  472)  * @l3l4_hdr: pointer to message; it has been already validated for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  473)  *            consistent size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  474)  * @size: size of the message (header + payload). The header length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  475)  *        declaration is assumed to be congruent with @size (as in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  476)  *        sizeof(*l3l4_hdr) + l3l4_hdr->length == size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  477)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  478)  * Walk over the TLVs in a report state and act on them.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  479)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  480) static
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  481) void i2400m_report_state_hook(struct i2400m *i2400m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  482) 			      const struct i2400m_l3l4_hdr *l3l4_hdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  483) 			      size_t size, const char *tag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  484) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  485) 	struct device *dev = i2400m_dev(i2400m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  486) 	const struct i2400m_tlv_hdr *tlv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  487) 	size_t tlv_size = le16_to_cpu(l3l4_hdr->length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  488) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  489) 	d_fnstart(4, dev, "(i2400m %p, l3l4_hdr %p, size %zu, %s)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  490) 		  i2400m, l3l4_hdr, size, tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  491) 	tlv = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  492) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  493) 	while ((tlv = i2400m_tlv_buffer_walk(i2400m, &l3l4_hdr->pl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  494) 					     tlv_size, tlv)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  495) 		i2400m_report_state_parse_tlv(i2400m, tlv, tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  496) 	d_fnend(4, dev, "(i2400m %p, l3l4_hdr %p, size %zu, %s) = void\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  497) 		i2400m, l3l4_hdr, size, tag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  498) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  499) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  500) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  501) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  502)  * i2400m_report_hook - (maybe) act on a report
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  503)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  504)  * @i2400m: device descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  505)  * @l3l4_hdr: pointer to message; it has been already validated for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  506)  *            consistent size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  507)  * @size: size of the message (header + payload). The header length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  508)  *        declaration is assumed to be congruent with @size (as in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  509)  *        sizeof(*l3l4_hdr) + l3l4_hdr->length == size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  510)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  511)  * Extract information we might need (like carrien on/off) from a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  512)  * device report.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  513)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  514) void i2400m_report_hook(struct i2400m *i2400m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  515) 			const struct i2400m_l3l4_hdr *l3l4_hdr, size_t size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  516) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  517) 	struct device *dev = i2400m_dev(i2400m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  518) 	unsigned msg_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  519) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  520) 	d_fnstart(3, dev, "(i2400m %p l3l4_hdr %p size %zu)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  521) 		  i2400m, l3l4_hdr, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  522) 	/* Chew on the message, we might need some information from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  523) 	 * here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  524) 	msg_type = le16_to_cpu(l3l4_hdr->type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  525) 	switch (msg_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  526) 	case I2400M_MT_REPORT_STATE:	/* carrier detection... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  527) 		i2400m_report_state_hook(i2400m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  528) 					 l3l4_hdr, size, "REPORT STATE");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  529) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  530) 	/* If the device is ready for power save, then ask it to do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  531) 	 * it. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  532) 	case I2400M_MT_REPORT_POWERSAVE_READY:	/* zzzzz */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  533) 		if (l3l4_hdr->status == cpu_to_le16(I2400M_MS_DONE_OK)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  534) 			if (i2400m_power_save_disabled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  535) 				d_printf(1, dev, "ready for powersave, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  536) 					 "not requesting (disabled by module "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  537) 					 "parameter)\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  538) 			else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  539) 				d_printf(1, dev, "ready for powersave, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  540) 					 "requesting\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  541) 				i2400m_cmd_enter_powersave(i2400m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  542) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  543) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  544) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  545) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  546) 	d_fnend(3, dev, "(i2400m %p l3l4_hdr %p size %zu) = void\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  547) 		i2400m, l3l4_hdr, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  548) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  549) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  550) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  551) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  552)  * i2400m_msg_ack_hook - process cmd/set/get ack for internal status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  553)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  554)  * @i2400m: device descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  555)  * @l3l4_hdr: pointer to message; it has been already validated for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  556)  *            consistent size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  557)  * @size: size of the message
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  558)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  559)  * Extract information we might need from acks to commands and act on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  560)  * it. This is akin to i2400m_report_hook(). Note most of this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  561)  * processing should be done in the function that calls the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  562)  * command. This is here for some cases where it can't happen...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  563)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  564) static void i2400m_msg_ack_hook(struct i2400m *i2400m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  565) 				 const struct i2400m_l3l4_hdr *l3l4_hdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  566) 				 size_t size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  567) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  568) 	int result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  569) 	struct device *dev = i2400m_dev(i2400m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  570) 	unsigned int ack_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  571) 	char strerr[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  572) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  573) 	/* Chew on the message, we might need some information from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  574) 	 * here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  575) 	ack_type = le16_to_cpu(l3l4_hdr->type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  576) 	switch (ack_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  577) 	case I2400M_MT_CMD_ENTER_POWERSAVE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  578) 		/* This is just left here for the sake of example, as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  579) 		 * the processing is done somewhere else. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  580) 		if (0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  581) 			result = i2400m_msg_check_status(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  582) 				l3l4_hdr, strerr, sizeof(strerr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  583) 			if (result >= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  584) 				d_printf(1, dev, "ready for power save: %zd\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  585) 					 size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  586) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  587) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  588) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  589) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  590) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  591) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  592) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  593)  * i2400m_msg_size_check() - verify message size and header are congruent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  594)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  595)  * It is ok if the total message size is larger than the expected
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  596)  * size, as there can be padding.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  597)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  598) int i2400m_msg_size_check(struct i2400m *i2400m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  599) 			  const struct i2400m_l3l4_hdr *l3l4_hdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  600) 			  size_t msg_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  601) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  602) 	int result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  603) 	struct device *dev = i2400m_dev(i2400m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  604) 	size_t expected_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  605) 	d_fnstart(4, dev, "(i2400m %p l3l4_hdr %p msg_size %zu)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  606) 		  i2400m, l3l4_hdr, msg_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  607) 	if (msg_size < sizeof(*l3l4_hdr)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  608) 		dev_err(dev, "bad size for message header "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  609) 			"(expected at least %zu, got %zu)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  610) 			(size_t) sizeof(*l3l4_hdr), msg_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  611) 		result = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  612) 		goto error_hdr_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  613) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  614) 	expected_size = le16_to_cpu(l3l4_hdr->length) + sizeof(*l3l4_hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  615) 	if (msg_size < expected_size) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  616) 		dev_err(dev, "bad size for message code 0x%04x (expected %zu, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  617) 			"got %zu)\n", le16_to_cpu(l3l4_hdr->type),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  618) 			expected_size, msg_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  619) 		result = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  620) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  621) 		result = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  622) error_hdr_size:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  623) 	d_fnend(4, dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  624) 		"(i2400m %p l3l4_hdr %p msg_size %zu) = %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  625) 		i2400m, l3l4_hdr, msg_size, result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  626) 	return result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  627) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  628) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  629) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  630) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  631) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  632)  * Cancel a wait for a command ACK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  633)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  634)  * @i2400m: device descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  635)  * @code: [negative] errno code to cancel with (don't use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  636)  *     -EINPROGRESS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  637)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  638)  * If there is an ack already filled out, free it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  639)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  640) void i2400m_msg_to_dev_cancel_wait(struct i2400m *i2400m, int code)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  641) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  642) 	struct sk_buff *ack_skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  643) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  644) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  645) 	spin_lock_irqsave(&i2400m->rx_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  646) 	ack_skb = i2400m->ack_skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  647) 	if (ack_skb && !IS_ERR(ack_skb))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  648) 		kfree_skb(ack_skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  649) 	i2400m->ack_skb = ERR_PTR(code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  650) 	spin_unlock_irqrestore(&i2400m->rx_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  651) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  652) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  653) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  654) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  655)  * i2400m_msg_to_dev - Send a control message to the device and get a response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  656)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  657)  * @i2400m: device descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  658)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  659)  * @buf: pointer to the buffer containing the message to be sent; it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  660)  *           has to start with a &struct i2400M_l3l4_hdr and then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  661)  *           followed by the payload. Once this function returns, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  662)  *           buffer can be reused.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  663)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  664)  * @buf_len: buffer size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  665)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  666)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  667)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  668)  * Pointer to skb containing the ack message. You need to check the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  669)  * pointer with IS_ERR(), as it might be an error code. Error codes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  670)  * could happen because:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  671)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  672)  *  - the message wasn't formatted correctly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  673)  *  - couldn't send the message
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  674)  *  - failed waiting for a response
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  675)  *  - the ack message wasn't formatted correctly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  676)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  677)  * The returned skb has been allocated with wimax_msg_to_user_alloc(),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  678)  * it contains the response in a netlink attribute and is ready to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  679)  * passed up to user space with wimax_msg_to_user_send(). To access
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  680)  * the payload and its length, use wimax_msg_{data,len}() on the skb.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  681)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  682)  * The skb has to be freed with kfree_skb() once done.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  683)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  684)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  685)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  686)  * This function delivers a message/command to the device and waits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  687)  * for an ack to be received. The format is described in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  688)  * linux/wimax/i2400m.h. In summary, a command/get/set is followed by an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  689)  * ack.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  690)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  691)  * This function will not check the ack status, that's left up to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  692)  * caller.  Once done with the ack skb, it has to be kfree_skb()ed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  693)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  694)  * The i2400m handles only one message at the same time, thus we need
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  695)  * the mutex to exclude other players.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  696)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  697)  * We write the message and then wait for an answer to come back. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  698)  * RX path intercepts control messages and handles them in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  699)  * i2400m_rx_ctl(). Reports (notifications) are (maybe) processed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  700)  * locally and then forwarded (as needed) to user space on the WiMAX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  701)  * stack message pipe. Acks are saved and passed back to us through an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  702)  * skb in i2400m->ack_skb which is ready to be given to generic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  703)  * netlink if need be.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  704)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  705) struct sk_buff *i2400m_msg_to_dev(struct i2400m *i2400m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  706) 				  const void *buf, size_t buf_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  707) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  708) 	int result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  709) 	struct device *dev = i2400m_dev(i2400m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  710) 	const struct i2400m_l3l4_hdr *msg_l3l4_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  711) 	struct sk_buff *ack_skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  712) 	const struct i2400m_l3l4_hdr *ack_l3l4_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  713) 	size_t ack_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  714) 	int ack_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  715) 	unsigned msg_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  716) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  717) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  718) 	d_fnstart(3, dev, "(i2400m %p buf %p len %zu)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  719) 		  i2400m, buf, buf_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  720) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  721) 	rmb();		/* Make sure we see what i2400m_dev_reset_handle() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  722) 	if (i2400m->boot_mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  723) 		return ERR_PTR(-EL3RST);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  724) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  725) 	msg_l3l4_hdr = buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  726) 	/* Check msg & payload consistency */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  727) 	result = i2400m_msg_size_check(i2400m, msg_l3l4_hdr, buf_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  728) 	if (result < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  729) 		goto error_bad_msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  730) 	msg_type = le16_to_cpu(msg_l3l4_hdr->type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  731) 	d_printf(1, dev, "CMD/GET/SET 0x%04x %zu bytes\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  732) 		 msg_type, buf_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  733) 	d_dump(2, dev, buf, buf_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  734) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  735) 	/* Setup the completion, ack_skb ("we are waiting") and send
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  736) 	 * the message to the device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  737) 	mutex_lock(&i2400m->msg_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  738) 	spin_lock_irqsave(&i2400m->rx_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  739) 	i2400m->ack_skb = ERR_PTR(-EINPROGRESS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  740) 	spin_unlock_irqrestore(&i2400m->rx_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  741) 	init_completion(&i2400m->msg_completion);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  742) 	result = i2400m_tx(i2400m, buf, buf_len, I2400M_PT_CTRL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  743) 	if (result < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  744) 		dev_err(dev, "can't send message 0x%04x: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  745) 			le16_to_cpu(msg_l3l4_hdr->type), result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  746) 		goto error_tx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  747) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  748) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  749) 	/* Some commands take longer to execute because of crypto ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  750) 	 * so we give them some more leeway on timeout */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  751) 	switch (msg_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  752) 	case I2400M_MT_GET_TLS_OPERATION_RESULT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  753) 	case I2400M_MT_CMD_SEND_EAP_RESPONSE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  754) 		ack_timeout = 5 * HZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  755) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  756) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  757) 		ack_timeout = HZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  758) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  759) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  760) 	if (unlikely(i2400m->trace_msg_from_user))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  761) 		wimax_msg(&i2400m->wimax_dev, "echo", buf, buf_len, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  762) 	/* The RX path in rx.c will put any response for this message
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  763) 	 * in i2400m->ack_skb and wake us up. If we cancel the wait,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  764) 	 * we need to change the value of i2400m->ack_skb to something
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  765) 	 * not -EINPROGRESS so RX knows there is no one waiting. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  766) 	result = wait_for_completion_interruptible_timeout(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  767) 		&i2400m->msg_completion, ack_timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  768) 	if (result == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  769) 		dev_err(dev, "timeout waiting for reply to message 0x%04x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  770) 			msg_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  771) 		result = -ETIMEDOUT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  772) 		i2400m_msg_to_dev_cancel_wait(i2400m, result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  773) 		goto error_wait_for_completion;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  774) 	} else if (result < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  775) 		dev_err(dev, "error waiting for reply to message 0x%04x: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  776) 			msg_type, result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  777) 		i2400m_msg_to_dev_cancel_wait(i2400m, result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  778) 		goto error_wait_for_completion;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  779) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  780) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  781) 	/* Pull out the ack data from i2400m->ack_skb -- see if it is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  782) 	 * an error and act accordingly */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  783) 	spin_lock_irqsave(&i2400m->rx_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  784) 	ack_skb = i2400m->ack_skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  785) 	if (IS_ERR(ack_skb))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  786) 		result = PTR_ERR(ack_skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  787) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  788) 		result = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  789) 	i2400m->ack_skb = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  790) 	spin_unlock_irqrestore(&i2400m->rx_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  791) 	if (result < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  792) 		goto error_ack_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  793) 	ack_l3l4_hdr = wimax_msg_data_len(ack_skb, &ack_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  794) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  795) 	/* Check the ack and deliver it if it is ok */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  796) 	if (unlikely(i2400m->trace_msg_from_user))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  797) 		wimax_msg(&i2400m->wimax_dev, "echo",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  798) 			  ack_l3l4_hdr, ack_len, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  799) 	result = i2400m_msg_size_check(i2400m, ack_l3l4_hdr, ack_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  800) 	if (result < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  801) 		dev_err(dev, "HW BUG? reply to message 0x%04x: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  802) 			msg_type, result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  803) 		goto error_bad_ack_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  804) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  805) 	if (msg_type != le16_to_cpu(ack_l3l4_hdr->type)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  806) 		dev_err(dev, "HW BUG? bad reply 0x%04x to message 0x%04x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  807) 			le16_to_cpu(ack_l3l4_hdr->type), msg_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  808) 		result = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  809) 		goto error_bad_ack_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  810) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  811) 	i2400m_msg_ack_hook(i2400m, ack_l3l4_hdr, ack_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  812) 	mutex_unlock(&i2400m->msg_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  813) 	d_fnend(3, dev, "(i2400m %p buf %p len %zu) = %p\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  814) 		i2400m, buf, buf_len, ack_skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  815) 	return ack_skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  816) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  817) error_bad_ack_type:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  818) error_bad_ack_len:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  819) 	kfree_skb(ack_skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  820) error_ack_status:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  821) error_wait_for_completion:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  822) error_tx:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  823) 	mutex_unlock(&i2400m->msg_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  824) error_bad_msg:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  825) 	d_fnend(3, dev, "(i2400m %p buf %p len %zu) = %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  826) 		i2400m, buf, buf_len, result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  827) 	return ERR_PTR(result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  828) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  829) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  830) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  831) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  832)  * Definitions for the Enter Power Save command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  833)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  834)  * The Enter Power Save command requests the device to go into power
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  835)  * saving mode. The device will ack or nak the command depending on it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  836)  * being ready for it. If it acks, we tell the USB subsystem to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  837)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  838)  * As well, the device might request to go into power saving mode by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  839)  * sending a report (REPORT_POWERSAVE_READY), in which case, we issue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  840)  * this command. The hookups in the RX coder allow
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  841)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  842) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  843) 	I2400M_WAKEUP_ENABLED  = 0x01,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  844) 	I2400M_WAKEUP_DISABLED = 0x02,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  845) 	I2400M_TLV_TYPE_WAKEUP_MODE = 144,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  846) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  847) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  848) struct i2400m_cmd_enter_power_save {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  849) 	struct i2400m_l3l4_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  850) 	struct i2400m_tlv_hdr tlv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  851) 	__le32 val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  852) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  853) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  854) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  855) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  856)  * Request entering power save
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  857)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  858)  * This command is (mainly) executed when the device indicates that it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  859)  * is ready to go into powersave mode via a REPORT_POWERSAVE_READY.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  860)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  861) int i2400m_cmd_enter_powersave(struct i2400m *i2400m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  862) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  863) 	int result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  864) 	struct device *dev = i2400m_dev(i2400m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  865) 	struct sk_buff *ack_skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  866) 	struct i2400m_cmd_enter_power_save *cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  867) 	char strerr[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  868) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  869) 	result = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  870) 	cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  871) 	if (cmd == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  872) 		goto error_alloc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  873) 	cmd->hdr.type = cpu_to_le16(I2400M_MT_CMD_ENTER_POWERSAVE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  874) 	cmd->hdr.length = cpu_to_le16(sizeof(*cmd) - sizeof(cmd->hdr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  875) 	cmd->hdr.version = cpu_to_le16(I2400M_L3L4_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  876) 	cmd->tlv.type = cpu_to_le16(I2400M_TLV_TYPE_WAKEUP_MODE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  877) 	cmd->tlv.length = cpu_to_le16(sizeof(cmd->val));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  878) 	cmd->val = cpu_to_le32(I2400M_WAKEUP_ENABLED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  879) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  880) 	ack_skb = i2400m_msg_to_dev(i2400m, cmd, sizeof(*cmd));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  881) 	result = PTR_ERR(ack_skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  882) 	if (IS_ERR(ack_skb)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  883) 		dev_err(dev, "Failed to issue 'Enter power save' command: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  884) 			result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  885) 		goto error_msg_to_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  886) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  887) 	result = i2400m_msg_check_status(wimax_msg_data(ack_skb),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  888) 					 strerr, sizeof(strerr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  889) 	if (result == -EACCES)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  890) 		d_printf(1, dev, "Cannot enter power save mode\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  891) 	else if (result < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  892) 		dev_err(dev, "'Enter power save' (0x%04x) command failed: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  893) 			"%d - %s\n", I2400M_MT_CMD_ENTER_POWERSAVE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  894) 			result, strerr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  895) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  896) 		d_printf(1, dev, "device ready to power save\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  897) 	kfree_skb(ack_skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  898) error_msg_to_dev:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  899) 	kfree(cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  900) error_alloc:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  901) 	return result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  902) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  903) EXPORT_SYMBOL_GPL(i2400m_cmd_enter_powersave);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  904) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  905) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  906) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  907)  * Definitions for getting device information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  908)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  909) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  910) 	I2400M_TLV_DETAILED_DEVICE_INFO = 140
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  911) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  912) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  913) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  914)  * i2400m_get_device_info - Query the device for detailed device information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  915)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  916)  * @i2400m: device descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  917)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  918)  * Returns: an skb whose skb->data points to a 'struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  919)  *    i2400m_tlv_detailed_device_info'. When done, kfree_skb() it. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  920)  *    skb is *guaranteed* to contain the whole TLV data structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  921)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  922)  *    On error, IS_ERR(skb) is true and ERR_PTR(skb) is the error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  923)  *    code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  924)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  925) struct sk_buff *i2400m_get_device_info(struct i2400m *i2400m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  926) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  927) 	int result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  928) 	struct device *dev = i2400m_dev(i2400m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  929) 	struct sk_buff *ack_skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  930) 	struct i2400m_l3l4_hdr *cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  931) 	const struct i2400m_l3l4_hdr *ack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  932) 	size_t ack_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  933) 	const struct i2400m_tlv_hdr *tlv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  934) 	const struct i2400m_tlv_detailed_device_info *ddi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  935) 	char strerr[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  936) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  937) 	ack_skb = ERR_PTR(-ENOMEM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  938) 	cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  939) 	if (cmd == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  940) 		goto error_alloc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  941) 	cmd->type = cpu_to_le16(I2400M_MT_GET_DEVICE_INFO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  942) 	cmd->length = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  943) 	cmd->version = cpu_to_le16(I2400M_L3L4_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  944) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  945) 	ack_skb = i2400m_msg_to_dev(i2400m, cmd, sizeof(*cmd));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  946) 	if (IS_ERR(ack_skb)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  947) 		dev_err(dev, "Failed to issue 'get device info' command: %ld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  948) 			PTR_ERR(ack_skb));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  949) 		goto error_msg_to_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  950) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  951) 	ack = wimax_msg_data_len(ack_skb, &ack_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  952) 	result = i2400m_msg_check_status(ack, strerr, sizeof(strerr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  953) 	if (result < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  954) 		dev_err(dev, "'get device info' (0x%04x) command failed: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  955) 			"%d - %s\n", I2400M_MT_GET_DEVICE_INFO, result,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  956) 			strerr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  957) 		goto error_cmd_failed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  958) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  959) 	tlv = i2400m_tlv_find(i2400m, ack->pl, ack_len - sizeof(*ack),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  960) 			      I2400M_TLV_DETAILED_DEVICE_INFO, sizeof(*ddi));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  961) 	if (tlv == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  962) 		dev_err(dev, "GET DEVICE INFO: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  963) 			"detailed device info TLV not found (0x%04x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  964) 			I2400M_TLV_DETAILED_DEVICE_INFO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  965) 		result = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  966) 		goto error_no_tlv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  967) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  968) 	skb_pull(ack_skb, (void *) tlv - (void *) ack_skb->data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  969) error_msg_to_dev:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  970) 	kfree(cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  971) error_alloc:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  972) 	return ack_skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  973) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  974) error_no_tlv:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  975) error_cmd_failed:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  976) 	kfree_skb(ack_skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  977) 	kfree(cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  978) 	return ERR_PTR(result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  979) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  980) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  981) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  982) /* Firmware interface versions we support */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  983) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  984) 	I2400M_HDIv_MAJOR = 9,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  985) 	I2400M_HDIv_MINOR = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  986) 	I2400M_HDIv_MINOR_2 = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  987) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  988) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  989) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  990) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  991)  * i2400m_firmware_check - check firmware versions are compatible with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  992)  * the driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  993)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  994)  * @i2400m: device descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  995)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  996)  * Returns: 0 if ok, < 0 errno code an error and a message in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  997)  *    kernel log.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  998)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  999)  * Long function, but quite simple; first chunk launches the command
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000)  * and double checks the reply for the right TLV. Then we process the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001)  * TLV (where the meat is).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003)  * Once we process the TLV that gives us the firmware's interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004)  * version, we encode it and save it in i2400m->fw_version for future
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005)  * reference.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) int i2400m_firmware_check(struct i2400m *i2400m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) 	int result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) 	struct device *dev = i2400m_dev(i2400m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) 	struct sk_buff *ack_skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) 	struct i2400m_l3l4_hdr *cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) 	const struct i2400m_l3l4_hdr *ack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) 	size_t ack_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) 	const struct i2400m_tlv_hdr *tlv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) 	const struct i2400m_tlv_l4_message_versions *l4mv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) 	char strerr[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) 	unsigned major, minor, branch;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) 	result = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) 	cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) 	if (cmd == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) 		goto error_alloc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) 	cmd->type = cpu_to_le16(I2400M_MT_GET_LM_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) 	cmd->length = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) 	cmd->version = cpu_to_le16(I2400M_L3L4_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) 	ack_skb = i2400m_msg_to_dev(i2400m, cmd, sizeof(*cmd));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) 	if (IS_ERR(ack_skb)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) 		result = PTR_ERR(ack_skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) 		dev_err(dev, "Failed to issue 'get lm version' command: %-d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) 			result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) 		goto error_msg_to_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) 	ack = wimax_msg_data_len(ack_skb, &ack_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) 	result = i2400m_msg_check_status(ack, strerr, sizeof(strerr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) 	if (result < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) 		dev_err(dev, "'get lm version' (0x%04x) command failed: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) 			"%d - %s\n", I2400M_MT_GET_LM_VERSION, result,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) 			strerr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) 		goto error_cmd_failed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) 	tlv = i2400m_tlv_find(i2400m, ack->pl, ack_len - sizeof(*ack),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) 			      I2400M_TLV_L4_MESSAGE_VERSIONS, sizeof(*l4mv));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) 	if (tlv == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) 		dev_err(dev, "get lm version: TLV not found (0x%04x)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) 			I2400M_TLV_L4_MESSAGE_VERSIONS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) 		result = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) 		goto error_no_tlv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) 	l4mv = container_of(tlv, typeof(*l4mv), hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) 	major = le16_to_cpu(l4mv->major);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) 	minor = le16_to_cpu(l4mv->minor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) 	branch = le16_to_cpu(l4mv->branch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) 	result = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) 	if (major != I2400M_HDIv_MAJOR) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) 		dev_err(dev, "unsupported major fw version "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) 			"%u.%u.%u\n", major, minor, branch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) 		goto error_bad_major;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) 	result = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) 	if (minor > I2400M_HDIv_MINOR_2 || minor < I2400M_HDIv_MINOR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) 		dev_warn(dev, "untested minor fw version %u.%u.%u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) 			 major, minor, branch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) 	/* Yes, we ignore the branch -- we don't have to track it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) 	i2400m->fw_version = major << 16 | minor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) 	dev_info(dev, "firmware interface version %u.%u.%u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) 		 major, minor, branch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) error_bad_major:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) error_no_tlv:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) error_cmd_failed:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) 	kfree_skb(ack_skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) error_msg_to_dev:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) 	kfree(cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) error_alloc:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) 	return result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081)  * Send an DoExitIdle command to the device to ask it to go out of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082)  * basestation-idle mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084)  * @i2400m: device descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086)  * This starts a renegotiation with the basestation that might involve
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087)  * another crypto handshake with user space.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089)  * Returns: 0 if ok, < 0 errno code on error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) int i2400m_cmd_exit_idle(struct i2400m *i2400m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) 	int result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) 	struct device *dev = i2400m_dev(i2400m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) 	struct sk_buff *ack_skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) 	struct i2400m_l3l4_hdr *cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) 	char strerr[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) 	result = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) 	cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) 	if (cmd == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) 		goto error_alloc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) 	cmd->type = cpu_to_le16(I2400M_MT_CMD_EXIT_IDLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) 	cmd->length = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) 	cmd->version = cpu_to_le16(I2400M_L3L4_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) 	ack_skb = i2400m_msg_to_dev(i2400m, cmd, sizeof(*cmd));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) 	result = PTR_ERR(ack_skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) 	if (IS_ERR(ack_skb)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) 		dev_err(dev, "Failed to issue 'exit idle' command: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) 			result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) 		goto error_msg_to_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) 	result = i2400m_msg_check_status(wimax_msg_data(ack_skb),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) 					 strerr, sizeof(strerr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) 	kfree_skb(ack_skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) error_msg_to_dev:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) 	kfree(cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) error_alloc:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) 	return result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126)  * Query the device for its state, update the WiMAX stack's idea of it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128)  * @i2400m: device descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130)  * Returns: 0 if ok, < 0 errno code on error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132)  * Executes a 'Get State' command and parses the returned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133)  * TLVs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135)  * Because this is almost identical to a 'Report State', we use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136)  * i2400m_report_state_hook() to parse the answer. This will set the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137)  * carrier state, as well as the RF Kill switches state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) static int i2400m_cmd_get_state(struct i2400m *i2400m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) 	int result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) 	struct device *dev = i2400m_dev(i2400m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) 	struct sk_buff *ack_skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) 	struct i2400m_l3l4_hdr *cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) 	const struct i2400m_l3l4_hdr *ack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) 	size_t ack_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) 	char strerr[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) 	result = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) 	cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) 	if (cmd == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) 		goto error_alloc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) 	cmd->type = cpu_to_le16(I2400M_MT_GET_STATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) 	cmd->length = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) 	cmd->version = cpu_to_le16(I2400M_L3L4_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) 	ack_skb = i2400m_msg_to_dev(i2400m, cmd, sizeof(*cmd));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) 	if (IS_ERR(ack_skb)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) 		dev_err(dev, "Failed to issue 'get state' command: %ld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) 			PTR_ERR(ack_skb));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) 		result = PTR_ERR(ack_skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) 		goto error_msg_to_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) 	ack = wimax_msg_data_len(ack_skb, &ack_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) 	result = i2400m_msg_check_status(ack, strerr, sizeof(strerr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) 	if (result < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) 		dev_err(dev, "'get state' (0x%04x) command failed: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) 			"%d - %s\n", I2400M_MT_GET_STATE, result, strerr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) 		goto error_cmd_failed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) 	i2400m_report_state_hook(i2400m, ack, ack_len - sizeof(*ack),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) 				 "GET STATE");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) 	result = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) 	kfree_skb(ack_skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) error_cmd_failed:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) error_msg_to_dev:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) 	kfree(cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) error_alloc:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) 	return result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183)  * Set basic configuration settings
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185)  * @i2400m: device descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186)  * @args: array of pointers to the TLV headers to send for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187)  *     configuration (each followed by its payload).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188)  *     TLV headers and payloads must be properly initialized, with the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189)  *     right endianess (LE).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190)  * @arg_size: number of pointers in the @args array
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) static int i2400m_set_init_config(struct i2400m *i2400m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) 				  const struct i2400m_tlv_hdr **arg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) 				  size_t args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) 	int result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) 	struct device *dev = i2400m_dev(i2400m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) 	struct sk_buff *ack_skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) 	struct i2400m_l3l4_hdr *cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) 	char strerr[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) 	unsigned argc, argsize, tlv_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) 	const struct i2400m_tlv_hdr *tlv_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) 	void *buf, *itr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) 	d_fnstart(3, dev, "(i2400m %p arg %p args %zu)\n", i2400m, arg, args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) 	result = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) 	if (args == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) 		goto none;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) 	/* Compute the size of all the TLVs, so we can alloc a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) 	 * contiguous command block to copy them. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) 	argsize = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) 	for (argc = 0; argc < args; argc++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) 		tlv_hdr = arg[argc];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) 		argsize += sizeof(*tlv_hdr) + le16_to_cpu(tlv_hdr->length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) 	WARN_ON(argc >= 9);	/* As per hw spec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) 	/* Alloc the space for the command and TLVs*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) 	result = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) 	buf = kzalloc(sizeof(*cmd) + argsize, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) 	if (buf == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) 		goto error_alloc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) 	cmd = buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) 	cmd->type = cpu_to_le16(I2400M_MT_SET_INIT_CONFIG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) 	cmd->length = cpu_to_le16(argsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) 	cmd->version = cpu_to_le16(I2400M_L3L4_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) 	/* Copy the TLVs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) 	itr = buf + sizeof(*cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) 	for (argc = 0; argc < args; argc++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) 		tlv_hdr = arg[argc];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) 		tlv_size = sizeof(*tlv_hdr) + le16_to_cpu(tlv_hdr->length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) 		memcpy(itr, tlv_hdr, tlv_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) 		itr += tlv_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) 	/* Send the message! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) 	ack_skb = i2400m_msg_to_dev(i2400m, buf, sizeof(*cmd) + argsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) 	result = PTR_ERR(ack_skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) 	if (IS_ERR(ack_skb)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) 		dev_err(dev, "Failed to issue 'init config' command: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) 			result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) 		goto error_msg_to_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) 	result = i2400m_msg_check_status(wimax_msg_data(ack_skb),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) 					 strerr, sizeof(strerr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) 	if (result < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) 		dev_err(dev, "'init config' (0x%04x) command failed: %d - %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) 			I2400M_MT_SET_INIT_CONFIG, result, strerr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) 	kfree_skb(ack_skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) error_msg_to_dev:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) 	kfree(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) error_alloc:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) none:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) 	d_fnend(3, dev, "(i2400m %p arg %p args %zu) = %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) 		i2400m, arg, args, result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) 	return result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263)  * i2400m_set_idle_timeout - Set the device's idle mode timeout
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265)  * @i2400m: i2400m device descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267)  * @msecs: milliseconds for the timeout to enter idle mode. Between
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268)  *     100 to 300000 (5m); 0 to disable. In increments of 100.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270)  * After this @msecs of the link being idle (no data being sent or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271)  * received), the device will negotiate with the basestation entering
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272)  * idle mode for saving power. The connection is maintained, but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273)  * getting out of it (done in tx.c) will require some negotiation,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274)  * possible crypto re-handshake and a possible DHCP re-lease.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276)  * Only available if fw_version >= 0x00090002.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278)  * Returns: 0 if ok, < 0 errno code on error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) int i2400m_set_idle_timeout(struct i2400m *i2400m, unsigned msecs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) 	int result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) 	struct device *dev = i2400m_dev(i2400m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) 	struct sk_buff *ack_skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) 	struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) 		struct i2400m_l3l4_hdr hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) 		struct i2400m_tlv_config_idle_timeout cit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) 	} *cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) 	const struct i2400m_l3l4_hdr *ack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) 	size_t ack_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) 	char strerr[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) 	result = -ENOSYS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) 	if (i2400m_le_v1_3(i2400m))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) 		goto error_alloc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) 	result = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) 	cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) 	if (cmd == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) 		goto error_alloc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) 	cmd->hdr.type = cpu_to_le16(I2400M_MT_GET_STATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) 	cmd->hdr.length = cpu_to_le16(sizeof(*cmd) - sizeof(cmd->hdr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) 	cmd->hdr.version = cpu_to_le16(I2400M_L3L4_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) 	cmd->cit.hdr.type =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) 		cpu_to_le16(I2400M_TLV_CONFIG_IDLE_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) 	cmd->cit.hdr.length = cpu_to_le16(sizeof(cmd->cit.timeout));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) 	cmd->cit.timeout = cpu_to_le32(msecs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) 	ack_skb = i2400m_msg_to_dev(i2400m, cmd, sizeof(*cmd));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) 	if (IS_ERR(ack_skb)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311) 		dev_err(dev, "Failed to issue 'set idle timeout' command: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) 			"%ld\n", PTR_ERR(ack_skb));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) 		result = PTR_ERR(ack_skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) 		goto error_msg_to_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) 	ack = wimax_msg_data_len(ack_skb, &ack_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) 	result = i2400m_msg_check_status(ack, strerr, sizeof(strerr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) 	if (result < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) 		dev_err(dev, "'set idle timeout' (0x%04x) command failed: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) 			"%d - %s\n", I2400M_MT_GET_STATE, result, strerr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321) 		goto error_cmd_failed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) 	result = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) 	kfree_skb(ack_skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) error_cmd_failed:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) error_msg_to_dev:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) 	kfree(cmd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) error_alloc:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) 	return result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334)  * i2400m_dev_initialize - Initialize the device once communications are ready
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336)  * @i2400m: device descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338)  * Returns: 0 if ok, < 0 errno code on error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340)  * Configures the device to work the way we like it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342)  * At the point of this call, the device is registered with the WiMAX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343)  * and netdev stacks, firmware is uploaded and we can talk to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344)  * device normally.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) int i2400m_dev_initialize(struct i2400m *i2400m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) 	int result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) 	struct device *dev = i2400m_dev(i2400m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) 	struct i2400m_tlv_config_idle_parameters idle_params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) 	struct i2400m_tlv_config_idle_timeout idle_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) 	struct i2400m_tlv_config_d2h_data_format df;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353) 	struct i2400m_tlv_config_dl_host_reorder dlhr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) 	const struct i2400m_tlv_hdr *args[9];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) 	unsigned argc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) 	d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) 	if (i2400m_passive_mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) 		goto out_passive;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) 	/* Disable idle mode? (enabled by default) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) 	if (i2400m_idle_mode_disabled) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) 		if (i2400m_le_v1_3(i2400m)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) 			idle_params.hdr.type =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) 				cpu_to_le16(I2400M_TLV_CONFIG_IDLE_PARAMETERS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365) 			idle_params.hdr.length = cpu_to_le16(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) 				sizeof(idle_params) - sizeof(idle_params.hdr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) 			idle_params.idle_timeout = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) 			idle_params.idle_paging_interval = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) 			args[argc++] = &idle_params.hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) 			idle_timeout.hdr.type =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) 				cpu_to_le16(I2400M_TLV_CONFIG_IDLE_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) 			idle_timeout.hdr.length = cpu_to_le16(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) 				sizeof(idle_timeout) - sizeof(idle_timeout.hdr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) 			idle_timeout.timeout = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) 			args[argc++] = &idle_timeout.hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) 	if (i2400m_ge_v1_4(i2400m)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380) 		/* Enable extended RX data format? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381) 		df.hdr.type =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) 			cpu_to_le16(I2400M_TLV_CONFIG_D2H_DATA_FORMAT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) 		df.hdr.length = cpu_to_le16(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) 			sizeof(df) - sizeof(df.hdr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) 		df.format = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) 		args[argc++] = &df.hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388) 		/* Enable RX data reordering?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) 		 * (switch flipped in rx.c:i2400m_rx_setup() after fw upload) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) 		if (i2400m->rx_reorder) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) 			dlhr.hdr.type =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) 				cpu_to_le16(I2400M_TLV_CONFIG_DL_HOST_REORDER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) 			dlhr.hdr.length = cpu_to_le16(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394) 				sizeof(dlhr) - sizeof(dlhr.hdr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) 			dlhr.reorder = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) 			args[argc++] = &dlhr.hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399) 	result = i2400m_set_init_config(i2400m, args, argc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) 	if (result < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) 		goto error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) out_passive:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) 	 * Update state: Here it just calls a get state; parsing the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405) 	 * result (System State TLV and RF Status TLV [done in the rx
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406) 	 * path hooks]) will set the hardware and software RF-Kill
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407) 	 * status.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) 	result = i2400m_cmd_get_state(i2400m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) error:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) 	if (result < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) 		dev_err(dev, "failed to initialize the device: %d\n", result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) 	d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) 	return result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419)  * i2400m_dev_shutdown - Shutdown a running device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421)  * @i2400m: device descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423)  * Release resources acquired during the running of the device; in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424)  * theory, should also tell the device to go to sleep, switch off the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425)  * radio, all that, but at this point, in most cases (driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426)  * disconnection, reset handling) we can't even talk to the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) void i2400m_dev_shutdown(struct i2400m *i2400m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430) 	struct device *dev = i2400m_dev(i2400m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432) 	d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433) 	d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) }