Skip to content

Commit eec8359

Browse files
TaeheeYookuba-moo
authored andcommitted
net: ethtool: add support for configuring hds-thresh
The hds-thresh option configures the threshold value of the header-data-split. If a received packet size is larger than this threshold value, a packet will be split into header and payload. The header indicates TCP and UDP header, but it depends on driver spec. The bnxt_en driver supports HDS(Header-Data-Split) configuration at FW level, affecting TCP and UDP too. So, If hds-thresh is set, it affects UDP and TCP packets. Example: # ethtool -G <interface name> hds-thresh <value> # ethtool -G enp14s0f0np0 tcp-data-split on hds-thresh 256 # ethtool -g enp14s0f0np0 Ring parameters for enp14s0f0np0: Pre-set maximums: ... HDS thresh: 1023 Current hardware settings: ... TCP data split: on HDS thresh: 256 The default/min/max values are not defined in the ethtool so the drivers should define themself. The 0 value means that all TCP/UDP packets' header and payload will be split. Tested-by: Stanislav Fomichev <[email protected]> Signed-off-by: Taehee Yoo <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 197258f commit eec8359

File tree

6 files changed

+55
-4
lines changed

6 files changed

+55
-4
lines changed

Documentation/netlink/specs/ethtool.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,12 @@ attribute-sets:
332332
-
333333
name: tx-push-buf-len-max
334334
type: u32
335+
-
336+
name: hds-thresh
337+
type: u32
338+
-
339+
name: hds-thresh-max
340+
type: u32
335341

336342
-
337343
name: mm-stat
@@ -1777,6 +1783,8 @@ operations:
17771783
- rx-push
17781784
- tx-push-buf-len
17791785
- tx-push-buf-len-max
1786+
- hds-thresh
1787+
- hds-thresh-max
17801788
dump: *ring-get-op
17811789
-
17821790
name: rings-set

Documentation/networking/ethtool-netlink.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,10 @@ Kernel response contents:
899899
``ETHTOOL_A_RINGS_RX_PUSH`` u8 flag of RX Push mode
900900
``ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN`` u32 size of TX push buffer
901901
``ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN_MAX`` u32 max size of TX push buffer
902+
``ETHTOOL_A_RINGS_HDS_THRESH`` u32 threshold of
903+
header / data split
904+
``ETHTOOL_A_RINGS_HDS_THRESH_MAX`` u32 max threshold of
905+
header / data split
902906
======================================= ====== ===========================
903907

904908
``ETHTOOL_A_RINGS_TCP_DATA_SPLIT`` indicates whether the device is usable with
@@ -941,10 +945,12 @@ Request contents:
941945
``ETHTOOL_A_RINGS_RX_JUMBO`` u32 size of RX jumbo ring
942946
``ETHTOOL_A_RINGS_TX`` u32 size of TX ring
943947
``ETHTOOL_A_RINGS_RX_BUF_LEN`` u32 size of buffers on the ring
948+
``ETHTOOL_A_RINGS_TCP_DATA_SPLIT`` u8 TCP header / data split
944949
``ETHTOOL_A_RINGS_CQE_SIZE`` u32 Size of TX/RX CQE
945950
``ETHTOOL_A_RINGS_TX_PUSH`` u8 flag of TX Push mode
946951
``ETHTOOL_A_RINGS_RX_PUSH`` u8 flag of RX Push mode
947952
``ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN`` u32 size of TX push buffer
953+
``ETHTOOL_A_RINGS_HDS_THRESH`` u32 threshold of header / data split
948954
==================================== ====== ===========================
949955

950956
Kernel checks that requested ring sizes do not exceed limits reported by
@@ -961,6 +967,10 @@ A bigger CQE can have more receive buffer pointers, and in turn the NIC can
961967
transfer a bigger frame from wire. Based on the NIC hardware, the overall
962968
completion queue size can be adjusted in the driver if CQE size is modified.
963969

970+
``ETHTOOL_A_RINGS_HDS_THRESH`` specifies the threshold value of
971+
header / data split feature. If a received packet size is larger than this
972+
threshold value, header and data will be split.
973+
964974
CHANNELS_GET
965975
============
966976

include/linux/ethtool.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ enum {
7878
* @cqe_size: Size of TX/RX completion queue event
7979
* @tx_push_buf_len: Size of TX push buffer
8080
* @tx_push_buf_max_len: Maximum allowed size of TX push buffer
81+
* @hds_thresh: Packet size threshold for header data split (HDS)
82+
* @hds_thresh_max: Maximum supported setting for @hds_threshold
83+
*
8184
*/
8285
struct kernel_ethtool_ringparam {
8386
u32 rx_buf_len;
@@ -87,6 +90,8 @@ struct kernel_ethtool_ringparam {
8790
u32 cqe_size;
8891
u32 tx_push_buf_len;
8992
u32 tx_push_buf_max_len;
93+
u32 hds_thresh;
94+
u32 hds_thresh_max;
9095
};
9196

9297
/**
@@ -97,6 +102,7 @@ struct kernel_ethtool_ringparam {
97102
* @ETHTOOL_RING_USE_RX_PUSH: capture for setting rx_push
98103
* @ETHTOOL_RING_USE_TX_PUSH_BUF_LEN: capture for setting tx_push_buf_len
99104
* @ETHTOOL_RING_USE_TCP_DATA_SPLIT: capture for setting tcp_data_split
105+
* @ETHTOOL_RING_USE_HDS_THRS: capture for setting header-data-split-thresh
100106
*/
101107
enum ethtool_supported_ring_param {
102108
ETHTOOL_RING_USE_RX_BUF_LEN = BIT(0),
@@ -105,6 +111,7 @@ enum ethtool_supported_ring_param {
105111
ETHTOOL_RING_USE_RX_PUSH = BIT(3),
106112
ETHTOOL_RING_USE_TX_PUSH_BUF_LEN = BIT(4),
107113
ETHTOOL_RING_USE_TCP_DATA_SPLIT = BIT(5),
114+
ETHTOOL_RING_USE_HDS_THRS = BIT(6),
108115
};
109116

110117
#define __ETH_RSS_HASH_BIT(bit) ((u32)1 << (bit))
@@ -1157,13 +1164,15 @@ int ethtool_virtdev_set_link_ksettings(struct net_device *dev,
11571164
* @rss_ctx: XArray of custom RSS contexts
11581165
* @rss_lock: Protects entries in @rss_ctx. May be taken from
11591166
* within RTNL.
1167+
* @hds_thresh: HDS Threshold value.
11601168
* @hds_config: HDS value from userspace.
11611169
* @wol_enabled: Wake-on-LAN is enabled
11621170
* @module_fw_flash_in_progress: Module firmware flashing is in progress.
11631171
*/
11641172
struct ethtool_netdev_state {
11651173
struct xarray rss_ctx;
11661174
struct mutex rss_lock;
1175+
u32 hds_thresh;
11671176
u8 hds_config;
11681177
unsigned wol_enabled:1;
11691178
unsigned module_fw_flash_in_progress:1;

include/uapi/linux/ethtool_netlink_generated.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ enum {
155155
ETHTOOL_A_RINGS_RX_PUSH,
156156
ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN,
157157
ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN_MAX,
158+
ETHTOOL_A_RINGS_HDS_THRESH,
159+
ETHTOOL_A_RINGS_HDS_THRESH_MAX,
158160

159161
__ETHTOOL_A_RINGS_CNT,
160162
ETHTOOL_A_RINGS_MAX = (__ETHTOOL_A_RINGS_CNT - 1)

net/ethtool/netlink.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ extern const struct nla_policy ethnl_features_set_policy[ETHTOOL_A_FEATURES_WANT
456456
extern const struct nla_policy ethnl_privflags_get_policy[ETHTOOL_A_PRIVFLAGS_HEADER + 1];
457457
extern const struct nla_policy ethnl_privflags_set_policy[ETHTOOL_A_PRIVFLAGS_FLAGS + 1];
458458
extern const struct nla_policy ethnl_rings_get_policy[ETHTOOL_A_RINGS_HEADER + 1];
459-
extern const struct nla_policy ethnl_rings_set_policy[ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN_MAX + 1];
459+
extern const struct nla_policy ethnl_rings_set_policy[ETHTOOL_A_RINGS_HDS_THRESH_MAX + 1];
460460
extern const struct nla_policy ethnl_channels_get_policy[ETHTOOL_A_CHANNELS_HEADER + 1];
461461
extern const struct nla_policy ethnl_channels_set_policy[ETHTOOL_A_CHANNELS_COMBINED_COUNT + 1];
462462
extern const struct nla_policy ethnl_coalesce_get_policy[ETHTOOL_A_COALESCE_HEADER + 1];

net/ethtool/rings.c

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ static int rings_reply_size(const struct ethnl_req_info *req_base,
6161
nla_total_size(sizeof(u8)) + /* _RINGS_TX_PUSH */
6262
nla_total_size(sizeof(u8))) + /* _RINGS_RX_PUSH */
6363
nla_total_size(sizeof(u32)) + /* _RINGS_TX_PUSH_BUF_LEN */
64-
nla_total_size(sizeof(u32)); /* _RINGS_TX_PUSH_BUF_LEN_MAX */
64+
nla_total_size(sizeof(u32)) + /* _RINGS_TX_PUSH_BUF_LEN_MAX */
65+
nla_total_size(sizeof(u32)) + /* _RINGS_HDS_THRESH */
66+
nla_total_size(sizeof(u32)); /* _RINGS_HDS_THRESH_MAX*/
6567
}
6668

6769
static int rings_fill_reply(struct sk_buff *skb,
@@ -108,7 +110,12 @@ static int rings_fill_reply(struct sk_buff *skb,
108110
(nla_put_u32(skb, ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN_MAX,
109111
kr->tx_push_buf_max_len) ||
110112
nla_put_u32(skb, ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN,
111-
kr->tx_push_buf_len))))
113+
kr->tx_push_buf_len))) ||
114+
((supported_ring_params & ETHTOOL_RING_USE_HDS_THRS) &&
115+
(nla_put_u32(skb, ETHTOOL_A_RINGS_HDS_THRESH,
116+
kr->hds_thresh) ||
117+
nla_put_u32(skb, ETHTOOL_A_RINGS_HDS_THRESH_MAX,
118+
kr->hds_thresh_max))))
112119
return -EMSGSIZE;
113120

114121
return 0;
@@ -130,6 +137,7 @@ const struct nla_policy ethnl_rings_set_policy[] = {
130137
[ETHTOOL_A_RINGS_TX_PUSH] = NLA_POLICY_MAX(NLA_U8, 1),
131138
[ETHTOOL_A_RINGS_RX_PUSH] = NLA_POLICY_MAX(NLA_U8, 1),
132139
[ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN] = { .type = NLA_U32 },
140+
[ETHTOOL_A_RINGS_HDS_THRESH] = { .type = NLA_U32 },
133141
};
134142

135143
static int
@@ -155,6 +163,14 @@ ethnl_set_rings_validate(struct ethnl_req_info *req_info,
155163
return -EOPNOTSUPP;
156164
}
157165

166+
if (tb[ETHTOOL_A_RINGS_HDS_THRESH] &&
167+
!(ops->supported_ring_params & ETHTOOL_RING_USE_HDS_THRS)) {
168+
NL_SET_ERR_MSG_ATTR(info->extack,
169+
tb[ETHTOOL_A_RINGS_HDS_THRESH],
170+
"setting hds-thresh is not supported");
171+
return -EOPNOTSUPP;
172+
}
173+
158174
if (tb[ETHTOOL_A_RINGS_CQE_SIZE] &&
159175
!(ops->supported_ring_params & ETHTOOL_RING_USE_CQE_SIZE)) {
160176
NL_SET_ERR_MSG_ATTR(info->extack,
@@ -223,6 +239,8 @@ ethnl_set_rings(struct ethnl_req_info *req_info, struct genl_info *info)
223239
tb[ETHTOOL_A_RINGS_RX_PUSH], &mod);
224240
ethnl_update_u32(&kernel_ringparam.tx_push_buf_len,
225241
tb[ETHTOOL_A_RINGS_TX_PUSH_BUF_LEN], &mod);
242+
ethnl_update_u32(&kernel_ringparam.hds_thresh,
243+
tb[ETHTOOL_A_RINGS_HDS_THRESH], &mod);
226244
if (!mod)
227245
return 0;
228246

@@ -243,6 +261,8 @@ ethnl_set_rings(struct ethnl_req_info *req_info, struct genl_info *info)
243261
err_attr = tb[ETHTOOL_A_RINGS_RX_JUMBO];
244262
else if (ringparam.tx_pending > ringparam.tx_max_pending)
245263
err_attr = tb[ETHTOOL_A_RINGS_TX];
264+
else if (kernel_ringparam.hds_thresh > kernel_ringparam.hds_thresh_max)
265+
err_attr = tb[ETHTOOL_A_RINGS_HDS_THRESH];
246266
else
247267
err_attr = NULL;
248268
if (err_attr) {
@@ -261,8 +281,10 @@ ethnl_set_rings(struct ethnl_req_info *req_info, struct genl_info *info)
261281

262282
ret = dev->ethtool_ops->set_ringparam(dev, &ringparam,
263283
&kernel_ringparam, info->extack);
264-
if (!ret)
284+
if (!ret) {
265285
dev->ethtool->hds_config = kernel_ringparam.tcp_data_split;
286+
dev->ethtool->hds_thresh = kernel_ringparam.hds_thresh;
287+
}
266288

267289
return ret < 0 ? ret : 1;
268290
}

0 commit comments

Comments
 (0)