diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /drivers/net/qlcnic | |
parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'drivers/net/qlcnic')
-rw-r--r-- | drivers/net/qlcnic/qlcnic.h | 649 | ||||
-rw-r--r-- | drivers/net/qlcnic/qlcnic_ctx.c | 681 | ||||
-rw-r--r-- | drivers/net/qlcnic/qlcnic_ethtool.c | 635 | ||||
-rw-r--r-- | drivers/net/qlcnic/qlcnic_hdr.h | 112 | ||||
-rw-r--r-- | drivers/net/qlcnic/qlcnic_hw.c | 743 | ||||
-rw-r--r-- | drivers/net/qlcnic/qlcnic_init.c | 522 | ||||
-rw-r--r-- | drivers/net/qlcnic/qlcnic_main.c | 1815 |
7 files changed, 3341 insertions, 1816 deletions
diff --git a/drivers/net/qlcnic/qlcnic.h b/drivers/net/qlcnic/qlcnic.h index 970389331bbc..480ef5cb6ef9 100644 --- a/drivers/net/qlcnic/qlcnic.h +++ b/drivers/net/qlcnic/qlcnic.h | |||
@@ -1,25 +1,8 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2009 - QLogic Corporation. | 2 | * QLogic qlcnic NIC Driver |
3 | * All rights reserved. | 3 | * Copyright (c) 2009-2010 QLogic Corporation |
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License | ||
7 | * as published by the Free Software Foundation; either version 2 | ||
8 | * of the License, or (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, but | ||
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, | ||
18 | * MA 02111-1307, USA. | ||
19 | * | ||
20 | * The full GNU General Public License is included in this distribution | ||
21 | * in the file called "COPYING". | ||
22 | * | 4 | * |
5 | * See LICENSE.qlcnic for copyright and licensing details. | ||
23 | */ | 6 | */ |
24 | 7 | ||
25 | #ifndef _QLCNIC_H_ | 8 | #ifndef _QLCNIC_H_ |
@@ -46,14 +29,18 @@ | |||
46 | 29 | ||
47 | #include <linux/io.h> | 30 | #include <linux/io.h> |
48 | #include <asm/byteorder.h> | 31 | #include <asm/byteorder.h> |
32 | #include <linux/bitops.h> | ||
33 | #include <linux/if_vlan.h> | ||
49 | 34 | ||
50 | #include "qlcnic_hdr.h" | 35 | #include "qlcnic_hdr.h" |
51 | 36 | ||
52 | #define _QLCNIC_LINUX_MAJOR 5 | 37 | #define _QLCNIC_LINUX_MAJOR 5 |
53 | #define _QLCNIC_LINUX_MINOR 0 | 38 | #define _QLCNIC_LINUX_MINOR 0 |
54 | #define _QLCNIC_LINUX_SUBVERSION 7 | 39 | #define _QLCNIC_LINUX_SUBVERSION 18 |
55 | #define QLCNIC_LINUX_VERSIONID "5.0.7" | 40 | #define QLCNIC_LINUX_VERSIONID "5.0.18" |
56 | #define QLCNIC_DRV_IDC_VER 0x01 | 41 | #define QLCNIC_DRV_IDC_VER 0x01 |
42 | #define QLCNIC_DRIVER_VERSION ((_QLCNIC_LINUX_MAJOR << 16) |\ | ||
43 | (_QLCNIC_LINUX_MINOR << 8) | (_QLCNIC_LINUX_SUBVERSION)) | ||
57 | 44 | ||
58 | #define QLCNIC_VERSION_CODE(a, b, c) (((a) << 24) + ((b) << 16) + (c)) | 45 | #define QLCNIC_VERSION_CODE(a, b, c) (((a) << 24) + ((b) << 16) + (c)) |
59 | #define _major(v) (((v) >> 24) & 0xff) | 46 | #define _major(v) (((v) >> 24) & 0xff) |
@@ -92,11 +79,12 @@ | |||
92 | #define FIRST_PAGE_GROUP_START 0 | 79 | #define FIRST_PAGE_GROUP_START 0 |
93 | #define FIRST_PAGE_GROUP_END 0x100000 | 80 | #define FIRST_PAGE_GROUP_END 0x100000 |
94 | 81 | ||
95 | #define P3_MAX_MTU (9600) | 82 | #define P3P_MAX_MTU (9600) |
83 | #define P3P_MIN_MTU (68) | ||
96 | #define QLCNIC_MAX_ETHERHDR 32 /* This contains some padding */ | 84 | #define QLCNIC_MAX_ETHERHDR 32 /* This contains some padding */ |
97 | 85 | ||
98 | #define QLCNIC_P3_RX_BUF_MAX_LEN (QLCNIC_MAX_ETHERHDR + ETH_DATA_LEN) | 86 | #define QLCNIC_P3P_RX_BUF_MAX_LEN (QLCNIC_MAX_ETHERHDR + ETH_DATA_LEN) |
99 | #define QLCNIC_P3_RX_JUMBO_BUF_MAX_LEN (QLCNIC_MAX_ETHERHDR + P3_MAX_MTU) | 87 | #define QLCNIC_P3P_RX_JUMBO_BUF_MAX_LEN (QLCNIC_MAX_ETHERHDR + P3P_MAX_MTU) |
100 | #define QLCNIC_CT_DEFAULT_RX_BUF_LEN 2048 | 88 | #define QLCNIC_CT_DEFAULT_RX_BUF_LEN 2048 |
101 | #define QLCNIC_LRO_BUFFER_EXTRA 2048 | 89 | #define QLCNIC_LRO_BUFFER_EXTRA 2048 |
102 | 90 | ||
@@ -107,12 +95,11 @@ | |||
107 | #define TX_IP_PKT 0x04 | 95 | #define TX_IP_PKT 0x04 |
108 | #define TX_TCP_LSO 0x05 | 96 | #define TX_TCP_LSO 0x05 |
109 | #define TX_TCP_LSO6 0x06 | 97 | #define TX_TCP_LSO6 0x06 |
110 | #define TX_IPSEC 0x07 | ||
111 | #define TX_IPSEC_CMD 0x0a | ||
112 | #define TX_TCPV6_PKT 0x0b | 98 | #define TX_TCPV6_PKT 0x0b |
113 | #define TX_UDPV6_PKT 0x0c | 99 | #define TX_UDPV6_PKT 0x0c |
114 | 100 | ||
115 | /* Tx defines */ | 101 | /* Tx defines */ |
102 | #define QLCNIC_MAX_FRAGS_PER_TX 14 | ||
116 | #define MAX_TSO_HEADER_DESC 2 | 103 | #define MAX_TSO_HEADER_DESC 2 |
117 | #define MGMT_CMD_DESC_RESV 4 | 104 | #define MGMT_CMD_DESC_RESV 4 |
118 | #define TX_STOP_THRESH ((MAX_SKB_FRAGS >> 2) + MAX_TSO_HEADER_DESC \ | 105 | #define TX_STOP_THRESH ((MAX_SKB_FRAGS >> 2) + MAX_TSO_HEADER_DESC \ |
@@ -131,7 +118,6 @@ | |||
131 | #define PHAN_PEG_RCV_INITIALIZED 0xff01 | 118 | #define PHAN_PEG_RCV_INITIALIZED 0xff01 |
132 | 119 | ||
133 | #define NUM_RCV_DESC_RINGS 3 | 120 | #define NUM_RCV_DESC_RINGS 3 |
134 | #define NUM_STS_DESC_RINGS 4 | ||
135 | 121 | ||
136 | #define RCV_RING_NORMAL 0 | 122 | #define RCV_RING_NORMAL 0 |
137 | #define RCV_RING_JUMBO 1 | 123 | #define RCV_RING_JUMBO 1 |
@@ -143,11 +129,14 @@ | |||
143 | #define MAX_CMD_DESCRIPTORS 1024 | 129 | #define MAX_CMD_DESCRIPTORS 1024 |
144 | #define MAX_RCV_DESCRIPTORS_1G 4096 | 130 | #define MAX_RCV_DESCRIPTORS_1G 4096 |
145 | #define MAX_RCV_DESCRIPTORS_10G 8192 | 131 | #define MAX_RCV_DESCRIPTORS_10G 8192 |
132 | #define MAX_RCV_DESCRIPTORS_VF 2048 | ||
146 | #define MAX_JUMBO_RCV_DESCRIPTORS_1G 512 | 133 | #define MAX_JUMBO_RCV_DESCRIPTORS_1G 512 |
147 | #define MAX_JUMBO_RCV_DESCRIPTORS_10G 1024 | 134 | #define MAX_JUMBO_RCV_DESCRIPTORS_10G 1024 |
148 | 135 | ||
149 | #define DEFAULT_RCV_DESCRIPTORS_1G 2048 | 136 | #define DEFAULT_RCV_DESCRIPTORS_1G 2048 |
150 | #define DEFAULT_RCV_DESCRIPTORS_10G 4096 | 137 | #define DEFAULT_RCV_DESCRIPTORS_10G 4096 |
138 | #define DEFAULT_RCV_DESCRIPTORS_VF 1024 | ||
139 | #define MAX_RDS_RINGS 2 | ||
151 | 140 | ||
152 | #define get_next_index(index, length) \ | 141 | #define get_next_index(index, length) \ |
153 | (((index) + 1) & ((length) - 1)) | 142 | (((index) + 1) & ((length) - 1)) |
@@ -172,7 +161,7 @@ | |||
172 | ((_desc)->port_ctxid = ((_port) & 0xf) | (((_port) << 4) & 0xf0)) | 161 | ((_desc)->port_ctxid = ((_port) & 0xf) | (((_port) << 4) & 0xf0)) |
173 | 162 | ||
174 | #define qlcnic_set_tx_flags_opcode(_desc, _flags, _opcode) \ | 163 | #define qlcnic_set_tx_flags_opcode(_desc, _flags, _opcode) \ |
175 | ((_desc)->flags_opcode = \ | 164 | ((_desc)->flags_opcode |= \ |
176 | cpu_to_le16(((_flags) & 0x7f) | (((_opcode) & 0x3f) << 7))) | 165 | cpu_to_le16(((_flags) & 0x7f) | (((_opcode) & 0x3f) << 7))) |
177 | 166 | ||
178 | #define qlcnic_set_tx_frags_len(_desc, _frags, _len) \ | 167 | #define qlcnic_set_tx_frags_len(_desc, _frags, _len) \ |
@@ -211,7 +200,7 @@ struct rcv_desc { | |||
211 | __le16 reserved; | 200 | __le16 reserved; |
212 | __le32 buffer_length; /* allocated buffer length (usually 2K) */ | 201 | __le32 buffer_length; /* allocated buffer length (usually 2K) */ |
213 | __le64 addr_buffer; | 202 | __le64 addr_buffer; |
214 | }; | 203 | } __packed; |
215 | 204 | ||
216 | /* opcode field in status_desc */ | 205 | /* opcode field in status_desc */ |
217 | #define QLCNIC_SYN_OFFLOAD 0x03 | 206 | #define QLCNIC_SYN_OFFLOAD 0x03 |
@@ -221,7 +210,8 @@ struct rcv_desc { | |||
221 | #define QLCNIC_LRO_DESC 0x12 | 210 | #define QLCNIC_LRO_DESC 0x12 |
222 | 211 | ||
223 | /* for status field in status_desc */ | 212 | /* for status field in status_desc */ |
224 | #define STATUS_CKSUM_OK (2) | 213 | #define STATUS_CKSUM_LOOP 0 |
214 | #define STATUS_CKSUM_OK 2 | ||
225 | 215 | ||
226 | /* owner bits of status_desc */ | 216 | /* owner bits of status_desc */ |
227 | #define STATUS_OWNER_HOST (0x1ULL << 56) | 217 | #define STATUS_OWNER_HOST (0x1ULL << 56) |
@@ -299,23 +289,44 @@ struct uni_data_desc{ | |||
299 | u32 reserved[5]; | 289 | u32 reserved[5]; |
300 | }; | 290 | }; |
301 | 291 | ||
292 | /* Flash Defines and Structures */ | ||
293 | #define QLCNIC_FLT_LOCATION 0x3F1000 | ||
294 | #define QLCNIC_FW_IMAGE_REGION 0x74 | ||
295 | #define QLCNIC_BOOTLD_REGION 0X72 | ||
296 | struct qlcnic_flt_header { | ||
297 | u16 version; | ||
298 | u16 len; | ||
299 | u16 checksum; | ||
300 | u16 reserved; | ||
301 | }; | ||
302 | |||
303 | struct qlcnic_flt_entry { | ||
304 | u8 region; | ||
305 | u8 reserved0; | ||
306 | u8 attrib; | ||
307 | u8 reserved1; | ||
308 | u32 size; | ||
309 | u32 start_addr; | ||
310 | u32 end_addr; | ||
311 | }; | ||
312 | |||
302 | /* Magic number to let user know flash is programmed */ | 313 | /* Magic number to let user know flash is programmed */ |
303 | #define QLCNIC_BDINFO_MAGIC 0x12345678 | 314 | #define QLCNIC_BDINFO_MAGIC 0x12345678 |
304 | 315 | ||
305 | #define QLCNIC_BRDTYPE_P3_REF_QG 0x0021 | 316 | #define QLCNIC_BRDTYPE_P3P_REF_QG 0x0021 |
306 | #define QLCNIC_BRDTYPE_P3_HMEZ 0x0022 | 317 | #define QLCNIC_BRDTYPE_P3P_HMEZ 0x0022 |
307 | #define QLCNIC_BRDTYPE_P3_10G_CX4_LP 0x0023 | 318 | #define QLCNIC_BRDTYPE_P3P_10G_CX4_LP 0x0023 |
308 | #define QLCNIC_BRDTYPE_P3_4_GB 0x0024 | 319 | #define QLCNIC_BRDTYPE_P3P_4_GB 0x0024 |
309 | #define QLCNIC_BRDTYPE_P3_IMEZ 0x0025 | 320 | #define QLCNIC_BRDTYPE_P3P_IMEZ 0x0025 |
310 | #define QLCNIC_BRDTYPE_P3_10G_SFP_PLUS 0x0026 | 321 | #define QLCNIC_BRDTYPE_P3P_10G_SFP_PLUS 0x0026 |
311 | #define QLCNIC_BRDTYPE_P3_10000_BASE_T 0x0027 | 322 | #define QLCNIC_BRDTYPE_P3P_10000_BASE_T 0x0027 |
312 | #define QLCNIC_BRDTYPE_P3_XG_LOM 0x0028 | 323 | #define QLCNIC_BRDTYPE_P3P_XG_LOM 0x0028 |
313 | #define QLCNIC_BRDTYPE_P3_4_GB_MM 0x0029 | 324 | #define QLCNIC_BRDTYPE_P3P_4_GB_MM 0x0029 |
314 | #define QLCNIC_BRDTYPE_P3_10G_SFP_CT 0x002a | 325 | #define QLCNIC_BRDTYPE_P3P_10G_SFP_CT 0x002a |
315 | #define QLCNIC_BRDTYPE_P3_10G_SFP_QT 0x002b | 326 | #define QLCNIC_BRDTYPE_P3P_10G_SFP_QT 0x002b |
316 | #define QLCNIC_BRDTYPE_P3_10G_CX4 0x0031 | 327 | #define QLCNIC_BRDTYPE_P3P_10G_CX4 0x0031 |
317 | #define QLCNIC_BRDTYPE_P3_10G_XFP 0x0032 | 328 | #define QLCNIC_BRDTYPE_P3P_10G_XFP 0x0032 |
318 | #define QLCNIC_BRDTYPE_P3_10G_TP 0x0080 | 329 | #define QLCNIC_BRDTYPE_P3P_10G_TP 0x0080 |
319 | 330 | ||
320 | #define QLCNIC_MSIX_TABLE_OFFSET 0x44 | 331 | #define QLCNIC_MSIX_TABLE_OFFSET 0x44 |
321 | 332 | ||
@@ -355,12 +366,6 @@ struct qlcnic_skb_frag { | |||
355 | u64 length; | 366 | u64 length; |
356 | }; | 367 | }; |
357 | 368 | ||
358 | struct qlcnic_recv_crb { | ||
359 | u32 crb_rcv_producer[NUM_RCV_DESC_RINGS]; | ||
360 | u32 crb_sts_consumer[NUM_STS_DESC_RINGS]; | ||
361 | u32 sw_int_mask[NUM_STS_DESC_RINGS]; | ||
362 | }; | ||
363 | |||
364 | /* Following defines are for the state of the buffers */ | 369 | /* Following defines are for the state of the buffers */ |
365 | #define QLCNIC_BUFFER_FREE 0 | 370 | #define QLCNIC_BUFFER_FREE 0 |
366 | #define QLCNIC_BUFFER_BUSY 1 | 371 | #define QLCNIC_BUFFER_BUSY 1 |
@@ -377,10 +382,10 @@ struct qlcnic_cmd_buffer { | |||
377 | 382 | ||
378 | /* In rx_buffer, we do not need multiple fragments as is a single buffer */ | 383 | /* In rx_buffer, we do not need multiple fragments as is a single buffer */ |
379 | struct qlcnic_rx_buffer { | 384 | struct qlcnic_rx_buffer { |
380 | struct list_head list; | 385 | u16 ref_handle; |
381 | struct sk_buff *skb; | 386 | struct sk_buff *skb; |
387 | struct list_head list; | ||
382 | u64 dma; | 388 | u64 dma; |
383 | u16 ref_handle; | ||
384 | }; | 389 | }; |
385 | 390 | ||
386 | /* Board types */ | 391 | /* Board types */ |
@@ -388,6 +393,48 @@ struct qlcnic_rx_buffer { | |||
388 | #define QLCNIC_XGBE 0x02 | 393 | #define QLCNIC_XGBE 0x02 |
389 | 394 | ||
390 | /* | 395 | /* |
396 | * Interrupt coalescing defaults. The defaults are for 1500 MTU. It is | ||
397 | * adjusted based on configured MTU. | ||
398 | */ | ||
399 | #define QLCNIC_DEFAULT_INTR_COALESCE_RX_TIME_US 3 | ||
400 | #define QLCNIC_DEFAULT_INTR_COALESCE_RX_PACKETS 256 | ||
401 | |||
402 | #define QLCNIC_INTR_DEFAULT 0x04 | ||
403 | #define QLCNIC_CONFIG_INTR_COALESCE 3 | ||
404 | |||
405 | struct qlcnic_nic_intr_coalesce { | ||
406 | u8 type; | ||
407 | u8 sts_ring_mask; | ||
408 | u16 rx_packets; | ||
409 | u16 rx_time_us; | ||
410 | u16 flag; | ||
411 | u32 timer_out; | ||
412 | }; | ||
413 | |||
414 | struct qlcnic_dump_template_hdr { | ||
415 | __le32 type; | ||
416 | __le32 offset; | ||
417 | __le32 size; | ||
418 | __le32 cap_mask; | ||
419 | __le32 num_entries; | ||
420 | __le32 version; | ||
421 | __le32 timestamp; | ||
422 | __le32 checksum; | ||
423 | __le32 drv_cap_mask; | ||
424 | __le32 sys_info[3]; | ||
425 | __le32 saved_state[16]; | ||
426 | __le32 cap_sizes[8]; | ||
427 | __le32 rsvd[0]; | ||
428 | }; | ||
429 | |||
430 | struct qlcnic_fw_dump { | ||
431 | u8 clr; /* flag to indicate if dump is cleared */ | ||
432 | u32 size; /* total size of the dump */ | ||
433 | void *data; /* dump data area */ | ||
434 | struct qlcnic_dump_template_hdr *tmpl_hdr; | ||
435 | }; | ||
436 | |||
437 | /* | ||
391 | * One hardware_context{} per adapter | 438 | * One hardware_context{} per adapter |
392 | * contains interrupt info as well shared hardware info. | 439 | * contains interrupt info as well shared hardware info. |
393 | */ | 440 | */ |
@@ -405,6 +452,9 @@ struct qlcnic_hardware_context { | |||
405 | u8 linkup; | 452 | u8 linkup; |
406 | u16 port_type; | 453 | u16 port_type; |
407 | u16 board_type; | 454 | u16 board_type; |
455 | |||
456 | struct qlcnic_nic_intr_coalesce coal; | ||
457 | struct qlcnic_fw_dump fw_dump; | ||
408 | }; | 458 | }; |
409 | 459 | ||
410 | struct qlcnic_adapter_stats { | 460 | struct qlcnic_adapter_stats { |
@@ -432,50 +482,49 @@ struct qlcnic_adapter_stats { | |||
432 | * be one Rcv Descriptor for normal packets, one for jumbo and may be others. | 482 | * be one Rcv Descriptor for normal packets, one for jumbo and may be others. |
433 | */ | 483 | */ |
434 | struct qlcnic_host_rds_ring { | 484 | struct qlcnic_host_rds_ring { |
435 | u32 producer; | 485 | void __iomem *crb_rcv_producer; |
486 | struct rcv_desc *desc_head; | ||
487 | struct qlcnic_rx_buffer *rx_buf_arr; | ||
436 | u32 num_desc; | 488 | u32 num_desc; |
489 | u32 producer; | ||
437 | u32 dma_size; | 490 | u32 dma_size; |
438 | u32 skb_size; | 491 | u32 skb_size; |
439 | u32 flags; | 492 | u32 flags; |
440 | void __iomem *crb_rcv_producer; | ||
441 | struct rcv_desc *desc_head; | ||
442 | struct qlcnic_rx_buffer *rx_buf_arr; | ||
443 | struct list_head free_list; | 493 | struct list_head free_list; |
444 | spinlock_t lock; | 494 | spinlock_t lock; |
445 | dma_addr_t phys_addr; | 495 | dma_addr_t phys_addr; |
446 | }; | 496 | } ____cacheline_internodealigned_in_smp; |
447 | 497 | ||
448 | struct qlcnic_host_sds_ring { | 498 | struct qlcnic_host_sds_ring { |
449 | u32 consumer; | 499 | u32 consumer; |
450 | u32 num_desc; | 500 | u32 num_desc; |
451 | void __iomem *crb_sts_consumer; | 501 | void __iomem *crb_sts_consumer; |
452 | void __iomem *crb_intr_mask; | ||
453 | 502 | ||
454 | struct status_desc *desc_head; | 503 | struct status_desc *desc_head; |
455 | struct qlcnic_adapter *adapter; | 504 | struct qlcnic_adapter *adapter; |
456 | struct napi_struct napi; | 505 | struct napi_struct napi; |
457 | struct list_head free_list[NUM_RCV_DESC_RINGS]; | 506 | struct list_head free_list[NUM_RCV_DESC_RINGS]; |
458 | 507 | ||
508 | void __iomem *crb_intr_mask; | ||
459 | int irq; | 509 | int irq; |
460 | 510 | ||
461 | dma_addr_t phys_addr; | 511 | dma_addr_t phys_addr; |
462 | char name[IFNAMSIZ+4]; | 512 | char name[IFNAMSIZ+4]; |
463 | }; | 513 | } ____cacheline_internodealigned_in_smp; |
464 | 514 | ||
465 | struct qlcnic_host_tx_ring { | 515 | struct qlcnic_host_tx_ring { |
466 | u32 producer; | 516 | u32 producer; |
467 | __le32 *hw_consumer; | ||
468 | u32 sw_consumer; | 517 | u32 sw_consumer; |
469 | void __iomem *crb_cmd_producer; | ||
470 | u32 num_desc; | 518 | u32 num_desc; |
471 | 519 | void __iomem *crb_cmd_producer; | |
472 | struct netdev_queue *txq; | ||
473 | |||
474 | struct qlcnic_cmd_buffer *cmd_buf_arr; | ||
475 | struct cmd_desc_type0 *desc_head; | 520 | struct cmd_desc_type0 *desc_head; |
521 | struct qlcnic_cmd_buffer *cmd_buf_arr; | ||
522 | __le32 *hw_consumer; | ||
523 | |||
476 | dma_addr_t phys_addr; | 524 | dma_addr_t phys_addr; |
477 | dma_addr_t hw_cons_phys_addr; | 525 | dma_addr_t hw_cons_phys_addr; |
478 | }; | 526 | struct netdev_queue *txq; |
527 | } ____cacheline_internodealigned_in_smp; | ||
479 | 528 | ||
480 | /* | 529 | /* |
481 | * Receive context. There is one such structure per instance of the | 530 | * Receive context. There is one such structure per instance of the |
@@ -484,12 +533,12 @@ struct qlcnic_host_tx_ring { | |||
484 | * present elsewhere. | 533 | * present elsewhere. |
485 | */ | 534 | */ |
486 | struct qlcnic_recv_context { | 535 | struct qlcnic_recv_context { |
536 | struct qlcnic_host_rds_ring *rds_rings; | ||
537 | struct qlcnic_host_sds_ring *sds_rings; | ||
487 | u32 state; | 538 | u32 state; |
488 | u16 context_id; | 539 | u16 context_id; |
489 | u16 virt_port; | 540 | u16 virt_port; |
490 | 541 | ||
491 | struct qlcnic_host_rds_ring *rds_rings; | ||
492 | struct qlcnic_host_sds_ring *sds_rings; | ||
493 | }; | 542 | }; |
494 | 543 | ||
495 | /* HW context creation */ | 544 | /* HW context creation */ |
@@ -528,9 +577,6 @@ struct qlcnic_recv_context { | |||
528 | #define QLCNIC_CDRP_CMD_DESTROY_RX_CTX 0x00000008 | 577 | #define QLCNIC_CDRP_CMD_DESTROY_RX_CTX 0x00000008 |
529 | #define QLCNIC_CDRP_CMD_CREATE_TX_CTX 0x00000009 | 578 | #define QLCNIC_CDRP_CMD_CREATE_TX_CTX 0x00000009 |
530 | #define QLCNIC_CDRP_CMD_DESTROY_TX_CTX 0x0000000a | 579 | #define QLCNIC_CDRP_CMD_DESTROY_TX_CTX 0x0000000a |
531 | #define QLCNIC_CDRP_CMD_SETUP_STATISTICS 0x0000000e | ||
532 | #define QLCNIC_CDRP_CMD_GET_STATISTICS 0x0000000f | ||
533 | #define QLCNIC_CDRP_CMD_DELETE_STATISTICS 0x00000010 | ||
534 | #define QLCNIC_CDRP_CMD_SET_MTU 0x00000012 | 580 | #define QLCNIC_CDRP_CMD_SET_MTU 0x00000012 |
535 | #define QLCNIC_CDRP_CMD_READ_PHY 0x00000013 | 581 | #define QLCNIC_CDRP_CMD_READ_PHY 0x00000013 |
536 | #define QLCNIC_CDRP_CMD_WRITE_PHY 0x00000014 | 582 | #define QLCNIC_CDRP_CMD_WRITE_PHY 0x00000014 |
@@ -539,24 +585,24 @@ struct qlcnic_recv_context { | |||
539 | #define QLCNIC_CDRP_CMD_SET_FLOW_CTL 0x00000017 | 585 | #define QLCNIC_CDRP_CMD_SET_FLOW_CTL 0x00000017 |
540 | #define QLCNIC_CDRP_CMD_READ_MAX_MTU 0x00000018 | 586 | #define QLCNIC_CDRP_CMD_READ_MAX_MTU 0x00000018 |
541 | #define QLCNIC_CDRP_CMD_READ_MAX_LRO 0x00000019 | 587 | #define QLCNIC_CDRP_CMD_READ_MAX_LRO 0x00000019 |
542 | #define QLCNIC_CDRP_CMD_CONFIGURE_TOE 0x0000001a | ||
543 | #define QLCNIC_CDRP_CMD_FUNC_ATTRIB 0x0000001b | ||
544 | #define QLCNIC_CDRP_CMD_READ_PEXQ_PARAMETERS 0x0000001c | ||
545 | #define QLCNIC_CDRP_CMD_GET_LIC_CAPABILITIES 0x0000001d | ||
546 | #define QLCNIC_CDRP_CMD_READ_MAX_LRO_PER_BOARD 0x0000001e | ||
547 | #define QLCNIC_CDRP_CMD_MAC_ADDRESS 0x0000001f | 588 | #define QLCNIC_CDRP_CMD_MAC_ADDRESS 0x0000001f |
548 | 589 | ||
549 | #define QLCNIC_CDRP_CMD_GET_PCI_INFO 0x00000020 | 590 | #define QLCNIC_CDRP_CMD_GET_PCI_INFO 0x00000020 |
550 | #define QLCNIC_CDRP_CMD_GET_NIC_INFO 0x00000021 | 591 | #define QLCNIC_CDRP_CMD_GET_NIC_INFO 0x00000021 |
551 | #define QLCNIC_CDRP_CMD_SET_NIC_INFO 0x00000022 | 592 | #define QLCNIC_CDRP_CMD_SET_NIC_INFO 0x00000022 |
552 | #define QLCNIC_CDRP_CMD_RESET_NPAR 0x00000023 | ||
553 | #define QLCNIC_CDRP_CMD_GET_ESWITCH_CAPABILITY 0x00000024 | 593 | #define QLCNIC_CDRP_CMD_GET_ESWITCH_CAPABILITY 0x00000024 |
554 | #define QLCNIC_CDRP_CMD_TOGGLE_ESWITCH 0x00000025 | 594 | #define QLCNIC_CDRP_CMD_TOGGLE_ESWITCH 0x00000025 |
555 | #define QLCNIC_CDRP_CMD_GET_ESWITCH_STATUS 0x00000026 | 595 | #define QLCNIC_CDRP_CMD_GET_ESWITCH_STATUS 0x00000026 |
556 | #define QLCNIC_CDRP_CMD_SET_PORTMIRRORING 0x00000027 | 596 | #define QLCNIC_CDRP_CMD_SET_PORTMIRRORING 0x00000027 |
557 | #define QLCNIC_CDRP_CMD_CONFIGURE_ESWITCH 0x00000028 | 597 | #define QLCNIC_CDRP_CMD_CONFIGURE_ESWITCH 0x00000028 |
598 | #define QLCNIC_CDRP_CMD_GET_ESWITCH_PORT_CONFIG 0x00000029 | ||
599 | #define QLCNIC_CDRP_CMD_GET_ESWITCH_STATS 0x0000002a | ||
600 | #define QLCNIC_CDRP_CMD_CONFIG_PORT 0x0000002E | ||
601 | #define QLCNIC_CDRP_CMD_TEMP_SIZE 0x0000002f | ||
602 | #define QLCNIC_CDRP_CMD_GET_TEMP_HDR 0x00000030 | ||
558 | 603 | ||
559 | #define QLCNIC_RCODE_SUCCESS 0 | 604 | #define QLCNIC_RCODE_SUCCESS 0 |
605 | #define QLCNIC_RCODE_NOT_SUPPORTED 9 | ||
560 | #define QLCNIC_RCODE_TIMEOUT 17 | 606 | #define QLCNIC_RCODE_TIMEOUT 17 |
561 | #define QLCNIC_DESTROY_CTX_RESET 0 | 607 | #define QLCNIC_DESTROY_CTX_RESET 0 |
562 | 608 | ||
@@ -585,14 +631,14 @@ struct qlcnic_hostrq_sds_ring { | |||
585 | __le32 ring_size; /* Ring entries */ | 631 | __le32 ring_size; /* Ring entries */ |
586 | __le16 msi_index; | 632 | __le16 msi_index; |
587 | __le16 rsvd; /* Padding */ | 633 | __le16 rsvd; /* Padding */ |
588 | }; | 634 | } __packed; |
589 | 635 | ||
590 | struct qlcnic_hostrq_rds_ring { | 636 | struct qlcnic_hostrq_rds_ring { |
591 | __le64 host_phys_addr; /* Ring base addr */ | 637 | __le64 host_phys_addr; /* Ring base addr */ |
592 | __le64 buff_size; /* Packet buffer size */ | 638 | __le64 buff_size; /* Packet buffer size */ |
593 | __le32 ring_size; /* Ring entries */ | 639 | __le32 ring_size; /* Ring entries */ |
594 | __le32 ring_kind; /* Class of ring */ | 640 | __le32 ring_kind; /* Class of ring */ |
595 | }; | 641 | } __packed; |
596 | 642 | ||
597 | struct qlcnic_hostrq_rx_ctx { | 643 | struct qlcnic_hostrq_rx_ctx { |
598 | __le64 host_rsp_dma_addr; /* Response dma'd here */ | 644 | __le64 host_rsp_dma_addr; /* Response dma'd here */ |
@@ -613,17 +659,17 @@ struct qlcnic_hostrq_rx_ctx { | |||
613 | - N hostrq_rds_rings | 659 | - N hostrq_rds_rings |
614 | - N hostrq_sds_rings */ | 660 | - N hostrq_sds_rings */ |
615 | char data[0]; | 661 | char data[0]; |
616 | }; | 662 | } __packed; |
617 | 663 | ||
618 | struct qlcnic_cardrsp_rds_ring{ | 664 | struct qlcnic_cardrsp_rds_ring{ |
619 | __le32 host_producer_crb; /* Crb to use */ | 665 | __le32 host_producer_crb; /* Crb to use */ |
620 | __le32 rsvd1; /* Padding */ | 666 | __le32 rsvd1; /* Padding */ |
621 | }; | 667 | } __packed; |
622 | 668 | ||
623 | struct qlcnic_cardrsp_sds_ring { | 669 | struct qlcnic_cardrsp_sds_ring { |
624 | __le32 host_consumer_crb; /* Crb to use */ | 670 | __le32 host_consumer_crb; /* Crb to use */ |
625 | __le32 interrupt_crb; /* Crb to use */ | 671 | __le32 interrupt_crb; /* Crb to use */ |
626 | }; | 672 | } __packed; |
627 | 673 | ||
628 | struct qlcnic_cardrsp_rx_ctx { | 674 | struct qlcnic_cardrsp_rx_ctx { |
629 | /* These ring offsets are relative to data[0] below */ | 675 | /* These ring offsets are relative to data[0] below */ |
@@ -642,7 +688,7 @@ struct qlcnic_cardrsp_rx_ctx { | |||
642 | - N cardrsp_rds_rings | 688 | - N cardrsp_rds_rings |
643 | - N cardrs_sds_rings */ | 689 | - N cardrs_sds_rings */ |
644 | char data[0]; | 690 | char data[0]; |
645 | }; | 691 | } __packed; |
646 | 692 | ||
647 | #define SIZEOF_HOSTRQ_RX(HOSTRQ_RX, rds_rings, sds_rings) \ | 693 | #define SIZEOF_HOSTRQ_RX(HOSTRQ_RX, rds_rings, sds_rings) \ |
648 | (sizeof(HOSTRQ_RX) + \ | 694 | (sizeof(HOSTRQ_RX) + \ |
@@ -662,7 +708,7 @@ struct qlcnic_hostrq_cds_ring { | |||
662 | __le64 host_phys_addr; /* Ring base addr */ | 708 | __le64 host_phys_addr; /* Ring base addr */ |
663 | __le32 ring_size; /* Ring entries */ | 709 | __le32 ring_size; /* Ring entries */ |
664 | __le32 rsvd; /* Padding */ | 710 | __le32 rsvd; /* Padding */ |
665 | }; | 711 | } __packed; |
666 | 712 | ||
667 | struct qlcnic_hostrq_tx_ctx { | 713 | struct qlcnic_hostrq_tx_ctx { |
668 | __le64 host_rsp_dma_addr; /* Response dma'd here */ | 714 | __le64 host_rsp_dma_addr; /* Response dma'd here */ |
@@ -677,12 +723,12 @@ struct qlcnic_hostrq_tx_ctx { | |||
677 | __le16 rsvd3; /* Padding */ | 723 | __le16 rsvd3; /* Padding */ |
678 | struct qlcnic_hostrq_cds_ring cds_ring; /* Desc of cds ring */ | 724 | struct qlcnic_hostrq_cds_ring cds_ring; /* Desc of cds ring */ |
679 | u8 reserved[128]; /* future expansion */ | 725 | u8 reserved[128]; /* future expansion */ |
680 | }; | 726 | } __packed; |
681 | 727 | ||
682 | struct qlcnic_cardrsp_cds_ring { | 728 | struct qlcnic_cardrsp_cds_ring { |
683 | __le32 host_producer_crb; /* Crb to use */ | 729 | __le32 host_producer_crb; /* Crb to use */ |
684 | __le32 interrupt_crb; /* Crb to use */ | 730 | __le32 interrupt_crb; /* Crb to use */ |
685 | }; | 731 | } __packed; |
686 | 732 | ||
687 | struct qlcnic_cardrsp_tx_ctx { | 733 | struct qlcnic_cardrsp_tx_ctx { |
688 | __le32 host_ctx_state; /* Starting state */ | 734 | __le32 host_ctx_state; /* Starting state */ |
@@ -691,7 +737,7 @@ struct qlcnic_cardrsp_tx_ctx { | |||
691 | u8 virt_port; /* Virtual/Logical id of port */ | 737 | u8 virt_port; /* Virtual/Logical id of port */ |
692 | struct qlcnic_cardrsp_cds_ring cds_ring; /* Card cds settings */ | 738 | struct qlcnic_cardrsp_cds_ring cds_ring; /* Card cds settings */ |
693 | u8 reserved[128]; /* future expansion */ | 739 | u8 reserved[128]; /* future expansion */ |
694 | }; | 740 | } __packed; |
695 | 741 | ||
696 | #define SIZEOF_HOSTRQ_TX(HOSTRQ_TX) (sizeof(HOSTRQ_TX)) | 742 | #define SIZEOF_HOSTRQ_TX(HOSTRQ_TX) (sizeof(HOSTRQ_TX)) |
697 | #define SIZEOF_CARDRSP_TX(CARDRSP_TX) (sizeof(CARDRSP_TX)) | 743 | #define SIZEOF_CARDRSP_TX(CARDRSP_TX) (sizeof(CARDRSP_TX)) |
@@ -712,51 +758,19 @@ struct qlcnic_cardrsp_tx_ctx { | |||
712 | 758 | ||
713 | /* MAC */ | 759 | /* MAC */ |
714 | 760 | ||
715 | #define MC_COUNT_P3 38 | 761 | #define MC_COUNT_P3P 38 |
716 | 762 | ||
717 | #define QLCNIC_MAC_NOOP 0 | 763 | #define QLCNIC_MAC_NOOP 0 |
718 | #define QLCNIC_MAC_ADD 1 | 764 | #define QLCNIC_MAC_ADD 1 |
719 | #define QLCNIC_MAC_DEL 2 | 765 | #define QLCNIC_MAC_DEL 2 |
766 | #define QLCNIC_MAC_VLAN_ADD 3 | ||
767 | #define QLCNIC_MAC_VLAN_DEL 4 | ||
720 | 768 | ||
721 | struct qlcnic_mac_list_s { | 769 | struct qlcnic_mac_list_s { |
722 | struct list_head list; | 770 | struct list_head list; |
723 | uint8_t mac_addr[ETH_ALEN+2]; | 771 | uint8_t mac_addr[ETH_ALEN+2]; |
724 | }; | 772 | }; |
725 | 773 | ||
726 | /* | ||
727 | * Interrupt coalescing defaults. The defaults are for 1500 MTU. It is | ||
728 | * adjusted based on configured MTU. | ||
729 | */ | ||
730 | #define QLCNIC_DEFAULT_INTR_COALESCE_RX_TIME_US 3 | ||
731 | #define QLCNIC_DEFAULT_INTR_COALESCE_RX_PACKETS 256 | ||
732 | #define QLCNIC_DEFAULT_INTR_COALESCE_TX_PACKETS 64 | ||
733 | #define QLCNIC_DEFAULT_INTR_COALESCE_TX_TIME_US 4 | ||
734 | |||
735 | #define QLCNIC_INTR_DEFAULT 0x04 | ||
736 | |||
737 | union qlcnic_nic_intr_coalesce_data { | ||
738 | struct { | ||
739 | u16 rx_packets; | ||
740 | u16 rx_time_us; | ||
741 | u16 tx_packets; | ||
742 | u16 tx_time_us; | ||
743 | } data; | ||
744 | u64 word; | ||
745 | }; | ||
746 | |||
747 | struct qlcnic_nic_intr_coalesce { | ||
748 | u16 stats_time_us; | ||
749 | u16 rate_sample_time; | ||
750 | u16 flags; | ||
751 | u16 rsvd_1; | ||
752 | u32 low_threshold; | ||
753 | u32 high_threshold; | ||
754 | union qlcnic_nic_intr_coalesce_data normal; | ||
755 | union qlcnic_nic_intr_coalesce_data low; | ||
756 | union qlcnic_nic_intr_coalesce_data high; | ||
757 | union qlcnic_nic_intr_coalesce_data irq; | ||
758 | }; | ||
759 | |||
760 | #define QLCNIC_HOST_REQUEST 0x13 | 774 | #define QLCNIC_HOST_REQUEST 0x13 |
761 | #define QLCNIC_REQUEST 0x14 | 775 | #define QLCNIC_REQUEST 0x14 |
762 | 776 | ||
@@ -768,51 +782,20 @@ struct qlcnic_nic_intr_coalesce { | |||
768 | /* | 782 | /* |
769 | * Driver --> Firmware | 783 | * Driver --> Firmware |
770 | */ | 784 | */ |
771 | #define QLCNIC_H2C_OPCODE_START 0 | 785 | #define QLCNIC_H2C_OPCODE_CONFIG_RSS 0x1 |
772 | #define QLCNIC_H2C_OPCODE_CONFIG_RSS 1 | 786 | #define QLCNIC_H2C_OPCODE_CONFIG_INTR_COALESCE 0x3 |
773 | #define QLCNIC_H2C_OPCODE_CONFIG_RSS_TBL 2 | 787 | #define QLCNIC_H2C_OPCODE_CONFIG_LED 0x4 |
774 | #define QLCNIC_H2C_OPCODE_CONFIG_INTR_COALESCE 3 | 788 | #define QLCNIC_H2C_OPCODE_LRO_REQUEST 0x7 |
775 | #define QLCNIC_H2C_OPCODE_CONFIG_LED 4 | 789 | #define QLCNIC_H2C_OPCODE_SET_MAC_RECEIVE_MODE 0xc |
776 | #define QLCNIC_H2C_OPCODE_CONFIG_PROMISCUOUS 5 | 790 | #define QLCNIC_H2C_OPCODE_CONFIG_IPADDR 0x12 |
777 | #define QLCNIC_H2C_OPCODE_CONFIG_L2_MAC 6 | 791 | #define QLCNIC_H2C_OPCODE_GET_LINKEVENT 0x15 |
778 | #define QLCNIC_H2C_OPCODE_LRO_REQUEST 7 | 792 | #define QLCNIC_H2C_OPCODE_CONFIG_BRIDGING 0x17 |
779 | #define QLCNIC_H2C_OPCODE_GET_SNMP_STATS 8 | 793 | #define QLCNIC_H2C_OPCODE_CONFIG_HW_LRO 0x18 |
780 | #define QLCNIC_H2C_OPCODE_PROXY_START_REQUEST 9 | ||
781 | #define QLCNIC_H2C_OPCODE_PROXY_STOP_REQUEST 10 | ||
782 | #define QLCNIC_H2C_OPCODE_PROXY_SET_MTU 11 | ||
783 | #define QLCNIC_H2C_OPCODE_PROXY_SET_VPORT_MISS_MODE 12 | ||
784 | #define QLCNIC_H2C_OPCODE_GET_FINGER_PRINT_REQUEST 13 | ||
785 | #define QLCNIC_H2C_OPCODE_INSTALL_LICENSE_REQUEST 14 | ||
786 | #define QLCNIC_H2C_OPCODE_GET_LICENSE_CAPABILITY_REQUEST 15 | ||
787 | #define QLCNIC_H2C_OPCODE_GET_NET_STATS 16 | ||
788 | #define QLCNIC_H2C_OPCODE_PROXY_UPDATE_P2V 17 | ||
789 | #define QLCNIC_H2C_OPCODE_CONFIG_IPADDR 18 | ||
790 | #define QLCNIC_H2C_OPCODE_CONFIG_LOOPBACK 19 | ||
791 | #define QLCNIC_H2C_OPCODE_PROXY_STOP_DONE 20 | ||
792 | #define QLCNIC_H2C_OPCODE_GET_LINKEVENT 21 | ||
793 | #define QLCNIC_C2C_OPCODE 22 | ||
794 | #define QLCNIC_H2C_OPCODE_CONFIG_BRIDGING 23 | ||
795 | #define QLCNIC_H2C_OPCODE_CONFIG_HW_LRO 24 | ||
796 | #define QLCNIC_H2C_OPCODE_LAST 25 | ||
797 | /* | 794 | /* |
798 | * Firmware --> Driver | 795 | * Firmware --> Driver |
799 | */ | 796 | */ |
800 | 797 | ||
801 | #define QLCNIC_C2H_OPCODE_START 128 | ||
802 | #define QLCNIC_C2H_OPCODE_CONFIG_RSS_RESPONSE 129 | ||
803 | #define QLCNIC_C2H_OPCODE_CONFIG_RSS_TBL_RESPONSE 130 | ||
804 | #define QLCNIC_C2H_OPCODE_CONFIG_MAC_RESPONSE 131 | ||
805 | #define QLCNIC_C2H_OPCODE_CONFIG_PROMISCUOUS_RESPONSE 132 | ||
806 | #define QLCNIC_C2H_OPCODE_CONFIG_L2_MAC_RESPONSE 133 | ||
807 | #define QLCNIC_C2H_OPCODE_LRO_DELETE_RESPONSE 134 | ||
808 | #define QLCNIC_C2H_OPCODE_LRO_ADD_FAILURE_RESPONSE 135 | ||
809 | #define QLCNIC_C2H_OPCODE_GET_SNMP_STATS 136 | ||
810 | #define QLCNIC_C2H_OPCODE_GET_FINGER_PRINT_REPLY 137 | ||
811 | #define QLCNIC_C2H_OPCODE_INSTALL_LICENSE_REPLY 138 | ||
812 | #define QLCNIC_C2H_OPCODE_GET_LICENSE_CAPABILITIES_REPLY 139 | ||
813 | #define QLCNIC_C2H_OPCODE_GET_NET_STATS_RESPONSE 140 | ||
814 | #define QLCNIC_C2H_OPCODE_GET_LINKEVENT_RESPONSE 141 | 798 | #define QLCNIC_C2H_OPCODE_GET_LINKEVENT_RESPONSE 141 |
815 | #define QLCNIC_C2H_OPCODE_LAST 142 | ||
816 | 799 | ||
817 | #define VPORT_MISS_MODE_DROP 0 /* drop all unmatched */ | 800 | #define VPORT_MISS_MODE_DROP 0 /* drop all unmatched */ |
818 | #define VPORT_MISS_MODE_ACCEPT_ALL 1 /* accept all packets */ | 801 | #define VPORT_MISS_MODE_ACCEPT_ALL 1 /* accept all packets */ |
@@ -854,7 +837,6 @@ struct qlcnic_nic_intr_coalesce { | |||
854 | #define LINKEVENT_LINKSPEED_MBPS 0 | 837 | #define LINKEVENT_LINKSPEED_MBPS 0 |
855 | #define LINKEVENT_LINKSPEED_ENCODED 1 | 838 | #define LINKEVENT_LINKSPEED_ENCODED 1 |
856 | 839 | ||
857 | #define AUTO_FW_RESET_ENABLED 0x01 | ||
858 | /* firmware response header: | 840 | /* firmware response header: |
859 | * 63:58 - message type | 841 | * 63:58 - message type |
860 | * 57:56 - owner | 842 | * 57:56 - owner |
@@ -882,7 +864,7 @@ struct qlcnic_nic_req { | |||
882 | __le64 qhdr; | 864 | __le64 qhdr; |
883 | __le64 req_hdr; | 865 | __le64 req_hdr; |
884 | __le64 words[6]; | 866 | __le64 words[6]; |
885 | }; | 867 | } __packed; |
886 | 868 | ||
887 | struct qlcnic_mac_req { | 869 | struct qlcnic_mac_req { |
888 | u8 op; | 870 | u8 op; |
@@ -890,16 +872,34 @@ struct qlcnic_mac_req { | |||
890 | u8 mac_addr[6]; | 872 | u8 mac_addr[6]; |
891 | }; | 873 | }; |
892 | 874 | ||
875 | struct qlcnic_vlan_req { | ||
876 | __le16 vlan_id; | ||
877 | __le16 rsvd[3]; | ||
878 | } __packed; | ||
879 | |||
880 | struct qlcnic_ipaddr { | ||
881 | __be32 ipv4; | ||
882 | __be32 ipv6[4]; | ||
883 | }; | ||
884 | |||
893 | #define QLCNIC_MSI_ENABLED 0x02 | 885 | #define QLCNIC_MSI_ENABLED 0x02 |
894 | #define QLCNIC_MSIX_ENABLED 0x04 | 886 | #define QLCNIC_MSIX_ENABLED 0x04 |
895 | #define QLCNIC_LRO_ENABLED 0x08 | 887 | #define QLCNIC_LRO_ENABLED 0x08 |
888 | #define QLCNIC_LRO_DISABLED 0x00 | ||
896 | #define QLCNIC_BRIDGE_ENABLED 0X10 | 889 | #define QLCNIC_BRIDGE_ENABLED 0X10 |
897 | #define QLCNIC_DIAG_ENABLED 0x20 | 890 | #define QLCNIC_DIAG_ENABLED 0x20 |
898 | #define QLCNIC_ESWITCH_ENABLED 0x40 | 891 | #define QLCNIC_ESWITCH_ENABLED 0x40 |
892 | #define QLCNIC_ADAPTER_INITIALIZED 0x80 | ||
893 | #define QLCNIC_TAGGING_ENABLED 0x100 | ||
894 | #define QLCNIC_MACSPOOF 0x200 | ||
895 | #define QLCNIC_MAC_OVERRIDE_DISABLED 0x400 | ||
896 | #define QLCNIC_PROMISC_DISABLED 0x800 | ||
897 | #define QLCNIC_NEED_FLR 0x1000 | ||
899 | #define QLCNIC_IS_MSI_FAMILY(adapter) \ | 898 | #define QLCNIC_IS_MSI_FAMILY(adapter) \ |
900 | ((adapter)->flags & (QLCNIC_MSI_ENABLED | QLCNIC_MSIX_ENABLED)) | 899 | ((adapter)->flags & (QLCNIC_MSI_ENABLED | QLCNIC_MSIX_ENABLED)) |
901 | 900 | ||
902 | #define MSIX_ENTRIES_PER_ADAPTER NUM_STS_DESC_RINGS | 901 | #define QLCNIC_DEF_NUM_STS_DESC_RINGS 4 |
902 | #define QLCNIC_MIN_NUM_RSS_RINGS 2 | ||
903 | #define QLCNIC_MSIX_TBL_SPACE 8192 | 903 | #define QLCNIC_MSIX_TBL_SPACE 8192 |
904 | #define QLCNIC_PCI_REG_MSIX_TBL 0x44 | 904 | #define QLCNIC_PCI_REG_MSIX_TBL 0x44 |
905 | #define QLCNIC_MSIX_TBL_PGSIZE 4096 | 905 | #define QLCNIC_MSIX_TBL_PGSIZE 4096 |
@@ -912,35 +912,54 @@ struct qlcnic_mac_req { | |||
912 | #define __QLCNIC_RESETTING 2 | 912 | #define __QLCNIC_RESETTING 2 |
913 | #define __QLCNIC_START_FW 4 | 913 | #define __QLCNIC_START_FW 4 |
914 | #define __QLCNIC_AER 5 | 914 | #define __QLCNIC_AER 5 |
915 | #define __QLCNIC_DIAG_RES_ALLOC 6 | ||
915 | 916 | ||
916 | #define QLCNIC_INTERRUPT_TEST 1 | 917 | #define QLCNIC_INTERRUPT_TEST 1 |
917 | #define QLCNIC_LOOPBACK_TEST 2 | 918 | #define QLCNIC_LOOPBACK_TEST 2 |
919 | #define QLCNIC_LED_TEST 3 | ||
918 | 920 | ||
919 | struct qlcnic_adapter { | 921 | #define QLCNIC_FILTER_AGE 80 |
920 | struct qlcnic_hardware_context ahw; | 922 | #define QLCNIC_READD_AGE 20 |
923 | #define QLCNIC_LB_MAX_FILTERS 64 | ||
924 | |||
925 | struct qlcnic_filter { | ||
926 | struct hlist_node fnode; | ||
927 | u8 faddr[ETH_ALEN]; | ||
928 | __le16 vlan_id; | ||
929 | unsigned long ftime; | ||
930 | }; | ||
931 | |||
932 | struct qlcnic_filter_hash { | ||
933 | struct hlist_head *fhead; | ||
934 | u8 fnum; | ||
935 | u8 fmax; | ||
936 | }; | ||
921 | 937 | ||
938 | struct qlcnic_adapter { | ||
939 | struct qlcnic_hardware_context *ahw; | ||
940 | struct qlcnic_recv_context *recv_ctx; | ||
941 | struct qlcnic_host_tx_ring *tx_ring; | ||
922 | struct net_device *netdev; | 942 | struct net_device *netdev; |
923 | struct pci_dev *pdev; | 943 | struct pci_dev *pdev; |
924 | struct list_head mac_list; | ||
925 | 944 | ||
926 | spinlock_t tx_clean_lock; | 945 | unsigned long state; |
946 | u32 flags; | ||
927 | 947 | ||
928 | u16 num_txd; | 948 | u16 num_txd; |
929 | u16 num_rxd; | 949 | u16 num_rxd; |
930 | u16 num_jumbo_rxd; | 950 | u16 num_jumbo_rxd; |
951 | u16 max_rxd; | ||
952 | u16 max_jumbo_rxd; | ||
931 | 953 | ||
932 | u8 max_rds_rings; | 954 | u8 max_rds_rings; |
933 | u8 max_sds_rings; | 955 | u8 max_sds_rings; |
934 | u8 driver_mismatch; | ||
935 | u8 msix_supported; | 956 | u8 msix_supported; |
936 | u8 rx_csum; | ||
937 | u8 portnum; | 957 | u8 portnum; |
938 | u8 physical_port; | 958 | u8 physical_port; |
939 | u8 reset_context; | 959 | u8 reset_context; |
940 | 960 | ||
941 | u8 mc_enabled; | 961 | u8 mc_enabled; |
942 | u8 max_mc_count; | 962 | u8 max_mc_count; |
943 | u8 rss_supported; | ||
944 | u8 fw_wait_cnt; | 963 | u8 fw_wait_cnt; |
945 | u8 fw_fail_cnt; | 964 | u8 fw_fail_cnt; |
946 | u8 tx_timeo_cnt; | 965 | u8 tx_timeo_cnt; |
@@ -961,15 +980,15 @@ struct qlcnic_adapter { | |||
961 | u16 max_tx_ques; | 980 | u16 max_tx_ques; |
962 | u16 max_rx_ques; | 981 | u16 max_rx_ques; |
963 | u16 max_mtu; | 982 | u16 max_mtu; |
983 | u16 pvid; | ||
964 | 984 | ||
965 | u32 fw_hal_version; | 985 | u32 fw_hal_version; |
966 | u32 capabilities; | 986 | u32 capabilities; |
967 | u32 flags; | ||
968 | u32 irq; | 987 | u32 irq; |
969 | u32 temp; | 988 | u32 temp; |
970 | 989 | ||
971 | u32 int_vec_bit; | 990 | u32 int_vec_bit; |
972 | u32 heartbit; | 991 | u32 heartbeat; |
973 | 992 | ||
974 | u8 max_mac_filters; | 993 | u8 max_mac_filters; |
975 | u8 dev_state; | 994 | u8 dev_state; |
@@ -982,28 +1001,29 @@ struct qlcnic_adapter { | |||
982 | u8 mac_addr[ETH_ALEN]; | 1001 | u8 mac_addr[ETH_ALEN]; |
983 | 1002 | ||
984 | u64 dev_rst_time; | 1003 | u64 dev_rst_time; |
1004 | unsigned long vlans[BITS_TO_LONGS(VLAN_N_VID)]; | ||
985 | 1005 | ||
986 | struct qlcnic_npar_info *npars; | 1006 | struct qlcnic_npar_info *npars; |
987 | struct qlcnic_eswitch *eswitch; | 1007 | struct qlcnic_eswitch *eswitch; |
988 | struct qlcnic_nic_template *nic_ops; | 1008 | struct qlcnic_nic_template *nic_ops; |
989 | 1009 | ||
990 | struct qlcnic_adapter_stats stats; | 1010 | struct qlcnic_adapter_stats stats; |
991 | 1011 | struct list_head mac_list; | |
992 | struct qlcnic_recv_context recv_ctx; | ||
993 | struct qlcnic_host_tx_ring *tx_ring; | ||
994 | 1012 | ||
995 | void __iomem *tgt_mask_reg; | 1013 | void __iomem *tgt_mask_reg; |
996 | void __iomem *tgt_status_reg; | 1014 | void __iomem *tgt_status_reg; |
997 | void __iomem *crb_int_state_reg; | 1015 | void __iomem *crb_int_state_reg; |
998 | void __iomem *isr_int_vec; | 1016 | void __iomem *isr_int_vec; |
999 | 1017 | ||
1000 | struct msix_entry msix_entries[MSIX_ENTRIES_PER_ADAPTER]; | 1018 | struct msix_entry *msix_entries; |
1001 | 1019 | ||
1002 | struct delayed_work fw_work; | 1020 | struct delayed_work fw_work; |
1003 | 1021 | ||
1004 | struct qlcnic_nic_intr_coalesce coal; | ||
1005 | 1022 | ||
1006 | unsigned long state; | 1023 | struct qlcnic_filter_hash fhash; |
1024 | |||
1025 | spinlock_t tx_clean_lock; | ||
1026 | spinlock_t mac_learn_lock; | ||
1007 | __le32 file_prd_off; /*File fw product offset*/ | 1027 | __le32 file_prd_off; /*File fw product offset*/ |
1008 | u32 fw_version; | 1028 | u32 fw_version; |
1009 | const struct firmware *fw; | 1029 | const struct firmware *fw; |
@@ -1025,7 +1045,7 @@ struct qlcnic_info { | |||
1025 | __le16 min_tx_bw; | 1045 | __le16 min_tx_bw; |
1026 | __le16 max_tx_bw; | 1046 | __le16 max_tx_bw; |
1027 | u8 reserved2[104]; | 1047 | u8 reserved2[104]; |
1028 | }; | 1048 | } __packed; |
1029 | 1049 | ||
1030 | struct qlcnic_pci_info { | 1050 | struct qlcnic_pci_info { |
1031 | __le16 id; /* pci function id */ | 1051 | __le16 id; /* pci function id */ |
@@ -1039,10 +1059,10 @@ struct qlcnic_pci_info { | |||
1039 | 1059 | ||
1040 | u8 mac[ETH_ALEN]; | 1060 | u8 mac[ETH_ALEN]; |
1041 | u8 reserved2[106]; | 1061 | u8 reserved2[106]; |
1042 | }; | 1062 | } __packed; |
1043 | 1063 | ||
1044 | struct qlcnic_npar_info { | 1064 | struct qlcnic_npar_info { |
1045 | u16 vlan_id; | 1065 | u16 pvid; |
1046 | u16 min_bw; | 1066 | u16 min_bw; |
1047 | u16 max_bw; | 1067 | u16 max_bw; |
1048 | u8 phy_port; | 1068 | u8 phy_port; |
@@ -1050,11 +1070,13 @@ struct qlcnic_npar_info { | |||
1050 | u8 active; | 1070 | u8 active; |
1051 | u8 enable_pm; | 1071 | u8 enable_pm; |
1052 | u8 dest_npar; | 1072 | u8 dest_npar; |
1053 | u8 host_vlan_tag; | ||
1054 | u8 promisc_mode; | ||
1055 | u8 discard_tagged; | 1073 | u8 discard_tagged; |
1056 | u8 mac_learning; | 1074 | u8 mac_override; |
1075 | u8 mac_anti_spoof; | ||
1076 | u8 promisc_mode; | ||
1077 | u8 offload_flags; | ||
1057 | }; | 1078 | }; |
1079 | |||
1058 | struct qlcnic_eswitch { | 1080 | struct qlcnic_eswitch { |
1059 | u8 port; | 1081 | u8 port; |
1060 | u8 active_vports; | 1082 | u8 active_vports; |
@@ -1074,19 +1096,13 @@ struct qlcnic_eswitch { | |||
1074 | /* Return codes for Error handling */ | 1096 | /* Return codes for Error handling */ |
1075 | #define QL_STATUS_INVALID_PARAM -1 | 1097 | #define QL_STATUS_INVALID_PARAM -1 |
1076 | 1098 | ||
1077 | #define MAX_BW 100 | 1099 | #define MAX_BW 100 /* % of link speed */ |
1078 | #define MIN_BW 1 | ||
1079 | #define MAX_VLAN_ID 4095 | 1100 | #define MAX_VLAN_ID 4095 |
1080 | #define MIN_VLAN_ID 2 | 1101 | #define MIN_VLAN_ID 2 |
1081 | #define MAX_TX_QUEUES 1 | ||
1082 | #define MAX_RX_QUEUES 4 | ||
1083 | #define DEFAULT_MAC_LEARN 1 | 1102 | #define DEFAULT_MAC_LEARN 1 |
1084 | 1103 | ||
1085 | #define IS_VALID_VLAN(vlan) (vlan >= MIN_VLAN_ID && vlan <= MAX_VLAN_ID) | 1104 | #define IS_VALID_VLAN(vlan) (vlan >= MIN_VLAN_ID && vlan < MAX_VLAN_ID) |
1086 | #define IS_VALID_BW(bw) (bw >= MIN_BW && bw <= MAX_BW) | 1105 | #define IS_VALID_BW(bw) (bw <= MAX_BW) |
1087 | #define IS_VALID_TX_QUEUES(que) (que > 0 && que <= MAX_TX_QUEUES) | ||
1088 | #define IS_VALID_RX_QUEUES(que) (que > 0 && que <= MAX_RX_QUEUES) | ||
1089 | #define IS_VALID_MODE(mode) (mode == 0 || mode == 1) | ||
1090 | 1106 | ||
1091 | struct qlcnic_pci_func_cfg { | 1107 | struct qlcnic_pci_func_cfg { |
1092 | u16 func_type; | 1108 | u16 func_type; |
@@ -1118,16 +1134,202 @@ struct qlcnic_pm_func_cfg { | |||
1118 | 1134 | ||
1119 | struct qlcnic_esw_func_cfg { | 1135 | struct qlcnic_esw_func_cfg { |
1120 | u16 vlan_id; | 1136 | u16 vlan_id; |
1137 | u8 op_mode; | ||
1138 | u8 op_type; | ||
1121 | u8 pci_func; | 1139 | u8 pci_func; |
1122 | u8 host_vlan_tag; | 1140 | u8 host_vlan_tag; |
1123 | u8 promisc_mode; | 1141 | u8 promisc_mode; |
1124 | u8 discard_tagged; | 1142 | u8 discard_tagged; |
1125 | u8 mac_learning; | 1143 | u8 mac_override; |
1126 | u8 reserved; | 1144 | u8 mac_anti_spoof; |
1145 | u8 offload_flags; | ||
1146 | u8 reserved[5]; | ||
1147 | }; | ||
1148 | |||
1149 | #define QLCNIC_STATS_VERSION 1 | ||
1150 | #define QLCNIC_STATS_PORT 1 | ||
1151 | #define QLCNIC_STATS_ESWITCH 2 | ||
1152 | #define QLCNIC_QUERY_RX_COUNTER 0 | ||
1153 | #define QLCNIC_QUERY_TX_COUNTER 1 | ||
1154 | #define QLCNIC_ESW_STATS_NOT_AVAIL 0xffffffffffffffffULL | ||
1155 | |||
1156 | #define QLCNIC_ADD_ESW_STATS(VAL1, VAL2)\ | ||
1157 | do { \ | ||
1158 | if (((VAL1) == QLCNIC_ESW_STATS_NOT_AVAIL) && \ | ||
1159 | ((VAL2) != QLCNIC_ESW_STATS_NOT_AVAIL)) \ | ||
1160 | (VAL1) = (VAL2); \ | ||
1161 | else if (((VAL1) != QLCNIC_ESW_STATS_NOT_AVAIL) && \ | ||
1162 | ((VAL2) != QLCNIC_ESW_STATS_NOT_AVAIL)) \ | ||
1163 | (VAL1) += (VAL2); \ | ||
1164 | } while (0) | ||
1165 | |||
1166 | struct __qlcnic_esw_statistics { | ||
1167 | __le16 context_id; | ||
1168 | __le16 version; | ||
1169 | __le16 size; | ||
1170 | __le16 unused; | ||
1171 | __le64 unicast_frames; | ||
1172 | __le64 multicast_frames; | ||
1173 | __le64 broadcast_frames; | ||
1174 | __le64 dropped_frames; | ||
1175 | __le64 errors; | ||
1176 | __le64 local_frames; | ||
1177 | __le64 numbytes; | ||
1178 | __le64 rsvd[3]; | ||
1179 | } __packed; | ||
1180 | |||
1181 | struct qlcnic_esw_statistics { | ||
1182 | struct __qlcnic_esw_statistics rx; | ||
1183 | struct __qlcnic_esw_statistics tx; | ||
1184 | }; | ||
1185 | |||
1186 | struct qlcnic_common_entry_hdr { | ||
1187 | __le32 type; | ||
1188 | __le32 offset; | ||
1189 | __le32 cap_size; | ||
1190 | u8 mask; | ||
1191 | u8 rsvd[2]; | ||
1192 | u8 flags; | ||
1193 | } __packed; | ||
1194 | |||
1195 | struct __crb { | ||
1196 | __le32 addr; | ||
1197 | u8 stride; | ||
1198 | u8 rsvd1[3]; | ||
1199 | __le32 data_size; | ||
1200 | __le32 no_ops; | ||
1201 | __le32 rsvd2[4]; | ||
1202 | } __packed; | ||
1203 | |||
1204 | struct __ctrl { | ||
1205 | __le32 addr; | ||
1206 | u8 stride; | ||
1207 | u8 index_a; | ||
1208 | __le16 timeout; | ||
1209 | __le32 data_size; | ||
1210 | __le32 no_ops; | ||
1211 | u8 opcode; | ||
1212 | u8 index_v; | ||
1213 | u8 shl_val; | ||
1214 | u8 shr_val; | ||
1215 | __le32 val1; | ||
1216 | __le32 val2; | ||
1217 | __le32 val3; | ||
1218 | } __packed; | ||
1219 | |||
1220 | struct __cache { | ||
1221 | __le32 addr; | ||
1222 | u8 stride; | ||
1223 | u8 rsvd; | ||
1224 | __le16 init_tag_val; | ||
1225 | __le32 size; | ||
1226 | __le32 no_ops; | ||
1227 | __le32 ctrl_addr; | ||
1228 | __le32 ctrl_val; | ||
1229 | __le32 read_addr; | ||
1230 | u8 read_addr_stride; | ||
1231 | u8 read_addr_num; | ||
1232 | u8 rsvd1[2]; | ||
1233 | } __packed; | ||
1234 | |||
1235 | struct __ocm { | ||
1236 | u8 rsvd[8]; | ||
1237 | __le32 size; | ||
1238 | __le32 no_ops; | ||
1239 | u8 rsvd1[8]; | ||
1240 | __le32 read_addr; | ||
1241 | __le32 read_addr_stride; | ||
1242 | } __packed; | ||
1243 | |||
1244 | struct __mem { | ||
1245 | u8 rsvd[24]; | ||
1246 | __le32 addr; | ||
1247 | __le32 size; | ||
1248 | } __packed; | ||
1249 | |||
1250 | struct __mux { | ||
1251 | __le32 addr; | ||
1252 | u8 rsvd[4]; | ||
1253 | __le32 size; | ||
1254 | __le32 no_ops; | ||
1255 | __le32 val; | ||
1256 | __le32 val_stride; | ||
1257 | __le32 read_addr; | ||
1258 | u8 rsvd2[4]; | ||
1259 | } __packed; | ||
1260 | |||
1261 | struct __queue { | ||
1262 | __le32 sel_addr; | ||
1263 | __le16 stride; | ||
1264 | u8 rsvd[2]; | ||
1265 | __le32 size; | ||
1266 | __le32 no_ops; | ||
1267 | u8 rsvd2[8]; | ||
1268 | __le32 read_addr; | ||
1269 | u8 read_addr_stride; | ||
1270 | u8 read_addr_cnt; | ||
1271 | u8 rsvd3[2]; | ||
1272 | } __packed; | ||
1273 | |||
1274 | struct qlcnic_dump_entry { | ||
1275 | struct qlcnic_common_entry_hdr hdr; | ||
1276 | union { | ||
1277 | struct __crb crb; | ||
1278 | struct __cache cache; | ||
1279 | struct __ocm ocm; | ||
1280 | struct __mem mem; | ||
1281 | struct __mux mux; | ||
1282 | struct __queue que; | ||
1283 | struct __ctrl ctrl; | ||
1284 | } region; | ||
1285 | } __packed; | ||
1286 | |||
1287 | enum op_codes { | ||
1288 | QLCNIC_DUMP_NOP = 0, | ||
1289 | QLCNIC_DUMP_READ_CRB = 1, | ||
1290 | QLCNIC_DUMP_READ_MUX = 2, | ||
1291 | QLCNIC_DUMP_QUEUE = 3, | ||
1292 | QLCNIC_DUMP_BRD_CONFIG = 4, | ||
1293 | QLCNIC_DUMP_READ_OCM = 6, | ||
1294 | QLCNIC_DUMP_PEG_REG = 7, | ||
1295 | QLCNIC_DUMP_L1_DTAG = 8, | ||
1296 | QLCNIC_DUMP_L1_ITAG = 9, | ||
1297 | QLCNIC_DUMP_L1_DATA = 11, | ||
1298 | QLCNIC_DUMP_L1_INST = 12, | ||
1299 | QLCNIC_DUMP_L2_DTAG = 21, | ||
1300 | QLCNIC_DUMP_L2_ITAG = 22, | ||
1301 | QLCNIC_DUMP_L2_DATA = 23, | ||
1302 | QLCNIC_DUMP_L2_INST = 24, | ||
1303 | QLCNIC_DUMP_READ_ROM = 71, | ||
1304 | QLCNIC_DUMP_READ_MEM = 72, | ||
1305 | QLCNIC_DUMP_READ_CTRL = 98, | ||
1306 | QLCNIC_DUMP_TLHDR = 99, | ||
1307 | QLCNIC_DUMP_RDEND = 255 | ||
1308 | }; | ||
1309 | |||
1310 | #define QLCNIC_DUMP_WCRB BIT_0 | ||
1311 | #define QLCNIC_DUMP_RWCRB BIT_1 | ||
1312 | #define QLCNIC_DUMP_ANDCRB BIT_2 | ||
1313 | #define QLCNIC_DUMP_ORCRB BIT_3 | ||
1314 | #define QLCNIC_DUMP_POLLCRB BIT_4 | ||
1315 | #define QLCNIC_DUMP_RD_SAVE BIT_5 | ||
1316 | #define QLCNIC_DUMP_WRT_SAVED BIT_6 | ||
1317 | #define QLCNIC_DUMP_MOD_SAVE_ST BIT_7 | ||
1318 | #define QLCNIC_DUMP_SKIP BIT_7 | ||
1319 | |||
1320 | #define QLCNIC_DUMP_MASK_MIN 3 | ||
1321 | #define QLCNIC_DUMP_MASK_DEF 0x0f | ||
1322 | #define QLCNIC_DUMP_MASK_MAX 0xff | ||
1323 | #define QLCNIC_FORCE_FW_DUMP_KEY 0xdeadfeed | ||
1324 | |||
1325 | struct qlcnic_dump_operations { | ||
1326 | enum op_codes opcode; | ||
1327 | u32 (*handler)(struct qlcnic_adapter *, | ||
1328 | struct qlcnic_dump_entry *, u32 *); | ||
1127 | }; | 1329 | }; |
1128 | 1330 | ||
1129 | int qlcnic_fw_cmd_query_phy(struct qlcnic_adapter *adapter, u32 reg, u32 *val); | 1331 | int qlcnic_fw_cmd_get_minidump_temp(struct qlcnic_adapter *adapter); |
1130 | int qlcnic_fw_cmd_set_phy(struct qlcnic_adapter *adapter, u32 reg, u32 val); | 1332 | int qlcnic_fw_cmd_set_port(struct qlcnic_adapter *adapter, u32 config); |
1131 | 1333 | ||
1132 | u32 qlcnic_hw_read_wx_2M(struct qlcnic_adapter *adapter, ulong off); | 1334 | u32 qlcnic_hw_read_wx_2M(struct qlcnic_adapter *adapter, ulong off); |
1133 | int qlcnic_hw_write_wx_2M(struct qlcnic_adapter *, ulong off, u32 data); | 1335 | int qlcnic_hw_write_wx_2M(struct qlcnic_adapter *, ulong off, u32 data); |
@@ -1171,6 +1373,9 @@ void qlcnic_pcie_sem_unlock(struct qlcnic_adapter *, int); | |||
1171 | int qlcnic_get_board_info(struct qlcnic_adapter *adapter); | 1373 | int qlcnic_get_board_info(struct qlcnic_adapter *adapter); |
1172 | int qlcnic_wol_supported(struct qlcnic_adapter *adapter); | 1374 | int qlcnic_wol_supported(struct qlcnic_adapter *adapter); |
1173 | int qlcnic_config_led(struct qlcnic_adapter *adapter, u32 state, u32 rate); | 1375 | int qlcnic_config_led(struct qlcnic_adapter *adapter, u32 state, u32 rate); |
1376 | void qlcnic_prune_lb_filters(struct qlcnic_adapter *adapter); | ||
1377 | void qlcnic_delete_lb_filters(struct qlcnic_adapter *adapter); | ||
1378 | int qlcnic_dump_fw(struct qlcnic_adapter *); | ||
1174 | 1379 | ||
1175 | /* Functions from qlcnic_init.c */ | 1380 | /* Functions from qlcnic_init.c */ |
1176 | int qlcnic_load_firmware(struct qlcnic_adapter *adapter); | 1381 | int qlcnic_load_firmware(struct qlcnic_adapter *adapter); |
@@ -1181,7 +1386,7 @@ int qlcnic_pinit_from_rom(struct qlcnic_adapter *adapter); | |||
1181 | int qlcnic_setup_idc_param(struct qlcnic_adapter *adapter); | 1386 | int qlcnic_setup_idc_param(struct qlcnic_adapter *adapter); |
1182 | int qlcnic_check_flash_fw_ver(struct qlcnic_adapter *adapter); | 1387 | int qlcnic_check_flash_fw_ver(struct qlcnic_adapter *adapter); |
1183 | 1388 | ||
1184 | int qlcnic_rom_fast_read(struct qlcnic_adapter *adapter, int addr, int *valp); | 1389 | int qlcnic_rom_fast_read(struct qlcnic_adapter *adapter, u32 addr, u32 *valp); |
1185 | int qlcnic_rom_fast_read_words(struct qlcnic_adapter *adapter, int addr, | 1390 | int qlcnic_rom_fast_read_words(struct qlcnic_adapter *adapter, int addr, |
1186 | u8 *bytes, size_t size); | 1391 | u8 *bytes, size_t size); |
1187 | int qlcnic_alloc_sw_resources(struct qlcnic_adapter *adapter); | 1392 | int qlcnic_alloc_sw_resources(struct qlcnic_adapter *adapter); |
@@ -1199,9 +1404,9 @@ void qlcnic_reset_rx_buffers_list(struct qlcnic_adapter *adapter); | |||
1199 | void qlcnic_release_rx_buffers(struct qlcnic_adapter *adapter); | 1404 | void qlcnic_release_rx_buffers(struct qlcnic_adapter *adapter); |
1200 | void qlcnic_release_tx_buffers(struct qlcnic_adapter *adapter); | 1405 | void qlcnic_release_tx_buffers(struct qlcnic_adapter *adapter); |
1201 | 1406 | ||
1202 | int qlcnic_init_firmware(struct qlcnic_adapter *adapter); | 1407 | int qlcnic_check_fw_status(struct qlcnic_adapter *adapter); |
1203 | void qlcnic_watchdog_task(struct work_struct *work); | 1408 | void qlcnic_watchdog_task(struct work_struct *work); |
1204 | void qlcnic_post_rx_buffers(struct qlcnic_adapter *adapter, u32 ringid, | 1409 | void qlcnic_post_rx_buffers(struct qlcnic_adapter *adapter, |
1205 | struct qlcnic_host_rds_ring *rds_ring); | 1410 | struct qlcnic_host_rds_ring *rds_ring); |
1206 | int qlcnic_process_rcv_ring(struct qlcnic_host_sds_ring *sds_ring, int max); | 1411 | int qlcnic_process_rcv_ring(struct qlcnic_host_sds_ring *sds_ring, int max); |
1207 | void qlcnic_set_multi(struct net_device *netdev); | 1412 | void qlcnic_set_multi(struct net_device *netdev); |
@@ -1209,20 +1414,19 @@ void qlcnic_free_mac_list(struct qlcnic_adapter *adapter); | |||
1209 | int qlcnic_nic_set_promisc(struct qlcnic_adapter *adapter, u32); | 1414 | int qlcnic_nic_set_promisc(struct qlcnic_adapter *adapter, u32); |
1210 | int qlcnic_config_intr_coalesce(struct qlcnic_adapter *adapter); | 1415 | int qlcnic_config_intr_coalesce(struct qlcnic_adapter *adapter); |
1211 | int qlcnic_config_rss(struct qlcnic_adapter *adapter, int enable); | 1416 | int qlcnic_config_rss(struct qlcnic_adapter *adapter, int enable); |
1212 | int qlcnic_config_ipaddr(struct qlcnic_adapter *adapter, u32 ip, int cmd); | 1417 | int qlcnic_config_ipaddr(struct qlcnic_adapter *adapter, __be32 ip, int cmd); |
1213 | int qlcnic_linkevent_request(struct qlcnic_adapter *adapter, int enable); | 1418 | int qlcnic_linkevent_request(struct qlcnic_adapter *adapter, int enable); |
1214 | void qlcnic_advert_link_change(struct qlcnic_adapter *adapter, int linkup); | 1419 | void qlcnic_advert_link_change(struct qlcnic_adapter *adapter, int linkup); |
1215 | 1420 | ||
1216 | int qlcnic_fw_cmd_set_mtu(struct qlcnic_adapter *adapter, int mtu); | 1421 | int qlcnic_fw_cmd_set_mtu(struct qlcnic_adapter *adapter, int mtu); |
1217 | int qlcnic_change_mtu(struct net_device *netdev, int new_mtu); | 1422 | int qlcnic_change_mtu(struct net_device *netdev, int new_mtu); |
1423 | u32 qlcnic_fix_features(struct net_device *netdev, u32 features); | ||
1424 | int qlcnic_set_features(struct net_device *netdev, u32 features); | ||
1218 | int qlcnic_config_hw_lro(struct qlcnic_adapter *adapter, int enable); | 1425 | int qlcnic_config_hw_lro(struct qlcnic_adapter *adapter, int enable); |
1219 | int qlcnic_config_bridged_mode(struct qlcnic_adapter *adapter, u32 enable); | 1426 | int qlcnic_config_bridged_mode(struct qlcnic_adapter *adapter, u32 enable); |
1220 | int qlcnic_send_lro_cleanup(struct qlcnic_adapter *adapter); | 1427 | int qlcnic_send_lro_cleanup(struct qlcnic_adapter *adapter); |
1221 | void qlcnic_update_cmd_producer(struct qlcnic_adapter *adapter, | 1428 | void qlcnic_update_cmd_producer(struct qlcnic_adapter *adapter, |
1222 | struct qlcnic_host_tx_ring *tx_ring); | 1429 | struct qlcnic_host_tx_ring *tx_ring); |
1223 | int qlcnic_get_mac_addr(struct qlcnic_adapter *adapter, u8 *mac); | ||
1224 | void qlcnic_clear_ilb_mode(struct qlcnic_adapter *adapter); | ||
1225 | int qlcnic_set_ilb_mode(struct qlcnic_adapter *adapter); | ||
1226 | void qlcnic_fetch_mac(struct qlcnic_adapter *, u32, u32, u8, u8 *); | 1430 | void qlcnic_fetch_mac(struct qlcnic_adapter *, u32, u32, u8, u8 *); |
1227 | 1431 | ||
1228 | /* Functions from qlcnic_main.c */ | 1432 | /* Functions from qlcnic_main.c */ |
@@ -1231,27 +1435,28 @@ u32 qlcnic_issue_cmd(struct qlcnic_adapter *adapter, | |||
1231 | u32 pci_fn, u32 version, u32 arg1, u32 arg2, u32 arg3, u32 cmd); | 1435 | u32 pci_fn, u32 version, u32 arg1, u32 arg2, u32 arg3, u32 cmd); |
1232 | void qlcnic_diag_free_res(struct net_device *netdev, int max_sds_rings); | 1436 | void qlcnic_diag_free_res(struct net_device *netdev, int max_sds_rings); |
1233 | int qlcnic_diag_alloc_res(struct net_device *netdev, int test); | 1437 | int qlcnic_diag_alloc_res(struct net_device *netdev, int test); |
1234 | int qlcnic_check_loopback_buff(unsigned char *data); | ||
1235 | netdev_tx_t qlcnic_xmit_frame(struct sk_buff *skb, struct net_device *netdev); | 1438 | netdev_tx_t qlcnic_xmit_frame(struct sk_buff *skb, struct net_device *netdev); |
1236 | void qlcnic_process_rcv_ring_diag(struct qlcnic_host_sds_ring *sds_ring); | 1439 | int qlcnic_validate_max_rss(struct net_device *netdev, u8 max_hw, u8 val); |
1440 | int qlcnic_set_max_rss(struct qlcnic_adapter *adapter, u8 data); | ||
1441 | void qlcnic_dev_request_reset(struct qlcnic_adapter *); | ||
1237 | 1442 | ||
1238 | /* Management functions */ | 1443 | /* Management functions */ |
1239 | int qlcnic_set_mac_address(struct qlcnic_adapter *, u8*); | ||
1240 | int qlcnic_get_mac_address(struct qlcnic_adapter *, u8*); | 1444 | int qlcnic_get_mac_address(struct qlcnic_adapter *, u8*); |
1241 | int qlcnic_get_nic_info(struct qlcnic_adapter *, struct qlcnic_info *, u8); | 1445 | int qlcnic_get_nic_info(struct qlcnic_adapter *, struct qlcnic_info *, u8); |
1242 | int qlcnic_set_nic_info(struct qlcnic_adapter *, struct qlcnic_info *); | 1446 | int qlcnic_set_nic_info(struct qlcnic_adapter *, struct qlcnic_info *); |
1243 | int qlcnic_get_pci_info(struct qlcnic_adapter *, struct qlcnic_pci_info*); | 1447 | int qlcnic_get_pci_info(struct qlcnic_adapter *, struct qlcnic_pci_info*); |
1244 | int qlcnic_reset_partition(struct qlcnic_adapter *, u8); | ||
1245 | 1448 | ||
1246 | /* eSwitch management functions */ | 1449 | /* eSwitch management functions */ |
1247 | int qlcnic_get_eswitch_capabilities(struct qlcnic_adapter *, u8, | 1450 | int qlcnic_config_switch_port(struct qlcnic_adapter *, |
1248 | struct qlcnic_eswitch *); | 1451 | struct qlcnic_esw_func_cfg *); |
1249 | int qlcnic_get_eswitch_status(struct qlcnic_adapter *, u8, | 1452 | int qlcnic_get_eswitch_port_config(struct qlcnic_adapter *, |
1250 | struct qlcnic_eswitch *); | 1453 | struct qlcnic_esw_func_cfg *); |
1251 | int qlcnic_toggle_eswitch(struct qlcnic_adapter *, u8, u8); | ||
1252 | int qlcnic_config_switch_port(struct qlcnic_adapter *, u8, int, u8, u8, | ||
1253 | u8, u8, u16); | ||
1254 | int qlcnic_config_port_mirroring(struct qlcnic_adapter *, u8, u8, u8); | 1454 | int qlcnic_config_port_mirroring(struct qlcnic_adapter *, u8, u8, u8); |
1455 | int qlcnic_get_port_stats(struct qlcnic_adapter *, const u8, const u8, | ||
1456 | struct __qlcnic_esw_statistics *); | ||
1457 | int qlcnic_get_eswitch_stats(struct qlcnic_adapter *, const u8, u8, | ||
1458 | struct __qlcnic_esw_statistics *); | ||
1459 | int qlcnic_clear_esw_stats(struct qlcnic_adapter *adapter, u8, u8, u8); | ||
1255 | extern int qlcnic_config_tso; | 1460 | extern int qlcnic_config_tso; |
1256 | 1461 | ||
1257 | /* | 1462 | /* |
@@ -1280,6 +1485,10 @@ static const struct qlcnic_brdinfo qlcnic_boards[] = { | |||
1280 | "3200 Series Quad Port 1Gb Intelligent Ethernet Adapter"}, | 1485 | "3200 Series Quad Port 1Gb Intelligent Ethernet Adapter"}, |
1281 | {0x1077, 0x8020, 0x1077, 0x20f, | 1486 | {0x1077, 0x8020, 0x1077, 0x20f, |
1282 | "3200 Series Single Port 10Gb Intelligent Ethernet Adapter"}, | 1487 | "3200 Series Single Port 10Gb Intelligent Ethernet Adapter"}, |
1488 | {0x1077, 0x8020, 0x103c, 0x3733, | ||
1489 | "NC523SFP 10Gb 2-port Server Adapter"}, | ||
1490 | {0x1077, 0x8020, 0x103c, 0x3346, | ||
1491 | "CN1000Q Dual Port Converged Network Adapter"}, | ||
1283 | {0x1077, 0x8020, 0x0, 0x0, "cLOM8214 1/10GbE Controller"}, | 1492 | {0x1077, 0x8020, 0x0, 0x0, "cLOM8214 1/10GbE Controller"}, |
1284 | }; | 1493 | }; |
1285 | 1494 | ||
@@ -1287,8 +1496,7 @@ static const struct qlcnic_brdinfo qlcnic_boards[] = { | |||
1287 | 1496 | ||
1288 | static inline u32 qlcnic_tx_avail(struct qlcnic_host_tx_ring *tx_ring) | 1497 | static inline u32 qlcnic_tx_avail(struct qlcnic_host_tx_ring *tx_ring) |
1289 | { | 1498 | { |
1290 | smp_mb(); | 1499 | if (likely(tx_ring->producer < tx_ring->sw_consumer)) |
1291 | if (tx_ring->producer < tx_ring->sw_consumer) | ||
1292 | return tx_ring->sw_consumer - tx_ring->producer; | 1500 | return tx_ring->sw_consumer - tx_ring->producer; |
1293 | else | 1501 | else |
1294 | return tx_ring->sw_consumer + tx_ring->num_desc - | 1502 | return tx_ring->sw_consumer + tx_ring->num_desc - |
@@ -1298,7 +1506,6 @@ static inline u32 qlcnic_tx_avail(struct qlcnic_host_tx_ring *tx_ring) | |||
1298 | extern const struct ethtool_ops qlcnic_ethtool_ops; | 1506 | extern const struct ethtool_ops qlcnic_ethtool_ops; |
1299 | 1507 | ||
1300 | struct qlcnic_nic_template { | 1508 | struct qlcnic_nic_template { |
1301 | int (*get_mac_addr) (struct qlcnic_adapter *, u8*); | ||
1302 | int (*config_bridged_mode) (struct qlcnic_adapter *, u32); | 1509 | int (*config_bridged_mode) (struct qlcnic_adapter *, u32); |
1303 | int (*config_led) (struct qlcnic_adapter *, u32, u32); | 1510 | int (*config_led) (struct qlcnic_adapter *, u32, u32); |
1304 | int (*start_firmware) (struct qlcnic_adapter *); | 1511 | int (*start_firmware) (struct qlcnic_adapter *); |
diff --git a/drivers/net/qlcnic/qlcnic_ctx.c b/drivers/net/qlcnic/qlcnic_ctx.c index cc5d861d9a12..bab041a5c758 100644 --- a/drivers/net/qlcnic/qlcnic_ctx.c +++ b/drivers/net/qlcnic/qlcnic_ctx.c | |||
@@ -1,25 +1,8 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2009 - QLogic Corporation. | 2 | * QLogic qlcnic NIC Driver |
3 | * All rights reserved. | 3 | * Copyright (c) 2009-2010 QLogic Corporation |
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License | ||
7 | * as published by the Free Software Foundation; either version 2 | ||
8 | * of the License, or (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, but | ||
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, | ||
18 | * MA 02111-1307, USA. | ||
19 | * | ||
20 | * The full GNU General Public License is included in this distribution | ||
21 | * in the file called "COPYING". | ||
22 | * | 4 | * |
5 | * See LICENSE.qlcnic for copyright and licensing details. | ||
23 | */ | 6 | */ |
24 | 7 | ||
25 | #include "qlcnic.h" | 8 | #include "qlcnic.h" |
@@ -81,14 +64,105 @@ qlcnic_issue_cmd(struct qlcnic_adapter *adapter, | |||
81 | return rcode; | 64 | return rcode; |
82 | } | 65 | } |
83 | 66 | ||
67 | static uint32_t qlcnic_temp_checksum(uint32_t *temp_buffer, u16 temp_size) | ||
68 | { | ||
69 | uint64_t sum = 0; | ||
70 | int count = temp_size / sizeof(uint32_t); | ||
71 | while (count-- > 0) | ||
72 | sum += *temp_buffer++; | ||
73 | while (sum >> 32) | ||
74 | sum = (sum & 0xFFFFFFFF) + (sum >> 32); | ||
75 | return ~sum; | ||
76 | } | ||
77 | |||
78 | int qlcnic_fw_cmd_get_minidump_temp(struct qlcnic_adapter *adapter) | ||
79 | { | ||
80 | int err, i; | ||
81 | u16 temp_size; | ||
82 | void *tmp_addr; | ||
83 | u32 version, csum, *template, *tmp_buf; | ||
84 | struct qlcnic_hardware_context *ahw; | ||
85 | struct qlcnic_dump_template_hdr *tmpl_hdr, *tmp_tmpl; | ||
86 | dma_addr_t tmp_addr_t = 0; | ||
87 | |||
88 | ahw = adapter->ahw; | ||
89 | err = qlcnic_issue_cmd(adapter, | ||
90 | adapter->ahw->pci_func, | ||
91 | adapter->fw_hal_version, | ||
92 | 0, | ||
93 | 0, | ||
94 | 0, | ||
95 | QLCNIC_CDRP_CMD_TEMP_SIZE); | ||
96 | if (err != QLCNIC_RCODE_SUCCESS) { | ||
97 | err = QLCRD32(adapter, QLCNIC_ARG1_CRB_OFFSET); | ||
98 | dev_err(&adapter->pdev->dev, | ||
99 | "Failed to get template size %d\n", err); | ||
100 | err = -EIO; | ||
101 | return err; | ||
102 | } | ||
103 | version = QLCRD32(adapter, QLCNIC_ARG3_CRB_OFFSET); | ||
104 | temp_size = QLCRD32(adapter, QLCNIC_ARG2_CRB_OFFSET); | ||
105 | if (!temp_size) | ||
106 | return -EIO; | ||
107 | |||
108 | tmp_addr = dma_alloc_coherent(&adapter->pdev->dev, temp_size, | ||
109 | &tmp_addr_t, GFP_KERNEL); | ||
110 | if (!tmp_addr) { | ||
111 | dev_err(&adapter->pdev->dev, | ||
112 | "Can't get memory for FW dump template\n"); | ||
113 | return -ENOMEM; | ||
114 | } | ||
115 | err = qlcnic_issue_cmd(adapter, | ||
116 | adapter->ahw->pci_func, | ||
117 | adapter->fw_hal_version, | ||
118 | LSD(tmp_addr_t), | ||
119 | MSD(tmp_addr_t), | ||
120 | temp_size, | ||
121 | QLCNIC_CDRP_CMD_GET_TEMP_HDR); | ||
122 | |||
123 | if (err != QLCNIC_RCODE_SUCCESS) { | ||
124 | dev_err(&adapter->pdev->dev, | ||
125 | "Failed to get mini dump template header %d\n", err); | ||
126 | err = -EIO; | ||
127 | goto error; | ||
128 | } | ||
129 | tmp_tmpl = (struct qlcnic_dump_template_hdr *) tmp_addr; | ||
130 | csum = qlcnic_temp_checksum((uint32_t *) tmp_addr, temp_size); | ||
131 | if (csum) { | ||
132 | dev_err(&adapter->pdev->dev, | ||
133 | "Template header checksum validation failed\n"); | ||
134 | err = -EIO; | ||
135 | goto error; | ||
136 | } | ||
137 | ahw->fw_dump.tmpl_hdr = vzalloc(temp_size); | ||
138 | if (!ahw->fw_dump.tmpl_hdr) { | ||
139 | err = -EIO; | ||
140 | goto error; | ||
141 | } | ||
142 | tmp_buf = (u32 *) tmp_addr; | ||
143 | template = (u32 *) ahw->fw_dump.tmpl_hdr; | ||
144 | for (i = 0; i < temp_size/sizeof(u32); i++) | ||
145 | *template++ = __le32_to_cpu(*tmp_buf++); | ||
146 | |||
147 | tmpl_hdr = ahw->fw_dump.tmpl_hdr; | ||
148 | if (tmpl_hdr->cap_mask > QLCNIC_DUMP_MASK_DEF && | ||
149 | tmpl_hdr->cap_mask <= QLCNIC_DUMP_MASK_MAX) | ||
150 | tmpl_hdr->drv_cap_mask = tmpl_hdr->cap_mask; | ||
151 | else | ||
152 | tmpl_hdr->drv_cap_mask = QLCNIC_DUMP_MASK_DEF; | ||
153 | error: | ||
154 | dma_free_coherent(&adapter->pdev->dev, temp_size, tmp_addr, tmp_addr_t); | ||
155 | return err; | ||
156 | } | ||
157 | |||
84 | int | 158 | int |
85 | qlcnic_fw_cmd_set_mtu(struct qlcnic_adapter *adapter, int mtu) | 159 | qlcnic_fw_cmd_set_mtu(struct qlcnic_adapter *adapter, int mtu) |
86 | { | 160 | { |
87 | struct qlcnic_recv_context *recv_ctx = &adapter->recv_ctx; | 161 | struct qlcnic_recv_context *recv_ctx = adapter->recv_ctx; |
88 | 162 | ||
89 | if (recv_ctx->state == QLCNIC_HOST_CTX_STATE_ACTIVE) { | 163 | if (recv_ctx->state == QLCNIC_HOST_CTX_STATE_ACTIVE) { |
90 | if (qlcnic_issue_cmd(adapter, | 164 | if (qlcnic_issue_cmd(adapter, |
91 | adapter->ahw.pci_func, | 165 | adapter->ahw->pci_func, |
92 | adapter->fw_hal_version, | 166 | adapter->fw_hal_version, |
93 | recv_ctx->context_id, | 167 | recv_ctx->context_id, |
94 | mtu, | 168 | mtu, |
@@ -119,12 +193,12 @@ qlcnic_fw_cmd_create_rx_ctx(struct qlcnic_adapter *adapter) | |||
119 | dma_addr_t hostrq_phys_addr, cardrsp_phys_addr; | 193 | dma_addr_t hostrq_phys_addr, cardrsp_phys_addr; |
120 | u64 phys_addr; | 194 | u64 phys_addr; |
121 | 195 | ||
122 | int i, nrds_rings, nsds_rings; | 196 | u8 i, nrds_rings, nsds_rings; |
123 | size_t rq_size, rsp_size; | 197 | size_t rq_size, rsp_size; |
124 | u32 cap, reg, val, reg2; | 198 | u32 cap, reg, val, reg2; |
125 | int err; | 199 | int err; |
126 | 200 | ||
127 | struct qlcnic_recv_context *recv_ctx = &adapter->recv_ctx; | 201 | struct qlcnic_recv_context *recv_ctx = adapter->recv_ctx; |
128 | 202 | ||
129 | nrds_rings = adapter->max_rds_rings; | 203 | nrds_rings = adapter->max_rds_rings; |
130 | nsds_rings = adapter->max_sds_rings; | 204 | nsds_rings = adapter->max_sds_rings; |
@@ -136,14 +210,14 @@ qlcnic_fw_cmd_create_rx_ctx(struct qlcnic_adapter *adapter) | |||
136 | SIZEOF_CARDRSP_RX(struct qlcnic_cardrsp_rx_ctx, nrds_rings, | 210 | SIZEOF_CARDRSP_RX(struct qlcnic_cardrsp_rx_ctx, nrds_rings, |
137 | nsds_rings); | 211 | nsds_rings); |
138 | 212 | ||
139 | addr = pci_alloc_consistent(adapter->pdev, | 213 | addr = dma_alloc_coherent(&adapter->pdev->dev, rq_size, |
140 | rq_size, &hostrq_phys_addr); | 214 | &hostrq_phys_addr, GFP_KERNEL); |
141 | if (addr == NULL) | 215 | if (addr == NULL) |
142 | return -ENOMEM; | 216 | return -ENOMEM; |
143 | prq = (struct qlcnic_hostrq_rx_ctx *)addr; | 217 | prq = (struct qlcnic_hostrq_rx_ctx *)addr; |
144 | 218 | ||
145 | addr = pci_alloc_consistent(adapter->pdev, | 219 | addr = dma_alloc_coherent(&adapter->pdev->dev, rsp_size, |
146 | rsp_size, &cardrsp_phys_addr); | 220 | &cardrsp_phys_addr, GFP_KERNEL); |
147 | if (addr == NULL) { | 221 | if (addr == NULL) { |
148 | err = -ENOMEM; | 222 | err = -ENOMEM; |
149 | goto out_free_rq; | 223 | goto out_free_rq; |
@@ -168,7 +242,7 @@ qlcnic_fw_cmd_create_rx_ctx(struct qlcnic_adapter *adapter) | |||
168 | 242 | ||
169 | prq->num_rds_rings = cpu_to_le16(nrds_rings); | 243 | prq->num_rds_rings = cpu_to_le16(nrds_rings); |
170 | prq->num_sds_rings = cpu_to_le16(nsds_rings); | 244 | prq->num_sds_rings = cpu_to_le16(nsds_rings); |
171 | prq->rds_ring_offset = cpu_to_le32(0); | 245 | prq->rds_ring_offset = 0; |
172 | 246 | ||
173 | val = le32_to_cpu(prq->rds_ring_offset) + | 247 | val = le32_to_cpu(prq->rds_ring_offset) + |
174 | (sizeof(struct qlcnic_hostrq_rds_ring) * nrds_rings); | 248 | (sizeof(struct qlcnic_hostrq_rds_ring) * nrds_rings); |
@@ -204,7 +278,7 @@ qlcnic_fw_cmd_create_rx_ctx(struct qlcnic_adapter *adapter) | |||
204 | 278 | ||
205 | phys_addr = hostrq_phys_addr; | 279 | phys_addr = hostrq_phys_addr; |
206 | err = qlcnic_issue_cmd(adapter, | 280 | err = qlcnic_issue_cmd(adapter, |
207 | adapter->ahw.pci_func, | 281 | adapter->ahw->pci_func, |
208 | adapter->fw_hal_version, | 282 | adapter->fw_hal_version, |
209 | (u32)(phys_addr >> 32), | 283 | (u32)(phys_addr >> 32), |
210 | (u32)(phys_addr & 0xffffffff), | 284 | (u32)(phys_addr & 0xffffffff), |
@@ -224,7 +298,7 @@ qlcnic_fw_cmd_create_rx_ctx(struct qlcnic_adapter *adapter) | |||
224 | rds_ring = &recv_ctx->rds_rings[i]; | 298 | rds_ring = &recv_ctx->rds_rings[i]; |
225 | 299 | ||
226 | reg = le32_to_cpu(prsp_rds[i].host_producer_crb); | 300 | reg = le32_to_cpu(prsp_rds[i].host_producer_crb); |
227 | rds_ring->crb_rcv_producer = adapter->ahw.pci_base0 + reg; | 301 | rds_ring->crb_rcv_producer = adapter->ahw->pci_base0 + reg; |
228 | } | 302 | } |
229 | 303 | ||
230 | prsp_sds = ((struct qlcnic_cardrsp_sds_ring *) | 304 | prsp_sds = ((struct qlcnic_cardrsp_sds_ring *) |
@@ -236,8 +310,8 @@ qlcnic_fw_cmd_create_rx_ctx(struct qlcnic_adapter *adapter) | |||
236 | reg = le32_to_cpu(prsp_sds[i].host_consumer_crb); | 310 | reg = le32_to_cpu(prsp_sds[i].host_consumer_crb); |
237 | reg2 = le32_to_cpu(prsp_sds[i].interrupt_crb); | 311 | reg2 = le32_to_cpu(prsp_sds[i].interrupt_crb); |
238 | 312 | ||
239 | sds_ring->crb_sts_consumer = adapter->ahw.pci_base0 + reg; | 313 | sds_ring->crb_sts_consumer = adapter->ahw->pci_base0 + reg; |
240 | sds_ring->crb_intr_mask = adapter->ahw.pci_base0 + reg2; | 314 | sds_ring->crb_intr_mask = adapter->ahw->pci_base0 + reg2; |
241 | } | 315 | } |
242 | 316 | ||
243 | recv_ctx->state = le32_to_cpu(prsp->host_ctx_state); | 317 | recv_ctx->state = le32_to_cpu(prsp->host_ctx_state); |
@@ -245,19 +319,20 @@ qlcnic_fw_cmd_create_rx_ctx(struct qlcnic_adapter *adapter) | |||
245 | recv_ctx->virt_port = prsp->virt_port; | 319 | recv_ctx->virt_port = prsp->virt_port; |
246 | 320 | ||
247 | out_free_rsp: | 321 | out_free_rsp: |
248 | pci_free_consistent(adapter->pdev, rsp_size, prsp, cardrsp_phys_addr); | 322 | dma_free_coherent(&adapter->pdev->dev, rsp_size, prsp, |
323 | cardrsp_phys_addr); | ||
249 | out_free_rq: | 324 | out_free_rq: |
250 | pci_free_consistent(adapter->pdev, rq_size, prq, hostrq_phys_addr); | 325 | dma_free_coherent(&adapter->pdev->dev, rq_size, prq, hostrq_phys_addr); |
251 | return err; | 326 | return err; |
252 | } | 327 | } |
253 | 328 | ||
254 | static void | 329 | static void |
255 | qlcnic_fw_cmd_destroy_rx_ctx(struct qlcnic_adapter *adapter) | 330 | qlcnic_fw_cmd_destroy_rx_ctx(struct qlcnic_adapter *adapter) |
256 | { | 331 | { |
257 | struct qlcnic_recv_context *recv_ctx = &adapter->recv_ctx; | 332 | struct qlcnic_recv_context *recv_ctx = adapter->recv_ctx; |
258 | 333 | ||
259 | if (qlcnic_issue_cmd(adapter, | 334 | if (qlcnic_issue_cmd(adapter, |
260 | adapter->ahw.pci_func, | 335 | adapter->ahw->pci_func, |
261 | adapter->fw_hal_version, | 336 | adapter->fw_hal_version, |
262 | recv_ctx->context_id, | 337 | recv_ctx->context_id, |
263 | QLCNIC_DESTROY_CTX_RESET, | 338 | QLCNIC_DESTROY_CTX_RESET, |
@@ -291,14 +366,14 @@ qlcnic_fw_cmd_create_tx_ctx(struct qlcnic_adapter *adapter) | |||
291 | *(tx_ring->hw_consumer) = 0; | 366 | *(tx_ring->hw_consumer) = 0; |
292 | 367 | ||
293 | rq_size = SIZEOF_HOSTRQ_TX(struct qlcnic_hostrq_tx_ctx); | 368 | rq_size = SIZEOF_HOSTRQ_TX(struct qlcnic_hostrq_tx_ctx); |
294 | rq_addr = pci_alloc_consistent(adapter->pdev, | 369 | rq_addr = dma_alloc_coherent(&adapter->pdev->dev, rq_size, |
295 | rq_size, &rq_phys_addr); | 370 | &rq_phys_addr, GFP_KERNEL); |
296 | if (!rq_addr) | 371 | if (!rq_addr) |
297 | return -ENOMEM; | 372 | return -ENOMEM; |
298 | 373 | ||
299 | rsp_size = SIZEOF_CARDRSP_TX(struct qlcnic_cardrsp_tx_ctx); | 374 | rsp_size = SIZEOF_CARDRSP_TX(struct qlcnic_cardrsp_tx_ctx); |
300 | rsp_addr = pci_alloc_consistent(adapter->pdev, | 375 | rsp_addr = dma_alloc_coherent(&adapter->pdev->dev, rsp_size, |
301 | rsp_size, &rsp_phys_addr); | 376 | &rsp_phys_addr, GFP_KERNEL); |
302 | if (!rsp_addr) { | 377 | if (!rsp_addr) { |
303 | err = -ENOMEM; | 378 | err = -ENOMEM; |
304 | goto out_free_rq; | 379 | goto out_free_rq; |
@@ -330,7 +405,7 @@ qlcnic_fw_cmd_create_tx_ctx(struct qlcnic_adapter *adapter) | |||
330 | 405 | ||
331 | phys_addr = rq_phys_addr; | 406 | phys_addr = rq_phys_addr; |
332 | err = qlcnic_issue_cmd(adapter, | 407 | err = qlcnic_issue_cmd(adapter, |
333 | adapter->ahw.pci_func, | 408 | adapter->ahw->pci_func, |
334 | adapter->fw_hal_version, | 409 | adapter->fw_hal_version, |
335 | (u32)(phys_addr >> 32), | 410 | (u32)(phys_addr >> 32), |
336 | ((u32)phys_addr & 0xffffffff), | 411 | ((u32)phys_addr & 0xffffffff), |
@@ -339,7 +414,7 @@ qlcnic_fw_cmd_create_tx_ctx(struct qlcnic_adapter *adapter) | |||
339 | 414 | ||
340 | if (err == QLCNIC_RCODE_SUCCESS) { | 415 | if (err == QLCNIC_RCODE_SUCCESS) { |
341 | temp = le32_to_cpu(prsp->cds_ring.host_producer_crb); | 416 | temp = le32_to_cpu(prsp->cds_ring.host_producer_crb); |
342 | tx_ring->crb_cmd_producer = adapter->ahw.pci_base0 + temp; | 417 | tx_ring->crb_cmd_producer = adapter->ahw->pci_base0 + temp; |
343 | 418 | ||
344 | adapter->tx_context_id = | 419 | adapter->tx_context_id = |
345 | le16_to_cpu(prsp->context_id); | 420 | le16_to_cpu(prsp->context_id); |
@@ -349,10 +424,11 @@ qlcnic_fw_cmd_create_tx_ctx(struct qlcnic_adapter *adapter) | |||
349 | err = -EIO; | 424 | err = -EIO; |
350 | } | 425 | } |
351 | 426 | ||
352 | pci_free_consistent(adapter->pdev, rsp_size, rsp_addr, rsp_phys_addr); | 427 | dma_free_coherent(&adapter->pdev->dev, rsp_size, rsp_addr, |
428 | rsp_phys_addr); | ||
353 | 429 | ||
354 | out_free_rq: | 430 | out_free_rq: |
355 | pci_free_consistent(adapter->pdev, rq_size, rq_addr, rq_phys_addr); | 431 | dma_free_coherent(&adapter->pdev->dev, rq_size, rq_addr, rq_phys_addr); |
356 | 432 | ||
357 | return err; | 433 | return err; |
358 | } | 434 | } |
@@ -361,7 +437,7 @@ static void | |||
361 | qlcnic_fw_cmd_destroy_tx_ctx(struct qlcnic_adapter *adapter) | 437 | qlcnic_fw_cmd_destroy_tx_ctx(struct qlcnic_adapter *adapter) |
362 | { | 438 | { |
363 | if (qlcnic_issue_cmd(adapter, | 439 | if (qlcnic_issue_cmd(adapter, |
364 | adapter->ahw.pci_func, | 440 | adapter->ahw->pci_func, |
365 | adapter->fw_hal_version, | 441 | adapter->fw_hal_version, |
366 | adapter->tx_context_id, | 442 | adapter->tx_context_id, |
367 | QLCNIC_DESTROY_CTX_RESET, | 443 | QLCNIC_DESTROY_CTX_RESET, |
@@ -374,33 +450,15 @@ qlcnic_fw_cmd_destroy_tx_ctx(struct qlcnic_adapter *adapter) | |||
374 | } | 450 | } |
375 | 451 | ||
376 | int | 452 | int |
377 | qlcnic_fw_cmd_query_phy(struct qlcnic_adapter *adapter, u32 reg, u32 *val) | 453 | qlcnic_fw_cmd_set_port(struct qlcnic_adapter *adapter, u32 config) |
378 | { | ||
379 | |||
380 | if (qlcnic_issue_cmd(adapter, | ||
381 | adapter->ahw.pci_func, | ||
382 | adapter->fw_hal_version, | ||
383 | reg, | ||
384 | 0, | ||
385 | 0, | ||
386 | QLCNIC_CDRP_CMD_READ_PHY)) { | ||
387 | |||
388 | return -EIO; | ||
389 | } | ||
390 | |||
391 | return QLCRD32(adapter, QLCNIC_ARG1_CRB_OFFSET); | ||
392 | } | ||
393 | |||
394 | int | ||
395 | qlcnic_fw_cmd_set_phy(struct qlcnic_adapter *adapter, u32 reg, u32 val) | ||
396 | { | 454 | { |
397 | return qlcnic_issue_cmd(adapter, | 455 | return qlcnic_issue_cmd(adapter, |
398 | adapter->ahw.pci_func, | 456 | adapter->ahw->pci_func, |
399 | adapter->fw_hal_version, | 457 | adapter->fw_hal_version, |
400 | reg, | 458 | config, |
401 | val, | ||
402 | 0, | 459 | 0, |
403 | QLCNIC_CDRP_CMD_WRITE_PHY); | 460 | 0, |
461 | QLCNIC_CDRP_CMD_CONFIG_PORT); | ||
404 | } | 462 | } |
405 | 463 | ||
406 | int qlcnic_alloc_hw_resources(struct qlcnic_adapter *adapter) | 464 | int qlcnic_alloc_hw_resources(struct qlcnic_adapter *adapter) |
@@ -415,20 +473,19 @@ int qlcnic_alloc_hw_resources(struct qlcnic_adapter *adapter) | |||
415 | 473 | ||
416 | struct pci_dev *pdev = adapter->pdev; | 474 | struct pci_dev *pdev = adapter->pdev; |
417 | 475 | ||
418 | recv_ctx = &adapter->recv_ctx; | 476 | recv_ctx = adapter->recv_ctx; |
419 | tx_ring = adapter->tx_ring; | 477 | tx_ring = adapter->tx_ring; |
420 | 478 | ||
421 | tx_ring->hw_consumer = (__le32 *)pci_alloc_consistent(pdev, sizeof(u32), | 479 | tx_ring->hw_consumer = (__le32 *) dma_alloc_coherent(&pdev->dev, |
422 | &tx_ring->hw_cons_phys_addr); | 480 | sizeof(u32), &tx_ring->hw_cons_phys_addr, GFP_KERNEL); |
423 | if (tx_ring->hw_consumer == NULL) { | 481 | if (tx_ring->hw_consumer == NULL) { |
424 | dev_err(&pdev->dev, "failed to allocate tx consumer\n"); | 482 | dev_err(&pdev->dev, "failed to allocate tx consumer\n"); |
425 | return -ENOMEM; | 483 | return -ENOMEM; |
426 | } | 484 | } |
427 | *(tx_ring->hw_consumer) = 0; | ||
428 | 485 | ||
429 | /* cmd desc ring */ | 486 | /* cmd desc ring */ |
430 | addr = pci_alloc_consistent(pdev, TX_DESC_RINGSIZE(tx_ring), | 487 | addr = dma_alloc_coherent(&pdev->dev, TX_DESC_RINGSIZE(tx_ring), |
431 | &tx_ring->phys_addr); | 488 | &tx_ring->phys_addr, GFP_KERNEL); |
432 | 489 | ||
433 | if (addr == NULL) { | 490 | if (addr == NULL) { |
434 | dev_err(&pdev->dev, "failed to allocate tx desc ring\n"); | 491 | dev_err(&pdev->dev, "failed to allocate tx desc ring\n"); |
@@ -440,9 +497,9 @@ int qlcnic_alloc_hw_resources(struct qlcnic_adapter *adapter) | |||
440 | 497 | ||
441 | for (ring = 0; ring < adapter->max_rds_rings; ring++) { | 498 | for (ring = 0; ring < adapter->max_rds_rings; ring++) { |
442 | rds_ring = &recv_ctx->rds_rings[ring]; | 499 | rds_ring = &recv_ctx->rds_rings[ring]; |
443 | addr = pci_alloc_consistent(adapter->pdev, | 500 | addr = dma_alloc_coherent(&adapter->pdev->dev, |
444 | RCV_DESC_RINGSIZE(rds_ring), | 501 | RCV_DESC_RINGSIZE(rds_ring), |
445 | &rds_ring->phys_addr); | 502 | &rds_ring->phys_addr, GFP_KERNEL); |
446 | if (addr == NULL) { | 503 | if (addr == NULL) { |
447 | dev_err(&pdev->dev, | 504 | dev_err(&pdev->dev, |
448 | "failed to allocate rds ring [%d]\n", ring); | 505 | "failed to allocate rds ring [%d]\n", ring); |
@@ -456,9 +513,9 @@ int qlcnic_alloc_hw_resources(struct qlcnic_adapter *adapter) | |||
456 | for (ring = 0; ring < adapter->max_sds_rings; ring++) { | 513 | for (ring = 0; ring < adapter->max_sds_rings; ring++) { |
457 | sds_ring = &recv_ctx->sds_rings[ring]; | 514 | sds_ring = &recv_ctx->sds_rings[ring]; |
458 | 515 | ||
459 | addr = pci_alloc_consistent(adapter->pdev, | 516 | addr = dma_alloc_coherent(&adapter->pdev->dev, |
460 | STATUS_DESC_RINGSIZE(sds_ring), | 517 | STATUS_DESC_RINGSIZE(sds_ring), |
461 | &sds_ring->phys_addr); | 518 | &sds_ring->phys_addr, GFP_KERNEL); |
462 | if (addr == NULL) { | 519 | if (addr == NULL) { |
463 | dev_err(&pdev->dev, | 520 | dev_err(&pdev->dev, |
464 | "failed to allocate sds ring [%d]\n", ring); | 521 | "failed to allocate sds ring [%d]\n", ring); |
@@ -480,6 +537,11 @@ int qlcnic_fw_create_ctx(struct qlcnic_adapter *adapter) | |||
480 | { | 537 | { |
481 | int err; | 538 | int err; |
482 | 539 | ||
540 | if (adapter->flags & QLCNIC_NEED_FLR) { | ||
541 | pci_reset_function(adapter->pdev); | ||
542 | adapter->flags &= ~QLCNIC_NEED_FLR; | ||
543 | } | ||
544 | |||
483 | err = qlcnic_fw_cmd_create_rx_ctx(adapter); | 545 | err = qlcnic_fw_cmd_create_rx_ctx(adapter); |
484 | if (err) | 546 | if (err) |
485 | return err; | 547 | return err; |
@@ -513,11 +575,11 @@ void qlcnic_free_hw_resources(struct qlcnic_adapter *adapter) | |||
513 | struct qlcnic_host_tx_ring *tx_ring; | 575 | struct qlcnic_host_tx_ring *tx_ring; |
514 | int ring; | 576 | int ring; |
515 | 577 | ||
516 | recv_ctx = &adapter->recv_ctx; | 578 | recv_ctx = adapter->recv_ctx; |
517 | 579 | ||
518 | tx_ring = adapter->tx_ring; | 580 | tx_ring = adapter->tx_ring; |
519 | if (tx_ring->hw_consumer != NULL) { | 581 | if (tx_ring->hw_consumer != NULL) { |
520 | pci_free_consistent(adapter->pdev, | 582 | dma_free_coherent(&adapter->pdev->dev, |
521 | sizeof(u32), | 583 | sizeof(u32), |
522 | tx_ring->hw_consumer, | 584 | tx_ring->hw_consumer, |
523 | tx_ring->hw_cons_phys_addr); | 585 | tx_ring->hw_cons_phys_addr); |
@@ -525,7 +587,7 @@ void qlcnic_free_hw_resources(struct qlcnic_adapter *adapter) | |||
525 | } | 587 | } |
526 | 588 | ||
527 | if (tx_ring->desc_head != NULL) { | 589 | if (tx_ring->desc_head != NULL) { |
528 | pci_free_consistent(adapter->pdev, | 590 | dma_free_coherent(&adapter->pdev->dev, |
529 | TX_DESC_RINGSIZE(tx_ring), | 591 | TX_DESC_RINGSIZE(tx_ring), |
530 | tx_ring->desc_head, tx_ring->phys_addr); | 592 | tx_ring->desc_head, tx_ring->phys_addr); |
531 | tx_ring->desc_head = NULL; | 593 | tx_ring->desc_head = NULL; |
@@ -535,7 +597,7 @@ void qlcnic_free_hw_resources(struct qlcnic_adapter *adapter) | |||
535 | rds_ring = &recv_ctx->rds_rings[ring]; | 597 | rds_ring = &recv_ctx->rds_rings[ring]; |
536 | 598 | ||
537 | if (rds_ring->desc_head != NULL) { | 599 | if (rds_ring->desc_head != NULL) { |
538 | pci_free_consistent(adapter->pdev, | 600 | dma_free_coherent(&adapter->pdev->dev, |
539 | RCV_DESC_RINGSIZE(rds_ring), | 601 | RCV_DESC_RINGSIZE(rds_ring), |
540 | rds_ring->desc_head, | 602 | rds_ring->desc_head, |
541 | rds_ring->phys_addr); | 603 | rds_ring->phys_addr); |
@@ -547,7 +609,7 @@ void qlcnic_free_hw_resources(struct qlcnic_adapter *adapter) | |||
547 | sds_ring = &recv_ctx->sds_rings[ring]; | 609 | sds_ring = &recv_ctx->sds_rings[ring]; |
548 | 610 | ||
549 | if (sds_ring->desc_head != NULL) { | 611 | if (sds_ring->desc_head != NULL) { |
550 | pci_free_consistent(adapter->pdev, | 612 | dma_free_coherent(&adapter->pdev->dev, |
551 | STATUS_DESC_RINGSIZE(sds_ring), | 613 | STATUS_DESC_RINGSIZE(sds_ring), |
552 | sds_ring->desc_head, | 614 | sds_ring->desc_head, |
553 | sds_ring->phys_addr); | 615 | sds_ring->phys_addr); |
@@ -556,32 +618,6 @@ void qlcnic_free_hw_resources(struct qlcnic_adapter *adapter) | |||
556 | } | 618 | } |
557 | } | 619 | } |
558 | 620 | ||
559 | /* Set MAC address of a NIC partition */ | ||
560 | int qlcnic_set_mac_address(struct qlcnic_adapter *adapter, u8* mac) | ||
561 | { | ||
562 | int err = 0; | ||
563 | u32 arg1, arg2, arg3; | ||
564 | |||
565 | arg1 = adapter->ahw.pci_func | BIT_9; | ||
566 | arg2 = mac[0] | (mac[1] << 8) | (mac[2] << 16) | (mac[3] << 24); | ||
567 | arg3 = mac[4] | (mac[5] << 16); | ||
568 | |||
569 | err = qlcnic_issue_cmd(adapter, | ||
570 | adapter->ahw.pci_func, | ||
571 | adapter->fw_hal_version, | ||
572 | arg1, | ||
573 | arg2, | ||
574 | arg3, | ||
575 | QLCNIC_CDRP_CMD_MAC_ADDRESS); | ||
576 | |||
577 | if (err != QLCNIC_RCODE_SUCCESS) { | ||
578 | dev_err(&adapter->pdev->dev, | ||
579 | "Failed to set mac address%d\n", err); | ||
580 | err = -EIO; | ||
581 | } | ||
582 | |||
583 | return err; | ||
584 | } | ||
585 | 621 | ||
586 | /* Get MAC address of a NIC partition */ | 622 | /* Get MAC address of a NIC partition */ |
587 | int qlcnic_get_mac_address(struct qlcnic_adapter *adapter, u8 *mac) | 623 | int qlcnic_get_mac_address(struct qlcnic_adapter *adapter, u8 *mac) |
@@ -589,9 +625,9 @@ int qlcnic_get_mac_address(struct qlcnic_adapter *adapter, u8 *mac) | |||
589 | int err; | 625 | int err; |
590 | u32 arg1; | 626 | u32 arg1; |
591 | 627 | ||
592 | arg1 = adapter->ahw.pci_func | BIT_8; | 628 | arg1 = adapter->ahw->pci_func | BIT_8; |
593 | err = qlcnic_issue_cmd(adapter, | 629 | err = qlcnic_issue_cmd(adapter, |
594 | adapter->ahw.pci_func, | 630 | adapter->ahw->pci_func, |
595 | adapter->fw_hal_version, | 631 | adapter->fw_hal_version, |
596 | arg1, | 632 | arg1, |
597 | 0, | 633 | 0, |
@@ -620,15 +656,15 @@ int qlcnic_get_nic_info(struct qlcnic_adapter *adapter, | |||
620 | void *nic_info_addr; | 656 | void *nic_info_addr; |
621 | size_t nic_size = sizeof(struct qlcnic_info); | 657 | size_t nic_size = sizeof(struct qlcnic_info); |
622 | 658 | ||
623 | nic_info_addr = pci_alloc_consistent(adapter->pdev, | 659 | nic_info_addr = dma_alloc_coherent(&adapter->pdev->dev, nic_size, |
624 | nic_size, &nic_dma_t); | 660 | &nic_dma_t, GFP_KERNEL); |
625 | if (!nic_info_addr) | 661 | if (!nic_info_addr) |
626 | return -ENOMEM; | 662 | return -ENOMEM; |
627 | memset(nic_info_addr, 0, nic_size); | 663 | memset(nic_info_addr, 0, nic_size); |
628 | 664 | ||
629 | nic_info = (struct qlcnic_info *) nic_info_addr; | 665 | nic_info = (struct qlcnic_info *) nic_info_addr; |
630 | err = qlcnic_issue_cmd(adapter, | 666 | err = qlcnic_issue_cmd(adapter, |
631 | adapter->ahw.pci_func, | 667 | adapter->ahw->pci_func, |
632 | adapter->fw_hal_version, | 668 | adapter->fw_hal_version, |
633 | MSD(nic_dma_t), | 669 | MSD(nic_dma_t), |
634 | LSD(nic_dma_t), | 670 | LSD(nic_dma_t), |
@@ -661,7 +697,8 @@ int qlcnic_get_nic_info(struct qlcnic_adapter *adapter, | |||
661 | err = -EIO; | 697 | err = -EIO; |
662 | } | 698 | } |
663 | 699 | ||
664 | pci_free_consistent(adapter->pdev, nic_size, nic_info_addr, nic_dma_t); | 700 | dma_free_coherent(&adapter->pdev->dev, nic_size, nic_info_addr, |
701 | nic_dma_t); | ||
665 | return err; | 702 | return err; |
666 | } | 703 | } |
667 | 704 | ||
@@ -677,8 +714,8 @@ int qlcnic_set_nic_info(struct qlcnic_adapter *adapter, struct qlcnic_info *nic) | |||
677 | if (adapter->op_mode != QLCNIC_MGMT_FUNC) | 714 | if (adapter->op_mode != QLCNIC_MGMT_FUNC) |
678 | return err; | 715 | return err; |
679 | 716 | ||
680 | nic_info_addr = pci_alloc_consistent(adapter->pdev, nic_size, | 717 | nic_info_addr = dma_alloc_coherent(&adapter->pdev->dev, nic_size, |
681 | &nic_dma_t); | 718 | &nic_dma_t, GFP_KERNEL); |
682 | if (!nic_info_addr) | 719 | if (!nic_info_addr) |
683 | return -ENOMEM; | 720 | return -ENOMEM; |
684 | 721 | ||
@@ -697,7 +734,7 @@ int qlcnic_set_nic_info(struct qlcnic_adapter *adapter, struct qlcnic_info *nic) | |||
697 | nic_info->max_tx_bw = cpu_to_le16(nic->max_tx_bw); | 734 | nic_info->max_tx_bw = cpu_to_le16(nic->max_tx_bw); |
698 | 735 | ||
699 | err = qlcnic_issue_cmd(adapter, | 736 | err = qlcnic_issue_cmd(adapter, |
700 | adapter->ahw.pci_func, | 737 | adapter->ahw->pci_func, |
701 | adapter->fw_hal_version, | 738 | adapter->fw_hal_version, |
702 | MSD(nic_dma_t), | 739 | MSD(nic_dma_t), |
703 | LSD(nic_dma_t), | 740 | LSD(nic_dma_t), |
@@ -710,7 +747,8 @@ int qlcnic_set_nic_info(struct qlcnic_adapter *adapter, struct qlcnic_info *nic) | |||
710 | err = -EIO; | 747 | err = -EIO; |
711 | } | 748 | } |
712 | 749 | ||
713 | pci_free_consistent(adapter->pdev, nic_size, nic_info_addr, nic_dma_t); | 750 | dma_free_coherent(&adapter->pdev->dev, nic_size, nic_info_addr, |
751 | nic_dma_t); | ||
714 | return err; | 752 | return err; |
715 | } | 753 | } |
716 | 754 | ||
@@ -725,15 +763,15 @@ int qlcnic_get_pci_info(struct qlcnic_adapter *adapter, | |||
725 | size_t npar_size = sizeof(struct qlcnic_pci_info); | 763 | size_t npar_size = sizeof(struct qlcnic_pci_info); |
726 | size_t pci_size = npar_size * QLCNIC_MAX_PCI_FUNC; | 764 | size_t pci_size = npar_size * QLCNIC_MAX_PCI_FUNC; |
727 | 765 | ||
728 | pci_info_addr = pci_alloc_consistent(adapter->pdev, pci_size, | 766 | pci_info_addr = dma_alloc_coherent(&adapter->pdev->dev, pci_size, |
729 | &pci_info_dma_t); | 767 | &pci_info_dma_t, GFP_KERNEL); |
730 | if (!pci_info_addr) | 768 | if (!pci_info_addr) |
731 | return -ENOMEM; | 769 | return -ENOMEM; |
732 | memset(pci_info_addr, 0, pci_size); | 770 | memset(pci_info_addr, 0, pci_size); |
733 | 771 | ||
734 | npar = (struct qlcnic_pci_info *) pci_info_addr; | 772 | npar = (struct qlcnic_pci_info *) pci_info_addr; |
735 | err = qlcnic_issue_cmd(adapter, | 773 | err = qlcnic_issue_cmd(adapter, |
736 | adapter->ahw.pci_func, | 774 | adapter->ahw->pci_func, |
737 | adapter->fw_hal_version, | 775 | adapter->fw_hal_version, |
738 | MSD(pci_info_dma_t), | 776 | MSD(pci_info_dma_t), |
739 | LSD(pci_info_dma_t), | 777 | LSD(pci_info_dma_t), |
@@ -742,15 +780,15 @@ int qlcnic_get_pci_info(struct qlcnic_adapter *adapter, | |||
742 | 780 | ||
743 | if (err == QLCNIC_RCODE_SUCCESS) { | 781 | if (err == QLCNIC_RCODE_SUCCESS) { |
744 | for (i = 0; i < QLCNIC_MAX_PCI_FUNC; i++, npar++, pci_info++) { | 782 | for (i = 0; i < QLCNIC_MAX_PCI_FUNC; i++, npar++, pci_info++) { |
745 | pci_info->id = le32_to_cpu(npar->id); | 783 | pci_info->id = le16_to_cpu(npar->id); |
746 | pci_info->active = le32_to_cpu(npar->active); | 784 | pci_info->active = le16_to_cpu(npar->active); |
747 | pci_info->type = le32_to_cpu(npar->type); | 785 | pci_info->type = le16_to_cpu(npar->type); |
748 | pci_info->default_port = | 786 | pci_info->default_port = |
749 | le32_to_cpu(npar->default_port); | 787 | le16_to_cpu(npar->default_port); |
750 | pci_info->tx_min_bw = | 788 | pci_info->tx_min_bw = |
751 | le32_to_cpu(npar->tx_min_bw); | 789 | le16_to_cpu(npar->tx_min_bw); |
752 | pci_info->tx_max_bw = | 790 | pci_info->tx_max_bw = |
753 | le32_to_cpu(npar->tx_max_bw); | 791 | le16_to_cpu(npar->tx_max_bw); |
754 | memcpy(pci_info->mac, npar->mac, ETH_ALEN); | 792 | memcpy(pci_info->mac, npar->mac, ETH_ALEN); |
755 | } | 793 | } |
756 | } else { | 794 | } else { |
@@ -759,227 +797,324 @@ int qlcnic_get_pci_info(struct qlcnic_adapter *adapter, | |||
759 | err = -EIO; | 797 | err = -EIO; |
760 | } | 798 | } |
761 | 799 | ||
762 | pci_free_consistent(adapter->pdev, pci_size, pci_info_addr, | 800 | dma_free_coherent(&adapter->pdev->dev, pci_size, pci_info_addr, |
763 | pci_info_dma_t); | 801 | pci_info_dma_t); |
764 | return err; | 802 | return err; |
765 | } | 803 | } |
766 | 804 | ||
767 | /* Reset a NIC partition */ | 805 | /* Configure eSwitch for port mirroring */ |
768 | 806 | int qlcnic_config_port_mirroring(struct qlcnic_adapter *adapter, u8 id, | |
769 | int qlcnic_reset_partition(struct qlcnic_adapter *adapter, u8 func_no) | 807 | u8 enable_mirroring, u8 pci_func) |
770 | { | 808 | { |
771 | int err = -EIO; | 809 | int err = -EIO; |
810 | u32 arg1; | ||
772 | 811 | ||
773 | if (adapter->op_mode != QLCNIC_MGMT_FUNC) | 812 | if (adapter->op_mode != QLCNIC_MGMT_FUNC || |
813 | !(adapter->eswitch[id].flags & QLCNIC_SWITCH_ENABLE)) | ||
774 | return err; | 814 | return err; |
775 | 815 | ||
816 | arg1 = id | (enable_mirroring ? BIT_4 : 0); | ||
817 | arg1 |= pci_func << 8; | ||
818 | |||
776 | err = qlcnic_issue_cmd(adapter, | 819 | err = qlcnic_issue_cmd(adapter, |
777 | adapter->ahw.pci_func, | 820 | adapter->ahw->pci_func, |
778 | adapter->fw_hal_version, | 821 | adapter->fw_hal_version, |
779 | func_no, | 822 | arg1, |
780 | 0, | 823 | 0, |
781 | 0, | 824 | 0, |
782 | QLCNIC_CDRP_CMD_RESET_NPAR); | 825 | QLCNIC_CDRP_CMD_SET_PORTMIRRORING); |
783 | 826 | ||
784 | if (err != QLCNIC_RCODE_SUCCESS) { | 827 | if (err != QLCNIC_RCODE_SUCCESS) { |
785 | dev_err(&adapter->pdev->dev, | 828 | dev_err(&adapter->pdev->dev, |
786 | "Failed to issue reset partition%d\n", err); | 829 | "Failed to configure port mirroring%d on eswitch:%d\n", |
787 | err = -EIO; | 830 | pci_func, id); |
831 | } else { | ||
832 | dev_info(&adapter->pdev->dev, | ||
833 | "Configured eSwitch %d for port mirroring:%d\n", | ||
834 | id, pci_func); | ||
788 | } | 835 | } |
789 | 836 | ||
790 | return err; | 837 | return err; |
791 | } | 838 | } |
792 | 839 | ||
793 | /* Get eSwitch Capabilities */ | 840 | int qlcnic_get_port_stats(struct qlcnic_adapter *adapter, const u8 func, |
794 | int qlcnic_get_eswitch_capabilities(struct qlcnic_adapter *adapter, u8 port, | 841 | const u8 rx_tx, struct __qlcnic_esw_statistics *esw_stats) { |
795 | struct qlcnic_eswitch *eswitch) | ||
796 | { | ||
797 | int err = -EIO; | ||
798 | u32 arg1, arg2; | ||
799 | 842 | ||
800 | if (adapter->op_mode == QLCNIC_NON_PRIV_FUNC) | 843 | size_t stats_size = sizeof(struct __qlcnic_esw_statistics); |
801 | return err; | 844 | struct __qlcnic_esw_statistics *stats; |
845 | dma_addr_t stats_dma_t; | ||
846 | void *stats_addr; | ||
847 | u32 arg1; | ||
848 | int err; | ||
802 | 849 | ||
803 | err = qlcnic_issue_cmd(adapter, | 850 | if (esw_stats == NULL) |
804 | adapter->ahw.pci_func, | 851 | return -ENOMEM; |
805 | adapter->fw_hal_version, | ||
806 | port, | ||
807 | 0, | ||
808 | 0, | ||
809 | QLCNIC_CDRP_CMD_GET_ESWITCH_CAPABILITY); | ||
810 | 852 | ||
811 | if (err == QLCNIC_RCODE_SUCCESS) { | 853 | if (adapter->op_mode != QLCNIC_MGMT_FUNC && |
812 | arg1 = QLCRD32(adapter, QLCNIC_ARG1_CRB_OFFSET); | 854 | func != adapter->ahw->pci_func) { |
813 | arg2 = QLCRD32(adapter, QLCNIC_ARG2_CRB_OFFSET); | ||
814 | |||
815 | eswitch->port = arg1 & 0xf; | ||
816 | eswitch->active_vports = LSB(arg2); | ||
817 | eswitch->max_ucast_filters = MSB(arg2); | ||
818 | eswitch->max_active_vlans = LSB(MSW(arg2)); | ||
819 | if (arg1 & BIT_6) | ||
820 | eswitch->flags |= QLCNIC_SWITCH_VLAN_FILTERING; | ||
821 | if (arg1 & BIT_7) | ||
822 | eswitch->flags |= QLCNIC_SWITCH_PROMISC_MODE; | ||
823 | if (arg1 & BIT_8) | ||
824 | eswitch->flags |= QLCNIC_SWITCH_PORT_MIRRORING; | ||
825 | } else { | ||
826 | dev_err(&adapter->pdev->dev, | 855 | dev_err(&adapter->pdev->dev, |
827 | "Failed to get eswitch capabilities%d\n", err); | 856 | "Not privilege to query stats for func=%d", func); |
857 | return -EIO; | ||
828 | } | 858 | } |
829 | 859 | ||
830 | return err; | 860 | stats_addr = dma_alloc_coherent(&adapter->pdev->dev, stats_size, |
831 | } | 861 | &stats_dma_t, GFP_KERNEL); |
862 | if (!stats_addr) { | ||
863 | dev_err(&adapter->pdev->dev, "Unable to allocate memory\n"); | ||
864 | return -ENOMEM; | ||
865 | } | ||
866 | memset(stats_addr, 0, stats_size); | ||
832 | 867 | ||
833 | /* Get current status of eswitch */ | 868 | arg1 = func | QLCNIC_STATS_VERSION << 8 | QLCNIC_STATS_PORT << 12; |
834 | int qlcnic_get_eswitch_status(struct qlcnic_adapter *adapter, u8 port, | 869 | arg1 |= rx_tx << 15 | stats_size << 16; |
835 | struct qlcnic_eswitch *eswitch) | ||
836 | { | ||
837 | int err = -EIO; | ||
838 | u32 arg1, arg2; | ||
839 | |||
840 | if (adapter->op_mode != QLCNIC_MGMT_FUNC) | ||
841 | return err; | ||
842 | 870 | ||
843 | err = qlcnic_issue_cmd(adapter, | 871 | err = qlcnic_issue_cmd(adapter, |
844 | adapter->ahw.pci_func, | 872 | adapter->ahw->pci_func, |
845 | adapter->fw_hal_version, | 873 | adapter->fw_hal_version, |
846 | port, | 874 | arg1, |
847 | 0, | 875 | MSD(stats_dma_t), |
848 | 0, | 876 | LSD(stats_dma_t), |
849 | QLCNIC_CDRP_CMD_GET_ESWITCH_STATUS); | 877 | QLCNIC_CDRP_CMD_GET_ESWITCH_STATS); |
850 | 878 | ||
851 | if (err == QLCNIC_RCODE_SUCCESS) { | 879 | if (!err) { |
852 | arg1 = QLCRD32(adapter, QLCNIC_ARG1_CRB_OFFSET); | 880 | stats = (struct __qlcnic_esw_statistics *)stats_addr; |
853 | arg2 = QLCRD32(adapter, QLCNIC_ARG2_CRB_OFFSET); | 881 | esw_stats->context_id = le16_to_cpu(stats->context_id); |
854 | 882 | esw_stats->version = le16_to_cpu(stats->version); | |
855 | eswitch->port = arg1 & 0xf; | 883 | esw_stats->size = le16_to_cpu(stats->size); |
856 | eswitch->active_vports = LSB(arg2); | 884 | esw_stats->multicast_frames = |
857 | eswitch->active_ucast_filters = MSB(arg2); | 885 | le64_to_cpu(stats->multicast_frames); |
858 | eswitch->active_vlans = LSB(MSW(arg2)); | 886 | esw_stats->broadcast_frames = |
859 | if (arg1 & BIT_6) | 887 | le64_to_cpu(stats->broadcast_frames); |
860 | eswitch->flags |= QLCNIC_SWITCH_VLAN_FILTERING; | 888 | esw_stats->unicast_frames = le64_to_cpu(stats->unicast_frames); |
861 | if (arg1 & BIT_8) | 889 | esw_stats->dropped_frames = le64_to_cpu(stats->dropped_frames); |
862 | eswitch->flags |= QLCNIC_SWITCH_PORT_MIRRORING; | 890 | esw_stats->local_frames = le64_to_cpu(stats->local_frames); |
863 | 891 | esw_stats->errors = le64_to_cpu(stats->errors); | |
864 | } else { | 892 | esw_stats->numbytes = le64_to_cpu(stats->numbytes); |
865 | dev_err(&adapter->pdev->dev, | ||
866 | "Failed to get eswitch status%d\n", err); | ||
867 | } | 893 | } |
868 | 894 | ||
895 | dma_free_coherent(&adapter->pdev->dev, stats_size, stats_addr, | ||
896 | stats_dma_t); | ||
869 | return err; | 897 | return err; |
870 | } | 898 | } |
871 | 899 | ||
872 | /* Enable/Disable eSwitch */ | 900 | int qlcnic_get_eswitch_stats(struct qlcnic_adapter *adapter, const u8 eswitch, |
873 | int qlcnic_toggle_eswitch(struct qlcnic_adapter *adapter, u8 id, u8 enable) | 901 | const u8 rx_tx, struct __qlcnic_esw_statistics *esw_stats) { |
902 | |||
903 | struct __qlcnic_esw_statistics port_stats; | ||
904 | u8 i; | ||
905 | int ret = -EIO; | ||
906 | |||
907 | if (esw_stats == NULL) | ||
908 | return -ENOMEM; | ||
909 | if (adapter->op_mode != QLCNIC_MGMT_FUNC) | ||
910 | return -EIO; | ||
911 | if (adapter->npars == NULL) | ||
912 | return -EIO; | ||
913 | |||
914 | memset(esw_stats, 0, sizeof(u64)); | ||
915 | esw_stats->unicast_frames = QLCNIC_ESW_STATS_NOT_AVAIL; | ||
916 | esw_stats->multicast_frames = QLCNIC_ESW_STATS_NOT_AVAIL; | ||
917 | esw_stats->broadcast_frames = QLCNIC_ESW_STATS_NOT_AVAIL; | ||
918 | esw_stats->dropped_frames = QLCNIC_ESW_STATS_NOT_AVAIL; | ||
919 | esw_stats->errors = QLCNIC_ESW_STATS_NOT_AVAIL; | ||
920 | esw_stats->local_frames = QLCNIC_ESW_STATS_NOT_AVAIL; | ||
921 | esw_stats->numbytes = QLCNIC_ESW_STATS_NOT_AVAIL; | ||
922 | esw_stats->context_id = eswitch; | ||
923 | |||
924 | for (i = 0; i < QLCNIC_MAX_PCI_FUNC; i++) { | ||
925 | if (adapter->npars[i].phy_port != eswitch) | ||
926 | continue; | ||
927 | |||
928 | memset(&port_stats, 0, sizeof(struct __qlcnic_esw_statistics)); | ||
929 | if (qlcnic_get_port_stats(adapter, i, rx_tx, &port_stats)) | ||
930 | continue; | ||
931 | |||
932 | esw_stats->size = port_stats.size; | ||
933 | esw_stats->version = port_stats.version; | ||
934 | QLCNIC_ADD_ESW_STATS(esw_stats->unicast_frames, | ||
935 | port_stats.unicast_frames); | ||
936 | QLCNIC_ADD_ESW_STATS(esw_stats->multicast_frames, | ||
937 | port_stats.multicast_frames); | ||
938 | QLCNIC_ADD_ESW_STATS(esw_stats->broadcast_frames, | ||
939 | port_stats.broadcast_frames); | ||
940 | QLCNIC_ADD_ESW_STATS(esw_stats->dropped_frames, | ||
941 | port_stats.dropped_frames); | ||
942 | QLCNIC_ADD_ESW_STATS(esw_stats->errors, | ||
943 | port_stats.errors); | ||
944 | QLCNIC_ADD_ESW_STATS(esw_stats->local_frames, | ||
945 | port_stats.local_frames); | ||
946 | QLCNIC_ADD_ESW_STATS(esw_stats->numbytes, | ||
947 | port_stats.numbytes); | ||
948 | ret = 0; | ||
949 | } | ||
950 | return ret; | ||
951 | } | ||
952 | |||
953 | int qlcnic_clear_esw_stats(struct qlcnic_adapter *adapter, const u8 func_esw, | ||
954 | const u8 port, const u8 rx_tx) | ||
874 | { | 955 | { |
875 | int err = -EIO; | 956 | |
876 | u32 arg1, arg2; | 957 | u32 arg1; |
877 | struct qlcnic_eswitch *eswitch; | ||
878 | 958 | ||
879 | if (adapter->op_mode != QLCNIC_MGMT_FUNC) | 959 | if (adapter->op_mode != QLCNIC_MGMT_FUNC) |
880 | return err; | 960 | return -EIO; |
881 | 961 | ||
882 | eswitch = &adapter->eswitch[id]; | 962 | if (func_esw == QLCNIC_STATS_PORT) { |
883 | if (!eswitch) | 963 | if (port >= QLCNIC_MAX_PCI_FUNC) |
884 | return err; | 964 | goto err_ret; |
965 | } else if (func_esw == QLCNIC_STATS_ESWITCH) { | ||
966 | if (port >= QLCNIC_NIU_MAX_XG_PORTS) | ||
967 | goto err_ret; | ||
968 | } else { | ||
969 | goto err_ret; | ||
970 | } | ||
885 | 971 | ||
886 | arg1 = eswitch->port | (enable ? BIT_4 : 0); | 972 | if (rx_tx > QLCNIC_QUERY_TX_COUNTER) |
887 | arg2 = eswitch->active_vports | (eswitch->max_ucast_filters << 8) | | 973 | goto err_ret; |
888 | (eswitch->max_active_vlans << 16); | 974 | |
889 | err = qlcnic_issue_cmd(adapter, | 975 | arg1 = port | QLCNIC_STATS_VERSION << 8 | func_esw << 12; |
890 | adapter->ahw.pci_func, | 976 | arg1 |= BIT_14 | rx_tx << 15; |
977 | |||
978 | return qlcnic_issue_cmd(adapter, | ||
979 | adapter->ahw->pci_func, | ||
891 | adapter->fw_hal_version, | 980 | adapter->fw_hal_version, |
892 | arg1, | 981 | arg1, |
893 | arg2, | ||
894 | 0, | 982 | 0, |
895 | QLCNIC_CDRP_CMD_TOGGLE_ESWITCH); | 983 | 0, |
896 | 984 | QLCNIC_CDRP_CMD_GET_ESWITCH_STATS); | |
897 | if (err != QLCNIC_RCODE_SUCCESS) { | ||
898 | dev_err(&adapter->pdev->dev, | ||
899 | "Failed to enable eswitch%d\n", eswitch->port); | ||
900 | eswitch->flags &= ~QLCNIC_SWITCH_ENABLE; | ||
901 | err = -EIO; | ||
902 | } else { | ||
903 | eswitch->flags |= QLCNIC_SWITCH_ENABLE; | ||
904 | dev_info(&adapter->pdev->dev, | ||
905 | "Enabled eSwitch for port %d\n", eswitch->port); | ||
906 | } | ||
907 | 985 | ||
908 | return err; | 986 | err_ret: |
987 | dev_err(&adapter->pdev->dev, "Invalid argument func_esw=%d port=%d" | ||
988 | "rx_ctx=%d\n", func_esw, port, rx_tx); | ||
989 | return -EIO; | ||
909 | } | 990 | } |
910 | 991 | ||
911 | /* Configure eSwitch for port mirroring */ | 992 | static int |
912 | int qlcnic_config_port_mirroring(struct qlcnic_adapter *adapter, u8 id, | 993 | __qlcnic_get_eswitch_port_config(struct qlcnic_adapter *adapter, |
913 | u8 enable_mirroring, u8 pci_func) | 994 | u32 *arg1, u32 *arg2) |
914 | { | 995 | { |
915 | int err = -EIO; | 996 | int err = -EIO; |
916 | u32 arg1; | 997 | u8 pci_func; |
917 | 998 | pci_func = (*arg1 >> 8); | |
918 | if (adapter->op_mode != QLCNIC_MGMT_FUNC || | ||
919 | !(adapter->eswitch[id].flags & QLCNIC_SWITCH_ENABLE)) | ||
920 | return err; | ||
921 | |||
922 | arg1 = id | (enable_mirroring ? BIT_4 : 0); | ||
923 | arg1 |= pci_func << 8; | ||
924 | |||
925 | err = qlcnic_issue_cmd(adapter, | 999 | err = qlcnic_issue_cmd(adapter, |
926 | adapter->ahw.pci_func, | 1000 | adapter->ahw->pci_func, |
927 | adapter->fw_hal_version, | 1001 | adapter->fw_hal_version, |
928 | arg1, | 1002 | *arg1, |
929 | 0, | 1003 | 0, |
930 | 0, | 1004 | 0, |
931 | QLCNIC_CDRP_CMD_SET_PORTMIRRORING); | 1005 | QLCNIC_CDRP_CMD_GET_ESWITCH_PORT_CONFIG); |
932 | 1006 | ||
933 | if (err != QLCNIC_RCODE_SUCCESS) { | 1007 | if (err == QLCNIC_RCODE_SUCCESS) { |
934 | dev_err(&adapter->pdev->dev, | 1008 | *arg1 = QLCRD32(adapter, QLCNIC_ARG1_CRB_OFFSET); |
935 | "Failed to configure port mirroring%d on eswitch:%d\n", | 1009 | *arg2 = QLCRD32(adapter, QLCNIC_ARG2_CRB_OFFSET); |
936 | pci_func, id); | ||
937 | } else { | ||
938 | dev_info(&adapter->pdev->dev, | 1010 | dev_info(&adapter->pdev->dev, |
939 | "Configured eSwitch %d for port mirroring:%d\n", | 1011 | "eSwitch port config for pci func %d\n", pci_func); |
940 | id, pci_func); | 1012 | } else { |
1013 | dev_err(&adapter->pdev->dev, | ||
1014 | "Failed to get eswitch port config for pci func %d\n", | ||
1015 | pci_func); | ||
941 | } | 1016 | } |
942 | |||
943 | return err; | 1017 | return err; |
944 | } | 1018 | } |
945 | 1019 | /* Configure eSwitch port | |
946 | /* Configure eSwitch port */ | 1020 | op_mode = 0 for setting default port behavior |
947 | int qlcnic_config_switch_port(struct qlcnic_adapter *adapter, u8 id, | 1021 | op_mode = 1 for setting vlan id |
948 | int vlan_tagging, u8 discard_tagged, u8 promsc_mode, | 1022 | op_mode = 2 for deleting vlan id |
949 | u8 mac_learn, u8 pci_func, u16 vlan_id) | 1023 | op_type = 0 for vlan_id |
1024 | op_type = 1 for port vlan_id | ||
1025 | */ | ||
1026 | int qlcnic_config_switch_port(struct qlcnic_adapter *adapter, | ||
1027 | struct qlcnic_esw_func_cfg *esw_cfg) | ||
950 | { | 1028 | { |
951 | int err = -EIO; | 1029 | int err = -EIO; |
952 | u32 arg1; | 1030 | u32 arg1, arg2 = 0; |
953 | struct qlcnic_eswitch *eswitch; | 1031 | u8 pci_func; |
954 | 1032 | ||
955 | if (adapter->op_mode != QLCNIC_MGMT_FUNC) | 1033 | if (adapter->op_mode != QLCNIC_MGMT_FUNC) |
956 | return err; | 1034 | return err; |
1035 | pci_func = esw_cfg->pci_func; | ||
1036 | arg1 = (adapter->npars[pci_func].phy_port & BIT_0); | ||
1037 | arg1 |= (pci_func << 8); | ||
957 | 1038 | ||
958 | eswitch = &adapter->eswitch[id]; | 1039 | if (__qlcnic_get_eswitch_port_config(adapter, &arg1, &arg2)) |
959 | if (!(eswitch->flags & QLCNIC_SWITCH_ENABLE)) | ||
960 | return err; | 1040 | return err; |
961 | 1041 | arg1 &= ~(0x0ff << 8); | |
962 | arg1 = eswitch->port | (discard_tagged ? BIT_4 : 0); | 1042 | arg1 |= (pci_func << 8); |
963 | arg1 |= (promsc_mode ? BIT_6 : 0) | (mac_learn ? BIT_7 : 0); | 1043 | arg1 &= ~(BIT_2 | BIT_3); |
964 | arg1 |= pci_func << 8; | 1044 | switch (esw_cfg->op_mode) { |
965 | if (vlan_tagging) | 1045 | case QLCNIC_PORT_DEFAULTS: |
966 | arg1 |= BIT_5 | (vlan_id << 16); | 1046 | arg1 |= (BIT_4 | BIT_6 | BIT_7); |
1047 | arg2 |= (BIT_0 | BIT_1); | ||
1048 | if (adapter->capabilities & QLCNIC_FW_CAPABILITY_TSO) | ||
1049 | arg2 |= (BIT_2 | BIT_3); | ||
1050 | if (!(esw_cfg->discard_tagged)) | ||
1051 | arg1 &= ~BIT_4; | ||
1052 | if (!(esw_cfg->promisc_mode)) | ||
1053 | arg1 &= ~BIT_6; | ||
1054 | if (!(esw_cfg->mac_override)) | ||
1055 | arg1 &= ~BIT_7; | ||
1056 | if (!(esw_cfg->mac_anti_spoof)) | ||
1057 | arg2 &= ~BIT_0; | ||
1058 | if (!(esw_cfg->offload_flags & BIT_0)) | ||
1059 | arg2 &= ~(BIT_1 | BIT_2 | BIT_3); | ||
1060 | if (!(esw_cfg->offload_flags & BIT_1)) | ||
1061 | arg2 &= ~BIT_2; | ||
1062 | if (!(esw_cfg->offload_flags & BIT_2)) | ||
1063 | arg2 &= ~BIT_3; | ||
1064 | break; | ||
1065 | case QLCNIC_ADD_VLAN: | ||
1066 | arg1 |= (BIT_2 | BIT_5); | ||
1067 | arg1 |= (esw_cfg->vlan_id << 16); | ||
1068 | break; | ||
1069 | case QLCNIC_DEL_VLAN: | ||
1070 | arg1 |= (BIT_3 | BIT_5); | ||
1071 | arg1 &= ~(0x0ffff << 16); | ||
1072 | break; | ||
1073 | default: | ||
1074 | return err; | ||
1075 | } | ||
967 | 1076 | ||
968 | err = qlcnic_issue_cmd(adapter, | 1077 | err = qlcnic_issue_cmd(adapter, |
969 | adapter->ahw.pci_func, | 1078 | adapter->ahw->pci_func, |
970 | adapter->fw_hal_version, | 1079 | adapter->fw_hal_version, |
971 | arg1, | 1080 | arg1, |
972 | 0, | 1081 | arg2, |
973 | 0, | 1082 | 0, |
974 | QLCNIC_CDRP_CMD_CONFIGURE_ESWITCH); | 1083 | QLCNIC_CDRP_CMD_CONFIGURE_ESWITCH); |
975 | 1084 | ||
976 | if (err != QLCNIC_RCODE_SUCCESS) { | 1085 | if (err != QLCNIC_RCODE_SUCCESS) { |
977 | dev_err(&adapter->pdev->dev, | 1086 | dev_err(&adapter->pdev->dev, |
978 | "Failed to configure eswitch port%d\n", eswitch->port); | 1087 | "Failed to configure eswitch pci func %d\n", pci_func); |
979 | } else { | 1088 | } else { |
980 | dev_info(&adapter->pdev->dev, | 1089 | dev_info(&adapter->pdev->dev, |
981 | "Configured eSwitch for port %d\n", eswitch->port); | 1090 | "Configured eSwitch for pci func %d\n", pci_func); |
982 | } | 1091 | } |
983 | 1092 | ||
984 | return err; | 1093 | return err; |
985 | } | 1094 | } |
1095 | |||
1096 | int | ||
1097 | qlcnic_get_eswitch_port_config(struct qlcnic_adapter *adapter, | ||
1098 | struct qlcnic_esw_func_cfg *esw_cfg) | ||
1099 | { | ||
1100 | u32 arg1, arg2; | ||
1101 | u8 phy_port; | ||
1102 | if (adapter->op_mode == QLCNIC_MGMT_FUNC) | ||
1103 | phy_port = adapter->npars[esw_cfg->pci_func].phy_port; | ||
1104 | else | ||
1105 | phy_port = adapter->physical_port; | ||
1106 | arg1 = phy_port; | ||
1107 | arg1 |= (esw_cfg->pci_func << 8); | ||
1108 | if (__qlcnic_get_eswitch_port_config(adapter, &arg1, &arg2)) | ||
1109 | return -EIO; | ||
1110 | |||
1111 | esw_cfg->discard_tagged = !!(arg1 & BIT_4); | ||
1112 | esw_cfg->host_vlan_tag = !!(arg1 & BIT_5); | ||
1113 | esw_cfg->promisc_mode = !!(arg1 & BIT_6); | ||
1114 | esw_cfg->mac_override = !!(arg1 & BIT_7); | ||
1115 | esw_cfg->vlan_id = LSW(arg1 >> 16); | ||
1116 | esw_cfg->mac_anti_spoof = (arg2 & 0x1); | ||
1117 | esw_cfg->offload_flags = ((arg2 >> 1) & 0x7); | ||
1118 | |||
1119 | return 0; | ||
1120 | } | ||
diff --git a/drivers/net/qlcnic/qlcnic_ethtool.c b/drivers/net/qlcnic/qlcnic_ethtool.c index 9328d59e21e0..9efc690a289f 100644 --- a/drivers/net/qlcnic/qlcnic_ethtool.c +++ b/drivers/net/qlcnic/qlcnic_ethtool.c | |||
@@ -1,25 +1,8 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2009 - QLogic Corporation. | 2 | * QLogic qlcnic NIC Driver |
3 | * All rights reserved. | 3 | * Copyright (c) 2009-2010 QLogic Corporation |
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License | ||
7 | * as published by the Free Software Foundation; either version 2 | ||
8 | * of the License, or (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, but | ||
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, | ||
18 | * MA 02111-1307, USA. | ||
19 | * | ||
20 | * The full GNU General Public License is included in this distribution | ||
21 | * in the file called "COPYING". | ||
22 | * | 4 | * |
5 | * See LICENSE.qlcnic for copyright and licensing details. | ||
23 | */ | 6 | */ |
24 | 7 | ||
25 | #include <linux/types.h> | 8 | #include <linux/types.h> |
@@ -78,13 +61,30 @@ static const struct qlcnic_stats qlcnic_gstrings_stats[] = { | |||
78 | 61 | ||
79 | }; | 62 | }; |
80 | 63 | ||
64 | static const char qlcnic_device_gstrings_stats[][ETH_GSTRING_LEN] = { | ||
65 | "rx unicast frames", | ||
66 | "rx multicast frames", | ||
67 | "rx broadcast frames", | ||
68 | "rx dropped frames", | ||
69 | "rx errors", | ||
70 | "rx local frames", | ||
71 | "rx numbytes", | ||
72 | "tx unicast frames", | ||
73 | "tx multicast frames", | ||
74 | "tx broadcast frames", | ||
75 | "tx dropped frames", | ||
76 | "tx errors", | ||
77 | "tx local frames", | ||
78 | "tx numbytes", | ||
79 | }; | ||
80 | |||
81 | #define QLCNIC_STATS_LEN ARRAY_SIZE(qlcnic_gstrings_stats) | 81 | #define QLCNIC_STATS_LEN ARRAY_SIZE(qlcnic_gstrings_stats) |
82 | #define QLCNIC_DEVICE_STATS_LEN ARRAY_SIZE(qlcnic_device_gstrings_stats) | ||
82 | 83 | ||
83 | static const char qlcnic_gstrings_test[][ETH_GSTRING_LEN] = { | 84 | static const char qlcnic_gstrings_test[][ETH_GSTRING_LEN] = { |
84 | "Register_Test_on_offline", | 85 | "Register_Test_on_offline", |
85 | "Link_Test_on_offline", | 86 | "Link_Test_on_offline", |
86 | "Interrupt_Test_offline", | 87 | "Interrupt_Test_offline" |
87 | "Loopback_Test_offline" | ||
88 | }; | 88 | }; |
89 | 89 | ||
90 | #define QLCNIC_TEST_LEN ARRAY_SIZE(qlcnic_gstrings_test) | 90 | #define QLCNIC_TEST_LEN ARRAY_SIZE(qlcnic_gstrings_test) |
@@ -96,10 +96,10 @@ static const char qlcnic_gstrings_test[][ETH_GSTRING_LEN] = { | |||
96 | static const u32 diag_registers[] = { | 96 | static const u32 diag_registers[] = { |
97 | CRB_CMDPEG_STATE, | 97 | CRB_CMDPEG_STATE, |
98 | CRB_RCVPEG_STATE, | 98 | CRB_RCVPEG_STATE, |
99 | CRB_XG_STATE_P3, | 99 | CRB_XG_STATE_P3P, |
100 | CRB_FW_CAPABILITIES_1, | 100 | CRB_FW_CAPABILITIES_1, |
101 | ISR_INT_STATE_REG, | 101 | ISR_INT_STATE_REG, |
102 | QLCNIC_CRB_DEV_REF_COUNT, | 102 | QLCNIC_CRB_DRV_ACTIVE, |
103 | QLCNIC_CRB_DEV_STATE, | 103 | QLCNIC_CRB_DEV_STATE, |
104 | QLCNIC_CRB_DRV_STATE, | 104 | QLCNIC_CRB_DRV_STATE, |
105 | QLCNIC_CRB_DRV_SCRATCH, | 105 | QLCNIC_CRB_DRV_SCRATCH, |
@@ -115,9 +115,13 @@ static const u32 diag_registers[] = { | |||
115 | -1 | 115 | -1 |
116 | }; | 116 | }; |
117 | 117 | ||
118 | #define QLCNIC_MGMT_API_VERSION 2 | ||
119 | #define QLCNIC_DEV_INFO_SIZE 1 | ||
120 | #define QLCNIC_ETHTOOL_REGS_VER 2 | ||
118 | static int qlcnic_get_regs_len(struct net_device *dev) | 121 | static int qlcnic_get_regs_len(struct net_device *dev) |
119 | { | 122 | { |
120 | return sizeof(diag_registers) + QLCNIC_RING_REGS_LEN; | 123 | return sizeof(diag_registers) + QLCNIC_RING_REGS_LEN + |
124 | QLCNIC_DEV_INFO_SIZE + 1; | ||
121 | } | 125 | } |
122 | 126 | ||
123 | static int qlcnic_get_eeprom_len(struct net_device *dev) | 127 | static int qlcnic_get_eeprom_len(struct net_device *dev) |
@@ -146,10 +150,10 @@ qlcnic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | |||
146 | { | 150 | { |
147 | struct qlcnic_adapter *adapter = netdev_priv(dev); | 151 | struct qlcnic_adapter *adapter = netdev_priv(dev); |
148 | int check_sfp_module = 0; | 152 | int check_sfp_module = 0; |
149 | u16 pcifn = adapter->ahw.pci_func; | 153 | u16 pcifn = adapter->ahw->pci_func; |
150 | 154 | ||
151 | /* read which mode */ | 155 | /* read which mode */ |
152 | if (adapter->ahw.port_type == QLCNIC_GBE) { | 156 | if (adapter->ahw->port_type == QLCNIC_GBE) { |
153 | ecmd->supported = (SUPPORTED_10baseT_Half | | 157 | ecmd->supported = (SUPPORTED_10baseT_Half | |
154 | SUPPORTED_10baseT_Full | | 158 | SUPPORTED_10baseT_Full | |
155 | SUPPORTED_100baseT_Half | | 159 | SUPPORTED_100baseT_Half | |
@@ -162,11 +166,11 @@ qlcnic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | |||
162 | ADVERTISED_1000baseT_Half | | 166 | ADVERTISED_1000baseT_Half | |
163 | ADVERTISED_1000baseT_Full); | 167 | ADVERTISED_1000baseT_Full); |
164 | 168 | ||
165 | ecmd->speed = adapter->link_speed; | 169 | ethtool_cmd_speed_set(ecmd, adapter->link_speed); |
166 | ecmd->duplex = adapter->link_duplex; | 170 | ecmd->duplex = adapter->link_duplex; |
167 | ecmd->autoneg = adapter->link_autoneg; | 171 | ecmd->autoneg = adapter->link_autoneg; |
168 | 172 | ||
169 | } else if (adapter->ahw.port_type == QLCNIC_XGBE) { | 173 | } else if (adapter->ahw->port_type == QLCNIC_XGBE) { |
170 | u32 val; | 174 | u32 val; |
171 | 175 | ||
172 | val = QLCRD32(adapter, QLCNIC_PORT_MODE_ADDR); | 176 | val = QLCRD32(adapter, QLCNIC_PORT_MODE_ADDR); |
@@ -179,15 +183,15 @@ qlcnic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | |||
179 | } | 183 | } |
180 | 184 | ||
181 | if (netif_running(dev) && adapter->has_link_events) { | 185 | if (netif_running(dev) && adapter->has_link_events) { |
182 | ecmd->speed = adapter->link_speed; | 186 | ethtool_cmd_speed_set(ecmd, adapter->link_speed); |
183 | ecmd->autoneg = adapter->link_autoneg; | 187 | ecmd->autoneg = adapter->link_autoneg; |
184 | ecmd->duplex = adapter->link_duplex; | 188 | ecmd->duplex = adapter->link_duplex; |
185 | goto skip; | 189 | goto skip; |
186 | } | 190 | } |
187 | 191 | ||
188 | val = QLCRD32(adapter, P3_LINK_SPEED_REG(pcifn)); | 192 | val = QLCRD32(adapter, P3P_LINK_SPEED_REG(pcifn)); |
189 | ecmd->speed = P3_LINK_SPEED_MHZ * | 193 | ethtool_cmd_speed_set(ecmd, P3P_LINK_SPEED_MHZ * |
190 | P3_LINK_SPEED_VAL(pcifn, val); | 194 | P3P_LINK_SPEED_VAL(pcifn, val)); |
191 | ecmd->duplex = DUPLEX_FULL; | 195 | ecmd->duplex = DUPLEX_FULL; |
192 | ecmd->autoneg = AUTONEG_DISABLE; | 196 | ecmd->autoneg = AUTONEG_DISABLE; |
193 | } else | 197 | } else |
@@ -197,44 +201,44 @@ skip: | |||
197 | ecmd->phy_address = adapter->physical_port; | 201 | ecmd->phy_address = adapter->physical_port; |
198 | ecmd->transceiver = XCVR_EXTERNAL; | 202 | ecmd->transceiver = XCVR_EXTERNAL; |
199 | 203 | ||
200 | switch (adapter->ahw.board_type) { | 204 | switch (adapter->ahw->board_type) { |
201 | case QLCNIC_BRDTYPE_P3_REF_QG: | 205 | case QLCNIC_BRDTYPE_P3P_REF_QG: |
202 | case QLCNIC_BRDTYPE_P3_4_GB: | 206 | case QLCNIC_BRDTYPE_P3P_4_GB: |
203 | case QLCNIC_BRDTYPE_P3_4_GB_MM: | 207 | case QLCNIC_BRDTYPE_P3P_4_GB_MM: |
204 | 208 | ||
205 | ecmd->supported |= SUPPORTED_Autoneg; | 209 | ecmd->supported |= SUPPORTED_Autoneg; |
206 | ecmd->advertising |= ADVERTISED_Autoneg; | 210 | ecmd->advertising |= ADVERTISED_Autoneg; |
207 | case QLCNIC_BRDTYPE_P3_10G_CX4: | 211 | case QLCNIC_BRDTYPE_P3P_10G_CX4: |
208 | case QLCNIC_BRDTYPE_P3_10G_CX4_LP: | 212 | case QLCNIC_BRDTYPE_P3P_10G_CX4_LP: |
209 | case QLCNIC_BRDTYPE_P3_10000_BASE_T: | 213 | case QLCNIC_BRDTYPE_P3P_10000_BASE_T: |
210 | ecmd->supported |= SUPPORTED_TP; | 214 | ecmd->supported |= SUPPORTED_TP; |
211 | ecmd->advertising |= ADVERTISED_TP; | 215 | ecmd->advertising |= ADVERTISED_TP; |
212 | ecmd->port = PORT_TP; | 216 | ecmd->port = PORT_TP; |
213 | ecmd->autoneg = adapter->link_autoneg; | 217 | ecmd->autoneg = adapter->link_autoneg; |
214 | break; | 218 | break; |
215 | case QLCNIC_BRDTYPE_P3_IMEZ: | 219 | case QLCNIC_BRDTYPE_P3P_IMEZ: |
216 | case QLCNIC_BRDTYPE_P3_XG_LOM: | 220 | case QLCNIC_BRDTYPE_P3P_XG_LOM: |
217 | case QLCNIC_BRDTYPE_P3_HMEZ: | 221 | case QLCNIC_BRDTYPE_P3P_HMEZ: |
218 | ecmd->supported |= SUPPORTED_MII; | 222 | ecmd->supported |= SUPPORTED_MII; |
219 | ecmd->advertising |= ADVERTISED_MII; | 223 | ecmd->advertising |= ADVERTISED_MII; |
220 | ecmd->port = PORT_MII; | 224 | ecmd->port = PORT_MII; |
221 | ecmd->autoneg = AUTONEG_DISABLE; | 225 | ecmd->autoneg = AUTONEG_DISABLE; |
222 | break; | 226 | break; |
223 | case QLCNIC_BRDTYPE_P3_10G_SFP_PLUS: | 227 | case QLCNIC_BRDTYPE_P3P_10G_SFP_PLUS: |
224 | case QLCNIC_BRDTYPE_P3_10G_SFP_CT: | 228 | case QLCNIC_BRDTYPE_P3P_10G_SFP_CT: |
225 | case QLCNIC_BRDTYPE_P3_10G_SFP_QT: | 229 | case QLCNIC_BRDTYPE_P3P_10G_SFP_QT: |
226 | ecmd->advertising |= ADVERTISED_TP; | 230 | ecmd->advertising |= ADVERTISED_TP; |
227 | ecmd->supported |= SUPPORTED_TP; | 231 | ecmd->supported |= SUPPORTED_TP; |
228 | check_sfp_module = netif_running(dev) && | 232 | check_sfp_module = netif_running(dev) && |
229 | adapter->has_link_events; | 233 | adapter->has_link_events; |
230 | case QLCNIC_BRDTYPE_P3_10G_XFP: | 234 | case QLCNIC_BRDTYPE_P3P_10G_XFP: |
231 | ecmd->supported |= SUPPORTED_FIBRE; | 235 | ecmd->supported |= SUPPORTED_FIBRE; |
232 | ecmd->advertising |= ADVERTISED_FIBRE; | 236 | ecmd->advertising |= ADVERTISED_FIBRE; |
233 | ecmd->port = PORT_FIBRE; | 237 | ecmd->port = PORT_FIBRE; |
234 | ecmd->autoneg = AUTONEG_DISABLE; | 238 | ecmd->autoneg = AUTONEG_DISABLE; |
235 | break; | 239 | break; |
236 | case QLCNIC_BRDTYPE_P3_10G_TP: | 240 | case QLCNIC_BRDTYPE_P3P_10G_TP: |
237 | if (adapter->ahw.port_type == QLCNIC_XGBE) { | 241 | if (adapter->ahw->port_type == QLCNIC_XGBE) { |
238 | ecmd->autoneg = AUTONEG_DISABLE; | 242 | ecmd->autoneg = AUTONEG_DISABLE; |
239 | ecmd->supported |= (SUPPORTED_FIBRE | SUPPORTED_TP); | 243 | ecmd->supported |= (SUPPORTED_FIBRE | SUPPORTED_TP); |
240 | ecmd->advertising |= | 244 | ecmd->advertising |= |
@@ -252,7 +256,7 @@ skip: | |||
252 | break; | 256 | break; |
253 | default: | 257 | default: |
254 | dev_err(&adapter->pdev->dev, "Unsupported board model %d\n", | 258 | dev_err(&adapter->pdev->dev, "Unsupported board model %d\n", |
255 | adapter->ahw.board_type); | 259 | adapter->ahw->board_type); |
256 | return -EIO; | 260 | return -EIO; |
257 | } | 261 | } |
258 | 262 | ||
@@ -280,50 +284,44 @@ skip: | |||
280 | static int | 284 | static int |
281 | qlcnic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | 285 | qlcnic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) |
282 | { | 286 | { |
287 | u32 config = 0; | ||
288 | u32 ret = 0; | ||
283 | struct qlcnic_adapter *adapter = netdev_priv(dev); | 289 | struct qlcnic_adapter *adapter = netdev_priv(dev); |
284 | __u32 status; | 290 | |
291 | if (adapter->ahw->port_type != QLCNIC_GBE) | ||
292 | return -EOPNOTSUPP; | ||
285 | 293 | ||
286 | /* read which mode */ | 294 | /* read which mode */ |
287 | if (adapter->ahw.port_type == QLCNIC_GBE) { | 295 | if (ecmd->duplex) |
288 | /* autonegotiation */ | 296 | config |= 0x1; |
289 | if (qlcnic_fw_cmd_set_phy(adapter, | ||
290 | QLCNIC_NIU_GB_MII_MGMT_ADDR_AUTONEG, | ||
291 | ecmd->autoneg) != 0) | ||
292 | return -EIO; | ||
293 | else | ||
294 | adapter->link_autoneg = ecmd->autoneg; | ||
295 | 297 | ||
296 | if (qlcnic_fw_cmd_query_phy(adapter, | 298 | if (ecmd->autoneg) |
297 | QLCNIC_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, | 299 | config |= 0x2; |
298 | &status) != 0) | ||
299 | return -EIO; | ||
300 | 300 | ||
301 | switch (ecmd->speed) { | 301 | switch (ethtool_cmd_speed(ecmd)) { |
302 | case SPEED_10: | 302 | case SPEED_10: |
303 | qlcnic_set_phy_speed(status, 0); | 303 | config |= (0 << 8); |
304 | break; | 304 | break; |
305 | case SPEED_100: | 305 | case SPEED_100: |
306 | qlcnic_set_phy_speed(status, 1); | 306 | config |= (1 << 8); |
307 | break; | 307 | break; |
308 | case SPEED_1000: | 308 | case SPEED_1000: |
309 | qlcnic_set_phy_speed(status, 2); | 309 | config |= (10 << 8); |
310 | break; | 310 | break; |
311 | } | 311 | default: |
312 | return -EIO; | ||
313 | } | ||
312 | 314 | ||
313 | if (ecmd->duplex == DUPLEX_HALF) | 315 | ret = qlcnic_fw_cmd_set_port(adapter, config); |
314 | qlcnic_clear_phy_duplex(status); | 316 | |
315 | if (ecmd->duplex == DUPLEX_FULL) | 317 | if (ret == QLCNIC_RCODE_NOT_SUPPORTED) |
316 | qlcnic_set_phy_duplex(status); | ||
317 | if (qlcnic_fw_cmd_set_phy(adapter, | ||
318 | QLCNIC_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, | ||
319 | *((int *)&status)) != 0) | ||
320 | return -EIO; | ||
321 | else { | ||
322 | adapter->link_speed = ecmd->speed; | ||
323 | adapter->link_duplex = ecmd->duplex; | ||
324 | } | ||
325 | } else | ||
326 | return -EOPNOTSUPP; | 318 | return -EOPNOTSUPP; |
319 | else if (ret) | ||
320 | return -EIO; | ||
321 | |||
322 | adapter->link_speed = ethtool_cmd_speed(ecmd); | ||
323 | adapter->link_duplex = ecmd->duplex; | ||
324 | adapter->link_autoneg = ecmd->autoneg; | ||
327 | 325 | ||
328 | if (!netif_running(dev)) | 326 | if (!netif_running(dev)) |
329 | return 0; | 327 | return 0; |
@@ -336,17 +334,20 @@ static void | |||
336 | qlcnic_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p) | 334 | qlcnic_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p) |
337 | { | 335 | { |
338 | struct qlcnic_adapter *adapter = netdev_priv(dev); | 336 | struct qlcnic_adapter *adapter = netdev_priv(dev); |
339 | struct qlcnic_recv_context *recv_ctx = &adapter->recv_ctx; | 337 | struct qlcnic_recv_context *recv_ctx = adapter->recv_ctx; |
340 | struct qlcnic_host_sds_ring *sds_ring; | 338 | struct qlcnic_host_sds_ring *sds_ring; |
341 | u32 *regs_buff = p; | 339 | u32 *regs_buff = p; |
342 | int ring, i = 0; | 340 | int ring, i = 0, j = 0; |
343 | 341 | ||
344 | memset(p, 0, qlcnic_get_regs_len(dev)); | 342 | memset(p, 0, qlcnic_get_regs_len(dev)); |
345 | regs->version = (1 << 24) | (adapter->ahw.revision_id << 16) | | 343 | regs->version = (QLCNIC_ETHTOOL_REGS_VER << 24) | |
346 | (adapter->pdev)->device; | 344 | (adapter->ahw->revision_id << 16) | (adapter->pdev)->device; |
347 | 345 | ||
348 | for (i = 0; diag_registers[i] != -1; i++) | 346 | regs_buff[0] = (0xcafe0000 | (QLCNIC_DEV_INFO_SIZE & 0xffff)); |
349 | regs_buff[i] = QLCRD32(adapter, diag_registers[i]); | 347 | regs_buff[1] = QLCNIC_MGMT_API_VERSION; |
348 | |||
349 | for (i = QLCNIC_DEV_INFO_SIZE + 1; diag_registers[j] != -1; j++, i++) | ||
350 | regs_buff[i] = QLCRD32(adapter, diag_registers[j]); | ||
350 | 351 | ||
351 | if (!test_bit(__QLCNIC_DEV_UP, &adapter->state)) | 352 | if (!test_bit(__QLCNIC_DEV_UP, &adapter->state)) |
352 | return; | 353 | return; |
@@ -374,9 +375,9 @@ static u32 qlcnic_test_link(struct net_device *dev) | |||
374 | struct qlcnic_adapter *adapter = netdev_priv(dev); | 375 | struct qlcnic_adapter *adapter = netdev_priv(dev); |
375 | u32 val; | 376 | u32 val; |
376 | 377 | ||
377 | val = QLCRD32(adapter, CRB_XG_STATE_P3); | 378 | val = QLCRD32(adapter, CRB_XG_STATE_P3P); |
378 | val = XG_LINK_STATE_P3(adapter->ahw.pci_func, val); | 379 | val = XG_LINK_STATE_P3P(adapter->ahw->pci_func, val); |
379 | return (val == XG_LINK_UP_P3) ? 0 : 1; | 380 | return (val == XG_LINK_UP_P3P) ? 0 : 1; |
380 | } | 381 | } |
381 | 382 | ||
382 | static int | 383 | static int |
@@ -412,14 +413,8 @@ qlcnic_get_ringparam(struct net_device *dev, | |||
412 | ring->rx_jumbo_pending = adapter->num_jumbo_rxd; | 413 | ring->rx_jumbo_pending = adapter->num_jumbo_rxd; |
413 | ring->tx_pending = adapter->num_txd; | 414 | ring->tx_pending = adapter->num_txd; |
414 | 415 | ||
415 | if (adapter->ahw.port_type == QLCNIC_GBE) { | 416 | ring->rx_max_pending = adapter->max_rxd; |
416 | ring->rx_max_pending = MAX_RCV_DESCRIPTORS_1G; | 417 | ring->rx_jumbo_max_pending = adapter->max_jumbo_rxd; |
417 | ring->rx_jumbo_max_pending = MAX_JUMBO_RCV_DESCRIPTORS_1G; | ||
418 | } else { | ||
419 | ring->rx_max_pending = MAX_RCV_DESCRIPTORS_10G; | ||
420 | ring->rx_jumbo_max_pending = MAX_JUMBO_RCV_DESCRIPTORS_10G; | ||
421 | } | ||
422 | |||
423 | ring->tx_max_pending = MAX_CMD_DESCRIPTORS; | 418 | ring->tx_max_pending = MAX_CMD_DESCRIPTORS; |
424 | 419 | ||
425 | ring->rx_mini_max_pending = 0; | 420 | ring->rx_mini_max_pending = 0; |
@@ -447,24 +442,17 @@ qlcnic_set_ringparam(struct net_device *dev, | |||
447 | struct ethtool_ringparam *ring) | 442 | struct ethtool_ringparam *ring) |
448 | { | 443 | { |
449 | struct qlcnic_adapter *adapter = netdev_priv(dev); | 444 | struct qlcnic_adapter *adapter = netdev_priv(dev); |
450 | u16 max_rcv_desc = MAX_RCV_DESCRIPTORS_10G; | ||
451 | u16 max_jumbo_desc = MAX_JUMBO_RCV_DESCRIPTORS_10G; | ||
452 | u16 num_rxd, num_jumbo_rxd, num_txd; | 445 | u16 num_rxd, num_jumbo_rxd, num_txd; |
453 | 446 | ||
454 | |||
455 | if (ring->rx_mini_pending) | 447 | if (ring->rx_mini_pending) |
456 | return -EOPNOTSUPP; | 448 | return -EOPNOTSUPP; |
457 | 449 | ||
458 | if (adapter->ahw.port_type == QLCNIC_GBE) { | ||
459 | max_rcv_desc = MAX_RCV_DESCRIPTORS_1G; | ||
460 | max_jumbo_desc = MAX_JUMBO_RCV_DESCRIPTORS_10G; | ||
461 | } | ||
462 | |||
463 | num_rxd = qlcnic_validate_ringparam(ring->rx_pending, | 450 | num_rxd = qlcnic_validate_ringparam(ring->rx_pending, |
464 | MIN_RCV_DESCRIPTORS, max_rcv_desc, "rx"); | 451 | MIN_RCV_DESCRIPTORS, adapter->max_rxd, "rx"); |
465 | 452 | ||
466 | num_jumbo_rxd = qlcnic_validate_ringparam(ring->rx_jumbo_pending, | 453 | num_jumbo_rxd = qlcnic_validate_ringparam(ring->rx_jumbo_pending, |
467 | MIN_JUMBO_DESCRIPTORS, max_jumbo_desc, "rx jumbo"); | 454 | MIN_JUMBO_DESCRIPTORS, adapter->max_jumbo_rxd, |
455 | "rx jumbo"); | ||
468 | 456 | ||
469 | num_txd = qlcnic_validate_ringparam(ring->tx_pending, | 457 | num_txd = qlcnic_validate_ringparam(ring->tx_pending, |
470 | MIN_CMD_DESCRIPTORS, MAX_CMD_DESCRIPTORS, "tx"); | 458 | MIN_CMD_DESCRIPTORS, MAX_CMD_DESCRIPTORS, "tx"); |
@@ -480,6 +468,39 @@ qlcnic_set_ringparam(struct net_device *dev, | |||
480 | return qlcnic_reset_context(adapter); | 468 | return qlcnic_reset_context(adapter); |
481 | } | 469 | } |
482 | 470 | ||
471 | static void qlcnic_get_channels(struct net_device *dev, | ||
472 | struct ethtool_channels *channel) | ||
473 | { | ||
474 | struct qlcnic_adapter *adapter = netdev_priv(dev); | ||
475 | |||
476 | channel->max_rx = rounddown_pow_of_two(min_t(int, | ||
477 | adapter->max_rx_ques, num_online_cpus())); | ||
478 | channel->max_tx = adapter->max_tx_ques; | ||
479 | |||
480 | channel->rx_count = adapter->max_sds_rings; | ||
481 | channel->tx_count = adapter->max_tx_ques; | ||
482 | } | ||
483 | |||
484 | static int qlcnic_set_channels(struct net_device *dev, | ||
485 | struct ethtool_channels *channel) | ||
486 | { | ||
487 | struct qlcnic_adapter *adapter = netdev_priv(dev); | ||
488 | int err; | ||
489 | |||
490 | if (channel->other_count || channel->combined_count || | ||
491 | channel->tx_count != channel->max_tx) | ||
492 | return -EINVAL; | ||
493 | |||
494 | err = qlcnic_validate_max_rss(dev, channel->max_rx, channel->rx_count); | ||
495 | if (err) | ||
496 | return err; | ||
497 | |||
498 | err = qlcnic_set_max_rss(adapter, channel->rx_count); | ||
499 | netdev_info(dev, "allocated 0x%x sds rings\n", | ||
500 | adapter->max_sds_rings); | ||
501 | return err; | ||
502 | } | ||
503 | |||
483 | static void | 504 | static void |
484 | qlcnic_get_pauseparam(struct net_device *netdev, | 505 | qlcnic_get_pauseparam(struct net_device *netdev, |
485 | struct ethtool_pauseparam *pause) | 506 | struct ethtool_pauseparam *pause) |
@@ -488,7 +509,7 @@ qlcnic_get_pauseparam(struct net_device *netdev, | |||
488 | int port = adapter->physical_port; | 509 | int port = adapter->physical_port; |
489 | __u32 val; | 510 | __u32 val; |
490 | 511 | ||
491 | if (adapter->ahw.port_type == QLCNIC_GBE) { | 512 | if (adapter->ahw->port_type == QLCNIC_GBE) { |
492 | if ((port < 0) || (port > QLCNIC_NIU_MAX_GBE_PORTS)) | 513 | if ((port < 0) || (port > QLCNIC_NIU_MAX_GBE_PORTS)) |
493 | return; | 514 | return; |
494 | /* get flow control settings */ | 515 | /* get flow control settings */ |
@@ -510,7 +531,7 @@ qlcnic_get_pauseparam(struct net_device *netdev, | |||
510 | pause->tx_pause = !(qlcnic_gb_get_gb3_mask(val)); | 531 | pause->tx_pause = !(qlcnic_gb_get_gb3_mask(val)); |
511 | break; | 532 | break; |
512 | } | 533 | } |
513 | } else if (adapter->ahw.port_type == QLCNIC_XGBE) { | 534 | } else if (adapter->ahw->port_type == QLCNIC_XGBE) { |
514 | if ((port < 0) || (port > QLCNIC_NIU_MAX_XG_PORTS)) | 535 | if ((port < 0) || (port > QLCNIC_NIU_MAX_XG_PORTS)) |
515 | return; | 536 | return; |
516 | pause->rx_pause = 1; | 537 | pause->rx_pause = 1; |
@@ -521,7 +542,7 @@ qlcnic_get_pauseparam(struct net_device *netdev, | |||
521 | pause->tx_pause = !(qlcnic_xg_get_xg1_mask(val)); | 542 | pause->tx_pause = !(qlcnic_xg_get_xg1_mask(val)); |
522 | } else { | 543 | } else { |
523 | dev_err(&netdev->dev, "Unknown board type: %x\n", | 544 | dev_err(&netdev->dev, "Unknown board type: %x\n", |
524 | adapter->ahw.port_type); | 545 | adapter->ahw->port_type); |
525 | } | 546 | } |
526 | } | 547 | } |
527 | 548 | ||
@@ -534,7 +555,7 @@ qlcnic_set_pauseparam(struct net_device *netdev, | |||
534 | __u32 val; | 555 | __u32 val; |
535 | 556 | ||
536 | /* read mode */ | 557 | /* read mode */ |
537 | if (adapter->ahw.port_type == QLCNIC_GBE) { | 558 | if (adapter->ahw->port_type == QLCNIC_GBE) { |
538 | if ((port < 0) || (port > QLCNIC_NIU_MAX_GBE_PORTS)) | 559 | if ((port < 0) || (port > QLCNIC_NIU_MAX_GBE_PORTS)) |
539 | return -EIO; | 560 | return -EIO; |
540 | /* set flow control */ | 561 | /* set flow control */ |
@@ -577,7 +598,7 @@ qlcnic_set_pauseparam(struct net_device *netdev, | |||
577 | break; | 598 | break; |
578 | } | 599 | } |
579 | QLCWR32(adapter, QLCNIC_NIU_GB_PAUSE_CTL, val); | 600 | QLCWR32(adapter, QLCNIC_NIU_GB_PAUSE_CTL, val); |
580 | } else if (adapter->ahw.port_type == QLCNIC_XGBE) { | 601 | } else if (adapter->ahw->port_type == QLCNIC_XGBE) { |
581 | if (!pause->rx_pause || pause->autoneg) | 602 | if (!pause->rx_pause || pause->autoneg) |
582 | return -EOPNOTSUPP; | 603 | return -EOPNOTSUPP; |
583 | 604 | ||
@@ -599,7 +620,7 @@ qlcnic_set_pauseparam(struct net_device *netdev, | |||
599 | QLCWR32(adapter, QLCNIC_NIU_XG_PAUSE_CTL, val); | 620 | QLCWR32(adapter, QLCNIC_NIU_XG_PAUSE_CTL, val); |
600 | } else { | 621 | } else { |
601 | dev_err(&netdev->dev, "Unknown board type: %x\n", | 622 | dev_err(&netdev->dev, "Unknown board type: %x\n", |
602 | adapter->ahw.port_type); | 623 | adapter->ahw->port_type); |
603 | } | 624 | } |
604 | return 0; | 625 | return 0; |
605 | } | 626 | } |
@@ -618,96 +639,19 @@ static int qlcnic_reg_test(struct net_device *dev) | |||
618 | 639 | ||
619 | static int qlcnic_get_sset_count(struct net_device *dev, int sset) | 640 | static int qlcnic_get_sset_count(struct net_device *dev, int sset) |
620 | { | 641 | { |
642 | struct qlcnic_adapter *adapter = netdev_priv(dev); | ||
621 | switch (sset) { | 643 | switch (sset) { |
622 | case ETH_SS_TEST: | 644 | case ETH_SS_TEST: |
623 | return QLCNIC_TEST_LEN; | 645 | return QLCNIC_TEST_LEN; |
624 | case ETH_SS_STATS: | 646 | case ETH_SS_STATS: |
647 | if (adapter->flags & QLCNIC_ESWITCH_ENABLED) | ||
648 | return QLCNIC_STATS_LEN + QLCNIC_DEVICE_STATS_LEN; | ||
625 | return QLCNIC_STATS_LEN; | 649 | return QLCNIC_STATS_LEN; |
626 | default: | 650 | default: |
627 | return -EOPNOTSUPP; | 651 | return -EOPNOTSUPP; |
628 | } | 652 | } |
629 | } | 653 | } |
630 | 654 | ||
631 | #define QLC_ILB_PKT_SIZE 64 | ||
632 | |||
633 | static void qlcnic_create_loopback_buff(unsigned char *data) | ||
634 | { | ||
635 | unsigned char random_data[] = {0xa8, 0x06, 0x45, 0x00}; | ||
636 | memset(data, 0x4e, QLC_ILB_PKT_SIZE); | ||
637 | memset(data, 0xff, 12); | ||
638 | memcpy(data + 12, random_data, sizeof(random_data)); | ||
639 | } | ||
640 | |||
641 | int qlcnic_check_loopback_buff(unsigned char *data) | ||
642 | { | ||
643 | unsigned char buff[QLC_ILB_PKT_SIZE]; | ||
644 | qlcnic_create_loopback_buff(buff); | ||
645 | return memcmp(data, buff, QLC_ILB_PKT_SIZE); | ||
646 | } | ||
647 | |||
648 | static int qlcnic_do_ilb_test(struct qlcnic_adapter *adapter) | ||
649 | { | ||
650 | struct qlcnic_recv_context *recv_ctx = &adapter->recv_ctx; | ||
651 | struct qlcnic_host_sds_ring *sds_ring = &recv_ctx->sds_rings[0]; | ||
652 | struct sk_buff *skb; | ||
653 | int i; | ||
654 | |||
655 | for (i = 0; i < 16; i++) { | ||
656 | skb = dev_alloc_skb(QLC_ILB_PKT_SIZE); | ||
657 | qlcnic_create_loopback_buff(skb->data); | ||
658 | skb_put(skb, QLC_ILB_PKT_SIZE); | ||
659 | |||
660 | adapter->diag_cnt = 0; | ||
661 | |||
662 | qlcnic_xmit_frame(skb, adapter->netdev); | ||
663 | |||
664 | msleep(5); | ||
665 | |||
666 | qlcnic_process_rcv_ring_diag(sds_ring); | ||
667 | |||
668 | dev_kfree_skb_any(skb); | ||
669 | if (!adapter->diag_cnt) | ||
670 | return -1; | ||
671 | } | ||
672 | return 0; | ||
673 | } | ||
674 | |||
675 | static int qlcnic_loopback_test(struct net_device *netdev) | ||
676 | { | ||
677 | struct qlcnic_adapter *adapter = netdev_priv(netdev); | ||
678 | int max_sds_rings = adapter->max_sds_rings; | ||
679 | int ret; | ||
680 | |||
681 | if (adapter->op_mode == QLCNIC_NON_PRIV_FUNC) { | ||
682 | dev_warn(&adapter->pdev->dev, "Loopback test not supported" | ||
683 | "for non privilege function\n"); | ||
684 | return 0; | ||
685 | } | ||
686 | |||
687 | if (test_and_set_bit(__QLCNIC_RESETTING, &adapter->state)) | ||
688 | return -EIO; | ||
689 | |||
690 | ret = qlcnic_diag_alloc_res(netdev, QLCNIC_LOOPBACK_TEST); | ||
691 | if (ret) | ||
692 | goto clear_it; | ||
693 | |||
694 | ret = qlcnic_set_ilb_mode(adapter); | ||
695 | if (ret) | ||
696 | goto done; | ||
697 | |||
698 | ret = qlcnic_do_ilb_test(adapter); | ||
699 | |||
700 | qlcnic_clear_ilb_mode(adapter); | ||
701 | |||
702 | done: | ||
703 | qlcnic_diag_free_res(netdev, max_sds_rings); | ||
704 | |||
705 | clear_it: | ||
706 | adapter->max_sds_rings = max_sds_rings; | ||
707 | clear_bit(__QLCNIC_RESETTING, &adapter->state); | ||
708 | return ret; | ||
709 | } | ||
710 | |||
711 | static int qlcnic_irq_test(struct net_device *netdev) | 655 | static int qlcnic_irq_test(struct net_device *netdev) |
712 | { | 656 | { |
713 | struct qlcnic_adapter *adapter = netdev_priv(netdev); | 657 | struct qlcnic_adapter *adapter = netdev_priv(netdev); |
@@ -722,8 +666,8 @@ static int qlcnic_irq_test(struct net_device *netdev) | |||
722 | goto clear_it; | 666 | goto clear_it; |
723 | 667 | ||
724 | adapter->diag_cnt = 0; | 668 | adapter->diag_cnt = 0; |
725 | ret = qlcnic_issue_cmd(adapter, adapter->ahw.pci_func, | 669 | ret = qlcnic_issue_cmd(adapter, adapter->ahw->pci_func, |
726 | adapter->fw_hal_version, adapter->portnum, | 670 | adapter->fw_hal_version, adapter->ahw->pci_func, |
727 | 0, 0, 0x00000011); | 671 | 0, 0, 0x00000011); |
728 | if (ret) | 672 | if (ret) |
729 | goto done; | 673 | goto done; |
@@ -747,31 +691,28 @@ qlcnic_diag_test(struct net_device *dev, struct ethtool_test *eth_test, | |||
747 | { | 691 | { |
748 | memset(data, 0, sizeof(u64) * QLCNIC_TEST_LEN); | 692 | memset(data, 0, sizeof(u64) * QLCNIC_TEST_LEN); |
749 | 693 | ||
750 | if (eth_test->flags == ETH_TEST_FL_OFFLINE) { | ||
751 | data[2] = qlcnic_irq_test(dev); | ||
752 | if (data[2]) | ||
753 | eth_test->flags |= ETH_TEST_FL_FAILED; | ||
754 | |||
755 | data[3] = qlcnic_loopback_test(dev); | ||
756 | if (data[3]) | ||
757 | eth_test->flags |= ETH_TEST_FL_FAILED; | ||
758 | |||
759 | } | ||
760 | |||
761 | data[0] = qlcnic_reg_test(dev); | 694 | data[0] = qlcnic_reg_test(dev); |
762 | if (data[0]) | 695 | if (data[0]) |
763 | eth_test->flags |= ETH_TEST_FL_FAILED; | 696 | eth_test->flags |= ETH_TEST_FL_FAILED; |
764 | 697 | ||
765 | /* link test */ | ||
766 | data[1] = (u64) qlcnic_test_link(dev); | 698 | data[1] = (u64) qlcnic_test_link(dev); |
767 | if (data[1]) | 699 | if (data[1]) |
768 | eth_test->flags |= ETH_TEST_FL_FAILED; | 700 | eth_test->flags |= ETH_TEST_FL_FAILED; |
701 | |||
702 | if (eth_test->flags & ETH_TEST_FL_OFFLINE) { | ||
703 | data[2] = qlcnic_irq_test(dev); | ||
704 | if (data[2]) | ||
705 | eth_test->flags |= ETH_TEST_FL_FAILED; | ||
706 | |||
707 | |||
708 | } | ||
769 | } | 709 | } |
770 | 710 | ||
771 | static void | 711 | static void |
772 | qlcnic_get_strings(struct net_device *dev, u32 stringset, u8 * data) | 712 | qlcnic_get_strings(struct net_device *dev, u32 stringset, u8 * data) |
773 | { | 713 | { |
774 | int index; | 714 | struct qlcnic_adapter *adapter = netdev_priv(dev); |
715 | int index, i; | ||
775 | 716 | ||
776 | switch (stringset) { | 717 | switch (stringset) { |
777 | case ETH_SS_TEST: | 718 | case ETH_SS_TEST: |
@@ -784,16 +725,43 @@ qlcnic_get_strings(struct net_device *dev, u32 stringset, u8 * data) | |||
784 | qlcnic_gstrings_stats[index].stat_string, | 725 | qlcnic_gstrings_stats[index].stat_string, |
785 | ETH_GSTRING_LEN); | 726 | ETH_GSTRING_LEN); |
786 | } | 727 | } |
787 | break; | 728 | if (!(adapter->flags & QLCNIC_ESWITCH_ENABLED)) |
729 | return; | ||
730 | for (i = 0; i < QLCNIC_DEVICE_STATS_LEN; index++, i++) { | ||
731 | memcpy(data + index * ETH_GSTRING_LEN, | ||
732 | qlcnic_device_gstrings_stats[i], | ||
733 | ETH_GSTRING_LEN); | ||
734 | } | ||
788 | } | 735 | } |
789 | } | 736 | } |
790 | 737 | ||
738 | #define QLCNIC_FILL_ESWITCH_STATS(VAL1) \ | ||
739 | (((VAL1) == QLCNIC_ESW_STATS_NOT_AVAIL) ? 0 : VAL1) | ||
740 | |||
741 | static void | ||
742 | qlcnic_fill_device_stats(int *index, u64 *data, | ||
743 | struct __qlcnic_esw_statistics *stats) | ||
744 | { | ||
745 | int ind = *index; | ||
746 | |||
747 | data[ind++] = QLCNIC_FILL_ESWITCH_STATS(stats->unicast_frames); | ||
748 | data[ind++] = QLCNIC_FILL_ESWITCH_STATS(stats->multicast_frames); | ||
749 | data[ind++] = QLCNIC_FILL_ESWITCH_STATS(stats->broadcast_frames); | ||
750 | data[ind++] = QLCNIC_FILL_ESWITCH_STATS(stats->dropped_frames); | ||
751 | data[ind++] = QLCNIC_FILL_ESWITCH_STATS(stats->errors); | ||
752 | data[ind++] = QLCNIC_FILL_ESWITCH_STATS(stats->local_frames); | ||
753 | data[ind++] = QLCNIC_FILL_ESWITCH_STATS(stats->numbytes); | ||
754 | |||
755 | *index = ind; | ||
756 | } | ||
757 | |||
791 | static void | 758 | static void |
792 | qlcnic_get_ethtool_stats(struct net_device *dev, | 759 | qlcnic_get_ethtool_stats(struct net_device *dev, |
793 | struct ethtool_stats *stats, u64 * data) | 760 | struct ethtool_stats *stats, u64 * data) |
794 | { | 761 | { |
795 | struct qlcnic_adapter *adapter = netdev_priv(dev); | 762 | struct qlcnic_adapter *adapter = netdev_priv(dev); |
796 | int index; | 763 | struct qlcnic_esw_statistics port_stats; |
764 | int index, ret; | ||
797 | 765 | ||
798 | for (index = 0; index < QLCNIC_STATS_LEN; index++) { | 766 | for (index = 0; index < QLCNIC_STATS_LEN; index++) { |
799 | char *p = | 767 | char *p = |
@@ -803,69 +771,69 @@ qlcnic_get_ethtool_stats(struct net_device *dev, | |||
803 | (qlcnic_gstrings_stats[index].sizeof_stat == | 771 | (qlcnic_gstrings_stats[index].sizeof_stat == |
804 | sizeof(u64)) ? *(u64 *)p:(*(u32 *)p); | 772 | sizeof(u64)) ? *(u64 *)p:(*(u32 *)p); |
805 | } | 773 | } |
806 | } | ||
807 | |||
808 | static u32 qlcnic_get_tx_csum(struct net_device *dev) | ||
809 | { | ||
810 | return dev->features & NETIF_F_IP_CSUM; | ||
811 | } | ||
812 | 774 | ||
813 | static u32 qlcnic_get_rx_csum(struct net_device *dev) | 775 | if (!(adapter->flags & QLCNIC_ESWITCH_ENABLED)) |
814 | { | 776 | return; |
815 | struct qlcnic_adapter *adapter = netdev_priv(dev); | ||
816 | return adapter->rx_csum; | ||
817 | } | ||
818 | 777 | ||
819 | static int qlcnic_set_rx_csum(struct net_device *dev, u32 data) | 778 | memset(&port_stats, 0, sizeof(struct qlcnic_esw_statistics)); |
820 | { | 779 | ret = qlcnic_get_port_stats(adapter, adapter->ahw->pci_func, |
821 | struct qlcnic_adapter *adapter = netdev_priv(dev); | 780 | QLCNIC_QUERY_RX_COUNTER, &port_stats.rx); |
822 | adapter->rx_csum = !!data; | 781 | if (ret) |
823 | return 0; | 782 | return; |
824 | } | ||
825 | 783 | ||
826 | static u32 qlcnic_get_tso(struct net_device *dev) | 784 | qlcnic_fill_device_stats(&index, data, &port_stats.rx); |
827 | { | ||
828 | return (dev->features & (NETIF_F_TSO | NETIF_F_TSO6)) != 0; | ||
829 | } | ||
830 | 785 | ||
831 | static int qlcnic_set_tso(struct net_device *dev, u32 data) | 786 | ret = qlcnic_get_port_stats(adapter, adapter->ahw->pci_func, |
832 | { | 787 | QLCNIC_QUERY_TX_COUNTER, &port_stats.tx); |
833 | struct qlcnic_adapter *adapter = netdev_priv(dev); | 788 | if (ret) |
834 | if (!(adapter->capabilities & QLCNIC_FW_CAPABILITY_TSO)) | 789 | return; |
835 | return -EOPNOTSUPP; | ||
836 | if (data) | ||
837 | dev->features |= (NETIF_F_TSO | NETIF_F_TSO6); | ||
838 | else | ||
839 | dev->features &= ~(NETIF_F_TSO | NETIF_F_TSO6); | ||
840 | 790 | ||
841 | return 0; | 791 | qlcnic_fill_device_stats(&index, data, &port_stats.tx); |
842 | } | 792 | } |
843 | 793 | ||
844 | static int qlcnic_blink_led(struct net_device *dev, u32 val) | 794 | static int qlcnic_set_led(struct net_device *dev, |
795 | enum ethtool_phys_id_state state) | ||
845 | { | 796 | { |
846 | struct qlcnic_adapter *adapter = netdev_priv(dev); | 797 | struct qlcnic_adapter *adapter = netdev_priv(dev); |
847 | int ret; | 798 | int max_sds_rings = adapter->max_sds_rings; |
848 | 799 | ||
849 | if (!test_bit(__QLCNIC_DEV_UP, &adapter->state)) | 800 | switch (state) { |
850 | return -EIO; | 801 | case ETHTOOL_ID_ACTIVE: |
802 | if (!test_bit(__QLCNIC_DEV_UP, &adapter->state)) { | ||
803 | if (test_and_set_bit(__QLCNIC_RESETTING, &adapter->state)) | ||
804 | return -EIO; | ||
805 | |||
806 | if (qlcnic_diag_alloc_res(dev, QLCNIC_LED_TEST)) { | ||
807 | clear_bit(__QLCNIC_RESETTING, &adapter->state); | ||
808 | return -EIO; | ||
809 | } | ||
810 | set_bit(__QLCNIC_DIAG_RES_ALLOC, &adapter->state); | ||
811 | } | ||
812 | |||
813 | if (adapter->nic_ops->config_led(adapter, 1, 0xf) == 0) | ||
814 | return 0; | ||
851 | 815 | ||
852 | ret = adapter->nic_ops->config_led(adapter, 1, 0xf); | ||
853 | if (ret) { | ||
854 | dev_err(&adapter->pdev->dev, | 816 | dev_err(&adapter->pdev->dev, |
855 | "Failed to set LED blink state.\n"); | 817 | "Failed to set LED blink state.\n"); |
856 | return ret; | 818 | break; |
857 | } | ||
858 | 819 | ||
859 | msleep_interruptible(val * 1000); | 820 | case ETHTOOL_ID_INACTIVE: |
821 | if (adapter->nic_ops->config_led(adapter, 0, 0xf)) | ||
822 | dev_err(&adapter->pdev->dev, | ||
823 | "Failed to reset LED blink state.\n"); | ||
860 | 824 | ||
861 | ret = adapter->nic_ops->config_led(adapter, 0, 0xf); | 825 | break; |
862 | if (ret) { | 826 | |
863 | dev_err(&adapter->pdev->dev, | 827 | default: |
864 | "Failed to reset LED blink state.\n"); | 828 | return -EINVAL; |
865 | return ret; | ||
866 | } | 829 | } |
867 | 830 | ||
868 | return 0; | 831 | if (test_and_clear_bit(__QLCNIC_DIAG_RES_ALLOC, &adapter->state)) { |
832 | qlcnic_diag_free_res(dev, max_sds_rings); | ||
833 | clear_bit(__QLCNIC_RESETTING, &adapter->state); | ||
834 | } | ||
835 | |||
836 | return -EIO; | ||
869 | } | 837 | } |
870 | 838 | ||
871 | static void | 839 | static void |
@@ -929,8 +897,8 @@ static int qlcnic_set_intr_coalesce(struct net_device *netdev, | |||
929 | */ | 897 | */ |
930 | if (ethcoal->rx_coalesce_usecs > 0xffff || | 898 | if (ethcoal->rx_coalesce_usecs > 0xffff || |
931 | ethcoal->rx_max_coalesced_frames > 0xffff || | 899 | ethcoal->rx_max_coalesced_frames > 0xffff || |
932 | ethcoal->tx_coalesce_usecs > 0xffff || | 900 | ethcoal->tx_coalesce_usecs || |
933 | ethcoal->tx_max_coalesced_frames > 0xffff || | 901 | ethcoal->tx_max_coalesced_frames || |
934 | ethcoal->rx_coalesce_usecs_irq || | 902 | ethcoal->rx_coalesce_usecs_irq || |
935 | ethcoal->rx_max_coalesced_frames_irq || | 903 | ethcoal->rx_max_coalesced_frames_irq || |
936 | ethcoal->tx_coalesce_usecs_irq || | 904 | ethcoal->tx_coalesce_usecs_irq || |
@@ -952,21 +920,17 @@ static int qlcnic_set_intr_coalesce(struct net_device *netdev, | |||
952 | 920 | ||
953 | if (!ethcoal->rx_coalesce_usecs || | 921 | if (!ethcoal->rx_coalesce_usecs || |
954 | !ethcoal->rx_max_coalesced_frames) { | 922 | !ethcoal->rx_max_coalesced_frames) { |
955 | adapter->coal.flags = QLCNIC_INTR_DEFAULT; | 923 | adapter->ahw->coal.flag = QLCNIC_INTR_DEFAULT; |
956 | adapter->coal.normal.data.rx_time_us = | 924 | adapter->ahw->coal.rx_time_us = |
957 | QLCNIC_DEFAULT_INTR_COALESCE_RX_TIME_US; | 925 | QLCNIC_DEFAULT_INTR_COALESCE_RX_TIME_US; |
958 | adapter->coal.normal.data.rx_packets = | 926 | adapter->ahw->coal.rx_packets = |
959 | QLCNIC_DEFAULT_INTR_COALESCE_RX_PACKETS; | 927 | QLCNIC_DEFAULT_INTR_COALESCE_RX_PACKETS; |
960 | } else { | 928 | } else { |
961 | adapter->coal.flags = 0; | 929 | adapter->ahw->coal.flag = 0; |
962 | adapter->coal.normal.data.rx_time_us = | 930 | adapter->ahw->coal.rx_time_us = ethcoal->rx_coalesce_usecs; |
963 | ethcoal->rx_coalesce_usecs; | 931 | adapter->ahw->coal.rx_packets = |
964 | adapter->coal.normal.data.rx_packets = | 932 | ethcoal->rx_max_coalesced_frames; |
965 | ethcoal->rx_max_coalesced_frames; | ||
966 | } | 933 | } |
967 | adapter->coal.normal.data.tx_time_us = ethcoal->tx_coalesce_usecs; | ||
968 | adapter->coal.normal.data.tx_packets = | ||
969 | ethcoal->tx_max_coalesced_frames; | ||
970 | 934 | ||
971 | qlcnic_config_intr_coalesce(adapter); | 935 | qlcnic_config_intr_coalesce(adapter); |
972 | 936 | ||
@@ -981,57 +945,102 @@ static int qlcnic_get_intr_coalesce(struct net_device *netdev, | |||
981 | if (adapter->is_up != QLCNIC_ADAPTER_UP_MAGIC) | 945 | if (adapter->is_up != QLCNIC_ADAPTER_UP_MAGIC) |
982 | return -EINVAL; | 946 | return -EINVAL; |
983 | 947 | ||
984 | ethcoal->rx_coalesce_usecs = adapter->coal.normal.data.rx_time_us; | 948 | ethcoal->rx_coalesce_usecs = adapter->ahw->coal.rx_time_us; |
985 | ethcoal->tx_coalesce_usecs = adapter->coal.normal.data.tx_time_us; | 949 | ethcoal->rx_max_coalesced_frames = adapter->ahw->coal.rx_packets; |
986 | ethcoal->rx_max_coalesced_frames = | ||
987 | adapter->coal.normal.data.rx_packets; | ||
988 | ethcoal->tx_max_coalesced_frames = | ||
989 | adapter->coal.normal.data.tx_packets; | ||
990 | 950 | ||
991 | return 0; | 951 | return 0; |
992 | } | 952 | } |
993 | 953 | ||
994 | static int qlcnic_set_flags(struct net_device *netdev, u32 data) | 954 | static u32 qlcnic_get_msglevel(struct net_device *netdev) |
995 | { | 955 | { |
996 | struct qlcnic_adapter *adapter = netdev_priv(netdev); | 956 | struct qlcnic_adapter *adapter = netdev_priv(netdev); |
997 | int hw_lro; | ||
998 | |||
999 | if (data & ~ETH_FLAG_LRO) | ||
1000 | return -EINVAL; | ||
1001 | |||
1002 | if (!(adapter->capabilities & QLCNIC_FW_CAPABILITY_HW_LRO)) | ||
1003 | return -EINVAL; | ||
1004 | 957 | ||
1005 | if (data & ETH_FLAG_LRO) { | 958 | return adapter->msg_enable; |
1006 | hw_lro = QLCNIC_LRO_ENABLED; | 959 | } |
1007 | netdev->features |= NETIF_F_LRO; | ||
1008 | } else { | ||
1009 | hw_lro = 0; | ||
1010 | netdev->features &= ~NETIF_F_LRO; | ||
1011 | } | ||
1012 | 960 | ||
1013 | if (qlcnic_config_hw_lro(adapter, hw_lro)) | 961 | static void qlcnic_set_msglevel(struct net_device *netdev, u32 msglvl) |
1014 | return -EIO; | 962 | { |
963 | struct qlcnic_adapter *adapter = netdev_priv(netdev); | ||
1015 | 964 | ||
1016 | if ((hw_lro == 0) && qlcnic_send_lro_cleanup(adapter)) | 965 | adapter->msg_enable = msglvl; |
1017 | return -EIO; | 966 | } |
1018 | 967 | ||
968 | static int | ||
969 | qlcnic_get_dump_flag(struct net_device *netdev, struct ethtool_dump *dump) | ||
970 | { | ||
971 | struct qlcnic_adapter *adapter = netdev_priv(netdev); | ||
972 | struct qlcnic_fw_dump *fw_dump = &adapter->ahw->fw_dump; | ||
1019 | 973 | ||
974 | dump->len = fw_dump->tmpl_hdr->size + fw_dump->size; | ||
975 | dump->flag = fw_dump->tmpl_hdr->drv_cap_mask; | ||
976 | dump->version = adapter->fw_version; | ||
1020 | return 0; | 977 | return 0; |
1021 | } | 978 | } |
1022 | 979 | ||
1023 | static u32 qlcnic_get_msglevel(struct net_device *netdev) | 980 | static int |
981 | qlcnic_get_dump_data(struct net_device *netdev, struct ethtool_dump *dump, | ||
982 | void *buffer) | ||
1024 | { | 983 | { |
984 | int i, copy_sz; | ||
985 | u32 *hdr_ptr, *data; | ||
1025 | struct qlcnic_adapter *adapter = netdev_priv(netdev); | 986 | struct qlcnic_adapter *adapter = netdev_priv(netdev); |
987 | struct qlcnic_fw_dump *fw_dump = &adapter->ahw->fw_dump; | ||
1026 | 988 | ||
1027 | return adapter->msg_enable; | 989 | if (qlcnic_api_lock(adapter)) |
990 | return -EIO; | ||
991 | if (!fw_dump->clr) { | ||
992 | netdev_info(netdev, "Dump not available\n"); | ||
993 | qlcnic_api_unlock(adapter); | ||
994 | return -EINVAL; | ||
995 | } | ||
996 | /* Copy template header first */ | ||
997 | copy_sz = fw_dump->tmpl_hdr->size; | ||
998 | hdr_ptr = (u32 *) fw_dump->tmpl_hdr; | ||
999 | data = (u32 *) buffer; | ||
1000 | for (i = 0; i < copy_sz/sizeof(u32); i++) | ||
1001 | *data++ = cpu_to_le32(*hdr_ptr++); | ||
1002 | |||
1003 | /* Copy captured dump data */ | ||
1004 | memcpy(buffer + copy_sz, fw_dump->data, fw_dump->size); | ||
1005 | dump->len = copy_sz + fw_dump->size; | ||
1006 | dump->flag = fw_dump->tmpl_hdr->drv_cap_mask; | ||
1007 | |||
1008 | /* Free dump area once data has been captured */ | ||
1009 | vfree(fw_dump->data); | ||
1010 | fw_dump->data = NULL; | ||
1011 | fw_dump->clr = 0; | ||
1012 | qlcnic_api_unlock(adapter); | ||
1013 | |||
1014 | return 0; | ||
1028 | } | 1015 | } |
1029 | 1016 | ||
1030 | static void qlcnic_set_msglevel(struct net_device *netdev, u32 msglvl) | 1017 | static int |
1018 | qlcnic_set_dump(struct net_device *netdev, struct ethtool_dump *val) | ||
1031 | { | 1019 | { |
1020 | int ret = 0; | ||
1032 | struct qlcnic_adapter *adapter = netdev_priv(netdev); | 1021 | struct qlcnic_adapter *adapter = netdev_priv(netdev); |
1022 | struct qlcnic_fw_dump *fw_dump = &adapter->ahw->fw_dump; | ||
1033 | 1023 | ||
1034 | adapter->msg_enable = msglvl; | 1024 | if (val->flag == QLCNIC_FORCE_FW_DUMP_KEY) { |
1025 | netdev_info(netdev, "Forcing a FW dump\n"); | ||
1026 | qlcnic_dev_request_reset(adapter); | ||
1027 | } else { | ||
1028 | if (val->flag > QLCNIC_DUMP_MASK_MAX || | ||
1029 | val->flag < QLCNIC_DUMP_MASK_MIN) { | ||
1030 | netdev_info(netdev, | ||
1031 | "Invalid dump level: 0x%x\n", val->flag); | ||
1032 | ret = -EINVAL; | ||
1033 | goto out; | ||
1034 | } | ||
1035 | if (qlcnic_api_lock(adapter)) | ||
1036 | return -EIO; | ||
1037 | fw_dump->tmpl_hdr->drv_cap_mask = val->flag & 0xff; | ||
1038 | qlcnic_api_unlock(adapter); | ||
1039 | netdev_info(netdev, "Driver mask changed to: 0x%x\n", | ||
1040 | fw_dump->tmpl_hdr->drv_cap_mask); | ||
1041 | } | ||
1042 | out: | ||
1043 | return ret; | ||
1035 | } | 1044 | } |
1036 | 1045 | ||
1037 | const struct ethtool_ops qlcnic_ethtool_ops = { | 1046 | const struct ethtool_ops qlcnic_ethtool_ops = { |
@@ -1045,26 +1054,22 @@ const struct ethtool_ops qlcnic_ethtool_ops = { | |||
1045 | .get_eeprom = qlcnic_get_eeprom, | 1054 | .get_eeprom = qlcnic_get_eeprom, |
1046 | .get_ringparam = qlcnic_get_ringparam, | 1055 | .get_ringparam = qlcnic_get_ringparam, |
1047 | .set_ringparam = qlcnic_set_ringparam, | 1056 | .set_ringparam = qlcnic_set_ringparam, |
1057 | .get_channels = qlcnic_get_channels, | ||
1058 | .set_channels = qlcnic_set_channels, | ||
1048 | .get_pauseparam = qlcnic_get_pauseparam, | 1059 | .get_pauseparam = qlcnic_get_pauseparam, |
1049 | .set_pauseparam = qlcnic_set_pauseparam, | 1060 | .set_pauseparam = qlcnic_set_pauseparam, |
1050 | .get_tx_csum = qlcnic_get_tx_csum, | ||
1051 | .set_tx_csum = ethtool_op_set_tx_csum, | ||
1052 | .set_sg = ethtool_op_set_sg, | ||
1053 | .get_tso = qlcnic_get_tso, | ||
1054 | .set_tso = qlcnic_set_tso, | ||
1055 | .get_wol = qlcnic_get_wol, | 1061 | .get_wol = qlcnic_get_wol, |
1056 | .set_wol = qlcnic_set_wol, | 1062 | .set_wol = qlcnic_set_wol, |
1057 | .self_test = qlcnic_diag_test, | 1063 | .self_test = qlcnic_diag_test, |
1058 | .get_strings = qlcnic_get_strings, | 1064 | .get_strings = qlcnic_get_strings, |
1059 | .get_ethtool_stats = qlcnic_get_ethtool_stats, | 1065 | .get_ethtool_stats = qlcnic_get_ethtool_stats, |
1060 | .get_sset_count = qlcnic_get_sset_count, | 1066 | .get_sset_count = qlcnic_get_sset_count, |
1061 | .get_rx_csum = qlcnic_get_rx_csum, | ||
1062 | .set_rx_csum = qlcnic_set_rx_csum, | ||
1063 | .get_coalesce = qlcnic_get_intr_coalesce, | 1067 | .get_coalesce = qlcnic_get_intr_coalesce, |
1064 | .set_coalesce = qlcnic_set_intr_coalesce, | 1068 | .set_coalesce = qlcnic_set_intr_coalesce, |
1065 | .get_flags = ethtool_op_get_flags, | 1069 | .set_phys_id = qlcnic_set_led, |
1066 | .set_flags = qlcnic_set_flags, | ||
1067 | .phys_id = qlcnic_blink_led, | ||
1068 | .set_msglevel = qlcnic_set_msglevel, | 1070 | .set_msglevel = qlcnic_set_msglevel, |
1069 | .get_msglevel = qlcnic_get_msglevel, | 1071 | .get_msglevel = qlcnic_get_msglevel, |
1072 | .get_dump_flag = qlcnic_get_dump_flag, | ||
1073 | .get_dump_data = qlcnic_get_dump_data, | ||
1074 | .set_dump = qlcnic_set_dump, | ||
1070 | }; | 1075 | }; |
diff --git a/drivers/net/qlcnic/qlcnic_hdr.h b/drivers/net/qlcnic/qlcnic_hdr.h index 15fc32070be3..d14506f764e0 100644 --- a/drivers/net/qlcnic/qlcnic_hdr.h +++ b/drivers/net/qlcnic/qlcnic_hdr.h | |||
@@ -1,25 +1,8 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2009 - QLogic Corporation. | 2 | * QLogic qlcnic NIC Driver |
3 | * All rights reserved. | 3 | * Copyright (c) 2009-2010 QLogic Corporation |
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License | ||
7 | * as published by the Free Software Foundation; either version 2 | ||
8 | * of the License, or (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, but | ||
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, | ||
18 | * MA 02111-1307, USA. | ||
19 | * | ||
20 | * The full GNU General Public License is included in this distribution | ||
21 | * in the file called "COPYING". | ||
22 | * | 4 | * |
5 | * See LICENSE.qlcnic for copyright and licensing details. | ||
23 | */ | 6 | */ |
24 | 7 | ||
25 | #ifndef __QLCNIC_HDR_H_ | 8 | #ifndef __QLCNIC_HDR_H_ |
@@ -509,10 +492,10 @@ enum { | |||
509 | 492 | ||
510 | #define TEST_AGT_CTRL (0x00) | 493 | #define TEST_AGT_CTRL (0x00) |
511 | 494 | ||
512 | #define TA_CTL_START 1 | 495 | #define TA_CTL_START BIT_0 |
513 | #define TA_CTL_ENABLE 2 | 496 | #define TA_CTL_ENABLE BIT_1 |
514 | #define TA_CTL_WRITE 4 | 497 | #define TA_CTL_WRITE BIT_2 |
515 | #define TA_CTL_BUSY 8 | 498 | #define TA_CTL_BUSY BIT_3 |
516 | 499 | ||
517 | /* | 500 | /* |
518 | * Register offsets for MN | 501 | * Register offsets for MN |
@@ -556,18 +539,18 @@ enum { | |||
556 | #define XG_LINK_UP 0x10 | 539 | #define XG_LINK_UP 0x10 |
557 | #define XG_LINK_DOWN 0x20 | 540 | #define XG_LINK_DOWN 0x20 |
558 | 541 | ||
559 | #define XG_LINK_UP_P3 0x01 | 542 | #define XG_LINK_UP_P3P 0x01 |
560 | #define XG_LINK_DOWN_P3 0x02 | 543 | #define XG_LINK_DOWN_P3P 0x02 |
561 | #define XG_LINK_STATE_P3_MASK 0xf | 544 | #define XG_LINK_STATE_P3P_MASK 0xf |
562 | #define XG_LINK_STATE_P3(pcifn, val) \ | 545 | #define XG_LINK_STATE_P3P(pcifn, val) \ |
563 | (((val) >> ((pcifn) * 4)) & XG_LINK_STATE_P3_MASK) | 546 | (((val) >> ((pcifn) * 4)) & XG_LINK_STATE_P3P_MASK) |
564 | 547 | ||
565 | #define P3_LINK_SPEED_MHZ 100 | 548 | #define P3P_LINK_SPEED_MHZ 100 |
566 | #define P3_LINK_SPEED_MASK 0xff | 549 | #define P3P_LINK_SPEED_MASK 0xff |
567 | #define P3_LINK_SPEED_REG(pcifn) \ | 550 | #define P3P_LINK_SPEED_REG(pcifn) \ |
568 | (CRB_PF_LINK_SPEED_1 + (((pcifn) / 4) * 4)) | 551 | (CRB_PF_LINK_SPEED_1 + (((pcifn) / 4) * 4)) |
569 | #define P3_LINK_SPEED_VAL(pcifn, reg) \ | 552 | #define P3P_LINK_SPEED_VAL(pcifn, reg) \ |
570 | (((reg) >> (8 * ((pcifn) & 0x3))) & P3_LINK_SPEED_MASK) | 553 | (((reg) >> (8 * ((pcifn) & 0x3))) & P3P_LINK_SPEED_MASK) |
571 | 554 | ||
572 | #define QLCNIC_CAM_RAM_BASE (QLCNIC_CRB_CAM + 0x02000) | 555 | #define QLCNIC_CAM_RAM_BASE (QLCNIC_CRB_CAM + 0x02000) |
573 | #define QLCNIC_CAM_RAM(reg) (QLCNIC_CAM_RAM_BASE + (reg)) | 556 | #define QLCNIC_CAM_RAM(reg) (QLCNIC_CAM_RAM_BASE + (reg)) |
@@ -592,7 +575,7 @@ enum { | |||
592 | #define CRB_CMDPEG_STATE (QLCNIC_REG(0x50)) | 575 | #define CRB_CMDPEG_STATE (QLCNIC_REG(0x50)) |
593 | #define CRB_RCVPEG_STATE (QLCNIC_REG(0x13c)) | 576 | #define CRB_RCVPEG_STATE (QLCNIC_REG(0x13c)) |
594 | 577 | ||
595 | #define CRB_XG_STATE_P3 (QLCNIC_REG(0x98)) | 578 | #define CRB_XG_STATE_P3P (QLCNIC_REG(0x98)) |
596 | #define CRB_PF_LINK_SPEED_1 (QLCNIC_REG(0xe8)) | 579 | #define CRB_PF_LINK_SPEED_1 (QLCNIC_REG(0xe8)) |
597 | #define CRB_PF_LINK_SPEED_2 (QLCNIC_REG(0xec)) | 580 | #define CRB_PF_LINK_SPEED_2 (QLCNIC_REG(0xec)) |
598 | 581 | ||
@@ -638,7 +621,7 @@ enum { | |||
638 | #define PCIX_INT_MASK (0x10104) | 621 | #define PCIX_INT_MASK (0x10104) |
639 | 622 | ||
640 | #define PCIX_OCM_WINDOW (0x10800) | 623 | #define PCIX_OCM_WINDOW (0x10800) |
641 | #define PCIX_OCM_WINDOW_REG(func) (PCIX_OCM_WINDOW + 0x20 * (func)) | 624 | #define PCIX_OCM_WINDOW_REG(func) (PCIX_OCM_WINDOW + 0x4 * (func)) |
642 | 625 | ||
643 | #define PCIX_TARGET_STATUS (0x10118) | 626 | #define PCIX_TARGET_STATUS (0x10118) |
644 | #define PCIX_TARGET_STATUS_F1 (0x10160) | 627 | #define PCIX_TARGET_STATUS_F1 (0x10160) |
@@ -698,7 +681,7 @@ enum { | |||
698 | #define QLCNIC_PEG_ALIVE_COUNTER (QLCNIC_CAM_RAM(0xb0)) | 681 | #define QLCNIC_PEG_ALIVE_COUNTER (QLCNIC_CAM_RAM(0xb0)) |
699 | #define QLCNIC_PEG_HALT_STATUS1 (QLCNIC_CAM_RAM(0xa8)) | 682 | #define QLCNIC_PEG_HALT_STATUS1 (QLCNIC_CAM_RAM(0xa8)) |
700 | #define QLCNIC_PEG_HALT_STATUS2 (QLCNIC_CAM_RAM(0xac)) | 683 | #define QLCNIC_PEG_HALT_STATUS2 (QLCNIC_CAM_RAM(0xac)) |
701 | #define QLCNIC_CRB_DEV_REF_COUNT (QLCNIC_CAM_RAM(0x138)) | 684 | #define QLCNIC_CRB_DRV_ACTIVE (QLCNIC_CAM_RAM(0x138)) |
702 | #define QLCNIC_CRB_DEV_STATE (QLCNIC_CAM_RAM(0x140)) | 685 | #define QLCNIC_CRB_DEV_STATE (QLCNIC_CAM_RAM(0x140)) |
703 | 686 | ||
704 | #define QLCNIC_CRB_DRV_STATE (QLCNIC_CAM_RAM(0x144)) | 687 | #define QLCNIC_CRB_DRV_STATE (QLCNIC_CAM_RAM(0x144)) |
@@ -718,10 +701,11 @@ enum { | |||
718 | #define QLCNIC_DEV_FAILED 0x6 | 701 | #define QLCNIC_DEV_FAILED 0x6 |
719 | #define QLCNIC_DEV_QUISCENT 0x7 | 702 | #define QLCNIC_DEV_QUISCENT 0x7 |
720 | 703 | ||
721 | #define QLCNIC_DEV_NPAR_NOT_RDY 0 | 704 | #define QLCNIC_DEV_NPAR_NON_OPER 0 /* NON Operational */ |
722 | #define QLCNIC_DEV_NPAR_RDY 1 | 705 | #define QLCNIC_DEV_NPAR_OPER 1 /* NPAR Operational */ |
706 | #define QLCNIC_DEV_NPAR_OPER_TIMEO 30 /* Operational time out */ | ||
723 | 707 | ||
724 | #define QLC_DEV_CHECK_ACTIVE(VAL, FN) ((VAL) &= (1 << (FN * 4))) | 708 | #define QLC_DEV_CHECK_ACTIVE(VAL, FN) ((VAL) & (1 << (FN * 4))) |
725 | #define QLC_DEV_SET_REF_CNT(VAL, FN) ((VAL) |= (1 << (FN * 4))) | 709 | #define QLC_DEV_SET_REF_CNT(VAL, FN) ((VAL) |= (1 << (FN * 4))) |
726 | #define QLC_DEV_CLR_REF_CNT(VAL, FN) ((VAL) &= ~(1 << (FN * 4))) | 710 | #define QLC_DEV_CLR_REF_CNT(VAL, FN) ((VAL) &= ~(1 << (FN * 4))) |
727 | #define QLC_DEV_SET_RST_RDY(VAL, FN) ((VAL) |= (1 << (FN * 4))) | 711 | #define QLC_DEV_SET_RST_RDY(VAL, FN) ((VAL) |= (1 << (FN * 4))) |
@@ -744,6 +728,15 @@ enum { | |||
744 | #define FW_POLL_DELAY (1 * HZ) | 728 | #define FW_POLL_DELAY (1 * HZ) |
745 | #define FW_FAIL_THRESH 2 | 729 | #define FW_FAIL_THRESH 2 |
746 | 730 | ||
731 | #define QLCNIC_RESET_TIMEOUT_SECS 10 | ||
732 | #define QLCNIC_INIT_TIMEOUT_SECS 30 | ||
733 | #define QLCNIC_RCVPEG_CHECK_RETRY_COUNT 2000 | ||
734 | #define QLCNIC_RCVPEG_CHECK_DELAY 10 | ||
735 | #define QLCNIC_CMDPEG_CHECK_RETRY_COUNT 60 | ||
736 | #define QLCNIC_CMDPEG_CHECK_DELAY 500 | ||
737 | #define QLCNIC_HEARTBEAT_PERIOD_MSECS 200 | ||
738 | #define QLCNIC_HEARTBEAT_CHECK_RETRY_COUNT 45 | ||
739 | |||
747 | #define ISR_MSI_INT_TRIGGER(FUNC) (QLCNIC_PCIX_PS_REG(PCIX_MSI_F(FUNC))) | 740 | #define ISR_MSI_INT_TRIGGER(FUNC) (QLCNIC_PCIX_PS_REG(PCIX_MSI_F(FUNC))) |
748 | #define ISR_LEGACY_INT_TRIGGERED(VAL) (((VAL) & 0x300) == 0x200) | 741 | #define ISR_LEGACY_INT_TRIGGERED(VAL) (((VAL) & 0x300) == 0x200) |
749 | 742 | ||
@@ -770,6 +763,39 @@ struct qlcnic_legacy_intr_set { | |||
770 | #define QLCNIC_DRV_OP_MODE 0x1b2170 | 763 | #define QLCNIC_DRV_OP_MODE 0x1b2170 |
771 | #define QLCNIC_MSIX_BASE 0x132110 | 764 | #define QLCNIC_MSIX_BASE 0x132110 |
772 | #define QLCNIC_MAX_PCI_FUNC 8 | 765 | #define QLCNIC_MAX_PCI_FUNC 8 |
766 | #define QLCNIC_MAX_VLAN_FILTERS 64 | ||
767 | |||
768 | /* FW dump defines */ | ||
769 | #define MIU_TEST_CTR 0x41000090 | ||
770 | #define MIU_TEST_ADDR_LO 0x41000094 | ||
771 | #define MIU_TEST_ADDR_HI 0x41000098 | ||
772 | #define FLASH_ROM_WINDOW 0x42110030 | ||
773 | #define FLASH_ROM_DATA 0x42150000 | ||
774 | |||
775 | static const u32 MIU_TEST_READ_DATA[] = { | ||
776 | 0x410000A8, 0x410000AC, 0x410000B8, 0x410000BC, }; | ||
777 | |||
778 | #define QLCNIC_FW_DUMP_REG1 0x00130060 | ||
779 | #define QLCNIC_FW_DUMP_REG2 0x001e0000 | ||
780 | #define QLCNIC_FLASH_SEM2_LK 0x0013C010 | ||
781 | #define QLCNIC_FLASH_SEM2_ULK 0x0013C014 | ||
782 | #define QLCNIC_FLASH_LOCK_ID 0x001B2100 | ||
783 | |||
784 | #define QLCNIC_RD_DUMP_REG(addr, bar0, data) do { \ | ||
785 | writel((addr & 0xFFFF0000), (void *) (bar0 + \ | ||
786 | QLCNIC_FW_DUMP_REG1)); \ | ||
787 | readl((void *) (bar0 + QLCNIC_FW_DUMP_REG1)); \ | ||
788 | *data = readl((void *) (bar0 + QLCNIC_FW_DUMP_REG2 + \ | ||
789 | LSW(addr))); \ | ||
790 | } while (0) | ||
791 | |||
792 | #define QLCNIC_WR_DUMP_REG(addr, bar0, data) do { \ | ||
793 | writel((addr & 0xFFFF0000), (void *) (bar0 + \ | ||
794 | QLCNIC_FW_DUMP_REG1)); \ | ||
795 | readl((void *) (bar0 + QLCNIC_FW_DUMP_REG1)); \ | ||
796 | writel(data, (void *) (bar0 + QLCNIC_FW_DUMP_REG2 + LSW(addr)));\ | ||
797 | readl((void *) (bar0 + QLCNIC_FW_DUMP_REG2 + LSW(addr))); \ | ||
798 | } while (0) | ||
773 | 799 | ||
774 | /* PCI function operational mode */ | 800 | /* PCI function operational mode */ |
775 | enum { | 801 | enum { |
@@ -778,6 +804,12 @@ enum { | |||
778 | QLCNIC_NON_PRIV_FUNC = 2 | 804 | QLCNIC_NON_PRIV_FUNC = 2 |
779 | }; | 805 | }; |
780 | 806 | ||
807 | enum { | ||
808 | QLCNIC_PORT_DEFAULTS = 0, | ||
809 | QLCNIC_ADD_VLAN = 1, | ||
810 | QLCNIC_DEL_VLAN = 2 | ||
811 | }; | ||
812 | |||
781 | #define QLC_DEV_DRV_DEFAULT 0x11111111 | 813 | #define QLC_DEV_DRV_DEFAULT 0x11111111 |
782 | 814 | ||
783 | #define LSB(x) ((uint8_t)(x)) | 815 | #define LSB(x) ((uint8_t)(x)) |
diff --git a/drivers/net/qlcnic/qlcnic_hw.c b/drivers/net/qlcnic/qlcnic_hw.c index e08c8b0556a4..a5d9fbf9d816 100644 --- a/drivers/net/qlcnic/qlcnic_hw.c +++ b/drivers/net/qlcnic/qlcnic_hw.c | |||
@@ -1,31 +1,15 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2009 - QLogic Corporation. | 2 | * QLogic qlcnic NIC Driver |
3 | * All rights reserved. | 3 | * Copyright (c) 2009-2010 QLogic Corporation |
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License | ||
7 | * as published by the Free Software Foundation; either version 2 | ||
8 | * of the License, or (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, but | ||
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, | ||
18 | * MA 02111-1307, USA. | ||
19 | * | ||
20 | * The full GNU General Public License is included in this distribution | ||
21 | * in the file called "COPYING". | ||
22 | * | 4 | * |
5 | * See LICENSE.qlcnic for copyright and licensing details. | ||
23 | */ | 6 | */ |
24 | 7 | ||
25 | #include "qlcnic.h" | 8 | #include "qlcnic.h" |
26 | 9 | ||
27 | #include <linux/slab.h> | 10 | #include <linux/slab.h> |
28 | #include <net/ip.h> | 11 | #include <net/ip.h> |
12 | #include <linux/bitops.h> | ||
29 | 13 | ||
30 | #define MASK(n) ((1ULL<<(n))-1) | 14 | #define MASK(n) ((1ULL<<(n))-1) |
31 | #define OCM_WIN_P3P(addr) (addr & 0xffc0000) | 15 | #define OCM_WIN_P3P(addr) (addr & 0xffc0000) |
@@ -297,8 +281,8 @@ qlcnic_pcie_sem_lock(struct qlcnic_adapter *adapter, int sem, u32 id_reg) | |||
297 | break; | 281 | break; |
298 | if (++timeout >= QLCNIC_PCIE_SEM_TIMEOUT) { | 282 | if (++timeout >= QLCNIC_PCIE_SEM_TIMEOUT) { |
299 | dev_err(&adapter->pdev->dev, | 283 | dev_err(&adapter->pdev->dev, |
300 | "Failed to acquire sem=%d lock;reg_id=%d\n", | 284 | "Failed to acquire sem=%d lock; holdby=%d\n", |
301 | sem, id_reg); | 285 | sem, id_reg ? QLCRD32(adapter, id_reg) : -1); |
302 | return -EIO; | 286 | return -EIO; |
303 | } | 287 | } |
304 | msleep(1); | 288 | msleep(1); |
@@ -375,10 +359,11 @@ qlcnic_send_cmd_descs(struct qlcnic_adapter *adapter, | |||
375 | 359 | ||
376 | static int | 360 | static int |
377 | qlcnic_sre_macaddr_change(struct qlcnic_adapter *adapter, u8 *addr, | 361 | qlcnic_sre_macaddr_change(struct qlcnic_adapter *adapter, u8 *addr, |
378 | unsigned op) | 362 | __le16 vlan_id, unsigned op) |
379 | { | 363 | { |
380 | struct qlcnic_nic_req req; | 364 | struct qlcnic_nic_req req; |
381 | struct qlcnic_mac_req *mac_req; | 365 | struct qlcnic_mac_req *mac_req; |
366 | struct qlcnic_vlan_req *vlan_req; | ||
382 | u64 word; | 367 | u64 word; |
383 | 368 | ||
384 | memset(&req, 0, sizeof(struct qlcnic_nic_req)); | 369 | memset(&req, 0, sizeof(struct qlcnic_nic_req)); |
@@ -391,10 +376,13 @@ qlcnic_sre_macaddr_change(struct qlcnic_adapter *adapter, u8 *addr, | |||
391 | mac_req->op = op; | 376 | mac_req->op = op; |
392 | memcpy(mac_req->mac_addr, addr, 6); | 377 | memcpy(mac_req->mac_addr, addr, 6); |
393 | 378 | ||
379 | vlan_req = (struct qlcnic_vlan_req *)&req.words[1]; | ||
380 | vlan_req->vlan_id = vlan_id; | ||
381 | |||
394 | return qlcnic_send_cmd_descs(adapter, (struct cmd_desc_type0 *)&req, 1); | 382 | return qlcnic_send_cmd_descs(adapter, (struct cmd_desc_type0 *)&req, 1); |
395 | } | 383 | } |
396 | 384 | ||
397 | static int qlcnic_nic_add_mac(struct qlcnic_adapter *adapter, u8 *addr) | 385 | static int qlcnic_nic_add_mac(struct qlcnic_adapter *adapter, const u8 *addr) |
398 | { | 386 | { |
399 | struct list_head *head; | 387 | struct list_head *head; |
400 | struct qlcnic_mac_list_s *cur; | 388 | struct qlcnic_mac_list_s *cur; |
@@ -415,7 +403,7 @@ static int qlcnic_nic_add_mac(struct qlcnic_adapter *adapter, u8 *addr) | |||
415 | memcpy(cur->mac_addr, addr, ETH_ALEN); | 403 | memcpy(cur->mac_addr, addr, ETH_ALEN); |
416 | 404 | ||
417 | if (qlcnic_sre_macaddr_change(adapter, | 405 | if (qlcnic_sre_macaddr_change(adapter, |
418 | cur->mac_addr, QLCNIC_MAC_ADD)) { | 406 | cur->mac_addr, 0, QLCNIC_MAC_ADD)) { |
419 | kfree(cur); | 407 | kfree(cur); |
420 | return -EIO; | 408 | return -EIO; |
421 | } | 409 | } |
@@ -428,7 +416,9 @@ void qlcnic_set_multi(struct net_device *netdev) | |||
428 | { | 416 | { |
429 | struct qlcnic_adapter *adapter = netdev_priv(netdev); | 417 | struct qlcnic_adapter *adapter = netdev_priv(netdev); |
430 | struct netdev_hw_addr *ha; | 418 | struct netdev_hw_addr *ha; |
431 | u8 bcast_addr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; | 419 | static const u8 bcast_addr[ETH_ALEN] = { |
420 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff | ||
421 | }; | ||
432 | u32 mode = VPORT_MISS_MODE_DROP; | 422 | u32 mode = VPORT_MISS_MODE_DROP; |
433 | 423 | ||
434 | if (!test_bit(__QLCNIC_FW_ATTACHED, &adapter->state)) | 424 | if (!test_bit(__QLCNIC_FW_ATTACHED, &adapter->state)) |
@@ -438,7 +428,8 @@ void qlcnic_set_multi(struct net_device *netdev) | |||
438 | qlcnic_nic_add_mac(adapter, bcast_addr); | 428 | qlcnic_nic_add_mac(adapter, bcast_addr); |
439 | 429 | ||
440 | if (netdev->flags & IFF_PROMISC) { | 430 | if (netdev->flags & IFF_PROMISC) { |
441 | mode = VPORT_MISS_MODE_ACCEPT_ALL; | 431 | if (!(adapter->flags & QLCNIC_PROMISC_DISABLED)) |
432 | mode = VPORT_MISS_MODE_ACCEPT_ALL; | ||
442 | goto send_fw_cmd; | 433 | goto send_fw_cmd; |
443 | } | 434 | } |
444 | 435 | ||
@@ -467,7 +458,7 @@ int qlcnic_nic_set_promisc(struct qlcnic_adapter *adapter, u32 mode) | |||
467 | 458 | ||
468 | req.qhdr = cpu_to_le64(QLCNIC_HOST_REQUEST << 23); | 459 | req.qhdr = cpu_to_le64(QLCNIC_HOST_REQUEST << 23); |
469 | 460 | ||
470 | word = QLCNIC_H2C_OPCODE_PROXY_SET_VPORT_MISS_MODE | | 461 | word = QLCNIC_H2C_OPCODE_SET_MAC_RECEIVE_MODE | |
471 | ((u64)adapter->portnum << 16); | 462 | ((u64)adapter->portnum << 16); |
472 | req.req_hdr = cpu_to_le64(word); | 463 | req.req_hdr = cpu_to_le64(word); |
473 | 464 | ||
@@ -485,13 +476,62 @@ void qlcnic_free_mac_list(struct qlcnic_adapter *adapter) | |||
485 | while (!list_empty(head)) { | 476 | while (!list_empty(head)) { |
486 | cur = list_entry(head->next, struct qlcnic_mac_list_s, list); | 477 | cur = list_entry(head->next, struct qlcnic_mac_list_s, list); |
487 | qlcnic_sre_macaddr_change(adapter, | 478 | qlcnic_sre_macaddr_change(adapter, |
488 | cur->mac_addr, QLCNIC_MAC_DEL); | 479 | cur->mac_addr, 0, QLCNIC_MAC_DEL); |
489 | list_del(&cur->list); | 480 | list_del(&cur->list); |
490 | kfree(cur); | 481 | kfree(cur); |
491 | } | 482 | } |
492 | } | 483 | } |
493 | 484 | ||
494 | #define QLCNIC_CONFIG_INTR_COALESCE 3 | 485 | void qlcnic_prune_lb_filters(struct qlcnic_adapter *adapter) |
486 | { | ||
487 | struct qlcnic_filter *tmp_fil; | ||
488 | struct hlist_node *tmp_hnode, *n; | ||
489 | struct hlist_head *head; | ||
490 | int i; | ||
491 | |||
492 | for (i = 0; i < adapter->fhash.fmax; i++) { | ||
493 | head = &(adapter->fhash.fhead[i]); | ||
494 | |||
495 | hlist_for_each_entry_safe(tmp_fil, tmp_hnode, n, head, fnode) | ||
496 | { | ||
497 | if (jiffies > | ||
498 | (QLCNIC_FILTER_AGE * HZ + tmp_fil->ftime)) { | ||
499 | qlcnic_sre_macaddr_change(adapter, | ||
500 | tmp_fil->faddr, tmp_fil->vlan_id, | ||
501 | tmp_fil->vlan_id ? QLCNIC_MAC_VLAN_DEL : | ||
502 | QLCNIC_MAC_DEL); | ||
503 | spin_lock_bh(&adapter->mac_learn_lock); | ||
504 | adapter->fhash.fnum--; | ||
505 | hlist_del(&tmp_fil->fnode); | ||
506 | spin_unlock_bh(&adapter->mac_learn_lock); | ||
507 | kfree(tmp_fil); | ||
508 | } | ||
509 | } | ||
510 | } | ||
511 | } | ||
512 | |||
513 | void qlcnic_delete_lb_filters(struct qlcnic_adapter *adapter) | ||
514 | { | ||
515 | struct qlcnic_filter *tmp_fil; | ||
516 | struct hlist_node *tmp_hnode, *n; | ||
517 | struct hlist_head *head; | ||
518 | int i; | ||
519 | |||
520 | for (i = 0; i < adapter->fhash.fmax; i++) { | ||
521 | head = &(adapter->fhash.fhead[i]); | ||
522 | |||
523 | hlist_for_each_entry_safe(tmp_fil, tmp_hnode, n, head, fnode) { | ||
524 | qlcnic_sre_macaddr_change(adapter, tmp_fil->faddr, | ||
525 | tmp_fil->vlan_id, tmp_fil->vlan_id ? | ||
526 | QLCNIC_MAC_VLAN_DEL : QLCNIC_MAC_DEL); | ||
527 | spin_lock_bh(&adapter->mac_learn_lock); | ||
528 | adapter->fhash.fnum--; | ||
529 | hlist_del(&tmp_fil->fnode); | ||
530 | spin_unlock_bh(&adapter->mac_learn_lock); | ||
531 | kfree(tmp_fil); | ||
532 | } | ||
533 | } | ||
534 | } | ||
495 | 535 | ||
496 | /* | 536 | /* |
497 | * Send the interrupt coalescing parameter set by ethtool to the card. | 537 | * Send the interrupt coalescing parameter set by ethtool to the card. |
@@ -499,25 +539,25 @@ void qlcnic_free_mac_list(struct qlcnic_adapter *adapter) | |||
499 | int qlcnic_config_intr_coalesce(struct qlcnic_adapter *adapter) | 539 | int qlcnic_config_intr_coalesce(struct qlcnic_adapter *adapter) |
500 | { | 540 | { |
501 | struct qlcnic_nic_req req; | 541 | struct qlcnic_nic_req req; |
502 | u64 word[6]; | 542 | int rv; |
503 | int rv, i; | ||
504 | 543 | ||
505 | memset(&req, 0, sizeof(struct qlcnic_nic_req)); | 544 | memset(&req, 0, sizeof(struct qlcnic_nic_req)); |
506 | 545 | ||
507 | req.qhdr = cpu_to_le64(QLCNIC_HOST_REQUEST << 23); | 546 | req.qhdr = cpu_to_le64(QLCNIC_HOST_REQUEST << 23); |
508 | 547 | ||
509 | word[0] = QLCNIC_CONFIG_INTR_COALESCE | ((u64)adapter->portnum << 16); | 548 | req.req_hdr = cpu_to_le64(QLCNIC_CONFIG_INTR_COALESCE | |
510 | req.req_hdr = cpu_to_le64(word[0]); | 549 | ((u64) adapter->portnum << 16)); |
511 | |||
512 | memcpy(&word[0], &adapter->coal, sizeof(adapter->coal)); | ||
513 | for (i = 0; i < 6; i++) | ||
514 | req.words[i] = cpu_to_le64(word[i]); | ||
515 | 550 | ||
551 | req.words[0] = cpu_to_le64(((u64) adapter->ahw->coal.flag) << 32); | ||
552 | req.words[2] = cpu_to_le64(adapter->ahw->coal.rx_packets | | ||
553 | ((u64) adapter->ahw->coal.rx_time_us) << 16); | ||
554 | req.words[5] = cpu_to_le64(adapter->ahw->coal.timer_out | | ||
555 | ((u64) adapter->ahw->coal.type) << 32 | | ||
556 | ((u64) adapter->ahw->coal.sts_ring_mask) << 40); | ||
516 | rv = qlcnic_send_cmd_descs(adapter, (struct cmd_desc_type0 *)&req, 1); | 557 | rv = qlcnic_send_cmd_descs(adapter, (struct cmd_desc_type0 *)&req, 1); |
517 | if (rv != 0) | 558 | if (rv != 0) |
518 | dev_err(&adapter->netdev->dev, | 559 | dev_err(&adapter->netdev->dev, |
519 | "Could not send interrupt coalescing parameters\n"); | 560 | "Could not send interrupt coalescing parameters\n"); |
520 | |||
521 | return rv; | 561 | return rv; |
522 | } | 562 | } |
523 | 563 | ||
@@ -527,7 +567,7 @@ int qlcnic_config_hw_lro(struct qlcnic_adapter *adapter, int enable) | |||
527 | u64 word; | 567 | u64 word; |
528 | int rv; | 568 | int rv; |
529 | 569 | ||
530 | if ((adapter->flags & QLCNIC_LRO_ENABLED) == enable) | 570 | if (!test_bit(__QLCNIC_FW_ATTACHED, &adapter->state)) |
531 | return 0; | 571 | return 0; |
532 | 572 | ||
533 | memset(&req, 0, sizeof(struct qlcnic_nic_req)); | 573 | memset(&req, 0, sizeof(struct qlcnic_nic_req)); |
@@ -544,8 +584,6 @@ int qlcnic_config_hw_lro(struct qlcnic_adapter *adapter, int enable) | |||
544 | dev_err(&adapter->netdev->dev, | 584 | dev_err(&adapter->netdev->dev, |
545 | "Could not send configure hw lro request\n"); | 585 | "Could not send configure hw lro request\n"); |
546 | 586 | ||
547 | adapter->flags ^= QLCNIC_LRO_ENABLED; | ||
548 | |||
549 | return rv; | 587 | return rv; |
550 | } | 588 | } |
551 | 589 | ||
@@ -587,10 +625,11 @@ int qlcnic_config_rss(struct qlcnic_adapter *adapter, int enable) | |||
587 | u64 word; | 625 | u64 word; |
588 | int i, rv; | 626 | int i, rv; |
589 | 627 | ||
590 | const u64 key[] = { 0xbeac01fa6a42b73bULL, 0x8030f20c77cb2da3ULL, | 628 | static const u64 key[] = { |
591 | 0xae7b30b4d0ca2bcbULL, 0x43a38fb04167253dULL, | 629 | 0xbeac01fa6a42b73bULL, 0x8030f20c77cb2da3ULL, |
592 | 0x255b0ec26d5a56daULL }; | 630 | 0xae7b30b4d0ca2bcbULL, 0x43a38fb04167253dULL, |
593 | 631 | 0x255b0ec26d5a56daULL | |
632 | }; | ||
594 | 633 | ||
595 | memset(&req, 0, sizeof(struct qlcnic_nic_req)); | 634 | memset(&req, 0, sizeof(struct qlcnic_nic_req)); |
596 | req.qhdr = cpu_to_le64(QLCNIC_HOST_REQUEST << 23); | 635 | req.qhdr = cpu_to_le64(QLCNIC_HOST_REQUEST << 23); |
@@ -623,9 +662,10 @@ int qlcnic_config_rss(struct qlcnic_adapter *adapter, int enable) | |||
623 | return rv; | 662 | return rv; |
624 | } | 663 | } |
625 | 664 | ||
626 | int qlcnic_config_ipaddr(struct qlcnic_adapter *adapter, u32 ip, int cmd) | 665 | int qlcnic_config_ipaddr(struct qlcnic_adapter *adapter, __be32 ip, int cmd) |
627 | { | 666 | { |
628 | struct qlcnic_nic_req req; | 667 | struct qlcnic_nic_req req; |
668 | struct qlcnic_ipaddr *ipa; | ||
629 | u64 word; | 669 | u64 word; |
630 | int rv; | 670 | int rv; |
631 | 671 | ||
@@ -636,7 +676,8 @@ int qlcnic_config_ipaddr(struct qlcnic_adapter *adapter, u32 ip, int cmd) | |||
636 | req.req_hdr = cpu_to_le64(word); | 676 | req.req_hdr = cpu_to_le64(word); |
637 | 677 | ||
638 | req.words[0] = cpu_to_le64(cmd); | 678 | req.words[0] = cpu_to_le64(cmd); |
639 | req.words[1] = cpu_to_le64(ip); | 679 | ipa = (struct qlcnic_ipaddr *)&req.words[1]; |
680 | ipa->ipv4 = ip; | ||
640 | 681 | ||
641 | rv = qlcnic_send_cmd_descs(adapter, (struct cmd_desc_type0 *)&req, 1); | 682 | rv = qlcnic_send_cmd_descs(adapter, (struct cmd_desc_type0 *)&req, 1); |
642 | if (rv != 0) | 683 | if (rv != 0) |
@@ -674,6 +715,9 @@ int qlcnic_send_lro_cleanup(struct qlcnic_adapter *adapter) | |||
674 | u64 word; | 715 | u64 word; |
675 | int rv; | 716 | int rv; |
676 | 717 | ||
718 | if (!test_bit(__QLCNIC_FW_ATTACHED, &adapter->state)) | ||
719 | return 0; | ||
720 | |||
677 | memset(&req, 0, sizeof(struct qlcnic_nic_req)); | 721 | memset(&req, 0, sizeof(struct qlcnic_nic_req)); |
678 | req.qhdr = cpu_to_le64(QLCNIC_HOST_REQUEST << 23); | 722 | req.qhdr = cpu_to_le64(QLCNIC_HOST_REQUEST << 23); |
679 | 723 | ||
@@ -701,9 +745,9 @@ int qlcnic_change_mtu(struct net_device *netdev, int mtu) | |||
701 | struct qlcnic_adapter *adapter = netdev_priv(netdev); | 745 | struct qlcnic_adapter *adapter = netdev_priv(netdev); |
702 | int rc = 0; | 746 | int rc = 0; |
703 | 747 | ||
704 | if (mtu > P3_MAX_MTU) { | 748 | if (mtu < P3P_MIN_MTU || mtu > P3P_MAX_MTU) { |
705 | dev_err(&adapter->netdev->dev, "mtu > %d bytes unsupported\n", | 749 | dev_err(&adapter->netdev->dev, "%d bytes < mtu < %d bytes" |
706 | P3_MAX_MTU); | 750 | " not supported\n", P3P_MAX_MTU, P3P_MIN_MTU); |
707 | return -EINVAL; | 751 | return -EINVAL; |
708 | } | 752 | } |
709 | 753 | ||
@@ -715,15 +759,39 @@ int qlcnic_change_mtu(struct net_device *netdev, int mtu) | |||
715 | return rc; | 759 | return rc; |
716 | } | 760 | } |
717 | 761 | ||
718 | int qlcnic_get_mac_addr(struct qlcnic_adapter *adapter, u8 *mac) | 762 | |
763 | u32 qlcnic_fix_features(struct net_device *netdev, u32 features) | ||
764 | { | ||
765 | struct qlcnic_adapter *adapter = netdev_priv(netdev); | ||
766 | |||
767 | if ((adapter->flags & QLCNIC_ESWITCH_ENABLED)) { | ||
768 | u32 changed = features ^ netdev->features; | ||
769 | features ^= changed & (NETIF_F_ALL_CSUM | NETIF_F_RXCSUM); | ||
770 | } | ||
771 | |||
772 | if (!(features & NETIF_F_RXCSUM)) | ||
773 | features &= ~NETIF_F_LRO; | ||
774 | |||
775 | return features; | ||
776 | } | ||
777 | |||
778 | |||
779 | int qlcnic_set_features(struct net_device *netdev, u32 features) | ||
719 | { | 780 | { |
720 | u32 crbaddr; | 781 | struct qlcnic_adapter *adapter = netdev_priv(netdev); |
721 | int pci_func = adapter->ahw.pci_func; | 782 | u32 changed = netdev->features ^ features; |
783 | int hw_lro = (features & NETIF_F_LRO) ? QLCNIC_LRO_ENABLED : 0; | ||
784 | |||
785 | if (!(changed & NETIF_F_LRO)) | ||
786 | return 0; | ||
722 | 787 | ||
723 | crbaddr = CRB_MAC_BLOCK_START + | 788 | netdev->features = features ^ NETIF_F_LRO; |
724 | (4 * ((pci_func/2) * 3)) + (4 * (pci_func & 1)); | ||
725 | 789 | ||
726 | qlcnic_fetch_mac(adapter, crbaddr, crbaddr+4, pci_func & 1, mac); | 790 | if (qlcnic_config_hw_lro(adapter, hw_lro)) |
791 | return -EIO; | ||
792 | |||
793 | if ((hw_lro == 0) && qlcnic_send_lro_cleanup(adapter)) | ||
794 | return -EIO; | ||
727 | 795 | ||
728 | return 0; | 796 | return 0; |
729 | } | 797 | } |
@@ -754,7 +822,7 @@ qlcnic_pci_get_crb_addr_2M(struct qlcnic_adapter *adapter, | |||
754 | m = &crb_128M_2M_map[CRB_BLK(off)].sub_block[CRB_SUBBLK(off)]; | 822 | m = &crb_128M_2M_map[CRB_BLK(off)].sub_block[CRB_SUBBLK(off)]; |
755 | 823 | ||
756 | if (m->valid && (m->start_128M <= off) && (m->end_128M > off)) { | 824 | if (m->valid && (m->start_128M <= off) && (m->end_128M > off)) { |
757 | *addr = adapter->ahw.pci_base0 + m->start_2M + | 825 | *addr = adapter->ahw->pci_base0 + m->start_2M + |
758 | (off - m->start_128M); | 826 | (off - m->start_128M); |
759 | return 0; | 827 | return 0; |
760 | } | 828 | } |
@@ -762,7 +830,7 @@ qlcnic_pci_get_crb_addr_2M(struct qlcnic_adapter *adapter, | |||
762 | /* | 830 | /* |
763 | * Not in direct map, use crb window | 831 | * Not in direct map, use crb window |
764 | */ | 832 | */ |
765 | *addr = adapter->ahw.pci_base0 + CRB_INDIRECT_2M + (off & MASK(16)); | 833 | *addr = adapter->ahw->pci_base0 + CRB_INDIRECT_2M + (off & MASK(16)); |
766 | return 1; | 834 | return 1; |
767 | } | 835 | } |
768 | 836 | ||
@@ -775,7 +843,7 @@ static int | |||
775 | qlcnic_pci_set_crbwindow_2M(struct qlcnic_adapter *adapter, ulong off) | 843 | qlcnic_pci_set_crbwindow_2M(struct qlcnic_adapter *adapter, ulong off) |
776 | { | 844 | { |
777 | u32 window; | 845 | u32 window; |
778 | void __iomem *addr = adapter->ahw.pci_base0 + CRB_WINDOW_2M; | 846 | void __iomem *addr = adapter->ahw->pci_base0 + CRB_WINDOW_2M; |
779 | 847 | ||
780 | off -= QLCNIC_PCI_CRBSPACE; | 848 | off -= QLCNIC_PCI_CRBSPACE; |
781 | 849 | ||
@@ -812,13 +880,13 @@ qlcnic_hw_write_wx_2M(struct qlcnic_adapter *adapter, ulong off, u32 data) | |||
812 | 880 | ||
813 | if (rv > 0) { | 881 | if (rv > 0) { |
814 | /* indirect access */ | 882 | /* indirect access */ |
815 | write_lock_irqsave(&adapter->ahw.crb_lock, flags); | 883 | write_lock_irqsave(&adapter->ahw->crb_lock, flags); |
816 | crb_win_lock(adapter); | 884 | crb_win_lock(adapter); |
817 | rv = qlcnic_pci_set_crbwindow_2M(adapter, off); | 885 | rv = qlcnic_pci_set_crbwindow_2M(adapter, off); |
818 | if (!rv) | 886 | if (!rv) |
819 | writel(data, addr); | 887 | writel(data, addr); |
820 | crb_win_unlock(adapter); | 888 | crb_win_unlock(adapter); |
821 | write_unlock_irqrestore(&adapter->ahw.crb_lock, flags); | 889 | write_unlock_irqrestore(&adapter->ahw->crb_lock, flags); |
822 | return rv; | 890 | return rv; |
823 | } | 891 | } |
824 | 892 | ||
@@ -843,12 +911,12 @@ qlcnic_hw_read_wx_2M(struct qlcnic_adapter *adapter, ulong off) | |||
843 | 911 | ||
844 | if (rv > 0) { | 912 | if (rv > 0) { |
845 | /* indirect access */ | 913 | /* indirect access */ |
846 | write_lock_irqsave(&adapter->ahw.crb_lock, flags); | 914 | write_lock_irqsave(&adapter->ahw->crb_lock, flags); |
847 | crb_win_lock(adapter); | 915 | crb_win_lock(adapter); |
848 | if (!qlcnic_pci_set_crbwindow_2M(adapter, off)) | 916 | if (!qlcnic_pci_set_crbwindow_2M(adapter, off)) |
849 | data = readl(addr); | 917 | data = readl(addr); |
850 | crb_win_unlock(adapter); | 918 | crb_win_unlock(adapter); |
851 | write_unlock_irqrestore(&adapter->ahw.crb_lock, flags); | 919 | write_unlock_irqrestore(&adapter->ahw->crb_lock, flags); |
852 | return data; | 920 | return data; |
853 | } | 921 | } |
854 | 922 | ||
@@ -878,9 +946,9 @@ qlcnic_pci_set_window_2M(struct qlcnic_adapter *adapter, | |||
878 | 946 | ||
879 | window = OCM_WIN_P3P(addr); | 947 | window = OCM_WIN_P3P(addr); |
880 | 948 | ||
881 | writel(window, adapter->ahw.ocm_win_crb); | 949 | writel(window, adapter->ahw->ocm_win_crb); |
882 | /* read back to flush */ | 950 | /* read back to flush */ |
883 | readl(adapter->ahw.ocm_win_crb); | 951 | readl(adapter->ahw->ocm_win_crb); |
884 | 952 | ||
885 | *start = QLCNIC_PCI_OCM0_2M + GET_MEM_OFFS_2M(addr); | 953 | *start = QLCNIC_PCI_OCM0_2M + GET_MEM_OFFS_2M(addr); |
886 | return 0; | 954 | return 0; |
@@ -894,13 +962,13 @@ qlcnic_pci_mem_access_direct(struct qlcnic_adapter *adapter, u64 off, | |||
894 | int ret; | 962 | int ret; |
895 | u32 start; | 963 | u32 start; |
896 | 964 | ||
897 | mutex_lock(&adapter->ahw.mem_lock); | 965 | mutex_lock(&adapter->ahw->mem_lock); |
898 | 966 | ||
899 | ret = qlcnic_pci_set_window_2M(adapter, off, &start); | 967 | ret = qlcnic_pci_set_window_2M(adapter, off, &start); |
900 | if (ret != 0) | 968 | if (ret != 0) |
901 | goto unlock; | 969 | goto unlock; |
902 | 970 | ||
903 | addr = adapter->ahw.pci_base0 + start; | 971 | addr = adapter->ahw->pci_base0 + start; |
904 | 972 | ||
905 | if (op == 0) /* read */ | 973 | if (op == 0) /* read */ |
906 | *data = readq(addr); | 974 | *data = readq(addr); |
@@ -908,7 +976,7 @@ qlcnic_pci_mem_access_direct(struct qlcnic_adapter *adapter, u64 off, | |||
908 | writeq(*data, addr); | 976 | writeq(*data, addr); |
909 | 977 | ||
910 | unlock: | 978 | unlock: |
911 | mutex_unlock(&adapter->ahw.mem_lock); | 979 | mutex_unlock(&adapter->ahw->mem_lock); |
912 | 980 | ||
913 | return ret; | 981 | return ret; |
914 | } | 982 | } |
@@ -916,23 +984,23 @@ unlock: | |||
916 | void | 984 | void |
917 | qlcnic_pci_camqm_read_2M(struct qlcnic_adapter *adapter, u64 off, u64 *data) | 985 | qlcnic_pci_camqm_read_2M(struct qlcnic_adapter *adapter, u64 off, u64 *data) |
918 | { | 986 | { |
919 | void __iomem *addr = adapter->ahw.pci_base0 + | 987 | void __iomem *addr = adapter->ahw->pci_base0 + |
920 | QLCNIC_PCI_CAMQM_2M_BASE + (off - QLCNIC_PCI_CAMQM); | 988 | QLCNIC_PCI_CAMQM_2M_BASE + (off - QLCNIC_PCI_CAMQM); |
921 | 989 | ||
922 | mutex_lock(&adapter->ahw.mem_lock); | 990 | mutex_lock(&adapter->ahw->mem_lock); |
923 | *data = readq(addr); | 991 | *data = readq(addr); |
924 | mutex_unlock(&adapter->ahw.mem_lock); | 992 | mutex_unlock(&adapter->ahw->mem_lock); |
925 | } | 993 | } |
926 | 994 | ||
927 | void | 995 | void |
928 | qlcnic_pci_camqm_write_2M(struct qlcnic_adapter *adapter, u64 off, u64 data) | 996 | qlcnic_pci_camqm_write_2M(struct qlcnic_adapter *adapter, u64 off, u64 data) |
929 | { | 997 | { |
930 | void __iomem *addr = adapter->ahw.pci_base0 + | 998 | void __iomem *addr = adapter->ahw->pci_base0 + |
931 | QLCNIC_PCI_CAMQM_2M_BASE + (off - QLCNIC_PCI_CAMQM); | 999 | QLCNIC_PCI_CAMQM_2M_BASE + (off - QLCNIC_PCI_CAMQM); |
932 | 1000 | ||
933 | mutex_lock(&adapter->ahw.mem_lock); | 1001 | mutex_lock(&adapter->ahw->mem_lock); |
934 | writeq(data, addr); | 1002 | writeq(data, addr); |
935 | mutex_unlock(&adapter->ahw.mem_lock); | 1003 | mutex_unlock(&adapter->ahw->mem_lock); |
936 | } | 1004 | } |
937 | 1005 | ||
938 | #define MAX_CTL_CHECK 1000 | 1006 | #define MAX_CTL_CHECK 1000 |
@@ -971,7 +1039,7 @@ qlcnic_pci_mem_write_2M(struct qlcnic_adapter *adapter, | |||
971 | correct: | 1039 | correct: |
972 | off8 = off & ~0xf; | 1040 | off8 = off & ~0xf; |
973 | 1041 | ||
974 | mutex_lock(&adapter->ahw.mem_lock); | 1042 | mutex_lock(&adapter->ahw->mem_lock); |
975 | 1043 | ||
976 | writel(off8, (mem_crb + MIU_TEST_AGT_ADDR_LO)); | 1044 | writel(off8, (mem_crb + MIU_TEST_AGT_ADDR_LO)); |
977 | writel(0, (mem_crb + MIU_TEST_AGT_ADDR_HI)); | 1045 | writel(0, (mem_crb + MIU_TEST_AGT_ADDR_HI)); |
@@ -1023,7 +1091,7 @@ correct: | |||
1023 | ret = 0; | 1091 | ret = 0; |
1024 | 1092 | ||
1025 | done: | 1093 | done: |
1026 | mutex_unlock(&adapter->ahw.mem_lock); | 1094 | mutex_unlock(&adapter->ahw->mem_lock); |
1027 | 1095 | ||
1028 | return ret; | 1096 | return ret; |
1029 | } | 1097 | } |
@@ -1065,7 +1133,7 @@ qlcnic_pci_mem_read_2M(struct qlcnic_adapter *adapter, | |||
1065 | correct: | 1133 | correct: |
1066 | off8 = off & ~0xf; | 1134 | off8 = off & ~0xf; |
1067 | 1135 | ||
1068 | mutex_lock(&adapter->ahw.mem_lock); | 1136 | mutex_lock(&adapter->ahw->mem_lock); |
1069 | 1137 | ||
1070 | writel(off8, (mem_crb + MIU_TEST_AGT_ADDR_LO)); | 1138 | writel(off8, (mem_crb + MIU_TEST_AGT_ADDR_LO)); |
1071 | writel(0, (mem_crb + MIU_TEST_AGT_ADDR_HI)); | 1139 | writel(0, (mem_crb + MIU_TEST_AGT_ADDR_HI)); |
@@ -1095,7 +1163,7 @@ correct: | |||
1095 | ret = 0; | 1163 | ret = 0; |
1096 | } | 1164 | } |
1097 | 1165 | ||
1098 | mutex_unlock(&adapter->ahw.mem_lock); | 1166 | mutex_unlock(&adapter->ahw->mem_lock); |
1099 | 1167 | ||
1100 | return ret; | 1168 | return ret; |
1101 | } | 1169 | } |
@@ -1119,39 +1187,39 @@ int qlcnic_get_board_info(struct qlcnic_adapter *adapter) | |||
1119 | if (qlcnic_rom_fast_read(adapter, offset, &board_type)) | 1187 | if (qlcnic_rom_fast_read(adapter, offset, &board_type)) |
1120 | return -EIO; | 1188 | return -EIO; |
1121 | 1189 | ||
1122 | adapter->ahw.board_type = board_type; | 1190 | adapter->ahw->board_type = board_type; |
1123 | 1191 | ||
1124 | if (board_type == QLCNIC_BRDTYPE_P3_4_GB_MM) { | 1192 | if (board_type == QLCNIC_BRDTYPE_P3P_4_GB_MM) { |
1125 | u32 gpio = QLCRD32(adapter, QLCNIC_ROMUSB_GLB_PAD_GPIO_I); | 1193 | u32 gpio = QLCRD32(adapter, QLCNIC_ROMUSB_GLB_PAD_GPIO_I); |
1126 | if ((gpio & 0x8000) == 0) | 1194 | if ((gpio & 0x8000) == 0) |
1127 | board_type = QLCNIC_BRDTYPE_P3_10G_TP; | 1195 | board_type = QLCNIC_BRDTYPE_P3P_10G_TP; |
1128 | } | 1196 | } |
1129 | 1197 | ||
1130 | switch (board_type) { | 1198 | switch (board_type) { |
1131 | case QLCNIC_BRDTYPE_P3_HMEZ: | 1199 | case QLCNIC_BRDTYPE_P3P_HMEZ: |
1132 | case QLCNIC_BRDTYPE_P3_XG_LOM: | 1200 | case QLCNIC_BRDTYPE_P3P_XG_LOM: |
1133 | case QLCNIC_BRDTYPE_P3_10G_CX4: | 1201 | case QLCNIC_BRDTYPE_P3P_10G_CX4: |
1134 | case QLCNIC_BRDTYPE_P3_10G_CX4_LP: | 1202 | case QLCNIC_BRDTYPE_P3P_10G_CX4_LP: |
1135 | case QLCNIC_BRDTYPE_P3_IMEZ: | 1203 | case QLCNIC_BRDTYPE_P3P_IMEZ: |
1136 | case QLCNIC_BRDTYPE_P3_10G_SFP_PLUS: | 1204 | case QLCNIC_BRDTYPE_P3P_10G_SFP_PLUS: |
1137 | case QLCNIC_BRDTYPE_P3_10G_SFP_CT: | 1205 | case QLCNIC_BRDTYPE_P3P_10G_SFP_CT: |
1138 | case QLCNIC_BRDTYPE_P3_10G_SFP_QT: | 1206 | case QLCNIC_BRDTYPE_P3P_10G_SFP_QT: |
1139 | case QLCNIC_BRDTYPE_P3_10G_XFP: | 1207 | case QLCNIC_BRDTYPE_P3P_10G_XFP: |
1140 | case QLCNIC_BRDTYPE_P3_10000_BASE_T: | 1208 | case QLCNIC_BRDTYPE_P3P_10000_BASE_T: |
1141 | adapter->ahw.port_type = QLCNIC_XGBE; | 1209 | adapter->ahw->port_type = QLCNIC_XGBE; |
1142 | break; | 1210 | break; |
1143 | case QLCNIC_BRDTYPE_P3_REF_QG: | 1211 | case QLCNIC_BRDTYPE_P3P_REF_QG: |
1144 | case QLCNIC_BRDTYPE_P3_4_GB: | 1212 | case QLCNIC_BRDTYPE_P3P_4_GB: |
1145 | case QLCNIC_BRDTYPE_P3_4_GB_MM: | 1213 | case QLCNIC_BRDTYPE_P3P_4_GB_MM: |
1146 | adapter->ahw.port_type = QLCNIC_GBE; | 1214 | adapter->ahw->port_type = QLCNIC_GBE; |
1147 | break; | 1215 | break; |
1148 | case QLCNIC_BRDTYPE_P3_10G_TP: | 1216 | case QLCNIC_BRDTYPE_P3P_10G_TP: |
1149 | adapter->ahw.port_type = (adapter->portnum < 2) ? | 1217 | adapter->ahw->port_type = (adapter->portnum < 2) ? |
1150 | QLCNIC_XGBE : QLCNIC_GBE; | 1218 | QLCNIC_XGBE : QLCNIC_GBE; |
1151 | break; | 1219 | break; |
1152 | default: | 1220 | default: |
1153 | dev_err(&pdev->dev, "unknown board type %x\n", board_type); | 1221 | dev_err(&pdev->dev, "unknown board type %x\n", board_type); |
1154 | adapter->ahw.port_type = QLCNIC_XGBE; | 1222 | adapter->ahw->port_type = QLCNIC_XGBE; |
1155 | break; | 1223 | break; |
1156 | } | 1224 | } |
1157 | 1225 | ||
@@ -1195,54 +1263,461 @@ int qlcnic_config_led(struct qlcnic_adapter *adapter, u32 state, u32 rate) | |||
1195 | return rv; | 1263 | return rv; |
1196 | } | 1264 | } |
1197 | 1265 | ||
1198 | static int qlcnic_set_fw_loopback(struct qlcnic_adapter *adapter, u32 flag) | 1266 | /* FW dump related functions */ |
1267 | static u32 | ||
1268 | qlcnic_dump_crb(struct qlcnic_adapter *adapter, struct qlcnic_dump_entry *entry, | ||
1269 | u32 *buffer) | ||
1199 | { | 1270 | { |
1200 | struct qlcnic_nic_req req; | 1271 | int i; |
1201 | int rv; | 1272 | u32 addr, data; |
1202 | u64 word; | 1273 | struct __crb *crb = &entry->region.crb; |
1274 | void __iomem *base = adapter->ahw->pci_base0; | ||
1275 | |||
1276 | addr = crb->addr; | ||
1277 | |||
1278 | for (i = 0; i < crb->no_ops; i++) { | ||
1279 | QLCNIC_RD_DUMP_REG(addr, base, &data); | ||
1280 | *buffer++ = cpu_to_le32(addr); | ||
1281 | *buffer++ = cpu_to_le32(data); | ||
1282 | addr += crb->stride; | ||
1283 | } | ||
1284 | return crb->no_ops * 2 * sizeof(u32); | ||
1285 | } | ||
1203 | 1286 | ||
1204 | memset(&req, 0, sizeof(struct qlcnic_nic_req)); | 1287 | static u32 |
1205 | req.qhdr = cpu_to_le64(QLCNIC_HOST_REQUEST << 23); | 1288 | qlcnic_dump_ctrl(struct qlcnic_adapter *adapter, |
1289 | struct qlcnic_dump_entry *entry, u32 *buffer) | ||
1290 | { | ||
1291 | int i, k, timeout = 0; | ||
1292 | void __iomem *base = adapter->ahw->pci_base0; | ||
1293 | u32 addr, data; | ||
1294 | u8 opcode, no_ops; | ||
1295 | struct __ctrl *ctr = &entry->region.ctrl; | ||
1296 | struct qlcnic_dump_template_hdr *t_hdr = adapter->ahw->fw_dump.tmpl_hdr; | ||
1297 | |||
1298 | addr = ctr->addr; | ||
1299 | no_ops = ctr->no_ops; | ||
1300 | |||
1301 | for (i = 0; i < no_ops; i++) { | ||
1302 | k = 0; | ||
1303 | opcode = 0; | ||
1304 | for (k = 0; k < 8; k++) { | ||
1305 | if (!(ctr->opcode & (1 << k))) | ||
1306 | continue; | ||
1307 | switch (1 << k) { | ||
1308 | case QLCNIC_DUMP_WCRB: | ||
1309 | QLCNIC_WR_DUMP_REG(addr, base, ctr->val1); | ||
1310 | break; | ||
1311 | case QLCNIC_DUMP_RWCRB: | ||
1312 | QLCNIC_RD_DUMP_REG(addr, base, &data); | ||
1313 | QLCNIC_WR_DUMP_REG(addr, base, data); | ||
1314 | break; | ||
1315 | case QLCNIC_DUMP_ANDCRB: | ||
1316 | QLCNIC_RD_DUMP_REG(addr, base, &data); | ||
1317 | QLCNIC_WR_DUMP_REG(addr, base, | ||
1318 | (data & ctr->val2)); | ||
1319 | break; | ||
1320 | case QLCNIC_DUMP_ORCRB: | ||
1321 | QLCNIC_RD_DUMP_REG(addr, base, &data); | ||
1322 | QLCNIC_WR_DUMP_REG(addr, base, | ||
1323 | (data | ctr->val3)); | ||
1324 | break; | ||
1325 | case QLCNIC_DUMP_POLLCRB: | ||
1326 | while (timeout <= ctr->timeout) { | ||
1327 | QLCNIC_RD_DUMP_REG(addr, base, &data); | ||
1328 | if ((data & ctr->val2) == ctr->val1) | ||
1329 | break; | ||
1330 | msleep(1); | ||
1331 | timeout++; | ||
1332 | } | ||
1333 | if (timeout > ctr->timeout) { | ||
1334 | dev_info(&adapter->pdev->dev, | ||
1335 | "Timed out, aborting poll CRB\n"); | ||
1336 | return -EINVAL; | ||
1337 | } | ||
1338 | break; | ||
1339 | case QLCNIC_DUMP_RD_SAVE: | ||
1340 | if (ctr->index_a) | ||
1341 | addr = t_hdr->saved_state[ctr->index_a]; | ||
1342 | QLCNIC_RD_DUMP_REG(addr, base, &data); | ||
1343 | t_hdr->saved_state[ctr->index_v] = data; | ||
1344 | break; | ||
1345 | case QLCNIC_DUMP_WRT_SAVED: | ||
1346 | if (ctr->index_v) | ||
1347 | data = t_hdr->saved_state[ctr->index_v]; | ||
1348 | else | ||
1349 | data = ctr->val1; | ||
1350 | if (ctr->index_a) | ||
1351 | addr = t_hdr->saved_state[ctr->index_a]; | ||
1352 | QLCNIC_WR_DUMP_REG(addr, base, data); | ||
1353 | break; | ||
1354 | case QLCNIC_DUMP_MOD_SAVE_ST: | ||
1355 | data = t_hdr->saved_state[ctr->index_v]; | ||
1356 | data <<= ctr->shl_val; | ||
1357 | data >>= ctr->shr_val; | ||
1358 | if (ctr->val2) | ||
1359 | data &= ctr->val2; | ||
1360 | data |= ctr->val3; | ||
1361 | data += ctr->val1; | ||
1362 | t_hdr->saved_state[ctr->index_v] = data; | ||
1363 | break; | ||
1364 | default: | ||
1365 | dev_info(&adapter->pdev->dev, | ||
1366 | "Unknown opcode\n"); | ||
1367 | break; | ||
1368 | } | ||
1369 | } | ||
1370 | addr += ctr->stride; | ||
1371 | } | ||
1372 | return 0; | ||
1373 | } | ||
1206 | 1374 | ||
1207 | word = QLCNIC_H2C_OPCODE_CONFIG_LOOPBACK | | 1375 | static u32 |
1208 | ((u64)adapter->portnum << 16); | 1376 | qlcnic_dump_mux(struct qlcnic_adapter *adapter, struct qlcnic_dump_entry *entry, |
1209 | req.req_hdr = cpu_to_le64(word); | 1377 | u32 *buffer) |
1210 | req.words[0] = cpu_to_le64(flag); | 1378 | { |
1379 | int loop; | ||
1380 | u32 val, data = 0; | ||
1381 | struct __mux *mux = &entry->region.mux; | ||
1382 | void __iomem *base = adapter->ahw->pci_base0; | ||
1383 | |||
1384 | val = mux->val; | ||
1385 | for (loop = 0; loop < mux->no_ops; loop++) { | ||
1386 | QLCNIC_WR_DUMP_REG(mux->addr, base, val); | ||
1387 | QLCNIC_RD_DUMP_REG(mux->read_addr, base, &data); | ||
1388 | *buffer++ = cpu_to_le32(val); | ||
1389 | *buffer++ = cpu_to_le32(data); | ||
1390 | val += mux->val_stride; | ||
1391 | } | ||
1392 | return 2 * mux->no_ops * sizeof(u32); | ||
1393 | } | ||
1211 | 1394 | ||
1212 | rv = qlcnic_send_cmd_descs(adapter, (struct cmd_desc_type0 *)&req, 1); | 1395 | static u32 |
1213 | if (rv) | 1396 | qlcnic_dump_que(struct qlcnic_adapter *adapter, struct qlcnic_dump_entry *entry, |
1214 | dev_err(&adapter->pdev->dev, | 1397 | u32 *buffer) |
1215 | "%sting loopback mode failed.\n", | 1398 | { |
1216 | flag ? "Set" : "Reset"); | 1399 | int i, loop; |
1217 | return rv; | 1400 | u32 cnt, addr, data, que_id = 0; |
1401 | void __iomem *base = adapter->ahw->pci_base0; | ||
1402 | struct __queue *que = &entry->region.que; | ||
1403 | |||
1404 | addr = que->read_addr; | ||
1405 | cnt = que->read_addr_cnt; | ||
1406 | |||
1407 | for (loop = 0; loop < que->no_ops; loop++) { | ||
1408 | QLCNIC_WR_DUMP_REG(que->sel_addr, base, que_id); | ||
1409 | addr = que->read_addr; | ||
1410 | for (i = 0; i < cnt; i++) { | ||
1411 | QLCNIC_RD_DUMP_REG(addr, base, &data); | ||
1412 | *buffer++ = cpu_to_le32(data); | ||
1413 | addr += que->read_addr_stride; | ||
1414 | } | ||
1415 | que_id += que->stride; | ||
1416 | } | ||
1417 | return que->no_ops * cnt * sizeof(u32); | ||
1218 | } | 1418 | } |
1219 | 1419 | ||
1220 | int qlcnic_set_ilb_mode(struct qlcnic_adapter *adapter) | 1420 | static u32 |
1421 | qlcnic_dump_ocm(struct qlcnic_adapter *adapter, struct qlcnic_dump_entry *entry, | ||
1422 | u32 *buffer) | ||
1221 | { | 1423 | { |
1222 | if (qlcnic_set_fw_loopback(adapter, 1)) | 1424 | int i; |
1223 | return -EIO; | 1425 | u32 data; |
1426 | void __iomem *addr; | ||
1427 | struct __ocm *ocm = &entry->region.ocm; | ||
1224 | 1428 | ||
1225 | if (qlcnic_nic_set_promisc(adapter, | 1429 | addr = adapter->ahw->pci_base0 + ocm->read_addr; |
1226 | VPORT_MISS_MODE_ACCEPT_ALL)) { | 1430 | for (i = 0; i < ocm->no_ops; i++) { |
1227 | qlcnic_set_fw_loopback(adapter, 0); | 1431 | data = readl(addr); |
1228 | return -EIO; | 1432 | *buffer++ = cpu_to_le32(data); |
1433 | addr += ocm->read_addr_stride; | ||
1229 | } | 1434 | } |
1435 | return ocm->no_ops * sizeof(u32); | ||
1436 | } | ||
1230 | 1437 | ||
1231 | msleep(1000); | 1438 | static u32 |
1232 | return 0; | 1439 | qlcnic_read_rom(struct qlcnic_adapter *adapter, struct qlcnic_dump_entry *entry, |
1440 | u32 *buffer) | ||
1441 | { | ||
1442 | int i, count = 0; | ||
1443 | u32 fl_addr, size, val, lck_val, addr; | ||
1444 | struct __mem *rom = &entry->region.mem; | ||
1445 | void __iomem *base = adapter->ahw->pci_base0; | ||
1446 | |||
1447 | fl_addr = rom->addr; | ||
1448 | size = rom->size/4; | ||
1449 | lock_try: | ||
1450 | lck_val = readl(base + QLCNIC_FLASH_SEM2_LK); | ||
1451 | if (!lck_val && count < MAX_CTL_CHECK) { | ||
1452 | msleep(10); | ||
1453 | count++; | ||
1454 | goto lock_try; | ||
1455 | } | ||
1456 | writel(adapter->ahw->pci_func, (base + QLCNIC_FLASH_LOCK_ID)); | ||
1457 | for (i = 0; i < size; i++) { | ||
1458 | addr = fl_addr & 0xFFFF0000; | ||
1459 | QLCNIC_WR_DUMP_REG(FLASH_ROM_WINDOW, base, addr); | ||
1460 | addr = LSW(fl_addr) + FLASH_ROM_DATA; | ||
1461 | QLCNIC_RD_DUMP_REG(addr, base, &val); | ||
1462 | fl_addr += 4; | ||
1463 | *buffer++ = cpu_to_le32(val); | ||
1464 | } | ||
1465 | readl(base + QLCNIC_FLASH_SEM2_ULK); | ||
1466 | return rom->size; | ||
1233 | } | 1467 | } |
1234 | 1468 | ||
1235 | void qlcnic_clear_ilb_mode(struct qlcnic_adapter *adapter) | 1469 | static u32 |
1470 | qlcnic_dump_l1_cache(struct qlcnic_adapter *adapter, | ||
1471 | struct qlcnic_dump_entry *entry, u32 *buffer) | ||
1236 | { | 1472 | { |
1237 | int mode = VPORT_MISS_MODE_DROP; | 1473 | int i; |
1238 | struct net_device *netdev = adapter->netdev; | 1474 | u32 cnt, val, data, addr; |
1475 | void __iomem *base = adapter->ahw->pci_base0; | ||
1476 | struct __cache *l1 = &entry->region.cache; | ||
1477 | |||
1478 | val = l1->init_tag_val; | ||
1479 | |||
1480 | for (i = 0; i < l1->no_ops; i++) { | ||
1481 | QLCNIC_WR_DUMP_REG(l1->addr, base, val); | ||
1482 | QLCNIC_WR_DUMP_REG(l1->ctrl_addr, base, LSW(l1->ctrl_val)); | ||
1483 | addr = l1->read_addr; | ||
1484 | cnt = l1->read_addr_num; | ||
1485 | while (cnt) { | ||
1486 | QLCNIC_RD_DUMP_REG(addr, base, &data); | ||
1487 | *buffer++ = cpu_to_le32(data); | ||
1488 | addr += l1->read_addr_stride; | ||
1489 | cnt--; | ||
1490 | } | ||
1491 | val += l1->stride; | ||
1492 | } | ||
1493 | return l1->no_ops * l1->read_addr_num * sizeof(u32); | ||
1494 | } | ||
1239 | 1495 | ||
1240 | qlcnic_set_fw_loopback(adapter, 0); | 1496 | static u32 |
1497 | qlcnic_dump_l2_cache(struct qlcnic_adapter *adapter, | ||
1498 | struct qlcnic_dump_entry *entry, u32 *buffer) | ||
1499 | { | ||
1500 | int i; | ||
1501 | u32 cnt, val, data, addr; | ||
1502 | u8 poll_mask, poll_to, time_out = 0; | ||
1503 | void __iomem *base = adapter->ahw->pci_base0; | ||
1504 | struct __cache *l2 = &entry->region.cache; | ||
1505 | |||
1506 | val = l2->init_tag_val; | ||
1507 | poll_mask = LSB(MSW(l2->ctrl_val)); | ||
1508 | poll_to = MSB(MSW(l2->ctrl_val)); | ||
1509 | |||
1510 | for (i = 0; i < l2->no_ops; i++) { | ||
1511 | QLCNIC_WR_DUMP_REG(l2->addr, base, val); | ||
1512 | do { | ||
1513 | QLCNIC_WR_DUMP_REG(l2->ctrl_addr, base, | ||
1514 | LSW(l2->ctrl_val)); | ||
1515 | QLCNIC_RD_DUMP_REG(l2->ctrl_addr, base, &data); | ||
1516 | if (!(data & poll_mask)) | ||
1517 | break; | ||
1518 | msleep(1); | ||
1519 | time_out++; | ||
1520 | } while (time_out <= poll_to); | ||
1521 | if (time_out > poll_to) | ||
1522 | return -EINVAL; | ||
1523 | |||
1524 | addr = l2->read_addr; | ||
1525 | cnt = l2->read_addr_num; | ||
1526 | while (cnt) { | ||
1527 | QLCNIC_RD_DUMP_REG(addr, base, &data); | ||
1528 | *buffer++ = cpu_to_le32(data); | ||
1529 | addr += l2->read_addr_stride; | ||
1530 | cnt--; | ||
1531 | } | ||
1532 | val += l2->stride; | ||
1533 | } | ||
1534 | return l2->no_ops * l2->read_addr_num * sizeof(u32); | ||
1535 | } | ||
1241 | 1536 | ||
1242 | if (netdev->flags & IFF_PROMISC) | 1537 | static u32 |
1243 | mode = VPORT_MISS_MODE_ACCEPT_ALL; | 1538 | qlcnic_read_memory(struct qlcnic_adapter *adapter, |
1244 | else if (netdev->flags & IFF_ALLMULTI) | 1539 | struct qlcnic_dump_entry *entry, u32 *buffer) |
1245 | mode = VPORT_MISS_MODE_ACCEPT_MULTI; | 1540 | { |
1541 | u32 addr, data, test, ret = 0; | ||
1542 | int i, reg_read; | ||
1543 | struct __mem *mem = &entry->region.mem; | ||
1544 | void __iomem *base = adapter->ahw->pci_base0; | ||
1545 | |||
1546 | reg_read = mem->size; | ||
1547 | addr = mem->addr; | ||
1548 | /* check for data size of multiple of 16 and 16 byte alignment */ | ||
1549 | if ((addr & 0xf) || (reg_read%16)) { | ||
1550 | dev_info(&adapter->pdev->dev, | ||
1551 | "Unaligned memory addr:0x%x size:0x%x\n", | ||
1552 | addr, reg_read); | ||
1553 | return -EINVAL; | ||
1554 | } | ||
1246 | 1555 | ||
1247 | qlcnic_nic_set_promisc(adapter, mode); | 1556 | mutex_lock(&adapter->ahw->mem_lock); |
1557 | |||
1558 | while (reg_read != 0) { | ||
1559 | QLCNIC_WR_DUMP_REG(MIU_TEST_ADDR_LO, base, addr); | ||
1560 | QLCNIC_WR_DUMP_REG(MIU_TEST_ADDR_HI, base, 0); | ||
1561 | QLCNIC_WR_DUMP_REG(MIU_TEST_CTR, base, | ||
1562 | TA_CTL_ENABLE | TA_CTL_START); | ||
1563 | |||
1564 | for (i = 0; i < MAX_CTL_CHECK; i++) { | ||
1565 | QLCNIC_RD_DUMP_REG(MIU_TEST_CTR, base, &test); | ||
1566 | if (!(test & TA_CTL_BUSY)) | ||
1567 | break; | ||
1568 | } | ||
1569 | if (i == MAX_CTL_CHECK) { | ||
1570 | if (printk_ratelimit()) { | ||
1571 | dev_err(&adapter->pdev->dev, | ||
1572 | "failed to read through agent\n"); | ||
1573 | ret = -EINVAL; | ||
1574 | goto out; | ||
1575 | } | ||
1576 | } | ||
1577 | for (i = 0; i < 4; i++) { | ||
1578 | QLCNIC_RD_DUMP_REG(MIU_TEST_READ_DATA[i], base, &data); | ||
1579 | *buffer++ = cpu_to_le32(data); | ||
1580 | } | ||
1581 | addr += 16; | ||
1582 | reg_read -= 16; | ||
1583 | ret += 16; | ||
1584 | } | ||
1585 | out: | ||
1586 | mutex_unlock(&adapter->ahw->mem_lock); | ||
1587 | return mem->size; | ||
1588 | } | ||
1589 | |||
1590 | static u32 | ||
1591 | qlcnic_dump_nop(struct qlcnic_adapter *adapter, | ||
1592 | struct qlcnic_dump_entry *entry, u32 *buffer) | ||
1593 | { | ||
1594 | entry->hdr.flags |= QLCNIC_DUMP_SKIP; | ||
1595 | return 0; | ||
1596 | } | ||
1597 | |||
1598 | struct qlcnic_dump_operations fw_dump_ops[] = { | ||
1599 | { QLCNIC_DUMP_NOP, qlcnic_dump_nop }, | ||
1600 | { QLCNIC_DUMP_READ_CRB, qlcnic_dump_crb }, | ||
1601 | { QLCNIC_DUMP_READ_MUX, qlcnic_dump_mux }, | ||
1602 | { QLCNIC_DUMP_QUEUE, qlcnic_dump_que }, | ||
1603 | { QLCNIC_DUMP_BRD_CONFIG, qlcnic_read_rom }, | ||
1604 | { QLCNIC_DUMP_READ_OCM, qlcnic_dump_ocm }, | ||
1605 | { QLCNIC_DUMP_PEG_REG, qlcnic_dump_ctrl }, | ||
1606 | { QLCNIC_DUMP_L1_DTAG, qlcnic_dump_l1_cache }, | ||
1607 | { QLCNIC_DUMP_L1_ITAG, qlcnic_dump_l1_cache }, | ||
1608 | { QLCNIC_DUMP_L1_DATA, qlcnic_dump_l1_cache }, | ||
1609 | { QLCNIC_DUMP_L1_INST, qlcnic_dump_l1_cache }, | ||
1610 | { QLCNIC_DUMP_L2_DTAG, qlcnic_dump_l2_cache }, | ||
1611 | { QLCNIC_DUMP_L2_ITAG, qlcnic_dump_l2_cache }, | ||
1612 | { QLCNIC_DUMP_L2_DATA, qlcnic_dump_l2_cache }, | ||
1613 | { QLCNIC_DUMP_L2_INST, qlcnic_dump_l2_cache }, | ||
1614 | { QLCNIC_DUMP_READ_ROM, qlcnic_read_rom }, | ||
1615 | { QLCNIC_DUMP_READ_MEM, qlcnic_read_memory }, | ||
1616 | { QLCNIC_DUMP_READ_CTRL, qlcnic_dump_ctrl }, | ||
1617 | { QLCNIC_DUMP_TLHDR, qlcnic_dump_nop }, | ||
1618 | { QLCNIC_DUMP_RDEND, qlcnic_dump_nop }, | ||
1619 | }; | ||
1620 | |||
1621 | /* Walk the template and collect dump for each entry in the dump template */ | ||
1622 | static int | ||
1623 | qlcnic_valid_dump_entry(struct device *dev, struct qlcnic_dump_entry *entry, | ||
1624 | u32 size) | ||
1625 | { | ||
1626 | int ret = 1; | ||
1627 | if (size != entry->hdr.cap_size) { | ||
1628 | dev_info(dev, | ||
1629 | "Invalidate dump, Type:%d\tMask:%d\tSize:%dCap_size:%d\n", | ||
1630 | entry->hdr.type, entry->hdr.mask, size, entry->hdr.cap_size); | ||
1631 | dev_info(dev, "Aborting further dump capture\n"); | ||
1632 | ret = 0; | ||
1633 | } | ||
1634 | return ret; | ||
1635 | } | ||
1636 | |||
1637 | int qlcnic_dump_fw(struct qlcnic_adapter *adapter) | ||
1638 | { | ||
1639 | u32 *buffer; | ||
1640 | char mesg[64]; | ||
1641 | char *msg[] = {mesg, NULL}; | ||
1642 | int i, k, ops_cnt, ops_index, dump_size = 0; | ||
1643 | u32 entry_offset, dump, no_entries, buf_offset = 0; | ||
1644 | struct qlcnic_dump_entry *entry; | ||
1645 | struct qlcnic_fw_dump *fw_dump = &adapter->ahw->fw_dump; | ||
1646 | struct qlcnic_dump_template_hdr *tmpl_hdr = fw_dump->tmpl_hdr; | ||
1647 | |||
1648 | if (fw_dump->clr) { | ||
1649 | dev_info(&adapter->pdev->dev, | ||
1650 | "Previous dump not cleared, not capturing dump\n"); | ||
1651 | return -EIO; | ||
1652 | } | ||
1653 | /* Calculate the size for dump data area only */ | ||
1654 | for (i = 2, k = 1; (i & QLCNIC_DUMP_MASK_MAX); i <<= 1, k++) | ||
1655 | if (i & tmpl_hdr->drv_cap_mask) | ||
1656 | dump_size += tmpl_hdr->cap_sizes[k]; | ||
1657 | if (!dump_size) | ||
1658 | return -EIO; | ||
1659 | |||
1660 | fw_dump->data = vzalloc(dump_size); | ||
1661 | if (!fw_dump->data) { | ||
1662 | dev_info(&adapter->pdev->dev, | ||
1663 | "Unable to allocate (%d KB) for fw dump\n", | ||
1664 | dump_size/1024); | ||
1665 | return -ENOMEM; | ||
1666 | } | ||
1667 | buffer = fw_dump->data; | ||
1668 | fw_dump->size = dump_size; | ||
1669 | no_entries = tmpl_hdr->num_entries; | ||
1670 | ops_cnt = ARRAY_SIZE(fw_dump_ops); | ||
1671 | entry_offset = tmpl_hdr->offset; | ||
1672 | tmpl_hdr->sys_info[0] = QLCNIC_DRIVER_VERSION; | ||
1673 | tmpl_hdr->sys_info[1] = adapter->fw_version; | ||
1674 | |||
1675 | for (i = 0; i < no_entries; i++) { | ||
1676 | entry = (struct qlcnic_dump_entry *) ((void *) tmpl_hdr + | ||
1677 | entry_offset); | ||
1678 | if (!(entry->hdr.mask & tmpl_hdr->drv_cap_mask)) { | ||
1679 | entry->hdr.flags |= QLCNIC_DUMP_SKIP; | ||
1680 | entry_offset += entry->hdr.offset; | ||
1681 | continue; | ||
1682 | } | ||
1683 | /* Find the handler for this entry */ | ||
1684 | ops_index = 0; | ||
1685 | while (ops_index < ops_cnt) { | ||
1686 | if (entry->hdr.type == fw_dump_ops[ops_index].opcode) | ||
1687 | break; | ||
1688 | ops_index++; | ||
1689 | } | ||
1690 | if (ops_index == ops_cnt) { | ||
1691 | dev_info(&adapter->pdev->dev, | ||
1692 | "Invalid entry type %d, exiting dump\n", | ||
1693 | entry->hdr.type); | ||
1694 | goto error; | ||
1695 | } | ||
1696 | /* Collect dump for this entry */ | ||
1697 | dump = fw_dump_ops[ops_index].handler(adapter, entry, buffer); | ||
1698 | if (dump && !qlcnic_valid_dump_entry(&adapter->pdev->dev, entry, | ||
1699 | dump)) | ||
1700 | entry->hdr.flags |= QLCNIC_DUMP_SKIP; | ||
1701 | buf_offset += entry->hdr.cap_size; | ||
1702 | entry_offset += entry->hdr.offset; | ||
1703 | buffer = fw_dump->data + buf_offset; | ||
1704 | } | ||
1705 | if (dump_size != buf_offset) { | ||
1706 | dev_info(&adapter->pdev->dev, | ||
1707 | "Captured(%d) and expected size(%d) do not match\n", | ||
1708 | buf_offset, dump_size); | ||
1709 | goto error; | ||
1710 | } else { | ||
1711 | fw_dump->clr = 1; | ||
1712 | snprintf(mesg, sizeof(mesg), "FW dump for device: %d\n", | ||
1713 | adapter->pdev->devfn); | ||
1714 | dev_info(&adapter->pdev->dev, "Dump data, %d bytes captured\n", | ||
1715 | fw_dump->size); | ||
1716 | /* Send a udev event to notify availability of FW dump */ | ||
1717 | kobject_uevent_env(&adapter->pdev->dev.kobj, KOBJ_CHANGE, msg); | ||
1718 | return 0; | ||
1719 | } | ||
1720 | error: | ||
1721 | vfree(fw_dump->data); | ||
1722 | return -EINVAL; | ||
1248 | } | 1723 | } |
diff --git a/drivers/net/qlcnic/qlcnic_init.c b/drivers/net/qlcnic/qlcnic_init.c index 2c7cf0b64811..5b8bbcf904d5 100644 --- a/drivers/net/qlcnic/qlcnic_init.c +++ b/drivers/net/qlcnic/qlcnic_init.c | |||
@@ -1,30 +1,14 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2009 - QLogic Corporation. | 2 | * QLogic qlcnic NIC Driver |
3 | * All rights reserved. | 3 | * Copyright (c) 2009-2010 QLogic Corporation |
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License | ||
7 | * as published by the Free Software Foundation; either version 2 | ||
8 | * of the License, or (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, but | ||
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, | ||
18 | * MA 02111-1307, USA. | ||
19 | * | ||
20 | * The full GNU General Public License is included in this distribution | ||
21 | * in the file called "COPYING". | ||
22 | * | 4 | * |
5 | * See LICENSE.qlcnic for copyright and licensing details. | ||
23 | */ | 6 | */ |
24 | 7 | ||
25 | #include <linux/netdevice.h> | 8 | #include <linux/netdevice.h> |
26 | #include <linux/delay.h> | 9 | #include <linux/delay.h> |
27 | #include <linux/slab.h> | 10 | #include <linux/slab.h> |
11 | #include <linux/if_vlan.h> | ||
28 | #include "qlcnic.h" | 12 | #include "qlcnic.h" |
29 | 13 | ||
30 | struct crb_addr_pair { | 14 | struct crb_addr_pair { |
@@ -45,6 +29,9 @@ static void | |||
45 | qlcnic_post_rx_buffers_nodb(struct qlcnic_adapter *adapter, | 29 | qlcnic_post_rx_buffers_nodb(struct qlcnic_adapter *adapter, |
46 | struct qlcnic_host_rds_ring *rds_ring); | 30 | struct qlcnic_host_rds_ring *rds_ring); |
47 | 31 | ||
32 | static int | ||
33 | qlcnic_check_fw_hearbeat(struct qlcnic_adapter *adapter); | ||
34 | |||
48 | static void crb_addr_transform_setup(void) | 35 | static void crb_addr_transform_setup(void) |
49 | { | 36 | { |
50 | crb_addr_transform(XDMA); | 37 | crb_addr_transform(XDMA); |
@@ -107,7 +94,7 @@ void qlcnic_release_rx_buffers(struct qlcnic_adapter *adapter) | |||
107 | struct qlcnic_rx_buffer *rx_buf; | 94 | struct qlcnic_rx_buffer *rx_buf; |
108 | int i, ring; | 95 | int i, ring; |
109 | 96 | ||
110 | recv_ctx = &adapter->recv_ctx; | 97 | recv_ctx = adapter->recv_ctx; |
111 | for (ring = 0; ring < adapter->max_rds_rings; ring++) { | 98 | for (ring = 0; ring < adapter->max_rds_rings; ring++) { |
112 | rds_ring = &recv_ctx->rds_rings[ring]; | 99 | rds_ring = &recv_ctx->rds_rings[ring]; |
113 | for (i = 0; i < rds_ring->num_desc; ++i) { | 100 | for (i = 0; i < rds_ring->num_desc; ++i) { |
@@ -132,12 +119,10 @@ void qlcnic_reset_rx_buffers_list(struct qlcnic_adapter *adapter) | |||
132 | struct qlcnic_rx_buffer *rx_buf; | 119 | struct qlcnic_rx_buffer *rx_buf; |
133 | int i, ring; | 120 | int i, ring; |
134 | 121 | ||
135 | recv_ctx = &adapter->recv_ctx; | 122 | recv_ctx = adapter->recv_ctx; |
136 | for (ring = 0; ring < adapter->max_rds_rings; ring++) { | 123 | for (ring = 0; ring < adapter->max_rds_rings; ring++) { |
137 | rds_ring = &recv_ctx->rds_rings[ring]; | 124 | rds_ring = &recv_ctx->rds_rings[ring]; |
138 | 125 | ||
139 | spin_lock(&rds_ring->lock); | ||
140 | |||
141 | INIT_LIST_HEAD(&rds_ring->free_list); | 126 | INIT_LIST_HEAD(&rds_ring->free_list); |
142 | 127 | ||
143 | rx_buf = rds_ring->rx_buf_arr; | 128 | rx_buf = rds_ring->rx_buf_arr; |
@@ -146,8 +131,6 @@ void qlcnic_reset_rx_buffers_list(struct qlcnic_adapter *adapter) | |||
146 | &rds_ring->free_list); | 131 | &rds_ring->free_list); |
147 | rx_buf++; | 132 | rx_buf++; |
148 | } | 133 | } |
149 | |||
150 | spin_unlock(&rds_ring->lock); | ||
151 | } | 134 | } |
152 | } | 135 | } |
153 | 136 | ||
@@ -190,7 +173,7 @@ void qlcnic_free_sw_resources(struct qlcnic_adapter *adapter) | |||
190 | struct qlcnic_host_tx_ring *tx_ring; | 173 | struct qlcnic_host_tx_ring *tx_ring; |
191 | int ring; | 174 | int ring; |
192 | 175 | ||
193 | recv_ctx = &adapter->recv_ctx; | 176 | recv_ctx = adapter->recv_ctx; |
194 | 177 | ||
195 | if (recv_ctx->rds_rings == NULL) | 178 | if (recv_ctx->rds_rings == NULL) |
196 | goto skip_rds; | 179 | goto skip_rds; |
@@ -236,15 +219,14 @@ int qlcnic_alloc_sw_resources(struct qlcnic_adapter *adapter) | |||
236 | tx_ring->num_desc = adapter->num_txd; | 219 | tx_ring->num_desc = adapter->num_txd; |
237 | tx_ring->txq = netdev_get_tx_queue(netdev, 0); | 220 | tx_ring->txq = netdev_get_tx_queue(netdev, 0); |
238 | 221 | ||
239 | cmd_buf_arr = vmalloc(TX_BUFF_RINGSIZE(tx_ring)); | 222 | cmd_buf_arr = vzalloc(TX_BUFF_RINGSIZE(tx_ring)); |
240 | if (cmd_buf_arr == NULL) { | 223 | if (cmd_buf_arr == NULL) { |
241 | dev_err(&netdev->dev, "failed to allocate cmd buffer ring\n"); | 224 | dev_err(&netdev->dev, "failed to allocate cmd buffer ring\n"); |
242 | goto err_out; | 225 | goto err_out; |
243 | } | 226 | } |
244 | memset(cmd_buf_arr, 0, TX_BUFF_RINGSIZE(tx_ring)); | ||
245 | tx_ring->cmd_buf_arr = cmd_buf_arr; | 227 | tx_ring->cmd_buf_arr = cmd_buf_arr; |
246 | 228 | ||
247 | recv_ctx = &adapter->recv_ctx; | 229 | recv_ctx = adapter->recv_ctx; |
248 | 230 | ||
249 | size = adapter->max_rds_rings * sizeof(struct qlcnic_host_rds_ring); | 231 | size = adapter->max_rds_rings * sizeof(struct qlcnic_host_rds_ring); |
250 | rds_ring = kzalloc(size, GFP_KERNEL); | 232 | rds_ring = kzalloc(size, GFP_KERNEL); |
@@ -259,14 +241,14 @@ int qlcnic_alloc_sw_resources(struct qlcnic_adapter *adapter) | |||
259 | switch (ring) { | 241 | switch (ring) { |
260 | case RCV_RING_NORMAL: | 242 | case RCV_RING_NORMAL: |
261 | rds_ring->num_desc = adapter->num_rxd; | 243 | rds_ring->num_desc = adapter->num_rxd; |
262 | rds_ring->dma_size = QLCNIC_P3_RX_BUF_MAX_LEN; | 244 | rds_ring->dma_size = QLCNIC_P3P_RX_BUF_MAX_LEN; |
263 | rds_ring->skb_size = rds_ring->dma_size + NET_IP_ALIGN; | 245 | rds_ring->skb_size = rds_ring->dma_size + NET_IP_ALIGN; |
264 | break; | 246 | break; |
265 | 247 | ||
266 | case RCV_RING_JUMBO: | 248 | case RCV_RING_JUMBO: |
267 | rds_ring->num_desc = adapter->num_jumbo_rxd; | 249 | rds_ring->num_desc = adapter->num_jumbo_rxd; |
268 | rds_ring->dma_size = | 250 | rds_ring->dma_size = |
269 | QLCNIC_P3_RX_JUMBO_BUF_MAX_LEN; | 251 | QLCNIC_P3P_RX_JUMBO_BUF_MAX_LEN; |
270 | 252 | ||
271 | if (adapter->capabilities & QLCNIC_FW_CAPABILITY_HW_LRO) | 253 | if (adapter->capabilities & QLCNIC_FW_CAPABILITY_HW_LRO) |
272 | rds_ring->dma_size += QLCNIC_LRO_BUFFER_EXTRA; | 254 | rds_ring->dma_size += QLCNIC_LRO_BUFFER_EXTRA; |
@@ -275,14 +257,12 @@ int qlcnic_alloc_sw_resources(struct qlcnic_adapter *adapter) | |||
275 | rds_ring->dma_size + NET_IP_ALIGN; | 257 | rds_ring->dma_size + NET_IP_ALIGN; |
276 | break; | 258 | break; |
277 | } | 259 | } |
278 | rds_ring->rx_buf_arr = (struct qlcnic_rx_buffer *) | 260 | rds_ring->rx_buf_arr = vzalloc(RCV_BUFF_RINGSIZE(rds_ring)); |
279 | vmalloc(RCV_BUFF_RINGSIZE(rds_ring)); | ||
280 | if (rds_ring->rx_buf_arr == NULL) { | 261 | if (rds_ring->rx_buf_arr == NULL) { |
281 | dev_err(&netdev->dev, "Failed to allocate " | 262 | dev_err(&netdev->dev, "Failed to allocate " |
282 | "rx buffer ring %d\n", ring); | 263 | "rx buffer ring %d\n", ring); |
283 | goto err_out; | 264 | goto err_out; |
284 | } | 265 | } |
285 | memset(rds_ring->rx_buf_arr, 0, RCV_BUFF_RINGSIZE(rds_ring)); | ||
286 | INIT_LIST_HEAD(&rds_ring->free_list); | 266 | INIT_LIST_HEAD(&rds_ring->free_list); |
287 | /* | 267 | /* |
288 | * Now go through all of them, set reference handles | 268 | * Now go through all of them, set reference handles |
@@ -365,7 +345,7 @@ static int qlcnic_wait_rom_done(struct qlcnic_adapter *adapter) | |||
365 | } | 345 | } |
366 | 346 | ||
367 | static int do_rom_fast_read(struct qlcnic_adapter *adapter, | 347 | static int do_rom_fast_read(struct qlcnic_adapter *adapter, |
368 | int addr, int *valp) | 348 | u32 addr, u32 *valp) |
369 | { | 349 | { |
370 | QLCWR32(adapter, QLCNIC_ROMUSB_ROM_ADDRESS, addr); | 350 | QLCWR32(adapter, QLCNIC_ROMUSB_ROM_ADDRESS, addr); |
371 | QLCWR32(adapter, QLCNIC_ROMUSB_ROM_DUMMY_BYTE_CNT, 0); | 351 | QLCWR32(adapter, QLCNIC_ROMUSB_ROM_DUMMY_BYTE_CNT, 0); |
@@ -418,7 +398,7 @@ qlcnic_rom_fast_read_words(struct qlcnic_adapter *adapter, int addr, | |||
418 | return ret; | 398 | return ret; |
419 | } | 399 | } |
420 | 400 | ||
421 | int qlcnic_rom_fast_read(struct qlcnic_adapter *adapter, int addr, int *valp) | 401 | int qlcnic_rom_fast_read(struct qlcnic_adapter *adapter, u32 addr, u32 *valp) |
422 | { | 402 | { |
423 | int ret; | 403 | int ret; |
424 | 404 | ||
@@ -439,11 +419,14 @@ int qlcnic_pinit_from_rom(struct qlcnic_adapter *adapter) | |||
439 | u32 off; | 419 | u32 off; |
440 | struct pci_dev *pdev = adapter->pdev; | 420 | struct pci_dev *pdev = adapter->pdev; |
441 | 421 | ||
442 | /* resetall */ | 422 | QLCWR32(adapter, CRB_CMDPEG_STATE, 0); |
423 | QLCWR32(adapter, CRB_RCVPEG_STATE, 0); | ||
424 | |||
443 | qlcnic_rom_lock(adapter); | 425 | qlcnic_rom_lock(adapter); |
444 | QLCWR32(adapter, QLCNIC_ROMUSB_GLB_SW_RESET, 0xfeffffff); | 426 | QLCWR32(adapter, QLCNIC_ROMUSB_GLB_SW_RESET, 0xfeffffff); |
445 | qlcnic_rom_unlock(adapter); | 427 | qlcnic_rom_unlock(adapter); |
446 | 428 | ||
429 | /* Init HW CRB block */ | ||
447 | if (qlcnic_rom_fast_read(adapter, 0, &n) != 0 || (n != 0xcafecafe) || | 430 | if (qlcnic_rom_fast_read(adapter, 0, &n) != 0 || (n != 0xcafecafe) || |
448 | qlcnic_rom_fast_read(adapter, 4, &n) != 0) { | 431 | qlcnic_rom_fast_read(adapter, 4, &n) != 0) { |
449 | dev_err(&pdev->dev, "ERROR Reading crb_init area: val:%x\n", n); | 432 | dev_err(&pdev->dev, "ERROR Reading crb_init area: val:%x\n", n); |
@@ -524,13 +507,10 @@ int qlcnic_pinit_from_rom(struct qlcnic_adapter *adapter) | |||
524 | } | 507 | } |
525 | kfree(buf); | 508 | kfree(buf); |
526 | 509 | ||
527 | /* p2dn replyCount */ | 510 | /* Initialize protocol process engine */ |
528 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_D + 0xec, 0x1e); | 511 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_D + 0xec, 0x1e); |
529 | /* disable_peg_cache 0 & 1*/ | ||
530 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_D + 0x4c, 8); | 512 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_D + 0x4c, 8); |
531 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_I + 0x4c, 8); | 513 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_I + 0x4c, 8); |
532 | |||
533 | /* peg_clr_all */ | ||
534 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_0 + 0x8, 0); | 514 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_0 + 0x8, 0); |
535 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_0 + 0xc, 0); | 515 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_0 + 0xc, 0); |
536 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_1 + 0x8, 0); | 516 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_1 + 0x8, 0); |
@@ -539,10 +519,88 @@ int qlcnic_pinit_from_rom(struct qlcnic_adapter *adapter) | |||
539 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_2 + 0xc, 0); | 519 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_2 + 0xc, 0); |
540 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_3 + 0x8, 0); | 520 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_3 + 0x8, 0); |
541 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_3 + 0xc, 0); | 521 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_3 + 0xc, 0); |
522 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_4 + 0x8, 0); | ||
523 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_4 + 0xc, 0); | ||
524 | msleep(1); | ||
525 | QLCWR32(adapter, QLCNIC_PEG_HALT_STATUS1, 0); | ||
526 | QLCWR32(adapter, QLCNIC_PEG_HALT_STATUS2, 0); | ||
527 | return 0; | ||
528 | } | ||
529 | |||
530 | static int qlcnic_cmd_peg_ready(struct qlcnic_adapter *adapter) | ||
531 | { | ||
532 | u32 val; | ||
533 | int retries = QLCNIC_CMDPEG_CHECK_RETRY_COUNT; | ||
534 | |||
535 | do { | ||
536 | val = QLCRD32(adapter, CRB_CMDPEG_STATE); | ||
537 | |||
538 | switch (val) { | ||
539 | case PHAN_INITIALIZE_COMPLETE: | ||
540 | case PHAN_INITIALIZE_ACK: | ||
541 | return 0; | ||
542 | case PHAN_INITIALIZE_FAILED: | ||
543 | goto out_err; | ||
544 | default: | ||
545 | break; | ||
546 | } | ||
547 | |||
548 | msleep(QLCNIC_CMDPEG_CHECK_DELAY); | ||
549 | |||
550 | } while (--retries); | ||
551 | |||
552 | QLCWR32(adapter, CRB_CMDPEG_STATE, PHAN_INITIALIZE_FAILED); | ||
553 | |||
554 | out_err: | ||
555 | dev_err(&adapter->pdev->dev, "Command Peg initialization not " | ||
556 | "complete, state: 0x%x.\n", val); | ||
557 | return -EIO; | ||
558 | } | ||
559 | |||
560 | static int | ||
561 | qlcnic_receive_peg_ready(struct qlcnic_adapter *adapter) | ||
562 | { | ||
563 | u32 val; | ||
564 | int retries = QLCNIC_RCVPEG_CHECK_RETRY_COUNT; | ||
565 | |||
566 | do { | ||
567 | val = QLCRD32(adapter, CRB_RCVPEG_STATE); | ||
568 | |||
569 | if (val == PHAN_PEG_RCV_INITIALIZED) | ||
570 | return 0; | ||
571 | |||
572 | msleep(QLCNIC_RCVPEG_CHECK_DELAY); | ||
573 | |||
574 | } while (--retries); | ||
575 | |||
576 | if (!retries) { | ||
577 | dev_err(&adapter->pdev->dev, "Receive Peg initialization not " | ||
578 | "complete, state: 0x%x.\n", val); | ||
579 | return -EIO; | ||
580 | } | ||
581 | |||
542 | return 0; | 582 | return 0; |
543 | } | 583 | } |
544 | 584 | ||
545 | int | 585 | int |
586 | qlcnic_check_fw_status(struct qlcnic_adapter *adapter) | ||
587 | { | ||
588 | int err; | ||
589 | |||
590 | err = qlcnic_cmd_peg_ready(adapter); | ||
591 | if (err) | ||
592 | return err; | ||
593 | |||
594 | err = qlcnic_receive_peg_ready(adapter); | ||
595 | if (err) | ||
596 | return err; | ||
597 | |||
598 | QLCWR32(adapter, CRB_CMDPEG_STATE, PHAN_INITIALIZE_ACK); | ||
599 | |||
600 | return err; | ||
601 | } | ||
602 | |||
603 | int | ||
546 | qlcnic_setup_idc_param(struct qlcnic_adapter *adapter) { | 604 | qlcnic_setup_idc_param(struct qlcnic_adapter *adapter) { |
547 | 605 | ||
548 | int timeo; | 606 | int timeo; |
@@ -557,24 +615,85 @@ qlcnic_setup_idc_param(struct qlcnic_adapter *adapter) { | |||
557 | } | 615 | } |
558 | adapter->physical_port = (val >> 2); | 616 | adapter->physical_port = (val >> 2); |
559 | if (qlcnic_rom_fast_read(adapter, QLCNIC_ROM_DEV_INIT_TIMEOUT, &timeo)) | 617 | if (qlcnic_rom_fast_read(adapter, QLCNIC_ROM_DEV_INIT_TIMEOUT, &timeo)) |
560 | timeo = 30; | 618 | timeo = QLCNIC_INIT_TIMEOUT_SECS; |
561 | 619 | ||
562 | adapter->dev_init_timeo = timeo; | 620 | adapter->dev_init_timeo = timeo; |
563 | 621 | ||
564 | if (qlcnic_rom_fast_read(adapter, QLCNIC_ROM_DRV_RESET_TIMEOUT, &timeo)) | 622 | if (qlcnic_rom_fast_read(adapter, QLCNIC_ROM_DRV_RESET_TIMEOUT, &timeo)) |
565 | timeo = 10; | 623 | timeo = QLCNIC_RESET_TIMEOUT_SECS; |
566 | 624 | ||
567 | adapter->reset_ack_timeo = timeo; | 625 | adapter->reset_ack_timeo = timeo; |
568 | 626 | ||
569 | return 0; | 627 | return 0; |
570 | } | 628 | } |
571 | 629 | ||
630 | static int qlcnic_get_flt_entry(struct qlcnic_adapter *adapter, u8 region, | ||
631 | struct qlcnic_flt_entry *region_entry) | ||
632 | { | ||
633 | struct qlcnic_flt_header flt_hdr; | ||
634 | struct qlcnic_flt_entry *flt_entry; | ||
635 | int i = 0, ret; | ||
636 | u32 entry_size; | ||
637 | |||
638 | memset(region_entry, 0, sizeof(struct qlcnic_flt_entry)); | ||
639 | ret = qlcnic_rom_fast_read_words(adapter, QLCNIC_FLT_LOCATION, | ||
640 | (u8 *)&flt_hdr, | ||
641 | sizeof(struct qlcnic_flt_header)); | ||
642 | if (ret) { | ||
643 | dev_warn(&adapter->pdev->dev, | ||
644 | "error reading flash layout header\n"); | ||
645 | return -EIO; | ||
646 | } | ||
647 | |||
648 | entry_size = flt_hdr.len - sizeof(struct qlcnic_flt_header); | ||
649 | flt_entry = (struct qlcnic_flt_entry *)vzalloc(entry_size); | ||
650 | if (flt_entry == NULL) { | ||
651 | dev_warn(&adapter->pdev->dev, "error allocating memory\n"); | ||
652 | return -EIO; | ||
653 | } | ||
654 | |||
655 | ret = qlcnic_rom_fast_read_words(adapter, QLCNIC_FLT_LOCATION + | ||
656 | sizeof(struct qlcnic_flt_header), | ||
657 | (u8 *)flt_entry, entry_size); | ||
658 | if (ret) { | ||
659 | dev_warn(&adapter->pdev->dev, | ||
660 | "error reading flash layout entries\n"); | ||
661 | goto err_out; | ||
662 | } | ||
663 | |||
664 | while (i < (entry_size/sizeof(struct qlcnic_flt_entry))) { | ||
665 | if (flt_entry[i].region == region) | ||
666 | break; | ||
667 | i++; | ||
668 | } | ||
669 | if (i >= (entry_size/sizeof(struct qlcnic_flt_entry))) { | ||
670 | dev_warn(&adapter->pdev->dev, | ||
671 | "region=%x not found in %d regions\n", region, i); | ||
672 | ret = -EIO; | ||
673 | goto err_out; | ||
674 | } | ||
675 | memcpy(region_entry, &flt_entry[i], sizeof(struct qlcnic_flt_entry)); | ||
676 | |||
677 | err_out: | ||
678 | vfree(flt_entry); | ||
679 | return ret; | ||
680 | } | ||
681 | |||
572 | int | 682 | int |
573 | qlcnic_check_flash_fw_ver(struct qlcnic_adapter *adapter) | 683 | qlcnic_check_flash_fw_ver(struct qlcnic_adapter *adapter) |
574 | { | 684 | { |
685 | struct qlcnic_flt_entry fw_entry; | ||
575 | u32 ver = -1, min_ver; | 686 | u32 ver = -1, min_ver; |
687 | int ret; | ||
576 | 688 | ||
577 | qlcnic_rom_fast_read(adapter, QLCNIC_FW_VERSION_OFFSET, (int *)&ver); | 689 | ret = qlcnic_get_flt_entry(adapter, QLCNIC_FW_IMAGE_REGION, &fw_entry); |
690 | if (!ret) | ||
691 | /* 0-4:-signature, 4-8:-fw version */ | ||
692 | qlcnic_rom_fast_read(adapter, fw_entry.start_addr + 4, | ||
693 | (int *)&ver); | ||
694 | else | ||
695 | qlcnic_rom_fast_read(adapter, QLCNIC_FW_VERSION_OFFSET, | ||
696 | (int *)&ver); | ||
578 | 697 | ||
579 | ver = QLCNIC_DECODE_VERSION(ver); | 698 | ver = QLCNIC_DECODE_VERSION(ver); |
580 | min_ver = QLCNIC_MIN_FW_VERSION; | 699 | min_ver = QLCNIC_MIN_FW_VERSION; |
@@ -745,7 +864,7 @@ nomn: | |||
745 | for (i = 0; i < entries; i++) { | 864 | for (i = 0; i < entries; i++) { |
746 | 865 | ||
747 | __le32 flags, file_chiprev, offs; | 866 | __le32 flags, file_chiprev, offs; |
748 | u8 chiprev = adapter->ahw.revision_id; | 867 | u8 chiprev = adapter->ahw->revision_id; |
749 | u32 flagbit; | 868 | u32 flagbit; |
750 | 869 | ||
751 | offs = cpu_to_le32(ptab_descr->findex) + | 870 | offs = cpu_to_le32(ptab_descr->findex) + |
@@ -906,54 +1025,47 @@ qlcnic_get_bios_version(struct qlcnic_adapter *adapter) | |||
906 | return (bios_ver << 16) + ((bios_ver >> 8) & 0xff00) + (bios_ver >> 24); | 1025 | return (bios_ver << 16) + ((bios_ver >> 8) & 0xff00) + (bios_ver >> 24); |
907 | } | 1026 | } |
908 | 1027 | ||
909 | int | 1028 | static void qlcnic_rom_lock_recovery(struct qlcnic_adapter *adapter) |
910 | qlcnic_need_fw_reset(struct qlcnic_adapter *adapter) | ||
911 | { | 1029 | { |
912 | u32 count, old_count; | 1030 | if (qlcnic_pcie_sem_lock(adapter, 2, QLCNIC_ROM_LOCK_ID)) |
913 | u32 val, version, major, minor, build; | 1031 | dev_info(&adapter->pdev->dev, "Resetting rom_lock\n"); |
914 | int i, timeout; | ||
915 | 1032 | ||
916 | if (adapter->need_fw_reset) | 1033 | qlcnic_pcie_sem_unlock(adapter, 2); |
917 | return 1; | 1034 | } |
918 | |||
919 | /* last attempt had failed */ | ||
920 | if (QLCRD32(adapter, CRB_CMDPEG_STATE) == PHAN_INITIALIZE_FAILED) | ||
921 | return 1; | ||
922 | 1035 | ||
923 | old_count = QLCRD32(adapter, QLCNIC_PEG_ALIVE_COUNTER); | 1036 | static int |
1037 | qlcnic_check_fw_hearbeat(struct qlcnic_adapter *adapter) | ||
1038 | { | ||
1039 | u32 heartbeat, ret = -EIO; | ||
1040 | int retries = QLCNIC_HEARTBEAT_CHECK_RETRY_COUNT; | ||
924 | 1041 | ||
925 | for (i = 0; i < 10; i++) { | 1042 | adapter->heartbeat = QLCRD32(adapter, QLCNIC_PEG_ALIVE_COUNTER); |
926 | 1043 | ||
927 | timeout = msleep_interruptible(200); | 1044 | do { |
928 | if (timeout) { | 1045 | msleep(QLCNIC_HEARTBEAT_PERIOD_MSECS); |
929 | QLCWR32(adapter, CRB_CMDPEG_STATE, | 1046 | heartbeat = QLCRD32(adapter, QLCNIC_PEG_ALIVE_COUNTER); |
930 | PHAN_INITIALIZE_FAILED); | 1047 | if (heartbeat != adapter->heartbeat) { |
931 | return -EINTR; | 1048 | ret = QLCNIC_RCODE_SUCCESS; |
1049 | break; | ||
932 | } | 1050 | } |
1051 | } while (--retries); | ||
933 | 1052 | ||
934 | count = QLCRD32(adapter, QLCNIC_PEG_ALIVE_COUNTER); | 1053 | return ret; |
935 | if (count != old_count) | 1054 | } |
936 | break; | ||
937 | } | ||
938 | 1055 | ||
939 | /* firmware is dead */ | 1056 | int |
940 | if (count == old_count) | 1057 | qlcnic_need_fw_reset(struct qlcnic_adapter *adapter) |
1058 | { | ||
1059 | if (qlcnic_check_fw_hearbeat(adapter)) { | ||
1060 | qlcnic_rom_lock_recovery(adapter); | ||
941 | return 1; | 1061 | return 1; |
1062 | } | ||
942 | 1063 | ||
943 | /* check if we have got newer or different file firmware */ | 1064 | if (adapter->need_fw_reset) |
944 | if (adapter->fw) { | 1065 | return 1; |
945 | |||
946 | val = qlcnic_get_fw_version(adapter); | ||
947 | |||
948 | version = QLCNIC_DECODE_VERSION(val); | ||
949 | |||
950 | major = QLCRD32(adapter, QLCNIC_FW_VERSION_MAJOR); | ||
951 | minor = QLCRD32(adapter, QLCNIC_FW_VERSION_MINOR); | ||
952 | build = QLCRD32(adapter, QLCNIC_FW_VERSION_SUB); | ||
953 | 1066 | ||
954 | if (version > QLCNIC_VERSION_CODE(major, minor, build)) | 1067 | if (adapter->fw) |
955 | return 1; | 1068 | return 1; |
956 | } | ||
957 | 1069 | ||
958 | return 0; | 1070 | return 0; |
959 | } | 1071 | } |
@@ -1018,9 +1130,20 @@ qlcnic_load_firmware(struct qlcnic_adapter *adapter) | |||
1018 | } else { | 1130 | } else { |
1019 | u64 data; | 1131 | u64 data; |
1020 | u32 hi, lo; | 1132 | u32 hi, lo; |
1021 | 1133 | int ret; | |
1022 | size = (QLCNIC_IMAGE_START - QLCNIC_BOOTLD_START) / 8; | 1134 | struct qlcnic_flt_entry bootld_entry; |
1023 | flashaddr = QLCNIC_BOOTLD_START; | 1135 | |
1136 | ret = qlcnic_get_flt_entry(adapter, QLCNIC_BOOTLD_REGION, | ||
1137 | &bootld_entry); | ||
1138 | if (!ret) { | ||
1139 | size = bootld_entry.size / 8; | ||
1140 | flashaddr = bootld_entry.start_addr; | ||
1141 | } else { | ||
1142 | size = (QLCNIC_IMAGE_START - QLCNIC_BOOTLD_START) / 8; | ||
1143 | flashaddr = QLCNIC_BOOTLD_START; | ||
1144 | dev_info(&pdev->dev, | ||
1145 | "using legacy method to get flash fw region"); | ||
1146 | } | ||
1024 | 1147 | ||
1025 | for (i = 0; i < size; i++) { | 1148 | for (i = 0; i < size; i++) { |
1026 | if (qlcnic_rom_fast_read(adapter, | 1149 | if (qlcnic_rom_fast_read(adapter, |
@@ -1089,18 +1212,6 @@ qlcnic_validate_firmware(struct qlcnic_adapter *adapter) | |||
1089 | return -EINVAL; | 1212 | return -EINVAL; |
1090 | } | 1213 | } |
1091 | 1214 | ||
1092 | /* check if flashed firmware is newer */ | ||
1093 | if (qlcnic_rom_fast_read(adapter, | ||
1094 | QLCNIC_FW_VERSION_OFFSET, (int *)&val)) | ||
1095 | return -EIO; | ||
1096 | |||
1097 | val = QLCNIC_DECODE_VERSION(val); | ||
1098 | if (val > ver) { | ||
1099 | dev_info(&pdev->dev, "%s: firmware is older than flash\n", | ||
1100 | fw_name[fw_type]); | ||
1101 | return -EINVAL; | ||
1102 | } | ||
1103 | |||
1104 | QLCWR32(adapter, QLCNIC_CAM_RAM(0x1fc), QLCNIC_BDINFO_MAGIC); | 1215 | QLCWR32(adapter, QLCNIC_CAM_RAM(0x1fc), QLCNIC_BDINFO_MAGIC); |
1105 | return 0; | 1216 | return 0; |
1106 | } | 1217 | } |
@@ -1162,78 +1273,6 @@ qlcnic_release_firmware(struct qlcnic_adapter *adapter) | |||
1162 | adapter->fw = NULL; | 1273 | adapter->fw = NULL; |
1163 | } | 1274 | } |
1164 | 1275 | ||
1165 | static int qlcnic_cmd_peg_ready(struct qlcnic_adapter *adapter) | ||
1166 | { | ||
1167 | u32 val; | ||
1168 | int retries = 60; | ||
1169 | |||
1170 | do { | ||
1171 | val = QLCRD32(adapter, CRB_CMDPEG_STATE); | ||
1172 | |||
1173 | switch (val) { | ||
1174 | case PHAN_INITIALIZE_COMPLETE: | ||
1175 | case PHAN_INITIALIZE_ACK: | ||
1176 | return 0; | ||
1177 | case PHAN_INITIALIZE_FAILED: | ||
1178 | goto out_err; | ||
1179 | default: | ||
1180 | break; | ||
1181 | } | ||
1182 | |||
1183 | msleep(500); | ||
1184 | |||
1185 | } while (--retries); | ||
1186 | |||
1187 | QLCWR32(adapter, CRB_CMDPEG_STATE, PHAN_INITIALIZE_FAILED); | ||
1188 | |||
1189 | out_err: | ||
1190 | dev_err(&adapter->pdev->dev, "Command Peg initialization not " | ||
1191 | "complete, state: 0x%x.\n", val); | ||
1192 | return -EIO; | ||
1193 | } | ||
1194 | |||
1195 | static int | ||
1196 | qlcnic_receive_peg_ready(struct qlcnic_adapter *adapter) | ||
1197 | { | ||
1198 | u32 val; | ||
1199 | int retries = 2000; | ||
1200 | |||
1201 | do { | ||
1202 | val = QLCRD32(adapter, CRB_RCVPEG_STATE); | ||
1203 | |||
1204 | if (val == PHAN_PEG_RCV_INITIALIZED) | ||
1205 | return 0; | ||
1206 | |||
1207 | msleep(10); | ||
1208 | |||
1209 | } while (--retries); | ||
1210 | |||
1211 | if (!retries) { | ||
1212 | dev_err(&adapter->pdev->dev, "Receive Peg initialization not " | ||
1213 | "complete, state: 0x%x.\n", val); | ||
1214 | return -EIO; | ||
1215 | } | ||
1216 | |||
1217 | return 0; | ||
1218 | } | ||
1219 | |||
1220 | int qlcnic_init_firmware(struct qlcnic_adapter *adapter) | ||
1221 | { | ||
1222 | int err; | ||
1223 | |||
1224 | err = qlcnic_cmd_peg_ready(adapter); | ||
1225 | if (err) | ||
1226 | return err; | ||
1227 | |||
1228 | err = qlcnic_receive_peg_ready(adapter); | ||
1229 | if (err) | ||
1230 | return err; | ||
1231 | |||
1232 | QLCWR32(adapter, CRB_CMDPEG_STATE, PHAN_INITIALIZE_ACK); | ||
1233 | |||
1234 | return err; | ||
1235 | } | ||
1236 | |||
1237 | static void | 1276 | static void |
1238 | qlcnic_handle_linkevent(struct qlcnic_adapter *adapter, | 1277 | qlcnic_handle_linkevent(struct qlcnic_adapter *adapter, |
1239 | struct qlcnic_fw_msg *msg) | 1278 | struct qlcnic_fw_msg *msg) |
@@ -1351,11 +1390,12 @@ static struct sk_buff *qlcnic_process_rxbuf(struct qlcnic_adapter *adapter, | |||
1351 | 1390 | ||
1352 | skb = buffer->skb; | 1391 | skb = buffer->skb; |
1353 | 1392 | ||
1354 | if (likely(adapter->rx_csum && cksum == STATUS_CKSUM_OK)) { | 1393 | if (likely((adapter->netdev->features & NETIF_F_RXCSUM) && |
1394 | (cksum == STATUS_CKSUM_OK || cksum == STATUS_CKSUM_LOOP))) { | ||
1355 | adapter->stats.csummed++; | 1395 | adapter->stats.csummed++; |
1356 | skb->ip_summed = CHECKSUM_UNNECESSARY; | 1396 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
1357 | } else { | 1397 | } else { |
1358 | skb->ip_summed = CHECKSUM_NONE; | 1398 | skb_checksum_none_assert(skb); |
1359 | } | 1399 | } |
1360 | 1400 | ||
1361 | skb->dev = adapter->netdev; | 1401 | skb->dev = adapter->netdev; |
@@ -1365,17 +1405,43 @@ static struct sk_buff *qlcnic_process_rxbuf(struct qlcnic_adapter *adapter, | |||
1365 | return skb; | 1405 | return skb; |
1366 | } | 1406 | } |
1367 | 1407 | ||
1408 | static inline int | ||
1409 | qlcnic_check_rx_tagging(struct qlcnic_adapter *adapter, struct sk_buff *skb, | ||
1410 | u16 *vlan_tag) | ||
1411 | { | ||
1412 | struct ethhdr *eth_hdr; | ||
1413 | |||
1414 | if (!__vlan_get_tag(skb, vlan_tag)) { | ||
1415 | eth_hdr = (struct ethhdr *) skb->data; | ||
1416 | memmove(skb->data + VLAN_HLEN, eth_hdr, ETH_ALEN * 2); | ||
1417 | skb_pull(skb, VLAN_HLEN); | ||
1418 | } | ||
1419 | if (!adapter->pvid) | ||
1420 | return 0; | ||
1421 | |||
1422 | if (*vlan_tag == adapter->pvid) { | ||
1423 | /* Outer vlan tag. Packet should follow non-vlan path */ | ||
1424 | *vlan_tag = 0xffff; | ||
1425 | return 0; | ||
1426 | } | ||
1427 | if (adapter->flags & QLCNIC_TAGGING_ENABLED) | ||
1428 | return 0; | ||
1429 | |||
1430 | return -EINVAL; | ||
1431 | } | ||
1432 | |||
1368 | static struct qlcnic_rx_buffer * | 1433 | static struct qlcnic_rx_buffer * |
1369 | qlcnic_process_rcv(struct qlcnic_adapter *adapter, | 1434 | qlcnic_process_rcv(struct qlcnic_adapter *adapter, |
1370 | struct qlcnic_host_sds_ring *sds_ring, | 1435 | struct qlcnic_host_sds_ring *sds_ring, |
1371 | int ring, u64 sts_data0) | 1436 | int ring, u64 sts_data0) |
1372 | { | 1437 | { |
1373 | struct net_device *netdev = adapter->netdev; | 1438 | struct net_device *netdev = adapter->netdev; |
1374 | struct qlcnic_recv_context *recv_ctx = &adapter->recv_ctx; | 1439 | struct qlcnic_recv_context *recv_ctx = adapter->recv_ctx; |
1375 | struct qlcnic_rx_buffer *buffer; | 1440 | struct qlcnic_rx_buffer *buffer; |
1376 | struct sk_buff *skb; | 1441 | struct sk_buff *skb; |
1377 | struct qlcnic_host_rds_ring *rds_ring; | 1442 | struct qlcnic_host_rds_ring *rds_ring; |
1378 | int index, length, cksum, pkt_offset; | 1443 | int index, length, cksum, pkt_offset; |
1444 | u16 vid = 0xffff; | ||
1379 | 1445 | ||
1380 | if (unlikely(ring >= adapter->max_rds_rings)) | 1446 | if (unlikely(ring >= adapter->max_rds_rings)) |
1381 | return NULL; | 1447 | return NULL; |
@@ -1404,8 +1470,17 @@ qlcnic_process_rcv(struct qlcnic_adapter *adapter, | |||
1404 | if (pkt_offset) | 1470 | if (pkt_offset) |
1405 | skb_pull(skb, pkt_offset); | 1471 | skb_pull(skb, pkt_offset); |
1406 | 1472 | ||
1473 | if (unlikely(qlcnic_check_rx_tagging(adapter, skb, &vid))) { | ||
1474 | adapter->stats.rxdropped++; | ||
1475 | dev_kfree_skb(skb); | ||
1476 | return buffer; | ||
1477 | } | ||
1478 | |||
1407 | skb->protocol = eth_type_trans(skb, netdev); | 1479 | skb->protocol = eth_type_trans(skb, netdev); |
1408 | 1480 | ||
1481 | if (vid != 0xffff) | ||
1482 | __vlan_hwaccel_put_tag(skb, vid); | ||
1483 | |||
1409 | napi_gro_receive(&sds_ring->napi, skb); | 1484 | napi_gro_receive(&sds_ring->napi, skb); |
1410 | 1485 | ||
1411 | adapter->stats.rx_pkts++; | 1486 | adapter->stats.rx_pkts++; |
@@ -1424,7 +1499,7 @@ qlcnic_process_lro(struct qlcnic_adapter *adapter, | |||
1424 | int ring, u64 sts_data0, u64 sts_data1) | 1499 | int ring, u64 sts_data0, u64 sts_data1) |
1425 | { | 1500 | { |
1426 | struct net_device *netdev = adapter->netdev; | 1501 | struct net_device *netdev = adapter->netdev; |
1427 | struct qlcnic_recv_context *recv_ctx = &adapter->recv_ctx; | 1502 | struct qlcnic_recv_context *recv_ctx = adapter->recv_ctx; |
1428 | struct qlcnic_rx_buffer *buffer; | 1503 | struct qlcnic_rx_buffer *buffer; |
1429 | struct sk_buff *skb; | 1504 | struct sk_buff *skb; |
1430 | struct qlcnic_host_rds_ring *rds_ring; | 1505 | struct qlcnic_host_rds_ring *rds_ring; |
@@ -1435,6 +1510,7 @@ qlcnic_process_lro(struct qlcnic_adapter *adapter, | |||
1435 | int index; | 1510 | int index; |
1436 | u16 lro_length, length, data_offset; | 1511 | u16 lro_length, length, data_offset; |
1437 | u32 seq_number; | 1512 | u32 seq_number; |
1513 | u16 vid = 0xffff; | ||
1438 | 1514 | ||
1439 | if (unlikely(ring > adapter->max_rds_rings)) | 1515 | if (unlikely(ring > adapter->max_rds_rings)) |
1440 | return NULL; | 1516 | return NULL; |
@@ -1466,6 +1542,13 @@ qlcnic_process_lro(struct qlcnic_adapter *adapter, | |||
1466 | skb_put(skb, lro_length + data_offset); | 1542 | skb_put(skb, lro_length + data_offset); |
1467 | 1543 | ||
1468 | skb_pull(skb, l2_hdr_offset); | 1544 | skb_pull(skb, l2_hdr_offset); |
1545 | |||
1546 | if (unlikely(qlcnic_check_rx_tagging(adapter, skb, &vid))) { | ||
1547 | adapter->stats.rxdropped++; | ||
1548 | dev_kfree_skb(skb); | ||
1549 | return buffer; | ||
1550 | } | ||
1551 | |||
1469 | skb->protocol = eth_type_trans(skb, netdev); | 1552 | skb->protocol = eth_type_trans(skb, netdev); |
1470 | 1553 | ||
1471 | iph = (struct iphdr *)skb->data; | 1554 | iph = (struct iphdr *)skb->data; |
@@ -1480,6 +1563,8 @@ qlcnic_process_lro(struct qlcnic_adapter *adapter, | |||
1480 | 1563 | ||
1481 | length = skb->len; | 1564 | length = skb->len; |
1482 | 1565 | ||
1566 | if (vid != 0xffff) | ||
1567 | __vlan_hwaccel_put_tag(skb, vid); | ||
1483 | netif_receive_skb(skb); | 1568 | netif_receive_skb(skb); |
1484 | 1569 | ||
1485 | adapter->stats.lro_pkts++; | 1570 | adapter->stats.lro_pkts++; |
@@ -1550,7 +1635,7 @@ skip: | |||
1550 | 1635 | ||
1551 | for (ring = 0; ring < adapter->max_rds_rings; ring++) { | 1636 | for (ring = 0; ring < adapter->max_rds_rings; ring++) { |
1552 | struct qlcnic_host_rds_ring *rds_ring = | 1637 | struct qlcnic_host_rds_ring *rds_ring = |
1553 | &adapter->recv_ctx.rds_rings[ring]; | 1638 | &adapter->recv_ctx->rds_rings[ring]; |
1554 | 1639 | ||
1555 | if (!list_empty(&sds_ring->free_list[ring])) { | 1640 | if (!list_empty(&sds_ring->free_list[ring])) { |
1556 | list_for_each(cur, &sds_ring->free_list[ring]) { | 1641 | list_for_each(cur, &sds_ring->free_list[ring]) { |
@@ -1576,16 +1661,15 @@ skip: | |||
1576 | } | 1661 | } |
1577 | 1662 | ||
1578 | void | 1663 | void |
1579 | qlcnic_post_rx_buffers(struct qlcnic_adapter *adapter, u32 ringid, | 1664 | qlcnic_post_rx_buffers(struct qlcnic_adapter *adapter, |
1580 | struct qlcnic_host_rds_ring *rds_ring) | 1665 | struct qlcnic_host_rds_ring *rds_ring) |
1581 | { | 1666 | { |
1582 | struct rcv_desc *pdesc; | 1667 | struct rcv_desc *pdesc; |
1583 | struct qlcnic_rx_buffer *buffer; | 1668 | struct qlcnic_rx_buffer *buffer; |
1584 | int producer, count = 0; | 1669 | int count = 0; |
1670 | u32 producer; | ||
1585 | struct list_head *head; | 1671 | struct list_head *head; |
1586 | 1672 | ||
1587 | spin_lock(&rds_ring->lock); | ||
1588 | |||
1589 | producer = rds_ring->producer; | 1673 | producer = rds_ring->producer; |
1590 | 1674 | ||
1591 | head = &rds_ring->free_list; | 1675 | head = &rds_ring->free_list; |
@@ -1615,7 +1699,6 @@ qlcnic_post_rx_buffers(struct qlcnic_adapter *adapter, u32 ringid, | |||
1615 | writel((producer-1) & (rds_ring->num_desc-1), | 1699 | writel((producer-1) & (rds_ring->num_desc-1), |
1616 | rds_ring->crb_rcv_producer); | 1700 | rds_ring->crb_rcv_producer); |
1617 | } | 1701 | } |
1618 | spin_unlock(&rds_ring->lock); | ||
1619 | } | 1702 | } |
1620 | 1703 | ||
1621 | static void | 1704 | static void |
@@ -1624,7 +1707,8 @@ qlcnic_post_rx_buffers_nodb(struct qlcnic_adapter *adapter, | |||
1624 | { | 1707 | { |
1625 | struct rcv_desc *pdesc; | 1708 | struct rcv_desc *pdesc; |
1626 | struct qlcnic_rx_buffer *buffer; | 1709 | struct qlcnic_rx_buffer *buffer; |
1627 | int producer, count = 0; | 1710 | int count = 0; |
1711 | uint32_t producer; | ||
1628 | struct list_head *head; | 1712 | struct list_head *head; |
1629 | 1713 | ||
1630 | if (!spin_trylock(&rds_ring->lock)) | 1714 | if (!spin_trylock(&rds_ring->lock)) |
@@ -1662,82 +1746,6 @@ qlcnic_post_rx_buffers_nodb(struct qlcnic_adapter *adapter, | |||
1662 | spin_unlock(&rds_ring->lock); | 1746 | spin_unlock(&rds_ring->lock); |
1663 | } | 1747 | } |
1664 | 1748 | ||
1665 | static struct qlcnic_rx_buffer * | ||
1666 | qlcnic_process_rcv_diag(struct qlcnic_adapter *adapter, | ||
1667 | struct qlcnic_host_sds_ring *sds_ring, | ||
1668 | int ring, u64 sts_data0) | ||
1669 | { | ||
1670 | struct qlcnic_recv_context *recv_ctx = &adapter->recv_ctx; | ||
1671 | struct qlcnic_rx_buffer *buffer; | ||
1672 | struct sk_buff *skb; | ||
1673 | struct qlcnic_host_rds_ring *rds_ring; | ||
1674 | int index, length, cksum, pkt_offset; | ||
1675 | |||
1676 | if (unlikely(ring >= adapter->max_rds_rings)) | ||
1677 | return NULL; | ||
1678 | |||
1679 | rds_ring = &recv_ctx->rds_rings[ring]; | ||
1680 | |||
1681 | index = qlcnic_get_sts_refhandle(sts_data0); | ||
1682 | if (unlikely(index >= rds_ring->num_desc)) | ||
1683 | return NULL; | ||
1684 | |||
1685 | buffer = &rds_ring->rx_buf_arr[index]; | ||
1686 | |||
1687 | length = qlcnic_get_sts_totallength(sts_data0); | ||
1688 | cksum = qlcnic_get_sts_status(sts_data0); | ||
1689 | pkt_offset = qlcnic_get_sts_pkt_offset(sts_data0); | ||
1690 | |||
1691 | skb = qlcnic_process_rxbuf(adapter, rds_ring, index, cksum); | ||
1692 | if (!skb) | ||
1693 | return buffer; | ||
1694 | |||
1695 | skb_put(skb, rds_ring->skb_size); | ||
1696 | |||
1697 | if (pkt_offset) | ||
1698 | skb_pull(skb, pkt_offset); | ||
1699 | |||
1700 | if (!qlcnic_check_loopback_buff(skb->data)) | ||
1701 | adapter->diag_cnt++; | ||
1702 | |||
1703 | dev_kfree_skb_any(skb); | ||
1704 | adapter->stats.rx_pkts++; | ||
1705 | adapter->stats.rxbytes += length; | ||
1706 | |||
1707 | return buffer; | ||
1708 | } | ||
1709 | |||
1710 | void | ||
1711 | qlcnic_process_rcv_ring_diag(struct qlcnic_host_sds_ring *sds_ring) | ||
1712 | { | ||
1713 | struct qlcnic_adapter *adapter = sds_ring->adapter; | ||
1714 | struct status_desc *desc; | ||
1715 | struct qlcnic_rx_buffer *rxbuf; | ||
1716 | u64 sts_data0; | ||
1717 | |||
1718 | int opcode, ring, desc_cnt; | ||
1719 | u32 consumer = sds_ring->consumer; | ||
1720 | |||
1721 | desc = &sds_ring->desc_head[consumer]; | ||
1722 | sts_data0 = le64_to_cpu(desc->status_desc_data[0]); | ||
1723 | |||
1724 | if (!(sts_data0 & STATUS_OWNER_HOST)) | ||
1725 | return; | ||
1726 | |||
1727 | desc_cnt = qlcnic_get_sts_desc_cnt(sts_data0); | ||
1728 | opcode = qlcnic_get_sts_opcode(sts_data0); | ||
1729 | |||
1730 | ring = qlcnic_get_sts_type(sts_data0); | ||
1731 | rxbuf = qlcnic_process_rcv_diag(adapter, sds_ring, | ||
1732 | ring, sts_data0); | ||
1733 | |||
1734 | desc->status_desc_data[0] = cpu_to_le64(STATUS_OWNER_PHANTOM); | ||
1735 | consumer = get_next_index(consumer, sds_ring->num_desc); | ||
1736 | |||
1737 | sds_ring->consumer = consumer; | ||
1738 | writel(consumer, sds_ring->crb_sts_consumer); | ||
1739 | } | ||
1740 | |||
1741 | void | 1749 | void |
1742 | qlcnic_fetch_mac(struct qlcnic_adapter *adapter, u32 off1, u32 off2, | 1750 | qlcnic_fetch_mac(struct qlcnic_adapter *adapter, u32 off1, u32 off2, |
1743 | u8 alt_mac, u8 *mac) | 1751 | u8 alt_mac, u8 *mac) |
diff --git a/drivers/net/qlcnic/qlcnic_main.c b/drivers/net/qlcnic/qlcnic_main.c index 66eea5972020..0f6af5c61a7c 100644 --- a/drivers/net/qlcnic/qlcnic_main.c +++ b/drivers/net/qlcnic/qlcnic_main.c | |||
@@ -1,25 +1,8 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2009 - QLogic Corporation. | 2 | * QLogic qlcnic NIC Driver |
3 | * All rights reserved. | 3 | * Copyright (c) 2009-2010 QLogic Corporation |
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License | ||
7 | * as published by the Free Software Foundation; either version 2 | ||
8 | * of the License, or (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, but | ||
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, | ||
18 | * MA 02111-1307, USA. | ||
19 | * | ||
20 | * The full GNU General Public License is included in this distribution | ||
21 | * in the file called "COPYING". | ||
22 | * | 4 | * |
5 | * See LICENSE.qlcnic for copyright and licensing details. | ||
23 | */ | 6 | */ |
24 | 7 | ||
25 | #include <linux/slab.h> | 8 | #include <linux/slab.h> |
@@ -28,13 +11,14 @@ | |||
28 | 11 | ||
29 | #include "qlcnic.h" | 12 | #include "qlcnic.h" |
30 | 13 | ||
14 | #include <linux/swab.h> | ||
31 | #include <linux/dma-mapping.h> | 15 | #include <linux/dma-mapping.h> |
32 | #include <linux/if_vlan.h> | ||
33 | #include <net/ip.h> | 16 | #include <net/ip.h> |
34 | #include <linux/ipv6.h> | 17 | #include <linux/ipv6.h> |
35 | #include <linux/inetdevice.h> | 18 | #include <linux/inetdevice.h> |
36 | #include <linux/sysfs.h> | 19 | #include <linux/sysfs.h> |
37 | #include <linux/aer.h> | 20 | #include <linux/aer.h> |
21 | #include <linux/log2.h> | ||
38 | 22 | ||
39 | MODULE_DESCRIPTION("QLogic 1/10 GbE Converged/Intelligent Ethernet Driver"); | 23 | MODULE_DESCRIPTION("QLogic 1/10 GbE Converged/Intelligent Ethernet Driver"); |
40 | MODULE_LICENSE("GPL"); | 24 | MODULE_LICENSE("GPL"); |
@@ -45,29 +29,29 @@ char qlcnic_driver_name[] = "qlcnic"; | |||
45 | static const char qlcnic_driver_string[] = "QLogic 1/10 GbE " | 29 | static const char qlcnic_driver_string[] = "QLogic 1/10 GbE " |
46 | "Converged/Intelligent Ethernet Driver v" QLCNIC_LINUX_VERSIONID; | 30 | "Converged/Intelligent Ethernet Driver v" QLCNIC_LINUX_VERSIONID; |
47 | 31 | ||
48 | static int port_mode = QLCNIC_PORT_MODE_AUTO_NEG; | 32 | static struct workqueue_struct *qlcnic_wq; |
49 | 33 | static int qlcnic_mac_learn; | |
50 | /* Default to restricted 1G auto-neg mode */ | 34 | module_param(qlcnic_mac_learn, int, 0444); |
51 | static int wol_port_mode = 5; | 35 | MODULE_PARM_DESC(qlcnic_mac_learn, "Mac Filter (0=disabled, 1=enabled)"); |
52 | 36 | ||
53 | static int use_msi = 1; | 37 | static int use_msi = 1; |
54 | module_param(use_msi, int, 0644); | 38 | module_param(use_msi, int, 0444); |
55 | MODULE_PARM_DESC(use_msi, "MSI interrupt (0=disabled, 1=enabled"); | 39 | MODULE_PARM_DESC(use_msi, "MSI interrupt (0=disabled, 1=enabled"); |
56 | 40 | ||
57 | static int use_msi_x = 1; | 41 | static int use_msi_x = 1; |
58 | module_param(use_msi_x, int, 0644); | 42 | module_param(use_msi_x, int, 0444); |
59 | MODULE_PARM_DESC(use_msi_x, "MSI-X interrupt (0=disabled, 1=enabled"); | 43 | MODULE_PARM_DESC(use_msi_x, "MSI-X interrupt (0=disabled, 1=enabled"); |
60 | 44 | ||
61 | static int auto_fw_reset = AUTO_FW_RESET_ENABLED; | 45 | static int auto_fw_reset = 1; |
62 | module_param(auto_fw_reset, int, 0644); | 46 | module_param(auto_fw_reset, int, 0644); |
63 | MODULE_PARM_DESC(auto_fw_reset, "Auto firmware reset (0=disabled, 1=enabled"); | 47 | MODULE_PARM_DESC(auto_fw_reset, "Auto firmware reset (0=disabled, 1=enabled"); |
64 | 48 | ||
65 | static int load_fw_file; | 49 | static int load_fw_file; |
66 | module_param(load_fw_file, int, 0644); | 50 | module_param(load_fw_file, int, 0444); |
67 | MODULE_PARM_DESC(load_fw_file, "Load firmware from (0=flash, 1=file"); | 51 | MODULE_PARM_DESC(load_fw_file, "Load firmware from (0=flash, 1=file"); |
68 | 52 | ||
69 | static int qlcnic_config_npars; | 53 | static int qlcnic_config_npars; |
70 | module_param(qlcnic_config_npars, int, 0644); | 54 | module_param(qlcnic_config_npars, int, 0444); |
71 | MODULE_PARM_DESC(qlcnic_config_npars, "Configure NPARs (0=disabled, 1=enabled"); | 55 | MODULE_PARM_DESC(qlcnic_config_npars, "Configure NPARs (0=disabled, 1=enabled"); |
72 | 56 | ||
73 | static int __devinit qlcnic_probe(struct pci_dev *pdev, | 57 | static int __devinit qlcnic_probe(struct pci_dev *pdev, |
@@ -94,7 +78,7 @@ static void qlcnic_create_diag_entries(struct qlcnic_adapter *adapter); | |||
94 | static void qlcnic_remove_diag_entries(struct qlcnic_adapter *adapter); | 78 | static void qlcnic_remove_diag_entries(struct qlcnic_adapter *adapter); |
95 | 79 | ||
96 | static void qlcnic_idc_debug_info(struct qlcnic_adapter *adapter, u8 encoding); | 80 | static void qlcnic_idc_debug_info(struct qlcnic_adapter *adapter, u8 encoding); |
97 | static void qlcnic_clr_all_drv_state(struct qlcnic_adapter *adapter); | 81 | static void qlcnic_clr_all_drv_state(struct qlcnic_adapter *adapter, u8); |
98 | static int qlcnic_can_start_firmware(struct qlcnic_adapter *adapter); | 82 | static int qlcnic_can_start_firmware(struct qlcnic_adapter *adapter); |
99 | 83 | ||
100 | static irqreturn_t qlcnic_tmp_intr(int irq, void *data); | 84 | static irqreturn_t qlcnic_tmp_intr(int irq, void *data); |
@@ -103,13 +87,20 @@ static irqreturn_t qlcnic_msi_intr(int irq, void *data); | |||
103 | static irqreturn_t qlcnic_msix_intr(int irq, void *data); | 87 | static irqreturn_t qlcnic_msix_intr(int irq, void *data); |
104 | 88 | ||
105 | static struct net_device_stats *qlcnic_get_stats(struct net_device *netdev); | 89 | static struct net_device_stats *qlcnic_get_stats(struct net_device *netdev); |
106 | static void qlcnic_config_indev_addr(struct net_device *dev, unsigned long); | 90 | static void qlcnic_restore_indev_addr(struct net_device *dev, unsigned long); |
107 | static int qlcnic_start_firmware(struct qlcnic_adapter *); | 91 | static int qlcnic_start_firmware(struct qlcnic_adapter *); |
108 | 92 | ||
93 | static void qlcnic_alloc_lb_filters_mem(struct qlcnic_adapter *adapter); | ||
94 | static void qlcnic_free_lb_filters_mem(struct qlcnic_adapter *adapter); | ||
109 | static void qlcnic_dev_set_npar_ready(struct qlcnic_adapter *); | 95 | static void qlcnic_dev_set_npar_ready(struct qlcnic_adapter *); |
110 | static int qlcnicvf_config_led(struct qlcnic_adapter *, u32, u32); | 96 | static int qlcnicvf_config_led(struct qlcnic_adapter *, u32, u32); |
111 | static int qlcnicvf_config_bridged_mode(struct qlcnic_adapter *, u32); | 97 | static int qlcnicvf_config_bridged_mode(struct qlcnic_adapter *, u32); |
112 | static int qlcnicvf_start_firmware(struct qlcnic_adapter *); | 98 | static int qlcnicvf_start_firmware(struct qlcnic_adapter *); |
99 | static void qlcnic_set_netdev_features(struct qlcnic_adapter *, | ||
100 | struct qlcnic_esw_func_cfg *); | ||
101 | static void qlcnic_vlan_rx_add(struct net_device *, u16); | ||
102 | static void qlcnic_vlan_rx_del(struct net_device *, u16); | ||
103 | |||
113 | /* PCI Device ID Table */ | 104 | /* PCI Device ID Table */ |
114 | #define ENTRY(device) \ | 105 | #define ENTRY(device) \ |
115 | {PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, (device)), \ | 106 | {PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, (device)), \ |
@@ -125,7 +116,7 @@ static DEFINE_PCI_DEVICE_TABLE(qlcnic_pci_tbl) = { | |||
125 | MODULE_DEVICE_TABLE(pci, qlcnic_pci_tbl); | 116 | MODULE_DEVICE_TABLE(pci, qlcnic_pci_tbl); |
126 | 117 | ||
127 | 118 | ||
128 | void | 119 | inline void |
129 | qlcnic_update_cmd_producer(struct qlcnic_adapter *adapter, | 120 | qlcnic_update_cmd_producer(struct qlcnic_adapter *adapter, |
130 | struct qlcnic_host_tx_ring *tx_ring) | 121 | struct qlcnic_host_tx_ring *tx_ring) |
131 | { | 122 | { |
@@ -164,7 +155,7 @@ qlcnic_alloc_sds_rings(struct qlcnic_recv_context *recv_ctx, int count) | |||
164 | 155 | ||
165 | recv_ctx->sds_rings = kzalloc(size, GFP_KERNEL); | 156 | recv_ctx->sds_rings = kzalloc(size, GFP_KERNEL); |
166 | 157 | ||
167 | return (recv_ctx->sds_rings == NULL); | 158 | return recv_ctx->sds_rings == NULL; |
168 | } | 159 | } |
169 | 160 | ||
170 | static void | 161 | static void |
@@ -181,7 +172,7 @@ qlcnic_napi_add(struct qlcnic_adapter *adapter, struct net_device *netdev) | |||
181 | { | 172 | { |
182 | int ring; | 173 | int ring; |
183 | struct qlcnic_host_sds_ring *sds_ring; | 174 | struct qlcnic_host_sds_ring *sds_ring; |
184 | struct qlcnic_recv_context *recv_ctx = &adapter->recv_ctx; | 175 | struct qlcnic_recv_context *recv_ctx = adapter->recv_ctx; |
185 | 176 | ||
186 | if (qlcnic_alloc_sds_rings(recv_ctx, adapter->max_sds_rings)) | 177 | if (qlcnic_alloc_sds_rings(recv_ctx, adapter->max_sds_rings)) |
187 | return -ENOMEM; | 178 | return -ENOMEM; |
@@ -205,14 +196,14 @@ qlcnic_napi_del(struct qlcnic_adapter *adapter) | |||
205 | { | 196 | { |
206 | int ring; | 197 | int ring; |
207 | struct qlcnic_host_sds_ring *sds_ring; | 198 | struct qlcnic_host_sds_ring *sds_ring; |
208 | struct qlcnic_recv_context *recv_ctx = &adapter->recv_ctx; | 199 | struct qlcnic_recv_context *recv_ctx = adapter->recv_ctx; |
209 | 200 | ||
210 | for (ring = 0; ring < adapter->max_sds_rings; ring++) { | 201 | for (ring = 0; ring < adapter->max_sds_rings; ring++) { |
211 | sds_ring = &recv_ctx->sds_rings[ring]; | 202 | sds_ring = &recv_ctx->sds_rings[ring]; |
212 | netif_napi_del(&sds_ring->napi); | 203 | netif_napi_del(&sds_ring->napi); |
213 | } | 204 | } |
214 | 205 | ||
215 | qlcnic_free_sds_rings(&adapter->recv_ctx); | 206 | qlcnic_free_sds_rings(adapter->recv_ctx); |
216 | } | 207 | } |
217 | 208 | ||
218 | static void | 209 | static void |
@@ -220,7 +211,7 @@ qlcnic_napi_enable(struct qlcnic_adapter *adapter) | |||
220 | { | 211 | { |
221 | int ring; | 212 | int ring; |
222 | struct qlcnic_host_sds_ring *sds_ring; | 213 | struct qlcnic_host_sds_ring *sds_ring; |
223 | struct qlcnic_recv_context *recv_ctx = &adapter->recv_ctx; | 214 | struct qlcnic_recv_context *recv_ctx = adapter->recv_ctx; |
224 | 215 | ||
225 | if (adapter->is_up != QLCNIC_ADAPTER_UP_MAGIC) | 216 | if (adapter->is_up != QLCNIC_ADAPTER_UP_MAGIC) |
226 | return; | 217 | return; |
@@ -237,7 +228,7 @@ qlcnic_napi_disable(struct qlcnic_adapter *adapter) | |||
237 | { | 228 | { |
238 | int ring; | 229 | int ring; |
239 | struct qlcnic_host_sds_ring *sds_ring; | 230 | struct qlcnic_host_sds_ring *sds_ring; |
240 | struct qlcnic_recv_context *recv_ctx = &adapter->recv_ctx; | 231 | struct qlcnic_recv_context *recv_ctx = adapter->recv_ctx; |
241 | 232 | ||
242 | if (adapter->is_up != QLCNIC_ADAPTER_UP_MAGIC) | 233 | if (adapter->is_up != QLCNIC_ADAPTER_UP_MAGIC) |
243 | return; | 234 | return; |
@@ -255,40 +246,6 @@ static void qlcnic_clear_stats(struct qlcnic_adapter *adapter) | |||
255 | memset(&adapter->stats, 0, sizeof(adapter->stats)); | 246 | memset(&adapter->stats, 0, sizeof(adapter->stats)); |
256 | } | 247 | } |
257 | 248 | ||
258 | static void qlcnic_set_port_mode(struct qlcnic_adapter *adapter) | ||
259 | { | ||
260 | u32 val, data; | ||
261 | |||
262 | val = adapter->ahw.board_type; | ||
263 | if ((val == QLCNIC_BRDTYPE_P3_HMEZ) || | ||
264 | (val == QLCNIC_BRDTYPE_P3_XG_LOM)) { | ||
265 | if (port_mode == QLCNIC_PORT_MODE_802_3_AP) { | ||
266 | data = QLCNIC_PORT_MODE_802_3_AP; | ||
267 | QLCWR32(adapter, QLCNIC_PORT_MODE_ADDR, data); | ||
268 | } else if (port_mode == QLCNIC_PORT_MODE_XG) { | ||
269 | data = QLCNIC_PORT_MODE_XG; | ||
270 | QLCWR32(adapter, QLCNIC_PORT_MODE_ADDR, data); | ||
271 | } else if (port_mode == QLCNIC_PORT_MODE_AUTO_NEG_1G) { | ||
272 | data = QLCNIC_PORT_MODE_AUTO_NEG_1G; | ||
273 | QLCWR32(adapter, QLCNIC_PORT_MODE_ADDR, data); | ||
274 | } else if (port_mode == QLCNIC_PORT_MODE_AUTO_NEG_XG) { | ||
275 | data = QLCNIC_PORT_MODE_AUTO_NEG_XG; | ||
276 | QLCWR32(adapter, QLCNIC_PORT_MODE_ADDR, data); | ||
277 | } else { | ||
278 | data = QLCNIC_PORT_MODE_AUTO_NEG; | ||
279 | QLCWR32(adapter, QLCNIC_PORT_MODE_ADDR, data); | ||
280 | } | ||
281 | |||
282 | if ((wol_port_mode != QLCNIC_PORT_MODE_802_3_AP) && | ||
283 | (wol_port_mode != QLCNIC_PORT_MODE_XG) && | ||
284 | (wol_port_mode != QLCNIC_PORT_MODE_AUTO_NEG_1G) && | ||
285 | (wol_port_mode != QLCNIC_PORT_MODE_AUTO_NEG_XG)) { | ||
286 | wol_port_mode = QLCNIC_PORT_MODE_AUTO_NEG; | ||
287 | } | ||
288 | QLCWR32(adapter, QLCNIC_WOL_PORT_MODE, wol_port_mode); | ||
289 | } | ||
290 | } | ||
291 | |||
292 | static void qlcnic_set_msix_bit(struct pci_dev *pdev, int enable) | 249 | static void qlcnic_set_msix_bit(struct pci_dev *pdev, int enable) |
293 | { | 250 | { |
294 | u32 control; | 251 | u32 control; |
@@ -320,7 +277,7 @@ qlcnic_read_mac_addr(struct qlcnic_adapter *adapter) | |||
320 | struct net_device *netdev = adapter->netdev; | 277 | struct net_device *netdev = adapter->netdev; |
321 | struct pci_dev *pdev = adapter->pdev; | 278 | struct pci_dev *pdev = adapter->pdev; |
322 | 279 | ||
323 | if (adapter->nic_ops->get_mac_addr(adapter, mac_addr) != 0) | 280 | if (qlcnic_get_mac_address(adapter, mac_addr) != 0) |
324 | return -EIO; | 281 | return -EIO; |
325 | 282 | ||
326 | memcpy(netdev->dev_addr, mac_addr, ETH_ALEN); | 283 | memcpy(netdev->dev_addr, mac_addr, ETH_ALEN); |
@@ -341,6 +298,9 @@ static int qlcnic_set_mac(struct net_device *netdev, void *p) | |||
341 | struct qlcnic_adapter *adapter = netdev_priv(netdev); | 298 | struct qlcnic_adapter *adapter = netdev_priv(netdev); |
342 | struct sockaddr *addr = p; | 299 | struct sockaddr *addr = p; |
343 | 300 | ||
301 | if ((adapter->flags & QLCNIC_MAC_OVERRIDE_DISABLED)) | ||
302 | return -EOPNOTSUPP; | ||
303 | |||
344 | if (!is_valid_ether_addr(addr->sa_data)) | 304 | if (!is_valid_ether_addr(addr->sa_data)) |
345 | return -EINVAL; | 305 | return -EINVAL; |
346 | 306 | ||
@@ -369,92 +329,109 @@ static const struct net_device_ops qlcnic_netdev_ops = { | |||
369 | .ndo_set_multicast_list = qlcnic_set_multi, | 329 | .ndo_set_multicast_list = qlcnic_set_multi, |
370 | .ndo_set_mac_address = qlcnic_set_mac, | 330 | .ndo_set_mac_address = qlcnic_set_mac, |
371 | .ndo_change_mtu = qlcnic_change_mtu, | 331 | .ndo_change_mtu = qlcnic_change_mtu, |
332 | .ndo_fix_features = qlcnic_fix_features, | ||
333 | .ndo_set_features = qlcnic_set_features, | ||
372 | .ndo_tx_timeout = qlcnic_tx_timeout, | 334 | .ndo_tx_timeout = qlcnic_tx_timeout, |
335 | .ndo_vlan_rx_add_vid = qlcnic_vlan_rx_add, | ||
336 | .ndo_vlan_rx_kill_vid = qlcnic_vlan_rx_del, | ||
373 | #ifdef CONFIG_NET_POLL_CONTROLLER | 337 | #ifdef CONFIG_NET_POLL_CONTROLLER |
374 | .ndo_poll_controller = qlcnic_poll_controller, | 338 | .ndo_poll_controller = qlcnic_poll_controller, |
375 | #endif | 339 | #endif |
376 | }; | 340 | }; |
377 | 341 | ||
378 | static struct qlcnic_nic_template qlcnic_ops = { | 342 | static struct qlcnic_nic_template qlcnic_ops = { |
379 | .get_mac_addr = qlcnic_get_mac_address, | ||
380 | .config_bridged_mode = qlcnic_config_bridged_mode, | 343 | .config_bridged_mode = qlcnic_config_bridged_mode, |
381 | .config_led = qlcnic_config_led, | 344 | .config_led = qlcnic_config_led, |
382 | .start_firmware = qlcnic_start_firmware | 345 | .start_firmware = qlcnic_start_firmware |
383 | }; | 346 | }; |
384 | 347 | ||
385 | static struct qlcnic_nic_template qlcnic_vf_ops = { | 348 | static struct qlcnic_nic_template qlcnic_vf_ops = { |
386 | .get_mac_addr = qlcnic_get_mac_address, | ||
387 | .config_bridged_mode = qlcnicvf_config_bridged_mode, | 349 | .config_bridged_mode = qlcnicvf_config_bridged_mode, |
388 | .config_led = qlcnicvf_config_led, | 350 | .config_led = qlcnicvf_config_led, |
389 | .start_firmware = qlcnicvf_start_firmware | 351 | .start_firmware = qlcnicvf_start_firmware |
390 | }; | 352 | }; |
391 | 353 | ||
392 | static void | 354 | static int qlcnic_enable_msix(struct qlcnic_adapter *adapter, u32 num_msix) |
393 | qlcnic_setup_intr(struct qlcnic_adapter *adapter) | ||
394 | { | 355 | { |
395 | const struct qlcnic_legacy_intr_set *legacy_intrp; | ||
396 | struct pci_dev *pdev = adapter->pdev; | 356 | struct pci_dev *pdev = adapter->pdev; |
397 | int err, num_msix; | 357 | int err = -1; |
398 | |||
399 | if (adapter->rss_supported) { | ||
400 | num_msix = (num_online_cpus() >= MSIX_ENTRIES_PER_ADAPTER) ? | ||
401 | MSIX_ENTRIES_PER_ADAPTER : 2; | ||
402 | } else | ||
403 | num_msix = 1; | ||
404 | 358 | ||
405 | adapter->max_sds_rings = 1; | 359 | adapter->max_sds_rings = 1; |
406 | |||
407 | adapter->flags &= ~(QLCNIC_MSI_ENABLED | QLCNIC_MSIX_ENABLED); | 360 | adapter->flags &= ~(QLCNIC_MSI_ENABLED | QLCNIC_MSIX_ENABLED); |
408 | |||
409 | legacy_intrp = &legacy_intr[adapter->ahw.pci_func]; | ||
410 | |||
411 | adapter->int_vec_bit = legacy_intrp->int_vec_bit; | ||
412 | adapter->tgt_status_reg = qlcnic_get_ioaddr(adapter, | ||
413 | legacy_intrp->tgt_status_reg); | ||
414 | adapter->tgt_mask_reg = qlcnic_get_ioaddr(adapter, | ||
415 | legacy_intrp->tgt_mask_reg); | ||
416 | adapter->isr_int_vec = qlcnic_get_ioaddr(adapter, ISR_INT_VECTOR); | ||
417 | |||
418 | adapter->crb_int_state_reg = qlcnic_get_ioaddr(adapter, | ||
419 | ISR_INT_STATE_REG); | ||
420 | |||
421 | qlcnic_set_msix_bit(pdev, 0); | 361 | qlcnic_set_msix_bit(pdev, 0); |
422 | 362 | ||
423 | if (adapter->msix_supported) { | 363 | if (adapter->msix_supported) { |
424 | 364 | enable_msix: | |
425 | qlcnic_init_msix_entries(adapter, num_msix); | 365 | qlcnic_init_msix_entries(adapter, num_msix); |
426 | err = pci_enable_msix(pdev, adapter->msix_entries, num_msix); | 366 | err = pci_enable_msix(pdev, adapter->msix_entries, num_msix); |
427 | if (err == 0) { | 367 | if (err == 0) { |
428 | adapter->flags |= QLCNIC_MSIX_ENABLED; | 368 | adapter->flags |= QLCNIC_MSIX_ENABLED; |
429 | qlcnic_set_msix_bit(pdev, 1); | 369 | qlcnic_set_msix_bit(pdev, 1); |
430 | 370 | ||
431 | if (adapter->rss_supported) | 371 | adapter->max_sds_rings = num_msix; |
432 | adapter->max_sds_rings = num_msix; | ||
433 | 372 | ||
434 | dev_info(&pdev->dev, "using msi-x interrupts\n"); | 373 | dev_info(&pdev->dev, "using msi-x interrupts\n"); |
435 | return; | 374 | return err; |
375 | } | ||
376 | if (err > 0) { | ||
377 | num_msix = rounddown_pow_of_two(err); | ||
378 | if (num_msix) | ||
379 | goto enable_msix; | ||
436 | } | 380 | } |
381 | } | ||
382 | return err; | ||
383 | } | ||
437 | 384 | ||
438 | if (err > 0) | ||
439 | pci_disable_msix(pdev); | ||
440 | 385 | ||
441 | /* fall through for msi */ | 386 | static void qlcnic_enable_msi_legacy(struct qlcnic_adapter *adapter) |
442 | } | 387 | { |
388 | const struct qlcnic_legacy_intr_set *legacy_intrp; | ||
389 | struct pci_dev *pdev = adapter->pdev; | ||
443 | 390 | ||
444 | if (use_msi && !pci_enable_msi(pdev)) { | 391 | if (use_msi && !pci_enable_msi(pdev)) { |
445 | adapter->flags |= QLCNIC_MSI_ENABLED; | 392 | adapter->flags |= QLCNIC_MSI_ENABLED; |
446 | adapter->tgt_status_reg = qlcnic_get_ioaddr(adapter, | 393 | adapter->tgt_status_reg = qlcnic_get_ioaddr(adapter, |
447 | msi_tgt_status[adapter->ahw.pci_func]); | 394 | msi_tgt_status[adapter->ahw->pci_func]); |
448 | dev_info(&pdev->dev, "using msi interrupts\n"); | 395 | dev_info(&pdev->dev, "using msi interrupts\n"); |
449 | adapter->msix_entries[0].vector = pdev->irq; | 396 | adapter->msix_entries[0].vector = pdev->irq; |
450 | return; | 397 | return; |
451 | } | 398 | } |
452 | 399 | ||
400 | legacy_intrp = &legacy_intr[adapter->ahw->pci_func]; | ||
401 | |||
402 | adapter->int_vec_bit = legacy_intrp->int_vec_bit; | ||
403 | adapter->tgt_status_reg = qlcnic_get_ioaddr(adapter, | ||
404 | legacy_intrp->tgt_status_reg); | ||
405 | adapter->tgt_mask_reg = qlcnic_get_ioaddr(adapter, | ||
406 | legacy_intrp->tgt_mask_reg); | ||
407 | adapter->isr_int_vec = qlcnic_get_ioaddr(adapter, ISR_INT_VECTOR); | ||
408 | |||
409 | adapter->crb_int_state_reg = qlcnic_get_ioaddr(adapter, | ||
410 | ISR_INT_STATE_REG); | ||
453 | dev_info(&pdev->dev, "using legacy interrupts\n"); | 411 | dev_info(&pdev->dev, "using legacy interrupts\n"); |
454 | adapter->msix_entries[0].vector = pdev->irq; | 412 | adapter->msix_entries[0].vector = pdev->irq; |
455 | } | 413 | } |
456 | 414 | ||
457 | static void | 415 | static void |
416 | qlcnic_setup_intr(struct qlcnic_adapter *adapter) | ||
417 | { | ||
418 | int num_msix; | ||
419 | |||
420 | if (adapter->msix_supported) { | ||
421 | num_msix = (num_online_cpus() >= | ||
422 | QLCNIC_DEF_NUM_STS_DESC_RINGS) ? | ||
423 | QLCNIC_DEF_NUM_STS_DESC_RINGS : | ||
424 | QLCNIC_MIN_NUM_RSS_RINGS; | ||
425 | } else | ||
426 | num_msix = 1; | ||
427 | |||
428 | if (!qlcnic_enable_msix(adapter, num_msix)) | ||
429 | return; | ||
430 | |||
431 | qlcnic_enable_msi_legacy(adapter); | ||
432 | } | ||
433 | |||
434 | static void | ||
458 | qlcnic_teardown_intr(struct qlcnic_adapter *adapter) | 435 | qlcnic_teardown_intr(struct qlcnic_adapter *adapter) |
459 | { | 436 | { |
460 | if (adapter->flags & QLCNIC_MSIX_ENABLED) | 437 | if (adapter->flags & QLCNIC_MSIX_ENABLED) |
@@ -466,15 +443,15 @@ qlcnic_teardown_intr(struct qlcnic_adapter *adapter) | |||
466 | static void | 443 | static void |
467 | qlcnic_cleanup_pci_map(struct qlcnic_adapter *adapter) | 444 | qlcnic_cleanup_pci_map(struct qlcnic_adapter *adapter) |
468 | { | 445 | { |
469 | if (adapter->ahw.pci_base0 != NULL) | 446 | if (adapter->ahw->pci_base0 != NULL) |
470 | iounmap(adapter->ahw.pci_base0); | 447 | iounmap(adapter->ahw->pci_base0); |
471 | } | 448 | } |
472 | 449 | ||
473 | static int | 450 | static int |
474 | qlcnic_init_pci_info(struct qlcnic_adapter *adapter) | 451 | qlcnic_init_pci_info(struct qlcnic_adapter *adapter) |
475 | { | 452 | { |
476 | struct qlcnic_pci_info *pci_info; | 453 | struct qlcnic_pci_info *pci_info; |
477 | int i, ret = 0, err; | 454 | int i, ret = 0; |
478 | u8 pfn; | 455 | u8 pfn; |
479 | 456 | ||
480 | pci_info = kcalloc(QLCNIC_MAX_PCI_FUNC, sizeof(*pci_info), GFP_KERNEL); | 457 | pci_info = kcalloc(QLCNIC_MAX_PCI_FUNC, sizeof(*pci_info), GFP_KERNEL); |
@@ -484,14 +461,14 @@ qlcnic_init_pci_info(struct qlcnic_adapter *adapter) | |||
484 | adapter->npars = kzalloc(sizeof(struct qlcnic_npar_info) * | 461 | adapter->npars = kzalloc(sizeof(struct qlcnic_npar_info) * |
485 | QLCNIC_MAX_PCI_FUNC, GFP_KERNEL); | 462 | QLCNIC_MAX_PCI_FUNC, GFP_KERNEL); |
486 | if (!adapter->npars) { | 463 | if (!adapter->npars) { |
487 | err = -ENOMEM; | 464 | ret = -ENOMEM; |
488 | goto err_pci_info; | 465 | goto err_pci_info; |
489 | } | 466 | } |
490 | 467 | ||
491 | adapter->eswitch = kzalloc(sizeof(struct qlcnic_eswitch) * | 468 | adapter->eswitch = kzalloc(sizeof(struct qlcnic_eswitch) * |
492 | QLCNIC_NIU_MAX_XG_PORTS, GFP_KERNEL); | 469 | QLCNIC_NIU_MAX_XG_PORTS, GFP_KERNEL); |
493 | if (!adapter->eswitch) { | 470 | if (!adapter->eswitch) { |
494 | err = -ENOMEM; | 471 | ret = -ENOMEM; |
495 | goto err_npars; | 472 | goto err_npars; |
496 | } | 473 | } |
497 | 474 | ||
@@ -501,12 +478,13 @@ qlcnic_init_pci_info(struct qlcnic_adapter *adapter) | |||
501 | 478 | ||
502 | for (i = 0; i < QLCNIC_MAX_PCI_FUNC; i++) { | 479 | for (i = 0; i < QLCNIC_MAX_PCI_FUNC; i++) { |
503 | pfn = pci_info[i].id; | 480 | pfn = pci_info[i].id; |
504 | if (pfn > QLCNIC_MAX_PCI_FUNC) | 481 | if (pfn > QLCNIC_MAX_PCI_FUNC) { |
505 | return QL_STATUS_INVALID_PARAM; | 482 | ret = QL_STATUS_INVALID_PARAM; |
506 | adapter->npars[pfn].active = pci_info[i].active; | 483 | goto err_eswitch; |
507 | adapter->npars[pfn].type = pci_info[i].type; | 484 | } |
508 | adapter->npars[pfn].phy_port = pci_info[i].default_port; | 485 | adapter->npars[pfn].active = (u8)pci_info[i].active; |
509 | adapter->npars[pfn].mac_learning = DEFAULT_MAC_LEARN; | 486 | adapter->npars[pfn].type = (u8)pci_info[i].type; |
487 | adapter->npars[pfn].phy_port = (u8)pci_info[i].default_port; | ||
510 | adapter->npars[pfn].min_bw = pci_info[i].tx_min_bw; | 488 | adapter->npars[pfn].min_bw = pci_info[i].tx_min_bw; |
511 | adapter->npars[pfn].max_bw = pci_info[i].tx_max_bw; | 489 | adapter->npars[pfn].max_bw = pci_info[i].tx_max_bw; |
512 | } | 490 | } |
@@ -536,111 +514,71 @@ qlcnic_set_function_modes(struct qlcnic_adapter *adapter) | |||
536 | u32 ref_count; | 514 | u32 ref_count; |
537 | int i, ret = 1; | 515 | int i, ret = 1; |
538 | u32 data = QLCNIC_MGMT_FUNC; | 516 | u32 data = QLCNIC_MGMT_FUNC; |
539 | void __iomem *priv_op = adapter->ahw.pci_base0 + QLCNIC_DRV_OP_MODE; | 517 | void __iomem *priv_op = adapter->ahw->pci_base0 + QLCNIC_DRV_OP_MODE; |
540 | 518 | ||
541 | /* If other drivers are not in use set their privilege level */ | 519 | /* If other drivers are not in use set their privilege level */ |
542 | ref_count = QLCRD32(adapter, QLCNIC_CRB_DEV_REF_COUNT); | 520 | ref_count = QLCRD32(adapter, QLCNIC_CRB_DRV_ACTIVE); |
543 | ret = qlcnic_api_lock(adapter); | 521 | ret = qlcnic_api_lock(adapter); |
544 | if (ret) | 522 | if (ret) |
545 | goto err_lock; | 523 | goto err_lock; |
546 | if (QLC_DEV_CLR_REF_CNT(ref_count, adapter->ahw.pci_func)) | ||
547 | goto err_npar; | ||
548 | 524 | ||
549 | if (qlcnic_config_npars) { | 525 | if (qlcnic_config_npars) { |
550 | for (i = 0; i < QLCNIC_MAX_PCI_FUNC; i++) { | 526 | for (i = 0; i < QLCNIC_MAX_PCI_FUNC; i++) { |
551 | id = i; | 527 | id = i; |
552 | if (adapter->npars[i].type != QLCNIC_TYPE_NIC || | 528 | if (adapter->npars[i].type != QLCNIC_TYPE_NIC || |
553 | id == adapter->ahw.pci_func) | 529 | id == adapter->ahw->pci_func) |
554 | continue; | 530 | continue; |
555 | data |= (qlcnic_config_npars & | 531 | data |= (qlcnic_config_npars & |
556 | QLC_DEV_SET_DRV(0xf, id)); | 532 | QLC_DEV_SET_DRV(0xf, id)); |
557 | } | 533 | } |
558 | } else { | 534 | } else { |
559 | data = readl(priv_op); | 535 | data = readl(priv_op); |
560 | data = (data & ~QLC_DEV_SET_DRV(0xf, adapter->ahw.pci_func)) | | 536 | data = (data & ~QLC_DEV_SET_DRV(0xf, adapter->ahw->pci_func)) | |
561 | (QLC_DEV_SET_DRV(QLCNIC_MGMT_FUNC, | 537 | (QLC_DEV_SET_DRV(QLCNIC_MGMT_FUNC, |
562 | adapter->ahw.pci_func)); | 538 | adapter->ahw->pci_func)); |
563 | } | 539 | } |
564 | writel(data, priv_op); | 540 | writel(data, priv_op); |
565 | err_npar: | ||
566 | qlcnic_api_unlock(adapter); | 541 | qlcnic_api_unlock(adapter); |
567 | err_lock: | 542 | err_lock: |
568 | return ret; | 543 | return ret; |
569 | } | 544 | } |
570 | 545 | ||
571 | static u32 | 546 | static void |
572 | qlcnic_get_driver_mode(struct qlcnic_adapter *adapter) | 547 | qlcnic_check_vf(struct qlcnic_adapter *adapter) |
573 | { | 548 | { |
574 | void __iomem *msix_base_addr; | 549 | void __iomem *msix_base_addr; |
575 | void __iomem *priv_op; | 550 | void __iomem *priv_op; |
576 | struct qlcnic_info nic_info; | ||
577 | u32 func; | 551 | u32 func; |
578 | u32 msix_base; | 552 | u32 msix_base; |
579 | u32 op_mode, priv_level; | 553 | u32 op_mode, priv_level; |
580 | 554 | ||
581 | /* Determine FW API version */ | 555 | /* Determine FW API version */ |
582 | adapter->fw_hal_version = readl(adapter->ahw.pci_base0 + QLCNIC_FW_API); | 556 | adapter->fw_hal_version = readl(adapter->ahw->pci_base0 + |
557 | QLCNIC_FW_API); | ||
583 | 558 | ||
584 | /* Find PCI function number */ | 559 | /* Find PCI function number */ |
585 | pci_read_config_dword(adapter->pdev, QLCNIC_MSIX_TABLE_OFFSET, &func); | 560 | pci_read_config_dword(adapter->pdev, QLCNIC_MSIX_TABLE_OFFSET, &func); |
586 | msix_base_addr = adapter->ahw.pci_base0 + QLCNIC_MSIX_BASE; | 561 | msix_base_addr = adapter->ahw->pci_base0 + QLCNIC_MSIX_BASE; |
587 | msix_base = readl(msix_base_addr); | 562 | msix_base = readl(msix_base_addr); |
588 | func = (func - msix_base)/QLCNIC_MSIX_TBL_PGSIZE; | 563 | func = (func - msix_base)/QLCNIC_MSIX_TBL_PGSIZE; |
589 | adapter->ahw.pci_func = func; | 564 | adapter->ahw->pci_func = func; |
590 | |||
591 | if (!qlcnic_get_nic_info(adapter, &nic_info, adapter->ahw.pci_func)) { | ||
592 | adapter->capabilities = nic_info.capabilities; | ||
593 | |||
594 | if (adapter->capabilities & BIT_6) | ||
595 | adapter->flags |= QLCNIC_ESWITCH_ENABLED; | ||
596 | else | ||
597 | adapter->flags &= ~QLCNIC_ESWITCH_ENABLED; | ||
598 | } | ||
599 | |||
600 | if (!(adapter->flags & QLCNIC_ESWITCH_ENABLED)) { | ||
601 | adapter->nic_ops = &qlcnic_ops; | ||
602 | return adapter->fw_hal_version; | ||
603 | } | ||
604 | 565 | ||
605 | /* Determine function privilege level */ | 566 | /* Determine function privilege level */ |
606 | priv_op = adapter->ahw.pci_base0 + QLCNIC_DRV_OP_MODE; | 567 | priv_op = adapter->ahw->pci_base0 + QLCNIC_DRV_OP_MODE; |
607 | op_mode = readl(priv_op); | 568 | op_mode = readl(priv_op); |
608 | if (op_mode == QLC_DEV_DRV_DEFAULT) | 569 | if (op_mode == QLC_DEV_DRV_DEFAULT) |
609 | priv_level = QLCNIC_MGMT_FUNC; | 570 | priv_level = QLCNIC_MGMT_FUNC; |
610 | else | 571 | else |
611 | priv_level = QLC_DEV_GET_DRV(op_mode, adapter->ahw.pci_func); | 572 | priv_level = QLC_DEV_GET_DRV(op_mode, adapter->ahw->pci_func); |
612 | 573 | ||
613 | switch (priv_level) { | 574 | if (priv_level == QLCNIC_NON_PRIV_FUNC) { |
614 | case QLCNIC_MGMT_FUNC: | ||
615 | adapter->op_mode = QLCNIC_MGMT_FUNC; | ||
616 | adapter->nic_ops = &qlcnic_ops; | ||
617 | qlcnic_init_pci_info(adapter); | ||
618 | /* Set privilege level for other functions */ | ||
619 | qlcnic_set_function_modes(adapter); | ||
620 | dev_info(&adapter->pdev->dev, | ||
621 | "HAL Version: %d, Management function\n", | ||
622 | adapter->fw_hal_version); | ||
623 | break; | ||
624 | case QLCNIC_PRIV_FUNC: | ||
625 | adapter->op_mode = QLCNIC_PRIV_FUNC; | ||
626 | dev_info(&adapter->pdev->dev, | ||
627 | "HAL Version: %d, Privileged function\n", | ||
628 | adapter->fw_hal_version); | ||
629 | adapter->nic_ops = &qlcnic_ops; | ||
630 | break; | ||
631 | case QLCNIC_NON_PRIV_FUNC: | ||
632 | adapter->op_mode = QLCNIC_NON_PRIV_FUNC; | 575 | adapter->op_mode = QLCNIC_NON_PRIV_FUNC; |
633 | dev_info(&adapter->pdev->dev, | 576 | dev_info(&adapter->pdev->dev, |
634 | "HAL Version: %d Non Privileged function\n", | 577 | "HAL Version: %d Non Privileged function\n", |
635 | adapter->fw_hal_version); | 578 | adapter->fw_hal_version); |
636 | adapter->nic_ops = &qlcnic_vf_ops; | 579 | adapter->nic_ops = &qlcnic_vf_ops; |
637 | break; | 580 | } else |
638 | default: | 581 | adapter->nic_ops = &qlcnic_ops; |
639 | dev_info(&adapter->pdev->dev, "Unknown function mode: %d\n", | ||
640 | priv_level); | ||
641 | return 0; | ||
642 | } | ||
643 | return adapter->fw_hal_version; | ||
644 | } | 582 | } |
645 | 583 | ||
646 | static int | 584 | static int |
@@ -670,16 +608,14 @@ qlcnic_setup_pci_map(struct qlcnic_adapter *adapter) | |||
670 | 608 | ||
671 | dev_info(&pdev->dev, "%dMB memory map\n", (int)(mem_len>>20)); | 609 | dev_info(&pdev->dev, "%dMB memory map\n", (int)(mem_len>>20)); |
672 | 610 | ||
673 | adapter->ahw.pci_base0 = mem_ptr0; | 611 | adapter->ahw->pci_base0 = mem_ptr0; |
674 | adapter->ahw.pci_len0 = pci_len0; | 612 | adapter->ahw->pci_len0 = pci_len0; |
675 | 613 | ||
676 | if (!qlcnic_get_driver_mode(adapter)) { | 614 | qlcnic_check_vf(adapter); |
677 | iounmap(adapter->ahw.pci_base0); | ||
678 | return -EIO; | ||
679 | } | ||
680 | 615 | ||
681 | adapter->ahw.ocm_win_crb = qlcnic_get_ioaddr(adapter, | 616 | adapter->ahw->ocm_win_crb = qlcnic_get_ioaddr(adapter, |
682 | QLCNIC_PCIX_PS_REG(PCIX_OCM_WINDOW_REG(adapter->ahw.pci_func))); | 617 | QLCNIC_PCIX_PS_REG(PCIX_OCM_WINDOW_REG( |
618 | adapter->ahw->pci_func))); | ||
683 | 619 | ||
684 | return 0; | 620 | return 0; |
685 | } | 621 | } |
@@ -711,25 +647,7 @@ static void | |||
711 | qlcnic_check_options(struct qlcnic_adapter *adapter) | 647 | qlcnic_check_options(struct qlcnic_adapter *adapter) |
712 | { | 648 | { |
713 | u32 fw_major, fw_minor, fw_build; | 649 | u32 fw_major, fw_minor, fw_build; |
714 | char brd_name[QLCNIC_MAX_BOARD_NAME_LEN]; | ||
715 | char serial_num[32]; | ||
716 | int i, offset, val; | ||
717 | int *ptr32; | ||
718 | struct pci_dev *pdev = adapter->pdev; | 650 | struct pci_dev *pdev = adapter->pdev; |
719 | struct qlcnic_info nic_info; | ||
720 | adapter->driver_mismatch = 0; | ||
721 | |||
722 | ptr32 = (int *)&serial_num; | ||
723 | offset = QLCNIC_FW_SERIAL_NUM_OFFSET; | ||
724 | for (i = 0; i < 8; i++) { | ||
725 | if (qlcnic_rom_fast_read(adapter, offset, &val) == -1) { | ||
726 | dev_err(&pdev->dev, "error reading board info\n"); | ||
727 | adapter->driver_mismatch = 1; | ||
728 | return; | ||
729 | } | ||
730 | ptr32[i] = cpu_to_le32(val); | ||
731 | offset += sizeof(u32); | ||
732 | } | ||
733 | 651 | ||
734 | fw_major = QLCRD32(adapter, QLCNIC_FW_VERSION_MAJOR); | 652 | fw_major = QLCRD32(adapter, QLCNIC_FW_VERSION_MAJOR); |
735 | fw_minor = QLCRD32(adapter, QLCNIC_FW_VERSION_MINOR); | 653 | fw_minor = QLCRD32(adapter, QLCNIC_FW_VERSION_MINOR); |
@@ -737,157 +655,399 @@ qlcnic_check_options(struct qlcnic_adapter *adapter) | |||
737 | 655 | ||
738 | adapter->fw_version = QLCNIC_VERSION_CODE(fw_major, fw_minor, fw_build); | 656 | adapter->fw_version = QLCNIC_VERSION_CODE(fw_major, fw_minor, fw_build); |
739 | 657 | ||
740 | if (adapter->portnum == 0) { | ||
741 | get_brd_name(adapter, brd_name); | ||
742 | |||
743 | pr_info("%s: %s Board Chip rev 0x%x\n", | ||
744 | module_name(THIS_MODULE), | ||
745 | brd_name, adapter->ahw.revision_id); | ||
746 | } | ||
747 | |||
748 | dev_info(&pdev->dev, "firmware v%d.%d.%d\n", | 658 | dev_info(&pdev->dev, "firmware v%d.%d.%d\n", |
749 | fw_major, fw_minor, fw_build); | 659 | fw_major, fw_minor, fw_build); |
660 | if (adapter->ahw->port_type == QLCNIC_XGBE) { | ||
661 | if (adapter->flags & QLCNIC_ESWITCH_ENABLED) { | ||
662 | adapter->num_rxd = DEFAULT_RCV_DESCRIPTORS_VF; | ||
663 | adapter->max_rxd = MAX_RCV_DESCRIPTORS_VF; | ||
664 | } else { | ||
665 | adapter->num_rxd = DEFAULT_RCV_DESCRIPTORS_10G; | ||
666 | adapter->max_rxd = MAX_RCV_DESCRIPTORS_10G; | ||
667 | } | ||
750 | 668 | ||
751 | adapter->flags &= ~QLCNIC_LRO_ENABLED; | ||
752 | |||
753 | if (adapter->ahw.port_type == QLCNIC_XGBE) { | ||
754 | adapter->num_rxd = DEFAULT_RCV_DESCRIPTORS_10G; | ||
755 | adapter->num_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS_10G; | 669 | adapter->num_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS_10G; |
756 | } else if (adapter->ahw.port_type == QLCNIC_GBE) { | 670 | adapter->max_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS_10G; |
671 | |||
672 | } else if (adapter->ahw->port_type == QLCNIC_GBE) { | ||
757 | adapter->num_rxd = DEFAULT_RCV_DESCRIPTORS_1G; | 673 | adapter->num_rxd = DEFAULT_RCV_DESCRIPTORS_1G; |
758 | adapter->num_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS_1G; | 674 | adapter->num_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS_1G; |
759 | } | 675 | adapter->max_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS_1G; |
760 | 676 | adapter->max_rxd = MAX_RCV_DESCRIPTORS_1G; | |
761 | if (!qlcnic_get_nic_info(adapter, &nic_info, adapter->ahw.pci_func)) { | ||
762 | adapter->physical_port = nic_info.phys_port; | ||
763 | adapter->switch_mode = nic_info.switch_mode; | ||
764 | adapter->max_tx_ques = nic_info.max_tx_ques; | ||
765 | adapter->max_rx_ques = nic_info.max_rx_ques; | ||
766 | adapter->capabilities = nic_info.capabilities; | ||
767 | adapter->max_mac_filters = nic_info.max_mac_filters; | ||
768 | adapter->max_mtu = nic_info.max_mtu; | ||
769 | } | 677 | } |
770 | 678 | ||
771 | adapter->msix_supported = !!use_msi_x; | 679 | adapter->msix_supported = !!use_msi_x; |
772 | adapter->rss_supported = !!use_msi_x; | ||
773 | 680 | ||
774 | adapter->num_txd = MAX_CMD_DESCRIPTORS; | 681 | adapter->num_txd = MAX_CMD_DESCRIPTORS; |
775 | 682 | ||
776 | adapter->max_rds_rings = 2; | 683 | adapter->max_rds_rings = MAX_RDS_RINGS; |
684 | } | ||
685 | |||
686 | static int | ||
687 | qlcnic_initialize_nic(struct qlcnic_adapter *adapter) | ||
688 | { | ||
689 | int err; | ||
690 | struct qlcnic_info nic_info; | ||
691 | |||
692 | err = qlcnic_get_nic_info(adapter, &nic_info, adapter->ahw->pci_func); | ||
693 | if (err) | ||
694 | return err; | ||
695 | |||
696 | adapter->physical_port = (u8)nic_info.phys_port; | ||
697 | adapter->switch_mode = nic_info.switch_mode; | ||
698 | adapter->max_tx_ques = nic_info.max_tx_ques; | ||
699 | adapter->max_rx_ques = nic_info.max_rx_ques; | ||
700 | adapter->capabilities = nic_info.capabilities; | ||
701 | adapter->max_mac_filters = nic_info.max_mac_filters; | ||
702 | adapter->max_mtu = nic_info.max_mtu; | ||
703 | |||
704 | if (adapter->capabilities & BIT_6) | ||
705 | adapter->flags |= QLCNIC_ESWITCH_ENABLED; | ||
706 | else | ||
707 | adapter->flags &= ~QLCNIC_ESWITCH_ENABLED; | ||
708 | |||
709 | return err; | ||
710 | } | ||
711 | |||
712 | static void | ||
713 | qlcnic_set_vlan_config(struct qlcnic_adapter *adapter, | ||
714 | struct qlcnic_esw_func_cfg *esw_cfg) | ||
715 | { | ||
716 | if (esw_cfg->discard_tagged) | ||
717 | adapter->flags &= ~QLCNIC_TAGGING_ENABLED; | ||
718 | else | ||
719 | adapter->flags |= QLCNIC_TAGGING_ENABLED; | ||
720 | |||
721 | if (esw_cfg->vlan_id) | ||
722 | adapter->pvid = esw_cfg->vlan_id; | ||
723 | else | ||
724 | adapter->pvid = 0; | ||
725 | } | ||
726 | |||
727 | static void | ||
728 | qlcnic_vlan_rx_add(struct net_device *netdev, u16 vid) | ||
729 | { | ||
730 | struct qlcnic_adapter *adapter = netdev_priv(netdev); | ||
731 | set_bit(vid, adapter->vlans); | ||
732 | } | ||
733 | |||
734 | static void | ||
735 | qlcnic_vlan_rx_del(struct net_device *netdev, u16 vid) | ||
736 | { | ||
737 | struct qlcnic_adapter *adapter = netdev_priv(netdev); | ||
738 | |||
739 | qlcnic_restore_indev_addr(netdev, NETDEV_DOWN); | ||
740 | clear_bit(vid, adapter->vlans); | ||
741 | } | ||
742 | |||
743 | static void | ||
744 | qlcnic_set_eswitch_port_features(struct qlcnic_adapter *adapter, | ||
745 | struct qlcnic_esw_func_cfg *esw_cfg) | ||
746 | { | ||
747 | adapter->flags &= ~(QLCNIC_MACSPOOF | QLCNIC_MAC_OVERRIDE_DISABLED | | ||
748 | QLCNIC_PROMISC_DISABLED); | ||
749 | |||
750 | if (esw_cfg->mac_anti_spoof) | ||
751 | adapter->flags |= QLCNIC_MACSPOOF; | ||
752 | |||
753 | if (!esw_cfg->mac_override) | ||
754 | adapter->flags |= QLCNIC_MAC_OVERRIDE_DISABLED; | ||
755 | |||
756 | if (!esw_cfg->promisc_mode) | ||
757 | adapter->flags |= QLCNIC_PROMISC_DISABLED; | ||
758 | |||
759 | qlcnic_set_netdev_features(adapter, esw_cfg); | ||
760 | } | ||
761 | |||
762 | static int | ||
763 | qlcnic_set_eswitch_port_config(struct qlcnic_adapter *adapter) | ||
764 | { | ||
765 | struct qlcnic_esw_func_cfg esw_cfg; | ||
766 | |||
767 | if (!(adapter->flags & QLCNIC_ESWITCH_ENABLED)) | ||
768 | return 0; | ||
769 | |||
770 | esw_cfg.pci_func = adapter->ahw->pci_func; | ||
771 | if (qlcnic_get_eswitch_port_config(adapter, &esw_cfg)) | ||
772 | return -EIO; | ||
773 | qlcnic_set_vlan_config(adapter, &esw_cfg); | ||
774 | qlcnic_set_eswitch_port_features(adapter, &esw_cfg); | ||
775 | |||
776 | return 0; | ||
777 | } | ||
778 | |||
779 | static void | ||
780 | qlcnic_set_netdev_features(struct qlcnic_adapter *adapter, | ||
781 | struct qlcnic_esw_func_cfg *esw_cfg) | ||
782 | { | ||
783 | struct net_device *netdev = adapter->netdev; | ||
784 | unsigned long features, vlan_features; | ||
785 | |||
786 | features = (NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_RXCSUM | | ||
787 | NETIF_F_IPV6_CSUM | NETIF_F_GRO); | ||
788 | vlan_features = (NETIF_F_SG | NETIF_F_IP_CSUM | | ||
789 | NETIF_F_IPV6_CSUM | NETIF_F_HW_VLAN_FILTER); | ||
790 | |||
791 | if (adapter->capabilities & QLCNIC_FW_CAPABILITY_TSO) { | ||
792 | features |= (NETIF_F_TSO | NETIF_F_TSO6); | ||
793 | vlan_features |= (NETIF_F_TSO | NETIF_F_TSO6); | ||
794 | } | ||
795 | |||
796 | if (netdev->features & NETIF_F_LRO) | ||
797 | features |= NETIF_F_LRO; | ||
798 | |||
799 | if (esw_cfg->offload_flags & BIT_0) { | ||
800 | netdev->features |= features; | ||
801 | if (!(esw_cfg->offload_flags & BIT_1)) | ||
802 | netdev->features &= ~NETIF_F_TSO; | ||
803 | if (!(esw_cfg->offload_flags & BIT_2)) | ||
804 | netdev->features &= ~NETIF_F_TSO6; | ||
805 | } else { | ||
806 | netdev->features &= ~features; | ||
807 | } | ||
808 | |||
809 | netdev->vlan_features = (features & vlan_features); | ||
810 | } | ||
811 | |||
812 | static int | ||
813 | qlcnic_check_eswitch_mode(struct qlcnic_adapter *adapter) | ||
814 | { | ||
815 | void __iomem *priv_op; | ||
816 | u32 op_mode, priv_level; | ||
817 | int err = 0; | ||
818 | |||
819 | err = qlcnic_initialize_nic(adapter); | ||
820 | if (err) | ||
821 | return err; | ||
822 | |||
823 | if (adapter->flags & QLCNIC_ADAPTER_INITIALIZED) | ||
824 | return 0; | ||
825 | |||
826 | priv_op = adapter->ahw->pci_base0 + QLCNIC_DRV_OP_MODE; | ||
827 | op_mode = readl(priv_op); | ||
828 | priv_level = QLC_DEV_GET_DRV(op_mode, adapter->ahw->pci_func); | ||
829 | |||
830 | if (op_mode == QLC_DEV_DRV_DEFAULT) | ||
831 | priv_level = QLCNIC_MGMT_FUNC; | ||
832 | else | ||
833 | priv_level = QLC_DEV_GET_DRV(op_mode, adapter->ahw->pci_func); | ||
834 | |||
835 | if (adapter->flags & QLCNIC_ESWITCH_ENABLED) { | ||
836 | if (priv_level == QLCNIC_MGMT_FUNC) { | ||
837 | adapter->op_mode = QLCNIC_MGMT_FUNC; | ||
838 | err = qlcnic_init_pci_info(adapter); | ||
839 | if (err) | ||
840 | return err; | ||
841 | /* Set privilege level for other functions */ | ||
842 | qlcnic_set_function_modes(adapter); | ||
843 | dev_info(&adapter->pdev->dev, | ||
844 | "HAL Version: %d, Management function\n", | ||
845 | adapter->fw_hal_version); | ||
846 | } else if (priv_level == QLCNIC_PRIV_FUNC) { | ||
847 | adapter->op_mode = QLCNIC_PRIV_FUNC; | ||
848 | dev_info(&adapter->pdev->dev, | ||
849 | "HAL Version: %d, Privileged function\n", | ||
850 | adapter->fw_hal_version); | ||
851 | } | ||
852 | } | ||
853 | |||
854 | adapter->flags |= QLCNIC_ADAPTER_INITIALIZED; | ||
855 | |||
856 | return err; | ||
857 | } | ||
858 | |||
859 | static int | ||
860 | qlcnic_set_default_offload_settings(struct qlcnic_adapter *adapter) | ||
861 | { | ||
862 | struct qlcnic_esw_func_cfg esw_cfg; | ||
863 | struct qlcnic_npar_info *npar; | ||
864 | u8 i; | ||
865 | |||
866 | if (adapter->need_fw_reset) | ||
867 | return 0; | ||
868 | |||
869 | for (i = 0; i < QLCNIC_MAX_PCI_FUNC; i++) { | ||
870 | if (adapter->npars[i].type != QLCNIC_TYPE_NIC) | ||
871 | continue; | ||
872 | memset(&esw_cfg, 0, sizeof(struct qlcnic_esw_func_cfg)); | ||
873 | esw_cfg.pci_func = i; | ||
874 | esw_cfg.offload_flags = BIT_0; | ||
875 | esw_cfg.mac_override = BIT_0; | ||
876 | esw_cfg.promisc_mode = BIT_0; | ||
877 | if (adapter->capabilities & QLCNIC_FW_CAPABILITY_TSO) | ||
878 | esw_cfg.offload_flags |= (BIT_1 | BIT_2); | ||
879 | if (qlcnic_config_switch_port(adapter, &esw_cfg)) | ||
880 | return -EIO; | ||
881 | npar = &adapter->npars[i]; | ||
882 | npar->pvid = esw_cfg.vlan_id; | ||
883 | npar->mac_override = esw_cfg.mac_override; | ||
884 | npar->mac_anti_spoof = esw_cfg.mac_anti_spoof; | ||
885 | npar->discard_tagged = esw_cfg.discard_tagged; | ||
886 | npar->promisc_mode = esw_cfg.promisc_mode; | ||
887 | npar->offload_flags = esw_cfg.offload_flags; | ||
888 | } | ||
889 | |||
890 | return 0; | ||
891 | } | ||
892 | |||
893 | static int | ||
894 | qlcnic_reset_eswitch_config(struct qlcnic_adapter *adapter, | ||
895 | struct qlcnic_npar_info *npar, int pci_func) | ||
896 | { | ||
897 | struct qlcnic_esw_func_cfg esw_cfg; | ||
898 | esw_cfg.op_mode = QLCNIC_PORT_DEFAULTS; | ||
899 | esw_cfg.pci_func = pci_func; | ||
900 | esw_cfg.vlan_id = npar->pvid; | ||
901 | esw_cfg.mac_override = npar->mac_override; | ||
902 | esw_cfg.discard_tagged = npar->discard_tagged; | ||
903 | esw_cfg.mac_anti_spoof = npar->mac_anti_spoof; | ||
904 | esw_cfg.offload_flags = npar->offload_flags; | ||
905 | esw_cfg.promisc_mode = npar->promisc_mode; | ||
906 | if (qlcnic_config_switch_port(adapter, &esw_cfg)) | ||
907 | return -EIO; | ||
908 | |||
909 | esw_cfg.op_mode = QLCNIC_ADD_VLAN; | ||
910 | if (qlcnic_config_switch_port(adapter, &esw_cfg)) | ||
911 | return -EIO; | ||
912 | |||
913 | return 0; | ||
777 | } | 914 | } |
778 | 915 | ||
779 | static int | 916 | static int |
780 | qlcnic_reset_npar_config(struct qlcnic_adapter *adapter) | 917 | qlcnic_reset_npar_config(struct qlcnic_adapter *adapter) |
781 | { | 918 | { |
782 | int i, err = 0; | 919 | int i, err; |
783 | struct qlcnic_npar_info *npar; | 920 | struct qlcnic_npar_info *npar; |
784 | struct qlcnic_info nic_info; | 921 | struct qlcnic_info nic_info; |
785 | 922 | ||
786 | if (!(adapter->flags & QLCNIC_ESWITCH_ENABLED) || | 923 | if (!adapter->need_fw_reset) |
787 | !adapter->need_fw_reset) | ||
788 | return 0; | 924 | return 0; |
789 | 925 | ||
790 | if (adapter->op_mode == QLCNIC_MGMT_FUNC) { | 926 | /* Set the NPAR config data after FW reset */ |
791 | /* Set the NPAR config data after FW reset */ | 927 | for (i = 0; i < QLCNIC_MAX_PCI_FUNC; i++) { |
792 | for (i = 0; i < QLCNIC_MAX_PCI_FUNC; i++) { | 928 | npar = &adapter->npars[i]; |
793 | npar = &adapter->npars[i]; | 929 | if (npar->type != QLCNIC_TYPE_NIC) |
794 | if (npar->type != QLCNIC_TYPE_NIC) | 930 | continue; |
795 | continue; | 931 | err = qlcnic_get_nic_info(adapter, &nic_info, i); |
796 | err = qlcnic_get_nic_info(adapter, &nic_info, i); | 932 | if (err) |
797 | if (err) | 933 | return err; |
798 | goto err_out; | 934 | nic_info.min_tx_bw = npar->min_bw; |
799 | nic_info.min_tx_bw = npar->min_bw; | 935 | nic_info.max_tx_bw = npar->max_bw; |
800 | nic_info.max_tx_bw = npar->max_bw; | 936 | err = qlcnic_set_nic_info(adapter, &nic_info); |
801 | err = qlcnic_set_nic_info(adapter, &nic_info); | 937 | if (err) |
938 | return err; | ||
939 | |||
940 | if (npar->enable_pm) { | ||
941 | err = qlcnic_config_port_mirroring(adapter, | ||
942 | npar->dest_npar, 1, i); | ||
802 | if (err) | 943 | if (err) |
803 | goto err_out; | 944 | return err; |
945 | } | ||
946 | err = qlcnic_reset_eswitch_config(adapter, npar, i); | ||
947 | if (err) | ||
948 | return err; | ||
949 | } | ||
950 | return 0; | ||
951 | } | ||
804 | 952 | ||
805 | if (npar->enable_pm) { | 953 | static int qlcnic_check_npar_opertional(struct qlcnic_adapter *adapter) |
806 | err = qlcnic_config_port_mirroring(adapter, | 954 | { |
807 | npar->dest_npar, 1, i); | 955 | u8 npar_opt_timeo = QLCNIC_DEV_NPAR_OPER_TIMEO; |
808 | if (err) | 956 | u32 npar_state; |
809 | goto err_out; | ||
810 | 957 | ||
811 | } | 958 | if (adapter->op_mode == QLCNIC_MGMT_FUNC) |
812 | npar->mac_learning = DEFAULT_MAC_LEARN; | 959 | return 0; |
813 | npar->host_vlan_tag = 0; | 960 | |
814 | npar->promisc_mode = 0; | 961 | npar_state = QLCRD32(adapter, QLCNIC_CRB_DEV_NPAR_STATE); |
815 | npar->discard_tagged = 0; | 962 | while (npar_state != QLCNIC_DEV_NPAR_OPER && --npar_opt_timeo) { |
816 | npar->vlan_id = 0; | 963 | msleep(1000); |
817 | } | 964 | npar_state = QLCRD32(adapter, QLCNIC_CRB_DEV_NPAR_STATE); |
818 | } | 965 | } |
819 | err_out: | 966 | if (!npar_opt_timeo) { |
967 | dev_err(&adapter->pdev->dev, | ||
968 | "Waiting for NPAR state to opertional timeout\n"); | ||
969 | return -EIO; | ||
970 | } | ||
971 | return 0; | ||
972 | } | ||
973 | |||
974 | static int | ||
975 | qlcnic_set_mgmt_operations(struct qlcnic_adapter *adapter) | ||
976 | { | ||
977 | int err; | ||
978 | |||
979 | if (!(adapter->flags & QLCNIC_ESWITCH_ENABLED) || | ||
980 | adapter->op_mode != QLCNIC_MGMT_FUNC) | ||
981 | return 0; | ||
982 | |||
983 | err = qlcnic_set_default_offload_settings(adapter); | ||
984 | if (err) | ||
985 | return err; | ||
986 | |||
987 | err = qlcnic_reset_npar_config(adapter); | ||
988 | if (err) | ||
989 | return err; | ||
990 | |||
991 | qlcnic_dev_set_npar_ready(adapter); | ||
992 | |||
820 | return err; | 993 | return err; |
821 | } | 994 | } |
822 | 995 | ||
823 | static int | 996 | static int |
824 | qlcnic_start_firmware(struct qlcnic_adapter *adapter) | 997 | qlcnic_start_firmware(struct qlcnic_adapter *adapter) |
825 | { | 998 | { |
826 | int val, err, first_boot; | 999 | int err; |
827 | 1000 | ||
828 | err = qlcnic_can_start_firmware(adapter); | 1001 | err = qlcnic_can_start_firmware(adapter); |
829 | if (err < 0) | 1002 | if (err < 0) |
830 | return err; | 1003 | return err; |
831 | else if (!err) | 1004 | else if (!err) |
832 | goto wait_init; | 1005 | goto check_fw_status; |
833 | |||
834 | first_boot = QLCRD32(adapter, QLCNIC_CAM_RAM(0x1fc)); | ||
835 | if (first_boot == 0x55555555) | ||
836 | /* This is the first boot after power up */ | ||
837 | QLCWR32(adapter, QLCNIC_CAM_RAM(0x1fc), QLCNIC_BDINFO_MAGIC); | ||
838 | 1006 | ||
839 | if (load_fw_file) | 1007 | if (load_fw_file) |
840 | qlcnic_request_firmware(adapter); | 1008 | qlcnic_request_firmware(adapter); |
841 | else { | 1009 | else { |
842 | if (qlcnic_check_flash_fw_ver(adapter)) | 1010 | err = qlcnic_check_flash_fw_ver(adapter); |
1011 | if (err) | ||
843 | goto err_out; | 1012 | goto err_out; |
844 | 1013 | ||
845 | adapter->fw_type = QLCNIC_FLASH_ROMIMAGE; | 1014 | adapter->fw_type = QLCNIC_FLASH_ROMIMAGE; |
846 | } | 1015 | } |
847 | 1016 | ||
848 | err = qlcnic_need_fw_reset(adapter); | 1017 | err = qlcnic_need_fw_reset(adapter); |
849 | if (err < 0) | ||
850 | goto err_out; | ||
851 | if (err == 0) | 1018 | if (err == 0) |
852 | goto wait_init; | 1019 | goto check_fw_status; |
853 | |||
854 | if (first_boot != 0x55555555) { | ||
855 | QLCWR32(adapter, CRB_CMDPEG_STATE, 0); | ||
856 | QLCWR32(adapter, CRB_RCVPEG_STATE, 0); | ||
857 | qlcnic_pinit_from_rom(adapter); | ||
858 | msleep(1); | ||
859 | } | ||
860 | 1020 | ||
861 | QLCWR32(adapter, QLCNIC_PEG_HALT_STATUS1, 0); | 1021 | err = qlcnic_pinit_from_rom(adapter); |
862 | QLCWR32(adapter, QLCNIC_PEG_HALT_STATUS2, 0); | 1022 | if (err) |
863 | 1023 | goto err_out; | |
864 | qlcnic_set_port_mode(adapter); | ||
865 | 1024 | ||
866 | err = qlcnic_load_firmware(adapter); | 1025 | err = qlcnic_load_firmware(adapter); |
867 | if (err) | 1026 | if (err) |
868 | goto err_out; | 1027 | goto err_out; |
869 | 1028 | ||
870 | qlcnic_release_firmware(adapter); | 1029 | qlcnic_release_firmware(adapter); |
1030 | QLCWR32(adapter, CRB_DRIVER_VERSION, QLCNIC_DRIVER_VERSION); | ||
871 | 1031 | ||
872 | val = (_QLCNIC_LINUX_MAJOR << 16) | 1032 | check_fw_status: |
873 | | ((_QLCNIC_LINUX_MINOR << 8)) | 1033 | err = qlcnic_check_fw_status(adapter); |
874 | | (_QLCNIC_LINUX_SUBVERSION); | ||
875 | QLCWR32(adapter, CRB_DRIVER_VERSION, val); | ||
876 | |||
877 | wait_init: | ||
878 | /* Handshake with the card before we register the devices. */ | ||
879 | err = qlcnic_init_firmware(adapter); | ||
880 | if (err) | 1034 | if (err) |
881 | goto err_out; | 1035 | goto err_out; |
882 | 1036 | ||
883 | QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_READY); | 1037 | QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_READY); |
884 | qlcnic_idc_debug_info(adapter, 1); | 1038 | qlcnic_idc_debug_info(adapter, 1); |
885 | 1039 | ||
886 | qlcnic_check_options(adapter); | 1040 | err = qlcnic_check_eswitch_mode(adapter); |
887 | if (qlcnic_reset_npar_config(adapter)) | 1041 | if (err) { |
1042 | dev_err(&adapter->pdev->dev, | ||
1043 | "Memory allocation failed for eswitch\n"); | ||
1044 | goto err_out; | ||
1045 | } | ||
1046 | err = qlcnic_set_mgmt_operations(adapter); | ||
1047 | if (err) | ||
888 | goto err_out; | 1048 | goto err_out; |
889 | qlcnic_dev_set_npar_ready(adapter); | ||
890 | 1049 | ||
1050 | qlcnic_check_options(adapter); | ||
891 | adapter->need_fw_reset = 0; | 1051 | adapter->need_fw_reset = 0; |
892 | 1052 | ||
893 | qlcnic_release_firmware(adapter); | 1053 | qlcnic_release_firmware(adapter); |
@@ -896,6 +1056,7 @@ wait_init: | |||
896 | err_out: | 1056 | err_out: |
897 | QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_FAILED); | 1057 | QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_FAILED); |
898 | dev_err(&adapter->pdev->dev, "Device state set to failed\n"); | 1058 | dev_err(&adapter->pdev->dev, "Device state set to failed\n"); |
1059 | |||
899 | qlcnic_release_firmware(adapter); | 1060 | qlcnic_release_firmware(adapter); |
900 | return err; | 1061 | return err; |
901 | } | 1062 | } |
@@ -909,7 +1070,7 @@ qlcnic_request_irq(struct qlcnic_adapter *adapter) | |||
909 | 1070 | ||
910 | unsigned long flags = 0; | 1071 | unsigned long flags = 0; |
911 | struct net_device *netdev = adapter->netdev; | 1072 | struct net_device *netdev = adapter->netdev; |
912 | struct qlcnic_recv_context *recv_ctx = &adapter->recv_ctx; | 1073 | struct qlcnic_recv_context *recv_ctx = adapter->recv_ctx; |
913 | 1074 | ||
914 | if (adapter->diag_test == QLCNIC_INTERRUPT_TEST) { | 1075 | if (adapter->diag_test == QLCNIC_INTERRUPT_TEST) { |
915 | handler = qlcnic_tmp_intr; | 1076 | handler = qlcnic_tmp_intr; |
@@ -946,7 +1107,7 @@ qlcnic_free_irq(struct qlcnic_adapter *adapter) | |||
946 | int ring; | 1107 | int ring; |
947 | struct qlcnic_host_sds_ring *sds_ring; | 1108 | struct qlcnic_host_sds_ring *sds_ring; |
948 | 1109 | ||
949 | struct qlcnic_recv_context *recv_ctx = &adapter->recv_ctx; | 1110 | struct qlcnic_recv_context *recv_ctx = adapter->recv_ctx; |
950 | 1111 | ||
951 | for (ring = 0; ring < adapter->max_sds_rings; ring++) { | 1112 | for (ring = 0; ring < adapter->max_sds_rings; ring++) { |
952 | sds_ring = &recv_ctx->sds_rings[ring]; | 1113 | sds_ring = &recv_ctx->sds_rings[ring]; |
@@ -954,20 +1115,6 @@ qlcnic_free_irq(struct qlcnic_adapter *adapter) | |||
954 | } | 1115 | } |
955 | } | 1116 | } |
956 | 1117 | ||
957 | static void | ||
958 | qlcnic_init_coalesce_defaults(struct qlcnic_adapter *adapter) | ||
959 | { | ||
960 | adapter->coal.flags = QLCNIC_INTR_DEFAULT; | ||
961 | adapter->coal.normal.data.rx_time_us = | ||
962 | QLCNIC_DEFAULT_INTR_COALESCE_RX_TIME_US; | ||
963 | adapter->coal.normal.data.rx_packets = | ||
964 | QLCNIC_DEFAULT_INTR_COALESCE_RX_PACKETS; | ||
965 | adapter->coal.normal.data.tx_time_us = | ||
966 | QLCNIC_DEFAULT_INTR_COALESCE_TX_TIME_US; | ||
967 | adapter->coal.normal.data.tx_packets = | ||
968 | QLCNIC_DEFAULT_INTR_COALESCE_TX_PACKETS; | ||
969 | } | ||
970 | |||
971 | static int | 1118 | static int |
972 | __qlcnic_up(struct qlcnic_adapter *adapter, struct net_device *netdev) | 1119 | __qlcnic_up(struct qlcnic_adapter *adapter, struct net_device *netdev) |
973 | { | 1120 | { |
@@ -979,26 +1126,28 @@ __qlcnic_up(struct qlcnic_adapter *adapter, struct net_device *netdev) | |||
979 | 1126 | ||
980 | if (test_bit(__QLCNIC_DEV_UP, &adapter->state)) | 1127 | if (test_bit(__QLCNIC_DEV_UP, &adapter->state)) |
981 | return 0; | 1128 | return 0; |
1129 | if (qlcnic_set_eswitch_port_config(adapter)) | ||
1130 | return -EIO; | ||
982 | 1131 | ||
983 | if (qlcnic_fw_create_ctx(adapter)) | 1132 | if (qlcnic_fw_create_ctx(adapter)) |
984 | return -EIO; | 1133 | return -EIO; |
985 | 1134 | ||
986 | for (ring = 0; ring < adapter->max_rds_rings; ring++) { | 1135 | for (ring = 0; ring < adapter->max_rds_rings; ring++) { |
987 | rds_ring = &adapter->recv_ctx.rds_rings[ring]; | 1136 | rds_ring = &adapter->recv_ctx->rds_rings[ring]; |
988 | qlcnic_post_rx_buffers(adapter, ring, rds_ring); | 1137 | qlcnic_post_rx_buffers(adapter, rds_ring); |
989 | } | 1138 | } |
990 | 1139 | ||
991 | qlcnic_set_multi(netdev); | 1140 | qlcnic_set_multi(netdev); |
992 | qlcnic_fw_cmd_set_mtu(adapter, netdev->mtu); | 1141 | qlcnic_fw_cmd_set_mtu(adapter, netdev->mtu); |
993 | 1142 | ||
994 | adapter->ahw.linkup = 0; | 1143 | adapter->ahw->linkup = 0; |
995 | 1144 | ||
996 | if (adapter->max_sds_rings > 1) | 1145 | if (adapter->max_sds_rings > 1) |
997 | qlcnic_config_rss(adapter, 1); | 1146 | qlcnic_config_rss(adapter, 1); |
998 | 1147 | ||
999 | qlcnic_config_intr_coalesce(adapter); | 1148 | qlcnic_config_intr_coalesce(adapter); |
1000 | 1149 | ||
1001 | if (adapter->capabilities & QLCNIC_FW_CAPABILITY_HW_LRO) | 1150 | if (netdev->features & NETIF_F_LRO) |
1002 | qlcnic_config_hw_lro(adapter, QLCNIC_LRO_ENABLED); | 1151 | qlcnic_config_hw_lro(adapter, QLCNIC_LRO_ENABLED); |
1003 | 1152 | ||
1004 | qlcnic_napi_enable(adapter); | 1153 | qlcnic_napi_enable(adapter); |
@@ -1041,6 +1190,9 @@ __qlcnic_down(struct qlcnic_adapter *adapter, struct net_device *netdev) | |||
1041 | 1190 | ||
1042 | qlcnic_free_mac_list(adapter); | 1191 | qlcnic_free_mac_list(adapter); |
1043 | 1192 | ||
1193 | if (adapter->fhash.fnum) | ||
1194 | qlcnic_delete_lb_filters(adapter); | ||
1195 | |||
1044 | qlcnic_nic_set_promisc(adapter, QLCNIC_NIU_NON_PROMISC_MODE); | 1196 | qlcnic_nic_set_promisc(adapter, QLCNIC_NIU_NON_PROMISC_MODE); |
1045 | 1197 | ||
1046 | qlcnic_napi_disable(adapter); | 1198 | qlcnic_napi_disable(adapter); |
@@ -1096,8 +1248,6 @@ qlcnic_attach(struct qlcnic_adapter *adapter) | |||
1096 | goto err_out_free_hw; | 1248 | goto err_out_free_hw; |
1097 | } | 1249 | } |
1098 | 1250 | ||
1099 | qlcnic_init_coalesce_defaults(adapter); | ||
1100 | |||
1101 | qlcnic_create_sysfs_entries(adapter); | 1251 | qlcnic_create_sysfs_entries(adapter); |
1102 | 1252 | ||
1103 | adapter->is_up = QLCNIC_ADAPTER_UP_MAGIC; | 1253 | adapter->is_up = QLCNIC_ADAPTER_UP_MAGIC; |
@@ -1138,7 +1288,7 @@ void qlcnic_diag_free_res(struct net_device *netdev, int max_sds_rings) | |||
1138 | clear_bit(__QLCNIC_DEV_UP, &adapter->state); | 1288 | clear_bit(__QLCNIC_DEV_UP, &adapter->state); |
1139 | if (adapter->diag_test == QLCNIC_INTERRUPT_TEST) { | 1289 | if (adapter->diag_test == QLCNIC_INTERRUPT_TEST) { |
1140 | for (ring = 0; ring < adapter->max_sds_rings; ring++) { | 1290 | for (ring = 0; ring < adapter->max_sds_rings; ring++) { |
1141 | sds_ring = &adapter->recv_ctx.sds_rings[ring]; | 1291 | sds_ring = &adapter->recv_ctx->sds_rings[ring]; |
1142 | qlcnic_disable_int(sds_ring); | 1292 | qlcnic_disable_int(sds_ring); |
1143 | } | 1293 | } |
1144 | } | 1294 | } |
@@ -1159,6 +1309,48 @@ out: | |||
1159 | netif_device_attach(netdev); | 1309 | netif_device_attach(netdev); |
1160 | } | 1310 | } |
1161 | 1311 | ||
1312 | static int qlcnic_alloc_adapter_resources(struct qlcnic_adapter *adapter) | ||
1313 | { | ||
1314 | int err = 0; | ||
1315 | adapter->ahw = kzalloc(sizeof(struct qlcnic_hardware_context), | ||
1316 | GFP_KERNEL); | ||
1317 | if (!adapter->ahw) { | ||
1318 | dev_err(&adapter->pdev->dev, | ||
1319 | "Failed to allocate recv ctx resources for adapter\n"); | ||
1320 | err = -ENOMEM; | ||
1321 | goto err_out; | ||
1322 | } | ||
1323 | adapter->recv_ctx = kzalloc(sizeof(struct qlcnic_recv_context), | ||
1324 | GFP_KERNEL); | ||
1325 | if (!adapter->recv_ctx) { | ||
1326 | dev_err(&adapter->pdev->dev, | ||
1327 | "Failed to allocate recv ctx resources for adapter\n"); | ||
1328 | kfree(adapter->ahw); | ||
1329 | adapter->ahw = NULL; | ||
1330 | err = -ENOMEM; | ||
1331 | goto err_out; | ||
1332 | } | ||
1333 | /* Initialize interrupt coalesce parameters */ | ||
1334 | adapter->ahw->coal.flag = QLCNIC_INTR_DEFAULT; | ||
1335 | adapter->ahw->coal.rx_time_us = QLCNIC_DEFAULT_INTR_COALESCE_RX_TIME_US; | ||
1336 | adapter->ahw->coal.rx_packets = QLCNIC_DEFAULT_INTR_COALESCE_RX_PACKETS; | ||
1337 | err_out: | ||
1338 | return err; | ||
1339 | } | ||
1340 | |||
1341 | static void qlcnic_free_adapter_resources(struct qlcnic_adapter *adapter) | ||
1342 | { | ||
1343 | kfree(adapter->recv_ctx); | ||
1344 | adapter->recv_ctx = NULL; | ||
1345 | |||
1346 | if (adapter->ahw->fw_dump.tmpl_hdr) { | ||
1347 | vfree(adapter->ahw->fw_dump.tmpl_hdr); | ||
1348 | adapter->ahw->fw_dump.tmpl_hdr = NULL; | ||
1349 | } | ||
1350 | kfree(adapter->ahw); | ||
1351 | adapter->ahw = NULL; | ||
1352 | } | ||
1353 | |||
1162 | int qlcnic_diag_alloc_res(struct net_device *netdev, int test) | 1354 | int qlcnic_diag_alloc_res(struct net_device *netdev, int test) |
1163 | { | 1355 | { |
1164 | struct qlcnic_adapter *adapter = netdev_priv(netdev); | 1356 | struct qlcnic_adapter *adapter = netdev_priv(netdev); |
@@ -1191,13 +1383,13 @@ int qlcnic_diag_alloc_res(struct net_device *netdev, int test) | |||
1191 | } | 1383 | } |
1192 | 1384 | ||
1193 | for (ring = 0; ring < adapter->max_rds_rings; ring++) { | 1385 | for (ring = 0; ring < adapter->max_rds_rings; ring++) { |
1194 | rds_ring = &adapter->recv_ctx.rds_rings[ring]; | 1386 | rds_ring = &adapter->recv_ctx->rds_rings[ring]; |
1195 | qlcnic_post_rx_buffers(adapter, ring, rds_ring); | 1387 | qlcnic_post_rx_buffers(adapter, rds_ring); |
1196 | } | 1388 | } |
1197 | 1389 | ||
1198 | if (adapter->diag_test == QLCNIC_INTERRUPT_TEST) { | 1390 | if (adapter->diag_test == QLCNIC_INTERRUPT_TEST) { |
1199 | for (ring = 0; ring < adapter->max_sds_rings; ring++) { | 1391 | for (ring = 0; ring < adapter->max_sds_rings; ring++) { |
1200 | sds_ring = &adapter->recv_ctx.sds_rings[ring]; | 1392 | sds_ring = &adapter->recv_ctx->sds_rings[ring]; |
1201 | qlcnic_enable_int(sds_ring); | 1393 | qlcnic_enable_int(sds_ring); |
1202 | } | 1394 | } |
1203 | } | 1395 | } |
@@ -1265,7 +1457,6 @@ qlcnic_setup_netdev(struct qlcnic_adapter *adapter, | |||
1265 | int err; | 1457 | int err; |
1266 | struct pci_dev *pdev = adapter->pdev; | 1458 | struct pci_dev *pdev = adapter->pdev; |
1267 | 1459 | ||
1268 | adapter->rx_csum = 1; | ||
1269 | adapter->mc_enabled = 0; | 1460 | adapter->mc_enabled = 0; |
1270 | adapter->max_mc_count = 38; | 1461 | adapter->max_mc_count = 38; |
1271 | 1462 | ||
@@ -1276,34 +1467,27 @@ qlcnic_setup_netdev(struct qlcnic_adapter *adapter, | |||
1276 | 1467 | ||
1277 | SET_ETHTOOL_OPS(netdev, &qlcnic_ethtool_ops); | 1468 | SET_ETHTOOL_OPS(netdev, &qlcnic_ethtool_ops); |
1278 | 1469 | ||
1279 | netdev->features |= (NETIF_F_SG | NETIF_F_IP_CSUM | | 1470 | netdev->hw_features = NETIF_F_SG | NETIF_F_IP_CSUM | |
1280 | NETIF_F_IPV6_CSUM | NETIF_F_GRO); | 1471 | NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM; |
1281 | netdev->vlan_features |= (NETIF_F_SG | NETIF_F_IP_CSUM | | ||
1282 | NETIF_F_IPV6_CSUM); | ||
1283 | 1472 | ||
1284 | if (adapter->capabilities & QLCNIC_FW_CAPABILITY_TSO) { | 1473 | if (adapter->capabilities & QLCNIC_FW_CAPABILITY_TSO) |
1285 | netdev->features |= (NETIF_F_TSO | NETIF_F_TSO6); | 1474 | netdev->hw_features |= NETIF_F_TSO | NETIF_F_TSO6; |
1286 | netdev->vlan_features |= (NETIF_F_TSO | NETIF_F_TSO6); | 1475 | if (pci_using_dac) |
1287 | } | 1476 | netdev->hw_features |= NETIF_F_HIGHDMA; |
1288 | 1477 | ||
1289 | if (pci_using_dac) { | 1478 | netdev->vlan_features = netdev->hw_features; |
1290 | netdev->features |= NETIF_F_HIGHDMA; | ||
1291 | netdev->vlan_features |= NETIF_F_HIGHDMA; | ||
1292 | } | ||
1293 | 1479 | ||
1294 | if (adapter->capabilities & QLCNIC_FW_CAPABILITY_FVLANTX) | 1480 | if (adapter->capabilities & QLCNIC_FW_CAPABILITY_FVLANTX) |
1295 | netdev->features |= (NETIF_F_HW_VLAN_TX); | 1481 | netdev->hw_features |= NETIF_F_HW_VLAN_TX; |
1296 | |||
1297 | if (adapter->capabilities & QLCNIC_FW_CAPABILITY_HW_LRO) | 1482 | if (adapter->capabilities & QLCNIC_FW_CAPABILITY_HW_LRO) |
1298 | netdev->features |= NETIF_F_LRO; | 1483 | netdev->hw_features |= NETIF_F_LRO; |
1299 | 1484 | ||
1300 | netdev->irq = adapter->msix_entries[0].vector; | 1485 | netdev->features |= netdev->hw_features | |
1486 | NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_FILTER; | ||
1301 | 1487 | ||
1302 | if (qlcnic_read_mac_addr(adapter)) | 1488 | netdev->irq = adapter->msix_entries[0].vector; |
1303 | dev_warn(&pdev->dev, "failed to read mac addr\n"); | ||
1304 | 1489 | ||
1305 | netif_carrier_off(netdev); | 1490 | netif_carrier_off(netdev); |
1306 | netif_stop_queue(netdev); | ||
1307 | 1491 | ||
1308 | err = register_netdev(netdev); | 1492 | err = register_netdev(netdev); |
1309 | if (err) { | 1493 | if (err) { |
@@ -1330,6 +1514,19 @@ static int qlcnic_set_dma_mask(struct pci_dev *pdev, u8 *pci_using_dac) | |||
1330 | return 0; | 1514 | return 0; |
1331 | } | 1515 | } |
1332 | 1516 | ||
1517 | static int | ||
1518 | qlcnic_alloc_msix_entries(struct qlcnic_adapter *adapter, u16 count) | ||
1519 | { | ||
1520 | adapter->msix_entries = kcalloc(count, sizeof(struct msix_entry), | ||
1521 | GFP_KERNEL); | ||
1522 | |||
1523 | if (adapter->msix_entries) | ||
1524 | return 0; | ||
1525 | |||
1526 | dev_err(&adapter->pdev->dev, "failed allocating msix_entries\n"); | ||
1527 | return -ENOMEM; | ||
1528 | } | ||
1529 | |||
1333 | static int __devinit | 1530 | static int __devinit |
1334 | qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | 1531 | qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) |
1335 | { | 1532 | { |
@@ -1338,6 +1535,7 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1338 | int err; | 1535 | int err; |
1339 | uint8_t revision_id; | 1536 | uint8_t revision_id; |
1340 | uint8_t pci_using_dac; | 1537 | uint8_t pci_using_dac; |
1538 | char brd_name[QLCNIC_MAX_BOARD_NAME_LEN]; | ||
1341 | 1539 | ||
1342 | err = pci_enable_device(pdev); | 1540 | err = pci_enable_device(pdev); |
1343 | if (err) | 1541 | if (err) |
@@ -1371,23 +1569,30 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1371 | adapter = netdev_priv(netdev); | 1569 | adapter = netdev_priv(netdev); |
1372 | adapter->netdev = netdev; | 1570 | adapter->netdev = netdev; |
1373 | adapter->pdev = pdev; | 1571 | adapter->pdev = pdev; |
1374 | adapter->dev_rst_time = jiffies; | ||
1375 | 1572 | ||
1573 | if (qlcnic_alloc_adapter_resources(adapter)) | ||
1574 | goto err_out_free_netdev; | ||
1575 | |||
1576 | adapter->dev_rst_time = jiffies; | ||
1376 | revision_id = pdev->revision; | 1577 | revision_id = pdev->revision; |
1377 | adapter->ahw.revision_id = revision_id; | 1578 | adapter->ahw->revision_id = revision_id; |
1378 | 1579 | ||
1379 | rwlock_init(&adapter->ahw.crb_lock); | 1580 | rwlock_init(&adapter->ahw->crb_lock); |
1380 | mutex_init(&adapter->ahw.mem_lock); | 1581 | mutex_init(&adapter->ahw->mem_lock); |
1381 | 1582 | ||
1382 | spin_lock_init(&adapter->tx_clean_lock); | 1583 | spin_lock_init(&adapter->tx_clean_lock); |
1383 | INIT_LIST_HEAD(&adapter->mac_list); | 1584 | INIT_LIST_HEAD(&adapter->mac_list); |
1384 | 1585 | ||
1385 | err = qlcnic_setup_pci_map(adapter); | 1586 | err = qlcnic_setup_pci_map(adapter); |
1386 | if (err) | 1587 | if (err) |
1387 | goto err_out_free_netdev; | 1588 | goto err_out_free_hw; |
1388 | 1589 | ||
1389 | /* This will be reset for mezz cards */ | 1590 | /* This will be reset for mezz cards */ |
1390 | adapter->portnum = adapter->ahw.pci_func; | 1591 | adapter->portnum = adapter->ahw->pci_func; |
1592 | |||
1593 | /* Get FW dump template and store it */ | ||
1594 | if (adapter->op_mode != QLCNIC_NON_PRIV_FUNC) | ||
1595 | qlcnic_fw_cmd_get_minidump_temp(adapter); | ||
1391 | 1596 | ||
1392 | err = qlcnic_get_board_info(adapter); | 1597 | err = qlcnic_get_board_info(adapter); |
1393 | if (err) { | 1598 | if (err) { |
@@ -1395,20 +1600,35 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1395 | goto err_out_iounmap; | 1600 | goto err_out_iounmap; |
1396 | } | 1601 | } |
1397 | 1602 | ||
1398 | if (qlcnic_read_mac_addr(adapter)) | 1603 | err = qlcnic_setup_idc_param(adapter); |
1399 | dev_warn(&pdev->dev, "failed to read mac addr\n"); | 1604 | if (err) |
1400 | |||
1401 | if (qlcnic_setup_idc_param(adapter)) | ||
1402 | goto err_out_iounmap; | 1605 | goto err_out_iounmap; |
1403 | 1606 | ||
1607 | adapter->flags |= QLCNIC_NEED_FLR; | ||
1608 | |||
1404 | err = adapter->nic_ops->start_firmware(adapter); | 1609 | err = adapter->nic_ops->start_firmware(adapter); |
1405 | if (err) { | 1610 | if (err) { |
1406 | dev_err(&pdev->dev, "Loading fw failed.Please Reboot\n"); | 1611 | dev_err(&pdev->dev, "Loading fw failed.Please Reboot\n"); |
1407 | goto err_out_decr_ref; | 1612 | goto err_out_decr_ref; |
1408 | } | 1613 | } |
1409 | 1614 | ||
1615 | if (qlcnic_read_mac_addr(adapter)) | ||
1616 | dev_warn(&pdev->dev, "failed to read mac addr\n"); | ||
1617 | |||
1618 | if (adapter->portnum == 0) { | ||
1619 | get_brd_name(adapter, brd_name); | ||
1620 | |||
1621 | pr_info("%s: %s Board Chip rev 0x%x\n", | ||
1622 | module_name(THIS_MODULE), | ||
1623 | brd_name, adapter->ahw->revision_id); | ||
1624 | } | ||
1625 | |||
1410 | qlcnic_clear_stats(adapter); | 1626 | qlcnic_clear_stats(adapter); |
1411 | 1627 | ||
1628 | err = qlcnic_alloc_msix_entries(adapter, adapter->max_rx_ques); | ||
1629 | if (err) | ||
1630 | goto err_out_decr_ref; | ||
1631 | |||
1412 | qlcnic_setup_intr(adapter); | 1632 | qlcnic_setup_intr(adapter); |
1413 | 1633 | ||
1414 | err = qlcnic_setup_netdev(adapter, netdev, pci_using_dac); | 1634 | err = qlcnic_setup_netdev(adapter, netdev, pci_using_dac); |
@@ -1419,7 +1639,7 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1419 | 1639 | ||
1420 | qlcnic_schedule_work(adapter, qlcnic_fw_poll_work, FW_POLL_DELAY); | 1640 | qlcnic_schedule_work(adapter, qlcnic_fw_poll_work, FW_POLL_DELAY); |
1421 | 1641 | ||
1422 | switch (adapter->ahw.port_type) { | 1642 | switch (adapter->ahw->port_type) { |
1423 | case QLCNIC_GBE: | 1643 | case QLCNIC_GBE: |
1424 | dev_info(&adapter->pdev->dev, "%s: GbE port initialized\n", | 1644 | dev_info(&adapter->pdev->dev, "%s: GbE port initialized\n", |
1425 | adapter->netdev->name); | 1645 | adapter->netdev->name); |
@@ -1430,19 +1650,24 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1430 | break; | 1650 | break; |
1431 | } | 1651 | } |
1432 | 1652 | ||
1653 | qlcnic_alloc_lb_filters_mem(adapter); | ||
1433 | qlcnic_create_diag_entries(adapter); | 1654 | qlcnic_create_diag_entries(adapter); |
1434 | 1655 | ||
1435 | return 0; | 1656 | return 0; |
1436 | 1657 | ||
1437 | err_out_disable_msi: | 1658 | err_out_disable_msi: |
1438 | qlcnic_teardown_intr(adapter); | 1659 | qlcnic_teardown_intr(adapter); |
1660 | kfree(adapter->msix_entries); | ||
1439 | 1661 | ||
1440 | err_out_decr_ref: | 1662 | err_out_decr_ref: |
1441 | qlcnic_clr_all_drv_state(adapter); | 1663 | qlcnic_clr_all_drv_state(adapter, 0); |
1442 | 1664 | ||
1443 | err_out_iounmap: | 1665 | err_out_iounmap: |
1444 | qlcnic_cleanup_pci_map(adapter); | 1666 | qlcnic_cleanup_pci_map(adapter); |
1445 | 1667 | ||
1668 | err_out_free_hw: | ||
1669 | qlcnic_free_adapter_resources(adapter); | ||
1670 | |||
1446 | err_out_free_netdev: | 1671 | err_out_free_netdev: |
1447 | free_netdev(netdev); | 1672 | free_netdev(netdev); |
1448 | 1673 | ||
@@ -1477,11 +1702,14 @@ static void __devexit qlcnic_remove(struct pci_dev *pdev) | |||
1477 | if (adapter->eswitch != NULL) | 1702 | if (adapter->eswitch != NULL) |
1478 | kfree(adapter->eswitch); | 1703 | kfree(adapter->eswitch); |
1479 | 1704 | ||
1480 | qlcnic_clr_all_drv_state(adapter); | 1705 | qlcnic_clr_all_drv_state(adapter, 0); |
1481 | 1706 | ||
1482 | clear_bit(__QLCNIC_RESETTING, &adapter->state); | 1707 | clear_bit(__QLCNIC_RESETTING, &adapter->state); |
1483 | 1708 | ||
1709 | qlcnic_free_lb_filters_mem(adapter); | ||
1710 | |||
1484 | qlcnic_teardown_intr(adapter); | 1711 | qlcnic_teardown_intr(adapter); |
1712 | kfree(adapter->msix_entries); | ||
1485 | 1713 | ||
1486 | qlcnic_remove_diag_entries(adapter); | 1714 | qlcnic_remove_diag_entries(adapter); |
1487 | 1715 | ||
@@ -1494,6 +1722,7 @@ static void __devexit qlcnic_remove(struct pci_dev *pdev) | |||
1494 | pci_disable_device(pdev); | 1722 | pci_disable_device(pdev); |
1495 | pci_set_drvdata(pdev, NULL); | 1723 | pci_set_drvdata(pdev, NULL); |
1496 | 1724 | ||
1725 | qlcnic_free_adapter_resources(adapter); | ||
1497 | free_netdev(netdev); | 1726 | free_netdev(netdev); |
1498 | } | 1727 | } |
1499 | static int __qlcnic_shutdown(struct pci_dev *pdev) | 1728 | static int __qlcnic_shutdown(struct pci_dev *pdev) |
@@ -1509,7 +1738,7 @@ static int __qlcnic_shutdown(struct pci_dev *pdev) | |||
1509 | if (netif_running(netdev)) | 1738 | if (netif_running(netdev)) |
1510 | qlcnic_down(adapter, netdev); | 1739 | qlcnic_down(adapter, netdev); |
1511 | 1740 | ||
1512 | qlcnic_clr_all_drv_state(adapter); | 1741 | qlcnic_clr_all_drv_state(adapter, 0); |
1513 | 1742 | ||
1514 | clear_bit(__QLCNIC_RESETTING, &adapter->state); | 1743 | clear_bit(__QLCNIC_RESETTING, &adapter->state); |
1515 | 1744 | ||
@@ -1573,7 +1802,7 @@ qlcnic_resume(struct pci_dev *pdev) | |||
1573 | if (err) | 1802 | if (err) |
1574 | goto done; | 1803 | goto done; |
1575 | 1804 | ||
1576 | qlcnic_config_indev_addr(netdev, NETDEV_UP); | 1805 | qlcnic_restore_indev_addr(netdev, NETDEV_UP); |
1577 | } | 1806 | } |
1578 | done: | 1807 | done: |
1579 | netif_device_attach(netdev); | 1808 | netif_device_attach(netdev); |
@@ -1587,9 +1816,6 @@ static int qlcnic_open(struct net_device *netdev) | |||
1587 | struct qlcnic_adapter *adapter = netdev_priv(netdev); | 1816 | struct qlcnic_adapter *adapter = netdev_priv(netdev); |
1588 | int err; | 1817 | int err; |
1589 | 1818 | ||
1590 | if (adapter->driver_mismatch) | ||
1591 | return -EIO; | ||
1592 | |||
1593 | err = qlcnic_attach(adapter); | 1819 | err = qlcnic_attach(adapter); |
1594 | if (err) | 1820 | if (err) |
1595 | return err; | 1821 | return err; |
@@ -1619,69 +1845,242 @@ static int qlcnic_close(struct net_device *netdev) | |||
1619 | } | 1845 | } |
1620 | 1846 | ||
1621 | static void | 1847 | static void |
1622 | qlcnic_tso_check(struct net_device *netdev, | 1848 | qlcnic_alloc_lb_filters_mem(struct qlcnic_adapter *adapter) |
1849 | { | ||
1850 | void *head; | ||
1851 | int i; | ||
1852 | |||
1853 | if (!qlcnic_mac_learn) | ||
1854 | return; | ||
1855 | |||
1856 | spin_lock_init(&adapter->mac_learn_lock); | ||
1857 | |||
1858 | head = kcalloc(QLCNIC_LB_MAX_FILTERS, sizeof(struct hlist_head), | ||
1859 | GFP_KERNEL); | ||
1860 | if (!head) | ||
1861 | return; | ||
1862 | |||
1863 | adapter->fhash.fmax = QLCNIC_LB_MAX_FILTERS; | ||
1864 | adapter->fhash.fhead = (struct hlist_head *)head; | ||
1865 | |||
1866 | for (i = 0; i < adapter->fhash.fmax; i++) | ||
1867 | INIT_HLIST_HEAD(&adapter->fhash.fhead[i]); | ||
1868 | } | ||
1869 | |||
1870 | static void qlcnic_free_lb_filters_mem(struct qlcnic_adapter *adapter) | ||
1871 | { | ||
1872 | if (adapter->fhash.fmax && adapter->fhash.fhead) | ||
1873 | kfree(adapter->fhash.fhead); | ||
1874 | |||
1875 | adapter->fhash.fhead = NULL; | ||
1876 | adapter->fhash.fmax = 0; | ||
1877 | } | ||
1878 | |||
1879 | static void qlcnic_change_filter(struct qlcnic_adapter *adapter, | ||
1880 | u64 uaddr, __le16 vlan_id, struct qlcnic_host_tx_ring *tx_ring) | ||
1881 | { | ||
1882 | struct cmd_desc_type0 *hwdesc; | ||
1883 | struct qlcnic_nic_req *req; | ||
1884 | struct qlcnic_mac_req *mac_req; | ||
1885 | struct qlcnic_vlan_req *vlan_req; | ||
1886 | u32 producer; | ||
1887 | u64 word; | ||
1888 | |||
1889 | producer = tx_ring->producer; | ||
1890 | hwdesc = &tx_ring->desc_head[tx_ring->producer]; | ||
1891 | |||
1892 | req = (struct qlcnic_nic_req *)hwdesc; | ||
1893 | memset(req, 0, sizeof(struct qlcnic_nic_req)); | ||
1894 | req->qhdr = cpu_to_le64(QLCNIC_REQUEST << 23); | ||
1895 | |||
1896 | word = QLCNIC_MAC_EVENT | ((u64)(adapter->portnum) << 16); | ||
1897 | req->req_hdr = cpu_to_le64(word); | ||
1898 | |||
1899 | mac_req = (struct qlcnic_mac_req *)&(req->words[0]); | ||
1900 | mac_req->op = vlan_id ? QLCNIC_MAC_VLAN_ADD : QLCNIC_MAC_ADD; | ||
1901 | memcpy(mac_req->mac_addr, &uaddr, ETH_ALEN); | ||
1902 | |||
1903 | vlan_req = (struct qlcnic_vlan_req *)&req->words[1]; | ||
1904 | vlan_req->vlan_id = vlan_id; | ||
1905 | |||
1906 | tx_ring->producer = get_next_index(producer, tx_ring->num_desc); | ||
1907 | smp_mb(); | ||
1908 | } | ||
1909 | |||
1910 | #define QLCNIC_MAC_HASH(MAC)\ | ||
1911 | ((((MAC) & 0x70000) >> 0x10) | (((MAC) & 0x70000000000ULL) >> 0x25)) | ||
1912 | |||
1913 | static void | ||
1914 | qlcnic_send_filter(struct qlcnic_adapter *adapter, | ||
1623 | struct qlcnic_host_tx_ring *tx_ring, | 1915 | struct qlcnic_host_tx_ring *tx_ring, |
1624 | struct cmd_desc_type0 *first_desc, | 1916 | struct cmd_desc_type0 *first_desc, |
1625 | struct sk_buff *skb) | 1917 | struct sk_buff *skb) |
1626 | { | 1918 | { |
1627 | u8 opcode = TX_ETHER_PKT; | 1919 | struct ethhdr *phdr = (struct ethhdr *)(skb->data); |
1628 | __be16 protocol = skb->protocol; | 1920 | struct qlcnic_filter *fil, *tmp_fil; |
1629 | u16 flags = 0, vid = 0; | 1921 | struct hlist_node *tmp_hnode, *n; |
1630 | int copied, offset, copy_len, hdr_len = 0, tso = 0, vlan_oob = 0; | 1922 | struct hlist_head *head; |
1923 | u64 src_addr = 0; | ||
1924 | __le16 vlan_id = 0; | ||
1925 | u8 hindex; | ||
1926 | |||
1927 | if (!compare_ether_addr(phdr->h_source, adapter->mac_addr)) | ||
1928 | return; | ||
1929 | |||
1930 | if (adapter->fhash.fnum >= adapter->fhash.fmax) | ||
1931 | return; | ||
1932 | |||
1933 | /* Only NPAR capable devices support vlan based learning*/ | ||
1934 | if (adapter->flags & QLCNIC_ESWITCH_ENABLED) | ||
1935 | vlan_id = first_desc->vlan_TCI; | ||
1936 | memcpy(&src_addr, phdr->h_source, ETH_ALEN); | ||
1937 | hindex = QLCNIC_MAC_HASH(src_addr) & (QLCNIC_LB_MAX_FILTERS - 1); | ||
1938 | head = &(adapter->fhash.fhead[hindex]); | ||
1939 | |||
1940 | hlist_for_each_entry_safe(tmp_fil, tmp_hnode, n, head, fnode) { | ||
1941 | if (!memcmp(tmp_fil->faddr, &src_addr, ETH_ALEN) && | ||
1942 | tmp_fil->vlan_id == vlan_id) { | ||
1943 | |||
1944 | if (jiffies > | ||
1945 | (QLCNIC_READD_AGE * HZ + tmp_fil->ftime)) | ||
1946 | qlcnic_change_filter(adapter, src_addr, vlan_id, | ||
1947 | tx_ring); | ||
1948 | tmp_fil->ftime = jiffies; | ||
1949 | return; | ||
1950 | } | ||
1951 | } | ||
1952 | |||
1953 | fil = kzalloc(sizeof(struct qlcnic_filter), GFP_ATOMIC); | ||
1954 | if (!fil) | ||
1955 | return; | ||
1956 | |||
1957 | qlcnic_change_filter(adapter, src_addr, vlan_id, tx_ring); | ||
1958 | |||
1959 | fil->ftime = jiffies; | ||
1960 | fil->vlan_id = vlan_id; | ||
1961 | memcpy(fil->faddr, &src_addr, ETH_ALEN); | ||
1962 | spin_lock(&adapter->mac_learn_lock); | ||
1963 | hlist_add_head(&(fil->fnode), head); | ||
1964 | adapter->fhash.fnum++; | ||
1965 | spin_unlock(&adapter->mac_learn_lock); | ||
1966 | } | ||
1967 | |||
1968 | static int | ||
1969 | qlcnic_tx_pkt(struct qlcnic_adapter *adapter, | ||
1970 | struct cmd_desc_type0 *first_desc, | ||
1971 | struct sk_buff *skb) | ||
1972 | { | ||
1973 | u8 opcode = 0, hdr_len = 0; | ||
1974 | u16 flags = 0, vlan_tci = 0; | ||
1975 | int copied, offset, copy_len; | ||
1631 | struct cmd_desc_type0 *hwdesc; | 1976 | struct cmd_desc_type0 *hwdesc; |
1632 | struct vlan_ethhdr *vh; | 1977 | struct vlan_ethhdr *vh; |
1633 | struct qlcnic_adapter *adapter = netdev_priv(netdev); | 1978 | struct qlcnic_host_tx_ring *tx_ring = adapter->tx_ring; |
1979 | u16 protocol = ntohs(skb->protocol); | ||
1634 | u32 producer = tx_ring->producer; | 1980 | u32 producer = tx_ring->producer; |
1635 | 1981 | ||
1636 | if (protocol == cpu_to_be16(ETH_P_8021Q)) { | 1982 | if (protocol == ETH_P_8021Q) { |
1637 | |||
1638 | vh = (struct vlan_ethhdr *)skb->data; | 1983 | vh = (struct vlan_ethhdr *)skb->data; |
1639 | protocol = vh->h_vlan_encapsulated_proto; | ||
1640 | flags = FLAGS_VLAN_TAGGED; | 1984 | flags = FLAGS_VLAN_TAGGED; |
1641 | 1985 | vlan_tci = vh->h_vlan_TCI; | |
1642 | } else if (vlan_tx_tag_present(skb)) { | 1986 | } else if (vlan_tx_tag_present(skb)) { |
1987 | flags = FLAGS_VLAN_OOB; | ||
1988 | vlan_tci = vlan_tx_tag_get(skb); | ||
1989 | } | ||
1990 | if (unlikely(adapter->pvid)) { | ||
1991 | if (vlan_tci && !(adapter->flags & QLCNIC_TAGGING_ENABLED)) | ||
1992 | return -EIO; | ||
1993 | if (vlan_tci && (adapter->flags & QLCNIC_TAGGING_ENABLED)) | ||
1994 | goto set_flags; | ||
1643 | 1995 | ||
1644 | flags = FLAGS_VLAN_OOB; | 1996 | flags = FLAGS_VLAN_OOB; |
1645 | vid = vlan_tx_tag_get(skb); | 1997 | vlan_tci = adapter->pvid; |
1646 | qlcnic_set_tx_vlan_tci(first_desc, vid); | ||
1647 | vlan_oob = 1; | ||
1648 | } | 1998 | } |
1999 | set_flags: | ||
2000 | qlcnic_set_tx_vlan_tci(first_desc, vlan_tci); | ||
2001 | qlcnic_set_tx_flags_opcode(first_desc, flags, opcode); | ||
1649 | 2002 | ||
1650 | if (*(skb->data) & BIT_0) { | 2003 | if (*(skb->data) & BIT_0) { |
1651 | flags |= BIT_0; | 2004 | flags |= BIT_0; |
1652 | memcpy(&first_desc->eth_addr, skb->data, ETH_ALEN); | 2005 | memcpy(&first_desc->eth_addr, skb->data, ETH_ALEN); |
1653 | } | 2006 | } |
1654 | 2007 | opcode = TX_ETHER_PKT; | |
1655 | if ((netdev->features & (NETIF_F_TSO | NETIF_F_TSO6)) && | 2008 | if ((adapter->netdev->features & (NETIF_F_TSO | NETIF_F_TSO6)) && |
1656 | skb_shinfo(skb)->gso_size > 0) { | 2009 | skb_shinfo(skb)->gso_size > 0) { |
1657 | 2010 | ||
1658 | hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb); | 2011 | hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb); |
1659 | 2012 | ||
1660 | first_desc->mss = cpu_to_le16(skb_shinfo(skb)->gso_size); | 2013 | first_desc->mss = cpu_to_le16(skb_shinfo(skb)->gso_size); |
1661 | first_desc->total_hdr_length = hdr_len; | 2014 | first_desc->total_hdr_length = hdr_len; |
1662 | if (vlan_oob) { | 2015 | |
2016 | opcode = (protocol == ETH_P_IPV6) ? TX_TCP_LSO6 : TX_TCP_LSO; | ||
2017 | |||
2018 | /* For LSO, we need to copy the MAC/IP/TCP headers into | ||
2019 | * the descriptor ring */ | ||
2020 | copied = 0; | ||
2021 | offset = 2; | ||
2022 | |||
2023 | if (flags & FLAGS_VLAN_OOB) { | ||
1663 | first_desc->total_hdr_length += VLAN_HLEN; | 2024 | first_desc->total_hdr_length += VLAN_HLEN; |
1664 | first_desc->tcp_hdr_offset = VLAN_HLEN; | 2025 | first_desc->tcp_hdr_offset = VLAN_HLEN; |
1665 | first_desc->ip_hdr_offset = VLAN_HLEN; | 2026 | first_desc->ip_hdr_offset = VLAN_HLEN; |
1666 | /* Only in case of TSO on vlan device */ | 2027 | /* Only in case of TSO on vlan device */ |
1667 | flags |= FLAGS_VLAN_TAGGED; | 2028 | flags |= FLAGS_VLAN_TAGGED; |
2029 | |||
2030 | /* Create a TSO vlan header template for firmware */ | ||
2031 | |||
2032 | hwdesc = &tx_ring->desc_head[producer]; | ||
2033 | tx_ring->cmd_buf_arr[producer].skb = NULL; | ||
2034 | |||
2035 | copy_len = min((int)sizeof(struct cmd_desc_type0) - | ||
2036 | offset, hdr_len + VLAN_HLEN); | ||
2037 | |||
2038 | vh = (struct vlan_ethhdr *)((char *) hwdesc + 2); | ||
2039 | skb_copy_from_linear_data(skb, vh, 12); | ||
2040 | vh->h_vlan_proto = htons(ETH_P_8021Q); | ||
2041 | vh->h_vlan_TCI = htons(vlan_tci); | ||
2042 | |||
2043 | skb_copy_from_linear_data_offset(skb, 12, | ||
2044 | (char *)vh + 16, copy_len - 16); | ||
2045 | |||
2046 | copied = copy_len - VLAN_HLEN; | ||
2047 | offset = 0; | ||
2048 | |||
2049 | producer = get_next_index(producer, tx_ring->num_desc); | ||
2050 | } | ||
2051 | |||
2052 | while (copied < hdr_len) { | ||
2053 | |||
2054 | copy_len = min((int)sizeof(struct cmd_desc_type0) - | ||
2055 | offset, (hdr_len - copied)); | ||
2056 | |||
2057 | hwdesc = &tx_ring->desc_head[producer]; | ||
2058 | tx_ring->cmd_buf_arr[producer].skb = NULL; | ||
2059 | |||
2060 | skb_copy_from_linear_data_offset(skb, copied, | ||
2061 | (char *) hwdesc + offset, copy_len); | ||
2062 | |||
2063 | copied += copy_len; | ||
2064 | offset = 0; | ||
2065 | |||
2066 | producer = get_next_index(producer, tx_ring->num_desc); | ||
1668 | } | 2067 | } |
1669 | 2068 | ||
1670 | opcode = (protocol == cpu_to_be16(ETH_P_IPV6)) ? | 2069 | tx_ring->producer = producer; |
1671 | TX_TCP_LSO6 : TX_TCP_LSO; | 2070 | smp_mb(); |
1672 | tso = 1; | 2071 | adapter->stats.lso_frames++; |
1673 | 2072 | ||
1674 | } else if (skb->ip_summed == CHECKSUM_PARTIAL) { | 2073 | } else if (skb->ip_summed == CHECKSUM_PARTIAL) { |
1675 | u8 l4proto; | 2074 | u8 l4proto; |
1676 | 2075 | ||
1677 | if (protocol == cpu_to_be16(ETH_P_IP)) { | 2076 | if (protocol == ETH_P_IP) { |
1678 | l4proto = ip_hdr(skb)->protocol; | 2077 | l4proto = ip_hdr(skb)->protocol; |
1679 | 2078 | ||
1680 | if (l4proto == IPPROTO_TCP) | 2079 | if (l4proto == IPPROTO_TCP) |
1681 | opcode = TX_TCP_PKT; | 2080 | opcode = TX_TCP_PKT; |
1682 | else if (l4proto == IPPROTO_UDP) | 2081 | else if (l4proto == IPPROTO_UDP) |
1683 | opcode = TX_UDP_PKT; | 2082 | opcode = TX_UDP_PKT; |
1684 | } else if (protocol == cpu_to_be16(ETH_P_IPV6)) { | 2083 | } else if (protocol == ETH_P_IPV6) { |
1685 | l4proto = ipv6_hdr(skb)->nexthdr; | 2084 | l4proto = ipv6_hdr(skb)->nexthdr; |
1686 | 2085 | ||
1687 | if (l4proto == IPPROTO_TCP) | 2086 | if (l4proto == IPPROTO_TCP) |
@@ -1690,62 +2089,11 @@ qlcnic_tso_check(struct net_device *netdev, | |||
1690 | opcode = TX_UDPV6_PKT; | 2089 | opcode = TX_UDPV6_PKT; |
1691 | } | 2090 | } |
1692 | } | 2091 | } |
1693 | |||
1694 | first_desc->tcp_hdr_offset += skb_transport_offset(skb); | 2092 | first_desc->tcp_hdr_offset += skb_transport_offset(skb); |
1695 | first_desc->ip_hdr_offset += skb_network_offset(skb); | 2093 | first_desc->ip_hdr_offset += skb_network_offset(skb); |
1696 | qlcnic_set_tx_flags_opcode(first_desc, flags, opcode); | 2094 | qlcnic_set_tx_flags_opcode(first_desc, flags, opcode); |
1697 | 2095 | ||
1698 | if (!tso) | 2096 | return 0; |
1699 | return; | ||
1700 | |||
1701 | /* For LSO, we need to copy the MAC/IP/TCP headers into | ||
1702 | * the descriptor ring | ||
1703 | */ | ||
1704 | copied = 0; | ||
1705 | offset = 2; | ||
1706 | |||
1707 | if (vlan_oob) { | ||
1708 | /* Create a TSO vlan header template for firmware */ | ||
1709 | |||
1710 | hwdesc = &tx_ring->desc_head[producer]; | ||
1711 | tx_ring->cmd_buf_arr[producer].skb = NULL; | ||
1712 | |||
1713 | copy_len = min((int)sizeof(struct cmd_desc_type0) - offset, | ||
1714 | hdr_len + VLAN_HLEN); | ||
1715 | |||
1716 | vh = (struct vlan_ethhdr *)((char *)hwdesc + 2); | ||
1717 | skb_copy_from_linear_data(skb, vh, 12); | ||
1718 | vh->h_vlan_proto = htons(ETH_P_8021Q); | ||
1719 | vh->h_vlan_TCI = htons(vid); | ||
1720 | skb_copy_from_linear_data_offset(skb, 12, | ||
1721 | (char *)vh + 16, copy_len - 16); | ||
1722 | |||
1723 | copied = copy_len - VLAN_HLEN; | ||
1724 | offset = 0; | ||
1725 | |||
1726 | producer = get_next_index(producer, tx_ring->num_desc); | ||
1727 | } | ||
1728 | |||
1729 | while (copied < hdr_len) { | ||
1730 | |||
1731 | copy_len = min((int)sizeof(struct cmd_desc_type0) - offset, | ||
1732 | (hdr_len - copied)); | ||
1733 | |||
1734 | hwdesc = &tx_ring->desc_head[producer]; | ||
1735 | tx_ring->cmd_buf_arr[producer].skb = NULL; | ||
1736 | |||
1737 | skb_copy_from_linear_data_offset(skb, copied, | ||
1738 | (char *)hwdesc + offset, copy_len); | ||
1739 | |||
1740 | copied += copy_len; | ||
1741 | offset = 0; | ||
1742 | |||
1743 | producer = get_next_index(producer, tx_ring->num_desc); | ||
1744 | } | ||
1745 | |||
1746 | tx_ring->producer = producer; | ||
1747 | barrier(); | ||
1748 | adapter->stats.lso_frames++; | ||
1749 | } | 2097 | } |
1750 | 2098 | ||
1751 | static int | 2099 | static int |
@@ -1796,11 +2144,30 @@ out_err: | |||
1796 | return -ENOMEM; | 2144 | return -ENOMEM; |
1797 | } | 2145 | } |
1798 | 2146 | ||
2147 | static void | ||
2148 | qlcnic_unmap_buffers(struct pci_dev *pdev, struct sk_buff *skb, | ||
2149 | struct qlcnic_cmd_buffer *pbuf) | ||
2150 | { | ||
2151 | struct qlcnic_skb_frag *nf = &pbuf->frag_array[0]; | ||
2152 | int nr_frags = skb_shinfo(skb)->nr_frags; | ||
2153 | int i; | ||
2154 | |||
2155 | for (i = 0; i < nr_frags; i++) { | ||
2156 | nf = &pbuf->frag_array[i+1]; | ||
2157 | pci_unmap_page(pdev, nf->dma, nf->length, PCI_DMA_TODEVICE); | ||
2158 | } | ||
2159 | |||
2160 | nf = &pbuf->frag_array[0]; | ||
2161 | pci_unmap_single(pdev, nf->dma, skb_headlen(skb), PCI_DMA_TODEVICE); | ||
2162 | pbuf->skb = NULL; | ||
2163 | } | ||
2164 | |||
1799 | static inline void | 2165 | static inline void |
1800 | qlcnic_clear_cmddesc(u64 *desc) | 2166 | qlcnic_clear_cmddesc(u64 *desc) |
1801 | { | 2167 | { |
1802 | desc[0] = 0ULL; | 2168 | desc[0] = 0ULL; |
1803 | desc[2] = 0ULL; | 2169 | desc[2] = 0ULL; |
2170 | desc[7] = 0ULL; | ||
1804 | } | 2171 | } |
1805 | 2172 | ||
1806 | netdev_tx_t | 2173 | netdev_tx_t |
@@ -1812,10 +2179,12 @@ qlcnic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
1812 | struct qlcnic_skb_frag *buffrag; | 2179 | struct qlcnic_skb_frag *buffrag; |
1813 | struct cmd_desc_type0 *hwdesc, *first_desc; | 2180 | struct cmd_desc_type0 *hwdesc, *first_desc; |
1814 | struct pci_dev *pdev; | 2181 | struct pci_dev *pdev; |
2182 | struct ethhdr *phdr; | ||
2183 | int delta = 0; | ||
1815 | int i, k; | 2184 | int i, k; |
1816 | 2185 | ||
1817 | u32 producer; | 2186 | u32 producer; |
1818 | int frag_count, no_of_desc; | 2187 | int frag_count; |
1819 | u32 num_txd = tx_ring->num_desc; | 2188 | u32 num_txd = tx_ring->num_desc; |
1820 | 2189 | ||
1821 | if (!test_bit(__QLCNIC_DEV_UP, &adapter->state)) { | 2190 | if (!test_bit(__QLCNIC_DEV_UP, &adapter->state)) { |
@@ -1823,14 +2192,30 @@ qlcnic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
1823 | return NETDEV_TX_BUSY; | 2192 | return NETDEV_TX_BUSY; |
1824 | } | 2193 | } |
1825 | 2194 | ||
2195 | if (adapter->flags & QLCNIC_MACSPOOF) { | ||
2196 | phdr = (struct ethhdr *)skb->data; | ||
2197 | if (compare_ether_addr(phdr->h_source, | ||
2198 | adapter->mac_addr)) | ||
2199 | goto drop_packet; | ||
2200 | } | ||
2201 | |||
1826 | frag_count = skb_shinfo(skb)->nr_frags + 1; | 2202 | frag_count = skb_shinfo(skb)->nr_frags + 1; |
2203 | /* 14 frags supported for normal packet and | ||
2204 | * 32 frags supported for TSO packet | ||
2205 | */ | ||
2206 | if (!skb_is_gso(skb) && frag_count > QLCNIC_MAX_FRAGS_PER_TX) { | ||
1827 | 2207 | ||
1828 | /* 4 fragments per cmd des */ | 2208 | for (i = 0; i < (frag_count - QLCNIC_MAX_FRAGS_PER_TX); i++) |
1829 | no_of_desc = (frag_count + 3) >> 2; | 2209 | delta += skb_shinfo(skb)->frags[i].size; |
2210 | |||
2211 | if (!__pskb_pull_tail(skb, delta)) | ||
2212 | goto drop_packet; | ||
2213 | |||
2214 | frag_count = 1 + skb_shinfo(skb)->nr_frags; | ||
2215 | } | ||
1830 | 2216 | ||
1831 | if (unlikely(qlcnic_tx_avail(tx_ring) <= TX_STOP_THRESH)) { | 2217 | if (unlikely(qlcnic_tx_avail(tx_ring) <= TX_STOP_THRESH)) { |
1832 | netif_stop_queue(netdev); | 2218 | netif_stop_queue(netdev); |
1833 | smp_mb(); | ||
1834 | if (qlcnic_tx_avail(tx_ring) > TX_STOP_THRESH) | 2219 | if (qlcnic_tx_avail(tx_ring) > TX_STOP_THRESH) |
1835 | netif_start_queue(netdev); | 2220 | netif_start_queue(netdev); |
1836 | else { | 2221 | else { |
@@ -1844,6 +2229,9 @@ qlcnic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
1844 | 2229 | ||
1845 | pdev = adapter->pdev; | 2230 | pdev = adapter->pdev; |
1846 | 2231 | ||
2232 | first_desc = hwdesc = &tx_ring->desc_head[producer]; | ||
2233 | qlcnic_clear_cmddesc((u64 *)hwdesc); | ||
2234 | |||
1847 | if (qlcnic_map_tx_skb(pdev, skb, pbuf)) { | 2235 | if (qlcnic_map_tx_skb(pdev, skb, pbuf)) { |
1848 | adapter->stats.tx_dma_map_error++; | 2236 | adapter->stats.tx_dma_map_error++; |
1849 | goto drop_packet; | 2237 | goto drop_packet; |
@@ -1852,9 +2240,6 @@ qlcnic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
1852 | pbuf->skb = skb; | 2240 | pbuf->skb = skb; |
1853 | pbuf->frag_count = frag_count; | 2241 | pbuf->frag_count = frag_count; |
1854 | 2242 | ||
1855 | first_desc = hwdesc = &tx_ring->desc_head[producer]; | ||
1856 | qlcnic_clear_cmddesc((u64 *)hwdesc); | ||
1857 | |||
1858 | qlcnic_set_tx_frags_len(first_desc, frag_count, skb->len); | 2243 | qlcnic_set_tx_frags_len(first_desc, frag_count, skb->len); |
1859 | qlcnic_set_tx_port(first_desc, adapter->portnum); | 2244 | qlcnic_set_tx_port(first_desc, adapter->portnum); |
1860 | 2245 | ||
@@ -1890,8 +2275,13 @@ qlcnic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
1890 | } | 2275 | } |
1891 | 2276 | ||
1892 | tx_ring->producer = get_next_index(producer, num_txd); | 2277 | tx_ring->producer = get_next_index(producer, num_txd); |
2278 | smp_mb(); | ||
2279 | |||
2280 | if (unlikely(qlcnic_tx_pkt(adapter, first_desc, skb))) | ||
2281 | goto unwind_buff; | ||
1893 | 2282 | ||
1894 | qlcnic_tso_check(netdev, tx_ring, first_desc, skb); | 2283 | if (qlcnic_mac_learn) |
2284 | qlcnic_send_filter(adapter, tx_ring, first_desc, skb); | ||
1895 | 2285 | ||
1896 | qlcnic_update_cmd_producer(adapter, tx_ring); | 2286 | qlcnic_update_cmd_producer(adapter, tx_ring); |
1897 | 2287 | ||
@@ -1900,6 +2290,8 @@ qlcnic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
1900 | 2290 | ||
1901 | return NETDEV_TX_OK; | 2291 | return NETDEV_TX_OK; |
1902 | 2292 | ||
2293 | unwind_buff: | ||
2294 | qlcnic_unmap_buffers(pdev, skb, pbuf); | ||
1903 | drop_packet: | 2295 | drop_packet: |
1904 | adapter->stats.txdropped++; | 2296 | adapter->stats.txdropped++; |
1905 | dev_kfree_skb_any(skb); | 2297 | dev_kfree_skb_any(skb); |
@@ -1946,16 +2338,16 @@ void qlcnic_advert_link_change(struct qlcnic_adapter *adapter, int linkup) | |||
1946 | { | 2338 | { |
1947 | struct net_device *netdev = adapter->netdev; | 2339 | struct net_device *netdev = adapter->netdev; |
1948 | 2340 | ||
1949 | if (adapter->ahw.linkup && !linkup) { | 2341 | if (adapter->ahw->linkup && !linkup) { |
1950 | dev_info(&netdev->dev, "NIC Link is down\n"); | 2342 | netdev_info(netdev, "NIC Link is down\n"); |
1951 | adapter->ahw.linkup = 0; | 2343 | adapter->ahw->linkup = 0; |
1952 | if (netif_running(netdev)) { | 2344 | if (netif_running(netdev)) { |
1953 | netif_carrier_off(netdev); | 2345 | netif_carrier_off(netdev); |
1954 | netif_stop_queue(netdev); | 2346 | netif_stop_queue(netdev); |
1955 | } | 2347 | } |
1956 | } else if (!adapter->ahw.linkup && linkup) { | 2348 | } else if (!adapter->ahw->linkup && linkup) { |
1957 | dev_info(&netdev->dev, "NIC Link is up\n"); | 2349 | netdev_info(netdev, "NIC Link is up\n"); |
1958 | adapter->ahw.linkup = 1; | 2350 | adapter->ahw->linkup = 1; |
1959 | if (netif_running(netdev)) { | 2351 | if (netif_running(netdev)) { |
1960 | netif_carrier_on(netdev); | 2352 | netif_carrier_on(netdev); |
1961 | netif_wake_queue(netdev); | 2353 | netif_wake_queue(netdev); |
@@ -2191,7 +2583,7 @@ static void qlcnic_poll_controller(struct net_device *netdev) | |||
2191 | int ring; | 2583 | int ring; |
2192 | struct qlcnic_host_sds_ring *sds_ring; | 2584 | struct qlcnic_host_sds_ring *sds_ring; |
2193 | struct qlcnic_adapter *adapter = netdev_priv(netdev); | 2585 | struct qlcnic_adapter *adapter = netdev_priv(netdev); |
2194 | struct qlcnic_recv_context *recv_ctx = &adapter->recv_ctx; | 2586 | struct qlcnic_recv_context *recv_ctx = adapter->recv_ctx; |
2195 | 2587 | ||
2196 | disable_irq(adapter->irq); | 2588 | disable_irq(adapter->irq); |
2197 | for (ring = 0; ring < adapter->max_sds_rings; ring++) { | 2589 | for (ring = 0; ring < adapter->max_sds_rings; ring++) { |
@@ -2258,18 +2650,22 @@ qlcnic_clr_drv_state(struct qlcnic_adapter *adapter) | |||
2258 | } | 2650 | } |
2259 | 2651 | ||
2260 | static void | 2652 | static void |
2261 | qlcnic_clr_all_drv_state(struct qlcnic_adapter *adapter) | 2653 | qlcnic_clr_all_drv_state(struct qlcnic_adapter *adapter, u8 failed) |
2262 | { | 2654 | { |
2263 | u32 val; | 2655 | u32 val; |
2264 | 2656 | ||
2265 | if (qlcnic_api_lock(adapter)) | 2657 | if (qlcnic_api_lock(adapter)) |
2266 | goto err; | 2658 | goto err; |
2267 | 2659 | ||
2268 | val = QLCRD32(adapter, QLCNIC_CRB_DEV_REF_COUNT); | 2660 | val = QLCRD32(adapter, QLCNIC_CRB_DRV_ACTIVE); |
2269 | QLC_DEV_CLR_REF_CNT(val, adapter->portnum); | 2661 | QLC_DEV_CLR_REF_CNT(val, adapter->portnum); |
2270 | QLCWR32(adapter, QLCNIC_CRB_DEV_REF_COUNT, val); | 2662 | QLCWR32(adapter, QLCNIC_CRB_DRV_ACTIVE, val); |
2271 | 2663 | ||
2272 | if (!(val & 0x11111111)) | 2664 | if (failed) { |
2665 | QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_FAILED); | ||
2666 | dev_info(&adapter->pdev->dev, | ||
2667 | "Device state set to Failed. Please Reboot\n"); | ||
2668 | } else if (!(val & 0x11111111)) | ||
2273 | QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_COLD); | 2669 | QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_COLD); |
2274 | 2670 | ||
2275 | val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE); | 2671 | val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE); |
@@ -2290,7 +2686,7 @@ qlcnic_check_drv_state(struct qlcnic_adapter *adapter) | |||
2290 | int act, state; | 2686 | int act, state; |
2291 | 2687 | ||
2292 | state = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE); | 2688 | state = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE); |
2293 | act = QLCRD32(adapter, QLCNIC_CRB_DEV_REF_COUNT); | 2689 | act = QLCRD32(adapter, QLCNIC_CRB_DRV_ACTIVE); |
2294 | 2690 | ||
2295 | if (((state & 0x11111111) == (act & 0x11111111)) || | 2691 | if (((state & 0x11111111) == (act & 0x11111111)) || |
2296 | ((act & 0x11111111) == ((state >> 1) & 0x11111111))) | 2692 | ((act & 0x11111111) == ((state >> 1) & 0x11111111))) |
@@ -2325,10 +2721,10 @@ qlcnic_can_start_firmware(struct qlcnic_adapter *adapter) | |||
2325 | if (qlcnic_api_lock(adapter)) | 2721 | if (qlcnic_api_lock(adapter)) |
2326 | return -1; | 2722 | return -1; |
2327 | 2723 | ||
2328 | val = QLCRD32(adapter, QLCNIC_CRB_DEV_REF_COUNT); | 2724 | val = QLCRD32(adapter, QLCNIC_CRB_DRV_ACTIVE); |
2329 | if (!(val & (1 << (portnum * 4)))) { | 2725 | if (!(val & (1 << (portnum * 4)))) { |
2330 | QLC_DEV_SET_REF_CNT(val, portnum); | 2726 | QLC_DEV_SET_REF_CNT(val, portnum); |
2331 | QLCWR32(adapter, QLCNIC_CRB_DEV_REF_COUNT, val); | 2727 | QLCWR32(adapter, QLCNIC_CRB_DRV_ACTIVE, val); |
2332 | } | 2728 | } |
2333 | 2729 | ||
2334 | prev_state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE); | 2730 | prev_state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE); |
@@ -2403,13 +2799,14 @@ qlcnic_fwinit_work(struct work_struct *work) | |||
2403 | { | 2799 | { |
2404 | struct qlcnic_adapter *adapter = container_of(work, | 2800 | struct qlcnic_adapter *adapter = container_of(work, |
2405 | struct qlcnic_adapter, fw_work.work); | 2801 | struct qlcnic_adapter, fw_work.work); |
2406 | u32 dev_state = 0xf, npar_state; | 2802 | u32 dev_state = 0xf; |
2407 | 2803 | ||
2408 | if (qlcnic_api_lock(adapter)) | 2804 | if (qlcnic_api_lock(adapter)) |
2409 | goto err_ret; | 2805 | goto err_ret; |
2410 | 2806 | ||
2411 | dev_state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE); | 2807 | dev_state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE); |
2412 | if (dev_state == QLCNIC_DEV_QUISCENT) { | 2808 | if (dev_state == QLCNIC_DEV_QUISCENT || |
2809 | dev_state == QLCNIC_DEV_NEED_QUISCENT) { | ||
2413 | qlcnic_api_unlock(adapter); | 2810 | qlcnic_api_unlock(adapter); |
2414 | qlcnic_schedule_work(adapter, qlcnic_fwinit_work, | 2811 | qlcnic_schedule_work(adapter, qlcnic_fwinit_work, |
2415 | FW_POLL_DELAY * 2); | 2812 | FW_POLL_DELAY * 2); |
@@ -2417,16 +2814,8 @@ qlcnic_fwinit_work(struct work_struct *work) | |||
2417 | } | 2814 | } |
2418 | 2815 | ||
2419 | if (adapter->op_mode == QLCNIC_NON_PRIV_FUNC) { | 2816 | if (adapter->op_mode == QLCNIC_NON_PRIV_FUNC) { |
2420 | npar_state = QLCRD32(adapter, QLCNIC_CRB_DEV_NPAR_STATE); | 2817 | qlcnic_api_unlock(adapter); |
2421 | if (npar_state == QLCNIC_DEV_NPAR_RDY) { | 2818 | goto wait_npar; |
2422 | qlcnic_api_unlock(adapter); | ||
2423 | goto wait_npar; | ||
2424 | } else { | ||
2425 | qlcnic_schedule_work(adapter, qlcnic_fwinit_work, | ||
2426 | FW_POLL_DELAY); | ||
2427 | qlcnic_api_unlock(adapter); | ||
2428 | return; | ||
2429 | } | ||
2430 | } | 2819 | } |
2431 | 2820 | ||
2432 | if (adapter->fw_wait_cnt++ > adapter->reset_ack_timeo) { | 2821 | if (adapter->fw_wait_cnt++ > adapter->reset_ack_timeo) { |
@@ -2439,30 +2828,21 @@ qlcnic_fwinit_work(struct work_struct *work) | |||
2439 | skip_ack_check: | 2828 | skip_ack_check: |
2440 | dev_state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE); | 2829 | dev_state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE); |
2441 | 2830 | ||
2442 | if (dev_state == QLCNIC_DEV_NEED_QUISCENT) { | ||
2443 | QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, | ||
2444 | QLCNIC_DEV_QUISCENT); | ||
2445 | qlcnic_schedule_work(adapter, qlcnic_fwinit_work, | ||
2446 | FW_POLL_DELAY * 2); | ||
2447 | QLCDB(adapter, DRV, "Quiscing the driver\n"); | ||
2448 | qlcnic_idc_debug_info(adapter, 0); | ||
2449 | |||
2450 | qlcnic_api_unlock(adapter); | ||
2451 | return; | ||
2452 | } | ||
2453 | |||
2454 | if (dev_state == QLCNIC_DEV_NEED_RESET) { | 2831 | if (dev_state == QLCNIC_DEV_NEED_RESET) { |
2455 | QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, | 2832 | QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, |
2456 | QLCNIC_DEV_INITIALIZING); | 2833 | QLCNIC_DEV_INITIALIZING); |
2457 | set_bit(__QLCNIC_START_FW, &adapter->state); | 2834 | set_bit(__QLCNIC_START_FW, &adapter->state); |
2458 | QLCDB(adapter, DRV, "Restarting fw\n"); | 2835 | QLCDB(adapter, DRV, "Restarting fw\n"); |
2459 | qlcnic_idc_debug_info(adapter, 0); | 2836 | qlcnic_idc_debug_info(adapter, 0); |
2837 | QLCDB(adapter, DRV, "Take FW dump\n"); | ||
2838 | qlcnic_dump_fw(adapter); | ||
2460 | } | 2839 | } |
2461 | 2840 | ||
2462 | qlcnic_api_unlock(adapter); | 2841 | qlcnic_api_unlock(adapter); |
2463 | 2842 | ||
2464 | if (!adapter->nic_ops->start_firmware(adapter)) { | 2843 | if (!adapter->nic_ops->start_firmware(adapter)) { |
2465 | qlcnic_schedule_work(adapter, qlcnic_attach_work, 0); | 2844 | qlcnic_schedule_work(adapter, qlcnic_attach_work, 0); |
2845 | adapter->fw_wait_cnt = 0; | ||
2466 | return; | 2846 | return; |
2467 | } | 2847 | } |
2468 | goto err_ret; | 2848 | goto err_ret; |
@@ -2475,27 +2855,25 @@ wait_npar: | |||
2475 | QLCDB(adapter, HW, "Func waiting: Device state=%u\n", dev_state); | 2855 | QLCDB(adapter, HW, "Func waiting: Device state=%u\n", dev_state); |
2476 | 2856 | ||
2477 | switch (dev_state) { | 2857 | switch (dev_state) { |
2478 | case QLCNIC_DEV_QUISCENT: | 2858 | case QLCNIC_DEV_READY: |
2479 | case QLCNIC_DEV_NEED_QUISCENT: | ||
2480 | case QLCNIC_DEV_NEED_RESET: | ||
2481 | qlcnic_schedule_work(adapter, | ||
2482 | qlcnic_fwinit_work, FW_POLL_DELAY); | ||
2483 | return; | ||
2484 | case QLCNIC_DEV_FAILED: | ||
2485 | break; | ||
2486 | |||
2487 | default: | ||
2488 | if (!adapter->nic_ops->start_firmware(adapter)) { | 2859 | if (!adapter->nic_ops->start_firmware(adapter)) { |
2489 | qlcnic_schedule_work(adapter, qlcnic_attach_work, 0); | 2860 | qlcnic_schedule_work(adapter, qlcnic_attach_work, 0); |
2861 | adapter->fw_wait_cnt = 0; | ||
2490 | return; | 2862 | return; |
2491 | } | 2863 | } |
2864 | case QLCNIC_DEV_FAILED: | ||
2865 | break; | ||
2866 | default: | ||
2867 | qlcnic_schedule_work(adapter, | ||
2868 | qlcnic_fwinit_work, FW_POLL_DELAY); | ||
2869 | return; | ||
2492 | } | 2870 | } |
2493 | 2871 | ||
2494 | err_ret: | 2872 | err_ret: |
2495 | dev_err(&adapter->pdev->dev, "Fwinit work failed state=%u " | 2873 | dev_err(&adapter->pdev->dev, "Fwinit work failed state=%u " |
2496 | "fw_wait_cnt=%u\n", dev_state, adapter->fw_wait_cnt); | 2874 | "fw_wait_cnt=%u\n", dev_state, adapter->fw_wait_cnt); |
2497 | netif_device_attach(adapter->netdev); | 2875 | netif_device_attach(adapter->netdev); |
2498 | qlcnic_clr_all_drv_state(adapter); | 2876 | qlcnic_clr_all_drv_state(adapter, 0); |
2499 | } | 2877 | } |
2500 | 2878 | ||
2501 | static void | 2879 | static void |
@@ -2508,7 +2886,12 @@ qlcnic_detach_work(struct work_struct *work) | |||
2508 | 2886 | ||
2509 | netif_device_detach(netdev); | 2887 | netif_device_detach(netdev); |
2510 | 2888 | ||
2511 | qlcnic_down(adapter, netdev); | 2889 | /* Dont grab rtnl lock during Quiscent mode */ |
2890 | if (adapter->dev_state == QLCNIC_DEV_NEED_QUISCENT) { | ||
2891 | if (netif_running(netdev)) | ||
2892 | __qlcnic_down(adapter, netdev); | ||
2893 | } else | ||
2894 | qlcnic_down(adapter, netdev); | ||
2512 | 2895 | ||
2513 | status = QLCRD32(adapter, QLCNIC_PEG_HALT_STATUS1); | 2896 | status = QLCRD32(adapter, QLCNIC_PEG_HALT_STATUS1); |
2514 | 2897 | ||
@@ -2531,12 +2914,27 @@ err_ret: | |||
2531 | dev_err(&adapter->pdev->dev, "detach failed; status=%d temp=%d\n", | 2914 | dev_err(&adapter->pdev->dev, "detach failed; status=%d temp=%d\n", |
2532 | status, adapter->temp); | 2915 | status, adapter->temp); |
2533 | netif_device_attach(netdev); | 2916 | netif_device_attach(netdev); |
2534 | qlcnic_clr_all_drv_state(adapter); | 2917 | qlcnic_clr_all_drv_state(adapter, 1); |
2918 | } | ||
2919 | |||
2920 | /*Transit NPAR state to NON Operational */ | ||
2921 | static void | ||
2922 | qlcnic_set_npar_non_operational(struct qlcnic_adapter *adapter) | ||
2923 | { | ||
2924 | u32 state; | ||
2925 | |||
2926 | state = QLCRD32(adapter, QLCNIC_CRB_DEV_NPAR_STATE); | ||
2927 | if (state == QLCNIC_DEV_NPAR_NON_OPER) | ||
2928 | return; | ||
2535 | 2929 | ||
2930 | if (qlcnic_api_lock(adapter)) | ||
2931 | return; | ||
2932 | QLCWR32(adapter, QLCNIC_CRB_DEV_NPAR_STATE, QLCNIC_DEV_NPAR_NON_OPER); | ||
2933 | qlcnic_api_unlock(adapter); | ||
2536 | } | 2934 | } |
2537 | 2935 | ||
2538 | /*Transit to RESET state from READY state only */ | 2936 | /*Transit to RESET state from READY state only */ |
2539 | static void | 2937 | void |
2540 | qlcnic_dev_request_reset(struct qlcnic_adapter *adapter) | 2938 | qlcnic_dev_request_reset(struct qlcnic_adapter *adapter) |
2541 | { | 2939 | { |
2542 | u32 state; | 2940 | u32 state; |
@@ -2553,6 +2951,7 @@ qlcnic_dev_request_reset(struct qlcnic_adapter *adapter) | |||
2553 | qlcnic_idc_debug_info(adapter, 0); | 2951 | qlcnic_idc_debug_info(adapter, 0); |
2554 | } | 2952 | } |
2555 | 2953 | ||
2954 | QLCWR32(adapter, QLCNIC_CRB_DEV_NPAR_STATE, QLCNIC_DEV_NPAR_NON_OPER); | ||
2556 | qlcnic_api_unlock(adapter); | 2955 | qlcnic_api_unlock(adapter); |
2557 | } | 2956 | } |
2558 | 2957 | ||
@@ -2560,21 +2959,11 @@ qlcnic_dev_request_reset(struct qlcnic_adapter *adapter) | |||
2560 | static void | 2959 | static void |
2561 | qlcnic_dev_set_npar_ready(struct qlcnic_adapter *adapter) | 2960 | qlcnic_dev_set_npar_ready(struct qlcnic_adapter *adapter) |
2562 | { | 2961 | { |
2563 | u32 state; | ||
2564 | |||
2565 | if (!(adapter->flags & QLCNIC_ESWITCH_ENABLED) || | ||
2566 | adapter->op_mode == QLCNIC_NON_PRIV_FUNC) | ||
2567 | return; | ||
2568 | if (qlcnic_api_lock(adapter)) | 2962 | if (qlcnic_api_lock(adapter)) |
2569 | return; | 2963 | return; |
2570 | 2964 | ||
2571 | state = QLCRD32(adapter, QLCNIC_CRB_DEV_NPAR_STATE); | 2965 | QLCWR32(adapter, QLCNIC_CRB_DEV_NPAR_STATE, QLCNIC_DEV_NPAR_OPER); |
2572 | 2966 | QLCDB(adapter, DRV, "NPAR operational state set\n"); | |
2573 | if (state != QLCNIC_DEV_NPAR_RDY) { | ||
2574 | QLCWR32(adapter, QLCNIC_CRB_DEV_NPAR_STATE, | ||
2575 | QLCNIC_DEV_NPAR_RDY); | ||
2576 | QLCDB(adapter, DRV, "NPAR READY state set\n"); | ||
2577 | } | ||
2578 | 2967 | ||
2579 | qlcnic_api_unlock(adapter); | 2968 | qlcnic_api_unlock(adapter); |
2580 | } | 2969 | } |
@@ -2587,7 +2976,8 @@ qlcnic_schedule_work(struct qlcnic_adapter *adapter, | |||
2587 | return; | 2976 | return; |
2588 | 2977 | ||
2589 | INIT_DELAYED_WORK(&adapter->fw_work, func); | 2978 | INIT_DELAYED_WORK(&adapter->fw_work, func); |
2590 | schedule_delayed_work(&adapter->fw_work, round_jiffies_relative(delay)); | 2979 | queue_delayed_work(qlcnic_wq, &adapter->fw_work, |
2980 | round_jiffies_relative(delay)); | ||
2591 | } | 2981 | } |
2592 | 2982 | ||
2593 | static void | 2983 | static void |
@@ -2605,12 +2995,26 @@ qlcnic_attach_work(struct work_struct *work) | |||
2605 | struct qlcnic_adapter *adapter = container_of(work, | 2995 | struct qlcnic_adapter *adapter = container_of(work, |
2606 | struct qlcnic_adapter, fw_work.work); | 2996 | struct qlcnic_adapter, fw_work.work); |
2607 | struct net_device *netdev = adapter->netdev; | 2997 | struct net_device *netdev = adapter->netdev; |
2998 | u32 npar_state; | ||
2608 | 2999 | ||
3000 | if (adapter->op_mode != QLCNIC_MGMT_FUNC) { | ||
3001 | npar_state = QLCRD32(adapter, QLCNIC_CRB_DEV_NPAR_STATE); | ||
3002 | if (adapter->fw_wait_cnt++ > QLCNIC_DEV_NPAR_OPER_TIMEO) | ||
3003 | qlcnic_clr_all_drv_state(adapter, 0); | ||
3004 | else if (npar_state != QLCNIC_DEV_NPAR_OPER) | ||
3005 | qlcnic_schedule_work(adapter, qlcnic_attach_work, | ||
3006 | FW_POLL_DELAY); | ||
3007 | else | ||
3008 | goto attach; | ||
3009 | QLCDB(adapter, DRV, "Waiting for NPAR state to operational\n"); | ||
3010 | return; | ||
3011 | } | ||
3012 | attach: | ||
2609 | if (netif_running(netdev)) { | 3013 | if (netif_running(netdev)) { |
2610 | if (qlcnic_up(adapter, netdev)) | 3014 | if (qlcnic_up(adapter, netdev)) |
2611 | goto done; | 3015 | goto done; |
2612 | 3016 | ||
2613 | qlcnic_config_indev_addr(netdev, NETDEV_UP); | 3017 | qlcnic_restore_indev_addr(netdev, NETDEV_UP); |
2614 | } | 3018 | } |
2615 | 3019 | ||
2616 | done: | 3020 | done: |
@@ -2626,7 +3030,7 @@ done: | |||
2626 | static int | 3030 | static int |
2627 | qlcnic_check_health(struct qlcnic_adapter *adapter) | 3031 | qlcnic_check_health(struct qlcnic_adapter *adapter) |
2628 | { | 3032 | { |
2629 | u32 state = 0, heartbit; | 3033 | u32 state = 0, heartbeat; |
2630 | struct net_device *netdev = adapter->netdev; | 3034 | struct net_device *netdev = adapter->netdev; |
2631 | 3035 | ||
2632 | if (qlcnic_check_temp(adapter)) | 3036 | if (qlcnic_check_temp(adapter)) |
@@ -2636,18 +3040,20 @@ qlcnic_check_health(struct qlcnic_adapter *adapter) | |||
2636 | qlcnic_dev_request_reset(adapter); | 3040 | qlcnic_dev_request_reset(adapter); |
2637 | 3041 | ||
2638 | state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE); | 3042 | state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE); |
2639 | if (state == QLCNIC_DEV_NEED_RESET || state == QLCNIC_DEV_NEED_QUISCENT) | 3043 | if (state == QLCNIC_DEV_NEED_RESET) { |
3044 | qlcnic_set_npar_non_operational(adapter); | ||
2640 | adapter->need_fw_reset = 1; | 3045 | adapter->need_fw_reset = 1; |
3046 | } else if (state == QLCNIC_DEV_NEED_QUISCENT) | ||
3047 | goto detach; | ||
2641 | 3048 | ||
2642 | heartbit = QLCRD32(adapter, QLCNIC_PEG_ALIVE_COUNTER); | 3049 | heartbeat = QLCRD32(adapter, QLCNIC_PEG_ALIVE_COUNTER); |
2643 | if (heartbit != adapter->heartbit) { | 3050 | if (heartbeat != adapter->heartbeat) { |
2644 | adapter->heartbit = heartbit; | 3051 | adapter->heartbeat = heartbeat; |
2645 | adapter->fw_fail_cnt = 0; | 3052 | adapter->fw_fail_cnt = 0; |
2646 | if (adapter->need_fw_reset) | 3053 | if (adapter->need_fw_reset) |
2647 | goto detach; | 3054 | goto detach; |
2648 | 3055 | ||
2649 | if (adapter->reset_context && | 3056 | if (adapter->reset_context && auto_fw_reset) { |
2650 | auto_fw_reset == AUTO_FW_RESET_ENABLED) { | ||
2651 | qlcnic_reset_hw_context(adapter); | 3057 | qlcnic_reset_hw_context(adapter); |
2652 | adapter->netdev->trans_start = jiffies; | 3058 | adapter->netdev->trans_start = jiffies; |
2653 | } | 3059 | } |
@@ -2660,7 +3066,7 @@ qlcnic_check_health(struct qlcnic_adapter *adapter) | |||
2660 | 3066 | ||
2661 | qlcnic_dev_request_reset(adapter); | 3067 | qlcnic_dev_request_reset(adapter); |
2662 | 3068 | ||
2663 | if ((auto_fw_reset == AUTO_FW_RESET_ENABLED)) | 3069 | if (auto_fw_reset) |
2664 | clear_bit(__QLCNIC_FW_ATTACHED, &adapter->state); | 3070 | clear_bit(__QLCNIC_FW_ATTACHED, &adapter->state); |
2665 | 3071 | ||
2666 | dev_info(&netdev->dev, "firmware hang detected\n"); | 3072 | dev_info(&netdev->dev, "firmware hang detected\n"); |
@@ -2669,7 +3075,7 @@ detach: | |||
2669 | adapter->dev_state = (state == QLCNIC_DEV_NEED_QUISCENT) ? state : | 3075 | adapter->dev_state = (state == QLCNIC_DEV_NEED_QUISCENT) ? state : |
2670 | QLCNIC_DEV_NEED_RESET; | 3076 | QLCNIC_DEV_NEED_RESET; |
2671 | 3077 | ||
2672 | if ((auto_fw_reset == AUTO_FW_RESET_ENABLED) && | 3078 | if (auto_fw_reset && |
2673 | !test_and_set_bit(__QLCNIC_RESETTING, &adapter->state)) { | 3079 | !test_and_set_bit(__QLCNIC_RESETTING, &adapter->state)) { |
2674 | 3080 | ||
2675 | qlcnic_schedule_work(adapter, qlcnic_detach_work, 0); | 3081 | qlcnic_schedule_work(adapter, qlcnic_detach_work, 0); |
@@ -2692,6 +3098,9 @@ qlcnic_fw_poll_work(struct work_struct *work) | |||
2692 | if (qlcnic_check_health(adapter)) | 3098 | if (qlcnic_check_health(adapter)) |
2693 | return; | 3099 | return; |
2694 | 3100 | ||
3101 | if (adapter->fhash.fnum) | ||
3102 | qlcnic_prune_lb_filters(adapter); | ||
3103 | |||
2695 | reschedule: | 3104 | reschedule: |
2696 | qlcnic_schedule_work(adapter, qlcnic_fw_poll_work, FW_POLL_DELAY); | 3105 | qlcnic_schedule_work(adapter, qlcnic_fw_poll_work, FW_POLL_DELAY); |
2697 | } | 3106 | } |
@@ -2738,7 +3147,7 @@ static int qlcnic_attach_func(struct pci_dev *pdev) | |||
2738 | if (qlcnic_api_lock(adapter)) | 3147 | if (qlcnic_api_lock(adapter)) |
2739 | return -EINVAL; | 3148 | return -EINVAL; |
2740 | 3149 | ||
2741 | if (first_func) { | 3150 | if (adapter->op_mode != QLCNIC_NON_PRIV_FUNC && first_func) { |
2742 | adapter->need_fw_reset = 1; | 3151 | adapter->need_fw_reset = 1; |
2743 | set_bit(__QLCNIC_START_FW, &adapter->state); | 3152 | set_bit(__QLCNIC_START_FW, &adapter->state); |
2744 | QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_INITIALIZING); | 3153 | QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_INITIALIZING); |
@@ -2756,7 +3165,7 @@ static int qlcnic_attach_func(struct pci_dev *pdev) | |||
2756 | if (netif_running(netdev)) { | 3165 | if (netif_running(netdev)) { |
2757 | err = qlcnic_attach(adapter); | 3166 | err = qlcnic_attach(adapter); |
2758 | if (err) { | 3167 | if (err) { |
2759 | qlcnic_clr_all_drv_state(adapter); | 3168 | qlcnic_clr_all_drv_state(adapter, 1); |
2760 | clear_bit(__QLCNIC_AER, &adapter->state); | 3169 | clear_bit(__QLCNIC_AER, &adapter->state); |
2761 | netif_device_attach(netdev); | 3170 | netif_device_attach(netdev); |
2762 | return err; | 3171 | return err; |
@@ -2766,7 +3175,7 @@ static int qlcnic_attach_func(struct pci_dev *pdev) | |||
2766 | if (err) | 3175 | if (err) |
2767 | goto done; | 3176 | goto done; |
2768 | 3177 | ||
2769 | qlcnic_config_indev_addr(netdev, NETDEV_UP); | 3178 | qlcnic_restore_indev_addr(netdev, NETDEV_UP); |
2770 | } | 3179 | } |
2771 | done: | 3180 | done: |
2772 | netif_device_attach(netdev); | 3181 | netif_device_attach(netdev); |
@@ -2822,7 +3231,6 @@ static void qlcnic_io_resume(struct pci_dev *pdev) | |||
2822 | FW_POLL_DELAY); | 3231 | FW_POLL_DELAY); |
2823 | } | 3232 | } |
2824 | 3233 | ||
2825 | |||
2826 | static int | 3234 | static int |
2827 | qlcnicvf_start_firmware(struct qlcnic_adapter *adapter) | 3235 | qlcnicvf_start_firmware(struct qlcnic_adapter *adapter) |
2828 | { | 3236 | { |
@@ -2832,8 +3240,20 @@ qlcnicvf_start_firmware(struct qlcnic_adapter *adapter) | |||
2832 | if (err) | 3240 | if (err) |
2833 | return err; | 3241 | return err; |
2834 | 3242 | ||
3243 | err = qlcnic_check_npar_opertional(adapter); | ||
3244 | if (err) | ||
3245 | return err; | ||
3246 | |||
3247 | err = qlcnic_initialize_nic(adapter); | ||
3248 | if (err) | ||
3249 | return err; | ||
3250 | |||
2835 | qlcnic_check_options(adapter); | 3251 | qlcnic_check_options(adapter); |
2836 | 3252 | ||
3253 | err = qlcnic_set_eswitch_port_config(adapter); | ||
3254 | if (err) | ||
3255 | return err; | ||
3256 | |||
2837 | adapter->need_fw_reset = 0; | 3257 | adapter->need_fw_reset = 0; |
2838 | 3258 | ||
2839 | return err; | 3259 | return err; |
@@ -2926,6 +3346,56 @@ static struct device_attribute dev_attr_diag_mode = { | |||
2926 | .store = qlcnic_store_diag_mode, | 3346 | .store = qlcnic_store_diag_mode, |
2927 | }; | 3347 | }; |
2928 | 3348 | ||
3349 | int qlcnic_validate_max_rss(struct net_device *netdev, u8 max_hw, u8 val) | ||
3350 | { | ||
3351 | if (!use_msi_x && !use_msi) { | ||
3352 | netdev_info(netdev, "no msix or msi support, hence no rss\n"); | ||
3353 | return -EINVAL; | ||
3354 | } | ||
3355 | |||
3356 | if ((val > max_hw) || (val < 2) || !is_power_of_2(val)) { | ||
3357 | netdev_info(netdev, "rss_ring valid range [2 - %x] in " | ||
3358 | " powers of 2\n", max_hw); | ||
3359 | return -EINVAL; | ||
3360 | } | ||
3361 | return 0; | ||
3362 | |||
3363 | } | ||
3364 | |||
3365 | int qlcnic_set_max_rss(struct qlcnic_adapter *adapter, u8 data) | ||
3366 | { | ||
3367 | struct net_device *netdev = adapter->netdev; | ||
3368 | int err = 0; | ||
3369 | |||
3370 | if (test_and_set_bit(__QLCNIC_RESETTING, &adapter->state)) | ||
3371 | return -EBUSY; | ||
3372 | |||
3373 | netif_device_detach(netdev); | ||
3374 | if (netif_running(netdev)) | ||
3375 | __qlcnic_down(adapter, netdev); | ||
3376 | qlcnic_detach(adapter); | ||
3377 | qlcnic_teardown_intr(adapter); | ||
3378 | |||
3379 | if (qlcnic_enable_msix(adapter, data)) { | ||
3380 | netdev_info(netdev, "failed setting max_rss; rss disabled\n"); | ||
3381 | qlcnic_enable_msi_legacy(adapter); | ||
3382 | } | ||
3383 | |||
3384 | if (netif_running(netdev)) { | ||
3385 | err = qlcnic_attach(adapter); | ||
3386 | if (err) | ||
3387 | goto done; | ||
3388 | err = __qlcnic_up(adapter, netdev); | ||
3389 | if (err) | ||
3390 | goto done; | ||
3391 | qlcnic_restore_indev_addr(netdev, NETDEV_UP); | ||
3392 | } | ||
3393 | done: | ||
3394 | netif_device_attach(netdev); | ||
3395 | clear_bit(__QLCNIC_RESETTING, &adapter->state); | ||
3396 | return err; | ||
3397 | } | ||
3398 | |||
2929 | static int | 3399 | static int |
2930 | qlcnic_sysfs_validate_crb(struct qlcnic_adapter *adapter, | 3400 | qlcnic_sysfs_validate_crb(struct qlcnic_adapter *adapter, |
2931 | loff_t offset, size_t size) | 3401 | loff_t offset, size_t size) |
@@ -3056,7 +3526,6 @@ qlcnic_sysfs_write_mem(struct file *filp, struct kobject *kobj, | |||
3056 | return size; | 3526 | return size; |
3057 | } | 3527 | } |
3058 | 3528 | ||
3059 | |||
3060 | static struct bin_attribute bin_attr_crb = { | 3529 | static struct bin_attribute bin_attr_crb = { |
3061 | .attr = {.name = "crb", .mode = (S_IRUGO | S_IWUSR)}, | 3530 | .attr = {.name = "crb", .mode = (S_IRUGO | S_IWUSR)}, |
3062 | .size = 0, | 3531 | .size = 0, |
@@ -3093,9 +3562,6 @@ validate_pm_config(struct qlcnic_adapter *adapter, | |||
3093 | if (adapter->npars[dest_pci_func].type != QLCNIC_TYPE_NIC) | 3562 | if (adapter->npars[dest_pci_func].type != QLCNIC_TYPE_NIC) |
3094 | return QL_STATUS_INVALID_PARAM; | 3563 | return QL_STATUS_INVALID_PARAM; |
3095 | 3564 | ||
3096 | if (!IS_VALID_MODE(pm_cfg[i].action)) | ||
3097 | return QL_STATUS_INVALID_PARAM; | ||
3098 | |||
3099 | s_esw_id = adapter->npars[src_pci_func].phy_port; | 3565 | s_esw_id = adapter->npars[src_pci_func].phy_port; |
3100 | d_esw_id = adapter->npars[dest_pci_func].phy_port; | 3566 | d_esw_id = adapter->npars[dest_pci_func].phy_port; |
3101 | 3567 | ||
@@ -3129,7 +3595,7 @@ qlcnic_sysfs_write_pm_config(struct file *filp, struct kobject *kobj, | |||
3129 | return ret; | 3595 | return ret; |
3130 | for (i = 0; i < count; i++) { | 3596 | for (i = 0; i < count; i++) { |
3131 | pci_func = pm_cfg[i].pci_func; | 3597 | pci_func = pm_cfg[i].pci_func; |
3132 | action = pm_cfg[i].action; | 3598 | action = !!pm_cfg[i].action; |
3133 | id = adapter->npars[pci_func].phy_port; | 3599 | id = adapter->npars[pci_func].phy_port; |
3134 | ret = qlcnic_config_port_mirroring(adapter, id, | 3600 | ret = qlcnic_config_port_mirroring(adapter, id, |
3135 | action, pci_func); | 3601 | action, pci_func); |
@@ -3140,7 +3606,7 @@ qlcnic_sysfs_write_pm_config(struct file *filp, struct kobject *kobj, | |||
3140 | for (i = 0; i < count; i++) { | 3606 | for (i = 0; i < count; i++) { |
3141 | pci_func = pm_cfg[i].pci_func; | 3607 | pci_func = pm_cfg[i].pci_func; |
3142 | id = adapter->npars[pci_func].phy_port; | 3608 | id = adapter->npars[pci_func].phy_port; |
3143 | adapter->npars[pci_func].enable_pm = pm_cfg[i].action; | 3609 | adapter->npars[pci_func].enable_pm = !!pm_cfg[i].action; |
3144 | adapter->npars[pci_func].dest_npar = id; | 3610 | adapter->npars[pci_func].dest_npar = id; |
3145 | } | 3611 | } |
3146 | return size; | 3612 | return size; |
@@ -3172,30 +3638,49 @@ qlcnic_sysfs_read_pm_config(struct file *filp, struct kobject *kobj, | |||
3172 | 3638 | ||
3173 | static int | 3639 | static int |
3174 | validate_esw_config(struct qlcnic_adapter *adapter, | 3640 | validate_esw_config(struct qlcnic_adapter *adapter, |
3175 | struct qlcnic_esw_func_cfg *esw_cfg, int count) | 3641 | struct qlcnic_esw_func_cfg *esw_cfg, int count) |
3176 | { | 3642 | { |
3643 | u32 op_mode; | ||
3177 | u8 pci_func; | 3644 | u8 pci_func; |
3178 | int i; | 3645 | int i; |
3179 | 3646 | ||
3647 | op_mode = readl(adapter->ahw->pci_base0 + QLCNIC_DRV_OP_MODE); | ||
3648 | |||
3180 | for (i = 0; i < count; i++) { | 3649 | for (i = 0; i < count; i++) { |
3181 | pci_func = esw_cfg[i].pci_func; | 3650 | pci_func = esw_cfg[i].pci_func; |
3182 | if (pci_func >= QLCNIC_MAX_PCI_FUNC) | 3651 | if (pci_func >= QLCNIC_MAX_PCI_FUNC) |
3183 | return QL_STATUS_INVALID_PARAM; | 3652 | return QL_STATUS_INVALID_PARAM; |
3184 | 3653 | ||
3185 | if (adapter->npars[i].type != QLCNIC_TYPE_NIC) | 3654 | if (adapter->op_mode == QLCNIC_MGMT_FUNC) |
3186 | return QL_STATUS_INVALID_PARAM; | 3655 | if (adapter->npars[pci_func].type != QLCNIC_TYPE_NIC) |
3656 | return QL_STATUS_INVALID_PARAM; | ||
3187 | 3657 | ||
3188 | if (esw_cfg->host_vlan_tag == 1) | 3658 | switch (esw_cfg[i].op_mode) { |
3659 | case QLCNIC_PORT_DEFAULTS: | ||
3660 | if (QLC_DEV_GET_DRV(op_mode, pci_func) != | ||
3661 | QLCNIC_NON_PRIV_FUNC) { | ||
3662 | if (esw_cfg[i].mac_anti_spoof != 0) | ||
3663 | return QL_STATUS_INVALID_PARAM; | ||
3664 | if (esw_cfg[i].mac_override != 1) | ||
3665 | return QL_STATUS_INVALID_PARAM; | ||
3666 | if (esw_cfg[i].promisc_mode != 1) | ||
3667 | return QL_STATUS_INVALID_PARAM; | ||
3668 | } | ||
3669 | break; | ||
3670 | case QLCNIC_ADD_VLAN: | ||
3189 | if (!IS_VALID_VLAN(esw_cfg[i].vlan_id)) | 3671 | if (!IS_VALID_VLAN(esw_cfg[i].vlan_id)) |
3190 | return QL_STATUS_INVALID_PARAM; | 3672 | return QL_STATUS_INVALID_PARAM; |
3191 | 3673 | if (!esw_cfg[i].op_type) | |
3192 | if (!IS_VALID_MODE(esw_cfg[i].promisc_mode) | 3674 | return QL_STATUS_INVALID_PARAM; |
3193 | || !IS_VALID_MODE(esw_cfg[i].host_vlan_tag) | 3675 | break; |
3194 | || !IS_VALID_MODE(esw_cfg[i].mac_learning) | 3676 | case QLCNIC_DEL_VLAN: |
3195 | || !IS_VALID_MODE(esw_cfg[i].discard_tagged)) | 3677 | if (!esw_cfg[i].op_type) |
3678 | return QL_STATUS_INVALID_PARAM; | ||
3679 | break; | ||
3680 | default: | ||
3196 | return QL_STATUS_INVALID_PARAM; | 3681 | return QL_STATUS_INVALID_PARAM; |
3682 | } | ||
3197 | } | 3683 | } |
3198 | |||
3199 | return 0; | 3684 | return 0; |
3200 | } | 3685 | } |
3201 | 3686 | ||
@@ -3206,8 +3691,9 @@ qlcnic_sysfs_write_esw_config(struct file *file, struct kobject *kobj, | |||
3206 | struct device *dev = container_of(kobj, struct device, kobj); | 3691 | struct device *dev = container_of(kobj, struct device, kobj); |
3207 | struct qlcnic_adapter *adapter = dev_get_drvdata(dev); | 3692 | struct qlcnic_adapter *adapter = dev_get_drvdata(dev); |
3208 | struct qlcnic_esw_func_cfg *esw_cfg; | 3693 | struct qlcnic_esw_func_cfg *esw_cfg; |
3694 | struct qlcnic_npar_info *npar; | ||
3209 | int count, rem, i, ret; | 3695 | int count, rem, i, ret; |
3210 | u8 id, pci_func; | 3696 | u8 pci_func, op_mode = 0; |
3211 | 3697 | ||
3212 | count = size / sizeof(struct qlcnic_esw_func_cfg); | 3698 | count = size / sizeof(struct qlcnic_esw_func_cfg); |
3213 | rem = size % sizeof(struct qlcnic_esw_func_cfg); | 3699 | rem = size % sizeof(struct qlcnic_esw_func_cfg); |
@@ -3220,30 +3706,55 @@ qlcnic_sysfs_write_esw_config(struct file *file, struct kobject *kobj, | |||
3220 | return ret; | 3706 | return ret; |
3221 | 3707 | ||
3222 | for (i = 0; i < count; i++) { | 3708 | for (i = 0; i < count; i++) { |
3223 | pci_func = esw_cfg[i].pci_func; | 3709 | if (adapter->op_mode == QLCNIC_MGMT_FUNC) |
3224 | id = adapter->npars[pci_func].phy_port; | 3710 | if (qlcnic_config_switch_port(adapter, &esw_cfg[i])) |
3225 | ret = qlcnic_config_switch_port(adapter, id, | 3711 | return QL_STATUS_INVALID_PARAM; |
3226 | esw_cfg[i].host_vlan_tag, | 3712 | |
3227 | esw_cfg[i].discard_tagged, | 3713 | if (adapter->ahw->pci_func != esw_cfg[i].pci_func) |
3228 | esw_cfg[i].promisc_mode, | 3714 | continue; |
3229 | esw_cfg[i].mac_learning, | 3715 | |
3230 | esw_cfg[i].pci_func, | 3716 | op_mode = esw_cfg[i].op_mode; |
3231 | esw_cfg[i].vlan_id); | 3717 | qlcnic_get_eswitch_port_config(adapter, &esw_cfg[i]); |
3232 | if (ret) | 3718 | esw_cfg[i].op_mode = op_mode; |
3233 | return ret; | 3719 | esw_cfg[i].pci_func = adapter->ahw->pci_func; |
3720 | |||
3721 | switch (esw_cfg[i].op_mode) { | ||
3722 | case QLCNIC_PORT_DEFAULTS: | ||
3723 | qlcnic_set_eswitch_port_features(adapter, &esw_cfg[i]); | ||
3724 | break; | ||
3725 | case QLCNIC_ADD_VLAN: | ||
3726 | qlcnic_set_vlan_config(adapter, &esw_cfg[i]); | ||
3727 | break; | ||
3728 | case QLCNIC_DEL_VLAN: | ||
3729 | esw_cfg[i].vlan_id = 0; | ||
3730 | qlcnic_set_vlan_config(adapter, &esw_cfg[i]); | ||
3731 | break; | ||
3732 | } | ||
3234 | } | 3733 | } |
3235 | 3734 | ||
3735 | if (adapter->op_mode != QLCNIC_MGMT_FUNC) | ||
3736 | goto out; | ||
3737 | |||
3236 | for (i = 0; i < count; i++) { | 3738 | for (i = 0; i < count; i++) { |
3237 | pci_func = esw_cfg[i].pci_func; | 3739 | pci_func = esw_cfg[i].pci_func; |
3238 | adapter->npars[pci_func].promisc_mode = esw_cfg[i].promisc_mode; | 3740 | npar = &adapter->npars[pci_func]; |
3239 | adapter->npars[pci_func].mac_learning = esw_cfg[i].mac_learning; | 3741 | switch (esw_cfg[i].op_mode) { |
3240 | adapter->npars[pci_func].vlan_id = esw_cfg[i].vlan_id; | 3742 | case QLCNIC_PORT_DEFAULTS: |
3241 | adapter->npars[pci_func].discard_tagged = | 3743 | npar->promisc_mode = esw_cfg[i].promisc_mode; |
3242 | esw_cfg[i].discard_tagged; | 3744 | npar->mac_override = esw_cfg[i].mac_override; |
3243 | adapter->npars[pci_func].host_vlan_tag = | 3745 | npar->offload_flags = esw_cfg[i].offload_flags; |
3244 | esw_cfg[i].host_vlan_tag; | 3746 | npar->mac_anti_spoof = esw_cfg[i].mac_anti_spoof; |
3747 | npar->discard_tagged = esw_cfg[i].discard_tagged; | ||
3748 | break; | ||
3749 | case QLCNIC_ADD_VLAN: | ||
3750 | npar->pvid = esw_cfg[i].vlan_id; | ||
3751 | break; | ||
3752 | case QLCNIC_DEL_VLAN: | ||
3753 | npar->pvid = 0; | ||
3754 | break; | ||
3755 | } | ||
3245 | } | 3756 | } |
3246 | 3757 | out: | |
3247 | return size; | 3758 | return size; |
3248 | } | 3759 | } |
3249 | 3760 | ||
@@ -3254,7 +3765,7 @@ qlcnic_sysfs_read_esw_config(struct file *file, struct kobject *kobj, | |||
3254 | struct device *dev = container_of(kobj, struct device, kobj); | 3765 | struct device *dev = container_of(kobj, struct device, kobj); |
3255 | struct qlcnic_adapter *adapter = dev_get_drvdata(dev); | 3766 | struct qlcnic_adapter *adapter = dev_get_drvdata(dev); |
3256 | struct qlcnic_esw_func_cfg esw_cfg[QLCNIC_MAX_PCI_FUNC]; | 3767 | struct qlcnic_esw_func_cfg esw_cfg[QLCNIC_MAX_PCI_FUNC]; |
3257 | int i; | 3768 | u8 i; |
3258 | 3769 | ||
3259 | if (size != sizeof(esw_cfg)) | 3770 | if (size != sizeof(esw_cfg)) |
3260 | return QL_STATUS_INVALID_PARAM; | 3771 | return QL_STATUS_INVALID_PARAM; |
@@ -3262,12 +3773,9 @@ qlcnic_sysfs_read_esw_config(struct file *file, struct kobject *kobj, | |||
3262 | for (i = 0; i < QLCNIC_MAX_PCI_FUNC; i++) { | 3773 | for (i = 0; i < QLCNIC_MAX_PCI_FUNC; i++) { |
3263 | if (adapter->npars[i].type != QLCNIC_TYPE_NIC) | 3774 | if (adapter->npars[i].type != QLCNIC_TYPE_NIC) |
3264 | continue; | 3775 | continue; |
3265 | 3776 | esw_cfg[i].pci_func = i; | |
3266 | esw_cfg[i].host_vlan_tag = adapter->npars[i].host_vlan_tag; | 3777 | if (qlcnic_get_eswitch_port_config(adapter, &esw_cfg[i])) |
3267 | esw_cfg[i].promisc_mode = adapter->npars[i].promisc_mode; | 3778 | return QL_STATUS_INVALID_PARAM; |
3268 | esw_cfg[i].discard_tagged = adapter->npars[i].discard_tagged; | ||
3269 | esw_cfg[i].vlan_id = adapter->npars[i].vlan_id; | ||
3270 | esw_cfg[i].mac_learning = adapter->npars[i].mac_learning; | ||
3271 | } | 3779 | } |
3272 | memcpy(buf, &esw_cfg, size); | 3780 | memcpy(buf, &esw_cfg, size); |
3273 | 3781 | ||
@@ -3288,10 +3796,8 @@ validate_npar_config(struct qlcnic_adapter *adapter, | |||
3288 | if (adapter->npars[pci_func].type != QLCNIC_TYPE_NIC) | 3796 | if (adapter->npars[pci_func].type != QLCNIC_TYPE_NIC) |
3289 | return QL_STATUS_INVALID_PARAM; | 3797 | return QL_STATUS_INVALID_PARAM; |
3290 | 3798 | ||
3291 | if (!IS_VALID_BW(np_cfg[i].min_bw) | 3799 | if (!IS_VALID_BW(np_cfg[i].min_bw) || |
3292 | || !IS_VALID_BW(np_cfg[i].max_bw) | 3800 | !IS_VALID_BW(np_cfg[i].max_bw)) |
3293 | || !IS_VALID_RX_QUEUES(np_cfg[i].max_rx_queues) | ||
3294 | || !IS_VALID_TX_QUEUES(np_cfg[i].max_tx_queues)) | ||
3295 | return QL_STATUS_INVALID_PARAM; | 3801 | return QL_STATUS_INVALID_PARAM; |
3296 | } | 3802 | } |
3297 | return 0; | 3803 | return 0; |
@@ -3357,7 +3863,7 @@ qlcnic_sysfs_read_npar_config(struct file *file, struct kobject *kobj, | |||
3357 | return ret; | 3863 | return ret; |
3358 | 3864 | ||
3359 | np_cfg[i].pci_func = i; | 3865 | np_cfg[i].pci_func = i; |
3360 | np_cfg[i].op_mode = nic_info.op_mode; | 3866 | np_cfg[i].op_mode = (u8)nic_info.op_mode; |
3361 | np_cfg[i].port_num = nic_info.phys_port; | 3867 | np_cfg[i].port_num = nic_info.phys_port; |
3362 | np_cfg[i].fw_capab = nic_info.capabilities; | 3868 | np_cfg[i].fw_capab = nic_info.capabilities; |
3363 | np_cfg[i].min_bw = nic_info.min_tx_bw ; | 3869 | np_cfg[i].min_bw = nic_info.min_tx_bw ; |
@@ -3370,6 +3876,115 @@ qlcnic_sysfs_read_npar_config(struct file *file, struct kobject *kobj, | |||
3370 | } | 3876 | } |
3371 | 3877 | ||
3372 | static ssize_t | 3878 | static ssize_t |
3879 | qlcnic_sysfs_get_port_stats(struct file *file, struct kobject *kobj, | ||
3880 | struct bin_attribute *attr, char *buf, loff_t offset, size_t size) | ||
3881 | { | ||
3882 | struct device *dev = container_of(kobj, struct device, kobj); | ||
3883 | struct qlcnic_adapter *adapter = dev_get_drvdata(dev); | ||
3884 | struct qlcnic_esw_statistics port_stats; | ||
3885 | int ret; | ||
3886 | |||
3887 | if (size != sizeof(struct qlcnic_esw_statistics)) | ||
3888 | return QL_STATUS_INVALID_PARAM; | ||
3889 | |||
3890 | if (offset >= QLCNIC_MAX_PCI_FUNC) | ||
3891 | return QL_STATUS_INVALID_PARAM; | ||
3892 | |||
3893 | memset(&port_stats, 0, size); | ||
3894 | ret = qlcnic_get_port_stats(adapter, offset, QLCNIC_QUERY_RX_COUNTER, | ||
3895 | &port_stats.rx); | ||
3896 | if (ret) | ||
3897 | return ret; | ||
3898 | |||
3899 | ret = qlcnic_get_port_stats(adapter, offset, QLCNIC_QUERY_TX_COUNTER, | ||
3900 | &port_stats.tx); | ||
3901 | if (ret) | ||
3902 | return ret; | ||
3903 | |||
3904 | memcpy(buf, &port_stats, size); | ||
3905 | return size; | ||
3906 | } | ||
3907 | |||
3908 | static ssize_t | ||
3909 | qlcnic_sysfs_get_esw_stats(struct file *file, struct kobject *kobj, | ||
3910 | struct bin_attribute *attr, char *buf, loff_t offset, size_t size) | ||
3911 | { | ||
3912 | struct device *dev = container_of(kobj, struct device, kobj); | ||
3913 | struct qlcnic_adapter *adapter = dev_get_drvdata(dev); | ||
3914 | struct qlcnic_esw_statistics esw_stats; | ||
3915 | int ret; | ||
3916 | |||
3917 | if (size != sizeof(struct qlcnic_esw_statistics)) | ||
3918 | return QL_STATUS_INVALID_PARAM; | ||
3919 | |||
3920 | if (offset >= QLCNIC_NIU_MAX_XG_PORTS) | ||
3921 | return QL_STATUS_INVALID_PARAM; | ||
3922 | |||
3923 | memset(&esw_stats, 0, size); | ||
3924 | ret = qlcnic_get_eswitch_stats(adapter, offset, QLCNIC_QUERY_RX_COUNTER, | ||
3925 | &esw_stats.rx); | ||
3926 | if (ret) | ||
3927 | return ret; | ||
3928 | |||
3929 | ret = qlcnic_get_eswitch_stats(adapter, offset, QLCNIC_QUERY_TX_COUNTER, | ||
3930 | &esw_stats.tx); | ||
3931 | if (ret) | ||
3932 | return ret; | ||
3933 | |||
3934 | memcpy(buf, &esw_stats, size); | ||
3935 | return size; | ||
3936 | } | ||
3937 | |||
3938 | static ssize_t | ||
3939 | qlcnic_sysfs_clear_esw_stats(struct file *file, struct kobject *kobj, | ||
3940 | struct bin_attribute *attr, char *buf, loff_t offset, size_t size) | ||
3941 | { | ||
3942 | struct device *dev = container_of(kobj, struct device, kobj); | ||
3943 | struct qlcnic_adapter *adapter = dev_get_drvdata(dev); | ||
3944 | int ret; | ||
3945 | |||
3946 | if (offset >= QLCNIC_NIU_MAX_XG_PORTS) | ||
3947 | return QL_STATUS_INVALID_PARAM; | ||
3948 | |||
3949 | ret = qlcnic_clear_esw_stats(adapter, QLCNIC_STATS_ESWITCH, offset, | ||
3950 | QLCNIC_QUERY_RX_COUNTER); | ||
3951 | if (ret) | ||
3952 | return ret; | ||
3953 | |||
3954 | ret = qlcnic_clear_esw_stats(adapter, QLCNIC_STATS_ESWITCH, offset, | ||
3955 | QLCNIC_QUERY_TX_COUNTER); | ||
3956 | if (ret) | ||
3957 | return ret; | ||
3958 | |||
3959 | return size; | ||
3960 | } | ||
3961 | |||
3962 | static ssize_t | ||
3963 | qlcnic_sysfs_clear_port_stats(struct file *file, struct kobject *kobj, | ||
3964 | struct bin_attribute *attr, char *buf, loff_t offset, size_t size) | ||
3965 | { | ||
3966 | |||
3967 | struct device *dev = container_of(kobj, struct device, kobj); | ||
3968 | struct qlcnic_adapter *adapter = dev_get_drvdata(dev); | ||
3969 | int ret; | ||
3970 | |||
3971 | if (offset >= QLCNIC_MAX_PCI_FUNC) | ||
3972 | return QL_STATUS_INVALID_PARAM; | ||
3973 | |||
3974 | ret = qlcnic_clear_esw_stats(adapter, QLCNIC_STATS_PORT, offset, | ||
3975 | QLCNIC_QUERY_RX_COUNTER); | ||
3976 | if (ret) | ||
3977 | return ret; | ||
3978 | |||
3979 | ret = qlcnic_clear_esw_stats(adapter, QLCNIC_STATS_PORT, offset, | ||
3980 | QLCNIC_QUERY_TX_COUNTER); | ||
3981 | if (ret) | ||
3982 | return ret; | ||
3983 | |||
3984 | return size; | ||
3985 | } | ||
3986 | |||
3987 | static ssize_t | ||
3373 | qlcnic_sysfs_read_pci_config(struct file *file, struct kobject *kobj, | 3988 | qlcnic_sysfs_read_pci_config(struct file *file, struct kobject *kobj, |
3374 | struct bin_attribute *attr, char *buf, loff_t offset, size_t size) | 3989 | struct bin_attribute *attr, char *buf, loff_t offset, size_t size) |
3375 | { | 3990 | { |
@@ -3418,6 +4033,20 @@ static struct bin_attribute bin_attr_pci_config = { | |||
3418 | .write = NULL, | 4033 | .write = NULL, |
3419 | }; | 4034 | }; |
3420 | 4035 | ||
4036 | static struct bin_attribute bin_attr_port_stats = { | ||
4037 | .attr = {.name = "port_stats", .mode = (S_IRUGO | S_IWUSR)}, | ||
4038 | .size = 0, | ||
4039 | .read = qlcnic_sysfs_get_port_stats, | ||
4040 | .write = qlcnic_sysfs_clear_port_stats, | ||
4041 | }; | ||
4042 | |||
4043 | static struct bin_attribute bin_attr_esw_stats = { | ||
4044 | .attr = {.name = "esw_stats", .mode = (S_IRUGO | S_IWUSR)}, | ||
4045 | .size = 0, | ||
4046 | .read = qlcnic_sysfs_get_esw_stats, | ||
4047 | .write = qlcnic_sysfs_clear_esw_stats, | ||
4048 | }; | ||
4049 | |||
3421 | static struct bin_attribute bin_attr_esw_config = { | 4050 | static struct bin_attribute bin_attr_esw_config = { |
3422 | .attr = {.name = "esw_config", .mode = (S_IRUGO | S_IWUSR)}, | 4051 | .attr = {.name = "esw_config", .mode = (S_IRUGO | S_IWUSR)}, |
3423 | .size = 0, | 4052 | .size = 0, |
@@ -3457,6 +4086,9 @@ qlcnic_create_diag_entries(struct qlcnic_adapter *adapter) | |||
3457 | { | 4086 | { |
3458 | struct device *dev = &adapter->pdev->dev; | 4087 | struct device *dev = &adapter->pdev->dev; |
3459 | 4088 | ||
4089 | if (device_create_bin_file(dev, &bin_attr_port_stats)) | ||
4090 | dev_info(dev, "failed to create port stats sysfs entry"); | ||
4091 | |||
3460 | if (adapter->op_mode == QLCNIC_NON_PRIV_FUNC) | 4092 | if (adapter->op_mode == QLCNIC_NON_PRIV_FUNC) |
3461 | return; | 4093 | return; |
3462 | if (device_create_file(dev, &dev_attr_diag_mode)) | 4094 | if (device_create_file(dev, &dev_attr_diag_mode)) |
@@ -3465,18 +4097,20 @@ qlcnic_create_diag_entries(struct qlcnic_adapter *adapter) | |||
3465 | dev_info(dev, "failed to create crb sysfs entry\n"); | 4097 | dev_info(dev, "failed to create crb sysfs entry\n"); |
3466 | if (device_create_bin_file(dev, &bin_attr_mem)) | 4098 | if (device_create_bin_file(dev, &bin_attr_mem)) |
3467 | dev_info(dev, "failed to create mem sysfs entry\n"); | 4099 | dev_info(dev, "failed to create mem sysfs entry\n"); |
3468 | if (!(adapter->flags & QLCNIC_ESWITCH_ENABLED) || | ||
3469 | adapter->op_mode != QLCNIC_MGMT_FUNC) | ||
3470 | return; | ||
3471 | if (device_create_bin_file(dev, &bin_attr_pci_config)) | 4100 | if (device_create_bin_file(dev, &bin_attr_pci_config)) |
3472 | dev_info(dev, "failed to create pci config sysfs entry"); | 4101 | dev_info(dev, "failed to create pci config sysfs entry"); |
3473 | if (device_create_bin_file(dev, &bin_attr_npar_config)) | 4102 | if (!(adapter->flags & QLCNIC_ESWITCH_ENABLED)) |
3474 | dev_info(dev, "failed to create npar config sysfs entry"); | 4103 | return; |
3475 | if (device_create_bin_file(dev, &bin_attr_esw_config)) | 4104 | if (device_create_bin_file(dev, &bin_attr_esw_config)) |
3476 | dev_info(dev, "failed to create esw config sysfs entry"); | 4105 | dev_info(dev, "failed to create esw config sysfs entry"); |
4106 | if (adapter->op_mode != QLCNIC_MGMT_FUNC) | ||
4107 | return; | ||
4108 | if (device_create_bin_file(dev, &bin_attr_npar_config)) | ||
4109 | dev_info(dev, "failed to create npar config sysfs entry"); | ||
3477 | if (device_create_bin_file(dev, &bin_attr_pm_config)) | 4110 | if (device_create_bin_file(dev, &bin_attr_pm_config)) |
3478 | dev_info(dev, "failed to create pm config sysfs entry"); | 4111 | dev_info(dev, "failed to create pm config sysfs entry"); |
3479 | 4112 | if (device_create_bin_file(dev, &bin_attr_esw_stats)) | |
4113 | dev_info(dev, "failed to create eswitch stats sysfs entry"); | ||
3480 | } | 4114 | } |
3481 | 4115 | ||
3482 | static void | 4116 | static void |
@@ -3484,18 +4118,22 @@ qlcnic_remove_diag_entries(struct qlcnic_adapter *adapter) | |||
3484 | { | 4118 | { |
3485 | struct device *dev = &adapter->pdev->dev; | 4119 | struct device *dev = &adapter->pdev->dev; |
3486 | 4120 | ||
4121 | device_remove_bin_file(dev, &bin_attr_port_stats); | ||
4122 | |||
3487 | if (adapter->op_mode == QLCNIC_NON_PRIV_FUNC) | 4123 | if (adapter->op_mode == QLCNIC_NON_PRIV_FUNC) |
3488 | return; | 4124 | return; |
3489 | device_remove_file(dev, &dev_attr_diag_mode); | 4125 | device_remove_file(dev, &dev_attr_diag_mode); |
3490 | device_remove_bin_file(dev, &bin_attr_crb); | 4126 | device_remove_bin_file(dev, &bin_attr_crb); |
3491 | device_remove_bin_file(dev, &bin_attr_mem); | 4127 | device_remove_bin_file(dev, &bin_attr_mem); |
3492 | if (!(adapter->flags & QLCNIC_ESWITCH_ENABLED) || | ||
3493 | adapter->op_mode != QLCNIC_MGMT_FUNC) | ||
3494 | return; | ||
3495 | device_remove_bin_file(dev, &bin_attr_pci_config); | 4128 | device_remove_bin_file(dev, &bin_attr_pci_config); |
3496 | device_remove_bin_file(dev, &bin_attr_npar_config); | 4129 | if (!(adapter->flags & QLCNIC_ESWITCH_ENABLED)) |
4130 | return; | ||
3497 | device_remove_bin_file(dev, &bin_attr_esw_config); | 4131 | device_remove_bin_file(dev, &bin_attr_esw_config); |
4132 | if (adapter->op_mode != QLCNIC_MGMT_FUNC) | ||
4133 | return; | ||
4134 | device_remove_bin_file(dev, &bin_attr_npar_config); | ||
3498 | device_remove_bin_file(dev, &bin_attr_pm_config); | 4135 | device_remove_bin_file(dev, &bin_attr_pm_config); |
4136 | device_remove_bin_file(dev, &bin_attr_esw_stats); | ||
3499 | } | 4137 | } |
3500 | 4138 | ||
3501 | #ifdef CONFIG_INET | 4139 | #ifdef CONFIG_INET |
@@ -3503,10 +4141,10 @@ qlcnic_remove_diag_entries(struct qlcnic_adapter *adapter) | |||
3503 | #define is_qlcnic_netdev(dev) (dev->netdev_ops == &qlcnic_netdev_ops) | 4141 | #define is_qlcnic_netdev(dev) (dev->netdev_ops == &qlcnic_netdev_ops) |
3504 | 4142 | ||
3505 | static void | 4143 | static void |
3506 | qlcnic_config_indev_addr(struct net_device *dev, unsigned long event) | 4144 | qlcnic_config_indev_addr(struct qlcnic_adapter *adapter, |
4145 | struct net_device *dev, unsigned long event) | ||
3507 | { | 4146 | { |
3508 | struct in_device *indev; | 4147 | struct in_device *indev; |
3509 | struct qlcnic_adapter *adapter = netdev_priv(dev); | ||
3510 | 4148 | ||
3511 | indev = in_dev_get(dev); | 4149 | indev = in_dev_get(dev); |
3512 | if (!indev) | 4150 | if (!indev) |
@@ -3530,6 +4168,23 @@ qlcnic_config_indev_addr(struct net_device *dev, unsigned long event) | |||
3530 | in_dev_put(indev); | 4168 | in_dev_put(indev); |
3531 | } | 4169 | } |
3532 | 4170 | ||
4171 | static void | ||
4172 | qlcnic_restore_indev_addr(struct net_device *netdev, unsigned long event) | ||
4173 | { | ||
4174 | struct qlcnic_adapter *adapter = netdev_priv(netdev); | ||
4175 | struct net_device *dev; | ||
4176 | u16 vid; | ||
4177 | |||
4178 | qlcnic_config_indev_addr(adapter, netdev, event); | ||
4179 | |||
4180 | for_each_set_bit(vid, adapter->vlans, VLAN_N_VID) { | ||
4181 | dev = vlan_find_dev(netdev, vid); | ||
4182 | if (!dev) | ||
4183 | continue; | ||
4184 | qlcnic_config_indev_addr(adapter, dev, event); | ||
4185 | } | ||
4186 | } | ||
4187 | |||
3533 | static int qlcnic_netdev_event(struct notifier_block *this, | 4188 | static int qlcnic_netdev_event(struct notifier_block *this, |
3534 | unsigned long event, void *ptr) | 4189 | unsigned long event, void *ptr) |
3535 | { | 4190 | { |
@@ -3556,7 +4211,7 @@ recheck: | |||
3556 | if (!test_bit(__QLCNIC_DEV_UP, &adapter->state)) | 4211 | if (!test_bit(__QLCNIC_DEV_UP, &adapter->state)) |
3557 | goto done; | 4212 | goto done; |
3558 | 4213 | ||
3559 | qlcnic_config_indev_addr(dev, event); | 4214 | qlcnic_config_indev_addr(adapter, dev, event); |
3560 | done: | 4215 | done: |
3561 | return NOTIFY_DONE; | 4216 | return NOTIFY_DONE; |
3562 | } | 4217 | } |
@@ -3573,7 +4228,7 @@ qlcnic_inetaddr_event(struct notifier_block *this, | |||
3573 | dev = ifa->ifa_dev ? ifa->ifa_dev->dev : NULL; | 4228 | dev = ifa->ifa_dev ? ifa->ifa_dev->dev : NULL; |
3574 | 4229 | ||
3575 | recheck: | 4230 | recheck: |
3576 | if (dev == NULL || !netif_running(dev)) | 4231 | if (dev == NULL) |
3577 | goto done; | 4232 | goto done; |
3578 | 4233 | ||
3579 | if (dev->priv_flags & IFF_802_1Q_VLAN) { | 4234 | if (dev->priv_flags & IFF_802_1Q_VLAN) { |
@@ -3616,7 +4271,7 @@ static struct notifier_block qlcnic_inetaddr_cb = { | |||
3616 | }; | 4271 | }; |
3617 | #else | 4272 | #else |
3618 | static void | 4273 | static void |
3619 | qlcnic_config_indev_addr(struct net_device *dev, unsigned long event) | 4274 | qlcnic_restore_indev_addr(struct net_device *dev, unsigned long event) |
3620 | { } | 4275 | { } |
3621 | #endif | 4276 | #endif |
3622 | static struct pci_error_handlers qlcnic_err_handler = { | 4277 | static struct pci_error_handlers qlcnic_err_handler = { |
@@ -3645,6 +4300,12 @@ static int __init qlcnic_init_module(void) | |||
3645 | 4300 | ||
3646 | printk(KERN_INFO "%s\n", qlcnic_driver_string); | 4301 | printk(KERN_INFO "%s\n", qlcnic_driver_string); |
3647 | 4302 | ||
4303 | qlcnic_wq = create_singlethread_workqueue("qlcnic"); | ||
4304 | if (qlcnic_wq == NULL) { | ||
4305 | printk(KERN_ERR "qlcnic: cannot create workqueue\n"); | ||
4306 | return -ENOMEM; | ||
4307 | } | ||
4308 | |||
3648 | #ifdef CONFIG_INET | 4309 | #ifdef CONFIG_INET |
3649 | register_netdevice_notifier(&qlcnic_netdev_cb); | 4310 | register_netdevice_notifier(&qlcnic_netdev_cb); |
3650 | register_inetaddr_notifier(&qlcnic_inetaddr_cb); | 4311 | register_inetaddr_notifier(&qlcnic_inetaddr_cb); |
@@ -3656,6 +4317,7 @@ static int __init qlcnic_init_module(void) | |||
3656 | unregister_inetaddr_notifier(&qlcnic_inetaddr_cb); | 4317 | unregister_inetaddr_notifier(&qlcnic_inetaddr_cb); |
3657 | unregister_netdevice_notifier(&qlcnic_netdev_cb); | 4318 | unregister_netdevice_notifier(&qlcnic_netdev_cb); |
3658 | #endif | 4319 | #endif |
4320 | destroy_workqueue(qlcnic_wq); | ||
3659 | } | 4321 | } |
3660 | 4322 | ||
3661 | return ret; | 4323 | return ret; |
@@ -3672,6 +4334,7 @@ static void __exit qlcnic_exit_module(void) | |||
3672 | unregister_inetaddr_notifier(&qlcnic_inetaddr_cb); | 4334 | unregister_inetaddr_notifier(&qlcnic_inetaddr_cb); |
3673 | unregister_netdevice_notifier(&qlcnic_netdev_cb); | 4335 | unregister_netdevice_notifier(&qlcnic_netdev_cb); |
3674 | #endif | 4336 | #endif |
4337 | destroy_workqueue(qlcnic_wq); | ||
3675 | } | 4338 | } |
3676 | 4339 | ||
3677 | module_exit(qlcnic_exit_module); | 4340 | module_exit(qlcnic_exit_module); |