From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from tyo201.gate.nec.co.jp (TYO201.gate.nec.co.jp [210.143.35.51]) by dpdk.org (Postfix) with ESMTP id 5EF4C58D5 for ; Tue, 25 Mar 2014 09:22:16 +0100 (CET) Received: from mailgate3.nec.co.jp ([10.7.69.195]) by tyo201.gate.nec.co.jp (8.13.8/8.13.4) with ESMTP id s2P8NgkE014166; Tue, 25 Mar 2014 17:23:42 +0900 (JST) Received: from mailsv4.nec.co.jp (imss62.nec.co.jp [10.7.69.157]) by mailgate3.nec.co.jp (8.11.7/3.7W-MAILGATE-NEC) with ESMTP id s2P8NfS26584; Tue, 25 Mar 2014 17:23:42 +0900 (JST) Received: from mail02.kamome.nec.co.jp (mail02.kamome.nec.co.jp [10.25.43.5]) by mailsv4.nec.co.jp (8.13.8/8.13.4) with ESMTP id s2P8NfdW018962; Tue, 25 Mar 2014 17:23:41 +0900 (JST) Received: from bpxc99gp.gisp.nec.co.jp ([10.38.151.144] [10.38.151.144]) by mail02.kamome.nec.co.jp with ESMTP id BT-MMP-404817; Tue, 25 Mar 2014 17:23:11 +0900 Received: from BPXM14GP.gisp.nec.co.jp ([169.254.1.238]) by BPXC16GP.gisp.nec.co.jp ([10.38.151.144]) with mapi id 14.02.0328.011; Tue, 25 Mar 2014 17:23:10 +0900 From: Hiroshi Shimamoto To: Thomas Monjalon Thread-Topic: [dpdk-dev] [memnic PATCH 3/5] pmd: implement stats of MEMNIC Thread-Index: AQHPR3Vjl1yGNjnkpEKbyHJY4ra4k5rxd5ww Date: Tue, 25 Mar 2014 08:23:09 +0000 Message-ID: <7F861DC0615E0C47A872E6F3C5FCDDBD0108D15C@BPXM14GP.gisp.nec.co.jp> References: <7F861DC0615E0C47A872E6F3C5FCDDBD01073B19@BPXM14GP.gisp.nec.co.jp> <1588240.i7QGELTBWt@xps13> In-Reply-To: <1588240.i7QGELTBWt@xps13> Accept-Language: ja-JP, en-US Content-Language: ja-JP X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.205.5.123] Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "dev@dpdk.org" , Hayato Momma Subject: Re: [dpdk-dev] [memnic PATCH 3/5] pmd: implement stats of MEMNIC X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Mar 2014 08:22:17 -0000 Hi, > Subject: Re: [dpdk-dev] [memnic PATCH 3/5] pmd: implement stats of MEMNIC >=20 > Hi, >=20 > 11/03/2014 05:38, Hiroshi Shimamoto: > > From: Hiroshi Shimamoto > > > > Implement missing feature to account statistics. > > This patch adds just an infrastructure. > > > > Signed-off-by: Hiroshi Shimamoto > > Reviewed-by: Hayato Momma >=20 > [...] >=20 > > @@ -51,6 +51,7 @@ struct memnic_adapter { > > int up_idx, down_idx; > > struct rte_mempool *mp; > > struct ether_addr mac_addr; > > + struct rte_eth_stats stats[RTE_MAX_LCORE]; > > }; >=20 > Could you make a comment to explain why you allocate a structure per core= ? > It is easier to read when locking strategy is described. sure, could you please see the new one? >=20 > > + for (i =3D 0; i < RTE_MAX_LCORE; i++) { > > + struct rte_eth_stats *st =3D &adapter->stats[i]; > > + > > + memset(st, 0, sizeof(*st)); > > + } >=20 > Could you use only one memset for the array? >=20 Yep, it's reasonable. The below is the updated patch. Is it okay for you? thanks, Hiroshi =3D=3D From: Hiroshi Shimamoto Subject: [PATCH v2] pmd: Implement stats of MEMNIC Implement missing feature to account statistics. This patch adds just an infrastructure. Allocating per core stats area to avoid locking. Signed-off-by: Hiroshi Shimamoto Reviewed-by: Hayato Momma --- pmd/pmd_memnic.c | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/pmd/pmd_memnic.c b/pmd/pmd_memnic.c index bf5fc2e..facaf54 100644 --- a/pmd/pmd_memnic.c +++ b/pmd/pmd_memnic.c @@ -51,6 +51,12 @@ struct memnic_adapter { int up_idx, down_idx; struct rte_mempool *mp; struct ether_addr mac_addr; + /* + * Allocate per core stats to avoid lock for accounting. + * Incrementing stats doesn't require lock, because only one thread + * is running on per core. + */ + struct rte_eth_stats stats[RTE_MAX_LCORE]; }; =20 static inline struct memnic_adapter *get_adapter(const struct rte_eth_dev = *dev) @@ -126,13 +132,46 @@ static void memnic_dev_infos_get(struct rte_eth_dev *= dev, dev_info->max_mac_addrs =3D 1; } =20 -static void memnic_dev_stats_get(__rte_unused struct rte_eth_dev *dev, - __rte_unused struct rte_eth_stats *stats) +static void memnic_dev_stats_get(struct rte_eth_dev *dev, + struct rte_eth_stats *stats) { + struct memnic_adapter *adapter =3D get_adapter(dev); + int i; + + memset(stats, 0, sizeof(*stats)); + for (i =3D 0; i < RTE_MAX_LCORE; i++) { + struct rte_eth_stats *st =3D &adapter->stats[i]; + + stats->ipackets +=3D st->ipackets; + stats->opackets +=3D st->opackets; + stats->ibytes +=3D st->ibytes; + stats->obytes +=3D st->obytes; + stats->ierrors +=3D st->ierrors; + stats->oerrors +=3D st->oerrors; + stats->imcasts +=3D st->imcasts; + stats->rx_nombuf +=3D st->rx_nombuf; + stats->fdirmatch +=3D st->fdirmatch; + stats->fdirmiss +=3D st->fdirmiss; + + /* no multiqueue support now */ + stats->q_ipackets[0] =3D st->q_ipackets[0]; + stats->q_opackets[0] =3D st->q_opackets[0]; + stats->q_ibytes[0] =3D st->q_ibytes[0]; + stats->q_obytes[0] =3D st->q_obytes[0]; + stats->q_errors[0] =3D st->q_errors[0]; + + stats->ilbpackets +=3D st->ilbpackets; + stats->olbpackets +=3D st->olbpackets; + stats->ilbbytes +=3D st->ilbbytes; + stats->olbbytes +=3D st->olbbytes; + } } =20 -static void memnic_dev_stats_reset(__rte_unused struct rte_eth_dev *dev) +static void memnic_dev_stats_reset(struct rte_eth_dev *dev) { + struct memnic_adapter *adapter =3D get_adapter(dev); + + memset(adapter->stats, 0, sizeof(adapter->stats)); } =20 static int memnic_dev_link_update(struct rte_eth_dev *dev, --=20 1.8.4