net: ipa: generalized register definitions
cover net: ipa: generalized register definitions
This series is quite a bit bigger than what I normally like to send, and I apologize for that. I would like it to get incorporated in its entirety this week if possible, and splitting up the series carries a small risk that wouldn't happen.
Each IPA register has a defined offset, and in most cases, a set of masks that define the width and position of fields within the register. Most registers currently use the same offset for all versions of IPA. Usually fields within registers are also the same across many versions. Offsets and fields like this are defined using preprocessor constants.
When a register has a different offset for different versions of IPA, an inline function is used to determine its offset. And in places where a field differs between versions, an inline function is used to determine how a value is encoded within the field, depending on IPA version.
Starting with IPA version 5.0, the number of IPA endpoints supported is greater than 32. As a consequence, *many* IPA register offsets differ considerably from prior versions. This increase in endpoints also requires a lot of field sizes and/or positions to change (such as those that contain an endpoint ID).
Defining these things with constants is no longer simple, and rather than fill the code with one-off functions to define offsets and encode field values, this series puts in place a new way of defining IPA registers and their fields. Note that this series creates this new scheme, but does not add IPA v5.0+ support.
An enumerated type will now define a unique ID for each IPA register. Each defined register will have a structure that contains its offset and its name (a printable string). Each version of IPA will have an array of these register structures, indexed by register ID.
Some "parameterized" registers are duplicated (this is not new). For example, each endpoint has an INIT_HDR register, and the offset of a given endpoint's INIT_HDR register is dependent on the endpoint number (the parameter). In such cases, the register's "stride" is defined as the distance between two of these registers.
If a register contains fields, each field will have a unique ID that's used as an index into an array of field masks defined for the register. The register structure also defines the number of entries in this field array.
When a register is to be used in code, its register structure will be fetched using function ipa_reg(). Other functions are then used to determine the register's offset, or to encode a value into one of the register's fields, and so on.
Each version of IPA defines the set of registers that are available, including all fields for these registers. The array of defined registers is set up at probe time based on the IPA version, and it is associated with the main IPA structure.
-Alex
Alex Elder (15):
net: ipa: introduce IPA register IDs
net: ipa: use IPA register IDs to determine offsets
net: ipa: add per-version IPA register definition files
net: ipa: use ipa_reg[] array for register offsets
net: ipa: introduce ipa_reg()
net: ipa: introduce ipa_reg field masks
net: ipa: define COMP_CFG IPA register fields
net: ipa: define CLKON_CFG and ROUTE IPA register fields
net: ipa: define some more IPA register fields
net: ipa: define more IPA register fields
net: ipa: define even more IPA register fields
net: ipa: define resource group/type IPA register fields
net: ipa: define some IPA endpoint register fields
net: ipa: define more IPA endpoint register fields
net: ipa: define remaining IPA register fields
drivers/net/ipa/Makefile | 2 + drivers/net/ipa/ipa.h | 2 + drivers/net/ipa/ipa_cmd.c | 7 +- drivers/net/ipa/ipa_endpoint.c | 378 ++++++---- drivers/net/ipa/ipa_interrupt.c | 45 +- drivers/net/ipa/ipa_main.c | 164 +++-- drivers/net/ipa/ipa_mem.c | 16 +- drivers/net/ipa/ipa_reg.c | 95 +++ drivers/net/ipa/ipa_reg.h | 1011 ++++++++++++-------------- drivers/net/ipa/ipa_resource.c | 63 +- drivers/net/ipa/ipa_table.c | 27 +- drivers/net/ipa/ipa_uc.c | 9 +- drivers/net/ipa/reg/ipa_reg-v3.1.c | 478 ++++++++++++ drivers/net/ipa/reg/ipa_reg-v3.5.1.c | 456 ++++++++++++ drivers/net/ipa/reg/ipa_reg-v4.11.c | 512 +++++++++++++ drivers/net/ipa/reg/ipa_reg-v4.2.c | 456 ++++++++++++ drivers/net/ipa/reg/ipa_reg-v4.5.c | 533 ++++++++++++++ drivers/net/ipa/reg/ipa_reg-v4.9.c | 509 +++++++++++++ 18 files changed, 3921 insertions(+), 842 deletions(-) create mode 100644 drivers/net/ipa/reg/ipa_reg-v3.1.c create mode 100644 drivers/net/ipa/reg/ipa_reg-v3.5.1.c create mode 100644 drivers/net/ipa/reg/ipa_reg-v4.11.c create mode 100644 drivers/net/ipa/reg/ipa_reg-v4.2.c create mode 100644 drivers/net/ipa/reg/ipa_reg-v4.5.c create mode 100644 drivers/net/ipa/reg/ipa_reg-v4.9.c
Signature · 1 line
2.34.1
PATCH 1/15 net: ipa: introduce IPA register IDs
Create a new ipa_reg_id enumerated type, which identifies each IPA register with a symbolic identifier. Use short names, but in some cases (such as "BCR") add "IPA_" to the name to help avoid name conflicts.
Create two functions that indicate register validity. The first concisely indicates whether a register is valid for a given version of IPA, and if so, whether it is defined. The second indicates whether a register is valid for TX or RX endpoints.
--- drivers/net/ipa/ipa_reg.c | 58 +++++++++++++++++++++++++++++++++++++++ drivers/net/ipa/ipa_reg.h | 55 +++++++++++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+)
drivers/net/ipa/ipa_reg.c +58 -0
@@ -9,11 +9,69 @@#include "ipa.h" #include "ipa_reg.h" +/* Is this register valid for the current IPA version? */ +static bool ipa_reg_valid (struct ipa *ipa,enum ipa_reg_id reg_id) +{ +enum ipa_version version = ipa->version; +bool valid; + +/* Check for bogus (out of range) register IDs */ +if ((u32 )reg_id >=IPA_REG_ID_COUNT ) +return false; + +switch (reg_id) { +case IPA_BCR : +case COUNTER_CFG : + valid = version <IPA_VERSION_4_5 ; +break ; + +case IPA_TX_CFG : +case FLAVOR_0 : +case IDLE_INDICATION_CFG : + valid = version >=IPA_VERSION_3_5 ; +break ; + +case QTIME_TIMESTAMP_CFG : +case TIMERS_XO_CLK_DIV_CFG : +case TIMERS_PULSE_GRAN_CFG : + valid = version >=IPA_VERSION_4_5 ; +break ; + +case SRC_RSRC_GRP_45_RSRC_TYPE : +case DST_RSRC_GRP_45_RSRC_TYPE : + valid = version <=IPA_VERSION_3_1 || + version ==IPA_VERSION_4_5 ; +break ; + +case SRC_RSRC_GRP_67_RSRC_TYPE : +case DST_RSRC_GRP_67_RSRC_TYPE : + valid = version <=IPA_VERSION_3_1 ; +break ; + +case ENDP_FILTER_ROUTER_HSH_CFG : + valid = version !=IPA_VERSION_4_2 ; +break ; + +case IRQ_SUSPEND_EN : +case IRQ_SUSPEND_CLR : + valid = version >=IPA_VERSION_3_1 ; +break ; + +default : + valid = true;/* Others should be defined for all versions */ +break ; + } + +return valid; +} +int ipa_reg_init (struct ipa *ipa) {struct device *dev = &ipa->pdev->dev;struct resource *res; + (void )ipa_reg_valid;/* Avoid a warning */ +/* Setup IPA register memory */ res =platform_get_resource_byname (ipa->pdev,IORESOURCE_MEM ,"ipa-reg" );
drivers/net/ipa/ipa_reg.h +55 -0
61 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 2/15 net: ipa: use IPA register IDs to determine offsets
In reply to Alex ElderExpose two inline functions that return the offset for a register whose ID is provided; one of them takes an additional argument that's used for registers that are parameterized. These both use a common helper function __ipa_reg_offset(), which just uses the offset symbols already defined.
Replace all references to the offset macros defined for IPA registers with calls to ipa_reg_offset() or ipa_reg_n_offset().
--- drivers/net/ipa/ipa_cmd.c | 4 +- drivers/net/ipa/ipa_endpoint.c | 108 +++++++++++++++++++---------- drivers/net/ipa/ipa_interrupt.c | 23 +++---- drivers/net/ipa/ipa_main.c | 49 ++++++++----- drivers/net/ipa/ipa_mem.c | 6 +- drivers/net/ipa/ipa_reg.c | 118 +++++++++++++++++++++++++++++++- drivers/net/ipa/ipa_reg.h | 13 ++++ drivers/net/ipa/ipa_resource.c | 24 ++++--- drivers/net/ipa/ipa_table.c | 9 ++- drivers/net/ipa/ipa_uc.c | 4 +- 10 files changed, 271 insertions(+), 87 deletions(-)
drivers/net/ipa/ipa_cmd.c +2 -2
@@ -312,7 +312,7 @@ static bool ipa_cmd_register_write_valid(struct ipa *ipa)* offset will fit in a register write IPA immediate command. */ if (ipa_table_hash_support (ipa)) { - offset =ipa_reg_filt_rout_hash_flush_offset (ipa->version); + offset =ipa_reg_offset (ipa,FILT_ROUT_HASH_FLUSH ); name ="filter/route hash flush" ;if (!ipa_cmd_register_write_offset_valid (ipa, name, offset))return false;
@@ -325,7 +325,7 @@ static bool ipa_cmd_register_write_valid(struct ipa *ipa)* worst case (highest endpoint number) offset of that endpoint * fits in the register write command field(s) that must hold it. */ - offset =IPA_REG_ENDP_STATUS_N_OFFSET (IPA_ENDPOINT_COUNT -1 ); + offset =ipa_reg_n_offset (ipa,ENDP_STATUS ,IPA_ENDPOINT_COUNT -1 ); name ="maximal endpoint status" ;if (!ipa_cmd_register_write_offset_valid (ipa, name, offset))return false;
drivers/net/ipa/ipa_endpoint.c +71 -37
337 lines not on this page · raw message
drivers/net/ipa/ipa_interrupt.c +9 -14
@@ -59,7 +59,7 @@ static void ipa_interrupt_process(struct ipa_interrupt *interrupt, u32 irq_id)/* For microcontroller interrupts, clear the interrupt right away, * "to avoid clearing unhandled interrupts." */ - offset =ipa_reg_irq_clr_offset (ipa->version); + offset =ipa_reg_offset (ipa,IPA_IRQ_CLR );if (uc_irq)iowrite32 (mask, ipa->reg_virt + offset);
@@ -95,7 +95,7 @@ static irqreturn_t ipa_isr_thread(int irq, void *dev_id)* including conditions whose interrupt is not enabled. Handle * only the enabled ones. */ - offset =ipa_reg_irq_stts_offset (ipa->version); + offset =ipa_reg_offset (ipa,IPA_IRQ_STTS ); pending =ioread32 (ipa->reg_virt + offset);while ((mask = pending & enabled)) { do {
@@ -112,7 +112,7 @@ static irqreturn_t ipa_isr_thread(int irq, void *dev_id)if (pending) {dev_dbg (dev,"clearing disabled IPA interrupts 0x%08x\n" , pending); - offset =ipa_reg_irq_clr_offset (ipa->version); + offset =ipa_reg_offset (ipa,IPA_IRQ_CLR );iowrite32 (pending, ipa->reg_virt + offset); } out_power_put:
@@ -137,7 +137,7 @@ static void ipa_interrupt_suspend_control(struct ipa_interrupt *interrupt,if (ipa->version ==IPA_VERSION_3_0 )return ; - offset =ipa_reg_irq_suspend_en_offset (ipa->version); + offset =ipa_reg_offset (ipa,IRQ_SUSPEND_EN ); val =ioread32 (ipa->reg_virt + offset);if (enable) val |= mask;
@@ -164,18 +164,15 @@ ipa_interrupt_suspend_disable(struct ipa_interrupt *interrupt, u32 endpoint_id)void ipa_interrupt_suspend_clear_all (struct ipa_interrupt *interrupt) {struct ipa *ipa = interrupt->ipa; -u32 offset;u32 val; - offset =ipa_reg_irq_suspend_info_offset (ipa->version); - val =ioread32 (ipa->reg_virt + offset); + val =ioread32 (ipa->reg_virt +ipa_reg_offset (ipa,IRQ_SUSPEND_INFO ));/* SUSPEND interrupt status isn't cleared on IPA version 3.0 */ if (ipa->version ==IPA_VERSION_3_0 )return ; - offset =ipa_reg_irq_suspend_clr_offset (ipa->version); -iowrite32 (val, ipa->reg_virt + offset); +iowrite32 (val, ipa->reg_virt +ipa_reg_offset (ipa,IRQ_SUSPEND_CLR )); }/* Simulate arrival of an IPA TX_SUSPEND interrupt */
@@ -198,7 +195,7 @@ void ipa_interrupt_add(struct ipa_interrupt *interrupt,/* Update the IPA interrupt mask to enable it */ interrupt->enabled |=BIT (ipa_irq); - offset =ipa_reg_irq_en_offset (ipa->version); + offset =ipa_reg_offset (ipa,IPA_IRQ_EN );iowrite32 (interrupt->enabled, ipa->reg_virt + offset); }
@@ -214,7 +211,7 @@ ipa_interrupt_remove(struct ipa_interrupt *interrupt, enum ipa_irq_id ipa_irq)/* Update the IPA interrupt mask to disable it */ interrupt->enabled &= ~BIT (ipa_irq); - offset =ipa_reg_irq_en_offset (ipa->version); + offset =ipa_reg_offset (ipa,IPA_IRQ_EN );iowrite32 (interrupt->enabled, ipa->reg_virt + offset); interrupt->handler[ipa_irq] =NULL ;
@@ -226,7 +223,6 @@ struct ipa_interrupt *ipa_interrupt_config(struct ipa *ipa)struct device *dev = &ipa->pdev->dev;struct ipa_interrupt *interrupt;unsigned int irq; -u32 offset;int ret; ret =platform_get_irq_byname (ipa->pdev,"ipa" );
@@ -244,8 +240,7 @@ struct ipa_interrupt *ipa_interrupt_config(struct ipa *ipa) interrupt->irq = irq;/* Start with all IPA interrupts disabled */ - offset =ipa_reg_irq_en_offset (ipa->version); -iowrite32 (0 , ipa->reg_virt + offset); +iowrite32 (0 , ipa->reg_virt +ipa_reg_offset (ipa,IPA_IRQ_EN )); ret =request_threaded_irq (irq,NULL , ipa_isr_thread,IRQF_ONESHOT ,"ipa" , interrupt);
drivers/net/ipa/ipa_main.c +33 -16
160 lines not on this page · raw message
drivers/net/ipa/ipa_mem.c +4 -2
@@ -113,7 +113,9 @@ int ipa_mem_setup(struct ipa *ipa) mem =ipa_mem_find (ipa,IPA_MEM_MODEM_PROC_CTX ); offset = ipa->mem_offset + mem->offset; val =proc_cntxt_base_addr_encoded (ipa->version, offset); -iowrite32 (val, ipa->reg_virt +IPA_REG_LOCAL_PKT_PROC_CNTXT_OFFSET ); + + offset =ipa_reg_offset (ipa,LOCAL_PKT_PROC_CNTXT ); +iowrite32 (val, ipa->reg_virt + offset);return 0 ; }
@@ -314,7 +316,7 @@ int ipa_mem_config(struct ipa *ipa)u32 i;/* Check the advertised location and size of the shared memory area */ - val =ioread32 (ipa->reg_virt +IPA_REG_SHARED_MEM_SIZE_OFFSET ); + val =ioread32 (ipa->reg_virt +ipa_reg_offset (ipa,SHARED_MEM_SIZE ));/* The fields in the register are in 8 byte units */ ipa->mem_offset =8 *u32_get_bits (val,SHARED_MEM_BADDR_FMASK );
drivers/net/ipa/ipa_reg.c +116 -2
129 lines not on this page · raw message
drivers/net/ipa/ipa_reg.h +13 -0
@@ -898,6 +898,19 @@ ipa_reg_irq_suspend_clr_offset(enum ipa_version version)return ipa_reg_irq_suspend_clr_ee_n_offset (version,GSI_EE_AP ); } +u32 __ipa_reg_offset (struct ipa *ipa,enum ipa_reg_id reg_id,u32 n); + +static inline u32 ipa_reg_offset (struct ipa *ipa,enum ipa_reg_id reg_id) +{ +return __ipa_reg_offset (ipa, reg_id,0 ); +} + +static inline u32 +ipa_reg_n_offset (struct ipa *ipa,enum ipa_reg_id reg_id,u32 n) +{ +return __ipa_reg_offset (ipa, reg_id, n); +} +int ipa_reg_init (struct ipa *ipa);void ipa_reg_exit (struct ipa *ipa);
drivers/net/ipa/ipa_resource.c +16 -8
@@ -95,28 +95,32 @@ static void ipa_resource_config_src(struct ipa *ipa, u32 resource_type, resource = &data->resource_src[resource_type]; - offset =IPA_REG_SRC_RSRC_GRP_01_RSRC_TYPE_N_OFFSET (resource_type); + offset =ipa_reg_n_offset (ipa,SRC_RSRC_GRP_01_RSRC_TYPE , + resource_type); ylimits = group_count ==1 ?NULL : &resource->limits[1 ];ipa_resource_config_common (ipa, offset, &resource->limits[0 ], ylimits);if (group_count <3 )return ; - offset =IPA_REG_SRC_RSRC_GRP_23_RSRC_TYPE_N_OFFSET (resource_type); + offset =ipa_reg_n_offset (ipa,SRC_RSRC_GRP_23_RSRC_TYPE , + resource_type); ylimits = group_count ==3 ?NULL : &resource->limits[3 ];ipa_resource_config_common (ipa, offset, &resource->limits[2 ], ylimits);if (group_count <5 )return ; - offset =IPA_REG_SRC_RSRC_GRP_45_RSRC_TYPE_N_OFFSET (resource_type); + offset =ipa_reg_n_offset (ipa,SRC_RSRC_GRP_45_RSRC_TYPE , + resource_type); ylimits = group_count ==5 ?NULL : &resource->limits[5 ];ipa_resource_config_common (ipa, offset, &resource->limits[4 ], ylimits);if (group_count <7 )return ; - offset =IPA_REG_SRC_RSRC_GRP_67_RSRC_TYPE_N_OFFSET (resource_type); + offset =ipa_reg_n_offset (ipa,SRC_RSRC_GRP_67_RSRC_TYPE , + resource_type); ylimits = group_count ==7 ?NULL : &resource->limits[7 ];ipa_resource_config_common (ipa, offset, &resource->limits[6 ], ylimits); }
@@ -131,28 +135,32 @@ static void ipa_resource_config_dst(struct ipa *ipa, u32 resource_type, resource = &data->resource_dst[resource_type]; - offset =IPA_REG_DST_RSRC_GRP_01_RSRC_TYPE_N_OFFSET (resource_type); + offset =ipa_reg_n_offset (ipa,DST_RSRC_GRP_01_RSRC_TYPE , + resource_type); ylimits = group_count ==1 ?NULL : &resource->limits[1 ];ipa_resource_config_common (ipa, offset, &resource->limits[0 ], ylimits);if (group_count <3 )return ; - offset =IPA_REG_DST_RSRC_GRP_23_RSRC_TYPE_N_OFFSET (resource_type); + offset =ipa_reg_n_offset (ipa,DST_RSRC_GRP_23_RSRC_TYPE , + resource_type); ylimits = group_count ==3 ?NULL : &resource->limits[3 ];ipa_resource_config_common (ipa, offset, &resource->limits[2 ], ylimits);if (group_count <5 )return ; - offset =IPA_REG_DST_RSRC_GRP_45_RSRC_TYPE_N_OFFSET (resource_type); + offset =ipa_reg_n_offset (ipa,DST_RSRC_GRP_45_RSRC_TYPE , + resource_type); ylimits = group_count ==5 ?NULL : &resource->limits[5 ];ipa_resource_config_common (ipa, offset, &resource->limits[4 ], ylimits);if (group_count <7 )return ; - offset =IPA_REG_DST_RSRC_GRP_67_RSRC_TYPE_N_OFFSET (resource_type); + offset =ipa_reg_n_offset (ipa,DST_RSRC_GRP_67_RSRC_TYPE , + resource_type); ylimits = group_count ==7 ?NULL : &resource->limits[7 ];ipa_resource_config_common (ipa, offset, &resource->limits[6 ], ylimits); }
drivers/net/ipa/ipa_table.c +6 -3
@@ -384,7 +384,7 @@ void ipa_table_reset(struct ipa *ipa, bool modem)int ipa_table_hash_flush (struct ipa *ipa) { -u32 offset =ipa_reg_filt_rout_hash_flush_offset (ipa->version); +u32 offset =ipa_reg_offset (ipa,FILT_ROUT_HASH_FLUSH );struct gsi_trans *trans;u32 val;
@@ -516,10 +516,11 @@ int ipa_table_setup(struct ipa *ipa)static void ipa_filter_tuple_zero (struct ipa_endpoint *endpoint) {u32 endpoint_id = endpoint->endpoint_id; +struct ipa *ipa = endpoint->ipa;u32 offset;u32 val; - offset =IPA_REG_ENDP_FILTER_ROUTER_HSH_CFG_N_OFFSET (endpoint_id); + offset =ipa_reg_n_offset (ipa,ENDP_FILTER_ROUTER_HSH_CFG , endpoint_id); val =ioread32 (endpoint->ipa->reg_virt + offset);
@@ -565,9 +566,11 @@ static bool ipa_route_id_modem(u32 route_id)*/ static void ipa_route_tuple_zero (struct ipa *ipa,u32 route_id) { -u32 offset =IPA_REG_ENDP_FILTER_ROUTER_HSH_CFG_N_OFFSET (route_id); +u32 offset;u32 val; + offset =ipa_reg_n_offset (ipa,ENDP_FILTER_ROUTER_HSH_CFG , route_id); + val =ioread32 (ipa->reg_virt + offset);/* Zero all route-related fields, preserving the rest */
drivers/net/ipa/ipa_uc.c +1 -3
@@ -222,7 +222,6 @@ void ipa_uc_power(struct ipa *ipa)static void send_uc_command (struct ipa *ipa,u32 command,u32 command_param) {struct ipa_uc_mem_area *shared =ipa_uc_shared (ipa); -u32 offset;u32 val;/* Fill in the command data */
@@ -234,8 +233,7 @@ static void send_uc_command(struct ipa *ipa, u32 command, u32 command_param)/* Use an interrupt to tell the microcontroller the command is ready */ val =u32_encode_bits (1 ,UC_INTR_FMASK ); - offset =ipa_reg_irq_uc_offset (ipa->version); -iowrite32 (val, ipa->reg_virt + offset); +iowrite32 (val, ipa->reg_virt +ipa_reg_offset (ipa,IPA_IRQ_UC )); }/* Tell the microcontroller the AP is shutting down */
Signature · 1 line
2.34.1
PATCH 3/15 net: ipa: add per-version IPA register definition files
In reply to Alex ElderCreate a new subdirectory "reg", which contains a register definition file for each supported version of IPA. Each register definition contains the register's offset, and for parameterized registers, the stride (distance between consecutive instances of the register). Finally, it includes an all-caps printable register name.
In these files, each IPA version defines an array of IPA register definition pointers, with unsupported registers defined with a null pointer. The array is indexed by the ipa_reg_id enumerated type.
At initialization time, the appropriate register definition array to use is selected based on the IPA version, and assigned to a new "regs" field in the IPA structure.
Extend ipa_reg_valid() so it fails if a valid register is not defined.
This patch simply puts this infrastructure in place; the next will use it.
--- drivers/net/ipa/Makefile | 2 + drivers/net/ipa/ipa.h | 2 + drivers/net/ipa/ipa_reg.c | 37 +++++- drivers/net/ipa/ipa_reg.h | 44 +++++++ drivers/net/ipa/reg/ipa_reg-v3.1.c | 166 ++++++++++++++++++++++++++ drivers/net/ipa/reg/ipa_reg-v3.5.1.c | 159 +++++++++++++++++++++++++ drivers/net/ipa/reg/ipa_reg-v4.11.c | 159 +++++++++++++++++++++++++ drivers/net/ipa/reg/ipa_reg-v4.2.c | 152 ++++++++++++++++++++++++ drivers/net/ipa/reg/ipa_reg-v4.5.c | 167 +++++++++++++++++++++++++++ drivers/net/ipa/reg/ipa_reg-v4.9.c | 159 +++++++++++++++++++++++++ 10 files changed, 1044 insertions(+), 3 deletions(-) create mode 100644 drivers/net/ipa/reg/ipa_reg-v3.1.c create mode 100644 drivers/net/ipa/reg/ipa_reg-v3.5.1.c create mode 100644 drivers/net/ipa/reg/ipa_reg-v4.11.c create mode 100644 drivers/net/ipa/reg/ipa_reg-v4.2.c create mode 100644 drivers/net/ipa/reg/ipa_reg-v4.5.c create mode 100644 drivers/net/ipa/reg/ipa_reg-v4.9.c
drivers/net/ipa/Makefile +2 -0
@@ -13,4 +13,6 @@ ipa-y := ipa_main.o ipa_power.o ipa_reg.o ipa_mem.o \ ipa_resource.o ipa_qmi.o ipa_qmi_msg.o \ ipa_sysfs.o +ipa-y += $(IPA_VERSIONS:%=reg/ipa_reg-v%.o) + ipa-y += $(IPA_VERSIONS:%=data/ipa_data-v%.o)
drivers/net/ipa/ipa.h +2 -0
@@ -44,6 +44,7 @@ struct ipa_interrupt;* @uc_loaded: true after microcontroller has reported it's ready * @reg_addr: DMA address used for IPA register access * @reg_virt: Virtual address used for IPA register access +* @regs: IPA register definitions * @mem_addr: DMA address of IPA-local memory space * @mem_virt: Virtual address of IPA-local memory space * @mem_offset: Offset from @mem_virt used for access to IPA memory
@@ -90,6 +91,7 @@ struct ipa {dma_addr_t reg_addr;void __iomem *reg_virt; +const struct ipa_regs *regs;dma_addr_t mem_addr;void *mem_virt;
drivers/net/ipa/ipa_reg.c +34 -3
@@ -9,14 +9,14 @@#include "ipa.h" #include "ipa_reg.h" -/* Is this register valid for the current IPA version? */ +/* Is this register valid and defined for the current IPA version? */ static bool ipa_reg_valid (struct ipa *ipa,enum ipa_reg_id reg_id) {enum ipa_version version = ipa->version;bool valid;/* Check for bogus (out of range) register IDs */ -if ((u32 )reg_id >=IPA_REG_ID_COUNT ) +if ((u32 )reg_id >= ipa->regs->reg_count)return false;switch (reg_id) {
@@ -62,7 +62,9 @@ static bool ipa_reg_valid(struct ipa *ipa, enum ipa_reg_id reg_id)break ; } -return valid; +/* To be valid, it must be defined */ + +return valid && ipa->regs->reg[reg_id]; }/* Assumes the endpoint transfer direction is valid; 0 is a bad offset */
@@ -181,11 +183,39 @@ u32 __ipa_reg_offset(struct ipa *ipa, enum ipa_reg_id reg_id, u32 n) } } +static const struct ipa_regs *ipa_regs (enum ipa_version version) +{ +switch (version) { +case IPA_VERSION_3_1 : +return &ipa_regs_v3_1; +case IPA_VERSION_3_5_1 : +return &ipa_regs_v3_5_1; +case IPA_VERSION_4_2 : +return &ipa_regs_v4_2; +case IPA_VERSION_4_5 : +return &ipa_regs_v4_5; +case IPA_VERSION_4_9 : +return &ipa_regs_v4_9; +case IPA_VERSION_4_11 : +return &ipa_regs_v4_11; +default : +return NULL ; + } +} +int ipa_reg_init (struct ipa *ipa) {struct device *dev = &ipa->pdev->dev; +const struct ipa_regs *regs;struct resource *res; + regs =ipa_regs (ipa->version); +if (!regs) +return -EINVAL ; + +if (WARN_ON (regs->reg_count >IPA_REG_ID_COUNT )) +return -EINVAL ; +/* Setup IPA register memory */ res =platform_get_resource_byname (ipa->pdev,IORESOURCE_MEM ,"ipa-reg" );
@@ -200,6 +230,7 @@ int ipa_reg_init(struct ipa *ipa)return -ENOMEM ; } ipa->reg_addr = res->start; + ipa->regs = regs;return 0 ; }
drivers/net/ipa/ipa_reg.h +44 -0
64 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v3.1.c new file +166 -0
166 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v3.5.1.c new file +159 -0
159 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v4.11.c new file +159 -0
159 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v4.2.c new file +152 -0
152 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v4.5.c new file +167 -0
167 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v4.9.c new file +159 -0
159 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 4/15 net: ipa: use ipa_reg[] array for register offsets
In reply to Alex ElderUse the array of register descriptors assigned at initialization time to determine the offset (and where used, stride) for IPA registers. Issue a warning if an offset is requested for a register that's not valid for the current system.
Remove all IPE_REG_*_OFFSET macros, as well as inline static functions that returned register offsets.
--- drivers/net/ipa/ipa_reg.c | 111 +--------------- drivers/net/ipa/ipa_reg.h | 260 +++++--------------------------------- 2 files changed, 37 insertions(+), 334 deletions(-)
drivers/net/ipa/ipa_reg.c +4 -107
@@ -70,117 +70,14 @@ static bool ipa_reg_valid(struct ipa *ipa, enum ipa_reg_id reg_id)/* Assumes the endpoint transfer direction is valid; 0 is a bad offset */ u32 __ipa_reg_offset (struct ipa *ipa,enum ipa_reg_id reg_id,u32 n) { -enum ipa_version version; +const struct ipa_reg *reg; -if (!ipa_reg_valid (ipa, reg_id)) +if (WARN_ON (!ipa_reg_valid (ipa, reg_id)))return 0 ; - version = ipa->version; + reg = ipa->regs->reg[reg_id]; -switch (reg_id) { -case COMP_CFG : -return IPA_REG_COMP_CFG_OFFSET ; -case CLKON_CFG : -return IPA_REG_CLKON_CFG_OFFSET ; -case ROUTE : -return IPA_REG_ROUTE_OFFSET ; -case SHARED_MEM_SIZE : -return IPA_REG_SHARED_MEM_SIZE_OFFSET ; -case QSB_MAX_WRITES : -return IPA_REG_QSB_MAX_WRITES_OFFSET ; -case QSB_MAX_READS : -return IPA_REG_QSB_MAX_READS_OFFSET ; -case FILT_ROUT_HASH_EN : -return ipa_reg_filt_rout_hash_en_offset (version); -case FILT_ROUT_HASH_FLUSH : -return ipa_reg_filt_rout_hash_flush_offset (version); -case STATE_AGGR_ACTIVE : -return ipa_reg_state_aggr_active_offset (version); -case IPA_BCR : -return IPA_REG_BCR_OFFSET ; -case LOCAL_PKT_PROC_CNTXT : -return IPA_REG_LOCAL_PKT_PROC_CNTXT_OFFSET ; -case AGGR_FORCE_CLOSE : -return IPA_REG_AGGR_FORCE_CLOSE_OFFSET ; -case COUNTER_CFG : -return IPA_REG_COUNTER_CFG_OFFSET ; -case IPA_TX_CFG : -return IPA_REG_TX_CFG_OFFSET ; -case FLAVOR_0 : -return IPA_REG_FLAVOR_0_OFFSET ; -case IDLE_INDICATION_CFG : -return ipa_reg_idle_indication_cfg_offset (version); -case QTIME_TIMESTAMP_CFG : -return IPA_REG_QTIME_TIMESTAMP_CFG_OFFSET ; -case TIMERS_XO_CLK_DIV_CFG : -return IPA_REG_TIMERS_XO_CLK_DIV_CFG_OFFSET ; -case TIMERS_PULSE_GRAN_CFG : -return IPA_REG_TIMERS_PULSE_GRAN_CFG_OFFSET ; -case SRC_RSRC_GRP_01_RSRC_TYPE : -return IPA_REG_SRC_RSRC_GRP_01_RSRC_TYPE_N_OFFSET (n); -case SRC_RSRC_GRP_23_RSRC_TYPE : -return IPA_REG_SRC_RSRC_GRP_23_RSRC_TYPE_N_OFFSET (n); -case SRC_RSRC_GRP_45_RSRC_TYPE : -return IPA_REG_SRC_RSRC_GRP_45_RSRC_TYPE_N_OFFSET (n); -case SRC_RSRC_GRP_67_RSRC_TYPE : -return IPA_REG_SRC_RSRC_GRP_67_RSRC_TYPE_N_OFFSET (n); -case DST_RSRC_GRP_01_RSRC_TYPE : -return IPA_REG_DST_RSRC_GRP_01_RSRC_TYPE_N_OFFSET (n); -case DST_RSRC_GRP_23_RSRC_TYPE : -return IPA_REG_DST_RSRC_GRP_23_RSRC_TYPE_N_OFFSET (n); -case DST_RSRC_GRP_45_RSRC_TYPE : -return IPA_REG_DST_RSRC_GRP_45_RSRC_TYPE_N_OFFSET (n); -case DST_RSRC_GRP_67_RSRC_TYPE : -return IPA_REG_DST_RSRC_GRP_67_RSRC_TYPE_N_OFFSET (n); -case ENDP_INIT_CTRL : -return IPA_REG_ENDP_INIT_CTRL_N_OFFSET (n); -case ENDP_INIT_CFG : -return IPA_REG_ENDP_INIT_CFG_N_OFFSET (n); -case ENDP_INIT_NAT : -return IPA_REG_ENDP_INIT_NAT_N_OFFSET (n); -case ENDP_INIT_HDR : -return IPA_REG_ENDP_INIT_HDR_N_OFFSET (n); -case ENDP_INIT_HDR_EXT : -return IPA_REG_ENDP_INIT_HDR_EXT_N_OFFSET (n); -case ENDP_INIT_HDR_METADATA_MASK : -return IPA_REG_ENDP_INIT_HDR_METADATA_MASK_N_OFFSET (n); -case ENDP_INIT_MODE : -return IPA_REG_ENDP_INIT_MODE_N_OFFSET (n); -case ENDP_INIT_AGGR : -return IPA_REG_ENDP_INIT_AGGR_N_OFFSET (n); -case ENDP_INIT_HOL_BLOCK_EN : -return IPA_REG_ENDP_INIT_HOL_BLOCK_EN_N_OFFSET (n); -case ENDP_INIT_HOL_BLOCK_TIMER : -return IPA_REG_ENDP_INIT_HOL_BLOCK_TIMER_N_OFFSET (n); -case ENDP_INIT_DEAGGR : -return IPA_REG_ENDP_INIT_DEAGGR_N_OFFSET (n); -case ENDP_INIT_RSRC_GRP : -return IPA_REG_ENDP_INIT_RSRC_GRP_N_OFFSET (n); -case ENDP_INIT_SEQ : -return IPA_REG_ENDP_INIT_SEQ_N_OFFSET (n); -case ENDP_STATUS : -return IPA_REG_ENDP_STATUS_N_OFFSET (n); -case ENDP_FILTER_ROUTER_HSH_CFG : -return IPA_REG_ENDP_FILTER_ROUTER_HSH_CFG_N_OFFSET (n); -/* The IRQ registers below are only used for GSI_EE_AP */ -case IPA_IRQ_STTS : -return ipa_reg_irq_stts_offset (version); -case IPA_IRQ_EN : -return ipa_reg_irq_en_offset (version); -case IPA_IRQ_CLR : -return ipa_reg_irq_clr_offset (version); -case IPA_IRQ_UC : -return ipa_reg_irq_uc_offset (version); -case IRQ_SUSPEND_INFO : -return ipa_reg_irq_suspend_info_offset (version); -case IRQ_SUSPEND_EN : -return ipa_reg_irq_suspend_en_offset (version); -case IRQ_SUSPEND_CLR : -return ipa_reg_irq_suspend_clr_offset (version); -default : -WARN (true,"bad register id %u???\n" , reg_id); -return 0 ; - } +return reg->offset + n * reg->stride; }static const struct ipa_regs *ipa_regs (enum ipa_version version)
drivers/net/ipa/ipa_reg.h +33 -227
437 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 5/15 net: ipa: introduce ipa_reg()
In reply to Alex ElderCreate a new function that returns a register descriptor given its ID. Change ipa_reg_offset() and ipa_reg_n_offset() so they take a register descriptor argument rather than an IPA pointer and register ID. Have them accept null pointers (and return an invalid 0 offset), to avoid the need for excessive error checking. (A warning is issued whenever ipa_reg() returns 0).
Call ipa_reg() or ipa_reg_n() to look up information about the register before calls to ipa_reg_offset() and ipa_reg_n_offset(). Delay looking up offsets until they're needed to read or write registers.
--- drivers/net/ipa/ipa_cmd.c | 7 +- drivers/net/ipa/ipa_endpoint.c | 120 ++++++++++++++++++-------------- drivers/net/ipa/ipa_interrupt.c | 40 +++++++---- drivers/net/ipa/ipa_main.c | 84 ++++++++++++---------- drivers/net/ipa/ipa_mem.c | 11 +-- drivers/net/ipa/ipa_reg.c | 11 +-- drivers/net/ipa/ipa_reg.h | 13 ++-- drivers/net/ipa/ipa_resource.c | 34 ++++----- drivers/net/ipa/ipa_table.c | 14 +++- drivers/net/ipa/ipa_uc.c | 5 +- 10 files changed, 195 insertions(+), 144 deletions(-)
drivers/net/ipa/ipa_cmd.c +5 -2
@@ -305,6 +305,7 @@ static bool ipa_cmd_register_write_offset_valid(struct ipa *ipa,/* Check whether offsets passed to register_write are valid */ static bool ipa_cmd_register_write_valid (struct ipa *ipa) { +const struct ipa_reg *reg;const char *name;u32 offset;
@@ -312,7 +313,8 @@ static bool ipa_cmd_register_write_valid(struct ipa *ipa)* offset will fit in a register write IPA immediate command. */ if (ipa_table_hash_support (ipa)) { - offset =ipa_reg_offset (ipa,FILT_ROUT_HASH_FLUSH ); + reg =ipa_reg (ipa,FILT_ROUT_HASH_FLUSH ); + offset =ipa_reg_offset (reg); name ="filter/route hash flush" ;if (!ipa_cmd_register_write_offset_valid (ipa, name, offset))return false;
@@ -325,7 +327,8 @@ static bool ipa_cmd_register_write_valid(struct ipa *ipa)* worst case (highest endpoint number) offset of that endpoint * fits in the register write command field(s) that must hold it. */ - offset =ipa_reg_n_offset (ipa,ENDP_STATUS ,IPA_ENDPOINT_COUNT -1 ); + reg =ipa_reg (ipa,ENDP_STATUS ); + offset =ipa_reg_n_offset (reg,IPA_ENDPOINT_COUNT -1 ); name ="maximal endpoint status" ;if (!ipa_cmd_register_write_offset_valid (ipa, name, offset))return false;
drivers/net/ipa/ipa_endpoint.c +66 -54
363 lines not on this page · raw message
drivers/net/ipa/ipa_interrupt.c +27 -13
@@ -53,13 +53,15 @@ static void ipa_interrupt_process(struct ipa_interrupt *interrupt, u32 irq_id) {bool uc_irq =ipa_interrupt_uc (interrupt, irq_id);struct ipa *ipa = interrupt->ipa; +const struct ipa_reg *reg;u32 mask =BIT (irq_id);u32 offset;/* For microcontroller interrupts, clear the interrupt right away, * "to avoid clearing unhandled interrupts." */ - offset =ipa_reg_offset (ipa,IPA_IRQ_CLR ); + reg =ipa_reg (ipa,IPA_IRQ_CLR ); + offset =ipa_reg_offset (reg);if (uc_irq)iowrite32 (mask, ipa->reg_virt + offset);
@@ -80,6 +82,7 @@ static irqreturn_t ipa_isr_thread(int irq, void *dev_id)struct ipa_interrupt *interrupt = dev_id;struct ipa *ipa = interrupt->ipa;u32 enabled = interrupt->enabled; +const struct ipa_reg *reg;struct device *dev;u32 pending;u32 offset;
@@ -95,7 +98,8 @@ static irqreturn_t ipa_isr_thread(int irq, void *dev_id)* including conditions whose interrupt is not enabled. Handle * only the enabled ones. */ - offset =ipa_reg_offset (ipa,IPA_IRQ_STTS ); + reg =ipa_reg (ipa,IPA_IRQ_STTS ); + offset =ipa_reg_offset (reg); pending =ioread32 (ipa->reg_virt + offset);while ((mask = pending & enabled)) { do {
@@ -112,7 +116,8 @@ static irqreturn_t ipa_isr_thread(int irq, void *dev_id)if (pending) {dev_dbg (dev,"clearing disabled IPA interrupts 0x%08x\n" , pending); - offset =ipa_reg_offset (ipa,IPA_IRQ_CLR ); + reg =ipa_reg (ipa,IPA_IRQ_CLR ); + offset =ipa_reg_offset (reg);iowrite32 (pending, ipa->reg_virt + offset); } out_power_put:
@@ -128,6 +133,7 @@ static void ipa_interrupt_suspend_control(struct ipa_interrupt *interrupt, {struct ipa *ipa = interrupt->ipa;u32 mask =BIT (endpoint_id); +const struct ipa_reg *reg;u32 offset;u32 val;
@@ -137,7 +143,8 @@ static void ipa_interrupt_suspend_control(struct ipa_interrupt *interrupt,if (ipa->version ==IPA_VERSION_3_0 )return ; - offset =ipa_reg_offset (ipa,IRQ_SUSPEND_EN ); + reg =ipa_reg (ipa,IRQ_SUSPEND_EN ); + offset =ipa_reg_offset (reg); val =ioread32 (ipa->reg_virt + offset);if (enable) val |= mask;
@@ -164,15 +171,18 @@ ipa_interrupt_suspend_disable(struct ipa_interrupt *interrupt, u32 endpoint_id)void ipa_interrupt_suspend_clear_all (struct ipa_interrupt *interrupt) {struct ipa *ipa = interrupt->ipa; +const struct ipa_reg *reg;u32 val; - val =ioread32 (ipa->reg_virt +ipa_reg_offset (ipa,IRQ_SUSPEND_INFO )); + reg =ipa_reg (ipa,IRQ_SUSPEND_INFO ); + val =ioread32 (ipa->reg_virt +ipa_reg_offset (reg));/* SUSPEND interrupt status isn't cleared on IPA version 3.0 */ if (ipa->version ==IPA_VERSION_3_0 )return ; -iowrite32 (val, ipa->reg_virt +ipa_reg_offset (ipa,IRQ_SUSPEND_CLR )); + reg =ipa_reg (ipa,IRQ_SUSPEND_CLR ); +iowrite32 (val, ipa->reg_virt +ipa_reg_offset (reg)); }/* Simulate arrival of an IPA TX_SUSPEND interrupt */
@@ -186,7 +196,7 @@ void ipa_interrupt_add(struct ipa_interrupt *interrupt, enum ipa_irq_id ipa_irq, ipa_irq_handler_t handler) {struct ipa *ipa = interrupt->ipa; -u32 offset; +const struct ipa_reg *reg;if (WARN_ON (ipa_irq >=IPA_IRQ_COUNT ))return ;
@@ -195,8 +205,9 @@ void ipa_interrupt_add(struct ipa_interrupt *interrupt,/* Update the IPA interrupt mask to enable it */ interrupt->enabled |=BIT (ipa_irq); - offset =ipa_reg_offset (ipa,IPA_IRQ_EN ); -iowrite32 (interrupt->enabled, ipa->reg_virt + offset); + + reg =ipa_reg (ipa,IPA_IRQ_EN ); +iowrite32 (interrupt->enabled, ipa->reg_virt +ipa_reg_offset (reg)); }/* Remove the handler for an IPA interrupt type */
@@ -204,15 +215,16 @@ void ipa_interrupt_remove(struct ipa_interrupt *interrupt, enum ipa_irq_id ipa_irq) { struct ipa *ipa = interrupt->ipa; -u32 offset; +const struct ipa_reg *reg;if (WARN_ON (ipa_irq >=IPA_IRQ_COUNT ))return ;/* Update the IPA interrupt mask to disable it */ interrupt->enabled &= ~BIT (ipa_irq); - offset =ipa_reg_offset (ipa,IPA_IRQ_EN ); -iowrite32 (interrupt->enabled, ipa->reg_virt + offset); + + reg =ipa_reg (ipa,IPA_IRQ_EN ); +iowrite32 (interrupt->enabled, ipa->reg_virt +ipa_reg_offset (reg)); interrupt->handler[ipa_irq] =NULL ; }
@@ -222,6 +234,7 @@ struct ipa_interrupt *ipa_interrupt_config(struct ipa *ipa) {struct device *dev = &ipa->pdev->dev;struct ipa_interrupt *interrupt; +const struct ipa_reg *reg;unsigned int irq;int ret;
@@ -240,7 +253,8 @@ struct ipa_interrupt *ipa_interrupt_config(struct ipa *ipa) interrupt->irq = irq;/* Start with all IPA interrupts disabled */ -iowrite32 (0 , ipa->reg_virt +ipa_reg_offset (ipa,IPA_IRQ_EN )); + reg =ipa_reg (ipa,IPA_IRQ_EN ); +iowrite32 (0 , ipa->reg_virt +ipa_reg_offset (reg)); ret =request_threaded_irq (irq,NULL , ipa_isr_thread,IRQF_ONESHOT ,"ipa" , interrupt);
drivers/net/ipa/ipa_main.c +48 -36
216 lines not on this page · raw message
drivers/net/ipa/ipa_mem.c +7 -4
@@ -75,6 +75,7 @@ ipa_mem_zero_region_add(struct gsi_trans *trans, enum ipa_mem_id mem_id)int ipa_mem_setup (struct ipa *ipa) {dma_addr_t addr = ipa->zero_addr; +const struct ipa_reg *reg;const struct ipa_mem *mem;struct gsi_trans *trans;u32 offset;
@@ -112,10 +113,10 @@ int ipa_mem_setup(struct ipa *ipa)/* Tell the hardware where the processing context area is located */ mem =ipa_mem_find (ipa,IPA_MEM_MODEM_PROC_CTX ); offset = ipa->mem_offset + mem->offset; + + reg =ipa_reg (ipa,LOCAL_PKT_PROC_CNTXT ); val =proc_cntxt_base_addr_encoded (ipa->version, offset); - - offset =ipa_reg_offset (ipa,LOCAL_PKT_PROC_CNTXT ); -iowrite32 (val, ipa->reg_virt + offset); +iowrite32 (val, ipa->reg_virt +ipa_reg_offset (reg));return 0 ; }
@@ -308,6 +309,7 @@ static bool ipa_mem_size_valid(struct ipa *ipa)int ipa_mem_config (struct ipa *ipa) {struct device *dev = &ipa->pdev->dev; +const struct ipa_reg *reg;const struct ipa_mem *mem;dma_addr_t addr;u32 mem_size;
@@ -316,7 +318,8 @@ int ipa_mem_config(struct ipa *ipa)u32 i;/* Check the advertised location and size of the shared memory area */ - val =ioread32 (ipa->reg_virt +ipa_reg_offset (ipa,SHARED_MEM_SIZE )); + reg =ipa_reg (ipa,SHARED_MEM_SIZE ); + val =ioread32 (ipa->reg_virt +ipa_reg_offset (reg));/* The fields in the register are in 8 byte units */ ipa->mem_offset =8 *u32_get_bits (val,SHARED_MEM_BADDR_FMASK );
drivers/net/ipa/ipa_reg.c +3 -8
@@ -67,17 +67,12 @@ static bool ipa_reg_valid(struct ipa *ipa, enum ipa_reg_id reg_id)return valid && ipa->regs->reg[reg_id]; } -/* Assumes the endpoint transfer direction is valid; 0 is a bad offset */ -u32 __ipa_reg_offset (struct ipa *ipa,enum ipa_reg_id reg_id,u32 n) +const struct ipa_reg *ipa_reg (struct ipa *ipa,enum ipa_reg_id reg_id) { -const struct ipa_reg *reg; -if (WARN_ON (!ipa_reg_valid (ipa, reg_id))) -return 0 ; +return NULL ; - reg = ipa->regs->reg[reg_id]; - -return reg->offset + n * reg->stride; +return ipa->regs->reg[reg_id]; }static const struct ipa_regs *ipa_regs (enum ipa_version version)
drivers/net/ipa/ipa_reg.h +6 -7
@@ -746,19 +746,18 @@ extern const struct ipa_regs ipa_regs_v4_5;extern const struct ipa_regs ipa_regs_v4_9;extern const struct ipa_regs ipa_regs_v4_11; -u32 __ipa_reg_offset (struct ipa *ipa,enum ipa_reg_id reg_id,u32 n); -const struct ipa_reg *ipa_reg (struct ipa *ipa,enum ipa_reg_id reg_id); -static inline u32 ipa_reg_offset (struct ipa *ipa,enum ipa_reg_id reg_id) +/* Returns 0 for NULL reg; warning will have already been issued */ +static inline u32 ipa_reg_offset (const struct ipa_reg *reg) { -return __ipa_reg_offset (ipa, reg_id,0 ); +return reg ? reg->offset :0 ; } -static inline u32 -ipa_reg_n_offset (struct ipa *ipa,enum ipa_reg_id reg_id,u32 n) +/* Returns 0 for NULL reg; warning will have already been issued */ +static inline u32 ipa_reg_n_offset (const struct ipa_reg *reg,u32 n) { -return __ipa_reg_offset (ipa, reg_id, n); +return reg ? reg->offset + n * reg->stride :0 ; }int ipa_reg_init (struct ipa *ipa);
drivers/net/ipa/ipa_resource.c +18 -16
@@ -91,36 +91,37 @@ static void ipa_resource_config_src(struct ipa *ipa, u32 resource_type,u32 group_count = data->rsrc_group_src_count;const struct ipa_resource_limits *ylimits;const struct ipa_resource *resource; +const struct ipa_reg *reg;u32 offset; resource = &data->resource_src[resource_type]; - offset =ipa_reg_n_offset (ipa,SRC_RSRC_GRP_01_RSRC_TYPE , - resource_type); + reg =ipa_reg (ipa,SRC_RSRC_GRP_01_RSRC_TYPE ); + offset =ipa_reg_n_offset (reg, resource_type); ylimits = group_count ==1 ?NULL : &resource->limits[1 ];ipa_resource_config_common (ipa, offset, &resource->limits[0 ], ylimits);if (group_count <3 )return ; - offset =ipa_reg_n_offset (ipa,SRC_RSRC_GRP_23_RSRC_TYPE , - resource_type); + reg =ipa_reg (ipa,SRC_RSRC_GRP_23_RSRC_TYPE ); + offset =ipa_reg_n_offset (reg, resource_type); ylimits = group_count ==3 ?NULL : &resource->limits[3 ];ipa_resource_config_common (ipa, offset, &resource->limits[2 ], ylimits);if (group_count <5 )return ; - offset =ipa_reg_n_offset (ipa,SRC_RSRC_GRP_45_RSRC_TYPE , - resource_type); + reg =ipa_reg (ipa,SRC_RSRC_GRP_45_RSRC_TYPE ); + offset =ipa_reg_n_offset (reg, resource_type); ylimits = group_count ==5 ?NULL : &resource->limits[5 ];ipa_resource_config_common (ipa, offset, &resource->limits[4 ], ylimits);if (group_count <7 )return ; - offset =ipa_reg_n_offset (ipa,SRC_RSRC_GRP_67_RSRC_TYPE , - resource_type); + reg =ipa_reg (ipa,SRC_RSRC_GRP_67_RSRC_TYPE ); + offset =ipa_reg_n_offset (reg, resource_type); ylimits = group_count ==7 ?NULL : &resource->limits[7 ];ipa_resource_config_common (ipa, offset, &resource->limits[6 ], ylimits); }
@@ -131,36 +132,37 @@ static void ipa_resource_config_dst(struct ipa *ipa, u32 resource_type,u32 group_count = data->rsrc_group_dst_count;const struct ipa_resource_limits *ylimits;const struct ipa_resource *resource; +const struct ipa_reg *reg;u32 offset; resource = &data->resource_dst[resource_type]; - offset =ipa_reg_n_offset (ipa,DST_RSRC_GRP_01_RSRC_TYPE , - resource_type); + reg =ipa_reg (ipa,DST_RSRC_GRP_01_RSRC_TYPE ); + offset =ipa_reg_n_offset (reg, resource_type); ylimits = group_count ==1 ?NULL : &resource->limits[1 ];ipa_resource_config_common (ipa, offset, &resource->limits[0 ], ylimits);if (group_count <3 )return ; - offset =ipa_reg_n_offset (ipa,DST_RSRC_GRP_23_RSRC_TYPE , - resource_type); + reg =ipa_reg (ipa,DST_RSRC_GRP_23_RSRC_TYPE ); + offset =ipa_reg_n_offset (reg, resource_type); ylimits = group_count ==3 ?NULL : &resource->limits[3 ];ipa_resource_config_common (ipa, offset, &resource->limits[2 ], ylimits);if (group_count <5 )return ; - offset =ipa_reg_n_offset (ipa,DST_RSRC_GRP_45_RSRC_TYPE , - resource_type); + reg =ipa_reg (ipa,DST_RSRC_GRP_45_RSRC_TYPE ); + offset =ipa_reg_n_offset (reg, resource_type); ylimits = group_count ==5 ?NULL : &resource->limits[5 ];ipa_resource_config_common (ipa, offset, &resource->limits[4 ], ylimits);if (group_count <7 )return ; - offset =ipa_reg_n_offset (ipa,DST_RSRC_GRP_67_RSRC_TYPE , - resource_type); + reg =ipa_reg (ipa,DST_RSRC_GRP_67_RSRC_TYPE ); + offset =ipa_reg_n_offset (reg, resource_type); ylimits = group_count ==7 ?NULL : &resource->limits[7 ];ipa_resource_config_common (ipa, offset, &resource->limits[6 ], ylimits); }
drivers/net/ipa/ipa_table.c +11 -3
@@ -384,8 +384,9 @@ void ipa_table_reset(struct ipa *ipa, bool modem)int ipa_table_hash_flush (struct ipa *ipa) { -u32 offset =ipa_reg_offset (ipa,FILT_ROUT_HASH_FLUSH ); +const struct ipa_reg *reg;struct gsi_trans *trans; +u32 offset;u32 val;if (!ipa_table_hash_support (ipa))
@@ -397,6 +398,9 @@ int ipa_table_hash_flush(struct ipa *ipa)return -EBUSY ; } + reg =ipa_reg (ipa,FILT_ROUT_HASH_FLUSH ); + offset =ipa_reg_offset (reg); + val =IPV4_FILTER_HASH_FMASK |IPV6_FILTER_HASH_FMASK ; val |=IPV6_ROUTER_HASH_FMASK |IPV4_ROUTER_HASH_FMASK ;
@@ -517,10 +521,12 @@ static void ipa_filter_tuple_zero(struct ipa_endpoint *endpoint) {u32 endpoint_id = endpoint->endpoint_id;struct ipa *ipa = endpoint->ipa; +const struct ipa_reg *reg;u32 offset;u32 val; - offset =ipa_reg_n_offset (ipa,ENDP_FILTER_ROUTER_HSH_CFG , endpoint_id); + reg =ipa_reg (ipa,ENDP_FILTER_ROUTER_HSH_CFG ); + offset =ipa_reg_n_offset (reg, endpoint_id); val =ioread32 (endpoint->ipa->reg_virt + offset);
@@ -566,10 +572,12 @@ static bool ipa_route_id_modem(u32 route_id)*/ static void ipa_route_tuple_zero (struct ipa *ipa,u32 route_id) { +const struct ipa_reg *reg;u32 offset;u32 val; - offset =ipa_reg_n_offset (ipa,ENDP_FILTER_ROUTER_HSH_CFG , route_id); + reg =ipa_reg (ipa,ENDP_FILTER_ROUTER_HSH_CFG ); + offset =ipa_reg_n_offset (reg, route_id); val =ioread32 (ipa->reg_virt + offset);
drivers/net/ipa/ipa_uc.c +4 -1
@@ -222,6 +222,7 @@ void ipa_uc_power(struct ipa *ipa)static void send_uc_command (struct ipa *ipa,u32 command,u32 command_param) {struct ipa_uc_mem_area *shared =ipa_uc_shared (ipa); +const struct ipa_reg *reg;u32 val;/* Fill in the command data */
@@ -232,8 +233,10 @@ static void send_uc_command(struct ipa *ipa, u32 command, u32 command_param) shared->response_param =0 ;/* Use an interrupt to tell the microcontroller the command is ready */ + reg =ipa_reg (ipa,IPA_IRQ_UC ); val =u32_encode_bits (1 ,UC_INTR_FMASK ); -iowrite32 (val, ipa->reg_virt +ipa_reg_offset (ipa,IPA_IRQ_UC )); + +iowrite32 (val, ipa->reg_virt +ipa_reg_offset (reg)); }/* Tell the microcontroller the AP is shutting down */
Signature · 1 line
2.34.1
PATCH 6/15 net: ipa: introduce ipa_reg field masks
In reply to Alex ElderAdd register field descriptors to the ipa_reg structure. A field in a register is defined by a field mask, which is a 32-bit mask having a single contiguous range of bits set.
For each register that has at least one field defined, an enumerated type will identify the register's fields. The ipa_reg structure for that register will include an array fmask[] of field masks, indexed by that enumerated type. Each field mask defines the position and bit width of a field. An additional "fcount" records how many fields (masks) are defined for a given register.
Introduce two macros to be used to define registers that have at least one field.
Introduce a few new functions related to field masks. The first simply returns a field mask, given an IPA register pointer and field mask ID. A variant of that is meant to be used for the special case of single-bit field masks.
Next, ipa_reg_encode(), identifies a field with an IPA register pointer and a field ID, and takes a value to represent in that field. The result encodes the value in the appropriate place to be stored in the register. This is roughly modeled after the bitmask operations (like u32_encode_bits()).
Another function (ipa_reg_decode()) similarly identifies a register field, but the value supplied to it represents a full register value. The value encoded in the field is extracted from the value and returned. This is also roughly modeled after bitmask operations (such as u32_get_bits()).
Finally, ipa_reg_field_max() returns the maximum value representable by a field.
--- drivers/net/ipa/ipa_reg.h | 68 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+)
drivers/net/ipa/ipa_reg.h +68 -0
@@ -125,11 +125,15 @@ enum ipa_reg_id {* struct ipa_reg - An IPA register descriptor * @offset: Register offset relative to base of the "ipa-reg" memory * @stride: Distance between two instances, if parameterized +* @fcount: Number of entries in the @fmask array +* @fmask: Array of mask values defining position and width of fields * @name: Upper-case name of the IPA register */ struct ipa_reg {u32 offset;u32 stride; +u32 fcount; +const u32 *fmask;/* BIT(nr) or GENMASK(h, l) */ const char *name; };
@@ -145,6 +149,18 @@ struct ipa_reg { .stride = __stride, \ } +#define IPA_REG_FIELDS (__NAME, __name, __offset) \ + IPA_REG_STRIDE_FIELDS(__NAME, __name, __offset, 0) + +#define IPA_REG_STRIDE_FIELDS (__NAME, __name, __offset, __stride) \ + static const struct ipa_reg ipa_reg_ ## __name = { \ + .name = #__NAME, \ + .offset = __offset, \ + .stride = __stride, \ + .fcount = ARRAY_SIZE(ipa_reg_ ## __name ## _fmask), \ + .fmask = ipa_reg_ ## __name ## _fmask, \ + } +/** * struct ipa_regs - Description of registers supported by hardware * @reg_count: Number of registers in the @reg[] array
@@ -746,6 +762,58 @@ extern const struct ipa_regs ipa_regs_v4_5;extern const struct ipa_regs ipa_regs_v4_9;extern const struct ipa_regs ipa_regs_v4_11; +/* Return the field mask for a field in a register */ +static inline u32 ipa_reg_fmask (const struct ipa_reg *reg,u32 field_id) +{ +if (!reg ||WARN_ON (field_id >= reg->fcount)) +return 0 ; + +return reg->fmask[field_id]; +} + +/* Return the mask for a single-bit field in a register */ +static inline u32 ipa_reg_bit (const struct ipa_reg *reg,u32 field_id) +{ +u32 fmask =ipa_reg_fmask (reg, field_id); + +WARN_ON (!is_power_of_2 (fmask)); + +return fmask; +} + +/* Encode a value into the given field of a register */ +static inline u32 +ipa_reg_encode (const struct ipa_reg *reg,u32 field_id,u32 val) +{ +u32 fmask =ipa_reg_fmask (reg, field_id); + +if (!fmask) +return 0 ; + + val <<=__ffs (fmask); +if (WARN_ON (val & ~fmask)) +return 0 ; + +return val; +} + +/* Given a register value, decode (extract) the value in the given field */ +static inline u32 +ipa_reg_decode (const struct ipa_reg *reg,u32 field_id,u32 val) +{ +u32 fmask =ipa_reg_fmask (reg, field_id); + +return fmask ? (val & fmask) >>__ffs (fmask) :0 ; +} + +/* Return the maximum value representable by the given field; always 2^n - 1 */ +static inline u32 ipa_reg_field_max (const struct ipa_reg *reg,u32 field_id) +{ +u32 fmask =ipa_reg_fmask (reg, field_id); + +return fmask ? fmask >>__ffs (fmask) :0 ; +} +const struct ipa_reg *ipa_reg (struct ipa *ipa,enum ipa_reg_id reg_id);/* Returns 0 for NULL reg; warning will have already been issued */
Signature · 1 line
2.34.1
PATCH 7/15 net: ipa: define COMP_CFG IPA register fields
In reply to Alex ElderCreate the ipa_reg_comp_cfg_field_id enumerated type, which identifies the fields for the COMP_CFG IPA register.
Use IPA_REG_FIELDS() to specify the field mask values defined for this register, for each supported version of IPA.
Use ipa_reg_bit() to build up the value to be written to this register rather than using the *_FMASK preprocessor symbols.
Remove the definition of the *_FMASK symbols, along with the inline functions that were used to encode certain fields whose position and/or width within the register was dependent on IPA version.
Take this opportunity to represent all one-bit fields using BIT(x) rather than GENMASK(x, x).
--- drivers/net/ipa/ipa_main.c | 14 ++--- drivers/net/ipa/ipa_reg.h | 84 +++++++++------------------- drivers/net/ipa/reg/ipa_reg-v3.1.c | 11 +++- drivers/net/ipa/reg/ipa_reg-v3.5.1.c | 11 +++- drivers/net/ipa/reg/ipa_reg-v4.11.c | 31 +++++++++- drivers/net/ipa/reg/ipa_reg-v4.2.c | 24 +++++++- drivers/net/ipa/reg/ipa_reg-v4.5.c | 25 ++++++++- drivers/net/ipa/reg/ipa_reg-v4.9.c | 30 +++++++++- 8 files changed, 160 insertions(+), 70 deletions(-)
drivers/net/ipa/ipa_main.c +7 -7
@@ -257,17 +257,17 @@ static void ipa_hardware_config_comp(struct ipa *ipa) val =ioread32 (ipa->reg_virt + offset);if (ipa->version ==IPA_VERSION_4_0 ) { - val &= ~IPA_QMB_SELECT_CONS_EN_FMASK ; - val &= ~IPA_QMB_SELECT_PROD_EN_FMASK ; - val &= ~IPA_QMB_SELECT_GLOBAL_EN_FMASK ; + val &= ~ipa_reg_bit (reg,IPA_QMB_SELECT_CONS_EN ); + val &= ~ipa_reg_bit (reg,IPA_QMB_SELECT_PROD_EN ); + val &= ~ipa_reg_bit (reg,IPA_QMB_SELECT_GLOBAL_EN ); }else if (ipa->version <IPA_VERSION_4_5 ) { - val |=GSI_MULTI_AXI_MASTERS_DIS_FMASK ; + val |=ipa_reg_bit (reg,GSI_MULTI_AXI_MASTERS_DIS ); }else { -/* For IPA v4.5 IPA_FULL_FLUSH_WAIT_RSC_CLOSE_EN is 0 */ +/* For IPA v4.5 FULL_FLUSH_WAIT_RS_CLOSURE_EN is 0 */ } - val |=GSI_MULTI_INORDER_RD_DIS_FMASK ; - val |=GSI_MULTI_INORDER_WR_DIS_FMASK ; + val |=ipa_reg_bit (reg,GSI_MULTI_INORDER_RD_DIS ); + val |=ipa_reg_bit (reg,GSI_MULTI_INORDER_WR_DIS );iowrite32 (val, ipa->reg_virt + offset); }
drivers/net/ipa/ipa_reg.h +27 -57
90 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v3.1.c +10 -1
@@ -7,7 +7,16 @@#include "../ipa.h" #include "../ipa_reg.h" -IPA_REG (COMP_CFG , comp_cfg,0x0000003c ); +static const u32 ipa_reg_comp_cfg_fmask[] = { + [COMP_CFG_ENABLE ] =BIT (0 ), + [GSI_SNOC_BYPASS_DIS ] =BIT (1 ), + [GEN_QMB_0_SNOC_BYPASS_DIS ] =BIT (2 ), + [GEN_QMB_1_SNOC_BYPASS_DIS ] =BIT (3 ), + [IPA_DCMP_FAST_CLK_EN ] =BIT (4 ), +/* Bits 5-31 reserved */ +}; + +IPA_REG_FIELDS (COMP_CFG , comp_cfg,0x0000003c );IPA_REG (CLKON_CFG , clkon_cfg,0x00000044 );
drivers/net/ipa/reg/ipa_reg-v3.5.1.c +10 -1
@@ -7,7 +7,16 @@#include "../ipa.h" #include "../ipa_reg.h" -IPA_REG (COMP_CFG , comp_cfg,0x0000003c ); +static const u32 ipa_reg_comp_cfg_fmask[] = { + [COMP_CFG_ENABLE ] =BIT (0 ), + [GSI_SNOC_BYPASS_DIS ] =BIT (1 ), + [GEN_QMB_0_SNOC_BYPASS_DIS ] =BIT (2 ), + [GEN_QMB_1_SNOC_BYPASS_DIS ] =BIT (3 ), + [IPA_DCMP_FAST_CLK_EN ] =BIT (4 ), +/* Bits 5-31 reserved */ +}; + +IPA_REG_FIELDS (COMP_CFG , comp_cfg,0x0000003c );IPA_REG (CLKON_CFG , clkon_cfg,0x00000044 );
drivers/net/ipa/reg/ipa_reg-v4.11.c +30 -1
@@ -7,7 +7,36 @@#include "../ipa.h" #include "../ipa_reg.h" -IPA_REG (COMP_CFG , comp_cfg,0x0000003c ); +static const u32 ipa_reg_comp_cfg_fmask[] = { + [RAM_ARB_PRI_CLIENT_SAMP_FIX_DIS ] =BIT (0 ), + [GSI_SNOC_BYPASS_DIS ] =BIT (1 ), + [GEN_QMB_0_SNOC_BYPASS_DIS ] =BIT (2 ), + [GEN_QMB_1_SNOC_BYPASS_DIS ] =BIT (3 ), +/* Bit 4 reserved */ + [IPA_QMB_SELECT_CONS_EN ] =BIT (5 ), + [IPA_QMB_SELECT_PROD_EN ] =BIT (6 ), + [GSI_MULTI_INORDER_RD_DIS ] =BIT (7 ), + [GSI_MULTI_INORDER_WR_DIS ] =BIT (8 ), + [GEN_QMB_0_MULTI_INORDER_RD_DIS ] =BIT (9 ), + [GEN_QMB_1_MULTI_INORDER_RD_DIS ] =BIT (10 ), + [GEN_QMB_0_MULTI_INORDER_WR_DIS ] =BIT (11 ), + [GEN_QMB_1_MULTI_INORDER_WR_DIS ] =BIT (12 ), + [GEN_QMB_0_SNOC_CNOC_LOOP_PROT_DIS ] =BIT (13 ), + [GSI_SNOC_CNOC_LOOP_PROT_DISABLE ] =BIT (14 ), + [GSI_MULTI_AXI_MASTERS_DIS ] =BIT (15 ), + [IPA_QMB_SELECT_GLOBAL_EN ] =BIT (16 ), + [FULL_FLUSH_WAIT_RS_CLOSURE_EN ] =BIT (17 ), +/* Bit 18 reserved */ + [QMB_RAM_RD_CACHE_DISABLE ] =BIT (19 ), + [GENQMB_AOOOWR ] =BIT (20 ), + [IF_OUT_OF_BUF_STOP_RESET_MASK_EN ] =BIT (21 ), + [ATOMIC_FETCHER_ARB_LOCK_DIS ] =GENMASK (23 ,22 ), +/* Bits 24-29 reserved */ + [GEN_QMB_1_DYNAMIC_ASIZE ] =BIT (30 ), + [GEN_QMB_0_DYNAMIC_ASIZE ] =BIT (31 ), +}; + +IPA_REG_FIELDS (COMP_CFG , comp_cfg,0x0000003c );IPA_REG (CLKON_CFG , clkon_cfg,0x00000044 );
drivers/net/ipa/reg/ipa_reg-v4.2.c +23 -1
@@ -7,7 +7,29 @@#include "../ipa.h" #include "../ipa_reg.h" -IPA_REG (COMP_CFG , comp_cfg,0x0000003c ); +static const u32 ipa_reg_comp_cfg_fmask[] = { +/* Bit 0 reserved */ + [GSI_SNOC_BYPASS_DIS ] =BIT (1 ), + [GEN_QMB_0_SNOC_BYPASS_DIS ] =BIT (2 ), + [GEN_QMB_1_SNOC_BYPASS_DIS ] =BIT (3 ), + [IPA_DCMP_FAST_CLK_EN ] =BIT (4 ), + [IPA_QMB_SELECT_CONS_EN ] =BIT (5 ), + [IPA_QMB_SELECT_PROD_EN ] =BIT (6 ), + [GSI_MULTI_INORDER_RD_DIS ] =BIT (7 ), + [GSI_MULTI_INORDER_WR_DIS ] =BIT (8 ), + [GEN_QMB_0_MULTI_INORDER_RD_DIS ] =BIT (9 ), + [GEN_QMB_1_MULTI_INORDER_RD_DIS ] =BIT (10 ), + [GEN_QMB_0_MULTI_INORDER_WR_DIS ] =BIT (11 ), + [GEN_QMB_1_MULTI_INORDER_WR_DIS ] =BIT (12 ), + [GEN_QMB_0_SNOC_CNOC_LOOP_PROT_DIS ] =BIT (13 ), + [GSI_SNOC_CNOC_LOOP_PROT_DISABLE ] =BIT (14 ), + [GSI_MULTI_AXI_MASTERS_DIS ] =BIT (15 ), + [IPA_QMB_SELECT_GLOBAL_EN ] =BIT (16 ), + [ATOMIC_FETCHER_ARB_LOCK_DIS ] =GENMASK (20 ,17 ), +/* Bits 21-31 reserved */ +}; + +IPA_REG_FIELDS (COMP_CFG , comp_cfg,0x0000003c );IPA_REG (CLKON_CFG , clkon_cfg,0x00000044 );
drivers/net/ipa/reg/ipa_reg-v4.5.c +24 -1
@@ -7,7 +7,30 @@#include "../ipa.h" #include "../ipa_reg.h" -IPA_REG (COMP_CFG , comp_cfg,0x0000003c ); +static const u32 ipa_reg_comp_cfg_fmask[] = { +/* Bit 0 reserved */ + [GSI_SNOC_BYPASS_DIS ] =BIT (1 ), + [GEN_QMB_0_SNOC_BYPASS_DIS ] =BIT (2 ), + [GEN_QMB_1_SNOC_BYPASS_DIS ] =BIT (3 ), +/* Bit 4 reserved */ + [IPA_QMB_SELECT_CONS_EN ] =BIT (5 ), + [IPA_QMB_SELECT_PROD_EN ] =BIT (6 ), + [GSI_MULTI_INORDER_RD_DIS ] =BIT (7 ), + [GSI_MULTI_INORDER_WR_DIS ] =BIT (8 ), + [GEN_QMB_0_MULTI_INORDER_RD_DIS ] =BIT (9 ), + [GEN_QMB_1_MULTI_INORDER_RD_DIS ] =BIT (10 ), + [GEN_QMB_0_MULTI_INORDER_WR_DIS ] =BIT (11 ), + [GEN_QMB_1_MULTI_INORDER_WR_DIS ] =BIT (12 ), + [GEN_QMB_0_SNOC_CNOC_LOOP_PROT_DIS ] =BIT (13 ), + [GSI_SNOC_CNOC_LOOP_PROT_DISABLE ] =BIT (14 ), + [GSI_MULTI_AXI_MASTERS_DIS ] =BIT (15 ), + [IPA_QMB_SELECT_GLOBAL_EN ] =BIT (16 ), + [ATOMIC_FETCHER_ARB_LOCK_DIS ] =GENMASK (20 ,17 ), + [FULL_FLUSH_WAIT_RS_CLOSURE_EN ] =BIT (21 ), +/* Bits 22-31 reserved */ +}; + +IPA_REG_FIELDS (COMP_CFG , comp_cfg,0x0000003c );IPA_REG (CLKON_CFG , clkon_cfg,0x00000044 );
drivers/net/ipa/reg/ipa_reg-v4.9.c +29 -1
@@ -7,7 +7,35 @@#include "../ipa.h" #include "../ipa_reg.h" -IPA_REG (COMP_CFG , comp_cfg,0x0000003c ); +static const u32 ipa_reg_comp_cfg_fmask[] = { + [RAM_ARB_PRI_CLIENT_SAMP_FIX_DIS ] =BIT (0 ), + [GSI_SNOC_BYPASS_DIS ] =BIT (1 ), + [GEN_QMB_0_SNOC_BYPASS_DIS ] =BIT (2 ), + [GEN_QMB_1_SNOC_BYPASS_DIS ] =BIT (3 ), +/* Bit 4 reserved */ + [IPA_QMB_SELECT_CONS_EN ] =BIT (5 ), + [IPA_QMB_SELECT_PROD_EN ] =BIT (6 ), + [GSI_MULTI_INORDER_RD_DIS ] =BIT (7 ), + [GSI_MULTI_INORDER_WR_DIS ] =BIT (8 ), + [GEN_QMB_0_MULTI_INORDER_RD_DIS ] =BIT (9 ), + [GEN_QMB_1_MULTI_INORDER_RD_DIS ] =BIT (10 ), + [GEN_QMB_0_MULTI_INORDER_WR_DIS ] =BIT (11 ), + [GEN_QMB_1_MULTI_INORDER_WR_DIS ] =BIT (12 ), + [GEN_QMB_0_SNOC_CNOC_LOOP_PROT_DIS ] =BIT (13 ), + [GSI_SNOC_CNOC_LOOP_PROT_DISABLE ] =BIT (14 ), + [GSI_MULTI_AXI_MASTERS_DIS ] =BIT (15 ), + [IPA_QMB_SELECT_GLOBAL_EN ] =BIT (16 ), + [FULL_FLUSH_WAIT_RS_CLOSURE_EN ] =BIT (17 ), + [QMB_RAM_RD_CACHE_DISABLE ] =BIT (19 ), + [GENQMB_AOOOWR ] =BIT (20 ), + [IF_OUT_OF_BUF_STOP_RESET_MASK_EN ] =BIT (21 ), + [ATOMIC_FETCHER_ARB_LOCK_DIS ] =GENMASK (24 ,22 ), +/* Bits 25-29 reserved */ + [GEN_QMB_1_DYNAMIC_ASIZE ] =BIT (30 ), + [GEN_QMB_0_DYNAMIC_ASIZE ] =BIT (31 ), +}; + +IPA_REG_FIELDS (COMP_CFG , comp_cfg,0x0000003c );IPA_REG (CLKON_CFG , clkon_cfg,0x00000044 );
Signature · 1 line
2.34.1
PATCH 8/15 net: ipa: define CLKON_CFG and ROUTE IPA register fields
In reply to Alex ElderCreate the ipa_reg_clkon_cfg_field_id enumerated type, which identifies the fields for the CLKON_CFG IPA register. Add "CLKON_" to a few short names to try to avoid name conflicts. Create the ipa_reg_route_field_id enumerated type, which identifies the fields for the ROUTE IPA register.
Use IPA_REG_FIELDS() to specify the field mask values defined for these registers, for each supported version of IPA.
Use ipa_reg_bit() and ipa_reg_encode() to build up the values to be written to these registers rather than using the *_FMASK preprocessor symbols.
Remove the definition of the now unused *_FMASK symbols.
--- drivers/net/ipa/ipa_endpoint.c | 10 ++-- drivers/net/ipa/ipa_main.c | 12 ++-- drivers/net/ipa/ipa_reg.h | 86 ++++++++++++++-------------- drivers/net/ipa/reg/ipa_reg-v3.1.c | 36 +++++++++++- drivers/net/ipa/reg/ipa_reg-v3.5.1.c | 41 ++++++++++++- drivers/net/ipa/reg/ipa_reg-v4.11.c | 50 +++++++++++++++- drivers/net/ipa/reg/ipa_reg-v4.2.c | 49 +++++++++++++++- drivers/net/ipa/reg/ipa_reg-v4.5.c | 50 +++++++++++++++- drivers/net/ipa/reg/ipa_reg-v4.9.c | 50 +++++++++++++++- 9 files changed, 319 insertions(+), 65 deletions(-)
drivers/net/ipa/ipa_endpoint.c +5 -5
@@ -1473,11 +1473,11 @@ void ipa_endpoint_default_route_set(struct ipa *ipa, u32 endpoint_id) reg =ipa_reg (ipa,ROUTE );/* ROUTE_DIS is 0 */ - val =u32_encode_bits (endpoint_id,ROUTE_DEF_PIPE_FMASK ); - val |=ROUTE_DEF_HDR_TABLE_FMASK ; - val |=u32_encode_bits (0 ,ROUTE_DEF_HDR_OFST_FMASK ); - val |=u32_encode_bits (endpoint_id,ROUTE_FRAG_DEF_PIPE_FMASK ); - val |=ROUTE_DEF_RETAIN_HDR_FMASK ; + val =ipa_reg_encode (reg,ROUTE_DEF_PIPE , endpoint_id); + val |=ipa_reg_bit (reg,ROUTE_DEF_HDR_TABLE ); +/* ROUTE_DEF_HDR_OFST is 0 */ + val |=ipa_reg_encode (reg,ROUTE_FRAG_DEF_PIPE , endpoint_id); + val |=ipa_reg_bit (reg,ROUTE_DEF_RETAIN_HDR );iowrite32 (val, ipa->reg_virt +ipa_reg_offset (reg)); }
drivers/net/ipa/ipa_main.c +8 -4
@@ -233,10 +233,14 @@ static void ipa_hardware_config_clkon(struct ipa *ipa)/* Implement some hardware workarounds */ reg =ipa_reg (ipa,CLKON_CFG ); -if (version ==IPA_VERSION_3_1 ) - val =MISC_FMASK ;/* Disable MISC clock gating */ -else /* Enable open global clocks in the CLKON configuration */ - val =GLOBAL_FMASK |GLOBAL_2X_CLK_FMASK ;/* IPA v4.0+ */ +if (version ==IPA_VERSION_3_1 ) { +/* Disable MISC clock gating */ + val =ipa_reg_bit (reg,CLKON_MISC ); + }else {/* IPA v4.0+ */ +/* Enable open global clocks in the CLKON configuration */ + val =ipa_reg_bit (reg,CLKON_GLOBAL ); + val |=ipa_reg_bit (reg,GLOBAL_2X_CLK ); + }iowrite32 (val, ipa->reg_virt +ipa_reg_offset (reg)); }
drivers/net/ipa/ipa_reg.h +42 -44
94 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v3.1.c +34 -2
@@ -18,9 +18,41 @@ static const u32 ipa_reg_comp_cfg_fmask[] = {IPA_REG_FIELDS (COMP_CFG , comp_cfg,0x0000003c ); -IPA_REG (CLKON_CFG , clkon_cfg,0x00000044 ); +static const u32 ipa_reg_clkon_cfg_fmask[] = { + [CLKON_RX ] =BIT (0 ), + [CLKON_PROC ] =BIT (1 ), + [TX_WRAPPER ] =BIT (2 ), + [CLKON_MISC ] =BIT (3 ), + [RAM_ARB ] =BIT (4 ), + [FTCH_HPS ] =BIT (5 ), + [FTCH_DPS ] =BIT (6 ), + [CLKON_HPS ] =BIT (7 ), + [CLKON_DPS ] =BIT (8 ), + [RX_HPS_CMDQS ] =BIT (9 ), + [HPS_DPS_CMDQS ] =BIT (10 ), + [DPS_TX_CMDQS ] =BIT (11 ), + [RSRC_MNGR ] =BIT (12 ), + [CTX_HANDLER ] =BIT (13 ), + [ACK_MNGR ] =BIT (14 ), + [D_DCPH ] =BIT (15 ), + [H_DCPH ] =BIT (16 ), +/* Bits 17-31 reserved */ +}; -IPA_REG (ROUTE , route,0x00000048 ); +IPA_REG_FIELDS (CLKON_CFG , clkon_cfg,0x00000044 ); + +static const u32 ipa_reg_route_fmask[] = { + [ROUTE_DIS ] =BIT (0 ), + [ROUTE_DEF_PIPE ] =GENMASK (5 ,1 ), + [ROUTE_DEF_HDR_TABLE ] =BIT (6 ), + [ROUTE_DEF_HDR_OFST ] =GENMASK (16 ,7 ), + [ROUTE_FRAG_DEF_PIPE ] =GENMASK (21 ,17 ), +/* Bits 22-23 reserved */ + [ROUTE_DEF_RETAIN_HDR ] =BIT (24 ), +/* Bits 25-31 reserved */ +}; + +IPA_REG_FIELDS (ROUTE , route,0x00000048 );IPA_REG (SHARED_MEM_SIZE , shared_mem_size,0x00000054 );
drivers/net/ipa/reg/ipa_reg-v3.5.1.c +39 -2
48 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v4.11.c +48 -2
57 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v4.2.c +47 -2
56 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v4.5.c +48 -2
57 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v4.9.c +48 -2
57 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 9/15 net: ipa: define some more IPA register fields
In reply to Alex ElderDefine the fields for the SHARED_MEM_SIZE, QSB_MAX_WRITES, QSB_MAX_READS, FILT_ROUT_HASH_EN, and FILT_ROUT_HASH_FLUSH IPA registers for all supported IPA versions.
Create enumerated types to identify fields for these registers. Use IPA_REG_FIELDS() to specify the field mask values defined for these registers, for each supported version of IPA.
Use ipa_reg_bit() and ipa_reg_encode() to build up the values to be written to these registers rather than using the *_FMASK preprocessor symbols.
Remove the definition of the now unused *_FMASK symbols.
--- drivers/net/ipa/ipa_main.c | 24 +++++++------ drivers/net/ipa/ipa_mem.c | 5 +-- drivers/net/ipa/ipa_reg.h | 33 +++++++++++------- drivers/net/ipa/ipa_table.c | 6 ++-- drivers/net/ipa/reg/ipa_reg-v3.1.c | 48 +++++++++++++++++++++++--- drivers/net/ipa/reg/ipa_reg-v3.5.1.c | 48 +++++++++++++++++++++++--- drivers/net/ipa/reg/ipa_reg-v4.11.c | 51 +++++++++++++++++++++++++--- drivers/net/ipa/reg/ipa_reg-v4.2.c | 51 +++++++++++++++++++++++++--- drivers/net/ipa/reg/ipa_reg-v4.5.c | 51 +++++++++++++++++++++++++--- drivers/net/ipa/reg/ipa_reg-v4.9.c | 51 +++++++++++++++++++++++++--- 10 files changed, 311 insertions(+), 57 deletions(-)
drivers/net/ipa/ipa_main.c +14 -10
@@ -293,26 +293,26 @@ ipa_hardware_config_qsb(struct ipa *ipa, const struct ipa_data *data)/* Max outstanding write accesses for QSB masters */ reg =ipa_reg (ipa,QSB_MAX_WRITES ); - val =u32_encode_bits (data0->max_writes,GEN_QMB_0_MAX_WRITES_FMASK ); + val =ipa_reg_encode (reg,GEN_QMB_0_MAX_WRITES , data0->max_writes);if (data->qsb_count >1 ) - val |=u32_encode_bits (data1->max_writes, -GEN_QMB_1_MAX_WRITES_FMASK ); + val |=ipa_reg_encode (reg,GEN_QMB_1_MAX_WRITES , + data1->max_writes);iowrite32 (val, ipa->reg_virt +ipa_reg_offset (reg));/* Max outstanding read accesses for QSB masters */ reg =ipa_reg (ipa,QSB_MAX_READS ); - val =u32_encode_bits (data0->max_reads,GEN_QMB_0_MAX_READS_FMASK ); + val =ipa_reg_encode (reg,GEN_QMB_0_MAX_READS , data0->max_reads);if (ipa->version >=IPA_VERSION_4_0 ) - val |=u32_encode_bits (data0->max_reads_beats, -GEN_QMB_0_MAX_READS_BEATS_FMASK ); + val |=ipa_reg_encode (reg,GEN_QMB_0_MAX_READS_BEATS , + data0->max_reads_beats);if (data->qsb_count >1 ) { - val |=u32_encode_bits (data1->max_reads, -GEN_QMB_1_MAX_READS_FMASK ); + val =ipa_reg_encode (reg,GEN_QMB_1_MAX_READS , + data1->max_reads);if (ipa->version >=IPA_VERSION_4_0 ) - val |=u32_encode_bits (data1->max_reads_beats, -GEN_QMB_1_MAX_READS_BEATS_FMASK ); + val |=ipa_reg_encode (reg,GEN_QMB_1_MAX_READS_BEATS , + data1->max_reads_beats); }iowrite32 (val, ipa->reg_virt +ipa_reg_offset (reg));
@@ -419,6 +419,10 @@ static void ipa_hardware_config_hashing(struct ipa *ipa)/* IPA v4.2 does not support hashed tables, so disable them */ reg =ipa_reg (ipa,FILT_ROUT_HASH_EN ); + +/* IPV6_ROUTER_HASH, IPV6_FILTER_HASH, IPV4_ROUTER_HASH, +* IPV4_FILTER_HASH are all zero. +*/ iowrite32 (0 , ipa->reg_virt +ipa_reg_offset (reg)); }
drivers/net/ipa/ipa_mem.c +3 -2
@@ -322,9 +322,10 @@ int ipa_mem_config(struct ipa *ipa) val =ioread32 (ipa->reg_virt +ipa_reg_offset (reg));/* The fields in the register are in 8 byte units */ - ipa->mem_offset =8 *u32_get_bits (val,SHARED_MEM_BADDR_FMASK ); + ipa->mem_offset =8 *ipa_reg_decode (reg,MEM_BADDR , val); +/* Make sure the end is within the region's mapped space */ - mem_size =8 *u32_get_bits (val,SHARED_MEM_SIZE_FMASK ); + mem_size =8 *ipa_reg_decode (reg,MEM_SIZE , val);/* If the sizes don't match, issue a warning */ if (ipa->mem_offset + mem_size < ipa->mem_size) {
drivers/net/ipa/ipa_reg.h +20 -13
@@ -247,25 +247,32 @@ enum ipa_reg_route_field_id { };/* SHARED_MEM_SIZE register */ -#define SHARED_MEM_SIZE_FMASK GENMASK(15, 0) -#define SHARED_MEM_BADDR_FMASK GENMASK(31, 16) +enum ipa_reg_shared_mem_size_field_id { +MEM_SIZE , +MEM_BADDR , +};/* QSB_MAX_WRITES register */ -#define GEN_QMB_0_MAX_WRITES_FMASK GENMASK(3, 0) -#define GEN_QMB_1_MAX_WRITES_FMASK GENMASK(7, 4) +enum ipa_reg_qsb_max_writes_field_id { +GEN_QMB_0_MAX_WRITES , +GEN_QMB_1_MAX_WRITES , +};/* QSB_MAX_READS register */ -#define GEN_QMB_0_MAX_READS_FMASK GENMASK(3, 0) -#define GEN_QMB_1_MAX_READS_FMASK GENMASK(7, 4) -/* The next two fields are present for IPA v4.0+ */ -#define GEN_QMB_0_MAX_READS_BEATS_FMASK GENMASK(23, 16) -#define GEN_QMB_1_MAX_READS_BEATS_FMASK GENMASK(31, 24) +enum ipa_reg_qsb_max_reads_field_id { +GEN_QMB_0_MAX_READS , +GEN_QMB_1_MAX_READS , +GEN_QMB_0_MAX_READS_BEATS ,/* IPA v4.0+ */ +GEN_QMB_1_MAX_READS_BEATS ,/* IPA v4.0+ */ +};/* FILT_ROUT_HASH_EN and FILT_ROUT_HASH_FLUSH registers */ -#define IPV6_ROUTER_HASH_FMASK GENMASK(0, 0) -#define IPV6_FILTER_HASH_FMASK GENMASK(4, 4) -#define IPV4_ROUTER_HASH_FMASK GENMASK(8, 8) -#define IPV4_FILTER_HASH_FMASK GENMASK(12, 12) +enum ipa_reg_rout_hash_field_id { +IPV6_ROUTER_HASH , +IPV6_FILTER_HASH , +IPV4_ROUTER_HASH , +IPV4_FILTER_HASH , +};/* BCR register */ enum ipa_bcr_compat {
drivers/net/ipa/ipa_table.c +4 -2
@@ -401,8 +401,10 @@ int ipa_table_hash_flush(struct ipa *ipa) reg =ipa_reg (ipa,FILT_ROUT_HASH_FLUSH ); offset =ipa_reg_offset (reg); - val =IPV4_FILTER_HASH_FMASK |IPV6_FILTER_HASH_FMASK ; - val |=IPV6_ROUTER_HASH_FMASK |IPV4_ROUTER_HASH_FMASK ; + val =ipa_reg_bit (reg,IPV6_ROUTER_HASH ); + val |=ipa_reg_bit (reg,IPV6_FILTER_HASH ); + val |=ipa_reg_bit (reg,IPV4_ROUTER_HASH ); + val |=ipa_reg_bit (reg,IPV4_FILTER_HASH );ipa_cmd_register_write_add (trans, offset, val, val, false);
drivers/net/ipa/reg/ipa_reg-v3.1.c +43 -5
58 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v3.5.1.c +43 -5
58 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v4.11.c +46 -5
61 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v4.2.c +46 -5
61 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v4.5.c +46 -5
61 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v4.9.c +46 -5
61 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 10/15 net: ipa: define more IPA register fields
In reply to Alex ElderDefine the fields for the LOCAL_PKT_PROC_CNTXT, COUNTER_CFG, and IPA_TX_CFG IPA registers for all supported IPA versions.
Create enumerated types to identify fields for these IPA registers. Use IPA_REG_FIELDS() to specify the field mask values defined for these registers, for each supported version of IPA.
Use ipa_reg_bit() and ipa_reg_encode() to build up the values to be written to these registers. Remove the definition of the *_FMASK symbols as well as proc_cntxt_base_addr_encoded(), because they are no longer needed.
--- drivers/net/ipa/ipa_main.c | 7 ++-- drivers/net/ipa/ipa_mem.c | 2 +- drivers/net/ipa/ipa_reg.h | 50 ++++++++++++---------------- drivers/net/ipa/reg/ipa_reg-v3.1.c | 15 +++++++-- drivers/net/ipa/reg/ipa_reg-v3.5.1.c | 24 +++++++++++-- drivers/net/ipa/reg/ipa_reg-v4.11.c | 22 ++++++++++-- drivers/net/ipa/reg/ipa_reg-v4.2.c | 31 +++++++++++++++-- drivers/net/ipa/reg/ipa_reg-v4.5.c | 21 ++++++++++-- drivers/net/ipa/reg/ipa_reg-v4.9.c | 22 ++++++++++-- 9 files changed, 146 insertions(+), 48 deletions(-)
drivers/net/ipa/ipa_main.c +3 -4
@@ -214,7 +214,7 @@ static void ipa_hardware_config_tx(struct ipa *ipa) val =ioread32 (ipa->reg_virt + offset); - val &= ~PA_MASK_EN_FMASK ; + val &= ~ipa_reg_bit (reg,PA_MASK_EN );iowrite32 (val, ipa->reg_virt + offset); }
@@ -398,7 +398,8 @@ static void ipa_hardware_config_counter(struct ipa *ipa)u32 val; reg =ipa_reg (ipa,COUNTER_CFG ); - val =u32_encode_bits (granularity,AGGR_GRANULARITY_FMASK ); +/* If defined, EOT_COAL_GRANULARITY is 0 */ + val =ipa_reg_encode (reg,AGGR_GRANULARITY , granularity);iowrite32 (val, ipa->reg_virt +ipa_reg_offset (reg)); }
@@ -690,8 +691,6 @@ static void ipa_validate_build(void)/* Aggregation granularity value can't be 0, and must fit */ BUILD_BUG_ON (!ipa_aggr_granularity_val (IPA_AGGR_GRANULARITY )); -BUILD_BUG_ON (ipa_aggr_granularity_val (IPA_AGGR_GRANULARITY ) > -field_max (AGGR_GRANULARITY_FMASK )); }/**
drivers/net/ipa/ipa_mem.c +1 -1
@@ -115,7 +115,7 @@ int ipa_mem_setup(struct ipa *ipa) offset = ipa->mem_offset + mem->offset; reg =ipa_reg (ipa,LOCAL_PKT_PROC_CNTXT ); - val =proc_cntxt_base_addr_encoded (ipa->version, offset); + val =ipa_reg_encode (reg,IPA_BASE_ADDR , offset);iowrite32 (val, ipa->reg_virt +ipa_reg_offset (reg));return 0 ;
drivers/net/ipa/ipa_reg.h +21 -29
60 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v3.1.c +13 -2
@@ -107,13 +107,24 @@ IPA_REG(STATE_AGGR_ACTIVE, state_aggr_active, 0x0000010c);IPA_REG (IPA_BCR , ipa_bcr,0x000001d0 ); +static const u32 ipa_reg_local_pkt_proc_cntxt_fmask[] = { + [IPA_BASE_ADDR ] =GENMASK (16 ,0 ), +/* Bits 17-31 reserved */ +}; +/* Offset must be a multiple of 8 */ -IPA_REG (LOCAL_PKT_PROC_CNTXT , local_pkt_proc_cntxt,0x000001e8 ); +IPA_REG_FIELDS (LOCAL_PKT_PROC_CNTXT , local_pkt_proc_cntxt,0x000001e8 );/* Valid bits defined by ipa->available */ IPA_REG (AGGR_FORCE_CLOSE , aggr_force_close,0x000001ec ); -IPA_REG (COUNTER_CFG , counter_cfg,0x000001f0 ); +static const u32 ipa_reg_counter_cfg_fmask[] = { + [EOT_COAL_GRANULARITY ] =GENMASK (3 ,0 ), + [AGGR_GRANULARITY ] =GENMASK (8 ,4 ), +/* Bits 5-31 reserved */ +}; + +IPA_REG_FIELDS (COUNTER_CFG , counter_cfg,0x000001f0 );IPA_REG_STRIDE (SRC_RSRC_GRP_01_RSRC_TYPE , src_rsrc_grp_01_rsrc_type,0x00000400 ,0x0020 );
drivers/net/ipa/reg/ipa_reg-v3.5.1.c +21 -3
@@ -112,15 +112,33 @@ IPA_REG(STATE_AGGR_ACTIVE, state_aggr_active, 0x0000010c);IPA_REG (IPA_BCR , ipa_bcr,0x000001d0 ); +static const u32 ipa_reg_local_pkt_proc_cntxt_fmask[] = { + [IPA_BASE_ADDR ] =GENMASK (16 ,0 ), +/* Bits 17-31 reserved */ +}; +/* Offset must be a multiple of 8 */ -IPA_REG (LOCAL_PKT_PROC_CNTXT , local_pkt_proc_cntxt,0x000001e8 ); +IPA_REG_FIELDS (LOCAL_PKT_PROC_CNTXT , local_pkt_proc_cntxt,0x000001e8 );/* Valid bits defined by ipa->available */ IPA_REG (AGGR_FORCE_CLOSE , aggr_force_close,0x000001ec ); -IPA_REG (COUNTER_CFG , counter_cfg,0x000001f0 ); +static const u32 ipa_reg_counter_cfg_fmask[] = { +/* Bits 0-3 reserved */ + [AGGR_GRANULARITY ] =GENMASK (8 ,4 ), +/* Bits 5-31 reserved */ +}; -IPA_REG (IPA_TX_CFG , ipa_tx_cfg,0x000001fc ); +IPA_REG_FIELDS (COUNTER_CFG , counter_cfg,0x000001f0 ); + +static const u32 ipa_reg_ipa_tx_cfg_fmask[] = { + [TX0_PREFETCH_DISABLE ] =BIT (0 ), + [TX1_PREFETCH_DISABLE ] =BIT (1 ), + [PREFETCH_ALMOST_EMPTY_SIZE ] =GENMASK (4 ,2 ), +/* Bits 5-31 reserved */ +}; + +IPA_REG_FIELDS (IPA_TX_CFG , ipa_tx_cfg,0x000001fc );IPA_REG (FLAVOR_0 , flavor_0,0x00000210 );
drivers/net/ipa/reg/ipa_reg-v4.11.c +20 -2
@@ -142,13 +142,31 @@ IPA_REG_FIELDS(FILT_ROUT_HASH_FLUSH, filt_rout_hash_flush, 0x000014c);/* Valid bits defined by ipa->available */ IPA_REG (STATE_AGGR_ACTIVE , state_aggr_active,0x000000b4 ); +static const u32 ipa_reg_local_pkt_proc_cntxt_fmask[] = { + [IPA_BASE_ADDR ] =GENMASK (17 ,0 ), +/* Bits 18-31 reserved */ +}; +/* Offset must be a multiple of 8 */ -IPA_REG (LOCAL_PKT_PROC_CNTXT , local_pkt_proc_cntxt,0x000001e8 ); +IPA_REG_FIELDS (LOCAL_PKT_PROC_CNTXT , local_pkt_proc_cntxt,0x000001e8 );/* Valid bits defined by ipa->available */ IPA_REG (AGGR_FORCE_CLOSE , aggr_force_close,0x000001ec ); -IPA_REG (IPA_TX_CFG , ipa_tx_cfg,0x000001fc ); +static const u32 ipa_reg_ipa_tx_cfg_fmask[] = { +/* Bits 0-1 reserved */ + [PREFETCH_ALMOST_EMPTY_SIZE_TX0 ] =GENMASK (5 ,2 ), + [DMAW_SCND_OUTSD_PRED_THRESHOLD ] =GENMASK (9 ,6 ), + [DMAW_SCND_OUTSD_PRED_EN ] =BIT (10 ), + [DMAW_MAX_BEATS_256_DIS ] =BIT (11 ), + [PA_MASK_EN ] =BIT (12 ), + [PREFETCH_ALMOST_EMPTY_SIZE_TX1 ] =GENMASK (16 ,13 ), + [DUAL_TX_ENABLE ] =BIT (17 ), + [SSPND_PA_NO_START_STATE ] =BIT (18 ), +/* Bits 19-31 reserved */ +}; + +IPA_REG_FIELDS (IPA_TX_CFG , ipa_tx_cfg,0x000001fc );IPA_REG (FLAVOR_0 , flavor_0,0x00000210 );
drivers/net/ipa/reg/ipa_reg-v4.2.c +28 -3
@@ -136,15 +136,40 @@ IPA_REG(STATE_AGGR_ACTIVE, state_aggr_active, 0x000000b4);IPA_REG (IPA_BCR , ipa_bcr,0x000001d0 ); +static const u32 ipa_reg_local_pkt_proc_cntxt_fmask[] = { + [IPA_BASE_ADDR ] =GENMASK (16 ,0 ), +/* Bits 17-31 reserved */ +}; +/* Offset must be a multiple of 8 */ -IPA_REG (LOCAL_PKT_PROC_CNTXT , local_pkt_proc_cntxt,0x000001e8 ); +IPA_REG_FIELDS (LOCAL_PKT_PROC_CNTXT , local_pkt_proc_cntxt,0x000001e8 );/* Valid bits defined by ipa->available */ IPA_REG (AGGR_FORCE_CLOSE , aggr_force_close,0x000001ec ); -IPA_REG (COUNTER_CFG , counter_cfg,0x000001f0 ); +static const u32 ipa_reg_counter_cfg_fmask[] = { +/* Bits 0-3 reserved */ + [AGGR_GRANULARITY ] =GENMASK (8 ,4 ), +/* Bits 9-31 reserved */ +}; -IPA_REG (IPA_TX_CFG , ipa_tx_cfg,0x000001fc ); +IPA_REG_FIELDS (COUNTER_CFG , counter_cfg,0x000001f0 ); + +static const u32 ipa_reg_ipa_tx_cfg_fmask[] = { +/* Bits 0-1 reserved */ + [PREFETCH_ALMOST_EMPTY_SIZE_TX0 ] =GENMASK (5 ,2 ), + [DMAW_SCND_OUTSD_PRED_THRESHOLD ] =GENMASK (9 ,6 ), + [DMAW_SCND_OUTSD_PRED_EN ] =BIT (10 ), + [DMAW_MAX_BEATS_256_DIS ] =BIT (11 ), + [PA_MASK_EN ] =BIT (12 ), + [PREFETCH_ALMOST_EMPTY_SIZE_TX1 ] =GENMASK (16 ,13 ), +/* Bit 17 reserved */ + [SSPND_PA_NO_START_STATE ] =BIT (18 ), + [SSPND_PA_NO_BQ_STATE ] =BIT (19 ), +/* Bits 20-31 reserved */ +}; + +IPA_REG_FIELDS (IPA_TX_CFG , ipa_tx_cfg,0x000001fc );IPA_REG (FLAVOR_0 , flavor_0,0x00000210 );
drivers/net/ipa/reg/ipa_reg-v4.5.c +19 -2
@@ -136,13 +136,30 @@ IPA_REG_FIELDS(FILT_ROUT_HASH_FLUSH, filt_rout_hash_flush, 0x000014c);/* Valid bits defined by ipa->available */ IPA_REG (STATE_AGGR_ACTIVE , state_aggr_active,0x000000b4 ); +static const u32 ipa_reg_local_pkt_proc_cntxt_fmask[] = { + [IPA_BASE_ADDR ] =GENMASK (17 ,0 ), +/* Bits 18-31 reserved */ +}; +/* Offset must be a multiple of 8 */ -IPA_REG (LOCAL_PKT_PROC_CNTXT , local_pkt_proc_cntxt,0x000001e8 ); +IPA_REG_FIELDS (LOCAL_PKT_PROC_CNTXT , local_pkt_proc_cntxt,0x000001e8 );/* Valid bits defined by ipa->available */ IPA_REG (AGGR_FORCE_CLOSE , aggr_force_close,0x000001ec ); -IPA_REG (IPA_TX_CFG , ipa_tx_cfg,0x000001fc ); +static const u32 ipa_reg_ipa_tx_cfg_fmask[] = { +/* Bits 0-1 reserved */ + [PREFETCH_ALMOST_EMPTY_SIZE_TX0 ] =GENMASK (5 ,2 ), + [DMAW_SCND_OUTSD_PRED_THRESHOLD ] =GENMASK (9 ,6 ), + [DMAW_SCND_OUTSD_PRED_EN ] =BIT (10 ), + [DMAW_MAX_BEATS_256_DIS ] =BIT (11 ), + [PA_MASK_EN ] =BIT (12 ), + [PREFETCH_ALMOST_EMPTY_SIZE_TX1 ] =GENMASK (16 ,13 ), + [DUAL_TX_ENABLE ] =BIT (17 ), +/* Bits 18-31 reserved */ +}; + +IPA_REG_FIELDS (IPA_TX_CFG , ipa_tx_cfg,0x000001fc );IPA_REG (FLAVOR_0 , flavor_0,0x00000210 );
drivers/net/ipa/reg/ipa_reg-v4.9.c +20 -2
@@ -141,13 +141,31 @@ IPA_REG_FIELDS(FILT_ROUT_HASH_FLUSH, filt_rout_hash_flush, 0x000014c);/* Valid bits defined by ipa->available */ IPA_REG (STATE_AGGR_ACTIVE , state_aggr_active,0x000000b4 ); +static const u32 ipa_reg_local_pkt_proc_cntxt_fmask[] = { + [IPA_BASE_ADDR ] =GENMASK (17 ,0 ), +/* Bits 18-31 reserved */ +}; +/* Offset must be a multiple of 8 */ -IPA_REG (LOCAL_PKT_PROC_CNTXT , local_pkt_proc_cntxt,0x000001e8 ); +IPA_REG_FIELDS (LOCAL_PKT_PROC_CNTXT , local_pkt_proc_cntxt,0x000001e8 );/* Valid bits defined by ipa->available */ IPA_REG (AGGR_FORCE_CLOSE , aggr_force_close,0x000001ec ); -IPA_REG (IPA_TX_CFG , ipa_tx_cfg,0x000001fc ); +static const u32 ipa_reg_ipa_tx_cfg_fmask[] = { +/* Bits 0-1 reserved */ + [PREFETCH_ALMOST_EMPTY_SIZE_TX0 ] =GENMASK (5 ,2 ), + [DMAW_SCND_OUTSD_PRED_THRESHOLD ] =GENMASK (9 ,6 ), + [DMAW_SCND_OUTSD_PRED_EN ] =BIT (10 ), + [DMAW_MAX_BEATS_256_DIS ] =BIT (11 ), + [PA_MASK_EN ] =BIT (12 ), + [PREFETCH_ALMOST_EMPTY_SIZE_TX1 ] =GENMASK (16 ,13 ), + [DUAL_TX_ENABLE ] =BIT (17 ), + [SSPND_PA_NO_START_STATE ] =BIT (18 ), +/* Bits 19-31 reserved */ +}; + +IPA_REG_FIELDS (IPA_TX_CFG , ipa_tx_cfg,0x000001fc );IPA_REG (FLAVOR_0 , flavor_0,0x00000210 );
Signature · 1 line
2.34.1
PATCH 11/15 net: ipa: define even more IPA register fields
In reply to Alex ElderDefine the fields for the FLAVOR_0, IDLE_INDICATION_CFG, QTIME_TIMESTAMP_CFG, TIMERS_XO_CLK_DIV_CFG and TIMERS_PULSE_GRAN_CFG IPA registers for all supported IPA versions.
Create enumerated types to identify fields for these IPA registers. Use IPA_REG_FIELDS() to specify the field mask values defined for these registers, for each supported version of IPA.
Use ipa_reg_bit() and ipa_reg_encode() to build up the values to be written to these registers. Use ipa_reg_decode() to extract field values from the FLAVOR_0 register.
Remove the definition of the no-longer-used *_FMASK symbols.
--- drivers/net/ipa/ipa_endpoint.c | 6 ++-- drivers/net/ipa/ipa_main.c | 24 ++++++------- drivers/net/ipa/ipa_reg.h | 43 +++++++++++++++--------- drivers/net/ipa/reg/ipa_reg-v3.5.1.c | 21 ++++++++++-- drivers/net/ipa/reg/ipa_reg-v4.11.c | 50 +++++++++++++++++++++++++--- drivers/net/ipa/reg/ipa_reg-v4.2.c | 21 ++++++++++-- drivers/net/ipa/reg/ipa_reg-v4.5.c | 49 ++++++++++++++++++++++++--- drivers/net/ipa/reg/ipa_reg-v4.9.c | 49 ++++++++++++++++++++++++--- 8 files changed, 213 insertions(+), 50 deletions(-)
drivers/net/ipa/ipa_endpoint.c +3 -3
@@ -1854,8 +1854,8 @@ int ipa_endpoint_config(struct ipa *ipa) val =ioread32 (ipa->reg_virt +ipa_reg_offset (reg));/* Our RX is an IPA producer */ - rx_base =u32_get_bits (val,IPA_PROD_LOWEST_FMASK ); - max = rx_base +u32_get_bits (val,IPA_MAX_PROD_PIPES_FMASK ); + rx_base =ipa_reg_decode (reg,PROD_LOWEST , val); + max = rx_base +ipa_reg_decode (reg,MAX_PROD_PIPES , val);if (max >IPA_ENDPOINT_MAX ) {dev_err (dev,"too many endpoints (%u > %u)\n" , max,IPA_ENDPOINT_MAX );
@@ -1864,7 +1864,7 @@ int ipa_endpoint_config(struct ipa *ipa) rx_mask =GENMASK (max -1 , rx_base);/* Our TX is an IPA consumer */ - max =u32_get_bits (val,IPA_MAX_CONS_PIPES_FMASK ); + max =ipa_reg_decode (reg,MAX_CONS_PIPES , val); tx_mask =GENMASK (max -1 ,0 ); ipa->available = rx_mask | tx_mask;
drivers/net/ipa/ipa_main.c +12 -12
@@ -361,31 +361,31 @@ static void ipa_qtime_config(struct ipa *ipa) reg =ipa_reg (ipa,QTIME_TIMESTAMP_CFG );/* Set DPL time stamp resolution to use Qtime (instead of 1 msec) */ - val =u32_encode_bits (DPL_TIMESTAMP_SHIFT ,DPL_TIMESTAMP_LSB_FMASK ); - val |=u32_encode_bits (1 ,DPL_TIMESTAMP_SEL_FMASK ); + val =ipa_reg_encode (reg,DPL_TIMESTAMP_LSB ,DPL_TIMESTAMP_SHIFT ); + val |=ipa_reg_bit (reg,DPL_TIMESTAMP_SEL );/* Configure tag and NAT Qtime timestamp resolution as well */ - val |=u32_encode_bits (TAG_TIMESTAMP_SHIFT ,TAG_TIMESTAMP_LSB_FMASK ); - val |=u32_encode_bits (NAT_TIMESTAMP_SHIFT ,NAT_TIMESTAMP_LSB_FMASK ); + val =ipa_reg_encode (reg,TAG_TIMESTAMP_LSB ,TAG_TIMESTAMP_SHIFT ); + val =ipa_reg_encode (reg,NAT_TIMESTAMP_LSB ,NAT_TIMESTAMP_SHIFT );iowrite32 (val, ipa->reg_virt +ipa_reg_offset (reg));/* Set granularity of pulse generators used for other timers */ reg =ipa_reg (ipa,TIMERS_PULSE_GRAN_CFG ); - val =u32_encode_bits (IPA_GRAN_100_US ,GRAN_0_FMASK ); - val |=u32_encode_bits (IPA_GRAN_1_MS ,GRAN_1_FMASK ); - val |=u32_encode_bits (IPA_GRAN_1_MS ,GRAN_2_FMASK ); + val =ipa_reg_encode (reg,PULSE_GRAN_0 ,IPA_GRAN_100_US ); + val |=ipa_reg_encode (reg,PULSE_GRAN_1 ,IPA_GRAN_1_MS ); + val |=ipa_reg_encode (reg,PULSE_GRAN_2 ,IPA_GRAN_1_MS );iowrite32 (val, ipa->reg_virt +ipa_reg_offset (reg));/* Actual divider is 1 more than value supplied here */ reg =ipa_reg (ipa,TIMERS_XO_CLK_DIV_CFG ); offset =ipa_reg_offset (reg); - val =u32_encode_bits (IPA_XO_CLOCK_DIVIDER -1 ,DIV_VALUE_FMASK ); + val =ipa_reg_encode (reg,DIV_VALUE ,IPA_XO_CLOCK_DIVIDER -1 );iowrite32 (val, ipa->reg_virt + offset);/* Divider value is set; re-enable the common timer clock divider */ - val |=u32_encode_bits (1 ,DIV_ENABLE_FMASK ); + val |=ipa_reg_bit (reg,DIV_ENABLE );iowrite32 (val, ipa->reg_virt + offset); }
@@ -435,10 +435,10 @@ static void ipa_idle_indication_cfg(struct ipa *ipa,u32 val; reg =ipa_reg (ipa,IDLE_INDICATION_CFG ); - val =u32_encode_bits (enter_idle_debounce_thresh, -ENTER_IDLE_DEBOUNCE_THRESH_FMASK ); + val =ipa_reg_encode (reg,ENTER_IDLE_DEBOUNCE_THRESH , + enter_idle_debounce_thresh);if (const_non_idle_enable) - val |=CONST_NON_IDLE_ENABLE_FMASK ; + val |=ipa_reg_bit (reg,CONST_NON_IDLE_ENABLE );iowrite32 (val, ipa->reg_virt +ipa_reg_offset (reg)); }
drivers/net/ipa/ipa_reg.h +27 -16
57 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v3.5.1.c +19 -2
@@ -140,9 +140,26 @@ static const u32 ipa_reg_ipa_tx_cfg_fmask[] = {IPA_REG_FIELDS (IPA_TX_CFG , ipa_tx_cfg,0x000001fc ); -IPA_REG (FLAVOR_0 , flavor_0,0x00000210 ); +static const u32 ipa_reg_flavor_0_fmask[] = { + [MAX_PIPES ] =GENMASK (3 ,0 ), +/* Bits 4-7 reserved */ + [MAX_CONS_PIPES ] =GENMASK (12 ,8 ), +/* Bits 13-15 reserved */ + [MAX_PROD_PIPES ] =GENMASK (20 ,16 ), +/* Bits 21-23 reserved */ + [PROD_LOWEST ] =GENMASK (27 ,24 ), +/* Bits 28-31 reserved */ +}; -IPA_REG (IDLE_INDICATION_CFG , idle_indication_cfg,0x00000220 ); +IPA_REG_FIELDS (FLAVOR_0 , flavor_0,0x00000210 ); + +static const u32 ipa_reg_idle_indication_cfg_fmask[] = { + [ENTER_IDLE_DEBOUNCE_THRESH ] =GENMASK (15 ,0 ), + [CONST_NON_IDLE_ENABLE ] =BIT (16 ), +/* Bits 17-31 reserved */ +}; + +IPA_REG_FIELDS (IDLE_INDICATION_CFG , idle_indication_cfg,0x00000220 );IPA_REG_STRIDE (SRC_RSRC_GRP_01_RSRC_TYPE , src_rsrc_grp_01_rsrc_type,0x00000400 ,0x0020 );
drivers/net/ipa/reg/ipa_reg-v4.11.c +45 -5
60 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v4.2.c +19 -2
@@ -171,9 +171,26 @@ static const u32 ipa_reg_ipa_tx_cfg_fmask[] = {IPA_REG_FIELDS (IPA_TX_CFG , ipa_tx_cfg,0x000001fc ); -IPA_REG (FLAVOR_0 , flavor_0,0x00000210 ); +static const u32 ipa_reg_flavor_0_fmask[] = { + [MAX_PIPES ] =GENMASK (3 ,0 ), +/* Bits 4-7 reserved */ + [MAX_CONS_PIPES ] =GENMASK (12 ,8 ), +/* Bits 13-15 reserved */ + [MAX_PROD_PIPES ] =GENMASK (20 ,16 ), +/* Bits 21-23 reserved */ + [PROD_LOWEST ] =GENMASK (27 ,24 ), +/* Bits 28-31 reserved */ +}; -IPA_REG (IDLE_INDICATION_CFG , idle_indication_cfg,0x00000240 ); +IPA_REG_FIELDS (FLAVOR_0 , flavor_0,0x00000210 ); + +static const u32 ipa_reg_idle_indication_cfg_fmask[] = { + [ENTER_IDLE_DEBOUNCE_THRESH ] =GENMASK (15 ,0 ), + [CONST_NON_IDLE_ENABLE ] =BIT (16 ), +/* Bits 17-31 reserved */ +}; + +IPA_REG_FIELDS (IDLE_INDICATION_CFG , idle_indication_cfg,0x00000240 );IPA_REG_STRIDE (SRC_RSRC_GRP_01_RSRC_TYPE , src_rsrc_grp_01_rsrc_type,0x00000400 ,0x0020 );
drivers/net/ipa/reg/ipa_reg-v4.5.c +44 -5
59 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v4.9.c +44 -5
59 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 12/15 net: ipa: define resource group/type IPA register fields
In reply to Alex ElderDefine the fields for the {SRC,DST}_RSRC_GRP_{01,23,45,67}_RSRC_TYPE IPA registers for all supported IPA versions.
Create enumerated types to identify fields for these IPA registers. Use IPA_REG_STRIDE_FIELDS() to specify the field mask values defined for these registers, for each supported version of IPA.
Use ipa_reg_encode() to build up the values to be written to these registers.
Remove the definition of the no-longer-used *_FMASK symbols.
--- drivers/net/ipa/ipa_reg.h | 10 ++- drivers/net/ipa/ipa_resource.c | 53 +++++------- drivers/net/ipa/reg/ipa_reg-v3.1.c | 120 +++++++++++++++++++++++---- drivers/net/ipa/reg/ipa_reg-v3.5.1.c | 60 ++++++++++++-- drivers/net/ipa/reg/ipa_reg-v4.11.c | 60 ++++++++++++-- drivers/net/ipa/reg/ipa_reg-v4.2.c | 60 ++++++++++++-- drivers/net/ipa/reg/ipa_reg-v4.5.c | 90 +++++++++++++++++--- drivers/net/ipa/reg/ipa_reg-v4.9.c | 60 ++++++++++++-- 8 files changed, 419 insertions(+), 94 deletions(-)
drivers/net/ipa/ipa_reg.h +6 -4
@@ -363,10 +363,12 @@ enum ipa_pulse_gran { };/* {SRC,DST}_RSRC_GRP_{01,23,45,67}_RSRC_TYPE registers */ -#define X_MIN_LIM_FMASK GENMASK(5, 0) -#define X_MAX_LIM_FMASK GENMASK(13, 8) -#define Y_MIN_LIM_FMASK GENMASK(21, 16) -#define Y_MAX_LIM_FMASK GENMASK(29, 24) +enum ipa_reg_rsrc_grp_rsrc_type_field_id { +X_MIN_LIM , +X_MAX_LIM , +Y_MIN_LIM , +Y_MAX_LIM , +};/* ENDP_INIT_CTRL register */ /* Valid only for RX (IPA producer) endpoints (do not use for IPA v4.0+) */
drivers/net/ipa/ipa_resource.c +23 -30
119 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v3.1.c +104 -16
133 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v3.5.1.c +52 -8
69 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v4.11.c +52 -8
69 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v4.2.c +52 -8
69 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v4.5.c +78 -12
101 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v4.9.c +52 -8
69 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 13/15 net: ipa: define some IPA endpoint register fields
In reply to Alex ElderDefine the fields for the ENDP_INIT_CTRL, ENDP_INIT_CFG, ENDP_INIT_NAT, ENDP_INIT_HDR, and ENDP_INIT_HDR_EXT IPA registers for all supported IPA versions.
Create enumerated types to identify fields for these IPA registers. Use IPA_REG_STRIDE_FIELDS() to specify the field mask values defined for these registers, for each supported version of IPA.
Move ipa_header_size_encoded() and ipa_metadata_offset_encoded() out of "ipa_reg.h" and into "ipa_endpoint.c". Change them so they take an additional ipa_reg structure argument, and use ipa_reg_encode() to encode the parts of the header size and offset prior to writing to the register. Change their names to be verbs rather than nouns.
Use ipa_reg_encode(), ipa_reg_bit, and ipa_reg_field_max() to manipulate values to be written to these registers, remove the definition of the no-longer-used *_FMASK symbols.
--- drivers/net/ipa/ipa_endpoint.c | 86 ++++++++++++++++----- drivers/net/ipa/ipa_reg.h | 110 +++++++++------------------ drivers/net/ipa/reg/ipa_reg-v3.1.c | 53 +++++++++++-- drivers/net/ipa/reg/ipa_reg-v3.5.1.c | 53 +++++++++++-- drivers/net/ipa/reg/ipa_reg-v4.11.c | 49 +++++++++++- drivers/net/ipa/reg/ipa_reg-v4.2.c | 45 ++++++++++- drivers/net/ipa/reg/ipa_reg-v4.5.c | 49 +++++++++++- drivers/net/ipa/reg/ipa_reg-v4.9.c | 48 +++++++++++- 8 files changed, 374 insertions(+), 119 deletions(-)
drivers/net/ipa/ipa_endpoint.c +66 -20
@@ -310,6 +310,7 @@ ipa_endpoint_init_ctrl(struct ipa_endpoint *endpoint, bool suspend_delay) {struct ipa *ipa = endpoint->ipa;const struct ipa_reg *reg; +u32 field_id;u32 offset;bool state;u32 mask;
@@ -321,10 +322,12 @@ ipa_endpoint_init_ctrl(struct ipa_endpoint *endpoint, bool suspend_delay)WARN_ON (ipa->version >=IPA_VERSION_4_0 ); reg =ipa_reg (ipa,ENDP_INIT_CTRL ); - mask = endpoint->toward_ipa ?ENDP_DELAY_FMASK :ENDP_SUSPEND_FMASK ; offset =ipa_reg_n_offset (reg, endpoint->endpoint_id); val =ioread32 (ipa->reg_virt + offset); + field_id = endpoint->toward_ipa ?ENDP_DELAY :ENDP_SUSPEND ; + mask =ipa_reg_bit (reg, field_id); + state = !!(val & mask);/* Don't bother if it's already in the requested state */
@@ -516,10 +519,8 @@ static void ipa_endpoint_init_cfg(struct ipa_endpoint *endpoint)u32 off;/* Checksum header offset is in 4-byte units */ - off =sizeof (struct rmnet_map_header ); - off /=sizeof (u32); - val |=u32_encode_bits (off, -CS_METADATA_HDR_OFFSET_FMASK ); + off =sizeof (struct rmnet_map_header ) /sizeof (u32); + val |=ipa_reg_encode (reg,CS_METADATA_HDR_OFFSET , off); enabled = version <IPA_VERSION_4_5 ? IPA_CS_OFFLOAD_UL
@@ -532,7 +533,7 @@ static void ipa_endpoint_init_cfg(struct ipa_endpoint *endpoint) }else { enabled =IPA_CS_OFFLOAD_NONE ; } - val |=u32_encode_bits (enabled,CS_OFFLOAD_EN_FMASK ); + val |=ipa_reg_encode (reg,CS_OFFLOAD_EN , enabled);/* CS_GEN_QMB_MASTER_SEL is 0 */ iowrite32 (val, ipa->reg_virt +ipa_reg_n_offset (reg, endpoint_id));
@@ -549,7 +550,7 @@ static void ipa_endpoint_init_nat(struct ipa_endpoint *endpoint)return ; reg =ipa_reg (ipa,ENDP_INIT_NAT ); - val =u32_encode_bits (IPA_NAT_BYPASS ,NAT_EN_FMASK ); + val =ipa_reg_encode (reg,NAT_EN ,IPA_NAT_BYPASS );iowrite32 (val, ipa->reg_virt +ipa_reg_n_offset (reg, endpoint_id)); }
@@ -575,6 +576,50 @@ ipa_qmap_header_size(enum ipa_version version, struct ipa_endpoint *endpoint)return header_size; } +/* Encoded value for ENDP_INIT_HDR register HDR_LEN* field(s) */ +static u32 ipa_header_size_encode (enum ipa_version version, +const struct ipa_reg *reg,u32 header_size) +{ +u32 field_max =ipa_reg_field_max (reg,HDR_LEN ); +u32 val; + +/* We know field_max can be used as a mask (2^n - 1) */ + val =ipa_reg_encode (reg,HDR_LEN , header_size & field_max); +if (version <IPA_VERSION_4_5 ) { +WARN_ON (header_size > field_max); +return val; + } + +/* IPA v4.5 adds a few more most-significant bits */ + header_size >>=hweight32 (field_max); +WARN_ON (header_size >ipa_reg_field_max (reg,HDR_LEN_MSB )); + val |=ipa_reg_encode (reg,HDR_LEN_MSB , header_size); + +return val; +} + +/* Encoded value for ENDP_INIT_HDR register OFST_METADATA* field(s) */ +static u32 ipa_metadata_offset_encode (enum ipa_version version, +const struct ipa_reg *reg,u32 offset) +{ +u32 field_max =ipa_reg_field_max (reg,HDR_OFST_METADATA ); +u32 val; + +/* We know field_max can be used as a mask (2^n - 1) */ + val =ipa_reg_encode (reg,HDR_OFST_METADATA , offset); +if (version <IPA_VERSION_4_5 ) { +WARN_ON (offset > field_max); +return val; + } + +/* IPA v4.5 adds a few more most-significant bits */ + offset >>=hweight32 (field_max); +WARN_ON (offset >ipa_reg_field_max (reg,HDR_OFST_METADATA_MSB )); + val |=ipa_reg_encode (reg,HDR_OFST_METADATA_MSB , offset); + +return val; +} +/** * ipa_endpoint_init_hdr() - Initialize HDR endpoint configuration register * @endpoint: Endpoint pointer
@@ -609,7 +654,7 @@ static void ipa_endpoint_init_hdr(struct ipa_endpoint *endpoint)size_t header_size; header_size =ipa_qmap_header_size (version, endpoint); - val =ipa_header_size_encoded (version, header_size); + val =ipa_header_size_encode (version, reg, header_size);/* Define how to fill fields in a received QMAP header */ if (!endpoint->toward_ipa) {
@@ -617,19 +662,19 @@ static void ipa_endpoint_init_hdr(struct ipa_endpoint *endpoint)/* Where IPA will write the metadata value */ off = offsetof(struct rmnet_map_header , mux_id); - val |=ipa_metadata_offset_encoded (version, off); + val |=ipa_metadata_offset_encode (version, reg, off);/* Where IPA will write the length */ off = offsetof(struct rmnet_map_header , pkt_len);/* Upper bits are stored in HDR_EXT with IPA v4.5 */ if (version >=IPA_VERSION_4_5 ) - off &=field_mask (HDR_OFST_PKT_SIZE_FMASK ); + off &=ipa_reg_field_max (reg,HDR_OFST_PKT_SIZE ); - val |=HDR_OFST_PKT_SIZE_VALID_FMASK ; - val |=u32_encode_bits (off,HDR_OFST_PKT_SIZE_FMASK ); + val |=ipa_reg_bit (reg,HDR_OFST_PKT_SIZE_VALID ); + val |=ipa_reg_encode (reg,HDR_OFST_PKT_SIZE , off); }/* For QMAP TX, metadata offset is 0 (modem assumes this) */ - val |=HDR_OFST_METADATA_VALID_FMASK ; + val |=ipa_reg_bit (reg,HDR_OFST_METADATA_VALID );/* HDR_ADDITIONAL_CONST_LEN is 0; (RX only) */ /* HDR_A5_MUX is 0 */
@@ -651,7 +696,7 @@ static void ipa_endpoint_init_hdr_ext(struct ipa_endpoint *endpoint) reg =ipa_reg (ipa,ENDP_INIT_HDR_EXT );if (endpoint->config.qmap) {/* We have a header, so we must specify its endianness */ - val |=HDR_ENDIANNESS_FMASK ;/* big endian */ + val |=ipa_reg_bit (reg,HDR_ENDIANNESS );/* big endian */ /* A QMAP header contains a 6 bit pad field at offset 0. * The RMNet driver assumes this field is meaningful in
@@ -661,16 +706,16 @@ static void ipa_endpoint_init_hdr_ext(struct ipa_endpoint *endpoint)* (although 0) should be ignored. */ if (!endpoint->toward_ipa) { - val |=HDR_TOTAL_LEN_OR_PAD_VALID_FMASK ; + val |=ipa_reg_bit (reg,HDR_TOTAL_LEN_OR_PAD_VALID );/* HDR_TOTAL_LEN_OR_PAD is 0 (pad, not total_len) */ - val |=HDR_PAYLOAD_LEN_INC_PADDING_FMASK ; + val |=ipa_reg_bit (reg,HDR_PAYLOAD_LEN_INC_PADDING );/* HDR_TOTAL_LEN_OR_PAD_OFFSET is 0 */ } }/* HDR_PAYLOAD_LEN_INC_PADDING is 0 */ if (!endpoint->toward_ipa) - val |=u32_encode_bits (pad_align,HDR_PAD_TO_ALIGNMENT_FMASK ); + val |=ipa_reg_encode (reg,HDR_PAD_TO_ALIGNMENT , pad_align);/* IPA v4.5 adds some most-significant bits to a few fields, * two of which are defined in the HDR (not HDR_EXT) register.
@@ -678,12 +723,13 @@ static void ipa_endpoint_init_hdr_ext(struct ipa_endpoint *endpoint)if (ipa->version >=IPA_VERSION_4_5 ) {/* HDR_TOTAL_LEN_OR_PAD_OFFSET is 0, so MSB is 0 */ if (endpoint->config.qmap && !endpoint->toward_ipa) { +u32 mask =ipa_reg_field_max (reg,HDR_OFST_PKT_SIZE );u32 off;/* Field offset within header */ off = offsetof(struct rmnet_map_header , pkt_len); - off >>=hweight32 (HDR_OFST_PKT_SIZE_FMASK ); - val |=u32_encode_bits (off, -HDR_OFST_PKT_SIZE_MSB_FMASK ); +/* Low bits are in the ENDP_INIT_HDR register */ + off >>=hweight32 (mask); + val |=ipa_reg_encode (reg,HDR_OFST_PKT_SIZE_MSB , off);/* HDR_ADDITIONAL_CONST_LEN is 0 so MSB is 0 */ } }
drivers/net/ipa/ipa_reg.h +37 -73
132 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v3.1.c +48 -5
63 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v3.5.1.c +48 -5
63 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v4.11.c +45 -4
58 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v4.2.c +41 -4
54 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v4.5.c +45 -4
58 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v4.9.c +44 -4
57 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 14/15 net: ipa: define more IPA endpoint register fields
In reply to Alex ElderDefine the fields for the ENDP_INIT_MODE, ENDP_INIT_AGGR, ENDP_INIT_HOL_BLOCK_EN, and ENDP_INIT_HOL_BLOCK_TIMER IPA registers for all supported IPA versions.
Create enumerated types to identify fields for these IPA registers. Use IPA_REG_STRIDE_FIELDS() to specify the field mask values defined for these registers, for each supported version of IPA.
Change aggr_time_limit_encode() and hol_block_timer_encode() so they take an ipa_reg pointer, and use those register's fields to compute their encoded results. Have aggr_time_limit_encode() take an IPA pointer rather than version, to match hol_block_timer_encode().
Use ipa_reg_encode(), ipa_reg_bit(), and ipa_reg_field_max() to manipulate values to be written to these registers, remove the definitions of the various inline functions and *_FMASK symbols that are now no longer used.
--- drivers/net/ipa/ipa_endpoint.c | 121 +++++++++++---------------- drivers/net/ipa/ipa_reg.h | 89 +++++++------------- drivers/net/ipa/reg/ipa_reg-v3.1.c | 47 +++++++++-- drivers/net/ipa/reg/ipa_reg-v3.5.1.c | 47 +++++++++-- drivers/net/ipa/reg/ipa_reg-v4.11.c | 51 +++++++++-- drivers/net/ipa/reg/ipa_reg-v4.2.c | 49 +++++++++-- drivers/net/ipa/reg/ipa_reg-v4.5.c | 50 +++++++++-- drivers/net/ipa/reg/ipa_reg-v4.9.c | 51 +++++++++-- 8 files changed, 336 insertions(+), 169 deletions(-)
drivers/net/ipa/ipa_endpoint.c +47 -74
@@ -72,14 +72,6 @@ struct ipa_status {#define IPA_STATUS_FLAGS1_RT_RULE_ID_FMASK GENMASK(31, 22)#define IPA_STATUS_FLAGS2_TAG_FMASK GENMASK_ULL(63, 16) -static u32 aggr_byte_limit_max (enum ipa_version version) -{ -if (version <IPA_VERSION_4_5 ) -return field_max (aggr_byte_limit_fmask (true)); - -return field_max (aggr_byte_limit_fmask (false)); -} -/* Compute the aggregation size value to use for a given buffer size */ static u32 ipa_aggr_size_kb (u32 rx_buffer_size,bool aggr_hard_limit) {
@@ -111,6 +103,7 @@ static bool ipa_endpoint_data_valid_one(struct ipa *ipa, u32 count,if (!data->toward_ipa) {const struct ipa_endpoint_rx *rx_config; +const struct ipa_reg *reg;u32 buffer_size;u32 aggr_size;u32 limit;
@@ -171,7 +164,9 @@ static bool ipa_endpoint_data_valid_one(struct ipa *ipa, u32 count,*/ aggr_size =ipa_aggr_size_kb (buffer_size -NET_SKB_PAD , rx_config->aggr_hard_limit); - limit =aggr_byte_limit_max (ipa->version); + reg =ipa_reg (ipa,ENDP_INIT_AGGR ); + + limit =ipa_reg_field_max (reg,BYTE_LIMIT );if (aggr_size > limit) {dev_err (dev,"aggregated size too large for RX endpoint %u (%u KB > %u KB)\n" , data->endpoint_id, aggr_size, limit);
@@ -769,32 +764,21 @@ static void ipa_endpoint_init_mode(struct ipa_endpoint *endpoint)return ;/* Register not valid for RX endpoints */ reg =ipa_reg (ipa,ENDP_INIT_MODE ); - offset =ipa_reg_n_offset (reg, endpoint->endpoint_id);if (endpoint->config.dma_mode) {enum ipa_endpoint_name name = endpoint->config.dma_endpoint; -u32 dma_endpoint_id; +u32 dma_endpoint_id = ipa->name_map[name]->endpoint_id; - dma_endpoint_id = ipa->name_map[name]->endpoint_id; - - val =u32_encode_bits (IPA_DMA ,MODE_FMASK ); - val |=u32_encode_bits (dma_endpoint_id,DEST_PIPE_INDEX_FMASK ); + val =ipa_reg_encode (reg,ENDP_MODE ,IPA_DMA ); + val |=ipa_reg_encode (reg,DEST_PIPE_INDEX , dma_endpoint_id); }else { - val =u32_encode_bits (IPA_BASIC ,MODE_FMASK ); + val =ipa_reg_encode (reg,ENDP_MODE ,IPA_BASIC ); }/* All other bits unspecified (and 0) */ + offset =ipa_reg_n_offset (reg, endpoint->endpoint_id);iowrite32 (val, ipa->reg_virt + offset); } -/* Encoded values for AGGR endpoint register fields */ -static u32 aggr_byte_limit_encoded (enum ipa_version version,u32 limit) -{ -if (version <IPA_VERSION_4_5 ) -return u32_encode_bits (limit,aggr_byte_limit_fmask (true)); - -return u32_encode_bits (limit,aggr_byte_limit_fmask (false)); -} -/* For IPA v4.5+, times are expressed using Qtime. The AP uses one of two * pulse generators (0 and 1) to measure elapsed time. In ipa_qtime_config() * they're configured to have granularity 100 usec and 1 msec, respectively.
@@ -820,50 +804,39 @@ static int ipa_qtime_val(u32 microseconds, u32 max) }/* Encode the aggregation timer limit (microseconds) based on IPA version */ -static u32 aggr_time_limit_encode (enum ipa_version version,u32 microseconds) +static u32 aggr_time_limit_encode (struct ipa *ipa,const struct ipa_reg *reg, +u32 microseconds) { -u32 fmask; +u32 max;u32 val;if (!microseconds)return 0 ;/* Nothing to compute if time limit is 0 */ -if (version >=IPA_VERSION_4_5 ) { + max =ipa_reg_field_max (reg,TIME_LIMIT ); +if (ipa->version >=IPA_VERSION_4_5 ) {u32 gran_sel;int ret;/* Compute the Qtime limit value to use */ - fmask =aggr_time_limit_fmask (false); - ret =ipa_qtime_val (microseconds,field_max (fmask)); + ret =ipa_qtime_val (microseconds, max);if (ret <0 ) { val = -ret; - gran_sel =AGGR_GRAN_SEL_FMASK ; + gran_sel =ipa_reg_bit (reg,AGGR_GRAN_SEL ); }else { val = ret; gran_sel =0 ; } -return gran_sel |u32_encode_bits (val, fmask); +return gran_sel |ipa_reg_encode (reg,TIME_LIMIT , val); } -/* We set aggregation granularity in ipa_hardware_config() */ - fmask =aggr_time_limit_fmask (true); +/* We program aggregation granularity in ipa_hardware_config() */ val =DIV_ROUND_CLOSEST (microseconds,IPA_AGGR_GRANULARITY ); -WARN (val >field_max (fmask), -"aggr_time_limit too large (%u > %u usec)\n" , - val,field_max (fmask) *IPA_AGGR_GRANULARITY ); +WARN (val > max,"aggr_time_limit too large (%u > %u usec)\n" , + microseconds, max *IPA_AGGR_GRANULARITY ); -return u32_encode_bits (val, fmask); -} - -static u32 aggr_sw_eof_active_encoded (enum ipa_version version,bool enabled) -{ -u32 val = enabled ?1 :0 ; - -if (version <IPA_VERSION_4_5 ) -return u32_encode_bits (val,aggr_sw_eof_active_fmask (true)); - -return u32_encode_bits (val,aggr_sw_eof_active_fmask (false)); +return ipa_reg_encode (reg,TIME_LIMIT , val); }static void ipa_endpoint_init_aggr (struct ipa_endpoint *endpoint)
@@ -877,37 +850,34 @@ static void ipa_endpoint_init_aggr(struct ipa_endpoint *endpoint)if (endpoint->config.aggregation) {if (!endpoint->toward_ipa) {const struct ipa_endpoint_rx *rx_config; -enum ipa_version version = ipa->version;u32 buffer_size; -bool close_eof;u32 limit; rx_config = &endpoint->config.rx; - val |=u32_encode_bits (IPA_ENABLE_AGGR ,AGGR_EN_FMASK ); - val |=u32_encode_bits (IPA_GENERIC ,AGGR_TYPE_FMASK ); + val |=ipa_reg_encode (reg,AGGR_EN ,IPA_ENABLE_AGGR ); + val |=ipa_reg_encode (reg,AGGR_TYPE ,IPA_GENERIC ); buffer_size = rx_config->buffer_size; limit =ipa_aggr_size_kb (buffer_size -NET_SKB_PAD , rx_config->aggr_hard_limit); - val |=aggr_byte_limit_encoded (version, limit); + val |=ipa_reg_encode (reg,BYTE_LIMIT , limit); limit = rx_config->aggr_time_limit; - val |=aggr_time_limit_encode (version, limit); + val |=aggr_time_limit_encode (ipa, reg, limit);/* AGGR_PKT_LIMIT is 0 (unlimited) */ - close_eof = rx_config->aggr_close_eof; - val |=aggr_sw_eof_active_encoded (version, close_eof); +if (rx_config->aggr_close_eof) + val |=ipa_reg_bit (reg,SW_EOF_ACTIVE ); }else { - val |=u32_encode_bits (IPA_ENABLE_DEAGGR , -AGGR_EN_FMASK ); - val |=u32_encode_bits (IPA_QCMAP ,AGGR_TYPE_FMASK ); + val |=ipa_reg_encode (reg,AGGR_EN ,IPA_ENABLE_DEAGGR ); + val |=ipa_reg_encode (reg,AGGR_TYPE ,IPA_QCMAP );/* 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 ); + val |=ipa_reg_encode (reg,AGGR_EN ,IPA_BYPASS_AGGR );/* other fields ignored */ }
@@ -922,7 +892,8 @@ static void ipa_endpoint_init_aggr(struct ipa_endpoint *endpoint)* Return the encoded value representing the timeout period provided * that should be written to the ENDP_INIT_HOL_BLOCK_TIMER register. */ -static u32 hol_block_timer_encode (struct ipa *ipa,u32 microseconds) +static u32 hol_block_timer_encode (struct ipa *ipa,const struct ipa_reg *reg, +u32 microseconds) {u32 width;u32 scale;
@@ -935,31 +906,33 @@ static u32 hol_block_timer_encode(struct ipa *ipa, u32 microseconds)return 0 ;/* Nothing to compute if timer period is 0 */ if (ipa->version >=IPA_VERSION_4_5 ) { +u32 max =ipa_reg_field_max (reg,TIMER_LIMIT );u32 gran_sel;int ret;/* Compute the Qtime limit value to use */ - ret =ipa_qtime_val (microseconds,field_max (TIME_LIMIT_FMASK )); + ret =ipa_qtime_val (microseconds, max);if (ret <0 ) { val = -ret; - gran_sel =GRAN_SEL_FMASK ; + gran_sel =ipa_reg_bit (reg,TIMER_GRAN_SEL ); }else { val = ret; gran_sel =0 ; } -return gran_sel |u32_encode_bits (val,TIME_LIMIT_FMASK ); +return gran_sel |ipa_reg_encode (reg,TIMER_LIMIT , val); } -/* Use 64 bit arithmetic to avoid overflow... */ +/* Use 64 bit arithmetic to avoid overflow */ rate =ipa_core_clock_rate (ipa); ticks =DIV_ROUND_CLOSEST (microseconds * rate,128 *USEC_PER_SEC ); -/* ...but we still need to fit into a 32-bit register */ -WARN_ON (ticks >U32_MAX ); + +/* We still need the result to fit into the field */ +WARN_ON (ticks >ipa_reg_field_max (reg,TIMER_BASE_VALUE ));/* IPA v3.5.1 through v4.1 just record the tick count */ if (ipa->version <IPA_VERSION_4_2 ) -return (u32 )ticks; +return ipa_reg_encode (reg,TIMER_BASE_VALUE , (u32 )ticks);/* For IPA v4.2, the tick count is represented by base and * scale fields within the 32-bit timer register, where:
@@ -969,8 +942,8 @@ static u32 hol_block_timer_encode(struct ipa *ipa, u32 microseconds)* count, and extract the number of bits in the base field * such that high bit is included. */ - high =fls (ticks);/* 1..32 */ - width =HWEIGHT32 (BASE_VALUE_FMASK ); + high =fls (ticks);/* 1..32 (or warning above) */ + width =hweight32 (ipa_reg_fmask (reg,TIMER_BASE_VALUE )); scale = high > width ? high - width :0 ;if (scale) {/* If we're scaling, round up to get a closer result */
@@ -980,8 +953,8 @@ static u32 hol_block_timer_encode(struct ipa *ipa, u32 microseconds) scale++; } - val =u32_encode_bits (scale,SCALE_FMASK ); - val |=u32_encode_bits (ticks >> scale,BASE_VALUE_FMASK ); + val =ipa_reg_encode (reg,TIMER_SCALE , scale); + val |=ipa_reg_encode (reg,TIMER_BASE_VALUE , (u32 )ticks >> scale);return val; }
@@ -997,7 +970,7 @@ static void ipa_endpoint_init_hol_block_timer(struct ipa_endpoint *endpoint,/* This should only be changed when HOL_BLOCK_EN is disabled */ reg =ipa_reg (ipa,ENDP_INIT_HOL_BLOCK_TIMER ); - val =hol_block_timer_encode (ipa, microseconds); + val =hol_block_timer_encode (ipa, reg, microseconds);iowrite32 (val, ipa->reg_virt +ipa_reg_n_offset (reg, endpoint_id)); }
@@ -1013,7 +986,7 @@ ipa_endpoint_init_hol_block_en(struct ipa_endpoint *endpoint, bool enable) reg =ipa_reg (ipa,ENDP_INIT_HOL_BLOCK_EN ); offset =ipa_reg_n_offset (reg, endpoint_id); - val = enable ?HOL_BLOCK_EN_FMASK :0 ; + val = enable ?ipa_reg_bit (reg,HOL_BLOCK_EN ) :0 ;iowrite32 (val, ipa->reg_virt + offset);
drivers/net/ipa/ipa_reg.h +30 -59
109 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v3.1.c +41 -6
56 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v3.5.1.c +41 -6
56 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v4.11.c +45 -6
60 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v4.2.c +43 -6
58 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v4.5.c +44 -6
59 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v4.9.c +45 -6
60 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 15/15 net: ipa: define remaining IPA register fields
In reply to Alex ElderDefine the fields for the ENDP_INIT_DEAGGR, ENDP_INIT_RSRC_GRP, ENDP_INIT_SEQ, ENDP_STATUS, and ENDP_FILTER_ROUTER_HSH_CFG, and IPA_IRQ_UC IPA registers for all supported IPA versions.
Create enumerated types to identify fields for these IPA registers. Use IPA_REG_FIELDS() and IPA_REG_STRIDE_FIELDS() to specify the field mask values defined for these registers, for each supported version of IPA.
Use ipa_reg_encode() and ipa_reg_bit() to build up the values to be written to these registers, remove an inline function and all the *_FMASK symbols that are now no longer used.
--- drivers/net/ipa/ipa_endpoint.c | 21 +++---- drivers/net/ipa/ipa_reg.h | 85 ++++++++++++++-------------- drivers/net/ipa/ipa_table.c | 6 +- drivers/net/ipa/ipa_uc.c | 2 +- drivers/net/ipa/reg/ipa_reg-v3.1.c | 70 ++++++++++++++++++++--- drivers/net/ipa/reg/ipa_reg-v3.5.1.c | 70 ++++++++++++++++++++--- drivers/net/ipa/reg/ipa_reg-v4.11.c | 69 +++++++++++++++++++--- drivers/net/ipa/reg/ipa_reg-v4.2.c | 46 +++++++++++++-- drivers/net/ipa/reg/ipa_reg-v4.5.c | 69 +++++++++++++++++++--- drivers/net/ipa/reg/ipa_reg-v4.9.c | 69 +++++++++++++++++++--- 10 files changed, 410 insertions(+), 97 deletions(-)
drivers/net/ipa/ipa_endpoint.c +11 -10
@@ -1044,13 +1044,14 @@ static void ipa_endpoint_init_deaggr(struct ipa_endpoint *endpoint)static void ipa_endpoint_init_rsrc_grp (struct ipa_endpoint *endpoint) { +u32 resource_group = endpoint->config.resource_group;u32 endpoint_id = endpoint->endpoint_id;struct ipa *ipa = endpoint->ipa;const struct ipa_reg *reg;u32 val; reg =ipa_reg (ipa,ENDP_INIT_RSRC_GRP ); - val =rsrc_grp_encoded (ipa->version, endpoint->config.resource_group); + val =ipa_reg_encode (reg,ENDP_RSRC_GRP , resource_group);iowrite32 (val, ipa->reg_virt +ipa_reg_n_offset (reg, endpoint_id)); }
@@ -1060,7 +1061,7 @@ static void ipa_endpoint_init_seq(struct ipa_endpoint *endpoint)u32 endpoint_id = endpoint->endpoint_id;struct ipa *ipa = endpoint->ipa;const struct ipa_reg *reg; -u32 val =0 ; +u32 val;if (!endpoint->toward_ipa)return ;/* Register not valid for RX endpoints */
@@ -1068,12 +1069,12 @@ static void ipa_endpoint_init_seq(struct ipa_endpoint *endpoint) reg =ipa_reg (ipa,ENDP_INIT_SEQ );/* Low-order byte configures primary packet processing */ - val |=u32_encode_bits (endpoint->config.tx.seq_type,SEQ_TYPE_FMASK ); + val =ipa_reg_encode (reg,SEQ_TYPE , endpoint->config.tx.seq_type);/* Second byte (if supported) configures replicated packet processing */ if (ipa->version <IPA_VERSION_4_5 ) - val |=u32_encode_bits (endpoint->config.tx.seq_rep_type, -SEQ_REP_TYPE_FMASK ); + val |=ipa_reg_encode (reg,SEQ_REP_TYPE , + endpoint->config.tx.seq_rep_type);iowrite32 (val, ipa->reg_virt +ipa_reg_n_offset (reg, endpoint_id)); }
@@ -1130,7 +1131,7 @@ static void ipa_endpoint_status(struct ipa_endpoint *endpoint) reg =ipa_reg (ipa,ENDP_STATUS );if (endpoint->config.status_enable) { - val |=STATUS_EN_FMASK ; + val |=ipa_reg_bit (reg,STATUS_EN );if (endpoint->toward_ipa) {enum ipa_endpoint_name name;u32 status_endpoint_id;
@@ -1138,13 +1139,13 @@ static void ipa_endpoint_status(struct ipa_endpoint *endpoint) name = endpoint->config.tx.status_endpoint; status_endpoint_id = ipa->name_map[name]->endpoint_id; - val |=u32_encode_bits (status_endpoint_id, -STATUS_ENDP_FMASK ); + val |=ipa_reg_encode (reg,STATUS_ENDP , + status_endpoint_id); }/* STATUS_LOCATION is 0, meaning status element precedes -* packet (not present for IPA v4.5) +* packet (not present for IPA v4.5+) */ -/* STATUS_PKT_SUPPRESS_FMASK is 0 (not present for v3.5.1) */ +/* STATUS_PKT_SUPPRESS_FMASK is 0 (not present for v4.0+) */ }iowrite32 (val, ipa->reg_virt +ipa_reg_n_offset (reg, endpoint_id));
drivers/net/ipa/ipa_reg.h +42 -43
110 lines not on this page · raw message
drivers/net/ipa/ipa_table.c +3 -3
@@ -528,12 +528,12 @@ static void ipa_filter_tuple_zero(struct ipa_endpoint *endpoint)u32 val; reg =ipa_reg (ipa,ENDP_FILTER_ROUTER_HSH_CFG ); + offset =ipa_reg_n_offset (reg, endpoint_id); - val =ioread32 (endpoint->ipa->reg_virt + offset);/* Zero all filter-related fields, preserving the rest */ - val &= ~IPA_REG_ENDP_FILTER_HASH_MSK_ALL ; + val &= ~ipa_reg_fmask (reg,FILTER_HASH_MSK_ALL );iowrite32 (val, endpoint->ipa->reg_virt + offset); }
@@ -584,7 +584,7 @@ static void ipa_route_tuple_zero(struct ipa *ipa, u32 route_id) val =ioread32 (ipa->reg_virt + offset);/* Zero all route-related fields, preserving the rest */ - val &= ~IPA_REG_ENDP_ROUTER_HASH_MSK_ALL ; + val &= ~ipa_reg_fmask (reg,ROUTER_HASH_MSK_ALL );iowrite32 (val, ipa->reg_virt + offset); }
drivers/net/ipa/ipa_uc.c +1 -1
@@ -234,7 +234,7 @@ static void send_uc_command(struct ipa *ipa, u32 command, u32 command_param)/* Use an interrupt to tell the microcontroller the command is ready */ reg =ipa_reg (ipa,IPA_IRQ_UC ); - val =u32_encode_bits (1 ,UC_INTR_FMASK ); + val =ipa_reg_bit (reg,UC_INTR );iowrite32 (val, ipa->reg_virt +ipa_reg_offset (reg)); }
drivers/net/ipa/reg/ipa_reg-v3.1.c +63 -7
86 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v3.5.1.c +63 -7
86 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v4.11.c +62 -7
85 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v4.2.c +41 -5
61 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v4.5.c +62 -7
85 lines not on this page · raw message
drivers/net/ipa/reg/ipa_reg-v4.9.c +62 -7
85 lines not on this page · raw message
Signature · 1 line
2.34.1
This series was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:
Quoted 5 lines · On Mon, 26 Sep 2022 17:09:16 -0500 you wrote:
This series is quite a bit bigger than what I normally like to send, and I apologize for that. I would like it to get incorporated in its entirety this week if possible, and splitting up the series carries a small risk that wouldn't happen.
Quoted 8 lines
Each IPA register has a defined offset, and in most cases, a set of masks that define the width and position of fields within the register. Most registers currently use the same offset for all versions of IPA. Usually fields within registers are also the same across many versions. Offsets and fields like this are defined using preprocessor constants.
[...]
Here is the summary with links:
- [net-next,01/15] net: ipa: introduce IPA register IDs
https://git.kernel.org/netdev/net-next/c/98e2dd71a826 - [net-next,02/15] net: ipa: use IPA register IDs to determine offsets https://git.kernel.org/netdev/net-next/c/6bfb753850d3 - [net-next,03/15] net: ipa: add per-version IPA register definition files https://git.kernel.org/netdev/net-next/c/07f120bcf76b - [net-next,04/15] net: ipa: use ipa_reg[] array for register offsets https://git.kernel.org/netdev/net-next/c/82a06807453a - [net-next,05/15] net: ipa: introduce ipa_reg() (no matching commit) - [net-next,06/15] net: ipa: introduce ipa_reg field masks https://git.kernel.org/netdev/net-next/c/a5ad8956f97a - [net-next,07/15] net: ipa: define COMP_CFG IPA register fields https://git.kernel.org/netdev/net-next/c/12c7ea7dfd2c
- [net-next,08/15] net: ipa: define CLKON_CFG and ROUTE IPA register fields (no matching commit)
- [net-next,09/15] net: ipa: define some more IPA register fields (no matching commit)
- [net-next,10/15] net: ipa: define more IPA register fields (no matching commit)
- [net-next,11/15] net: ipa: define even more IPA register fields (no matching commit)
- [net-next,12/15] net: ipa: define resource group/type IPA register fields (no matching commit)
- [net-next,13/15] net: ipa: define some IPA endpoint register fields (no matching commit)
- [net-next,14/15] net: ipa: define more IPA endpoint register fields (no matching commit)
- [net-next,15/15] net: ipa: define remaining IPA register fields (no matching commit)
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Jakub Kicinski
maintainerQuoted 52 lines · On Wed, 28 Sep 2022 02:00:18 +0000 [email protected] wrote:
Hello:
This series was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:
Quoted 5 lines · On Mon, 26 Sep 2022 17:09:16 -0500 you wrote:
This series is quite a bit bigger than what I normally like to send, and I apologize for that. I would like it to get incorporated in its entirety this week if possible, and splitting up the series carries a small risk that wouldn't happen.
Quoted 8 lines
Each IPA register has a defined offset, and in most cases, a set of masks that define the width and position of fields within the register. Most registers currently use the same offset for all versions of IPA. Usually fields within registers are also the same across many versions. Offsets and fields like this are defined using preprocessor constants.
[...]
Here is the summary with links:
- [net-next,01/15] net: ipa: introduce IPA register IDshttps://git.kernel.org/netdev/net-next/c/98e2dd71a826 - [net-next,02/15] net: ipa: use IPA register IDs to determine offsets https://git.kernel.org/netdev/net-next/c/6bfb753850d3 - [net-next,03/15] net: ipa: add per-version IPA register definition files https://git.kernel.org/netdev/net-next/c/07f120bcf76b - [net-next,04/15] net: ipa: use ipa_reg[] array for register offsets https://git.kernel.org/netdev/net-next/c/82a06807453a - [net-next,05/15] net: ipa: introduce ipa_reg() (no matching commit) - [net-next,06/15] net: ipa: introduce ipa_reg field masks https://git.kernel.org/netdev/net-next/c/a5ad8956f97a - [net-next,07/15] net: ipa: define COMP_CFG IPA register fields https://git.kernel.org/netdev/net-next/c/12c7ea7dfd2c- [net-next,08/15] net: ipa: define
CLKON_CFGand ROUTE IPA register fields (no matching commit)
- [net-next,09/15] net: ipa: define some more IPA register fields (no matching commit)
- [net-next,10/15] net: ipa: define more IPA register fields (no matching commit)
- [net-next,11/15] net: ipa: define even more IPA register fields (no matching commit)
- [net-next,12/15] net: ipa: define resource group/type IPA register fields (no matching commit)
- [net-next,13/15] net: ipa: define some IPA endpoint register fields (no matching commit)
- [net-next,14/15] net: ipa: define more IPA endpoint register fields (no matching commit)
- [net-next,15/15] net: ipa: define remaining IPA register fields (no matching commit)
Quoted 1 line
You are awesome, thank you!
Hi Konstantin,
did anything change in the pw-bot in the last couple of weeks?
I didn't touch these patches and yet half got missed. Do you recommend we slap a Link on all patches? Currently I only add it to the cover letter / merge commit.