hisilicon net: fix some bugs in HNS drivers
Subsystems (3)
v2 cover hisilicon net: fix some bugs in HNS drivers
This patchset fixes the two bugs in HNS driver, one is change the code style according to the review comments from Joe Perches<[email protected]>, another is fixing the wrong mac_id judgement bug which is found during internal tests.
change log:
v2
1) remove first bug fix, which is fixed in another patch submitted by Arnd Bergmann <[email protected]>
2) change the code sytyle according to Joe.
v1
initial version.
huangdaode (2):
hisilicon net: removes the once HANDEL_TX_MSG macro hisilicon net: fix a bug on Hisilicon Network Subsystem
drivers/net/ethernet/hisilicon/hns/hnae.c | 45 +++++++++++------------ drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 2 +- 2 files changed, 23 insertions(+), 24 deletions(-)
Signature · 1 line
1.9.1
PATCH v2 1/2 hisilicon net: removes the once HANDEL_TX_MSG macro
This patch changes the code style to make the code more simple. also removes the once used HNADEL_TX_MSG macro, according to the review comments from Joe Perches.
--- drivers/net/ethernet/hisilicon/hns/hnae.c | 45 +++++++++++++++---------------- 1 file changed, 22 insertions(+), 23 deletions(-)
drivers/net/ethernet/hisilicon/hns/hnae.c +22 -23
@@ -439,40 +439,39 @@ EXPORT_SYMBOL(hnae_ae_unregister);static ssize_t handles_show (struct device *dev,struct device_attribute *attr,char *buf) { -ssize_t s =0 ; +char *s = buf;struct hnae_ae_dev *hdev =cls_to_ae_dev (dev);struct hnae_handle *h;int i =0 , j;list_for_each_entry_rcu (h, &hdev->handle_list, node) { - s +=sprintf (buf + s,"handle %d (eport_id=%u from %s):\n" , + s +=sprintf (s,"handle %d (eport_id=%u from %s):\n" , i++, h->eport_id, h->dev->name);for (j =0 ; j < h->q_num; j++) { - s +=sprintf (buf + s,"\tqueue[%d] on %p\n" , + s +=sprintf (s,"\tqueue[%d] on %p\n" , j, h->qs[i]->io_base); -#define HANDEL_TX_MSG "\t\ttx_ring on %p:%u,%u,%u,%u,%u,%llu,%llu\n" - s +=sprintf (buf + s, -HANDEL_TX_MSG , - h->qs[i]->tx_ring.io_base, - h->qs[i]->tx_ring.buf_size, - h->qs[i]->tx_ring.desc_num, - h->qs[i]->tx_ring.max_desc_num_per_pkt, - h->qs[i]->tx_ring.max_raw_data_sz_per_desc, - h->qs[i]->tx_ring.max_pkt_size, - h->qs[i]->tx_ring.stats.sw_err_cnt, - h->qs[i]->tx_ring.stats.io_err_cnt); - s +=sprintf (buf + s, -"\t\trx_ring on %p:%u,%u,%llu,%llu,%llu\n" , - h->qs[i]->rx_ring.io_base, - h->qs[i]->rx_ring.buf_size, - h->qs[i]->rx_ring.desc_num, - h->qs[i]->rx_ring.stats.sw_err_cnt, - h->qs[i]->rx_ring.stats.io_err_cnt, - h->qs[i]->rx_ring.stats.seg_pkt_cnt); + s +=sprintf (s, +"\t\ttx_ring on %p:%u,%u,%u,%u,%u,%llu,%llu\n" , + h->qs[i]->tx_ring.io_base, + h->qs[i]->tx_ring.buf_size, + h->qs[i]->tx_ring.desc_num, + h->qs[i]->tx_ring.max_desc_num_per_pkt, + h->qs[i]->tx_ring.max_raw_data_sz_per_desc, + h->qs[i]->tx_ring.max_pkt_size, + h->qs[i]->tx_ring.stats.sw_err_cnt, + h->qs[i]->tx_ring.stats.io_err_cnt); + s +=sprintf (s, +"\t\trx_ring on %p:%u,%u,%llu,%llu,%llu\n" , + h->qs[i]->rx_ring.io_base, + h->qs[i]->rx_ring.buf_size, + h->qs[i]->rx_ring.desc_num, + h->qs[i]->rx_ring.stats.sw_err_cnt, + h->qs[i]->rx_ring.stats.io_err_cnt, + h->qs[i]->rx_ring.stats.seg_pkt_cnt); } } -return s; +return s - buf; }static DEVICE_ATTR_RO (handles);
Signature · 1 line
1.9.1
Re: [PATCH net-next v2 1/2] hisilicon net: removes the once HANDEL_TX_MSG macro
Hello Huang.
Quoted 2 lines · huangdaode
This patch changes the code style to make the code more simple. also removes the once used
HNADEL_TX_MSGmacro, according to the
HANDEL_TX_MSG typo
Quoted 4 lines
review comments from Joe Perches.
Signed-off-by huangdaode <[email protected]>Reviewed-by Joe Perches <[email protected]>
I didn't review this.
Please do not add signatures for another person when not specifically added by that person.
Re: [PATCH net-next v2 1/2] hisilicon net: removes the once HANDEL_TX_MSG macro
Quoted 5 lines · Joe Perches
Hello Huang.
Quoted 2 lines · huangdaode
This patch changes the code style to make the code more simple. also removes the once used
HNADEL_TX_MSGmacro, according to the
Quoted 8 lines
HANDEL_TX_MSGtypoQuoted 4 lines
review comments from Joe Perches.
Signed-off-by huangdaode <[email protected]>Reviewed-by Joe Perches <[email protected]>I didn't review this.
'
Hi Joe
please refer to http://lists.openwall.net/netdev/2015/10/11/61
thanks.
Quoted 7 lines
Please do not add signatures for another person when not specifically added by that person.
.
Signature · 2 lines
Best Regards Daode Huang
Re: [PATCH net-next v2 1/2] hisilicon net: removes the once HANDEL_TX_MSG macro
Quoted 8 lines · On Monday 12 October 2015 11:38:24 huangdaode wrote:
Quoted 7 lines · Joe Perches
Hello Huang.
Quoted 2 lines · huangdaode
This patch changes the code style to make the code more simple. also removes the once used
HNADEL_TX_MSGmacro, according to the
HANDEL_TX_MSGtypo
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
review comments from Joe Perches.
Signed-off-by huangdaode <[email protected]>Reviewed-by Joe Perches <[email protected]>I didn't review this.
'Hi Joe
please refer to http://lists.openwall.net/netdev/2015/10/11/61
You should only add the "Reviewed-by" tag to a commit message if the person you are adding replied with this explicitly. Don't add it just because someone gave feedback.
Arnd
Re: [PATCH net-next v2 1/2] hisilicon net: removes the once HANDEL_TX_MSG macro
In reply to huangdaodedrivers/net/ethernet/hisilicon/hns/hnae.c EXPORT_SYMBOL(hnae_ae_unregister); · line 462
Quoted 10 lines · On Monday 12 October 2015 11:23:44 huangdaode wrote:
drivers/net/ethernet/hisilicon/hns/hnae.c +10
-0+ s +=sprintf (s, +"\t\ttx_ring on %p:%u,%u,%u,%u,%u,%llu,%llu\n" , + h->qs[i]->tx_ring.io_base, + h->qs[i]->tx_ring.buf_size, + h->qs[i]->tx_ring.desc_num, + h->qs[i]->tx_ring.max_desc_num_per_pkt, + h->qs[i]->tx_ring.max_raw_data_sz_per_desc, + h->qs[i]->tx_ring.max_pkt_size, + h->qs[i]->tx_ring.stats.sw_err_cnt, + h->qs[i]->tx_ring.stats.io_err_cnt);
There is actually a more significant problem with this code, which I failed to notice when doing the original bugfix:
You have a sysfs interface here that exports internal data of the device that should not be visible like this. One problem is that the io_base is a kernel pointer that must not be visible to non-root users (so we don't easily create an attack surface for exploits). Another problem is that the format is not documented in Documentation/ABI/ and that you have multiple values in one sysfs file here.
It would probably be better to completely remove that sysfs interface, and to use the ethtool netlink interface to export them.
Arnd
Re: [PATCH net-next v2 1/2] hisilicon net: removes the once HANDEL_TX_MSG macro
Quoted 4 lines · Arnd Bergmann
drivers/net/ethernet/hisilicon/hns/hnae.c EXPORT_SYMBOL(hnae_ae_unregister); · line 455
Quoted 3 lines · On Monday 12 October 2015 11:23:44 huangdaode wrote:
drivers/net/ethernet/hisilicon/hns/hnae.c +3
-0+ s += sprintf(s, + "\t\ttx_ring on %p:%u,%u,%u,%u,%u,%llu,%llu\n", + h->qs[i]->tx_ring.io_base,
[]
Quoted 7 lines
There is actually a more significant problem with this code, which I failed to notice when doing the original bugfix:
You have a sysfs interface here that exports internal data of the device that should not be visible like this. One problem is that the
io_baseis a kernel pointer that must not be visible to non-root users (so we don't easily create an attack surface for exploits).
Using %pK might have been appropriate.
Quoted 2 lines
It would probably be better to completely remove that sysfs interface, and to use the ethtool netlink interface to export them.
But this would be better.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: Fwd: Re: [PATCH net-next v2 1/2] hisilicon net: removes the once HANDEL_TX_MSG macro
Quoted 42 lines · huangdaode
Date: Tue, 13 Oct 2015 15:06:21 +0800
From: huangdaode <[email protected]>
To: Kenneth Lee <[email protected]>
Subject: Fwd: Re: [PATCH net-next v2 1/2] hisilicon net: removes the once
HANDEL_TX_MSGmacro
Message-ID: <[email protected]>-------- Forwarded Message --------
Subject: Re: [PATCH net-next v2 1/2] hisilicon net: removes the once
HANDEL_TX_MSGmacro
Date: Mon, 12 Oct 2015 13:59:39 +0200
From: Arnd Bergmann <[email protected]>
To: huangdaode <[email protected]>
CC: [email protected], [email protected], [email protected],
[email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]drivers/net/ethernet/hisilicon/hns/hnae.c EXPORT_SYMBOL(hnae_ae_unregister); · line 462
Quoted 10 lines · On Monday 12 October 2015 11:23:44 huangdaode wrote:
drivers/net/ethernet/hisilicon/hns/hnae.c +10
-0+ s +=sprintf (s, +"\t\ttx_ring on %p:%u,%u,%u,%u,%u,%llu,%llu\n" , + h->qs[i]->tx_ring.io_base, + h->qs[i]->tx_ring.buf_size, + h->qs[i]->tx_ring.desc_num, + h->qs[i]->tx_ring.max_desc_num_per_pkt, + h->qs[i]->tx_ring.max_raw_data_sz_per_desc, + h->qs[i]->tx_ring.max_pkt_size, + h->qs[i]->tx_ring.stats.sw_err_cnt, + h->qs[i]->tx_ring.stats.io_err_cnt);There is actually a more significant problem with this code, which I failed to notice when doing the original bugfix:
You have a sysfs interface here that exports internal data of the device that should not be visible like this. One problem is that the
io_baseis a kernel pointer that must not be visible to non-root users (so we don't easily create an attack surface for exploits). Another problem is that the format is not documented inDocumentation/ABI/and that you have multiple values in one sysfs file here.
Quoted 6 lines
It would probably be better to completely remove that sysfs interface, and to use the ethtool netlink interface to export them.
Arnd
.
Hi, Arnd,
Thank you for the comment. Yes, the io_base is a security problem, we will fix it in coming patch soon.
But can we keep the sysfs? The interface from hnae is not used only by ethernet driver but also by Open Data Plane driver. If we more it to upper layers. Both drivers will have the same logic.
So how about we just add documents to Documention/ABI?
Thanks
Signature · 1 line
-Kenneth Lee (Hisilicon)
Re: Fwd: Re: [PATCH net-next v2 1/2] hisilicon net: removes the once HANDEL_TX_MSG macro
Quoted 11 lines · On Tuesday 13 October 2015 21:27:12 Kenneth Lee wrote:
Hi, Arnd,
Thank you for the comment. Yes, the
io_baseis a security problem, we will fix it in coming patch soon.But can we keep the sysfs? The interface from hnae is not used only by ethernet driver but also by Open Data Plane driver. If we more it to upper layers. Both drivers will have the same logic.
So how about we just add documents to Documention/ABI?
Hi Kenneth,
In the end this is up to David Miller of course, but I'd say we are better off not introducing any ABIs for ODP prematurely.
We are talking about very generic statistics data, and you should already provide them for the ethernet driver using the standard interfaces.
I have not seen any discussion about adding an ODP subsystem for the Linux kernel, or what the API will be, but I think we should not export any interfaces from a particular device driver directly but always go through a common layer here and use an extensible interface that can be implemented by everyone.
The API has not been part of a release yet, so I'd say we should remove it for now. Once we have a net/odp/ directory, we can add a driver-independent implementation there and call it from the hisi driver.
Arnd
Re: Fwd: Re: [PATCH net-next v2 1/2] hisilicon net: removes the once HANDEL_TX_MSG macro
Quoted 40 lines · Arnd Bergmann
Date: Tue, 13 Oct 2015 16:18:23 +0200
From: Arnd Bergmann <[email protected]>
To: Kenneth Lee <[email protected]>
Cc: [email protected], [email protected], [email protected],
[email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], huangdaode <[email protected]>
Subject: Re: Fwd: Re: [PATCH net-next v2 1/2] hisilicon net: removes the
onceHANDEL_TX_MSGmacro
Message-ID: <6914069.XLdT9Eli48@wuerfel>Quoted 11 lines · On Tuesday 13 October 2015 21:27:12 Kenneth Lee wrote:
Hi, Arnd,
Thank you for the comment. Yes, the
io_baseis a security problem, we will fix it in coming patch soon.But can we keep the sysfs? The interface from hnae is not used only by ethernet driver but also by Open Data Plane driver. If we more it to upper layers. Both drivers will have the same logic.
So how about we just add documents to Documention/ABI?
Hi Kenneth,
In the end this is up to David Miller of course, but I'd say we are better off not introducing any ABIs for ODP prematurely.
We are talking about very generic statistics data, and you should already provide them for the ethernet driver using the standard interfaces.
I have not seen any discussion about adding an ODP subsystem for the Linux kernel, or what the API will be, but I think we should not export any interfaces from a particular device driver directly but always go through a common layer here and use an extensible interface that can be implemented by everyone.
Quoted 6 lines
The API has not been part of a release yet, so I'd say we should remove it for now. Once we have a
net/odp/directory, we can add a driver-independent implementation there and call it from the hisi driver.Arnd
Hi, Arnd,
Agree. We will remove the interface for the time being. Thank you.
Signature · 1 line
-Kenneth Lee (Hisilicon)
PATCH v2 2/2 hisilicon net: fix a bug on Hisilicon Network Subsystem
In reply to huangdaodeThis patch fixes the wrong judgement of mac_id when get port num.
--- drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c +1 -1
@@ -179,7 +179,7 @@ static int hns_mac_get_inner_port_num(struct hns_mac_cb *mac_cb,return -EINVAL ; } }else if (mac_cb->dsaf_dev->dsaf_mode <DSAF_MODE_MAX ) { -if (mac_cb->mac_id <=DSAF_MAX_PORT_NUM_PER_CHIP ) { +if (mac_cb->mac_id >=DSAF_MAX_PORT_NUM_PER_CHIP ) { dev_err(mac_cb->dev, "input invalid,%s mac%d vmid%d!\n", mac_cb->dsaf_dev->ae_dev.name,
Signature · 1 line
1.9.1