Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * mac80211_hwsim - software simulator of 802.11 radio(s) for mac80211
0004  * Copyright (c) 2008, Jouni Malinen <j@w1.fi>
0005  * Copyright (c) 2011, Javier Lopez <jlopex@gmail.com>
0006  * Copyright (C) 2020, 2022 Intel Corporation
0007  */
0008 
0009 #ifndef __MAC80211_HWSIM_H
0010 #define __MAC80211_HWSIM_H
0011 
0012 /**
0013  * enum hwsim_tx_control_flags - flags to describe transmission info/status
0014  *
0015  * These flags are used to give the wmediumd extra information in order to
0016  * modify its behavior for each frame
0017  *
0018  * @HWSIM_TX_CTL_REQ_TX_STATUS: require TX status callback for this frame.
0019  * @HWSIM_TX_CTL_NO_ACK: tell the wmediumd not to wait for an ack
0020  * @HWSIM_TX_STAT_ACK: Frame was acknowledged
0021  *
0022  */
0023 enum hwsim_tx_control_flags {
0024     HWSIM_TX_CTL_REQ_TX_STATUS      = BIT(0),
0025     HWSIM_TX_CTL_NO_ACK         = BIT(1),
0026     HWSIM_TX_STAT_ACK           = BIT(2),
0027 };
0028 
0029 /**
0030  * DOC: Frame transmission/registration support
0031  *
0032  * Frame transmission and registration support exists to allow userspace
0033  * entities such as wmediumd to receive and process all broadcasted
0034  * frames from a mac80211_hwsim radio device.
0035  *
0036  * This allow user space applications to decide if the frame should be
0037  * dropped or not and implement a wireless medium simulator at user space.
0038  *
0039  * Registration is done by sending a register message to the driver and
0040  * will be automatically unregistered if the user application doesn't
0041  * responds to sent frames.
0042  * Once registered the user application has to take responsibility of
0043  * broadcasting the frames to all listening mac80211_hwsim radio
0044  * interfaces.
0045  *
0046  * For more technical details, see the corresponding command descriptions
0047  * below.
0048  */
0049 
0050 /**
0051  * enum hwsim_commands - supported hwsim commands
0052  *
0053  * @HWSIM_CMD_UNSPEC: unspecified command to catch errors
0054  *
0055  * @HWSIM_CMD_REGISTER: request to register and received all broadcasted
0056  *  frames by any mac80211_hwsim radio device.
0057  * @HWSIM_CMD_FRAME: send/receive a broadcasted frame from/to kernel/user
0058  *  space, uses:
0059  *  %HWSIM_ATTR_ADDR_TRANSMITTER, %HWSIM_ATTR_ADDR_RECEIVER,
0060  *  %HWSIM_ATTR_FRAME, %HWSIM_ATTR_FLAGS, %HWSIM_ATTR_RX_RATE,
0061  *  %HWSIM_ATTR_SIGNAL, %HWSIM_ATTR_COOKIE, %HWSIM_ATTR_FREQ (optional)
0062  * @HWSIM_CMD_TX_INFO_FRAME: Transmission info report from user space to
0063  *  kernel, uses:
0064  *  %HWSIM_ATTR_ADDR_TRANSMITTER, %HWSIM_ATTR_FLAGS,
0065  *  %HWSIM_ATTR_TX_INFO, %WSIM_ATTR_TX_INFO_FLAGS,
0066  *  %HWSIM_ATTR_SIGNAL, %HWSIM_ATTR_COOKIE
0067  * @HWSIM_CMD_NEW_RADIO: create a new radio with the given parameters,
0068  *  returns the radio ID (>= 0) or negative on errors, if successful
0069  *  then multicast the result, uses optional parameter:
0070  *  %HWSIM_ATTR_REG_STRICT_REG, %HWSIM_ATTR_SUPPORT_P2P_DEVICE,
0071  *  %HWSIM_ATTR_DESTROY_RADIO_ON_CLOSE, %HWSIM_ATTR_CHANNELS,
0072  *  %HWSIM_ATTR_NO_VIF, %HWSIM_ATTR_RADIO_NAME, %HWSIM_ATTR_USE_CHANCTX,
0073  *  %HWSIM_ATTR_REG_HINT_ALPHA2, %HWSIM_ATTR_REG_CUSTOM_REG,
0074  *  %HWSIM_ATTR_PERM_ADDR
0075  * @HWSIM_CMD_DEL_RADIO: destroy a radio, reply is multicasted
0076  * @HWSIM_CMD_GET_RADIO: fetch information about existing radios, uses:
0077  *  %HWSIM_ATTR_RADIO_ID
0078  * @HWSIM_CMD_ADD_MAC_ADDR: add a receive MAC address (given in the
0079  *  %HWSIM_ATTR_ADDR_RECEIVER attribute) to a device identified by
0080  *  %HWSIM_ATTR_ADDR_TRANSMITTER. This lets wmediumd forward frames
0081  *  to this receiver address for a given station.
0082  * @HWSIM_CMD_DEL_MAC_ADDR: remove the MAC address again, the attributes
0083  *  are the same as to @HWSIM_CMD_ADD_MAC_ADDR.
0084  * @__HWSIM_CMD_MAX: enum limit
0085  */
0086 enum {
0087     HWSIM_CMD_UNSPEC,
0088     HWSIM_CMD_REGISTER,
0089     HWSIM_CMD_FRAME,
0090     HWSIM_CMD_TX_INFO_FRAME,
0091     HWSIM_CMD_NEW_RADIO,
0092     HWSIM_CMD_DEL_RADIO,
0093     HWSIM_CMD_GET_RADIO,
0094     HWSIM_CMD_ADD_MAC_ADDR,
0095     HWSIM_CMD_DEL_MAC_ADDR,
0096     __HWSIM_CMD_MAX,
0097 };
0098 #define HWSIM_CMD_MAX (_HWSIM_CMD_MAX - 1)
0099 
0100 #define HWSIM_CMD_CREATE_RADIO   HWSIM_CMD_NEW_RADIO
0101 #define HWSIM_CMD_DESTROY_RADIO  HWSIM_CMD_DEL_RADIO
0102 
0103 /**
0104  * enum hwsim_attrs - hwsim netlink attributes
0105  *
0106  * @HWSIM_ATTR_UNSPEC: unspecified attribute to catch errors
0107  *
0108  * @HWSIM_ATTR_ADDR_RECEIVER: MAC address of the radio device that
0109  *  the frame is broadcasted to
0110  * @HWSIM_ATTR_ADDR_TRANSMITTER: MAC address of the radio device that
0111  *  the frame was broadcasted from
0112  * @HWSIM_ATTR_FRAME: Data array
0113  * @HWSIM_ATTR_FLAGS: mac80211 transmission flags, used to process
0114     properly the frame at user space
0115  * @HWSIM_ATTR_RX_RATE: estimated rx rate index for this frame at user
0116     space
0117  * @HWSIM_ATTR_SIGNAL: estimated RX signal for this frame at user
0118     space
0119  * @HWSIM_ATTR_TX_INFO: ieee80211_tx_rate array
0120  * @HWSIM_ATTR_COOKIE: sk_buff cookie to identify the frame
0121  * @HWSIM_ATTR_CHANNELS: u32 attribute used with the %HWSIM_CMD_CREATE_RADIO
0122  *  command giving the number of channels supported by the new radio
0123  * @HWSIM_ATTR_RADIO_ID: u32 attribute used with %HWSIM_CMD_DESTROY_RADIO
0124  *  only to destroy a radio
0125  * @HWSIM_ATTR_REG_HINT_ALPHA2: alpha2 for regulatoro driver hint
0126  *  (nla string, length 2)
0127  * @HWSIM_ATTR_REG_CUSTOM_REG: custom regulatory domain index (u32 attribute)
0128  * @HWSIM_ATTR_REG_STRICT_REG: request REGULATORY_STRICT_REG (flag attribute)
0129  * @HWSIM_ATTR_SUPPORT_P2P_DEVICE: support P2P Device virtual interface (flag)
0130  * @HWSIM_ATTR_USE_CHANCTX: used with the %HWSIM_CMD_CREATE_RADIO
0131  *  command to force use of channel contexts even when only a
0132  *  single channel is supported
0133  * @HWSIM_ATTR_DESTROY_RADIO_ON_CLOSE: used with the %HWSIM_CMD_CREATE_RADIO
0134  *  command to force radio removal when process that created the radio dies
0135  * @HWSIM_ATTR_RADIO_NAME: Name of radio, e.g. phy666
0136  * @HWSIM_ATTR_NO_VIF:  Do not create vif (wlanX) when creating radio.
0137  * @HWSIM_ATTR_FREQ: Frequency at which packet is transmitted or received.
0138  * @HWSIM_ATTR_TX_INFO_FLAGS: additional flags for corresponding
0139  *  rates of %HWSIM_ATTR_TX_INFO
0140  * @HWSIM_ATTR_PERM_ADDR: permanent mac address of new radio
0141  * @HWSIM_ATTR_IFTYPE_SUPPORT: u32 attribute of supported interface types bits
0142  * @HWSIM_ATTR_CIPHER_SUPPORT: u32 array of supported cipher types
0143  * @HWSIM_ATTR_MLO_SUPPORT: claim MLO support (exact parameters TBD) for
0144  *  the new radio
0145  * @__HWSIM_ATTR_MAX: enum limit
0146  */
0147 
0148 
0149 enum {
0150     HWSIM_ATTR_UNSPEC,
0151     HWSIM_ATTR_ADDR_RECEIVER,
0152     HWSIM_ATTR_ADDR_TRANSMITTER,
0153     HWSIM_ATTR_FRAME,
0154     HWSIM_ATTR_FLAGS,
0155     HWSIM_ATTR_RX_RATE,
0156     HWSIM_ATTR_SIGNAL,
0157     HWSIM_ATTR_TX_INFO,
0158     HWSIM_ATTR_COOKIE,
0159     HWSIM_ATTR_CHANNELS,
0160     HWSIM_ATTR_RADIO_ID,
0161     HWSIM_ATTR_REG_HINT_ALPHA2,
0162     HWSIM_ATTR_REG_CUSTOM_REG,
0163     HWSIM_ATTR_REG_STRICT_REG,
0164     HWSIM_ATTR_SUPPORT_P2P_DEVICE,
0165     HWSIM_ATTR_USE_CHANCTX,
0166     HWSIM_ATTR_DESTROY_RADIO_ON_CLOSE,
0167     HWSIM_ATTR_RADIO_NAME,
0168     HWSIM_ATTR_NO_VIF,
0169     HWSIM_ATTR_FREQ,
0170     HWSIM_ATTR_PAD,
0171     HWSIM_ATTR_TX_INFO_FLAGS,
0172     HWSIM_ATTR_PERM_ADDR,
0173     HWSIM_ATTR_IFTYPE_SUPPORT,
0174     HWSIM_ATTR_CIPHER_SUPPORT,
0175     HWSIM_ATTR_MLO_SUPPORT,
0176     __HWSIM_ATTR_MAX,
0177 };
0178 #define HWSIM_ATTR_MAX (__HWSIM_ATTR_MAX - 1)
0179 
0180 /**
0181  * struct hwsim_tx_rate - rate selection/status
0182  *
0183  * @idx: rate index to attempt to send with
0184  * @count: number of tries in this rate before going to the next rate
0185  *
0186  * A value of -1 for @idx indicates an invalid rate and, if used
0187  * in an array of retry rates, that no more rates should be tried.
0188  *
0189  * When used for transmit status reporting, the driver should
0190  * always report the rate and number of retries used.
0191  *
0192  */
0193 struct hwsim_tx_rate {
0194     s8 idx;
0195     u8 count;
0196 } __packed;
0197 
0198 /**
0199  * enum hwsim_tx_rate_flags - per-rate flags set by the rate control algorithm.
0200  *  Inspired by structure mac80211_rate_control_flags. New flags may be
0201  *  appended, but old flags not deleted, to keep compatibility for
0202  *  userspace.
0203  *
0204  * These flags are set by the Rate control algorithm for each rate during tx,
0205  * in the @flags member of struct ieee80211_tx_rate.
0206  *
0207  * @MAC80211_HWSIM_TX_RC_USE_RTS_CTS: Use RTS/CTS exchange for this rate.
0208  * @MAC80211_HWSIM_TX_RC_USE_CTS_PROTECT: CTS-to-self protection is required.
0209  *  This is set if the current BSS requires ERP protection.
0210  * @MAC80211_HWSIM_TX_RC_USE_SHORT_PREAMBLE: Use short preamble.
0211  * @MAC80211_HWSIM_TX_RC_MCS: HT rate.
0212  * @MAC80211_HWSIM_TX_RC_VHT_MCS: VHT MCS rate, in this case the idx field is
0213  *  split into a higher 4 bits (Nss) and lower 4 bits (MCS number)
0214  * @MAC80211_HWSIM_TX_RC_GREEN_FIELD: Indicates whether this rate should be used
0215  *  in Greenfield mode.
0216  * @MAC80211_HWSIM_TX_RC_40_MHZ_WIDTH: Indicates if the Channel Width should be
0217  *  40 MHz.
0218  * @MAC80211_HWSIM_TX_RC_80_MHZ_WIDTH: Indicates 80 MHz transmission
0219  * @MAC80211_HWSIM_TX_RC_160_MHZ_WIDTH: Indicates 160 MHz transmission
0220  *  (80+80 isn't supported yet)
0221  * @MAC80211_HWSIM_TX_RC_DUP_DATA: The frame should be transmitted on both of
0222  *  the adjacent 20 MHz channels, if the current channel type is
0223  *  NL80211_CHAN_HT40MINUS or NL80211_CHAN_HT40PLUS.
0224  * @MAC80211_HWSIM_TX_RC_SHORT_GI: Short Guard interval should be used for this
0225  *  rate.
0226  */
0227 enum hwsim_tx_rate_flags {
0228     MAC80211_HWSIM_TX_RC_USE_RTS_CTS        = BIT(0),
0229     MAC80211_HWSIM_TX_RC_USE_CTS_PROTECT        = BIT(1),
0230     MAC80211_HWSIM_TX_RC_USE_SHORT_PREAMBLE = BIT(2),
0231 
0232     /* rate index is an HT/VHT MCS instead of an index */
0233     MAC80211_HWSIM_TX_RC_MCS            = BIT(3),
0234     MAC80211_HWSIM_TX_RC_GREEN_FIELD        = BIT(4),
0235     MAC80211_HWSIM_TX_RC_40_MHZ_WIDTH       = BIT(5),
0236     MAC80211_HWSIM_TX_RC_DUP_DATA       = BIT(6),
0237     MAC80211_HWSIM_TX_RC_SHORT_GI       = BIT(7),
0238     MAC80211_HWSIM_TX_RC_VHT_MCS            = BIT(8),
0239     MAC80211_HWSIM_TX_RC_80_MHZ_WIDTH       = BIT(9),
0240     MAC80211_HWSIM_TX_RC_160_MHZ_WIDTH      = BIT(10),
0241 };
0242 
0243 /**
0244  * struct hwsim_tx_rate - rate selection/status
0245  *
0246  * @idx: rate index to attempt to send with
0247  * @count: number of tries in this rate before going to the next rate
0248  *
0249  * A value of -1 for @idx indicates an invalid rate and, if used
0250  * in an array of retry rates, that no more rates should be tried.
0251  *
0252  * When used for transmit status reporting, the driver should
0253  * always report the rate and number of retries used.
0254  *
0255  */
0256 struct hwsim_tx_rate_flag {
0257     s8 idx;
0258     u16 flags;
0259 } __packed;
0260 
0261 /**
0262  * DOC: Frame transmission support over virtio
0263  *
0264  * Frame transmission is also supported over virtio to allow communication
0265  * with external entities.
0266  */
0267 
0268 /**
0269  * enum hwsim_vqs - queues for virtio frame transmission
0270  *
0271  * @HWSIM_VQ_TX: send frames to external entity
0272  * @HWSIM_VQ_RX: receive frames and transmission info reports
0273  * @HWSIM_NUM_VQS: enum limit
0274  */
0275 enum {
0276     HWSIM_VQ_TX,
0277     HWSIM_VQ_RX,
0278     HWSIM_NUM_VQS,
0279 };
0280 #endif /* __MAC80211_HWSIM_H */