<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Aptos;
        panose-1:2 11 0 4 2 2 2 2 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:10.0pt;
        font-family:"Aptos",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
span.EmailStyle21
        {mso-style-type:personal-reply;
        font-family:"Aptos",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;
        mso-ligatures:none;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="en-PS" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<div id="mail-editor-reference-message-container">
<div>
<div>
<div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Comment inline below.</span><span lang="EN-US"><o:p></o:p></span></p>
</div>
<p class="MsoNormal" style="margin-left:36.0pt"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"> </span><span lang="EN-US"><o:p></o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:12.0pt;margin-left:36.0pt">
<b><span lang="EN-US" style="font-family:"Tahoma",sans-serif">From:</span></b><span lang="EN-US" style="font-family:"Tahoma",sans-serif"> Raslan Darawsheh [mailto:rasland@nvidia.com]
<br>
<b>Sent:</b> Monday, 24 March 2025 08.35</span><span lang="EN-US"><o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal" style="margin-left:36.0pt"><span lang="EN-US"> <o:p></o:p></span></p>
<div id="mail-editor-reference-message-container">
<div>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:12.0pt;margin-left:72.0pt">
<span lang="EN-US" style="font-size:11.0pt">>> From: Raslan Darawsheh [<a href="mailto:rasland@nvidia.com">mailto:rasland@nvidia.com</a>]<br>
>> Sent: Sunday, 23 March 2025 13.28<br>
>> <br>
>> Updated the `get_ethertype_by_ptype` function to correctly parse VLAN<br>
>> headers.<br>
>> <br>
>> Fixes: 76730c7b9b5a ("app/testpmd: use packet type parsing API")<br>
>> Cc: haijie1@huawei.com<br>
>> <br>
>>> Signed-off-by: Raslan Darawsheh <rasland@nvidia.com><br>
>> ---<br>
>>  app/test-pmd/csumonly.c | 8 +++++---<br>
>>  1 file changed, 5 insertions(+), 3 deletions(-)<br>
>> <br>
>> diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c<br>
>> index 5b906eaa53..302cc4cc66 100644<br>
>> --- a/app/test-pmd/csumonly.c<br>
>> +++ b/app/test-pmd/csumonly.c<br>
>> @@ -468,6 +468,7 @@ get_ethertype_by_ptype(struct rte_ether_hdr<br>
>> *eth_hdr, uint32_t ptype)<br>
>>  {<br>
>>        struct rte_vlan_hdr *vlan_hdr;<br>
>>        uint16_t ethertype;<br>
>> +     uint32_t i = 0;<br>
>> <br>
>>        switch (ptype) {<br>
>>        case RTE_PTYPE_L3_IPV4:<br>
>> @@ -486,10 +487,11 @@ get_ethertype_by_ptype(struct rte_ether_hdr<br>
>> *eth_hdr, uint32_t ptype)<br>
>>                return _htons(RTE_ETHER_TYPE_IPV6);<br>
>>        default:<br>
>>                ethertype = eth_hdr->ether_type;<br>
>> -             while (eth_hdr->ether_type == _htons(RTE_ETHER_TYPE_VLAN)<br>
>> ||<br>
>> -                     eth_hdr->ether_type == _htons(RTE_ETHER_TYPE_QINQ)) {<br>
>> +             while (ethertype == _htons(RTE_ETHER_TYPE_VLAN) ||<br>
>> +                     ethertype == _htons(RTE_ETHER_TYPE_QINQ)) {<br>
>>                        vlan_hdr = (struct rte_vlan_hdr *)<br>
>> -                             ((char *)eth_hdr + sizeof(*eth_hdr));<br>
>> +                             ((char *)eth_hdr + sizeof(*eth_hdr) +<br>
>> +                             (i * sizeof(struct rte_vlan_hdr)));<br>
<br>
>Doesn't work; "i" is not incremented, and remains 0.<br>
>Instead do this: Initialize (struct rte_vlan_hdr *)vlan_hdr=RTE_PTR_ADD(eth_hdr, offsetof(rte_ether_hdr, ether_type)) before the loop, and move vlan_hdr+=RTE_VLAN_HLEN inside the loop.<br>
Yes you are correct I had a (i++ *) but must have slipped while rebasing will handle your way in v2
</span><span lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:12.0pt;margin-left:36.0pt">
<span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">MB: Noticed a bug in my suggestion: Due to the type of vlan_hdr, moving it should be vlan_hdr++, not vlan_hdr+=RTE_VLAN_HLEN.</span><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span lang="EN-US" style="font-size:11.0pt">                 Yes sure will handle,
<o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:12.0pt;margin-left:36.0pt">
<span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">MB: And you might want to impose a maximum boundary to the loop, as suggested by Stephen. E.g. break out of the loop if vlan_hdr>RTE_PTR_ADD(eth_hdr, offsetof(rte_ether_hdr,
 ether_type)+4*sizeof(struct rte_vlan_hdr)). Supporting up to 4 stacked VLAN tags should suffice.</span><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span lang="EN-US" style="font-size:11.0pt">              I’m not sure this should be added to this patch, as I tend to believe it’s less critical to handle for this release, and also, this might cause inconsistent
 results, think of the case if we send five stacked vlan tags, then we’ll return ethertype as VLAN as we skipped the last one.<o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:12.0pt;margin-left:72.0pt">
<span lang="EN-US" style="font-size:11.0pt"><br>
>>                        ethertype = vlan_hdr->eth_proto;<br>
>>                }<br>
>>                return ethertype;<br>
>> --<br>
>> 2.39.5 (Apple Git-154)</span><span lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:12.0pt;margin-left:36.0pt">
<span lang="EN-US" style="font-size:11.0pt"> </span><span lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:12.0pt;margin-left:36.0pt">
<span lang="EN-US" style="font-size:11.0pt">Kindest regards</span><span lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:12.0pt;margin-left:36.0pt">
<span lang="EN-US" style="font-size:11.0pt">Raslan Darawsheh</span><span lang="EN-US"><o:p></o:p></span></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>