In order for a driver to use cfg80211, it must register the hardware device with cfg80211. This happens through a number of hardware capability structs described below.
The fundamental structure for each device is the ‘wiphy’, of which each instance describes a physical wireless device connected to the system. Each such wiphy can have zero, one, or many virtual interfaces associated with it, which need to be identified as such by pointing the network interface’s ieee80211_ptr pointer to a struct wireless_dev which further describes the wireless part of the interface, normally this struct is embedded in the network interface’s private data area. Drivers can optionally allow creating or destroying virtual interfaces on the fly, but without at least one or the ability to create some the wireless device isn’t useful.
Each wiphy structure contains device capability information, and also has a pointer to the various operations the driver offers. The definitions and structures here describe these capabilities in detail.
channel flags
Constants
Description
Channel flags set by the regulatory control code.
channel definition
Definition
struct ieee80211_channel {
enum nl80211_band band;
u16 center_freq;
u16 hw_value;
u32 flags;
int max_antenna_gain;
int max_power;
int max_reg_power;
bool beacon_found;
u32 orig_flags;
int orig_mag;
int orig_mpwr;
enum nl80211_dfs_state dfs_state;
unsigned long dfs_state_entered;
unsigned int dfs_cac_ms;
};
Members
Description
This structure describes a single channel for use with cfg80211.
rate flags
Constants
Description
Hardware/specification flags for rates. These are structured in a way that allows using the same bitrate structure for different bands/PHY modes.
bitrate definition
Definition
struct ieee80211_rate {
u32 flags;
u16 bitrate;
u16 hw_value;
u16 hw_value_short;
};
Members
Description
This structure describes a bitrate that an 802.11 PHY can operate with. The two values hw_value and hw_value_short are only for driver use when pointers to this structure are passed around.
STA’s HT capabilities
Definition
struct ieee80211_sta_ht_cap {
u16 cap;
bool ht_supported;
u8 ampdu_factor;
u8 ampdu_density;
struct ieee80211_mcs_info mcs;
};
Members
Description
This structure describes most essential parameters needed to describe 802.11n HT capabilities for an STA.
frequency band definition
Definition
struct ieee80211_supported_band {
struct ieee80211_channel * channels;
struct ieee80211_rate * bitrates;
enum nl80211_band band;
int n_channels;
int n_bitrates;
struct ieee80211_sta_ht_cap ht_cap;
struct ieee80211_sta_vht_cap vht_cap;
};
Members
Description
This structure describes a frequency band a wiphy is able to operate in.
signal type
Constants
set_wiphy_params bitfield values
Constants
wiphy capability flags
Constants
wireless hardware description
Definition
struct wiphy {
u8 perm_addr[ETH_ALEN];
u8 addr_mask[ETH_ALEN];
struct mac_address * addresses;
const struct ieee80211_txrx_stypes * mgmt_stypes;
const struct ieee80211_iface_combination * iface_combinations;
int n_iface_combinations;
u16 software_iftypes;
u16 n_addresses;
u16 interface_modes;
u16 max_acl_mac_addrs;
u32 flags;
u32 regulatory_flags;
u32 features;
u8 ext_features[DIV_ROUND_UP(NUM_NL80211_EXT_FEATURES# 8)];
u32 ap_sme_capa;
enum cfg80211_signal_type signal_type;
int bss_priv_size;
u8 max_scan_ssids;
u8 max_sched_scan_ssids;
u8 max_match_sets;
u16 max_scan_ie_len;
u16 max_sched_scan_ie_len;
u32 max_sched_scan_plans;
u32 max_sched_scan_plan_interval;
u32 max_sched_scan_plan_iterations;
int n_cipher_suites;
const u32 * cipher_suites;
u8 retry_short;
u8 retry_long;
u32 frag_threshold;
u32 rts_threshold;
u8 coverage_class;
char fw_version[ETHTOOL_FWVERS_LEN];
u32 hw_version;
#ifdef CONFIG_PM
const struct wiphy_wowlan_support * wowlan;
struct cfg80211_wowlan * wowlan_config;
#endif
u16 max_remain_on_channel_duration;
u8 max_num_pmkids;
u32 available_antennas_tx;
u32 available_antennas_rx;
u32 probe_resp_offload;
const u8 * extended_capabilities;
const u8 * extended_capabilities_mask;
u8 extended_capabilities_len;
const struct wiphy_iftype_ext_capab * iftype_ext_capab;
unsigned int num_iftype_ext_capab;
const void * privid;
struct ieee80211_supported_band * bands[NUM_NL80211_BANDS];
void (* reg_notifier) (struct wiphy *wiphy,struct regulatory_request *request);
const struct ieee80211_regdomain __rcu * regd;
struct device dev;
bool registered;
struct dentry * debugfsdir;
const struct ieee80211_ht_cap * ht_capa_mod_mask;
const struct ieee80211_vht_cap * vht_capa_mod_mask;
struct list_head wdev_list;
possible_net_t _net;
#ifdef CONFIG_CFG80211_WEXT
const struct iw_handler_def * wext;
#endif
const struct wiphy_coalesce_support * coalesce;
const struct wiphy_vendor_command * vendor_commands;
const struct nl80211_vendor_cmd_info * vendor_events;
int n_vendor_commands;
int n_vendor_events;
u16 max_ap_assoc_sta;
u8 max_num_csa_counters;
u8 max_adj_channel_rssi_comp;
u32 bss_select_support;
u64 cookie_counter;
u8 nan_supported_bands;
char priv[0];
};
Members
wireless device state
Definition
struct wireless_dev {
struct wiphy * wiphy;
enum nl80211_iftype iftype;
struct list_head list;
struct net_device * netdev;
u32 identifier;
struct list_head mgmt_registrations;
spinlock_t mgmt_registrations_lock;
struct mutex mtx;
bool use_4addr;
bool is_running;
u8 address[ETH_ALEN];
u8 ssid[IEEE80211_MAX_SSID_LEN];
u8 ssid_len;
u8 mesh_id_len;
u8 mesh_id_up_len;
struct cfg80211_conn * conn;
struct cfg80211_cached_keys * connect_keys;
enum ieee80211_bss_type conn_bss_type;
u32 conn_owner_nlportid;
struct work_struct disconnect_wk;
u8 disconnect_bssid[ETH_ALEN];
struct list_head event_list;
spinlock_t event_lock;
struct cfg80211_internal_bss * current_bss;
struct cfg80211_chan_def preset_chandef;
struct cfg80211_chan_def chandef;
bool ibss_fixed;
bool ibss_dfs_possible;
bool ps;
int ps_timeout;
int beacon_interval;
u32 ap_unexpected_nlportid;
bool cac_started;
unsigned long cac_start_time;
unsigned int cac_time_ms;
u32 owner_nlportid;
#ifdef CONFIG_CFG80211_WEXT
struct wext;
#endif
};
Members
Description
For netdevs, this structure must be allocated by the driver that uses the ieee80211_ptr field in struct net_device (this is intentional so it can be allocated along with the netdev.) It need not be registered then as netdev registration will be intercepted by cfg80211 to see the new wireless device.
For non-netdev uses, it must also be allocated by the driver in response to the cfg80211 callbacks that require it, as there’s no netdev registration in that case it may not be allocated outside of callback operations that return it.
create a new wiphy for use with cfg80211
Parameters
Description
Create a new wiphy and associate the given operations with it. sizeof_priv bytes are allocated for private use.
Return
A pointer to the new wiphy. This pointer must be assigned to each netdev’s ieee80211_ptr for proper operation.
Parameters
Description
Some devices may have extra limitations specified in DT. This may be useful for chipsets that normally support more bands but are limited due to board design (e.g. by antennas or external power amplifier).
This function reads info from DT and uses it to modify channels (disable unavailable ones). It’s usually a bad idea to use it in drivers with shared channel data as DT limitations are device specific. You should make sure to call it only if channels in wiphy are copied and can be modified without affecting other devices.
As this function access device node it has to be called after set_wiphy_dev. It also modifies channels so they have to be set first. If using this helper, call it before wiphy_register().
Parameters
Return
A non-negative wiphy index or a negative error code.
Parameters
Description
After this call, no more requests can be made with this priv pointer, but the call may sleep to wait for an outstanding request that is being handled.
Parameters
Parameters
Return
The name of wiphy.
Parameters
Return
The dev of wiphy.
Parameters
Return
The priv of wiphy.
Parameters
Return
The wiphy of priv.
Parameters
return wiphy priv from wireless_dev
Parameters
Return
The wiphy priv of wdev.
limit on certain interface types
Definition
struct ieee80211_iface_limit {
u16 max;
u16 types;
};
Members
possible interface combination
Definition
struct ieee80211_iface_combination {
const struct ieee80211_iface_limit * limits;
u32 num_different_channels;
u16 max_interfaces;
u8 n_limits;
bool beacon_int_infra_match;
u8 radar_detect_widths;
u8 radar_detect_regions;
u32 beacon_int_min_gcd;
};
Members
This interface combination supports different beacon intervals.
Description
With this structure the driver can describe which interface combinations it supports concurrently.
Examples
Allow #STA <= 1, #AP <= 1, matching BI, channels = 1, 2 total:
struct ieee80211_iface_limit limits1[] = {
{ .max = 1, .types = BIT(NL80211_IFTYPE_STATION), },
{ .max = 1, .types = BIT(NL80211_IFTYPE_AP}, },
};
struct ieee80211_iface_combination combination1 = {
.limits = limits1,
.n_limits = ARRAY_SIZE(limits1),
.max_interfaces = 2,
.beacon_int_infra_match = true,
};
Allow #{AP, P2P-GO} <= 8, channels = 1, 8 total:
struct ieee80211_iface_limit limits2[] = {
{ .max = 8, .types = BIT(NL80211_IFTYPE_AP) |
BIT(NL80211_IFTYPE_P2P_GO), },
};
struct ieee80211_iface_combination combination2 = {
.limits = limits2,
.n_limits = ARRAY_SIZE(limits2),
.max_interfaces = 8,
.num_different_channels = 1,
};
Allow #STA <= 1, #{P2P-client,P2P-GO} <= 3 on two channels, 4 total.
This allows for an infrastructure connection and three P2P connections.
struct ieee80211_iface_limit limits3[] = {
{ .max = 1, .types = BIT(NL80211_IFTYPE_STATION), },
{ .max = 3, .types = BIT(NL80211_IFTYPE_P2P_GO) |
BIT(NL80211_IFTYPE_P2P_CLIENT), },
};
struct ieee80211_iface_combination combination3 = {
.limits = limits3,
.n_limits = ARRAY_SIZE(limits3),
.max_interfaces = 4,
.num_different_channels = 2,
};
check interface combinations
Parameters
Description
This function can be called by the driver to check whether a combination of interfaces and their types are allowed according to the interface combinations.
Each wireless device and each virtual interface offer a set of configuration operations and other actions that are invoked by userspace. Each of these actions is described in the operations structure, and the parameters these operations use are described separately.
Additionally, some operations are asynchronous and expect to get status information via some functions that drivers need to call.
Scanning and BSS list handling with its associated functionality is described in a separate chapter.
backend description for wireless configuration
Definition
struct cfg80211_ops {
int (* suspend) (struct wiphy *wiphy, struct cfg80211_wowlan *wow);
int (* resume) (struct wiphy *wiphy);
void (* set_wakeup) (struct wiphy *wiphy, bool enabled);
struct wireless_dev * (* add_virtual_intf) (struct wiphy *wiphy,const char *name,unsigned char name_assign_type,enum nl80211_iftype type,u32 *flags,struct vif_params *params);
int (* del_virtual_intf) (struct wiphy *wiphy,struct wireless_dev *wdev);
int (* change_virtual_intf) (struct wiphy *wiphy,struct net_device *dev,enum nl80211_iftype type, u32 *flags,struct vif_params *params);
int (* add_key) (struct wiphy *wiphy, struct net_device *netdev,u8 key_index, bool pairwise, const u8 *mac_addr,struct key_params *params);
int (* get_key) (struct wiphy *wiphy, struct net_device *netdev,u8 key_index, bool pairwise, const u8 *mac_addr,void *cookie,void (*callback);
int (* del_key) (struct wiphy *wiphy, struct net_device *netdev,u8 key_index, bool pairwise, const u8 *mac_addr);
int (* set_default_key) (struct wiphy *wiphy,struct net_device *netdev,u8 key_index, bool unicast, bool multicast);
int (* set_default_mgmt_key) (struct wiphy *wiphy,struct net_device *netdev,u8 key_index);
int (* start_ap) (struct wiphy *wiphy, struct net_device *dev,struct cfg80211_ap_settings *settings);
int (* change_beacon) (struct wiphy *wiphy, struct net_device *dev,struct cfg80211_beacon_data *info);
int (* stop_ap) (struct wiphy *wiphy, struct net_device *dev);
int (* add_station) (struct wiphy *wiphy, struct net_device *dev,const u8 *mac,struct station_parameters *params);
int (* del_station) (struct wiphy *wiphy, struct net_device *dev,struct station_del_parameters *params);
int (* change_station) (struct wiphy *wiphy, struct net_device *dev,const u8 *mac,struct station_parameters *params);
int (* get_station) (struct wiphy *wiphy, struct net_device *dev,const u8 *mac, struct station_info *sinfo);
int (* dump_station) (struct wiphy *wiphy, struct net_device *dev,int idx, u8 *mac, struct station_info *sinfo);
int (* add_mpath) (struct wiphy *wiphy, struct net_device *dev,const u8 *dst, const u8 *next_hop);
int (* del_mpath) (struct wiphy *wiphy, struct net_device *dev,const u8 *dst);
int (* change_mpath) (struct wiphy *wiphy, struct net_device *dev,const u8 *dst, const u8 *next_hop);
int (* get_mpath) (struct wiphy *wiphy, struct net_device *dev,u8 *dst, u8 *next_hop, struct mpath_info *pinfo);
int (* dump_mpath) (struct wiphy *wiphy, struct net_device *dev,int idx, u8 *dst, u8 *next_hop,struct mpath_info *pinfo);
int (* get_mpp) (struct wiphy *wiphy, struct net_device *dev,u8 *dst, u8 *mpp, struct mpath_info *pinfo);
int (* dump_mpp) (struct wiphy *wiphy, struct net_device *dev,int idx, u8 *dst, u8 *mpp,struct mpath_info *pinfo);
int (* get_mesh_config) (struct wiphy *wiphy,struct net_device *dev,struct mesh_config *conf);
int (* update_mesh_config) (struct wiphy *wiphy,struct net_device *dev, u32 mask,const struct mesh_config *nconf);
int (* join_mesh) (struct wiphy *wiphy, struct net_device *dev,const struct mesh_config *conf,const struct mesh_setup *setup);
int (* leave_mesh) (struct wiphy *wiphy, struct net_device *dev);
int (* join_ocb) (struct wiphy *wiphy, struct net_device *dev,struct ocb_setup *setup);
int (* leave_ocb) (struct wiphy *wiphy, struct net_device *dev);
int (* change_bss) (struct wiphy *wiphy, struct net_device *dev,struct bss_parameters *params);
int (* set_txq_params) (struct wiphy *wiphy, struct net_device *dev,struct ieee80211_txq_params *params);
int (* libertas_set_mesh_channel) (struct wiphy *wiphy,struct net_device *dev,struct ieee80211_channel *chan);
int (* set_monitor_channel) (struct wiphy *wiphy,struct cfg80211_chan_def *chandef);
int (* scan) (struct wiphy *wiphy,struct cfg80211_scan_request *request);
void (* abort_scan) (struct wiphy *wiphy, struct wireless_dev *wdev);
int (* auth) (struct wiphy *wiphy, struct net_device *dev,struct cfg80211_auth_request *req);
int (* assoc) (struct wiphy *wiphy, struct net_device *dev,struct cfg80211_assoc_request *req);
int (* deauth) (struct wiphy *wiphy, struct net_device *dev,struct cfg80211_deauth_request *req);
int (* disassoc) (struct wiphy *wiphy, struct net_device *dev,struct cfg80211_disassoc_request *req);
int (* connect) (struct wiphy *wiphy, struct net_device *dev,struct cfg80211_connect_params *sme);
int (* update_connect_params) (struct wiphy *wiphy,struct net_device *dev,struct cfg80211_connect_params *sme,u32 changed);
int (* disconnect) (struct wiphy *wiphy, struct net_device *dev,u16 reason_code);
int (* join_ibss) (struct wiphy *wiphy, struct net_device *dev,struct cfg80211_ibss_params *params);
int (* leave_ibss) (struct wiphy *wiphy, struct net_device *dev);
int (* set_mcast_rate) (struct wiphy *wiphy, struct net_device *dev,int rate[NUM_NL80211_BANDS]);
int (* set_wiphy_params) (struct wiphy *wiphy, u32 changed);
int (* set_tx_power) (struct wiphy *wiphy, struct wireless_dev *wdev,enum nl80211_tx_power_setting type, int mbm);
int (* get_tx_power) (struct wiphy *wiphy, struct wireless_dev *wdev,int *dbm);
int (* set_wds_peer) (struct wiphy *wiphy, struct net_device *dev,const u8 *addr);
void (* rfkill_poll) (struct wiphy *wiphy);
#ifdef CONFIG_NL80211_TESTMODE
int (* testmode_cmd) (struct wiphy *wiphy, struct wireless_dev *wdev,void *data, int len);
int (* testmode_dump) (struct wiphy *wiphy, struct sk_buff *skb,struct netlink_callback *cb,void *data, int len);
#endif
int (* set_bitrate_mask) (struct wiphy *wiphy,struct net_device *dev,const u8 *peer,const struct cfg80211_bitrate_mask *mask);
int (* dump_survey) (struct wiphy *wiphy, struct net_device *netdev,int idx, struct survey_info *info);
int (* set_pmksa) (struct wiphy *wiphy, struct net_device *netdev,struct cfg80211_pmksa *pmksa);
int (* del_pmksa) (struct wiphy *wiphy, struct net_device *netdev,struct cfg80211_pmksa *pmksa);
int (* flush_pmksa) (struct wiphy *wiphy, struct net_device *netdev);
int (* remain_on_channel) (struct wiphy *wiphy,struct wireless_dev *wdev,struct ieee80211_channel *chan,unsigned int duration,u64 *cookie);
int (* cancel_remain_on_channel) (struct wiphy *wiphy,struct wireless_dev *wdev,u64 cookie);
int (* mgmt_tx) (struct wiphy *wiphy, struct wireless_dev *wdev,struct cfg80211_mgmt_tx_params *params,u64 *cookie);
int (* mgmt_tx_cancel_wait) (struct wiphy *wiphy,struct wireless_dev *wdev,u64 cookie);
int (* set_power_mgmt) (struct wiphy *wiphy, struct net_device *dev,bool enabled, int timeout);
int (* set_cqm_rssi_config) (struct wiphy *wiphy,struct net_device *dev,s32 rssi_thold, u32 rssi_hyst);
int (* set_cqm_txe_config) (struct wiphy *wiphy,struct net_device *dev,u32 rate, u32 pkts, u32 intvl);
void (* mgmt_frame_register) (struct wiphy *wiphy,struct wireless_dev *wdev,u16 frame_type, bool reg);
int (* set_antenna) (struct wiphy *wiphy, u32 tx_ant, u32 rx_ant);
int (* get_antenna) (struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant);
int (* sched_scan_start) (struct wiphy *wiphy,struct net_device *dev,struct cfg80211_sched_scan_request *request);
int (* sched_scan_stop) (struct wiphy *wiphy, struct net_device *dev);
int (* set_rekey_data) (struct wiphy *wiphy, struct net_device *dev,struct cfg80211_gtk_rekey_data *data);
int (* tdls_mgmt) (struct wiphy *wiphy, struct net_device *dev,const u8 *peer, u8 action_code, u8 dialog_token,u16 status_code, u32 peer_capability,bool initiator, const u8 *buf, size_t len);
int (* tdls_oper) (struct wiphy *wiphy, struct net_device *dev,const u8 *peer, enum nl80211_tdls_operation oper);
int (* probe_client) (struct wiphy *wiphy, struct net_device *dev,const u8 *peer, u64 *cookie);
int (* set_noack_map) (struct wiphy *wiphy,struct net_device *dev,u16 noack_map);
int (* get_channel) (struct wiphy *wiphy,struct wireless_dev *wdev,struct cfg80211_chan_def *chandef);
int (* start_p2p_device) (struct wiphy *wiphy,struct wireless_dev *wdev);
void (* stop_p2p_device) (struct wiphy *wiphy,struct wireless_dev *wdev);
int (* set_mac_acl) (struct wiphy *wiphy, struct net_device *dev,const struct cfg80211_acl_data *params);
int (* start_radar_detection) (struct wiphy *wiphy,struct net_device *dev,struct cfg80211_chan_def *chandef,u32 cac_time_ms);
int (* update_ft_ies) (struct wiphy *wiphy, struct net_device *dev,struct cfg80211_update_ft_ies_params *ftie);
int (* crit_proto_start) (struct wiphy *wiphy,struct wireless_dev *wdev,enum nl80211_crit_proto_id protocol,u16 duration);
void (* crit_proto_stop) (struct wiphy *wiphy,struct wireless_dev *wdev);
int (* set_coalesce) (struct wiphy *wiphy,struct cfg80211_coalesce *coalesce);
int (* channel_switch) (struct wiphy *wiphy,struct net_device *dev,struct cfg80211_csa_settings *params);
int (* set_qos_map) (struct wiphy *wiphy,struct net_device *dev,struct cfg80211_qos_map *qos_map);
int (* set_ap_chanwidth) (struct wiphy *wiphy, struct net_device *dev,struct cfg80211_chan_def *chandef);
int (* add_tx_ts) (struct wiphy *wiphy, struct net_device *dev,u8 tsid, const u8 *peer, u8 user_prio,u16 admitted_time);
int (* del_tx_ts) (struct wiphy *wiphy, struct net_device *dev,u8 tsid, const u8 *peer);
int (* tdls_channel_switch) (struct wiphy *wiphy,struct net_device *dev,const u8 *addr, u8 oper_class,struct cfg80211_chan_def *chandef);
void (* tdls_cancel_channel_switch) (struct wiphy *wiphy,struct net_device *dev,const u8 *addr);
int (* start_nan) (struct wiphy *wiphy, struct wireless_dev *wdev,struct cfg80211_nan_conf *conf);
void (* stop_nan) (struct wiphy *wiphy, struct wireless_dev *wdev);
int (* add_nan_func) (struct wiphy *wiphy, struct wireless_dev *wdev,struct cfg80211_nan_func *nan_func);
void (* del_nan_func) (struct wiphy *wiphy, struct wireless_dev *wdev,u64 cookie);
int (* nan_change_conf) (struct wiphy *wiphy,struct wireless_dev *wdev,struct cfg80211_nan_conf *conf,u32 changes);
int (* set_multicast_to_unicast) (struct wiphy *wiphy,struct net_device *dev,const bool enabled);
};
Members
Description
This struct is registered by fullmac card drivers and/or wireless stacks in order to handle configuration requests on their interfaces.
All callbacks except where otherwise noted should return 0 on success or a negative error code.
All operations are currently invoked under rtnl for consistency with the wireless extensions but this is subject to reevaluation as soon as this code is used more widely and we have a first user without wext.
describes virtual interface parameters
Definition
struct vif_params {
int use_4addr;
u8 macaddr[ETH_ALEN];
u8 vht_mumimo_groups[VHT_MUMIMO_GROUPS_DATA_LEN];
};
Members
key information
Definition
struct key_params {
const u8 * key;
const u8 * seq;
int key_len;
int seq_len;
u32 cipher;
};
Members
Description
Information about a key
survey information flags
Constants
Description
Used by the driver to indicate which info in struct survey_info it has filled in during the get_survey().
channel survey response
Definition
struct survey_info {
struct ieee80211_channel * channel;
u64 time;
u64 time_busy;
u64 time_ext_busy;
u64 time_rx;
u64 time_tx;
u64 time_scan;
u32 filled;
s8 noise;
};
Members
Description
Used by dump_survey() to report back per-channel survey information.
This structure can later be expanded with things like channel duty cycle etc.
beacon data
Definition
struct cfg80211_beacon_data {
const u8 * head;
const u8 * tail;
const u8 * beacon_ies;
const u8 * proberesp_ies;
const u8 * assocresp_ies;
const u8 * probe_resp;
size_t head_len;
size_t tail_len;
size_t beacon_ies_len;
size_t proberesp_ies_len;
size_t assocresp_ies_len;
size_t probe_resp_len;
};
Members
AP configuration
Definition
struct cfg80211_ap_settings {
struct cfg80211_chan_def chandef;
struct cfg80211_beacon_data beacon;
int beacon_interval;
int dtim_period;
const u8 * ssid;
size_t ssid_len;
enum nl80211_hidden_ssid hidden_ssid;
struct cfg80211_crypto_settings crypto;
bool privacy;
enum nl80211_auth_type auth_type;
enum nl80211_smps_mode smps_mode;
int inactivity_timeout;
u8 p2p_ctwindow;
bool p2p_opp_ps;
const struct cfg80211_acl_data * acl;
bool pbss;
struct cfg80211_bitrate_mask beacon_rate;
const struct ieee80211_ht_cap * ht_cap;
const struct ieee80211_vht_cap * vht_cap;
bool ht_required;
bool vht_required;
};
Members
Description
Used to configure an AP interface.
station parameters
Definition
struct station_parameters {
const u8 * supported_rates;
struct net_device * vlan;
u32 sta_flags_mask;
u32 sta_flags_set;
u32 sta_modify_mask;
int listen_interval;
u16 aid;
u16 peer_aid;
u8 supported_rates_len;
u8 plink_action;
u8 plink_state;
const struct ieee80211_ht_cap * ht_capa;
const struct ieee80211_vht_cap * vht_capa;
u8 uapsd_queues;
u8 max_sp;
enum nl80211_mesh_power_mode local_pm;
u16 capability;
const u8 * ext_capab;
u8 ext_capab_len;
const u8 * supported_channels;
u8 supported_channels_len;
const u8 * supported_oper_classes;
u8 supported_oper_classes_len;
u8 opmode_notif;
bool opmode_notif_used;
int support_p2p_ps;
};
Members
Description
Used to change and create a new station.
bitrate info flags
Constants
Description
Used by the driver to indicate the specific rate transmission type for 802.11n transmissions.
bitrate information
Definition
struct rate_info {
u8 flags;
u8 mcs;
u16 legacy;
u8 nss;
u8 bw;
};
Members
Description
Information about a receiving or transmitting bitrate
station information
Definition
struct station_info {
u64 filled;
u32 connected_time;
u32 inactive_time;
u64 rx_bytes;
u64 tx_bytes;
u16 llid;
u16 plid;
u8 plink_state;
s8 signal;
s8 signal_avg;
u8 chains;
s8 chain_signal[IEEE80211_MAX_CHAINS];
s8 chain_signal_avg[IEEE80211_MAX_CHAINS];
struct rate_info txrate;
struct rate_info rxrate;
u32 rx_packets;
u32 tx_packets;
u32 tx_retries;
u32 tx_failed;
u32 rx_dropped_misc;
struct sta_bss_parameters bss_param;
struct nl80211_sta_flag_update sta_flags;
int generation;
const u8 * assoc_req_ies;
size_t assoc_req_ies_len;
u32 beacon_loss_count;
s64 t_offset;
enum nl80211_mesh_power_mode local_pm;
enum nl80211_mesh_power_mode peer_pm;
enum nl80211_mesh_power_mode nonpeer_pm;
u32 expected_throughput;
u64 rx_beacon;
u64 rx_duration;
u8 rx_beacon_signal_avg;
struct cfg80211_tid_stats pertid[IEEE80211_NUM_TIDS + 1];
};
Members
Description
Station information filled by driver for get_station() and dump_station.
monitor flags
Constants
Description
Monitor interface configuration flags. Note that these must be the bits according to the nl80211 flags.
mesh path information flags
Constants
Description
Used by the driver to indicate which info in struct mpath_info it has filled in during get_station() or dump_station().
mesh path information
Definition
struct mpath_info {
u32 filled;
u32 frame_qlen;
u32 sn;
u32 metric;
u32 exptime;
u32 discovery_timeout;
u8 discovery_retries;
u8 flags;
int generation;
};
Members
Description
Mesh path information filled by driver for get_mpath() and dump_mpath().
BSS parameters
Definition
struct bss_parameters {
int use_cts_prot;
int use_short_preamble;
int use_short_slot_time;
const u8 * basic_rates;
u8 basic_rates_len;
int ap_isolate;
int ht_opmode;
s8 p2p_ctwindow;
s8 p2p_opp_ps;
};
Members
Description
Used to change BSS parameters (mainly for AP mode).
TX queue parameters
Definition
struct ieee80211_txq_params {
enum nl80211_ac ac;
u16 txop;
u16 cwmin;
u16 cwmax;
u8 aifs;
};
Members
Crypto settings
Definition
struct cfg80211_crypto_settings {
u32 wpa_versions;
u32 cipher_group;
int n_ciphers_pairwise;
u32 ciphers_pairwise[NL80211_MAX_NR_CIPHER_SUITES];
int n_akm_suites;
u32 akm_suites[NL80211_MAX_NR_AKM_SUITES];
bool control_port;
__be16 control_port_ethertype;
bool control_port_no_encrypt;
struct key_params * wep_keys;
int wep_tx_key;
};
Members
Authentication request data
Definition
struct cfg80211_auth_request {
struct cfg80211_bss * bss;
const u8 * ie;
size_t ie_len;
enum nl80211_auth_type auth_type;
const u8 * key;
u8 key_len;
u8 key_idx;
const u8 * auth_data;
size_t auth_data_len;
};
Members
Description
This structure provides information needed to complete IEEE 802.11 authentication.
(Re)Association request data
Definition
struct cfg80211_assoc_request {
struct cfg80211_bss * bss;
const u8 * ie;
const u8 * prev_bssid;
size_t ie_len;
struct cfg80211_crypto_settings crypto;
bool use_mfp;
u32 flags;
struct ieee80211_ht_cap ht_capa;
struct ieee80211_ht_cap ht_capa_mask;
struct ieee80211_vht_cap vht_capa;
struct ieee80211_vht_cap vht_capa_mask;
const u8 * fils_kek;
size_t fils_kek_len;
const u8 * fils_nonces;
};
Members
Description
This structure provides information needed to complete IEEE 802.11 (re)association.
Deauthentication request data
Definition
struct cfg80211_deauth_request {
const u8 * bssid;
const u8 * ie;
size_t ie_len;
u16 reason_code;
bool local_state_change;
};
Members
Description
This structure provides information needed to complete IEEE 802.11 deauthentication.
Disassociation request data
Definition
struct cfg80211_disassoc_request {
struct cfg80211_bss * bss;
const u8 * ie;
size_t ie_len;
u16 reason_code;
bool local_state_change;
};
Members
Description
This structure provides information needed to complete IEEE 802.11 disassociation.
IBSS parameters
Definition
struct cfg80211_ibss_params {
const u8 * ssid;
const u8 * bssid;
struct cfg80211_chan_def chandef;
const u8 * ie;
u8 ssid_len;
u8 ie_len;
u16 beacon_interval;
u32 basic_rates;
bool channel_fixed;
bool privacy;
bool control_port;
bool userspace_handles_dfs;
int mcast_rate[NUM_NL80211_BANDS];
struct ieee80211_ht_cap ht_capa;
struct ieee80211_ht_cap ht_capa_mask;
};
Members
Description
This structure defines the IBSS parameters for the join_ibss() method.
Connection parameters
Definition
struct cfg80211_connect_params {
struct ieee80211_channel * channel;
struct ieee80211_channel * channel_hint;
const u8 * bssid;
const u8 * bssid_hint;
const u8 * ssid;
size_t ssid_len;
enum nl80211_auth_type auth_type;
const u8 * ie;
size_t ie_len;
bool privacy;
enum nl80211_mfp mfp;
struct cfg80211_crypto_settings crypto;
const u8 * key;
u8 key_len;
u8 key_idx;
u32 flags;
int bg_scan_period;
struct ieee80211_ht_cap ht_capa;
struct ieee80211_ht_cap ht_capa_mask;
struct ieee80211_vht_cap vht_capa;
struct ieee80211_vht_cap vht_capa_mask;
bool pbss;
struct cfg80211_bss_selection bss_select;
const u8 * prev_bssid;
};
Members
Description
This structure provides information needed to complete IEEE 802.11 authentication and association.
PMK Security Association
Definition
struct cfg80211_pmksa {
const u8 * bssid;
const u8 * pmkid;
};
Members
Description
This structure is passed to the set/del_pmksa() method for PMKSA caching.
notification of processed MLME management frame
Parameters
Description
This function is called whenever an authentication, disassociation or deauthentication frame has been received and processed in station mode. After being asked to authenticate via cfg80211_ops::auth() the driver must call either this function or cfg80211_auth_timeout(). After being asked to associate via cfg80211_ops::assoc() the driver must call either this function or cfg80211_auth_timeout(). While connected, the driver must calls this for received and processed disassociation and deauthentication frames. If the frame couldn’t be used because it was unprotected, the driver must call the function cfg80211_rx_unprot_mlme_mgmt() instead.
This function may sleep. The caller must hold the corresponding wdev’s mutex.
notification of timed out authentication
Parameters
Description
This function may sleep. The caller must hold the corresponding wdev’s mutex.
notification of processed association response
Parameters
Description
After being asked to associate via cfg80211_ops::assoc() the driver must call either this function or cfg80211_auth_timeout().
This function may sleep. The caller must hold the corresponding wdev’s mutex.
notification of timed out association
Parameters
Description
This function may sleep. The caller must hold the corresponding wdev’s mutex.
notification of transmitted deauth/disassoc frame
Parameters
Description
This function is called whenever deauthentication has been processed in station mode. This includes both received deauthentication frames and locally generated ones. This function may sleep. The caller must hold the corresponding wdev’s mutex.
notify cfg80211 that device joined an IBSS
Parameters
Description
This function notifies cfg80211 that the device joined an IBSS or switched to a different BSSID. Before this function can be called, either a beacon has to have been received from the IBSS, or one of the cfg80211_inform_bss{,_frame} functions must have been called with the locally generated beacon – this guarantees that there is always a scan result for this IBSS. cfg80211 will handle the rest.
notify cfg80211 of connection result
Parameters
Description
It should be called by the underlying driver once execution of the connection request from connect() has been completed. This is similar to cfg80211_connect_bss() which allows the exact bss entry to be specified. Only one of these functions should be called.
notify cfg80211 of connection result
Parameters
Description
It should be called by the underlying driver once execution of the connection request from connect() has been completed. This is similar to cfg80211_connect_result(), but with the option of identifying the exact bss entry for the connection. Only one of these functions should be called.
notify cfg80211 of connection timeout
Parameters
Description
It should be called by the underlying driver whenever connect() has failed in a sequence where no explicit authentication/association rejection was received from the AP. This could happen, e.g., due to not being able to send out the Authentication or Association Request frame or timing out while waiting for the response.
notify cfg80211 of roaming
Parameters
Description
It should be called by the underlying driver whenever it roamed from one AP to another while connected.
notify cfg80211 that connection was dropped
Parameters
Description
After it calls this function, the driver should enter an idle state and not try to connect to any AP any more.
notification of remain_on_channel start
Parameters
remain_on_channel duration expired
Parameters
notify userspace about station
Parameters
notification of received, unprocessed management frame
Parameters
Description
This function is called whenever an Action frame is received for a station mode interface, but is not processed in kernel.
Return
true if a user space application has registered for this frame. For action frames, that makes it responsible for rejecting unrecognized action frames; false otherwise, in which case for action frames the driver is responsible for rejecting the frame.
notification of TX status for management frame
Parameters
Description
This function is called whenever a management frame was requested to be transmitted with cfg80211_ops::mgmt_tx() to report the TX status of the transmission attempt.
connection quality monitoring rssi event
Parameters
Description
This function is called when a configured connection quality monitoring rssi threshold reached event occurs.
notify userspace about packetloss to peer
Parameters
notification of Michael MIC failure (TKIP)
Parameters
Description
This function is called whenever the local MAC detects a MIC failure in a received frame. This matches with MLME-MICHAELMICFAILURE.:c:func:indication() primitive.
The scanning process itself is fairly simple, but cfg80211 offers quite a bit of helper functionality. To start a scan, the scan operation will be invoked with a scan definition. This scan definition contains the channels to scan, and the SSIDs to send probe requests for (including the wildcard, if desired). A passive scan is indicated by having no SSIDs to probe. Additionally, a scan request may contain extra information elements that should be added to the probe request. The IEs are guaranteed to be well-formed, and will not exceed the maximum length the driver advertised in the wiphy structure.
When scanning finds a BSS, cfg80211 needs to be notified of that, because it is responsible for maintaining the BSS list; the driver should not maintain a list itself. For this notification, various functions exist.
Since drivers do not maintain a BSS list, there are also a number of functions to search for a BSS and obtain information about it from the BSS structure cfg80211 maintains. The BSS list is also made available to userspace.
SSID description
Definition
struct cfg80211_ssid {
u8 ssid[IEEE80211_MAX_SSID_LEN];
u8 ssid_len;
};
Members
scan request description
Definition
struct cfg80211_scan_request {
struct cfg80211_ssid * ssids;
int n_ssids;
u32 n_channels;
enum nl80211_bss_scan_width scan_width;
const u8 * ie;
size_t ie_len;
u16 duration;
bool duration_mandatory;
u32 flags;
u32 rates[NUM_NL80211_BANDS];
struct wireless_dev * wdev;
u8 mac_addr[ETH_ALEN];
u8 mac_addr_mask[ETH_ALEN];
u8 bssid[ETH_ALEN];
struct wiphy * wiphy;
unsigned long scan_start;
struct cfg80211_scan_info info;
bool notified;
bool no_cck;
struct ieee80211_channel * channels[0];
};
Members
notify that scan finished
Parameters
BSS description
Definition
struct cfg80211_bss {
struct ieee80211_channel * channel;
enum nl80211_bss_scan_width scan_width;
const struct cfg80211_bss_ies __rcu * ies;
const struct cfg80211_bss_ies __rcu * beacon_ies;
const struct cfg80211_bss_ies __rcu * proberesp_ies;
struct cfg80211_bss * hidden_beacon_bss;
s32 signal;
u16 beacon_interval;
u16 capability;
u8 bssid[ETH_ALEN];
u8 priv[0];
};
Members
Description
This structure describes a BSS (which may also be a mesh network) for use in scan results and similar.
BSS inform data
Definition
struct cfg80211_inform_bss {
struct ieee80211_channel * chan;
enum nl80211_bss_scan_width scan_width;
s32 signal;
u64 boottime_ns;
u64 parent_tsf;
u8 parent_bssid[ETH_ALEN];
};
Members
inform cfg80211 of a received BSS frame
Parameters
Description
This informs cfg80211 that BSS information was found and the BSS should be updated/added.
Return
A referenced struct, must be released with cfg80211_put_bss()! Or NULL on error.
inform cfg80211 of a new BSS
Parameters
Description
This informs cfg80211 that BSS information was found and the BSS should be updated/added.
Return
A referenced struct, must be released with cfg80211_put_bss()! Or NULL on error.
unlink BSS from internal data structures
Parameters
Description
This function removes the given BSS from the internal data structures thereby making it no longer show up in scan results etc. Use this function when you detect a BSS is gone. Normally BSSes will also time out, so it is not necessary to use this function at all.
find information element in data
Parameters
Return
NULL if the element ID could not be found or if the element is invalid (claims to be longer than the given data), or a pointer to the first byte of the requested element, that is the byte containing the element ID.
Note
There are no checks on the element length other than having to fit into the given data.
find IE with given ID
Parameters
Description
Note that the return value is an RCU-protected pointer, so rcu_read_lock() must be held when calling this function.
Return
NULL if not found.
cfg80211 offers a number of utility functions that can be useful.
convert channel number to frequency
Parameters
Return
The corresponding frequency (in MHz), or 0 if the conversion failed.
convert frequency to channel number
Parameters
Return
The corresponding channel, or 0 if the conversion failed.
get channel struct from wiphy for specified frequency
Parameters
Return
The channel struct from wiphy at freq.
get basic rate for a given rate
Parameters
Return
The basic rate corresponding to a given bitrate, that is the next lower bitrate contained in the basic rate map, which is, for this function, given as a bitmap of indices of rates in the band’s bitrate table.
get header length in bytes from frame control
Parameters
Return
The header length in bytes.
get header length from data
Parameters
Description
Given an skb with a raw 802.11 header at the data pointer this function returns the 802.11 header length.
Return
The 802.11 header length in bytes (not including encryption headers). Or 0 if the data in the sk_buff is too short to contain a valid 802.11 header.
tracks walk thru present radiotap args
Definition
struct ieee80211_radiotap_iterator {
struct ieee80211_radiotap_header * _rtheader;
const struct ieee80211_radiotap_vendor_namespaces * _vns;
const struct ieee80211_radiotap_namespace * current_namespace;
unsigned char * _arg;
unsigned char * _next_ns_data;
__le32 * _next_bitmap;
unsigned char * this_arg;
int this_arg_index;
int this_arg_size;
int is_radiotap_ns;
int _max_length;
int _arg_index;
uint32_t _bitmap_shifter;
int _reset_on_ext;
};
Members
Description
Describes the radiotap parser state. Fields prefixed with an underscore must not be used by users of the parser, only by the parser internally.
In addition to generic utilities, cfg80211 also offers functions that help implement the data path for devices that do not do the 802.11/802.3 conversion on the device.
convert an 802.11 data frame to 802.3
Parameters
Return
0 on success. Non-zero on error.
convert an 802.3 frame to 802.11
Parameters
Return
0 on success, or a negative error code.
decode an IEEE 802.11n A-MSDU frame
Parameters
Description
Decode an IEEE 802.11 A-MSDU and convert it to a list of 802.3 frames. The list will be empty if the decode fails. The skb must be fully header-less before being passed in here; it is freed in this function.
determine the 802.1p/1d tag for a data frame
Parameters
Return
The 802.1p/1d tag.
TODO
driver hint to the wireless core a regulatory domain
Parameters
Description
Wireless drivers can use this function to hint to the wireless core what it believes should be the current regulatory domain by giving it an ISO/IEC 3166 alpha2 country code it knows its regulatory domain should be in or by providing a completely build regulatory domain. If the driver provides an ISO/IEC 3166 alpha2 userspace will be queried for a regulatory domain structure for the respective country.
The wiphy must have been registered to cfg80211 prior to this call. For cfg80211 drivers this means you must first use wiphy_register(), for mac80211 drivers you must first use ieee80211_register_hw().
Drivers should check the return value, its possible you can get an -ENOMEM.
Return
0 on success. -ENOMEM.
apply a custom driver regulatory domain
Parameters
Description
Drivers can sometimes have custom regulatory domains which do not apply to a specific country. Drivers can use this to apply such custom regulatory domains. This routine must be called prior to wiphy registration. The custom regulatory domain will be trusted completely and as such previous default channel settings will be disregarded. If no rule is found for a channel on the regulatory domain the channel will be disabled. Drivers using this for a wiphy should also set the wiphy flag REGULATORY_CUSTOM_REG or cfg80211 will set it for the wiphy that called this helper.
get regulatory information for the given frequency
Parameters
Description
Use this function to get the regulatory rule for a specific frequency on a given wireless device. If the device has a specific regulatory domain it wants to follow we respect that unless a country IE has been received and processed already.
Return
A valid pointer, or, when an error occurs, for example if no rule can be found, the return value is encoded using ERR_PTR(). Use IS_ERR() to check and PTR_ERR() to obtain the numeric return value. The numeric return value will be -ERANGE if we determine the given center_freq does not even have a regulatory rule for a frequency range in the center_freq’s band. See freq_in_rule_band() for our current definition of a band – this is purely subjective and right now it’s 802.11 specific.
RFkill integration in cfg80211 is almost invisible to drivers, as cfg80211 automatically registers an rfkill instance for each wireless device it knows about. Soft kill is also translated into disconnecting and turning all interfaces off, drivers are expected to turn off the device when all interfaces are down.
However, devices may have a hard RFkill line, in which case they also need to interact with the rfkill subsystem, via cfg80211. They can do this with a few helper functions documented here.
notify cfg80211 about hw block state
Parameters
Parameters
Parameters
Test mode is a set of utility functions to allow drivers to interact with driver-specific tools to aid, for instance, factory programming.
This chapter describes how drivers interact with it, for more information see the nl80211 book’s chapter on it.
allocate testmode reply
Parameters
Description
This function allocates and pre-fills an skb for a reply to the testmode command. Since it is intended for a reply, calling it outside of the testmode_cmd operation is invalid.
The returned skb is pre-filled with the wiphy index and set up in a way that any data that is put into the skb (with skb_put(), nla_put() or similar) will end up being within the NL80211_ATTR_TESTDATA attribute, so all that needs to be done with the skb is adding data for the corresponding userspace tool which can then read that data out of the testdata attribute. You must not modify the skb in any other way.
When done, call cfg80211_testmode_reply() with the skb and return its error code as the result of the testmode_cmd operation.
Return
An allocated and pre-filled skb. NULL if any errors happen.
send the reply skb
Parameters
Description
Since calling this function will usually be the last thing before returning from the testmode_cmd you should return the error code. Note that this function consumes the skb regardless of the return value.
Return
An error code or 0 on success.
allocate testmode event
Parameters
Description
This function allocates and pre-fills an skb for an event on the testmode multicast group.
The returned skb is set up in the same way as with cfg80211_testmode_alloc_reply_skb() but prepared for an event. As there, you should simply add data to it that will then end up in the NL80211_ATTR_TESTDATA attribute. Again, you must not modify the skb in any other way.
When done filling the skb, call cfg80211_testmode_event() with the skb to send the event.
Return
An allocated and pre-filled skb. NULL if any errors happen.
send the event
Parameters
Description
This function sends the given skb, which must have been allocated by cfg80211_testmode_alloc_event_skb(), as an event. It always consumes it.