Skip to content

Commit a251eee

Browse files
jahay1anguy11
authored andcommitted
idpf: add SRIOV support and other ndo_ops
Add support for SRIOV: send the requested number of VFs to the device Control Plane, via the virtchnl message and then enable the VFs using 'pci_enable_sriov'. 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 documentation and build support for the driver. Signed-off-by: Joshua Hay <[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: Phani Burra <[email protected]> Signed-off-by: Phani Burra <[email protected]> Reviewed-by: Sridhar Samudrala <[email protected]> Reviewed-by: Willem de Bruijn <[email protected]> Co-developed-by: Pavan Kumar Linga <[email protected]> Signed-off-by: Pavan Kumar Linga <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 02cbfba commit a251eee

File tree

10 files changed

+1114
-3
lines changed

10 files changed

+1114
-3
lines changed

Documentation/networking/device_drivers/ethernet/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Contents:
3232
intel/e1000
3333
intel/e1000e
3434
intel/fm10k
35+
intel/idpf
3536
intel/igb
3637
intel/igbvf
3738
intel/ixgbe
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
.. SPDX-License-Identifier: GPL-2.0+
2+
3+
==========================================================================
4+
idpf Linux* Base Driver for the Intel(R) Infrastructure Data Path Function
5+
==========================================================================
6+
7+
Intel idpf Linux driver.
8+
Copyright(C) 2023 Intel Corporation.
9+
10+
.. contents::
11+
12+
The idpf driver serves as both the Physical Function (PF) and Virtual Function
13+
(VF) driver for the Intel(R) Infrastructure Data Path Function.
14+
15+
Driver information can be obtained using ethtool, lspci, and ip.
16+
17+
For questions related to hardware requirements, refer to the documentation
18+
supplied with your Intel adapter. All hardware requirements listed apply to use
19+
with Linux.
20+
21+
22+
Identifying Your Adapter
23+
========================
24+
For information on how to identify your adapter, and for the latest Intel
25+
network drivers, refer to the Intel Support website:
26+
http://www.intel.com/support
27+
28+
29+
Additional Features and Configurations
30+
======================================
31+
32+
ethtool
33+
-------
34+
The driver utilizes the ethtool interface for driver configuration and
35+
diagnostics, as well as displaying statistical information. The latest ethtool
36+
version is required for this functionality. If you don't have one yet, you can
37+
obtain it at:
38+
https://kernel.org/pub/software/network/ethtool/
39+
40+
41+
Viewing Link Messages
42+
---------------------
43+
Link messages will not be displayed to the console if the distribution is
44+
restricting system messages. In order to see network driver link messages on
45+
your console, set dmesg to eight by entering the following::
46+
47+
# dmesg -n 8
48+
49+
.. note::
50+
This setting is not saved across reboots.
51+
52+
53+
Jumbo Frames
54+
------------
55+
Jumbo Frames support is enabled by changing the Maximum Transmission Unit (MTU)
56+
to a value larger than the default value of 1500.
57+
58+
Use the ip command to increase the MTU size. For example, enter the following
59+
where <ethX> is the interface number::
60+
61+
# ip link set mtu 9000 dev <ethX>
62+
# ip link set up dev <ethX>
63+
64+
.. note::
65+
The maximum MTU setting for jumbo frames is 9706. This corresponds to the
66+
maximum jumbo frame size of 9728 bytes.
67+
68+
.. note::
69+
This driver will attempt to use multiple page sized buffers to receive
70+
each jumbo packet. This should help to avoid buffer starvation issues when
71+
allocating receive packets.
72+
73+
.. note::
74+
Packet loss may have a greater impact on throughput when you use jumbo
75+
frames. If you observe a drop in performance after enabling jumbo frames,
76+
enabling flow control may mitigate the issue.
77+
78+
79+
Performance Optimization
80+
========================
81+
Driver defaults are meant to fit a wide variety of workloads, but if further
82+
optimization is required, we recommend experimenting with the following
83+
settings.
84+
85+
86+
Interrupt Rate Limiting
87+
-----------------------
88+
This driver supports an adaptive interrupt throttle rate (ITR) mechanism that
89+
is tuned for general workloads. The user can customize the interrupt rate
90+
control for specific workloads, via ethtool, adjusting the number of
91+
microseconds between interrupts.
92+
93+
To set the interrupt rate manually, you must disable adaptive mode::
94+
95+
# ethtool -C <ethX> adaptive-rx off adaptive-tx off
96+
97+
For lower CPU utilization:
98+
- Disable adaptive ITR and lower Rx and Tx interrupts. The examples below
99+
affect every queue of the specified interface.
100+
101+
- Setting rx-usecs and tx-usecs to 80 will limit interrupts to about
102+
12,500 interrupts per second per queue::
103+
104+
# ethtool -C <ethX> adaptive-rx off adaptive-tx off rx-usecs 80
105+
tx-usecs 80
106+
107+
For reduced latency:
108+
- Disable adaptive ITR and ITR by setting rx-usecs and tx-usecs to 0
109+
using ethtool::
110+
111+
# ethtool -C <ethX> adaptive-rx off adaptive-tx off rx-usecs 0
112+
tx-usecs 0
113+
114+
Per-queue interrupt rate settings:
115+
- The following examples are for queues 1 and 3, but you can adjust other
116+
queues.
117+
118+
- To disable Rx adaptive ITR and set static Rx ITR to 10 microseconds or
119+
about 100,000 interrupts/second, for queues 1 and 3::
120+
121+
# ethtool --per-queue <ethX> queue_mask 0xa --coalesce adaptive-rx off
122+
rx-usecs 10
123+
124+
- To show the current coalesce settings for queues 1 and 3::
125+
126+
# ethtool --per-queue <ethX> queue_mask 0xa --show-coalesce
127+
128+
129+
130+
Virtualized Environments
131+
------------------------
132+
In addition to the other suggestions in this section, the following may be
133+
helpful to optimize performance in VMs.
134+
135+
- Using the appropriate mechanism (vcpupin) in the VM, pin the CPUs to
136+
individual LCPUs, making sure to use a set of CPUs included in the
137+
device's local_cpulist: /sys/class/net/<ethX>/device/local_cpulist.
138+
139+
- Configure as many Rx/Tx queues in the VM as available. (See the idpf driver
140+
documentation for the number of queues supported.) For example::
141+
142+
# ethtool -L <virt_interface> rx <max> tx <max>
143+
144+
145+
Support
146+
=======
147+
For general information, go to the Intel support website at:
148+
http://www.intel.com/support/
149+
150+
If an issue is identified with the released source code on a supported kernel
151+
with a supported adapter, email the specific information related to the issue
152+
153+
154+
155+
Trademarks
156+
==========
157+
Intel is a trademark or registered trademark of Intel Corporation or its
158+
subsidiaries in the United States and/or other countries.
159+
160+
* Other names and brands may be claimed as the property of others.

drivers/net/ethernet/intel/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,5 +355,17 @@ config IGC
355355

356356
To compile this driver as a module, choose M here. The module
357357
will be called igc.
358+
config IDPF
359+
tristate "Intel(R) Infrastructure Data Path Function Support"
360+
depends on PCI_MSI
361+
select DIMLIB
362+
select PAGE_POOL
363+
select PAGE_POOL_STATS
364+
help
365+
This driver supports Intel(R) Infrastructure Data Path Function
366+
devices.
367+
368+
To compile this driver as a module, choose M here. The module
369+
will be called idpf.
358370

359371
endif # NET_VENDOR_INTEL

drivers/net/ethernet/intel/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ obj-$(CONFIG_I40E) += i40e/
1515
obj-$(CONFIG_IAVF) += iavf/
1616
obj-$(CONFIG_FM10K) += fm10k/
1717
obj-$(CONFIG_ICE) += ice/
18+
obj-$(CONFIG_IDPF) += idpf/

drivers/net/ethernet/intel/idpf/idpf.h

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,17 @@ enum idpf_vport_state {
147147
* @vport_id: Vport identifier
148148
* @vport_idx: Relative vport index
149149
* @state: See enum idpf_vport_state
150+
* @netstats: Packet and byte stats
151+
* @stats_lock: Lock to protect stats update
150152
*/
151153
struct idpf_netdev_priv {
152154
struct idpf_adapter *adapter;
153155
struct idpf_vport *vport;
154156
u32 vport_id;
155157
u16 vport_idx;
156158
enum idpf_vport_state state;
159+
struct rtnl_link_stats64 netstats;
160+
spinlock_t stats_lock;
157161
};
158162

159163
/**
@@ -239,6 +243,8 @@ struct idpf_dev_ops {
239243
STATE(IDPF_VC_ALLOC_VECTORS_ERR) \
240244
STATE(IDPF_VC_DEALLOC_VECTORS) \
241245
STATE(IDPF_VC_DEALLOC_VECTORS_ERR) \
246+
STATE(IDPF_VC_SET_SRIOV_VFS) \
247+
STATE(IDPF_VC_SET_SRIOV_VFS_ERR) \
242248
STATE(IDPF_VC_GET_RSS_LUT) \
243249
STATE(IDPF_VC_GET_RSS_LUT_ERR) \
244250
STATE(IDPF_VC_SET_RSS_LUT) \
@@ -247,12 +253,16 @@ struct idpf_dev_ops {
247253
STATE(IDPF_VC_GET_RSS_KEY_ERR) \
248254
STATE(IDPF_VC_SET_RSS_KEY) \
249255
STATE(IDPF_VC_SET_RSS_KEY_ERR) \
256+
STATE(IDPF_VC_GET_STATS) \
257+
STATE(IDPF_VC_GET_STATS_ERR) \
250258
STATE(IDPF_VC_ADD_MAC_ADDR) \
251259
STATE(IDPF_VC_ADD_MAC_ADDR_ERR) \
252260
STATE(IDPF_VC_DEL_MAC_ADDR) \
253261
STATE(IDPF_VC_DEL_MAC_ADDR_ERR) \
254262
STATE(IDPF_VC_GET_PTYPE_INFO) \
255263
STATE(IDPF_VC_GET_PTYPE_INFO_ERR) \
264+
STATE(IDPF_VC_LOOPBACK_STATE) \
265+
STATE(IDPF_VC_LOOPBACK_STATE_ERR) \
256266
STATE(IDPF_VC_NBITS)
257267

258268
#define IDPF_GEN_ENUM(ENUM) ENUM,
@@ -268,10 +278,14 @@ extern const char * const idpf_vport_vc_state_str[];
268278
* enum idpf_vport_reset_cause - Vport soft reset causes
269279
* @IDPF_SR_Q_CHANGE: Soft reset queue change
270280
* @IDPF_SR_Q_DESC_CHANGE: Soft reset descriptor change
281+
* @IDPF_SR_MTU_CHANGE: Soft reset MTU change
282+
* @IDPF_SR_RSC_CHANGE: Soft reset RSC change
271283
*/
272284
enum idpf_vport_reset_cause {
273285
IDPF_SR_Q_CHANGE,
274286
IDPF_SR_Q_DESC_CHANGE,
287+
IDPF_SR_MTU_CHANGE,
288+
IDPF_SR_RSC_CHANGE,
275289
};
276290

277291
/**
@@ -402,6 +416,19 @@ struct idpf_vport {
402416
struct mutex vc_buf_lock;
403417
};
404418

419+
/**
420+
* enum idpf_user_flags
421+
* @__IDPF_PROMISC_UC: Unicast promiscuous mode
422+
* @__IDPF_PROMISC_MC: Multicast promiscuous mode
423+
* @__IDPF_USER_FLAGS_NBITS: Must be last
424+
*/
425+
enum idpf_user_flags {
426+
__IDPF_PROMISC_UC = 32,
427+
__IDPF_PROMISC_MC,
428+
429+
__IDPF_USER_FLAGS_NBITS,
430+
};
431+
405432
/**
406433
* struct idpf_rss_data - Associated RSS data
407434
* @rss_key_size: Size of RSS hash key
@@ -428,6 +455,7 @@ struct idpf_rss_data {
428455
* ethtool
429456
* @num_req_rxq_desc: Number of user requested RX queue descriptors through
430457
* ethtool
458+
* @user_flags: User toggled config flags
431459
* @mac_filter_list: List of MAC filters
432460
*
433461
* Used to restore configuration after a reset as the vport will get wiped.
@@ -438,6 +466,7 @@ struct idpf_vport_user_config_data {
438466
u16 num_req_rx_qs;
439467
u32 num_req_txq_desc;
440468
u32 num_req_rxq_desc;
469+
DECLARE_BITMAP(user_flags, __IDPF_USER_FLAGS_NBITS);
441470
struct list_head mac_filter_list;
442471
};
443472

@@ -548,6 +577,7 @@ struct idpf_vport_config {
548577
* @mb_vector: Mailbox vector data
549578
* @vector_stack: Stack to store the msix vector indexes
550579
* @irq_mb_handler: Handler for hard interrupt for mailbox
580+
* @tx_timeout_count: Number of TX timeouts that have occurred
551581
* @avail_queues: Device given queue limits
552582
* @vports: Array to store vports created by the driver
553583
* @netdevs: Associated Vport netdevs
@@ -566,6 +596,8 @@ struct idpf_vport_config {
566596
* @mbx_wq: Workqueue for mailbox responses
567597
* @vc_event_task: Task to handle out of band virtchnl event notifications
568598
* @vc_event_wq: Workqueue for virtchnl events
599+
* @stats_task: Periodic statistics retrieval task
600+
* @stats_wq: Workqueue for statistics task
569601
* @caps: Negotiated capabilities with device
570602
* @vchnl_wq: Wait queue for virtchnl messages
571603
* @vc_state: Virtchnl message state
@@ -601,6 +633,7 @@ struct idpf_adapter {
601633
struct idpf_vector_lifo vector_stack;
602634
irqreturn_t (*irq_mb_handler)(int irq, void *data);
603635

636+
u32 tx_timeout_count;
604637
struct idpf_avail_queue_info avail_queues;
605638
struct idpf_vport **vports;
606639
struct net_device **netdevs;
@@ -621,6 +654,8 @@ struct idpf_adapter {
621654
struct workqueue_struct *mbx_wq;
622655
struct delayed_work vc_event_task;
623656
struct workqueue_struct *vc_event_wq;
657+
struct delayed_work stats_task;
658+
struct workqueue_struct *stats_wq;
624659
struct virtchnl2_get_capabilities caps;
625660

626661
wait_queue_head_t vchnl_wq;
@@ -825,6 +860,15 @@ static inline bool idpf_is_feature_ena(const struct idpf_vport *vport,
825860
return vport->netdev->features & feature;
826861
}
827862

863+
/**
864+
* idpf_get_max_tx_hdr_size -- get the size of tx header
865+
* @adapter: Driver specific private structure
866+
*/
867+
static inline u16 idpf_get_max_tx_hdr_size(struct idpf_adapter *adapter)
868+
{
869+
return le16_to_cpu(adapter->caps.max_tx_hdr_size);
870+
}
871+
828872
/**
829873
* idpf_vport_ctrl_lock - Acquire the vport control lock
830874
* @netdev: Network interface device structure
@@ -850,6 +894,7 @@ static inline void idpf_vport_ctrl_unlock(struct net_device *netdev)
850894
mutex_unlock(&np->adapter->vport_ctrl_lock);
851895
}
852896

897+
void idpf_statistics_task(struct work_struct *work);
853898
void idpf_init_task(struct work_struct *work);
854899
void idpf_service_task(struct work_struct *work);
855900
void idpf_mbx_task(struct work_struct *work);
@@ -865,6 +910,7 @@ int idpf_intr_req(struct idpf_adapter *adapter);
865910
void idpf_intr_rel(struct idpf_adapter *adapter);
866911
int idpf_get_reg_intr_vecs(struct idpf_vport *vport,
867912
struct idpf_vec_regs *reg_vals);
913+
u16 idpf_get_max_tx_hdr_size(struct idpf_adapter *adapter);
868914
int idpf_send_delete_queues_msg(struct idpf_vport *vport);
869915
int idpf_send_add_queues_msg(const struct idpf_vport *vport, u16 num_tx_q,
870916
u16 num_complq, u16 num_rx_q, u16 num_rx_bufq);
@@ -874,6 +920,7 @@ int idpf_send_enable_vport_msg(struct idpf_vport *vport);
874920
int idpf_send_disable_vport_msg(struct idpf_vport *vport);
875921
int idpf_send_destroy_vport_msg(struct idpf_vport *vport);
876922
int idpf_send_get_rx_ptype_msg(struct idpf_vport *vport);
923+
int idpf_send_ena_dis_loopback_msg(struct idpf_vport *vport);
877924
int idpf_send_get_set_rss_key_msg(struct idpf_vport *vport, bool get);
878925
int idpf_send_get_set_rss_lut_msg(struct idpf_vport *vport, bool get);
879926
int idpf_send_dealloc_vectors_msg(struct idpf_adapter *adapter);
@@ -883,6 +930,7 @@ int idpf_req_rel_vector_indexes(struct idpf_adapter *adapter,
883930
u16 *q_vector_idxs,
884931
struct idpf_vector_info *vec_info);
885932
int idpf_vport_alloc_vec_indexes(struct idpf_vport *vport);
933+
int idpf_send_get_stats_msg(struct idpf_vport *vport);
886934
int idpf_get_vec_ids(struct idpf_adapter *adapter,
887935
u16 *vecids, int num_vecids,
888936
struct virtchnl2_vector_chunks *chunks);
@@ -898,6 +946,9 @@ void idpf_vport_dealloc_max_qs(struct idpf_adapter *adapter,
898946
int idpf_add_del_mac_filters(struct idpf_vport *vport,
899947
struct idpf_netdev_priv *np,
900948
bool add, bool async);
949+
int idpf_set_promiscuous(struct idpf_adapter *adapter,
950+
struct idpf_vport_user_config_data *config_data,
951+
u32 vport_id);
901952
int idpf_send_disable_queues_msg(struct idpf_vport *vport);
902953
void idpf_vport_init(struct idpf_vport *vport, struct idpf_vport_max_q *max_q);
903954
u32 idpf_get_vport_id(struct idpf_vport *vport);

0 commit comments

Comments
 (0)