Lines Matching refs:softc
860 static void adasetflags(struct ada_softc *softc,
862 static void adasetgeom(struct ada_softc *softc,
865 static void ada_dsmtrim(struct ada_softc *softc, struct bio *bp,
867 static void ada_cfaerase(struct ada_softc *softc, struct bio *bp,
912 #define ADA_RA (softc->read_ahead >= 0 ? \
913 softc->read_ahead : ada_read_ahead)
914 #define ADA_WC (softc->write_cache >= 0 ? \
915 softc->write_cache : ada_write_cache)
980 struct ada_softc *softc; in adaopen() local
998 softc = (struct ada_softc *)periph->softc; in adaopen()
999 softc->flags |= ADA_FLAG_OPEN; in adaopen()
1010 struct ada_softc *softc; in adaclose() local
1015 softc = (struct ada_softc *)periph->softc; in adaclose()
1022 if ((softc->flags & ADA_FLAG_DIRTY) != 0 && in adaclose()
1023 (softc->flags & ADA_FLAG_CAN_FLUSHCACHE) != 0 && in adaclose()
1036 if (softc->flags & ADA_FLAG_CAN_48BIT) in adaclose()
1041 /*sense_flags*/0, softc->disk->d_devstat); in adaclose()
1045 softc->flags &= ~ADA_FLAG_DIRTY; in adaclose()
1050 softc->flags &= ~ADA_FLAG_OPEN; in adaclose()
1052 while (softc->refcount != 0) in adaclose()
1053 cam_periph_sleep(periph, &softc->refcount, PRIBIO, "adaclose", 1); in adaclose()
1062 struct ada_softc *softc = (struct ada_softc *)periph->softc; in adaschedule() local
1064 if (softc->state != ADA_STATE_NORMAL) in adaschedule()
1067 cam_iosched_schedule(softc->cam_iosched, periph); in adaschedule()
1079 struct ada_softc *softc; in adastrategy() local
1082 softc = (struct ada_softc *)periph->softc; in adastrategy()
1108 cam_iosched_queue_work(softc->cam_iosched, bp); in adastrategy()
1123 struct ada_softc *softc; in adadump() local
1133 softc = (struct ada_softc *)periph->softc; in adadump()
1134 secsize = softc->params.secsize; in adadump()
1152 if ((softc->flags & ADA_FLAG_CAN_48BIT) && in adadump()
1169 if (softc->flags & ADA_FLAG_CAN_FLUSHCACHE) { in adadump()
1187 if (softc->flags & ADA_FLAG_CAN_48BIT) in adadump()
1248 struct ada_softc *softc; in adaoninvalidate() local
1250 softc = (struct ada_softc *)periph->softc; in adaoninvalidate()
1257 softc->invalidations++; in adaoninvalidate()
1266 cam_iosched_flush(softc->cam_iosched, NULL, ENXIO); in adaoninvalidate()
1272 disk_gone(softc->disk); in adaoninvalidate()
1278 struct ada_softc *softc; in adacleanup() local
1280 softc = (struct ada_softc *)periph->softc; in adacleanup()
1284 cam_iosched_fini(softc->cam_iosched); in adacleanup()
1289 if ((softc->flags & ADA_FLAG_SCTX_INIT) != 0) { in adacleanup()
1291 if (sysctl_ctx_free(&softc->sysctl_stats_ctx) != 0) in adacleanup()
1295 if (sysctl_ctx_free(&softc->sysctl_ctx) != 0) in adacleanup()
1300 disk_destroy(softc->disk); in adacleanup()
1301 callout_drain(&softc->sendordered_c); in adacleanup()
1302 free(softc, M_DEVBUF); in adacleanup()
1307 adasetdeletemethod(struct ada_softc *softc) in adasetdeletemethod() argument
1310 if (softc->flags & ADA_FLAG_CAN_NCQ_TRIM) in adasetdeletemethod()
1311 softc->delete_method = ADA_DELETE_NCQ_DSM_TRIM; in adasetdeletemethod()
1312 else if (softc->flags & ADA_FLAG_CAN_TRIM) in adasetdeletemethod()
1313 softc->delete_method = ADA_DELETE_DSM_TRIM; in adasetdeletemethod()
1314 else if ((softc->flags & ADA_FLAG_CAN_CFA) && !(softc->flags & ADA_FLAG_CAN_48BIT)) in adasetdeletemethod()
1315 softc->delete_method = ADA_DELETE_CFA_ERASE; in adasetdeletemethod()
1317 softc->delete_method = ADA_DELETE_NONE; in adasetdeletemethod()
1326 struct ada_softc *softc; in adaasync() local
1361 softc = (struct ada_softc *)periph->softc; in adaasync()
1370 adasetflags(softc, &cgd); in adaasync()
1371 adasetgeom(softc, &cgd); in adaasync()
1372 disk_resize(softc->disk, M_NOWAIT); in adaasync()
1381 struct ada_softc *softc; in adaasync() local
1383 softc = periph->softc; in adaasync()
1384 disk_attr_changed(softc->disk, "GEOM::physpath", in adaasync()
1392 softc = (struct ada_softc *)periph->softc; in adaasync()
1393 if (softc->state != ADA_STATE_NORMAL) in adaasync()
1395 if (ADA_RA >= 0 && softc->flags & ADA_FLAG_CAN_RAHEAD) in adaasync()
1396 softc->state = ADA_STATE_RAHEAD; in adaasync()
1397 else if (ADA_WC >= 0 && softc->flags & ADA_FLAG_CAN_WCACHE) in adaasync()
1398 softc->state = ADA_STATE_WCACHE; in adaasync()
1399 else if ((softc->flags & ADA_FLAG_CAN_LOG) in adaasync()
1400 && (softc->zone_mode != ADA_ZONE_NONE)) in adaasync()
1401 softc->state = ADA_STATE_LOGDIR; in adaasync()
1405 softc->state = ADA_STATE_NORMAL; in adaasync()
1420 struct ada_softc *softc; in adazonemodesysctl() local
1423 softc = (struct ada_softc *)arg1; in adazonemodesysctl()
1425 switch (softc->zone_mode) { in adazonemodesysctl()
1449 struct ada_softc *softc; in adazonesupsysctl() local
1454 softc = (struct ada_softc *)arg1; in adazonesupsysctl()
1461 if (softc->zone_flags & ada_zone_desc_table[i].value) { in adazonesupsysctl()
1482 struct ada_softc *softc; in adasysctlinit() local
1493 softc = (struct ada_softc *)periph->softc; in adasysctlinit()
1497 sysctl_ctx_init(&softc->sysctl_ctx); in adasysctlinit()
1498 softc->flags |= ADA_FLAG_SCTX_INIT; in adasysctlinit()
1499 softc->sysctl_tree = SYSCTL_ADD_NODE_WITH_LABEL(&softc->sysctl_ctx, in adasysctlinit()
1502 if (softc->sysctl_tree == NULL) { in adasysctlinit()
1508 SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), in adasysctlinit()
1511 softc, 0, adadeletemethodsysctl, "A", in adasysctlinit()
1513 SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, in adasysctlinit()
1514 SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, in adasysctlinit()
1515 "trim_count", CTLFLAG_RD, &softc->trim_count, in adasysctlinit()
1517 SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, in adasysctlinit()
1518 SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, in adasysctlinit()
1519 "trim_ranges", CTLFLAG_RD, &softc->trim_ranges, in adasysctlinit()
1521 SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, in adasysctlinit()
1522 SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, in adasysctlinit()
1523 "trim_lbas", CTLFLAG_RD, &softc->trim_lbas, in adasysctlinit()
1525 SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), in adasysctlinit()
1527 &softc->read_ahead, 0, "Enable disk read ahead."); in adasysctlinit()
1528 SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), in adasysctlinit()
1530 &softc->write_cache, 0, "Enable disk write cache."); in adasysctlinit()
1531 SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), in adasysctlinit()
1534 softc, 0, adazonemodesysctl, "A", in adasysctlinit()
1536 SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), in adasysctlinit()
1539 softc, 0, adazonesupsysctl, "A", in adasysctlinit()
1541 SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, in adasysctlinit()
1542 SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, in adasysctlinit()
1543 "optimal_seq_zones", CTLFLAG_RD, &softc->optimal_seq_zones, in adasysctlinit()
1545 SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, in adasysctlinit()
1546 SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, in adasysctlinit()
1548 &softc->optimal_nonseq_zones, in adasysctlinit()
1551 SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, in adasysctlinit()
1552 SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, in adasysctlinit()
1553 "max_seq_zones", CTLFLAG_RD, &softc->max_seq_zones, in adasysctlinit()
1555 SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), in adasysctlinit()
1557 softc, 0, adaflagssysctl, "A", in adasysctlinit()
1559 SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), in adasysctlinit()
1561 &softc->flags, (u_int)ADA_FLAG_UNMAPPEDIO, adabitsysctl, "I", in adasysctlinit()
1563 SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), in adasysctlinit()
1565 &softc->flags, (u_int)ADA_FLAG_ROTATING, adabitsysctl, "I", in adasysctlinit()
1574 SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), in adasysctlinit()
1576 &softc->force_read_error, 0, in adasysctlinit()
1578 SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), in adasysctlinit()
1580 &softc->force_write_error, 0, in adasysctlinit()
1582 SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), in adasysctlinit()
1584 &softc->periodic_read_error, 0, in adasysctlinit()
1586 SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), in adasysctlinit()
1593 softc->sysctl_stats_tree = SYSCTL_ADD_NODE(&softc->sysctl_stats_ctx, in adasysctlinit()
1594 SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "stats", in adasysctlinit()
1596 SYSCTL_ADD_INT(&softc->sysctl_stats_ctx, in adasysctlinit()
1597 SYSCTL_CHILDREN(softc->sysctl_stats_tree), in adasysctlinit()
1599 &softc->timeouts, 0, in adasysctlinit()
1601 SYSCTL_ADD_INT(&softc->sysctl_stats_ctx, in adasysctlinit()
1602 SYSCTL_CHILDREN(softc->sysctl_stats_tree), in adasysctlinit()
1604 &softc->errors, 0, in adasysctlinit()
1606 SYSCTL_ADD_INT(&softc->sysctl_stats_ctx, in adasysctlinit()
1607 SYSCTL_CHILDREN(softc->sysctl_stats_tree), in adasysctlinit()
1609 &softc->invalidations, 0, in adasysctlinit()
1613 cam_iosched_sysctl_init(softc->cam_iosched, &softc->sysctl_ctx, in adasysctlinit()
1614 softc->sysctl_tree); in adasysctlinit()
1643 struct ada_softc *softc; in adadeletemethodsysctl() local
1646 softc = (struct ada_softc *)arg1; in adadeletemethodsysctl()
1648 value = softc->delete_method; in adadeletemethodsysctl()
1658 if ((softc->flags & ADA_FLAG_CAN_CFA) && in adadeletemethodsysctl()
1659 !(softc->flags & ADA_FLAG_CAN_48BIT)) in adadeletemethodsysctl()
1661 if (softc->flags & ADA_FLAG_CAN_TRIM) in adadeletemethodsysctl()
1663 if (softc->flags & ADA_FLAG_CAN_NCQ_TRIM) in adadeletemethodsysctl()
1669 softc->delete_method = i; in adadeletemethodsysctl()
1694 struct ada_softc *softc = arg1; in adaflagssysctl() local
1698 if (softc->flags != 0) in adaflagssysctl()
1699 sbuf_printf(&sbuf, "0x%b", (unsigned)softc->flags, ADA_FLAG_STRING); in adaflagssysctl()
1709 adasetflags(struct ada_softc *softc, struct ccb_getdev *cgd) in adasetflags() argument
1713 softc->flags |= ADA_FLAG_CAN_DMA; in adasetflags()
1715 softc->flags &= ~ADA_FLAG_CAN_DMA; in adasetflags()
1718 softc->flags |= ADA_FLAG_CAN_48BIT; in adasetflags()
1720 softc->flags |= ADA_FLAG_CAN_DMA48; in adasetflags()
1722 softc->flags &= ~ADA_FLAG_CAN_DMA48; in adasetflags()
1724 softc->flags &= ~(ADA_FLAG_CAN_48BIT | ADA_FLAG_CAN_DMA48); in adasetflags()
1727 softc->flags |= ADA_FLAG_CAN_FLUSHCACHE; in adasetflags()
1729 softc->flags &= ~ADA_FLAG_CAN_FLUSHCACHE; in adasetflags()
1732 softc->flags |= ADA_FLAG_CAN_POWERMGT; in adasetflags()
1734 softc->flags &= ~ADA_FLAG_CAN_POWERMGT; in adasetflags()
1738 softc->flags |= ADA_FLAG_CAN_NCQ; in adasetflags()
1740 softc->flags &= ~ADA_FLAG_CAN_NCQ; in adasetflags()
1744 (softc->quirks & ADA_Q_NO_TRIM) == 0) { in adasetflags()
1745 softc->flags |= ADA_FLAG_CAN_TRIM; in adasetflags()
1746 softc->trim_max_ranges = TRIM_MAX_RANGES; in adasetflags()
1748 softc->trim_max_ranges = in adasetflags()
1750 ATA_DSM_BLK_RANGES, softc->trim_max_ranges); in adasetflags()
1759 if ((softc->quirks & ADA_Q_NCQ_TRIM_BROKEN) == 0 && in adasetflags()
1760 (softc->flags & ADA_FLAG_PIM_ATA_EXT) != 0 && in adasetflags()
1763 (softc->flags & ADA_FLAG_CAN_TRIM) != 0) in adasetflags()
1764 softc->flags |= ADA_FLAG_CAN_NCQ_TRIM; in adasetflags()
1766 softc->flags &= ~ADA_FLAG_CAN_NCQ_TRIM; in adasetflags()
1768 softc->flags &= ~(ADA_FLAG_CAN_TRIM | ADA_FLAG_CAN_NCQ_TRIM); in adasetflags()
1771 softc->flags |= ADA_FLAG_CAN_CFA; in adasetflags()
1773 softc->flags &= ~ADA_FLAG_CAN_CFA; in adasetflags()
1779 adasetdeletemethod(softc); in adasetflags()
1782 && ((softc->quirks & ADA_Q_LOG_BROKEN) == 0)) in adasetflags()
1783 softc->flags |= ADA_FLAG_CAN_LOG; in adasetflags()
1785 softc->flags &= ~ADA_FLAG_CAN_LOG; in adasetflags()
1789 softc->zone_mode = ADA_ZONE_HOST_AWARE; in adasetflags()
1792 || (softc->quirks & ADA_Q_SMR_DM)) in adasetflags()
1793 softc->zone_mode = ADA_ZONE_DRIVE_MANAGED; in adasetflags()
1795 softc->zone_mode = ADA_ZONE_NONE; in adasetflags()
1798 softc->flags |= ADA_FLAG_CAN_RAHEAD; in adasetflags()
1800 softc->flags &= ~ADA_FLAG_CAN_RAHEAD; in adasetflags()
1803 softc->flags |= ADA_FLAG_CAN_WCACHE; in adasetflags()
1805 softc->flags &= ~ADA_FLAG_CAN_WCACHE; in adasetflags()
1811 struct ada_softc *softc; in adaregister() local
1825 softc = (struct ada_softc *)malloc(sizeof(*softc), M_DEVBUF, in adaregister()
1828 if (softc == NULL) { in adaregister()
1834 announce_buf = softc->announce_temp; in adaregister()
1837 periph->softc = softc; in adaregister()
1838 xpt_path_inq(&softc->cpi, periph->path); in adaregister()
1848 softc->quirks = ((struct ada_quirk_entry *)match)->quirks; in adaregister()
1850 softc->quirks = ADA_Q_NONE; in adaregister()
1852 TASK_INIT(&softc->sysctl_task, 0, adasysctlinit, periph); in adaregister()
1863 quirks = softc->quirks; in adaregister()
1865 softc->quirks = quirks; in adaregister()
1866 softc->read_ahead = -1; in adaregister()
1869 TUNABLE_INT_FETCH(announce_buf, &softc->read_ahead); in adaregister()
1870 softc->write_cache = -1; in adaregister()
1873 TUNABLE_INT_FETCH(announce_buf, &softc->write_cache); in adaregister()
1887 adasetflags(softc, cgd); in adaregister()
1888 if (softc->cpi.hba_misc & PIM_ATA_EXT) in adaregister()
1889 softc->flags |= ADA_FLAG_PIM_ATA_EXT; in adaregister()
1893 softc->flags &= ~ADA_FLAG_ROTATING; in adaregister()
1895 softc->flags |= ADA_FLAG_ROTATING; in adaregister()
1897 softc->disk = disk_alloc(); in adaregister()
1898 adasetgeom(softc, cgd); in adaregister()
1899 softc->disk->d_devstat = devstat_new_entry(periph->periph_name, in adaregister()
1900 periph->unit_number, softc->params.secsize, in adaregister()
1903 XPORT_DEVSTAT_TYPE(softc->cpi.transport), in adaregister()
1905 softc->disk->d_open = adaopen; in adaregister()
1906 softc->disk->d_close = adaclose; in adaregister()
1907 softc->disk->d_strategy = adastrategy; in adaregister()
1908 softc->disk->d_getattr = adagetattr; in adaregister()
1910 softc->disk->d_dump = adadump; in adaregister()
1911 softc->disk->d_gone = adadiskgonecb; in adaregister()
1912 softc->disk->d_name = "ada"; in adaregister()
1913 softc->disk->d_drv1 = periph; in adaregister()
1914 softc->disk->d_unit = periph->unit_number; in adaregister()
1916 if (cam_iosched_init(&softc->cam_iosched, periph, softc->disk, in adaregister()
1920 free(softc, M_DEVBUF); in adaregister()
1923 cam_iosched_set_sort_queue(softc->cam_iosched, in adaregister()
1924 (softc->flags & ADA_FLAG_ROTATING) ? -1 : 0); in adaregister()
1928 dp = &softc->params; in adaregister()
1934 sbuf_new(&sb, softc->announce_buffer, ADA_ANNOUNCE_SZ, SBUF_FIXEDLEN); in adaregister()
1936 xpt_announce_quirks_sbuf(periph, &sb, softc->quirks, ADA_Q_BIT_STRING); in adaregister()
1945 taskqueue_enqueue(taskqueue_thread, &softc->sysctl_task); in adaregister()
1963 callout_init_mtx(&softc->sendordered_c, cam_periph_mtx(periph), 0); in adaregister()
1964 callout_reset_sbt(&softc->sendordered_c, in adaregister()
1966 adasendorderedtag, softc, C_PREL(1)); in adaregister()
1971 if (ADA_RA >= 0 && softc->flags & ADA_FLAG_CAN_RAHEAD) { in adaregister()
1972 softc->state = ADA_STATE_RAHEAD; in adaregister()
1973 } else if (ADA_WC >= 0 && softc->flags & ADA_FLAG_CAN_WCACHE) { in adaregister()
1974 softc->state = ADA_STATE_WCACHE; in adaregister()
1975 } else if ((softc->flags & ADA_FLAG_CAN_LOG) in adaregister()
1976 && (softc->zone_mode != ADA_ZONE_NONE)) { in adaregister()
1977 softc->state = ADA_STATE_LOGDIR; in adaregister()
1992 ada_dsmtrim_req_create(struct ada_softc *softc, struct bio *bp, struct trim_request *req) in ada_dsmtrim_req_create() argument
2001 int count = bp->bio_bcount / softc->params.secsize; in ada_dsmtrim_req_create()
2041 bp = cam_iosched_next_trim(softc->cam_iosched); in ada_dsmtrim_req_create()
2044 if (bp->bio_bcount / softc->params.secsize > in ada_dsmtrim_req_create()
2045 (softc->trim_max_ranges - ranges) * ATA_DSM_RANGE_MAX) { in ada_dsmtrim_req_create()
2046 cam_iosched_put_back_trim(softc->cam_iosched, bp); in ada_dsmtrim_req_create()
2050 softc->trim_count++; in ada_dsmtrim_req_create()
2051 softc->trim_ranges += ranges; in ada_dsmtrim_req_create()
2052 softc->trim_lbas += lbas; in ada_dsmtrim_req_create()
2058 ada_dsmtrim(struct ada_softc *softc, struct bio *bp, struct ccb_ataio *ataio) in ada_dsmtrim() argument
2060 struct trim_request *req = &softc->trim_req; in ada_dsmtrim()
2063 ranges = ada_dsmtrim_req_create(softc, bp, req); in ada_dsmtrim()
2077 ada_ncq_dsmtrim(struct ada_softc *softc, struct bio *bp, struct ccb_ataio *ataio) in ada_ncq_dsmtrim() argument
2079 struct trim_request *req = &softc->trim_req; in ada_ncq_dsmtrim()
2082 ranges = ada_dsmtrim_req_create(softc, bp, req); in ada_ncq_dsmtrim()
2101 ada_cfaerase(struct ada_softc *softc, struct bio *bp, struct ccb_ataio *ataio) in ada_cfaerase() argument
2103 struct trim_request *req = &softc->trim_req; in ada_cfaerase()
2105 uint16_t count = bp->bio_bcount / softc->params.secsize; in ada_cfaerase()
2146 struct ada_softc *softc; in ada_zone_cmd() local
2156 softc = periph->softc; in ada_zone_cmd()
2185 /*use_ncq*/ (softc->flags & in ada_zone_cmd()
2214 alloc_size = min(alloc_size, softc->disk->d_maxsize); in ada_zone_cmd()
2226 /*use_ncq*/ (softc->flags & in ada_zone_cmd()
2271 switch (softc->zone_mode) { in ada_zone_cmd()
2287 if (softc->zone_flags & ADA_ZONE_FLAG_URSWRZ) in ada_zone_cmd()
2290 if (softc->zone_flags & ADA_ZONE_FLAG_OPT_SEQ_SET) { in ada_zone_cmd()
2291 params->optimal_seq_zones = softc->optimal_seq_zones; in ada_zone_cmd()
2295 if (softc->zone_flags & ADA_ZONE_FLAG_OPT_NONSEQ_SET) { in ada_zone_cmd()
2297 softc->optimal_nonseq_zones; in ada_zone_cmd()
2301 if (softc->zone_flags & ADA_ZONE_FLAG_MAX_SEQ_SET) { in ada_zone_cmd()
2302 params->max_seq_zones = softc->max_seq_zones; in ada_zone_cmd()
2305 if (softc->zone_flags & ADA_ZONE_FLAG_RZ_SUP) in ada_zone_cmd()
2308 if (softc->zone_flags & ADA_ZONE_FLAG_OPEN_SUP) in ada_zone_cmd()
2311 if (softc->zone_flags & ADA_ZONE_FLAG_CLOSE_SUP) in ada_zone_cmd()
2314 if (softc->zone_flags & ADA_ZONE_FLAG_FINISH_SUP) in ada_zone_cmd()
2317 if (softc->zone_flags & ADA_ZONE_FLAG_RWP_SUP) in ada_zone_cmd()
2331 struct ada_softc *softc = (struct ada_softc *)periph->softc; in adastart() local
2336 switch (softc->state) { in adastart()
2342 bp = cam_iosched_next_bio(softc->cam_iosched); in adastart()
2349 (bp->bio_cmd != BIO_DELETE && (softc->flags & ADA_FLAG_NEED_OTAG) != 0)) { in adastart()
2350 softc->flags &= ~ADA_FLAG_NEED_OTAG; in adastart()
2351 softc->flags |= ADA_FLAG_WAS_OTAG; in adastart()
2361 uint16_t count = bp->bio_bcount / softc->params.secsize; in adastart()
2366 softc->flags |= ADA_FLAG_DIRTY; in adastart()
2391 if (softc->force_read_error) { in adastart()
2392 softc->force_read_error--; in adastart()
2395 if (softc->periodic_read_error > 0) { in adastart()
2396 if (++softc->periodic_read_count >= in adastart()
2397 softc->periodic_read_error) { in adastart()
2398 softc->periodic_read_count = 0; in adastart()
2403 if (softc->force_write_error) { in adastart()
2404 softc->force_write_error--; in adastart()
2428 if ((softc->flags & ADA_FLAG_CAN_NCQ) && tag_code) { in adastart()
2436 } else if ((softc->flags & ADA_FLAG_CAN_48BIT) && in adastart()
2439 if (softc->flags & ADA_FLAG_CAN_DMA48) { in adastart()
2459 if (softc->flags & ADA_FLAG_CAN_DMA) { in adastart()
2480 switch (softc->delete_method) { in adastart()
2482 ada_ncq_dsmtrim(softc, bp, ataio); in adastart()
2485 ada_dsmtrim(softc, bp, ataio); in adastart()
2488 ada_cfaerase(softc, bp, ataio); in adastart()
2498 cam_iosched_submit_trim(softc->cam_iosched); in adastart()
2510 if (softc->flags & ADA_FLAG_CAN_48BIT) in adastart()
2547 softc->outstanding_cmds++; in adastart()
2548 softc->refcount++; in adastart()
2569 if (softc->state == ADA_STATE_RAHEAD) { in adastart()
2586 if ((softc->flags & ADA_FLAG_CAN_LOG) == 0) { in adastart()
2595 softc->state = ADA_STATE_NORMAL; in adastart()
2606 /*protocol*/ softc->flags & ADA_FLAG_CAN_DMA ? in adastart()
2634 /*protocol*/ softc->flags & ADA_FLAG_CAN_DMA ? in adastart()
2662 /*protocol*/ softc->flags & ADA_FLAG_CAN_DMA ? in adastart()
2690 /*protocol*/ softc->flags & ADA_FLAG_CAN_DMA ? in adastart()
2706 struct ada_softc *softc; in adaprobedone() local
2708 softc = (struct ada_softc *)periph->softc; in adaprobedone()
2719 softc->state = ADA_STATE_NORMAL; in adaprobedone()
2720 softc->flags |= ADA_FLAG_PROBED; in adaprobedone()
2722 if ((softc->flags & ADA_FLAG_ANNOUNCED) == 0) { in adaprobedone()
2723 softc->flags |= ADA_FLAG_ANNOUNCED; in adaprobedone()
2730 disk_create(softc->disk, DISK_VERSION); in adaprobedone()
2880 struct ada_softc *softc; in adadone() local
2886 softc = (struct ada_softc *)periph->softc; in adadone()
2925 (softc->flags & ADA_FLAG_CAN_NCQ_TRIM) != 0) { in adadone()
2926 softc->flags &= ~ADA_FLAG_CAN_NCQ_TRIM; in adadone()
2928 adasetdeletemethod(softc); in adadone()
2952 softc->outstanding_cmds--; in adadone()
2953 if (softc->outstanding_cmds == 0) in adadone()
2954 softc->flags |= ADA_FLAG_WAS_OTAG; in adadone()
2963 cam_iosched_bio_complete(softc->cam_iosched, bp, done_ccb); in adadone()
2965 KASSERT(softc->refcount >= 1, ("adadone softc %p refcount %d", softc, softc->refcount)); in adadone()
2966 softc->refcount--; in adadone()
2972 TAILQ_CONCAT(&queue, &softc->trim_req.bps, bio_queue); in adadone()
2983 cam_iosched_trim_done(softc->cam_iosched); in adadone()
3020 softc->state = ADA_STATE_WCACHE; in adadone()
3045 if ((softc->flags & ADA_FLAG_CAN_LOG) in adadone()
3046 && (softc->zone_mode != ADA_ZONE_NONE)) { in adadone()
3048 softc->state = ADA_STATE_LOGDIR; in adadone()
3061 softc->valid_logdir_len = 0; in adadone()
3062 bzero(&softc->ata_logdir, sizeof(softc->ata_logdir)); in adadone()
3063 softc->valid_logdir_len = in adadone()
3065 if (softc->valid_logdir_len > 0) in adadone()
3066 bcopy(ataio->data_ptr, &softc->ata_logdir, in adadone()
3067 min(softc->valid_logdir_len, in adadone()
3068 sizeof(softc->ata_logdir))); in adadone()
3076 if ((softc->valid_logdir_len >= in adadone()
3078 && (le16dec(softc->ata_logdir.header) == in adadone()
3080 && (le16dec(&softc->ata_logdir.num_pages[ in adadone()
3083 softc->flags |= ADA_FLAG_CAN_IDLOG; in adadone()
3085 softc->flags &= ~ADA_FLAG_CAN_IDLOG; in adadone()
3099 softc->flags &= ~(ADA_FLAG_CAN_LOG | in adadone()
3116 && (softc->flags & ADA_FLAG_CAN_IDLOG)) { in adadone()
3117 softc->state = ADA_STATE_IDDIR; in adadone()
3132 softc->valid_iddir_len = 0; in adadone()
3133 bzero(&softc->ata_iddir, sizeof(softc->ata_iddir)); in adadone()
3134 softc->flags &= ~(ADA_FLAG_CAN_SUPCAP | in adadone()
3136 softc->valid_iddir_len = in adadone()
3138 if (softc->valid_iddir_len > 0) in adadone()
3139 bcopy(ataio->data_ptr, &softc->ata_iddir, in adadone()
3140 min(softc->valid_iddir_len, in adadone()
3141 sizeof(softc->ata_iddir))); in adadone()
3145 max_entries = softc->valid_iddir_len - entries_offset; in adadone()
3146 if ((softc->valid_iddir_len > (entries_offset + 1)) in adadone()
3147 && (le64dec(softc->ata_iddir.header) == in adadone()
3149 && (softc->ata_iddir.entry_count > 0)) { in adadone()
3152 num_entries = softc->ata_iddir.entry_count; in adadone()
3154 softc->valid_iddir_len - entries_offset); in adadone()
3157 if (softc->ata_iddir.entries[i] == in adadone()
3159 softc->flags |= in adadone()
3161 else if (softc->ata_iddir.entries[i]== in adadone()
3163 softc->flags |= in adadone()
3166 if ((softc->flags & in adadone()
3168 && (softc->flags & in adadone()
3186 softc->flags &= ~ADA_FLAG_CAN_IDLOG; in adadone()
3202 && (softc->flags & ADA_FLAG_CAN_SUPCAP)) { in adadone()
3203 softc->state = ADA_STATE_SUP_CAP; in adadone()
3237 softc->zone_mode = in adadone()
3241 softc->zone_mode = in adadone()
3248 softc->zone_flags |= in adadone()
3251 softc->zone_flags |= in adadone()
3254 softc->zone_flags |= in adadone()
3257 softc->zone_flags |= in adadone()
3260 softc->zone_flags |= in adadone()
3271 softc->zone_flags |= in adadone()
3286 softc->flags &= ~ADA_FLAG_CAN_SUPCAP; in adadone()
3290 softc->zone_flags &= ~ADA_ZONE_FLAG_SUP_MASK; in adadone()
3306 && (softc->flags & ADA_FLAG_CAN_ZONE)) { in adadone()
3307 softc->state = ADA_STATE_ZONE; in adadone()
3333 softc->zone_flags |= in adadone()
3336 softc->zone_flags &= in adadone()
3341 softc->zone_flags |= in adadone()
3343 softc->optimal_seq_zones = (tmpvar & in adadone()
3346 softc->zone_flags &= in adadone()
3348 softc->optimal_seq_zones = 0; in adadone()
3353 softc->zone_flags |= in adadone()
3355 softc->optimal_nonseq_zones = in adadone()
3358 softc->zone_flags &= in adadone()
3360 softc->optimal_nonseq_zones = 0; in adadone()
3365 softc->zone_flags |= in adadone()
3367 softc->max_seq_zones = in adadone()
3370 softc->zone_flags &= in adadone()
3372 softc->max_seq_zones = 0; in adadone()
3381 softc->flags &= ~ADA_FLAG_CAN_ZONE; in adadone()
3382 softc->flags &= ~ADA_ZONE_FLAG_SET_MASK; in adadone()
3413 struct ada_softc *softc; in adaerror() local
3417 softc = (struct ada_softc *)periph->softc; in adaerror()
3421 softc->timeouts++; in adaerror()
3429 softc->errors++; in adaerror()
3440 adasetgeom(struct ada_softc *softc, struct ccb_getdev *cgd) in adasetgeom() argument
3442 struct disk_params *dp = &softc->params; in adasetgeom()
3480 maxio = softc->cpi.maxio; /* Honor max I/O size of SIM */ in adasetgeom()
3485 if (softc->flags & ADA_FLAG_CAN_48BIT) in adasetgeom()
3486 maxio = min(maxio, 65536 * softc->params.secsize); in adasetgeom()
3488 maxio = min(maxio, 256 * softc->params.secsize); in adasetgeom()
3489 if (softc->quirks & ADA_Q_128KB) in adasetgeom()
3491 softc->disk->d_maxsize = maxio; in adasetgeom()
3493 if (softc->flags & ADA_FLAG_CAN_FLUSHCACHE) in adasetgeom()
3495 if (softc->flags & ADA_FLAG_CAN_TRIM) { in adasetgeom()
3497 softc->disk->d_delmaxsize = softc->params.secsize * in adasetgeom()
3498 ATA_DSM_RANGE_MAX * softc->trim_max_ranges; in adasetgeom()
3499 } else if ((softc->flags & ADA_FLAG_CAN_CFA) && in adasetgeom()
3500 !(softc->flags & ADA_FLAG_CAN_48BIT)) { in adasetgeom()
3502 softc->disk->d_delmaxsize = 256 * softc->params.secsize; in adasetgeom()
3504 softc->disk->d_delmaxsize = maxio; in adasetgeom()
3505 if ((softc->cpi.hba_misc & PIM_UNMAPPED) != 0) { in adasetgeom()
3507 softc->flags |= ADA_FLAG_UNMAPPEDIO; in adasetgeom()
3509 softc->disk->d_flags = d_flags; in adasetgeom()
3520 tmpsize = MIN(sizeof(softc->disk->d_descr) - 1, in adasetgeom()
3522 memcpy(softc->disk->d_descr, cgd->ident_data.model, tmpsize); in adasetgeom()
3523 softc->disk->d_descr[tmpsize] = '\0'; in adasetgeom()
3525 tmpsize = MIN(sizeof(softc->disk->d_ident) - 1, in adasetgeom()
3527 memcpy(softc->disk->d_ident, cgd->ident_data.serial, tmpsize); in adasetgeom()
3528 softc->disk->d_ident[tmpsize] = '\0'; in adasetgeom()
3530 softc->disk->d_sectorsize = softc->params.secsize; in adasetgeom()
3531 softc->disk->d_mediasize = (off_t)softc->params.sectors * in adasetgeom()
3532 softc->params.secsize; in adasetgeom()
3534 softc->params.secsize) { in adasetgeom()
3535 softc->disk->d_stripesize = in adasetgeom()
3537 softc->disk->d_stripeoffset = (softc->disk->d_stripesize - in adasetgeom()
3539 softc->disk->d_stripesize; in adasetgeom()
3540 } else if (softc->quirks & ADA_Q_4K) { in adasetgeom()
3541 softc->disk->d_stripesize = 4096; in adasetgeom()
3542 softc->disk->d_stripeoffset = 0; in adasetgeom()
3544 softc->disk->d_fwsectors = softc->params.secs_per_track; in adasetgeom()
3545 softc->disk->d_fwheads = softc->params.heads; in adasetgeom()
3546 softc->disk->d_rotation_rate = cgd->ident_data.media_rotation_rate; in adasetgeom()
3547 snprintf(softc->disk->d_attachment, sizeof(softc->disk->d_attachment), in adasetgeom()
3548 "%s%d", softc->cpi.dev_name, softc->cpi.unit_number); in adasetgeom()
3554 struct ada_softc *softc = arg; in adasendorderedtag() local
3557 if (softc->outstanding_cmds > 0) { in adasendorderedtag()
3558 if ((softc->flags & ADA_FLAG_WAS_OTAG) == 0) in adasendorderedtag()
3559 softc->flags |= ADA_FLAG_NEED_OTAG; in adasendorderedtag()
3560 softc->flags &= ~ADA_FLAG_WAS_OTAG; in adasendorderedtag()
3565 callout_schedule_sbt(&softc->sendordered_c, in adasendorderedtag()
3578 struct ada_softc *softc; in adaflush() local
3583 softc = (struct ada_softc *)periph->softc; in adaflush()
3587 (softc->flags & ADA_FLAG_OPEN)) { in adaflush()
3588 adadump(softc->disk, NULL, 0, 0); in adaflush()
3597 if (((softc->flags & ADA_FLAG_OPEN) == 0) || in adaflush()
3598 (softc->flags & ADA_FLAG_CAN_FLUSHCACHE) == 0) { in adaflush()
3612 if (softc->flags & ADA_FLAG_CAN_48BIT) in adaflush()
3619 softc->disk->d_devstat); in adaflush()
3631 struct ada_softc *softc; in adaspindown() local
3641 softc = (struct ada_softc *)periph->softc; in adaspindown()
3645 if ((softc->flags & ADA_FLAG_CAN_POWERMGT) == 0) { in adaspindown()
3669 softc->disk->d_devstat); in adaspindown()
3714 softc->disk->d_devstat); in adaspindown()
3769 struct ada_softc *softc; in adaresume() local
3776 softc = (struct ada_softc *)periph->softc; in adaresume()
3780 if ((softc->flags & ADA_FLAG_CAN_POWERMGT) == 0) { in adaresume()