cfg80211: Expose TXQ stats and parameters to userspace
[platform/kernel/linux-rpi.git] / include / net / cfg80211.h
index fc40843..8db6071 100644 (file)
@@ -6,6 +6,7 @@
  * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net>
  * Copyright 2013-2014 Intel Mobile Communications GmbH
  * Copyright 2015-2017 Intel Deutschland GmbH
+ * Copyright (C) 2018 Intel Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -646,6 +647,8 @@ struct survey_info {
  *     allowed through even on unauthorized ports
  * @control_port_no_encrypt: TRUE to prevent encryption of control port
  *     protocol frames.
+ * @control_port_over_nl80211: TRUE if userspace expects to exchange control
+ *     port frames over NL80211 instead of the network interface.
  * @wep_keys: static WEP keys, if not NULL points to an array of
  *     CFG80211_MAX_WEP_KEYS WEP keys
  * @wep_tx_key: key index (0..3) of the default TX static WEP key
@@ -661,6 +664,7 @@ struct cfg80211_crypto_settings {
        bool control_port;
        __be16 control_port_ethertype;
        bool control_port_no_encrypt;
+       bool control_port_over_nl80211;
        struct key_params *wep_keys;
        int wep_tx_key;
        const u8 *psk;
@@ -1076,6 +1080,37 @@ struct sta_bss_parameters {
 };
 
 /**
+ * struct cfg80211_txq_stats - TXQ statistics for this TID
+ * @filled: bitmap of flags using the bits of &enum nl80211_txq_stats to
+ *     indicate the relevant values in this struct are filled
+ * @backlog_bytes: total number of bytes currently backlogged
+ * @backlog_packets: total number of packets currently backlogged
+ * @flows: number of new flows seen
+ * @drops: total number of packets dropped
+ * @ecn_marks: total number of packets marked with ECN CE
+ * @overlimit: number of drops due to queue space overflow
+ * @overmemory: number of drops due to memory limit overflow
+ * @collisions: number of hash collisions
+ * @tx_bytes: total number of bytes dequeued
+ * @tx_packets: total number of packets dequeued
+ * @max_flows: maximum number of flows supported
+ */
+struct cfg80211_txq_stats {
+       u32 filled;
+       u32 backlog_bytes;
+       u32 backlog_packets;
+       u32 flows;
+       u32 drops;
+       u32 ecn_marks;
+       u32 overlimit;
+       u32 overmemory;
+       u32 collisions;
+       u32 tx_bytes;
+       u32 tx_packets;
+       u32 max_flows;
+};
+
+/**
  * struct cfg80211_tid_stats - per-TID statistics
  * @filled: bitmap of flags using the bits of &enum nl80211_tid_stats to
  *     indicate the relevant values in this struct are filled
@@ -1084,6 +1119,7 @@ struct sta_bss_parameters {
  * @tx_msdu_retries: number of retries (not counting the first) for
  *     transmitted MSDUs
  * @tx_msdu_failed: number of failed transmitted MSDUs
+ * @txq_stats: TXQ statistics
  */
 struct cfg80211_tid_stats {
        u32 filled;
@@ -1091,6 +1127,7 @@ struct cfg80211_tid_stats {
        u64 tx_msdu;
        u64 tx_msdu_retries;
        u64 tx_msdu_failed;
+       struct cfg80211_txq_stats txq_stats;
 };
 
 #define IEEE80211_MAX_CHAINS   4
@@ -1148,6 +1185,8 @@ struct cfg80211_tid_stats {
  * @pertid: per-TID statistics, see &struct cfg80211_tid_stats, using the last
  *     (IEEE80211_NUM_TIDS) index for MSDUs not encapsulated in QoS-MPDUs.
  * @ack_signal: signal strength (in dBm) of the last ACK frame.
+ * @avg_ack_signal: average rssi value of ack packet for the no of msdu's has
+ *     been sent.
  */
 struct station_info {
        u64 filled;
@@ -1193,6 +1232,7 @@ struct station_info {
        u8 rx_beacon_signal_avg;
        struct cfg80211_tid_stats pertid[IEEE80211_NUM_TIDS + 1];
        s8 ack_signal;
+       s8 avg_ack_signal;
 };
 
 #if IS_ENABLED(CONFIG_CFG80211)
@@ -1450,6 +1490,8 @@ struct mesh_config {
  * @userspace_handles_dfs: whether user space controls DFS operation, i.e.
  *     changes the channel when a radar is detected. This is required
  *     to operate on DFS channels.
+ * @control_port_over_nl80211: TRUE if userspace expects to exchange control
+ *     port frames over NL80211 instead of the network interface.
  *
  * These parameters are fixed when the mesh is created.
  */
@@ -1472,6 +1514,7 @@ struct mesh_setup {
        u32 basic_rates;
        struct cfg80211_bitrate_mask beacon_rate;
        bool userspace_handles_dfs;
+       bool control_port_over_nl80211;
 };
 
 /**
@@ -2030,6 +2073,8 @@ struct cfg80211_disassoc_request {
  *     sets/clears %NL80211_STA_FLAG_AUTHORIZED. If true, the driver is
  *     required to assume that the port is unauthorized until authorized by
  *     user space. Otherwise, port is marked authorized by default.
+ * @control_port_over_nl80211: TRUE if userspace expects to exchange control
+ *     port frames over NL80211 instead of the network interface.
  * @userspace_handles_dfs: whether user space controls DFS operation, i.e.
  *     changes the channel when a radar is detected. This is required
  *     to operate on DFS channels.
@@ -2053,6 +2098,7 @@ struct cfg80211_ibss_params {
        bool channel_fixed;
        bool privacy;
        bool control_port;
+       bool control_port_over_nl80211;
        bool userspace_handles_dfs;
        int mcast_rate[NUM_NL80211_BANDS];
        struct ieee80211_ht_cap ht_capa;
@@ -2191,6 +2237,9 @@ enum cfg80211_connect_params_changed {
  * @WIPHY_PARAM_RTS_THRESHOLD: wiphy->rts_threshold has changed
  * @WIPHY_PARAM_COVERAGE_CLASS: coverage class changed
  * @WIPHY_PARAM_DYN_ACK: dynack has been enabled
+ * @WIPHY_PARAM_TXQ_LIMIT: TXQ packet limit has been changed
+ * @WIPHY_PARAM_TXQ_MEMORY_LIMIT: TXQ memory limit has been changed
+ * @WIPHY_PARAM_TXQ_QUANTUM: TXQ scheduler quantum
  */
 enum wiphy_params_flags {
        WIPHY_PARAM_RETRY_SHORT         = 1 << 0,
@@ -2199,6 +2248,9 @@ enum wiphy_params_flags {
        WIPHY_PARAM_RTS_THRESHOLD       = 1 << 3,
        WIPHY_PARAM_COVERAGE_CLASS      = 1 << 4,
        WIPHY_PARAM_DYN_ACK             = 1 << 5,
+       WIPHY_PARAM_TXQ_LIMIT           = 1 << 6,
+       WIPHY_PARAM_TXQ_MEMORY_LIMIT    = 1 << 7,
+       WIPHY_PARAM_TXQ_QUANTUM         = 1 << 8,
 };
 
 /**
@@ -2951,6 +3003,9 @@ struct cfg80211_external_auth_params {
  *
  * @set_multicast_to_unicast: configure multicast to unicast conversion for BSS
  *
+ * @get_txq_stats: Get TXQ stats for interface or phy. If wdev is %NULL, this
+ *      function should return phy stats, and interface stats otherwise.
+ *
  * @set_pmk: configure the PMK to be used for offloaded 802.1X 4-Way handshake.
  *     If not deleted through @del_pmk the PMK remains valid until disconnect
  *     upon which the driver should clear it.
@@ -2960,6 +3015,9 @@ struct cfg80211_external_auth_params {
  *
  * @external_auth: indicates result of offloaded authentication processing from
  *     user space
+ *
+ * @tx_control_port: TX a control port frame (EAPoL).  The noencrypt parameter
+ *     tells the driver that the frame should not be encrypted.
  */
 struct cfg80211_ops {
        int     (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow);
@@ -3249,12 +3307,22 @@ struct cfg80211_ops {
                                            struct net_device *dev,
                                            const bool enabled);
 
+       int     (*get_txq_stats)(struct wiphy *wiphy,
+                                struct wireless_dev *wdev,
+                                struct cfg80211_txq_stats *txqstats);
+
        int     (*set_pmk)(struct wiphy *wiphy, struct net_device *dev,
                           const struct cfg80211_pmk_conf *conf);
        int     (*del_pmk)(struct wiphy *wiphy, struct net_device *dev,
                           const u8 *aa);
        int     (*external_auth)(struct wiphy *wiphy, struct net_device *dev,
                                 struct cfg80211_external_auth_params *params);
+
+       int     (*tx_control_port)(struct wiphy *wiphy,
+                                  struct net_device *dev,
+                                  const u8 *buf, size_t len,
+                                  const u8 *dest, const __be16 proto,
+                                  const bool noencrypt);
 };
 
 /*
@@ -3572,15 +3640,15 @@ enum wiphy_opmode_flag {
 /**
  * struct sta_opmode_info - Station's ht/vht operation mode information
  * @changed: contains value from &enum wiphy_opmode_flag
- * @smps_mode: New SMPS mode of a station
- * @bw: new max bandwidth value of a station
+ * @smps_mode: New SMPS mode value from &enum nl80211_smps_mode of a station
+ * @bw: new max bandwidth value from &enum nl80211_chan_width of a station
  * @rx_nss: new rx_nss value of a station
  */
 
 struct sta_opmode_info {
        u32 changed;
-       u8 smps_mode;
-       u8 bw;
+       enum nl80211_smps_mode smps_mode;
+       enum nl80211_chan_width bw;
        u8 rx_nss;
 };
 
@@ -3921,6 +3989,10 @@ struct wiphy {
 
        u8 nan_supported_bands;
 
+       u32 txq_limit;
+       u32 txq_memory_limit;
+       u32 txq_quantum;
+
        char priv[0] __aligned(NETDEV_ALIGN);
 };
 
@@ -4657,6 +4729,33 @@ const struct ieee80211_reg_rule *freq_reg_info(struct wiphy *wiphy,
  */
 const char *reg_initiator_name(enum nl80211_reg_initiator initiator);
 
+/**
+ * DOC: Internal regulatory db functions
+ *
+ */
+
+/**
+ * reg_query_regdb_wmm -  Query internal regulatory db for wmm rule
+ * Regulatory self-managed driver can use it to proactively
+ *
+ * @alpha2: the ISO/IEC 3166 alpha2 wmm rule to be queried.
+ * @freq: the freqency(in MHz) to be queried.
+ * @ptr: pointer where the regdb wmm data is to be stored (or %NULL if
+ *     irrelevant). This can be used later for deduplication.
+ * @rule: pointer to store the wmm rule from the regulatory db.
+ *
+ * Self-managed wireless drivers can use this function to  query
+ * the internal regulatory database to check whether the given
+ * ISO/IEC 3166 alpha2 country and freq have wmm rule limitations.
+ *
+ * Drivers should check the return value, its possible you can get
+ * an -ENODATA.
+ *
+ * Return: 0 on success. -ENODATA.
+ */
+int reg_query_regdb_wmm(char *alpha2, int freq, u32 *ptr,
+                       struct ieee80211_wmm_rule *rule);
+
 /*
  * callbacks for asynchronous cfg80211 methods, notification
  * functions and BSS handling helpers
@@ -5694,6 +5793,28 @@ void cfg80211_mgmt_tx_status(struct wireless_dev *wdev, u64 cookie,
 
 
 /**
+ * cfg80211_rx_control_port - notification about a received control port frame
+ * @dev: The device the frame matched to
+ * @buf: control port frame
+ * @len: length of the frame data
+ * @addr: The peer from which the frame was received
+ * @proto: frame protocol, typically PAE or Pre-authentication
+ * @unencrypted: Whether the frame was received unencrypted
+ *
+ * This function is used to inform userspace about a received control port
+ * frame.  It should only be used if userspace indicated it wants to receive
+ * control port frames over nl80211.
+ *
+ * The frame is the data portion of the 802.3 or 802.11 data frame with all
+ * network layer headers removed (e.g. the raw EAPoL frame).
+ *
+ * Return: %true if the frame was passed to userspace
+ */
+bool cfg80211_rx_control_port(struct net_device *dev,
+                             const u8 *buf, size_t len,
+                             const u8 *addr, u16 proto, bool unencrypted);
+
+/**
  * cfg80211_cqm_rssi_notify - connection quality monitoring rssi event
  * @dev: network device
  * @rssi_event: the triggered RSSI event