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 15F8841CF1; Mon, 20 Feb 2023 23:57:40 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E75E043106; Mon, 20 Feb 2023 23:57:39 +0100 (CET) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2052.outbound.protection.outlook.com [40.107.237.52]) by mails.dpdk.org (Postfix) with ESMTP id 3E6F340395 for ; Mon, 20 Feb 2023 23:57:39 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OumRgejzTPtHK/daTGLse1jKK6aHZLi6ieeiuBUrkAo3FqwfFItsesdVFYc6S1CdYjkhTSgJJH3a/c8fY0a1ou8QTceI9BC5+Vv6+p/OKPYnH8rnqy9S1GZ1jJup1okv9S7f/2rin8QiJNY+/sedA6W1MIBT/sy89c1oglbPgCN4u3pN6/Xo472YmaTLlRFDtFC6VnEpqNz+0O7oPFTZrfpoww+5S58f1YfnB3kYstraQfEgp321/w+CFIipGz5X2M1Fc0GU3eInUqfycq/7pxHCNs5p8+xrckiG0NH3UnCpX9FhbnAzsLmpl7wpCt9Yn3+gwn515O1pqnUsh1LW4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Ij6HqAU/feo/ebYlGJ5LI2683KfelwRmD1OG5S4D4pE=; b=VtoVOuVyJmwx9TPb+tOzenvLAM4OSjKMhoD5mYTS4L00UEoTgSnGue4Va95496SGJpXGKavsTKSQuQeDEWk3FIqPCmPkRH30VgPOkafbdMohPVqgLnpjRBgEiyVkc6roM0Gf31wA9cw/RIx1/jYUAz3gfQmU3mlvaFVCX2rqoXm2DCFDGXBYI8vKy4JvkZP3LdYgzoBQtAFDDhVWJtqFOczL+1R7WS0c0G85qYUus+PUx9bcUgdyDA4MuzzBtj6sG0UOkMUrajLeCRvOTNgTJwtsvzA3XtrdO3nKjyhEOK2o8NNwSSS/jSmhb83oBCt3Y0wCxrd2RgpKUast2enh0Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ij6HqAU/feo/ebYlGJ5LI2683KfelwRmD1OG5S4D4pE=; b=2oaGDo3U4VF/V9jemR3gZ0zHRRTLoK4oyU5xgY1WZ11B4Phen+S3kDSn0t2R/Ujbs8qqNV9ITMcscfu2wPcxF17T233M04tTpQq3oZ3wXVTDesfqvwj/BLx/efaxT8Vxc0XLx10uGMJrGoPr56lcBmH/Bb8qaaoOVijafI0eFdQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from CH2PR12MB4294.namprd12.prod.outlook.com (2603:10b6:610:a9::11) by SJ2PR12MB7798.namprd12.prod.outlook.com (2603:10b6:a03:4c0::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.19; Mon, 20 Feb 2023 22:57:35 +0000 Received: from CH2PR12MB4294.namprd12.prod.outlook.com ([fe80::3614:22ed:ed5:5b48]) by CH2PR12MB4294.namprd12.prod.outlook.com ([fe80::3614:22ed:ed5:5b48%8]) with mapi id 15.20.6111.020; Mon, 20 Feb 2023 22:57:35 +0000 Message-ID: Date: Mon, 20 Feb 2023 22:57:30 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Content-Language: en-US To: Levend Sayar , junfeng.guo@intel.com Cc: dev@dpdk.org References: <20230220151936.2716-1-levendsayar@gmail.com> <20230220211103.8282-1-levendsayar@gmail.com> <20230220211103.8282-2-levendsayar@gmail.com> From: Ferruh Yigit Subject: Re: [PATCH v3 2/2] net/gve: add Rx/Tx queue stats as extended stats In-Reply-To: <20230220211103.8282-2-levendsayar@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO6P123CA0034.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:2fe::16) To CH2PR12MB4294.namprd12.prod.outlook.com (2603:10b6:610:a9::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR12MB4294:EE_|SJ2PR12MB7798:EE_ X-MS-Office365-Filtering-Correlation-Id: cb23634a-35e2-4bac-70cd-08db1395dae0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0HYLdlF2JmtCl28w4cDv2XEMXoYDUmtXETA+UgtWMLpKpv9EWcwTh3xXVwVOXqKtAOUiD4KlQ2aupPhDZDpbwDgWRt6GPX69zjrIGwY/A5G1JHq00jIl/kvTramyuVjlW2qmIEP00Ul79C1SteX6ELoB2zP1NfAR3TQ+1zwvTiqHKNQMqqnmaBB7+pNgZOZGLgkiD0c6VE652wnn2tMew4OXwfKKgVXdvlf1r6REvnaDbj9TLCFLc6+nFptpIGZ1nNP6DmGsF1jn8mmtjh7XfnWu4EdBQPJkqEYayMoLOoG7h0bLKuAvcuVlPi6QNLIodXPx2s33QU3t8CyS+IlL4a1lxOgWwnbHd6VD54nnesDP0WVV3Tgjay7+KlbZCONpdA3Z7nOPOR29ROSM3pkrznkB38FrDUp3dAURhJ2RPspwdEkDbJ2bi+GGOTTn+AilZjDXATdo9XHJrdAyBWSAVuMTl7O49a4u4dUCK90te+kQxaUIPeySEvQtNy93oMCwfF40lZPmC59oqoWXxmhGy+lVqpkAs+Ouzu+4qYHAT7PM4ZjlhIfTfOeP7PhpKJSOuZ70Ui/GXTCAsBFk2xp6NiW4vsK6vn6I3DbGLL3NJu8cqfvLAzpN9GvSyIbjGnhveM2886tTgd1NtQFjmaBokqM2L8o0RWveeYm4BPae54CIG73itHLXXGiLQ2gVsxZvPfwwQ1vHVtZC3tK3MMeQoXEcw84EfMmbPNXVrzn8Qjo= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR12MB4294.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(4636009)(39860400002)(136003)(376002)(346002)(366004)(396003)(451199018)(478600001)(38100700002)(44832011)(31696002)(2906002)(86362001)(316002)(41300700001)(36756003)(5660300002)(83380400001)(2616005)(8936002)(66556008)(4326008)(8676002)(66476007)(66946007)(6506007)(26005)(186003)(31686004)(53546011)(6486002)(966005)(6512007)(6666004)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?QnhqU3BrRzFaMXJnWnBSeTNqckk2cVZ0UHFyTWM4WXRnRkFBbXd5elBuV1ZK?= =?utf-8?B?SldCcVRsZ245SC9YZUFzMDVXbmJ1QmV0QnpPQTh4alpRM3RMOTJIWHZQblZN?= =?utf-8?B?cEppSkU0NlpSckNqOGRLR0duYlZwRVNGRC9ZQWwrM3MrK0NaVllRQnFSQjFR?= =?utf-8?B?SlNRTVplN0UxWXc2U2p5YmpGV2pieFZzTmxlbjdoYnF3dHlIMkVBM09xV1JQ?= =?utf-8?B?ZnlJRE4yYmVGUVNHZ3pET0J0UWVQOWkrSG93YUQ4TDVuaS9FdHFjVmo3T1Y4?= =?utf-8?B?N2NKMEZWUWhsSF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NE9NbWVTWGhMcmFUckI2?= =?utf-8?Q?zcCyOMcc/3VtP9e7bZvsBR8pr?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: cb23634a-35e2-4bac-70cd-08db1395dae0 X-MS-Exchange-CrossTenant-AuthSource: CH2PR12MB4294.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2023 22:57:34.8754 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: xHUaw0wPaqW/q5kL88DZKcZaXsRKxgyxlOjdATYADRN5ZcOgrB0Wl3HaJAr5Fq6s X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB7798 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 On 2/20/2023 9:11 PM, Levend Sayar wrote: > Google Virtual NIC rx/tx queue stats are added as extended stats. > > Signed-off-by: Levend Sayar Thank you for the update, mainly looks good to me, there area a few minor questions/comments below. <...> > +static const struct gve_xstats_name_offset tx_xstats_name_offset[] = { > + { "packets", offsetof(struct gve_tx_stats, packets) }, > + { "bytes", offsetof(struct gve_tx_stats, bytes) }, > + { "errors", offsetof(struct gve_tx_stats, errors) }, > +}; > + It is possible to create macros to get offsets to prevent any mistakes but not quite sure if it is needed with above limited number of items, so up to you, I mean something like: #define RX_QUEUE_STATS_OFFSET(x) offsetof(struct gve_rx_stats, X) #define TX_QUEUE_STATS_OFFSET(x) offsetof(struct gve_tx_stats, X) > +static const struct gve_xstats_name_offset rx_xstats_name_offset[] = { > + { "packets", offsetof(struct gve_rx_stats, packets) }, > + { "bytes", offsetof(struct gve_rx_stats, bytes) }, > + { "errors", offsetof(struct gve_rx_stats, errors) }, > +}; > + Is 'no_mbufs' omitted intentionally? <...> > > +static int > +gve_xstats_count(struct rte_eth_dev *dev) > +{ > + uint16_t i, count = 0; > + > + for (i = 0; i < dev->data->nb_tx_queues; i++) { > + if (dev->data->tx_queues[i]) Normally 'dev->data->tx_queues[i]' shouldn't be NULL, but I can see driver checks this in a few locations. Is there a case that 'dev->data->tx_queues[i]' can be NULL where "0 <= i < dev->data->nb_tx_queues" ? > + count += RTE_DIM(tx_xstats_name_offset); > + } > + > + for (i = 0; i < dev->data->nb_rx_queues; i++) { > + if (dev->data->rx_queues[i]) > + count += RTE_DIM(rx_xstats_name_offset); > + } > + > + return count; > +} > + > +static int > +gve_xstats_get(struct rte_eth_dev *dev, > + struct rte_eth_xstat *xstats, > + unsigned int size) > +{ > + uint16_t i, count = 0; > + > + if (!xstats) > + return (size == 0) ? gve_xstats_count(dev) : -EINVAL; Error case (xstats == NULL && size != 0) should be handled by ethdev, so driver can only check "xstats == NULL" case. btw, although we have mixed usage and not very strict on it, coding convention requires testing against NULL [1] instead of '!'. [1] https://doc.dpdk.org/guides/contributing/coding_style.html#null-pointers > + > + for (i = 0; i < dev->data->nb_tx_queues; i++) { > + const struct gve_tx_queue *txq = dev->data->tx_queues[i]; > + if (!txq) > + continue; > + similar to above comment, I expect 'txq' not to be NULL, isn't this correct for the driver? > + if (count >= size) > + break; > + Instead of above check in a loop, it is possible to check once at the beginning of the function like count = gve_xstats_count(dev) if (size < count) return count; Because when there is not enough room in the xstats array, API doesn't expect existing elements of array to be correct, returning a value bigger than 'size' indicates error case and content of xstats is invalid anyway. > + uint16_t j = 0; > + const char *stats = (const char *)&txq->stats; Can you please move variable declarations at the beginning of the scope, for above variables it is just after for statement, according coding convention. > + for (j = 0; j < RTE_DIM(tx_xstats_name_offset); j++, count++) { > + xstats[count].id = count; > + xstats[count].value = *(const uint64_t *) > + (stats + tx_xstats_name_offset[j].offset); > + } > + } > + > + for (i = 0; i < dev->data->nb_rx_queues; i++) { > + const struct gve_rx_queue *rxq = dev->data->rx_queues[i]; > + if (!rxq) > + continue; > + > + if (count >= size) > + break; > + > + uint16_t j = 0; > + const char *stats = (const char *)&rxq->stats; > + for (j = 0; j < RTE_DIM(rx_xstats_name_offset); j++, count++) { > + xstats[count].id = count; > + xstats[count].value = *(const uint64_t *) > + (stats + rx_xstats_name_offset[j].offset); > + } > + } > + > + return count; > +} > + > +static int > +gve_xstats_get_names(struct rte_eth_dev *dev, > + struct rte_eth_xstat_name *xstats_names, > + unsigned int size) > +{ > + uint16_t i, count = 0; > + > + if (!xstats_names) > + return (size == 0) ? gve_xstats_count(dev) : -EINVAL; > + > + for (i = 0; i < dev->data->nb_tx_queues; i++) { > + if (!dev->data->tx_queues[i]) > + continue; > + > + if (count >= size) > + break; > + > + uint16_t j = 0; > + for (; j < RTE_DIM(tx_xstats_name_offset); j++) > + snprintf(xstats_names[count++].name, > + RTE_ETH_XSTATS_NAME_SIZE, > + "tx_q%u_%s", i, tx_xstats_name_offset[j].name); > + } > + > + for (i = 0; i < dev->data->nb_rx_queues; i++) { > + if (!dev->data->rx_queues[i]) > + continue; > + > + if (count >= size) > + break; > + > + uint16_t j = 0; > + for (; j < RTE_DIM(rx_xstats_name_offset); j++) > + snprintf(xstats_names[count++].name, > + RTE_ETH_XSTATS_NAME_SIZE, > + "rx_q%u_%s", i, rx_xstats_name_offset[j].name); > + } > + > + return count; > +} > + comments on 'gve_xstats_get()' valid here too.