Linux ieee80211_opsを読む

Linuxのieee80211_opsを読んでみました。

ieee80211_ops は Linux Kernelのmac80211とSoftMAC driver間のインターフェイスです。

![Untitled.png](https://qiita-image-store.s3.amazonaws.com/0/42120/cc41e90d-1c55-de8b-2254-9f89cb089ba6.png)

ieee80211_opsにもたくさんのメソッドがありますが、最低限必ず必要そうな関数を調べてみました。

# ソースコード
* https://github.com/torvalds/linux/blob/master/include/net/mac80211.h

# ieee80211_ops
## tx
* skbで指定したframeをcontrolの送信設定を使ってhwで送信する。

```
 * @tx: Handler that 802.11 module calls for each transmitted frame.
 *	skb contains the buffer starting from the IEEE 802.11 header.
 *	The low-level driver should send the frame out based on
 *	configuration in the TX control data. This handler should,
 *	preferably, never fail and stop queues appropriately.
 *	Must be atomic.
```
```
	void (*tx)(struct ieee80211_hw *hw,
		   struct ieee80211_tx_control *control,
		   struct sk_buff *skb);
```

## start
* hwの動作を開始する。

```
 * @start: Called before the first netdevice attached to the hardware
 *	is enabled. This should turn on the hardware and must turn on
 *	frame reception (for possibly enabled monitor interfaces.)
 *	Returns negative error codes, these may be seen in userspace,
 *	or zero.
 *	When the device is started it should not have a MAC address
 *	to avoid acknowledging frames before a non-monitor device
 *	is added.
 *	Must be implemented and can sleep.
```
```
	int (*start)(struct ieee80211_hw *hw);
```

## stop
* hwの動作を停止する。

```
 * @stop: Called after last netdevice attached to the hardware
 *	is disabled. This should turn off the hardware (at least
 *	it must turn off frame reception.)
 *	May be called right after add_interface if that rejects
 *	an interface. If you added any work onto the mac80211 workqueue
 *	you should ensure to cancel it on this callback.
 *	Must be implemented and can sleep.
```
```
	void (*stop)(struct ieee80211_hw *hw);
```
## add_interface
* hwにインターフェイスvifを追加する。

```
 * @add_interface: Called when a netdevice attached to the hardware is
 *	enabled. Because it is not called for monitor mode devices, @start
 *	and @stop must be implemented.
 *	The driver should perform any initialization it needs before
 *	the device can be enabled. The initial configuration for the
 *	interface is given in the conf parameter.
 *	The callback may refuse to add an interface by returning a
 *	negative error code (which will be seen in userspace.)
 *	Must be implemented and can sleep.
```
```
	int (*add_interface)(struct ieee80211_hw *hw,
			     struct ieee80211_vif *vif);
```

## remove_interface
* hwのインターフェイスvifを削除する。

```
 * @remove_interface: Notifies a driver that an interface is going down.
 *	The @stop callback is called after this if it is the last interface
 *	and no monitor interfaces are present.
 *	When all interfaces are removed, the MAC address in the hardware
 *	must be cleared so the device no longer acknowledges packets,
 *	the mac_addr member of the conf structure is, however, set to the
 *	MAC address of the device going away.
 *	Hence, this callback must be implemented. It can sleep.
```
```
	void (*remove_interface)(struct ieee80211_hw *hw,
				 struct ieee80211_vif *vif);
```
## config
* hwの設定を変更する。　changedのフラグの情報のみ変更する。 変更の情報はhw内にある。
* channelを変更する場合などに使う。

```
 * @config: Handler for configuration requests. IEEE 802.11 code calls this
 *	function to change hardware configuration, e.g., channel.
 *	This function should never fail but returns a negative error code
 *	if it does. The callback can sleep.
```
```
	int (*config)(struct ieee80211_hw *hw, u32 changed);
```
## bss_info_changed
* hwのインターフェイスvifにBSS設定infoの設定変更をする。

```
 * @bss_info_changed: Handler for configuration requests related to BSS
 *	parameters that may vary during BSS's lifespan, and may affect low
 *	level driver (e.g. assoc/disassoc status, erp parameters).
 *	This function should not be used if no BSS has been set, unless
 *	for association indication. The @changed parameter indicates which
 *	of the bss parameters has changed when a call is made. The callback
 *	can sleep.
```
```
	void (*bss_info_changed)(struct ieee80211_hw *hw,
				 struct ieee80211_vif *vif,
				 struct ieee80211_bss_conf *info,
				 u32 changed);
```
## conf_tx
* hw vifの送信キューの設定をする

```
 * @conf_tx: Configure TX queue parameters (EDCF (aifs, cw_min, cw_max),
 *	bursting) for a hardware TX queue.
 *	Returns a negative error code on failure.
 *	The callback can sleep.
```
```
	int (*conf_tx)(struct ieee80211_hw *hw,
		       struct ieee80211_vif *vif, u16 ac,
		       const struct ieee80211_tx_queue_params *params);
```
## configure_filter
* 受信filterの設定をする。

```
 * @configure_filter: Configure the device's RX filter.
 *	See the section "Frame filtering" for more information.
 *	This callback must be implemented and can sleep.
```
```
	void (*configure_filter)(struct ieee80211_hw *hw,
				 unsigned int changed_flags,
				 unsigned int *total_flags,
				 u64 multicast);
```