Re: [PATCH net-next 4/6] net: ipa: add support to code for IPA v4.5

2020-12-01 Thread Alex Elder

On 12/1/20 12:11 PM, Jon Hunter wrote:


On 25/11/2020 20:45, Alex Elder wrote:

Update the IPA code to make use of the updated IPA v4.5 register
definitions.  Generally what this patch does is, if IPA v4.5
hardware is in use:
   - Ensure new registers or fields in IPA v4.5 are updated where
 required
   - Ensure registers or fields not supported in IPA v4.5 are not
 examined when read, or are set to 0 when written
It does this while preserving the existing functionality for IPA
versions lower than v4.5.

The values to program for QSB_MAX_READS and QSB_MAX_WRITES and the
source and destination resource counts are updated to be correct for
all versions through v4.5 as well.

Note that IPA_RESOURCE_GROUP_SRC_MAX and IPA_RESOURCE_GROUP_DST_MAX
already reflect that 5 is an acceptable number of resources (which
IPA v4.5 implements).

Signed-off-by: Alex Elder 



This change is generating the following build error on ARM64 ...


Sorry about that.  Thank you for reporting this, I will investigate.

-Alex


In file included from drivers/net/ipa/ipa_main.c:9:0:
In function ‘u32_encode_bits’,
 inlined from ‘ipa_hardware_config_qsb.isra.7’ at 
drivers/net/ipa/ipa_main.c:286:6,
 inlined from ‘ipa_hardware_config’ at drivers/net/ipa/ipa_main.c:363:2,
 inlined from ‘ipa_config.isra.12’ at drivers/net/ipa/ipa_main.c:555:2,
 inlined from ‘ipa_probe’ at drivers/net/ipa/ipa_main.c:835:6:
./include/linux/bitfield.h:131:3: error: call to ‘__field_overflow’ declared 
with attribute error: value doesn't fit into mask
__field_overflow(); \
^~
./include/linux/bitfield.h:151:2: note: in expansion of macro ‘MAKE_OP’
   MAKE_OP(u##size,u##size,,)
   ^~~
./include/linux/bitfield.h:154:1: note: in expansion of macro ‘__MAKE_OP’
  __MAKE_OP(32)
  ^

Cheers
Jon





Re: [PATCH net-next 4/6] net: ipa: add support to code for IPA v4.5

2020-12-01 Thread Jon Hunter


On 25/11/2020 20:45, Alex Elder wrote:
> Update the IPA code to make use of the updated IPA v4.5 register
> definitions.  Generally what this patch does is, if IPA v4.5
> hardware is in use:
>   - Ensure new registers or fields in IPA v4.5 are updated where
> required
>   - Ensure registers or fields not supported in IPA v4.5 are not
> examined when read, or are set to 0 when written
> It does this while preserving the existing functionality for IPA
> versions lower than v4.5.
> 
> The values to program for QSB_MAX_READS and QSB_MAX_WRITES and the
> source and destination resource counts are updated to be correct for
> all versions through v4.5 as well.
> 
> Note that IPA_RESOURCE_GROUP_SRC_MAX and IPA_RESOURCE_GROUP_DST_MAX
> already reflect that 5 is an acceptable number of resources (which
> IPA v4.5 implements).
> 
> Signed-off-by: Alex Elder 


This change is generating the following build error on ARM64 ...

In file included from drivers/net/ipa/ipa_main.c:9:0:
In function ‘u32_encode_bits’,
inlined from ‘ipa_hardware_config_qsb.isra.7’ at 
drivers/net/ipa/ipa_main.c:286:6,
inlined from ‘ipa_hardware_config’ at drivers/net/ipa/ipa_main.c:363:2,
inlined from ‘ipa_config.isra.12’ at drivers/net/ipa/ipa_main.c:555:2,
inlined from ‘ipa_probe’ at drivers/net/ipa/ipa_main.c:835:6:
./include/linux/bitfield.h:131:3: error: call to ‘__field_overflow’ declared 
with attribute error: value doesn't fit into mask
   __field_overflow(); \
   ^~
./include/linux/bitfield.h:151:2: note: in expansion of macro ‘MAKE_OP’
  MAKE_OP(u##size,u##size,,)
  ^~~
./include/linux/bitfield.h:154:1: note: in expansion of macro ‘__MAKE_OP’
 __MAKE_OP(32)
 ^

Cheers
Jon

-- 
nvpublic


[PATCH net-next 4/6] net: ipa: add support to code for IPA v4.5

2020-11-25 Thread Alex Elder
Update the IPA code to make use of the updated IPA v4.5 register
definitions.  Generally what this patch does is, if IPA v4.5
hardware is in use:
  - Ensure new registers or fields in IPA v4.5 are updated where
required
  - Ensure registers or fields not supported in IPA v4.5 are not
examined when read, or are set to 0 when written
It does this while preserving the existing functionality for IPA
versions lower than v4.5.

The values to program for QSB_MAX_READS and QSB_MAX_WRITES and the
source and destination resource counts are updated to be correct for
all versions through v4.5 as well.

Note that IPA_RESOURCE_GROUP_SRC_MAX and IPA_RESOURCE_GROUP_DST_MAX
already reflect that 5 is an acceptable number of resources (which
IPA v4.5 implements).

Signed-off-by: Alex Elder 
---
 drivers/net/ipa/ipa_endpoint.c | 10 +++---
 drivers/net/ipa/ipa_main.c | 63 --
 drivers/net/ipa/ipa_reg.h  |  7 
 3 files changed, 57 insertions(+), 23 deletions(-)

diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c
index f28ea062aaf1d..27f543b6780b1 100644
--- a/drivers/net/ipa/ipa_endpoint.c
+++ b/drivers/net/ipa/ipa_endpoint.c
@@ -520,7 +520,7 @@ static void ipa_endpoint_init_hdr(struct ipa_endpoint 
*endpoint)
/* HDR_ADDITIONAL_CONST_LEN is 0; (RX only) */
/* HDR_A5_MUX is 0 */
/* HDR_LEN_INC_DEAGG_HDR is 0 */
-   /* HDR_METADATA_REG_VALID is 0 (TX only) */
+   /* HDR_METADATA_REG_VALID is 0 (TX only, version < v4.5) */
}
 
iowrite32(val, ipa->reg_virt + offset);
@@ -655,6 +655,7 @@ static void ipa_endpoint_init_aggr(struct ipa_endpoint 
*endpoint)
/* other fields ignored */
}
/* AGGR_FORCE_CLOSE is 0 */
+   /* AGGR_GRAN_SEL is 0 for IPA v4.5 */
} else {
val |= u32_encode_bits(IPA_BYPASS_AGGR, AGGR_EN_FMASK);
/* other fields ignored */
@@ -865,9 +866,10 @@ static void ipa_endpoint_status(struct ipa_endpoint 
*endpoint)
val |= u32_encode_bits(status_endpoint_id,
   STATUS_ENDP_FMASK);
}
-   /* STATUS_LOCATION is 0 (status element precedes packet) */
-   /* The next field is present for IPA v4.0 and above */
-   /* STATUS_PKT_SUPPRESS_FMASK is 0 */
+   /* STATUS_LOCATION is 0, meaning status element precedes
+* packet (not present for IPA v4.5)
+*/
+   /* STATUS_PKT_SUPPRESS_FMASK is 0 (not present for v3.5.1) */
}
 
iowrite32(val, ipa->reg_virt + offset);
diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c
index 7cd7f6cc05b3c..f25bcfe51dd4b 100644
--- a/drivers/net/ipa/ipa_main.c
+++ b/drivers/net/ipa/ipa_main.c
@@ -230,8 +230,10 @@ static void ipa_hardware_config_comp(struct ipa *ipa)
val &= ~IPA_QMB_SELECT_CONS_EN_FMASK;
val &= ~IPA_QMB_SELECT_PROD_EN_FMASK;
val &= ~IPA_QMB_SELECT_GLOBAL_EN_FMASK;
-   } else  {
+   } else if (ipa->version < IPA_VERSION_4_5) {
val |= GSI_MULTI_AXI_MASTERS_DIS_FMASK;
+   } else {
+   /* For IPA v4.5 IPA_FULL_FLUSH_WAIT_RSC_CLOSE_EN is 0 */
}
 
val |= GSI_MULTI_INORDER_RD_DIS_FMASK;
@@ -243,25 +245,47 @@ static void ipa_hardware_config_comp(struct ipa *ipa)
 /* Configure DDR and PCIe max read/write QSB values */
 static void ipa_hardware_config_qsb(struct ipa *ipa)
 {
+   enum ipa_version version = ipa->version;
+   u32 max0;
+   u32 max1;
u32 val;
 
-   /* QMB_0 represents DDR; QMB_1 represents PCIe (not present in 4.2) */
+   /* QMB_0 represents DDR; QMB_1 represents PCIe */
val = u32_encode_bits(8, GEN_QMB_0_MAX_WRITES_FMASK);
-   if (ipa->version == IPA_VERSION_4_2)
-   val |= u32_encode_bits(0, GEN_QMB_1_MAX_WRITES_FMASK);
-   else
-   val |= u32_encode_bits(4, GEN_QMB_1_MAX_WRITES_FMASK);
+   switch (version) {
+   case IPA_VERSION_4_2:
+   max1 = 0;   /* PCIe not present */
+   break;
+   case IPA_VERSION_4_5:
+   max1 = 8;
+   break;
+   default:
+   max1 = 4;
+   break;
+   }
+   val |= u32_encode_bits(max1, GEN_QMB_1_MAX_WRITES_FMASK);
iowrite32(val, ipa->reg_virt + IPA_REG_QSB_MAX_WRITES_OFFSET);
 
-   if (ipa->version == IPA_VERSION_3_5_1) {
-   val = u32_encode_bits(8, GEN_QMB_0_MAX_READS_FMASK);
-   val |= u32_encode_bits(12, GEN_QMB_1_MAX_READS_FMASK);
-   } else {
-   val = u32_encode_bits(12, GEN_QMB_0_MAX_READS_FMASK);
-   if (ipa->version == IPA_VERSION_4_2)
-   val |= u32_encode_bits(0, GEN_QMB_1_MAX_READS_FMASK);
-   else
-