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 00801A04DB; Fri, 16 Oct 2020 07:42:17 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6203E1D639; Fri, 16 Oct 2020 07:42:16 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id A8DA21D404 for ; Fri, 16 Oct 2020 07:42:13 +0200 (CEST) IronPort-SDR: NGPCNYFp9cE69uTSe/9ifbILrgeNzs85D5x+STXu4FWTylybaTmu4mL4jc4Lqf11p8/EZoBGnH Qow6aiMqKd2w== X-IronPort-AV: E=McAfee;i="6000,8403,9775"; a="251227057" X-IronPort-AV: E=Sophos;i="5.77,381,1596524400"; d="scan'208";a="251227057" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Oct 2020 22:42:11 -0700 IronPort-SDR: conYvWk3woCJq/aHVF2cJRn0bNLhJh7ifkHWQJBcYcdjzoMwT/x2BpscS7DT8QnyZ6PYIc546r I685OUsodIpw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,381,1596524400"; d="scan'208";a="331060591" Received: from orsmsx605.amr.corp.intel.com ([10.22.229.18]) by orsmga002.jf.intel.com with ESMTP; 15 Oct 2020 22:42:11 -0700 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX605.amr.corp.intel.com (10.22.229.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Thu, 15 Oct 2020 22:42:10 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Thu, 15 Oct 2020 22:42:10 -0700 Received: from NAM04-CO1-obe.outbound.protection.outlook.com (104.47.45.57) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Thu, 15 Oct 2020 22:42:10 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a9BldTVbkIlm+040YN36gx1Di/KteGcr2L2W9B2uCTQedEix/VzkUmcDLukrU4vRPJprOBeTIM1OgQcp4gufeR3QhSODaAofffVBmSE7SEhXH/s5lRj157waBzte5zVtUb+qeBD/8JuVqBs2r14ecUt6xViZJnmJCOhCkKmFFwoNFsFC8tVe+g+zGijEGrUMpLSzyhrfqhg3X6MR09tYhUlWKCALjdkQMWfQNdkZSwQ8Er/M3JUgRiN4ZCaxO1YMZmZAIr7Ms2Q4kv26DHpKbbxcJibxr0U/Mfs+Wr/olaj1B5MSHCpDcI0Uw4eVtRmLn6f3N1TqnzP7fTLE8rwr6Q== 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=epv+7cQPZN2bAHzgoegy6tpxCy87BoQVqlEagoR4mU0=; b=B5poS7ZwcmQeEW9DYXvmSVT5a//dwmef7omymvSNhXqHdg+KHKO8LyauxUBlbiKNaxn8sU1tEzPRrXDWUjDbnUNY7kkLnK2N3RFO8OgP2YOLWinrCYPubl9ZS9RMw++yX+vDrjEAVCFfimY/1aXFUlpjlwJjqkwsyZw1TqnX/jmgeROzTWc2KvCnp2hbTgczLIMKTPAURPN/w/va9WZqpsV/JXkfiRYdrXH8iqHINs8QtrhKEuYfAsFfXVCG4/3vJVNERnvFbvXDpAupEY1cz/hoZv1Bi54Xdr2LAtXJiDWbddJ3QOU6XyoJLAgfrQQ+0E1tdQ8Icq8735+u4hJbiw== 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=epv+7cQPZN2bAHzgoegy6tpxCy87BoQVqlEagoR4mU0=; b=SVdW64C9vabnlp4GoBNWRrqHXhsYgbWmsFCgE7x/w2/BrFRrOQcQFnJToBzlt5bMF4cLY4Htd0OKY+S1zdMgjhQy1YdPLzOI2DXrJbKXVkgMQ6v5IpHdrqGgcB+y3GKyEMxywzpoTtsEZFPQKWQKf1Qp7pfX55fkWdCOqur9fos= Received: from BYAPR11MB2648.namprd11.prod.outlook.com (2603:10b6:a02:c7::10) by BYAPR11MB2744.namprd11.prod.outlook.com (2603:10b6:a02:c8::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.24; Fri, 16 Oct 2020 05:42:09 +0000 Received: from BYAPR11MB2648.namprd11.prod.outlook.com ([fe80::990c:c0a1:b470:1916]) by BYAPR11MB2648.namprd11.prod.outlook.com ([fe80::990c:c0a1:b470:1916%6]) with mapi id 15.20.3477.021; Fri, 16 Oct 2020 05:42:09 +0000 From: "Wang, Yinan" To: Maxime Coquelin , "dev@dpdk.org" , "Xia, Chenbo" , "Fu, Patrick" , "amorenoz@redhat.com" Thread-Topic: [dpdk-dev] [PATCH v3 3/8] net/virtio: move backend type selection to ethdev Thread-Index: AQHWlnvV8UzSLAoMzEaf98ns6JWpQKmZzMXg Date: Fri, 16 Oct 2020 05:42:09 +0000 Message-ID: References: <20200929161404.124580-1-maxime.coquelin@redhat.com> <20200929161404.124580-4-maxime.coquelin@redhat.com> In-Reply-To: <20200929161404.124580-4-maxime.coquelin@redhat.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-reaction: no-action dlp-version: 11.5.1.3 dlp-product: dlpe-windows authentication-results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.102.204.37] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 03b96dc3-fc0d-4f1a-fde1-08d871963940 x-ms-traffictypediagnostic: BYAPR11MB2744: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2089; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: UJmG58Yuv+63dF4Go9zXbT9Pe5zbzJPY1fEmio9YTur/XqJe+MjzDakZx+dtWmMCCej9MciZevQxnG12qxTlU35ZeWp332pEbnsZiQvOp3pVOQovsIOdUClUrjClXuo3O09pY0/5ENCYiTCnOq2iWV/AChTFfBmiBkQph0ysxAKCAFeiD3dC96Xdk1fV7zgRrB+3ZYz4DqdJplyBrWxF2tINSlViC2vhURr/Dv8Lg9eeI8pbZqJlFNf4Fr9HAIurJWwGTEyTl7LHGt2tw0LtkRvR+3N1Ij7GGS1PgIfeXL2j81zVg0+GtU55I30psH45bhQUuOqLUikL5f/yMDmBeP+QfxNifuZjvd8LLDPYy27oEvqDGRHZOlVygmW9YvM5/vXCRasf35CGYhJuoCaYrw== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR11MB2648.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(376002)(396003)(136003)(366004)(39860400002)(26005)(33656002)(55016002)(9686003)(52536014)(5660300002)(8936002)(86362001)(6506007)(316002)(71200400001)(66946007)(66556008)(110136005)(83380400001)(478600001)(76116006)(53546011)(186003)(66476007)(7696005)(966005)(66446008)(2906002)(64756008); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: KbDXIWdKlZHu1IqSoWAw/lVmOXCeqlUFLMvsVaDadhmcwd7m5MasZ5gwzlC1R5hBSEH6fmfDBu0RH4eEt2z36HT5aMHk4aFgCA6ULF5+CoWK9flRRo5GMh829l9Bfcrbd/4YTuEhCHvW0C5/1QV7w1aPR2BRVhRdzDU2aLYvefWlwHYH3X5CKEA93BTKaLNhkJ4vBh6fNh3t8h5UZX7h0U07jXeb/Unl2SNGKfP0iJ4pxXbTFj/AvNRpP3PazgHhiVpN65/VXvRDl8IEIgVKu2p5+xsoKAVDo1BrnuBA6KJB4OV9O3WQh2IqpStrOlhqfRCEmJ0CPbxN76cBPN9vGohKFsJa0ne7HsbcDMTLiiWZcP7WD6UlYFnLKiPI+i6UuE7fEpqNx7+S9sryFkWdWnbwW1Sk/SWC0qqWFBTz2a5fWGTHpHhUM2uD2eH7hCZ+IIe4ucRMx0NMHCbOedjaSjNnloSDcG2Nnm17OrITA8mmV2X+dGnfWHxMZwsXk9/BE7Fiiq9CvOKXf8Y7xbkIUqRH+J3Lw5dzjjzECY+NNt1XgvueodDV7k8V4vNmBTMTzVjsI3wZ2LJo8dKz7mw94bAKHQ30jr9zemYLlNedQK+tHCVLW/StckrXxJ0uyIrXVCvuaI+7L/j7tvrq/8SLSw== Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BYAPR11MB2648.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 03b96dc3-fc0d-4f1a-fde1-08d871963940 X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Oct 2020 05:42:09.0929 (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: p3FGVwrlacwlPxQeewVtkIIl9XPxgWPVfniMpUHJcFBNzBRFJ3hRi3ESPX4vjSOGwnaAwlgMpXWhMo9sVFvqXQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB2744 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v3 3/8] net/virtio: move backend type selection to ethdev 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 Adrian, This patch introduce a regression issue that vhost-user can't launch with s= erver mode, details in https://bugs.dpdk.org/show_bug.cgi?id=3D559. This issue blocked amount of regression cases, could you help to take a loo= k? Thanks in advance! BR, Yinan > -----Original Message----- > From: dev On Behalf Of Maxime Coquelin > Sent: 2020?9?30? 0:14 > To: dev@dpdk.org; Xia, Chenbo ; Fu, Patrick > ; amorenoz@redhat.com > Cc: Maxime Coquelin > Subject: [dpdk-dev] [PATCH v3 3/8] net/virtio: move backend type selectio= n to > ethdev >=20 > From: Adrian Moreno >=20 > This is a preparation patch with no functional change. >=20 > Use an enum instead of a boolean for the backend type. > Move the detection logic to the ethdev layer (where it is needed for the > first time). > The virtio_user_dev stores the backend type in the virtio_user_dev > struct so the type is only determined once >=20 > Signed-off-by: Maxime Coquelin > Signed-off-by: Adrian Moreno > --- > .../net/virtio/virtio_user/virtio_user_dev.c | 37 ++++++++----------- > .../net/virtio/virtio_user/virtio_user_dev.h | 11 +++++- > drivers/net/virtio/virtio_user_ethdev.c | 28 +++++++++++++- > 3 files changed, 50 insertions(+), 26 deletions(-) >=20 > diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c > b/drivers/net/virtio/virtio_user/virtio_user_dev.c > index 2a0c861085..b79a9f84aa 100644 > --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c > +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c > @@ -111,17 +111,6 @@ virtio_user_queue_setup(struct virtio_user_dev *dev, > return 0; > } >=20 > -int > -is_vhost_user_by_type(const char *path) > -{ > - struct stat sb; > - > - if (stat(path, &sb) =3D=3D -1) > - return 0; > - > - return S_ISSOCK(sb.st_mode); > -} > - > int > virtio_user_start_device(struct virtio_user_dev *dev) > { > @@ -144,7 +133,8 @@ virtio_user_start_device(struct virtio_user_dev *dev) > rte_mcfg_mem_read_lock(); > pthread_mutex_lock(&dev->mutex); >=20 > - if (is_vhost_user_by_type(dev->path) && dev->vhostfd < 0) > + if (dev->backend_type =3D=3D VIRTIO_USER_BACKEND_VHOST_USER && > + dev->vhostfd < 0) > goto error; >=20 > /* Step 0: tell vhost to create queues */ > @@ -360,16 +350,16 @@ virtio_user_dev_setup(struct virtio_user_dev *dev) > dev->tapfds =3D NULL; >=20 > if (dev->is_server) { > - if (access(dev->path, F_OK) =3D=3D 0 && > - !is_vhost_user_by_type(dev->path)) { > - PMD_DRV_LOG(ERR, "Server mode doesn't support > vhost-kernel!"); > + if (dev->backend_type !=3D > VIRTIO_USER_BACKEND_VHOST_USER) { > + PMD_DRV_LOG(ERR, "Server mode only supports > vhost-user!"); > return -1; > } > dev->ops =3D &virtio_ops_user; > } else { > - if (is_vhost_user_by_type(dev->path)) { > + if (dev->backend_type =3D=3D > VIRTIO_USER_BACKEND_VHOST_USER) { > dev->ops =3D &virtio_ops_user; > - } else { > + } else if (dev->backend_type =3D=3D > + > VIRTIO_USER_BACKEND_VHOST_KERNEL) { > dev->ops =3D &virtio_ops_kernel; >=20 > dev->vhostfds =3D malloc(dev->max_queue_pairs * > @@ -430,7 +420,8 @@ virtio_user_dev_setup(struct virtio_user_dev *dev) > int > virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues= , > int cq, int queue_size, const char *mac, char **ifname, > - int server, int mrg_rxbuf, int in_order, int packed_vq) > + int server, int mrg_rxbuf, int in_order, int packed_vq, > + enum virtio_user_backend_type backend_type) > { > uint64_t protocol_features =3D 0; >=20 > @@ -445,6 +436,8 @@ virtio_user_dev_init(struct virtio_user_dev *dev, cha= r > *path, int queues, > dev->frontend_features =3D 0; > dev->unsupported_features =3D ~VIRTIO_USER_SUPPORTED_FEATURES; > dev->protocol_features =3D > VIRTIO_USER_SUPPORTED_PROTOCOL_FEATURES; > + dev->backend_type =3D backend_type; > + > parse_mac(dev, mac); >=20 > if (*ifname) { > @@ -457,7 +450,7 @@ virtio_user_dev_init(struct virtio_user_dev *dev, cha= r > *path, int queues, > return -1; > } >=20 > - if (!is_vhost_user_by_type(dev->path)) > + if (dev->backend_type !=3D VIRTIO_USER_BACKEND_VHOST_USER) > dev->unsupported_features |=3D > (1ULL << VHOST_USER_F_PROTOCOL_FEATURES); >=20 > @@ -539,7 +532,7 @@ virtio_user_dev_init(struct virtio_user_dev *dev, cha= r > *path, int queues, > } >=20 > /* The backend will not report this feature, we add it explicitly */ > - if (is_vhost_user_by_type(dev->path)) > + if (dev->backend_type =3D=3D VIRTIO_USER_BACKEND_VHOST_USER) > dev->frontend_features |=3D (1ull << VIRTIO_NET_F_STATUS); >=20 > /* > @@ -792,7 +785,7 @@ virtio_user_send_status_update(struct virtio_user_dev > *dev, uint8_t status) > uint64_t arg =3D status; >=20 > /* Vhost-user only for now */ > - if (!is_vhost_user_by_type(dev->path)) > + if (dev->backend_type !=3D VIRTIO_USER_BACKEND_VHOST_USER) > return 0; >=20 > if (!(dev->protocol_features & (1ULL << > VHOST_USER_PROTOCOL_F_STATUS))) > @@ -815,7 +808,7 @@ virtio_user_update_status(struct virtio_user_dev *dev= ) > int err; >=20 > /* Vhost-user only for now */ > - if (!is_vhost_user_by_type(dev->path)) > + if (dev->backend_type !=3D VIRTIO_USER_BACKEND_VHOST_USER) > return 0; >=20 > if (!(dev->protocol_features & (1UL << > VHOST_USER_PROTOCOL_F_STATUS))) > diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.h > b/drivers/net/virtio/virtio_user/virtio_user_dev.h > index 9377d5ba66..575bf430c0 100644 > --- a/drivers/net/virtio/virtio_user/virtio_user_dev.h > +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.h > @@ -10,6 +10,12 @@ > #include "../virtio_pci.h" > #include "../virtio_ring.h" >=20 > +enum virtio_user_backend_type { > + VIRTIO_USER_BACKEND_UNKNOWN, > + VIRTIO_USER_BACKEND_VHOST_USER, > + VIRTIO_USER_BACKEND_VHOST_KERNEL, > +}; > + > struct virtio_user_queue { > uint16_t used_idx; > bool avail_wrap_counter; > @@ -17,6 +23,7 @@ struct virtio_user_queue { > }; >=20 > struct virtio_user_dev { > + enum virtio_user_backend_type backend_type; > /* for vhost_user backend */ > int vhostfd; > int listenfd; /* listening fd */ > @@ -60,13 +67,13 @@ struct virtio_user_dev { > bool started; > }; >=20 > -int is_vhost_user_by_type(const char *path); > int virtio_user_start_device(struct virtio_user_dev *dev); > int virtio_user_stop_device(struct virtio_user_dev *dev); > int virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int qu= eues, > int cq, int queue_size, const char *mac, char **ifname, > int server, int mrg_rxbuf, int in_order, > - int packed_vq); > + int packed_vq, > + enum virtio_user_backend_type backend_type); > void virtio_user_dev_uninit(struct virtio_user_dev *dev); > void virtio_user_handle_cq(struct virtio_user_dev *dev, uint16_t queue_i= dx); > void virtio_user_handle_cq_packed(struct virtio_user_dev *dev, > diff --git a/drivers/net/virtio/virtio_user_ethdev.c > b/drivers/net/virtio/virtio_user_ethdev.c > index 60d17af888..38b49bad5f 100644 > --- a/drivers/net/virtio/virtio_user_ethdev.c > +++ b/drivers/net/virtio/virtio_user_ethdev.c > @@ -6,6 +6,7 @@ > #include > #include > #include > +#include > #include >=20 > #include > @@ -518,6 +519,19 @@ get_integer_arg(const char *key __rte_unused, > return -errno; > } >=20 > +static enum virtio_user_backend_type > +virtio_user_backend_type(const char *path) > +{ > + struct stat sb; > + > + if (stat(path, &sb) =3D=3D -1) > + return VIRTIO_USER_BACKEND_UNKNOWN; > + > + return S_ISSOCK(sb.st_mode) ? > + VIRTIO_USER_BACKEND_VHOST_USER : > + VIRTIO_USER_BACKEND_VHOST_KERNEL; > +} > + > static struct rte_eth_dev * > virtio_user_eth_dev_alloc(struct rte_vdev_device *vdev) > { > @@ -579,6 +593,7 @@ virtio_user_pmd_probe(struct rte_vdev_device *dev) > struct rte_kvargs *kvlist =3D NULL; > struct rte_eth_dev *eth_dev; > struct virtio_hw *hw; > + enum virtio_user_backend_type backend_type =3D > VIRTIO_USER_BACKEND_UNKNOWN; > uint64_t queues =3D VIRTIO_USER_DEF_Q_NUM; > uint64_t cq =3D VIRTIO_USER_DEF_CQ_EN; > uint64_t queue_size =3D VIRTIO_USER_DEF_Q_SZ; > @@ -631,8 +646,17 @@ virtio_user_pmd_probe(struct rte_vdev_device *dev) > goto end; > } >=20 > + backend_type =3D virtio_user_backend_type(path); > + if (backend_type =3D=3D VIRTIO_USER_BACKEND_UNKNOWN) { > + PMD_INIT_LOG(ERR, > + "unable to determine backend type for path %s", > + path); > + goto end; > + } > + > + > if (rte_kvargs_count(kvlist, VIRTIO_USER_ARG_INTERFACE_NAME) =3D=3D 1) > { > - if (is_vhost_user_by_type(path)) { > + if (backend_type !=3D VIRTIO_USER_BACKEND_VHOST_KERNEL) { > PMD_INIT_LOG(ERR, > "arg %s applies only to vhost-kernel backend", > VIRTIO_USER_ARG_INTERFACE_NAME); > @@ -751,7 +775,7 @@ virtio_user_pmd_probe(struct rte_vdev_device *dev) > hw =3D eth_dev->data->dev_private; > if (virtio_user_dev_init(hw->virtio_user_dev, path, queues, cq, > queue_size, mac_addr, &ifname, server_mode, > - mrg_rxbuf, in_order, packed_vq) < 0) { > + mrg_rxbuf, in_order, packed_vq, backend_type) < 0) { > PMD_INIT_LOG(ERR, "virtio_user_dev_init fails"); > virtio_user_eth_dev_free(eth_dev); > goto end; > -- > 2.26.2