Commit beb90cba authored by Alex Elder's avatar Alex Elder Committed by David S. Miller

net: ipa: specify RX aggregation time limit in config data

Don't assume that a 500 microsecond time limit should be used for
all receive endpoints that support aggregation.  Instead, specify
the time limit to use in the configuration data.

Set a 500 microsecond limit for all existing RX endpoints, as before.

Checking for overflow for the time limit field is a bit complicated.
Rather than duplicate a lot of code in ipa_endpoint_data_valid_one(),
call WARN() if any value is found to be too large when encoding it.
Signed-off-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3cebb7c2
...@@ -103,6 +103,7 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = { ...@@ -103,6 +103,7 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = {
.rx = { .rx = {
.buffer_size = 8192, .buffer_size = 8192,
.pad_align = ilog2(sizeof(u32)), .pad_align = ilog2(sizeof(u32)),
.aggr_time_limit = 500,
}, },
}, },
}, },
...@@ -150,6 +151,7 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = { ...@@ -150,6 +151,7 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = {
.aggregation = true, .aggregation = true,
.rx = { .rx = {
.buffer_size = 8192, .buffer_size = 8192,
.aggr_time_limit = 500,
.aggr_close_eof = true, .aggr_close_eof = true,
}, },
}, },
......
...@@ -94,6 +94,7 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = { ...@@ -94,6 +94,7 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = {
.rx = { .rx = {
.buffer_size = 8192, .buffer_size = 8192,
.pad_align = ilog2(sizeof(u32)), .pad_align = ilog2(sizeof(u32)),
.aggr_time_limit = 500,
}, },
}, },
}, },
...@@ -142,6 +143,7 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = { ...@@ -142,6 +143,7 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = {
.aggregation = true, .aggregation = true,
.rx = { .rx = {
.buffer_size = 8192, .buffer_size = 8192,
.aggr_time_limit = 500,
.aggr_close_eof = true, .aggr_close_eof = true,
}, },
}, },
......
...@@ -88,6 +88,7 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = { ...@@ -88,6 +88,7 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = {
.rx = { .rx = {
.buffer_size = 8192, .buffer_size = 8192,
.pad_align = ilog2(sizeof(u32)), .pad_align = ilog2(sizeof(u32)),
.aggr_time_limit = 500,
}, },
}, },
}, },
...@@ -135,6 +136,7 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = { ...@@ -135,6 +136,7 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = {
.aggregation = true, .aggregation = true,
.rx = { .rx = {
.buffer_size = 32768, .buffer_size = 32768,
.aggr_time_limit = 500,
.aggr_close_eof = true, .aggr_close_eof = true,
}, },
}, },
......
...@@ -84,6 +84,7 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = { ...@@ -84,6 +84,7 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = {
.rx = { .rx = {
.buffer_size = 8192, .buffer_size = 8192,
.pad_align = ilog2(sizeof(u32)), .pad_align = ilog2(sizeof(u32)),
.aggr_time_limit = 500,
}, },
}, },
}, },
...@@ -132,6 +133,7 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = { ...@@ -132,6 +133,7 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = {
.aggregation = true, .aggregation = true,
.rx = { .rx = {
.buffer_size = 8192, .buffer_size = 8192,
.aggr_time_limit = 500,
.aggr_close_eof = true, .aggr_close_eof = true,
}, },
}, },
......
...@@ -97,6 +97,7 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = { ...@@ -97,6 +97,7 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = {
.rx = { .rx = {
.buffer_size = 8192, .buffer_size = 8192,
.pad_align = ilog2(sizeof(u32)), .pad_align = ilog2(sizeof(u32)),
.aggr_time_limit = 500,
}, },
}, },
}, },
...@@ -144,6 +145,7 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = { ...@@ -144,6 +145,7 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = {
.aggregation = true, .aggregation = true,
.rx = { .rx = {
.buffer_size = 8192, .buffer_size = 8192,
.aggr_time_limit = 500,
.aggr_close_eof = true, .aggr_close_eof = true,
}, },
}, },
......
...@@ -89,6 +89,7 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = { ...@@ -89,6 +89,7 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = {
.rx = { .rx = {
.buffer_size = 8192, .buffer_size = 8192,
.pad_align = ilog2(sizeof(u32)), .pad_align = ilog2(sizeof(u32)),
.aggr_time_limit = 500,
}, },
}, },
}, },
...@@ -136,6 +137,7 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = { ...@@ -136,6 +137,7 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = {
.aggregation = true, .aggregation = true,
.rx = { .rx = {
.buffer_size = 8192, .buffer_size = 8192,
.aggr_time_limit = 500,
.aggr_close_eof = true, .aggr_close_eof = true,
}, },
}, },
......
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
#define IPA_ENDPOINT_QMAP_METADATA_MASK 0x000000ff /* host byte order */ #define IPA_ENDPOINT_QMAP_METADATA_MASK 0x000000ff /* host byte order */
#define IPA_ENDPOINT_RESET_AGGR_RETRY_MAX 3 #define IPA_ENDPOINT_RESET_AGGR_RETRY_MAX 3
#define IPA_AGGR_TIME_LIMIT 500 /* microseconds */
/** enum ipa_status_opcode - status element opcode hardware values */ /** enum ipa_status_opcode - status element opcode hardware values */
enum ipa_status_opcode { enum ipa_status_opcode {
...@@ -142,6 +141,13 @@ static bool ipa_endpoint_data_valid_one(struct ipa *ipa, u32 count, ...@@ -142,6 +141,13 @@ static bool ipa_endpoint_data_valid_one(struct ipa *ipa, u32 count,
bool result = true; bool result = true;
/* No aggregation; check for bogus aggregation data */ /* No aggregation; check for bogus aggregation data */
if (rx_config->aggr_time_limit) {
dev_err(dev,
"time limit with no aggregation for RX endpoint %u\n",
data->endpoint_id);
result = false;
}
if (rx_config->aggr_hard_limit) { if (rx_config->aggr_hard_limit) {
dev_err(dev, "hard limit with no aggregation for RX endpoint %u\n", dev_err(dev, "hard limit with no aggregation for RX endpoint %u\n",
data->endpoint_id); data->endpoint_id);
...@@ -722,9 +728,13 @@ static u32 aggr_time_limit_encoded(enum ipa_version version, u32 limit) ...@@ -722,9 +728,13 @@ static u32 aggr_time_limit_encoded(enum ipa_version version, u32 limit)
if (version < IPA_VERSION_4_5) { if (version < IPA_VERSION_4_5) {
/* We set aggregation granularity in ipa_hardware_config() */ /* We set aggregation granularity in ipa_hardware_config() */
limit = DIV_ROUND_CLOSEST(limit, IPA_AGGR_GRANULARITY); fmask = aggr_time_limit_fmask(true);
val = DIV_ROUND_CLOSEST(limit, IPA_AGGR_GRANULARITY);
WARN(val > field_max(fmask),
"aggr_time_limit too large (%u > %u usec)\n",
val, field_max(fmask) * IPA_AGGR_GRANULARITY);
return u32_encode_bits(limit, aggr_time_limit_fmask(true)); return u32_encode_bits(val, fmask);
} }
/* IPA v4.5 expresses the time limit using Qtime. The AP has /* IPA v4.5 expresses the time limit using Qtime. The AP has
...@@ -739,6 +749,9 @@ static u32 aggr_time_limit_encoded(enum ipa_version version, u32 limit) ...@@ -739,6 +749,9 @@ static u32 aggr_time_limit_encoded(enum ipa_version version, u32 limit)
/* Have to use pulse generator 1 (millisecond granularity) */ /* Have to use pulse generator 1 (millisecond granularity) */
gran_sel = AGGR_GRAN_SEL_FMASK; gran_sel = AGGR_GRAN_SEL_FMASK;
val = DIV_ROUND_CLOSEST(limit, 1000); val = DIV_ROUND_CLOSEST(limit, 1000);
WARN(val > field_max(fmask),
"aggr_time_limit too large (%u > %u usec)\n",
limit, field_max(fmask) * 1000);
} else { } else {
/* We can use pulse generator 0 (100 usec granularity) */ /* We can use pulse generator 0 (100 usec granularity) */
gran_sel = 0; gran_sel = 0;
...@@ -779,7 +792,7 @@ static void ipa_endpoint_init_aggr(struct ipa_endpoint *endpoint) ...@@ -779,7 +792,7 @@ static void ipa_endpoint_init_aggr(struct ipa_endpoint *endpoint)
rx_config->aggr_hard_limit); rx_config->aggr_hard_limit);
val |= aggr_byte_limit_encoded(version, limit); val |= aggr_byte_limit_encoded(version, limit);
limit = IPA_AGGR_TIME_LIMIT; limit = rx_config->aggr_time_limit;
val |= aggr_time_limit_encoded(version, limit); val |= aggr_time_limit_encoded(version, limit);
/* AGGR_PKT_LIMIT is 0 (unlimited) */ /* AGGR_PKT_LIMIT is 0 (unlimited) */
......
...@@ -59,6 +59,7 @@ struct ipa_endpoint_tx { ...@@ -59,6 +59,7 @@ struct ipa_endpoint_tx {
* struct ipa_endpoint_rx - Endpoint configuration for RX endpoints * struct ipa_endpoint_rx - Endpoint configuration for RX endpoints
* @buffer_size: requested receive buffer size (bytes) * @buffer_size: requested receive buffer size (bytes)
* @pad_align: power-of-2 boundary to which packet payload is aligned * @pad_align: power-of-2 boundary to which packet payload is aligned
* @aggr_time_limit: time before aggregation closes (microseconds)
* @aggr_hard_limit: whether aggregation closes before or after boundary * @aggr_hard_limit: whether aggregation closes before or after boundary
* @aggr_close_eof: whether aggregation closes on end-of-frame * @aggr_close_eof: whether aggregation closes on end-of-frame
* @holb_drop: whether to drop packets to avoid head-of-line blocking * @holb_drop: whether to drop packets to avoid head-of-line blocking
...@@ -74,6 +75,10 @@ struct ipa_endpoint_tx { ...@@ -74,6 +75,10 @@ struct ipa_endpoint_tx {
* Aggregation is "open" while a buffer is being filled, and "closes" when * Aggregation is "open" while a buffer is being filled, and "closes" when
* certain criteria are met. * certain criteria are met.
* *
* A time limit can be specified to close aggregation. Aggregation will be
* closed if this period passes after data is first written into a receive
* buffer. If not specified, no time limit is imposed.
*
* Insufficient space available in the receive buffer can close aggregation. * Insufficient space available in the receive buffer can close aggregation.
* The aggregation byte limit defines the point (in units of 1024 bytes) in * The aggregation byte limit defines the point (in units of 1024 bytes) in
* the buffer where aggregation closes. With a "soft" aggregation limit, * the buffer where aggregation closes. With a "soft" aggregation limit,
...@@ -84,6 +89,7 @@ struct ipa_endpoint_tx { ...@@ -84,6 +89,7 @@ struct ipa_endpoint_tx {
struct ipa_endpoint_rx { struct ipa_endpoint_rx {
u32 buffer_size; u32 buffer_size;
u32 pad_align; u32 pad_align;
u32 aggr_time_limit;
bool aggr_hard_limit; bool aggr_hard_limit;
bool aggr_close_eof; bool aggr_close_eof;
bool holb_drop; bool holb_drop;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment