xref: /freebsd/sys/contrib/dev/iwlwifi/mvm/rs.h (revision 8ddb146abcdf061be9f2c0db7e391697dafad85c)
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 		u8		sta_id;
57 		u8		chains;
58 		u8		chain_signal[IEEE80211_MAX_CHAINS];
59 		u8		last_rssi;
60 	} pers;
61 };
62 
63 struct iwl_lq_sta {
64 	struct iwl_lq_cmd	lq;
65 	struct {
66 		spinlock_t	lock;
67 	} pers;
68 };
69 
70 #define	RS_DRV_DATA_PACK(_c, _f)	((void *)(uintptr_t)(_c | (uintptr_t)(_f) << sizeof(_c)))	/* XXX TODO | ? */
71 
72 struct iwl_mvm_sta;
73 
74 void iwl_mvm_rs_add_sta(struct iwl_mvm *, struct iwl_mvm_sta *);
75 void iwl_mvm_tlc_update_notif(struct iwl_mvm *, struct iwl_rx_cmd_buffer *);
76 u16 rs_fw_get_max_amsdu_len(struct ieee80211_sta *);
77 void rs_fw_rate_init(struct iwl_mvm *, struct ieee80211_sta *,
78     enum nl80211_band, bool);
79 int rs_fw_tx_protection(struct iwl_mvm *, struct iwl_mvm_sta *, bool);
80 int iwl_mvm_tx_protection(struct iwl_mvm *, struct iwl_mvm_sta *, bool);
81 
82 int iwl_mvm_rate_control_register(void);
83 void iwl_mvm_rate_control_unregister(void);
84 void iwl_mvm_rs_rate_init(struct iwl_mvm *, struct ieee80211_sta *,
85     enum nl80211_band, bool);
86 void iwl_mvm_rs_tx_status(struct iwl_mvm *, struct ieee80211_sta *,
87     int, struct ieee80211_tx_info *, bool);
88 
89 #endif	/* _IWLWIFI_MVM_RS_H */
90