Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions | Variables
control.c File Reference
#include <stdarg.h>
#include "i2400m.h"
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/wimax/i2400m.h>
#include <linux/export.h>
#include <linux/moduleparam.h>
#include "debug-levels.h"

Go to the source code of this file.

Data Structures

struct  i2400m_cmd_enter_power_save


#define D_SUBMODULE   control


enum  { I2400M_WAKEUP_ENABLED = 0x01, I2400M_WAKEUP_DISABLED = 0x02, I2400M_TLV_TYPE_WAKEUP_MODE = 144 }
enum  { I2400M_TLV_DETAILED_DEVICE_INFO = 140 }
enum  { I2400M_HDIv_MAJOR = 9, I2400M_HDIv_MINOR = 1, I2400M_HDIv_MINOR_2 = 2 }


 module_param_named (idle_mode_disabled, i2400m_idle_mode_disabled, int, 0644)
 MODULE_PARM_DESC (idle_mode_disabled,"If true, the device will not enable idle mode negotiation ""with the base station (when connected) to save power.")
 module_param_named (power_save_disabled, i2400m_power_save_disabled, int, 0644)
 MODULE_PARM_DESC (power_save_disabled,"If true, the driver will not tell the device to enter ""power saving mode when it reports it is ready for it. ""False by default (so the device is told to do power ""saving).")
 module_param_named (passive_mode, i2400m_passive_mode, int, 0644)
 MODULE_PARM_DESC (passive_mode,"If true, the driver will not do any device setup ""and leave it up to user space, who must be properly ""setup.")
int i2400m_msg_check_status (const struct i2400m_l3l4_hdr *l3l4_hdr, char *strbuf, size_t strbuf_size)
void i2400m_report_hook (struct i2400m *i2400m, const struct i2400m_l3l4_hdr *l3l4_hdr, size_t size)
int i2400m_msg_size_check (struct i2400m *i2400m, const struct i2400m_l3l4_hdr *l3l4_hdr, size_t msg_size)
void i2400m_msg_to_dev_cancel_wait (struct i2400m *i2400m, int code)
struct sk_buffi2400m_msg_to_dev (struct i2400m *i2400m, const void *buf, size_t buf_len)
int i2400m_cmd_enter_powersave (struct i2400m *i2400m)
 EXPORT_SYMBOL_GPL (i2400m_cmd_enter_powersave)
struct sk_buffi2400m_get_device_info (struct i2400m *i2400m)
int i2400m_firmware_check (struct i2400m *i2400m)
int i2400m_cmd_exit_idle (struct i2400m *i2400m)
int i2400m_set_idle_timeout (struct i2400m *i2400m, unsigned msecs)
int i2400m_dev_initialize (struct i2400m *i2400m)
void i2400m_dev_shutdown (struct i2400m *i2400m)


struct i2400m_cmd_enter_power_save __packed

Macro Definition Documentation

#define D_SUBMODULE   control

Definition at line 85 of file control.c.

Enumeration Type Documentation

anonymous enum

Definition at line 844 of file control.c.

anonymous enum

Definition at line 911 of file control.c.

anonymous enum

Definition at line 985 of file control.c.

Function Documentation

EXPORT_SYMBOL_GPL ( i2400m_cmd_enter_powersave  )
int i2400m_cmd_enter_powersave ( struct i2400m i2400m)

Definition at line 863 of file control.c.

int i2400m_cmd_exit_idle ( struct i2400m i2400m)

Definition at line 1093 of file control.c.

int i2400m_dev_initialize ( struct i2400m i2400m)

i2400m_dev_initialize - Initialize the device once communications are ready

: device descriptor

Returns: 0 if ok, < 0 errno code on error.

Configures the device to work the way we like it.

At the point of this call, the device is registered with the WiMAX and netdev stacks, firmware is uploaded and we can talk to the device normally.

Definition at line 1348 of file control.c.

void i2400m_dev_shutdown ( struct i2400m i2400m)

i2400m_dev_shutdown - Shutdown a running device

: device descriptor

Release resources acquired during the running of the device; in theory, should also tell the device to go to sleep, switch off the radio, all that, but at this point, in most cases (driver disconnection, reset handling) we can't even talk to the device.

Definition at line 1430 of file control.c.

int i2400m_firmware_check ( struct i2400m i2400m)

i2400m_firmware_check - check firmware versions are compatible with the driver

: device descriptor

Returns: 0 if ok, < 0 errno code an error and a message in the kernel log.

Long function, but quite simple; first chunk launches the command and double checks the reply for the right TLV. Then we process the TLV (where the meat is).

Once we process the TLV that gives us the firmware's interface version, we encode it and save it in i2400m->fw_version for future reference.

Definition at line 1009 of file control.c.

struct sk_buff* i2400m_get_device_info ( struct i2400m i2400m)

i2400m_get_device_info - Query the device for detailed device information

: device descriptor

Returns: an skb whose skb->data points to a 'struct i2400m_tlv_detailed_device_info'. When done, kfree_skb() it. The skb is guaranteed to contain the whole TLV data structure.

On error, IS_ERR(skb) is true and ERR_PTR(skb) is the error code.

Definition at line 927 of file control.c.

int i2400m_msg_check_status ( const struct i2400m_l3l4_hdr l3l4_hdr,
char strbuf,
size_t  strbuf_size 

Definition at line 282 of file control.c.

int i2400m_msg_size_check ( struct i2400m i2400m,
const struct i2400m_l3l4_hdr l3l4_hdr,
size_t  msg_size 

Definition at line 598 of file control.c.

struct sk_buff* i2400m_msg_to_dev ( struct i2400m i2400m,
const void buf,
size_t  buf_len 

i2400m_msg_to_dev - Send a control message to the device and get a response

: device descriptor

: an skb *

: pointer to the buffer containing the message to be sent; it has to start with a &struct i2400M_l3l4_hdr and then followed by the payload. Once this function returns, the buffer can be reused.

: buffer size


Pointer to skb containing the ack message. You need to check the pointer with IS_ERR(), as it might be an error code. Error codes could happen because:

  • the message wasn't formatted correctly
  • couldn't send the message
  • failed waiting for a response
  • the ack message wasn't formatted correctly

The returned skb has been allocated with wimax_msg_to_user_alloc(), it contains the response in a netlink attribute and is ready to be passed up to user space with wimax_msg_to_user_send(). To access the payload and its length, use wimax_msg_{data,len}() on the skb.

The skb has to be freed with kfree_skb() once done.


This function delivers a message/command to the device and waits for an ack to be received. The format is described in linux/wimax/i2400m.h. In summary, a command/get/set is followed by an ack.

This function will not check the ack status, that's left up to the caller. Once done with the ack skb, it has to be kfree_skb()ed.

The i2400m handles only one message at the same time, thus we need the mutex to exclude other players.

We write the message and then wait for an answer to come back. The RX path intercepts control messages and handles them in i2400m_rx_ctl(). Reports (notifications) are (maybe) processed locally and then forwarded (as needed) to user space on the WiMAX stack message pipe. Acks are saved and passed back to us through an skb in i2400m->ack_skb which is ready to be given to generic netlink if need be.

Definition at line 707 of file control.c.

void i2400m_msg_to_dev_cancel_wait ( struct i2400m i2400m,
int  code 

Definition at line 640 of file control.c.

void i2400m_report_hook ( struct i2400m i2400m,
const struct i2400m_l3l4_hdr l3l4_hdr,
size_t  size 

Definition at line 513 of file control.c.

int i2400m_set_idle_timeout ( struct i2400m i2400m,
unsigned  msecs 

i2400m_set_idle_timeout - Set the device's idle mode timeout

: i2400m device descriptor

: milliseconds for the timeout to enter idle mode. Between 100 to 300000 (5m); 0 to disable. In increments of 100.

After this of the link being idle (no data being sent or received), the device will negotiate with the basestation entering idle mode for saving power. The connection is maintained, but getting out of it (done in tx.c) will require some negotiation, possible crypto re-handshake and a possible DHCP re-lease.

Only available if fw_version >= 0x00090002.

Returns: 0 if ok, < 0 errno code on error.

Definition at line 1282 of file control.c.

module_param_named ( idle_mode_disabled  ,
i2400m_idle_mode_disabled  ,
int  ,
module_param_named ( power_save_disabled  ,
i2400m_power_save_disabled  ,
int  ,
module_param_named ( passive_mode  ,
i2400m_passive_mode  ,
int  ,
MODULE_PARM_DESC ( idle_mode_disabled  ,
"If  true,
the device will not enable idle mode negotiation""with the base station(when connected) to save power."   
MODULE_PARM_DESC ( power_save_disabled  ,
"If  true,
the driver will not tell the device to enter""power saving mode when it reports it is ready for it.""False by default(so the device is told to do power""saving)."   
MODULE_PARM_DESC ( passive_mode  ,
"If  true,
the driver will not do any device setup""and leave it up to user  space,
who must be properly""setup."   

Variable Documentation

int errno

Definition at line 248 of file control.c.

Definition at line 247 of file control.c.