* [RFCv2 PATCH net-next 0/2] net-next: ethool: add support to get/set tx push by ethtool -G/g @ 2022-03-26 8:51 Jie Wang 2022-03-26 8:51 ` [RFCv2 PATCH net-next 1/2] net-next: ethtool: extend ringparam set/get APIs for tx_push Jie Wang 2022-03-26 8:51 ` [RFCv2 PATCH net-next 2/2] net-next: hn3: add tx push support in hns3 ring param process Jie Wang 0 siblings, 2 replies; 6+ messages in thread From: Jie Wang @ 2022-03-26 8:51 UTC (permalink / raw) To: mkubecek, davem, kuba, wangjie125 Cc: netdev, huangguangbin2, lipeng321, shenjian15, moyufeng, linyunsheng, salil.mehta, chenhao288 These two patches add tx push in ring parms and adapt the set and get APIs of ring params The former discussion please see [1]. [1]:https://lore.kernel.org/netdev/20220315032108.57228-1-wangjie125@huawei.com/ ChangeLog: V1->V2 extend tx push param in ringparam, suggested by Jakub Kicinski. Jie Wang (2): net-next: ethtool: extend ringparam set/get APIs for tx_push net-next: hn3: add tx push support in hns3 ring param process .../ethernet/hisilicon/hns3/hns3_ethtool.c | 30 +++++++++++++++++++ include/linux/ethtool.h | 3 ++ include/uapi/linux/ethtool_netlink.h | 1 + net/ethtool/netlink.h | 2 +- net/ethtool/rings.c | 9 ++++-- 5 files changed, 42 insertions(+), 3 deletions(-) -- 2.33.0 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [RFCv2 PATCH net-next 1/2] net-next: ethtool: extend ringparam set/get APIs for tx_push 2022-03-26 8:51 [RFCv2 PATCH net-next 0/2] net-next: ethool: add support to get/set tx push by ethtool -G/g Jie Wang @ 2022-03-26 8:51 ` Jie Wang 2022-03-26 19:50 ` Jakub Kicinski 2022-03-26 8:51 ` [RFCv2 PATCH net-next 2/2] net-next: hn3: add tx push support in hns3 ring param process Jie Wang 1 sibling, 1 reply; 6+ messages in thread From: Jie Wang @ 2022-03-26 8:51 UTC (permalink / raw) To: mkubecek, davem, kuba, wangjie125 Cc: netdev, huangguangbin2, lipeng321, shenjian15, moyufeng, linyunsheng, salil.mehta, chenhao288 Currently tx push is a standard driver feature which controls use of a fast path descriptor push. So this patch extends the ringparam APIs and data structures to support set/get tx push by ethtool -G/g. Signed-off-by: Jie Wang <wangjie125@huawei.com> --- include/linux/ethtool.h | 3 +++ include/uapi/linux/ethtool_netlink.h | 1 + net/ethtool/netlink.h | 2 +- net/ethtool/rings.c | 9 +++++++-- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index 4af58459a1e7..096771ee8586 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -72,11 +72,13 @@ enum { * @rx_buf_len: Current length of buffers on the rx ring. * @tcp_data_split: Scatter packet headers and data to separate buffers * @cqe_size: Size of TX/RX completion queue event + * @tx_push: The flag of tx push mode */ struct kernel_ethtool_ringparam { u32 rx_buf_len; u8 tcp_data_split; u32 cqe_size; + u32 tx_push; }; /** @@ -87,6 +89,7 @@ struct kernel_ethtool_ringparam { enum ethtool_supported_ring_param { ETHTOOL_RING_USE_RX_BUF_LEN = BIT(0), ETHTOOL_RING_USE_CQE_SIZE = BIT(1), + ETHTOOL_RING_USE_TX_PUSH = BIT(2), }; #define __ETH_RSS_HASH_BIT(bit) ((u32)1 << (bit)) diff --git a/include/uapi/linux/ethtool_netlink.h b/include/uapi/linux/ethtool_netlink.h index 979850221b8d..d2fb4f7be61b 100644 --- a/include/uapi/linux/ethtool_netlink.h +++ b/include/uapi/linux/ethtool_netlink.h @@ -338,6 +338,7 @@ enum { ETHTOOL_A_RINGS_RX_BUF_LEN, /* u32 */ ETHTOOL_A_RINGS_TCP_DATA_SPLIT, /* u8 */ ETHTOOL_A_RINGS_CQE_SIZE, /* u32 */ + ETHTOOL_A_RINGS_TX_PUSH, /* u8 */ /* add new constants above here */ __ETHTOOL_A_RINGS_CNT, diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h index 29d01662a48b..7919ddb2371c 100644 --- a/net/ethtool/netlink.h +++ b/net/ethtool/netlink.h @@ -363,7 +363,7 @@ extern const struct nla_policy ethnl_features_set_policy[ETHTOOL_A_FEATURES_WANT extern const struct nla_policy ethnl_privflags_get_policy[ETHTOOL_A_PRIVFLAGS_HEADER + 1]; extern const struct nla_policy ethnl_privflags_set_policy[ETHTOOL_A_PRIVFLAGS_FLAGS + 1]; extern const struct nla_policy ethnl_rings_get_policy[ETHTOOL_A_RINGS_HEADER + 1]; -extern const struct nla_policy ethnl_rings_set_policy[ETHTOOL_A_RINGS_CQE_SIZE + 1]; +extern const struct nla_policy ethnl_rings_set_policy[ETHTOOL_A_RINGS_TX_PUSH + 1]; extern const struct nla_policy ethnl_channels_get_policy[ETHTOOL_A_CHANNELS_HEADER + 1]; extern const struct nla_policy ethnl_channels_set_policy[ETHTOOL_A_CHANNELS_COMBINED_COUNT + 1]; extern const struct nla_policy ethnl_coalesce_get_policy[ETHTOOL_A_COALESCE_HEADER + 1]; diff --git a/net/ethtool/rings.c b/net/ethtool/rings.c index 9f33c9689b56..10f8c99ff17e 100644 --- a/net/ethtool/rings.c +++ b/net/ethtool/rings.c @@ -55,7 +55,8 @@ static int rings_reply_size(const struct ethnl_req_info *req_base, nla_total_size(sizeof(u32)) + /* _RINGS_TX */ nla_total_size(sizeof(u32)) + /* _RINGS_RX_BUF_LEN */ nla_total_size(sizeof(u8)) + /* _RINGS_TCP_DATA_SPLIT */ - nla_total_size(sizeof(u32)); /* _RINGS_CQE_SIZE */ + nla_total_size(sizeof(u32) + /* _RINGS_CQE_SIZE */ + nla_total_size(sizeof(u8))); /* _RINGS_TX_PUSH */ } static int rings_fill_reply(struct sk_buff *skb, @@ -94,7 +95,8 @@ static int rings_fill_reply(struct sk_buff *skb, (nla_put_u8(skb, ETHTOOL_A_RINGS_TCP_DATA_SPLIT, kr->tcp_data_split))) || (kr->cqe_size && - (nla_put_u32(skb, ETHTOOL_A_RINGS_CQE_SIZE, kr->cqe_size)))) + (nla_put_u32(skb, ETHTOOL_A_RINGS_CQE_SIZE, kr->cqe_size))) || + nla_put_u8(skb, ETHTOOL_A_RINGS_TX_PUSH, !!kr->tx_push)) return -EMSGSIZE; return 0; @@ -123,6 +125,7 @@ const struct nla_policy ethnl_rings_set_policy[] = { [ETHTOOL_A_RINGS_TX] = { .type = NLA_U32 }, [ETHTOOL_A_RINGS_RX_BUF_LEN] = NLA_POLICY_MIN(NLA_U32, 1), [ETHTOOL_A_RINGS_CQE_SIZE] = NLA_POLICY_MIN(NLA_U32, 1), + [ETHTOOL_A_RINGS_TX_PUSH] = { .type = NLA_U8 }, }; int ethnl_set_rings(struct sk_buff *skb, struct genl_info *info) @@ -165,6 +168,8 @@ int ethnl_set_rings(struct sk_buff *skb, struct genl_info *info) tb[ETHTOOL_A_RINGS_RX_BUF_LEN], &mod); ethnl_update_u32(&kernel_ringparam.cqe_size, tb[ETHTOOL_A_RINGS_CQE_SIZE], &mod); + ethnl_update_bool32(&kernel_ringparam.tx_push, + tb[ETHTOOL_A_RINGS_TX_PUSH], &mod); ret = 0; if (!mod) goto out_ops; -- 2.33.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [RFCv2 PATCH net-next 1/2] net-next: ethtool: extend ringparam set/get APIs for tx_push 2022-03-26 8:51 ` [RFCv2 PATCH net-next 1/2] net-next: ethtool: extend ringparam set/get APIs for tx_push Jie Wang @ 2022-03-26 19:50 ` Jakub Kicinski 2022-03-28 3:05 ` wangjie (L) 0 siblings, 1 reply; 6+ messages in thread From: Jakub Kicinski @ 2022-03-26 19:50 UTC (permalink / raw) To: Jie Wang Cc: mkubecek, davem, netdev, huangguangbin2, lipeng321, shenjian15, moyufeng, linyunsheng, salil.mehta, chenhao288 On Sat, 26 Mar 2022 16:51:01 +0800 Jie Wang wrote: > Currently tx push is a standard driver feature which controls use of a fast > path descriptor push. So this patch extends the ringparam APIs and data > structures to support set/get tx push by ethtool -G/g. > > Signed-off-by: Jie Wang <wangjie125@huawei.com> > --- > include/linux/ethtool.h | 3 +++ > include/uapi/linux/ethtool_netlink.h | 1 + > net/ethtool/netlink.h | 2 +- > net/ethtool/rings.c | 9 +++++++-- You need to add documentation in: Documentation/networking/ethtool-netlink.rst > diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h > index 4af58459a1e7..096771ee8586 100644 > --- a/include/linux/ethtool.h > +++ b/include/linux/ethtool.h > @@ -72,11 +72,13 @@ enum { > * @rx_buf_len: Current length of buffers on the rx ring. > * @tcp_data_split: Scatter packet headers and data to separate buffers > * @cqe_size: Size of TX/RX completion queue event > + * @tx_push: The flag of tx push mode > */ > struct kernel_ethtool_ringparam { > u32 rx_buf_len; > u8 tcp_data_split; > u32 cqe_size; > + u32 tx_push; Can we make this a u8 and move it up above cqe_size? u8 should be enough. You can use ethnl_update_u8(). > }; > > /** > @@ -87,6 +89,7 @@ struct kernel_ethtool_ringparam { > enum ethtool_supported_ring_param { > ETHTOOL_RING_USE_RX_BUF_LEN = BIT(0), > ETHTOOL_RING_USE_CQE_SIZE = BIT(1), > + ETHTOOL_RING_USE_TX_PUSH = BIT(2), You need to actually use this constant to reject the setting for drivers which don't support the feature. > }; > > #define __ETH_RSS_HASH_BIT(bit) ((u32)1 << (bit)) > @@ -94,7 +95,8 @@ static int rings_fill_reply(struct sk_buff *skb, > (nla_put_u8(skb, ETHTOOL_A_RINGS_TCP_DATA_SPLIT, > kr->tcp_data_split))) || > (kr->cqe_size && > - (nla_put_u32(skb, ETHTOOL_A_RINGS_CQE_SIZE, kr->cqe_size)))) > + (nla_put_u32(skb, ETHTOOL_A_RINGS_CQE_SIZE, kr->cqe_size))) || > + nla_put_u8(skb, ETHTOOL_A_RINGS_TX_PUSH, !!kr->tx_push)) > > return -EMSGSIZE; > > return 0; > @@ -123,6 +125,7 @@ const struct nla_policy ethnl_rings_set_policy[] = { > [ETHTOOL_A_RINGS_TX] = { .type = NLA_U32 }, > [ETHTOOL_A_RINGS_RX_BUF_LEN] = NLA_POLICY_MIN(NLA_U32, 1), > [ETHTOOL_A_RINGS_CQE_SIZE] = NLA_POLICY_MIN(NLA_U32, 1), > + [ETHTOOL_A_RINGS_TX_PUSH] = { .type = NLA_U8 }, This can only be 0 and 1, right? Set a policy to to that effect please. > }; > > int ethnl_set_rings(struct sk_buff *skb, struct genl_info *info) > @@ -165,6 +168,8 @@ int ethnl_set_rings(struct sk_buff *skb, struct genl_info *info) > tb[ETHTOOL_A_RINGS_RX_BUF_LEN], &mod); > ethnl_update_u32(&kernel_ringparam.cqe_size, > tb[ETHTOOL_A_RINGS_CQE_SIZE], &mod); > + ethnl_update_bool32(&kernel_ringparam.tx_push, > + tb[ETHTOOL_A_RINGS_TX_PUSH], &mod); > ret = 0; > if (!mod) > goto out_ops; ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFCv2 PATCH net-next 1/2] net-next: ethtool: extend ringparam set/get APIs for tx_push 2022-03-26 19:50 ` Jakub Kicinski @ 2022-03-28 3:05 ` wangjie (L) 2022-03-28 17:35 ` Jakub Kicinski 0 siblings, 1 reply; 6+ messages in thread From: wangjie (L) @ 2022-03-28 3:05 UTC (permalink / raw) To: Jakub Kicinski Cc: mkubecek, davem, netdev, huangguangbin2, lipeng321, shenjian15, moyufeng, linyunsheng, salil.mehta, chenhao288 On 2022/3/27 3:50, Jakub Kicinski wrote: > On Sat, 26 Mar 2022 16:51:01 +0800 Jie Wang wrote: >> Currently tx push is a standard driver feature which controls use of a fast >> path descriptor push. So this patch extends the ringparam APIs and data >> structures to support set/get tx push by ethtool -G/g. >> >> Signed-off-by: Jie Wang <wangjie125@huawei.com> >> --- >> include/linux/ethtool.h | 3 +++ >> include/uapi/linux/ethtool_netlink.h | 1 + >> net/ethtool/netlink.h | 2 +- >> net/ethtool/rings.c | 9 +++++++-- > > You need to add documentation in: > Documentation/networking/ethtool-netlink.rst > OK, i will add it in next version RFC version. >> diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h >> index 4af58459a1e7..096771ee8586 100644 >> --- a/include/linux/ethtool.h >> +++ b/include/linux/ethtool.h >> @@ -72,11 +72,13 @@ enum { >> * @rx_buf_len: Current length of buffers on the rx ring. >> * @tcp_data_split: Scatter packet headers and data to separate buffers >> * @cqe_size: Size of TX/RX completion queue event >> + * @tx_push: The flag of tx push mode >> */ >> struct kernel_ethtool_ringparam { >> u32 rx_buf_len; >> u8 tcp_data_split; >> u32 cqe_size; >> + u32 tx_push; > > Can we make this a u8 and move it up above cqe_size? > u8 should be enough. You can use ethnl_update_u8(). > yes, u8 is enough, next RFC version i will change it. >> }; >> >> /** >> @@ -87,6 +89,7 @@ struct kernel_ethtool_ringparam { >> enum ethtool_supported_ring_param { >> ETHTOOL_RING_USE_RX_BUF_LEN = BIT(0), >> ETHTOOL_RING_USE_CQE_SIZE = BIT(1), >> + ETHTOOL_RING_USE_TX_PUSH = BIT(2), > > You need to actually use this constant to reject the setting for > drivers which don't support the feature. > I will use this constant next version. >> }; >> >> #define __ETH_RSS_HASH_BIT(bit) ((u32)1 << (bit)) > >> @@ -94,7 +95,8 @@ static int rings_fill_reply(struct sk_buff *skb, >> (nla_put_u8(skb, ETHTOOL_A_RINGS_TCP_DATA_SPLIT, >> kr->tcp_data_split))) || >> (kr->cqe_size && >> - (nla_put_u32(skb, ETHTOOL_A_RINGS_CQE_SIZE, kr->cqe_size)))) >> + (nla_put_u32(skb, ETHTOOL_A_RINGS_CQE_SIZE, kr->cqe_size))) || >> + nla_put_u8(skb, ETHTOOL_A_RINGS_TX_PUSH, !!kr->tx_push)) >> >> return -EMSGSIZE; >> >> return 0; >> @@ -123,6 +125,7 @@ const struct nla_policy ethnl_rings_set_policy[] = { >> [ETHTOOL_A_RINGS_TX] = { .type = NLA_U32 }, >> [ETHTOOL_A_RINGS_RX_BUF_LEN] = NLA_POLICY_MIN(NLA_U32, 1), >> [ETHTOOL_A_RINGS_CQE_SIZE] = NLA_POLICY_MIN(NLA_U32, 1), >> + [ETHTOOL_A_RINGS_TX_PUSH] = { .type = NLA_U8 }, > > This can only be 0 and 1, right? Set a policy to to that effect please. > I will use NLA_POLICY_MAX(NLA_U8, 1), is this ok? >> }; >> >> int ethnl_set_rings(struct sk_buff *skb, struct genl_info *info) >> @@ -165,6 +168,8 @@ int ethnl_set_rings(struct sk_buff *skb, struct genl_info *info) >> tb[ETHTOOL_A_RINGS_RX_BUF_LEN], &mod); >> ethnl_update_u32(&kernel_ringparam.cqe_size, >> tb[ETHTOOL_A_RINGS_CQE_SIZE], &mod); >> + ethnl_update_bool32(&kernel_ringparam.tx_push, >> + tb[ETHTOOL_A_RINGS_TX_PUSH], &mod); >> ret = 0; >> if (!mod) >> goto out_ops; > > > . > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFCv2 PATCH net-next 1/2] net-next: ethtool: extend ringparam set/get APIs for tx_push 2022-03-28 3:05 ` wangjie (L) @ 2022-03-28 17:35 ` Jakub Kicinski 0 siblings, 0 replies; 6+ messages in thread From: Jakub Kicinski @ 2022-03-28 17:35 UTC (permalink / raw) To: wangjie (L) Cc: mkubecek, davem, netdev, huangguangbin2, lipeng321, shenjian15, moyufeng, linyunsheng, salil.mehta, chenhao288 On Mon, 28 Mar 2022 11:05:26 +0800 wangjie (L) wrote: > > This can only be 0 and 1, right? Set a policy to to that effect please. > > > I will use NLA_POLICY_MAX(NLA_U8, 1), is this ok? Yes, that looks right! ^ permalink raw reply [flat|nested] 6+ messages in thread
* [RFCv2 PATCH net-next 2/2] net-next: hn3: add tx push support in hns3 ring param process 2022-03-26 8:51 [RFCv2 PATCH net-next 0/2] net-next: ethool: add support to get/set tx push by ethtool -G/g Jie Wang 2022-03-26 8:51 ` [RFCv2 PATCH net-next 1/2] net-next: ethtool: extend ringparam set/get APIs for tx_push Jie Wang @ 2022-03-26 8:51 ` Jie Wang 1 sibling, 0 replies; 6+ messages in thread From: Jie Wang @ 2022-03-26 8:51 UTC (permalink / raw) To: mkubecek, davem, kuba, wangjie125 Cc: netdev, huangguangbin2, lipeng321, shenjian15, moyufeng, linyunsheng, salil.mehta, chenhao288 This patch adds tx push param to hns3 ring param and adapts the set and get API of ring params. So users can set it by cmd ethtool -G and get it by cmd ethtool -g. Signed-off-by: Jie Wang <wangjie125@huawei.com> --- .../ethernet/hisilicon/hns3/hns3_ethtool.c | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c index 6469238ae090..845a56b93075 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c @@ -664,6 +664,8 @@ static void hns3_get_ringparam(struct net_device *netdev, param->tx_pending = priv->ring[0].desc_num; param->rx_pending = priv->ring[rx_queue_index].desc_num; kernel_param->rx_buf_len = priv->ring[rx_queue_index].buf_size; + kernel_param->tx_push = test_bit(HNS3_NIC_STATE_TX_PUSH_ENABLE, + &priv->state); } static void hns3_get_pauseparam(struct net_device *netdev, @@ -1114,6 +1116,30 @@ static int hns3_change_rx_buf_len(struct net_device *ndev, u32 rx_buf_len) return 0; } +static int hns3_set_tx_push(struct net_device *netdev, u32 tx_push) +{ + struct hns3_nic_priv *priv = netdev_priv(netdev); + struct hnae3_handle *h = hns3_get_handle(netdev); + struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev); + u32 old_state = test_bit(HNS3_NIC_STATE_TX_PUSH_ENABLE, &priv->state); + + if (!test_bit(HNAE3_DEV_SUPPORT_TX_PUSH_B, ae_dev->caps) && tx_push) + return -EOPNOTSUPP; + + if (tx_push == old_state) + return 0; + + netdev_info(netdev, "Changing tx push from %s to %s\n", + old_state ? "on" : "off", tx_push ? "on" : "off"); + + if (tx_push) + set_bit(HNS3_NIC_STATE_TX_PUSH_ENABLE, &priv->state); + else + clear_bit(HNS3_NIC_STATE_TX_PUSH_ENABLE, &priv->state); + + return 0; +} + static int hns3_set_ringparam(struct net_device *ndev, struct ethtool_ringparam *param, struct kernel_ethtool_ringparam *kernel_param, @@ -1133,6 +1159,10 @@ static int hns3_set_ringparam(struct net_device *ndev, if (ret) return ret; + ret = hns3_set_tx_push(ndev, kernel_param->tx_push); + if (ret) + return ret; + /* Hardware requires that its descriptors must be multiple of eight */ new_tx_desc_num = ALIGN(param->tx_pending, HNS3_RING_BD_MULTIPLE); new_rx_desc_num = ALIGN(param->rx_pending, HNS3_RING_BD_MULTIPLE); -- 2.33.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-03-28 17:35 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-03-26 8:51 [RFCv2 PATCH net-next 0/2] net-next: ethool: add support to get/set tx push by ethtool -G/g Jie Wang 2022-03-26 8:51 ` [RFCv2 PATCH net-next 1/2] net-next: ethtool: extend ringparam set/get APIs for tx_push Jie Wang 2022-03-26 19:50 ` Jakub Kicinski 2022-03-28 3:05 ` wangjie (L) 2022-03-28 17:35 ` Jakub Kicinski 2022-03-26 8:51 ` [RFCv2 PATCH net-next 2/2] net-next: hn3: add tx push support in hns3 ring param process Jie Wang
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).