Lines Matching refs:mgp

179 	struct myri10ge_priv *mgp;  member
368 static void set_fw_name(struct myri10ge_priv *mgp, char *name, bool allocated) in set_fw_name() argument
370 if (mgp->fw_name_allocated) in set_fw_name()
371 kfree(mgp->fw_name); in set_fw_name()
372 mgp->fw_name = name; in set_fw_name()
373 mgp->fw_name_allocated = allocated; in set_fw_name()
377 myri10ge_send_cmd(struct myri10ge_priv *mgp, u32 cmd, in myri10ge_send_cmd() argument
382 struct mcp_cmd_response *response = mgp->cmd; in myri10ge_send_cmd()
383 char __iomem *cmd_addr = mgp->sram + MXGEFW_ETH_CMD; in myri10ge_send_cmd()
394 dma_low = MYRI10GE_LOWPART_TO_U32(mgp->cmd_bus); in myri10ge_send_cmd()
395 dma_high = MYRI10GE_HIGHPART_TO_U32(mgp->cmd_bus); in myri10ge_send_cmd()
445 dev_err(&mgp->pdev->dev, in myri10ge_send_cmd()
452 dev_err(&mgp->pdev->dev, "command %d timed out, result = %d\n", in myri10ge_send_cmd()
464 static int myri10ge_read_mac_addr(struct myri10ge_priv *mgp) in myri10ge_read_mac_addr() argument
469 ptr = mgp->eeprom_strings; in myri10ge_read_mac_addr()
470 limit = mgp->eeprom_strings + MYRI10GE_EEPROM_STRINGS_SIZE; in myri10ge_read_mac_addr()
475 mgp->mac_addr_string = ptr; in myri10ge_read_mac_addr()
479 mgp->mac_addr[i] = in myri10ge_read_mac_addr()
486 mgp->product_code_string = ptr; in myri10ge_read_mac_addr()
490 mgp->serial_number = simple_strtoul(ptr, &ptr, 10); in myri10ge_read_mac_addr()
498 dev_err(&mgp->pdev->dev, "failed to parse eeprom_strings\n"); in myri10ge_read_mac_addr()
507 static void myri10ge_dummy_rdma(struct myri10ge_priv *mgp, int enable) in myri10ge_dummy_rdma() argument
515 mgp->cmd->data = 0; in myri10ge_dummy_rdma()
522 dma_low = MYRI10GE_LOWPART_TO_U32(mgp->cmd_bus); in myri10ge_dummy_rdma()
523 dma_high = MYRI10GE_HIGHPART_TO_U32(mgp->cmd_bus); in myri10ge_dummy_rdma()
532 submit = mgp->sram + MXGEFW_BOOT_DUMMY_RDMA; in myri10ge_dummy_rdma()
535 for (i = 0; mgp->cmd->data != MYRI10GE_NO_CONFIRM_DATA && i < 20; i++) in myri10ge_dummy_rdma()
537 if (mgp->cmd->data != MYRI10GE_NO_CONFIRM_DATA) in myri10ge_dummy_rdma()
538 dev_err(&mgp->pdev->dev, "dummy rdma %s failed\n", in myri10ge_dummy_rdma()
543 myri10ge_validate_firmware(struct myri10ge_priv *mgp, in myri10ge_validate_firmware() argument
546 struct device *dev = &mgp->pdev->dev; in myri10ge_validate_firmware()
555 strncpy(mgp->fw_version, hdr->version, sizeof(mgp->fw_version)); in myri10ge_validate_firmware()
556 mgp->fw_version[sizeof(mgp->fw_version) - 1] = '\0'; 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()
571 static int myri10ge_load_hotplug_firmware(struct myri10ge_priv *mgp, u32 * size) in myri10ge_load_hotplug_firmware() argument
575 struct device *dev = &mgp->pdev->dev; in myri10ge_load_hotplug_firmware()
582 if ((status = request_firmware(&fw, mgp->fw_name, dev)) < 0) { in myri10ge_load_hotplug_firmware()
584 mgp->fw_name); in myri10ge_load_hotplug_firmware()
591 if (fw->size >= mgp->sram_size - MYRI10GE_FW_OFFSET || in myri10ge_load_hotplug_firmware()
607 status = myri10ge_validate_firmware(mgp, hdr); in myri10ge_load_hotplug_firmware()
613 myri10ge_pio_copy(mgp->sram + MYRI10GE_FW_OFFSET + i, in myri10ge_load_hotplug_firmware()
617 readb(mgp->sram); in myri10ge_load_hotplug_firmware()
625 memcpy_fromio(fw_readback, mgp->sram + MYRI10GE_FW_OFFSET, fw->size); in myri10ge_load_hotplug_firmware()
643 static int myri10ge_adopt_running_firmware(struct myri10ge_priv *mgp) in myri10ge_adopt_running_firmware() argument
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()
666 memcpy_fromio(hdr, mgp->sram + hdr_offset, bytes); in myri10ge_adopt_running_firmware()
667 status = myri10ge_validate_firmware(mgp, hdr); 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()
684 static int myri10ge_get_firmware_capabilities(struct myri10ge_priv *mgp) in myri10ge_get_firmware_capabilities() argument
690 mgp->features = NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_TSO; in myri10ge_get_firmware_capabilities()
691 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_MAX_TSO6_HDR_SIZE, 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()
698 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_RX_RING_SIZE, &cmd, 0); in myri10ge_get_firmware_capabilities()
700 dev_err(&mgp->pdev->dev, in myri10ge_get_firmware_capabilities()
705 mgp->max_intr_slots = 2 * (cmd.data0 / sizeof(struct mcp_dma_addr)); in myri10ge_get_firmware_capabilities()
710 static int myri10ge_load_firmware(struct myri10ge_priv *mgp, int adopt) in myri10ge_load_firmware() argument
718 status = myri10ge_load_hotplug_firmware(mgp, &size); in myri10ge_load_firmware()
722 dev_warn(&mgp->pdev->dev, "hotplug firmware loading failed\n"); in myri10ge_load_firmware()
729 status = myri10ge_adopt_running_firmware(mgp); 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()
747 set_fw_name(mgp, "adopted", false); in myri10ge_load_firmware()
748 mgp->tx_boundary = 2048; in myri10ge_load_firmware()
749 myri10ge_dummy_rdma(mgp, 1); in myri10ge_load_firmware()
750 status = myri10ge_get_firmware_capabilities(mgp); in myri10ge_load_firmware()
755 mgp->cmd->data = 0; 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()
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()
793 myri10ge_dummy_rdma(mgp, 1); in myri10ge_load_firmware()
794 status = myri10ge_get_firmware_capabilities(mgp); in myri10ge_load_firmware()
799 static int myri10ge_update_mac_address(struct myri10ge_priv *mgp, u8 * addr) in myri10ge_update_mac_address() argument
809 status = myri10ge_send_cmd(mgp, MXGEFW_SET_MAC_ADDRESS, &cmd, 0); in myri10ge_update_mac_address()
813 static int myri10ge_change_pause(struct myri10ge_priv *mgp, int pause) in myri10ge_change_pause() argument
819 status = myri10ge_send_cmd(mgp, ctl, &cmd, 0); in myri10ge_change_pause()
822 netdev_err(mgp->dev, "Failed to set flow control mode\n"); in myri10ge_change_pause()
825 mgp->pause = pause; in myri10ge_change_pause()
830 myri10ge_change_promisc(struct myri10ge_priv *mgp, int promisc, int atomic) in myri10ge_change_promisc() argument
836 status = myri10ge_send_cmd(mgp, ctl, &cmd, atomic); in myri10ge_change_promisc()
838 netdev_err(mgp->dev, "Failed to set promisc mode\n"); in myri10ge_change_promisc()
841 static int myri10ge_dma_test(struct myri10ge_priv *mgp, int test_type) in myri10ge_dma_test() argument
853 dmatest_bus = pci_map_page(mgp->pdev, dmatest_page, 0, PAGE_SIZE, in myri10ge_dma_test()
855 if (unlikely(pci_dma_mapping_error(mgp->pdev, dmatest_bus))) { in myri10ge_dma_test()
869 len = mgp->tx_boundary; in myri10ge_dma_test()
874 status = myri10ge_send_cmd(mgp, test_type, &cmd, 0); in myri10ge_dma_test()
879 mgp->read_dma = ((cmd.data0 >> 16) * len * 2) / (cmd.data0 & 0xffff); in myri10ge_dma_test()
883 status = myri10ge_send_cmd(mgp, test_type, &cmd, 0); in myri10ge_dma_test()
888 mgp->write_dma = ((cmd.data0 >> 16) * len * 2) / (cmd.data0 & 0xffff); in myri10ge_dma_test()
893 status = myri10ge_send_cmd(mgp, test_type, &cmd, 0); in myri10ge_dma_test()
898 mgp->read_write_dma = ((cmd.data0 >> 16) * len * 2 * 2) / in myri10ge_dma_test()
902 pci_unmap_page(mgp->pdev, dmatest_bus, PAGE_SIZE, DMA_BIDIRECTIONAL); in myri10ge_dma_test()
906 dev_warn(&mgp->pdev->dev, "DMA %s benchmark failed: %d\n", in myri10ge_dma_test()
912 static int myri10ge_reset(struct myri10ge_priv *mgp) in myri10ge_reset() argument
925 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_RESET, &cmd, 0); in myri10ge_reset()
927 dev_err(&mgp->pdev->dev, "failed reset\n"); in myri10ge_reset()
931 (void)myri10ge_dma_test(mgp, MXGEFW_DMA_TEST); in myri10ge_reset()
939 (void)myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_RSS_MCP_SLOT_TYPE, &cmd, 0); in myri10ge_reset()
943 bytes = mgp->max_intr_slots * sizeof(*mgp->ss[0].rx_done.entry); in myri10ge_reset()
945 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_INTRQ_SIZE, &cmd, 0); in myri10ge_reset()
958 if (mgp->num_slices > 1) { in myri10ge_reset()
961 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_MAX_RSS_QUEUES, in myri10ge_reset()
964 dev_err(&mgp->pdev->dev, in myri10ge_reset()
973 cmd.data0 = mgp->num_slices; in myri10ge_reset()
975 if (mgp->dev->real_num_tx_queues > 1) in myri10ge_reset()
977 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_ENABLE_RSS_QUEUES, in myri10ge_reset()
983 if (status != 0 && mgp->dev->real_num_tx_queues > 1) { in myri10ge_reset()
984 netif_set_real_num_tx_queues(mgp->dev, 1); in myri10ge_reset()
985 cmd.data0 = mgp->num_slices; in myri10ge_reset()
987 status = myri10ge_send_cmd(mgp, in myri10ge_reset()
993 dev_err(&mgp->pdev->dev, in myri10ge_reset()
999 for (i = 0; i < mgp->num_slices; i++) { in myri10ge_reset()
1000 ss = &mgp->ss[i]; in myri10ge_reset()
1004 status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_INTRQ_DMA, in myri10ge_reset()
1009 myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_IRQ_ACK_OFFSET, &cmd, 0); in myri10ge_reset()
1010 for (i = 0; i < mgp->num_slices; i++) { in myri10ge_reset()
1011 ss = &mgp->ss[i]; in myri10ge_reset()
1013 (__iomem __be32 *) (mgp->sram + cmd.data0 + 8 * i); in myri10ge_reset()
1015 status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_IRQ_DEASSERT_OFFSET, in myri10ge_reset()
1017 mgp->irq_deassert = (__iomem __be32 *) (mgp->sram + cmd.data0); in myri10ge_reset()
1020 (mgp, MXGEFW_CMD_GET_INTR_COAL_DELAY_OFFSET, &cmd, 0); in myri10ge_reset()
1021 mgp->intr_coal_delay_ptr = (__iomem __be32 *) (mgp->sram + cmd.data0); in myri10ge_reset()
1023 dev_err(&mgp->pdev->dev, "failed set interrupt parameters\n"); in myri10ge_reset()
1026 put_be32(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr); in myri10ge_reset()
1029 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_DCA_OFFSET, &cmd, 0); in myri10ge_reset()
1031 for (i = 0; i < mgp->num_slices; i++) { in myri10ge_reset()
1032 ss = &mgp->ss[i]; in myri10ge_reset()
1035 (mgp->sram + dca_tag_off + 4 * i); in myri10ge_reset()
1044 mgp->link_changes = 0; in myri10ge_reset()
1045 for (i = 0; i < mgp->num_slices; i++) { in myri10ge_reset()
1046 ss = &mgp->ss[i]; in myri10ge_reset()
1061 status = myri10ge_update_mac_address(mgp, mgp->dev->dev_addr); in myri10ge_reset()
1062 myri10ge_change_pause(mgp, mgp->pause); in myri10ge_reset()
1063 myri10ge_set_multicast_list(mgp->dev); in myri10ge_reset()
1097 tag = dca3_get_tag(&ss->mgp->pdev->dev, cpu); in myri10ge_update_dca()
1105 static void myri10ge_setup_dca(struct myri10ge_priv *mgp) in myri10ge_setup_dca() argument
1108 struct pci_dev *pdev = mgp->pdev; in myri10ge_setup_dca()
1110 if (mgp->ss[0].dca_tag == NULL || mgp->dca_enabled) in myri10ge_setup_dca()
1123 mgp->relaxed_order = myri10ge_toggle_relaxed(pdev, 0); in myri10ge_setup_dca()
1124 mgp->dca_enabled = 1; in myri10ge_setup_dca()
1125 for (i = 0; i < mgp->num_slices; i++) { in myri10ge_setup_dca()
1126 mgp->ss[i].cpu = -1; in myri10ge_setup_dca()
1127 mgp->ss[i].cached_dca_tag = -1; in myri10ge_setup_dca()
1128 myri10ge_update_dca(&mgp->ss[i]); in myri10ge_setup_dca()
1132 static void myri10ge_teardown_dca(struct myri10ge_priv *mgp) in myri10ge_teardown_dca() argument
1134 struct pci_dev *pdev = mgp->pdev; in myri10ge_teardown_dca()
1136 if (!mgp->dca_enabled) in myri10ge_teardown_dca()
1138 mgp->dca_enabled = 0; in myri10ge_teardown_dca()
1139 if (mgp->relaxed_order) in myri10ge_teardown_dca()
1146 struct myri10ge_priv *mgp; in myri10ge_notify_dca_device() local
1149 mgp = dev_get_drvdata(dev); in myri10ge_notify_dca_device()
1153 myri10ge_setup_dca(mgp); in myri10ge_notify_dca_device()
1155 myri10ge_teardown_dca(mgp); in myri10ge_notify_dca_device()
1190 myri10ge_alloc_rx_pages(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx, in myri10ge_alloc_rx_pages() argument
1220 bus = pci_map_page(mgp->pdev, page, 0, in myri10ge_alloc_rx_pages()
1223 if (unlikely(pci_dma_mapping_error(mgp->pdev, bus))) { in myri10ge_alloc_rx_pages()
1319 struct myri10ge_priv *mgp = ss->mgp; in myri10ge_rx_done() local
1324 struct pci_dev *pdev = mgp->pdev; in myri10ge_rx_done()
1325 struct net_device *dev = mgp->dev; in myri10ge_rx_done()
1328 if (len <= mgp->small_bytes) { in myri10ge_rx_done()
1330 bytes = mgp->small_bytes; in myri10ge_rx_done()
1333 bytes = mgp->big_bytes; in myri10ge_rx_done()
1378 myri10ge_vlan_rx(mgp->dev, va, skb); in myri10ge_rx_done()
1379 skb_record_rx_queue(skb, ss - &mgp->ss[0]); in myri10ge_rx_done()
1389 struct pci_dev *pdev = ss->mgp->pdev; in myri10ge_tx_done()
1426 dev_queue = netdev_get_tx_queue(ss->dev, ss - ss->mgp->ss); in myri10ge_tx_done()
1436 if ((ss->mgp->dev->real_num_tx_queues > 1) && in myri10ge_tx_done()
1449 ss->mgp->running == MYRI10GE_ETH_RUNNING) { in myri10ge_tx_done()
1459 struct myri10ge_priv *mgp = ss->mgp; in myri10ge_clean_rx_done() local
1477 idx = cnt & (mgp->max_intr_slots - 1); in myri10ge_clean_rx_done()
1487 myri10ge_alloc_rx_pages(mgp, &ss->rx_small, in myri10ge_clean_rx_done()
1488 mgp->small_bytes + MXGEFW_PAD, 0); in myri10ge_clean_rx_done()
1490 myri10ge_alloc_rx_pages(mgp, &ss->rx_big, mgp->big_bytes, 0); in myri10ge_clean_rx_done()
1495 static inline void myri10ge_check_statblock(struct myri10ge_priv *mgp) in myri10ge_check_statblock() argument
1497 struct mcp_irq_data *stats = mgp->ss[0].fw_stats; in myri10ge_check_statblock()
1501 if (mgp->link_state != link_up) { in myri10ge_check_statblock()
1502 mgp->link_state = link_up; in myri10ge_check_statblock()
1504 if (mgp->link_state == MXGEFW_LINK_UP) { in myri10ge_check_statblock()
1505 netif_info(mgp, link, mgp->dev, "link up\n"); in myri10ge_check_statblock()
1506 netif_carrier_on(mgp->dev); in myri10ge_check_statblock()
1507 mgp->link_changes++; in myri10ge_check_statblock()
1509 netif_info(mgp, link, mgp->dev, "link %s\n", in myri10ge_check_statblock()
1513 netif_carrier_off(mgp->dev); in myri10ge_check_statblock()
1514 mgp->link_changes++; in myri10ge_check_statblock()
1517 if (mgp->rdma_tags_available != in myri10ge_check_statblock()
1519 mgp->rdma_tags_available = in myri10ge_check_statblock()
1521 netdev_warn(mgp->dev, "RDMA timed out! %d tags left\n", in myri10ge_check_statblock()
1522 mgp->rdma_tags_available); in myri10ge_check_statblock()
1524 mgp->down_cnt += stats->link_down; in myri10ge_check_statblock()
1526 wake_up(&mgp->down_wq); in myri10ge_check_statblock()
1537 if (ss->mgp->dca_enabled) in myri10ge_poll()
1553 struct myri10ge_priv *mgp = ss->mgp; in myri10ge_intr() local
1561 if ((mgp->dev->real_num_tx_queues == 1) && (ss != mgp->ss)) { in myri10ge_intr()
1575 if (!mgp->msi_enabled && !mgp->msix_enabled) { in myri10ge_intr()
1576 put_be32(0, mgp->irq_deassert); in myri10ge_intr()
1592 netdev_warn(mgp->dev, "irq stuck?\n"); in myri10ge_intr()
1594 schedule_work(&mgp->watchdog_work); in myri10ge_intr()
1603 if (ss == mgp->ss) in myri10ge_intr()
1604 myri10ge_check_statblock(mgp); in myri10ge_intr()
1614 struct myri10ge_priv *mgp = netdev_priv(netdev); in myri10ge_get_link_ksettings() local
1628 ptr = mgp->product_code_string; in myri10ge_get_link_ksettings()
1637 mgp->product_code_string); in myri10ge_get_link_ksettings()
1658 struct myri10ge_priv *mgp = netdev_priv(netdev); in myri10ge_get_drvinfo() local
1662 strlcpy(info->fw_version, mgp->fw_version, sizeof(info->fw_version)); in myri10ge_get_drvinfo()
1663 strlcpy(info->bus_info, pci_name(mgp->pdev), sizeof(info->bus_info)); in myri10ge_get_drvinfo()
1669 struct myri10ge_priv *mgp = netdev_priv(netdev); in myri10ge_get_coalesce() local
1671 coal->rx_coalesce_usecs = mgp->intr_coal_delay; in myri10ge_get_coalesce()
1678 struct myri10ge_priv *mgp = netdev_priv(netdev); in myri10ge_set_coalesce() local
1680 mgp->intr_coal_delay = coal->rx_coalesce_usecs; in myri10ge_set_coalesce()
1681 put_be32(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr); in myri10ge_set_coalesce()
1689 struct myri10ge_priv *mgp = netdev_priv(netdev); in myri10ge_get_pauseparam() local
1692 pause->rx_pause = mgp->pause; in myri10ge_get_pauseparam()
1693 pause->tx_pause = mgp->pause; in myri10ge_get_pauseparam()
1700 struct myri10ge_priv *mgp = netdev_priv(netdev); in myri10ge_set_pauseparam() local
1702 if (pause->tx_pause != mgp->pause) in myri10ge_set_pauseparam()
1703 return myri10ge_change_pause(mgp, pause->tx_pause); in myri10ge_set_pauseparam()
1704 if (pause->rx_pause != mgp->pause) in myri10ge_set_pauseparam()
1705 return myri10ge_change_pause(mgp, pause->rx_pause); in myri10ge_set_pauseparam()
1715 struct myri10ge_priv *mgp = netdev_priv(netdev); in myri10ge_get_ringparam() local
1717 ring->rx_mini_max_pending = mgp->ss[0].rx_small.mask + 1; in myri10ge_get_ringparam()
1718 ring->rx_max_pending = mgp->ss[0].rx_big.mask + 1; in myri10ge_get_ringparam()
1720 ring->tx_max_pending = mgp->ss[0].tx.mask + 1; in myri10ge_get_ringparam()
1763 struct myri10ge_priv *mgp = netdev_priv(netdev); in myri10ge_get_strings() local
1771 for (i = 0; i < mgp->num_slices; i++) { in myri10ge_get_strings()
1782 struct myri10ge_priv *mgp = netdev_priv(netdev); in myri10ge_get_sset_count() local
1787 mgp->num_slices * MYRI10GE_SLICE_STATS_LEN; in myri10ge_get_sset_count()
1797 struct myri10ge_priv *mgp = netdev_priv(netdev); in myri10ge_get_ethtool_stats() local
1809 data[i++] = (unsigned int)mgp->tx_boundary; in myri10ge_get_ethtool_stats()
1810 data[i++] = (unsigned int)mgp->pdev->irq; in myri10ge_get_ethtool_stats()
1811 data[i++] = (unsigned int)mgp->msi_enabled; in myri10ge_get_ethtool_stats()
1812 data[i++] = (unsigned int)mgp->msix_enabled; in myri10ge_get_ethtool_stats()
1813 data[i++] = (unsigned int)mgp->read_dma; in myri10ge_get_ethtool_stats()
1814 data[i++] = (unsigned int)mgp->write_dma; in myri10ge_get_ethtool_stats()
1815 data[i++] = (unsigned int)mgp->read_write_dma; in myri10ge_get_ethtool_stats()
1816 data[i++] = (unsigned int)mgp->serial_number; in myri10ge_get_ethtool_stats()
1817 data[i++] = (unsigned int)mgp->watchdog_resets; in myri10ge_get_ethtool_stats()
1819 data[i++] = (unsigned int)(mgp->ss[0].dca_tag != NULL); in myri10ge_get_ethtool_stats()
1820 data[i++] = (unsigned int)(mgp->dca_enabled); in myri10ge_get_ethtool_stats()
1822 data[i++] = (unsigned int)mgp->link_changes; in myri10ge_get_ethtool_stats()
1825 ss = &mgp->ss[0]; in myri10ge_get_ethtool_stats()
1841 for (slice = 0; slice < mgp->num_slices; slice++) { in myri10ge_get_ethtool_stats()
1842 ss = &mgp->ss[slice]; in myri10ge_get_ethtool_stats()
1858 struct myri10ge_priv *mgp = netdev_priv(netdev); in myri10ge_set_msglevel() local
1859 mgp->msg_enable = value; in myri10ge_set_msglevel()
1864 struct myri10ge_priv *mgp = netdev_priv(netdev); in myri10ge_get_msglevel() local
1865 return mgp->msg_enable; in myri10ge_get_msglevel()
1873 static int myri10ge_led(struct myri10ge_priv *mgp, int on) in myri10ge_led() argument
1876 struct device *dev = &mgp->pdev->dev; in myri10ge_led()
1881 hdr_off = swab32(readl(mgp->sram + MCP_HEADER_PTR_OFFSET)); in myri10ge_led()
1882 if ((hdr_off & 3) || hdr_off + sizeof(*hdr) > mgp->sram_size) { in myri10ge_led()
1887 hdr_len = swab32(readl(mgp->sram + hdr_off + in myri10ge_led()
1895 pattern = swab32(readl(mgp->sram + pattern_off + 4)); in myri10ge_led()
1896 writel(swab32(pattern), mgp->sram + pattern_off); in myri10ge_led()
1903 struct myri10ge_priv *mgp = netdev_priv(netdev); in myri10ge_phys_id() local
1908 rc = myri10ge_led(mgp, 1); in myri10ge_phys_id()
1912 rc = myri10ge_led(mgp, 0); in myri10ge_phys_id()
1941 struct myri10ge_priv *mgp = ss->mgp; in myri10ge_allocate_rings() local
1943 struct net_device *dev = mgp->dev; in myri10ge_allocate_rings()
1950 slice = ss - mgp->ss; in myri10ge_allocate_rings()
1952 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_SEND_RING_SIZE, &cmd, 0); in myri10ge_allocate_rings()
1955 status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_RX_RING_SIZE, &cmd, 0); in myri10ge_allocate_rings()
2016 if (mgp->small_bytes == 0) { in myri10ge_allocate_rings()
2019 myri10ge_alloc_rx_pages(mgp, &ss->rx_small, in myri10ge_allocate_rings()
2020 mgp->small_bytes + MXGEFW_PAD, 0); in myri10ge_allocate_rings()
2029 myri10ge_alloc_rx_pages(mgp, &ss->rx_big, mgp->big_bytes, 0); in myri10ge_allocate_rings()
2041 myri10ge_unmap_rx_page(mgp->pdev, &ss->rx_big.info[idx], in myri10ge_allocate_rings()
2042 mgp->big_bytes); in myri10ge_allocate_rings()
2047 if (mgp->small_bytes == 0) in myri10ge_allocate_rings()
2051 myri10ge_unmap_rx_page(mgp->pdev, &ss->rx_small.info[idx], in myri10ge_allocate_rings()
2052 mgp->small_bytes + MXGEFW_PAD); in myri10ge_allocate_rings()
2081 struct myri10ge_priv *mgp = ss->mgp; in myri10ge_free_rings() local
2094 myri10ge_unmap_rx_page(mgp->pdev, &ss->rx_big.info[idx], in myri10ge_free_rings()
2095 mgp->big_bytes); in myri10ge_free_rings()
2099 if (mgp->small_bytes == 0) in myri10ge_free_rings()
2106 myri10ge_unmap_rx_page(mgp->pdev, &ss->rx_small.info[idx], in myri10ge_free_rings()
2107 mgp->small_bytes + MXGEFW_PAD); in myri10ge_free_rings()
2124 pci_unmap_single(mgp->pdev, in myri10ge_free_rings()
2130 pci_unmap_page(mgp->pdev, in myri10ge_free_rings()
2151 static int myri10ge_request_irq(struct myri10ge_priv *mgp) in myri10ge_request_irq() argument
2153 struct pci_dev *pdev = mgp->pdev; in myri10ge_request_irq()
2155 struct net_device *netdev = mgp->dev; in myri10ge_request_irq()
2159 mgp->msi_enabled = 0; in myri10ge_request_irq()
2160 mgp->msix_enabled = 0; in myri10ge_request_irq()
2163 if (mgp->num_slices > 1) { in myri10ge_request_irq()
2164 status = pci_enable_msix_range(pdev, mgp->msix_vectors, in myri10ge_request_irq()
2165 mgp->num_slices, mgp->num_slices); in myri10ge_request_irq()
2171 mgp->msix_enabled = 1; in myri10ge_request_irq()
2173 if (mgp->msix_enabled == 0) { in myri10ge_request_irq()
2180 mgp->msi_enabled = 1; in myri10ge_request_irq()
2184 if (mgp->msix_enabled) { in myri10ge_request_irq()
2185 for (i = 0; i < mgp->num_slices; i++) { in myri10ge_request_irq()
2186 ss = &mgp->ss[i]; in myri10ge_request_irq()
2189 status = request_irq(mgp->msix_vectors[i].vector, in myri10ge_request_irq()
2197 free_irq(mgp->msix_vectors[i].vector, in myri10ge_request_irq()
2198 &mgp->ss[i]); in myri10ge_request_irq()
2207 mgp->dev->name, &mgp->ss[0]); in myri10ge_request_irq()
2210 if (mgp->msi_enabled) in myri10ge_request_irq()
2217 static void myri10ge_free_irq(struct myri10ge_priv *mgp) in myri10ge_free_irq() argument
2219 struct pci_dev *pdev = mgp->pdev; in myri10ge_free_irq()
2222 if (mgp->msix_enabled) { in myri10ge_free_irq()
2223 for (i = 0; i < mgp->num_slices; i++) in myri10ge_free_irq()
2224 free_irq(mgp->msix_vectors[i].vector, &mgp->ss[i]); in myri10ge_free_irq()
2226 free_irq(pdev->irq, &mgp->ss[0]); in myri10ge_free_irq()
2228 if (mgp->msi_enabled) in myri10ge_free_irq()
2230 if (mgp->msix_enabled) in myri10ge_free_irq()
2234 static int myri10ge_get_txrx(struct myri10ge_priv *mgp, int slice) in myri10ge_get_txrx() argument
2240 ss = &mgp->ss[slice]; in myri10ge_get_txrx()
2242 if (slice == 0 || (mgp->dev->real_num_tx_queues > 1)) { in myri10ge_get_txrx()
2244 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_SEND_OFFSET, in myri10ge_get_txrx()
2247 (mgp->sram + cmd.data0); in myri10ge_get_txrx()
2250 status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_SMALL_RX_OFFSET, in myri10ge_get_txrx()
2253 (mgp->sram + cmd.data0); in myri10ge_get_txrx()
2256 status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_BIG_RX_OFFSET, &cmd, 0); in myri10ge_get_txrx()
2258 (mgp->sram + cmd.data0); in myri10ge_get_txrx()
2261 (mgp->sram + MXGEFW_ETH_SEND_GO + 64 * slice); in myri10ge_get_txrx()
2263 (mgp->sram + MXGEFW_ETH_SEND_STOP + 64 * slice); in myri10ge_get_txrx()
2268 static int myri10ge_set_stats(struct myri10ge_priv *mgp, int slice) in myri10ge_set_stats() argument
2274 ss = &mgp->ss[slice]; in myri10ge_set_stats()
2278 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_STATS_DMA_V2, &cmd, 0); in myri10ge_set_stats()
2286 status = myri10ge_send_cmd(mgp, in myri10ge_set_stats()
2290 mgp->fw_multicast_support = 0; in myri10ge_set_stats()
2292 mgp->fw_multicast_support = 1; in myri10ge_set_stats()
2300 struct myri10ge_priv *mgp = netdev_priv(dev); in myri10ge_open() local
2305 if (mgp->running != MYRI10GE_ETH_STOPPED) in myri10ge_open()
2308 mgp->running = MYRI10GE_ETH_STARTING; in myri10ge_open()
2309 status = myri10ge_reset(mgp); in myri10ge_open()
2315 if (mgp->num_slices > 1) { in myri10ge_open()
2316 cmd.data0 = mgp->num_slices; in myri10ge_open()
2318 if (mgp->dev->real_num_tx_queues > 1) in myri10ge_open()
2320 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_ENABLE_RSS_QUEUES, in myri10ge_open()
2327 cmd.data0 = mgp->num_slices; in myri10ge_open()
2328 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_RSS_TABLE_SIZE, in myri10ge_open()
2331 status |= myri10ge_send_cmd(mgp, in myri10ge_open()
2340 itable = mgp->sram + cmd.data0; in myri10ge_open()
2341 for (i = 0; i < mgp->num_slices; i++) in myri10ge_open()
2346 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_RSS_ENABLE, in myri10ge_open()
2354 status = myri10ge_request_irq(mgp); in myri10ge_open()
2366 mgp->small_bytes = (128 > SMP_CACHE_BYTES) in myri10ge_open()
2371 mgp->small_bytes = VLAN_ETH_FRAME_LEN; in myri10ge_open()
2375 mgp->small_bytes = myri10ge_small_bytes; in myri10ge_open()
2385 mgp->big_bytes = dev->mtu + ETH_HLEN + VLAN_HLEN + MXGEFW_PAD; in myri10ge_open()
2388 mgp->big_bytes = big_pow2; in myri10ge_open()
2392 for (slice = 0; slice < mgp->num_slices; slice++) { in myri10ge_open()
2393 ss = &mgp->ss[slice]; in myri10ge_open()
2395 status = myri10ge_get_txrx(mgp, slice); in myri10ge_open()
2407 if (slice == 0 || mgp->dev->real_num_tx_queues > 1) in myri10ge_open()
2408 status = myri10ge_set_stats(mgp, slice); in myri10ge_open()
2420 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_MTU, &cmd, 0); in myri10ge_open()
2421 cmd.data0 = mgp->small_bytes; in myri10ge_open()
2423 myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_SMALL_BUFFER_SIZE, &cmd, 0); in myri10ge_open()
2426 myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_BIG_BUFFER_SIZE, &cmd, 0); in myri10ge_open()
2438 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_TSO_MODE, &cmd, 0); in myri10ge_open()
2444 mgp->link_state = ~0U; in myri10ge_open()
2445 mgp->rdma_tags_available = 15; in myri10ge_open()
2447 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_ETHERNET_UP, &cmd, 0); in myri10ge_open()
2453 mgp->running = MYRI10GE_ETH_RUNNING; in myri10ge_open()
2454 mgp->watchdog_timer.expires = jiffies + myri10ge_watchdog_timeout * HZ; in myri10ge_open()
2455 add_timer(&mgp->watchdog_timer); in myri10ge_open()
2463 napi_disable(&mgp->ss[slice].napi); in myri10ge_open()
2465 for (i = 0; i < mgp->num_slices; i++) in myri10ge_open()
2466 myri10ge_free_rings(&mgp->ss[i]); in myri10ge_open()
2468 myri10ge_free_irq(mgp); in myri10ge_open()
2471 mgp->running = MYRI10GE_ETH_STOPPED; in myri10ge_open()
2477 struct myri10ge_priv *mgp = netdev_priv(dev); in myri10ge_close() local
2482 if (mgp->running != MYRI10GE_ETH_RUNNING) in myri10ge_close()
2485 if (mgp->ss[0].tx.req_bytes == NULL) in myri10ge_close()
2488 del_timer_sync(&mgp->watchdog_timer); in myri10ge_close()
2489 mgp->running = MYRI10GE_ETH_STOPPING; in myri10ge_close()
2490 for (i = 0; i < mgp->num_slices; i++) in myri10ge_close()
2491 napi_disable(&mgp->ss[i].napi); in myri10ge_close()
2496 if (mgp->rebooted == 0) { in myri10ge_close()
2497 old_down_cnt = mgp->down_cnt; in myri10ge_close()
2500 myri10ge_send_cmd(mgp, MXGEFW_CMD_ETHERNET_DOWN, &cmd, 0); in myri10ge_close()
2504 wait_event_timeout(mgp->down_wq, old_down_cnt != mgp->down_cnt, in myri10ge_close()
2506 if (old_down_cnt == mgp->down_cnt) in myri10ge_close()
2510 myri10ge_free_irq(mgp); in myri10ge_close()
2511 for (i = 0; i < mgp->num_slices; i++) in myri10ge_close()
2512 myri10ge_free_rings(&mgp->ss[i]); in myri10ge_close()
2514 mgp->running = MYRI10GE_ETH_STOPPED; in myri10ge_close()
2585 static void myri10ge_unmap_tx_dma(struct myri10ge_priv *mgp, in myri10ge_unmap_tx_dma() argument
2598 pci_unmap_single(mgp->pdev, in myri10ge_unmap_tx_dma()
2603 pci_unmap_page(mgp->pdev, in myri10ge_unmap_tx_dma()
2627 struct myri10ge_priv *mgp = netdev_priv(dev); in myri10ge_xmit() local
2643 ss = &mgp->ss[queue]; in myri10ge_xmit()
2644 netdev_queue = netdev_get_tx_queue(mgp->dev, queue); in myri10ge_xmit()
2706 if (unlikely(-cum_len > mgp->max_tso6)) in myri10ge_xmit()
2729 bus = pci_map_single(mgp->pdev, skb->data, len, PCI_DMA_TODEVICE); in myri10ge_xmit()
2730 if (unlikely(pci_dma_mapping_error(mgp->pdev, bus))) in myri10ge_xmit()
2774 (low + mgp->tx_boundary) & ~(mgp->tx_boundary - 1); in myri10ge_xmit()
2836 bus = skb_frag_dma_map(&mgp->pdev->dev, frag, 0, len, in myri10ge_xmit()
2838 if (unlikely(pci_dma_mapping_error(mgp->pdev, bus))) { in myri10ge_xmit()
2839 myri10ge_unmap_tx_dma(mgp, tx, idx); in myri10ge_xmit()
2859 if ((mgp->dev->real_num_tx_queues > 1) && tx->queue_active == 0) { in myri10ge_xmit()
2872 myri10ge_unmap_tx_dma(mgp, tx, idx); in myri10ge_xmit()
2875 netdev_err(mgp->dev, "TSO but wanted to linearize?!?!?\n"); in myri10ge_xmit()
2896 struct myri10ge_priv *mgp = netdev_priv(dev); in myri10ge_sw_tso() local
2924 ss = &mgp->ss[skb_get_queue_mapping(skb)]; in myri10ge_sw_tso()
2933 const struct myri10ge_priv *mgp = netdev_priv(dev); in myri10ge_get_stats() local
2937 for (i = 0; i < mgp->num_slices; i++) { in myri10ge_get_stats()
2938 slice_stats = &mgp->ss[i].stats; in myri10ge_get_stats()
2950 struct myri10ge_priv *mgp = netdev_priv(dev); in myri10ge_set_multicast_list() local
2958 myri10ge_change_promisc(mgp, dev->flags & IFF_PROMISC, 1); in myri10ge_set_multicast_list()
2961 if (!mgp->fw_multicast_support) in myri10ge_set_multicast_list()
2966 err = myri10ge_send_cmd(mgp, MXGEFW_ENABLE_ALLMULTI, &cmd, 1); in myri10ge_set_multicast_list()
2973 if ((dev->flags & IFF_ALLMULTI) || mgp->adopted_rx_filter_bug) { in myri10ge_set_multicast_list()
2980 err = myri10ge_send_cmd(mgp, MXGEFW_LEAVE_ALL_MULTICAST_GROUPS, in myri10ge_set_multicast_list()
2993 err = myri10ge_send_cmd(mgp, MXGEFW_JOIN_MULTICAST_GROUP, in myri10ge_set_multicast_list()
3003 err = myri10ge_send_cmd(mgp, MXGEFW_DISABLE_ALLMULTI, &cmd, 1); in myri10ge_set_multicast_list()
3019 struct myri10ge_priv *mgp = netdev_priv(dev); in myri10ge_set_mac_address() local
3025 status = myri10ge_update_mac_address(mgp, sa->sa_data); in myri10ge_set_mac_address()
3039 struct myri10ge_priv *mgp = netdev_priv(dev); in myri10ge_change_mtu() local
3042 if (mgp->running) { in myri10ge_change_mtu()
3060 static void myri10ge_enable_ecrc(struct myri10ge_priv *mgp) in myri10ge_enable_ecrc() argument
3062 struct pci_dev *bridge = mgp->pdev->bus->self; in myri10ge_enable_ecrc()
3063 struct device *dev = &mgp->pdev->dev; in myri10ge_enable_ecrc()
3141 static void myri10ge_firmware_probe(struct myri10ge_priv *mgp) in myri10ge_firmware_probe() argument
3143 struct pci_dev *pdev = mgp->pdev; in myri10ge_firmware_probe()
3147 mgp->tx_boundary = 4096; in myri10ge_firmware_probe()
3159 mgp->tx_boundary = 2048; in myri10ge_firmware_probe()
3165 set_fw_name(mgp, myri10ge_fw_aligned, false); in myri10ge_firmware_probe()
3166 status = myri10ge_load_firmware(mgp, 1); in myri10ge_firmware_probe()
3174 myri10ge_enable_ecrc(mgp); in myri10ge_firmware_probe()
3181 status = myri10ge_dma_test(mgp, MXGEFW_CMD_UNALIGNED_TEST); in myri10ge_firmware_probe()
3192 mgp->tx_boundary = 2048; in myri10ge_firmware_probe()
3193 set_fw_name(mgp, myri10ge_fw_unaligned, false); in myri10ge_firmware_probe()
3196 static void myri10ge_select_firmware(struct myri10ge_priv *mgp) in myri10ge_select_firmware() argument
3204 pcie_capability_read_word(mgp->pdev, PCI_EXP_LNKSTA, &lnk); in myri10ge_select_firmware()
3211 dev_info(&mgp->pdev->dev, "PCIE x%d Link\n", in myri10ge_select_firmware()
3213 mgp->tx_boundary = 4096; in myri10ge_select_firmware()
3214 set_fw_name(mgp, myri10ge_fw_aligned, false); in myri10ge_select_firmware()
3216 myri10ge_firmware_probe(mgp); in myri10ge_select_firmware()
3220 dev_info(&mgp->pdev->dev, in myri10ge_select_firmware()
3222 mgp->tx_boundary = 4096; in myri10ge_select_firmware()
3223 set_fw_name(mgp, myri10ge_fw_aligned, false); in myri10ge_select_firmware()
3225 dev_info(&mgp->pdev->dev, in myri10ge_select_firmware()
3227 mgp->tx_boundary = 2048; in myri10ge_select_firmware()
3228 set_fw_name(mgp, myri10ge_fw_unaligned, false); in myri10ge_select_firmware()
3237 set_fw_name(mgp, fw_name, true); in myri10ge_select_firmware()
3242 if (mgp->board_number < MYRI10GE_MAX_BOARDS && in myri10ge_select_firmware()
3243 myri10ge_fw_names[mgp->board_number] != NULL && in myri10ge_select_firmware()
3244 strlen(myri10ge_fw_names[mgp->board_number])) { in myri10ge_select_firmware()
3245 set_fw_name(mgp, myri10ge_fw_names[mgp->board_number], false); in myri10ge_select_firmware()
3249 dev_info(&mgp->pdev->dev, "overriding firmware to %s\n", in myri10ge_select_firmware()
3250 mgp->fw_name); in myri10ge_select_firmware()
3276 struct myri10ge_priv *mgp; in myri10ge_suspend() local
3279 mgp = pci_get_drvdata(pdev); in myri10ge_suspend()
3280 if (mgp == NULL) in myri10ge_suspend()
3282 netdev = mgp->dev; in myri10ge_suspend()
3291 myri10ge_dummy_rdma(mgp, 0); in myri10ge_suspend()
3300 struct myri10ge_priv *mgp; in myri10ge_resume() local
3305 mgp = pci_get_drvdata(pdev); in myri10ge_resume()
3306 if (mgp == NULL) in myri10ge_resume()
3308 netdev = mgp->dev; in myri10ge_resume()
3311 pci_read_config_word(mgp->pdev, PCI_VENDOR_ID, &vendor); in myri10ge_resume()
3313 netdev_err(mgp->dev, "device disappeared!\n"); in myri10ge_resume()
3327 myri10ge_reset(mgp); in myri10ge_resume()
3328 myri10ge_dummy_rdma(mgp, 1); in myri10ge_resume()
3353 static u32 myri10ge_read_reboot(struct myri10ge_priv *mgp) in myri10ge_read_reboot() argument
3355 struct pci_dev *pdev = mgp->pdev; in myri10ge_read_reboot()
3356 int vs = mgp->vendor_specific_offset; in myri10ge_read_reboot()
3372 struct myri10ge_priv *mgp = ss->mgp; in myri10ge_check_slice() local
3373 int slice = ss - mgp->ss; in myri10ge_check_slice()
3379 if (rx_pause_cnt != mgp->watchdog_pause) { in myri10ge_check_slice()
3381 netdev_warn(mgp->dev, "slice %d: TX paused, " in myri10ge_check_slice()
3384 netdev_warn(mgp->dev, in myri10ge_check_slice()
3389 (int)ntohl(mgp->ss[slice].fw_stats-> in myri10ge_check_slice()
3410 struct myri10ge_priv *mgp = in myri10ge_watchdog() local
3420 mgp->watchdog_resets++; in myri10ge_watchdog()
3421 pci_read_config_word(mgp->pdev, PCI_COMMAND, &cmd); in myri10ge_watchdog()
3427 reboot = myri10ge_read_reboot(mgp); in myri10ge_watchdog()
3428 netdev_err(mgp->dev, "NIC rebooted (0x%x),%s resetting\n", in myri10ge_watchdog()
3433 mgp->rebooted = 1; in myri10ge_watchdog()
3435 myri10ge_close(mgp->dev); in myri10ge_watchdog()
3437 mgp->rebooted = 0; in myri10ge_watchdog()
3445 pci_restore_state(mgp->pdev); in myri10ge_watchdog()
3448 pci_save_state(mgp->pdev); in myri10ge_watchdog()
3455 pci_read_config_word(mgp->pdev, PCI_VENDOR_ID, &vendor); in myri10ge_watchdog()
3457 netdev_err(mgp->dev, "device disappeared!\n"); in myri10ge_watchdog()
3463 rx_pause_cnt = ntohl(mgp->ss[0].fw_stats->dropped_pause); in myri10ge_watchdog()
3464 for (i = 0; i < mgp->num_slices; i++) { in myri10ge_watchdog()
3465 ss = mgp->ss; in myri10ge_watchdog()
3474 netdev_dbg(mgp->dev, "not resetting\n"); in myri10ge_watchdog()
3478 netdev_err(mgp->dev, "device timeout, resetting\n"); in myri10ge_watchdog()
3483 myri10ge_close(mgp->dev); in myri10ge_watchdog()
3485 status = myri10ge_load_firmware(mgp, 1); in myri10ge_watchdog()
3487 netdev_err(mgp->dev, "failed to load firmware\n"); in myri10ge_watchdog()
3489 myri10ge_open(mgp->dev); in myri10ge_watchdog()
3502 struct myri10ge_priv *mgp; in myri10ge_watchdog_timer() local
3508 mgp = from_timer(mgp, t, watchdog_timer); in myri10ge_watchdog_timer()
3510 rx_pause_cnt = ntohl(mgp->ss[0].fw_stats->dropped_pause); in myri10ge_watchdog_timer()
3513 i < mgp->num_slices && reset_needed == 0; ++i) { in myri10ge_watchdog_timer()
3515 ss = &mgp->ss[i]; in myri10ge_watchdog_timer()
3517 myri10ge_alloc_rx_pages(mgp, &ss->rx_small, in myri10ge_watchdog_timer()
3518 mgp->small_bytes + MXGEFW_PAD, in myri10ge_watchdog_timer()
3525 myri10ge_alloc_rx_pages(mgp, &ss->rx_big, in myri10ge_watchdog_timer()
3526 mgp->big_bytes, 1); in myri10ge_watchdog_timer()
3538 pci_read_config_word(mgp->pdev, PCI_COMMAND, &cmd); in myri10ge_watchdog_timer()
3543 mgp->watchdog_pause = rx_pause_cnt; in myri10ge_watchdog_timer()
3546 schedule_work(&mgp->watchdog_work); in myri10ge_watchdog_timer()
3549 mod_timer(&mgp->watchdog_timer, in myri10ge_watchdog_timer()
3554 static void myri10ge_free_slices(struct myri10ge_priv *mgp) in myri10ge_free_slices() argument
3557 struct pci_dev *pdev = mgp->pdev; in myri10ge_free_slices()
3561 if (mgp->ss == NULL) in myri10ge_free_slices()
3564 for (i = 0; i < mgp->num_slices; i++) { in myri10ge_free_slices()
3565 ss = &mgp->ss[i]; in myri10ge_free_slices()
3567 bytes = mgp->max_intr_slots * in myri10ge_free_slices()
3584 kfree(mgp->ss); in myri10ge_free_slices()
3585 mgp->ss = NULL; in myri10ge_free_slices()
3588 static int myri10ge_alloc_slices(struct myri10ge_priv *mgp) in myri10ge_alloc_slices() argument
3591 struct pci_dev *pdev = mgp->pdev; in myri10ge_alloc_slices()
3595 bytes = sizeof(*mgp->ss) * mgp->num_slices; in myri10ge_alloc_slices()
3596 mgp->ss = kzalloc(bytes, GFP_KERNEL); in myri10ge_alloc_slices()
3597 if (mgp->ss == NULL) { in myri10ge_alloc_slices()
3601 for (i = 0; i < mgp->num_slices; i++) { in myri10ge_alloc_slices()
3602 ss = &mgp->ss[i]; in myri10ge_alloc_slices()
3603 bytes = mgp->max_intr_slots * sizeof(*ss->rx_done.entry); in myri10ge_alloc_slices()
3615 ss->mgp = mgp; in myri10ge_alloc_slices()
3616 ss->dev = mgp->dev; in myri10ge_alloc_slices()
3622 myri10ge_free_slices(mgp); in myri10ge_alloc_slices()
3632 static void myri10ge_probe_slices(struct myri10ge_priv *mgp) in myri10ge_probe_slices() argument
3635 struct pci_dev *pdev = mgp->pdev; in myri10ge_probe_slices()
3640 mgp->num_slices = 1; in myri10ge_probe_slices()
3648 old_fw = mgp->fw_name; in myri10ge_probe_slices()
3649 old_allocated = mgp->fw_name_allocated; in myri10ge_probe_slices()
3651 mgp->fw_name_allocated = false; in myri10ge_probe_slices()
3654 dev_info(&mgp->pdev->dev, "overriding rss firmware to %s\n", in myri10ge_probe_slices()
3656 set_fw_name(mgp, myri10ge_fw_name, false); in myri10ge_probe_slices()
3658 set_fw_name(mgp, myri10ge_fw_rss_aligned, false); in myri10ge_probe_slices()
3660 set_fw_name(mgp, myri10ge_fw_rss_unaligned, false); in myri10ge_probe_slices()
3661 status = myri10ge_load_firmware(mgp, 0); in myri10ge_probe_slices()
3671 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_RESET, &cmd, 0); in myri10ge_probe_slices()
3673 dev_err(&mgp->pdev->dev, "failed reset\n"); in myri10ge_probe_slices()
3677 mgp->max_intr_slots = cmd.data0 / sizeof(struct mcp_slot); in myri10ge_probe_slices()
3680 cmd.data0 = mgp->max_intr_slots * sizeof(struct mcp_slot); in myri10ge_probe_slices()
3681 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_INTRQ_SIZE, &cmd, 0); in myri10ge_probe_slices()
3683 dev_err(&mgp->pdev->dev, "failed MXGEFW_CMD_SET_INTRQ_SIZE\n"); in myri10ge_probe_slices()
3688 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_MAX_RSS_QUEUES, &cmd, 0); in myri10ge_probe_slices()
3692 mgp->num_slices = cmd.data0; in myri10ge_probe_slices()
3705 if (mgp->num_slices > myri10ge_max_slices) in myri10ge_probe_slices()
3706 mgp->num_slices = myri10ge_max_slices; in myri10ge_probe_slices()
3712 mgp->msix_vectors = kcalloc(mgp->num_slices, sizeof(*mgp->msix_vectors), in myri10ge_probe_slices()
3714 if (mgp->msix_vectors == NULL) in myri10ge_probe_slices()
3716 for (i = 0; i < mgp->num_slices; i++) { in myri10ge_probe_slices()
3717 mgp->msix_vectors[i].entry = i; in myri10ge_probe_slices()
3720 while (mgp->num_slices > 1) { in myri10ge_probe_slices()
3721 mgp->num_slices = rounddown_pow_of_two(mgp->num_slices); in myri10ge_probe_slices()
3722 if (mgp->num_slices == 1) in myri10ge_probe_slices()
3725 mgp->msix_vectors, in myri10ge_probe_slices()
3726 mgp->num_slices, in myri10ge_probe_slices()
3727 mgp->num_slices); in myri10ge_probe_slices()
3733 if (status == mgp->num_slices) { in myri10ge_probe_slices()
3738 mgp->num_slices = status; in myri10ge_probe_slices()
3743 if (mgp->msix_vectors != NULL) { in myri10ge_probe_slices()
3744 kfree(mgp->msix_vectors); in myri10ge_probe_slices()
3745 mgp->msix_vectors = NULL; in myri10ge_probe_slices()
3749 mgp->num_slices = 1; in myri10ge_probe_slices()
3750 set_fw_name(mgp, old_fw, old_allocated); in myri10ge_probe_slices()
3751 myri10ge_load_firmware(mgp, 0); in myri10ge_probe_slices()
3768 struct myri10ge_priv *mgp; in myri10ge_probe() local
3776 netdev = alloc_etherdev_mq(sizeof(*mgp), MYRI10GE_MAX_SLICES); in myri10ge_probe()
3782 mgp = netdev_priv(netdev); in myri10ge_probe()
3783 mgp->dev = netdev; in myri10ge_probe()
3784 mgp->pdev = pdev; in myri10ge_probe()
3785 mgp->pause = myri10ge_flow_control; in myri10ge_probe()
3786 mgp->intr_coal_delay = myri10ge_intr_coal_delay; in myri10ge_probe()
3787 mgp->msg_enable = netif_msg_init(myri10ge_debug, MYRI10GE_MSG_DEFAULT); in myri10ge_probe()
3788 mgp->board_number = board_number; in myri10ge_probe()
3789 init_waitqueue_head(&mgp->down_wq); in myri10ge_probe()
3799 mgp->vendor_specific_offset in myri10ge_probe()
3826 mgp->cmd = dma_alloc_coherent(&pdev->dev, sizeof(*mgp->cmd), in myri10ge_probe()
3827 &mgp->cmd_bus, GFP_KERNEL); in myri10ge_probe()
3828 if (!mgp->cmd) { in myri10ge_probe()
3833 mgp->board_span = pci_resource_len(pdev, 0); in myri10ge_probe()
3834 mgp->iomem_base = pci_resource_start(pdev, 0); in myri10ge_probe()
3835 mgp->wc_cookie = arch_phys_wc_add(mgp->iomem_base, mgp->board_span); in myri10ge_probe()
3836 mgp->sram = ioremap_wc(mgp->iomem_base, mgp->board_span); in myri10ge_probe()
3837 if (mgp->sram == NULL) { in myri10ge_probe()
3839 mgp->board_span, mgp->iomem_base); in myri10ge_probe()
3844 swab32(readl(mgp->sram + MCP_HEADER_PTR_OFFSET)) & 0xffffc; in myri10ge_probe()
3846 mgp->sram_size = swab32(readl(mgp->sram + ss_offset)); in myri10ge_probe()
3847 if (mgp->sram_size > mgp->board_span || in myri10ge_probe()
3848 mgp->sram_size <= MYRI10GE_FW_OFFSET) { in myri10ge_probe()
3851 mgp->sram_size, mgp->board_span); in myri10ge_probe()
3854 memcpy_fromio(mgp->eeprom_strings, in myri10ge_probe()
3855 mgp->sram + mgp->sram_size, MYRI10GE_EEPROM_STRINGS_SIZE); in myri10ge_probe()
3856 memset(mgp->eeprom_strings + MYRI10GE_EEPROM_STRINGS_SIZE - 2, 0, 2); in myri10ge_probe()
3857 status = myri10ge_read_mac_addr(mgp); in myri10ge_probe()
3862 netdev->dev_addr[i] = mgp->mac_addr[i]; in myri10ge_probe()
3864 myri10ge_select_firmware(mgp); in myri10ge_probe()
3866 status = myri10ge_load_firmware(mgp, 1); in myri10ge_probe()
3871 myri10ge_probe_slices(mgp); in myri10ge_probe()
3872 status = myri10ge_alloc_slices(mgp); in myri10ge_probe()
3877 netif_set_real_num_tx_queues(netdev, mgp->num_slices); in myri10ge_probe()
3878 netif_set_real_num_rx_queues(netdev, mgp->num_slices); in myri10ge_probe()
3879 status = myri10ge_reset(mgp); in myri10ge_probe()
3885 myri10ge_setup_dca(mgp); in myri10ge_probe()
3887 pci_set_drvdata(pdev, mgp); in myri10ge_probe()
3901 netdev->hw_features = mgp->features | NETIF_F_RXCSUM; in myri10ge_probe()
3911 netdev->vlan_features |= mgp->features; in myri10ge_probe()
3912 if (mgp->fw_ver_tiny < 37) in myri10ge_probe()
3914 if (mgp->fw_ver_tiny < 32) in myri10ge_probe()
3919 status = myri10ge_request_irq(mgp); in myri10ge_probe()
3922 myri10ge_free_irq(mgp); in myri10ge_probe()
3929 timer_setup(&mgp->watchdog_timer, myri10ge_watchdog_timer, 0); in myri10ge_probe()
3932 INIT_WORK(&mgp->watchdog_work, myri10ge_watchdog); in myri10ge_probe()
3938 if (mgp->msix_enabled) in myri10ge_probe()
3940 mgp->num_slices, mgp->tx_boundary, mgp->fw_name, in myri10ge_probe()
3941 (mgp->wc_cookie > 0 ? "Enabled" : "Disabled")); in myri10ge_probe()
3944 mgp->msi_enabled ? "MSI" : "xPIC", in myri10ge_probe()
3945 pdev->irq, mgp->tx_boundary, mgp->fw_name, in myri10ge_probe()
3946 (mgp->wc_cookie > 0 ? "Enabled" : "Disabled")); in myri10ge_probe()
3955 myri10ge_free_slices(mgp); in myri10ge_probe()
3958 myri10ge_dummy_rdma(mgp, 0); in myri10ge_probe()
3961 if (mgp->mac_addr_string != NULL) in myri10ge_probe()
3964 mgp->mac_addr_string, mgp->serial_number); in myri10ge_probe()
3965 iounmap(mgp->sram); in myri10ge_probe()
3968 arch_phys_wc_del(mgp->wc_cookie); in myri10ge_probe()
3969 dma_free_coherent(&pdev->dev, sizeof(*mgp->cmd), in myri10ge_probe()
3970 mgp->cmd, mgp->cmd_bus); in myri10ge_probe()
3976 set_fw_name(mgp, NULL, false); in myri10ge_probe()
3990 struct myri10ge_priv *mgp; in myri10ge_remove() local
3993 mgp = pci_get_drvdata(pdev); in myri10ge_remove()
3994 if (mgp == NULL) in myri10ge_remove()
3997 cancel_work_sync(&mgp->watchdog_work); in myri10ge_remove()
3998 netdev = mgp->dev; in myri10ge_remove()
4002 myri10ge_teardown_dca(mgp); in myri10ge_remove()
4004 myri10ge_dummy_rdma(mgp, 0); in myri10ge_remove()
4009 iounmap(mgp->sram); in myri10ge_remove()
4010 arch_phys_wc_del(mgp->wc_cookie); in myri10ge_remove()
4011 myri10ge_free_slices(mgp); in myri10ge_remove()
4012 kfree(mgp->msix_vectors); in myri10ge_remove()
4013 dma_free_coherent(&pdev->dev, sizeof(*mgp->cmd), in myri10ge_remove()
4014 mgp->cmd, mgp->cmd_bus); in myri10ge_remove()
4016 set_fw_name(mgp, NULL, false); in myri10ge_remove()