Skip to content

Commit 2172754

Browse files
mkubecekdavem330
authored andcommitted
ethtool: provide coalescing parameters with COALESCE_GET request
Implement COALESCE_GET request to get coalescing parameters of a network device. These are traditionally available via ETHTOOL_GCOALESCE ioctl request. This commit adds only support for device coalescing parameters, not per queue coalescing parameters. Omit attributes with zero values unless they are declared as supported (i.e. the corresponding bit in ethtool_ops::supported_coalesce_params is set). Signed-off-by: Michal Kubecek <mkubecek@suse.cz> Reviewed-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent b51fb77 commit 2172754

6 files changed

Lines changed: 306 additions & 2 deletions

File tree

‎Documentation/networking/ethtool-netlink.rst‎

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ Userspace to kernel:
197197
``ETHTOOL_MSG_RINGS_SET`` set ring sizes
198198
``ETHTOOL_MSG_CHANNELS_GET`` get channel counts
199199
``ETHTOOL_MSG_CHANNELS_SET`` set channel counts
200+
``ETHTOOL_MSG_COALESCE_GET`` get coalescing parameters
200201
===================================== ================================
201202

202203
Kernel to userspace:
@@ -221,6 +222,7 @@ Kernel to userspace:
221222
``ETHTOOL_MSG_RINGS_NTF`` ring sizes
222223
``ETHTOOL_MSG_CHANNELS_GET_REPLY`` channel counts
223224
``ETHTOOL_MSG_CHANNELS_NTF`` channel counts
225+
``ETHTOOL_MSG_COALESCE_GET_REPLY`` coalescing parameters
224226
===================================== =================================
225227

226228
``GET`` requests are sent by userspace applications to retrieve device
@@ -745,6 +747,50 @@ driver. Driver may impose additional constraints and may not suspport all
745747
attributes.
746748

747749

750+
COALESCE_GET
751+
============
752+
753+
Gets coalescing parameters like ``ETHTOOL_GCOALESCE`` ioctl request.
754+
755+
Request contents:
756+
757+
==================================== ====== ==========================
758+
``ETHTOOL_A_COALESCE_HEADER`` nested request header
759+
==================================== ====== ==========================
760+
761+
Kernel response contents:
762+
763+
=========================================== ====== =======================
764+
``ETHTOOL_A_COALESCE_HEADER`` nested reply header
765+
``ETHTOOL_A_COALESCE_RX_USECS`` u32 delay (us), normal Rx
766+
``ETHTOOL_A_COALESCE_RX_MAX_FRAMES`` u32 max packets, normal Rx
767+
``ETHTOOL_A_COALESCE_RX_USECS_IRQ`` u32 delay (us), Rx in IRQ
768+
``ETHTOOL_A_COALESCE_RX_MAX_FRAMES_IRQ`` u32 max packets, Rx in IRQ
769+
``ETHTOOL_A_COALESCE_TX_USECS`` u32 delay (us), normal Tx
770+
``ETHTOOL_A_COALESCE_TX_MAX_FRAMES`` u32 max packets, normal Tx
771+
``ETHTOOL_A_COALESCE_TX_USECS_IRQ`` u32 delay (us), Tx in IRQ
772+
``ETHTOOL_A_COALESCE_TX_MAX_FRAMES_IRQ`` u32 IRQ packets, Tx in IRQ
773+
``ETHTOOL_A_COALESCE_STATS_BLOCK_USECS`` u32 delay of stats update
774+
``ETHTOOL_A_COALESCE_USE_ADAPTIVE_RX`` bool adaptive Rx coalesce
775+
``ETHTOOL_A_COALESCE_USE_ADAPTIVE_TX`` bool adaptive Tx coalesce
776+
``ETHTOOL_A_COALESCE_PKT_RATE_LOW`` u32 threshold for low rate
777+
``ETHTOOL_A_COALESCE_RX_USECS_LOW`` u32 delay (us), low Rx
778+
``ETHTOOL_A_COALESCE_RX_MAX_FRAMES_LOW`` u32 max packets, low Rx
779+
``ETHTOOL_A_COALESCE_TX_USECS_LOW`` u32 delay (us), low Tx
780+
``ETHTOOL_A_COALESCE_TX_MAX_FRAMES_LOW`` u32 max packets, low Tx
781+
``ETHTOOL_A_COALESCE_PKT_RATE_HIGH`` u32 threshold for high rate
782+
``ETHTOOL_A_COALESCE_RX_USECS_HIGH`` u32 delay (us), high Rx
783+
``ETHTOOL_A_COALESCE_RX_MAX_FRAMES_HIGH`` u32 max packets, high Rx
784+
``ETHTOOL_A_COALESCE_TX_USECS_HIGH`` u32 delay (us), high Tx
785+
``ETHTOOL_A_COALESCE_TX_MAX_FRAMES_HIGH`` u32 max packets, high Tx
786+
``ETHTOOL_A_COALESCE_RATE_SAMPLE_INTERVAL`` u32 rate sampling interval
787+
=========================================== ====== =======================
788+
789+
Attributes are only included in reply if their value is not zero or the
790+
corresponding bit in ``ethtool_ops::supported_coalesce_params`` is set (i.e.
791+
they are declared as supported by driver).
792+
793+
748794
Request translation
749795
===================
750796

@@ -769,7 +815,7 @@ have their netlink replacement yet.
769815
``ETHTOOL_GLINK`` ``ETHTOOL_MSG_LINKSTATE_GET``
770816
``ETHTOOL_GEEPROM`` n/a
771817
``ETHTOOL_SEEPROM`` n/a
772-
``ETHTOOL_GCOALESCE`` n/a
818+
``ETHTOOL_GCOALESCE`` ``ETHTOOL_MSG_COALESCE_GET``
773819
``ETHTOOL_SCOALESCE`` n/a
774820
``ETHTOOL_GRINGPARAM`` ``ETHTOOL_MSG_RINGS_GET``
775821
``ETHTOOL_SRINGPARAM`` ``ETHTOOL_MSG_RINGS_SET``

‎include/uapi/linux/ethtool_netlink.h‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ enum {
3232
ETHTOOL_MSG_RINGS_SET,
3333
ETHTOOL_MSG_CHANNELS_GET,
3434
ETHTOOL_MSG_CHANNELS_SET,
35+
ETHTOOL_MSG_COALESCE_GET,
3536

3637
/* add new constants above here */
3738
__ETHTOOL_MSG_USER_CNT,
@@ -60,6 +61,7 @@ enum {
6061
ETHTOOL_MSG_RINGS_NTF,
6162
ETHTOOL_MSG_CHANNELS_GET_REPLY,
6263
ETHTOOL_MSG_CHANNELS_NTF,
64+
ETHTOOL_MSG_COALESCE_GET_REPLY,
6365

6466
/* add new constants above here */
6567
__ETHTOOL_MSG_KERNEL_CNT,
@@ -310,6 +312,39 @@ enum {
310312
ETHTOOL_A_CHANNELS_MAX = (__ETHTOOL_A_CHANNELS_CNT - 1)
311313
};
312314

315+
/* COALESCE */
316+
317+
enum {
318+
ETHTOOL_A_COALESCE_UNSPEC,
319+
ETHTOOL_A_COALESCE_HEADER, /* nest - _A_HEADER_* */
320+
ETHTOOL_A_COALESCE_RX_USECS, /* u32 */
321+
ETHTOOL_A_COALESCE_RX_MAX_FRAMES, /* u32 */
322+
ETHTOOL_A_COALESCE_RX_USECS_IRQ, /* u32 */
323+
ETHTOOL_A_COALESCE_RX_MAX_FRAMES_IRQ, /* u32 */
324+
ETHTOOL_A_COALESCE_TX_USECS, /* u32 */
325+
ETHTOOL_A_COALESCE_TX_MAX_FRAMES, /* u32 */
326+
ETHTOOL_A_COALESCE_TX_USECS_IRQ, /* u32 */
327+
ETHTOOL_A_COALESCE_TX_MAX_FRAMES_IRQ, /* u32 */
328+
ETHTOOL_A_COALESCE_STATS_BLOCK_USECS, /* u32 */
329+
ETHTOOL_A_COALESCE_USE_ADAPTIVE_RX, /* u8 */
330+
ETHTOOL_A_COALESCE_USE_ADAPTIVE_TX, /* u8 */
331+
ETHTOOL_A_COALESCE_PKT_RATE_LOW, /* u32 */
332+
ETHTOOL_A_COALESCE_RX_USECS_LOW, /* u32 */
333+
ETHTOOL_A_COALESCE_RX_MAX_FRAMES_LOW, /* u32 */
334+
ETHTOOL_A_COALESCE_TX_USECS_LOW, /* u32 */
335+
ETHTOOL_A_COALESCE_TX_MAX_FRAMES_LOW, /* u32 */
336+
ETHTOOL_A_COALESCE_PKT_RATE_HIGH, /* u32 */
337+
ETHTOOL_A_COALESCE_RX_USECS_HIGH, /* u32 */
338+
ETHTOOL_A_COALESCE_RX_MAX_FRAMES_HIGH, /* u32 */
339+
ETHTOOL_A_COALESCE_TX_USECS_HIGH, /* u32 */
340+
ETHTOOL_A_COALESCE_TX_MAX_FRAMES_HIGH, /* u32 */
341+
ETHTOOL_A_COALESCE_RATE_SAMPLE_INTERVAL, /* u32 */
342+
343+
/* add new constants above here */
344+
__ETHTOOL_A_COALESCE_CNT,
345+
ETHTOOL_A_COALESCE_MAX = (__ETHTOOL_A_COALESCE_CNT - 1)
346+
};
347+
313348
/* generic netlink info */
314349
#define ETHTOOL_GENL_NAME "ethtool"
315350
#define ETHTOOL_GENL_VERSION 1

‎net/ethtool/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ obj-$(CONFIG_ETHTOOL_NETLINK) += ethtool_nl.o
66

77
ethtool_nl-y := netlink.o bitset.o strset.o linkinfo.o linkmodes.o \
88
linkstate.o debug.o wol.o features.o privflags.o rings.o \
9-
channels.o
9+
channels.o coalesce.o

‎net/ethtool/coalesce.c‎

Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
3+
#include "netlink.h"
4+
#include "common.h"
5+
6+
struct coalesce_req_info {
7+
struct ethnl_req_info base;
8+
};
9+
10+
struct coalesce_reply_data {
11+
struct ethnl_reply_data base;
12+
struct ethtool_coalesce coalesce;
13+
u32 supported_params;
14+
};
15+
16+
#define COALESCE_REPDATA(__reply_base) \
17+
container_of(__reply_base, struct coalesce_reply_data, base)
18+
19+
#define __SUPPORTED_OFFSET ETHTOOL_A_COALESCE_RX_USECS
20+
static u32 attr_to_mask(unsigned int attr_type)
21+
{
22+
return BIT(attr_type - __SUPPORTED_OFFSET);
23+
}
24+
25+
/* build time check that indices in ethtool_ops::supported_coalesce_params
26+
* match corresponding attribute types with an offset
27+
*/
28+
#define __CHECK_SUPPORTED_OFFSET(x) \
29+
static_assert((ETHTOOL_ ## x) == \
30+
BIT((ETHTOOL_A_ ## x) - __SUPPORTED_OFFSET))
31+
__CHECK_SUPPORTED_OFFSET(COALESCE_RX_USECS);
32+
__CHECK_SUPPORTED_OFFSET(COALESCE_RX_MAX_FRAMES);
33+
__CHECK_SUPPORTED_OFFSET(COALESCE_RX_USECS_IRQ);
34+
__CHECK_SUPPORTED_OFFSET(COALESCE_RX_MAX_FRAMES_IRQ);
35+
__CHECK_SUPPORTED_OFFSET(COALESCE_TX_USECS);
36+
__CHECK_SUPPORTED_OFFSET(COALESCE_TX_MAX_FRAMES);
37+
__CHECK_SUPPORTED_OFFSET(COALESCE_TX_USECS_IRQ);
38+
__CHECK_SUPPORTED_OFFSET(COALESCE_TX_MAX_FRAMES_IRQ);
39+
__CHECK_SUPPORTED_OFFSET(COALESCE_STATS_BLOCK_USECS);
40+
__CHECK_SUPPORTED_OFFSET(COALESCE_USE_ADAPTIVE_RX);
41+
__CHECK_SUPPORTED_OFFSET(COALESCE_USE_ADAPTIVE_TX);
42+
__CHECK_SUPPORTED_OFFSET(COALESCE_PKT_RATE_LOW);
43+
__CHECK_SUPPORTED_OFFSET(COALESCE_RX_USECS_LOW);
44+
__CHECK_SUPPORTED_OFFSET(COALESCE_RX_MAX_FRAMES_LOW);
45+
__CHECK_SUPPORTED_OFFSET(COALESCE_TX_USECS_LOW);
46+
__CHECK_SUPPORTED_OFFSET(COALESCE_TX_MAX_FRAMES_LOW);
47+
__CHECK_SUPPORTED_OFFSET(COALESCE_PKT_RATE_HIGH);
48+
__CHECK_SUPPORTED_OFFSET(COALESCE_RX_USECS_HIGH);
49+
__CHECK_SUPPORTED_OFFSET(COALESCE_RX_MAX_FRAMES_HIGH);
50+
__CHECK_SUPPORTED_OFFSET(COALESCE_TX_USECS_HIGH);
51+
__CHECK_SUPPORTED_OFFSET(COALESCE_TX_MAX_FRAMES_HIGH);
52+
__CHECK_SUPPORTED_OFFSET(COALESCE_RATE_SAMPLE_INTERVAL);
53+
54+
static const struct nla_policy
55+
coalesce_get_policy[ETHTOOL_A_COALESCE_MAX + 1] = {
56+
[ETHTOOL_A_COALESCE_UNSPEC] = { .type = NLA_REJECT },
57+
[ETHTOOL_A_COALESCE_HEADER] = { .type = NLA_NESTED },
58+
[ETHTOOL_A_COALESCE_RX_USECS] = { .type = NLA_REJECT },
59+
[ETHTOOL_A_COALESCE_RX_MAX_FRAMES] = { .type = NLA_REJECT },
60+
[ETHTOOL_A_COALESCE_RX_USECS_IRQ] = { .type = NLA_REJECT },
61+
[ETHTOOL_A_COALESCE_RX_MAX_FRAMES_IRQ] = { .type = NLA_REJECT },
62+
[ETHTOOL_A_COALESCE_TX_USECS] = { .type = NLA_REJECT },
63+
[ETHTOOL_A_COALESCE_TX_MAX_FRAMES] = { .type = NLA_REJECT },
64+
[ETHTOOL_A_COALESCE_TX_USECS_IRQ] = { .type = NLA_REJECT },
65+
[ETHTOOL_A_COALESCE_TX_MAX_FRAMES_IRQ] = { .type = NLA_REJECT },
66+
[ETHTOOL_A_COALESCE_STATS_BLOCK_USECS] = { .type = NLA_REJECT },
67+
[ETHTOOL_A_COALESCE_USE_ADAPTIVE_RX] = { .type = NLA_REJECT },
68+
[ETHTOOL_A_COALESCE_USE_ADAPTIVE_TX] = { .type = NLA_REJECT },
69+
[ETHTOOL_A_COALESCE_PKT_RATE_LOW] = { .type = NLA_REJECT },
70+
[ETHTOOL_A_COALESCE_RX_USECS_LOW] = { .type = NLA_REJECT },
71+
[ETHTOOL_A_COALESCE_RX_MAX_FRAMES_LOW] = { .type = NLA_REJECT },
72+
[ETHTOOL_A_COALESCE_TX_USECS_LOW] = { .type = NLA_REJECT },
73+
[ETHTOOL_A_COALESCE_TX_MAX_FRAMES_LOW] = { .type = NLA_REJECT },
74+
[ETHTOOL_A_COALESCE_PKT_RATE_HIGH] = { .type = NLA_REJECT },
75+
[ETHTOOL_A_COALESCE_RX_USECS_HIGH] = { .type = NLA_REJECT },
76+
[ETHTOOL_A_COALESCE_RX_MAX_FRAMES_HIGH] = { .type = NLA_REJECT },
77+
[ETHTOOL_A_COALESCE_TX_USECS_HIGH] = { .type = NLA_REJECT },
78+
[ETHTOOL_A_COALESCE_TX_MAX_FRAMES_HIGH] = { .type = NLA_REJECT },
79+
[ETHTOOL_A_COALESCE_RATE_SAMPLE_INTERVAL] = { .type = NLA_REJECT },
80+
};
81+
82+
static int coalesce_prepare_data(const struct ethnl_req_info *req_base,
83+
struct ethnl_reply_data *reply_base,
84+
struct genl_info *info)
85+
{
86+
struct coalesce_reply_data *data = COALESCE_REPDATA(reply_base);
87+
struct net_device *dev = reply_base->dev;
88+
int ret;
89+
90+
if (!dev->ethtool_ops->get_coalesce)
91+
return -EOPNOTSUPP;
92+
data->supported_params = dev->ethtool_ops->supported_coalesce_params;
93+
ret = ethnl_ops_begin(dev);
94+
if (ret < 0)
95+
return ret;
96+
ret = dev->ethtool_ops->get_coalesce(dev, &data->coalesce);
97+
ethnl_ops_complete(dev);
98+
99+
return ret;
100+
}
101+
102+
static int coalesce_reply_size(const struct ethnl_req_info *req_base,
103+
const struct ethnl_reply_data *reply_base)
104+
{
105+
return nla_total_size(sizeof(u32)) + /* _RX_USECS */
106+
nla_total_size(sizeof(u32)) + /* _RX_MAX_FRAMES */
107+
nla_total_size(sizeof(u32)) + /* _RX_USECS_IRQ */
108+
nla_total_size(sizeof(u32)) + /* _RX_MAX_FRAMES_IRQ */
109+
nla_total_size(sizeof(u32)) + /* _TX_USECS */
110+
nla_total_size(sizeof(u32)) + /* _TX_MAX_FRAMES */
111+
nla_total_size(sizeof(u32)) + /* _TX_USECS_IRQ */
112+
nla_total_size(sizeof(u32)) + /* _TX_MAX_FRAMES_IRQ */
113+
nla_total_size(sizeof(u32)) + /* _STATS_BLOCK_USECS */
114+
nla_total_size(sizeof(u8)) + /* _USE_ADAPTIVE_RX */
115+
nla_total_size(sizeof(u8)) + /* _USE_ADAPTIVE_TX */
116+
nla_total_size(sizeof(u32)) + /* _PKT_RATE_LOW */
117+
nla_total_size(sizeof(u32)) + /* _RX_USECS_LOW */
118+
nla_total_size(sizeof(u32)) + /* _RX_MAX_FRAMES_LOW */
119+
nla_total_size(sizeof(u32)) + /* _TX_USECS_LOW */
120+
nla_total_size(sizeof(u32)) + /* _TX_MAX_FRAMES_LOW */
121+
nla_total_size(sizeof(u32)) + /* _PKT_RATE_HIGH */
122+
nla_total_size(sizeof(u32)) + /* _RX_USECS_HIGH */
123+
nla_total_size(sizeof(u32)) + /* _RX_MAX_FRAMES_HIGH */
124+
nla_total_size(sizeof(u32)) + /* _TX_USECS_HIGH */
125+
nla_total_size(sizeof(u32)) + /* _TX_MAX_FRAMES_HIGH */
126+
nla_total_size(sizeof(u32)); /* _RATE_SAMPLE_INTERVAL */
127+
}
128+
129+
static bool coalesce_put_u32(struct sk_buff *skb, u16 attr_type, u32 val,
130+
u32 supported_params)
131+
{
132+
if (!val && !(supported_params & attr_to_mask(attr_type)))
133+
return false;
134+
return nla_put_u32(skb, attr_type, val);
135+
}
136+
137+
static bool coalesce_put_bool(struct sk_buff *skb, u16 attr_type, u32 val,
138+
u32 supported_params)
139+
{
140+
if (!val && !(supported_params & attr_to_mask(attr_type)))
141+
return false;
142+
return nla_put_u8(skb, attr_type, !!val);
143+
}
144+
145+
static int coalesce_fill_reply(struct sk_buff *skb,
146+
const struct ethnl_req_info *req_base,
147+
const struct ethnl_reply_data *reply_base)
148+
{
149+
const struct coalesce_reply_data *data = COALESCE_REPDATA(reply_base);
150+
const struct ethtool_coalesce *coal = &data->coalesce;
151+
u32 supported = data->supported_params;
152+
153+
if (coalesce_put_u32(skb, ETHTOOL_A_COALESCE_RX_USECS,
154+
coal->rx_coalesce_usecs, supported) ||
155+
coalesce_put_u32(skb, ETHTOOL_A_COALESCE_RX_MAX_FRAMES,
156+
coal->rx_max_coalesced_frames, supported) ||
157+
coalesce_put_u32(skb, ETHTOOL_A_COALESCE_RX_USECS_IRQ,
158+
coal->rx_coalesce_usecs_irq, supported) ||
159+
coalesce_put_u32(skb, ETHTOOL_A_COALESCE_RX_MAX_FRAMES_IRQ,
160+
coal->rx_max_coalesced_frames_irq, supported) ||
161+
coalesce_put_u32(skb, ETHTOOL_A_COALESCE_TX_USECS,
162+
coal->tx_coalesce_usecs, supported) ||
163+
coalesce_put_u32(skb, ETHTOOL_A_COALESCE_TX_MAX_FRAMES,
164+
coal->tx_max_coalesced_frames, supported) ||
165+
coalesce_put_u32(skb, ETHTOOL_A_COALESCE_TX_USECS_IRQ,
166+
coal->tx_coalesce_usecs_irq, supported) ||
167+
coalesce_put_u32(skb, ETHTOOL_A_COALESCE_TX_MAX_FRAMES_IRQ,
168+
coal->tx_max_coalesced_frames_irq, supported) ||
169+
coalesce_put_u32(skb, ETHTOOL_A_COALESCE_STATS_BLOCK_USECS,
170+
coal->stats_block_coalesce_usecs, supported) ||
171+
coalesce_put_bool(skb, ETHTOOL_A_COALESCE_USE_ADAPTIVE_RX,
172+
coal->use_adaptive_rx_coalesce, supported) ||
173+
coalesce_put_bool(skb, ETHTOOL_A_COALESCE_USE_ADAPTIVE_TX,
174+
coal->use_adaptive_tx_coalesce, supported) ||
175+
coalesce_put_u32(skb, ETHTOOL_A_COALESCE_PKT_RATE_LOW,
176+
coal->pkt_rate_low, supported) ||
177+
coalesce_put_u32(skb, ETHTOOL_A_COALESCE_RX_USECS_LOW,
178+
coal->rx_coalesce_usecs_low, supported) ||
179+
coalesce_put_u32(skb, ETHTOOL_A_COALESCE_RX_MAX_FRAMES_LOW,
180+
coal->rx_max_coalesced_frames_low, supported) ||
181+
coalesce_put_u32(skb, ETHTOOL_A_COALESCE_TX_USECS_LOW,
182+
coal->tx_coalesce_usecs_low, supported) ||
183+
coalesce_put_u32(skb, ETHTOOL_A_COALESCE_TX_MAX_FRAMES_LOW,
184+
coal->tx_max_coalesced_frames_low, supported) ||
185+
coalesce_put_u32(skb, ETHTOOL_A_COALESCE_PKT_RATE_HIGH,
186+
coal->pkt_rate_high, supported) ||
187+
coalesce_put_u32(skb, ETHTOOL_A_COALESCE_RX_USECS_HIGH,
188+
coal->rx_coalesce_usecs_high, supported) ||
189+
coalesce_put_u32(skb, ETHTOOL_A_COALESCE_RX_MAX_FRAMES_HIGH,
190+
coal->rx_max_coalesced_frames_high, supported) ||
191+
coalesce_put_u32(skb, ETHTOOL_A_COALESCE_TX_USECS_HIGH,
192+
coal->tx_coalesce_usecs_high, supported) ||
193+
coalesce_put_u32(skb, ETHTOOL_A_COALESCE_TX_MAX_FRAMES_HIGH,
194+
coal->tx_max_coalesced_frames_high, supported) ||
195+
coalesce_put_u32(skb, ETHTOOL_A_COALESCE_RATE_SAMPLE_INTERVAL,
196+
coal->rate_sample_interval, supported))
197+
return -EMSGSIZE;
198+
199+
return 0;
200+
}
201+
202+
const struct ethnl_request_ops ethnl_coalesce_request_ops = {
203+
.request_cmd = ETHTOOL_MSG_COALESCE_GET,
204+
.reply_cmd = ETHTOOL_MSG_COALESCE_GET_REPLY,
205+
.hdr_attr = ETHTOOL_A_COALESCE_HEADER,
206+
.max_attr = ETHTOOL_A_COALESCE_MAX,
207+
.req_info_size = sizeof(struct coalesce_req_info),
208+
.reply_data_size = sizeof(struct coalesce_reply_data),
209+
.request_policy = coalesce_get_policy,
210+
211+
.prepare_data = coalesce_prepare_data,
212+
.reply_size = coalesce_reply_size,
213+
.fill_reply = coalesce_fill_reply,
214+
};

‎net/ethtool/netlink.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ ethnl_default_requests[__ETHTOOL_MSG_USER_CNT] = {
227227
[ETHTOOL_MSG_PRIVFLAGS_GET] = &ethnl_privflags_request_ops,
228228
[ETHTOOL_MSG_RINGS_GET] = &ethnl_rings_request_ops,
229229
[ETHTOOL_MSG_CHANNELS_GET] = &ethnl_channels_request_ops,
230+
[ETHTOOL_MSG_COALESCE_GET] = &ethnl_coalesce_request_ops,
230231
};
231232

232233
static struct ethnl_dump_ctx *ethnl_dump_context(struct netlink_callback *cb)
@@ -786,6 +787,13 @@ static const struct genl_ops ethtool_genl_ops[] = {
786787
.flags = GENL_UNS_ADMIN_PERM,
787788
.doit = ethnl_set_channels,
788789
},
790+
{
791+
.cmd = ETHTOOL_MSG_COALESCE_GET,
792+
.doit = ethnl_default_doit,
793+
.start = ethnl_default_start,
794+
.dumpit = ethnl_default_dumpit,
795+
.done = ethnl_default_done,
796+
},
789797
};
790798

791799
static const struct genl_multicast_group ethtool_nl_mcgrps[] = {

‎net/ethtool/netlink.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ extern const struct ethnl_request_ops ethnl_features_request_ops;
341341
extern const struct ethnl_request_ops ethnl_privflags_request_ops;
342342
extern const struct ethnl_request_ops ethnl_rings_request_ops;
343343
extern const struct ethnl_request_ops ethnl_channels_request_ops;
344+
extern const struct ethnl_request_ops ethnl_coalesce_request_ops;
344345

345346
int ethnl_set_linkinfo(struct sk_buff *skb, struct genl_info *info);
346347
int ethnl_set_linkmodes(struct sk_buff *skb, struct genl_info *info);

0 commit comments

Comments
 (0)