[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221109180249.4721-2-dnlplm@gmail.com>
Date: Wed, 9 Nov 2022 19:02:47 +0100
From: Daniele Palmas <dnlplm@...il.com>
To: David Miller <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Eric Dumazet <edumazet@...gle.com>,
Subash Abhinov Kasiviswanathan <quic_subashab@...cinc.com>,
Sean Tranchetti <quic_stranche@...cinc.com>,
Jonathan Corbet <corbet@....net>
Cc: Bjørn Mork <bjorn@...k.no>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
netdev@...r.kernel.org, Daniele Palmas <dnlplm@...il.com>
Subject: [PATCH net-next 1/3] ethtool: add tx aggregation parameters
Add the following ethtool tx aggregation parameters:
ETHTOOL_A_COALESCE_TX_MAX_AGGR_SIZE
Maximum size of an aggregated block of frames in tx.
ETHTOOL_A_COALESCE_TX_MAX_AGGR_FRAMES
Maximum number of frames that can be aggregated into a block.
ETHTOOL_A_COALESCE_TX_USECS_AGGR_TIME
Time in usecs after the first packet arrival in an aggregated
block for the block to be sent.
Signed-off-by: Daniele Palmas <dnlplm@...il.com>
---
Documentation/networking/ethtool-netlink.rst | 6 ++++++
include/linux/ethtool.h | 12 ++++++++++-
include/uapi/linux/ethtool_netlink.h | 3 +++
net/ethtool/coalesce.c | 22 ++++++++++++++++++--
4 files changed, 40 insertions(+), 3 deletions(-)
diff --git a/Documentation/networking/ethtool-netlink.rst b/Documentation/networking/ethtool-netlink.rst
index d578b8bcd8a4..a6f115867648 100644
--- a/Documentation/networking/ethtool-netlink.rst
+++ b/Documentation/networking/ethtool-netlink.rst
@@ -1001,6 +1001,9 @@ Kernel response contents:
``ETHTOOL_A_COALESCE_RATE_SAMPLE_INTERVAL`` u32 rate sampling interval
``ETHTOOL_A_COALESCE_USE_CQE_TX`` bool timer reset mode, Tx
``ETHTOOL_A_COALESCE_USE_CQE_RX`` bool timer reset mode, Rx
+ ``ETHTOOL_A_COALESCE_TX_MAX_AGGR_SIZE`` u32 max aggr packets size, Tx
+ ``ETHTOOL_A_COALESCE_TX_MAX_AGGR_FRAMES`` u32 max aggr packets, Tx
+ ``ETHTOOL_A_COALESCE_TX_USECS_AGGR_TIME`` u32 time (us), aggr pkts, Tx
=========================================== ====== =======================
Attributes are only included in reply if their value is not zero or the
@@ -1052,6 +1055,9 @@ Request contents:
``ETHTOOL_A_COALESCE_RATE_SAMPLE_INTERVAL`` u32 rate sampling interval
``ETHTOOL_A_COALESCE_USE_CQE_TX`` bool timer reset mode, Tx
``ETHTOOL_A_COALESCE_USE_CQE_RX`` bool timer reset mode, Rx
+ ``ETHTOOL_A_COALESCE_TX_MAX_AGGR_SIZE`` u32 max aggr packets size, Tx
+ ``ETHTOOL_A_COALESCE_TX_MAX_AGGR_FRAMES`` u32 max aggr packets, Tx
+ ``ETHTOOL_A_COALESCE_TX_USECS_AGGR_TIME`` u32 time (us), aggr pkts, Tx
=========================================== ====== =======================
Request is rejected if it attributes declared as unsupported by driver (i.e.
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index 99dc7bfbcd3c..3726db470247 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -203,6 +203,9 @@ __ethtool_get_link_ksettings(struct net_device *dev,
struct kernel_ethtool_coalesce {
u8 use_cqe_mode_tx;
u8 use_cqe_mode_rx;
+ u32 tx_max_aggr_size;
+ u32 tx_max_aggr_frames;
+ u32 tx_usecs_aggr_time;
};
/**
@@ -246,7 +249,10 @@ bool ethtool_convert_link_mode_to_legacy_u32(u32 *legacy_u32,
#define ETHTOOL_COALESCE_RATE_SAMPLE_INTERVAL BIT(21)
#define ETHTOOL_COALESCE_USE_CQE_RX BIT(22)
#define ETHTOOL_COALESCE_USE_CQE_TX BIT(23)
-#define ETHTOOL_COALESCE_ALL_PARAMS GENMASK(23, 0)
+#define ETHTOOL_COALESCE_TX_MAX_AGGR_SIZE BIT(24)
+#define ETHTOOL_COALESCE_TX_MAX_AGGR_FRAMES BIT(25)
+#define ETHTOOL_COALESCE_TX_USECS_AGGR_TIME BIT(26)
+#define ETHTOOL_COALESCE_ALL_PARAMS GENMASK(26, 0)
#define ETHTOOL_COALESCE_USECS \
(ETHTOOL_COALESCE_RX_USECS | ETHTOOL_COALESCE_TX_USECS)
@@ -274,6 +280,10 @@ bool ethtool_convert_link_mode_to_legacy_u32(u32 *legacy_u32,
ETHTOOL_COALESCE_RATE_SAMPLE_INTERVAL)
#define ETHTOOL_COALESCE_USE_CQE \
(ETHTOOL_COALESCE_USE_CQE_RX | ETHTOOL_COALESCE_USE_CQE_TX)
+#define ETHTOOL_COALESCE_TX_AGGR \
+ (ETHTOOL_COALESCE_TX_MAX_AGGR_SIZE | \
+ ETHTOOL_COALESCE_TX_MAX_AGGR_FRAMES | \
+ ETHTOOL_COALESCE_TX_USECS_AGGR_TIME)
#define ETHTOOL_STAT_NOT_SET (~0ULL)
diff --git a/include/uapi/linux/ethtool_netlink.h b/include/uapi/linux/ethtool_netlink.h
index bb57084ac524..08872c8ea0d6 100644
--- a/include/uapi/linux/ethtool_netlink.h
+++ b/include/uapi/linux/ethtool_netlink.h
@@ -397,6 +397,9 @@ enum {
ETHTOOL_A_COALESCE_RATE_SAMPLE_INTERVAL, /* u32 */
ETHTOOL_A_COALESCE_USE_CQE_MODE_TX, /* u8 */
ETHTOOL_A_COALESCE_USE_CQE_MODE_RX, /* u8 */
+ ETHTOOL_A_COALESCE_TX_MAX_AGGR_SIZE, /* u32 */
+ ETHTOOL_A_COALESCE_TX_MAX_AGGR_FRAMES, /* u32 */
+ ETHTOOL_A_COALESCE_TX_USECS_AGGR_TIME, /* u32 */
/* add new constants above here */
__ETHTOOL_A_COALESCE_CNT,
diff --git a/net/ethtool/coalesce.c b/net/ethtool/coalesce.c
index 487bdf345541..014a7a4f73f2 100644
--- a/net/ethtool/coalesce.c
+++ b/net/ethtool/coalesce.c
@@ -105,7 +105,10 @@ static int coalesce_reply_size(const struct ethnl_req_info *req_base,
nla_total_size(sizeof(u32)) + /* _TX_MAX_FRAMES_HIGH */
nla_total_size(sizeof(u32)) + /* _RATE_SAMPLE_INTERVAL */
nla_total_size(sizeof(u8)) + /* _USE_CQE_MODE_TX */
- nla_total_size(sizeof(u8)); /* _USE_CQE_MODE_RX */
+ nla_total_size(sizeof(u8)) + /* _USE_CQE_MODE_RX */
+ nla_total_size(sizeof(u32)) + /* _TX_MAX_AGGR_SIZE */
+ nla_total_size(sizeof(u32)) + /* _TX_MAX_AGGR_FRAMES */
+ nla_total_size(sizeof(u32)); /* _TX_USECS_AGGR_TIME */
}
static bool coalesce_put_u32(struct sk_buff *skb, u16 attr_type, u32 val,
@@ -180,7 +183,13 @@ static int coalesce_fill_reply(struct sk_buff *skb,
coalesce_put_bool(skb, ETHTOOL_A_COALESCE_USE_CQE_MODE_TX,
kcoal->use_cqe_mode_tx, supported) ||
coalesce_put_bool(skb, ETHTOOL_A_COALESCE_USE_CQE_MODE_RX,
- kcoal->use_cqe_mode_rx, supported))
+ kcoal->use_cqe_mode_rx, supported) ||
+ coalesce_put_u32(skb, ETHTOOL_A_COALESCE_TX_MAX_AGGR_SIZE,
+ kcoal->tx_max_aggr_size, supported) ||
+ coalesce_put_u32(skb, ETHTOOL_A_COALESCE_TX_MAX_AGGR_FRAMES,
+ kcoal->tx_max_aggr_frames, supported) ||
+ coalesce_put_u32(skb, ETHTOOL_A_COALESCE_TX_USECS_AGGR_TIME,
+ kcoal->tx_usecs_aggr_time, supported))
return -EMSGSIZE;
return 0;
@@ -227,6 +236,9 @@ const struct nla_policy ethnl_coalesce_set_policy[] = {
[ETHTOOL_A_COALESCE_RATE_SAMPLE_INTERVAL] = { .type = NLA_U32 },
[ETHTOOL_A_COALESCE_USE_CQE_MODE_TX] = NLA_POLICY_MAX(NLA_U8, 1),
[ETHTOOL_A_COALESCE_USE_CQE_MODE_RX] = NLA_POLICY_MAX(NLA_U8, 1),
+ [ETHTOOL_A_COALESCE_TX_MAX_AGGR_SIZE] = { .type = NLA_U32 },
+ [ETHTOOL_A_COALESCE_TX_MAX_AGGR_FRAMES] = { .type = NLA_U32 },
+ [ETHTOOL_A_COALESCE_TX_USECS_AGGR_TIME] = { .type = NLA_U32 },
};
int ethnl_set_coalesce(struct sk_buff *skb, struct genl_info *info)
@@ -321,6 +333,12 @@ int ethnl_set_coalesce(struct sk_buff *skb, struct genl_info *info)
tb[ETHTOOL_A_COALESCE_USE_CQE_MODE_TX], &mod);
ethnl_update_u8(&kernel_coalesce.use_cqe_mode_rx,
tb[ETHTOOL_A_COALESCE_USE_CQE_MODE_RX], &mod);
+ ethnl_update_u32(&kernel_coalesce.tx_max_aggr_size,
+ tb[ETHTOOL_A_COALESCE_TX_MAX_AGGR_SIZE], &mod);
+ ethnl_update_u32(&kernel_coalesce.tx_max_aggr_frames,
+ tb[ETHTOOL_A_COALESCE_TX_MAX_AGGR_FRAMES], &mod);
+ ethnl_update_u32(&kernel_coalesce.tx_usecs_aggr_time,
+ tb[ETHTOOL_A_COALESCE_TX_USECS_AGGR_TIME], &mod);
ret = 0;
if (!mod)
goto out_ops;
--
2.37.1
Powered by blists - more mailing lists