From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (xvm-189-124.dc0.ghst.net [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C75F4A09FF; Thu, 7 Jan 2021 08:18:56 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 87445140E95; Thu, 7 Jan 2021 08:18:56 +0100 (CET) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id 12398140E92 for ; Thu, 7 Jan 2021 08:18:54 +0100 (CET) IronPort-SDR: HecF1IwqsWn/8mi6PbZgGP5J8idSuwTXGW6VamCVqMzd7Et/ObyJRGsM/i0u4ul6nhoUsgxAwG 3yAIIUKGXLrw== X-IronPort-AV: E=McAfee;i="6000,8403,9856"; a="165084153" X-IronPort-AV: E=Sophos;i="5.79,329,1602572400"; d="scan'208";a="165084153" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jan 2021 23:18:53 -0800 IronPort-SDR: Gp7v9lVEnZ3A3ofSE9Xui81cLpfwBOOUy8W1wzxOW1eYD7P9t/1XsK602eHqC5XzGWJ9+ANltC SsZ63sLv0vRw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.79,329,1602572400"; d="scan'208";a="350473950" Received: from fmsmsx604.amr.corp.intel.com ([10.18.126.84]) by orsmga006.jf.intel.com with ESMTP; 06 Jan 2021 23:18:53 -0800 Received: from fmsmsx609.amr.corp.intel.com (10.18.126.89) by fmsmsx604.amr.corp.intel.com (10.18.126.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 6 Jan 2021 23:18:52 -0800 Received: from fmsmsx606.amr.corp.intel.com (10.18.126.86) by fmsmsx609.amr.corp.intel.com (10.18.126.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 6 Jan 2021 23:18:52 -0800 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Wed, 6 Jan 2021 23:18:52 -0800 Received: from NAM02-BL2-obe.outbound.protection.outlook.com (104.47.38.56) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Wed, 6 Jan 2021 23:18:52 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=On1f3fn/rZJByJfmS0o+44eLl9nlEJWRc2iVgd8YHlSNeGkCdQ9lx+wZm56xwRe0lQzOrw8cJpV2tcTBzG53Jsx0KmmS1QnD/cy1GXKK4lSiPIL1fwZimEaZ5rL5pLM03pEl703rL4z5h/RsE3pU8um2sPgV4GgVeubG7tVJ2hLhVR7TmEmWmcEeQgVQAMoDmOUURBaHZWtGaamZgcmPLqcNLmTXrPPK7mAveX2utB4dpaDiw1Q76a3KuFL+kTkmEzdFqa6z3gs9i2E8yDXi4WNabukkhBjuKe9qkPENJVsfizTxAQI5WK1TCaTli+hemY2A+IC0RQiuzvh0E40+2Q== 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=xQeZvlVEO+Db0tBSHsdnr7CXmeSJST6Y/uKfteczaOY=; b=Oq8rlTGnfbXFoGGLPwOT9IqSxUPAPylVSiZpR788xDwqi7AXClhp1kiqOZ/TYq8MJptIMszlnuw+U6xkR0V4ssznvDak8CXN/ZF/W7u/jyySu8T6qM1mqhLIxeKNGlK0xhy6iuybnmQmQ5G/J7hkVxAN0r2+LRc/MA6+QGsQOXeBtL9QZnwqNky/HmS4Ru8+RhNRcUqSGPjNJPT02/f9x8e/ZhYtoBKLsT4fck1iE18dXf207356sYLUFO3aOJdQRyomPfTo2bBwQqeLTa/notkxEsnu0Osa55XCNGBTYPeorKOict88Y3e9D0gznF4o3MAenOs8BLAu1lsWCm+42Q== 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=xQeZvlVEO+Db0tBSHsdnr7CXmeSJST6Y/uKfteczaOY=; b=ls+G923j7odvuoeJ30hlsxX70X6kWQwdfjzB5oBdwVYqyVKxkHnYYoynIA7QDygyN4G08zWGRQbORXlmS84xcY509+WAliG2Fp3sQnFZA05EuenYD3iLlVaK4ANiIwxKFO04CiRTeg5y47s5WUzEFsMixk1K3GAy/TgA34Qkdvw= Received: from MN2PR11MB3807.namprd11.prod.outlook.com (2603:10b6:208:f0::24) by MN2PR11MB3919.namprd11.prod.outlook.com (2603:10b6:208:13b::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Thu, 7 Jan 2021 07:18:50 +0000 Received: from MN2PR11MB3807.namprd11.prod.outlook.com ([fe80::4d7f:d51:79bc:e596]) by MN2PR11MB3807.namprd11.prod.outlook.com ([fe80::4d7f:d51:79bc:e596%4]) with mapi id 15.20.3721.024; Thu, 7 Jan 2021 07:18:50 +0000 From: "Xing, Beilei" To: "Xia, Chenbo" , "dev@dpdk.org" , "thomas@monjalon.net" , "david.marchand@redhat.com" CC: "stephen@networkplumber.org" , "Liang, Cunming" , "Lu, Xiuchun" , "Li, Miao" , "Wu, Jingjing" Thread-Topic: [dpdk-dev] [PATCH 4/8] emu/iavf: add vfio-user device register and unregister Thread-Index: AQHW1RRzAeKKO1p1hUui3T0ydpCqAKob3kew Date: Thu, 7 Jan 2021 07:18:50 +0000 Message-ID: References: <20201218074736.93999-1-chenbo.xia@intel.com> <20201218074736.93999-5-chenbo.xia@intel.com> In-Reply-To: <20201218074736.93999-5-chenbo.xia@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: 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.102.204.36] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e1608b1d-2fd5-4ca0-ff21-08d8b2dc7b94 x-ms-traffictypediagnostic: MN2PR11MB3919: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1850; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: UFxTPQT6pHlI5LIOTxQEWxumqSX+jMCtL4v2ysnqFzMoZ0V2MwHJ6lUt6IU2stmY4AkSPjLHXOJekIII5u+EojwG0AMdvgwvti5upe87cpFxL7K196v9kYESRFH90d3Whle6LzYsSqAlzg+f+tYTblr8SuIOqiVpwobOQ3mpGUy77g5wAvSxIMTw2CeI9dW2ah8q8zg0YZ/3Bjj1WS9ixKj1tUL+UqxnbvE2Gy9+iKqG29iUC3nfaKkP9FV1WOiB5qf9AgKkHpvGl+l5u5ilk4FZBwXu/flJSqYXMRl2wawLnt/rf8vW9IxXg0zhCf0PTMxbqB4yIgwz+KTV5sQEN8zUi5QJ9JnnGFjb5GrOqBVfRAfwRlt337ryMKmS1gg6QVN9xa1pOhAwNSEKP8yy9UuKSk/v4wjdM/SBxUGFyuYWY5dbXqgsiheFdTa4u+aW x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MN2PR11MB3807.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(39860400002)(396003)(376002)(346002)(136003)(9686003)(107886003)(55016002)(5660300002)(7696005)(26005)(316002)(66446008)(64756008)(52536014)(2906002)(8936002)(76116006)(66476007)(53546011)(6506007)(83380400001)(54906003)(110136005)(478600001)(33656002)(71200400001)(186003)(66556008)(4326008)(86362001)(66946007)(21314003); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?quTkx0ZNxUrhjGYAJEVJNcIdtE/93EpBrfLcyp8TdJnV7G32Z3LnOMUiAOFM?= =?us-ascii?Q?MJIpjPq4Qw000iOFxMp+IqLqX6/wUwvQzBeN3jrpAaTzSpo4vygB5sP8FzwR?= =?us-ascii?Q?2OtgkDXG0ZTku6nCC7BnJpfHcvngrgPSBhQX7QToineL0n5EFTGdNzubIBwd?= =?us-ascii?Q?lvtAHGcPpTY8Rz/kLEsqdlS1l9EBFp3R3+L4d0ifu7aKNaThUKfsL9DhEXJC?= =?us-ascii?Q?gEepoUvZ15flYU0beGELBpMhhiMmcDyZwBbWHq95Om5hLudpzCRLHRbD4tx5?= =?us-ascii?Q?r5r4CSShxjCB1nGb54CZJZusUihzkbrYzsAN+SbQdMUIezRGjigKuOe1hX+O?= =?us-ascii?Q?67hqXoRXmOuNcfQC5d4dnd/lWSLC0O9oKwD15Zzz66VvhY1oZPHT73GbjpqB?= =?us-ascii?Q?Z3pjyFYKzSYtEQHVJOStmPSwTiX1+PcG44LGvQw8MbxkFnxzCGR407AaGiTM?= =?us-ascii?Q?KooAVcfVaT3WZuEALndOkgZilR4pgejkmlgg1sToKtTrAFCwhd2iBzyHGLdH?= =?us-ascii?Q?ru/k0QPt72ghXuEvNT8ZpBp73dT2BbDMoJPl8GXs36kIkP7hXoVztEzYaDJz?= =?us-ascii?Q?DIC9U/bf90XbaNd9RzQWzWAZpLs3Bod/mjtgrzooR2uZL1lkSBEZKOc2hn8E?= =?us-ascii?Q?taJ+2S6ZuGJzv+PobB1BZMjr4B2JwP2mqAWhzV+2pYcwy1lzLRM06iAI2esf?= =?us-ascii?Q?wP30xuw2T2W9qwovDaxJmx+p4qQjv1nAJbBPjDN5vs6X/AjYSXQkIAm1Ddxf?= =?us-ascii?Q?q4rDqbtCg/F6STlTg97YKveM9p6/OingDe/DEF5r562bNmxdSmbKayYpc0SZ?= =?us-ascii?Q?VS4Lq0ZfqKa67U1XiMv9ODcSCLw8EGyu6MdQln9YdbYOyfywaHiHfYCUlDET?= =?us-ascii?Q?8IKbcx8RfYYMSKj9lIXzsgCdLnADT3y/Njz2mb8zXEndDIjmt/aE/t7K38mv?= =?us-ascii?Q?c5JVf1bQeSvdEhtugpNLo5dzByrfFzcU/bIxQdWSWM0=3D?= 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: MN2PR11MB3807.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e1608b1d-2fd5-4ca0-ff21-08d8b2dc7b94 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Jan 2021 07:18:50.7377 (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: XF1CwEIa1PkrBr3yMKLvXJjhSv+L8iaaWAtakuVjClOl4BZB7Btfhi0rNFY7o1mRuPzt2QQuKp6q5R78CME7og== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3919 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH 4/8] emu/iavf: add vfio-user device register and unregister 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" > -----Original Message----- > From: dev On Behalf Of Chenbo Xia > Sent: Friday, December 18, 2020 3:48 PM > To: dev@dpdk.org; thomas@monjalon.net; david.marchand@redhat.com > Cc: stephen@networkplumber.org; Liang, Cunming > ; Lu, Xiuchun ; Li, Miao > ; Wu, Jingjing > Subject: [dpdk-dev] [PATCH 4/8] emu/iavf: add vfio-user device register a= nd > unregister >=20 > This patch adds vfio-user APIs call in driver probe and remove. > rte_vfio_user_register() and rte_vfio_user_unregister() are called to > create/destroy a vfio-user device. Notify callbacks that libvfio_user def= ines are > also implemented. >=20 > Signed-off-by: Chenbo Xia > Signed-off-by: Miao Li > --- > +static struct iavf_emudev *find_iavf_with_dev_id(int vfio_dev_id) { It's better to change the function name to follow other function names' sty= le. iavf_emu_xxx=20 > + struct iavf_emu_sock_list *list; > + char sock_addr[PATH_MAX]; > + int ret; > + > + ret =3D rte_vfio_get_sock_addr(vfio_dev_id, sock_addr, > + sizeof(sock_addr)); > + if (ret) { > + EMU_IAVF_LOG(ERR, "Can not find vfio device %d " > + "sock_addr.\n", vfio_dev_id); > + return NULL; > + } > + > + list =3D iavf_emu_find_sock_list(sock_addr); > + if (!list) { > + EMU_IAVF_LOG(ERR, "Can not find sock list.\n"); > + return NULL; > + } > + > + return (struct iavf_emudev *)list->emu_dev->priv_data; } It's better to check if list->emu_dev is NULL first. > + > +static int iavf_emu_new_device(int vfio_dev_id) { > + struct iavf_emudev *dev; > + int ret; > + > + dev =3D find_iavf_with_dev_id(vfio_dev_id); > + if (!dev) > + return -1; > + > + dev->vfio->dev_id =3D vfio_dev_id; > + > + ret =3D iavf_emu_setup_mem_table(dev); > + if (ret) { > + EMU_IAVF_LOG(ERR, "Failed to set up memtable for " > + "device %d", dev->vfio->dev_id); > + return ret; > + } > + > + ret =3D iavf_emu_setup_irq(dev); > + if (ret) { > + EMU_IAVF_LOG(ERR, "Failed to set up irq for " > + "device %d", dev->vfio->dev_id); > + return ret; > + } > + > + ret =3D iavf_emu_setup_queues(dev); > + if (ret) { > + EMU_IAVF_LOG(ERR, "Failed to set up queues for " > + "device %d", dev->vfio->dev_id); > + return ret; > + } > + > + ret =3D dev->ops->device_ready(dev->edev); Same as above, and please also check other functions, such as device_destro= y... > + if (ret) > + return ret; > + > + dev->ready =3D 1; > + return 0; > +} > + > +static void iavf_emu_destroy_device(int vfio_dev_id) { > + struct iavf_emudev *dev; > + > + dev =3D find_iavf_with_dev_id(vfio_dev_id); > + if (!dev) > + return; > + > + iavf_emu_reset_all_resources(dev); Should we add 'dev->ready =3D 0' here? > + > + dev->ops->device_destroy(dev->edev); > +} > + > +static int iavf_emu_lock_datapath(int vfio_dev_id, int lock) { > + struct iavf_emudev *dev; > + > + dev =3D find_iavf_with_dev_id(vfio_dev_id); > + if (!dev) > + return -1; > + > + return dev->ops->lock_dp(dev->edev, lock); } > + > +static int iavf_emu_reset_device(int vfio_dev_id) { > + struct iavf_emudev *dev; > + > + dev =3D find_iavf_with_dev_id(vfio_dev_id); > + if (!dev) > + return -1; > + > + iavf_emu_reset_all_resources(dev); Should we add 'dev->ready =3D 0' here? > + > + return dev->ops->reset_device(dev->edev); > +} > +