Skip to content

Commit f50ca7c

Browse files
Alex Elderkuba-moo
authored andcommitted
net: ipa: define GSI CH_C_QOS register fields
Define the fields within the CH_C_QOS GSI register using an array of field masks in that register's reg structure. Use the reg functions for encoding values in those fields. One field in the register is present for IPA v4.0-4.2 only, two others are present starting at IPA v4.5, and one more is there starting at IPA v4.9. Drop the "GSI_" prefix in symbols defined in the gsi_prefetch_mode enumerated type, and define their values using decimal rather than hexidecimal values. Signed-off-by: Alex Elder <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 4a4270c commit f50ca7c

File tree

7 files changed

+72
-26
lines changed

7 files changed

+72
-26
lines changed

drivers/net/ipa/gsi.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -889,29 +889,28 @@ static void gsi_channel_program(struct gsi_channel *channel, bool doorbell)
889889

890890
/* Command channel gets low weighted round-robin priority */
891891
if (channel->command)
892-
wrr_weight = field_max(WRR_WEIGHT_FMASK);
893-
val = u32_encode_bits(wrr_weight, WRR_WEIGHT_FMASK);
892+
wrr_weight = reg_field_max(reg, WRR_WEIGHT);
893+
val = reg_encode(reg, WRR_WEIGHT, wrr_weight);
894894

895895
/* Max prefetch is 1 segment (do not set MAX_PREFETCH_FMASK) */
896896

897897
/* No need to use the doorbell engine starting at IPA v4.0 */
898898
if (gsi->version < IPA_VERSION_4_0 && doorbell)
899-
val |= USE_DB_ENG_FMASK;
899+
val |= reg_bit(reg, USE_DB_ENG);
900900

901901
/* v4.0 introduces an escape buffer for prefetch. We use it
902902
* on all but the AP command channel.
903903
*/
904904
if (gsi->version >= IPA_VERSION_4_0 && !channel->command) {
905905
/* If not otherwise set, prefetch buffers are used */
906906
if (gsi->version < IPA_VERSION_4_5)
907-
val |= USE_ESCAPE_BUF_ONLY_FMASK;
907+
val |= reg_bit(reg, USE_ESCAPE_BUF_ONLY);
908908
else
909-
val |= u32_encode_bits(GSI_ESCAPE_BUF_ONLY,
910-
PREFETCH_MODE_FMASK);
909+
val |= reg_encode(reg, PREFETCH_MODE, ESCAPE_BUF_ONLY);
911910
}
912911
/* All channels set DB_IN_BYTES */
913912
if (gsi->version >= IPA_VERSION_4_9)
914-
val |= DB_IN_BYTES;
913+
val |= reg_bit(reg, DB_IN_BYTES);
915914

916915
iowrite32(val, gsi->virt + reg_n_offset(reg, channel_id));
917916

drivers/net/ipa/gsi_reg.h

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -121,23 +121,22 @@ enum gsi_channel_type {
121121
};
122122

123123
/* CH_C_QOS register */
124-
#define WRR_WEIGHT_FMASK GENMASK(3, 0)
125-
#define MAX_PREFETCH_FMASK GENMASK(8, 8)
126-
#define USE_DB_ENG_FMASK GENMASK(9, 9)
127-
/* The next field is only present for IPA v4.0, v4.1, and v4.2 */
128-
#define USE_ESCAPE_BUF_ONLY_FMASK GENMASK(10, 10)
129-
/* The next two fields are present for IPA v4.5 and above */
130-
#define PREFETCH_MODE_FMASK GENMASK(13, 10)
131-
#define EMPTY_LVL_THRSHOLD_FMASK GENMASK(23, 16)
132-
/* The next field is present for IPA v4.9 and above */
133-
#define DB_IN_BYTES GENMASK(24, 24)
124+
enum gsi_reg_ch_c_qos_field_id {
125+
WRR_WEIGHT,
126+
MAX_PREFETCH,
127+
USE_DB_ENG,
128+
USE_ESCAPE_BUF_ONLY, /* IPA v4.0-4.2 */
129+
PREFETCH_MODE, /* IPA v4.5+ */
130+
EMPTY_LVL_THRSHOLD, /* IPA v4.5+ */
131+
DB_IN_BYTES, /* IPA v4.9+ */
132+
};
134133

135134
/** enum gsi_prefetch_mode - PREFETCH_MODE field in CH_C_QOS */
136135
enum gsi_prefetch_mode {
137-
GSI_USE_PREFETCH_BUFS = 0x0,
138-
GSI_ESCAPE_BUF_ONLY = 0x1,
139-
GSI_SMART_PREFETCH = 0x2,
140-
GSI_FREE_PREFETCH = 0x3,
136+
USE_PREFETCH_BUFS = 0,
137+
ESCAPE_BUF_ONLY = 1,
138+
SMART_PREFETCH = 2,
139+
FREE_PREFETCH = 3,
141140
};
142141

143142
/* EV_CH_E_CNTXT_0 register */

drivers/net/ipa/reg/gsi_reg-v3.1.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,15 @@ REG_STRIDE(CH_C_CNTXT_2, ch_c_cntxt_2, 0x0001c008 + 0x4000 * GSI_EE_AP, 0x80);
2626

2727
REG_STRIDE(CH_C_CNTXT_3, ch_c_cntxt_3, 0x0001c00c + 0x4000 * GSI_EE_AP, 0x80);
2828

29-
REG_STRIDE(CH_C_QOS, ch_c_qos, 0x0001c05c + 0x4000 * GSI_EE_AP, 0x80);
29+
static const u32 reg_ch_c_qos_fmask[] = {
30+
[WRR_WEIGHT] = GENMASK(3, 0),
31+
/* Bits 4-7 reserved */
32+
[MAX_PREFETCH] = BIT(8),
33+
[USE_DB_ENG] = BIT(9),
34+
/* Bits 10-31 reserved */
35+
};
36+
37+
REG_STRIDE_FIELDS(CH_C_QOS, ch_c_qos, 0x0001c05c + 0x4000 * GSI_EE_AP, 0x80);
3038

3139
REG(ERROR_LOG, error_log, 0x0001f200 + 0x4000 * GSI_EE_AP);
3240

drivers/net/ipa/reg/gsi_reg-v3.5.1.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,15 @@ REG_STRIDE(CH_C_CNTXT_2, ch_c_cntxt_2, 0x0001c008 + 0x4000 * GSI_EE_AP, 0x80);
2626

2727
REG_STRIDE(CH_C_CNTXT_3, ch_c_cntxt_3, 0x0001c00c + 0x4000 * GSI_EE_AP, 0x80);
2828

29-
REG_STRIDE(CH_C_QOS, ch_c_qos, 0x0001c05c + 0x4000 * GSI_EE_AP, 0x80);
29+
static const u32 reg_ch_c_qos_fmask[] = {
30+
[WRR_WEIGHT] = GENMASK(3, 0),
31+
/* Bits 4-7 reserved */
32+
[MAX_PREFETCH] = BIT(8),
33+
[USE_DB_ENG] = BIT(9),
34+
/* Bits 10-31 reserved */
35+
};
36+
37+
REG_STRIDE_FIELDS(CH_C_QOS, ch_c_qos, 0x0001c05c + 0x4000 * GSI_EE_AP, 0x80);
3038

3139
REG(ERROR_LOG, error_log, 0x0001f200 + 0x4000 * GSI_EE_AP);
3240

drivers/net/ipa/reg/gsi_reg-v4.0.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,16 @@ REG_STRIDE(CH_C_CNTXT_2, ch_c_cntxt_2, 0x0001c008 + 0x4000 * GSI_EE_AP, 0x80);
2626

2727
REG_STRIDE(CH_C_CNTXT_3, ch_c_cntxt_3, 0x0001c00c + 0x4000 * GSI_EE_AP, 0x80);
2828

29-
REG_STRIDE(CH_C_QOS, ch_c_qos, 0x0001c05c + 0x4000 * GSI_EE_AP, 0x80);
29+
static const u32 reg_ch_c_qos_fmask[] = {
30+
[WRR_WEIGHT] = GENMASK(3, 0),
31+
/* Bits 4-7 reserved */
32+
[MAX_PREFETCH] = BIT(8),
33+
[USE_DB_ENG] = BIT(9),
34+
[USE_ESCAPE_BUF_ONLY] = BIT(10),
35+
/* Bits 11-31 reserved */
36+
};
37+
38+
REG_STRIDE_FIELDS(CH_C_QOS, ch_c_qos, 0x0001c05c + 0x4000 * GSI_EE_AP, 0x80);
3039

3140
REG(ERROR_LOG, error_log, 0x0001f200 + 0x4000 * GSI_EE_AP);
3241

drivers/net/ipa/reg/gsi_reg-v4.5.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,18 @@ REG_STRIDE(CH_C_CNTXT_2, ch_c_cntxt_2, 0x0001c008 + 0x4000 * GSI_EE_AP, 0x80);
2626

2727
REG_STRIDE(CH_C_CNTXT_3, ch_c_cntxt_3, 0x0001c00c + 0x4000 * GSI_EE_AP, 0x80);
2828

29-
REG_STRIDE(CH_C_QOS, ch_c_qos, 0x0001c05c + 0x4000 * GSI_EE_AP, 0x80);
29+
static const u32 reg_ch_c_qos_fmask[] = {
30+
[WRR_WEIGHT] = GENMASK(3, 0),
31+
/* Bits 4-7 reserved */
32+
[MAX_PREFETCH] = BIT(8),
33+
[USE_DB_ENG] = BIT(9),
34+
[PREFETCH_MODE] = GENMASK(13, 10),
35+
/* Bits 14-15 reserved */
36+
[EMPTY_LVL_THRSHOLD] = GENMASK(23, 16),
37+
/* Bits 24-31 reserved */
38+
};
39+
40+
REG_STRIDE_FIELDS(CH_C_QOS, ch_c_qos, 0x0001c05c + 0x4000 * GSI_EE_AP, 0x80);
3041

3142
REG(ERROR_LOG, error_log, 0x0001f200 + 0x4000 * GSI_EE_AP);
3243

drivers/net/ipa/reg/gsi_reg-v4.9.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,19 @@ REG_STRIDE(CH_C_CNTXT_2, ch_c_cntxt_2, 0x0001c008 + 0x4000 * GSI_EE_AP, 0x80);
2626

2727
REG_STRIDE(CH_C_CNTXT_3, ch_c_cntxt_3, 0x0001c00c + 0x4000 * GSI_EE_AP, 0x80);
2828

29-
REG_STRIDE(CH_C_QOS, ch_c_qos, 0x0001c05c + 0x4000 * GSI_EE_AP, 0x80);
29+
static const u32 reg_ch_c_qos_fmask[] = {
30+
[WRR_WEIGHT] = GENMASK(3, 0),
31+
/* Bits 4-7 reserved */
32+
[MAX_PREFETCH] = BIT(8),
33+
[USE_DB_ENG] = BIT(9),
34+
[PREFETCH_MODE] = GENMASK(13, 10),
35+
/* Bits 14-15 reserved */
36+
[EMPTY_LVL_THRSHOLD] = GENMASK(23, 16),
37+
[DB_IN_BYTES] = BIT(24),
38+
/* Bits 25-31 reserved */
39+
};
40+
41+
REG_STRIDE_FIELDS(CH_C_QOS, ch_c_qos, 0x0001c05c + 0x4000 * GSI_EE_AP, 0x80);
3042

3143
REG(ERROR_LOG, error_log, 0x0001f200 + 0x4000 * GSI_EE_AP);
3244

0 commit comments

Comments
 (0)