diff options
author | Dhananjay Phadke <dhananjay@netxen.com> | 2009-09-05 13:43:11 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-09-07 04:53:18 -0400 |
commit | 2b9e62ee7b2f1971c01fdaa7653c9dae7b571187 (patch) | |
tree | 2985333288b3c984009aca8db6b44a1cf99b4703 /drivers/net/netxen | |
parent | 195c5f9829407857cba86f083caec6302b1fd8e1 (diff) |
netxen: refactor firmware info code
o Combine netxen_get_firmware_info(), netxen_check_options()
so that they are updated every time firmware is reset.
o Set dma mask everytime firmware is reset.
Signed-off-by: Dhananjay Phadke <dhananjay@netxen.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/netxen')
-rw-r--r-- | drivers/net/netxen/netxen_nic.h | 1 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_hw.c | 59 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_main.c | 141 |
3 files changed, 98 insertions, 103 deletions
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h index 5bbc40be9de6..df03ea4500d1 100644 --- a/drivers/net/netxen/netxen_nic.h +++ b/drivers/net/netxen/netxen_nic.h | |||
@@ -1263,7 +1263,6 @@ void netxen_pcie_sem_unlock(struct netxen_adapter *, int); | |||
1263 | netxen_pcie_sem_unlock((a), 7) | 1263 | netxen_pcie_sem_unlock((a), 7) |
1264 | 1264 | ||
1265 | int netxen_nic_get_board_info(struct netxen_adapter *adapter); | 1265 | int netxen_nic_get_board_info(struct netxen_adapter *adapter); |
1266 | void netxen_nic_get_firmware_info(struct netxen_adapter *adapter); | ||
1267 | int netxen_nic_wol_supported(struct netxen_adapter *adapter); | 1266 | int netxen_nic_wol_supported(struct netxen_adapter *adapter); |
1268 | 1267 | ||
1269 | /* Functions from netxen_nic_init.c */ | 1268 | /* Functions from netxen_nic_init.c */ |
diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c index cbfd6102e455..555bc4a7e888 100644 --- a/drivers/net/netxen/netxen_nic_hw.c +++ b/drivers/net/netxen/netxen_nic_hw.c | |||
@@ -2240,65 +2240,6 @@ void netxen_nic_set_link_parameters(struct netxen_adapter *adapter) | |||
2240 | } | 2240 | } |
2241 | } | 2241 | } |
2242 | 2242 | ||
2243 | void netxen_nic_get_firmware_info(struct netxen_adapter *adapter) | ||
2244 | { | ||
2245 | u32 fw_major, fw_minor, fw_build; | ||
2246 | char brd_name[NETXEN_MAX_SHORT_NAME]; | ||
2247 | char serial_num[32]; | ||
2248 | int i, offset, val; | ||
2249 | int *ptr32; | ||
2250 | struct pci_dev *pdev = adapter->pdev; | ||
2251 | |||
2252 | adapter->driver_mismatch = 0; | ||
2253 | |||
2254 | ptr32 = (int *)&serial_num; | ||
2255 | offset = NX_FW_SERIAL_NUM_OFFSET; | ||
2256 | for (i = 0; i < 8; i++) { | ||
2257 | if (netxen_rom_fast_read(adapter, offset, &val) == -1) { | ||
2258 | dev_err(&pdev->dev, "error reading board info\n"); | ||
2259 | adapter->driver_mismatch = 1; | ||
2260 | return; | ||
2261 | } | ||
2262 | ptr32[i] = cpu_to_le32(val); | ||
2263 | offset += sizeof(u32); | ||
2264 | } | ||
2265 | |||
2266 | fw_major = NXRD32(adapter, NETXEN_FW_VERSION_MAJOR); | ||
2267 | fw_minor = NXRD32(adapter, NETXEN_FW_VERSION_MINOR); | ||
2268 | fw_build = NXRD32(adapter, NETXEN_FW_VERSION_SUB); | ||
2269 | |||
2270 | adapter->fw_version = NETXEN_VERSION_CODE(fw_major, fw_minor, fw_build); | ||
2271 | |||
2272 | if (adapter->portnum == 0) { | ||
2273 | get_brd_name_by_type(adapter->ahw.board_type, brd_name); | ||
2274 | |||
2275 | printk(KERN_INFO "NetXen %s Board S/N %s Chip rev 0x%x\n", | ||
2276 | brd_name, serial_num, adapter->ahw.revision_id); | ||
2277 | } | ||
2278 | |||
2279 | if (adapter->fw_version < NETXEN_VERSION_CODE(3, 4, 216)) { | ||
2280 | adapter->driver_mismatch = 1; | ||
2281 | dev_warn(&pdev->dev, "firmware version %d.%d.%d unsupported\n", | ||
2282 | fw_major, fw_minor, fw_build); | ||
2283 | return; | ||
2284 | } | ||
2285 | |||
2286 | dev_info(&pdev->dev, "firmware version %d.%d.%d\n", | ||
2287 | fw_major, fw_minor, fw_build); | ||
2288 | |||
2289 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { | ||
2290 | i = NXRD32(adapter, NETXEN_SRE_MISC); | ||
2291 | adapter->ahw.cut_through = (i & 0x8000) ? 1 : 0; | ||
2292 | dev_info(&pdev->dev, "firmware running in %s mode\n", | ||
2293 | adapter->ahw.cut_through ? "cut-through" : "legacy"); | ||
2294 | } | ||
2295 | |||
2296 | if (adapter->fw_version >= NETXEN_VERSION_CODE(4, 0, 222)) | ||
2297 | adapter->capabilities = NXRD32(adapter, CRB_FW_CAPABILITIES_1); | ||
2298 | |||
2299 | adapter->flags &= ~NETXEN_NIC_LRO_ENABLED; | ||
2300 | } | ||
2301 | |||
2302 | int | 2243 | int |
2303 | netxen_nic_wol_supported(struct netxen_adapter *adapter) | 2244 | netxen_nic_wol_supported(struct netxen_adapter *adapter) |
2304 | { | 2245 | { |
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index b2fd7132bc36..304618aa09dd 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c | |||
@@ -318,44 +318,6 @@ err_out: | |||
318 | return err; | 318 | return err; |
319 | } | 319 | } |
320 | 320 | ||
321 | static void | ||
322 | netxen_check_options(struct netxen_adapter *adapter) | ||
323 | { | ||
324 | if (adapter->ahw.port_type == NETXEN_NIC_XGBE) { | ||
325 | adapter->num_rxd = DEFAULT_RCV_DESCRIPTORS_10G; | ||
326 | adapter->num_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS_10G; | ||
327 | } else if (adapter->ahw.port_type == NETXEN_NIC_GBE) { | ||
328 | adapter->num_rxd = DEFAULT_RCV_DESCRIPTORS_1G; | ||
329 | adapter->num_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS_1G; | ||
330 | } | ||
331 | |||
332 | adapter->msix_supported = 0; | ||
333 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { | ||
334 | adapter->msix_supported = !!use_msi_x; | ||
335 | adapter->rss_supported = !!use_msi_x; | ||
336 | } else if (adapter->fw_version >= NETXEN_VERSION_CODE(3, 4, 336)) { | ||
337 | switch (adapter->ahw.board_type) { | ||
338 | case NETXEN_BRDTYPE_P2_SB31_10G: | ||
339 | case NETXEN_BRDTYPE_P2_SB31_10G_CX4: | ||
340 | adapter->msix_supported = !!use_msi_x; | ||
341 | adapter->rss_supported = !!use_msi_x; | ||
342 | break; | ||
343 | default: | ||
344 | break; | ||
345 | } | ||
346 | } | ||
347 | |||
348 | adapter->num_txd = MAX_CMD_DESCRIPTORS; | ||
349 | |||
350 | if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) { | ||
351 | adapter->num_lro_rxd = MAX_LRO_RCV_DESCRIPTORS; | ||
352 | adapter->max_rds_rings = 3; | ||
353 | } else { | ||
354 | adapter->num_lro_rxd = 0; | ||
355 | adapter->max_rds_rings = 2; | ||
356 | } | ||
357 | } | ||
358 | |||
359 | static int | 321 | static int |
360 | netxen_check_hw_init(struct netxen_adapter *adapter, int first_boot) | 322 | netxen_check_hw_init(struct netxen_adapter *adapter, int first_boot) |
361 | { | 323 | { |
@@ -733,12 +695,110 @@ err_out: | |||
733 | return err; | 695 | return err; |
734 | } | 696 | } |
735 | 697 | ||
698 | static void | ||
699 | netxen_check_options(struct netxen_adapter *adapter) | ||
700 | { | ||
701 | u32 fw_major, fw_minor, fw_build; | ||
702 | char brd_name[NETXEN_MAX_SHORT_NAME]; | ||
703 | char serial_num[32]; | ||
704 | int i, offset, val; | ||
705 | int *ptr32; | ||
706 | struct pci_dev *pdev = adapter->pdev; | ||
707 | |||
708 | adapter->driver_mismatch = 0; | ||
709 | |||
710 | ptr32 = (int *)&serial_num; | ||
711 | offset = NX_FW_SERIAL_NUM_OFFSET; | ||
712 | for (i = 0; i < 8; i++) { | ||
713 | if (netxen_rom_fast_read(adapter, offset, &val) == -1) { | ||
714 | dev_err(&pdev->dev, "error reading board info\n"); | ||
715 | adapter->driver_mismatch = 1; | ||
716 | return; | ||
717 | } | ||
718 | ptr32[i] = cpu_to_le32(val); | ||
719 | offset += sizeof(u32); | ||
720 | } | ||
721 | |||
722 | fw_major = NXRD32(adapter, NETXEN_FW_VERSION_MAJOR); | ||
723 | fw_minor = NXRD32(adapter, NETXEN_FW_VERSION_MINOR); | ||
724 | fw_build = NXRD32(adapter, NETXEN_FW_VERSION_SUB); | ||
725 | |||
726 | adapter->fw_version = NETXEN_VERSION_CODE(fw_major, fw_minor, fw_build); | ||
727 | |||
728 | if (adapter->portnum == 0) { | ||
729 | get_brd_name_by_type(adapter->ahw.board_type, brd_name); | ||
730 | |||
731 | printk(KERN_INFO "NetXen %s Board S/N %s Chip rev 0x%x\n", | ||
732 | brd_name, serial_num, adapter->ahw.revision_id); | ||
733 | } | ||
734 | |||
735 | if (adapter->fw_version < NETXEN_VERSION_CODE(3, 4, 216)) { | ||
736 | adapter->driver_mismatch = 1; | ||
737 | dev_warn(&pdev->dev, "firmware version %d.%d.%d unsupported\n", | ||
738 | fw_major, fw_minor, fw_build); | ||
739 | return; | ||
740 | } | ||
741 | |||
742 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { | ||
743 | i = NXRD32(adapter, NETXEN_SRE_MISC); | ||
744 | adapter->ahw.cut_through = (i & 0x8000) ? 1 : 0; | ||
745 | } | ||
746 | |||
747 | dev_info(&pdev->dev, "firmware v%d.%d.%d [%s]\n", | ||
748 | fw_major, fw_minor, fw_build, | ||
749 | adapter->ahw.cut_through ? "cut-through" : "legacy"); | ||
750 | |||
751 | if (adapter->fw_version >= NETXEN_VERSION_CODE(4, 0, 222)) | ||
752 | adapter->capabilities = NXRD32(adapter, CRB_FW_CAPABILITIES_1); | ||
753 | |||
754 | adapter->flags &= ~NETXEN_NIC_LRO_ENABLED; | ||
755 | |||
756 | if (adapter->ahw.port_type == NETXEN_NIC_XGBE) { | ||
757 | adapter->num_rxd = DEFAULT_RCV_DESCRIPTORS_10G; | ||
758 | adapter->num_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS_10G; | ||
759 | } else if (adapter->ahw.port_type == NETXEN_NIC_GBE) { | ||
760 | adapter->num_rxd = DEFAULT_RCV_DESCRIPTORS_1G; | ||
761 | adapter->num_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS_1G; | ||
762 | } | ||
763 | |||
764 | adapter->msix_supported = 0; | ||
765 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { | ||
766 | adapter->msix_supported = !!use_msi_x; | ||
767 | adapter->rss_supported = !!use_msi_x; | ||
768 | } else if (adapter->fw_version >= NETXEN_VERSION_CODE(3, 4, 336)) { | ||
769 | switch (adapter->ahw.board_type) { | ||
770 | case NETXEN_BRDTYPE_P2_SB31_10G: | ||
771 | case NETXEN_BRDTYPE_P2_SB31_10G_CX4: | ||
772 | adapter->msix_supported = !!use_msi_x; | ||
773 | adapter->rss_supported = !!use_msi_x; | ||
774 | break; | ||
775 | default: | ||
776 | break; | ||
777 | } | ||
778 | } | ||
779 | |||
780 | adapter->num_txd = MAX_CMD_DESCRIPTORS; | ||
781 | |||
782 | if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) { | ||
783 | adapter->num_lro_rxd = MAX_LRO_RCV_DESCRIPTORS; | ||
784 | adapter->max_rds_rings = 3; | ||
785 | } else { | ||
786 | adapter->num_lro_rxd = 0; | ||
787 | adapter->max_rds_rings = 2; | ||
788 | } | ||
789 | } | ||
790 | |||
736 | static int | 791 | static int |
737 | netxen_start_firmware(struct netxen_adapter *adapter) | 792 | netxen_start_firmware(struct netxen_adapter *adapter) |
738 | { | 793 | { |
739 | int val, err, first_boot; | 794 | int val, err, first_boot; |
740 | struct pci_dev *pdev = adapter->pdev; | 795 | struct pci_dev *pdev = adapter->pdev; |
741 | 796 | ||
797 | /* required for NX2031 dummy dma */ | ||
798 | err = nx_set_dma_mask(adapter); | ||
799 | if (err) | ||
800 | return err; | ||
801 | |||
742 | if (!netxen_can_start_firmware(adapter)) | 802 | if (!netxen_can_start_firmware(adapter)) |
743 | goto wait_init; | 803 | goto wait_init; |
744 | 804 | ||
@@ -811,7 +871,6 @@ wait_init: | |||
811 | 871 | ||
812 | nx_update_dma_mask(adapter); | 872 | nx_update_dma_mask(adapter); |
813 | 873 | ||
814 | netxen_nic_get_firmware_info(adapter); | ||
815 | netxen_check_options(adapter); | 874 | netxen_check_options(adapter); |
816 | 875 | ||
817 | return 0; | 876 | return 0; |
@@ -1191,10 +1250,6 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1191 | revision_id = pdev->revision; | 1250 | revision_id = pdev->revision; |
1192 | adapter->ahw.revision_id = revision_id; | 1251 | adapter->ahw.revision_id = revision_id; |
1193 | 1252 | ||
1194 | err = nx_set_dma_mask(adapter); | ||
1195 | if (err) | ||
1196 | goto err_out_free_netdev; | ||
1197 | |||
1198 | rwlock_init(&adapter->adapter_lock); | 1253 | rwlock_init(&adapter->adapter_lock); |
1199 | spin_lock_init(&adapter->tx_clean_lock); | 1254 | spin_lock_init(&adapter->tx_clean_lock); |
1200 | INIT_LIST_HEAD(&adapter->mac_list); | 1255 | INIT_LIST_HEAD(&adapter->mac_list); |