Introduce Intel IDPF driver
Subsystems (4)
v2 cover Introduce Intel IDPF driver
This patch series introduces the Intel 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.
v1 --> v2: link [1]
* removed the OASIS reference in the commit message to make it clear that this is an Intel vendor specific driver
* fixed misspells
* used comment starter "/**" for struct and definition headers in virtchnl header files
* removed AVF reference
* renamed APF reference to IDPF
* added a comment to explain the reason for 'no flex field' at the end of virtchnl2_get_ptype_info struct
* removed 'key[1]' in virtchnl2_rss_key struct as it is not used
* set VIRTCHNL2_RXDID_2_FLEX_SQ_NIC to VIRTCHNL2_RXDID_2_FLEX_SPLITQ instead of assigning the same value
* cleanup unnecessary NULL assignment to the rx_buf skb pointer since it is not used in splitq model
* added comments to clarify the generation bit usage in splitq model
* introduced 'reuse_bias' in the page_info structure and make use of it in the hot path
* fixed RCT format in idpf_rx_construct_skb
* report SPEED_UNKNOWN and DUPLEX_UNKNOWN when the link is down
* fixed -Wframe-larger-than warning reported by lkp bot in idpf_vport_queue_ids_init
* updated the documentation in idpf.rst to fix LKP bot warning
[1] https://lore.kernel.org/netdev/[email protected]/
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 | 162 + 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 | 188 + .../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 | 1330 +++++ .../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 | 4861 +++++++++++++++++ drivers/net/ethernet/intel/idpf/idpf_txrx.h | 854 +++ drivers/net/ethernet/intel/idpf/idpf_vf_dev.c | 180 + .../net/ethernet/intel/idpf/idpf_virtchnl.c | 3821 +++++++++++++ drivers/net/ethernet/intel/idpf/virtchnl2.h | 1201 ++++ .../ethernet/intel/idpf/virtchnl2_lan_desc.h | 666 +++ 25 files changed, 19629 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 · 6 lines
2.37.3 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
PATCH v2 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 · 6 lines
2.37.3 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
PATCH v2 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 · 6 lines
2.37.3 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
PATCH v2 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 · 6 lines
2.37.3 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
PATCH v2 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.
--- drivers/net/ethernet/intel/idpf/virtchnl2.h | 1201 +++++++++++++++++ .../ethernet/intel/idpf/virtchnl2_lan_desc.h | 666 +++++++++ 2 files changed, 1867 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 +1201 -0
@@ -0,0 +1,1201 @@ +/* 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 */ +/* 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 transmit 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 IDPF 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. +* Reason for doing this is because compiler doesn't allow nested flexible +* array fields). +* +* 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 */ + __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 +666 -0
666 lines not on this page · raw message
Signature · 6 lines
2.37.3 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
PATCH v2 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 maintained 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 · 6 lines
2.37.3 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
PATCH v2 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
@@ -24,6 +24,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
@@ -254,29 +255,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 ];
@@ -286,6 +303,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 {
@@ -475,6 +493,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);
@@ -486,6 +505,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 · 6 lines
2.37.3 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
PATCH v2 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 | 188 +++++ .../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, 1902 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 +188 -0
188 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 · 6 lines
2.37.3 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
PATCH v2 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 | 920 +++++++++++++++++- drivers/net/ethernet/intel/idpf/idpf_txrx.h | 148 ++- .../net/ethernet/intel/idpf/idpf_virtchnl.c | 495 +++++++++- 8 files changed, 1735 insertions(+), 15 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 +917 -3
1,001 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_txrx.h +143 -5
223 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +491 -4
590 lines not on this page · raw message
Signature · 6 lines
2.37.3 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
PATCH v2 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 · 6 lines
2.37.3 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
PATCH v2 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 | 177 ++++++ .../net/ethernet/intel/idpf/idpf_virtchnl.c | 403 +++++++++++++ 6 files changed, 1359 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 +177 -0
215 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +403 -0
433 lines not on this page · raw message
Signature · 7 lines
2.37.3 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
PATCH v2 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 | 1330 +++++++++++++++++ drivers/net/ethernet/intel/idpf/idpf_lib.c | 158 ++ drivers/net/ethernet/intel/idpf/idpf_txrx.c | 7 +- drivers/net/ethernet/intel/idpf/idpf_txrx.h | 14 + .../net/ethernet/intel/idpf/idpf_virtchnl.c | 249 ++- 7 files changed, 1795 insertions(+), 3 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 +1330 -0
1,330 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_lib.c +158 -0
176 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_txrx.c +5 -2
@@ -1684,6 +1684,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); }/**
@@ -4232,8 +4236,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 -0
@@ -9,13 +9,26 @@#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#define IDPF_MAX_QIDS 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)
@@ -509,6 +522,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 +248 -1
305 lines not on this page · raw message
Signature · 6 lines
2.37.3 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
PATCH v2 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 | 67 +- 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, 1370 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 +35 -32
161 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 · 6 lines
2.37.3 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
PATCH v2 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 | 162 +++++ drivers/net/ethernet/intel/idpf/idpf.h | 36 + drivers/net/ethernet/intel/idpf/idpf_lib.c | 657 +++++++++++++++++- 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 | 193 +++++ 7 files changed, 1076 insertions(+), 3 deletions(-) create mode 100644 Documentation/networking/device_drivers/ethernet/intel/idpf.rst
Documentation/networking/device_drivers/ethernet/intel/idpf.rst new file +162 -0
@@ -0,0 +1,162 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +========================================================================== +idpf Linux* Base Driver for the Intel(R) Infrastructure Data Path Function +========================================================================== + +Intel idpf Linux driver. +Copyright(C) 2023 Intel Corporation. + +Contents +======== + +- Overview +- Identifying Your Adapter +- Additional Features & Configurations +- Performance Optimization + + +The idpf driver serves as both the Physical Function (PF) and Virtual Function +(VF) driver for the Intel(R) Infrastructure Data Path Function. + +Driver information can be obtained using ethtool, lspci, and ip. + +For questions related to hardware requirements, refer to the documentation +supplied with your Intel adapter. All hardware requirements listed apply to use +with Linux. + + +Identifying Your Adapter +======================== +For information on how to identify your adapter, and for the latest Intel +network drivers, refer to the Intel Support website: +http://www.intel.com/support + + +Additional Features and Configurations +====================================== + +ethtool +------- +The driver utilizes the ethtool interface for driver configuration and +diagnostics, as well as displaying statistical information. The latest ethtool +version is required for this functionality. Download it at: +https://kernel.org/pub/software/network/ethtool/ + + +Viewing Link Messages +--------------------- +Link messages will not be displayed to the console if the distribution is +restricting system messages. In order to see network driver link messages on +your console, set dmesg to eight by entering the following: + +# dmesg -n 8 + +NOTE: This setting is not saved across reboots. + + +Jumbo Frames +------------ +Jumbo Frames support is enabled by changing the Maximum Transmission Unit (MTU) +to a value larger than the default value of 1500. + +Use the ip command to increase the MTU size. For example, enter the following +where <ethX> is the interface number: + +# ip link set mtu 9000 dev <ethX> +# ip link set up dev <ethX> + +NOTE: The maximum MTU setting for jumbo frames is 9706. This corresponds to the +maximum jumbo frame size of 9728 bytes. + +NOTE: This driver will attempt to use multiple page sized buffers to receive +each jumbo packet. This should help to avoid buffer starvation issues when +allocating receive packets. + +NOTE: Packet loss may have a greater impact on throughput when you use jumbo +frames. If you observe a drop in performance after enabling jumbo frames, +enabling flow control may mitigate the issue. + + +Performance Optimization +======================== +Driver defaults are meant to fit a wide variety of workloads, but if further +optimization is required, we recommend experimenting with the following +settings. + + +Interrupt Rate Limiting +----------------------- +This driver supports an adaptive interrupt throttle rate (ITR) mechanism that +is tuned for general workloads. The user can customize the interrupt rate +control for specific workloads, via ethtool, adjusting the number of +microseconds between interrupts. + +To set the interrupt rate manually, you must disable adaptive mode: + +# ethtool -C <ethX> adaptive-rx off adaptive-tx off + +For lower CPU utilization: + - Disable adaptive ITR and lower Rx and Tx interrupts. The examples below + affect every queue of the specified interface. + + - Setting rx-usecs and tx-usecs to 80 will limit interrupts to about + 12,500 interrupts per second per queue: + + # ethtool -C <ethX> adaptive-rx off adaptive-tx off rx-usecs 80 + tx-usecs 80 + +For reduced latency: + - Disable adaptive ITR and ITR by setting rx-usecs and tx-usecs to 0 + using ethtool: + + # ethtool -C <ethX> adaptive-rx off adaptive-tx off rx-usecs 0 + tx-usecs 0 + +Per-queue interrupt rate settings: + - The following examples are for queues 1 and 3, but you can adjust other + queues. + + - To disable Rx adaptive ITR and set static Rx ITR to 10 microseconds or + about 100,000 interrupts/second, for queues 1 and 3: + + # ethtool --per-queue <ethX> queue_mask 0xa --coalesce adaptive-rx off + rx-usecs 10 + + - To show the current coalesce settings for queues 1 and 3: + + # ethtool --per-queue <ethX> queue_mask 0xa --show-coalesce + + + +Virtualized Environments +------------------------ +In addition to the other suggestions in this section, the following may be +helpful to optimize performance in VMs. + + - Using the appropriate mechanism (vcpupin) in the VM, pin the CPUs to + individual LCPUs, making sure to use a set of CPUs included in the + device's local_cpulist: /sys/class/net/<ethX>/device/local_cpulist. + + - Configure as many Rx/Tx queues in the VM as available. (See the idpf driver + documentation for the number of queues supported.) For example: + + # ethtool -L <virt_interface> rx <max> tx <max> + + +Support +======= +For general information, go to the Intel support website at: +http://www.intel.com/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]. + + +Trademarks +========== +Intel is a trademark or registered trademark of Intel Corporation or its +subsidiaries in the United States and/or other countries. + +* Other names and brands may be claimed as the property of others.
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 +654 -3
803 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
@@ -99,6 +99,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
@@ -841,6 +842,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 +193 -0
250 lines not on this page · raw message
Signature · 6 lines
2.37.3 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
PATCH v2 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 | 998 +++++++++++++++++- drivers/net/ethernet/intel/idpf/idpf_txrx.h | 56 +- .../net/ethernet/intel/idpf/idpf_virtchnl.c | 4 +- 4 files changed, 1051 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 +994 -4
1,064 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 · 7 lines
2.37.3 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
PATCH v2 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 | 803 ++++++++++++++++++ drivers/net/ethernet/intel/idpf/idpf_txrx.h | 167 +++- 5 files changed, 1109 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 +803 -0
816 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 · 7 lines
2.37.3 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Re: [PATCH net-next v2 01/15] virtchnl: add virtchnl version 2 ops
In reply to Pavan Kumar LingaQuoted 36 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.
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]>Reviewed-by Willem de Bruijn <[email protected]>--- drivers/net/ethernet/intel/idpf/virtchnl2.h | 1201 +++++++++++++++++ .../ethernet/intel/idpf/virtchnl2_lan_desc.h | 666 +++++++++ 2 files changed, 1867 insertions(+) create mode 100644 drivers/net/ethernet/intel/idpf/virtchnl2.h create mode 100644 drivers/net/ethernet/intel/idpf/virtchnl2_lan_desc.hdrivers/net/ethernet/intel/idpf/virtchnl2.h +0
-0
...
Quoted 4 lines
+/**
+ * This macro is used to generate compilation errors if a structure
+ * is not exactly the correct length.
+ */
Hi Pavan,
./scripts/kernel-doc -none drivers/net/ethernet/intel/idpf/virtchnl2.h reports that the comment above starts with '/**' but is not a kernel-doc comment. Which seems to be correct. It also flags many other similar issues.
Please consider running kernel-doc and resolving the issues it flags.
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Re: [PATCH net-next v2 06/15] idpf: continue expanding init task
In reply to Pavan Kumar LingaOn Mon, Apr 10, 2023 at 06:13:45PM -0700, Pavan Kumar Linga wrote:
...
Quoted 1 line
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +0
-0
...
Quoted 8 lines
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +8
-0+/** +* idpf_send_get_rx_ptype_msg - Send virtchnl for ptype info +* @vport: virtual port data structure +* +* Returns 0 on success, negative on failure. +*/ +int idpf_send_get_rx_ptype_msg (struct idpf_vport *vport) +{
...
Quoted 30 lines
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +30
-0+while (ptypes_recvd < max_ptype) { + err =idpf_wait_for_event (adapter,NULL ,IDPF_VC_GET_PTYPE_INFO , +IDPF_VC_GET_PTYPE_INFO_ERR ); +if (err) + goto get_ptype_rel; + + len =IDPF_DFLT_MBX_BUF_SIZE ; + ptype_info =kcalloc (1 , len,GFP_KERNEL ); +if (!ptype_info) { + err = -ENOMEM ; + goto clear_vc_flag; + } + +memcpy (ptype_info, adapter->vc_msg, len); + + ptypes_recvd +=le16_to_cpu (ptype_info->num_ptypes); +if (ptypes_recvd > max_ptype) { + err = -EINVAL ; + goto ptype_rel; + } + + ptype_offset =sizeof (struct virtchnl2_get_ptype_info ); + +for (i =0 ; i <le16_to_cpu (ptype_info->num_ptypes); i++) { +struct idpf_ptype_state pstate = { }; +struct virtchnl2_ptype *ptype; +u16 id; + + ptype = (struct virtchnl2_ptype *) + ((u8 *)ptype_info + ptype_offset);
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c int idpf_send_dealloc_vectors_msg(struct idpf_adapter *adapter) · line 1198
Quoted 10 lines
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +10
-0+ + ptype_offset +=IDPF_GET_PTYPE_SIZE (ptype); +if (ptype_offset > len) { + err = -EINVAL ; + goto ptype_rel; + } + +if (le16_to_cpu (ptype->ptype_id_10) == +IDPF_INVALID_PTYPE_ID ) + goto ptype_rel;
Hi Pavan,
The ptype_rel label will return err.
But err is 0 here. Perhaps it should be set to a negative error code?
Flagged by Smatch as:
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c:1198 idpf_send_get_rx_ptype_msg() warn: missing error code 'err'
...
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c int idpf_send_dealloc_vectors_msg(struct idpf_adapter *adapter) · line 1339
Quoted 13 lines
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +13
-0+kfree (get_ptype_info); + +return 0 ; + +ptype_rel: +kfree (ptype_info); +clear_vc_flag: +clear_bit (__IDPF_VC_MSG_PENDING, adapter->flags); +get_ptype_rel: +kfree (get_ptype_info); + +return err; +}
...
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Re: [PATCH net-next v2 03/15] idpf: add controlq init and reset checks
In reply to Pavan Kumar LingaQuoted 9 lines · Pavan Kumar Linga
From: 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.
...
Quoted 6 lines
drivers/net/ethernet/intel/idpf/idpf_controlq.c new file +6
-0+int idpf_ctlq_add (struct idpf_hw *hw, +struct idpf_ctlq_create_info *qinfo, +struct idpf_ctlq_info **cq_out) +{ +struct idpf_ctlq_info *cq; +bool is_rxq = false;
drivers/net/ethernet/intel/idpf/idpf_controlq.c line 142
Quoted 10 lines
drivers/net/ethernet/intel/idpf/idpf_controlq.c new file +10
-0+int status =0 ; + +if (!qinfo->len || !qinfo->buf_size || + qinfo->len >IDPF_CTLQ_MAX_RING_SIZE || + qinfo->buf_size >IDPF_CTLQ_MAX_BUF_LEN ) +return -EINVAL ; + + cq =kcalloc (1 ,sizeof (struct idpf_ctlq_info ),GFP_KERNEL ); +if (!cq) +return -ENOMEM ;
Hi Pavan, Hi Joshua,
nit: I notice a number of instances in this patchset where either
the first argument passed to kcalloc() is 1, or the second argument is sizeof(u8).
I think it would be slightly better to use kmalloc() in such cases.
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Re: [PATCH net-next v2 04/15] idpf: add core init and interrupt request
In reply to Pavan Kumar LingaOn Mon, Apr 10, 2023 at 06:13:43PM -0700, Pavan Kumar Linga wrote:
...
Quoted 1 line
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +0
-0
...
Quoted 46 lines
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +46
-0+/** +* idpf_recv_get_caps_msg - Receive virtchnl get capabilities message +* @adapter: Driver specific private structure +* +* Receive virtchnl get capabilities message. Returns 0 on success, negative on +* failure. +*/ +static int idpf_recv_get_caps_msg (struct idpf_adapter *adapter) +{ +return idpf_recv_mb_msg (adapter,VIRTCHNL2_OP_GET_CAPS , &adapter->caps, +sizeof (struct virtchnl2_get_capabilities )); +} + +/** +* idpf_send_alloc_vectors_msg - Send virtchnl alloc vectors message +* @adapter: Driver specific private structure +* @num_vectors: number of vectors to be allocated +* +* Returns 0 on success, negative on failure. +*/ +int idpf_send_alloc_vectors_msg (struct idpf_adapter *adapter,u16 num_vectors) +{ +struct virtchnl2_alloc_vectors *alloc_vec, *rcvd_vec; +struct virtchnl2_alloc_vectors ac = { }; +u16 num_vchunks; +int size, err; + + ac.num_vectors =cpu_to_le16 (num_vectors); + + err =idpf_send_mb_msg (adapter,VIRTCHNL2_OP_ALLOC_VECTORS , +sizeof (ac), (u8 *)&ac); +if (err) +return err; + + err =idpf_wait_for_event (adapter,NULL ,IDPF_VC_ALLOC_VECTORS , +IDPF_VC_ALLOC_VECTORS_ERR ); +if (err) +return err; + + rcvd_vec = (struct virtchnl2_alloc_vectors *)adapter->vc_msg; + num_vchunks =le16_to_cpu (rcvd_vec->vchunks.num_vchunks); + + size =struct_size (rcvd_vec, vchunks.vchunks, num_vchunks); +if (size >sizeof (adapter->vc_msg)) { + err = -EINVAL ; + goto error;
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c static int idpf_mb_clean(struct idpf_adapter *adapter) · line 633
Quoted 10 lines
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +10
-0+ } + +kfree (adapter->req_vec_chunks); + adapter->req_vec_chunks =NULL ; + adapter->req_vec_chunks =kzalloc (size,GFP_KERNEL ); +if (!adapter->req_vec_chunks) { + err = -ENOMEM ; + goto error; + } +memcpy (adapter->req_vec_chunks, adapter->vc_msg, size);
Hi Pavan,
Coccinelle suggests that kmemdup might be used here.
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c:2085:27-34: WARNING opportunity for kmemdup
Likewise for a similar pattern in:
* [PATCH net-next v2 14/15] idpf: add ethtool callbacks
...
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Re: [PATCH net-next v2 14/15] idpf: add ethtool callbacks
In reply to Pavan Kumar LingaQuoted 1 line · Pavan Kumar Linga
From: Alan Brady <[email protected]>
...
Quoted 1 line
drivers/net/ethernet/intel/idpf/idpf_ethtool.c +0
-0
...
Quoted 6 lines
drivers/net/ethernet/intel/idpf/idpf_ethtool.c +6
-0+/** +* idpf_add_qstat_strings - Copy queue stat strings into ethtool buffer +* @p: ethtool supplied buffer +* @stats: stat definitions array +* @type: stat type +* @idx: stat idx
drivers/net/ethernet/intel/idpf/idpf_ethtool.c line 531
Quoted 10 lines
drivers/net/ethernet/intel/idpf/idpf_ethtool.c +10
-0+* +* Format and copy the strings described by the const static stats value into +* the buffer pointed at by p. +* +* The parameter @stats is evaluated twice, so parameters with side effects +* should be avoided. Additionally, stats must be an array such that +* ARRAY_SIZE can be called on it. +*/ +#define idpf_add_qstat_strings (p, stats, type, idx) \ + __idpf_add_qstat_strings(p, stats, ARRAY_SIZE(stats), type, idx)
Hi Pavan, Hi Alan,
FWIIW, I think __idpf_add_qstat_strings() could be a function. It would give some type checking. And avoid possible aliasing of inputs. Basically, I think functions should be used unless there is a reason not to.
...
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Re: [PATCH net-next v2 02/15] idpf: add module register and probe functionality
In reply to Pavan Kumar LingaQuoted 36 lines · Pavan Kumar Linga
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.
Signed-off-by Phani Burra <[email protected]>Co-developed-by Alan Brady <[email protected]>Signed-off-by Alan Brady <[email protected]>Co-developed-by Madhu Chittim <[email protected]>Signed-off-by Madhu Chittim <[email protected]>Co-developed-by Shailendra Bhatnagar <[email protected]>Signed-off-by Shailendra Bhatnagar <[email protected]>Co-developed-by Pavan Kumar Linga <[email protected]>Signed-off-by Pavan Kumar Linga <[email protected]>Reviewed-by Sridhar Samudrala <[email protected]>Reviewed-by Willem de Bruijn <[email protected]>--- 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/idpf/idpf_lib.c line 92
Quoted 9 lines
drivers/net/ethernet/intel/idpf/idpf_lib.c new file +9
-0+/** +* idpf_remove_common - Device removal routine +* @pdev: PCI device information struct +*/ +void idpf_remove_common (struct pci_dev *pdev) +{ +struct idpf_adapter *adapter =pci_get_drvdata (pdev); + +if (!adapter)
How is it possible to have adapter be NULL here?
Quoted 19 lines
drivers/net/ethernet/intel/idpf/idpf_lib.c new file +4
-0+return ; + +pci_disable_pcie_error_reporting (pdev); +}drivers/net/ethernet/intel/idpf/idpf_main.c new file +9
-0@@ -0,0 +1,70 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* Copyright (C) 2023 Intel Corporation */ + +#include "idpf.h" + +#define DRV_SUMMARY "Infrastructure Data Path Function Linux Driver" + +MODULE_DESCRIPTION (DRV_SUMMARY ); +MODULE_LICENSE ("GPL" );
drivers/net/ethernet/intel/idpf/idpf_main.c line 19
Quoted 10 lines
drivers/net/ethernet/intel/idpf/idpf_main.c new file +10
-0+ +/** +* idpf_remove - Device removal routine +* @pdev: PCI device information struct +*/ +static void idpf_remove (struct pci_dev *pdev) +{ +struct idpf_adapter *adapter =pci_get_drvdata (pdev); + +if (!adapter)
Ditto
Quoted 20 lines
drivers/net/ethernet/intel/idpf/idpf_main.c new file +20
-0+return ; + +idpf_remove_common (pdev); +pci_set_drvdata (pdev,NULL ); +} + +/** +* idpf_shutdown - PCI callback for shutting down device +* @pdev: PCI device information struct +*/ +static void idpf_shutdown (struct pci_dev *pdev) +{ +idpf_remove (pdev); + +if (system_state ==SYSTEM_POWER_OFF ) +pci_set_power_state (pdev, PCI_D3hot); +} + +/** +* idpf_probe - Device initialization routine
drivers/net/ethernet/intel/idpf/idpf_main.c line 49
Quoted 10 lines
drivers/net/ethernet/intel/idpf/idpf_main.c new file +10
-0+* @pdev: PCI device information struct +* @ent: entry in idpf_pci_tbl +* +* Returns 0 on success, negative on failure +*/ +static int idpf_probe (struct pci_dev *pdev,const struct pci_device_id *ent) +{ +struct idpf_adapter *adapter; + + adapter =devm_kzalloc (&pdev->dev,sizeof (*adapter),GFP_KERNEL );
Why devm_kzalloc() and not kzalloc?
drivers/net/ethernet/intel/idpf/idpf_main.c line 53
Quoted 4 lines
drivers/net/ethernet/intel/idpf/idpf_main.c new file +4
-0+if (!adapter) +return -ENOMEM ; + +return idpf_probe_common (pdev, adapter);
There is no need in idpf_probe_common/idpf_remove_common functions and they better be embedded here. They called only once and just obfuscate the code.
drivers/net/ethernet/intel/idpf/idpf_main.c line 59
Quoted 6 lines
drivers/net/ethernet/intel/idpf/idpf_main.c new file +6
-0+} + +/* idpf_pci_tbl - PCI Dev idpf ID Table +*/ +static const struct pci_device_id idpf_pci_tbl[] = { + {/* Sentinel */ }
What does it mean empty pci_device_id table?
Quoted 14 lines
drivers/net/ethernet/intel/idpf/idpf_main.c new file +11
-0+}; +MODULE_DEVICE_TABLE (pci, idpf_pci_tbl); + +static struct pci_driver idpf_driver = { + .name =KBUILD_MODNAME , + .id_table = idpf_pci_tbl, + .probe = idpf_probe, + .remove = idpf_remove, + .shutdown = idpf_shutdown, +}; +module_pci_driver (idpf_driver);Signature · 1 line
2.37.3
Quoted 3 lines · Pavan Kumar Linga
v1 --> v2: link [1]
* removed the OASIS reference in the commit message to make it clear that this is an Intel vendor specific driver
How will this work when the OASIS driver is ready down the road?
We'll end up with two "idpf" drivers, where one will work with hardware that is not fully spec compliant using this Intel driver, and everything else will use the OASIS driver?
Does Intel plan to remove this driver when the OASIS one lands?
At the very least, having two "idpf" drivers will be very confusing.
Signature · 6 lines
Thanks, Sasha _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Quoted 7 lines · Sasha Levin
Quoted 3 lines · Pavan Kumar Linga
v1 --> v2: link [1]
* removed the OASIS reference in the commit message to make it clear that this is an Intel vendor specific driverHow will this work when the OASIS driver is ready down the road?
Quoted 7 lines
We'll end up with two "idpf" drivers, where one will work with hardware that is not fully spec compliant using this Intel driver, and everything else will use the OASIS driver?
Does Intel plan to remove this driver when the OASIS one lands?
At the very least, having two "idpf" drivers will be very confusing.
One approach is that when the OASIS v1 spec is published, this driver is updated to match that and moved out of the intel directory.
This IPU/DPU/SmartNIC/.. device highly programmable. I assume a goal is to make sure that the device meets the new v1 spec. That quite likely requires a firmware update, but that is fine.
Re: [PATCH net-next v2 01/15] virtchnl: add virtchnl version 2 ops
In reply to Simon HormanQuoted 45 lines · Simon Horman
Quoted 36 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.
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]>Reviewed-by Willem de Bruijn <[email protected]>--- drivers/net/ethernet/intel/idpf/virtchnl2.h | 1201 +++++++++++++++++ .../ethernet/intel/idpf/virtchnl2_lan_desc.h | 666 +++++++++ 2 files changed, 1867 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...
Quoted 4 lines
+/**
+ * This macro is used to generate compilation errors if a structure
+ * is not exactly the correct length.
+ */
Quoted 7 lines
Hi Pavan,
./scripts/kernel-doc-nonedrivers/net/ethernet/intel/idpf/virtchnl2.hreports that the comment above starts with '/**' but is not a kernel-doc comment. Which seems to be correct. It also flags many other similar issues.Please consider running kernel-doc and resolving the issues it flags.
Will address in v3. Thanks for the tip!
Emil
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Re: [PATCH net-next v2 02/15] idpf: add module register and probe functionality
In reply to Leon RomanovskyQuoted 40 lines · Leon Romanovsky
Quoted 36 lines · Pavan Kumar Linga
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.
Signed-off-by Phani Burra <[email protected]>Co-developed-by Alan Brady <[email protected]>Signed-off-by Alan Brady <[email protected]>Co-developed-by Madhu Chittim <[email protected]>Signed-off-by Madhu Chittim <[email protected]>Co-developed-by Shailendra Bhatnagar <[email protected]>Signed-off-by Shailendra Bhatnagar <[email protected]>Co-developed-by Pavan Kumar Linga <[email protected]>Signed-off-by Pavan Kumar Linga <[email protected]>Reviewed-by Sridhar Samudrala <[email protected]>Reviewed-by Willem de Bruijn <[email protected]>--- 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/Makefilecreate mode 100644drivers/net/ethernet/intel/idpf/idpf.hcreate mode 100644drivers/net/ethernet/intel/idpf/idpf_controlq.hcreate mode 100644drivers/net/ethernet/intel/idpf/idpf_lib.ccreate mode 100644drivers/net/ethernet/intel/idpf/idpf_main.c<...>
Quoted 11 lines
drivers/net/ethernet/intel/idpf/idpf_lib.c line 92
Quoted 9 lines
drivers/net/ethernet/intel/idpf/idpf_lib.c new file +9
-0+/** +* idpf_remove_common - Device removal routine +* @pdev: PCI device information struct +*/ +void idpf_remove_common (struct pci_dev *pdev) +{ +struct idpf_adapter *adapter =pci_get_drvdata (pdev); + +if (!adapter)How is it possible to have adapter be NULL here?
I think it is just defensive check since remove can be called on error code path, but in general you're right and we likely don't need it. Will remove in v3.
Quoted 24 lines
Quoted 24 lines
drivers/net/ethernet/intel/idpf/idpf_lib.c new file +4
-0+return ; + +pci_disable_pcie_error_reporting (pdev); +}drivers/net/ethernet/intel/idpf/idpf_main.c new file +13
-0@@ -0,0 +1,70 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* Copyright (C) 2023 Intel Corporation */ + +#include "idpf.h" + +#define DRV_SUMMARY "Infrastructure Data Path Function Linux Driver" + +MODULE_DESCRIPTION (DRV_SUMMARY ); +MODULE_LICENSE ("GPL" ); + +/** +* idpf_remove - Device removal routine +* @pdev: PCI device information struct
Quoted 8 lines
drivers/net/ethernet/intel/idpf/idpf_main.c line 19
Quoted 6 lines
drivers/net/ethernet/intel/idpf/idpf_main.c new file +6
-0+*/ +static void idpf_remove (struct pci_dev *pdev) +{ +struct idpf_adapter *adapter =pci_get_drvdata (pdev); + +if (!adapter)Ditto
Will remove in v3.
Quoted 24 lines
Quoted 24 lines
drivers/net/ethernet/intel/idpf/idpf_main.c new file +24
-0+return ; + +idpf_remove_common (pdev); +pci_set_drvdata (pdev,NULL ); +} + +/** +* idpf_shutdown - PCI callback for shutting down device +* @pdev: PCI device information struct +*/ +static void idpf_shutdown (struct pci_dev *pdev) +{ +idpf_remove (pdev); + +if (system_state ==SYSTEM_POWER_OFF ) +pci_set_power_state (pdev, PCI_D3hot); +} + +/** +* idpf_probe - Device initialization routine +* @pdev: PCI device information struct +* @ent: entry in idpf_pci_tbl +* +* Returns 0 on success, negative on failure
Quoted 8 lines
drivers/net/ethernet/intel/idpf/idpf_main.c line 49
Quoted 6 lines
drivers/net/ethernet/intel/idpf/idpf_main.c new file +6
-0+*/ +static int idpf_probe (struct pci_dev *pdev,const struct pci_device_id *ent) +{ +struct idpf_adapter *adapter; + + adapter =devm_kzalloc (&pdev->dev,sizeof (*adapter),GFP_KERNEL );Why
devm_kzalloc()and not kzalloc?
It provides managed memory allocation on probe, which seems to be the preferred method in that case.
Quoted 8 lines
drivers/net/ethernet/intel/idpf/idpf_main.c line 53
Quoted 4 lines
drivers/net/ethernet/intel/idpf/idpf_main.c new file +4
-0+if (!adapter) +return -ENOMEM ; + +return idpf_probe_common (pdev, adapter);There is no need in idpf_probe_common/idpf_remove_common functions and they better be embedded here. They called only once and just obfuscate the code.
Will remove in v3.
Quoted 8 lines
drivers/net/ethernet/intel/idpf/idpf_main.c line 59
Quoted 6 lines
drivers/net/ethernet/intel/idpf/idpf_main.c new file +6
-0+} + +/* idpf_pci_tbl - PCI Dev idpf ID Table +*/ +static const struct pci_device_id idpf_pci_tbl[] = { + {/* Sentinel */ }What does it mean empty
pci_device_idtable?
Device ID's are added later, but it does make sense to be in this patch instead. Will fix in v3.
Quoted 14 lines
Quoted 14 lines
drivers/net/ethernet/intel/idpf/idpf_main.c new file +11
-0+}; +MODULE_DEVICE_TABLE (pci, idpf_pci_tbl); + +static struct pci_driver idpf_driver = { + .name =KBUILD_MODNAME , + .id_table = idpf_pci_tbl, + .probe = idpf_probe, + .remove = idpf_remove, + .shutdown = idpf_shutdown, +}; +module_pci_driver (idpf_driver);Signature · 1 line
2.37.3
Quoted 12 lines · Willem de Bruijn
Quoted 11 lines · Sasha Levin
Quoted 3 lines · Pavan Kumar Linga
v1 --> v2: link [1]
* removed the OASIS reference in the commit message to make it clear that this is an Intel vendor specific driverHow will this work when the OASIS driver is ready down the road?
We'll end up with two "idpf" drivers, where one will work with hardware that is not fully spec compliant using this Intel driver, and everything else will use the OASIS driver?
Quoted 6 lines
Quoted 3 lines
Does Intel plan to remove this driver when the OASIS one lands?
At the very least, having two "idpf" drivers will be very confusing.
One approach is that when the OASIS v1 spec is published, this driver is updated to match that and moved out of the intel directory.
Yes. We don't want to have 2 idpf drivers in the upstream kernel.
It will be an Intel vendor driver until it becomes a standard.
Hope it will be OK to move the driver out of the intel directory when that happens.
Quoted 8 lines
This IPU/DPU/SmartNIC/.. device highly programmable. I assume a goal is to make sure that the device meets the new v1 spec. That quite likely requires a firmware update, but that is fine.
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Jakub Kicinski
maintainerQuoted 13 lines · Sridhar
Quoted 12 lines · Willem de Bruijn
Quoted 10 lines · Sasha Levin
On Mon, Apr 10, 2023 at 06:13:39PM -0700, Pavan Kumar Linga wrote:
How will this work when the OASIS driver is ready down the road?We'll end up with two "idpf" drivers, where one will work with hardware that is not fully spec compliant using this Intel driver, and everything else will use the OASIS driver?
Does Intel plan to remove this driver when the OASIS one lands?
At the very least, having two "idpf" drivers will be very confusing.
Quoted 7 lines
Quoted 2 lines
One approach is that when the OASIS v1 spec is published, this driver is updated to match that and moved out of the intel directory.
Yes. We don't want to have 2 idpf drivers in the upstream kernel. It will be an Intel vendor driver until it becomes a standard. Hope it will be OK to move the driver out of the intel directory when that happens.
As I said previously in [0] until there is a compatible, widely available implementation from a second vendor - this is an Intel driver and nothing more. It's not moving anywhere.
I think that's a reasonable position which should allow Intel to ship your code and me to remain professional.
Re: [PATCH net-next v2 02/15] idpf: add module register and probe functionality
In reply to Tantilov, Emil SQuoted 42 lines · Emil S
Quoted 39 lines · Leon Romanovsky
Quoted 36 lines · Pavan Kumar Linga
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.
Signed-off-by Phani Burra <[email protected]>Co-developed-by Alan Brady <[email protected]>Signed-off-by Alan Brady <[email protected]>Co-developed-by Madhu Chittim <[email protected]>Signed-off-by Madhu Chittim <[email protected]>Co-developed-by Shailendra Bhatnagar <[email protected]>Signed-off-by Shailendra Bhatnagar <[email protected]>Co-developed-by Pavan Kumar Linga <[email protected]>Signed-off-by Pavan Kumar Linga <[email protected]>Reviewed-by Sridhar Samudrala <[email protected]>Reviewed-by Willem de Bruijn <[email protected]>--- 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/Makefilecreate mode 100644drivers/net/ethernet/intel/idpf/idpf.hcreate mode 100644drivers/net/ethernet/intel/idpf/idpf_controlq.hcreate mode 100644drivers/net/ethernet/intel/idpf/idpf_lib.ccreate mode 100644drivers/net/ethernet/intel/idpf/idpf_main.c<...>
<...>
Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
+/**
+ *idpf_probe- Device initialization routine
+ * @pdev: PCI device information struct
+ * @ent: entry inidpf_pci_tbl
+ *
+ * Returns 0 on success, negative on failureQuoted 8 lines
drivers/net/ethernet/intel/idpf/idpf_main.c line 49
Quoted 6 lines
+ */
drivers/net/ethernet/intel/idpf/idpf_main.c new file +5
-0+static int idpf_probe (struct pci_dev *pdev,const struct pci_device_id *ent) +{ +struct idpf_adapter *adapter; + + adapter =devm_kzalloc (&pdev->dev,sizeof (*adapter),GFP_KERNEL );Why
devm_kzalloc()and not kzalloc?
Quoted 2 lines
It provides managed memory allocation on probe, which seems to be the preferred method in that case.
I don't think so, as PCI probe/remove has very clear lifetime model and doesn't need garbage collection memory logic. In general, it is better to avoid devm_*() APIs as they hide error unwind flows.
Thanks
Quoted 17 lines · Jakub Kicinski
Quoted 16 lines · Sridhar
Quoted 14 lines · Willem de Bruijn
Quoted 10 lines · Sasha Levin
On Mon, Apr 10, 2023 at 06:13:39PM -0700, Pavan Kumar Linga wrote:
How will this work when the OASIS driver is ready down the road?We'll end up with two "idpf" drivers, where one will work with hardware that is not fully spec compliant using this Intel driver, and everything else will use the OASIS driver?
Does Intel plan to remove this driver when the OASIS one lands?
At the very least, having two "idpf" drivers will be very confusing.
One approach is that when the OASIS v1 spec is published, this driver is updated to match that and moved out of the intel directory.
Quoted 8 lines
Quoted 4 lines
Yes. We don't want to have 2 idpf drivers in the upstream kernel. It will be an Intel vendor driver until it becomes a standard. Hope it will be OK to move the driver out of the intel directory when that happens.
As I said previously in [0] until there is a compatible, widely available implementation from a second vendor - this is an Intel driver and nothing more. It's not moving anywhere.
Even if second implementation arrives, it is unlikely that this idpf driver will be moved. Mainly because of different level of review between vendor driver vs. standard one, and expected pushback to any incompatible changes in existing driver as it is already deployed.
Thanks
Quoted 5 lines
I think that's a reasonable position which should allow Intel to ship your code and me to remain professional.
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Re: [PATCH net-next v2 02/15] idpf: add module register and probe functionality
In reply to Leon RomanovskyQuoted 60 lines · Leon Romanovsky
Quoted 42 lines · Emil S
Quoted 39 lines · Leon Romanovsky
Quoted 36 lines · Pavan Kumar Linga
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.
Signed-off-by Phani Burra <[email protected]>Co-developed-by Alan Brady <[email protected]>Signed-off-by Alan Brady <[email protected]>Co-developed-by Madhu Chittim <[email protected]>Signed-off-by Madhu Chittim <[email protected]>Co-developed-by Shailendra Bhatnagar <[email protected]>Signed-off-by Shailendra Bhatnagar <[email protected]>Co-developed-by Pavan Kumar Linga <[email protected]>Signed-off-by Pavan Kumar Linga <[email protected]>Reviewed-by Sridhar Samudrala <[email protected]>Reviewed-by Willem de Bruijn <[email protected]>--- 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/Makefilecreate mode 100644drivers/net/ethernet/intel/idpf/idpf.hcreate mode 100644drivers/net/ethernet/intel/idpf/idpf_controlq.hcreate mode 100644drivers/net/ethernet/intel/idpf/idpf_lib.ccreate mode 100644drivers/net/ethernet/intel/idpf/idpf_main.c<...>
<...>
Quoted 14 lines
Quoted 14 lines
drivers/net/ethernet/intel/idpf/idpf_main.c line 49
Quoted 12 lines
drivers/net/ethernet/intel/idpf/idpf_main.c new file +12
-0+/** +* idpf_probe - Device initialization routine +* @pdev: PCI device information struct +* @ent: entry in idpf_pci_tbl +* +* Returns 0 on success, negative on failure +*/ +static int idpf_probe (struct pci_dev *pdev,const struct pci_device_id *ent) +{ +struct idpf_adapter *adapter; + + adapter =devm_kzalloc (&pdev->dev,sizeof (*adapter),GFP_KERNEL );Why
devm_kzalloc()and not kzalloc?
Quoted 6 lines
Quoted 2 lines
It provides managed memory allocation on probe, which seems to be the preferred method in that case.
I don't think so, as PCI probe/remove has very clear lifetime model and doesn't need garbage collection memory logic. In general, it is better to avoid devm_*() APIs as they hide error unwind flows.
We'll remove it in v3.
Thanks,
Emil
Quoted 1 line
Thanks
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Re: [PATCH net-next v2 06/15] idpf: continue expanding init task
In reply to Simon HormanQuoted 62 lines · Simon Horman
On Mon, Apr 10, 2023 at 06:13:45PM -0700, Pavan Kumar Linga wrote:
...
Quoted 1 line
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +0
-0...
Quoted 8 lines
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +8
-0+/** +* idpf_send_get_rx_ptype_msg - Send virtchnl for ptype info +* @vport: virtual port data structure +* +* Returns 0 on success, negative on failure. +*/ +int idpf_send_get_rx_ptype_msg (struct idpf_vport *vport) +{...
Quoted 30 lines
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +30
-0+while (ptypes_recvd < max_ptype) { + err =idpf_wait_for_event (adapter,NULL ,IDPF_VC_GET_PTYPE_INFO , +IDPF_VC_GET_PTYPE_INFO_ERR ); +if (err) + goto get_ptype_rel; + + len =IDPF_DFLT_MBX_BUF_SIZE ; + ptype_info =kcalloc (1 , len,GFP_KERNEL ); +if (!ptype_info) { + err = -ENOMEM ; + goto clear_vc_flag; + } + +memcpy (ptype_info, adapter->vc_msg, len); + + ptypes_recvd +=le16_to_cpu (ptype_info->num_ptypes); +if (ptypes_recvd > max_ptype) { + err = -EINVAL ; + goto ptype_rel; + } + + ptype_offset =sizeof (struct virtchnl2_get_ptype_info ); + +for (i =0 ; i <le16_to_cpu (ptype_info->num_ptypes); i++) { +struct idpf_ptype_state pstate = { }; +struct virtchnl2_ptype *ptype; +u16 id; + + ptype = (struct virtchnl2_ptype *) + ((u8 *)ptype_info + ptype_offset);drivers/net/ethernet/intel/idpf/idpf_virtchnl.c int idpf_send_dealloc_vectors_msg(struct idpf_adapter *adapter) · line 1198
Quoted 10 lines
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +10
-0+ + ptype_offset +=IDPF_GET_PTYPE_SIZE (ptype); +if (ptype_offset > len) { + err = -EINVAL ; + goto ptype_rel; + } + +if (le16_to_cpu (ptype->ptype_id_10) == +IDPF_INVALID_PTYPE_ID ) + goto ptype_rel;Hi Pavan,
Quoted 6 lines
The
ptype_rellabel will return err.
But err is 0 here. Perhaps it should be set to a negative error code?Flagged by Smatch as:
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c:1198idpf_send_get_rx_ptype_msg()warn: missing error code 'err'
We'll address this in v3 along with the other smatch related hits.
Thanks,
Emil
Quoted 17 lines
...
Quoted 13 lines
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +13
-0+kfree (get_ptype_info); + +return 0 ; + +ptype_rel: +kfree (ptype_info); +clear_vc_flag: +clear_bit (__IDPF_VC_MSG_PENDING, adapter->flags); +get_ptype_rel: +kfree (get_ptype_info); + +return err; +}...
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Re: [PATCH net-next v2 04/15] idpf: add core init and interrupt request
In reply to Simon HormanQuoted 67 lines · Simon Horman
On Mon, Apr 10, 2023 at 06:13:43PM -0700, Pavan Kumar Linga wrote:
...
Quoted 1 line
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +0
-0...
Quoted 46 lines
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +46
-0+/** +* idpf_recv_get_caps_msg - Receive virtchnl get capabilities message +* @adapter: Driver specific private structure +* +* Receive virtchnl get capabilities message. Returns 0 on success, negative on +* failure. +*/ +static int idpf_recv_get_caps_msg (struct idpf_adapter *adapter) +{ +return idpf_recv_mb_msg (adapter,VIRTCHNL2_OP_GET_CAPS , &adapter->caps, +sizeof (struct virtchnl2_get_capabilities )); +} + +/** +* idpf_send_alloc_vectors_msg - Send virtchnl alloc vectors message +* @adapter: Driver specific private structure +* @num_vectors: number of vectors to be allocated +* +* Returns 0 on success, negative on failure. +*/ +int idpf_send_alloc_vectors_msg (struct idpf_adapter *adapter,u16 num_vectors) +{ +struct virtchnl2_alloc_vectors *alloc_vec, *rcvd_vec; +struct virtchnl2_alloc_vectors ac = { }; +u16 num_vchunks; +int size, err; + + ac.num_vectors =cpu_to_le16 (num_vectors); + + err =idpf_send_mb_msg (adapter,VIRTCHNL2_OP_ALLOC_VECTORS , +sizeof (ac), (u8 *)&ac); +if (err) +return err; + + err =idpf_wait_for_event (adapter,NULL ,IDPF_VC_ALLOC_VECTORS , +IDPF_VC_ALLOC_VECTORS_ERR ); +if (err) +return err; + + rcvd_vec = (struct virtchnl2_alloc_vectors *)adapter->vc_msg; + num_vchunks =le16_to_cpu (rcvd_vec->vchunks.num_vchunks); + + size =struct_size (rcvd_vec, vchunks.vchunks, num_vchunks); +if (size >sizeof (adapter->vc_msg)) { + err = -EINVAL ; + goto error;drivers/net/ethernet/intel/idpf/idpf_virtchnl.c static int idpf_mb_clean(struct idpf_adapter *adapter) · line 633
Quoted 10 lines
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +10
-0+ } + +kfree (adapter->req_vec_chunks); + adapter->req_vec_chunks =NULL ; + adapter->req_vec_chunks =kzalloc (size,GFP_KERNEL ); +if (!adapter->req_vec_chunks) { + err = -ENOMEM ; + goto error; + } +memcpy (adapter->req_vec_chunks, adapter->vc_msg, size);Hi Pavan,
Quoted 8 lines
Coccinelle suggests that kmemdup might be used here.
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c:2085:27-34: WARNING opportunity for kmemdup
Likewise for a similar pattern in:
* [PATCH net-next v2 14/15] idpf: add ethtool callbacks...
We'll address it in v3.
Thanks,
Emil
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Re: [PATCH net-next v2 14/15] idpf: add ethtool callbacks
In reply to Simon HormanQuoted 28 lines · Simon Horman
Quoted 1 line · Pavan Kumar Linga
From: Alan Brady <[email protected]>
...
Quoted 1 line
drivers/net/ethernet/intel/idpf/idpf_ethtool.c +0
-0...
Quoted 6 lines
drivers/net/ethernet/intel/idpf/idpf_ethtool.c +6
-0+/** +* idpf_add_qstat_strings - Copy queue stat strings into ethtool buffer +* @p: ethtool supplied buffer +* @stats: stat definitions array +* @type: stat type +* @idx: stat idx drivers/net/ethernet/intel/idpf/idpf_ethtool.c line 531
Quoted 10 lines
drivers/net/ethernet/intel/idpf/idpf_ethtool.c +10
-0+* +* Format and copy the strings described by the const static stats value into +* the buffer pointed at by p. +* +* The parameter @stats is evaluated twice, so parameters with side effects +* should be avoided. Additionally, stats must be an array such that +* ARRAY_SIZE can be called on it. +*/ +#define idpf_add_qstat_strings (p, stats, type, idx) \ + __idpf_add_qstat_strings(p, stats, ARRAY_SIZE(stats), type, idx)Hi Pavan, Hi Alan,
Quoted 5 lines
FWIIW, I think
__idpf_add_qstat_strings()could be a function. It would give some type checking. And avoid possible aliasing of inputs. Basically, I think functions should be used unless there is a reason not to....
Good catch, we'll resolve it in v3.
Thanks,
Emil
Quoted 17 lines · Jakub Kicinski
Quoted 16 lines · Sridhar
Quoted 14 lines · Willem de Bruijn
Quoted 10 lines · Sasha Levin
On Mon, Apr 10, 2023 at 06:13:39PM -0700, Pavan Kumar Linga wrote:
How will this work when the OASIS driver is ready down the road?We'll end up with two "idpf" drivers, where one will work with hardware that is not fully spec compliant using this Intel driver, and everything else will use the OASIS driver?
Does Intel plan to remove this driver when the OASIS one lands?
At the very least, having two "idpf" drivers will be very confusing.
One approach is that when the OASIS v1 spec is published, this driver is updated to match that and moved out of the intel directory.
Quoted 8 lines
Quoted 4 lines
Yes. We don't want to have 2 idpf drivers in the upstream kernel. It will be an Intel vendor driver until it becomes a standard. Hope it will be OK to move the driver out of the intel directory when that happens.
As I said previously in [0] until there is a compatible, widely available implementation from a second vendor - this is an Intel driver and nothing more. It's not moving anywhere.
My concern isn't around the OASIS legal stuff, it's about the users who end up using this and will end up getting confused when we have two (or more) in-kernel "IDPF" drivers.
I don't think that moving is an option - it'll brake distros and upset
users: we can't rename drivers as we go because it has a good chance of breaking users.
Quoted 2 lines
I think that's a reasonable position which should allow Intel to ship your code and me to remain professional.
No concerns about OASIS or the current code, I just don't want to make this a mess for the users.
Signature · 6 lines
Thanks, Sasha _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Jakub Kicinski
maintainerQuoted 11 lines · On Fri, 14 Apr 2023 18:01:42 -0400 Sasha Levin wrote:
Quoted 3 lines
As I said previously in [0] until there is a compatible, widely available implementation from a second vendor - this is an Intel driver and nothing more. It's not moving anywhere.
My concern isn't around the OASIS legal stuff, it's about the users who end up using this and will end up getting confused when we have two (or more) in-kernel "IDPF" drivers.
I don't think that moving is an option - it'll brake distros and upset
users: we can't rename drivers as we go because it has a good chance of breaking users.
Minor pain for backports but I don't think we need to rename anything, just move.
Or we can just leave it be under intel/, since there are not other participant now. Unless perhaps under google/ is a better option?
Drivers are organized by the vendor for better or worse. We have a number of drivers under the "wrong directly" already. Companies merge / buy each others product lines, there's also some confusion about common IP drivers. It's all fine, whatever.
Users are very, very unlikely to care.
Quoted 5 lines
Quoted 2 lines
I think that's a reasonable position which should allow Intel to ship your code and me to remain professional.
No concerns about OASIS or the current code, I just don't want to make this a mess for the users.
It's not a standard until someone else actually adopts it. What stops all the other vendors from declaring that their driver interface is a standard now, too?
We have a long standing rule in netdev against using marketing language.
Quoted 29 lines · Jakub Kicinski
Quoted 11 lines · On Fri, 14 Apr 2023 18:01:42 -0400 Sasha Levin wrote:
Quoted 3 lines
As I said previously in [0] until there is a compatible, widely available implementation from a second vendor - this is an Intel driver and nothing more. It's not moving anywhere.
My concern isn't around the OASIS legal stuff, it's about the users who end up using this and will end up getting confused when we have two (or more) in-kernel "IDPF" drivers.
I don't think that moving is an option - it'll brake distros and upset
users: we can't rename drivers as we go because it has a good chance of breaking users.Minor pain for backports but I don't think we need to rename anything, just move.
Or we can just leave it be under intel/, since there are not other participant now. Unless perhaps under google/ is a better option?
Drivers are organized by the vendor for better or worse. We have a number of drivers under the "wrong directly" already. Companies merge / buy each others product lines, there's also some confusion about common IP drivers. It's all fine, whatever.
Users are very, very unlikely to care.
Quoted 3 lines
Quoted 2 lines
I think that's a reasonable position which should allow Intel to ship your code and me to remain professional.
Quoted 8 lines
Quoted 2 lines
No concerns about OASIS or the current code, I just don't want to make this a mess for the users.
It's not a standard until someone else actually adopts it. What stops all the other vendors from declaring that their driver interface is a standard now, too?
We have a long standing rule in netdev against using marketing language.
Sorry, I may not have explained myself well. My concern is not around what's standard and what's not, nor around where in the kernel tree these drivers live.
I'm concerned that down the road we may end up with two drivers that have the same name, and are working with hardware so similar that it might be confusing to understand which driver a user should be using.
Yes, it's not something too big, but we have an opportunity to think about this before committing to anything that might be a pain down the road.
Signature · 2 lines
Thanks, Sasha
Jakub Kicinski
maintainerQuoted 3 lines · On Sat, 15 Apr 2023 13:16:23 -0400 Sasha Levin wrote:
Sorry, I may not have explained myself well. My concern is not around what's standard and what's not, nor around where in the kernel tree these drivers live.
My bad, I thought you were looking at this from the stable tree's angle.
Quoted 7 lines
I'm concerned that down the road we may end up with two drivers that have the same name, and are working with hardware so similar that it might be confusing to understand which driver a user should be using.
Yes, it's not something too big, but we have an opportunity to think about this before committing to anything that might be a pain down the road.
Indeed, the "update" Willem mentioned should be at most a quirk or capability exchange with the device within this driver. Two drivers would be unacceptable.
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Re: [Intel-wired-lan] [PATCH net-next v2 02/15] idpf: add module register and probe functionality
In reply to Tantilov, Emil SQuoted 51 lines · Emil S
Quoted 39 lines · Leon Romanovsky
Quoted 36 lines · Pavan Kumar Linga
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.
Signed-off-by Phani Burra <[email protected]>Co-developed-by Alan Brady <[email protected]>Signed-off-by Alan Brady <[email protected]>Co-developed-by Madhu Chittim <[email protected]>Signed-off-by Madhu Chittim <[email protected]>Co-developed-by Shailendra Bhatnagar <[email protected]>Signed-off-by Shailendra Bhatnagar <[email protected]>Co-developed-by Pavan Kumar Linga <[email protected]>Signed-off-by Pavan Kumar Linga <[email protected]>Reviewed-by Sridhar Samudrala <[email protected]>Reviewed-by Willem de Bruijn <[email protected]>---
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/Makefilecreate mode 100644drivers/net/ethernet/intel/idpf/idpf.hcreate mode 100644drivers/net/ethernet/intel/idpf/idpf_controlq.hcreate mode 100644drivers/net/ethernet/intel/idpf/idpf_lib.ccreate mode 100644drivers/net/ethernet/intel/idpf/idpf_main.c<...>
Quoted 8 lines
drivers/net/ethernet/intel/idpf/idpf_main.c line 59
Quoted 6 lines
drivers/net/ethernet/intel/idpf/idpf_main.c new file +6
-0+} + +/* idpf_pci_tbl - PCI Dev idpf ID Table +*/ +static const struct pci_device_id idpf_pci_tbl[] = { + { /* Sentinel */ }What does it mean empty
pci_device_idtable?
Quoted 1 line
Device ID's are added later, but it does make sense to be in this patch instead. Will fix in v3.
On second look, the reason PCI ids are added in the last patch is because none of the modules from the previous patches would result in a functional driver.
Thanks,
Emil
Re: [Intel-wired-lan] [PATCH net-next v2 02/15] idpf: add module register and probe functionality
Quoted 54 lines · Emil S
Quoted 51 lines · Emil S
Quoted 47 lines · Leon Romanovsky
Quoted 36 lines · Pavan Kumar Linga
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.
Signed-off-by Phani Burra <[email protected]>Co-developed-by Alan Brady <[email protected]>Signed-off-by Alan Brady <[email protected]>Co-developed-by Madhu Chittim <[email protected]>Signed-off-by Madhu Chittim <[email protected]>Co-developed-by Shailendra Bhatnagar <[email protected]>Signed-off-by Shailendra Bhatnagar <[email protected]>Co-developed-by Pavan Kumar Linga <[email protected]>Signed-off-by Pavan Kumar Linga <[email protected]>Reviewed-by Sridhar Samudrala <[email protected]>Reviewed-by Willem de Bruijn <[email protected]>---
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/Makefilecreate mode 100644drivers/net/ethernet/intel/idpf/idpf.hcreate mode 100644drivers/net/ethernet/intel/idpf/idpf_controlq.hcreate mode 100644drivers/net/ethernet/intel/idpf/idpf_lib.ccreate mode 100644drivers/net/ethernet/intel/idpf/idpf_main.c<...>
drivers/net/ethernet/intel/idpf/idpf_main.c line 59
Quoted 6 lines
drivers/net/ethernet/intel/idpf/idpf_main.c new file +6
-0+} + +/* idpf_pci_tbl - PCI Dev idpf ID Table +*/ +static const struct pci_device_id idpf_pci_tbl[] = { + { /* Sentinel */ }What does it mean empty
pci_device_idtable?
Quoted 6 lines
Quoted 2 lines
Device ID's are added later, but it does make sense to be in this patch instead. Will fix in v3.
On second look, the reason PCI ids are added in the last patch is because none of the modules from the previous patches would result in a functional driver.
And yet patches should be split to meaningful and logical chunks. If you add pci_device_id, please add relevant device at the same patch.
Thanks
Quoted 3 lines
Thanks,
Emil
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Re: [Intel-wired-lan] [PATCH net-next v2 14/15] idpf: add ethtool callbacks
In reply to Tantilov, Emil SQuoted 33 lines · Emil S
Quoted 30 lines · Simon Horman
Quoted 1 line · Pavan Kumar Linga
From: Alan Brady <[email protected]>
...
Quoted 1 line
drivers/net/ethernet/intel/idpf/idpf_ethtool.c +0
-0...
Quoted 10 lines
+/**
+ *idpf_add_qstat_strings- Copy queue stat strings into ethtool buffer
+ * @p: ethtool supplied buffer
+ * @stats: stat definitions array
+ * @type: stat type
+ * @idx: stat idx
+ *
+ * Format and copy the strings described by the const static stats value into
+ * the buffer pointed at by p.Quoted 8 lines
+ *
+ * The parameter @stats is evaluated twice, so parameters with side effects
+ * should be avoided. Additionally, stats must be an array such that
+ *ARRAY_SIZEcan be called on it.
+ */
+#defineidpf_add_qstat_strings(p, stats, type, idx)\
+__idpf_add_qstat_strings(p, stats, ARRAY_SIZE(stats), type, idx)Hi Pavan, Hi Alan,
Quoted 7 lines
Quoted 5 lines
FWIIW, I think
__idpf_add_qstat_strings()could be a function. It would give some type checking. And avoid possible aliasing of inputs. Basically, I think functions should be used unless there is a reason not to....
Good catch, we'll resolve it in v3.
The reason a macro is used in this case is that it allows __idpf_add_qstat_strings() to get the size of the arrays passed by the caller. Is there a way to do this if we convert the macro to a function?
Thanks,
Emil
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Re: [Intel-wired-lan] [PATCH net-next v2 14/15] idpf: add ethtool callbacks
Quoted 42 lines · Emil S
Quoted 39 lines · Emil S
Quoted 36 lines · Simon Horman
Quoted 1 line · Pavan Kumar Linga
From: Alan Brady <[email protected]>
...
Quoted 2 lines
drivers/net/ethernet/intel/idpf/idpf_ethtool.c +0
-0...
Quoted 10 lines
+/**
+ *idpf_add_qstat_strings- Copy queue stat strings into ethtool buffer
+ * @p: ethtool supplied buffer
+ * @stats: stat definitions array
+ * @type: stat type
+ * @idx: stat idx
+ *
+ * Format and copy the strings described by the const static stats value into
+ * the buffer pointed at by p.Quoted 8 lines
+ *
+ * The parameter @stats is evaluated twice, so parameters with side effects
+ * should be avoided. Additionally, stats must be an array such that
+ *ARRAY_SIZEcan be called on it.
+ */
+#defineidpf_add_qstat_strings(p, stats, type, idx)\
+__idpf_add_qstat_strings(p, stats, ARRAY_SIZE(stats), type, idx)Hi Pavan, Hi Alan,
FWIIW, I think
__idpf_add_qstat_strings()could be a function. It would give some type checking. And avoid possible aliasing of inputs. Basically, I think functions should be used unless there is a reason not to.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
...
Good catch, we'll resolve it in v3.
The reason a macro is used in this case is that it allows
__idpf_add_qstat_strings()to get the size of the arrays passed by the caller. Is there a way to do this if we convert the macro to a function?
Understood, in that case perhaps a macro is best after all.
_______________________________________________
Intel-wired-lan mailing list [email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan