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 A394142BA2; Fri, 26 May 2023 02:20:06 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 47C984114B; Fri, 26 May 2023 02:20:06 +0200 (CEST) Received: from BN6PR00CU002.outbound.protection.outlook.com (mail-eastus2azon11021017.outbound.protection.outlook.com [52.101.57.17]) by mails.dpdk.org (Postfix) with ESMTP id 4D98C410FA; Fri, 26 May 2023 02:20:03 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m9CYVRPGxg/hbyvFOlgbKFNw9ZDyIsBEgkdNG5tLa/6RHdmXTzwm/cPZUfEUbmq08ZPHWuIZrxZ+Pzd5B2q6Im6KxOtub0l6z3gDORHCqWj8XPQP8ZeMG2uJuHI2I0xfMCsP1SWUsoS/bKoIklijiaVrNn7fKUyEeKOrhF1975yHoEM6cYUTNwtIvG2DwiR2s8zFvTK9e98CTkrJFn+ZFv9nAYikQjAWh0IrMkbwT/1ZPN3kpllPNuZnPVQDlleYjxYJ9c3LVis0EGWj9V9VVxrH8exOQSb7lTYJrojt8snGgzXQsW/guh07NswUQmFUP1tq+TBOQPRkenlF0jQnww== 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=BORLGJUfT5L+xFzaDbgXNmx1dkfo9E7K4QPymPbebIU=; b=Vo+tHNoOsI5UP6Y4Kgv28Qj8Bekxc77SLfMUC4cIEfgJ2qyUJPABlwDHqtxymwAlHOyNebRDD0stJ/7U9D6zxSkimm+3YCrhPjbOs8/Rvycfl5YMW3tFs6Sg1CEG4T6Hv0ASR/xJUsb/UZslUyispyXO0iRpEkEVuwz7YkFupRQFdhWzZGJrREHkqKsRIbOdY6czAIKi6lsRQ9GrEhhDm10S02oPVDOq9kUyksVrMTSydGnUhpt3dxm7HgP4Bq20i5A94Mi92gYu42x1OglrWG5O/7XzoZWFSN4TY950/BR+3x3FhrIb2OpZLV0yPVTbhsFCIf8R4TKfFcgcT73SGA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BORLGJUfT5L+xFzaDbgXNmx1dkfo9E7K4QPymPbebIU=; b=TUohBdMwUF5mtHs68+7gOe/SDYLhigDVxck5Dhi2tdaQ0voEDgeyImw/v9XPSoi1DrXpH8To8uiGvQVxbMg9zIdEc5rWCgaE9g3rC8y4y5qtBelHoxPRMqJfUWDQE0YSiGZzt5fKkHL4pY1EzUwwU8gL3dAHsCEWJ/jmgm/FDYI= Received: from BY5PR21MB1394.namprd21.prod.outlook.com (2603:10b6:a03:21c::20) by SJ0PR21MB2056.namprd21.prod.outlook.com (2603:10b6:a03:395::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.7; Fri, 26 May 2023 00:20:00 +0000 Received: from BY5PR21MB1394.namprd21.prod.outlook.com ([fe80::b87e:bfdd:fbcc:ff3c]) by BY5PR21MB1394.namprd21.prod.outlook.com ([fe80::b87e:bfdd:fbcc:ff3c%5]) with mapi id 15.20.6455.004; Fri, 26 May 2023 00:19:59 +0000 From: Ajay Sharma To: Ferruh Yigit , Andrew Rybchenko CC: "dev@dpdk.org" , Long Li , "stable@dpdk.org" , Ajay Sharma Subject: EXTERNAL] [PATCH ] Add checks for the port capabilties Thread-Topic: EXTERNAL] [PATCH ] Add checks for the port capabilties Thread-Index: AQHZj2fOI4djbSgSZUK9vJcADHRodw== Date: Fri, 26 May 2023 00:19:59 +0000 Message-ID: References: <1682653009-19988-1-git-send-email-longli@linuxonhyperv.com> <1683336767-19526-1-git-send-email-longli@linuxonhyperv.com> In-Reply-To: <1683336767-19526-1-git-send-email-longli@linuxonhyperv.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ActionId=6419b8a7-4fd7-4f4c-85ab-b53e438ca483; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=true; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Standard; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=Internal; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2023-05-26T00:15:00Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: BY5PR21MB1394:EE_|SJ0PR21MB2056:EE_ x-ms-office365-filtering-correlation-id: 73e2dc2e-a936-47c2-11a7-08db5d7ef143 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: sgOiFx2gwG1TctP7Te1HBew2UxjxMMMYuSaDcPfeyQkU+hjN+W1dp8wI5vwnEVf7yaUp3aLvZiRP8X9jXkOcXi/X4PvZVKaHdKb7uZt6TTCfy0DjxqlB0irYtZxBP8qlkj9CiPT5nj2BizLepByQrwE3beDOQYRmxirs01AJqx2cFR1HEss1/x7i57t/VqOaXepH0fPEX+s0zlF8M87q+KyuEsYbCjMb4iddlcLTYPIL30bAG+JlRHg1IC+6XJOOKF4F4Z/xttlS8JdNtgFZFlha/NGQALTgMoLA/H8N234GV9sOjHK1bFUL0H56ydB4qiTep6+ouD994rU8Yz7UessyqecQiY2JWmQ5ajurr9m9OZEApkQ4XAtdCRm3vpAtcQ1BOBOPXaHDonYiD8BQ+3LqrfAmW+pNMe+Pwxyb6S4Tae4sEtequm4CvbvcQsrRpR/Opo/D+S72Zr6/NybcpU/4OjDyrzNI8cuSonzx+XgQ/eGZdZROP8NiOTy3lvlAm1oAtqoAOjtu6cPTGfUoFY7eUybkwc8+rjP09HB7SsKyjhiysNTJ//K4AxlyaGTQ8Qv9adq42HcmclSTncYo1QeInzdjFfC7U3K5p034WfsazyYCraTssAQRxorDh6YlPzt15NjGN0/kJkgD+KFcTuE24qMENNke+vWluuaYlCE= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BY5PR21MB1394.namprd21.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(396003)(366004)(136003)(346002)(376002)(39860400002)(451199021)(8990500004)(71200400001)(38100700002)(41300700001)(55016003)(38070700005)(8936002)(33656002)(83380400001)(5660300002)(66446008)(52536014)(186003)(8676002)(66946007)(4326008)(76116006)(64756008)(786003)(66556008)(82960400001)(82950400001)(122000001)(66476007)(316002)(107886003)(2906002)(110136005)(54906003)(26005)(7696005)(9686003)(53546011)(478600001)(86362001)(10290500003)(6506007); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?8ZQ8wFoESXQfscdHvLlOc538lPZHGCsEOdy1NJ8oGN9VNxK79Fa0xIEEoUh4?= =?us-ascii?Q?oJ2KzylOLVXeSP3SlJm1k+Rkvk/82PrF2+Wsm16xb1R0Z5PWO/FrmHh1pbDo?= =?us-ascii?Q?Xm9X+ZwA/8EG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?us-ascii?Q?IlBEsxh9jAqAgDWCKPfzuORDp06oj8RUgr4VUmw04Ip4QYGVouOCH0eef7xy?= =?us-ascii?Q?B2ejv3B+GpCA5T2+XcrraCI9fuNHMBE5mSxE6EYZk+kE8bBH8Z2JMTT4R+c7?= =?us-ascii?Q?BCuvQUA82I3tB0PPeO7Zx88DZ98MwQGzPc0xzmBXCKUNdIJ0qQbKYN6TO8ca?= =?us-ascii?Q?SiCo9UQN5QZyK1qxXNBSKGLkPCOzoKFPbPkJuBaH7pFDKpQvBJLuLGA5LrAZ?= =?us-ascii?Q?r+JbF3NkDfq8V8M+C+GiR3QwicPlAjb4j2Cj4SFBbn+L1bkMsQPV97EnuKPZ?= =?us-ascii?Q?Zfc1sm4dHfuUdVh/INRwt/+gcrzD2n3CezfCHjGwBAeFWytvgKR8GX2eu09A?= =?us-ascii?Q?IqCjuiHDlkj6lmw/OWBd1rmwfyXIISdhDk0Jqtx2htQJGpSII1r9jyjBbV5A?= =?us-ascii?Q?ZbSd7v9pfF3oce4Y+YDlLRcOnbk/hmDualw9A0AqsN2VX+rJj9RtPNAsZwiH?= =?us-ascii?Q?kGsDwUGJWM6OPpMghFcICIUZnugeHQNn8oQ/?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BY5PR21MB1394.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 73e2dc2e-a936-47c2-11a7-08db5d7ef143 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 May 2023 00:19:59.7599 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: ZG2DhfXYww5fHsZOUKkKLBKz7f6P3hpDEjZLlFDZfKw21C7fGa0ugmRLSNQVAZvR6cVumDzv5pipX2juvqA8j5uSmHC6EmiTH7tSC4R9shM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR21MB2056 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 From: Ajay Sharma Date: Mon, 22 May 2023 20:24:39 -0700 Subject: [PATCH] Add checks for the port capabilties =20 Add checks to the values retrieved from the firmware to prevent overflow. =20 Signed-off-by: Ajay Sharma --- drivers/net/mana/mana.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) =20 diff --git a/drivers/net/mana/mana.c b/drivers/net/mana/mana.c index 7630118d4f..3a7e302c86 100644 --- a/drivers/net/mana/mana.c +++ b/drivers/net/mana/mana.c @@ -292,8 +292,9 @@ mana_dev_info_get(struct rte_eth_dev *dev, dev_info->min_rx_bufsize =3D MIN_RX_BUF_SIZE; dev_info->max_rx_pktlen =3D MAX_FRAME_SIZE; =20 - dev_info->max_rx_queues =3D priv->max_rx_queues; - dev_info->max_tx_queues =3D priv->max_tx_queues; + dev_info->max_rx_queues =3D RTE_MIN(priv->max_rx_queues, USHRT_MA= X); + dev_info->max_tx_queues =3D RTE_MIN(priv->max_tx_queues, USHRT_MA= X); + =20 dev_info->max_mac_addrs =3D MANA_MAX_MAC_ADDR; dev_info->max_hash_mac_addrs =3D 0; @@ -334,16 +335,17 @@ mana_dev_info_get(struct rte_eth_dev *dev, =20 /* Buffer limits */ dev_info->rx_desc_lim.nb_min =3D MIN_BUFFERS_PER_QUEUE; - dev_info->rx_desc_lim.nb_max =3D priv->max_rx_desc; + dev_info->rx_desc_lim.nb_max =3D RTE_MIN(priv->max_rx_desc, USHRT= _MAX); dev_info->rx_desc_lim.nb_align =3D MIN_BUFFERS_PER_QUEUE; - dev_info->rx_desc_lim.nb_seg_max =3D priv->max_recv_sge; - dev_info->rx_desc_lim.nb_mtu_seg_max =3D priv->max_recv_sge; + dev_info->rx_desc_lim.nb_seg_max =3D RTE_MIN(priv->max_recv_sge, = USHRT_MAX); + dev_info->rx_desc_lim.nb_mtu_seg_max =3D RTE_MIN(priv->max_recv_s= ge, USHRT_MAX); + =20 dev_info->tx_desc_lim.nb_min =3D MIN_BUFFERS_PER_QUEUE; - dev_info->tx_desc_lim.nb_max =3D priv->max_tx_desc; + dev_info->tx_desc_lim.nb_max =3D RTE_MIN(priv->max_tx_desc, USHRT= _MAX); dev_info->tx_desc_lim.nb_align =3D MIN_BUFFERS_PER_QUEUE; - dev_info->tx_desc_lim.nb_seg_max =3D priv->max_send_sge; - dev_info->rx_desc_lim.nb_mtu_seg_max =3D priv->max_recv_sge; + dev_info->tx_desc_lim.nb_seg_max =3D RTE_MIN(priv->max_send_sge, = USHRT_MAX); + dev_info->rx_desc_lim.nb_mtu_seg_max =3D RTE_MIN(priv->max_recv_s= ge, USHRT_MAX); =20 /* Speed */ dev_info->speed_capa =3D RTE_ETH_LINK_SPEED_100G; -- 2.25.1 56