Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: ipa: add a parameter to aggregation registers

Starting with IPA v5.0, a single IPA instance can have more than 32
endpoints defined. To handle this, each register that holds a
bitmap of IPA endpoints is replicated as needed to represent the
available endpoints.

To prepare for this, registers that represent endpoint IDs in a bit
mask will be defined to have a parameter, with a stride value of 4
bytes. The first 32 endpoints are represented in the first 32-bit
register, then the next (up to) 32 endpoints at an offset 4 bytes
higher. When accessing such a register, the endpoint ID divided
by 32 determines the offset, and the endpoint ID modulo 32 defines
the endpoint's bit position within the register.

The first two registers we'll update for this are STATE_AGGR_ACTIVE
and AGGR_FORCE_CLOSE.

Until more than 32 endpoints are supported, this change has no
practical effect.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Alex Elder and committed by
David S. Miller
1d8f16db 6337b147

+22 -16
+10 -4
drivers/net/ipa/ipa_endpoint.c
··· 350 350 351 351 static bool ipa_endpoint_aggr_active(struct ipa_endpoint *endpoint) 352 352 { 353 - u32 mask = BIT(endpoint->endpoint_id); 353 + u32 endpoint_id = endpoint->endpoint_id; 354 + u32 mask = BIT(endpoint_id % 32); 354 355 struct ipa *ipa = endpoint->ipa; 356 + u32 unit = endpoint_id / 32; 355 357 const struct ipa_reg *reg; 356 358 u32 val; 357 359 360 + /* This works until we actually have more than 32 endpoints */ 358 361 WARN_ON(!(mask & ipa->available)); 359 362 360 363 reg = ipa_reg(ipa, STATE_AGGR_ACTIVE); 361 - val = ioread32(ipa->reg_virt + ipa_reg_offset(reg)); 364 + val = ioread32(ipa->reg_virt + ipa_reg_n_offset(reg, unit)); 362 365 363 366 return !!(val & mask); 364 367 } 365 368 366 369 static void ipa_endpoint_force_close(struct ipa_endpoint *endpoint) 367 370 { 368 - u32 mask = BIT(endpoint->endpoint_id); 371 + u32 endpoint_id = endpoint->endpoint_id; 372 + u32 mask = BIT(endpoint_id % 32); 369 373 struct ipa *ipa = endpoint->ipa; 374 + u32 unit = endpoint_id / 32; 370 375 const struct ipa_reg *reg; 371 376 377 + /* This works until we actually have more than 32 endpoints */ 372 378 WARN_ON(!(mask & ipa->available)); 373 379 374 380 reg = ipa_reg(ipa, AGGR_FORCE_CLOSE); 375 - iowrite32(mask, ipa->reg_virt + ipa_reg_offset(reg)); 381 + iowrite32(mask, ipa->reg_virt + ipa_reg_n_offset(reg, unit)); 376 382 } 377 383 378 384 /**
+2 -2
drivers/net/ipa/reg/ipa_reg-v3.1.c
··· 103 103 IPA_REG_FIELDS(FILT_ROUT_HASH_FLUSH, filt_rout_hash_flush, 0x0000090); 104 104 105 105 /* Valid bits defined by ipa->available */ 106 - IPA_REG(STATE_AGGR_ACTIVE, state_aggr_active, 0x0000010c); 106 + IPA_REG_STRIDE(STATE_AGGR_ACTIVE, state_aggr_active, 0x0000010c, 0x0004); 107 107 108 108 IPA_REG(IPA_BCR, ipa_bcr, 0x000001d0); 109 109 ··· 116 116 IPA_REG_FIELDS(LOCAL_PKT_PROC_CNTXT, local_pkt_proc_cntxt, 0x000001e8); 117 117 118 118 /* Valid bits defined by ipa->available */ 119 - IPA_REG(AGGR_FORCE_CLOSE, aggr_force_close, 0x000001ec); 119 + IPA_REG_STRIDE(AGGR_FORCE_CLOSE, aggr_force_close, 0x000001ec, 0x0004); 120 120 121 121 static const u32 ipa_reg_counter_cfg_fmask[] = { 122 122 [EOT_COAL_GRANULARITY] = GENMASK(3, 0),
+2 -2
drivers/net/ipa/reg/ipa_reg-v3.5.1.c
··· 108 108 IPA_REG_FIELDS(FILT_ROUT_HASH_FLUSH, filt_rout_hash_flush, 0x0000090); 109 109 110 110 /* Valid bits defined by ipa->available */ 111 - IPA_REG(STATE_AGGR_ACTIVE, state_aggr_active, 0x0000010c); 111 + IPA_REG_STRIDE(STATE_AGGR_ACTIVE, state_aggr_active, 0x0000010c, 0x0004); 112 112 113 113 IPA_REG(IPA_BCR, ipa_bcr, 0x000001d0); 114 114 ··· 121 121 IPA_REG_FIELDS(LOCAL_PKT_PROC_CNTXT, local_pkt_proc_cntxt, 0x000001e8); 122 122 123 123 /* Valid bits defined by ipa->available */ 124 - IPA_REG(AGGR_FORCE_CLOSE, aggr_force_close, 0x000001ec); 124 + IPA_REG_STRIDE(AGGR_FORCE_CLOSE, aggr_force_close, 0x000001ec, 0x0004); 125 125 126 126 static const u32 ipa_reg_counter_cfg_fmask[] = { 127 127 /* Bits 0-3 reserved */
+2 -2
drivers/net/ipa/reg/ipa_reg-v4.11.c
··· 140 140 IPA_REG_FIELDS(FILT_ROUT_HASH_FLUSH, filt_rout_hash_flush, 0x000014c); 141 141 142 142 /* Valid bits defined by ipa->available */ 143 - IPA_REG(STATE_AGGR_ACTIVE, state_aggr_active, 0x000000b4); 143 + IPA_REG_STRIDE(STATE_AGGR_ACTIVE, state_aggr_active, 0x000000b4, 0x0004); 144 144 145 145 static const u32 ipa_reg_local_pkt_proc_cntxt_fmask[] = { 146 146 [IPA_BASE_ADDR] = GENMASK(17, 0), ··· 151 151 IPA_REG_FIELDS(LOCAL_PKT_PROC_CNTXT, local_pkt_proc_cntxt, 0x000001e8); 152 152 153 153 /* Valid bits defined by ipa->available */ 154 - IPA_REG(AGGR_FORCE_CLOSE, aggr_force_close, 0x000001ec); 154 + IPA_REG_STRIDE(AGGR_FORCE_CLOSE, aggr_force_close, 0x000001ec, 0x0004); 155 155 156 156 static const u32 ipa_reg_ipa_tx_cfg_fmask[] = { 157 157 /* Bits 0-1 reserved */
+2 -2
drivers/net/ipa/reg/ipa_reg-v4.2.c
··· 132 132 IPA_REG_FIELDS(FILT_ROUT_HASH_FLUSH, filt_rout_hash_flush, 0x000014c); 133 133 134 134 /* Valid bits defined by ipa->available */ 135 - IPA_REG(STATE_AGGR_ACTIVE, state_aggr_active, 0x000000b4); 135 + IPA_REG_STRIDE(STATE_AGGR_ACTIVE, state_aggr_active, 0x000000b4, 0x0004); 136 136 137 137 IPA_REG(IPA_BCR, ipa_bcr, 0x000001d0); 138 138 ··· 145 145 IPA_REG_FIELDS(LOCAL_PKT_PROC_CNTXT, local_pkt_proc_cntxt, 0x000001e8); 146 146 147 147 /* Valid bits defined by ipa->available */ 148 - IPA_REG(AGGR_FORCE_CLOSE, aggr_force_close, 0x000001ec); 148 + IPA_REG_STRIDE(AGGR_FORCE_CLOSE, aggr_force_close, 0x000001ec, 0x0004); 149 149 150 150 static const u32 ipa_reg_counter_cfg_fmask[] = { 151 151 /* Bits 0-3 reserved */
+2 -2
drivers/net/ipa/reg/ipa_reg-v4.5.c
··· 134 134 IPA_REG_FIELDS(FILT_ROUT_HASH_FLUSH, filt_rout_hash_flush, 0x000014c); 135 135 136 136 /* Valid bits defined by ipa->available */ 137 - IPA_REG(STATE_AGGR_ACTIVE, state_aggr_active, 0x000000b4); 137 + IPA_REG_STRIDE(STATE_AGGR_ACTIVE, state_aggr_active, 0x000000b4, 0x0004); 138 138 139 139 static const u32 ipa_reg_local_pkt_proc_cntxt_fmask[] = { 140 140 [IPA_BASE_ADDR] = GENMASK(17, 0), ··· 145 145 IPA_REG_FIELDS(LOCAL_PKT_PROC_CNTXT, local_pkt_proc_cntxt, 0x000001e8); 146 146 147 147 /* Valid bits defined by ipa->available */ 148 - IPA_REG(AGGR_FORCE_CLOSE, aggr_force_close, 0x000001ec); 148 + IPA_REG_STRIDE(AGGR_FORCE_CLOSE, aggr_force_close, 0x000001ec, 0x0004); 149 149 150 150 static const u32 ipa_reg_ipa_tx_cfg_fmask[] = { 151 151 /* Bits 0-1 reserved */
+2 -2
drivers/net/ipa/reg/ipa_reg-v4.9.c
··· 139 139 IPA_REG_FIELDS(FILT_ROUT_HASH_FLUSH, filt_rout_hash_flush, 0x000014c); 140 140 141 141 /* Valid bits defined by ipa->available */ 142 - IPA_REG(STATE_AGGR_ACTIVE, state_aggr_active, 0x000000b4); 142 + IPA_REG_STRIDE(STATE_AGGR_ACTIVE, state_aggr_active, 0x000000b4, 0x0004); 143 143 144 144 static const u32 ipa_reg_local_pkt_proc_cntxt_fmask[] = { 145 145 [IPA_BASE_ADDR] = GENMASK(17, 0), ··· 150 150 IPA_REG_FIELDS(LOCAL_PKT_PROC_CNTXT, local_pkt_proc_cntxt, 0x000001e8); 151 151 152 152 /* Valid bits defined by ipa->available */ 153 - IPA_REG(AGGR_FORCE_CLOSE, aggr_force_close, 0x000001ec); 153 + IPA_REG_STRIDE(AGGR_FORCE_CLOSE, aggr_force_close, 0x000001ec, 0x0004); 154 154 155 155 static const u32 ipa_reg_ipa_tx_cfg_fmask[] = { 156 156 /* Bits 0-1 reserved */