Introduce IDPF driver
Subsystems (4)
cover Introduce IDPF driver
This patch series introduces the Infrastructure Data Path Function (IDPF) driver. It is used for both physical and virtual functions. Except for some of the device operations the rest of the functionality is the same for both PF and VF. IDPF uses virtchnl version2 opcodes and structures defined in the virtchnl2 header file which helps the driver to learn the capabilities and register offsets from the device Control Plane (CP) instead of assuming the default values.
The format of the series follows the driver init flow to interface open. To start with, probe gets called and kicks off the driver initialization by spawning the 'vc_event_task' work queue which in turn calls the 'hard reset' function. As part of that, the mailbox is initialized which is used to send/receive the virtchnl messages to/from the CP. Once that is done, 'core init' kicks in which requests all the required global resources from the CP and spawns the 'init_task' work queue to create the vports.
Based on the capability information received, the driver creates the said number of vports (one or many) where each vport is associated to a netdev. Also, each vport has its own resources such as queues, vectors etc. From there, rest of the netdev_ops and data path are added.
IDPF implements both single queue which is traditional queueing model as well as split queue model. In split queue model, it uses separate queue for both completion descriptors and buffers which helps to implement out-of-order completions. It also helps to implement asymmetric queues, for example multiple RX completion queues can be processed by a single RX buffer queue and multiple TX buffer queues can be processed by a single TX completion queue. In single queue model, same queue is used for both descriptor completions as well as buffer completions. It also supports features such as generic checksum offload, generic receive offload (hardware GRO) etc.
Pavan Kumar Linga (15):
virtchnl: add virtchnl version 2 ops
idpf: add module register and probe functionality
idpf: add controlq init and reset checks
idpf: add core init and interrupt request
idpf: add create vport and netdev configuration
idpf: continue expanding init task
idpf: configure resources for TX queues
idpf: configure resources for RX queues
idpf: initialize interrupts and enable vport
idpf: add splitq start_xmit
idpf: add TX splitq napi poll support
idpf: add RX splitq napi poll support
idpf: add singleq start_xmit and napi poll
idpf: add ethtool callbacks
idpf: configure SRIOV and add other ndo_ops
.../device_drivers/ethernet/intel/idpf.rst | 46 + drivers/net/ethernet/intel/Kconfig | 11 + drivers/net/ethernet/intel/Makefile | 1 + drivers/net/ethernet/intel/idpf/Makefile | 18 + drivers/net/ethernet/intel/idpf/idpf.h | 734 +++ .../net/ethernet/intel/idpf/idpf_controlq.c | 644 +++ .../net/ethernet/intel/idpf/idpf_controlq.h | 131 + .../ethernet/intel/idpf/idpf_controlq_api.h | 190 + .../ethernet/intel/idpf/idpf_controlq_setup.c | 175 + drivers/net/ethernet/intel/idpf/idpf_dev.c | 179 + drivers/net/ethernet/intel/idpf/idpf_devids.h | 10 + .../net/ethernet/intel/idpf/idpf_ethtool.c | 1325 +++++ .../ethernet/intel/idpf/idpf_lan_pf_regs.h | 124 + .../net/ethernet/intel/idpf/idpf_lan_txrx.h | 293 + .../ethernet/intel/idpf/idpf_lan_vf_regs.h | 128 + drivers/net/ethernet/intel/idpf/idpf_lib.c | 2551 +++++++++ drivers/net/ethernet/intel/idpf/idpf_main.c | 85 + drivers/net/ethernet/intel/idpf/idpf_mem.h | 20 + .../ethernet/intel/idpf/idpf_singleq_txrx.c | 1262 +++++ drivers/net/ethernet/intel/idpf/idpf_txrx.c | 4850 +++++++++++++++++ drivers/net/ethernet/intel/idpf/idpf_txrx.h | 838 +++ drivers/net/ethernet/intel/idpf/idpf_vf_dev.c | 180 + .../net/ethernet/intel/idpf/idpf_virtchnl.c | 3802 +++++++++++++ drivers/net/ethernet/intel/idpf/virtchnl2.h | 1153 ++++ .../ethernet/intel/idpf/virtchnl2_lan_desc.h | 644 +++ 25 files changed, 19394 insertions(+) create mode 100644 Documentation/networking/device_drivers/ethernet/intel/idpf.rst create mode 100644 drivers/net/ethernet/intel/idpf/Makefile create mode 100644 drivers/net/ethernet/intel/idpf/idpf.h create mode 100644 drivers/net/ethernet/intel/idpf/idpf_controlq.c create mode 100644 drivers/net/ethernet/intel/idpf/idpf_controlq.h create mode 100644 drivers/net/ethernet/intel/idpf/idpf_controlq_api.h create mode 100644 drivers/net/ethernet/intel/idpf/idpf_controlq_setup.c create mode 100644 drivers/net/ethernet/intel/idpf/idpf_dev.c create mode 100644 drivers/net/ethernet/intel/idpf/idpf_devids.h create mode 100644 drivers/net/ethernet/intel/idpf/idpf_ethtool.c create mode 100644 drivers/net/ethernet/intel/idpf/idpf_lan_pf_regs.h create mode 100644 drivers/net/ethernet/intel/idpf/idpf_lan_txrx.h create mode 100644 drivers/net/ethernet/intel/idpf/idpf_lan_vf_regs.h create mode 100644 drivers/net/ethernet/intel/idpf/idpf_lib.c create mode 100644 drivers/net/ethernet/intel/idpf/idpf_main.c create mode 100644 drivers/net/ethernet/intel/idpf/idpf_mem.h create mode 100644 drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c create mode 100644 drivers/net/ethernet/intel/idpf/idpf_txrx.c create mode 100644 drivers/net/ethernet/intel/idpf/idpf_txrx.h create mode 100644 drivers/net/ethernet/intel/idpf/idpf_vf_dev.c create mode 100644 drivers/net/ethernet/intel/idpf/idpf_virtchnl.c create mode 100644 drivers/net/ethernet/intel/idpf/virtchnl2.h create mode 100644 drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h
Signature · 1 line
2.37.3
PATCH 2/15 idpf: add module register and probe functionality
From: Phani Burra <[email protected]>
Add the required support to register IDPF PCI driver, as well as probe and remove call backs. Enable the PCI device and request the kernel to reserve the memory resources that will be used by the driver. Finally map the BAR0 address space.
PCI IDs table is intentionally left blank to prevent the kernel from probing the device with the incomplete driver. It will be added in the last patch of the series.
--- drivers/net/ethernet/intel/Kconfig | 11 +++ drivers/net/ethernet/intel/Makefile | 1 + drivers/net/ethernet/intel/idpf/Makefile | 10 ++ drivers/net/ethernet/intel/idpf/idpf.h | 27 ++++++ .../net/ethernet/intel/idpf/idpf_controlq.h | 14 +++ drivers/net/ethernet/intel/idpf/idpf_lib.c | 96 +++++++++++++++++++ drivers/net/ethernet/intel/idpf/idpf_main.c | 70 ++++++++++++++ 7 files changed, 229 insertions(+) create mode 100644 drivers/net/ethernet/intel/idpf/Makefile create mode 100644 drivers/net/ethernet/intel/idpf/idpf.h create mode 100644 drivers/net/ethernet/intel/idpf/idpf_controlq.h create mode 100644 drivers/net/ethernet/intel/idpf/idpf_lib.c create mode 100644 drivers/net/ethernet/intel/idpf/idpf_main.c
drivers/net/ethernet/intel/Kconfig +11 -0
@@ -373,4 +373,15 @@ config IGC To compile this driver as a module, choose M here. The module will be called igc. +config IDPF + tristate "Intel(R) Infrastructure Data Path Function Support" + depends on PCI_MSI + select DIMLIB + help + This driver supports Intel(R) Infrastructure Processing Unit (IPU) + devices. + + To compile this driver as a module, choose M here. The module + will be called idpf. + endif # NET_VENDOR_INTEL
drivers/net/ethernet/intel/Makefile +1 -0
@@ -16,3 +16,4 @@ obj-$(CONFIG_IXGB) += ixgb/ obj-$(CONFIG_IAVF) += iavf/ obj-$(CONFIG_FM10K) += fm10k/ obj-$(CONFIG_ICE) += ice/ +obj-$(CONFIG_IDPF) += idpf/
drivers/net/ethernet/intel/idpf/Makefile new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Copyright (C) 2023 Intel Corporation + +# Makefile for Infrastructure Data Path Function Linux Driver + +obj-$(CONFIG_IDPF) += idpf.o + +idpf-y := \ + idpf_lib.o \ + idpf_main.o
drivers/net/ethernet/intel/idpf/idpf.h new file +27 -0
@@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright (C) 2023 Intel Corporation */ + +#ifndef _IDPF_H_ +#define _IDPF_H_ + +#include <linux/aer.h> +#include <linux/etherdevice.h> +#include <linux/pci.h> + +#include "idpf_controlq.h" + +/* available message levels */ +#define IDPF_AVAIL_NETIF_M (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK) + +struct idpf_adapter { +struct pci_dev *pdev; +u32 msg_enable; +struct idpf_hw hw; +}; + +int idpf_pf_probe (struct pci_dev *pdev,struct idpf_adapter *adapter); +int idpf_vf_probe (struct pci_dev *pdev,struct idpf_adapter *adapter); +int idpf_probe_common (struct pci_dev *pdev,struct idpf_adapter *adapter); +void idpf_remove_common (struct pci_dev *pdev); + +#endif /* !_IDPF_H_ */
drivers/net/ethernet/intel/idpf/idpf_controlq.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright (C) 2023 Intel Corporation */ + +#ifndef _IDPF_CONTROLQ_H_ +#define _IDPF_CONTROLQ_H_ + +struct idpf_hw { +void __iomem *hw_addr; +resource_size_t hw_addr_len; + +void *back; +}; + +#endif /* _IDPF_CONTROLQ_H_ */
drivers/net/ethernet/intel/idpf/idpf_lib.c new file +96 -0
96 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_main.c new file +70 -0
70 lines not on this page · raw message
Signature · 1 line
2.37.3
PATCH 1/15 virtchnl: add virtchnl version 2 ops
In reply to Pavan Kumar LingaVirtchnl version 1 is an interface used by the current generation of foundational NICs to negotiate the capabilities and configure the HW resources such as queues, vectors, RSS LUT, etc between the PF and VF drivers. It is not extensible to enable new features supported in the next generation of NICs/IPUs and to negotiate descriptor types, packet types and register offsets.
To overcome the limitations of the existing interface, introduce the virtchnl version 2 and add the necessary opcodes, structures, definitions, and descriptor formats. The driver also learns the data queue and other register offsets to use instead of hardcoding them. The advantage of this approach is that it gives the flexibility to modify the register offsets if needed, restrict the use of certain descriptor types and negotiate the supported packet types.
Following are the links to the specifications for reference
Virtchnl version1:
https://www.intel.com/content/dam/www/public/us/en/documents/
product-specifications/ethernet-adaptive-virtual-function-hardware-spec.pdf
Virtchnl version2:
https://www.oasis-open.org/committees/documents.php?wg_abbrev=idpf
--- drivers/net/ethernet/intel/idpf/virtchnl2.h | 1153 +++++++++++++++++ .../ethernet/intel/idpf/virtchnl2_lan_desc.h | 644 +++++++++ 2 files changed, 1797 insertions(+) create mode 100644 drivers/net/ethernet/intel/idpf/virtchnl2.h create mode 100644 drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +1153 -0
@@ -0,0 +1,1153 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright (C) 2023 Intel Corporation */ + +#ifndef _VIRTCHNL2_H_ +#define _VIRTCHNL2_H_ + +/* All opcodes associated with virtchnl 2 are prefixed with virtchnl2 or +* VIRTCHNL2. Any future opcodes, offloads/capabilities, structures, +* and defines must be prefixed with virtchnl2 or VIRTCHNL2 to avoid confusion. +* +* PF/VF uses the virtchnl interface defined in this header file to communicate +* with device Control Plane (CP). Driver and the CP may run on different +* platforms with different endianness. To avoid byte order discrepancies, +* struct members in this header follow little-endian format. Users of this +* virtchnl interface are expected to convert back to their native endian +* format. +*/ + +#include "virtchnl2_lan_desc.h" + +/* VIRTCHNL2_ERROR_CODES */ +/* Success */ +#define VIRTCHNL2_STATUS_SUCCESS 0 +/* Operation not permitted, used in case of command not permitted for sender */ +#define VIRTCHNL2_STATUS_ERR_EPERM 1 +/* Bad opcode - virtchnl interface problem */ +#define VIRTCHNL2_STATUS_ERR_ESRCH 3 +/* I/O error - HW access error */ +#define VIRTCHNL2_STATUS_ERR_EIO 5 +/* No such resource - Referenced resource is not allacated */ +#define VIRTCHNL2_STATUS_ERR_ENXIO 6 +/* Permission denied - Resource is not permitted to caller */ +#define VIRTCHNL2_STATUS_ERR_EACCES 13 +/* Device or resource busy - In case shared resource is in use by others */ +#define VIRTCHNL2_STATUS_ERR_EBUSY 16 +/* Object already exists and not free */ +#define VIRTCHNL2_STATUS_ERR_EEXIST 17 +/* Invalid input argument in command */ +#define VIRTCHNL2_STATUS_ERR_EINVAL 22 +/* No space left or allocation failure */ +#define VIRTCHNL2_STATUS_ERR_ENOSPC 28 +/* Parameter out of range */ +#define VIRTCHNL2_STATUS_ERR_ERANGE 34 + +/* Op not allowed in current dev mode */ +#define VIRTCHNL2_STATUS_ERR_EMODE 200 +/* State Machine error - Command sequence problem */ +#define VIRTCHNL2_STATUS_ERR_ESM 201 + +/* This macro is used to generate compilation errors if a structure +* is not exactly the correct length. +*/ +#define VIRTCHNL2_CHECK_STRUCT_LEN (n,X ) \ + static_assert((n) == sizeof(struct X)) + +/* New major set of opcodes introduced and so leaving room for +* old misc opcodes to be added in future. Also these opcodes may only +* be used if both the PF and VF have successfully negotiated the +* VIRTCHNL version as 2.0 during VIRTCHNL2_OP_VERSION exchange. +*/ +#define VIRTCHNL2_OP_UNKNOWN 0 +#define VIRTCHNL2_OP_VERSION 1 +#define VIRTCHNL2_OP_GET_CAPS 500 +#define VIRTCHNL2_OP_CREATE_VPORT 501 +#define VIRTCHNL2_OP_DESTROY_VPORT 502 +#define VIRTCHNL2_OP_ENABLE_VPORT 503 +#define VIRTCHNL2_OP_DISABLE_VPORT 504 +#define VIRTCHNL2_OP_CONFIG_TX_QUEUES 505 +#define VIRTCHNL2_OP_CONFIG_RX_QUEUES 506 +#define VIRTCHNL2_OP_ENABLE_QUEUES 507 +#define VIRTCHNL2_OP_DISABLE_QUEUES 508 +#define VIRTCHNL2_OP_ADD_QUEUES 509 +#define VIRTCHNL2_OP_DEL_QUEUES 510 +#define VIRTCHNL2_OP_MAP_QUEUE_VECTOR 511 +#define VIRTCHNL2_OP_UNMAP_QUEUE_VECTOR 512 +#define VIRTCHNL2_OP_GET_RSS_KEY 513 +#define VIRTCHNL2_OP_SET_RSS_KEY 514 +#define VIRTCHNL2_OP_GET_RSS_LUT 515 +#define VIRTCHNL2_OP_SET_RSS_LUT 516 +#define VIRTCHNL2_OP_GET_RSS_HASH 517 +#define VIRTCHNL2_OP_SET_RSS_HASH 518 +#define VIRTCHNL2_OP_SET_SRIOV_VFS 519 +#define VIRTCHNL2_OP_ALLOC_VECTORS 520 +#define VIRTCHNL2_OP_DEALLOC_VECTORS 521 +#define VIRTCHNL2_OP_EVENT 522 +#define VIRTCHNL2_OP_GET_STATS 523 +#define VIRTCHNL2_OP_RESET_VF 524 +#define VIRTCHNL2_OP_GET_EDT_CAPS 525 +#define VIRTCHNL2_OP_GET_PTYPE_INFO 526 +/* Opcode 527 and 528 are reserved for VIRTCHNL2_OP_GET_PTYPE_ID and +* VIRTCHNL2_OP_GET_PTYPE_INFO_RAW. +* Opcodes 529, 530, 531, 532 and 533 are reserved. +*/ +#define VIRTCHNL2_OP_LOOPBACK 534 +#define VIRTCHNL2_OP_ADD_MAC_ADDR 535 +#define VIRTCHNL2_OP_DEL_MAC_ADDR 536 +#define VIRTCHNL2_OP_CONFIG_PROMISCUOUS_MODE 537 + +/* VIRTCHNL2_VPORT_TYPE +* Type of virtual port +*/ +#define VIRTCHNL2_VPORT_TYPE_DEFAULT 0 + +/* VIRTCHNL2_QUEUE_MODEL +* Type of queue model +* +* In the single queue model, the same transmit descriptor queue is used by +* software to post descriptors to hardware and by hardware to post completed +* descriptors to software. +* Likewise, the same receive descriptor queue is used by hardware to post +* completions to software and by software to post buffers to hardware. +*/ +#define VIRTCHNL2_QUEUE_MODEL_SINGLE 0 +/* In the split queue model, hardware uses transmit completion queues to post +* descriptor/buffer completions to software, while software uses transmit +* descriptor queues to post descriptors to hardware. +* Likewise, hardware posts descriptor completions to the receive descriptor +* queue, while software uses receive buffer queues to post buffers to hardware. +*/ +#define VIRTCHNL2_QUEUE_MODEL_SPLIT 1 + +/* VIRTCHNL2_CHECKSUM_OFFLOAD_CAPS +* Checksum offload capability flags +*/ +#define VIRTCHNL2_CAP_TX_CSUM_L3_IPV4 BIT(0) +#define VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_TCP BIT(1) +#define VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_UDP BIT(2) +#define VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_SCTP BIT(3) +#define VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_TCP BIT(4) +#define VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_UDP BIT(5) +#define VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_SCTP BIT(6) +#define VIRTCHNL2_CAP_TX_CSUM_GENERIC BIT(7) +#define VIRTCHNL2_CAP_RX_CSUM_L3_IPV4 BIT(8) +#define VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_TCP BIT(9) +#define VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_UDP BIT(10) +#define VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_SCTP BIT(11) +#define VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_TCP BIT(12) +#define VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_UDP BIT(13) +#define VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_SCTP BIT(14) +#define VIRTCHNL2_CAP_RX_CSUM_GENERIC BIT(15) +#define VIRTCHNL2_CAP_TX_CSUM_L3_SINGLE_TUNNEL BIT(16) +#define VIRTCHNL2_CAP_TX_CSUM_L3_DOUBLE_TUNNEL BIT(17) +#define VIRTCHNL2_CAP_RX_CSUM_L3_SINGLE_TUNNEL BIT(18) +#define VIRTCHNL2_CAP_RX_CSUM_L3_DOUBLE_TUNNEL BIT(19) +#define VIRTCHNL2_CAP_TX_CSUM_L4_SINGLE_TUNNEL BIT(20) +#define VIRTCHNL2_CAP_TX_CSUM_L4_DOUBLE_TUNNEL BIT(21) +#define VIRTCHNL2_CAP_RX_CSUM_L4_SINGLE_TUNNEL BIT(22) +#define VIRTCHNL2_CAP_RX_CSUM_L4_DOUBLE_TUNNEL BIT(23) + +/* VIRTCHNL2_SEGMENTATION_OFFLOAD_CAPS +* Segmentation offload capability flags +*/ +#define VIRTCHNL2_CAP_SEG_IPV4_TCP BIT(0) +#define VIRTCHNL2_CAP_SEG_IPV4_UDP BIT(1) +#define VIRTCHNL2_CAP_SEG_IPV4_SCTP BIT(2) +#define VIRTCHNL2_CAP_SEG_IPV6_TCP BIT(3) +#define VIRTCHNL2_CAP_SEG_IPV6_UDP BIT(4) +#define VIRTCHNL2_CAP_SEG_IPV6_SCTP BIT(5) +#define VIRTCHNL2_CAP_SEG_GENERIC BIT(6) +#define VIRTCHNL2_CAP_SEG_TX_SINGLE_TUNNEL BIT(7) +#define VIRTCHNL2_CAP_SEG_TX_DOUBLE_TUNNEL BIT(8) + +/* VIRTCHNL2_RSS_FLOW_TYPE_CAPS +* Receive Side Scaling Flow type capability flags +*/ +#define VIRTCHNL2_CAP_RSS_IPV4_TCP BIT_ULL(0) +#define VIRTCHNL2_CAP_RSS_IPV4_UDP BIT_ULL(1) +#define VIRTCHNL2_CAP_RSS_IPV4_SCTP BIT_ULL(2) +#define VIRTCHNL2_CAP_RSS_IPV4_OTHER BIT_ULL(3) +#define VIRTCHNL2_CAP_RSS_IPV6_TCP BIT_ULL(4) +#define VIRTCHNL2_CAP_RSS_IPV6_UDP BIT_ULL(5) +#define VIRTCHNL2_CAP_RSS_IPV6_SCTP BIT_ULL(6) +#define VIRTCHNL2_CAP_RSS_IPV6_OTHER BIT_ULL(7) +#define VIRTCHNL2_CAP_RSS_IPV4_AH BIT_ULL(8) +#define VIRTCHNL2_CAP_RSS_IPV4_ESP BIT_ULL(9) +#define VIRTCHNL2_CAP_RSS_IPV4_AH_ESP BIT_ULL(10) +#define VIRTCHNL2_CAP_RSS_IPV6_AH BIT_ULL(11) +#define VIRTCHNL2_CAP_RSS_IPV6_ESP BIT_ULL(12) +#define VIRTCHNL2_CAP_RSS_IPV6_AH_ESP BIT_ULL(13) + +/* VIRTCHNL2_HEADER_SPLIT_CAPS +* Header split capability flags +*/ +/* For prepended metadata */ +#define VIRTCHNL2_CAP_RX_HSPLIT_AT_L2 BIT(0) +/* All VLANs go into header buffer */ +#define VIRTCHNL2_CAP_RX_HSPLIT_AT_L3 BIT(1) +#define VIRTCHNL2_CAP_RX_HSPLIT_AT_L4V4 BIT(2) +#define VIRTCHNL2_CAP_RX_HSPLIT_AT_L4V6 BIT(3) + +/* VIRTCHNL2_RSC_OFFLOAD_CAPS +* Receive Side Coalescing offload capability flags +*/ +#define VIRTCHNL2_CAP_RSC_IPV4_TCP BIT(0) +#define VIRTCHNL2_CAP_RSC_IPV4_SCTP BIT(1) +#define VIRTCHNL2_CAP_RSC_IPV6_TCP BIT(2) +#define VIRTCHNL2_CAP_RSC_IPV6_SCTP BIT(3) + +/* VIRTCHNL2_OTHER_CAPS +* Other capability flags +* SPLITQ_QSCHED: Queue based scheduling using split queue model +* TX_VLAN: VLAN tag insertion +* RX_VLAN: VLAN tag stripping +*/ +#define VIRTCHNL2_CAP_RDMA BIT_ULL(0) +#define VIRTCHNL2_CAP_SRIOV BIT_ULL(1) +#define VIRTCHNL2_CAP_MACFILTER BIT_ULL(2) +#define VIRTCHNL2_CAP_FLOW_DIRECTOR BIT_ULL(3) +#define VIRTCHNL2_CAP_SPLITQ_QSCHED BIT_ULL(4) +#define VIRTCHNL2_CAP_CRC BIT_ULL(5) +#define VIRTCHNL2_CAP_ADQ BIT_ULL(6) +#define VIRTCHNL2_CAP_WB_ON_ITR BIT_ULL(7) +#define VIRTCHNL2_CAP_PROMISC BIT_ULL(8) +#define VIRTCHNL2_CAP_LINK_SPEED BIT_ULL(9) +#define VIRTCHNL2_CAP_INLINE_IPSEC BIT_ULL(10) +#define VIRTCHNL2_CAP_LARGE_NUM_QUEUES BIT_ULL(11) +/* Require additional info */ +#define VIRTCHNL2_CAP_VLAN BIT_ULL(12) +#define VIRTCHNL2_CAP_PTP BIT_ULL(13) +/* EDT: Earliest Departure Time capability used for Timing Wheel */ +#define VIRTCHNL2_CAP_EDT BIT_ULL(14) +#define VIRTCHNL2_CAP_ADV_RSS BIT_ULL(15) +#define VIRTCHNL2_CAP_FDIR BIT_ULL(16) +#define VIRTCHNL2_CAP_RX_FLEX_DESC BIT_ULL(17) +#define VIRTCHNL2_CAP_PTYPE BIT_ULL(18) +#define VIRTCHNL2_CAP_LOOPBACK BIT_ULL(19) +/* Enable miss completion types plus ability to detect a miss completion if a +* reserved bit is set in a standared completion's tag. +*/ +#define VIRTCHNL2_CAP_MISS_COMPL_TAG BIT_ULL(20) +/* This must be the last capability */ +#define VIRTCHNL2_CAP_OEM BIT_ULL(63) + +/* VIRTCHNL2_DEVICE_TYPE */ +/* Underlying device type */ +#define VIRTCHNL2_MEV_DEVICE 0 + +/* VIRTCHNL2_TXQ_SCHED_MODE +* Transmit Queue Scheduling Modes - Queue mode is the legacy mode i.e. inorder +* completions where descriptors and buffers are completed at the same time. +* Flow scheduling mode allows for out of order packet processing where +* descriptors are cleaned in order, but buffers can be completed out of order. +*/ +#define VIRTCHNL2_TXQ_SCHED_MODE_QUEUE 0 +#define VIRTCHNL2_TXQ_SCHED_MODE_FLOW 1 + +/* VIRTCHNL2_TXQ_FLAGS +* Transmit Queue feature flags +* +* Enable rule miss completion type; packet completion for a packet +* sent on exception path; only relevant in flow scheduling mode. +*/ +#define VIRTCHNL2_TXQ_ENABLE_MISS_COMPL BIT(0) + +/* VIRTCHNL2_PEER_TYPE +* Transmit mailbox peer type +*/ +#define VIRTCHNL2_RDMA_CPF 0 +#define VIRTCHNL2_NVME_CPF 1 +#define VIRTCHNL2_ATE_CPF 2 +#define VIRTCHNL2_LCE_CPF 3 + +/* VIRTCHNL2_RXQ_FLAGS +* Receive Queue Feature flags +*/ +#define VIRTCHNL2_RXQ_RSC BIT(0) +#define VIRTCHNL2_RXQ_HDR_SPLIT BIT(1) +/* When set, packet descriptors are flushed by hardware immediately after +* processing each packet. +*/ +#define VIRTCHNL2_RXQ_IMMEDIATE_WRITE_BACK BIT(2) +#define VIRTCHNL2_RX_DESC_SIZE_16BYTE BIT(3) +#define VIRTCHNL2_RX_DESC_SIZE_32BYTE BIT(4) + +/* VIRTCHNL2_RSS_ALGORITHM +* Type of RSS algorithm +*/ +#define VIRTCHNL2_RSS_ALG_TOEPLITZ_ASYMMETRIC 0 +#define VIRTCHNL2_RSS_ALG_R_ASYMMETRIC 1 +#define VIRTCHNL2_RSS_ALG_TOEPLITZ_SYMMETRIC 2 +#define VIRTCHNL2_RSS_ALG_XOR_SYMMETRIC 3 + +/* VIRTCHNL2_EVENT_CODES +* Type of event +*/ +#define VIRTCHNL2_EVENT_UNKNOWN 0 +#define VIRTCHNL2_EVENT_LINK_CHANGE 1 +/* Event type 2, 3 are reserved */ + +/* VIRTCHNL2_QUEUE_TYPE +* Transmit and Receive queue types are valid in legacy as well as split queue +* models. With Split Queue model, 2 additional types are introduced - +* TX_COMPLETION and RX_BUFFER. In split queue model, receive corresponds to +* the queue where hardware posts completions. +*/ +#define VIRTCHNL2_QUEUE_TYPE_TX 0 +#define VIRTCHNL2_QUEUE_TYPE_RX 1 +#define VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION 2 +#define VIRTCHNL2_QUEUE_TYPE_RX_BUFFER 3 +#define VIRTCHNL2_QUEUE_TYPE_CONFIG_TX 4 +#define VIRTCHNL2_QUEUE_TYPE_CONFIG_RX 5 +/* Queue types 6, 7, 8, 9 are reserved */ +#define VIRTCHNL2_QUEUE_TYPE_MBX_TX 10 +#define VIRTCHNL2_QUEUE_TYPE_MBX_RX 11 + +/* VIRTCHNL2_ITR_IDX +* Virtchannel interrupt throttling rate index +*/ +#define VIRTCHNL2_ITR_IDX_0 0 +#define VIRTCHNL2_ITR_IDX_1 1 + +/* VIRTCHNL2_MAC_TYPE +* VIRTCHNL2_MAC_ADDR_PRIMARY +* PF/VF driver should set @type to VIRTCHNL2_MAC_ADDR_PRIMARY for the +* primary/device unicast MAC address filter for VIRTCHNL2_OP_ADD_MAC_ADDR and +* VIRTCHNL2_OP_DEL_MAC_ADDR. This allows for the underlying control plane +* function to accurately track the MAC address and for VM/function reset. +* +* VIRTCHNL2_MAC_ADDR_EXTRA +* PF/VF driver should set @type to VIRTCHNL2_MAC_ADDR_EXTRA for any extra +* unicast and/or multicast filters that are being added/deleted via +* VIRTCHNL2_OP_ADD_MAC_ADDR/VIRTCHNL2_OP_DEL_MAC_ADDR respectively. +*/ +#define VIRTCHNL2_MAC_ADDR_PRIMARY 1 +#define VIRTCHNL2_MAC_ADDR_EXTRA 2 + +/* VIRTCHNL2_PROMISC_FLAGS +* Flags used for promiscuous mode +*/ +#define VIRTCHNL2_UNICAST_PROMISC BIT(0) +#define VIRTCHNL2_MULTICAST_PROMISC BIT(1) + +/* VIRTCHNL2_PROTO_HDR_TYPE +* Protocol header type within a packet segment. A segment consists of one or +* more protocol headers that make up a logical group of protocol headers. Each +* logical group of protocol headers encapsulates or is encapsulated using/by +* tunneling or encapsulation protocols for network virtualization. +*/ +/* VIRTCHNL2_PROTO_HDR_ANY is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_ANY 0 +#define VIRTCHNL2_PROTO_HDR_PRE_MAC 1 +/* VIRTCHNL2_PROTO_HDR_MAC is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_MAC 2 +#define VIRTCHNL2_PROTO_HDR_POST_MAC 3 +#define VIRTCHNL2_PROTO_HDR_ETHERTYPE 4 +#define VIRTCHNL2_PROTO_HDR_VLAN 5 +#define VIRTCHNL2_PROTO_HDR_SVLAN 6 +#define VIRTCHNL2_PROTO_HDR_CVLAN 7 +#define VIRTCHNL2_PROTO_HDR_MPLS 8 +#define VIRTCHNL2_PROTO_HDR_UMPLS 9 +#define VIRTCHNL2_PROTO_HDR_MMPLS 10 +#define VIRTCHNL2_PROTO_HDR_PTP 11 +#define VIRTCHNL2_PROTO_HDR_CTRL 12 +#define VIRTCHNL2_PROTO_HDR_LLDP 13 +#define VIRTCHNL2_PROTO_HDR_ARP 14 +#define VIRTCHNL2_PROTO_HDR_ECP 15 +#define VIRTCHNL2_PROTO_HDR_EAPOL 16 +#define VIRTCHNL2_PROTO_HDR_PPPOD 17 +#define VIRTCHNL2_PROTO_HDR_PPPOE 18 +/* VIRTCHNL2_PROTO_HDR_IPV4 is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_IPV4 19 +/* IPv4 and IPv6 Fragment header types are only associated to +* VIRTCHNL2_PROTO_HDR_IPV4 and VIRTCHNL2_PROTO_HDR_IPV6 respectively, +* cannot be used independently. +*/ +/* VIRTCHNL2_PROTO_HDR_IPV4_FRAG is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_IPV4_FRAG 20 +/* VIRTCHNL2_PROTO_HDR_IPV6 is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_IPV6 21 +/* VIRTCHNL2_PROTO_HDR_IPV6_FRAG is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_IPV6_FRAG 22 +#define VIRTCHNL2_PROTO_HDR_IPV6_EH 23 +/* VIRTCHNL2_PROTO_HDR_UDP is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_UDP 24 +/* VIRTCHNL2_PROTO_HDR_TCP is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_TCP 25 +/* VIRTCHNL2_PROTO_HDR_SCTP is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_SCTP 26 +/* VIRTCHNL2_PROTO_HDR_ICMP is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_ICMP 27 +/* VIRTCHNL2_PROTO_HDR_ICMPV6 is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_ICMPV6 28 +#define VIRTCHNL2_PROTO_HDR_IGMP 29 +#define VIRTCHNL2_PROTO_HDR_AH 30 +#define VIRTCHNL2_PROTO_HDR_ESP 31 +#define VIRTCHNL2_PROTO_HDR_IKE 32 +#define VIRTCHNL2_PROTO_HDR_NATT_KEEP 33 +/* VIRTCHNL2_PROTO_HDR_PAY is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_PAY 34 +#define VIRTCHNL2_PROTO_HDR_L2TPV2 35 +#define VIRTCHNL2_PROTO_HDR_L2TPV2_CONTROL 36 +#define VIRTCHNL2_PROTO_HDR_L2TPV3 37 +#define VIRTCHNL2_PROTO_HDR_GTP 38 +#define VIRTCHNL2_PROTO_HDR_GTP_EH 39 +#define VIRTCHNL2_PROTO_HDR_GTPCV2 40 +#define VIRTCHNL2_PROTO_HDR_GTPC_TEID 41 +#define VIRTCHNL2_PROTO_HDR_GTPU 42 +#define VIRTCHNL2_PROTO_HDR_GTPU_UL 43 +#define VIRTCHNL2_PROTO_HDR_GTPU_DL 44 +#define VIRTCHNL2_PROTO_HDR_ECPRI 45 +#define VIRTCHNL2_PROTO_HDR_VRRP 46 +#define VIRTCHNL2_PROTO_HDR_OSPF 47 +/* VIRTCHNL2_PROTO_HDR_TUN is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_TUN 48 +#define VIRTCHNL2_PROTO_HDR_GRE 49 +#define VIRTCHNL2_PROTO_HDR_NVGRE 50 +#define VIRTCHNL2_PROTO_HDR_VXLAN 51 +#define VIRTCHNL2_PROTO_HDR_VXLAN_GPE 52 +#define VIRTCHNL2_PROTO_HDR_GENEVE 53 +#define VIRTCHNL2_PROTO_HDR_NSH 54 +#define VIRTCHNL2_PROTO_HDR_QUIC 55 +#define VIRTCHNL2_PROTO_HDR_PFCP 56 +#define VIRTCHNL2_PROTO_HDR_PFCP_NODE 57 +#define VIRTCHNL2_PROTO_HDR_PFCP_SESSION 58 +#define VIRTCHNL2_PROTO_HDR_RTP 59 +#define VIRTCHNL2_PROTO_HDR_ROCE 60 +#define VIRTCHNL2_PROTO_HDR_ROCEV1 61 +#define VIRTCHNL2_PROTO_HDR_ROCEV2 62 +/* Protocol ids up to 32767 are reserved for AVF use */ +/* 32768 - 65534 are used for user defined protocol ids */ +/* VIRTCHNL2_PROTO_HDR_NO_PROTO is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_NO_PROTO 65535 + +#define VIRTCHNL2_VERSION_MAJOR_2 2 +#define VIRTCHNL2_VERSION_MINOR_0 0 + +/* VIRTCHNL2_OP_GET_EDT_CAPS +* Get EDT granularity and time horizon +*/ +struct virtchnl2_edt_caps { +/* Timestamp granularity in nanoseconds */ +__le64 tstamp_granularity_ns; +/* Total time window in nanoseconds */ +__le64 time_horizon_ns; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (16 , virtchnl2_edt_caps); + +/* VIRTCHNL2_OP_VERSION +* PF/VF posts its version number to the CP. CP responds with its version number +* in the same format, along with a return code. +* If there is a major version mismatch, then the PF/VF cannot operate. +* If there is a minor version mismatch, then the PF/VF can operate but should +* add a warning to the system log. +* +* This version opcode MUST always be specified as == 1, regardless of other +* changes in the API. The CP must always respond to this message without +* error regardless of version mismatch. +*/ +struct virtchnl2_version_info { +__le32 major; +__le32 minor; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (8 , virtchnl2_version_info); + +/* VIRTCHNL2_OP_GET_CAPS +* Dataplane driver sends this message to CP to negotiate capabilities and +* provides a virtchnl2_get_capabilities structure with its desired +* capabilities, max_sriov_vfs and num_allocated_vectors. +* CP responds with a virtchnl2_get_capabilities structure updated +* with allowed capabilities and the other fields as below. +* If PF sets max_sriov_vfs as 0, CP will respond with max number of VFs +* that can be created by this PF. For any other value 'n', CP responds +* with max_sriov_vfs set to min(n, x) where x is the max number of VFs +* allowed by CP's policy. max_sriov_vfs is not applicable for VFs. +* If dataplane driver sets num_allocated_vectors as 0, CP will respond with 1 +* which is default vector associated with the default mailbox. For any other +* value 'n', CP responds with a value <= n based on the CP's policy of +* max number of vectors for a PF. +* CP will respond with the vector ID of mailbox allocated to the PF in +* mailbox_vector_id and the number of itr index registers in itr_idx_map. +* It also responds with default number of vports that the dataplane driver +* should comeup with in default_num_vports and maximum number of vports that +* can be supported in max_vports. +*/ +struct virtchnl2_get_capabilities { +/* See VIRTCHNL2_CHECKSUM_OFFLOAD_CAPS definitions */ +__le32 csum_caps; +/* See VIRTCHNL2_SEGMENTATION_OFFLOAD_CAPS definitions */ +__le32 seg_caps; +/* See VIRTCHNL2_HEADER_SPLIT_CAPS definitions */ +__le32 hsplit_caps; +/* See VIRTCHNL2_RSC_OFFLOAD_CAPS definitions */ +__le32 rsc_caps; +/* See VIRTCHNL2_RSS_FLOW_TYPE_CAPS definitions */ +__le64 rss_caps; +/* See VIRTCHNL2_OTHER_CAPS definitions */ +__le64 other_caps; + +/* DYN_CTL register offset and vector id for mailbox provided by CP */ +__le32 mailbox_dyn_ctl; +__le16 mailbox_vector_id; +/* Maximum number of allocated vectors for the device */ +__le16 num_allocated_vectors; + +/* Maximum number of queues that can be supported */ +__le16 max_rx_q; +__le16 max_tx_q; +__le16 max_rx_bufq; +__le16 max_tx_complq; + +/* The PF sends the maximum VFs it is requesting. The CP responds with +* the maximum VFs granted. +*/ +__le16 max_sriov_vfs; + +/* Maximum number of vports that can be supported */ +__le16 max_vports; +/* Default number of vports driver should allocate on load */ +__le16 default_num_vports; + +/* Max header length hardware can parse/checksum, in bytes */ +__le16 max_tx_hdr_size; + +/* Max number of scatter gather buffers that can be sent per transmit +* packet without needing to be linearized. +*/ +u8 max_sg_bufs_per_tx_pkt; + +u8 pad[3 ]; + +u8 reserved[4 ]; +/* See VIRTCHNL2_DEVICE_TYPE definitions */ +__le32 device_type; + +/* Min packet length supported by device for single segment offload */ +u8 min_sso_packet_len; +/* Max number of header buffers that can be used for an LSO */ +u8 max_hdr_buf_per_lso; + +u8 pad1[10 ]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (80 , virtchnl2_get_capabilities); + +struct virtchnl2_queue_reg_chunk { +/* See VIRTCHNL2_QUEUE_TYPE definitions */ +__le32 type; +__le32 start_queue_id; +__le32 num_queues; +__le32 pad; + +/* Queue tail register offset and spacing provided by CP */ +__le64 qtail_reg_start; +__le32 qtail_reg_spacing; + +u8 pad1[4 ]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (32 , virtchnl2_queue_reg_chunk); + +/* Structure to specify several chunks of contiguous queues */ +struct virtchnl2_queue_reg_chunks { +__le16 num_chunks; +u8 pad[6 ]; + +struct virtchnl2_queue_reg_chunk chunks[]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (8 , virtchnl2_queue_reg_chunks); + +/* VIRTCHNL2_OP_CREATE_VPORT +* PF sends this message to CP to create a vport by filling in required +* fields of virtchnl2_create_vport structure. +* CP responds with the updated virtchnl2_create_vport structure containing the +* necessary fields followed by chunks which in turn will have an array of +* num_chunks entries of virtchnl2_queue_chunk structures. +*/ +struct virtchnl2_create_vport { +/* PF/VF populates the following fields on request */ +/* See VIRTCHNL2_VPORT_TYPE definitions */ +__le16 vport_type; + +/* See VIRTCHNL2_QUEUE_MODEL definitions */ +__le16 txq_model; + +/* See VIRTCHNL2_QUEUE_MODEL definitions */ +__le16 rxq_model; +__le16 num_tx_q; +/* Valid only if txq_model is split queue */ +__le16 num_tx_complq; +__le16 num_rx_q; +/* Valid only if rxq_model is split queue */ +__le16 num_rx_bufq; +/* Relative receive queue index to be used as default */ +__le16 default_rx_q; +/* Used to align PF and CP in case of default multiple vports, it is +* filled by the PF and CP returns the same value, to enable the driver +* to support multiple asynchronous parallel CREATE_VPORT requests and +* associate a response to a specific request. +*/ +__le16 vport_index; + +/* CP populates the following fields on response */ +__le16 max_mtu; +__le32 vport_id; +u8 default_mac_addr[ETH_ALEN ]; +__le16 pad; +/* See VIRTCHNL2_RX_DESC_IDS definitions */ +__le64 rx_desc_ids; +/* See VIRTCHNL2_TX_DESC_IDS definitions */ +__le64 tx_desc_ids; + +u8 pad1[72 ]; + +/* See VIRTCHNL2_RSS_ALGORITHM definitions */ +__le32 rss_algorithm; +__le16 rss_key_size; +__le16 rss_lut_size; + +/* See VIRTCHNL2_HEADER_SPLIT_CAPS definitions */ +__le32 rx_split_pos; + +u8 pad2[20 ]; + +struct virtchnl2_queue_reg_chunks chunks; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (160 , virtchnl2_create_vport); + +/* VIRTCHNL2_OP_DESTROY_VPORT +* VIRTCHNL2_OP_ENABLE_VPORT +* VIRTCHNL2_OP_DISABLE_VPORT +* PF sends this message to CP to destroy, enable or disable a vport by filling +* in the vport_id in virtchnl2_vport structure. +* CP responds with the status of the requested operation. +*/ +struct virtchnl2_vport { +__le32 vport_id; +u8 pad[4 ]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (8 , virtchnl2_vport); + +/* Transmit queue config info */ +struct virtchnl2_txq_info { +__le64 dma_ring_addr; + +/* See VIRTCHNL2_QUEUE_TYPE definitions */ +__le32 type; + +__le32 queue_id; +/* Valid only if queue model is split and type is trasmit queue. Used +* in many to one mapping of transmit queues to completion queue. +*/ +__le16 relative_queue_id; + +/* See VIRTCHNL2_QUEUE_MODEL definitions */ +__le16 model; + +/* See VIRTCHNL2_TXQ_SCHED_MODE definitions */ +__le16 sched_mode; + +/* See VIRTCHNL2_TXQ_FLAGS definitions */ +__le16 qflags; +__le16 ring_len; + +/* Valid only if queue model is split and type is transmit queue */ +__le16 tx_compl_queue_id; +/* Valid only if queue type is VIRTCHNL2_QUEUE_TYPE_MAILBOX_TX */ +/* See VIRTCHNL2_PEER_TYPE definitions */ +__le16 peer_type; +/* Valid only if queue type is CONFIG_TX and used to deliver messages +* for the respective CONFIG_TX queue. +*/ +__le16 peer_rx_queue_id; + +u8 pad[4 ]; + +/* Egress pasid is used for SIOV use case */ +__le32 egress_pasid; +__le32 egress_hdr_pasid; +__le32 egress_buf_pasid; + +u8 pad1[8 ]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (56 , virtchnl2_txq_info); + +/* VIRTCHNL2_OP_CONFIG_TX_QUEUES +* PF sends this message to set up parameters for one or more transmit queues. +* This message contains an array of num_qinfo instances of virtchnl2_txq_info +* structures. CP configures requested queues and returns a status code. If +* num_qinfo specified is greater than the number of queues associated with the +* vport, an error is returned and no queues are configured. +*/ +struct virtchnl2_config_tx_queues { +__le32 vport_id; + +__le16 num_qinfo; +u8 pad[10 ]; + +struct virtchnl2_txq_info qinfo[]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (16 , virtchnl2_config_tx_queues); + +/* Receive queue config info */ +struct virtchnl2_rxq_info { +/* See VIRTCHNL2_RX_DESC_IDS definitions */ +__le64 desc_ids; +__le64 dma_ring_addr; + +/* See VIRTCHNL2_QUEUE_TYPE definitions */ +__le32 type; +__le32 queue_id; + +/* See QUEUE_MODEL definitions */ +__le16 model; + +__le16 hdr_buffer_size; +__le32 data_buffer_size; +__le32 max_pkt_size; + +__le16 ring_len; +u8 buffer_notif_stride; +u8 pad; + +/* Applicable only for receive buffer queues */ +__le64 dma_head_wb_addr; + +/* Applicable only for receive completion queues */ +/* See VIRTCHNL2_RXQ_FLAGS definitions */ +__le16 qflags; + +__le16 rx_buffer_low_watermark; + +/* Valid only in split queue model */ +__le16 rx_bufq1_id; +/* Valid only in split queue model */ +__le16 rx_bufq2_id; +/* It indicates if there is a second buffer, rx_bufq2_id is valid only +* if this field is set. +*/ +u8 bufq2_ena; +u8 pad1[3 ]; + +/* Ingress pasid is used for SIOV use case */ +__le32 ingress_pasid; +__le32 ingress_hdr_pasid; +__le32 ingress_buf_pasid; + +u8 pad2[16 ]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (88 , virtchnl2_rxq_info); + +/* VIRTCHNL2_OP_CONFIG_RX_QUEUES +* PF sends this message to set up parameters for one or more receive queues. +* This message contains an array of num_qinfo instances of virtchnl2_rxq_info +* structures. CP configures requested queues and returns a status code. +* If the number of queues specified is greater than the number of queues +* associated with the vport, an error is returned and no queues are configured. +*/ +struct virtchnl2_config_rx_queues { +__le32 vport_id; + +__le16 num_qinfo; +u8 pad[18 ]; + +struct virtchnl2_rxq_info qinfo[]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (24 , virtchnl2_config_rx_queues); + +/* VIRTCHNL2_OP_ADD_QUEUES +* PF sends this message to request additional transmit/receive queues beyond +* the ones that were assigned via CREATE_VPORT request. virtchnl2_add_queues +* structure is used to specify the number of each type of queues. +* CP responds with the same structure with the actual number of queues assigned +* followed by num_chunks of virtchnl2_queue_chunk structures. +*/ +struct virtchnl2_add_queues { +__le32 vport_id; + +__le16 num_tx_q; +__le16 num_tx_complq; +__le16 num_rx_q; +__le16 num_rx_bufq; +u8 pad[4 ]; + +struct virtchnl2_queue_reg_chunks chunks; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (24 , virtchnl2_add_queues); + +/* Structure to specify a chunk of contiguous interrupt vectors */ +struct virtchnl2_vector_chunk { +__le16 start_vector_id; +__le16 start_evv_id; +__le16 num_vectors; +__le16 pad; + +/* Register offsets and spacing provided by CP. +* Dynamic control registers are used for enabling/disabling/re-enabling +* interrupts and updating interrupt rates in the hotpath. Any changes +* to interrupt rates in the dynamic control registers will be reflected +* in the interrupt throttling rate registers. +* itrn registers are used to update interrupt rates for specific +* interrupt indices without modifying the state of the interrupt. +*/ +__le32 dynctl_reg_start; +/* Register spacing between dynctl registers of 2 consecutive vectors */ +__le32 dynctl_reg_spacing; + +__le32 itrn_reg_start; +/* Register spacing between itrn registers of 2 consecutive vectors */ +__le32 itrn_reg_spacing; +/* Register spacing between itrn registers of the same vector +* where n=0..2. +*/ +__le32 itrn_index_spacing; +u8 pad1[4 ]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (32 , virtchnl2_vector_chunk); + +/* VIRTCHNL2_OP_DEALLOC_VECTORS +* PF sends virtchnl2_vector_chunks struct to specify the vectors it is giving +* away. CP performs requested action and returns status. +*/ +struct virtchnl2_vector_chunks { +__le16 num_vchunks; +u8 pad[14 ]; + +struct virtchnl2_vector_chunk vchunks[]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (16 , virtchnl2_vector_chunks); + +/* VIRTCHNL2_OP_ALLOC_VECTORS +* PF sends this message to request additional interrupt vectors beyond the +* ones that were assigned via GET_CAPS request. virtchnl2_alloc_vectors +* structure is used to specify the number of vectors requested. CP responds +* with the same structure with the actual number of vectors assigned followed +* by virtchnl2_vector_chunks structure identifying the vector ids. +*/ +struct virtchnl2_alloc_vectors { +__le16 num_vectors; +u8 pad[14 ]; + +struct virtchnl2_vector_chunks vchunks; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (32 , virtchnl2_alloc_vectors); + +/* VIRTCHNL2_OP_GET_RSS_LUT +* VIRTCHNL2_OP_SET_RSS_LUT +* PF sends this message to get or set RSS lookup table. Only supported if +* both PF and CP drivers set the VIRTCHNL2_CAP_RSS bit during configuration +* negotiation. Uses the virtchnl2_rss_lut structure. +*/ +struct virtchnl2_rss_lut { +__le32 vport_id; + +__le16 lut_entries_start; +__le16 lut_entries; +u8 pad[4 ]; + +/* RSS lookup table */ +__le32 lut[]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (12 , virtchnl2_rss_lut); + +/* VIRTCHNL2_OP_GET_RSS_HASH +* VIRTCHNL2_OP_SET_RSS_HASH +* PF sends these messages to get and set the hash filter enable bits for RSS. +* By default, the CP sets these to all possible traffic types that the +* hardware supports. The PF can query this value if it wants to change the +* traffic types that are hashed by the hardware. +* Only supported if both PF and CP drivers set the VIRTCHNL2_CAP_RSS bit +* during configuration negotiation. +*/ +struct virtchnl2_rss_hash { +/* Packet Type Groups bitmap */ +__le64 ptype_groups; + +__le32 vport_id; +u8 pad[4 ]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (16 , virtchnl2_rss_hash); + +/* VIRTCHNL2_OP_SET_SRIOV_VFS +* This message is used to set number of SRIOV VFs to be created. The actual +* allocation of resources for the VFs in terms of vport, queues and interrupts +* is done by CP. When this call completes, the APF driver calls +* pci_enable_sriov to let the OS instantiate the SRIOV PCIE devices. +* The number of VFs set to 0 will destroy all the VFs of this function. +*/ +struct virtchnl2_sriov_vfs_info { +__le16 num_vfs; +__le16 pad; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (4 , virtchnl2_sriov_vfs_info); + +/* Based on the descriptor type the PF supports, CP fills ptype_id_10 or +* ptype_id_8 for flex and base descriptor respectively. If ptype_id_10 value +* is set to 0xFFFF, PF should consider this ptype as dummy one and it is the +* last ptype. +*/ +struct virtchnl2_ptype { +__le16 ptype_id_10; +u8 ptype_id_8; + +/* Number of protocol ids the packet supports, maximum of 32 +* protocol ids are supported. +*/ +u8 proto_id_count; +__le16 pad; + +/* Proto_id_count decides the allocation of protocol id array */ +/* See VIRTCHNL2_PROTO_HDR_TYPE */ +__le16 proto_id[]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (6 , virtchnl2_ptype); + +/* VIRTCHNL2_OP_GET_PTYPE_INFO +* The total number of supported packet types is based on the descriptor type. +* For the flex descriptor, it is 1024 (10-bit ptype), and for the base +* descriptor, it is 256 (8-bit ptype). Send this message to the CP by +* populating the 'start_ptype_id' and the 'num_ptypes'. CP responds with the +* 'start_ptype_id', 'num_ptypes', and the array of ptype (virtchnl2_ptype) that +* are added at the end of the 'virtchnl2_get_ptype_info' message (Note: There +* is no specific field for the ptypes but are added at the end of the +* ptype info message. PF/VF is expected to extract the ptypes accordingly). +* +* If all the ptypes don't fit into one mailbox buffer, CP splits the +* ptype info into multiple messages, where each message will have its own +* 'start_ptype_id', 'num_ptypes', and the ptype array itself. When CP is done +* updating all the ptype information extracted from the package (the number of +* ptypes extracted might be less than what PF/VF expects), it will append a +* dummy ptype (which has 'ptype_id_10' of 'struct virtchnl2_ptype' as 0xFFFF) +* to the ptype array. +* +* PF/VF is expected to receive multiple VIRTCHNL2_OP_GET_PTYPE_INFO messages. +*/ +struct virtchnl2_get_ptype_info { +__le16 start_ptype_id; +__le16 num_ptypes; +__le32 pad; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (8 , virtchnl2_get_ptype_info); + +/* VIRTCHNL2_OP_GET_STATS +* PF/VF sends this message to CP to get the update stats by specifying the +* vport_id. CP responds with stats in struct virtchnl2_vport_stats. +*/ +struct virtchnl2_vport_stats { +__le32 vport_id; +u8 pad[4 ]; + +__le64 rx_bytes;/* received bytes */ +__le64 rx_unicast;/* received unicast pkts */ +__le64 rx_multicast;/* received multicast pkts */ +__le64 rx_broadcast;/* received broadcast pkts */ +__le64 rx_discards; +__le64 rx_errors; +__le64 rx_unknown_protocol; +__le64 tx_bytes;/* transmitted bytes */ +__le64 tx_unicast;/* transmitted unicast pkts */ +__le64 tx_multicast;/* transmitted multicast pkts */ +__le64 tx_broadcast;/* transmitted broadcast pkts */ +__le64 tx_discards; +__le64 tx_errors; +__le64 rx_invalid_frame_length; +__le64 rx_overflow_drop; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (128 , virtchnl2_vport_stats); + +/* VIRTCHNL2_OP_EVENT +* CP sends this message to inform the PF/VF driver of events that may affect +* it. No direct response is expected from the driver, though it may generate +* other messages in response to this one. +*/ +struct virtchnl2_event { +/* See VIRTCHNL2_EVENT_CODES definitions */ +__le32 event; + +/* Link_speed provided in Mbps */ +__le32 link_speed; + +__le32 vport_id; + +u8 link_status; +u8 pad; + +__le16 reserved; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (16 , virtchnl2_event); + +/* VIRTCHNL2_OP_GET_RSS_KEY +* VIRTCHNL2_OP_SET_RSS_KEY +* PF/VF sends this message to get or set RSS key. Only supported if both +* PF/VF and CP drivers set the VIRTCHNL2_CAP_RSS bit during configuration +* negotiation. Uses the virtchnl2_rss_key structure +*/ +struct virtchnl2_rss_key { +__le32 vport_id; + +__le16 key_len; +u8 pad; + +/* RSS hash key, packed bytes */ +union { +u8 key[1 ]; + __DECLARE_FLEX_ARRAY(u8, key_flex); + }; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (8 , virtchnl2_rss_key); + +/* structure to specify a chunk of contiguous queues */ +struct virtchnl2_queue_chunk { +/* See VIRTCHNL2_QUEUE_TYPE definitions */ +__le32 type; +__le32 start_queue_id; +__le32 num_queues; +u8 pad[4 ]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (16 , virtchnl2_queue_chunk); + +/* Structure to specify several chunks of contiguous queues */ +struct virtchnl2_queue_chunks { +__le16 num_chunks; +u8 pad[6 ]; + +struct virtchnl2_queue_chunk chunks[]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (8 , virtchnl2_queue_chunks); + +/* VIRTCHNL2_OP_ENABLE_QUEUES +* VIRTCHNL2_OP_DISABLE_QUEUES +* VIRTCHNL2_OP_DEL_QUEUES +* +* PF sends these messages to enable, disable or delete queues specified in +* chunks. PF sends virtchnl2_del_ena_dis_queues struct to specify the queues +* to be enabled/disabled/deleted. Also applicable to single queue receive or +* transmit. CP performs requested action and returns status. +*/ +struct virtchnl2_del_ena_dis_queues { +__le32 vport_id; +u8 pad[4 ]; + +struct virtchnl2_queue_chunks chunks; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (16 , virtchnl2_del_ena_dis_queues); + +/* Queue to vector mapping */ +struct virtchnl2_queue_vector { +__le32 queue_id; +__le16 vector_id; +u8 pad[2 ]; + +/* See VIRTCHNL2_ITR_IDX definitions */ +__le32 itr_idx; + +/* See VIRTCHNL2_QUEUE_TYPE definitions */ +__le32 queue_type; +u8 pad1[8 ]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (24 , virtchnl2_queue_vector); + +/* VIRTCHNL2_OP_MAP_QUEUE_VECTOR +* VIRTCHNL2_OP_UNMAP_QUEUE_VECTOR +* +* PF sends this message to map or unmap queues to vectors and interrupt +* throttling rate index registers. External data buffer contains +* virtchnl2_queue_vector_maps structure that contains num_qv_maps of +* virtchnl2_queue_vector structures. CP maps the requested queue vector maps +* after validating the queue and vector ids and returns a status code. +*/ +struct virtchnl2_queue_vector_maps { +__le32 vport_id; + +__le16 num_qv_maps; +u8 pad[10 ]; + +struct virtchnl2_queue_vector qv_maps[]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (16 , virtchnl2_queue_vector_maps); + +/* VIRTCHNL2_OP_LOOPBACK +* +* PF/VF sends this message to transition to/from the loopback state. Setting +* the 'enable' to 1 enables the loopback state and setting 'enable' to 0 +* disables it. CP configures the state to loopback and returns status. +*/ +struct virtchnl2_loopback { +__le32 vport_id; + +u8 enable; +u8 pad[3 ]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (8 , virtchnl2_loopback); + +/* Structure to specify each MAC address */ +struct virtchnl2_mac_addr { +u8 addr[ETH_ALEN ]; +/* See VIRTCHNL2_MAC_TYPE definitions */ +u8 type; +u8 pad; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (8 , virtchnl2_mac_addr); + +/* VIRTCHNL2_OP_ADD_MAC_ADDR +* VIRTCHNL2_OP_DEL_MAC_ADDR +* +* PF/VF driver uses this structure to send list of MAC addresses to be +* added/deleted to the CP where as CP performs the action and returns the +* status. +*/ +struct virtchnl2_mac_addr_list { +__le32 vport_id; + +__le16 num_mac_addr; +u8 pad[2 ]; + +struct virtchnl2_mac_addr mac_addr_list[]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (8 , virtchnl2_mac_addr_list); + +/* VIRTCHNL2_OP_CONFIG_PROMISCUOUS_MODE +* +* PF/VF sends vport id and flags to the CP where as CP performs the action +* and returns the status. +*/ +struct virtchnl2_promisc_info { +__le32 vport_id; + +/* See VIRTCHNL2_PROMISC_FLAGS definitions */ +__le16 flags; +u8 pad[2 ]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (8 , virtchnl2_promisc_info); + +#endif /* _VIRTCHNL_2_H_ */
drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h new file +644 -0
644 lines not on this page · raw message
Signature · 1 line
2.37.3
PATCH 3/15 idpf: add controlq init and reset checks
In reply to Pavan Kumar LingaFrom: Joshua Hay <[email protected]>
At the end of the probe, initialize and schedule the event workqueue. It calls the hard reset function where reset checks are done to find if the device is out of the reset. Control queue initialization and the necessary control queue support is added.
Introduce function pointers for the register operations which are different between PF and VF devices.
--- drivers/net/ethernet/intel/idpf/Makefile | 7 +- drivers/net/ethernet/intel/idpf/idpf.h | 89 +++ .../net/ethernet/intel/idpf/idpf_controlq.c | 644 ++++++++++++++++++ .../net/ethernet/intel/idpf/idpf_controlq.h | 117 ++++ .../ethernet/intel/idpf/idpf_controlq_api.h | 190 ++++++ .../ethernet/intel/idpf/idpf_controlq_setup.c | 175 +++++ drivers/net/ethernet/intel/idpf/idpf_dev.c | 103 +++ drivers/net/ethernet/intel/idpf/idpf_devids.h | 10 + .../ethernet/intel/idpf/idpf_lan_pf_regs.h | 70 ++ .../ethernet/intel/idpf/idpf_lan_vf_regs.h | 65 ++ drivers/net/ethernet/intel/idpf/idpf_lib.c | 176 +++++ drivers/net/ethernet/intel/idpf/idpf_main.c | 12 +- drivers/net/ethernet/intel/idpf/idpf_mem.h | 20 + drivers/net/ethernet/intel/idpf/idpf_vf_dev.c | 100 +++ .../net/ethernet/intel/idpf/idpf_virtchnl.c | 128 ++++ 15 files changed, 1904 insertions(+), 2 deletions(-) create mode 100644 drivers/net/ethernet/intel/idpf/idpf_controlq.c create mode 100644 drivers/net/ethernet/intel/idpf/idpf_controlq_api.h create mode 100644 drivers/net/ethernet/intel/idpf/idpf_controlq_setup.c create mode 100644 drivers/net/ethernet/intel/idpf/idpf_dev.c create mode 100644 drivers/net/ethernet/intel/idpf/idpf_devids.h create mode 100644 drivers/net/ethernet/intel/idpf/idpf_lan_pf_regs.h create mode 100644 drivers/net/ethernet/intel/idpf/idpf_lan_vf_regs.h create mode 100644 drivers/net/ethernet/intel/idpf/idpf_mem.h create mode 100644 drivers/net/ethernet/intel/idpf/idpf_vf_dev.c create mode 100644 drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
drivers/net/ethernet/intel/idpf/Makefile +6 -1
@@ -6,5 +6,10 @@ obj-$(CONFIG_IDPF) += idpf.o idpf-y := \ + idpf_controlq.o \ + idpf_controlq_setup.o \ + idpf_dev.o \ idpf_lib.o \ - idpf_main.o + idpf_main.o \ + idpf_virtchnl.o \ + idpf_vf_dev.o
drivers/net/ethernet/intel/idpf/idpf.h +89 -0
113 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_controlq.c new file +644 -0
644 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_controlq.h +117 -0
128 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_controlq_api.h new file +190 -0
190 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_controlq_setup.c new file +175 -0
175 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_dev.c new file +103 -0
103 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_devids.h new file +10 -0
@@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright (C) 2023 Intel Corporation */ + +#ifndef _IDPF_DEVIDS_H_ +#define _IDPF_DEVIDS_H_ + +#define IDPF_DEV_ID_PF 0x1452 +#define IDPF_DEV_ID_VF 0x145C + +#endif /* _IDPF_DEVIDS_H_ */
drivers/net/ethernet/intel/idpf/idpf_lan_pf_regs.h new file +70 -0
70 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_lan_vf_regs.h new file +65 -0
65 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_lib.c +176 -0
202 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_main.c +11 -1
@@ -2,6 +2,7 @@/* Copyright (C) 2023 Intel Corporation */ #include "idpf.h" +#include "idpf_devids.h" #define DRV_SUMMARY "Infrastructure Data Path Function Linux Driver"
@@ -50,7 +51,16 @@ static int idpf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)if (!adapter)return -ENOMEM ; -return idpf_probe_common (pdev, adapter); +if (ent->device ==IDPF_DEV_ID_PF ) +return idpf_pf_probe (pdev, adapter); +if (ent->device ==IDPF_DEV_ID_VF ) +return idpf_vf_probe (pdev, adapter); + +dev_err (&pdev->dev,"Unexpected dev ID 0x%x in idpf probe\n" , + ent->device); + +return -EINVAL ; + }/* idpf_pci_tbl - PCI Dev idpf ID Table
drivers/net/ethernet/intel/idpf/idpf_mem.h new file +20 -0
@@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright (C) 2023 Intel Corporation */ + +#ifndef _IDPF_MEM_H_ +#define _IDPF_MEM_H_ + +#include <linux/io.h> + +struct idpf_dma_mem { +void *va; +dma_addr_t pa; +size_t size; +}; + +#define wr32 (a, reg, value) writel((value), ((a)->hw_addr + (reg))) +#define rd32 (a, reg) readl((a)->hw_addr + (reg)) +#define wr64 (a, reg, value) writeq((value), ((a)->hw_addr + (reg))) +#define rd64 (a, reg) readq((a)->hw_addr + (reg)) + +#endif /* _IDPF_MEM_H_ */
drivers/net/ethernet/intel/idpf/idpf_vf_dev.c new file +100 -0
100 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c new file +128 -0
128 lines not on this page · raw message
Signature · 1 line
2.37.3
PATCH 4/15 idpf: add core init and interrupt request
In reply to Pavan Kumar LingaAs the mailbox is setup, add the necessary send and receive mailbox message framework to support the virtchnl communication between the driver and device Control Plane (CP).
Add the core initialization. To start with, driver confirms the virtchnl version with the CP. Once that is done, it requests and gets the required capabilities and resources needed such as max vectors, queues etc.
Based on the vector information received in 'VIRTCHNL2_OP_GET_CAPS', request the stack to allocate the required vectors. Finally add the interrupt handling mechanism for the mailbox queue and enable the interrupt.
Note: Checkpatch issues a warning about IDPF_FOREACH_VPORT_VC_STATE and IDPF_GEN_STRING being complex macros and should be enclosed in parentheses but it's not the case. They are never used as a statement and instead only used to define the enum and array.
--- drivers/net/ethernet/intel/idpf/idpf.h | 136 ++- drivers/net/ethernet/intel/idpf/idpf_dev.c | 17 + .../ethernet/intel/idpf/idpf_lan_pf_regs.h | 43 + .../ethernet/intel/idpf/idpf_lan_vf_regs.h | 38 + drivers/net/ethernet/intel/idpf/idpf_lib.c | 359 ++++++++ drivers/net/ethernet/intel/idpf/idpf_txrx.h | 26 + drivers/net/ethernet/intel/idpf/idpf_vf_dev.c | 22 +- .../net/ethernet/intel/idpf/idpf_virtchnl.c | 802 ++++++++++++++++++ 8 files changed, 1441 insertions(+), 2 deletions(-) create mode 100644 drivers/net/ethernet/intel/idpf/idpf_txrx.h
drivers/net/ethernet/intel/idpf/idpf.h +135 -1
@@ -11,6 +11,8 @@ struct idpf_adapter;#include <linux/etherdevice.h> #include <linux/pci.h> +#include "virtchnl2.h" +#include "idpf_txrx.h" #include "idpf_controlq.h" /* Default Mailbox settings */
@@ -18,12 +20,24 @@ struct idpf_adapter;#define IDPF_NUM_DFLT_MBX_Q 2/* includes both TX and RX */ #define IDPF_DFLT_MBX_Q_LEN 64#define IDPF_DFLT_MBX_ID -1 +/* maximum number of times to try before resetting mailbox */ +#define IDPF_MB_MAX_ERR 20 +#define IDPF_WAIT_FOR_EVENT_TIMEO_MIN 2000 +#define IDPF_WAIT_FOR_EVENT_TIMEO 60000 + +#define IDPF_MAX_WAIT 500/* available message levels */ #define IDPF_AVAIL_NETIF_M (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK) +#define IDPF_VIRTCHNL_VERSION_MAJOR VIRTCHNL2_VERSION_MAJOR_2 +#define IDPF_VIRTCHNL_VERSION_MINOR VIRTCHNL2_VERSION_MINOR_0 +enum idpf_state { __IDPF_STARTUP, + __IDPF_VER_CHECK, + __IDPF_GET_CAPS, + __IDPF_INIT_SW, __IDPF_STATE_LAST/* this member MUST be last */ };
@@ -37,6 +51,16 @@ enum idpf_flags { __IDPF_HR_DRV_LOAD,/* Reset in progress */ __IDPF_HR_RESET_IN_PROG, +/* Resources release in progress*/ + __IDPF_REL_RES_IN_PROG, +/* Generic bits to share a message */ +/* Mailbox interrupt event */ + __IDPF_MB_INTR_MODE, + __IDPF_MB_INTR_TRIGGER, +/* Virtchnl message buffer received needs to be processed */ + __IDPF_VC_MSG_PENDING, +/* Do not schedule service task if bit is set */ + __IDPF_CANCEL_SERVICE_TASK,/* Driver remove in progress */ __IDPF_REMOVE_IN_PROG,/* must be last */
@@ -53,6 +77,7 @@ struct idpf_reset_reg {/* product specific register API */ struct idpf_reg_ops {void (*ctlq_reg_init)(struct idpf_ctlq_create_info *cq); +void (*mb_intr_reg_init)(struct idpf_adapter *adapter);void (*reset_reg_init)(struct idpf_adapter *adapter);void (*trigger_reset)(struct idpf_adapter *adapter,enum idpf_flags trig_cause);
@@ -62,22 +87,104 @@ struct idpf_dev_ops {struct idpf_reg_ops reg_ops; }; +/* These macros allow us to generate an enum and a matching char * array of +* stringified enums that are always in sync. Checkpatch issues a bogus warning +* about this being a complex macro; but it's wrong, these are never used as a +* statement and instead only used to define the enum and array. +*/ +#define IDPF_FOREACH_VPORT_VC_STATE (STATE ) \ + STATE(IDPF_VC_ALLOC_VECTORS) \ + STATE(IDPF_VC_ALLOC_VECTORS_ERR) \ + STATE(IDPF_VC_DEALLOC_VECTORS) \ + STATE(IDPF_VC_DEALLOC_VECTORS_ERR) \ + STATE(IDPF_VC_NBITS) + +#define IDPF_GEN_ENUM (ENUM ) ENUM, +#define IDPF_GEN_STRING (STRING ) #STRING, + +enum idpf_vport_vc_state { + IDPF_FOREACH_VPORT_VC_STATE(IDPF_GEN_ENUM) +}; + +extern const char *const idpf_vport_vc_state_str[]; + +struct idpf_vport { +u32 vport_id; +}; + +/* Stack to maintain vector indexes used for 'vector distribution' algorithm */ +struct idpf_vector_lifo { +/* Vector stack maintains all the relative vector indexes at the +* *adapter* level. This stack is divided into 2 parts, first one is +* called as 'default pool' and other one is called 'free pool'. +* Vector distribution algorithm gives priority to default vports in +* a way that at least IDPF_MIN_Q_VEC vectors are allocated per +* default vport and the relative vector indexes for those are +* maintained in default pool. Free pool contains all the unallocated +* vector indexes which can be allocated on-demand basis. +* Mailbox vector index is maitained in the default pool of the stack +*/ +u16 top;/* Points to stack top i.e. next available vector index */ +u16 base;/* Always points to start of the 'free pool' */ +u16 size;/* Total size of the vector stack */ +u16 *vec_idx;/* Array to store all the vector indexes */ +}; +struct idpf_adapter {struct pci_dev *pdev; +u32 virt_ver_maj; +u32 virt_ver_min; +u32 msg_enable; +u32 mb_wait_count;enum idpf_state state; DECLARE_BITMAP(flags, __IDPF_FLAGS_NBITS);struct idpf_reset_reg reset_reg;struct idpf_hw hw; - +u16 num_req_msix; +u16 num_avail_msix; +u16 num_msix_entries; +struct msix_entry *msix_entries; +struct virtchnl2_alloc_vectors *req_vec_chunks; +struct idpf_q_vector mb_vector; +/* Stack to store the msix vector indexes */ +struct idpf_vector_lifo vector_stack; +/* handler for hard interrupt for mailbox*/ +irqreturn_t (*irq_mb_handler)(int irq,void *data); + +struct delayed_work serv_task;/* delayed service task */ +struct workqueue_struct *serv_wq;struct delayed_work vc_event_task;/* delayed virtchannel event task */ struct workqueue_struct *vc_event_wq; +struct virtchnl2_get_capabilities caps; +wait_queue_head_t vchnl_wq; + DECLARE_BITMAP(vc_state, IDPF_VC_NBITS); +char vc_msg[IDPF_DFLT_MBX_BUF_SIZE ];struct idpf_dev_ops dev_ops;struct mutex reset_lock;/* lock to protect reset flows */ +struct mutex vector_lock;/* lock to protect vector distribution */ }; +/** +* idpf_get_reserved_vecs - Get reserved vectors +* @adapter: private data struct +*/ +static inline u16 idpf_get_reserved_vecs (struct idpf_adapter *adapter) +{ +return le16_to_cpu (adapter->caps.num_allocated_vectors); +} + +/** +* idpf_get_default_vports - Get default number of vports +* @adapter: private data struct +*/ +static inline u16 idpf_get_default_vports (struct idpf_adapter *adapter) +{ +return le16_to_cpu (adapter->caps.default_num_vports); +} +/** * idpf_get_reg_addr - Get BAR0 register address * @adapter: private data struct
@@ -106,11 +213,38 @@ static inline bool idpf_is_reset_detected(struct idpf_adapter *adapter) adapter->hw.arq->reg.len_ena_mask); } +/** +* idpf_is_reset_in_prog - check if reset is in progress +* @adapter: driver specific private structure +* +* Returns true if hard reset is in progress, false otherwise +*/ +static inline bool idpf_is_reset_in_prog (struct idpf_adapter *adapter) +{ +return (test_bit (__IDPF_HR_RESET_IN_PROG, adapter->flags) || +test_bit (__IDPF_HR_FUNC_RESET, adapter->flags) || +test_bit (__IDPF_HR_CORE_RESET, adapter->flags) || +test_bit (__IDPF_HR_DRV_LOAD, adapter->flags)); +} +int idpf_pf_probe (struct pci_dev *pdev,struct idpf_adapter *adapter);int idpf_vf_probe (struct pci_dev *pdev,struct idpf_adapter *adapter);int idpf_probe_common (struct pci_dev *pdev,struct idpf_adapter *adapter);void idpf_remove_common (struct pci_dev *pdev);int idpf_init_dflt_mbx (struct idpf_adapter *adapter);void idpf_deinit_dflt_mbx (struct idpf_adapter *adapter); +int idpf_vc_core_init (struct idpf_adapter *adapter); +void idpf_vc_core_deinit (struct idpf_adapter *adapter); +int idpf_intr_req (struct idpf_adapter *adapter); +void idpf_intr_rel (struct idpf_adapter *adapter); +int idpf_send_dealloc_vectors_msg (struct idpf_adapter *adapter); +int idpf_send_alloc_vectors_msg (struct idpf_adapter *adapter,u16 num_vectors); +int idpf_get_vec_ids (struct idpf_adapter *adapter, +u16 *vecids,int num_vecids, +struct virtchnl2_vector_chunks *chunks); +int idpf_recv_mb_msg (struct idpf_adapter *adapter,u32 op, +void *msg,int msg_size); +int idpf_send_mb_msg (struct idpf_adapter *adapter,u32 op, +u16 msg_size,u8 *msg);#endif /* !_IDPF_H_ */
drivers/net/ethernet/intel/idpf/idpf_dev.c +17 -0
@@ -44,6 +44,22 @@ static void idpf_ctlq_reg_init(struct idpf_ctlq_create_info *cq) } } +/** +* idpf_mb_intr_reg_init - Initialize mailbox interrupt register +* @adapter: adapter structure +*/ +static void idpf_mb_intr_reg_init (struct idpf_adapter *adapter) +{ +struct idpf_intr_reg *intr = &adapter->mb_vector.intr_reg; +u32 dyn_ctl =le32_to_cpu (adapter->caps.mailbox_dyn_ctl); + + intr->dyn_ctl =idpf_get_reg_addr (adapter, dyn_ctl); + intr->dyn_ctl_intena_m =PF_GLINT_DYN_CTL_INTENA_M ; + intr->dyn_ctl_itridx_m =PF_GLINT_DYN_CTL_ITR_INDX_M ; + intr->icr_ena =idpf_get_reg_addr (adapter,PF_INT_DIR_OICR_ENA ); + intr->icr_ena_ctlq_m =PF_INT_DIR_OICR_ENA_M ; +} +/** * idpf_reset_reg_init - Initialize reset registers * @adapter: Driver specific private structure
@@ -75,6 +91,7 @@ static void idpf_trigger_reset(struct idpf_adapter *adapter,static void idpf_reg_ops_init (struct idpf_adapter *adapter) { adapter->dev_ops.reg_ops.ctlq_reg_init = idpf_ctlq_reg_init; + adapter->dev_ops.reg_ops.mb_intr_reg_init = idpf_mb_intr_reg_init; adapter->dev_ops.reg_ops.reset_reg_init = idpf_reset_reg_init; adapter->dev_ops.reg_ops.trigger_reset = idpf_trigger_reset; }
drivers/net/ethernet/intel/idpf/idpf_lan_pf_regs.h +43 -0
49 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_lan_vf_regs.h +38 -0
@@ -62,4 +62,42 @@#define VF_QRXB_TAIL_BASE 0x00060000#define VF_QRXB_TAIL (_QRX) (VF_QRXB_TAIL_BASE + ((_QRX) * 4)) +/* Interrupts */ +#define VF_INT_DYN_CTL0 0x00005C00 +#define VF_INT_DYN_CTL0_INTENA_S 0 +#define VF_INT_DYN_CTL0_INTENA_M BIT(VF_INT_DYN_CTL0_INTENA_S) +#define VF_INT_DYN_CTL0_ITR_INDX_S 3 +#define VF_INT_DYN_CTL0_ITR_INDX_M GENMASK(4, 3) +#define VF_INT_DYN_CTLN (_INT) (0x00003800 + ((_INT) * 4)) +#define VF_INT_DYN_CTLN_EXT (_INT) (0x00070000 + ((_INT) * 4)) +#define VF_INT_DYN_CTLN_INTENA_S 0 +#define VF_INT_DYN_CTLN_INTENA_M BIT(VF_INT_DYN_CTLN_INTENA_S) +#define VF_INT_DYN_CTLN_CLEARPBA_S 1 +#define VF_INT_DYN_CTLN_CLEARPBA_M BIT(VF_INT_DYN_CTLN_CLEARPBA_S) +#define VF_INT_DYN_CTLN_SWINT_TRIG_S 2 +#define VF_INT_DYN_CTLN_SWINT_TRIG_M BIT(VF_INT_DYN_CTLN_SWINT_TRIG_S) +#define VF_INT_DYN_CTLN_ITR_INDX_S 3 +#define VF_INT_DYN_CTLN_ITR_INDX_M GENMASK(4, 3) +#define VF_INT_DYN_CTLN_INTERVAL_S 5 +#define VF_INT_DYN_CTLN_INTERVAL_M BIT(VF_INT_DYN_CTLN_INTERVAL_S) +#define VF_INT_DYN_CTLN_SW_ITR_INDX_ENA_S 24 +#define VF_INT_DYN_CTLN_SW_ITR_INDX_ENA_M BIT(VF_INT_DYN_CTLN_SW_ITR_INDX_ENA_S) +#define VF_INT_DYN_CTLN_SW_ITR_INDX_S 25 +#define VF_INT_DYN_CTLN_SW_ITR_INDX_M BIT(VF_INT_DYN_CTLN_SW_ITR_INDX_S) +#define VF_INT_DYN_CTLN_WB_ON_ITR_S 30 +#define VF_INT_DYN_CTLN_WB_ON_ITR_M BIT(VF_INT_DYN_CTLN_WB_ON_ITR_S) +#define VF_INT_DYN_CTLN_INTENA_MSK_S 31 +#define VF_INT_DYN_CTLN_INTENA_MSK_M BIT(VF_INT_DYN_CTLN_INTENA_MSK_S) + +#define VF_INT_ICR0_ENA1 0x00005000 +#define VF_INT_ICR0_ENA1_ADMINQ_S 30 +#define VF_INT_ICR0_ENA1_ADMINQ_M BIT(VF_INT_ICR0_ENA1_ADMINQ_S) +#define VF_INT_ICR0_ENA1_RSVD_S 31 +#define VF_INT_ICR01 0x00004800 +#define VF_QF_HENA (_i) (0x0000C400 + ((_i) * 4)) +#define VF_QF_HENA_MAX_INDX 1 +#define VF_QF_HKEY (_i) (0x0000CC00 + ((_i) * 4)) +#define VF_QF_HKEY_MAX_INDX 12 +#define VF_QF_HLUT (_i) (0x0000D000 + ((_i) * 4)) +#define VF_QF_HLUT_MAX_INDX 15#endif
drivers/net/ethernet/intel/idpf/idpf_lib.c +359 -0
417 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_txrx.h new file +26 -0
@@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright (C) 2023 Intel Corporation */ + +#ifndef _IDPF_TXRX_H_ +#define _IDPF_TXRX_H_ + +/* Default vector sharing */ +#define IDPF_MBX_Q_VEC 1 +#define IDPF_MIN_Q_VEC 1 + +#define IDPF_INT_NAME_STR_LEN (IFNAMSIZ + 16) + +struct idpf_intr_reg { +void __iomem *dyn_ctl; +u32 dyn_ctl_intena_m; +u32 dyn_ctl_itridx_m; +void __iomem *icr_ena; +u32 icr_ena_ctlq_m; +}; + +struct idpf_q_vector { +u16 v_idx;/* index in the vport->q_vector array */ +struct idpf_intr_reg intr_reg; +char name[IDPF_INT_NAME_STR_LEN ]; +}; +#endif /* !_IDPF_TXRX_H_ */
drivers/net/ethernet/intel/idpf/idpf_vf_dev.c +21 -1
@@ -44,6 +44,22 @@ static void idpf_vf_ctlq_reg_init(struct idpf_ctlq_create_info *cq) } } +/** +* idpf_vf_mb_intr_reg_init - Initialize the mailbox register +* @adapter: adapter structure +*/ +static void idpf_vf_mb_intr_reg_init (struct idpf_adapter *adapter) +{ +struct idpf_intr_reg *intr = &adapter->mb_vector.intr_reg; +u32 dyn_ctl =le32_to_cpu (adapter->caps.mailbox_dyn_ctl); + + intr->dyn_ctl =idpf_get_reg_addr (adapter, dyn_ctl); + intr->dyn_ctl_intena_m =VF_INT_DYN_CTL0_INTENA_M ; + intr->dyn_ctl_itridx_m =VF_INT_DYN_CTL0_ITR_INDX_M ; + intr->icr_ena =idpf_get_reg_addr (adapter,VF_INT_ICR0_ENA1 ); + intr->icr_ena_ctlq_m =VF_INT_ICR0_ENA1_ADMINQ_M ; +} +/** * idpf_vf_reset_reg_init - Initialize reset registers * @adapter: Driver specific private structure
@@ -62,7 +78,10 @@ static void idpf_vf_reset_reg_init(struct idpf_adapter *adapter)static void idpf_vf_trigger_reset (struct idpf_adapter *adapter,enum idpf_flags trig_cause) { -/* stub */ +/* Do not send VIRTCHNL2_OP_RESET_VF message on driver unload */ +if (trig_cause == __IDPF_HR_FUNC_RESET && + !test_bit (__IDPF_REMOVE_IN_PROG, adapter->flags)) +idpf_send_mb_msg (adapter,VIRTCHNL2_OP_RESET_VF ,0 ,NULL ); }/**
@@ -72,6 +91,7 @@ static void idpf_vf_trigger_reset(struct idpf_adapter *adapter,static void idpf_vf_reg_ops_init (struct idpf_adapter *adapter) { adapter->dev_ops.reg_ops.ctlq_reg_init = idpf_vf_ctlq_reg_init; + adapter->dev_ops.reg_ops.mb_intr_reg_init = idpf_vf_mb_intr_reg_init; adapter->dev_ops.reg_ops.reset_reg_init = idpf_vf_reset_reg_init; adapter->dev_ops.reg_ops.trigger_reset = idpf_vf_trigger_reset; }
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +802 -0
811 lines not on this page · raw message
Signature · 1 line
2.37.3
PATCH 5/15 idpf: add create vport and netdev configuration
In reply to Pavan Kumar LingaAdd the required support to create a vport by spawning the init task. Once the vport is created, initialize and allocate the resources needed for it. Configure and register a netdev for each vport with all the features supported by the device based on the capabilities received from the device Control Plane. Spawn the init task till all the default vports are created.
--- drivers/net/ethernet/intel/idpf/Makefile | 1 + drivers/net/ethernet/intel/idpf/idpf.h | 240 ++++++++ drivers/net/ethernet/intel/idpf/idpf_lib.c | 459 +++++++++++++++ drivers/net/ethernet/intel/idpf/idpf_main.c | 2 + drivers/net/ethernet/intel/idpf/idpf_txrx.c | 182 ++++++ drivers/net/ethernet/intel/idpf/idpf_txrx.h | 52 ++ .../net/ethernet/intel/idpf/idpf_virtchnl.c | 528 +++++++++++++++++- 7 files changed, 1452 insertions(+), 12 deletions(-) create mode 100644 drivers/net/ethernet/intel/idpf/idpf_txrx.c
drivers/net/ethernet/intel/idpf/Makefile +1 -0
@@ -11,5 +11,6 @@ idpf-y := \ idpf_dev.o \ idpf_lib.o \ idpf_main.o \ + idpf_txrx.o \ idpf_virtchnl.o \ idpf_vf_dev.o
drivers/net/ethernet/intel/idpf/idpf.h +240 -0
325 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_lib.c +459 -0
532 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_main.c +2 -0
@@ -51,6 +51,8 @@ static int idpf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)if (!adapter)return -ENOMEM ; +set_bit (__IDPF_REQ_TX_SPLITQ, adapter->flags); +set_bit (__IDPF_REQ_RX_SPLITQ, adapter->flags);if (ent->device ==IDPF_DEV_ID_PF )return idpf_pf_probe (pdev, adapter);if (ent->device ==IDPF_DEV_ID_VF )
drivers/net/ethernet/intel/idpf/idpf_txrx.c new file +182 -0
182 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_txrx.h +52 -0
66 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +516 -12
656 lines not on this page · raw message
Signature · 1 line
2.37.3
PATCH 6/15 idpf: continue expanding init task
In reply to Pavan Kumar LingaAdd the virtchnl support to request the packet types. Parse the responses received from CP and based on the protocol headers, populate the packet type structure with necessary information. Initialize the MAC address and add the virtchnl support to add and del MAC address.
--- drivers/net/ethernet/intel/idpf/idpf.h | 26 + drivers/net/ethernet/intel/idpf/idpf_lib.c | 184 ++++++- drivers/net/ethernet/intel/idpf/idpf_txrx.h | 104 ++++ .../net/ethernet/intel/idpf/idpf_virtchnl.c | 482 ++++++++++++++++++ 4 files changed, 791 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/idpf/idpf.h +26 -0
@@ -22,6 +22,7 @@ struct idpf_vport_max_q;/* Default Mailbox settings */ #define IDPF_DFLT_MBX_BUF_SIZE SZ_4K +#define IDPF_NUM_FILTERS_PER_MSG 20#define IDPF_NUM_DFLT_MBX_Q 2/* includes both TX and RX */ #define IDPF_DFLT_MBX_Q_LEN 64#define IDPF_DFLT_MBX_ID -1
@@ -38,6 +39,13 @@ struct idpf_vport_max_q;#define IDPF_VIRTCHNL_VERSION_MAJOR VIRTCHNL2_VERSION_MAJOR_2#define IDPF_VIRTCHNL_VERSION_MINOR VIRTCHNL2_VERSION_MINOR_0 +struct idpf_mac_filter { +struct list_head list; +u8 macaddr[ETH_ALEN ]; +bool remove;/* filter needs to be removed */ +bool add;/* filter needs to be added */ +}; +enum idpf_state { __IDPF_STARTUP, __IDPF_VER_CHECK,
@@ -140,6 +148,12 @@ struct idpf_dev_ops { STATE(IDPF_VC_ALLOC_VECTORS_ERR) \ STATE(IDPF_VC_DEALLOC_VECTORS) \ STATE(IDPF_VC_DEALLOC_VECTORS_ERR) \ + STATE(IDPF_VC_ADD_MAC_ADDR) \ + STATE(IDPF_VC_ADD_MAC_ADDR_ERR) \ + STATE(IDPF_VC_DEL_MAC_ADDR) \ + STATE(IDPF_VC_DEL_MAC_ADDR_ERR) \ + STATE(IDPF_VC_GET_PTYPE_INFO) \ + STATE(IDPF_VC_GET_PTYPE_INFO_ERR) \ STATE(IDPF_VC_NBITS) #define IDPF_GEN_ENUM(ENUM) ENUM,
@@ -154,6 +168,9 @@ extern const char * const idpf_vport_vc_state_str[];enum idpf_vport_flags {/* Virtchnl message buffer received needs to be processed */ __IDPF_VPORT_VC_MSG_PENDING, +/* Asynchronous add/del ether address in flight */ + __IDPF_VPORT_ADD_MAC_REQ, + __IDPF_VPORT_DEL_MAC_REQ, __IDPF_VPORT_FLAGS_NBITS, };
@@ -188,6 +205,7 @@ struct idpf_vport {u32 bufq_size[IDPF_MAX_BUFQS_PER_RXQ_GRP ];int num_rxq_grp;u32 rxq_model; +struct idpf_rx_ptype_decoded rx_ptype_lkup[IDPF_RX_MAX_PTYPE ];struct idpf_adapter *adapter;struct net_device *netdev;
@@ -196,6 +214,7 @@ struct idpf_vport {u32 vport_id;u16 idx;/* software index in adapter vports struct */ bool default_vport; +bool base_rxd;u16 max_mtu;u8 default_mac_addr[ETH_ALEN ];
@@ -210,6 +229,9 @@ struct idpf_vport {* the driver is in a namespace in a system that is being shutdown */ struct mutex stop_mutex; + +/* lock to protect mac filters */ +spinlock_t mac_filter_list_lock; };/* User defined configuration values for each vport */
@@ -218,6 +240,7 @@ struct idpf_vport_user_config_data {u32 num_req_rx_qs;/* user requested RX queues through ethtool */ u32 num_req_txq_desc;/* user requested TX queue descriptors through ethtool */ u32 num_req_rxq_desc;/* user requested RX queue descriptors through ethtool */ +struct list_head mac_filter_list; };enum idpf_vport_config_flags {
@@ -468,6 +491,7 @@ void idpf_vc_core_deinit(struct idpf_adapter *adapter);int idpf_intr_req (struct idpf_adapter *adapter);void idpf_intr_rel (struct idpf_adapter *adapter);int idpf_send_destroy_vport_msg (struct idpf_vport *vport); +int idpf_send_get_rx_ptype_msg (struct idpf_vport *vport);int idpf_send_dealloc_vectors_msg (struct idpf_adapter *adapter);int idpf_send_alloc_vectors_msg (struct idpf_adapter *adapter,u16 num_vectors);void idpf_deinit_task (struct idpf_adapter *adapter);
@@ -482,9 +506,11 @@ int idpf_vport_alloc_max_qs(struct idpf_adapter *adapter, struct idpf_vport_max_q *max_q);void idpf_vport_dealloc_max_qs (struct idpf_adapter *adapter,struct idpf_vport_max_q *max_q); +int idpf_add_del_mac_filters (struct idpf_vport *vport,bool add,bool async);void idpf_vport_init (struct idpf_vport *vport,struct idpf_vport_max_q *max_q);u32 idpf_get_vport_id (struct idpf_vport *vport);int idpf_send_create_vport_msg (struct idpf_adapter *adapter,struct idpf_vport_max_q *max_q); +int idpf_check_supported_desc_ids (struct idpf_vport *vport);#endif /* !_IDPF_H_ */
drivers/net/ethernet/intel/idpf/idpf_lib.c +179 -5
243 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_txrx.h +104 -0
118 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +482 -0
513 lines not on this page · raw message
Signature · 1 line
2.37.3
PATCH 7/15 idpf: configure resources for TX queues
In reply to Pavan Kumar LingaFrom: Alan Brady <[email protected]>
IDPF supports two queue models i.e. single queue which is a traditional queueing model as well as split queue model. In single queue model, the same descriptor queue is used by SW to post descriptors to the HW, HW to post completed descriptors to SW. In split queue model, "TX Queues" are used to pass buffers from SW to HW and "TX Completion Queues" are used to post descriptor completions from HW to SW. Device supports asymmetric ratio of TX queues to TX completion queues. Considering this, queue group mechanism is used i.e. some TX queues are grouped together which will be serviced by only one TX completion queue per TX queue group.
Add all the resources required for the TX queues initialization. To start with, allocate memory for the TX queue groups, TX queues and TX completion queues. Then, allocate the descriptors for both TX and TX completion queues, and bookkeeping buffers for TX queues alone. Also, allocate queue vectors for the vport and initialize the TX queue related fields for each queue vector.
Initialize the queue parameters such as q_id, q_type and tail register offset with the info received from the device control plane (CP). Once all the TX queues are configured, send config TX queue virtchnl message to the CP with all the TX queue context information.
--- drivers/net/ethernet/intel/idpf/idpf.h | 51 ++ .../net/ethernet/intel/idpf/idpf_lan_txrx.h | 25 + drivers/net/ethernet/intel/idpf/idpf_lib.c | 150 +++++ drivers/net/ethernet/intel/idpf/idpf_txrx.c | 553 ++++++++++++++++++ drivers/net/ethernet/intel/idpf/idpf_txrx.h | 166 ++++++ .../net/ethernet/intel/idpf/idpf_virtchnl.c | 392 +++++++++++++ 6 files changed, 1337 insertions(+) create mode 100644 drivers/net/ethernet/intel/idpf/idpf_lan_txrx.h
drivers/net/ethernet/intel/idpf/idpf.h +51 -0
@@ -15,9 +15,12 @@ struct idpf_vport_max_q;#include <linux/pci.h> #include "virtchnl2.h" +#include "idpf_lan_txrx.h" #include "idpf_txrx.h" #include "idpf_controlq.h" +#define GETMAXVAL (num_bits) GENMASK((num_bits) - 1, 0) +#define IDPF_NO_FREE_SLOT 0xffff/* Default Mailbox settings */
@@ -28,6 +31,8 @@ struct idpf_vport_max_q;#define IDPF_DFLT_MBX_ID -1/* maximum number of times to try before resetting mailbox */ #define IDPF_MB_MAX_ERR 20 +#define IDPF_NUM_CHUNKS_PER_MSG (struct_sz, chunk_sz) \ + ((IDPF_DFLT_MBX_BUF_SIZE - (struct_sz)) / (chunk_sz))#define IDPF_WAIT_FOR_EVENT_TIMEO_MIN 2000#define IDPF_WAIT_FOR_EVENT_TIMEO 60000
@@ -144,6 +149,8 @@ struct idpf_dev_ops { STATE(IDPF_VC_CREATE_VPORT_ERR) \ STATE(IDPF_VC_DESTROY_VPORT) \ STATE(IDPF_VC_DESTROY_VPORT_ERR) \ + STATE(IDPF_VC_CONFIG_TXQ) \ + STATE(IDPF_VC_CONFIG_TXQ_ERR) \ STATE(IDPF_VC_ALLOC_VECTORS) \ STATE(IDPF_VC_ALLOC_VECTORS_ERR) \ STATE(IDPF_VC_DEALLOC_VECTORS) \
@@ -194,7 +201,10 @@ struct idpf_vport {int txq_desc_count;int complq_desc_count;int num_txq_grp; +struct idpf_txq_group *txq_grps;u32 txq_model; +/* Used only in hotpath to get to the right queue very fast */ +struct idpf_queue **txqs;/* RX */ int num_rxq;
@@ -216,6 +226,8 @@ struct idpf_vport {bool default_vport;bool base_rxd; +u16 num_q_vectors; +struct idpf_q_vector *q_vectors;/* q vector array */ u16 max_mtu;u8 default_mac_addr[ETH_ALEN ];
@@ -285,6 +297,8 @@ struct idpf_vector_lifo {struct idpf_vport_config {struct idpf_vport_user_config_data user_config;struct idpf_vport_max_q max_q; +/* Stores the queue chunks received on VIRTCHNL2_OP_ADD_QUEUES */ +void *req_qs_chunks; DECLARE_BITMAP(flags, __IDPF_VPORT_CONFIG_FLAGS_NBITS); };
@@ -438,6 +452,26 @@ static inline u16 idpf_get_max_vports(struct idpf_adapter *adapter)return le16_to_cpu (adapter->caps.max_vports); } +/** +* idpf_get_max_tx_bufs - Get max scatter-gather buffers supported by the device +* @adapter: private data struct +*/ +static inline unsigned int idpf_get_max_tx_bufs (struct idpf_adapter *adapter) +{ +return adapter->caps.max_sg_bufs_per_tx_pkt; +} + +/** +* idpf_get_min_tx_pkt_len - Get min packet length supported by the device +* @adapter: private data struct +*/ +static inline u8 idpf_get_min_tx_pkt_len (struct idpf_adapter *adapter) +{ +u8 pkt_len = adapter->caps.min_sso_packet_len; + +return pkt_len ? pkt_len :IDPF_TX_MIN_LEN ; +} +/** * idpf_get_reg_addr - Get BAR0 register address * @adapter: private data struct
@@ -480,6 +514,20 @@ static inline bool idpf_is_reset_in_prog(struct idpf_adapter *adapter) test_bit(__IDPF_HR_DRV_LOAD, adapter->flags)); } +/** +* idpf_netdev_to_vport - get a vport handle from a netdev +* @netdev: network interface device structure +* +* It's possible for the vport to be NULL. Caller must check for a valid +* pointer. +*/ +static inline struct idpf_vport *idpf_netdev_to_vport (struct net_device *netdev) +{ +struct idpf_netdev_priv *np =netdev_priv (netdev); + +return np->vport; +} +int idpf_pf_probe (struct pci_dev *pdev,struct idpf_adapter *adapter);int idpf_vf_probe (struct pci_dev *pdev,struct idpf_adapter *adapter);int idpf_probe_common (struct pci_dev *pdev,struct idpf_adapter *adapter);
@@ -509,6 +557,9 @@ void idpf_vport_dealloc_max_qs(struct idpf_adapter *adapter,int idpf_add_del_mac_filters (struct idpf_vport *vport,bool add,bool async);void idpf_vport_init (struct idpf_vport *vport,struct idpf_vport_max_q *max_q);u32 idpf_get_vport_id (struct idpf_vport *vport); +int idpf_vport_queue_ids_init (struct idpf_vport *vport); +int idpf_queue_reg_init (struct idpf_vport *vport); +int idpf_send_config_tx_queues_msg (struct idpf_vport *vport);int idpf_send_create_vport_msg (struct idpf_adapter *adapter,struct idpf_vport_max_q *max_q);int idpf_check_supported_desc_ids (struct idpf_vport *vport);
drivers/net/ethernet/intel/idpf/idpf_lan_txrx.h new file +25 -0
@@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright (C) 2022 Intel Corporation */ + +#ifndef _IDPF_LAN_TXRX_H_ +#define _IDPF_LAN_TXRX_H_ + +/* Transmit descriptors */ +/* splitq tx buf, singleq tx buf and singleq compl desc */ +struct idpf_base_tx_desc { +__le64 buf_addr;/* Address of descriptor's data buf */ +__le64 qw1;/* type_cmd_offset_bsz_l2tag1 */ +};/* read used with buffer queues */ + +struct idpf_splitq_tx_compl_desc { +/* qid=[10:0] comptype=[13:11] rsvd=[14] gen=[15] */ +__le16 qid_comptype_gen; +union { +__le16 q_head;/* Queue head */ +__le16 compl_tag;/* Completion tag */ + } q_head_compl_tag; +u8 ts[3 ]; +u8 rsvd;/* Reserved */ +};/* writeback used with completion queues */ + +#endif /* _IDPF_LAN_TXRX_H_ */
drivers/net/ethernet/intel/idpf/idpf_lib.c +150 -0
195 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_txrx.c +553 -0
562 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_txrx.h +166 -0
200 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +392 -0
422 lines not on this page · raw message
Signature · 1 line
2.37.3
PATCH 8/15 idpf: configure resources for RX queues
In reply to Pavan Kumar LingaFrom: Alan Brady <[email protected]>
Similar to the TX, RX also supports both single and split queue models. In single queue model, the same descriptor queue is used by SW to post buffer descriptors to HW and by HW to post completed descriptors to SW. In split queue model, "RX buffer queues" are used to pass descriptor buffers from SW to HW whereas "RX queues" are used to post the descriptor completions i.e. descriptors that point to completed buffers, from HW to SW. "RX queue group" is a set of RX queues grouped together and will be serviced by a "RX buffer queue group". IDPF supports 2 buffer queues i.e. large buffer (4KB) queue and small buffer (2KB) queue per buffer queue group. HW uses large buffers for 'hardware gro' feature and also if the packet size is more than 2KB, if not 2KB buffers are used.
Add all the resources required for the RX queues initialization. Allocate memory for the RX queue and RX buffer queue groups. Initialize the software maintained refill queues for buffer management algorithm.
Same like the TX queues, initialize the queue parameters for the RX queues and send the config RX queue virtchnl message to the device Control Plane.
--- drivers/net/ethernet/intel/idpf/Makefile | 1 + drivers/net/ethernet/intel/idpf/idpf.h | 37 +- .../net/ethernet/intel/idpf/idpf_lan_txrx.h | 54 +- drivers/net/ethernet/intel/idpf/idpf_lib.c | 35 +- .../ethernet/intel/idpf/idpf_singleq_txrx.c | 60 ++ drivers/net/ethernet/intel/idpf/idpf_txrx.c | 907 +++++++++++++++++- drivers/net/ethernet/intel/idpf/idpf_txrx.h | 144 ++- .../net/ethernet/intel/idpf/idpf_virtchnl.c | 485 +++++++++- 8 files changed, 1709 insertions(+), 14 deletions(-) create mode 100644 drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c
drivers/net/ethernet/intel/idpf/Makefile +1 -0
@@ -11,6 +11,7 @@ idpf-y := \ idpf_dev.o \ idpf_lib.o \ idpf_main.o \ + idpf_singleq_txrx.o \ idpf_txrx.o \ idpf_virtchnl.o \ idpf_vf_dev.o
drivers/net/ethernet/intel/idpf/idpf.h +36 -1
@@ -151,10 +151,20 @@ struct idpf_dev_ops { STATE(IDPF_VC_DESTROY_VPORT_ERR) \ STATE(IDPF_VC_CONFIG_TXQ) \ STATE(IDPF_VC_CONFIG_TXQ_ERR) \ + STATE(IDPF_VC_CONFIG_RXQ) \ + STATE(IDPF_VC_CONFIG_RXQ_ERR) \ STATE(IDPF_VC_ALLOC_VECTORS) \ STATE(IDPF_VC_ALLOC_VECTORS_ERR) \ STATE(IDPF_VC_DEALLOC_VECTORS) \ STATE(IDPF_VC_DEALLOC_VECTORS_ERR) \ + STATE(IDPF_VC_GET_RSS_LUT) \ + STATE(IDPF_VC_GET_RSS_LUT_ERR) \ + STATE(IDPF_VC_SET_RSS_LUT) \ + STATE(IDPF_VC_SET_RSS_LUT_ERR) \ + STATE(IDPF_VC_GET_RSS_KEY) \ + STATE(IDPF_VC_GET_RSS_KEY_ERR) \ + STATE(IDPF_VC_SET_RSS_KEY) \ + STATE(IDPF_VC_SET_RSS_KEY_ERR) \ STATE(IDPF_VC_ADD_MAC_ADDR) \ STATE(IDPF_VC_ADD_MAC_ADDR_ERR) \ STATE(IDPF_VC_DEL_MAC_ADDR) \
@@ -214,6 +224,7 @@ struct idpf_vport {int bufq_desc_count[IDPF_MAX_BUFQS_PER_RXQ_GRP ];u32 bufq_size[IDPF_MAX_BUFQS_PER_RXQ_GRP ];int num_rxq_grp; +struct idpf_rxq_group *rxq_grps;u32 rxq_model;struct idpf_rx_ptype_decoded rx_ptype_lkup[IDPF_RX_MAX_PTYPE ];
@@ -246,8 +257,17 @@ struct idpf_vport {spinlock_t mac_filter_list_lock; }; +struct idpf_rss_data { +u16 rss_key_size; +u8 *rss_key; +u16 rss_lut_size; +u32 *rss_lut; +u32 *cached_lut; +}; +/* User defined configuration values for each vport */ struct idpf_vport_user_config_data { +struct idpf_rss_data rss_data;u32 num_req_tx_qs;/* user requested TX queues through ethtool */ u32 num_req_rx_qs;/* user requested RX queues through ethtool */ u32 num_req_txq_desc;/* user requested TX queue descriptors through ethtool */
@@ -528,6 +548,19 @@ static inline struct idpf_vport *idpf_netdev_to_vport(struct net_device *netdev)return np->vport; } +/** +* idpf_is_feature_ena - Determine if a particular feature is enabled +* @vport: vport to check +* @feature: netdev flag to check +* +* Returns true or false if a particular feature is enabled. +*/ +static inline bool idpf_is_feature_ena (struct idpf_vport *vport, +netdev_features_t feature) +{ +return vport->netdev->features & feature; +} +int idpf_pf_probe (struct pci_dev *pdev,struct idpf_adapter *adapter);int idpf_vf_probe (struct pci_dev *pdev,struct idpf_adapter *adapter);int idpf_probe_common (struct pci_dev *pdev,struct idpf_adapter *adapter);
@@ -540,6 +573,8 @@ int idpf_intr_req(struct idpf_adapter *adapter);void idpf_intr_rel (struct idpf_adapter *adapter);int idpf_send_destroy_vport_msg (struct idpf_vport *vport);int idpf_send_get_rx_ptype_msg (struct idpf_vport *vport); +int idpf_send_get_set_rss_key_msg (struct idpf_vport *vport,bool get); +int idpf_send_get_set_rss_lut_msg (struct idpf_vport *vport,bool get);int idpf_send_dealloc_vectors_msg (struct idpf_adapter *adapter);int idpf_send_alloc_vectors_msg (struct idpf_adapter *adapter,u16 num_vectors);void idpf_deinit_task (struct idpf_adapter *adapter);
@@ -559,7 +594,7 @@ void idpf_vport_init(struct idpf_vport *vport, struct idpf_vport_max_q *max_q);u32 idpf_get_vport_id (struct idpf_vport *vport);int idpf_vport_queue_ids_init (struct idpf_vport *vport);int idpf_queue_reg_init (struct idpf_vport *vport); -int idpf_send_config_tx_queues_msg (struct idpf_vport *vport); +int idpf_send_config_queues_msg (struct idpf_vport *vport);int idpf_send_create_vport_msg (struct idpf_adapter *adapter,struct idpf_vport_max_q *max_q);int idpf_check_supported_desc_ids (struct idpf_vport *vport);
drivers/net/ethernet/intel/idpf/idpf_lan_txrx.h +53 -1
62 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_lib.c +34 -1
@@ -681,11 +681,16 @@ static void idpf_vport_rel(struct idpf_vport *vport) {struct idpf_adapter *adapter = vport->adapter;struct idpf_vport_config *vport_config; +struct idpf_rss_data *rss_data;struct idpf_vport_max_q max_q;u16 idx = vport->idx;int i; vport_config = adapter->vport_config[vport->idx]; +idpf_deinit_rss (vport); + rss_data = &vport_config->user_config.rss_data; +kfree (rss_data->rss_key); + rss_data->rss_key =NULL ;idpf_send_destroy_vport_msg (vport);
@@ -754,6 +759,7 @@ static void idpf_vport_dealloc(struct idpf_vport *vport)static struct idpf_vport *idpf_vport_alloc (struct idpf_adapter *adapter,struct idpf_vport_max_q *max_q) { +struct idpf_rss_data *rss_data;u16 idx = adapter->next_vport;struct idpf_vport *vport;
@@ -784,6 +790,21 @@ static struct idpf_vport *idpf_vport_alloc(struct idpf_adapter *adapter,idpf_vport_init (vport, max_q); +/* This alloc is done separate from the LUT because it's not strictly +* dependent on how many queues we have. If we change number of queues +* and soft reset we'll need a new LUT but the key can remain the same +* for as long as the vport exists. +*/ + rss_data = &adapter->vport_config[idx]->user_config.rss_data; + rss_data->rss_key =kzalloc (rss_data->rss_key_size,GFP_KERNEL ); +if (!rss_data->rss_key) { +kfree (vport); + +return NULL ; + } +/* Initialize default rss key */ +netdev_rss_key_fill ((void *)rss_data->rss_key, rss_data->rss_key_size); +/* fill vport slot in the adapter struct */ adapter->vports[idx] = vport; adapter->vport_ids[idx] =idpf_get_vport_id (vport);
@@ -840,6 +861,7 @@ static void idpf_service_task(struct work_struct *work)static int idpf_vport_open (struct idpf_vport *vport,bool alloc_res) {struct idpf_adapter *adapter = vport->adapter; +struct idpf_vport_config *vport_config;int err;if (vport->state != __IDPF_VPORT_DOWN)
@@ -875,13 +897,24 @@ static int idpf_vport_open(struct idpf_vport *vport, bool alloc_res) goto intr_rel; } - err =idpf_send_config_tx_queues_msg (vport); + err =idpf_send_config_queues_msg (vport);if (err) {dev_err (&adapter->pdev->dev,"Failed to configure queues for vport %u, %d\n" , vport->vport_id, err); goto intr_rel; } + vport_config = adapter->vport_config[vport->idx]; +if (vport_config->user_config.rss_data.rss_lut) + err =idpf_config_rss (vport); +else + err =idpf_init_rss (vport); +if (err) { +dev_err (&adapter->pdev->dev,"Failed to initialize RSS for vport %u: %d\n" , + vport->vport_id, err); + goto intr_rel; + } +return 0 ; intr_rel:
drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c new file +60 -0
60 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_txrx.c +904 -3
988 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_txrx.h +139 -5
219 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +482 -3
580 lines not on this page · raw message
Signature · 1 line
2.37.3
PATCH 10/15 idpf: add splitq start_xmit
In reply to Pavan Kumar LingaFrom: Joshua Hay <[email protected]>
Add start_xmit support for split queue model. To start with, add the necessary checks to linearize the skb if it uses more number of buffers than the hardware supported limit. Stop the transmit queue if there are no enough descriptors available for the skb to use or if there we're going to potentially overrun the completion queue. Finally prepare the descriptor with all the required information and update the tail.
--- drivers/net/ethernet/intel/idpf/idpf.h | 3 +- .../net/ethernet/intel/idpf/idpf_lan_txrx.h | 143 ++++ drivers/net/ethernet/intel/idpf/idpf_lib.c | 1 + drivers/net/ethernet/intel/idpf/idpf_txrx.c | 802 ++++++++++++++++++ drivers/net/ethernet/intel/idpf/idpf_txrx.h | 167 +++- 5 files changed, 1108 insertions(+), 8 deletions(-)
drivers/net/ethernet/intel/idpf/idpf.h +2 -1
@@ -13,6 +13,7 @@ struct idpf_vport_max_q;#include <linux/aer.h> #include <linux/etherdevice.h> #include <linux/pci.h> +#include <linux/bitfield.h> #include "virtchnl2.h" #include "idpf_lan_txrx.h"
@@ -516,7 +517,7 @@ static inline u8 idpf_get_min_tx_pkt_len(struct idpf_adapter *adapter) {u8 pkt_len = adapter->caps.min_sso_packet_len; -return pkt_len ? pkt_len :IDPF_TX_MIN_LEN ; +return pkt_len ? pkt_len :IDPF_TX_MIN_PKT_LEN ; }/**
drivers/net/ethernet/intel/idpf/idpf_lan_txrx.h +143 -0
153 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_lib.c +1 -0
@@ -1730,6 +1730,7 @@ void idpf_free_dma_mem(struct idpf_hw *hw, struct idpf_dma_mem *mem)static const struct net_device_ops idpf_netdev_ops_splitq = { .ndo_open = idpf_open, .ndo_stop = idpf_stop, + .ndo_start_xmit = idpf_tx_splitq_start, };static const struct net_device_ops idpf_netdev_ops_singleq = {
drivers/net/ethernet/intel/idpf/idpf_txrx.c +802 -0
815 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_txrx.h +160 -7
228 lines not on this page · raw message
Signature · 1 line
2.37.3
PATCH 11/15 idpf: add TX splitq napi poll support
In reply to Pavan Kumar LingaFrom: Joshua Hay <[email protected]>
Add support to handle the interrupts for the TX completion queue and process the various completion types.
In the flow scheduling mode, the driver processes primarily buffer completions as well as descriptor completions occasionally. This mode supports out of order TX completions. To do so, HW generates one buffer completion per packet. Each of those completions contains the unique tag provided during the TX encoding which is used to locate the packet either on the TX buffer ring or in a hash table. The hash table is used to track TX buffer information so the descriptor(s) for a given packet can be reused while the driver is still waiting on the buffer completion(s).
Packets end up in the hash table in one of 2 ways: 1) a packet was stashed during descriptor completion cleaning, or 2) because an out of order buffer completion was processed. A descriptor completion arrives only every so often and is primarily used to guarantee the TX descriptor ring can be reused without having to wait on the individual buffer completions. E.g. a descriptor completion for N+16 guarantees HW read all of the descriptors for packets N through N+15, therefore all of the buffers for packets N through N+15 are stashed into the hash table and the descriptors can be reused for more TX packets. Similarly, a packet can be stashed in the hash table because an out an order buffer completion was processed. E.g. processing a buffer completion for packet N+3 implies that HW read all of the descriptors for packets N through N+3 and they can be reused. However, the HW did not do the DMA yet. The buffers for packets N through N+2 cannot be freed, so they are stashed in the hash table. In either case, the buffer completions will eventually be processed for all of the stashed packets, and all of the buffers will be cleaned from the hash table.
In queue based scheduling mode, the driver processes primarily descriptor completions and cleans the TX ring the conventional way.
In addition, the driver processes miss and reinject completions when the packet triggers the rule miss flow. The HW generates a miss completion when a packet triggers this flow. While processing the miss completion, the driver frees DMA buffers for the given packet, but it cannot free the SKB or update BQLs (as the packet did not go out on the wire yet). A reinject completion is expected to follow but not guaranteed, so the driver starts a timer. Once the reinject completion is processed or the timer expires, the driver frees the SKB and updates BQL. No other completions are expected for this packet.
Finally, the driver triggers a TX queue drain after sending the disable queues virtchnl message. When the HW completes the queue draining, it sends the driver a queue marker packet completion. The driver determines when all TX queues have been drained and proceeds with the disable flow.
With this, the driver can send TX packets and clean up the resources properly.
--- drivers/net/ethernet/intel/idpf/idpf.h | 9 + .../net/ethernet/intel/idpf/idpf_lan_txrx.h | 16 + drivers/net/ethernet/intel/idpf/idpf_lib.c | 2 + drivers/net/ethernet/intel/idpf/idpf_txrx.c | 1029 ++++++++++++++++- drivers/net/ethernet/intel/idpf/idpf_txrx.h | 49 +- .../net/ethernet/intel/idpf/idpf_virtchnl.c | 52 +- 6 files changed, 1152 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/idpf/idpf.h +9 -0
@@ -14,6 +14,7 @@ struct idpf_vport_max_q;#include <linux/etherdevice.h> #include <linux/pci.h> #include <linux/bitfield.h> +#include <linux/dim.h> #include "virtchnl2.h" #include "idpf_lan_txrx.h"
@@ -199,6 +200,8 @@ extern const char * const idpf_vport_vc_state_str[];enum idpf_vport_flags {/* Virtchnl message buffer received needs to be processed */ __IDPF_VPORT_VC_MSG_PENDING, +/* Indicate TX pipe drain software marker packets processing is done */ + __IDPF_VPORT_SW_MARKER,/* Asynchronous add/del ether address in flight */ __IDPF_VPORT_ADD_MAC_REQ, __IDPF_VPORT_DEL_MAC_REQ,
@@ -224,6 +227,7 @@ struct idpf_vport {*/ int txq_desc_count;int complq_desc_count; +int compln_clean_budget;int num_txq_grp;struct idpf_txq_group *txq_grps;u32 txq_model;
@@ -256,6 +260,9 @@ struct idpf_vport {u16 *q_vector_idxs;/* q vector index array */ u16 max_mtu;u8 default_mac_addr[ETH_ALEN ]; +/* ITR profiles for the DIM algorithm */ +#define IDPF_DIM_PROFILE_SLOTS 5 +u16 tx_itr_profile[IDPF_DIM_PROFILE_SLOTS ];bool link_up;
@@ -265,6 +272,8 @@ struct idpf_vport {/* Everything below this will NOT be copied during soft reset */ enum idpf_vport_state state;wait_queue_head_t vchnl_wq; +/* wait_queue for TX drain SW marker packets */ +wait_queue_head_t sw_marker_wq;/* lock to protect against multiple stop threads, which can happen when * the driver is in a namespace in a system that is being shutdown */
drivers/net/ethernet/intel/idpf/idpf_lan_txrx.h +16 -0
@@ -56,6 +56,14 @@ enum idpf_rss_hash { BIT_ULL(IDPF_HASH_NONF_UNICAST_IPV6_UDP) | \ BIT_ULL(IDPF_HASH_NONF_MULTICAST_IPV6_UDP)) +/* For idpf_splitq_base_tx_compl_desc */ +#define IDPF_TXD_COMPLQ_GEN_S 15 +#define IDPF_TXD_COMPLQ_GEN_M BIT_ULL(IDPF_TXD_COMPLQ_GEN_S) +#define IDPF_TXD_COMPLQ_COMPL_TYPE_S 11 +#define IDPF_TXD_COMPLQ_COMPL_TYPE_M GENMASK_ULL(13, 11) +#define IDPF_TXD_COMPLQ_QID_S 0 +#define IDPF_TXD_COMPLQ_QID_M GENMASK_ULL(9, 0) +#define IDPF_TXD_CTX_QW1_MSS_S 50#define IDPF_TXD_CTX_QW1_MSS_M GENMASK_ULL(63, 50)#define IDPF_TXD_CTX_QW1_TSO_LEN_S 30
@@ -75,6 +83,14 @@ enum idpf_rss_hash {#define IDPF_TXD_QW1_DTYPE_S 0#define IDPF_TXD_QW1_DTYPE_M GENMASK_ULL(3, 0) +/* TX Completion Descriptor Completion Types */ +#define IDPF_TXD_COMPLT_ITR_FLUSH 0 +#define IDPF_TXD_COMPLT_RULE_MISS 1 +#define IDPF_TXD_COMPLT_RS 2 +#define IDPF_TXD_COMPLT_REINJECTED 3 +#define IDPF_TXD_COMPLT_RE 4 +#define IDPF_TXD_COMPLT_SW_MARKER 5 +enum idpf_tx_desc_dtype_value {IDPF_TX_DESC_DTYPE_DATA =0 ,IDPF_TX_DESC_DTYPE_CTX =1 ,
drivers/net/ethernet/intel/idpf/idpf_lib.c +2 -0
@@ -939,6 +939,7 @@ static struct idpf_vport *idpf_vport_alloc(struct idpf_adapter *adapter, vport->idx = idx; vport->adapter = adapter; + vport->compln_clean_budget =IDPF_TX_COMPLQ_CLEAN_BUDGET ; vport->default_vport = adapter->num_alloc_vports <idpf_get_default_vports (adapter);
@@ -1276,6 +1277,7 @@ static void idpf_init_task(struct work_struct *work) index = vport->idx; vport_config = adapter->vport_config[index]; +init_waitqueue_head (&vport->sw_marker_wq);init_waitqueue_head (&vport->vchnl_wq);spin_lock_init (&vport->mac_filter_list_lock);
drivers/net/ethernet/intel/idpf/idpf_txrx.c +1026 -3
1,090 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_txrx.h +48 -1
124 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +51 -1
76 lines not on this page · raw message
Signature · 1 line
2.37.3
PATCH 9/15 idpf: initialize interrupts and enable vport
In reply to Pavan Kumar LingaTo further continue 'vport open', initialize all the resources required for the interrupts. To start with, initialize the queue vector indices with the ones received from the device Control Plane. Now that all the TX and RX queues are initialized, map the RX descriptor and buffer queues as well as TX completion queues to the allocated vectors. Initialize and enable the napi handler for the napi polling. Finally, request the IRQs for the interrupt vectors from the stack and setup the interrupt handler.
Once the interrupt init is done, send 'map queue vector', 'enable queues' and 'enable vport' virtchnl messages to the CP to complete the 'vport open' flow.
--- drivers/net/ethernet/intel/idpf/idpf.h | 37 ++ drivers/net/ethernet/intel/idpf/idpf_dev.c | 59 ++ .../ethernet/intel/idpf/idpf_lan_pf_regs.h | 11 + .../ethernet/intel/idpf/idpf_lan_vf_regs.h | 25 + drivers/net/ethernet/intel/idpf/idpf_lib.c | 295 +++++++++- .../ethernet/intel/idpf/idpf_singleq_txrx.c | 11 + drivers/net/ethernet/intel/idpf/idpf_txrx.c | 366 +++++++++++- drivers/net/ethernet/intel/idpf/idpf_txrx.h | 21 + drivers/net/ethernet/intel/idpf/idpf_vf_dev.c | 58 ++ .../net/ethernet/intel/idpf/idpf_virtchnl.c | 521 ++++++++++++++++++ 10 files changed, 1401 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/idpf/idpf.h +37 -0
@@ -129,6 +129,7 @@ struct idpf_vport_max_q {/* product specific register API */ struct idpf_reg_ops {void (*ctlq_reg_init)(struct idpf_ctlq_create_info *cq); +int (*intr_reg_init)(struct idpf_vport *vport);void (*mb_intr_reg_init)(struct idpf_adapter *adapter);void (*reset_reg_init)(struct idpf_adapter *adapter); void (*trigger_reset)(struct idpf_adapter *adapter,
@@ -147,12 +148,24 @@ struct idpf_dev_ops {#define IDPF_FOREACH_VPORT_VC_STATE (STATE ) \ STATE(IDPF_VC_CREATE_VPORT) \ STATE(IDPF_VC_CREATE_VPORT_ERR) \ + STATE(IDPF_VC_ENA_VPORT) \ + STATE(IDPF_VC_ENA_VPORT_ERR) \ + STATE(IDPF_VC_DIS_VPORT) \ + STATE(IDPF_VC_DIS_VPORT_ERR) \ STATE(IDPF_VC_DESTROY_VPORT) \ STATE(IDPF_VC_DESTROY_VPORT_ERR) \ STATE(IDPF_VC_CONFIG_TXQ) \ STATE(IDPF_VC_CONFIG_TXQ_ERR) \ STATE(IDPF_VC_CONFIG_RXQ) \ STATE(IDPF_VC_CONFIG_RXQ_ERR) \ + STATE(IDPF_VC_ENA_QUEUES) \ + STATE(IDPF_VC_ENA_QUEUES_ERR) \ + STATE(IDPF_VC_DIS_QUEUES) \ + STATE(IDPF_VC_DIS_QUEUES_ERR) \ + STATE(IDPF_VC_MAP_IRQ) \ + STATE(IDPF_VC_MAP_IRQ_ERR) \ + STATE(IDPF_VC_UNMAP_IRQ) \ + STATE(IDPF_VC_UNMAP_IRQ_ERR) \ STATE(IDPF_VC_ALLOC_VECTORS) \ STATE(IDPF_VC_ALLOC_VECTORS_ERR) \ STATE(IDPF_VC_DEALLOC_VECTORS) \
@@ -239,9 +252,12 @@ struct idpf_vport {u16 num_q_vectors;struct idpf_q_vector *q_vectors;/* q vector array */ +u16 *q_vector_idxs;/* q vector index array */ u16 max_mtu;u8 default_mac_addr[ETH_ALEN ]; +bool link_up; +char vc_msg[IDPF_DFLT_MBX_BUF_SIZE ];DECLARE_BITMAP (vc_state,IDPF_VC_NBITS );
@@ -295,6 +311,17 @@ struct idpf_avail_queue_info {u16 avail_complq; }; +/* Utility structure to pass function arguments as a structure */ +struct idpf_vector_info { +/* Vectors required based on the number of queues updated by the user +* via ethtool +*/ +u16 num_req_vecs; +u16 num_curr_vecs;/* Vectors previously allocated */ +u16 index;/* Vport relative index */ +bool default_vport; +}; +/* Stack to maintain vector indexes used for 'vector distribution' algorithm */ struct idpf_vector_lifo {/* Vector stack maintains all the relative vector indexes at the
@@ -571,6 +598,10 @@ int idpf_vc_core_init(struct idpf_adapter *adapter);void idpf_vc_core_deinit (struct idpf_adapter *adapter);int idpf_intr_req (struct idpf_adapter *adapter);void idpf_intr_rel (struct idpf_adapter *adapter); +int idpf_get_reg_intr_vecs (struct idpf_vport *vport, +struct idpf_vec_regs *reg_vals); +int idpf_send_enable_vport_msg (struct idpf_vport *vport); +int idpf_send_disable_vport_msg (struct idpf_vport *vport);int idpf_send_destroy_vport_msg (struct idpf_vport *vport);int idpf_send_get_rx_ptype_msg (struct idpf_vport *vport);int idpf_send_get_set_rss_key_msg (struct idpf_vport *vport,bool get);
@@ -578,6 +609,9 @@ int idpf_send_get_set_rss_lut_msg(struct idpf_vport *vport, bool get);int idpf_send_dealloc_vectors_msg (struct idpf_adapter *adapter);int idpf_send_alloc_vectors_msg (struct idpf_adapter *adapter,u16 num_vectors);void idpf_deinit_task (struct idpf_adapter *adapter); +int idpf_req_rel_vector_indexes (struct idpf_adapter *adapter, +u16 *q_vector_idxs, +struct idpf_vector_info *vec_info);int idpf_get_vec_ids (struct idpf_adapter *adapter,u16 *vecids,int num_vecids,struct virtchnl2_vector_chunks *chunks);
@@ -590,13 +624,16 @@ int idpf_vport_alloc_max_qs(struct idpf_adapter *adapter,void idpf_vport_dealloc_max_qs (struct idpf_adapter *adapter,struct idpf_vport_max_q *max_q);int idpf_add_del_mac_filters (struct idpf_vport *vport,bool add,bool async); +int idpf_send_disable_queues_msg (struct idpf_vport *vport);void idpf_vport_init (struct idpf_vport *vport,struct idpf_vport_max_q *max_q);u32 idpf_get_vport_id (struct idpf_vport *vport);int idpf_vport_queue_ids_init (struct idpf_vport *vport);int idpf_queue_reg_init (struct idpf_vport *vport);int idpf_send_config_queues_msg (struct idpf_vport *vport); +int idpf_send_enable_queues_msg (struct idpf_vport *vport);int idpf_send_create_vport_msg (struct idpf_adapter *adapter,struct idpf_vport_max_q *max_q);int idpf_check_supported_desc_ids (struct idpf_vport *vport); +int idpf_send_map_unmap_queue_vector_msg (struct idpf_vport *vport,bool map);#endif /* !_IDPF_H_ */
drivers/net/ethernet/intel/idpf/idpf_dev.c +59 -0
77 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_lan_pf_regs.h +11 -0
@@ -74,6 +74,17 @@#define PF_GLINT_DYN_CTL_WB_ON_ITR_M BIT(PF_GLINT_DYN_CTL_WB_ON_ITR_S)#define PF_GLINT_DYN_CTL_INTENA_MSK_S 31#define PF_GLINT_DYN_CTL_INTENA_MSK_M BIT(PF_GLINT_DYN_CTL_INTENA_MSK_S) +/* _ITR is ITR index, _INT is interrupt index, _itrn_indx_spacing is +* spacing b/w itrn registers of the same vector. +*/ +#define PF_GLINT_ITR_ADDR (_ITR, _reg_start, _itrn_indx_spacing) \ + ((_reg_start) + ((_ITR) * (_itrn_indx_spacing))) +/* For PF, itrn_indx_spacing is 4 and itrn_reg_spacing is 0x1000 */ +#define PF_GLINT_ITR (_ITR, _INT) \ + (PF_GLINT_BASE + (((_ITR) + 1) * 4) + ((_INT) * 0x1000)) +#define PF_GLINT_ITR_MAX_INDEX 2 +#define PF_GLINT_ITR_INTERVAL_S 0 +#define PF_GLINT_ITR_INTERVAL_M GENMASK(11, 0)/* Generic registers */ #define PF_INT_DIR_OICR_ENA 0x08406000
drivers/net/ethernet/intel/idpf/idpf_lan_vf_regs.h +25 -0
@@ -88,6 +88,31 @@#define VF_INT_DYN_CTLN_WB_ON_ITR_M BIT(VF_INT_DYN_CTLN_WB_ON_ITR_S)#define VF_INT_DYN_CTLN_INTENA_MSK_S 31#define VF_INT_DYN_CTLN_INTENA_MSK_M BIT(VF_INT_DYN_CTLN_INTENA_MSK_S) +/* _ITR is ITR index, _INT is interrupt index, _itrn_indx_spacing is spacing +* b/w itrn registers of the same vector +*/ +#define VF_INT_ITR0 (_ITR) (0x00004C00 + ((_ITR) * 4)) +#define VF_INT_ITRN_ADDR (_ITR, _reg_start, _itrn_indx_spacing) \ + ((_reg_start) + ((_ITR) * (_itrn_indx_spacing))) +/* For VF with 16 vector support, itrn_reg_spacing is 0x4, itrn_indx_spacing +* is 0x40 and base register offset is 0x00002800 +*/ +#define VF_INT_ITRN (_INT, _ITR) \ + (0x00002800 + ((_INT) * 4) + ((_ITR) * 0x40)) +/* For VF with 64 vector support, itrn_reg_spacing is 0x4, itrn_indx_spacing +* is 0x100 and base register offset is 0x00002C00 +*/ +#define VF_INT_ITRN_64 (_INT, _ITR) \ + (0x00002C00 + ((_INT) * 4) + ((_ITR) * 0x100)) +/* For VF with 2k vector support, itrn_reg_spacing is 0x4, itrn_indx_spacing +* is 0x2000 and base register offset is 0x00072000 +*/ +#define VF_INT_ITRN_2K (_INT, _ITR) \ + (0x00072000 + ((_INT) * 4) + ((_ITR) * 0x2000)) +#define VF_INT_ITRN_MAX_INDEX 2 +#define VF_INT_ITRN_INTERVAL_S 0 +#define VF_INT_ITRN_INTERVAL_M GENMASK(11, 0) +#define VF_INT_PBA_CLEAR 0x00008900#define VF_INT_ICR0_ENA1 0x00005000#define VF_INT_ICR0_ENA1_ADMINQ_S 30
drivers/net/ethernet/intel/idpf/idpf_lib.c +293 -2
364 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c +11 -0
@@ -58,3 +58,14 @@ bool idpf_rx_singleq_buf_hw_alloc_all(struct idpf_queue *rx_q,return !!cleaned_count; } + +/** +* idpf_vport_singleq_napi_poll - NAPI handler +* @napi: struct from which you get q_vector +* @budget: budget provided by stack +*/ +int idpf_vport_singleq_napi_poll (struct napi_struct *napi,int budget) +{ +/* stub */ +return 0 ; +}
drivers/net/ethernet/intel/idpf/idpf_txrx.c +365 -1
394 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_txrx.h +21 -0
@@ -23,6 +23,7 @@#define IDPF_SINGLE_BUFQ_PER_RXQ_GRP 1#define IDPF_MAX_BUFQS_PER_RXQ_GRP 2#define IDPF_BUFQ2_ENA 1 +#define IDPF_NUMQ_PER_CHUNK 1#define IDPF_DFLT_SPLITQ_TXQ_PER_GROUP 1#define IDPF_DFLT_SPLITQ_RXQ_PER_GROUP 1
@@ -239,29 +240,45 @@ enum idpf_queue_flags_t { __IDPF_Q_FLAGS_NBITS, }; +struct idpf_vec_regs { +u32 dyn_ctl_reg; +u32 itrn_reg; +u32 itrn_index_spacing; +}; +struct idpf_intr_reg {void __iomem *dyn_ctl;u32 dyn_ctl_intena_m; +u32 dyn_ctl_clrpba_m; +u32 dyn_ctl_itridx_s;u32 dyn_ctl_itridx_m; +u32 dyn_ctl_intrvl_s; +void __iomem *rx_itr; +void __iomem *tx_itr;void __iomem *icr_ena;u32 icr_ena_ctlq_m; };struct idpf_q_vector {struct idpf_vport *vport; +cpumask_t affinity_mask; +struct napi_struct napi;u16 v_idx;/* index in the vport->q_vector array */ struct idpf_intr_reg intr_reg; +int num_txq;struct idpf_queue **tx;u16 tx_itr_value;bool tx_intr_mode;u32 tx_itr_idx; +int num_rxq;struct idpf_queue **rx;u16 rx_itr_value;bool rx_intr_mode;u32 rx_itr_idx; +int num_bufq;struct idpf_queue **bufq;char name[IDPF_INT_NAME_STR_LEN ];
@@ -271,6 +288,7 @@ struct idpf_q_vector {#define IDPF_ITR_20K 0x0032#define IDPF_ITR_TX_DEF IDPF_ITR_20K#define IDPF_ITR_RX_DEF IDPF_ITR_20K +#define IDPF_ITR_IDX_SPACING (spacing, dflt) (spacing ? spacing : dflt)/* queue associated with a vport */ struct idpf_queue {
@@ -460,6 +478,7 @@ struct idpf_txq_group {u64 num_completions_pending; }; +int idpf_vport_singleq_napi_poll (struct napi_struct *napi,int budget);void idpf_vport_init_num_qs (struct idpf_vport *vport,struct virtchnl2_create_vport *vport_msg);void idpf_vport_calc_num_q_desc (struct idpf_vport *vport);
@@ -471,6 +490,8 @@ int idpf_vport_queues_alloc(struct idpf_vport *vport);void idpf_vport_queues_rel (struct idpf_vport *vport);void idpf_vport_intr_rel (struct idpf_vport *vport);int idpf_vport_intr_alloc (struct idpf_vport *vport); +void idpf_vport_intr_deinit (struct idpf_vport *vport); +int idpf_vport_intr_init (struct idpf_vport *vport);int idpf_config_rss (struct idpf_vport *vport);int idpf_init_rss (struct idpf_vport *vport);void idpf_deinit_rss (struct idpf_vport *vport);
drivers/net/ethernet/intel/idpf/idpf_vf_dev.c +58 -0
76 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +521 -0
575 lines not on this page · raw message
Signature · 1 line
2.37.3
PATCH 13/15 idpf: add singleq start_xmit and napi poll
In reply to Pavan Kumar LingaFrom: Joshua Hay <[email protected]>
Add the start_xmit, TX and RX napi poll support for the single queue model. Unlike split queue model, single queue uses same queue to post buffer descriptors and completed descriptors.
--- drivers/net/ethernet/intel/idpf/idpf.h | 8 + .../net/ethernet/intel/idpf/idpf_lan_txrx.h | 57 + drivers/net/ethernet/intel/idpf/idpf_lib.c | 1 + .../ethernet/intel/idpf/idpf_singleq_txrx.c | 1195 ++++++++++++++++- drivers/net/ethernet/intel/idpf/idpf_txrx.c | 68 +- drivers/net/ethernet/intel/idpf/idpf_txrx.h | 72 + drivers/net/ethernet/intel/idpf/idpf_vf_dev.c | 2 + .../net/ethernet/intel/idpf/idpf_virtchnl.c | 2 + 8 files changed, 1371 insertions(+), 34 deletions(-)
drivers/net/ethernet/intel/idpf/idpf.h +8 -0
@@ -14,6 +14,7 @@ struct idpf_vport_max_q;#include <linux/etherdevice.h> #include <linux/pci.h> #include <linux/bitfield.h> +#include <linux/sctp.h> #include <net/gro.h> #include <linux/dim.h>
@@ -234,6 +235,8 @@ struct idpf_vport {u32 txq_model;/* Used only in hotpath to get to the right queue very fast */ struct idpf_queue **txqs; +/* Enable CRC insertion offload */ +bool crc_enable;/* RX */ int num_rxq;
@@ -413,6 +416,9 @@ struct idpf_adapter {DECLARE_BITMAP (vc_state,IDPF_VC_NBITS );char vc_msg[IDPF_DFLT_MBX_BUF_SIZE ];struct idpf_dev_ops dev_ops; +int num_vfs; +/* Enable CRC insertion offload */ +bool crc_enable;struct mutex reset_lock;/* lock to protect reset flows */ struct mutex sw_mutex;/* lock to protect vport alloc flow */
@@ -647,5 +653,7 @@ int idpf_send_create_vport_msg(struct idpf_adapter *adapter, struct idpf_vport_max_q *max_q);int idpf_check_supported_desc_ids (struct idpf_vport *vport);int idpf_send_map_unmap_queue_vector_msg (struct idpf_vport *vport,bool map); +int idpf_send_set_sriov_vfs_msg (struct idpf_adapter *adapter,u16 num_vfs); +int idpf_sriov_configure (struct pci_dev *pdev,int num_vfs);#endif /* !_IDPF_H_ */
drivers/net/ethernet/intel/idpf/idpf_lan_txrx.h +57 -0
75 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_lib.c +1 -0
@@ -1738,4 +1738,5 @@ static const struct net_device_ops idpf_netdev_ops_splitq = {static const struct net_device_ops idpf_netdev_ops_singleq = { .ndo_open = idpf_open, .ndo_stop = idpf_stop, + .ndo_start_xmit = idpf_tx_singleq_start, };
drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c +1193 -2
1,211 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_txrx.c +36 -32
164 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_txrx.h +72 -0
126 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_vf_dev.c +2 -0
@@ -174,5 +174,7 @@ int idpf_vf_probe(struct pci_dev *pdev, struct idpf_adapter *adapter) {idpf_vf_dev_ops_init (adapter); + adapter->crc_enable = true; +return idpf_probe_common (pdev, adapter); }
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +2 -0
@@ -2933,6 +2933,8 @@ void idpf_vport_init(struct idpf_vport *vport, struct idpf_vport_max_q *max_q)idpf_vport_calc_num_q_groups (vport);idpf_vport_alloc_vec_indexes (vport); + vport->crc_enable = adapter->crc_enable; +mutex_init (&vport->stop_mutex); }
Signature · 1 line
2.37.3
PATCH 12/15 idpf: add RX splitq napi poll support
In reply to Pavan Kumar LingaFrom: Alan Brady <[email protected]>
Add support to handle interrupts for the RX completion queue and RX buffer queue. When the interrupt fires on RX completion queue, process the RX descriptors that are received. Allocate and prepare the SKB with the RX packet info, for both data and header buffer.
IDPF uses software maintained refill queues to manage buffers between RX queue producer and the buffer queue consumer. They are required in order to maintain a lockless buffer management system and are strictly software only constructs. Instead of updating the RX buffer queue tail with available buffers right after the clean routine, it posts the buffer ids to the refill queues, only to post them to the HW later.
If the generic receive offload (GRO) is enabled in the capabilities and turned on by default or via ethtool, then HW performs the packet coalescing if certain criteria are met by the incoming packets and updates the RX descriptor. Similar to GRO, if generic checksum is enabled, HW computes the checksum and updates the respective fields in the descriptor. Add support to update the SKB fields with the GRO and the generic checksum received.
--- drivers/net/ethernet/intel/idpf/idpf.h | 2 + drivers/net/ethernet/intel/idpf/idpf_txrx.c | 1000 ++++++++++++++++- drivers/net/ethernet/intel/idpf/idpf_txrx.h | 56 +- .../net/ethernet/intel/idpf/idpf_virtchnl.c | 4 +- 4 files changed, 1053 insertions(+), 9 deletions(-)
drivers/net/ethernet/intel/idpf/idpf.h +2 -0
@@ -14,6 +14,7 @@ struct idpf_vport_max_q;#include <linux/etherdevice.h> #include <linux/pci.h> #include <linux/bitfield.h> +#include <net/gro.h> #include <linux/dim.h> #include "virtchnl2.h"
@@ -262,6 +263,7 @@ struct idpf_vport {u8 default_mac_addr[ETH_ALEN ];/* ITR profiles for the DIM algorithm */ #define IDPF_DIM_PROFILE_SLOTS 5 +u16 rx_itr_profile[IDPF_DIM_PROFILE_SLOTS ];u16 tx_itr_profile[IDPF_DIM_PROFILE_SLOTS ];bool link_up;
drivers/net/ethernet/intel/idpf/idpf_txrx.c +996 -4
1,066 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_txrx.h +52 -4
118 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +3 -1
@@ -2898,6 +2898,7 @@ void idpf_vport_init(struct idpf_vport *vport, struct idpf_vport_max_q *max_q)struct virtchnl2_create_vport *vport_msg;struct idpf_vport_config *vport_config;u16 tx_itr[] = {2 ,8 ,64 ,128 ,256 }; +u16 rx_itr[] = {2 ,8 ,32 ,96 ,128 };struct idpf_rss_data *rss_data;u16 idx = vport->idx;
@@ -2923,7 +2924,8 @@ void idpf_vport_init(struct idpf_vport *vport, struct idpf_vport_max_q *max_q)ether_addr_copy (vport->default_mac_addr, vport_msg->default_mac_addr); vport->max_mtu =le16_to_cpu (vport_msg->max_mtu) -IDPF_PACKET_HDR_PAD ; -/* Initialize Tx profiles for Dynamic Interrupt Moderation */ +/* Initialize Tx and Rx profiles for Dynamic Interrupt Moderation */ +memcpy (vport->rx_itr_profile, rx_itr,IDPF_DIM_PROFILE_SLOTS );memcpy (vport->tx_itr_profile, tx_itr,IDPF_DIM_PROFILE_SLOTS );idpf_vport_init_num_qs (vport, vport_msg);
Signature · 1 line
2.37.3
PATCH 14/15 idpf: add ethtool callbacks
In reply to Pavan Kumar LingaFrom: Alan Brady <[email protected]>
Initialize all the ethtool ops that are supported by the driver and add the necessary support for the ethtool callbacks. Also add asynchronous link notification virtchnl support where the device Control Plane sends the link status and link speed as an asynchronous event message. Driver report the link speed on ethtool .idpf_get_link_ksettings query.
Introduce soft reset function which is used by some of the ethtool callbacks such as .set_channels, .set_ringparam etc. to change the existing queue configuration. It deletes the existing queues by sending delete queues virtchnl message to the CP and calls the 'vport_stop' flow which disables the queues, vport etc. New set of queues are requested to the CP and reconfigure the queue context by calling the 'vport_open' flow. Soft reset flow also adjusts the number of vectors associated to a vport if .set_channels is called.
--- drivers/net/ethernet/intel/idpf/Makefile | 1 + drivers/net/ethernet/intel/idpf/idpf.h | 39 + .../net/ethernet/intel/idpf/idpf_ethtool.c | 1325 +++++++++++++++++ drivers/net/ethernet/intel/idpf/idpf_lib.c | 156 ++ drivers/net/ethernet/intel/idpf/idpf_txrx.c | 7 +- drivers/net/ethernet/intel/idpf/idpf_txrx.h | 15 +- .../net/ethernet/intel/idpf/idpf_virtchnl.c | 245 ++- 7 files changed, 1784 insertions(+), 4 deletions(-) create mode 100644 drivers/net/ethernet/intel/idpf/idpf_ethtool.c
drivers/net/ethernet/intel/idpf/Makefile +1 -0
@@ -9,6 +9,7 @@ idpf-y := \ idpf_controlq.o \ idpf_controlq_setup.o \ idpf_dev.o \ + idpf_ethtool.o \ idpf_lib.o \ idpf_main.o \ idpf_singleq_txrx.o \
drivers/net/ethernet/intel/idpf/idpf.h +39 -0
@@ -15,6 +15,7 @@ struct idpf_vport_max_q;#include <linux/pci.h> #include <linux/bitfield.h> #include <linux/sctp.h> +#include <linux/ethtool.h> #include <net/gro.h> #include <linux/dim.h>
@@ -170,6 +171,10 @@ struct idpf_dev_ops { STATE(IDPF_VC_MAP_IRQ_ERR) \ STATE(IDPF_VC_UNMAP_IRQ) \ STATE(IDPF_VC_UNMAP_IRQ_ERR) \ + STATE(IDPF_VC_ADD_QUEUES) \ + STATE(IDPF_VC_ADD_QUEUES_ERR) \ + STATE(IDPF_VC_DEL_QUEUES) \ + STATE(IDPF_VC_DEL_QUEUES_ERR) \ STATE(IDPF_VC_ALLOC_VECTORS) \ STATE(IDPF_VC_ALLOC_VECTORS_ERR) \ STATE(IDPF_VC_DEALLOC_VECTORS) \
@@ -200,6 +205,12 @@ enum idpf_vport_vc_state {extern const char *const idpf_vport_vc_state_str[];enum idpf_vport_flags { +/* Soft reset causes */ + __IDPF_SR_Q_CHANGE,/* Soft reset to do queue change */ + __IDPF_SR_Q_DESC_CHANGE, + __IDPF_SR_HSPLIT_CHANGE, +/* To send delete queues message */ + __IDPF_VPORT_DEL_QUEUES,/* Virtchnl message buffer received needs to be processed */ __IDPF_VPORT_VC_MSG_PENDING,/* Indicate TX pipe drain software marker packets processing is done */
@@ -211,6 +222,20 @@ enum idpf_vport_flags { __IDPF_VPORT_FLAGS_NBITS, }; +struct idpf_port_stats { +struct u64_stats_sync stats_sync; +u64_stats_t rx_hw_csum_err; +u64_stats_t rx_hsplit; +u64_stats_t rx_hsplit_hbo; +u64_stats_t rx_bad_descs; +u64_stats_t tx_linearize; +u64_stats_t tx_busy; +u64_stats_t tx_drops; +u64_stats_t tx_dma_map_errs; +u64_stats_t tx_reinjection_timeouts; +struct virtchnl2_vport_stats vport_stats; +}; +enum idpf_vport_state { __IDPF_VPORT_DOWN, __IDPF_VPORT_UP,
@@ -268,8 +293,10 @@ struct idpf_vport {#define IDPF_DIM_PROFILE_SLOTS 5u16 rx_itr_profile[IDPF_DIM_PROFILE_SLOTS ];u16 tx_itr_profile[IDPF_DIM_PROFILE_SLOTS ]; +struct idpf_port_stats port_stats;bool link_up; +u32 link_speed_mbps;char vc_msg[IDPF_DFLT_MBX_BUF_SIZE ];DECLARE_BITMAP (vc_state,IDPF_VC_NBITS );
@@ -283,6 +310,8 @@ struct idpf_vport {* the driver is in a namespace in a system that is being shutdown */ struct mutex stop_mutex; +/* lock to protect soft reset flow */ +struct mutex soft_reset_lock;/* lock to protect mac filters */ spinlock_t mac_filter_list_lock;
@@ -606,6 +635,7 @@ static inline bool idpf_is_feature_ena(struct idpf_vport *vport,return vport->netdev->features & feature; } +int idpf_vport_adjust_qs (struct idpf_vport *vport);int idpf_pf_probe (struct pci_dev *pdev,struct idpf_adapter *adapter);int idpf_vf_probe (struct pci_dev *pdev,struct idpf_adapter *adapter);int idpf_probe_common (struct pci_dev *pdev,struct idpf_adapter *adapter);
@@ -618,6 +648,11 @@ int idpf_intr_req(struct idpf_adapter *adapter);void idpf_intr_rel (struct idpf_adapter *adapter);int idpf_get_reg_intr_vecs (struct idpf_vport *vport,struct idpf_vec_regs *reg_vals); +int idpf_send_delete_queues_msg (struct idpf_vport *vport); +int idpf_send_add_queues_msg (const struct idpf_vport *vport,u16 num_tx_q, +u16 num_complq,u16 num_rx_q,u16 num_rx_bufq); +int idpf_initiate_soft_reset (struct idpf_vport *vport, +enum idpf_vport_flags reset_cause);int idpf_send_enable_vport_msg (struct idpf_vport *vport);int idpf_send_disable_vport_msg (struct idpf_vport *vport);int idpf_send_destroy_vport_msg (struct idpf_vport *vport);
@@ -630,6 +665,7 @@ void idpf_deinit_task(struct idpf_adapter *adapter);int idpf_req_rel_vector_indexes (struct idpf_adapter *adapter,u16 *q_vector_idxs,struct idpf_vector_info *vec_info); +int idpf_vport_alloc_vec_indexes (struct idpf_vport *vport);int idpf_get_vec_ids (struct idpf_adapter *adapter,u16 *vecids,int num_vecids,struct virtchnl2_vector_chunks *chunks);
@@ -637,6 +673,7 @@ int idpf_recv_mb_msg(struct idpf_adapter *adapter, u32 op, void *msg, int msg_size);int idpf_send_mb_msg (struct idpf_adapter *adapter,u32 op,u16 msg_size,u8 *msg); +void idpf_set_ethtool_ops (struct net_device *netdev);int idpf_vport_alloc_max_qs (struct idpf_adapter *adapter,struct idpf_vport_max_q *max_q); void idpf_vport_dealloc_max_qs(struct idpf_adapter *adapter,
@@ -652,6 +689,8 @@ int idpf_send_enable_queues_msg(struct idpf_vport *vport);int idpf_send_create_vport_msg (struct idpf_adapter *adapter,struct idpf_vport_max_q *max_q);int idpf_check_supported_desc_ids (struct idpf_vport *vport); +void idpf_vport_intr_write_itr (struct idpf_q_vector *q_vector, +u16 itr,bool tx);int idpf_send_map_unmap_queue_vector_msg (struct idpf_vport *vport,bool map);int idpf_send_set_sriov_vfs_msg (struct idpf_adapter *adapter,u16 num_vfs);int idpf_sriov_configure (struct pci_dev *pdev,int num_vfs);
drivers/net/ethernet/intel/idpf/idpf_ethtool.c new file +1325 -0
1,325 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_lib.c +156 -0
174 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_txrx.c +5 -2
@@ -1671,6 +1671,10 @@ static void idpf_tx_handle_reinject_expire(struct timer_list *timer)/* Update BQL */ nq =netdev_get_tx_queue (txq->vport->netdev, txq->idx);netdev_tx_completed_queue (nq, cleaned.packets, cleaned.bytes); + +u64_stats_update_begin (&txq->stats_sync); +u64_stats_inc (&txq->vport->port_stats.tx_reinjection_timeouts); +u64_stats_update_end (&txq->stats_sync); }/**
@@ -4221,8 +4225,7 @@ static int idpf_vport_intr_req_irq(struct idpf_vport *vport, char *basename)* @itr: Interrupt throttling rate * @tx: Tx or Rx ITR */ -static void idpf_vport_intr_write_itr (struct idpf_q_vector *q_vector, -u16 itr,bool tx) +void idpf_vport_intr_write_itr (struct idpf_q_vector *q_vector,u16 itr,bool tx) {struct idpf_intr_reg *intr_reg;
drivers/net/ethernet/intel/idpf/idpf_txrx.h +14 -1
@@ -9,12 +9,24 @@#define IDPF_LARGE_MAX_Q 256#define IDPF_MAX_Q 16#define IDPF_MIN_Q 2 +/* Mailbox Queue */ +#define IDPF_MAX_MBXQ 1 +#define IDPF_MIN_TXQ_DESC 64 +#define IDPF_MIN_RXQ_DESC 64#define IDPF_MIN_TXQ_COMPLQ_DESC 256 - +/* Number of descriptors in a queue should be a multiple of 32. RX queue +* descriptors alone should be a multiple of IDPF_REQ_RXQ_DESC_MULTIPLE +* to achieve BufQ descriptors aligned to 32 +*/ +#define IDPF_REQ_DESC_MULTIPLE 32 +#define IDPF_REQ_RXQ_DESC_MULTIPLE (IDPF_MAX_BUFQS_PER_RXQ_GRP * 32)#define IDPF_MIN_TX_DESC_NEEDED (MAX_SKB_FRAGS + 6)#define IDPF_TX_WAKE_THRESH ((u16)IDPF_MIN_TX_DESC_NEEDED * 2) +#define IDPF_MAX_DESCS 8160 +#define IDPF_MAX_TXQ_DESC ALIGN_DOWN(IDPF_MAX_DESCS, IDPF_REQ_DESC_MULTIPLE) +#define IDPF_MAX_RXQ_DESC ALIGN_DOWN(IDPF_MAX_DESCS, IDPF_REQ_RXQ_DESC_MULTIPLE)#define MIN_SUPPORT_TXDID (\ VIRTCHNL2_TXDID_FLEX_FLOW_SCHED |\ VIRTCHNL2_TXDID_FLEX_TSO_CTX)
@@ -494,6 +506,7 @@ union idpf_queue_stats { };#define IDPF_ITR_DYNAMIC 1 +#define IDPF_ITR_MAX 0x1FE0#define IDPF_ITR_20K 0x0032#define IDPF_ITR_GRAN_S 1/* Assume ITR granularity is 2us */ #define IDPF_ITR_MASK 0x1FFE/* ITR register value alignment mask */
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +244 -1
301 lines not on this page · raw message
Signature · 1 line
2.37.3
PATCH 15/15 idpf: configure SRIOV and add other ndo_ops
In reply to Pavan Kumar LingaFrom: Joshua Hay <[email protected]>
Add PCI callback to configure SRIOV and add the necessary support to initialize the requested number of VFs by sending the virtchnl message to the device Control Plane.
Add other ndo ops supported by the driver such as features_check, set_rx_mode, validate_addr, set_mac_address, change_mtu, get_stats64, set_features, and tx_timeout. Initialize the statistics task which requests the queue related statistics to the CP. Add loopback and promiscuous mode support and the respective virtchnl messages.
Finally, add the IDPF's PF and VF device IDs.
--- .../device_drivers/ethernet/intel/idpf.rst | 46 ++ drivers/net/ethernet/intel/idpf/idpf.h | 36 + drivers/net/ethernet/intel/idpf/idpf_lib.c | 659 +++++++++++++++++- drivers/net/ethernet/intel/idpf/idpf_main.c | 3 + drivers/net/ethernet/intel/idpf/idpf_txrx.c | 26 + drivers/net/ethernet/intel/idpf/idpf_txrx.h | 2 + .../net/ethernet/intel/idpf/idpf_virtchnl.c | 201 +++++- 7 files changed, 968 insertions(+), 5 deletions(-) create mode 100644 Documentation/networking/device_drivers/ethernet/intel/idpf.rst
Documentation/networking/device_drivers/ethernet/intel/idpf.rst new file +46 -0
@@ -0,0 +1,46 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +========================================================================== +Linux Driver for the Intel(R) Infrastructure Processing Unit (IPU) devices +========================================================================== + +IDPF Linux driver. +Copyright(C) 2023 Intel Corporation. + +Contents +======== + +- Enabling the driver +- Support + +Driver information can be obtained using ethtool and lspci. + +For questions related to hardware requirements, refer to the documentation +supplied with your Intel adapter. All hardware requirements listed apply to use +with Linux. + +This driver supports both Physical Function (PF) and Virtual Function (VF). +Functionality difference is based on the device ID. + + +Enabling the driver +=================== +The driver is enabled via the standard kernel configuration system, using +the make command: + + make oldconfig/menuconfig/etc. + +The driver is located in the menu structure at: + + -> Device Drivers + -> Network device support (NETDEVICES [=y]) + -> Ethernet driver support + -> Intel devices + -> Infrastructure Processing Unit + + +Support +======= +If an issue is identified with the released source code on a supported kernel +with a supported adapter, email the specific information related to the issue +to [email protected].
drivers/net/ethernet/intel/idpf/idpf.h +36 -0
@@ -88,6 +88,8 @@ enum idpf_flags { __IDPF_VC_MSG_PENDING,/* Do not schedule service task if bit is set */ __IDPF_CANCEL_SERVICE_TASK, +/* Do not schedule stats task if bit is set */ + __IDPF_CANCEL_STATS_TASK,/* Driver remove in progress */ __IDPF_REMOVE_IN_PROG,/* must be last */
@@ -179,6 +181,8 @@ struct idpf_dev_ops { STATE(IDPF_VC_ALLOC_VECTORS_ERR) \ STATE(IDPF_VC_DEALLOC_VECTORS) \ STATE(IDPF_VC_DEALLOC_VECTORS_ERR) \ + STATE(IDPF_VC_SET_SRIOV_VFS) \ + STATE(IDPF_VC_SET_SRIOV_VFS_ERR) \ STATE(IDPF_VC_GET_RSS_LUT) \ STATE(IDPF_VC_GET_RSS_LUT_ERR) \ STATE(IDPF_VC_SET_RSS_LUT) \
@@ -187,12 +191,16 @@ struct idpf_dev_ops { STATE(IDPF_VC_GET_RSS_KEY_ERR) \ STATE(IDPF_VC_SET_RSS_KEY) \ STATE(IDPF_VC_SET_RSS_KEY_ERR) \ + STATE(IDPF_VC_GET_STATS) \ + STATE(IDPF_VC_GET_STATS_ERR) \ STATE(IDPF_VC_ADD_MAC_ADDR) \ STATE(IDPF_VC_ADD_MAC_ADDR_ERR) \ STATE(IDPF_VC_DEL_MAC_ADDR) \ STATE(IDPF_VC_DEL_MAC_ADDR_ERR) \ STATE(IDPF_VC_GET_PTYPE_INFO) \ STATE(IDPF_VC_GET_PTYPE_INFO_ERR) \ + STATE(IDPF_VC_LOOPBACK_STATE) \ + STATE(IDPF_VC_LOOPBACK_STATE_ERR) \ STATE(IDPF_VC_NBITS) #define IDPF_GEN_ENUM(ENUM) ENUM,
@@ -208,6 +216,9 @@ enum idpf_vport_flags {/* Soft reset causes */ __IDPF_SR_Q_CHANGE,/* Soft reset to do queue change */ __IDPF_SR_Q_DESC_CHANGE, + __IDPF_SR_Q_SCH_CHANGE,/* Scheduling mode change in queue context */ + __IDPF_SR_MTU_CHANGE, + __IDPF_SR_RSC_CHANGE, __IDPF_SR_HSPLIT_CHANGE,/* To send delete queues message */ __IDPF_VPORT_DEL_QUEUES,
@@ -293,6 +304,7 @@ struct idpf_vport {#define IDPF_DIM_PROFILE_SLOTS 5u16 rx_itr_profile[IDPF_DIM_PROFILE_SLOTS ];u16 tx_itr_profile[IDPF_DIM_PROFILE_SLOTS ]; +struct rtnl_link_stats64 netstats;struct idpf_port_stats port_stats;bool link_up;
@@ -317,6 +329,13 @@ struct idpf_vport {spinlock_t mac_filter_list_lock; }; +enum idpf_user_flags { + __IDPF_PROMISC_UC =32 , + __IDPF_PROMISC_MC, + + __IDPF_USER_FLAGS_NBITS, +}; +struct idpf_rss_data {u16 rss_key_size;u8 *rss_key;
@@ -332,6 +351,7 @@ struct idpf_vport_user_config_data {u32 num_req_rx_qs;/* user requested RX queues through ethtool */ u32 num_req_txq_desc;/* user requested TX queue descriptors through ethtool */ u32 num_req_rxq_desc;/* user requested RX queue descriptors through ethtool */ +DECLARE_BITMAP (user_flags, __IDPF_USER_FLAGS_NBITS);struct list_head mac_filter_list; };
@@ -416,6 +436,7 @@ struct idpf_adapter {irqreturn_t (*irq_mb_handler)(int irq,void *data);/* vport structs */ +u32 tx_timeout_count;struct idpf_avail_queue_info avail_queues;/* array to store vports created by the driver */ struct idpf_vport **vports;
@@ -439,6 +460,8 @@ struct idpf_adapter {struct workqueue_struct *serv_wq;struct delayed_work vc_event_task;/* delayed virtchannel event task */ struct workqueue_struct *vc_event_wq; +struct delayed_work stats_task;/* delayed statistics task */ +struct workqueue_struct *stats_wq;struct virtchnl2_get_capabilities caps;wait_queue_head_t vchnl_wq;
@@ -635,6 +658,15 @@ static inline bool idpf_is_feature_ena(struct idpf_vport *vport,return vport->netdev->features & feature; } +/** +* idpf_get_max_tx_hdr_size -- get the size of tx header +* @adapter: Driver specific private structure +*/ +static inline u16 idpf_get_max_tx_hdr_size (struct idpf_adapter *adapter) +{ +return le16_to_cpu (adapter->caps.max_tx_hdr_size); +} +int idpf_vport_adjust_qs (struct idpf_vport *vport);int idpf_pf_probe (struct pci_dev *pdev,struct idpf_adapter *adapter);int idpf_vf_probe (struct pci_dev *pdev,struct idpf_adapter *adapter);
@@ -648,6 +680,7 @@ int idpf_intr_req(struct idpf_adapter *adapter);void idpf_intr_rel (struct idpf_adapter *adapter);int idpf_get_reg_intr_vecs (struct idpf_vport *vport,struct idpf_vec_regs *reg_vals); +u16 idpf_get_max_tx_hdr_size (struct idpf_adapter *adapter);int idpf_send_delete_queues_msg (struct idpf_vport *vport);int idpf_send_add_queues_msg (const struct idpf_vport *vport,u16 num_tx_q,u16 num_complq,u16 num_rx_q,u16 num_rx_bufq);
@@ -657,6 +690,7 @@ int idpf_send_enable_vport_msg(struct idpf_vport *vport);int idpf_send_disable_vport_msg (struct idpf_vport *vport);int idpf_send_destroy_vport_msg (struct idpf_vport *vport);int idpf_send_get_rx_ptype_msg (struct idpf_vport *vport); +int idpf_send_ena_dis_loopback_msg (struct idpf_vport *vport);int idpf_send_get_set_rss_key_msg (struct idpf_vport *vport,bool get);int idpf_send_get_set_rss_lut_msg (struct idpf_vport *vport,bool get);int idpf_send_dealloc_vectors_msg (struct idpf_adapter *adapter);
@@ -666,6 +700,7 @@ int idpf_req_rel_vector_indexes(struct idpf_adapter *adapter,u16 *q_vector_idxs, struct idpf_vector_info *vec_info);int idpf_vport_alloc_vec_indexes (struct idpf_vport *vport); +int idpf_send_get_stats_msg (struct idpf_vport *vport);int idpf_get_vec_ids (struct idpf_adapter *adapter,u16 *vecids,int num_vecids,struct virtchnl2_vector_chunks *chunks);
@@ -679,6 +714,7 @@ int idpf_vport_alloc_max_qs(struct idpf_adapter *adapter,void idpf_vport_dealloc_max_qs (struct idpf_adapter *adapter,struct idpf_vport_max_q *max_q);int idpf_add_del_mac_filters (struct idpf_vport *vport,bool add,bool async); +int idpf_set_promiscuous (struct idpf_vport *vport);int idpf_send_disable_queues_msg (struct idpf_vport *vport);void idpf_vport_init (struct idpf_vport *vport,struct idpf_vport_max_q *max_q);u32 idpf_get_vport_id (struct idpf_vport *vport);
drivers/net/ethernet/intel/idpf/idpf_lib.c +656 -3
805 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_main.c +3 -0
@@ -68,6 +68,8 @@ static int idpf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)/* idpf_pci_tbl - PCI Dev idpf ID Table */ static const struct pci_device_id idpf_pci_tbl[] = { + {PCI_VDEVICE (INTEL ,IDPF_DEV_ID_PF )}, + {PCI_VDEVICE (INTEL ,IDPF_DEV_ID_VF )}, {/* Sentinel */ } };MODULE_DEVICE_TABLE (pci, idpf_pci_tbl);
@@ -76,6 +78,7 @@ static struct pci_driver idpf_driver = { .name = KBUILD_MODNAME, .id_table = idpf_pci_tbl, .probe = idpf_probe, + .sriov_configure = idpf_sriov_configure, .remove = idpf_remove, .shutdown = idpf_shutdown, };
drivers/net/ethernet/intel/idpf/idpf_txrx.c +26 -0
@@ -33,6 +33,32 @@ static struct idpf_tx_stash *idpf_buf_lifo_pop(struct idpf_buf_lifo *stack)return stack->bufs[--stack->top]; } +/** +* idpf_tx_timeout - Respond to a Tx Hang +* @netdev: network interface device structure +* @txqueue: TX queue +*/ +void idpf_tx_timeout (struct net_device *netdev,unsigned int txqueue) +{ +struct idpf_vport *vport =idpf_netdev_to_vport (netdev); +struct idpf_adapter *adapter; + +if (!vport) +return ; + + adapter = vport->adapter; + adapter->tx_timeout_count++; + +netdev_err (netdev,"Detected Tx timeout: Count %d, Queue %d\n" , + adapter->tx_timeout_count, txqueue); +if (!idpf_is_reset_in_prog (adapter)) { +set_bit (__IDPF_HR_FUNC_RESET, adapter->flags); +queue_delayed_work (adapter->vc_event_wq, + &adapter->vc_event_task, +msecs_to_jiffies (10 )); + } +} +/** * idpf_tx_buf_rel - Release a Tx buffer * @tx_q: the queue that owns the buffer
drivers/net/ethernet/intel/idpf/idpf_txrx.h +2 -0
@@ -97,6 +97,7 @@ do { \#define IDPF_HDR_BUF_SIZE 256#define IDPF_PACKET_HDR_PAD \ (ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN * 2) +#define IDPF_TX_TSO_MIN_MSS 88/* Minimum number of descriptors between 2 descriptors with the RE bit set; * only relevant in flow scheduling mode
@@ -825,6 +826,7 @@ unsigned int idpf_tx_desc_count_required(struct idpf_queue *txq,bool idpf_chk_linearize (struct sk_buff *skb,unsigned int max_bufs,unsigned int count);int idpf_tx_maybe_stop_common (struct idpf_queue *tx_q,unsigned int size); +void idpf_tx_timeout (struct net_device *netdev,unsigned int txqueue);netdev_tx_t idpf_tx_splitq_start (struct sk_buff *skb,struct net_device *netdev); netdev_tx_t idpf_tx_singleq_start(struct sk_buff *skb,
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +199 -2
264 lines not on this page · raw message
Signature · 1 line
2.37.3
Re: [Intel-wired-lan] [PATCH net-next 14/15] idpf: add ethtool callbacks
In reply to Pavan Kumar Lingadrivers/net/ethernet/intel/idpf/idpf_ethtool.c line 1285
Quoted 13 lines
drivers/net/ethernet/intel/idpf/idpf_ethtool.c new file +13
-0+static int idpf_get_link_ksettings (struct net_device *netdev, +struct ethtool_link_ksettings *cmd) +{ +struct idpf_vport *vport =idpf_netdev_to_vport (netdev); + +if (!vport) +return -EINVAL ; + +ethtool_link_ksettings_zero_link_mode (cmd, supported); + cmd->base.autoneg =AUTONEG_DISABLE ; + cmd->base.port =PORT_NONE ; + cmd->base.duplex =DUPLEX_FULL ; + cmd->base.speed = vport->link_speed_mbps;
No supported modes, yet it has a duplex and a link speed?
Quoted 17 lines
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +17
-0+static void idpf_recv_event_msg (struct idpf_vport *vport) +{ +struct virtchnl2_event *v2e =NULL ; +bool link_status; +u32 event; + + v2e = (struct virtchnl2_event *)vport->vc_msg; + event =le32_to_cpu (v2e->event); + +switch (event) { +case VIRTCHNL2_EVENT_LINK_CHANGE : + vport->link_speed_mbps =le32_to_cpu (v2e->link_speed); + link_status = v2e->link_status; + +if (vport->link_up == link_status) +break ; +
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c line 38
Quoted 10 lines
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +10
-0+ vport->link_up = link_status; +if (vport->state == __IDPF_VPORT_UP) { +if (vport->link_up) { +netif_carrier_on (vport->netdev); +netif_tx_start_all_queues (vport->netdev); + }else { +netif_tx_stop_all_queues (vport->netdev); +netif_carrier_off (vport->netdev); + } + }
It has a link speed even when the carrier is off? This just makes me think the link speed is bogus, and you would be better reporting DUPLEX_UNKNOWN, SPEED_UNKNOWN. Or not even implementing ksettings, since you don't have anything meaningful to report.
Andrew
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Dear Pavan,
Thank you very much for the new driver. It’s a lot of code. ;-)
Am 29.03.23 um 16:03 schrieb Pavan Kumar Linga:
Quoted 21 lines
This patch series introduces the Infrastructure Data Path Function (IDPF) driver. It is used for both physical and virtual functions. Except for some of the device operations the rest of the functionality is the same for both PF and VF. IDPF uses virtchnl version2 opcodes and structures defined in the virtchnl2 header file which helps the driver to learn the capabilities and register offsets from the device Control Plane (CP) instead of assuming the default values.
The format of the series follows the driver init flow to interface open. To start with, probe gets called and kicks off the driver initialization by spawning the '
vc_event_task' work queue which in turn calls the 'hard reset' function. As part of that, the mailbox is initialized which is used to send/receive the virtchnl messages to/from the CP. Once that is done, 'core init' kicks in which requests all the required global resources from the CP and spawns the 'init_task' work queue to create the vports.Based on the capability information received, the driver creates the said number of vports (one or many) where each vport is associated to a netdev. Also, each vport has its own resources such as queues, vectors etc.
From there, rest of thenetdev_opsand data path are added.
Quoted 10 lines
IDPF implements both single queue which is traditional queueing model as well as split queue model. In split queue model, it uses separate queue for both completion descriptors and buffers which helps to implement out-of-order completions. It also helps to implement asymmetric queues, for example multiple RX completion queues can be processed by a single RX buffer queue and multiple TX buffer queues can be processed by a single TX completion queue. In single queue model, same queue is used for both descriptor completions as well as buffer completions. It also supports features such as generic checksum offload, generic receive offload (hardware GRO) etc.
[…]
Can you please elaborate on how the driver can be tested, and if tests are added to automatically test the driver?
Kind regards,
Paul
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Willem de Bruijn
Reviewed-by David Decotigny Reviewed-by Tested-by David Decotigny Tested-by on the v1 seriesQuoted 100 lines · Pavan Kumar Linga
This patch series introduces the Infrastructure Data Path Function (IDPF) driver. It is used for both physical and virtual functions. Except for some of the device operations the rest of the functionality is the same for both PF and VF. IDPF uses virtchnl version2 opcodes and structures defined in the virtchnl2 header file which helps the driver to learn the capabilities and register offsets from the device Control Plane (CP) instead of assuming the default values.
The format of the series follows the driver init flow to interface open. To start with, probe gets called and kicks off the driver initialization by spawning the '
vc_event_task' work queue which in turn calls the 'hard reset' function. As part of that, the mailbox is initialized which is used to send/receive the virtchnl messages to/from the CP. Once that is done, 'core init' kicks in which requests all the required global resources from the CP and spawns the 'init_task' work queue to create the vports.Based on the capability information received, the driver creates the said number of vports (one or many) where each vport is associated to a netdev. Also, each vport has its own resources such as queues, vectors etc. From there, rest of the
netdev_opsand data path are added.IDPF implements both single queue which is traditional queueing model as well as split queue model. In split queue model, it uses separate queue for both completion descriptors and buffers which helps to implement out-of-order completions. It also helps to implement asymmetric queues, for example multiple RX completion queues can be processed by a single RX buffer queue and multiple TX buffer queues can be processed by a single TX completion queue. In single queue model, same queue is used for both descriptor completions as well as buffer completions. It also supports features such as generic checksum offload, generic receive offload (hardware GRO) etc.
Pavan Kumar Linga (15):
virtchnl: add virtchnl version 2 ops
idpf: add module register and probe functionality
idpf: add controlq init and reset checks
idpf: add core init and interrupt request
idpf: add create vport and netdev configuration
idpf: continue expanding init task
idpf: configure resources for TX queues
idpf: configure resources for RX queues
idpf: initialize interrupts and enable vport
idpf: add splitqstart_xmit
idpf: add TX splitq napi poll support
idpf: add RX splitq napi poll support
idpf: add singleqstart_xmitand napi poll
idpf: add ethtool callbacks
idpf: configure SRIOV and add otherndo_ops.../device_drivers/ethernet/intel/idpf.rst | 46 + drivers/net/ethernet/intel/Kconfig | 11 + drivers/net/ethernet/intel/Makefile | 1 + drivers/net/ethernet/intel/idpf/Makefile | 18 + drivers/net/ethernet/intel/idpf/idpf.h | 734 +++ .../net/ethernet/intel/idpf/idpf_controlq.c | 644 +++ .../net/ethernet/intel/idpf/idpf_controlq.h | 131 + .../ethernet/intel/idpf/idpf_controlq_api.h | 190 + .../ethernet/intel/idpf/idpf_controlq_setup.c | 175 + drivers/net/ethernet/intel/idpf/idpf_dev.c | 179 + drivers/net/ethernet/intel/idpf/idpf_devids.h | 10 + .../net/ethernet/intel/idpf/idpf_ethtool.c | 1325 +++++ .../ethernet/intel/idpf/idpf_lan_pf_regs.h | 124 + .../net/ethernet/intel/idpf/idpf_lan_txrx.h | 293 + .../ethernet/intel/idpf/idpf_lan_vf_regs.h | 128 + drivers/net/ethernet/intel/idpf/idpf_lib.c | 2551 +++++++++ drivers/net/ethernet/intel/idpf/idpf_main.c | 85 + drivers/net/ethernet/intel/idpf/idpf_mem.h | 20 + .../ethernet/intel/idpf/idpf_singleq_txrx.c | 1262 +++++ drivers/net/ethernet/intel/idpf/idpf_txrx.c | 4850 +++++++++++++++++ drivers/net/ethernet/intel/idpf/idpf_txrx.h | 838 +++ drivers/net/ethernet/intel/idpf/idpf_vf_dev.c | 180 + .../net/ethernet/intel/idpf/idpf_virtchnl.c | 3802 +++++++++++++ drivers/net/ethernet/intel/idpf/virtchnl2.h | 1153 ++++ .../ethernet/intel/idpf/virtchnl2_lan_desc.h | 644 +++ 25 files changed, 19394 insertions(+) create mode 100644 Documentation/networking/device_drivers/ethernet/intel/idpf.rst create mode 100644 drivers/net/ethernet/intel/idpf/Makefile create mode 100644 drivers/net/ethernet/intel/idpf/idpf.h create mode 100644 drivers/net/ethernet/intel/idpf/idpf_controlq.c create mode 100644 drivers/net/ethernet/intel/idpf/idpf_controlq.h create mode 100644 drivers/net/ethernet/intel/idpf/idpf_controlq_api.h create mode 100644 drivers/net/ethernet/intel/idpf/idpf_controlq_setup.c create mode 100644 drivers/net/ethernet/intel/idpf/idpf_dev.c create mode 100644 drivers/net/ethernet/intel/idpf/idpf_devids.h create mode 100644 drivers/net/ethernet/intel/idpf/idpf_ethtool.c create mode 100644 drivers/net/ethernet/intel/idpf/idpf_lan_pf_regs.h create mode 100644 drivers/net/ethernet/intel/idpf/idpf_lan_txrx.h create mode 100644 drivers/net/ethernet/intel/idpf/idpf_lan_vf_regs.h create mode 100644 drivers/net/ethernet/intel/idpf/idpf_lib.c create mode 100644 drivers/net/ethernet/intel/idpf/idpf_main.c create mode 100644 drivers/net/ethernet/intel/idpf/idpf_mem.h create mode 100644 drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c create mode 100644 drivers/net/ethernet/intel/idpf/idpf_txrx.c create mode 100644 drivers/net/ethernet/intel/idpf/idpf_txrx.h create mode 100644 drivers/net/ethernet/intel/idpf/idpf_vf_dev.c create mode 100644 drivers/net/ethernet/intel/idpf/idpf_virtchnl.c create mode 100644 drivers/net/ethernet/intel/idpf/virtchnl2.h create mode 100644 drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h
Quoted 2 lines
--
2.37.3
We have been working with this driver at Google for well over a year through multiple revisions.
The current version runs in continuous testing with both functional (RSS, checksum, TSO/USO, HW-GRO, etc., many from tools/testing/selftests/net) and performance (github.com/google/neper tcp_stream, tcp_rr, etc. in variety of #threads and #flows configurations) tests, including ASAN, lockdep. The driver is also exercised continuously with more varied application workloads.
kernel test robot
build botRe: [Intel-wired-lan] [PATCH net-next 07/15] idpf: configure resources for TX queues
In reply to Pavan Kumar LingaThank you for the patch! Perhaps something to improve:
Hi Pavan,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Pavan-Kumar-Linga/virtchnl-add-virtchnl-version-2-ops/20230329-221347 patch link: https://lore.kernel.org/r/20230329140404.1647925-8-pavan.kumar.linga%40intel.com patch subject: [Intel-wired-lan] [PATCH net-next 07/15] idpf: configure resources for TX queues config: powerpc-allyesconfig (https://download.01.org/0day-ci/archive/20230330/[email protected]/config) compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project 67409911353323ca5edf2049ef0df54132fa1ca7)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install powerpc cross compiling tool for clang build
# apt-get install binutils-powerpc-linux-gnu
# https://github.com/intel-lab-lkp/linux/commit/306315c1a27395f92f28516fab2493fc68884130
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Pavan-Kumar-Linga/virtchnl-add-virtchnl-version-2-ops/20230329-221347
git checkout 306315c1a27395f92f28516fab2493fc68884130
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=powerpc olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=powerpc SHELL=/bin/bash drivers/net/ethernet/intel/idpf/ drivers/tty/serial/8250/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> drivers/net/ethernet/intel/idpf/idpf_virtchnl.c:2078:5: warning: stack frame size (1120) exceeds limit (1024) in 'idpf_vport_queue_ids_init' [-Wframe-larger-than]
int idpf_vport_queue_ids_init(struct idpf_vport *vport)
^76/1120 (6.79%) spills, 1044/1120 (93.21%) variables 1 warning generated.
vim +/idpf_vport_queue_ids_init +2078 drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
2070
2071 /**
2072 * idpf_vport_queue_ids_init - Initialize queue ids from Mailbox parameters
2073 * @vport: virtual port for which the queues ids are initialized
2074 *
2075 * Will initialize all queue ids with ids received as mailbox parameters.
2076 * Returns 0 on success, negative if all the queues are not initialized.
2077 */
> 2078 int idpf_vport_queue_ids_init(struct idpf_vport *vport)
2079 {
2080 struct virtchnl2_create_vport *vport_params;
2081 struct virtchnl2_queue_reg_chunks *chunks;
2082 struct idpf_vport_config *vport_config;
2083 u16 vport_idx = vport->idx;
2084 /* We may never deal with more than 256 same type of queues */
2085 #define IDPF_MAX_QIDS 256
2086 u32 qids[IDPF_MAX_QIDS];
2087 int num_ids;
2088 u16 q_type;
2089
2090 vport_config = vport->adapter->vport_config[vport_idx];
2091 if (vport_config->req_qs_chunks) {
2092 struct virtchnl2_add_queues *vc_aq =
2093 (struct virtchnl2_add_queues *)vport_config->req_qs_chunks;
2094 chunks = &vc_aq->chunks;
2095 } else {
2096 vport_params = (struct virtchnl2_create_vport *)
2097 vport->adapter->vport_params_recvd[vport_idx];
2098 chunks = &vport_params->chunks;
2099 }
2100
2101 num_ids = idpf_vport_get_queue_ids(qids, IDPF_MAX_QIDS,
2102 VIRTCHNL2_QUEUE_TYPE_TX,
2103 chunks);
2104 if (num_ids < vport->num_txq)
2105 return -EINVAL;
2106 num_ids = __idpf_vport_queue_ids_init(vport, qids, num_ids,
2107 VIRTCHNL2_QUEUE_TYPE_TX);
2108 if (num_ids < vport->num_txq)
2109 return -EINVAL;
2110
2111 if (!idpf_is_queue_model_split(vport->txq_model))
2112 return 0;
2113
2114 q_type = VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION;
2115 num_ids = idpf_vport_get_queue_ids(qids, IDPF_MAX_QIDS, q_type, chunks);
2116 if (num_ids < vport->num_complq)
2117 return -EINVAL;
2118 num_ids = __idpf_vport_queue_ids_init(vport, qids, num_ids, q_type);
2119 if (num_ids < vport->num_complq)
2120 return -EINVAL;
2121
2122 return 0;
2123 }
2124
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
kernel test robot
build botRe: [Intel-wired-lan] [PATCH net-next 07/15] idpf: configure resources for TX queues
In reply to Pavan Kumar LingaThank you for the patch! Perhaps something to improve:
Hi Pavan,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Pavan-Kumar-Linga/virtchnl-add-virtchnl-version-2-ops/20230329-221347 patch link: https://lore.kernel.org/r/20230329140404.1647925-8-pavan.kumar.linga%40intel.com patch subject: [Intel-wired-lan] [PATCH net-next 07/15] idpf: configure resources for TX queues config: csky-allmodconfig (https://download.01.org/0day-ci/archive/20230330/[email protected]/config) compiler: csky-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/306315c1a27395f92f28516fab2493fc68884130
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Pavan-Kumar-Linga/virtchnl-add-virtchnl-version-2-ops/20230329-221347
git checkout 306315c1a27395f92f28516fab2493fc68884130
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=csky olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=csky SHELL=/bin/bash drivers/net/ethernet/intel/idpf/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c: In function 'idpf_vport_queue_ids_init':
>> drivers/net/ethernet/intel/idpf/idpf_virtchnl.c:2123:1: warning: the frame size of 1028 bytes is larger than 1024 bytes [-Wframe-larger-than=]
2123 | }
| ^vim +2123 drivers/net/ethernet/intel/idpf/idpf_virtchnl.c
2070
2071 /**
2072 * idpf_vport_queue_ids_init - Initialize queue ids from Mailbox parameters
2073 * @vport: virtual port for which the queues ids are initialized
2074 *
2075 * Will initialize all queue ids with ids received as mailbox parameters.
2076 * Returns 0 on success, negative if all the queues are not initialized.
2077 */
2078 int idpf_vport_queue_ids_init(struct idpf_vport *vport)
2079 {
2080 struct virtchnl2_create_vport *vport_params;
2081 struct virtchnl2_queue_reg_chunks *chunks;
2082 struct idpf_vport_config *vport_config;
2083 u16 vport_idx = vport->idx;
2084 /* We may never deal with more than 256 same type of queues */
2085 #define IDPF_MAX_QIDS 256
2086 u32 qids[IDPF_MAX_QIDS];
2087 int num_ids;
2088 u16 q_type;
2089
2090 vport_config = vport->adapter->vport_config[vport_idx];
2091 if (vport_config->req_qs_chunks) {
2092 struct virtchnl2_add_queues *vc_aq =
2093 (struct virtchnl2_add_queues *)vport_config->req_qs_chunks;
2094 chunks = &vc_aq->chunks;
2095 } else {
2096 vport_params = (struct virtchnl2_create_vport *)
2097 vport->adapter->vport_params_recvd[vport_idx];
2098 chunks = &vport_params->chunks;
2099 }
2100
2101 num_ids = idpf_vport_get_queue_ids(qids, IDPF_MAX_QIDS,
2102 VIRTCHNL2_QUEUE_TYPE_TX,
2103 chunks);
2104 if (num_ids < vport->num_txq)
2105 return -EINVAL;
2106 num_ids = __idpf_vport_queue_ids_init(vport, qids, num_ids,
2107 VIRTCHNL2_QUEUE_TYPE_TX);
2108 if (num_ids < vport->num_txq)
2109 return -EINVAL;
2110
2111 if (!idpf_is_queue_model_split(vport->txq_model))
2112 return 0;
2113
2114 q_type = VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION;
2115 num_ids = idpf_vport_get_queue_ids(qids, IDPF_MAX_QIDS, q_type, chunks);
2116 if (num_ids < vport->num_complq)
2117 return -EINVAL;
2118 num_ids = __idpf_vport_queue_ids_init(vport, qids, num_ids, q_type);
2119 if (num_ids < vport->num_complq)
2120 return -EINVAL;
2121
2122 return 0;
> 2123 }
2124
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
Quoted 7 lines · Pavan Kumar Linga
This patch series introduces the Infrastructure Data Path Function (IDPF) driver. It is used for both physical and virtual functions. Except for some of the device operations the rest of the functionality is the same for both PF and VF. IDPF uses virtchnl version2 opcodes and structures defined in the virtchnl2 header file which helps the driver to learn the capabilities and register offsets from the device Control Plane (CP) instead of assuming the default values.
Isn't IDPF currently being "standardized" at OASIS?
Has a standard been ratified? Isn't it rather premature to merge a driver for a standard that doesn't exist?
Publicly posting pre-ratification work is often against the IP policies of standards orgs, are you even legally OK to post this?
Confused,
Jason
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Re: [Intel-wired-lan] [PATCH net-next 12/15] idpf: add RX splitq napi poll support
In reply to Pavan Kumar LingaQuoted 64 lines · Pavan Kumar Linga
From: Alan Brady <[email protected]>
Add support to handle interrupts for the RX completion queue and RX buffer queue. When the interrupt fires on RX completion queue, process the RX descriptors that are received. Allocate and prepare the SKB with the RX packet info, for both data and header buffer.
IDPF uses software maintained refill queues to manage buffers between RX queue producer and the buffer queue consumer. They are required in order to maintain a lockless buffer management system and are strictly software only constructs. Instead of updating the RX buffer queue tail with available buffers right after the clean routine, it posts the buffer ids to the refill queues, only to post them to the HW later.
If the generic receive offload (GRO) is enabled in the capabilities and turned on by default or via ethtool, then HW performs the packet coalescing if certain criteria are met by the incoming packets and updates the RX descriptor. Similar to GRO, if generic checksum is enabled, HW computes the checksum and updates the respective fields in the descriptor. Add support to update the SKB fields with the GRO and the generic checksum received.
Signed-off-by Alan Brady <[email protected]>Co-developed-by Joshua Hay <[email protected]>Signed-off-by Joshua Hay <[email protected]>Co-developed-by Madhu Chittim <[email protected]>Signed-off-by Madhu Chittim <[email protected]>Co-developed-by Phani Burra <[email protected]>Signed-off-by Phani Burra <[email protected]>Co-developed-by Pavan Kumar Linga <[email protected]>Signed-off-by Pavan Kumar Linga <[email protected]>Reviewed-by Sridhar Samudrala <[email protected]>--- drivers/net/ethernet/intel/idpf/idpf.h | 2 + drivers/net/ethernet/intel/idpf/idpf_txrx.c | 1000 ++++++++++++++++- drivers/net/ethernet/intel/idpf/idpf_txrx.h | 56 +- .../net/ethernet/intel/idpf/idpf_virtchnl.c | 4 +- 4 files changed, 1053 insertions(+), 9 deletions(-)drivers/net/ethernet/intel/idpf/idpf.h +2
-0@@ -14,6 +14,7 @@ struct idpf_vport_max_q;#include <linux/etherdevice.h> #include <linux/pci.h> #include <linux/bitfield.h> +#include <net/gro.h> #include <linux/dim.h> #include "virtchnl2.h" @@ -262,6 +263,7 @@ struct idpf_vport {u8 default_mac_addr[ETH_ALEN ];/* ITR profiles for the DIM algorithm */ #define IDPF_DIM_PROFILE_SLOTS 5 +u16 rx_itr_profile[IDPF_DIM_PROFILE_SLOTS ];u16 tx_itr_profile[IDPF_DIM_PROFILE_SLOTS ];bool link_up;drivers/net/ethernet/intel/idpf/idpf_txrx.c +0
-0
drivers/net/ethernet/intel/idpf/idpf_txrx.c static void idpf_rx_buf_rel(struct idpf_queue *rxq, · line 346
Quoted 8 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +5
-0@@ -339,6 +339,11 @@ static void idpf_rx_buf_rel(struct idpf_queue *rxq,idpf_rx_page_rel (rxq, &rx_buf->page_info[0 ]);if (PAGE_SIZE <8192 && rx_buf->buf_size >IDPF_RX_BUF_2048 )idpf_rx_page_rel (rxq, &rx_buf->page_info[1 ]); + +if (rx_buf->skb) { +dev_kfree_skb (rx_buf->skb); + rx_buf->skb =NULL ; + }
can you elaborate why you're introducing skb ptr to rx_buf if you have this ptr already on idpf_queue?
Quoted 11 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +4
-0}/** @@ -641,6 +646,28 @@ static bool idpf_rx_buf_hw_alloc_all(struct idpf_queue *rxbufq, u16 alloc_count)return !!alloc_count; } +/** +* idpf_rx_post_buf_refill - Post buffer id to refill queue +* @refillq: refill queue to post to +* @buf_id: buffer id to post
drivers/net/ethernet/intel/idpf/idpf_txrx.c static bool idpf_rx_buf_hw_alloc_all(struct idpf_queue *rxbufq, u16 alloc_count) · line 662
Quoted 10 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +10
-0+*/ +static void idpf_rx_post_buf_refill (struct idpf_sw_queue *refillq,u16 buf_id) +{ +u16 nta = refillq->next_to_alloc; + +/* store the buffer ID and the SW maintained GEN bit to the refillq */ + refillq->ring[nta] = + ((buf_id <<IDPF_RX_BI_BUFID_S ) &IDPF_RX_BI_BUFID_M ) | + (!!(test_bit (__IDPF_Q_GEN_CHK, refillq->flags)) << +IDPF_RX_BI_GEN_S );
do you explain anywhere in this patchset GEN bit usage?
Quoted 8 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +8
-0+ +if (unlikely (++nta == refillq->desc_count)) { + nta =0 ; +change_bit (__IDPF_Q_GEN_CHK, refillq->flags); + } + refillq->next_to_alloc = nta; +} +
[...]
Quoted 8 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +8
-0+/** +* idpf_rx_buf_adjust_pg - Prepare rx buffer for reuse +* @rx_buf: Rx buffer to adjust +* @size: Size of adjustment +* +* Update the offset within page so that rx buf will be ready to be reused. +* For systems with PAGE_SIZE < 8192 this function will flip the page offset +* so the second half of page assigned to rx buffer will be used, otherwise
drivers/net/ethernet/intel/idpf/idpf_txrx.c netdev_tx_t idpf_tx_splitq_start(struct sk_buff *skb, · line 3321
Quoted 10 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +10
-0+* the offset is moved by the @size bytes +*/ +static void idpf_rx_buf_adjust_pg (struct idpf_rx_buf *rx_buf,unsigned int size) +{ +struct idpf_page_info *pinfo; + + pinfo = &rx_buf->page_info[rx_buf->page_indx]; + +if (PAGE_SIZE <8192 ) +if (rx_buf->buf_size >IDPF_RX_BUF_2048 )
when buf_size can be non-2k?
Quoted 28 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +28
-0+/* flip to second page */ + rx_buf->page_indx = !rx_buf->page_indx; + else +/* flip page offset to other buffer */ + pinfo->page_offset ^= size; + else + pinfo->page_offset += size; +} + +/** +* idpf_rx_can_reuse_page - Determine if page can be reused for another rx +* @rx_buf: buffer containing the page +* +* If page is reusable, we have a green light for calling idpf_reuse_rx_page, +* which will assign the current buffer to the buffer that next_to_alloc is +* pointing to; otherwise, the dma mapping needs to be destroyed and +* page freed +*/ +static bool idpf_rx_can_reuse_page (struct idpf_rx_buf *rx_buf) +{ +unsigned int last_offset =PAGE_SIZE - rx_buf->buf_size; +struct idpf_page_info *pinfo; +unsigned int pagecnt_bias; +struct page *page; + + pinfo = &rx_buf->page_info[rx_buf->page_indx]; + pagecnt_bias = pinfo->pagecnt_bias; + page = pinfo->page;
drivers/net/ethernet/intel/idpf/idpf_txrx.c netdev_tx_t idpf_tx_splitq_start(struct sk_buff *skb, · line 3359
Quoted 10 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +10
-0+ +if (unlikely (!dev_page_is_reusable (page))) +return false; + +if (PAGE_SIZE <8192 ) { +/* For 2K buffers, we can reuse the page if we are the +* owner. For 4K buffers, we can reuse the page if there are +* no other others. +*/ +int reuse_bias = rx_buf->buf_size >IDPF_RX_BUF_2048 ?0 :1 ;
couldn't this be just:
bool reuse_bias = !(rx_buf->buf_size > IDPF_RX_BUF_2048);
this is a hot path so avoiding branches is worthy.
Quoted 19 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +19
-0+ +if (unlikely ((page_count (page) - pagecnt_bias) > reuse_bias)) +return false; + }else if (pinfo->page_offset > last_offset) { +return false; + } + +/* If we have drained the page fragment pool we need to update +* the pagecnt_bias and page count so that we fully restock the +* number of references the driver holds. +*/ +if (unlikely (pagecnt_bias ==1 )) { +page_ref_add (page,USHRT_MAX -1 ); + pinfo->pagecnt_bias =USHRT_MAX ; + } + +return true; +} +
[...]
Quoted 6 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +6
-0+/** +* idpf_rx_construct_skb - Allocate skb and populate it +* @rxq: Rx descriptor queue +* @rx_buf: Rx buffer to pull data from +* @size: the length of the packet +*
drivers/net/ethernet/intel/idpf/idpf_txrx.c netdev_tx_t idpf_tx_splitq_start(struct sk_buff *skb, · line 3456
Quoted 10 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +10
-0+* This function allocates an skb. It then populates it with the page +* data from the current receive descriptor, taking care to set up the +* skb correctly. +*/ +static struct sk_buff *idpf_rx_construct_skb (struct idpf_queue *rxq, +struct idpf_rx_buf *rx_buf, +unsigned int size) +{ +struct idpf_page_info *pinfo; +unsigned int headlen, truesize;
RCT please
drivers/net/ethernet/intel/idpf/idpf_txrx.c netdev_tx_t idpf_tx_splitq_start(struct sk_buff *skb, · line 3467
Quoted 11 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +11
-0+struct sk_buff *skb; +void *va; + + pinfo = &rx_buf->page_info[rx_buf->page_indx]; + va =page_address (pinfo->page) + pinfo->page_offset; + +/* prefetch first cache line of first page */ +net_prefetch (va); +/* allocate a skb to store the frags */ + skb =__napi_alloc_skb (&rxq->q_vector->napi,IDPF_RX_HDR_SIZE , +GFP_ATOMIC | __GFP_NOWARN);
any reason why no build_skb() support right from the start?
Quoted 44 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +44
-0+if (unlikely (!skb)) +return NULL ; + +skb_record_rx_queue (skb, rxq->idx); + +/* Determine available headroom for copy */ + headlen = size; +if (headlen >IDPF_RX_HDR_SIZE ) + headlen =eth_get_headlen (skb->dev, va,IDPF_RX_HDR_SIZE ); + +/* align pull length to size of long to optimize memcpy performance */ +memcpy (__skb_put (skb, headlen), va,ALIGN (headlen,sizeof (long ))); + +/* if we exhaust the linear part then add what is left as a frag */ + size -= headlen; +if (!size) { +/* buffer is unused, reset bias back to rx_buf; data was copied +* onto skb's linear part so there's no need for adjusting +* page offset and we can reuse this buffer as-is +*/ + pinfo->pagecnt_bias++; + +return skb; + } + + truesize =idpf_rx_frame_truesize (rx_buf, size); +skb_add_rx_frag (skb,0 , pinfo->page, + pinfo->page_offset + headlen, size, + truesize); +/* buffer is used by skb, update page_offset */ +idpf_rx_buf_adjust_pg (rx_buf, truesize); + +return skb; +} + +/** +* idpf_rx_hdr_construct_skb - Allocate skb and populate it from header buffer +* @rxq: Rx descriptor queue +* @hdr_buf: Rx buffer to pull data from +* @size: the length of the packet +* +* This function allocates an skb. It then populates it with the page data from +* the current receive descriptor, taking care to set up the skb correctly. +* This specifcally uses a header buffer to start building the skb.
drivers/net/ethernet/intel/idpf/idpf_txrx.c netdev_tx_t idpf_tx_splitq_start(struct sk_buff *skb, · line 3521
Quoted 10 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +10
-0+*/ +static struct sk_buff *idpf_rx_hdr_construct_skb (struct idpf_queue *rxq, +struct idpf_dma_mem *hdr_buf, +unsigned int size) +{ +struct sk_buff *skb; + +/* allocate a skb to store the frags */ + skb =__napi_alloc_skb (&rxq->q_vector->napi, size, +GFP_ATOMIC | __GFP_NOWARN);
ditto re: build_skb() comment
Quoted 60 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +60
-0+if (unlikely (!skb)) +return NULL ; + +skb_record_rx_queue (skb, rxq->idx); + +memcpy (__skb_put (skb, size), hdr_buf->va,ALIGN (size,sizeof (long ))); + +return skb; +} + +/** +* idpf_rx_splitq_test_staterr - tests bits in Rx descriptor +* status and error fields +* @stat_err_field: field from descriptor to test bits in +* @stat_err_bits: value to mask +* +*/ +static bool idpf_rx_splitq_test_staterr (const u8 stat_err_field, +const u8 stat_err_bits) +{ +return !!(stat_err_field & stat_err_bits); +} + +/** +* idpf_rx_splitq_is_eop - process handling of EOP buffers +* @rx_desc: Rx descriptor for current buffer +* +* If the buffer is an EOP buffer, this function exits returning true, +* otherwise return false indicating that this is in fact a non-EOP buffer. +*/ +static bool idpf_rx_splitq_is_eop (struct virtchnl2_rx_flex_desc_adv_nic_3 *rx_desc) +{ +/* if we are the last buffer then there is nothing else to do */ +return likely (idpf_rx_splitq_test_staterr (rx_desc->status_err0_qw1, +IDPF_RXD_EOF_SPLITQ )); +} + +/** +* idpf_rx_splitq_recycle_buf - Attempt to recycle or realloc buffer +* @rxbufq: receive queue +* @rx_buf: Rx buffer to pull data from +* +* This function will clean up the contents of the rx_buf. It will either +* recycle the buffer or unmap it and free the associated resources. The buffer +* will then be placed on a refillq where it will later be reclaimed by the +* corresponding bufq. +* +* This works based on page flipping. If we assume e.g., a 4k page, it will be +* divided into two 2k buffers. We post the first half to hardware and, after +* using it, flip to second half of the page with idpf_adjust_pg_offset and +* post that to hardware. The third time through we'll flip back to first half +* of page and check if stack is still using it, if not we can reuse the buffer +* as is, otherwise we'll drain it and get a new page. +*/ +static void idpf_rx_splitq_recycle_buf (struct idpf_queue *rxbufq, +struct idpf_rx_buf *rx_buf) +{ +struct idpf_page_info *pinfo = &rx_buf->page_info[rx_buf->page_indx]; + +if (idpf_rx_can_reuse_page (rx_buf))
drivers/net/ethernet/intel/idpf/idpf_txrx.c netdev_tx_t idpf_tx_splitq_start(struct sk_buff *skb, · line 3591
Quoted 10 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +10
-0+return ; + +/* we are not reusing the buffer so unmap it */ +dma_unmap_page_attrs (rxbufq->dev, pinfo->dma,PAGE_SIZE , +DMA_FROM_DEVICE ,IDPF_RX_DMA_ATTR ); +__page_frag_cache_drain (pinfo->page, pinfo->pagecnt_bias); + +/* clear contents of buffer_info */ + pinfo->page =NULL ; + rx_buf->skb =NULL ;
this skb NULLing is pointless to me. from the callsite of this function you operate strictly on a skb from idpf_queue.
Quoted 177 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +177
-0+ +/* It's possible the alloc can fail here but there's not much +* we can do, bufq will have to try and realloc to fill the +* hole. +*/ +idpf_alloc_page (rxbufq, pinfo); +} + +/** +* idpf_rx_splitq_clean - Clean completed descriptors from Rx queue +* @rxq: Rx descriptor queue to retrieve receive buffer queue +* @budget: Total limit on number of packets to process +* +* This function provides a "bounce buffer" approach to Rx interrupt +* processing. The advantage to this is that on systems that have +* expensive overhead for IOMMU access this provides a means of avoiding +* it by maintaining the mapping of the page to the system. +* +* Returns amount of work completed +*/ +static int idpf_rx_splitq_clean (struct idpf_queue *rxq,int budget) +{ +int total_rx_bytes =0 , total_rx_pkts =0 ; +struct idpf_queue *rx_bufq =NULL ; +struct sk_buff *skb = rxq->skb; +u16 ntc = rxq->next_to_clean; + +/* Process Rx packets bounded by budget */ +while (likely (total_rx_pkts < budget)) { +struct virtchnl2_rx_flex_desc_adv_nic_3 *rx_desc; +struct idpf_sw_queue *refillq =NULL ; +struct idpf_dma_mem *hdr_buf =NULL ; +struct idpf_rxq_set *rxq_set =NULL ; +struct idpf_rx_buf *rx_buf =NULL ; +union virtchnl2_rx_desc *desc; +unsigned int pkt_len =0 ; +unsigned int hdr_len =0 ; +u16 gen_id, buf_id =0 ; +/* Header buffer overflow only valid for header split */ +bool hbo = false; +int bufq_id; +u8 rxdid; + +/* get the Rx desc from Rx queue based on 'next_to_clean' */ + desc =IDPF_RX_DESC (rxq, ntc); + rx_desc = (struct virtchnl2_rx_flex_desc_adv_nic_3 *)desc; + +/* This memory barrier is needed to keep us from reading +* any other fields out of the rx_desc +*/ +dma_rmb (); + +/* if the descriptor isn't done, no work yet to do */ + gen_id =le16_to_cpu (rx_desc->pktlen_gen_bufq_id); + gen_id =FIELD_GET (VIRTCHNL2_RX_FLEX_DESC_ADV_GEN_M , gen_id); + +if (test_bit (__IDPF_Q_GEN_CHK, rxq->flags) != gen_id) +break ; + + rxdid =FIELD_GET (VIRTCHNL2_RX_FLEX_DESC_ADV_RXDID_M , + rx_desc->rxdid_ucast); +if (rxdid !=VIRTCHNL2_RXDID_2_FLEX_SPLITQ ) { +IDPF_RX_BUMP_NTC (rxq, ntc); +u64_stats_update_begin (&rxq->stats_sync); +u64_stats_inc (&rxq->q_stats.rx.bad_descs); +u64_stats_update_end (&rxq->stats_sync); +continue ; + } + + pkt_len =le16_to_cpu (rx_desc->pktlen_gen_bufq_id); + pkt_len =FIELD_GET (VIRTCHNL2_RX_FLEX_DESC_ADV_LEN_PBUF_M , + pkt_len); + + hbo =FIELD_GET (BIT (VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_HBO_S ), + rx_desc->status_err0_qw1); + +if (unlikely (hbo)) { +/* If a header buffer overflow, occurs, i.e. header is +* too large to fit in the header split buffer, HW will +* put the entire packet, including headers, in the +* data/payload buffer. +*/ +u64_stats_update_begin (&rxq->stats_sync); +u64_stats_inc (&rxq->q_stats.rx.hsplit_buf_ovf); +u64_stats_update_end (&rxq->stats_sync); + goto bypass_hsplit; + } + + hdr_len =le16_to_cpu (rx_desc->hdrlen_flags); + hdr_len =FIELD_GET (VIRTCHNL2_RX_FLEX_DESC_ADV_LEN_HDR_M , + hdr_len); + +bypass_hsplit: + bufq_id =le16_to_cpu (rx_desc->pktlen_gen_bufq_id); + bufq_id =FIELD_GET (VIRTCHNL2_RX_FLEX_DESC_ADV_BUFQ_ID_M , + bufq_id); + + rxq_set = container_of(rxq, struct idpf_rxq_set, rxq); +if (!bufq_id) + refillq = rxq_set->refillq0; +else + refillq = rxq_set->refillq1; + +/* retrieve buffer from the rxq */ + rx_bufq = &rxq->rxq_grp->splitq.bufq_sets[bufq_id].bufq; + + buf_id =le16_to_cpu (rx_desc->buf_id); + +if (pkt_len) { + rx_buf = &rx_bufq->rx_buf.buf[buf_id]; +idpf_rx_get_buf_page (rx_bufq->dev, rx_buf, pkt_len); + } + +if (hdr_len) { + hdr_buf = rx_bufq->rx_buf.hdr_buf[buf_id]; + +dma_sync_single_for_cpu (rxq->dev, hdr_buf->pa, hdr_buf->size, +DMA_FROM_DEVICE ); + + skb =idpf_rx_hdr_construct_skb (rxq, hdr_buf, hdr_len); +u64_stats_update_begin (&rxq->stats_sync); +u64_stats_inc (&rxq->q_stats.rx.hsplit_pkts); +u64_stats_update_end (&rxq->stats_sync); + } + +if (pkt_len) { +if (skb) +idpf_rx_add_frag (rx_buf, skb, pkt_len); +else + skb =idpf_rx_construct_skb (rxq, rx_buf, + pkt_len); + } + +/* exit if we failed to retrieve a buffer */ +if (!skb) { +/* If we fetched a buffer, but didn't use it +* undo pagecnt_bias decrement +*/ +if (rx_buf) + rx_buf->page_info[rx_buf->page_indx].pagecnt_bias++; +break ; + } + +if (rx_buf) +idpf_rx_splitq_recycle_buf (rx_bufq, rx_buf); +idpf_rx_post_buf_refill (refillq, buf_id); + +IDPF_RX_BUMP_NTC (rxq, ntc); +/* skip if it is non EOP desc */ +if (!idpf_rx_splitq_is_eop (rx_desc)) +continue ; + +/* pad skb if needed (to make valid ethernet frame) */ +if (eth_skb_pad (skb)) { + skb =NULL ; +continue ; + } + +/* probably a little skewed due to removing CRC */ + total_rx_bytes += skb->len; + +/* protocol */ +if (unlikely (idpf_rx_process_skb_fields (rxq, skb, rx_desc))) { +dev_kfree_skb_any (skb); + skb =NULL ; +continue ; + } + +/* send completed skb up the stack */ +napi_gro_receive (&rxq->q_vector->napi, skb); + skb =NULL ; + +/* update budget accounting */ + total_rx_pkts++; + } + + rxq->next_to_clean = ntc;
drivers/net/ethernet/intel/idpf/idpf_txrx.c netdev_tx_t idpf_tx_splitq_start(struct sk_buff *skb, · line 3778
Quoted 10 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +10
-0+ + rxq->skb = skb; +u64_stats_update_begin (&rxq->stats_sync); +u64_stats_add (&rxq->q_stats.rx.packets, total_rx_pkts); +u64_stats_add (&rxq->q_stats.rx.bytes, total_rx_bytes); +u64_stats_update_end (&rxq->stats_sync); + +/* guarantee a trip back through this routine if there was a failure */ +return total_rx_pkts; +}
keeping above func for a context
[...]
Quoted 167 lines
/**
*idpf_vport_intr_clean_queues- MSIX mode Interrupt Handler
* @irq: interrupt numberdrivers/net/ethernet/intel/idpf/idpf_txrx.c +99
-4@@ -3205,7 +4102,7 @@ static void idpf_net_dim(struct idpf_q_vector *q_vector)u32 i;if (!IDPF_ITR_IS_DYNAMIC (q_vector->tx_intr_mode)) -return ; + goto check_rx_itr;for (i =0 , packets =0 , bytes =0 ; i < q_vector->num_txq; i++) {struct idpf_queue *txq = q_vector->tx[i];@@ -3221,6 +4118,25 @@ static void idpf_net_dim(struct idpf_q_vector *q_vector)idpf_update_dim_sample (q_vector, &dim_sample, &q_vector->tx_dim, packets, bytes);net_dim (&q_vector->tx_dim, dim_sample); + +check_rx_itr: +if (!IDPF_ITR_IS_DYNAMIC (q_vector->rx_intr_mode)) +return ; + +for (i =0 , packets =0 , bytes =0 ; i < q_vector->num_rxq; i++) { +struct idpf_queue *rxq = q_vector->rx[i]; +unsigned int start; + +do { + start =u64_stats_fetch_begin (&rxq->stats_sync); + packets +=u64_stats_read (&rxq->q_stats.rx.packets); + bytes +=u64_stats_read (&rxq->q_stats.rx.bytes); + }while (u64_stats_fetch_retry (&rxq->stats_sync, start)); + } + +idpf_update_dim_sample (q_vector, &dim_sample, &q_vector->rx_dim, + packets, bytes); +net_dim (&q_vector->rx_dim, dim_sample); }/** @@ -3338,7 +4254,15 @@ static void idpf_vport_intr_ena_irq_all(struct idpf_vport *vport) true); } -if (qv->num_txq) +if (qv->num_rxq) { + dynamic =IDPF_ITR_IS_DYNAMIC (qv->rx_intr_mode); + itr = vport->rx_itr_profile[qv->rx_dim.profile_ix]; +idpf_vport_intr_write_itr (qv, dynamic ? + itr : qv->rx_itr_value, + false); + } + +if (qv->num_txq || qv->num_rxq)idpf_vport_intr_update_itr_ena_irq (qv); } }@@ -3381,6 +4305,32 @@ static void idpf_tx_dim_work(struct work_struct *work) dim->state =DIM_START_MEASURE ; } +/** +* idpf_rx_dim_work - Call back from the stack +* @work: work queue structure +*/ +static void idpf_rx_dim_work (struct work_struct *work) +{ +struct idpf_q_vector *q_vector; +struct idpf_vport *vport; +struct dim *dim; +u16 itr; + + dim = container_of(work, struct dim, work); + q_vector = container_of(dim, struct idpf_q_vector, rx_dim); + vport = q_vector->vport; + +if (dim->profile_ix >=ARRAY_SIZE (vport->rx_itr_profile)) + dim->profile_ix =ARRAY_SIZE (vport->rx_itr_profile) -1 ; + +/* look up the values in our local table */ + itr = vport->rx_itr_profile[dim->profile_ix]; + +idpf_vport_intr_write_itr (q_vector, itr, false); + + dim->state =DIM_START_MEASURE ; +} +/** * idpf_init_dim - Set up dynamic interrupt moderation * @qv: q_vector structure @@ -3390,6 +4340,10 @@ static void idpf_init_dim(struct idpf_q_vector *qv)INIT_WORK (&qv->tx_dim.work, idpf_tx_dim_work); qv->tx_dim.mode =DIM_CQ_PERIOD_MODE_START_FROM_EQE ; qv->tx_dim.profile_ix =IDPF_DIM_DEFAULT_PROFILE_IX ; + +INIT_WORK (&qv->rx_dim.work, idpf_rx_dim_work); + qv->rx_dim.mode =DIM_CQ_PERIOD_MODE_START_FROM_EQE ; + qv->rx_dim.profile_ix =IDPF_DIM_DEFAULT_PROFILE_IX ; }/** @@ -3437,6 +4391,44 @@ static bool idpf_tx_splitq_clean_all(struct idpf_q_vector *q_vec,return clean_complete; } +/** +* idpf_rx_splitq_clean_all- Clean completetion queues +* @q_vec: queue vector +* @budget: Used to determine if we are in netpoll +* @cleaned: returns number of packets cleaned +* +* Returns false if clean is not complete else returns true +*/ +static bool idpf_rx_splitq_clean_all (struct idpf_q_vector *q_vec,int budget, +int *cleaned) +{ +int num_rxq = q_vec->num_rxq; +bool clean_complete = true; +int pkts_cleaned =0 ; +int i, budget_per_q; + +/* We attempt to distribute budget to each Rx queue fairly, but don't +* allow the budget to go below 1 because that would exit polling early. +*/ + budget_per_q = num_rxq ?max (budget / num_rxq,1 ) :0 ; +for (i =0 ; i < num_rxq; i++) { +struct idpf_queue *rxq = q_vec->rx[i]; +int pkts_cleaned_per_q; + + pkts_cleaned_per_q =idpf_rx_splitq_clean (rxq, budget_per_q); +/* if we clean as many as budgeted, we must not be done */ +if (pkts_cleaned_per_q >= budget_per_q) + clean_complete = false; + pkts_cleaned += pkts_cleaned_per_q; + } + *cleaned = pkts_cleaned; + +for (i =0 ; i < q_vec->num_bufq; i++) +idpf_rx_clean_refillq_all (q_vec->bufq[i]); + +return clean_complete; +} +/** * idpf_vport_splitq_napi_poll - NAPI handler * @napi: struct from which you get q_vector @@ -3456,7 +4448,8 @@ static int idpf_vport_splitq_napi_poll(struct napi_struct *napi, int budget)return 0 ; } - clean_complete =idpf_tx_splitq_clean_all (q_vector, budget, &work_done); + clean_complete =idpf_rx_splitq_clean_all (q_vector, budget, &work_done); + clean_complete &=idpf_tx_splitq_clean_all (q_vector, budget, &work_done);/* If work not completed, return budget and polling will return */ if (!clean_complete)@@ -3810,7 +4803,6 @@ int idpf_init_rss(struct idpf_vport *vport)/** * idpf_deinit_rss - Release RSS resources * @vport: virtual port -* */ void idpf_deinit_rss (struct idpf_vport *vport) {drivers/net/ethernet/intel/idpf/idpf_txrx.h +0
-0
drivers/net/ethernet/intel/idpf/idpf_txrx.h line 66
Quoted 6 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.h +3
-0@@ -61,10 +61,21 @@#define IDPF_RX_BUFQ_WORKING_SET (rxq) ((rxq)->desc_count - 1) +#define IDPF_RX_BUMP_NTC (rxq, ntc) \ +do { \ + if (unlikely(++(ntc) == (rxq)->desc_count)) { \
desc_count won't change within single NAPI instance so i would rather store this to aux variable on stack and use this in this macro.
Quoted 19 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.h +8
-0+ ntc =0 ; \ +change_bit (__IDPF_Q_GEN_CHK, (rxq)->flags); \ + } \ +} while (0) + +#define IDPF_RX_HDR_SIZE 256#define IDPF_RX_BUF_2048 2048#define IDPF_RX_BUF_4096 4096#define IDPF_RX_BUF_STRIDE 32 +#define IDPF_RX_BUF_POST_STRIDE 16#define IDPF_LOW_WATERMARK 64 +/* Size of header buffer specifically for header split */ #define IDPF_HDR_BUF_SIZE 256#define IDPF_PACKET_HDR_PAD \ (ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN * 2)@@ -74,10 +85,18 @@*/ #define IDPF_TX_SPLITQ_RE_MIN_GAP 64
[...]
Jakub Kicinski
maintainerQuoted 11 lines · On Thu, 30 Mar 2023 09:03:09 -0300 Jason Gunthorpe wrote:
Quoted 7 lines · Pavan Kumar Linga
This patch series introduces the Infrastructure Data Path Function (IDPF) driver. It is used for both physical and virtual functions. Except for some of the device operations the rest of the functionality is the same for both PF and VF. IDPF uses virtchnl version2 opcodes and structures defined in the virtchnl2 header file which helps the driver to learn the capabilities and register offsets from the device Control Plane (CP) instead of assuming the default values.
Isn't IDPF currently being "standardized" at OASIS?
Quoted 7 lines
Has a standard been ratified? Isn't it rather premature to merge a driver for a standard that doesn't exist?
Publicly posting pre-ratification work is often against the IP policies of standards orgs, are you even legally OK to post this?
Confused,
And you called me politically motivated in the discussion about RDMA :| Vendor posts a driver, nothing special as far as netdev is concerned.
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Quoted 15 lines · Jakub Kicinski
Quoted 14 lines · On Thu, 30 Mar 2023 09:03:09 -0300 Jason Gunthorpe wrote:
Quoted 7 lines · Pavan Kumar Linga
This patch series introduces the Infrastructure Data Path Function (IDPF) driver. It is used for both physical and virtual functions. Except for some of the device operations the rest of the functionality is the same for both PF and VF. IDPF uses virtchnl version2 opcodes and structures defined in the virtchnl2 header file which helps the driver to learn the capabilities and register offsets from the device Control Plane (CP) instead of assuming the default values.
Isn't IDPF currently being "standardized" at OASIS?
Has a standard been ratified? Isn't it rather premature to merge a driver for a standard that doesn't exist?
Quoted 7 lines
Quoted 4 lines
Publicly posting pre-ratification work is often against the IP policies of standards orgs, are you even legally OK to post this?
Confused,
And you called me politically motivated in the discussion about RDMA :| Vendor posts a driver, nothing special as far as netdev is concerned.
The patches directly link to the OASIS working group, they need to explain WTF is going on here.
The published doucments they link to expressly say:
This is version 0.9 of IDPF Specification, to serve as basis for IDPF TC work. This is a work-in-progress document, and should not be used for implementation as is.
Further OASIS has a legal IPR policy that basically means Intel needs to publicly justify that their Signed-off-by is consisent with the kernel rules of the DCO. ie that they have a legal right to submit this IP to the kernel.
It is frequent that people make IPR mistakes, it is something maintainers should be double-checking when they are aware of it.
Frankly, this stopped being a "vendor driver" as soon as they linked to OASIS documents.
More broadly we have seen good success in Linux with the standards-first model. NVMe for example will not merge "vendor extensions" and the like that are not in the published ratified standard. It gives more power to the standards bodies and encourages vendor collaboration.
It is up to netdev community, but it looks pretty wild to see patches link to a supposed multi-vendor OASIS standard, put the implementation under net/ethernet/intel/idpf/ and come before standard ratification.
It is a legitimate question if that is how netdev community wants to manage its standard backed drivers.
Jason
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Quoted 38 lines · Paul Menzel
Dear Pavan,
Thank you very much for the new driver. It’s a lot of code. ;-)
Am 29.03.23 um 16:03 schrieb Pavan Kumar Linga:
Quoted 21 lines
This patch series introduces the Infrastructure Data Path Function (IDPF) driver. It is used for both physical and virtual functions. Except for some of the device operations the rest of the functionality is the same for both PF and VF. IDPF uses virtchnl version2 opcodes and structures defined in the virtchnl2 header file which helps the driver to learn the capabilities and register offsets from the device Control Plane (CP) instead of assuming the default values.
The format of the series follows the driver init flow to interface open. To start with, probe gets called and kicks off the driver initialization by spawning the '
vc_event_task' work queue which in turn calls the 'hard reset' function. As part of that, the mailbox is initialized which is used to send/receive the virtchnl messages to/from the CP. Once that is done, 'core init' kicks in which requests all the required global resources from the CP and spawns the 'init_task' work queue to create the vports.Based on the capability information received, the driver creates the said number of vports (one or many) where each vport is associated to a netdev. Also, each vport has its own resources such as queues, vectors etc. From there, rest of the
netdev_opsand data path are added.Quoted 10 lines
IDPF implements both single queue which is traditional queueing model as well as split queue model. In split queue model, it uses separate queue for both completion descriptors and buffers which helps to implement out-of-order completions. It also helps to implement asymmetric queues, for example multiple RX completion queues can be processed by a single RX buffer queue and multiple TX buffer queues can be processed by a single TX completion queue. In single queue model, same queue is used for both descriptor completions as well as buffer completions. It also supports features such as generic checksum offload, generic receive offload (hardware GRO) etc.
Quoted 5 lines
[…]
Can you please elaborate on how the driver can be tested, and if tests are added to automatically test the driver?
Not really sure on what tests are you referring to. Can you please elaborate on that part? We are looking into ways to provide remote access to the HW but don't have anything currently available. Will provide more details once that is sorted.
Quoted 3 lines
Kind regards,
Paul
Thanks,
Pavan
Re: [Intel-wired-lan] [PATCH net-next 14/15] idpf: add ethtool callbacks
In reply to Andrew LunnQuoted 8 lines · Andrew Lunn
Quoted 8 lines
drivers/net/ethernet/intel/idpf/idpf_ethtool.c new file +8
-0+static int idpf_get_link_ksettings (struct net_device *netdev, +struct ethtool_link_ksettings *cmd) +{ +struct idpf_vport *vport =idpf_netdev_to_vport (netdev); + +if (!vport) +return -EINVAL ; +
Quoted 9 lines
drivers/net/ethernet/intel/idpf/idpf_ethtool.c line 1285
Quoted 5 lines
drivers/net/ethernet/intel/idpf/idpf_ethtool.c new file +5
-0+ethtool_link_ksettings_zero_link_mode (cmd, supported); + cmd->base.autoneg =AUTONEG_DISABLE ; + cmd->base.port =PORT_NONE ; + cmd->base.duplex =DUPLEX_FULL ; + cmd->base.speed = vport->link_speed_mbps;No supported modes, yet it has a duplex and a link speed?
At present, the supported modes info is not provided by the device control plane but we do get the info on the speed.
Quoted 33 lines
Quoted 17 lines
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +17
-0+static void idpf_recv_event_msg (struct idpf_vport *vport) +{ +struct virtchnl2_event *v2e =NULL ; +bool link_status; +u32 event; + + v2e = (struct virtchnl2_event *)vport->vc_msg; + event =le32_to_cpu (v2e->event); + +switch (event) { +case VIRTCHNL2_EVENT_LINK_CHANGE : + vport->link_speed_mbps =le32_to_cpu (v2e->link_speed); + link_status = v2e->link_status; + +if (vport->link_up == link_status) +break ; +drivers/net/ethernet/intel/idpf/idpf_virtchnl.c line 38
Quoted 10 lines
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +10
-0+ vport->link_up = link_status; +if (vport->state == __IDPF_VPORT_UP) { +if (vport->link_up) { +netif_carrier_on (vport->netdev); +netif_tx_start_all_queues (vport->netdev); + }else { +netif_tx_stop_all_queues (vport->netdev); +netif_carrier_off (vport->netdev); + } + }It has a link speed even when the carrier is off? This just makes me think the link speed is bogus, and you would be better reporting
DUPLEX_UNKNOWN,SPEED_UNKNOWN. Or not even implementing ksettings, since you don't have anything meaningful to report.
Quoted 1 line
Andrew
You are right. When the carrier is off, the link speed should be set to unknown. Will fix it.
Thanks,
Pavan
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Re: [Intel-wired-lan] [PATCH net-next 01/15] virtchnl: add virtchnl version 2 ops
In reply to Pavan Kumar LingaQuoted 24 lines · Pavan Kumar Linga
Virtchnl version 1 is an interface used by the current generation of foundational NICs to negotiate the capabilities and configure the HW resources such as queues, vectors, RSS LUT, etc between the PF and VF drivers. It is not extensible to enable new features supported in the next generation of NICs/IPUs and to negotiate descriptor types, packet types and register offsets.
To overcome the limitations of the existing interface, introduce the virtchnl version 2 and add the necessary opcodes, structures, definitions, and descriptor formats. The driver also learns the data queue and other register offsets to use instead of hardcoding them. The advantage of this approach is that it gives the flexibility to modify the register offsets if needed, restrict the use of certain descriptor types and negotiate the supported packet types.
Following are the links to the specifications for reference
Virtchnl version1:
https://www.intel.com/content/dam/www/public/us/en/documents/
product-specifications/ethernet-adaptive-virtual-function-hardware-spec.pdfVirtchnl version2:
https://www.oasis-open.org/committees/documents.php?wg_abbrev=idpf
Quoted 12 lines
Co-developed-by Alan Brady <[email protected]>Signed-off-by Alan Brady <[email protected]>Co-developed-by Joshua Hay <[email protected]>Signed-off-by Joshua Hay <[email protected]>Co-developed-by Madhu Chittim <[email protected]>Signed-off-by Madhu Chittim <[email protected]>Co-developed-by Phani Burra <[email protected]>Signed-off-by Phani Burra <[email protected]>Co-developed-by Sridhar Samudrala <[email protected]>Signed-off-by Sridhar Samudrala <[email protected]>Signed-off-by Pavan Kumar Linga <[email protected]>Reviewed-by Sridhar Samudrala <[email protected]>
I guess this patchset has a while to run in review.
Some initial nits from my side, in case they are of any use to you.
...
drivers/net/ethernet/intel/idpf/virtchnl2.h line 644
Quoted 9 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +9
-0+/* Transmit queue config info */ +struct virtchnl2_txq_info { +__le64 dma_ring_addr; + +/* See VIRTCHNL2_QUEUE_TYPE definitions */ +__le32 type; + +__le32 queue_id; +/* Valid only if queue model is split and type is trasmit queue. Used
nit: s/trasmit/transmit/
...
drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h line 268
Quoted 7 lines
drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h new file +7
-0+/* Receive Descriptors */ +/* Splitq buf +* | 16| 0| +* ---------------------------------------------------------------- +* | RSV | Buffer ID | +* ---------------------------------------------------------------- +* | Rx packet buffer adresss |
nit: s/adresss/address
Quoted 2 lines
+ * ----------------------------------------------------------------
+ * | Rx header buffer adresss |
ditto
Quoted 5 lines
+ * ----------------------------------------------------------------
+ * | RSV |
+ * ----------------------------------------------------------------
+ * | 0|
+ */
drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h line 284
Quoted 9 lines
drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h new file +9
-0+struct virtchnl2_splitq_rx_buf_desc { +struct { +/* Buffer Identifier */ +__le16 buf_id; +__le16 rsvd0; +__le32 rsvd1; + } qword0; + +/* Packet buffer address */
ditto
Review
Quoted 2 lines
(quoted diff) +2
-0+ __le64 pkt_addr; + /* Header buffer address */
ditto
drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h line 289
Quoted 3 lines
drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h new file +3
-0+__le64 hdr_addr; +__le64 rsvd2; +};/* RX buffer descriptor format */
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Re: [Intel-wired-lan] [PATCH net-next 04/15] idpf: add core init and interrupt request
In reply to Pavan Kumar LingaQuoted 19 lines · Pavan Kumar Linga
As the mailbox is setup, add the necessary send and receive mailbox message framework to support the virtchnl communication between the driver and device Control Plane (CP).
Add the core initialization. To start with, driver confirms the virtchnl version with the CP. Once that is done, it requests and gets the required capabilities and resources needed such as max vectors, queues etc.
Based on the vector information received in '
VIRTCHNL2_OP_GET_CAPS', request the stack to allocate the required vectors. Finally add the interrupt handling mechanism for the mailbox queue and enable the interrupt.Note: Checkpatch issues a warning about
IDPF_FOREACH_VPORT_VC_STATEandIDPF_GEN_STRINGbeing complex macros and should be enclosed in parentheses but it's not the case. They are never used as a statement and instead only used to define the enum and array.
Quoted 14 lines
Co-developed-by Alan Brady <[email protected]>Signed-off-by Alan Brady <[email protected]>Co-developed-by Emil Tantilov <[email protected]>Signed-off-by Emil Tantilov <[email protected]>Co-developed-by Joshua Hay <[email protected]>Signed-off-by Joshua Hay <[email protected]>Co-developed-by Madhu Chittim <[email protected]>Signed-off-by Madhu Chittim <[email protected]>Co-developed-by Phani Burra <[email protected]>Signed-off-by Phani Burra <[email protected]>Co-developed-by Shailendra Bhatnagar <[email protected]>Signed-off-by Shailendra Bhatnagar <[email protected]>Signed-off-by Pavan Kumar Linga <[email protected]>Reviewed-by Sridhar Samudrala <[email protected]>
More spelling nits from my side.
...
Quoted 1 line
drivers/net/ethernet/intel/idpf/idpf.h +0
-0
...
drivers/net/ethernet/intel/idpf/idpf.h struct idpf_dev_ops { · line 125
Quoted 11 lines
drivers/net/ethernet/intel/idpf/idpf.h +11
-0+/* Stack to maintain vector indexes used for 'vector distribution' algorithm */ +struct idpf_vector_lifo { +/* Vector stack maintains all the relative vector indexes at the +* *adapter* level. This stack is divided into 2 parts, first one is +* called as 'default pool' and other one is called 'free pool'. +* Vector distribution algorithm gives priority to default vports in +* a way that at least IDPF_MIN_Q_VEC vectors are allocated per +* default vport and the relative vector indexes for those are +* maintained in default pool. Free pool contains all the unallocated +* vector indexes which can be allocated on-demand basis. +* Mailbox vector index is maitained in the default pool of the stack
s/maitained/maintained/
Quoted 1 line
drivers/net/ethernet/intel/idpf/idpf.h +1
-0+*/
...
Quoted 1 line
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +0
-0
...
Quoted 5 lines
+/**
+ *idpf_recv_get_caps_msg- Receive virtchnl get capabilities message
+ * @adapter: Driver specific private structure
+ *
+ * Receive virtchnl get capabilities message. Returns 0 on succes, negative on
s/succes/success/
...
Quoted 3 lines
+/**
+ *idpf_vc_core_deinit- Device deinit routine
+ * @adapter: Driver specific private structue
s/structue/structure/
...
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Re: [Intel-wired-lan] [PATCH net-next 05/15] idpf: add create vport and netdev configuration
In reply to Pavan Kumar LingaQuoted 8 lines · Pavan Kumar Linga
Add the required support to create a vport by spawning the init task. Once the vport is created, initialize and allocate the resources needed for it. Configure and register a netdev for each vport with all the features supported by the device based on the capabilities received from the device Control Plane. Spawn the init task till all the default vports are created.
Quoted 12 lines
Co-developed-by Alan Brady <[email protected]>Signed-off-by Alan Brady <[email protected]>Co-developed-by Joshua Hay <[email protected]>Signed-off-by Joshua Hay <[email protected]>Co-developed-by Madhu Chittim <[email protected]>Signed-off-by Madhu Chittim <[email protected]>Co-developed-by Phani Burra <[email protected]>Signed-off-by Phani Burra <[email protected]>Co-developed-by Shailendra Bhatnagar <[email protected]>Signed-off-by Shailendra Bhatnagar <[email protected]>Signed-off-by Pavan Kumar Linga <[email protected]>Reviewed-by Sridhar Samudrala <[email protected]>
Some spelling nits from my side.
Quoted 1 line
drivers/net/ethernet/intel/idpf/idpf_lib.c +0
-0
...
Quoted 4 lines
+/**
+ *idpf_decfg_netdev- Unregister the netdev
+ * @vport: vport for which netdev to be unregistred
+ */
s/unregistred/unregistered/
Quoted 3 lines
+/**
+ *idpf_deinit_task- Device deinit routine
+ * @adapter: Driver specific private structue
s/structue/structure/
Quoted 4 lines
+ *
+ * Extended remove logic which will be used for
+ * hard reset as well
+ */
...
Re: [Intel-wired-lan] [PATCH net-next 06/15] idpf: continue expanding init task
In reply to Pavan Kumar LingaQuoted 5 lines · Pavan Kumar Linga
Add the virtchnl support to request the packet types. Parse the responses received from CP and based on the protocol headers, populate the packet type structure with necessary information. Initialize the MAC address and add the virtchnl support to add and del MAC address.
Quoted 12 lines
Co-developed-by Alan Brady <[email protected]>Signed-off-by Alan Brady <[email protected]>Co-developed-by Joshua Hay <[email protected]>Signed-off-by Joshua Hay <[email protected]>Co-developed-by Madhu Chittim <[email protected]>Signed-off-by Madhu Chittim <[email protected]>Co-developed-by Phani Burra <[email protected]>Signed-off-by Phani Burra <[email protected]>Co-developed-by Shailendra Bhatnagar <[email protected]>Signed-off-by Shailendra Bhatnagar <[email protected]>Signed-off-by Pavan Kumar Linga <[email protected]>Reviewed-by Sridhar Samudrala <[email protected]>
Another spelling nit from my side.
Quoted 1 line
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +0
-0
...
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c u32 idpf_get_vport_id(struct idpf_vport *vport) · line 1789
Quoted 13 lines
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +9
-0@@ -1432,3 +1778,139 @@ u32 idpf_get_vport_id(struct idpf_vport *vport)return le32_to_cpu (vport_msg->vport_id); } + +/** +* idpf_add_del_mac_filters - Add/del mac filters +* @vport: virtual port data structure +* @add: Add or delete flag +* @async: Don't wait for return message +* +* Returns 0 on success, error on failre. +**/
s/failre/failure/
...
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Re: [Intel-wired-lan] [PATCH net-next 07/15] idpf: configure resources for TX queues
In reply to Pavan Kumar LingaQuoted 25 lines · Pavan Kumar Linga
From: Alan Brady <[email protected]>
IDPF supports two queue models i.e. single queue which is a traditional queueing model as well as split queue model. In single queue model, the same descriptor queue is used by SW to post descriptors to the HW, HW to post completed descriptors to SW. In split queue model, "TX Queues" are used to pass buffers from SW to HW and "TX Completion Queues" are used to post descriptor completions from HW to SW. Device supports asymmetric ratio of TX queues to TX completion queues. Considering this, queue group mechanism is used i.e. some TX queues are grouped together which will be serviced by only one TX completion queue per TX queue group.
Add all the resources required for the TX queues initialization. To start with, allocate memory for the TX queue groups, TX queues and TX completion queues. Then, allocate the descriptors for both TX and TX completion queues, and bookkeeping buffers for TX queues alone. Also, allocate queue vectors for the vport and initialize the TX queue related fields for each queue vector.
Initialize the queue parameters such as
q_id,q_typeand tail register offset with the info received from the device control plane (CP). Once all the TX queues are configured, send config TX queue virtchnl message to the CP with all the TX queue context information.
Quoted 10 lines
Signed-off-by Alan Brady <[email protected]>Co-developed-by Alice Michael <[email protected]>Signed-off-by Alice Michael <[email protected]>Co-developed-by Joshua Hay <[email protected]>Signed-off-by Joshua Hay <[email protected]>Co-developed-by Phani Burra <[email protected]>Signed-off-by Phani Burra <[email protected]>Co-developed-by Pavan Kumar Linga <[email protected]>Signed-off-by Pavan Kumar Linga <[email protected]>Reviewed-by Sridhar Samudrala <[email protected]>
Another spelling nit from me.
...
Quoted 1 line
drivers/net/ethernet/intel/idpf/idpf_txrx.h +0
-0
...
Quoted 25 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.h +25
-0+/* queue associated with a vport */ +struct idpf_queue { +struct device *dev;/* Used for DMA mapping */ +struct idpf_vport *vport;/* Backreference to associated vport */ +struct idpf_txq_group *txq_grp; +/* bufq: Used as group id, either 0 or 1, on clean bufq uses this +* index to determine which group of refill queues to clean. +* Bufqs are use in splitq only. +* txq: Index to map between txq group and hot path Tx ptrs stored in +* vport. Used in both singleq/splitq +*/ +u16 idx; +/* Used for both queue models single and split. In splitq model relevant +* only to txq +*/ +void __iomem *tail; +/* Used in both singleq and splitq */ +struct idpf_tx_buf *tx_buf; +u16 q_type; +/* Queue id(Tx/Tx compl/Rx/Bufq) */ +u32 q_id; +u16 desc_count;/* Number of descriptors */ + +/* Relevant in both split & single txq & bufq */ +u16 next_to_use;
drivers/net/ethernet/intel/idpf/idpf_txrx.h struct idpf_intr_reg { · line 266
Quoted 10 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.h +10
-0+/* In split q model only relevant for tx complq and rxq */ +u16 next_to_clean;/* used in interrupt processing */ +/* Used only for Rx. In splitq model only relevant to rxq */ +u16 next_to_alloc; +/* Generation bit check stored, as HW flips the bit at Queue end */ +DECLARE_BITMAP (flags, __IDPF_Q_FLAGS_NBITS); + +/* Used for both queue models single and split. In splitq model relavant +* only to Tx compl Q and Rx compl Q +*/
s/relavant/relevant/
...
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Re: [Intel-wired-lan] [PATCH net-next 09/15] idpf: initialize interrupts and enable vport
In reply to Pavan Kumar LingaQuoted 13 lines · Pavan Kumar Linga
To further continue 'vport open', initialize all the resources required for the interrupts. To start with, initialize the queue vector indices with the ones received from the device Control Plane. Now that all the TX and RX queues are initialized, map the RX descriptor and buffer queues as well as TX completion queues to the allocated vectors. Initialize and enable the napi handler for the napi polling. Finally, request the IRQs for the interrupt vectors from the stack and setup the interrupt handler.
Once the interrupt init is done, send 'map queue vector', 'enable queues' and 'enable vport' virtchnl messages to the CP to complete the 'vport open' flow.
Quoted 10 lines
Co-developed-by Alan Brady <[email protected]>Signed-off-by Alan Brady <[email protected]>Co-developed-by Joshua Hay <[email protected]>Signed-off-by Joshua Hay <[email protected]>Co-developed-by Madhu Chittim <[email protected]>Signed-off-by Madhu Chittim <[email protected]>Co-developed-by Phani Burra <[email protected]>Signed-off-by Phani Burra <[email protected]>Signed-off-by Pavan Kumar Linga <[email protected]>Reviewed-by Sridhar Samudrala <[email protected]>
Spelling from me again.
I think I'll stop there and just mention that you might want to consider adding ./checkpatch.pl --codespell to your CI.
Quoted 1 line
drivers/net/ethernet/intel/idpf/idpf_lib.c +0
-0
...
Quoted 6 lines
+/**
+ *idpf_up_complete- Complete interface up sequence
+ * @vport: virtual port strucutre
+ *
+ * Returns 0 on success, negative on failure.
+ */
s/strucutre/structure/
...
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Posting on behalf of Michael Orr, Intel.
====
I am Michael Orr, from Intel
I am the Convener of IDPF TC at Oasis, and the Author of IDPF charter, so Probably the right Person to answer this.
Due to tech issues in getting subscribed, I am asking my Colleague to post this into the thread.
Bottom line: There is no issue in publishing this driver, and no conflict with OASIS IDPF TC.
See point-by-point below
Quoted 11 lines · Jason Gunthorpe
Quoted 10 lines · Jakub Kicinski
Quoted 9 lines · On Thu, 30 Mar 2023 09:03:09 -0300 Jason Gunthorpe wrote:
Quoted 7 lines · Pavan Kumar Linga
This patch series introduces the Infrastructure Data Path Function (IDPF) driver. It is used for both physical and virtual functions. Except for some of the device operations the rest of the functionality is the same for both PF and VF. IDPF uses virtchnl version2 opcodes and structures defined in the virtchnl2 header file which helps the driver to learn the capabilities and register offsets from the device Control Plane (CP) instead of assuming the default values.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Isn't IDPF currently being "standardized" at OASIS?
IDPF is indeed being Standardized at OASIS. Everyone is free (AND INVITED!) to join the work.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Has a standard been ratified? Isn't it rather premature to merge a driver for a standard that doesn't exist?
The Standard has not been ratified. Work has just started recently. When IDPF TC members finish the work and vote to approve the result THAT version will be the OASIS Standard IDPF specification, and will have a reference driver to accompany it, likely labeled V1.0
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Publicly posting pre-ratification work is often against the IP policies of standards orgs, are you even legally OK to post this?
Publishing this driver does not go against any IP policy of OASIS or the IDPF TC. There is no legal issue.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Confused,
And you called me politically motivated in the discussion about RDMA :| Vendor posts a driver, nothing special as far as netdev is concerned.
The patches directly link to the OASIS working group, they need to explain WTF is going on here.
As explained in the Charter, Intel & Google are donating the current Vendor driver & its spec to the IDPF TC to serve as a starting point for an eventual vendor-agnostic Spec & Driver that will be the OASIS IDPF standard set.
Quoted 6 lines
The published doucments they link to expressly say:
This is version 0.9 of IDPF Specification, to serve as basis for IDPF TC work. This is a work-in-progress document, and should not be used for implementation as is.
Since I wrote this: This is intended to state that version 0.9 is NOT *the* OASIS IDPF TC driver, just a base to start working from. We know the current version is not vendor independent and that it is likely changes will be added by the IDPF TC.
Quoted 5 lines
Further OASIS has a legal IPR policy that basically means Intel needs to publicly justify that their Signed-off-by is consisent with the kernel rules of the DCO. ie that they have a legal right to submit this IP to the kernel.
OASIS does NOT have such a legal IPR policy. The only IPR policy that applies to the IDPF TC members is the “Non-assert” IPR policy as stated in the Charter.
Any IDPF TC member company is free to publish any vendor driver they choose to. What they Publish is simply then their driver, and not an implementation of the OASIS IDPF Standard.
IDPF Charter (And draft spec, and all other documents and mailings) are here:
https://www.oasis-open.org/committees/documents.php?wg_abbrev=idpf&show_descriptions=yes
OASIS IPR Policies for TC’s are here: https://www.oasis-open.org/policies-guidelines/ipr/
Quoted 18 lines
It is frequent that people make IPR mistakes, it is something maintainers should be double-checking when they are aware of it.
Frankly, this stopped being a "vendor driver" as soon as they linked to OASIS documents.
More broadly we have seen good success in Linux with the standards-first model. NVMe for example will not merge "vendor extensions" and the like that are not in the published ratified standard. It gives more power to the standards bodies and encourages vendor collaboration.
It is up to netdev community, but it looks pretty wild to see patches link to a supposed multi-vendor OASIS standard, put the implementation under
net/ethernet/intel/idpf/and come before standard ratification.
Quoted 4 lines
It is a legitimate question if that is how netdev community wants to manage its standard backed drivers.
Jason
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Re: [Intel-wired-lan] [PATCH net-next 01/15] virtchnl: add virtchnl version 2 ops
In reply to Pavan Kumar Lingadrivers/net/ethernet/intel/idpf/virtchnl2.h
Quoted 45 lines · Pavan Kumar Linga
Virtchnl version 1 is an interface used by the current generation of foundational NICs to negotiate the capabilities and configure the HW resources such as queues, vectors, RSS LUT, etc between the PF and VF drivers. It is not extensible to enable new features supported in the next generation of NICs/IPUs and to negotiate descriptor types, packet types and register offsets.
To overcome the limitations of the existing interface, introduce the virtchnl version 2 and add the necessary opcodes, structures, definitions, and descriptor formats. The driver also learns the data queue and other register offsets to use instead of hardcoding them. The advantage of this approach is that it gives the flexibility to modify the register offsets if needed, restrict the use of certain descriptor types and negotiate the supported packet types.
Following are the links to the specifications for reference
Virtchnl version1:
https://www.intel.com/content/dam/www/public/us/en/documents/
product-specifications/ethernet-adaptive-virtual-function-hardware-spec.pdfVirtchnl version2:
https://www.oasis-open.org/committees/documents.php?wg_abbrev=idpfCo-developed-by Alan Brady <[email protected]>Signed-off-by Alan Brady <[email protected]>Co-developed-by Joshua Hay <[email protected]>Signed-off-by Joshua Hay <[email protected]>Co-developed-by Madhu Chittim <[email protected]>Signed-off-by Madhu Chittim <[email protected]>Co-developed-by Phani Burra <[email protected]>Signed-off-by Phani Burra <[email protected]>Co-developed-by Sridhar Samudrala <[email protected]>Signed-off-by Sridhar Samudrala <[email protected]>Signed-off-by Pavan Kumar Linga <[email protected]>Reviewed-by Sridhar Samudrala <[email protected]>--- drivers/net/ethernet/intel/idpf/virtchnl2.h | 1153 +++++++++++++++++ .../ethernet/intel/idpf/virtchnl2_lan_desc.h | 644 +++++++++ 2 files changed, 1797 insertions(+)create mode 100644
drivers/net/ethernet/intel/idpf/virtchnl2.hcreate mode 100644drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.hdrivers/net/ethernet/intel/idpf/virtchnl2.h +0
-0
If this is to be a standardized interface, why is this header buried in the driver specific directory instead of something more accessible like include/linux/idpf?
Quoted 18 lines
new file mode 100644
index 000000000000..a6e57df2c35fdrivers/net/ethernet/intel/idpf/virtchnl2.h new file +13
-0@@ -0,0 +1,1153 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright (C) 2023 Intel Corporation */ + +#ifndef _VIRTCHNL2_H_ +#define _VIRTCHNL2_H_ + +/* All opcodes associated with virtchnl 2 are prefixed with virtchnl2 or +* VIRTCHNL2. Any future opcodes, offloads/capabilities, structures, +* and defines must be prefixed with virtchnl2 or VIRTCHNL2 to avoid confusion. +* +* PF/VF uses the virtchnl interface defined in this header file to communicate +* with device Control Plane (CP). Driver and the CP may run on different +* platforms with different endianness. To avoid byte order discrepancies,
drivers/net/ethernet/intel/idpf/virtchnl2.h line 23
Quoted 10 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +10
-0+* struct members in this header follow little-endian format. Users of this +* virtchnl interface are expected to convert back to their native endian +* format. +*/ + +#include "virtchnl2_lan_desc.h" + +/* VIRTCHNL2_ERROR_CODES */ +/* Success */ +#define VIRTCHNL2_STATUS_SUCCESS 0
Shouldn't these be enum and not #define?
Quoted 28 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +28
-0+/* Operation not permitted, used in case of command not permitted for sender */ +#define VIRTCHNL2_STATUS_ERR_EPERM 1 +/* Bad opcode - virtchnl interface problem */ +#define VIRTCHNL2_STATUS_ERR_ESRCH 3 +/* I/O error - HW access error */ +#define VIRTCHNL2_STATUS_ERR_EIO 5 +/* No such resource - Referenced resource is not allacated */ +#define VIRTCHNL2_STATUS_ERR_ENXIO 6 +/* Permission denied - Resource is not permitted to caller */ +#define VIRTCHNL2_STATUS_ERR_EACCES 13 +/* Device or resource busy - In case shared resource is in use by others */ +#define VIRTCHNL2_STATUS_ERR_EBUSY 16 +/* Object already exists and not free */ +#define VIRTCHNL2_STATUS_ERR_EEXIST 17 +/* Invalid input argument in command */ +#define VIRTCHNL2_STATUS_ERR_EINVAL 22 +/* No space left or allocation failure */ +#define VIRTCHNL2_STATUS_ERR_ENOSPC 28 +/* Parameter out of range */ +#define VIRTCHNL2_STATUS_ERR_ERANGE 34 + +/* Op not allowed in current dev mode */ +#define VIRTCHNL2_STATUS_ERR_EMODE 200 +/* State Machine error - Command sequence problem */ +#define VIRTCHNL2_STATUS_ERR_ESM 201 + +/* This macro is used to generate compilation errors if a structure +* is not exactly the correct length.
drivers/net/ethernet/intel/idpf/virtchnl2.h line 61
Quoted 10 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +10
-0+*/ +#define VIRTCHNL2_CHECK_STRUCT_LEN (n,X ) \ + static_assert((n) == sizeof(struct X)) + +/* New major set of opcodes introduced and so leaving room for +* old misc opcodes to be added in future. Also these opcodes may only +* be used if both the PF and VF have successfully negotiated the +* VIRTCHNL version as 2.0 during VIRTCHNL2_OP_VERSION exchange. +*/ +#define VIRTCHNL2_OP_UNKNOWN 0
I think these also should be enum.
Quoted 54 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +54
-0+#define VIRTCHNL2_OP_VERSION 1 +#define VIRTCHNL2_OP_GET_CAPS 500 +#define VIRTCHNL2_OP_CREATE_VPORT 501 +#define VIRTCHNL2_OP_DESTROY_VPORT 502 +#define VIRTCHNL2_OP_ENABLE_VPORT 503 +#define VIRTCHNL2_OP_DISABLE_VPORT 504 +#define VIRTCHNL2_OP_CONFIG_TX_QUEUES 505 +#define VIRTCHNL2_OP_CONFIG_RX_QUEUES 506 +#define VIRTCHNL2_OP_ENABLE_QUEUES 507 +#define VIRTCHNL2_OP_DISABLE_QUEUES 508 +#define VIRTCHNL2_OP_ADD_QUEUES 509 +#define VIRTCHNL2_OP_DEL_QUEUES 510 +#define VIRTCHNL2_OP_MAP_QUEUE_VECTOR 511 +#define VIRTCHNL2_OP_UNMAP_QUEUE_VECTOR 512 +#define VIRTCHNL2_OP_GET_RSS_KEY 513 +#define VIRTCHNL2_OP_SET_RSS_KEY 514 +#define VIRTCHNL2_OP_GET_RSS_LUT 515 +#define VIRTCHNL2_OP_SET_RSS_LUT 516 +#define VIRTCHNL2_OP_GET_RSS_HASH 517 +#define VIRTCHNL2_OP_SET_RSS_HASH 518 +#define VIRTCHNL2_OP_SET_SRIOV_VFS 519 +#define VIRTCHNL2_OP_ALLOC_VECTORS 520 +#define VIRTCHNL2_OP_DEALLOC_VECTORS 521 +#define VIRTCHNL2_OP_EVENT 522 +#define VIRTCHNL2_OP_GET_STATS 523 +#define VIRTCHNL2_OP_RESET_VF 524 +#define VIRTCHNL2_OP_GET_EDT_CAPS 525 +#define VIRTCHNL2_OP_GET_PTYPE_INFO 526 +/* Opcode 527 and 528 are reserved for VIRTCHNL2_OP_GET_PTYPE_ID and +* VIRTCHNL2_OP_GET_PTYPE_INFO_RAW. +* Opcodes 529, 530, 531, 532 and 533 are reserved. +*/ +#define VIRTCHNL2_OP_LOOPBACK 534 +#define VIRTCHNL2_OP_ADD_MAC_ADDR 535 +#define VIRTCHNL2_OP_DEL_MAC_ADDR 536 +#define VIRTCHNL2_OP_CONFIG_PROMISCUOUS_MODE 537 + +/* VIRTCHNL2_VPORT_TYPE +* Type of virtual port +*/ +#define VIRTCHNL2_VPORT_TYPE_DEFAULT 0 + +/* VIRTCHNL2_QUEUE_MODEL +* Type of queue model +* +* In the single queue model, the same transmit descriptor queue is used by +* software to post descriptors to hardware and by hardware to post completed +* descriptors to software. +* Likewise, the same receive descriptor queue is used by hardware to post +* completions to software and by software to post buffers to hardware. +*/ +#define VIRTCHNL2_QUEUE_MODEL_SINGLE 0 +/* In the split queue model, hardware uses transmit completion queues to post +* descriptor/buffer completions to software, while software uses transmit
drivers/net/ethernet/intel/idpf/virtchnl2.h line 125
Quoted 10 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +10
-0+* descriptor queues to post descriptors to hardware. +* Likewise, hardware posts descriptor completions to the receive descriptor +* queue, while software uses receive buffer queues to post buffers to hardware. +*/ +#define VIRTCHNL2_QUEUE_MODEL_SPLIT 1 + +/* VIRTCHNL2_CHECKSUM_OFFLOAD_CAPS +* Checksum offload capability flags +*/ +#define VIRTCHNL2_CAP_TX_CSUM_L3_IPV4 BIT(0)
More enums... I'll stop here with the enum comments, but really anywhere you have a collection of constants enum is preferred.
Quoted 17 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +17
-0+#define VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_TCP BIT(1) +#define VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_UDP BIT(2) +#define VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_SCTP BIT(3) +#define VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_TCP BIT(4) +#define VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_UDP BIT(5) +#define VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_SCTP BIT(6) +#define VIRTCHNL2_CAP_TX_CSUM_GENERIC BIT(7) +#define VIRTCHNL2_CAP_RX_CSUM_L3_IPV4 BIT(8) +#define VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_TCP BIT(9) +#define VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_UDP BIT(10) +#define VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_SCTP BIT(11) +#define VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_TCP BIT(12) +#define VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_UDP BIT(13) +#define VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_SCTP BIT(14) +#define VIRTCHNL2_CAP_RX_CSUM_GENERIC BIT(15) +#define VIRTCHNL2_CAP_TX_CSUM_L3_SINGLE_TUNNEL BIT(16) +#define VIRTCHNL2_CAP_TX_CSUM_L3_DOUBLE_TUNNEL BIT(17)
drivers/net/ethernet/intel/idpf/virtchnl2.h line 152
Quoted 10 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +10
-0+#define VIRTCHNL2_CAP_RX_CSUM_L3_SINGLE_TUNNEL BIT(18) +#define VIRTCHNL2_CAP_RX_CSUM_L3_DOUBLE_TUNNEL BIT(19) +#define VIRTCHNL2_CAP_TX_CSUM_L4_SINGLE_TUNNEL BIT(20) +#define VIRTCHNL2_CAP_TX_CSUM_L4_DOUBLE_TUNNEL BIT(21) +#define VIRTCHNL2_CAP_RX_CSUM_L4_SINGLE_TUNNEL BIT(22) +#define VIRTCHNL2_CAP_RX_CSUM_L4_DOUBLE_TUNNEL BIT(23) + +/* VIRTCHNL2_SEGMENTATION_OFFLOAD_CAPS +* Segmentation offload capability flags +*/
You might use the comment starter "/**" on many of these struct and enum headers in order to make use of the kernel-doc tool for code documentation generation.
Quoted 257 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +257
-0+#define VIRTCHNL2_CAP_SEG_IPV4_TCP BIT(0) +#define VIRTCHNL2_CAP_SEG_IPV4_UDP BIT(1) +#define VIRTCHNL2_CAP_SEG_IPV4_SCTP BIT(2) +#define VIRTCHNL2_CAP_SEG_IPV6_TCP BIT(3) +#define VIRTCHNL2_CAP_SEG_IPV6_UDP BIT(4) +#define VIRTCHNL2_CAP_SEG_IPV6_SCTP BIT(5) +#define VIRTCHNL2_CAP_SEG_GENERIC BIT(6) +#define VIRTCHNL2_CAP_SEG_TX_SINGLE_TUNNEL BIT(7) +#define VIRTCHNL2_CAP_SEG_TX_DOUBLE_TUNNEL BIT(8) + +/* VIRTCHNL2_RSS_FLOW_TYPE_CAPS +* Receive Side Scaling Flow type capability flags +*/ +#define VIRTCHNL2_CAP_RSS_IPV4_TCP BIT_ULL(0) +#define VIRTCHNL2_CAP_RSS_IPV4_UDP BIT_ULL(1) +#define VIRTCHNL2_CAP_RSS_IPV4_SCTP BIT_ULL(2) +#define VIRTCHNL2_CAP_RSS_IPV4_OTHER BIT_ULL(3) +#define VIRTCHNL2_CAP_RSS_IPV6_TCP BIT_ULL(4) +#define VIRTCHNL2_CAP_RSS_IPV6_UDP BIT_ULL(5) +#define VIRTCHNL2_CAP_RSS_IPV6_SCTP BIT_ULL(6) +#define VIRTCHNL2_CAP_RSS_IPV6_OTHER BIT_ULL(7) +#define VIRTCHNL2_CAP_RSS_IPV4_AH BIT_ULL(8) +#define VIRTCHNL2_CAP_RSS_IPV4_ESP BIT_ULL(9) +#define VIRTCHNL2_CAP_RSS_IPV4_AH_ESP BIT_ULL(10) +#define VIRTCHNL2_CAP_RSS_IPV6_AH BIT_ULL(11) +#define VIRTCHNL2_CAP_RSS_IPV6_ESP BIT_ULL(12) +#define VIRTCHNL2_CAP_RSS_IPV6_AH_ESP BIT_ULL(13) + +/* VIRTCHNL2_HEADER_SPLIT_CAPS +* Header split capability flags +*/ +/* For prepended metadata */ +#define VIRTCHNL2_CAP_RX_HSPLIT_AT_L2 BIT(0) +/* All VLANs go into header buffer */ +#define VIRTCHNL2_CAP_RX_HSPLIT_AT_L3 BIT(1) +#define VIRTCHNL2_CAP_RX_HSPLIT_AT_L4V4 BIT(2) +#define VIRTCHNL2_CAP_RX_HSPLIT_AT_L4V6 BIT(3) + +/* VIRTCHNL2_RSC_OFFLOAD_CAPS +* Receive Side Coalescing offload capability flags +*/ +#define VIRTCHNL2_CAP_RSC_IPV4_TCP BIT(0) +#define VIRTCHNL2_CAP_RSC_IPV4_SCTP BIT(1) +#define VIRTCHNL2_CAP_RSC_IPV6_TCP BIT(2) +#define VIRTCHNL2_CAP_RSC_IPV6_SCTP BIT(3) + +/* VIRTCHNL2_OTHER_CAPS +* Other capability flags +* SPLITQ_QSCHED: Queue based scheduling using split queue model +* TX_VLAN: VLAN tag insertion +* RX_VLAN: VLAN tag stripping +*/ +#define VIRTCHNL2_CAP_RDMA BIT_ULL(0) +#define VIRTCHNL2_CAP_SRIOV BIT_ULL(1) +#define VIRTCHNL2_CAP_MACFILTER BIT_ULL(2) +#define VIRTCHNL2_CAP_FLOW_DIRECTOR BIT_ULL(3) +#define VIRTCHNL2_CAP_SPLITQ_QSCHED BIT_ULL(4) +#define VIRTCHNL2_CAP_CRC BIT_ULL(5) +#define VIRTCHNL2_CAP_ADQ BIT_ULL(6) +#define VIRTCHNL2_CAP_WB_ON_ITR BIT_ULL(7) +#define VIRTCHNL2_CAP_PROMISC BIT_ULL(8) +#define VIRTCHNL2_CAP_LINK_SPEED BIT_ULL(9) +#define VIRTCHNL2_CAP_INLINE_IPSEC BIT_ULL(10) +#define VIRTCHNL2_CAP_LARGE_NUM_QUEUES BIT_ULL(11) +/* Require additional info */ +#define VIRTCHNL2_CAP_VLAN BIT_ULL(12) +#define VIRTCHNL2_CAP_PTP BIT_ULL(13) +/* EDT: Earliest Departure Time capability used for Timing Wheel */ +#define VIRTCHNL2_CAP_EDT BIT_ULL(14) +#define VIRTCHNL2_CAP_ADV_RSS BIT_ULL(15) +#define VIRTCHNL2_CAP_FDIR BIT_ULL(16) +#define VIRTCHNL2_CAP_RX_FLEX_DESC BIT_ULL(17) +#define VIRTCHNL2_CAP_PTYPE BIT_ULL(18) +#define VIRTCHNL2_CAP_LOOPBACK BIT_ULL(19) +/* Enable miss completion types plus ability to detect a miss completion if a +* reserved bit is set in a standared completion's tag. +*/ +#define VIRTCHNL2_CAP_MISS_COMPL_TAG BIT_ULL(20) +/* This must be the last capability */ +#define VIRTCHNL2_CAP_OEM BIT_ULL(63) + +/* VIRTCHNL2_DEVICE_TYPE */ +/* Underlying device type */ +#define VIRTCHNL2_MEV_DEVICE 0 + +/* VIRTCHNL2_TXQ_SCHED_MODE +* Transmit Queue Scheduling Modes - Queue mode is the legacy mode i.e. inorder +* completions where descriptors and buffers are completed at the same time. +* Flow scheduling mode allows for out of order packet processing where +* descriptors are cleaned in order, but buffers can be completed out of order. +*/ +#define VIRTCHNL2_TXQ_SCHED_MODE_QUEUE 0 +#define VIRTCHNL2_TXQ_SCHED_MODE_FLOW 1 + +/* VIRTCHNL2_TXQ_FLAGS +* Transmit Queue feature flags +* +* Enable rule miss completion type; packet completion for a packet +* sent on exception path; only relevant in flow scheduling mode. +*/ +#define VIRTCHNL2_TXQ_ENABLE_MISS_COMPL BIT(0) + +/* VIRTCHNL2_PEER_TYPE +* Transmit mailbox peer type +*/ +#define VIRTCHNL2_RDMA_CPF 0 +#define VIRTCHNL2_NVME_CPF 1 +#define VIRTCHNL2_ATE_CPF 2 +#define VIRTCHNL2_LCE_CPF 3 + +/* VIRTCHNL2_RXQ_FLAGS +* Receive Queue Feature flags +*/ +#define VIRTCHNL2_RXQ_RSC BIT(0) +#define VIRTCHNL2_RXQ_HDR_SPLIT BIT(1) +/* When set, packet descriptors are flushed by hardware immediately after +* processing each packet. +*/ +#define VIRTCHNL2_RXQ_IMMEDIATE_WRITE_BACK BIT(2) +#define VIRTCHNL2_RX_DESC_SIZE_16BYTE BIT(3) +#define VIRTCHNL2_RX_DESC_SIZE_32BYTE BIT(4) + +/* VIRTCHNL2_RSS_ALGORITHM +* Type of RSS algorithm +*/ +#define VIRTCHNL2_RSS_ALG_TOEPLITZ_ASYMMETRIC 0 +#define VIRTCHNL2_RSS_ALG_R_ASYMMETRIC 1 +#define VIRTCHNL2_RSS_ALG_TOEPLITZ_SYMMETRIC 2 +#define VIRTCHNL2_RSS_ALG_XOR_SYMMETRIC 3 + +/* VIRTCHNL2_EVENT_CODES +* Type of event +*/ +#define VIRTCHNL2_EVENT_UNKNOWN 0 +#define VIRTCHNL2_EVENT_LINK_CHANGE 1 +/* Event type 2, 3 are reserved */ + +/* VIRTCHNL2_QUEUE_TYPE +* Transmit and Receive queue types are valid in legacy as well as split queue +* models. With Split Queue model, 2 additional types are introduced - +* TX_COMPLETION and RX_BUFFER. In split queue model, receive corresponds to +* the queue where hardware posts completions. +*/ +#define VIRTCHNL2_QUEUE_TYPE_TX 0 +#define VIRTCHNL2_QUEUE_TYPE_RX 1 +#define VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION 2 +#define VIRTCHNL2_QUEUE_TYPE_RX_BUFFER 3 +#define VIRTCHNL2_QUEUE_TYPE_CONFIG_TX 4 +#define VIRTCHNL2_QUEUE_TYPE_CONFIG_RX 5 +/* Queue types 6, 7, 8, 9 are reserved */ +#define VIRTCHNL2_QUEUE_TYPE_MBX_TX 10 +#define VIRTCHNL2_QUEUE_TYPE_MBX_RX 11 + +/* VIRTCHNL2_ITR_IDX +* Virtchannel interrupt throttling rate index +*/ +#define VIRTCHNL2_ITR_IDX_0 0 +#define VIRTCHNL2_ITR_IDX_1 1 + +/* VIRTCHNL2_MAC_TYPE +* VIRTCHNL2_MAC_ADDR_PRIMARY +* PF/VF driver should set @type to VIRTCHNL2_MAC_ADDR_PRIMARY for the +* primary/device unicast MAC address filter for VIRTCHNL2_OP_ADD_MAC_ADDR and +* VIRTCHNL2_OP_DEL_MAC_ADDR. This allows for the underlying control plane +* function to accurately track the MAC address and for VM/function reset. +* +* VIRTCHNL2_MAC_ADDR_EXTRA +* PF/VF driver should set @type to VIRTCHNL2_MAC_ADDR_EXTRA for any extra +* unicast and/or multicast filters that are being added/deleted via +* VIRTCHNL2_OP_ADD_MAC_ADDR/VIRTCHNL2_OP_DEL_MAC_ADDR respectively. +*/ +#define VIRTCHNL2_MAC_ADDR_PRIMARY 1 +#define VIRTCHNL2_MAC_ADDR_EXTRA 2 + +/* VIRTCHNL2_PROMISC_FLAGS +* Flags used for promiscuous mode +*/ +#define VIRTCHNL2_UNICAST_PROMISC BIT(0) +#define VIRTCHNL2_MULTICAST_PROMISC BIT(1) + +/* VIRTCHNL2_PROTO_HDR_TYPE +* Protocol header type within a packet segment. A segment consists of one or +* more protocol headers that make up a logical group of protocol headers. Each +* logical group of protocol headers encapsulates or is encapsulated using/by +* tunneling or encapsulation protocols for network virtualization. +*/ +/* VIRTCHNL2_PROTO_HDR_ANY is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_ANY 0 +#define VIRTCHNL2_PROTO_HDR_PRE_MAC 1 +/* VIRTCHNL2_PROTO_HDR_MAC is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_MAC 2 +#define VIRTCHNL2_PROTO_HDR_POST_MAC 3 +#define VIRTCHNL2_PROTO_HDR_ETHERTYPE 4 +#define VIRTCHNL2_PROTO_HDR_VLAN 5 +#define VIRTCHNL2_PROTO_HDR_SVLAN 6 +#define VIRTCHNL2_PROTO_HDR_CVLAN 7 +#define VIRTCHNL2_PROTO_HDR_MPLS 8 +#define VIRTCHNL2_PROTO_HDR_UMPLS 9 +#define VIRTCHNL2_PROTO_HDR_MMPLS 10 +#define VIRTCHNL2_PROTO_HDR_PTP 11 +#define VIRTCHNL2_PROTO_HDR_CTRL 12 +#define VIRTCHNL2_PROTO_HDR_LLDP 13 +#define VIRTCHNL2_PROTO_HDR_ARP 14 +#define VIRTCHNL2_PROTO_HDR_ECP 15 +#define VIRTCHNL2_PROTO_HDR_EAPOL 16 +#define VIRTCHNL2_PROTO_HDR_PPPOD 17 +#define VIRTCHNL2_PROTO_HDR_PPPOE 18 +/* VIRTCHNL2_PROTO_HDR_IPV4 is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_IPV4 19 +/* IPv4 and IPv6 Fragment header types are only associated to +* VIRTCHNL2_PROTO_HDR_IPV4 and VIRTCHNL2_PROTO_HDR_IPV6 respectively, +* cannot be used independently. +*/ +/* VIRTCHNL2_PROTO_HDR_IPV4_FRAG is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_IPV4_FRAG 20 +/* VIRTCHNL2_PROTO_HDR_IPV6 is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_IPV6 21 +/* VIRTCHNL2_PROTO_HDR_IPV6_FRAG is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_IPV6_FRAG 22 +#define VIRTCHNL2_PROTO_HDR_IPV6_EH 23 +/* VIRTCHNL2_PROTO_HDR_UDP is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_UDP 24 +/* VIRTCHNL2_PROTO_HDR_TCP is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_TCP 25 +/* VIRTCHNL2_PROTO_HDR_SCTP is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_SCTP 26 +/* VIRTCHNL2_PROTO_HDR_ICMP is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_ICMP 27 +/* VIRTCHNL2_PROTO_HDR_ICMPV6 is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_ICMPV6 28 +#define VIRTCHNL2_PROTO_HDR_IGMP 29 +#define VIRTCHNL2_PROTO_HDR_AH 30 +#define VIRTCHNL2_PROTO_HDR_ESP 31 +#define VIRTCHNL2_PROTO_HDR_IKE 32 +#define VIRTCHNL2_PROTO_HDR_NATT_KEEP 33 +/* VIRTCHNL2_PROTO_HDR_PAY is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_PAY 34 +#define VIRTCHNL2_PROTO_HDR_L2TPV2 35 +#define VIRTCHNL2_PROTO_HDR_L2TPV2_CONTROL 36 +#define VIRTCHNL2_PROTO_HDR_L2TPV3 37 +#define VIRTCHNL2_PROTO_HDR_GTP 38 +#define VIRTCHNL2_PROTO_HDR_GTP_EH 39 +#define VIRTCHNL2_PROTO_HDR_GTPCV2 40 +#define VIRTCHNL2_PROTO_HDR_GTPC_TEID 41 +#define VIRTCHNL2_PROTO_HDR_GTPU 42 +#define VIRTCHNL2_PROTO_HDR_GTPU_UL 43 +#define VIRTCHNL2_PROTO_HDR_GTPU_DL 44 +#define VIRTCHNL2_PROTO_HDR_ECPRI 45 +#define VIRTCHNL2_PROTO_HDR_VRRP 46 +#define VIRTCHNL2_PROTO_HDR_OSPF 47 +/* VIRTCHNL2_PROTO_HDR_TUN is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_TUN 48 +#define VIRTCHNL2_PROTO_HDR_GRE 49 +#define VIRTCHNL2_PROTO_HDR_NVGRE 50 +#define VIRTCHNL2_PROTO_HDR_VXLAN 51 +#define VIRTCHNL2_PROTO_HDR_VXLAN_GPE 52 +#define VIRTCHNL2_PROTO_HDR_GENEVE 53
drivers/net/ethernet/intel/idpf/virtchnl2.h line 419
Quoted 10 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +10
-0+#define VIRTCHNL2_PROTO_HDR_NSH 54 +#define VIRTCHNL2_PROTO_HDR_QUIC 55 +#define VIRTCHNL2_PROTO_HDR_PFCP 56 +#define VIRTCHNL2_PROTO_HDR_PFCP_NODE 57 +#define VIRTCHNL2_PROTO_HDR_PFCP_SESSION 58 +#define VIRTCHNL2_PROTO_HDR_RTP 59 +#define VIRTCHNL2_PROTO_HDR_ROCE 60 +#define VIRTCHNL2_PROTO_HDR_ROCEV1 61 +#define VIRTCHNL2_PROTO_HDR_ROCEV2 62 +/* Protocol ids up to 32767 are reserved for AVF use */
Why are we mentioning AVF here? Is this supposed to be Virtchnl2 use?
drivers/net/ethernet/intel/idpf/virtchnl2.h line 425
Quoted 6 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +6
-0+/* 32768 - 65534 are used for user defined protocol ids */ +/* VIRTCHNL2_PROTO_HDR_NO_PROTO is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_NO_PROTO 65535 + +#define VIRTCHNL2_VERSION_MAJOR_2 2 +#define VIRTCHNL2_VERSION_MINOR_0 0
If this is related to the IDPF spec version, why is it not 0.9? If this is something else, what happened to major version 1?
drivers/net/ethernet/intel/idpf/virtchnl2.h line 437
Quoted 12 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +12
-0+ +/* VIRTCHNL2_OP_GET_EDT_CAPS +* Get EDT granularity and time horizon +*/ +struct virtchnl2_edt_caps { +/* Timestamp granularity in nanoseconds */ +__le64 tstamp_granularity_ns; +/* Total time window in nanoseconds */ +__le64 time_horizon_ns; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (16 , virtchnl2_edt_caps);
Don't put a space between the struct and the check.
Quoted 358 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +358
-0+ +/* VIRTCHNL2_OP_VERSION +* PF/VF posts its version number to the CP. CP responds with its version number +* in the same format, along with a return code. +* If there is a major version mismatch, then the PF/VF cannot operate. +* If there is a minor version mismatch, then the PF/VF can operate but should +* add a warning to the system log. +* +* This version opcode MUST always be specified as == 1, regardless of other +* changes in the API. The CP must always respond to this message without +* error regardless of version mismatch. +*/ +struct virtchnl2_version_info { +__le32 major; +__le32 minor; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (8 , virtchnl2_version_info); + +/* VIRTCHNL2_OP_GET_CAPS +* Dataplane driver sends this message to CP to negotiate capabilities and +* provides a virtchnl2_get_capabilities structure with its desired +* capabilities, max_sriov_vfs and num_allocated_vectors. +* CP responds with a virtchnl2_get_capabilities structure updated +* with allowed capabilities and the other fields as below. +* If PF sets max_sriov_vfs as 0, CP will respond with max number of VFs +* that can be created by this PF. For any other value 'n', CP responds +* with max_sriov_vfs set to min(n, x) where x is the max number of VFs +* allowed by CP's policy. max_sriov_vfs is not applicable for VFs. +* If dataplane driver sets num_allocated_vectors as 0, CP will respond with 1 +* which is default vector associated with the default mailbox. For any other +* value 'n', CP responds with a value <= n based on the CP's policy of +* max number of vectors for a PF. +* CP will respond with the vector ID of mailbox allocated to the PF in +* mailbox_vector_id and the number of itr index registers in itr_idx_map. +* It also responds with default number of vports that the dataplane driver +* should comeup with in default_num_vports and maximum number of vports that +* can be supported in max_vports. +*/ +struct virtchnl2_get_capabilities { +/* See VIRTCHNL2_CHECKSUM_OFFLOAD_CAPS definitions */ +__le32 csum_caps; +/* See VIRTCHNL2_SEGMENTATION_OFFLOAD_CAPS definitions */ +__le32 seg_caps; +/* See VIRTCHNL2_HEADER_SPLIT_CAPS definitions */ +__le32 hsplit_caps; +/* See VIRTCHNL2_RSC_OFFLOAD_CAPS definitions */ +__le32 rsc_caps; +/* See VIRTCHNL2_RSS_FLOW_TYPE_CAPS definitions */ +__le64 rss_caps; +/* See VIRTCHNL2_OTHER_CAPS definitions */ +__le64 other_caps; + +/* DYN_CTL register offset and vector id for mailbox provided by CP */ +__le32 mailbox_dyn_ctl; +__le16 mailbox_vector_id; +/* Maximum number of allocated vectors for the device */ +__le16 num_allocated_vectors; + +/* Maximum number of queues that can be supported */ +__le16 max_rx_q; +__le16 max_tx_q; +__le16 max_rx_bufq; +__le16 max_tx_complq; + +/* The PF sends the maximum VFs it is requesting. The CP responds with +* the maximum VFs granted. +*/ +__le16 max_sriov_vfs; + +/* Maximum number of vports that can be supported */ +__le16 max_vports; +/* Default number of vports driver should allocate on load */ +__le16 default_num_vports; + +/* Max header length hardware can parse/checksum, in bytes */ +__le16 max_tx_hdr_size; + +/* Max number of scatter gather buffers that can be sent per transmit +* packet without needing to be linearized. +*/ +u8 max_sg_bufs_per_tx_pkt; + +u8 pad[3 ]; + +u8 reserved[4 ]; +/* See VIRTCHNL2_DEVICE_TYPE definitions */ +__le32 device_type; + +/* Min packet length supported by device for single segment offload */ +u8 min_sso_packet_len; +/* Max number of header buffers that can be used for an LSO */ +u8 max_hdr_buf_per_lso; + +u8 pad1[10 ]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (80 , virtchnl2_get_capabilities); + +struct virtchnl2_queue_reg_chunk { +/* See VIRTCHNL2_QUEUE_TYPE definitions */ +__le32 type; +__le32 start_queue_id; +__le32 num_queues; +__le32 pad; + +/* Queue tail register offset and spacing provided by CP */ +__le64 qtail_reg_start; +__le32 qtail_reg_spacing; + +u8 pad1[4 ]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (32 , virtchnl2_queue_reg_chunk); + +/* Structure to specify several chunks of contiguous queues */ +struct virtchnl2_queue_reg_chunks { +__le16 num_chunks; +u8 pad[6 ]; + +struct virtchnl2_queue_reg_chunk chunks[]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (8 , virtchnl2_queue_reg_chunks); + +/* VIRTCHNL2_OP_CREATE_VPORT +* PF sends this message to CP to create a vport by filling in required +* fields of virtchnl2_create_vport structure. +* CP responds with the updated virtchnl2_create_vport structure containing the +* necessary fields followed by chunks which in turn will have an array of +* num_chunks entries of virtchnl2_queue_chunk structures. +*/ +struct virtchnl2_create_vport { +/* PF/VF populates the following fields on request */ +/* See VIRTCHNL2_VPORT_TYPE definitions */ +__le16 vport_type; + +/* See VIRTCHNL2_QUEUE_MODEL definitions */ +__le16 txq_model; + +/* See VIRTCHNL2_QUEUE_MODEL definitions */ +__le16 rxq_model; +__le16 num_tx_q; +/* Valid only if txq_model is split queue */ +__le16 num_tx_complq; +__le16 num_rx_q; +/* Valid only if rxq_model is split queue */ +__le16 num_rx_bufq; +/* Relative receive queue index to be used as default */ +__le16 default_rx_q; +/* Used to align PF and CP in case of default multiple vports, it is +* filled by the PF and CP returns the same value, to enable the driver +* to support multiple asynchronous parallel CREATE_VPORT requests and +* associate a response to a specific request. +*/ +__le16 vport_index; + +/* CP populates the following fields on response */ +__le16 max_mtu; +__le32 vport_id; +u8 default_mac_addr[ETH_ALEN ]; +__le16 pad; +/* See VIRTCHNL2_RX_DESC_IDS definitions */ +__le64 rx_desc_ids; +/* See VIRTCHNL2_TX_DESC_IDS definitions */ +__le64 tx_desc_ids; + +u8 pad1[72 ]; + +/* See VIRTCHNL2_RSS_ALGORITHM definitions */ +__le32 rss_algorithm; +__le16 rss_key_size; +__le16 rss_lut_size; + +/* See VIRTCHNL2_HEADER_SPLIT_CAPS definitions */ +__le32 rx_split_pos; + +u8 pad2[20 ]; + +struct virtchnl2_queue_reg_chunks chunks; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (160 , virtchnl2_create_vport); + +/* VIRTCHNL2_OP_DESTROY_VPORT +* VIRTCHNL2_OP_ENABLE_VPORT +* VIRTCHNL2_OP_DISABLE_VPORT +* PF sends this message to CP to destroy, enable or disable a vport by filling +* in the vport_id in virtchnl2_vport structure. +* CP responds with the status of the requested operation. +*/ +struct virtchnl2_vport { +__le32 vport_id; +u8 pad[4 ]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (8 , virtchnl2_vport); + +/* Transmit queue config info */ +struct virtchnl2_txq_info { +__le64 dma_ring_addr; + +/* See VIRTCHNL2_QUEUE_TYPE definitions */ +__le32 type; + +__le32 queue_id; +/* Valid only if queue model is split and type is trasmit queue. Used +* in many to one mapping of transmit queues to completion queue. +*/ +__le16 relative_queue_id; + +/* See VIRTCHNL2_QUEUE_MODEL definitions */ +__le16 model; + +/* See VIRTCHNL2_TXQ_SCHED_MODE definitions */ +__le16 sched_mode; + +/* See VIRTCHNL2_TXQ_FLAGS definitions */ +__le16 qflags; +__le16 ring_len; + +/* Valid only if queue model is split and type is transmit queue */ +__le16 tx_compl_queue_id; +/* Valid only if queue type is VIRTCHNL2_QUEUE_TYPE_MAILBOX_TX */ +/* See VIRTCHNL2_PEER_TYPE definitions */ +__le16 peer_type; +/* Valid only if queue type is CONFIG_TX and used to deliver messages +* for the respective CONFIG_TX queue. +*/ +__le16 peer_rx_queue_id; + +u8 pad[4 ]; + +/* Egress pasid is used for SIOV use case */ +__le32 egress_pasid; +__le32 egress_hdr_pasid; +__le32 egress_buf_pasid; + +u8 pad1[8 ]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (56 , virtchnl2_txq_info); + +/* VIRTCHNL2_OP_CONFIG_TX_QUEUES +* PF sends this message to set up parameters for one or more transmit queues. +* This message contains an array of num_qinfo instances of virtchnl2_txq_info +* structures. CP configures requested queues and returns a status code. If +* num_qinfo specified is greater than the number of queues associated with the +* vport, an error is returned and no queues are configured. +*/ +struct virtchnl2_config_tx_queues { +__le32 vport_id; + +__le16 num_qinfo; +u8 pad[10 ]; + +struct virtchnl2_txq_info qinfo[]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (16 , virtchnl2_config_tx_queues); + +/* Receive queue config info */ +struct virtchnl2_rxq_info { +/* See VIRTCHNL2_RX_DESC_IDS definitions */ +__le64 desc_ids; +__le64 dma_ring_addr; + +/* See VIRTCHNL2_QUEUE_TYPE definitions */ +__le32 type; +__le32 queue_id; + +/* See QUEUE_MODEL definitions */ +__le16 model; + +__le16 hdr_buffer_size; +__le32 data_buffer_size; +__le32 max_pkt_size; + +__le16 ring_len; +u8 buffer_notif_stride; +u8 pad; + +/* Applicable only for receive buffer queues */ +__le64 dma_head_wb_addr; + +/* Applicable only for receive completion queues */ +/* See VIRTCHNL2_RXQ_FLAGS definitions */ +__le16 qflags; + +__le16 rx_buffer_low_watermark; + +/* Valid only in split queue model */ +__le16 rx_bufq1_id; +/* Valid only in split queue model */ +__le16 rx_bufq2_id; +/* It indicates if there is a second buffer, rx_bufq2_id is valid only +* if this field is set. +*/ +u8 bufq2_ena; +u8 pad1[3 ]; + +/* Ingress pasid is used for SIOV use case */ +__le32 ingress_pasid; +__le32 ingress_hdr_pasid; +__le32 ingress_buf_pasid; + +u8 pad2[16 ]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (88 , virtchnl2_rxq_info); + +/* VIRTCHNL2_OP_CONFIG_RX_QUEUES +* PF sends this message to set up parameters for one or more receive queues. +* This message contains an array of num_qinfo instances of virtchnl2_rxq_info +* structures. CP configures requested queues and returns a status code. +* If the number of queues specified is greater than the number of queues +* associated with the vport, an error is returned and no queues are configured. +*/ +struct virtchnl2_config_rx_queues { +__le32 vport_id; + +__le16 num_qinfo; +u8 pad[18 ]; + +struct virtchnl2_rxq_info qinfo[]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (24 , virtchnl2_config_rx_queues); + +/* VIRTCHNL2_OP_ADD_QUEUES +* PF sends this message to request additional transmit/receive queues beyond +* the ones that were assigned via CREATE_VPORT request. virtchnl2_add_queues +* structure is used to specify the number of each type of queues. +* CP responds with the same structure with the actual number of queues assigned +* followed by num_chunks of virtchnl2_queue_chunk structures. +*/ +struct virtchnl2_add_queues { +__le32 vport_id; + +__le16 num_tx_q; +__le16 num_tx_complq; +__le16 num_rx_q; +__le16 num_rx_bufq; +u8 pad[4 ]; + +struct virtchnl2_queue_reg_chunks chunks; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (24 , virtchnl2_add_queues); + +/* Structure to specify a chunk of contiguous interrupt vectors */ +struct virtchnl2_vector_chunk { +__le16 start_vector_id; +__le16 start_evv_id; +__le16 num_vectors; +__le16 pad; + +/* Register offsets and spacing provided by CP.
drivers/net/ethernet/intel/idpf/virtchnl2.h line 805
Quoted 10 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +10
-0+* Dynamic control registers are used for enabling/disabling/re-enabling +* interrupts and updating interrupt rates in the hotpath. Any changes +* to interrupt rates in the dynamic control registers will be reflected +* in the interrupt throttling rate registers. +* itrn registers are used to update interrupt rates for specific +* interrupt indices without modifying the state of the interrupt. +*/ +__le32 dynctl_reg_start; +/* Register spacing between dynctl registers of 2 consecutive vectors */ +__le32 dynctl_reg_spacing;
This is usually referred to as 'stride'
drivers/net/ethernet/intel/idpf/virtchnl2.h line 809
Quoted 4 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +4
-0+ +__le32 itrn_reg_start; +/* Register spacing between itrn registers of 2 consecutive vectors */ +__le32 itrn_reg_spacing;
stride
drivers/net/ethernet/intel/idpf/virtchnl2.h line 813
Quoted 4 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +4
-0+/* Register spacing between itrn registers of the same vector +* where n=0..2. +*/ +__le32 itrn_index_spacing;
ditto
Quoted 66 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +66
-0+u8 pad1[4 ]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (32 , virtchnl2_vector_chunk); + +/* VIRTCHNL2_OP_DEALLOC_VECTORS +* PF sends virtchnl2_vector_chunks struct to specify the vectors it is giving +* away. CP performs requested action and returns status. +*/ +struct virtchnl2_vector_chunks { +__le16 num_vchunks; +u8 pad[14 ]; + +struct virtchnl2_vector_chunk vchunks[]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (16 , virtchnl2_vector_chunks); + +/* VIRTCHNL2_OP_ALLOC_VECTORS +* PF sends this message to request additional interrupt vectors beyond the +* ones that were assigned via GET_CAPS request. virtchnl2_alloc_vectors +* structure is used to specify the number of vectors requested. CP responds +* with the same structure with the actual number of vectors assigned followed +* by virtchnl2_vector_chunks structure identifying the vector ids. +*/ +struct virtchnl2_alloc_vectors { +__le16 num_vectors; +u8 pad[14 ]; + +struct virtchnl2_vector_chunks vchunks; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (32 , virtchnl2_alloc_vectors); + +/* VIRTCHNL2_OP_GET_RSS_LUT +* VIRTCHNL2_OP_SET_RSS_LUT +* PF sends this message to get or set RSS lookup table. Only supported if +* both PF and CP drivers set the VIRTCHNL2_CAP_RSS bit during configuration +* negotiation. Uses the virtchnl2_rss_lut structure. +*/ +struct virtchnl2_rss_lut { +__le32 vport_id; + +__le16 lut_entries_start; +__le16 lut_entries; +u8 pad[4 ]; + +/* RSS lookup table */ +__le32 lut[]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (12 , virtchnl2_rss_lut); + +/* VIRTCHNL2_OP_GET_RSS_HASH +* VIRTCHNL2_OP_SET_RSS_HASH +* PF sends these messages to get and set the hash filter enable bits for RSS. +* By default, the CP sets these to all possible traffic types that the +* hardware supports. The PF can query this value if it wants to change the +* traffic types that are hashed by the hardware. +* Only supported if both PF and CP drivers set the VIRTCHNL2_CAP_RSS bit +* during configuration negotiation. +*/ +struct virtchnl2_rss_hash { +/* Packet Type Groups bitmap */ +__le64 ptype_groups; +
drivers/net/ethernet/intel/idpf/virtchnl2.h line 889
Quoted 10 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +10
-0+__le32 vport_id; +u8 pad[4 ]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (16 , virtchnl2_rss_hash); + +/* VIRTCHNL2_OP_SET_SRIOV_VFS +* This message is used to set number of SRIOV VFs to be created. The actual +* allocation of resources for the VFs in terms of vport, queues and interrupts +* is done by CP. When this call completes, the APF driver calls
What's an 'APF driver'? Should this be IDPF PF driver?
Quoted 31 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +31
-0+* pci_enable_sriov to let the OS instantiate the SRIOV PCIE devices. +* The number of VFs set to 0 will destroy all the VFs of this function. +*/ +struct virtchnl2_sriov_vfs_info { +__le16 num_vfs; +__le16 pad; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (4 , virtchnl2_sriov_vfs_info); + +/* Based on the descriptor type the PF supports, CP fills ptype_id_10 or +* ptype_id_8 for flex and base descriptor respectively. If ptype_id_10 value +* is set to 0xFFFF, PF should consider this ptype as dummy one and it is the +* last ptype. +*/ +struct virtchnl2_ptype { +__le16 ptype_id_10; +u8 ptype_id_8; + +/* Number of protocol ids the packet supports, maximum of 32 +* protocol ids are supported. +*/ +u8 proto_id_count; +__le16 pad; + +/* Proto_id_count decides the allocation of protocol id array */ +/* See VIRTCHNL2_PROTO_HDR_TYPE */ +__le16 proto_id[]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (6 , virtchnl2_ptype);
drivers/net/ethernet/intel/idpf/virtchnl2.h line 930
Quoted 10 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +10
-0+ +/* VIRTCHNL2_OP_GET_PTYPE_INFO +* The total number of supported packet types is based on the descriptor type. +* For the flex descriptor, it is 1024 (10-bit ptype), and for the base +* descriptor, it is 256 (8-bit ptype). Send this message to the CP by +* populating the 'start_ptype_id' and the 'num_ptypes'. CP responds with the +* 'start_ptype_id', 'num_ptypes', and the array of ptype (virtchnl2_ptype) that +* are added at the end of the 'virtchnl2_get_ptype_info' message (Note: There +* is no specific field for the ptypes but are added at the end of the +* ptype info message. PF/VF is expected to extract the ptypes accordingly).
Why is there not a flexible array field at the end of the struct?
Quoted 76 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +76
-0+* +* If all the ptypes don't fit into one mailbox buffer, CP splits the +* ptype info into multiple messages, where each message will have its own +* 'start_ptype_id', 'num_ptypes', and the ptype array itself. When CP is done +* updating all the ptype information extracted from the package (the number of +* ptypes extracted might be less than what PF/VF expects), it will append a +* dummy ptype (which has 'ptype_id_10' of 'struct virtchnl2_ptype' as 0xFFFF) +* to the ptype array. +* +* PF/VF is expected to receive multiple VIRTCHNL2_OP_GET_PTYPE_INFO messages. +*/ +struct virtchnl2_get_ptype_info { +__le16 start_ptype_id; +__le16 num_ptypes; +__le32 pad; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (8 , virtchnl2_get_ptype_info); + +/* VIRTCHNL2_OP_GET_STATS +* PF/VF sends this message to CP to get the update stats by specifying the +* vport_id. CP responds with stats in struct virtchnl2_vport_stats. +*/ +struct virtchnl2_vport_stats { +__le32 vport_id; +u8 pad[4 ]; + +__le64 rx_bytes;/* received bytes */ +__le64 rx_unicast;/* received unicast pkts */ +__le64 rx_multicast;/* received multicast pkts */ +__le64 rx_broadcast;/* received broadcast pkts */ +__le64 rx_discards; +__le64 rx_errors; +__le64 rx_unknown_protocol; +__le64 tx_bytes;/* transmitted bytes */ +__le64 tx_unicast;/* transmitted unicast pkts */ +__le64 tx_multicast;/* transmitted multicast pkts */ +__le64 tx_broadcast;/* transmitted broadcast pkts */ +__le64 tx_discards; +__le64 tx_errors; +__le64 rx_invalid_frame_length; +__le64 rx_overflow_drop; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (128 , virtchnl2_vport_stats); + +/* VIRTCHNL2_OP_EVENT +* CP sends this message to inform the PF/VF driver of events that may affect +* it. No direct response is expected from the driver, though it may generate +* other messages in response to this one. +*/ +struct virtchnl2_event { +/* See VIRTCHNL2_EVENT_CODES definitions */ +__le32 event; + +/* Link_speed provided in Mbps */ +__le32 link_speed; + +__le32 vport_id; + +u8 link_status; +u8 pad; + +__le16 reserved; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (16 , virtchnl2_event); + +/* VIRTCHNL2_OP_GET_RSS_KEY +* VIRTCHNL2_OP_SET_RSS_KEY +* PF/VF sends this message to get or set RSS key. Only supported if both +* PF/VF and CP drivers set the VIRTCHNL2_CAP_RSS bit during configuration +* negotiation. Uses the virtchnl2_rss_key structure +*/ +struct virtchnl2_rss_key { +__le32 vport_id;
drivers/net/ethernet/intel/idpf/virtchnl2.h line 1016
Quoted 10 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +10
-0+ +__le16 key_len; +u8 pad; + +/* RSS hash key, packed bytes */ +union { +u8 key[1 ]; + __DECLARE_FLEX_ARRAY(u8, key_flex); + }; +};
What's with this 1 byte key versus flex length key? When would there only be a 1 byte key value, and why wouldn't the flex array work for it? Without more description, this looks like unnecessary complexity.
Quoted 45 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +45
-0+ +VIRTCHNL2_CHECK_STRUCT_LEN (8 , virtchnl2_rss_key); + +/* structure to specify a chunk of contiguous queues */ +struct virtchnl2_queue_chunk { +/* See VIRTCHNL2_QUEUE_TYPE definitions */ +__le32 type; +__le32 start_queue_id; +__le32 num_queues; +u8 pad[4 ]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (16 , virtchnl2_queue_chunk); + +/* Structure to specify several chunks of contiguous queues */ +struct virtchnl2_queue_chunks { +__le16 num_chunks; +u8 pad[6 ]; + +struct virtchnl2_queue_chunk chunks[]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (8 , virtchnl2_queue_chunks); + +/* VIRTCHNL2_OP_ENABLE_QUEUES +* VIRTCHNL2_OP_DISABLE_QUEUES +* VIRTCHNL2_OP_DEL_QUEUES +* +* PF sends these messages to enable, disable or delete queues specified in +* chunks. PF sends virtchnl2_del_ena_dis_queues struct to specify the queues +* to be enabled/disabled/deleted. Also applicable to single queue receive or +* transmit. CP performs requested action and returns status. +*/ +struct virtchnl2_del_ena_dis_queues { +__le32 vport_id; +u8 pad[4 ]; + +struct virtchnl2_queue_chunks chunks; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (16 , virtchnl2_del_ena_dis_queues); + +/* Queue to vector mapping */ +struct virtchnl2_queue_vector { +__le32 queue_id;
drivers/net/ethernet/intel/idpf/virtchnl2.h line 1071
Quoted 10 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +10
-0+__le16 vector_id; +u8 pad[2 ]; + +/* See VIRTCHNL2_ITR_IDX definitions */ +__le32 itr_idx; + +/* See VIRTCHNL2_QUEUE_TYPE definitions */ +__le32 queue_type; +u8 pad1[8 ]; +};
Why the end padding? What's wrong with the 16-byte size?
Quoted 109 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +82
-0+ +VIRTCHNL2_CHECK_STRUCT_LEN (24 , virtchnl2_queue_vector); + +/* VIRTCHNL2_OP_MAP_QUEUE_VECTOR +* VIRTCHNL2_OP_UNMAP_QUEUE_VECTOR +* +* PF sends this message to map or unmap queues to vectors and interrupt +* throttling rate index registers. External data buffer contains +* virtchnl2_queue_vector_maps structure that contains num_qv_maps of +* virtchnl2_queue_vector structures. CP maps the requested queue vector maps +* after validating the queue and vector ids and returns a status code. +*/ +struct virtchnl2_queue_vector_maps { +__le32 vport_id; + +__le16 num_qv_maps; +u8 pad[10 ]; + +struct virtchnl2_queue_vector qv_maps[]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (16 , virtchnl2_queue_vector_maps); + +/* VIRTCHNL2_OP_LOOPBACK +* +* PF/VF sends this message to transition to/from the loopback state. Setting +* the 'enable' to 1 enables the loopback state and setting 'enable' to 0 +* disables it. CP configures the state to loopback and returns status. +*/ +struct virtchnl2_loopback { +__le32 vport_id; + +u8 enable; +u8 pad[3 ]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (8 , virtchnl2_loopback); + +/* Structure to specify each MAC address */ +struct virtchnl2_mac_addr { +u8 addr[ETH_ALEN ]; +/* See VIRTCHNL2_MAC_TYPE definitions */ +u8 type; +u8 pad; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (8 , virtchnl2_mac_addr); + +/* VIRTCHNL2_OP_ADD_MAC_ADDR +* VIRTCHNL2_OP_DEL_MAC_ADDR +* +* PF/VF driver uses this structure to send list of MAC addresses to be +* added/deleted to the CP where as CP performs the action and returns the +* status. +*/ +struct virtchnl2_mac_addr_list { +__le32 vport_id; + +__le16 num_mac_addr; +u8 pad[2 ]; + +struct virtchnl2_mac_addr mac_addr_list[]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (8 , virtchnl2_mac_addr_list); + +/* VIRTCHNL2_OP_CONFIG_PROMISCUOUS_MODE +* +* PF/VF sends vport id and flags to the CP where as CP performs the action +* and returns the status. +*/ +struct virtchnl2_promisc_info { +__le32 vport_id; + +/* See VIRTCHNL2_PROMISC_FLAGS definitions */ +__le16 flags; +u8 pad[2 ]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (8 , virtchnl2_promisc_info); + +#endif /* _VIRTCHNL_2_H_ */ drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h new file +21
-0@@ -0,0 +1,644 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright (C) 2023 Intel Corporation */ + +#ifndef _VIRTCHNL2_LAN_DESC_H_ +#define _VIRTCHNL2_LAN_DESC_H_ + +#include <linux/bits.h> + +/* VIRTCHNL2_TX_DESC_IDS +* Transmit descriptor ID flags +*/ +#define VIRTCHNL2_TXDID_DATA BIT(0) +#define VIRTCHNL2_TXDID_CTX BIT(1) +/* TXDID 2 is reserved +* TXDID 3 is free for future use +* TXDID 4 is reserved +*/ +#define VIRTCHNL2_TXDID_FLEX_TSO_CTX BIT(5) +/* TXDID 6 is reserved */ +#define VIRTCHNL2_TXDID_FLEX_L2TAG1_L2TAG2 BIT(7) +/* TXDID 8, 9 are free for future use
drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h line 31
Quoted 10 lines
drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h new file +10
-0+* TXDID 10 is reserved +* TXDID 11 is free for future use +*/ +#define VIRTCHNL2_TXDID_FLEX_FLOW_SCHED BIT(12) +/* TXDID 13, 14 are free for future use */ +#define VIRTCHNL2_TXDID_DESC_DONE BIT(15) + +/* VIRTCHNL2_RX_DESC_IDS +* Receive descriptor IDs (range from 0 to 63) +*/
Again, enum for these lists of values
drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h line 40
Quoted 9 lines
drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h new file +9
-0+#define VIRTCHNL2_RXDID_0_16B_BASE 0 +#define VIRTCHNL2_RXDID_1_32B_BASE 1 +/* FLEX_SQ_NIC and FLEX_SPLITQ share desc ids because they can be +* differentiated based on queue model; e.g. single queue model can +* only use FLEX_SQ_NIC and split queue model can only use FLEX_SPLITQ +* for DID 2. +*/ +#define VIRTCHNL2_RXDID_2_FLEX_SPLITQ 2 +#define VIRTCHNL2_RXDID_2_FLEX_SQ_NIC 2
Maybe set VIRTCHNL2_RXDID_2_FLEX_SQ_NIC to value VIRTCHNL2_RXDID_2_FLEX_SPLITQ instead of '2' to help make it clear this isn't a mistake.
Quoted 220 lines
drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h new file +220
-0+#define VIRTCHNL2_RXDID_3_FLEX_SQ_SW 3 +#define VIRTCHNL2_RXDID_4_FLEX_SQ_NIC_VEB 4 +#define VIRTCHNL2_RXDID_5_FLEX_SQ_NIC_ACL 5 +#define VIRTCHNL2_RXDID_6_FLEX_SQ_NIC_2 6 +#define VIRTCHNL2_RXDID_7_HW_RSVD 7 +/* 9 through 15 are reserved */ +#define VIRTCHNL2_RXDID_16_COMMS_GENERIC 16 +#define VIRTCHNL2_RXDID_17_COMMS_AUX_VLAN 17 +#define VIRTCHNL2_RXDID_18_COMMS_AUX_IPV4 18 +#define VIRTCHNL2_RXDID_19_COMMS_AUX_IPV6 19 +#define VIRTCHNL2_RXDID_20_COMMS_AUX_FLOW 20 +#define VIRTCHNL2_RXDID_21_COMMS_AUX_TCP 21 +/* 22 through 63 are reserved */ + +/* VIRTCHNL2_RX_DESC_ID_BITMASKS +* Receive descriptor ID bitmasks +*/ +#define VIRTCHNL2_RXDID_M (bit) BIT_ULL(VIRTCHNL2_RXDID_##bit) +#define VIRTCHNL2_RXDID_0_16B_BASE_M VIRTCHNL2_RXDID_M(0_16B_BASE) +#define VIRTCHNL2_RXDID_1_32B_BASE_M VIRTCHNL2_RXDID_M(1_32B_BASE) +#define VIRTCHNL2_RXDID_2_FLEX_SPLITQ_M VIRTCHNL2_RXDID_M(2_FLEX_SPLITQ) +#define VIRTCHNL2_RXDID_2_FLEX_SQ_NIC_M VIRTCHNL2_RXDID_M(2_FLEX_SQ_NIC) +#define VIRTCHNL2_RXDID_3_FLEX_SQ_SW_M VIRTCHNL2_RXDID_M(3_FLEX_SQ_SW) +#define VIRTCHNL2_RXDID_4_FLEX_SQ_NIC_VEB_M VIRTCHNL2_RXDID_M(4_FLEX_SQ_NIC_VEB) +#define VIRTCHNL2_RXDID_5_FLEX_SQ_NIC_ACL_M VIRTCHNL2_RXDID_M(5_FLEX_SQ_NIC_ACL) +#define VIRTCHNL2_RXDID_6_FLEX_SQ_NIC_2_M VIRTCHNL2_RXDID_M(6_FLEX_SQ_NIC_2) +#define VIRTCHNL2_RXDID_7_HW_RSVD_M VIRTCHNL2_RXDID_M(7_HW_RSVD) +/* 9 through 15 are reserved */ +#define VIRTCHNL2_RXDID_16_COMMS_GENERIC_M VIRTCHNL2_RXDID_M(16_COMMS_GENERIC) +#define VIRTCHNL2_RXDID_17_COMMS_AUX_VLAN_M VIRTCHNL2_RXDID_M(17_COMMS_AUX_VLAN) +#define VIRTCHNL2_RXDID_18_COMMS_AUX_IPV4_M VIRTCHNL2_RXDID_M(18_COMMS_AUX_IPV4) +#define VIRTCHNL2_RXDID_19_COMMS_AUX_IPV6_M VIRTCHNL2_RXDID_M(19_COMMS_AUX_IPV6) +#define VIRTCHNL2_RXDID_20_COMMS_AUX_FLOW_M VIRTCHNL2_RXDID_M(20_COMMS_AUX_FLOW) +#define VIRTCHNL2_RXDID_21_COMMS_AUX_TCP_M VIRTCHNL2_RXDID_M(21_COMMS_AUX_TCP) +/* 22 through 63 are reserved */ + +/* Rx */ +/* For splitq virtchnl2_rx_flex_desc_adv desc members */ +#define VIRTCHNL2_RX_FLEX_DESC_ADV_RXDID_S 0 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_RXDID_M GENMASK(3, 0) +#define VIRTCHNL2_RX_FLEX_DESC_ADV_UMBCAST_S 6 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_UMBCAST_M GENMASK(7, 6) +#define VIRTCHNL2_RX_FLEX_DESC_ADV_PTYPE_S 0 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_PTYPE_M GENMASK(9, 0) +#define VIRTCHNL2_RX_FLEX_DESC_ADV_FF0_S 12 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_FF0_M GENMASK(15, 13) +#define VIRTCHNL2_RX_FLEX_DESC_ADV_LEN_PBUF_S 0 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_LEN_PBUF_M GENMASK(13, 0) +#define VIRTCHNL2_RX_FLEX_DESC_ADV_GEN_S 14 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_GEN_M \ + BIT_ULL(VIRTCHNL2_RX_FLEX_DESC_ADV_GEN_S) +#define VIRTCHNL2_RX_FLEX_DESC_ADV_BUFQ_ID_S 15 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_BUFQ_ID_M \ + BIT_ULL(VIRTCHNL2_RX_FLEX_DESC_ADV_BUFQ_ID_S) +#define VIRTCHNL2_RX_FLEX_DESC_ADV_LEN_HDR_S 0 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_LEN_HDR_M GENMASK(9, 0) +#define VIRTCHNL2_RX_FLEX_DESC_ADV_RSC_S 10 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_RSC_M \ + BIT_ULL(VIRTCHNL2_RX_FLEX_DESC_ADV_RSC_S) +#define VIRTCHNL2_RX_FLEX_DESC_ADV_SPH_S 11 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_SPH_M \ + BIT_ULL(VIRTCHNL2_RX_FLEX_DESC_ADV_SPH_S) +#define VIRTCHNL2_RX_FLEX_DESC_ADV_FF1_S 12 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_FF1_M GENMASK(14, 12) +#define VIRTCHNL2_RX_FLEX_DESC_ADV_MISS_S 15 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_MISS_M \ + BIT_ULL(VIRTCHNL2_RX_FLEX_DESC_ADV_MISS_S) + +/* VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS_ERROR_0_QW1_BITS +* For splitq virtchnl2_rx_flex_desc_adv +* Note: These are predefined bit offsets +*/ +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_DD_S 0 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_EOF_S 1 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_HBO_S 2 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_L3L4P_S 3 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_XSUM_IPE_S 4 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_XSUM_L4E_S 5 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_XSUM_EIPE_S 6 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_XSUM_EUDPE_S 7 + +/* VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS_ERROR_0_QW0_BITS +* For splitq virtchnl2_rx_flex_desc_adv +* Note: These are predefined bit offsets +*/ +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_LPBK_S 0 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_IPV6EXADD_S 1 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_RXE_S 2 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_CRCP_S 3 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_RSS_VALID_S 4 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_L2TAG1P_S 5 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_XTRMD0_VALID_S 6 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_XTRMD1_VALID_S 7 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_LAST 8 + +/* VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS_ERROR_1_BITS +* For splitq virtchnl2_rx_flex_desc_adv +* Note: These are predefined bit offsets +*/ +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS1_RSVD_S 0/* 2 bits */ +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS1_ATRAEFAIL_S 2 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS1_L2TAG2P_S 3 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS1_XTRMD2_VALID_S 4 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS1_XTRMD3_VALID_S 5 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS1_XTRMD4_VALID_S 6 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS1_XTRMD5_VALID_S 7 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS1_LAST 8 + +/* For singleq (flex) virtchnl2_rx_flex_desc fields */ +/* For virtchnl2_rx_flex_desc.ptype_flex_flags0 member */ +#define VIRTCHNL2_RX_FLEX_DESC_PTYPE_S 0 +#define VIRTCHNL2_RX_FLEX_DESC_PTYPE_M GENMASK(9, 0) + +/* For virtchnl2_rx_flex_desc.pkt_len member */ +#define VIRTCHNL2_RX_FLEX_DESC_PKT_LEN_S 0 +#define VIRTCHNL2_RX_FLEX_DESC_PKT_LEN_M GENMASK(13, 0) + +/* VIRTCHNL2_RX_FLEX_DESC_STATUS_ERROR_0_BITS +* For singleq (flex) virtchnl2_rx_flex_desc +* Note: These are predefined bit offsets +*/ +#define VIRTCHNL2_RX_FLEX_DESC_STATUS0_DD_S 0 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS0_EOF_S 1 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS0_HBO_S 2 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS0_L3L4P_S 3 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS0_XSUM_IPE_S 4 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS0_XSUM_L4E_S 5 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS0_XSUM_EIPE_S 6 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS0_XSUM_EUDPE_S 7 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS0_LPBK_S 8 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS0_IPV6EXADD_S 9 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS0_RXE_S 10 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS0_CRCP_S 11 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS0_RSS_VALID_S 12 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS0_L2TAG1P_S 13 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS0_XTRMD0_VALID_S 14 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS0_XTRMD1_VALID_S 15 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS0_LAST 16 + +/* VIRTCHNL2_RX_FLEX_DESC_STATUS_ERROR_1_BITS +* For singleq (flex) virtchnl2_rx_flex_desc +* Note: These are predefined bit offsets +*/ +#define VIRTCHNL2_RX_FLEX_DESC_STATUS1_CPM_S 0/* 4 bits */ +#define VIRTCHNL2_RX_FLEX_DESC_STATUS1_NAT_S 4 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS1_CRYPTO_S 5 +/* [10:6] reserved */ +#define VIRTCHNL2_RX_FLEX_DESC_STATUS1_L2TAG2P_S 11 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS1_XTRMD2_VALID_S 12 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS1_XTRMD3_VALID_S 13 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS1_XTRMD4_VALID_S 14 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS1_XTRMD5_VALID_S 15 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS1_LAST 16 + +/* For virtchnl2_rx_flex_desc.ts_low member */ +#define VIRTCHNL2_RX_FLEX_TSTAMP_VALID BIT(0) + +/* For singleq (non flex) virtchnl2_singleq_base_rx_desc legacy desc members */ +#define VIRTCHNL2_RX_BASE_DESC_QW1_LEN_SPH_S 63 +#define VIRTCHNL2_RX_BASE_DESC_QW1_LEN_SPH_M \ + BIT_ULL(VIRTCHNL2_RX_BASE_DESC_QW1_LEN_SPH_S) +#define VIRTCHNL2_RX_BASE_DESC_QW1_LEN_HBUF_S 52 +#define VIRTCHNL2_RX_BASE_DESC_QW1_LEN_HBUF_M GENMASK_ULL(62, 52) +#define VIRTCHNL2_RX_BASE_DESC_QW1_LEN_PBUF_S 38 +#define VIRTCHNL2_RX_BASE_DESC_QW1_LEN_PBUF_M GENMASK_ULL(51, 38) +#define VIRTCHNL2_RX_BASE_DESC_QW1_PTYPE_S 30 +#define VIRTCHNL2_RX_BASE_DESC_QW1_PTYPE_M GENMASK_ULL(37, 30) +#define VIRTCHNL2_RX_BASE_DESC_QW1_ERROR_S 19 +#define VIRTCHNL2_RX_BASE_DESC_QW1_ERROR_M GENMASK_ULL(26, 19) +#define VIRTCHNL2_RX_BASE_DESC_QW1_STATUS_S 0 +#define VIRTCHNL2_RX_BASE_DESC_QW1_STATUS_M GENMASK_ULL(18, 0) + +/* VIRTCHNL2_RX_BASE_DESC_STATUS_BITS +* For singleq (base) virtchnl2_rx_base_desc +* Note: These are predefined bit offsets +*/ +#define VIRTCHNL2_RX_BASE_DESC_STATUS_DD_S 0 +#define VIRTCHNL2_RX_BASE_DESC_STATUS_EOF_S 1 +#define VIRTCHNL2_RX_BASE_DESC_STATUS_L2TAG1P_S 2 +#define VIRTCHNL2_RX_BASE_DESC_STATUS_L3L4P_S 3 +#define VIRTCHNL2_RX_BASE_DESC_STATUS_CRCP_S 4 +#define VIRTCHNL2_RX_BASE_DESC_STATUS_RSVD_S 5/* 3 bits */ +#define VIRTCHNL2_RX_BASE_DESC_STATUS_EXT_UDP_0_S 8 +#define VIRTCHNL2_RX_BASE_DESC_STATUS_UMBCAST_S 9/* 2 bits */ +#define VIRTCHNL2_RX_BASE_DESC_STATUS_FLM_S 11 +#define VIRTCHNL2_RX_BASE_DESC_STATUS_FLTSTAT_S 12/* 2 bits */ +#define VIRTCHNL2_RX_BASE_DESC_STATUS_LPBK_S 14 +#define VIRTCHNL2_RX_BASE_DESC_STATUS_IPV6EXADD_S 15 +#define VIRTCHNL2_RX_BASE_DESC_STATUS_RSVD1_S 16/* 2 bits */ +#define VIRTCHNL2_RX_BASE_DESC_STATUS_INT_UDP_0_S 18 +#define VIRTCHNL2_RX_BASE_DESC_STATUS_LAST 19 + +/* VIRTCHNL2_RX_BASE_DESC_EXT_STATUS_BITS +* For singleq (base) virtchnl2_rx_base_desc +* Note: These are predefined bit offsets +*/ +#define VIRTCHNL2_RX_BASE_DESC_EXT_STATUS_L2TAG2P_S 0 + +/* VIRTCHNL2_RX_BASE_DESC_ERROR_BITS +* For singleq (base) virtchnl2_rx_base_desc +* Note: These are predefined bit offsets +*/ +#define VIRTCHNL2_RX_BASE_DESC_ERROR_RXE_S 0 +#define VIRTCHNL2_RX_BASE_DESC_ERROR_ATRAEFAIL_S 1 +#define VIRTCHNL2_RX_BASE_DESC_ERROR_HBO_S 2 +#define VIRTCHNL2_RX_BASE_DESC_ERROR_L3L4E_S 3/* 3 bits */ +#define VIRTCHNL2_RX_BASE_DESC_ERROR_IPE_S 3 +#define VIRTCHNL2_RX_BASE_DESC_ERROR_L4E_S 4 +#define VIRTCHNL2_RX_BASE_DESC_ERROR_EIPE_S 5 +#define VIRTCHNL2_RX_BASE_DESC_ERROR_OVERSIZE_S 6 +#define VIRTCHNL2_RX_BASE_DESC_ERROR_PPRS_S 7 + +/* VIRTCHNL2_RX_BASE_DESC_FLTSTAT_VALUES +* For singleq (base) virtchnl2_rx_base_desc +* Note: These are predefined bit offsets +*/ +#define VIRTCHNL2_RX_BASE_DESC_FLTSTAT_NO_DATA 0 +#define VIRTCHNL2_RX_BASE_DESC_FLTSTAT_FD_ID 1 +#define VIRTCHNL2_RX_BASE_DESC_FLTSTAT_RSV 2 +#define VIRTCHNL2_RX_BASE_DESC_FLTSTAT_RSS_HASH 3
drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h line 270
Quoted 10 lines
drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h new file +10
-0+ +/* Receive Descriptors */ +/* Splitq buf +* | 16| 0| +* ---------------------------------------------------------------- +* | RSV | Buffer ID | +* ---------------------------------------------------------------- +* | Rx packet buffer adresss | +* ---------------------------------------------------------------- +* | Rx header buffer adresss |
%s/adresss/address/g
Quoted 70 lines
drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h new file +70
-0+* ---------------------------------------------------------------- +* | RSV | +* ---------------------------------------------------------------- +* | 0| +*/ +struct virtchnl2_splitq_rx_buf_desc { +struct { +/* Buffer Identifier */ +__le16 buf_id; +__le16 rsvd0; +__le32 rsvd1; + } qword0; + +/* Packet buffer address */ +__le64 pkt_addr; +/* Header buffer address */ +__le64 hdr_addr; +__le64 rsvd2; +};/* RX buffer descriptor format */ + +/* Singleq buf +* | 0| +* ---------------------------------------------------------------- +* | Rx packet buffer adresss | +* ---------------------------------------------------------------- +* | Rx header buffer adresss | +* ---------------------------------------------------------------- +* | RSV | +* ---------------------------------------------------------------- +* | RSV | +* ---------------------------------------------------------------- +* | 0| +*/ +struct virtchnl2_singleq_rx_buf_desc { +/* Packet buffer address */ +__le64 pkt_addr; +/* Header buffer address */ +__le64 hdr_addr; +__le64 rsvd1; +__le64 rsvd2; +};/* RX buffer descriptor format */ + +union virtchnl2_rx_buf_desc { +struct virtchnl2_singleq_rx_buf_desc read; +struct virtchnl2_splitq_rx_buf_desc split_rd; +}; + +/* (0x00) singleq wb(compl) */ +struct virtchnl2_singleq_base_rx_desc { +struct { +struct { +__le16 mirroring_status; +__le16 l2tag1; + } lo_dword; +union { +/* RSS Hash */ +__le32 rss; +/* Flow Director filter id */ +__le32 fd_id; + } hi_dword; + } qword0; + +struct { +/* status/error/PTYPE/length */ +__le64 status_error_ptype_len; + } qword1; + +struct { +/* Extended status */ +__le16 ext_status;
drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h line 350
Quoted 10 lines
drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h new file +10
-0+__le16 rsvd; +__le16 l2tag2_1; +__le16 l2tag2_2; + } qword2; + +struct { +__le32 reserved; +__le32 fd_id; + } qword3; +};/* RX descriptor writeback format */
Hmmm... looks a lot like the Fortville descriptor :-)
Quoted 297 lines
drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h new file +294
-1+ +/* (0x01) singleq flex compl */ +struct virtchnl2_rx_flex_desc { +/* Qword 0 */ +/* Descriptor builder profile id */ +u8 rxdid; + +/* mirror=[5:0], umb=[7:6] */ +u8 mir_id_umb_cast; + +/* ptype=[9:0], ff0=[15:10] */ +__le16 ptype_flex_flags0; + +/* [15:14] are reserved */ +__le16 pkt_len; + +/* header=[10:0] +* sph=[11] +* ff1/ext=[15:12] +*/ +__le16 hdr_len_sph_flex_flags1; + +/* Qword 1 */ +__le16 status_error0; +__le16 l2tag1; +__le16 flex_meta0; +__le16 flex_meta1; + +/* Qword 2 */ +__le16 status_error1; +u8 flex_flags2; +u8 time_stamp_low; +__le16 l2tag2_1st; +__le16 l2tag2_2nd; + +/* Qword 3 */ +__le16 flex_meta2; +__le16 flex_meta3; +union { +struct { +__le16 flex_meta4; +__le16 flex_meta5; + } flex; +__le32 ts_high; + } flex_ts; +};/* RX descriptor writeback format */ + +/* (0x02) */ +struct virtchnl2_rx_flex_desc_nic { +/* Qword 0 */ +u8 rxdid; +u8 mir_id_umb_cast; +__le16 ptype_flex_flags0; +__le16 pkt_len; +__le16 hdr_len_sph_flex_flags1; + +/* Qword 1 */ +__le16 status_error0; +__le16 l2tag1; +__le32 rss_hash; + +/* Qword 2 */ +__le16 status_error1; +u8 flexi_flags2; +u8 ts_low; +__le16 l2tag2_1st; +__le16 l2tag2_2nd; + +/* Qword 3 */ +__le32 flow_id; +union { +struct { +__le16 rsvd; +__le16 flow_id_ipv6; + } flex; +__le32 ts_high; + } flex_ts; +};/* RX descriptor writeback format */ + +/* Rx Flex Descriptor Switch Profile +* RxDID Profile Id 3 +* Flex-field 0: Source Vsi +*/ +struct virtchnl2_rx_flex_desc_sw { +/* Qword 0 */ +u8 rxdid; +u8 mir_id_umb_cast; +__le16 ptype_flex_flags0; +__le16 pkt_len; +__le16 hdr_len_sph_flex_flags1; + +/* Qword 1 */ +__le16 status_error0; +__le16 l2tag1; +/* [10:15] are reserved */ +__le16 src_vsi; +__le16 flex_md1_rsvd; + +/* Qword 2 */ +__le16 status_error1; +u8 flex_flags2; +u8 ts_low; +__le16 l2tag2_1st; +__le16 l2tag2_2nd; + +/* Qword 3 */ +/* Flex words 2-3 are reserved */ +__le32 rsvd; +__le32 ts_high; +};/* RX descriptor writeback format */ + +/* Rx Flex Descriptor NIC Profile +* RxDID Profile Id 6 +* Flex-field 0: RSS hash lower 16-bits +* Flex-field 1: RSS hash upper 16-bits +* Flex-field 2: Flow Id lower 16-bits +* Flex-field 3: Source Vsi +* Flex-field 4: reserved, Vlan id taken from L2Tag +*/ +struct virtchnl2_rx_flex_desc_nic_2 { +/* Qword 0 */ +u8 rxdid; +u8 mir_id_umb_cast; +__le16 ptype_flex_flags0; +__le16 pkt_len; +__le16 hdr_len_sph_flex_flags1; + +/* Qword 1 */ +__le16 status_error0; +__le16 l2tag1; +__le32 rss_hash; + +/* Qword 2 */ +__le16 status_error1; +u8 flexi_flags2; +u8 ts_low; +__le16 l2tag2_1st; +__le16 l2tag2_2nd; + +/* Qword 3 */ +__le16 flow_id; +__le16 src_vsi; +union { +struct { +__le16 rsvd; +__le16 flow_id_ipv6; + } flex; +__le32 ts_high; + } flex_ts; +};/* RX descriptor writeback format */ + +/* Rx Flex Descriptor Advanced (Split Queue Model) +* RxDID Profile Id 7 +*/ +struct virtchnl2_rx_flex_desc_adv { +/* Qword 0 */ +/* profile_id=[3:0] +* rsvd=[5:4] +* ucast=[7:6] +*/ +u8 rxdid_ucast; + +u8 status_err0_qw0; + +/* ptype=[9:0] +* ip_hdr_err=[10] +* udp_len_err=[11] +* ff0=[15:12] +*/ +__le16 ptype_err_fflags0; + +/* plen=[13:0] +* gen=[14] only in splitq +* bufq_id=[15] only in splitq +*/ +__le16 pktlen_gen_bufq_id; + +/* header=[9:0] +* rsc=[10] only in splitq +* sph=[11] only in splitq +* ext_udp_0=[12] +* int_udp_0=[13] +* trunc_mirr=[14] +* miss_prepend=[15] +*/ +__le16 hdrlen_flags; + +/* Qword 1 */ +u8 status_err0_qw1; +u8 status_err1; +u8 fflags1; +u8 ts_low; +__le16 fmd0; +__le16 fmd1; + +/* Qword 2 */ +__le16 fmd2; +u8 fflags2; +u8 hash3; +__le16 fmd3; +__le16 fmd4; + +/* Qword 3 */ +__le16 fmd5; +__le16 fmd6; +__le16 fmd7_0; +__le16 fmd7_1; +};/* RX descriptor writeback format */ + +/* Rx Flex Descriptor Advanced (Split Queue Model) NIC Profile +* RxDID Profile Id 8 +* Flex-field 0: BufferID +* Flex-field 1: Raw checksum/L2TAG1/RSC Seg Len (determined by HW) +* Flex-field 2: Hash[15:0] +* Flex-flags 2: Hash[23:16] +* Flex-field 3: L2TAG2 +* Flex-field 5: L2TAG1 +* Flex-field 7: Timestamp (upper 32 bits) +*/ +struct virtchnl2_rx_flex_desc_adv_nic_3 { +/* Qword 0 */ +/* profile_id=[3:0] +* rsvd=[5:4] +* ucast=[7:6] +*/ +u8 rxdid_ucast; + +u8 status_err0_qw0; + +/* ptype=[9:0] +* ip_hdr_err=[10] +* udp_len_err=[11] +* ff0=[15:12] +*/ +__le16 ptype_err_fflags0; + +/* plen=[13:0] +* gen=[14] only in splitq +* bufq_id=[15] only in splitq +*/ +__le16 pktlen_gen_bufq_id; + +/* header=[9:0] +* rsc=[10] only in splitq +* sph=[11] only in splitq +* ext_udp_0=[12] +* int_udp_0=[13] +* trunc_mirr=[14] +* miss_prepend=[15] +*/ +__le16 hdrlen_flags; + +/* Qword 1 */ +u8 status_err0_qw1; +u8 status_err1; +u8 fflags1; +u8 ts_low; +/* Only in splitq */ +__le16 buf_id; +union { +__le16 raw_cs; +__le16 l2tag1; +__le16 rscseglen; + } misc; + +/* Qword 2 */ +__le16 hash1; +union { +u8 fflags2; +u8 mirrorid; +u8 hash2; + } ff2_mirrid_hash2; +u8 hash3; +__le16 l2tag2; +__le16 fmd4; + +/* Qword 3 */ +__le16 l2tag1; +__le16 fmd6; +__le32 ts_high; +};/* RX descriptor writeback format */ + +union virtchnl2_rx_desc { +struct virtchnl2_singleq_rx_buf_desc read; +struct virtchnl2_singleq_base_rx_desc base_wb; +struct virtchnl2_rx_flex_desc flex_wb; +struct virtchnl2_rx_flex_desc_nic flex_nic_wb; +struct virtchnl2_rx_flex_desc_sw flex_sw_wb; +struct virtchnl2_rx_flex_desc_nic_2 flex_nic_2_wb; +struct virtchnl2_rx_flex_desc_adv flex_adv_wb; +struct virtchnl2_rx_flex_desc_adv_nic_3 flex_adv_nic_3_wb; +}; + +#endif /* _VIRTCHNL_LAN_DESC_H_ */ --2.37.3
Jakub Kicinski
maintainerRe: [Intel-wired-lan] [PATCH net-next 01/15] virtchnl: add virtchnl version 2 ops
Quoted 5 lines · On Mon, 3 Apr 2023 15:01:55 -0700 Shannon Nelson wrote:
drivers/net/ethernet/intel/idpf/virtchnl2.h
Quoted 1 line
drivers/net/ethernet/intel/idpf/virtchnl2.h +0
-0If this is to be a standardized interface, why is this header buried in the driver specific directory instead of something more accessible like
include/linux/idpf?
The noise about this driver being "a standard" is quite confusing.
Are you considering implementing any of it?
I haven't heard of anyone who is yet, so I thought all this talk of a standard is pretty empty from the technical perspective :(
Re: [Intel-wired-lan] [PATCH net-next 01/15] virtchnl: add virtchnl version 2 ops
Quoted 8 lines · Jakub Kicinski
Quoted 5 lines · On Mon, 3 Apr 2023 15:01:55 -0700 Shannon Nelson wrote:
drivers/net/ethernet/intel/idpf/virtchnl2.h
Quoted 1 line
drivers/net/ethernet/intel/idpf/virtchnl2.h +0
-0If this is to be a standardized interface, why is this header buried in the driver specific directory instead of something more accessible like
include/linux/idpf?
Quoted 6 lines
The noise about this driver being "a standard" is quite confusing.
Are you considering implementing any of it?
I haven't heard of anyone who is yet, so I thought all this talk of a standard is pretty empty from the technical perspective :(
Just that they seem to be pushing it to become a standard through OASIS,
as they infer by pointing to their OASIS docs in this patch, and I was under the (mistaken?) impression that this would be the One Driver for any device that implemented the HW/FW interface, kinda like virtio. If that's true, then why would the driver live under the Intel directory?
sln
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Jakub Kicinski
maintainerRe: [Intel-wired-lan] [PATCH net-next 01/15] virtchnl: add virtchnl version 2 ops
Quoted 4 lines · On Mon, 3 Apr 2023 15:54:33 -0700 Shannon Nelson wrote:
Quoted 4 lines
The noise about this driver being "a standard" is quite confusing.
Are you considering implementing any of it?
Quoted 8 lines
Quoted 2 lines
I haven't heard of anyone who is yet, so I thought all this talk of a standard is pretty empty from the technical perspective :(
Just that they seem to be pushing it to become a standard through OASIS, as they infer by pointing to their OASIS docs in this patch, and I was under the (mistaken?) impression that this would be the One Driver for any device that implemented the HW/FW interface, kinda like virtio. If that's true, then why would the driver live under the Intel directory?
Fair point. But standards are generally defined by getting interested parties together and agreeing. Not by a vendor taking a barely deployed implementation to some unfamiliar forum and claiming it's a standard.
I think it should be 100% clear that to netdev this is just another (yet another?) Ethernet driver from Intel, nothing more. Maybe I should say this more strongly, given certain rumors... Here:
Reviewing / merging of this driver into the tree should not be interpreted as netdev recognizing or supporting idpf as any sort of a standard. This is our position until the driver is in fact adopted by other vendors. Attempts to misrepresent our position and any claims that merging of this *vendor driver* constitutes adoption of the standard will result in removal of the driver.
Is that helpful? There seems to be a lot of FUD around IDPF. I'd prefer to stay out of it.
_______________________________________________
Intel-wired-lan mailing list [email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Re: [Intel-wired-lan] [PATCH net-next 01/15] virtchnl: add virtchnl version 2 ops
In reply to Shannon NelsonThis version is not yet the standard IDPF version. It is the current Intel driver. The mentions of “standard” and OASIS Zaretsky because this version is the
Basis from which a standard driver WILL be developed at OASIS, which is relevant info to know.
--
Michael Orr. Cell: +1(408)636-3744
Note: Dyslexic here. Even on speller-equipped iPad, typos Probable.
Quoted 18 lines · Shannon Nelson
Quoted 10 lines · Jakub Kicinski
Quoted 5 lines · On Mon, 3 Apr 2023 15:01:55 -0700 Shannon Nelson wrote:
drivers/net/ethernet/intel/idpf/virtchnl2.h
Quoted 1 line
drivers/net/ethernet/intel/idpf/virtchnl2.h +0
-0If this is to be a standardized interface, why is this header buried in the driver specific directory instead of something more accessible like
include/linux/idpf?The noise about this driver being "a standard" is quite confusing. Are you considering implementing any of it?
I haven't heard of anyone who is yet, so I thought all this talk of a standard is pretty empty from the technical perspective :(Just that they seem to be pushing it to become a standard through OASIS,
as they infer by pointing to their OASIS docs in this patch, and I was under the (mistaken?) impression that this would be the One Driver for any device that implemented the HW/FW interface, kinda like virtio. If that's true, then why would the driver live under the Intel directory?sln
Re: [Intel-wired-lan] [PATCH net-next 01/15] virtchnl: add virtchnl version 2 ops
Quoted 4 lines · Michael
This version is not yet the standard IDPF version. It is the current Intel driver. The mentions of “standard” and OASIS Zaretsky because this version is the
Basis from which a standard driver WILL be developed at OASIS, which is relevant info to know.
Please clearly spell out this intent and any related expectations in the cover letter.
sln
Quoted 23 lines
--
Michael Orr. Cell: +1(408)636-3744
Note: Dyslexic here. Even on speller-equipped iPad, typos Probable.Quoted 18 lines · Shannon Nelson
Quoted 10 lines · Jakub Kicinski
Quoted 5 lines · On Mon, 3 Apr 2023 15:01:55 -0700 Shannon Nelson wrote:
drivers/net/ethernet/intel/idpf/virtchnl2.h
Quoted 1 line
drivers/net/ethernet/intel/idpf/virtchnl2.h +0
-0If this is to be a standardized interface, why is this header buried in the driver specific directory instead of something more accessible like
include/linux/idpf?The noise about this driver being "a standard" is quite confusing. Are you considering implementing any of it?
I haven't heard of anyone who is yet, so I thought all this talk of a standard is pretty empty from the technical perspective :(Just that they seem to be pushing it to become a standard through OASIS,
as they infer by pointing to their OASIS docs in this patch, and I was under the (mistaken?) impression that this would be the One Driver for any device that implemented the HW/FW interface, kinda like virtio. If that's true, then why would the driver live under the Intel directory?sln
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Quoted 8 lines · Sridhar
Quoted 4 lines
Further OASIS has a legal IPR policy that basically means Intel needs to publicly justify that their Signed-off-by is consisent with the kernel rules of the DCO. ie that they have a legal right to submit this IP to the kernel.
OASIS does NOT have such a legal IPR policy. The only IPR policy that applies to the IDPF TC members is the “Non-assert” IPR policy as stated in the Charter.
Non-assert is relevant to inclusion in Linux and is part of what the DCO considers. According to the OASIS IPR non-assert doesn't automatically trigger just because information has been shared within a TC.
As the submitter you need to explain that all IP and license issues are accounted for because *in general* taking work-in-progress out of a industry workgroup with an IPR is a problematic thing to include in Linux.
eg you can say that the 0.9 document this series linked to has properly reached "OASIS Standards Draft Deliverable" and is thus covered by the IPR, or you can explain that all Intel has confirmed outside OASIS that all parties that contribued to the document clear the IP release, or perhaps even that Intel is the only IP owner.
This abnormal thing just needs to be explained, maintainer's can't be left to guess if IP issues are correct.
Jason
Jason -
The Driver being published now is an Intel driver, under Intel directory,
and using the Intel Device ID - because it is NOT the IDPF standard. It is a Vendor driver.
Therefore all the discussion about any IPR policy applying to the OASIS TC work is simply irrelevant here.
The reason OASIS is referenced is that since this Intel driver is the basis/starting point for an Eventual OASIS IDPF standard, anyone who has an interest in OASIS IDPF will have an interest in this driver even If they have no interest in Intel's Products. I (we) assume that there are many people in the mailing list who might be interested in at least keeping up with OASIS IDPF TC work, hence the OASIS references. Anyone who is not interested in OASIS IDPF can simply ignore this referencing.
If you have additional questions, please reach out to me directly - I'll gladly discuss any concerns, but I think This should happen apart from this forum. My contact is below.
P2P answers below
--
Michael Orr NCNG Strategy & Roadmap Office WW Cell: (669)265-5995
Note: Dyslexic @Work. Please excuse my typos. (Remember, Dyslexics are teople, poo)
-----Original Message-----
From: Jason Gunthorpe <[email protected]>
Sent: Tuesday, April 4, 2023 7:42 PM
To: Samudrala, Sridhar <[email protected]>
Cc: Jakub Kicinski <[email protected]>; Linga, Pavan Kumar <[email protected]>; [email protected]; [email protected]; Saleem, Shiraz <[email protected]>; Tantilov, Emil S <[email protected]>; [email protected]; [email protected]; Hay, Joshua A <[email protected]>; Christoph Hellwig <[email protected]>; Orr, Michael <[email protected]>; Singhai, Anjali <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH net-next 00/15] Introduce IDPF driver
Quoted 10 lines · Sridhar
Quoted 8 lines
Quoted 4 lines
Further OASIS has a legal IPR policy that basically means Intel needs to publicly justify that their Signed-off-by is consisent with the kernel rules of the DCO. ie that they have a legal right to submit this IP to the kernel.
OASIS does NOT have such a legal IPR policy. The only IPR policy that applies to the IDPF TC members is the “Non-assert” IPR policy as stated in the Charter.
Non-assert is relevant to inclusion in Linux and is part of what the DCO considers. According to the OASIS IPR non-assert doesn't automatically trigger just because information has been shared within a TC.
The TC charter states that *All* TC work is under Non-Assert. Any materials/documents/code submitted to the TC do not change ownership, but they are covered by a "non-assert" license. this applies to Everything, not just final or draft deliverables. I have not seen any OASIS statement that says what you quote above, and the TC member companies have not agreed to any such. There is nothing needed to "trigger" non-assert and any information Shared in the TC *IS* under non-assert. When you sing up to the OASIS TC mailing list you agree to these terms.
But more importantly: whatever OASIS's Policies/IPR are, they do not apply here. This driver upload is NOT part of the TC work, and OASIS has nothing to do with it.
Quoted 1 line
As the submitter you need to explain that all IP and license issues are accounted for because *in general* taking work-in-progress out of a industry workgroup with an IPR is a problematic thing to include in Linux.
I frankly do not understand what the above means, and how this would make "all IP and license issues are accounted for".
Again - the driver published by intel here is not " taking work-in-progress out of a industry workgroup".
On the contrary - this is an Intel Driver, that will be Donated INTO the OASIS TC Industry work-group. Even then, it will NOT be "THE" standard. It is just a way to speed up the TC work by having it not start from scratch.
Quoted 2 lines
eg you can say that the 0.9 document this series linked to has properly reached "OASIS Standards Draft Deliverable" and is thus covered by the IPR,
or you can explain that all Intel has confirmed outside OASIS that all parties that contribued to the document clear the IP release, or perhaps even that Intel is the > only IP owner.
I am not planning to say any of these.
1. This driver has not reached "OASIS Standards Draft Deliverable" - in fact, I have no idea what this term means - it is not in the TC's milestones, and if this term has any legal/IPR significance, I do not know it.
2. This driver is an Intel driver, published as such, and has nothing to do with OASIS, and any and all OASIS Policies and IPR terms do not apply. When the IDPF TC will Publish an industry-standard IDPF driver - THAT driver, like all TC materials, will be under Non-Assert IPR policy - and nothing else.
Quoted 4 lines
This abnormal thing just needs to be explained, maintainer's can't be left to guess if IP issues are correct.
Jason
Re: [Intel-wired-lan] [PATCH net-next 09/15] idpf: initialize interrupts and enable vport
In reply to Simon HormanQuoted 25 lines · Simon Horman
Quoted 13 lines · Pavan Kumar Linga
To further continue 'vport open', initialize all the resources required for the interrupts. To start with, initialize the queue vector indices with the ones received from the device Control Plane. Now that all the TX and RX queues are initialized, map the RX descriptor and buffer queues as well as TX completion queues to the allocated vectors. Initialize and enable the napi handler for the napi polling. Finally, request the IRQs for the interrupt vectors from the stack and setup the interrupt handler.
Once the interrupt init is done, send 'map queue vector', 'enable queues' and 'enable vport' virtchnl messages to the CP to complete the 'vport open' flow.
Quoted 10 lines
Co-developed-by Alan Brady <[email protected]>Signed-off-by Alan Brady <[email protected]>Co-developed-by Joshua Hay <[email protected]>Signed-off-by Joshua Hay <[email protected]>Co-developed-by Madhu Chittim <[email protected]>Signed-off-by Madhu Chittim <[email protected]>Co-developed-by Phani Burra <[email protected]>Signed-off-by Phani Burra <[email protected]>Signed-off-by Pavan Kumar Linga <[email protected]>Reviewed-by Sridhar Samudrala <[email protected]>
Quoted 5 lines
Spelling from me again.
I think I'll stop there and just mention that you might want to consider adding ./checkpatch.pl --codespell to your CI.
Thanks for pointing at the misspells. Fixed all of them by running codespell through all the patches. Changes will be part of the v2 version. As suggested, will add the 'codespell' into the CI to catch any misspells in advance, during the code development.
Quoted 11 lines
Quoted 1 line
drivers/net/ethernet/intel/idpf/idpf_lib.c +0
-0...
Quoted 6 lines
+/**
+ *idpf_up_complete- Complete interface up sequence
+ * @vport: virtual port strucutre
+ *
+ * Returns 0 on success, negative on failure.
+ */
Quoted 3 lines
s/strucutre/structure/
...
Thanks,
Pavan
RE: [Intel-wired-lan] [PATCH net-next 01/15] virtchnl: add virtchnl version 2 ops
In reply to Jakub KicinskiSee below
-----Original Message-----
From: Jakub Kicinski <[email protected]>
Sent: Tuesday, April 4, 2023 1:21 AM
To: Shannon Nelson <[email protected]>
Cc: Linga, Pavan Kumar <[email protected]>; [email protected]; [email protected]; Saleem, Shiraz <[email protected]>; Tantilov, Emil S <[email protected]>; [email protected]; [email protected]; Hay, Joshua A <[email protected]>; Samudrala, Sridhar <[email protected]>; Brady, Alan <[email protected]>; Chittim, Madhu <[email protected]>; Burra, Phani R <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH net-next 01/15] virtchnl: add virtchnl version 2 ops
Quoted 6 lines · On Mon, 3 Apr 2023 15:01:55 -0700 Shannon Nelson wrote:
Quoted 6 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h
Quoted 2 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h +0
-0If this is to be a standardized interface, why is this header buried in the driver specific directory instead of something more accessible like
include/linux/idpf?
This is an Intel driver, hence in Intel tree location. When OASIS has a Standard driver,
(that will be based on, but different than this one) THAT driver will go where industry standard drivers belong.
Quoted 1 line
The noise about this driver being "a standard" is quite confusing.
This driver is NOT "a standard".
Quoted 3 lines
Are you considering implementing any of it?
I haven't heard of anyone who is yet, so I thought all this talk of a standard is pretty empty from the technical perspective :(
Agreed.
Quoted 3 lines · Michael
The Driver being published now is an Intel driver, under Intel directory, and using the Intel Device ID - because it is NOT the IDPF standard. It is a Vendor driver.
This series literally said in patch 1 that it is implementing "virtchnl version 2" and links directly to unapproved OASIS documents as "the specification for reference".
What you are saying may be the case, but it does not match what was submitted for review.
Send a v2 with the references to OASIS scrubbed out of the series, and explain what you explained here in the cover letter - that this Intel IDPF is not derived from the other OASIS IDPF.
Then you are fine.
Quoted 5 lines
I am not planning to say any of these.
1. This driver has not reached "OASIS Standards Draft Deliverable" - in fact, I have no idea what this term means - it is not in the TC's milestones, and if this term has any legal/IPR significance, I do not know it.
It is a defined term in the OASIS IPR you linked to:
19. OASIS Standards Draft Deliverable - an OASIS Deliverable that has been designated and approved by a Technical Committee as an OASIS Standards Draft Deliverable and which is enumerated in and developed in accordance with the OASIS Technical Committee Process.
IPR Section 6:
... a limited covenant not to assert any Essential Claims required to
implement such OASIS Standards Draft Deliverable ...
IPR Section 10.3 describes how the "non-assertion mode TC" works, and that the non-assertion covenant comes into full effect for a "OASIS Standards Final Deliverable" [defined term #20].
The OASIS document "TC Process" explains what steps a TC must do to achieve these milestones defined in the IPR.
Achieving the milestones defined in the IPR unambiguously triggers the non-assertion convents and then we know the IP is safe to incorporate into Linux.
As I've said a few times now, Linux requires submissions to be properly licensed and have IP rights compatible with the GPL.
IPR is complicated, the knee jerk reaction should be to reject any patches implementing in-progress works from standards bodies.
Jason
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Re: [Intel-wired-lan] [PATCH net-next 12/15] idpf: add RX splitq napi poll support
In reply to Maciej FijalkowskiQuoted 68 lines · Maciej Fijalkowski
Quoted 67 lines · Pavan Kumar Linga
From: Alan Brady <[email protected]>
Add support to handle interrupts for the RX completion queue and RX buffer queue. When the interrupt fires on RX completion queue, process the RX descriptors that are received. Allocate and prepare the SKB with the RX packet info, for both data and header buffer.
IDPF uses software maintained refill queues to manage buffers between RX queue producer and the buffer queue consumer. They are required in order to maintain a lockless buffer management system and are strictly software only constructs. Instead of updating the RX buffer queue tail with available buffers right after the clean routine, it posts the buffer ids to the refill queues, only to post them to the HW later.
If the generic receive offload (GRO) is enabled in the capabilities and turned on by default or via ethtool, then HW performs the packet coalescing if certain criteria are met by the incoming packets and updates the RX descriptor. Similar to GRO, if generic checksum is enabled, HW computes the checksum and updates the respective fields in the descriptor. Add support to update the SKB fields with the GRO and the generic checksum received.
Signed-off-by Alan Brady <[email protected]>Co-developed-by Joshua Hay <[email protected]>Signed-off-by Joshua Hay <[email protected]>Co-developed-by Madhu Chittim <[email protected]>Signed-off-by Madhu Chittim <[email protected]>Co-developed-by Phani Burra <[email protected]>Signed-off-by Phani Burra <[email protected]>Co-developed-by Pavan Kumar Linga <[email protected]>Signed-off-by Pavan Kumar Linga <[email protected]>Reviewed-by Sridhar Samudrala <[email protected]>--- drivers/net/ethernet/intel/idpf/idpf.h | 2 + drivers/net/ethernet/intel/idpf/idpf_txrx.c | 1000 ++++++++++++++++- drivers/net/ethernet/intel/idpf/idpf_txrx.h | 56 +- .../net/ethernet/intel/idpf/idpf_virtchnl.c | 4 +- 4 files changed, 1053 insertions(+), 9 deletions(-)drivers/net/ethernet/intel/idpf/idpf.h +2
-0@@ -14,6 +14,7 @@ struct idpf_vport_max_q;#include <linux/etherdevice.h> #include <linux/pci.h> #include <linux/bitfield.h> +#include <net/gro.h> #include <linux/dim.h> #include "virtchnl2.h" @@ -262,6 +263,7 @@ struct idpf_vport {u8 default_mac_addr[ETH_ALEN ];/* ITR profiles for the DIM algorithm */ #define IDPF_DIM_PROFILE_SLOTS 5 +u16 rx_itr_profile[IDPF_DIM_PROFILE_SLOTS ];u16 tx_itr_profile[IDPF_DIM_PROFILE_SLOTS ];bool link_up;drivers/net/ethernet/intel/idpf/idpf_txrx.c +0
-0@@ -339,6 +339,11 @@ static void idpf_rx_buf_rel(struct idpf_queue *rxq,idpf_rx_page_rel (rxq, &rx_buf->page_info[0 ]);if (PAGE_SIZE <8192 && rx_buf->buf_size >IDPF_RX_BUF_2048 )idpf_rx_page_rel (rxq, &rx_buf->page_info[1 ]);
Quoted 8 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c static void idpf_rx_buf_rel(struct idpf_queue *rxq, · line 346
Quoted 5 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +5
-0+ +if (rx_buf->skb) { +dev_kfree_skb (rx_buf->skb); + rx_buf->skb =NULL ; + }can you elaborate why you're introducing skb ptr to
rx_bufif you have this ptr already onidpf_queue?
The pointer gets some use in single queue mode, but we can probably look into cleaning up its use in split queue.
Quoted 8 lines
Quoted 8 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +0
-0}/** @@ -641,6 +646,28 @@ static bool idpf_rx_buf_hw_alloc_all(struct idpf_queue *rxbufq, u16 alloc_count)return !!alloc_count; }
Quoted 16 lines
Quoted 4 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +4
-0+/** +* idpf_rx_post_buf_refill - Post buffer id to refill queue +* @refillq: refill queue to post to +* @buf_id: buffer id to post drivers/net/ethernet/intel/idpf/idpf_txrx.c static bool idpf_rx_buf_hw_alloc_all(struct idpf_queue *rxbufq, u16 alloc_count) · line 662
Quoted 10 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +10
-0+*/ +static void idpf_rx_post_buf_refill (struct idpf_sw_queue *refillq,u16 buf_id) +{ +u16 nta = refillq->next_to_alloc; + +/* store the buffer ID and the SW maintained GEN bit to the refillq */ + refillq->ring[nta] = + ((buf_id <<IDPF_RX_BI_BUFID_S ) &IDPF_RX_BI_BUFID_M ) | + (!!(test_bit (__IDPF_Q_GEN_CHK, refillq->flags)) << +IDPF_RX_BI_GEN_S );do you explain anywhere in this patchset GEN bit usage?
We can add some additional comments to make it clearer.
Quoted 24 lines
Quoted 9 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +8
-0+ +if (unlikely (++nta == refillq->desc_count)) { + nta =0 ; +change_bit (__IDPF_Q_GEN_CHK, refillq->flags); + } + refillq->next_to_alloc = nta; +} +[...]
Quoted 12 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +12
-0+/** +* idpf_rx_buf_adjust_pg - Prepare rx buffer for reuse +* @rx_buf: Rx buffer to adjust +* @size: Size of adjustment +* +* Update the offset within page so that rx buf will be ready to be reused. +* For systems with PAGE_SIZE < 8192 this function will flip the page offset +* so the second half of page assigned to rx buffer will be used, otherwise +* the offset is moved by the @size bytes +*/ +static void idpf_rx_buf_adjust_pg (struct idpf_rx_buf *rx_buf,unsigned int size) +{
Quoted 8 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c netdev_tx_t idpf_tx_splitq_start(struct sk_buff *skb, · line 3321
Quoted 6 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +6
-0+struct idpf_page_info *pinfo; + + pinfo = &rx_buf->page_info[rx_buf->page_indx]; + +if (PAGE_SIZE <8192 ) +if (rx_buf->buf_size >IDPF_RX_BUF_2048 )when
buf_sizecan be non-2k?
The split queue model uses separate Rx completion and Rx buffer queues, the latter of which can support both 2k and 4k buffers.
Quoted 42 lines
Quoted 29 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +28
-0+/* flip to second page */ + rx_buf->page_indx = !rx_buf->page_indx; + else +/* flip page offset to other buffer */ + pinfo->page_offset ^= size; + else + pinfo->page_offset += size; +} + +/** +* idpf_rx_can_reuse_page - Determine if page can be reused for another rx +* @rx_buf: buffer containing the page +* +* If page is reusable, we have a green light for calling idpf_reuse_rx_page, +* which will assign the current buffer to the buffer that next_to_alloc is +* pointing to; otherwise, the dma mapping needs to be destroyed and +* page freed +*/ +static bool idpf_rx_can_reuse_page (struct idpf_rx_buf *rx_buf) +{ +unsigned int last_offset =PAGE_SIZE - rx_buf->buf_size; +struct idpf_page_info *pinfo; +unsigned int pagecnt_bias; +struct page *page; + + pinfo = &rx_buf->page_info[rx_buf->page_indx]; + pagecnt_bias = pinfo->pagecnt_bias; + page = pinfo->page;drivers/net/ethernet/intel/idpf/idpf_txrx.c netdev_tx_t idpf_tx_splitq_start(struct sk_buff *skb, · line 3359
Quoted 10 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +10
-0+ +if (unlikely (!dev_page_is_reusable (page))) +return false; + +if (PAGE_SIZE <8192 ) { +/* For 2K buffers, we can reuse the page if we are the +* owner. For 4K buffers, we can reuse the page if there are +* no other others. +*/ +int reuse_bias = rx_buf->buf_size >IDPF_RX_BUF_2048 ?0 :1 ;couldn't this be just:
Quoted 3 lines
bool reuse_bias = !(rx_buf->buf_size > IDPF_RX_BUF_2048);this is a hot path so avoiding branches is worthy.
In this instance we rely on the result being 0 or 1, which is why we do not use boolean explicitly, where true may be a non-zero value.
Quoted 33 lines
Quoted 20 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +19
-0+ +if (unlikely ((page_count (page) - pagecnt_bias) > reuse_bias)) +return false; + }else if (pinfo->page_offset > last_offset) { +return false; + } + +/* If we have drained the page fragment pool we need to update +* the pagecnt_bias and page count so that we fully restock the +* number of references the driver holds. +*/ +if (unlikely (pagecnt_bias ==1 )) { +page_ref_add (page,USHRT_MAX -1 ); + pinfo->pagecnt_bias =USHRT_MAX ; + } + +return true; +} +[...]
Quoted 10 lines
+/**
+ *idpf_rx_construct_skb- Allocate skb and populate it
+ * @rxq: Rx descriptor queue
+ * @rx_buf: Rx buffer to pull data from
+ * @size: the length of the packet
+ *
+ * This function allocates an skb. It then populates it with the page
+ * data from the current receive descriptor, taking care to set up the
+ * skb correctly.
+ */
Quoted 8 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c netdev_tx_t idpf_tx_splitq_start(struct sk_buff *skb, · line 3456
Quoted 6 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +6
-0+static struct sk_buff *idpf_rx_construct_skb (struct idpf_queue *rxq, +struct idpf_rx_buf *rx_buf, +unsigned int size) +{ +struct idpf_page_info *pinfo; +unsigned int headlen, truesize;RCT please
Will correct in next revision.
Quoted 14 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c netdev_tx_t idpf_tx_splitq_start(struct sk_buff *skb, · line 3467
Quoted 12 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +11
-0+struct sk_buff *skb; +void *va; + + pinfo = &rx_buf->page_info[rx_buf->page_indx]; + va =page_address (pinfo->page) + pinfo->page_offset; + +/* prefetch first cache line of first page */ +net_prefetch (va); +/* allocate a skb to store the frags */ + skb =__napi_alloc_skb (&rxq->q_vector->napi,IDPF_RX_HDR_SIZE , +GFP_ATOMIC | __GFP_NOWARN);any reason why no
build_skb()support right from the start?
We want to move toward supporting build_skb, but there are number of complications to that in the way we handle buffers (e.g. different buffer sizes/header split) that we want to optimize before implementing build_skb.
Quoted 49 lines
Quoted 49 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +48
-0+if (unlikely (!skb)) +return NULL ; + +skb_record_rx_queue (skb, rxq->idx); + +/* Determine available headroom for copy */ + headlen = size; +if (headlen >IDPF_RX_HDR_SIZE ) + headlen =eth_get_headlen (skb->dev, va,IDPF_RX_HDR_SIZE ); + +/* align pull length to size of long to optimize memcpy performance */ +memcpy (__skb_put (skb, headlen), va,ALIGN (headlen,sizeof (long ))); + +/* if we exhaust the linear part then add what is left as a frag */ + size -= headlen; +if (!size) { +/* buffer is unused, reset bias back to rx_buf; data was copied +* onto skb's linear part so there's no need for adjusting +* page offset and we can reuse this buffer as-is +*/ + pinfo->pagecnt_bias++; + +return skb; + } + + truesize =idpf_rx_frame_truesize (rx_buf, size); +skb_add_rx_frag (skb,0 , pinfo->page, + pinfo->page_offset + headlen, size, + truesize); +/* buffer is used by skb, update page_offset */ +idpf_rx_buf_adjust_pg (rx_buf, truesize); + +return skb; +} + +/** +* idpf_rx_hdr_construct_skb - Allocate skb and populate it from header buffer +* @rxq: Rx descriptor queue +* @hdr_buf: Rx buffer to pull data from +* @size: the length of the packet +* +* This function allocates an skb. It then populates it with the page data from +* the current receive descriptor, taking care to set up the skb correctly. +* This specifcally uses a header buffer to start building the skb. +*/ +static struct sk_buff *idpf_rx_hdr_construct_skb (struct idpf_queue *rxq, +struct idpf_dma_mem *hdr_buf, +unsigned int size)
Quoted 8 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c netdev_tx_t idpf_tx_splitq_start(struct sk_buff *skb, · line 3521
Quoted 6 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +6
-0+{ +struct sk_buff *skb; + +/* allocate a skb to store the frags */ + skb =__napi_alloc_skb (&rxq->q_vector->napi, size, +GFP_ATOMIC | __GFP_NOWARN);ditto re:
build_skb()comment
See the reply to your related comment.
Quoted 66 lines
Quoted 66 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +65
-0+if (unlikely (!skb)) +return NULL ; + +skb_record_rx_queue (skb, rxq->idx); + +memcpy (__skb_put (skb, size), hdr_buf->va,ALIGN (size,sizeof (long ))); + +return skb; +} + +/** +* idpf_rx_splitq_test_staterr - tests bits in Rx descriptor +* status and error fields +* @stat_err_field: field from descriptor to test bits in +* @stat_err_bits: value to mask +* +*/ +static bool idpf_rx_splitq_test_staterr (const u8 stat_err_field, +const u8 stat_err_bits) +{ +return !!(stat_err_field & stat_err_bits); +} + +/** +* idpf_rx_splitq_is_eop - process handling of EOP buffers +* @rx_desc: Rx descriptor for current buffer +* +* If the buffer is an EOP buffer, this function exits returning true, +* otherwise return false indicating that this is in fact a non-EOP buffer. +*/ +static bool idpf_rx_splitq_is_eop (struct virtchnl2_rx_flex_desc_adv_nic_3 *rx_desc) +{ +/* if we are the last buffer then there is nothing else to do */ +return likely (idpf_rx_splitq_test_staterr (rx_desc->status_err0_qw1, +IDPF_RXD_EOF_SPLITQ )); +} + +/** +* idpf_rx_splitq_recycle_buf - Attempt to recycle or realloc buffer +* @rxbufq: receive queue +* @rx_buf: Rx buffer to pull data from +* +* This function will clean up the contents of the rx_buf. It will either +* recycle the buffer or unmap it and free the associated resources. The buffer +* will then be placed on a refillq where it will later be reclaimed by the +* corresponding bufq. +* +* This works based on page flipping. If we assume e.g., a 4k page, it will be +* divided into two 2k buffers. We post the first half to hardware and, after +* using it, flip to second half of the page with idpf_adjust_pg_offset and +* post that to hardware. The third time through we'll flip back to first half +* of page and check if stack is still using it, if not we can reuse the buffer +* as is, otherwise we'll drain it and get a new page. +*/ +static void idpf_rx_splitq_recycle_buf (struct idpf_queue *rxbufq, +struct idpf_rx_buf *rx_buf) +{ +struct idpf_page_info *pinfo = &rx_buf->page_info[rx_buf->page_indx]; + +if (idpf_rx_can_reuse_page (rx_buf)) +return ; + +/* we are not reusing the buffer so unmap it */ +dma_unmap_page_attrs (rxbufq->dev, pinfo->dma,PAGE_SIZE , +DMA_FROM_DEVICE ,IDPF_RX_DMA_ATTR );
Quoted 8 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c netdev_tx_t idpf_tx_splitq_start(struct sk_buff *skb, · line 3591
Quoted 5 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +5
-0+__page_frag_cache_drain (pinfo->page, pinfo->pagecnt_bias); + +/* clear contents of buffer_info */ + pinfo->page =NULL ; + rx_buf->skb =NULL ;this skb NULLing is pointless to me. from the callsite of this function you operate strictly on a skb from
idpf_queue.
We'll look into cleaning this up.
Quoted 361 lines
Quoted 178 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +177
-0+ +/* It's possible the alloc can fail here but there's not much +* we can do, bufq will have to try and realloc to fill the +* hole. +*/ +idpf_alloc_page (rxbufq, pinfo); +} + +/** +* idpf_rx_splitq_clean - Clean completed descriptors from Rx queue +* @rxq: Rx descriptor queue to retrieve receive buffer queue +* @budget: Total limit on number of packets to process +* +* This function provides a "bounce buffer" approach to Rx interrupt +* processing. The advantage to this is that on systems that have +* expensive overhead for IOMMU access this provides a means of avoiding +* it by maintaining the mapping of the page to the system. +* +* Returns amount of work completed +*/ +static int idpf_rx_splitq_clean (struct idpf_queue *rxq,int budget) +{ +int total_rx_bytes =0 , total_rx_pkts =0 ; +struct idpf_queue *rx_bufq =NULL ; +struct sk_buff *skb = rxq->skb; +u16 ntc = rxq->next_to_clean; + +/* Process Rx packets bounded by budget */ +while (likely (total_rx_pkts < budget)) { +struct virtchnl2_rx_flex_desc_adv_nic_3 *rx_desc; +struct idpf_sw_queue *refillq =NULL ; +struct idpf_dma_mem *hdr_buf =NULL ; +struct idpf_rxq_set *rxq_set =NULL ; +struct idpf_rx_buf *rx_buf =NULL ; +union virtchnl2_rx_desc *desc; +unsigned int pkt_len =0 ; +unsigned int hdr_len =0 ; +u16 gen_id, buf_id =0 ; +/* Header buffer overflow only valid for header split */ +bool hbo = false; +int bufq_id; +u8 rxdid; + +/* get the Rx desc from Rx queue based on 'next_to_clean' */ + desc =IDPF_RX_DESC (rxq, ntc); + rx_desc = (struct virtchnl2_rx_flex_desc_adv_nic_3 *)desc; + +/* This memory barrier is needed to keep us from reading +* any other fields out of the rx_desc +*/ +dma_rmb (); + +/* if the descriptor isn't done, no work yet to do */ + gen_id =le16_to_cpu (rx_desc->pktlen_gen_bufq_id); + gen_id =FIELD_GET (VIRTCHNL2_RX_FLEX_DESC_ADV_GEN_M , gen_id); + +if (test_bit (__IDPF_Q_GEN_CHK, rxq->flags) != gen_id) +break ; + + rxdid =FIELD_GET (VIRTCHNL2_RX_FLEX_DESC_ADV_RXDID_M , + rx_desc->rxdid_ucast); +if (rxdid !=VIRTCHNL2_RXDID_2_FLEX_SPLITQ ) { +IDPF_RX_BUMP_NTC (rxq, ntc); +u64_stats_update_begin (&rxq->stats_sync); +u64_stats_inc (&rxq->q_stats.rx.bad_descs); +u64_stats_update_end (&rxq->stats_sync); +continue ; + } + + pkt_len =le16_to_cpu (rx_desc->pktlen_gen_bufq_id); + pkt_len =FIELD_GET (VIRTCHNL2_RX_FLEX_DESC_ADV_LEN_PBUF_M , + pkt_len); + + hbo =FIELD_GET (BIT (VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_HBO_S ), + rx_desc->status_err0_qw1); + +if (unlikely (hbo)) { +/* If a header buffer overflow, occurs, i.e. header is +* too large to fit in the header split buffer, HW will +* put the entire packet, including headers, in the +* data/payload buffer. +*/ +u64_stats_update_begin (&rxq->stats_sync); +u64_stats_inc (&rxq->q_stats.rx.hsplit_buf_ovf); +u64_stats_update_end (&rxq->stats_sync); + goto bypass_hsplit; + } + + hdr_len =le16_to_cpu (rx_desc->hdrlen_flags); + hdr_len =FIELD_GET (VIRTCHNL2_RX_FLEX_DESC_ADV_LEN_HDR_M , + hdr_len); + +bypass_hsplit: + bufq_id =le16_to_cpu (rx_desc->pktlen_gen_bufq_id); + bufq_id =FIELD_GET (VIRTCHNL2_RX_FLEX_DESC_ADV_BUFQ_ID_M , + bufq_id); + + rxq_set = container_of(rxq, struct idpf_rxq_set, rxq); +if (!bufq_id) + refillq = rxq_set->refillq0; +else + refillq = rxq_set->refillq1; + +/* retrieve buffer from the rxq */ + rx_bufq = &rxq->rxq_grp->splitq.bufq_sets[bufq_id].bufq; + + buf_id =le16_to_cpu (rx_desc->buf_id); + +if (pkt_len) { + rx_buf = &rx_bufq->rx_buf.buf[buf_id]; +idpf_rx_get_buf_page (rx_bufq->dev, rx_buf, pkt_len); + } + +if (hdr_len) { + hdr_buf = rx_bufq->rx_buf.hdr_buf[buf_id]; + +dma_sync_single_for_cpu (rxq->dev, hdr_buf->pa, hdr_buf->size, +DMA_FROM_DEVICE ); + + skb =idpf_rx_hdr_construct_skb (rxq, hdr_buf, hdr_len); +u64_stats_update_begin (&rxq->stats_sync); +u64_stats_inc (&rxq->q_stats.rx.hsplit_pkts); +u64_stats_update_end (&rxq->stats_sync); + } + +if (pkt_len) { +if (skb) +idpf_rx_add_frag (rx_buf, skb, pkt_len); +else + skb =idpf_rx_construct_skb (rxq, rx_buf, + pkt_len); + } + +/* exit if we failed to retrieve a buffer */ +if (!skb) { +/* If we fetched a buffer, but didn't use it +* undo pagecnt_bias decrement +*/ +if (rx_buf) + rx_buf->page_info[rx_buf->page_indx].pagecnt_bias++; +break ; + } + +if (rx_buf) +idpf_rx_splitq_recycle_buf (rx_bufq, rx_buf); +idpf_rx_post_buf_refill (refillq, buf_id); + +IDPF_RX_BUMP_NTC (rxq, ntc); +/* skip if it is non EOP desc */ +if (!idpf_rx_splitq_is_eop (rx_desc)) +continue ; + +/* pad skb if needed (to make valid ethernet frame) */ +if (eth_skb_pad (skb)) { + skb =NULL ; +continue ; + } + +/* probably a little skewed due to removing CRC */ + total_rx_bytes += skb->len; + +/* protocol */ +if (unlikely (idpf_rx_process_skb_fields (rxq, skb, rx_desc))) { +dev_kfree_skb_any (skb); + skb =NULL ; +continue ; + } + +/* send completed skb up the stack */ +napi_gro_receive (&rxq->q_vector->napi, skb); + skb =NULL ; + +/* update budget accounting */ + total_rx_pkts++; + } + + rxq->next_to_clean = ntc;drivers/net/ethernet/intel/idpf/idpf_txrx.c netdev_tx_t idpf_tx_splitq_start(struct sk_buff *skb, · line 3778
Quoted 10 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +10
-0+ + rxq->skb = skb; +u64_stats_update_begin (&rxq->stats_sync); +u64_stats_add (&rxq->q_stats.rx.packets, total_rx_pkts); +u64_stats_add (&rxq->q_stats.rx.bytes, total_rx_bytes); +u64_stats_update_end (&rxq->stats_sync); + +/* guarantee a trip back through this routine if there was a failure */ +return total_rx_pkts; +}keeping above func for a context
[...]
Quoted 168 lines
/**
*idpf_vport_intr_clean_queues- MSIX mode Interrupt Handler
* @irq: interrupt numberdrivers/net/ethernet/intel/idpf/idpf_txrx.c +99
-4@@ -3205,7 +4102,7 @@ static void idpf_net_dim(struct idpf_q_vector *q_vector)u32 i;if (!IDPF_ITR_IS_DYNAMIC (q_vector->tx_intr_mode)) -return ; + goto check_rx_itr;for (i =0 , packets =0 , bytes =0 ; i < q_vector->num_txq; i++) {struct idpf_queue *txq = q_vector->tx[i];@@ -3221,6 +4118,25 @@ static void idpf_net_dim(struct idpf_q_vector *q_vector)idpf_update_dim_sample (q_vector, &dim_sample, &q_vector->tx_dim, packets, bytes);net_dim (&q_vector->tx_dim, dim_sample); + +check_rx_itr: +if (!IDPF_ITR_IS_DYNAMIC (q_vector->rx_intr_mode)) +return ; + +for (i =0 , packets =0 , bytes =0 ; i < q_vector->num_rxq; i++) { +struct idpf_queue *rxq = q_vector->rx[i]; +unsigned int start; + +do { + start =u64_stats_fetch_begin (&rxq->stats_sync); + packets +=u64_stats_read (&rxq->q_stats.rx.packets); + bytes +=u64_stats_read (&rxq->q_stats.rx.bytes); + }while (u64_stats_fetch_retry (&rxq->stats_sync, start)); + } + +idpf_update_dim_sample (q_vector, &dim_sample, &q_vector->rx_dim, + packets, bytes); +net_dim (&q_vector->rx_dim, dim_sample); }/** @@ -3338,7 +4254,15 @@ static void idpf_vport_intr_ena_irq_all(struct idpf_vport *vport) true); } -if (qv->num_txq) +if (qv->num_rxq) { + dynamic =IDPF_ITR_IS_DYNAMIC (qv->rx_intr_mode); + itr = vport->rx_itr_profile[qv->rx_dim.profile_ix]; +idpf_vport_intr_write_itr (qv, dynamic ? + itr : qv->rx_itr_value, + false); + } + +if (qv->num_txq || qv->num_rxq)idpf_vport_intr_update_itr_ena_irq (qv); } }@@ -3381,6 +4305,32 @@ static void idpf_tx_dim_work(struct work_struct *work) dim->state =DIM_START_MEASURE ; } +/** +* idpf_rx_dim_work - Call back from the stack +* @work: work queue structure +*/ +static void idpf_rx_dim_work (struct work_struct *work) +{ +struct idpf_q_vector *q_vector; +struct idpf_vport *vport; +struct dim *dim; +u16 itr; + + dim = container_of(work, struct dim, work); + q_vector = container_of(dim, struct idpf_q_vector, rx_dim); + vport = q_vector->vport; + +if (dim->profile_ix >=ARRAY_SIZE (vport->rx_itr_profile)) + dim->profile_ix =ARRAY_SIZE (vport->rx_itr_profile) -1 ; + +/* look up the values in our local table */ + itr = vport->rx_itr_profile[dim->profile_ix]; + +idpf_vport_intr_write_itr (q_vector, itr, false); + + dim->state =DIM_START_MEASURE ; +} +/** * idpf_init_dim - Set up dynamic interrupt moderation * @qv: q_vector structure @@ -3390,6 +4340,10 @@ static void idpf_init_dim(struct idpf_q_vector *qv)INIT_WORK (&qv->tx_dim.work, idpf_tx_dim_work); qv->tx_dim.mode =DIM_CQ_PERIOD_MODE_START_FROM_EQE ; qv->tx_dim.profile_ix =IDPF_DIM_DEFAULT_PROFILE_IX ; + +INIT_WORK (&qv->rx_dim.work, idpf_rx_dim_work); + qv->rx_dim.mode =DIM_CQ_PERIOD_MODE_START_FROM_EQE ; + qv->rx_dim.profile_ix =IDPF_DIM_DEFAULT_PROFILE_IX ; }/** @@ -3437,6 +4391,44 @@ static bool idpf_tx_splitq_clean_all(struct idpf_q_vector *q_vec,return clean_complete; } +/** +* idpf_rx_splitq_clean_all- Clean completetion queues +* @q_vec: queue vector +* @budget: Used to determine if we are in netpoll +* @cleaned: returns number of packets cleaned +* +* Returns false if clean is not complete else returns true +*/ +static bool idpf_rx_splitq_clean_all (struct idpf_q_vector *q_vec,int budget, +int *cleaned) +{ +int num_rxq = q_vec->num_rxq; +bool clean_complete = true; +int pkts_cleaned =0 ; +int i, budget_per_q; + +/* We attempt to distribute budget to each Rx queue fairly, but don't +* allow the budget to go below 1 because that would exit polling early. +*/ + budget_per_q = num_rxq ?max (budget / num_rxq,1 ) :0 ; +for (i =0 ; i < num_rxq; i++) { +struct idpf_queue *rxq = q_vec->rx[i]; +int pkts_cleaned_per_q; + + pkts_cleaned_per_q =idpf_rx_splitq_clean (rxq, budget_per_q); +/* if we clean as many as budgeted, we must not be done */ +if (pkts_cleaned_per_q >= budget_per_q) + clean_complete = false; + pkts_cleaned += pkts_cleaned_per_q; + } + *cleaned = pkts_cleaned; + +for (i =0 ; i < q_vec->num_bufq; i++) +idpf_rx_clean_refillq_all (q_vec->bufq[i]); + +return clean_complete; +} +/** * idpf_vport_splitq_napi_poll - NAPI handler * @napi: struct from which you get q_vector @@ -3456,7 +4448,8 @@ static int idpf_vport_splitq_napi_poll(struct napi_struct *napi, int budget)return 0 ; } - clean_complete =idpf_tx_splitq_clean_all (q_vector, budget, &work_done); + clean_complete =idpf_rx_splitq_clean_all (q_vector, budget, &work_done); + clean_complete &=idpf_tx_splitq_clean_all (q_vector, budget, &work_done);/* If work not completed, return budget and polling will return */ if (!clean_complete)@@ -3810,7 +4803,6 @@ int idpf_init_rss(struct idpf_vport *vport)/** * idpf_deinit_rss - Release RSS resources * @vport: virtual port -* */ void idpf_deinit_rss (struct idpf_vport *vport) {drivers/net/ethernet/intel/idpf/idpf_txrx.h +0
-0@@ -61,10 +61,21 @@
Quoted 8 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.h line 66
Quoted 5 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.h +3
-0#define IDPF_RX_BUFQ_WORKING_SET (rxq) ((rxq)->desc_count - 1) +#define IDPF_RX_BUMP_NTC (rxq, ntc) \ +do { \ + if (unlikely(++(ntc) == (rxq)->desc_count)) { \
desc_countwon't change within single NAPI instance so i would rather store this to aux variable on stack and use this in this macro.
We will consider this as part of a more broad macro update if we can get some measurable improvement in performance.
Quoted 14 lines
Quoted 14 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.h +8
-0+ ntc =0 ; \ +change_bit (__IDPF_Q_GEN_CHK, (rxq)->flags); \ + } \ +} while (0) + +#define IDPF_RX_HDR_SIZE 256#define IDPF_RX_BUF_2048 2048#define IDPF_RX_BUF_4096 4096#define IDPF_RX_BUF_STRIDE 32 +#define IDPF_RX_BUF_POST_STRIDE 16#define IDPF_LOW_WATERMARK 64 +/* Size of header buffer specifically for header split */ #define IDPF_HDR_BUF_SIZE 256
Quoted 8 lines
Quoted 6 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.h +0
-0#define IDPF_PACKET_HDR_PAD \ (ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN * 2)@@ -74,10 +85,18 @@*/ #define IDPF_TX_SPLITQ_RE_MIN_GAP 64[...]
Thanks for reviewing,
Emil
Re: [Intel-wired-lan] [PATCH net-next 09/15] idpf: initialize interrupts and enable vport
In reply to Linga, Pavan KumarQuoted 34 lines · Pavan Kumar
Quoted 25 lines · Simon Horman
Quoted 13 lines · Pavan Kumar Linga
To further continue 'vport open', initialize all the resources required for the interrupts. To start with, initialize the queue vector indices with the ones received from the device Control Plane. Now that all the TX and RX queues are initialized, map the RX descriptor and buffer queues as well as TX completion queues to the allocated vectors. Initialize and enable the napi handler for the napi polling. Finally, request the IRQs for the interrupt vectors from the stack and setup the interrupt handler.
Once the interrupt init is done, send 'map queue vector', 'enable queues' and 'enable vport' virtchnl messages to the CP to complete the 'vport open' flow.
Quoted 10 lines
Co-developed-by Alan Brady <[email protected]>Signed-off-by Alan Brady <[email protected]>Co-developed-by Joshua Hay <[email protected]>Signed-off-by Joshua Hay <[email protected]>Co-developed-by Madhu Chittim <[email protected]>Signed-off-by Madhu Chittim <[email protected]>Co-developed-by Phani Burra <[email protected]>Signed-off-by Phani Burra <[email protected]>Signed-off-by Pavan Kumar Linga <[email protected]>Reviewed-by Sridhar Samudrala <[email protected]>Quoted 5 lines
Spelling from me again.
I think I'll stop there and just mention that you might want to consider adding ./checkpatch.pl --codespell to your CI.
Quoted 4 lines
Thanks for pointing at the misspells. Fixed all of them by running codespell through all the patches. Changes will be part of the v2 version. As suggested, will add the 'codespell' into the CI to catch any misspells in advance, during the code development.
Perfect, thanks Pavan.
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
FYI, thanks to Michael for the feedback.
Quoted 4 lines
As explained in the Charter, Intel & Google are donating the current Vendor driver & its spec to the IDPF TC to serve as a starting point for an eventual vendor-agnostic Spec & Driver that will be the OASIS IDPF standard set.
Having both under the same name seems like a massive confusion.
Quoted 9 lines · Christoph Hellwig
FYI, thanks to Michael for the feedback.
Quoted 4 lines
As explained in the Charter, Intel & Google are donating the current Vendor driver & its spec to the IDPF TC to serve as a starting point for an eventual vendor-agnostic Spec & Driver that will be the OASIS IDPF standard set.
Having both under the same name seems like a massive confusion.
I was thinking something similar. If "idpf" is likely to be the final generic driver name (which makes sense), and Intel's driver is an Intel-device specific driver, can Intel use a more Intel-device specific name for their driver? This would help both in reminding us that this isn't intended as the vendor-agnostic driver, and would prevent potential future name confusion.
sln
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Re: [Intel-wired-lan] [PATCH net-next 01/15] virtchnl: add virtchnl version 2 ops
In reply to Shannon NelsonQuoted 77 lines · Shannon Nelson
drivers/net/ethernet/intel/idpf/virtchnl2.h
Quoted 45 lines · Pavan Kumar Linga
Virtchnl version 1 is an interface used by the current generation of foundational NICs to negotiate the capabilities and configure the HW resources such as queues, vectors, RSS LUT, etc between the PF and VF drivers. It is not extensible to enable new features supported in the next generation of NICs/IPUs and to negotiate descriptor types, packet types and register offsets.
To overcome the limitations of the existing interface, introduce the virtchnl version 2 and add the necessary opcodes, structures, definitions, and descriptor formats. The driver also learns the data queue and other register offsets to use instead of hardcoding them. The advantage of this approach is that it gives the flexibility to modify the register offsets if needed, restrict the use of certain descriptor types and negotiate the supported packet types.
Following are the links to the specifications for reference
Virtchnl version1:
https://www.intel.com/content/dam/www/public/us/en/documents/
product-specifications/ethernet-adaptive-virtual-function-hardware-spec.pdfVirtchnl version2:
https://www.oasis-open.org/committees/documents.php?wg_abbrev=idpfCo-developed-by Alan Brady <[email protected]>Signed-off-by Alan Brady <[email protected]>Co-developed-by Joshua Hay <[email protected]>Signed-off-by Joshua Hay <[email protected]>Co-developed-by Madhu Chittim <[email protected]>Signed-off-by Madhu Chittim <[email protected]>Co-developed-by Phani Burra <[email protected]>Signed-off-by Phani Burra <[email protected]>Co-developed-by Sridhar Samudrala <[email protected]>Signed-off-by Sridhar Samudrala <[email protected]>Signed-off-by Pavan Kumar Linga <[email protected]>Reviewed-by Sridhar Samudrala <[email protected]>---
drivers/net/ethernet/intel/idpf/virtchnl2.h | 1153 +++++++++++++++++ .../ethernet/intel/idpf/virtchnl2_lan_desc.h | 644 +++++++++2 files changed, 1797 insertions(+)create mode 100644
drivers/net/ethernet/intel/idpf/virtchnl2.hcreate mode 100644drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.hdrivers/net/ethernet/intel/idpf/virtchnl2.h +0
-0If this is to be a standardized interface, why is this header buried in the driver specific directory instead of something more accessible like
include/linux/idpf?Quoted 28 lines
new file mode 100644
index 000000000000..a6e57df2c35fdrivers/net/ethernet/intel/idpf/virtchnl2.h new file +9
-0@@ -0,0 +1,1153 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright (C) 2023 Intel Corporation */ + +#ifndef _VIRTCHNL2_H_ +#define _VIRTCHNL2_H_ + +/* All opcodes associated with virtchnl 2 are prefixed with virtchnl2 or +* VIRTCHNL2. Any future opcodes, offloads/capabilities, structures, +* and defines must be prefixed with virtchnl2 or VIRTCHNL2 to avoid confusion.
+ *
+ * PF/VF uses the virtchnl interface defined in this header file to communicate
+ * with device Control Plane (CP). Driver and the CP may run on different
+ * platforms with different endianness. To avoid byte order discrepancies,
+ * struct members in this header follow little-endian format. Users of this
+ * virtchnl interface are expected to convert back to their native endian
+ * format.
+ */
Quoted 9 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h line 23
Quoted 6 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +6
-0+ +#include "virtchnl2_lan_desc.h" + +/* VIRTCHNL2_ERROR_CODES */ +/* Success */ +#define VIRTCHNL2_STATUS_SUCCESS 0Shouldn't these be enum and not #define?
This header file is describing communication protocol with opcodes, error codes, capabilities etc. that are exchanged between IDPF and device Control Plane. Compiler chooses the size of the enum based on the enumeration constants that are present which is not a constant size. But for virtchnl protocol, we want to have fixed size no matter what. To avoid such cases, we are using defines whereever necessary.
Quoted 34 lines
Quoted 34 lines
+/* Operation not permitted, used in case of command not permitted for sender */
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +10
-0+#define VIRTCHNL2_STATUS_ERR_EPERM 1 +/* Bad opcode - virtchnl interface problem */ +#define VIRTCHNL2_STATUS_ERR_ESRCH 3 +/* I/O error - HW access error */ +#define VIRTCHNL2_STATUS_ERR_EIO 5 +/* No such resource - Referenced resource is not allacated */ +#define VIRTCHNL2_STATUS_ERR_ENXIO 6 +/* Permission denied - Resource is not permitted to caller */ +#define VIRTCHNL2_STATUS_ERR_EACCES 13 +/* Device or resource busy - In case shared resource is in use by others */
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +21
-0+#define VIRTCHNL2_STATUS_ERR_EBUSY 16 +/* Object already exists and not free */ +#define VIRTCHNL2_STATUS_ERR_EEXIST 17 +/* Invalid input argument in command */ +#define VIRTCHNL2_STATUS_ERR_EINVAL 22 +/* No space left or allocation failure */ +#define VIRTCHNL2_STATUS_ERR_ENOSPC 28 +/* Parameter out of range */ +#define VIRTCHNL2_STATUS_ERR_ERANGE 34 + +/* Op not allowed in current dev mode */ +#define VIRTCHNL2_STATUS_ERR_EMODE 200 +/* State Machine error - Command sequence problem */ +#define VIRTCHNL2_STATUS_ERR_ESM 201 + +/* This macro is used to generate compilation errors if a structure +* is not exactly the correct length. +*/ +#define VIRTCHNL2_CHECK_STRUCT_LEN (n,X ) \ + static_assert((n) == sizeof(struct X)) +
Quoted 9 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h line 61
Quoted 6 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +6
-0+/* New major set of opcodes introduced and so leaving room for +* old misc opcodes to be added in future. Also these opcodes may only +* be used if both the PF and VF have successfully negotiated the +* VIRTCHNL version as 2.0 during VIRTCHNL2_OP_VERSION exchange. +*/ +#define VIRTCHNL2_OP_UNKNOWN 0I think these also should be enum.
Please see comment above.
Quoted 65 lines
Quoted 65 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +46
-0+#define VIRTCHNL2_OP_VERSION 1 +#define VIRTCHNL2_OP_GET_CAPS 500 +#define VIRTCHNL2_OP_CREATE_VPORT 501 +#define VIRTCHNL2_OP_DESTROY_VPORT 502 +#define VIRTCHNL2_OP_ENABLE_VPORT 503 +#define VIRTCHNL2_OP_DISABLE_VPORT 504 +#define VIRTCHNL2_OP_CONFIG_TX_QUEUES 505 +#define VIRTCHNL2_OP_CONFIG_RX_QUEUES 506 +#define VIRTCHNL2_OP_ENABLE_QUEUES 507 +#define VIRTCHNL2_OP_DISABLE_QUEUES 508 +#define VIRTCHNL2_OP_ADD_QUEUES 509 +#define VIRTCHNL2_OP_DEL_QUEUES 510 +#define VIRTCHNL2_OP_MAP_QUEUE_VECTOR 511 +#define VIRTCHNL2_OP_UNMAP_QUEUE_VECTOR 512 +#define VIRTCHNL2_OP_GET_RSS_KEY 513 +#define VIRTCHNL2_OP_SET_RSS_KEY 514 +#define VIRTCHNL2_OP_GET_RSS_LUT 515 +#define VIRTCHNL2_OP_SET_RSS_LUT 516 +#define VIRTCHNL2_OP_GET_RSS_HASH 517 +#define VIRTCHNL2_OP_SET_RSS_HASH 518 +#define VIRTCHNL2_OP_SET_SRIOV_VFS 519 +#define VIRTCHNL2_OP_ALLOC_VECTORS 520 +#define VIRTCHNL2_OP_DEALLOC_VECTORS 521 +#define VIRTCHNL2_OP_EVENT 522 +#define VIRTCHNL2_OP_GET_STATS 523 +#define VIRTCHNL2_OP_RESET_VF 524 +#define VIRTCHNL2_OP_GET_EDT_CAPS 525 +#define VIRTCHNL2_OP_GET_PTYPE_INFO 526 +/* Opcode 527 and 528 are reserved for VIRTCHNL2_OP_GET_PTYPE_ID and +* VIRTCHNL2_OP_GET_PTYPE_INFO_RAW. +* Opcodes 529, 530, 531, 532 and 533 are reserved. +*/ +#define VIRTCHNL2_OP_LOOPBACK 534 +#define VIRTCHNL2_OP_ADD_MAC_ADDR 535 +#define VIRTCHNL2_OP_DEL_MAC_ADDR 536 +#define VIRTCHNL2_OP_CONFIG_PROMISCUOUS_MODE 537 + +/* VIRTCHNL2_VPORT_TYPE +* Type of virtual port +*/ +#define VIRTCHNL2_VPORT_TYPE_DEFAULT 0 + +/* VIRTCHNL2_QUEUE_MODEL +* Type of queue model +* +* In the single queue model, the same transmit descriptor queue is used by
+ * software to post descriptors to hardware and by hardware to post completed
+ * descriptors to software.
+ * Likewise, the same receive descriptor queue is used by hardware to post
+ * completions to software and by software to post buffers to hardware.
+ */drivers/net/ethernet/intel/idpf/virtchnl2.h new file +2
-0+#define VIRTCHNL2_QUEUE_MODEL_SINGLE 0 +/* In the split queue model, hardware uses transmit completion queues to post
+ * descriptor/buffer completions to software, while software uses transmit
+ * descriptor queues to post descriptors to hardware.
+ * Likewise, hardware posts descriptor completions to the receive descriptor
+ * queue, while software uses receive buffer queues to post buffers to hardware.
+ */
Quoted 9 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h line 125
Quoted 6 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +6
-0+#define VIRTCHNL2_QUEUE_MODEL_SPLIT 1 + +/* VIRTCHNL2_CHECKSUM_OFFLOAD_CAPS +* Checksum offload capability flags +*/ +#define VIRTCHNL2_CAP_TX_CSUM_L3_IPV4 BIT(0)More enums... I'll stop here with the enum comments, but really anywhere you have a collection of constants enum is preferred.
Same as comment above.
Quoted 21 lines
Quoted 21 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +21
-0+#define VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_TCP BIT(1) +#define VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_UDP BIT(2) +#define VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_SCTP BIT(3) +#define VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_TCP BIT(4) +#define VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_UDP BIT(5) +#define VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_SCTP BIT(6) +#define VIRTCHNL2_CAP_TX_CSUM_GENERIC BIT(7) +#define VIRTCHNL2_CAP_RX_CSUM_L3_IPV4 BIT(8) +#define VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_TCP BIT(9) +#define VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_UDP BIT(10) +#define VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_SCTP BIT(11) +#define VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_TCP BIT(12) +#define VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_UDP BIT(13) +#define VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_SCTP BIT(14) +#define VIRTCHNL2_CAP_RX_CSUM_GENERIC BIT(15) +#define VIRTCHNL2_CAP_TX_CSUM_L3_SINGLE_TUNNEL BIT(16) +#define VIRTCHNL2_CAP_TX_CSUM_L3_DOUBLE_TUNNEL BIT(17) +#define VIRTCHNL2_CAP_RX_CSUM_L3_SINGLE_TUNNEL BIT(18) +#define VIRTCHNL2_CAP_RX_CSUM_L3_DOUBLE_TUNNEL BIT(19) +#define VIRTCHNL2_CAP_TX_CSUM_L4_SINGLE_TUNNEL BIT(20) +#define VIRTCHNL2_CAP_TX_CSUM_L4_DOUBLE_TUNNEL BIT(21)
Quoted 9 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h line 152
Quoted 6 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +6
-0+#define VIRTCHNL2_CAP_RX_CSUM_L4_SINGLE_TUNNEL BIT(22) +#define VIRTCHNL2_CAP_RX_CSUM_L4_DOUBLE_TUNNEL BIT(23) + +/* VIRTCHNL2_SEGMENTATION_OFFLOAD_CAPS +* Segmentation offload capability flags +*/ You might use the comment starter "/**" on many of these struct and enum headers in order to make use of the kernel-doc tool for code documentation generation.
Thanks for the feedback. Fixed all the instances of struct, enums, definitions comments to start with "/**" in the header file.
Quoted 275 lines
Quoted 275 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +75
-0+#define VIRTCHNL2_CAP_SEG_IPV4_TCP BIT(0) +#define VIRTCHNL2_CAP_SEG_IPV4_UDP BIT(1) +#define VIRTCHNL2_CAP_SEG_IPV4_SCTP BIT(2) +#define VIRTCHNL2_CAP_SEG_IPV6_TCP BIT(3) +#define VIRTCHNL2_CAP_SEG_IPV6_UDP BIT(4) +#define VIRTCHNL2_CAP_SEG_IPV6_SCTP BIT(5) +#define VIRTCHNL2_CAP_SEG_GENERIC BIT(6) +#define VIRTCHNL2_CAP_SEG_TX_SINGLE_TUNNEL BIT(7) +#define VIRTCHNL2_CAP_SEG_TX_DOUBLE_TUNNEL BIT(8) + +/* VIRTCHNL2_RSS_FLOW_TYPE_CAPS +* Receive Side Scaling Flow type capability flags +*/ +#define VIRTCHNL2_CAP_RSS_IPV4_TCP BIT_ULL(0) +#define VIRTCHNL2_CAP_RSS_IPV4_UDP BIT_ULL(1) +#define VIRTCHNL2_CAP_RSS_IPV4_SCTP BIT_ULL(2) +#define VIRTCHNL2_CAP_RSS_IPV4_OTHER BIT_ULL(3) +#define VIRTCHNL2_CAP_RSS_IPV6_TCP BIT_ULL(4) +#define VIRTCHNL2_CAP_RSS_IPV6_UDP BIT_ULL(5) +#define VIRTCHNL2_CAP_RSS_IPV6_SCTP BIT_ULL(6) +#define VIRTCHNL2_CAP_RSS_IPV6_OTHER BIT_ULL(7) +#define VIRTCHNL2_CAP_RSS_IPV4_AH BIT_ULL(8) +#define VIRTCHNL2_CAP_RSS_IPV4_ESP BIT_ULL(9) +#define VIRTCHNL2_CAP_RSS_IPV4_AH_ESP BIT_ULL(10) +#define VIRTCHNL2_CAP_RSS_IPV6_AH BIT_ULL(11) +#define VIRTCHNL2_CAP_RSS_IPV6_ESP BIT_ULL(12) +#define VIRTCHNL2_CAP_RSS_IPV6_AH_ESP BIT_ULL(13) + +/* VIRTCHNL2_HEADER_SPLIT_CAPS +* Header split capability flags +*/ +/* For prepended metadata */ +#define VIRTCHNL2_CAP_RX_HSPLIT_AT_L2 BIT(0) +/* All VLANs go into header buffer */ +#define VIRTCHNL2_CAP_RX_HSPLIT_AT_L3 BIT(1) +#define VIRTCHNL2_CAP_RX_HSPLIT_AT_L4V4 BIT(2) +#define VIRTCHNL2_CAP_RX_HSPLIT_AT_L4V6 BIT(3) + +/* VIRTCHNL2_RSC_OFFLOAD_CAPS +* Receive Side Coalescing offload capability flags +*/ +#define VIRTCHNL2_CAP_RSC_IPV4_TCP BIT(0) +#define VIRTCHNL2_CAP_RSC_IPV4_SCTP BIT(1) +#define VIRTCHNL2_CAP_RSC_IPV6_TCP BIT(2) +#define VIRTCHNL2_CAP_RSC_IPV6_SCTP BIT(3) + +/* VIRTCHNL2_OTHER_CAPS +* Other capability flags +* SPLITQ_QSCHED: Queue based scheduling using split queue model +* TX_VLAN: VLAN tag insertion +* RX_VLAN: VLAN tag stripping +*/ +#define VIRTCHNL2_CAP_RDMA BIT_ULL(0) +#define VIRTCHNL2_CAP_SRIOV BIT_ULL(1) +#define VIRTCHNL2_CAP_MACFILTER BIT_ULL(2) +#define VIRTCHNL2_CAP_FLOW_DIRECTOR BIT_ULL(3) +#define VIRTCHNL2_CAP_SPLITQ_QSCHED BIT_ULL(4) +#define VIRTCHNL2_CAP_CRC BIT_ULL(5) +#define VIRTCHNL2_CAP_ADQ BIT_ULL(6) +#define VIRTCHNL2_CAP_WB_ON_ITR BIT_ULL(7) +#define VIRTCHNL2_CAP_PROMISC BIT_ULL(8) +#define VIRTCHNL2_CAP_LINK_SPEED BIT_ULL(9) +#define VIRTCHNL2_CAP_INLINE_IPSEC BIT_ULL(10) +#define VIRTCHNL2_CAP_LARGE_NUM_QUEUES BIT_ULL(11) +/* Require additional info */ +#define VIRTCHNL2_CAP_VLAN BIT_ULL(12) +#define VIRTCHNL2_CAP_PTP BIT_ULL(13) +/* EDT: Earliest Departure Time capability used for Timing Wheel */ +#define VIRTCHNL2_CAP_EDT BIT_ULL(14) +#define VIRTCHNL2_CAP_ADV_RSS BIT_ULL(15) +#define VIRTCHNL2_CAP_FDIR BIT_ULL(16) +#define VIRTCHNL2_CAP_RX_FLEX_DESC BIT_ULL(17) +#define VIRTCHNL2_CAP_PTYPE BIT_ULL(18) +#define VIRTCHNL2_CAP_LOOPBACK BIT_ULL(19) +/* Enable miss completion types plus ability to detect a miss completion if a
+ * reserved bit is set in a standared completion's tag.
+ */drivers/net/ethernet/intel/idpf/virtchnl2.h new file +10
-0+#define VIRTCHNL2_CAP_MISS_COMPL_TAG BIT_ULL(20) +/* This must be the last capability */ +#define VIRTCHNL2_CAP_OEM BIT_ULL(63) + +/* VIRTCHNL2_DEVICE_TYPE */ +/* Underlying device type */ +#define VIRTCHNL2_MEV_DEVICE 0 + +/* VIRTCHNL2_TXQ_SCHED_MODE +* Transmit Queue Scheduling Modes - Queue mode is the legacy mode i.e. inorder
+ * completions where descriptors and buffers are completed at the same time.
+ * Flow scheduling mode allows for out of order packet processing where
+ * descriptors are cleaned in order, but buffers can be completed out of order.
+ */drivers/net/ethernet/intel/idpf/virtchnl2.h new file +25
-0+#define VIRTCHNL2_TXQ_SCHED_MODE_QUEUE 0 +#define VIRTCHNL2_TXQ_SCHED_MODE_FLOW 1 + +/* VIRTCHNL2_TXQ_FLAGS +* Transmit Queue feature flags +* +* Enable rule miss completion type; packet completion for a packet +* sent on exception path; only relevant in flow scheduling mode. +*/ +#define VIRTCHNL2_TXQ_ENABLE_MISS_COMPL BIT(0) + +/* VIRTCHNL2_PEER_TYPE +* Transmit mailbox peer type +*/ +#define VIRTCHNL2_RDMA_CPF 0 +#define VIRTCHNL2_NVME_CPF 1 +#define VIRTCHNL2_ATE_CPF 2 +#define VIRTCHNL2_LCE_CPF 3 + +/* VIRTCHNL2_RXQ_FLAGS +* Receive Queue Feature flags +*/ +#define VIRTCHNL2_RXQ_RSC BIT(0) +#define VIRTCHNL2_RXQ_HDR_SPLIT BIT(1) +/* When set, packet descriptors are flushed by hardware immediately after
+ * processing each packet.
+ */drivers/net/ethernet/intel/idpf/virtchnl2.h new file +21
-0+#define VIRTCHNL2_RXQ_IMMEDIATE_WRITE_BACK BIT(2) +#define VIRTCHNL2_RX_DESC_SIZE_16BYTE BIT(3) +#define VIRTCHNL2_RX_DESC_SIZE_32BYTE BIT(4) + +/* VIRTCHNL2_RSS_ALGORITHM +* Type of RSS algorithm +*/ +#define VIRTCHNL2_RSS_ALG_TOEPLITZ_ASYMMETRIC 0 +#define VIRTCHNL2_RSS_ALG_R_ASYMMETRIC 1 +#define VIRTCHNL2_RSS_ALG_TOEPLITZ_SYMMETRIC 2 +#define VIRTCHNL2_RSS_ALG_XOR_SYMMETRIC 3 + +/* VIRTCHNL2_EVENT_CODES +* Type of event +*/ +#define VIRTCHNL2_EVENT_UNKNOWN 0 +#define VIRTCHNL2_EVENT_LINK_CHANGE 1 +/* Event type 2, 3 are reserved */ + +/* VIRTCHNL2_QUEUE_TYPE +* Transmit and Receive queue types are valid in legacy as well as split queue
+ * models. With Split Queue model, 2 additional types are introduced -
+ *TX_COMPLETIONandRX_BUFFER. In split queue model, receive corresponds to
+ * the queue where hardware posts completions.
+ */drivers/net/ethernet/intel/idpf/virtchnl2.h new file +20
-0+#define VIRTCHNL2_QUEUE_TYPE_TX 0 +#define VIRTCHNL2_QUEUE_TYPE_RX 1 +#define VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION 2 +#define VIRTCHNL2_QUEUE_TYPE_RX_BUFFER 3 +#define VIRTCHNL2_QUEUE_TYPE_CONFIG_TX 4 +#define VIRTCHNL2_QUEUE_TYPE_CONFIG_RX 5 +/* Queue types 6, 7, 8, 9 are reserved */ +#define VIRTCHNL2_QUEUE_TYPE_MBX_TX 10 +#define VIRTCHNL2_QUEUE_TYPE_MBX_RX 11 + +/* VIRTCHNL2_ITR_IDX +* Virtchannel interrupt throttling rate index +*/ +#define VIRTCHNL2_ITR_IDX_0 0 +#define VIRTCHNL2_ITR_IDX_1 1 + +/* VIRTCHNL2_MAC_TYPE +* VIRTCHNL2_MAC_ADDR_PRIMARY +* PF/VF driver should set @type to VIRTCHNL2_MAC_ADDR_PRIMARY for the +* primary/device unicast MAC address filter for
VIRTCHNL2_OP_ADD_MAC_ADDRand
+ *VIRTCHNL2_OP_DEL_MAC_ADDR. This allows for the underlying control plane
+ * function to accurately track the MAC address and for VM/function reset.
+ *
+ *VIRTCHNL2_MAC_ADDR_EXTRA
+ * PF/VF driver should set @type toVIRTCHNL2_MAC_ADDR_EXTRAfor any extra
+ * unicast and/or multicast filters that are being added/deleted via
+ * VIRTCHNL2_OP_ADD_MAC_ADDR/VIRTCHNL2_OP_DEL_MAC_ADDR respectively.
+ */drivers/net/ethernet/intel/idpf/virtchnl2.h new file +11
-0+#define VIRTCHNL2_MAC_ADDR_PRIMARY 1 +#define VIRTCHNL2_MAC_ADDR_EXTRA 2 + +/* VIRTCHNL2_PROMISC_FLAGS +* Flags used for promiscuous mode +*/ +#define VIRTCHNL2_UNICAST_PROMISC BIT(0) +#define VIRTCHNL2_MULTICAST_PROMISC BIT(1) + +/* VIRTCHNL2_PROTO_HDR_TYPE +* Protocol header type within a packet segment. A segment consists of one or
+ * more protocol headers that make up a logical group of protocol headers. Each
+ * logical group of protocol headers encapsulates or is encapsulated using/by
+ * tunneling or encapsulation protocols for network virtualization.
+ */drivers/net/ethernet/intel/idpf/virtchnl2.h new file +75
-0+/* VIRTCHNL2_PROTO_HDR_ANY is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_ANY 0 +#define VIRTCHNL2_PROTO_HDR_PRE_MAC 1 +/* VIRTCHNL2_PROTO_HDR_MAC is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_MAC 2 +#define VIRTCHNL2_PROTO_HDR_POST_MAC 3 +#define VIRTCHNL2_PROTO_HDR_ETHERTYPE 4 +#define VIRTCHNL2_PROTO_HDR_VLAN 5 +#define VIRTCHNL2_PROTO_HDR_SVLAN 6 +#define VIRTCHNL2_PROTO_HDR_CVLAN 7 +#define VIRTCHNL2_PROTO_HDR_MPLS 8 +#define VIRTCHNL2_PROTO_HDR_UMPLS 9 +#define VIRTCHNL2_PROTO_HDR_MMPLS 10 +#define VIRTCHNL2_PROTO_HDR_PTP 11 +#define VIRTCHNL2_PROTO_HDR_CTRL 12 +#define VIRTCHNL2_PROTO_HDR_LLDP 13 +#define VIRTCHNL2_PROTO_HDR_ARP 14 +#define VIRTCHNL2_PROTO_HDR_ECP 15 +#define VIRTCHNL2_PROTO_HDR_EAPOL 16 +#define VIRTCHNL2_PROTO_HDR_PPPOD 17 +#define VIRTCHNL2_PROTO_HDR_PPPOE 18 +/* VIRTCHNL2_PROTO_HDR_IPV4 is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_IPV4 19 +/* IPv4 and IPv6 Fragment header types are only associated to +* VIRTCHNL2_PROTO_HDR_IPV4 and VIRTCHNL2_PROTO_HDR_IPV6 respectively, +* cannot be used independently. +*/ +/* VIRTCHNL2_PROTO_HDR_IPV4_FRAG is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_IPV4_FRAG 20 +/* VIRTCHNL2_PROTO_HDR_IPV6 is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_IPV6 21 +/* VIRTCHNL2_PROTO_HDR_IPV6_FRAG is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_IPV6_FRAG 22 +#define VIRTCHNL2_PROTO_HDR_IPV6_EH 23 +/* VIRTCHNL2_PROTO_HDR_UDP is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_UDP 24 +/* VIRTCHNL2_PROTO_HDR_TCP is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_TCP 25 +/* VIRTCHNL2_PROTO_HDR_SCTP is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_SCTP 26 +/* VIRTCHNL2_PROTO_HDR_ICMP is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_ICMP 27 +/* VIRTCHNL2_PROTO_HDR_ICMPV6 is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_ICMPV6 28 +#define VIRTCHNL2_PROTO_HDR_IGMP 29 +#define VIRTCHNL2_PROTO_HDR_AH 30 +#define VIRTCHNL2_PROTO_HDR_ESP 31 +#define VIRTCHNL2_PROTO_HDR_IKE 32 +#define VIRTCHNL2_PROTO_HDR_NATT_KEEP 33 +/* VIRTCHNL2_PROTO_HDR_PAY is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_PAY 34 +#define VIRTCHNL2_PROTO_HDR_L2TPV2 35 +#define VIRTCHNL2_PROTO_HDR_L2TPV2_CONTROL 36 +#define VIRTCHNL2_PROTO_HDR_L2TPV3 37 +#define VIRTCHNL2_PROTO_HDR_GTP 38 +#define VIRTCHNL2_PROTO_HDR_GTP_EH 39 +#define VIRTCHNL2_PROTO_HDR_GTPCV2 40 +#define VIRTCHNL2_PROTO_HDR_GTPC_TEID 41 +#define VIRTCHNL2_PROTO_HDR_GTPU 42 +#define VIRTCHNL2_PROTO_HDR_GTPU_UL 43 +#define VIRTCHNL2_PROTO_HDR_GTPU_DL 44 +#define VIRTCHNL2_PROTO_HDR_ECPRI 45 +#define VIRTCHNL2_PROTO_HDR_VRRP 46 +#define VIRTCHNL2_PROTO_HDR_OSPF 47 +/* VIRTCHNL2_PROTO_HDR_TUN is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_TUN 48 +#define VIRTCHNL2_PROTO_HDR_GRE 49 +#define VIRTCHNL2_PROTO_HDR_NVGRE 50 +#define VIRTCHNL2_PROTO_HDR_VXLAN 51 +#define VIRTCHNL2_PROTO_HDR_VXLAN_GPE 52 +#define VIRTCHNL2_PROTO_HDR_GENEVE 53 +#define VIRTCHNL2_PROTO_HDR_NSH 54 +#define VIRTCHNL2_PROTO_HDR_QUIC 55 +#define VIRTCHNL2_PROTO_HDR_PFCP 56 +#define VIRTCHNL2_PROTO_HDR_PFCP_NODE 57
Quoted 9 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h line 419
Quoted 6 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +6
-0+#define VIRTCHNL2_PROTO_HDR_PFCP_SESSION 58 +#define VIRTCHNL2_PROTO_HDR_RTP 59 +#define VIRTCHNL2_PROTO_HDR_ROCE 60 +#define VIRTCHNL2_PROTO_HDR_ROCEV1 61 +#define VIRTCHNL2_PROTO_HDR_ROCEV2 62 +/* Protocol ids up to 32767 are reserved for AVF use */ Why are we mentioning AVF here? Is this supposed to be Virtchnl2 use?
Thanks for pointing out. Removed the AVF reference as it is not necessary.
Quoted 9 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h line 425
Quoted 6 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +6
-0+/* 32768 - 65534 are used for user defined protocol ids */ +/* VIRTCHNL2_PROTO_HDR_NO_PROTO is a mandatory protocol id */ +#define VIRTCHNL2_PROTO_HDR_NO_PROTO 65535 + +#define VIRTCHNL2_VERSION_MAJOR_2 2 +#define VIRTCHNL2_VERSION_MINOR_0 0If this is related to the IDPF spec version, why is it not 0.9? If this is something else, what happened to major version 1?
IPU HW supports both the versions, virtchnl1 and virtchnl2. IDPF only supports virtchnl2 version. Virtchnl version1 uses major number as 1 used by AVF whereas virtchnl version2 uses 2 as the major number used by IDPF.
Quoted 6 lines
Quoted 6 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +6
-0+ +/* VIRTCHNL2_OP_GET_EDT_CAPS +* Get EDT granularity and time horizon +*/ +struct virtchnl2_edt_caps { + /* Timestamp granularity in nanoseconds */
Quoted 9 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h line 437
Quoted 6 lines
+
__le64tstamp_granularity_ns;
+ /* Total time window in nanoseconds */
+__le64time_horizon_ns;drivers/net/ethernet/intel/idpf/virtchnl2.h new file +3
-0+}; + +VIRTCHNL2_CHECK_STRUCT_LEN (16 , virtchnl2_edt_caps);Don't put a space between the struct and the check.
Checkpatch reports a warning (actually a 'Check') when the newline is removed. Following is the checkpatch output when the newline is removed:
"CHECK: Please use a blank line after function/struct/union/enum declarations"
Quoted 402 lines
Quoted 402 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +3
-0+ +/* VIRTCHNL2_OP_VERSION +* PF/VF posts its version number to the CP. CP responds with its version number
+ * in the same format, along with a return code.
+ * If there is a major version mismatch, then the PF/VF cannot operate.
+ * If there is a minor version mismatch, then the PF/VF can operate but should
+ * add a warning to the system log.
+ *
+ * This version opcode MUST always be specified as == 1, regardless of other
+ * changes in the API. The CP must always respond to this message without
+ * error regardless of version mismatch.
+ */drivers/net/ethernet/intel/idpf/virtchnl2.h new file +9
-0+struct virtchnl2_version_info { + __le32 major; + __le32 minor; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (8 , virtchnl2_version_info); + +/* VIRTCHNL2_OP_GET_CAPS +* Dataplane driver sends this message to CP to negotiate capabilities and
+ * provides avirtchnl2_get_capabilitiesstructure with its desired
+ * capabilities,max_sriov_vfsandnum_allocated_vectors.
+ * CP responds with avirtchnl2_get_capabilitiesstructure updated
+ * with allowed capabilities and the other fields as below.
+ * If PF setsmax_sriov_vfsas 0, CP will respond with max number of VFs
+ * that can be created by this PF. For any other value 'n', CP responds
+ * withmax_sriov_vfsset tomin(n, x)where x is the max number of VFs
+ * allowed by CP's policy.max_sriov_vfsis not applicable for VFs.
+ * If dataplane driver setsnum_allocated_vectorsas 0, CP will respond with 1
+ * which is default vector associated with the default mailbox. For any other
+ * value 'n', CP responds with a value <= n based on the CP's policy of
+ * max number of vectors for a PF.
+ * CP will respond with the vector ID of mailbox allocated to the PF in
+ *mailbox_vector_idand the number of itr index registers initr_idx_map.
+ * It also responds with default number of vports that the dataplane driver
+ * should comeup with indefault_num_vportsand maximum number of vports that
+ * can be supported inmax_vports.
+ */drivers/net/ethernet/intel/idpf/virtchnl2.h new file +15
-0+struct virtchnl2_get_capabilities { + /* See VIRTCHNL2_CHECKSUM_OFFLOAD_CAPS definitions */ + __le32 csum_caps; + /* See VIRTCHNL2_SEGMENTATION_OFFLOAD_CAPS definitions */ + __le32 seg_caps; + /* See VIRTCHNL2_HEADER_SPLIT_CAPS definitions */ + __le32 hsplit_caps; + /* See VIRTCHNL2_RSC_OFFLOAD_CAPS definitions */ + __le32 rsc_caps; + /* See VIRTCHNL2_RSS_FLOW_TYPE_CAPS definitions */ + __le64 rss_caps; + /* See VIRTCHNL2_OTHER_CAPS definitions */ + __le64 other_caps; + + /* DYN_CTL register offset and vector id for mailbox providedby CP */
+__le32mailbox_dyn_ctl;
+__le16mailbox_vector_id;
+ /* Maximum number of allocated vectors for the device */ +__le16num_allocated_vectors;drivers/net/ethernet/intel/idpf/virtchnl2.h new file +8
-0+ + /* Maximum number of queues that can be supported */ + __le16 max_rx_q; + __le16 max_tx_q; + __le16 max_rx_bufq; + __le16 max_tx_complq; + + /* The PF sends the maximum VFs it is requesting. The CPresponds with
+ * the maximum VFs granted.
+ */
+__le16max_sriov_vfs;drivers/net/ethernet/intel/idpf/virtchnl2.h new file +10
-0+ + /* Maximum number of vports that can be supported */ + __le16 max_vports; + /* Default number of vports driver should allocate on load */ + __le16 default_num_vports; + + /* Max header length hardware can parse/checksum, in bytes */ + __le16 max_tx_hdr_size; + + /* Max number of scatter gather buffers that can be sent pertransmit
+ * packet without needing to be linearized. + */
+ u8max_sg_bufs_per_tx_pkt;drivers/net/ethernet/intel/idpf/virtchnl2.h new file +8
-0+ + u8 pad[3]; + + u8 reserved[4]; + /* See VIRTCHNL2_DEVICE_TYPE definitions */ + __le32 device_type; + + /* Min packet length supported by device for single segmentoffload */
+ u8min_sso_packet_len;
+ /* Max number of header buffers that can be used for an LSO */ + u8max_hdr_buf_per_lso;drivers/net/ethernet/intel/idpf/virtchnl2.h new file +36
-0+ + u8 pad1[10]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (80 , virtchnl2_get_capabilities); + +struct virtchnl2_queue_reg_chunk { + /* See VIRTCHNL2_QUEUE_TYPE definitions */ + __le32 type; + __le32 start_queue_id; + __le32 num_queues; + __le32 pad; + + /* Queue tail register offset and spacing provided by CP */ + __le64 qtail_reg_start; + __le32 qtail_reg_spacing; + + u8 pad1[4]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (32 , virtchnl2_queue_reg_chunk); + +/* Structure to specify several chunks of contiguous queues */ +struct virtchnl2_queue_reg_chunks { + __le16 num_chunks; + u8 pad[6]; + + struct virtchnl2_queue_reg_chunk chunks[]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (8 , virtchnl2_queue_reg_chunks); + +/* VIRTCHNL2_OP_CREATE_VPORT +* PF sends this message to CP to create a vport by filling in required +* fields of virtchnl2_create_vport structure. +* CP responds with the updated virtchnl2_create_vport structure containing the
+ * necessary fields followed by chunks which in turn will have an array of
+ *num_chunksentries ofvirtchnl2_queue_chunkstructures.
+ */drivers/net/ethernet/intel/idpf/virtchnl2.h new file +19
-0+struct virtchnl2_create_vport { + /* PF/VF populates the following fields on request */ + /* See VIRTCHNL2_VPORT_TYPE definitions */ + __le16 vport_type; + + /* See VIRTCHNL2_QUEUE_MODEL definitions */ + __le16 txq_model; + + /* See VIRTCHNL2_QUEUE_MODEL definitions */ + __le16 rxq_model; + __le16 num_tx_q; + /* Valid only if txq_model is split queue */ + __le16 num_tx_complq; + __le16 num_rx_q; + /* Valid only if rxq_model is split queue */ + __le16 num_rx_bufq; + /* Relative receive queue index to be used as default */ + __le16 default_rx_q; + /* Used to align PF and CP in case of default multiple vports,it is
+ * filled by the PF and CP returns the same value, to enable the driver
+ * to support multiple asynchronous parallelCREATE_VPORTrequests and
+ * associate a response to a specific request.
+ */
+__le16vport_index;drivers/net/ethernet/intel/idpf/virtchnl2.h new file +32
-0+ + /* CP populates the following fields on response */ + __le16 max_mtu; + __le32 vport_id; + u8 default_mac_addr[ETH_ALEN]; + __le16 pad; + /* See VIRTCHNL2_RX_DESC_IDS definitions */ + __le64 rx_desc_ids; + /* See VIRTCHNL2_TX_DESC_IDS definitions */ + __le64 tx_desc_ids; + + u8 pad1[72]; + + /* See VIRTCHNL2_RSS_ALGORITHM definitions */ + __le32 rss_algorithm; + __le16 rss_key_size; + __le16 rss_lut_size; + + /* See VIRTCHNL2_HEADER_SPLIT_CAPS definitions */ + __le32 rx_split_pos; + + u8 pad2[20]; + + struct virtchnl2_queue_reg_chunks chunks; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (160 , virtchnl2_create_vport); + +/* VIRTCHNL2_OP_DESTROY_VPORT +* VIRTCHNL2_OP_ENABLE_VPORT +* VIRTCHNL2_OP_DISABLE_VPORT +* PF sends this message to CP to destroy, enable or disable a vport by filling
+ * in thevport_idinvirtchnl2_vportstructure.
+ * CP responds with the status of the requested operation.
+ */drivers/net/ethernet/intel/idpf/virtchnl2.h new file +16
-0+struct virtchnl2_vport { + __le32 vport_id; + u8 pad[4]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (8 , virtchnl2_vport); + +/* Transmit queue config info */ +struct virtchnl2_txq_info { + __le64 dma_ring_addr; + + /* See VIRTCHNL2_QUEUE_TYPE definitions */ + __le32 type; + + __le32 queue_id; + /* Valid only if queue model is split and type is trasmitqueue. Used
+ * in many to one mapping of transmit queues to completion queue. + */
+__le16relative_queue_id;drivers/net/ethernet/intel/idpf/virtchnl2.h new file +12
-0+ + /* See VIRTCHNL2_QUEUE_MODEL definitions */ + __le16 model; + + /* See VIRTCHNL2_TXQ_SCHED_MODE definitions */ + __le16 sched_mode; + + /* See VIRTCHNL2_TXQ_FLAGS definitions */ + __le16 qflags; + __le16 ring_len; + + /* Valid only if queue model is split and type is transmitqueue */
+__le16tx_compl_queue_id;
+ /* Valid only if queue type isVIRTCHNL2_QUEUE_TYPE_MAILBOX_TX*/ + /* SeeVIRTCHNL2_PEER_TYPEdefinitions */
+__le16peer_type;
+ /* Valid only if queue type isCONFIG_TXand used to deliver messages
+ * for the respectiveCONFIG_TXqueue.
+ */
+__le16peer_rx_queue_id;drivers/net/ethernet/intel/idpf/virtchnl2.h new file +15
-0+ + u8 pad[4]; + + /* Egress pasid is used for SIOV use case */ + __le32 egress_pasid; + __le32 egress_hdr_pasid; + __le32 egress_buf_pasid; + + u8 pad1[8]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (56 , virtchnl2_txq_info); + +/* VIRTCHNL2_OP_CONFIG_TX_QUEUES +* PF sends this message to set up parameters for one or more transmit queues.
+ * This message contains an array ofnum_qinfoinstances ofvirtchnl2_txq_info
+ * structures. CP configures requested queues and returns a status code. If
+ *num_qinfospecified is greater than the number of queues associated with the
+ * vport, an error is returned and no queues are configured.
+ */drivers/net/ethernet/intel/idpf/virtchnl2.h new file +46
-0+struct virtchnl2_config_tx_queues { + __le32 vport_id; + + __le16 num_qinfo; + u8 pad[10]; + + struct virtchnl2_txq_info qinfo[]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (16 , virtchnl2_config_tx_queues); + +/* Receive queue config info */ +struct virtchnl2_rxq_info { + /* See VIRTCHNL2_RX_DESC_IDS definitions */ + __le64 desc_ids; + __le64 dma_ring_addr; + + /* See VIRTCHNL2_QUEUE_TYPE definitions */ + __le32 type; + __le32 queue_id; + + /* See QUEUE_MODEL definitions */ + __le16 model; + + __le16 hdr_buffer_size; + __le32 data_buffer_size; + __le32 max_pkt_size; + + __le16 ring_len; + u8 buffer_notif_stride; + u8 pad; + + /* Applicable only for receive buffer queues */ + __le64 dma_head_wb_addr; + + /* Applicable only for receive completion queues */ + /* See VIRTCHNL2_RXQ_FLAGS definitions */ + __le16 qflags; + + __le16 rx_buffer_low_watermark; + + /* Valid only in split queue model */ + __le16 rx_bufq1_id; + /* Valid only in split queue model */ + __le16 rx_bufq2_id; + /* It indicates if there is a second buffer, rx_bufq2_id isvalid only
+ * if this field is set.
+ */
+ u8bufq2_ena;
+ u8 pad1[3];drivers/net/ethernet/intel/idpf/virtchnl2.h new file +13
-0+ + /* Ingress pasid is used for SIOV use case */ + __le32 ingress_pasid; + __le32 ingress_hdr_pasid; + __le32 ingress_buf_pasid; + + u8 pad2[16]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (88 , virtchnl2_rxq_info); + +/* VIRTCHNL2_OP_CONFIG_RX_QUEUES +* PF sends this message to set up parameters for one or more receive queues.
+ * This message contains an array ofnum_qinfoinstances ofvirtchnl2_rxq_info
+ * structures. CP configures requested queues and returns a status code.
+ * If the number of queues specified is greater than the number of queues
+ * associated with the vport, an error is returned and no queues are configured.
+ */drivers/net/ethernet/intel/idpf/virtchnl2.h new file +13
-0+struct virtchnl2_config_rx_queues { + __le32 vport_id; + + __le16 num_qinfo; + u8 pad[18]; + + struct virtchnl2_rxq_info qinfo[]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (24 , virtchnl2_config_rx_queues); + +/* VIRTCHNL2_OP_ADD_QUEUES +* PF sends this message to request additional transmit/receive queues beyond
+ * the ones that were assigned viaCREATE_VPORTrequest.virtchnl2_add_queues
+ * structure is used to specify the number of each type of queues.
+ * CP responds with the same structure with the actual number of queues assigned
+ * followed bynum_chunksofvirtchnl2_queue_chunkstructures.
+ */drivers/net/ethernet/intel/idpf/virtchnl2.h new file +23
-0+struct virtchnl2_add_queues { + __le32 vport_id; + + __le16 num_tx_q; + __le16 num_tx_complq; + __le16 num_rx_q; + __le16 num_rx_bufq; + u8 pad[4]; + + struct virtchnl2_queue_reg_chunks chunks; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (24 , virtchnl2_add_queues); + +/* Structure to specify a chunk of contiguous interrupt vectors */ +struct virtchnl2_vector_chunk { + __le16 start_vector_id; + __le16 start_evv_id; + __le16 num_vectors; + __le16 pad; + + /* Register offsets and spacing provided by CP. + * Dynamic control registers are used forenabling/disabling/re-enabling
+ * interrupts and updating interrupt rates in the hotpath. Any changes
+ * to interrupt rates in the dynamic control registers will be reflected
+ * in the interrupt throttling rate registers.
+ * itrn registers are used to update interrupt rates for specific + * interrupt indices without modifying the state of the
Quoted 9 lines
Quoted 6 lines
interrupt.
+ */
+__le32dynctl_reg_start;
+ /* Register spacing between dynctl registers of 2 consecutive vectors */
+__le32dynctl_reg_spacing;This is usually referred to as 'stride'
Will consider that.
Quoted 96 lines
Quoted 5 lines
+
+__le32itrn_reg_start;
+ /* Register spacing between itrn registers of 2 consecutive vectors */
+__le32itrn_reg_spacing;stride
Quoted 4 lines
+ /* Register spacing between itrn registers of the same vector + * where n=0..2.
+ */
+__le32itrn_index_spacing;ditto
Quoted 81 lines
+ u8 pad1[4];
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +6
-0+}; + +VIRTCHNL2_CHECK_STRUCT_LEN (32 , virtchnl2_vector_chunk); + +/* VIRTCHNL2_OP_DEALLOC_VECTORS +* PF sends virtchnl2_vector_chunks struct to specify the vectors it is giving
+ * away. CP performs requested action and returns status.
+ */drivers/net/ethernet/intel/idpf/virtchnl2.h new file +11
-0+struct virtchnl2_vector_chunks { + __le16 num_vchunks; + u8 pad[14]; + + struct virtchnl2_vector_chunk vchunks[]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (16 , virtchnl2_vector_chunks); + +/* VIRTCHNL2_OP_ALLOC_VECTORS +* PF sends this message to request additional interrupt vectors beyond the
+ * ones that were assigned viaGET_CAPSrequest.virtchnl2_alloc_vectors
+ * structure is used to specify the number of vectors requested. CP responds
+ * with the same structure with the actual number of vectors assigned followed
+ * byvirtchnl2_vector_chunksstructure identifying the vector ids.
+ */drivers/net/ethernet/intel/idpf/virtchnl2.h new file +12
-0+struct virtchnl2_alloc_vectors { + __le16 num_vectors; + u8 pad[14]; + + struct virtchnl2_vector_chunks vchunks; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (32 , virtchnl2_alloc_vectors); + +/* VIRTCHNL2_OP_GET_RSS_LUT +* VIRTCHNL2_OP_SET_RSS_LUT +* PF sends this message to get or set RSS lookup table. Only supported if
+ * both PF and CP drivers set theVIRTCHNL2_CAP_RSSbit during configuration
+ * negotiation. Uses thevirtchnl2_rss_lutstructure.
+ */drivers/net/ethernet/intel/idpf/virtchnl2.h new file +16
-0+struct virtchnl2_rss_lut { + __le32 vport_id; + + __le16 lut_entries_start; + __le16 lut_entries; + u8 pad[4]; + + /* RSS lookup table */ + __le32 lut[]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (12 , virtchnl2_rss_lut); + +/* VIRTCHNL2_OP_GET_RSS_HASH +* VIRTCHNL2_OP_SET_RSS_HASH +* PF sends these messages to get and set the hash filter enable bits for RSS.
+ * By default, the CP sets these to all possible traffic types that the
+ * hardware supports. The PF can query this value if it wants to change the
+ * traffic types that are hashed by the hardware.
+ * Only supported if both PF and CP drivers set theVIRTCHNL2_CAP_RSSbit
+ * during configuration negotiation.
+ */drivers/net/ethernet/intel/idpf/virtchnl2.h new file +10
-0+struct virtchnl2_rss_hash { + /* Packet Type Groups bitmap */ + __le64 ptype_groups; + + __le32 vport_id; + u8 pad[4]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (16 , virtchnl2_rss_hash); +
Quoted 9 lines
Quoted 6 lines
+/*
VIRTCHNL2_OP_SET_SRIOV_VFS
+ * This message is used to set number of SRIOV VFs to be created. The actual
+ * allocation of resources for the VFs in terms of vport, queues and interrupts
+ * is done by CP. When this call completes, the APF driver callsWhat's an 'APF driver'? Should this be IDPF PF driver?
Good catch. Replaced the APF reference with IDPF.
Quoted 42 lines
Quoted 42 lines
+ *
pci_enable_sriovto let the OS instantiate the SRIOV PCIE devices.
+ * The number of VFs set to 0 will destroy all the VFs of this function.
+ */drivers/net/ethernet/intel/idpf/virtchnl2.h new file +9
-0+struct virtchnl2_sriov_vfs_info { + __le16 num_vfs; + __le16 pad; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (4 , virtchnl2_sriov_vfs_info); + +/* Based on the descriptor type the PF supports, CP fills ptype_id_10 or +* ptype_id_8 for flex and base descriptor respectively. If
ptype_id_10value
+ * is set to0xFFFF, PF should consider this ptype as dummy one and it is the
+ * last ptype.
+ */drivers/net/ethernet/intel/idpf/virtchnl2.h new file +19
-0+struct virtchnl2_ptype { + __le16 ptype_id_10; + u8 ptype_id_8; + + /* Number of protocol ids the packet supports, maximum of 32 + * protocol ids are supported. + */ + u8 proto_id_count; + __le16 pad; + + /* Proto_id_count decides the allocation of protocol id array */ + /* See VIRTCHNL2_PROTO_HDR_TYPE */ + __le16 proto_id[]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (6 , virtchnl2_ptype); + +/* VIRTCHNL2_OP_GET_PTYPE_INFO +* The total number of supported packet types is based on the descriptor type.
+ * For the flex descriptor, it is 1024 (10-bit ptype), and for the base
+ * descriptor, it is 256 (8-bit ptype). Send this message to the CP by
+ * populating the 'start_ptype_id' and the 'num_ptypes'. CP responds with the
+ * 'start_ptype_id', 'num_ptypes', and the array of ptype
Quoted 9 lines
Quoted 6 lines
(
virtchnl2_ptype) that
+ * are added at the end of the 'virtchnl2_get_ptype_info' message (Note: There
+ * is no specific field for the ptypes but are added at the end of the
+ * ptype info message. PF/VF is expected to extract the ptypes accordingly).Why is there not a flexible array field at the end of the struct?
The reason for doing it this way is because the compiler doesn't allow nested flexible array fields. Added a comment with the said reasoning (it will be in v2).
Quoted 92 lines
Quoted 92 lines
+ *
+ * If all the ptypes don't fit into one mailbox buffer, CP splits the
+ * ptype info into multiple messages, where each message will have its own
+ * 'start_ptype_id', 'num_ptypes', and the ptype array itself. When CP is done
+ * updating all the ptype information extracted from the package (the number of
+ * ptypes extracted might be less than what PF/VF expects), it will append a
+ * dummy ptype (which has 'ptype_id_10' of 'structvirtchnl2_ptype' as0xFFFF)
+ * to the ptype array.
+ *
+ * PF/VF is expected to receive multipleVIRTCHNL2_OP_GET_PTYPE_INFOmessages.
+ */drivers/net/ethernet/intel/idpf/virtchnl2.h new file +10
-0+struct virtchnl2_get_ptype_info { + __le16 start_ptype_id; + __le16 num_ptypes; + __le32 pad; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (8 , virtchnl2_get_ptype_info); + +/* VIRTCHNL2_OP_GET_STATS +* PF/VF sends this message to CP to get the update stats by specifying the
+ *vport_id. CP responds with stats in structvirtchnl2_vport_stats.
+ */drivers/net/ethernet/intel/idpf/virtchnl2.h new file +25
-0+struct virtchnl2_vport_stats { + __le32 vport_id; + u8 pad[4]; + + __le64 rx_bytes; /* received bytes */ + __le64 rx_unicast; /* received unicast pkts */ + __le64 rx_multicast; /* received multicast pkts */ + __le64 rx_broadcast; /* received broadcast pkts */ + __le64 rx_discards; + __le64 rx_errors; + __le64 rx_unknown_protocol; + __le64 tx_bytes; /* transmitted bytes */ + __le64 tx_unicast; /* transmitted unicast pkts */ + __le64 tx_multicast; /* transmitted multicast pkts */ + __le64 tx_broadcast; /* transmitted broadcast pkts */ + __le64 tx_discards; + __le64 tx_errors; + __le64 rx_invalid_frame_length; + __le64 rx_overflow_drop; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (128 , virtchnl2_vport_stats); + +/* VIRTCHNL2_OP_EVENT +* CP sends this message to inform the PF/VF driver of events that may affect
+ * it. No direct response is expected from the driver, though it may generate
+ * other messages in response to this one.
+ */drivers/net/ethernet/intel/idpf/virtchnl2.h new file +20
-0+struct virtchnl2_event { + /* See VIRTCHNL2_EVENT_CODES definitions */ + __le32 event; + + /* Link_speed provided in Mbps */ + __le32 link_speed; + + __le32 vport_id; + + u8 link_status; + u8 pad; + + __le16 reserved; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (16 , virtchnl2_event); + +/* VIRTCHNL2_OP_GET_RSS_KEY +* VIRTCHNL2_OP_SET_RSS_KEY +* PF/VF sends this message to get or set RSS key. Only supported if both
+ * PF/VF and CP drivers set theVIRTCHNL2_CAP_RSSbit during configuration
+ * negotiation. Uses thevirtchnl2_rss_keystructure
+ */drivers/net/ethernet/intel/idpf/virtchnl2.h new file +7
-0+struct virtchnl2_rss_key { + __le32 vport_id; + + __le16 key_len; + u8 pad; + + /* RSS hash key, packed bytes */
Quoted 9 lines
Quoted 5 lines
+ union {
+ u8 key[1];
+__DECLARE_FLEX_ARRAY(u8, key_flex); + };
+};What's with this 1 byte key versus flex length key? When would there only be a 1 byte key value, and why wouldn't the flex array work for it? Without more description, this looks like unnecessary complexity.
Removed the key[1] as it is not being used, that results in removing union as well but we still need __DECLARE_FLEX_ARRAY macro. Without that the size of the struct would be 7 bytes and the compiler rounds it up to 8 bytes.
Quoted 52 lines
Quoted 52 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +29
-0+ +VIRTCHNL2_CHECK_STRUCT_LEN (8 , virtchnl2_rss_key); + +/* structure to specify a chunk of contiguous queues */ +struct virtchnl2_queue_chunk { + /* See VIRTCHNL2_QUEUE_TYPE definitions */ + __le32 type; + __le32 start_queue_id; + __le32 num_queues; + u8 pad[4]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (16 , virtchnl2_queue_chunk); + +/* Structure to specify several chunks of contiguous queues */ +struct virtchnl2_queue_chunks { + __le16 num_chunks; + u8 pad[6]; + + struct virtchnl2_queue_chunk chunks[]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (8 , virtchnl2_queue_chunks); + +/* VIRTCHNL2_OP_ENABLE_QUEUES +* VIRTCHNL2_OP_DISABLE_QUEUES +* VIRTCHNL2_OP_DEL_QUEUES +* +* PF sends these messages to enable, disable or delete queues specified in
+ * chunks. PF sendsvirtchnl2_del_ena_dis_queuesstruct to specify the queues
+ * to be enabled/disabled/deleted. Also applicable to single queue receive or
+ * transmit. CP performs requested action and returns status.
+ */drivers/net/ethernet/intel/idpf/virtchnl2.h new file +16
-0+struct virtchnl2_del_ena_dis_queues { + __le32 vport_id; + u8 pad[4]; + + struct virtchnl2_queue_chunks chunks; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (16 , virtchnl2_del_ena_dis_queues); + +/* Queue to vector mapping */ +struct virtchnl2_queue_vector { + __le32 queue_id; + __le16 vector_id; + u8 pad[2]; + + /* See VIRTCHNL2_ITR_IDX definitions */
Quoted 9 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h line 1071
Quoted 6 lines
+
__le32itr_idx;drivers/net/ethernet/intel/idpf/virtchnl2.h new file +5
-0+ + /* See VIRTCHNL2_QUEUE_TYPE definitions */ + __le32 queue_type; + u8 pad1[8]; +};Why the end padding? What's wrong with the 16-byte size?
The end padding is added for any possible future additions of the fields to this structure. Didn't get the ask for 16-byte size, can you please elaborate?
Quoted 127 lines
Quoted 114 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +10
-0+ +VIRTCHNL2_CHECK_STRUCT_LEN (24 , virtchnl2_queue_vector); + +/* VIRTCHNL2_OP_MAP_QUEUE_VECTOR +* VIRTCHNL2_OP_UNMAP_QUEUE_VECTOR +* +* PF sends this message to map or unmap queues to vectors and interrupt +* throttling rate index registers. External data buffer contains +* virtchnl2_queue_vector_maps structure that contains num_qv_maps of +* virtchnl2_queue_vector structures. CP maps the requested queue vector maps
+ * after validating the queue and vector ids and returns a status code.
+ */drivers/net/ethernet/intel/idpf/virtchnl2.h new file +14
-0+struct virtchnl2_queue_vector_maps { + __le32 vport_id; + + __le16 num_qv_maps; + u8 pad[10]; + + struct virtchnl2_queue_vector qv_maps[]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (16 , virtchnl2_queue_vector_maps); + +/* VIRTCHNL2_OP_LOOPBACK +* +* PF/VF sends this message to transition to/from the loopback state. Setting
+ * the 'enable' to 1 enables the loopback state and setting 'enable' to 0
+ * disables it. CP configures the state to loopback and returns status.
+ */drivers/net/ethernet/intel/idpf/virtchnl2.h new file +24
-0+struct virtchnl2_loopback { + __le32 vport_id; + + u8 enable; + u8 pad[3]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (8 , virtchnl2_loopback); + +/* Structure to specify each MAC address */ +struct virtchnl2_mac_addr { + u8 addr[ETH_ALEN]; + /* See VIRTCHNL2_MAC_TYPE definitions */ + u8 type; + u8 pad; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (8 , virtchnl2_mac_addr); + +/* VIRTCHNL2_OP_ADD_MAC_ADDR +* VIRTCHNL2_OP_DEL_MAC_ADDR +* +* PF/VF driver uses this structure to send list of MAC addresses to be +* added/deleted to the CP where as CP performs the action and returns the
+ * status.
+ */drivers/net/ethernet/intel/idpf/virtchnl2.h new file +14
-0+struct virtchnl2_mac_addr_list { + __le32 vport_id; + + __le16 num_mac_addr; + u8 pad[2]; + + struct virtchnl2_mac_addr mac_addr_list[]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (8 , virtchnl2_mac_addr_list); + +/* VIRTCHNL2_OP_CONFIG_PROMISCUOUS_MODE +* +* PF/VF sends vport id and flags to the CP where as CP performs the action
+ * and returns the status.
+ */drivers/net/ethernet/intel/idpf/virtchnl2.h new file +11
-0+struct virtchnl2_promisc_info { + __le32 vport_id; + + /* See VIRTCHNL2_PROMISC_FLAGS definitions */ + __le16 flags; + u8 pad[2]; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (8 , virtchnl2_promisc_info); + +#endif /* _VIRTCHNL_2_H_ */ drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h new file +21
-0@@ -0,0 +1,644 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright (C) 2023 Intel Corporation */ + +#ifndef _VIRTCHNL2_LAN_DESC_H_ +#define _VIRTCHNL2_LAN_DESC_H_ + +#include <linux/bits.h> + +/* VIRTCHNL2_TX_DESC_IDS +* Transmit descriptor ID flags +*/ +#define VIRTCHNL2_TXDID_DATA BIT(0) +#define VIRTCHNL2_TXDID_CTX BIT(1) +/* TXDID 2 is reserved +* TXDID 3 is free for future use +* TXDID 4 is reserved +*/ +#define VIRTCHNL2_TXDID_FLEX_TSO_CTX BIT(5) +/* TXDID 6 is reserved */ +#define VIRTCHNL2_TXDID_FLEX_L2TAG1_L2TAG2 BIT(7) +/* TXDID 8, 9 are free for future use drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h line 31
Quoted 10 lines
drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h new file +10
-0+* TXDID 10 is reserved +* TXDID 11 is free for future use +*/ +#define VIRTCHNL2_TXDID_FLEX_FLOW_SCHED BIT(12) +/* TXDID 13, 14 are free for future use */ +#define VIRTCHNL2_TXDID_DESC_DONE BIT(15) + +/* VIRTCHNL2_RX_DESC_IDS +* Receive descriptor IDs (range from 0 to 63) +*/ Again, enum for these lists of values
Quoted 12 lines
drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h line 40
Quoted 9 lines
drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h new file +9
-0+#define VIRTCHNL2_RXDID_0_16B_BASE 0 +#define VIRTCHNL2_RXDID_1_32B_BASE 1 +/* FLEX_SQ_NIC and FLEX_SPLITQ share desc ids because they can be +* differentiated based on queue model; e.g. single queue model can +* only use FLEX_SQ_NIC and split queue model can only use FLEX_SPLITQ +* for DID 2. +*/ +#define VIRTCHNL2_RXDID_2_FLEX_SPLITQ 2 +#define VIRTCHNL2_RXDID_2_FLEX_SQ_NIC 2Maybe set
VIRTCHNL2_RXDID_2_FLEX_SQ_NICto valueVIRTCHNL2_RXDID_2_FLEX_SPLITQinstead of '2' to help make it clear this isn't a mistake.
The comment above explains the reason for doing it. Based on your suggestion, updated the VIRTCHNL2_RXDID_2_FLEX_SQ_NIC with VIRTCHNL2_RXDID_2_FLEX_SPLITQ to make it more clear. It will be in v2.
Quoted 246 lines
Quoted 246 lines
drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h new file +18
-0+#define VIRTCHNL2_RXDID_3_FLEX_SQ_SW 3 +#define VIRTCHNL2_RXDID_4_FLEX_SQ_NIC_VEB 4 +#define VIRTCHNL2_RXDID_5_FLEX_SQ_NIC_ACL 5 +#define VIRTCHNL2_RXDID_6_FLEX_SQ_NIC_2 6 +#define VIRTCHNL2_RXDID_7_HW_RSVD 7 +/* 9 through 15 are reserved */ +#define VIRTCHNL2_RXDID_16_COMMS_GENERIC 16 +#define VIRTCHNL2_RXDID_17_COMMS_AUX_VLAN 17 +#define VIRTCHNL2_RXDID_18_COMMS_AUX_IPV4 18 +#define VIRTCHNL2_RXDID_19_COMMS_AUX_IPV6 19 +#define VIRTCHNL2_RXDID_20_COMMS_AUX_FLOW 20 +#define VIRTCHNL2_RXDID_21_COMMS_AUX_TCP 21 +/* 22 through 63 are reserved */ + +/* VIRTCHNL2_RX_DESC_ID_BITMASKS +* Receive descriptor ID bitmasks +*/ +#define VIRTCHNL2_RXDID_M (bit)
BIT_ULL(VIRTCHNL2_RXDID_##bit)
+#defineVIRTCHNL2_RXDID_0_16B_BASE_MVIRTCHNL2_RXDID_M(0_16B_BASE)
+#defineVIRTCHNL2_RXDID_1_32B_BASE_MVIRTCHNL2_RXDID_M(1_32B_BASE)
+#defineVIRTCHNL2_RXDID_2_FLEX_SPLITQ_MVIRTCHNL2_RXDID_M(2_FLEX_SPLITQ)
+#defineVIRTCHNL2_RXDID_2_FLEX_SQ_NIC_MVIRTCHNL2_RXDID_M(2_FLEX_SQ_NIC)
+#defineVIRTCHNL2_RXDID_3_FLEX_SQ_SW_MVIRTCHNL2_RXDID_M(3_FLEX_SQ_SW)
+#defineVIRTCHNL2_RXDID_4_FLEX_SQ_NIC_VEB_MVIRTCHNL2_RXDID_M(4_FLEX_SQ_NIC_VEB)
+#defineVIRTCHNL2_RXDID_5_FLEX_SQ_NIC_ACL_MVIRTCHNL2_RXDID_M(5_FLEX_SQ_NIC_ACL)
+#defineVIRTCHNL2_RXDID_6_FLEX_SQ_NIC_2_MVIRTCHNL2_RXDID_M(6_FLEX_SQ_NIC_2)
+#defineVIRTCHNL2_RXDID_7_HW_RSVD_MVIRTCHNL2_RXDID_M(7_HW_RSVD)drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h new file +2
-0+/* 9 through 15 are reserved */ +#define VIRTCHNL2_RXDID_16_COMMS_GENERIC_M
VIRTCHNL2_RXDID_M(16_COMMS_GENERIC)
+#defineVIRTCHNL2_RXDID_17_COMMS_AUX_VLAN_MVIRTCHNL2_RXDID_M(17_COMMS_AUX_VLAN)
+#defineVIRTCHNL2_RXDID_18_COMMS_AUX_IPV4_MVIRTCHNL2_RXDID_M(18_COMMS_AUX_IPV4)
+#defineVIRTCHNL2_RXDID_19_COMMS_AUX_IPV6_MVIRTCHNL2_RXDID_M(19_COMMS_AUX_IPV6)
+#defineVIRTCHNL2_RXDID_20_COMMS_AUX_FLOW_MVIRTCHNL2_RXDID_M(20_COMMS_AUX_FLOW)
+#defineVIRTCHNL2_RXDID_21_COMMS_AUX_TCP_MVIRTCHNL2_RXDID_M(21_COMMS_AUX_TCP)drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h new file +66
-0+/* 22 through 63 are reserved */ + +/* Rx */ +/* For splitq virtchnl2_rx_flex_desc_adv desc members */ +#define VIRTCHNL2_RX_FLEX_DESC_ADV_RXDID_S 0 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_RXDID_M GENMASK(3, 0) +#define VIRTCHNL2_RX_FLEX_DESC_ADV_UMBCAST_S 6 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_UMBCAST_M GENMASK(7, 6) +#define VIRTCHNL2_RX_FLEX_DESC_ADV_PTYPE_S 0 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_PTYPE_M GENMASK(9, 0) +#define VIRTCHNL2_RX_FLEX_DESC_ADV_FF0_S 12 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_FF0_M GENMASK(15, 13) +#define VIRTCHNL2_RX_FLEX_DESC_ADV_LEN_PBUF_S 0 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_LEN_PBUF_M GENMASK(13, 0) +#define VIRTCHNL2_RX_FLEX_DESC_ADV_GEN_S 14 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_GEN_M \ + BIT_ULL(VIRTCHNL2_RX_FLEX_DESC_ADV_GEN_S) +#define VIRTCHNL2_RX_FLEX_DESC_ADV_BUFQ_ID_S 15 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_BUFQ_ID_M \ + BIT_ULL(VIRTCHNL2_RX_FLEX_DESC_ADV_BUFQ_ID_S) +#define VIRTCHNL2_RX_FLEX_DESC_ADV_LEN_HDR_S 0 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_LEN_HDR_M GENMASK(9, 0) +#define VIRTCHNL2_RX_FLEX_DESC_ADV_RSC_S 10 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_RSC_M \ + BIT_ULL(VIRTCHNL2_RX_FLEX_DESC_ADV_RSC_S) +#define VIRTCHNL2_RX_FLEX_DESC_ADV_SPH_S 11 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_SPH_M \ + BIT_ULL(VIRTCHNL2_RX_FLEX_DESC_ADV_SPH_S) +#define VIRTCHNL2_RX_FLEX_DESC_ADV_FF1_S 12 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_FF1_M GENMASK(14, 12) +#define VIRTCHNL2_RX_FLEX_DESC_ADV_MISS_S 15 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_MISS_M \ + BIT_ULL(VIRTCHNL2_RX_FLEX_DESC_ADV_MISS_S) + +/* VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS_ERROR_0_QW1_BITS +* For splitq virtchnl2_rx_flex_desc_adv +* Note: These are predefined bit offsets +*/ +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_DD_S 0 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_EOF_S 1 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_HBO_S 2 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_L3L4P_S 3 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_XSUM_IPE_S 4 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_XSUM_L4E_S 5 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_XSUM_EIPE_S 6 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_XSUM_EUDPE_S 7 + +/* VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS_ERROR_0_QW0_BITS +* For splitq virtchnl2_rx_flex_desc_adv +* Note: These are predefined bit offsets +*/ +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_LPBK_S 0 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_IPV6EXADD_S 1 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_RXE_S 2 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_CRCP_S 3 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_RSS_VALID_S 4 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_L2TAG1P_S 5 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_XTRMD0_VALID_S 6 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_XTRMD1_VALID_S 7 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_LAST 8 + +/* VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS_ERROR_1_BITS +* For splitq virtchnl2_rx_flex_desc_adv +* Note: These are predefined bit offsets +*/ +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS1_RSVD_S 0/* 2 bits */
drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h new file +16
-0+#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS1_ATRAEFAIL_S 2 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS1_L2TAG2P_S 3 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS1_XTRMD2_VALID_S 4 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS1_XTRMD3_VALID_S 5 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS1_XTRMD4_VALID_S 6 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS1_XTRMD5_VALID_S 7 +#define VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS1_LAST 8 + +/* For singleq (flex) virtchnl2_rx_flex_desc fields */ +/* For virtchnl2_rx_flex_desc.ptype_flex_flags0 member */ +#define VIRTCHNL2_RX_FLEX_DESC_PTYPE_S 0 +#define VIRTCHNL2_RX_FLEX_DESC_PTYPE_M GENMASK(9, 0) + +/* For virtchnl2_rx_flex_desc.pkt_len member */ +#define VIRTCHNL2_RX_FLEX_DESC_PKT_LEN_S 0 +#define VIRTCHNL2_RX_FLEX_DESC_PKT_LEN_M
GENMASK(13, 0)drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h new file +28
-0+ +/* VIRTCHNL2_RX_FLEX_DESC_STATUS_ERROR_0_BITS +* For singleq (flex) virtchnl2_rx_flex_desc +* Note: These are predefined bit offsets +*/ +#define VIRTCHNL2_RX_FLEX_DESC_STATUS0_DD_S 0 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS0_EOF_S 1 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS0_HBO_S 2 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS0_L3L4P_S 3 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS0_XSUM_IPE_S 4 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS0_XSUM_L4E_S 5 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS0_XSUM_EIPE_S 6 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS0_XSUM_EUDPE_S 7 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS0_LPBK_S 8 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS0_IPV6EXADD_S 9 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS0_RXE_S 10 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS0_CRCP_S 11 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS0_RSS_VALID_S 12 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS0_L2TAG1P_S 13 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS0_XTRMD0_VALID_S 14 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS0_XTRMD1_VALID_S 15 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS0_LAST 16 + +/* VIRTCHNL2_RX_FLEX_DESC_STATUS_ERROR_1_BITS +* For singleq (flex) virtchnl2_rx_flex_desc +* Note: These are predefined bit offsets +*/ +#define VIRTCHNL2_RX_FLEX_DESC_STATUS1_CPM_S 0/* 4 bits */
drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h new file +14
-0+#define VIRTCHNL2_RX_FLEX_DESC_STATUS1_NAT_S 4 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS1_CRYPTO_S 5 +/* [10:6] reserved */ +#define VIRTCHNL2_RX_FLEX_DESC_STATUS1_L2TAG2P_S 11 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS1_XTRMD2_VALID_S 12 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS1_XTRMD3_VALID_S 13 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS1_XTRMD4_VALID_S 14 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS1_XTRMD5_VALID_S 15 +#define VIRTCHNL2_RX_FLEX_DESC_STATUS1_LAST 16 + +/* For virtchnl2_rx_flex_desc.ts_low member */ +#define VIRTCHNL2_RX_FLEX_TSTAMP_VALID BIT(0) + +/* For singleq (non flex) virtchnl2_singleq_base_rx_desc legacy desc members */
drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h new file +26
-0+#define VIRTCHNL2_RX_BASE_DESC_QW1_LEN_SPH_S 63 +#define VIRTCHNL2_RX_BASE_DESC_QW1_LEN_SPH_M \ + BIT_ULL(VIRTCHNL2_RX_BASE_DESC_QW1_LEN_SPH_S) +#define VIRTCHNL2_RX_BASE_DESC_QW1_LEN_HBUF_S 52 +#define VIRTCHNL2_RX_BASE_DESC_QW1_LEN_HBUF_M GENMASK_ULL(62, 52) +#define VIRTCHNL2_RX_BASE_DESC_QW1_LEN_PBUF_S 38 +#define VIRTCHNL2_RX_BASE_DESC_QW1_LEN_PBUF_M GENMASK_ULL(51, 38) +#define VIRTCHNL2_RX_BASE_DESC_QW1_PTYPE_S 30 +#define VIRTCHNL2_RX_BASE_DESC_QW1_PTYPE_M GENMASK_ULL(37, 30) +#define VIRTCHNL2_RX_BASE_DESC_QW1_ERROR_S 19 +#define VIRTCHNL2_RX_BASE_DESC_QW1_ERROR_M GENMASK_ULL(26, 19) +#define VIRTCHNL2_RX_BASE_DESC_QW1_STATUS_S 0 +#define VIRTCHNL2_RX_BASE_DESC_QW1_STATUS_M GENMASK_ULL(18, 0) + +/* VIRTCHNL2_RX_BASE_DESC_STATUS_BITS +* For singleq (base) virtchnl2_rx_base_desc +* Note: These are predefined bit offsets +*/ +#define VIRTCHNL2_RX_BASE_DESC_STATUS_DD_S 0 +#define VIRTCHNL2_RX_BASE_DESC_STATUS_EOF_S 1 +#define VIRTCHNL2_RX_BASE_DESC_STATUS_L2TAG1P_S 2 +#define VIRTCHNL2_RX_BASE_DESC_STATUS_L3L4P_S 3 +#define VIRTCHNL2_RX_BASE_DESC_STATUS_CRCP_S 4 +#define VIRTCHNL2_RX_BASE_DESC_STATUS_RSVD_S 5/* 3 bits */ +#define VIRTCHNL2_RX_BASE_DESC_STATUS_EXT_UDP_0_S 8 +#define VIRTCHNL2_RX_BASE_DESC_STATUS_UMBCAST_S 9/* 2 bits */
drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h new file +2
-0+#define VIRTCHNL2_RX_BASE_DESC_STATUS_FLM_S 11 +#define VIRTCHNL2_RX_BASE_DESC_STATUS_FLTSTAT_S 12/* 2 bits */
drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h new file +38
-0+#define VIRTCHNL2_RX_BASE_DESC_STATUS_LPBK_S 14 +#define VIRTCHNL2_RX_BASE_DESC_STATUS_IPV6EXADD_S 15 +#define VIRTCHNL2_RX_BASE_DESC_STATUS_RSVD1_S 16/* 2 bits */ +#define VIRTCHNL2_RX_BASE_DESC_STATUS_INT_UDP_0_S 18 +#define VIRTCHNL2_RX_BASE_DESC_STATUS_LAST 19 + +/* VIRTCHNL2_RX_BASE_DESC_EXT_STATUS_BITS +* For singleq (base) virtchnl2_rx_base_desc +* Note: These are predefined bit offsets +*/ +#define VIRTCHNL2_RX_BASE_DESC_EXT_STATUS_L2TAG2P_S 0 + +/* VIRTCHNL2_RX_BASE_DESC_ERROR_BITS +* For singleq (base) virtchnl2_rx_base_desc +* Note: These are predefined bit offsets +*/ +#define VIRTCHNL2_RX_BASE_DESC_ERROR_RXE_S 0 +#define VIRTCHNL2_RX_BASE_DESC_ERROR_ATRAEFAIL_S 1 +#define VIRTCHNL2_RX_BASE_DESC_ERROR_HBO_S 2 +#define VIRTCHNL2_RX_BASE_DESC_ERROR_L3L4E_S 3/* 3 bits */ +#define VIRTCHNL2_RX_BASE_DESC_ERROR_IPE_S 3 +#define VIRTCHNL2_RX_BASE_DESC_ERROR_L4E_S 4 +#define VIRTCHNL2_RX_BASE_DESC_ERROR_EIPE_S 5 +#define VIRTCHNL2_RX_BASE_DESC_ERROR_OVERSIZE_S 6 +#define VIRTCHNL2_RX_BASE_DESC_ERROR_PPRS_S 7 + +/* VIRTCHNL2_RX_BASE_DESC_FLTSTAT_VALUES +* For singleq (base) virtchnl2_rx_base_desc +* Note: These are predefined bit offsets +*/ +#define VIRTCHNL2_RX_BASE_DESC_FLTSTAT_NO_DATA 0 +#define VIRTCHNL2_RX_BASE_DESC_FLTSTAT_FD_ID 1 +#define VIRTCHNL2_RX_BASE_DESC_FLTSTAT_RSV 2 +#define VIRTCHNL2_RX_BASE_DESC_FLTSTAT_RSS_HASH 3 + +/* Receive Descriptors */ +/* Splitq buf +* | 16| 0|
Quoted 9 lines
Quoted 6 lines
+ * ----------------------------------------------------------------
+ * | RSV | Buffer ID |
+ * ----------------------------------------------------------------
+ * | Rx packet buffer adresss |
+ * ----------------------------------------------------------------
+ * | Rx header buffer adresss |%s/adresss/address/g
Fixed ( will be in v2).
Quoted 374 lines
Quoted 70 lines
+ * ----------------------------------------------------------------
+ * | RSV |
+ * ----------------------------------------------------------------
+ * | 0|
+ */drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h new file +65
-0+struct virtchnl2_splitq_rx_buf_desc { + struct { + /* Buffer Identifier */ + __le16 buf_id; + __le16 rsvd0; + __le32 rsvd1; + } qword0; + + /* Packet buffer address */ + __le64 pkt_addr; + /* Header buffer address */ + __le64 hdr_addr; + __le64 rsvd2; +};/* RX buffer descriptor format */ + +/* Singleq buf +* | 0| +* ---------------------------------------------------------------- +* | Rx packet buffer adresss | +* ---------------------------------------------------------------- +* | Rx header buffer adresss | +* ---------------------------------------------------------------- +* | RSV | +* ---------------------------------------------------------------- +* | RSV | +* ---------------------------------------------------------------- +* | 0| +*/ +struct virtchnl2_singleq_rx_buf_desc { + /* Packet buffer address */ + __le64 pkt_addr; + /* Header buffer address */ + __le64 hdr_addr; + __le64 rsvd1; + __le64 rsvd2; +};/* RX buffer descriptor format */ + +union virtchnl2_rx_buf_desc { + struct virtchnl2_singleq_rx_buf_desc read; + struct virtchnl2_splitq_rx_buf_desc split_rd; +}; + +/* (0x00) singleq wb(compl) */ +struct virtchnl2_singleq_base_rx_desc { + struct { + struct { + __le16 mirroring_status; + __le16 l2tag1; + } lo_dword; + union { + /* RSS Hash */ + __le32 rss; + /* Flow Director filter id */ + __le32 fd_id; + } hi_dword; + } qword0; + + struct { + /* status/error/PTYPE/length */ + __le64 status_error_ptype_len; + } qword1; + + struct { + /* Extended status */ + __le16 ext_status;drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h line 350
Quoted 10 lines
drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h new file +10
-0+ __le16 rsvd; + __le16 l2tag2_1; + __le16 l2tag2_2; + } qword2; + + struct { + __le32 reserved; + __le32 fd_id; + } qword3; +};/* RX descriptor writeback format */ Hmmm... looks a lot like the Fortville descriptor :-)
Quoted 290 lines
drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h new file +290
-0+ +/* (0x01) singleq flex compl */ +struct virtchnl2_rx_flex_desc { + /* Qword 0 */ + /* Descriptor builder profile id */ + u8 rxdid; + + /* mirror=[5:0], umb=[7:6] */ + u8 mir_id_umb_cast; + + /* ptype=[9:0], ff0=[15:10] */ + __le16 ptype_flex_flags0; + + /* [15:14] are reserved */ + __le16 pkt_len; + + /* header=[10:0] + * sph=[11] + * ff1/ext=[15:12] + */ + __le16 hdr_len_sph_flex_flags1; + + /* Qword 1 */ + __le16 status_error0; + __le16 l2tag1; + __le16 flex_meta0; + __le16 flex_meta1; + + /* Qword 2 */ + __le16 status_error1; + u8 flex_flags2; + u8 time_stamp_low; + __le16 l2tag2_1st; + __le16 l2tag2_2nd; + + /* Qword 3 */ + __le16 flex_meta2; + __le16 flex_meta3; + union { + struct { + __le16 flex_meta4; + __le16 flex_meta5; + } flex; + __le32 ts_high; + } flex_ts; +};/* RX descriptor writeback format */ + +/* (0x02) */ +struct virtchnl2_rx_flex_desc_nic { + /* Qword 0 */ + u8 rxdid; + u8 mir_id_umb_cast; + __le16 ptype_flex_flags0; + __le16 pkt_len; + __le16 hdr_len_sph_flex_flags1; + + /* Qword 1 */ + __le16 status_error0; + __le16 l2tag1; + __le32 rss_hash; + + /* Qword 2 */ + __le16 status_error1; + u8 flexi_flags2; + u8 ts_low; + __le16 l2tag2_1st; + __le16 l2tag2_2nd; + + /* Qword 3 */ + __le32 flow_id; + union { + struct { + __le16 rsvd; + __le16 flow_id_ipv6; + } flex; + __le32 ts_high; + } flex_ts; +};/* RX descriptor writeback format */ + +/* Rx Flex Descriptor Switch Profile +* RxDID Profile Id 3 +* Flex-field 0: Source Vsi +*/ +struct virtchnl2_rx_flex_desc_sw { + /* Qword 0 */ + u8 rxdid; + u8 mir_id_umb_cast; + __le16 ptype_flex_flags0; + __le16 pkt_len; + __le16 hdr_len_sph_flex_flags1; + + /* Qword 1 */ + __le16 status_error0; + __le16 l2tag1; + /* [10:15] are reserved */ + __le16 src_vsi; + __le16 flex_md1_rsvd; + + /* Qword 2 */ + __le16 status_error1; + u8 flex_flags2; + u8 ts_low; + __le16 l2tag2_1st; + __le16 l2tag2_2nd; + + /* Qword 3 */ + /* Flex words 2-3 are reserved */ + __le32 rsvd; + __le32 ts_high; +};/* RX descriptor writeback format */ + +/* Rx Flex Descriptor NIC Profile +* RxDID Profile Id 6 +* Flex-field 0: RSS hash lower 16-bits +* Flex-field 1: RSS hash upper 16-bits +* Flex-field 2: Flow Id lower 16-bits +* Flex-field 3: Source Vsi +* Flex-field 4: reserved, Vlan id taken from L2Tag +*/ +struct virtchnl2_rx_flex_desc_nic_2 { + /* Qword 0 */ + u8 rxdid; + u8 mir_id_umb_cast; + __le16 ptype_flex_flags0; + __le16 pkt_len; + __le16 hdr_len_sph_flex_flags1; + + /* Qword 1 */ + __le16 status_error0; + __le16 l2tag1; + __le32 rss_hash; + + /* Qword 2 */ + __le16 status_error1; + u8 flexi_flags2; + u8 ts_low; + __le16 l2tag2_1st; + __le16 l2tag2_2nd; + + /* Qword 3 */ + __le16 flow_id; + __le16 src_vsi; + union { + struct { + __le16 rsvd; + __le16 flow_id_ipv6; + } flex; + __le32 ts_high; + } flex_ts; +};/* RX descriptor writeback format */ + +/* Rx Flex Descriptor Advanced (Split Queue Model) +* RxDID Profile Id 7 +*/ +struct virtchnl2_rx_flex_desc_adv { + /* Qword 0 */ + /* profile_id=[3:0] + * rsvd=[5:4] + * ucast=[7:6] + */ + u8 rxdid_ucast; + + u8 status_err0_qw0; + + /* ptype=[9:0] + * ip_hdr_err=[10] + * udp_len_err=[11] + * ff0=[15:12] + */ + __le16 ptype_err_fflags0; + + /* plen=[13:0] + * gen=[14] only in splitq + * bufq_id=[15] only in splitq + */ + __le16 pktlen_gen_bufq_id; + + /* header=[9:0] + * rsc=[10] only in splitq + * sph=[11] only in splitq + * ext_udp_0=[12] + * int_udp_0=[13] + * trunc_mirr=[14] + * miss_prepend=[15] + */ + __le16 hdrlen_flags; + + /* Qword 1 */ + u8 status_err0_qw1; + u8 status_err1; + u8 fflags1; + u8 ts_low; + __le16 fmd0; + __le16 fmd1; + + /* Qword 2 */ + __le16 fmd2; + u8 fflags2; + u8 hash3; + __le16 fmd3; + __le16 fmd4; + + /* Qword 3 */ + __le16 fmd5; + __le16 fmd6; + __le16 fmd7_0; + __le16 fmd7_1; +};/* RX descriptor writeback format */ + +/* Rx Flex Descriptor Advanced (Split Queue Model) NIC Profile +* RxDID Profile Id 8 +* Flex-field 0: BufferID +* Flex-field 1: Raw checksum/L2TAG1/RSC Seg Len (determined by HW) +* Flex-field 2: Hash[15:0] +* Flex-flags 2: Hash[23:16] +* Flex-field 3: L2TAG2 +* Flex-field 5: L2TAG1 +* Flex-field 7: Timestamp (upper 32 bits) +*/ +struct virtchnl2_rx_flex_desc_adv_nic_3 { + /* Qword 0 */ + /* profile_id=[3:0] + * rsvd=[5:4] + * ucast=[7:6] + */ + u8 rxdid_ucast; + + u8 status_err0_qw0; + + /* ptype=[9:0] + * ip_hdr_err=[10] + * udp_len_err=[11] + * ff0=[15:12] + */ + __le16 ptype_err_fflags0; + + /* plen=[13:0] + * gen=[14] only in splitq + * bufq_id=[15] only in splitq + */ + __le16 pktlen_gen_bufq_id; + + /* header=[9:0] + * rsc=[10] only in splitq + * sph=[11] only in splitq + * ext_udp_0=[12] + * int_udp_0=[13] + * trunc_mirr=[14] + * miss_prepend=[15] + */ + __le16 hdrlen_flags; + + /* Qword 1 */ + u8 status_err0_qw1; + u8 status_err1; + u8 fflags1; + u8 ts_low; + /* Only in splitq */ + __le16 buf_id; + union { + __le16 raw_cs; + __le16 l2tag1; + __le16 rscseglen; + } misc; + + /* Qword 2 */ + __le16 hash1; + union { + u8 fflags2; + u8 mirrorid; + u8 hash2; + } ff2_mirrid_hash2; + u8 hash3; + __le16 l2tag2; + __le16 fmd4; + + /* Qword 3 */ + __le16 l2tag1; + __le16 fmd6; + __le32 ts_high; +};/* RX descriptor writeback format */ + +union virtchnl2_rx_desc { + struct virtchnl2_singleq_rx_buf_desc read; + struct virtchnl2_singleq_base_rx_desc base_wb; + struct virtchnl2_rx_flex_desc flex_wb; + struct virtchnl2_rx_flex_desc_nic flex_nic_wb; + struct virtchnl2_rx_flex_desc_sw flex_sw_wb; + struct virtchnl2_rx_flex_desc_nic_2 flex_nic_2_wb; + struct virtchnl2_rx_flex_desc_adv flex_adv_wb;
Quoted 8 lines
Quoted 8 lines
+ struct
virtchnl2_rx_flex_desc_adv_nic_3flex_adv_nic_3_wb;drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.h new file +3
-0+}; + +#endif /* _VIRTCHNL_LAN_DESC_H_ */ Signature · 1 line
2.37.3
Thanks,
Pavan
Re: [Intel-wired-lan] [PATCH net-next 01/15] virtchnl: add virtchnl version 2 ops
Quoted 11 lines · Pavan Kumar
Quoted 9 lines · Shannon Nelson
Quoted 8 lines · Pavan Kumar Linga
Virtchnl version 1 is an interface used by the current generation of foundational NICs to negotiate the capabilities and configure the HW resources such as queues, vectors, RSS LUT, etc between the PF and VF drivers. It is not extensible to enable new features supported in the next generation of NICs/IPUs and to negotiate descriptor types, packet types and register offsets.
[...]
Quoted 10 lines
Quoted 9 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h line 23
Quoted 6 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +6
-0+ +#include "virtchnl2_lan_desc.h" + +/* VIRTCHNL2_ERROR_CODES */ +/* Success */ +#define VIRTCHNL2_STATUS_SUCCESS 0Shouldn't these be enum and not #define?
Quoted 6 lines
This header file is describing communication protocol with opcodes, error codes, capabilities etc. that are exchanged between IDPF and device Control Plane. Compiler chooses the size of the enum based on the enumeration constants that are present which is not a constant size. But for virtchnl protocol, we want to have fixed size no matter what. To avoid such cases, we are using defines whereever necessary.
The field size limitations in an API are one thing, and that can be managed by using a u8/u16/u32 or whatever as necessary. But that doesn't mean that you can't define values to be assigned in those fields as enums, which are preferred when defining several related constants.
[...]
Quoted 17 lines
Quoted 16 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h line 437
Quoted 13 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +12
-0+ +/* VIRTCHNL2_OP_GET_EDT_CAPS +* Get EDT granularity and time horizon +*/ +struct virtchnl2_edt_caps { + /* Timestamp granularity in nanoseconds */ + __le64 tstamp_granularity_ns; + /* Total time window in nanoseconds */ + __le64 time_horizon_ns; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (16 , virtchnl2_edt_caps);Don't put a space between the struct and the check.
Quoted 5 lines
Checkpatch reports a warning (actually a 'Check') when the newline is removed. Following is the checkpatch output when the newline is removed:
"CHECK: Please use a blank line after function/struct/union/enum declarations"
Since it has to do directly with the finished definition, one would think it could follow the same rule as EXPORT... does. It might not be a bad idea at some point for static_assert() to be added to that allowed list. For now, though, since it is only a CHECK and not WARN or ERROR, you might be able to ignore it. It might be easier to ignore if you just used the existing static_assert() rather than definigin your own synonym.
[...]
Quoted 17 lines
Quoted 7 lines
Quoted 7 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +7
-0+/* Queue to vector mapping */ +struct virtchnl2_queue_vector { + __le32 queue_id; + __le16 vector_id; + u8 pad[2]; + + /* See VIRTCHNL2_ITR_IDX definitions */Quoted 9 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h line 1071
Quoted 6 lines
+
__le32itr_idx;drivers/net/ethernet/intel/idpf/virtchnl2.h new file +5
-0+ + /* See VIRTCHNL2_QUEUE_TYPE definitions */ + __le32 queue_type; + u8 pad1[8]; +};Why the end padding? What's wrong with the 16-byte size?
Quoted 3 lines
The end padding is added for any possible future additions of the fields to this structure. Didn't get the ask for 16-byte size, can you please elaborate?
Without the pad1[8], this struct is an even 16 bytes, seems like a logical place to stop. 24 bytes seems odd, if you're going to pad for the future it makes some sense to do it to an even 32 bytes (power-of-2). And please add a comment for this future thinking.
sln
Re: [Intel-wired-lan] [PATCH net-next 01/15] virtchnl: add virtchnl version 2 ops
Quoted 25 lines · Shannon Nelson
Quoted 11 lines · Pavan Kumar
Quoted 9 lines · Shannon Nelson
Quoted 8 lines · Pavan Kumar Linga
Virtchnl version 1 is an interface used by the current generation of foundational NICs to negotiate the capabilities and configure the HW resources such as queues, vectors, RSS LUT, etc between the PF and VF drivers. It is not extensible to enable new features supported in the next generation of NICs/IPUs and to negotiate descriptor types, packet types and register offsets.
[...]
Quoted 10 lines
Quoted 9 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h line 23
Quoted 6 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +6
-0+ +#include "virtchnl2_lan_desc.h" + +/* VIRTCHNL2_ERROR_CODES */ +/* Success */ +#define VIRTCHNL2_STATUS_SUCCESS 0Shouldn't these be enum and not #define?
Quoted 9 lines
Quoted 6 lines
This header file is describing communication protocol with opcodes, error codes, capabilities etc. that are exchanged between IDPF and device Control Plane. Compiler chooses the size of the enum based on the enumeration constants that are present which is not a constant size. But for virtchnl protocol, we want to have fixed size no matter what. To avoid such cases, we are using defines whereever necessary.
The field size limitations in an API are one thing, and that can be managed by using a u8/u16/u32 or whatever as necessary. But that doesn't mean that you can't define values to be assigned in those fields as enums, which are preferred when defining several related constants.
We can certainly look into it, but for the purpose of this series it doesn't seem like a meaningful change if it only helps with the grouping since the define names already follow a certain pattern to indicate that they are related.
Quoted 20 lines
[...]
Quoted 17 lines
Quoted 16 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h line 437
Quoted 13 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +12
-0+ +/* VIRTCHNL2_OP_GET_EDT_CAPS +* Get EDT granularity and time horizon +*/ +struct virtchnl2_edt_caps { + /* Timestamp granularity in nanoseconds */ + __le64 tstamp_granularity_ns; + /* Total time window in nanoseconds */ + __le64 time_horizon_ns; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (16 , virtchnl2_edt_caps);Don't put a space between the struct and the check.
Quoted 7 lines
Quoted 5 lines
Checkpatch reports a warning (actually a 'Check') when the newline is removed. Following is the checkpatch output when the newline is removed:
"CHECK: Please use a blank line after function/struct/union/enum declarations"
Since it has to do directly with the finished definition, one would think it could follow the same rule as EXPORT... does. It might not be a bad idea at some point for
static_assert()to be added to that allowed list. For now, though, since it is only a CHECK and not WARN or ERROR, you might be able to ignore it. It might be easier to ignore if you just used the existingstatic_assert()rather than definigin your own synonym.
OK, we'll remove it.
Quoted 21 lines
[...]
Quoted 17 lines
Quoted 16 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h line 1071
Quoted 13 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +13
-0+/* Queue to vector mapping */ +struct virtchnl2_queue_vector { + __le32 queue_id; + __le16 vector_id; + u8 pad[2]; + + /* See VIRTCHNL2_ITR_IDX definitions */ + __le32 itr_idx; + + /* See VIRTCHNL2_QUEUE_TYPE definitions */ + __le32 queue_type; + u8 pad1[8]; +};Why the end padding? What's wrong with the 16-byte size?
Quoted 5 lines
Quoted 3 lines
The end padding is added for any possible future additions of the fields to this structure. Didn't get the ask for 16-byte size, can you please elaborate?
Without the pad1[8], this struct is an even 16 bytes, seems like a logical place to stop. 24 bytes seems odd, if you're going to pad for the future it makes some sense to do it to an even 32 bytes (power-of-2). And please add a comment for this future thinking.
We can change the name to reserved to make it clearer, but the size cannot be changed because it's an ABI already.
Thanks,
Emil
Quoted 2 lines
sln
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Re: [Intel-wired-lan] [PATCH net-next 01/15] virtchnl: add virtchnl version 2 ops
Quoted 39 lines · Emil S
Quoted 32 lines · Shannon Nelson
Quoted 11 lines · Pavan Kumar
Quoted 9 lines · Shannon Nelson
Quoted 8 lines · Pavan Kumar Linga
Virtchnl version 1 is an interface used by the current generation of foundational NICs to negotiate the capabilities and configure the HW resources such as queues, vectors, RSS LUT, etc between the PF and VF drivers. It is not extensible to enable new features supported in the next generation of NICs/IPUs and to negotiate descriptor types, packet types and register offsets.
[...]
Quoted 10 lines
Quoted 9 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h line 23
Quoted 6 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +6
-0+ +#include "virtchnl2_lan_desc.h" + +/* VIRTCHNL2_ERROR_CODES */ +/* Success */ +#define VIRTCHNL2_STATUS_SUCCESS 0Shouldn't these be enum and not #define?
Quoted 6 lines
This header file is describing communication protocol with opcodes, error codes, capabilities etc. that are exchanged between IDPF and device Control Plane. Compiler chooses the size of the enum based on the enumeration constants that are present which is not a constant size. But for virtchnl protocol, we want to have fixed size no matter what. To avoid such cases, we are using defines whereever necessary.
Quoted 5 lines
The field size limitations in an API are one thing, and that can be managed by using a u8/u16/u32 or whatever as necessary. But that doesn't mean that you can't define values to be assigned in those fields as enums, which are preferred when defining several related constants.
Quoted 4 lines
We can certainly look into it, but for the purpose of this series it doesn't seem like a meaningful change if it only helps with the grouping since the define names already follow a certain pattern to indicate that they are related.
I was trying not to be overly pedantic, but the last words of that paragraph are copied directly from section 12 of the coding-style.rst. We should follow the wisdom therein.
Look, whether we like this patchset or not, it is going to get used as an example and a starting point for related work, so we need to be sure it serves as a good example. Let's start from the beginning with clean code.
Quoted 35 lines
Quoted 27 lines
[...]
Quoted 17 lines
Quoted 16 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h line 437
Quoted 13 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +12
-0+ +/* VIRTCHNL2_OP_GET_EDT_CAPS +* Get EDT granularity and time horizon +*/ +struct virtchnl2_edt_caps { + /* Timestamp granularity in nanoseconds */ + __le64 tstamp_granularity_ns; + /* Total time window in nanoseconds */ + __le64 time_horizon_ns; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (16 , virtchnl2_edt_caps);Don't put a space between the struct and the check.
Quoted 5 lines
Checkpatch reports a warning (actually a 'Check') when the newline is removed. Following is the checkpatch output when the newline is removed:
"CHECK: Please use a blank line after function/struct/union/enum declarations"
Quoted 7 lines
Since it has to do directly with the finished definition, one would think it could follow the same rule as EXPORT... does. It might not be a bad idea at some point for
static_assert()to be added to that allowed list. For now, though, since it is only a CHECK and not WARN or ERROR, you might be able to ignore it. It might be easier to ignore if you just used the existingstatic_assert()rather than definigin your own synonym.
Quoted 1 line
OK, we'll remove it.
I'm not sure 'it' means your synonym or the actual check. The check is a useful thing to help make sure no one screws up the API message layout, so don't remove the check itself. If you can't get away with ignoring the checkpatch.pl CHECK complaint about the line spacing, I'm fine with leaving it alone. Some other day we can look at teaching checkpatch.pl to allow static_assert() after a struct.
Quoted 26 lines
Quoted 26 lines
[...]
Quoted 20 lines
Quoted 7 lines
Quoted 7 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +7
-0+/* Queue to vector mapping */ +struct virtchnl2_queue_vector { + __le32 queue_id; + __le16 vector_id; + u8 pad[2]; + + /* See VIRTCHNL2_ITR_IDX definitions */Quoted 9 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h line 1071
Quoted 6 lines
+
__le32itr_idx;drivers/net/ethernet/intel/idpf/virtchnl2.h new file +5
-0+ + /* See VIRTCHNL2_QUEUE_TYPE definitions */ + __le32 queue_type; + u8 pad1[8]; +};Why the end padding? What's wrong with the 16-byte size?
The end padding is added for any possible future additions of the fields to this structure. Didn't get the ask for 16-byte size, can you please elaborate?
Quoted 7 lines
Quoted 4 lines
Without the pad1[8], this struct is an even 16 bytes, seems like a logical place to stop. 24 bytes seems odd, if you're going to pad for the future it makes some sense to do it to an even 32 bytes (power-of-2). And please add a comment for this future thinking.
We can change the name to reserved to make it clearer, but the size cannot be changed because it's an ABI already.
That's fine - just make sure it is clear this was intended.
sln
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Re: [Intel-wired-lan] [PATCH net-next 01/15] virtchnl: add virtchnl version 2 ops
Quoted 40 lines · Shannon Nelson
Quoted 39 lines · Emil S
Quoted 37 lines · Shannon Nelson
Quoted 11 lines · Pavan Kumar
Quoted 9 lines · Shannon Nelson
Quoted 8 lines · Pavan Kumar Linga
Virtchnl version 1 is an interface used by the current generation of foundational NICs to negotiate the capabilities and configure the HW resources such as queues, vectors, RSS LUT, etc between the PF and VF drivers. It is not extensible to enable new features supported in the next generation of NICs/IPUs and to negotiate descriptor types, packet types and register offsets.
[...]
Quoted 10 lines
Quoted 9 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h line 23
Quoted 6 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +6
-0+ +#include "virtchnl2_lan_desc.h" + +/* VIRTCHNL2_ERROR_CODES */ +/* Success */ +#define VIRTCHNL2_STATUS_SUCCESS 0Shouldn't these be enum and not #define?
Quoted 6 lines
This header file is describing communication protocol with opcodes, error codes, capabilities etc. that are exchanged between IDPF and device Control Plane. Compiler chooses the size of the enum based on the enumeration constants that are present which is not a constant size. But for virtchnl protocol, we want to have fixed size no matter what. To avoid such cases, we are using defines whereever necessary.
The field size limitations in an API are one thing, and that can be managed by using a u8/u16/u32 or whatever as necessary. But that doesn't mean that you can't define values to be assigned in those fields as enums, which are preferred when defining several related constants.
Quoted 8 lines
Quoted 4 lines
We can certainly look into it, but for the purpose of this series it doesn't seem like a meaningful change if it only helps with the grouping since the define names already follow a certain pattern to indicate that they are related.
I was trying not to be overly pedantic, but the last words of that paragraph are copied directly from section 12 of the
coding-style.rst. We should follow the wisdom therein.Look, whether we like this patchset or not, it is going to get used as an example and a starting point for related work, so we need to be sure it serves as a good example. Let's start from the beginning with clean code.
Got it. Will convert to enums in v3.
Quoted 36 lines
Quoted 36 lines
Quoted 35 lines
[...]
Quoted 17 lines
Quoted 16 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h line 437
Quoted 13 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +12
-0+ +/* VIRTCHNL2_OP_GET_EDT_CAPS +* Get EDT granularity and time horizon +*/ +struct virtchnl2_edt_caps { + /* Timestamp granularity in nanoseconds */ + __le64 tstamp_granularity_ns; + /* Total time window in nanoseconds */ + __le64 time_horizon_ns; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN (16 , virtchnl2_edt_caps);Don't put a space between the struct and the check.
Quoted 5 lines
Checkpatch reports a warning (actually a 'Check') when the newline is removed. Following is the checkpatch output when the newline is removed:
"CHECK: Please use a blank line after function/struct/union/enum declarations"
Since it has to do directly with the finished definition, one would think it could follow the same rule as EXPORT... does. It might not be a bad idea at some point for
static_assert()to be added to that allowed list. For now, though, since it is only a CHECK and not WARN or ERROR, you might be able to ignore it. It might be easier to ignore if you just used the existingstatic_assert()rather than definigin your own synonym.
Quoted 4 lines
Quoted 1 line
OK, we'll remove it.
I'm not sure 'it' means your synonym or the actual check. The check is a useful thing to help make sure no one screws up the API message layout, so don't remove the check itself. If you can't get away with ignoring the checkpatch.pl CHECK complaint about the line spacing, I'm fine with leaving it alone. Some other day we can look at teaching checkpatch.pl to allow
static_assert()after a struct.
I should have been more specific. I was referring to removing the blank line as I think we can live with the CHECK. Your call I guess.
Quoted 31 lines
Quoted 31 lines
Quoted 30 lines
[...]
Quoted 17 lines
Quoted 7 lines
Quoted 7 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h new file +7
-0+/* Queue to vector mapping */ +struct virtchnl2_queue_vector { + __le32 queue_id; + __le16 vector_id; + u8 pad[2]; + + /* See VIRTCHNL2_ITR_IDX definitions */Quoted 9 lines
drivers/net/ethernet/intel/idpf/virtchnl2.h line 1071
Quoted 6 lines
+
__le32itr_idx;drivers/net/ethernet/intel/idpf/virtchnl2.h new file +5
-0+ + /* See VIRTCHNL2_QUEUE_TYPE definitions */ + __le32 queue_type; + u8 pad1[8]; +};Why the end padding? What's wrong with the 16-byte size?
Quoted 3 lines
The end padding is added for any possible future additions of the fields to this structure. Didn't get the ask for 16-byte size, can you please elaborate?
Without the pad1[8], this struct is an even 16 bytes, seems like a logical place to stop. 24 bytes seems odd, if you're going to pad for the future it makes some sense to do it to an even 32 bytes (power-of-2). And please add a comment for this future thinking.
Quoted 4 lines
Quoted 2 lines
We can change the name to reserved to make it clearer, but the size cannot be changed because it's an ABI already.
That's fine - just make sure it is clear this was intended.
Right.
Thanks for the review,
Emil
Quoted 2 lines
sln
Re: [Intel-wired-lan] [PATCH net-next 01/15] virtchnl: add virtchnl version 2 ops
Quoted 54 lines · Emil S
Quoted 52 lines · Shannon Nelson
Quoted 42 lines · Emil S
Quoted 35 lines · Shannon Nelson
Quoted 12 lines · Pavan Kumar
Quoted 10 lines · Shannon Nelson
Quoted 9 lines · Pavan Kumar Linga
Virtchnl version 1 is an interface used by the current generation of foundational NICs to negotiate the capabilities and configure the HW resources such as queues, vectors, RSS LUT, etc between the PF and VF drivers. It is not extensible to enable new features supported in the next generation of NICs/IPUs and to negotiate descriptor types,
packet types and register offsets.[...]
Quoted 10 lines
Quoted 9 lines
Review
Quoted 6 lines
(quoted diff) +6
-0+ +#include "virtchnl2_lan_desc.h" + +/* VIRTCHNL2_ERROR_CODES */ +/* Success */ +#define VIRTCHNL2_STATUS_SUCCESS 0Shouldn't these be enum and not #define?
Quoted 8 lines
This header file is describing communication protocol with opcodes, error codes, capabilities etc. that are exchanged between IDPF and device Control Plane. Compiler chooses the size of the enum based on the
enumeration constants that are present which is not a constant size. But
for virtchnl protocol, we want to have fixed size no matter what. To avoid such cases, we are using defines whereever necessary.Quoted 5 lines
The field size limitations in an API are one thing, and that can be managed by using a u8/u16/u32 or whatever as necessary. But that doesn't mean that you can't define values to be assigned in those fields as enums, which are preferred when defining several related constants.
Quoted 4 lines
We can certainly look into it, but for the purpose of this series it doesn't seem like a meaningful change if it only helps with the grouping since the define names already follow a certain pattern to indicate that they are related.
I was trying not to be overly pedantic, but the last words of that paragraph are copied directly from section 12 of the
coding-style.rst. We should follow the wisdom therein.
Quoted 6 lines
Quoted 4 lines
Look, whether we like this patchset or not, it is going to get used as an example and a starting point for related work, so we need to be sure it serves as a good example. Let's start from the beginning with clean code.
Got it. Will convert to enums in v3.
Thanks
Quoted 48 lines
Quoted 38 lines
Quoted 38 lines
Quoted 37 lines
[...]
Quoted 17 lines
Quoted 16 lines
Review
Quoted 13 lines
(quoted diff) +12
-0+ +/* VIRTCHNL2_OP_GET_EDT_CAPS + * Get EDT granularity and time horizon + */ +struct virtchnl2_edt_caps { + /* Timestamp granularity in nanoseconds */ + __le64 tstamp_granularity_ns; + /* Total time window in nanoseconds */ + __le64 time_horizon_ns; +}; + +VIRTCHNL2_CHECK_STRUCT_LEN(16, virtchnl2_edt_caps);Don't put a space between the struct and the check.
Quoted 6 lines
Checkpatch reports a warning (actually a 'Check') when the newline is removed. Following is the checkpatch output when the newline is removed:
"CHECK: Please use a blank line after function/struct/union/enum declarations"
Since it has to do directly with the finished definition, one would think it could follow the same rule as EXPORT... does. It might not be a bad idea at some point for
static_assert()to be added to that allowed list. For now, though, since it is only a CHECK and not WARN or ERROR, you might be able to ignore it. It might be easier to ignore if you just used the existingstatic_assert()rather than definigin your own synonym.Quoted 9 lines
Quoted 1 line
OK, we'll remove it.
I'm not sure 'it' means your synonym or the actual check. The check is a useful thing to help make sure no one screws up the API message layout, so don't remove the check itself. If you can't get away with ignoring the checkpatch.pl CHECK complaint about the line spacing, I'm fine with leaving it alone. Some other day we can look at teaching checkpatch.pl to allow
static_assert()after a struct.
Quoted 2 lines
I should have been more specific. I was referring to removing the blank line as I think we can live with the CHECK. Your call I guess.
I'd prefer to live with the CHECK as long as Jakub and friends are good with it.
sln
Quoted 45 lines
Quoted 33 lines
Quoted 33 lines
Quoted 32 lines
[...]
Quoted 17 lines
Quoted 7 lines
Quoted 7 lines
(quoted diff) +7
-0+/* Queue to vector mapping */ +struct virtchnl2_queue_vector { + __le32 queue_id; + __le16 vector_id; + u8 pad[2]; + + /* See VIRTCHNL2_ITR_IDX definitions */Quoted 9 lines
Review
Quoted 6 lines
+
__le32itr_idx;(quoted diff) +5
-0+ + /* See VIRTCHNL2_QUEUE_TYPE definitions */ + __le32 queue_type; + u8 pad1[8]; +};Why the end padding? What's wrong with the 16-byte size?
Quoted 4 lines
The end padding is added for any possible future additions of the fields
to this structure. Didn't get the ask for 16-byte size, can you please elaborate?Without the pad1[8], this struct is an even 16 bytes, seems like a logical place to stop. 24 bytes seems odd, if you're going to pad for the future it makes some sense to do it to an even 32 bytes (power-of-2). And please add a comment for this future thinking.
Quoted 4 lines
Quoted 2 lines
We can change the name to reserved to make it clearer, but the size cannot be changed because it's an ABI already.
That's fine - just make sure it is clear this was intended.
Right.
Thanks for the review,
EmilQuoted 2 lines
sln