File Index
Files and directories
Sign in
FILE

idpf_virtchnl.h

File preview with syntax highlighting.

linux-6.19.14/drivers/net/ethernet/intel/idpf/idpf_virtchnl.h C
  1/* SPDX-License-Identifier: GPL-2.0-only */
  2/* Copyright (C) 2024 Intel Corporation */
  3
  4#ifndef _IDPF_VIRTCHNL_H_
  5#define _IDPF_VIRTCHNL_H_
  6
  7#include "virtchnl2.h"
  8
  9#define IDPF_VC_XN_DEFAULT_TIMEOUT_MSEC	(60 * 1000)
 10#define IDPF_VC_XN_IDX_M		GENMASK(7, 0)
 11#define IDPF_VC_XN_SALT_M		GENMASK(15, 8)
 12#define IDPF_VC_XN_RING_LEN		U8_MAX
 13
 14/**
 15 * enum idpf_vc_xn_state - Virtchnl transaction status
 16 * @IDPF_VC_XN_IDLE: not expecting a reply, ready to be used
 17 * @IDPF_VC_XN_WAITING: expecting a reply, not yet received
 18 * @IDPF_VC_XN_COMPLETED_SUCCESS: a reply was expected and received, buffer
 19 *				  updated
 20 * @IDPF_VC_XN_COMPLETED_FAILED: a reply was expected and received, but there
 21 *				 was an error, buffer not updated
 22 * @IDPF_VC_XN_SHUTDOWN: transaction object cannot be used, VC torn down
 23 * @IDPF_VC_XN_ASYNC: transaction sent asynchronously and doesn't have the
 24 *		      return context; a callback may be provided to handle
 25 *		      return
 26 */
 27enum idpf_vc_xn_state {
 28	IDPF_VC_XN_IDLE = 1,
 29	IDPF_VC_XN_WAITING,
 30	IDPF_VC_XN_COMPLETED_SUCCESS,
 31	IDPF_VC_XN_COMPLETED_FAILED,
 32	IDPF_VC_XN_SHUTDOWN,
 33	IDPF_VC_XN_ASYNC,
 34};
 35
 36struct idpf_vc_xn;
 37/* Callback for asynchronous messages */
 38typedef int (*async_vc_cb) (struct idpf_adapter *, struct idpf_vc_xn *,
 39			    const struct idpf_ctlq_msg *);
 40
 41/**
 42 * struct idpf_vc_xn - Data structure representing virtchnl transactions
 43 * @completed: virtchnl event loop uses that to signal when a reply is
 44 *	       available, uses kernel completion API
 45 * @lock: protects the transaction state fields below
 46 * @state: virtchnl event loop stores the data below, protected by @lock
 47 * @reply_sz: Original size of reply, may be > reply_buf.iov_len; it will be
 48 *	      truncated on its way to the receiver thread according to
 49 *	      reply_buf.iov_len.
 50 * @reply: Reference to the buffer(s) where the reply data should be written
 51 *	   to. May be 0-length (then NULL address permitted) if the reply data
 52 *	   should be ignored.
 53 * @async_handler: if sent asynchronously, a callback can be provided to handle
 54 *		   the reply when it's received
 55 * @vc_op: corresponding opcode sent with this transaction
 56 * @idx: index used as retrieval on reply receive, used for cookie
 57 * @salt: changed every message to make unique, used for cookie
 58 */
 59struct idpf_vc_xn {
 60	struct completion completed;
 61	spinlock_t lock;
 62	enum idpf_vc_xn_state state;
 63	size_t reply_sz;
 64	struct kvec reply;
 65	async_vc_cb async_handler;
 66	u32 vc_op;
 67	u8 idx;
 68	u8 salt;
 69};
 70
 71/**
 72 * struct idpf_vc_xn_params - Parameters for executing transaction
 73 * @send_buf: kvec for send buffer
 74 * @recv_buf: kvec for recv buffer, may be NULL, must then have zero length
 75 * @timeout_ms: timeout to wait for reply
 76 * @async: send message asynchronously, will not wait on completion
 77 * @async_handler: If sent asynchronously, optional callback handler. The user
 78 *		   must be careful when using async handlers as the memory for
 79 *		   the recv_buf _cannot_ be on stack if this is async.
 80 * @vc_op: virtchnl op to send
 81 */
 82struct idpf_vc_xn_params {
 83	struct kvec send_buf;
 84	struct kvec recv_buf;
 85	int timeout_ms;
 86	bool async;
 87	async_vc_cb async_handler;
 88	u32 vc_op;
 89};
 90
 91struct idpf_adapter;
 92struct idpf_netdev_priv;
 93struct idpf_vec_regs;
 94struct idpf_vport;
 95struct idpf_vport_max_q;
 96struct idpf_vport_user_config_data;
 97
 98ssize_t idpf_vc_xn_exec(struct idpf_adapter *adapter,
 99			const struct idpf_vc_xn_params *params);
100int idpf_init_dflt_mbx(struct idpf_adapter *adapter);
101void idpf_deinit_dflt_mbx(struct idpf_adapter *adapter);
102int idpf_vc_core_init(struct idpf_adapter *adapter);
103void idpf_vc_core_deinit(struct idpf_adapter *adapter);
104
105int idpf_get_reg_intr_vecs(struct idpf_vport *vport,
106			   struct idpf_vec_regs *reg_vals);
107int idpf_queue_reg_init(struct idpf_vport *vport);
108int idpf_vport_queue_ids_init(struct idpf_vport *vport);
109
110bool idpf_vport_is_cap_ena(struct idpf_vport *vport, u16 flag);
111bool idpf_sideband_flow_type_ena(struct idpf_vport *vport, u32 flow_type);
112bool idpf_sideband_action_ena(struct idpf_vport *vport,
113			      struct ethtool_rx_flow_spec *fsp);
114unsigned int idpf_fsteer_max_rules(struct idpf_vport *vport);
115
116int idpf_recv_mb_msg(struct idpf_adapter *adapter);
117int idpf_send_mb_msg(struct idpf_adapter *adapter, u32 op,
118		     u16 msg_size, u8 *msg, u16 cookie);
119
120struct idpf_queue_ptr {
121	enum virtchnl2_queue_type	type;
122	union {
123		struct idpf_rx_queue		*rxq;
124		struct idpf_tx_queue		*txq;
125		struct idpf_buf_queue		*bufq;
126		struct idpf_compl_queue		*complq;
127	};
128};
129
130struct idpf_queue_set {
131	struct idpf_vport		*vport;
132
133	u32				num;
134	struct idpf_queue_ptr		qs[] __counted_by(num);
135};
136
137struct idpf_queue_set *idpf_alloc_queue_set(struct idpf_vport *vport, u32 num);
138
139int idpf_send_enable_queue_set_msg(const struct idpf_queue_set *qs);
140int idpf_send_disable_queue_set_msg(const struct idpf_queue_set *qs);
141int idpf_send_config_queue_set_msg(const struct idpf_queue_set *qs);
142
143int idpf_send_disable_queues_msg(struct idpf_vport *vport);
144int idpf_send_config_queues_msg(struct idpf_vport *vport);
145int idpf_send_enable_queues_msg(struct idpf_vport *vport);
146
147void idpf_vport_init(struct idpf_vport *vport, struct idpf_vport_max_q *max_q);
148u32 idpf_get_vport_id(struct idpf_vport *vport);
149int idpf_send_create_vport_msg(struct idpf_adapter *adapter,
150			       struct idpf_vport_max_q *max_q);
151int idpf_send_destroy_vport_msg(struct idpf_vport *vport);
152int idpf_send_enable_vport_msg(struct idpf_vport *vport);
153int idpf_send_disable_vport_msg(struct idpf_vport *vport);
154
155int idpf_vport_adjust_qs(struct idpf_vport *vport);
156int idpf_vport_alloc_max_qs(struct idpf_adapter *adapter,
157			    struct idpf_vport_max_q *max_q);
158void idpf_vport_dealloc_max_qs(struct idpf_adapter *adapter,
159			       struct idpf_vport_max_q *max_q);
160int idpf_send_add_queues_msg(const struct idpf_vport *vport, u16 num_tx_q,
161			     u16 num_complq, u16 num_rx_q, u16 num_rx_bufq);
162int idpf_send_delete_queues_msg(struct idpf_vport *vport);
163
164int idpf_vport_alloc_vec_indexes(struct idpf_vport *vport);
165int idpf_get_vec_ids(struct idpf_adapter *adapter,
166		     u16 *vecids, int num_vecids,
167		     struct virtchnl2_vector_chunks *chunks);
168int idpf_send_alloc_vectors_msg(struct idpf_adapter *adapter, u16 num_vectors);
169int idpf_send_dealloc_vectors_msg(struct idpf_adapter *adapter);
170int idpf_send_map_unmap_queue_vector_msg(struct idpf_vport *vport, bool map);
171
172int idpf_add_del_mac_filters(struct idpf_vport *vport,
173			     struct idpf_netdev_priv *np,
174			     bool add, bool async);
175int idpf_set_promiscuous(struct idpf_adapter *adapter,
176			 struct idpf_vport_user_config_data *config_data,
177			 u32 vport_id);
178int idpf_check_supported_desc_ids(struct idpf_vport *vport);
179int idpf_send_get_rx_ptype_msg(struct idpf_vport *vport);
180int idpf_send_ena_dis_loopback_msg(struct idpf_vport *vport);
181int idpf_send_get_stats_msg(struct idpf_vport *vport);
182int idpf_send_set_sriov_vfs_msg(struct idpf_adapter *adapter, u16 num_vfs);
183int idpf_send_get_set_rss_key_msg(struct idpf_vport *vport, bool get);
184int idpf_send_get_set_rss_lut_msg(struct idpf_vport *vport, bool get);
185void idpf_vc_xn_shutdown(struct idpf_vc_xn_manager *vcxn_mngr);
186int idpf_idc_rdma_vc_send_sync(struct iidc_rdma_core_dev_info *cdev_info,
187			       u8 *send_msg, u16 msg_size,
188			       u8 *recv_msg, u16 *recv_len);
189
190#endif /* _IDPF_VIRTCHNL_H_ */
~/ Read-only file preview.