2022-09-05 08:47:19

by Guangbin Huang

[permalink] [raw]
Subject: [PATCH net-next 0/5] net: hns3: updates for -next

This series includes some updates for the HNS3 ethernet driver.

Patches #1~#3 support configuring dscp map to tc.

Patch 4# supports querying FEC statistics by command "ethtool -I --show-fec eth0".

Patch 5# supports querying and setting Serdes lane number.

Guangbin Huang (3):
net: hns3: add support config dscp map to tc
net: hns3: support ndo_select_queue()
net: hns3: debugfs add dump dscp map info

Hao Chen (1):
net: hns3: add support to query and set lane number by ethtool

Hao Lan (1):
net: hns3: add querying fec statistics

drivers/net/ethernet/hisilicon/hns3/hnae3.h | 26 ++-
.../hns3/hns3_common/hclge_comm_cmd.c | 2 +
.../hns3/hns3_common/hclge_comm_cmd.h | 3 +
.../net/ethernet/hisilicon/hns3/hns3_dcbnl.c | 28 +++
.../ethernet/hisilicon/hns3/hns3_debugfs.c | 13 ++
.../net/ethernet/hisilicon/hns3/hns3_enet.c | 46 +++++
.../ethernet/hisilicon/hns3/hns3_ethtool.c | 33 +++-
.../hisilicon/hns3/hns3pf/hclge_cmd.h | 21 +-
.../hisilicon/hns3/hns3pf/hclge_dcb.c | 107 ++++++++++
.../hisilicon/hns3/hns3pf/hclge_dcb.h | 3 +
.../hisilicon/hns3/hns3pf/hclge_debugfs.c | 60 +++++-
.../hisilicon/hns3/hns3pf/hclge_main.c | 183 +++++++++++++++++-
.../hisilicon/hns3/hns3pf/hclge_main.h | 29 ++-
.../hisilicon/hns3/hns3pf/hclge_mdio.c | 2 +-
.../ethernet/hisilicon/hns3/hns3pf/hclge_tm.c | 50 ++++-
.../ethernet/hisilicon/hns3/hns3pf/hclge_tm.h | 5 +
.../hisilicon/hns3/hns3vf/hclgevf_main.c | 2 +-
17 files changed, 588 insertions(+), 25 deletions(-)

--
2.33.0


2022-09-05 09:12:16

by Guangbin Huang

[permalink] [raw]
Subject: [PATCH net-next 2/5] net: hns3: support ndo_select_queue()

To support tx packets to select queue according to its dscp field after
setting dscp and tc map relationship, this patch implements
ndo_select_queue() to set skb->priority according to the user's setting
dscp and priority map relationship.

Signed-off-by: Guangbin Huang <[email protected]>
---
.../net/ethernet/hisilicon/hns3/hns3_enet.c | 46 +++++++++++++++++++
1 file changed, 46 insertions(+)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 481a300819ad..82f83e3f8162 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -2963,6 +2963,51 @@ static int hns3_nic_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)
return h->ae_algo->ops->set_vf_mac(h, vf_id, mac);
}

+#define HNS3_INVALID_DSCP 0xff
+#define HNS3_DSCP_SHIFT 2
+
+static u8 hns3_get_skb_dscp(struct sk_buff *skb)
+{
+ __be16 protocol = skb->protocol;
+ u8 dscp = HNS3_INVALID_DSCP;
+
+ if (protocol == htons(ETH_P_8021Q))
+ protocol = vlan_get_protocol(skb);
+
+ if (protocol == htons(ETH_P_IP))
+ dscp = ipv4_get_dsfield(ip_hdr(skb)) >> HNS3_DSCP_SHIFT;
+ else if (protocol == htons(ETH_P_IPV6))
+ dscp = ipv6_get_dsfield(ipv6_hdr(skb)) >> HNS3_DSCP_SHIFT;
+
+ return dscp;
+}
+
+static u16 hns3_nic_select_queue(struct net_device *netdev,
+ struct sk_buff *skb,
+ struct net_device *sb_dev)
+{
+ struct hnae3_handle *h = hns3_get_handle(netdev);
+ u8 dscp, priority;
+ int ret;
+
+ if (h->kinfo.tc_map_mode != HNAE3_TC_MAP_MODE_DSCP ||
+ !h->ae_algo->ops->get_dscp_prio)
+ goto out;
+
+ dscp = hns3_get_skb_dscp(skb);
+ if (unlikely(dscp == HNS3_INVALID_DSCP))
+ goto out;
+
+ ret = h->ae_algo->ops->get_dscp_prio(h, dscp, NULL, &priority);
+ if (ret)
+ goto out;
+
+ skb->priority = priority;
+
+out:
+ return netdev_pick_tx(netdev, skb, sb_dev);
+}
+
static const struct net_device_ops hns3_nic_netdev_ops = {
.ndo_open = hns3_nic_net_open,
.ndo_stop = hns3_nic_net_stop,
@@ -2988,6 +3033,7 @@ static const struct net_device_ops hns3_nic_netdev_ops = {
.ndo_set_vf_link_state = hns3_nic_set_vf_link_state,
.ndo_set_vf_rate = hns3_nic_set_vf_rate,
.ndo_set_vf_mac = hns3_nic_set_vf_mac,
+ .ndo_select_queue = hns3_nic_select_queue,
};

bool hns3_is_phys_func(struct pci_dev *pdev)
--
2.33.0

2022-09-06 13:32:09

by Paolo Abeni

[permalink] [raw]
Subject: Re: [PATCH net-next 2/5] net: hns3: support ndo_select_queue()

On Mon, 2022-09-05 at 16:15 +0800, Guangbin Huang wrote:
> To support tx packets to select queue according to its dscp field after
> setting dscp and tc map relationship, this patch implements
> ndo_select_queue() to set skb->priority according to the user's setting
> dscp and priority map relationship.
>
> Signed-off-by: Guangbin Huang <[email protected]>
> ---
> .../net/ethernet/hisilicon/hns3/hns3_enet.c | 46 +++++++++++++++++++
> 1 file changed, 46 insertions(+)
>
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
> index 481a300819ad..82f83e3f8162 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
> @@ -2963,6 +2963,51 @@ static int hns3_nic_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)
> return h->ae_algo->ops->set_vf_mac(h, vf_id, mac);
> }
>
> +#define HNS3_INVALID_DSCP 0xff
> +#define HNS3_DSCP_SHIFT 2
> +
> +static u8 hns3_get_skb_dscp(struct sk_buff *skb)
> +{
> + __be16 protocol = skb->protocol;
> + u8 dscp = HNS3_INVALID_DSCP;
> +
> + if (protocol == htons(ETH_P_8021Q))
> + protocol = vlan_get_protocol(skb);
> +
> + if (protocol == htons(ETH_P_IP))
> + dscp = ipv4_get_dsfield(ip_hdr(skb)) >> HNS3_DSCP_SHIFT;
> + else if (protocol == htons(ETH_P_IPV6))
> + dscp = ipv6_get_dsfield(ipv6_hdr(skb)) >> HNS3_DSCP_SHIFT;
> +
> + return dscp;
> +}
> +
> +static u16 hns3_nic_select_queue(struct net_device *netdev,
> + struct sk_buff *skb,
> + struct net_device *sb_dev)
> +{
> + struct hnae3_handle *h = hns3_get_handle(netdev);
> + u8 dscp, priority;
> + int ret;
> +
> + if (h->kinfo.tc_map_mode != HNAE3_TC_MAP_MODE_DSCP ||
> + !h->ae_algo->ops->get_dscp_prio)
> + goto out;
> +
> + dscp = hns3_get_skb_dscp(skb);
> + if (unlikely(dscp == HNS3_INVALID_DSCP))
> + goto out;
> +
> + ret = h->ae_algo->ops->get_dscp_prio(h, dscp, NULL, &priority);

This introduces an additional, unneeded indirect call in the fast path,
you could consider replacing the above with a direct call to
hclge_get_dscp_prio() - again taking care of the CONFIG_HNS3_DCB
dependency.

Cheers,

Paolo

2022-09-07 01:46:51

by Guangbin Huang

[permalink] [raw]
Subject: Re: [PATCH net-next 2/5] net: hns3: support ndo_select_queue()



On 2022/9/6 21:15, Paolo Abeni wrote:
> On Mon, 2022-09-05 at 16:15 +0800, Guangbin Huang wrote:
>> To support tx packets to select queue according to its dscp field after
>> setting dscp and tc map relationship, this patch implements
>> ndo_select_queue() to set skb->priority according to the user's setting
>> dscp and priority map relationship.
>>
>> Signed-off-by: Guangbin Huang <[email protected]>
>> ---
>> .../net/ethernet/hisilicon/hns3/hns3_enet.c | 46 +++++++++++++++++++
>> 1 file changed, 46 insertions(+)
>>
>> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
>> index 481a300819ad..82f83e3f8162 100644
>> --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
>> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
>> @@ -2963,6 +2963,51 @@ static int hns3_nic_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)
>> return h->ae_algo->ops->set_vf_mac(h, vf_id, mac);
>> }
>>
>> +#define HNS3_INVALID_DSCP 0xff
>> +#define HNS3_DSCP_SHIFT 2
>> +
>> +static u8 hns3_get_skb_dscp(struct sk_buff *skb)
>> +{
>> + __be16 protocol = skb->protocol;
>> + u8 dscp = HNS3_INVALID_DSCP;
>> +
>> + if (protocol == htons(ETH_P_8021Q))
>> + protocol = vlan_get_protocol(skb);
>> +
>> + if (protocol == htons(ETH_P_IP))
>> + dscp = ipv4_get_dsfield(ip_hdr(skb)) >> HNS3_DSCP_SHIFT;
>> + else if (protocol == htons(ETH_P_IPV6))
>> + dscp = ipv6_get_dsfield(ipv6_hdr(skb)) >> HNS3_DSCP_SHIFT;
>> +
>> + return dscp;
>> +}
>> +
>> +static u16 hns3_nic_select_queue(struct net_device *netdev,
>> + struct sk_buff *skb,
>> + struct net_device *sb_dev)
>> +{
>> + struct hnae3_handle *h = hns3_get_handle(netdev);
>> + u8 dscp, priority;
>> + int ret;
>> +
>> + if (h->kinfo.tc_map_mode != HNAE3_TC_MAP_MODE_DSCP ||
>> + !h->ae_algo->ops->get_dscp_prio)
>> + goto out;
>> +
>> + dscp = hns3_get_skb_dscp(skb);
>> + if (unlikely(dscp == HNS3_INVALID_DSCP))
>> + goto out;
>> +
>> + ret = h->ae_algo->ops->get_dscp_prio(h, dscp, NULL, &priority);
>
> This introduces an additional, unneeded indirect call in the fast path,
> you could consider replacing the above with a direct call to
> hclge_get_dscp_prio() - again taking care of the CONFIG_HNS3_DCB
> dependency.
>
> Cheers,
>
> Paolo
>
> .
>
Ok.