From: andriy.shevchenko@linux.intel.com (Andy Shevchenko)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH net-next 10/19] net: hns: bugfix about pfc pause frame statistics
Date: Wed, 22 Jun 2016 12:41:38 +0300 [thread overview]
Message-ID: <1466588498.30123.235.camel@linux.intel.com> (raw)
In-Reply-To: <5769ED55.3000408@huawei.com>
On Wed, 2016-06-22 at 09:43 +0800, Yisen Zhuang wrote:
>
> ? 2016/6/21 18:32, Andy Shevchenko ??:
> > On Tue, 2016-06-21 at 11:56 +0800, Yisen Zhuang wrote:
> > > From: Daode Huang <huangdaode@hisilicon.com>
> > >
> > > 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.
> > >
> >?
> >
> > > +static char *hns_dsaf_get_node_stats_strings(char *data, int
> > > node,
> > > + ?????struct dsaf_device
> > > *dsaf_dev)
> > > ?{
> > > ? char *buff = data;
> > > + int i;
> > > + bool is_ver1 = AE_IS_VER1(dsaf_dev->dsaf_ver);
> > > ?
> > > ? snprintf(buff, ETH_GSTRING_LEN, "innod%d_pad_drop_pkts",
> > > node);
> > > ? buff = buff + ETH_GSTRING_LEN;
> > > @@ -2502,6 +2530,18 @@ static char
> > > *hns_dsaf_get_node_stats_strings(char *data, int node)
> > > ? buff = buff + ETH_GSTRING_LEN;
> > > ? snprintf(buff, ETH_GSTRING_LEN, "innod%d_stp_drop_pkts",
> > > node);
> > > ? buff = buff + ETH_GSTRING_LEN;
> > > + if ((node < DSAF_SERVICE_NW_NUM) && (!is_ver1)) {
> >
> > Redundant parens.
> >
> > > + for (i = 0; i < DSAF_PRIO_NR; i++) {
> > > + snprintf(buff, ETH_GSTRING_LEN,
> > > + ?"inod%d_pfc_prio%d_pkts", node,
> > > i);
> > > + buff = buff + ETH_GSTRING_LEN;
> >
> > buff += ...
> >
> > > + }
> > > + for (i = 0; i < DSAF_PRIO_NR; i++) {
> > > + snprintf(buff, ETH_GSTRING_LEN,
> > > + ?"onod%d_pfc_prio%d_pkts", node,
> > > i);
> > > + buff = buff + ETH_GSTRING_LEN;
> >
> > Ditto.
> >
> > > ?{
> > > ? u64 *p = data;
> > > + int i;
> > > ? struct dsaf_hw_stats *hw_stats = &ddev-
> > > >hw_stats[node_num];
> > > + bool is_ver1 = AE_IS_VER1(ddev->dsaf_ver);
> > > ?
> > > ? p[0] = hw_stats->pad_drop;
> > > ? p[1] = hw_stats->man_pkts;
> > > @@ -2527,8 +2569,16 @@ static u64 *hns_dsaf_get_node_stats(struct
> > > 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-
> > > > 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 <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
next prev parent reply other threads:[~2016-06-22 9:41 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-21 3:56 [PATCH net-next 00/19] net: hns: fix some bugs in hns driver Yisen Zhuang
2016-06-21 3:56 ` [PATCH net-next 01/19] net: hns: bug fix of ge reset sequence Yisen Zhuang
2016-06-21 10:35 ` Andy Shevchenko
2016-06-22 1:33 ` Yisen Zhuang
2016-06-21 3:56 ` [PATCH net-next 02/19] net: hns: fix hns dsaf v1 dont support tx_pause close Yisen Zhuang
2016-06-21 3:56 ` [PATCH net-next 03/19] net: hns: add skb_reset_mac_header() after skb being alloc Yisen Zhuang
2016-06-21 3:56 ` [PATCH net-next 04/19] net: hns: typo fix of annotation info for hns_nic_reset_subtask() Yisen Zhuang
2016-06-21 3:56 ` [PATCH net-next 05/19] net: hns: Remove unnecessary device resource free Yisen Zhuang
2016-06-21 3:56 ` [PATCH net-next 06/19] net: hns: fix the error info when dma_set_mask_and_coherent fail Yisen Zhuang
2016-06-21 3:56 ` [PATCH net-next 07/19] net: hns: select Hilink before serdes loopback for HNS V2 Yisen Zhuang
2016-06-21 3:56 ` [PATCH net-next 08/19] net: hns: fix ethtool loopback fail bug Yisen Zhuang
2016-06-21 3:56 ` [PATCH net-next 09/19] net: hns: fix the wrong speed for bond Yisen Zhuang
2016-06-21 3:56 ` [PATCH net-next 10/19] net: hns: bugfix about pfc pause frame statistics Yisen Zhuang
2016-06-21 10:32 ` Andy Shevchenko
2016-06-22 1:43 ` Yisen Zhuang
2016-06-22 9:41 ` Andy Shevchenko [this message]
2016-06-23 5:42 ` Yisen Zhuang
2016-06-21 3:56 ` [PATCH net-next 11/19] net: hns: add spin lock for tcam table operation Yisen Zhuang
2016-06-21 3:56 ` [PATCH net-next 12/19] net: hns: fix bug of getting the wrong tcam data Yisen Zhuang
2016-06-21 3:56 ` [PATCH net-next 13/19] net: hns: add get_coalesce_range api for hns Yisen Zhuang
2016-06-21 3:56 ` [PATCH net-next 14/19] net: hns: delete redundancy ring enable operations Yisen Zhuang
2016-06-21 3:56 ` [PATCH net-next 15/19] net: hns: bug fix about led control logic when link down Yisen Zhuang
2016-06-21 3:56 ` [PATCH net-next 16/19] net: hns: fix bug that alloc skb fail lead to port unavailable Yisen Zhuang
2016-06-21 13:25 ` Sergei Shtylyov
2016-06-22 1:41 ` Yisen Zhuang
2016-06-21 3:56 ` [PATCH net-next 17/19] net: hns: fix sbm default parameters config error Yisen Zhuang
2016-06-21 3:56 ` [PATCH net-next 18/19] net: hns: change the default coalesce usecs Yisen Zhuang
2016-06-21 3:56 ` [PATCH net-next 19/19] net: hns: bug fix about TSO on|off when there is traffic Yisen Zhuang
2016-06-21 8:54 ` [PATCH net-next 00/19] net: hns: fix some bugs in hns driver David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1466588498.30123.235.camel@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).