Lines Matching defs:chp
84 static void ch_free_dma_handles(ch_t *chp);
85 static void ch_set_name(ch_t *chp, int unit);
86 static void ch_free_name(ch_t *chp);
87 static void ch_get_prop(ch_t *chp);
90 static void ch_free_dvma_handles(ch_t *chp);
364 ch_t *chp;
399 chp = (ch_t *)kmem_zalloc(sizeof (ch_t), KM_SLEEP);
401 if (chp == NULL) {
402 PRINT(("zalloc of chp failed\n"));
412 gchp[unit] = chp;
415 PRINT(("attach macinfo: %p chp: %p\n", macinfo, chp));
417 chp->ch_dip = dip;
418 chp->ch_macp = macinfo;
419 chp->ch_unit = unit;
420 ch_set_name(chp, unit);
432 &chp->ch_hpci); /* ptr to data access handle */
441 chp->ch_name, rv);
443 ch_free_name(chp);
444 kmem_free(chp, sizeof (ch_t));
450 ch_get_prop(chp);
453 macinfo->gldm_private = (caddr_t)chp;
469 macinfo->gldm_maxpkt = chp->ch_mtu;
483 pci_config_put32(chp->ch_hpci, 0x44, 3);
484 pci_config_put32(chp->ch_hpci, 0x44, 0);
490 VendorID = pci_config_get16(chp->ch_hpci, 0);
491 DeviceID = pci_config_get16(chp->ch_hpci, 2);
492 SubDeviceID = pci_config_get16(chp->ch_hpci, 0x2e);
493 Command = pci_config_get16(chp->ch_hpci, 4);
502 &chp->ch_bar0, /* address of offset */
506 &chp->ch_hbar0); /* ptr to data access handle */
516 chp->ch_name, rv);
518 pci_config_teardown(&chp->ch_hpci);
519 ch_free_name(chp);
520 kmem_free(chp, sizeof (ch_t));
527 Version = ddi_get32(chp->ch_hbar0,
528 (uint32_t *)(chp->ch_bar0+0x6c));
531 (void) ddi_dev_regsize(dip, 1, &chp->ch_bar0sz);
533 PRINT(("PCI BAR0 space addr: %p\n", chp->ch_bar0));
534 PRINT(("PCI BAR0 space size: %x\n", chp->ch_bar0sz));
543 &chp->ch_icookp); /* ptr to interrupt block cookie */
553 chp->ch_name, rv);
555 ddi_regs_map_free(&chp->ch_hbar0);
556 pci_config_teardown(&chp->ch_hpci);
557 ch_free_name(chp);
558 kmem_free(chp, sizeof (ch_t));
582 chp->ch_name, rv);
584 ddi_regs_map_free(&chp->ch_hbar0);
585 pci_config_teardown(&chp->ch_hpci);
586 ch_free_name(chp);
587 kmem_free(chp, sizeof (ch_t));
594 mutex_init(&chp->ch_lock, NULL, MUTEX_DRIVER,
595 (void *)chp->ch_icookp);
596 mutex_init(&chp->ch_intr, NULL, MUTEX_DRIVER,
597 (void *)chp->ch_icookp);
598 mutex_init(&chp->ch_mc_lck, NULL, MUTEX_DRIVER, NULL);
599 mutex_init(&chp->ch_dh_lck, NULL, MUTEX_DRIVER, NULL);
600 mutex_init(&chp->mac_lock, NULL, MUTEX_DRIVER, NULL);
604 if (pe_attach(chp)) {
611 chp->ch_name);
613 mutex_destroy(&chp->ch_lock);
614 mutex_destroy(&chp->ch_intr);
615 mutex_destroy(&chp->ch_mc_lck);
616 mutex_destroy(&chp->ch_dh_lck);
617 mutex_destroy(&chp->mac_lock);
618 ddi_remove_intr(dip, 0, chp->ch_icookp);
619 ddi_regs_map_free(&chp->ch_hbar0);
620 pci_config_teardown(&chp->ch_hpci);
621 ch_free_name(chp);
622 kmem_free(chp, sizeof (ch_t));
631 macinfo->gldm_vendor_addr = pe_get_mac(chp);
633 macinfo->gldm_cookie = chp->ch_icookp;
638 if (is_T2(chp)) {
639 if (chp->ch_config.cksum_enabled)
643 chp->ch_config.cksum_enabled = 0;
658 macinfo->gldm_maxpkt = chp->ch_mtu = 1500;
671 chp->ch_name, rv);
673 pe_detach(chp);
675 mutex_destroy(&chp->ch_lock);
676 mutex_destroy(&chp->ch_intr);
677 mutex_destroy(&chp->ch_mc_lck);
678 mutex_destroy(&chp->ch_dh_lck);
679 mutex_destroy(&chp->mac_lock);
680 ddi_remove_intr(dip, 0, chp->ch_icookp);
681 ddi_regs_map_free(&chp->ch_hbar0);
682 pci_config_teardown(&chp->ch_hpci);
683 ch_free_name(chp);
684 kmem_free(chp, sizeof (ch_t));
704 if ((chp = (ch_t *)ddi_get_driver_private(dip)) == NULL)
707 mutex_enter(&chp->ch_lock);
708 chp->ch_flags &= ~PESUSPENDED;
709 mutex_exit(&chp->ch_lock);
732 ch_t *chp;
736 chp = (ch_t *)macinfo->gldm_private;
741 gchp[chp->ch_unit] = NULL;
745 chp->ch_state = PEIDLE;
752 pci_config_put32(chp->ch_hpci, 0x44, 3);
753 pci_config_put32(chp->ch_hpci, 0x44, 0);
761 chp->ch_refcnt = 0;
762 chp->ch_state = PESTOP;
765 t1_interrupts_disable(chp);
768 t1_write_reg_4(chp->sge->obj, A_SG_CONTROL, 0x0);
769 t1_write_reg_4(chp->sge->obj, A_SG_INT_CAUSE, 0x0);
778 ch_t *chp;
782 chp = (ch_t *)macinfo->gldm_private;
790 mutex_enter(&chp->ch_lock);
791 if (chp->ch_refcnt > 0) {
792 mutex_exit(&chp->ch_lock);
795 mutex_exit(&chp->ch_lock);
796 gchp[chp->ch_unit] = NULL;
802 mutex_enter(&chp->ch_lock);
803 chp->ch_state = PEIDLE;
804 mutex_exit(&chp->ch_lock);
812 pci_config_put32(chp->ch_hpci, 0x44, 3);
813 pci_config_put32(chp->ch_hpci, 0x44, 0);
822 ddi_remove_intr(dip, 0, chp->ch_icookp);
827 pe_detach(chp);
829 ddi_regs_map_free(&chp->ch_hbar0);
830 pci_config_teardown(&chp->ch_hpci);
831 mutex_destroy(&chp->ch_lock);
832 mutex_destroy(&chp->ch_intr);
833 mutex_destroy(&chp->ch_mc_lck);
834 mutex_destroy(&chp->ch_dh_lck);
835 mutex_destroy(&chp->mac_lock);
836 ch_free_dma_handles(chp);
838 ch_free_dvma_handles(chp);
840 ch_free_name(chp);
841 kmem_free(chp, sizeof (ch_t));
850 if ((chp = (ch_t *)ddi_get_driver_private(dip)) == NULL)
852 mutex_enter(&chp->ch_lock);
853 chp->ch_flags |= PESUSPENDED;
854 mutex_exit(&chp->ch_lock);
870 * chp - per-board descriptor
880 ch_alloc_dma_mem(ch_t *chp, int type, int flags, int size, uint64_t *paddr,
900 align = chp->ch_sm_buf_aln;
902 align = chp->ch_bg_buf_aln;
905 chp->ch_name);
927 chp->ch_dip, /* device dev_info structure */
936 chp->ch_name, rv);
962 chp->ch_name, rv);
983 chp->ch_name, rv);
991 chp->ch_name, count);
1033 ch_get_dma_handle(ch_t *chp)
1056 chp->ch_dip, /* device dev_info */
1065 chp->ch_name, rv);
1081 ch_free_dma_handles(ch_t *chp)
1085 dhe = chp->ch_dh;
1092 chp->ch_dh = NULL;
1100 * chp - per-board descriptor
1108 ch_bind_dma_handle(ch_t *chp, int size, caddr_t vaddr, cmdQ_ce_t *cmp,
1118 mutex_enter(&chp->ch_dh_lck);
1119 if ((dhe = chp->ch_dh) != NULL) {
1120 chp->ch_dh = dhe->dhe_next;
1122 mutex_exit(&chp->ch_dh_lck);
1143 mutex_enter(&chp->ch_dh_lck);
1144 dhe->dhe_next = chp->ch_dh;
1145 chp->ch_dh = dhe;
1146 mutex_exit(&chp->ch_dh_lck);
1150 chp->ch_name, rv);
1160 mutex_enter(&chp->ch_dh_lck);
1161 dhe->dhe_next = chp->ch_dh;
1162 chp->ch_dh = dhe;
1163 mutex_exit(&chp->ch_dh_lck);
1199 ch_unbind_dma_handle(ch_t *chp, free_dh_t *dhe)
1205 chp->ch_name);
1207 mutex_enter(&chp->ch_dh_lck);
1208 dhe->dhe_next = chp->ch_dh;
1209 chp->ch_dh = dhe;
1210 mutex_exit(&chp->ch_dh_lck);
1224 ch_get_dvma_handle(ch_t *chp)
1241 chp->ch_dip, /* device dev_info */
1250 chp->ch_name, rv);
1268 ch_free_dvma_handles(ch_t *chp)
1272 dhe = chp->ch_vdh;
1279 chp->ch_vdh = NULL;
1288 * chp - per-board descriptor
1296 ch_bind_dvma_handle(ch_t *chp, int size, caddr_t vaddr, cmdQ_ce_t *cmp,
1304 mutex_enter(&chp->ch_dh_lck);
1305 if ((dhe = chp->ch_vdh) != NULL) {
1306 chp->ch_vdh = dhe->dhe_next;
1308 mutex_exit(&chp->ch_dh_lck);
1347 ch_unbind_dvma_handle(ch_t *chp, free_dh_t *dhe)
1353 mutex_enter(&chp->ch_dh_lck);
1354 dhe->dhe_next = chp->ch_vdh;
1355 chp->ch_vdh = dhe;
1356 mutex_exit(&chp->ch_dh_lck);
1367 ch_send_up(ch_t *chp, mblk_t *mp, uint32_t cksum, int flg)
1374 if (chp->ch_state == PERUNNING) {
1382 gld_recv(chp->ch_macp, mp);
1392 ch_gld_ok(ch_t *chp)
1394 gld_sched(chp->ch_macp);
1406 ch_t *chp;
1412 chp = (ch_t *)mp->gldm_private;
1414 if (chp == NULL) {
1430 if (chp->ch_hpci) {
1431 pci_config_put32(chp->ch_hpci, 0x44, 3);
1432 pci_config_put32(chp->ch_hpci, 0x44, 0);
1445 ch_t *chp = (ch_t *)macinfo->gldm_private;
1448 mutex_enter(&chp->ch_lock);
1449 chp->ch_refcnt++;
1450 if (chp->ch_refcnt == 1) {
1451 chp->ch_state = PERUNNING;
1452 mutex_exit(&chp->ch_lock);
1453 pe_init((void *)chp);
1455 mutex_exit(&chp->ch_lock);
1457 pe_init((void *)chp);
1460 mutex_enter(&chp->ch_lock);
1461 chp->ch_state = PERUNNING;
1462 mutex_exit(&chp->ch_lock);
1471 ch_t *chp = (ch_t *)mp->gldm_private;
1476 mutex_enter(&chp->ch_lock);
1477 if (chp->ch_state == PEIDLE) {
1478 mutex_exit(&chp->ch_lock);
1482 chp->ch_refcnt--;
1483 if (chp->ch_refcnt == 0) {
1484 chp->ch_state = PESTOP;
1485 mutex_exit(&chp->ch_lock);
1486 pe_stop(chp);
1488 mutex_exit(&chp->ch_lock);
1490 chp->ch_state = PESTOP;
1491 mutex_exit(&chp->ch_lock);
1492 pe_stop(chp);
1500 ch_t *chp;
1503 chp = (ch_t *)mp->gldm_private;
1508 pe_set_mac(chp, mac);
1516 ch_t *chp = (ch_t *)mp->gldm_private;
1518 return (pe_set_mc(chp, ep, flg));
1556 ch_t *chp = (ch_t *)mp->gldm_private;
1560 pe_set_promiscuous(chp, 2);
1564 pe_set_promiscuous(chp, 0);
1569 pe_set_promiscuous(chp, 1);
1579 ch_t *chp = (ch_t *)mp->gldm_private;
1606 if (chp->ch_state != PERUNNING) {
1610 (void) pe_get_stats(chp,
1673 ch_t *chp = (ch_t *)macinfo->gldm_private;
1689 if (chp->ch_state != PERUNNING) {
1694 if (chp->ch_config.cksum_enabled) {
1695 if (is_T2(chp)) {
1751 chp->sge->intr_cnt.tx_msg_pullups++;
1758 chp->sge->intr_cnt.tx_hdr_pullups++;
1773 chp->sge->intr_cnt.tx_udp_ip_frag++;
1776 chp->sge->intr_cnt.tx_tcp_ip_frag++;
1787 if (pe_start(chp, mp, flg))
1803 ch_set_name(ch_t *chp, int unit)
1805 chp->ch_name = (char *)kmem_alloc(sizeof ("chxge00"), KM_SLEEP);
1807 bcopy("chxge00", (void *)chp->ch_name, sizeof ("chxge00"));
1808 chp->ch_name[5] += unit/10;
1809 chp->ch_name[6] += unit%10;
1811 bcopy("chxge0", (void *)chp->ch_name, sizeof ("chxge0"));
1812 chp->ch_name[5] += unit;
1817 ch_free_name(ch_t *chp)
1819 if (chp->ch_name)
1820 kmem_free(chp->ch_name, sizeof ("chxge00"));
1821 chp->ch_name = NULL;
1832 ch_t *chp = gchp[unit];
1833 if (chp != NULL) {
1834 mutex_enter(&chp->ch_lock);
1836 chp->toe_rcv = (void (*)(void *, mblk_t *))toe_rcv;
1837 chp->ch_toeinst = instp;
1838 chp->toe_free = (void (*)(void *, tbuf_t *))toe_free;
1839 chp->toe_tunnel = (int (*)(void *, mblk_t *))toe_tunnel;
1840 chp->ch_tx_overflow_mutex = toe_tx_mx;
1841 chp->ch_tx_overflow_cv = toe_of_cv;
1842 chp->open_device_map |= TOEDEV_DEVMAP_BIT;
1845 chp->ch_refcnt++;
1846 if (chp->ch_refcnt == 1) {
1847 chp->ch_state = PERUNNING;
1848 mutex_exit(&chp->ch_lock);
1849 pe_init((void *)chp);
1851 mutex_exit(&chp->ch_lock);
1868 ch_t *chp;
1871 chp = gchp[i];
1872 if (chp == NULL)
1875 mutex_enter(&chp->ch_lock);
1877 chp->ch_refcnt--;
1878 if (chp->ch_refcnt == 0) {
1879 chp->ch_state = PESTOP;
1880 mutex_exit(&chp->ch_lock);
1881 pe_stop(chp);
1883 mutex_exit(&chp->ch_lock);
1885 chp->open_device_map &= ~TOEDEV_DEVMAP_BIT;
1886 chp->toe_rcv = NULL;
1887 chp->ch_toeinst = NULL;
1888 chp->toe_free = NULL;
1889 chp->toe_tunnel = NULL;
1890 chp->ch_tx_overflow_mutex = NULL;
1891 chp->ch_tx_overflow_cv = NULL;
1900 ch_get_prop(ch_t *chp)
1920 val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
1923 val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
1927 chp->ch_config.enable_dvma = 1;
1930 val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
1933 val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
1938 chp->ch_config.burstsize_set = 0;
1939 chp->ch_config.transaction_cnt_set = 0;
1948 pdip = ddi_get_parent(chp->ch_dip);
1955 chp->ch_config.burstsize_set = 0;
1956 chp->ch_config.transaction_cnt_set = 0;
1967 chp->ch_config.burstsize_set = 0;
1968 chp->ch_config.transaction_cnt_set = 0;
1979 chp->ch_config.burstsize_set = 0;
1980 chp->ch_config.transaction_cnt_set = 0;
1996 v = pci_config_get32(chp->ch_hpci, 0x64);
1998 chp->ch_config.burstsize_set = 0;
1999 chp->ch_config.transaction_cnt_set = 0;
2004 v = pci_config_get32(chp->ch_hpci, 0x60);
2012 chp->ch_config.burstsize_set = 0;
2013 chp->ch_config.transaction_cnt_set = 0;
2020 chp->ch_config.burstsize_set = 0;
2021 chp->ch_config.transaction_cnt_set = 0;
2028 chp->ch_config.burstsize_set = 0;
2029 chp->ch_config.transaction_cnt_set = 0;
2043 chp->ch_config.burstsize = 1;
2044 chp->ch_config.burstsize_set = 1;
2048 chp->ch_config.transaction_cnt = 1;
2049 chp->ch_config.transaction_cnt_set = 1;
2059 val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
2062 val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
2069 chp->ch_config.burstsize_set = 0;
2073 chp->ch_config.burstsize_set = 1;
2074 chp->ch_config.burstsize = 1;
2078 chp->ch_config.burstsize_set = 1;
2079 chp->ch_config.burstsize = 2;
2084 chp->ch_name, val);
2089 chp->ch_name, val);
2097 val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
2100 val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
2106 chp->ch_config.transaction_cnt_set = 0;
2110 chp->ch_config.transaction_cnt_set = 1;
2111 chp->ch_config.transaction_cnt = 0;
2115 chp->ch_config.transaction_cnt_set = 1;
2116 chp->ch_config.transaction_cnt = 1;
2120 chp->ch_config.transaction_cnt_set = 1;
2121 chp->ch_config.transaction_cnt = 2;
2125 chp->ch_config.transaction_cnt_set = 1;
2126 chp->ch_config.transaction_cnt = 3;
2130 chp->ch_config.transaction_cnt_set = 1;
2131 chp->ch_config.transaction_cnt = 4;
2135 chp->ch_config.transaction_cnt_set = 1;
2136 chp->ch_config.transaction_cnt = 5;
2140 chp->ch_config.transaction_cnt_set = 1;
2141 chp->ch_config.transaction_cnt = 6;
2145 chp->ch_config.transaction_cnt_set = 1;
2146 chp->ch_config.transaction_cnt = 7;
2151 chp->ch_name, val);
2159 val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
2162 val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
2168 chp->ch_config.relaxed_ordering = 0;
2172 chp->ch_config.relaxed_ordering = 1;
2175 val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
2178 val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
2186 chp->ch_maximum_mtu = 9198; /* tunable via chxge.conf */
2187 val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
2190 val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
2207 chp->ch_maximum_mtu = val;
2213 chp->ch_mtu = ETHERMTU;
2215 val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
2218 val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
2223 chp->ch_mtu = chp->ch_maximum_mtu;
2226 chp->ch_sm_buf_sz = 0x800;
2227 chp->ch_sm_buf_aln = 0x800;
2228 chp->ch_bg_buf_sz = 0x4000;
2229 chp->ch_bg_buf_aln = 0x4000;
2231 chp->ch_sm_buf_sz = 0x200;
2232 chp->ch_sm_buf_aln = 0x200;
2233 chp->ch_bg_buf_sz = 0x800;
2234 chp->ch_bg_buf_aln = 0x800;
2235 if ((chp->ch_mtu > 0x800) && (chp->ch_mtu <= 0x1000)) {
2236 chp->ch_sm_buf_sz = 0x400;
2237 chp->ch_sm_buf_aln = 0x400;
2238 chp->ch_bg_buf_sz = 0x1000;
2239 chp->ch_bg_buf_aln = 0x1000;
2240 } else if ((chp->ch_mtu > 0x1000) && (chp->ch_mtu <= 0x2000)) {
2241 chp->ch_sm_buf_sz = 0x400;
2242 chp->ch_sm_buf_aln = 0x400;
2243 chp->ch_bg_buf_sz = 0x2000;
2244 chp->ch_bg_buf_aln = 0x2000;
2245 } else if (chp->ch_mtu > 0x2000) {
2246 chp->ch_sm_buf_sz = 0x400;
2247 chp->ch_sm_buf_aln = 0x400;
2248 chp->ch_bg_buf_sz = 0x3000;
2249 chp->ch_bg_buf_aln = 0x4000;
2252 chp->ch_config.cksum_enabled = 1;
2254 val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
2257 val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
2261 chp->ch_config.cksum_enabled = 0;
2267 val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
2270 val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
2280 chp->ch_name);
2288 val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
2291 val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
2301 chp->ch_name);
2308 val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
2311 val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
2321 chp->ch_name);
2330 val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
2333 val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
2343 chp->ch_name);
2352 val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
2355 val = ddi_getprop(DDI_DEV_T_ANY, chp->ch_dip, DDI_PROP_DONTPASS,
2365 chp->ch_name);
2373 chp->ch_name, tval, tval);
2379 chp->ch_name);