ethdev: fix max Rx packet length
authorFerruh Yigit <ferruh.yigit@intel.com>
Mon, 18 Oct 2021 13:48:48 +0000 (14:48 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 18 Oct 2021 17:20:20 +0000 (19:20 +0200)
commit1bb4a528c41f4af4847bd3d58cc2b2b9f1ec9a27
tree39a1c83a9bed6811b27dfe8c3e0aa16afda86307
parent24f1955d1ecd13a3c261a328c72932115732825e
ethdev: fix max Rx packet length

There is a confusion on setting max Rx packet length, this patch aims to
clarify it.

'rte_eth_dev_configure()' API accepts max Rx packet size via
'uint32_t max_rx_pkt_len' field of the config struct 'struct
rte_eth_conf'.

Also 'rte_eth_dev_set_mtu()' API can be used to set the MTU, and result
stored into '(struct rte_eth_dev)->data->mtu'.

These two APIs are related but they work in a disconnected way, they
store the set values in different variables which makes hard to figure
out which one to use, also having two different method for a related
functionality is confusing for the users.

Other issues causing confusion is:
* maximum transmission unit (MTU) is payload of the Ethernet frame. And
  'max_rx_pkt_len' is the size of the Ethernet frame. Difference is
  Ethernet frame overhead, and this overhead may be different from
  device to device based on what device supports, like VLAN and QinQ.
* 'max_rx_pkt_len' is only valid when application requested jumbo frame,
  which adds additional confusion and some APIs and PMDs already
  discards this documented behavior.
* For the jumbo frame enabled case, 'max_rx_pkt_len' is an mandatory
  field, this adds configuration complexity for application.

As solution, both APIs gets MTU as parameter, and both saves the result
in same variable '(struct rte_eth_dev)->data->mtu'. For this
'max_rx_pkt_len' updated as 'mtu', and it is always valid independent
from jumbo frame.

For 'rte_eth_dev_configure()', 'dev->data->dev_conf.rxmode.mtu' is user
request and it should be used only within configure function and result
should be stored to '(struct rte_eth_dev)->data->mtu'. After that point
both application and PMD uses MTU from this variable.

When application doesn't provide an MTU during 'rte_eth_dev_configure()'
default 'RTE_ETHER_MTU' value is used.

Additional clarification done on scattered Rx configuration, in
relation to MTU and Rx buffer size.
MTU is used to configure the device for physical Rx/Tx size limitation,
Rx buffer is where to store Rx packets, many PMDs use mbuf data buffer
size as Rx buffer size.
PMDs compare MTU against Rx buffer size to decide enabling scattered Rx
or not. If scattered Rx is not supported by device, MTU bigger than Rx
buffer size should fail.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Acked-by: Somnath Kotur <somnath.kotur@broadcom.com>
Acked-by: Huisong Li <lihuisong@huawei.com>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
Acked-by: Rosen Xu <rosen.xu@intel.com>
Acked-by: Hyong Youb Kim <hyonkim@cisco.com>
121 files changed:
app/test-eventdev/test_perf_common.c
app/test-eventdev/test_pipeline_common.c
app/test-pmd/cmdline.c
app/test-pmd/config.c
app/test-pmd/parameters.c
app/test-pmd/testpmd.c
app/test-pmd/testpmd.h
app/test/test_link_bonding.c
app/test/test_link_bonding_mode4.c
app/test/test_link_bonding_rssconf.c
app/test/test_pmd_perf.c
doc/guides/nics/dpaa.rst
doc/guides/nics/dpaa2.rst
doc/guides/nics/features.rst
doc/guides/nics/fm10k.rst
doc/guides/nics/mlx5.rst
doc/guides/nics/octeontx.rst
doc/guides/nics/thunderx.rst
doc/guides/rel_notes/deprecation.rst
doc/guides/sample_app_ug/flow_classify.rst
doc/guides/sample_app_ug/l3_forward.rst
doc/guides/sample_app_ug/l3_forward_access_ctrl.rst
doc/guides/sample_app_ug/l3_forward_graph.rst
doc/guides/sample_app_ug/l3_forward_power_man.rst
doc/guides/sample_app_ug/performance_thread.rst
doc/guides/sample_app_ug/skeleton.rst
drivers/net/atlantic/atl_ethdev.c
drivers/net/avp/avp_ethdev.c
drivers/net/axgbe/axgbe_ethdev.c
drivers/net/bnx2x/bnx2x_ethdev.c
drivers/net/bnxt/bnxt_ethdev.c
drivers/net/bonding/rte_eth_bond_pmd.c
drivers/net/cnxk/cnxk_ethdev.c
drivers/net/cnxk/cnxk_ethdev_ops.c
drivers/net/cxgbe/cxgbe_ethdev.c
drivers/net/cxgbe/cxgbe_main.c
drivers/net/cxgbe/sge.c
drivers/net/dpaa/dpaa_ethdev.c
drivers/net/dpaa2/dpaa2_ethdev.c
drivers/net/e1000/em_ethdev.c
drivers/net/e1000/igb_ethdev.c
drivers/net/e1000/igb_rxtx.c
drivers/net/ena/ena_ethdev.c
drivers/net/enetc/enetc_ethdev.c
drivers/net/enic/enic_ethdev.c
drivers/net/enic/enic_main.c
drivers/net/fm10k/fm10k_ethdev.c
drivers/net/hinic/hinic_pmd_ethdev.c
drivers/net/hns3/hns3_ethdev.c
drivers/net/hns3/hns3_ethdev_vf.c
drivers/net/hns3/hns3_rxtx.c
drivers/net/i40e/i40e_ethdev.c
drivers/net/i40e/i40e_rxtx.c
drivers/net/iavf/iavf_ethdev.c
drivers/net/ice/ice_dcf_ethdev.c
drivers/net/ice/ice_ethdev.c
drivers/net/ice/ice_rxtx.c
drivers/net/igc/igc_ethdev.c
drivers/net/igc/igc_ethdev.h
drivers/net/igc/igc_txrx.c
drivers/net/ionic/ionic_ethdev.c
drivers/net/ionic/ionic_rxtx.c
drivers/net/ipn3ke/ipn3ke_representor.c
drivers/net/ixgbe/ixgbe_ethdev.c
drivers/net/ixgbe/ixgbe_pf.c
drivers/net/ixgbe/ixgbe_rxtx.c
drivers/net/liquidio/lio_ethdev.c
drivers/net/mlx4/mlx4_rxq.c
drivers/net/mlx5/mlx5_rxq.c
drivers/net/mvneta/mvneta_ethdev.c
drivers/net/mvneta/mvneta_rxtx.c
drivers/net/mvpp2/mrvl_ethdev.c
drivers/net/nfp/nfp_common.c
drivers/net/octeontx/octeontx_ethdev.c
drivers/net/octeontx2/otx2_ethdev.c
drivers/net/octeontx2/otx2_ethdev_ops.c
drivers/net/pfe/pfe_ethdev.c
drivers/net/qede/qede_ethdev.c
drivers/net/qede/qede_rxtx.c
drivers/net/sfc/sfc_ethdev.c
drivers/net/sfc/sfc_port.c
drivers/net/tap/rte_eth_tap.c
drivers/net/thunderx/nicvf_ethdev.c
drivers/net/txgbe/txgbe_ethdev.c
drivers/net/txgbe/txgbe_ethdev.h
drivers/net/txgbe/txgbe_ethdev_vf.c
drivers/net/txgbe/txgbe_rxtx.c
drivers/net/virtio/virtio_ethdev.c
examples/bbdev_app/main.c
examples/bond/main.c
examples/distributor/main.c
examples/eventdev_pipeline/pipeline_worker_generic.c
examples/eventdev_pipeline/pipeline_worker_tx.c
examples/flow_classify/flow_classify.c
examples/ioat/ioatfwd.c
examples/ip_fragmentation/main.c
examples/ip_pipeline/link.c
examples/ip_reassembly/main.c
examples/ipsec-secgw/ipsec-secgw.c
examples/ipv4_multicast/main.c
examples/kni/main.c
examples/l2fwd-cat/l2fwd-cat.c
examples/l2fwd-crypto/main.c
examples/l2fwd-event/l2fwd_common.c
examples/l3fwd-acl/main.c
examples/l3fwd-graph/main.c
examples/l3fwd-power/main.c
examples/l3fwd/main.c
examples/performance-thread/l3fwd-thread/main.c
examples/performance-thread/l3fwd-thread/test.sh
examples/pipeline/obj.c
examples/ptpclient/ptpclient.c
examples/qos_meter/main.c
examples/qos_sched/init.c
examples/rxtx_callbacks/main.c
examples/skeleton/basicfwd.c
examples/vhost/main.c
examples/vm_power_manager/main.c
lib/ethdev/rte_ethdev.c
lib/ethdev/rte_ethdev.h
lib/ethdev/rte_ethdev_trace.h