From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7C1CBA09FF; Mon, 11 Jan 2021 15:49:53 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 19BDC140E71; Mon, 11 Jan 2021 15:49:53 +0100 (CET) Received: from mail-io1-f50.google.com (mail-io1-f50.google.com [209.85.166.50]) by mails.dpdk.org (Postfix) with ESMTP id 49981140E68 for ; Mon, 11 Jan 2021 15:49:51 +0100 (CET) Received: by mail-io1-f50.google.com with SMTP id q1so3688615ion.8 for ; Mon, 11 Jan 2021 06:49:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=P+aLVf4uTfI78pTr3wiOBD8mkATUnQkrKLF9H8ZWsNM=; b=H3dif4dUt5LiuLQsI3FL4yP35JPGZaPTW0dGJrya4LDsvKHV4fS5DXKjmtCJNatofD bKX5xABkzc8I/pXlaHH0Cjsln2qti82v3tJJdWsFh/vTBMOli0IJ7mfBtMsGAfO2jmhw TQYmHU6nFWa5OwtjOjbn+iYJPP5PYC7i7CtkI8951gqR/wLtc/VBWCHGrSPAFM40vi1j GGKgxNfOMA+7EzE1PvJ3WxJErDJoNFaM6UnC2z+GYzDNmjjd6clBoKblTKeZQ/7JqNXU K3xXomkpOlehzn9hywFged/J2ol478Wp67nsPx6L/yM8M/eew2o9CmaFopXUz7bgtRk0 Ky3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=P+aLVf4uTfI78pTr3wiOBD8mkATUnQkrKLF9H8ZWsNM=; b=JtN4ydOIskmiX9/f7EYjzf3VcBNaLwGsEV4HVT86wMwvUzcEHGR/P7pSwS5fmauHVA Jpp5jO5E8E+94zJY17A+g736nW512vC9wD7SqrZWdRdoJVGNZmoRJM1/HqwAzZ9YWWsc ub2plmnNzcm7+o0u3o2sIttBtneeR2PPcUXPBrgoLa802rRW8InmaU8SZLKMV42caY2q yq1kdQ8CSZPlfp4MfWsfpBc4STF2kOydunLUY+iHWbz43yuTWNNrDtUWusDk6Fmjnh06 j1Me2YzxbibpeYuw4aef+Yq2coCzCiHFBzQ5Jn008R+0xUxrF9ZK9q0IaOYooDMMT2XG cDMA== X-Gm-Message-State: AOAM533UqfEWeIXhDa/ZrBN/y+dHAsl562hdke+T8nTCgh4ZYQ2SMimH rIPZwqy9sfblfdPer2mURkNuMZxBw6/4n1MFwSM= X-Google-Smtp-Source: ABdhPJw5JP5S0EJLyvLkSraWNu2k5po8acPM/NosLdVPHWXTieTGx55LbgxOrLfNTTqnan/ujqU9v0/zCddvqxHC6eg= X-Received: by 2002:a02:ce2c:: with SMTP id v12mr108047jar.60.1610376590505; Mon, 11 Jan 2021 06:49:50 -0800 (PST) MIME-Version: 1.0 References: <20201202101212.4717-1-lironh@marvell.com> <20201202101212.4717-10-lironh@marvell.com> In-Reply-To: From: Jerin Jacob Date: Mon, 11 Jan 2021 20:19:34 +0530 Message-ID: To: Michael Shamis Cc: Liron Himi , Jerin Jacob Kollanukkaran , "dev@dpdk.org" , Yuri Chipchev Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] [PATCH v1 09/38] net/mvpp2: extend xstats support X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Wed, Dec 23, 2020 at 3:14 PM Michael Shamis wrote: > > Reviewed-by: Michael Shamis > > -----Original Message----- > From: dev On Behalf Of lironh@marvell.com > Sent: Wednesday, December 2, 2020 12:12 PM > To: Jerin Jacob Kollanukkaran > Cc: dev@dpdk.org; Yuri Chipchev ; Liron Himi > Subject: [dpdk-dev] [PATCH v1 09/38] net/mvpp2: extend xstats support > > From: Yuri Chipchev > > add xstats_by_id callbacks > > Signed-off-by: Yuri Chipchev > Reviewed-by: Liron Himi > --- > drivers/net/mvpp2/mrvl_ethdev.c | 90 +++++++++++++++++++++++++++++++++ > 1 file changed, 90 insertions(+) > > diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c index 46e7260be..e81d5ee91 100644 > --- a/drivers/net/mvpp2/mrvl_ethdev.c > +++ b/drivers/net/mvpp2/mrvl_ethdev.c > @@ -2027,6 +2027,94 @@ mrvl_eth_filter_ctrl(struct rte_eth_dev *dev __rte_unused, > } > } > > +/** > + * DPDK callback to get xstats by id. > + * > + * @param dev > + * Pointer to the device structure. > + * @param ids > + * Pointer to the ids table. > + * @param values > + * Pointer to the values table. > + * @param n > + * Values table size. > + * @returns > + * Number of read values, negative value otherwise. > + */ > +static int > +mrvl_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, > + uint64_t *values, unsigned int n) { > + unsigned int i, num = RTE_DIM(mrvl_xstats_tbl); > + uint64_t vals[n]; Please add boundary checks for "n". > + int ret; > + > + if (!ids) { According to spec, if ids == NULL, we just need to return the size of max objects, no need to copy to values. > + struct rte_eth_xstat xstats[num]; > + int j; > + > + ret = mrvl_xstats_get(dev, xstats, num); > + for (j = 0; j < ret; i++) > + values[j] = xstats[j].value; > + > + return ret; > + } > + > + ret = mrvl_xstats_get_by_id(dev, NULL, vals, n); > + if (ret < 0) > + return ret; > + > + for (i = 0; i < n; i++) { > + if (ids[i] >= num) { > + MRVL_LOG(ERR, "id value is not valid\n"); > + return -1; > + } > + > + values[i] = vals[ids[i]]; > + } > + > + return n; > +} > + > +/** > + * DPDK callback to get xstats names by ids. > + * > + * @param dev > + * Pointer to the device structure. > + * @param xstats_names > + * Pointer to table with xstats names. > + * @param ids > + * Pointer to table with ids. > + * @param size > + * Xstats names table size. > + * @returns > + * Number of names read, negative value otherwise. > + */ > +static int > +mrvl_xstats_get_names_by_id(struct rte_eth_dev *dev, > + struct rte_eth_xstat_name *xstats_names, > + const uint64_t *ids, unsigned int size) { > + unsigned int i, num = RTE_DIM(mrvl_xstats_tbl); > + struct rte_eth_xstat_name names[num]; Above comments appliable here too. > + > + if (!ids) > + return mrvl_xstats_get_names(dev, xstats_names, size); > + > + mrvl_xstats_get_names(dev, names, size); > + for (i = 0; i < size; i++) { > + if (ids[i] >= num) { > + MRVL_LOG(ERR, "id value is not valid"); > + return -1; > + } > + > + snprintf(xstats_names[i].name, RTE_ETH_XSTATS_NAME_SIZE, > + "%s", names[ids[i]].name); > + } > + > + return size; > +} > + > /** > * DPDK callback to get rte_mtr callbacks. > * > @@ -2102,6 +2190,8 @@ static const struct eth_dev_ops mrvl_ops = { > .rss_hash_update = mrvl_rss_hash_update, > .rss_hash_conf_get = mrvl_rss_hash_conf_get, > .filter_ctrl = mrvl_eth_filter_ctrl, > + .xstats_get_by_id = mrvl_xstats_get_by_id, > + .xstats_get_names_by_id = mrvl_xstats_get_names_by_id, > .mtr_ops_get = mrvl_mtr_ops_get, > .tm_ops_get = mrvl_tm_ops_get, > }; > -- > 2.28.0 >