blob: cd2d379df5c5496b689811e8b3fb18e3fdb1a40b [file] [log] [blame]
Sunil Goutham4863dea2015-05-26 19:20:15 -07001/*
2 * Copyright (C) 2015 Cavium, Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License
6 * as published by the Free Software Foundation.
7 */
8
9#ifndef NIC_H
10#define NIC_H
11
12#include <linux/netdevice.h>
13#include <linux/interrupt.h>
Robert Richterd768b672015-06-02 11:00:18 -070014#include <linux/pci.h>
Sunil Goutham4863dea2015-05-26 19:20:15 -070015#include "thunder_bgx.h"
16
17/* PCI device IDs */
18#define PCI_DEVICE_ID_THUNDER_NIC_PF 0xA01E
19#define PCI_DEVICE_ID_THUNDER_PASS1_NIC_VF 0x0011
20#define PCI_DEVICE_ID_THUNDER_NIC_VF 0xA034
21#define PCI_DEVICE_ID_THUNDER_BGX 0xA026
22
Sunil Gouthama5c3d492016-08-12 16:51:24 +053023/* Subsystem device IDs */
Sunil Gouthamf7ff0ae2016-08-12 16:51:25 +053024#define PCI_SUBSYS_DEVID_88XX_NIC_PF 0xA11E
25#define PCI_SUBSYS_DEVID_81XX_NIC_PF 0xA21E
26#define PCI_SUBSYS_DEVID_83XX_NIC_PF 0xA31E
27
28#define PCI_SUBSYS_DEVID_88XX_PASS1_NIC_VF 0xA11E
29#define PCI_SUBSYS_DEVID_88XX_NIC_VF 0xA134
30#define PCI_SUBSYS_DEVID_81XX_NIC_VF 0xA234
31#define PCI_SUBSYS_DEVID_83XX_NIC_VF 0xA334
32
Sunil Gouthama5c3d492016-08-12 16:51:24 +053033
Sunil Goutham4863dea2015-05-26 19:20:15 -070034/* PCI BAR nos */
35#define PCI_CFG_REG_BAR_NUM 0
36#define PCI_MSIX_REG_BAR_NUM 4
37
38/* NIC SRIOV VF count */
39#define MAX_NUM_VFS_SUPPORTED 128
40#define DEFAULT_NUM_VF_ENABLED 8
41
42#define NIC_TNS_BYPASS_MODE 0
43#define NIC_TNS_MODE 1
44
45/* NIC priv flags */
46#define NIC_SRIOV_ENABLED BIT(0)
47
48/* Min/Max packet size */
49#define NIC_HW_MIN_FRS 64
Sunil Goutham712c3182016-11-15 17:37:36 +053050#define NIC_HW_MAX_FRS 9190 /* Excluding L2 header and FCS */
Sunil Goutham4863dea2015-05-26 19:20:15 -070051
52/* Max pkinds */
53#define NIC_MAX_PKIND 16
54
Sunil Gouthama5c3d492016-08-12 16:51:24 +053055/* Max when CPI_ALG is IP diffserv */
56#define NIC_MAX_CPI_PER_LMAC 64
Sunil Goutham4863dea2015-05-26 19:20:15 -070057
58/* NIC VF Interrupts */
59#define NICVF_INTR_CQ 0
60#define NICVF_INTR_SQ 1
61#define NICVF_INTR_RBDR 2
62#define NICVF_INTR_PKT_DROP 3
63#define NICVF_INTR_TCP_TIMER 4
64#define NICVF_INTR_MBOX 5
65#define NICVF_INTR_QS_ERR 6
66
67#define NICVF_INTR_CQ_SHIFT 0
68#define NICVF_INTR_SQ_SHIFT 8
69#define NICVF_INTR_RBDR_SHIFT 16
70#define NICVF_INTR_PKT_DROP_SHIFT 20
71#define NICVF_INTR_TCP_TIMER_SHIFT 21
72#define NICVF_INTR_MBOX_SHIFT 22
73#define NICVF_INTR_QS_ERR_SHIFT 23
74
75#define NICVF_INTR_CQ_MASK (0xFF << NICVF_INTR_CQ_SHIFT)
76#define NICVF_INTR_SQ_MASK (0xFF << NICVF_INTR_SQ_SHIFT)
77#define NICVF_INTR_RBDR_MASK (0x03 << NICVF_INTR_RBDR_SHIFT)
78#define NICVF_INTR_PKT_DROP_MASK BIT(NICVF_INTR_PKT_DROP_SHIFT)
79#define NICVF_INTR_TCP_TIMER_MASK BIT(NICVF_INTR_TCP_TIMER_SHIFT)
80#define NICVF_INTR_MBOX_MASK BIT(NICVF_INTR_MBOX_SHIFT)
81#define NICVF_INTR_QS_ERR_MASK BIT(NICVF_INTR_QS_ERR_SHIFT)
82
83/* MSI-X interrupts */
84#define NIC_PF_MSIX_VECTORS 10
85#define NIC_VF_MSIX_VECTORS 20
86
87#define NIC_PF_INTR_ID_ECC0_SBE 0
88#define NIC_PF_INTR_ID_ECC0_DBE 1
89#define NIC_PF_INTR_ID_ECC1_SBE 2
90#define NIC_PF_INTR_ID_ECC1_DBE 3
91#define NIC_PF_INTR_ID_ECC2_SBE 4
92#define NIC_PF_INTR_ID_ECC2_DBE 5
93#define NIC_PF_INTR_ID_ECC3_SBE 6
94#define NIC_PF_INTR_ID_ECC3_DBE 7
95#define NIC_PF_INTR_ID_MBOX0 8
96#define NIC_PF_INTR_ID_MBOX1 9
97
Sunil Goutham4c0b6eaf2016-02-24 16:40:50 +053098/* Minimum FIFO level before all packets for the CQ are dropped
99 *
100 * This value ensures that once a packet has been "accepted"
101 * for reception it will not get dropped due to non-availability
102 * of CQ descriptor. An errata in HW mandates this value to be
103 * atleast 0x100.
104 */
105#define NICPF_CQM_MIN_DROP_LEVEL 0x100
106
Sunil Goutham4863dea2015-05-26 19:20:15 -0700107/* Global timer for CQ timer thresh interrupts
108 * Calculated for SCLK of 700Mhz
109 * value written should be a 1/16th of what is expected
110 *
Sunil Goutham006394a2015-12-02 15:36:15 +0530111 * 1 tick per 0.025usec
Sunil Goutham4863dea2015-05-26 19:20:15 -0700112 */
Sunil Goutham006394a2015-12-02 15:36:15 +0530113#define NICPF_CLK_PER_INT_TICK 1
Sunil Goutham4863dea2015-05-26 19:20:15 -0700114
Sunil Goutham3d7a8aa2015-07-29 16:49:43 +0300115/* Time to wait before we decide that a SQ is stuck.
116 *
117 * Since both pkt rx and tx notifications are done with same CQ,
118 * when packets are being received at very high rate (eg: L2 forwarding)
119 * then freeing transmitted skbs will be delayed and watchdog
120 * will kick in, resetting interface. Hence keeping this value high.
121 */
122#define NICVF_TX_TIMEOUT (50 * HZ)
123
Sunil Goutham4863dea2015-05-26 19:20:15 -0700124struct nicvf_cq_poll {
Sunil Goutham39ad6ee2015-08-30 12:29:14 +0300125 struct nicvf *nicvf;
Sunil Goutham4863dea2015-05-26 19:20:15 -0700126 u8 cq_idx; /* Completion queue index */
127 struct napi_struct napi;
128};
129
Sunil Goutham4863dea2015-05-26 19:20:15 -0700130#define NIC_MAX_RSS_HASH_BITS 8
131#define NIC_MAX_RSS_IDR_TBL_SIZE (1 << NIC_MAX_RSS_HASH_BITS)
132#define RSS_HASH_KEY_SIZE 5 /* 320 bit key */
133
134struct nicvf_rss_info {
135 bool enable;
136#define RSS_L2_EXTENDED_HASH_ENA BIT(0)
137#define RSS_IP_HASH_ENA BIT(1)
138#define RSS_TCP_HASH_ENA BIT(2)
139#define RSS_TCP_SYN_DIS BIT(3)
140#define RSS_UDP_HASH_ENA BIT(4)
141#define RSS_L4_EXTENDED_HASH_ENA BIT(5)
142#define RSS_ROCE_ENA BIT(6)
143#define RSS_L3_BI_DIRECTION_ENA BIT(7)
144#define RSS_L4_BI_DIRECTION_ENA BIT(8)
145 u64 cfg;
146 u8 hash_bits;
147 u16 rss_size;
148 u8 ind_tbl[NIC_MAX_RSS_IDR_TBL_SIZE];
149 u64 key[RSS_HASH_KEY_SIZE];
150} ____cacheline_aligned_in_smp;
151
152enum rx_stats_reg_offset {
153 RX_OCTS = 0x0,
154 RX_UCAST = 0x1,
155 RX_BCAST = 0x2,
156 RX_MCAST = 0x3,
157 RX_RED = 0x4,
158 RX_RED_OCTS = 0x5,
159 RX_ORUN = 0x6,
160 RX_ORUN_OCTS = 0x7,
161 RX_FCS = 0x8,
162 RX_L2ERR = 0x9,
163 RX_DRP_BCAST = 0xa,
164 RX_DRP_MCAST = 0xb,
165 RX_DRP_L3BCAST = 0xc,
166 RX_DRP_L3MCAST = 0xd,
167 RX_STATS_ENUM_LAST,
168};
169
170enum tx_stats_reg_offset {
171 TX_OCTS = 0x0,
172 TX_UCAST = 0x1,
173 TX_BCAST = 0x2,
174 TX_MCAST = 0x3,
175 TX_DROP = 0x4,
176 TX_STATS_ENUM_LAST,
177};
178
179struct nicvf_hw_stats {
Sunil Gouthama2dc5de2015-08-30 12:29:10 +0300180 u64 rx_bytes;
181 u64 rx_ucast_frames;
182 u64 rx_bcast_frames;
183 u64 rx_mcast_frames;
Sunil Goutham4863dea2015-05-26 19:20:15 -0700184 u64 rx_fcs_errors;
185 u64 rx_l2_errors;
186 u64 rx_drop_red;
187 u64 rx_drop_red_bytes;
188 u64 rx_drop_overrun;
189 u64 rx_drop_overrun_bytes;
190 u64 rx_drop_bcast;
191 u64 rx_drop_mcast;
192 u64 rx_drop_l3_bcast;
193 u64 rx_drop_l3_mcast;
Sunil Gouthama2dc5de2015-08-30 12:29:10 +0300194 u64 rx_bgx_truncated_pkts;
195 u64 rx_jabber_errs;
196 u64 rx_fcs_errs;
197 u64 rx_bgx_errs;
198 u64 rx_prel2_errs;
199 u64 rx_l2_hdr_malformed;
200 u64 rx_oversize;
201 u64 rx_undersize;
202 u64 rx_l2_len_mismatch;
203 u64 rx_l2_pclp;
204 u64 rx_ip_ver_errs;
205 u64 rx_ip_csum_errs;
206 u64 rx_ip_hdr_malformed;
207 u64 rx_ip_payload_malformed;
208 u64 rx_ip_ttl_errs;
209 u64 rx_l3_pclp;
210 u64 rx_l4_malformed;
211 u64 rx_l4_csum_errs;
212 u64 rx_udp_len_errs;
213 u64 rx_l4_port_errs;
214 u64 rx_tcp_flag_errs;
215 u64 rx_tcp_offset_errs;
216 u64 rx_l4_pclp;
217 u64 rx_truncated_pkts;
218
Sunil Goutham4863dea2015-05-26 19:20:15 -0700219 u64 tx_bytes_ok;
220 u64 tx_ucast_frames_ok;
221 u64 tx_bcast_frames_ok;
222 u64 tx_mcast_frames_ok;
223 u64 tx_drops;
224};
225
226struct nicvf_drv_stats {
227 /* Rx */
228 u64 rx_frames_ok;
229 u64 rx_frames_64;
230 u64 rx_frames_127;
231 u64 rx_frames_255;
232 u64 rx_frames_511;
233 u64 rx_frames_1023;
234 u64 rx_frames_1518;
235 u64 rx_frames_jumbo;
236 u64 rx_drops;
Sunil Gouthama2dc5de2015-08-30 12:29:10 +0300237
Thanneeru Srinivasulua05d4842016-02-11 21:50:21 +0530238 u64 rcv_buffer_alloc_failures;
239
Sunil Goutham4863dea2015-05-26 19:20:15 -0700240 /* Tx */
241 u64 tx_frames_ok;
242 u64 tx_drops;
Sunil Goutham4863dea2015-05-26 19:20:15 -0700243 u64 tx_tso;
Thanneeru Srinivasulua05d4842016-02-11 21:50:21 +0530244 u64 tx_timeout;
Sunil Goutham74840b82015-07-29 16:49:42 +0300245 u64 txq_stop;
246 u64 txq_wake;
Sunil Goutham4863dea2015-05-26 19:20:15 -0700247};
248
249struct nicvf {
Sunil Goutham92dc8762015-08-30 12:29:15 +0300250 struct nicvf *pnicvf;
Sunil Goutham4863dea2015-05-26 19:20:15 -0700251 struct net_device *netdev;
252 struct pci_dev *pdev;
Sunil Goutham4863dea2015-05-26 19:20:15 -0700253 void __iomem *reg_base;
Sunil Gouthama5c3d492016-08-12 16:51:24 +0530254#define MAX_QUEUES_PER_QSET 8
Sunil Goutham1d368792016-03-14 16:36:15 +0530255 struct queue_set *qs;
256 struct nicvf_cq_poll *napi[8];
257 u8 vf_id;
258 u8 sqs_id;
259 bool sqs_mode;
260 bool hw_tso;
Sunil Goutham7ceb8a12016-08-30 11:36:27 +0530261 bool t88;
Sunil Goutham1d368792016-03-14 16:36:15 +0530262
263 /* Receive buffer alloc */
Sunil Goutham4863dea2015-05-26 19:20:15 -0700264 u32 rb_page_offset;
Sunil Goutham5c2e26f2016-03-14 16:36:14 +0530265 u16 rb_pageref;
Sunil Goutham4863dea2015-05-26 19:20:15 -0700266 bool rb_alloc_fail;
267 bool rb_work_scheduled;
Sunil Goutham1d368792016-03-14 16:36:15 +0530268 struct page *rb_page;
Sunil Goutham4863dea2015-05-26 19:20:15 -0700269 struct delayed_work rbdr_work;
270 struct tasklet_struct rbdr_task;
Sunil Goutham1d368792016-03-14 16:36:15 +0530271
272 /* Secondary Qset */
273 u8 sqs_count;
274#define MAX_SQS_PER_VF_SINGLE_NODE 5
275#define MAX_SQS_PER_VF 11
276 struct nicvf *snicvf[MAX_SQS_PER_VF];
277
278 /* Queue count */
279 u8 rx_queues;
280 u8 tx_queues;
281 u8 max_queues;
282
283 u8 node;
Sunil Goutham4863dea2015-05-26 19:20:15 -0700284 u8 cpi_alg;
Sunil Goutham1d368792016-03-14 16:36:15 +0530285 bool link_up;
286 u8 duplex;
287 u32 speed;
288 bool tns_mode;
289 bool loopback_supported;
290 struct nicvf_rss_info rss_info;
291 struct tasklet_struct qs_err_task;
292 struct work_struct reset_task;
293
Sunil Goutham4863dea2015-05-26 19:20:15 -0700294 /* Interrupt coalescing settings */
295 u32 cq_coalesce_usecs;
Sunil Goutham4863dea2015-05-26 19:20:15 -0700296 u32 msg_enable;
Sunil Goutham1d368792016-03-14 16:36:15 +0530297
298 /* Stats */
Sunil Gouthama2dc5de2015-08-30 12:29:10 +0300299 struct nicvf_hw_stats hw_stats;
Sunil Goutham4863dea2015-05-26 19:20:15 -0700300 struct nicvf_drv_stats drv_stats;
301 struct bgx_stats bgx_stats;
Sunil Goutham4863dea2015-05-26 19:20:15 -0700302
303 /* MSI-X */
304 bool msix_enabled;
305 u8 num_vec;
306 struct msix_entry msix_entries[NIC_VF_MSIX_VECTORS];
Sunil Gouthamb4e28c12016-09-23 14:42:27 +0530307 char irq_name[NIC_VF_MSIX_VECTORS][IFNAMSIZ + 15];
Sunil Goutham4863dea2015-05-26 19:20:15 -0700308 bool irq_allocated[NIC_VF_MSIX_VECTORS];
Sunil Gouthamfb4b7d92016-02-11 21:50:23 +0530309 cpumask_var_t affinity_mask[NIC_VF_MSIX_VECTORS];
Sunil Goutham4863dea2015-05-26 19:20:15 -0700310
Sunil Goutham6051cba2015-08-30 12:29:11 +0300311 /* VF <-> PF mailbox communication */
Sunil Goutham4863dea2015-05-26 19:20:15 -0700312 bool pf_acked;
313 bool pf_nacked;
Pavel Fedinbd049a92015-06-23 17:51:06 +0300314 bool set_mac_pending;
Sunil Goutham4863dea2015-05-26 19:20:15 -0700315} ____cacheline_aligned_in_smp;
316
317/* PF <--> VF Mailbox communication
318 * Eight 64bit registers are shared between PF and VF.
319 * Separate set for each VF.
320 * Writing '1' into last register mbx7 means end of message.
321 */
322
323/* PF <--> VF mailbox communication */
324#define NIC_PF_VF_MAILBOX_SIZE 2
325#define NIC_MBOX_MSG_TIMEOUT 2000 /* ms */
326
327/* Mailbox message types */
328#define NIC_MBOX_MSG_READY 0x01 /* Is PF ready to rcv msgs */
329#define NIC_MBOX_MSG_ACK 0x02 /* ACK the message received */
330#define NIC_MBOX_MSG_NACK 0x03 /* NACK the message received */
331#define NIC_MBOX_MSG_QS_CFG 0x04 /* Configure Qset */
332#define NIC_MBOX_MSG_RQ_CFG 0x05 /* Configure receive queue */
333#define NIC_MBOX_MSG_SQ_CFG 0x06 /* Configure Send queue */
334#define NIC_MBOX_MSG_RQ_DROP_CFG 0x07 /* Configure receive queue */
335#define NIC_MBOX_MSG_SET_MAC 0x08 /* Add MAC ID to DMAC filter */
336#define NIC_MBOX_MSG_SET_MAX_FRS 0x09 /* Set max frame size */
337#define NIC_MBOX_MSG_CPI_CFG 0x0A /* Config CPI, RSSI */
338#define NIC_MBOX_MSG_RSS_SIZE 0x0B /* Get RSS indir_tbl size */
339#define NIC_MBOX_MSG_RSS_CFG 0x0C /* Config RSS table */
340#define NIC_MBOX_MSG_RSS_CFG_CONT 0x0D /* RSS config continuation */
341#define NIC_MBOX_MSG_RQ_BP_CFG 0x0E /* RQ backpressure config */
342#define NIC_MBOX_MSG_RQ_SW_SYNC 0x0F /* Flush inflight pkts to RQ */
343#define NIC_MBOX_MSG_BGX_STATS 0x10 /* Get stats from BGX */
344#define NIC_MBOX_MSG_BGX_LINK_CHANGE 0x11 /* BGX:LMAC link status */
Sunil Goutham92dc8762015-08-30 12:29:15 +0300345#define NIC_MBOX_MSG_ALLOC_SQS 0x12 /* Allocate secondary Qset */
346#define NIC_MBOX_MSG_NICVF_PTR 0x13 /* Send nicvf ptr to PF */
347#define NIC_MBOX_MSG_PNICVF_PTR 0x14 /* Get primary qset nicvf ptr */
348#define NIC_MBOX_MSG_SNICVF_PTR 0x15 /* Send sqet nicvf ptr to PVF */
Sunil Gouthamd77a2382015-08-30 12:29:16 +0300349#define NIC_MBOX_MSG_LOOPBACK 0x16 /* Set interface in loopback */
Jerin Jacob3458c402016-08-12 16:51:39 +0530350#define NIC_MBOX_MSG_RESET_STAT_COUNTER 0x17 /* Reset statistics counters */
Sunil Goutham92dc8762015-08-30 12:29:15 +0300351#define NIC_MBOX_MSG_CFG_DONE 0xF0 /* VF configuration done */
352#define NIC_MBOX_MSG_SHUTDOWN 0xF1 /* VF is being shutdown */
Sunil Goutham4863dea2015-05-26 19:20:15 -0700353
354struct nic_cfg_msg {
355 u8 msg;
356 u8 vf_id;
Sunil Goutham4863dea2015-05-26 19:20:15 -0700357 u8 node_id;
Sunil Goutham92dc8762015-08-30 12:29:15 +0300358 u8 tns_mode:1;
359 u8 sqs_mode:1;
Sunil Gouthamd77a2382015-08-30 12:29:16 +0300360 u8 loopback_supported:1;
Aleksey Makarove610cb32015-06-02 11:00:21 -0700361 u8 mac_addr[ETH_ALEN];
Sunil Goutham4863dea2015-05-26 19:20:15 -0700362};
363
364/* Qset configuration */
365struct qs_cfg_msg {
366 u8 msg;
367 u8 num;
Sunil Goutham92dc8762015-08-30 12:29:15 +0300368 u8 sqs_count;
Sunil Goutham4863dea2015-05-26 19:20:15 -0700369 u64 cfg;
370};
371
372/* Receive queue configuration */
373struct rq_cfg_msg {
374 u8 msg;
375 u8 qs_num;
376 u8 rq_num;
377 u64 cfg;
378};
379
380/* Send queue configuration */
381struct sq_cfg_msg {
382 u8 msg;
383 u8 qs_num;
384 u8 sq_num;
Sunil Goutham92dc8762015-08-30 12:29:15 +0300385 bool sqs_mode;
Sunil Goutham4863dea2015-05-26 19:20:15 -0700386 u64 cfg;
387};
388
389/* Set VF's MAC address */
390struct set_mac_msg {
391 u8 msg;
392 u8 vf_id;
Aleksey Makarove610cb32015-06-02 11:00:21 -0700393 u8 mac_addr[ETH_ALEN];
Sunil Goutham4863dea2015-05-26 19:20:15 -0700394};
395
396/* Set Maximum frame size */
397struct set_frs_msg {
398 u8 msg;
399 u8 vf_id;
400 u16 max_frs;
401};
402
403/* Set CPI algorithm type */
404struct cpi_cfg_msg {
405 u8 msg;
406 u8 vf_id;
407 u8 rq_cnt;
408 u8 cpi_alg;
409};
410
411/* Get RSS table size */
412struct rss_sz_msg {
413 u8 msg;
414 u8 vf_id;
415 u16 ind_tbl_size;
416};
417
418/* Set RSS configuration */
419struct rss_cfg_msg {
420 u8 msg;
421 u8 vf_id;
422 u8 hash_bits;
423 u8 tbl_len;
424 u8 tbl_offset;
425#define RSS_IND_TBL_LEN_PER_MBX_MSG 8
426 u8 ind_tbl[RSS_IND_TBL_LEN_PER_MBX_MSG];
427};
428
429struct bgx_stats_msg {
430 u8 msg;
431 u8 vf_id;
432 u8 rx;
433 u8 idx;
434 u64 stats;
435};
436
437/* Physical interface link status */
438struct bgx_link_status {
439 u8 msg;
440 u8 link_up;
441 u8 duplex;
442 u32 speed;
443};
444
Sunil Goutham92dc8762015-08-30 12:29:15 +0300445/* Get Extra Qset IDs */
446struct sqs_alloc {
447 u8 msg;
448 u8 vf_id;
449 u8 qs_count;
450};
451
452struct nicvf_ptr {
453 u8 msg;
454 u8 vf_id;
455 bool sqs_mode;
456 u8 sqs_id;
457 u64 nicvf;
458};
459
Sunil Gouthamd77a2382015-08-30 12:29:16 +0300460/* Set interface in loopback mode */
461struct set_loopback {
462 u8 msg;
463 u8 vf_id;
464 bool enable;
465};
466
Jerin Jacob3458c402016-08-12 16:51:39 +0530467/* Reset statistics counters */
468struct reset_stat_cfg {
469 u8 msg;
470 /* Bitmap to select NIC_PF_VNIC(vf_id)_RX_STAT(0..13) */
471 u16 rx_stat_mask;
472 /* Bitmap to select NIC_PF_VNIC(vf_id)_TX_STAT(0..4) */
473 u8 tx_stat_mask;
474 /* Bitmap to select NIC_PF_QS(0..127)_RQ(0..7)_STAT(0..1)
475 * bit14, bit15 NIC_PF_QS(vf_id)_RQ7_STAT(0..1)
476 * bit12, bit13 NIC_PF_QS(vf_id)_RQ6_STAT(0..1)
477 * ..
478 * bit2, bit3 NIC_PF_QS(vf_id)_RQ1_STAT(0..1)
479 * bit0, bit1 NIC_PF_QS(vf_id)_RQ0_STAT(0..1)
480 */
481 u16 rq_stat_mask;
482 /* Bitmap to select NIC_PF_QS(0..127)_SQ(0..7)_STAT(0..1)
483 * bit14, bit15 NIC_PF_QS(vf_id)_SQ7_STAT(0..1)
484 * bit12, bit13 NIC_PF_QS(vf_id)_SQ6_STAT(0..1)
485 * ..
486 * bit2, bit3 NIC_PF_QS(vf_id)_SQ1_STAT(0..1)
487 * bit0, bit1 NIC_PF_QS(vf_id)_SQ0_STAT(0..1)
488 */
489 u16 sq_stat_mask;
490};
491
Sunil Goutham4863dea2015-05-26 19:20:15 -0700492/* 128 bit shared memory between PF and each VF */
493union nic_mbx {
494 struct { u8 msg; } msg;
495 struct nic_cfg_msg nic_cfg;
496 struct qs_cfg_msg qs;
497 struct rq_cfg_msg rq;
498 struct sq_cfg_msg sq;
499 struct set_mac_msg mac;
500 struct set_frs_msg frs;
501 struct cpi_cfg_msg cpi_cfg;
502 struct rss_sz_msg rss_size;
503 struct rss_cfg_msg rss_cfg;
504 struct bgx_stats_msg bgx_stats;
505 struct bgx_link_status link_status;
Sunil Goutham92dc8762015-08-30 12:29:15 +0300506 struct sqs_alloc sqs_alloc;
507 struct nicvf_ptr nicvf;
Sunil Gouthamd77a2382015-08-30 12:29:16 +0300508 struct set_loopback lbk;
Jerin Jacob3458c402016-08-12 16:51:39 +0530509 struct reset_stat_cfg reset_stat;
Sunil Goutham4863dea2015-05-26 19:20:15 -0700510};
511
Robert Richterd768b672015-06-02 11:00:18 -0700512#define NIC_NODE_ID_MASK 0x03
513#define NIC_NODE_ID_SHIFT 44
514
515static inline int nic_get_node_id(struct pci_dev *pdev)
516{
517 u64 addr = pci_resource_start(pdev, PCI_CFG_REG_BAR_NUM);
518 return ((addr >> NIC_NODE_ID_SHIFT) & NIC_NODE_ID_MASK);
519}
520
Sunil Goutham40fb5f82015-12-10 13:25:19 +0530521static inline bool pass1_silicon(struct pci_dev *pdev)
522{
Sunil Goutham02a72bd2016-08-12 16:51:28 +0530523 return (pdev->revision < 8) &&
524 (pdev->subsystem_device == PCI_SUBSYS_DEVID_88XX_NIC_PF);
525}
526
527static inline bool pass2_silicon(struct pci_dev *pdev)
528{
529 return (pdev->revision >= 8) &&
530 (pdev->subsystem_device == PCI_SUBSYS_DEVID_88XX_NIC_PF);
Sunil Goutham40fb5f82015-12-10 13:25:19 +0530531}
532
Sunil Goutham4863dea2015-05-26 19:20:15 -0700533int nicvf_set_real_num_queues(struct net_device *netdev,
534 int tx_queues, int rx_queues);
535int nicvf_open(struct net_device *netdev);
536int nicvf_stop(struct net_device *netdev);
537int nicvf_send_msg_to_pf(struct nicvf *vf, union nic_mbx *mbx);
Sunil Goutham4863dea2015-05-26 19:20:15 -0700538void nicvf_config_rss(struct nicvf *nic);
539void nicvf_set_rss_key(struct nicvf *nic);
Sunil Goutham4863dea2015-05-26 19:20:15 -0700540void nicvf_set_ethtool_ops(struct net_device *netdev);
541void nicvf_update_stats(struct nicvf *nic);
542void nicvf_update_lmac_stats(struct nicvf *nic);
543
544#endif /* NIC_H */