Lines Matching +full:xfp +full:- +full:mac

2  * myri10ge.c: Myricom Myri-10G Ethernet driver.
4 * Copyright (C) 2005 - 2011 Myricom, Inc.
34 * http://www.myri.com/scs/download-Myri10GE.html
49 #include <linux/dma-mapping.h>
78 #define MYRI10GE_VERSION_STR "1.5.3-1.534"
135 int mask; /* number of rx slots -1 */
146 int mask; /* number of transmit slots -1 */
243 u8 mac_addr[ETH_ALEN]; /* eeprom mac address */
274 {[0 ... (MYRI10GE_MAX_BOARDS - 1)] = NULL };
281 MODULE_PARM_DESC(myri10ge_ecrc_enable, "Enable Extended CRC on PCI-E");
283 static int myri10ge_small_bytes = -1; /* -1 == auto */
309 static int myri10ge_initial_mtu = MYRI10GE_MAX_ETHER_MTU - ETH_HLEN;
328 static int myri10ge_debug = -1; /* defaults above */
371 if (mgp->fw_name_allocated) in set_fw_name()
372 kfree(mgp->fw_name); in set_fw_name()
373 mgp->fw_name = name; in set_fw_name()
374 mgp->fw_name_allocated = allocated; in set_fw_name()
383 struct mcp_cmd_response *response = mgp->cmd; in myri10ge_send_cmd()
384 char __iomem *cmd_addr = mgp->sram + MXGEFW_ETH_CMD; in myri10ge_send_cmd()
391 buf->data0 = htonl(data->data0); in myri10ge_send_cmd()
392 buf->data1 = htonl(data->data1); in myri10ge_send_cmd()
393 buf->data2 = htonl(data->data2); in myri10ge_send_cmd()
394 buf->cmd = htonl(cmd); in myri10ge_send_cmd()
395 dma_low = MYRI10GE_LOWPART_TO_U32(mgp->cmd_bus); in myri10ge_send_cmd()
396 dma_high = MYRI10GE_HIGHPART_TO_U32(mgp->cmd_bus); in myri10ge_send_cmd()
398 buf->response_addr.low = htonl(dma_low); in myri10ge_send_cmd()
399 buf->response_addr.high = htonl(dma_high); in myri10ge_send_cmd()
400 response->result = htonl(MYRI10GE_NO_RESPONSE_RESULT); in myri10ge_send_cmd()
415 response->result == htonl(MYRI10GE_NO_RESPONSE_RESULT); in myri10ge_send_cmd()
424 response->result == htonl(MYRI10GE_NO_RESPONSE_RESULT); in myri10ge_send_cmd()
429 result = ntohl(response->result); in myri10ge_send_cmd()
430 value = ntohl(response->data); in myri10ge_send_cmd()
433 data->data0 = value; in myri10ge_send_cmd()
436 return -ENOSYS; in myri10ge_send_cmd()
438 return -E2BIG; in myri10ge_send_cmd()
441 (data-> in myri10ge_send_cmd()
444 return -ERANGE; in myri10ge_send_cmd()
446 dev_err(&mgp->pdev->dev, in myri10ge_send_cmd()
449 return -ENXIO; in myri10ge_send_cmd()
453 dev_err(&mgp->pdev->dev, "command %d timed out, result = %d\n", in myri10ge_send_cmd()
455 return -EAGAIN; in myri10ge_send_cmd()
461 * MAC=x:x:x:x:x:x\0
470 ptr = mgp->eeprom_strings; in myri10ge_read_mac_addr()
471 limit = mgp->eeprom_strings + MYRI10GE_EEPROM_STRINGS_SIZE; in myri10ge_read_mac_addr()
474 if (memcmp(ptr, "MAC=", 4) == 0) { in myri10ge_read_mac_addr()
476 mgp->mac_addr_string = ptr; in myri10ge_read_mac_addr()
480 mgp->mac_addr[i] = in myri10ge_read_mac_addr()
487 mgp->product_code_string = ptr; in myri10ge_read_mac_addr()
491 mgp->serial_number = simple_strtoul(ptr, &ptr, 10); in myri10ge_read_mac_addr()
499 dev_err(&mgp->pdev->dev, "failed to parse eeprom_strings\n"); in myri10ge_read_mac_addr()
500 return -ENXIO; in myri10ge_read_mac_addr()
516 mgp->cmd->data = 0; in myri10ge_dummy_rdma()
521 * write a -1 there to indicate it is alive and well in myri10ge_dummy_rdma()
523 dma_low = MYRI10GE_LOWPART_TO_U32(mgp->cmd_bus); in myri10ge_dummy_rdma()
524 dma_high = MYRI10GE_HIGHPART_TO_U32(mgp->cmd_bus); in myri10ge_dummy_rdma()
533 submit = mgp->sram + MXGEFW_BOOT_DUMMY_RDMA; in myri10ge_dummy_rdma()
536 for (i = 0; mgp->cmd->data != MYRI10GE_NO_CONFIRM_DATA && i < 20; i++) in myri10ge_dummy_rdma()
538 if (mgp->cmd->data != MYRI10GE_NO_CONFIRM_DATA) in myri10ge_dummy_rdma()
539 dev_err(&mgp->pdev->dev, "dummy rdma %s failed\n", in myri10ge_dummy_rdma()
547 struct device *dev = &mgp->pdev->dev; in myri10ge_validate_firmware()
550 if (ntohl(hdr->mcp_type) != MCP_TYPE_ETH) { in myri10ge_validate_firmware()
551 dev_err(dev, "Bad firmware type: 0x%x\n", ntohl(hdr->mcp_type)); in myri10ge_validate_firmware()
552 return -EINVAL; in myri10ge_validate_firmware()
556 strscpy(mgp->fw_version, hdr->version, sizeof(mgp->fw_version)); in myri10ge_validate_firmware()
558 sscanf(mgp->fw_version, "%d.%d.%d", &mgp->fw_ver_major, in myri10ge_validate_firmware()
559 &mgp->fw_ver_minor, &mgp->fw_ver_tiny); in myri10ge_validate_firmware()
561 if (!(mgp->fw_ver_major == MXGEFW_VERSION_MAJOR && in myri10ge_validate_firmware()
562 mgp->fw_ver_minor == MXGEFW_VERSION_MINOR)) { in myri10ge_validate_firmware()
563 dev_err(dev, "Found firmware version %s\n", mgp->fw_version); in myri10ge_validate_firmware()
566 return -EINVAL; in myri10ge_validate_firmware()
575 struct device *dev = &mgp->pdev->dev; in myri10ge_load_hotplug_firmware()
582 if (request_firmware(&fw, mgp->fw_name, dev) < 0) { in myri10ge_load_hotplug_firmware()
584 mgp->fw_name); in myri10ge_load_hotplug_firmware()
585 status = -EINVAL; in myri10ge_load_hotplug_firmware()
591 if (fw->size >= mgp->sram_size - MYRI10GE_FW_OFFSET || in myri10ge_load_hotplug_firmware()
592 fw->size < MCP_HEADER_PTR_OFFSET + 4) { in myri10ge_load_hotplug_firmware()
593 dev_err(dev, "Firmware size invalid:%d\n", (int)fw->size); in myri10ge_load_hotplug_firmware()
594 status = -EINVAL; in myri10ge_load_hotplug_firmware()
599 hdr_offset = ntohl(*(__be32 *) (fw->data + MCP_HEADER_PTR_OFFSET)); in myri10ge_load_hotplug_firmware()
600 if ((hdr_offset & 3) || hdr_offset + sizeof(*hdr) > fw->size) { in myri10ge_load_hotplug_firmware()
602 status = -EINVAL; in myri10ge_load_hotplug_firmware()
605 hdr = (void *)(fw->data + hdr_offset); in myri10ge_load_hotplug_firmware()
611 crc = crc32(~0, fw->data, fw->size); in myri10ge_load_hotplug_firmware()
612 for (i = 0; i < fw->size; i += 256) { in myri10ge_load_hotplug_firmware()
613 myri10ge_pio_copy(mgp->sram + MYRI10GE_FW_OFFSET + i, in myri10ge_load_hotplug_firmware()
614 fw->data + i, in myri10ge_load_hotplug_firmware()
615 min(256U, (unsigned)(fw->size - i))); in myri10ge_load_hotplug_firmware()
617 readb(mgp->sram); in myri10ge_load_hotplug_firmware()
619 fw_readback = vmalloc(fw->size); in myri10ge_load_hotplug_firmware()
621 status = -ENOMEM; in myri10ge_load_hotplug_firmware()
625 memcpy_fromio(fw_readback, mgp->sram + MYRI10GE_FW_OFFSET, fw->size); in myri10ge_load_hotplug_firmware()
626 reread_crc = crc32(~0, fw_readback, fw->size); in myri10ge_load_hotplug_firmware()
629 dev_err(dev, "CRC failed(fw-len=%u), got 0x%x (expect 0x%x)\n", in myri10ge_load_hotplug_firmware()
630 (unsigned)fw->size, reread_crc, crc); in myri10ge_load_hotplug_firmware()
631 status = -EIO; in myri10ge_load_hotplug_firmware()
634 *size = (u32) fw->size; in myri10ge_load_hotplug_firmware()
646 struct device *dev = &mgp->pdev->dev; in myri10ge_adopt_running_firmware()
652 hdr_offset = swab32(readl(mgp->sram + MCP_HEADER_PTR_OFFSET)); in myri10ge_adopt_running_firmware()
654 if ((hdr_offset & 3) || hdr_offset + sizeof(*hdr) > mgp->sram_size) { in myri10ge_adopt_running_firmware()
657 return -EIO; in myri10ge_adopt_running_firmware()
664 return -ENOMEM; in myri10ge_adopt_running_firmware()
666 memcpy_fromio(hdr, mgp->sram + hdr_offset, bytes); in myri10ge_adopt_running_firmware()
673 if (mgp->fw_ver_major == 1 && mgp->fw_ver_minor == 4 && in myri10ge_adopt_running_firmware()
674 mgp->fw_ver_tiny >= 4 && mgp->fw_ver_tiny <= 11) { in myri10ge_adopt_running_firmware()
675 mgp->adopted_rx_filter_bug = 1; in myri10ge_adopt_running_firmware()
678 mgp->fw_ver_major, mgp->fw_ver_minor, in myri10ge_adopt_running_firmware()
679 mgp->fw_ver_tiny); in myri10ge_adopt_running_firmware()
690 mgp->features = NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_TSO; in myri10ge_get_firmware_capabilities()
694 mgp->max_tso6 = cmd.data0; in myri10ge_get_firmware_capabilities()
695 mgp->features |= NETIF_F_TSO6; in myri10ge_get_firmware_capabilities()
700 dev_err(&mgp->pdev->dev, in myri10ge_get_firmware_capabilities()
702 return -ENXIO; in myri10ge_get_firmware_capabilities()
705 mgp->max_intr_slots = 2 * (cmd.data0 / sizeof(struct mcp_dma_addr)); in myri10ge_get_firmware_capabilities()
722 dev_warn(&mgp->pdev->dev, "hotplug firmware loading failed\n"); in myri10ge_load_firmware()
726 if (status == -EIO) in myri10ge_load_firmware()
731 dev_err(&mgp->pdev->dev, in myri10ge_load_firmware()
735 dev_info(&mgp->pdev->dev, in myri10ge_load_firmware()
737 if (mgp->tx_boundary == 4096) { in myri10ge_load_firmware()
738 dev_warn(&mgp->pdev->dev, in myri10ge_load_firmware()
741 dev_warn(&mgp->pdev->dev, in myri10ge_load_firmware()
744 dev_warn(&mgp->pdev->dev, "via hotplug\n"); in myri10ge_load_firmware()
748 mgp->tx_boundary = 2048; in myri10ge_load_firmware()
755 mgp->cmd->data = 0; in myri10ge_load_firmware()
760 * write a -1 there to indicate it is alive and well in myri10ge_load_firmware()
762 dma_low = MYRI10GE_LOWPART_TO_U32(mgp->cmd_bus); in myri10ge_load_firmware()
763 dma_high = MYRI10GE_HIGHPART_TO_U32(mgp->cmd_bus); in myri10ge_load_firmware()
769 /* FIX: All newest firmware should un-protect the bottom of in myri10ge_load_firmware()
774 buf[4] = htonl(size - 8); /* length of code */ in myri10ge_load_firmware()
778 submit = mgp->sram + MXGEFW_BOOT_HANDOFF; in myri10ge_load_firmware()
785 while (mgp->cmd->data != MYRI10GE_NO_CONFIRM_DATA && i < 9) { in myri10ge_load_firmware()
789 if (mgp->cmd->data != MYRI10GE_NO_CONFIRM_DATA) { in myri10ge_load_firmware()
790 dev_err(&mgp->pdev->dev, "handoff failed\n"); in myri10ge_load_firmware()
791 return -ENXIO; in myri10ge_load_firmware()
823 netdev_err(mgp->dev, "Failed to set flow control mode\n"); in myri10ge_change_pause()
826 mgp->pause = pause; in myri10ge_change_pause()
839 netdev_err(mgp->dev, "Failed to set promisc mode\n"); in myri10ge_change_promisc()
853 return -ENOMEM; in myri10ge_dma_test()
854 dmatest_bus = dma_map_page(&mgp->pdev->dev, dmatest_page, 0, in myri10ge_dma_test()
856 if (unlikely(dma_mapping_error(&mgp->pdev->dev, dmatest_bus))) { in myri10ge_dma_test()
858 return -ENOMEM; in myri10ge_dma_test()
870 len = mgp->tx_boundary; in myri10ge_dma_test()
880 mgp->read_dma = ((cmd.data0 >> 16) * len * 2) / (cmd.data0 & 0xffff); in myri10ge_dma_test()
889 mgp->write_dma = ((cmd.data0 >> 16) * len * 2) / (cmd.data0 & 0xffff); in myri10ge_dma_test()
899 mgp->read_write_dma = ((cmd.data0 >> 16) * len * 2 * 2) / in myri10ge_dma_test()
903 dma_unmap_page(&mgp->pdev->dev, dmatest_bus, PAGE_SIZE, in myri10ge_dma_test()
908 dev_warn(&mgp->pdev->dev, "DMA %s benchmark failed: %d\n", in myri10ge_dma_test()
929 dev_err(&mgp->pdev->dev, "failed reset\n"); in myri10ge_reset()
930 return -ENXIO; in myri10ge_reset()
935 * Use non-ndis mcp_slot (eg, 4 bytes total, in myri10ge_reset()
945 bytes = mgp->max_intr_slots * sizeof(*mgp->ss[0].rx_done.entry); in myri10ge_reset()
960 if (mgp->num_slices > 1) { in myri10ge_reset()
966 dev_err(&mgp->pdev->dev, in myri10ge_reset()
975 cmd.data0 = mgp->num_slices; in myri10ge_reset()
977 if (mgp->dev->real_num_tx_queues > 1) in myri10ge_reset()
985 if (status != 0 && mgp->dev->real_num_tx_queues > 1) { in myri10ge_reset()
986 netif_set_real_num_tx_queues(mgp->dev, 1); in myri10ge_reset()
987 cmd.data0 = mgp->num_slices; in myri10ge_reset()
995 dev_err(&mgp->pdev->dev, in myri10ge_reset()
1001 for (i = 0; i < mgp->num_slices; i++) { in myri10ge_reset()
1002 ss = &mgp->ss[i]; in myri10ge_reset()
1003 cmd.data0 = MYRI10GE_LOWPART_TO_U32(ss->rx_done.bus); in myri10ge_reset()
1004 cmd.data1 = MYRI10GE_HIGHPART_TO_U32(ss->rx_done.bus); in myri10ge_reset()
1012 for (i = 0; i < mgp->num_slices; i++) { in myri10ge_reset()
1013 ss = &mgp->ss[i]; in myri10ge_reset()
1014 ss->irq_claim = in myri10ge_reset()
1015 (__iomem __be32 *) (mgp->sram + cmd.data0 + 8 * i); in myri10ge_reset()
1019 mgp->irq_deassert = (__iomem __be32 *) (mgp->sram + cmd.data0); in myri10ge_reset()
1023 mgp->intr_coal_delay_ptr = (__iomem __be32 *) (mgp->sram + cmd.data0); in myri10ge_reset()
1025 dev_err(&mgp->pdev->dev, "failed set interrupt parameters\n"); in myri10ge_reset()
1028 put_be32(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr); in myri10ge_reset()
1033 for (i = 0; i < mgp->num_slices; i++) { in myri10ge_reset()
1034 ss = &mgp->ss[i]; in myri10ge_reset()
1036 ss->dca_tag = (__iomem __be32 *) in myri10ge_reset()
1037 (mgp->sram + dca_tag_off + 4 * i); in myri10ge_reset()
1039 ss->dca_tag = NULL; in myri10ge_reset()
1046 mgp->link_changes = 0; in myri10ge_reset()
1047 for (i = 0; i < mgp->num_slices; i++) { in myri10ge_reset()
1048 ss = &mgp->ss[i]; in myri10ge_reset()
1050 memset(ss->rx_done.entry, 0, bytes); in myri10ge_reset()
1051 ss->tx.req = 0; in myri10ge_reset()
1052 ss->tx.done = 0; in myri10ge_reset()
1053 ss->tx.pkt_start = 0; in myri10ge_reset()
1054 ss->tx.pkt_done = 0; in myri10ge_reset()
1055 ss->rx_big.cnt = 0; in myri10ge_reset()
1056 ss->rx_small.cnt = 0; in myri10ge_reset()
1057 ss->rx_done.idx = 0; in myri10ge_reset()
1058 ss->rx_done.cnt = 0; in myri10ge_reset()
1059 ss->tx.wake_queue = 0; in myri10ge_reset()
1060 ss->tx.stop_queue = 0; in myri10ge_reset()
1063 status = myri10ge_update_mac_address(mgp, mgp->dev->dev_addr); in myri10ge_reset()
1064 myri10ge_change_pause(mgp, mgp->pause); in myri10ge_reset()
1065 myri10ge_set_multicast_list(mgp->dev); in myri10ge_reset()
1089 ss->cached_dca_tag = tag; in myri10ge_write_dca()
1090 put_be32(htonl(tag), ss->dca_tag); in myri10ge_write_dca()
1098 if (cpu != ss->cpu) { in myri10ge_update_dca()
1099 tag = dca3_get_tag(&ss->mgp->pdev->dev, cpu); in myri10ge_update_dca()
1100 if (ss->cached_dca_tag != tag) in myri10ge_update_dca()
1102 ss->cpu = cpu; in myri10ge_update_dca()
1110 struct pci_dev *pdev = mgp->pdev; in myri10ge_setup_dca()
1112 if (mgp->ss[0].dca_tag == NULL || mgp->dca_enabled) in myri10ge_setup_dca()
1115 dev_err(&pdev->dev, "dca disabled by administrator\n"); in myri10ge_setup_dca()
1118 err = dca_add_requester(&pdev->dev); in myri10ge_setup_dca()
1120 if (err != -ENODEV) in myri10ge_setup_dca()
1121 dev_err(&pdev->dev, in myri10ge_setup_dca()
1125 mgp->relaxed_order = myri10ge_toggle_relaxed(pdev, 0); in myri10ge_setup_dca()
1126 mgp->dca_enabled = 1; in myri10ge_setup_dca()
1127 for (i = 0; i < mgp->num_slices; i++) { in myri10ge_setup_dca()
1128 mgp->ss[i].cpu = -1; in myri10ge_setup_dca()
1129 mgp->ss[i].cached_dca_tag = -1; in myri10ge_setup_dca()
1130 myri10ge_update_dca(&mgp->ss[i]); in myri10ge_setup_dca()
1136 struct pci_dev *pdev = mgp->pdev; in myri10ge_teardown_dca()
1138 if (!mgp->dca_enabled) in myri10ge_teardown_dca()
1140 mgp->dca_enabled = 0; in myri10ge_teardown_dca()
1141 if (mgp->relaxed_order) in myri10ge_teardown_dca()
1143 dca_remove_requester(&pdev->dev); in myri10ge_teardown_dca()
1168 low = src->addr_low; in myri10ge_submit_8rx()
1169 src->addr_low = htonl(DMA_BIT_MASK(32)); in myri10ge_submit_8rx()
1174 src->addr_low = low; in myri10ge_submit_8rx()
1175 put_be32(low, &dst->addr_low); in myri10ge_submit_8rx()
1190 if (unlikely(rx->watchdog_needed && !watchdog)) in myri10ge_alloc_rx_pages()
1194 while (rx->fill_cnt != (rx->cnt + rx->mask + 1)) { in myri10ge_alloc_rx_pages()
1195 idx = rx->fill_cnt & rx->mask; in myri10ge_alloc_rx_pages()
1196 if (rx->page_offset + bytes <= MYRI10GE_ALLOC_SIZE) { in myri10ge_alloc_rx_pages()
1198 get_page(rx->page); in myri10ge_alloc_rx_pages()
1205 if (rx->fill_cnt - rx->cnt < 16) in myri10ge_alloc_rx_pages()
1206 rx->watchdog_needed = 1; in myri10ge_alloc_rx_pages()
1210 bus = dma_map_page(&mgp->pdev->dev, page, 0, in myri10ge_alloc_rx_pages()
1213 if (unlikely(dma_mapping_error(&mgp->pdev->dev, bus))) { in myri10ge_alloc_rx_pages()
1215 if (rx->fill_cnt - rx->cnt < 16) in myri10ge_alloc_rx_pages()
1216 rx->watchdog_needed = 1; in myri10ge_alloc_rx_pages()
1220 rx->page = page; in myri10ge_alloc_rx_pages()
1221 rx->page_offset = 0; in myri10ge_alloc_rx_pages()
1222 rx->bus = bus; in myri10ge_alloc_rx_pages()
1225 rx->info[idx].page = rx->page; in myri10ge_alloc_rx_pages()
1226 rx->info[idx].page_offset = rx->page_offset; in myri10ge_alloc_rx_pages()
1229 dma_unmap_addr_set(&rx->info[idx], bus, rx->bus); in myri10ge_alloc_rx_pages()
1230 rx->shadow[idx].addr_low = in myri10ge_alloc_rx_pages()
1231 htonl(MYRI10GE_LOWPART_TO_U32(rx->bus) + rx->page_offset); in myri10ge_alloc_rx_pages()
1232 rx->shadow[idx].addr_high = in myri10ge_alloc_rx_pages()
1233 htonl(MYRI10GE_HIGHPART_TO_U32(rx->bus)); in myri10ge_alloc_rx_pages()
1236 rx->page_offset += SKB_DATA_ALIGN(bytes); in myri10ge_alloc_rx_pages()
1240 end_offset = rx->page_offset + bytes - 1; in myri10ge_alloc_rx_pages()
1241 if ((unsigned)(rx->page_offset ^ end_offset) > 4095) in myri10ge_alloc_rx_pages()
1242 rx->page_offset = end_offset & ~4095; in myri10ge_alloc_rx_pages()
1244 rx->fill_cnt++; in myri10ge_alloc_rx_pages()
1248 myri10ge_submit_8rx(&rx->lanai[idx - 7], in myri10ge_alloc_rx_pages()
1249 &rx->shadow[idx - 7]); in myri10ge_alloc_rx_pages()
1260 (info->page_offset + 2 * bytes) > MYRI10GE_ALLOC_SIZE) { in myri10ge_unmap_rx_page()
1261 dma_unmap_page(&pdev->dev, (dma_unmap_addr(info, bus) in myri10ge_unmap_rx_page()
1262 & ~(MYRI10GE_ALLOC_SIZE - 1)), in myri10ge_unmap_rx_page()
1285 if ((dev->features & NETIF_F_HW_VLAN_CTAG_RX) == in myri10ge_vlan_rx()
1287 veh->h_vlan_proto == htons(ETH_P_8021Q)) { in myri10ge_vlan_rx()
1289 if (skb->ip_summed == CHECKSUM_COMPLETE) { in myri10ge_vlan_rx()
1291 skb->csum = csum_sub(skb->csum, vsum); in myri10ge_vlan_rx()
1294 __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), ntohs(veh->h_vlan_TCI)); in myri10ge_vlan_rx()
1296 skb->len -= VLAN_HLEN; in myri10ge_vlan_rx()
1297 skb->data_len -= VLAN_HLEN; in myri10ge_vlan_rx()
1298 frag = skb_shinfo(skb)->frags; in myri10ge_vlan_rx()
1309 struct myri10ge_priv *mgp = ss->mgp; in myri10ge_rx_done()
1314 struct pci_dev *pdev = mgp->pdev; in myri10ge_rx_done()
1315 struct net_device *dev = mgp->dev; in myri10ge_rx_done()
1318 if (len <= mgp->small_bytes) { in myri10ge_rx_done()
1319 rx = &ss->rx_small; in myri10ge_rx_done()
1320 bytes = mgp->small_bytes; in myri10ge_rx_done()
1322 rx = &ss->rx_big; in myri10ge_rx_done()
1323 bytes = mgp->big_bytes; in myri10ge_rx_done()
1327 idx = rx->cnt & rx->mask; in myri10ge_rx_done()
1328 va = page_address(rx->info[idx].page) + rx->info[idx].page_offset; in myri10ge_rx_done()
1331 skb = napi_get_frags(&ss->napi); in myri10ge_rx_done()
1333 ss->stats.rx_dropped++; in myri10ge_rx_done()
1335 myri10ge_unmap_rx_page(pdev, &rx->info[idx], bytes); in myri10ge_rx_done()
1336 put_page(rx->info[idx].page); in myri10ge_rx_done()
1337 rx->cnt++; in myri10ge_rx_done()
1338 idx = rx->cnt & rx->mask; in myri10ge_rx_done()
1339 remainder -= MYRI10GE_ALLOC_SIZE; in myri10ge_rx_done()
1343 rx_frags = skb_shinfo(skb)->frags; in myri10ge_rx_done()
1346 myri10ge_unmap_rx_page(pdev, &rx->info[idx], bytes); in myri10ge_rx_done()
1347 skb_fill_page_desc(skb, i, rx->info[idx].page, in myri10ge_rx_done()
1348 rx->info[idx].page_offset, in myri10ge_rx_done()
1351 rx->cnt++; in myri10ge_rx_done()
1352 idx = rx->cnt & rx->mask; in myri10ge_rx_done()
1353 remainder -= MYRI10GE_ALLOC_SIZE; in myri10ge_rx_done()
1359 len -= MXGEFW_PAD; in myri10ge_rx_done()
1361 skb->len = len; in myri10ge_rx_done()
1362 skb->data_len = len; in myri10ge_rx_done()
1363 skb->truesize += len; in myri10ge_rx_done()
1364 if (dev->features & NETIF_F_RXCSUM) { in myri10ge_rx_done()
1365 skb->ip_summed = CHECKSUM_COMPLETE; in myri10ge_rx_done()
1366 skb->csum = csum; in myri10ge_rx_done()
1368 myri10ge_vlan_rx(mgp->dev, va, skb); in myri10ge_rx_done()
1369 skb_record_rx_queue(skb, ss - &mgp->ss[0]); in myri10ge_rx_done()
1371 napi_gro_frags(&ss->napi); in myri10ge_rx_done()
1379 struct pci_dev *pdev = ss->mgp->pdev; in myri10ge_tx_done()
1380 struct myri10ge_tx_buf *tx = &ss->tx; in myri10ge_tx_done()
1385 while (tx->pkt_done != mcp_index) { in myri10ge_tx_done()
1386 idx = tx->done & tx->mask; in myri10ge_tx_done()
1387 skb = tx->info[idx].skb; in myri10ge_tx_done()
1390 tx->info[idx].skb = NULL; in myri10ge_tx_done()
1391 if (tx->info[idx].last) { in myri10ge_tx_done()
1392 tx->pkt_done++; in myri10ge_tx_done()
1393 tx->info[idx].last = 0; in myri10ge_tx_done()
1395 tx->done++; in myri10ge_tx_done()
1396 len = dma_unmap_len(&tx->info[idx], len); in myri10ge_tx_done()
1397 dma_unmap_len_set(&tx->info[idx], len, 0); in myri10ge_tx_done()
1399 ss->stats.tx_bytes += skb->len; in myri10ge_tx_done()
1400 ss->stats.tx_packets++; in myri10ge_tx_done()
1403 dma_unmap_single(&pdev->dev, in myri10ge_tx_done()
1404 dma_unmap_addr(&tx->info[idx], in myri10ge_tx_done()
1409 dma_unmap_page(&pdev->dev, in myri10ge_tx_done()
1410 dma_unmap_addr(&tx->info[idx], in myri10ge_tx_done()
1416 dev_queue = netdev_get_tx_queue(ss->dev, ss - ss->mgp->ss); in myri10ge_tx_done()
1426 if ((ss->mgp->dev->real_num_tx_queues > 1) && in myri10ge_tx_done()
1428 if (tx->req == tx->done) { in myri10ge_tx_done()
1429 tx->queue_active = 0; in myri10ge_tx_done()
1430 put_be32(htonl(1), tx->send_stop); in myri10ge_tx_done()
1438 tx->req - tx->done < (tx->mask >> 1) && in myri10ge_tx_done()
1439 ss->mgp->running == MYRI10GE_ETH_RUNNING) { in myri10ge_tx_done()
1440 tx->wake_queue++; in myri10ge_tx_done()
1448 struct myri10ge_rx_done *rx_done = &ss->rx_done; in myri10ge_clean_rx_done()
1449 struct myri10ge_priv *mgp = ss->mgp; in myri10ge_clean_rx_done()
1453 int idx = rx_done->idx; in myri10ge_clean_rx_done()
1454 int cnt = rx_done->cnt; in myri10ge_clean_rx_done()
1459 while (rx_done->entry[idx].length != 0 && work_done < budget) { in myri10ge_clean_rx_done()
1460 length = ntohs(rx_done->entry[idx].length); in myri10ge_clean_rx_done()
1461 rx_done->entry[idx].length = 0; in myri10ge_clean_rx_done()
1462 checksum = csum_unfold(rx_done->entry[idx].checksum); in myri10ge_clean_rx_done()
1467 idx = cnt & (mgp->max_intr_slots - 1); in myri10ge_clean_rx_done()
1470 rx_done->idx = idx; in myri10ge_clean_rx_done()
1471 rx_done->cnt = cnt; in myri10ge_clean_rx_done()
1472 ss->stats.rx_packets += rx_packets; in myri10ge_clean_rx_done()
1473 ss->stats.rx_bytes += rx_bytes; in myri10ge_clean_rx_done()
1476 if (ss->rx_small.fill_cnt - ss->rx_small.cnt < myri10ge_fill_thresh) in myri10ge_clean_rx_done()
1477 myri10ge_alloc_rx_pages(mgp, &ss->rx_small, in myri10ge_clean_rx_done()
1478 mgp->small_bytes + MXGEFW_PAD, 0); in myri10ge_clean_rx_done()
1479 if (ss->rx_big.fill_cnt - ss->rx_big.cnt < myri10ge_fill_thresh) in myri10ge_clean_rx_done()
1480 myri10ge_alloc_rx_pages(mgp, &ss->rx_big, mgp->big_bytes, 0); in myri10ge_clean_rx_done()
1487 struct mcp_irq_data *stats = mgp->ss[0].fw_stats; in myri10ge_check_statblock()
1489 if (unlikely(stats->stats_updated)) { in myri10ge_check_statblock()
1490 unsigned link_up = ntohl(stats->link_up); in myri10ge_check_statblock()
1491 if (mgp->link_state != link_up) { in myri10ge_check_statblock()
1492 mgp->link_state = link_up; in myri10ge_check_statblock()
1494 if (mgp->link_state == MXGEFW_LINK_UP) { in myri10ge_check_statblock()
1495 netif_info(mgp, link, mgp->dev, "link up\n"); in myri10ge_check_statblock()
1496 netif_carrier_on(mgp->dev); in myri10ge_check_statblock()
1497 mgp->link_changes++; in myri10ge_check_statblock()
1499 netif_info(mgp, link, mgp->dev, "link %s\n", in myri10ge_check_statblock()
1503 netif_carrier_off(mgp->dev); in myri10ge_check_statblock()
1504 mgp->link_changes++; in myri10ge_check_statblock()
1507 if (mgp->rdma_tags_available != in myri10ge_check_statblock()
1508 ntohl(stats->rdma_tags_available)) { in myri10ge_check_statblock()
1509 mgp->rdma_tags_available = in myri10ge_check_statblock()
1510 ntohl(stats->rdma_tags_available); in myri10ge_check_statblock()
1511 netdev_warn(mgp->dev, "RDMA timed out! %d tags left\n", in myri10ge_check_statblock()
1512 mgp->rdma_tags_available); in myri10ge_check_statblock()
1514 mgp->down_cnt += stats->link_down; in myri10ge_check_statblock()
1515 if (stats->link_down) in myri10ge_check_statblock()
1516 wake_up(&mgp->down_wq); in myri10ge_check_statblock()
1527 if (ss->mgp->dca_enabled) in myri10ge_poll()
1535 put_be32(htonl(3), ss->irq_claim); in myri10ge_poll()
1543 struct myri10ge_priv *mgp = ss->mgp; in myri10ge_intr()
1544 struct mcp_irq_data *stats = ss->fw_stats; in myri10ge_intr()
1545 struct myri10ge_tx_buf *tx = &ss->tx; in myri10ge_intr()
1549 /* an interrupt on a non-zero receive-only slice is implicitly in myri10ge_intr()
1550 * valid since MSI-X irqs are not shared */ in myri10ge_intr()
1551 if ((mgp->dev->real_num_tx_queues == 1) && (ss != mgp->ss)) { in myri10ge_intr()
1552 napi_schedule(&ss->napi); in myri10ge_intr()
1557 if (unlikely(!stats->valid)) in myri10ge_intr()
1562 if (stats->valid & 1) in myri10ge_intr()
1563 napi_schedule(&ss->napi); in myri10ge_intr()
1565 if (!mgp->msi_enabled && !mgp->msix_enabled) { in myri10ge_intr()
1566 put_be32(0, mgp->irq_deassert); in myri10ge_intr()
1568 stats->valid = 0; in myri10ge_intr()
1571 stats->valid = 0; in myri10ge_intr()
1578 send_done_count = ntohl(stats->send_done_count); in myri10ge_intr()
1579 if (send_done_count != tx->pkt_done) in myri10ge_intr()
1582 netdev_warn(mgp->dev, "irq stuck?\n"); in myri10ge_intr()
1583 stats->valid = 0; in myri10ge_intr()
1584 schedule_work(&mgp->watchdog_work); in myri10ge_intr()
1586 if (likely(stats->valid == 0)) in myri10ge_intr()
1593 if (ss == mgp->ss) in myri10ge_intr()
1596 put_be32(htonl(3), ss->irq_claim + 1); in myri10ge_intr()
1608 cmd->base.autoneg = AUTONEG_DISABLE; in myri10ge_get_link_ksettings()
1609 cmd->base.speed = SPEED_10000; in myri10ge_get_link_ksettings()
1610 cmd->base.duplex = DUPLEX_FULL; in myri10ge_get_link_ksettings()
1614 * (CX4, XFP, Quad Ribbon Fiber) by looking at the character in myri10ge_get_link_ksettings()
1618 ptr = mgp->product_code_string; in myri10ge_get_link_ksettings()
1624 ptr = strchr(ptr, '-'); in myri10ge_get_link_ksettings()
1627 mgp->product_code_string); in myri10ge_get_link_ksettings()
1634 /* We've found either an XFP, quad ribbon fiber, or SFP+ */ in myri10ge_get_link_ksettings()
1635 cmd->base.port = PORT_FIBRE; in myri10ge_get_link_ksettings()
1639 cmd->base.port = PORT_OTHER; in myri10ge_get_link_ksettings()
1650 strscpy(info->driver, "myri10ge", sizeof(info->driver)); in myri10ge_get_drvinfo()
1651 strscpy(info->version, MYRI10GE_VERSION_STR, sizeof(info->version)); in myri10ge_get_drvinfo()
1652 strscpy(info->fw_version, mgp->fw_version, sizeof(info->fw_version)); in myri10ge_get_drvinfo()
1653 strscpy(info->bus_info, pci_name(mgp->pdev), sizeof(info->bus_info)); in myri10ge_get_drvinfo()
1663 coal->rx_coalesce_usecs = mgp->intr_coal_delay; in myri10ge_get_coalesce()
1674 mgp->intr_coal_delay = coal->rx_coalesce_usecs; in myri10ge_set_coalesce()
1675 put_be32(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr); in myri10ge_set_coalesce()
1685 pause->autoneg = 0; in myri10ge_get_pauseparam()
1686 pause->rx_pause = mgp->pause; in myri10ge_get_pauseparam()
1687 pause->tx_pause = mgp->pause; in myri10ge_get_pauseparam()
1696 if (pause->tx_pause != mgp->pause) in myri10ge_set_pauseparam()
1697 return myri10ge_change_pause(mgp, pause->tx_pause); in myri10ge_set_pauseparam()
1698 if (pause->rx_pause != mgp->pause) in myri10ge_set_pauseparam()
1699 return myri10ge_change_pause(mgp, pause->rx_pause); in myri10ge_set_pauseparam()
1700 if (pause->autoneg != 0) in myri10ge_set_pauseparam()
1701 return -EINVAL; in myri10ge_set_pauseparam()
1713 ring->rx_mini_max_pending = mgp->ss[0].rx_small.mask + 1; in myri10ge_get_ringparam()
1714 ring->rx_max_pending = mgp->ss[0].rx_big.mask + 1; in myri10ge_get_ringparam()
1715 ring->rx_jumbo_max_pending = 0; in myri10ge_get_ringparam()
1716 ring->tx_max_pending = mgp->ss[0].tx.mask + 1; in myri10ge_get_ringparam()
1717 ring->rx_mini_pending = ring->rx_mini_max_pending; in myri10ge_get_ringparam()
1718 ring->rx_pending = ring->rx_max_pending; in myri10ge_get_ringparam()
1719 ring->rx_jumbo_pending = ring->rx_jumbo_max_pending; in myri10ge_get_ringparam()
1720 ring->tx_pending = ring->tx_max_pending; in myri10ge_get_ringparam()
1730 /* device-specific stats */
1746 "----------- slice ---------",
1767 for (i = 0; i < mgp->num_slices; i++) { in myri10ge_get_strings()
1783 mgp->num_slices * MYRI10GE_SLICE_STATS_LEN; in myri10ge_get_sset_count()
1785 return -EOPNOTSUPP; in myri10ge_get_sset_count()
1805 data[i++] = (unsigned int)mgp->tx_boundary; in myri10ge_get_ethtool_stats()
1806 data[i++] = (unsigned int)mgp->pdev->irq; in myri10ge_get_ethtool_stats()
1807 data[i++] = (unsigned int)mgp->msi_enabled; in myri10ge_get_ethtool_stats()
1808 data[i++] = (unsigned int)mgp->msix_enabled; in myri10ge_get_ethtool_stats()
1809 data[i++] = (unsigned int)mgp->read_dma; in myri10ge_get_ethtool_stats()
1810 data[i++] = (unsigned int)mgp->write_dma; in myri10ge_get_ethtool_stats()
1811 data[i++] = (unsigned int)mgp->read_write_dma; in myri10ge_get_ethtool_stats()
1812 data[i++] = (unsigned int)mgp->serial_number; in myri10ge_get_ethtool_stats()
1813 data[i++] = (unsigned int)mgp->watchdog_resets; in myri10ge_get_ethtool_stats()
1815 data[i++] = (unsigned int)(mgp->ss[0].dca_tag != NULL); in myri10ge_get_ethtool_stats()
1816 data[i++] = (unsigned int)(mgp->dca_enabled); in myri10ge_get_ethtool_stats()
1818 data[i++] = (unsigned int)mgp->link_changes; in myri10ge_get_ethtool_stats()
1821 ss = &mgp->ss[0]; in myri10ge_get_ethtool_stats()
1822 data[i++] = (unsigned int)ntohl(ss->fw_stats->link_up); in myri10ge_get_ethtool_stats()
1823 data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_link_overflow); in myri10ge_get_ethtool_stats()
1825 (unsigned int)ntohl(ss->fw_stats->dropped_link_error_or_filtered); in myri10ge_get_ethtool_stats()
1826 data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_pause); in myri10ge_get_ethtool_stats()
1827 data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_bad_phy); in myri10ge_get_ethtool_stats()
1828 data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_bad_crc32); in myri10ge_get_ethtool_stats()
1829 data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_unicast_filtered); in myri10ge_get_ethtool_stats()
1831 (unsigned int)ntohl(ss->fw_stats->dropped_multicast_filtered); in myri10ge_get_ethtool_stats()
1832 data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_runt); in myri10ge_get_ethtool_stats()
1833 data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_overrun); in myri10ge_get_ethtool_stats()
1834 data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_no_small_buffer); in myri10ge_get_ethtool_stats()
1835 data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_no_big_buffer); in myri10ge_get_ethtool_stats()
1837 for (slice = 0; slice < mgp->num_slices; slice++) { in myri10ge_get_ethtool_stats()
1838 ss = &mgp->ss[slice]; in myri10ge_get_ethtool_stats()
1840 data[i++] = (unsigned int)ss->tx.pkt_start; in myri10ge_get_ethtool_stats()
1841 data[i++] = (unsigned int)ss->tx.pkt_done; in myri10ge_get_ethtool_stats()
1842 data[i++] = (unsigned int)ss->tx.req; in myri10ge_get_ethtool_stats()
1843 data[i++] = (unsigned int)ss->tx.done; in myri10ge_get_ethtool_stats()
1844 data[i++] = (unsigned int)ss->rx_small.cnt; in myri10ge_get_ethtool_stats()
1845 data[i++] = (unsigned int)ss->rx_big.cnt; in myri10ge_get_ethtool_stats()
1846 data[i++] = (unsigned int)ss->tx.wake_queue; in myri10ge_get_ethtool_stats()
1847 data[i++] = (unsigned int)ss->tx.stop_queue; in myri10ge_get_ethtool_stats()
1848 data[i++] = (unsigned int)ss->tx.linearized; in myri10ge_get_ethtool_stats()
1855 mgp->msg_enable = value; in myri10ge_set_msglevel()
1861 return mgp->msg_enable; in myri10ge_get_msglevel()
1865 * Use a low-level command to change the LED behavior. Rather than
1872 struct device *dev = &mgp->pdev->dev; in myri10ge_led()
1877 hdr_off = swab32(readl(mgp->sram + MCP_HEADER_PTR_OFFSET)); in myri10ge_led()
1878 if ((hdr_off & 3) || hdr_off + sizeof(*hdr) > mgp->sram_size) { in myri10ge_led()
1881 return -EIO; in myri10ge_led()
1883 hdr_len = swab32(readl(mgp->sram + hdr_off + in myri10ge_led()
1888 return -EINVAL; in myri10ge_led()
1891 pattern = swab32(readl(mgp->sram + pattern_off + 4)); in myri10ge_led()
1892 writel(swab32(pattern), mgp->sram + pattern_off); in myri10ge_led()
1912 rc = -EINVAL; in myri10ge_phys_id()
1938 struct myri10ge_priv *mgp = ss->mgp; in myri10ge_allocate_rings()
1940 struct net_device *dev = mgp->dev; in myri10ge_allocate_rings()
1947 slice = ss - mgp->ss; in myri10ge_allocate_rings()
1959 ss->tx.mask = tx_ring_entries - 1; in myri10ge_allocate_rings()
1960 ss->rx_small.mask = ss->rx_big.mask = rx_ring_entries - 1; in myri10ge_allocate_rings()
1962 status = -ENOMEM; in myri10ge_allocate_rings()
1967 * sizeof(*ss->tx.req_list); in myri10ge_allocate_rings()
1968 ss->tx.req_bytes = kzalloc(bytes, GFP_KERNEL); in myri10ge_allocate_rings()
1969 if (ss->tx.req_bytes == NULL) in myri10ge_allocate_rings()
1973 ss->tx.req_list = (struct mcp_kreq_ether_send *) in myri10ge_allocate_rings()
1974 ALIGN((unsigned long)ss->tx.req_bytes, 8); in myri10ge_allocate_rings()
1975 ss->tx.queue_active = 0; in myri10ge_allocate_rings()
1977 bytes = rx_ring_entries * sizeof(*ss->rx_small.shadow); in myri10ge_allocate_rings()
1978 ss->rx_small.shadow = kzalloc(bytes, GFP_KERNEL); in myri10ge_allocate_rings()
1979 if (ss->rx_small.shadow == NULL) in myri10ge_allocate_rings()
1982 bytes = rx_ring_entries * sizeof(*ss->rx_big.shadow); in myri10ge_allocate_rings()
1983 ss->rx_big.shadow = kzalloc(bytes, GFP_KERNEL); in myri10ge_allocate_rings()
1984 if (ss->rx_big.shadow == NULL) in myri10ge_allocate_rings()
1989 bytes = tx_ring_entries * sizeof(*ss->tx.info); in myri10ge_allocate_rings()
1990 ss->tx.info = kzalloc(bytes, GFP_KERNEL); in myri10ge_allocate_rings()
1991 if (ss->tx.info == NULL) in myri10ge_allocate_rings()
1994 bytes = rx_ring_entries * sizeof(*ss->rx_small.info); in myri10ge_allocate_rings()
1995 ss->rx_small.info = kzalloc(bytes, GFP_KERNEL); in myri10ge_allocate_rings()
1996 if (ss->rx_small.info == NULL) in myri10ge_allocate_rings()
1999 bytes = rx_ring_entries * sizeof(*ss->rx_big.info); in myri10ge_allocate_rings()
2000 ss->rx_big.info = kzalloc(bytes, GFP_KERNEL); in myri10ge_allocate_rings()
2001 if (ss->rx_big.info == NULL) in myri10ge_allocate_rings()
2005 ss->rx_big.cnt = 0; in myri10ge_allocate_rings()
2006 ss->rx_small.cnt = 0; in myri10ge_allocate_rings()
2007 ss->rx_big.fill_cnt = 0; in myri10ge_allocate_rings()
2008 ss->rx_small.fill_cnt = 0; in myri10ge_allocate_rings()
2009 ss->rx_small.page_offset = MYRI10GE_ALLOC_SIZE; in myri10ge_allocate_rings()
2010 ss->rx_big.page_offset = MYRI10GE_ALLOC_SIZE; in myri10ge_allocate_rings()
2011 ss->rx_small.watchdog_needed = 0; in myri10ge_allocate_rings()
2012 ss->rx_big.watchdog_needed = 0; in myri10ge_allocate_rings()
2013 if (mgp->small_bytes == 0) { in myri10ge_allocate_rings()
2014 ss->rx_small.fill_cnt = ss->rx_small.mask + 1; in myri10ge_allocate_rings()
2016 myri10ge_alloc_rx_pages(mgp, &ss->rx_small, in myri10ge_allocate_rings()
2017 mgp->small_bytes + MXGEFW_PAD, 0); in myri10ge_allocate_rings()
2020 if (ss->rx_small.fill_cnt < ss->rx_small.mask + 1) { in myri10ge_allocate_rings()
2021 netdev_err(dev, "slice-%d: alloced only %d small bufs\n", in myri10ge_allocate_rings()
2022 slice, ss->rx_small.fill_cnt); in myri10ge_allocate_rings()
2026 myri10ge_alloc_rx_pages(mgp, &ss->rx_big, mgp->big_bytes, 0); in myri10ge_allocate_rings()
2027 if (ss->rx_big.fill_cnt < ss->rx_big.mask + 1) { in myri10ge_allocate_rings()
2028 netdev_err(dev, "slice-%d: alloced only %d big bufs\n", in myri10ge_allocate_rings()
2029 slice, ss->rx_big.fill_cnt); in myri10ge_allocate_rings()
2036 for (i = ss->rx_big.cnt; i < ss->rx_big.fill_cnt; i++) { in myri10ge_allocate_rings()
2037 int idx = i & ss->rx_big.mask; in myri10ge_allocate_rings()
2038 myri10ge_unmap_rx_page(mgp->pdev, &ss->rx_big.info[idx], in myri10ge_allocate_rings()
2039 mgp->big_bytes); in myri10ge_allocate_rings()
2040 put_page(ss->rx_big.info[idx].page); in myri10ge_allocate_rings()
2044 if (mgp->small_bytes == 0) in myri10ge_allocate_rings()
2045 ss->rx_small.fill_cnt = ss->rx_small.cnt; in myri10ge_allocate_rings()
2046 for (i = ss->rx_small.cnt; i < ss->rx_small.fill_cnt; i++) { in myri10ge_allocate_rings()
2047 int idx = i & ss->rx_small.mask; in myri10ge_allocate_rings()
2048 myri10ge_unmap_rx_page(mgp->pdev, &ss->rx_small.info[idx], in myri10ge_allocate_rings()
2049 mgp->small_bytes + MXGEFW_PAD); in myri10ge_allocate_rings()
2050 put_page(ss->rx_small.info[idx].page); in myri10ge_allocate_rings()
2053 kfree(ss->rx_big.info); in myri10ge_allocate_rings()
2056 kfree(ss->rx_small.info); in myri10ge_allocate_rings()
2059 kfree(ss->tx.info); in myri10ge_allocate_rings()
2062 kfree(ss->rx_big.shadow); in myri10ge_allocate_rings()
2065 kfree(ss->rx_small.shadow); in myri10ge_allocate_rings()
2068 kfree(ss->tx.req_bytes); in myri10ge_allocate_rings()
2069 ss->tx.req_bytes = NULL; in myri10ge_allocate_rings()
2070 ss->tx.req_list = NULL; in myri10ge_allocate_rings()
2078 struct myri10ge_priv *mgp = ss->mgp; in myri10ge_free_rings()
2084 if (ss->tx.req_list == NULL) in myri10ge_free_rings()
2087 for (i = ss->rx_big.cnt; i < ss->rx_big.fill_cnt; i++) { in myri10ge_free_rings()
2088 idx = i & ss->rx_big.mask; in myri10ge_free_rings()
2089 if (i == ss->rx_big.fill_cnt - 1) in myri10ge_free_rings()
2090 ss->rx_big.info[idx].page_offset = MYRI10GE_ALLOC_SIZE; in myri10ge_free_rings()
2091 myri10ge_unmap_rx_page(mgp->pdev, &ss->rx_big.info[idx], in myri10ge_free_rings()
2092 mgp->big_bytes); in myri10ge_free_rings()
2093 put_page(ss->rx_big.info[idx].page); in myri10ge_free_rings()
2096 if (mgp->small_bytes == 0) in myri10ge_free_rings()
2097 ss->rx_small.fill_cnt = ss->rx_small.cnt; in myri10ge_free_rings()
2098 for (i = ss->rx_small.cnt; i < ss->rx_small.fill_cnt; i++) { in myri10ge_free_rings()
2099 idx = i & ss->rx_small.mask; in myri10ge_free_rings()
2100 if (i == ss->rx_small.fill_cnt - 1) in myri10ge_free_rings()
2101 ss->rx_small.info[idx].page_offset = in myri10ge_free_rings()
2103 myri10ge_unmap_rx_page(mgp->pdev, &ss->rx_small.info[idx], in myri10ge_free_rings()
2104 mgp->small_bytes + MXGEFW_PAD); in myri10ge_free_rings()
2105 put_page(ss->rx_small.info[idx].page); in myri10ge_free_rings()
2107 tx = &ss->tx; in myri10ge_free_rings()
2108 while (tx->done != tx->req) { in myri10ge_free_rings()
2109 idx = tx->done & tx->mask; in myri10ge_free_rings()
2110 skb = tx->info[idx].skb; in myri10ge_free_rings()
2113 tx->info[idx].skb = NULL; in myri10ge_free_rings()
2114 tx->done++; in myri10ge_free_rings()
2115 len = dma_unmap_len(&tx->info[idx], len); in myri10ge_free_rings()
2116 dma_unmap_len_set(&tx->info[idx], len, 0); in myri10ge_free_rings()
2118 ss->stats.tx_dropped++; in myri10ge_free_rings()
2121 dma_unmap_single(&mgp->pdev->dev, in myri10ge_free_rings()
2122 dma_unmap_addr(&tx->info[idx], in myri10ge_free_rings()
2127 dma_unmap_page(&mgp->pdev->dev, in myri10ge_free_rings()
2128 dma_unmap_addr(&tx->info[idx], in myri10ge_free_rings()
2133 kfree(ss->rx_big.info); in myri10ge_free_rings()
2135 kfree(ss->rx_small.info); in myri10ge_free_rings()
2137 kfree(ss->tx.info); in myri10ge_free_rings()
2139 kfree(ss->rx_big.shadow); in myri10ge_free_rings()
2141 kfree(ss->rx_small.shadow); in myri10ge_free_rings()
2143 kfree(ss->tx.req_bytes); in myri10ge_free_rings()
2144 ss->tx.req_bytes = NULL; in myri10ge_free_rings()
2145 ss->tx.req_list = NULL; in myri10ge_free_rings()
2150 struct pci_dev *pdev = mgp->pdev; in myri10ge_request_irq()
2152 struct net_device *netdev = mgp->dev; in myri10ge_request_irq()
2156 mgp->msi_enabled = 0; in myri10ge_request_irq()
2157 mgp->msix_enabled = 0; in myri10ge_request_irq()
2160 if (mgp->num_slices > 1) { in myri10ge_request_irq()
2161 status = pci_enable_msix_range(pdev, mgp->msix_vectors, in myri10ge_request_irq()
2162 mgp->num_slices, mgp->num_slices); in myri10ge_request_irq()
2164 dev_err(&pdev->dev, in myri10ge_request_irq()
2165 "Error %d setting up MSI-X\n", status); in myri10ge_request_irq()
2168 mgp->msix_enabled = 1; in myri10ge_request_irq()
2170 if (mgp->msix_enabled == 0) { in myri10ge_request_irq()
2173 dev_err(&pdev->dev, in myri10ge_request_irq()
2177 mgp->msi_enabled = 1; in myri10ge_request_irq()
2181 if (mgp->msix_enabled) { in myri10ge_request_irq()
2182 for (i = 0; i < mgp->num_slices; i++) { in myri10ge_request_irq()
2183 ss = &mgp->ss[i]; in myri10ge_request_irq()
2184 snprintf(ss->irq_desc, sizeof(ss->irq_desc), in myri10ge_request_irq()
2185 "%s:slice-%d", netdev->name, i); in myri10ge_request_irq()
2186 status = request_irq(mgp->msix_vectors[i].vector, in myri10ge_request_irq()
2187 myri10ge_intr, 0, ss->irq_desc, in myri10ge_request_irq()
2190 dev_err(&pdev->dev, in myri10ge_request_irq()
2192 i--; in myri10ge_request_irq()
2194 free_irq(mgp->msix_vectors[i].vector, in myri10ge_request_irq()
2195 &mgp->ss[i]); in myri10ge_request_irq()
2196 i--; in myri10ge_request_irq()
2203 status = request_irq(pdev->irq, myri10ge_intr, IRQF_SHARED, in myri10ge_request_irq()
2204 mgp->dev->name, &mgp->ss[0]); in myri10ge_request_irq()
2206 dev_err(&pdev->dev, "failed to allocate IRQ\n"); in myri10ge_request_irq()
2207 if (mgp->msi_enabled) in myri10ge_request_irq()
2216 struct pci_dev *pdev = mgp->pdev; in myri10ge_free_irq()
2219 if (mgp->msix_enabled) { in myri10ge_free_irq()
2220 for (i = 0; i < mgp->num_slices; i++) in myri10ge_free_irq()
2221 free_irq(mgp->msix_vectors[i].vector, &mgp->ss[i]); in myri10ge_free_irq()
2223 free_irq(pdev->irq, &mgp->ss[0]); in myri10ge_free_irq()
2225 if (mgp->msi_enabled) in myri10ge_free_irq()
2227 if (mgp->msix_enabled) in myri10ge_free_irq()
2237 ss = &mgp->ss[slice]; in myri10ge_get_txrx()
2239 if (slice == 0 || (mgp->dev->real_num_tx_queues > 1)) { in myri10ge_get_txrx()
2243 ss->tx.lanai = (struct mcp_kreq_ether_send __iomem *) in myri10ge_get_txrx()
2244 (mgp->sram + cmd.data0); in myri10ge_get_txrx()
2249 ss->rx_small.lanai = (struct mcp_kreq_ether_recv __iomem *) in myri10ge_get_txrx()
2250 (mgp->sram + cmd.data0); in myri10ge_get_txrx()
2254 ss->rx_big.lanai = (struct mcp_kreq_ether_recv __iomem *) in myri10ge_get_txrx()
2255 (mgp->sram + cmd.data0); in myri10ge_get_txrx()
2257 ss->tx.send_go = (__iomem __be32 *) in myri10ge_get_txrx()
2258 (mgp->sram + MXGEFW_ETH_SEND_GO + 64 * slice); in myri10ge_get_txrx()
2259 ss->tx.send_stop = (__iomem __be32 *) in myri10ge_get_txrx()
2260 (mgp->sram + MXGEFW_ETH_SEND_STOP + 64 * slice); in myri10ge_get_txrx()
2271 ss = &mgp->ss[slice]; in myri10ge_set_stats()
2272 cmd.data0 = MYRI10GE_LOWPART_TO_U32(ss->fw_stats_bus); in myri10ge_set_stats()
2273 cmd.data1 = MYRI10GE_HIGHPART_TO_U32(ss->fw_stats_bus); in myri10ge_set_stats()
2276 if (status == -ENOSYS) { in myri10ge_set_stats()
2277 dma_addr_t bus = ss->fw_stats_bus; in myri10ge_set_stats()
2279 return -EINVAL; in myri10ge_set_stats()
2287 mgp->fw_multicast_support = 0; in myri10ge_set_stats()
2289 mgp->fw_multicast_support = 1; in myri10ge_set_stats()
2302 if (mgp->running != MYRI10GE_ETH_STOPPED) in myri10ge_open()
2303 return -EBUSY; in myri10ge_open()
2305 mgp->running = MYRI10GE_ETH_STARTING; in myri10ge_open()
2312 if (mgp->num_slices > 1) { in myri10ge_open()
2313 cmd.data0 = mgp->num_slices; in myri10ge_open()
2315 if (mgp->dev->real_num_tx_queues > 1) in myri10ge_open()
2324 cmd.data0 = mgp->num_slices; in myri10ge_open()
2337 itable = mgp->sram + cmd.data0; in myri10ge_open()
2338 for (i = 0; i < mgp->num_slices; i++) in myri10ge_open()
2361 if (dev->mtu <= ETH_DATA_LEN) in myri10ge_open()
2363 mgp->small_bytes = (128 > SMP_CACHE_BYTES) in myri10ge_open()
2364 ? (128 - MXGEFW_PAD) in myri10ge_open()
2365 : (SMP_CACHE_BYTES - MXGEFW_PAD); in myri10ge_open()
2368 mgp->small_bytes = VLAN_ETH_FRAME_LEN; in myri10ge_open()
2372 mgp->small_bytes = myri10ge_small_bytes; in myri10ge_open()
2378 big_pow2 = dev->mtu + ETH_HLEN + VLAN_HLEN + MXGEFW_PAD; in myri10ge_open()
2382 mgp->big_bytes = dev->mtu + ETH_HLEN + VLAN_HLEN + MXGEFW_PAD; in myri10ge_open()
2385 mgp->big_bytes = big_pow2; in myri10ge_open()
2388 /* setup the per-slice data structures */ in myri10ge_open()
2389 for (slice = 0; slice < mgp->num_slices; slice++) { in myri10ge_open()
2390 ss = &mgp->ss[slice]; in myri10ge_open()
2402 * supports setting up the tx stats on non-zero in myri10ge_open()
2404 if (slice == 0 || mgp->dev->real_num_tx_queues > 1) in myri10ge_open()
2412 napi_enable(&(ss)->napi); in myri10ge_open()
2416 cmd.data0 = dev->mtu + ETH_HLEN + VLAN_HLEN; in myri10ge_open()
2418 cmd.data0 = mgp->small_bytes; in myri10ge_open()
2436 if (status && status != -ENOSYS) { in myri10ge_open()
2441 mgp->link_state = ~0U; in myri10ge_open()
2442 mgp->rdma_tags_available = 15; in myri10ge_open()
2450 mgp->running = MYRI10GE_ETH_RUNNING; in myri10ge_open()
2451 mgp->watchdog_timer.expires = jiffies + myri10ge_watchdog_timeout * HZ; in myri10ge_open()
2452 add_timer(&mgp->watchdog_timer); in myri10ge_open()
2459 slice--; in myri10ge_open()
2460 napi_disable(&mgp->ss[slice].napi); in myri10ge_open()
2462 for (i = 0; i < mgp->num_slices; i++) in myri10ge_open()
2463 myri10ge_free_rings(&mgp->ss[i]); in myri10ge_open()
2468 mgp->running = MYRI10GE_ETH_STOPPED; in myri10ge_open()
2469 return -ENOMEM; in myri10ge_open()
2479 if (mgp->running != MYRI10GE_ETH_RUNNING) in myri10ge_close()
2482 if (mgp->ss[0].tx.req_bytes == NULL) in myri10ge_close()
2485 del_timer_sync(&mgp->watchdog_timer); in myri10ge_close()
2486 mgp->running = MYRI10GE_ETH_STOPPING; in myri10ge_close()
2487 for (i = 0; i < mgp->num_slices; i++) in myri10ge_close()
2488 napi_disable(&mgp->ss[i].napi); in myri10ge_close()
2493 if (mgp->rebooted == 0) { in myri10ge_close()
2494 old_down_cnt = mgp->down_cnt; in myri10ge_close()
2501 wait_event_timeout(mgp->down_wq, old_down_cnt != mgp->down_cnt, in myri10ge_close()
2503 if (old_down_cnt == mgp->down_cnt) in myri10ge_close()
2508 for (i = 0; i < mgp->num_slices; i++) in myri10ge_close()
2509 myri10ge_free_rings(&mgp->ss[i]); in myri10ge_close()
2511 mgp->running = MYRI10GE_ETH_STOPPED; in myri10ge_close()
2523 starting_slot = tx->req; in myri10ge_submit_req_backwards()
2525 cnt--; in myri10ge_submit_req_backwards()
2526 idx = (starting_slot + cnt) & tx->mask; in myri10ge_submit_req_backwards()
2527 myri10ge_pio_copy(&tx->lanai[idx], &src[cnt], sizeof(*src)); in myri10ge_submit_req_backwards()
2535 * pio handler in the nic. We re-write the first segment's flags
2548 idx = tx->req & tx->mask; in myri10ge_submit_req()
2550 last_flags = src->flags; in myri10ge_submit_req()
2551 src->flags = 0; in myri10ge_submit_req()
2553 dst = dstp = &tx->lanai[idx]; in myri10ge_submit_req()
2556 if ((idx + cnt) < tx->mask) { in myri10ge_submit_req()
2557 for (i = 0; i < (cnt - 1); i += 2) { in myri10ge_submit_req()
2575 /* re-write the last 32-bits with the valid flags */ in myri10ge_submit_req()
2576 src->flags = last_flags; in myri10ge_submit_req()
2578 tx->req += cnt; in myri10ge_submit_req()
2589 last_idx = (idx + 1) & tx->mask; in myri10ge_unmap_tx_dma()
2590 idx = tx->req & tx->mask; in myri10ge_unmap_tx_dma()
2592 len = dma_unmap_len(&tx->info[idx], len); in myri10ge_unmap_tx_dma()
2594 if (tx->info[idx].skb != NULL) in myri10ge_unmap_tx_dma()
2595 dma_unmap_single(&mgp->pdev->dev, in myri10ge_unmap_tx_dma()
2596 dma_unmap_addr(&tx->info[idx], in myri10ge_unmap_tx_dma()
2600 dma_unmap_page(&mgp->pdev->dev, in myri10ge_unmap_tx_dma()
2601 dma_unmap_addr(&tx->info[idx], in myri10ge_unmap_tx_dma()
2604 dma_unmap_len_set(&tx->info[idx], len, 0); in myri10ge_unmap_tx_dma()
2605 tx->info[idx].skb = NULL; in myri10ge_unmap_tx_dma()
2607 idx = (idx + 1) & tx->mask; in myri10ge_unmap_tx_dma()
2613 * segment does not cross myri10ge->tx_boundary, so this makes segment
2640 ss = &mgp->ss[queue]; in myri10ge_xmit()
2641 netdev_queue = netdev_get_tx_queue(mgp->dev, queue); in myri10ge_xmit()
2642 tx = &ss->tx; in myri10ge_xmit()
2645 req = tx->req_list; in myri10ge_xmit()
2646 avail = tx->mask - 1 - (tx->req - tx->done); in myri10ge_xmit()
2652 mss = skb_shinfo(skb)->gso_size; in myri10ge_xmit()
2658 tx->stop_queue++; in myri10ge_xmit()
2668 if (likely(skb->ip_summed == CHECKSUM_PARTIAL)) { in myri10ge_xmit()
2670 pseudo_hdr_offset = cksum_offset + skb->csum_offset; in myri10ge_xmit()
2695 cum_len = -skb_tcp_all_headers(skb); in myri10ge_xmit()
2703 if (unlikely(-cum_len > mgp->max_tso6)) in myri10ge_xmit()
2712 if (skb->len <= MXGEFW_SEND_SMALL_SIZE) { in myri10ge_xmit()
2719 ss->stats.tx_dropped += 1; in myri10ge_xmit()
2726 bus = dma_map_single(&mgp->pdev->dev, skb->data, len, DMA_TO_DEVICE); in myri10ge_xmit()
2727 if (unlikely(dma_mapping_error(&mgp->pdev->dev, bus))) in myri10ge_xmit()
2730 idx = tx->req & tx->mask; in myri10ge_xmit()
2731 tx->info[idx].skb = skb; in myri10ge_xmit()
2732 dma_unmap_addr_set(&tx->info[idx], bus, bus); in myri10ge_xmit()
2733 dma_unmap_len_set(&tx->info[idx], len, len); in myri10ge_xmit()
2735 frag_cnt = skb_shinfo(skb)->nr_frags; in myri10ge_xmit()
2742 * non-TSO packets, this is equal to "count". in myri10ge_xmit()
2754 * it must be filled-in retroactively - after each in myri10ge_xmit()
2760 * do not cross mgp->tx_boundary */ in myri10ge_xmit()
2771 (low + mgp->tx_boundary) & ~(mgp->tx_boundary - 1); in myri10ge_xmit()
2772 seglen = boundary - low; in myri10ge_xmit()
2778 (req - rdma_count)->rdma_count = rdma_count + 1; in myri10ge_xmit()
2789 rdma_count |= -(chop | next_is_first); in myri10ge_xmit()
2794 rdma_count = -1; in myri10ge_xmit()
2796 seglen = -cum_len; in myri10ge_xmit()
2803 req->addr_high = high_swapped; in myri10ge_xmit()
2804 req->addr_low = htonl(low); in myri10ge_xmit()
2805 req->pseudo_hdr_offset = htons(pseudo_hdr_offset); in myri10ge_xmit()
2806 req->pad = 0; /* complete solid 16-byte block; does this matter? */ in myri10ge_xmit()
2807 req->rdma_count = 1; in myri10ge_xmit()
2808 req->length = htons(seglen); in myri10ge_xmit()
2809 req->cksum_offset = cksum_offset; in myri10ge_xmit()
2810 req->flags = flags | ((cum_len & 1) * odd_flag); in myri10ge_xmit()
2813 len -= seglen; in myri10ge_xmit()
2821 cksum_offset -= seglen; in myri10ge_xmit()
2830 frag = &skb_shinfo(skb)->frags[frag_idx]; in myri10ge_xmit()
2833 bus = skb_frag_dma_map(&mgp->pdev->dev, frag, 0, len, in myri10ge_xmit()
2835 if (unlikely(dma_mapping_error(&mgp->pdev->dev, bus))) { in myri10ge_xmit()
2839 idx = (count + tx->req) & tx->mask; in myri10ge_xmit()
2840 dma_unmap_addr_set(&tx->info[idx], bus, bus); in myri10ge_xmit()
2841 dma_unmap_len_set(&tx->info[idx], len, len); in myri10ge_xmit()
2844 (req - rdma_count)->rdma_count = rdma_count; in myri10ge_xmit()
2847 req--; in myri10ge_xmit()
2848 req->flags |= MXGEFW_FLAGS_TSO_LAST; in myri10ge_xmit()
2849 } while (!(req->flags & (MXGEFW_FLAGS_TSO_CHOP | in myri10ge_xmit()
2851 idx = ((count - 1) + tx->req) & tx->mask; in myri10ge_xmit()
2852 tx->info[idx].last = 1; in myri10ge_xmit()
2853 myri10ge_submit_req(tx, tx->req_list, count); in myri10ge_xmit()
2856 if ((mgp->dev->real_num_tx_queues > 1) && tx->queue_active == 0) { in myri10ge_xmit()
2857 tx->queue_active = 1; in myri10ge_xmit()
2858 put_be32(htonl(1), tx->send_go); in myri10ge_xmit()
2861 tx->pkt_start++; in myri10ge_xmit()
2862 if ((avail - count) < MXGEFW_MAX_SEND_DESC) { in myri10ge_xmit()
2863 tx->stop_queue++; in myri10ge_xmit()
2872 netdev_err(mgp->dev, "TSO but wanted to linearize?!?!?\n"); in myri10ge_xmit()
2879 tx->linearized++; in myri10ge_xmit()
2884 ss->stats.tx_dropped += 1; in myri10ge_xmit()
2897 segs = skb_gso_segment(skb, dev->features & ~NETIF_F_TSO6); in myri10ge_sw_tso()
2907 curr->next = NULL; in myri10ge_sw_tso()
2917 ss = &mgp->ss[skb_get_queue_mapping(skb)]; in myri10ge_sw_tso()
2919 ss->stats.tx_dropped += 1; in myri10ge_sw_tso()
2930 for (i = 0; i < mgp->num_slices; i++) { in myri10ge_get_stats()
2931 slice_stats = &mgp->ss[i].stats; in myri10ge_get_stats()
2932 stats->rx_packets += slice_stats->rx_packets; in myri10ge_get_stats()
2933 stats->tx_packets += slice_stats->tx_packets; in myri10ge_get_stats()
2934 stats->rx_bytes += slice_stats->rx_bytes; in myri10ge_get_stats()
2935 stats->tx_bytes += slice_stats->tx_bytes; in myri10ge_get_stats()
2936 stats->rx_dropped += slice_stats->rx_dropped; in myri10ge_get_stats()
2937 stats->tx_dropped += slice_stats->tx_dropped; in myri10ge_get_stats()
2951 myri10ge_change_promisc(mgp, dev->flags & IFF_PROMISC, 1); in myri10ge_set_multicast_list()
2954 if (!mgp->fw_multicast_support) in myri10ge_set_multicast_list()
2966 if ((dev->flags & IFF_ALLMULTI) || mgp->adopted_rx_filter_bug) { in myri10ge_set_multicast_list()
2983 memcpy(data, &ha->addr, ETH_ALEN); in myri10ge_set_multicast_list()
2991 err, ha->addr); in myri10ge_set_multicast_list()
3015 if (!is_valid_ether_addr(sa->sa_data)) in myri10ge_set_mac_address()
3016 return -EADDRNOTAVAIL; in myri10ge_set_mac_address()
3018 status = myri10ge_update_mac_address(mgp, sa->sa_data); in myri10ge_set_mac_address()
3020 netdev_err(dev, "changing mac address failed with %d\n", in myri10ge_set_mac_address()
3026 eth_hw_addr_set(dev, sa->sa_data); in myri10ge_set_mac_address()
3034 netdev_info(dev, "changing mtu from %d to %d\n", dev->mtu, new_mtu); in myri10ge_change_mtu()
3035 if (mgp->running) { in myri10ge_change_mtu()
3039 WRITE_ONCE(dev->mtu, new_mtu); in myri10ge_change_mtu()
3042 WRITE_ONCE(dev->mtu, new_mtu); in myri10ge_change_mtu()
3048 * Enable ECRC to align PCI-E Completion packets on an 8-byte boundary.
3055 struct pci_dev *bridge = mgp->pdev->bus->self; in myri10ge_enable_ecrc()
3056 struct device *dev = &mgp->pdev->dev; in myri10ge_enable_ecrc()
3073 bridge = bridge->bus->self; in myri10ge_enable_ecrc()
3084 "Forcing ECRC on non-root port %s" in myri10ge_enable_ecrc()
3089 "Not enabling ECRC on non-root port %s\n", in myri10ge_enable_ecrc()
3101 dev_err(dev, "failed reading ext-conf-space of %s\n", in myri10ge_enable_ecrc()
3116 * The Lanai Z8E PCI-E interface achieves higher Read-DMA throughput
3117 * when the PCI-E Completion packets are aligned on an 8-byte
3118 * boundary. Some PCI-E chip sets always align Completion packets; on
3122 * When PCI-E Completion packets are not aligned, it is actually more
3123 * efficient to limit Read-DMA transactions to 2KB, rather than 4KB.
3128 * should also ensure that it never gives the device a Read-DMA which is
3136 struct pci_dev *pdev = mgp->pdev; in myri10ge_firmware_probe()
3137 struct device *dev = &pdev->dev; in myri10ge_firmware_probe()
3140 mgp->tx_boundary = 4096; in myri10ge_firmware_probe()
3152 mgp->tx_boundary = 2048; in myri10ge_firmware_probe()
3178 if (status != -E2BIG) in myri10ge_firmware_probe()
3180 if (status == -ENOSYS) in myri10ge_firmware_probe()
3185 mgp->tx_boundary = 2048; in myri10ge_firmware_probe()
3197 pcie_capability_read_word(mgp->pdev, PCI_EXP_LNKSTA, &lnk); in myri10ge_select_firmware()
3204 dev_info(&mgp->pdev->dev, "PCIE x%d Link\n", in myri10ge_select_firmware()
3206 mgp->tx_boundary = 4096; in myri10ge_select_firmware()
3213 dev_info(&mgp->pdev->dev, in myri10ge_select_firmware()
3215 mgp->tx_boundary = 4096; in myri10ge_select_firmware()
3218 dev_info(&mgp->pdev->dev, in myri10ge_select_firmware()
3220 mgp->tx_boundary = 2048; in myri10ge_select_firmware()
3235 if (mgp->board_number < MYRI10GE_MAX_BOARDS && in myri10ge_select_firmware()
3236 myri10ge_fw_names[mgp->board_number] != NULL && in myri10ge_select_firmware()
3237 strlen(myri10ge_fw_names[mgp->board_number])) { in myri10ge_select_firmware()
3238 set_fw_name(mgp, myri10ge_fw_names[mgp->board_number], false); in myri10ge_select_firmware()
3242 dev_info(&mgp->pdev->dev, "overriding firmware to %s\n", in myri10ge_select_firmware()
3243 mgp->fw_name); in myri10ge_select_firmware()
3248 struct pci_dev *bridge = pdev->bus->self; in myri10ge_mask_surprise_down()
3273 return -EINVAL; in myri10ge_suspend()
3274 netdev = mgp->dev; in myri10ge_suspend()
3298 return -EINVAL; in myri10ge_resume()
3299 netdev = mgp->dev; in myri10ge_resume()
3301 pci_read_config_word(mgp->pdev, PCI_VENDOR_ID, &vendor); in myri10ge_resume()
3303 netdev_err(mgp->dev, "device disappeared!\n"); in myri10ge_resume()
3304 return -EIO; in myri10ge_resume()
3323 return -EIO; in myri10ge_resume()
3328 struct pci_dev *pdev = mgp->pdev; in myri10ge_read_reboot()
3329 int vs = mgp->vendor_specific_offset; in myri10ge_read_reboot()
3345 struct myri10ge_priv *mgp = ss->mgp; in myri10ge_check_slice()
3346 int slice = ss - mgp->ss; in myri10ge_check_slice()
3348 if (ss->tx.req != ss->tx.done && in myri10ge_check_slice()
3349 ss->tx.done == ss->watchdog_tx_done && in myri10ge_check_slice()
3350 ss->watchdog_tx_req != ss->watchdog_tx_done) { in myri10ge_check_slice()
3352 if (rx_pause_cnt != mgp->watchdog_pause) { in myri10ge_check_slice()
3354 netdev_warn(mgp->dev, "slice %d: TX paused, " in myri10ge_check_slice()
3357 netdev_warn(mgp->dev, in myri10ge_check_slice()
3359 slice, ss->tx.queue_active, ss->tx.req, in myri10ge_check_slice()
3360 ss->tx.done, ss->tx.pkt_start, in myri10ge_check_slice()
3361 ss->tx.pkt_done, in myri10ge_check_slice()
3362 (int)ntohl(mgp->ss[slice].fw_stats-> in myri10ge_check_slice()
3365 ss->stuck = 1; in myri10ge_check_slice()
3368 if (ss->watchdog_tx_done != ss->tx.done || in myri10ge_check_slice()
3369 ss->watchdog_rx_done != ss->rx_done.cnt) { in myri10ge_check_slice()
3372 ss->watchdog_tx_done = ss->tx.done; in myri10ge_check_slice()
3373 ss->watchdog_tx_req = ss->tx.req; in myri10ge_check_slice()
3374 ss->watchdog_rx_done = ss->rx_done.cnt; in myri10ge_check_slice()
3393 mgp->watchdog_resets++; in myri10ge_watchdog()
3394 pci_read_config_word(mgp->pdev, PCI_COMMAND, &cmd); in myri10ge_watchdog()
3401 netdev_err(mgp->dev, "NIC rebooted (0x%x),%s resetting\n", in myri10ge_watchdog()
3406 mgp->rebooted = 1; in myri10ge_watchdog()
3408 myri10ge_close(mgp->dev); in myri10ge_watchdog()
3409 myri10ge_reset_recover--; in myri10ge_watchdog()
3410 mgp->rebooted = 0; in myri10ge_watchdog()
3418 pci_restore_state(mgp->pdev); in myri10ge_watchdog()
3421 pci_save_state(mgp->pdev); in myri10ge_watchdog()
3424 /* if we get back -1's from our slot, perhaps somebody in myri10ge_watchdog()
3428 pci_read_config_word(mgp->pdev, PCI_VENDOR_ID, &vendor); in myri10ge_watchdog()
3430 netdev_err(mgp->dev, "device disappeared!\n"); in myri10ge_watchdog()
3436 rx_pause_cnt = ntohl(mgp->ss[0].fw_stats->dropped_pause); in myri10ge_watchdog()
3437 for (i = 0; i < mgp->num_slices; i++) { in myri10ge_watchdog()
3438 ss = mgp->ss; in myri10ge_watchdog()
3439 if (ss->stuck) { in myri10ge_watchdog()
3443 ss->stuck = 0; in myri10ge_watchdog()
3447 netdev_dbg(mgp->dev, "not resetting\n"); in myri10ge_watchdog()
3451 netdev_err(mgp->dev, "device timeout, resetting\n"); in myri10ge_watchdog()
3456 myri10ge_close(mgp->dev); in myri10ge_watchdog()
3460 netdev_err(mgp->dev, "failed to load firmware\n"); in myri10ge_watchdog()
3462 myri10ge_open(mgp->dev); in myri10ge_watchdog()
3468 * netdev->tx_timeout because we have a very large hardware transmit
3469 * queue. Due to the large queue, the netdev->tx_timeout function
3483 rx_pause_cnt = ntohl(mgp->ss[0].fw_stats->dropped_pause); in myri10ge_watchdog_timer()
3486 i < mgp->num_slices && reset_needed == 0; ++i) { in myri10ge_watchdog_timer()
3488 ss = &mgp->ss[i]; in myri10ge_watchdog_timer()
3489 if (ss->rx_small.watchdog_needed) { in myri10ge_watchdog_timer()
3490 myri10ge_alloc_rx_pages(mgp, &ss->rx_small, in myri10ge_watchdog_timer()
3491 mgp->small_bytes + MXGEFW_PAD, in myri10ge_watchdog_timer()
3493 if (ss->rx_small.fill_cnt - ss->rx_small.cnt >= in myri10ge_watchdog_timer()
3495 ss->rx_small.watchdog_needed = 0; in myri10ge_watchdog_timer()
3497 if (ss->rx_big.watchdog_needed) { in myri10ge_watchdog_timer()
3498 myri10ge_alloc_rx_pages(mgp, &ss->rx_big, in myri10ge_watchdog_timer()
3499 mgp->big_bytes, 1); in myri10ge_watchdog_timer()
3500 if (ss->rx_big.fill_cnt - ss->rx_big.cnt >= in myri10ge_watchdog_timer()
3502 ss->rx_big.watchdog_needed = 0; in myri10ge_watchdog_timer()
3511 pci_read_config_word(mgp->pdev, PCI_COMMAND, &cmd); in myri10ge_watchdog_timer()
3516 mgp->watchdog_pause = rx_pause_cnt; in myri10ge_watchdog_timer()
3519 schedule_work(&mgp->watchdog_work); in myri10ge_watchdog_timer()
3522 mod_timer(&mgp->watchdog_timer, in myri10ge_watchdog_timer()
3530 struct pci_dev *pdev = mgp->pdev; in myri10ge_free_slices()
3534 if (mgp->ss == NULL) in myri10ge_free_slices()
3537 for (i = 0; i < mgp->num_slices; i++) { in myri10ge_free_slices()
3538 ss = &mgp->ss[i]; in myri10ge_free_slices()
3539 if (ss->rx_done.entry != NULL) { in myri10ge_free_slices()
3540 bytes = mgp->max_intr_slots * in myri10ge_free_slices()
3541 sizeof(*ss->rx_done.entry); in myri10ge_free_slices()
3542 dma_free_coherent(&pdev->dev, bytes, in myri10ge_free_slices()
3543 ss->rx_done.entry, ss->rx_done.bus); in myri10ge_free_slices()
3544 ss->rx_done.entry = NULL; in myri10ge_free_slices()
3546 if (ss->fw_stats != NULL) { in myri10ge_free_slices()
3547 bytes = sizeof(*ss->fw_stats); in myri10ge_free_slices()
3548 dma_free_coherent(&pdev->dev, bytes, in myri10ge_free_slices()
3549 ss->fw_stats, ss->fw_stats_bus); in myri10ge_free_slices()
3550 ss->fw_stats = NULL; in myri10ge_free_slices()
3552 __netif_napi_del(&ss->napi); in myri10ge_free_slices()
3556 kfree(mgp->ss); in myri10ge_free_slices()
3557 mgp->ss = NULL; in myri10ge_free_slices()
3563 struct pci_dev *pdev = mgp->pdev; in myri10ge_alloc_slices()
3567 bytes = sizeof(*mgp->ss) * mgp->num_slices; in myri10ge_alloc_slices()
3568 mgp->ss = kzalloc(bytes, GFP_KERNEL); in myri10ge_alloc_slices()
3569 if (mgp->ss == NULL) { in myri10ge_alloc_slices()
3570 return -ENOMEM; in myri10ge_alloc_slices()
3573 for (i = 0; i < mgp->num_slices; i++) { in myri10ge_alloc_slices()
3574 ss = &mgp->ss[i]; in myri10ge_alloc_slices()
3575 bytes = mgp->max_intr_slots * sizeof(*ss->rx_done.entry); in myri10ge_alloc_slices()
3576 ss->rx_done.entry = dma_alloc_coherent(&pdev->dev, bytes, in myri10ge_alloc_slices()
3577 &ss->rx_done.bus, in myri10ge_alloc_slices()
3579 if (ss->rx_done.entry == NULL) in myri10ge_alloc_slices()
3581 bytes = sizeof(*ss->fw_stats); in myri10ge_alloc_slices()
3582 ss->fw_stats = dma_alloc_coherent(&pdev->dev, bytes, in myri10ge_alloc_slices()
3583 &ss->fw_stats_bus, in myri10ge_alloc_slices()
3585 if (ss->fw_stats == NULL) in myri10ge_alloc_slices()
3587 ss->mgp = mgp; in myri10ge_alloc_slices()
3588 ss->dev = mgp->dev; in myri10ge_alloc_slices()
3589 netif_napi_add_weight(ss->dev, &ss->napi, myri10ge_poll, in myri10ge_alloc_slices()
3595 return -ENOMEM; in myri10ge_alloc_slices()
3601 * the number of MSI-X irqs supported, the number of slices
3607 struct pci_dev *pdev = mgp->pdev; in myri10ge_probe_slices()
3612 mgp->num_slices = 1; in myri10ge_probe_slices()
3615 if (myri10ge_max_slices == 1 || !pdev->msix_cap || in myri10ge_probe_slices()
3616 (myri10ge_max_slices == -1 && ncpus < 2)) in myri10ge_probe_slices()
3620 old_fw = mgp->fw_name; in myri10ge_probe_slices()
3621 old_allocated = mgp->fw_name_allocated; in myri10ge_probe_slices()
3623 mgp->fw_name_allocated = false; in myri10ge_probe_slices()
3626 dev_info(&mgp->pdev->dev, "overriding rss firmware to %s\n", in myri10ge_probe_slices()
3635 dev_info(&pdev->dev, "Rss firmware not found\n"); in myri10ge_probe_slices()
3645 dev_err(&mgp->pdev->dev, "failed reset\n"); in myri10ge_probe_slices()
3649 mgp->max_intr_slots = cmd.data0 / sizeof(struct mcp_slot); in myri10ge_probe_slices()
3652 cmd.data0 = mgp->max_intr_slots * sizeof(struct mcp_slot); in myri10ge_probe_slices()
3655 dev_err(&mgp->pdev->dev, "failed MXGEFW_CMD_SET_INTRQ_SIZE\n"); in myri10ge_probe_slices()
3664 mgp->num_slices = cmd.data0; in myri10ge_probe_slices()
3666 /* Only allow multiple slices if MSI-X is usable */ in myri10ge_probe_slices()
3674 if (myri10ge_max_slices == -1) in myri10ge_probe_slices()
3677 if (mgp->num_slices > myri10ge_max_slices) in myri10ge_probe_slices()
3678 mgp->num_slices = myri10ge_max_slices; in myri10ge_probe_slices()
3680 /* Now try to allocate as many MSI-X vectors as we have in myri10ge_probe_slices()
3681 * slices. We give up on MSI-X if we can only get a single in myri10ge_probe_slices()
3684 mgp->msix_vectors = kcalloc(mgp->num_slices, sizeof(*mgp->msix_vectors), in myri10ge_probe_slices()
3686 if (mgp->msix_vectors == NULL) in myri10ge_probe_slices()
3688 for (i = 0; i < mgp->num_slices; i++) { in myri10ge_probe_slices()
3689 mgp->msix_vectors[i].entry = i; in myri10ge_probe_slices()
3692 while (mgp->num_slices > 1) { in myri10ge_probe_slices()
3693 mgp->num_slices = rounddown_pow_of_two(mgp->num_slices); in myri10ge_probe_slices()
3694 if (mgp->num_slices == 1) in myri10ge_probe_slices()
3697 mgp->msix_vectors, in myri10ge_probe_slices()
3698 mgp->num_slices, in myri10ge_probe_slices()
3699 mgp->num_slices); in myri10ge_probe_slices()
3705 if (status == mgp->num_slices) { in myri10ge_probe_slices()
3710 mgp->num_slices = status; in myri10ge_probe_slices()
3715 if (mgp->msix_vectors != NULL) { in myri10ge_probe_slices()
3716 kfree(mgp->msix_vectors); in myri10ge_probe_slices()
3717 mgp->msix_vectors = NULL; in myri10ge_probe_slices()
3721 mgp->num_slices = 1; in myri10ge_probe_slices()
3741 struct device *dev = &pdev->dev; in myri10ge_probe()
3742 int status = -ENXIO; in myri10ge_probe()
3748 return -ENOMEM; in myri10ge_probe()
3750 SET_NETDEV_DEV(netdev, &pdev->dev); in myri10ge_probe()
3753 mgp->dev = netdev; in myri10ge_probe()
3754 mgp->pdev = pdev; in myri10ge_probe()
3755 mgp->pause = myri10ge_flow_control; in myri10ge_probe()
3756 mgp->intr_coal_delay = myri10ge_intr_coal_delay; in myri10ge_probe()
3757 mgp->msg_enable = netif_msg_init(myri10ge_debug, MYRI10GE_MSG_DEFAULT); in myri10ge_probe()
3758 mgp->board_number = board_number; in myri10ge_probe()
3759 init_waitqueue_head(&mgp->down_wq); in myri10ge_probe()
3762 dev_err(&pdev->dev, "pci_enable_device call failed\n"); in myri10ge_probe()
3763 status = -ENODEV; in myri10ge_probe()
3767 /* Find the vendor-specific cap so we can check in myri10ge_probe()
3769 mgp->vendor_specific_offset in myri10ge_probe()
3775 dev_err(&pdev->dev, "Error %d writing PCI_EXP_DEVCTL\n", in myri10ge_probe()
3782 status = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); in myri10ge_probe()
3784 dev_err(&pdev->dev, "Error %d setting DMA mask\n", status); in myri10ge_probe()
3787 mgp->cmd = dma_alloc_coherent(&pdev->dev, sizeof(*mgp->cmd), in myri10ge_probe()
3788 &mgp->cmd_bus, GFP_KERNEL); in myri10ge_probe()
3789 if (!mgp->cmd) { in myri10ge_probe()
3790 status = -ENOMEM; in myri10ge_probe()
3794 mgp->board_span = pci_resource_len(pdev, 0); in myri10ge_probe()
3795 mgp->iomem_base = pci_resource_start(pdev, 0); in myri10ge_probe()
3796 mgp->wc_cookie = arch_phys_wc_add(mgp->iomem_base, mgp->board_span); in myri10ge_probe()
3797 mgp->sram = ioremap_wc(mgp->iomem_base, mgp->board_span); in myri10ge_probe()
3798 if (mgp->sram == NULL) { in myri10ge_probe()
3799 dev_err(&pdev->dev, "ioremap failed for %ld bytes at 0x%lx\n", in myri10ge_probe()
3800 mgp->board_span, mgp->iomem_base); in myri10ge_probe()
3801 status = -ENXIO; in myri10ge_probe()
3805 swab32(readl(mgp->sram + MCP_HEADER_PTR_OFFSET)) & 0xffffc; in myri10ge_probe()
3807 mgp->sram_size = swab32(readl(mgp->sram + ss_offset)); in myri10ge_probe()
3808 if (mgp->sram_size > mgp->board_span || in myri10ge_probe()
3809 mgp->sram_size <= MYRI10GE_FW_OFFSET) { in myri10ge_probe()
3810 dev_err(&pdev->dev, in myri10ge_probe()
3812 mgp->sram_size, mgp->board_span); in myri10ge_probe()
3813 status = -EINVAL; in myri10ge_probe()
3816 memcpy_fromio(mgp->eeprom_strings, in myri10ge_probe()
3817 mgp->sram + mgp->sram_size, MYRI10GE_EEPROM_STRINGS_SIZE); in myri10ge_probe()
3818 memset(mgp->eeprom_strings + MYRI10GE_EEPROM_STRINGS_SIZE - 2, 0, 2); in myri10ge_probe()
3823 eth_hw_addr_set(netdev, mgp->mac_addr); in myri10ge_probe()
3829 dev_err(&pdev->dev, "failed to load firmware\n"); in myri10ge_probe()
3835 dev_err(&pdev->dev, "failed to alloc slice state\n"); in myri10ge_probe()
3838 netif_set_real_num_tx_queues(netdev, mgp->num_slices); in myri10ge_probe()
3839 netif_set_real_num_rx_queues(netdev, mgp->num_slices); in myri10ge_probe()
3842 dev_err(&pdev->dev, "failed reset\n"); in myri10ge_probe()
3850 /* MTU range: 68 - 9000 */ in myri10ge_probe()
3851 netdev->min_mtu = ETH_MIN_MTU; in myri10ge_probe()
3852 netdev->max_mtu = MYRI10GE_MAX_ETHER_MTU - ETH_HLEN; in myri10ge_probe()
3854 if (myri10ge_initial_mtu > netdev->max_mtu) in myri10ge_probe()
3855 myri10ge_initial_mtu = netdev->max_mtu; in myri10ge_probe()
3856 if (myri10ge_initial_mtu < netdev->min_mtu) in myri10ge_probe()
3857 myri10ge_initial_mtu = netdev->min_mtu; in myri10ge_probe()
3859 netdev->mtu = myri10ge_initial_mtu; in myri10ge_probe()
3861 netdev->netdev_ops = &myri10ge_netdev_ops; in myri10ge_probe()
3862 netdev->hw_features = mgp->features | NETIF_F_RXCSUM; in myri10ge_probe()
3865 netdev->hw_features |= NETIF_F_HW_VLAN_CTAG_RX; in myri10ge_probe()
3867 netdev->features = netdev->hw_features | NETIF_F_HIGHDMA; in myri10ge_probe()
3869 netdev->vlan_features |= mgp->features; in myri10ge_probe()
3870 if (mgp->fw_ver_tiny < 37) in myri10ge_probe()
3871 netdev->vlan_features &= ~NETIF_F_TSO6; in myri10ge_probe()
3872 if (mgp->fw_ver_tiny < 32) in myri10ge_probe()
3873 netdev->vlan_features &= ~NETIF_F_TSO; in myri10ge_probe()
3887 timer_setup(&mgp->watchdog_timer, myri10ge_watchdog_timer, 0); in myri10ge_probe()
3889 netdev->ethtool_ops = &myri10ge_ethtool_ops; in myri10ge_probe()
3890 INIT_WORK(&mgp->watchdog_work, myri10ge_watchdog); in myri10ge_probe()
3893 dev_err(&pdev->dev, "register_netdev failed: %d\n", status); in myri10ge_probe()
3896 if (mgp->msix_enabled) in myri10ge_probe()
3897 dev_info(dev, "%d MSI-X IRQs, tx bndry %d, fw %s, MTRR %s, WC Enabled\n", in myri10ge_probe()
3898 mgp->num_slices, mgp->tx_boundary, mgp->fw_name, in myri10ge_probe()
3899 (mgp->wc_cookie > 0 ? "Enabled" : "Disabled")); in myri10ge_probe()
3902 mgp->msi_enabled ? "MSI" : "xPIC", in myri10ge_probe()
3903 pdev->irq, mgp->tx_boundary, mgp->fw_name, in myri10ge_probe()
3904 (mgp->wc_cookie > 0 ? "Enabled" : "Disabled")); in myri10ge_probe()
3916 kfree(mgp->msix_vectors); in myri10ge_probe()
3920 if (mgp->mac_addr_string != NULL) in myri10ge_probe()
3921 dev_err(&pdev->dev, in myri10ge_probe()
3922 "myri10ge_probe() failed: MAC=%s, SN=%ld\n", in myri10ge_probe()
3923 mgp->mac_addr_string, mgp->serial_number); in myri10ge_probe()
3924 iounmap(mgp->sram); in myri10ge_probe()
3927 arch_phys_wc_del(mgp->wc_cookie); in myri10ge_probe()
3928 dma_free_coherent(&pdev->dev, sizeof(*mgp->cmd), in myri10ge_probe()
3929 mgp->cmd, mgp->cmd_bus); in myri10ge_probe()
3956 cancel_work_sync(&mgp->watchdog_work); in myri10ge_remove()
3957 netdev = mgp->dev; in myri10ge_remove()
3968 iounmap(mgp->sram); in myri10ge_remove()
3969 arch_phys_wc_del(mgp->wc_cookie); in myri10ge_remove()
3971 kfree(mgp->msix_vectors); in myri10ge_remove()
3972 dma_free_coherent(&pdev->dev, sizeof(*mgp->cmd), in myri10ge_remove()
3973 mgp->cmd, mgp->cmd_bus); in myri10ge_remove()