net: intel: Cleanup the copyright/license headers
[sfrench/cifs-2.6.git] / drivers / net / ethernet / intel / i40evf / i40evf_client.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright(c) 2013 - 2018 Intel Corporation. */
3
4 #ifndef _I40E_CLIENT_H_
5 #define _I40E_CLIENT_H_
6
7 #define I40EVF_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 I40EVF_CLIENT_VERSION_MAJOR 0
13 #define I40EVF_CLIENT_VERSION_MINOR 01
14 #define I40EVF_CLIENT_VERSION_BUILD 00
15 #define I40EVF_CLIENT_VERSION_STR     \
16         __stringify(I40EVF_CLIENT_VERSION_MAJOR) "." \
17         __stringify(I40EVF_CLIENT_VERSION_MINOR) "." \
18         __stringify(I40EVF_CLIENT_VERSION_BUILD)
19
20 struct i40e_client_version {
21         u8 major;
22         u8 minor;
23         u8 build;
24         u8 rsvd;
25 };
26
27 enum i40e_client_state {
28         __I40E_CLIENT_NULL,
29         __I40E_CLIENT_REGISTERED
30 };
31
32 enum i40e_client_instance_state {
33         __I40E_CLIENT_INSTANCE_NONE,
34         __I40E_CLIENT_INSTANCE_OPENED,
35 };
36
37 struct i40e_ops;
38 struct i40e_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 I40E_QUEUE_TYPE_PE_AEQ  0x80
45 #define I40E_QUEUE_INVALID_IDX  0xFFFF
46
47 struct i40e_qv_info {
48         u32 v_idx; /* msix_vector */
49         u16 ceq_idx;
50         u16 aeq_idx;
51         u8 itr_idx;
52 };
53
54 struct i40e_qvlist_info {
55         u32 num_vectors;
56         struct i40e_qv_info qv_info[1];
57 };
58
59 #define I40E_CLIENT_MSIX_ALL 0xFFFFFFFF
60
61 /* set of LAN parameters useful for clients managed by LAN */
62
63 /* Struct to hold per priority info */
64 struct i40e_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 I40E_CLIENT_MAX_USER_PRIORITY        8
71 /* Struct to hold Client QoS */
72 struct i40e_qos_params {
73         struct i40e_prio_qos_params prio_qos[I40E_CLIENT_MAX_USER_PRIORITY];
74 };
75
76 struct i40e_params {
77         struct i40e_qos_params qos;
78         u16 mtu;
79         u16 link_up; /* boolean */
80 };
81
82 /* Structure to hold LAN device info for a client device */
83 struct i40e_info {
84         struct i40e_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 I40E_CLIENT_FTYPE_PF 0
91 #define I40E_CLIENT_FTYPE_VF 1
92         u8 ftype; /* function type, PF or VF */
93         void *vf; /* cast to i40evf_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 i40e_params params;
99         struct i40e_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
107 struct i40e_ops {
108         /* setup_q_vector_list enables queues with a particular vector */
109         int (*setup_qvlist)(struct i40e_info *ldev, struct i40e_client *client,
110                             struct i40e_qvlist_info *qv_info);
111
112         u32 (*virtchnl_send)(struct i40e_info *ldev, struct i40e_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 i40e_info *ldev,
117                               struct i40e_client *client);
118 };
119
120 struct i40e_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 i40e_info *ldev, struct i40e_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 i40e_info *ldev, struct i40e_client *client,
131                       bool reset);
132
133         /* called when some l2 managed parameters changes - mss */
134         void (*l2_param_change)(struct i40e_info *ldev,
135                                 struct i40e_client *client,
136                                 struct i40e_params *params);
137
138         /* called when a message is received from the PF */
139         int (*virtchnl_receive)(struct i40e_info *ldev,
140                                 struct i40e_client *client,
141                                 u8 *msg, u16 len);
142 };
143
144 /* Client device */
145 struct i40e_client_instance {
146         struct list_head list;
147         struct i40e_info lan_info;
148         struct i40e_client *client;
149         unsigned long  state;
150 };
151
152 struct i40e_client {
153         struct list_head list;          /* list of registered clients */
154         char name[I40EVF_CLIENT_STR_LENGTH];
155         struct i40e_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 I40E_CLIENT_FLAGS_LAUNCH_ON_PROBE       BIT(0)
160 #define I40E_TX_FLAGS_NOTIFY_OTHER_EVENTS       BIT(2)
161         u8 type;
162 #define I40E_CLIENT_IWARP 0
163         struct i40e_client_ops *ops;    /* client ops provided by the client */
164 };
165
166 /* used by clients */
167 int i40evf_register_client(struct i40e_client *client);
168 int i40evf_unregister_client(struct i40e_client *client);
169 #endif /* _I40E_CLIENT_H_ */