This series includes some bugs fixed. All these patches needs to be
applied after the patchset about ACPI support, so this series is
floated to net-next list.
The patches are:
> from Daode, fixes about pfc pause frame, getting coaslesce, led
control logic, TSO on|off and tcam table configuration.
> from Jun He, fix the potential leak to port unavailable
> from Kejian, fix bug of loopback and failing to test ping6
> from Qianqian, fix the several typo in hns driver
For more details, please see individual patches.
MBR.
Daode Huang (9):
net: hns: bugfix about pfc pause frame statistics
net: hns: add spin lock for tcam table operation
net: hns: fix bug of getting the wrong tcam data
net: hns: add get_coalesce_range api for hns
net: hns: delete redundancy ring enable operations
net: hns: bug fix about led control logic when link down
net: hns: fix sbm default parameters config error
net: hns: change the default coalesce usecs
net: hns: bug fix about TSO on|off when there is traffic
Jun He (1):
net: hns: fix bug that alloc skb fail lead to port unavailable
Kejian Yan (3):
net: hns: add skb_reset_mac_header() after skb being alloc
net: hns: select Hilink before serdes loopback for HNS V2
net: hns: fix ethtool loopback fail bug
Qianqian Xie (6):
net: hns: bug fix of ge reset sequence
net: hns: fix hns dsaf v1 dont support tx_pause close
net: hns: typo fix of annotation info for hns_nic_reset_subtask()
net: hns: Remove unnecessary device resource free
net: hns: fix the error info when dma_set_mask_and_coherent fail
net: hns: fix the wrong speed for bond
drivers/net/ethernet/hisilicon/hns/hnae.c | 1 -
drivers/net/ethernet/hisilicon/hns/hnae.h | 6 +-
drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c | 53 ++++--
drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c | 190 ++++++++++++++-------
drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h | 12 +-
drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c | 44 +++--
drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c | 2 +-
drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h | 2 +-
drivers/net/ethernet/hisilicon/hns/hns_dsaf_reg.h | 21 ++-
drivers/net/ethernet/hisilicon/hns/hns_enet.c | 68 ++++----
drivers/net/ethernet/hisilicon/hns/hns_ethtool.c | 47 ++---
11 files changed, 291 insertions(+), 155 deletions(-)
--
1.9.1
From: Qianqian Xie <redacted>
For service port, hns dsaf v1 support to close tx_pause.
However, the port will be invalid when it run command
ethtool to close tx_pause. This patch will fix it.
Signed-off-by: Qianqian Xie <redacted>
Signed-off-by: Yisen Zhuang <redacted>
---
drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
@@ -1114,10 +1114,10 @@ int hns_dsaf_set_rx_mac_pause_en(struct dsaf_device *dsaf_dev, int mac_id,u32en){if(AE_IS_VER1(dsaf_dev->dsaf_ver)){-if(!en)+if(!en){dev_err(dsaf_dev->dev,"dsafv1 can't close rx_pause!\n");--return-EINVAL;+return-EINVAL;+}}dsaf_set_dev_bit(dsaf_dev,DSAF_PAUSE_CFG_REG+mac_id*4,
From: Qianqian Xie <redacted>
The bit fileds of PPE reset register are different between HNS v1 and
HNS v2, but the current procedure just only match HNS v1. Here is a
patch to fix it.
Signed-off-by: Kejian Yan <redacted>
Signed-off-by: Qianqian Xie <redacted>
Signed-off-by: Yisen Zhuang <redacted>
---
drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
From: Daode Huang <redacted>
The default coalesce timeout is 3us, which is will cause CPU
usage is too high. This patch change it to 50us in order to reduce
CPU usage and the value makes sure network latency also meets requirement.
Signed-off-by: Daode Huang <redacted>
Signed-off-by: Yisen Zhuang <redacted>
---
drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c | 2 +-
drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
@@ -540,7 +540,7 @@ int hns_rcb_set_coalesce_usecs(}if(timeout>HNS_RCB_MAX_COALESCED_USECS){dev_err(rcb_common->dsaf_dev->dev,-"error: not support coalesce %dus!\n",timeout);+"error: coalesce_usecs setting supports 0~1023us\n");return-EINVAL;}hns_rcb_set_port_timeout(rcb_common,port_idx,timeout);
From: Qianqian Xie <redacted>
For debug-ports,there are two non-synchronized processes:
Speed-Auto-Negotiation and Link-Update-Status. The two
processes are towed by two different state machines.
Bond reads the speed when link up, but the speed maybe
not update the right value at that time.That make for bond's
wrong speed. Thus only one state machine should be used and
if phy_state_machine is used, it does not need to do
hns_nic_update_link_status().
Signed-off-by: Qianqian Xie <redacted>
Signed-off-by: Yisen Zhuang <redacted>
---
drivers/net/ethernet/hisilicon/hns/hns_enet.c | 43 +++++++++++++-----------
drivers/net/ethernet/hisilicon/hns/hns_ethtool.c | 2 +-
2 files changed, 25 insertions(+), 20 deletions(-)
From: Kejian Yan <redacted>
As Hilink3 and Hilink4 use the same xge training and xge u adaptor for
HNSv2, it needs to select which Hilink to be set before relative serdes
being configed. The hilink_access_sel is the register to do that.
Signed-off-by: Kejian Yan <redacted>
Signed-off-by: Yisen Zhuang <redacted>
---
drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c | 26 +++++++++++++++++-----
1 file changed, 20 insertions(+), 6 deletions(-)
@@ -435,11 +435,6 @@ int hns_mac_get_sfp_prsnt(struct hns_mac_cb *mac_cb, int *sfp_prsnt)*/staticinthns_mac_config_sds_loopback(structhns_mac_cb*mac_cb,boolen){-/* port 0-3 hilink4 base is serdes_vaddr + 0x00280000-*port4-7hilink3baseisserdes_vaddr+0x00200000-*/-u8*base_addr=(u8*)mac_cb->serdes_vaddr+-(mac_cb->mac_id<=3?0x00280000:0x00200000);constu8lane_id[]={0,/* mac 0 -> lane 0 */1,/* mac 1 -> lane 1 */
@@ -465,11 +460,30 @@ static int hns_mac_config_sds_loopback(struct hns_mac_cb *mac_cb, bool en)}if(mac_cb->serdes_ctrl){-u32origin=dsaf_read_syscon(mac_cb->serdes_ctrl,reg_offset);+u32origin;++if(!AE_IS_VER1(mac_cb->dsaf_dev->dsaf_ver)){+#define HILINK_ACCESS_SEL_CFG 0x40008+/* hilink4 & hilink3 use the same xge training and+*xgeuadaptor.Thereisahilinkaccessselcfg+*registertoselectwhichonetobeconfiged+*/+if((!HNS_DSAF_IS_DEBUG(mac_cb->dsaf_dev))&&+(mac_cb->mac_id<=3))+dsaf_write_syscon(mac_cb->serdes_ctrl,+HILINK_ACCESS_SEL_CFG,0);+else+dsaf_write_syscon(mac_cb->serdes_ctrl,+HILINK_ACCESS_SEL_CFG,3);+}++origin=dsaf_read_syscon(mac_cb->serdes_ctrl,reg_offset);dsaf_set_field(origin,1ull<<10,10,en);dsaf_write_syscon(mac_cb->serdes_ctrl,reg_offset,origin);}else{+u8*base_addr=(u8*)mac_cb->serdes_vaddr++(mac_cb->mac_id<=3?0x00280000:0x00200000);dsaf_set_reg_field(base_addr,reg_offset,1ull<<10,10,en);}
From: Daode Huang <redacted>
This patch adds get_coalesce_range api for hns, it shows
range of coalesce usecs and frames that can be set on
this interface.
Signed-off-by: Daode Huang <redacted>
Signed-off-by: Yisen Zhuang <redacted>
---
drivers/net/ethernet/hisilicon/hns/hnae.h | 5 +++++
drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c | 25 +++++++++++++++++++++++
drivers/net/ethernet/hisilicon/hns/hns_ethtool.c | 10 +++++++++
3 files changed, 40 insertions(+)
From: Daode Huang <redacted>
The current driver stores the high bit value of tcam data register
to the tcam data low element, stores the low bit value of tcam data
register to tcam data high element, this patch fixes this bug.
Signed-off-by: Daode Huang <redacted>
Signed-off-by: Yisen Zhuang <redacted>
---
drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
@@ -626,7 +628,7 @@ int hns_ae_get_sset_count(struct hnae_handle *handle, int stringset)sset_count+=hns_mac_get_sset_count(mac_cb,stringset);if(mac_cb->mac_type==HNAE_PORT_SERVICE)-sset_count+=hns_dsaf_get_sset_count(stringset);+sset_count+=hns_dsaf_get_sset_count(dsaf_dev,stringset);returnsset_count;}
@@ -2570,7 +2625,8 @@ int hns_dsaf_get_sset_count(int stringset)*@data:stringsnamevalue*@port:portindex*/-voidhns_dsaf_get_strings(intstringset,u8*data,intport)+voidhns_dsaf_get_strings(intstringset,u8*data,intport,+structdsaf_device*dsaf_dev){char*buff=(char*)data;intnode=port;
@@ -2579,11 +2635,11 @@ void hns_dsaf_get_strings(int stringset, u8 *data, int port)return;/* for ge/xge node info */-buff=hns_dsaf_get_node_stats_strings(buff,node);+buff=hns_dsaf_get_node_stats_strings(buff,node,dsaf_dev);/* for ppe node info */node=port+DSAF_PPE_INODE_BASE;-(void)hns_dsaf_get_node_stats_strings(buff,node);+(void)hns_dsaf_get_node_stats_strings(buff,node,dsaf_dev);}/**
From: Kejian Yan <redacted>
When run ethtool cmd(ethtool -t ethx) again and again for a long
time, it will be probabilistically fail. The PHYs' registers may
be on different pages, so it must be switch to the right page
before setting PHYs' registers.
And __lb_up() calls phy_start() to startup the PHYs device, but
this function may change Copper Control Register(Page 0, Register 0)
to an other value. It would cause phy loopback test fail. if we
remove phy_start(), we have to remove the relative phy_stop(),
phy_disconnect() when doing phy loopback to keep the phy stay in
right status.
Reported-by: hejun <redacted>
Signed-off-by: Kejian Yan <redacted>
Signed-off-by: Yisen Zhuang <redacted>
---
drivers/net/ethernet/hisilicon/hns/hns_ethtool.c | 35 ++++++++++--------------
1 file changed, 14 insertions(+), 21 deletions(-)
From: Kejian Yan <redacted>
HNS receives a packet without doing anything, but it should call
skb_reset_mac_header() to initialize the header before using
eth_hdr().
Fixes: 0d6b425a3773c3445b0f51b2f333821beaacb619
Signed-off-by: Kejian Yan <redacted>
Signed-off-by: Yisen Zhuang <redacted>
---
drivers/net/ethernet/hisilicon/hns/hns_enet.c | 1 +
1 file changed, 1 insertion(+)
From: Daode Huang <redacted>
The default driver sets anchor led bit to 0 when link down,
actually, the anchor bit should be set to 1, so fixes it when
link status is down.
Secondly, change the return value of cpld_set_led_id to 0, which
means leave the cpld to control led blink frequece other than the
driver itself.
Signed-off-by: Daode Huang <redacted>
Signed-off-by: Yisen Zhuang <redacted>
---
drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
From: Daode Huang <redacted>
The default sbm config parameter leaves little buffer when there is heavy
traffic, which will cause packets drop. This patch changes them to make
enough buffers for handling packets.
Signed-off-by: Daode Huang <redacted>
Signed-off-by: Yisen Zhuang <redacted>
---
drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c | 40 ++++++++++++++--------
drivers/net/ethernet/hisilicon/hns/hns_dsaf_reg.h | 16 +++++++--
2 files changed, 39 insertions(+), 17 deletions(-)
@@ -200,7 +200,7 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)if(dsaf_dev->buf_size_type<0){dev_err(dsaf_dev->dev,"buf_size(%d) is wrong!\n",buf_size);-gotounmap_base_addr;+return-EINVAL;}dsaf_dev->misc_op=hns_misc_op_get(dsaf_dev);
@@ -213,32 +213,6 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)dev_err(dsaf_dev->dev,"set mask to 64bit fail!\n");return0;--unmap_base_addr:-if(dsaf_dev->io_base)-iounmap(dsaf_dev->io_base);-if(dsaf_dev->ppe_base)-iounmap(dsaf_dev->ppe_base);-if(dsaf_dev->sds_base)-iounmap(dsaf_dev->sds_base);-if(dsaf_dev->sc_base)-iounmap(dsaf_dev->sc_base);-returnret;-}--staticvoidhns_dsaf_free_cfg(structdsaf_device*dsaf_dev)-{-if(dsaf_dev->io_base)-iounmap(dsaf_dev->io_base);--if(dsaf_dev->ppe_base)-iounmap(dsaf_dev->ppe_base);--if(dsaf_dev->sds_base)-iounmap(dsaf_dev->sds_base);--if(dsaf_dev->sc_base)-iounmap(dsaf_dev->sc_base);}/**
@@ -2645,7 +2619,7 @@ static int hns_dsaf_probe(struct platform_device *pdev)ret=hns_dsaf_init(dsaf_dev);if(ret)-gotofree_cfg;+gotofree_dev;ret=hns_mac_init(dsaf_dev);if(ret)
From: Qianqian Xie <redacted>
The error info should be printed as "set mask to 64bit fail!" instead of
"set mask to 32bit fail!" in dma_set_mask_and_coherent().
Signed-off-by: Qianqian Xie <redacted>
Signed-off-by: Yisen Zhuang <redacted>
---
drivers/net/ethernet/hisilicon/hns/hns_enet.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@@ -1972,7 +1972,7 @@ static int hns_nic_dev_probe(struct platform_device *pdev)if(!dma_set_mask_and_coherent(dev,DMA_BIT_MASK(64)))dev_dbg(dev,"set mask to 64bit\n");else-dev_err(dev,"set mask to 32bit fail!\n");+dev_err(dev,"set mask to 64bit fail!\n");/* carrier off reporting is important to ethtool even BEFORE open */netif_carrier_off(ndev);
From: Daode Huang <redacted>
When enable/disable tso, the driver tries to access the hardware register,
but this operation will cause the port unavalible when there is traffic.
This patch tries to enable TSO when initialize, then control tso through
TSE bit in transmit descriptor.
Signed-off-by: Daode Huang <redacted>
Signed-off-by: Yisen Zhuang <redacted>
---
drivers/net/ethernet/hisilicon/hns/hns_enet.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
@@ -1441,7 +1441,6 @@ static int hns_nic_set_features(struct net_device *netdev,netdev_features_tfeatures){structhns_nic_priv*priv=netdev_priv(netdev);-structhnae_handle*h=priv->ae_handle;switch(priv->enet_ver){caseAE_VERSION_1:
@@ -1454,11 +1453,9 @@ static int hns_nic_set_features(struct net_device *netdev,priv->ops.maybe_stop_tx=hns_nic_maybe_stop_tso;/* The chip only support 7*4096 */netif_set_gso_max_size(netdev,7*4096);-h->dev->ops->set_tso_stats(h,1);}else{priv->ops.fill_desc=fill_v2_desc;priv->ops.maybe_stop_tx=hns_nic_maybe_stop_tx;-h->dev->ops->set_tso_stats(h,0);}break;}
@@ -1804,11 +1801,14 @@ static void hns_nic_set_priv_ops(struct net_device *netdev)priv->ops.maybe_stop_tx=hns_nic_maybe_stop_tso;/* This chip only support 7*4096 */netif_set_gso_max_size(netdev,7*4096);-h->dev->ops->set_tso_stats(h,1);}else{priv->ops.fill_desc=fill_v2_desc;priv->ops.maybe_stop_tx=hns_nic_maybe_stop_tx;}+/* enable tso when init+*controltsoon/offthroughTSEbitinbd+*/+h->dev->ops->set_tso_stats(h,1);}}
From: Jun He <redacted>
When hns_nic_poll_rx_skb alloc skb fail, it will break receive cycle and
read new fbd_num to start new receive cycle. It recomputes cycle num is
fbd_num minus clean_count, actually this cycle num is too big because
it drop out receive cycle. It brings about the port unavailable.
So we will goto out when alloc skb fail to fix this bug.
Signed-off-by: Jun He <redacted>
Signed-off-by: Ding Tianhong <redacted>
Signed-off-by: Yisen Zhuang <redacted>
---
drivers/net/ethernet/hisilicon/hns/hns_enet.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
@@ -768,10 +768,10 @@ recv:clean_count=0;}-/* poll one pkg*/+/* poll one pkt*/err=hns_nic_poll_rx_skb(ring_data,&skb,&bnum);if(unlikely(!skb))/* this fault cannot be repaired */-break;+gotoout;recv_bds+=bnum;clean_count+=bnum;
@@ -797,6 +797,7 @@ recv:}}+out:/* make all data has been write before submit */if(clean_count>0)hns_nic_alloc_rx_buffers(ring_data,clean_count);
This series includes some bugs fixed. All these patches needs to be
applied after the patchset about ACPI support, so this series is
floated to net-next list.
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Date: 2016-06-21 10:36:12
On Tue, 2016-06-21 at 11:56 +0800, Yisen Zhuang wrote:
quoted hunk
From: Qianqian Xie <redacted>
The bit fileds of PPE reset register are different between HNS v1 and
HNS v2, but the current procedure just only match HNS v1. Here is a
patch to fix it.
Signed-off-by: Kejian Yan <redacted>
Signed-off-by: Qianqian Xie <redacted>
Signed-off-by: Yisen Zhuang <redacted>
---
drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Date: 2016-06-21 10:40:18
On Tue, 2016-06-21 at 11:56 +0800, Yisen Zhuang wrote:
From: Daode Huang <redacted>
For SoC hip06, PFC pause handled in dsaf, while hip05 in XGMAC,
so change the statistics of pfc pause in dsaf and remove the old
pfc pause frame statistics.
From: Sergei Shtylyov <hidden> Date: 2016-06-21 13:25:25
Hello.
On 6/21/2016 6:56 AM, Yisen Zhuang wrote:
quoted hunk
From: Jun He <redacted>
When hns_nic_poll_rx_skb alloc skb fail, it will break receive cycle and
read new fbd_num to start new receive cycle. It recomputes cycle num is
fbd_num minus clean_count, actually this cycle num is too big because
it drop out receive cycle. It brings about the port unavailable.
So we will goto out when alloc skb fail to fix this bug.
Signed-off-by: Jun He <redacted>
Signed-off-by: Ding Tianhong <redacted>
Signed-off-by: Yisen Zhuang <redacted>
---
drivers/net/ethernet/hisilicon/hns/hns_enet.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
On Tue, 2016-06-21 at 11:56 +0800, Yisen Zhuang wrote:
quoted
From: Qianqian Xie <redacted>
The bit fileds of PPE reset register are different between HNS v1 and
HNS v2, but the current procedure just only match HNS v1. Here is a
patch to fix it.
Signed-off-by: Kejian Yan <redacted>
Signed-off-by: Qianqian Xie <redacted>
Signed-off-by: Yisen Zhuang <redacted>
---
drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
On Tue, 2016-06-21 at 11:56 +0800, Yisen Zhuang wrote:
quoted
From: Daode Huang <redacted>
For SoC hip06, PFC pause handled in dsaf, while hip05 in XGMAC,
so change the statistics of pfc pause in dsaf and remove the old
pfc pause frame statistics.
dsaf_device *ddev, u64 *data,
p[10] = hw_stats->local_addr_false;
p[11] = hw_stats->vlan_drop;
p[12] = hw_stats->stp_drop;
- p[13] = hw_stats->tx_pkts;
+ if ((node_num < DSAF_SERVICE_NW_NUM) && (!is_ver1)) {
+ for (i = 0; i < DSAF_PRIO_NR; i++) {
+ p[13 + i] = hw_stats->rx_pfc[i];
+ p[13 + i + DSAF_PRIO_NR] = hw_stats-
quoted
tx_pfc[i];
+ }
Two different approaches how to assign data. Above uses 2 for-loops,
here you put everything to one.
Above cann't be merged to 1 for-loop, because lenght of the string is unknowable.
And here we put everything to one to reduce codes.
I will generate a new patch to fix other comments.
Thanks,
Yisen
From: Jun He <redacted>
When hns_nic_poll_rx_skb alloc skb fail, it will break receive cycle and
read new fbd_num to start new receive cycle. It recomputes cycle num is
fbd_num minus clean_count, actually this cycle num is too big because
it drop out receive cycle. It brings about the port unavailable.
So we will goto out when alloc skb fail to fix this bug.
Signed-off-by: Jun He <redacted>
Signed-off-by: Ding Tianhong <redacted>
Signed-off-by: Yisen Zhuang <redacted>
---
drivers/net/ethernet/hisilicon/hns/hns_enet.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Date: 2016-06-22 09:41:46
On Wed, 2016-06-22 at 09:43 +0800, Yisen Zhuang wrote:
在 2016/6/21 18:32, Andy Shevchenko 写道:
quoted
On Tue, 2016-06-21 at 11:56 +0800, Yisen Zhuang wrote:
quoted
From: Daode Huang <redacted>
For SoC hip06, PFC pause handled in dsaf, while hip05 in XGMAC,
so change the statistics of pfc pause in dsaf and remove the old
pfc pause frame statistics.
dsaf_device *ddev, u64 *data,
p[10] = hw_stats->local_addr_false;
p[11] = hw_stats->vlan_drop;
p[12] = hw_stats->stp_drop;
- p[13] = hw_stats->tx_pkts;
+ if ((node_num < DSAF_SERVICE_NW_NUM) && (!is_ver1)) {
+ for (i = 0; i < DSAF_PRIO_NR; i++) {
+ p[13 + i] = hw_stats->rx_pfc[i];
+ p[13 + i + DSAF_PRIO_NR] = hw_stats-
quoted
tx_pfc[i];
+ }
Two different approaches how to assign data. Above uses 2 for-loops,
here you put everything to one.
Above cann't be merged to 1 for-loop, because lenght of the string is
unknowable.
It doesn't matter since you are incrementing start position by
constant.
snprintf(buff, ETH_GSTRING_LEN, "inod%d_pfc_prio%d_pkts", node, i);
snprintf(buff, ETH_GSTRING_LEN, "onod%d_pfc_prio%d_pkts", node, i);
Same approach as below can be used
snprintf(buff + 0 * ETH_GSTRING_LEN * DSAF_PRIO_NR, ETH_GSTRING_LEN, ...
snprintf(buff + 1 * ETH_GSTRING_LEN * DSAF_PRIO_NR, ETH_GSTRING_LEN, ...
Of course to make it less verbose you may add new definition(s) and/ or
variable(s).
And here we put everything to one to reduce codes.
I would suggest to use following pattern for such lines
p[13 + i + 0 * DSAF_PRIO_NR] = hw_stats->rx_pfc[i];
p[13 + i + 1 * DSAF_PRIO_NR] = hw_stats->tx_pfc[i];
That's allow reader to see what are you doing here.
P.S. This is for the future patches since current is already applied.
--
Andy Shevchenko [off-list ref]
Intel Finland Oy
On Wed, 2016-06-22 at 09:43 +0800, Yisen Zhuang wrote:
quoted
在 2016/6/21 18:32, Andy Shevchenko 写道:
quoted
On Tue, 2016-06-21 at 11:56 +0800, Yisen Zhuang wrote:
quoted
From: Daode Huang <redacted>
For SoC hip06, PFC pause handled in dsaf, while hip05 in XGMAC,
so change the statistics of pfc pause in dsaf and remove the old
pfc pause frame statistics.
dsaf_device *ddev, u64 *data,
p[10] = hw_stats->local_addr_false;
p[11] = hw_stats->vlan_drop;
p[12] = hw_stats->stp_drop;
- p[13] = hw_stats->tx_pkts;
+ if ((node_num < DSAF_SERVICE_NW_NUM) && (!is_ver1)) {
+ for (i = 0; i < DSAF_PRIO_NR; i++) {
+ p[13 + i] = hw_stats->rx_pfc[i];
+ p[13 + i + DSAF_PRIO_NR] = hw_stats-
quoted
tx_pfc[i];
+ }
Two different approaches how to assign data. Above uses 2 for-loops,
here you put everything to one.
Above cann't be merged to 1 for-loop, because lenght of the string is
unknowable.
It doesn't matter since you are incrementing start position by
constant.
snprintf(buff, ETH_GSTRING_LEN, "inod%d_pfc_prio%d_pkts", node, i);
snprintf(buff, ETH_GSTRING_LEN, "onod%d_pfc_prio%d_pkts", node, i);
Same approach as below can be used
snprintf(buff + 0 * ETH_GSTRING_LEN * DSAF_PRIO_NR, ETH_GSTRING_LEN, ...
snprintf(buff + 1 * ETH_GSTRING_LEN * DSAF_PRIO_NR, ETH_GSTRING_LEN, ...
Of course to make it less verbose you may add new definition(s) and/ or
variable(s).
quoted
And here we put everything to one to reduce codes.
I would suggest to use following pattern for such lines
p[13 + i + 0 * DSAF_PRIO_NR] = hw_stats->rx_pfc[i];
p[13 + i + 1 * DSAF_PRIO_NR] = hw_stats->tx_pfc[i];
That's allow reader to see what are you doing here.
P.S. This is for the future patches since current is already applied.
Hi Andy,
Many thanks for you suggestions. I will fix it with a new patch.
Thanks,
Yisen