Linux Audio

Check our new training course

Loading...
Note: File does not exist in v6.9.4.
  1/* SPDX-License-Identifier: GPL-2.0 */
  2/* Copyright(c) 2013 - 2018 Intel Corporation. */
  3
  4#ifndef _IAVF_CLIENT_H_
  5#define _IAVF_CLIENT_H_
  6
  7#define IAVF_CLIENT_STR_LENGTH 10
  8
  9/* Client interface version should be updated anytime there is a change in the
 10 * existing APIs or data structures.
 11 */
 12#define IAVF_CLIENT_VERSION_MAJOR 0
 13#define IAVF_CLIENT_VERSION_MINOR 01
 14#define IAVF_CLIENT_VERSION_BUILD 00
 15#define IAVF_CLIENT_VERSION_STR     \
 16	__stringify(IAVF_CLIENT_VERSION_MAJOR) "." \
 17	__stringify(IAVF_CLIENT_VERSION_MINOR) "." \
 18	__stringify(IAVF_CLIENT_VERSION_BUILD)
 19
 20struct iavf_client_version {
 21	u8 major;
 22	u8 minor;
 23	u8 build;
 24	u8 rsvd;
 25};
 26
 27enum iavf_client_state {
 28	__IAVF_CLIENT_NULL,
 29	__IAVF_CLIENT_REGISTERED
 30};
 31
 32enum iavf_client_instance_state {
 33	__IAVF_CLIENT_INSTANCE_NONE,
 34	__IAVF_CLIENT_INSTANCE_OPENED,
 35};
 36
 37struct iavf_ops;
 38struct iavf_client;
 39
 40/* HW does not define a type value for AEQ; only for RX/TX and CEQ.
 41 * In order for us to keep the interface simple, SW will define a
 42 * unique type value for AEQ.
 43 */
 44#define IAVF_QUEUE_TYPE_PE_AEQ	0x80
 45#define IAVF_QUEUE_INVALID_IDX	0xFFFF
 46
 47struct iavf_qv_info {
 48	u32 v_idx; /* msix_vector */
 49	u16 ceq_idx;
 50	u16 aeq_idx;
 51	u8 itr_idx;
 52};
 53
 54struct iavf_qvlist_info {
 55	u32 num_vectors;
 56	struct iavf_qv_info qv_info[1];
 57};
 58
 59#define IAVF_CLIENT_MSIX_ALL 0xFFFFFFFF
 60
 61/* set of LAN parameters useful for clients managed by LAN */
 62
 63/* Struct to hold per priority info */
 64struct iavf_prio_qos_params {
 65	u16 qs_handle; /* qs handle for prio */
 66	u8 tc; /* TC mapped to prio */
 67	u8 reserved;
 68};
 69
 70#define IAVF_CLIENT_MAX_USER_PRIORITY	8
 71/* Struct to hold Client QoS */
 72struct iavf_qos_params {
 73	struct iavf_prio_qos_params prio_qos[IAVF_CLIENT_MAX_USER_PRIORITY];
 74};
 75
 76struct iavf_params {
 77	struct iavf_qos_params qos;
 78	u16 mtu;
 79	u16 link_up; /* boolean */
 80};
 81
 82/* Structure to hold LAN device info for a client device */
 83struct iavf_info {
 84	struct iavf_client_version version;
 85	u8 lanmac[6];
 86	struct net_device *netdev;
 87	struct pci_dev *pcidev;
 88	u8 __iomem *hw_addr;
 89	u8 fid;	/* function id, PF id or VF id */
 90#define IAVF_CLIENT_FTYPE_PF 0
 91#define IAVF_CLIENT_FTYPE_VF 1
 92	u8 ftype; /* function type, PF or VF */
 93	void *vf; /* cast to iavf_adapter */
 94
 95	/* All L2 params that could change during the life span of the device
 96	 * and needs to be communicated to the client when they change
 97	 */
 98	struct iavf_params params;
 99	struct iavf_ops *ops;
100
101	u16 msix_count;	 /* number of msix vectors*/
102	/* Array down below will be dynamically allocated based on msix_count */
103	struct msix_entry *msix_entries;
104	u16 itr_index; /* Which ITR index the PE driver is suppose to use */
105};
106
107struct iavf_ops {
108	/* setup_q_vector_list enables queues with a particular vector */
109	int (*setup_qvlist)(struct iavf_info *ldev, struct iavf_client *client,
110			    struct iavf_qvlist_info *qv_info);
111
112	u32 (*virtchnl_send)(struct iavf_info *ldev, struct iavf_client *client,
113			     u8 *msg, u16 len);
114
115	/* If the PE Engine is unresponsive, RDMA driver can request a reset.*/
116	void (*request_reset)(struct iavf_info *ldev,
117			      struct iavf_client *client);
118};
119
120struct iavf_client_ops {
121	/* Should be called from register_client() or whenever the driver is
122	 * ready to create a specific client instance.
123	 */
124	int (*open)(struct iavf_info *ldev, struct iavf_client *client);
125
126	/* Should be closed when netdev is unavailable or when unregister
127	 * call comes in. If the close happens due to a reset, set the reset
128	 * bit to true.
129	 */
130	void (*close)(struct iavf_info *ldev, struct iavf_client *client,
131		      bool reset);
132
133	/* called when some l2 managed parameters changes - mss */
134	void (*l2_param_change)(struct iavf_info *ldev,
135				struct iavf_client *client,
136				struct iavf_params *params);
137
138	/* called when a message is received from the PF */
139	int (*virtchnl_receive)(struct iavf_info *ldev,
140				struct iavf_client *client,
141				u8 *msg, u16 len);
142};
143
144/* Client device */
145struct iavf_client_instance {
146	struct list_head list;
147	struct iavf_info lan_info;
148	struct iavf_client *client;
149	unsigned long  state;
150};
151
152struct iavf_client {
153	struct list_head list;		/* list of registered clients */
154	char name[IAVF_CLIENT_STR_LENGTH];
155	struct iavf_client_version version;
156	unsigned long state;		/* client state */
157	atomic_t ref_cnt;  /* Count of all the client devices of this kind */
158	u32 flags;
159#define IAVF_CLIENT_FLAGS_LAUNCH_ON_PROBE	BIT(0)
160#define IAVF_TX_FLAGS_NOTIFY_OTHER_EVENTS	BIT(2)
161	u8 type;
162#define IAVF_CLIENT_IWARP 0
163	struct iavf_client_ops *ops;	/* client ops provided by the client */
164};
165
166/* used by clients */
167int iavf_register_client(struct iavf_client *client);
168int iavf_unregister_client(struct iavf_client *client);
169#endif /* _IAVF_CLIENT_H_ */