brintos

brintos / linux-shallow public Read only

0
0
Text · 25.2 KiB · 66544fa Raw
839 lines · c
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		0xffff28 29/* Default Mailbox settings */30#define IDPF_NUM_FILTERS_PER_MSG	2031#define IDPF_NUM_DFLT_MBX_Q		2	/* includes both TX and RX */32#define IDPF_DFLT_MBX_Q_LEN		6433#define IDPF_DFLT_MBX_ID		-134/* maximum number of times to try before resetting mailbox */35#define IDPF_MB_MAX_ERR			2036#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			50040 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  545 46#define IDPF_VIRTCHNL_VERSION_MAJOR VIRTCHNL2_VERSION_MAJOR_247#define IDPF_VIRTCHNL_VERSION_MINOR VIRTCHNL2_VERSION_MINOR_048 49/**50 * struct idpf_mac_filter51 * @list: list member field52 * @macaddr: MAC address53 * @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 up65 * @__IDPF_VER_CHECK: Negotiate virtchnl version66 * @__IDPF_GET_CAPS: Negotiate capabilities67 * @__IDPF_INIT_SW: Init based on given capabilities68 * @__IDPF_STATE_LAST: Must be last, used to determine size69 */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 timeout80 * @IDPF_HR_DRV_LOAD: Set on driver load for a clean HW81 * @IDPF_HR_RESET_IN_PROG: Reset in progress82 * @IDPF_REMOVE_IN_PROG: Driver remove in progress83 * @IDPF_MB_INTR_MODE: Mailbox in interrupt mode84 * @IDPF_VC_CORE_INIT: virtchnl core has been init85 * @IDPF_FLAGS_NBITS: Must be last86 */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 caps99 * @IDPF_BASE_CAPS: generic base capabilities100 * @IDPF_CSUM_CAPS: checksum offload capabilities101 * @IDPF_SEG_CAPS: segmentation offload capabilities102 * @IDPF_RSS_CAPS: RSS offload capabilities103 * @IDPF_HSPLIT_CAPS: Header split capabilities104 * @IDPF_RSC_CAPS: RSC offload capabilities105 * @IDPF_OTHER_CAPS: miscellaneous offloads106 *107 * Used when checking for a specific capability flag since different capability108 * sets are not mutually exclusive numerically, the caller must specify which109 * 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 state129 * @__IDPF_VPORT_DOWN: Vport is down130 * @__IDPF_VPORT_UP: Vport is up131 * @__IDPF_VPORT_STATE_LAST: Must be last, number of states132 */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 pointer141 * @adapter: Adapter back pointer142 * @vport: Vport back pointer143 * @vport_id: Vport identifier144 * @link_speed_mbps: Link speed in mbps145 * @vport_idx: Relative vport index146 * @state: See enum idpf_vport_state147 * @netstats: Packet and byte stats148 * @stats_lock: Lock to protect stats update149 */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/masks163 * @rstat: Reset status register164 * @rstat_m: Reset status mask165 */166struct idpf_reset_reg {167	void __iomem *rstat;168	u32 rstat_m;169};170 171/**172 * struct idpf_vport_max_q - Queue limits173 * @max_rxq: Maximum number of RX queues supported174 * @max_txq: Maixmum number of TX queues supported175 * @max_bufq: In splitq, maximum number of buffer queues supported176 * @max_complq: In splitq, maximum number of completion queues supported177 */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 pointers187 * @ctlq_reg_init: Mailbox control queue register initialization188 * @intr_reg_init: Traffic interrupt register initialization189 * @mb_intr_reg_init: Mailbox interrupt register initialization190 * @reset_reg_init: Reset register initialization191 * @trigger_reset: Trigger a reset to occur192 */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 operations204 * @reg_ops: Register operations205 */206struct idpf_dev_ops {207	struct idpf_reg_ops reg_ops;208};209 210/**211 * enum idpf_vport_reset_cause - Vport soft reset causes212 * @IDPF_SR_Q_CHANGE: Soft reset queue change213 * @IDPF_SR_Q_DESC_CHANGE: Soft reset descriptor change214 * @IDPF_SR_MTU_CHANGE: Soft reset MTU change215 * @IDPF_SR_RSC_CHANGE: Soft reset RSC change216 */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 flags226 * @IDPF_VPORT_DEL_QUEUES: To send delete queues message227 * @IDPF_VPORT_SW_MARKER: Indicate TX pipe drain software marker packets228 *			  processing is done229 * @IDPF_VPORT_FLAGS_NBITS: Must be last230 */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 resources252 * @num_txq: Number of allocated TX queues253 * @num_complq: Number of allocated completion queues254 * @txq_desc_count: TX queue descriptor count255 * @complq_desc_count: Completion queue descriptor count256 * @compln_clean_budget: Work budget for completion clean257 * @num_txq_grp: Number of TX queue groups258 * @txq_grps: Array of TX queue groups259 * @txq_model: Split queue or single queue queuing model260 * @txqs: Used only in hotpath to get to the right queue very fast261 * @crc_enable: Enable CRC insertion offload262 * @num_rxq: Number of allocated RX queues263 * @num_bufq: Number of allocated buffer queues264 * @rxq_desc_count: RX queue descriptor count. *MUST* have enough descriptors265 *		    to complete all buffer descriptors for all buffer queues in266 *		    the worst case.267 * @num_bufqs_per_qgrp: Buffer queues per RX queue in a given grouping268 * @bufq_desc_count: Buffer queue descriptor count269 * @num_rxq_grp: Number of RX queues in a group270 * @rxq_grps: Total number of RX groups. Number of groups * number of RX per271 *	      group will yield total number of RX queues.272 * @rxq_model: Splitq queue or single queue queuing model273 * @rx_ptype_lkup: Lookup table for ptypes on RX274 * @adapter: back pointer to associated adapter275 * @netdev: Associated net_device. Each vport should have one and only one276 *	    associated netdev.277 * @flags: See enum idpf_vport_flags278 * @vport_type: Default SRIOV, SIOV, etc.279 * @vport_id: Device given vport identifier280 * @idx: Software index in adapter vports struct281 * @default_vport: Use this vport if one isn't specified282 * @base_rxd: True if the driver should use base descriptors instead of flex283 * @num_q_vectors: Number of IRQ vectors allocated284 * @q_vectors: Array of queue vectors285 * @q_vector_idxs: Starting index of queue vectors286 * @max_mtu: device given max possible MTU287 * @default_mac_addr: device will give a default MAC to use288 * @rx_itr_profile: RX profiles for Dynamic Interrupt Moderation289 * @tx_itr_profile: TX profiles for Dynamic Interrupt Moderation290 * @port_stats: per port csum, header split, and other offload stats291 * @link_up: True if link is up292 * @sw_marker_wq: workqueue for marker packets293 */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_flags341 * @__IDPF_USER_FLAG_HSPLIT: header split state342 * @__IDPF_PROMISC_UC: Unicast promiscuous mode343 * @__IDPF_PROMISC_MC: Multicast promiscuous mode344 * @__IDPF_USER_FLAGS_NBITS: Must be last345 */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 data356 * @rss_key_size: Size of RSS hash key357 * @rss_key: RSS hash key358 * @rss_lut_size: Size of RSS lookup table359 * @rss_lut: RSS lookup table360 * @cached_lut: Used to restore previously init RSS lut361 */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 for372 *					each vport.373 * @rss_data: See struct idpf_rss_data374 * @num_req_tx_qs: Number of user requested TX queues through ethtool375 * @num_req_rx_qs: Number of user requested RX queues through ethtool376 * @num_req_txq_desc: Number of user requested TX queue descriptors through377 *		      ethtool378 * @num_req_rxq_desc: Number of user requested RX queue descriptors through379 *		      ethtool380 * @user_flags: User toggled config flags381 * @mac_filter_list: List of MAC filters382 *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 flags397 * @IDPF_VPORT_REG_NETDEV: Register netdev398 * @IDPF_VPORT_UP_REQUESTED: Set if interface up is requested on core reset399 * @IDPF_VPORT_CONFIG_FLAGS_NBITS: Must be last400 */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_info409 * @avail_rxq: Available RX queues410 * @avail_txq: Available TX queues411 * @avail_bufq: Available buffer queues412 * @avail_complq: Available completion queues413 *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 a425 *			     structure426 * @num_req_vecs: Vectors required based on the number of queues updated by the427 *		  user via ethtool428 * @num_curr_vecs: Current number of vectors, must be >= @num_req_vecs429 * @index: Relative starting index for vectors430 * @default_vport: Vectors are for default vport431 */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 vector441 *			     distribution algorithm442 * @top: Points to stack top i.e. next available vector index443 * @base: Always points to start of the free pool444 * @size: Total size of the vector stack445 * @vec_idx: Array to store all the vector indexes446 *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 'default449 * pool' and other one is called 'free pool'.  Vector distribution algorithm450 * gives priority to default vports in a way that at least IDPF_MIN_Q_VEC451 * vectors are allocated per default vport and the relative vector indexes for452 * those are maintained in default pool. Free pool contains all the unallocated453 * vector indexes which can be allocated on-demand basis. Mailbox vector index454 * 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 data465 * @user_config: see struct idpf_vport_user_config_data466 * @max_q: Maximum possible queues467 * @req_qs_chunks: Queue chunk data for requested queues468 * @mac_filter_list_lock: Lock to protect mac filters469 * @flags: See enum idpf_vport_config_flags470 */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 probe483 * @pdev: PCI device struct given on probe484 * @virt_ver_maj: Virtchnl version major485 * @virt_ver_min: Virtchnl version minor486 * @msg_enable: Debug message level enabled487 * @mb_wait_count: Number of times mailbox was attempted initialization488 * @state: Init state machine489 * @flags: See enum idpf_flags490 * @reset_reg: See struct idpf_reset_reg491 * @hw: Device access data492 * @num_req_msix: Requested number of MSIX vectors493 * @num_avail_msix: Available number of MSIX vectors494 * @num_msix_entries: Number of entries in MSIX table495 * @msix_entries: MSIX table496 * @req_vec_chunks: Requested vector chunk data497 * @mb_vector: Mailbox vector data498 * @vector_stack: Stack to store the msix vector indexes499 * @irq_mb_handler: Handler for hard interrupt for mailbox500 * @tx_timeout_count: Number of TX timeouts that have occurred501 * @avail_queues: Device given queue limits502 * @vports: Array to store vports created by the driver503 * @netdevs: Associated Vport netdevs504 * @vport_params_reqd: Vport params requested505 * @vport_params_recvd: Vport params received506 * @vport_ids: Array of device given vport identifiers507 * @vport_config: Vport config parameters508 * @max_vports: Maximum vports that can be allocated509 * @num_alloc_vports: Current number of vports allocated510 * @next_vport: Next free slot in pf->vport[] - 0-based!511 * @init_task: Initialization task512 * @init_wq: Workqueue for initialization task513 * @serv_task: Periodically recurring maintenance task514 * @serv_wq: Workqueue for service task515 * @mbx_task: Task to handle mailbox interrupts516 * @mbx_wq: Workqueue for mailbox responses517 * @vc_event_task: Task to handle out of band virtchnl event notifications518 * @vc_event_wq: Workqueue for virtchnl events519 * @stats_task: Periodic statistics retrieval task520 * @stats_wq: Workqueue for statistics task521 * @caps: Negotiated capabilities with device522 * @vcxn_mngr: Virtchnl transaction manager523 * @dev_ops: See idpf_dev_ops524 * @num_vfs: Number of allocated VFs through sysfs. PF does not directly talk525 *	     to VFs but is used to initialize them526 * @crc_enable: Enable CRC insertion offload527 * @req_tx_splitq: TX split or single queue model to request528 * @req_rx_splitq: RX split or single queue model to request529 * @vport_ctrl_lock: Lock to protect the vport control flow530 * @vector_lock: Lock to protect vector distribution531 * @queue_lock: Lock to protect queue distribution532 * @vc_buf_lock: Lock to protect virtchnl buffer533 */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 split594 * @q_model: queue model single or split595 *596 * Returns true if queue model is split else false597 */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 vectors659 * @adapter: private data struct660 */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 vports668 * @adapter: private data struct669 */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 vports677 * @adapter: private data struct678 */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 device686 * @adapter: private data struct687 */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 device695 * @adapter: private data struct696 */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 address706 * @adapter: private data struct707 * @reg_offset: register offset value708 *709 * Based on the register offset, return the actual BAR0 register address710 */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 point719 * @adapter: driver specific private structure720 *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 progress734 * @adapter: driver specific private structure735 *736 * Returns true if hard reset is in progress, false otherwise737 */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 netdev747 * @netdev: network interface device structure748 */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 netdev758 * @netdev: Network interface device structure759 */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 enabled769 * @vport: Vport to check770 * @feature: Netdev flag to check771 *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 header782 * @adapter: Driver specific private structure783 */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 lock791 * @netdev: Network interface device structure792 *793 * This lock should be used by non-datapath code to protect against vport794 * 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 lock805 * @netdev: Network interface device structure806 */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_ */839