Loading...
1/* SPDX-License-Identifier: GPL-2.0-only */
2/* Copyright (C) 2023 Intel Corporation */
3
4#ifndef _IDPF_H_
5#define _IDPF_H_
6
7/* Forward declaration */
8struct idpf_adapter;
9struct idpf_vport;
10struct idpf_vport_max_q;
11
12#include <net/pkt_sched.h>
13#include <linux/aer.h>
14#include <linux/etherdevice.h>
15#include <linux/pci.h>
16#include <linux/bitfield.h>
17#include <linux/sctp.h>
18#include <linux/ethtool_netlink.h>
19#include <net/gro.h>
20
21#include "virtchnl2.h"
22#include "idpf_txrx.h"
23#include "idpf_controlq.h"
24
25#define GETMAXVAL(num_bits) GENMASK((num_bits) - 1, 0)
26
27#define IDPF_NO_FREE_SLOT 0xffff
28
29/* Default Mailbox settings */
30#define IDPF_NUM_FILTERS_PER_MSG 20
31#define IDPF_NUM_DFLT_MBX_Q 2 /* includes both TX and RX */
32#define IDPF_DFLT_MBX_Q_LEN 64
33#define IDPF_DFLT_MBX_ID -1
34/* maximum number of times to try before resetting mailbox */
35#define IDPF_MB_MAX_ERR 20
36#define IDPF_NUM_CHUNKS_PER_MSG(struct_sz, chunk_sz) \
37 ((IDPF_CTLQ_MAX_BUF_LEN - (struct_sz)) / (chunk_sz))
38
39#define IDPF_MAX_WAIT 500
40
41/* available message levels */
42#define IDPF_AVAIL_NETIF_M (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK)
43
44#define IDPF_DIM_PROFILE_SLOTS 5
45
46#define IDPF_VIRTCHNL_VERSION_MAJOR VIRTCHNL2_VERSION_MAJOR_2
47#define IDPF_VIRTCHNL_VERSION_MINOR VIRTCHNL2_VERSION_MINOR_0
48
49/**
50 * struct idpf_mac_filter
51 * @list: list member field
52 * @macaddr: MAC address
53 * @remove: filter should be removed (virtchnl)
54 * @add: filter should be added (virtchnl)
55 */
56struct idpf_mac_filter {
57 struct list_head list;
58 u8 macaddr[ETH_ALEN];
59 bool remove;
60 bool add;
61};
62
63/**
64 * enum idpf_state - State machine to handle bring up
65 * @__IDPF_VER_CHECK: Negotiate virtchnl version
66 * @__IDPF_GET_CAPS: Negotiate capabilities
67 * @__IDPF_INIT_SW: Init based on given capabilities
68 * @__IDPF_STATE_LAST: Must be last, used to determine size
69 */
70enum idpf_state {
71 __IDPF_VER_CHECK,
72 __IDPF_GET_CAPS,
73 __IDPF_INIT_SW,
74 __IDPF_STATE_LAST,
75};
76
77/**
78 * enum idpf_flags - Hard reset causes.
79 * @IDPF_HR_FUNC_RESET: Hard reset when TxRx timeout
80 * @IDPF_HR_DRV_LOAD: Set on driver load for a clean HW
81 * @IDPF_HR_RESET_IN_PROG: Reset in progress
82 * @IDPF_REMOVE_IN_PROG: Driver remove in progress
83 * @IDPF_MB_INTR_MODE: Mailbox in interrupt mode
84 * @IDPF_VC_CORE_INIT: virtchnl core has been init
85 * @IDPF_FLAGS_NBITS: Must be last
86 */
87enum idpf_flags {
88 IDPF_HR_FUNC_RESET,
89 IDPF_HR_DRV_LOAD,
90 IDPF_HR_RESET_IN_PROG,
91 IDPF_REMOVE_IN_PROG,
92 IDPF_MB_INTR_MODE,
93 IDPF_VC_CORE_INIT,
94 IDPF_FLAGS_NBITS,
95};
96
97/**
98 * enum idpf_cap_field - Offsets into capabilities struct for specific caps
99 * @IDPF_BASE_CAPS: generic base capabilities
100 * @IDPF_CSUM_CAPS: checksum offload capabilities
101 * @IDPF_SEG_CAPS: segmentation offload capabilities
102 * @IDPF_RSS_CAPS: RSS offload capabilities
103 * @IDPF_HSPLIT_CAPS: Header split capabilities
104 * @IDPF_RSC_CAPS: RSC offload capabilities
105 * @IDPF_OTHER_CAPS: miscellaneous offloads
106 *
107 * Used when checking for a specific capability flag since different capability
108 * sets are not mutually exclusive numerically, the caller must specify which
109 * type of capability they are checking for.
110 */
111enum idpf_cap_field {
112 IDPF_BASE_CAPS = -1,
113 IDPF_CSUM_CAPS = offsetof(struct virtchnl2_get_capabilities,
114 csum_caps),
115 IDPF_SEG_CAPS = offsetof(struct virtchnl2_get_capabilities,
116 seg_caps),
117 IDPF_RSS_CAPS = offsetof(struct virtchnl2_get_capabilities,
118 rss_caps),
119 IDPF_HSPLIT_CAPS = offsetof(struct virtchnl2_get_capabilities,
120 hsplit_caps),
121 IDPF_RSC_CAPS = offsetof(struct virtchnl2_get_capabilities,
122 rsc_caps),
123 IDPF_OTHER_CAPS = offsetof(struct virtchnl2_get_capabilities,
124 other_caps),
125};
126
127/**
128 * enum idpf_vport_state - Current vport state
129 * @__IDPF_VPORT_DOWN: Vport is down
130 * @__IDPF_VPORT_UP: Vport is up
131 * @__IDPF_VPORT_STATE_LAST: Must be last, number of states
132 */
133enum idpf_vport_state {
134 __IDPF_VPORT_DOWN,
135 __IDPF_VPORT_UP,
136 __IDPF_VPORT_STATE_LAST,
137};
138
139/**
140 * struct idpf_netdev_priv - Struct to store vport back pointer
141 * @adapter: Adapter back pointer
142 * @vport: Vport back pointer
143 * @vport_id: Vport identifier
144 * @link_speed_mbps: Link speed in mbps
145 * @vport_idx: Relative vport index
146 * @state: See enum idpf_vport_state
147 * @netstats: Packet and byte stats
148 * @stats_lock: Lock to protect stats update
149 */
150struct idpf_netdev_priv {
151 struct idpf_adapter *adapter;
152 struct idpf_vport *vport;
153 u32 vport_id;
154 u32 link_speed_mbps;
155 u16 vport_idx;
156 enum idpf_vport_state state;
157 struct rtnl_link_stats64 netstats;
158 spinlock_t stats_lock;
159};
160
161/**
162 * struct idpf_reset_reg - Reset register offsets/masks
163 * @rstat: Reset status register
164 * @rstat_m: Reset status mask
165 */
166struct idpf_reset_reg {
167 void __iomem *rstat;
168 u32 rstat_m;
169};
170
171/**
172 * struct idpf_vport_max_q - Queue limits
173 * @max_rxq: Maximum number of RX queues supported
174 * @max_txq: Maixmum number of TX queues supported
175 * @max_bufq: In splitq, maximum number of buffer queues supported
176 * @max_complq: In splitq, maximum number of completion queues supported
177 */
178struct idpf_vport_max_q {
179 u16 max_rxq;
180 u16 max_txq;
181 u16 max_bufq;
182 u16 max_complq;
183};
184
185/**
186 * struct idpf_reg_ops - Device specific register operation function pointers
187 * @ctlq_reg_init: Mailbox control queue register initialization
188 * @intr_reg_init: Traffic interrupt register initialization
189 * @mb_intr_reg_init: Mailbox interrupt register initialization
190 * @reset_reg_init: Reset register initialization
191 * @trigger_reset: Trigger a reset to occur
192 */
193struct idpf_reg_ops {
194 void (*ctlq_reg_init)(struct idpf_ctlq_create_info *cq);
195 int (*intr_reg_init)(struct idpf_vport *vport);
196 void (*mb_intr_reg_init)(struct idpf_adapter *adapter);
197 void (*reset_reg_init)(struct idpf_adapter *adapter);
198 void (*trigger_reset)(struct idpf_adapter *adapter,
199 enum idpf_flags trig_cause);
200};
201
202/**
203 * struct idpf_dev_ops - Device specific operations
204 * @reg_ops: Register operations
205 */
206struct idpf_dev_ops {
207 struct idpf_reg_ops reg_ops;
208};
209
210/**
211 * enum idpf_vport_reset_cause - Vport soft reset causes
212 * @IDPF_SR_Q_CHANGE: Soft reset queue change
213 * @IDPF_SR_Q_DESC_CHANGE: Soft reset descriptor change
214 * @IDPF_SR_MTU_CHANGE: Soft reset MTU change
215 * @IDPF_SR_RSC_CHANGE: Soft reset RSC change
216 */
217enum idpf_vport_reset_cause {
218 IDPF_SR_Q_CHANGE,
219 IDPF_SR_Q_DESC_CHANGE,
220 IDPF_SR_MTU_CHANGE,
221 IDPF_SR_RSC_CHANGE,
222};
223
224/**
225 * enum idpf_vport_flags - Vport flags
226 * @IDPF_VPORT_DEL_QUEUES: To send delete queues message
227 * @IDPF_VPORT_SW_MARKER: Indicate TX pipe drain software marker packets
228 * processing is done
229 * @IDPF_VPORT_FLAGS_NBITS: Must be last
230 */
231enum idpf_vport_flags {
232 IDPF_VPORT_DEL_QUEUES,
233 IDPF_VPORT_SW_MARKER,
234 IDPF_VPORT_FLAGS_NBITS,
235};
236
237struct idpf_port_stats {
238 struct u64_stats_sync stats_sync;
239 u64_stats_t rx_hw_csum_err;
240 u64_stats_t rx_hsplit;
241 u64_stats_t rx_hsplit_hbo;
242 u64_stats_t rx_bad_descs;
243 u64_stats_t tx_linearize;
244 u64_stats_t tx_busy;
245 u64_stats_t tx_drops;
246 u64_stats_t tx_dma_map_errs;
247 struct virtchnl2_vport_stats vport_stats;
248};
249
250/**
251 * struct idpf_vport - Handle for netdevices and queue resources
252 * @num_txq: Number of allocated TX queues
253 * @num_complq: Number of allocated completion queues
254 * @txq_desc_count: TX queue descriptor count
255 * @complq_desc_count: Completion queue descriptor count
256 * @compln_clean_budget: Work budget for completion clean
257 * @num_txq_grp: Number of TX queue groups
258 * @txq_grps: Array of TX queue groups
259 * @txq_model: Split queue or single queue queuing model
260 * @txqs: Used only in hotpath to get to the right queue very fast
261 * @crc_enable: Enable CRC insertion offload
262 * @num_rxq: Number of allocated RX queues
263 * @num_bufq: Number of allocated buffer queues
264 * @rxq_desc_count: RX queue descriptor count. *MUST* have enough descriptors
265 * to complete all buffer descriptors for all buffer queues in
266 * the worst case.
267 * @num_bufqs_per_qgrp: Buffer queues per RX queue in a given grouping
268 * @bufq_desc_count: Buffer queue descriptor count
269 * @num_rxq_grp: Number of RX queues in a group
270 * @rxq_grps: Total number of RX groups. Number of groups * number of RX per
271 * group will yield total number of RX queues.
272 * @rxq_model: Splitq queue or single queue queuing model
273 * @rx_ptype_lkup: Lookup table for ptypes on RX
274 * @adapter: back pointer to associated adapter
275 * @netdev: Associated net_device. Each vport should have one and only one
276 * associated netdev.
277 * @flags: See enum idpf_vport_flags
278 * @vport_type: Default SRIOV, SIOV, etc.
279 * @vport_id: Device given vport identifier
280 * @idx: Software index in adapter vports struct
281 * @default_vport: Use this vport if one isn't specified
282 * @base_rxd: True if the driver should use base descriptors instead of flex
283 * @num_q_vectors: Number of IRQ vectors allocated
284 * @q_vectors: Array of queue vectors
285 * @q_vector_idxs: Starting index of queue vectors
286 * @max_mtu: device given max possible MTU
287 * @default_mac_addr: device will give a default MAC to use
288 * @rx_itr_profile: RX profiles for Dynamic Interrupt Moderation
289 * @tx_itr_profile: TX profiles for Dynamic Interrupt Moderation
290 * @port_stats: per port csum, header split, and other offload stats
291 * @link_up: True if link is up
292 * @sw_marker_wq: workqueue for marker packets
293 */
294struct idpf_vport {
295 u16 num_txq;
296 u16 num_complq;
297 u32 txq_desc_count;
298 u32 complq_desc_count;
299 u32 compln_clean_budget;
300 u16 num_txq_grp;
301 struct idpf_txq_group *txq_grps;
302 u32 txq_model;
303 struct idpf_tx_queue **txqs;
304 bool crc_enable;
305
306 u16 num_rxq;
307 u16 num_bufq;
308 u32 rxq_desc_count;
309 u8 num_bufqs_per_qgrp;
310 u32 bufq_desc_count[IDPF_MAX_BUFQS_PER_RXQ_GRP];
311 u16 num_rxq_grp;
312 struct idpf_rxq_group *rxq_grps;
313 u32 rxq_model;
314 struct libeth_rx_pt *rx_ptype_lkup;
315
316 struct idpf_adapter *adapter;
317 struct net_device *netdev;
318 DECLARE_BITMAP(flags, IDPF_VPORT_FLAGS_NBITS);
319 u16 vport_type;
320 u32 vport_id;
321 u16 idx;
322 bool default_vport;
323 bool base_rxd;
324
325 u16 num_q_vectors;
326 struct idpf_q_vector *q_vectors;
327 u16 *q_vector_idxs;
328 u16 max_mtu;
329 u8 default_mac_addr[ETH_ALEN];
330 u16 rx_itr_profile[IDPF_DIM_PROFILE_SLOTS];
331 u16 tx_itr_profile[IDPF_DIM_PROFILE_SLOTS];
332 struct idpf_port_stats port_stats;
333
334 bool link_up;
335
336 wait_queue_head_t sw_marker_wq;
337};
338
339/**
340 * enum idpf_user_flags
341 * @__IDPF_USER_FLAG_HSPLIT: header split state
342 * @__IDPF_PROMISC_UC: Unicast promiscuous mode
343 * @__IDPF_PROMISC_MC: Multicast promiscuous mode
344 * @__IDPF_USER_FLAGS_NBITS: Must be last
345 */
346enum idpf_user_flags {
347 __IDPF_USER_FLAG_HSPLIT = 0U,
348 __IDPF_PROMISC_UC = 32,
349 __IDPF_PROMISC_MC,
350
351 __IDPF_USER_FLAGS_NBITS,
352};
353
354/**
355 * struct idpf_rss_data - Associated RSS data
356 * @rss_key_size: Size of RSS hash key
357 * @rss_key: RSS hash key
358 * @rss_lut_size: Size of RSS lookup table
359 * @rss_lut: RSS lookup table
360 * @cached_lut: Used to restore previously init RSS lut
361 */
362struct idpf_rss_data {
363 u16 rss_key_size;
364 u8 *rss_key;
365 u16 rss_lut_size;
366 u32 *rss_lut;
367 u32 *cached_lut;
368};
369
370/**
371 * struct idpf_vport_user_config_data - User defined configuration values for
372 * each vport.
373 * @rss_data: See struct idpf_rss_data
374 * @num_req_tx_qs: Number of user requested TX queues through ethtool
375 * @num_req_rx_qs: Number of user requested RX queues through ethtool
376 * @num_req_txq_desc: Number of user requested TX queue descriptors through
377 * ethtool
378 * @num_req_rxq_desc: Number of user requested RX queue descriptors through
379 * ethtool
380 * @user_flags: User toggled config flags
381 * @mac_filter_list: List of MAC filters
382 *
383 * Used to restore configuration after a reset as the vport will get wiped.
384 */
385struct idpf_vport_user_config_data {
386 struct idpf_rss_data rss_data;
387 u16 num_req_tx_qs;
388 u16 num_req_rx_qs;
389 u32 num_req_txq_desc;
390 u32 num_req_rxq_desc;
391 DECLARE_BITMAP(user_flags, __IDPF_USER_FLAGS_NBITS);
392 struct list_head mac_filter_list;
393};
394
395/**
396 * enum idpf_vport_config_flags - Vport config flags
397 * @IDPF_VPORT_REG_NETDEV: Register netdev
398 * @IDPF_VPORT_UP_REQUESTED: Set if interface up is requested on core reset
399 * @IDPF_VPORT_CONFIG_FLAGS_NBITS: Must be last
400 */
401enum idpf_vport_config_flags {
402 IDPF_VPORT_REG_NETDEV,
403 IDPF_VPORT_UP_REQUESTED,
404 IDPF_VPORT_CONFIG_FLAGS_NBITS,
405};
406
407/**
408 * struct idpf_avail_queue_info
409 * @avail_rxq: Available RX queues
410 * @avail_txq: Available TX queues
411 * @avail_bufq: Available buffer queues
412 * @avail_complq: Available completion queues
413 *
414 * Maintain total queues available after allocating max queues to each vport.
415 */
416struct idpf_avail_queue_info {
417 u16 avail_rxq;
418 u16 avail_txq;
419 u16 avail_bufq;
420 u16 avail_complq;
421};
422
423/**
424 * struct idpf_vector_info - Utility structure to pass function arguments as a
425 * structure
426 * @num_req_vecs: Vectors required based on the number of queues updated by the
427 * user via ethtool
428 * @num_curr_vecs: Current number of vectors, must be >= @num_req_vecs
429 * @index: Relative starting index for vectors
430 * @default_vport: Vectors are for default vport
431 */
432struct idpf_vector_info {
433 u16 num_req_vecs;
434 u16 num_curr_vecs;
435 u16 index;
436 bool default_vport;
437};
438
439/**
440 * struct idpf_vector_lifo - Stack to maintain vector indexes used for vector
441 * distribution algorithm
442 * @top: Points to stack top i.e. next available vector index
443 * @base: Always points to start of the free pool
444 * @size: Total size of the vector stack
445 * @vec_idx: Array to store all the vector indexes
446 *
447 * Vector stack maintains all the relative vector indexes at the *adapter*
448 * level. This stack is divided into 2 parts, first one is called as 'default
449 * pool' and other one is called 'free pool'. Vector distribution algorithm
450 * gives priority to default vports in a way that at least IDPF_MIN_Q_VEC
451 * vectors are allocated per default vport and the relative vector indexes for
452 * those are maintained in default pool. Free pool contains all the unallocated
453 * vector indexes which can be allocated on-demand basis. Mailbox vector index
454 * is maintained in the default pool of the stack.
455 */
456struct idpf_vector_lifo {
457 u16 top;
458 u16 base;
459 u16 size;
460 u16 *vec_idx;
461};
462
463/**
464 * struct idpf_vport_config - Vport configuration data
465 * @user_config: see struct idpf_vport_user_config_data
466 * @max_q: Maximum possible queues
467 * @req_qs_chunks: Queue chunk data for requested queues
468 * @mac_filter_list_lock: Lock to protect mac filters
469 * @flags: See enum idpf_vport_config_flags
470 */
471struct idpf_vport_config {
472 struct idpf_vport_user_config_data user_config;
473 struct idpf_vport_max_q max_q;
474 struct virtchnl2_add_queues *req_qs_chunks;
475 spinlock_t mac_filter_list_lock;
476 DECLARE_BITMAP(flags, IDPF_VPORT_CONFIG_FLAGS_NBITS);
477};
478
479struct idpf_vc_xn_manager;
480
481/**
482 * struct idpf_adapter - Device data struct generated on probe
483 * @pdev: PCI device struct given on probe
484 * @virt_ver_maj: Virtchnl version major
485 * @virt_ver_min: Virtchnl version minor
486 * @msg_enable: Debug message level enabled
487 * @mb_wait_count: Number of times mailbox was attempted initialization
488 * @state: Init state machine
489 * @flags: See enum idpf_flags
490 * @reset_reg: See struct idpf_reset_reg
491 * @hw: Device access data
492 * @num_req_msix: Requested number of MSIX vectors
493 * @num_avail_msix: Available number of MSIX vectors
494 * @num_msix_entries: Number of entries in MSIX table
495 * @msix_entries: MSIX table
496 * @req_vec_chunks: Requested vector chunk data
497 * @mb_vector: Mailbox vector data
498 * @vector_stack: Stack to store the msix vector indexes
499 * @irq_mb_handler: Handler for hard interrupt for mailbox
500 * @tx_timeout_count: Number of TX timeouts that have occurred
501 * @avail_queues: Device given queue limits
502 * @vports: Array to store vports created by the driver
503 * @netdevs: Associated Vport netdevs
504 * @vport_params_reqd: Vport params requested
505 * @vport_params_recvd: Vport params received
506 * @vport_ids: Array of device given vport identifiers
507 * @vport_config: Vport config parameters
508 * @max_vports: Maximum vports that can be allocated
509 * @num_alloc_vports: Current number of vports allocated
510 * @next_vport: Next free slot in pf->vport[] - 0-based!
511 * @init_task: Initialization task
512 * @init_wq: Workqueue for initialization task
513 * @serv_task: Periodically recurring maintenance task
514 * @serv_wq: Workqueue for service task
515 * @mbx_task: Task to handle mailbox interrupts
516 * @mbx_wq: Workqueue for mailbox responses
517 * @vc_event_task: Task to handle out of band virtchnl event notifications
518 * @vc_event_wq: Workqueue for virtchnl events
519 * @stats_task: Periodic statistics retrieval task
520 * @stats_wq: Workqueue for statistics task
521 * @caps: Negotiated capabilities with device
522 * @vcxn_mngr: Virtchnl transaction manager
523 * @dev_ops: See idpf_dev_ops
524 * @num_vfs: Number of allocated VFs through sysfs. PF does not directly talk
525 * to VFs but is used to initialize them
526 * @crc_enable: Enable CRC insertion offload
527 * @req_tx_splitq: TX split or single queue model to request
528 * @req_rx_splitq: RX split or single queue model to request
529 * @vport_ctrl_lock: Lock to protect the vport control flow
530 * @vector_lock: Lock to protect vector distribution
531 * @queue_lock: Lock to protect queue distribution
532 * @vc_buf_lock: Lock to protect virtchnl buffer
533 */
534struct idpf_adapter {
535 struct pci_dev *pdev;
536 u32 virt_ver_maj;
537 u32 virt_ver_min;
538
539 u32 msg_enable;
540 u32 mb_wait_count;
541 enum idpf_state state;
542 DECLARE_BITMAP(flags, IDPF_FLAGS_NBITS);
543 struct idpf_reset_reg reset_reg;
544 struct idpf_hw hw;
545 u16 num_req_msix;
546 u16 num_avail_msix;
547 u16 num_msix_entries;
548 struct msix_entry *msix_entries;
549 struct virtchnl2_alloc_vectors *req_vec_chunks;
550 struct idpf_q_vector mb_vector;
551 struct idpf_vector_lifo vector_stack;
552 irqreturn_t (*irq_mb_handler)(int irq, void *data);
553
554 u32 tx_timeout_count;
555 struct idpf_avail_queue_info avail_queues;
556 struct idpf_vport **vports;
557 struct net_device **netdevs;
558 struct virtchnl2_create_vport **vport_params_reqd;
559 struct virtchnl2_create_vport **vport_params_recvd;
560 u32 *vport_ids;
561
562 struct idpf_vport_config **vport_config;
563 u16 max_vports;
564 u16 num_alloc_vports;
565 u16 next_vport;
566
567 struct delayed_work init_task;
568 struct workqueue_struct *init_wq;
569 struct delayed_work serv_task;
570 struct workqueue_struct *serv_wq;
571 struct delayed_work mbx_task;
572 struct workqueue_struct *mbx_wq;
573 struct delayed_work vc_event_task;
574 struct workqueue_struct *vc_event_wq;
575 struct delayed_work stats_task;
576 struct workqueue_struct *stats_wq;
577 struct virtchnl2_get_capabilities caps;
578 struct idpf_vc_xn_manager *vcxn_mngr;
579
580 struct idpf_dev_ops dev_ops;
581 int num_vfs;
582 bool crc_enable;
583 bool req_tx_splitq;
584 bool req_rx_splitq;
585
586 struct mutex vport_ctrl_lock;
587 struct mutex vector_lock;
588 struct mutex queue_lock;
589 struct mutex vc_buf_lock;
590};
591
592/**
593 * idpf_is_queue_model_split - check if queue model is split
594 * @q_model: queue model single or split
595 *
596 * Returns true if queue model is split else false
597 */
598static inline int idpf_is_queue_model_split(u16 q_model)
599{
600 return !IS_ENABLED(CONFIG_IDPF_SINGLEQ) ||
601 q_model == VIRTCHNL2_QUEUE_MODEL_SPLIT;
602}
603
604#define idpf_is_cap_ena(adapter, field, flag) \
605 idpf_is_capability_ena(adapter, false, field, flag)
606#define idpf_is_cap_ena_all(adapter, field, flag) \
607 idpf_is_capability_ena(adapter, true, field, flag)
608
609bool idpf_is_capability_ena(struct idpf_adapter *adapter, bool all,
610 enum idpf_cap_field field, u64 flag);
611
612#define IDPF_CAP_RSS (\
613 VIRTCHNL2_CAP_RSS_IPV4_TCP |\
614 VIRTCHNL2_CAP_RSS_IPV4_TCP |\
615 VIRTCHNL2_CAP_RSS_IPV4_UDP |\
616 VIRTCHNL2_CAP_RSS_IPV4_SCTP |\
617 VIRTCHNL2_CAP_RSS_IPV4_OTHER |\
618 VIRTCHNL2_CAP_RSS_IPV6_TCP |\
619 VIRTCHNL2_CAP_RSS_IPV6_TCP |\
620 VIRTCHNL2_CAP_RSS_IPV6_UDP |\
621 VIRTCHNL2_CAP_RSS_IPV6_SCTP |\
622 VIRTCHNL2_CAP_RSS_IPV6_OTHER)
623
624#define IDPF_CAP_RSC (\
625 VIRTCHNL2_CAP_RSC_IPV4_TCP |\
626 VIRTCHNL2_CAP_RSC_IPV6_TCP)
627
628#define IDPF_CAP_HSPLIT (\
629 VIRTCHNL2_CAP_RX_HSPLIT_AT_L4V4 |\
630 VIRTCHNL2_CAP_RX_HSPLIT_AT_L4V6)
631
632#define IDPF_CAP_RX_CSUM_L4V4 (\
633 VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_TCP |\
634 VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_UDP)
635
636#define IDPF_CAP_RX_CSUM_L4V6 (\
637 VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_TCP |\
638 VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_UDP)
639
640#define IDPF_CAP_RX_CSUM (\
641 VIRTCHNL2_CAP_RX_CSUM_L3_IPV4 |\
642 VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_TCP |\
643 VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_UDP |\
644 VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_TCP |\
645 VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_UDP)
646
647#define IDPF_CAP_SCTP_CSUM (\
648 VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_SCTP |\
649 VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_SCTP |\
650 VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_SCTP |\
651 VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_SCTP)
652
653#define IDPF_CAP_TUNNEL_TX_CSUM (\
654 VIRTCHNL2_CAP_TX_CSUM_L3_SINGLE_TUNNEL |\
655 VIRTCHNL2_CAP_TX_CSUM_L4_SINGLE_TUNNEL)
656
657/**
658 * idpf_get_reserved_vecs - Get reserved vectors
659 * @adapter: private data struct
660 */
661static inline u16 idpf_get_reserved_vecs(struct idpf_adapter *adapter)
662{
663 return le16_to_cpu(adapter->caps.num_allocated_vectors);
664}
665
666/**
667 * idpf_get_default_vports - Get default number of vports
668 * @adapter: private data struct
669 */
670static inline u16 idpf_get_default_vports(struct idpf_adapter *adapter)
671{
672 return le16_to_cpu(adapter->caps.default_num_vports);
673}
674
675/**
676 * idpf_get_max_vports - Get max number of vports
677 * @adapter: private data struct
678 */
679static inline u16 idpf_get_max_vports(struct idpf_adapter *adapter)
680{
681 return le16_to_cpu(adapter->caps.max_vports);
682}
683
684/**
685 * idpf_get_max_tx_bufs - Get max scatter-gather buffers supported by the device
686 * @adapter: private data struct
687 */
688static inline unsigned int idpf_get_max_tx_bufs(struct idpf_adapter *adapter)
689{
690 return adapter->caps.max_sg_bufs_per_tx_pkt;
691}
692
693/**
694 * idpf_get_min_tx_pkt_len - Get min packet length supported by the device
695 * @adapter: private data struct
696 */
697static inline u8 idpf_get_min_tx_pkt_len(struct idpf_adapter *adapter)
698{
699 u8 pkt_len = adapter->caps.min_sso_packet_len;
700
701 return pkt_len ? pkt_len : IDPF_TX_MIN_PKT_LEN;
702}
703
704/**
705 * idpf_get_reg_addr - Get BAR0 register address
706 * @adapter: private data struct
707 * @reg_offset: register offset value
708 *
709 * Based on the register offset, return the actual BAR0 register address
710 */
711static inline void __iomem *idpf_get_reg_addr(struct idpf_adapter *adapter,
712 resource_size_t reg_offset)
713{
714 return (void __iomem *)(adapter->hw.hw_addr + reg_offset);
715}
716
717/**
718 * idpf_is_reset_detected - check if we were reset at some point
719 * @adapter: driver specific private structure
720 *
721 * Returns true if we are either in reset currently or were previously reset.
722 */
723static inline bool idpf_is_reset_detected(struct idpf_adapter *adapter)
724{
725 if (!adapter->hw.arq)
726 return true;
727
728 return !(readl(idpf_get_reg_addr(adapter, adapter->hw.arq->reg.len)) &
729 adapter->hw.arq->reg.len_mask);
730}
731
732/**
733 * idpf_is_reset_in_prog - check if reset is in progress
734 * @adapter: driver specific private structure
735 *
736 * Returns true if hard reset is in progress, false otherwise
737 */
738static inline bool idpf_is_reset_in_prog(struct idpf_adapter *adapter)
739{
740 return (test_bit(IDPF_HR_RESET_IN_PROG, adapter->flags) ||
741 test_bit(IDPF_HR_FUNC_RESET, adapter->flags) ||
742 test_bit(IDPF_HR_DRV_LOAD, adapter->flags));
743}
744
745/**
746 * idpf_netdev_to_vport - get a vport handle from a netdev
747 * @netdev: network interface device structure
748 */
749static inline struct idpf_vport *idpf_netdev_to_vport(struct net_device *netdev)
750{
751 struct idpf_netdev_priv *np = netdev_priv(netdev);
752
753 return np->vport;
754}
755
756/**
757 * idpf_netdev_to_adapter - Get adapter handle from a netdev
758 * @netdev: Network interface device structure
759 */
760static inline struct idpf_adapter *idpf_netdev_to_adapter(struct net_device *netdev)
761{
762 struct idpf_netdev_priv *np = netdev_priv(netdev);
763
764 return np->adapter;
765}
766
767/**
768 * idpf_is_feature_ena - Determine if a particular feature is enabled
769 * @vport: Vport to check
770 * @feature: Netdev flag to check
771 *
772 * Returns true or false if a particular feature is enabled.
773 */
774static inline bool idpf_is_feature_ena(const struct idpf_vport *vport,
775 netdev_features_t feature)
776{
777 return vport->netdev->features & feature;
778}
779
780/**
781 * idpf_get_max_tx_hdr_size -- get the size of tx header
782 * @adapter: Driver specific private structure
783 */
784static inline u16 idpf_get_max_tx_hdr_size(struct idpf_adapter *adapter)
785{
786 return le16_to_cpu(adapter->caps.max_tx_hdr_size);
787}
788
789/**
790 * idpf_vport_ctrl_lock - Acquire the vport control lock
791 * @netdev: Network interface device structure
792 *
793 * This lock should be used by non-datapath code to protect against vport
794 * destruction.
795 */
796static inline void idpf_vport_ctrl_lock(struct net_device *netdev)
797{
798 struct idpf_netdev_priv *np = netdev_priv(netdev);
799
800 mutex_lock(&np->adapter->vport_ctrl_lock);
801}
802
803/**
804 * idpf_vport_ctrl_unlock - Release the vport control lock
805 * @netdev: Network interface device structure
806 */
807static inline void idpf_vport_ctrl_unlock(struct net_device *netdev)
808{
809 struct idpf_netdev_priv *np = netdev_priv(netdev);
810
811 mutex_unlock(&np->adapter->vport_ctrl_lock);
812}
813
814void idpf_statistics_task(struct work_struct *work);
815void idpf_init_task(struct work_struct *work);
816void idpf_service_task(struct work_struct *work);
817void idpf_mbx_task(struct work_struct *work);
818void idpf_vc_event_task(struct work_struct *work);
819void idpf_dev_ops_init(struct idpf_adapter *adapter);
820void idpf_vf_dev_ops_init(struct idpf_adapter *adapter);
821int idpf_intr_req(struct idpf_adapter *adapter);
822void idpf_intr_rel(struct idpf_adapter *adapter);
823u16 idpf_get_max_tx_hdr_size(struct idpf_adapter *adapter);
824int idpf_initiate_soft_reset(struct idpf_vport *vport,
825 enum idpf_vport_reset_cause reset_cause);
826void idpf_deinit_task(struct idpf_adapter *adapter);
827int idpf_req_rel_vector_indexes(struct idpf_adapter *adapter,
828 u16 *q_vector_idxs,
829 struct idpf_vector_info *vec_info);
830void idpf_set_ethtool_ops(struct net_device *netdev);
831void idpf_vport_intr_write_itr(struct idpf_q_vector *q_vector,
832 u16 itr, bool tx);
833int idpf_sriov_configure(struct pci_dev *pdev, int num_vfs);
834
835u8 idpf_vport_get_hsplit(const struct idpf_vport *vport);
836bool idpf_vport_set_hsplit(const struct idpf_vport *vport, u8 val);
837
838#endif /* !_IDPF_H_ */
1/* SPDX-License-Identifier: GPL-2.0-only */
2/* Copyright (C) 2023 Intel Corporation */
3
4#ifndef _IDPF_H_
5#define _IDPF_H_
6
7/* Forward declaration */
8struct idpf_adapter;
9struct idpf_vport;
10struct idpf_vport_max_q;
11
12#include <net/pkt_sched.h>
13#include <linux/aer.h>
14#include <linux/etherdevice.h>
15#include <linux/pci.h>
16#include <linux/bitfield.h>
17#include <linux/sctp.h>
18#include <linux/ethtool_netlink.h>
19#include <net/gro.h>
20#include <linux/dim.h>
21
22#include "virtchnl2.h"
23#include "idpf_lan_txrx.h"
24#include "idpf_txrx.h"
25#include "idpf_controlq.h"
26
27#define GETMAXVAL(num_bits) GENMASK((num_bits) - 1, 0)
28
29#define IDPF_NO_FREE_SLOT 0xffff
30
31/* Default Mailbox settings */
32#define IDPF_NUM_FILTERS_PER_MSG 20
33#define IDPF_NUM_DFLT_MBX_Q 2 /* includes both TX and RX */
34#define IDPF_DFLT_MBX_Q_LEN 64
35#define IDPF_DFLT_MBX_ID -1
36/* maximum number of times to try before resetting mailbox */
37#define IDPF_MB_MAX_ERR 20
38#define IDPF_NUM_CHUNKS_PER_MSG(struct_sz, chunk_sz) \
39 ((IDPF_CTLQ_MAX_BUF_LEN - (struct_sz)) / (chunk_sz))
40#define IDPF_WAIT_FOR_EVENT_TIMEO_MIN 2000
41#define IDPF_WAIT_FOR_EVENT_TIMEO 60000
42
43#define IDPF_MAX_WAIT 500
44
45/* available message levels */
46#define IDPF_AVAIL_NETIF_M (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK)
47
48#define IDPF_DIM_PROFILE_SLOTS 5
49
50#define IDPF_VIRTCHNL_VERSION_MAJOR VIRTCHNL2_VERSION_MAJOR_2
51#define IDPF_VIRTCHNL_VERSION_MINOR VIRTCHNL2_VERSION_MINOR_0
52
53/**
54 * struct idpf_mac_filter
55 * @list: list member field
56 * @macaddr: MAC address
57 * @remove: filter should be removed (virtchnl)
58 * @add: filter should be added (virtchnl)
59 */
60struct idpf_mac_filter {
61 struct list_head list;
62 u8 macaddr[ETH_ALEN];
63 bool remove;
64 bool add;
65};
66
67/**
68 * enum idpf_state - State machine to handle bring up
69 * @__IDPF_STARTUP: Start the state machine
70 * @__IDPF_VER_CHECK: Negotiate virtchnl version
71 * @__IDPF_GET_CAPS: Negotiate capabilities
72 * @__IDPF_INIT_SW: Init based on given capabilities
73 * @__IDPF_STATE_LAST: Must be last, used to determine size
74 */
75enum idpf_state {
76 __IDPF_STARTUP,
77 __IDPF_VER_CHECK,
78 __IDPF_GET_CAPS,
79 __IDPF_INIT_SW,
80 __IDPF_STATE_LAST,
81};
82
83/**
84 * enum idpf_flags - Hard reset causes.
85 * @IDPF_HR_FUNC_RESET: Hard reset when TxRx timeout
86 * @IDPF_HR_DRV_LOAD: Set on driver load for a clean HW
87 * @IDPF_HR_RESET_IN_PROG: Reset in progress
88 * @IDPF_REMOVE_IN_PROG: Driver remove in progress
89 * @IDPF_MB_INTR_MODE: Mailbox in interrupt mode
90 * @IDPF_FLAGS_NBITS: Must be last
91 */
92enum idpf_flags {
93 IDPF_HR_FUNC_RESET,
94 IDPF_HR_DRV_LOAD,
95 IDPF_HR_RESET_IN_PROG,
96 IDPF_REMOVE_IN_PROG,
97 IDPF_MB_INTR_MODE,
98 IDPF_FLAGS_NBITS,
99};
100
101/**
102 * enum idpf_cap_field - Offsets into capabilities struct for specific caps
103 * @IDPF_BASE_CAPS: generic base capabilities
104 * @IDPF_CSUM_CAPS: checksum offload capabilities
105 * @IDPF_SEG_CAPS: segmentation offload capabilities
106 * @IDPF_RSS_CAPS: RSS offload capabilities
107 * @IDPF_HSPLIT_CAPS: Header split capabilities
108 * @IDPF_RSC_CAPS: RSC offload capabilities
109 * @IDPF_OTHER_CAPS: miscellaneous offloads
110 *
111 * Used when checking for a specific capability flag since different capability
112 * sets are not mutually exclusive numerically, the caller must specify which
113 * type of capability they are checking for.
114 */
115enum idpf_cap_field {
116 IDPF_BASE_CAPS = -1,
117 IDPF_CSUM_CAPS = offsetof(struct virtchnl2_get_capabilities,
118 csum_caps),
119 IDPF_SEG_CAPS = offsetof(struct virtchnl2_get_capabilities,
120 seg_caps),
121 IDPF_RSS_CAPS = offsetof(struct virtchnl2_get_capabilities,
122 rss_caps),
123 IDPF_HSPLIT_CAPS = offsetof(struct virtchnl2_get_capabilities,
124 hsplit_caps),
125 IDPF_RSC_CAPS = offsetof(struct virtchnl2_get_capabilities,
126 rsc_caps),
127 IDPF_OTHER_CAPS = offsetof(struct virtchnl2_get_capabilities,
128 other_caps),
129};
130
131/**
132 * enum idpf_vport_state - Current vport state
133 * @__IDPF_VPORT_DOWN: Vport is down
134 * @__IDPF_VPORT_UP: Vport is up
135 * @__IDPF_VPORT_STATE_LAST: Must be last, number of states
136 */
137enum idpf_vport_state {
138 __IDPF_VPORT_DOWN,
139 __IDPF_VPORT_UP,
140 __IDPF_VPORT_STATE_LAST,
141};
142
143/**
144 * struct idpf_netdev_priv - Struct to store vport back pointer
145 * @adapter: Adapter back pointer
146 * @vport: Vport back pointer
147 * @vport_id: Vport identifier
148 * @vport_idx: Relative vport index
149 * @state: See enum idpf_vport_state
150 * @netstats: Packet and byte stats
151 * @stats_lock: Lock to protect stats update
152 */
153struct idpf_netdev_priv {
154 struct idpf_adapter *adapter;
155 struct idpf_vport *vport;
156 u32 vport_id;
157 u16 vport_idx;
158 enum idpf_vport_state state;
159 struct rtnl_link_stats64 netstats;
160 spinlock_t stats_lock;
161};
162
163/**
164 * struct idpf_reset_reg - Reset register offsets/masks
165 * @rstat: Reset status register
166 * @rstat_m: Reset status mask
167 */
168struct idpf_reset_reg {
169 void __iomem *rstat;
170 u32 rstat_m;
171};
172
173/**
174 * struct idpf_vport_max_q - Queue limits
175 * @max_rxq: Maximum number of RX queues supported
176 * @max_txq: Maixmum number of TX queues supported
177 * @max_bufq: In splitq, maximum number of buffer queues supported
178 * @max_complq: In splitq, maximum number of completion queues supported
179 */
180struct idpf_vport_max_q {
181 u16 max_rxq;
182 u16 max_txq;
183 u16 max_bufq;
184 u16 max_complq;
185};
186
187/**
188 * struct idpf_reg_ops - Device specific register operation function pointers
189 * @ctlq_reg_init: Mailbox control queue register initialization
190 * @intr_reg_init: Traffic interrupt register initialization
191 * @mb_intr_reg_init: Mailbox interrupt register initialization
192 * @reset_reg_init: Reset register initialization
193 * @trigger_reset: Trigger a reset to occur
194 */
195struct idpf_reg_ops {
196 void (*ctlq_reg_init)(struct idpf_ctlq_create_info *cq);
197 int (*intr_reg_init)(struct idpf_vport *vport);
198 void (*mb_intr_reg_init)(struct idpf_adapter *adapter);
199 void (*reset_reg_init)(struct idpf_adapter *adapter);
200 void (*trigger_reset)(struct idpf_adapter *adapter,
201 enum idpf_flags trig_cause);
202};
203
204/**
205 * struct idpf_dev_ops - Device specific operations
206 * @reg_ops: Register operations
207 */
208struct idpf_dev_ops {
209 struct idpf_reg_ops reg_ops;
210};
211
212/* These macros allow us to generate an enum and a matching char * array of
213 * stringified enums that are always in sync. Checkpatch issues a bogus warning
214 * about this being a complex macro; but it's wrong, these are never used as a
215 * statement and instead only used to define the enum and array.
216 */
217#define IDPF_FOREACH_VPORT_VC_STATE(STATE) \
218 STATE(IDPF_VC_CREATE_VPORT) \
219 STATE(IDPF_VC_CREATE_VPORT_ERR) \
220 STATE(IDPF_VC_ENA_VPORT) \
221 STATE(IDPF_VC_ENA_VPORT_ERR) \
222 STATE(IDPF_VC_DIS_VPORT) \
223 STATE(IDPF_VC_DIS_VPORT_ERR) \
224 STATE(IDPF_VC_DESTROY_VPORT) \
225 STATE(IDPF_VC_DESTROY_VPORT_ERR) \
226 STATE(IDPF_VC_CONFIG_TXQ) \
227 STATE(IDPF_VC_CONFIG_TXQ_ERR) \
228 STATE(IDPF_VC_CONFIG_RXQ) \
229 STATE(IDPF_VC_CONFIG_RXQ_ERR) \
230 STATE(IDPF_VC_ENA_QUEUES) \
231 STATE(IDPF_VC_ENA_QUEUES_ERR) \
232 STATE(IDPF_VC_DIS_QUEUES) \
233 STATE(IDPF_VC_DIS_QUEUES_ERR) \
234 STATE(IDPF_VC_MAP_IRQ) \
235 STATE(IDPF_VC_MAP_IRQ_ERR) \
236 STATE(IDPF_VC_UNMAP_IRQ) \
237 STATE(IDPF_VC_UNMAP_IRQ_ERR) \
238 STATE(IDPF_VC_ADD_QUEUES) \
239 STATE(IDPF_VC_ADD_QUEUES_ERR) \
240 STATE(IDPF_VC_DEL_QUEUES) \
241 STATE(IDPF_VC_DEL_QUEUES_ERR) \
242 STATE(IDPF_VC_ALLOC_VECTORS) \
243 STATE(IDPF_VC_ALLOC_VECTORS_ERR) \
244 STATE(IDPF_VC_DEALLOC_VECTORS) \
245 STATE(IDPF_VC_DEALLOC_VECTORS_ERR) \
246 STATE(IDPF_VC_SET_SRIOV_VFS) \
247 STATE(IDPF_VC_SET_SRIOV_VFS_ERR) \
248 STATE(IDPF_VC_GET_RSS_LUT) \
249 STATE(IDPF_VC_GET_RSS_LUT_ERR) \
250 STATE(IDPF_VC_SET_RSS_LUT) \
251 STATE(IDPF_VC_SET_RSS_LUT_ERR) \
252 STATE(IDPF_VC_GET_RSS_KEY) \
253 STATE(IDPF_VC_GET_RSS_KEY_ERR) \
254 STATE(IDPF_VC_SET_RSS_KEY) \
255 STATE(IDPF_VC_SET_RSS_KEY_ERR) \
256 STATE(IDPF_VC_GET_STATS) \
257 STATE(IDPF_VC_GET_STATS_ERR) \
258 STATE(IDPF_VC_ADD_MAC_ADDR) \
259 STATE(IDPF_VC_ADD_MAC_ADDR_ERR) \
260 STATE(IDPF_VC_DEL_MAC_ADDR) \
261 STATE(IDPF_VC_DEL_MAC_ADDR_ERR) \
262 STATE(IDPF_VC_GET_PTYPE_INFO) \
263 STATE(IDPF_VC_GET_PTYPE_INFO_ERR) \
264 STATE(IDPF_VC_LOOPBACK_STATE) \
265 STATE(IDPF_VC_LOOPBACK_STATE_ERR) \
266 STATE(IDPF_VC_NBITS)
267
268#define IDPF_GEN_ENUM(ENUM) ENUM,
269#define IDPF_GEN_STRING(STRING) #STRING,
270
271enum idpf_vport_vc_state {
272 IDPF_FOREACH_VPORT_VC_STATE(IDPF_GEN_ENUM)
273};
274
275extern const char * const idpf_vport_vc_state_str[];
276
277/**
278 * enum idpf_vport_reset_cause - Vport soft reset causes
279 * @IDPF_SR_Q_CHANGE: Soft reset queue change
280 * @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
283 */
284enum idpf_vport_reset_cause {
285 IDPF_SR_Q_CHANGE,
286 IDPF_SR_Q_DESC_CHANGE,
287 IDPF_SR_MTU_CHANGE,
288 IDPF_SR_RSC_CHANGE,
289};
290
291/**
292 * enum idpf_vport_flags - Vport flags
293 * @IDPF_VPORT_DEL_QUEUES: To send delete queues message
294 * @IDPF_VPORT_SW_MARKER: Indicate TX pipe drain software marker packets
295 * processing is done
296 * @IDPF_VPORT_FLAGS_NBITS: Must be last
297 */
298enum idpf_vport_flags {
299 IDPF_VPORT_DEL_QUEUES,
300 IDPF_VPORT_SW_MARKER,
301 IDPF_VPORT_FLAGS_NBITS,
302};
303
304struct idpf_port_stats {
305 struct u64_stats_sync stats_sync;
306 u64_stats_t rx_hw_csum_err;
307 u64_stats_t rx_hsplit;
308 u64_stats_t rx_hsplit_hbo;
309 u64_stats_t rx_bad_descs;
310 u64_stats_t tx_linearize;
311 u64_stats_t tx_busy;
312 u64_stats_t tx_drops;
313 u64_stats_t tx_dma_map_errs;
314 struct virtchnl2_vport_stats vport_stats;
315};
316
317/**
318 * struct idpf_vport - Handle for netdevices and queue resources
319 * @num_txq: Number of allocated TX queues
320 * @num_complq: Number of allocated completion queues
321 * @txq_desc_count: TX queue descriptor count
322 * @complq_desc_count: Completion queue descriptor count
323 * @compln_clean_budget: Work budget for completion clean
324 * @num_txq_grp: Number of TX queue groups
325 * @txq_grps: Array of TX queue groups
326 * @txq_model: Split queue or single queue queuing model
327 * @txqs: Used only in hotpath to get to the right queue very fast
328 * @crc_enable: Enable CRC insertion offload
329 * @num_rxq: Number of allocated RX queues
330 * @num_bufq: Number of allocated buffer queues
331 * @rxq_desc_count: RX queue descriptor count. *MUST* have enough descriptors
332 * to complete all buffer descriptors for all buffer queues in
333 * the worst case.
334 * @num_bufqs_per_qgrp: Buffer queues per RX queue in a given grouping
335 * @bufq_desc_count: Buffer queue descriptor count
336 * @bufq_size: Size of buffers in ring (e.g. 2K, 4K, etc)
337 * @num_rxq_grp: Number of RX queues in a group
338 * @rxq_grps: Total number of RX groups. Number of groups * number of RX per
339 * group will yield total number of RX queues.
340 * @rxq_model: Splitq queue or single queue queuing model
341 * @rx_ptype_lkup: Lookup table for ptypes on RX
342 * @adapter: back pointer to associated adapter
343 * @netdev: Associated net_device. Each vport should have one and only one
344 * associated netdev.
345 * @flags: See enum idpf_vport_flags
346 * @vport_type: Default SRIOV, SIOV, etc.
347 * @vport_id: Device given vport identifier
348 * @idx: Software index in adapter vports struct
349 * @default_vport: Use this vport if one isn't specified
350 * @base_rxd: True if the driver should use base descriptors instead of flex
351 * @num_q_vectors: Number of IRQ vectors allocated
352 * @q_vectors: Array of queue vectors
353 * @q_vector_idxs: Starting index of queue vectors
354 * @max_mtu: device given max possible MTU
355 * @default_mac_addr: device will give a default MAC to use
356 * @rx_itr_profile: RX profiles for Dynamic Interrupt Moderation
357 * @tx_itr_profile: TX profiles for Dynamic Interrupt Moderation
358 * @port_stats: per port csum, header split, and other offload stats
359 * @link_up: True if link is up
360 * @link_speed_mbps: Link speed in mbps
361 * @vc_msg: Virtchnl message buffer
362 * @vc_state: Virtchnl message state
363 * @vchnl_wq: Wait queue for virtchnl messages
364 * @sw_marker_wq: workqueue for marker packets
365 * @vc_buf_lock: Lock to protect virtchnl buffer
366 */
367struct idpf_vport {
368 u16 num_txq;
369 u16 num_complq;
370 u32 txq_desc_count;
371 u32 complq_desc_count;
372 u32 compln_clean_budget;
373 u16 num_txq_grp;
374 struct idpf_txq_group *txq_grps;
375 u32 txq_model;
376 struct idpf_queue **txqs;
377 bool crc_enable;
378
379 u16 num_rxq;
380 u16 num_bufq;
381 u32 rxq_desc_count;
382 u8 num_bufqs_per_qgrp;
383 u32 bufq_desc_count[IDPF_MAX_BUFQS_PER_RXQ_GRP];
384 u32 bufq_size[IDPF_MAX_BUFQS_PER_RXQ_GRP];
385 u16 num_rxq_grp;
386 struct idpf_rxq_group *rxq_grps;
387 u32 rxq_model;
388 struct idpf_rx_ptype_decoded rx_ptype_lkup[IDPF_RX_MAX_PTYPE];
389
390 struct idpf_adapter *adapter;
391 struct net_device *netdev;
392 DECLARE_BITMAP(flags, IDPF_VPORT_FLAGS_NBITS);
393 u16 vport_type;
394 u32 vport_id;
395 u16 idx;
396 bool default_vport;
397 bool base_rxd;
398
399 u16 num_q_vectors;
400 struct idpf_q_vector *q_vectors;
401 u16 *q_vector_idxs;
402 u16 max_mtu;
403 u8 default_mac_addr[ETH_ALEN];
404 u16 rx_itr_profile[IDPF_DIM_PROFILE_SLOTS];
405 u16 tx_itr_profile[IDPF_DIM_PROFILE_SLOTS];
406 struct idpf_port_stats port_stats;
407
408 bool link_up;
409 u32 link_speed_mbps;
410
411 char vc_msg[IDPF_CTLQ_MAX_BUF_LEN];
412 DECLARE_BITMAP(vc_state, IDPF_VC_NBITS);
413
414 wait_queue_head_t vchnl_wq;
415 wait_queue_head_t sw_marker_wq;
416 struct mutex vc_buf_lock;
417};
418
419/**
420 * enum idpf_user_flags
421 * @__IDPF_USER_FLAG_HSPLIT: header split state
422 * @__IDPF_PROMISC_UC: Unicast promiscuous mode
423 * @__IDPF_PROMISC_MC: Multicast promiscuous mode
424 * @__IDPF_USER_FLAGS_NBITS: Must be last
425 */
426enum idpf_user_flags {
427 __IDPF_USER_FLAG_HSPLIT = 0U,
428 __IDPF_PROMISC_UC = 32,
429 __IDPF_PROMISC_MC,
430
431 __IDPF_USER_FLAGS_NBITS,
432};
433
434/**
435 * struct idpf_rss_data - Associated RSS data
436 * @rss_key_size: Size of RSS hash key
437 * @rss_key: RSS hash key
438 * @rss_lut_size: Size of RSS lookup table
439 * @rss_lut: RSS lookup table
440 * @cached_lut: Used to restore previously init RSS lut
441 */
442struct idpf_rss_data {
443 u16 rss_key_size;
444 u8 *rss_key;
445 u16 rss_lut_size;
446 u32 *rss_lut;
447 u32 *cached_lut;
448};
449
450/**
451 * struct idpf_vport_user_config_data - User defined configuration values for
452 * each vport.
453 * @rss_data: See struct idpf_rss_data
454 * @num_req_tx_qs: Number of user requested TX queues through ethtool
455 * @num_req_rx_qs: Number of user requested RX queues through ethtool
456 * @num_req_txq_desc: Number of user requested TX queue descriptors through
457 * ethtool
458 * @num_req_rxq_desc: Number of user requested RX queue descriptors through
459 * ethtool
460 * @user_flags: User toggled config flags
461 * @mac_filter_list: List of MAC filters
462 *
463 * Used to restore configuration after a reset as the vport will get wiped.
464 */
465struct idpf_vport_user_config_data {
466 struct idpf_rss_data rss_data;
467 u16 num_req_tx_qs;
468 u16 num_req_rx_qs;
469 u32 num_req_txq_desc;
470 u32 num_req_rxq_desc;
471 DECLARE_BITMAP(user_flags, __IDPF_USER_FLAGS_NBITS);
472 struct list_head mac_filter_list;
473};
474
475/**
476 * enum idpf_vport_config_flags - Vport config flags
477 * @IDPF_VPORT_REG_NETDEV: Register netdev
478 * @IDPF_VPORT_UP_REQUESTED: Set if interface up is requested on core reset
479 * @IDPF_VPORT_ADD_MAC_REQ: Asynchronous add ether address in flight
480 * @IDPF_VPORT_DEL_MAC_REQ: Asynchronous delete ether address in flight
481 * @IDPF_VPORT_CONFIG_FLAGS_NBITS: Must be last
482 */
483enum idpf_vport_config_flags {
484 IDPF_VPORT_REG_NETDEV,
485 IDPF_VPORT_UP_REQUESTED,
486 IDPF_VPORT_ADD_MAC_REQ,
487 IDPF_VPORT_DEL_MAC_REQ,
488 IDPF_VPORT_CONFIG_FLAGS_NBITS,
489};
490
491/**
492 * struct idpf_avail_queue_info
493 * @avail_rxq: Available RX queues
494 * @avail_txq: Available TX queues
495 * @avail_bufq: Available buffer queues
496 * @avail_complq: Available completion queues
497 *
498 * Maintain total queues available after allocating max queues to each vport.
499 */
500struct idpf_avail_queue_info {
501 u16 avail_rxq;
502 u16 avail_txq;
503 u16 avail_bufq;
504 u16 avail_complq;
505};
506
507/**
508 * struct idpf_vector_info - Utility structure to pass function arguments as a
509 * structure
510 * @num_req_vecs: Vectors required based on the number of queues updated by the
511 * user via ethtool
512 * @num_curr_vecs: Current number of vectors, must be >= @num_req_vecs
513 * @index: Relative starting index for vectors
514 * @default_vport: Vectors are for default vport
515 */
516struct idpf_vector_info {
517 u16 num_req_vecs;
518 u16 num_curr_vecs;
519 u16 index;
520 bool default_vport;
521};
522
523/**
524 * struct idpf_vector_lifo - Stack to maintain vector indexes used for vector
525 * distribution algorithm
526 * @top: Points to stack top i.e. next available vector index
527 * @base: Always points to start of the free pool
528 * @size: Total size of the vector stack
529 * @vec_idx: Array to store all the vector indexes
530 *
531 * Vector stack maintains all the relative vector indexes at the *adapter*
532 * level. This stack is divided into 2 parts, first one is called as 'default
533 * pool' and other one is called 'free pool'. Vector distribution algorithm
534 * gives priority to default vports in a way that at least IDPF_MIN_Q_VEC
535 * vectors are allocated per default vport and the relative vector indexes for
536 * those are maintained in default pool. Free pool contains all the unallocated
537 * vector indexes which can be allocated on-demand basis. Mailbox vector index
538 * is maintained in the default pool of the stack.
539 */
540struct idpf_vector_lifo {
541 u16 top;
542 u16 base;
543 u16 size;
544 u16 *vec_idx;
545};
546
547/**
548 * struct idpf_vport_config - Vport configuration data
549 * @user_config: see struct idpf_vport_user_config_data
550 * @max_q: Maximum possible queues
551 * @req_qs_chunks: Queue chunk data for requested queues
552 * @mac_filter_list_lock: Lock to protect mac filters
553 * @flags: See enum idpf_vport_config_flags
554 */
555struct idpf_vport_config {
556 struct idpf_vport_user_config_data user_config;
557 struct idpf_vport_max_q max_q;
558 void *req_qs_chunks;
559 spinlock_t mac_filter_list_lock;
560 DECLARE_BITMAP(flags, IDPF_VPORT_CONFIG_FLAGS_NBITS);
561};
562
563/**
564 * struct idpf_adapter - Device data struct generated on probe
565 * @pdev: PCI device struct given on probe
566 * @virt_ver_maj: Virtchnl version major
567 * @virt_ver_min: Virtchnl version minor
568 * @msg_enable: Debug message level enabled
569 * @mb_wait_count: Number of times mailbox was attempted initialization
570 * @state: Init state machine
571 * @flags: See enum idpf_flags
572 * @reset_reg: See struct idpf_reset_reg
573 * @hw: Device access data
574 * @num_req_msix: Requested number of MSIX vectors
575 * @num_avail_msix: Available number of MSIX vectors
576 * @num_msix_entries: Number of entries in MSIX table
577 * @msix_entries: MSIX table
578 * @req_vec_chunks: Requested vector chunk data
579 * @mb_vector: Mailbox vector data
580 * @vector_stack: Stack to store the msix vector indexes
581 * @irq_mb_handler: Handler for hard interrupt for mailbox
582 * @tx_timeout_count: Number of TX timeouts that have occurred
583 * @avail_queues: Device given queue limits
584 * @vports: Array to store vports created by the driver
585 * @netdevs: Associated Vport netdevs
586 * @vport_params_reqd: Vport params requested
587 * @vport_params_recvd: Vport params received
588 * @vport_ids: Array of device given vport identifiers
589 * @vport_config: Vport config parameters
590 * @max_vports: Maximum vports that can be allocated
591 * @num_alloc_vports: Current number of vports allocated
592 * @next_vport: Next free slot in pf->vport[] - 0-based!
593 * @init_task: Initialization task
594 * @init_wq: Workqueue for initialization task
595 * @serv_task: Periodically recurring maintenance task
596 * @serv_wq: Workqueue for service task
597 * @mbx_task: Task to handle mailbox interrupts
598 * @mbx_wq: Workqueue for mailbox responses
599 * @vc_event_task: Task to handle out of band virtchnl event notifications
600 * @vc_event_wq: Workqueue for virtchnl events
601 * @stats_task: Periodic statistics retrieval task
602 * @stats_wq: Workqueue for statistics task
603 * @caps: Negotiated capabilities with device
604 * @vchnl_wq: Wait queue for virtchnl messages
605 * @vc_state: Virtchnl message state
606 * @vc_msg: Virtchnl message buffer
607 * @dev_ops: See idpf_dev_ops
608 * @num_vfs: Number of allocated VFs through sysfs. PF does not directly talk
609 * to VFs but is used to initialize them
610 * @crc_enable: Enable CRC insertion offload
611 * @req_tx_splitq: TX split or single queue model to request
612 * @req_rx_splitq: RX split or single queue model to request
613 * @vport_ctrl_lock: Lock to protect the vport control flow
614 * @vector_lock: Lock to protect vector distribution
615 * @queue_lock: Lock to protect queue distribution
616 * @vc_buf_lock: Lock to protect virtchnl buffer
617 */
618struct idpf_adapter {
619 struct pci_dev *pdev;
620 u32 virt_ver_maj;
621 u32 virt_ver_min;
622
623 u32 msg_enable;
624 u32 mb_wait_count;
625 enum idpf_state state;
626 DECLARE_BITMAP(flags, IDPF_FLAGS_NBITS);
627 struct idpf_reset_reg reset_reg;
628 struct idpf_hw hw;
629 u16 num_req_msix;
630 u16 num_avail_msix;
631 u16 num_msix_entries;
632 struct msix_entry *msix_entries;
633 struct virtchnl2_alloc_vectors *req_vec_chunks;
634 struct idpf_q_vector mb_vector;
635 struct idpf_vector_lifo vector_stack;
636 irqreturn_t (*irq_mb_handler)(int irq, void *data);
637
638 u32 tx_timeout_count;
639 struct idpf_avail_queue_info avail_queues;
640 struct idpf_vport **vports;
641 struct net_device **netdevs;
642 struct virtchnl2_create_vport **vport_params_reqd;
643 struct virtchnl2_create_vport **vport_params_recvd;
644 u32 *vport_ids;
645
646 struct idpf_vport_config **vport_config;
647 u16 max_vports;
648 u16 num_alloc_vports;
649 u16 next_vport;
650
651 struct delayed_work init_task;
652 struct workqueue_struct *init_wq;
653 struct delayed_work serv_task;
654 struct workqueue_struct *serv_wq;
655 struct delayed_work mbx_task;
656 struct workqueue_struct *mbx_wq;
657 struct delayed_work vc_event_task;
658 struct workqueue_struct *vc_event_wq;
659 struct delayed_work stats_task;
660 struct workqueue_struct *stats_wq;
661 struct virtchnl2_get_capabilities caps;
662
663 wait_queue_head_t vchnl_wq;
664 DECLARE_BITMAP(vc_state, IDPF_VC_NBITS);
665 char vc_msg[IDPF_CTLQ_MAX_BUF_LEN];
666 struct idpf_dev_ops dev_ops;
667 int num_vfs;
668 bool crc_enable;
669 bool req_tx_splitq;
670 bool req_rx_splitq;
671
672 struct mutex vport_ctrl_lock;
673 struct mutex vector_lock;
674 struct mutex queue_lock;
675 struct mutex vc_buf_lock;
676};
677
678/**
679 * idpf_is_queue_model_split - check if queue model is split
680 * @q_model: queue model single or split
681 *
682 * Returns true if queue model is split else false
683 */
684static inline int idpf_is_queue_model_split(u16 q_model)
685{
686 return q_model == VIRTCHNL2_QUEUE_MODEL_SPLIT;
687}
688
689#define idpf_is_cap_ena(adapter, field, flag) \
690 idpf_is_capability_ena(adapter, false, field, flag)
691#define idpf_is_cap_ena_all(adapter, field, flag) \
692 idpf_is_capability_ena(adapter, true, field, flag)
693
694bool idpf_is_capability_ena(struct idpf_adapter *adapter, bool all,
695 enum idpf_cap_field field, u64 flag);
696
697#define IDPF_CAP_RSS (\
698 VIRTCHNL2_CAP_RSS_IPV4_TCP |\
699 VIRTCHNL2_CAP_RSS_IPV4_TCP |\
700 VIRTCHNL2_CAP_RSS_IPV4_UDP |\
701 VIRTCHNL2_CAP_RSS_IPV4_SCTP |\
702 VIRTCHNL2_CAP_RSS_IPV4_OTHER |\
703 VIRTCHNL2_CAP_RSS_IPV6_TCP |\
704 VIRTCHNL2_CAP_RSS_IPV6_TCP |\
705 VIRTCHNL2_CAP_RSS_IPV6_UDP |\
706 VIRTCHNL2_CAP_RSS_IPV6_SCTP |\
707 VIRTCHNL2_CAP_RSS_IPV6_OTHER)
708
709#define IDPF_CAP_RSC (\
710 VIRTCHNL2_CAP_RSC_IPV4_TCP |\
711 VIRTCHNL2_CAP_RSC_IPV6_TCP)
712
713#define IDPF_CAP_HSPLIT (\
714 VIRTCHNL2_CAP_RX_HSPLIT_AT_L4V4 |\
715 VIRTCHNL2_CAP_RX_HSPLIT_AT_L4V6)
716
717#define IDPF_CAP_RX_CSUM_L4V4 (\
718 VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_TCP |\
719 VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_UDP)
720
721#define IDPF_CAP_RX_CSUM_L4V6 (\
722 VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_TCP |\
723 VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_UDP)
724
725#define IDPF_CAP_RX_CSUM (\
726 VIRTCHNL2_CAP_RX_CSUM_L3_IPV4 |\
727 VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_TCP |\
728 VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_UDP |\
729 VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_TCP |\
730 VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_UDP)
731
732#define IDPF_CAP_SCTP_CSUM (\
733 VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_SCTP |\
734 VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_SCTP |\
735 VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_SCTP |\
736 VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_SCTP)
737
738#define IDPF_CAP_TUNNEL_TX_CSUM (\
739 VIRTCHNL2_CAP_TX_CSUM_L3_SINGLE_TUNNEL |\
740 VIRTCHNL2_CAP_TX_CSUM_L4_SINGLE_TUNNEL)
741
742/**
743 * idpf_get_reserved_vecs - Get reserved vectors
744 * @adapter: private data struct
745 */
746static inline u16 idpf_get_reserved_vecs(struct idpf_adapter *adapter)
747{
748 return le16_to_cpu(adapter->caps.num_allocated_vectors);
749}
750
751/**
752 * idpf_get_default_vports - Get default number of vports
753 * @adapter: private data struct
754 */
755static inline u16 idpf_get_default_vports(struct idpf_adapter *adapter)
756{
757 return le16_to_cpu(adapter->caps.default_num_vports);
758}
759
760/**
761 * idpf_get_max_vports - Get max number of vports
762 * @adapter: private data struct
763 */
764static inline u16 idpf_get_max_vports(struct idpf_adapter *adapter)
765{
766 return le16_to_cpu(adapter->caps.max_vports);
767}
768
769/**
770 * idpf_get_max_tx_bufs - Get max scatter-gather buffers supported by the device
771 * @adapter: private data struct
772 */
773static inline unsigned int idpf_get_max_tx_bufs(struct idpf_adapter *adapter)
774{
775 return adapter->caps.max_sg_bufs_per_tx_pkt;
776}
777
778/**
779 * idpf_get_min_tx_pkt_len - Get min packet length supported by the device
780 * @adapter: private data struct
781 */
782static inline u8 idpf_get_min_tx_pkt_len(struct idpf_adapter *adapter)
783{
784 u8 pkt_len = adapter->caps.min_sso_packet_len;
785
786 return pkt_len ? pkt_len : IDPF_TX_MIN_PKT_LEN;
787}
788
789/**
790 * idpf_get_reg_addr - Get BAR0 register address
791 * @adapter: private data struct
792 * @reg_offset: register offset value
793 *
794 * Based on the register offset, return the actual BAR0 register address
795 */
796static inline void __iomem *idpf_get_reg_addr(struct idpf_adapter *adapter,
797 resource_size_t reg_offset)
798{
799 return (void __iomem *)(adapter->hw.hw_addr + reg_offset);
800}
801
802/**
803 * idpf_is_reset_detected - check if we were reset at some point
804 * @adapter: driver specific private structure
805 *
806 * Returns true if we are either in reset currently or were previously reset.
807 */
808static inline bool idpf_is_reset_detected(struct idpf_adapter *adapter)
809{
810 if (!adapter->hw.arq)
811 return true;
812
813 return !(readl(idpf_get_reg_addr(adapter, adapter->hw.arq->reg.len)) &
814 adapter->hw.arq->reg.len_mask);
815}
816
817/**
818 * idpf_is_reset_in_prog - check if reset is in progress
819 * @adapter: driver specific private structure
820 *
821 * Returns true if hard reset is in progress, false otherwise
822 */
823static inline bool idpf_is_reset_in_prog(struct idpf_adapter *adapter)
824{
825 return (test_bit(IDPF_HR_RESET_IN_PROG, adapter->flags) ||
826 test_bit(IDPF_HR_FUNC_RESET, adapter->flags) ||
827 test_bit(IDPF_HR_DRV_LOAD, adapter->flags));
828}
829
830/**
831 * idpf_netdev_to_vport - get a vport handle from a netdev
832 * @netdev: network interface device structure
833 */
834static inline struct idpf_vport *idpf_netdev_to_vport(struct net_device *netdev)
835{
836 struct idpf_netdev_priv *np = netdev_priv(netdev);
837
838 return np->vport;
839}
840
841/**
842 * idpf_netdev_to_adapter - Get adapter handle from a netdev
843 * @netdev: Network interface device structure
844 */
845static inline struct idpf_adapter *idpf_netdev_to_adapter(struct net_device *netdev)
846{
847 struct idpf_netdev_priv *np = netdev_priv(netdev);
848
849 return np->adapter;
850}
851
852/**
853 * idpf_is_feature_ena - Determine if a particular feature is enabled
854 * @vport: Vport to check
855 * @feature: Netdev flag to check
856 *
857 * Returns true or false if a particular feature is enabled.
858 */
859static inline bool idpf_is_feature_ena(const struct idpf_vport *vport,
860 netdev_features_t feature)
861{
862 return vport->netdev->features & feature;
863}
864
865/**
866 * idpf_get_max_tx_hdr_size -- get the size of tx header
867 * @adapter: Driver specific private structure
868 */
869static inline u16 idpf_get_max_tx_hdr_size(struct idpf_adapter *adapter)
870{
871 return le16_to_cpu(adapter->caps.max_tx_hdr_size);
872}
873
874/**
875 * idpf_vport_ctrl_lock - Acquire the vport control lock
876 * @netdev: Network interface device structure
877 *
878 * This lock should be used by non-datapath code to protect against vport
879 * destruction.
880 */
881static inline void idpf_vport_ctrl_lock(struct net_device *netdev)
882{
883 struct idpf_netdev_priv *np = netdev_priv(netdev);
884
885 mutex_lock(&np->adapter->vport_ctrl_lock);
886}
887
888/**
889 * idpf_vport_ctrl_unlock - Release the vport control lock
890 * @netdev: Network interface device structure
891 */
892static inline void idpf_vport_ctrl_unlock(struct net_device *netdev)
893{
894 struct idpf_netdev_priv *np = netdev_priv(netdev);
895
896 mutex_unlock(&np->adapter->vport_ctrl_lock);
897}
898
899void idpf_statistics_task(struct work_struct *work);
900void idpf_init_task(struct work_struct *work);
901void idpf_service_task(struct work_struct *work);
902void idpf_mbx_task(struct work_struct *work);
903void idpf_vc_event_task(struct work_struct *work);
904void idpf_dev_ops_init(struct idpf_adapter *adapter);
905void idpf_vf_dev_ops_init(struct idpf_adapter *adapter);
906int idpf_vport_adjust_qs(struct idpf_vport *vport);
907int idpf_init_dflt_mbx(struct idpf_adapter *adapter);
908void idpf_deinit_dflt_mbx(struct idpf_adapter *adapter);
909int idpf_vc_core_init(struct idpf_adapter *adapter);
910void idpf_vc_core_deinit(struct idpf_adapter *adapter);
911int idpf_intr_req(struct idpf_adapter *adapter);
912void idpf_intr_rel(struct idpf_adapter *adapter);
913int idpf_get_reg_intr_vecs(struct idpf_vport *vport,
914 struct idpf_vec_regs *reg_vals);
915u16 idpf_get_max_tx_hdr_size(struct idpf_adapter *adapter);
916int idpf_send_delete_queues_msg(struct idpf_vport *vport);
917int idpf_send_add_queues_msg(const struct idpf_vport *vport, u16 num_tx_q,
918 u16 num_complq, u16 num_rx_q, u16 num_rx_bufq);
919int idpf_initiate_soft_reset(struct idpf_vport *vport,
920 enum idpf_vport_reset_cause reset_cause);
921int idpf_send_enable_vport_msg(struct idpf_vport *vport);
922int idpf_send_disable_vport_msg(struct idpf_vport *vport);
923int idpf_send_destroy_vport_msg(struct idpf_vport *vport);
924int idpf_send_get_rx_ptype_msg(struct idpf_vport *vport);
925int idpf_send_ena_dis_loopback_msg(struct idpf_vport *vport);
926int idpf_send_get_set_rss_key_msg(struct idpf_vport *vport, bool get);
927int idpf_send_get_set_rss_lut_msg(struct idpf_vport *vport, bool get);
928int idpf_send_dealloc_vectors_msg(struct idpf_adapter *adapter);
929int idpf_send_alloc_vectors_msg(struct idpf_adapter *adapter, u16 num_vectors);
930void idpf_deinit_task(struct idpf_adapter *adapter);
931int idpf_req_rel_vector_indexes(struct idpf_adapter *adapter,
932 u16 *q_vector_idxs,
933 struct idpf_vector_info *vec_info);
934int idpf_vport_alloc_vec_indexes(struct idpf_vport *vport);
935int idpf_send_get_stats_msg(struct idpf_vport *vport);
936int idpf_get_vec_ids(struct idpf_adapter *adapter,
937 u16 *vecids, int num_vecids,
938 struct virtchnl2_vector_chunks *chunks);
939int idpf_recv_mb_msg(struct idpf_adapter *adapter, u32 op,
940 void *msg, int msg_size);
941int idpf_send_mb_msg(struct idpf_adapter *adapter, u32 op,
942 u16 msg_size, u8 *msg);
943void idpf_set_ethtool_ops(struct net_device *netdev);
944int idpf_vport_alloc_max_qs(struct idpf_adapter *adapter,
945 struct idpf_vport_max_q *max_q);
946void idpf_vport_dealloc_max_qs(struct idpf_adapter *adapter,
947 struct idpf_vport_max_q *max_q);
948int idpf_add_del_mac_filters(struct idpf_vport *vport,
949 struct idpf_netdev_priv *np,
950 bool add, bool async);
951int idpf_set_promiscuous(struct idpf_adapter *adapter,
952 struct idpf_vport_user_config_data *config_data,
953 u32 vport_id);
954int idpf_send_disable_queues_msg(struct idpf_vport *vport);
955void idpf_vport_init(struct idpf_vport *vport, struct idpf_vport_max_q *max_q);
956u32 idpf_get_vport_id(struct idpf_vport *vport);
957int idpf_vport_queue_ids_init(struct idpf_vport *vport);
958int idpf_queue_reg_init(struct idpf_vport *vport);
959int idpf_send_config_queues_msg(struct idpf_vport *vport);
960int idpf_send_enable_queues_msg(struct idpf_vport *vport);
961int idpf_send_create_vport_msg(struct idpf_adapter *adapter,
962 struct idpf_vport_max_q *max_q);
963int idpf_check_supported_desc_ids(struct idpf_vport *vport);
964void idpf_vport_intr_write_itr(struct idpf_q_vector *q_vector,
965 u16 itr, bool tx);
966int idpf_send_map_unmap_queue_vector_msg(struct idpf_vport *vport, bool map);
967int idpf_send_set_sriov_vfs_msg(struct idpf_adapter *adapter, u16 num_vfs);
968int idpf_sriov_configure(struct pci_dev *pdev, int num_vfs);
969
970u8 idpf_vport_get_hsplit(const struct idpf_vport *vport);
971bool idpf_vport_set_hsplit(const struct idpf_vport *vport, u8 val);
972
973#endif /* !_IDPF_H_ */