[PATCH v5 2/2] drivers/net: return number of types in get supported types

Ferruh Yigit ferruh.yigit at amd.com
Tue Jan 23 15:59:19 CET 2024


On 1/23/2024 12:07 PM, Power, Ciara wrote:
> Hi Ferruh,
> 
>> -----Original Message-----
>> From: Ferruh Yigit <ferruh.yigit at amd.com>
>> Sent: Friday, January 19, 2024 2:51 PM
>> To: Sivaramakrishnan, VenkatX <venkatx.sivaramakrishnan at intel.com>; Igor
>> Russkikh <irusskikh at marvell.com>; Selwin Sebastian
>> <selwin.sebastian at amd.com>; Ajit Khaparde
>> <ajit.khaparde at broadcom.com>; Somnath Kotur
>> <somnath.kotur at broadcom.com>; Nithin Dabilpuram
>> <ndabilpuram at marvell.com>; Kiran Kumar K <kirankumark at marvell.com>;
>> Sunil Kumar Kori <skori at marvell.com>; Satha Rao
>> <skoteshwar at marvell.com>; Zhang, Yuying <yuying.zhang at intel.com>; Xing,
>> Beilei <beilei.xing at intel.com>; Rahul Lakkireddy
>> <rahul.lakkireddy at chelsio.com>; Hemant Agrawal
>> <hemant.agrawal at nxp.com>; Sachin Saxena <sachin.saxena at nxp.com>; Su,
>> Simei <simei.su at intel.com>; Wu, Wenjun1 <wenjun1.wu at intel.com>;
>> Gagandeep Singh <g.singh at nxp.com>; John Daley <johndale at cisco.com>;
>> Hyong Youb Kim <hyonkim at cisco.com>; Gaetan Rivet <grive at u256.net>;
>> Zhang, Qi Z <qi.z.zhang at intel.com>; Wang, Xiao W <xiao.w.wang at intel.com>;
>> Jie Hai <haijie1 at huawei.com>; Yisen Zhuang <yisen.zhuang at huawei.com>;
>> Wu, Jingjing <jingjing.wu at intel.com>; Yang, Qiming
>> <qiming.yang at intel.com>; Guo, Junfeng <junfeng.guo at intel.com>; Andrew
>> Boyer <andrew.boyer at amd.com>; Long Li <longli at microsoft.com>; Matan
>> Azrad <matan at nvidia.com>; Viacheslav Ovsiienko <viacheslavo at nvidia.com>;
>> Dariusz Sosnowski <dsosnowski at nvidia.com>; Ori Kam <orika at nvidia.com>;
>> Suanming Mou <suanmingm at nvidia.com>; Chaoyong He
>> <chaoyong.he at corigine.com>; Jiawen Wu <jiawenwu at trustnetic.com>;
>> Harman Kalra <hkalra at marvell.com>; Devendra Singh Rawat
>> <dsinghrawat at marvell.com>; Alok Prasad <palok at marvell.com>; Andrew
>> Rybchenko <andrew.rybchenko at oktetlabs.ru>; Jerin Jacob
>> <jerinj at marvell.com>; Maciej Czekaj <mczekaj at marvell.com>; Jian Wang
>> <jianwang at trustnetic.com>; Behrens, Jochen <jbehrens at vmware.com>;
>> Thomas Monjalon <thomas at monjalon.net>
>> Cc: dev at dpdk.org; Power, Ciara <ciara.power at intel.com>
>> Subject: Re: [PATCH v5 2/2] drivers/net: return number of types in get
>> supported types
>>
>> On 1/18/2024 12:07 PM, Sivaramakrishnan Venkat wrote:
>>> Missing "RTE_PTYPE_UNKNOWN" ptype causes buffer overflow.
>>> Enhance code such that the dev_supported_ptypes_get() function pointer
>>> now returns  the number of elements to eliminate the need for
>>> "RTE_PTYPE_UNKNOWN" as the last item.
>>>
>>> Signed-off-by: Sivaramakrishnan Venkat
>>> <venkatx.sivaramakrishnan at intel.com>
>>>
>>> --
>>>   v5:
>>>      - modified commit message.
>>>      - tidied formatting of code.
>>>      - added doxygen comment.
>>>   v4:
>>>      - split into two patches, one for backporting and another one for
>>>        upstream rework.
>>>   v3:
>>>      - reworked the function to return number of elements and remove the
>>>        need for RTE_PTYPE_UNKNOWN in list.
>>>   v2:
>>>      - extended fix for multiple drivers.
>>> ---
>>
>> <...>
>>
>>>  59 files changed, 188 insertions(+), 141 deletions(-)
>>>
>>
>> Some driver still have the flag:
>> - drivers/net/mvneta/mvneta_ethdev.c
>> - drivers/net/mvpp2/mrvl_ethdev.c
>> - pfe
>> - dpaa
>> - drivers/net/thunderx/nicvf_ethdev.c
>> - drivers/net/nfp/nfp_net_common.c
>>
>> Above seems the ones updated in previous patch, flags added in previous
>> patch should be removed in this one.
>>
>>
>> And following seems missed and still has the flag:
>>
>> - drivers/net/ngbe/ngbe_ptypes.c
>>
>> <...>
>>
>>> @@ -3971,9 +3975,6 @@ rte_eth_dev_set_ptypes(uint16_t port_id,
>> uint32_t ptype_mask,
>>>  		}
>>>  	}
>>>
>>> -	if (set_ptypes != NULL && j < num)
>>> -		set_ptypes[j] = RTE_PTYPE_UNKNOWN;
>>> -
>>>
>>
>> This change is new in this version and not mentioned in the changelog.
>>
>> 'rte_eth_dev_set_ptypes()' returns 'set_ptypes' that terminated with
>> 'RTE_PTYPE_UNKNOWN', this is how that API works.
>> Why changing it in this patch?
> 
> Apologies, yes, we missed this in the changelog.
> 
> For the change itself, if we are removing the need for RTE_PTYPE_UNKNOWN in the supported ptypes lists to mark the last element, do we still need to add it here when setting ptypes list?
> Maybe a misunderstanding on my part - I thought it would be the same for both cases.
> 
> 

They are two different APIs, and 'rte_eth_dev_set_ptypes()' returns
ptypes to user that will be terminated by RTE_PTYPE_UNKNOWN, so to not
break the user code we can't change it.




More information about the dev mailing list