xref: /freebsd/sys/contrib/dev/iwlwifi/mvm/rs.h (revision ec965063070e5753c166cf592c9336444b74720a)
1 /*-
2  * Copyright (c) 2020-2021 The FreeBSD Foundation
3  *
4  * This software was developed by Björn Zeeb under sponsorship from
5  * the FreeBSD Foundation.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  *
28  * $FreeBSD$
29  */
30 
31 /*
32  * XXX-BZ:
33  * This file is left as a wrapper to make mvm compile and we will only
34  * deal with it on a need basis.  Most newer chipsets do this in firmware.
35  */
36 
37 #ifndef	_IWLWIFI_MVM_RS_H
38 #define	_IWLWIFI_MVM_RS_H
39 
40 #include <net/mac80211.h>
41 
42 #include "iwl-trans.h"
43 #include "fw-api.h"
44 
45 #define	RS_NAME		"XXX_unknown"
46 
47 #define	LINK_QUAL_AGG_FRAME_LIMIT_DEF		(64-1)
48 #define	LINK_QUAL_AGG_FRAME_LIMIT_GEN2_DEF	(256-1)
49 
50 struct iwl_mvm;
51 
52 struct iwl_lq_sta_rs_fw {
53 	int	last_rate_n_flags;
54 	struct {
55 		struct iwl_mvm	*drv;
56 		uint8_t		sta_id;
57 		uint8_t		chains;
58 		uint8_t		chain_signal[IEEE80211_MAX_CHAINS];
59 		uint8_t		last_rssi;
60 #ifdef CONFIG_MAC80211_DEBUGFS
61 		uint32_t	dbg_fixed_rate;
62 		uint32_t	dbg_agg_frame_count_lim;
63 #endif
64 	} pers;
65 };
66 
67 struct iwl_lq_sta {
68 	struct iwl_lq_cmd	lq;
69 	struct {
70 		spinlock_t	lock;
71 	} pers;
72 };
73 
74 #define	RS_DRV_DATA_PACK(_c, _f)	((void *)(uintptr_t)(_c | (uintptr_t)(_f) << sizeof(_c)))	/* XXX TODO | ? */
75 
76 struct iwl_mvm_sta;
77 
78 #ifdef CONFIG_IWLWIFI_DEBUGFS
79 void iwl_mvm_reset_frame_stats(struct iwl_mvm *);
80 #endif
81 
82 void iwl_mvm_rs_add_sta(struct iwl_mvm *, struct iwl_mvm_sta *);
83 void iwl_mvm_tlc_update_notif(struct iwl_mvm *, struct iwl_rx_cmd_buffer *);
84 u16 rs_fw_get_max_amsdu_len(struct ieee80211_sta *);
85 void rs_fw_rate_init(struct iwl_mvm *, struct ieee80211_sta *,
86     enum nl80211_band, bool);
87 int rs_fw_tx_protection(struct iwl_mvm *, struct iwl_mvm_sta *, bool);
88 int iwl_mvm_tx_protection(struct iwl_mvm *, struct iwl_mvm_sta *, bool);
89 
90 int iwl_mvm_rate_control_register(void);
91 void iwl_mvm_rate_control_unregister(void);
92 void iwl_mvm_rs_rate_init(struct iwl_mvm *, struct ieee80211_sta *,
93     enum nl80211_band, bool);
94 void iwl_mvm_rs_tx_status(struct iwl_mvm *, struct ieee80211_sta *,
95     int, struct ieee80211_tx_info *, bool);
96 
97 #endif	/* _IWLWIFI_MVM_RS_H */
98