Re: [PATCH] eal: allow both allow and block options coexistence

2023-07-07 Thread Thomas Monjalon
07/07/2023 07:07, Marvin Liu:
> Currently, all buses use the same eal allow and block options. Need to
> allow both allow and block options for different buses to coexist.
> It wouldn't be a problem for pci bus if both allow and block options
> were present. When the first option occurs, the scan mode for pci bus is
> set.
> 
> For example:
>   --allow :05:00.0 --block wq0.0
> only pci device :05:00.0 will be scanned
> all devices except wq0.0 on dsa bus will be scanned
>   --allow :05:00.0 --block :05:00.1
> block option will be ignored
>   --block :05:00.1 --allow :05:00.0
> allow option will be ignored

It is wrong to ignore a user parameter silently.

Also, it would be clearer to use the new devargs syntax
with bus=pci,addr=:05:00.0





[Bug 1261] [dpdk 23.07] the dpdk-testpmd (based on VF) 's throughput is 0

2023-07-07 Thread bugzilla
https://bugs.dpdk.org/show_bug.cgi?id=1261

Bug ID: 1261
   Summary: [dpdk 23.07] the dpdk-testpmd (based on VF) 's
throughput is 0
   Product: DPDK
   Version: 23.07
  Hardware: x86
OS: Linux
Status: UNCONFIRMED
  Severity: major
  Priority: Normal
 Component: testpmd
  Assignee: dev@dpdk.org
  Reporter: yangh...@redhat.com
  Target Milestone: ---

Description of problem:
start a dpdk-testpmd based on VF , do the Moongen Throughput tests, the
dpdk-testpmd throughput is 0 

Version-Release number of selected component (if applicable):
host:
Ethernet Controller 10-Gigabit X540-AT2
5.14 kernel


How reproducible:
100%

Steps to Reproduce:
1. setup the host kernel option
# grubby --args="iommu=pt intel_iommu=on default_hugepagesz=1G"
--update-kernel=`grubby --default-kernel` 
# reboot

2. setup hugepage number
# echo 20 >
/sys/devices/system/node/node0/hugepages/hugepages-1048576kB/nr_hugepages
# echo 20 >
/sys/devices/system/node/node1/hugepages/hugepages-1048576kB/nr_hugepages

3. create VF and setup VF mac address

# /usr/sbin/ifconfig ens3f0  up
# echo 2 > /sys/bus/pci/devices/\:5e\:00.0/sriov_numvfs
# readlink /sys/bus/pci/devices/:5e:00.0/virtfn*
# ip link set enp94s0f0 vf 0 mac 88:66:da:5f:dd:02
# dpdk-devbind.py --bind=vfio-pci :5e:10.0
# /usr/sbin/ifconfig ens3f1 up
# echo 2 > /sys/bus/pci/devices/\:5e\:00.1/sriov_numvfs
# readlink /sys/bus/pci/devices/:5e:00.1/virtfn*
# ip link set enp94s0f1 vf 0 mac 88:66:da:5f:dd:03
# dpdk-devbind.py --bind=vfio-pci :5e:10.1


4. start a dpdk-testpmd on the host
# /usr/local/bin/dpdk-testpmd -l 2,4,6 -n 4  -- --nb-cores=2 -i --disable-rss
--rxd=512 --txd=512 --rxq=1 --txq=1 
EAL: Detected CPU lcores: 64
EAL: Detected NUMA nodes: 2
EAL: Detected static linkage of DPDK
EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
EAL: Selected IOVA mode 'VA'
EAL: VFIO support initialized
EAL: Using IOMMU type 1 (Type 1)
EAL: Probe PCI driver: net_ixgbe_vf (8086:1515) device: :5e:10.0 (socket 0)
EAL: Probe PCI driver: net_ixgbe_vf (8086:1515) device: :5e:10.1 (socket 0)
TELEMETRY: No legacy callbacks, legacy socket not created
Interactive-mode selected
testpmd: create a new mbuf pool : n=163456, size=2176, socket=0
testpmd: preferred mempool ops selected: ring_mp_mc
Configuring Port 0 (socket 0)
Port 0: 88:66:DA:5F:DD:02
Configuring Port 1 (socket 0)
Port 1: 88:66:DA:5F:DD:03
Checking link statuses...
Done
testpmd> set fwd mac retry
Set mac packet forwarding mode with retry
testpmd> vlan set strip on 0
testpmd> vlan set strip on 1
testpmd> start
mac packet forwarding with retry - ports=2 - cores=2 - streams=2 - NUMA support
enabled, MP allocation mode: native
TX retry num: 64, delay between TX retries: 1us
Logical Core 4 (socket 0) forwards packets on 1 streams:
  RX P=0/Q=0 (socket 0) -> TX P=1/Q=0 (socket 0) peer=02:00:00:00:00:01
Logical Core 6 (socket 0) forwards packets on 1 streams:
  RX P=1/Q=0 (socket 0) -> TX P=0/Q=0 (socket 0) peer=02:00:00:00:00:00

  mac packet forwarding with retry packets/burst=32
  nb forwarding cores=2 - nb forwarding ports=2
  port 0: RX queue number: 1 Tx queue number: 1
Rx offloads=0x1 Tx offloads=0x0
RX queue: 0
  RX desc=512 - RX free threshold=32
  RX threshold registers: pthresh=0 hthresh=0  wthresh=0
  RX Offloads=0x1
TX queue: 0
  TX desc=512 - TX free threshold=32
  TX threshold registers: pthresh=32 hthresh=0  wthresh=0
  TX offloads=0x0 - TX RS bit threshold=32
  port 1: RX queue number: 1 Tx queue number: 1
Rx offloads=0x1 Tx offloads=0x0
RX queue: 0
  RX desc=512 - RX free threshold=32
  RX threshold registers: pthresh=0 hthresh=0  wthresh=0
  RX Offloads=0x1
TX queue: 0
  TX desc=512 - TX free threshold=32
  TX threshold registers: pthresh=32 hthresh=0  wthresh=0
  TX offloads=0x0 - TX RS bit threshold=32



5. Use Moongen to do the DPDK VF throughput tests

# ./build/MoonGen throughput.lua 88:66:da:5f:dd:02 88:66:da:5f:dd:03 


6. check the dpdk-testpmd all ports' throughput 

testpmd> show port stats all 

   NIC statistics for port 0  
  RX-packets: 511RX-missed: 0  RX-bytes:  30660
  RX-errors: 0
  RX-nombuf:  0 
  TX-packets: 0  TX-errors: 0  TX-bytes:  0

  Throughput (since last show)
  Rx-pps:0  Rx-bps:0
  Tx-pps:0  Tx-bps:0
  

   NIC statistics for port 1  
  RX-packets: 511RX-missed: 0  RX-bytes:  31208
  RX-errors: 0
  RX-nombuf:  0 
  TX-packets: 0  TX-errors: 0  TX-bytes:  0

  Throughput (since last show)
  Rx-pps:0  Rx-bps:0
  Tx-pps: 

RedHat QE's test result against release candidate 23.07-rc2

2023-07-07 Thread YangHang Liu
Hi,I has runned all my dpdk test cases against 23.07-rc2 already and the
test details fris as follows:

Test environment:

   - kernel 5.14
   - qemu 6.2
   - dpdk: git://dpdk.org/dpdk

# git log -1

commit 93a4b3beba4ee611685148917981f846427cafb2
Author: Thomas Monjalon 
Date:   Wed Jun 28 02:27:14 2023 +0200
version: 23.07-rc2
Signed-off-by: Thomas Monjalon 


   - NICs: X540-AT2 NIC(ixgbe, 10G)

Test result:

   - Guest with device assignment(PF) throughput testing(1G hugepage size):
   PASS
   - Guest with device assignment(PF) throughput testing(2M hugepage size)
   : PASS
   - Guest with vhost-user 2Q throughput testing: PASS
   - Vhost-user reconnect with dpdk-client, qemu-server: qemu reconnect:
   PASS
   - Vhost-user reconnect with dpdk-client, qemu-server: ovs reconnect: PASS
   - Guest with ovs+dpdk+vhost-user 1Q live migration testing: PASS
   - Guest with ovs+dpdk+vhost-user 1Q live migration testing (2M): PASS
   - Guest with ovs+dpdk+vhost-user 2Q live migration testing: PASS
   - Guest with ovs+dpdk+vhost-user 4Q live migration testing: PASS
   - Host PF + DPDK testing: PASS
   - PVP 1Q live migration testing: PASS
   - PVP (host dpdk testpmd as vswitch) 1Q: throughput testing: PASS
   - PVP vhost-user 2Q throughput testing: PASS
   - PVP vhost-user 1Q - cross numa node throughput testing:  PASS
   - PVP 1Q cross numa node live migration testing: PASS
   - PVP 4Q  reconnect with dpdk-client, qemu-server dpdk-testpmd
   reconnect: PASS
  - Guest with device assignment(VF) throughput testing:  FAILED
   - Host VF + DPDK testing: FAILED

My test result shows 2 DPDK + VF tests failed and  I have opened a upstream
dpdk bug for tracking this regression issue: Bug 1261
 - [dpdk 23.07] the
dpdk-testpmd (based on VF) 's throughput is 0



Best Regards,
YangHang Liu


[PATCH] net/iavf: fix vlan offload strip flag inconsistency

2023-07-07 Thread Wenjing Qiao
For i40e in-tree kernel driver, it will set strip on when setting
filter on. To be consistent with dpdk, disable strip again.

Fixes: cb25d4323fbf ("net/avf: enable MAC VLAN and promisc ops")

Signed-off-by: Wenjing Qiao 
---
 drivers/net/iavf/iavf.h|  1 +
 drivers/net/iavf/iavf_ethdev.c | 18 ++
 drivers/net/iavf/iavf_vchnl.c  |  2 ++
 3 files changed, 21 insertions(+)

diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index 98861e4242..18b05f5cce 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -325,6 +325,7 @@ struct iavf_adapter {
bool closed;
uint16_t fdir_ref_cnt;
struct iavf_devargs devargs;
+   bool is_strip; /* only for vlan v1 */
 };
 
 /* IAVF_DEV_PRIVATE_TO */
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index 00b963128b..8cd534e93c 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -1379,6 +1379,24 @@ iavf_dev_vlan_filter_set(struct rte_eth_dev *dev, 
uint16_t vlan_id, int on)
err = iavf_add_del_vlan(adapter, vlan_id, on);
if (err)
return -EIO;
+   /* for i40e in-tree kernel driver, it will set strip on when setting
+* filter on. To be consistent with dpdk, disable strip again.
+*/
+   if (adapter->hw.vendor_id == IAVF_INTEL_VENDOR_ID) {
+   switch (adapter->hw.device_id) {
+   case IAVF_DEV_ID_VF:
+   case IAVF_DEV_ID_VF_HV:
+   case IAVF_DEV_ID_X722_VF:
+   if (on && !adapter->is_strip) {
+   err = iavf_disable_vlan_strip(adapter);
+   if (err)
+   return -EIO;
+   }
+   break;
+   default:
+   break;
+   }
+   }
return 0;
 }
 
diff --git a/drivers/net/iavf/iavf_vchnl.c b/drivers/net/iavf/iavf_vchnl.c
index 524732f67d..2d2fee4312 100644
--- a/drivers/net/iavf/iavf_vchnl.c
+++ b/drivers/net/iavf/iavf_vchnl.c
@@ -589,6 +589,7 @@ iavf_enable_vlan_strip(struct iavf_adapter *adapter)
PMD_DRV_LOG(ERR, "Failed to execute command of"
" OP_ENABLE_VLAN_STRIPPING");
 
+   adapter->is_strip = true;
return ret;
 }
 
@@ -611,6 +612,7 @@ iavf_disable_vlan_strip(struct iavf_adapter *adapter)
" OP_DISABLE_VLAN_STRIPPING");
 
return ret;
+   adapter->is_strip = false;
 }
 
 #define VIRTCHNL_VERSION_MAJOR_START 1
-- 
2.34.1



Re: [PATCH v6] app/mldev: add internal function for file read

2023-07-07 Thread Thomas Monjalon
07/06/2023 19:24, Srikanth Yalavarthi:
> Added internal function to read model, input and reference
> files with required error checks. This change fixes the
> unchecked return value and improper use of negative value
> issues reported by coverity scan for file read operations.
> 
> Coverity issue: 383742, 383743
> Fixes: f6661e6d9a3a ("app/mldev: validate model operations")
> Fixes: da6793390596 ("app/mldev: support inference validation")
> 
> Signed-off-by: Srikanth Yalavarthi 

Applied, thanks.





Re: [PATCH v1] app/mldev: improve checks for invalid options

2023-07-07 Thread Thomas Monjalon
12/06/2023 19:58, Srikanth Yalavarthi:
> Improve checks for ML application options. Check for negative,
> non-integral and hexadecimal values. Check for number of entries
> in filelist option. Improve error reporting for invalid options.
> 
> Signed-off-by: Srikanth Yalavarthi 

Applied, thanks.





Re: [PATCH v1] app/mldev: fix error reporting on IO failure

2023-07-07 Thread Thomas Monjalon
12/06/2023 20:00, Srikanth Yalavarthi:
> Application is reporting the test output as success when a
> failure occurs in writing the output. Fix incorrect error
> reporting on failure to write output files.
> 
> Fixes: da6793390596 ("app/mldev: support inference validation")
> 
> Signed-off-by: Srikanth Yalavarthi 

Applied, thanks.






RE: [PATCH] bus/cdx: provide driver flag for optional resource mapping

2023-07-07 Thread Gupta, Nipun



> -Original Message-
> From: Abhijit Gangurde 
> Sent: Monday, June 26, 2023 4:10 PM
> To: Gupta, Nipun ; Agarwal, Nikhil
> 
> Cc: dev@dpdk.org; david.march...@redhat.com; Yigit, Ferruh
> ; Gangurde, Abhijit 
> Subject: [PATCH] bus/cdx: provide driver flag for optional resource mapping
> 
> Provide driver flag which gives an option to map the cdx
> device resource before probing the device driver.
> Also, make rte_cdx_map_device() API as public to map
> device resource separately.
> 
> Signed-off-by: Abhijit Gangurde 
> ---
>  drivers/bus/cdx/bus_cdx_driver.h | 26 ++---
>  drivers/bus/cdx/cdx.c| 11 ---
>  drivers/bus/cdx/rte_bus_cdx.h| 50 
>  drivers/bus/cdx/version.map  | 11 +--
>  4 files changed, 69 insertions(+), 29 deletions(-)
>  create mode 100644 drivers/bus/cdx/rte_bus_cdx.h
> 



> +/* Forward declarations */
> +struct rte_cdx_device;
> +
> +/**
> + * Map the CDX device resources in user space virtual memory address
> + *
> + * Note that driver should not call this function when flag
> + * RTE_CDX_DRV_NEED_MAPPING is set, as EAL will do that for
> + * you when it's on.
> + *
> + * @param dev
> + *   A pointer to a rte_cdx_device structure describing the device
> + *   to use
> + *
> + * @return
> + *   0 on success, negative on error and positive if no driver
> + *   is found for the device.
> + */
> +int rte_cdx_map_device(struct rte_cdx_device *dev);

rte_experimental?



[Bug 1261] [dpdk 23.07] the dpdk-testpmd (based on VF) 's throughput is 0

2023-07-07 Thread bugzilla
https://bugs.dpdk.org/show_bug.cgi?id=1261

David Marchand (david.march...@redhat.com) changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |DUPLICATE
 CC||david.march...@redhat.com

--- Comment #1 from David Marchand (david.march...@redhat.com) ---
Thank you for the report.

I logged on this system, reproduced the issue on the main branch.
The fix from bz #1259 restored packet processing.

*** This bug has been marked as a duplicate of bug 1259 ***

-- 
You are receiving this mail because:
You are the assignee for the bug.

RE: [PATCH] doc: update BIOS setting and supported HW list for NTB

2023-07-07 Thread Guo, Junfeng



> -Original Message-
> From: Stephen Hemminger 
> Sent: Friday, July 7, 2023 04:30
> To: Wu, Jingjing 
> Cc: Guo, Junfeng ; dev@dpdk.org;
> sta...@dpdk.org
> Subject: Re: [PATCH] doc: update BIOS setting and supported HW list for
> NTB
> 
> On Mon, 3 Jul 2023 09:35:29 +
> "Wu, Jingjing"  wrote:
> 
> > > -Original Message-
> > > From: Guo, Junfeng 
> > > Sent: Monday, July 3, 2023 5:25 PM
> > > To: Wu, Jingjing 
> > > Cc: dev@dpdk.org; sta...@dpdk.org; Guo, Junfeng
> 
> > > Subject: [PATCH] doc: update BIOS setting and supported HW list for
> NTB
> > >
> > > Update BIOS settings and supported platform list for Intel NTB.
> > >
> > > Fixes: f5057be340e4 ("raw/ntb: support Intel Ice Lake")
> > > Cc: sta...@dpdk.org
> > >
> > > Signed-off-by: Junfeng Guo 
> >
> > Acked-by: Jingjing Wu 
> 
> Kind of unfortunate that the documentation does not list why non-
> standard
> settings are needed for DPDK.

Thanks for the comments!
Yes, these BIOS settings are used to enable the NTB device so that it can
be used by DPDK PMD or other drivers. 
I'm not quite sure about the principle of each required item. But without
them, the NTB device cannot show up in the PCI buses list.
We can update them gradually once we know the purpose of each setting.
Thanks!



Re: [EXT] [PATCH] ipsec: fix NAT-T length calculation

2023-07-07 Thread Radu Nicolau



On 07-Jul-23 4:12 AM, Xiao Liang wrote:

|<-   mb->pkt_len - sqh_len   ->|
|<-sa->hdr_len->|
|<- sa->hdr_l3_off ->||<- udph->dgram_len ->|

+++-+-+-+-+
| ETH| IP | UDP | ESP | payload | sqh |
+++-+-+-+-+

|<- sa->hdr_l3_off ->|<- l3_len ->|
|<-  prm->tun.hdr_len   ->|
|<-sa->hdr_len->|


sa->hdr_len and prm->tun.hdr_len don't include L2 length so both should 
start in the diagram at the end of the ETH header.


So the right way to compute datagram length is

dgram_len = mb->pkt_len - sqh_len - sa->hdr_l3_off - sa->hdr_len + 
sizeof(struct rte_udp_hdr)





The figure above shows how
 udph->dgram_len = mb->pkt_len - sqh_len - sa->hdr_len +
sizeof(struct rte_udp_hdr);
and
 l3_len = prm->tun.hdr_len - sa->hdr_l3_off;

Correct me if anything wrong.

Thanks,
Xiao Liang




On Thu, Jul 6, 2023 at 6:20 PM Radu Nicolau  wrote:


On 06-Jul-23 10:08 AM, Konstantin Ananyev wrote:

Hi Akhil,


Hi Konstantin,
Can you review this patch?


UDP header length is included in sa->hdr_len. Take care of that in
L3 header and pakcet length calculation.

Fixes: 01eef5907fc3 ("ipsec: support NAT-T")

Signed-off-by: Xiao Liang 
---
   lib/ipsec/esp_outb.c | 2 +-
   lib/ipsec/sa.c   | 2 +-
   2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/ipsec/esp_outb.c b/lib/ipsec/esp_outb.c
index 9cbd9202f6..ec87b1dce2 100644
--- a/lib/ipsec/esp_outb.c
+++ b/lib/ipsec/esp_outb.c
@@ -198,7 +198,7 @@ outb_tun_pkt_prepare(struct rte_ipsec_sa *sa,
rte_be64_t sqc,
 struct rte_udp_hdr *udph = (struct rte_udp_hdr *)
 (ph + sa->hdr_len - sizeof(struct rte_udp_hdr));
 udph->dgram_len = rte_cpu_to_be_16(mb->pkt_len - sqh_len -
-   sa->hdr_l3_off - sa->hdr_len);
+   sa->hdr_len + sizeof(struct rte_udp_hdr));

To be honest, it is not clear to me why we shouldn't take into account 
sa->hdr_l3_off
   any more.
Probably the author can explain.
Also would like author of  NAT-T support to chime in.
Radu, any comments on that patch?

I agree, hdr_l3_off should not be ignored. Also sa->hdr_len already
includes the size of UDP header, see line 366 in esp_outb_tun_init in
sa.c (or the line above this change, where the udph pointer is computed
assuming this)

Thanks
Konstantin


 }

 /* update original and new ip header fields */
diff --git a/lib/ipsec/sa.c b/lib/ipsec/sa.c
index 59a547637d..2297bd6d72 100644
--- a/lib/ipsec/sa.c
+++ b/lib/ipsec/sa.c
@@ -371,7 +371,7 @@ esp_outb_tun_init(struct rte_ipsec_sa *sa, const struct
rte_ipsec_sa_prm *prm)

 /* update l2_len and l3_len fields for outbound mbuf */
 sa->tx_offload.val = rte_mbuf_tx_offload(sa->hdr_l3_off,
-   sa->hdr_len - sa->hdr_l3_off, 0, 0, 0, 0, 0);
+   prm->tun.hdr_len - sa->hdr_l3_off, 0, 0, 0, 0, 0);

 esp_outb_init(sa, sa->hdr_len, prm->ipsec_xform.esn.value);
   }
--
2.40.0


Re: [PATCH] net/mana: fix wrong indexing on CQE error when coalescing is used

2023-07-07 Thread Ferruh Yigit
On 7/7/2023 1:17 AM, lon...@linuxonhyperv.com wrote:
> From: Long Li 
> 
> On a fatal CQE error when coalescing is used, update the correct index
> and allow proceeding to the next CQE.
> 
> Fixes: 3409e0f172f6 ("net/mana: implement Rx CQE coalescing")
>

Is above fixes commit correct?
Logic for 'CQE_RX_COALESCED_4' is not changed with this commit, in above
commit and in this commit both does breaks the loop.

This commit changes logic for 'CQE_RX_TRUNCATED' and 'default' cases,
which are added with different commits, not the one in fixes line.

"fatal CQE error when coalescing" mentioned in the commit log, to which
switch case does this corresponds to?


> Signed-off-by: Long Li 
> ---
>  drivers/net/mana/rx.c | 18 --
>  1 file changed, 8 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/net/mana/rx.c b/drivers/net/mana/rx.c
> index cacfd9ae1b..220b372b15 100644
> --- a/drivers/net/mana/rx.c
> +++ b/drivers/net/mana/rx.c
> @@ -416,23 +416,21 @@ mana_rx_burst(void *dpdk_rxq, struct rte_mbuf **pkts, 
> uint16_t pkts_n)
>  
>   switch (oob->cqe_hdr.cqe_type) {
>   case CQE_RX_OKAY:
> + case CQE_RX_COALESCED_4:
>   /* Proceed to process mbuf */
>   break;
>  
>   case CQE_RX_TRUNCATED:
> - DP_LOG(DEBUG, "Drop a truncated packet");
> + default:
> + DP_LOG(ERR, "RX CQE type %d client %d vendor %d",
> +oob->cqe_hdr.cqe_type, oob->cqe_hdr.client_type,
> +oob->cqe_hdr.vendor_err);
> +
>   rxq->stats.errors++;
>   rte_pktmbuf_free(mbuf);
> - goto drop;
> -
> - case CQE_RX_COALESCED_4:
> - /* Proceed to process mbuf */
> - break;
>  
> - default:
> - DP_LOG(ERR, "Unknown RX CQE type %d",
> -oob->cqe_hdr.cqe_type);
> - continue;
> + i++;
> + goto drop;
>   }
>  
>   DP_LOG(DEBUG, "mana_rx_comp_oob type %d rxq %p",



Re: [PATCH v17] app/procinfo: display eventdev xstats

2023-07-07 Thread Thomas Monjalon
25/05/2023 22:07, Stephen Hemminger:
> On Thu, 25 May 2023 13:47:31 -0500
> Abdullah Sevincer  wrote:
> 
> > This commit extends proc-info application to
> > display xstats for the eventdev devices.
> > 
> > New command line arguments are introduced to
> > display xstats for eventdev devices. The command
> > example is like:
> > 
> > For displaying a specific port stats (e.g. port 1):
> > ./dpdk-proc-info -- --show-edev-port-xstats=1:0
> > 
> > If any xstats parameters for eventdev passed through
> > proc-info command line, proc-info will only display
> > requested eventdev data and exit.
> > 
> > Users should not pass any eventdev xstats parameters
> > if they desire to dump other proc-info data such as
> > Rx/Tx descriptor dump.
> > More information can be found in proc-info app doc.
> > 
> > Signed-off-by: Abdullah Sevincer 
> 
> Acked-by: Stephen Hemminger 

Applied, thanks.





Re: release candidate 23.07-rc2

2023-07-07 Thread Thinh Tran

IBM - Power Systems
DPDK v23.07-rc2-5-ga64a456470

* Build CI on Fedora 30,31,34,36,37 for ppc64le
* Basic PF on Mellanox: No issue found
* Performance: not tested.
* OS: RHEL 9.1  kernel: 5.14.0-162.6.1.el9_1.ppc64le
with gcc version 11.3.1 20220421 (Red Hat 11.3.1-2) (GCC)
  RHEL 8.8  kernel: 4.18.0-477.10.1.el8_8.ppc64le
with gcc version 8.5.0 20210514 (Red Hat 8.5.0-18) (GCC)


Systems tested:
 - LPARs on IBM Power10 CHRP IBM,9105-22A
NICs:
- Mellanox Mellanox Technologies MT2894 Family [ConnectX-6 Lx]
- firmware version: 26.37.1014
- MLNX_OFED_LINUX-23.04-0.5.3.6

Regards,
Thinh Tran

On 6/27/2023 7:59 PM, Thomas Monjalon wrote:

A new DPDK release candidate is ready for testing:
https://git.dpdk.org/dpdk/tag/?id=v23.07-rc2

There are 237 new patches in this snapshot.

Release notes:
https://doc.dpdk.org/guides/rel_notes/release_23_07.html

There were a lot of updates in drivers.
The driver features should be frozen now.

Please test and report issues on bugs.dpdk.org.
Do not forget to review examples, tests and documentation updates.
Breaking changes for 23.11 must be announced in 23.07.

DPDK 23.07-rc3 is expected in approximately one week.

Thank you everyone







RE: [PATCH] net/iavf: fix vlan offload strip flag inconsistency

2023-07-07 Thread Huang, ZhiminX
-Original Message-
From: Qiao, Wenjing  
Sent: Friday, July 7, 2023 3:58 PM
To: Wu, Jingjing ; Xing, Beilei 
Cc: dev@dpdk.org; Huang, ZhiminX ; Qiao, Wenjing 

Subject: [PATCH] net/iavf: fix vlan offload strip flag inconsistency

For i40e in-tree kernel driver, it will set strip on when setting filter on. To 
be consistent with dpdk, disable strip again.

Fixes: cb25d4323fbf ("net/avf: enable MAC VLAN and promisc ops")

Signed-off-by: Wenjing Qiao 
---
 drivers/net/iavf/iavf.h|  1 +
 drivers/net/iavf/iavf_ethdev.c | 18 ++  
drivers/net/iavf/iavf_vchnl.c  |  2 ++
 3 files changed, 21 insertions(+)

Verified vf vlan filter and strip cases in i40e and ice intree driver, tested 
pass.
Tested-by: Zhimin Huang 




Re: [PATCH v2] net/failsafe: link_update request crashing at boot

2023-07-07 Thread Ferruh Yigit
On 2/15/2022 4:24 PM, Vipul Ashri wrote:
> On 11/22/2021 3:53 PM, Gaëtan Rivet wrote:
>> Could describe in more detail the execution?
>> In particular, setting the EAL log-level to debug with the option:
>> ' --log-level pmd.net.failsafe:debug '
>> for example while using testpmd or your DPDK app.
>> It should show ethdev level accesses to the sub-devices, and error values.
>>
>> Best regards,
> 
> Hi Gaetan
> 
> Sorry for very late reply, we were busy working on 21.11 integration.
> 
> Although we have adopted this code internally for us but I am sharing the 
> patch to opensource for community benefit.
> 
> This is specific case of AZURE setup with our very customized complex 
> environment.
> 
> Let me share the logs with trace-back first
> ==
> SECONDARY PROCESS
> timestamp=1633598184
> TCZ0.0.0 Cycle 152 (Build 1832)
> signal 11 (Segmentation fault), address is 0x31117bbce6c8 from 0x47d08b1
> 
> [bt]: ( 1) _Z18snprintf_backtraceRPciiP9siginfo_tPv  (+   0xf4) - sp = 
> 0x7fffef3fd110, ip = 0x3acdc54
> [bt]: ( 2) _Z13crit_err_hdlriP9siginfo_tPv   (+  0x159) - sp = 
> 0x7fffef3fdc20, ip = 0x3acdf29
> [bt]: ( 3) _ZN13SignalAdapter12handleSignalEiP9siginfo_tPv (+  0x104) - sp = 
> 0x7fffef3fdf00, ip = 0x274d4c4
> [bt]: ( 4) _L_unlock_18  (+   0x2c) - sp = 
> 0x7fffef3fdf80, ip = 0x77bce630
> [bt]: ( 5) rte_eth_dev_attach_secondary  (+   0x21) - sp = 
> 0x7fffef3fec50, ip = 0x47d08b1
> [bt]: ( 6) rte_eth_from_ring (+ 0x3438) - sp = 
> 0x7fffef3fec80, ip = 0x4e49da8
> [bt]: ( 7) _init (+ 0xa1b8) - sp = 
> 0x7fffef3feec0, ip = 0x12e0368
> [bt]: ( 8) local_dev_probe   (+   0xac) - sp = 
> 0x7fffef3feef0, ip = 0x478fd2c
> [bt]: ( 9) rte_uuid_unparse  (+  0x274) - sp = 
> 0x7fffef3fef30, ip = 0x47a3e94
> [bt]: (10) rte_eal_vfio_get_vf_token (+   0xd7) - sp = 
> 0x7fffef3ff110, ip = 0x47b04b7
> [bt]: (11) eal_hugepage_info_read    (+  0x602) - sp = 
> 0x7fffef3ff170, ip = 0x47b2cd2
> [bt]: (12) start_thread  (+   0xc5) - sp = 
> 0x7fffef3ff220, ip = 0x77bc6ea5
> [bt]: (13) clone (+   0x6d) - sp = 
> 0x7fffef3ff2c0, ip = 0x7004096d
> EAL: Fail to recv reply for request 
> /var/run/dpdk/oracusbc/mp_socket:eal_dev_mp_request
> EAL: Cannot send request to primary
> EAL: Failed to send hotplug request to primary
> net_failsafe: Failed to probe devargs net_tap_vsc0
> EAL: Fail to recv reply for request 
> /var/run/dpdk/oracusbc/mp_socket:eal_dev_mp_request
> EAL: Cannot send request to primary
> EAL: Failed to send hotplug request to primary
> net_failsafe: Failed to probe devargs net_tap_vsc1
> EAL: No legacy callbacks, legacy socket not created
> EAL: Drop mp reply: eal_dev_mp_request
> ==
> PRIMARY PROCESS
> timestamp=1633598196
> TCZ0.0.0 Cycle 152 (Build 1832)
> signal 11 (Segmentation fault), address is 0x38 from 0x9d8fbe
> 
> [bt]: ( 1) _Z18snprintf_backtraceRPciiP9siginfo_tPv  (+   0xf4) - sp = 
> 0x7fffecf41150, ip = 0x100dd44
> [bt]: ( 2) _Z13crit_err_hdlriP9siginfo_tPv   (+  0x159) - sp = 
> 0x7fffecf41c60, ip = 0x100e019
> [bt]: ( 3) _ZN13SignalAdapter12handleSignalEiP9siginfo_tPv (+  0x104) - sp = 
> 0x7fffecf41f40, ip = 0xff4894
> [bt]: ( 4) _L_unlock_18  (+   0x2c) - sp = 
> 0x7fffecf41fc0, ip = 0x761d9630
> [bt]: ( 5) failsafe_eth_dev_close    (+  0x65e) - sp = 
> 0x7fffecf42c90, ip = 0x9d8fbe
> [bt]: ( 6) rte_eth_link_get_nowait   (+   0x6a) - sp = 
> 0x7fffecf42cf0, ip = 0x62fa0a
> [bt]: ( 7) _ZN11StatsThread9statsLoopEP10CustomObject  (+  0x33e) - sp = 
> 0x7fffecf42d20, ip = 0xedea2e
> [bt]: ( 8) _ZN11StatsThread9statsLoopEP10CustomObject  (+  0x8dc) - sp = 
> 0x7fffecf42d90, ip = 0xedefcc
> [bt]: ( 9) ThreadFunction    (+   0xe6) - sp = 
> 0x7fffecf42db0, ip = 0x76b477e6
> [bt]: (10) start_thread  (+   0xc5) - sp = 
> 0x7fffecf42de0, ip = 0x761d1ea5
> [bt]: (11) clone (+   0x6d) - sp = 
> 0x7fffecf42e80, ip = 0x70a6b96d
> 
> ==
> DPDK 20.11.2
> core mask is 4000
> DPDK Custom Process initialized with 2 ports
> the min max TxQ is maxTxQueues 16
> Using 1 RxQs for port 0 (# F-core=1)
> Using 1 RxQs for port 3 (# F-core=1)
> Core 14 (port=0, rxQ=0) kni_ring=(nil)
> Core 14 (port=3, rxQ=0) kni_ring=(nil)
> Core 14 txN = 0
> Thread 

Re: [PATCH v11] app/dma-perf: introduce dma-perf application

2023-07-07 Thread Thomas Monjalon
> > There are many high-performance DMA devices supported in DPDK now, and
> > these DMA devices can also be integrated into other modules of DPDK as
> > accelerators, such as Vhost. Before integrating DMA into applications,
> > developers need to know the performance of these DMA devices in various
> > scenarios and the performance of CPUs in the same scenario, such as
> > different buffer lengths. Only in this way can we know the target
> > performance of the application accelerated by using them. This patch
> > introduces a high-performance testing tool, which supports comparing the
> > performance of CPU and DMA in different scenarios automatically with a
> > pre-set config file. Memory Copy performance test are supported for now.
> > This patch also updates the documentation and maintainer list for the
> > application.
> > 
> > Signed-off-by: Cheng Jiang 
> > Signed-off-by: Jiayu Hu 
> > Signed-off-by: Yuan Wang 
> > Acked-by: Morten Brørup 
> > Acked-by: Chenbo Xia 
> > Acked-by: Anoob Joseph 
> > Tested-by: Anoob Joseph 
> > Tested-by: Wei Ling 
> 
> Acked-by: Chengwen Feng 

Applied with few improvements in the documentation, thanks.




Re: [PATCH v3] graph: fix graph model check in core binding

2023-07-07 Thread Jerin Jacob
On Wed, Jul 5, 2023 at 7:38 AM Zhirun Yan  wrote:
>
> Fix graph model check in core binding with graph. And rte_graph_clone()

Two fixes, Lets have two patches. Also tell what is fixed and how it is fixed.


> need to use valid params rather than NULL pointer. Update release notes
> for new mcore dispatch model.
>
> Fixes: ecb22a294980 ("graph: introduce graph bind unbind API")
> Fixes: 67e2303cd823 ("test/graph: add functional tests for mcore dispatch 
> model")
>
> Signed-off-by: Zhirun Yan 
> ---
>  app/test/test_graph.c  | 15 ---
>  doc/guides/rel_notes/release_23_07.rst | 11 +++
>  lib/graph/graph.c  |  2 +-
>  3 files changed, 24 insertions(+), 4 deletions(-)
>
> diff --git a/app/test/test_graph.c b/app/test/test_graph.c
> index 8609c0b3a4..8983363c8e 100644
> --- a/app/test/test_graph.c
> +++ b/app/test/test_graph.c
> @@ -702,6 +702,7 @@ 
> test_graph_model_mcore_dispatch_node_lcore_affinity_set(void)
> unsigned int worker_lcore = RTE_MAX_LCORE;
> rte_node_t nid = RTE_NODE_ID_INVALID;
> char node_name[64] = "test_node00";
> +   struct rte_graph_param graph_conf;

Initialize with zero or defaults, aka add =  { 0 }


Re: [PATCH v4] dmadev: add tracepoints

2023-07-07 Thread Thomas Monjalon
26/05/2023 10:42, Chengwen Feng:
> Add tracepoints at important APIs for tracing support.
> 
> Signed-off-by: Chengwen Feng 
> Acked-by: Morten Brørup 
> 
> ---
> v4: Fix asan smoke fail.
> v3: Address Morten's comment:
> Move stats_get and vchan_status and to trace_fp.h.
> v2: Address Morten's comment:
> Make stats_get as fast-path trace-points.
> Place fast-path trace-point functions behind in version.map.

There are more things to fix.
First you must export rte_dmadev_trace_fp.h as it is included by rte_dmadev.h.
Note: you could have caught this if testing the example app for DMA.
Second, you must avoid structs and enum in this header file,
otherwise it cannot be included alone.
Look at what is done in other *_trace_fp.h files.





[PATCH] net/hns3: fix non-zero weight for disabled TC

2023-07-07 Thread Dongdong Liu
From: Huisong Li 

hns3 PF driver enables one TC, allocates to 100% weight for this
TC and 0% for other disabled TC by default. But driver modifies
the weight to 1% for disabled TC and then set to hardware to make
all TC work in DWRR mode. As a result, the total percent of all TC
is more than 100%. Actually, this operation is also redundant,
because these disabled TC will never be used. So this patch sets
the weight of all TC based on user's configuration.

Fixes: 62e3ccc2b94c ("net/hns3: support flow control")
Cc: sta...@dpdk.org

Signed-off-by: Huisong Li 
Signed-off-by: Dongdong Liu 
---
 drivers/net/hns3/hns3_dcb.c | 9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/net/hns3/hns3_dcb.c b/drivers/net/hns3/hns3_dcb.c
index af045b22f7..07b8c46a81 100644
--- a/drivers/net/hns3/hns3_dcb.c
+++ b/drivers/net/hns3/hns3_dcb.c
@@ -237,9 +237,9 @@ hns3_dcb_qs_weight_cfg(struct hns3_hw *hw, uint16_t qs_id, 
uint8_t dwrr)
 static int
 hns3_dcb_ets_tc_dwrr_cfg(struct hns3_hw *hw)
 {
-#define DEFAULT_TC_WEIGHT  1
 #define DEFAULT_TC_OFFSET  14
struct hns3_ets_tc_weight_cmd *ets_weight;
+   struct hns3_pg_info *pg_info;
struct hns3_cmd_desc desc;
uint8_t i;
 
@@ -247,13 +247,6 @@ hns3_dcb_ets_tc_dwrr_cfg(struct hns3_hw *hw)
ets_weight = (struct hns3_ets_tc_weight_cmd *)desc.data;
 
for (i = 0; i < HNS3_MAX_TC_NUM; i++) {
-   struct hns3_pg_info *pg_info;
-
-   ets_weight->tc_weight[i] = DEFAULT_TC_WEIGHT;
-
-   if (!(hw->hw_tc_map & BIT(i)))
-   continue;
-
pg_info = &hw->dcb_info.pg_info[hw->dcb_info.tc_info[i].pgid];
ets_weight->tc_weight[i] = pg_info->tc_dwrr[i];
}
-- 
2.22.0



Re: [PATCH] net/hns3: fix non-zero weight for disabled TC

2023-07-07 Thread Ferruh Yigit
On 7/7/2023 11:40 AM, Dongdong Liu wrote:
> From: Huisong Li 
> 
> hns3 PF driver enables one TC, allocates to 100% weight for this
> TC and 0% for other disabled TC by default. But driver modifies
> the weight to 1% for disabled TC and then set to hardware to make
> all TC work in DWRR mode. As a result, the total percent of all TC
> is more than 100%. Actually, this operation is also redundant,
> because these disabled TC will never be used. So this patch sets
> the weight of all TC based on user's configuration.
> 
> Fixes: 62e3ccc2b94c ("net/hns3: support flow control")
> Cc: sta...@dpdk.org
> 
> Signed-off-by: Huisong Li 
> Signed-off-by: Dongdong Liu 
>

Applied to dpdk-next-net/main, thanks.


Re: [PATCH v3 1/2] crypto/ipsec_mb: remove unused defines

2023-07-07 Thread Maxime Coquelin




On 7/6/23 18:21, Brian Dooley wrote:

removed AESNI_MB_DOCSIS_SEC_ENABLED defines as they are no longer used.

Fixes: 798f9d134519 ("crypto/ipsec_mb: remove security lib presence checks")
Cc: maxime.coque...@redhat.com

Signed-off-by: Brian Dooley 
---
  drivers/crypto/ipsec_mb/ipsec_mb_private.c  |  4 
  drivers/crypto/ipsec_mb/pmd_aesni_mb.c  | 22 ++---
  drivers/crypto/ipsec_mb/pmd_aesni_mb_priv.h |  1 -
  3 files changed, 2 insertions(+), 25 deletions(-)



Reviewed-by: Maxime Coquelin 

Thanks,
Maxime



Re: [PATCH v3 04/14] test: cryptodev use rte_pktmbuf_mtod_offset

2023-07-07 Thread Ferruh Yigit
On 7/6/2023 6:59 PM, Stephen Hemminger wrote:
> Based off patch generated by cocci/mtod-offset.cocci.
> With some cleanup to shorten lines by using conditional
> with omitted operand.
> 
> Signed-off-by: Stephen Hemminger 

<...>

> @@ -5163,9 +5169,9 @@ test_snow3g_auth_cipher(const struct snow3g_test_data 
> *tdata,
>   debug_hexdump(stdout, "ciphertext expected:",
>   tdata->ciphertext.data, tdata->ciphertext.len >> 3);
>  
> - ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
> - + (tdata->digest.offset_bytes == 0 ?
> - plaintext_pad_len : tdata->digest.offset_bytes);
> + ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
> + uint8_t *,
> + tdata->digest.offset_bytes ? : 
> plaintext_pad_len);
>  

As far as I know "x ?: y" support is gcc extention, what about sticking
to standard syntax?


Re: [PATCH v3 13/14] net/mlx4: use rte_pktmbuf_mtod_offset

2023-07-07 Thread Ferruh Yigit
On 7/6/2023 6:59 PM, Stephen Hemminger wrote:
> Autogenerated with cocci/mtod-offset.cocci.
> 
> Signed-off-by: Stephen Hemminger 
> ---
>  drivers/net/mlx4/mlx4_rxtx.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/mlx4/mlx4_rxtx.c b/drivers/net/mlx4/mlx4_rxtx.c
> index 059e432a63fc..d5feeb7f7e6d 100644
> --- a/drivers/net/mlx4/mlx4_rxtx.c
> +++ b/drivers/net/mlx4/mlx4_rxtx.c
> @@ -1014,9 +1014,9 @@ mlx4_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, 
> uint16_t pkts_n)
>* loopback in eSwitch, so that VFs and PF can
>* communicate with each other.
>*/
> - srcrb.flags16[0] = *(rte_pktmbuf_mtod(buf, uint16_t *));
> - ctrl->imm = *(rte_pktmbuf_mtod_offset(buf, uint32_t *,
> -   sizeof(uint16_t)));
> + srcrb.flags16[0] = *rte_pktmbuf_mtod(buf, uint16_t *);
> + ctrl->imm = *rte_pktmbuf_mtod_offset(buf, uint32_t *,
> +  sizeof(uint16_t));
>   } else {
>   ctrl->imm = 0;
>   }

Although parenthesis may not be required, keeping them looks more clear
to me; personal preferences.

And patch title is not accurate for this patch.



Re: [PATCH v3 00/14] Use rte_pktmbuf_mtod_offset() where possible

2023-07-07 Thread Ferruh Yigit
On 7/6/2023 6:59 PM, Stephen Hemminger wrote:
> Run the coccinelle script for rte_pktmbuf_mtod_offset
> against current main branch.
> 
> v3 - rebase to cover gro changes
> 

There is one more instance in 'gro_tcp6.c'

```
$ ag -s 'rte_pktmbuf_mtod\(.*\).*\+' lib/
lib/gro/gro_tcp6.c
121:ipv6_hdr = (struct rte_ipv6_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
```


> Stephen Hemminger (14):
>   gro: use rte_pktmbuf_mtod_offset
>   gso: use rte_pktmbuf_mtod_offset
>   testpmd: use rte_pktmbuf_mtod_offset
>   test: cryptodev use rte_pktmbuf_mtod_offset
>   examples: use rte_pktmbuf_mtod_offset
>   net/tap: use rte_pktmbuf_mtod_offset
>   net/nfp: use rte_pktmbuf_mtod_offset
>   crypto/ipsec_mb: use rte_pktmbuf_mtod_offset
>   crypto/qat: use rte_pktmbuf_mtod_offset
>   crypto/cnxk: use rte_ptkmbuf_mtod_offset
>   common/cpt: use rte_pktmbuf_mtod_offset
>   crypto/caam_jr: use rte_pktmbuf_mtod_offset
>   net/mlx4: use rte_pktmbuf_mtod_offset
>   baseband/fpga_5gnr: use rte_pktmbu_mtod_offset


For series,
Reviewed-by: Ferruh Yigit 

There are a few minor issues commented on individual patches.



Re: [EXT] [PATCH] ipsec: fix NAT-T length calculation

2023-07-07 Thread Xiao Liang
> sa->hdr_len and prm->tun.hdr_len don't include L2 length so both should
> start in the diagram at the end of the ETH header.
>
> So the right way to compute datagram length is
>
> dgram_len = mb->pkt_len - sqh_len - sa->hdr_l3_off - sa->hdr_len +
> sizeof(struct rte_udp_hdr)
>

|<-   mb->pkt_len - sqh_len   ->|
|<- sa->hdr_l3_off ->|<- sa->hdr_len ->|
  |<- udph->dgram_len ->|

+++-+-+-+-+
| ETH| IP | UDP | ESP | payload | sqh |
+++-+-+-+-+

|<- sa->hdr_l3_off ->|<- l3_len ->|
 |<- sa->hdr_len  ->|

If hdr_len doesn't include L2 length, I would agree that

dgram_len = mb->pkt_len - sqh_len - sa->hdr_l3_off - sa->hdr_len +
sizeof(struct rte_udp_hdr)

But then what's the point of
sa->hdr_len - sa->hdr_l3_off
in lib/ipsec/sa.c?


Re: [EXT] [PATCH] ipsec: fix NAT-T length calculation

2023-07-07 Thread Xiao Liang
The context

hlen = sa->hdr_len + sa->iv_len + sizeof(*esph);
...
ph = rte_pktmbuf_prepend(mb, hlen - l2len);
...
update_tun_outb_l3hdr(sa, ph + sa->hdr_l3_off, ph + hlen,
mb->pkt_len - sqh_len, sa->hdr_l3_off, sqn_low16(sqc));

assumes L2 header length included in sa->hdr_len.

Even if hdr_len doesn't include L2, then mb->pkt_len won't either, so
UDP datagram length should still be
mb->pkt_len - sqh_len - sa->hdr_len + sizeof(struct rte_udp_hdr);

On Fri, Jul 7, 2023 at 8:51 PM Xiao Liang  wrote:
>
> > sa->hdr_len and prm->tun.hdr_len don't include L2 length so both should
> > start in the diagram at the end of the ETH header.
> >
> > So the right way to compute datagram length is
> >
> > dgram_len = mb->pkt_len - sqh_len - sa->hdr_l3_off - sa->hdr_len +
> > sizeof(struct rte_udp_hdr)
> >
>
> |<-   mb->pkt_len - sqh_len   ->|
> |<- sa->hdr_l3_off ->|<- sa->hdr_len ->|
>   |<- udph->dgram_len ->|
>
> +++-+-+-+-+
> | ETH| IP | UDP | ESP | payload | sqh |
> +++-+-+-+-+
>
> |<- sa->hdr_l3_off ->|<- l3_len ->|
>  |<- sa->hdr_len  ->|
>
> If hdr_len doesn't include L2 length, I would agree that
>
> dgram_len = mb->pkt_len - sqh_len - sa->hdr_l3_off - sa->hdr_len +
> sizeof(struct rte_udp_hdr)
>
> But then what's the point of
> sa->hdr_len - sa->hdr_l3_off
> in lib/ipsec/sa.c?


Re: [EXT] [PATCH] ipsec: fix NAT-T length calculation

2023-07-07 Thread Radu Nicolau



On 07-Jul-23 1:51 PM, Xiao Liang wrote:

sa->hdr_len and prm->tun.hdr_len don't include L2 length so both should
start in the diagram at the end of the ETH header.

So the right way to compute datagram length is

dgram_len = mb->pkt_len - sqh_len - sa->hdr_l3_off - sa->hdr_len +
sizeof(struct rte_udp_hdr)


|<-   mb->pkt_len - sqh_len   ->|
|<- sa->hdr_l3_off ->|<- sa->hdr_len ->|
   |<- udph->dgram_len ->|

+++-+-+-+-+
| ETH| IP | UDP | ESP | payload | sqh |
+++-+-+-+-+

|<- sa->hdr_l3_off ->|<- l3_len ->|
  |<- sa->hdr_len  ->|

If hdr_len doesn't include L2 length, I would agree that

 dgram_len = mb->pkt_len - sqh_len - sa->hdr_l3_off - sa->hdr_len +
sizeof(struct rte_udp_hdr)

But then what's the point of
 sa->hdr_len - sa->hdr_l3_off
in lib/ipsec/sa.c?


I will defer to Konstantin for a definite answer, that is if sa->hdr_len 
is supposed to include l2 length / offset or not. If it does, then the 
change that triggered this discussion is correct and we don't need to 
account for hdr_l3_off there.




Re: [PATCH v17] app/procinfo: display eventdev xstats

2023-07-07 Thread Stephen Hemminger
On Fri, 07 Jul 2023 11:15:22 +0200
Thomas Monjalon  wrote:

> 25/05/2023 22:07, Stephen Hemminger:
> > On Thu, 25 May 2023 13:47:31 -0500
> > Abdullah Sevincer  wrote:
> >   
> > > This commit extends proc-info application to
> > > display xstats for the eventdev devices.
> > > 
> > > New command line arguments are introduced to
> > > display xstats for eventdev devices. The command
> > > example is like:
> > > 
> > > For displaying a specific port stats (e.g. port 1):
> > > ./dpdk-proc-info -- --show-edev-port-xstats=1:0
> > > 
> > > If any xstats parameters for eventdev passed through
> > > proc-info command line, proc-info will only display
> > > requested eventdev data and exit.
> > > 
> > > Users should not pass any eventdev xstats parameters
> > > if they desire to dump other proc-info data such as
> > > Rx/Tx descriptor dump.
> > > More information can be found in proc-info app doc.
> > > 
> > > Signed-off-by: Abdullah Sevincer   
> > 
> > Acked-by: Stephen Hemminger   
> 
> Applied, thanks.

Has new coverity issue.
The reason is the boolean is set every time because it gets every time.

Looks like code goes over eventdev_var[] even if no eventdevs are present.
Should only look for the number of eventdevs

*** CID 395458:  Control flow issues  (DEADCODE)
/app/proc-info/main.c: 2114 in process_eventdev_xstats()
2108}
2109}
2110 
2111if (processing_eventdev_xstats)
2112return 1;
2113 
>>> CID 395458:  Control flow issues  (DEADCODE)
>>> Execution cannot reach this statement: "return 0;".  
2114return 0;
2115 }
2116 
2117 int
2118 main(int argc, char **argv)
2119 {



Re: [PATCH v2 1/2] net/virtio: fix legacy device IO port map in secondary process

2023-07-07 Thread Gupta, Nipun




On 7/3/2023 3:01 PM, Xia, Chenbo wrote:

+Nipun


-Original Message-
From: David Marchand 
Sent: Monday, July 3, 2023 4:58 PM
To: Li, Miao 
Cc: dev@dpdk.org; sta...@dpdk.org; Maxime Coquelin
; Xia, Chenbo 
Subject: Re: [PATCH v2 1/2] net/virtio: fix legacy device IO port map in
secondary process

On Mon, Jul 3, 2023 at 10:54 AM Li, Miao  wrote:

When doing IO port map for legacy device in secondary process,
vfio_cfg setup for legacy device like vfio_group_fd and vfio_dev_fd

is

missing. So, in secondary process, rte_pci_map_device is added for
legacy device to setup vfio_cfg and fill in region info like in
primary process.


I think, in legacy mode, there is no PCI mappable memory.
So there should be no need for this call to rte_pci_map_device.

What is missing is a vfio setup, is this correct?
I'd rather see this issue be fixed in the pci_vfio_ioport_map()

function.



If adding vfio setup in the pci_vfio_ioport_map() function, vfio will be

setup twice in primary process because rte_pci_map_device will be called
for legacy device in primary process.

I add IO port region check to skip region map in the next patch.


Well, something must be done so that it is not mapped twice, I did not
look into the details.
This current patch looks wrong to me and I understand this is not a
virtio only issue.


I think we could have some way to improve this:

1. Make rte_pci_map_device map either PIO or MMIO (Based on my knowledge, it's 
doable
for vfio. For UIO, I am no expert and not sure). For ioport, it's only about 
setting
up the ioport offset and size.
2. rte_pci_ioport_map may not be needed anymore.
3. struct rte_pci_ioport may not be needed anymore as the info could be saved in
struct rte_pci_device_internal.
4. ioport device uses bar #, len, offset to RW specific BAR.

Then for virtio device, either primary or secondary process only calls 
rte_pci_map_device
once.

Any comments?


Wouldn't a call to API rte_vfio_setup_device() to setup vfio_cfg, 
vfio_group_fd, vfio_dev_fd under a secondary process check suffice to 
handle IO port map for legacy device in secondary process?


I do not have much info on legacy Virtio device, and I am not clear on 
why and how for these devices rte_pci_map_device() would be called in 
case of primary process, but not in case of secondary process as 
mentioned by Miao Li?


Steps you have mentioned looks fine but note that this would cause an 
ABI breakage and as you mentioned may need changes in UIO (even I am not 
an expert in UIO).


Thanks,
Nipun



Thanks,
Chenbo




--
David Marchand




RE: [PATCH] net/mana: fix wrong indexing on CQE error when coalescing is used

2023-07-07 Thread Long Li
> Subject: Re: [PATCH] net/mana: fix wrong indexing on CQE error when coalescing
> is used
> 
> On 7/7/2023 1:17 AM, lon...@linuxonhyperv.com wrote:
> > From: Long Li 
> >
> > On a fatal CQE error when coalescing is used, update the correct index
> > and allow proceeding to the next CQE.
> >
> > Fixes: 3409e0f172f6 ("net/mana: implement Rx CQE coalescing")
> >
> 
> Is above fixes commit correct?
> Logic for 'CQE_RX_COALESCED_4' is not changed with this commit, in above
> commit and in this commit both does breaks the loop.

Yes, the "Fixes" tag is correct. Here CQE_RX_COALESCED_4 is rearranged to make 
it easier to read, but it doesn't change the behavior.

> 
> This commit changes logic for 'CQE_RX_TRUNCATED' and 'default' cases, which
> are added with different commits, not the one in fixes line.
> 
> "fatal CQE error when coalescing" mentioned in the commit log, to which switch
> case does this corresponds to?

The previous patch (3409e0f172f6 ) introduced variable "i", an index to 
completion CQEs. But both 'default' and 'CQE_RX_TRUNCATED' cases don't advance 
"i", hence not advance to next CQE on error.

The fatal CQE error means the "default" case. On 'CQE_RX_TRUNCATED' the code 
can recover when all CQEs are read. But on "default", it's a dead loop.

> 
> 
> > Signed-off-by: Long Li 
> > ---
> >  drivers/net/mana/rx.c | 18 --
> >  1 file changed, 8 insertions(+), 10 deletions(-)
> >
> > diff --git a/drivers/net/mana/rx.c b/drivers/net/mana/rx.c index
> > cacfd9ae1b..220b372b15 100644
> > --- a/drivers/net/mana/rx.c
> > +++ b/drivers/net/mana/rx.c
> > @@ -416,23 +416,21 @@ mana_rx_burst(void *dpdk_rxq, struct rte_mbuf
> > **pkts, uint16_t pkts_n)
> >
> > switch (oob->cqe_hdr.cqe_type) {
> > case CQE_RX_OKAY:
> > +   case CQE_RX_COALESCED_4:
> > /* Proceed to process mbuf */
> > break;
> >
> > case CQE_RX_TRUNCATED:
> > -   DP_LOG(DEBUG, "Drop a truncated packet");
> > +   default:
> > +   DP_LOG(ERR, "RX CQE type %d client %d vendor %d",
> > +  oob->cqe_hdr.cqe_type, oob->cqe_hdr.client_type,
> > +  oob->cqe_hdr.vendor_err);
> > +
> > rxq->stats.errors++;
> > rte_pktmbuf_free(mbuf);
> > -   goto drop;
> > -
> > -   case CQE_RX_COALESCED_4:
> > -   /* Proceed to process mbuf */
> > -   break;
> >
> > -   default:
> > -   DP_LOG(ERR, "Unknown RX CQE type %d",
> > -  oob->cqe_hdr.cqe_type);
> > -   continue;
> > +   i++;
> > +   goto drop;
> > }
> >
> > DP_LOG(DEBUG, "mana_rx_comp_oob type %d rxq %p",



[PATCH] net/mana: set the correct queue state

2023-07-07 Thread longli
From: Long Li 

Set the queue state when queue is started/stopped

Signed-off-by: Long Li 
---
 drivers/net/mana/rx.c | 15 +++
 drivers/net/mana/tx.c | 13 +
 2 files changed, 28 insertions(+)

diff --git a/drivers/net/mana/rx.c b/drivers/net/mana/rx.c
index 220b372b15..1047ac1743 100644
--- a/drivers/net/mana/rx.c
+++ b/drivers/net/mana/rx.c
@@ -131,6 +131,10 @@ mana_stop_rx_queues(struct rte_eth_dev *dev)
struct mana_priv *priv = dev->data->dev_private;
int ret, i;
 
+   for (i = 0; i < priv->num_queues; i++)
+   if (dev->data->rx_queue_state[i] == RTE_ETH_QUEUE_STATE_STOPPED)
+   return -EINVAL;
+
if (priv->rwq_qp) {
ret = ibv_destroy_qp(priv->rwq_qp);
if (ret)
@@ -187,7 +191,10 @@ mana_stop_rx_queues(struct rte_eth_dev *dev)
 
memset(&rxq->gdma_rq, 0, sizeof(rxq->gdma_rq));
memset(&rxq->gdma_cq, 0, sizeof(rxq->gdma_cq));
+
+   dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED;
}
+
return 0;
 }
 
@@ -199,6 +206,11 @@ mana_start_rx_queues(struct rte_eth_dev *dev)
struct ibv_wq *ind_tbl[priv->num_queues];
 
DRV_LOG(INFO, "start rx queues");
+
+   for (i = 0; i < priv->num_queues; i++)
+   if (dev->data->rx_queue_state[i] == RTE_ETH_QUEUE_STATE_STARTED)
+   return -EINVAL;
+
for (i = 0; i < priv->num_queues; i++) {
struct mana_rxq *rxq = dev->data->rx_queues[i];
struct ibv_wq_init_attr wq_attr = {};
@@ -373,6 +385,9 @@ mana_start_rx_queues(struct rte_eth_dev *dev)
goto fail;
}
 
+   for (i = 0; i < priv->num_queues; i++)
+   dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
+
return 0;
 
 fail:
diff --git a/drivers/net/mana/tx.c b/drivers/net/mana/tx.c
index 5947efbe8d..eb4b60cc10 100644
--- a/drivers/net/mana/tx.c
+++ b/drivers/net/mana/tx.c
@@ -15,6 +15,10 @@ mana_stop_tx_queues(struct rte_eth_dev *dev)
struct mana_priv *priv = dev->data->dev_private;
int i, ret;
 
+   for (i = 0; i < priv->num_queues; i++)
+   if (dev->data->tx_queue_state[i] == RTE_ETH_QUEUE_STATE_STOPPED)
+   return -EINVAL;
+
for (i = 0; i < priv->num_queues; i++) {
struct mana_txq *txq = dev->data->tx_queues[i];
 
@@ -51,6 +55,8 @@ mana_stop_tx_queues(struct rte_eth_dev *dev)
 
memset(&txq->gdma_sq, 0, sizeof(txq->gdma_sq));
memset(&txq->gdma_cq, 0, sizeof(txq->gdma_cq));
+
+   dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED;
}
 
return 0;
@@ -63,6 +69,11 @@ mana_start_tx_queues(struct rte_eth_dev *dev)
int ret, i;
 
/* start TX queues */
+
+   for (i = 0; i < priv->num_queues; i++)
+   if (dev->data->tx_queue_state[i] == RTE_ETH_QUEUE_STATE_STARTED)
+   return -EINVAL;
+
for (i = 0; i < priv->num_queues; i++) {
struct mana_txq *txq;
struct ibv_qp_init_attr qp_attr = { 0 };
@@ -142,6 +153,8 @@ mana_start_tx_queues(struct rte_eth_dev *dev)
txq->gdma_cq.id, txq->gdma_cq.buffer,
txq->gdma_cq.count, txq->gdma_cq.size,
txq->gdma_cq.head);
+
+   dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
}
 
return 0;
-- 
2.34.1



[PATCH] net/netvsc: set the correct queue state

2023-07-07 Thread longli
From: Long Li 

Set the queue state when queue is started/stopped.

Signed-off-by: Long Li 
---
 drivers/net/netvsc/hn_ethdev.c | 15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c
index d0bbc0a4c0..0c15f9f826 100644
--- a/drivers/net/netvsc/hn_ethdev.c
+++ b/drivers/net/netvsc/hn_ethdev.c
@@ -1017,6 +1017,11 @@ hn_dev_start(struct rte_eth_dev *dev)
if (error == 0)
hn_dev_link_update(dev, 0);
 
+   for (int i = 0; i < hv->num_queues; i++) {
+   dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
+   dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED;
+   }
+
return error;
 }
 
@@ -1024,13 +1029,21 @@ static int
 hn_dev_stop(struct rte_eth_dev *dev)
 {
struct hn_data *hv = dev->data->dev_private;
+   int ret;
 
PMD_INIT_FUNC_TRACE();
dev->data->dev_started = 0;
 
rte_dev_event_callback_unregister(NULL, netvsc_hotadd_callback, hv);
hn_rndis_set_rxfilter(hv, 0);
-   return hn_vf_stop(dev);
+   ret = hn_vf_stop(dev);
+
+   for (int i = 0; i < hv->num_queues; i++) {
+   dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED;
+   dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED;
+   }
+
+   return ret;
 }
 
 static int
-- 
2.34.1



Re: [PATCH] net/netvsc: set the correct queue state

2023-07-07 Thread Stephen Hemminger
On Fri,  7 Jul 2023 11:53:16 -0700
lon...@linuxonhyperv.com wrote:

> From: Long Li 
> 
> Set the queue state when queue is started/stopped.
> 
> Signed-off-by: Long Li 
> ---
>  drivers/net/netvsc/hn_ethdev.c | 15 ++-
>  1 file changed, 14 insertions(+), 1 deletion(-)

Interesting that not all drivers do this.

Acked-by: Stephen Hemminger 

The ones not doing it.
af_packet
af_xdp
avp
axgbe
bnx2x
bonding
dpaa
dpaa2
e1000
ena
enetfec
gve
hinic
igc
ipn3ke
kni
liquidio
mana
memif
mlx4
netvsc
nfp
null
octeon_ep
pfe
ring
softnic
vdev_netvsc
vhost
virtio
vmxnet3


[PATCH v4 01/11] gro: use rte_pktmbuf_mtod_offset

2023-07-07 Thread Stephen Hemminger
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

Signed-off-by: Stephen Hemminger 
---
 lib/gro/gro_tcp.h| 4 ++--
 lib/gro/gro_tcp4.c   | 4 ++--
 lib/gro/gro_tcp6.c   | 4 ++--
 lib/gro/gro_udp4.c   | 4 ++--
 lib/gro/gro_vxlan_tcp4.c | 4 ++--
 lib/gro/gro_vxlan_udp4.c | 4 ++--
 6 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/lib/gro/gro_tcp.h b/lib/gro/gro_tcp.h
index d926c4b8cc71..bbd2f9c16a00 100644
--- a/lib/gro/gro_tcp.h
+++ b/lib/gro/gro_tcp.h
@@ -150,8 +150,8 @@ check_seq_option(struct gro_tcp_item *item,
struct rte_tcp_hdr *tcph_orig;
uint16_t len, tcp_hl_orig;
 
-   iph_orig = (char *)(rte_pktmbuf_mtod(pkt_orig, char *) +
-   l2_offset + pkt_orig->l2_len);
+   iph_orig = rte_pktmbuf_mtod_offset(pkt_orig, char *,
+  l2_offset + pkt_orig->l2_len);
tcph_orig = (struct rte_tcp_hdr *)(iph_orig + pkt_orig->l3_len);
tcp_hl_orig = pkt_orig->l4_len;
 
diff --git a/lib/gro/gro_tcp4.c b/lib/gro/gro_tcp4.c
index 6645de592b63..d6c0f9182d45 100644
--- a/lib/gro/gro_tcp4.c
+++ b/lib/gro/gro_tcp4.c
@@ -223,8 +223,8 @@ update_header(struct gro_tcp_item *item)
struct rte_ipv4_hdr *ipv4_hdr;
struct rte_mbuf *pkt = item->firstseg;
 
-   ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-   pkt->l2_len);
+   ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+  pkt->l2_len);
ipv4_hdr->total_length = rte_cpu_to_be_16(pkt->pkt_len -
pkt->l2_len);
 }
diff --git a/lib/gro/gro_tcp6.c b/lib/gro/gro_tcp6.c
index 5aa39801e132..6edfb6045cf6 100644
--- a/lib/gro/gro_tcp6.c
+++ b/lib/gro/gro_tcp6.c
@@ -118,8 +118,8 @@ update_header(struct gro_tcp_item *item)
struct rte_ipv6_hdr *ipv6_hdr;
struct rte_mbuf *pkt = item->firstseg;
 
-   ipv6_hdr = (struct rte_ipv6_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-   pkt->l2_len);
+   ipv6_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv6_hdr *,
+  pkt->l2_len);
ipv6_hdr->payload_len = rte_cpu_to_be_16(pkt->pkt_len -
pkt->l2_len - pkt->l3_len);
 }
diff --git a/lib/gro/gro_udp4.c b/lib/gro/gro_udp4.c
index 42596d33b6dc..019e05bcdea5 100644
--- a/lib/gro/gro_udp4.c
+++ b/lib/gro/gro_udp4.c
@@ -179,8 +179,8 @@ update_header(struct gro_udp4_item *item)
struct rte_mbuf *pkt = item->firstseg;
uint16_t frag_offset;
 
-   ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-   pkt->l2_len);
+   ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+  pkt->l2_len);
ipv4_hdr->total_length = rte_cpu_to_be_16(pkt->pkt_len -
pkt->l2_len);
 
diff --git a/lib/gro/gro_vxlan_tcp4.c b/lib/gro/gro_vxlan_tcp4.c
index 6ab700192261..2752650389a4 100644
--- a/lib/gro/gro_vxlan_tcp4.c
+++ b/lib/gro/gro_vxlan_tcp4.c
@@ -263,8 +263,8 @@ update_vxlan_header(struct gro_vxlan_tcp4_item *item)
 
/* Update the outer IPv4 header. */
len = pkt->pkt_len - pkt->outer_l2_len;
-   ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-   pkt->outer_l2_len);
+   ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+  pkt->outer_l2_len);
ipv4_hdr->total_length = rte_cpu_to_be_16(len);
 
/* Update the outer UDP header. */
diff --git a/lib/gro/gro_vxlan_udp4.c b/lib/gro/gro_vxlan_udp4.c
index b78a7ae89eef..ca8cee270d3d 100644
--- a/lib/gro/gro_vxlan_udp4.c
+++ b/lib/gro/gro_vxlan_udp4.c
@@ -259,8 +259,8 @@ update_vxlan_header(struct gro_vxlan_udp4_item *item)
 
/* Update the outer IPv4 header. */
len = pkt->pkt_len - pkt->outer_l2_len;
-   ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-   pkt->outer_l2_len);
+   ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+  pkt->outer_l2_len);
ipv4_hdr->total_length = rte_cpu_to_be_16(len);
 
/* Update the outer UDP header. */
-- 
2.39.2



[PATCH v4 00/11] Use rte_pktmbuf_mtod_offset

2023-07-07 Thread Stephen Hemminger
v4 - drop mlx4 change not needed
   - add some new ones in gro

Stephen Hemminger (11):
  gro: use rte_pktmbuf_mtod_offset
  gso: use rte_pktmbuf_mtod_offset
  test: use rte_pktmbuf_mtod_offset
  drivers/crypto: use rte_pktmbuf_mtod_offset
  net/nfp: use rte_pktmbuf_mtod_offset
  net/tap: use rte_pktmbuf_motd_offset
  baseband/fpga: use rte_pktmbuf_offset
  cpt: use rte_pktmbuf_mtod_offset
  testpmd: use rte_pktmbuf_mtod_offset
  examples/ptpclient: use rte_pktmbuf_mtod_offset
  examples/l2fwd-crypto: use rte_pktmbuf_mtod_offset

 app/test-pmd/ieee1588fwd.c|  4 +-
 app/test/test_cryptodev.c | 66 ++-
 .../fpga_5gnr_fec/rte_fpga_5gnr_fec.c |  7 +-
 drivers/common/cpt/cpt_ucode.h| 10 ++-
 drivers/crypto/caam_jr/caam_jr.c  |  8 +--
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c  |  2 +-
 drivers/crypto/cnxk/cnxk_se.h |  5 +-
 drivers/crypto/ipsec_mb/pmd_kasumi.c  | 19 +++---
 drivers/crypto/ipsec_mb/pmd_snow3g.c  |  4 +-
 drivers/crypto/ipsec_mb/pmd_zuc.c | 18 ++---
 drivers/crypto/qat/dev/qat_crypto_pmd_gens.h  |  9 +--
 drivers/crypto/qat/qat_sym.h  |  9 +--
 drivers/net/nfp/flower/nfp_flower_cmsg.h  |  3 +-
 drivers/net/nfp/flower/nfp_flower_ctrl.c  |  4 +-
 drivers/net/tap/rte_eth_tap.c |  4 +-
 examples/l2fwd-crypto/main.c  | 16 +++--
 examples/ptpclient/ptpclient.c| 18 ++---
 lib/gro/gro_tcp.h |  4 +-
 lib/gro/gro_tcp4.c|  4 +-
 lib/gro/gro_tcp6.c|  4 +-
 lib/gro/gro_udp4.c|  4 +-
 lib/gro/gro_vxlan_tcp4.c  |  4 +-
 lib/gro/gro_vxlan_udp4.c  |  4 +-
 lib/gso/gso_common.h  | 12 ++--
 lib/gso/gso_tcp4.c|  8 +--
 lib/gso/gso_tunnel_tcp4.c | 12 ++--
 lib/gso/gso_tunnel_udp4.c | 18 ++---
 27 files changed, 146 insertions(+), 134 deletions(-)

Reviewed-by: Ferruh Yigit 

-- 
2.39.2



[PATCH v4 02/11] gso: use rte_pktmbuf_mtod_offset

2023-07-07 Thread Stephen Hemminger
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

Signed-off-by: Stephen Hemminger 
---
 lib/gso/gso_common.h  | 12 ++--
 lib/gso/gso_tcp4.c|  8 
 lib/gso/gso_tunnel_tcp4.c | 12 ++--
 lib/gso/gso_tunnel_udp4.c | 18 +-
 4 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/lib/gso/gso_common.h b/lib/gso/gso_common.h
index 9456d596d3c5..4100765f2355 100644
--- a/lib/gso/gso_common.h
+++ b/lib/gso/gso_common.h
@@ -52,8 +52,8 @@ update_udp_header(struct rte_mbuf *pkt, uint16_t udp_offset)
 {
struct rte_udp_hdr *udp_hdr;
 
-   udp_hdr = (struct rte_udp_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-   udp_offset);
+   udp_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_udp_hdr *,
+ udp_offset);
udp_hdr->dgram_len = rte_cpu_to_be_16(pkt->pkt_len - udp_offset);
 }
 
@@ -77,8 +77,8 @@ update_tcp_header(struct rte_mbuf *pkt, uint16_t l4_offset, 
uint32_t sent_seq,
 {
struct rte_tcp_hdr *tcp_hdr;
 
-   tcp_hdr = (struct rte_tcp_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-   l4_offset);
+   tcp_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_tcp_hdr *,
+ l4_offset);
tcp_hdr->sent_seq = rte_cpu_to_be_32(sent_seq);
if (likely(non_tail))
tcp_hdr->tcp_flags &= (~(TCP_HDR_PSH_MASK |
@@ -104,8 +104,8 @@ update_ipv4_header(struct rte_mbuf *pkt, uint16_t 
l3_offset, uint16_t id)
 {
struct rte_ipv4_hdr *ipv4_hdr;
 
-   ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-   l3_offset);
+   ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+  l3_offset);
ipv4_hdr->total_length = rte_cpu_to_be_16(pkt->pkt_len - l3_offset);
ipv4_hdr->packet_id = rte_cpu_to_be_16(id);
 }
diff --git a/lib/gso/gso_tcp4.c b/lib/gso/gso_tcp4.c
index d31feaff95cd..e2ae4aaf6c5a 100644
--- a/lib/gso/gso_tcp4.c
+++ b/lib/gso/gso_tcp4.c
@@ -16,8 +16,8 @@ update_ipv4_tcp_headers(struct rte_mbuf *pkt, uint8_t 
ipid_delta,
uint16_t l3_offset = pkt->l2_len;
uint16_t l4_offset = l3_offset + pkt->l3_len;
 
-   ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char*) +
-   l3_offset);
+   ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+  l3_offset);
tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr + pkt->l3_len);
id = rte_be_to_cpu_16(ipv4_hdr->packet_id);
sent_seq = rte_be_to_cpu_32(tcp_hdr->sent_seq);
@@ -46,8 +46,8 @@ gso_tcp4_segment(struct rte_mbuf *pkt,
int ret;
 
/* Don't process the fragmented packet */
-   ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-   pkt->l2_len);
+   ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+  pkt->l2_len);
frag_off = rte_be_to_cpu_16(ipv4_hdr->fragment_offset);
if (unlikely(IS_FRAGMENTED(frag_off))) {
return 0;
diff --git a/lib/gso/gso_tunnel_tcp4.c b/lib/gso/gso_tunnel_tcp4.c
index 1a7ef30ddebf..3a9159774b27 100644
--- a/lib/gso/gso_tunnel_tcp4.c
+++ b/lib/gso/gso_tunnel_tcp4.c
@@ -23,13 +23,13 @@ update_tunnel_ipv4_tcp_headers(struct rte_mbuf *pkt, 
uint8_t ipid_delta,
tcp_offset = inner_ipv4_offset + pkt->l3_len;
 
/* Outer IPv4 header. */
-   ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-   outer_ipv4_offset);
+   ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+  outer_ipv4_offset);
outer_id = rte_be_to_cpu_16(ipv4_hdr->packet_id);
 
/* Inner IPv4 header. */
-   ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-   inner_ipv4_offset);
+   ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+  inner_ipv4_offset);
inner_id = rte_be_to_cpu_16(ipv4_hdr->packet_id);
 
tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr + pkt->l3_len);
@@ -65,8 +65,8 @@ gso_tunnel_tcp4_segment(struct rte_mbuf *pkt,
int ret;
 
hdr_offset = pkt->outer_l2_len + pkt->outer_l3_len + pkt->l2_len;
-   inner_ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-   hdr_offset);
+   inner_ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+hdr_offset);
/*
 * Don't process the packet whose MF bit or offset in the inner
 * IPv4 header are non-zero.
diff --git a/lib/gso/gso_tunnel_udp4.c b/lib/gso/gso_tunnel_udp4.c
index 1fc7a8dbc5aa..4fb275484ca8 100644
--- a/lib/gso/gso_tunnel_udp4.c
+++ b/lib/gso/gso_tunnel_udp

[PATCH v4 03/11] test: use rte_pktmbuf_mtod_offset

2023-07-07 Thread Stephen Hemminger
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

Signed-off-by: Stephen Hemminger 
---
 app/test/test_cryptodev.c | 66 +--
 1 file changed, 36 insertions(+), 30 deletions(-)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index fb2af40b99ee..c79681255106 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -3153,8 +3153,9 @@ test_snow3g_authentication(const struct 
snow3g_hash_test_data *tdata)
ut_params->op);
ut_params->obuf = ut_params->op->sym->m_src;
TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
-   ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-   + plaintext_pad_len;
+   ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+   uint8_t *,
+   plaintext_pad_len);
 
/* Validate obuf */
TEST_ASSERT_BUFFERS_ARE_EQUAL(
@@ -3247,8 +3248,9 @@ test_snow3g_authentication_verify(const struct 
snow3g_hash_test_data *tdata)
ut_params->op);
TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
ut_params->obuf = ut_params->op->sym->m_src;
-   ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-   + plaintext_pad_len;
+   ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+   uint8_t *,
+   plaintext_pad_len);
 
/* Validate obuf */
if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
@@ -3337,8 +3339,9 @@ test_kasumi_authentication(const struct 
kasumi_hash_test_data *tdata)
 
ut_params->obuf = ut_params->op->sym->m_src;
TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
-   ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-   + plaintext_pad_len;
+   ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+   uint8_t *,
+   plaintext_pad_len);
 
/* Validate obuf */
TEST_ASSERT_BUFFERS_ARE_EQUAL(
@@ -3425,8 +3428,9 @@ test_kasumi_authentication_verify(const struct 
kasumi_hash_test_data *tdata)
ut_params->op);
TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
ut_params->obuf = ut_params->op->sym->m_src;
-   ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-   + plaintext_pad_len;
+   ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+   uint8_t *,
+   plaintext_pad_len);
 
/* Validate obuf */
if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
@@ -4879,8 +4883,9 @@ test_zuc_cipher_auth(const struct wireless_test_data 
*tdata)
tdata->validDataLenInBits.len,
"ZUC Ciphertext data not as expected");
 
-   ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-   + plaintext_pad_len;
+   ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+   uint8_t *,
+   plaintext_pad_len);
 
/* Validate obuf */
TEST_ASSERT_BUFFERS_ARE_EQUAL(
@@ -4994,8 +4999,9 @@ test_snow3g_cipher_auth(const struct snow3g_test_data 
*tdata)
tdata->validDataLenInBits.len,
"SNOW 3G Ciphertext data not as expected");
 
-   ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-   + plaintext_pad_len;
+   ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+   uint8_t *,
+   plaintext_pad_len);
 
/* Validate obuf */
TEST_ASSERT_BUFFERS_ARE_EQUAL(
@@ -5163,9 +5169,9 @@ test_snow3g_auth_cipher(const struct snow3g_test_data 
*tdata,
debug_hexdump(stdout, "ciphertext expected:",
tdata->ciphertext.data, tdata->ciphertext.len >> 3);
 
-   ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-   + (tdata->digest.offset_bytes == 0 ?
-   plaintext_pad_len : tdata->digest.offset_bytes);
+   ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+   uint8_t *,
+   
(tdata->digest.offset_bytes == 0 ? plaintext_pad_len : 
tdata->digest.offset_bytes));
 
de

[PATCH v4 04/11] drivers/crypto: use rte_pktmbuf_mtod_offset

2023-07-07 Thread Stephen Hemminger
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

Signed-off-by: Stephen Hemminger 
---
 drivers/crypto/caam_jr/caam_jr.c |  8 
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c |  2 +-
 drivers/crypto/cnxk/cnxk_se.h|  5 ++---
 drivers/crypto/ipsec_mb/pmd_kasumi.c | 19 +++
 drivers/crypto/ipsec_mb/pmd_snow3g.c |  4 ++--
 drivers/crypto/ipsec_mb/pmd_zuc.c| 18 ++
 drivers/crypto/qat/dev/qat_crypto_pmd_gens.h |  9 +
 drivers/crypto/qat/qat_sym.h |  9 +
 8 files changed, 40 insertions(+), 34 deletions(-)

diff --git a/drivers/crypto/caam_jr/caam_jr.c b/drivers/crypto/caam_jr/caam_jr.c
index b55258689b49..9c96fd21a48d 100644
--- a/drivers/crypto/caam_jr/caam_jr.c
+++ b/drivers/crypto/caam_jr/caam_jr.c
@@ -631,15 +631,15 @@ hw_poll_job_ring(struct sec_job_ring_t *job_ring,
 
if (ctx->op->sym->m_dst) {
/*TODO check for ip header or other*/
-   ip4_hdr = (struct ip *)
-   rte_pktmbuf_mtod(ctx->op->sym->m_dst, char*);
+   ip4_hdr = rte_pktmbuf_mtod(ctx->op->sym->m_dst,
+  struct ip *);
ctx->op->sym->m_dst->pkt_len =
rte_be_to_cpu_16(ip4_hdr->ip_len);
ctx->op->sym->m_dst->data_len =
rte_be_to_cpu_16(ip4_hdr->ip_len);
} else {
-   ip4_hdr = (struct ip *)
-   rte_pktmbuf_mtod(ctx->op->sym->m_src, char*);
+   ip4_hdr = rte_pktmbuf_mtod(ctx->op->sym->m_src,
+  struct ip *);
ctx->op->sym->m_src->pkt_len =
rte_be_to_cpu_16(ip4_hdr->ip_len);
ctx->op->sym->m_src->data_len =
diff --git a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c 
b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
index 34d40b07d4c6..8b91d11b79cc 100644
--- a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
+++ b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
@@ -520,7 +520,7 @@ cn9k_cpt_sec_post_process(struct rte_crypto_op *cop,
 
if (infl_req->op_flags & CPT_OP_FLAGS_IPSEC_DIR_INBOUND) {
 
-   hdr = (struct roc_ie_on_inb_hdr *)rte_pktmbuf_mtod(m, char *);
+   hdr = rte_pktmbuf_mtod(m, struct roc_ie_on_inb_hdr *);
 
if (likely(m->next == NULL)) {
ip = PLT_PTR_ADD(hdr, ROC_IE_ON_INB_RPTR_HDR);
diff --git a/drivers/crypto/cnxk/cnxk_se.h b/drivers/crypto/cnxk/cnxk_se.h
index 75c1dce231bf..1392af5833d1 100644
--- a/drivers/crypto/cnxk/cnxk_se.h
+++ b/drivers/crypto/cnxk/cnxk_se.h
@@ -2724,7 +2724,7 @@ fill_fc_params(struct rte_crypto_op *cop, struct 
cnxk_se_sess *sess,
m = cpt_m_dst_get(cpt_op, m_src, m_dst);
 
/* Digest immediately following data is best case */
-   if (unlikely(rte_pktmbuf_mtod(m, uint8_t *) + mc_hash_off !=
+   if (unlikely(rte_pktmbuf_mtod_offset(m, uint8_t *, mc_hash_off) 
!=
 (uint8_t *)sym_op->aead.digest.data)) {
flags |= ROC_SE_VALID_MAC_BUF;
fc_params.mac_buf.size = sess->mac_len;
@@ -2759,8 +2759,7 @@ fill_fc_params(struct rte_crypto_op *cop, struct 
cnxk_se_sess *sess,
 
/* hmac immediately following data is best case */
if (!(op_minor & ROC_SE_FC_MINOR_OP_HMAC_FIRST) &&
-   (unlikely(rte_pktmbuf_mtod(m, uint8_t *) +
- mc_hash_off !=
+   (unlikely(rte_pktmbuf_mtod_offset(m, uint8_t *, 
mc_hash_off) !=
  (uint8_t *)sym_op->auth.digest.data))) {
flags |= ROC_SE_VALID_MAC_BUF;
fc_params.mac_buf.size = sess->mac_len;
diff --git a/drivers/crypto/ipsec_mb/pmd_kasumi.c 
b/drivers/crypto/ipsec_mb/pmd_kasumi.c
index 5db9c523cd9a..70536ec3dc2a 100644
--- a/drivers/crypto/ipsec_mb/pmd_kasumi.c
+++ b/drivers/crypto/ipsec_mb/pmd_kasumi.c
@@ -83,13 +83,16 @@ process_kasumi_cipher_op(struct ipsec_mb_qp *qp, struct 
rte_crypto_op **ops,
uint32_t num_bytes[num_ops];
 
for (i = 0; i < num_ops; i++) {
-   src[i] = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *)
-+ (ops[i]->sym->cipher.data.offset >> 3);
+   src[i] = rte_pktmbuf_mtod_offset(ops[i]->sym->m_src,
+uint8_t *,
+
(ops[i]->sym->cipher.data.offset >> 3));
dst[i] 

[PATCH v4 05/11] net/nfp: use rte_pktmbuf_mtod_offset

2023-07-07 Thread Stephen Hemminger
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

Signed-off-by: Stephen Hemminger 
---
 drivers/net/nfp/flower/nfp_flower_cmsg.h | 3 ++-
 drivers/net/nfp/flower/nfp_flower_ctrl.c | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h 
b/drivers/net/nfp/flower/nfp_flower_cmsg.h
index f643d54d39a4..787a38dc9aa0 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.h
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h
@@ -381,7 +381,8 @@ enum nfp_flower_cmsg_port_vnic_type {
 static inline char*
 nfp_flower_cmsg_get_data(struct rte_mbuf *m)
 {
-   return rte_pktmbuf_mtod(m, char *) + 4 + 4 + NFP_FLOWER_CMSG_HLEN;
+   return rte_pktmbuf_mtod_offset(m, char *,
+  4 + 4 + NFP_FLOWER_CMSG_HLEN);
 }
 
 /*
diff --git a/drivers/net/nfp/flower/nfp_flower_ctrl.c 
b/drivers/net/nfp/flower/nfp_flower_ctrl.c
index 4cb2c2f99e04..18823a97887d 100644
--- a/drivers/net/nfp/flower/nfp_flower_ctrl.c
+++ b/drivers/net/nfp/flower/nfp_flower_ctrl.c
@@ -389,7 +389,7 @@ nfp_flower_cmsg_rx_stats(struct nfp_flow_priv *flow_priv,
uint32_t ctx_id;
struct nfp_flower_stats_frame *stats;
 
-   msg = rte_pktmbuf_mtod(mbuf, char *) + NFP_FLOWER_CMSG_HLEN;
+   msg = rte_pktmbuf_mtod_offset(mbuf, char *, NFP_FLOWER_CMSG_HLEN);
msg_len = mbuf->data_len - NFP_FLOWER_CMSG_HLEN;
count = msg_len / sizeof(struct nfp_flower_stats_frame);
 
@@ -412,7 +412,7 @@ nfp_flower_cmsg_rx_qos_stats(struct nfp_mtr_priv *mtr_priv,
struct nfp_mtr *mtr;
struct nfp_mtr_stats_reply *mtr_stats;
 
-   msg = rte_pktmbuf_mtod(mbuf, char *) + NFP_FLOWER_CMSG_HLEN;
+   msg = rte_pktmbuf_mtod_offset(mbuf, char *, NFP_FLOWER_CMSG_HLEN);
 
mtr_stats = (struct nfp_mtr_stats_reply *)msg;
profile_id = rte_be_to_cpu_32(mtr_stats->head.profile_id);
-- 
2.39.2



[PATCH v4 06/11] net/tap: use rte_pktmbuf_motd_offset

2023-07-07 Thread Stephen Hemminger
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

Signed-off-by: Stephen Hemminger 
---
 drivers/net/tap/rte_eth_tap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index bf98f7555990..968a1b6b45df 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -672,8 +672,8 @@ tap_write_mbufs(struct tx_queue *txq, uint16_t num_mbufs,
if (seg_len > l234_hlen) {
iovecs[k].iov_len = seg_len - l234_hlen;
iovecs[k].iov_base =
-   rte_pktmbuf_mtod(seg, char *) +
-   l234_hlen;
+   rte_pktmbuf_mtod_offset(seg, char *,
+   l234_hlen);
tap_tx_l4_add_rcksum(iovecs[k].iov_base,
iovecs[k].iov_len, l4_cksum,
&l4_raw_cksum);
-- 
2.39.2



[PATCH v4 07/11] baseband/fpga: use rte_pktmbuf_offset

2023-07-07 Thread Stephen Hemminger
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

Signed-off-by: Stephen Hemminger 
---
 drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c 
b/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
index f29565af8cca..465a65f3dca2 100644
--- a/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
+++ b/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
@@ -1543,8 +1543,7 @@ fpga_harq_write_loopback(struct fpga_queue *q,
rte_bbdev_log(ERR, "HARQ in length > HARQ buffer size\n");
}
 
-   input = (uint64_t *)rte_pktmbuf_mtod_offset(harq_input,
-   uint8_t *, in_offset);
+   input = rte_pktmbuf_mtod_offset(harq_input, uint64_t *, in_offset);
 
while (left_length > 0) {
if (fpga_reg_read_8(q->d->mmio_base,
@@ -1621,8 +1620,8 @@ fpga_harq_read_loopback(struct fpga_queue *q,
}
left_length = harq_in_length;
 
-   input = (uint64_t *)rte_pktmbuf_mtod_offset(harq_output,
-   uint8_t *, harq_out_offset);
+   input = rte_pktmbuf_mtod_offset(harq_output, uint64_t *,
+   harq_out_offset);
 
while (left_length > 0) {
fpga_reg_write_32(q->d->mmio_base,
-- 
2.39.2



[PATCH v4 08/11] cpt: use rte_pktmbuf_mtod_offset

2023-07-07 Thread Stephen Hemminger
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

Signed-off-by: Stephen Hemminger 
---
 drivers/common/cpt/cpt_ucode.h | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/common/cpt/cpt_ucode.h b/drivers/common/cpt/cpt_ucode.h
index b393be4cf661..87a3ac80b9da 100644
--- a/drivers/common/cpt/cpt_ucode.h
+++ b/drivers/common/cpt/cpt_ucode.h
@@ -3167,9 +3167,8 @@ fill_fc_params(struct rte_crypto_op *cop,
m = m_src;
 
/* hmac immediately following data is best case */
-   if (unlikely(rte_pktmbuf_mtod(m, uint8_t *) +
-   mc_hash_off !=
-   (uint8_t *)sym_op->aead.digest.data)) {
+   if (unlikely(rte_pktmbuf_mtod_offset(m, uint8_t *, 
mc_hash_off) !=
+(uint8_t *)sym_op->aead.digest.data)) {
flags |= VALID_MAC_BUF;
fc_params.mac_buf.size = sess_misc->mac_len;
fc_params.mac_buf.vaddr =
@@ -3211,9 +3210,8 @@ fill_fc_params(struct rte_crypto_op *cop,
 
/* hmac immediately following data is best case */
if (!ctx->dec_auth && !ctx->auth_enc &&
-(unlikely(rte_pktmbuf_mtod(m, uint8_t *) +
-   mc_hash_off !=
-(uint8_t *)sym_op->auth.digest.data))) {
+(unlikely(rte_pktmbuf_mtod_offset(m, uint8_t 
*, mc_hash_off) !=
+  (uint8_t 
*)sym_op->auth.digest.data))) {
flags |= VALID_MAC_BUF;
fc_params.mac_buf.size =
sess_misc->mac_len;
-- 
2.39.2



[PATCH v4 09/11] testpmd: use rte_pktmbuf_mtod_offset

2023-07-07 Thread Stephen Hemminger
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

Signed-off-by: Stephen Hemminger 
---
 app/test-pmd/ieee1588fwd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/app/test-pmd/ieee1588fwd.c b/app/test-pmd/ieee1588fwd.c
index 386d9f10e642..3371771751dd 100644
--- a/app/test-pmd/ieee1588fwd.c
+++ b/app/test-pmd/ieee1588fwd.c
@@ -138,8 +138,8 @@ ieee1588_packet_fwd(struct fwd_stream *fs)
 * Check that the received PTP packet is a PTP V2 packet of type
 * PTP_SYNC_MESSAGE.
 */
-   ptp_hdr = (struct ptpv2_msg *) (rte_pktmbuf_mtod(mb, char *) +
-   sizeof(struct rte_ether_hdr));
+   ptp_hdr = rte_pktmbuf_mtod_offset(mb, struct ptpv2_msg *,
+ sizeof(struct rte_ether_hdr));
if (ptp_hdr->version != 0x02) {
printf("Port %u Received PTP V2 Ethernet frame with wrong PTP"
   " protocol version 0x%x (should be 0x02)\n",
-- 
2.39.2



[PATCH v4 10/11] examples/ptpclient: use rte_pktmbuf_mtod_offset

2023-07-07 Thread Stephen Hemminger
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

Signed-off-by: Stephen Hemminger 
---
 examples/ptpclient/ptpclient.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/examples/ptpclient/ptpclient.c b/examples/ptpclient/ptpclient.c
index cdf2da64dfee..2535d848a1e9 100644
--- a/examples/ptpclient/ptpclient.c
+++ b/examples/ptpclient/ptpclient.c
@@ -354,8 +354,8 @@ parse_sync(struct ptpv2_data_slave_ordinary *ptp_data, 
uint16_t rx_tstamp_idx)
 {
struct ptp_header *ptp_hdr;
 
-   ptp_hdr = (struct ptp_header *)(rte_pktmbuf_mtod(ptp_data->m, char *)
-   + sizeof(struct rte_ether_hdr));
+   ptp_hdr = rte_pktmbuf_mtod_offset(ptp_data->m, struct ptp_header *,
+ sizeof(struct rte_ether_hdr));
ptp_data->seqID_SYNC = rte_be_to_cpu_16(ptp_hdr->seq_id);
 
if (ptp_data->ptpset == 0) {
@@ -397,15 +397,15 @@ parse_fup(struct ptpv2_data_slave_ordinary *ptp_data)
int ret;
 
eth_hdr = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
-   ptp_hdr = (struct ptp_header *)(rte_pktmbuf_mtod(m, char *)
-   + sizeof(struct rte_ether_hdr));
+   ptp_hdr = rte_pktmbuf_mtod_offset(m, struct ptp_header *,
+ sizeof(struct rte_ether_hdr));
if (memcmp(&ptp_data->master_clock_id,
&ptp_hdr->source_port_id.clock_id,
sizeof(struct clock_id)) != 0)
return;
 
ptp_data->seqID_FOLLOWUP = rte_be_to_cpu_16(ptp_hdr->seq_id);
-   ptp_msg = (struct ptp_message *) (rte_pktmbuf_mtod(m, char *) +
+   ptp_msg = rte_pktmbuf_mtod_offset(m, struct ptp_message *,
  sizeof(struct rte_ether_hdr));
 
origin_tstamp = &ptp_msg->follow_up.precise_origin_tstamp;
@@ -537,8 +537,8 @@ parse_drsp(struct ptpv2_data_slave_ordinary *ptp_data)
struct tstamp *rx_tstamp;
uint16_t seq_id;
 
-   ptp_msg = (struct ptp_message *) (rte_pktmbuf_mtod(m, char *) +
-   sizeof(struct rte_ether_hdr));
+   ptp_msg = rte_pktmbuf_mtod_offset(m, struct ptp_message *,
+ sizeof(struct rte_ether_hdr));
seq_id = rte_be_to_cpu_16(ptp_msg->delay_resp.hdr.seq_id);
if (memcmp(&ptp_data->client_clock_id,
   &ptp_msg->delay_resp.req_port_id.clock_id,
@@ -585,8 +585,8 @@ parse_ptp_frames(uint16_t portid, struct rte_mbuf *m) {
if (eth_type == PTP_PROTOCOL) {
ptp_data.m = m;
ptp_data.portid = portid;
-   ptp_hdr = (struct ptp_header *)(rte_pktmbuf_mtod(m, char *)
-   + sizeof(struct rte_ether_hdr));
+   ptp_hdr = rte_pktmbuf_mtod_offset(m, struct ptp_header *,
+ sizeof(struct rte_ether_hdr));
 
switch (ptp_hdr->msg_type) {
case SYNC:
-- 
2.39.2



[PATCH v4 11/11] examples/l2fwd-crypto: use rte_pktmbuf_mtod_offset

2023-07-07 Thread Stephen Hemminger
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

Signed-off-by: Stephen Hemminger 
---
 examples/l2fwd-crypto/main.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index efe7eea2a768..981b449710a7 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -410,8 +410,8 @@ l2fwd_simple_crypto_enqueue(struct rte_mbuf *m,
 
ipdata_offset = sizeof(struct rte_ether_hdr);
 
-   ip_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(m, char *) +
-   ipdata_offset);
+   ip_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *,
+ipdata_offset);
 
ipdata_offset += (ip_hdr->version_ihl & RTE_IPV4_HDR_IHL_MASK)
* RTE_IPV4_IHL_MULTIPLIER;
@@ -479,8 +479,9 @@ l2fwd_simple_crypto_enqueue(struct rte_mbuf *m,
op->sym->auth.digest.data = (uint8_t 
*)rte_pktmbuf_append(m,
cparams->digest_length);
} else {
-   op->sym->auth.digest.data = rte_pktmbuf_mtod(m,
-   uint8_t *) + ipdata_offset + data_len;
+   op->sym->auth.digest.data = rte_pktmbuf_mtod_offset(m,
+   
uint8_t *,
+   
ipdata_offset + data_len);
}
 
op->sym->auth.digest.phys_addr = rte_pktmbuf_iova_offset(m,
@@ -540,8 +541,9 @@ l2fwd_simple_crypto_enqueue(struct rte_mbuf *m,
op->sym->aead.digest.data = (uint8_t 
*)rte_pktmbuf_append(m,
cparams->digest_length);
} else {
-   op->sym->aead.digest.data = rte_pktmbuf_mtod(m,
-   uint8_t *) + ipdata_offset + data_len;
+   op->sym->aead.digest.data = rte_pktmbuf_mtod_offset(m,
+   
uint8_t *,
+   
ipdata_offset + data_len);
}
 
op->sym->aead.digest.phys_addr = rte_pktmbuf_iova_offset(m,
@@ -631,7 +633,7 @@ l2fwd_simple_forward(struct rte_mbuf *m, uint16_t portid,
struct rte_ipv4_hdr *ip_hdr;
uint32_t ipdata_offset = sizeof(struct rte_ether_hdr);
 
-   ip_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(m, char *) +
+   ip_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *,
 ipdata_offset);
dst_port = l2fwd_dst_ports[portid];
 
-- 
2.39.2



RE: [PATCH] net/netvsc: set the correct queue state

2023-07-07 Thread Long Li
> Subject: Re: [PATCH] net/netvsc: set the correct queue state
> 
> On Fri,  7 Jul 2023 11:53:16 -0700
> lon...@linuxonhyperv.com wrote:
> 
> > From: Long Li 
> >
> > Set the queue state when queue is started/stopped.
> >
> > Signed-off-by: Long Li 
> > ---
> >  drivers/net/netvsc/hn_ethdev.c | 15 ++-
> >  1 file changed, 14 insertions(+), 1 deletion(-)
> 
> Interesting that not all drivers do this.
> 
> Acked-by: Stephen Hemminger 
> 
> The ones not doing it.
> af_packet
> af_xdp
> avp
> axgbe
> bnx2x
> bonding
> dpaa
> dpaa2
> e1000
> ena
> enetfec
> gve
> hinic
> igc
> ipn3ke
> kni
> liquidio
> mana
> memif
> mlx4
> netvsc
> nfp
> null
> octeon_ep
> pfe
> ring
> softnic
> vdev_netvsc
> vhost
> virtio
> vmxnet3

Testpmd added the check for stopped queues:
3c4426db54 app/testpmd: do not poll stopped queues

To pass testpmd, PMD needs to set queue state.


Re: [PATCH] net/netvsc: set the correct queue state

2023-07-07 Thread Stephen Hemminger
On Fri, 7 Jul 2023 20:43:51 +
Long Li  wrote:

> > Subject: Re: [PATCH] net/netvsc: set the correct queue state
> > 
> > On Fri,  7 Jul 2023 11:53:16 -0700
> > lon...@linuxonhyperv.com wrote:
> >   
> > > From: Long Li 
> > >
> > > Set the queue state when queue is started/stopped.
> > >
> > > Signed-off-by: Long Li 
> > > ---
> > >  drivers/net/netvsc/hn_ethdev.c | 15 ++-
> > >  1 file changed, 14 insertions(+), 1 deletion(-)  
> > 
> > Interesting that not all drivers do this.
> > 
> > Acked-by: Stephen Hemminger 
> > 
> > The ones not doing it.
> > af_packet
> > af_xdp
> > avp
> > axgbe
> > bnx2x
> > bonding
> > dpaa
> > dpaa2
> > e1000
> > ena
> > enetfec
> > gve
> > hinic
> > igc
> > ipn3ke
> > kni
> > liquidio
> > mana
> > memif
> > mlx4
> > netvsc
> > nfp
> > null
> > octeon_ep
> > pfe
> > ring
> > softnic
> > vdev_netvsc
> > vhost
> > virtio
> > vmxnet3  
> 
> Testpmd added the check for stopped queues:
> 3c4426db54 app/testpmd: do not poll stopped queues
> 
> To pass testpmd, PMD needs to set queue state.

So there are 20 drivers broken by that change!
Sounds like it needs to be reverted.


Re: [PATCH v3 1/2] app/testpmd: do not poll stopped queues

2023-07-07 Thread Stephen Hemminger
On Wed, 9 Mar 2022 10:36:15 +
Dmitry Kozlyuk  wrote:

> > Calling Rx/Tx functions on a stopped queue is not supported.
> > Do not run packet forwarding for streams that use stopped queues.
> > 
> > Each stream has a read-only "disabled" field,
> > so that lcore function can skip such streams.
> > Forwarding engines can set this field
> > using a new "stream_init" callback function
> > by checking relevant queue states,
> > which are stored along with queue configurations
> > (not all PMDs implement rte_eth_rx/tx_queue_info_get()
> > to query the state from there).
> > 
> > Fixes: 5f4ec54f1d16 ("testpmd: queue start and stop")
> > Cc: sta...@dpdk.org
> > 
> > Signed-off-by: Dmitry Kozlyuk 
> > Acked-by: Matan Azrad 
> > ---  
> 
> Pinging testpmd maintainers for this bugfix.
> The sibling ethdev patch will have to wait until the next release cycle.

So you broke a bunch of drivers now that is merged???
Sound like it needs to be reverted. Certainly not something that should
go into stable tree if you expect all drivers to correctly set queue state.


[PATCH v5 00/11] use rte_pktmbuf_mto_offset

2023-07-07 Thread Stephen Hemminger
v5 - fix checkpatch warnings about long lines
 split up complex expression in test/crypto_dev

Stephen Hemminger (11):
  gro: use rte_pktmbuf_mtod_offset
  gso: use rte_pktmbuf_mtod_offset
  test/crypto_dev: use rte_pktmbuf_mtod_offset
  drivers/crypto: use rte_pktmbuf_mtod_offset
  net/nfp: use rte_pktmbuf_mtod_offset
  net/tap: use rte_pktmbuf_motd_offset
  baseband/fpga: use rte_pktmbuf_offset
  cpt: use rte_pktmbuf_mtod_offset
  testpmd: use rte_pktmbuf_mtod_offset
  examples/ptpclient: use rte_pktmbuf_mtod_offset
  examples/l2fwd-crypto: use rte_pktmbuf_mtod_offset

 app/test-pmd/ieee1588fwd.c|  4 +-
 app/test/test_cryptodev.c | 83 ---
 .../fpga_5gnr_fec/rte_fpga_5gnr_fec.c |  7 +-
 drivers/common/cpt/cpt_ucode.h| 10 +--
 drivers/crypto/caam_jr/caam_jr.c  |  8 +-
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c  |  2 +-
 drivers/crypto/cnxk/cnxk_se.h |  5 +-
 drivers/crypto/ipsec_mb/pmd_kasumi.c  | 19 +++--
 drivers/crypto/ipsec_mb/pmd_snow3g.c  |  4 +-
 drivers/crypto/ipsec_mb/pmd_zuc.c | 18 ++--
 drivers/crypto/qat/dev/qat_crypto_pmd_gens.h  |  9 +-
 drivers/crypto/qat/qat_sym.h  |  9 +-
 drivers/net/nfp/flower/nfp_flower_cmsg.h  |  3 +-
 drivers/net/nfp/flower/nfp_flower_ctrl.c  |  4 +-
 drivers/net/tap/rte_eth_tap.c |  4 +-
 examples/l2fwd-crypto/main.c  | 14 ++--
 examples/ptpclient/ptpclient.c| 18 ++--
 lib/gro/gro_tcp.h |  4 +-
 lib/gro/gro_tcp4.c|  4 +-
 lib/gro/gro_tcp6.c|  4 +-
 lib/gro/gro_udp4.c|  4 +-
 lib/gro/gro_vxlan_tcp4.c  |  4 +-
 lib/gro/gro_vxlan_udp4.c  |  4 +-
 lib/gso/gso_common.h  | 12 +--
 lib/gso/gso_tcp4.c|  8 +-
 lib/gso/gso_tunnel_tcp4.c | 12 +--
 lib/gso/gso_tunnel_udp4.c | 18 ++--
 27 files changed, 161 insertions(+), 134 deletions(-)

-- 
2.39.2



[PATCH v5 01/11] gro: use rte_pktmbuf_mtod_offset

2023-07-07 Thread Stephen Hemminger
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

Signed-off-by: Stephen Hemminger 
---
 lib/gro/gro_tcp.h| 4 ++--
 lib/gro/gro_tcp4.c   | 4 ++--
 lib/gro/gro_tcp6.c   | 4 ++--
 lib/gro/gro_udp4.c   | 4 ++--
 lib/gro/gro_vxlan_tcp4.c | 4 ++--
 lib/gro/gro_vxlan_udp4.c | 4 ++--
 6 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/lib/gro/gro_tcp.h b/lib/gro/gro_tcp.h
index d926c4b8cc71..bbd2f9c16a00 100644
--- a/lib/gro/gro_tcp.h
+++ b/lib/gro/gro_tcp.h
@@ -150,8 +150,8 @@ check_seq_option(struct gro_tcp_item *item,
struct rte_tcp_hdr *tcph_orig;
uint16_t len, tcp_hl_orig;
 
-   iph_orig = (char *)(rte_pktmbuf_mtod(pkt_orig, char *) +
-   l2_offset + pkt_orig->l2_len);
+   iph_orig = rte_pktmbuf_mtod_offset(pkt_orig, char *,
+  l2_offset + pkt_orig->l2_len);
tcph_orig = (struct rte_tcp_hdr *)(iph_orig + pkt_orig->l3_len);
tcp_hl_orig = pkt_orig->l4_len;
 
diff --git a/lib/gro/gro_tcp4.c b/lib/gro/gro_tcp4.c
index 6645de592b63..d6c0f9182d45 100644
--- a/lib/gro/gro_tcp4.c
+++ b/lib/gro/gro_tcp4.c
@@ -223,8 +223,8 @@ update_header(struct gro_tcp_item *item)
struct rte_ipv4_hdr *ipv4_hdr;
struct rte_mbuf *pkt = item->firstseg;
 
-   ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-   pkt->l2_len);
+   ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+  pkt->l2_len);
ipv4_hdr->total_length = rte_cpu_to_be_16(pkt->pkt_len -
pkt->l2_len);
 }
diff --git a/lib/gro/gro_tcp6.c b/lib/gro/gro_tcp6.c
index 5aa39801e132..6edfb6045cf6 100644
--- a/lib/gro/gro_tcp6.c
+++ b/lib/gro/gro_tcp6.c
@@ -118,8 +118,8 @@ update_header(struct gro_tcp_item *item)
struct rte_ipv6_hdr *ipv6_hdr;
struct rte_mbuf *pkt = item->firstseg;
 
-   ipv6_hdr = (struct rte_ipv6_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-   pkt->l2_len);
+   ipv6_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv6_hdr *,
+  pkt->l2_len);
ipv6_hdr->payload_len = rte_cpu_to_be_16(pkt->pkt_len -
pkt->l2_len - pkt->l3_len);
 }
diff --git a/lib/gro/gro_udp4.c b/lib/gro/gro_udp4.c
index 42596d33b6dc..019e05bcdea5 100644
--- a/lib/gro/gro_udp4.c
+++ b/lib/gro/gro_udp4.c
@@ -179,8 +179,8 @@ update_header(struct gro_udp4_item *item)
struct rte_mbuf *pkt = item->firstseg;
uint16_t frag_offset;
 
-   ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-   pkt->l2_len);
+   ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+  pkt->l2_len);
ipv4_hdr->total_length = rte_cpu_to_be_16(pkt->pkt_len -
pkt->l2_len);
 
diff --git a/lib/gro/gro_vxlan_tcp4.c b/lib/gro/gro_vxlan_tcp4.c
index 6ab700192261..2752650389a4 100644
--- a/lib/gro/gro_vxlan_tcp4.c
+++ b/lib/gro/gro_vxlan_tcp4.c
@@ -263,8 +263,8 @@ update_vxlan_header(struct gro_vxlan_tcp4_item *item)
 
/* Update the outer IPv4 header. */
len = pkt->pkt_len - pkt->outer_l2_len;
-   ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-   pkt->outer_l2_len);
+   ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+  pkt->outer_l2_len);
ipv4_hdr->total_length = rte_cpu_to_be_16(len);
 
/* Update the outer UDP header. */
diff --git a/lib/gro/gro_vxlan_udp4.c b/lib/gro/gro_vxlan_udp4.c
index b78a7ae89eef..ca8cee270d3d 100644
--- a/lib/gro/gro_vxlan_udp4.c
+++ b/lib/gro/gro_vxlan_udp4.c
@@ -259,8 +259,8 @@ update_vxlan_header(struct gro_vxlan_udp4_item *item)
 
/* Update the outer IPv4 header. */
len = pkt->pkt_len - pkt->outer_l2_len;
-   ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-   pkt->outer_l2_len);
+   ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+  pkt->outer_l2_len);
ipv4_hdr->total_length = rte_cpu_to_be_16(len);
 
/* Update the outer UDP header. */
-- 
2.39.2



[PATCH v5 02/11] gso: use rte_pktmbuf_mtod_offset

2023-07-07 Thread Stephen Hemminger
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

Signed-off-by: Stephen Hemminger 
---
 lib/gso/gso_common.h  | 12 ++--
 lib/gso/gso_tcp4.c|  8 
 lib/gso/gso_tunnel_tcp4.c | 12 ++--
 lib/gso/gso_tunnel_udp4.c | 18 +-
 4 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/lib/gso/gso_common.h b/lib/gso/gso_common.h
index 9456d596d3c5..d1c1b73091e2 100644
--- a/lib/gso/gso_common.h
+++ b/lib/gso/gso_common.h
@@ -52,8 +52,8 @@ update_udp_header(struct rte_mbuf *pkt, uint16_t udp_offset)
 {
struct rte_udp_hdr *udp_hdr;
 
-   udp_hdr = (struct rte_udp_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-   udp_offset);
+   udp_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_udp_hdr *,
+ udp_offset);
udp_hdr->dgram_len = rte_cpu_to_be_16(pkt->pkt_len - udp_offset);
 }
 
@@ -77,8 +77,8 @@ update_tcp_header(struct rte_mbuf *pkt, uint16_t l4_offset, 
uint32_t sent_seq,
 {
struct rte_tcp_hdr *tcp_hdr;
 
-   tcp_hdr = (struct rte_tcp_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-   l4_offset);
+   tcp_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_tcp_hdr *,
+ l4_offset);
tcp_hdr->sent_seq = rte_cpu_to_be_32(sent_seq);
if (likely(non_tail))
tcp_hdr->tcp_flags &= (~(TCP_HDR_PSH_MASK |
@@ -104,8 +104,8 @@ update_ipv4_header(struct rte_mbuf *pkt, uint16_t 
l3_offset, uint16_t id)
 {
struct rte_ipv4_hdr *ipv4_hdr;
 
-   ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-   l3_offset);
+   ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+  l3_offset);
ipv4_hdr->total_length = rte_cpu_to_be_16(pkt->pkt_len - l3_offset);
ipv4_hdr->packet_id = rte_cpu_to_be_16(id);
 }
diff --git a/lib/gso/gso_tcp4.c b/lib/gso/gso_tcp4.c
index d31feaff95cd..e2ae4aaf6c5a 100644
--- a/lib/gso/gso_tcp4.c
+++ b/lib/gso/gso_tcp4.c
@@ -16,8 +16,8 @@ update_ipv4_tcp_headers(struct rte_mbuf *pkt, uint8_t 
ipid_delta,
uint16_t l3_offset = pkt->l2_len;
uint16_t l4_offset = l3_offset + pkt->l3_len;
 
-   ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char*) +
-   l3_offset);
+   ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+  l3_offset);
tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr + pkt->l3_len);
id = rte_be_to_cpu_16(ipv4_hdr->packet_id);
sent_seq = rte_be_to_cpu_32(tcp_hdr->sent_seq);
@@ -46,8 +46,8 @@ gso_tcp4_segment(struct rte_mbuf *pkt,
int ret;
 
/* Don't process the fragmented packet */
-   ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-   pkt->l2_len);
+   ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+  pkt->l2_len);
frag_off = rte_be_to_cpu_16(ipv4_hdr->fragment_offset);
if (unlikely(IS_FRAGMENTED(frag_off))) {
return 0;
diff --git a/lib/gso/gso_tunnel_tcp4.c b/lib/gso/gso_tunnel_tcp4.c
index 1a7ef30ddebf..3a9159774b27 100644
--- a/lib/gso/gso_tunnel_tcp4.c
+++ b/lib/gso/gso_tunnel_tcp4.c
@@ -23,13 +23,13 @@ update_tunnel_ipv4_tcp_headers(struct rte_mbuf *pkt, 
uint8_t ipid_delta,
tcp_offset = inner_ipv4_offset + pkt->l3_len;
 
/* Outer IPv4 header. */
-   ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-   outer_ipv4_offset);
+   ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+  outer_ipv4_offset);
outer_id = rte_be_to_cpu_16(ipv4_hdr->packet_id);
 
/* Inner IPv4 header. */
-   ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-   inner_ipv4_offset);
+   ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+  inner_ipv4_offset);
inner_id = rte_be_to_cpu_16(ipv4_hdr->packet_id);
 
tcp_hdr = (struct rte_tcp_hdr *)((char *)ipv4_hdr + pkt->l3_len);
@@ -65,8 +65,8 @@ gso_tunnel_tcp4_segment(struct rte_mbuf *pkt,
int ret;
 
hdr_offset = pkt->outer_l2_len + pkt->outer_l3_len + pkt->l2_len;
-   inner_ipv4_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(pkt, char *) +
-   hdr_offset);
+   inner_ipv4_hdr = rte_pktmbuf_mtod_offset(pkt, struct rte_ipv4_hdr *,
+hdr_offset);
/*
 * Don't process the packet whose MF bit or offset in the inner
 * IPv4 header are non-zero.
diff --git a/lib/gso/gso_tunnel_udp4.c b/lib/gso/gso_tunnel_udp4.c
index 1fc7a8dbc5aa..4fb275484ca8 100644
--- a/lib/gso/gso_tunnel_udp4.c
+++ b/lib/gso/gso_tunnel_udp

[PATCH v5 03/11] test/crypto_dev: use rte_pktmbuf_mtod_offset

2023-07-07 Thread Stephen Hemminger
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

Signed-off-by: Stephen Hemminger 
---
 app/test/test_cryptodev.c | 83 +--
 1 file changed, 53 insertions(+), 30 deletions(-)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index fb2af40b99ee..549afe252d54 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -3153,8 +3153,9 @@ test_snow3g_authentication(const struct 
snow3g_hash_test_data *tdata)
ut_params->op);
ut_params->obuf = ut_params->op->sym->m_src;
TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
-   ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-   + plaintext_pad_len;
+   ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+   uint8_t *,
+   plaintext_pad_len);
 
/* Validate obuf */
TEST_ASSERT_BUFFERS_ARE_EQUAL(
@@ -3247,8 +3248,9 @@ test_snow3g_authentication_verify(const struct 
snow3g_hash_test_data *tdata)
ut_params->op);
TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
ut_params->obuf = ut_params->op->sym->m_src;
-   ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-   + plaintext_pad_len;
+   ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+   uint8_t *,
+   plaintext_pad_len);
 
/* Validate obuf */
if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
@@ -3337,8 +3339,9 @@ test_kasumi_authentication(const struct 
kasumi_hash_test_data *tdata)
 
ut_params->obuf = ut_params->op->sym->m_src;
TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
-   ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-   + plaintext_pad_len;
+   ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+   uint8_t *,
+   plaintext_pad_len);
 
/* Validate obuf */
TEST_ASSERT_BUFFERS_ARE_EQUAL(
@@ -3425,8 +3428,9 @@ test_kasumi_authentication_verify(const struct 
kasumi_hash_test_data *tdata)
ut_params->op);
TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
ut_params->obuf = ut_params->op->sym->m_src;
-   ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-   + plaintext_pad_len;
+   ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+   uint8_t *,
+   plaintext_pad_len);
 
/* Validate obuf */
if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
@@ -4879,8 +4883,9 @@ test_zuc_cipher_auth(const struct wireless_test_data 
*tdata)
tdata->validDataLenInBits.len,
"ZUC Ciphertext data not as expected");
 
-   ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-   + plaintext_pad_len;
+   ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+   uint8_t *,
+   plaintext_pad_len);
 
/* Validate obuf */
TEST_ASSERT_BUFFERS_ARE_EQUAL(
@@ -4994,8 +4999,9 @@ test_snow3g_cipher_auth(const struct snow3g_test_data 
*tdata)
tdata->validDataLenInBits.len,
"SNOW 3G Ciphertext data not as expected");
 
-   ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-   + plaintext_pad_len;
+   ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
+   uint8_t *,
+   plaintext_pad_len);
 
/* Validate obuf */
TEST_ASSERT_BUFFERS_ARE_EQUAL(
@@ -5020,6 +5026,7 @@ test_snow3g_auth_cipher(const struct snow3g_test_data 
*tdata,
unsigned int plaintext_len;
unsigned int ciphertext_pad_len;
unsigned int ciphertext_len;
+   unsigned int digest_offset;
 
struct rte_cryptodev_info dev_info;
 
@@ -5163,9 +5170,12 @@ test_snow3g_auth_cipher(const struct snow3g_test_data 
*tdata,
debug_hexdump(stdout, "ciphertext expected:",
tdata->ciphertext.data, tdata->ciphertext.len >> 3);
 
-   ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
-   + (tdata->digest.offset_bytes == 0 ?
-   plaintext_pad_len : tdata->digest.offset_bytes);
+   if (tdata->dige

[PATCH v5 05/11] net/nfp: use rte_pktmbuf_mtod_offset

2023-07-07 Thread Stephen Hemminger
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

Signed-off-by: Stephen Hemminger 
---
 drivers/net/nfp/flower/nfp_flower_cmsg.h | 3 ++-
 drivers/net/nfp/flower/nfp_flower_ctrl.c | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h 
b/drivers/net/nfp/flower/nfp_flower_cmsg.h
index f643d54d39a4..787a38dc9aa0 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.h
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h
@@ -381,7 +381,8 @@ enum nfp_flower_cmsg_port_vnic_type {
 static inline char*
 nfp_flower_cmsg_get_data(struct rte_mbuf *m)
 {
-   return rte_pktmbuf_mtod(m, char *) + 4 + 4 + NFP_FLOWER_CMSG_HLEN;
+   return rte_pktmbuf_mtod_offset(m, char *,
+  4 + 4 + NFP_FLOWER_CMSG_HLEN);
 }
 
 /*
diff --git a/drivers/net/nfp/flower/nfp_flower_ctrl.c 
b/drivers/net/nfp/flower/nfp_flower_ctrl.c
index 4cb2c2f99e04..18823a97887d 100644
--- a/drivers/net/nfp/flower/nfp_flower_ctrl.c
+++ b/drivers/net/nfp/flower/nfp_flower_ctrl.c
@@ -389,7 +389,7 @@ nfp_flower_cmsg_rx_stats(struct nfp_flow_priv *flow_priv,
uint32_t ctx_id;
struct nfp_flower_stats_frame *stats;
 
-   msg = rte_pktmbuf_mtod(mbuf, char *) + NFP_FLOWER_CMSG_HLEN;
+   msg = rte_pktmbuf_mtod_offset(mbuf, char *, NFP_FLOWER_CMSG_HLEN);
msg_len = mbuf->data_len - NFP_FLOWER_CMSG_HLEN;
count = msg_len / sizeof(struct nfp_flower_stats_frame);
 
@@ -412,7 +412,7 @@ nfp_flower_cmsg_rx_qos_stats(struct nfp_mtr_priv *mtr_priv,
struct nfp_mtr *mtr;
struct nfp_mtr_stats_reply *mtr_stats;
 
-   msg = rte_pktmbuf_mtod(mbuf, char *) + NFP_FLOWER_CMSG_HLEN;
+   msg = rte_pktmbuf_mtod_offset(mbuf, char *, NFP_FLOWER_CMSG_HLEN);
 
mtr_stats = (struct nfp_mtr_stats_reply *)msg;
profile_id = rte_be_to_cpu_32(mtr_stats->head.profile_id);
-- 
2.39.2



[PATCH v5 04/11] drivers/crypto: use rte_pktmbuf_mtod_offset

2023-07-07 Thread Stephen Hemminger
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

Signed-off-by: Stephen Hemminger 
---
 drivers/crypto/caam_jr/caam_jr.c |  8 
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c |  2 +-
 drivers/crypto/cnxk/cnxk_se.h|  5 ++---
 drivers/crypto/ipsec_mb/pmd_kasumi.c | 19 +++
 drivers/crypto/ipsec_mb/pmd_snow3g.c |  4 ++--
 drivers/crypto/ipsec_mb/pmd_zuc.c| 18 ++
 drivers/crypto/qat/dev/qat_crypto_pmd_gens.h |  9 +
 drivers/crypto/qat/qat_sym.h |  9 +
 8 files changed, 40 insertions(+), 34 deletions(-)

diff --git a/drivers/crypto/caam_jr/caam_jr.c b/drivers/crypto/caam_jr/caam_jr.c
index b55258689b49..9c96fd21a48d 100644
--- a/drivers/crypto/caam_jr/caam_jr.c
+++ b/drivers/crypto/caam_jr/caam_jr.c
@@ -631,15 +631,15 @@ hw_poll_job_ring(struct sec_job_ring_t *job_ring,
 
if (ctx->op->sym->m_dst) {
/*TODO check for ip header or other*/
-   ip4_hdr = (struct ip *)
-   rte_pktmbuf_mtod(ctx->op->sym->m_dst, char*);
+   ip4_hdr = rte_pktmbuf_mtod(ctx->op->sym->m_dst,
+  struct ip *);
ctx->op->sym->m_dst->pkt_len =
rte_be_to_cpu_16(ip4_hdr->ip_len);
ctx->op->sym->m_dst->data_len =
rte_be_to_cpu_16(ip4_hdr->ip_len);
} else {
-   ip4_hdr = (struct ip *)
-   rte_pktmbuf_mtod(ctx->op->sym->m_src, char*);
+   ip4_hdr = rte_pktmbuf_mtod(ctx->op->sym->m_src,
+  struct ip *);
ctx->op->sym->m_src->pkt_len =
rte_be_to_cpu_16(ip4_hdr->ip_len);
ctx->op->sym->m_src->data_len =
diff --git a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c 
b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
index 34d40b07d4c6..8b91d11b79cc 100644
--- a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
+++ b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
@@ -520,7 +520,7 @@ cn9k_cpt_sec_post_process(struct rte_crypto_op *cop,
 
if (infl_req->op_flags & CPT_OP_FLAGS_IPSEC_DIR_INBOUND) {
 
-   hdr = (struct roc_ie_on_inb_hdr *)rte_pktmbuf_mtod(m, char *);
+   hdr = rte_pktmbuf_mtod(m, struct roc_ie_on_inb_hdr *);
 
if (likely(m->next == NULL)) {
ip = PLT_PTR_ADD(hdr, ROC_IE_ON_INB_RPTR_HDR);
diff --git a/drivers/crypto/cnxk/cnxk_se.h b/drivers/crypto/cnxk/cnxk_se.h
index 75c1dce231bf..1392af5833d1 100644
--- a/drivers/crypto/cnxk/cnxk_se.h
+++ b/drivers/crypto/cnxk/cnxk_se.h
@@ -2724,7 +2724,7 @@ fill_fc_params(struct rte_crypto_op *cop, struct 
cnxk_se_sess *sess,
m = cpt_m_dst_get(cpt_op, m_src, m_dst);
 
/* Digest immediately following data is best case */
-   if (unlikely(rte_pktmbuf_mtod(m, uint8_t *) + mc_hash_off !=
+   if (unlikely(rte_pktmbuf_mtod_offset(m, uint8_t *, mc_hash_off) 
!=
 (uint8_t *)sym_op->aead.digest.data)) {
flags |= ROC_SE_VALID_MAC_BUF;
fc_params.mac_buf.size = sess->mac_len;
@@ -2759,8 +2759,7 @@ fill_fc_params(struct rte_crypto_op *cop, struct 
cnxk_se_sess *sess,
 
/* hmac immediately following data is best case */
if (!(op_minor & ROC_SE_FC_MINOR_OP_HMAC_FIRST) &&
-   (unlikely(rte_pktmbuf_mtod(m, uint8_t *) +
- mc_hash_off !=
+   (unlikely(rte_pktmbuf_mtod_offset(m, uint8_t *, 
mc_hash_off) !=
  (uint8_t *)sym_op->auth.digest.data))) {
flags |= ROC_SE_VALID_MAC_BUF;
fc_params.mac_buf.size = sess->mac_len;
diff --git a/drivers/crypto/ipsec_mb/pmd_kasumi.c 
b/drivers/crypto/ipsec_mb/pmd_kasumi.c
index 5db9c523cd9a..70536ec3dc2a 100644
--- a/drivers/crypto/ipsec_mb/pmd_kasumi.c
+++ b/drivers/crypto/ipsec_mb/pmd_kasumi.c
@@ -83,13 +83,16 @@ process_kasumi_cipher_op(struct ipsec_mb_qp *qp, struct 
rte_crypto_op **ops,
uint32_t num_bytes[num_ops];
 
for (i = 0; i < num_ops; i++) {
-   src[i] = rte_pktmbuf_mtod(ops[i]->sym->m_src, uint8_t *)
-+ (ops[i]->sym->cipher.data.offset >> 3);
+   src[i] = rte_pktmbuf_mtod_offset(ops[i]->sym->m_src,
+uint8_t *,
+
(ops[i]->sym->cipher.data.offset >> 3));
dst[i] 

[PATCH v5 06/11] net/tap: use rte_pktmbuf_motd_offset

2023-07-07 Thread Stephen Hemminger
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

Signed-off-by: Stephen Hemminger 
---
 drivers/net/tap/rte_eth_tap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index bf98f7555990..968a1b6b45df 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -672,8 +672,8 @@ tap_write_mbufs(struct tx_queue *txq, uint16_t num_mbufs,
if (seg_len > l234_hlen) {
iovecs[k].iov_len = seg_len - l234_hlen;
iovecs[k].iov_base =
-   rte_pktmbuf_mtod(seg, char *) +
-   l234_hlen;
+   rte_pktmbuf_mtod_offset(seg, char *,
+   l234_hlen);
tap_tx_l4_add_rcksum(iovecs[k].iov_base,
iovecs[k].iov_len, l4_cksum,
&l4_raw_cksum);
-- 
2.39.2



[PATCH v5 07/11] baseband/fpga: use rte_pktmbuf_offset

2023-07-07 Thread Stephen Hemminger
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

Signed-off-by: Stephen Hemminger 
---
 drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c 
b/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
index f29565af8cca..465a65f3dca2 100644
--- a/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
+++ b/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
@@ -1543,8 +1543,7 @@ fpga_harq_write_loopback(struct fpga_queue *q,
rte_bbdev_log(ERR, "HARQ in length > HARQ buffer size\n");
}
 
-   input = (uint64_t *)rte_pktmbuf_mtod_offset(harq_input,
-   uint8_t *, in_offset);
+   input = rte_pktmbuf_mtod_offset(harq_input, uint64_t *, in_offset);
 
while (left_length > 0) {
if (fpga_reg_read_8(q->d->mmio_base,
@@ -1621,8 +1620,8 @@ fpga_harq_read_loopback(struct fpga_queue *q,
}
left_length = harq_in_length;
 
-   input = (uint64_t *)rte_pktmbuf_mtod_offset(harq_output,
-   uint8_t *, harq_out_offset);
+   input = rte_pktmbuf_mtod_offset(harq_output, uint64_t *,
+   harq_out_offset);
 
while (left_length > 0) {
fpga_reg_write_32(q->d->mmio_base,
-- 
2.39.2



[PATCH v5 08/11] cpt: use rte_pktmbuf_mtod_offset

2023-07-07 Thread Stephen Hemminger
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

Signed-off-by: Stephen Hemminger 
---
 drivers/common/cpt/cpt_ucode.h | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/common/cpt/cpt_ucode.h b/drivers/common/cpt/cpt_ucode.h
index b393be4cf661..87a3ac80b9da 100644
--- a/drivers/common/cpt/cpt_ucode.h
+++ b/drivers/common/cpt/cpt_ucode.h
@@ -3167,9 +3167,8 @@ fill_fc_params(struct rte_crypto_op *cop,
m = m_src;
 
/* hmac immediately following data is best case */
-   if (unlikely(rte_pktmbuf_mtod(m, uint8_t *) +
-   mc_hash_off !=
-   (uint8_t *)sym_op->aead.digest.data)) {
+   if (unlikely(rte_pktmbuf_mtod_offset(m, uint8_t *, 
mc_hash_off) !=
+(uint8_t *)sym_op->aead.digest.data)) {
flags |= VALID_MAC_BUF;
fc_params.mac_buf.size = sess_misc->mac_len;
fc_params.mac_buf.vaddr =
@@ -3211,9 +3210,8 @@ fill_fc_params(struct rte_crypto_op *cop,
 
/* hmac immediately following data is best case */
if (!ctx->dec_auth && !ctx->auth_enc &&
-(unlikely(rte_pktmbuf_mtod(m, uint8_t *) +
-   mc_hash_off !=
-(uint8_t *)sym_op->auth.digest.data))) {
+(unlikely(rte_pktmbuf_mtod_offset(m, uint8_t 
*, mc_hash_off) !=
+  (uint8_t 
*)sym_op->auth.digest.data))) {
flags |= VALID_MAC_BUF;
fc_params.mac_buf.size =
sess_misc->mac_len;
-- 
2.39.2



[PATCH v5 09/11] testpmd: use rte_pktmbuf_mtod_offset

2023-07-07 Thread Stephen Hemminger
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

Signed-off-by: Stephen Hemminger 
---
 app/test-pmd/ieee1588fwd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/app/test-pmd/ieee1588fwd.c b/app/test-pmd/ieee1588fwd.c
index 386d9f10e642..3371771751dd 100644
--- a/app/test-pmd/ieee1588fwd.c
+++ b/app/test-pmd/ieee1588fwd.c
@@ -138,8 +138,8 @@ ieee1588_packet_fwd(struct fwd_stream *fs)
 * Check that the received PTP packet is a PTP V2 packet of type
 * PTP_SYNC_MESSAGE.
 */
-   ptp_hdr = (struct ptpv2_msg *) (rte_pktmbuf_mtod(mb, char *) +
-   sizeof(struct rte_ether_hdr));
+   ptp_hdr = rte_pktmbuf_mtod_offset(mb, struct ptpv2_msg *,
+ sizeof(struct rte_ether_hdr));
if (ptp_hdr->version != 0x02) {
printf("Port %u Received PTP V2 Ethernet frame with wrong PTP"
   " protocol version 0x%x (should be 0x02)\n",
-- 
2.39.2



[PATCH v5 11/11] examples/l2fwd-crypto: use rte_pktmbuf_mtod_offset

2023-07-07 Thread Stephen Hemminger
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

Signed-off-by: Stephen Hemminger 
---
 examples/l2fwd-crypto/main.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index efe7eea2a768..19db0a280bf0 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -410,8 +410,8 @@ l2fwd_simple_crypto_enqueue(struct rte_mbuf *m,
 
ipdata_offset = sizeof(struct rte_ether_hdr);
 
-   ip_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(m, char *) +
-   ipdata_offset);
+   ip_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *,
+ipdata_offset);
 
ipdata_offset += (ip_hdr->version_ihl & RTE_IPV4_HDR_IHL_MASK)
* RTE_IPV4_IHL_MULTIPLIER;
@@ -479,8 +479,8 @@ l2fwd_simple_crypto_enqueue(struct rte_mbuf *m,
op->sym->auth.digest.data = (uint8_t 
*)rte_pktmbuf_append(m,
cparams->digest_length);
} else {
-   op->sym->auth.digest.data = rte_pktmbuf_mtod(m,
-   uint8_t *) + ipdata_offset + data_len;
+   op->sym->auth.digest.data = rte_pktmbuf_mtod_offset(m,
+   uint8_t *, ipdata_offset + data_len);
}
 
op->sym->auth.digest.phys_addr = rte_pktmbuf_iova_offset(m,
@@ -540,8 +540,8 @@ l2fwd_simple_crypto_enqueue(struct rte_mbuf *m,
op->sym->aead.digest.data = (uint8_t 
*)rte_pktmbuf_append(m,
cparams->digest_length);
} else {
-   op->sym->aead.digest.data = rte_pktmbuf_mtod(m,
-   uint8_t *) + ipdata_offset + data_len;
+   op->sym->aead.digest.data = rte_pktmbuf_mtod_offset(m,
+   uint8_t *, ipdata_offset + data_len);
}
 
op->sym->aead.digest.phys_addr = rte_pktmbuf_iova_offset(m,
@@ -631,7 +631,7 @@ l2fwd_simple_forward(struct rte_mbuf *m, uint16_t portid,
struct rte_ipv4_hdr *ip_hdr;
uint32_t ipdata_offset = sizeof(struct rte_ether_hdr);
 
-   ip_hdr = (struct rte_ipv4_hdr *)(rte_pktmbuf_mtod(m, char *) +
+   ip_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *,
 ipdata_offset);
dst_port = l2fwd_dst_ports[portid];
 
-- 
2.39.2



[PATCH v5 10/11] examples/ptpclient: use rte_pktmbuf_mtod_offset

2023-07-07 Thread Stephen Hemminger
Replace explicit packet offset computations with rte_pktmbuf_mtod_offset().

Signed-off-by: Stephen Hemminger 
---
 examples/ptpclient/ptpclient.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/examples/ptpclient/ptpclient.c b/examples/ptpclient/ptpclient.c
index cdf2da64dfee..2535d848a1e9 100644
--- a/examples/ptpclient/ptpclient.c
+++ b/examples/ptpclient/ptpclient.c
@@ -354,8 +354,8 @@ parse_sync(struct ptpv2_data_slave_ordinary *ptp_data, 
uint16_t rx_tstamp_idx)
 {
struct ptp_header *ptp_hdr;
 
-   ptp_hdr = (struct ptp_header *)(rte_pktmbuf_mtod(ptp_data->m, char *)
-   + sizeof(struct rte_ether_hdr));
+   ptp_hdr = rte_pktmbuf_mtod_offset(ptp_data->m, struct ptp_header *,
+ sizeof(struct rte_ether_hdr));
ptp_data->seqID_SYNC = rte_be_to_cpu_16(ptp_hdr->seq_id);
 
if (ptp_data->ptpset == 0) {
@@ -397,15 +397,15 @@ parse_fup(struct ptpv2_data_slave_ordinary *ptp_data)
int ret;
 
eth_hdr = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
-   ptp_hdr = (struct ptp_header *)(rte_pktmbuf_mtod(m, char *)
-   + sizeof(struct rte_ether_hdr));
+   ptp_hdr = rte_pktmbuf_mtod_offset(m, struct ptp_header *,
+ sizeof(struct rte_ether_hdr));
if (memcmp(&ptp_data->master_clock_id,
&ptp_hdr->source_port_id.clock_id,
sizeof(struct clock_id)) != 0)
return;
 
ptp_data->seqID_FOLLOWUP = rte_be_to_cpu_16(ptp_hdr->seq_id);
-   ptp_msg = (struct ptp_message *) (rte_pktmbuf_mtod(m, char *) +
+   ptp_msg = rte_pktmbuf_mtod_offset(m, struct ptp_message *,
  sizeof(struct rte_ether_hdr));
 
origin_tstamp = &ptp_msg->follow_up.precise_origin_tstamp;
@@ -537,8 +537,8 @@ parse_drsp(struct ptpv2_data_slave_ordinary *ptp_data)
struct tstamp *rx_tstamp;
uint16_t seq_id;
 
-   ptp_msg = (struct ptp_message *) (rte_pktmbuf_mtod(m, char *) +
-   sizeof(struct rte_ether_hdr));
+   ptp_msg = rte_pktmbuf_mtod_offset(m, struct ptp_message *,
+ sizeof(struct rte_ether_hdr));
seq_id = rte_be_to_cpu_16(ptp_msg->delay_resp.hdr.seq_id);
if (memcmp(&ptp_data->client_clock_id,
   &ptp_msg->delay_resp.req_port_id.clock_id,
@@ -585,8 +585,8 @@ parse_ptp_frames(uint16_t portid, struct rte_mbuf *m) {
if (eth_type == PTP_PROTOCOL) {
ptp_data.m = m;
ptp_data.portid = portid;
-   ptp_hdr = (struct ptp_header *)(rte_pktmbuf_mtod(m, char *)
-   + sizeof(struct rte_ether_hdr));
+   ptp_hdr = rte_pktmbuf_mtod_offset(m, struct ptp_header *,
+ sizeof(struct rte_ether_hdr));
 
switch (ptp_hdr->msg_type) {
case SYNC:
-- 
2.39.2