History

net: ethtool: add ethtool COALESCE_RX_CQE_FRAMES/NSECS

Add two parameters for drivers supporting Rx CQE coalescing / descriptor writeback. ETHTOOL_A_COALESCE_RX_CQE_FRAMES: Maximum number of frames that can be coalesced into a CQE or writeback. ETHTOOL_A_COALESCE_RX_CQE_NSECS: Max time in nanoseconds after the first packet arrival in a coalesced CQE or writeback to be sent.

Haiyang Zhang committed 8 months ago

Commit dc3d7201 parent 04cd0755 files · +39 −2Browse files

Unified · Split

5 files
  1. Documentation/netlink/specs/ethtool.yaml +8 −0
  2. Documentation/networking/ethtool-netlink.rst +11 −0
  3. include/linux/ethtool.h +5 −1
  4. include/uapi/linux/ethtool_netlink_generated.h +2 −0
  5. net/ethtool/coalesce.c +13 −1
Documentation/netlink/specs/ethtool.yaml+8−0
@@ -857,6 +857,12 @@ attribute-sets: · 856 unmodified lines
857 name: tx-profile857 name: tx-profile
858 type: nest858 type: nest
859 nested-attributes: profile859 nested-attributes: profile
860 -
861 name: rx-cqe-frames
862 type: u32
863 -
864 name: rx-cqe-nsecs
865 type: u32
860 866
861 -867 -
862 name: pause-stat868 name: pause-stat
@@ -2253,6 +2259,8 @@ operations: · 1390 unmodified lines
2253 - tx-aggr-time-usecs2259 - tx-aggr-time-usecs
2254 - rx-profile2260 - rx-profile
2255 - tx-profile2261 - tx-profile
2262 - rx-cqe-frames
2263 - rx-cqe-nsecs
2256 dump: *coalesce-get-op2264 dump: *coalesce-get-op
2257 -2265 -
2258 name: coalesce-set2266 name: coalesce-set
Documentation/networking/ethtool-netlink.rst+11−0
@@ -1076,6 +1076,8 @@ Kernel response contents: · 1075 unmodified lines
1076 ``ETHTOOL_A_COALESCE_TX_AGGR_TIME_USECS`` u32 time (us), aggr, Tx1076 ``ETHTOOL_A_COALESCE_TX_AGGR_TIME_USECS`` u32 time (us), aggr, Tx
1077 ``ETHTOOL_A_COALESCE_RX_PROFILE`` nested profile of DIM, Rx1077 ``ETHTOOL_A_COALESCE_RX_PROFILE`` nested profile of DIM, Rx
1078 ``ETHTOOL_A_COALESCE_TX_PROFILE`` nested profile of DIM, Tx1078 ``ETHTOOL_A_COALESCE_TX_PROFILE`` nested profile of DIM, Tx
1079 ``ETHTOOL_A_COALESCE_RX_CQE_FRAMES`` u32 max packets, Rx CQE
1080 ``ETHTOOL_A_COALESCE_RX_CQE_NSECS`` u32 delay (ns), Rx CQE
1079 =========================================== ====== =======================1081 =========================================== ====== =======================
1080 1082
1081Attributes are only included in reply if their value is not zero or the1083Attributes are only included in reply if their value is not zero or the
@@ -1109,6 +1111,13 @@ well with frequent small-sized URBs transmissions. · 27 unmodified lines
1109to DIM parameters, see `Generic Network Dynamic Interrupt Moderation (Net DIM)1111to DIM parameters, see `Generic Network Dynamic Interrupt Moderation (Net DIM)
1110<https://www.kernel.org/doc/Documentation/networking/net_dim.rst>`_.1112<https://www.kernel.org/doc/Documentation/networking/net_dim.rst>`_.
1111 1113
1114Rx CQE coalescing allows multiple received packets to be coalesced into a
1115single Completion Queue Entry (CQE) or descriptor writeback.
1116``ETHTOOL_A_COALESCE_RX_CQE_FRAMES`` describes the maximum number of
1117frames that can be coalesced into a CQE or writeback.
1118``ETHTOOL_A_COALESCE_RX_CQE_NSECS`` describes max time in nanoseconds after
1119the first packet arrival in a coalesced CQE or writeback to be sent.
1120
1112COALESCE_SET1121COALESCE_SET
1113============1122============
1114 1123
@@ -1147,6 +1156,8 @@ Request contents: · 32 unmodified lines
1147 ``ETHTOOL_A_COALESCE_TX_AGGR_TIME_USECS`` u32 time (us), aggr, Tx1156 ``ETHTOOL_A_COALESCE_TX_AGGR_TIME_USECS`` u32 time (us), aggr, Tx
1148 ``ETHTOOL_A_COALESCE_RX_PROFILE`` nested profile of DIM, Rx1157 ``ETHTOOL_A_COALESCE_RX_PROFILE`` nested profile of DIM, Rx
1149 ``ETHTOOL_A_COALESCE_TX_PROFILE`` nested profile of DIM, Tx1158 ``ETHTOOL_A_COALESCE_TX_PROFILE`` nested profile of DIM, Tx
1159 ``ETHTOOL_A_COALESCE_RX_CQE_FRAMES`` u32 max packets, Rx CQE
1160 ``ETHTOOL_A_COALESCE_RX_CQE_NSECS`` u32 delay (ns), Rx CQE
1150 =========================================== ====== =======================1161 =========================================== ====== =======================
1151 1162
1152Request is rejected if it attributes declared as unsupported by driver (i.e.1163Request is rejected if it attributes declared as unsupported by driver (i.e.
include/linux/ethtool.h+5−1
@@ -332,6 +332,8 @@ struct kernel_ethtool_coalesce { · 331 unmodified lines
332 u32 tx_aggr_max_bytes;332 u32 tx_aggr_max_bytes;
333 u32 tx_aggr_max_frames;333 u32 tx_aggr_max_frames;
334 u32 tx_aggr_time_usecs;334 u32 tx_aggr_time_usecs;
335 u32 rx_cqe_frames;
336 u32 rx_cqe_nsecs;
335};337};
336 338
337/**339/**
@@ -380,7 +382,9 @@ bool ethtool_convert_link_mode_to_legacy_u32(u32 *legacy_u32, · 42 unmodified lines
380#define ETHTOOL_COALESCE_TX_AGGR_TIME_USECS BIT(26)382#define ETHTOOL_COALESCE_TX_AGGR_TIME_USECS BIT(26)
381#define ETHTOOL_COALESCE_RX_PROFILE BIT(27)383#define ETHTOOL_COALESCE_RX_PROFILE BIT(27)
382#define ETHTOOL_COALESCE_TX_PROFILE BIT(28)384#define ETHTOOL_COALESCE_TX_PROFILE BIT(28)
383#define ETHTOOL_COALESCE_ALL_PARAMS GENMASK(28, 0)385#define ETHTOOL_COALESCE_RX_CQE_FRAMES BIT(29)
386#define ETHTOOL_COALESCE_RX_CQE_NSECS BIT(30)
387#define ETHTOOL_COALESCE_ALL_PARAMS GENMASK(30, 0)
384 388
385#define ETHTOOL_COALESCE_USECS \389#define ETHTOOL_COALESCE_USECS \
386 (ETHTOOL_COALESCE_RX_USECS | ETHTOOL_COALESCE_TX_USECS)390 (ETHTOOL_COALESCE_RX_USECS | ETHTOOL_COALESCE_TX_USECS)
include/uapi/linux/ethtool_netlink_generated.h+2−0
@@ -371,6 +371,8 @@ enum { · 370 unmodified lines
371 ETHTOOL_A_COALESCE_TX_AGGR_TIME_USECS,371 ETHTOOL_A_COALESCE_TX_AGGR_TIME_USECS,
372 ETHTOOL_A_COALESCE_RX_PROFILE,372 ETHTOOL_A_COALESCE_RX_PROFILE,
373 ETHTOOL_A_COALESCE_TX_PROFILE,373 ETHTOOL_A_COALESCE_TX_PROFILE,
374 ETHTOOL_A_COALESCE_RX_CQE_FRAMES,
375 ETHTOOL_A_COALESCE_RX_CQE_NSECS,
374 376
375 __ETHTOOL_A_COALESCE_CNT,377 __ETHTOOL_A_COALESCE_CNT,
376 ETHTOOL_A_COALESCE_MAX = (__ETHTOOL_A_COALESCE_CNT - 1)378 ETHTOOL_A_COALESCE_MAX = (__ETHTOOL_A_COALESCE_CNT - 1)
net/ethtool/coalesce.c+13−1
@@ -118,6 +118,8 @@ static int coalesce_reply_size(const struct ethnl_req_info *req_base, · 117 unmodified lines
118 nla_total_size(sizeof(u32)) + /* _TX_AGGR_MAX_BYTES */118 nla_total_size(sizeof(u32)) + /* _TX_AGGR_MAX_BYTES */
119 nla_total_size(sizeof(u32)) + /* _TX_AGGR_MAX_FRAMES */119 nla_total_size(sizeof(u32)) + /* _TX_AGGR_MAX_FRAMES */
120 nla_total_size(sizeof(u32)) + /* _TX_AGGR_TIME_USECS */120 nla_total_size(sizeof(u32)) + /* _TX_AGGR_TIME_USECS */
121 nla_total_size(sizeof(u32)) + /* _RX_CQE_FRAMES */
122 nla_total_size(sizeof(u32)) + /* _RX_CQE_NSECS */
121 total_modersz * 2; /* _{R,T}X_PROFILE */123 total_modersz * 2; /* _{R,T}X_PROFILE */
122}124}
123 125
@@ -269,7 +271,11 @@ static int coalesce_fill_reply(struct sk_buff *skb, · 145 unmodified lines
269 coalesce_put_u32(skb, ETHTOOL_A_COALESCE_TX_AGGR_MAX_FRAMES,271 coalesce_put_u32(skb, ETHTOOL_A_COALESCE_TX_AGGR_MAX_FRAMES,
270 kcoal->tx_aggr_max_frames, supported) ||272 kcoal->tx_aggr_max_frames, supported) ||
271 coalesce_put_u32(skb, ETHTOOL_A_COALESCE_TX_AGGR_TIME_USECS,273 coalesce_put_u32(skb, ETHTOOL_A_COALESCE_TX_AGGR_TIME_USECS,
272 kcoal->tx_aggr_time_usecs, supported))274 kcoal->tx_aggr_time_usecs, supported) ||
275 coalesce_put_u32(skb, ETHTOOL_A_COALESCE_RX_CQE_FRAMES,
276 kcoal->rx_cqe_frames, supported) ||
277 coalesce_put_u32(skb, ETHTOOL_A_COALESCE_RX_CQE_NSECS,
278 kcoal->rx_cqe_nsecs, supported))
273 return -EMSGSIZE;279 return -EMSGSIZE;
274 280
275 if (!req_base->dev || !req_base->dev->irq_moder)281 if (!req_base->dev || !req_base->dev->irq_moder)
@@ -338,6 +344,8 @@ const struct nla_policy ethnl_coalesce_set_policy[] = { · 62 unmodified lines
338 [ETHTOOL_A_COALESCE_TX_AGGR_MAX_BYTES] = { .type = NLA_U32 },344 [ETHTOOL_A_COALESCE_TX_AGGR_MAX_BYTES] = { .type = NLA_U32 },
339 [ETHTOOL_A_COALESCE_TX_AGGR_MAX_FRAMES] = { .type = NLA_U32 },345 [ETHTOOL_A_COALESCE_TX_AGGR_MAX_FRAMES] = { .type = NLA_U32 },
340 [ETHTOOL_A_COALESCE_TX_AGGR_TIME_USECS] = { .type = NLA_U32 },346 [ETHTOOL_A_COALESCE_TX_AGGR_TIME_USECS] = { .type = NLA_U32 },
347 [ETHTOOL_A_COALESCE_RX_CQE_FRAMES] = { .type = NLA_U32 },
348 [ETHTOOL_A_COALESCE_RX_CQE_NSECS] = { .type = NLA_U32 },
341 [ETHTOOL_A_COALESCE_RX_PROFILE] =349 [ETHTOOL_A_COALESCE_RX_PROFILE] =
342 NLA_POLICY_NESTED(coalesce_profile_policy),350 NLA_POLICY_NESTED(coalesce_profile_policy),
343 [ETHTOOL_A_COALESCE_TX_PROFILE] =351 [ETHTOOL_A_COALESCE_TX_PROFILE] =
@@ -570,6 +578,10 @@ __ethnl_set_coalesce(struct ethnl_req_info *req_info, struct genl_info *info, · 226 unmodified lines
570 tb[ETHTOOL_A_COALESCE_TX_AGGR_MAX_FRAMES], &mod);578 tb[ETHTOOL_A_COALESCE_TX_AGGR_MAX_FRAMES], &mod);
571 ethnl_update_u32(&kernel_coalesce.tx_aggr_time_usecs,579 ethnl_update_u32(&kernel_coalesce.tx_aggr_time_usecs,
572 tb[ETHTOOL_A_COALESCE_TX_AGGR_TIME_USECS], &mod);580 tb[ETHTOOL_A_COALESCE_TX_AGGR_TIME_USECS], &mod);
581 ethnl_update_u32(&kernel_coalesce.rx_cqe_frames,
582 tb[ETHTOOL_A_COALESCE_RX_CQE_FRAMES], &mod);
583 ethnl_update_u32(&kernel_coalesce.rx_cqe_nsecs,
584 tb[ETHTOOL_A_COALESCE_RX_CQE_NSECS], &mod);
573 585
574 if (dev->irq_moder && dev->irq_moder->profile_flags & DIM_PROFILE_RX) {586 if (dev->irq_moder && dev->irq_moder->profile_flags & DIM_PROFILE_RX) {
575 ret = ethnl_update_profile(dev, &dev->irq_moder->rx_profile,587 ret = ethnl_update_profile(dev, &dev->irq_moder->rx_profile,