^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) * Declarations for bus-generic internal APIs
^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) * Yanir Lubetkin <yanirx.lubetkin@intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * - Initial implementation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * GENERAL DRIVER ARCHITECTURE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * The i2400m driver is split in the following two major parts:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) * - bus specific driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) * - bus generic driver (this part)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) * The bus specific driver sets up stuff specific to the bus the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * device is connected to (USB, PCI, tam-tam...non-authoritative
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) * nor binding list) which is basically the device-model management
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * (probe/disconnect, etc), moving data from device to kernel and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * back, doing the power saving details and reseting the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) * For details on each bus-specific driver, see it's include file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) * i2400m-BUSNAME.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) * The bus-generic functionality break up is:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) * - Firmware upload: fw.c - takes care of uploading firmware to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) * device. bus-specific driver just needs to provides a way to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) * execute boot-mode commands and to reset the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) * - RX handling: rx.c - receives data from the bus-specific code and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * feeds it to the network or WiMAX stack or uses it to modify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) * the driver state. bus-specific driver only has to receive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) * frames and pass them to this module.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) * - TX handling: tx.c - manages the TX FIFO queue and provides means
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) * for the bus-specific TX code to pull data from the FIFO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) * queue. bus-specific code just pulls frames from this module
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) * to sends them to the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) * - netdev glue: netdev.c - interface with Linux networking
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) * stack. Pass around data frames, and configure when the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) * device is up and running or shutdown (through ifconfig up /
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) * down). Bus-generic only.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) * - control ops: control.c - implements various commands for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) * controlling the device. bus-generic only.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) * - device model glue: driver.c - implements helpers for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) * device-model glue done by the bus-specific layer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) * (setup/release the driver resources), turning the device on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) * and off, handling the device reboots/resets and a few simple
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) * WiMAX stack ops.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) * Code is also broken up in linux-glue / device-glue.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) * Linux glue contains functions that deal mostly with gluing with the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) * rest of the Linux kernel.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) * Device-glue are functions that deal mostly with the way the device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) * does things and talk the device's language.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) * device-glue code is licensed BSD so other open source OSes can take
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) * it to implement their drivers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) * APIs AND HEADER FILES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) * This bus generic code exports three APIs:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) * - HDI (host-device interface) definitions common to all busses
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) * (include/linux/wimax/i2400m.h); these can be also used by user
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) * space code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) * - internal API for the bus-generic code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) * - external API for the bus-specific drivers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) * LIFE CYCLE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) * When the bus-specific driver probes, it allocates a network device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) * with enough space for it's data structue, that must contain a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) * &struct i2400m at the top.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) * On probe, it needs to fill the i2400m members marked as [fill], as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) * well as i2400m->wimax_dev.net_dev and call i2400m_setup(). The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) * i2400m driver will only register with the WiMAX and network stacks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) * the only access done to the device is to read the MAC address so we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) * can register a network device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) * The high-level call flow is:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) * bus_probe()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) * i2400m_setup()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) * i2400m->bus_setup()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) * boot rom initialization / read mac addr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) * network / WiMAX stacks registration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) * i2400m_dev_start()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) * i2400m->bus_dev_start()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) * i2400m_dev_initialize()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) * The reverse applies for a disconnect() call:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) * bus_disconnect()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) * i2400m_release()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) * i2400m_dev_stop()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) * i2400m_dev_shutdown()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) * i2400m->bus_dev_stop()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) * network / WiMAX stack unregistration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) * i2400m->bus_release()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) * At this point, control and data communications are possible.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) * While the device is up, it might reset. The bus-specific driver has
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) * to catch that situation and call i2400m_dev_reset_handle() to deal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) * with it (reset the internal driver structures and go back to square
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) * one).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) #ifndef __I2400M_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) #define __I2400M_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) #include <linux/usb.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) #include <linux/netdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) #include <linux/completion.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) #include <linux/rwsem.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) #include <linux/atomic.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) #include <net/wimax.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) #include <linux/wimax/i2400m.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) #include <asm/byteorder.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) /* netdev interface */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) * Out of NWG spec (R1_v1.2.2), 3.3.3 ASN Bearer Plane MTU Size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) * The MTU is 1400 or less
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) I2400M_MAX_MTU = 1400,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) /* Misc constants */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) /* Size of the Boot Mode Command buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) I2400M_BM_CMD_BUF_SIZE = 16 * 1024,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) I2400M_BM_ACK_BUF_SIZE = 256,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) /* Maximum number of bus reset can be retried */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) I2400M_BUS_RESET_RETRIES = 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) * struct i2400m_poke_table - Hardware poke table for the Intel 2400m
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) * This structure will be used to create a device specific poke table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) * to put the device in a consistent state at boot time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) * @address: The device address to poke
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) * @data: The data value to poke to the device address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) struct i2400m_poke_table{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) __le32 address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) __le32 data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) #define I2400M_FW_POKE(a, d) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) .address = cpu_to_le32(a), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) .data = cpu_to_le32(d) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) }
^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) * i2400m_reset_type - methods to reset a device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) * @I2400M_RT_WARM: Reset without device disconnection, device handles
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) * are kept valid but state is back to power on, with firmware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) * re-uploaded.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) * @I2400M_RT_COLD: Tell the device to disconnect itself from the bus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) * and reconnect. Renders all device handles invalid.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) * @I2400M_RT_BUS: Tells the bus to reset the device; last measure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) * used when both types above don't work.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) enum i2400m_reset_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) I2400M_RT_WARM, /* first measure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) I2400M_RT_COLD, /* second measure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) I2400M_RT_BUS, /* call in artillery */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) struct i2400m_reset_ctx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) struct i2400m_roq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) struct i2400m_barker_db;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) * struct i2400m - descriptor for an Intel 2400m
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) * Members marked with [fill] must be filled out/initialized before
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) * calling i2400m_setup().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) * Note the @bus_setup/@bus_release, @bus_dev_start/@bus_dev_release
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) * call pairs are very much doing almost the same, and depending on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) * the underlying bus, some stuff has to be put in one or the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) * other. The idea of setup/release is that they setup the minimal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) * amount needed for loading firmware, where us dev_start/stop setup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) * the rest needed to do full data/control traffic.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) * @bus_tx_block_size: [fill] USB imposes a 16 block size, but other
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) * busses will differ. So we have a tx_blk_size variable that the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) * bus layer sets to tell the engine how much of that we need.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) * @bus_tx_room_min: [fill] Minimum room required while allocating
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) * TX queue's buffer space for message header. USB requires
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) * 16 bytes. Refer to bus specific driver code for details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) * @bus_pl_size_max: [fill] Maximum payload size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) * @bus_setup: [optional fill] Function called by the bus-generic code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) * [i2400m_setup()] to setup the basic bus-specific communications
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) * to the the device needed to load firmware. See LIFE CYCLE above.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) * NOTE: Doesn't need to upload the firmware, as that is taken
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) * care of by the bus-generic code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) * @bus_release: [optional fill] Function called by the bus-generic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) * code [i2400m_release()] to shutdown the basic bus-specific
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) * communications to the the device needed to load firmware. See
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) * LIFE CYCLE above.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) * This function does not need to reset the device, just tear down
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) * all the host resources created to handle communication with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) * the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) * @bus_dev_start: [optional fill] Function called by the bus-generic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) * code [i2400m_dev_start()] to do things needed to start the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) * device. See LIFE CYCLE above.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) * NOTE: Doesn't need to upload the firmware, as that is taken
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) * care of by the bus-generic code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) * @bus_dev_stop: [optional fill] Function called by the bus-generic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) * code [i2400m_dev_stop()] to do things needed for stopping the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) * device. See LIFE CYCLE above.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) * This function does not need to reset the device, just tear down
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) * all the host resources created to handle communication with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) * the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) * @bus_tx_kick: [fill] Function called by the bus-generic code to let
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) * the bus-specific code know that there is data available in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) * TX FIFO for transmission to the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) * This function cannot sleep.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) * @bus_reset: [fill] Function called by the bus-generic code to reset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) * the device in in various ways. Doesn't need to wait for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) * reset to finish.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) * If warm or cold reset fail, this function is expected to do a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) * bus-specific reset (eg: USB reset) to get the device to a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) * working state (even if it implies device disconecction).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) * Note the warm reset is used by the firmware uploader to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) * reinitialize the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) * IMPORTANT: this is called very early in the device setup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) * process, so it cannot rely on common infrastructure being laid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) * out.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) * IMPORTANT: don't call reset on RT_BUS with i2400m->init_mutex
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) * held, as the .pre/.post reset handlers will deadlock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) * @bus_bm_retries: [fill] How many times shall a firmware upload /
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) * device initialization be retried? Different models of the same
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) * device might need different values, hence it is set by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) * bus-specific driver. Note this value is used in two places,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) * i2400m_fw_dnload() and __i2400m_dev_start(); they won't become
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) * multiplicative (__i2400m_dev_start() calling N times
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) * i2400m_fw_dnload() and this trying N times to download the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) * firmware), as if __i2400m_dev_start() only retries if the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) * firmware crashed while initializing the device (not in a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) * general case).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) * @bus_bm_cmd_send: [fill] Function called to send a boot-mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) * command. Flags are defined in 'enum i2400m_bm_cmd_flags'. This
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) * is synchronous and has to return 0 if ok or < 0 errno code in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) * any error condition.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) * @bus_bm_wait_for_ack: [fill] Function called to wait for a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) * boot-mode notification (that can be a response to a previously
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) * issued command or an asynchronous one). Will read until all the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) * indicated size is read or timeout. Reading more or less data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) * than asked for is an error condition. Return 0 if ok, < 0 errno
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) * code on error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) * The caller to this function will check if the response is a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) * barker that indicates the device going into reset mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) * @bus_fw_names: [fill] a NULL-terminated array with the names of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) * firmware images to try loading. This is made a list so we can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) * support backward compatibility of firmware releases (eg: if we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) * can't find the default v1.4, we try v1.3). In general, the name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) * should be i2400m-fw-X-VERSION.sbcf, where X is the bus name.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) * The list is tried in order and the first one that loads is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) * used. The fw loader will set i2400m->fw_name to point to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) * active firmware image.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) * @bus_bm_mac_addr_impaired: [fill] Set to true if the device's MAC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) * address provided in boot mode is kind of broken and needs to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) * be re-read later on.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) * @bus_bm_pokes_table: [fill/optional] A table of device addresses
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) * and values that will be poked at device init time to move the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) * device to the correct state for the type of boot/firmware being
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) * used. This table MUST be terminated with (0x000000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) * 0x00000000) or bad things will happen.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) * @wimax_dev: WiMAX generic device for linkage into the kernel WiMAX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) * stack. Due to the way a net_device is allocated, we need to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) * force this to be the first field so that we can get from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) * netdev_priv() the right pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) * @updown: the device is up and ready for transmitting control and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) * data packets. This implies @ready (communication infrastructure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) * with the device is ready) and the device's firmware has been
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) * loaded and the device initialized.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) * Write to it only inside a i2400m->init_mutex protected area
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) * followed with a wmb(); rmb() before accesing (unless locked
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) * inside i2400m->init_mutex). Read access can be loose like that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) * [just using rmb()] because the paths that use this also do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) * other error checks later on.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) * @ready: Communication infrastructure with the device is ready, data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) * frames can start to be passed around (this is lighter than
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) * using the WiMAX state for certain hot paths).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) * Write to it only inside a i2400m->init_mutex protected area
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) * followed with a wmb(); rmb() before accesing (unless locked
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) * inside i2400m->init_mutex). Read access can be loose like that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) * [just using rmb()] because the paths that use this also do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) * other error checks later on.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) * @rx_reorder: 1 if RX reordering is enabled; this can only be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) * set at probe time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) * @state: device's state (as reported by it)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) * @state_wq: waitqueue that is woken up whenever the state changes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) * @tx_lock: spinlock to protect TX members
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) * @tx_buf: FIFO buffer for TX; we queue data here
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) * @tx_in: FIFO index for incoming data. Note this doesn't wrap around
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) * and it is always greater than @tx_out.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) * @tx_out: FIFO index for outgoing data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) * @tx_msg: current TX message that is active in the FIFO for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) * appending payloads.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) * @tx_sequence: current sequence number for TX messages from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) * device to the host.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) * @tx_msg_size: size of the current message being transmitted by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) * bus-specific code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) * @tx_pl_num: total number of payloads sent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) * @tx_pl_max: maximum number of payloads sent in a TX message
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) * @tx_pl_min: minimum number of payloads sent in a TX message
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) * @tx_num: number of TX messages sent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) * @tx_size_acc: number of bytes in all TX messages sent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) * (this is different to net_dev's statistics as it also counts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) * control messages).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) * @tx_size_min: smallest TX message sent.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) * @tx_size_max: biggest TX message sent.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) * @rx_lock: spinlock to protect RX members and rx_roq_refcount.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) * @rx_pl_num: total number of payloads received
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) * @rx_pl_max: maximum number of payloads received in a RX message
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) * @rx_pl_min: minimum number of payloads received in a RX message
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) * @rx_num: number of RX messages received
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) * @rx_size_acc: number of bytes in all RX messages received
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) * (this is different to net_dev's statistics as it also counts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) * control messages).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) * @rx_size_min: smallest RX message received.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) * @rx_size_max: buggest RX message received.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) * @rx_roq: RX ReOrder queues. (fw >= v1.4) When packets are received
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) * out of order, the device will ask the driver to hold certain
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) * packets until the ones that are received out of order can be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) * delivered. Then the driver can release them to the host. See
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) * drivers/net/i2400m/rx.c for details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) * @rx_roq_refcount: refcount rx_roq. This refcounts any access to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) * rx_roq thus preventing rx_roq being destroyed when rx_roq
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) * is being accessed. rx_roq_refcount is protected by rx_lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) * @rx_reports: reports received from the device that couldn't be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) * processed because the driver wasn't still ready; when ready,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) * they are pulled from here and chewed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) * @rx_reports_ws: Work struct used to kick a scan of the RX reports
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) * list and to process each.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) * @src_mac_addr: MAC address used to make ethernet packets be coming
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) * from. This is generated at i2400m_setup() time and used during
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) * the life cycle of the instance. See i2400m_fake_eth_header().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) * @init_mutex: Mutex used for serializing the device bringup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) * sequence; this way if the device reboots in the middle, we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) * don't try to do a bringup again while we are tearing down the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) * one that failed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) * Can't reuse @msg_mutex because from within the bringup sequence
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) * we need to send messages to the device and thus use @msg_mutex.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) * @msg_mutex: mutex used to send control commands to the device (we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) * only allow one at a time, per host-device interface design).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) * @msg_completion: used to wait for an ack to a control command sent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) * to the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) * @ack_skb: used to store the actual ack to a control command if the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) * reception of the command was successful. Otherwise, a ERR_PTR()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) * errno code that indicates what failed with the ack reception.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) * Only valid after @msg_completion is woken up. Only updateable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) * if @msg_completion is armed. Only touched by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) * i2400m_msg_to_dev().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) * Protected by @rx_lock. In theory the command execution flow is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) * sequential, but in case the device sends an out-of-phase or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) * very delayed response, we need to avoid it trampling current
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) * execution.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) * @bm_cmd_buf: boot mode command buffer for composing firmware upload
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) * commands.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) * USB can't r/w to stack, vmalloc, etc...as well, we end up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) * having to alloc/free a lot to compose commands, so we use these
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) * for stagging and not having to realloc all the time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) * This assumes the code always runs serialized. Only one thread
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) * can call i2400m_bm_cmd() at the same time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) * @bm_ack_buf: boot mode acknoledge buffer for staging reception of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) * responses to commands.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) * See @bm_cmd_buf.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) * @work_queue: work queue for processing device reports. This
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) * workqueue cannot be used for processing TX or RX to the device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) * as from it we'll process device reports, which might require
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) * further communication with the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) * @debugfs_dentry: hookup for debugfs files.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) * These have to be in a separate directory, a child of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) * (wimax_dev->debugfs_dentry) so they can be removed when the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) * module unloads, as we don't keep each dentry.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) * @fw_name: name of the firmware image that is currently being used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) * @fw_version: version of the firmware interface, Major.minor,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) * encoded in the high word and low word (major << 16 | minor).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) * @fw_hdrs: NULL terminated array of pointers to the firmware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) * headers. This is only available during firmware load time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) * @fw_cached: Used to cache firmware when the system goes to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) * suspend/standby/hibernation (as on resume we can't read it). If
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) * NULL, no firmware was cached, read it. If ~0, you can't read
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) * any firmware files (the system still didn't come out of suspend
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) * and failed to cache one), so abort; otherwise, a valid cached
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) * firmware to be used. Access to this variable is protected by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) * the spinlock i2400m->rx_lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) * @barker: barker type that the device uses; this is initialized by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) * i2400m_is_boot_barker() the first time it is called. Then it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) * won't change during the life cycle of the device and every time
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) * a boot barker is received, it is just verified for it being the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) * same.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) * @pm_notifier: used to register for PM events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) * @bus_reset_retries: counter for the number of bus resets attempted for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) * this boot. It's not for tracking the number of bus resets during
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) * the whole driver life cycle (from insmod to rmmod) but for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) * number of dev_start() executed until dev_start() returns a success
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) * (ie: a good boot means a dev_stop() followed by a successful
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) * dev_start()). dev_reset_handler() increments this counter whenever
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) * it is triggering a bus reset. It checks this counter to decide if a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) * subsequent bus reset should be retried. dev_reset_handler() retries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) * the bus reset until dev_start() succeeds or the counter reaches
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) * I2400M_BUS_RESET_RETRIES. The counter is cleared to 0 in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) * dev_reset_handle() when dev_start() returns a success,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) * ie: a successul boot is completed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) * @alive: flag to denote if the device *should* be alive. This flag is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) * everything like @updown (see doc for @updown) except reflecting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) * the device state *we expect* rather than the actual state as denoted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) * by @updown. It is set 1 whenever @updown is set 1 in dev_start().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) * Then the device is expected to be alive all the time
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) * (i2400m->alive remains 1) until the driver is removed. Therefore
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) * all the device reboot events detected can be still handled properly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) * by either dev_reset_handle() or .pre_reset/.post_reset as long as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) * the driver presents. It is set 0 along with @updown in dev_stop().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) * @error_recovery: flag to denote if we are ready to take an error recovery.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) * 0 for ready to take an error recovery; 1 for not ready. It is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) * initialized to 1 while probe() since we don't tend to take any error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) * recovery during probe(). It is decremented by 1 whenever dev_start()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) * succeeds to indicate we are ready to take error recovery from now on.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) * It is checked every time we wanna schedule an error recovery. If an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) * error recovery is already in place (error_recovery was set 1), we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) * should not schedule another one until the last one is done.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) struct i2400m {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) struct wimax_dev wimax_dev; /* FIRST! See doc */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) unsigned updown:1; /* Network device is up or down */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) unsigned boot_mode:1; /* is the device in boot mode? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) unsigned sboot:1; /* signed or unsigned fw boot */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) unsigned ready:1; /* Device comm infrastructure ready */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) unsigned rx_reorder:1; /* RX reorder is enabled */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) u8 trace_msg_from_user; /* echo rx msgs to 'trace' pipe */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) /* typed u8 so /sys/kernel/debug/u8 can tweak */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) enum i2400m_system_state state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) wait_queue_head_t state_wq; /* Woken up when on state updates */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) size_t bus_tx_block_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) size_t bus_tx_room_min;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) size_t bus_pl_size_max;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) unsigned bus_bm_retries;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) int (*bus_setup)(struct i2400m *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) int (*bus_dev_start)(struct i2400m *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) void (*bus_dev_stop)(struct i2400m *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) void (*bus_release)(struct i2400m *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) void (*bus_tx_kick)(struct i2400m *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) int (*bus_reset)(struct i2400m *, enum i2400m_reset_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) ssize_t (*bus_bm_cmd_send)(struct i2400m *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) const struct i2400m_bootrom_header *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) size_t, int flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) ssize_t (*bus_bm_wait_for_ack)(struct i2400m *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) struct i2400m_bootrom_header *, size_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) const char **bus_fw_names;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) unsigned bus_bm_mac_addr_impaired:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) const struct i2400m_poke_table *bus_bm_pokes_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) spinlock_t tx_lock; /* protect TX state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) void *tx_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) size_t tx_in, tx_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) struct i2400m_msg_hdr *tx_msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) size_t tx_sequence, tx_msg_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) /* TX stats */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) unsigned tx_pl_num, tx_pl_max, tx_pl_min,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) tx_num, tx_size_acc, tx_size_min, tx_size_max;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) /* RX stuff */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) /* protect RX state and rx_roq_refcount */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) spinlock_t rx_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) unsigned rx_pl_num, rx_pl_max, rx_pl_min,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) rx_num, rx_size_acc, rx_size_min, rx_size_max;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) struct i2400m_roq *rx_roq; /* access is refcounted */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) struct kref rx_roq_refcount; /* refcount access to rx_roq */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) u8 src_mac_addr[ETH_HLEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) struct list_head rx_reports; /* under rx_lock! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) struct work_struct rx_report_ws;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) struct mutex msg_mutex; /* serialize command execution */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) struct completion msg_completion;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) struct sk_buff *ack_skb; /* protected by rx_lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) void *bm_ack_buf; /* for receiving acks over USB */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) void *bm_cmd_buf; /* for issuing commands over USB */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) struct workqueue_struct *work_queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) struct mutex init_mutex; /* protect bringup seq */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) struct i2400m_reset_ctx *reset_ctx; /* protected by init_mutex */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) struct work_struct wake_tx_ws;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) struct sk_buff *wake_tx_skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) struct work_struct reset_ws;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) const char *reset_reason;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) struct work_struct recovery_ws;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) struct dentry *debugfs_dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) const char *fw_name; /* name of the current firmware image */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) unsigned long fw_version; /* version of the firmware interface */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) const struct i2400m_bcf_hdr **fw_hdrs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) struct i2400m_fw *fw_cached; /* protected by rx_lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) struct i2400m_barker_db *barker;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) struct notifier_block pm_notifier;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) /* counting bus reset retries in this boot */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) atomic_t bus_reset_retries;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) /* if the device is expected to be alive */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) unsigned alive;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) /* 0 if we are ready for error recovery; 1 if not ready */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) atomic_t error_recovery;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) * Bus-generic internal APIs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) * -------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) struct i2400m *wimax_dev_to_i2400m(struct wimax_dev *wimax_dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) return container_of(wimax_dev, struct i2400m, wimax_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) struct i2400m *net_dev_to_i2400m(struct net_device *net_dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) return wimax_dev_to_i2400m(netdev_priv(net_dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) * Boot mode support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) * i2400m_bm_cmd_flags - flags to i2400m_bm_cmd()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) * @I2400M_BM_CMD_RAW: send the command block as-is, without doing any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) * extra processing for adding CRC.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) enum i2400m_bm_cmd_flags {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) I2400M_BM_CMD_RAW = 1 << 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) * i2400m_bri - Boot-ROM indicators
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) * Flags for i2400m_bootrom_init() and i2400m_dev_bootstrap() [which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) * are passed from things like i2400m_setup()]. Can be combined with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) * |.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) * @I2400M_BRI_SOFT: The device rebooted already and a reboot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) * barker received, proceed directly to ack the boot sequence.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) * @I2400M_BRI_NO_REBOOT: Do not reboot the device and proceed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) * directly to wait for a reboot barker from the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) * @I2400M_BRI_MAC_REINIT: We need to reinitialize the boot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) * rom after reading the MAC address. This is quite a dirty hack,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) * if you ask me -- the device requires the bootrom to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) * initialized after reading the MAC address.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) enum i2400m_bri {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) I2400M_BRI_SOFT = 1 << 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) I2400M_BRI_NO_REBOOT = 1 << 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) I2400M_BRI_MAC_REINIT = 1 << 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) void i2400m_bm_cmd_prepare(struct i2400m_bootrom_header *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) int i2400m_dev_bootstrap(struct i2400m *, enum i2400m_bri);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) int i2400m_read_mac_addr(struct i2400m *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) int i2400m_bootrom_init(struct i2400m *, enum i2400m_bri);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) int i2400m_is_boot_barker(struct i2400m *, const void *, size_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) int i2400m_is_d2h_barker(const void *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) const __le32 *barker = buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) return le32_to_cpu(*barker) == I2400M_D2H_MSG_BARKER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) void i2400m_unknown_barker(struct i2400m *, const void *, size_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) /* Make/grok boot-rom header commands */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) __le32 i2400m_brh_command(enum i2400m_brh_opcode opcode, unsigned use_checksum,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) unsigned direct_access)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) return cpu_to_le32(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) I2400M_BRH_SIGNATURE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) | (direct_access ? I2400M_BRH_DIRECT_ACCESS : 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) | I2400M_BRH_RESPONSE_REQUIRED /* response always required */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) | (use_checksum ? I2400M_BRH_USE_CHECKSUM : 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) | (opcode & I2400M_BRH_OPCODE_MASK));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) void i2400m_brh_set_opcode(struct i2400m_bootrom_header *hdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) enum i2400m_brh_opcode opcode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) hdr->command = cpu_to_le32(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) (le32_to_cpu(hdr->command) & ~I2400M_BRH_OPCODE_MASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) | (opcode & I2400M_BRH_OPCODE_MASK));
^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) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) unsigned i2400m_brh_get_opcode(const struct i2400m_bootrom_header *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) return le32_to_cpu(hdr->command) & I2400M_BRH_OPCODE_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) unsigned i2400m_brh_get_response(const struct i2400m_bootrom_header *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) return (le32_to_cpu(hdr->command) & I2400M_BRH_RESPONSE_MASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) >> I2400M_BRH_RESPONSE_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) unsigned i2400m_brh_get_use_checksum(const struct i2400m_bootrom_header *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) return le32_to_cpu(hdr->command) & I2400M_BRH_USE_CHECKSUM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) unsigned i2400m_brh_get_response_required(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) const struct i2400m_bootrom_header *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) return le32_to_cpu(hdr->command) & I2400M_BRH_RESPONSE_REQUIRED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) unsigned i2400m_brh_get_direct_access(const struct i2400m_bootrom_header *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) return le32_to_cpu(hdr->command) & I2400M_BRH_DIRECT_ACCESS;
^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) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) unsigned i2400m_brh_get_signature(const struct i2400m_bootrom_header *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) return (le32_to_cpu(hdr->command) & I2400M_BRH_SIGNATURE_MASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) >> I2400M_BRH_SIGNATURE_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) * Driver / device setup and internal functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) void i2400m_init(struct i2400m *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) int i2400m_reset(struct i2400m *, enum i2400m_reset_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) void i2400m_netdev_setup(struct net_device *net_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) int i2400m_sysfs_setup(struct device_driver *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) void i2400m_sysfs_release(struct device_driver *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) int i2400m_tx_setup(struct i2400m *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) void i2400m_wake_tx_work(struct work_struct *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) void i2400m_tx_release(struct i2400m *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) int i2400m_rx_setup(struct i2400m *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) void i2400m_rx_release(struct i2400m *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) void i2400m_fw_cache(struct i2400m *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) void i2400m_fw_uncache(struct i2400m *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) void i2400m_net_rx(struct i2400m *, struct sk_buff *, unsigned, const void *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) void i2400m_net_erx(struct i2400m *, struct sk_buff *, enum i2400m_cs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) void i2400m_net_wake_stop(struct i2400m *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) enum i2400m_pt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) int i2400m_tx(struct i2400m *, const void *, size_t, enum i2400m_pt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) #ifdef CONFIG_DEBUG_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) void i2400m_debugfs_add(struct i2400m *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) void i2400m_debugfs_rm(struct i2400m *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) static inline void i2400m_debugfs_add(struct i2400m *i2400m) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) static inline void i2400m_debugfs_rm(struct i2400m *i2400m) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) /* Initialize/shutdown the device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) int i2400m_dev_initialize(struct i2400m *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) void i2400m_dev_shutdown(struct i2400m *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) extern struct attribute_group i2400m_dev_attr_group;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) /* HDI message's payload description handling */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) size_t i2400m_pld_size(const struct i2400m_pld *pld)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) return I2400M_PLD_SIZE_MASK & le32_to_cpu(pld->val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) enum i2400m_pt i2400m_pld_type(const struct i2400m_pld *pld)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) return (I2400M_PLD_TYPE_MASK & le32_to_cpu(pld->val))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) >> I2400M_PLD_TYPE_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) void i2400m_pld_set(struct i2400m_pld *pld, size_t size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) enum i2400m_pt type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) pld->val = cpu_to_le32(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) ((type << I2400M_PLD_TYPE_SHIFT) & I2400M_PLD_TYPE_MASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) | (size & I2400M_PLD_SIZE_MASK));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852)
^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) * API for the bus-specific drivers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) * --------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) struct i2400m *i2400m_get(struct i2400m *i2400m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) dev_hold(i2400m->wimax_dev.net_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) return i2400m;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) void i2400m_put(struct i2400m *i2400m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) dev_put(i2400m->wimax_dev.net_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) int i2400m_dev_reset_handle(struct i2400m *, const char *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) int i2400m_pre_reset(struct i2400m *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) int i2400m_post_reset(struct i2400m *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) void i2400m_error_recovery(struct i2400m *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) * _setup()/_release() are called by the probe/disconnect functions of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) * the bus-specific drivers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) int i2400m_setup(struct i2400m *, enum i2400m_bri bm_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) void i2400m_release(struct i2400m *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) int i2400m_rx(struct i2400m *, struct sk_buff *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) struct i2400m_msg_hdr *i2400m_tx_msg_get(struct i2400m *, size_t *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) void i2400m_tx_msg_sent(struct i2400m *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) * Utility functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) struct device *i2400m_dev(struct i2400m *i2400m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) return i2400m->wimax_dev.net_dev->dev.parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) int i2400m_msg_check_status(const struct i2400m_l3l4_hdr *, char *, size_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) int i2400m_msg_size_check(struct i2400m *, const struct i2400m_l3l4_hdr *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) size_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) struct sk_buff *i2400m_msg_to_dev(struct i2400m *, const void *, size_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) void i2400m_msg_to_dev_cancel_wait(struct i2400m *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) void i2400m_report_hook(struct i2400m *, const struct i2400m_l3l4_hdr *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) size_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) void i2400m_report_hook_work(struct work_struct *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) int i2400m_cmd_enter_powersave(struct i2400m *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) int i2400m_cmd_exit_idle(struct i2400m *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) struct sk_buff *i2400m_get_device_info(struct i2400m *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) int i2400m_firmware_check(struct i2400m *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) int i2400m_set_idle_timeout(struct i2400m *, unsigned);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) struct usb_endpoint_descriptor *usb_get_epd(struct usb_interface *iface, int ep)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) return &iface->cur_altsetting->endpoint[ep].desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) int i2400m_op_rfkill_sw_toggle(struct wimax_dev *, enum wimax_rf_state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) void i2400m_report_tlv_rf_switches_status(struct i2400m *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) const struct i2400m_tlv_rf_switches_status *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) * Helpers for firmware backwards compatibility
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) * As we aim to support at least the firmware version that was
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) * released with the previous kernel/driver release, some code will be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) * conditionally executed depending on the firmware version. On each
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) * release, the code to support fw releases past the last two ones
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930) * will be purged.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) * By making it depend on this macros, it is easier to keep it a tab
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933) * on what has to go and what not.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) unsigned i2400m_le_v1_3(struct i2400m *i2400m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) /* running fw is lower or v1.3 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) return i2400m->fw_version <= 0x00090001;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943) unsigned i2400m_ge_v1_4(struct i2400m *i2400m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) /* running fw is higher or v1.4 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946) return i2400m->fw_version >= 0x00090002;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) * Do a millisecond-sleep for allowing wireshark to dump all the data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) * packets. Used only for debugging.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955) void __i2400m_msleep(unsigned ms)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957) #if 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959) msleep(ms);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) /* module initialization helpers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965) int i2400m_barker_db_init(const char *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) void i2400m_barker_db_exit(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970) #endif /* #ifndef __I2400M_H__ */