318 4, /* default number of rx queues */
319 4, /* maximum number of tx queues */
320 1, /* minimum number of tx queues */
321 4, /* default number of tx queues */
322 65535, /* maximum interrupt throttle rate */
323 0, /* minimum interrupt throttle rate */
324 200, /* default interrupt throttle rate */
325
326 /* function pointers */
327 igb_enable_adapter_interrupts_82580,
328 igb_setup_msix_82580,
329
330 /* capabilities */
331 (IGB_FLAG_HAS_DCA | /* capability flags */
332 IGB_FLAG_VMDQ_POOL |
333 IGB_FLAG_NEED_CTX_IDX),
334
335 0xfff00000 /* mask for RXDCTL register */
336 };
337
338 /*
339 * Module Initialization Functions
340 */
341
342 int
343 _init(void)
344 {
345 int status;
346
347 mac_init_ops(&igb_dev_ops, MODULE_NAME);
348
349 status = mod_install(&igb_modlinkage);
350
351 if (status != DDI_SUCCESS) {
352 mac_fini_ops(&igb_dev_ops);
353 }
354
355 return (status);
356 }
357
556
557 /*
558 * Now that mutex locks are initialized, and the chip is also
559 * initialized, enable interrupts.
560 */
561 if (igb_enable_intrs(igb) != IGB_SUCCESS) {
562 igb_error(igb, "Failed to enable DDI interrupts");
563 goto attach_fail;
564 }
565 igb->attach_progress |= ATTACH_PROGRESS_ENABLE_INTR;
566
567 igb_log(igb, "%s", igb_version);
568 atomic_or_32(&igb->igb_state, IGB_INITIALIZED);
569
570 /*
571 * Newer models have Energy Efficient Ethernet, let's disable this by
572 * default.
573 */
574 if (igb->hw.mac.type == e1000_i350)
575 (void) e1000_set_eee_i350(&igb->hw);
576
577 return (DDI_SUCCESS);
578
579 attach_fail:
580 igb_unconfigure(devinfo, igb);
581 return (DDI_FAILURE);
582 }
583
584 /*
585 * igb_detach - driver detach
586 *
587 * The detach() function is the complement of the attach routine.
588 * If cmd is set to DDI_DETACH, detach() is used to remove the
589 * state associated with a given instance of a device node
590 * prior to the removal of that instance from the system.
591 *
592 * The detach() function will be called once for each instance
593 * of the device for which there has been a successful attach()
594 * once there are no longer any opens on the device.
595 *
883 /*
884 * Install adapter capabilities based on mac type
885 */
886 switch (hw->mac.type) {
887 case e1000_82575:
888 igb->capab = &igb_82575_cap;
889 break;
890 case e1000_82576:
891 igb->capab = &igb_82576_cap;
892 break;
893 case e1000_82580:
894 igb->capab = &igb_82580_cap;
895 break;
896 case e1000_i350:
897 igb->capab = &igb_i350_cap;
898 break;
899 case e1000_i210:
900 case e1000_i211:
901 igb->capab = &igb_i210_cap;
902 break;
903 default:
904 return (IGB_FAILURE);
905 }
906
907 return (IGB_SUCCESS);
908 }
909
910 /*
911 * igb_regs_map - Map the device registers
912 */
913 static int
914 igb_regs_map(igb_t *igb)
915 {
916 dev_info_t *devinfo = igb->dip;
917 struct e1000_hw *hw = &igb->hw;
918 struct igb_osdep *osdep = &igb->osdep;
919 off_t mem_size;
920
921 /*
922 * First get the size of device registers to be mapped.
1301 if (igb_init_mac_address(igb) != IGB_SUCCESS) {
1302 igb_error(igb, "Failed to initialize MAC address");
1303 goto init_adapter_fail;
1304 }
1305
1306 /*
1307 * Packet Buffer Allocation (PBA)
1308 * Writing PBA sets the receive portion of the buffer
1309 * the remainder is used for the transmit buffer.
1310 */
1311 switch (hw->mac.type) {
1312 case e1000_82575:
1313 pba = E1000_PBA_32K;
1314 break;
1315 case e1000_82576:
1316 pba = E1000_READ_REG(hw, E1000_RXPBS);
1317 pba &= E1000_RXPBS_SIZE_MASK_82576;
1318 break;
1319 case e1000_82580:
1320 case e1000_i350:
1321 pba = E1000_READ_REG(hw, E1000_RXPBS);
1322 pba = e1000_rxpbs_adjust_82580(pba);
1323 break;
1324 case e1000_i210:
1325 case e1000_i211:
1326 pba = E1000_PBA_34K;
1327 default:
1328 break;
1329 }
1330
1331 /* Special needs in case of Jumbo frames */
1332 default_mtu = igb_get_prop(igb, PROP_DEFAULT_MTU,
1333 MIN_MTU, MAX_MTU, DEFAULT_MTU);
1334 if ((hw->mac.type == e1000_82575) && (default_mtu > ETHERMTU)) {
1335 u32 tx_space, min_tx, min_rx;
1336 pba = E1000_READ_REG(hw, E1000_PBA);
1337 tx_space = pba >> 16;
1338 pba &= 0xffff;
1339 min_tx = (igb->max_frame_size +
1340 sizeof (struct e1000_tx_desc) - ETHERNET_FCS_SIZE) * 2;
1818
1819 /*
1820 * Setup the rx/tx rings
1821 */
1822 igb_setup_rings(igb);
1823
1824 /*
1825 * Enable adapter interrupts
1826 * The interrupts must be enabled after the driver state is START
1827 */
1828 igb->capab->enable_intr(igb);
1829
1830 if (igb_check_acc_handle(igb->osdep.cfg_handle) != DDI_FM_OK)
1831 goto start_failure;
1832
1833 if (igb_check_acc_handle(igb->osdep.reg_handle) != DDI_FM_OK)
1834 goto start_failure;
1835
1836 if (igb->hw.mac.type == e1000_i350)
1837 (void) e1000_set_eee_i350(&igb->hw);
1838
1839 for (i = igb->num_tx_rings - 1; i >= 0; i--)
1840 mutex_exit(&igb->tx_rings[i].tx_lock);
1841 for (i = igb->num_rx_rings - 1; i >= 0; i--)
1842 mutex_exit(&igb->rx_rings[i].rx_lock);
1843
1844 return (IGB_SUCCESS);
1845
1846 start_failure:
1847 for (i = igb->num_tx_rings - 1; i >= 0; i--)
1848 mutex_exit(&igb->tx_rings[i].tx_lock);
1849 for (i = igb->num_rx_rings - 1; i >= 0; i--)
1850 mutex_exit(&igb->rx_rings[i].rx_lock);
1851
1852 ddi_fm_service_impact(igb->dip, DDI_SERVICE_LOST);
1853
1854 return (IGB_FAILURE);
1855 }
1856
1857 /*
|
318 4, /* default number of rx queues */
319 4, /* maximum number of tx queues */
320 1, /* minimum number of tx queues */
321 4, /* default number of tx queues */
322 65535, /* maximum interrupt throttle rate */
323 0, /* minimum interrupt throttle rate */
324 200, /* default interrupt throttle rate */
325
326 /* function pointers */
327 igb_enable_adapter_interrupts_82580,
328 igb_setup_msix_82580,
329
330 /* capabilities */
331 (IGB_FLAG_HAS_DCA | /* capability flags */
332 IGB_FLAG_VMDQ_POOL |
333 IGB_FLAG_NEED_CTX_IDX),
334
335 0xfff00000 /* mask for RXDCTL register */
336 };
337
338 static adapter_info_t igb_i354_cap = {
339 /* limits */
340 8, /* maximum number of rx queues */
341 1, /* minimum number of rx queues */
342 4, /* default number of rx queues */
343 8, /* maximum number of tx queues */
344 1, /* minimum number of tx queues */
345 4, /* default number of tx queues */
346 65535, /* maximum interrupt throttle rate */
347 0, /* minimum interrupt throttle rate */
348 200, /* default interrupt throttle rate */
349
350 /* function pointers */
351 igb_enable_adapter_interrupts_82580,
352 igb_setup_msix_82580,
353
354 /* capabilities */
355 (IGB_FLAG_HAS_DCA | /* capability flags */
356 IGB_FLAG_VMDQ_POOL |
357 IGB_FLAG_NEED_CTX_IDX),
358
359 0xfff00000 /* mask for RXDCTL register */
360 };
361
362 /*
363 * Module Initialization Functions
364 */
365
366 int
367 _init(void)
368 {
369 int status;
370
371 mac_init_ops(&igb_dev_ops, MODULE_NAME);
372
373 status = mod_install(&igb_modlinkage);
374
375 if (status != DDI_SUCCESS) {
376 mac_fini_ops(&igb_dev_ops);
377 }
378
379 return (status);
380 }
381
580
581 /*
582 * Now that mutex locks are initialized, and the chip is also
583 * initialized, enable interrupts.
584 */
585 if (igb_enable_intrs(igb) != IGB_SUCCESS) {
586 igb_error(igb, "Failed to enable DDI interrupts");
587 goto attach_fail;
588 }
589 igb->attach_progress |= ATTACH_PROGRESS_ENABLE_INTR;
590
591 igb_log(igb, "%s", igb_version);
592 atomic_or_32(&igb->igb_state, IGB_INITIALIZED);
593
594 /*
595 * Newer models have Energy Efficient Ethernet, let's disable this by
596 * default.
597 */
598 if (igb->hw.mac.type == e1000_i350)
599 (void) e1000_set_eee_i350(&igb->hw);
600 else if (igb->hw.mac.type == e1000_i354)
601 (void) e1000_set_eee_i354(&igb->hw);
602
603 return (DDI_SUCCESS);
604
605 attach_fail:
606 igb_unconfigure(devinfo, igb);
607 return (DDI_FAILURE);
608 }
609
610 /*
611 * igb_detach - driver detach
612 *
613 * The detach() function is the complement of the attach routine.
614 * If cmd is set to DDI_DETACH, detach() is used to remove the
615 * state associated with a given instance of a device node
616 * prior to the removal of that instance from the system.
617 *
618 * The detach() function will be called once for each instance
619 * of the device for which there has been a successful attach()
620 * once there are no longer any opens on the device.
621 *
909 /*
910 * Install adapter capabilities based on mac type
911 */
912 switch (hw->mac.type) {
913 case e1000_82575:
914 igb->capab = &igb_82575_cap;
915 break;
916 case e1000_82576:
917 igb->capab = &igb_82576_cap;
918 break;
919 case e1000_82580:
920 igb->capab = &igb_82580_cap;
921 break;
922 case e1000_i350:
923 igb->capab = &igb_i350_cap;
924 break;
925 case e1000_i210:
926 case e1000_i211:
927 igb->capab = &igb_i210_cap;
928 break;
929 case e1000_i354:
930 igb->capab = &igb_i354_cap;
931 break;
932 default:
933 return (IGB_FAILURE);
934 }
935
936 return (IGB_SUCCESS);
937 }
938
939 /*
940 * igb_regs_map - Map the device registers
941 */
942 static int
943 igb_regs_map(igb_t *igb)
944 {
945 dev_info_t *devinfo = igb->dip;
946 struct e1000_hw *hw = &igb->hw;
947 struct igb_osdep *osdep = &igb->osdep;
948 off_t mem_size;
949
950 /*
951 * First get the size of device registers to be mapped.
1330 if (igb_init_mac_address(igb) != IGB_SUCCESS) {
1331 igb_error(igb, "Failed to initialize MAC address");
1332 goto init_adapter_fail;
1333 }
1334
1335 /*
1336 * Packet Buffer Allocation (PBA)
1337 * Writing PBA sets the receive portion of the buffer
1338 * the remainder is used for the transmit buffer.
1339 */
1340 switch (hw->mac.type) {
1341 case e1000_82575:
1342 pba = E1000_PBA_32K;
1343 break;
1344 case e1000_82576:
1345 pba = E1000_READ_REG(hw, E1000_RXPBS);
1346 pba &= E1000_RXPBS_SIZE_MASK_82576;
1347 break;
1348 case e1000_82580:
1349 case e1000_i350:
1350 case e1000_i354:
1351 pba = E1000_READ_REG(hw, E1000_RXPBS);
1352 pba = e1000_rxpbs_adjust_82580(pba);
1353 break;
1354 case e1000_i210:
1355 case e1000_i211:
1356 pba = E1000_PBA_34K;
1357 default:
1358 break;
1359 }
1360
1361 /* Special needs in case of Jumbo frames */
1362 default_mtu = igb_get_prop(igb, PROP_DEFAULT_MTU,
1363 MIN_MTU, MAX_MTU, DEFAULT_MTU);
1364 if ((hw->mac.type == e1000_82575) && (default_mtu > ETHERMTU)) {
1365 u32 tx_space, min_tx, min_rx;
1366 pba = E1000_READ_REG(hw, E1000_PBA);
1367 tx_space = pba >> 16;
1368 pba &= 0xffff;
1369 min_tx = (igb->max_frame_size +
1370 sizeof (struct e1000_tx_desc) - ETHERNET_FCS_SIZE) * 2;
1848
1849 /*
1850 * Setup the rx/tx rings
1851 */
1852 igb_setup_rings(igb);
1853
1854 /*
1855 * Enable adapter interrupts
1856 * The interrupts must be enabled after the driver state is START
1857 */
1858 igb->capab->enable_intr(igb);
1859
1860 if (igb_check_acc_handle(igb->osdep.cfg_handle) != DDI_FM_OK)
1861 goto start_failure;
1862
1863 if (igb_check_acc_handle(igb->osdep.reg_handle) != DDI_FM_OK)
1864 goto start_failure;
1865
1866 if (igb->hw.mac.type == e1000_i350)
1867 (void) e1000_set_eee_i350(&igb->hw);
1868 else if (igb->hw.mac.type == e1000_i354)
1869 (void) e1000_set_eee_i354(&igb->hw);
1870
1871 for (i = igb->num_tx_rings - 1; i >= 0; i--)
1872 mutex_exit(&igb->tx_rings[i].tx_lock);
1873 for (i = igb->num_rx_rings - 1; i >= 0; i--)
1874 mutex_exit(&igb->rx_rings[i].rx_lock);
1875
1876 return (IGB_SUCCESS);
1877
1878 start_failure:
1879 for (i = igb->num_tx_rings - 1; i >= 0; i--)
1880 mutex_exit(&igb->tx_rings[i].tx_lock);
1881 for (i = igb->num_rx_rings - 1; i >= 0; i--)
1882 mutex_exit(&igb->rx_rings[i].rx_lock);
1883
1884 ddi_fm_service_impact(igb->dip, DDI_SERVICE_LOST);
1885
1886 return (IGB_FAILURE);
1887 }
1888
1889 /*
|