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 710A6A034F; Mon, 29 Mar 2021 11:35:53 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5030640151; Mon, 29 Mar 2021 11:35:53 +0200 (CEST) Received: from NAM04-CO1-obe.outbound.protection.outlook.com (mail-eopbgr690075.outbound.protection.outlook.com [40.107.69.75]) by mails.dpdk.org (Postfix) with ESMTP id B195340042 for ; Mon, 29 Mar 2021 11:35:51 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A6jeZ9rd8KU0ob2ft+4zoUh+uhwaItQye+BUHy2i1L1jDJfmC+oJwnHhJCYvBulyJ565LfZrnnBsFQ3jIJYcX84w1q3bk+lbafc+5RMXutlVFShx5zmerZYnClJxcEng1YT4U7sdudcadH8gZVwA9LnxznnSh1fY062gDC3bq61ScXgP2Qpg3Ava8F0iLcZALWcg+NXwyQ4UUlNZS8C4btqnoie+ZAfCJAOGvMKJ8HiQxks2cyt7L0f/NfBNWkuLxsdpB4lE3CgrJYUB+kI+qT9+NyEMgONPb4fr6//kl3E6wKAp+BDMr67s/Y6KBNpK7OZtDYEVjDtNBOtk7lH1YQ== 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=lF8fVUgpesLqdzajcksozaieSnRg08xG6mU12PJWzxM=; b=DsZTZ/9urfyfne5r2iD+sSpew2vSSYkusW8kQYEMbwgWmN/zinFywpzizc7wk3gMkxEwlxE7uVcnpET20sPO+TB5lEzcFaYfCUFGz11TJugTIgjVd4ivt07lNRRj1DBYR/XPD/cH33ktVcVb89uaAcRR0/xpWGzfvu62HXf0YhSmpaB0+t8Wf/yietOQCVvpMF2uH+TU7GTsKWp1rpSLub+48LTDICWNeOhJKftjkLOxqs3jAY/VVsR60gziJjjLkJRFGQjUqdggXdJHf3xRLWiS3ei90XTHymuv/MWqo7n7+53HGsbx10HchFNh4YkVWU2KRwxrxzo2uVNrcKPX2w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lF8fVUgpesLqdzajcksozaieSnRg08xG6mU12PJWzxM=; b=qTMtE7UYCfCOPJnTKLLMMd5FLltBhKkJYhDb+iKeiq3vC/S84zZ1rl7xrON5dAEeS0nTeFmnQr+Rik9Em/Vuq2TB6vs5kS1oDwuAAqjF+9i7Vhf14ZrlQFGhjzB/T82t/IIkdmJJhhcem9rb7Ufa5tFN7TBHkRbrY3bSQ8SMRVNp0bIsjjgWFhi54JL/DZS9zmtusFfwZ6ZWqkU8tfrVgCNX9CLJIVWCZ/T8ld2xMQGe3vA7YhM4Vz6utJV+SmGGVk4SIQwUtmBLA3l+mkLxBd2W/4WOHKrn/0QsYHH1eUjUV7wJIZzX8yt/2bH3U9FNsmEoUQ2iRhhz7r/ql4TESA== Received: from DM6PR12MB4987.namprd12.prod.outlook.com (2603:10b6:5:163::31) by DM6PR12MB4043.namprd12.prod.outlook.com (2603:10b6:5:216::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.24; Mon, 29 Mar 2021 09:35:50 +0000 Received: from DM6PR12MB4987.namprd12.prod.outlook.com ([fe80::f5ce:c5a8:6aec:e308]) by DM6PR12MB4987.namprd12.prod.outlook.com ([fe80::f5ce:c5a8:6aec:e308%7]) with mapi id 15.20.3977.033; Mon, 29 Mar 2021 09:35:50 +0000 From: Ori Kam To: Suanming Mou CC: "dev@dpdk.org" , Slava Ovsiienko , Matan Azrad , Raslan Darawsheh , John Hurley Thread-Topic: [PATCH v2 4/4] regex/mlx5: prevent wrong calculation of free sqs in umr mode Thread-Index: AQHXIS/u4OdhyCHQWEi6FfTfFLfRaaqau0AQ Date: Mon, 29 Mar 2021 09:35:50 +0000 Message-ID: References: <20210309235732.3952418-1-suanmingm@nvidia.com> <20210325043236.964312-1-suanmingm@nvidia.com> <20210325043236.964312-5-suanmingm@nvidia.com> In-Reply-To: <20210325043236.964312-5-suanmingm@nvidia.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: nvidia.com; dkim=none (message not signed) header.d=none;nvidia.com; dmarc=none action=none header.from=nvidia.com; x-originating-ip: [147.236.145.126] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 4c738fdd-819f-4778-4701-08d8f2960a49 x-ms-traffictypediagnostic: DM6PR12MB4043: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2958; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: laO1aJ1/ojGCbqheTDxf/DbtOwRq0ZFoj8cWsuxmkGvzxooEZrF0mzLPXPYnK6Ldaa3MnKLrXEeUSPi51LoPwmoOQtw0PWZPT0E0QtdRvw8QqzuMazed5UQrrYW6+WVBmhIFGFm3S7qxPB2DXXw5iQOUVMoZ4zy9R+4RpPeCTVsFCYCbZZ1sIuTo/7CS2fadRGFY0EvSW2LjOzWh/+nWOPlpSpsx6D4r6cyKrV0b78139h4G1UAkB0sJhOJ/uvQb6yZZPG/L6Yooz8SLMytnAdt3XqD1Q4ArDy775Pze2gcJwcdXobHr6bJmvUbHhu+tqIoqCbWJJd14P/CjKmgmQf4no7d6r6b92Cpasg2ZoqY19d9t0t0VOuTPCwefCS/5HyFlXi97W4TRQ4PwfNqn44lJpsz0XvF/ituBmxCyqXntt6YZaYVFP6ATU10Y/8oPitvB94ckdjq7rxAe4jb+uQvDYdj4GcE7wvXc3twbc0UteBlDZ4TYaUTVA1elZ20dKj5D04KmacLr2IfurwBfSBoOJ4iLfqz6urEH4rfK02k8qy9D/Pc4S7BZppPyNSqmqb+T3CHCXaKeL9ARTwyYJzWAKt5hPqXVxtsDawaPMl4zQYvcMk8+ka6itqzZio8akQtt+RiETWITDhIcVR6HZfi4TIea54ZRJuBM/F39JFM= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR12MB4987.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(346002)(396003)(39860400002)(366004)(376002)(5660300002)(8936002)(26005)(478600001)(64756008)(8676002)(316002)(83380400001)(9686003)(186003)(71200400001)(2906002)(66446008)(66556008)(4326008)(54906003)(55016002)(6506007)(33656002)(7696005)(6636002)(52536014)(86362001)(107886003)(66946007)(6862004)(38100700001)(76116006)(66476007); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?N8ga9wupax4BcyAaocAYFRb+8jnIFe4MOj0OF+7eV6hHDk2DUPI5il9tbOhI?= =?us-ascii?Q?kzhdOcTIV4btaT64lbIUkA90KnKjxw0MDmB2FpSdj7THaIfwGPv8od5uDRPI?= =?us-ascii?Q?jdnTB5Ox+IcYffO/Qf3Sjh6HrtGiV752t3rGQ4qT89jeo7udW19+hYcurq70?= =?us-ascii?Q?8jyuLwbAgjr5HjV9ST4lrXKm1rYoDAHyp1ZlZf5/SCZ+RGQzPQP1qzwCWwsj?= =?us-ascii?Q?K0s+16C80nai904MJa0swRSOtH6Y/BqwPGG1zeJNDXle+VQ8CtW1k4vqts38?= =?us-ascii?Q?NU57RpMduMnd0efwxL0KgUCcxxctdRkl6qe7HyDwzAC3b56BzI7MkqZYNHoq?= =?us-ascii?Q?wUDUXwqkWC88wVpdImujer4lh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XEhiYnkjhPwBTDbSP8vkIXn6tKLwRd/pWP77Hvuu9xz8J+4Te7q84/E34?= =?us-ascii?Q?B0k7woSRXs/ij+lGBb4uEkjy?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB4987.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4c738fdd-819f-4778-4701-08d8f2960a49 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Mar 2021 09:35:50.2277 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Kda1YHql38jtwy8c92zHd0dLnCKMf3MapYFHTJc4lloTvbEhi7C7OYkCRXUqb48olg9XRHxpKDvBkux2TwYv4g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4043 Subject: Re: [dpdk-dev] [PATCH v2 4/4] regex/mlx5: prevent wrong calculation of free sqs in umr mode 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" Hi > -----Original Message----- > From: Suanming Mou >=20 > From: John Hurley >=20 > A recent change adds support for scattered mbuf and UMR support for regex= . > Part of this commit makes the pi and ci counters of the regex_sq a quarte= r > of the length in non umr mode, effectively moving them from 16 bits to > 14. The new get_free method casts the difference in pi and ci to a 16 bit > value when calculating the free send queues, accounting for any wrapping > when pi has looped back to 0 but ci has not yet. However, the move to 14 > bits while still casting to 16 can now lead to corrupted, large values > returned. >=20 > Modify the get_free function to take in the has_umr flag and, accordingly= , > account for wrapping on either 14 or 16 bit pi/ci difference. >=20 > Fixes: a20fe8e74dea ("regex/mlx5: add data path scattered mbuf process") > Signed-off-by: John Hurley > --- > drivers/regex/mlx5/mlx5_regex_fastpath.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) >=20 > diff --git a/drivers/regex/mlx5/mlx5_regex_fastpath.c > b/drivers/regex/mlx5/mlx5_regex_fastpath.c > index 4f9402c583..b57e7d7794 100644 > --- a/drivers/regex/mlx5/mlx5_regex_fastpath.c > +++ b/drivers/regex/mlx5/mlx5_regex_fastpath.c > @@ -192,8 +192,10 @@ send_doorbell(struct mlx5_regex_priv *priv, struct > mlx5_regex_sq *sq) > } >=20 > static inline int > -get_free(struct mlx5_regex_sq *sq) { > - return (sq_size_get(sq) - (uint16_t)(sq->pi - sq->ci)); > +get_free(struct mlx5_regex_sq *sq, uint8_t has_umr) { > + return (sq_size_get(sq) - ((sq->pi - sq->ci) & > + (has_umr ? (MLX5_REGEX_MAX_WQE_INDEX >> 2) : > + MLX5_REGEX_MAX_WQE_INDEX))); > } >=20 > static inline uint32_t > @@ -385,7 +387,7 @@ mlx5_regexdev_enqueue_gga(struct rte_regexdev > *dev, uint16_t qp_id, > while ((sqid =3D ffs(queue->free_sqs))) { > sqid--; /* ffs returns 1 for bit 0 */ > sq =3D &queue->sqs[sqid]; > - nb_desc =3D get_free(sq); > + nb_desc =3D get_free(sq, priv->has_umr); > if (nb_desc) { > /* The ops be handled can't exceed nb_ops. */ > if (nb_desc > nb_left) > @@ -418,7 +420,7 @@ mlx5_regexdev_enqueue(struct rte_regexdev *dev, > uint16_t qp_id, > while ((sqid =3D ffs(queue->free_sqs))) { > sqid--; /* ffs returns 1 for bit 0 */ > sq =3D &queue->sqs[sqid]; > - while (get_free(sq)) { > + while (get_free(sq, priv->has_umr)) { > job_id =3D job_id_get(sqid, sq_size_get(sq), sq->pi); > prep_one(priv, queue, sq, ops[i], &queue- > >jobs[job_id]); > i++; > -- > 2.25.1 Acked-by: Ori Kam Best, Ori