xref: /freebsd/sys/contrib/dev/iwlwifi/fw/api/binding.h (revision bfcc09ddd422c95a1a2e4e794b63ee54c4902398)
1*bfcc09ddSBjoern A. Zeeb /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2*bfcc09ddSBjoern A. Zeeb /*
3*bfcc09ddSBjoern A. Zeeb  * Copyright (C) 2012-2014, 2020 Intel Corporation
4*bfcc09ddSBjoern A. Zeeb  * Copyright (C) 2013-2015 Intel Mobile Communications GmbH
5*bfcc09ddSBjoern A. Zeeb  * Copyright (C) 2016-2017 Intel Deutschland GmbH
6*bfcc09ddSBjoern A. Zeeb  */
7*bfcc09ddSBjoern A. Zeeb #ifndef __iwl_fw_api_binding_h__
8*bfcc09ddSBjoern A. Zeeb #define __iwl_fw_api_binding_h__
9*bfcc09ddSBjoern A. Zeeb 
10*bfcc09ddSBjoern A. Zeeb #include <fw/file.h>
11*bfcc09ddSBjoern A. Zeeb #include <fw/img.h>
12*bfcc09ddSBjoern A. Zeeb 
13*bfcc09ddSBjoern A. Zeeb #define MAX_MACS_IN_BINDING	(3)
14*bfcc09ddSBjoern A. Zeeb #define MAX_BINDINGS		(4)
15*bfcc09ddSBjoern A. Zeeb 
16*bfcc09ddSBjoern A. Zeeb /**
17*bfcc09ddSBjoern A. Zeeb  * struct iwl_binding_cmd_v1 - configuring bindings
18*bfcc09ddSBjoern A. Zeeb  * ( BINDING_CONTEXT_CMD = 0x2b )
19*bfcc09ddSBjoern A. Zeeb  * @id_and_color: ID and color of the relevant Binding,
20*bfcc09ddSBjoern A. Zeeb  *	&enum iwl_ctxt_id_and_color
21*bfcc09ddSBjoern A. Zeeb  * @action: action to perform, one of FW_CTXT_ACTION_*
22*bfcc09ddSBjoern A. Zeeb  * @macs: array of MAC id and colors which belong to the binding,
23*bfcc09ddSBjoern A. Zeeb  *	&enum iwl_ctxt_id_and_color
24*bfcc09ddSBjoern A. Zeeb  * @phy: PHY id and color which belongs to the binding,
25*bfcc09ddSBjoern A. Zeeb  *	&enum iwl_ctxt_id_and_color
26*bfcc09ddSBjoern A. Zeeb  */
27*bfcc09ddSBjoern A. Zeeb struct iwl_binding_cmd_v1 {
28*bfcc09ddSBjoern A. Zeeb 	/* COMMON_INDEX_HDR_API_S_VER_1 */
29*bfcc09ddSBjoern A. Zeeb 	__le32 id_and_color;
30*bfcc09ddSBjoern A. Zeeb 	__le32 action;
31*bfcc09ddSBjoern A. Zeeb 	/* BINDING_DATA_API_S_VER_1 */
32*bfcc09ddSBjoern A. Zeeb 	__le32 macs[MAX_MACS_IN_BINDING];
33*bfcc09ddSBjoern A. Zeeb 	__le32 phy;
34*bfcc09ddSBjoern A. Zeeb } __packed; /* BINDING_CMD_API_S_VER_1 */
35*bfcc09ddSBjoern A. Zeeb 
36*bfcc09ddSBjoern A. Zeeb /**
37*bfcc09ddSBjoern A. Zeeb  * struct iwl_binding_cmd - configuring bindings
38*bfcc09ddSBjoern A. Zeeb  * ( BINDING_CONTEXT_CMD = 0x2b )
39*bfcc09ddSBjoern A. Zeeb  * @id_and_color: ID and color of the relevant Binding,
40*bfcc09ddSBjoern A. Zeeb  *	&enum iwl_ctxt_id_and_color
41*bfcc09ddSBjoern A. Zeeb  * @action: action to perform, one of FW_CTXT_ACTION_*
42*bfcc09ddSBjoern A. Zeeb  * @macs: array of MAC id and colors which belong to the binding
43*bfcc09ddSBjoern A. Zeeb  *	&enum iwl_ctxt_id_and_color
44*bfcc09ddSBjoern A. Zeeb  * @phy: PHY id and color which belongs to the binding
45*bfcc09ddSBjoern A. Zeeb  *	&enum iwl_ctxt_id_and_color
46*bfcc09ddSBjoern A. Zeeb  * @lmac_id: the lmac id the binding belongs to
47*bfcc09ddSBjoern A. Zeeb  */
48*bfcc09ddSBjoern A. Zeeb struct iwl_binding_cmd {
49*bfcc09ddSBjoern A. Zeeb 	/* COMMON_INDEX_HDR_API_S_VER_1 */
50*bfcc09ddSBjoern A. Zeeb 	__le32 id_and_color;
51*bfcc09ddSBjoern A. Zeeb 	__le32 action;
52*bfcc09ddSBjoern A. Zeeb 	/* BINDING_DATA_API_S_VER_1 */
53*bfcc09ddSBjoern A. Zeeb 	__le32 macs[MAX_MACS_IN_BINDING];
54*bfcc09ddSBjoern A. Zeeb 	__le32 phy;
55*bfcc09ddSBjoern A. Zeeb 	__le32 lmac_id;
56*bfcc09ddSBjoern A. Zeeb } __packed; /* BINDING_CMD_API_S_VER_2 */
57*bfcc09ddSBjoern A. Zeeb 
58*bfcc09ddSBjoern A. Zeeb #define IWL_BINDING_CMD_SIZE_V1	sizeof(struct iwl_binding_cmd_v1)
59*bfcc09ddSBjoern A. Zeeb #define IWL_LMAC_24G_INDEX		0
60*bfcc09ddSBjoern A. Zeeb #define IWL_LMAC_5G_INDEX		1
61*bfcc09ddSBjoern A. Zeeb 
62*bfcc09ddSBjoern A. Zeeb static inline u32 iwl_mvm_get_lmac_id(const struct iwl_fw *fw,
63*bfcc09ddSBjoern A. Zeeb 				      enum nl80211_band band){
64*bfcc09ddSBjoern A. Zeeb 	if (!fw_has_capa(&fw->ucode_capa, IWL_UCODE_TLV_CAPA_CDB_SUPPORT) ||
65*bfcc09ddSBjoern A. Zeeb 	    band == NL80211_BAND_2GHZ)
66*bfcc09ddSBjoern A. Zeeb 		return IWL_LMAC_24G_INDEX;
67*bfcc09ddSBjoern A. Zeeb 	return IWL_LMAC_5G_INDEX;
68*bfcc09ddSBjoern A. Zeeb }
69*bfcc09ddSBjoern A. Zeeb 
70*bfcc09ddSBjoern A. Zeeb /* The maximal number of fragments in the FW's schedule session */
71*bfcc09ddSBjoern A. Zeeb #define IWL_MVM_MAX_QUOTA 128
72*bfcc09ddSBjoern A. Zeeb 
73*bfcc09ddSBjoern A. Zeeb /**
74*bfcc09ddSBjoern A. Zeeb  * struct iwl_time_quota_data_v1 - configuration of time quota per binding
75*bfcc09ddSBjoern A. Zeeb  * @id_and_color: ID and color of the relevant Binding,
76*bfcc09ddSBjoern A. Zeeb  *	&enum iwl_ctxt_id_and_color
77*bfcc09ddSBjoern A. Zeeb  * @quota: absolute time quota in TU. The scheduler will try to divide the
78*bfcc09ddSBjoern A. Zeeb  *	remainig quota (after Time Events) according to this quota.
79*bfcc09ddSBjoern A. Zeeb  * @max_duration: max uninterrupted context duration in TU
80*bfcc09ddSBjoern A. Zeeb  */
81*bfcc09ddSBjoern A. Zeeb struct iwl_time_quota_data_v1 {
82*bfcc09ddSBjoern A. Zeeb 	__le32 id_and_color;
83*bfcc09ddSBjoern A. Zeeb 	__le32 quota;
84*bfcc09ddSBjoern A. Zeeb 	__le32 max_duration;
85*bfcc09ddSBjoern A. Zeeb } __packed; /* TIME_QUOTA_DATA_API_S_VER_1 */
86*bfcc09ddSBjoern A. Zeeb 
87*bfcc09ddSBjoern A. Zeeb /**
88*bfcc09ddSBjoern A. Zeeb  * struct iwl_time_quota_cmd - configuration of time quota between bindings
89*bfcc09ddSBjoern A. Zeeb  * ( TIME_QUOTA_CMD = 0x2c )
90*bfcc09ddSBjoern A. Zeeb  * @quotas: allocations per binding
91*bfcc09ddSBjoern A. Zeeb  * Note: on non-CDB the fourth one is the auxilary mac and is
92*bfcc09ddSBjoern A. Zeeb  *	essentially zero.
93*bfcc09ddSBjoern A. Zeeb  *	On CDB the fourth one is a regular binding.
94*bfcc09ddSBjoern A. Zeeb  */
95*bfcc09ddSBjoern A. Zeeb struct iwl_time_quota_cmd_v1 {
96*bfcc09ddSBjoern A. Zeeb 	struct iwl_time_quota_data_v1 quotas[MAX_BINDINGS];
97*bfcc09ddSBjoern A. Zeeb } __packed; /* TIME_QUOTA_ALLOCATION_CMD_API_S_VER_1 */
98*bfcc09ddSBjoern A. Zeeb 
99*bfcc09ddSBjoern A. Zeeb enum iwl_quota_low_latency {
100*bfcc09ddSBjoern A. Zeeb 	IWL_QUOTA_LOW_LATENCY_NONE = 0,
101*bfcc09ddSBjoern A. Zeeb 	IWL_QUOTA_LOW_LATENCY_TX = BIT(0),
102*bfcc09ddSBjoern A. Zeeb 	IWL_QUOTA_LOW_LATENCY_RX = BIT(1),
103*bfcc09ddSBjoern A. Zeeb 	IWL_QUOTA_LOW_LATENCY_TX_RX =
104*bfcc09ddSBjoern A. Zeeb 		IWL_QUOTA_LOW_LATENCY_TX | IWL_QUOTA_LOW_LATENCY_RX,
105*bfcc09ddSBjoern A. Zeeb };
106*bfcc09ddSBjoern A. Zeeb 
107*bfcc09ddSBjoern A. Zeeb /**
108*bfcc09ddSBjoern A. Zeeb  * struct iwl_time_quota_data - configuration of time quota per binding
109*bfcc09ddSBjoern A. Zeeb  * @id_and_color: ID and color of the relevant Binding.
110*bfcc09ddSBjoern A. Zeeb  * @quota: absolute time quota in TU. The scheduler will try to divide the
111*bfcc09ddSBjoern A. Zeeb  *	remainig quota (after Time Events) according to this quota.
112*bfcc09ddSBjoern A. Zeeb  * @max_duration: max uninterrupted context duration in TU
113*bfcc09ddSBjoern A. Zeeb  * @low_latency: low latency status, &enum iwl_quota_low_latency
114*bfcc09ddSBjoern A. Zeeb  */
115*bfcc09ddSBjoern A. Zeeb struct iwl_time_quota_data {
116*bfcc09ddSBjoern A. Zeeb 	__le32 id_and_color;
117*bfcc09ddSBjoern A. Zeeb 	__le32 quota;
118*bfcc09ddSBjoern A. Zeeb 	__le32 max_duration;
119*bfcc09ddSBjoern A. Zeeb 	__le32 low_latency;
120*bfcc09ddSBjoern A. Zeeb } __packed; /* TIME_QUOTA_DATA_API_S_VER_2 */
121*bfcc09ddSBjoern A. Zeeb 
122*bfcc09ddSBjoern A. Zeeb /**
123*bfcc09ddSBjoern A. Zeeb  * struct iwl_time_quota_cmd - configuration of time quota between bindings
124*bfcc09ddSBjoern A. Zeeb  * ( TIME_QUOTA_CMD = 0x2c )
125*bfcc09ddSBjoern A. Zeeb  * Note: on non-CDB the fourth one is the auxilary mac and is essentially zero.
126*bfcc09ddSBjoern A. Zeeb  * On CDB the fourth one is a regular binding.
127*bfcc09ddSBjoern A. Zeeb  *
128*bfcc09ddSBjoern A. Zeeb  * @quotas: allocations per binding
129*bfcc09ddSBjoern A. Zeeb  */
130*bfcc09ddSBjoern A. Zeeb struct iwl_time_quota_cmd {
131*bfcc09ddSBjoern A. Zeeb 	struct iwl_time_quota_data quotas[MAX_BINDINGS];
132*bfcc09ddSBjoern A. Zeeb } __packed; /* TIME_QUOTA_ALLOCATION_CMD_API_S_VER_2 */
133*bfcc09ddSBjoern A. Zeeb 
134*bfcc09ddSBjoern A. Zeeb #endif /* __iwl_fw_api_binding_h__ */
135