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 575D141B89; Tue, 31 Jan 2023 06:22:22 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 43B7141144; Tue, 31 Jan 2023 06:22:22 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id 4F138427F5 for ; Tue, 31 Jan 2023 06:22:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675142540; x=1706678540; h=from:to:subject:date:message-id:references:in-reply-to: content-transfer-encoding:mime-version; bh=mXVj+oD1WotXMjd6AmY3PP9qrk+uxUzBF/EgvG4fxLY=; b=l5fqfk3PvExh3lJXPmH/Z8+RYT/j3FH6JvhsahiHiSqyhjJ0EDYpyjnw M5sJNj5siQe4fVsHFkj9T3eq9oQ84HI8moVwAZVypXyTX+GhBcGUjvm1e KFWGMOrCXOJqI84/uzSRFrHDQwvvUKOaoGGyDWsMY46BWjax0eR7ZThD0 dvMl3wOvBursjOuexobE4nv8qgERH0SEzfAO0z26OE+3j4Cs9RH0lCDXe kzLrHhy+/vv7qHjb1DnSvw6gYjzIWeZ9tPMox9QIOqbPr6mPNB8pAiuIu nmZX/+hiDjPstwOnM8rgVhiAswqLSL3K2IlZPouymFLVjfzVw0NUHhCsC w==; X-IronPort-AV: E=McAfee;i="6500,9779,10606"; a="315716254" X-IronPort-AV: E=Sophos;i="5.97,259,1669104000"; d="scan'208";a="315716254" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jan 2023 21:21:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10606"; a="909777779" X-IronPort-AV: E=Sophos;i="5.97,259,1669104000"; d="scan'208";a="909777779" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by fmsmga006.fm.intel.com with ESMTP; 30 Jan 2023 21:21:57 -0800 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Mon, 30 Jan 2023 21:21:57 -0800 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16 via Frontend Transport; Mon, 30 Jan 2023 21:21:57 -0800 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.105) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.16; Mon, 30 Jan 2023 21:21:57 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LodDF+GieEUhccUjKkeKNjp5oMFgz7k+FywxW7/b4/Czj9myuZIzm3WyWA7NaNY1ZSR5GFWX91Dl0cxN2Kpa1TirP00dnuQMcwtNdHMasswnThHDfShi9UK3EACIAUK/puUDMwyUNkFBB9UP69cM4I6MdxfAURUTlKuB+tHcw8wylm5PZPWq2qDKd3hlTVkIW4oYRBB1ZnNJHwNVjtQC4IoLk+xiobPRBIVtOMgeRn3SHlQEL09BptXqIYsHq7hw7cXToQ0hRnAE56SBeGpwRZ9EwoPM1podijhQDCgTXqh/J5XBCWLtnujK8NakDX6+SG4myJLyfg8IyZe4+LGAbg== 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=xqc5tYKgcJG2JuVm1j+ozyJxZKA/GqB3ocrwvARvRb8=; b=fJPxAa42d1u2Ra39qunsllznElxdyh5MoA24o1sXRlOJsYZojAlNrHbY4K8PnP2mwB7rpVXfGU5KR7CgB7q2JreNvV91j7tNKW5RH81+kxY/3O1WWZ74D85XiG6Z7TBezjhe5Jymh7DLtJe6MT4lYAQdy11Y2+EA2cpa+5k+p3GyCOfYMiMCToHH5eOW4RxRu9FcTkPk9FgzCZz26rA+5x5WNVS3WUVFGVe5ZNgAMrzJnFEC9SJTYdEwdp5cuWQwuBKettso6QO4/bw3RBNr8rLblndIqWD9cgK6QK8XBUMkS0AkICyI+ae1Rubt0lxQWjPHl7hUJwjhWlCL+cgzrQ== 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 Received: from SN6PR11MB3504.namprd11.prod.outlook.com (2603:10b6:805:d0::17) by SA2PR11MB5050.namprd11.prod.outlook.com (2603:10b6:806:fb::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Tue, 31 Jan 2023 05:21:54 +0000 Received: from SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::c8f8:a3e1:5b23:a9c3]) by SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::c8f8:a3e1:5b23:a9c3%5]) with mapi id 15.20.6043.036; Tue, 31 Jan 2023 05:21:54 +0000 From: "Xia, Chenbo" To: "Coquelin, Maxime" , "dev@dpdk.org" , "david.marchand@redhat.com" , "eperezma@redhat.com" Subject: RE: [PATCH v1 16/21] net/virtio-user: allocate shadow control queue Thread-Topic: [PATCH v1 16/21] net/virtio-user: allocate shadow control queue Thread-Index: AQHZBNR0INL1ucF9k0a/JzMJAZSZj664XiYw Date: Tue, 31 Jan 2023 05:21:54 +0000 Message-ID: References: <20221130155639.150553-1-maxime.coquelin@redhat.com> <20221130155639.150553-17-maxime.coquelin@redhat.com> In-Reply-To: <20221130155639.150553-17-maxime.coquelin@redhat.com> Accept-Language: en-US, zh-CN Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SN6PR11MB3504:EE_|SA2PR11MB5050:EE_ x-ms-office365-filtering-correlation-id: f1158bca-9ee7-4af2-99ad-08db034b1115 x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: CTUEEvAY4AQlJ48I9VJeu0WQkoIelldolBFi9W5dJTZvslwsJVlM02lPxPWyXz0wEVKRka++H4PhRjjxhCXwzJWQ6S8ZBh/Eedr0XzVb/t75hzF2bThfumeinxnJR26uQ8JsJJg6gyQ8P8r5eSysJ4YoibiY5kaumDEut7pvaKBzPFrTHN9PH0ncbwevSZcxf6jXAeq3BX6yyB8ZrqGdsY0qZUPExkR8cJlxjCBIW9DKC/XFrbdCAr7xrH/HXLvP7Rpqlx4fvwLU7FYwgzGqPuAjE5WD43yM+TfSjpq7+abQz2A03ur1z8oboObWDr6KdSE2PHKXs4d+vriua+KT1pzEevWnw2eIJjZjJ/+1fBUuiYBrj+9qMC/F9r0jjphkdxmjJQHOvIG76/RhXYsYzZmRE++tP4ANmuIgWd4WseF73BeqQDV5f+wc+vJEIlFCheeM419qypgz0sWQ1L4AFaAXu3O0P1Kj5zMMjj5M58W8dG16gZCU2KD5FIWplBdMgtq9smGgtNmA6p6pFW7EumdRGUdUEV46PF8RafvBLdNbqxxrD6w3HlVlvOBUsgEwJhTq+4EfMCQiYqhAe510/hijKRULYuI71S0HBASrBdH/P0PxRd4iyTEW003aF7jzAHd8hHOnpeUIaneEUlHVcTzchZvRVn5HLHujCf0zSpdOeTQjh+hmilyPtDpffR6I6nER0P4+guMl3xAmGxr1ZQ== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR11MB3504.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(376002)(366004)(136003)(396003)(346002)(39860400002)(451199018)(122000001)(110136005)(71200400001)(7696005)(33656002)(82960400001)(5660300002)(83380400001)(53546011)(55016003)(6506007)(38100700002)(316002)(52536014)(41300700001)(2906002)(86362001)(8936002)(38070700005)(9686003)(26005)(186003)(8676002)(478600001)(76116006)(64756008)(66556008)(66946007)(66476007)(66446008); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?R/okHH6eqywXvatltW0bG6TxgpOg7LzFJyySOCopAd7R/F/ey1IssvqAYTBO?= =?us-ascii?Q?2ZjIvoo8pmvwXwg9AHuUkev2zsuv0VBx8KTIs8Ykz/sHfGut9WZ9rbwwoDBQ?= =?us-ascii?Q?XgnldsE050Lq6KmOPQ8buVkuNnYplcbJPJnPsSqcCElmbqebbCV4TtSBiYKZ?= =?us-ascii?Q?KX0Jg6ZeZZamiAbt/rVzuoOJwdn7zKqK+IcZsvDRiKK6GeVj19wtu9O6jIFQ?= =?us-ascii?Q?TxbNT1kZCFwAUlhCNFyxL+ImAHYT2olvL/y4hS/xcbJROyGGfMQ2c/5tk5Az?= =?us-ascii?Q?Sth7D4hl5jnrjRKZ2oRXYd6h5ZeZuyXqyatZUxw+HCUyGcLqZ/Lq9ZGe2MQF?= =?us-ascii?Q?sdbAOaQABML4Umf3Plz4As8S0+NP0QrqvnKrmFqsKqDnyRe08FWzXvPP8dL6?= =?us-ascii?Q?XdZvd8q4WRSHMhezeJQtgRN2uEenaSK/myBHO+vrc/7u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IxcPaTrAhuKMKDQJu7/HB+tFFp17TgBDRpj7mdx?= =?us-ascii?Q?f+wHIoNKJRDzkAey7H9XQ6FrWGT5IOSzU5+NaYx4GwFZ+gBQ/6C7FlVfy2wo?= =?us-ascii?Q?6og1y/d6BbhX3UMOeIsYy+F7zuplJP62a0WafMnnDkPAnYZ5bm8KpS1/sniw?= =?us-ascii?Q?ElBx7kvD46fDLblzse6XU5wP3jN/MWu7RxxFDu51ZX6myhIUiEVZz4n+pMLl?= =?us-ascii?Q?pZGHq3wo9a+tdn/F327Khkz4GT0kQ/VLlN68ZwWD?= 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: SN6PR11MB3504.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f1158bca-9ee7-4af2-99ad-08db034b1115 X-MS-Exchange-CrossTenant-originalarrivaltime: 31 Jan 2023 05:21:54.6647 (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: LWmx0v2Y4kUJNY165BMS5HLSdWlFRwasw64k/7VAnEf/B3ZqukRKAMU48enCI1mxQcm11Pkh8LP0bbCFcjJXRw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR11MB5050 X-OriginatorOrg: intel.com 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 > -----Original Message----- > From: Maxime Coquelin > Sent: Wednesday, November 30, 2022 11:57 PM > To: dev@dpdk.org; Xia, Chenbo ; > david.marchand@redhat.com; eperezma@redhat.com > Cc: Maxime Coquelin > Subject: [PATCH v1 16/21] net/virtio-user: allocate shadow control queue >=20 > If the backends supports control virtqueue, allocate a > shadow control virtqueue, and implement the notify callback > that writes into the kickfd. >=20 > Signed-off-by: Maxime Coquelin > --- > .../net/virtio/virtio_user/virtio_user_dev.c | 47 ++++++++++++++++++- > .../net/virtio/virtio_user/virtio_user_dev.h | 5 ++ > drivers/net/virtio/virtio_user_ethdev.c | 6 +++ > 3 files changed, 56 insertions(+), 2 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 a3584e7735..16a0e07413 100644 > --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c > +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c > @@ -146,8 +146,9 @@ virtio_user_dev_set_features(struct virtio_user_dev > *dev) >=20 > /* Strip VIRTIO_NET_F_MAC, as MAC address is handled in vdev init */ > features &=3D ~(1ull << VIRTIO_NET_F_MAC); > - /* Strip VIRTIO_NET_F_CTRL_VQ, as devices do not really need to know > */ > - features &=3D ~(1ull << VIRTIO_NET_F_CTRL_VQ); > + /* Strip VIRTIO_NET_F_CTRL_VQ if the devices does not really support > control VQ */ > + if (!dev->hw_cvq) > + features &=3D ~(1ull << VIRTIO_NET_F_CTRL_VQ); > features &=3D ~(1ull << VIRTIO_NET_F_STATUS); > ret =3D dev->ops->set_features(dev, features); > if (ret < 0) > @@ -911,6 +912,48 @@ virtio_user_handle_cq(struct virtio_user_dev *dev, > uint16_t queue_idx) > } > } >=20 > +static void > +virtio_user_control_queue_notify(struct virtqueue *vq, void *cookie) > +{ > + struct virtio_user_dev *dev =3D cookie; > + uint64_t buf =3D 1; > + > + if (write(dev->kickfds[vq->vq_queue_index], &buf, sizeof(buf)) < 0) > + PMD_DRV_LOG(ERR, "failed to kick backend: %s", > + strerror(errno)); > +} > + > +int > +virtio_user_dev_create_shadow_cvq(struct virtio_user_dev *dev, struct > virtqueue *vq) > +{ > + char name[VIRTQUEUE_MAX_NAME_SZ]; > + struct virtqueue *scvq; > + > + snprintf(name, sizeof(name), "port%d_shadow_cvq", vq->hw->port_id); > + scvq =3D virtqueue_alloc(&dev->hw, vq->vq_queue_index, vq->vq_nentries, > + VTNET_CQ, SOCKET_ID_ANY, name); > + if (!scvq) { > + PMD_INIT_LOG(ERR, "(%s) Failed to alloc shadow control vq\n", > dev->path); > + return -ENOMEM; > + } > + > + scvq->cq.notify_queue =3D &virtio_user_control_queue_notify; > + scvq->cq.notify_cookie =3D dev; > + dev->scvq =3D scvq; > + > + return 0; > +} > + > +void > +virtio_user_dev_destroy_shadow_cvq(struct virtio_user_dev *dev) > +{ > + if (!dev->scvq) > + return; > + > + virtqueue_free(dev->scvq); > + dev->scvq =3D NULL; > +} > + > int > virtio_user_dev_set_status(struct virtio_user_dev *dev, uint8_t status) > { > diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.h > b/drivers/net/virtio/virtio_user/virtio_user_dev.h > index 3c5453eac0..e0db4faf3f 100644 > --- a/drivers/net/virtio/virtio_user/virtio_user_dev.h > +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.h > @@ -58,6 +58,9 @@ struct virtio_user_dev { > pthread_mutex_t mutex; > bool started; >=20 > + bool hw_cvq; > + struct virtqueue *scvq; > + > void *backend_data; > }; >=20 > @@ -74,6 +77,8 @@ void virtio_user_handle_cq(struct virtio_user_dev *dev, > uint16_t queue_idx); > void virtio_user_handle_cq_packed(struct virtio_user_dev *dev, > uint16_t queue_idx); > uint8_t virtio_user_handle_mq(struct virtio_user_dev *dev, uint16_t > q_pairs); > +int virtio_user_dev_create_shadow_cvq(struct virtio_user_dev *dev, struc= t > virtqueue *vq); > +void virtio_user_dev_destroy_shadow_cvq(struct virtio_user_dev *dev); > int virtio_user_dev_set_status(struct virtio_user_dev *dev, uint8_t > status); > int virtio_user_dev_update_status(struct virtio_user_dev *dev); > int virtio_user_dev_update_link_state(struct virtio_user_dev *dev); > diff --git a/drivers/net/virtio/virtio_user_ethdev.c > b/drivers/net/virtio/virtio_user_ethdev.c > index 6c3e875793..626bd95b62 100644 > --- a/drivers/net/virtio/virtio_user_ethdev.c > +++ b/drivers/net/virtio/virtio_user_ethdev.c > @@ -232,6 +232,9 @@ virtio_user_setup_queue(struct virtio_hw *hw, struct > virtqueue *vq) > else > virtio_user_setup_queue_split(vq, dev); >=20 > + if (dev->hw_cvq && hw->cvq && (virtnet_cq_to_vq(hw->cvq) =3D=3D vq)) > + return virtio_user_dev_create_shadow_cvq(dev, vq); > + > return 0; > } >=20 > @@ -251,6 +254,9 @@ virtio_user_del_queue(struct virtio_hw *hw, struct > virtqueue *vq) >=20 > close(dev->callfds[vq->vq_queue_index]); > close(dev->kickfds[vq->vq_queue_index]); > + > + if (hw->cvq && (virtnet_cq_to_vq(hw->cvq) =3D=3D vq) && dev->scvq) > + virtio_user_dev_destroy_shadow_cvq(dev); > } >=20 > static void > -- > 2.38.1 Reviewed-by: Chenbo Xia =20