1 /*************************************************************************
2 * myri10ge.c: Myricom Myri-10G Ethernet driver.
4 * Copyright (C) 2005 - 2007 Myricom, Inc.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of Myricom, Inc. nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 * If the eeprom on your board is not recent enough, you will need to get a
33 * newer firmware image at:
34 * http://www.myri.com/scs/download-Myri10GE.html
36 * Contact Information:
38 * Myricom, Inc., 325N Santa Anita Avenue, Arcadia, CA 91006
39 *************************************************************************/
41 #include <linux/tcp.h>
42 #include <linux/netdevice.h>
43 #include <linux/skbuff.h>
44 #include <linux/string.h>
45 #include <linux/module.h>
46 #include <linux/pci.h>
47 #include <linux/dma-mapping.h>
48 #include <linux/etherdevice.h>
49 #include <linux/if_ether.h>
50 #include <linux/if_vlan.h>
51 #include <linux/inet_lro.h>
53 #include <linux/inet.h>
55 #include <linux/ethtool.h>
56 #include <linux/firmware.h>
57 #include <linux/delay.h>
58 #include <linux/version.h>
59 #include <linux/timer.h>
60 #include <linux/vmalloc.h>
61 #include <linux/crc32.h>
62 #include <linux/moduleparam.h>
64 #include <linux/log2.h>
65 #include <net/checksum.h>
68 #include <asm/byteorder.h>
70 #include <asm/processor.h>
75 #include "myri10ge_mcp.h"
76 #include "myri10ge_mcp_gen_header.h"
78 #define MYRI10GE_VERSION_STR "1.3.2-1.269"
80 MODULE_DESCRIPTION("Myricom 10G driver (10GbE)");
81 MODULE_AUTHOR("Maintainer: help@myri.com");
82 MODULE_VERSION(MYRI10GE_VERSION_STR
);
83 MODULE_LICENSE("Dual BSD/GPL");
85 #define MYRI10GE_MAX_ETHER_MTU 9014
87 #define MYRI10GE_ETH_STOPPED 0
88 #define MYRI10GE_ETH_STOPPING 1
89 #define MYRI10GE_ETH_STARTING 2
90 #define MYRI10GE_ETH_RUNNING 3
91 #define MYRI10GE_ETH_OPEN_FAILED 4
93 #define MYRI10GE_EEPROM_STRINGS_SIZE 256
94 #define MYRI10GE_MAX_SEND_DESC_TSO ((65536 / 2048) * 2)
95 #define MYRI10GE_MAX_LRO_DESCRIPTORS 8
96 #define MYRI10GE_LRO_MAX_PKTS 64
98 #define MYRI10GE_NO_CONFIRM_DATA htonl(0xffffffff)
99 #define MYRI10GE_NO_RESPONSE_RESULT 0xffffffff
101 #define MYRI10GE_ALLOC_ORDER 0
102 #define MYRI10GE_ALLOC_SIZE ((1 << MYRI10GE_ALLOC_ORDER) * PAGE_SIZE)
103 #define MYRI10GE_MAX_FRAGS_PER_FRAME (MYRI10GE_MAX_ETHER_MTU/MYRI10GE_ALLOC_SIZE + 1)
105 struct myri10ge_rx_buffer_state
{
108 DECLARE_PCI_UNMAP_ADDR(bus
)
109 DECLARE_PCI_UNMAP_LEN(len
)
112 struct myri10ge_tx_buffer_state
{
115 DECLARE_PCI_UNMAP_ADDR(bus
)
116 DECLARE_PCI_UNMAP_LEN(len
)
119 struct myri10ge_cmd
{
125 struct myri10ge_rx_buf
{
126 struct mcp_kreq_ether_recv __iomem
*lanai
; /* lanai ptr for recv ring */
127 u8 __iomem
*wc_fifo
; /* w/c rx dma addr fifo address */
128 struct mcp_kreq_ether_recv
*shadow
; /* host shadow of recv ring */
129 struct myri10ge_rx_buffer_state
*info
;
136 int mask
; /* number of rx slots -1 */
140 struct myri10ge_tx_buf
{
141 struct mcp_kreq_ether_send __iomem
*lanai
; /* lanai ptr for sendq */
142 u8 __iomem
*wc_fifo
; /* w/c send fifo address */
143 struct mcp_kreq_ether_send
*req_list
; /* host shadow of sendq */
145 struct myri10ge_tx_buffer_state
*info
;
146 int mask
; /* number of transmit slots -1 */
147 int boundary
; /* boundary transmits cannot cross */
148 int req ____cacheline_aligned
; /* transmit slots submitted */
149 int pkt_start
; /* packets started */
150 int done ____cacheline_aligned
; /* transmit slots completed */
151 int pkt_done
; /* packets completed */
154 struct myri10ge_rx_done
{
155 struct mcp_slot
*entry
;
159 struct net_lro_mgr lro_mgr
;
160 struct net_lro_desc lro_desc
[MYRI10GE_MAX_LRO_DESCRIPTORS
];
163 struct myri10ge_priv
{
164 int running
; /* running? */
165 int csum_flag
; /* rx_csums? */
166 struct myri10ge_tx_buf tx
; /* transmit ring */
167 struct myri10ge_rx_buf rx_small
;
168 struct myri10ge_rx_buf rx_big
;
169 struct myri10ge_rx_done rx_done
;
172 struct net_device
*dev
;
173 struct napi_struct napi
;
174 struct net_device_stats stats
;
177 unsigned long board_span
;
178 unsigned long iomem_base
;
179 __be32 __iomem
*irq_claim
;
180 __be32 __iomem
*irq_deassert
;
181 char *mac_addr_string
;
182 struct mcp_cmd_response
*cmd
;
184 struct mcp_irq_data
*fw_stats
;
185 dma_addr_t fw_stats_bus
;
186 struct pci_dev
*pdev
;
189 unsigned int rdma_tags_available
;
191 __be32 __iomem
*intr_coal_delay_ptr
;
197 wait_queue_head_t down_wq
;
198 struct work_struct watchdog_work
;
199 struct timer_list watchdog_timer
;
200 int watchdog_tx_done
;
207 char eeprom_strings
[MYRI10GE_EEPROM_STRINGS_SIZE
];
208 char fw_version
[128];
212 int adopted_rx_filter_bug
;
213 u8 mac_addr
[6]; /* eeprom mac address */
214 unsigned long serial_number
;
215 int vendor_specific_offset
;
216 int fw_multicast_support
;
224 static char *myri10ge_fw_unaligned
= "myri10ge_ethp_z8e.dat";
225 static char *myri10ge_fw_aligned
= "myri10ge_eth_z8e.dat";
227 static char *myri10ge_fw_name
= NULL
;
228 module_param(myri10ge_fw_name
, charp
, S_IRUGO
| S_IWUSR
);
229 MODULE_PARM_DESC(myri10ge_fw_name
, "Firmware image name\n");
231 static int myri10ge_ecrc_enable
= 1;
232 module_param(myri10ge_ecrc_enable
, int, S_IRUGO
);
233 MODULE_PARM_DESC(myri10ge_ecrc_enable
, "Enable Extended CRC on PCI-E\n");
235 static int myri10ge_max_intr_slots
= 1024;
236 module_param(myri10ge_max_intr_slots
, int, S_IRUGO
);
237 MODULE_PARM_DESC(myri10ge_max_intr_slots
, "Interrupt queue slots\n");
239 static int myri10ge_small_bytes
= -1; /* -1 == auto */
240 module_param(myri10ge_small_bytes
, int, S_IRUGO
| S_IWUSR
);
241 MODULE_PARM_DESC(myri10ge_small_bytes
, "Threshold of small packets\n");
243 static int myri10ge_msi
= 1; /* enable msi by default */
244 module_param(myri10ge_msi
, int, S_IRUGO
| S_IWUSR
);
245 MODULE_PARM_DESC(myri10ge_msi
, "Enable Message Signalled Interrupts\n");
247 static int myri10ge_intr_coal_delay
= 75;
248 module_param(myri10ge_intr_coal_delay
, int, S_IRUGO
);
249 MODULE_PARM_DESC(myri10ge_intr_coal_delay
, "Interrupt coalescing delay\n");
251 static int myri10ge_flow_control
= 1;
252 module_param(myri10ge_flow_control
, int, S_IRUGO
);
253 MODULE_PARM_DESC(myri10ge_flow_control
, "Pause parameter\n");
255 static int myri10ge_deassert_wait
= 1;
256 module_param(myri10ge_deassert_wait
, int, S_IRUGO
| S_IWUSR
);
257 MODULE_PARM_DESC(myri10ge_deassert_wait
,
258 "Wait when deasserting legacy interrupts\n");
260 static int myri10ge_force_firmware
= 0;
261 module_param(myri10ge_force_firmware
, int, S_IRUGO
);
262 MODULE_PARM_DESC(myri10ge_force_firmware
,
263 "Force firmware to assume aligned completions\n");
265 static int myri10ge_initial_mtu
= MYRI10GE_MAX_ETHER_MTU
- ETH_HLEN
;
266 module_param(myri10ge_initial_mtu
, int, S_IRUGO
);
267 MODULE_PARM_DESC(myri10ge_initial_mtu
, "Initial MTU\n");
269 static int myri10ge_napi_weight
= 64;
270 module_param(myri10ge_napi_weight
, int, S_IRUGO
);
271 MODULE_PARM_DESC(myri10ge_napi_weight
, "Set NAPI weight\n");
273 static int myri10ge_watchdog_timeout
= 1;
274 module_param(myri10ge_watchdog_timeout
, int, S_IRUGO
);
275 MODULE_PARM_DESC(myri10ge_watchdog_timeout
, "Set watchdog timeout\n");
277 static int myri10ge_max_irq_loops
= 1048576;
278 module_param(myri10ge_max_irq_loops
, int, S_IRUGO
);
279 MODULE_PARM_DESC(myri10ge_max_irq_loops
,
280 "Set stuck legacy IRQ detection threshold\n");
282 #define MYRI10GE_MSG_DEFAULT NETIF_MSG_LINK
284 static int myri10ge_debug
= -1; /* defaults above */
285 module_param(myri10ge_debug
, int, 0);
286 MODULE_PARM_DESC(myri10ge_debug
, "Debug level (0=none,...,16=all)");
288 static int myri10ge_lro
= 1;
289 module_param(myri10ge_lro
, int, S_IRUGO
);
290 MODULE_PARM_DESC(myri10ge_lro
, "Enable large receive offload\n");
292 static int myri10ge_lro_max_pkts
= MYRI10GE_LRO_MAX_PKTS
;
293 module_param(myri10ge_lro_max_pkts
, int, S_IRUGO
);
294 MODULE_PARM_DESC(myri10ge_lro
, "Number of LRO packets to be aggregated\n");
296 static int myri10ge_fill_thresh
= 256;
297 module_param(myri10ge_fill_thresh
, int, S_IRUGO
| S_IWUSR
);
298 MODULE_PARM_DESC(myri10ge_fill_thresh
, "Number of empty rx slots allowed\n");
300 static int myri10ge_reset_recover
= 1;
302 static int myri10ge_wcfifo
= 0;
303 module_param(myri10ge_wcfifo
, int, S_IRUGO
);
304 MODULE_PARM_DESC(myri10ge_wcfifo
, "Enable WC Fifo when WC is enabled\n");
306 #define MYRI10GE_FW_OFFSET 1024*1024
307 #define MYRI10GE_HIGHPART_TO_U32(X) \
308 (sizeof (X) == 8) ? ((u32)((u64)(X) >> 32)) : (0)
309 #define MYRI10GE_LOWPART_TO_U32(X) ((u32)(X))
311 #define myri10ge_pio_copy(to,from,size) __iowrite64_copy(to,from,size/8)
313 static void myri10ge_set_multicast_list(struct net_device
*dev
);
315 static inline void put_be32(__be32 val
, __be32 __iomem
* p
)
317 __raw_writel((__force __u32
) val
, (__force
void __iomem
*)p
);
321 myri10ge_send_cmd(struct myri10ge_priv
*mgp
, u32 cmd
,
322 struct myri10ge_cmd
*data
, int atomic
)
325 char buf_bytes
[sizeof(*buf
) + 8];
326 struct mcp_cmd_response
*response
= mgp
->cmd
;
327 char __iomem
*cmd_addr
= mgp
->sram
+ MXGEFW_ETH_CMD
;
328 u32 dma_low
, dma_high
, result
, value
;
331 /* ensure buf is aligned to 8 bytes */
332 buf
= (struct mcp_cmd
*)ALIGN((unsigned long)buf_bytes
, 8);
334 buf
->data0
= htonl(data
->data0
);
335 buf
->data1
= htonl(data
->data1
);
336 buf
->data2
= htonl(data
->data2
);
337 buf
->cmd
= htonl(cmd
);
338 dma_low
= MYRI10GE_LOWPART_TO_U32(mgp
->cmd_bus
);
339 dma_high
= MYRI10GE_HIGHPART_TO_U32(mgp
->cmd_bus
);
341 buf
->response_addr
.low
= htonl(dma_low
);
342 buf
->response_addr
.high
= htonl(dma_high
);
343 response
->result
= htonl(MYRI10GE_NO_RESPONSE_RESULT
);
345 myri10ge_pio_copy(cmd_addr
, buf
, sizeof(*buf
));
347 /* wait up to 15ms. Longest command is the DMA benchmark,
348 * which is capped at 5ms, but runs from a timeout handler
349 * that runs every 7.8ms. So a 15ms timeout leaves us with
353 /* if atomic is set, do not sleep,
354 * and try to get the completion quickly
355 * (1ms will be enough for those commands) */
356 for (sleep_total
= 0;
358 && response
->result
== htonl(MYRI10GE_NO_RESPONSE_RESULT
);
362 /* use msleep for most command */
363 for (sleep_total
= 0;
365 && response
->result
== htonl(MYRI10GE_NO_RESPONSE_RESULT
);
370 result
= ntohl(response
->result
);
371 value
= ntohl(response
->data
);
372 if (result
!= MYRI10GE_NO_RESPONSE_RESULT
) {
376 } else if (result
== MXGEFW_CMD_UNKNOWN
) {
378 } else if (result
== MXGEFW_CMD_ERROR_UNALIGNED
) {
381 dev_err(&mgp
->pdev
->dev
,
382 "command %d failed, result = %d\n",
388 dev_err(&mgp
->pdev
->dev
, "command %d timed out, result = %d\n",
394 * The eeprom strings on the lanaiX have the format
397 * PT:ddd mmm xx xx:xx:xx xx\0
398 * PV:ddd mmm xx xx:xx:xx xx\0
400 static int myri10ge_read_mac_addr(struct myri10ge_priv
*mgp
)
405 ptr
= mgp
->eeprom_strings
;
406 limit
= mgp
->eeprom_strings
+ MYRI10GE_EEPROM_STRINGS_SIZE
;
408 while (*ptr
!= '\0' && ptr
< limit
) {
409 if (memcmp(ptr
, "MAC=", 4) == 0) {
411 mgp
->mac_addr_string
= ptr
;
412 for (i
= 0; i
< 6; i
++) {
413 if ((ptr
+ 2) > limit
)
416 simple_strtoul(ptr
, &ptr
, 16);
420 if (memcmp((const void *)ptr
, "SN=", 3) == 0) {
422 mgp
->serial_number
= simple_strtoul(ptr
, &ptr
, 10);
424 while (ptr
< limit
&& *ptr
++) ;
430 dev_err(&mgp
->pdev
->dev
, "failed to parse eeprom_strings\n");
435 * Enable or disable periodic RDMAs from the host to make certain
436 * chipsets resend dropped PCIe messages
439 static void myri10ge_dummy_rdma(struct myri10ge_priv
*mgp
, int enable
)
441 char __iomem
*submit
;
443 u32 dma_low
, dma_high
;
446 /* clear confirmation addr */
450 /* send a rdma command to the PCIe engine, and wait for the
451 * response in the confirmation address. The firmware should
452 * write a -1 there to indicate it is alive and well
454 dma_low
= MYRI10GE_LOWPART_TO_U32(mgp
->cmd_bus
);
455 dma_high
= MYRI10GE_HIGHPART_TO_U32(mgp
->cmd_bus
);
457 buf
[0] = htonl(dma_high
); /* confirm addr MSW */
458 buf
[1] = htonl(dma_low
); /* confirm addr LSW */
459 buf
[2] = MYRI10GE_NO_CONFIRM_DATA
; /* confirm data */
460 buf
[3] = htonl(dma_high
); /* dummy addr MSW */
461 buf
[4] = htonl(dma_low
); /* dummy addr LSW */
462 buf
[5] = htonl(enable
); /* enable? */
464 submit
= mgp
->sram
+ MXGEFW_BOOT_DUMMY_RDMA
;
466 myri10ge_pio_copy(submit
, &buf
, sizeof(buf
));
467 for (i
= 0; mgp
->cmd
->data
!= MYRI10GE_NO_CONFIRM_DATA
&& i
< 20; i
++)
469 if (mgp
->cmd
->data
!= MYRI10GE_NO_CONFIRM_DATA
)
470 dev_err(&mgp
->pdev
->dev
, "dummy rdma %s failed\n",
471 (enable
? "enable" : "disable"));
475 myri10ge_validate_firmware(struct myri10ge_priv
*mgp
,
476 struct mcp_gen_header
*hdr
)
478 struct device
*dev
= &mgp
->pdev
->dev
;
480 /* check firmware type */
481 if (ntohl(hdr
->mcp_type
) != MCP_TYPE_ETH
) {
482 dev_err(dev
, "Bad firmware type: 0x%x\n", ntohl(hdr
->mcp_type
));
486 /* save firmware version for ethtool */
487 strncpy(mgp
->fw_version
, hdr
->version
, sizeof(mgp
->fw_version
));
489 sscanf(mgp
->fw_version
, "%d.%d.%d", &mgp
->fw_ver_major
,
490 &mgp
->fw_ver_minor
, &mgp
->fw_ver_tiny
);
492 if (!(mgp
->fw_ver_major
== MXGEFW_VERSION_MAJOR
493 && mgp
->fw_ver_minor
== MXGEFW_VERSION_MINOR
)) {
494 dev_err(dev
, "Found firmware version %s\n", mgp
->fw_version
);
495 dev_err(dev
, "Driver needs %d.%d\n", MXGEFW_VERSION_MAJOR
,
496 MXGEFW_VERSION_MINOR
);
502 static int myri10ge_load_hotplug_firmware(struct myri10ge_priv
*mgp
, u32
* size
)
504 unsigned crc
, reread_crc
;
505 const struct firmware
*fw
;
506 struct device
*dev
= &mgp
->pdev
->dev
;
507 struct mcp_gen_header
*hdr
;
512 if ((status
= request_firmware(&fw
, mgp
->fw_name
, dev
)) < 0) {
513 dev_err(dev
, "Unable to load %s firmware image via hotplug\n",
516 goto abort_with_nothing
;
521 if (fw
->size
>= mgp
->sram_size
- MYRI10GE_FW_OFFSET
||
522 fw
->size
< MCP_HEADER_PTR_OFFSET
+ 4) {
523 dev_err(dev
, "Firmware size invalid:%d\n", (int)fw
->size
);
529 hdr_offset
= ntohl(*(__be32
*) (fw
->data
+ MCP_HEADER_PTR_OFFSET
));
530 if ((hdr_offset
& 3) || hdr_offset
+ sizeof(*hdr
) > fw
->size
) {
531 dev_err(dev
, "Bad firmware file\n");
535 hdr
= (void *)(fw
->data
+ hdr_offset
);
537 status
= myri10ge_validate_firmware(mgp
, hdr
);
541 crc
= crc32(~0, fw
->data
, fw
->size
);
542 for (i
= 0; i
< fw
->size
; i
+= 256) {
543 myri10ge_pio_copy(mgp
->sram
+ MYRI10GE_FW_OFFSET
+ i
,
545 min(256U, (unsigned)(fw
->size
- i
)));
549 /* corruption checking is good for parity recovery and buggy chipset */
550 memcpy_fromio(fw
->data
, mgp
->sram
+ MYRI10GE_FW_OFFSET
, fw
->size
);
551 reread_crc
= crc32(~0, fw
->data
, fw
->size
);
552 if (crc
!= reread_crc
) {
553 dev_err(dev
, "CRC failed(fw-len=%u), got 0x%x (expect 0x%x)\n",
554 (unsigned)fw
->size
, reread_crc
, crc
);
558 *size
= (u32
) fw
->size
;
561 release_firmware(fw
);
567 static int myri10ge_adopt_running_firmware(struct myri10ge_priv
*mgp
)
569 struct mcp_gen_header
*hdr
;
570 struct device
*dev
= &mgp
->pdev
->dev
;
571 const size_t bytes
= sizeof(struct mcp_gen_header
);
575 /* find running firmware header */
576 hdr_offset
= ntohl(__raw_readl(mgp
->sram
+ MCP_HEADER_PTR_OFFSET
));
578 if ((hdr_offset
& 3) || hdr_offset
+ sizeof(*hdr
) > mgp
->sram_size
) {
579 dev_err(dev
, "Running firmware has bad header offset (%d)\n",
584 /* copy header of running firmware from SRAM to host memory to
585 * validate firmware */
586 hdr
= kmalloc(bytes
, GFP_KERNEL
);
588 dev_err(dev
, "could not malloc firmware hdr\n");
591 memcpy_fromio(hdr
, mgp
->sram
+ hdr_offset
, bytes
);
592 status
= myri10ge_validate_firmware(mgp
, hdr
);
595 /* check to see if adopted firmware has bug where adopting
596 * it will cause broadcasts to be filtered unless the NIC
597 * is kept in ALLMULTI mode */
598 if (mgp
->fw_ver_major
== 1 && mgp
->fw_ver_minor
== 4 &&
599 mgp
->fw_ver_tiny
>= 4 && mgp
->fw_ver_tiny
<= 11) {
600 mgp
->adopted_rx_filter_bug
= 1;
601 dev_warn(dev
, "Adopting fw %d.%d.%d: "
602 "working around rx filter bug\n",
603 mgp
->fw_ver_major
, mgp
->fw_ver_minor
,
609 static int myri10ge_load_firmware(struct myri10ge_priv
*mgp
)
611 char __iomem
*submit
;
613 u32 dma_low
, dma_high
, size
;
617 status
= myri10ge_load_hotplug_firmware(mgp
, &size
);
619 dev_warn(&mgp
->pdev
->dev
, "hotplug firmware loading failed\n");
621 /* Do not attempt to adopt firmware if there
626 status
= myri10ge_adopt_running_firmware(mgp
);
628 dev_err(&mgp
->pdev
->dev
,
629 "failed to adopt running firmware\n");
632 dev_info(&mgp
->pdev
->dev
,
633 "Successfully adopted running firmware\n");
634 if (mgp
->tx
.boundary
== 4096) {
635 dev_warn(&mgp
->pdev
->dev
,
636 "Using firmware currently running on NIC"
638 dev_warn(&mgp
->pdev
->dev
,
639 "performance consider loading optimized "
641 dev_warn(&mgp
->pdev
->dev
, "via hotplug\n");
644 mgp
->fw_name
= "adopted";
645 mgp
->tx
.boundary
= 2048;
649 /* clear confirmation addr */
653 /* send a reload command to the bootstrap MCP, and wait for the
654 * response in the confirmation address. The firmware should
655 * write a -1 there to indicate it is alive and well
657 dma_low
= MYRI10GE_LOWPART_TO_U32(mgp
->cmd_bus
);
658 dma_high
= MYRI10GE_HIGHPART_TO_U32(mgp
->cmd_bus
);
660 buf
[0] = htonl(dma_high
); /* confirm addr MSW */
661 buf
[1] = htonl(dma_low
); /* confirm addr LSW */
662 buf
[2] = MYRI10GE_NO_CONFIRM_DATA
; /* confirm data */
664 /* FIX: All newest firmware should un-protect the bottom of
665 * the sram before handoff. However, the very first interfaces
666 * do not. Therefore the handoff copy must skip the first 8 bytes
668 buf
[3] = htonl(MYRI10GE_FW_OFFSET
+ 8); /* where the code starts */
669 buf
[4] = htonl(size
- 8); /* length of code */
670 buf
[5] = htonl(8); /* where to copy to */
671 buf
[6] = htonl(0); /* where to jump to */
673 submit
= mgp
->sram
+ MXGEFW_BOOT_HANDOFF
;
675 myri10ge_pio_copy(submit
, &buf
, sizeof(buf
));
680 while (mgp
->cmd
->data
!= MYRI10GE_NO_CONFIRM_DATA
&& i
< 20) {
684 if (mgp
->cmd
->data
!= MYRI10GE_NO_CONFIRM_DATA
) {
685 dev_err(&mgp
->pdev
->dev
, "handoff failed\n");
688 dev_info(&mgp
->pdev
->dev
, "handoff confirmed\n");
689 myri10ge_dummy_rdma(mgp
, 1);
694 static int myri10ge_update_mac_address(struct myri10ge_priv
*mgp
, u8
* addr
)
696 struct myri10ge_cmd cmd
;
699 cmd
.data0
= ((addr
[0] << 24) | (addr
[1] << 16)
700 | (addr
[2] << 8) | addr
[3]);
702 cmd
.data1
= ((addr
[4] << 8) | (addr
[5]));
704 status
= myri10ge_send_cmd(mgp
, MXGEFW_SET_MAC_ADDRESS
, &cmd
, 0);
708 static int myri10ge_change_pause(struct myri10ge_priv
*mgp
, int pause
)
710 struct myri10ge_cmd cmd
;
713 ctl
= pause
? MXGEFW_ENABLE_FLOW_CONTROL
: MXGEFW_DISABLE_FLOW_CONTROL
;
714 status
= myri10ge_send_cmd(mgp
, ctl
, &cmd
, 0);
718 "myri10ge: %s: Failed to set flow control mode\n",
727 myri10ge_change_promisc(struct myri10ge_priv
*mgp
, int promisc
, int atomic
)
729 struct myri10ge_cmd cmd
;
732 ctl
= promisc
? MXGEFW_ENABLE_PROMISC
: MXGEFW_DISABLE_PROMISC
;
733 status
= myri10ge_send_cmd(mgp
, ctl
, &cmd
, atomic
);
735 printk(KERN_ERR
"myri10ge: %s: Failed to set promisc mode\n",
739 static int myri10ge_dma_test(struct myri10ge_priv
*mgp
, int test_type
)
741 struct myri10ge_cmd cmd
;
744 struct page
*dmatest_page
;
745 dma_addr_t dmatest_bus
;
748 dmatest_page
= alloc_page(GFP_KERNEL
);
751 dmatest_bus
= pci_map_page(mgp
->pdev
, dmatest_page
, 0, PAGE_SIZE
,
754 /* Run a small DMA test.
755 * The magic multipliers to the length tell the firmware
756 * to do DMA read, write, or read+write tests. The
757 * results are returned in cmd.data0. The upper 16
758 * bits or the return is the number of transfers completed.
759 * The lower 16 bits is the time in 0.5us ticks that the
760 * transfers took to complete.
763 len
= mgp
->tx
.boundary
;
765 cmd
.data0
= MYRI10GE_LOWPART_TO_U32(dmatest_bus
);
766 cmd
.data1
= MYRI10GE_HIGHPART_TO_U32(dmatest_bus
);
767 cmd
.data2
= len
* 0x10000;
768 status
= myri10ge_send_cmd(mgp
, test_type
, &cmd
, 0);
773 mgp
->read_dma
= ((cmd
.data0
>> 16) * len
* 2) / (cmd
.data0
& 0xffff);
774 cmd
.data0
= MYRI10GE_LOWPART_TO_U32(dmatest_bus
);
775 cmd
.data1
= MYRI10GE_HIGHPART_TO_U32(dmatest_bus
);
776 cmd
.data2
= len
* 0x1;
777 status
= myri10ge_send_cmd(mgp
, test_type
, &cmd
, 0);
782 mgp
->write_dma
= ((cmd
.data0
>> 16) * len
* 2) / (cmd
.data0
& 0xffff);
784 cmd
.data0
= MYRI10GE_LOWPART_TO_U32(dmatest_bus
);
785 cmd
.data1
= MYRI10GE_HIGHPART_TO_U32(dmatest_bus
);
786 cmd
.data2
= len
* 0x10001;
787 status
= myri10ge_send_cmd(mgp
, test_type
, &cmd
, 0);
792 mgp
->read_write_dma
= ((cmd
.data0
>> 16) * len
* 2 * 2) /
793 (cmd
.data0
& 0xffff);
796 pci_unmap_page(mgp
->pdev
, dmatest_bus
, PAGE_SIZE
, DMA_BIDIRECTIONAL
);
797 put_page(dmatest_page
);
799 if (status
!= 0 && test_type
!= MXGEFW_CMD_UNALIGNED_TEST
)
800 dev_warn(&mgp
->pdev
->dev
, "DMA %s benchmark failed: %d\n",
806 static int myri10ge_reset(struct myri10ge_priv
*mgp
)
808 struct myri10ge_cmd cmd
;
812 /* try to send a reset command to the card to see if it
814 memset(&cmd
, 0, sizeof(cmd
));
815 status
= myri10ge_send_cmd(mgp
, MXGEFW_CMD_RESET
, &cmd
, 0);
817 dev_err(&mgp
->pdev
->dev
, "failed reset\n");
821 (void)myri10ge_dma_test(mgp
, MXGEFW_DMA_TEST
);
823 /* Now exchange information about interrupts */
825 bytes
= myri10ge_max_intr_slots
* sizeof(*mgp
->rx_done
.entry
);
826 memset(mgp
->rx_done
.entry
, 0, bytes
);
827 cmd
.data0
= (u32
) bytes
;
828 status
= myri10ge_send_cmd(mgp
, MXGEFW_CMD_SET_INTRQ_SIZE
, &cmd
, 0);
829 cmd
.data0
= MYRI10GE_LOWPART_TO_U32(mgp
->rx_done
.bus
);
830 cmd
.data1
= MYRI10GE_HIGHPART_TO_U32(mgp
->rx_done
.bus
);
831 status
|= myri10ge_send_cmd(mgp
, MXGEFW_CMD_SET_INTRQ_DMA
, &cmd
, 0);
834 myri10ge_send_cmd(mgp
, MXGEFW_CMD_GET_IRQ_ACK_OFFSET
, &cmd
, 0);
835 mgp
->irq_claim
= (__iomem __be32
*) (mgp
->sram
+ cmd
.data0
);
836 status
|= myri10ge_send_cmd(mgp
, MXGEFW_CMD_GET_IRQ_DEASSERT_OFFSET
,
838 mgp
->irq_deassert
= (__iomem __be32
*) (mgp
->sram
+ cmd
.data0
);
840 status
|= myri10ge_send_cmd
841 (mgp
, MXGEFW_CMD_GET_INTR_COAL_DELAY_OFFSET
, &cmd
, 0);
842 mgp
->intr_coal_delay_ptr
= (__iomem __be32
*) (mgp
->sram
+ cmd
.data0
);
844 dev_err(&mgp
->pdev
->dev
, "failed set interrupt parameters\n");
847 put_be32(htonl(mgp
->intr_coal_delay
), mgp
->intr_coal_delay_ptr
);
849 memset(mgp
->rx_done
.entry
, 0, bytes
);
851 /* reset mcp/driver shared state back to 0 */
854 mgp
->tx
.pkt_start
= 0;
855 mgp
->tx
.pkt_done
= 0;
857 mgp
->rx_small
.cnt
= 0;
858 mgp
->rx_done
.idx
= 0;
859 mgp
->rx_done
.cnt
= 0;
860 mgp
->link_changes
= 0;
861 status
= myri10ge_update_mac_address(mgp
, mgp
->dev
->dev_addr
);
862 myri10ge_change_pause(mgp
, mgp
->pause
);
863 myri10ge_set_multicast_list(mgp
->dev
);
868 myri10ge_submit_8rx(struct mcp_kreq_ether_recv __iomem
* dst
,
869 struct mcp_kreq_ether_recv
*src
)
874 src
->addr_low
= htonl(DMA_32BIT_MASK
);
875 myri10ge_pio_copy(dst
, src
, 4 * sizeof(*src
));
877 myri10ge_pio_copy(dst
+ 4, src
+ 4, 4 * sizeof(*src
));
880 put_be32(low
, &dst
->addr_low
);
884 static inline void myri10ge_vlan_ip_csum(struct sk_buff
*skb
, __wsum hw_csum
)
886 struct vlan_hdr
*vh
= (struct vlan_hdr
*)(skb
->data
);
888 if ((skb
->protocol
== htons(ETH_P_8021Q
)) &&
889 (vh
->h_vlan_encapsulated_proto
== htons(ETH_P_IP
) ||
890 vh
->h_vlan_encapsulated_proto
== htons(ETH_P_IPV6
))) {
892 skb
->ip_summed
= CHECKSUM_COMPLETE
;
897 myri10ge_rx_skb_build(struct sk_buff
*skb
, u8
* va
,
898 struct skb_frag_struct
*rx_frags
, int len
, int hlen
)
900 struct skb_frag_struct
*skb_frags
;
902 skb
->len
= skb
->data_len
= len
;
903 skb
->truesize
= len
+ sizeof(struct sk_buff
);
904 /* attach the page(s) */
906 skb_frags
= skb_shinfo(skb
)->frags
;
908 memcpy(skb_frags
, rx_frags
, sizeof(*skb_frags
));
909 len
-= rx_frags
->size
;
912 skb_shinfo(skb
)->nr_frags
++;
915 /* pskb_may_pull is not available in irq context, but
916 * skb_pull() (for ether_pad and eth_type_trans()) requires
917 * the beginning of the packet in skb_headlen(), move it
919 skb_copy_to_linear_data(skb
, va
, hlen
);
920 skb_shinfo(skb
)->frags
[0].page_offset
+= hlen
;
921 skb_shinfo(skb
)->frags
[0].size
-= hlen
;
922 skb
->data_len
-= hlen
;
924 skb_pull(skb
, MXGEFW_PAD
);
928 myri10ge_alloc_rx_pages(struct myri10ge_priv
*mgp
, struct myri10ge_rx_buf
*rx
,
929 int bytes
, int watchdog
)
934 if (unlikely(rx
->watchdog_needed
&& !watchdog
))
937 /* try to refill entire ring */
938 while (rx
->fill_cnt
!= (rx
->cnt
+ rx
->mask
+ 1)) {
939 idx
= rx
->fill_cnt
& rx
->mask
;
940 if (rx
->page_offset
+ bytes
<= MYRI10GE_ALLOC_SIZE
) {
941 /* we can use part of previous page */
944 /* we need a new page */
946 alloc_pages(GFP_ATOMIC
| __GFP_COMP
,
947 MYRI10GE_ALLOC_ORDER
);
948 if (unlikely(page
== NULL
)) {
949 if (rx
->fill_cnt
- rx
->cnt
< 16)
950 rx
->watchdog_needed
= 1;
955 rx
->bus
= pci_map_page(mgp
->pdev
, page
, 0,
959 rx
->info
[idx
].page
= rx
->page
;
960 rx
->info
[idx
].page_offset
= rx
->page_offset
;
961 /* note that this is the address of the start of the
963 pci_unmap_addr_set(&rx
->info
[idx
], bus
, rx
->bus
);
964 rx
->shadow
[idx
].addr_low
=
965 htonl(MYRI10GE_LOWPART_TO_U32(rx
->bus
) + rx
->page_offset
);
966 rx
->shadow
[idx
].addr_high
=
967 htonl(MYRI10GE_HIGHPART_TO_U32(rx
->bus
));
969 /* start next packet on a cacheline boundary */
970 rx
->page_offset
+= SKB_DATA_ALIGN(bytes
);
972 #if MYRI10GE_ALLOC_SIZE > 4096
973 /* don't cross a 4KB boundary */
974 if ((rx
->page_offset
>> 12) !=
975 ((rx
->page_offset
+ bytes
- 1) >> 12))
976 rx
->page_offset
= (rx
->page_offset
+ 4096) & ~4095;
980 /* copy 8 descriptors to the firmware at a time */
981 if ((idx
& 7) == 7) {
982 if (rx
->wc_fifo
== NULL
)
983 myri10ge_submit_8rx(&rx
->lanai
[idx
- 7],
984 &rx
->shadow
[idx
- 7]);
987 myri10ge_pio_copy(rx
->wc_fifo
,
988 &rx
->shadow
[idx
- 7], 64);
995 myri10ge_unmap_rx_page(struct pci_dev
*pdev
,
996 struct myri10ge_rx_buffer_state
*info
, int bytes
)
998 /* unmap the recvd page if we're the only or last user of it */
999 if (bytes
>= MYRI10GE_ALLOC_SIZE
/ 2 ||
1000 (info
->page_offset
+ 2 * bytes
) > MYRI10GE_ALLOC_SIZE
) {
1001 pci_unmap_page(pdev
, (pci_unmap_addr(info
, bus
)
1002 & ~(MYRI10GE_ALLOC_SIZE
- 1)),
1003 MYRI10GE_ALLOC_SIZE
, PCI_DMA_FROMDEVICE
);
1007 #define MYRI10GE_HLEN 64 /* The number of bytes to copy from a
1008 * page into an skb */
1011 myri10ge_rx_done(struct myri10ge_priv
*mgp
, struct myri10ge_rx_buf
*rx
,
1012 int bytes
, int len
, __wsum csum
)
1014 struct sk_buff
*skb
;
1015 struct skb_frag_struct rx_frags
[MYRI10GE_MAX_FRAGS_PER_FRAME
];
1016 int i
, idx
, hlen
, remainder
;
1017 struct pci_dev
*pdev
= mgp
->pdev
;
1018 struct net_device
*dev
= mgp
->dev
;
1022 idx
= rx
->cnt
& rx
->mask
;
1023 va
= page_address(rx
->info
[idx
].page
) + rx
->info
[idx
].page_offset
;
1025 /* Fill skb_frag_struct(s) with data from our receive */
1026 for (i
= 0, remainder
= len
; remainder
> 0; i
++) {
1027 myri10ge_unmap_rx_page(pdev
, &rx
->info
[idx
], bytes
);
1028 rx_frags
[i
].page
= rx
->info
[idx
].page
;
1029 rx_frags
[i
].page_offset
= rx
->info
[idx
].page_offset
;
1030 if (remainder
< MYRI10GE_ALLOC_SIZE
)
1031 rx_frags
[i
].size
= remainder
;
1033 rx_frags
[i
].size
= MYRI10GE_ALLOC_SIZE
;
1035 idx
= rx
->cnt
& rx
->mask
;
1036 remainder
-= MYRI10GE_ALLOC_SIZE
;
1039 if (mgp
->csum_flag
&& myri10ge_lro
) {
1040 rx_frags
[0].page_offset
+= MXGEFW_PAD
;
1041 rx_frags
[0].size
-= MXGEFW_PAD
;
1043 lro_receive_frags(&mgp
->rx_done
.lro_mgr
, rx_frags
,
1044 len
, len
, (void *)(unsigned long)csum
, csum
);
1048 hlen
= MYRI10GE_HLEN
> len
? len
: MYRI10GE_HLEN
;
1050 /* allocate an skb to attach the page(s) to. */
1052 skb
= netdev_alloc_skb(dev
, MYRI10GE_HLEN
+ 16);
1053 if (unlikely(skb
== NULL
)) {
1054 mgp
->stats
.rx_dropped
++;
1057 put_page(rx_frags
[i
].page
);
1062 /* Attach the pages to the skb, and trim off any padding */
1063 myri10ge_rx_skb_build(skb
, va
, rx_frags
, len
, hlen
);
1064 if (skb_shinfo(skb
)->frags
[0].size
<= 0) {
1065 put_page(skb_shinfo(skb
)->frags
[0].page
);
1066 skb_shinfo(skb
)->nr_frags
= 0;
1068 skb
->protocol
= eth_type_trans(skb
, dev
);
1070 if (mgp
->csum_flag
) {
1071 if ((skb
->protocol
== htons(ETH_P_IP
)) ||
1072 (skb
->protocol
== htons(ETH_P_IPV6
))) {
1074 skb
->ip_summed
= CHECKSUM_COMPLETE
;
1076 myri10ge_vlan_ip_csum(skb
, csum
);
1078 netif_receive_skb(skb
);
1079 dev
->last_rx
= jiffies
;
1083 static inline void myri10ge_tx_done(struct myri10ge_priv
*mgp
, int mcp_index
)
1085 struct pci_dev
*pdev
= mgp
->pdev
;
1086 struct myri10ge_tx_buf
*tx
= &mgp
->tx
;
1087 struct sk_buff
*skb
;
1090 while (tx
->pkt_done
!= mcp_index
) {
1091 idx
= tx
->done
& tx
->mask
;
1092 skb
= tx
->info
[idx
].skb
;
1095 tx
->info
[idx
].skb
= NULL
;
1096 if (tx
->info
[idx
].last
) {
1098 tx
->info
[idx
].last
= 0;
1101 len
= pci_unmap_len(&tx
->info
[idx
], len
);
1102 pci_unmap_len_set(&tx
->info
[idx
], len
, 0);
1104 mgp
->stats
.tx_bytes
+= skb
->len
;
1105 mgp
->stats
.tx_packets
++;
1106 dev_kfree_skb_irq(skb
);
1108 pci_unmap_single(pdev
,
1109 pci_unmap_addr(&tx
->info
[idx
],
1114 pci_unmap_page(pdev
,
1115 pci_unmap_addr(&tx
->info
[idx
],
1120 /* start the queue if we've stopped it */
1121 if (netif_queue_stopped(mgp
->dev
)
1122 && tx
->req
- tx
->done
< (tx
->mask
>> 1)) {
1124 netif_wake_queue(mgp
->dev
);
1128 static inline int myri10ge_clean_rx_done(struct myri10ge_priv
*mgp
, int budget
)
1130 struct myri10ge_rx_done
*rx_done
= &mgp
->rx_done
;
1131 unsigned long rx_bytes
= 0;
1132 unsigned long rx_packets
= 0;
1133 unsigned long rx_ok
;
1135 int idx
= rx_done
->idx
;
1136 int cnt
= rx_done
->cnt
;
1141 while (rx_done
->entry
[idx
].length
!= 0 && work_done
++ < budget
) {
1142 length
= ntohs(rx_done
->entry
[idx
].length
);
1143 rx_done
->entry
[idx
].length
= 0;
1144 checksum
= csum_unfold(rx_done
->entry
[idx
].checksum
);
1145 if (length
<= mgp
->small_bytes
)
1146 rx_ok
= myri10ge_rx_done(mgp
, &mgp
->rx_small
,
1150 rx_ok
= myri10ge_rx_done(mgp
, &mgp
->rx_big
,
1153 rx_packets
+= rx_ok
;
1154 rx_bytes
+= rx_ok
* (unsigned long)length
;
1156 idx
= cnt
& (myri10ge_max_intr_slots
- 1);
1160 mgp
->stats
.rx_packets
+= rx_packets
;
1161 mgp
->stats
.rx_bytes
+= rx_bytes
;
1164 lro_flush_all(&rx_done
->lro_mgr
);
1166 /* restock receive rings if needed */
1167 if (mgp
->rx_small
.fill_cnt
- mgp
->rx_small
.cnt
< myri10ge_fill_thresh
)
1168 myri10ge_alloc_rx_pages(mgp
, &mgp
->rx_small
,
1169 mgp
->small_bytes
+ MXGEFW_PAD
, 0);
1170 if (mgp
->rx_big
.fill_cnt
- mgp
->rx_big
.cnt
< myri10ge_fill_thresh
)
1171 myri10ge_alloc_rx_pages(mgp
, &mgp
->rx_big
, mgp
->big_bytes
, 0);
1176 static inline void myri10ge_check_statblock(struct myri10ge_priv
*mgp
)
1178 struct mcp_irq_data
*stats
= mgp
->fw_stats
;
1180 if (unlikely(stats
->stats_updated
)) {
1181 unsigned link_up
= ntohl(stats
->link_up
);
1182 if (mgp
->link_state
!= link_up
) {
1183 mgp
->link_state
= link_up
;
1185 if (mgp
->link_state
== MXGEFW_LINK_UP
) {
1186 if (netif_msg_link(mgp
))
1188 "myri10ge: %s: link up\n",
1190 netif_carrier_on(mgp
->dev
);
1191 mgp
->link_changes
++;
1193 if (netif_msg_link(mgp
))
1195 "myri10ge: %s: link %s\n",
1197 (link_up
== MXGEFW_LINK_MYRINET
?
1198 "mismatch (Myrinet detected)" :
1200 netif_carrier_off(mgp
->dev
);
1201 mgp
->link_changes
++;
1204 if (mgp
->rdma_tags_available
!=
1205 ntohl(mgp
->fw_stats
->rdma_tags_available
)) {
1206 mgp
->rdma_tags_available
=
1207 ntohl(mgp
->fw_stats
->rdma_tags_available
);
1208 printk(KERN_WARNING
"myri10ge: %s: RDMA timed out! "
1209 "%d tags left\n", mgp
->dev
->name
,
1210 mgp
->rdma_tags_available
);
1212 mgp
->down_cnt
+= stats
->link_down
;
1213 if (stats
->link_down
)
1214 wake_up(&mgp
->down_wq
);
1218 static int myri10ge_poll(struct napi_struct
*napi
, int budget
)
1220 struct myri10ge_priv
*mgp
= container_of(napi
, struct myri10ge_priv
, napi
);
1221 struct net_device
*netdev
= mgp
->dev
;
1222 struct myri10ge_rx_done
*rx_done
= &mgp
->rx_done
;
1225 /* process as many rx events as NAPI will allow */
1226 work_done
= myri10ge_clean_rx_done(mgp
, budget
);
1228 if (rx_done
->entry
[rx_done
->idx
].length
== 0 || !netif_running(netdev
)) {
1229 netif_rx_complete(netdev
, napi
);
1230 put_be32(htonl(3), mgp
->irq_claim
);
1235 static irqreturn_t
myri10ge_intr(int irq
, void *arg
)
1237 struct myri10ge_priv
*mgp
= arg
;
1238 struct mcp_irq_data
*stats
= mgp
->fw_stats
;
1239 struct myri10ge_tx_buf
*tx
= &mgp
->tx
;
1240 u32 send_done_count
;
1243 /* make sure it is our IRQ, and that the DMA has finished */
1244 if (unlikely(!stats
->valid
))
1247 /* low bit indicates receives are present, so schedule
1248 * napi poll handler */
1249 if (stats
->valid
& 1)
1250 netif_rx_schedule(mgp
->dev
, &mgp
->napi
);
1252 if (!mgp
->msi_enabled
) {
1253 put_be32(0, mgp
->irq_deassert
);
1254 if (!myri10ge_deassert_wait
)
1260 /* Wait for IRQ line to go low, if using INTx */
1264 /* check for transmit completes and receives */
1265 send_done_count
= ntohl(stats
->send_done_count
);
1266 if (send_done_count
!= tx
->pkt_done
)
1267 myri10ge_tx_done(mgp
, (int)send_done_count
);
1268 if (unlikely(i
> myri10ge_max_irq_loops
)) {
1269 printk(KERN_WARNING
"myri10ge: %s: irq stuck?\n",
1272 schedule_work(&mgp
->watchdog_work
);
1274 if (likely(stats
->valid
== 0))
1280 myri10ge_check_statblock(mgp
);
1282 put_be32(htonl(3), mgp
->irq_claim
+ 1);
1283 return (IRQ_HANDLED
);
1287 myri10ge_get_settings(struct net_device
*netdev
, struct ethtool_cmd
*cmd
)
1289 cmd
->autoneg
= AUTONEG_DISABLE
;
1290 cmd
->speed
= SPEED_10000
;
1291 cmd
->duplex
= DUPLEX_FULL
;
1296 myri10ge_get_drvinfo(struct net_device
*netdev
, struct ethtool_drvinfo
*info
)
1298 struct myri10ge_priv
*mgp
= netdev_priv(netdev
);
1300 strlcpy(info
->driver
, "myri10ge", sizeof(info
->driver
));
1301 strlcpy(info
->version
, MYRI10GE_VERSION_STR
, sizeof(info
->version
));
1302 strlcpy(info
->fw_version
, mgp
->fw_version
, sizeof(info
->fw_version
));
1303 strlcpy(info
->bus_info
, pci_name(mgp
->pdev
), sizeof(info
->bus_info
));
1307 myri10ge_get_coalesce(struct net_device
*netdev
, struct ethtool_coalesce
*coal
)
1309 struct myri10ge_priv
*mgp
= netdev_priv(netdev
);
1310 coal
->rx_coalesce_usecs
= mgp
->intr_coal_delay
;
1315 myri10ge_set_coalesce(struct net_device
*netdev
, struct ethtool_coalesce
*coal
)
1317 struct myri10ge_priv
*mgp
= netdev_priv(netdev
);
1319 mgp
->intr_coal_delay
= coal
->rx_coalesce_usecs
;
1320 put_be32(htonl(mgp
->intr_coal_delay
), mgp
->intr_coal_delay_ptr
);
1325 myri10ge_get_pauseparam(struct net_device
*netdev
,
1326 struct ethtool_pauseparam
*pause
)
1328 struct myri10ge_priv
*mgp
= netdev_priv(netdev
);
1331 pause
->rx_pause
= mgp
->pause
;
1332 pause
->tx_pause
= mgp
->pause
;
1336 myri10ge_set_pauseparam(struct net_device
*netdev
,
1337 struct ethtool_pauseparam
*pause
)
1339 struct myri10ge_priv
*mgp
= netdev_priv(netdev
);
1341 if (pause
->tx_pause
!= mgp
->pause
)
1342 return myri10ge_change_pause(mgp
, pause
->tx_pause
);
1343 if (pause
->rx_pause
!= mgp
->pause
)
1344 return myri10ge_change_pause(mgp
, pause
->tx_pause
);
1345 if (pause
->autoneg
!= 0)
1351 myri10ge_get_ringparam(struct net_device
*netdev
,
1352 struct ethtool_ringparam
*ring
)
1354 struct myri10ge_priv
*mgp
= netdev_priv(netdev
);
1356 ring
->rx_mini_max_pending
= mgp
->rx_small
.mask
+ 1;
1357 ring
->rx_max_pending
= mgp
->rx_big
.mask
+ 1;
1358 ring
->rx_jumbo_max_pending
= 0;
1359 ring
->tx_max_pending
= mgp
->rx_small
.mask
+ 1;
1360 ring
->rx_mini_pending
= ring
->rx_mini_max_pending
;
1361 ring
->rx_pending
= ring
->rx_max_pending
;
1362 ring
->rx_jumbo_pending
= ring
->rx_jumbo_max_pending
;
1363 ring
->tx_pending
= ring
->tx_max_pending
;
1366 static u32
myri10ge_get_rx_csum(struct net_device
*netdev
)
1368 struct myri10ge_priv
*mgp
= netdev_priv(netdev
);
1375 static int myri10ge_set_rx_csum(struct net_device
*netdev
, u32 csum_enabled
)
1377 struct myri10ge_priv
*mgp
= netdev_priv(netdev
);
1379 mgp
->csum_flag
= MXGEFW_FLAGS_CKSUM
;
1385 static const char myri10ge_gstrings_stats
[][ETH_GSTRING_LEN
] = {
1386 "rx_packets", "tx_packets", "rx_bytes", "tx_bytes", "rx_errors",
1387 "tx_errors", "rx_dropped", "tx_dropped", "multicast", "collisions",
1388 "rx_length_errors", "rx_over_errors", "rx_crc_errors",
1389 "rx_frame_errors", "rx_fifo_errors", "rx_missed_errors",
1390 "tx_aborted_errors", "tx_carrier_errors", "tx_fifo_errors",
1391 "tx_heartbeat_errors", "tx_window_errors",
1392 /* device-specific stats */
1393 "tx_boundary", "WC", "irq", "MSI",
1394 "read_dma_bw_MBs", "write_dma_bw_MBs", "read_write_dma_bw_MBs",
1395 "serial_number", "tx_pkt_start", "tx_pkt_done",
1396 "tx_req", "tx_done", "rx_small_cnt", "rx_big_cnt",
1397 "wake_queue", "stop_queue", "watchdog_resets", "tx_linearized",
1398 "link_changes", "link_up", "dropped_link_overflow",
1399 "dropped_link_error_or_filtered",
1400 "dropped_pause", "dropped_bad_phy", "dropped_bad_crc32",
1401 "dropped_unicast_filtered", "dropped_multicast_filtered",
1402 "dropped_runt", "dropped_overrun", "dropped_no_small_buffer",
1403 "dropped_no_big_buffer", "LRO aggregated", "LRO flushed",
1404 "LRO avg aggr", "LRO no_desc"
1407 #define MYRI10GE_NET_STATS_LEN 21
1408 #define MYRI10GE_STATS_LEN sizeof(myri10ge_gstrings_stats) / ETH_GSTRING_LEN
1411 myri10ge_get_strings(struct net_device
*netdev
, u32 stringset
, u8
* data
)
1413 switch (stringset
) {
1415 memcpy(data
, *myri10ge_gstrings_stats
,
1416 sizeof(myri10ge_gstrings_stats
));
1421 static int myri10ge_get_sset_count(struct net_device
*netdev
, int sset
)
1425 return MYRI10GE_STATS_LEN
;
1432 myri10ge_get_ethtool_stats(struct net_device
*netdev
,
1433 struct ethtool_stats
*stats
, u64
* data
)
1435 struct myri10ge_priv
*mgp
= netdev_priv(netdev
);
1438 for (i
= 0; i
< MYRI10GE_NET_STATS_LEN
; i
++)
1439 data
[i
] = ((unsigned long *)&mgp
->stats
)[i
];
1441 data
[i
++] = (unsigned int)mgp
->tx
.boundary
;
1442 data
[i
++] = (unsigned int)mgp
->wc_enabled
;
1443 data
[i
++] = (unsigned int)mgp
->pdev
->irq
;
1444 data
[i
++] = (unsigned int)mgp
->msi_enabled
;
1445 data
[i
++] = (unsigned int)mgp
->read_dma
;
1446 data
[i
++] = (unsigned int)mgp
->write_dma
;
1447 data
[i
++] = (unsigned int)mgp
->read_write_dma
;
1448 data
[i
++] = (unsigned int)mgp
->serial_number
;
1449 data
[i
++] = (unsigned int)mgp
->tx
.pkt_start
;
1450 data
[i
++] = (unsigned int)mgp
->tx
.pkt_done
;
1451 data
[i
++] = (unsigned int)mgp
->tx
.req
;
1452 data
[i
++] = (unsigned int)mgp
->tx
.done
;
1453 data
[i
++] = (unsigned int)mgp
->rx_small
.cnt
;
1454 data
[i
++] = (unsigned int)mgp
->rx_big
.cnt
;
1455 data
[i
++] = (unsigned int)mgp
->wake_queue
;
1456 data
[i
++] = (unsigned int)mgp
->stop_queue
;
1457 data
[i
++] = (unsigned int)mgp
->watchdog_resets
;
1458 data
[i
++] = (unsigned int)mgp
->tx_linearized
;
1459 data
[i
++] = (unsigned int)mgp
->link_changes
;
1460 data
[i
++] = (unsigned int)ntohl(mgp
->fw_stats
->link_up
);
1461 data
[i
++] = (unsigned int)ntohl(mgp
->fw_stats
->dropped_link_overflow
);
1463 (unsigned int)ntohl(mgp
->fw_stats
->dropped_link_error_or_filtered
);
1464 data
[i
++] = (unsigned int)ntohl(mgp
->fw_stats
->dropped_pause
);
1465 data
[i
++] = (unsigned int)ntohl(mgp
->fw_stats
->dropped_bad_phy
);
1466 data
[i
++] = (unsigned int)ntohl(mgp
->fw_stats
->dropped_bad_crc32
);
1468 (unsigned int)ntohl(mgp
->fw_stats
->dropped_unicast_filtered
);
1470 (unsigned int)ntohl(mgp
->fw_stats
->dropped_multicast_filtered
);
1471 data
[i
++] = (unsigned int)ntohl(mgp
->fw_stats
->dropped_runt
);
1472 data
[i
++] = (unsigned int)ntohl(mgp
->fw_stats
->dropped_overrun
);
1473 data
[i
++] = (unsigned int)ntohl(mgp
->fw_stats
->dropped_no_small_buffer
);
1474 data
[i
++] = (unsigned int)ntohl(mgp
->fw_stats
->dropped_no_big_buffer
);
1475 data
[i
++] = mgp
->rx_done
.lro_mgr
.stats
.aggregated
;
1476 data
[i
++] = mgp
->rx_done
.lro_mgr
.stats
.flushed
;
1477 if (mgp
->rx_done
.lro_mgr
.stats
.flushed
)
1478 data
[i
++] = mgp
->rx_done
.lro_mgr
.stats
.aggregated
/
1479 mgp
->rx_done
.lro_mgr
.stats
.flushed
;
1482 data
[i
++] = mgp
->rx_done
.lro_mgr
.stats
.no_desc
;
1485 static void myri10ge_set_msglevel(struct net_device
*netdev
, u32 value
)
1487 struct myri10ge_priv
*mgp
= netdev_priv(netdev
);
1488 mgp
->msg_enable
= value
;
1491 static u32
myri10ge_get_msglevel(struct net_device
*netdev
)
1493 struct myri10ge_priv
*mgp
= netdev_priv(netdev
);
1494 return mgp
->msg_enable
;
1497 static const struct ethtool_ops myri10ge_ethtool_ops
= {
1498 .get_settings
= myri10ge_get_settings
,
1499 .get_drvinfo
= myri10ge_get_drvinfo
,
1500 .get_coalesce
= myri10ge_get_coalesce
,
1501 .set_coalesce
= myri10ge_set_coalesce
,
1502 .get_pauseparam
= myri10ge_get_pauseparam
,
1503 .set_pauseparam
= myri10ge_set_pauseparam
,
1504 .get_ringparam
= myri10ge_get_ringparam
,
1505 .get_rx_csum
= myri10ge_get_rx_csum
,
1506 .set_rx_csum
= myri10ge_set_rx_csum
,
1507 .set_tx_csum
= ethtool_op_set_tx_hw_csum
,
1508 .set_sg
= ethtool_op_set_sg
,
1509 .set_tso
= ethtool_op_set_tso
,
1510 .get_link
= ethtool_op_get_link
,
1511 .get_strings
= myri10ge_get_strings
,
1512 .get_sset_count
= myri10ge_get_sset_count
,
1513 .get_ethtool_stats
= myri10ge_get_ethtool_stats
,
1514 .set_msglevel
= myri10ge_set_msglevel
,
1515 .get_msglevel
= myri10ge_get_msglevel
1518 static int myri10ge_allocate_rings(struct net_device
*dev
)
1520 struct myri10ge_priv
*mgp
;
1521 struct myri10ge_cmd cmd
;
1522 int tx_ring_size
, rx_ring_size
;
1523 int tx_ring_entries
, rx_ring_entries
;
1527 mgp
= netdev_priv(dev
);
1529 /* get ring sizes */
1531 status
= myri10ge_send_cmd(mgp
, MXGEFW_CMD_GET_SEND_RING_SIZE
, &cmd
, 0);
1532 tx_ring_size
= cmd
.data0
;
1533 status
|= myri10ge_send_cmd(mgp
, MXGEFW_CMD_GET_RX_RING_SIZE
, &cmd
, 0);
1536 rx_ring_size
= cmd
.data0
;
1538 tx_ring_entries
= tx_ring_size
/ sizeof(struct mcp_kreq_ether_send
);
1539 rx_ring_entries
= rx_ring_size
/ sizeof(struct mcp_dma_addr
);
1540 mgp
->tx
.mask
= tx_ring_entries
- 1;
1541 mgp
->rx_small
.mask
= mgp
->rx_big
.mask
= rx_ring_entries
- 1;
1545 /* allocate the host shadow rings */
1547 bytes
= 8 + (MYRI10GE_MAX_SEND_DESC_TSO
+ 4)
1548 * sizeof(*mgp
->tx
.req_list
);
1549 mgp
->tx
.req_bytes
= kzalloc(bytes
, GFP_KERNEL
);
1550 if (mgp
->tx
.req_bytes
== NULL
)
1551 goto abort_with_nothing
;
1553 /* ensure req_list entries are aligned to 8 bytes */
1554 mgp
->tx
.req_list
= (struct mcp_kreq_ether_send
*)
1555 ALIGN((unsigned long)mgp
->tx
.req_bytes
, 8);
1557 bytes
= rx_ring_entries
* sizeof(*mgp
->rx_small
.shadow
);
1558 mgp
->rx_small
.shadow
= kzalloc(bytes
, GFP_KERNEL
);
1559 if (mgp
->rx_small
.shadow
== NULL
)
1560 goto abort_with_tx_req_bytes
;
1562 bytes
= rx_ring_entries
* sizeof(*mgp
->rx_big
.shadow
);
1563 mgp
->rx_big
.shadow
= kzalloc(bytes
, GFP_KERNEL
);
1564 if (mgp
->rx_big
.shadow
== NULL
)
1565 goto abort_with_rx_small_shadow
;
1567 /* allocate the host info rings */
1569 bytes
= tx_ring_entries
* sizeof(*mgp
->tx
.info
);
1570 mgp
->tx
.info
= kzalloc(bytes
, GFP_KERNEL
);
1571 if (mgp
->tx
.info
== NULL
)
1572 goto abort_with_rx_big_shadow
;
1574 bytes
= rx_ring_entries
* sizeof(*mgp
->rx_small
.info
);
1575 mgp
->rx_small
.info
= kzalloc(bytes
, GFP_KERNEL
);
1576 if (mgp
->rx_small
.info
== NULL
)
1577 goto abort_with_tx_info
;
1579 bytes
= rx_ring_entries
* sizeof(*mgp
->rx_big
.info
);
1580 mgp
->rx_big
.info
= kzalloc(bytes
, GFP_KERNEL
);
1581 if (mgp
->rx_big
.info
== NULL
)
1582 goto abort_with_rx_small_info
;
1584 /* Fill the receive rings */
1585 mgp
->rx_big
.cnt
= 0;
1586 mgp
->rx_small
.cnt
= 0;
1587 mgp
->rx_big
.fill_cnt
= 0;
1588 mgp
->rx_small
.fill_cnt
= 0;
1589 mgp
->rx_small
.page_offset
= MYRI10GE_ALLOC_SIZE
;
1590 mgp
->rx_big
.page_offset
= MYRI10GE_ALLOC_SIZE
;
1591 mgp
->rx_small
.watchdog_needed
= 0;
1592 mgp
->rx_big
.watchdog_needed
= 0;
1593 myri10ge_alloc_rx_pages(mgp
, &mgp
->rx_small
,
1594 mgp
->small_bytes
+ MXGEFW_PAD
, 0);
1596 if (mgp
->rx_small
.fill_cnt
< mgp
->rx_small
.mask
+ 1) {
1597 printk(KERN_ERR
"myri10ge: %s: alloced only %d small bufs\n",
1598 dev
->name
, mgp
->rx_small
.fill_cnt
);
1599 goto abort_with_rx_small_ring
;
1602 myri10ge_alloc_rx_pages(mgp
, &mgp
->rx_big
, mgp
->big_bytes
, 0);
1603 if (mgp
->rx_big
.fill_cnt
< mgp
->rx_big
.mask
+ 1) {
1604 printk(KERN_ERR
"myri10ge: %s: alloced only %d big bufs\n",
1605 dev
->name
, mgp
->rx_big
.fill_cnt
);
1606 goto abort_with_rx_big_ring
;
1611 abort_with_rx_big_ring
:
1612 for (i
= mgp
->rx_big
.cnt
; i
< mgp
->rx_big
.fill_cnt
; i
++) {
1613 int idx
= i
& mgp
->rx_big
.mask
;
1614 myri10ge_unmap_rx_page(mgp
->pdev
, &mgp
->rx_big
.info
[idx
],
1616 put_page(mgp
->rx_big
.info
[idx
].page
);
1619 abort_with_rx_small_ring
:
1620 for (i
= mgp
->rx_small
.cnt
; i
< mgp
->rx_small
.fill_cnt
; i
++) {
1621 int idx
= i
& mgp
->rx_small
.mask
;
1622 myri10ge_unmap_rx_page(mgp
->pdev
, &mgp
->rx_small
.info
[idx
],
1623 mgp
->small_bytes
+ MXGEFW_PAD
);
1624 put_page(mgp
->rx_small
.info
[idx
].page
);
1627 kfree(mgp
->rx_big
.info
);
1629 abort_with_rx_small_info
:
1630 kfree(mgp
->rx_small
.info
);
1633 kfree(mgp
->tx
.info
);
1635 abort_with_rx_big_shadow
:
1636 kfree(mgp
->rx_big
.shadow
);
1638 abort_with_rx_small_shadow
:
1639 kfree(mgp
->rx_small
.shadow
);
1641 abort_with_tx_req_bytes
:
1642 kfree(mgp
->tx
.req_bytes
);
1643 mgp
->tx
.req_bytes
= NULL
;
1644 mgp
->tx
.req_list
= NULL
;
1650 static void myri10ge_free_rings(struct net_device
*dev
)
1652 struct myri10ge_priv
*mgp
;
1653 struct sk_buff
*skb
;
1654 struct myri10ge_tx_buf
*tx
;
1657 mgp
= netdev_priv(dev
);
1659 for (i
= mgp
->rx_big
.cnt
; i
< mgp
->rx_big
.fill_cnt
; i
++) {
1660 idx
= i
& mgp
->rx_big
.mask
;
1661 if (i
== mgp
->rx_big
.fill_cnt
- 1)
1662 mgp
->rx_big
.info
[idx
].page_offset
= MYRI10GE_ALLOC_SIZE
;
1663 myri10ge_unmap_rx_page(mgp
->pdev
, &mgp
->rx_big
.info
[idx
],
1665 put_page(mgp
->rx_big
.info
[idx
].page
);
1668 for (i
= mgp
->rx_small
.cnt
; i
< mgp
->rx_small
.fill_cnt
; i
++) {
1669 idx
= i
& mgp
->rx_small
.mask
;
1670 if (i
== mgp
->rx_small
.fill_cnt
- 1)
1671 mgp
->rx_small
.info
[idx
].page_offset
=
1672 MYRI10GE_ALLOC_SIZE
;
1673 myri10ge_unmap_rx_page(mgp
->pdev
, &mgp
->rx_small
.info
[idx
],
1674 mgp
->small_bytes
+ MXGEFW_PAD
);
1675 put_page(mgp
->rx_small
.info
[idx
].page
);
1678 while (tx
->done
!= tx
->req
) {
1679 idx
= tx
->done
& tx
->mask
;
1680 skb
= tx
->info
[idx
].skb
;
1683 tx
->info
[idx
].skb
= NULL
;
1685 len
= pci_unmap_len(&tx
->info
[idx
], len
);
1686 pci_unmap_len_set(&tx
->info
[idx
], len
, 0);
1688 mgp
->stats
.tx_dropped
++;
1689 dev_kfree_skb_any(skb
);
1691 pci_unmap_single(mgp
->pdev
,
1692 pci_unmap_addr(&tx
->info
[idx
],
1697 pci_unmap_page(mgp
->pdev
,
1698 pci_unmap_addr(&tx
->info
[idx
],
1703 kfree(mgp
->rx_big
.info
);
1705 kfree(mgp
->rx_small
.info
);
1707 kfree(mgp
->tx
.info
);
1709 kfree(mgp
->rx_big
.shadow
);
1711 kfree(mgp
->rx_small
.shadow
);
1713 kfree(mgp
->tx
.req_bytes
);
1714 mgp
->tx
.req_bytes
= NULL
;
1715 mgp
->tx
.req_list
= NULL
;
1718 static int myri10ge_request_irq(struct myri10ge_priv
*mgp
)
1720 struct pci_dev
*pdev
= mgp
->pdev
;
1724 status
= pci_enable_msi(pdev
);
1727 "Error %d setting up MSI; falling back to xPIC\n",
1730 mgp
->msi_enabled
= 1;
1732 mgp
->msi_enabled
= 0;
1734 status
= request_irq(pdev
->irq
, myri10ge_intr
, IRQF_SHARED
,
1735 mgp
->dev
->name
, mgp
);
1737 dev_err(&pdev
->dev
, "failed to allocate IRQ\n");
1738 if (mgp
->msi_enabled
)
1739 pci_disable_msi(pdev
);
1744 static void myri10ge_free_irq(struct myri10ge_priv
*mgp
)
1746 struct pci_dev
*pdev
= mgp
->pdev
;
1748 free_irq(pdev
->irq
, mgp
);
1749 if (mgp
->msi_enabled
)
1750 pci_disable_msi(pdev
);
1754 myri10ge_get_frag_header(struct skb_frag_struct
*frag
, void **mac_hdr
,
1755 void **ip_hdr
, void **tcpudp_hdr
,
1756 u64
* hdr_flags
, void *priv
)
1759 struct vlan_ethhdr
*veh
;
1761 u8
*va
= page_address(frag
->page
) + frag
->page_offset
;
1762 unsigned long ll_hlen
;
1763 __wsum csum
= (__wsum
) (unsigned long)priv
;
1765 /* find the mac header, aborting if not IPv4 */
1767 eh
= (struct ethhdr
*)va
;
1770 if (eh
->h_proto
!= htons(ETH_P_IP
)) {
1771 if (eh
->h_proto
== htons(ETH_P_8021Q
)) {
1772 veh
= (struct vlan_ethhdr
*)va
;
1773 if (veh
->h_vlan_encapsulated_proto
!= htons(ETH_P_IP
))
1776 ll_hlen
+= VLAN_HLEN
;
1779 * HW checksum starts ETH_HLEN bytes into
1780 * frame, so we must subtract off the VLAN
1781 * header's checksum before csum can be used
1783 csum
= csum_sub(csum
, csum_partial(va
+ ETH_HLEN
,
1789 *hdr_flags
= LRO_IPV4
;
1791 iph
= (struct iphdr
*)(va
+ ll_hlen
);
1793 if (iph
->protocol
!= IPPROTO_TCP
)
1795 *hdr_flags
|= LRO_TCP
;
1796 *tcpudp_hdr
= (u8
*) (*ip_hdr
) + (iph
->ihl
<< 2);
1798 /* verify the IP checksum */
1799 if (unlikely(ip_fast_csum((u8
*) iph
, iph
->ihl
)))
1802 /* verify the checksum */
1803 if (unlikely(csum_tcpudp_magic(iph
->saddr
, iph
->daddr
,
1804 ntohs(iph
->tot_len
) - (iph
->ihl
<< 2),
1805 IPPROTO_TCP
, csum
)))
1811 static int myri10ge_open(struct net_device
*dev
)
1813 struct myri10ge_priv
*mgp
;
1814 struct myri10ge_cmd cmd
;
1815 struct net_lro_mgr
*lro_mgr
;
1816 int status
, big_pow2
;
1818 mgp
= netdev_priv(dev
);
1820 if (mgp
->running
!= MYRI10GE_ETH_STOPPED
)
1823 mgp
->running
= MYRI10GE_ETH_STARTING
;
1824 status
= myri10ge_reset(mgp
);
1826 printk(KERN_ERR
"myri10ge: %s: failed reset\n", dev
->name
);
1827 goto abort_with_nothing
;
1830 status
= myri10ge_request_irq(mgp
);
1832 goto abort_with_nothing
;
1834 /* decide what small buffer size to use. For good TCP rx
1835 * performance, it is important to not receive 1514 byte
1836 * frames into jumbo buffers, as it confuses the socket buffer
1837 * accounting code, leading to drops and erratic performance.
1840 if (dev
->mtu
<= ETH_DATA_LEN
)
1841 /* enough for a TCP header */
1842 mgp
->small_bytes
= (128 > SMP_CACHE_BYTES
)
1843 ? (128 - MXGEFW_PAD
)
1844 : (SMP_CACHE_BYTES
- MXGEFW_PAD
);
1846 /* enough for a vlan encapsulated ETH_DATA_LEN frame */
1847 mgp
->small_bytes
= VLAN_ETH_FRAME_LEN
;
1849 /* Override the small buffer size? */
1850 if (myri10ge_small_bytes
> 0)
1851 mgp
->small_bytes
= myri10ge_small_bytes
;
1853 /* get the lanai pointers to the send and receive rings */
1855 status
|= myri10ge_send_cmd(mgp
, MXGEFW_CMD_GET_SEND_OFFSET
, &cmd
, 0);
1857 (struct mcp_kreq_ether_send __iomem
*)(mgp
->sram
+ cmd
.data0
);
1860 myri10ge_send_cmd(mgp
, MXGEFW_CMD_GET_SMALL_RX_OFFSET
, &cmd
, 0);
1861 mgp
->rx_small
.lanai
=
1862 (struct mcp_kreq_ether_recv __iomem
*)(mgp
->sram
+ cmd
.data0
);
1864 status
|= myri10ge_send_cmd(mgp
, MXGEFW_CMD_GET_BIG_RX_OFFSET
, &cmd
, 0);
1866 (struct mcp_kreq_ether_recv __iomem
*)(mgp
->sram
+ cmd
.data0
);
1870 "myri10ge: %s: failed to get ring sizes or locations\n",
1872 mgp
->running
= MYRI10GE_ETH_STOPPED
;
1873 goto abort_with_irq
;
1876 if (myri10ge_wcfifo
&& mgp
->wc_enabled
) {
1877 mgp
->tx
.wc_fifo
= (u8 __iomem
*) mgp
->sram
+ MXGEFW_ETH_SEND_4
;
1878 mgp
->rx_small
.wc_fifo
=
1879 (u8 __iomem
*) mgp
->sram
+ MXGEFW_ETH_RECV_SMALL
;
1880 mgp
->rx_big
.wc_fifo
=
1881 (u8 __iomem
*) mgp
->sram
+ MXGEFW_ETH_RECV_BIG
;
1883 mgp
->tx
.wc_fifo
= NULL
;
1884 mgp
->rx_small
.wc_fifo
= NULL
;
1885 mgp
->rx_big
.wc_fifo
= NULL
;
1888 /* Firmware needs the big buff size as a power of 2. Lie and
1889 * tell him the buffer is larger, because we only use 1
1890 * buffer/pkt, and the mtu will prevent overruns.
1892 big_pow2
= dev
->mtu
+ ETH_HLEN
+ VLAN_HLEN
+ MXGEFW_PAD
;
1893 if (big_pow2
< MYRI10GE_ALLOC_SIZE
/ 2) {
1894 while (!is_power_of_2(big_pow2
))
1896 mgp
->big_bytes
= dev
->mtu
+ ETH_HLEN
+ VLAN_HLEN
+ MXGEFW_PAD
;
1898 big_pow2
= MYRI10GE_ALLOC_SIZE
;
1899 mgp
->big_bytes
= big_pow2
;
1902 status
= myri10ge_allocate_rings(dev
);
1904 goto abort_with_irq
;
1906 /* now give firmware buffers sizes, and MTU */
1907 cmd
.data0
= dev
->mtu
+ ETH_HLEN
+ VLAN_HLEN
;
1908 status
= myri10ge_send_cmd(mgp
, MXGEFW_CMD_SET_MTU
, &cmd
, 0);
1909 cmd
.data0
= mgp
->small_bytes
;
1911 myri10ge_send_cmd(mgp
, MXGEFW_CMD_SET_SMALL_BUFFER_SIZE
, &cmd
, 0);
1912 cmd
.data0
= big_pow2
;
1914 myri10ge_send_cmd(mgp
, MXGEFW_CMD_SET_BIG_BUFFER_SIZE
, &cmd
, 0);
1916 printk(KERN_ERR
"myri10ge: %s: Couldn't set buffer sizes\n",
1918 goto abort_with_rings
;
1921 cmd
.data0
= MYRI10GE_LOWPART_TO_U32(mgp
->fw_stats_bus
);
1922 cmd
.data1
= MYRI10GE_HIGHPART_TO_U32(mgp
->fw_stats_bus
);
1923 cmd
.data2
= sizeof(struct mcp_irq_data
);
1924 status
= myri10ge_send_cmd(mgp
, MXGEFW_CMD_SET_STATS_DMA_V2
, &cmd
, 0);
1925 if (status
== -ENOSYS
) {
1926 dma_addr_t bus
= mgp
->fw_stats_bus
;
1927 bus
+= offsetof(struct mcp_irq_data
, send_done_count
);
1928 cmd
.data0
= MYRI10GE_LOWPART_TO_U32(bus
);
1929 cmd
.data1
= MYRI10GE_HIGHPART_TO_U32(bus
);
1930 status
= myri10ge_send_cmd(mgp
,
1931 MXGEFW_CMD_SET_STATS_DMA_OBSOLETE
,
1933 /* Firmware cannot support multicast without STATS_DMA_V2 */
1934 mgp
->fw_multicast_support
= 0;
1936 mgp
->fw_multicast_support
= 1;
1939 printk(KERN_ERR
"myri10ge: %s: Couldn't set stats DMA\n",
1941 goto abort_with_rings
;
1944 mgp
->link_state
= htonl(~0U);
1945 mgp
->rdma_tags_available
= 15;
1947 lro_mgr
= &mgp
->rx_done
.lro_mgr
;
1949 lro_mgr
->features
= LRO_F_NAPI
;
1950 lro_mgr
->ip_summed
= CHECKSUM_COMPLETE
;
1951 lro_mgr
->ip_summed_aggr
= CHECKSUM_UNNECESSARY
;
1952 lro_mgr
->max_desc
= MYRI10GE_MAX_LRO_DESCRIPTORS
;
1953 lro_mgr
->lro_arr
= mgp
->rx_done
.lro_desc
;
1954 lro_mgr
->get_frag_header
= myri10ge_get_frag_header
;
1955 lro_mgr
->max_aggr
= myri10ge_lro_max_pkts
;
1956 if (lro_mgr
->max_aggr
> MAX_SKB_FRAGS
)
1957 lro_mgr
->max_aggr
= MAX_SKB_FRAGS
;
1959 napi_enable(&mgp
->napi
); /* must happen prior to any irq */
1961 status
= myri10ge_send_cmd(mgp
, MXGEFW_CMD_ETHERNET_UP
, &cmd
, 0);
1963 printk(KERN_ERR
"myri10ge: %s: Couldn't bring up link\n",
1965 goto abort_with_rings
;
1968 mgp
->wake_queue
= 0;
1969 mgp
->stop_queue
= 0;
1970 mgp
->running
= MYRI10GE_ETH_RUNNING
;
1971 mgp
->watchdog_timer
.expires
= jiffies
+ myri10ge_watchdog_timeout
* HZ
;
1972 add_timer(&mgp
->watchdog_timer
);
1973 netif_wake_queue(dev
);
1977 myri10ge_free_rings(dev
);
1980 myri10ge_free_irq(mgp
);
1983 mgp
->running
= MYRI10GE_ETH_STOPPED
;
1987 static int myri10ge_close(struct net_device
*dev
)
1989 struct myri10ge_priv
*mgp
;
1990 struct myri10ge_cmd cmd
;
1991 int status
, old_down_cnt
;
1993 mgp
= netdev_priv(dev
);
1995 if (mgp
->running
!= MYRI10GE_ETH_RUNNING
)
1998 if (mgp
->tx
.req_bytes
== NULL
)
2001 del_timer_sync(&mgp
->watchdog_timer
);
2002 mgp
->running
= MYRI10GE_ETH_STOPPING
;
2003 napi_disable(&mgp
->napi
);
2004 netif_carrier_off(dev
);
2005 netif_stop_queue(dev
);
2006 old_down_cnt
= mgp
->down_cnt
;
2008 status
= myri10ge_send_cmd(mgp
, MXGEFW_CMD_ETHERNET_DOWN
, &cmd
, 0);
2010 printk(KERN_ERR
"myri10ge: %s: Couldn't bring down link\n",
2013 wait_event_timeout(mgp
->down_wq
, old_down_cnt
!= mgp
->down_cnt
, HZ
);
2014 if (old_down_cnt
== mgp
->down_cnt
)
2015 printk(KERN_ERR
"myri10ge: %s never got down irq\n", dev
->name
);
2017 netif_tx_disable(dev
);
2018 myri10ge_free_irq(mgp
);
2019 myri10ge_free_rings(dev
);
2021 mgp
->running
= MYRI10GE_ETH_STOPPED
;
2025 /* copy an array of struct mcp_kreq_ether_send's to the mcp. Copy
2026 * backwards one at a time and handle ring wraps */
2029 myri10ge_submit_req_backwards(struct myri10ge_tx_buf
*tx
,
2030 struct mcp_kreq_ether_send
*src
, int cnt
)
2032 int idx
, starting_slot
;
2033 starting_slot
= tx
->req
;
2036 idx
= (starting_slot
+ cnt
) & tx
->mask
;
2037 myri10ge_pio_copy(&tx
->lanai
[idx
], &src
[cnt
], sizeof(*src
));
2043 * copy an array of struct mcp_kreq_ether_send's to the mcp. Copy
2044 * at most 32 bytes at a time, so as to avoid involving the software
2045 * pio handler in the nic. We re-write the first segment's flags
2046 * to mark them valid only after writing the entire chain.
2050 myri10ge_submit_req(struct myri10ge_tx_buf
*tx
, struct mcp_kreq_ether_send
*src
,
2054 struct mcp_kreq_ether_send __iomem
*dstp
, *dst
;
2055 struct mcp_kreq_ether_send
*srcp
;
2058 idx
= tx
->req
& tx
->mask
;
2060 last_flags
= src
->flags
;
2063 dst
= dstp
= &tx
->lanai
[idx
];
2066 if ((idx
+ cnt
) < tx
->mask
) {
2067 for (i
= 0; i
< (cnt
- 1); i
+= 2) {
2068 myri10ge_pio_copy(dstp
, srcp
, 2 * sizeof(*src
));
2069 mb(); /* force write every 32 bytes */
2074 /* submit all but the first request, and ensure
2075 * that it is submitted below */
2076 myri10ge_submit_req_backwards(tx
, src
, cnt
);
2080 /* submit the first request */
2081 myri10ge_pio_copy(dstp
, srcp
, sizeof(*src
));
2082 mb(); /* barrier before setting valid flag */
2085 /* re-write the last 32-bits with the valid flags */
2086 src
->flags
= last_flags
;
2087 put_be32(*((__be32
*) src
+ 3), (__be32 __iomem
*) dst
+ 3);
2093 myri10ge_submit_req_wc(struct myri10ge_tx_buf
*tx
,
2094 struct mcp_kreq_ether_send
*src
, int cnt
)
2099 myri10ge_pio_copy(tx
->wc_fifo
, src
, 64);
2105 /* pad it to 64 bytes. The src is 64 bytes bigger than it
2106 * needs to be so that we don't overrun it */
2107 myri10ge_pio_copy(tx
->wc_fifo
+ MXGEFW_ETH_SEND_OFFSET(cnt
),
2114 * Transmit a packet. We need to split the packet so that a single
2115 * segment does not cross myri10ge->tx.boundary, so this makes segment
2116 * counting tricky. So rather than try to count segments up front, we
2117 * just give up if there are too few segments to hold a reasonably
2118 * fragmented packet currently available. If we run
2119 * out of segments while preparing a packet for DMA, we just linearize
2123 static int myri10ge_xmit(struct sk_buff
*skb
, struct net_device
*dev
)
2125 struct myri10ge_priv
*mgp
= netdev_priv(dev
);
2126 struct mcp_kreq_ether_send
*req
;
2127 struct myri10ge_tx_buf
*tx
= &mgp
->tx
;
2128 struct skb_frag_struct
*frag
;
2131 __be32 high_swapped
;
2133 int idx
, last_idx
, avail
, frag_cnt
, frag_idx
, count
, mss
, max_segments
;
2134 u16 pseudo_hdr_offset
, cksum_offset
;
2135 int cum_len
, seglen
, boundary
, rdma_count
;
2140 avail
= tx
->mask
- 1 - (tx
->req
- tx
->done
);
2143 max_segments
= MXGEFW_MAX_SEND_DESC
;
2145 if (skb_is_gso(skb
)) {
2146 mss
= skb_shinfo(skb
)->gso_size
;
2147 max_segments
= MYRI10GE_MAX_SEND_DESC_TSO
;
2150 if ((unlikely(avail
< max_segments
))) {
2151 /* we are out of transmit resources */
2153 netif_stop_queue(dev
);
2157 /* Setup checksum offloading, if needed */
2159 pseudo_hdr_offset
= 0;
2161 flags
= (MXGEFW_FLAGS_NO_TSO
| MXGEFW_FLAGS_FIRST
);
2162 if (likely(skb
->ip_summed
== CHECKSUM_PARTIAL
)) {
2163 cksum_offset
= skb_transport_offset(skb
);
2164 pseudo_hdr_offset
= cksum_offset
+ skb
->csum_offset
;
2165 /* If the headers are excessively large, then we must
2166 * fall back to a software checksum */
2167 if (unlikely(cksum_offset
> 255 || pseudo_hdr_offset
> 127)) {
2168 if (skb_checksum_help(skb
))
2171 pseudo_hdr_offset
= 0;
2173 odd_flag
= MXGEFW_FLAGS_ALIGN_ODD
;
2174 flags
|= MXGEFW_FLAGS_CKSUM
;
2180 if (mss
) { /* TSO */
2181 /* this removes any CKSUM flag from before */
2182 flags
= (MXGEFW_FLAGS_TSO_HDR
| MXGEFW_FLAGS_FIRST
);
2184 /* negative cum_len signifies to the
2185 * send loop that we are still in the
2186 * header portion of the TSO packet.
2187 * TSO header must be at most 134 bytes long */
2188 cum_len
= -(skb_transport_offset(skb
) + tcp_hdrlen(skb
));
2190 /* for TSO, pseudo_hdr_offset holds mss.
2191 * The firmware figures out where to put
2192 * the checksum by parsing the header. */
2193 pseudo_hdr_offset
= mss
;
2195 /* Mark small packets, and pad out tiny packets */
2196 if (skb
->len
<= MXGEFW_SEND_SMALL_SIZE
) {
2197 flags
|= MXGEFW_FLAGS_SMALL
;
2199 /* pad frames to at least ETH_ZLEN bytes */
2200 if (unlikely(skb
->len
< ETH_ZLEN
)) {
2201 if (skb_padto(skb
, ETH_ZLEN
)) {
2202 /* The packet is gone, so we must
2204 mgp
->stats
.tx_dropped
+= 1;
2207 /* adjust the len to account for the zero pad
2208 * so that the nic can know how long it is */
2209 skb
->len
= ETH_ZLEN
;
2213 /* map the skb for DMA */
2214 len
= skb
->len
- skb
->data_len
;
2215 idx
= tx
->req
& tx
->mask
;
2216 tx
->info
[idx
].skb
= skb
;
2217 bus
= pci_map_single(mgp
->pdev
, skb
->data
, len
, PCI_DMA_TODEVICE
);
2218 pci_unmap_addr_set(&tx
->info
[idx
], bus
, bus
);
2219 pci_unmap_len_set(&tx
->info
[idx
], len
, len
);
2221 frag_cnt
= skb_shinfo(skb
)->nr_frags
;
2226 /* "rdma_count" is the number of RDMAs belonging to the
2227 * current packet BEFORE the current send request. For
2228 * non-TSO packets, this is equal to "count".
2229 * For TSO packets, rdma_count needs to be reset
2230 * to 0 after a segment cut.
2232 * The rdma_count field of the send request is
2233 * the number of RDMAs of the packet starting at
2234 * that request. For TSO send requests with one ore more cuts
2235 * in the middle, this is the number of RDMAs starting
2236 * after the last cut in the request. All previous
2237 * segments before the last cut implicitly have 1 RDMA.
2239 * Since the number of RDMAs is not known beforehand,
2240 * it must be filled-in retroactively - after each
2241 * segmentation cut or at the end of the entire packet.
2245 /* Break the SKB or Fragment up into pieces which
2246 * do not cross mgp->tx.boundary */
2247 low
= MYRI10GE_LOWPART_TO_U32(bus
);
2248 high_swapped
= htonl(MYRI10GE_HIGHPART_TO_U32(bus
));
2253 if (unlikely(count
== max_segments
))
2254 goto abort_linearize
;
2256 boundary
= (low
+ tx
->boundary
) & ~(tx
->boundary
- 1);
2257 seglen
= boundary
- low
;
2260 flags_next
= flags
& ~MXGEFW_FLAGS_FIRST
;
2261 cum_len_next
= cum_len
+ seglen
;
2262 if (mss
) { /* TSO */
2263 (req
- rdma_count
)->rdma_count
= rdma_count
+ 1;
2265 if (likely(cum_len
>= 0)) { /* payload */
2266 int next_is_first
, chop
;
2268 chop
= (cum_len_next
> mss
);
2269 cum_len_next
= cum_len_next
% mss
;
2270 next_is_first
= (cum_len_next
== 0);
2271 flags
|= chop
* MXGEFW_FLAGS_TSO_CHOP
;
2272 flags_next
|= next_is_first
*
2274 rdma_count
|= -(chop
| next_is_first
);
2275 rdma_count
+= chop
& !next_is_first
;
2276 } else if (likely(cum_len_next
>= 0)) { /* header ends */
2282 small
= (mss
<= MXGEFW_SEND_SMALL_SIZE
);
2283 flags_next
= MXGEFW_FLAGS_TSO_PLD
|
2284 MXGEFW_FLAGS_FIRST
|
2285 (small
* MXGEFW_FLAGS_SMALL
);
2288 req
->addr_high
= high_swapped
;
2289 req
->addr_low
= htonl(low
);
2290 req
->pseudo_hdr_offset
= htons(pseudo_hdr_offset
);
2291 req
->pad
= 0; /* complete solid 16-byte block; does this matter? */
2292 req
->rdma_count
= 1;
2293 req
->length
= htons(seglen
);
2294 req
->cksum_offset
= cksum_offset
;
2295 req
->flags
= flags
| ((cum_len
& 1) * odd_flag
);
2299 cum_len
= cum_len_next
;
2304 if (unlikely(cksum_offset
> seglen
))
2305 cksum_offset
-= seglen
;
2309 if (frag_idx
== frag_cnt
)
2312 /* map next fragment for DMA */
2313 idx
= (count
+ tx
->req
) & tx
->mask
;
2314 frag
= &skb_shinfo(skb
)->frags
[frag_idx
];
2317 bus
= pci_map_page(mgp
->pdev
, frag
->page
, frag
->page_offset
,
2318 len
, PCI_DMA_TODEVICE
);
2319 pci_unmap_addr_set(&tx
->info
[idx
], bus
, bus
);
2320 pci_unmap_len_set(&tx
->info
[idx
], len
, len
);
2323 (req
- rdma_count
)->rdma_count
= rdma_count
;
2327 req
->flags
|= MXGEFW_FLAGS_TSO_LAST
;
2328 } while (!(req
->flags
& (MXGEFW_FLAGS_TSO_CHOP
|
2329 MXGEFW_FLAGS_FIRST
)));
2330 idx
= ((count
- 1) + tx
->req
) & tx
->mask
;
2331 tx
->info
[idx
].last
= 1;
2332 if (tx
->wc_fifo
== NULL
)
2333 myri10ge_submit_req(tx
, tx
->req_list
, count
);
2335 myri10ge_submit_req_wc(tx
, tx
->req_list
, count
);
2337 if ((avail
- count
) < MXGEFW_MAX_SEND_DESC
) {
2339 netif_stop_queue(dev
);
2341 dev
->trans_start
= jiffies
;
2345 /* Free any DMA resources we've alloced and clear out the skb
2346 * slot so as to not trip up assertions, and to avoid a
2347 * double-free if linearizing fails */
2349 last_idx
= (idx
+ 1) & tx
->mask
;
2350 idx
= tx
->req
& tx
->mask
;
2351 tx
->info
[idx
].skb
= NULL
;
2353 len
= pci_unmap_len(&tx
->info
[idx
], len
);
2355 if (tx
->info
[idx
].skb
!= NULL
)
2356 pci_unmap_single(mgp
->pdev
,
2357 pci_unmap_addr(&tx
->info
[idx
],
2361 pci_unmap_page(mgp
->pdev
,
2362 pci_unmap_addr(&tx
->info
[idx
],
2365 pci_unmap_len_set(&tx
->info
[idx
], len
, 0);
2366 tx
->info
[idx
].skb
= NULL
;
2368 idx
= (idx
+ 1) & tx
->mask
;
2369 } while (idx
!= last_idx
);
2370 if (skb_is_gso(skb
)) {
2372 "myri10ge: %s: TSO but wanted to linearize?!?!?\n",
2377 if (skb_linearize(skb
))
2380 mgp
->tx_linearized
++;
2384 dev_kfree_skb_any(skb
);
2385 mgp
->stats
.tx_dropped
+= 1;
2390 static struct net_device_stats
*myri10ge_get_stats(struct net_device
*dev
)
2392 struct myri10ge_priv
*mgp
= netdev_priv(dev
);
2396 static void myri10ge_set_multicast_list(struct net_device
*dev
)
2398 struct myri10ge_cmd cmd
;
2399 struct myri10ge_priv
*mgp
;
2400 struct dev_mc_list
*mc_list
;
2401 __be32 data
[2] = { 0, 0 };
2403 DECLARE_MAC_BUF(mac
);
2405 mgp
= netdev_priv(dev
);
2406 /* can be called from atomic contexts,
2407 * pass 1 to force atomicity in myri10ge_send_cmd() */
2408 myri10ge_change_promisc(mgp
, dev
->flags
& IFF_PROMISC
, 1);
2410 /* This firmware is known to not support multicast */
2411 if (!mgp
->fw_multicast_support
)
2414 /* Disable multicast filtering */
2416 err
= myri10ge_send_cmd(mgp
, MXGEFW_ENABLE_ALLMULTI
, &cmd
, 1);
2418 printk(KERN_ERR
"myri10ge: %s: Failed MXGEFW_ENABLE_ALLMULTI,"
2419 " error status: %d\n", dev
->name
, err
);
2423 if ((dev
->flags
& IFF_ALLMULTI
) || mgp
->adopted_rx_filter_bug
) {
2424 /* request to disable multicast filtering, so quit here */
2428 /* Flush the filters */
2430 err
= myri10ge_send_cmd(mgp
, MXGEFW_LEAVE_ALL_MULTICAST_GROUPS
,
2434 "myri10ge: %s: Failed MXGEFW_LEAVE_ALL_MULTICAST_GROUPS"
2435 ", error status: %d\n", dev
->name
, err
);
2439 /* Walk the multicast list, and add each address */
2440 for (mc_list
= dev
->mc_list
; mc_list
!= NULL
; mc_list
= mc_list
->next
) {
2441 memcpy(data
, &mc_list
->dmi_addr
, 6);
2442 cmd
.data0
= ntohl(data
[0]);
2443 cmd
.data1
= ntohl(data
[1]);
2444 err
= myri10ge_send_cmd(mgp
, MXGEFW_JOIN_MULTICAST_GROUP
,
2448 printk(KERN_ERR
"myri10ge: %s: Failed "
2449 "MXGEFW_JOIN_MULTICAST_GROUP, error status:"
2450 "%d\t", dev
->name
, err
);
2451 printk(KERN_ERR
"MAC %s\n",
2452 print_mac(mac
, mc_list
->dmi_addr
));
2456 /* Enable multicast filtering */
2457 err
= myri10ge_send_cmd(mgp
, MXGEFW_DISABLE_ALLMULTI
, &cmd
, 1);
2459 printk(KERN_ERR
"myri10ge: %s: Failed MXGEFW_DISABLE_ALLMULTI,"
2460 "error status: %d\n", dev
->name
, err
);
2470 static int myri10ge_set_mac_address(struct net_device
*dev
, void *addr
)
2472 struct sockaddr
*sa
= addr
;
2473 struct myri10ge_priv
*mgp
= netdev_priv(dev
);
2476 if (!is_valid_ether_addr(sa
->sa_data
))
2477 return -EADDRNOTAVAIL
;
2479 status
= myri10ge_update_mac_address(mgp
, sa
->sa_data
);
2482 "myri10ge: %s: changing mac address failed with %d\n",
2487 /* change the dev structure */
2488 memcpy(dev
->dev_addr
, sa
->sa_data
, 6);
2492 static int myri10ge_change_mtu(struct net_device
*dev
, int new_mtu
)
2494 struct myri10ge_priv
*mgp
= netdev_priv(dev
);
2497 if ((new_mtu
< 68) || (ETH_HLEN
+ new_mtu
> MYRI10GE_MAX_ETHER_MTU
)) {
2498 printk(KERN_ERR
"myri10ge: %s: new mtu (%d) is not valid\n",
2499 dev
->name
, new_mtu
);
2502 printk(KERN_INFO
"%s: changing mtu from %d to %d\n",
2503 dev
->name
, dev
->mtu
, new_mtu
);
2505 /* if we change the mtu on an active device, we must
2506 * reset the device so the firmware sees the change */
2507 myri10ge_close(dev
);
2517 * Enable ECRC to align PCI-E Completion packets on an 8-byte boundary.
2518 * Only do it if the bridge is a root port since we don't want to disturb
2519 * any other device, except if forced with myri10ge_ecrc_enable > 1.
2522 static void myri10ge_enable_ecrc(struct myri10ge_priv
*mgp
)
2524 struct pci_dev
*bridge
= mgp
->pdev
->bus
->self
;
2525 struct device
*dev
= &mgp
->pdev
->dev
;
2532 if (!myri10ge_ecrc_enable
|| !bridge
)
2535 /* check that the bridge is a root port */
2536 cap
= pci_find_capability(bridge
, PCI_CAP_ID_EXP
);
2537 pci_read_config_word(bridge
, cap
+ PCI_CAP_FLAGS
, &val
);
2538 ext_type
= (val
& PCI_EXP_FLAGS_TYPE
) >> 4;
2539 if (ext_type
!= PCI_EXP_TYPE_ROOT_PORT
) {
2540 if (myri10ge_ecrc_enable
> 1) {
2541 struct pci_dev
*old_bridge
= bridge
;
2543 /* Walk the hierarchy up to the root port
2544 * where ECRC has to be enabled */
2546 bridge
= bridge
->bus
->self
;
2549 "Failed to find root port"
2550 " to force ECRC\n");
2554 pci_find_capability(bridge
, PCI_CAP_ID_EXP
);
2555 pci_read_config_word(bridge
,
2556 cap
+ PCI_CAP_FLAGS
, &val
);
2557 ext_type
= (val
& PCI_EXP_FLAGS_TYPE
) >> 4;
2558 } while (ext_type
!= PCI_EXP_TYPE_ROOT_PORT
);
2561 "Forcing ECRC on non-root port %s"
2562 " (enabling on root port %s)\n",
2563 pci_name(old_bridge
), pci_name(bridge
));
2566 "Not enabling ECRC on non-root port %s\n",
2572 cap
= pci_find_ext_capability(bridge
, PCI_EXT_CAP_ID_ERR
);
2576 ret
= pci_read_config_dword(bridge
, cap
+ PCI_ERR_CAP
, &err_cap
);
2578 dev_err(dev
, "failed reading ext-conf-space of %s\n",
2580 dev_err(dev
, "\t pci=nommconf in use? "
2581 "or buggy/incomplete/absent ACPI MCFG attr?\n");
2584 if (!(err_cap
& PCI_ERR_CAP_ECRC_GENC
))
2587 err_cap
|= PCI_ERR_CAP_ECRC_GENE
;
2588 pci_write_config_dword(bridge
, cap
+ PCI_ERR_CAP
, err_cap
);
2589 dev_info(dev
, "Enabled ECRC on upstream bridge %s\n", pci_name(bridge
));
2593 * The Lanai Z8E PCI-E interface achieves higher Read-DMA throughput
2594 * when the PCI-E Completion packets are aligned on an 8-byte
2595 * boundary. Some PCI-E chip sets always align Completion packets; on
2596 * the ones that do not, the alignment can be enforced by enabling
2597 * ECRC generation (if supported).
2599 * When PCI-E Completion packets are not aligned, it is actually more
2600 * efficient to limit Read-DMA transactions to 2KB, rather than 4KB.
2602 * If the driver can neither enable ECRC nor verify that it has
2603 * already been enabled, then it must use a firmware image which works
2604 * around unaligned completion packets (myri10ge_ethp_z8e.dat), and it
2605 * should also ensure that it never gives the device a Read-DMA which is
2606 * larger than 2KB by setting the tx.boundary to 2KB. If ECRC is
2607 * enabled, then the driver should use the aligned (myri10ge_eth_z8e.dat)
2608 * firmware image, and set tx.boundary to 4KB.
2611 static void myri10ge_firmware_probe(struct myri10ge_priv
*mgp
)
2613 struct pci_dev
*pdev
= mgp
->pdev
;
2614 struct device
*dev
= &pdev
->dev
;
2617 mgp
->tx
.boundary
= 4096;
2619 * Verify the max read request size was set to 4KB
2620 * before trying the test with 4KB.
2622 status
= pcie_get_readrq(pdev
);
2624 dev_err(dev
, "Couldn't read max read req size: %d\n", status
);
2627 if (status
!= 4096) {
2628 dev_warn(dev
, "Max Read Request size != 4096 (%d)\n", status
);
2629 mgp
->tx
.boundary
= 2048;
2632 * load the optimized firmware (which assumes aligned PCIe
2633 * completions) in order to see if it works on this host.
2635 mgp
->fw_name
= myri10ge_fw_aligned
;
2636 status
= myri10ge_load_firmware(mgp
);
2642 * Enable ECRC if possible
2644 myri10ge_enable_ecrc(mgp
);
2647 * Run a DMA test which watches for unaligned completions and
2648 * aborts on the first one seen.
2651 status
= myri10ge_dma_test(mgp
, MXGEFW_CMD_UNALIGNED_TEST
);
2653 return; /* keep the aligned firmware */
2655 if (status
!= -E2BIG
)
2656 dev_warn(dev
, "DMA test failed: %d\n", status
);
2657 if (status
== -ENOSYS
)
2658 dev_warn(dev
, "Falling back to ethp! "
2659 "Please install up to date fw\n");
2661 /* fall back to using the unaligned firmware */
2662 mgp
->tx
.boundary
= 2048;
2663 mgp
->fw_name
= myri10ge_fw_unaligned
;
2667 static void myri10ge_select_firmware(struct myri10ge_priv
*mgp
)
2669 if (myri10ge_force_firmware
== 0) {
2670 int link_width
, exp_cap
;
2673 exp_cap
= pci_find_capability(mgp
->pdev
, PCI_CAP_ID_EXP
);
2674 pci_read_config_word(mgp
->pdev
, exp_cap
+ PCI_EXP_LNKSTA
, &lnk
);
2675 link_width
= (lnk
>> 4) & 0x3f;
2677 /* Check to see if Link is less than 8 or if the
2678 * upstream bridge is known to provide aligned
2680 if (link_width
< 8) {
2681 dev_info(&mgp
->pdev
->dev
, "PCIE x%d Link\n",
2683 mgp
->tx
.boundary
= 4096;
2684 mgp
->fw_name
= myri10ge_fw_aligned
;
2686 myri10ge_firmware_probe(mgp
);
2689 if (myri10ge_force_firmware
== 1) {
2690 dev_info(&mgp
->pdev
->dev
,
2691 "Assuming aligned completions (forced)\n");
2692 mgp
->tx
.boundary
= 4096;
2693 mgp
->fw_name
= myri10ge_fw_aligned
;
2695 dev_info(&mgp
->pdev
->dev
,
2696 "Assuming unaligned completions (forced)\n");
2697 mgp
->tx
.boundary
= 2048;
2698 mgp
->fw_name
= myri10ge_fw_unaligned
;
2701 if (myri10ge_fw_name
!= NULL
) {
2702 dev_info(&mgp
->pdev
->dev
, "overriding firmware to %s\n",
2704 mgp
->fw_name
= myri10ge_fw_name
;
2710 static int myri10ge_suspend(struct pci_dev
*pdev
, pm_message_t state
)
2712 struct myri10ge_priv
*mgp
;
2713 struct net_device
*netdev
;
2715 mgp
= pci_get_drvdata(pdev
);
2720 netif_device_detach(netdev
);
2721 if (netif_running(netdev
)) {
2722 printk(KERN_INFO
"myri10ge: closing %s\n", netdev
->name
);
2724 myri10ge_close(netdev
);
2727 myri10ge_dummy_rdma(mgp
, 0);
2728 pci_save_state(pdev
);
2729 pci_disable_device(pdev
);
2731 return pci_set_power_state(pdev
, pci_choose_state(pdev
, state
));
2734 static int myri10ge_resume(struct pci_dev
*pdev
)
2736 struct myri10ge_priv
*mgp
;
2737 struct net_device
*netdev
;
2741 mgp
= pci_get_drvdata(pdev
);
2745 pci_set_power_state(pdev
, 0); /* zeros conf space as a side effect */
2746 msleep(5); /* give card time to respond */
2747 pci_read_config_word(mgp
->pdev
, PCI_VENDOR_ID
, &vendor
);
2748 if (vendor
== 0xffff) {
2749 printk(KERN_ERR
"myri10ge: %s: device disappeared!\n",
2754 status
= pci_restore_state(pdev
);
2758 status
= pci_enable_device(pdev
);
2760 dev_err(&pdev
->dev
, "failed to enable device\n");
2764 pci_set_master(pdev
);
2766 myri10ge_reset(mgp
);
2767 myri10ge_dummy_rdma(mgp
, 1);
2769 /* Save configuration space to be restored if the
2770 * nic resets due to a parity error */
2771 pci_save_state(pdev
);
2773 if (netif_running(netdev
)) {
2775 status
= myri10ge_open(netdev
);
2778 goto abort_with_enabled
;
2781 netif_device_attach(netdev
);
2786 pci_disable_device(pdev
);
2791 #endif /* CONFIG_PM */
2793 static u32
myri10ge_read_reboot(struct myri10ge_priv
*mgp
)
2795 struct pci_dev
*pdev
= mgp
->pdev
;
2796 int vs
= mgp
->vendor_specific_offset
;
2799 /*enter read32 mode */
2800 pci_write_config_byte(pdev
, vs
+ 0x10, 0x3);
2802 /*read REBOOT_STATUS (0xfffffff0) */
2803 pci_write_config_dword(pdev
, vs
+ 0x18, 0xfffffff0);
2804 pci_read_config_dword(pdev
, vs
+ 0x14, &reboot
);
2809 * This watchdog is used to check whether the board has suffered
2810 * from a parity error and needs to be recovered.
2812 static void myri10ge_watchdog(struct work_struct
*work
)
2814 struct myri10ge_priv
*mgp
=
2815 container_of(work
, struct myri10ge_priv
, watchdog_work
);
2820 mgp
->watchdog_resets
++;
2821 pci_read_config_word(mgp
->pdev
, PCI_COMMAND
, &cmd
);
2822 if ((cmd
& PCI_COMMAND_MASTER
) == 0) {
2823 /* Bus master DMA disabled? Check to see
2824 * if the card rebooted due to a parity error
2825 * For now, just report it */
2826 reboot
= myri10ge_read_reboot(mgp
);
2828 "myri10ge: %s: NIC rebooted (0x%x),%s resetting\n",
2829 mgp
->dev
->name
, reboot
,
2830 myri10ge_reset_recover
? " " : " not");
2831 if (myri10ge_reset_recover
== 0)
2834 myri10ge_reset_recover
--;
2837 * A rebooted nic will come back with config space as
2838 * it was after power was applied to PCIe bus.
2839 * Attempt to restore config space which was saved
2840 * when the driver was loaded, or the last time the
2841 * nic was resumed from power saving mode.
2843 pci_restore_state(mgp
->pdev
);
2845 /* save state again for accounting reasons */
2846 pci_save_state(mgp
->pdev
);
2849 /* if we get back -1's from our slot, perhaps somebody
2850 * powered off our card. Don't try to reset it in
2852 if (cmd
== 0xffff) {
2853 pci_read_config_word(mgp
->pdev
, PCI_VENDOR_ID
, &vendor
);
2854 if (vendor
== 0xffff) {
2856 "myri10ge: %s: device disappeared!\n",
2861 /* Perhaps it is a software error. Try to reset */
2863 printk(KERN_ERR
"myri10ge: %s: device timeout, resetting\n",
2865 printk(KERN_INFO
"myri10ge: %s: %d %d %d %d %d\n",
2866 mgp
->dev
->name
, mgp
->tx
.req
, mgp
->tx
.done
,
2867 mgp
->tx
.pkt_start
, mgp
->tx
.pkt_done
,
2868 (int)ntohl(mgp
->fw_stats
->send_done_count
));
2870 printk(KERN_INFO
"myri10ge: %s: %d %d %d %d %d\n",
2871 mgp
->dev
->name
, mgp
->tx
.req
, mgp
->tx
.done
,
2872 mgp
->tx
.pkt_start
, mgp
->tx
.pkt_done
,
2873 (int)ntohl(mgp
->fw_stats
->send_done_count
));
2876 myri10ge_close(mgp
->dev
);
2877 status
= myri10ge_load_firmware(mgp
);
2879 printk(KERN_ERR
"myri10ge: %s: failed to load firmware\n",
2882 myri10ge_open(mgp
->dev
);
2887 * We use our own timer routine rather than relying upon
2888 * netdev->tx_timeout because we have a very large hardware transmit
2889 * queue. Due to the large queue, the netdev->tx_timeout function
2890 * cannot detect a NIC with a parity error in a timely fashion if the
2891 * NIC is lightly loaded.
2893 static void myri10ge_watchdog_timer(unsigned long arg
)
2895 struct myri10ge_priv
*mgp
;
2898 mgp
= (struct myri10ge_priv
*)arg
;
2900 if (mgp
->rx_small
.watchdog_needed
) {
2901 myri10ge_alloc_rx_pages(mgp
, &mgp
->rx_small
,
2902 mgp
->small_bytes
+ MXGEFW_PAD
, 1);
2903 if (mgp
->rx_small
.fill_cnt
- mgp
->rx_small
.cnt
>=
2904 myri10ge_fill_thresh
)
2905 mgp
->rx_small
.watchdog_needed
= 0;
2907 if (mgp
->rx_big
.watchdog_needed
) {
2908 myri10ge_alloc_rx_pages(mgp
, &mgp
->rx_big
, mgp
->big_bytes
, 1);
2909 if (mgp
->rx_big
.fill_cnt
- mgp
->rx_big
.cnt
>=
2910 myri10ge_fill_thresh
)
2911 mgp
->rx_big
.watchdog_needed
= 0;
2913 rx_pause_cnt
= ntohl(mgp
->fw_stats
->dropped_pause
);
2915 if (mgp
->tx
.req
!= mgp
->tx
.done
&&
2916 mgp
->tx
.done
== mgp
->watchdog_tx_done
&&
2917 mgp
->watchdog_tx_req
!= mgp
->watchdog_tx_done
) {
2918 /* nic seems like it might be stuck.. */
2919 if (rx_pause_cnt
!= mgp
->watchdog_pause
) {
2920 if (net_ratelimit())
2921 printk(KERN_WARNING
"myri10ge %s:"
2922 "TX paused, check link partner\n",
2925 schedule_work(&mgp
->watchdog_work
);
2930 mod_timer(&mgp
->watchdog_timer
,
2931 jiffies
+ myri10ge_watchdog_timeout
* HZ
);
2932 mgp
->watchdog_tx_done
= mgp
->tx
.done
;
2933 mgp
->watchdog_tx_req
= mgp
->tx
.req
;
2934 mgp
->watchdog_pause
= rx_pause_cnt
;
2937 static int myri10ge_probe(struct pci_dev
*pdev
, const struct pci_device_id
*ent
)
2939 struct net_device
*netdev
;
2940 struct myri10ge_priv
*mgp
;
2941 struct device
*dev
= &pdev
->dev
;
2944 int status
= -ENXIO
;
2947 netdev
= alloc_etherdev(sizeof(*mgp
));
2948 if (netdev
== NULL
) {
2949 dev_err(dev
, "Could not allocate ethernet device\n");
2953 SET_NETDEV_DEV(netdev
, &pdev
->dev
);
2955 mgp
= netdev_priv(netdev
);
2957 netif_napi_add(netdev
, &mgp
->napi
,
2958 myri10ge_poll
, myri10ge_napi_weight
);
2960 mgp
->csum_flag
= MXGEFW_FLAGS_CKSUM
;
2961 mgp
->pause
= myri10ge_flow_control
;
2962 mgp
->intr_coal_delay
= myri10ge_intr_coal_delay
;
2963 mgp
->msg_enable
= netif_msg_init(myri10ge_debug
, MYRI10GE_MSG_DEFAULT
);
2964 init_waitqueue_head(&mgp
->down_wq
);
2966 if (pci_enable_device(pdev
)) {
2967 dev_err(&pdev
->dev
, "pci_enable_device call failed\n");
2969 goto abort_with_netdev
;
2972 /* Find the vendor-specific cap so we can check
2973 * the reboot register later on */
2974 mgp
->vendor_specific_offset
2975 = pci_find_capability(pdev
, PCI_CAP_ID_VNDR
);
2977 /* Set our max read request to 4KB */
2978 status
= pcie_set_readrq(pdev
, 4096);
2980 dev_err(&pdev
->dev
, "Error %d writing PCI_EXP_DEVCTL\n",
2982 goto abort_with_netdev
;
2985 pci_set_master(pdev
);
2987 status
= pci_set_dma_mask(pdev
, DMA_64BIT_MASK
);
2991 "64-bit pci address mask was refused, trying 32-bit");
2992 status
= pci_set_dma_mask(pdev
, DMA_32BIT_MASK
);
2995 dev_err(&pdev
->dev
, "Error %d setting DMA mask\n", status
);
2996 goto abort_with_netdev
;
2998 mgp
->cmd
= dma_alloc_coherent(&pdev
->dev
, sizeof(*mgp
->cmd
),
2999 &mgp
->cmd_bus
, GFP_KERNEL
);
3000 if (mgp
->cmd
== NULL
)
3001 goto abort_with_netdev
;
3003 mgp
->fw_stats
= dma_alloc_coherent(&pdev
->dev
, sizeof(*mgp
->fw_stats
),
3004 &mgp
->fw_stats_bus
, GFP_KERNEL
);
3005 if (mgp
->fw_stats
== NULL
)
3006 goto abort_with_cmd
;
3008 mgp
->board_span
= pci_resource_len(pdev
, 0);
3009 mgp
->iomem_base
= pci_resource_start(pdev
, 0);
3011 mgp
->wc_enabled
= 0;
3013 mgp
->mtrr
= mtrr_add(mgp
->iomem_base
, mgp
->board_span
,
3014 MTRR_TYPE_WRCOMB
, 1);
3016 mgp
->wc_enabled
= 1;
3018 /* Hack. need to get rid of these magic numbers */
3020 2 * 1024 * 1024 - (2 * (48 * 1024) + (32 * 1024)) - 0x100;
3021 if (mgp
->sram_size
> mgp
->board_span
) {
3022 dev_err(&pdev
->dev
, "board span %ld bytes too small\n",
3026 mgp
->sram
= ioremap(mgp
->iomem_base
, mgp
->board_span
);
3027 if (mgp
->sram
== NULL
) {
3028 dev_err(&pdev
->dev
, "ioremap failed for %ld bytes at 0x%lx\n",
3029 mgp
->board_span
, mgp
->iomem_base
);
3033 memcpy_fromio(mgp
->eeprom_strings
,
3034 mgp
->sram
+ mgp
->sram_size
- MYRI10GE_EEPROM_STRINGS_SIZE
,
3035 MYRI10GE_EEPROM_STRINGS_SIZE
);
3036 memset(mgp
->eeprom_strings
+ MYRI10GE_EEPROM_STRINGS_SIZE
- 2, 0, 2);
3037 status
= myri10ge_read_mac_addr(mgp
);
3039 goto abort_with_ioremap
;
3041 for (i
= 0; i
< ETH_ALEN
; i
++)
3042 netdev
->dev_addr
[i
] = mgp
->mac_addr
[i
];
3044 /* allocate rx done ring */
3045 bytes
= myri10ge_max_intr_slots
* sizeof(*mgp
->rx_done
.entry
);
3046 mgp
->rx_done
.entry
= dma_alloc_coherent(&pdev
->dev
, bytes
,
3047 &mgp
->rx_done
.bus
, GFP_KERNEL
);
3048 if (mgp
->rx_done
.entry
== NULL
)
3049 goto abort_with_ioremap
;
3050 memset(mgp
->rx_done
.entry
, 0, bytes
);
3052 myri10ge_select_firmware(mgp
);
3054 status
= myri10ge_load_firmware(mgp
);
3056 dev_err(&pdev
->dev
, "failed to load firmware\n");
3057 goto abort_with_rx_done
;
3060 status
= myri10ge_reset(mgp
);
3062 dev_err(&pdev
->dev
, "failed reset\n");
3063 goto abort_with_firmware
;
3066 pci_set_drvdata(pdev
, mgp
);
3067 if ((myri10ge_initial_mtu
+ ETH_HLEN
) > MYRI10GE_MAX_ETHER_MTU
)
3068 myri10ge_initial_mtu
= MYRI10GE_MAX_ETHER_MTU
- ETH_HLEN
;
3069 if ((myri10ge_initial_mtu
+ ETH_HLEN
) < 68)
3070 myri10ge_initial_mtu
= 68;
3071 netdev
->mtu
= myri10ge_initial_mtu
;
3072 netdev
->open
= myri10ge_open
;
3073 netdev
->stop
= myri10ge_close
;
3074 netdev
->hard_start_xmit
= myri10ge_xmit
;
3075 netdev
->get_stats
= myri10ge_get_stats
;
3076 netdev
->base_addr
= mgp
->iomem_base
;
3077 netdev
->change_mtu
= myri10ge_change_mtu
;
3078 netdev
->set_multicast_list
= myri10ge_set_multicast_list
;
3079 netdev
->set_mac_address
= myri10ge_set_mac_address
;
3080 netdev
->features
= NETIF_F_SG
| NETIF_F_HW_CSUM
| NETIF_F_TSO
;
3082 netdev
->features
|= NETIF_F_HIGHDMA
;
3084 /* make sure we can get an irq, and that MSI can be
3085 * setup (if available). Also ensure netdev->irq
3086 * is set to correct value if MSI is enabled */
3087 status
= myri10ge_request_irq(mgp
);
3089 goto abort_with_firmware
;
3090 netdev
->irq
= pdev
->irq
;
3091 myri10ge_free_irq(mgp
);
3093 /* Save configuration space to be restored if the
3094 * nic resets due to a parity error */
3095 pci_save_state(pdev
);
3097 /* Setup the watchdog timer */
3098 setup_timer(&mgp
->watchdog_timer
, myri10ge_watchdog_timer
,
3099 (unsigned long)mgp
);
3101 SET_ETHTOOL_OPS(netdev
, &myri10ge_ethtool_ops
);
3102 INIT_WORK(&mgp
->watchdog_work
, myri10ge_watchdog
);
3103 status
= register_netdev(netdev
);
3105 dev_err(&pdev
->dev
, "register_netdev failed: %d\n", status
);
3106 goto abort_with_state
;
3108 dev_info(dev
, "%s IRQ %d, tx bndry %d, fw %s, WC %s\n",
3109 (mgp
->msi_enabled
? "MSI" : "xPIC"),
3110 netdev
->irq
, mgp
->tx
.boundary
, mgp
->fw_name
,
3111 (mgp
->wc_enabled
? "Enabled" : "Disabled"));
3116 pci_restore_state(pdev
);
3118 abort_with_firmware
:
3119 myri10ge_dummy_rdma(mgp
, 0);
3122 bytes
= myri10ge_max_intr_slots
* sizeof(*mgp
->rx_done
.entry
);
3123 dma_free_coherent(&pdev
->dev
, bytes
,
3124 mgp
->rx_done
.entry
, mgp
->rx_done
.bus
);
3132 mtrr_del(mgp
->mtrr
, mgp
->iomem_base
, mgp
->board_span
);
3134 dma_free_coherent(&pdev
->dev
, sizeof(*mgp
->fw_stats
),
3135 mgp
->fw_stats
, mgp
->fw_stats_bus
);
3138 dma_free_coherent(&pdev
->dev
, sizeof(*mgp
->cmd
),
3139 mgp
->cmd
, mgp
->cmd_bus
);
3143 free_netdev(netdev
);
3150 * Does what is necessary to shutdown one Myrinet device. Called
3151 * once for each Myrinet card by the kernel when a module is
3154 static void myri10ge_remove(struct pci_dev
*pdev
)
3156 struct myri10ge_priv
*mgp
;
3157 struct net_device
*netdev
;
3160 mgp
= pci_get_drvdata(pdev
);
3164 flush_scheduled_work();
3166 unregister_netdev(netdev
);
3168 myri10ge_dummy_rdma(mgp
, 0);
3170 /* avoid a memory leak */
3171 pci_restore_state(pdev
);
3173 bytes
= myri10ge_max_intr_slots
* sizeof(*mgp
->rx_done
.entry
);
3174 dma_free_coherent(&pdev
->dev
, bytes
,
3175 mgp
->rx_done
.entry
, mgp
->rx_done
.bus
);
3181 mtrr_del(mgp
->mtrr
, mgp
->iomem_base
, mgp
->board_span
);
3183 dma_free_coherent(&pdev
->dev
, sizeof(*mgp
->fw_stats
),
3184 mgp
->fw_stats
, mgp
->fw_stats_bus
);
3186 dma_free_coherent(&pdev
->dev
, sizeof(*mgp
->cmd
),
3187 mgp
->cmd
, mgp
->cmd_bus
);
3189 free_netdev(netdev
);
3190 pci_set_drvdata(pdev
, NULL
);
3193 #define PCI_DEVICE_ID_MYRICOM_MYRI10GE_Z8E 0x0008
3194 #define PCI_DEVICE_ID_MYRICOM_MYRI10GE_Z8E_9 0x0009
3196 static struct pci_device_id myri10ge_pci_tbl
[] = {
3197 {PCI_DEVICE(PCI_VENDOR_ID_MYRICOM
, PCI_DEVICE_ID_MYRICOM_MYRI10GE_Z8E
)},
3199 (PCI_VENDOR_ID_MYRICOM
, PCI_DEVICE_ID_MYRICOM_MYRI10GE_Z8E_9
)},
3203 static struct pci_driver myri10ge_driver
= {
3205 .probe
= myri10ge_probe
,
3206 .remove
= myri10ge_remove
,
3207 .id_table
= myri10ge_pci_tbl
,
3209 .suspend
= myri10ge_suspend
,
3210 .resume
= myri10ge_resume
,
3214 static __init
int myri10ge_init_module(void)
3216 printk(KERN_INFO
"%s: Version %s\n", myri10ge_driver
.name
,
3217 MYRI10GE_VERSION_STR
);
3218 return pci_register_driver(&myri10ge_driver
);
3221 module_init(myri10ge_init_module
);
3223 static __exit
void myri10ge_cleanup_module(void)
3225 pci_unregister_driver(&myri10ge_driver
);
3228 module_exit(myri10ge_cleanup_module
);