From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 660871B2B7; Mon, 5 Feb 2018 11:41:14 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Feb 2018 02:41:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,464,1511856000"; d="scan'208";a="28119992" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga001.fm.intel.com with ESMTP; 05 Feb 2018 02:41:13 -0800 Received: from fmsmsx115.amr.corp.intel.com (10.18.116.19) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 5 Feb 2018 02:41:13 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx115.amr.corp.intel.com (10.18.116.19) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 5 Feb 2018 02:41:12 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.253]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.130]) with mapi id 14.03.0319.002; Mon, 5 Feb 2018 18:41:10 +0800 From: "Xing, Beilei" To: "Rybalchenko, Kirill" , "dev@dpdk.org" CC: "stable@dpdk.org" , "Chilikin, Andrey" , "Wu, Jingjing" Thread-Topic: [PATCH v3] net/i40e: fix multiple DDP packages should not be allowed Thread-Index: AQHTm1o/IKiHmOQ+1EqVnZ0sd0oAA6OVo7Ng Date: Mon, 5 Feb 2018 10:41:09 +0000 Message-ID: <94479800C636CB44BD422CB454846E01320CDDEC@SHSMSX101.ccr.corp.intel.com> References: <1517335797-84501-1-git-send-email-kirill.rybalchenko@intel.com> <1517488985-5264-1-git-send-email-kirill.rybalchenko@intel.com> In-Reply-To: <1517488985-5264-1-git-send-email-kirill.rybalchenko@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v3] net/i40e: fix multiple DDP packages should not be allowed 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: , X-List-Received-Date: Mon, 05 Feb 2018 10:41:15 -0000 > -----Original Message----- > From: Rybalchenko, Kirill > Sent: Thursday, February 1, 2018 8:43 PM > To: dev@dpdk.org > Cc: stable@dpdk.org; Rybalchenko, Kirill ; > Chilikin, Andrey ; Xing, Beilei > ; Wu, Jingjing > Subject: [PATCH v3] net/i40e: fix multiple DDP packages should not be > allowed >=20 > Should be not possible to load conflicting DDP profiles. > Only DDP profiles of the same group (not 0) can be loaded together; If DD= P > profile group is 0, it is exclusive, i.e. it cannot be loaded with any ot= her DDP > profile; If DDP profile groups are different - these profiles cannot be l= oaded > together; >=20 > Fixes: b319712f53c8 ("net/i40e: extended list of operations for DDP > processing") >=20 > v3: prevent registration of read-only profiles with profile list >=20 > Signed-off-by: Kirill Rybalchenko > --- > drivers/net/i40e/rte_pmd_i40e.c | 40 > ++++++++++++++++++++++++++++++++++++---- > 1 file changed, 36 insertions(+), 4 deletions(-) >=20 > diff --git a/drivers/net/i40e/rte_pmd_i40e.c > b/drivers/net/i40e/rte_pmd_i40e.c index 5436db4..dae59e6 100644 > --- a/drivers/net/i40e/rte_pmd_i40e.c > +++ b/drivers/net/i40e/rte_pmd_i40e.c > @@ -1496,7 +1496,14 @@ i40e_check_profile_info(uint16_t port, uint8_t > *profile_info_sec) > struct rte_pmd_i40e_profile_info *pinfo, *p; > uint32_t i; > int ret; > + static const uint32_t group_mask =3D 0x00ff0000; >=20 > + pinfo =3D (struct rte_pmd_i40e_profile_info *)(profile_info_sec + > + sizeof(struct i40e_profile_section_header)); > + if (pinfo->track_id =3D=3D 0) { > + PMD_DRV_LOG(INFO, "Read-only profile."); > + return 0; > + } > buff =3D rte_zmalloc("pinfo_list", > (I40E_PROFILE_INFO_SIZE * > I40E_MAX_PROFILE_NUM + 4), > 0); > @@ -1515,8 +1522,6 @@ i40e_check_profile_info(uint16_t port, uint8_t > *profile_info_sec) > return -1; > } > p_list =3D (struct rte_pmd_i40e_profile_list *)buff; > - pinfo =3D (struct rte_pmd_i40e_profile_info *)(profile_info_sec + > - sizeof(struct i40e_profile_section_header)); > for (i =3D 0; i < p_list->p_count; i++) { > p =3D &p_list->p_info[i]; > if (pinfo->track_id =3D=3D p->track_id) { @@ -1525,6 +1530,23 > @@ i40e_check_profile_info(uint16_t port, uint8_t *profile_info_sec) > return 1; > } > } > + for (i =3D 0; i < p_list->p_count; i++) { > + p =3D &p_list->p_info[i]; > + if ((p->track_id & group_mask) =3D=3D 0) { > + PMD_DRV_LOG(INFO, "Profile of the group 0 > exists."); > + rte_free(buff); > + return 2; > + } > + } > + for (i =3D 0; i < p_list->p_count; i++) { > + p =3D &p_list->p_info[i]; > + if ((pinfo->track_id & group_mask) !=3D > + (p->track_id & group_mask)) { > + PMD_DRV_LOG(INFO, "Profile of different group > exists."); > + rte_free(buff); > + return 3; > + } > + } >=20 > rte_free(buff); > return 0; > @@ -1544,6 +1566,7 @@ rte_pmd_i40e_process_ddp_package(uint16_t > port, uint8_t *buff, > uint8_t *profile_info_sec; > int is_exist; > enum i40e_status_code status =3D I40E_SUCCESS; > + static const uint32_t type_mask =3D 0xff000000; >=20 > if (op !=3D RTE_PMD_I40E_PKG_OP_WR_ADD && > op !=3D RTE_PMD_I40E_PKG_OP_WR_ONLY && > @@ -1595,6 +1618,10 @@ rte_pmd_i40e_process_ddp_package(uint16_t > port, uint8_t *buff, > return -EINVAL; > } >=20 > + /* force read-only track_id for type 0 */ > + if ((track_id & type_mask) =3D=3D 0) > + track_id =3D 0; > + > /* Find profile segment */ > profile_seg_hdr =3D > i40e_find_segment_in_package(SEGMENT_TYPE_I40E, > pkg_hdr); > @@ -1628,12 +1655,17 @@ rte_pmd_i40e_process_ddp_package(uint16_t > port, uint8_t *buff, >=20 > if (op =3D=3D RTE_PMD_I40E_PKG_OP_WR_ADD) { > if (is_exist) { How about removing the above if statement since there're 3 if statements fo= r is_exist below? > - PMD_DRV_LOG(ERR, "Profile already exists."); > + if (is_exist =3D=3D 1) > + PMD_DRV_LOG(ERR, "Profile already > exists."); > + else if (is_exist =3D=3D 2) > + PMD_DRV_LOG(ERR, "Profile of group 0 > already exists."); > + else if (is_exist =3D=3D 3) > + PMD_DRV_LOG(ERR, "Profile of different > group already exists"); > rte_free(profile_info_sec); > return -EEXIST; > } > } else if (op =3D=3D RTE_PMD_I40E_PKG_OP_WR_DEL) { > - if (!is_exist) { > + if (is_exist !=3D 1) { > PMD_DRV_LOG(ERR, "Profile does not exist."); > rte_free(profile_info_sec); > return -EACCES; > -- > 2.5.5