Lines Matching refs:mgp
180 struct myri10ge_priv *mgp; member
369 static void set_fw_name(struct myri10ge_priv *mgp, char *name, bool allocated) in set_fw_name() argument
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()
378 myri10ge_send_cmd(struct myri10ge_priv *mgp, u32 cmd, in myri10ge_send_cmd() argument
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()
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()
446 dev_err(&mgp->pdev->dev, in myri10ge_send_cmd()
453 dev_err(&mgp->pdev->dev, "command %d timed out, result = %d\n", in myri10ge_send_cmd()
465 static int myri10ge_read_mac_addr(struct myri10ge_priv *mgp) in myri10ge_read_mac_addr() argument
470 ptr = mgp->eeprom_strings; in myri10ge_read_mac_addr()
471 limit = mgp->eeprom_strings + MYRI10GE_EEPROM_STRINGS_SIZE; 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()
508 static void myri10ge_dummy_rdma(struct myri10ge_priv *mgp, int enable) in myri10ge_dummy_rdma() argument
516 mgp->cmd->data = 0; 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()
544 myri10ge_validate_firmware(struct myri10ge_priv *mgp, in myri10ge_validate_firmware() argument
547 struct device *dev = &mgp->pdev->dev; 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()
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 (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, in myri10ge_update_mac_address() argument
810 status = myri10ge_send_cmd(mgp, MXGEFW_SET_MAC_ADDRESS, &cmd, 0); in myri10ge_update_mac_address()
814 static int myri10ge_change_pause(struct myri10ge_priv *mgp, int pause) in myri10ge_change_pause() argument
820 status = myri10ge_send_cmd(mgp, ctl, &cmd, 0); in myri10ge_change_pause()
823 netdev_err(mgp->dev, "Failed to set flow control mode\n"); in myri10ge_change_pause()
826 mgp->pause = pause; in myri10ge_change_pause()
831 myri10ge_change_promisc(struct myri10ge_priv *mgp, int promisc, int atomic) in myri10ge_change_promisc() argument
837 status = myri10ge_send_cmd(mgp, ctl, &cmd, atomic); in myri10ge_change_promisc()
839 netdev_err(mgp->dev, "Failed to set promisc mode\n"); in myri10ge_change_promisc()
842 static int myri10ge_dma_test(struct myri10ge_priv *mgp, int test_type) in myri10ge_dma_test() argument
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()
870 len = mgp->tx_boundary; in myri10ge_dma_test()
875 status = myri10ge_send_cmd(mgp, test_type, &cmd, 0); in myri10ge_dma_test()
880 mgp->read_dma = ((cmd.data0 >> 16) * len * 2) / (cmd.data0 & 0xffff); in myri10ge_dma_test()
884 status = myri10ge_send_cmd(mgp, test_type, &cmd, 0); in myri10ge_dma_test()
889 mgp->write_dma = ((cmd.data0 >> 16) * len * 2) / (cmd.data0 & 0xffff); in myri10ge_dma_test()
894 status = myri10ge_send_cmd(mgp, test_type, &cmd, 0); 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()
914 static int myri10ge_reset(struct myri10ge_priv *mgp) in myri10ge_reset() argument
927 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_RESET, &cmd, 0); in myri10ge_reset()
929 dev_err(&mgp->pdev->dev, "failed reset\n"); in myri10ge_reset()
933 (void)myri10ge_dma_test(mgp, MXGEFW_DMA_TEST); in myri10ge_reset()
941 (void)myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_RSS_MCP_SLOT_TYPE, &cmd, 0); in myri10ge_reset()
945 bytes = mgp->max_intr_slots * sizeof(*mgp->ss[0].rx_done.entry); in myri10ge_reset()
947 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_INTRQ_SIZE, &cmd, 0); in myri10ge_reset()
960 if (mgp->num_slices > 1) { in myri10ge_reset()
963 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_MAX_RSS_QUEUES, 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()
979 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_ENABLE_RSS_QUEUES, 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()
989 status = myri10ge_send_cmd(mgp, 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()
1006 status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_INTRQ_DMA, in myri10ge_reset()
1011 myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_IRQ_ACK_OFFSET, &cmd, 0); in myri10ge_reset()
1012 for (i = 0; i < mgp->num_slices; i++) { in myri10ge_reset()
1013 ss = &mgp->ss[i]; in myri10ge_reset()
1015 (__iomem __be32 *) (mgp->sram + cmd.data0 + 8 * i); in myri10ge_reset()
1017 status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_IRQ_DEASSERT_OFFSET, in myri10ge_reset()
1019 mgp->irq_deassert = (__iomem __be32 *) (mgp->sram + cmd.data0); in myri10ge_reset()
1022 (mgp, MXGEFW_CMD_GET_INTR_COAL_DELAY_OFFSET, &cmd, 0); 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()
1031 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_DCA_OFFSET, &cmd, 0); in myri10ge_reset()
1033 for (i = 0; i < mgp->num_slices; i++) { in myri10ge_reset()
1034 ss = &mgp->ss[i]; in myri10ge_reset()
1037 (mgp->sram + dca_tag_off + 4 * i); 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()
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()
1099 tag = dca3_get_tag(&ss->mgp->pdev->dev, cpu); in myri10ge_update_dca()
1107 static void myri10ge_setup_dca(struct myri10ge_priv *mgp) in myri10ge_setup_dca() argument
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()
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()
1134 static void myri10ge_teardown_dca(struct myri10ge_priv *mgp) in myri10ge_teardown_dca() argument
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()
1148 struct myri10ge_priv *mgp; in myri10ge_notify_dca_device() local
1151 mgp = dev_get_drvdata(dev); in myri10ge_notify_dca_device()
1155 myri10ge_setup_dca(mgp); in myri10ge_notify_dca_device()
1157 myri10ge_teardown_dca(mgp); in myri10ge_notify_dca_device()
1180 myri10ge_alloc_rx_pages(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx, in myri10ge_alloc_rx_pages() argument
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()
1309 struct myri10ge_priv *mgp = ss->mgp; in myri10ge_rx_done() local
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()
1320 bytes = mgp->small_bytes; in myri10ge_rx_done()
1323 bytes = mgp->big_bytes; 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()
1379 struct pci_dev *pdev = ss->mgp->pdev; 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()
1439 ss->mgp->running == MYRI10GE_ETH_RUNNING) { in myri10ge_tx_done()
1449 struct myri10ge_priv *mgp = ss->mgp; in myri10ge_clean_rx_done() local
1467 idx = cnt & (mgp->max_intr_slots - 1); 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()
1480 myri10ge_alloc_rx_pages(mgp, &ss->rx_big, mgp->big_bytes, 0); in myri10ge_clean_rx_done()
1485 static inline void myri10ge_check_statblock(struct myri10ge_priv *mgp) in myri10ge_check_statblock() argument
1487 struct mcp_irq_data *stats = mgp->ss[0].fw_stats; 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()
1509 mgp->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()
1516 wake_up(&mgp->down_wq); in myri10ge_check_statblock()
1527 if (ss->mgp->dca_enabled) in myri10ge_poll()
1543 struct myri10ge_priv *mgp = ss->mgp; in myri10ge_intr() local
1551 if ((mgp->dev->real_num_tx_queues == 1) && (ss != mgp->ss)) { in myri10ge_intr()
1565 if (!mgp->msi_enabled && !mgp->msix_enabled) { in myri10ge_intr()
1566 put_be32(0, mgp->irq_deassert); in myri10ge_intr()
1582 netdev_warn(mgp->dev, "irq stuck?\n"); in myri10ge_intr()
1584 schedule_work(&mgp->watchdog_work); in myri10ge_intr()
1593 if (ss == mgp->ss) in myri10ge_intr()
1594 myri10ge_check_statblock(mgp); in myri10ge_intr()
1604 struct myri10ge_priv *mgp = netdev_priv(netdev); in myri10ge_get_link_ksettings() local
1618 ptr = mgp->product_code_string; in myri10ge_get_link_ksettings()
1627 mgp->product_code_string); in myri10ge_get_link_ksettings()
1648 struct myri10ge_priv *mgp = netdev_priv(netdev); in myri10ge_get_drvinfo() local
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()
1661 struct myri10ge_priv *mgp = netdev_priv(netdev); in myri10ge_get_coalesce() local
1663 coal->rx_coalesce_usecs = mgp->intr_coal_delay; in myri10ge_get_coalesce()
1672 struct myri10ge_priv *mgp = netdev_priv(netdev); in myri10ge_set_coalesce() local
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()
1683 struct myri10ge_priv *mgp = netdev_priv(netdev); in myri10ge_get_pauseparam() local
1686 pause->rx_pause = mgp->pause; in myri10ge_get_pauseparam()
1687 pause->tx_pause = mgp->pause; in myri10ge_get_pauseparam()
1694 struct myri10ge_priv *mgp = netdev_priv(netdev); in myri10ge_set_pauseparam() local
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()
1711 struct myri10ge_priv *mgp = netdev_priv(netdev); in myri10ge_get_ringparam() local
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()
1716 ring->tx_max_pending = mgp->ss[0].tx.mask + 1; in myri10ge_get_ringparam()
1759 struct myri10ge_priv *mgp = netdev_priv(netdev); in myri10ge_get_strings() local
1767 for (i = 0; i < mgp->num_slices; i++) { in myri10ge_get_strings()
1778 struct myri10ge_priv *mgp = netdev_priv(netdev); in myri10ge_get_sset_count() local
1783 mgp->num_slices * MYRI10GE_SLICE_STATS_LEN; in myri10ge_get_sset_count()
1793 struct myri10ge_priv *mgp = netdev_priv(netdev); in myri10ge_get_ethtool_stats() local
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()
1837 for (slice = 0; slice < mgp->num_slices; slice++) { in myri10ge_get_ethtool_stats()
1838 ss = &mgp->ss[slice]; in myri10ge_get_ethtool_stats()
1854 struct myri10ge_priv *mgp = netdev_priv(netdev); in myri10ge_set_msglevel() local
1855 mgp->msg_enable = value; in myri10ge_set_msglevel()
1860 struct myri10ge_priv *mgp = netdev_priv(netdev); in myri10ge_get_msglevel() local
1861 return mgp->msg_enable; in myri10ge_get_msglevel()
1869 static int myri10ge_led(struct myri10ge_priv *mgp, int on) in myri10ge_led() argument
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()
1883 hdr_len = swab32(readl(mgp->sram + hdr_off + 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()
1899 struct myri10ge_priv *mgp = netdev_priv(netdev); in myri10ge_phys_id() local
1904 rc = myri10ge_led(mgp, 1); in myri10ge_phys_id()
1908 rc = myri10ge_led(mgp, 0); in myri10ge_phys_id()
1938 struct myri10ge_priv *mgp = ss->mgp; in myri10ge_allocate_rings() local
1940 struct net_device *dev = mgp->dev; in myri10ge_allocate_rings()
1947 slice = ss - mgp->ss; in myri10ge_allocate_rings()
1949 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_SEND_RING_SIZE, &cmd, 0); in myri10ge_allocate_rings()
1952 status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_RX_RING_SIZE, &cmd, 0); in myri10ge_allocate_rings()
2013 if (mgp->small_bytes == 0) { 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()
2026 myri10ge_alloc_rx_pages(mgp, &ss->rx_big, mgp->big_bytes, 0); 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()
2044 if (mgp->small_bytes == 0) 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()
2078 struct myri10ge_priv *mgp = ss->mgp; in myri10ge_free_rings() local
2091 myri10ge_unmap_rx_page(mgp->pdev, &ss->rx_big.info[idx], in myri10ge_free_rings()
2092 mgp->big_bytes); in myri10ge_free_rings()
2096 if (mgp->small_bytes == 0) 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()
2121 dma_unmap_single(&mgp->pdev->dev, in myri10ge_free_rings()
2127 dma_unmap_page(&mgp->pdev->dev, in myri10ge_free_rings()
2148 static int myri10ge_request_irq(struct myri10ge_priv *mgp) in myri10ge_request_irq() argument
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()
2168 mgp->msix_enabled = 1; in myri10ge_request_irq()
2170 if (mgp->msix_enabled == 0) { 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()
2186 status = request_irq(mgp->msix_vectors[i].vector, in myri10ge_request_irq()
2194 free_irq(mgp->msix_vectors[i].vector, in myri10ge_request_irq()
2195 &mgp->ss[i]); in myri10ge_request_irq()
2204 mgp->dev->name, &mgp->ss[0]); in myri10ge_request_irq()
2207 if (mgp->msi_enabled) in myri10ge_request_irq()
2214 static void myri10ge_free_irq(struct myri10ge_priv *mgp) in myri10ge_free_irq() argument
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()
2231 static int myri10ge_get_txrx(struct myri10ge_priv *mgp, int slice) in myri10ge_get_txrx() argument
2237 ss = &mgp->ss[slice]; in myri10ge_get_txrx()
2239 if (slice == 0 || (mgp->dev->real_num_tx_queues > 1)) { in myri10ge_get_txrx()
2241 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_SEND_OFFSET, in myri10ge_get_txrx()
2244 (mgp->sram + cmd.data0); in myri10ge_get_txrx()
2247 status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_SMALL_RX_OFFSET, in myri10ge_get_txrx()
2250 (mgp->sram + cmd.data0); in myri10ge_get_txrx()
2253 status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_BIG_RX_OFFSET, &cmd, 0); in myri10ge_get_txrx()
2255 (mgp->sram + cmd.data0); in myri10ge_get_txrx()
2258 (mgp->sram + MXGEFW_ETH_SEND_GO + 64 * slice); in myri10ge_get_txrx()
2260 (mgp->sram + MXGEFW_ETH_SEND_STOP + 64 * slice); in myri10ge_get_txrx()
2265 static int myri10ge_set_stats(struct myri10ge_priv *mgp, int slice) in myri10ge_set_stats() argument
2271 ss = &mgp->ss[slice]; in myri10ge_set_stats()
2275 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_STATS_DMA_V2, &cmd, 0); in myri10ge_set_stats()
2283 status = myri10ge_send_cmd(mgp, in myri10ge_set_stats()
2287 mgp->fw_multicast_support = 0; in myri10ge_set_stats()
2289 mgp->fw_multicast_support = 1; in myri10ge_set_stats()
2297 struct myri10ge_priv *mgp = netdev_priv(dev); in myri10ge_open() local
2302 if (mgp->running != MYRI10GE_ETH_STOPPED) in myri10ge_open()
2305 mgp->running = MYRI10GE_ETH_STARTING; in myri10ge_open()
2306 status = myri10ge_reset(mgp); 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()
2317 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_ENABLE_RSS_QUEUES, in myri10ge_open()
2324 cmd.data0 = mgp->num_slices; in myri10ge_open()
2325 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_RSS_TABLE_SIZE, in myri10ge_open()
2328 status |= myri10ge_send_cmd(mgp, in myri10ge_open()
2337 itable = mgp->sram + cmd.data0; in myri10ge_open()
2338 for (i = 0; i < mgp->num_slices; i++) in myri10ge_open()
2343 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_RSS_ENABLE, in myri10ge_open()
2351 status = myri10ge_request_irq(mgp); in myri10ge_open()
2363 mgp->small_bytes = (128 > SMP_CACHE_BYTES) in myri10ge_open()
2368 mgp->small_bytes = VLAN_ETH_FRAME_LEN; in myri10ge_open()
2372 mgp->small_bytes = myri10ge_small_bytes; 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()
2389 for (slice = 0; slice < mgp->num_slices; slice++) { in myri10ge_open()
2390 ss = &mgp->ss[slice]; in myri10ge_open()
2392 status = myri10ge_get_txrx(mgp, slice); in myri10ge_open()
2404 if (slice == 0 || mgp->dev->real_num_tx_queues > 1) in myri10ge_open()
2405 status = myri10ge_set_stats(mgp, slice); in myri10ge_open()
2417 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_MTU, &cmd, 0); in myri10ge_open()
2418 cmd.data0 = mgp->small_bytes; in myri10ge_open()
2420 myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_SMALL_BUFFER_SIZE, &cmd, 0); in myri10ge_open()
2423 myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_BIG_BUFFER_SIZE, &cmd, 0); in myri10ge_open()
2435 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_TSO_MODE, &cmd, 0); in myri10ge_open()
2441 mgp->link_state = ~0U; in myri10ge_open()
2442 mgp->rdma_tags_available = 15; in myri10ge_open()
2444 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_ETHERNET_UP, &cmd, 0); 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()
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()
2465 myri10ge_free_irq(mgp); in myri10ge_open()
2468 mgp->running = MYRI10GE_ETH_STOPPED; in myri10ge_open()
2474 struct myri10ge_priv *mgp = netdev_priv(dev); in myri10ge_close() local
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()
2497 myri10ge_send_cmd(mgp, MXGEFW_CMD_ETHERNET_DOWN, &cmd, 0); 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()
2507 myri10ge_free_irq(mgp); 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()
2582 static void myri10ge_unmap_tx_dma(struct myri10ge_priv *mgp, in myri10ge_unmap_tx_dma() argument
2595 dma_unmap_single(&mgp->pdev->dev, in myri10ge_unmap_tx_dma()
2600 dma_unmap_page(&mgp->pdev->dev, in myri10ge_unmap_tx_dma()
2624 struct myri10ge_priv *mgp = netdev_priv(dev); in myri10ge_xmit() local
2640 ss = &mgp->ss[queue]; in myri10ge_xmit()
2641 netdev_queue = netdev_get_tx_queue(mgp->dev, queue); in myri10ge_xmit()
2703 if (unlikely(-cum_len > mgp->max_tso6)) 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()
2771 (low + mgp->tx_boundary) & ~(mgp->tx_boundary - 1); 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()
2836 myri10ge_unmap_tx_dma(mgp, tx, idx); in myri10ge_xmit()
2856 if ((mgp->dev->real_num_tx_queues > 1) && tx->queue_active == 0) { in myri10ge_xmit()
2869 myri10ge_unmap_tx_dma(mgp, tx, idx); in myri10ge_xmit()
2872 netdev_err(mgp->dev, "TSO but wanted to linearize?!?!?\n"); in myri10ge_xmit()
2893 struct myri10ge_priv *mgp = netdev_priv(dev); in myri10ge_sw_tso() local
2917 ss = &mgp->ss[skb_get_queue_mapping(skb)]; in myri10ge_sw_tso()
2926 const struct myri10ge_priv *mgp = netdev_priv(dev); in myri10ge_get_stats() local
2930 for (i = 0; i < mgp->num_slices; i++) { in myri10ge_get_stats()
2931 slice_stats = &mgp->ss[i].stats; in myri10ge_get_stats()
2943 struct myri10ge_priv *mgp = netdev_priv(dev); in myri10ge_set_multicast_list() local
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()
2959 err = myri10ge_send_cmd(mgp, MXGEFW_ENABLE_ALLMULTI, &cmd, 1); in myri10ge_set_multicast_list()
2966 if ((dev->flags & IFF_ALLMULTI) || mgp->adopted_rx_filter_bug) { in myri10ge_set_multicast_list()
2973 err = myri10ge_send_cmd(mgp, MXGEFW_LEAVE_ALL_MULTICAST_GROUPS, in myri10ge_set_multicast_list()
2986 err = myri10ge_send_cmd(mgp, MXGEFW_JOIN_MULTICAST_GROUP, in myri10ge_set_multicast_list()
2996 err = myri10ge_send_cmd(mgp, MXGEFW_DISABLE_ALLMULTI, &cmd, 1); in myri10ge_set_multicast_list()
3012 struct myri10ge_priv *mgp = netdev_priv(dev); in myri10ge_set_mac_address() local
3018 status = myri10ge_update_mac_address(mgp, sa->sa_data); in myri10ge_set_mac_address()
3032 struct myri10ge_priv *mgp = netdev_priv(dev); in myri10ge_change_mtu() local
3035 if (mgp->running) { in myri10ge_change_mtu()
3053 static void myri10ge_enable_ecrc(struct myri10ge_priv *mgp) in myri10ge_enable_ecrc() argument
3055 struct pci_dev *bridge = mgp->pdev->bus->self; in myri10ge_enable_ecrc()
3056 struct device *dev = &mgp->pdev->dev; in myri10ge_enable_ecrc()
3134 static void myri10ge_firmware_probe(struct myri10ge_priv *mgp) in myri10ge_firmware_probe() argument
3136 struct pci_dev *pdev = mgp->pdev; in myri10ge_firmware_probe()
3140 mgp->tx_boundary = 4096; in myri10ge_firmware_probe()
3152 mgp->tx_boundary = 2048; in myri10ge_firmware_probe()
3158 set_fw_name(mgp, myri10ge_fw_aligned, false); in myri10ge_firmware_probe()
3159 status = myri10ge_load_firmware(mgp, 1); in myri10ge_firmware_probe()
3167 myri10ge_enable_ecrc(mgp); in myri10ge_firmware_probe()
3174 status = myri10ge_dma_test(mgp, MXGEFW_CMD_UNALIGNED_TEST); in myri10ge_firmware_probe()
3185 mgp->tx_boundary = 2048; in myri10ge_firmware_probe()
3186 set_fw_name(mgp, myri10ge_fw_unaligned, false); in myri10ge_firmware_probe()
3189 static void myri10ge_select_firmware(struct myri10ge_priv *mgp) in myri10ge_select_firmware() argument
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()
3207 set_fw_name(mgp, myri10ge_fw_aligned, false); in myri10ge_select_firmware()
3209 myri10ge_firmware_probe(mgp); in myri10ge_select_firmware()
3213 dev_info(&mgp->pdev->dev, in myri10ge_select_firmware()
3215 mgp->tx_boundary = 4096; in myri10ge_select_firmware()
3216 set_fw_name(mgp, myri10ge_fw_aligned, false); in myri10ge_select_firmware()
3218 dev_info(&mgp->pdev->dev, in myri10ge_select_firmware()
3220 mgp->tx_boundary = 2048; in myri10ge_select_firmware()
3221 set_fw_name(mgp, myri10ge_fw_unaligned, false); in myri10ge_select_firmware()
3230 set_fw_name(mgp, fw_name, true); 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()
3268 struct myri10ge_priv *mgp; in myri10ge_suspend() local
3271 mgp = dev_get_drvdata(dev); in myri10ge_suspend()
3272 if (mgp == NULL) in myri10ge_suspend()
3274 netdev = mgp->dev; in myri10ge_suspend()
3283 myri10ge_dummy_rdma(mgp, 0); in myri10ge_suspend()
3291 struct myri10ge_priv *mgp; in myri10ge_resume() local
3296 mgp = pci_get_drvdata(pdev); in myri10ge_resume()
3297 if (mgp == NULL) 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()
3307 myri10ge_reset(mgp); in myri10ge_resume()
3308 myri10ge_dummy_rdma(mgp, 1); in myri10ge_resume()
3326 static u32 myri10ge_read_reboot(struct myri10ge_priv *mgp) in myri10ge_read_reboot() argument
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() local
3346 int slice = ss - mgp->ss; 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()
3362 (int)ntohl(mgp->ss[slice].fw_stats-> in myri10ge_check_slice()
3383 struct myri10ge_priv *mgp = in myri10ge_watchdog() local
3393 mgp->watchdog_resets++; in myri10ge_watchdog()
3394 pci_read_config_word(mgp->pdev, PCI_COMMAND, &cmd); in myri10ge_watchdog()
3400 reboot = myri10ge_read_reboot(mgp); 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()
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()
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()
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()
3458 status = myri10ge_load_firmware(mgp, 1); in myri10ge_watchdog()
3460 netdev_err(mgp->dev, "failed to load firmware\n"); in myri10ge_watchdog()
3462 myri10ge_open(mgp->dev); in myri10ge_watchdog()
3475 struct myri10ge_priv *mgp; in myri10ge_watchdog_timer() local
3481 mgp = from_timer(mgp, t, watchdog_timer); in myri10ge_watchdog_timer()
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()
3490 myri10ge_alloc_rx_pages(mgp, &ss->rx_small, in myri10ge_watchdog_timer()
3491 mgp->small_bytes + MXGEFW_PAD, 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()
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()
3527 static void myri10ge_free_slices(struct myri10ge_priv *mgp) in myri10ge_free_slices() argument
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()
3540 bytes = mgp->max_intr_slots * in myri10ge_free_slices()
3556 kfree(mgp->ss); in myri10ge_free_slices()
3557 mgp->ss = NULL; in myri10ge_free_slices()
3560 static int myri10ge_alloc_slices(struct myri10ge_priv *mgp) in myri10ge_alloc_slices() argument
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()
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()
3587 ss->mgp = mgp; in myri10ge_alloc_slices()
3588 ss->dev = mgp->dev; in myri10ge_alloc_slices()
3594 myri10ge_free_slices(mgp); in myri10ge_alloc_slices()
3604 static void myri10ge_probe_slices(struct myri10ge_priv *mgp) in myri10ge_probe_slices() argument
3607 struct pci_dev *pdev = mgp->pdev; in myri10ge_probe_slices()
3612 mgp->num_slices = 1; 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()
3628 set_fw_name(mgp, myri10ge_fw_name, false); in myri10ge_probe_slices()
3630 set_fw_name(mgp, myri10ge_fw_rss_aligned, false); in myri10ge_probe_slices()
3632 set_fw_name(mgp, myri10ge_fw_rss_unaligned, false); in myri10ge_probe_slices()
3633 status = myri10ge_load_firmware(mgp, 0); in myri10ge_probe_slices()
3643 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_RESET, &cmd, 0); 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()
3653 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_INTRQ_SIZE, &cmd, 0); in myri10ge_probe_slices()
3655 dev_err(&mgp->pdev->dev, "failed MXGEFW_CMD_SET_INTRQ_SIZE\n"); in myri10ge_probe_slices()
3660 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_MAX_RSS_QUEUES, &cmd, 0); in myri10ge_probe_slices()
3664 mgp->num_slices = cmd.data0; 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()
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()
3722 set_fw_name(mgp, old_fw, old_allocated); in myri10ge_probe_slices()
3723 myri10ge_load_firmware(mgp, 0); in myri10ge_probe_slices()
3740 struct myri10ge_priv *mgp; in myri10ge_probe() local
3746 netdev = alloc_etherdev_mq(sizeof(*mgp), MYRI10GE_MAX_SLICES); in myri10ge_probe()
3752 mgp = netdev_priv(netdev); 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()
3769 mgp->vendor_specific_offset 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()
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()
3800 mgp->board_span, mgp->iomem_base); 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()
3812 mgp->sram_size, mgp->board_span); 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()
3819 status = myri10ge_read_mac_addr(mgp); in myri10ge_probe()
3823 eth_hw_addr_set(netdev, mgp->mac_addr); in myri10ge_probe()
3825 myri10ge_select_firmware(mgp); in myri10ge_probe()
3827 status = myri10ge_load_firmware(mgp, 1); in myri10ge_probe()
3832 myri10ge_probe_slices(mgp); in myri10ge_probe()
3833 status = myri10ge_alloc_slices(mgp); 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()
3840 status = myri10ge_reset(mgp); in myri10ge_probe()
3846 myri10ge_setup_dca(mgp); in myri10ge_probe()
3848 pci_set_drvdata(pdev, mgp); in myri10ge_probe()
3862 netdev->hw_features = mgp->features | NETIF_F_RXCSUM; in myri10ge_probe()
3869 netdev->vlan_features |= mgp->features; in myri10ge_probe()
3870 if (mgp->fw_ver_tiny < 37) in myri10ge_probe()
3872 if (mgp->fw_ver_tiny < 32) in myri10ge_probe()
3877 status = myri10ge_request_irq(mgp); in myri10ge_probe()
3880 myri10ge_free_irq(mgp); in myri10ge_probe()
3887 timer_setup(&mgp->watchdog_timer, myri10ge_watchdog_timer, 0); in myri10ge_probe()
3890 INIT_WORK(&mgp->watchdog_work, myri10ge_watchdog); in myri10ge_probe()
3896 if (mgp->msix_enabled) 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()
3913 myri10ge_free_slices(mgp); in myri10ge_probe()
3916 kfree(mgp->msix_vectors); in myri10ge_probe()
3917 myri10ge_dummy_rdma(mgp, 0); in myri10ge_probe()
3920 if (mgp->mac_addr_string != NULL) 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()
3935 set_fw_name(mgp, NULL, false); in myri10ge_probe()
3949 struct myri10ge_priv *mgp; in myri10ge_remove() local
3952 mgp = pci_get_drvdata(pdev); in myri10ge_remove()
3953 if (mgp == NULL) in myri10ge_remove()
3956 cancel_work_sync(&mgp->watchdog_work); in myri10ge_remove()
3957 netdev = mgp->dev; in myri10ge_remove()
3961 myri10ge_teardown_dca(mgp); in myri10ge_remove()
3963 myri10ge_dummy_rdma(mgp, 0); in myri10ge_remove()
3968 iounmap(mgp->sram); in myri10ge_remove()
3969 arch_phys_wc_del(mgp->wc_cookie); in myri10ge_remove()
3970 myri10ge_free_slices(mgp); 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()
3975 set_fw_name(mgp, NULL, false); in myri10ge_remove()