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
857857 name: tx-profile
858858 type: nest
859859 nested-attributes: profile
860+ -
861+ name: rx-cqe-frames
862+ type: u32
863+ -
864+ name: rx-cqe-nsecs
865+ type: u32
860866
861867 -
862868 name: pause-stat
@@ -2253,6 +2259,8 @@ operations: · 1390 unmodified lines
22532259 - tx-aggr-time-usecs
22542260 - rx-profile
22552261 - tx-profile
2262+ - rx-cqe-frames
2263+ - rx-cqe-nsecs
22562264 dump: *coalesce-get-op
22572265 -
22582266 name: coalesce-set
Documentation/networking/ethtool-netlink.rst+11−0
@@ -1076,6 +1076,8 @@ Kernel response contents: · 1075 unmodified lines
10761076 ``ETHTOOL_A_COALESCE_TX_AGGR_TIME_USECS`` u32 time (us), aggr, Tx
10771077 ``ETHTOOL_A_COALESCE_RX_PROFILE`` nested profile of DIM, Rx
10781078 ``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
10791081 =========================================== ====== =======================
10801082
10811083 Attributes 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
11091111 to DIM parameters, see `Generic Network Dynamic Interrupt Moderation (Net DIM)
11101112 <https://www.kernel.org/doc/Documentation/networking/net_dim.rst>`_.
11111113
1114+Rx CQE coalescing allows multiple received packets to be coalesced into a
1115+single Completion Queue Entry (CQE) or descriptor writeback.
1116+``ETHTOOL_A_COALESCE_RX_CQE_FRAMES`` describes the maximum number of
1117+frames that can be coalesced into a CQE or writeback.
1118+``ETHTOOL_A_COALESCE_RX_CQE_NSECS`` describes max time in nanoseconds after
1119+the first packet arrival in a coalesced CQE or writeback to be sent.
1120+
11121121 COALESCE_SET
11131122 ============
11141123
@@ -1147,6 +1156,8 @@ Request contents: · 32 unmodified lines
11471156 ``ETHTOOL_A_COALESCE_TX_AGGR_TIME_USECS`` u32 time (us), aggr, Tx
11481157 ``ETHTOOL_A_COALESCE_RX_PROFILE`` nested profile of DIM, Rx
11491158 ``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
11501161 =========================================== ====== =======================
11511162
11521163 Request 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
332332 u32 tx_aggr_max_bytes;
333333 u32 tx_aggr_max_frames;
334334 u32 tx_aggr_time_usecs;
335+ u32 rx_cqe_frames;
336+ u32 rx_cqe_nsecs;
335337 };
336338
337339 /**
@@ -380,7 +382,9 @@ bool ethtool_convert_link_mode_to_legacy_u32(u32 *legacy_u32, · 42 unmodified lines
380382 #define ETHTOOL_COALESCE_TX_AGGR_TIME_USECS BIT(26)
381383 #define ETHTOOL_COALESCE_RX_PROFILE BIT(27)
382384 #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)
384388
385389 #define ETHTOOL_COALESCE_USECS \
386390 (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
371371 ETHTOOL_A_COALESCE_TX_AGGR_TIME_USECS,
372372 ETHTOOL_A_COALESCE_RX_PROFILE,
373373 ETHTOOL_A_COALESCE_TX_PROFILE,
374+ ETHTOOL_A_COALESCE_RX_CQE_FRAMES,
375+ ETHTOOL_A_COALESCE_RX_CQE_NSECS,
374376
375377 __ETHTOOL_A_COALESCE_CNT,
376378 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
118118 nla_total_size(sizeof(u32)) + /* _TX_AGGR_MAX_BYTES */
119119 nla_total_size(sizeof(u32)) + /* _TX_AGGR_MAX_FRAMES */
120120 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 */
121123 total_modersz * 2; /* _{R,T}X_PROFILE */
122124 }
123125
@@ -269,7 +271,11 @@ static int coalesce_fill_reply(struct sk_buff *skb, · 145 unmodified lines
269271 coalesce_put_u32(skb, ETHTOOL_A_COALESCE_TX_AGGR_MAX_FRAMES,
270272 kcoal->tx_aggr_max_frames, supported) ||
271273 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))
273279 return -EMSGSIZE;
274280
275281 if (!req_base->dev || !req_base->dev->irq_moder)
@@ -338,6 +344,8 @@ const struct nla_policy ethnl_coalesce_set_policy[] = { · 62 unmodified lines
338344 [ETHTOOL_A_COALESCE_TX_AGGR_MAX_BYTES] = { .type = NLA_U32 },
339345 [ETHTOOL_A_COALESCE_TX_AGGR_MAX_FRAMES] = { .type = NLA_U32 },
340346 [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 },
341349 [ETHTOOL_A_COALESCE_RX_PROFILE] =
342350 NLA_POLICY_NESTED(coalesce_profile_policy),
343351 [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
570578 tb[ETHTOOL_A_COALESCE_TX_AGGR_MAX_FRAMES], &mod);
571579 ethnl_update_u32(&kernel_coalesce.tx_aggr_time_usecs,
572580 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);
573585
574586 if (dev->irq_moder && dev->irq_moder->profile_flags & DIM_PROFILE_RX) {
575587 ret = ethnl_update_profile(dev, &dev->irq_moder->rx_profile,