Skip to content

Commit 5b4e9a7

Browse files
emuslndavem330
authored andcommitted
net: ethtool: extend ringparam set/get APIs for rx_push
Similar to what was done for TX_PUSH, add an RX_PUSH concept to the ethtool interfaces. Signed-off-by: Shannon Nelson <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 896de44 commit 5b4e9a7

File tree

5 files changed

+25
-5
lines changed

5 files changed

+25
-5
lines changed

Documentation/networking/ethtool-netlink.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,7 @@ Kernel response contents:
874874
``ETHTOOL_A_RINGS_TCP_DATA_SPLIT`` u8 TCP header / data split
875875
``ETHTOOL_A_RINGS_CQE_SIZE`` u32 Size of TX/RX CQE
876876
``ETHTOOL_A_RINGS_TX_PUSH`` u8 flag of TX Push mode
877+
``ETHTOOL_A_RINGS_RX_PUSH`` u8 flag of RX Push mode
877878
==================================== ====== ===========================
878879

879880
``ETHTOOL_A_RINGS_TCP_DATA_SPLIT`` indicates whether the device is usable with
@@ -883,8 +884,8 @@ separate buffers. The device configuration must make it possible to receive
883884
full memory pages of data, for example because MTU is high enough or through
884885
HW-GRO.
885886

886-
``ETHTOOL_A_RINGS_TX_PUSH`` flag is used to enable descriptor fast
887-
path to send packets. In ordinary path, driver fills descriptors in DRAM and
887+
``ETHTOOL_A_RINGS_[RX|TX]_PUSH`` flag is used to enable descriptor fast
888+
path to send or receive packets. In ordinary path, driver fills descriptors in DRAM and
888889
notifies NIC hardware. In fast path, driver pushes descriptors to the device
889890
through MMIO writes, thus reducing the latency. However, enabling this feature
890891
may increase the CPU cost. Drivers may enforce additional per-packet
@@ -906,6 +907,7 @@ Request contents:
906907
``ETHTOOL_A_RINGS_RX_BUF_LEN`` u32 size of buffers on the ring
907908
``ETHTOOL_A_RINGS_CQE_SIZE`` u32 Size of TX/RX CQE
908909
``ETHTOOL_A_RINGS_TX_PUSH`` u8 flag of TX Push mode
910+
``ETHTOOL_A_RINGS_RX_PUSH`` u8 flag of RX Push mode
909911
==================================== ====== ===========================
910912

911913
Kernel checks that requested ring sizes do not exceed limits reported by

include/linux/ethtool.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,14 @@ enum {
7373
* @rx_buf_len: Current length of buffers on the rx ring.
7474
* @tcp_data_split: Scatter packet headers and data to separate buffers
7575
* @tx_push: The flag of tx push mode
76+
* @rx_push: The flag of rx push mode
7677
* @cqe_size: Size of TX/RX completion queue event
7778
*/
7879
struct kernel_ethtool_ringparam {
7980
u32 rx_buf_len;
8081
u8 tcp_data_split;
8182
u8 tx_push;
83+
u8 rx_push;
8284
u32 cqe_size;
8385
};
8486

@@ -87,11 +89,13 @@ struct kernel_ethtool_ringparam {
8789
* @ETHTOOL_RING_USE_RX_BUF_LEN: capture for setting rx_buf_len
8890
* @ETHTOOL_RING_USE_CQE_SIZE: capture for setting cqe_size
8991
* @ETHTOOL_RING_USE_TX_PUSH: capture for setting tx_push
92+
* @ETHTOOL_RING_USE_RX_PUSH: capture for setting rx_push
9093
*/
9194
enum ethtool_supported_ring_param {
9295
ETHTOOL_RING_USE_RX_BUF_LEN = BIT(0),
9396
ETHTOOL_RING_USE_CQE_SIZE = BIT(1),
9497
ETHTOOL_RING_USE_TX_PUSH = BIT(2),
98+
ETHTOOL_RING_USE_RX_PUSH = BIT(3),
9599
};
96100

97101
#define __ETH_RSS_HASH_BIT(bit) ((u32)1 << (bit))

include/uapi/linux/ethtool_netlink.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ enum {
356356
ETHTOOL_A_RINGS_TCP_DATA_SPLIT, /* u8 */
357357
ETHTOOL_A_RINGS_CQE_SIZE, /* u32 */
358358
ETHTOOL_A_RINGS_TX_PUSH, /* u8 */
359+
ETHTOOL_A_RINGS_RX_PUSH, /* u8 */
359360

360361
/* add new constants above here */
361362
__ETHTOOL_A_RINGS_CNT,

net/ethtool/netlink.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ extern const struct nla_policy ethnl_features_set_policy[ETHTOOL_A_FEATURES_WANT
413413
extern const struct nla_policy ethnl_privflags_get_policy[ETHTOOL_A_PRIVFLAGS_HEADER + 1];
414414
extern const struct nla_policy ethnl_privflags_set_policy[ETHTOOL_A_PRIVFLAGS_FLAGS + 1];
415415
extern const struct nla_policy ethnl_rings_get_policy[ETHTOOL_A_RINGS_HEADER + 1];
416-
extern const struct nla_policy ethnl_rings_set_policy[ETHTOOL_A_RINGS_TX_PUSH + 1];
416+
extern const struct nla_policy ethnl_rings_set_policy[ETHTOOL_A_RINGS_RX_PUSH + 1];
417417
extern const struct nla_policy ethnl_channels_get_policy[ETHTOOL_A_CHANNELS_HEADER + 1];
418418
extern const struct nla_policy ethnl_channels_set_policy[ETHTOOL_A_CHANNELS_COMBINED_COUNT + 1];
419419
extern const struct nla_policy ethnl_coalesce_get_policy[ETHTOOL_A_COALESCE_HEADER + 1];

net/ethtool/rings.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ static int rings_reply_size(const struct ethnl_req_info *req_base,
5656
nla_total_size(sizeof(u32)) + /* _RINGS_RX_BUF_LEN */
5757
nla_total_size(sizeof(u8)) + /* _RINGS_TCP_DATA_SPLIT */
5858
nla_total_size(sizeof(u32) + /* _RINGS_CQE_SIZE */
59-
nla_total_size(sizeof(u8))); /* _RINGS_TX_PUSH */
59+
nla_total_size(sizeof(u8)) + /* _RINGS_TX_PUSH */
60+
nla_total_size(sizeof(u8))); /* _RINGS_RX_PUSH */
6061
}
6162

6263
static int rings_fill_reply(struct sk_buff *skb,
@@ -96,7 +97,8 @@ static int rings_fill_reply(struct sk_buff *skb,
9697
kr->tcp_data_split))) ||
9798
(kr->cqe_size &&
9899
(nla_put_u32(skb, ETHTOOL_A_RINGS_CQE_SIZE, kr->cqe_size))) ||
99-
nla_put_u8(skb, ETHTOOL_A_RINGS_TX_PUSH, !!kr->tx_push))
100+
nla_put_u8(skb, ETHTOOL_A_RINGS_TX_PUSH, !!kr->tx_push) ||
101+
nla_put_u8(skb, ETHTOOL_A_RINGS_RX_PUSH, !!kr->rx_push))
100102
return -EMSGSIZE;
101103

102104
return 0;
@@ -114,6 +116,7 @@ const struct nla_policy ethnl_rings_set_policy[] = {
114116
[ETHTOOL_A_RINGS_RX_BUF_LEN] = NLA_POLICY_MIN(NLA_U32, 1),
115117
[ETHTOOL_A_RINGS_CQE_SIZE] = NLA_POLICY_MIN(NLA_U32, 1),
116118
[ETHTOOL_A_RINGS_TX_PUSH] = NLA_POLICY_MAX(NLA_U8, 1),
119+
[ETHTOOL_A_RINGS_RX_PUSH] = NLA_POLICY_MAX(NLA_U8, 1),
117120
};
118121

119122
static int
@@ -147,6 +150,14 @@ ethnl_set_rings_validate(struct ethnl_req_info *req_info,
147150
return -EOPNOTSUPP;
148151
}
149152

153+
if (tb[ETHTOOL_A_RINGS_RX_PUSH] &&
154+
!(ops->supported_ring_params & ETHTOOL_RING_USE_RX_PUSH)) {
155+
NL_SET_ERR_MSG_ATTR(info->extack,
156+
tb[ETHTOOL_A_RINGS_RX_PUSH],
157+
"setting rx push not supported");
158+
return -EOPNOTSUPP;
159+
}
160+
150161
return ops->get_ringparam && ops->set_ringparam ? 1 : -EOPNOTSUPP;
151162
}
152163

@@ -176,6 +187,8 @@ ethnl_set_rings(struct ethnl_req_info *req_info, struct genl_info *info)
176187
tb[ETHTOOL_A_RINGS_CQE_SIZE], &mod);
177188
ethnl_update_u8(&kernel_ringparam.tx_push,
178189
tb[ETHTOOL_A_RINGS_TX_PUSH], &mod);
190+
ethnl_update_u8(&kernel_ringparam.rx_push,
191+
tb[ETHTOOL_A_RINGS_RX_PUSH], &mod);
179192
if (!mod)
180193
return 0;
181194

0 commit comments

Comments
 (0)