net: ipa: rework ipa_aggr_granularity_val()
The timer used for aggregation makes use of an internal 32 KHz clock. The granularity of the timer is programmed by a field whose value is computed by ipa_aggr_granularity_val(). Redefine the way that value is computed by using a new TIMER_FREQUENCY constant representing the underlying clock frequency. Add two BUILD_BUG_ON() calls to ensure the value used is valid. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
8c96439724
commit
317a5740b7
|
@ -674,6 +674,11 @@ static void ipa_validate_build(void)
|
|||
|
||||
/* This is used as a divisor */
|
||||
BUILD_BUG_ON(!IPA_AGGR_GRANULARITY);
|
||||
|
||||
/* 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));
|
||||
#endif /* IPA_VALIDATE */
|
||||
}
|
||||
|
||||
|
|
|
@ -190,24 +190,23 @@ static inline u32 ipa_reg_bcr_val(enum ipa_version version)
|
|||
return 0x00000000;
|
||||
}
|
||||
|
||||
|
||||
#define IPA_REG_LOCAL_PKT_PROC_CNTXT_BASE_OFFSET 0x000001e8
|
||||
|
||||
#define IPA_REG_AGGR_FORCE_CLOSE_OFFSET 0x000001ec
|
||||
/* ipa->available defines the valid bits in the AGGR_FORCE_CLOSE register */
|
||||
|
||||
/* The internal inactivity timer clock is used for the aggregation timer */
|
||||
#define TIMER_FREQUENCY 32000 /* 32 KHz inactivity timer clock */
|
||||
|
||||
#define IPA_REG_COUNTER_CFG_OFFSET 0x000001f0
|
||||
#define AGGR_GRANULARITY GENMASK(8, 4)
|
||||
/* Compute the value to use in the AGGR_GRANULARITY field representing
|
||||
* the given number of microseconds (up to 1 millisecond).
|
||||
* x = (32 * usec) / 1000 - 1
|
||||
/* Compute the value to use in the AGGR_GRANULARITY field representing the
|
||||
* given number of microseconds. The value is one less than the number of
|
||||
* timer ticks in the requested period. Zero not a valid granularity value.
|
||||
*/
|
||||
static inline u32 ipa_aggr_granularity_val(u32 microseconds)
|
||||
static inline u32 ipa_aggr_granularity_val(u32 usec)
|
||||
{
|
||||
/* assert(microseconds >= 16); (?) */
|
||||
/* assert(microseconds <= 1015); */
|
||||
|
||||
return DIV_ROUND_CLOSEST(32 * microseconds, 1000) - 1;
|
||||
return DIV_ROUND_CLOSEST(usec * TIMER_FREQUENCY, USEC_PER_SEC) - 1;
|
||||
}
|
||||
|
||||
#define IPA_REG_TX_CFG_OFFSET 0x000001fc
|
||||
|
|
Loading…
Reference in New Issue