2020-11-07 06:35:51

by Huazhong Tan

[permalink] [raw]
Subject: [PATCH net-next 02/11] net: hns3: add support for 1us unit GL configuration

For device whose version is above V3(include V3), the GL
configuration can set as 1us unit, so adds support for
configuring this field.

Signed-off-by: Huazhong Tan <[email protected]>
---
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 26 ++++++++++++++++++----
drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | 3 +++
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 6 +++++
3 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 6e08719..2813fe5 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -224,17 +224,27 @@ void hns3_set_vector_coalesce_rl(struct hns3_enet_tqp_vector *tqp_vector,
void hns3_set_vector_coalesce_rx_gl(struct hns3_enet_tqp_vector *tqp_vector,
u32 gl_value)
{
- u32 rx_gl_reg = hns3_gl_usec_to_reg(gl_value);
+ u32 new_val;

- writel(rx_gl_reg, tqp_vector->mask_addr + HNS3_VECTOR_GL0_OFFSET);
+ if (tqp_vector->rx_group.coal.unit_1us)
+ new_val = gl_value | HNS3_INT_GL_1US;
+ else
+ new_val = hns3_gl_usec_to_reg(gl_value);
+
+ writel(new_val, tqp_vector->mask_addr + HNS3_VECTOR_GL0_OFFSET);
}

void hns3_set_vector_coalesce_tx_gl(struct hns3_enet_tqp_vector *tqp_vector,
u32 gl_value)
{
- u32 tx_gl_reg = hns3_gl_usec_to_reg(gl_value);
+ u32 new_val;
+
+ if (tqp_vector->tx_group.coal.unit_1us)
+ new_val = gl_value | HNS3_INT_GL_1US;
+ else
+ new_val = hns3_gl_usec_to_reg(gl_value);

- writel(tx_gl_reg, tqp_vector->mask_addr + HNS3_VECTOR_GL1_OFFSET);
+ writel(new_val, tqp_vector->mask_addr + HNS3_VECTOR_GL1_OFFSET);
}

void hns3_set_vector_coalesce_tx_ql(struct hns3_enet_tqp_vector *tqp_vector,
@@ -272,6 +282,14 @@ static void hns3_vector_coalesce_init(struct hns3_enet_tqp_vector *tqp_vector,
rx_coal->flow_level = HNS3_FLOW_LOW;
tx_coal->flow_level = HNS3_FLOW_LOW;

+ /* device version above V3(include V3), GL can configure 1us
+ * unit, so uses 1us unit.
+ */
+ if (ae_dev->dev_version >= HNAE3_DEVICE_VERSION_V3) {
+ tx_coal->unit_1us = 1;
+ rx_coal->unit_1us = 1;
+ }
+
if (ae_dev->dev_specs.int_ql_max) {
tx_coal->ql_enable = 1;
rx_coal->ql_enable = 1;
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
index 10990bd..b37635d 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
@@ -426,6 +426,8 @@ enum hns3_flow_level_range {
#define HNS3_INT_GL_18K 0x0036
#define HNS3_INT_GL_8K 0x007C

+#define HNS3_INT_GL_1US BIT(31)
+
#define HNS3_INT_RL_MAX 0x00EC
#define HNS3_INT_RL_ENABLE_MASK 0x40

@@ -437,6 +439,7 @@ struct hns3_enet_coalesce {
u16 int_ql_max;
u8 gl_adapt_enable:1;
u8 ql_enable:1;
+ u8 unit_1us:1;
enum hns3_flow_level_range flow_level;
};

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
index 9af7cb9..128e9ec 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
@@ -1146,6 +1146,12 @@ static int hns3_check_gl_coalesce_para(struct net_device *netdev,
return -EINVAL;
}

+ /* device version above V3(include V3), GL uses 1us unit,
+ * so the round down is not needed.
+ */
+ if (ae_dev->dev_version >= HNAE3_DEVICE_VERSION_V3)
+ return 0;
+
rx_gl = hns3_gl_round_down(cmd->rx_coalesce_usecs);
if (rx_gl != cmd->rx_coalesce_usecs) {
netdev_info(netdev,
--
2.7.4


2020-11-07 17:48:03

by Jakub Kicinski

[permalink] [raw]
Subject: Re: [PATCH net-next 02/11] net: hns3: add support for 1us unit GL configuration

On Sat, 7 Nov 2020 14:31:12 +0800 Huazhong Tan wrote:
> For device whose version is above V3(include V3), the GL
> configuration can set as 1us unit, so adds support for
> configuring this field.
>
> Signed-off-by: Huazhong Tan <[email protected]>

Doesn't build.

drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c: In function ‘hns3_check_gl_coalesce_para’:
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c:1152:6: error: ‘ae_dev’ undeclared (first use in this function); did you mean ‘netdev’?
1152 | if (ae_dev->dev_version >= HNAE3_DEVICE_VERSION_V3)
| ^~~~~~
| netdev
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c:1152:6: note: each undeclared identifier is reported only once for each function it appears in
make[6]: *** [drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.o] Error 1
make[5]: *** [drivers/net/ethernet/hisilicon/hns3] Error 2
make[4]: *** [drivers/net/ethernet/hisilicon] Error 2
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [drivers/net/ethernet] Error 2
make[2]: *** [drivers/net] Error 2
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [drivers] Error 2
make: *** [__sub-make] Error 2

2020-11-09 00:59:47

by Huazhong Tan

[permalink] [raw]
Subject: Re: [PATCH net-next 02/11] net: hns3: add support for 1us unit GL configuration



On 2020/11/8 1:46, Jakub Kicinski wrote:
> On Sat, 7 Nov 2020 14:31:12 +0800 Huazhong Tan wrote:
>> For device whose version is above V3(include V3), the GL
>> configuration can set as 1us unit, so adds support for
>> configuring this field.
>>
>> Signed-off-by: Huazhong Tan <[email protected]>
>
> Doesn't build.
>
> drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c: In function ‘hns3_check_gl_coalesce_para’:
> drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c:1152:6: error: ‘ae_dev’ undeclared (first use in this function); did you mean ‘netdev’?
> 1152 | if (ae_dev->dev_version >= HNAE3_DEVICE_VERSION_V3)
> | ^~~~~~
> | netdev
> drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c:1152:6: note: each undeclared identifier is reported only once for each function it appears in
> make[6]: *** [drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.o] Error 1
> make[5]: *** [drivers/net/ethernet/hisilicon/hns3] Error 2
> make[4]: *** [drivers/net/ethernet/hisilicon] Error 2
> make[4]: *** Waiting for unfinished jobs....
> make[3]: *** [drivers/net/ethernet] Error 2
> make[2]: *** [drivers/net] Error 2
> make[2]: *** Waiting for unfinished jobs....
> make[1]: *** [drivers] Error 2
> make: *** [__sub-make] Error 2
>

Will fix it.
Thanks.

> .
>