From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id C64FFA053A; Sun, 12 Jul 2020 16:13:33 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1EBE01BFA4; Sun, 12 Jul 2020 16:13:29 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id D2B412B9A for ; Sun, 12 Jul 2020 16:13:26 +0200 (CEST) IronPort-SDR: dzxRzH49HHXUmxrnsFLiNGo4akupgzbPFGY1i0igij4zEJn1LMJaveaJy3XVM21EOnx4hTjvTw mYLMPg07y2DQ== X-IronPort-AV: E=McAfee;i="6000,8403,9680"; a="136676670" X-IronPort-AV: E=Sophos;i="5.75,343,1589266800"; d="scan'208";a="136676670" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jul 2020 07:13:25 -0700 IronPort-SDR: KXIGrbcc/9VYCZbNn261kKI3Js62GucalGTrU8K7YlpOOshcsgH5GDaYnibMWnWxE44GYow4nB jxLjIO5yVImg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,343,1589266800"; d="scan'208";a="429105305" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga004.jf.intel.com with ESMTP; 12 Jul 2020 07:13:25 -0700 Received: from fmsmsx116.amr.corp.intel.com (10.18.116.20) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 12 Jul 2020 07:13:24 -0700 Received: from FMSEDG001.ED.cps.intel.com (10.1.192.133) by fmsmsx116.amr.corp.intel.com (10.18.116.20) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 12 Jul 2020 07:13:24 -0700 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.103) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 12 Jul 2020 07:13:24 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d0rMAiIXmgnGv/Z3QvLPHYdYK3xLode1X6qhF2v6reE/f99pIDFJcBPVkR/F+9ShCgk0XsHN2udoxXZihI3B0M651xKG7hP6ToaN2ijqdiSAeeB95LqK7O8WB5Dr1r0ooSJhCMClBqkXvbeAmq7VBj2IuQuYX8YoishnDNXgwyz9KQHR8FM5uxLwwg+f0/7KOpbpSD6c02XTDIO4MugFBUFHN0Iqt/oCUruCigJxtSHM7fiT40VaUN8zjJjq9OlkAu9NnIDZSTWnZ4xXY1xJk9QjKQrb7WZiGMeFQIe0fr1Kfh3QzJz+lYxGqLa3YRDHBX2RuOHBQxtHnOQAMJAUNw== 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-SenderADCheck; bh=kDObIm933uiJ9NKOYT2LzYQvcYq/G03OyZyNINq20vc=; b=PKUcfW3R2DF5Lp4S1zQwyGI4xo0bCgVzK+iiEklZoDZ6CWobdkMc26xS9WSwxjie1mhiO3UBQHt9ptOHM3MdAqvHqqFmjNdadUGlfDwqPT3rjIjsteo/FlljAPgwldH8I8XD4yv0VSXXEJjSo41obnVYxHbwS4NG6AuMNWaDMujIip5rA2RbiD+7JliE97kjvdhC5wSds9oZgIP3MkeVdz/4bKZJTfhCEzTTkQhMP+4j4jhOLvqDz53HgJQxiBW6RPEuXq3Q1lW5JN//K4ekSZIo7cYfrlYo/nc+uypCXd4K9A3kbNiA07a5TuloqZ1bviwR0iwzXqCLCE2bwyY4Nw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kDObIm933uiJ9NKOYT2LzYQvcYq/G03OyZyNINq20vc=; b=iW3wq+lTMMcCziOqjmK7zHak9Bv6jCZmdqaCxl1RYz77cHl7d0y7zUrUQUvkj2Cd/mu1LyogbyUtOMPtKsosWZGwRjCd7Fq8vmAZjfHMAj7qwjOygXK+cxVaiNmnEII8GZmHVNFJXy8p1++CAXja1york8oBMX1KeGlq9pp2AGw= Received: from BYAPR11MB2901.namprd11.prod.outlook.com (2603:10b6:a03:91::23) by BYAPR11MB3814.namprd11.prod.outlook.com (2603:10b6:a03:fb::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21; Sun, 12 Jul 2020 14:13:22 +0000 Received: from BYAPR11MB2901.namprd11.prod.outlook.com ([fe80::6552:92f9:74a5:412]) by BYAPR11MB2901.namprd11.prod.outlook.com ([fe80::6552:92f9:74a5:412%4]) with mapi id 15.20.3174.025; Sun, 12 Jul 2020 14:13:22 +0000 From: "Xu, Rosen" To: "Richardson, Bruce" , Nipun Gupta , Hemant Agrawal CC: "dev@dpdk.org" , "Zhang, Tianfei" , "Li, Xiaoyun" , "Wu, Jingjing" , Satha Rao , Mahipal Challa , Jerin Jacob Thread-Topic: [PATCH 20.11 2/5] rawdev: allow drivers to return error from info function Thread-Index: AQHWVgSYQjKy8n7Gl0uJIA9zkKkfS6kEAR+g Date: Sun, 12 Jul 2020 14:13:21 +0000 Message-ID: References: <20200709152047.167730-1-bruce.richardson@intel.com> <20200709152047.167730-3-bruce.richardson@intel.com> In-Reply-To: <20200709152047.167730-3-bruce.richardson@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiODFjMDkxZmEtNmEzMy00ODljLTkzOWUtYjY3Y2I4MTZkYWJiIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoieGpDT3lDWERrdE0wNzFcL283dndDK1wvdGVCWGJcLzdqWUZaY1Ric0xzRWhBdU0zTnJhWTI1aTU0U0YxNFVlem1FKyJ9 x-ctpclassification: CTP_NT authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.198.147.202] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 21657272-c7c8-431d-3c55-08d8266dbc21 x-ms-traffictypediagnostic: BYAPR11MB3814: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3173; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: A8lqDSHO1MgIOB/DpMQ7o8lwX72u3W5knbnyQ0LIGu9Cks6UFyjYuYN8A16zH/RKDpEE9YfxhnZ+uOMW7mWkOhv2w2hkIx8Gs/xklrOnEzmXrQ44QlGoymv9xoVQr8ldONh9Iwd1LAb7Gb08vlE8ANpK/qoMQaRqntZ2+J8xEBT97Ir6kW8ySNWvacTjj8J8GbL+hWPkG2ZbZC1QjfO8B30PlWGuYmgvfm5RGrSwmeRebarYA0KnsnXTYiGGWcKhuR2mGHe2BdW5kHg9MwOEMQ2gh/L5bEq1FsBtKr8BnzyHT5bMbOaheAUtmdu1miOg9MS6LV/eCCd0tJk+I/FycQ== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR11MB2901.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(366004)(346002)(376002)(396003)(39860400002)(136003)(9686003)(26005)(66946007)(478600001)(54906003)(86362001)(76116006)(2906002)(53546011)(66476007)(6506007)(66556008)(66446008)(186003)(64756008)(110136005)(52536014)(5660300002)(71200400001)(7696005)(4326008)(8676002)(55016002)(33656002)(316002)(83380400001)(8936002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: XN+xAj5Y17WeVIpcDETTUIiQAxWmkp/OTg1RqqepziIWVSL1UfLIkrL6g2cq2SFA5hRxjA26vX4eUkatenvobxjbROQIeAsYarYjUFT4e/Ozz0Ihgw2Tn8LG4e5pYCk+toOKBctCXQCU2YL/v7ONAoJW5AhbduIB+dS3SnXDaIWA4WQWMynLKRo0JaH50cR4FDZ+ebU8QD1gV8dQ/sA11lT6IPWWhVSt6z/DaKag7ApZ1n+wm6x6oQg1pxTfcJ4FuRnxshthnky84Gt7+1ZhtvmjNYccvGuBJfJijKAt9TbMj662WkyCdvBUn7bW0MaX9BdzNsu3/WErpY4guL3P2pmX5skHBotPLDehzL2/HI8p266dVHKTSscxeD+xzZeunOVMTS1R7en+5JDpT7rX26M+3Zlit1iDGkuDzNfXfrlpT93P6NxkpcMFNIBM5XmDSVCm5WYcTvLJWtBCqBb8dukOXP6ldmluWzfZuvu0yBQN4LaH2onb/+GnEl6BpFzM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BYAPR11MB2901.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 21657272-c7c8-431d-3c55-08d8266dbc21 X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Jul 2020 14:13:21.9972 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 4BQ5W5m9abYTuN4fUZpBI2n9KwZIRDjEERX8cO7K2x0dSr5NhC0Z+H5WRX3kZx7roiHGy9ZjqCibqcDQA1pcvA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB3814 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH 20.11 2/5] rawdev: allow drivers to return error from info function X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" Hi, Reviewed-by: Rosen Xu > -----Original Message----- > From: Richardson, Bruce > Sent: Thursday, July 09, 2020 23:21 > To: Nipun Gupta ; Hemant Agrawal > > Cc: dev@dpdk.org; Xu, Rosen ; Zhang, Tianfei > ; Li, Xiaoyun ; Wu, Jingji= ng > ; Satha Rao ; Mahipal > Challa ; Jerin Jacob ; > Richardson, Bruce > Subject: [PATCH 20.11 2/5] rawdev: allow drivers to return error from inf= o > function >=20 > Since we now allow some parameter checking inside the driver info_get() > functions, it makes sense to allow error return from those functions to t= he > caller. Therefore we change the driver callback return type from void to = int. >=20 > Signed-off-by: Bruce Richardson > --- > drivers/raw/ifpga/ifpga_rawdev.c | 15 ++++++++------- > drivers/raw/ioat/ioat_rawdev.c | 9 ++++++--- > drivers/raw/ntb/ntb.c | 8 +++++--- > drivers/raw/skeleton/skeleton_rawdev.c | 6 ++++-- > lib/librte_rawdev/rte_rawdev.c | 6 ++++-- > lib/librte_rawdev/rte_rawdev_pmd.h | 4 ++-- > 6 files changed, 29 insertions(+), 19 deletions(-) >=20 > diff --git a/drivers/raw/ifpga/ifpga_rawdev.c > b/drivers/raw/ifpga/ifpga_rawdev.c > index 47cfa3877..32a2b96c9 100644 > --- a/drivers/raw/ifpga/ifpga_rawdev.c > +++ b/drivers/raw/ifpga/ifpga_rawdev.c > @@ -603,7 +603,7 @@ ifpga_fill_afu_dev(struct opae_accelerator *acc, > return 0; > } >=20 > -static void > +static int > ifpga_rawdev_info_get(struct rte_rawdev *dev, > rte_rawdev_obj_t dev_info, > size_t dev_info_size) > @@ -620,12 +620,12 @@ ifpga_rawdev_info_get(struct rte_rawdev *dev, >=20 > if (!dev_info || dev_info_size !=3D sizeof(*afu_dev)) { > IFPGA_RAWDEV_PMD_ERR("Invalid request"); > - return; > + return -EINVAL; > } >=20 > adapter =3D ifpga_rawdev_get_priv(dev); > if (!adapter) > - return; > + return -ENOENT; >=20 > afu_dev =3D dev_info; > afu_dev->rawdev =3D dev; > @@ -637,7 +637,7 @@ ifpga_rawdev_info_get(struct rte_rawdev *dev, >=20 > if (ifpga_fill_afu_dev(acc, afu_dev)) { > IFPGA_RAWDEV_PMD_ERR("cannot get info\n"); > - return; > + return -ENOENT; > } > } >=20 > @@ -647,21 +647,21 @@ ifpga_rawdev_info_get(struct rte_rawdev *dev, > /* get LineSide BAR Index */ > if (opae_manager_get_eth_group_region_info(mgr, 0, > &opae_lside_eth_info)) { > - return; > + return -ENOENT; > } > lside_bar_idx =3D opae_lside_eth_info.mem_idx; >=20 > /* get NICSide BAR Index */ > if (opae_manager_get_eth_group_region_info(mgr, 1, > &opae_nside_eth_info)) { > - return; > + return -ENOENT; > } > nside_bar_idx =3D opae_nside_eth_info.mem_idx; >=20 > if (lside_bar_idx >=3D PCI_MAX_RESOURCE || > nside_bar_idx >=3D PCI_MAX_RESOURCE || > lside_bar_idx =3D=3D nside_bar_idx) > - return; > + return -ENOENT; >=20 > /* fill LineSide BAR Index */ > afu_dev->mem_resource[lside_bar_idx].phys_addr =3D @@ - > 679,6 +679,7 @@ ifpga_rawdev_info_get(struct rte_rawdev *dev, > afu_dev->mem_resource[nside_bar_idx].addr =3D > opae_nside_eth_info.addr; > } > + return 0; > } >=20 > static int > diff --git a/drivers/raw/ioat/ioat_rawdev.c b/drivers/raw/ioat/ioat_rawde= v.c > index 8dd856c55..6a336795d 100644 > --- a/drivers/raw/ioat/ioat_rawdev.c > +++ b/drivers/raw/ioat/ioat_rawdev.c > @@ -112,15 +112,18 @@ ioat_dev_stop(struct rte_rawdev *dev) > RTE_SET_USED(dev); > } >=20 > -static void > +static int > ioat_dev_info_get(struct rte_rawdev *dev, rte_rawdev_obj_t dev_info, > size_t dev_info_size) > { > struct rte_ioat_rawdev_config *cfg =3D dev_info; > struct rte_ioat_rawdev *ioat =3D dev->dev_private; >=20 > - if (cfg !=3D NULL && dev_info_size =3D=3D sizeof(*cfg)) > - cfg->ring_size =3D ioat->ring_size; > + if (dev_info =3D=3D NULL || dev_info_size !=3D sizeof(*cfg)) > + return -EINVAL; > + > + cfg->ring_size =3D ioat->ring_size; > + return 0; > } >=20 > static const char * const xstat_names[] =3D { diff --git a/drivers/raw/n= tb/ntb.c > b/drivers/raw/ntb/ntb.c index 4676c6f8f..eaeb67b74 100644 > --- a/drivers/raw/ntb/ntb.c > +++ b/drivers/raw/ntb/ntb.c > @@ -800,7 +800,7 @@ ntb_dequeue_bufs(struct rte_rawdev *dev, > return nb_rx; > } >=20 > -static void > +static int > ntb_dev_info_get(struct rte_rawdev *dev, rte_rawdev_obj_t dev_info, > size_t dev_info_size) > { > @@ -809,7 +809,7 @@ ntb_dev_info_get(struct rte_rawdev *dev, > rte_rawdev_obj_t dev_info, >=20 > if (dev_info_size !=3D sizeof(*info)){ > NTB_LOG(ERR, "Invalid size parameter to %s", __func__); > - return; > + return -EINVAL; > } >=20 > info->mw_cnt =3D hw->mw_cnt; > @@ -824,7 +824,7 @@ ntb_dev_info_get(struct rte_rawdev *dev, > rte_rawdev_obj_t dev_info, >=20 > if (!hw->queue_size || !hw->queue_pairs) { > NTB_LOG(ERR, "No queue size and queue num assigned."); > - return; > + return -EAGAIN; > } >=20 > hw->hdr_size_per_queue =3D RTE_ALIGN(sizeof(struct ntb_header) + > @@ -832,6 +832,8 @@ ntb_dev_info_get(struct rte_rawdev *dev, > rte_rawdev_obj_t dev_info, > hw->queue_size * sizeof(struct ntb_used), > RTE_CACHE_LINE_SIZE); > info->ntb_hdr_size =3D hw->hdr_size_per_queue * hw->queue_pairs; > + > + return 0; > } >=20 > static int > diff --git a/drivers/raw/skeleton/skeleton_rawdev.c > b/drivers/raw/skeleton/skeleton_rawdev.c > index dc05f3ecf..dce300c35 100644 > --- a/drivers/raw/skeleton/skeleton_rawdev.c > +++ b/drivers/raw/skeleton/skeleton_rawdev.c > @@ -41,7 +41,7 @@ struct queue_buffers { static struct queue_buffers > queue_buf[SKELETON_MAX_QUEUES] =3D {}; static void clear_queue_bufs(int > queue_id); >=20 > -static void skeleton_rawdev_info_get(struct rte_rawdev *dev, > +static int skeleton_rawdev_info_get(struct rte_rawdev *dev, > rte_rawdev_obj_t dev_info, > size_t dev_info_size) > { > @@ -52,7 +52,7 @@ static void skeleton_rawdev_info_get(struct > rte_rawdev *dev, >=20 > if (!dev_info || dev_info_size !=3D sizeof(*skeldev_conf)) { > SKELETON_PMD_ERR("Invalid request"); > - return; > + return -EINVAL; > } >=20 > skeldev =3D skeleton_rawdev_get_priv(dev); @@ -63,6 +63,8 @@ > static void skeleton_rawdev_info_get(struct rte_rawdev *dev, > skeldev_conf->capabilities =3D skeldev->capabilities; > skeldev_conf->device_state =3D skeldev->device_state; > skeldev_conf->firmware_state =3D skeldev->fw.firmware_state; > + > + return 0; > } >=20 > static int skeleton_rawdev_configure(const struct rte_rawdev *dev, diff = -- > git a/lib/librte_rawdev/rte_rawdev.c b/lib/librte_rawdev/rte_rawdev.c > index a57689035..bde33763e 100644 > --- a/lib/librte_rawdev/rte_rawdev.c > +++ b/lib/librte_rawdev/rte_rawdev.c > @@ -82,6 +82,7 @@ rte_rawdev_info_get(uint16_t dev_id, struct > rte_rawdev_info *dev_info, > size_t dev_private_size) > { > struct rte_rawdev *rawdev; > + int ret =3D 0; >=20 > RTE_RAWDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL); > RTE_FUNC_PTR_OR_ERR_RET(dev_info, -EINVAL); @@ -90,7 +91,8 > @@ rte_rawdev_info_get(uint16_t dev_id, struct rte_rawdev_info > *dev_info, >=20 > if (dev_info->dev_private !=3D NULL) { > RTE_FUNC_PTR_OR_ERR_RET(*rawdev->dev_ops- > >dev_info_get, -ENOTSUP); > - (*rawdev->dev_ops->dev_info_get)(rawdev, dev_info- > >dev_private, > + ret =3D (*rawdev->dev_ops->dev_info_get)(rawdev, > + dev_info->dev_private, > dev_private_size); > } >=20 > @@ -98,7 +100,7 @@ rte_rawdev_info_get(uint16_t dev_id, struct > rte_rawdev_info *dev_info, > dev_info->device =3D rawdev->device; > dev_info->socket_id =3D rawdev->socket_id; >=20 > - return 0; > + return ret; > } >=20 > int > diff --git a/lib/librte_rawdev/rte_rawdev_pmd.h > b/lib/librte_rawdev/rte_rawdev_pmd.h > index 0e72a9205..89e46412a 100644 > --- a/lib/librte_rawdev/rte_rawdev_pmd.h > +++ b/lib/librte_rawdev/rte_rawdev_pmd.h > @@ -142,9 +142,9 @@ rte_rawdev_pmd_is_valid_dev(uint8_t dev_id) > * The size of the structure pointed to by dev_info->dev_private > * > * @return > - * Returns 0 on success > + * Returns 0 on success, negative error code on failure > */ > -typedef void (*rawdev_info_get_t)(struct rte_rawdev *dev, > +typedef int (*rawdev_info_get_t)(struct rte_rawdev *dev, > rte_rawdev_obj_t dev_info, > size_t dev_private_size); >=20 > -- > 2.25.1