From db4300da10a965c7478aea49f3283be7c284cb7d Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Fri, 9 May 2014 14:23:06 +0000 Subject: Multiple DWC OTG host mode related fixes and improvements: - Rework how we allocate and free USB host channels, so that we only allocate a channel if there is a real packet going out on the USB cable. - Use BULK type for control data and status, due to instabilities in the HW it appears. - Split FIFO TX levels into one for the periodic FIFO and one for the non-periodic FIFO. - Use correct HFNUM mask when scheduling host transactions. The HFNUM register does not count the full 16-bit range. - Correct START/COMPLETION slot for TT transactions. For INTERRUPT and ISOCHRONOUS type transactions the hardware always respects the ODDFRM bit, which means we need to allocate multiple host channels when processing such endpoints, to not miss any so-called complete split opportunities. - When doing ISOCHRONOUS OUT transfers through a TT send all data payload in a single ALL-burst. This deacreases the likelyhood for isochronous data underruns. - Fixed unbalanced unlock in case of "dwc_otg_init_fifo()" failure. - Increase interrupt priority. MFC after: 2 weeks --- sys/dev/usb/controller/dwc_otg.c | 1291 +++++++++++++++------------------- sys/dev/usb/controller/dwc_otg.h | 27 +- sys/dev/usb/controller/dwc_otg_fdt.c | 2 +- sys/dev/usb/controller/dwc_otgreg.h | 5 +- 4 files changed, 597 insertions(+), 728 deletions(-) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/dwc_otg.c b/sys/dev/usb/controller/dwc_otg.c index d8bf7ea39be70..3f4d3a00047c7 100644 --- a/sys/dev/usb/controller/dwc_otg.c +++ b/sys/dev/usb/controller/dwc_otg.c @@ -92,6 +92,9 @@ #define DWC_OTG_PC2SC(pc) \ DWC_OTG_BUS2SC(USB_DMATAG_TO_XROOT((pc)->tag_parent)->bus) +#define DWC_OTG_PC2UDEV(pc) \ + (USB_DMATAG_TO_XROOT((pc)->tag_parent)->udev) + #define DWC_OTG_MSK_GINT_ENABLED \ (GINTMSK_ENUMDONEMSK | \ GINTMSK_USBRSTMSK | \ @@ -136,8 +139,8 @@ static dwc_otg_cmd_t dwc_otg_host_data_rx; static void dwc_otg_device_done(struct usb_xfer *, usb_error_t); static void dwc_otg_do_poll(struct usb_bus *); static void dwc_otg_standard_done(struct usb_xfer *); -static void dwc_otg_root_intr(struct dwc_otg_softc *sc); -static void dwc_otg_interrupt_poll(struct dwc_otg_softc *sc); +static void dwc_otg_root_intr(struct dwc_otg_softc *); +static void dwc_otg_interrupt_poll(struct dwc_otg_softc *); /* * Here is a configuration that the chip supports. @@ -177,26 +180,33 @@ dwc_otg_init_fifo(struct dwc_otg_softc *sc, uint8_t mode) fifo_size = sc->sc_fifo_size; - fifo_regs = 4 * (sc->sc_dev_ep_max + sc->sc_dev_in_ep_max); + /* + * NOTE: Reserved fixed size area at end of RAM, which must + * not be allocated to the FIFOs: + */ + fifo_regs = 4 * 16; - if (fifo_size >= fifo_regs) - fifo_size -= fifo_regs; - else - fifo_size = 0; + if (fifo_size < fifo_regs) { + DPRINTF("Too little FIFO\n"); + return (EINVAL); + } + + /* subtract FIFO regs from total once */ + fifo_size -= fifo_regs; /* split equally for IN and OUT */ fifo_size /= 2; - DWC_OTG_WRITE_4(sc, DOTG_GRXFSIZ, fifo_size / 4); - - /* align to 4-bytes */ + /* align to 4 bytes boundary */ fifo_size &= ~3; + /* set global receive FIFO size */ + DWC_OTG_WRITE_4(sc, DOTG_GRXFSIZ, fifo_size / 4); + tx_start = fifo_size; - if (fifo_size < 0x40) { + if (fifo_size < 64) { DPRINTFN(-1, "Not enough data space for EP0 FIFO.\n"); - USB_BUS_UNLOCK(&sc->sc_bus); return (EINVAL); } @@ -205,14 +215,12 @@ dwc_otg_init_fifo(struct dwc_otg_softc *sc, uint8_t mode) /* reset active endpoints */ sc->sc_active_rx_ep = 0; - /* reset TX size */ - sc->sc_tx_cur_size = 0; - - /* reset TT info */ - memset(sc->sc_tt_info, 0, sizeof(sc->sc_tt_info)); - + /* split equally for periodic and non-periodic */ fifo_size /= 2; + /* align to 4 bytes boundary */ + fifo_size &= ~3; + DWC_OTG_WRITE_4(sc, DOTG_GNPTXFSIZ, ((fifo_size / 4) << 16) | (tx_start / 4)); @@ -228,7 +236,11 @@ dwc_otg_init_fifo(struct dwc_otg_softc *sc, uint8_t mode) ((fifo_size / 4) << 16) | (tx_start / 4)); - /* store maximum TX FIFO size */ + /* reset FIFO TX levels */ + sc->sc_tx_cur_p_level = 0; + sc->sc_tx_cur_np_level = 0; + + /* store maximum periodic and non-periodic FIFO TX size */ sc->sc_tx_max_size = fifo_size; /* disable all host channel interrupts */ @@ -311,11 +323,12 @@ dwc_otg_init_fifo(struct dwc_otg_softc *sc, uint8_t mode) /* reset active endpoints */ sc->sc_active_rx_ep = 0; - /* reset TX size */ - sc->sc_tx_cur_size = 0; + /* reset periodic and non-periodic FIFO TX size */ + sc->sc_tx_max_size = fifo_size; - /* reset TT info */ - memset(sc->sc_tt_info, 0, sizeof(sc->sc_tt_info)); + /* reset FIFO TX levels */ + sc->sc_tx_cur_p_level = 0; + sc->sc_tx_cur_np_level = 0; } return (0); } @@ -555,125 +568,70 @@ dwc_otg_clear_hcint(struct dwc_otg_softc *sc, uint8_t x) sc->sc_chan_state[x].hcint = 0; } -/* - * This function waits until a DWC OTG host channel is ready to be - * used again: - */ static uint8_t -dwc_otg_host_channel_wait(struct dwc_otg_td *td) +dwc_otg_host_channel_alloc(struct dwc_otg_td *td, uint8_t which) { struct dwc_otg_softc *sc; + uint32_t tx_p_size; + uint32_t tx_np_size; uint8_t x; - x = td->channel; - - DPRINTF("CH=%d\n", x); - - /* get pointer to softc */ - sc = DWC_OTG_PC2SC(td->pc); - - if (sc->sc_chan_state[x].wait_sof == 0) { - dwc_otg_clear_hcint(sc, x); - return (1); /* done */ - } - - if (x == 0) - return (0); /* wait */ - - /* find new disabled channel */ - for (x = 1; x != sc->sc_host_ch_max; x++) { - - if (sc->sc_chan_state[x].allocated) - continue; - if (sc->sc_chan_state[x].wait_sof != 0) - continue; - - sc->sc_chan_state[td->channel].allocated = 0; - sc->sc_chan_state[x].allocated = 1; - - sc->sc_chan_state[x].tx_size = - sc->sc_chan_state[td->channel].tx_size; - - if (sc->sc_chan_state[td->channel].suspended) { - sc->sc_chan_state[td->channel].suspended = 0; - sc->sc_chan_state[x].suspended = 1; - } - - /* clear interrupts */ - dwc_otg_clear_hcint(sc, x); - - DPRINTF("CH=%d HCCHAR=0x%08x " - "HCSPLT=0x%08x\n", x, td->hcchar, td->hcsplt); - - /* ack any pending messages */ - if (sc->sc_last_rx_status != 0 && - GRXSTSRD_CHNUM_GET(sc->sc_last_rx_status) == td->channel) { - /* get rid of message */ - dwc_otg_common_rx_ack(sc); - } - - /* move active channel */ - sc->sc_active_rx_ep &= ~(1 << td->channel); - sc->sc_active_rx_ep |= (1 << x); - - /* set channel */ - td->channel = x; - - return (1); /* new channel allocated */ - } - return (0); /* wait */ -} - -static uint8_t -dwc_otg_host_channel_alloc(struct dwc_otg_td *td) -{ - struct dwc_otg_softc *sc; - uint32_t tx_size; - uint8_t x; - uint8_t max_channel; - - if (td->channel < DWC_OTG_MAX_CHANNELS) + if (td->channel[which] < DWC_OTG_MAX_CHANNELS) return (0); /* already allocated */ + /* check if device is suspended */ + if (DWC_OTG_PC2UDEV(td->pc)->flags.self_suspended != 0) + return (1); /* busy - cannot transfer data */ + /* get pointer to softc */ sc = DWC_OTG_PC2SC(td->pc); - if ((td->hcchar & HCCHAR_EPNUM_MASK) == 0) { - max_channel = 1; - x = 0; - tx_size = td->max_packet_size; - if ((sc->sc_tx_cur_size + tx_size) > sc->sc_tx_max_size) { - DPRINTF("Too little FIFO space\n"); - return (1); /* too little FIFO */ - } - } else { - max_channel = sc->sc_host_ch_max; - x = 1; - if ((td->hcchar & HCCHAR_EPDIR) == HCCHAR_EPDIR_OUT) { - tx_size = td->max_packet_size; - if (td->hcsplt != 0 && tx_size > HCSPLT_XACTLEN_MAX) - tx_size = HCSPLT_XACTLEN_MAX; - if ((sc->sc_tx_cur_size + tx_size) > sc->sc_tx_max_size) { + /* compute needed TX FIFO size */ + if (td->ep_type == UE_CONTROL) { + /* RX and TX transactions */ + tx_p_size = 0; + tx_np_size = td->max_packet_size; + } else if ((td->hcchar & HCCHAR_EPDIR) == HCCHAR_EPDIR_OUT) { + if (td->ep_type == UE_INTERRUPT || + td->ep_type == UE_ISOCHRONOUS) { + tx_p_size = td->max_packet_size; + tx_np_size = 0; + if (td->hcsplt != 0 && tx_p_size > HCSPLT_XACTLEN_BURST) + tx_p_size = HCSPLT_XACTLEN_BURST; + if ((sc->sc_tx_cur_p_level + tx_p_size) > sc->sc_tx_max_size) { DPRINTF("Too little FIFO space\n"); return (1); /* too little FIFO */ } } else { - tx_size = 0; + tx_p_size = 0; + tx_np_size = td->max_packet_size; + if (td->hcsplt != 0 && tx_np_size > HCSPLT_XACTLEN_BURST) + tx_np_size = HCSPLT_XACTLEN_BURST; + if ((sc->sc_tx_cur_np_level + tx_np_size) > sc->sc_tx_max_size) { + DPRINTF("Too little FIFO space\n"); + return (1); /* too little FIFO */ + } } + } else { + /* not a TX transaction */ + tx_p_size = 0; + tx_np_size = 0; } - for (; x != max_channel; x++) { - - if (sc->sc_chan_state[x].allocated) + for (x = 0; x != sc->sc_host_ch_max; x++) { + if (sc->sc_chan_state[x].allocated != 0) continue; + /* check if channel is still enabled */ if (sc->sc_chan_state[x].wait_sof != 0) continue; sc->sc_chan_state[x].allocated = 1; - sc->sc_chan_state[x].tx_size = tx_size; + sc->sc_chan_state[x].tx_p_size = tx_p_size; + sc->sc_chan_state[x].tx_np_size = tx_np_size; - /* keep track of used FIFO */ - sc->sc_tx_cur_size += tx_size; + /* keep track of used TX FIFO, if any */ + sc->sc_tx_cur_p_level += tx_p_size; + sc->sc_tx_cur_np_level += tx_np_size; /* clear interrupts */ dwc_otg_clear_hcint(sc, x); @@ -685,54 +643,38 @@ dwc_otg_host_channel_alloc(struct dwc_otg_td *td) sc->sc_active_rx_ep |= (1 << x); /* set channel */ - td->channel = x; + td->channel[which] = x; return (0); /* allocated */ } + /* wait a bit */ + dwc_otg_enable_sof_irq(sc); return (1); /* busy */ } static void -dwc_otg_host_channel_disable(struct dwc_otg_softc *sc, uint8_t x) -{ - uint32_t hcchar; - if (sc->sc_chan_state[x].wait_sof != 0) - return; - hcchar = DWC_OTG_READ_4(sc, DOTG_HCCHAR(x)); - if (hcchar & (HCCHAR_CHENA | HCCHAR_CHDIS)) { - /* disable channel */ - DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(x), - HCCHAR_CHENA | HCCHAR_CHDIS); - /* don't re-use channel until next SOF is transmitted */ - sc->sc_chan_state[x].wait_sof = 2; - } -} - -static void -dwc_otg_host_channel_free(struct dwc_otg_td *td) +dwc_otg_host_channel_free(struct dwc_otg_td *td, uint8_t which) { struct dwc_otg_softc *sc; uint8_t x; - if (td->channel >= DWC_OTG_MAX_CHANNELS) + if (td->channel[which] >= DWC_OTG_MAX_CHANNELS) return; /* already freed */ /* free channel */ - x = td->channel; - td->channel = DWC_OTG_MAX_CHANNELS; + x = td->channel[which]; + td->channel[which] = DWC_OTG_MAX_CHANNELS; DPRINTF("CH=%d\n", x); /* get pointer to softc */ sc = DWC_OTG_PC2SC(td->pc); - - dwc_otg_host_channel_disable(sc, x); - + sc->sc_chan_state[x].wait_sof = DWC_OTG_SLOT_IDLE_MAX; sc->sc_chan_state[x].allocated = 0; - sc->sc_chan_state[x].suspended = 0; - /* keep track of used FIFO */ - sc->sc_tx_cur_size -= sc->sc_chan_state[x].tx_size; + /* keep track of used TX FIFO, if any */ + sc->sc_tx_cur_p_level -= sc->sc_chan_state[x].tx_p_size; + sc->sc_tx_cur_np_level -= sc->sc_chan_state[x].tx_np_size; /* ack any pending messages */ if (sc->sc_last_rx_status != 0 && @@ -751,30 +693,33 @@ dwc_otg_host_setup_tx(struct dwc_otg_td *td) struct dwc_otg_softc *sc; uint32_t hcint; uint32_t hcchar; - - if (dwc_otg_host_channel_alloc(td)) - goto busy; + uint8_t delta; /* get pointer to softc */ sc = DWC_OTG_PC2SC(td->pc); - hcint = sc->sc_chan_state[td->channel].hcint; + if (td->channel[0] < DWC_OTG_MAX_CHANNELS) { + hcint = sc->sc_chan_state[td->channel[0]].hcint; - DPRINTF("CH=%d ST=%d HCINT=0x%08x HCCHAR=0x%08x HCTSIZ=0x%08x\n", - td->channel, td->state, hcint, - DWC_OTG_READ_4(sc, DOTG_HCCHAR(td->channel)), - DWC_OTG_READ_4(sc, DOTG_HCTSIZ(td->channel))); + DPRINTF("CH=%d ST=%d HCINT=0x%08x HCCHAR=0x%08x HCTSIZ=0x%08x\n", + td->channel[0], td->state, hcint, + DWC_OTG_READ_4(sc, DOTG_HCCHAR(td->channel[0])), + DWC_OTG_READ_4(sc, DOTG_HCTSIZ(td->channel[0]))); + } else { + hcint = 0; + goto check_state; + } if (hcint & (HCINT_RETRY | HCINT_ACK | HCINT_NYET)) { /* give success bits priority over failure bits */ } else if (hcint & HCINT_STALL) { - DPRINTF("CH=%d STALL\n", td->channel); + DPRINTF("CH=%d STALL\n", td->channel[0]); td->error_stall = 1; td->error_any = 1; goto complete; } else if (hcint & HCINT_ERRORS) { - DPRINTF("CH=%d ERROR\n", td->channel); + DPRINTF("CH=%d ERROR\n", td->channel[0]); td->errcnt++; if (td->hcsplt != 0 || td->errcnt >= 3) { td->error_any = 1; @@ -782,34 +727,23 @@ dwc_otg_host_setup_tx(struct dwc_otg_td *td) } } - /* channel must be disabled before we can complete the transfer */ - if (hcint & (HCINT_ERRORS | HCINT_RETRY | HCINT_ACK | HCINT_NYET)) { - - dwc_otg_host_channel_disable(sc, td->channel); - if (!(hcint & HCINT_ERRORS)) td->errcnt = 0; } +check_state: switch (td->state) { case DWC_CHAN_ST_START: - if (!dwc_otg_host_channel_wait(td)) - break; goto send_pkt; case DWC_CHAN_ST_WAIT_ANE: if (hcint & (HCINT_RETRY | HCINT_ERRORS)) { - if (!dwc_otg_host_channel_wait(td)) - break; td->did_nak = 1; td->tt_scheduled = 0; goto send_pkt; - } - if (hcint & (HCINT_ACK | HCINT_NYET)) { - if (!dwc_otg_host_channel_wait(td)) - break; + } else if (hcint & (HCINT_ACK | HCINT_NYET)) { td->offset += td->tx_bytes; td->remainder -= td->tx_bytes; td->toggle = 1; @@ -820,35 +754,22 @@ dwc_otg_host_setup_tx(struct dwc_otg_td *td) case DWC_CHAN_ST_WAIT_S_ANE: if (hcint & (HCINT_RETRY | HCINT_ERRORS)) { - if (!dwc_otg_host_channel_wait(td)) - break; td->did_nak = 1; td->tt_scheduled = 0; goto send_pkt; - } - if (hcint & (HCINT_ACK | HCINT_NYET)) { - if (!dwc_otg_host_channel_wait(td)) - break; + } else if (hcint & (HCINT_ACK | HCINT_NYET)) { goto send_cpkt; } break; case DWC_CHAN_ST_WAIT_C_ANE: if (hcint & HCINT_NYET) { - if (!dwc_otg_host_channel_wait(td)) - break; goto send_cpkt; - } - if (hcint & (HCINT_RETRY | HCINT_ERRORS)) { - if (!dwc_otg_host_channel_wait(td)) - break; + } else if (hcint & (HCINT_RETRY | HCINT_ERRORS)) { td->did_nak = 1; td->tt_scheduled = 0; goto send_pkt; - } - if (hcint & HCINT_ACK) { - if (!dwc_otg_host_channel_wait(td)) - break; + } else if (hcint & HCINT_ACK) { td->offset += td->tx_bytes; td->remainder -= td->tx_bytes; td->toggle = 1; @@ -857,8 +778,6 @@ dwc_otg_host_setup_tx(struct dwc_otg_td *td) break; case DWC_CHAN_ST_WAIT_C_PKT: - if (!dwc_otg_host_channel_wait(td)) - break; goto send_cpkt; default: @@ -867,20 +786,36 @@ dwc_otg_host_setup_tx(struct dwc_otg_td *td) goto busy; send_pkt: + /* free existing channel, if any */ + dwc_otg_host_channel_free(td, 0); + if (sizeof(req) != td->remainder) { td->error_any = 1; goto complete; } if (td->hcsplt != 0) { - /* Wait for our turn, if TT transfer */ - if (td->tt_scheduled == 0 || - (sc->sc_last_frame_num & 7) < td->tt_start_slot) { - /* set return state */ + delta = td->tt_start_slot - sc->sc_last_frame_num - 1; + if (td->tt_scheduled == 0 || delta < DWC_OTG_TT_SLOT_MAX) { + td->state = DWC_CHAN_ST_START; + goto busy; + } + delta = sc->sc_last_frame_num - td->tt_start_slot; + if (delta > 5) { + /* missed it */ + td->tt_scheduled = 0; td->state = DWC_CHAN_ST_START; - goto tt_wait; + goto busy; } + } + /* allocate a new channel */ + if (dwc_otg_host_channel_alloc(td, 0)) { + td->state = DWC_CHAN_ST_START; + goto busy; + } + + if (td->hcsplt != 0) { td->hcsplt &= ~HCSPLT_COMPSPLT; td->state = DWC_CHAN_ST_WAIT_S_ANE; } else { @@ -889,60 +824,73 @@ send_pkt: usbd_copy_out(td->pc, 0, &req, sizeof(req)); - DWC_OTG_WRITE_4(sc, DOTG_HCTSIZ(td->channel), + DWC_OTG_WRITE_4(sc, DOTG_HCTSIZ(td->channel[0]), (sizeof(req) << HCTSIZ_XFERSIZE_SHIFT) | (1 << HCTSIZ_PKTCNT_SHIFT) | (HCTSIZ_PID_SETUP << HCTSIZ_PID_SHIFT)); - DWC_OTG_WRITE_4(sc, DOTG_HCSPLT(td->channel), td->hcsplt); + DWC_OTG_WRITE_4(sc, DOTG_HCSPLT(td->channel[0]), td->hcsplt); hcchar = td->hcchar; - hcchar &= ~HCCHAR_EPDIR_IN; + hcchar &= ~(HCCHAR_EPDIR_IN | HCCHAR_EPTYPE_MASK); + hcchar |= UE_CONTROL << HCCHAR_EPTYPE_SHIFT; /* must enable channel before writing data to FIFO */ - DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(td->channel), hcchar); + DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(td->channel[0]), hcchar); /* transfer data into FIFO */ bus_space_write_region_4(sc->sc_io_tag, sc->sc_io_hdl, - DOTG_DFIFO(td->channel), (uint32_t *)&req, sizeof(req) / 4); + DOTG_DFIFO(td->channel[0]), (uint32_t *)&req, sizeof(req) / 4); /* store number of bytes transmitted */ td->tx_bytes = sizeof(req); - goto busy; send_cpkt: - /* Wait for our turn, if TT transfer */ - if (td->tt_scheduled == 0 || - (sc->sc_last_frame_num & 7) < td->tt_complete_slot) { - /* set return state */ + /* free existing channel, if any */ + dwc_otg_host_channel_free(td, 0); + + delta = td->tt_complete_slot - sc->sc_last_frame_num - 1; + if (td->tt_scheduled == 0 || delta < DWC_OTG_TT_SLOT_MAX) { td->state = DWC_CHAN_ST_WAIT_C_PKT; - goto tt_wait; + goto busy; + } + delta = sc->sc_last_frame_num - td->tt_start_slot; + if (delta > DWC_OTG_TT_SLOT_MAX) { + /* we missed the service interval */ + if (td->ep_type != UE_ISOCHRONOUS) + td->error_any = 1; + goto complete; } + /* allocate a new channel */ + if (dwc_otg_host_channel_alloc(td, 0)) { + td->state = DWC_CHAN_ST_WAIT_C_PKT; + goto busy; + } + /* wait until next slot before trying again */ td->tt_complete_slot++; td->hcsplt |= HCSPLT_COMPSPLT; td->state = DWC_CHAN_ST_WAIT_C_ANE; - DWC_OTG_WRITE_4(sc, DOTG_HCTSIZ(td->channel), + DWC_OTG_WRITE_4(sc, DOTG_HCTSIZ(td->channel[0]), (HCTSIZ_PID_SETUP << HCTSIZ_PID_SHIFT)); - DWC_OTG_WRITE_4(sc, DOTG_HCSPLT(td->channel), td->hcsplt); + DWC_OTG_WRITE_4(sc, DOTG_HCSPLT(td->channel[0]), td->hcsplt); hcchar = td->hcchar; - hcchar &= ~HCCHAR_EPDIR_IN; + hcchar &= ~(HCCHAR_EPDIR_IN | HCCHAR_EPTYPE_MASK); + hcchar |= UE_CONTROL << HCCHAR_EPTYPE_SHIFT; /* must enable channel before writing data to FIFO */ - DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(td->channel), hcchar); - goto busy; + DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(td->channel[0]), hcchar); -tt_wait: - /* free allocated channel */ - dwc_otg_host_channel_free(td); busy: return (1); /* busy */ + complete: + dwc_otg_host_channel_free(td, 0); return (0); /* complete */ } @@ -1100,20 +1048,11 @@ static uint8_t dwc_otg_host_rate_check(struct dwc_otg_td *td) { struct dwc_otg_softc *sc; - uint8_t ep_type; /* get pointer to softc */ sc = DWC_OTG_PC2SC(td->pc); - if (td->channel < DWC_OTG_MAX_CHANNELS && - sc->sc_chan_state[td->channel].suspended) - goto busy; - - ep_type = ((td->hcchar & - HCCHAR_EPTYPE_MASK) >> HCCHAR_EPTYPE_SHIFT); - - if (ep_type == UE_ISOCHRONOUS) { - + if (td->ep_type == UE_ISOCHRONOUS) { /* non TT isochronous traffic */ if ((td->tmr_val != 0) || (sc->sc_last_frame_num & (td->tmr_res - 1))) { @@ -1122,7 +1061,7 @@ dwc_otg_host_rate_check(struct dwc_otg_td *td) td->tmr_val = 1; /* executed */ td->toggle = 0; - } else if (ep_type == UE_INTERRUPT) { + } else if (td->ep_type == UE_INTERRUPT) { if (!td->tt_scheduled) goto busy; td->tt_scheduled = 0; @@ -1144,23 +1083,24 @@ dwc_otg_host_data_rx(struct dwc_otg_td *td) uint32_t hcint; uint32_t hcchar; uint32_t count; - uint8_t ep_type; - - if (dwc_otg_host_channel_alloc(td)) - goto busy; + uint8_t delta; + uint8_t channel; /* get pointer to softc */ sc = DWC_OTG_PC2SC(td->pc); + channel = td->channel[td->tt_channel_tog]; - ep_type = ((td->hcchar & - HCCHAR_EPTYPE_MASK) >> HCCHAR_EPTYPE_SHIFT); + if (channel < DWC_OTG_MAX_CHANNELS) { + hcint = sc->sc_chan_state[channel].hcint; - hcint = sc->sc_chan_state[td->channel].hcint; - - DPRINTF("CH=%d ST=%d HCINT=0x%08x HCCHAR=0x%08x HCTSIZ=0x%08x\n", - td->channel, td->state, hcint, - DWC_OTG_READ_4(sc, DOTG_HCCHAR(td->channel)), - DWC_OTG_READ_4(sc, DOTG_HCTSIZ(td->channel))); + DPRINTF("CH=%d ST=%d HCINT=0x%08x HCCHAR=0x%08x HCTSIZ=0x%08x\n", + channel, td->state, hcint, + DWC_OTG_READ_4(sc, DOTG_HCCHAR(channel)), + DWC_OTG_READ_4(sc, DOTG_HCTSIZ(channel))); + } else { + hcint = 0; + goto check_state; + } /* check interrupt bits */ @@ -1168,37 +1108,26 @@ dwc_otg_host_data_rx(struct dwc_otg_td *td) HCINT_ACK | HCINT_NYET)) { /* give success bits priority over failure bits */ } else if (hcint & HCINT_STALL) { - DPRINTF("CH=%d STALL\n", td->channel); + DPRINTF("CH=%d STALL\n", channel); td->error_stall = 1; td->error_any = 1; goto complete; } else if (hcint & HCINT_ERRORS) { - DPRINTF("CH=%d ERROR\n", td->channel); + DPRINTF("CH=%d ERROR\n", channel); td->errcnt++; if (td->hcsplt != 0 || td->errcnt >= 3) { - if (ep_type != UE_ISOCHRONOUS) { + if (td->ep_type != UE_ISOCHRONOUS) { td->error_any = 1; goto complete; } } } - /* channel must be disabled before we can complete the transfer */ - - if (hcint & (HCINT_ERRORS | HCINT_RETRY | - HCINT_ACK | HCINT_NYET)) { - - dwc_otg_host_channel_disable(sc, td->channel); - - if (!(hcint & HCINT_ERRORS)) - td->errcnt = 0; - } - /* check endpoint status */ if (sc->sc_last_rx_status == 0) goto check_state; - if (GRXSTSRD_CHNUM_GET(sc->sc_last_rx_status) != td->channel) + if (GRXSTSRD_CHNUM_GET(sc->sc_last_rx_status) != channel) goto check_state; switch (sc->sc_last_rx_status & GRXSTSRD_PKTSTS_MASK) { @@ -1220,7 +1149,7 @@ dwc_otg_host_data_rx(struct dwc_otg_td *td) count = GRXSTSRD_BCNT_GET(sc->sc_last_rx_status); /* check for isochronous transfer or high-speed bandwidth endpoint */ - if (ep_type == UE_ISOCHRONOUS || td->max_packet_count > 1) { + if (td->ep_type == UE_ISOCHRONOUS || td->max_packet_count > 1) { if ((sc->sc_last_rx_status & GRXSTSRD_DPID_MASK) != GRXSTSRD_DPID_DATA0) { td->tt_xactpos = HCSPLT_XACTPOS_MIDDLE; } else { @@ -1269,8 +1198,8 @@ dwc_otg_host_data_rx(struct dwc_otg_td *td) td->remainder -= count; td->offset += count; - hcint |= HCINT_SOFTWARE_ONLY | HCINT_ACK; - sc->sc_chan_state[td->channel].hcint = hcint; + hcint |= HCINT_SOFTWARE_ONLY; + sc->sc_chan_state[channel].hcint = hcint; break; default: @@ -1280,10 +1209,14 @@ dwc_otg_host_data_rx(struct dwc_otg_td *td) dwc_otg_common_rx_ack(sc); check_state: + if (hcint & (HCINT_ERRORS | HCINT_RETRY | + HCINT_ACK | HCINT_NYET)) { + if (!(hcint & HCINT_ERRORS)) + td->errcnt = 0; + } + switch (td->state) { case DWC_CHAN_ST_START: - if (!dwc_otg_host_channel_wait(td)) - break; if (td->hcsplt != 0) goto receive_spkt; else @@ -1291,38 +1224,29 @@ check_state: case DWC_CHAN_ST_WAIT_ANE: if (hcint & (HCINT_RETRY | HCINT_ERRORS)) { - if (!dwc_otg_host_channel_wait(td)) - break; - td->did_nak = 1; td->tt_scheduled = 0; if (td->hcsplt != 0) goto receive_spkt; else goto receive_pkt; - } - if (!(hcint & HCINT_SOFTWARE_ONLY)) { - if (hcint & HCINT_NYET) { - if (ep_type == UE_ISOCHRONOUS) { - /* we missed the service interval */ - goto complete; - } - if (!dwc_otg_host_channel_wait(td)) - break; + } else if (hcint & HCINT_NYET) { + if (td->hcsplt != 0) { + /* try again */ goto receive_pkt; + } else { + /* not a valid token for IN endpoints */ + td->error_any = 1; + goto complete; } - break; - } - if (hcint & (HCINT_ACK | HCINT_NYET)) { - if (!dwc_otg_host_channel_wait(td)) - break; - - if (ep_type == UE_ISOCHRONOUS) { + } else if (hcint & HCINT_ACK) { + if (td->ep_type == UE_ISOCHRONOUS) { /* check if we are complete */ if ((td->remainder == 0) || - (td->tt_xactpos == HCSPLT_XACTPOS_BEGIN)) + (td->tt_xactpos == HCSPLT_XACTPOS_BEGIN)) { goto complete; - + } + /* get another packet */ goto receive_pkt; } else { /* check if we are complete */ @@ -1350,23 +1274,17 @@ check_state: * case of interrupt and isochronous transfers: */ if (hcint & (HCINT_RETRY | HCINT_ERRORS)) { - if (!dwc_otg_host_channel_wait(td)) - break; - td->did_nak = 1; td->tt_scheduled = 0; goto receive_spkt; - } - if (hcint & (HCINT_ACK | HCINT_NYET)) { - if (!dwc_otg_host_channel_wait(td)) - break; + } else if (hcint & HCINT_NYET) { + td->tt_scheduled = 0; + goto receive_spkt; + } else if (hcint & HCINT_ACK) goto receive_pkt; - } break; case DWC_CHAN_ST_WAIT_C_PKT: - if (!dwc_otg_host_channel_wait(td)) - break; goto receive_pkt; default: @@ -1375,103 +1293,149 @@ check_state: goto busy; receive_pkt: + /* free existing channel, if any */ + dwc_otg_host_channel_free(td, td->tt_channel_tog); + if (td->hcsplt != 0) { - /* Wait for our turn, if TT transfer */ - if (td->tt_scheduled == 0 || - (sc->sc_last_frame_num & 7) < td->tt_complete_slot) { - /* set return state */ + delta = td->tt_complete_slot - sc->sc_last_frame_num - 1; + if (td->tt_scheduled == 0 || delta < DWC_OTG_TT_SLOT_MAX) { td->state = DWC_CHAN_ST_WAIT_C_PKT; - goto tt_wait; + goto busy; } - /* wait until next slot before trying again */ - td->tt_complete_slot++; - - /* set toggle, if any */ - if (td->set_toggle) { - td->set_toggle = 0; - td->toggle = 1; + delta = sc->sc_last_frame_num - td->tt_start_slot; + if (delta > DWC_OTG_TT_SLOT_MAX) { + /* we missed the service interval */ + if (td->ep_type != UE_ISOCHRONOUS) + td->error_any = 1; + goto complete; } + /* complete split */ td->hcsplt |= HCSPLT_COMPSPLT; - count = HCSPLT_XACTLEN_MAX; } else if (td->tt_xactpos == HCSPLT_XACTPOS_BEGIN && dwc_otg_host_rate_check(td)) { - td->state = DWC_CHAN_ST_START; - dwc_otg_host_channel_free(td); + td->state = DWC_CHAN_ST_WAIT_C_PKT; goto busy; - } else { - count = td->max_packet_size; } + + /* allocate a new channel */ + if (dwc_otg_host_channel_alloc(td, td->tt_channel_tog)) { + td->state = DWC_CHAN_ST_WAIT_C_PKT; + goto busy; + } + + channel = td->channel[td->tt_channel_tog]; + + /* set toggle, if any */ + if (td->set_toggle) { + td->set_toggle = 0; + td->toggle = 1; + } + td->state = DWC_CHAN_ST_WAIT_ANE; /* receive one packet */ - DWC_OTG_WRITE_4(sc, DOTG_HCTSIZ(td->channel), - (count << HCTSIZ_XFERSIZE_SHIFT) | + DWC_OTG_WRITE_4(sc, DOTG_HCTSIZ(channel), + (td->max_packet_size << HCTSIZ_XFERSIZE_SHIFT) | (1 << HCTSIZ_PKTCNT_SHIFT) | (td->toggle ? (HCTSIZ_PID_DATA1 << HCTSIZ_PID_SHIFT) : (HCTSIZ_PID_DATA0 << HCTSIZ_PID_SHIFT))); - DWC_OTG_WRITE_4(sc, DOTG_HCSPLT(td->channel), td->hcsplt); - - /* send ASAP */ - if ((ep_type == UE_ISOCHRONOUS) && !(sc->sc_last_frame_num & 1)) - td->hcchar |= HCCHAR_ODDFRM; - else - td->hcchar &= ~HCCHAR_ODDFRM; + DWC_OTG_WRITE_4(sc, DOTG_HCSPLT(channel), td->hcsplt); hcchar = td->hcchar; hcchar |= HCCHAR_EPDIR_IN; - /* must enable channel before data can be received */ - DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(td->channel), hcchar); + /* check if other channel is allocated */ + if (td->channel[td->tt_channel_tog ^ 1] < DWC_OTG_MAX_CHANNELS) { + /* second - receive after next SOF event */ + if ((sc->sc_last_frame_num & 1) != 0) + hcchar |= HCCHAR_ODDFRM; + else + hcchar &= ~HCCHAR_ODDFRM; + + /* other channel is next */ + td->tt_channel_tog ^= 1; + td->tt_complete_slot++; + + /* must enable channel before data can be received */ + DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(channel), hcchar); + } else { + /* first - receive after second next SOF event */ + if ((sc->sc_last_frame_num & 1) == 0) + hcchar |= HCCHAR_ODDFRM; + else + hcchar &= ~HCCHAR_ODDFRM; + + /* must enable channel before data can be received */ + DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(channel), hcchar); + + if (td->hcsplt != 0) { + if (td->ep_type == UE_ISOCHRONOUS || td->ep_type == UE_INTERRUPT) { + /* allocate a second channel */ + td->tt_channel_tog ^= 1; + goto receive_pkt; + } else { + td->tt_complete_slot++; + } + } + } goto busy; receive_spkt: - /* Wait for our turn, if TT transfer */ - if (td->tt_scheduled == 0) { - if (ep_type == UE_INTERRUPT) { - td->state = DWC_CHAN_ST_START; - dwc_otg_host_channel_free(td); - goto busy; - } - /* set return state */ + /* free existing channel(s), if any */ + dwc_otg_host_channel_free(td, 0); + dwc_otg_host_channel_free(td, 1); + + delta = td->tt_start_slot - sc->sc_last_frame_num - 1; + if (td->tt_scheduled == 0 || delta < DWC_OTG_TT_SLOT_MAX) { td->state = DWC_CHAN_ST_START; - goto tt_wait; + goto busy; } - if ((sc->sc_last_frame_num & 7) < td->tt_start_slot) { - /* set return state */ + delta = sc->sc_last_frame_num - td->tt_start_slot; + if (delta > 5) { + /* missed it */ + td->tt_scheduled = 0; td->state = DWC_CHAN_ST_START; - goto tt_wait; + goto busy; } - /* send ASAP */ - if ((ep_type == UE_ISOCHRONOUS) && !(sc->sc_last_frame_num & 1)) - td->hcchar |= HCCHAR_ODDFRM; - else - td->hcchar &= ~HCCHAR_ODDFRM; + /* allocate a new channel */ + if (dwc_otg_host_channel_alloc(td, 0)) { + td->state = DWC_CHAN_ST_START; + goto busy; + } + + channel = td->channel[0]; td->hcsplt &= ~HCSPLT_COMPSPLT; td->state = DWC_CHAN_ST_WAIT_S_ANE; + /* reset channel toggle */ + td->tt_channel_tog = 0; + /* receive one packet */ - DWC_OTG_WRITE_4(sc, DOTG_HCTSIZ(td->channel), - (td->toggle ? (HCTSIZ_PID_DATA1 << HCTSIZ_PID_SHIFT) : - (HCTSIZ_PID_DATA0 << HCTSIZ_PID_SHIFT))); + DWC_OTG_WRITE_4(sc, DOTG_HCTSIZ(channel), + (HCTSIZ_PID_DATA0 << HCTSIZ_PID_SHIFT)); - DWC_OTG_WRITE_4(sc, DOTG_HCSPLT(td->channel), td->hcsplt); + DWC_OTG_WRITE_4(sc, DOTG_HCSPLT(channel), td->hcsplt); + + /* send after next SOF event */ + if ((sc->sc_last_frame_num & 1) == 0) + td->hcchar |= HCCHAR_ODDFRM; + else + td->hcchar &= ~HCCHAR_ODDFRM; hcchar = td->hcchar; hcchar |= HCCHAR_EPDIR_IN; /* must enable channel before data can be received */ - DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(td->channel), hcchar); - goto busy; - -tt_wait: - /* free allocated channel */ - dwc_otg_host_channel_free(td); + DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(channel), hcchar); busy: return (1); /* busy */ + complete: + dwc_otg_host_channel_free(td, 0); + dwc_otg_host_channel_free(td, 1); return (0); /* complete */ } @@ -1595,34 +1559,35 @@ dwc_otg_host_data_tx(struct dwc_otg_td *td) uint32_t count; uint32_t hcint; uint32_t hcchar; - uint8_t ep_type; - - if (dwc_otg_host_channel_alloc(td)) - goto busy; + uint8_t delta; + uint8_t channel; /* get pointer to softc */ sc = DWC_OTG_PC2SC(td->pc); + channel = td->channel[td->tt_channel_tog]; - ep_type = ((td->hcchar & - HCCHAR_EPTYPE_MASK) >> HCCHAR_EPTYPE_SHIFT); + if (channel < DWC_OTG_MAX_CHANNELS) { + hcint = sc->sc_chan_state[channel].hcint; - hcint = sc->sc_chan_state[td->channel].hcint; - - DPRINTF("CH=%d ST=%d HCINT=0x%08x HCCHAR=0x%08x HCTSIZ=0x%08x\n", - td->channel, td->state, hcint, - DWC_OTG_READ_4(sc, DOTG_HCCHAR(td->channel)), - DWC_OTG_READ_4(sc, DOTG_HCTSIZ(td->channel))); + DPRINTF("CH=%d ST=%d HCINT=0x%08x HCCHAR=0x%08x HCTSIZ=0x%08x\n", + channel, td->state, hcint, + DWC_OTG_READ_4(sc, DOTG_HCCHAR(channel)), + DWC_OTG_READ_4(sc, DOTG_HCTSIZ(channel))); + } else { + hcint = 0; + goto check_state; + } if (hcint & (HCINT_RETRY | HCINT_ACK | HCINT_NYET)) { /* give success bits priority over failure bits */ } else if (hcint & HCINT_STALL) { - DPRINTF("CH=%d STALL\n", td->channel); + DPRINTF("CH=%d STALL\n", channel); td->error_stall = 1; td->error_any = 1; goto complete; } else if (hcint & HCINT_ERRORS) { - DPRINTF("CH=%d ERROR\n", td->channel); + DPRINTF("CH=%d ERROR\n", channel); td->errcnt++; if (td->hcsplt != 0 || td->errcnt >= 3) { td->error_any = 1; @@ -1635,30 +1600,22 @@ dwc_otg_host_data_tx(struct dwc_otg_td *td) if (hcint & (HCINT_ERRORS | HCINT_RETRY | HCINT_ACK | HCINT_NYET)) { - dwc_otg_host_channel_disable(sc, td->channel); - if (!(hcint & HCINT_ERRORS)) td->errcnt = 0; } +check_state: switch (td->state) { case DWC_CHAN_ST_START: - if (!dwc_otg_host_channel_wait(td)) - break; goto send_pkt; case DWC_CHAN_ST_WAIT_ANE: if (hcint & (HCINT_RETRY | HCINT_ERRORS)) { - if (!dwc_otg_host_channel_wait(td)) - break; td->did_nak = 1; td->tt_scheduled = 0; goto send_pkt; } if (hcint & (HCINT_ACK | HCINT_NYET)) { - if (!dwc_otg_host_channel_wait(td)) - break; - td->offset += td->tx_bytes; td->remainder -= td->tx_bytes; td->toggle ^= 1; @@ -1680,35 +1637,24 @@ dwc_otg_host_data_tx(struct dwc_otg_td *td) case DWC_CHAN_ST_WAIT_S_ANE: if (hcint & (HCINT_RETRY | HCINT_ERRORS)) { - if (!dwc_otg_host_channel_wait(td)) - break; td->did_nak = 1; td->tt_scheduled = 0; goto send_pkt; } - if (hcint & (HCINT_ACK | HCINT_NYET)) { - if (!dwc_otg_host_channel_wait(td)) - break; + if (hcint & (HCINT_ACK | HCINT_NYET)) goto send_cpkt; - } break; case DWC_CHAN_ST_WAIT_C_ANE: - if (hcint & HCINT_NYET) { - if (!dwc_otg_host_channel_wait(td)) - break; + if (hcint & HCINT_NYET) goto send_cpkt; - } + if (hcint & (HCINT_RETRY | HCINT_ERRORS)) { - if (!dwc_otg_host_channel_wait(td)) - break; td->did_nak = 1; td->tt_scheduled = 0; goto send_pkt; } if (hcint & HCINT_ACK) { - if (!dwc_otg_host_channel_wait(td)) - break; td->offset += td->tx_bytes; td->remainder -= td->tx_bytes; td->toggle ^= 1; @@ -1726,46 +1672,35 @@ dwc_otg_host_data_tx(struct dwc_otg_td *td) break; case DWC_CHAN_ST_WAIT_C_PKT: - if (!dwc_otg_host_channel_wait(td)) - break; goto send_cpkt; case DWC_CHAN_ST_TX_WAIT_ISOC: /* Check if isochronous OUT traffic is complete */ - if ((hcint & HCINT_ACK) == 0) + if ((hcint & HCINT_HCH_DONE_MASK) == 0) break; td->offset += td->tx_bytes; td->remainder -= td->tx_bytes; - /* Update split token according to specification */ - if (td->hcsplt != 0) { - if (td->tt_xactpos == HCSPLT_XACTPOS_BEGIN) - td->tt_xactpos = HCSPLT_XACTPOS_MIDDLE; - } else if (td->max_packet_count > 1) { - td->tt_xactpos++; - } + if (td->hcsplt != 0 || td->remainder == 0) + goto complete; - dwc_otg_host_channel_disable(sc, td->channel); + /* check for next packet */ + if (td->max_packet_count > 1) + td->tt_xactpos++; - if (td->remainder == 0) - goto complete; + /* free existing channel, if any */ + dwc_otg_host_channel_free(td, td->tt_channel_tog); td->state = DWC_CHAN_ST_TX_PKT_ISOC; /* FALLTHROUGH */ case DWC_CHAN_ST_TX_PKT_ISOC: - if (!dwc_otg_host_channel_wait(td)) + if (dwc_otg_host_channel_alloc(td, 0)) break; - - if (td->hcsplt != 0) { - if ((sc->sc_last_frame_num & 7) < td->tt_start_slot) - goto tt_wait; - /* packets must be 125us apart */ - td->tt_start_slot++; - } + channel = td->channel[0]; goto send_isoc_pkt; default: break; @@ -1773,39 +1708,43 @@ dwc_otg_host_data_tx(struct dwc_otg_td *td) goto busy; send_pkt: + /* free existing channel(s), if any */ + dwc_otg_host_channel_free(td, 0); + dwc_otg_host_channel_free(td, 1); + if (td->hcsplt != 0) { - /* Wait for our turn, if TT transfer */ - if (td->tt_scheduled == 0) { - if (ep_type == UE_INTERRUPT) { - td->state = DWC_CHAN_ST_START; - dwc_otg_host_channel_free(td); - goto busy; - } - /* set return state */ + delta = td->tt_start_slot - sc->sc_last_frame_num - 1; + if (td->tt_scheduled == 0 || delta < DWC_OTG_TT_SLOT_MAX) { td->state = DWC_CHAN_ST_START; - goto tt_wait; + goto busy; } - if ((sc->sc_last_frame_num & 7) < td->tt_start_slot) { - /* set return state */ + delta = sc->sc_last_frame_num - td->tt_start_slot; + if (delta > 5) { + /* missed it */ + td->tt_scheduled = 0; td->state = DWC_CHAN_ST_START; - goto tt_wait; - } - - /* packets must be 125us apart */ - td->tt_start_slot++; - - /* set toggle, if any */ - if (td->set_toggle) { - td->set_toggle = 0; - td->toggle = 1; + goto busy; } } else if (dwc_otg_host_rate_check(td)) { td->state = DWC_CHAN_ST_START; - dwc_otg_host_channel_free(td); goto busy; } - if (ep_type == UE_ISOCHRONOUS) { + /* allocate a new channel */ + if (dwc_otg_host_channel_alloc(td, 0)) { + td->state = DWC_CHAN_ST_START; + goto busy; + } + + channel = td->channel[0]; + + /* set toggle, if any */ + if (td->set_toggle) { + td->set_toggle = 0; + td->toggle = 1; + } + + if (td->ep_type == UE_ISOCHRONOUS) { send_isoc_pkt: /* Isochronous OUT transfers don't have any ACKs */ td->state = DWC_CHAN_ST_TX_WAIT_ISOC; @@ -1813,23 +1752,14 @@ send_isoc_pkt: if (td->hcsplt != 0) { /* get maximum transfer length */ count = td->remainder; - - /* Update split token according to specification */ - if (td->tt_xactpos == HCSPLT_XACTPOS_BEGIN) { - if (count <= HCSPLT_XACTLEN_MAX) - td->tt_xactpos = HCSPLT_XACTPOS_ALL; - else - count = HCSPLT_XACTLEN_MAX; - } else if (td->tt_xactpos == HCSPLT_XACTPOS_MIDDLE) { - if (count <= HCSPLT_XACTLEN_MAX) - td->tt_xactpos = HCSPLT_XACTPOS_LAST; - else - count = HCSPLT_XACTLEN_MAX; + if (count > HCSPLT_XACTLEN_BURST) { + DPRINTF("TT overflow\n"); + td->error = 1; + goto complete; } - /* Update transaction position */ td->hcsplt &= ~HCSPLT_XACTPOS_MASK; - td->hcsplt |= ((uint32_t)td->tt_xactpos << HCSPLT_XACTPOS_SHIFT); + td->hcsplt |= (HCSPLT_XACTPOS_ALL << HCSPLT_XACTPOS_SHIFT); } else { /* send one packet at a time */ count = td->max_packet_size; @@ -1883,24 +1813,24 @@ send_isoc_pkt: } if (td->tt_xactpos == td->npkt) { if (td->npkt == 1) { - DWC_OTG_WRITE_4(sc, DOTG_HCTSIZ(td->channel), + DWC_OTG_WRITE_4(sc, DOTG_HCTSIZ(channel), (count << HCTSIZ_XFERSIZE_SHIFT) | (1 << HCTSIZ_PKTCNT_SHIFT) | (HCTSIZ_PID_DATA0 << HCTSIZ_PID_SHIFT)); } else if (td->npkt == 2) { - DWC_OTG_WRITE_4(sc, DOTG_HCTSIZ(td->channel), + DWC_OTG_WRITE_4(sc, DOTG_HCTSIZ(channel), (count << HCTSIZ_XFERSIZE_SHIFT) | (1 << HCTSIZ_PKTCNT_SHIFT) | (HCTSIZ_PID_DATA1 << HCTSIZ_PID_SHIFT)); } else { - DWC_OTG_WRITE_4(sc, DOTG_HCTSIZ(td->channel), + DWC_OTG_WRITE_4(sc, DOTG_HCTSIZ(channel), (count << HCTSIZ_XFERSIZE_SHIFT) | (1 << HCTSIZ_PKTCNT_SHIFT) | (HCTSIZ_PID_DATA2 << HCTSIZ_PID_SHIFT)); } td->npkt = 0; } else { - DWC_OTG_WRITE_4(sc, DOTG_HCTSIZ(td->channel), + DWC_OTG_WRITE_4(sc, DOTG_HCTSIZ(channel), (count << HCTSIZ_XFERSIZE_SHIFT) | (1 << HCTSIZ_PKTCNT_SHIFT) | (HCTSIZ_PID_MDATA << HCTSIZ_PID_SHIFT)); @@ -1908,26 +1838,26 @@ send_isoc_pkt: } else { /* TODO: HCTSIZ_DOPNG */ - DWC_OTG_WRITE_4(sc, DOTG_HCTSIZ(td->channel), + DWC_OTG_WRITE_4(sc, DOTG_HCTSIZ(channel), (count << HCTSIZ_XFERSIZE_SHIFT) | (1 << HCTSIZ_PKTCNT_SHIFT) | (td->toggle ? (HCTSIZ_PID_DATA1 << HCTSIZ_PID_SHIFT) : (HCTSIZ_PID_DATA0 << HCTSIZ_PID_SHIFT))); } - DWC_OTG_WRITE_4(sc, DOTG_HCSPLT(td->channel), td->hcsplt); - - /* send ASAP */ - if ((ep_type == UE_ISOCHRONOUS) && !(sc->sc_last_frame_num & 1)) - td->hcchar |= HCCHAR_ODDFRM; - else - td->hcchar &= ~HCCHAR_ODDFRM; + DWC_OTG_WRITE_4(sc, DOTG_HCSPLT(channel), td->hcsplt); hcchar = td->hcchar; hcchar &= ~HCCHAR_EPDIR_IN; + /* send after next SOF event */ + if ((sc->sc_last_frame_num & 1) == 0) + hcchar |= HCCHAR_ODDFRM; + else + hcchar &= ~HCCHAR_ODDFRM; + /* must enable before writing data to FIFO */ - DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(td->channel), hcchar); + DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(channel), hcchar); if (count != 0) { @@ -1940,7 +1870,7 @@ send_isoc_pkt: /* transfer data into FIFO */ bus_space_write_region_4(sc->sc_io_tag, sc->sc_io_hdl, - DOTG_DFIFO(td->channel), + DOTG_DFIFO(channel), sc->sc_tx_bounce_buffer, (count + 3) / 4); } @@ -1949,38 +1879,83 @@ send_isoc_pkt: goto busy; send_cpkt: - /* Wait for our turn, if TT transfer */ - if (td->tt_scheduled == 0 || - (sc->sc_last_frame_num & 7) < td->tt_complete_slot) { - /* set return state */ + /* free existing channel, if any */ + dwc_otg_host_channel_free(td, td->tt_channel_tog); + + delta = td->tt_complete_slot - sc->sc_last_frame_num - 1; + if (td->tt_scheduled == 0 || delta < DWC_OTG_TT_SLOT_MAX) { td->state = DWC_CHAN_ST_WAIT_C_PKT; - goto tt_wait; + goto busy; + } + delta = sc->sc_last_frame_num - td->tt_start_slot; + if (delta > DWC_OTG_TT_SLOT_MAX) { + /* we missed the service interval */ + if (td->ep_type != UE_ISOCHRONOUS) + td->error_any = 1; + goto complete; + } + + /* allocate a new channel */ + if (dwc_otg_host_channel_alloc(td, td->tt_channel_tog)) { + td->state = DWC_CHAN_ST_WAIT_C_PKT; + goto busy; } - /* wait until next slot before trying again */ - td->tt_complete_slot++; + + channel = td->channel[td->tt_channel_tog]; td->hcsplt |= HCSPLT_COMPSPLT; td->state = DWC_CHAN_ST_WAIT_C_ANE; - DWC_OTG_WRITE_4(sc, DOTG_HCTSIZ(td->channel), - (td->toggle ? (HCTSIZ_PID_DATA1 << HCTSIZ_PID_SHIFT) : - (HCTSIZ_PID_DATA0 << HCTSIZ_PID_SHIFT))); + DWC_OTG_WRITE_4(sc, DOTG_HCTSIZ(channel), + (HCTSIZ_PID_DATA0 << HCTSIZ_PID_SHIFT)); - DWC_OTG_WRITE_4(sc, DOTG_HCSPLT(td->channel), td->hcsplt); + DWC_OTG_WRITE_4(sc, DOTG_HCSPLT(channel), td->hcsplt); hcchar = td->hcchar; hcchar &= ~HCCHAR_EPDIR_IN; - /* must enable channel before writing data to FIFO */ - DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(td->channel), hcchar); - goto busy; + /* check if other channel is allocated */ + if (td->channel[td->tt_channel_tog ^ 1] < DWC_OTG_MAX_CHANNELS) { + /* second - receive after next SOF event */ + if ((sc->sc_last_frame_num & 1) != 0) + hcchar |= HCCHAR_ODDFRM; + else + hcchar &= ~HCCHAR_ODDFRM; + + /* other channel is next */ + td->tt_channel_tog ^= 1; + /* wait until next slot before trying again */ + td->tt_complete_slot++; + + /* must enable channel before data can be received */ + DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(channel), hcchar); + } else { + /* first - receive after second next SOF event */ + if ((sc->sc_last_frame_num & 1) == 0) + hcchar |= HCCHAR_ODDFRM; + else + hcchar &= ~HCCHAR_ODDFRM; -tt_wait: - /* free allocated channel */ - dwc_otg_host_channel_free(td); + /* must enable channel before data can be received */ + DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(channel), hcchar); + + if (td->hcsplt != 0) { + if (td->ep_type == UE_ISOCHRONOUS || td->ep_type == UE_INTERRUPT) { + /* allocate a second channel */ + td->tt_channel_tog ^= 1; + goto send_cpkt; + } else { + /* wait until next slot before trying again */ + td->tt_complete_slot++; + } + } + } busy: return (1); /* busy */ + complete: + dwc_otg_host_channel_free(td, 0); + dwc_otg_host_channel_free(td, 1); return (0); /* complete */ } @@ -2226,7 +2201,6 @@ dwc_otg_xfer_do_fifo(struct usb_xfer *xfer) { struct dwc_otg_td *td; uint8_t toggle; - uint8_t channel; uint8_t tmr_val; uint8_t tmr_res; @@ -2234,15 +2208,6 @@ dwc_otg_xfer_do_fifo(struct usb_xfer *xfer) td = xfer->td_transfer_cache; - /* - * If we are suspended in host mode and no channel is - * allocated, simply return: - */ - if (xfer->xroot->udev->flags.self_suspended != 0 && - xfer->xroot->udev->flags.usb_mode == USB_MODE_HOST && - td->channel >= DWC_OTG_MAX_CHANNELS) { - return (1); /* not complete */ - } while (1) { if ((td->func) (td)) { /* operation in progress */ @@ -2269,11 +2234,9 @@ dwc_otg_xfer_do_fifo(struct usb_xfer *xfer) tmr_res = td->tmr_res; tmr_val = td->tmr_val; toggle = td->toggle; - channel = td->channel; td = td->obj_next; xfer->td_transfer_cache = td; td->toggle = toggle; /* transfer toggle */ - td->channel = channel; /* transfer channel */ td->tmr_res = tmr_res; td->tmr_val = tmr_val; } @@ -2343,236 +2306,182 @@ dwc_otg_timer_stop(struct dwc_otg_softc *sc) usb_callout_stop(&sc->sc_timer); } -static void +static uint8_t dwc_otg_update_host_transfer_schedule(struct dwc_otg_softc *sc) { TAILQ_HEAD(, usb_xfer) head; struct usb_xfer *xfer; struct usb_xfer *xfer_next; struct dwc_otg_td *td; - uint8_t needsof; uint16_t temp; + uint8_t x; - /* FS/LS TT frames are one behind, so add one here */ - temp = (DWC_OTG_READ_4(sc, DOTG_HFNUM) + 1) & HFNUM_FRNUM_MASK; + temp = DWC_OTG_READ_4(sc, DOTG_HFNUM) & DWC_OTG_FRAME_MASK; if (sc->sc_last_frame_num == temp) - return; + return (0); sc->sc_last_frame_num = temp; - needsof = 0; - TAILQ_INIT(&head); - if (sc->sc_irq_mask & GINTMSK_SOFMSK) { - uint8_t x; - - for (x = 0; x != sc->sc_host_ch_max; x++) { - if (sc->sc_chan_state[x].wait_sof != 0) { - if (--(sc->sc_chan_state[x].wait_sof) != 0) - needsof = 1; - } - } - } - - if ((temp & 7) == 0) { - - /* reset TT info */ - memset(sc->sc_tt_info, 0, sizeof(sc->sc_tt_info)); - - /* - * Plan ahead FULL speed transfers going through the - * transaction translator, according to the USB - * specified priority: - */ - TAILQ_FOREACH_SAFE(xfer, &sc->sc_bus.intr_q.head, wait_entry, xfer_next) { - struct dwc_otg_tt_info *pinfo; - - td = xfer->td_transfer_cache; - if (td == NULL || td->did_nak != 0 || - (td->hcchar & HCCHAR_EPTYPE_MASK) != - (UE_CONTROL << HCCHAR_EPTYPE_SHIFT)) - continue; - - needsof = 1; - - if (td->hcsplt == 0) - continue; + for (x = 0; x != sc->sc_host_ch_max; x++) { + uint32_t hcchar; - /* Reset state if stuck waiting for complete split */ - if (td->state == DWC_CHAN_ST_WAIT_C_PKT) - td->state = DWC_CHAN_ST_START; + if (sc->sc_chan_state[x].wait_sof == 0) + continue; - pinfo = sc->sc_tt_info + td->tt_index; + sc->sc_needsof = 1; + sc->sc_chan_state[x].wait_sof--; + if (sc->sc_chan_state[x].wait_sof != 0) + continue; - td->tt_start_slot = pinfo->slot_index; - pinfo->bytes_used += td->max_packet_size; - while (pinfo->bytes_used >= HCSPLT_XACTLEN_MAX) { - pinfo->bytes_used -= HCSPLT_XACTLEN_MAX; - pinfo->slot_index ++; - } + hcchar = DWC_OTG_READ_4(sc, DOTG_HCCHAR(x)); - td->tt_complete_slot = pinfo->slot_index + 2; - if (td->tt_complete_slot < 8) { - td->tt_scheduled = 1; - TAILQ_REMOVE(&sc->sc_bus.intr_q.head, xfer, wait_entry); - TAILQ_INSERT_TAIL(&head, xfer, wait_entry); - } else { - td->tt_scheduled = 0; - } + /* disable host channel, if any */ + if (hcchar & (HCCHAR_CHENA | HCCHAR_CHDIS)) { + /* disable channel */ + DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(x), + HCCHAR_CHENA | HCCHAR_CHDIS); + /* wait for chip to get its brains in order */ + sc->sc_chan_state[x].wait_sof = 2; } + } + if ((temp & 7) == 0) { TAILQ_FOREACH_SAFE(xfer, &sc->sc_bus.intr_q.head, wait_entry, xfer_next) { - struct dwc_otg_tt_info *pinfo; - td = xfer->td_transfer_cache; - if (td == NULL || - (td->hcchar & HCCHAR_EPTYPE_MASK) != - (UE_ISOCHRONOUS << HCCHAR_EPTYPE_SHIFT)) + if (td == NULL || td->ep_type != UE_ISOCHRONOUS) continue; /* execute more frames */ td->tmr_val = 0; - needsof = 1; + sc->sc_needsof = 1; - if (td->hcsplt == 0) + if (td->hcsplt == 0 || td->tt_scheduled != 0) continue; - /* Reset state if stuck waiting for complete split */ - if (td->state == DWC_CHAN_ST_WAIT_C_PKT) - td->state = DWC_CHAN_ST_START; - - pinfo = sc->sc_tt_info + td->tt_index; - - td->tt_start_slot = pinfo->slot_index; - pinfo->bytes_used += td->remainder; - while (pinfo->bytes_used >= HCSPLT_XACTLEN_MAX) { - pinfo->bytes_used -= HCSPLT_XACTLEN_MAX; - pinfo->slot_index ++; - } - - td->tt_complete_slot = pinfo->slot_index + 2; - if (td->tt_complete_slot < 8) { - td->tt_scheduled = 1; - TAILQ_REMOVE(&sc->sc_bus.intr_q.head, xfer, wait_entry); - TAILQ_INSERT_TAIL(&head, xfer, wait_entry); - } else { - td->tt_scheduled = 0; - } + /* Start ASAP */ + td->tt_start_slot = temp + 0; + td->tt_complete_slot = temp + 2; + td->tt_scheduled = 1; + TAILQ_REMOVE(&sc->sc_bus.intr_q.head, xfer, wait_entry); + TAILQ_INSERT_TAIL(&head, xfer, wait_entry); } TAILQ_FOREACH_SAFE(xfer, &sc->sc_bus.intr_q.head, wait_entry, xfer_next) { - struct dwc_otg_tt_info *pinfo; - td = xfer->td_transfer_cache; - if (td == NULL || - (td->hcchar & HCCHAR_EPTYPE_MASK) != - (UE_INTERRUPT << HCCHAR_EPTYPE_SHIFT)) { + if (td == NULL || td->ep_type != UE_INTERRUPT) + continue; + + if (td->tt_scheduled != 0) { + sc->sc_needsof = 1; continue; } if (dwc_otg_host_rate_check_interrupt(sc, td)) continue; - needsof = 1; - if (td->hcsplt == 0) { + sc->sc_needsof = 1; td->tt_scheduled = 1; continue; } - /* Reset state if stuck waiting for complete split */ - if (td->state == DWC_CHAN_ST_WAIT_C_PKT) - td->state = DWC_CHAN_ST_START; + /* start ASAP */ + td->tt_start_slot = temp + 0; + td->tt_complete_slot = temp + 2; + sc->sc_needsof = 1; + td->tt_scheduled = 1; + TAILQ_REMOVE(&sc->sc_bus.intr_q.head, xfer, wait_entry); + TAILQ_INSERT_TAIL(&head, xfer, wait_entry); + } - pinfo = sc->sc_tt_info + td->tt_index; + TAILQ_FOREACH_SAFE(xfer, &sc->sc_bus.intr_q.head, wait_entry, xfer_next) { + td = xfer->td_transfer_cache; + if (td == NULL || td->did_nak != 0 || td->ep_type != UE_CONTROL) + continue; - td->tt_start_slot = pinfo->slot_index; - pinfo->bytes_used += td->remainder; - while (pinfo->bytes_used >= HCSPLT_XACTLEN_MAX) { - pinfo->bytes_used -= HCSPLT_XACTLEN_MAX; - pinfo->slot_index ++; - } + sc->sc_needsof = 1; - td->tt_complete_slot = pinfo->slot_index + 2; - if (td->tt_complete_slot < 8) { - td->tt_scheduled = 1; - TAILQ_REMOVE(&sc->sc_bus.intr_q.head, xfer, wait_entry); - TAILQ_INSERT_TAIL(&head, xfer, wait_entry); - } else { - td->tt_scheduled = 0; - } + if (td->hcsplt == 0 || td->tt_scheduled != 0) + continue; + + /* start ASAP */ + td->tt_start_slot = temp + 0; + td->tt_complete_slot = temp + 1; + td->tt_scheduled = 1; + TAILQ_REMOVE(&sc->sc_bus.intr_q.head, xfer, wait_entry); + TAILQ_INSERT_TAIL(&head, xfer, wait_entry); } } - if ((temp & 7) < 6) { TAILQ_FOREACH_SAFE(xfer, &sc->sc_bus.intr_q.head, wait_entry, xfer_next) { - struct dwc_otg_tt_info *pinfo; - td = xfer->td_transfer_cache; - if (td == NULL || td->did_nak != 0 || - (td->hcchar & HCCHAR_EPTYPE_MASK) != - (UE_BULK << HCCHAR_EPTYPE_SHIFT)) { + if (td == NULL || td->did_nak != 0 || td->ep_type != UE_BULK) continue; - } - needsof = 1; + sc->sc_needsof = 1; - if (td->hcsplt == 0) + if (td->hcsplt == 0 || td->tt_scheduled != 0) continue; - if ((temp & 7) == 0) { - /* Reset state if stuck waiting for complete split */ - if (td->state == DWC_CHAN_ST_WAIT_C_PKT) - td->state = DWC_CHAN_ST_START; - } else if (td->tt_scheduled != 0) - continue; /* already scheduled */ - - pinfo = sc->sc_tt_info + td->tt_index; - - td->tt_start_slot = pinfo->slot_index; - pinfo->bytes_used += td->remainder; - while (pinfo->bytes_used >= HCSPLT_XACTLEN_MAX) { - pinfo->bytes_used -= HCSPLT_XACTLEN_MAX; - pinfo->slot_index ++; - } - - td->tt_complete_slot = pinfo->slot_index + 2; - if (td->tt_complete_slot < 8) { - td->tt_scheduled = 1; - TAILQ_REMOVE(&sc->sc_bus.intr_q.head, xfer, wait_entry); - TAILQ_INSERT_TAIL(&head, xfer, wait_entry); - } else { - td->tt_scheduled = 0; - } + /* start ASAP */ + td->tt_start_slot = temp + 0; + td->tt_complete_slot = temp + 1; + td->tt_scheduled = 1; + TAILQ_REMOVE(&sc->sc_bus.intr_q.head, xfer, wait_entry); + TAILQ_INSERT_TAIL(&head, xfer, wait_entry); } } - /* TT transfers need to be executed in a specific order */ + /* Put TT transfers in execution order at the end */ + TAILQ_CONCAT(&sc->sc_bus.intr_q.head, &head, wait_entry); + + /* move all TT transfers in front, keeping the current order */ + TAILQ_FOREACH_SAFE(xfer, &sc->sc_bus.intr_q.head, wait_entry, xfer_next) { + td = xfer->td_transfer_cache; + if (td == NULL || td->hcsplt == 0) + continue; + TAILQ_REMOVE(&sc->sc_bus.intr_q.head, xfer, wait_entry); + TAILQ_INSERT_TAIL(&head, xfer, wait_entry); + } TAILQ_CONCAT(&head, &sc->sc_bus.intr_q.head, wait_entry); + TAILQ_CONCAT(&sc->sc_bus.intr_q.head, &head, wait_entry); - /* Put TT transfers first in the queue */ + /* put non-TT BULK transfers last */ + TAILQ_FOREACH_SAFE(xfer, &sc->sc_bus.intr_q.head, wait_entry, xfer_next) { + td = xfer->td_transfer_cache; + if (td == NULL || td->hcsplt != 0 || td->ep_type != UE_BULK) + continue; + TAILQ_REMOVE(&sc->sc_bus.intr_q.head, xfer, wait_entry); + TAILQ_INSERT_TAIL(&head, xfer, wait_entry); + } TAILQ_CONCAT(&sc->sc_bus.intr_q.head, &head, wait_entry); if ((temp & 7) == 0) { + DPRINTFN(12, "SOF interrupt #%d, needsof=%d\n", - (int)temp, (int)needsof); + (int)temp, (int)sc->sc_needsof); /* update SOF IRQ mask */ if (sc->sc_irq_mask & GINTMSK_SOFMSK) { - if (needsof == 0) { + if (sc->sc_needsof == 0) { sc->sc_irq_mask &= ~GINTMSK_SOFMSK; DWC_OTG_WRITE_4(sc, DOTG_GINTMSK, sc->sc_irq_mask); } } else { - if (needsof != 0) { + if (sc->sc_needsof != 0) { sc->sc_irq_mask |= GINTMSK_SOFMSK; DWC_OTG_WRITE_4(sc, DOTG_GINTMSK, sc->sc_irq_mask); } } + + /* clear need SOF flag */ + sc->sc_needsof = 0; } + return (1); } static void @@ -2669,19 +2578,6 @@ repeat: } } - if (sc->sc_flags.status_device_mode == 0) { - /* update host transfer schedule, so that new transfers can be issued */ - dwc_otg_update_host_transfer_schedule(sc); - - /* start re-scheduled transfers */ - TAILQ_FOREACH(xfer, &sc->sc_bus.intr_q.head, wait_entry) { - if (!dwc_otg_xfer_do_fifo(xfer)) { - /* queue has been modified */ - goto repeat; - } - } - } - if (got_rx_status) { /* check if data was consumed */ if (sc->sc_last_rx_status == 0) @@ -2691,6 +2587,12 @@ repeat: sc->sc_irq_mask &= ~GINTMSK_RXFLVLMSK; DWC_OTG_WRITE_4(sc, DOTG_GINTMSK, sc->sc_irq_mask); } + + if (sc->sc_flags.status_device_mode == 0) { + /* update host transfer schedule, so that new transfers can be issued */ + if (dwc_otg_update_host_transfer_schedule(sc)) + goto repeat; + } } static void @@ -2777,7 +2679,7 @@ dwc_otg_interrupt(struct dwc_otg_softc *sc) sc->sc_flags.port_enabled = 1; /* reset FIFOs */ - dwc_otg_init_fifo(sc, DWC_MODE_DEVICE); + (void) dwc_otg_init_fifo(sc, DWC_MODE_DEVICE); /* reset function address */ dwc_otg_set_address(sc, 0); @@ -2952,11 +2854,12 @@ dwc_otg_setup_standard_chain_sub(struct dwc_otg_std_temp *temp) td->set_toggle = 0; td->got_short = 0; td->did_nak = 0; - td->channel = DWC_OTG_MAX_CHANNELS; + td->channel[0] = DWC_OTG_MAX_CHANNELS; + td->channel[1] = DWC_OTG_MAX_CHANNELS; td->state = 0; td->errcnt = 0; td->tt_scheduled = 0; - td->tt_index = temp->tt_index; + td->tt_channel_tog = 0; td->tt_xactpos = HCSPLT_XACTPOS_BEGIN; } @@ -2965,7 +2868,6 @@ dwc_otg_setup_standard_chain(struct usb_xfer *xfer) { struct dwc_otg_std_temp temp; struct dwc_otg_td *td; - struct usb_device *udev; uint32_t x; uint8_t need_sync; uint8_t is_host; @@ -2976,16 +2878,6 @@ dwc_otg_setup_standard_chain(struct usb_xfer *xfer) temp.max_frame_size = xfer->max_frame_size; - udev = xfer->xroot->udev; - if (udev->parent_hs_hub != NULL && udev->speed != USB_SPEED_HIGH) { - if (udev->parent_hs_hub->ddesc.bDeviceProtocol == UDPROTO_HSHUBMTT) - temp.tt_index = udev->device_index; - else - temp.tt_index = udev->parent_hs_hub->device_index; - } else { - temp.tt_index = udev->device_index; - } - td = xfer->td_start[0]; xfer->td_transfer_first = td; xfer->td_transfer_cache = td; @@ -3170,10 +3062,8 @@ dwc_otg_setup_standard_chain(struct usb_xfer *xfer) struct dwc_otg_softc *sc; uint32_t hcchar; uint32_t hcsplt; - uint8_t xfer_type; sc = DWC_OTG_BUS2SC(xfer->xroot->bus); - xfer_type = xfer->endpoint->edesc->bmAttributes & UE_XFERTYPE; /* get first again */ td = xfer->td_transfer_first; @@ -3181,11 +3071,16 @@ dwc_otg_setup_standard_chain(struct usb_xfer *xfer) hcchar = (xfer->address << HCCHAR_DEVADDR_SHIFT) | - (xfer_type << HCCHAR_EPTYPE_SHIFT) | ((xfer->endpointno & UE_ADDR) << HCCHAR_EPNUM_SHIFT) | (xfer->max_packet_size << HCCHAR_MPS_SHIFT) | HCCHAR_CHENA; + /* XXX stability hack - possible HW issue */ + if (td->ep_type == UE_CONTROL) + hcchar |= (UE_BULK << HCCHAR_EPTYPE_SHIFT); + else + hcchar |= (td->ep_type << HCCHAR_EPTYPE_SHIFT); + if (usbd_get_speed(xfer->xroot->udev) == USB_SPEED_LOW) hcchar |= HCCHAR_LSPDDEV; if (UE_GET_DIR(xfer->endpointno) == UE_DIR_IN) @@ -3204,7 +3099,7 @@ dwc_otg_setup_standard_chain(struct usb_xfer *xfer) } else { hcsplt = 0; } - if (xfer_type == UE_INTERRUPT) { + if (td->ep_type == UE_INTERRUPT) { uint32_t ival; ival = xfer->interval / DWC_OTG_HOST_TIMER_RATE; if (ival == 0) @@ -3213,7 +3108,7 @@ dwc_otg_setup_standard_chain(struct usb_xfer *xfer) ival = 127; td->tmr_val = sc->sc_tmr_val + ival; td->tmr_res = ival; - } else if (xfer_type == UE_ISOCHRONOUS) { + } else if (td->ep_type == UE_ISOCHRONOUS) { td->tmr_val = 0; td->tmr_res = 1; } else { @@ -3223,12 +3118,12 @@ dwc_otg_setup_standard_chain(struct usb_xfer *xfer) break; case USB_SPEED_HIGH: hcsplt = 0; - if (xfer_type == UE_ISOCHRONOUS || - xfer_type == UE_INTERRUPT) { + if (td->ep_type == UE_ISOCHRONOUS || + td->ep_type == UE_INTERRUPT) { hcchar |= ((xfer->max_packet_count & 3) << HCCHAR_MC_SHIFT); } - if (xfer_type == UE_INTERRUPT) { + if (td->ep_type == UE_INTERRUPT) { uint32_t ival; ival = xfer->interval / DWC_OTG_HOST_TIMER_RATE; if (ival == 0) @@ -3237,7 +3132,7 @@ dwc_otg_setup_standard_chain(struct usb_xfer *xfer) ival = 127; td->tmr_val = sc->sc_tmr_val + ival; td->tmr_res = ival; - } else if (xfer_type == UE_ISOCHRONOUS) { + } else if (td->ep_type == UE_ISOCHRONOUS) { td->tmr_val = 0; td->tmr_res = 1 << usbd_xfer_get_fps_shift(xfer); } else { @@ -3446,8 +3341,10 @@ dwc_otg_device_done(struct usb_xfer *xfer, usb_error_t error) td = xfer->td_transfer_first; - if (td != NULL) - dwc_otg_host_channel_free(td); + if (td != NULL) { + dwc_otg_host_channel_free(td, 0); + dwc_otg_host_channel_free(td, 1); + } } /* dequeue transfer and start next transfer */ usbd_transfer_done(xfer, error); @@ -3755,8 +3652,10 @@ dwc_otg_init(struct dwc_otg_softc *sc) sc->sc_host_ch_max); /* setup FIFO */ - if (dwc_otg_init_fifo(sc, sc->sc_mode)) + if (dwc_otg_init_fifo(sc, sc->sc_mode)) { + USB_BUS_UNLOCK(&sc->sc_bus); return (EINVAL); + } /* enable interrupts */ sc->sc_irq_mask = DWC_OTG_MSK_GINT_ENABLED; @@ -4445,7 +4344,7 @@ tr_handle_set_port_feature: usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 16); /* reset FIFOs */ - dwc_otg_init_fifo(sc, DWC_MODE_HOST); + (void) dwc_otg_init_fifo(sc, DWC_MODE_HOST); sc->sc_flags.change_reset = 1; } else { @@ -4555,6 +4454,7 @@ dwc_otg_xfer_setup(struct usb_setup_params *parm) uint32_t ntd; uint32_t n; uint8_t ep_no; + uint8_t ep_type; xfer = parm->curr_xfer; @@ -4572,7 +4472,9 @@ dwc_otg_xfer_setup(struct usb_setup_params *parm) /* * compute maximum number of TDs */ - if ((xfer->endpoint->edesc->bmAttributes & UE_XFERTYPE) == UE_CONTROL) { + ep_type = (xfer->endpoint->edesc->bmAttributes & UE_XFERTYPE); + + if (ep_type == UE_CONTROL) { ntd = xfer->nframes + 1 /* STATUS */ + 1 /* SYNC 1 */ + 1 /* SYNC 2 */ + 1 /* SYNC 3 */; @@ -4624,6 +4526,7 @@ dwc_otg_xfer_setup(struct usb_setup_params *parm) td->max_packet_size = xfer->max_packet_size; td->max_packet_count = xfer->max_packet_count; td->ep_no = ep_no; + td->ep_type = ep_type; td->obj_next = last_obj; last_obj = td; @@ -4659,6 +4562,14 @@ dwc_otg_ep_init(struct usb_device *udev, struct usb_endpoint_descriptor *edesc, /* not supported */ return; } + } else { + if (udev->speed == USB_SPEED_HIGH) { + if ((UGETW(edesc->wMaxPacketSize) >> 11) & 3) { + /* high bandwidth endpoint - not tested */ + DPRINTF("High Bandwidth Endpoint - not tested\n"); + return; + } + } } if ((edesc->bmAttributes & UE_XFERTYPE) == UE_ISOCHRONOUS) ep->methods = &dwc_otg_device_isoc_methods; @@ -4697,29 +4608,8 @@ dwc_otg_get_dma_delay(struct usb_device *udev, uint32_t *pus) static void dwc_otg_device_resume(struct usb_device *udev) { - struct dwc_otg_softc *sc = DWC_OTG_BUS2SC(udev->bus); - struct usb_xfer *xfer; - struct dwc_otg_td *td; - DPRINTF("\n"); - /* Enable relevant Host channels before resuming */ - - USB_BUS_LOCK(udev->bus); - - TAILQ_FOREACH(xfer, &sc->sc_bus.intr_q.head, wait_entry) { - - if (xfer->xroot->udev == udev) { - - td = xfer->td_transfer_cache; - if (td != NULL && - td->channel < DWC_OTG_MAX_CHANNELS) - sc->sc_chan_state[td->channel].suspended = 0; - } - } - - USB_BUS_UNLOCK(udev->bus); - /* poll all transfers again to restart resumed ones */ dwc_otg_do_poll(udev->bus); } @@ -4727,28 +4617,7 @@ dwc_otg_device_resume(struct usb_device *udev) static void dwc_otg_device_suspend(struct usb_device *udev) { - struct dwc_otg_softc *sc = DWC_OTG_BUS2SC(udev->bus); - struct usb_xfer *xfer; - struct dwc_otg_td *td; - DPRINTF("\n"); - - /* Disable relevant Host channels before going to suspend */ - - USB_BUS_LOCK(udev->bus); - - TAILQ_FOREACH(xfer, &sc->sc_bus.intr_q.head, wait_entry) { - - if (xfer->xroot->udev == udev) { - - td = xfer->td_transfer_cache; - if (td != NULL && - td->channel < DWC_OTG_MAX_CHANNELS) - sc->sc_chan_state[td->channel].suspended = 1; - } - } - - USB_BUS_UNLOCK(udev->bus); } static const struct usb_bus_methods dwc_otg_bus_methods = diff --git a/sys/dev/usb/controller/dwc_otg.h b/sys/dev/usb/controller/dwc_otg.h index 2ae2eaeb60141..f2a54a6f9d869 100644 --- a/sys/dev/usb/controller/dwc_otg.h +++ b/sys/dev/usb/controller/dwc_otg.h @@ -34,6 +34,8 @@ #define DWC_OTG_MAX_CHANNELS 16 #define DWC_OTG_MAX_ENDPOINTS 16 #define DWC_OTG_HOST_TIMER_RATE 10 /* ms */ +#define DWC_OTG_TT_SLOT_MAX 8 +#define DWC_OTG_SLOT_IDLE_MAX 4 #define DWC_OTG_READ_4(sc, reg) \ bus_space_read_4((sc)->sc_io_tag, (sc)->sc_io_hdl, reg) @@ -62,8 +64,8 @@ struct dwc_otg_td { uint8_t tmr_res; uint8_t tmr_val; uint8_t ep_no; - uint8_t channel; - uint8_t tt_index; /* TT data */ + uint8_t ep_type; + uint8_t channel[2]; uint8_t tt_start_slot; /* TT data */ uint8_t tt_complete_slot; /* TT data */ uint8_t tt_xactpos; /* TT data */ @@ -86,6 +88,7 @@ struct dwc_otg_td { uint8_t got_short:1; uint8_t did_nak:1; uint8_t tt_scheduled:1; + uint8_t tt_channel_tog:1; }; struct dwc_otg_std_temp { @@ -105,7 +108,6 @@ struct dwc_otg_std_temp { uint8_t setup_alt_next; uint8_t did_stall; uint8_t bulk_or_control; - uint8_t tt_index; }; struct dwc_otg_config_desc { @@ -145,17 +147,11 @@ struct dwc_otg_profile { }; struct dwc_otg_chan_state { + uint16_t allocated; + uint16_t wait_sof; uint32_t hcint; - uint32_t tx_size; - uint8_t wait_sof; - uint8_t allocated; - uint8_t suspended; -}; - -struct dwc_otg_tt_info { - uint16_t bytes_used; - uint8_t slot_index; - uint8_t dummy; + uint16_t tx_p_size; /* periodic */ + uint16_t tx_np_size; /* non-periodic */ }; struct dwc_otg_softc { @@ -177,7 +173,8 @@ struct dwc_otg_softc { uint32_t sc_fifo_size; uint32_t sc_tx_max_size; - uint32_t sc_tx_cur_size; + uint32_t sc_tx_cur_p_level; /* periodic */ + uint32_t sc_tx_cur_np_level; /* non-periodic */ uint32_t sc_irq_mask; uint32_t sc_last_rx_status; uint32_t sc_out_ctl[DWC_OTG_MAX_ENDPOINTS]; @@ -186,7 +183,6 @@ struct dwc_otg_softc { uint32_t sc_tmr_val; uint32_t sc_hprt_val; - struct dwc_otg_tt_info sc_tt_info[DWC_OTG_MAX_DEVICES]; uint16_t sc_active_rx_ep; uint16_t sc_last_frame_num; @@ -194,6 +190,7 @@ struct dwc_otg_softc { uint8_t sc_dev_ep_max; uint8_t sc_dev_in_ep_max; uint8_t sc_host_ch_max; + uint8_t sc_needsof; uint8_t sc_rt_addr; /* root HUB address */ uint8_t sc_conf; /* root HUB config */ uint8_t sc_mode; /* mode of operation */ diff --git a/sys/dev/usb/controller/dwc_otg_fdt.c b/sys/dev/usb/controller/dwc_otg_fdt.c index 78bb801edf5ba..d7de56799a884 100644 --- a/sys/dev/usb/controller/dwc_otg_fdt.c +++ b/sys/dev/usb/controller/dwc_otg_fdt.c @@ -146,7 +146,7 @@ dwc_otg_attach(device_t dev) device_set_ivars(sc->sc_otg.sc_bus.bdev, &sc->sc_otg.sc_bus); - err = bus_setup_intr(dev, sc->sc_otg.sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE, + err = bus_setup_intr(dev, sc->sc_otg.sc_irq_res, INTR_TYPE_TTY | INTR_MPSAFE, NULL, (driver_intr_t *)dwc_otg_interrupt, sc, &sc->sc_otg.sc_intr_hdl); if (err) { sc->sc_otg.sc_intr_hdl = NULL; diff --git a/sys/dev/usb/controller/dwc_otgreg.h b/sys/dev/usb/controller/dwc_otgreg.h index cd2f45de32a60..344d36a28534f 100644 --- a/sys/dev/usb/controller/dwc_otgreg.h +++ b/sys/dev/usb/controller/dwc_otgreg.h @@ -540,7 +540,7 @@ #define HCSPLT_XACTPOS_LAST 1 #define HCSPLT_XACTPOS_BEGIN 2 #define HCSPLT_XACTPOS_ALL 3 -#define HCSPLT_XACTLEN_MAX 188 /* bytes */ +#define HCSPLT_XACTLEN_BURST 1023 /* bytes */ #define HCSPLT_HUBADDR_SHIFT 7 #define HCSPLT_HUBADDR_MASK 0x00003f80 #define HCSPLT_PRTADDR_SHIFT 0 @@ -555,6 +555,9 @@ HCINT_XACTERR | HCINT_NAK | HCINT_ACK | HCINT_NYET | \ HCINT_CHHLTD | HCINT_FRMOVRUN | \ HCINT_DATATGLERR) +#define HCINT_HCH_DONE_MASK \ + (HCINT_ACK | HCINT_RETRY | HCINT_NYET | \ + HCINT_ERRORS | HCINT_STALL | HCINT_SOFTWARE_ONLY) #define HCINT_SOFTWARE_ONLY (1<<20) /* BSD only */ #define HCINT_DATATGLERR (1<<10) -- cgit v1.3 From 897b7965df2d9fc0ccd49a70dcc048d5234482cb Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Fri, 9 May 2014 16:40:41 +0000 Subject: Fix a regression issue: - ACK can be received before data arrives in RX FIFO. Handle this. - Remove obsolete comment. - Some minor code styling. MFC after: 2 weeks --- sys/dev/usb/controller/dwc_otg.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/dwc_otg.c b/sys/dev/usb/controller/dwc_otg.c index 3f4d3a00047c7..0b203ddd1e64f 100644 --- a/sys/dev/usb/controller/dwc_otg.c +++ b/sys/dev/usb/controller/dwc_otg.c @@ -1240,6 +1240,10 @@ check_state: goto complete; } } else if (hcint & HCINT_ACK) { + /* wait for data - ACK arrived first */ + if (!(hcint & HCINT_SOFTWARE_ONLY)) + goto busy; + if (td->ep_type == UE_ISOCHRONOUS) { /* check if we are complete */ if ((td->remainder == 0) || @@ -1595,8 +1599,6 @@ dwc_otg_host_data_tx(struct dwc_otg_td *td) } } - /* channel must be disabled before we can complete the transfer */ - if (hcint & (HCINT_ERRORS | HCINT_RETRY | HCINT_ACK | HCINT_NYET)) { @@ -1646,15 +1648,13 @@ check_state: break; case DWC_CHAN_ST_WAIT_C_ANE: - if (hcint & HCINT_NYET) + if (hcint & HCINT_NYET) { goto send_cpkt; - - if (hcint & (HCINT_RETRY | HCINT_ERRORS)) { + } else if (hcint & (HCINT_RETRY | HCINT_ERRORS)) { td->did_nak = 1; td->tt_scheduled = 0; goto send_pkt; - } - if (hcint & HCINT_ACK) { + } else if (hcint & HCINT_ACK) { td->offset += td->tx_bytes; td->remainder -= td->tx_bytes; td->toggle ^= 1; -- cgit v1.3 From e2192fdfc691176d1280cadb9f8d22ba1bbe2351 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Sat, 10 May 2014 07:37:32 +0000 Subject: Optimise host channel disabling: - For non-periodic traffic we only need to wait two SOFs before disabling the channel. - Make sure we release the TX FIFO tracking level after the host channel is disabled. - Make sure the host channel state gets reset/disabled initially. - Two minor code style changes. MFC after: 2 weeks --- sys/dev/usb/controller/dwc_otg.c | 105 +++++++++++++++++++++++++-------------- sys/dev/usb/controller/dwc_otg.h | 1 + 2 files changed, 68 insertions(+), 38 deletions(-) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/dwc_otg.c b/sys/dev/usb/controller/dwc_otg.c index 0b203ddd1e64f..c225bac7fb685 100644 --- a/sys/dev/usb/controller/dwc_otg.c +++ b/sys/dev/usb/controller/dwc_otg.c @@ -141,6 +141,7 @@ static void dwc_otg_do_poll(struct usb_bus *); static void dwc_otg_standard_done(struct usb_xfer *); static void dwc_otg_root_intr(struct dwc_otg_softc *); static void dwc_otg_interrupt_poll(struct dwc_otg_softc *); +static void dwc_otg_host_channel_disable(struct dwc_otg_softc *, uint8_t); /* * Here is a configuration that the chip supports. @@ -210,6 +211,13 @@ dwc_otg_init_fifo(struct dwc_otg_softc *sc, uint8_t mode) return (EINVAL); } + /* disable any leftover host channels */ + for (x = 0; x != sc->sc_host_ch_max; x++) { + if (sc->sc_chan_state[x].wait_sof == 0) + continue; + dwc_otg_host_channel_disable(sc, x); + } + if (mode == DWC_MODE_HOST) { /* reset active endpoints */ @@ -236,6 +244,9 @@ dwc_otg_init_fifo(struct dwc_otg_softc *sc, uint8_t mode) ((fifo_size / 4) << 16) | (tx_start / 4)); + /* reset host channel state */ + memset(sc->sc_chan_state, 0, sizeof(sc->sc_chan_state)); + /* reset FIFO TX levels */ sc->sc_tx_cur_p_level = 0; sc->sc_tx_cur_np_level = 0; @@ -326,6 +337,9 @@ dwc_otg_init_fifo(struct dwc_otg_softc *sc, uint8_t mode) /* reset periodic and non-periodic FIFO TX size */ sc->sc_tx_max_size = fifo_size; + /* reset host channel state */ + memset(sc->sc_chan_state, 0, sizeof(sc->sc_chan_state)); + /* reset FIFO TX levels */ sc->sc_tx_cur_p_level = 0; sc->sc_tx_cur_np_level = 0; @@ -569,7 +583,7 @@ dwc_otg_clear_hcint(struct dwc_otg_softc *sc, uint8_t x) } static uint8_t -dwc_otg_host_channel_alloc(struct dwc_otg_td *td, uint8_t which) +dwc_otg_host_channel_alloc(struct dwc_otg_td *td, uint8_t which, uint8_t is_out) { struct dwc_otg_softc *sc; uint32_t tx_p_size; @@ -587,11 +601,7 @@ dwc_otg_host_channel_alloc(struct dwc_otg_td *td, uint8_t which) sc = DWC_OTG_PC2SC(td->pc); /* compute needed TX FIFO size */ - if (td->ep_type == UE_CONTROL) { - /* RX and TX transactions */ - tx_p_size = 0; - tx_np_size = td->max_packet_size; - } else if ((td->hcchar & HCCHAR_EPDIR) == HCCHAR_EPDIR_OUT) { + if (is_out != 0) { if (td->ep_type == UE_INTERRUPT || td->ep_type == UE_ISOCHRONOUS) { tx_p_size = td->max_packet_size; @@ -669,12 +679,22 @@ dwc_otg_host_channel_free(struct dwc_otg_td *td, uint8_t which) /* get pointer to softc */ sc = DWC_OTG_PC2SC(td->pc); - sc->sc_chan_state[x].wait_sof = DWC_OTG_SLOT_IDLE_MAX; - sc->sc_chan_state[x].allocated = 0; - /* keep track of used TX FIFO, if any */ - sc->sc_tx_cur_p_level -= sc->sc_chan_state[x].tx_p_size; - sc->sc_tx_cur_np_level -= sc->sc_chan_state[x].tx_np_size; + /* + * We need to let programmed host channels run till complete + * else the host channel will stop functioning. Assume that + * after a fixed given amount of time the host channel is no + * longer doing any USB traffic: + */ + if (td->ep_type == UE_ISOCHRONOUS || td->ep_type == UE_INTERRUPT) { + /* double buffered */ + sc->sc_chan_state[x].wait_sof = DWC_OTG_SLOT_IDLE_MAX; + } else { + /* single buffered */ + sc->sc_chan_state[x].wait_sof = DWC_OTG_SLOT_IDLE_MIN; + } + + sc->sc_chan_state[x].allocated = 0; /* ack any pending messages */ if (sc->sc_last_rx_status != 0 && @@ -810,7 +830,7 @@ send_pkt: } /* allocate a new channel */ - if (dwc_otg_host_channel_alloc(td, 0)) { + if (dwc_otg_host_channel_alloc(td, 0, 1)) { td->state = DWC_CHAN_ST_START; goto busy; } @@ -863,7 +883,7 @@ send_cpkt: goto complete; } /* allocate a new channel */ - if (dwc_otg_host_channel_alloc(td, 0)) { + if (dwc_otg_host_channel_alloc(td, 0, 0)) { td->state = DWC_CHAN_ST_WAIT_C_PKT; goto busy; } @@ -1322,7 +1342,7 @@ receive_pkt: } /* allocate a new channel */ - if (dwc_otg_host_channel_alloc(td, td->tt_channel_tog)) { + if (dwc_otg_host_channel_alloc(td, td->tt_channel_tog, 0)) { td->state = DWC_CHAN_ST_WAIT_C_PKT; goto busy; } @@ -1404,7 +1424,7 @@ receive_spkt: } /* allocate a new channel */ - if (dwc_otg_host_channel_alloc(td, 0)) { + if (dwc_otg_host_channel_alloc(td, 0, 0)) { td->state = DWC_CHAN_ST_START; goto busy; } @@ -1616,8 +1636,7 @@ check_state: td->did_nak = 1; td->tt_scheduled = 0; goto send_pkt; - } - if (hcint & (HCINT_ACK | HCINT_NYET)) { + } else if (hcint & (HCINT_ACK | HCINT_NYET)) { td->offset += td->tx_bytes; td->remainder -= td->tx_bytes; td->toggle ^= 1; @@ -1642,8 +1661,7 @@ check_state: td->did_nak = 1; td->tt_scheduled = 0; goto send_pkt; - } - if (hcint & (HCINT_ACK | HCINT_NYET)) + } else if (hcint & (HCINT_ACK | HCINT_NYET)) goto send_cpkt; break; @@ -1698,7 +1716,7 @@ check_state: /* FALLTHROUGH */ case DWC_CHAN_ST_TX_PKT_ISOC: - if (dwc_otg_host_channel_alloc(td, 0)) + if (dwc_otg_host_channel_alloc(td, 0, 1)) break; channel = td->channel[0]; goto send_isoc_pkt; @@ -1731,7 +1749,7 @@ send_pkt: } /* allocate a new channel */ - if (dwc_otg_host_channel_alloc(td, 0)) { + if (dwc_otg_host_channel_alloc(td, 0, 1)) { td->state = DWC_CHAN_ST_START; goto busy; } @@ -1896,7 +1914,7 @@ send_cpkt: } /* allocate a new channel */ - if (dwc_otg_host_channel_alloc(td, td->tt_channel_tog)) { + if (dwc_otg_host_channel_alloc(td, td->tt_channel_tog, 0)) { td->state = DWC_CHAN_ST_WAIT_C_PKT; goto busy; } @@ -2306,6 +2324,31 @@ dwc_otg_timer_stop(struct dwc_otg_softc *sc) usb_callout_stop(&sc->sc_timer); } +static void +dwc_otg_host_channel_disable(struct dwc_otg_softc *sc, uint8_t x) +{ + uint32_t hcchar; + + hcchar = DWC_OTG_READ_4(sc, DOTG_HCCHAR(x)); + + /* disable host channel, if any */ + if (hcchar & (HCCHAR_CHENA | HCCHAR_CHDIS)) { + /* disable channel */ + DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(x), + HCCHAR_CHENA | HCCHAR_CHDIS); + /* wait for chip to get its brains in order */ + sc->sc_chan_state[x].wait_sof = 2; + } + + /* release TX FIFO usage, if any */ + sc->sc_tx_cur_p_level -= sc->sc_chan_state[x].tx_p_size; + sc->sc_tx_cur_np_level -= sc->sc_chan_state[x].tx_np_size; + + /* don't release TX FIFO usage twice */ + sc->sc_chan_state[x].tx_p_size = 0; + sc->sc_chan_state[x].tx_np_size = 0; +} + static uint8_t dwc_otg_update_host_transfer_schedule(struct dwc_otg_softc *sc) { @@ -2326,26 +2369,12 @@ dwc_otg_update_host_transfer_schedule(struct dwc_otg_softc *sc) TAILQ_INIT(&head); for (x = 0; x != sc->sc_host_ch_max; x++) { - uint32_t hcchar; - if (sc->sc_chan_state[x].wait_sof == 0) continue; sc->sc_needsof = 1; - sc->sc_chan_state[x].wait_sof--; - if (sc->sc_chan_state[x].wait_sof != 0) - continue; - - hcchar = DWC_OTG_READ_4(sc, DOTG_HCCHAR(x)); - - /* disable host channel, if any */ - if (hcchar & (HCCHAR_CHENA | HCCHAR_CHDIS)) { - /* disable channel */ - DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(x), - HCCHAR_CHENA | HCCHAR_CHDIS); - /* wait for chip to get its brains in order */ - sc->sc_chan_state[x].wait_sof = 2; - } + if (--(sc->sc_chan_state[x].wait_sof) == 0) + dwc_otg_host_channel_disable(sc, x); } if ((temp & 7) == 0) { diff --git a/sys/dev/usb/controller/dwc_otg.h b/sys/dev/usb/controller/dwc_otg.h index f2a54a6f9d869..406341669788a 100644 --- a/sys/dev/usb/controller/dwc_otg.h +++ b/sys/dev/usb/controller/dwc_otg.h @@ -36,6 +36,7 @@ #define DWC_OTG_HOST_TIMER_RATE 10 /* ms */ #define DWC_OTG_TT_SLOT_MAX 8 #define DWC_OTG_SLOT_IDLE_MAX 4 +#define DWC_OTG_SLOT_IDLE_MIN 2 #define DWC_OTG_READ_4(sc, reg) \ bus_space_read_4((sc)->sc_io_tag, (sc)->sc_io_hdl, reg) -- cgit v1.3 From 4541f27356219bd72f2f74dac9dc15593c7e20bf Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Sun, 11 May 2014 08:17:46 +0000 Subject: Optimise host mode data roundtrip time. When BULK data is submitted to the main processing queue, clear the NAK counter for any associated BULK or CONTROL transfers and poll the endpoint(s) for 1 millisecond at 125us rate interval, before going into slow, 10ms, NAK polling mode again. This has the effect that typical ping-ping protocols respond quicker when initiated from the USB host. MFC after: 2 weeks --- sys/dev/usb/controller/dwc_otg.c | 94 +++++++++++++++++++++++++++++----------- sys/dev/usb/controller/dwc_otg.h | 3 +- 2 files changed, 71 insertions(+), 26 deletions(-) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/dwc_otg.c b/sys/dev/usb/controller/dwc_otg.c index c225bac7fb685..5d003a7eb72e7 100644 --- a/sys/dev/usb/controller/dwc_otg.c +++ b/sys/dev/usb/controller/dwc_otg.c @@ -760,7 +760,7 @@ check_state: case DWC_CHAN_ST_WAIT_ANE: if (hcint & (HCINT_RETRY | HCINT_ERRORS)) { - td->did_nak = 1; + td->did_nak++; td->tt_scheduled = 0; goto send_pkt; } else if (hcint & (HCINT_ACK | HCINT_NYET)) { @@ -774,7 +774,7 @@ check_state: case DWC_CHAN_ST_WAIT_S_ANE: if (hcint & (HCINT_RETRY | HCINT_ERRORS)) { - td->did_nak = 1; + td->did_nak++; td->tt_scheduled = 0; goto send_pkt; } else if (hcint & (HCINT_ACK | HCINT_NYET)) { @@ -786,7 +786,7 @@ check_state: if (hcint & HCINT_NYET) { goto send_cpkt; } else if (hcint & (HCINT_RETRY | HCINT_ERRORS)) { - td->did_nak = 1; + td->did_nak++; td->tt_scheduled = 0; goto send_pkt; } else if (hcint & HCINT_ACK) { @@ -1085,7 +1085,7 @@ dwc_otg_host_rate_check(struct dwc_otg_td *td) if (!td->tt_scheduled) goto busy; td->tt_scheduled = 0; - } else if (td->did_nak != 0) { + } else if (td->did_nak >= DWC_OTG_NAK_MAX) { goto busy; } else if (td->set_toggle) { td->set_toggle = 0; @@ -1244,7 +1244,7 @@ check_state: case DWC_CHAN_ST_WAIT_ANE: if (hcint & (HCINT_RETRY | HCINT_ERRORS)) { - td->did_nak = 1; + td->did_nak++; td->tt_scheduled = 0; if (td->hcsplt != 0) goto receive_spkt; @@ -1284,6 +1284,7 @@ check_state: */ } td->tt_scheduled = 0; + td->did_nak = 0; if (td->hcsplt != 0) goto receive_spkt; else @@ -1298,14 +1299,16 @@ check_state: * case of interrupt and isochronous transfers: */ if (hcint & (HCINT_RETRY | HCINT_ERRORS)) { - td->did_nak = 1; + td->did_nak++; td->tt_scheduled = 0; goto receive_spkt; } else if (hcint & HCINT_NYET) { td->tt_scheduled = 0; goto receive_spkt; - } else if (hcint & HCINT_ACK) + } else if (hcint & HCINT_ACK) { + td->did_nak = 0; goto receive_pkt; + } break; case DWC_CHAN_ST_WAIT_C_PKT: @@ -1633,13 +1636,14 @@ check_state: case DWC_CHAN_ST_WAIT_ANE: if (hcint & (HCINT_RETRY | HCINT_ERRORS)) { - td->did_nak = 1; + td->did_nak++; td->tt_scheduled = 0; goto send_pkt; } else if (hcint & (HCINT_ACK | HCINT_NYET)) { td->offset += td->tx_bytes; td->remainder -= td->tx_bytes; td->toggle ^= 1; + td->did_nak = 0; td->tt_scheduled = 0; /* check remainder */ @@ -1658,24 +1662,27 @@ check_state: case DWC_CHAN_ST_WAIT_S_ANE: if (hcint & (HCINT_RETRY | HCINT_ERRORS)) { - td->did_nak = 1; + td->did_nak++; td->tt_scheduled = 0; goto send_pkt; - } else if (hcint & (HCINT_ACK | HCINT_NYET)) + } else if (hcint & (HCINT_ACK | HCINT_NYET)) { + td->did_nak = 0; goto send_cpkt; + } break; case DWC_CHAN_ST_WAIT_C_ANE: if (hcint & HCINT_NYET) { goto send_cpkt; } else if (hcint & (HCINT_RETRY | HCINT_ERRORS)) { - td->did_nak = 1; + td->did_nak++; td->tt_scheduled = 0; goto send_pkt; } else if (hcint & HCINT_ACK) { td->offset += td->tx_bytes; td->remainder -= td->tx_bytes; td->toggle ^= 1; + td->did_nak = 0; td->tt_scheduled = 0; /* check remainder */ @@ -2283,8 +2290,10 @@ dwc_otg_timer(void *_sc) TAILQ_FOREACH(xfer, &sc->sc_bus.intr_q.head, wait_entry) { td = xfer->td_transfer_cache; - if (td != NULL) + if (td != NULL) { + /* reset NAK counter */ td->did_nak = 0; + } } /* enable SOF interrupt, which will poll jobs */ @@ -2429,8 +2438,11 @@ dwc_otg_update_host_transfer_schedule(struct dwc_otg_softc *sc) TAILQ_FOREACH_SAFE(xfer, &sc->sc_bus.intr_q.head, wait_entry, xfer_next) { td = xfer->td_transfer_cache; - if (td == NULL || td->did_nak != 0 || td->ep_type != UE_CONTROL) + if (td == NULL || + td->ep_type != UE_CONTROL || + td->did_nak >= DWC_OTG_NAK_MAX) { continue; + } sc->sc_needsof = 1; @@ -2448,8 +2460,11 @@ dwc_otg_update_host_transfer_schedule(struct dwc_otg_softc *sc) if ((temp & 7) < 6) { TAILQ_FOREACH_SAFE(xfer, &sc->sc_bus.intr_q.head, wait_entry, xfer_next) { td = xfer->td_transfer_cache; - if (td == NULL || td->did_nak != 0 || td->ep_type != UE_BULK) + if (td == NULL || + td->ep_type != UE_BULK || + td->did_nak >= DWC_OTG_NAK_MAX) { continue; + } sc->sc_needsof = 1; @@ -3206,24 +3221,53 @@ static void dwc_otg_start_standard_chain(struct usb_xfer *xfer) { struct dwc_otg_softc *sc = DWC_OTG_BUS2SC(xfer->xroot->bus); + struct usb_xfer_root *xroot; + struct dwc_otg_td *td; DPRINTFN(9, "\n"); - /* poll one time - will turn on interrupts */ - if (dwc_otg_xfer_do_fifo(xfer)) { + /* + * Poll one time in device mode, which will turn on the + * endpoint interrupts. Else wait for SOF interrupt in host + * mode. + */ + if (sc->sc_flags.status_device_mode != 0 && + dwc_otg_xfer_do_fifo(xfer) == 0) + goto done; - /* put transfer on interrupt queue */ - usbd_transfer_enqueue(&xfer->xroot->bus->intr_q, xfer); + /* put transfer on interrupt queue */ + usbd_transfer_enqueue(&xfer->xroot->bus->intr_q, xfer); - /* start timeout, if any */ - if (xfer->timeout != 0) { - usbd_transfer_timeout_ms(xfer, - &dwc_otg_timeout, xfer->timeout); - } + /* start timeout, if any */ + if (xfer->timeout != 0) { + usbd_transfer_timeout_ms(xfer, + &dwc_otg_timeout, xfer->timeout); + } + + if (sc->sc_flags.status_device_mode != 0) + goto done; - /* enable SOF interrupt, if any */ - dwc_otg_enable_sof_irq(sc); + /* enable SOF interrupt, if any */ + dwc_otg_enable_sof_irq(sc); + + td = xfer->td_transfer_cache; + if (td->ep_type != UE_BULK) + goto done; + + xroot = xfer->xroot; + + /* + * Optimise the ping-pong effect by waking up other BULK + * transfers belonging to the same device group: + */ + TAILQ_FOREACH(xfer, &sc->sc_bus.intr_q.head, wait_entry) { + td = xfer->td_transfer_cache; + if (td == NULL || td->ep_type != UE_BULK || xfer->xroot != xroot) + continue; + /* reset NAK counter */ + td->did_nak = 0; } +done:; } static void diff --git a/sys/dev/usb/controller/dwc_otg.h b/sys/dev/usb/controller/dwc_otg.h index 406341669788a..7c46b75494e01 100644 --- a/sys/dev/usb/controller/dwc_otg.h +++ b/sys/dev/usb/controller/dwc_otg.h @@ -37,6 +37,7 @@ #define DWC_OTG_TT_SLOT_MAX 8 #define DWC_OTG_SLOT_IDLE_MAX 4 #define DWC_OTG_SLOT_IDLE_MIN 2 +#define DWC_OTG_NAK_MAX 8 /* 1 ms */ #define DWC_OTG_READ_4(sc, reg) \ bus_space_read_4((sc)->sc_io_tag, (sc)->sc_io_hdl, reg) @@ -64,6 +65,7 @@ struct dwc_otg_td { uint8_t errcnt; uint8_t tmr_res; uint8_t tmr_val; + uint8_t did_nak; /* NAK counter */ uint8_t ep_no; uint8_t ep_type; uint8_t channel[2]; @@ -87,7 +89,6 @@ struct dwc_otg_td { uint8_t toggle:1; uint8_t set_toggle:1; uint8_t got_short:1; - uint8_t did_nak:1; uint8_t tt_scheduled:1; uint8_t tt_channel_tog:1; }; -- cgit v1.3 From 1d6b6e9d462cb4114974d738ddbc541c134e29b3 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Mon, 12 May 2014 09:05:07 +0000 Subject: Create driver file templates, kernel module Makefile and add initial version of register definitions for ISP1761 and SAF1761 compatible chips. Sponsored by: DARPA, AFRL --- sys/dev/usb/controller/saf1761_dci.c | 33 +++++++ sys/dev/usb/controller/saf1761_dci.h | 36 +++++++ sys/dev/usb/controller/saf1761_dci_fdt.c | 34 +++++++ sys/dev/usb/controller/saf1761_dci_reg.h | 156 +++++++++++++++++++++++++++++++ sys/modules/usb/saf1761/Makefile | 42 +++++++++ 5 files changed, 301 insertions(+) create mode 100644 sys/dev/usb/controller/saf1761_dci.c create mode 100644 sys/dev/usb/controller/saf1761_dci.h create mode 100644 sys/dev/usb/controller/saf1761_dci_fdt.c create mode 100644 sys/dev/usb/controller/saf1761_dci_reg.h create mode 100644 sys/modules/usb/saf1761/Makefile (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/saf1761_dci.c b/sys/dev/usb/controller/saf1761_dci.c new file mode 100644 index 0000000000000..39e0fc550e7ad --- /dev/null +++ b/sys/dev/usb/controller/saf1761_dci.c @@ -0,0 +1,33 @@ +/* $FreeBSD$ */ +/*- + * Copyright (c) 2014 Hans Petter Selasky + * All rights reserved. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include diff --git a/sys/dev/usb/controller/saf1761_dci.h b/sys/dev/usb/controller/saf1761_dci.h new file mode 100644 index 0000000000000..871e5c1d50774 --- /dev/null +++ b/sys/dev/usb/controller/saf1761_dci.h @@ -0,0 +1,36 @@ +/* $FreeBSD$ */ +/*- + * Copyright (c) 2014 Hans Petter Selasky + * All rights reserved. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _SAF1761_DCI_H_ +#define _SAF1761_DCI_H_ + + +#endif /* _SAF1761_DCI_H_ */ diff --git a/sys/dev/usb/controller/saf1761_dci_fdt.c b/sys/dev/usb/controller/saf1761_dci_fdt.c new file mode 100644 index 0000000000000..ea078510c3b55 --- /dev/null +++ b/sys/dev/usb/controller/saf1761_dci_fdt.c @@ -0,0 +1,34 @@ +/* $FreeBSD$ */ +/*- + * Copyright (c) 2014 Hans Petter Selasky + * All rights reserved. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include + diff --git a/sys/dev/usb/controller/saf1761_dci_reg.h b/sys/dev/usb/controller/saf1761_dci_reg.h new file mode 100644 index 0000000000000..1728f4345a56a --- /dev/null +++ b/sys/dev/usb/controller/saf1761_dci_reg.h @@ -0,0 +1,156 @@ +/* $FreeBSD$ */ +/*- + * Copyright (c) 2014 Hans Petter Selasky + * All rights reserved. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _SAF1761_DCI_REG_H_ +#define _SAF1761_DCI_REG_H_ + +/* Global registers */ + +#define SOTG_VEND_ID 0x370 +#define SOTG_PROD_ID 0x372 +#define SOTG_CTRL_SET 0x374 +#define SOTG_CTRL_CLR 0x376 +#define SOTG_CTRL_OTG_DISABLE (1 << 10) +#define SOTG_CTRL_OTG_SE0_EN (1 << 9) +#define SOTG_CTRL_BDIS_ACON_EN (1 << 8) +#define SOTG_CTRL_SW_SEL_HC_DC (1 << 7) +#define SOTG_CTRL_VBUS_CHRG (1 << 6) +#define SOTG_CTRL_VBUS_DISCHRG (1 << 5) +#define SOTG_CTRL_VBUS_DRV (1 << 4) +#define SOTG_CTRL_SEL_CP_EXT (1 << 3) +#define SOTG_CTRL_DM_PULL_DOWN (1 << 2) +#define SOTG_CTRL_DP_PULL_DOWN (1 << 1) +#define SOTG_CTRL_DP_PULL_UP (1 << 0) +#define SOTG_STATUS 0x378 +#define SOTG_STATUS_B_SE0_SRP (1 << 8) +#define SOTG_STATUS_B_SESS_END (1 << 7) +#define SOTG_STATUS_RMT_CONN (1 << 4) +#define SOTG_STATUS_ID (1 << 3) +#define SOTG_STATUS_DP_SRP (1 << 2) +#define SOTG_STATUS_A_B_SESS_VLD (1 << 1) +#define SOTG_STATUS_VBUS_VLD (1 << 0) +#define SOTG_IRQ_LATCH_SET 0x37C +#define SOTG_IRQ_LATCH_CLR 0x37E +#define SOTG_IRQ_ENABLE_SET 0x380 +#define SOTG_IRQ_ENABLE_CLR 0x382 +#define SOTG_IRQ_RISE_SET 0x384 +#define SOTG_IRQ_RISE_CLR 0x386 +#define SOTG_IRQ_OTG_TMR_TIMEOUT (1 << 9) +#define SOTG_IRQ_B_SE0_SRP (1 << 8) +#define SOTG_IRQ_B_SESS_END (1 << 7) +#define SOTG_IRQ_BDIS_ACON (1 << 6) +#define SOTG_IRQ_OTG_RESUME (1 << 5) +#define SOTG_IRQ_RMT_CONN (1 << 4) +#define SOTG_IRQ_ID (1 << 3) +#define SOTG_IRQ_DP_SRP (1 << 2) +#define SOTG_IRQ_A_B_SESS_VLD (1 << 1) +#define SOTG_IRQ_VBUS_VLD (1 << 0) +#define SOTG_TIMER_LOW_SET 0x388 +#define SOTG_TIMER_LOW_CLR 0x38A +#define SOTG_TIMER_HIGH_SET 0x38C +#define SOTG_TIMER_HIGH_CLR 0x38E +#define SOTG_TIMER_START_TMR (1U << 15) + +/* Peripheral controller specific registers */ + +#define SOTG_ADDRESS 0x200 +#define SOTG_ADDRESS_ENABLE (1 << 7) +#define SOTG_MODE 0x20C +#define SOTG_MODE_DMACLK_ON (1 << 9) +#define SOTG_MODE_VBUSSTAT (1 << 8) +#define SOTG_MODE_CLKAON (1 << 7) +#define SOTG_MODE_SNDRSU (1 << 6) +#define SOTG_MODE_GOSUSP (1 << 5) +#define SOTG_MODE_SFRESET (1 << 4) +#define SOTG_MODE_GLINTENA (1 << 3) +#define SOTG_MODE_WKUPCS (1 << 2) +#define SOTG_INTERRUPT_CFG 0x210 +#define SOTG_INTERRUPT_CFG_CDBGMOD (3 << 6) +#define SOTG_INTERRUPT_CFG_DDBGMODIN (3 << 4) +#define SOTG_INTERRUPT_CFG_DDBGMODOUT (3 << 2) +#define SOTG_INTERRUPT_CFG_INTLVL (1 << 1) +#define SOTG_INTERRUPT_CFG_INTPOL (1 << 0) +#define SOTG_DEBUG 0x212 +#define SOTG_DEBUG_SET (1 << 0) +#define SOTG_DCINTERRUPT_EN 0x214 +#define SOTG_HW_MODE_CTRL 0x300 +#define SOTG_OTG_CTRL 0x374 +#define SOTG_EP_INDEX 0x22c +#define SOTG_EP_INDEX_EP0SETUP (1 << 5) +#define SOTG_EP_INDEX_ENDP_INDEX (15 << 1) +#define SOTG_EP_INDEX_DIR_IN (1 << 0) +#define SOTG_CTRL_FUNC 0x228 +#define SOTG_CTRL_FUNC_CLBUF (1 << 4) +#define SOTG_CTRL_FUNC_VENDP (1 << 3) +#define SOTG_CTRL_FUNC_DSEN (1 << 2) +#define SOTG_CTRL_FUNC_STATUS (1 << 1) +#define SOTG_CTRL_FUNC_STALL (1 << 0) +#define SOTG_DATA_PORT 0x220 +#define SOTG_BUF_LENGTH 0x21C +#define SOTG_DCBUFFERSTATUS 0x21E +#define SOTG_EP_MAXPACKET 0x204 +#define SOTG_EP_TYPE 0x208 +#define SOTG_EP_TYPE_NOEMPPKT (1 << 4) +#define SOTG_EP_TYPE_ENABLE (1 << 3) +#define SOTG_EP_TYPE_DBLBUF (1 << 2) +#define SOTG_EP_TYPE_EP_TYPE (3 << 0) +#define SOTG_DMA_CMD 0x230 +#define SOTG_DMA_XFER_COUNT 0x234 +#define SOTG_DCDMA_CFG 0x238 +#define SOTG_DMA_HW 0x23C +#define SOTG_DMA_IRQ_REASON 0x250 +#define SOTG_DMA_IRQ_ENABLE 0x254 +#define SOTG_DMA_EP 0x258 +#define SOTG_BURST_COUNTER 0x264 +#define SOTG_DCINTERRUPT 0x218 +#define SOTG_DCINTERRUPT_IEPRX(n) (1 << (10 + (2*(n)))) +#define SOTG_DCINTERRUPT_IEPTX(n) (1 << (11 + (2*(n)))) +#define SOTG_DCINTERRUPT_IEP0SETUP (1 << 8) +#define SOTG_DCINTERRUPT_IEVBUS (1 << 7) +#define SOTG_DCINTERRUPT_IEDMA (1 << 6) +#define SOTG_DCINTERRUPT_IEHS_STA (1 << 5) +#define SOTG_DCINTERRUPT_IERESM (1 << 4) +#define SOTG_DCINTERRUPT_IESUSP (1 << 3) +#define SOTG_DCINTERRUPT_IEPSOF (1 << 2) +#define SOTG_DCINTERRUPT_IESOF (1 << 1) +#define SOTG_DCINTERRUPT_IEBRST (1 << 0) +#define SOTG_DCCHIP_ID 0x270 +#define SOTG_FRAME_NUM 0x274 +#define SOTG_FRAME_NUM_MICROSOFR 0x3800 +#define SOTG_FRAME_NUM_MICROSOFR_SHIFT 11 +#define SOTG_FRAME_NUM_SOFR 0x7FF +#define SOTG_DCSCRATCH 0x278 +#define SOTG_UNLOCK_DEVICE 0x27C +#define SOTG_UNLOCK_DEVICE_CODE 0xAA37 +#define SOTG_IRQ_PULSE_WIDTH 0x280 +#define SOTG_TEST_MODE 0x284 + +#endif /* _SAF1761_DCI_REG_H_ */ diff --git a/sys/modules/usb/saf1761/Makefile b/sys/modules/usb/saf1761/Makefile new file mode 100644 index 0000000000000..bd1be7d2ae848 --- /dev/null +++ b/sys/modules/usb/saf1761/Makefile @@ -0,0 +1,42 @@ +# +# $FreeBSD$ +# +# Copyright (c) 2014 Hans Petter Selasky. All rights reserved. +# +# This software was developed by SRI International and the University of +# Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) +# ("CTSRD"), as part of the DARPA CRASH research programme. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# + +S= ${.CURDIR}/../../.. + +.PATH: $S/dev/usb/controller + +KMOD= saf1761 +SRCS= bus_if.h device_if.h usb_if.h \ + opt_bus.h opt_usb.h ofw_bus_if.h \ + saf1761_dci.c saf1761_dci_fdt.c \ + pci_if.h + +.include -- cgit v1.3 From 40ba168d27de3700f623b8f241be33181f8a3eab Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Tue, 13 May 2014 13:46:38 +0000 Subject: - Isochronous transfers should use the alternate next transfer descriptor upon receiving a short packet, in host and device mode. - Correct some comments. --- sys/dev/usb/controller/at91dci.c | 6 ++++-- sys/dev/usb/controller/atmegadci.c | 16 +++++++++------- sys/dev/usb/controller/avr32dci.c | 16 +++++++++------- sys/dev/usb/controller/musb_otg.c | 6 ++++-- sys/dev/usb/controller/uss820dci.c | 16 +++++++++------- 5 files changed, 35 insertions(+), 25 deletions(-) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/at91dci.c b/sys/dev/usb/controller/at91dci.c index 0d5f176a3589f..abcad6233d218 100644 --- a/sys/dev/usb/controller/at91dci.c +++ b/sys/dev/usb/controller/at91dci.c @@ -898,7 +898,8 @@ at91dci_setup_standard_chain(struct usb_xfer *xfer) temp.td = NULL; temp.td_next = xfer->td_start[0]; temp.offset = 0; - temp.setup_alt_next = xfer->flags_int.short_frames_ok; + temp.setup_alt_next = xfer->flags_int.short_frames_ok || + xfer->flags_int.isochronous_xfr; temp.did_stall = !xfer->flags_int.control_stall; sc = AT9100_DCI_BUS2SC(xfer->xroot->bus); @@ -1124,7 +1125,8 @@ at91dci_standard_done_sub(struct usb_xfer *xfer) } /* Check for short transfer */ if (len > 0) { - if (xfer->flags_int.short_frames_ok) { + if (xfer->flags_int.short_frames_ok || + xfer->flags_int.isochronous_xfr) { /* follow alt next */ if (td->alt_next) { td = td->obj_next; diff --git a/sys/dev/usb/controller/atmegadci.c b/sys/dev/usb/controller/atmegadci.c index 856d0bd916cfd..8e08ff1bdca69 100644 --- a/sys/dev/usb/controller/atmegadci.c +++ b/sys/dev/usb/controller/atmegadci.c @@ -804,7 +804,8 @@ atmegadci_setup_standard_chain(struct usb_xfer *xfer) temp.td = NULL; temp.td_next = xfer->td_start[0]; temp.offset = 0; - temp.setup_alt_next = xfer->flags_int.short_frames_ok; + temp.setup_alt_next = xfer->flags_int.short_frames_ok || + xfer->flags_int.isochronous_xfr; temp.did_stall = !xfer->flags_int.control_stall; sc = ATMEGA_BUS2SC(xfer->xroot->bus); @@ -1010,7 +1011,8 @@ atmegadci_standard_done_sub(struct usb_xfer *xfer) } /* Check for short transfer */ if (len > 0) { - if (xfer->flags_int.short_frames_ok) { + if (xfer->flags_int.short_frames_ok || + xfer->flags_int.isochronous_xfr) { /* follow alt next */ if (td->alt_next) { td = td->obj_next; @@ -1380,9 +1382,9 @@ atmegadci_do_poll(struct usb_bus *bus) } /*------------------------------------------------------------------------* - * at91dci bulk support - * at91dci control support - * at91dci interrupt support + * atmegadci bulk support + * atmegadci control support + * atmegadci interrupt support *------------------------------------------------------------------------*/ static void atmegadci_device_non_isoc_open(struct usb_xfer *xfer) @@ -1419,7 +1421,7 @@ static const struct usb_pipe_methods atmegadci_device_non_isoc_methods = }; /*------------------------------------------------------------------------* - * at91dci full speed isochronous support + * atmegadci full speed isochronous support *------------------------------------------------------------------------*/ static void atmegadci_device_isoc_fs_open(struct usb_xfer *xfer) @@ -1505,7 +1507,7 @@ static const struct usb_pipe_methods atmegadci_device_isoc_fs_methods = }; /*------------------------------------------------------------------------* - * at91dci root control support + * atmegadci root control support *------------------------------------------------------------------------* * Simulate a hardware HUB by handling all the necessary requests. *------------------------------------------------------------------------*/ diff --git a/sys/dev/usb/controller/avr32dci.c b/sys/dev/usb/controller/avr32dci.c index c7c25046a4450..f9b4c641c08af 100644 --- a/sys/dev/usb/controller/avr32dci.c +++ b/sys/dev/usb/controller/avr32dci.c @@ -771,7 +771,8 @@ avr32dci_setup_standard_chain(struct usb_xfer *xfer) temp.td = NULL; temp.td_next = xfer->td_start[0]; temp.offset = 0; - temp.setup_alt_next = xfer->flags_int.short_frames_ok; + temp.setup_alt_next = xfer->flags_int.short_frames_ok || + xfer->flags_int.isochronous_xfr; temp.did_stall = !xfer->flags_int.control_stall; sc = AVR32_BUS2SC(xfer->xroot->bus); @@ -979,7 +980,8 @@ avr32dci_standard_done_sub(struct usb_xfer *xfer) } /* Check for short transfer */ if (len > 0) { - if (xfer->flags_int.short_frames_ok) { + if (xfer->flags_int.short_frames_ok || + xfer->flags_int.isochronous_xfr) { /* follow alt next */ if (td->alt_next) { td = td->obj_next; @@ -1310,9 +1312,9 @@ avr32dci_do_poll(struct usb_bus *bus) } /*------------------------------------------------------------------------* - * at91dci bulk support - * at91dci control support - * at91dci interrupt support + * avr32dci bulk support + * avr32dci control support + * avr32dci interrupt support *------------------------------------------------------------------------*/ static void avr32dci_device_non_isoc_open(struct usb_xfer *xfer) @@ -1349,7 +1351,7 @@ static const struct usb_pipe_methods avr32dci_device_non_isoc_methods = }; /*------------------------------------------------------------------------* - * at91dci full speed isochronous support + * avr32dci full speed isochronous support *------------------------------------------------------------------------*/ static void avr32dci_device_isoc_fs_open(struct usb_xfer *xfer) @@ -1434,7 +1436,7 @@ static const struct usb_pipe_methods avr32dci_device_isoc_fs_methods = }; /*------------------------------------------------------------------------* - * at91dci root control support + * avr32dci root control support *------------------------------------------------------------------------* * Simulate a hardware HUB by handling all the necessary requests. *------------------------------------------------------------------------*/ diff --git a/sys/dev/usb/controller/musb_otg.c b/sys/dev/usb/controller/musb_otg.c index 39ff96844be7d..289ba56df5607 100644 --- a/sys/dev/usb/controller/musb_otg.c +++ b/sys/dev/usb/controller/musb_otg.c @@ -2403,7 +2403,8 @@ musbotg_setup_standard_chain(struct usb_xfer *xfer) temp.td = NULL; temp.td_next = xfer->td_start[0]; temp.offset = 0; - temp.setup_alt_next = xfer->flags_int.short_frames_ok; + temp.setup_alt_next = xfer->flags_int.short_frames_ok || + xfer->flags_int.isochronous_xfr; temp.did_stall = !xfer->flags_int.control_stall; temp.channel = -1; temp.dev_addr = dev_addr; @@ -2714,7 +2715,8 @@ musbotg_standard_done_sub(struct usb_xfer *xfer) } /* Check for short transfer */ if (len > 0) { - if (xfer->flags_int.short_frames_ok) { + if (xfer->flags_int.short_frames_ok || + xfer->flags_int.isochronous_xfr) { /* follow alt next */ if (td->alt_next) { td = td->obj_next; diff --git a/sys/dev/usb/controller/uss820dci.c b/sys/dev/usb/controller/uss820dci.c index ba777115cc36a..9e10000030387 100644 --- a/sys/dev/usb/controller/uss820dci.c +++ b/sys/dev/usb/controller/uss820dci.c @@ -875,7 +875,8 @@ uss820dci_setup_standard_chain(struct usb_xfer *xfer) temp.td = NULL; temp.td_next = xfer->td_start[0]; temp.offset = 0; - temp.setup_alt_next = xfer->flags_int.short_frames_ok; + temp.setup_alt_next = xfer->flags_int.short_frames_ok || + xfer->flags_int.isochronous_xfr; temp.did_stall = !xfer->flags_int.control_stall; sc = USS820_DCI_BUS2SC(xfer->xroot->bus); @@ -1120,7 +1121,8 @@ uss820dci_standard_done_sub(struct usb_xfer *xfer) } /* Check for short transfer */ if (len > 0) { - if (xfer->flags_int.short_frames_ok) { + if (xfer->flags_int.short_frames_ok || + xfer->flags_int.isochronous_xfr) { /* follow alt next */ if (td->alt_next) { td = td->obj_next; @@ -1543,7 +1545,7 @@ uss820dci_do_poll(struct usb_bus *bus) } /*------------------------------------------------------------------------* - * at91dci bulk support + * uss820dci bulk support *------------------------------------------------------------------------*/ static void uss820dci_device_bulk_open(struct usb_xfer *xfer) @@ -1580,7 +1582,7 @@ static const struct usb_pipe_methods uss820dci_device_bulk_methods = }; /*------------------------------------------------------------------------* - * at91dci control support + * uss820dci control support *------------------------------------------------------------------------*/ static void uss820dci_device_ctrl_open(struct usb_xfer *xfer) @@ -1617,7 +1619,7 @@ static const struct usb_pipe_methods uss820dci_device_ctrl_methods = }; /*------------------------------------------------------------------------* - * at91dci interrupt support + * uss820dci interrupt support *------------------------------------------------------------------------*/ static void uss820dci_device_intr_open(struct usb_xfer *xfer) @@ -1654,7 +1656,7 @@ static const struct usb_pipe_methods uss820dci_device_intr_methods = }; /*------------------------------------------------------------------------* - * at91dci full speed isochronous support + * uss820dci full speed isochronous support *------------------------------------------------------------------------*/ static void uss820dci_device_isoc_fs_open(struct usb_xfer *xfer) @@ -1736,7 +1738,7 @@ static const struct usb_pipe_methods uss820dci_device_isoc_fs_methods = }; /*------------------------------------------------------------------------* - * at91dci root control support + * uss820dci root control support *------------------------------------------------------------------------* * Simulate a hardware HUB by handling all the necessary requests. *------------------------------------------------------------------------*/ -- cgit v1.3 From f5bf22f3b5a6a0c6fbcac336f7e7dd96705fe678 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Wed, 14 May 2014 11:32:15 +0000 Subject: Disable configuration of the host frame interval register until further, hence it breaks USB support on some non-RPI platforms. --- sys/dev/usb/controller/dwc_otg.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/dwc_otg.c b/sys/dev/usb/controller/dwc_otg.c index 5d003a7eb72e7..06727d1691a0c 100644 --- a/sys/dev/usb/controller/dwc_otg.c +++ b/sys/dev/usb/controller/dwc_otg.c @@ -350,6 +350,12 @@ dwc_otg_init_fifo(struct dwc_otg_softc *sc, uint8_t mode) static void dwc_otg_update_host_frame_interval(struct dwc_otg_softc *sc) { + + /* + * Disabled until further. Assuming that the register is already + * programmed correctly by the boot loader. + */ +#if 0 uint32_t temp; /* setup HOST frame interval register, based on existing value */ @@ -375,6 +381,7 @@ dwc_otg_update_host_frame_interval(struct dwc_otg_softc *sc) DPRINTF("HFIR=0x%08x\n", temp); DWC_OTG_WRITE_4(sc, DOTG_HFIR, temp); +#endif } static void -- cgit v1.3 From b9f21c2ce887be8d539e4cd83a84e7644f00183b Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Wed, 14 May 2014 17:04:02 +0000 Subject: Implement USB device side driver code for SAF1761 and compatible chips, based on datasheet and existing USS820 DCI driver. This code is not yet tested. Sponsored by: DARPA, AFRL --- sys/dev/usb/controller/saf1761_dci.c | 1955 +++++++++++++++++++++++++++++- sys/dev/usb/controller/saf1761_dci.h | 108 +- sys/dev/usb/controller/saf1761_dci_fdt.c | 40 +- sys/dev/usb/controller/saf1761_dci_reg.h | 11 +- 4 files changed, 2106 insertions(+), 8 deletions(-) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/saf1761_dci.c b/sys/dev/usb/controller/saf1761_dci.c index 39e0fc550e7ad..f4a754d2f14bf 100644 --- a/sys/dev/usb/controller/saf1761_dci.c +++ b/sys/dev/usb/controller/saf1761_dci.c @@ -1,6 +1,6 @@ /* $FreeBSD$ */ /*- - * Copyright (c) 2014 Hans Petter Selasky + * Copyright (c) 2014 Hans Petter Selasky * All rights reserved. * * This software was developed by SRI International and the University of @@ -29,5 +29,1958 @@ * SUCH DAMAGE. */ +/* + * This file contains the driver for the SAF1761 series USB OTG + * controller. + * + * Datasheet is available from: + * http://www.nxp.com/products/automotive/multimedia/usb/SAF1761BE.html + */ + +#ifdef USB_GLOBAL_INCLUDE_FILE +#include USB_GLOBAL_INCLUDE_FILE +#else +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#define USB_DEBUG_VAR saf1761_dci_debug + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#endif /* USB_GLOBAL_INCLUDE_FILE */ + #include #include + +#define SAF1761_DCI_BUS2SC(bus) \ + ((struct saf1761_dci_softc *)(((uint8_t *)(bus)) - \ + ((uint8_t *)&(((struct saf1761_dci_softc *)0)->sc_bus)))) + +#ifdef USB_DEBUG +static int saf1761_dci_debug = 0; +static int saf1761_dci_forcefs = 0; + +static +SYSCTL_NODE(_hw_usb, OID_AUTO, saf1761_dci, CTLFLAG_RW, 0, + "USB SAF1761 DCI"); + +SYSCTL_INT(_hw_usb_saf1761_dci, OID_AUTO, debug, CTLFLAG_RW, + &saf1761_dci_debug, 0, "SAF1761 DCI debug level"); +SYSCTL_INT(_hw_usb_saf1761_dci, OID_AUTO, forcefs, CTLFLAG_RW, + &saf1761_dci_forcefs, 0, "SAF1761 DCI force FULL speed"); +#endif + +#define SAF1761_DCI_INTR_ENDPT 1 + +/* prototypes */ + +static const struct usb_bus_methods saf1761_dci_bus_methods; +static const struct usb_pipe_methods saf1761_dci_device_non_isoc_methods; +static const struct usb_pipe_methods saf1761_dci_device_isoc_methods; + +static saf1761_dci_cmd_t saf1761_dci_setup_rx; +static saf1761_dci_cmd_t saf1761_dci_data_rx; +static saf1761_dci_cmd_t saf1761_dci_data_tx; +static saf1761_dci_cmd_t saf1761_dci_data_tx_sync; +static void saf1761_dci_device_done(struct usb_xfer *, usb_error_t); +static void saf1761_dci_do_poll(struct usb_bus *); +static void saf1761_dci_standard_done(struct usb_xfer *); +static void saf1761_dci_intr_set(struct usb_xfer *, uint8_t); +static void saf1761_dci_root_intr(struct saf1761_dci_softc *); + +/* + * Here is a list of what the SAF1761 chip can support. The main + * limitation is that the sum of the buffer sizes must be less than + * 8192 bytes. + */ +static const struct usb_hw_ep_profile saf1761_dci_ep_profile[] = { + + [0] = { + .max_in_frame_size = 64, + .max_out_frame_size = 64, + .is_simplex = 0, + .support_control = 1, + }, + [1] = { + .max_in_frame_size = SOTG_HS_MAX_PACKET_SIZE, + .max_out_frame_size = SOTG_HS_MAX_PACKET_SIZE, + .is_simplex = 0, + .support_interrupt = 1, + .support_bulk = 1, + .support_isochronous = 1, + .support_in = 1, + .support_out = 1, + }, +}; + +static void +saf1761_dci_get_hw_ep_profile(struct usb_device *udev, + const struct usb_hw_ep_profile **ppf, uint8_t ep_addr) +{ + if (ep_addr == 0) { + *ppf = saf1761_dci_ep_profile + 0; + } else if (ep_addr < 8) { + *ppf = saf1761_dci_ep_profile + 1; + } else { + *ppf = NULL; + } +} + +static void +saf1761_dci_pull_up(struct saf1761_dci_softc *sc) +{ + /* activate pullup on D+, if possible */ + + if (!sc->sc_flags.d_pulled_up && sc->sc_flags.port_powered) { + DPRINTF("\n"); + + sc->sc_flags.d_pulled_up = 1; + + SAF1761_WRITE_2(sc, SOTG_CTRL_SET, SOTG_CTRL_DP_PULL_UP); + } +} + +static void +saf1761_dci_pull_down(struct saf1761_dci_softc *sc) +{ + /* release pullup on D+, if possible */ + + if (sc->sc_flags.d_pulled_up) { + DPRINTF("\n"); + + sc->sc_flags.d_pulled_up = 0; + + SAF1761_WRITE_2(sc, SOTG_CTRL_CLR, SOTG_CTRL_DP_PULL_UP); + } +} + +static void +saf1761_dci_wakeup_peer(struct saf1761_dci_softc *sc) +{ + uint16_t temp; + + if (!(sc->sc_flags.status_suspend)) + return; + + DPRINTFN(5, "\n"); + + temp = SAF1761_READ_2(sc, SOTG_MODE); + SAF1761_WRITE_2(sc, SOTG_MODE, temp | SOTG_MODE_SNDRSU); + SAF1761_WRITE_2(sc, SOTG_MODE, temp & ~SOTG_MODE_SNDRSU); + + /* Wait 8ms for remote wakeup to complete. */ + usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 125); + +} + +static void +saf1761_dci_set_address(struct saf1761_dci_softc *sc, uint8_t addr) +{ + DPRINTFN(5, "addr=%d\n", addr); + + SAF1761_WRITE_1(sc, SOTG_ADDRESS, addr | SOTG_ADDRESS_ENABLE); +} + +static void +saf1761_read_fifo(struct saf1761_dci_softc *sc, void *buf, uint32_t len) +{ + bus_space_read_multi_1((sc)->sc_io_tag, (sc)->sc_io_hdl, SOTG_DATA_PORT, buf, len); +} + +static void +saf1761_write_fifo(struct saf1761_dci_softc *sc, void *buf, uint32_t len) +{ + bus_space_write_multi_1((sc)->sc_io_tag, (sc)->sc_io_hdl, SOTG_DATA_PORT, buf, len); +} + +static uint8_t +saf1761_dci_setup_rx(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) +{ + struct usb_device_request req; + uint16_t count; + + /* select the correct endpoint */ + SAF1761_WRITE_1(sc, SOTG_EP_INDEX, SOTG_EP_INDEX_EP0SETUP); + + /* check buffer status */ + if ((SAF1761_READ_1(sc, SOTG_DCBUFFERSTATUS) & + SOTG_DCBUFFERSTATUS_FILLED_MASK) == 0) + goto busy; + + /* read buffer length */ + count = SAF1761_READ_2(sc, SOTG_BUF_LENGTH); + + DPRINTFN(5, "count=%u rem=%u\n", count, td->remainder); + + /* clear did stall */ + td->did_stall = 0; + + /* clear stall */ + SAF1761_WRITE_1(sc, SOTG_CTRL_FUNC, 0); + + /* verify data length */ + if (count != td->remainder) { + DPRINTFN(0, "Invalid SETUP packet " + "length, %d bytes\n", count); + goto busy; + } + if (count != sizeof(req)) { + DPRINTFN(0, "Unsupported SETUP packet " + "length, %d bytes\n", count); + goto busy; + } + /* receive data */ + saf1761_read_fifo(sc, &req, sizeof(req)); + + /* copy data into real buffer */ + usbd_copy_in(td->pc, 0, &req, sizeof(req)); + + td->offset = sizeof(req); + td->remainder = 0; + + /* sneak peek the set address */ + if ((req.bmRequestType == UT_WRITE_DEVICE) && + (req.bRequest == UR_SET_ADDRESS)) { + sc->sc_dv_addr = req.wValue[0] & 0x7F; + } else { + sc->sc_dv_addr = 0xFF; + } + return (0); /* complete */ + +busy: + /* abort any ongoing transfer */ + if (!td->did_stall) { + DPRINTFN(5, "stalling\n"); + + /* set stall */ + SAF1761_WRITE_1(sc, SOTG_CTRL_FUNC, SOTG_CTRL_FUNC_STALL); + + td->did_stall = 1; + } + return (1); /* not complete */ +} + +static uint8_t +saf1761_dci_data_rx(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) +{ + struct usb_page_search buf_res; + uint16_t count; + uint8_t got_short = 0; + + if (td->ep_index == 0) { + /* select the correct endpoint */ + SAF1761_WRITE_1(sc, SOTG_EP_INDEX, SOTG_EP_INDEX_EP0SETUP); + + /* check buffer status */ + if ((SAF1761_READ_1(sc, SOTG_DCBUFFERSTATUS) & + SOTG_DCBUFFERSTATUS_FILLED_MASK) != 0) { + + if (td->remainder == 0) { + /* + * We are actually complete and have + * received the next SETUP: + */ + DPRINTFN(5, "faking complete\n"); + return (0); /* complete */ + } + DPRINTFN(5, "SETUP packet while receiving data\n"); + /* + * USB Host Aborted the transfer. + */ + td->error = 1; + return (0); /* complete */ + } + } + /* select the correct endpoint */ + SAF1761_WRITE_1(sc, SOTG_EP_INDEX, + (td->ep_index << SOTG_EP_INDEX_ENDP_INDEX_SHIFT) | + SOTG_EP_INDEX_DIR_OUT); + + /* check buffer status */ + if ((SAF1761_READ_1(sc, SOTG_DCBUFFERSTATUS) & + SOTG_DCBUFFERSTATUS_FILLED_MASK) == 0) { + return (1); /* not complete */ + } + /* read buffer length */ + count = SAF1761_READ_2(sc, SOTG_BUF_LENGTH); + + DPRINTFN(5, "rem=%u count=0x%04x\n", td->remainder, count); + + /* verify the packet byte count */ + if (count != td->max_packet_size) { + if (count < td->max_packet_size) { + /* we have a short packet */ + td->short_pkt = 1; + got_short = 1; + } else { + /* invalid USB packet */ + td->error = 1; + return (0); /* we are complete */ + } + } + /* verify the packet byte count */ + if (count > td->remainder) { + /* invalid USB packet */ + td->error = 1; + return (0); /* we are complete */ + } + while (count > 0) { + usbd_get_page(td->pc, td->offset, &buf_res); + + /* get correct length */ + if (buf_res.length > count) + buf_res.length = count; + + /* receive data */ + saf1761_read_fifo(sc, buf_res.buffer, buf_res.length); + + /* update counters */ + count -= buf_res.length; + td->offset += buf_res.length; + td->remainder -= buf_res.length; + } + /* check if we are complete */ + if ((td->remainder == 0) || got_short) { + if (td->short_pkt) { + /* we are complete */ + return (0); + } + /* else need to receive a zero length packet */ + } + return (1); /* not complete */ +} + +static uint8_t +saf1761_dci_data_tx(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) +{ + struct usb_page_search buf_res; + uint16_t count; + uint16_t count_old; + + if (td->ep_index == 0) { + /* select the correct endpoint */ + SAF1761_WRITE_1(sc, SOTG_EP_INDEX, SOTG_EP_INDEX_EP0SETUP); + + /* check buffer status */ + if ((SAF1761_READ_1(sc, SOTG_DCBUFFERSTATUS) & + SOTG_DCBUFFERSTATUS_FILLED_MASK) != 0) { + DPRINTFN(5, "SETUP abort\n"); + /* + * USB Host Aborted the transfer. + */ + td->error = 1; + return (0); /* complete */ + } + } + /* select the correct endpoint */ + SAF1761_WRITE_1(sc, SOTG_EP_INDEX, + (td->ep_index << SOTG_EP_INDEX_ENDP_INDEX_SHIFT) | + SOTG_EP_INDEX_DIR_IN); + + /* check buffer status */ + if ((SAF1761_READ_1(sc, SOTG_DCBUFFERSTATUS) & + SOTG_DCBUFFERSTATUS_FILLED_MASK) != 0) { + return (1); /* not complete */ + } + DPRINTFN(5, "rem=%u\n", td->remainder); + + count = td->max_packet_size; + if (td->remainder < count) { + /* we have a short packet */ + td->short_pkt = 1; + count = td->remainder; + } + count_old = count; + + while (count > 0) { + + usbd_get_page(td->pc, td->offset, &buf_res); + + /* get correct length */ + if (buf_res.length > count) + buf_res.length = count; + + /* transmit data */ + saf1761_write_fifo(sc, buf_res.buffer, buf_res.length); + + /* update counters */ + count -= buf_res.length; + td->offset += buf_res.length; + td->remainder -= buf_res.length; + } + + if (td->ep_index == 0) { + if (count_old < SOTG_FS_MAX_PACKET_SIZE) { + /* set end of packet */ + SAF1761_WRITE_1(sc, SOTG_CTRL_FUNC, SOTG_CTRL_FUNC_VENDP); + } + } else { + if (count_old < SOTG_HS_MAX_PACKET_SIZE) { + /* set end of packet */ + SAF1761_WRITE_1(sc, SOTG_CTRL_FUNC, SOTG_CTRL_FUNC_VENDP); + } + } + + /* check remainder */ + if (td->remainder == 0) { + if (td->short_pkt) { + return (0); /* complete */ + } + /* else we need to transmit a short packet */ + } + return (1); /* not complete */ +} + +static uint8_t +saf1761_dci_data_tx_sync(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) +{ + if (td->ep_index == 0) { + /* select the correct endpoint */ + SAF1761_WRITE_1(sc, SOTG_EP_INDEX, SOTG_EP_INDEX_EP0SETUP); + + /* check buffer status */ + if ((SAF1761_READ_1(sc, SOTG_DCBUFFERSTATUS) & + SOTG_DCBUFFERSTATUS_FILLED_MASK) != 0) { + DPRINTFN(5, "Faking complete\n"); + return (0); /* complete */ + } + } + /* select the correct endpoint */ + SAF1761_WRITE_1(sc, SOTG_EP_INDEX, + (td->ep_index << SOTG_EP_INDEX_ENDP_INDEX_SHIFT) | + SOTG_EP_INDEX_DIR_IN); + + /* check buffer status */ + if ((SAF1761_READ_1(sc, SOTG_DCBUFFERSTATUS) & + SOTG_DCBUFFERSTATUS_FILLED_MASK) != 0) + return (1); /* busy */ + + if (sc->sc_dv_addr != 0xFF) { + /* write function address */ + saf1761_dci_set_address(sc, sc->sc_dv_addr); + } + return (0); /* complete */ +} + +static uint8_t +saf1761_dci_xfer_do_fifo(struct saf1761_dci_softc *sc, struct usb_xfer *xfer) +{ + struct saf1761_dci_td *td; + + DPRINTFN(9, "\n"); + + td = xfer->td_transfer_cache; + while (1) { + if ((td->func) (sc, td)) { + /* operation in progress */ + break; + } + if (((void *)td) == xfer->td_transfer_last) { + goto done; + } + if (td->error) { + goto done; + } else if (td->remainder > 0) { + /* + * We had a short transfer. If there is no alternate + * next, stop processing ! + */ + if (!td->alt_next) { + goto done; + } + } + /* + * Fetch the next transfer descriptor. + */ + td = td->obj_next; + xfer->td_transfer_cache = td; + } + return (1); /* not complete */ + +done: + /* compute all actual lengths */ + + saf1761_dci_standard_done(xfer); + + return (0); /* complete */ +} + +static void +saf1761_dci_interrupt_poll(struct saf1761_dci_softc *sc) +{ + struct usb_xfer *xfer; + +repeat: + TAILQ_FOREACH(xfer, &sc->sc_bus.intr_q.head, wait_entry) { + if (!saf1761_dci_xfer_do_fifo(sc, xfer)) { + /* queue has been modified */ + goto repeat; + } + } +} + +static void +saf1761_dci_wait_suspend(struct saf1761_dci_softc *sc, uint8_t on) +{ + if (on) { + sc->sc_intr_enable |= SOTG_DCINTERRUPT_IESUSP; + sc->sc_intr_enable &= ~SOTG_DCINTERRUPT_IERESM; + } else { + sc->sc_intr_enable &= ~SOTG_DCINTERRUPT_IESUSP; + sc->sc_intr_enable |= SOTG_DCINTERRUPT_IERESM; + } + SAF1761_WRITE_4(sc, SOTG_DCINTERRUPT_EN, sc->sc_intr_enable); +} + +static void +saf1761_dci_update_vbus(struct saf1761_dci_softc *sc) +{ + if (SAF1761_READ_4(sc, SOTG_MODE) & SOTG_MODE_VBUSSTAT) { + DPRINTFN(4, "VBUS ON\n"); + + /* VBUS present */ + if (!sc->sc_flags.status_vbus) { + sc->sc_flags.status_vbus = 1; + + /* complete root HUB interrupt endpoint */ + saf1761_dci_root_intr(sc); + } + } else { + DPRINTFN(4, "VBUS OFF\n"); + + /* VBUS not-present */ + if (sc->sc_flags.status_vbus) { + sc->sc_flags.status_vbus = 0; + sc->sc_flags.status_bus_reset = 0; + sc->sc_flags.status_suspend = 0; + sc->sc_flags.change_suspend = 0; + sc->sc_flags.change_connect = 1; + + /* complete root HUB interrupt endpoint */ + saf1761_dci_root_intr(sc); + } + } +} + +void +saf1761_dci_interrupt(struct saf1761_dci_softc *sc) +{ + uint32_t status; + + USB_BUS_LOCK(&sc->sc_bus); + + status = SAF1761_READ_4(sc, SOTG_DCINTERRUPT); + + /* acknowledge all interrupts */ + SAF1761_WRITE_4(sc, SOTG_DCINTERRUPT, status); + + if (status & SOTG_DCINTERRUPT_IEVBUS) { + /* update VBUS bit */ + saf1761_dci_update_vbus(sc); + } + if (status & SOTG_DCINTERRUPT_IEBRST) { + sc->sc_flags.status_bus_reset = 1; + sc->sc_flags.status_suspend = 0; + sc->sc_flags.change_suspend = 0; + sc->sc_flags.change_connect = 1; + + /* disable resume interrupt */ + saf1761_dci_wait_suspend(sc, 1); + /* complete root HUB interrupt endpoint */ + saf1761_dci_root_intr(sc); + } + /* + * If "RESUME" and "SUSPEND" is set at the same time we + * interpret that like "RESUME". Resume is set when there is + * at least 3 milliseconds of inactivity on the USB BUS: + */ + if (status & SOTG_DCINTERRUPT_IERESM) { + if (sc->sc_flags.status_suspend) { + sc->sc_flags.status_suspend = 0; + sc->sc_flags.change_suspend = 1; + /* disable resume interrupt */ + saf1761_dci_wait_suspend(sc, 1); + /* complete root HUB interrupt endpoint */ + saf1761_dci_root_intr(sc); + } + } else if (status & SOTG_DCINTERRUPT_IESUSP) { + if (!sc->sc_flags.status_suspend) { + sc->sc_flags.status_suspend = 1; + sc->sc_flags.change_suspend = 1; + /* enable resume interrupt */ + saf1761_dci_wait_suspend(sc, 0); + /* complete root HUB interrupt endpoint */ + saf1761_dci_root_intr(sc); + } + } + /* poll all active transfers */ + saf1761_dci_interrupt_poll(sc); + + USB_BUS_UNLOCK(&sc->sc_bus); +} + +static void +saf1761_dci_setup_standard_chain_sub(struct saf1761_dci_std_temp *temp) +{ + struct saf1761_dci_td *td; + + /* get current Transfer Descriptor */ + td = temp->td_next; + temp->td = td; + + /* prepare for next TD */ + temp->td_next = td->obj_next; + + /* fill out the Transfer Descriptor */ + td->func = temp->func; + td->pc = temp->pc; + td->offset = temp->offset; + td->remainder = temp->len; + td->error = 0; + td->did_stall = temp->did_stall; + td->short_pkt = temp->short_pkt; + td->alt_next = temp->setup_alt_next; +} + +static void +saf1761_dci_setup_standard_chain(struct usb_xfer *xfer) +{ + struct saf1761_dci_std_temp temp; + struct saf1761_dci_softc *sc; + struct saf1761_dci_td *td; + uint32_t x; + uint8_t ep_no; + + DPRINTFN(9, "addr=%d endpt=%d sumlen=%d speed=%d\n", + xfer->address, UE_GET_ADDR(xfer->endpointno), + xfer->sumlen, usbd_get_speed(xfer->xroot->udev)); + + temp.max_frame_size = xfer->max_frame_size; + + td = xfer->td_start[0]; + xfer->td_transfer_first = td; + xfer->td_transfer_cache = td; + + /* setup temp */ + + temp.pc = NULL; + temp.td = NULL; + temp.td_next = xfer->td_start[0]; + temp.offset = 0; + temp.setup_alt_next = xfer->flags_int.short_frames_ok; + temp.did_stall = !xfer->flags_int.control_stall; + + sc = SAF1761_DCI_BUS2SC(xfer->xroot->bus); + ep_no = (xfer->endpointno & UE_ADDR); + + /* check if we should prepend a setup message */ + + if (xfer->flags_int.control_xfr) { + if (xfer->flags_int.control_hdr) { + + temp.func = &saf1761_dci_setup_rx; + temp.len = xfer->frlengths[0]; + temp.pc = xfer->frbuffers + 0; + temp.short_pkt = temp.len ? 1 : 0; + /* check for last frame */ + if (xfer->nframes == 1) { + /* no STATUS stage yet, SETUP is last */ + if (xfer->flags_int.control_act) + temp.setup_alt_next = 0; + } + saf1761_dci_setup_standard_chain_sub(&temp); + } + x = 1; + } else { + x = 0; + } + + if (x != xfer->nframes) { + if (xfer->endpointno & UE_DIR_IN) { + temp.func = &saf1761_dci_data_tx; + } else { + temp.func = &saf1761_dci_data_rx; + } + + /* setup "pc" pointer */ + temp.pc = xfer->frbuffers + x; + } + while (x != xfer->nframes) { + + /* DATA0 / DATA1 message */ + + temp.len = xfer->frlengths[x]; + + x++; + + if (x == xfer->nframes) { + if (xfer->flags_int.control_xfr) { + if (xfer->flags_int.control_act) { + temp.setup_alt_next = 0; + } + } else { + temp.setup_alt_next = 0; + } + } + if (temp.len == 0) { + + /* make sure that we send an USB packet */ + + temp.short_pkt = 0; + + } else { + + /* regular data transfer */ + + temp.short_pkt = (xfer->flags.force_short_xfer) ? 0 : 1; + } + + saf1761_dci_setup_standard_chain_sub(&temp); + + if (xfer->flags_int.isochronous_xfr) { + temp.offset += temp.len; + } else { + /* get next Page Cache pointer */ + temp.pc = xfer->frbuffers + x; + } + } + + /* check for control transfer */ + if (xfer->flags_int.control_xfr) { + uint8_t need_sync; + + /* always setup a valid "pc" pointer for status and sync */ + temp.pc = xfer->frbuffers + 0; + temp.len = 0; + temp.short_pkt = 0; + temp.setup_alt_next = 0; + + /* check if we should append a status stage */ + if (!xfer->flags_int.control_act) { + + /* + * Send a DATA1 message and invert the current + * endpoint direction. + */ + if (xfer->endpointno & UE_DIR_IN) { + temp.func = &saf1761_dci_data_rx; + need_sync = 0; + } else { + temp.func = &saf1761_dci_data_tx; + need_sync = 1; + } + temp.len = 0; + temp.short_pkt = 0; + + saf1761_dci_setup_standard_chain_sub(&temp); + if (need_sync) { + /* we need a SYNC point after TX */ + temp.func = &saf1761_dci_data_tx_sync; + saf1761_dci_setup_standard_chain_sub(&temp); + } + } + } + /* must have at least one frame! */ + td = temp.td; + xfer->td_transfer_last = td; +} + +static void +saf1761_dci_timeout(void *arg) +{ + struct usb_xfer *xfer = arg; + + DPRINTF("xfer=%p\n", xfer); + + USB_BUS_LOCK_ASSERT(xfer->xroot->bus, MA_OWNED); + + /* transfer is transferred */ + saf1761_dci_device_done(xfer, USB_ERR_TIMEOUT); +} + +static void +saf1761_dci_intr_set(struct usb_xfer *xfer, uint8_t set) +{ + struct saf1761_dci_softc *sc = SAF1761_DCI_BUS2SC(xfer->xroot->bus); + uint8_t ep_no = (xfer->endpointno & UE_ADDR); + uint32_t mask; + + DPRINTFN(15, "endpoint 0x%02x\n", xfer->endpointno); + + if (ep_no == 0) { + mask = SOTG_DCINTERRUPT_IEPRX(0) | + SOTG_DCINTERRUPT_IEPTX(0) | + SOTG_DCINTERRUPT_IEP0SETUP; + } else if (xfer->endpointno & UE_DIR_IN) { + mask = SOTG_DCINTERRUPT_IEPTX(ep_no); + } else { + mask = SOTG_DCINTERRUPT_IEPRX(ep_no); + } + + if (set) + sc->sc_intr_enable |= mask; + else + sc->sc_intr_enable &= ~mask; + + SAF1761_WRITE_4(sc, SOTG_DCINTERRUPT_EN, sc->sc_intr_enable); +} + +static void +saf1761_dci_start_standard_chain(struct usb_xfer *xfer) +{ + struct saf1761_dci_softc *sc = SAF1761_DCI_BUS2SC(xfer->xroot->bus); + + DPRINTFN(9, "\n"); + + /* poll one time */ + if (saf1761_dci_xfer_do_fifo(sc, xfer)) { + + /* + * Only enable the endpoint interrupt when we are + * actually waiting for data, hence we are dealing + * with level triggered interrupts ! + */ + saf1761_dci_intr_set(xfer, 1); + + /* put transfer on interrupt queue */ + usbd_transfer_enqueue(&xfer->xroot->bus->intr_q, xfer); + + /* start timeout, if any */ + if (xfer->timeout != 0) { + usbd_transfer_timeout_ms(xfer, + &saf1761_dci_timeout, xfer->timeout); + } + } +} + +static void +saf1761_dci_root_intr(struct saf1761_dci_softc *sc) +{ + DPRINTFN(9, "\n"); + + USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED); + + /* set port bit - we only have one port */ + sc->sc_hub_idata[0] = 0x02; + + uhub_root_intr(&sc->sc_bus, sc->sc_hub_idata, + sizeof(sc->sc_hub_idata)); +} + +static usb_error_t +saf1761_dci_standard_done_sub(struct usb_xfer *xfer) +{ + struct saf1761_dci_td *td; + uint32_t len; + uint8_t error; + + DPRINTFN(9, "\n"); + + td = xfer->td_transfer_cache; + + do { + len = td->remainder; + + if (xfer->aframes != xfer->nframes) { + /* + * Verify the length and subtract + * the remainder from "frlengths[]": + */ + if (len > xfer->frlengths[xfer->aframes]) { + td->error = 1; + } else { + xfer->frlengths[xfer->aframes] -= len; + } + } + /* Check for transfer error */ + if (td->error) { + /* the transfer is finished */ + error = 1; + td = NULL; + break; + } + /* Check for short transfer */ + if (len > 0) { + if (xfer->flags_int.short_frames_ok) { + /* follow alt next */ + if (td->alt_next) { + td = td->obj_next; + } else { + td = NULL; + } + } else { + /* the transfer is finished */ + td = NULL; + } + error = 0; + break; + } + td = td->obj_next; + + /* this USB frame is complete */ + error = 0; + break; + + } while (0); + + /* update transfer cache */ + + xfer->td_transfer_cache = td; + + return (error ? + USB_ERR_STALLED : USB_ERR_NORMAL_COMPLETION); +} + +static void +saf1761_dci_standard_done(struct usb_xfer *xfer) +{ + usb_error_t err = 0; + + DPRINTFN(13, "xfer=%p endpoint=%p transfer done\n", + xfer, xfer->endpoint); + + /* reset scanner */ + + xfer->td_transfer_cache = xfer->td_transfer_first; + + if (xfer->flags_int.control_xfr) { + + if (xfer->flags_int.control_hdr) { + + err = saf1761_dci_standard_done_sub(xfer); + } + xfer->aframes = 1; + + if (xfer->td_transfer_cache == NULL) { + goto done; + } + } + while (xfer->aframes != xfer->nframes) { + + err = saf1761_dci_standard_done_sub(xfer); + xfer->aframes++; + + if (xfer->td_transfer_cache == NULL) { + goto done; + } + } + + if (xfer->flags_int.control_xfr && + !xfer->flags_int.control_act) { + + err = saf1761_dci_standard_done_sub(xfer); + } +done: + saf1761_dci_device_done(xfer, err); +} + +/*------------------------------------------------------------------------* + * saf1761_dci_device_done + * + * NOTE: this function can be called more than one time on the + * same USB transfer! + *------------------------------------------------------------------------*/ +static void +saf1761_dci_device_done(struct usb_xfer *xfer, usb_error_t error) +{ + USB_BUS_LOCK_ASSERT(xfer->xroot->bus, MA_OWNED); + + DPRINTFN(2, "xfer=%p, endpoint=%p, error=%d\n", + xfer, xfer->endpoint, error); + + if (xfer->flags_int.usb_mode == USB_MODE_DEVICE) + saf1761_dci_intr_set(xfer, 0); + + /* dequeue transfer and start next transfer */ + usbd_transfer_done(xfer, error); +} + +static void +saf1761_dci_xfer_stall(struct usb_xfer *xfer) +{ + saf1761_dci_device_done(xfer, USB_ERR_STALLED); +} + +static void +saf1761_dci_set_stall(struct usb_device *udev, + struct usb_endpoint *ep, uint8_t *did_stall) +{ + struct saf1761_dci_softc *sc; + uint8_t ep_no; + uint8_t ep_type; + uint8_t ep_dir; + + USB_BUS_LOCK_ASSERT(udev->bus, MA_OWNED); + + DPRINTFN(5, "endpoint=%p\n", ep); + + /* set FORCESTALL */ + sc = SAF1761_DCI_BUS2SC(udev->bus); + ep_no = (ep->edesc->bEndpointAddress & UE_ADDR); + ep_dir = (ep->edesc->bEndpointAddress & (UE_DIR_IN | UE_DIR_OUT)); + ep_type = (ep->edesc->bmAttributes & UE_XFERTYPE); + + if (ep_type == UE_CONTROL) { + /* should not happen */ + return; + } + /* select the correct endpoint */ + SAF1761_WRITE_1(sc, SOTG_EP_INDEX, + (ep_no << SOTG_EP_INDEX_ENDP_INDEX_SHIFT) | + ((ep_dir == UE_DIR_IN) ? SOTG_EP_INDEX_DIR_IN : + SOTG_EP_INDEX_DIR_OUT)); + + /* set stall */ + SAF1761_WRITE_1(sc, SOTG_CTRL_FUNC, SOTG_CTRL_FUNC_STALL); +} + +static void +saf1761_dci_clear_stall_sub(struct saf1761_dci_softc *sc, + uint8_t ep_no, uint8_t ep_type, uint8_t ep_dir) +{ + if (ep_type == UE_CONTROL) { + /* clearing stall is not needed */ + return; + } + /* select the correct endpoint */ + SAF1761_WRITE_1(sc, SOTG_EP_INDEX, + (ep_no << SOTG_EP_INDEX_ENDP_INDEX_SHIFT) | + ((ep_dir == UE_DIR_IN) ? SOTG_EP_INDEX_DIR_IN : + SOTG_EP_INDEX_DIR_OUT)); + + /* disable endpoint */ + SAF1761_WRITE_2(sc, SOTG_EP_TYPE, 0); + /* enable endpoint again - will clear data toggle */ + SAF1761_WRITE_2(sc, SOTG_EP_TYPE, ep_type | SOTG_EP_TYPE_ENABLE); + + /* clear buffer */ + SAF1761_WRITE_1(sc, SOTG_CTRL_FUNC, SOTG_CTRL_FUNC_CLBUF); + /* clear stall */ + SAF1761_WRITE_1(sc, SOTG_CTRL_FUNC, 0); +} + +static void +saf1761_dci_clear_stall(struct usb_device *udev, struct usb_endpoint *ep) +{ + struct saf1761_dci_softc *sc; + struct usb_endpoint_descriptor *ed; + + USB_BUS_LOCK_ASSERT(udev->bus, MA_OWNED); + + DPRINTFN(5, "endpoint=%p\n", ep); + + /* check mode */ + if (udev->flags.usb_mode != USB_MODE_DEVICE) { + /* not supported */ + return; + } + /* get softc */ + sc = SAF1761_DCI_BUS2SC(udev->bus); + + /* get endpoint descriptor */ + ed = ep->edesc; + + /* reset endpoint */ + saf1761_dci_clear_stall_sub(sc, + (ed->bEndpointAddress & UE_ADDR), + (ed->bmAttributes & UE_XFERTYPE), + (ed->bEndpointAddress & (UE_DIR_IN | UE_DIR_OUT))); +} + +usb_error_t +saf1761_dci_init(struct saf1761_dci_softc *sc) +{ + const struct usb_hw_ep_profile *pf; + uint8_t x; + + DPRINTF("start\n"); + + /* set up the bus structure */ + sc->sc_bus.usbrev = USB_REV_2_0; + sc->sc_bus.methods = &saf1761_dci_bus_methods; + + USB_BUS_LOCK(&sc->sc_bus); + + /* reset device */ + SAF1761_WRITE_2(sc, SOTG_MODE, SOTG_MODE_SFRESET); + SAF1761_WRITE_2(sc, SOTG_MODE, 0); + + /* wait a bit */ + DELAY(1000); + + /* do a pulldown */ + saf1761_dci_pull_down(sc); + + /* wait 10ms for pulldown to stabilise */ + usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 100); + + for (x = 0;; x++) { + + saf1761_dci_get_hw_ep_profile(NULL, &pf, x); + if (pf == NULL) + break; + + /* select the correct endpoint */ + SAF1761_WRITE_1(sc, SOTG_EP_INDEX, + (x << SOTG_EP_INDEX_ENDP_INDEX_SHIFT) | + SOTG_EP_INDEX_DIR_IN); + + /* select the maximum packet size */ + SAF1761_WRITE_2(sc, SOTG_EP_MAXPACKET, pf->max_in_frame_size); + + if (x == 0) { + /* enable control endpoint */ + SAF1761_WRITE_2(sc, SOTG_EP_TYPE, SOTG_EP_TYPE_ENABLE); + } + /* select the correct endpoint */ + SAF1761_WRITE_1(sc, SOTG_EP_INDEX, + (x << SOTG_EP_INDEX_ENDP_INDEX_SHIFT) | + SOTG_EP_INDEX_DIR_OUT); + + /* select the maximum packet size */ + SAF1761_WRITE_2(sc, SOTG_EP_MAXPACKET, pf->max_out_frame_size); + + if (x == 0) { + /* enable control endpoint */ + SAF1761_WRITE_2(sc, SOTG_EP_TYPE, SOTG_EP_TYPE_ENABLE); + } + } + + /* enable interrupts */ + SAF1761_WRITE_2(sc, SOTG_MODE, SOTG_MODE_GLINTENA); + + /* enable interrupts */ + sc->sc_intr_enable = SOTG_DCINTERRUPT_EN, SOTG_DCINTERRUPT_IEVBUS | + SOTG_DCINTERRUPT_IEBRST | SOTG_DCINTERRUPT_IESUSP; + SAF1761_WRITE_2(sc, SOTG_DCINTERRUPT_EN, sc->sc_intr_enable); + + /* poll initial VBUS status */ + saf1761_dci_update_vbus(sc); + + USB_BUS_UNLOCK(&sc->sc_bus); + + /* catch any lost interrupts */ + + saf1761_dci_do_poll(&sc->sc_bus); + + return (0); /* success */ +} + +void +saf1761_dci_uninit(struct saf1761_dci_softc *sc) +{ + USB_BUS_LOCK(&sc->sc_bus); + + /* disable all interrupts */ + SAF1761_WRITE_2(sc, SOTG_MODE, 0); + + sc->sc_flags.port_powered = 0; + sc->sc_flags.status_vbus = 0; + sc->sc_flags.status_bus_reset = 0; + sc->sc_flags.status_suspend = 0; + sc->sc_flags.change_suspend = 0; + sc->sc_flags.change_connect = 1; + + saf1761_dci_pull_down(sc); + USB_BUS_UNLOCK(&sc->sc_bus); +} + +static void +saf1761_dci_suspend(struct saf1761_dci_softc *sc) +{ + /* TODO */ +} + +static void +saf1761_dci_resume(struct saf1761_dci_softc *sc) +{ + /* TODO */ +} + +static void +saf1761_dci_do_poll(struct usb_bus *bus) +{ + struct saf1761_dci_softc *sc = SAF1761_DCI_BUS2SC(bus); + + USB_BUS_LOCK(&sc->sc_bus); + saf1761_dci_interrupt_poll(sc); + USB_BUS_UNLOCK(&sc->sc_bus); +} + +/*------------------------------------------------------------------------* + * saf1761_dci control support + * saf1761_dci interrupt support + * saf1761_dci bulk support + *------------------------------------------------------------------------*/ +static void +saf1761_dci_device_non_isoc_open(struct usb_xfer *xfer) +{ + return; +} + +static void +saf1761_dci_device_non_isoc_close(struct usb_xfer *xfer) +{ + saf1761_dci_device_done(xfer, USB_ERR_CANCELLED); +} + +static void +saf1761_dci_device_non_isoc_enter(struct usb_xfer *xfer) +{ + return; +} + +static void +saf1761_dci_device_non_isoc_start(struct usb_xfer *xfer) +{ + /* setup TDs */ + saf1761_dci_setup_standard_chain(xfer); + saf1761_dci_start_standard_chain(xfer); +} + +static const struct usb_pipe_methods saf1761_dci_device_non_isoc_methods = +{ + .open = saf1761_dci_device_non_isoc_open, + .close = saf1761_dci_device_non_isoc_close, + .enter = saf1761_dci_device_non_isoc_enter, + .start = saf1761_dci_device_non_isoc_start, +}; + +/*------------------------------------------------------------------------* + * saf1761_dci isochronous support + *------------------------------------------------------------------------*/ +static void +saf1761_dci_device_isoc_open(struct usb_xfer *xfer) +{ + return; +} + +static void +saf1761_dci_device_isoc_close(struct usb_xfer *xfer) +{ + saf1761_dci_device_done(xfer, USB_ERR_CANCELLED); +} + +static void +saf1761_dci_device_isoc_enter(struct usb_xfer *xfer) +{ + struct saf1761_dci_softc *sc = SAF1761_DCI_BUS2SC(xfer->xroot->bus); + uint32_t temp; + uint32_t nframes; + + DPRINTFN(6, "xfer=%p next=%d nframes=%d\n", + xfer, xfer->endpoint->isoc_next, xfer->nframes); + + /* get the current frame index - we don't need the high bits */ + + nframes = SAF1761_READ_2(sc, SOTG_FRAME_NUM); + + /* + * check if the frame index is within the window where the + * frames will be inserted + */ + temp = (nframes - xfer->endpoint->isoc_next) & SOTG_FRAME_NUM_SOFR_MASK; + + if ((xfer->endpoint->is_synced == 0) || + (temp < xfer->nframes)) { + /* + * If there is data underflow or the pipe queue is + * empty we schedule the transfer a few frames ahead + * of the current frame position. Else two isochronous + * transfers might overlap. + */ + xfer->endpoint->isoc_next = (nframes + 3) & SOTG_FRAME_NUM_SOFR_MASK; + xfer->endpoint->is_synced = 1; + DPRINTFN(3, "start next=%d\n", xfer->endpoint->isoc_next); + } + /* + * compute how many milliseconds the insertion is ahead of the + * current frame position: + */ + temp = (xfer->endpoint->isoc_next - nframes) & SOTG_FRAME_NUM_SOFR_MASK; + + /* + * pre-compute when the isochronous transfer will be finished: + */ + xfer->isoc_time_complete = + usb_isoc_time_expand(&sc->sc_bus, nframes) + temp + + xfer->nframes; + + /* compute frame number for next insertion */ + xfer->endpoint->isoc_next += xfer->nframes; + + /* setup TDs */ + saf1761_dci_setup_standard_chain(xfer); +} + +static void +saf1761_dci_device_isoc_start(struct usb_xfer *xfer) +{ + /* start TD chain */ + saf1761_dci_start_standard_chain(xfer); +} + +static const struct usb_pipe_methods saf1761_dci_device_isoc_methods = +{ + .open = saf1761_dci_device_isoc_open, + .close = saf1761_dci_device_isoc_close, + .enter = saf1761_dci_device_isoc_enter, + .start = saf1761_dci_device_isoc_start, +}; + +/*------------------------------------------------------------------------* + * saf1761_dci root control support + *------------------------------------------------------------------------* + * Simulate a hardware HUB by handling all the necessary requests. + *------------------------------------------------------------------------*/ + +static const struct usb_device_descriptor saf1761_dci_devd = { + .bLength = sizeof(struct usb_device_descriptor), + .bDescriptorType = UDESC_DEVICE, + .bcdUSB = {0x00, 0x02}, + .bDeviceClass = UDCLASS_HUB, + .bDeviceSubClass = UDSUBCLASS_HUB, + .bDeviceProtocol = UDPROTO_FSHUB, + .bMaxPacketSize = 64, + .bcdDevice = {0x00, 0x01}, + .iManufacturer = 1, + .iProduct = 2, + .bNumConfigurations = 1, +}; + +static const struct usb_device_qualifier saf1761_dci_odevd = { + .bLength = sizeof(struct usb_device_qualifier), + .bDescriptorType = UDESC_DEVICE_QUALIFIER, + .bcdUSB = {0x00, 0x02}, + .bDeviceClass = UDCLASS_HUB, + .bDeviceSubClass = UDSUBCLASS_HUB, + .bDeviceProtocol = UDPROTO_FSHUB, + .bMaxPacketSize0 = 0, + .bNumConfigurations = 0, +}; + +static const struct saf1761_dci_config_desc saf1761_dci_confd = { + .confd = { + .bLength = sizeof(struct usb_config_descriptor), + .bDescriptorType = UDESC_CONFIG, + .wTotalLength[0] = sizeof(saf1761_dci_confd), + .bNumInterface = 1, + .bConfigurationValue = 1, + .iConfiguration = 0, + .bmAttributes = UC_SELF_POWERED, + .bMaxPower = 0, + }, + .ifcd = { + .bLength = sizeof(struct usb_interface_descriptor), + .bDescriptorType = UDESC_INTERFACE, + .bNumEndpoints = 1, + .bInterfaceClass = UICLASS_HUB, + .bInterfaceSubClass = UISUBCLASS_HUB, + .bInterfaceProtocol = 0, + }, + + .endpd = { + .bLength = sizeof(struct usb_endpoint_descriptor), + .bDescriptorType = UDESC_ENDPOINT, + .bEndpointAddress = (UE_DIR_IN | SAF1761_DCI_INTR_ENDPT), + .bmAttributes = UE_INTERRUPT, + .wMaxPacketSize[0] = 8, + .bInterval = 255, + }, +}; + +#define HSETW(ptr, val) ptr = { (uint8_t)(val), (uint8_t)((val) >> 8) } + +static const struct usb_hub_descriptor_min saf1761_dci_hubd = { + .bDescLength = sizeof(saf1761_dci_hubd), + .bDescriptorType = UDESC_HUB, + .bNbrPorts = 1, + HSETW(.wHubCharacteristics, (UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL)), + .bPwrOn2PwrGood = 50, + .bHubContrCurrent = 0, + .DeviceRemovable = {0}, /* port is removable */ +}; + +#define STRING_VENDOR \ + "N\0X\0P" + +#define STRING_PRODUCT \ + "D\0C\0I\0 \0R\0o\0o\0t\0 \0H\0U\0B" + +USB_MAKE_STRING_DESC(STRING_VENDOR, saf1761_dci_vendor); +USB_MAKE_STRING_DESC(STRING_PRODUCT, saf1761_dci_product); + +static usb_error_t +saf1761_dci_roothub_exec(struct usb_device *udev, + struct usb_device_request *req, const void **pptr, uint16_t *plength) +{ + struct saf1761_dci_softc *sc = SAF1761_DCI_BUS2SC(udev->bus); + const void *ptr; + uint16_t len; + uint16_t value; + uint16_t index; + usb_error_t err; + + USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED); + + /* buffer reset */ + ptr = (const void *)&sc->sc_hub_temp; + len = 0; + err = 0; + + value = UGETW(req->wValue); + index = UGETW(req->wIndex); + + /* demultiplex the control request */ + + switch (req->bmRequestType) { + case UT_READ_DEVICE: + switch (req->bRequest) { + case UR_GET_DESCRIPTOR: + goto tr_handle_get_descriptor; + case UR_GET_CONFIG: + goto tr_handle_get_config; + case UR_GET_STATUS: + goto tr_handle_get_status; + default: + goto tr_stalled; + } + break; + + case UT_WRITE_DEVICE: + switch (req->bRequest) { + case UR_SET_ADDRESS: + goto tr_handle_set_address; + case UR_SET_CONFIG: + goto tr_handle_set_config; + case UR_CLEAR_FEATURE: + goto tr_valid; /* nop */ + case UR_SET_DESCRIPTOR: + goto tr_valid; /* nop */ + case UR_SET_FEATURE: + default: + goto tr_stalled; + } + break; + + case UT_WRITE_ENDPOINT: + switch (req->bRequest) { + case UR_CLEAR_FEATURE: + switch (UGETW(req->wValue)) { + case UF_ENDPOINT_HALT: + goto tr_handle_clear_halt; + case UF_DEVICE_REMOTE_WAKEUP: + goto tr_handle_clear_wakeup; + default: + goto tr_stalled; + } + break; + case UR_SET_FEATURE: + switch (UGETW(req->wValue)) { + case UF_ENDPOINT_HALT: + goto tr_handle_set_halt; + case UF_DEVICE_REMOTE_WAKEUP: + goto tr_handle_set_wakeup; + default: + goto tr_stalled; + } + break; + case UR_SYNCH_FRAME: + goto tr_valid; /* nop */ + default: + goto tr_stalled; + } + break; + + case UT_READ_ENDPOINT: + switch (req->bRequest) { + case UR_GET_STATUS: + goto tr_handle_get_ep_status; + default: + goto tr_stalled; + } + break; + + case UT_WRITE_INTERFACE: + switch (req->bRequest) { + case UR_SET_INTERFACE: + goto tr_handle_set_interface; + case UR_CLEAR_FEATURE: + goto tr_valid; /* nop */ + case UR_SET_FEATURE: + default: + goto tr_stalled; + } + break; + + case UT_READ_INTERFACE: + switch (req->bRequest) { + case UR_GET_INTERFACE: + goto tr_handle_get_interface; + case UR_GET_STATUS: + goto tr_handle_get_iface_status; + default: + goto tr_stalled; + } + break; + + case UT_WRITE_CLASS_INTERFACE: + case UT_WRITE_VENDOR_INTERFACE: + /* XXX forward */ + break; + + case UT_READ_CLASS_INTERFACE: + case UT_READ_VENDOR_INTERFACE: + /* XXX forward */ + break; + + case UT_WRITE_CLASS_DEVICE: + switch (req->bRequest) { + case UR_CLEAR_FEATURE: + goto tr_valid; + case UR_SET_DESCRIPTOR: + case UR_SET_FEATURE: + break; + default: + goto tr_stalled; + } + break; + + case UT_WRITE_CLASS_OTHER: + switch (req->bRequest) { + case UR_CLEAR_FEATURE: + goto tr_handle_clear_port_feature; + case UR_SET_FEATURE: + goto tr_handle_set_port_feature; + case UR_CLEAR_TT_BUFFER: + case UR_RESET_TT: + case UR_STOP_TT: + goto tr_valid; + + default: + goto tr_stalled; + } + break; + + case UT_READ_CLASS_OTHER: + switch (req->bRequest) { + case UR_GET_TT_STATE: + goto tr_handle_get_tt_state; + case UR_GET_STATUS: + goto tr_handle_get_port_status; + default: + goto tr_stalled; + } + break; + + case UT_READ_CLASS_DEVICE: + switch (req->bRequest) { + case UR_GET_DESCRIPTOR: + goto tr_handle_get_class_descriptor; + case UR_GET_STATUS: + goto tr_handle_get_class_status; + + default: + goto tr_stalled; + } + break; + default: + goto tr_stalled; + } + goto tr_valid; + +tr_handle_get_descriptor: + switch (value >> 8) { + case UDESC_DEVICE: + if (value & 0xff) + goto tr_stalled; + len = sizeof(saf1761_dci_devd); + ptr = (const void *)&saf1761_dci_devd; + goto tr_valid; + case UDESC_DEVICE_QUALIFIER: + if (value & 0xff) + goto tr_stalled; + len = sizeof(saf1761_dci_odevd); + ptr = (const void *)&saf1761_dci_odevd; + goto tr_valid; + case UDESC_CONFIG: + if (value & 0xff) + goto tr_stalled; + len = sizeof(saf1761_dci_confd); + ptr = (const void *)&saf1761_dci_confd; + goto tr_valid; + case UDESC_STRING: + switch (value & 0xff) { + case 0: /* Language table */ + len = sizeof(usb_string_lang_en); + ptr = (const void *)&usb_string_lang_en; + goto tr_valid; + + case 1: /* Vendor */ + len = sizeof(saf1761_dci_vendor); + ptr = (const void *)&saf1761_dci_vendor; + goto tr_valid; + + case 2: /* Product */ + len = sizeof(saf1761_dci_product); + ptr = (const void *)&saf1761_dci_product; + goto tr_valid; + default: + break; + } + break; + default: + goto tr_stalled; + } + goto tr_stalled; + +tr_handle_get_config: + len = 1; + sc->sc_hub_temp.wValue[0] = sc->sc_conf; + goto tr_valid; + +tr_handle_get_status: + len = 2; + USETW(sc->sc_hub_temp.wValue, UDS_SELF_POWERED); + goto tr_valid; + +tr_handle_set_address: + if (value & 0xFF00) + goto tr_stalled; + + sc->sc_rt_addr = value; + goto tr_valid; + +tr_handle_set_config: + if (value >= 2) + goto tr_stalled; + sc->sc_conf = value; + goto tr_valid; + +tr_handle_get_interface: + len = 1; + sc->sc_hub_temp.wValue[0] = 0; + goto tr_valid; + +tr_handle_get_tt_state: +tr_handle_get_class_status: +tr_handle_get_iface_status: +tr_handle_get_ep_status: + len = 2; + USETW(sc->sc_hub_temp.wValue, 0); + goto tr_valid; + +tr_handle_set_halt: +tr_handle_set_interface: +tr_handle_set_wakeup: +tr_handle_clear_wakeup: +tr_handle_clear_halt: + goto tr_valid; + +tr_handle_clear_port_feature: + if (index != 1) + goto tr_stalled; + DPRINTFN(9, "UR_CLEAR_PORT_FEATURE on port %d\n", index); + + switch (value) { + case UHF_PORT_SUSPEND: + saf1761_dci_wakeup_peer(sc); + break; + + case UHF_PORT_ENABLE: + sc->sc_flags.port_enabled = 0; + break; + + case UHF_PORT_TEST: + case UHF_PORT_INDICATOR: + case UHF_C_PORT_ENABLE: + case UHF_C_PORT_OVER_CURRENT: + case UHF_C_PORT_RESET: + /* nops */ + break; + case UHF_PORT_POWER: + sc->sc_flags.port_powered = 0; + saf1761_dci_pull_down(sc); + break; + case UHF_C_PORT_CONNECTION: + sc->sc_flags.change_connect = 0; + break; + case UHF_C_PORT_SUSPEND: + sc->sc_flags.change_suspend = 0; + break; + default: + err = USB_ERR_IOERROR; + goto tr_valid; + } + goto tr_valid; + +tr_handle_set_port_feature: + if (index != 1) + goto tr_stalled; + DPRINTFN(9, "UR_SET_PORT_FEATURE\n"); + + switch (value) { + case UHF_PORT_ENABLE: + sc->sc_flags.port_enabled = 1; + break; + case UHF_PORT_SUSPEND: + case UHF_PORT_RESET: + case UHF_PORT_TEST: + case UHF_PORT_INDICATOR: + /* nops */ + break; + case UHF_PORT_POWER: + sc->sc_flags.port_powered = 1; + break; + default: + err = USB_ERR_IOERROR; + goto tr_valid; + } + goto tr_valid; + +tr_handle_get_port_status: + + DPRINTFN(9, "UR_GET_PORT_STATUS\n"); + + if (index != 1) + goto tr_stalled; + + if (sc->sc_flags.status_vbus) { + saf1761_dci_pull_up(sc); + } else { + saf1761_dci_pull_down(sc); + } + + /* Select FULL-speed and Device Side Mode */ + + value = UPS_PORT_MODE_DEVICE; + + if (sc->sc_flags.port_powered) + value |= UPS_PORT_POWER; + + if (sc->sc_flags.port_enabled) + value |= UPS_PORT_ENABLED; + + if (sc->sc_flags.status_vbus && + sc->sc_flags.status_bus_reset) + value |= UPS_CURRENT_CONNECT_STATUS; + + if (sc->sc_flags.status_suspend) + value |= UPS_SUSPEND; + + USETW(sc->sc_hub_temp.ps.wPortStatus, value); + + value = 0; + + if (sc->sc_flags.change_connect) + value |= UPS_C_CONNECT_STATUS; + + if (sc->sc_flags.change_suspend) + value |= UPS_C_SUSPEND; + + USETW(sc->sc_hub_temp.ps.wPortChange, value); + len = sizeof(sc->sc_hub_temp.ps); + goto tr_valid; + +tr_handle_get_class_descriptor: + if (value & 0xFF) + goto tr_stalled; + ptr = (const void *)&saf1761_dci_hubd; + len = sizeof(saf1761_dci_hubd); + goto tr_valid; + +tr_stalled: + err = USB_ERR_STALLED; +tr_valid: + *plength = len; + *pptr = ptr; + return (err); +} + +static void +saf1761_dci_xfer_setup(struct usb_setup_params *parm) +{ + const struct usb_hw_ep_profile *pf; + struct saf1761_dci_softc *sc; + struct usb_xfer *xfer; + void *last_obj; + uint32_t ntd; + uint32_t n; + uint8_t ep_no; + uint8_t ep_type; + + sc = SAF1761_DCI_BUS2SC(parm->udev->bus); + xfer = parm->curr_xfer; + + /* + * NOTE: This driver does not use any of the parameters that + * are computed from the following values. Just set some + * reasonable dummies: + */ + parm->hc_max_packet_size = 0x500; + parm->hc_max_packet_count = 1; + parm->hc_max_frame_size = 0x500; + + usbd_transfer_setup_sub(parm); + + /* + * Compute maximum number of TDs: + */ + ep_type = (xfer->endpoint->edesc->bmAttributes & UE_XFERTYPE); + + if (ep_type == UE_CONTROL) { + + ntd = xfer->nframes + 1 /* STATUS */ + 1 /* SYNC */ ; + + } else { + ntd = xfer->nframes + 1 /* SYNC */ ; + } + + /* + * check if "usbd_transfer_setup_sub" set an error + */ + if (parm->err) + return; + + /* + * allocate transfer descriptors + */ + last_obj = NULL; + + /* + * get profile stuff + */ + if (ntd) { + + ep_no = xfer->endpointno & UE_ADDR; + saf1761_dci_get_hw_ep_profile(parm->udev, &pf, ep_no); + + if (pf == NULL) { + /* should not happen */ + parm->err = USB_ERR_INVAL; + return; + } + } else { + ep_no = 0; + pf = NULL; + } + + /* align data */ + parm->size[0] += ((-parm->size[0]) & (USB_HOST_ALIGN - 1)); + + for (n = 0; n != ntd; n++) { + + struct saf1761_dci_td *td; + + if (parm->buf) { + + td = USB_ADD_BYTES(parm->buf, parm->size[0]); + + /* init TD */ + td->max_packet_size = xfer->max_packet_size; + td->ep_index = ep_no; + + td->obj_next = last_obj; + + last_obj = td; + } + parm->size[0] += sizeof(*td); + } + + xfer->td_start[0] = last_obj; +} + +static void +saf1761_dci_xfer_unsetup(struct usb_xfer *xfer) +{ +} + +static void +saf1761_dci_ep_init(struct usb_device *udev, struct usb_endpoint_descriptor *edesc, + struct usb_endpoint *ep) +{ + struct saf1761_dci_softc *sc = SAF1761_DCI_BUS2SC(udev->bus); + + DPRINTFN(2, "endpoint=%p, addr=%d, endpt=%d, mode=%d (%d)\n", + ep, udev->address, + edesc->bEndpointAddress, udev->flags.usb_mode, + sc->sc_rt_addr); + + if (udev->device_index != sc->sc_rt_addr) { + if (udev->speed != USB_SPEED_FULL && + udev->speed != USB_SPEED_HIGH) { + /* not supported */ + return; + } + switch (edesc->bmAttributes & UE_XFERTYPE) { + case UE_ISOCHRONOUS: + ep->methods = &saf1761_dci_device_isoc_methods; + break; + default: + ep->methods = &saf1761_dci_device_non_isoc_methods; + break; + } + } +} + +static void +saf1761_dci_set_hw_power_sleep(struct usb_bus *bus, uint32_t state) +{ + struct saf1761_dci_softc *sc = SAF1761_DCI_BUS2SC(bus); + + switch (state) { + case USB_HW_POWER_SUSPEND: + saf1761_dci_suspend(sc); + break; + case USB_HW_POWER_SHUTDOWN: + saf1761_dci_uninit(sc); + break; + case USB_HW_POWER_RESUME: + saf1761_dci_resume(sc); + break; + default: + break; + } +} + +static const struct usb_bus_methods saf1761_dci_bus_methods = +{ + .endpoint_init = &saf1761_dci_ep_init, + .xfer_setup = &saf1761_dci_xfer_setup, + .xfer_unsetup = &saf1761_dci_xfer_unsetup, + .get_hw_ep_profile = &saf1761_dci_get_hw_ep_profile, + .xfer_stall = &saf1761_dci_xfer_stall, + .set_stall = &saf1761_dci_set_stall, + .clear_stall = &saf1761_dci_clear_stall, + .roothub_exec = &saf1761_dci_roothub_exec, + .xfer_poll = &saf1761_dci_do_poll, + .set_hw_power_sleep = saf1761_dci_set_hw_power_sleep, +}; diff --git a/sys/dev/usb/controller/saf1761_dci.h b/sys/dev/usb/controller/saf1761_dci.h index 871e5c1d50774..957e702577bf4 100644 --- a/sys/dev/usb/controller/saf1761_dci.h +++ b/sys/dev/usb/controller/saf1761_dci.h @@ -1,6 +1,6 @@ /* $FreeBSD$ */ /*- - * Copyright (c) 2014 Hans Petter Selasky + * Copyright (c) 2014 Hans Petter Selasky * All rights reserved. * * This software was developed by SRI International and the University of @@ -32,5 +32,111 @@ #ifndef _SAF1761_DCI_H_ #define _SAF1761_DCI_H_ +#define SOTG_MAX_DEVICES (USB_MIN_DEVICES + 1) +#define SOTG_FS_MAX_PACKET_SIZE 64 +#define SOTG_HS_MAX_PACKET_SIZE 512 + +#define SAF1761_READ_1(sc, reg) \ + bus_space_read_1((sc)->sc_io_tag, (sc)->sc_io_hdl, reg) +#define SAF1761_READ_2(sc, reg) \ + bus_space_read_2((sc)->sc_io_tag, (sc)->sc_io_hdl, reg) +#define SAF1761_READ_4(sc, reg) \ + bus_space_read_4((sc)->sc_io_tag, (sc)->sc_io_hdl, reg) + +#define SAF1761_WRITE_1(sc, reg, data) \ + bus_space_write_1((sc)->sc_io_tag, (sc)->sc_io_hdl, reg, data) +#define SAF1761_WRITE_2(sc, reg, data) \ + bus_space_write_2((sc)->sc_io_tag, (sc)->sc_io_hdl, reg, data) +#define SAF1761_WRITE_4(sc, reg, data) \ + bus_space_write_4((sc)->sc_io_tag, (sc)->sc_io_hdl, reg, data) + +struct saf1761_dci_softc; +struct saf1761_dci_td; + +typedef uint8_t (saf1761_dci_cmd_t)(struct saf1761_dci_softc *, struct saf1761_dci_td *td); + +struct saf1761_dci_td { + struct saf1761_dci_td *obj_next; + saf1761_dci_cmd_t *func; + struct usb_page_cache *pc; + uint32_t offset; + uint32_t remainder; + uint16_t max_packet_size; + uint8_t ep_index; + uint8_t error:1; + uint8_t alt_next:1; + uint8_t short_pkt:1; + uint8_t did_stall:1; +}; + +struct saf1761_dci_std_temp { + saf1761_dci_cmd_t *func; + struct usb_page_cache *pc; + struct saf1761_dci_td *td; + struct saf1761_dci_td *td_next; + uint32_t len; + uint32_t offset; + uint16_t max_frame_size; + uint8_t short_pkt; + /* + * short_pkt = 0: transfer should be short terminated + * short_pkt = 1: transfer should not be short terminated + */ + uint8_t setup_alt_next; + uint8_t did_stall; +}; + +struct saf1761_dci_config_desc { + struct usb_config_descriptor confd; + struct usb_interface_descriptor ifcd; + struct usb_endpoint_descriptor endpd; +} __packed; + +union saf1761_dci_hub_temp { + uWord wValue; + struct usb_port_status ps; +}; + +struct saf1761_dci_flags { + uint8_t change_connect:1; + uint8_t change_suspend:1; + uint8_t status_suspend:1; /* set if suspended */ + uint8_t status_vbus:1; /* set if present */ + uint8_t status_bus_reset:1; /* set if reset complete */ + uint8_t clocks_off:1; + uint8_t port_powered:1; + uint8_t port_enabled:1; + uint8_t d_pulled_up:1; + uint8_t mcsr_feat:1; +}; + +struct saf1761_dci_softc { + struct usb_bus sc_bus; + union saf1761_dci_hub_temp sc_hub_temp; + + struct usb_device *sc_devices[SOTG_MAX_DEVICES]; + struct resource *sc_io_res; + struct resource *sc_irq_res; + void *sc_intr_hdl; + bus_size_t sc_io_size; + bus_space_tag_t sc_io_tag; + bus_space_handle_t sc_io_hdl; + + uint32_t sc_intr_enable; /* enabled interrupts */ + + uint8_t sc_rt_addr; /* root HUB address */ + uint8_t sc_dv_addr; /* device address */ + uint8_t sc_conf; /* root HUB config */ + + uint8_t sc_hub_idata[1]; + + struct saf1761_dci_flags sc_flags; +}; + +/* prototypes */ + +usb_error_t saf1761_dci_init(struct saf1761_dci_softc *sc); +void saf1761_dci_uninit(struct saf1761_dci_softc *sc); +void saf1761_dci_interrupt(struct saf1761_dci_softc *sc); #endif /* _SAF1761_DCI_H_ */ diff --git a/sys/dev/usb/controller/saf1761_dci_fdt.c b/sys/dev/usb/controller/saf1761_dci_fdt.c index ea078510c3b55..256a2f49ff88b 100644 --- a/sys/dev/usb/controller/saf1761_dci_fdt.c +++ b/sys/dev/usb/controller/saf1761_dci_fdt.c @@ -1,6 +1,6 @@ /* $FreeBSD$ */ /*- - * Copyright (c) 2014 Hans Petter Selasky + * Copyright (c) 2014 Hans Petter Selasky * All rights reserved. * * This software was developed by SRI International and the University of @@ -29,6 +29,42 @@ * SUCH DAMAGE. */ +#ifdef USB_GLOBAL_INCLUDE_FILE +#include USB_GLOBAL_INCLUDE_FILE +#else +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#endif /* USB_GLOBAL_INCLUDE_FILE */ + #include #include - diff --git a/sys/dev/usb/controller/saf1761_dci_reg.h b/sys/dev/usb/controller/saf1761_dci_reg.h index 1728f4345a56a..258be76888254 100644 --- a/sys/dev/usb/controller/saf1761_dci_reg.h +++ b/sys/dev/usb/controller/saf1761_dci_reg.h @@ -1,6 +1,6 @@ /* $FreeBSD$ */ /*- - * Copyright (c) 2014 Hans Petter Selasky + * Copyright (c) 2014 Hans Petter Selasky * All rights reserved. * * This software was developed by SRI International and the University of @@ -105,8 +105,10 @@ #define SOTG_OTG_CTRL 0x374 #define SOTG_EP_INDEX 0x22c #define SOTG_EP_INDEX_EP0SETUP (1 << 5) -#define SOTG_EP_INDEX_ENDP_INDEX (15 << 1) +#define SOTG_EP_INDEX_ENDP_INDEX_MASK (15 << 1) +#define SOTG_EP_INDEX_ENDP_INDEX_SHIFT 1 #define SOTG_EP_INDEX_DIR_IN (1 << 0) +#define SOTG_EP_INDEX_DIR_OUT 0 #define SOTG_CTRL_FUNC 0x228 #define SOTG_CTRL_FUNC_CLBUF (1 << 4) #define SOTG_CTRL_FUNC_VENDP (1 << 3) @@ -116,6 +118,7 @@ #define SOTG_DATA_PORT 0x220 #define SOTG_BUF_LENGTH 0x21C #define SOTG_DCBUFFERSTATUS 0x21E +#define SOTG_DCBUFFERSTATUS_FILLED_MASK (3 << 0) #define SOTG_EP_MAXPACKET 0x204 #define SOTG_EP_TYPE 0x208 #define SOTG_EP_TYPE_NOEMPPKT (1 << 4) @@ -144,9 +147,9 @@ #define SOTG_DCINTERRUPT_IEBRST (1 << 0) #define SOTG_DCCHIP_ID 0x270 #define SOTG_FRAME_NUM 0x274 -#define SOTG_FRAME_NUM_MICROSOFR 0x3800 +#define SOTG_FRAME_NUM_MICROSOFR_MASK 0x3800 #define SOTG_FRAME_NUM_MICROSOFR_SHIFT 11 -#define SOTG_FRAME_NUM_SOFR 0x7FF +#define SOTG_FRAME_NUM_SOFR_MASK 0x7FF #define SOTG_DCSCRATCH 0x278 #define SOTG_UNLOCK_DEVICE 0x27C #define SOTG_UNLOCK_DEVICE_CODE 0xAA37 -- cgit v1.3 From a673f4c22bc48649fae9f1852ca068b49cb92dfd Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Fri, 16 May 2014 10:30:30 +0000 Subject: - Correct some programming details for the SAF1761 driver. - Add some more register details. Sponsored by: DARPA, AFRL --- sys/dev/usb/controller/saf1761_dci.c | 99 +++++++++++++++++++++++--------- sys/dev/usb/controller/saf1761_dci.h | 2 +- sys/dev/usb/controller/saf1761_dci_reg.h | 35 +++++++++++ 3 files changed, 107 insertions(+), 29 deletions(-) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/saf1761_dci.c b/sys/dev/usb/controller/saf1761_dci.c index f4a754d2f14bf..ae23d5c60cc12 100644 --- a/sys/dev/usb/controller/saf1761_dci.c +++ b/sys/dev/usb/controller/saf1761_dci.c @@ -163,8 +163,6 @@ saf1761_dci_pull_up(struct saf1761_dci_softc *sc) DPRINTF("\n"); sc->sc_flags.d_pulled_up = 1; - - SAF1761_WRITE_2(sc, SOTG_CTRL_SET, SOTG_CTRL_DP_PULL_UP); } } @@ -177,8 +175,6 @@ saf1761_dci_pull_down(struct saf1761_dci_softc *sc) DPRINTF("\n"); sc->sc_flags.d_pulled_up = 0; - - SAF1761_WRITE_2(sc, SOTG_CTRL_CLR, SOTG_CTRL_DP_PULL_UP); } } @@ -212,13 +208,15 @@ saf1761_dci_set_address(struct saf1761_dci_softc *sc, uint8_t addr) static void saf1761_read_fifo(struct saf1761_dci_softc *sc, void *buf, uint32_t len) { - bus_space_read_multi_1((sc)->sc_io_tag, (sc)->sc_io_hdl, SOTG_DATA_PORT, buf, len); + bus_space_read_multi_1((sc)->sc_io_tag, (sc)->sc_io_hdl, + SOTG_DATA_PORT, buf, len); } static void saf1761_write_fifo(struct saf1761_dci_softc *sc, void *buf, uint32_t len) { - bus_space_write_multi_1((sc)->sc_io_tag, (sc)->sc_io_hdl, SOTG_DATA_PORT, buf, len); + bus_space_write_multi_1((sc)->sc_io_tag, (sc)->sc_io_hdl, + SOTG_DATA_PORT, buf, len); } static uint8_t @@ -270,6 +268,7 @@ saf1761_dci_setup_rx(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) if ((req.bmRequestType == UT_WRITE_DEVICE) && (req.bRequest == UR_SET_ADDRESS)) { sc->sc_dv_addr = req.wValue[0] & 0x7F; + DPRINTF("Set address %d\n", sc->sc_dv_addr); } else { sc->sc_dv_addr = 0xFF; } @@ -563,10 +562,16 @@ saf1761_dci_wait_suspend(struct saf1761_dci_softc *sc, uint8_t on) static void saf1761_dci_update_vbus(struct saf1761_dci_softc *sc) { - if (SAF1761_READ_4(sc, SOTG_MODE) & SOTG_MODE_VBUSSTAT) { - DPRINTFN(4, "VBUS ON\n"); + uint16_t status; + + /* read fresh status */ + status = SAF1761_READ_2(sc, SOTG_STATUS); - /* VBUS present */ + DPRINTFN(4, "STATUS=0x%04x\n", status); + + if ((status & SOTG_STATUS_VBUS_VLD) && + (status & SOTG_STATUS_ID)) { + /* VBUS present and device mode */ if (!sc->sc_flags.status_vbus) { sc->sc_flags.status_vbus = 1; @@ -574,9 +579,7 @@ saf1761_dci_update_vbus(struct saf1761_dci_softc *sc) saf1761_dci_root_intr(sc); } } else { - DPRINTFN(4, "VBUS OFF\n"); - - /* VBUS not-present */ + /* VBUS not-present or host mode */ if (sc->sc_flags.status_vbus) { sc->sc_flags.status_vbus = 0; sc->sc_flags.status_bus_reset = 0; @@ -602,11 +605,23 @@ saf1761_dci_interrupt(struct saf1761_dci_softc *sc) /* acknowledge all interrupts */ SAF1761_WRITE_4(sc, SOTG_DCINTERRUPT, status); + DPRINTF("DCINTERRUPT=0x%08x SOF=0x%04x\n", status, + SAF1761_READ_2(sc, SOTG_FRAME_NUM)); + + /* update VBUS and ID bits, if any */ if (status & SOTG_DCINTERRUPT_IEVBUS) { - /* update VBUS bit */ saf1761_dci_update_vbus(sc); } + if (status & SOTG_DCINTERRUPT_IEBRST) { + /* unlock device */ + SAF1761_WRITE_2(sc, SOTG_UNLOCK_DEVICE, + SOTG_UNLOCK_DEVICE_CODE); + + /* Enable device address */ + SAF1761_WRITE_1(sc, SOTG_ADDRESS, + SOTG_ADDRESS_ENABLE); + sc->sc_flags.status_bus_reset = 1; sc->sc_flags.status_suspend = 0; sc->sc_flags.change_suspend = 0; @@ -623,6 +638,10 @@ saf1761_dci_interrupt(struct saf1761_dci_softc *sc) * at least 3 milliseconds of inactivity on the USB BUS: */ if (status & SOTG_DCINTERRUPT_IERESM) { + /* unlock device */ + SAF1761_WRITE_2(sc, SOTG_UNLOCK_DEVICE, + SOTG_UNLOCK_DEVICE_CODE); + if (sc->sc_flags.status_suspend) { sc->sc_flags.status_suspend = 0; sc->sc_flags.change_suspend = 1; @@ -833,7 +852,7 @@ saf1761_dci_intr_set(struct usb_xfer *xfer, uint8_t set) uint8_t ep_no = (xfer->endpointno & UE_ADDR); uint32_t mask; - DPRINTFN(15, "endpoint 0x%02x\n", xfer->endpointno); + DPRINTFN(15, "endpoint=%d set=%d\n", xfer->endpointno, set); if (ep_no == 0) { mask = SOTG_DCINTERRUPT_IEPRX(0) | @@ -1121,7 +1140,7 @@ saf1761_dci_init(struct saf1761_dci_softc *sc) const struct usb_hw_ep_profile *pf; uint8_t x; - DPRINTF("start\n"); + DPRINTF("\n"); /* set up the bus structure */ sc->sc_bus.usbrev = USB_REV_2_0; @@ -1129,6 +1148,19 @@ saf1761_dci_init(struct saf1761_dci_softc *sc) USB_BUS_LOCK(&sc->sc_bus); + /* Enable interrupts */ + sc->sc_hw_mode |= SOTG_HW_MODE_CTRL_GLOBAL_INTR_EN | + SOTG_HW_MODE_CTRL_COMN_INT; + + /* + * Set correct hardware mode, must be written twice if bus + * width is changed: + */ + SAF1761_WRITE_2(sc, SOTG_HW_MODE_CTRL, sc->sc_hw_mode); + SAF1761_WRITE_4(sc, SOTG_HW_MODE_CTRL, sc->sc_hw_mode); + + DPRINTF("DCID=0x%08x\n", SAF1761_READ_4(sc, SOTG_DCCHIP_ID)); + /* reset device */ SAF1761_WRITE_2(sc, SOTG_MODE, SOTG_MODE_SFRESET); SAF1761_WRITE_2(sc, SOTG_MODE, 0); @@ -1142,7 +1174,7 @@ saf1761_dci_init(struct saf1761_dci_softc *sc) /* wait 10ms for pulldown to stabilise */ usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 100); - for (x = 0;; x++) { + for (x = 1;; x++) { saf1761_dci_get_hw_ep_profile(NULL, &pf, x); if (pf == NULL) @@ -1156,10 +1188,6 @@ saf1761_dci_init(struct saf1761_dci_softc *sc) /* select the maximum packet size */ SAF1761_WRITE_2(sc, SOTG_EP_MAXPACKET, pf->max_in_frame_size); - if (x == 0) { - /* enable control endpoint */ - SAF1761_WRITE_2(sc, SOTG_EP_TYPE, SOTG_EP_TYPE_ENABLE); - } /* select the correct endpoint */ SAF1761_WRITE_1(sc, SOTG_EP_INDEX, (x << SOTG_EP_INDEX_ENDP_INDEX_SHIFT) | @@ -1167,20 +1195,35 @@ saf1761_dci_init(struct saf1761_dci_softc *sc) /* select the maximum packet size */ SAF1761_WRITE_2(sc, SOTG_EP_MAXPACKET, pf->max_out_frame_size); - - if (x == 0) { - /* enable control endpoint */ - SAF1761_WRITE_2(sc, SOTG_EP_TYPE, SOTG_EP_TYPE_ENABLE); - } } /* enable interrupts */ - SAF1761_WRITE_2(sc, SOTG_MODE, SOTG_MODE_GLINTENA); + SAF1761_WRITE_2(sc, SOTG_MODE, SOTG_MODE_GLINTENA | + SOTG_MODE_CLKAON | SOTG_MODE_WKUPCS); + + /* set default values */ + SAF1761_WRITE_1(sc, SOTG_INTERRUPT_CFG, + SOTG_INTERRUPT_CFG_CDBGMOD | + SOTG_INTERRUPT_CFG_DDBGMODIN | + SOTG_INTERRUPT_CFG_DDBGMODOUT); + + /* enable VBUS and ID interrupt */ + SAF1761_WRITE_2(sc, SOTG_IRQ_ENABLE_CLR, 0xFFFF); + SAF1761_WRITE_2(sc, SOTG_IRQ_ENABLE_SET, + SOTG_IRQ_ID | SOTG_IRQ_VBUS_VLD); /* enable interrupts */ - sc->sc_intr_enable = SOTG_DCINTERRUPT_EN, SOTG_DCINTERRUPT_IEVBUS | + sc->sc_intr_enable = SOTG_DCINTERRUPT_IEVBUS | SOTG_DCINTERRUPT_IEBRST | SOTG_DCINTERRUPT_IESUSP; - SAF1761_WRITE_2(sc, SOTG_DCINTERRUPT_EN, sc->sc_intr_enable); + SAF1761_WRITE_4(sc, SOTG_DCINTERRUPT_EN, sc->sc_intr_enable); + + /* connect ATX port 1 to device controller */ + SAF1761_WRITE_2(sc, SOTG_CTRL_CLR, 0xFFFF); + SAF1761_WRITE_2(sc, SOTG_CTRL_SET, SOTG_CTRL_SW_SEL_HC_DC | + SOTG_CTRL_BDIS_ACON_EN); + + /* disable device address */ + SAF1761_WRITE_1(sc, SOTG_ADDRESS, 0); /* poll initial VBUS status */ saf1761_dci_update_vbus(sc); diff --git a/sys/dev/usb/controller/saf1761_dci.h b/sys/dev/usb/controller/saf1761_dci.h index 957e702577bf4..a8dd18c990eb0 100644 --- a/sys/dev/usb/controller/saf1761_dci.h +++ b/sys/dev/usb/controller/saf1761_dci.h @@ -107,7 +107,6 @@ struct saf1761_dci_flags { uint8_t port_powered:1; uint8_t port_enabled:1; uint8_t d_pulled_up:1; - uint8_t mcsr_feat:1; }; struct saf1761_dci_softc { @@ -123,6 +122,7 @@ struct saf1761_dci_softc { bus_space_handle_t sc_io_hdl; uint32_t sc_intr_enable; /* enabled interrupts */ + uint32_t sc_hw_mode; /* hardware mode */ uint8_t sc_rt_addr; /* root HUB address */ uint8_t sc_dv_addr; /* device address */ diff --git a/sys/dev/usb/controller/saf1761_dci_reg.h b/sys/dev/usb/controller/saf1761_dci_reg.h index 258be76888254..959ef22f9519b 100644 --- a/sys/dev/usb/controller/saf1761_dci_reg.h +++ b/sys/dev/usb/controller/saf1761_dci_reg.h @@ -102,6 +102,17 @@ #define SOTG_DEBUG_SET (1 << 0) #define SOTG_DCINTERRUPT_EN 0x214 #define SOTG_HW_MODE_CTRL 0x300 +#define SOTG_HW_MODE_CTRL_ALL_ATX_RESET (1 << 31) +#define SOTG_HW_MODE_CTRL_ANA_DIGI_OC (1 << 15) +#define SOTG_HW_MODE_CTRL_DEV_DMA (1 << 11) +#define SOTG_HW_MODE_CTRL_COMN_INT (1 << 10) +#define SOTG_HW_MODE_CTRL_COMN_DMA (1 << 9) +#define SOTG_HW_MODE_CTRL_DATA_BUS_WIDTH (1 << 8) +#define SOTG_HW_MODE_CTRL_DACK_POL (1 << 6) +#define SOTG_HW_MODE_CTRL_DREQ_POL (1 << 5) +#define SOTG_HW_MODE_CTRL_INTR_POL (1 << 2) +#define SOTG_HW_MODE_CTRL_INTR_LEVEL (1 << 1) +#define SOTG_HW_MODE_CTRL_GLOBAL_INTR_EN (1 << 0) #define SOTG_OTG_CTRL 0x374 #define SOTG_EP_INDEX 0x22c #define SOTG_EP_INDEX_EP0SETUP (1 << 5) @@ -155,5 +166,29 @@ #define SOTG_UNLOCK_DEVICE_CODE 0xAA37 #define SOTG_IRQ_PULSE_WIDTH 0x280 #define SOTG_TEST_MODE 0x284 +#define SOTG_TEST_MODE_FORCEHS (1 << 7) +#define SOTG_TEST_MODE_FORCEFS (1 << 4) +#define SOTG_TEST_MODE_PRBS (1 << 3) +#define SOTG_TEST_MODE_KSTATE (1 << 2) +#define SOTG_TEST_MODE_JSTATE (1 << 1) +#define SOTG_TEST_MODE_SE0_NAK (1 << 0) + +/* Host controller specific registers */ + +#define SOTG_CONFIGFLAG 0x0060 +#define SOTG_CONFIGFLAG_ENABLE (1 << 0) +#define SOTG_PORTSC1 0x0064 +#define SOTG_PORTSC1_PO (1 << 13) +#define SOTG_PORTSC1_PP (1 << 12) +#define SOTG_PORTSC1_PR (1 << 8) +#define SOTG_PORTSC1_SUSP (1 << 7) +#define SOTG_PORTSC1_FPR (1 << 6) +#define SOTG_PORTSC1_PED (1 << 2) +#define SOTG_PORTSC1_ECSC (1 << 1) +#define SOTG_PORTSC1_ECCS (1 << 0) +#define SOTG_ASYNC_PDT(x) (0x400 + (60 * 1024) + ((x) * 32)) +#define SOTG_INTR_PDT(x) (0x400 + (61 * 1024) + ((x) * 32)) +#define SOTG_ISOC_PDT(x) (0x400 + (62 * 1024) + ((x) * 32)) +#define SOTG_HC_MEMORY_ADDR(x) (((x) - 0x400) >> 3) #endif /* _SAF1761_DCI_REG_H_ */ -- cgit v1.3 From fffa71cbfe3ffe1ce24098a042e7ee127bac9e51 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Fri, 16 May 2014 10:35:21 +0000 Subject: - Add flattended device tree probe-, attach- and detach code for the SAF1761 driver, compatible to existing Linux based FDT tables for the same hardware. Sponsored by: DARPA, AFRL --- sys/dev/usb/controller/saf1761_dci_fdt.c | 183 +++++++++++++++++++++++++++++++ 1 file changed, 183 insertions(+) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/saf1761_dci_fdt.c b/sys/dev/usb/controller/saf1761_dci_fdt.c index 256a2f49ff88b..3927c7358b3d5 100644 --- a/sys/dev/usb/controller/saf1761_dci_fdt.c +++ b/sys/dev/usb/controller/saf1761_dci_fdt.c @@ -50,6 +50,13 @@ #include #include #include +#include + +#include + +#include +#include +#include #include #include @@ -68,3 +75,179 @@ #include #include + +static device_probe_t saf1761_dci_fdt_probe; +static device_attach_t saf1761_dci_fdt_attach; +static device_detach_t saf1761_dci_fdt_detach; + +static device_method_t saf1761_dci_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, saf1761_dci_fdt_probe), + DEVMETHOD(device_attach, saf1761_dci_fdt_attach), + DEVMETHOD(device_detach, saf1761_dci_fdt_detach), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + + DEVMETHOD_END +}; + +static driver_t saf1761_dci_driver = { + .name = "saf1761", + .methods = saf1761_dci_methods, + .size = sizeof(struct saf1761_dci_softc), +}; + +static devclass_t saf1761_dci_devclass; + +DRIVER_MODULE(saf1761, simplebus, saf1761_dci_driver, saf1761_dci_devclass, 0, 0); +MODULE_DEPEND(saf1761, usb, 1, 1, 1); + +static int +saf1761_dci_fdt_probe(device_t dev) +{ + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + if (!ofw_bus_is_compatible(dev, "nxp,usb-isp1761")) + return (ENXIO); + + device_set_desc(dev, "ISP1761/SAF1761 DCI USB 2.0 Device Controller"); + + return (0); +} + +static int +saf1761_dci_fdt_attach(device_t dev) +{ + struct saf1761_dci_softc *sc = device_get_softc(dev); + char param[24]; + int err; + int rid; + + /* get configuration from FDT */ + + /* get bus-width, if any */ + if (OF_getprop(ofw_bus_get_node(dev), "bus-width", + ¶m, sizeof(param)) > 0) { + param[sizeof(param) - 1] = 0; + if (strcmp(param, "32") == 0) + sc->sc_hw_mode |= SOTG_HW_MODE_CTRL_DATA_BUS_WIDTH; + } else { + /* assume 32-bit data bus */ + sc->sc_hw_mode |= SOTG_HW_MODE_CTRL_DATA_BUS_WIDTH; + } + + /* get analog over-current setting */ + if (OF_getprop(ofw_bus_get_node(dev), "analog-oc", + ¶m, sizeof(param)) > 0) { + sc->sc_hw_mode |= SOTG_HW_MODE_CTRL_ANA_DIGI_OC; + } + + /* get DACK polarity */ + if (OF_getprop(ofw_bus_get_node(dev), "dack-polarity", + ¶m, sizeof(param)) > 0) { + sc->sc_hw_mode |= SOTG_HW_MODE_CTRL_DACK_POL; + } + + /* get DREQ polarity */ + if (OF_getprop(ofw_bus_get_node(dev), "dreq-polarity", + ¶m, sizeof(param)) > 0) { + sc->sc_hw_mode |= SOTG_HW_MODE_CTRL_DREQ_POL; + } + + /* initialise some bus fields */ + sc->sc_bus.parent = dev; + sc->sc_bus.devices = sc->sc_devices; + sc->sc_bus.devices_max = SOTG_MAX_DEVICES; + + /* get all DMA memory */ + if (usb_bus_mem_alloc_all(&sc->sc_bus, + USB_GET_DMA_TAG(dev), NULL)) { + return (ENOMEM); + } + rid = 0; + sc->sc_io_res = + bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, RF_ACTIVE); + + if (!sc->sc_io_res) { + goto error; + } + sc->sc_io_tag = rman_get_bustag(sc->sc_io_res); + sc->sc_io_hdl = rman_get_bushandle(sc->sc_io_res); + sc->sc_io_size = rman_get_size(sc->sc_io_res); + + rid = 0; + sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, + RF_SHAREABLE | RF_ACTIVE); + if (sc->sc_irq_res == NULL) { + goto error; + } + sc->sc_bus.bdev = device_add_child(dev, "usbus", -1); + if (!(sc->sc_bus.bdev)) { + goto error; + } + device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus); + + err = bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE, + NULL, (driver_intr_t *)saf1761_dci_interrupt, sc, &sc->sc_intr_hdl); + if (err) { + sc->sc_intr_hdl = NULL; + goto error; + } + err = saf1761_dci_init(sc); + if (err) { + device_printf(dev, "Init failed\n"); + goto error; + } + err = device_probe_and_attach(sc->sc_bus.bdev); + if (err) { + device_printf(dev, "USB probe and attach failed\n"); + goto error; + } + return (0); + +error: + saf1761_dci_fdt_detach(dev); + return (ENXIO); +} + +static int +saf1761_dci_fdt_detach(device_t dev) +{ + struct saf1761_dci_softc *sc = device_get_softc(dev); + device_t bdev; + int err; + + if (sc->sc_bus.bdev) { + bdev = sc->sc_bus.bdev; + device_detach(bdev); + device_delete_child(dev, bdev); + } + /* during module unload there are lots of children leftover */ + device_delete_children(dev); + + if (sc->sc_irq_res && sc->sc_intr_hdl) { + /* + * Only call uninit() after init() + */ + saf1761_dci_uninit(sc); + + err = bus_teardown_intr(dev, sc->sc_irq_res, + sc->sc_intr_hdl); + sc->sc_intr_hdl = NULL; + } + if (sc->sc_irq_res) { + bus_release_resource(dev, SYS_RES_IRQ, 0, + sc->sc_irq_res); + sc->sc_irq_res = NULL; + } + if (sc->sc_io_res) { + bus_release_resource(dev, SYS_RES_IOPORT, 0, + sc->sc_io_res); + sc->sc_io_res = NULL; + } + usb_bus_mem_free_all(&sc->sc_bus, NULL); + + return (0); +} -- cgit v1.3 From 39c913fb219e286604b050b28bf1c8fcfd27cd7a Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Fri, 16 May 2014 10:37:25 +0000 Subject: - Allow the SAF1761 driver to attach to the root HUB USB driver. Sponsored by: DARPA, AFRL --- sys/dev/usb/controller/usb_controller.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/usb_controller.c b/sys/dev/usb/controller/usb_controller.c index bbb9e85df954e..ee13a3524e726 100644 --- a/sys/dev/usb/controller/usb_controller.c +++ b/sys/dev/usb/controller/usb_controller.c @@ -138,6 +138,7 @@ DRIVER_MODULE(usbus, octusb, usb_driver, usb_devclass, 0, 0); /* Dual Mode Drivers */ DRIVER_MODULE(usbus, dwcotg, usb_driver, usb_devclass, 0, 0); +DRIVER_MODULE(usbus, saf1761, usb_driver, usb_devclass, 0, 0); /*------------------------------------------------------------------------* * usb_probe -- cgit v1.3 From 2550c55ed390cecf88b859b940f2de60c0abdb36 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Fri, 16 May 2014 15:41:55 +0000 Subject: Implement basic support for the USB host controller found in the SAF1761 chip, supporting BULK and CONTROL endpoints. This code is not yet tested. Sponsored by: DARPA, AFRL --- sys/dev/usb/controller/saf1761_dci.c | 804 ++++++++++++++++++++++++++++--- sys/dev/usb/controller/saf1761_dci.h | 17 +- sys/dev/usb/controller/saf1761_dci_reg.h | 20 + 3 files changed, 775 insertions(+), 66 deletions(-) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/saf1761_dci.c b/sys/dev/usb/controller/saf1761_dci.c index ae23d5c60cc12..78fbab3691744 100644 --- a/sys/dev/usb/controller/saf1761_dci.c +++ b/sys/dev/usb/controller/saf1761_dci.c @@ -103,13 +103,20 @@ SYSCTL_INT(_hw_usb_saf1761_dci, OID_AUTO, forcefs, CTLFLAG_RW, /* prototypes */ static const struct usb_bus_methods saf1761_dci_bus_methods; -static const struct usb_pipe_methods saf1761_dci_device_non_isoc_methods; +static const struct usb_pipe_methods saf1761_otg_non_isoc_methods; static const struct usb_pipe_methods saf1761_dci_device_isoc_methods; -static saf1761_dci_cmd_t saf1761_dci_setup_rx; -static saf1761_dci_cmd_t saf1761_dci_data_rx; -static saf1761_dci_cmd_t saf1761_dci_data_tx; -static saf1761_dci_cmd_t saf1761_dci_data_tx_sync; +static saf1761_dci_cmd_t saf1761_host_setup_tx; +static saf1761_dci_cmd_t saf1761_host_bulk_data_rx; +static saf1761_dci_cmd_t saf1761_host_bulk_data_tx; +static saf1761_dci_cmd_t saf1761_host_intr_data_rx; +static saf1761_dci_cmd_t saf1761_host_intr_data_tx; +static saf1761_dci_cmd_t saf1761_host_isoc_data_rx; +static saf1761_dci_cmd_t saf1761_host_isoc_data_tx; +static saf1761_dci_cmd_t saf1761_device_setup_rx; +static saf1761_dci_cmd_t saf1761_device_data_rx; +static saf1761_dci_cmd_t saf1761_device_data_tx; +static saf1761_dci_cmd_t saf1761_device_data_tx_sync; static void saf1761_dci_device_done(struct usb_xfer *, usb_error_t); static void saf1761_dci_do_poll(struct usb_bus *); static void saf1761_dci_standard_done(struct usb_xfer *); @@ -197,6 +204,357 @@ saf1761_dci_wakeup_peer(struct saf1761_dci_softc *sc) } +static uint8_t +saf1761_host_channel_alloc(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) +{ + uint32_t x; + + if (td->channel < SOTG_HOST_CHANNEL_MAX) + return (0); + + switch (td->ep_type) { + case UE_INTERRUPT: + for (x = 0; x != 32; x++) { + if (sc->sc_host_intr_map & (1 << x)) + continue; + sc->sc_host_intr_map |= (1 << x); + td->channel = 32 + x; + return (0); + } + break; + case UE_ISOCHRONOUS: + for (x = 0; x != 32; x++) { + if (sc->sc_host_isoc_map & (1 << x)) + continue; + sc->sc_host_isoc_map |= (1 << x); + td->channel = 64 + x; + return (0); + } + break; + default: + for (x = 0; x != 32; x++) { + if (sc->sc_host_async_map & (1 << x)) + continue; + sc->sc_host_async_map |= (1 << x); + td->channel = x; + return (0); + } + break; + } + return (1); +} + +static void +saf1761_host_channel_free(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) +{ + uint32_t x; + + if (td->channel >= SOTG_HOST_CHANNEL_MAX) + return; + + /* disable channel */ + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 3), 0); + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 0), 0); + + switch (td->ep_type) { + case UE_INTERRUPT: + x = td->channel - 32; + sc->sc_host_intr_map &= ~(1 << x); + td->channel = SOTG_HOST_CHANNEL_MAX; + break; + case UE_ISOCHRONOUS: + x = td->channel - 64; + sc->sc_host_isoc_map &= ~(1 << x); + td->channel = SOTG_HOST_CHANNEL_MAX; + break; + default: + x = td->channel - 64; + sc->sc_host_async_map &= ~(1 << x); + td->channel = SOTG_HOST_CHANNEL_MAX; + break; + } +} + +static void +saf1761_read_host_fifo_1(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td, + void *buf, uint32_t len) +{ + bus_space_read_region_1((sc)->sc_io_tag, (sc)->sc_io_hdl, + SOTG_DATA_ADDR(td->channel), buf, len); +} + +static void +saf1761_write_host_fifo_1(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td, + void *buf, uint32_t len) +{ + bus_space_write_region_1((sc)->sc_io_tag, (sc)->sc_io_hdl, + SOTG_DATA_ADDR(td->channel), buf, len); +} + +static uint8_t +saf1761_host_setup_tx(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) +{ + struct usb_device_request req __aligned(4); + uint32_t status; + uint32_t count; + + if (td->channel < SOTG_HOST_CHANNEL_MAX) { + status = SAF1761_READ_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 3)); + if (status & (1 << 31)) { + goto busy; + } else if (status & (1 << 30)) { + td->error_stall = 1; + td->error_any = 1; + } else if (status & (3 << 28)) { + td->error_any = 1; + } + count = (status & 0x7FFF); + + saf1761_host_channel_free(sc, td); + goto complete; + } + if (saf1761_host_channel_alloc(sc, td)) + goto busy; + + if (sizeof(req) != td->remainder) { + td->error_any = 1; + goto complete; + } + + count = sizeof(req); + + usbd_copy_out(td->pc, 0, &req, count); + + saf1761_write_host_fifo_1(sc, td, &req, count); + + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 7), 0); + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 6), 0); + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 5), 0); + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 4), 0); + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 3), + (1 << 31) | (td->toggle << 25) | (3 << 23)); + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 2), + SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8); + + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 1), + td->dw1_value | + (2 << 10) /* SETUP PID */ | + (td->ep_index >> 1)); + + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 0), + (td->ep_index << 31) | + (1 << 29) /* pkt-multiplier */ | + (td->max_packet_size << 18) /* wMaxPacketSize */ | + (count << 3) /* transfer count */ | + 1 /* valid */); + + td->offset += count; + td->remainder -= count; + td->toggle = 1; +busy: + return (1); /* busy */ +complete: + return (0); /* complete */ +} + +static uint8_t +saf1761_host_bulk_data_rx(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) +{ + if (td->channel < SOTG_HOST_CHANNEL_MAX) { + uint32_t status; + uint32_t count; + uint8_t got_short; + + status = SAF1761_READ_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 3)); + + if (status & (1 << 31)) { + goto busy; + } else if (status & (1 << 30)) { + td->error_stall = 1; + td->error_any = 1; + goto complete; + } else if (status & (3 << 28)) { + td->error_any = 1; + goto complete; + } + count = (status & 0x7FFF); + got_short = 0; + + /* verify the packet byte count */ + if (count != td->max_packet_size) { + if (count < td->max_packet_size) { + /* we have a short packet */ + td->short_pkt = 1; + got_short = 1; + } else { + /* invalid USB packet */ + td->error_any = 1; + goto complete; + } + } + td->toggle ^= 1; + + /* verify the packet byte count */ + if (count > td->remainder) { + /* invalid USB packet */ + td->error_any = 1; + goto complete; + } + + saf1761_read_host_fifo_1(sc, td, + sc->sc_bounce_buffer, count); + usbd_copy_in(td->pc, td->offset, + sc->sc_bounce_buffer, count); + + td->remainder -= count; + td->offset += count; + + saf1761_host_channel_free(sc, td); + + /* check if we are complete */ + if ((td->remainder == 0) || got_short) { + if (td->short_pkt) + goto complete; + /* else need to receive a zero length packet */ + } + } + if (saf1761_host_channel_alloc(sc, td)) + goto busy; + + /* set toggle, if any */ + if (td->set_toggle) { + td->set_toggle = 0; + td->toggle = 1; + } + + /* receive one more packet */ + + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 7), 0); + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 6), 0); + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 5), 0); + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 4), 0); + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 3), + (1 << 31) | (td->toggle << 25) | (3 << 23)); + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 2), + SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8); + + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 1), + td->dw1_value | + (1 << 10) /* IN-PID */ | + (td->ep_index >> 1)); + + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 0), + (td->ep_index << 31) | + (1 << 29) /* pkt-multiplier */ | + (td->max_packet_size << 18) /* wMaxPacketSize */ | + (td->max_packet_size << 3) /* transfer count */ | + 1 /* valid */); +busy: + return (1); /* busy */ +complete: + return (0); /* complete */ +} + +static uint8_t +saf1761_host_bulk_data_tx(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) +{ + uint32_t count; + + if (td->channel < SOTG_HOST_CHANNEL_MAX) { + uint32_t status; + + status = SAF1761_READ_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 3)); + if (status & (1 << 31)) { + goto busy; + } else if (status & (1 << 30)) { + td->error_stall = 1; + td->error_any = 1; + } else if (status & (3 << 28)) { + td->error_any = 1; + } + + saf1761_host_channel_free(sc, td); + + /* check remainder */ + if (td->remainder == 0) { + if (td->short_pkt) + goto complete; + /* else we need to transmit a short packet */ + } + } + if (saf1761_host_channel_alloc(sc, td)) + goto busy; + + count = td->max_packet_size; + if (td->remainder < count) { + /* we have a short packet */ + td->short_pkt = 1; + count = td->remainder; + } + + usbd_copy_out(td->pc, td->offset, sc->sc_bounce_buffer, count); + saf1761_write_host_fifo_1(sc, td, sc->sc_bounce_buffer, count); + + /* set toggle, if any */ + if (td->set_toggle) { + td->set_toggle = 0; + td->toggle = 1; + } + + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 7), 0); + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 6), 0); + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 5), 0); + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 4), 0); + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 3), + (1 << 31) | (td->toggle << 25) | (3 << 23)); + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 2), + SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8); + + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 1), + td->dw1_value | + (0 << 10) /* OUT-PID */ | + (td->ep_index >> 1)); + + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 0), + (td->ep_index << 31) | + (1 << 29) /* pkt-multiplier */ | + (td->max_packet_size << 18) /* wMaxPacketSize */ | + (count << 3) /* transfer count */ | + 1 /* valid */); + + td->offset += count; + td->remainder -= count; + td->toggle ^= 1; +busy: + return (1); /* busy */ +complete: + return (0); /* complete */ +} + +static uint8_t +saf1761_host_intr_data_rx(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) +{ + return (1); /* busy */ +} + +static uint8_t +saf1761_host_intr_data_tx(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) +{ + return (1); /* busy */ +} + +static uint8_t +saf1761_host_isoc_data_rx(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) +{ + return (1); /* busy */ +} + +static uint8_t +saf1761_host_isoc_data_tx(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) +{ + return (1); /* busy */ +} + static void saf1761_dci_set_address(struct saf1761_dci_softc *sc, uint8_t addr) { @@ -206,21 +564,21 @@ saf1761_dci_set_address(struct saf1761_dci_softc *sc, uint8_t addr) } static void -saf1761_read_fifo(struct saf1761_dci_softc *sc, void *buf, uint32_t len) +saf1761_read_device_fifo_1(struct saf1761_dci_softc *sc, void *buf, uint32_t len) { bus_space_read_multi_1((sc)->sc_io_tag, (sc)->sc_io_hdl, SOTG_DATA_PORT, buf, len); } static void -saf1761_write_fifo(struct saf1761_dci_softc *sc, void *buf, uint32_t len) +saf1761_write_device_fifo_1(struct saf1761_dci_softc *sc, void *buf, uint32_t len) { bus_space_write_multi_1((sc)->sc_io_tag, (sc)->sc_io_hdl, SOTG_DATA_PORT, buf, len); } static uint8_t -saf1761_dci_setup_rx(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) +saf1761_device_setup_rx(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) { struct usb_device_request req; uint16_t count; @@ -256,7 +614,7 @@ saf1761_dci_setup_rx(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) goto busy; } /* receive data */ - saf1761_read_fifo(sc, &req, sizeof(req)); + saf1761_read_device_fifo_1(sc, &req, sizeof(req)); /* copy data into real buffer */ usbd_copy_in(td->pc, 0, &req, sizeof(req)); @@ -288,7 +646,7 @@ busy: } static uint8_t -saf1761_dci_data_rx(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) +saf1761_device_data_rx(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) { struct usb_page_search buf_res; uint16_t count; @@ -314,7 +672,7 @@ saf1761_dci_data_rx(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) /* * USB Host Aborted the transfer. */ - td->error = 1; + td->error_any = 1; return (0); /* complete */ } } @@ -323,6 +681,12 @@ saf1761_dci_data_rx(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) (td->ep_index << SOTG_EP_INDEX_ENDP_INDEX_SHIFT) | SOTG_EP_INDEX_DIR_OUT); + /* enable data stage */ + if (td->set_toggle) { + td->set_toggle = 0; + SAF1761_WRITE_1(sc, SOTG_CTRL_FUNC, SOTG_CTRL_FUNC_DSEN); + } + /* check buffer status */ if ((SAF1761_READ_1(sc, SOTG_DCBUFFERSTATUS) & SOTG_DCBUFFERSTATUS_FILLED_MASK) == 0) { @@ -341,14 +705,14 @@ saf1761_dci_data_rx(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) got_short = 1; } else { /* invalid USB packet */ - td->error = 1; + td->error_any = 1; return (0); /* we are complete */ } } /* verify the packet byte count */ if (count > td->remainder) { /* invalid USB packet */ - td->error = 1; + td->error_any = 1; return (0); /* we are complete */ } while (count > 0) { @@ -359,7 +723,7 @@ saf1761_dci_data_rx(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) buf_res.length = count; /* receive data */ - saf1761_read_fifo(sc, buf_res.buffer, buf_res.length); + saf1761_read_device_fifo_1(sc, buf_res.buffer, buf_res.length); /* update counters */ count -= buf_res.length; @@ -378,7 +742,7 @@ saf1761_dci_data_rx(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) } static uint8_t -saf1761_dci_data_tx(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) +saf1761_device_data_tx(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) { struct usb_page_search buf_res; uint16_t count; @@ -395,7 +759,7 @@ saf1761_dci_data_tx(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) /* * USB Host Aborted the transfer. */ - td->error = 1; + td->error_any = 1; return (0); /* complete */ } } @@ -409,6 +773,13 @@ saf1761_dci_data_tx(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) SOTG_DCBUFFERSTATUS_FILLED_MASK) != 0) { return (1); /* not complete */ } + + /* enable data stage */ + if (td->set_toggle) { + td->set_toggle = 0; + SAF1761_WRITE_1(sc, SOTG_CTRL_FUNC, SOTG_CTRL_FUNC_DSEN); + } + DPRINTFN(5, "rem=%u\n", td->remainder); count = td->max_packet_size; @@ -428,7 +799,7 @@ saf1761_dci_data_tx(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) buf_res.length = count; /* transmit data */ - saf1761_write_fifo(sc, buf_res.buffer, buf_res.length); + saf1761_write_device_fifo_1(sc, buf_res.buffer, buf_res.length); /* update counters */ count -= buf_res.length; @@ -459,7 +830,7 @@ saf1761_dci_data_tx(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) } static uint8_t -saf1761_dci_data_tx_sync(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) +saf1761_device_data_tx_sync(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) { if (td->ep_index == 0) { /* select the correct endpoint */ @@ -493,6 +864,7 @@ static uint8_t saf1761_dci_xfer_do_fifo(struct saf1761_dci_softc *sc, struct usb_xfer *xfer) { struct saf1761_dci_td *td; + uint8_t toggle; DPRINTFN(9, "\n"); @@ -505,7 +877,7 @@ saf1761_dci_xfer_do_fifo(struct saf1761_dci_softc *sc, struct usb_xfer *xfer) if (((void *)td) == xfer->td_transfer_last) { goto done; } - if (td->error) { + if (td->error_any) { goto done; } else if (td->remainder > 0) { /* @@ -519,7 +891,9 @@ saf1761_dci_xfer_do_fifo(struct saf1761_dci_softc *sc, struct usb_xfer *xfer) /* * Fetch the next transfer descriptor. */ + toggle = td->toggle; td = td->obj_next; + td->toggle = toggle; xfer->td_transfer_cache = td; } return (1); /* not complete */ @@ -683,10 +1057,13 @@ saf1761_dci_setup_standard_chain_sub(struct saf1761_dci_std_temp *temp) td->pc = temp->pc; td->offset = temp->offset; td->remainder = temp->len; - td->error = 0; + td->error_any = 0; + td->error_stall = 0; + td->set_toggle = 0; td->did_stall = temp->did_stall; td->short_pkt = temp->short_pkt; td->alt_next = temp->setup_alt_next; + td->channel = SOTG_HOST_CHANNEL_MAX; } static void @@ -697,6 +1074,9 @@ saf1761_dci_setup_standard_chain(struct usb_xfer *xfer) struct saf1761_dci_td *td; uint32_t x; uint8_t ep_no; + uint8_t ep_type; + uint8_t need_sync; + uint8_t is_host; DPRINTFN(9, "addr=%d endpt=%d sumlen=%d speed=%d\n", xfer->address, UE_GET_ADDR(xfer->endpointno), @@ -717,15 +1097,22 @@ saf1761_dci_setup_standard_chain(struct usb_xfer *xfer) temp.setup_alt_next = xfer->flags_int.short_frames_ok; temp.did_stall = !xfer->flags_int.control_stall; + is_host = (xfer->xroot->udev->flags.usb_mode == USB_MODE_HOST); + sc = SAF1761_DCI_BUS2SC(xfer->xroot->bus); ep_no = (xfer->endpointno & UE_ADDR); + ep_type = (xfer->endpoint->edesc->bmAttributes & UE_XFERTYPE); /* check if we should prepend a setup message */ if (xfer->flags_int.control_xfr) { if (xfer->flags_int.control_hdr) { - temp.func = &saf1761_dci_setup_rx; + if (is_host) + temp.func = &saf1761_host_setup_tx; + else + temp.func = &saf1761_device_setup_rx; + temp.len = xfer->frlengths[0]; temp.pc = xfer->frbuffers + 0; temp.short_pkt = temp.len ? 1 : 0; @@ -744,14 +1131,39 @@ saf1761_dci_setup_standard_chain(struct usb_xfer *xfer) if (x != xfer->nframes) { if (xfer->endpointno & UE_DIR_IN) { - temp.func = &saf1761_dci_data_tx; + if (is_host) { + if (ep_type == UE_INTERRUPT) + temp.func = &saf1761_host_intr_data_rx; + else if (ep_type == UE_ISOCHRONOUS) + temp.func = &saf1761_host_isoc_data_rx; + else + temp.func = &saf1761_host_bulk_data_rx; + need_sync = 0; + } else { + temp.func = &saf1761_device_data_tx; + need_sync = 1; + } } else { - temp.func = &saf1761_dci_data_rx; + if (is_host) { + if (ep_type == UE_INTERRUPT) + temp.func = &saf1761_host_intr_data_tx; + else if (ep_type == UE_ISOCHRONOUS) + temp.func = &saf1761_host_isoc_data_tx; + else + temp.func = &saf1761_host_bulk_data_tx; + need_sync = 0; + } else { + temp.func = &saf1761_device_data_rx; + need_sync = 0; + } } /* setup "pc" pointer */ temp.pc = xfer->frbuffers + x; + } else { + need_sync = 0; } + while (x != xfer->nframes) { /* DATA0 / DATA1 message */ @@ -794,8 +1206,6 @@ saf1761_dci_setup_standard_chain(struct usb_xfer *xfer) /* check for control transfer */ if (xfer->flags_int.control_xfr) { - uint8_t need_sync; - /* always setup a valid "pc" pointer for status and sync */ temp.pc = xfer->frbuffers + 0; temp.len = 0; @@ -810,26 +1220,59 @@ saf1761_dci_setup_standard_chain(struct usb_xfer *xfer) * endpoint direction. */ if (xfer->endpointno & UE_DIR_IN) { - temp.func = &saf1761_dci_data_rx; - need_sync = 0; + if (is_host) { + temp.func = &saf1761_host_bulk_data_tx; + need_sync = 0; + } else { + temp.func = &saf1761_device_data_rx; + need_sync = 0; + } } else { - temp.func = &saf1761_dci_data_tx; - need_sync = 1; + if (is_host) { + temp.func = &saf1761_host_bulk_data_rx; + need_sync = 0; + } else { + temp.func = &saf1761_device_data_tx; + need_sync = 1; + } } temp.len = 0; temp.short_pkt = 0; saf1761_dci_setup_standard_chain_sub(&temp); + + /* data toggle should be DATA1 */ + td = temp.td; + td->set_toggle = 1; + if (need_sync) { /* we need a SYNC point after TX */ - temp.func = &saf1761_dci_data_tx_sync; + temp.func = &saf1761_device_data_tx_sync; saf1761_dci_setup_standard_chain_sub(&temp); } } + } else { + if (need_sync) { + temp.pc = xfer->frbuffers + 0; + temp.len = 0; + temp.short_pkt = 0; + temp.setup_alt_next = 0; + + /* we need a SYNC point after TX */ + temp.func = &saf1761_device_data_tx_sync; + saf1761_dci_setup_standard_chain_sub(&temp); + } } + /* must have at least one frame! */ td = temp.td; xfer->td_transfer_last = td; + + if (is_host) { + /* get first again */ + td = xfer->td_transfer_first; + td->toggle = (xfer->endpoint->toggle_next ? 1 : 0); + } } static void @@ -919,7 +1362,7 @@ saf1761_dci_standard_done_sub(struct usb_xfer *xfer) { struct saf1761_dci_td *td; uint32_t len; - uint8_t error; + usb_error_t error; DPRINTFN(9, "\n"); @@ -928,21 +1371,25 @@ saf1761_dci_standard_done_sub(struct usb_xfer *xfer) do { len = td->remainder; + /* store last data toggle */ + xfer->endpoint->toggle_next = td->toggle; + if (xfer->aframes != xfer->nframes) { /* * Verify the length and subtract * the remainder from "frlengths[]": */ if (len > xfer->frlengths[xfer->aframes]) { - td->error = 1; + td->error_any = 1; } else { xfer->frlengths[xfer->aframes] -= len; } } /* Check for transfer error */ - if (td->error) { + if (td->error_any) { /* the transfer is finished */ - error = 1; + error = (td->error_stall ? + USB_ERR_STALLED : USB_ERR_IOERROR); td = NULL; break; } @@ -974,8 +1421,7 @@ saf1761_dci_standard_done_sub(struct usb_xfer *xfer) xfer->td_transfer_cache = td; - return (error ? - USB_ERR_STALLED : USB_ERR_NORMAL_COMPLETION); + return (error); } static void @@ -1030,13 +1476,23 @@ done: static void saf1761_dci_device_done(struct usb_xfer *xfer, usb_error_t error) { + struct saf1761_dci_softc *sc = SAF1761_DCI_BUS2SC(xfer->xroot->bus); + USB_BUS_LOCK_ASSERT(xfer->xroot->bus, MA_OWNED); DPRINTFN(2, "xfer=%p, endpoint=%p, error=%d\n", xfer, xfer->endpoint, error); - if (xfer->flags_int.usb_mode == USB_MODE_DEVICE) + if (xfer->flags_int.usb_mode == USB_MODE_DEVICE) { saf1761_dci_intr_set(xfer, 0); + } else { + struct saf1761_dci_td *td; + + td = xfer->td_transfer_first; + + if (td != NULL) + saf1761_host_channel_free(sc, td); + } /* dequeue transfer and start next transfer */ usbd_transfer_done(xfer, error); @@ -1059,6 +1515,12 @@ saf1761_dci_set_stall(struct usb_device *udev, USB_BUS_LOCK_ASSERT(udev->bus, MA_OWNED); + /* check mode */ + if (udev->flags.usb_mode != USB_MODE_DEVICE) { + /* not supported */ + return; + } + DPRINTFN(5, "endpoint=%p\n", ep); /* set FORCESTALL */ @@ -1138,7 +1600,7 @@ usb_error_t saf1761_dci_init(struct saf1761_dci_softc *sc) { const struct usb_hw_ep_profile *pf; - uint8_t x; + uint32_t x; DPRINTF("\n"); @@ -1161,13 +1623,26 @@ saf1761_dci_init(struct saf1761_dci_softc *sc) DPRINTF("DCID=0x%08x\n", SAF1761_READ_4(sc, SOTG_DCCHIP_ID)); - /* reset device */ + /* reset device controller */ SAF1761_WRITE_2(sc, SOTG_MODE, SOTG_MODE_SFRESET); SAF1761_WRITE_2(sc, SOTG_MODE, 0); /* wait a bit */ DELAY(1000); + /* reset host controller */ + SAF1761_WRITE_4(sc, SOTG_SW_RESET, SOTG_SW_RESET_HC); + SAF1761_WRITE_4(sc, SOTG_USBCMD, SOTG_USBCMD_HCRESET); + + /* wait a bit */ + DELAY(1000); + + SAF1761_WRITE_4(sc, SOTG_SW_RESET, 0); + SAF1761_WRITE_4(sc, SOTG_USBCMD, 0); + + /* wait a bit */ + DELAY(1000); + /* do a pulldown */ saf1761_dci_pull_down(sc); @@ -1225,6 +1700,22 @@ saf1761_dci_init(struct saf1761_dci_softc *sc) /* disable device address */ SAF1761_WRITE_1(sc, SOTG_ADDRESS, 0); + /* enable host controller clock */ + SAF1761_WRITE_4(sc, SOTG_POWER_DOWN, SOTG_POWER_DOWN_HC_CLK_EN); + + /* wait 10ms for clock */ + usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 100); + + /* enable configuration flag */ + SAF1761_WRITE_4(sc, SOTG_CONFIGFLAG, SOTG_CONFIGFLAG_ENABLE); + + /* clear RAM block */ + for (x = 0x400; x != 0x10000; x += 4) + SAF1761_WRITE_4(sc, x, 0); + + /* start the HC */ + SAF1761_WRITE_4(sc, SOTG_USBCMD, SOTG_USBCMD_RS); + /* poll initial VBUS status */ saf1761_dci_update_vbus(sc); @@ -1309,7 +1800,7 @@ saf1761_dci_device_non_isoc_start(struct usb_xfer *xfer) saf1761_dci_start_standard_chain(xfer); } -static const struct usb_pipe_methods saf1761_dci_device_non_isoc_methods = +static const struct usb_pipe_methods saf1761_otg_non_isoc_methods = { .open = saf1761_dci_device_non_isoc_open, .close = saf1761_dci_device_non_isoc_close, @@ -1465,7 +1956,7 @@ static const struct saf1761_dci_config_desc saf1761_dci_confd = { static const struct usb_hub_descriptor_min saf1761_dci_hubd = { .bDescLength = sizeof(saf1761_dci_hubd), .bDescriptorType = UDESC_HUB, - .bNbrPorts = 1, + .bNbrPorts = SOTG_NUM_PORTS, HSETW(.wHubCharacteristics, (UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL)), .bPwrOn2PwrGood = 50, .bHubContrCurrent = 0, @@ -1490,6 +1981,8 @@ saf1761_dci_roothub_exec(struct usb_device *udev, uint16_t len; uint16_t value; uint16_t index; + uint32_t temp; + uint32_t i; usb_error_t err; USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED); @@ -1620,9 +2113,19 @@ saf1761_dci_roothub_exec(struct usb_device *udev, case UT_WRITE_CLASS_OTHER: switch (req->bRequest) { case UR_CLEAR_FEATURE: - goto tr_handle_clear_port_feature; + if (index == SOTG_HOST_PORT_NUM) + goto tr_handle_clear_port_feature_host; + else if (index == SOTG_DEVICE_PORT_NUM) + goto tr_handle_clear_port_feature_device; + else + goto tr_stalled; case UR_SET_FEATURE: - goto tr_handle_set_port_feature; + if (index == SOTG_HOST_PORT_NUM) + goto tr_handle_set_port_feature_host; + else if (index == SOTG_DEVICE_PORT_NUM) + goto tr_handle_set_port_feature_device; + else + goto tr_stalled; case UR_CLEAR_TT_BUFFER: case UR_RESET_TT: case UR_STOP_TT: @@ -1638,7 +2141,12 @@ saf1761_dci_roothub_exec(struct usb_device *udev, case UR_GET_TT_STATE: goto tr_handle_get_tt_state; case UR_GET_STATUS: - goto tr_handle_get_port_status; + if (index == SOTG_HOST_PORT_NUM) + goto tr_handle_get_port_status_host; + else if (index == SOTG_DEVICE_PORT_NUM) + goto tr_handle_get_port_status_device; + else + goto tr_stalled; default: goto tr_stalled; } @@ -1748,10 +2256,8 @@ tr_handle_clear_wakeup: tr_handle_clear_halt: goto tr_valid; -tr_handle_clear_port_feature: - if (index != 1) - goto tr_stalled; - DPRINTFN(9, "UR_CLEAR_PORT_FEATURE on port %d\n", index); +tr_handle_clear_port_feature_device: + DPRINTFN(9, "UR_CLEAR_FEATURE on port %d\n", index); switch (value) { case UHF_PORT_SUSPEND: @@ -1785,10 +2291,52 @@ tr_handle_clear_port_feature: } goto tr_valid; -tr_handle_set_port_feature: - if (index != 1) - goto tr_stalled; - DPRINTFN(9, "UR_SET_PORT_FEATURE\n"); +tr_handle_clear_port_feature_host: + DPRINTFN(9, "UR_CLEAR_FEATURE on port %d\n", index); + + temp = SAF1761_READ_4(sc, SOTG_PORTSC1); + + switch (value) { + case UHF_PORT_ENABLE: + SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp & ~SOTG_PORTSC1_PED); + break; + case UHF_PORT_SUSPEND: + if ((temp & SOTG_PORTSC1_SUSP) && (!(temp & SOTG_PORTSC1_FPR))) + SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp | SOTG_PORTSC1_FPR); + + /* wait 20ms for resume sequence to complete */ + usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 50); + + SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp & ~(SOTG_PORTSC1_SUSP | + SOTG_PORTSC1_FPR | SOTG_PORTSC1_LS /* High Speed */ )); + + /* 4ms settle time */ + usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 250); + break; + case UHF_PORT_INDICATOR: + SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp & ~SOTG_PORTSC1_PIC); + break; + case UHF_PORT_TEST: + case UHF_C_PORT_ENABLE: + case UHF_C_PORT_OVER_CURRENT: + case UHF_C_PORT_RESET: + case UHF_C_PORT_SUSPEND: + /* NOPs */ + break; + case UHF_PORT_POWER: + SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp & ~SOTG_PORTSC1_PP); + break; + case UHF_C_PORT_CONNECTION: + SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp & ~SOTG_PORTSC1_ECSC); + break; + default: + err = USB_ERR_IOERROR; + goto tr_valid; + } + goto tr_valid; + +tr_handle_set_port_feature_device: + DPRINTFN(9, "UR_SET_FEATURE on port %d\n", index); switch (value) { case UHF_PORT_ENABLE: @@ -1809,12 +2357,73 @@ tr_handle_set_port_feature: } goto tr_valid; -tr_handle_get_port_status: +tr_handle_set_port_feature_host: + DPRINTFN(9, "UR_SET_FEATURE on port %d\n", index); - DPRINTFN(9, "UR_GET_PORT_STATUS\n"); + temp = SAF1761_READ_4(sc, SOTG_PORTSC1); - if (index != 1) - goto tr_stalled; + switch (value) { + case UHF_PORT_ENABLE: + SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp | SOTG_PORTSC1_PED); + break; + case UHF_PORT_SUSPEND: + SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp | SOTG_PORTSC1_SUSP); + break; + case UHF_PORT_RESET: + DPRINTFN(6, "reset port %d\n", index); + + /* Start reset sequence. */ + temp &= ~(SOTG_PORTSC1_PED | SOTG_PORTSC1_PR); + + SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp | SOTG_PORTSC1_PR); + + /* Wait for reset to complete. */ + usb_pause_mtx(&sc->sc_bus.bus_mtx, + USB_MS_TO_TICKS(usb_port_root_reset_delay)); + + SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp); + + /* Wait for HC to complete reset. */ + usb_pause_mtx(&sc->sc_bus.bus_mtx, USB_MS_TO_TICKS(2)); + + temp = SAF1761_READ_4(sc, SOTG_PORTSC1); + + DPRINTF("After reset, status=0x%08x\n", temp); + if (temp & SOTG_PORTSC1_PR) { + device_printf(sc->sc_bus.bdev, "port reset timeout\n"); + err = USB_ERR_TIMEOUT; + goto tr_valid; + } + if (!(temp & SOTG_PORTSC1_PED)) { + /* Not a high speed device, give up ownership.*/ + SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp | SOTG_PORTSC1_PO); + break; + } + sc->sc_isreset = 1; + DPRINTF("port %d reset, status = 0x%08x\n", index, temp); + break; + case UHF_PORT_POWER: + DPRINTFN(3, "set port power %d\n", index); + SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp | SOTG_PORTSC1_PP); + break; + + case UHF_PORT_TEST: + DPRINTFN(3, "set port test %d\n", index); + break; + + case UHF_PORT_INDICATOR: + DPRINTFN(3, "set port ind %d\n", index); + SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp | SOTG_PORTSC1_PIC); + break; + default: + err = USB_ERR_IOERROR; + goto tr_valid; + } + goto tr_valid; + +tr_handle_get_port_status_device: + + DPRINTFN(9, "UR_GET_PORT_STATUS on port %d\n", index); if (sc->sc_flags.status_vbus) { saf1761_dci_pull_up(sc); @@ -1853,6 +2462,37 @@ tr_handle_get_port_status: len = sizeof(sc->sc_hub_temp.ps); goto tr_valid; +tr_handle_get_port_status_host: + + temp = SAF1761_READ_4(sc, SOTG_PORTSC1); + + DPRINTFN(9, "port status=0x%04x\n", temp); + i = UPS_HIGH_SPEED; + + if (temp & SOTG_PORTSC1_ECCS) + i |= UPS_CURRENT_CONNECT_STATUS; + if (temp & SOTG_PORTSC1_PED) + i |= UPS_PORT_ENABLED; + if ((temp & SOTG_PORTSC1_SUSP) && !(temp & SOTG_PORTSC1_FPR)) + i |= UPS_SUSPEND; + if (temp & SOTG_PORTSC1_PR) + i |= UPS_RESET; + if (temp & SOTG_PORTSC1_PP) + i |= UPS_PORT_POWER; + + USETW(sc->sc_hub_temp.ps.wPortStatus, i); + i = 0; + + if (temp & SOTG_PORTSC1_ECSC) + i |= UPS_C_CONNECT_STATUS; + if (temp & SOTG_PORTSC1_FPR) + i |= UPS_C_SUSPEND; + if (sc->sc_isreset) + i |= UPS_C_PORT_RESET; + USETW(sc->sc_hub_temp.ps.wPortChange, i); + len = sizeof(sc->sc_hub_temp.ps); + goto tr_valid; + tr_handle_get_class_descriptor: if (value & 0xFF) goto tr_stalled; @@ -1871,10 +2511,10 @@ tr_valid: static void saf1761_dci_xfer_setup(struct usb_setup_params *parm) { - const struct usb_hw_ep_profile *pf; struct saf1761_dci_softc *sc; struct usb_xfer *xfer; void *last_obj; + uint32_t dw1; uint32_t ntd; uint32_t n; uint8_t ep_no; @@ -1918,12 +2558,14 @@ saf1761_dci_xfer_setup(struct usb_setup_params *parm) */ last_obj = NULL; + ep_no = xfer->endpointno & UE_ADDR; + /* - * get profile stuff + * Check profile stuff */ - if (ntd) { + if (parm->udev->flags.usb_mode == USB_MODE_DEVICE) { + const struct usb_hw_ep_profile *pf; - ep_no = xfer->endpointno & UE_ADDR; saf1761_dci_get_hw_ep_profile(parm->udev, &pf, ep_no); if (pf == NULL) { @@ -1931,9 +2573,24 @@ saf1761_dci_xfer_setup(struct usb_setup_params *parm) parm->err = USB_ERR_INVAL; return; } - } else { - ep_no = 0; - pf = NULL; + } + + dw1 = (xfer->address << 3) | (ep_type << 12); + + switch (parm->udev->speed) { + case USB_SPEED_FULL: + case USB_SPEED_LOW: + /* check if root HUB port is running High Speed */ + if (parm->udev->parent_hs_hub != NULL) { + dw1 |= (1 << 14); + dw1 |= (parm->udev->hs_port_no << 18); + dw1 |= (parm->udev->hs_hub_addr << 25); + if (parm->udev->speed == USB_SPEED_LOW) + dw1 |= (1 << 17); + } + break; + default: + break; } /* align data */ @@ -1950,6 +2607,8 @@ saf1761_dci_xfer_setup(struct usb_setup_params *parm) /* init TD */ td->max_packet_size = xfer->max_packet_size; td->ep_index = ep_no; + td->ep_type = ep_type; + td->dw1_value = dw1; td->obj_next = last_obj; @@ -1977,7 +2636,12 @@ saf1761_dci_ep_init(struct usb_device *udev, struct usb_endpoint_descriptor *ede edesc->bEndpointAddress, udev->flags.usb_mode, sc->sc_rt_addr); - if (udev->device_index != sc->sc_rt_addr) { + if (udev->parent_hub == NULL) { + /* root HUB has special endpoint handling */ + return; + } + + if (udev->flags.usb_mode == USB_MODE_DEVICE) { if (udev->speed != USB_SPEED_FULL && udev->speed != USB_SPEED_HIGH) { /* not supported */ @@ -1988,7 +2652,17 @@ saf1761_dci_ep_init(struct usb_device *udev, struct usb_endpoint_descriptor *ede ep->methods = &saf1761_dci_device_isoc_methods; break; default: - ep->methods = &saf1761_dci_device_non_isoc_methods; + ep->methods = &saf1761_otg_non_isoc_methods; + break; + } + } else { + switch (edesc->bmAttributes & UE_XFERTYPE) { + case UE_CONTROL: + case UE_BULK: + ep->methods = &saf1761_otg_non_isoc_methods; + break; + default: + /* TODO */ break; } } diff --git a/sys/dev/usb/controller/saf1761_dci.h b/sys/dev/usb/controller/saf1761_dci.h index a8dd18c990eb0..0fde2f58443bd 100644 --- a/sys/dev/usb/controller/saf1761_dci.h +++ b/sys/dev/usb/controller/saf1761_dci.h @@ -35,6 +35,10 @@ #define SOTG_MAX_DEVICES (USB_MIN_DEVICES + 1) #define SOTG_FS_MAX_PACKET_SIZE 64 #define SOTG_HS_MAX_PACKET_SIZE 512 +#define SOTG_NUM_PORTS 2 /* one Device and one Host port */ +#define SOTG_HOST_PORT_NUM 1 +#define SOTG_DEVICE_PORT_NUM 2 +#define SOTG_HOST_CHANNEL_MAX (3 * 32) #define SAF1761_READ_1(sc, reg) \ bus_space_read_1((sc)->sc_io_tag, (sc)->sc_io_hdl, reg) @@ -61,12 +65,18 @@ struct saf1761_dci_td { struct usb_page_cache *pc; uint32_t offset; uint32_t remainder; + uint32_t dw1_value; uint16_t max_packet_size; uint8_t ep_index; - uint8_t error:1; + uint8_t ep_type; + uint8_t channel; + uint8_t error_any:1; + uint8_t error_stall:1; uint8_t alt_next:1; uint8_t short_pkt:1; uint8_t did_stall:1; + uint8_t toggle:1; + uint8_t set_toggle:1; }; struct saf1761_dci_std_temp { @@ -121,12 +131,17 @@ struct saf1761_dci_softc { bus_space_tag_t sc_io_tag; bus_space_handle_t sc_io_hdl; + uint32_t sc_host_async_map; + uint32_t sc_host_intr_map; + uint32_t sc_host_isoc_map; uint32_t sc_intr_enable; /* enabled interrupts */ uint32_t sc_hw_mode; /* hardware mode */ + uint8_t sc_bounce_buffer[1024] __aligned(4); uint8_t sc_rt_addr; /* root HUB address */ uint8_t sc_dv_addr; /* device address */ uint8_t sc_conf; /* root HUB config */ + uint8_t sc_isreset; /* host mode */ uint8_t sc_hub_idata[1]; diff --git a/sys/dev/usb/controller/saf1761_dci_reg.h b/sys/dev/usb/controller/saf1761_dci_reg.h index 959ef22f9519b..4d4dd8611f2d8 100644 --- a/sys/dev/usb/controller/saf1761_dci_reg.h +++ b/sys/dev/usb/controller/saf1761_dci_reg.h @@ -178,17 +178,37 @@ #define SOTG_CONFIGFLAG 0x0060 #define SOTG_CONFIGFLAG_ENABLE (1 << 0) #define SOTG_PORTSC1 0x0064 +#define SOTG_PORTSC1_PIC (3 << 14) #define SOTG_PORTSC1_PO (1 << 13) #define SOTG_PORTSC1_PP (1 << 12) +#define SOTG_PORTSC1_LS (3 << 10) #define SOTG_PORTSC1_PR (1 << 8) #define SOTG_PORTSC1_SUSP (1 << 7) #define SOTG_PORTSC1_FPR (1 << 6) #define SOTG_PORTSC1_PED (1 << 2) #define SOTG_PORTSC1_ECSC (1 << 1) #define SOTG_PORTSC1_ECCS (1 << 0) +#define SOTG_DATA_ADDR(x) (0x400 + (512 * (x))) #define SOTG_ASYNC_PDT(x) (0x400 + (60 * 1024) + ((x) * 32)) #define SOTG_INTR_PDT(x) (0x400 + (61 * 1024) + ((x) * 32)) #define SOTG_ISOC_PDT(x) (0x400 + (62 * 1024) + ((x) * 32)) #define SOTG_HC_MEMORY_ADDR(x) (((x) - 0x400) >> 3) +#define SOTG_SW_RESET 0x30C +#define SOTG_SW_RESET_HC (1 << 1) +#define SOTG_SW_RESET_ALL (1 << 0) +#define SOTG_POWER_DOWN 0x354 +#define SOTG_POWER_DOWN_PORT3_PD (1 << 12) +#define SOTG_POWER_DOWN_PORT2_PD (1 << 11) +#define SOTG_POWER_DOWN_VBATDET_PWR (1 << 10) +#define SOTG_POWER_DOWN_BIAS_EN (1 << 5) +#define SOTG_POWER_DOWN_VREG_ON (1 << 4) +#define SOTG_POWER_DOWN_OC3_PWR (1 << 3) +#define SOTG_POWER_DOWN_OC2_PWR (1 << 2) +#define SOTG_POWER_DOWN_OC1_PWR (1 << 1) +#define SOTG_POWER_DOWN_HC_CLK_EN (1 << 0) +#define SOTG_USBCMD 0x20 +#define SOTG_USBCMD_LHCR (1 << 7) +#define SOTG_USBCMD_HCRESET (1 << 1) +#define SOTG_USBCMD_RS (1 << 0) #endif /* _SAF1761_DCI_REG_H_ */ -- cgit v1.3 From f46e2f146bba8f90568687f0032b0f50ee927726 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Fri, 16 May 2014 15:50:21 +0000 Subject: Rename "saf1761_dci_xxx" into "saf1761_otg_xxx" to reflect that this driver supports both host and device side mode. Sponsored by: DARPA, AFRL --- sys/dev/usb/controller/saf1761_otg.c | 2703 ++++++++++++++++++++++++++++++ sys/dev/usb/controller/saf1761_otg.h | 157 ++ sys/dev/usb/controller/saf1761_otg_fdt.c | 253 +++ sys/dev/usb/controller/saf1761_otg_reg.h | 214 +++ sys/modules/usb/saf1761/Makefile | 2 +- 5 files changed, 3328 insertions(+), 1 deletion(-) create mode 100644 sys/dev/usb/controller/saf1761_otg.c create mode 100644 sys/dev/usb/controller/saf1761_otg.h create mode 100644 sys/dev/usb/controller/saf1761_otg_fdt.c create mode 100644 sys/dev/usb/controller/saf1761_otg_reg.h (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/saf1761_otg.c b/sys/dev/usb/controller/saf1761_otg.c new file mode 100644 index 0000000000000..36e8c2c5a5561 --- /dev/null +++ b/sys/dev/usb/controller/saf1761_otg.c @@ -0,0 +1,2703 @@ +/* $FreeBSD$ */ +/*- + * Copyright (c) 2014 Hans Petter Selasky + * All rights reserved. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * This file contains the driver for the SAF1761 series USB OTG + * controller. + * + * Datasheet is available from: + * http://www.nxp.com/products/automotive/multimedia/usb/SAF1761BE.html + */ + +#ifdef USB_GLOBAL_INCLUDE_FILE +#include USB_GLOBAL_INCLUDE_FILE +#else +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#define USB_DEBUG_VAR saf1761_otg_debug + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#endif /* USB_GLOBAL_INCLUDE_FILE */ + +#include +#include + +#define SAF1761_OTG_BUS2SC(bus) \ + ((struct saf1761_otg_softc *)(((uint8_t *)(bus)) - \ + ((uint8_t *)&(((struct saf1761_otg_softc *)0)->sc_bus)))) + +#ifdef USB_DEBUG +static int saf1761_otg_debug = 0; +static int saf1761_otg_forcefs = 0; + +static +SYSCTL_NODE(_hw_usb, OID_AUTO, saf1761_otg, CTLFLAG_RW, 0, + "USB SAF1761 DCI"); + +SYSCTL_INT(_hw_usb_saf1761_otg, OID_AUTO, debug, CTLFLAG_RW, + &saf1761_otg_debug, 0, "SAF1761 DCI debug level"); +SYSCTL_INT(_hw_usb_saf1761_otg, OID_AUTO, forcefs, CTLFLAG_RW, + &saf1761_otg_forcefs, 0, "SAF1761 DCI force FULL speed"); +#endif + +#define SAF1761_OTG_INTR_ENDPT 1 + +/* prototypes */ + +static const struct usb_bus_methods saf1761_otg_bus_methods; +static const struct usb_pipe_methods saf1761_otg_non_isoc_methods; +static const struct usb_pipe_methods saf1761_otg_device_isoc_methods; + +static saf1761_otg_cmd_t saf1761_host_setup_tx; +static saf1761_otg_cmd_t saf1761_host_bulk_data_rx; +static saf1761_otg_cmd_t saf1761_host_bulk_data_tx; +static saf1761_otg_cmd_t saf1761_host_intr_data_rx; +static saf1761_otg_cmd_t saf1761_host_intr_data_tx; +static saf1761_otg_cmd_t saf1761_host_isoc_data_rx; +static saf1761_otg_cmd_t saf1761_host_isoc_data_tx; +static saf1761_otg_cmd_t saf1761_device_setup_rx; +static saf1761_otg_cmd_t saf1761_device_data_rx; +static saf1761_otg_cmd_t saf1761_device_data_tx; +static saf1761_otg_cmd_t saf1761_device_data_tx_sync; +static void saf1761_otg_device_done(struct usb_xfer *, usb_error_t); +static void saf1761_otg_do_poll(struct usb_bus *); +static void saf1761_otg_standard_done(struct usb_xfer *); +static void saf1761_otg_intr_set(struct usb_xfer *, uint8_t); +static void saf1761_otg_root_intr(struct saf1761_otg_softc *); + +/* + * Here is a list of what the SAF1761 chip can support. The main + * limitation is that the sum of the buffer sizes must be less than + * 8192 bytes. + */ +static const struct usb_hw_ep_profile saf1761_otg_ep_profile[] = { + + [0] = { + .max_in_frame_size = 64, + .max_out_frame_size = 64, + .is_simplex = 0, + .support_control = 1, + }, + [1] = { + .max_in_frame_size = SOTG_HS_MAX_PACKET_SIZE, + .max_out_frame_size = SOTG_HS_MAX_PACKET_SIZE, + .is_simplex = 0, + .support_interrupt = 1, + .support_bulk = 1, + .support_isochronous = 1, + .support_in = 1, + .support_out = 1, + }, +}; + +static void +saf1761_otg_get_hw_ep_profile(struct usb_device *udev, + const struct usb_hw_ep_profile **ppf, uint8_t ep_addr) +{ + if (ep_addr == 0) { + *ppf = saf1761_otg_ep_profile + 0; + } else if (ep_addr < 8) { + *ppf = saf1761_otg_ep_profile + 1; + } else { + *ppf = NULL; + } +} + +static void +saf1761_otg_pull_up(struct saf1761_otg_softc *sc) +{ + /* activate pullup on D+, if possible */ + + if (!sc->sc_flags.d_pulled_up && sc->sc_flags.port_powered) { + DPRINTF("\n"); + + sc->sc_flags.d_pulled_up = 1; + } +} + +static void +saf1761_otg_pull_down(struct saf1761_otg_softc *sc) +{ + /* release pullup on D+, if possible */ + + if (sc->sc_flags.d_pulled_up) { + DPRINTF("\n"); + + sc->sc_flags.d_pulled_up = 0; + } +} + +static void +saf1761_otg_wakeup_peer(struct saf1761_otg_softc *sc) +{ + uint16_t temp; + + if (!(sc->sc_flags.status_suspend)) + return; + + DPRINTFN(5, "\n"); + + temp = SAF1761_READ_2(sc, SOTG_MODE); + SAF1761_WRITE_2(sc, SOTG_MODE, temp | SOTG_MODE_SNDRSU); + SAF1761_WRITE_2(sc, SOTG_MODE, temp & ~SOTG_MODE_SNDRSU); + + /* Wait 8ms for remote wakeup to complete. */ + usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 125); + +} + +static uint8_t +saf1761_host_channel_alloc(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) +{ + uint32_t x; + + if (td->channel < SOTG_HOST_CHANNEL_MAX) + return (0); + + switch (td->ep_type) { + case UE_INTERRUPT: + for (x = 0; x != 32; x++) { + if (sc->sc_host_intr_map & (1 << x)) + continue; + sc->sc_host_intr_map |= (1 << x); + td->channel = 32 + x; + return (0); + } + break; + case UE_ISOCHRONOUS: + for (x = 0; x != 32; x++) { + if (sc->sc_host_isoc_map & (1 << x)) + continue; + sc->sc_host_isoc_map |= (1 << x); + td->channel = 64 + x; + return (0); + } + break; + default: + for (x = 0; x != 32; x++) { + if (sc->sc_host_async_map & (1 << x)) + continue; + sc->sc_host_async_map |= (1 << x); + td->channel = x; + return (0); + } + break; + } + return (1); +} + +static void +saf1761_host_channel_free(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) +{ + uint32_t x; + + if (td->channel >= SOTG_HOST_CHANNEL_MAX) + return; + + /* disable channel */ + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 3), 0); + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 0), 0); + + switch (td->ep_type) { + case UE_INTERRUPT: + x = td->channel - 32; + sc->sc_host_intr_map &= ~(1 << x); + td->channel = SOTG_HOST_CHANNEL_MAX; + break; + case UE_ISOCHRONOUS: + x = td->channel - 64; + sc->sc_host_isoc_map &= ~(1 << x); + td->channel = SOTG_HOST_CHANNEL_MAX; + break; + default: + x = td->channel - 64; + sc->sc_host_async_map &= ~(1 << x); + td->channel = SOTG_HOST_CHANNEL_MAX; + break; + } +} + +static void +saf1761_read_host_fifo_1(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td, + void *buf, uint32_t len) +{ + bus_space_read_region_1((sc)->sc_io_tag, (sc)->sc_io_hdl, + SOTG_DATA_ADDR(td->channel), buf, len); +} + +static void +saf1761_write_host_fifo_1(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td, + void *buf, uint32_t len) +{ + bus_space_write_region_1((sc)->sc_io_tag, (sc)->sc_io_hdl, + SOTG_DATA_ADDR(td->channel), buf, len); +} + +static uint8_t +saf1761_host_setup_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) +{ + struct usb_device_request req __aligned(4); + uint32_t status; + uint32_t count; + + if (td->channel < SOTG_HOST_CHANNEL_MAX) { + status = SAF1761_READ_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 3)); + if (status & (1 << 31)) { + goto busy; + } else if (status & (1 << 30)) { + td->error_stall = 1; + td->error_any = 1; + } else if (status & (3 << 28)) { + td->error_any = 1; + } + count = (status & 0x7FFF); + + saf1761_host_channel_free(sc, td); + goto complete; + } + if (saf1761_host_channel_alloc(sc, td)) + goto busy; + + if (sizeof(req) != td->remainder) { + td->error_any = 1; + goto complete; + } + + count = sizeof(req); + + usbd_copy_out(td->pc, 0, &req, count); + + saf1761_write_host_fifo_1(sc, td, &req, count); + + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 7), 0); + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 6), 0); + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 5), 0); + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 4), 0); + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 3), + (1 << 31) | (td->toggle << 25) | (3 << 23)); + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 2), + SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8); + + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 1), + td->dw1_value | + (2 << 10) /* SETUP PID */ | + (td->ep_index >> 1)); + + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 0), + (td->ep_index << 31) | + (1 << 29) /* pkt-multiplier */ | + (td->max_packet_size << 18) /* wMaxPacketSize */ | + (count << 3) /* transfer count */ | + 1 /* valid */); + + td->offset += count; + td->remainder -= count; + td->toggle = 1; +busy: + return (1); /* busy */ +complete: + return (0); /* complete */ +} + +static uint8_t +saf1761_host_bulk_data_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) +{ + if (td->channel < SOTG_HOST_CHANNEL_MAX) { + uint32_t status; + uint32_t count; + uint8_t got_short; + + status = SAF1761_READ_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 3)); + + if (status & (1 << 31)) { + goto busy; + } else if (status & (1 << 30)) { + td->error_stall = 1; + td->error_any = 1; + goto complete; + } else if (status & (3 << 28)) { + td->error_any = 1; + goto complete; + } + count = (status & 0x7FFF); + got_short = 0; + + /* verify the packet byte count */ + if (count != td->max_packet_size) { + if (count < td->max_packet_size) { + /* we have a short packet */ + td->short_pkt = 1; + got_short = 1; + } else { + /* invalid USB packet */ + td->error_any = 1; + goto complete; + } + } + td->toggle ^= 1; + + /* verify the packet byte count */ + if (count > td->remainder) { + /* invalid USB packet */ + td->error_any = 1; + goto complete; + } + + saf1761_read_host_fifo_1(sc, td, + sc->sc_bounce_buffer, count); + usbd_copy_in(td->pc, td->offset, + sc->sc_bounce_buffer, count); + + td->remainder -= count; + td->offset += count; + + saf1761_host_channel_free(sc, td); + + /* check if we are complete */ + if ((td->remainder == 0) || got_short) { + if (td->short_pkt) + goto complete; + /* else need to receive a zero length packet */ + } + } + if (saf1761_host_channel_alloc(sc, td)) + goto busy; + + /* set toggle, if any */ + if (td->set_toggle) { + td->set_toggle = 0; + td->toggle = 1; + } + + /* receive one more packet */ + + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 7), 0); + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 6), 0); + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 5), 0); + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 4), 0); + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 3), + (1 << 31) | (td->toggle << 25) | (3 << 23)); + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 2), + SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8); + + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 1), + td->dw1_value | + (1 << 10) /* IN-PID */ | + (td->ep_index >> 1)); + + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 0), + (td->ep_index << 31) | + (1 << 29) /* pkt-multiplier */ | + (td->max_packet_size << 18) /* wMaxPacketSize */ | + (td->max_packet_size << 3) /* transfer count */ | + 1 /* valid */); +busy: + return (1); /* busy */ +complete: + return (0); /* complete */ +} + +static uint8_t +saf1761_host_bulk_data_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) +{ + uint32_t count; + + if (td->channel < SOTG_HOST_CHANNEL_MAX) { + uint32_t status; + + status = SAF1761_READ_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 3)); + if (status & (1 << 31)) { + goto busy; + } else if (status & (1 << 30)) { + td->error_stall = 1; + td->error_any = 1; + } else if (status & (3 << 28)) { + td->error_any = 1; + } + + saf1761_host_channel_free(sc, td); + + /* check remainder */ + if (td->remainder == 0) { + if (td->short_pkt) + goto complete; + /* else we need to transmit a short packet */ + } + } + if (saf1761_host_channel_alloc(sc, td)) + goto busy; + + count = td->max_packet_size; + if (td->remainder < count) { + /* we have a short packet */ + td->short_pkt = 1; + count = td->remainder; + } + + usbd_copy_out(td->pc, td->offset, sc->sc_bounce_buffer, count); + saf1761_write_host_fifo_1(sc, td, sc->sc_bounce_buffer, count); + + /* set toggle, if any */ + if (td->set_toggle) { + td->set_toggle = 0; + td->toggle = 1; + } + + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 7), 0); + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 6), 0); + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 5), 0); + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 4), 0); + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 3), + (1 << 31) | (td->toggle << 25) | (3 << 23)); + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 2), + SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8); + + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 1), + td->dw1_value | + (0 << 10) /* OUT-PID */ | + (td->ep_index >> 1)); + + SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 0), + (td->ep_index << 31) | + (1 << 29) /* pkt-multiplier */ | + (td->max_packet_size << 18) /* wMaxPacketSize */ | + (count << 3) /* transfer count */ | + 1 /* valid */); + + td->offset += count; + td->remainder -= count; + td->toggle ^= 1; +busy: + return (1); /* busy */ +complete: + return (0); /* complete */ +} + +static uint8_t +saf1761_host_intr_data_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) +{ + return (1); /* busy */ +} + +static uint8_t +saf1761_host_intr_data_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) +{ + return (1); /* busy */ +} + +static uint8_t +saf1761_host_isoc_data_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) +{ + return (1); /* busy */ +} + +static uint8_t +saf1761_host_isoc_data_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) +{ + return (1); /* busy */ +} + +static void +saf1761_otg_set_address(struct saf1761_otg_softc *sc, uint8_t addr) +{ + DPRINTFN(5, "addr=%d\n", addr); + + SAF1761_WRITE_1(sc, SOTG_ADDRESS, addr | SOTG_ADDRESS_ENABLE); +} + +static void +saf1761_read_device_fifo_1(struct saf1761_otg_softc *sc, void *buf, uint32_t len) +{ + bus_space_read_multi_1((sc)->sc_io_tag, (sc)->sc_io_hdl, + SOTG_DATA_PORT, buf, len); +} + +static void +saf1761_write_device_fifo_1(struct saf1761_otg_softc *sc, void *buf, uint32_t len) +{ + bus_space_write_multi_1((sc)->sc_io_tag, (sc)->sc_io_hdl, + SOTG_DATA_PORT, buf, len); +} + +static uint8_t +saf1761_device_setup_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) +{ + struct usb_device_request req; + uint16_t count; + + /* select the correct endpoint */ + SAF1761_WRITE_1(sc, SOTG_EP_INDEX, SOTG_EP_INDEX_EP0SETUP); + + /* check buffer status */ + if ((SAF1761_READ_1(sc, SOTG_DCBUFFERSTATUS) & + SOTG_DCBUFFERSTATUS_FILLED_MASK) == 0) + goto busy; + + /* read buffer length */ + count = SAF1761_READ_2(sc, SOTG_BUF_LENGTH); + + DPRINTFN(5, "count=%u rem=%u\n", count, td->remainder); + + /* clear did stall */ + td->did_stall = 0; + + /* clear stall */ + SAF1761_WRITE_1(sc, SOTG_CTRL_FUNC, 0); + + /* verify data length */ + if (count != td->remainder) { + DPRINTFN(0, "Invalid SETUP packet " + "length, %d bytes\n", count); + goto busy; + } + if (count != sizeof(req)) { + DPRINTFN(0, "Unsupported SETUP packet " + "length, %d bytes\n", count); + goto busy; + } + /* receive data */ + saf1761_read_device_fifo_1(sc, &req, sizeof(req)); + + /* copy data into real buffer */ + usbd_copy_in(td->pc, 0, &req, sizeof(req)); + + td->offset = sizeof(req); + td->remainder = 0; + + /* sneak peek the set address */ + if ((req.bmRequestType == UT_WRITE_DEVICE) && + (req.bRequest == UR_SET_ADDRESS)) { + sc->sc_dv_addr = req.wValue[0] & 0x7F; + DPRINTF("Set address %d\n", sc->sc_dv_addr); + } else { + sc->sc_dv_addr = 0xFF; + } + return (0); /* complete */ + +busy: + /* abort any ongoing transfer */ + if (!td->did_stall) { + DPRINTFN(5, "stalling\n"); + + /* set stall */ + SAF1761_WRITE_1(sc, SOTG_CTRL_FUNC, SOTG_CTRL_FUNC_STALL); + + td->did_stall = 1; + } + return (1); /* not complete */ +} + +static uint8_t +saf1761_device_data_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) +{ + struct usb_page_search buf_res; + uint16_t count; + uint8_t got_short = 0; + + if (td->ep_index == 0) { + /* select the correct endpoint */ + SAF1761_WRITE_1(sc, SOTG_EP_INDEX, SOTG_EP_INDEX_EP0SETUP); + + /* check buffer status */ + if ((SAF1761_READ_1(sc, SOTG_DCBUFFERSTATUS) & + SOTG_DCBUFFERSTATUS_FILLED_MASK) != 0) { + + if (td->remainder == 0) { + /* + * We are actually complete and have + * received the next SETUP: + */ + DPRINTFN(5, "faking complete\n"); + return (0); /* complete */ + } + DPRINTFN(5, "SETUP packet while receiving data\n"); + /* + * USB Host Aborted the transfer. + */ + td->error_any = 1; + return (0); /* complete */ + } + } + /* select the correct endpoint */ + SAF1761_WRITE_1(sc, SOTG_EP_INDEX, + (td->ep_index << SOTG_EP_INDEX_ENDP_INDEX_SHIFT) | + SOTG_EP_INDEX_DIR_OUT); + + /* enable data stage */ + if (td->set_toggle) { + td->set_toggle = 0; + SAF1761_WRITE_1(sc, SOTG_CTRL_FUNC, SOTG_CTRL_FUNC_DSEN); + } + + /* check buffer status */ + if ((SAF1761_READ_1(sc, SOTG_DCBUFFERSTATUS) & + SOTG_DCBUFFERSTATUS_FILLED_MASK) == 0) { + return (1); /* not complete */ + } + /* read buffer length */ + count = SAF1761_READ_2(sc, SOTG_BUF_LENGTH); + + DPRINTFN(5, "rem=%u count=0x%04x\n", td->remainder, count); + + /* verify the packet byte count */ + if (count != td->max_packet_size) { + if (count < td->max_packet_size) { + /* we have a short packet */ + td->short_pkt = 1; + got_short = 1; + } else { + /* invalid USB packet */ + td->error_any = 1; + return (0); /* we are complete */ + } + } + /* verify the packet byte count */ + if (count > td->remainder) { + /* invalid USB packet */ + td->error_any = 1; + return (0); /* we are complete */ + } + while (count > 0) { + usbd_get_page(td->pc, td->offset, &buf_res); + + /* get correct length */ + if (buf_res.length > count) + buf_res.length = count; + + /* receive data */ + saf1761_read_device_fifo_1(sc, buf_res.buffer, buf_res.length); + + /* update counters */ + count -= buf_res.length; + td->offset += buf_res.length; + td->remainder -= buf_res.length; + } + /* check if we are complete */ + if ((td->remainder == 0) || got_short) { + if (td->short_pkt) { + /* we are complete */ + return (0); + } + /* else need to receive a zero length packet */ + } + return (1); /* not complete */ +} + +static uint8_t +saf1761_device_data_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) +{ + struct usb_page_search buf_res; + uint16_t count; + uint16_t count_old; + + if (td->ep_index == 0) { + /* select the correct endpoint */ + SAF1761_WRITE_1(sc, SOTG_EP_INDEX, SOTG_EP_INDEX_EP0SETUP); + + /* check buffer status */ + if ((SAF1761_READ_1(sc, SOTG_DCBUFFERSTATUS) & + SOTG_DCBUFFERSTATUS_FILLED_MASK) != 0) { + DPRINTFN(5, "SETUP abort\n"); + /* + * USB Host Aborted the transfer. + */ + td->error_any = 1; + return (0); /* complete */ + } + } + /* select the correct endpoint */ + SAF1761_WRITE_1(sc, SOTG_EP_INDEX, + (td->ep_index << SOTG_EP_INDEX_ENDP_INDEX_SHIFT) | + SOTG_EP_INDEX_DIR_IN); + + /* check buffer status */ + if ((SAF1761_READ_1(sc, SOTG_DCBUFFERSTATUS) & + SOTG_DCBUFFERSTATUS_FILLED_MASK) != 0) { + return (1); /* not complete */ + } + + /* enable data stage */ + if (td->set_toggle) { + td->set_toggle = 0; + SAF1761_WRITE_1(sc, SOTG_CTRL_FUNC, SOTG_CTRL_FUNC_DSEN); + } + + DPRINTFN(5, "rem=%u\n", td->remainder); + + count = td->max_packet_size; + if (td->remainder < count) { + /* we have a short packet */ + td->short_pkt = 1; + count = td->remainder; + } + count_old = count; + + while (count > 0) { + + usbd_get_page(td->pc, td->offset, &buf_res); + + /* get correct length */ + if (buf_res.length > count) + buf_res.length = count; + + /* transmit data */ + saf1761_write_device_fifo_1(sc, buf_res.buffer, buf_res.length); + + /* update counters */ + count -= buf_res.length; + td->offset += buf_res.length; + td->remainder -= buf_res.length; + } + + if (td->ep_index == 0) { + if (count_old < SOTG_FS_MAX_PACKET_SIZE) { + /* set end of packet */ + SAF1761_WRITE_1(sc, SOTG_CTRL_FUNC, SOTG_CTRL_FUNC_VENDP); + } + } else { + if (count_old < SOTG_HS_MAX_PACKET_SIZE) { + /* set end of packet */ + SAF1761_WRITE_1(sc, SOTG_CTRL_FUNC, SOTG_CTRL_FUNC_VENDP); + } + } + + /* check remainder */ + if (td->remainder == 0) { + if (td->short_pkt) { + return (0); /* complete */ + } + /* else we need to transmit a short packet */ + } + return (1); /* not complete */ +} + +static uint8_t +saf1761_device_data_tx_sync(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) +{ + if (td->ep_index == 0) { + /* select the correct endpoint */ + SAF1761_WRITE_1(sc, SOTG_EP_INDEX, SOTG_EP_INDEX_EP0SETUP); + + /* check buffer status */ + if ((SAF1761_READ_1(sc, SOTG_DCBUFFERSTATUS) & + SOTG_DCBUFFERSTATUS_FILLED_MASK) != 0) { + DPRINTFN(5, "Faking complete\n"); + return (0); /* complete */ + } + } + /* select the correct endpoint */ + SAF1761_WRITE_1(sc, SOTG_EP_INDEX, + (td->ep_index << SOTG_EP_INDEX_ENDP_INDEX_SHIFT) | + SOTG_EP_INDEX_DIR_IN); + + /* check buffer status */ + if ((SAF1761_READ_1(sc, SOTG_DCBUFFERSTATUS) & + SOTG_DCBUFFERSTATUS_FILLED_MASK) != 0) + return (1); /* busy */ + + if (sc->sc_dv_addr != 0xFF) { + /* write function address */ + saf1761_otg_set_address(sc, sc->sc_dv_addr); + } + return (0); /* complete */ +} + +static uint8_t +saf1761_otg_xfer_do_fifo(struct saf1761_otg_softc *sc, struct usb_xfer *xfer) +{ + struct saf1761_otg_td *td; + uint8_t toggle; + + DPRINTFN(9, "\n"); + + td = xfer->td_transfer_cache; + while (1) { + if ((td->func) (sc, td)) { + /* operation in progress */ + break; + } + if (((void *)td) == xfer->td_transfer_last) { + goto done; + } + if (td->error_any) { + goto done; + } else if (td->remainder > 0) { + /* + * We had a short transfer. If there is no alternate + * next, stop processing ! + */ + if (!td->alt_next) { + goto done; + } + } + /* + * Fetch the next transfer descriptor. + */ + toggle = td->toggle; + td = td->obj_next; + td->toggle = toggle; + xfer->td_transfer_cache = td; + } + return (1); /* not complete */ + +done: + /* compute all actual lengths */ + + saf1761_otg_standard_done(xfer); + + return (0); /* complete */ +} + +static void +saf1761_otg_interrupt_poll(struct saf1761_otg_softc *sc) +{ + struct usb_xfer *xfer; + +repeat: + TAILQ_FOREACH(xfer, &sc->sc_bus.intr_q.head, wait_entry) { + if (!saf1761_otg_xfer_do_fifo(sc, xfer)) { + /* queue has been modified */ + goto repeat; + } + } +} + +static void +saf1761_otg_wait_suspend(struct saf1761_otg_softc *sc, uint8_t on) +{ + if (on) { + sc->sc_intr_enable |= SOTG_DCINTERRUPT_IESUSP; + sc->sc_intr_enable &= ~SOTG_DCINTERRUPT_IERESM; + } else { + sc->sc_intr_enable &= ~SOTG_DCINTERRUPT_IESUSP; + sc->sc_intr_enable |= SOTG_DCINTERRUPT_IERESM; + } + SAF1761_WRITE_4(sc, SOTG_DCINTERRUPT_EN, sc->sc_intr_enable); +} + +static void +saf1761_otg_update_vbus(struct saf1761_otg_softc *sc) +{ + uint16_t status; + + /* read fresh status */ + status = SAF1761_READ_2(sc, SOTG_STATUS); + + DPRINTFN(4, "STATUS=0x%04x\n", status); + + if ((status & SOTG_STATUS_VBUS_VLD) && + (status & SOTG_STATUS_ID)) { + /* VBUS present and device mode */ + if (!sc->sc_flags.status_vbus) { + sc->sc_flags.status_vbus = 1; + + /* complete root HUB interrupt endpoint */ + saf1761_otg_root_intr(sc); + } + } else { + /* VBUS not-present or host mode */ + if (sc->sc_flags.status_vbus) { + sc->sc_flags.status_vbus = 0; + sc->sc_flags.status_bus_reset = 0; + sc->sc_flags.status_suspend = 0; + sc->sc_flags.change_suspend = 0; + sc->sc_flags.change_connect = 1; + + /* complete root HUB interrupt endpoint */ + saf1761_otg_root_intr(sc); + } + } +} + +void +saf1761_otg_interrupt(struct saf1761_otg_softc *sc) +{ + uint32_t status; + + USB_BUS_LOCK(&sc->sc_bus); + + status = SAF1761_READ_4(sc, SOTG_DCINTERRUPT); + + /* acknowledge all interrupts */ + SAF1761_WRITE_4(sc, SOTG_DCINTERRUPT, status); + + DPRINTF("DCINTERRUPT=0x%08x SOF=0x%04x\n", status, + SAF1761_READ_2(sc, SOTG_FRAME_NUM)); + + /* update VBUS and ID bits, if any */ + if (status & SOTG_DCINTERRUPT_IEVBUS) { + saf1761_otg_update_vbus(sc); + } + + if (status & SOTG_DCINTERRUPT_IEBRST) { + /* unlock device */ + SAF1761_WRITE_2(sc, SOTG_UNLOCK_DEVICE, + SOTG_UNLOCK_DEVICE_CODE); + + /* Enable device address */ + SAF1761_WRITE_1(sc, SOTG_ADDRESS, + SOTG_ADDRESS_ENABLE); + + sc->sc_flags.status_bus_reset = 1; + sc->sc_flags.status_suspend = 0; + sc->sc_flags.change_suspend = 0; + sc->sc_flags.change_connect = 1; + + /* disable resume interrupt */ + saf1761_otg_wait_suspend(sc, 1); + /* complete root HUB interrupt endpoint */ + saf1761_otg_root_intr(sc); + } + /* + * If "RESUME" and "SUSPEND" is set at the same time we + * interpret that like "RESUME". Resume is set when there is + * at least 3 milliseconds of inactivity on the USB BUS: + */ + if (status & SOTG_DCINTERRUPT_IERESM) { + /* unlock device */ + SAF1761_WRITE_2(sc, SOTG_UNLOCK_DEVICE, + SOTG_UNLOCK_DEVICE_CODE); + + if (sc->sc_flags.status_suspend) { + sc->sc_flags.status_suspend = 0; + sc->sc_flags.change_suspend = 1; + /* disable resume interrupt */ + saf1761_otg_wait_suspend(sc, 1); + /* complete root HUB interrupt endpoint */ + saf1761_otg_root_intr(sc); + } + } else if (status & SOTG_DCINTERRUPT_IESUSP) { + if (!sc->sc_flags.status_suspend) { + sc->sc_flags.status_suspend = 1; + sc->sc_flags.change_suspend = 1; + /* enable resume interrupt */ + saf1761_otg_wait_suspend(sc, 0); + /* complete root HUB interrupt endpoint */ + saf1761_otg_root_intr(sc); + } + } + /* poll all active transfers */ + saf1761_otg_interrupt_poll(sc); + + USB_BUS_UNLOCK(&sc->sc_bus); +} + +static void +saf1761_otg_setup_standard_chain_sub(struct saf1761_otg_std_temp *temp) +{ + struct saf1761_otg_td *td; + + /* get current Transfer Descriptor */ + td = temp->td_next; + temp->td = td; + + /* prepare for next TD */ + temp->td_next = td->obj_next; + + /* fill out the Transfer Descriptor */ + td->func = temp->func; + td->pc = temp->pc; + td->offset = temp->offset; + td->remainder = temp->len; + td->error_any = 0; + td->error_stall = 0; + td->set_toggle = 0; + td->did_stall = temp->did_stall; + td->short_pkt = temp->short_pkt; + td->alt_next = temp->setup_alt_next; + td->channel = SOTG_HOST_CHANNEL_MAX; +} + +static void +saf1761_otg_setup_standard_chain(struct usb_xfer *xfer) +{ + struct saf1761_otg_std_temp temp; + struct saf1761_otg_softc *sc; + struct saf1761_otg_td *td; + uint32_t x; + uint8_t ep_no; + uint8_t ep_type; + uint8_t need_sync; + uint8_t is_host; + + DPRINTFN(9, "addr=%d endpt=%d sumlen=%d speed=%d\n", + xfer->address, UE_GET_ADDR(xfer->endpointno), + xfer->sumlen, usbd_get_speed(xfer->xroot->udev)); + + temp.max_frame_size = xfer->max_frame_size; + + td = xfer->td_start[0]; + xfer->td_transfer_first = td; + xfer->td_transfer_cache = td; + + /* setup temp */ + + temp.pc = NULL; + temp.td = NULL; + temp.td_next = xfer->td_start[0]; + temp.offset = 0; + temp.setup_alt_next = xfer->flags_int.short_frames_ok; + temp.did_stall = !xfer->flags_int.control_stall; + + is_host = (xfer->xroot->udev->flags.usb_mode == USB_MODE_HOST); + + sc = SAF1761_OTG_BUS2SC(xfer->xroot->bus); + ep_no = (xfer->endpointno & UE_ADDR); + ep_type = (xfer->endpoint->edesc->bmAttributes & UE_XFERTYPE); + + /* check if we should prepend a setup message */ + + if (xfer->flags_int.control_xfr) { + if (xfer->flags_int.control_hdr) { + + if (is_host) + temp.func = &saf1761_host_setup_tx; + else + temp.func = &saf1761_device_setup_rx; + + temp.len = xfer->frlengths[0]; + temp.pc = xfer->frbuffers + 0; + temp.short_pkt = temp.len ? 1 : 0; + /* check for last frame */ + if (xfer->nframes == 1) { + /* no STATUS stage yet, SETUP is last */ + if (xfer->flags_int.control_act) + temp.setup_alt_next = 0; + } + saf1761_otg_setup_standard_chain_sub(&temp); + } + x = 1; + } else { + x = 0; + } + + if (x != xfer->nframes) { + if (xfer->endpointno & UE_DIR_IN) { + if (is_host) { + if (ep_type == UE_INTERRUPT) + temp.func = &saf1761_host_intr_data_rx; + else if (ep_type == UE_ISOCHRONOUS) + temp.func = &saf1761_host_isoc_data_rx; + else + temp.func = &saf1761_host_bulk_data_rx; + need_sync = 0; + } else { + temp.func = &saf1761_device_data_tx; + need_sync = 1; + } + } else { + if (is_host) { + if (ep_type == UE_INTERRUPT) + temp.func = &saf1761_host_intr_data_tx; + else if (ep_type == UE_ISOCHRONOUS) + temp.func = &saf1761_host_isoc_data_tx; + else + temp.func = &saf1761_host_bulk_data_tx; + need_sync = 0; + } else { + temp.func = &saf1761_device_data_rx; + need_sync = 0; + } + } + + /* setup "pc" pointer */ + temp.pc = xfer->frbuffers + x; + } else { + need_sync = 0; + } + + while (x != xfer->nframes) { + + /* DATA0 / DATA1 message */ + + temp.len = xfer->frlengths[x]; + + x++; + + if (x == xfer->nframes) { + if (xfer->flags_int.control_xfr) { + if (xfer->flags_int.control_act) { + temp.setup_alt_next = 0; + } + } else { + temp.setup_alt_next = 0; + } + } + if (temp.len == 0) { + + /* make sure that we send an USB packet */ + + temp.short_pkt = 0; + + } else { + + /* regular data transfer */ + + temp.short_pkt = (xfer->flags.force_short_xfer) ? 0 : 1; + } + + saf1761_otg_setup_standard_chain_sub(&temp); + + if (xfer->flags_int.isochronous_xfr) { + temp.offset += temp.len; + } else { + /* get next Page Cache pointer */ + temp.pc = xfer->frbuffers + x; + } + } + + /* check for control transfer */ + if (xfer->flags_int.control_xfr) { + /* always setup a valid "pc" pointer for status and sync */ + temp.pc = xfer->frbuffers + 0; + temp.len = 0; + temp.short_pkt = 0; + temp.setup_alt_next = 0; + + /* check if we should append a status stage */ + if (!xfer->flags_int.control_act) { + + /* + * Send a DATA1 message and invert the current + * endpoint direction. + */ + if (xfer->endpointno & UE_DIR_IN) { + if (is_host) { + temp.func = &saf1761_host_bulk_data_tx; + need_sync = 0; + } else { + temp.func = &saf1761_device_data_rx; + need_sync = 0; + } + } else { + if (is_host) { + temp.func = &saf1761_host_bulk_data_rx; + need_sync = 0; + } else { + temp.func = &saf1761_device_data_tx; + need_sync = 1; + } + } + temp.len = 0; + temp.short_pkt = 0; + + saf1761_otg_setup_standard_chain_sub(&temp); + + /* data toggle should be DATA1 */ + td = temp.td; + td->set_toggle = 1; + + if (need_sync) { + /* we need a SYNC point after TX */ + temp.func = &saf1761_device_data_tx_sync; + saf1761_otg_setup_standard_chain_sub(&temp); + } + } + } else { + if (need_sync) { + temp.pc = xfer->frbuffers + 0; + temp.len = 0; + temp.short_pkt = 0; + temp.setup_alt_next = 0; + + /* we need a SYNC point after TX */ + temp.func = &saf1761_device_data_tx_sync; + saf1761_otg_setup_standard_chain_sub(&temp); + } + } + + /* must have at least one frame! */ + td = temp.td; + xfer->td_transfer_last = td; + + if (is_host) { + /* get first again */ + td = xfer->td_transfer_first; + td->toggle = (xfer->endpoint->toggle_next ? 1 : 0); + } +} + +static void +saf1761_otg_timeout(void *arg) +{ + struct usb_xfer *xfer = arg; + + DPRINTF("xfer=%p\n", xfer); + + USB_BUS_LOCK_ASSERT(xfer->xroot->bus, MA_OWNED); + + /* transfer is transferred */ + saf1761_otg_device_done(xfer, USB_ERR_TIMEOUT); +} + +static void +saf1761_otg_intr_set(struct usb_xfer *xfer, uint8_t set) +{ + struct saf1761_otg_softc *sc = SAF1761_OTG_BUS2SC(xfer->xroot->bus); + uint8_t ep_no = (xfer->endpointno & UE_ADDR); + uint32_t mask; + + DPRINTFN(15, "endpoint=%d set=%d\n", xfer->endpointno, set); + + if (ep_no == 0) { + mask = SOTG_DCINTERRUPT_IEPRX(0) | + SOTG_DCINTERRUPT_IEPTX(0) | + SOTG_DCINTERRUPT_IEP0SETUP; + } else if (xfer->endpointno & UE_DIR_IN) { + mask = SOTG_DCINTERRUPT_IEPTX(ep_no); + } else { + mask = SOTG_DCINTERRUPT_IEPRX(ep_no); + } + + if (set) + sc->sc_intr_enable |= mask; + else + sc->sc_intr_enable &= ~mask; + + SAF1761_WRITE_4(sc, SOTG_DCINTERRUPT_EN, sc->sc_intr_enable); +} + +static void +saf1761_otg_start_standard_chain(struct usb_xfer *xfer) +{ + struct saf1761_otg_softc *sc = SAF1761_OTG_BUS2SC(xfer->xroot->bus); + + DPRINTFN(9, "\n"); + + /* poll one time */ + if (saf1761_otg_xfer_do_fifo(sc, xfer)) { + + /* + * Only enable the endpoint interrupt when we are + * actually waiting for data, hence we are dealing + * with level triggered interrupts ! + */ + saf1761_otg_intr_set(xfer, 1); + + /* put transfer on interrupt queue */ + usbd_transfer_enqueue(&xfer->xroot->bus->intr_q, xfer); + + /* start timeout, if any */ + if (xfer->timeout != 0) { + usbd_transfer_timeout_ms(xfer, + &saf1761_otg_timeout, xfer->timeout); + } + } +} + +static void +saf1761_otg_root_intr(struct saf1761_otg_softc *sc) +{ + DPRINTFN(9, "\n"); + + USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED); + + /* set port bit - we only have one port */ + sc->sc_hub_idata[0] = 0x02; + + uhub_root_intr(&sc->sc_bus, sc->sc_hub_idata, + sizeof(sc->sc_hub_idata)); +} + +static usb_error_t +saf1761_otg_standard_done_sub(struct usb_xfer *xfer) +{ + struct saf1761_otg_td *td; + uint32_t len; + usb_error_t error; + + DPRINTFN(9, "\n"); + + td = xfer->td_transfer_cache; + + do { + len = td->remainder; + + /* store last data toggle */ + xfer->endpoint->toggle_next = td->toggle; + + if (xfer->aframes != xfer->nframes) { + /* + * Verify the length and subtract + * the remainder from "frlengths[]": + */ + if (len > xfer->frlengths[xfer->aframes]) { + td->error_any = 1; + } else { + xfer->frlengths[xfer->aframes] -= len; + } + } + /* Check for transfer error */ + if (td->error_any) { + /* the transfer is finished */ + error = (td->error_stall ? + USB_ERR_STALLED : USB_ERR_IOERROR); + td = NULL; + break; + } + /* Check for short transfer */ + if (len > 0) { + if (xfer->flags_int.short_frames_ok) { + /* follow alt next */ + if (td->alt_next) { + td = td->obj_next; + } else { + td = NULL; + } + } else { + /* the transfer is finished */ + td = NULL; + } + error = 0; + break; + } + td = td->obj_next; + + /* this USB frame is complete */ + error = 0; + break; + + } while (0); + + /* update transfer cache */ + + xfer->td_transfer_cache = td; + + return (error); +} + +static void +saf1761_otg_standard_done(struct usb_xfer *xfer) +{ + usb_error_t err = 0; + + DPRINTFN(13, "xfer=%p endpoint=%p transfer done\n", + xfer, xfer->endpoint); + + /* reset scanner */ + + xfer->td_transfer_cache = xfer->td_transfer_first; + + if (xfer->flags_int.control_xfr) { + + if (xfer->flags_int.control_hdr) { + + err = saf1761_otg_standard_done_sub(xfer); + } + xfer->aframes = 1; + + if (xfer->td_transfer_cache == NULL) { + goto done; + } + } + while (xfer->aframes != xfer->nframes) { + + err = saf1761_otg_standard_done_sub(xfer); + xfer->aframes++; + + if (xfer->td_transfer_cache == NULL) { + goto done; + } + } + + if (xfer->flags_int.control_xfr && + !xfer->flags_int.control_act) { + + err = saf1761_otg_standard_done_sub(xfer); + } +done: + saf1761_otg_device_done(xfer, err); +} + +/*------------------------------------------------------------------------* + * saf1761_otg_device_done + * + * NOTE: this function can be called more than one time on the + * same USB transfer! + *------------------------------------------------------------------------*/ +static void +saf1761_otg_device_done(struct usb_xfer *xfer, usb_error_t error) +{ + struct saf1761_otg_softc *sc = SAF1761_OTG_BUS2SC(xfer->xroot->bus); + + USB_BUS_LOCK_ASSERT(xfer->xroot->bus, MA_OWNED); + + DPRINTFN(2, "xfer=%p, endpoint=%p, error=%d\n", + xfer, xfer->endpoint, error); + + if (xfer->flags_int.usb_mode == USB_MODE_DEVICE) { + saf1761_otg_intr_set(xfer, 0); + } else { + struct saf1761_otg_td *td; + + td = xfer->td_transfer_first; + + if (td != NULL) + saf1761_host_channel_free(sc, td); + } + + /* dequeue transfer and start next transfer */ + usbd_transfer_done(xfer, error); +} + +static void +saf1761_otg_xfer_stall(struct usb_xfer *xfer) +{ + saf1761_otg_device_done(xfer, USB_ERR_STALLED); +} + +static void +saf1761_otg_set_stall(struct usb_device *udev, + struct usb_endpoint *ep, uint8_t *did_stall) +{ + struct saf1761_otg_softc *sc; + uint8_t ep_no; + uint8_t ep_type; + uint8_t ep_dir; + + USB_BUS_LOCK_ASSERT(udev->bus, MA_OWNED); + + /* check mode */ + if (udev->flags.usb_mode != USB_MODE_DEVICE) { + /* not supported */ + return; + } + + DPRINTFN(5, "endpoint=%p\n", ep); + + /* set FORCESTALL */ + sc = SAF1761_OTG_BUS2SC(udev->bus); + ep_no = (ep->edesc->bEndpointAddress & UE_ADDR); + ep_dir = (ep->edesc->bEndpointAddress & (UE_DIR_IN | UE_DIR_OUT)); + ep_type = (ep->edesc->bmAttributes & UE_XFERTYPE); + + if (ep_type == UE_CONTROL) { + /* should not happen */ + return; + } + /* select the correct endpoint */ + SAF1761_WRITE_1(sc, SOTG_EP_INDEX, + (ep_no << SOTG_EP_INDEX_ENDP_INDEX_SHIFT) | + ((ep_dir == UE_DIR_IN) ? SOTG_EP_INDEX_DIR_IN : + SOTG_EP_INDEX_DIR_OUT)); + + /* set stall */ + SAF1761_WRITE_1(sc, SOTG_CTRL_FUNC, SOTG_CTRL_FUNC_STALL); +} + +static void +saf1761_otg_clear_stall_sub(struct saf1761_otg_softc *sc, + uint8_t ep_no, uint8_t ep_type, uint8_t ep_dir) +{ + if (ep_type == UE_CONTROL) { + /* clearing stall is not needed */ + return; + } + /* select the correct endpoint */ + SAF1761_WRITE_1(sc, SOTG_EP_INDEX, + (ep_no << SOTG_EP_INDEX_ENDP_INDEX_SHIFT) | + ((ep_dir == UE_DIR_IN) ? SOTG_EP_INDEX_DIR_IN : + SOTG_EP_INDEX_DIR_OUT)); + + /* disable endpoint */ + SAF1761_WRITE_2(sc, SOTG_EP_TYPE, 0); + /* enable endpoint again - will clear data toggle */ + SAF1761_WRITE_2(sc, SOTG_EP_TYPE, ep_type | SOTG_EP_TYPE_ENABLE); + + /* clear buffer */ + SAF1761_WRITE_1(sc, SOTG_CTRL_FUNC, SOTG_CTRL_FUNC_CLBUF); + /* clear stall */ + SAF1761_WRITE_1(sc, SOTG_CTRL_FUNC, 0); +} + +static void +saf1761_otg_clear_stall(struct usb_device *udev, struct usb_endpoint *ep) +{ + struct saf1761_otg_softc *sc; + struct usb_endpoint_descriptor *ed; + + USB_BUS_LOCK_ASSERT(udev->bus, MA_OWNED); + + DPRINTFN(5, "endpoint=%p\n", ep); + + /* check mode */ + if (udev->flags.usb_mode != USB_MODE_DEVICE) { + /* not supported */ + return; + } + /* get softc */ + sc = SAF1761_OTG_BUS2SC(udev->bus); + + /* get endpoint descriptor */ + ed = ep->edesc; + + /* reset endpoint */ + saf1761_otg_clear_stall_sub(sc, + (ed->bEndpointAddress & UE_ADDR), + (ed->bmAttributes & UE_XFERTYPE), + (ed->bEndpointAddress & (UE_DIR_IN | UE_DIR_OUT))); +} + +usb_error_t +saf1761_otg_init(struct saf1761_otg_softc *sc) +{ + const struct usb_hw_ep_profile *pf; + uint32_t x; + + DPRINTF("\n"); + + /* set up the bus structure */ + sc->sc_bus.usbrev = USB_REV_2_0; + sc->sc_bus.methods = &saf1761_otg_bus_methods; + + USB_BUS_LOCK(&sc->sc_bus); + + /* Enable interrupts */ + sc->sc_hw_mode |= SOTG_HW_MODE_CTRL_GLOBAL_INTR_EN | + SOTG_HW_MODE_CTRL_COMN_INT; + + /* + * Set correct hardware mode, must be written twice if bus + * width is changed: + */ + SAF1761_WRITE_2(sc, SOTG_HW_MODE_CTRL, sc->sc_hw_mode); + SAF1761_WRITE_4(sc, SOTG_HW_MODE_CTRL, sc->sc_hw_mode); + + DPRINTF("DCID=0x%08x\n", SAF1761_READ_4(sc, SOTG_DCCHIP_ID)); + + /* reset device controller */ + SAF1761_WRITE_2(sc, SOTG_MODE, SOTG_MODE_SFRESET); + SAF1761_WRITE_2(sc, SOTG_MODE, 0); + + /* wait a bit */ + DELAY(1000); + + /* reset host controller */ + SAF1761_WRITE_4(sc, SOTG_SW_RESET, SOTG_SW_RESET_HC); + SAF1761_WRITE_4(sc, SOTG_USBCMD, SOTG_USBCMD_HCRESET); + + /* wait a bit */ + DELAY(1000); + + SAF1761_WRITE_4(sc, SOTG_SW_RESET, 0); + SAF1761_WRITE_4(sc, SOTG_USBCMD, 0); + + /* wait a bit */ + DELAY(1000); + + /* do a pulldown */ + saf1761_otg_pull_down(sc); + + /* wait 10ms for pulldown to stabilise */ + usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 100); + + for (x = 1;; x++) { + + saf1761_otg_get_hw_ep_profile(NULL, &pf, x); + if (pf == NULL) + break; + + /* select the correct endpoint */ + SAF1761_WRITE_1(sc, SOTG_EP_INDEX, + (x << SOTG_EP_INDEX_ENDP_INDEX_SHIFT) | + SOTG_EP_INDEX_DIR_IN); + + /* select the maximum packet size */ + SAF1761_WRITE_2(sc, SOTG_EP_MAXPACKET, pf->max_in_frame_size); + + /* select the correct endpoint */ + SAF1761_WRITE_1(sc, SOTG_EP_INDEX, + (x << SOTG_EP_INDEX_ENDP_INDEX_SHIFT) | + SOTG_EP_INDEX_DIR_OUT); + + /* select the maximum packet size */ + SAF1761_WRITE_2(sc, SOTG_EP_MAXPACKET, pf->max_out_frame_size); + } + + /* enable interrupts */ + SAF1761_WRITE_2(sc, SOTG_MODE, SOTG_MODE_GLINTENA | + SOTG_MODE_CLKAON | SOTG_MODE_WKUPCS); + + /* set default values */ + SAF1761_WRITE_1(sc, SOTG_INTERRUPT_CFG, + SOTG_INTERRUPT_CFG_CDBGMOD | + SOTG_INTERRUPT_CFG_DDBGMODIN | + SOTG_INTERRUPT_CFG_DDBGMODOUT); + + /* enable VBUS and ID interrupt */ + SAF1761_WRITE_2(sc, SOTG_IRQ_ENABLE_CLR, 0xFFFF); + SAF1761_WRITE_2(sc, SOTG_IRQ_ENABLE_SET, + SOTG_IRQ_ID | SOTG_IRQ_VBUS_VLD); + + /* enable interrupts */ + sc->sc_intr_enable = SOTG_DCINTERRUPT_IEVBUS | + SOTG_DCINTERRUPT_IEBRST | SOTG_DCINTERRUPT_IESUSP; + SAF1761_WRITE_4(sc, SOTG_DCINTERRUPT_EN, sc->sc_intr_enable); + + /* connect ATX port 1 to device controller */ + SAF1761_WRITE_2(sc, SOTG_CTRL_CLR, 0xFFFF); + SAF1761_WRITE_2(sc, SOTG_CTRL_SET, SOTG_CTRL_SW_SEL_HC_DC | + SOTG_CTRL_BDIS_ACON_EN); + + /* disable device address */ + SAF1761_WRITE_1(sc, SOTG_ADDRESS, 0); + + /* enable host controller clock */ + SAF1761_WRITE_4(sc, SOTG_POWER_DOWN, SOTG_POWER_DOWN_HC_CLK_EN); + + /* wait 10ms for clock */ + usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 100); + + /* enable configuration flag */ + SAF1761_WRITE_4(sc, SOTG_CONFIGFLAG, SOTG_CONFIGFLAG_ENABLE); + + /* clear RAM block */ + for (x = 0x400; x != 0x10000; x += 4) + SAF1761_WRITE_4(sc, x, 0); + + /* start the HC */ + SAF1761_WRITE_4(sc, SOTG_USBCMD, SOTG_USBCMD_RS); + + /* poll initial VBUS status */ + saf1761_otg_update_vbus(sc); + + USB_BUS_UNLOCK(&sc->sc_bus); + + /* catch any lost interrupts */ + + saf1761_otg_do_poll(&sc->sc_bus); + + return (0); /* success */ +} + +void +saf1761_otg_uninit(struct saf1761_otg_softc *sc) +{ + USB_BUS_LOCK(&sc->sc_bus); + + /* disable all interrupts */ + SAF1761_WRITE_2(sc, SOTG_MODE, 0); + + sc->sc_flags.port_powered = 0; + sc->sc_flags.status_vbus = 0; + sc->sc_flags.status_bus_reset = 0; + sc->sc_flags.status_suspend = 0; + sc->sc_flags.change_suspend = 0; + sc->sc_flags.change_connect = 1; + + saf1761_otg_pull_down(sc); + USB_BUS_UNLOCK(&sc->sc_bus); +} + +static void +saf1761_otg_suspend(struct saf1761_otg_softc *sc) +{ + /* TODO */ +} + +static void +saf1761_otg_resume(struct saf1761_otg_softc *sc) +{ + /* TODO */ +} + +static void +saf1761_otg_do_poll(struct usb_bus *bus) +{ + struct saf1761_otg_softc *sc = SAF1761_OTG_BUS2SC(bus); + + USB_BUS_LOCK(&sc->sc_bus); + saf1761_otg_interrupt_poll(sc); + USB_BUS_UNLOCK(&sc->sc_bus); +} + +/*------------------------------------------------------------------------* + * saf1761_otg control support + * saf1761_otg interrupt support + * saf1761_otg bulk support + *------------------------------------------------------------------------*/ +static void +saf1761_otg_device_non_isoc_open(struct usb_xfer *xfer) +{ + return; +} + +static void +saf1761_otg_device_non_isoc_close(struct usb_xfer *xfer) +{ + saf1761_otg_device_done(xfer, USB_ERR_CANCELLED); +} + +static void +saf1761_otg_device_non_isoc_enter(struct usb_xfer *xfer) +{ + return; +} + +static void +saf1761_otg_device_non_isoc_start(struct usb_xfer *xfer) +{ + /* setup TDs */ + saf1761_otg_setup_standard_chain(xfer); + saf1761_otg_start_standard_chain(xfer); +} + +static const struct usb_pipe_methods saf1761_otg_non_isoc_methods = +{ + .open = saf1761_otg_device_non_isoc_open, + .close = saf1761_otg_device_non_isoc_close, + .enter = saf1761_otg_device_non_isoc_enter, + .start = saf1761_otg_device_non_isoc_start, +}; + +/*------------------------------------------------------------------------* + * saf1761_otg isochronous support + *------------------------------------------------------------------------*/ +static void +saf1761_otg_device_isoc_open(struct usb_xfer *xfer) +{ + return; +} + +static void +saf1761_otg_device_isoc_close(struct usb_xfer *xfer) +{ + saf1761_otg_device_done(xfer, USB_ERR_CANCELLED); +} + +static void +saf1761_otg_device_isoc_enter(struct usb_xfer *xfer) +{ + struct saf1761_otg_softc *sc = SAF1761_OTG_BUS2SC(xfer->xroot->bus); + uint32_t temp; + uint32_t nframes; + + DPRINTFN(6, "xfer=%p next=%d nframes=%d\n", + xfer, xfer->endpoint->isoc_next, xfer->nframes); + + /* get the current frame index - we don't need the high bits */ + + nframes = SAF1761_READ_2(sc, SOTG_FRAME_NUM); + + /* + * check if the frame index is within the window where the + * frames will be inserted + */ + temp = (nframes - xfer->endpoint->isoc_next) & SOTG_FRAME_NUM_SOFR_MASK; + + if ((xfer->endpoint->is_synced == 0) || + (temp < xfer->nframes)) { + /* + * If there is data underflow or the pipe queue is + * empty we schedule the transfer a few frames ahead + * of the current frame position. Else two isochronous + * transfers might overlap. + */ + xfer->endpoint->isoc_next = (nframes + 3) & SOTG_FRAME_NUM_SOFR_MASK; + xfer->endpoint->is_synced = 1; + DPRINTFN(3, "start next=%d\n", xfer->endpoint->isoc_next); + } + /* + * compute how many milliseconds the insertion is ahead of the + * current frame position: + */ + temp = (xfer->endpoint->isoc_next - nframes) & SOTG_FRAME_NUM_SOFR_MASK; + + /* + * pre-compute when the isochronous transfer will be finished: + */ + xfer->isoc_time_complete = + usb_isoc_time_expand(&sc->sc_bus, nframes) + temp + + xfer->nframes; + + /* compute frame number for next insertion */ + xfer->endpoint->isoc_next += xfer->nframes; + + /* setup TDs */ + saf1761_otg_setup_standard_chain(xfer); +} + +static void +saf1761_otg_device_isoc_start(struct usb_xfer *xfer) +{ + /* start TD chain */ + saf1761_otg_start_standard_chain(xfer); +} + +static const struct usb_pipe_methods saf1761_otg_device_isoc_methods = +{ + .open = saf1761_otg_device_isoc_open, + .close = saf1761_otg_device_isoc_close, + .enter = saf1761_otg_device_isoc_enter, + .start = saf1761_otg_device_isoc_start, +}; + +/*------------------------------------------------------------------------* + * saf1761_otg root control support + *------------------------------------------------------------------------* + * Simulate a hardware HUB by handling all the necessary requests. + *------------------------------------------------------------------------*/ + +static const struct usb_device_descriptor saf1761_otg_devd = { + .bLength = sizeof(struct usb_device_descriptor), + .bDescriptorType = UDESC_DEVICE, + .bcdUSB = {0x00, 0x02}, + .bDeviceClass = UDCLASS_HUB, + .bDeviceSubClass = UDSUBCLASS_HUB, + .bDeviceProtocol = UDPROTO_FSHUB, + .bMaxPacketSize = 64, + .bcdDevice = {0x00, 0x01}, + .iManufacturer = 1, + .iProduct = 2, + .bNumConfigurations = 1, +}; + +static const struct usb_device_qualifier saf1761_otg_odevd = { + .bLength = sizeof(struct usb_device_qualifier), + .bDescriptorType = UDESC_DEVICE_QUALIFIER, + .bcdUSB = {0x00, 0x02}, + .bDeviceClass = UDCLASS_HUB, + .bDeviceSubClass = UDSUBCLASS_HUB, + .bDeviceProtocol = UDPROTO_FSHUB, + .bMaxPacketSize0 = 0, + .bNumConfigurations = 0, +}; + +static const struct saf1761_otg_config_desc saf1761_otg_confd = { + .confd = { + .bLength = sizeof(struct usb_config_descriptor), + .bDescriptorType = UDESC_CONFIG, + .wTotalLength[0] = sizeof(saf1761_otg_confd), + .bNumInterface = 1, + .bConfigurationValue = 1, + .iConfiguration = 0, + .bmAttributes = UC_SELF_POWERED, + .bMaxPower = 0, + }, + .ifcd = { + .bLength = sizeof(struct usb_interface_descriptor), + .bDescriptorType = UDESC_INTERFACE, + .bNumEndpoints = 1, + .bInterfaceClass = UICLASS_HUB, + .bInterfaceSubClass = UISUBCLASS_HUB, + .bInterfaceProtocol = 0, + }, + + .endpd = { + .bLength = sizeof(struct usb_endpoint_descriptor), + .bDescriptorType = UDESC_ENDPOINT, + .bEndpointAddress = (UE_DIR_IN | SAF1761_OTG_INTR_ENDPT), + .bmAttributes = UE_INTERRUPT, + .wMaxPacketSize[0] = 8, + .bInterval = 255, + }, +}; + +#define HSETW(ptr, val) ptr = { (uint8_t)(val), (uint8_t)((val) >> 8) } + +static const struct usb_hub_descriptor_min saf1761_otg_hubd = { + .bDescLength = sizeof(saf1761_otg_hubd), + .bDescriptorType = UDESC_HUB, + .bNbrPorts = SOTG_NUM_PORTS, + HSETW(.wHubCharacteristics, (UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL)), + .bPwrOn2PwrGood = 50, + .bHubContrCurrent = 0, + .DeviceRemovable = {0}, /* port is removable */ +}; + +#define STRING_VENDOR \ + "N\0X\0P" + +#define STRING_PRODUCT \ + "D\0C\0I\0 \0R\0o\0o\0t\0 \0H\0U\0B" + +USB_MAKE_STRING_DESC(STRING_VENDOR, saf1761_otg_vendor); +USB_MAKE_STRING_DESC(STRING_PRODUCT, saf1761_otg_product); + +static usb_error_t +saf1761_otg_roothub_exec(struct usb_device *udev, + struct usb_device_request *req, const void **pptr, uint16_t *plength) +{ + struct saf1761_otg_softc *sc = SAF1761_OTG_BUS2SC(udev->bus); + const void *ptr; + uint16_t len; + uint16_t value; + uint16_t index; + uint32_t temp; + uint32_t i; + usb_error_t err; + + USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED); + + /* buffer reset */ + ptr = (const void *)&sc->sc_hub_temp; + len = 0; + err = 0; + + value = UGETW(req->wValue); + index = UGETW(req->wIndex); + + /* demultiplex the control request */ + + switch (req->bmRequestType) { + case UT_READ_DEVICE: + switch (req->bRequest) { + case UR_GET_DESCRIPTOR: + goto tr_handle_get_descriptor; + case UR_GET_CONFIG: + goto tr_handle_get_config; + case UR_GET_STATUS: + goto tr_handle_get_status; + default: + goto tr_stalled; + } + break; + + case UT_WRITE_DEVICE: + switch (req->bRequest) { + case UR_SET_ADDRESS: + goto tr_handle_set_address; + case UR_SET_CONFIG: + goto tr_handle_set_config; + case UR_CLEAR_FEATURE: + goto tr_valid; /* nop */ + case UR_SET_DESCRIPTOR: + goto tr_valid; /* nop */ + case UR_SET_FEATURE: + default: + goto tr_stalled; + } + break; + + case UT_WRITE_ENDPOINT: + switch (req->bRequest) { + case UR_CLEAR_FEATURE: + switch (UGETW(req->wValue)) { + case UF_ENDPOINT_HALT: + goto tr_handle_clear_halt; + case UF_DEVICE_REMOTE_WAKEUP: + goto tr_handle_clear_wakeup; + default: + goto tr_stalled; + } + break; + case UR_SET_FEATURE: + switch (UGETW(req->wValue)) { + case UF_ENDPOINT_HALT: + goto tr_handle_set_halt; + case UF_DEVICE_REMOTE_WAKEUP: + goto tr_handle_set_wakeup; + default: + goto tr_stalled; + } + break; + case UR_SYNCH_FRAME: + goto tr_valid; /* nop */ + default: + goto tr_stalled; + } + break; + + case UT_READ_ENDPOINT: + switch (req->bRequest) { + case UR_GET_STATUS: + goto tr_handle_get_ep_status; + default: + goto tr_stalled; + } + break; + + case UT_WRITE_INTERFACE: + switch (req->bRequest) { + case UR_SET_INTERFACE: + goto tr_handle_set_interface; + case UR_CLEAR_FEATURE: + goto tr_valid; /* nop */ + case UR_SET_FEATURE: + default: + goto tr_stalled; + } + break; + + case UT_READ_INTERFACE: + switch (req->bRequest) { + case UR_GET_INTERFACE: + goto tr_handle_get_interface; + case UR_GET_STATUS: + goto tr_handle_get_iface_status; + default: + goto tr_stalled; + } + break; + + case UT_WRITE_CLASS_INTERFACE: + case UT_WRITE_VENDOR_INTERFACE: + /* XXX forward */ + break; + + case UT_READ_CLASS_INTERFACE: + case UT_READ_VENDOR_INTERFACE: + /* XXX forward */ + break; + + case UT_WRITE_CLASS_DEVICE: + switch (req->bRequest) { + case UR_CLEAR_FEATURE: + goto tr_valid; + case UR_SET_DESCRIPTOR: + case UR_SET_FEATURE: + break; + default: + goto tr_stalled; + } + break; + + case UT_WRITE_CLASS_OTHER: + switch (req->bRequest) { + case UR_CLEAR_FEATURE: + if (index == SOTG_HOST_PORT_NUM) + goto tr_handle_clear_port_feature_host; + else if (index == SOTG_DEVICE_PORT_NUM) + goto tr_handle_clear_port_feature_device; + else + goto tr_stalled; + case UR_SET_FEATURE: + if (index == SOTG_HOST_PORT_NUM) + goto tr_handle_set_port_feature_host; + else if (index == SOTG_DEVICE_PORT_NUM) + goto tr_handle_set_port_feature_device; + else + goto tr_stalled; + case UR_CLEAR_TT_BUFFER: + case UR_RESET_TT: + case UR_STOP_TT: + goto tr_valid; + + default: + goto tr_stalled; + } + break; + + case UT_READ_CLASS_OTHER: + switch (req->bRequest) { + case UR_GET_TT_STATE: + goto tr_handle_get_tt_state; + case UR_GET_STATUS: + if (index == SOTG_HOST_PORT_NUM) + goto tr_handle_get_port_status_host; + else if (index == SOTG_DEVICE_PORT_NUM) + goto tr_handle_get_port_status_device; + else + goto tr_stalled; + default: + goto tr_stalled; + } + break; + + case UT_READ_CLASS_DEVICE: + switch (req->bRequest) { + case UR_GET_DESCRIPTOR: + goto tr_handle_get_class_descriptor; + case UR_GET_STATUS: + goto tr_handle_get_class_status; + + default: + goto tr_stalled; + } + break; + default: + goto tr_stalled; + } + goto tr_valid; + +tr_handle_get_descriptor: + switch (value >> 8) { + case UDESC_DEVICE: + if (value & 0xff) + goto tr_stalled; + len = sizeof(saf1761_otg_devd); + ptr = (const void *)&saf1761_otg_devd; + goto tr_valid; + case UDESC_DEVICE_QUALIFIER: + if (value & 0xff) + goto tr_stalled; + len = sizeof(saf1761_otg_odevd); + ptr = (const void *)&saf1761_otg_odevd; + goto tr_valid; + case UDESC_CONFIG: + if (value & 0xff) + goto tr_stalled; + len = sizeof(saf1761_otg_confd); + ptr = (const void *)&saf1761_otg_confd; + goto tr_valid; + case UDESC_STRING: + switch (value & 0xff) { + case 0: /* Language table */ + len = sizeof(usb_string_lang_en); + ptr = (const void *)&usb_string_lang_en; + goto tr_valid; + + case 1: /* Vendor */ + len = sizeof(saf1761_otg_vendor); + ptr = (const void *)&saf1761_otg_vendor; + goto tr_valid; + + case 2: /* Product */ + len = sizeof(saf1761_otg_product); + ptr = (const void *)&saf1761_otg_product; + goto tr_valid; + default: + break; + } + break; + default: + goto tr_stalled; + } + goto tr_stalled; + +tr_handle_get_config: + len = 1; + sc->sc_hub_temp.wValue[0] = sc->sc_conf; + goto tr_valid; + +tr_handle_get_status: + len = 2; + USETW(sc->sc_hub_temp.wValue, UDS_SELF_POWERED); + goto tr_valid; + +tr_handle_set_address: + if (value & 0xFF00) + goto tr_stalled; + + sc->sc_rt_addr = value; + goto tr_valid; + +tr_handle_set_config: + if (value >= 2) + goto tr_stalled; + sc->sc_conf = value; + goto tr_valid; + +tr_handle_get_interface: + len = 1; + sc->sc_hub_temp.wValue[0] = 0; + goto tr_valid; + +tr_handle_get_tt_state: +tr_handle_get_class_status: +tr_handle_get_iface_status: +tr_handle_get_ep_status: + len = 2; + USETW(sc->sc_hub_temp.wValue, 0); + goto tr_valid; + +tr_handle_set_halt: +tr_handle_set_interface: +tr_handle_set_wakeup: +tr_handle_clear_wakeup: +tr_handle_clear_halt: + goto tr_valid; + +tr_handle_clear_port_feature_device: + DPRINTFN(9, "UR_CLEAR_FEATURE on port %d\n", index); + + switch (value) { + case UHF_PORT_SUSPEND: + saf1761_otg_wakeup_peer(sc); + break; + + case UHF_PORT_ENABLE: + sc->sc_flags.port_enabled = 0; + break; + + case UHF_PORT_TEST: + case UHF_PORT_INDICATOR: + case UHF_C_PORT_ENABLE: + case UHF_C_PORT_OVER_CURRENT: + case UHF_C_PORT_RESET: + /* nops */ + break; + case UHF_PORT_POWER: + sc->sc_flags.port_powered = 0; + saf1761_otg_pull_down(sc); + break; + case UHF_C_PORT_CONNECTION: + sc->sc_flags.change_connect = 0; + break; + case UHF_C_PORT_SUSPEND: + sc->sc_flags.change_suspend = 0; + break; + default: + err = USB_ERR_IOERROR; + goto tr_valid; + } + goto tr_valid; + +tr_handle_clear_port_feature_host: + DPRINTFN(9, "UR_CLEAR_FEATURE on port %d\n", index); + + temp = SAF1761_READ_4(sc, SOTG_PORTSC1); + + switch (value) { + case UHF_PORT_ENABLE: + SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp & ~SOTG_PORTSC1_PED); + break; + case UHF_PORT_SUSPEND: + if ((temp & SOTG_PORTSC1_SUSP) && (!(temp & SOTG_PORTSC1_FPR))) + SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp | SOTG_PORTSC1_FPR); + + /* wait 20ms for resume sequence to complete */ + usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 50); + + SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp & ~(SOTG_PORTSC1_SUSP | + SOTG_PORTSC1_FPR | SOTG_PORTSC1_LS /* High Speed */ )); + + /* 4ms settle time */ + usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 250); + break; + case UHF_PORT_INDICATOR: + SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp & ~SOTG_PORTSC1_PIC); + break; + case UHF_PORT_TEST: + case UHF_C_PORT_ENABLE: + case UHF_C_PORT_OVER_CURRENT: + case UHF_C_PORT_RESET: + case UHF_C_PORT_SUSPEND: + /* NOPs */ + break; + case UHF_PORT_POWER: + SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp & ~SOTG_PORTSC1_PP); + break; + case UHF_C_PORT_CONNECTION: + SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp & ~SOTG_PORTSC1_ECSC); + break; + default: + err = USB_ERR_IOERROR; + goto tr_valid; + } + goto tr_valid; + +tr_handle_set_port_feature_device: + DPRINTFN(9, "UR_SET_FEATURE on port %d\n", index); + + switch (value) { + case UHF_PORT_ENABLE: + sc->sc_flags.port_enabled = 1; + break; + case UHF_PORT_SUSPEND: + case UHF_PORT_RESET: + case UHF_PORT_TEST: + case UHF_PORT_INDICATOR: + /* nops */ + break; + case UHF_PORT_POWER: + sc->sc_flags.port_powered = 1; + break; + default: + err = USB_ERR_IOERROR; + goto tr_valid; + } + goto tr_valid; + +tr_handle_set_port_feature_host: + DPRINTFN(9, "UR_SET_FEATURE on port %d\n", index); + + temp = SAF1761_READ_4(sc, SOTG_PORTSC1); + + switch (value) { + case UHF_PORT_ENABLE: + SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp | SOTG_PORTSC1_PED); + break; + case UHF_PORT_SUSPEND: + SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp | SOTG_PORTSC1_SUSP); + break; + case UHF_PORT_RESET: + DPRINTFN(6, "reset port %d\n", index); + + /* Start reset sequence. */ + temp &= ~(SOTG_PORTSC1_PED | SOTG_PORTSC1_PR); + + SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp | SOTG_PORTSC1_PR); + + /* Wait for reset to complete. */ + usb_pause_mtx(&sc->sc_bus.bus_mtx, + USB_MS_TO_TICKS(usb_port_root_reset_delay)); + + SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp); + + /* Wait for HC to complete reset. */ + usb_pause_mtx(&sc->sc_bus.bus_mtx, USB_MS_TO_TICKS(2)); + + temp = SAF1761_READ_4(sc, SOTG_PORTSC1); + + DPRINTF("After reset, status=0x%08x\n", temp); + if (temp & SOTG_PORTSC1_PR) { + device_printf(sc->sc_bus.bdev, "port reset timeout\n"); + err = USB_ERR_TIMEOUT; + goto tr_valid; + } + if (!(temp & SOTG_PORTSC1_PED)) { + /* Not a high speed device, give up ownership.*/ + SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp | SOTG_PORTSC1_PO); + break; + } + sc->sc_isreset = 1; + DPRINTF("port %d reset, status = 0x%08x\n", index, temp); + break; + case UHF_PORT_POWER: + DPRINTFN(3, "set port power %d\n", index); + SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp | SOTG_PORTSC1_PP); + break; + + case UHF_PORT_TEST: + DPRINTFN(3, "set port test %d\n", index); + break; + + case UHF_PORT_INDICATOR: + DPRINTFN(3, "set port ind %d\n", index); + SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp | SOTG_PORTSC1_PIC); + break; + default: + err = USB_ERR_IOERROR; + goto tr_valid; + } + goto tr_valid; + +tr_handle_get_port_status_device: + + DPRINTFN(9, "UR_GET_PORT_STATUS on port %d\n", index); + + if (sc->sc_flags.status_vbus) { + saf1761_otg_pull_up(sc); + } else { + saf1761_otg_pull_down(sc); + } + + /* Select FULL-speed and Device Side Mode */ + + value = UPS_PORT_MODE_DEVICE; + + if (sc->sc_flags.port_powered) + value |= UPS_PORT_POWER; + + if (sc->sc_flags.port_enabled) + value |= UPS_PORT_ENABLED; + + if (sc->sc_flags.status_vbus && + sc->sc_flags.status_bus_reset) + value |= UPS_CURRENT_CONNECT_STATUS; + + if (sc->sc_flags.status_suspend) + value |= UPS_SUSPEND; + + USETW(sc->sc_hub_temp.ps.wPortStatus, value); + + value = 0; + + if (sc->sc_flags.change_connect) + value |= UPS_C_CONNECT_STATUS; + + if (sc->sc_flags.change_suspend) + value |= UPS_C_SUSPEND; + + USETW(sc->sc_hub_temp.ps.wPortChange, value); + len = sizeof(sc->sc_hub_temp.ps); + goto tr_valid; + +tr_handle_get_port_status_host: + + temp = SAF1761_READ_4(sc, SOTG_PORTSC1); + + DPRINTFN(9, "port status=0x%04x\n", temp); + i = UPS_HIGH_SPEED; + + if (temp & SOTG_PORTSC1_ECCS) + i |= UPS_CURRENT_CONNECT_STATUS; + if (temp & SOTG_PORTSC1_PED) + i |= UPS_PORT_ENABLED; + if ((temp & SOTG_PORTSC1_SUSP) && !(temp & SOTG_PORTSC1_FPR)) + i |= UPS_SUSPEND; + if (temp & SOTG_PORTSC1_PR) + i |= UPS_RESET; + if (temp & SOTG_PORTSC1_PP) + i |= UPS_PORT_POWER; + + USETW(sc->sc_hub_temp.ps.wPortStatus, i); + i = 0; + + if (temp & SOTG_PORTSC1_ECSC) + i |= UPS_C_CONNECT_STATUS; + if (temp & SOTG_PORTSC1_FPR) + i |= UPS_C_SUSPEND; + if (sc->sc_isreset) + i |= UPS_C_PORT_RESET; + USETW(sc->sc_hub_temp.ps.wPortChange, i); + len = sizeof(sc->sc_hub_temp.ps); + goto tr_valid; + +tr_handle_get_class_descriptor: + if (value & 0xFF) + goto tr_stalled; + ptr = (const void *)&saf1761_otg_hubd; + len = sizeof(saf1761_otg_hubd); + goto tr_valid; + +tr_stalled: + err = USB_ERR_STALLED; +tr_valid: + *plength = len; + *pptr = ptr; + return (err); +} + +static void +saf1761_otg_xfer_setup(struct usb_setup_params *parm) +{ + struct saf1761_otg_softc *sc; + struct usb_xfer *xfer; + void *last_obj; + uint32_t dw1; + uint32_t ntd; + uint32_t n; + uint8_t ep_no; + uint8_t ep_type; + + sc = SAF1761_OTG_BUS2SC(parm->udev->bus); + xfer = parm->curr_xfer; + + /* + * NOTE: This driver does not use any of the parameters that + * are computed from the following values. Just set some + * reasonable dummies: + */ + parm->hc_max_packet_size = 0x500; + parm->hc_max_packet_count = 1; + parm->hc_max_frame_size = 0x500; + + usbd_transfer_setup_sub(parm); + + /* + * Compute maximum number of TDs: + */ + ep_type = (xfer->endpoint->edesc->bmAttributes & UE_XFERTYPE); + + if (ep_type == UE_CONTROL) { + + ntd = xfer->nframes + 1 /* STATUS */ + 1 /* SYNC */ ; + + } else { + ntd = xfer->nframes + 1 /* SYNC */ ; + } + + /* + * check if "usbd_transfer_setup_sub" set an error + */ + if (parm->err) + return; + + /* + * allocate transfer descriptors + */ + last_obj = NULL; + + ep_no = xfer->endpointno & UE_ADDR; + + /* + * Check profile stuff + */ + if (parm->udev->flags.usb_mode == USB_MODE_DEVICE) { + const struct usb_hw_ep_profile *pf; + + saf1761_otg_get_hw_ep_profile(parm->udev, &pf, ep_no); + + if (pf == NULL) { + /* should not happen */ + parm->err = USB_ERR_INVAL; + return; + } + } + + dw1 = (xfer->address << 3) | (ep_type << 12); + + switch (parm->udev->speed) { + case USB_SPEED_FULL: + case USB_SPEED_LOW: + /* check if root HUB port is running High Speed */ + if (parm->udev->parent_hs_hub != NULL) { + dw1 |= (1 << 14); + dw1 |= (parm->udev->hs_port_no << 18); + dw1 |= (parm->udev->hs_hub_addr << 25); + if (parm->udev->speed == USB_SPEED_LOW) + dw1 |= (1 << 17); + } + break; + default: + break; + } + + /* align data */ + parm->size[0] += ((-parm->size[0]) & (USB_HOST_ALIGN - 1)); + + for (n = 0; n != ntd; n++) { + + struct saf1761_otg_td *td; + + if (parm->buf) { + + td = USB_ADD_BYTES(parm->buf, parm->size[0]); + + /* init TD */ + td->max_packet_size = xfer->max_packet_size; + td->ep_index = ep_no; + td->ep_type = ep_type; + td->dw1_value = dw1; + + td->obj_next = last_obj; + + last_obj = td; + } + parm->size[0] += sizeof(*td); + } + + xfer->td_start[0] = last_obj; +} + +static void +saf1761_otg_xfer_unsetup(struct usb_xfer *xfer) +{ +} + +static void +saf1761_otg_ep_init(struct usb_device *udev, struct usb_endpoint_descriptor *edesc, + struct usb_endpoint *ep) +{ + struct saf1761_otg_softc *sc = SAF1761_OTG_BUS2SC(udev->bus); + + DPRINTFN(2, "endpoint=%p, addr=%d, endpt=%d, mode=%d (%d)\n", + ep, udev->address, + edesc->bEndpointAddress, udev->flags.usb_mode, + sc->sc_rt_addr); + + if (udev->parent_hub == NULL) { + /* root HUB has special endpoint handling */ + return; + } + + if (udev->flags.usb_mode == USB_MODE_DEVICE) { + if (udev->speed != USB_SPEED_FULL && + udev->speed != USB_SPEED_HIGH) { + /* not supported */ + return; + } + switch (edesc->bmAttributes & UE_XFERTYPE) { + case UE_ISOCHRONOUS: + ep->methods = &saf1761_otg_device_isoc_methods; + break; + default: + ep->methods = &saf1761_otg_non_isoc_methods; + break; + } + } else { + switch (edesc->bmAttributes & UE_XFERTYPE) { + case UE_CONTROL: + case UE_BULK: + ep->methods = &saf1761_otg_non_isoc_methods; + break; + default: + /* TODO */ + break; + } + } +} + +static void +saf1761_otg_set_hw_power_sleep(struct usb_bus *bus, uint32_t state) +{ + struct saf1761_otg_softc *sc = SAF1761_OTG_BUS2SC(bus); + + switch (state) { + case USB_HW_POWER_SUSPEND: + saf1761_otg_suspend(sc); + break; + case USB_HW_POWER_SHUTDOWN: + saf1761_otg_uninit(sc); + break; + case USB_HW_POWER_RESUME: + saf1761_otg_resume(sc); + break; + default: + break; + } +} + +static const struct usb_bus_methods saf1761_otg_bus_methods = +{ + .endpoint_init = &saf1761_otg_ep_init, + .xfer_setup = &saf1761_otg_xfer_setup, + .xfer_unsetup = &saf1761_otg_xfer_unsetup, + .get_hw_ep_profile = &saf1761_otg_get_hw_ep_profile, + .xfer_stall = &saf1761_otg_xfer_stall, + .set_stall = &saf1761_otg_set_stall, + .clear_stall = &saf1761_otg_clear_stall, + .roothub_exec = &saf1761_otg_roothub_exec, + .xfer_poll = &saf1761_otg_do_poll, + .set_hw_power_sleep = saf1761_otg_set_hw_power_sleep, +}; diff --git a/sys/dev/usb/controller/saf1761_otg.h b/sys/dev/usb/controller/saf1761_otg.h new file mode 100644 index 0000000000000..55c454274cf1d --- /dev/null +++ b/sys/dev/usb/controller/saf1761_otg.h @@ -0,0 +1,157 @@ +/* $FreeBSD$ */ +/*- + * Copyright (c) 2014 Hans Petter Selasky + * All rights reserved. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _SAF1761_OTG_H_ +#define _SAF1761_OTG_H_ + +#define SOTG_MAX_DEVICES (USB_MIN_DEVICES + 1) +#define SOTG_FS_MAX_PACKET_SIZE 64 +#define SOTG_HS_MAX_PACKET_SIZE 512 +#define SOTG_NUM_PORTS 2 /* one Device and one Host port */ +#define SOTG_HOST_PORT_NUM 1 +#define SOTG_DEVICE_PORT_NUM 2 +#define SOTG_HOST_CHANNEL_MAX (3 * 32) + +#define SAF1761_READ_1(sc, reg) \ + bus_space_read_1((sc)->sc_io_tag, (sc)->sc_io_hdl, reg) +#define SAF1761_READ_2(sc, reg) \ + bus_space_read_2((sc)->sc_io_tag, (sc)->sc_io_hdl, reg) +#define SAF1761_READ_4(sc, reg) \ + bus_space_read_4((sc)->sc_io_tag, (sc)->sc_io_hdl, reg) + +#define SAF1761_WRITE_1(sc, reg, data) \ + bus_space_write_1((sc)->sc_io_tag, (sc)->sc_io_hdl, reg, data) +#define SAF1761_WRITE_2(sc, reg, data) \ + bus_space_write_2((sc)->sc_io_tag, (sc)->sc_io_hdl, reg, data) +#define SAF1761_WRITE_4(sc, reg, data) \ + bus_space_write_4((sc)->sc_io_tag, (sc)->sc_io_hdl, reg, data) + +struct saf1761_otg_softc; +struct saf1761_otg_td; + +typedef uint8_t (saf1761_otg_cmd_t)(struct saf1761_otg_softc *, struct saf1761_otg_td *td); + +struct saf1761_otg_td { + struct saf1761_otg_td *obj_next; + saf1761_otg_cmd_t *func; + struct usb_page_cache *pc; + uint32_t offset; + uint32_t remainder; + uint32_t dw1_value; + uint16_t max_packet_size; + uint8_t ep_index; + uint8_t ep_type; + uint8_t channel; + uint8_t error_any:1; + uint8_t error_stall:1; + uint8_t alt_next:1; + uint8_t short_pkt:1; + uint8_t did_stall:1; + uint8_t toggle:1; + uint8_t set_toggle:1; +}; + +struct saf1761_otg_std_temp { + saf1761_otg_cmd_t *func; + struct usb_page_cache *pc; + struct saf1761_otg_td *td; + struct saf1761_otg_td *td_next; + uint32_t len; + uint32_t offset; + uint16_t max_frame_size; + uint8_t short_pkt; + /* + * short_pkt = 0: transfer should be short terminated + * short_pkt = 1: transfer should not be short terminated + */ + uint8_t setup_alt_next; + uint8_t did_stall; +}; + +struct saf1761_otg_config_desc { + struct usb_config_descriptor confd; + struct usb_interface_descriptor ifcd; + struct usb_endpoint_descriptor endpd; +} __packed; + +union saf1761_otg_hub_temp { + uWord wValue; + struct usb_port_status ps; +}; + +struct saf1761_otg_flags { + uint8_t change_connect:1; + uint8_t change_suspend:1; + uint8_t status_suspend:1; /* set if suspended */ + uint8_t status_vbus:1; /* set if present */ + uint8_t status_bus_reset:1; /* set if reset complete */ + uint8_t clocks_off:1; + uint8_t port_powered:1; + uint8_t port_enabled:1; + uint8_t d_pulled_up:1; +}; + +struct saf1761_otg_softc { + struct usb_bus sc_bus; + union saf1761_otg_hub_temp sc_hub_temp; + + struct usb_device *sc_devices[SOTG_MAX_DEVICES]; + struct resource *sc_io_res; + struct resource *sc_irq_res; + void *sc_intr_hdl; + bus_size_t sc_io_size; + bus_space_tag_t sc_io_tag; + bus_space_handle_t sc_io_hdl; + + uint32_t sc_host_async_map; + uint32_t sc_host_intr_map; + uint32_t sc_host_isoc_map; + uint32_t sc_intr_enable; /* enabled interrupts */ + uint32_t sc_hw_mode; /* hardware mode */ + + uint8_t sc_bounce_buffer[1024] __aligned(4); + uint8_t sc_rt_addr; /* root HUB address */ + uint8_t sc_dv_addr; /* device address */ + uint8_t sc_conf; /* root HUB config */ + uint8_t sc_isreset; /* host mode */ + + uint8_t sc_hub_idata[1]; + + struct saf1761_otg_flags sc_flags; +}; + +/* prototypes */ + +usb_error_t saf1761_otg_init(struct saf1761_otg_softc *sc); +void saf1761_otg_uninit(struct saf1761_otg_softc *sc); +void saf1761_otg_interrupt(struct saf1761_otg_softc *sc); + +#endif /* _SAF1761_OTG_H_ */ diff --git a/sys/dev/usb/controller/saf1761_otg_fdt.c b/sys/dev/usb/controller/saf1761_otg_fdt.c new file mode 100644 index 0000000000000..b0119d9342112 --- /dev/null +++ b/sys/dev/usb/controller/saf1761_otg_fdt.c @@ -0,0 +1,253 @@ +/* $FreeBSD$ */ +/*- + * Copyright (c) 2014 Hans Petter Selasky + * All rights reserved. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef USB_GLOBAL_INCLUDE_FILE +#include USB_GLOBAL_INCLUDE_FILE +#else +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#endif /* USB_GLOBAL_INCLUDE_FILE */ + +#include +#include + +static device_probe_t saf1761_otg_fdt_probe; +static device_attach_t saf1761_otg_fdt_attach; +static device_detach_t saf1761_otg_fdt_detach; + +static device_method_t saf1761_otg_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, saf1761_otg_fdt_probe), + DEVMETHOD(device_attach, saf1761_otg_fdt_attach), + DEVMETHOD(device_detach, saf1761_otg_fdt_detach), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + + DEVMETHOD_END +}; + +static driver_t saf1761_otg_driver = { + .name = "saf1761", + .methods = saf1761_otg_methods, + .size = sizeof(struct saf1761_otg_softc), +}; + +static devclass_t saf1761_otg_devclass; + +DRIVER_MODULE(saf1761, simplebus, saf1761_otg_driver, saf1761_otg_devclass, 0, 0); +MODULE_DEPEND(saf1761, usb, 1, 1, 1); + +static int +saf1761_otg_fdt_probe(device_t dev) +{ + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + + if (!ofw_bus_is_compatible(dev, "nxp,usb-isp1761")) + return (ENXIO); + + device_set_desc(dev, "ISP1761/SAF1761 DCI USB 2.0 Device Controller"); + + return (0); +} + +static int +saf1761_otg_fdt_attach(device_t dev) +{ + struct saf1761_otg_softc *sc = device_get_softc(dev); + char param[24]; + int err; + int rid; + + /* get configuration from FDT */ + + /* get bus-width, if any */ + if (OF_getprop(ofw_bus_get_node(dev), "bus-width", + ¶m, sizeof(param)) > 0) { + param[sizeof(param) - 1] = 0; + if (strcmp(param, "32") == 0) + sc->sc_hw_mode |= SOTG_HW_MODE_CTRL_DATA_BUS_WIDTH; + } else { + /* assume 32-bit data bus */ + sc->sc_hw_mode |= SOTG_HW_MODE_CTRL_DATA_BUS_WIDTH; + } + + /* get analog over-current setting */ + if (OF_getprop(ofw_bus_get_node(dev), "analog-oc", + ¶m, sizeof(param)) > 0) { + sc->sc_hw_mode |= SOTG_HW_MODE_CTRL_ANA_DIGI_OC; + } + + /* get DACK polarity */ + if (OF_getprop(ofw_bus_get_node(dev), "dack-polarity", + ¶m, sizeof(param)) > 0) { + sc->sc_hw_mode |= SOTG_HW_MODE_CTRL_DACK_POL; + } + + /* get DREQ polarity */ + if (OF_getprop(ofw_bus_get_node(dev), "dreq-polarity", + ¶m, sizeof(param)) > 0) { + sc->sc_hw_mode |= SOTG_HW_MODE_CTRL_DREQ_POL; + } + + /* initialise some bus fields */ + sc->sc_bus.parent = dev; + sc->sc_bus.devices = sc->sc_devices; + sc->sc_bus.devices_max = SOTG_MAX_DEVICES; + + /* get all DMA memory */ + if (usb_bus_mem_alloc_all(&sc->sc_bus, + USB_GET_DMA_TAG(dev), NULL)) { + return (ENOMEM); + } + rid = 0; + sc->sc_io_res = + bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, RF_ACTIVE); + + if (!sc->sc_io_res) { + goto error; + } + sc->sc_io_tag = rman_get_bustag(sc->sc_io_res); + sc->sc_io_hdl = rman_get_bushandle(sc->sc_io_res); + sc->sc_io_size = rman_get_size(sc->sc_io_res); + + rid = 0; + sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, + RF_SHAREABLE | RF_ACTIVE); + if (sc->sc_irq_res == NULL) { + goto error; + } + sc->sc_bus.bdev = device_add_child(dev, "usbus", -1); + if (!(sc->sc_bus.bdev)) { + goto error; + } + device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus); + + err = bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE, + NULL, (driver_intr_t *)saf1761_otg_interrupt, sc, &sc->sc_intr_hdl); + if (err) { + sc->sc_intr_hdl = NULL; + goto error; + } + err = saf1761_otg_init(sc); + if (err) { + device_printf(dev, "Init failed\n"); + goto error; + } + err = device_probe_and_attach(sc->sc_bus.bdev); + if (err) { + device_printf(dev, "USB probe and attach failed\n"); + goto error; + } + return (0); + +error: + saf1761_otg_fdt_detach(dev); + return (ENXIO); +} + +static int +saf1761_otg_fdt_detach(device_t dev) +{ + struct saf1761_otg_softc *sc = device_get_softc(dev); + device_t bdev; + int err; + + if (sc->sc_bus.bdev) { + bdev = sc->sc_bus.bdev; + device_detach(bdev); + device_delete_child(dev, bdev); + } + /* during module unload there are lots of children leftover */ + device_delete_children(dev); + + if (sc->sc_irq_res && sc->sc_intr_hdl) { + /* + * Only call uninit() after init() + */ + saf1761_otg_uninit(sc); + + err = bus_teardown_intr(dev, sc->sc_irq_res, + sc->sc_intr_hdl); + sc->sc_intr_hdl = NULL; + } + if (sc->sc_irq_res) { + bus_release_resource(dev, SYS_RES_IRQ, 0, + sc->sc_irq_res); + sc->sc_irq_res = NULL; + } + if (sc->sc_io_res) { + bus_release_resource(dev, SYS_RES_IOPORT, 0, + sc->sc_io_res); + sc->sc_io_res = NULL; + } + usb_bus_mem_free_all(&sc->sc_bus, NULL); + + return (0); +} diff --git a/sys/dev/usb/controller/saf1761_otg_reg.h b/sys/dev/usb/controller/saf1761_otg_reg.h new file mode 100644 index 0000000000000..2b74866b919cf --- /dev/null +++ b/sys/dev/usb/controller/saf1761_otg_reg.h @@ -0,0 +1,214 @@ +/* $FreeBSD$ */ +/*- + * Copyright (c) 2014 Hans Petter Selasky + * All rights reserved. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _SAF1761_OTG_REG_H_ +#define _SAF1761_OTG_REG_H_ + +/* Global registers */ + +#define SOTG_VEND_ID 0x370 +#define SOTG_PROD_ID 0x372 +#define SOTG_CTRL_SET 0x374 +#define SOTG_CTRL_CLR 0x376 +#define SOTG_CTRL_OTG_DISABLE (1 << 10) +#define SOTG_CTRL_OTG_SE0_EN (1 << 9) +#define SOTG_CTRL_BDIS_ACON_EN (1 << 8) +#define SOTG_CTRL_SW_SEL_HC_DC (1 << 7) +#define SOTG_CTRL_VBUS_CHRG (1 << 6) +#define SOTG_CTRL_VBUS_DISCHRG (1 << 5) +#define SOTG_CTRL_VBUS_DRV (1 << 4) +#define SOTG_CTRL_SEL_CP_EXT (1 << 3) +#define SOTG_CTRL_DM_PULL_DOWN (1 << 2) +#define SOTG_CTRL_DP_PULL_DOWN (1 << 1) +#define SOTG_CTRL_DP_PULL_UP (1 << 0) +#define SOTG_STATUS 0x378 +#define SOTG_STATUS_B_SE0_SRP (1 << 8) +#define SOTG_STATUS_B_SESS_END (1 << 7) +#define SOTG_STATUS_RMT_CONN (1 << 4) +#define SOTG_STATUS_ID (1 << 3) +#define SOTG_STATUS_DP_SRP (1 << 2) +#define SOTG_STATUS_A_B_SESS_VLD (1 << 1) +#define SOTG_STATUS_VBUS_VLD (1 << 0) +#define SOTG_IRQ_LATCH_SET 0x37C +#define SOTG_IRQ_LATCH_CLR 0x37E +#define SOTG_IRQ_ENABLE_SET 0x380 +#define SOTG_IRQ_ENABLE_CLR 0x382 +#define SOTG_IRQ_RISE_SET 0x384 +#define SOTG_IRQ_RISE_CLR 0x386 +#define SOTG_IRQ_OTG_TMR_TIMEOUT (1 << 9) +#define SOTG_IRQ_B_SE0_SRP (1 << 8) +#define SOTG_IRQ_B_SESS_END (1 << 7) +#define SOTG_IRQ_BDIS_ACON (1 << 6) +#define SOTG_IRQ_OTG_RESUME (1 << 5) +#define SOTG_IRQ_RMT_CONN (1 << 4) +#define SOTG_IRQ_ID (1 << 3) +#define SOTG_IRQ_DP_SRP (1 << 2) +#define SOTG_IRQ_A_B_SESS_VLD (1 << 1) +#define SOTG_IRQ_VBUS_VLD (1 << 0) +#define SOTG_TIMER_LOW_SET 0x388 +#define SOTG_TIMER_LOW_CLR 0x38A +#define SOTG_TIMER_HIGH_SET 0x38C +#define SOTG_TIMER_HIGH_CLR 0x38E +#define SOTG_TIMER_START_TMR (1U << 15) + +/* Peripheral controller specific registers */ + +#define SOTG_ADDRESS 0x200 +#define SOTG_ADDRESS_ENABLE (1 << 7) +#define SOTG_MODE 0x20C +#define SOTG_MODE_DMACLK_ON (1 << 9) +#define SOTG_MODE_VBUSSTAT (1 << 8) +#define SOTG_MODE_CLKAON (1 << 7) +#define SOTG_MODE_SNDRSU (1 << 6) +#define SOTG_MODE_GOSUSP (1 << 5) +#define SOTG_MODE_SFRESET (1 << 4) +#define SOTG_MODE_GLINTENA (1 << 3) +#define SOTG_MODE_WKUPCS (1 << 2) +#define SOTG_INTERRUPT_CFG 0x210 +#define SOTG_INTERRUPT_CFG_CDBGMOD (3 << 6) +#define SOTG_INTERRUPT_CFG_DDBGMODIN (3 << 4) +#define SOTG_INTERRUPT_CFG_DDBGMODOUT (3 << 2) +#define SOTG_INTERRUPT_CFG_INTLVL (1 << 1) +#define SOTG_INTERRUPT_CFG_INTPOL (1 << 0) +#define SOTG_DEBUG 0x212 +#define SOTG_DEBUG_SET (1 << 0) +#define SOTG_DCINTERRUPT_EN 0x214 +#define SOTG_HW_MODE_CTRL 0x300 +#define SOTG_HW_MODE_CTRL_ALL_ATX_RESET (1 << 31) +#define SOTG_HW_MODE_CTRL_ANA_DIGI_OC (1 << 15) +#define SOTG_HW_MODE_CTRL_DEV_DMA (1 << 11) +#define SOTG_HW_MODE_CTRL_COMN_INT (1 << 10) +#define SOTG_HW_MODE_CTRL_COMN_DMA (1 << 9) +#define SOTG_HW_MODE_CTRL_DATA_BUS_WIDTH (1 << 8) +#define SOTG_HW_MODE_CTRL_DACK_POL (1 << 6) +#define SOTG_HW_MODE_CTRL_DREQ_POL (1 << 5) +#define SOTG_HW_MODE_CTRL_INTR_POL (1 << 2) +#define SOTG_HW_MODE_CTRL_INTR_LEVEL (1 << 1) +#define SOTG_HW_MODE_CTRL_GLOBAL_INTR_EN (1 << 0) +#define SOTG_OTG_CTRL 0x374 +#define SOTG_EP_INDEX 0x22c +#define SOTG_EP_INDEX_EP0SETUP (1 << 5) +#define SOTG_EP_INDEX_ENDP_INDEX_MASK (15 << 1) +#define SOTG_EP_INDEX_ENDP_INDEX_SHIFT 1 +#define SOTG_EP_INDEX_DIR_IN (1 << 0) +#define SOTG_EP_INDEX_DIR_OUT 0 +#define SOTG_CTRL_FUNC 0x228 +#define SOTG_CTRL_FUNC_CLBUF (1 << 4) +#define SOTG_CTRL_FUNC_VENDP (1 << 3) +#define SOTG_CTRL_FUNC_DSEN (1 << 2) +#define SOTG_CTRL_FUNC_STATUS (1 << 1) +#define SOTG_CTRL_FUNC_STALL (1 << 0) +#define SOTG_DATA_PORT 0x220 +#define SOTG_BUF_LENGTH 0x21C +#define SOTG_DCBUFFERSTATUS 0x21E +#define SOTG_DCBUFFERSTATUS_FILLED_MASK (3 << 0) +#define SOTG_EP_MAXPACKET 0x204 +#define SOTG_EP_TYPE 0x208 +#define SOTG_EP_TYPE_NOEMPPKT (1 << 4) +#define SOTG_EP_TYPE_ENABLE (1 << 3) +#define SOTG_EP_TYPE_DBLBUF (1 << 2) +#define SOTG_EP_TYPE_EP_TYPE (3 << 0) +#define SOTG_DMA_CMD 0x230 +#define SOTG_DMA_XFER_COUNT 0x234 +#define SOTG_DCDMA_CFG 0x238 +#define SOTG_DMA_HW 0x23C +#define SOTG_DMA_IRQ_REASON 0x250 +#define SOTG_DMA_IRQ_ENABLE 0x254 +#define SOTG_DMA_EP 0x258 +#define SOTG_BURST_COUNTER 0x264 +#define SOTG_DCINTERRUPT 0x218 +#define SOTG_DCINTERRUPT_IEPRX(n) (1 << (10 + (2*(n)))) +#define SOTG_DCINTERRUPT_IEPTX(n) (1 << (11 + (2*(n)))) +#define SOTG_DCINTERRUPT_IEP0SETUP (1 << 8) +#define SOTG_DCINTERRUPT_IEVBUS (1 << 7) +#define SOTG_DCINTERRUPT_IEDMA (1 << 6) +#define SOTG_DCINTERRUPT_IEHS_STA (1 << 5) +#define SOTG_DCINTERRUPT_IERESM (1 << 4) +#define SOTG_DCINTERRUPT_IESUSP (1 << 3) +#define SOTG_DCINTERRUPT_IEPSOF (1 << 2) +#define SOTG_DCINTERRUPT_IESOF (1 << 1) +#define SOTG_DCINTERRUPT_IEBRST (1 << 0) +#define SOTG_DCCHIP_ID 0x270 +#define SOTG_FRAME_NUM 0x274 +#define SOTG_FRAME_NUM_MICROSOFR_MASK 0x3800 +#define SOTG_FRAME_NUM_MICROSOFR_SHIFT 11 +#define SOTG_FRAME_NUM_SOFR_MASK 0x7FF +#define SOTG_DCSCRATCH 0x278 +#define SOTG_UNLOCK_DEVICE 0x27C +#define SOTG_UNLOCK_DEVICE_CODE 0xAA37 +#define SOTG_IRQ_PULSE_WIDTH 0x280 +#define SOTG_TEST_MODE 0x284 +#define SOTG_TEST_MODE_FORCEHS (1 << 7) +#define SOTG_TEST_MODE_FORCEFS (1 << 4) +#define SOTG_TEST_MODE_PRBS (1 << 3) +#define SOTG_TEST_MODE_KSTATE (1 << 2) +#define SOTG_TEST_MODE_JSTATE (1 << 1) +#define SOTG_TEST_MODE_SE0_NAK (1 << 0) + +/* Host controller specific registers */ + +#define SOTG_CONFIGFLAG 0x0060 +#define SOTG_CONFIGFLAG_ENABLE (1 << 0) +#define SOTG_PORTSC1 0x0064 +#define SOTG_PORTSC1_PIC (3 << 14) +#define SOTG_PORTSC1_PO (1 << 13) +#define SOTG_PORTSC1_PP (1 << 12) +#define SOTG_PORTSC1_LS (3 << 10) +#define SOTG_PORTSC1_PR (1 << 8) +#define SOTG_PORTSC1_SUSP (1 << 7) +#define SOTG_PORTSC1_FPR (1 << 6) +#define SOTG_PORTSC1_PED (1 << 2) +#define SOTG_PORTSC1_ECSC (1 << 1) +#define SOTG_PORTSC1_ECCS (1 << 0) +#define SOTG_DATA_ADDR(x) (0x400 + (512 * (x))) +#define SOTG_ASYNC_PDT(x) (0x400 + (60 * 1024) + ((x) * 32)) +#define SOTG_INTR_PDT(x) (0x400 + (61 * 1024) + ((x) * 32)) +#define SOTG_ISOC_PDT(x) (0x400 + (62 * 1024) + ((x) * 32)) +#define SOTG_HC_MEMORY_ADDR(x) (((x) - 0x400) >> 3) +#define SOTG_SW_RESET 0x30C +#define SOTG_SW_RESET_HC (1 << 1) +#define SOTG_SW_RESET_ALL (1 << 0) +#define SOTG_POWER_DOWN 0x354 +#define SOTG_POWER_DOWN_PORT3_PD (1 << 12) +#define SOTG_POWER_DOWN_PORT2_PD (1 << 11) +#define SOTG_POWER_DOWN_VBATDET_PWR (1 << 10) +#define SOTG_POWER_DOWN_BIAS_EN (1 << 5) +#define SOTG_POWER_DOWN_VREG_ON (1 << 4) +#define SOTG_POWER_DOWN_OC3_PWR (1 << 3) +#define SOTG_POWER_DOWN_OC2_PWR (1 << 2) +#define SOTG_POWER_DOWN_OC1_PWR (1 << 1) +#define SOTG_POWER_DOWN_HC_CLK_EN (1 << 0) +#define SOTG_USBCMD 0x20 +#define SOTG_USBCMD_LHCR (1 << 7) +#define SOTG_USBCMD_HCRESET (1 << 1) +#define SOTG_USBCMD_RS (1 << 0) + +#endif /* _SAF1761_OTG_REG_H_ */ diff --git a/sys/modules/usb/saf1761/Makefile b/sys/modules/usb/saf1761/Makefile index bd1be7d2ae848..5610a38737350 100644 --- a/sys/modules/usb/saf1761/Makefile +++ b/sys/modules/usb/saf1761/Makefile @@ -36,7 +36,7 @@ S= ${.CURDIR}/../../.. KMOD= saf1761 SRCS= bus_if.h device_if.h usb_if.h \ opt_bus.h opt_usb.h ofw_bus_if.h \ - saf1761_dci.c saf1761_dci_fdt.c \ + saf1761_otg.c saf1761_otg_fdt.c \ pci_if.h .include -- cgit v1.3 From 4327a6c8c6e3a43bb344fd7140fef0d2ea64d7d8 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Fri, 16 May 2014 15:53:14 +0000 Subject: Fix a compile warning about unused variable. Sponsored by: DARPA, AFRL --- sys/dev/usb/controller/saf1761_otg.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/saf1761_otg.c b/sys/dev/usb/controller/saf1761_otg.c index 36e8c2c5a5561..080e5ed6cf66c 100644 --- a/sys/dev/usb/controller/saf1761_otg.c +++ b/sys/dev/usb/controller/saf1761_otg.c @@ -2629,12 +2629,9 @@ static void saf1761_otg_ep_init(struct usb_device *udev, struct usb_endpoint_descriptor *edesc, struct usb_endpoint *ep) { - struct saf1761_otg_softc *sc = SAF1761_OTG_BUS2SC(udev->bus); - - DPRINTFN(2, "endpoint=%p, addr=%d, endpt=%d, mode=%d (%d)\n", + DPRINTFN(2, "endpoint=%p, addr=%d, endpt=%d, mode=%d\n", ep, udev->address, - edesc->bEndpointAddress, udev->flags.usb_mode, - sc->sc_rt_addr); + edesc->bEndpointAddress, udev->flags.usb_mode); if (udev->parent_hub == NULL) { /* root HUB has special endpoint handling */ -- cgit v1.3 From 56a052ffdd49a4f681655d65e8ad84256a010ebf Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Fri, 16 May 2014 15:53:47 +0000 Subject: Remove old files. Sponsored by: DARPA, AFRL --- sys/dev/usb/controller/saf1761_dci.c | 2703 ------------------------------ sys/dev/usb/controller/saf1761_dci.h | 157 -- sys/dev/usb/controller/saf1761_dci_fdt.c | 253 --- sys/dev/usb/controller/saf1761_dci_reg.h | 214 --- 4 files changed, 3327 deletions(-) delete mode 100644 sys/dev/usb/controller/saf1761_dci.c delete mode 100644 sys/dev/usb/controller/saf1761_dci.h delete mode 100644 sys/dev/usb/controller/saf1761_dci_fdt.c delete mode 100644 sys/dev/usb/controller/saf1761_dci_reg.h (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/saf1761_dci.c b/sys/dev/usb/controller/saf1761_dci.c deleted file mode 100644 index 78fbab3691744..0000000000000 --- a/sys/dev/usb/controller/saf1761_dci.c +++ /dev/null @@ -1,2703 +0,0 @@ -/* $FreeBSD$ */ -/*- - * Copyright (c) 2014 Hans Petter Selasky - * All rights reserved. - * - * This software was developed by SRI International and the University of - * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) - * ("CTSRD"), as part of the DARPA CRASH research programme. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * This file contains the driver for the SAF1761 series USB OTG - * controller. - * - * Datasheet is available from: - * http://www.nxp.com/products/automotive/multimedia/usb/SAF1761BE.html - */ - -#ifdef USB_GLOBAL_INCLUDE_FILE -#include USB_GLOBAL_INCLUDE_FILE -#else -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#define USB_DEBUG_VAR saf1761_dci_debug - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#endif /* USB_GLOBAL_INCLUDE_FILE */ - -#include -#include - -#define SAF1761_DCI_BUS2SC(bus) \ - ((struct saf1761_dci_softc *)(((uint8_t *)(bus)) - \ - ((uint8_t *)&(((struct saf1761_dci_softc *)0)->sc_bus)))) - -#ifdef USB_DEBUG -static int saf1761_dci_debug = 0; -static int saf1761_dci_forcefs = 0; - -static -SYSCTL_NODE(_hw_usb, OID_AUTO, saf1761_dci, CTLFLAG_RW, 0, - "USB SAF1761 DCI"); - -SYSCTL_INT(_hw_usb_saf1761_dci, OID_AUTO, debug, CTLFLAG_RW, - &saf1761_dci_debug, 0, "SAF1761 DCI debug level"); -SYSCTL_INT(_hw_usb_saf1761_dci, OID_AUTO, forcefs, CTLFLAG_RW, - &saf1761_dci_forcefs, 0, "SAF1761 DCI force FULL speed"); -#endif - -#define SAF1761_DCI_INTR_ENDPT 1 - -/* prototypes */ - -static const struct usb_bus_methods saf1761_dci_bus_methods; -static const struct usb_pipe_methods saf1761_otg_non_isoc_methods; -static const struct usb_pipe_methods saf1761_dci_device_isoc_methods; - -static saf1761_dci_cmd_t saf1761_host_setup_tx; -static saf1761_dci_cmd_t saf1761_host_bulk_data_rx; -static saf1761_dci_cmd_t saf1761_host_bulk_data_tx; -static saf1761_dci_cmd_t saf1761_host_intr_data_rx; -static saf1761_dci_cmd_t saf1761_host_intr_data_tx; -static saf1761_dci_cmd_t saf1761_host_isoc_data_rx; -static saf1761_dci_cmd_t saf1761_host_isoc_data_tx; -static saf1761_dci_cmd_t saf1761_device_setup_rx; -static saf1761_dci_cmd_t saf1761_device_data_rx; -static saf1761_dci_cmd_t saf1761_device_data_tx; -static saf1761_dci_cmd_t saf1761_device_data_tx_sync; -static void saf1761_dci_device_done(struct usb_xfer *, usb_error_t); -static void saf1761_dci_do_poll(struct usb_bus *); -static void saf1761_dci_standard_done(struct usb_xfer *); -static void saf1761_dci_intr_set(struct usb_xfer *, uint8_t); -static void saf1761_dci_root_intr(struct saf1761_dci_softc *); - -/* - * Here is a list of what the SAF1761 chip can support. The main - * limitation is that the sum of the buffer sizes must be less than - * 8192 bytes. - */ -static const struct usb_hw_ep_profile saf1761_dci_ep_profile[] = { - - [0] = { - .max_in_frame_size = 64, - .max_out_frame_size = 64, - .is_simplex = 0, - .support_control = 1, - }, - [1] = { - .max_in_frame_size = SOTG_HS_MAX_PACKET_SIZE, - .max_out_frame_size = SOTG_HS_MAX_PACKET_SIZE, - .is_simplex = 0, - .support_interrupt = 1, - .support_bulk = 1, - .support_isochronous = 1, - .support_in = 1, - .support_out = 1, - }, -}; - -static void -saf1761_dci_get_hw_ep_profile(struct usb_device *udev, - const struct usb_hw_ep_profile **ppf, uint8_t ep_addr) -{ - if (ep_addr == 0) { - *ppf = saf1761_dci_ep_profile + 0; - } else if (ep_addr < 8) { - *ppf = saf1761_dci_ep_profile + 1; - } else { - *ppf = NULL; - } -} - -static void -saf1761_dci_pull_up(struct saf1761_dci_softc *sc) -{ - /* activate pullup on D+, if possible */ - - if (!sc->sc_flags.d_pulled_up && sc->sc_flags.port_powered) { - DPRINTF("\n"); - - sc->sc_flags.d_pulled_up = 1; - } -} - -static void -saf1761_dci_pull_down(struct saf1761_dci_softc *sc) -{ - /* release pullup on D+, if possible */ - - if (sc->sc_flags.d_pulled_up) { - DPRINTF("\n"); - - sc->sc_flags.d_pulled_up = 0; - } -} - -static void -saf1761_dci_wakeup_peer(struct saf1761_dci_softc *sc) -{ - uint16_t temp; - - if (!(sc->sc_flags.status_suspend)) - return; - - DPRINTFN(5, "\n"); - - temp = SAF1761_READ_2(sc, SOTG_MODE); - SAF1761_WRITE_2(sc, SOTG_MODE, temp | SOTG_MODE_SNDRSU); - SAF1761_WRITE_2(sc, SOTG_MODE, temp & ~SOTG_MODE_SNDRSU); - - /* Wait 8ms for remote wakeup to complete. */ - usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 125); - -} - -static uint8_t -saf1761_host_channel_alloc(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) -{ - uint32_t x; - - if (td->channel < SOTG_HOST_CHANNEL_MAX) - return (0); - - switch (td->ep_type) { - case UE_INTERRUPT: - for (x = 0; x != 32; x++) { - if (sc->sc_host_intr_map & (1 << x)) - continue; - sc->sc_host_intr_map |= (1 << x); - td->channel = 32 + x; - return (0); - } - break; - case UE_ISOCHRONOUS: - for (x = 0; x != 32; x++) { - if (sc->sc_host_isoc_map & (1 << x)) - continue; - sc->sc_host_isoc_map |= (1 << x); - td->channel = 64 + x; - return (0); - } - break; - default: - for (x = 0; x != 32; x++) { - if (sc->sc_host_async_map & (1 << x)) - continue; - sc->sc_host_async_map |= (1 << x); - td->channel = x; - return (0); - } - break; - } - return (1); -} - -static void -saf1761_host_channel_free(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) -{ - uint32_t x; - - if (td->channel >= SOTG_HOST_CHANNEL_MAX) - return; - - /* disable channel */ - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 3), 0); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 0), 0); - - switch (td->ep_type) { - case UE_INTERRUPT: - x = td->channel - 32; - sc->sc_host_intr_map &= ~(1 << x); - td->channel = SOTG_HOST_CHANNEL_MAX; - break; - case UE_ISOCHRONOUS: - x = td->channel - 64; - sc->sc_host_isoc_map &= ~(1 << x); - td->channel = SOTG_HOST_CHANNEL_MAX; - break; - default: - x = td->channel - 64; - sc->sc_host_async_map &= ~(1 << x); - td->channel = SOTG_HOST_CHANNEL_MAX; - break; - } -} - -static void -saf1761_read_host_fifo_1(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td, - void *buf, uint32_t len) -{ - bus_space_read_region_1((sc)->sc_io_tag, (sc)->sc_io_hdl, - SOTG_DATA_ADDR(td->channel), buf, len); -} - -static void -saf1761_write_host_fifo_1(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td, - void *buf, uint32_t len) -{ - bus_space_write_region_1((sc)->sc_io_tag, (sc)->sc_io_hdl, - SOTG_DATA_ADDR(td->channel), buf, len); -} - -static uint8_t -saf1761_host_setup_tx(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) -{ - struct usb_device_request req __aligned(4); - uint32_t status; - uint32_t count; - - if (td->channel < SOTG_HOST_CHANNEL_MAX) { - status = SAF1761_READ_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 3)); - if (status & (1 << 31)) { - goto busy; - } else if (status & (1 << 30)) { - td->error_stall = 1; - td->error_any = 1; - } else if (status & (3 << 28)) { - td->error_any = 1; - } - count = (status & 0x7FFF); - - saf1761_host_channel_free(sc, td); - goto complete; - } - if (saf1761_host_channel_alloc(sc, td)) - goto busy; - - if (sizeof(req) != td->remainder) { - td->error_any = 1; - goto complete; - } - - count = sizeof(req); - - usbd_copy_out(td->pc, 0, &req, count); - - saf1761_write_host_fifo_1(sc, td, &req, count); - - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 7), 0); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 6), 0); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 5), 0); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 4), 0); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 3), - (1 << 31) | (td->toggle << 25) | (3 << 23)); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 2), - SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8); - - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 1), - td->dw1_value | - (2 << 10) /* SETUP PID */ | - (td->ep_index >> 1)); - - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 0), - (td->ep_index << 31) | - (1 << 29) /* pkt-multiplier */ | - (td->max_packet_size << 18) /* wMaxPacketSize */ | - (count << 3) /* transfer count */ | - 1 /* valid */); - - td->offset += count; - td->remainder -= count; - td->toggle = 1; -busy: - return (1); /* busy */ -complete: - return (0); /* complete */ -} - -static uint8_t -saf1761_host_bulk_data_rx(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) -{ - if (td->channel < SOTG_HOST_CHANNEL_MAX) { - uint32_t status; - uint32_t count; - uint8_t got_short; - - status = SAF1761_READ_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 3)); - - if (status & (1 << 31)) { - goto busy; - } else if (status & (1 << 30)) { - td->error_stall = 1; - td->error_any = 1; - goto complete; - } else if (status & (3 << 28)) { - td->error_any = 1; - goto complete; - } - count = (status & 0x7FFF); - got_short = 0; - - /* verify the packet byte count */ - if (count != td->max_packet_size) { - if (count < td->max_packet_size) { - /* we have a short packet */ - td->short_pkt = 1; - got_short = 1; - } else { - /* invalid USB packet */ - td->error_any = 1; - goto complete; - } - } - td->toggle ^= 1; - - /* verify the packet byte count */ - if (count > td->remainder) { - /* invalid USB packet */ - td->error_any = 1; - goto complete; - } - - saf1761_read_host_fifo_1(sc, td, - sc->sc_bounce_buffer, count); - usbd_copy_in(td->pc, td->offset, - sc->sc_bounce_buffer, count); - - td->remainder -= count; - td->offset += count; - - saf1761_host_channel_free(sc, td); - - /* check if we are complete */ - if ((td->remainder == 0) || got_short) { - if (td->short_pkt) - goto complete; - /* else need to receive a zero length packet */ - } - } - if (saf1761_host_channel_alloc(sc, td)) - goto busy; - - /* set toggle, if any */ - if (td->set_toggle) { - td->set_toggle = 0; - td->toggle = 1; - } - - /* receive one more packet */ - - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 7), 0); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 6), 0); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 5), 0); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 4), 0); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 3), - (1 << 31) | (td->toggle << 25) | (3 << 23)); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 2), - SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8); - - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 1), - td->dw1_value | - (1 << 10) /* IN-PID */ | - (td->ep_index >> 1)); - - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 0), - (td->ep_index << 31) | - (1 << 29) /* pkt-multiplier */ | - (td->max_packet_size << 18) /* wMaxPacketSize */ | - (td->max_packet_size << 3) /* transfer count */ | - 1 /* valid */); -busy: - return (1); /* busy */ -complete: - return (0); /* complete */ -} - -static uint8_t -saf1761_host_bulk_data_tx(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) -{ - uint32_t count; - - if (td->channel < SOTG_HOST_CHANNEL_MAX) { - uint32_t status; - - status = SAF1761_READ_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 3)); - if (status & (1 << 31)) { - goto busy; - } else if (status & (1 << 30)) { - td->error_stall = 1; - td->error_any = 1; - } else if (status & (3 << 28)) { - td->error_any = 1; - } - - saf1761_host_channel_free(sc, td); - - /* check remainder */ - if (td->remainder == 0) { - if (td->short_pkt) - goto complete; - /* else we need to transmit a short packet */ - } - } - if (saf1761_host_channel_alloc(sc, td)) - goto busy; - - count = td->max_packet_size; - if (td->remainder < count) { - /* we have a short packet */ - td->short_pkt = 1; - count = td->remainder; - } - - usbd_copy_out(td->pc, td->offset, sc->sc_bounce_buffer, count); - saf1761_write_host_fifo_1(sc, td, sc->sc_bounce_buffer, count); - - /* set toggle, if any */ - if (td->set_toggle) { - td->set_toggle = 0; - td->toggle = 1; - } - - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 7), 0); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 6), 0); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 5), 0); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 4), 0); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 3), - (1 << 31) | (td->toggle << 25) | (3 << 23)); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 2), - SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8); - - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 1), - td->dw1_value | - (0 << 10) /* OUT-PID */ | - (td->ep_index >> 1)); - - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 0), - (td->ep_index << 31) | - (1 << 29) /* pkt-multiplier */ | - (td->max_packet_size << 18) /* wMaxPacketSize */ | - (count << 3) /* transfer count */ | - 1 /* valid */); - - td->offset += count; - td->remainder -= count; - td->toggle ^= 1; -busy: - return (1); /* busy */ -complete: - return (0); /* complete */ -} - -static uint8_t -saf1761_host_intr_data_rx(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) -{ - return (1); /* busy */ -} - -static uint8_t -saf1761_host_intr_data_tx(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) -{ - return (1); /* busy */ -} - -static uint8_t -saf1761_host_isoc_data_rx(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) -{ - return (1); /* busy */ -} - -static uint8_t -saf1761_host_isoc_data_tx(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) -{ - return (1); /* busy */ -} - -static void -saf1761_dci_set_address(struct saf1761_dci_softc *sc, uint8_t addr) -{ - DPRINTFN(5, "addr=%d\n", addr); - - SAF1761_WRITE_1(sc, SOTG_ADDRESS, addr | SOTG_ADDRESS_ENABLE); -} - -static void -saf1761_read_device_fifo_1(struct saf1761_dci_softc *sc, void *buf, uint32_t len) -{ - bus_space_read_multi_1((sc)->sc_io_tag, (sc)->sc_io_hdl, - SOTG_DATA_PORT, buf, len); -} - -static void -saf1761_write_device_fifo_1(struct saf1761_dci_softc *sc, void *buf, uint32_t len) -{ - bus_space_write_multi_1((sc)->sc_io_tag, (sc)->sc_io_hdl, - SOTG_DATA_PORT, buf, len); -} - -static uint8_t -saf1761_device_setup_rx(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) -{ - struct usb_device_request req; - uint16_t count; - - /* select the correct endpoint */ - SAF1761_WRITE_1(sc, SOTG_EP_INDEX, SOTG_EP_INDEX_EP0SETUP); - - /* check buffer status */ - if ((SAF1761_READ_1(sc, SOTG_DCBUFFERSTATUS) & - SOTG_DCBUFFERSTATUS_FILLED_MASK) == 0) - goto busy; - - /* read buffer length */ - count = SAF1761_READ_2(sc, SOTG_BUF_LENGTH); - - DPRINTFN(5, "count=%u rem=%u\n", count, td->remainder); - - /* clear did stall */ - td->did_stall = 0; - - /* clear stall */ - SAF1761_WRITE_1(sc, SOTG_CTRL_FUNC, 0); - - /* verify data length */ - if (count != td->remainder) { - DPRINTFN(0, "Invalid SETUP packet " - "length, %d bytes\n", count); - goto busy; - } - if (count != sizeof(req)) { - DPRINTFN(0, "Unsupported SETUP packet " - "length, %d bytes\n", count); - goto busy; - } - /* receive data */ - saf1761_read_device_fifo_1(sc, &req, sizeof(req)); - - /* copy data into real buffer */ - usbd_copy_in(td->pc, 0, &req, sizeof(req)); - - td->offset = sizeof(req); - td->remainder = 0; - - /* sneak peek the set address */ - if ((req.bmRequestType == UT_WRITE_DEVICE) && - (req.bRequest == UR_SET_ADDRESS)) { - sc->sc_dv_addr = req.wValue[0] & 0x7F; - DPRINTF("Set address %d\n", sc->sc_dv_addr); - } else { - sc->sc_dv_addr = 0xFF; - } - return (0); /* complete */ - -busy: - /* abort any ongoing transfer */ - if (!td->did_stall) { - DPRINTFN(5, "stalling\n"); - - /* set stall */ - SAF1761_WRITE_1(sc, SOTG_CTRL_FUNC, SOTG_CTRL_FUNC_STALL); - - td->did_stall = 1; - } - return (1); /* not complete */ -} - -static uint8_t -saf1761_device_data_rx(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) -{ - struct usb_page_search buf_res; - uint16_t count; - uint8_t got_short = 0; - - if (td->ep_index == 0) { - /* select the correct endpoint */ - SAF1761_WRITE_1(sc, SOTG_EP_INDEX, SOTG_EP_INDEX_EP0SETUP); - - /* check buffer status */ - if ((SAF1761_READ_1(sc, SOTG_DCBUFFERSTATUS) & - SOTG_DCBUFFERSTATUS_FILLED_MASK) != 0) { - - if (td->remainder == 0) { - /* - * We are actually complete and have - * received the next SETUP: - */ - DPRINTFN(5, "faking complete\n"); - return (0); /* complete */ - } - DPRINTFN(5, "SETUP packet while receiving data\n"); - /* - * USB Host Aborted the transfer. - */ - td->error_any = 1; - return (0); /* complete */ - } - } - /* select the correct endpoint */ - SAF1761_WRITE_1(sc, SOTG_EP_INDEX, - (td->ep_index << SOTG_EP_INDEX_ENDP_INDEX_SHIFT) | - SOTG_EP_INDEX_DIR_OUT); - - /* enable data stage */ - if (td->set_toggle) { - td->set_toggle = 0; - SAF1761_WRITE_1(sc, SOTG_CTRL_FUNC, SOTG_CTRL_FUNC_DSEN); - } - - /* check buffer status */ - if ((SAF1761_READ_1(sc, SOTG_DCBUFFERSTATUS) & - SOTG_DCBUFFERSTATUS_FILLED_MASK) == 0) { - return (1); /* not complete */ - } - /* read buffer length */ - count = SAF1761_READ_2(sc, SOTG_BUF_LENGTH); - - DPRINTFN(5, "rem=%u count=0x%04x\n", td->remainder, count); - - /* verify the packet byte count */ - if (count != td->max_packet_size) { - if (count < td->max_packet_size) { - /* we have a short packet */ - td->short_pkt = 1; - got_short = 1; - } else { - /* invalid USB packet */ - td->error_any = 1; - return (0); /* we are complete */ - } - } - /* verify the packet byte count */ - if (count > td->remainder) { - /* invalid USB packet */ - td->error_any = 1; - return (0); /* we are complete */ - } - while (count > 0) { - usbd_get_page(td->pc, td->offset, &buf_res); - - /* get correct length */ - if (buf_res.length > count) - buf_res.length = count; - - /* receive data */ - saf1761_read_device_fifo_1(sc, buf_res.buffer, buf_res.length); - - /* update counters */ - count -= buf_res.length; - td->offset += buf_res.length; - td->remainder -= buf_res.length; - } - /* check if we are complete */ - if ((td->remainder == 0) || got_short) { - if (td->short_pkt) { - /* we are complete */ - return (0); - } - /* else need to receive a zero length packet */ - } - return (1); /* not complete */ -} - -static uint8_t -saf1761_device_data_tx(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) -{ - struct usb_page_search buf_res; - uint16_t count; - uint16_t count_old; - - if (td->ep_index == 0) { - /* select the correct endpoint */ - SAF1761_WRITE_1(sc, SOTG_EP_INDEX, SOTG_EP_INDEX_EP0SETUP); - - /* check buffer status */ - if ((SAF1761_READ_1(sc, SOTG_DCBUFFERSTATUS) & - SOTG_DCBUFFERSTATUS_FILLED_MASK) != 0) { - DPRINTFN(5, "SETUP abort\n"); - /* - * USB Host Aborted the transfer. - */ - td->error_any = 1; - return (0); /* complete */ - } - } - /* select the correct endpoint */ - SAF1761_WRITE_1(sc, SOTG_EP_INDEX, - (td->ep_index << SOTG_EP_INDEX_ENDP_INDEX_SHIFT) | - SOTG_EP_INDEX_DIR_IN); - - /* check buffer status */ - if ((SAF1761_READ_1(sc, SOTG_DCBUFFERSTATUS) & - SOTG_DCBUFFERSTATUS_FILLED_MASK) != 0) { - return (1); /* not complete */ - } - - /* enable data stage */ - if (td->set_toggle) { - td->set_toggle = 0; - SAF1761_WRITE_1(sc, SOTG_CTRL_FUNC, SOTG_CTRL_FUNC_DSEN); - } - - DPRINTFN(5, "rem=%u\n", td->remainder); - - count = td->max_packet_size; - if (td->remainder < count) { - /* we have a short packet */ - td->short_pkt = 1; - count = td->remainder; - } - count_old = count; - - while (count > 0) { - - usbd_get_page(td->pc, td->offset, &buf_res); - - /* get correct length */ - if (buf_res.length > count) - buf_res.length = count; - - /* transmit data */ - saf1761_write_device_fifo_1(sc, buf_res.buffer, buf_res.length); - - /* update counters */ - count -= buf_res.length; - td->offset += buf_res.length; - td->remainder -= buf_res.length; - } - - if (td->ep_index == 0) { - if (count_old < SOTG_FS_MAX_PACKET_SIZE) { - /* set end of packet */ - SAF1761_WRITE_1(sc, SOTG_CTRL_FUNC, SOTG_CTRL_FUNC_VENDP); - } - } else { - if (count_old < SOTG_HS_MAX_PACKET_SIZE) { - /* set end of packet */ - SAF1761_WRITE_1(sc, SOTG_CTRL_FUNC, SOTG_CTRL_FUNC_VENDP); - } - } - - /* check remainder */ - if (td->remainder == 0) { - if (td->short_pkt) { - return (0); /* complete */ - } - /* else we need to transmit a short packet */ - } - return (1); /* not complete */ -} - -static uint8_t -saf1761_device_data_tx_sync(struct saf1761_dci_softc *sc, struct saf1761_dci_td *td) -{ - if (td->ep_index == 0) { - /* select the correct endpoint */ - SAF1761_WRITE_1(sc, SOTG_EP_INDEX, SOTG_EP_INDEX_EP0SETUP); - - /* check buffer status */ - if ((SAF1761_READ_1(sc, SOTG_DCBUFFERSTATUS) & - SOTG_DCBUFFERSTATUS_FILLED_MASK) != 0) { - DPRINTFN(5, "Faking complete\n"); - return (0); /* complete */ - } - } - /* select the correct endpoint */ - SAF1761_WRITE_1(sc, SOTG_EP_INDEX, - (td->ep_index << SOTG_EP_INDEX_ENDP_INDEX_SHIFT) | - SOTG_EP_INDEX_DIR_IN); - - /* check buffer status */ - if ((SAF1761_READ_1(sc, SOTG_DCBUFFERSTATUS) & - SOTG_DCBUFFERSTATUS_FILLED_MASK) != 0) - return (1); /* busy */ - - if (sc->sc_dv_addr != 0xFF) { - /* write function address */ - saf1761_dci_set_address(sc, sc->sc_dv_addr); - } - return (0); /* complete */ -} - -static uint8_t -saf1761_dci_xfer_do_fifo(struct saf1761_dci_softc *sc, struct usb_xfer *xfer) -{ - struct saf1761_dci_td *td; - uint8_t toggle; - - DPRINTFN(9, "\n"); - - td = xfer->td_transfer_cache; - while (1) { - if ((td->func) (sc, td)) { - /* operation in progress */ - break; - } - if (((void *)td) == xfer->td_transfer_last) { - goto done; - } - if (td->error_any) { - goto done; - } else if (td->remainder > 0) { - /* - * We had a short transfer. If there is no alternate - * next, stop processing ! - */ - if (!td->alt_next) { - goto done; - } - } - /* - * Fetch the next transfer descriptor. - */ - toggle = td->toggle; - td = td->obj_next; - td->toggle = toggle; - xfer->td_transfer_cache = td; - } - return (1); /* not complete */ - -done: - /* compute all actual lengths */ - - saf1761_dci_standard_done(xfer); - - return (0); /* complete */ -} - -static void -saf1761_dci_interrupt_poll(struct saf1761_dci_softc *sc) -{ - struct usb_xfer *xfer; - -repeat: - TAILQ_FOREACH(xfer, &sc->sc_bus.intr_q.head, wait_entry) { - if (!saf1761_dci_xfer_do_fifo(sc, xfer)) { - /* queue has been modified */ - goto repeat; - } - } -} - -static void -saf1761_dci_wait_suspend(struct saf1761_dci_softc *sc, uint8_t on) -{ - if (on) { - sc->sc_intr_enable |= SOTG_DCINTERRUPT_IESUSP; - sc->sc_intr_enable &= ~SOTG_DCINTERRUPT_IERESM; - } else { - sc->sc_intr_enable &= ~SOTG_DCINTERRUPT_IESUSP; - sc->sc_intr_enable |= SOTG_DCINTERRUPT_IERESM; - } - SAF1761_WRITE_4(sc, SOTG_DCINTERRUPT_EN, sc->sc_intr_enable); -} - -static void -saf1761_dci_update_vbus(struct saf1761_dci_softc *sc) -{ - uint16_t status; - - /* read fresh status */ - status = SAF1761_READ_2(sc, SOTG_STATUS); - - DPRINTFN(4, "STATUS=0x%04x\n", status); - - if ((status & SOTG_STATUS_VBUS_VLD) && - (status & SOTG_STATUS_ID)) { - /* VBUS present and device mode */ - if (!sc->sc_flags.status_vbus) { - sc->sc_flags.status_vbus = 1; - - /* complete root HUB interrupt endpoint */ - saf1761_dci_root_intr(sc); - } - } else { - /* VBUS not-present or host mode */ - if (sc->sc_flags.status_vbus) { - sc->sc_flags.status_vbus = 0; - sc->sc_flags.status_bus_reset = 0; - sc->sc_flags.status_suspend = 0; - sc->sc_flags.change_suspend = 0; - sc->sc_flags.change_connect = 1; - - /* complete root HUB interrupt endpoint */ - saf1761_dci_root_intr(sc); - } - } -} - -void -saf1761_dci_interrupt(struct saf1761_dci_softc *sc) -{ - uint32_t status; - - USB_BUS_LOCK(&sc->sc_bus); - - status = SAF1761_READ_4(sc, SOTG_DCINTERRUPT); - - /* acknowledge all interrupts */ - SAF1761_WRITE_4(sc, SOTG_DCINTERRUPT, status); - - DPRINTF("DCINTERRUPT=0x%08x SOF=0x%04x\n", status, - SAF1761_READ_2(sc, SOTG_FRAME_NUM)); - - /* update VBUS and ID bits, if any */ - if (status & SOTG_DCINTERRUPT_IEVBUS) { - saf1761_dci_update_vbus(sc); - } - - if (status & SOTG_DCINTERRUPT_IEBRST) { - /* unlock device */ - SAF1761_WRITE_2(sc, SOTG_UNLOCK_DEVICE, - SOTG_UNLOCK_DEVICE_CODE); - - /* Enable device address */ - SAF1761_WRITE_1(sc, SOTG_ADDRESS, - SOTG_ADDRESS_ENABLE); - - sc->sc_flags.status_bus_reset = 1; - sc->sc_flags.status_suspend = 0; - sc->sc_flags.change_suspend = 0; - sc->sc_flags.change_connect = 1; - - /* disable resume interrupt */ - saf1761_dci_wait_suspend(sc, 1); - /* complete root HUB interrupt endpoint */ - saf1761_dci_root_intr(sc); - } - /* - * If "RESUME" and "SUSPEND" is set at the same time we - * interpret that like "RESUME". Resume is set when there is - * at least 3 milliseconds of inactivity on the USB BUS: - */ - if (status & SOTG_DCINTERRUPT_IERESM) { - /* unlock device */ - SAF1761_WRITE_2(sc, SOTG_UNLOCK_DEVICE, - SOTG_UNLOCK_DEVICE_CODE); - - if (sc->sc_flags.status_suspend) { - sc->sc_flags.status_suspend = 0; - sc->sc_flags.change_suspend = 1; - /* disable resume interrupt */ - saf1761_dci_wait_suspend(sc, 1); - /* complete root HUB interrupt endpoint */ - saf1761_dci_root_intr(sc); - } - } else if (status & SOTG_DCINTERRUPT_IESUSP) { - if (!sc->sc_flags.status_suspend) { - sc->sc_flags.status_suspend = 1; - sc->sc_flags.change_suspend = 1; - /* enable resume interrupt */ - saf1761_dci_wait_suspend(sc, 0); - /* complete root HUB interrupt endpoint */ - saf1761_dci_root_intr(sc); - } - } - /* poll all active transfers */ - saf1761_dci_interrupt_poll(sc); - - USB_BUS_UNLOCK(&sc->sc_bus); -} - -static void -saf1761_dci_setup_standard_chain_sub(struct saf1761_dci_std_temp *temp) -{ - struct saf1761_dci_td *td; - - /* get current Transfer Descriptor */ - td = temp->td_next; - temp->td = td; - - /* prepare for next TD */ - temp->td_next = td->obj_next; - - /* fill out the Transfer Descriptor */ - td->func = temp->func; - td->pc = temp->pc; - td->offset = temp->offset; - td->remainder = temp->len; - td->error_any = 0; - td->error_stall = 0; - td->set_toggle = 0; - td->did_stall = temp->did_stall; - td->short_pkt = temp->short_pkt; - td->alt_next = temp->setup_alt_next; - td->channel = SOTG_HOST_CHANNEL_MAX; -} - -static void -saf1761_dci_setup_standard_chain(struct usb_xfer *xfer) -{ - struct saf1761_dci_std_temp temp; - struct saf1761_dci_softc *sc; - struct saf1761_dci_td *td; - uint32_t x; - uint8_t ep_no; - uint8_t ep_type; - uint8_t need_sync; - uint8_t is_host; - - DPRINTFN(9, "addr=%d endpt=%d sumlen=%d speed=%d\n", - xfer->address, UE_GET_ADDR(xfer->endpointno), - xfer->sumlen, usbd_get_speed(xfer->xroot->udev)); - - temp.max_frame_size = xfer->max_frame_size; - - td = xfer->td_start[0]; - xfer->td_transfer_first = td; - xfer->td_transfer_cache = td; - - /* setup temp */ - - temp.pc = NULL; - temp.td = NULL; - temp.td_next = xfer->td_start[0]; - temp.offset = 0; - temp.setup_alt_next = xfer->flags_int.short_frames_ok; - temp.did_stall = !xfer->flags_int.control_stall; - - is_host = (xfer->xroot->udev->flags.usb_mode == USB_MODE_HOST); - - sc = SAF1761_DCI_BUS2SC(xfer->xroot->bus); - ep_no = (xfer->endpointno & UE_ADDR); - ep_type = (xfer->endpoint->edesc->bmAttributes & UE_XFERTYPE); - - /* check if we should prepend a setup message */ - - if (xfer->flags_int.control_xfr) { - if (xfer->flags_int.control_hdr) { - - if (is_host) - temp.func = &saf1761_host_setup_tx; - else - temp.func = &saf1761_device_setup_rx; - - temp.len = xfer->frlengths[0]; - temp.pc = xfer->frbuffers + 0; - temp.short_pkt = temp.len ? 1 : 0; - /* check for last frame */ - if (xfer->nframes == 1) { - /* no STATUS stage yet, SETUP is last */ - if (xfer->flags_int.control_act) - temp.setup_alt_next = 0; - } - saf1761_dci_setup_standard_chain_sub(&temp); - } - x = 1; - } else { - x = 0; - } - - if (x != xfer->nframes) { - if (xfer->endpointno & UE_DIR_IN) { - if (is_host) { - if (ep_type == UE_INTERRUPT) - temp.func = &saf1761_host_intr_data_rx; - else if (ep_type == UE_ISOCHRONOUS) - temp.func = &saf1761_host_isoc_data_rx; - else - temp.func = &saf1761_host_bulk_data_rx; - need_sync = 0; - } else { - temp.func = &saf1761_device_data_tx; - need_sync = 1; - } - } else { - if (is_host) { - if (ep_type == UE_INTERRUPT) - temp.func = &saf1761_host_intr_data_tx; - else if (ep_type == UE_ISOCHRONOUS) - temp.func = &saf1761_host_isoc_data_tx; - else - temp.func = &saf1761_host_bulk_data_tx; - need_sync = 0; - } else { - temp.func = &saf1761_device_data_rx; - need_sync = 0; - } - } - - /* setup "pc" pointer */ - temp.pc = xfer->frbuffers + x; - } else { - need_sync = 0; - } - - while (x != xfer->nframes) { - - /* DATA0 / DATA1 message */ - - temp.len = xfer->frlengths[x]; - - x++; - - if (x == xfer->nframes) { - if (xfer->flags_int.control_xfr) { - if (xfer->flags_int.control_act) { - temp.setup_alt_next = 0; - } - } else { - temp.setup_alt_next = 0; - } - } - if (temp.len == 0) { - - /* make sure that we send an USB packet */ - - temp.short_pkt = 0; - - } else { - - /* regular data transfer */ - - temp.short_pkt = (xfer->flags.force_short_xfer) ? 0 : 1; - } - - saf1761_dci_setup_standard_chain_sub(&temp); - - if (xfer->flags_int.isochronous_xfr) { - temp.offset += temp.len; - } else { - /* get next Page Cache pointer */ - temp.pc = xfer->frbuffers + x; - } - } - - /* check for control transfer */ - if (xfer->flags_int.control_xfr) { - /* always setup a valid "pc" pointer for status and sync */ - temp.pc = xfer->frbuffers + 0; - temp.len = 0; - temp.short_pkt = 0; - temp.setup_alt_next = 0; - - /* check if we should append a status stage */ - if (!xfer->flags_int.control_act) { - - /* - * Send a DATA1 message and invert the current - * endpoint direction. - */ - if (xfer->endpointno & UE_DIR_IN) { - if (is_host) { - temp.func = &saf1761_host_bulk_data_tx; - need_sync = 0; - } else { - temp.func = &saf1761_device_data_rx; - need_sync = 0; - } - } else { - if (is_host) { - temp.func = &saf1761_host_bulk_data_rx; - need_sync = 0; - } else { - temp.func = &saf1761_device_data_tx; - need_sync = 1; - } - } - temp.len = 0; - temp.short_pkt = 0; - - saf1761_dci_setup_standard_chain_sub(&temp); - - /* data toggle should be DATA1 */ - td = temp.td; - td->set_toggle = 1; - - if (need_sync) { - /* we need a SYNC point after TX */ - temp.func = &saf1761_device_data_tx_sync; - saf1761_dci_setup_standard_chain_sub(&temp); - } - } - } else { - if (need_sync) { - temp.pc = xfer->frbuffers + 0; - temp.len = 0; - temp.short_pkt = 0; - temp.setup_alt_next = 0; - - /* we need a SYNC point after TX */ - temp.func = &saf1761_device_data_tx_sync; - saf1761_dci_setup_standard_chain_sub(&temp); - } - } - - /* must have at least one frame! */ - td = temp.td; - xfer->td_transfer_last = td; - - if (is_host) { - /* get first again */ - td = xfer->td_transfer_first; - td->toggle = (xfer->endpoint->toggle_next ? 1 : 0); - } -} - -static void -saf1761_dci_timeout(void *arg) -{ - struct usb_xfer *xfer = arg; - - DPRINTF("xfer=%p\n", xfer); - - USB_BUS_LOCK_ASSERT(xfer->xroot->bus, MA_OWNED); - - /* transfer is transferred */ - saf1761_dci_device_done(xfer, USB_ERR_TIMEOUT); -} - -static void -saf1761_dci_intr_set(struct usb_xfer *xfer, uint8_t set) -{ - struct saf1761_dci_softc *sc = SAF1761_DCI_BUS2SC(xfer->xroot->bus); - uint8_t ep_no = (xfer->endpointno & UE_ADDR); - uint32_t mask; - - DPRINTFN(15, "endpoint=%d set=%d\n", xfer->endpointno, set); - - if (ep_no == 0) { - mask = SOTG_DCINTERRUPT_IEPRX(0) | - SOTG_DCINTERRUPT_IEPTX(0) | - SOTG_DCINTERRUPT_IEP0SETUP; - } else if (xfer->endpointno & UE_DIR_IN) { - mask = SOTG_DCINTERRUPT_IEPTX(ep_no); - } else { - mask = SOTG_DCINTERRUPT_IEPRX(ep_no); - } - - if (set) - sc->sc_intr_enable |= mask; - else - sc->sc_intr_enable &= ~mask; - - SAF1761_WRITE_4(sc, SOTG_DCINTERRUPT_EN, sc->sc_intr_enable); -} - -static void -saf1761_dci_start_standard_chain(struct usb_xfer *xfer) -{ - struct saf1761_dci_softc *sc = SAF1761_DCI_BUS2SC(xfer->xroot->bus); - - DPRINTFN(9, "\n"); - - /* poll one time */ - if (saf1761_dci_xfer_do_fifo(sc, xfer)) { - - /* - * Only enable the endpoint interrupt when we are - * actually waiting for data, hence we are dealing - * with level triggered interrupts ! - */ - saf1761_dci_intr_set(xfer, 1); - - /* put transfer on interrupt queue */ - usbd_transfer_enqueue(&xfer->xroot->bus->intr_q, xfer); - - /* start timeout, if any */ - if (xfer->timeout != 0) { - usbd_transfer_timeout_ms(xfer, - &saf1761_dci_timeout, xfer->timeout); - } - } -} - -static void -saf1761_dci_root_intr(struct saf1761_dci_softc *sc) -{ - DPRINTFN(9, "\n"); - - USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED); - - /* set port bit - we only have one port */ - sc->sc_hub_idata[0] = 0x02; - - uhub_root_intr(&sc->sc_bus, sc->sc_hub_idata, - sizeof(sc->sc_hub_idata)); -} - -static usb_error_t -saf1761_dci_standard_done_sub(struct usb_xfer *xfer) -{ - struct saf1761_dci_td *td; - uint32_t len; - usb_error_t error; - - DPRINTFN(9, "\n"); - - td = xfer->td_transfer_cache; - - do { - len = td->remainder; - - /* store last data toggle */ - xfer->endpoint->toggle_next = td->toggle; - - if (xfer->aframes != xfer->nframes) { - /* - * Verify the length and subtract - * the remainder from "frlengths[]": - */ - if (len > xfer->frlengths[xfer->aframes]) { - td->error_any = 1; - } else { - xfer->frlengths[xfer->aframes] -= len; - } - } - /* Check for transfer error */ - if (td->error_any) { - /* the transfer is finished */ - error = (td->error_stall ? - USB_ERR_STALLED : USB_ERR_IOERROR); - td = NULL; - break; - } - /* Check for short transfer */ - if (len > 0) { - if (xfer->flags_int.short_frames_ok) { - /* follow alt next */ - if (td->alt_next) { - td = td->obj_next; - } else { - td = NULL; - } - } else { - /* the transfer is finished */ - td = NULL; - } - error = 0; - break; - } - td = td->obj_next; - - /* this USB frame is complete */ - error = 0; - break; - - } while (0); - - /* update transfer cache */ - - xfer->td_transfer_cache = td; - - return (error); -} - -static void -saf1761_dci_standard_done(struct usb_xfer *xfer) -{ - usb_error_t err = 0; - - DPRINTFN(13, "xfer=%p endpoint=%p transfer done\n", - xfer, xfer->endpoint); - - /* reset scanner */ - - xfer->td_transfer_cache = xfer->td_transfer_first; - - if (xfer->flags_int.control_xfr) { - - if (xfer->flags_int.control_hdr) { - - err = saf1761_dci_standard_done_sub(xfer); - } - xfer->aframes = 1; - - if (xfer->td_transfer_cache == NULL) { - goto done; - } - } - while (xfer->aframes != xfer->nframes) { - - err = saf1761_dci_standard_done_sub(xfer); - xfer->aframes++; - - if (xfer->td_transfer_cache == NULL) { - goto done; - } - } - - if (xfer->flags_int.control_xfr && - !xfer->flags_int.control_act) { - - err = saf1761_dci_standard_done_sub(xfer); - } -done: - saf1761_dci_device_done(xfer, err); -} - -/*------------------------------------------------------------------------* - * saf1761_dci_device_done - * - * NOTE: this function can be called more than one time on the - * same USB transfer! - *------------------------------------------------------------------------*/ -static void -saf1761_dci_device_done(struct usb_xfer *xfer, usb_error_t error) -{ - struct saf1761_dci_softc *sc = SAF1761_DCI_BUS2SC(xfer->xroot->bus); - - USB_BUS_LOCK_ASSERT(xfer->xroot->bus, MA_OWNED); - - DPRINTFN(2, "xfer=%p, endpoint=%p, error=%d\n", - xfer, xfer->endpoint, error); - - if (xfer->flags_int.usb_mode == USB_MODE_DEVICE) { - saf1761_dci_intr_set(xfer, 0); - } else { - struct saf1761_dci_td *td; - - td = xfer->td_transfer_first; - - if (td != NULL) - saf1761_host_channel_free(sc, td); - } - - /* dequeue transfer and start next transfer */ - usbd_transfer_done(xfer, error); -} - -static void -saf1761_dci_xfer_stall(struct usb_xfer *xfer) -{ - saf1761_dci_device_done(xfer, USB_ERR_STALLED); -} - -static void -saf1761_dci_set_stall(struct usb_device *udev, - struct usb_endpoint *ep, uint8_t *did_stall) -{ - struct saf1761_dci_softc *sc; - uint8_t ep_no; - uint8_t ep_type; - uint8_t ep_dir; - - USB_BUS_LOCK_ASSERT(udev->bus, MA_OWNED); - - /* check mode */ - if (udev->flags.usb_mode != USB_MODE_DEVICE) { - /* not supported */ - return; - } - - DPRINTFN(5, "endpoint=%p\n", ep); - - /* set FORCESTALL */ - sc = SAF1761_DCI_BUS2SC(udev->bus); - ep_no = (ep->edesc->bEndpointAddress & UE_ADDR); - ep_dir = (ep->edesc->bEndpointAddress & (UE_DIR_IN | UE_DIR_OUT)); - ep_type = (ep->edesc->bmAttributes & UE_XFERTYPE); - - if (ep_type == UE_CONTROL) { - /* should not happen */ - return; - } - /* select the correct endpoint */ - SAF1761_WRITE_1(sc, SOTG_EP_INDEX, - (ep_no << SOTG_EP_INDEX_ENDP_INDEX_SHIFT) | - ((ep_dir == UE_DIR_IN) ? SOTG_EP_INDEX_DIR_IN : - SOTG_EP_INDEX_DIR_OUT)); - - /* set stall */ - SAF1761_WRITE_1(sc, SOTG_CTRL_FUNC, SOTG_CTRL_FUNC_STALL); -} - -static void -saf1761_dci_clear_stall_sub(struct saf1761_dci_softc *sc, - uint8_t ep_no, uint8_t ep_type, uint8_t ep_dir) -{ - if (ep_type == UE_CONTROL) { - /* clearing stall is not needed */ - return; - } - /* select the correct endpoint */ - SAF1761_WRITE_1(sc, SOTG_EP_INDEX, - (ep_no << SOTG_EP_INDEX_ENDP_INDEX_SHIFT) | - ((ep_dir == UE_DIR_IN) ? SOTG_EP_INDEX_DIR_IN : - SOTG_EP_INDEX_DIR_OUT)); - - /* disable endpoint */ - SAF1761_WRITE_2(sc, SOTG_EP_TYPE, 0); - /* enable endpoint again - will clear data toggle */ - SAF1761_WRITE_2(sc, SOTG_EP_TYPE, ep_type | SOTG_EP_TYPE_ENABLE); - - /* clear buffer */ - SAF1761_WRITE_1(sc, SOTG_CTRL_FUNC, SOTG_CTRL_FUNC_CLBUF); - /* clear stall */ - SAF1761_WRITE_1(sc, SOTG_CTRL_FUNC, 0); -} - -static void -saf1761_dci_clear_stall(struct usb_device *udev, struct usb_endpoint *ep) -{ - struct saf1761_dci_softc *sc; - struct usb_endpoint_descriptor *ed; - - USB_BUS_LOCK_ASSERT(udev->bus, MA_OWNED); - - DPRINTFN(5, "endpoint=%p\n", ep); - - /* check mode */ - if (udev->flags.usb_mode != USB_MODE_DEVICE) { - /* not supported */ - return; - } - /* get softc */ - sc = SAF1761_DCI_BUS2SC(udev->bus); - - /* get endpoint descriptor */ - ed = ep->edesc; - - /* reset endpoint */ - saf1761_dci_clear_stall_sub(sc, - (ed->bEndpointAddress & UE_ADDR), - (ed->bmAttributes & UE_XFERTYPE), - (ed->bEndpointAddress & (UE_DIR_IN | UE_DIR_OUT))); -} - -usb_error_t -saf1761_dci_init(struct saf1761_dci_softc *sc) -{ - const struct usb_hw_ep_profile *pf; - uint32_t x; - - DPRINTF("\n"); - - /* set up the bus structure */ - sc->sc_bus.usbrev = USB_REV_2_0; - sc->sc_bus.methods = &saf1761_dci_bus_methods; - - USB_BUS_LOCK(&sc->sc_bus); - - /* Enable interrupts */ - sc->sc_hw_mode |= SOTG_HW_MODE_CTRL_GLOBAL_INTR_EN | - SOTG_HW_MODE_CTRL_COMN_INT; - - /* - * Set correct hardware mode, must be written twice if bus - * width is changed: - */ - SAF1761_WRITE_2(sc, SOTG_HW_MODE_CTRL, sc->sc_hw_mode); - SAF1761_WRITE_4(sc, SOTG_HW_MODE_CTRL, sc->sc_hw_mode); - - DPRINTF("DCID=0x%08x\n", SAF1761_READ_4(sc, SOTG_DCCHIP_ID)); - - /* reset device controller */ - SAF1761_WRITE_2(sc, SOTG_MODE, SOTG_MODE_SFRESET); - SAF1761_WRITE_2(sc, SOTG_MODE, 0); - - /* wait a bit */ - DELAY(1000); - - /* reset host controller */ - SAF1761_WRITE_4(sc, SOTG_SW_RESET, SOTG_SW_RESET_HC); - SAF1761_WRITE_4(sc, SOTG_USBCMD, SOTG_USBCMD_HCRESET); - - /* wait a bit */ - DELAY(1000); - - SAF1761_WRITE_4(sc, SOTG_SW_RESET, 0); - SAF1761_WRITE_4(sc, SOTG_USBCMD, 0); - - /* wait a bit */ - DELAY(1000); - - /* do a pulldown */ - saf1761_dci_pull_down(sc); - - /* wait 10ms for pulldown to stabilise */ - usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 100); - - for (x = 1;; x++) { - - saf1761_dci_get_hw_ep_profile(NULL, &pf, x); - if (pf == NULL) - break; - - /* select the correct endpoint */ - SAF1761_WRITE_1(sc, SOTG_EP_INDEX, - (x << SOTG_EP_INDEX_ENDP_INDEX_SHIFT) | - SOTG_EP_INDEX_DIR_IN); - - /* select the maximum packet size */ - SAF1761_WRITE_2(sc, SOTG_EP_MAXPACKET, pf->max_in_frame_size); - - /* select the correct endpoint */ - SAF1761_WRITE_1(sc, SOTG_EP_INDEX, - (x << SOTG_EP_INDEX_ENDP_INDEX_SHIFT) | - SOTG_EP_INDEX_DIR_OUT); - - /* select the maximum packet size */ - SAF1761_WRITE_2(sc, SOTG_EP_MAXPACKET, pf->max_out_frame_size); - } - - /* enable interrupts */ - SAF1761_WRITE_2(sc, SOTG_MODE, SOTG_MODE_GLINTENA | - SOTG_MODE_CLKAON | SOTG_MODE_WKUPCS); - - /* set default values */ - SAF1761_WRITE_1(sc, SOTG_INTERRUPT_CFG, - SOTG_INTERRUPT_CFG_CDBGMOD | - SOTG_INTERRUPT_CFG_DDBGMODIN | - SOTG_INTERRUPT_CFG_DDBGMODOUT); - - /* enable VBUS and ID interrupt */ - SAF1761_WRITE_2(sc, SOTG_IRQ_ENABLE_CLR, 0xFFFF); - SAF1761_WRITE_2(sc, SOTG_IRQ_ENABLE_SET, - SOTG_IRQ_ID | SOTG_IRQ_VBUS_VLD); - - /* enable interrupts */ - sc->sc_intr_enable = SOTG_DCINTERRUPT_IEVBUS | - SOTG_DCINTERRUPT_IEBRST | SOTG_DCINTERRUPT_IESUSP; - SAF1761_WRITE_4(sc, SOTG_DCINTERRUPT_EN, sc->sc_intr_enable); - - /* connect ATX port 1 to device controller */ - SAF1761_WRITE_2(sc, SOTG_CTRL_CLR, 0xFFFF); - SAF1761_WRITE_2(sc, SOTG_CTRL_SET, SOTG_CTRL_SW_SEL_HC_DC | - SOTG_CTRL_BDIS_ACON_EN); - - /* disable device address */ - SAF1761_WRITE_1(sc, SOTG_ADDRESS, 0); - - /* enable host controller clock */ - SAF1761_WRITE_4(sc, SOTG_POWER_DOWN, SOTG_POWER_DOWN_HC_CLK_EN); - - /* wait 10ms for clock */ - usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 100); - - /* enable configuration flag */ - SAF1761_WRITE_4(sc, SOTG_CONFIGFLAG, SOTG_CONFIGFLAG_ENABLE); - - /* clear RAM block */ - for (x = 0x400; x != 0x10000; x += 4) - SAF1761_WRITE_4(sc, x, 0); - - /* start the HC */ - SAF1761_WRITE_4(sc, SOTG_USBCMD, SOTG_USBCMD_RS); - - /* poll initial VBUS status */ - saf1761_dci_update_vbus(sc); - - USB_BUS_UNLOCK(&sc->sc_bus); - - /* catch any lost interrupts */ - - saf1761_dci_do_poll(&sc->sc_bus); - - return (0); /* success */ -} - -void -saf1761_dci_uninit(struct saf1761_dci_softc *sc) -{ - USB_BUS_LOCK(&sc->sc_bus); - - /* disable all interrupts */ - SAF1761_WRITE_2(sc, SOTG_MODE, 0); - - sc->sc_flags.port_powered = 0; - sc->sc_flags.status_vbus = 0; - sc->sc_flags.status_bus_reset = 0; - sc->sc_flags.status_suspend = 0; - sc->sc_flags.change_suspend = 0; - sc->sc_flags.change_connect = 1; - - saf1761_dci_pull_down(sc); - USB_BUS_UNLOCK(&sc->sc_bus); -} - -static void -saf1761_dci_suspend(struct saf1761_dci_softc *sc) -{ - /* TODO */ -} - -static void -saf1761_dci_resume(struct saf1761_dci_softc *sc) -{ - /* TODO */ -} - -static void -saf1761_dci_do_poll(struct usb_bus *bus) -{ - struct saf1761_dci_softc *sc = SAF1761_DCI_BUS2SC(bus); - - USB_BUS_LOCK(&sc->sc_bus); - saf1761_dci_interrupt_poll(sc); - USB_BUS_UNLOCK(&sc->sc_bus); -} - -/*------------------------------------------------------------------------* - * saf1761_dci control support - * saf1761_dci interrupt support - * saf1761_dci bulk support - *------------------------------------------------------------------------*/ -static void -saf1761_dci_device_non_isoc_open(struct usb_xfer *xfer) -{ - return; -} - -static void -saf1761_dci_device_non_isoc_close(struct usb_xfer *xfer) -{ - saf1761_dci_device_done(xfer, USB_ERR_CANCELLED); -} - -static void -saf1761_dci_device_non_isoc_enter(struct usb_xfer *xfer) -{ - return; -} - -static void -saf1761_dci_device_non_isoc_start(struct usb_xfer *xfer) -{ - /* setup TDs */ - saf1761_dci_setup_standard_chain(xfer); - saf1761_dci_start_standard_chain(xfer); -} - -static const struct usb_pipe_methods saf1761_otg_non_isoc_methods = -{ - .open = saf1761_dci_device_non_isoc_open, - .close = saf1761_dci_device_non_isoc_close, - .enter = saf1761_dci_device_non_isoc_enter, - .start = saf1761_dci_device_non_isoc_start, -}; - -/*------------------------------------------------------------------------* - * saf1761_dci isochronous support - *------------------------------------------------------------------------*/ -static void -saf1761_dci_device_isoc_open(struct usb_xfer *xfer) -{ - return; -} - -static void -saf1761_dci_device_isoc_close(struct usb_xfer *xfer) -{ - saf1761_dci_device_done(xfer, USB_ERR_CANCELLED); -} - -static void -saf1761_dci_device_isoc_enter(struct usb_xfer *xfer) -{ - struct saf1761_dci_softc *sc = SAF1761_DCI_BUS2SC(xfer->xroot->bus); - uint32_t temp; - uint32_t nframes; - - DPRINTFN(6, "xfer=%p next=%d nframes=%d\n", - xfer, xfer->endpoint->isoc_next, xfer->nframes); - - /* get the current frame index - we don't need the high bits */ - - nframes = SAF1761_READ_2(sc, SOTG_FRAME_NUM); - - /* - * check if the frame index is within the window where the - * frames will be inserted - */ - temp = (nframes - xfer->endpoint->isoc_next) & SOTG_FRAME_NUM_SOFR_MASK; - - if ((xfer->endpoint->is_synced == 0) || - (temp < xfer->nframes)) { - /* - * If there is data underflow or the pipe queue is - * empty we schedule the transfer a few frames ahead - * of the current frame position. Else two isochronous - * transfers might overlap. - */ - xfer->endpoint->isoc_next = (nframes + 3) & SOTG_FRAME_NUM_SOFR_MASK; - xfer->endpoint->is_synced = 1; - DPRINTFN(3, "start next=%d\n", xfer->endpoint->isoc_next); - } - /* - * compute how many milliseconds the insertion is ahead of the - * current frame position: - */ - temp = (xfer->endpoint->isoc_next - nframes) & SOTG_FRAME_NUM_SOFR_MASK; - - /* - * pre-compute when the isochronous transfer will be finished: - */ - xfer->isoc_time_complete = - usb_isoc_time_expand(&sc->sc_bus, nframes) + temp + - xfer->nframes; - - /* compute frame number for next insertion */ - xfer->endpoint->isoc_next += xfer->nframes; - - /* setup TDs */ - saf1761_dci_setup_standard_chain(xfer); -} - -static void -saf1761_dci_device_isoc_start(struct usb_xfer *xfer) -{ - /* start TD chain */ - saf1761_dci_start_standard_chain(xfer); -} - -static const struct usb_pipe_methods saf1761_dci_device_isoc_methods = -{ - .open = saf1761_dci_device_isoc_open, - .close = saf1761_dci_device_isoc_close, - .enter = saf1761_dci_device_isoc_enter, - .start = saf1761_dci_device_isoc_start, -}; - -/*------------------------------------------------------------------------* - * saf1761_dci root control support - *------------------------------------------------------------------------* - * Simulate a hardware HUB by handling all the necessary requests. - *------------------------------------------------------------------------*/ - -static const struct usb_device_descriptor saf1761_dci_devd = { - .bLength = sizeof(struct usb_device_descriptor), - .bDescriptorType = UDESC_DEVICE, - .bcdUSB = {0x00, 0x02}, - .bDeviceClass = UDCLASS_HUB, - .bDeviceSubClass = UDSUBCLASS_HUB, - .bDeviceProtocol = UDPROTO_FSHUB, - .bMaxPacketSize = 64, - .bcdDevice = {0x00, 0x01}, - .iManufacturer = 1, - .iProduct = 2, - .bNumConfigurations = 1, -}; - -static const struct usb_device_qualifier saf1761_dci_odevd = { - .bLength = sizeof(struct usb_device_qualifier), - .bDescriptorType = UDESC_DEVICE_QUALIFIER, - .bcdUSB = {0x00, 0x02}, - .bDeviceClass = UDCLASS_HUB, - .bDeviceSubClass = UDSUBCLASS_HUB, - .bDeviceProtocol = UDPROTO_FSHUB, - .bMaxPacketSize0 = 0, - .bNumConfigurations = 0, -}; - -static const struct saf1761_dci_config_desc saf1761_dci_confd = { - .confd = { - .bLength = sizeof(struct usb_config_descriptor), - .bDescriptorType = UDESC_CONFIG, - .wTotalLength[0] = sizeof(saf1761_dci_confd), - .bNumInterface = 1, - .bConfigurationValue = 1, - .iConfiguration = 0, - .bmAttributes = UC_SELF_POWERED, - .bMaxPower = 0, - }, - .ifcd = { - .bLength = sizeof(struct usb_interface_descriptor), - .bDescriptorType = UDESC_INTERFACE, - .bNumEndpoints = 1, - .bInterfaceClass = UICLASS_HUB, - .bInterfaceSubClass = UISUBCLASS_HUB, - .bInterfaceProtocol = 0, - }, - - .endpd = { - .bLength = sizeof(struct usb_endpoint_descriptor), - .bDescriptorType = UDESC_ENDPOINT, - .bEndpointAddress = (UE_DIR_IN | SAF1761_DCI_INTR_ENDPT), - .bmAttributes = UE_INTERRUPT, - .wMaxPacketSize[0] = 8, - .bInterval = 255, - }, -}; - -#define HSETW(ptr, val) ptr = { (uint8_t)(val), (uint8_t)((val) >> 8) } - -static const struct usb_hub_descriptor_min saf1761_dci_hubd = { - .bDescLength = sizeof(saf1761_dci_hubd), - .bDescriptorType = UDESC_HUB, - .bNbrPorts = SOTG_NUM_PORTS, - HSETW(.wHubCharacteristics, (UHD_PWR_NO_SWITCH | UHD_OC_INDIVIDUAL)), - .bPwrOn2PwrGood = 50, - .bHubContrCurrent = 0, - .DeviceRemovable = {0}, /* port is removable */ -}; - -#define STRING_VENDOR \ - "N\0X\0P" - -#define STRING_PRODUCT \ - "D\0C\0I\0 \0R\0o\0o\0t\0 \0H\0U\0B" - -USB_MAKE_STRING_DESC(STRING_VENDOR, saf1761_dci_vendor); -USB_MAKE_STRING_DESC(STRING_PRODUCT, saf1761_dci_product); - -static usb_error_t -saf1761_dci_roothub_exec(struct usb_device *udev, - struct usb_device_request *req, const void **pptr, uint16_t *plength) -{ - struct saf1761_dci_softc *sc = SAF1761_DCI_BUS2SC(udev->bus); - const void *ptr; - uint16_t len; - uint16_t value; - uint16_t index; - uint32_t temp; - uint32_t i; - usb_error_t err; - - USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED); - - /* buffer reset */ - ptr = (const void *)&sc->sc_hub_temp; - len = 0; - err = 0; - - value = UGETW(req->wValue); - index = UGETW(req->wIndex); - - /* demultiplex the control request */ - - switch (req->bmRequestType) { - case UT_READ_DEVICE: - switch (req->bRequest) { - case UR_GET_DESCRIPTOR: - goto tr_handle_get_descriptor; - case UR_GET_CONFIG: - goto tr_handle_get_config; - case UR_GET_STATUS: - goto tr_handle_get_status; - default: - goto tr_stalled; - } - break; - - case UT_WRITE_DEVICE: - switch (req->bRequest) { - case UR_SET_ADDRESS: - goto tr_handle_set_address; - case UR_SET_CONFIG: - goto tr_handle_set_config; - case UR_CLEAR_FEATURE: - goto tr_valid; /* nop */ - case UR_SET_DESCRIPTOR: - goto tr_valid; /* nop */ - case UR_SET_FEATURE: - default: - goto tr_stalled; - } - break; - - case UT_WRITE_ENDPOINT: - switch (req->bRequest) { - case UR_CLEAR_FEATURE: - switch (UGETW(req->wValue)) { - case UF_ENDPOINT_HALT: - goto tr_handle_clear_halt; - case UF_DEVICE_REMOTE_WAKEUP: - goto tr_handle_clear_wakeup; - default: - goto tr_stalled; - } - break; - case UR_SET_FEATURE: - switch (UGETW(req->wValue)) { - case UF_ENDPOINT_HALT: - goto tr_handle_set_halt; - case UF_DEVICE_REMOTE_WAKEUP: - goto tr_handle_set_wakeup; - default: - goto tr_stalled; - } - break; - case UR_SYNCH_FRAME: - goto tr_valid; /* nop */ - default: - goto tr_stalled; - } - break; - - case UT_READ_ENDPOINT: - switch (req->bRequest) { - case UR_GET_STATUS: - goto tr_handle_get_ep_status; - default: - goto tr_stalled; - } - break; - - case UT_WRITE_INTERFACE: - switch (req->bRequest) { - case UR_SET_INTERFACE: - goto tr_handle_set_interface; - case UR_CLEAR_FEATURE: - goto tr_valid; /* nop */ - case UR_SET_FEATURE: - default: - goto tr_stalled; - } - break; - - case UT_READ_INTERFACE: - switch (req->bRequest) { - case UR_GET_INTERFACE: - goto tr_handle_get_interface; - case UR_GET_STATUS: - goto tr_handle_get_iface_status; - default: - goto tr_stalled; - } - break; - - case UT_WRITE_CLASS_INTERFACE: - case UT_WRITE_VENDOR_INTERFACE: - /* XXX forward */ - break; - - case UT_READ_CLASS_INTERFACE: - case UT_READ_VENDOR_INTERFACE: - /* XXX forward */ - break; - - case UT_WRITE_CLASS_DEVICE: - switch (req->bRequest) { - case UR_CLEAR_FEATURE: - goto tr_valid; - case UR_SET_DESCRIPTOR: - case UR_SET_FEATURE: - break; - default: - goto tr_stalled; - } - break; - - case UT_WRITE_CLASS_OTHER: - switch (req->bRequest) { - case UR_CLEAR_FEATURE: - if (index == SOTG_HOST_PORT_NUM) - goto tr_handle_clear_port_feature_host; - else if (index == SOTG_DEVICE_PORT_NUM) - goto tr_handle_clear_port_feature_device; - else - goto tr_stalled; - case UR_SET_FEATURE: - if (index == SOTG_HOST_PORT_NUM) - goto tr_handle_set_port_feature_host; - else if (index == SOTG_DEVICE_PORT_NUM) - goto tr_handle_set_port_feature_device; - else - goto tr_stalled; - case UR_CLEAR_TT_BUFFER: - case UR_RESET_TT: - case UR_STOP_TT: - goto tr_valid; - - default: - goto tr_stalled; - } - break; - - case UT_READ_CLASS_OTHER: - switch (req->bRequest) { - case UR_GET_TT_STATE: - goto tr_handle_get_tt_state; - case UR_GET_STATUS: - if (index == SOTG_HOST_PORT_NUM) - goto tr_handle_get_port_status_host; - else if (index == SOTG_DEVICE_PORT_NUM) - goto tr_handle_get_port_status_device; - else - goto tr_stalled; - default: - goto tr_stalled; - } - break; - - case UT_READ_CLASS_DEVICE: - switch (req->bRequest) { - case UR_GET_DESCRIPTOR: - goto tr_handle_get_class_descriptor; - case UR_GET_STATUS: - goto tr_handle_get_class_status; - - default: - goto tr_stalled; - } - break; - default: - goto tr_stalled; - } - goto tr_valid; - -tr_handle_get_descriptor: - switch (value >> 8) { - case UDESC_DEVICE: - if (value & 0xff) - goto tr_stalled; - len = sizeof(saf1761_dci_devd); - ptr = (const void *)&saf1761_dci_devd; - goto tr_valid; - case UDESC_DEVICE_QUALIFIER: - if (value & 0xff) - goto tr_stalled; - len = sizeof(saf1761_dci_odevd); - ptr = (const void *)&saf1761_dci_odevd; - goto tr_valid; - case UDESC_CONFIG: - if (value & 0xff) - goto tr_stalled; - len = sizeof(saf1761_dci_confd); - ptr = (const void *)&saf1761_dci_confd; - goto tr_valid; - case UDESC_STRING: - switch (value & 0xff) { - case 0: /* Language table */ - len = sizeof(usb_string_lang_en); - ptr = (const void *)&usb_string_lang_en; - goto tr_valid; - - case 1: /* Vendor */ - len = sizeof(saf1761_dci_vendor); - ptr = (const void *)&saf1761_dci_vendor; - goto tr_valid; - - case 2: /* Product */ - len = sizeof(saf1761_dci_product); - ptr = (const void *)&saf1761_dci_product; - goto tr_valid; - default: - break; - } - break; - default: - goto tr_stalled; - } - goto tr_stalled; - -tr_handle_get_config: - len = 1; - sc->sc_hub_temp.wValue[0] = sc->sc_conf; - goto tr_valid; - -tr_handle_get_status: - len = 2; - USETW(sc->sc_hub_temp.wValue, UDS_SELF_POWERED); - goto tr_valid; - -tr_handle_set_address: - if (value & 0xFF00) - goto tr_stalled; - - sc->sc_rt_addr = value; - goto tr_valid; - -tr_handle_set_config: - if (value >= 2) - goto tr_stalled; - sc->sc_conf = value; - goto tr_valid; - -tr_handle_get_interface: - len = 1; - sc->sc_hub_temp.wValue[0] = 0; - goto tr_valid; - -tr_handle_get_tt_state: -tr_handle_get_class_status: -tr_handle_get_iface_status: -tr_handle_get_ep_status: - len = 2; - USETW(sc->sc_hub_temp.wValue, 0); - goto tr_valid; - -tr_handle_set_halt: -tr_handle_set_interface: -tr_handle_set_wakeup: -tr_handle_clear_wakeup: -tr_handle_clear_halt: - goto tr_valid; - -tr_handle_clear_port_feature_device: - DPRINTFN(9, "UR_CLEAR_FEATURE on port %d\n", index); - - switch (value) { - case UHF_PORT_SUSPEND: - saf1761_dci_wakeup_peer(sc); - break; - - case UHF_PORT_ENABLE: - sc->sc_flags.port_enabled = 0; - break; - - case UHF_PORT_TEST: - case UHF_PORT_INDICATOR: - case UHF_C_PORT_ENABLE: - case UHF_C_PORT_OVER_CURRENT: - case UHF_C_PORT_RESET: - /* nops */ - break; - case UHF_PORT_POWER: - sc->sc_flags.port_powered = 0; - saf1761_dci_pull_down(sc); - break; - case UHF_C_PORT_CONNECTION: - sc->sc_flags.change_connect = 0; - break; - case UHF_C_PORT_SUSPEND: - sc->sc_flags.change_suspend = 0; - break; - default: - err = USB_ERR_IOERROR; - goto tr_valid; - } - goto tr_valid; - -tr_handle_clear_port_feature_host: - DPRINTFN(9, "UR_CLEAR_FEATURE on port %d\n", index); - - temp = SAF1761_READ_4(sc, SOTG_PORTSC1); - - switch (value) { - case UHF_PORT_ENABLE: - SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp & ~SOTG_PORTSC1_PED); - break; - case UHF_PORT_SUSPEND: - if ((temp & SOTG_PORTSC1_SUSP) && (!(temp & SOTG_PORTSC1_FPR))) - SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp | SOTG_PORTSC1_FPR); - - /* wait 20ms for resume sequence to complete */ - usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 50); - - SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp & ~(SOTG_PORTSC1_SUSP | - SOTG_PORTSC1_FPR | SOTG_PORTSC1_LS /* High Speed */ )); - - /* 4ms settle time */ - usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 250); - break; - case UHF_PORT_INDICATOR: - SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp & ~SOTG_PORTSC1_PIC); - break; - case UHF_PORT_TEST: - case UHF_C_PORT_ENABLE: - case UHF_C_PORT_OVER_CURRENT: - case UHF_C_PORT_RESET: - case UHF_C_PORT_SUSPEND: - /* NOPs */ - break; - case UHF_PORT_POWER: - SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp & ~SOTG_PORTSC1_PP); - break; - case UHF_C_PORT_CONNECTION: - SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp & ~SOTG_PORTSC1_ECSC); - break; - default: - err = USB_ERR_IOERROR; - goto tr_valid; - } - goto tr_valid; - -tr_handle_set_port_feature_device: - DPRINTFN(9, "UR_SET_FEATURE on port %d\n", index); - - switch (value) { - case UHF_PORT_ENABLE: - sc->sc_flags.port_enabled = 1; - break; - case UHF_PORT_SUSPEND: - case UHF_PORT_RESET: - case UHF_PORT_TEST: - case UHF_PORT_INDICATOR: - /* nops */ - break; - case UHF_PORT_POWER: - sc->sc_flags.port_powered = 1; - break; - default: - err = USB_ERR_IOERROR; - goto tr_valid; - } - goto tr_valid; - -tr_handle_set_port_feature_host: - DPRINTFN(9, "UR_SET_FEATURE on port %d\n", index); - - temp = SAF1761_READ_4(sc, SOTG_PORTSC1); - - switch (value) { - case UHF_PORT_ENABLE: - SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp | SOTG_PORTSC1_PED); - break; - case UHF_PORT_SUSPEND: - SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp | SOTG_PORTSC1_SUSP); - break; - case UHF_PORT_RESET: - DPRINTFN(6, "reset port %d\n", index); - - /* Start reset sequence. */ - temp &= ~(SOTG_PORTSC1_PED | SOTG_PORTSC1_PR); - - SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp | SOTG_PORTSC1_PR); - - /* Wait for reset to complete. */ - usb_pause_mtx(&sc->sc_bus.bus_mtx, - USB_MS_TO_TICKS(usb_port_root_reset_delay)); - - SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp); - - /* Wait for HC to complete reset. */ - usb_pause_mtx(&sc->sc_bus.bus_mtx, USB_MS_TO_TICKS(2)); - - temp = SAF1761_READ_4(sc, SOTG_PORTSC1); - - DPRINTF("After reset, status=0x%08x\n", temp); - if (temp & SOTG_PORTSC1_PR) { - device_printf(sc->sc_bus.bdev, "port reset timeout\n"); - err = USB_ERR_TIMEOUT; - goto tr_valid; - } - if (!(temp & SOTG_PORTSC1_PED)) { - /* Not a high speed device, give up ownership.*/ - SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp | SOTG_PORTSC1_PO); - break; - } - sc->sc_isreset = 1; - DPRINTF("port %d reset, status = 0x%08x\n", index, temp); - break; - case UHF_PORT_POWER: - DPRINTFN(3, "set port power %d\n", index); - SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp | SOTG_PORTSC1_PP); - break; - - case UHF_PORT_TEST: - DPRINTFN(3, "set port test %d\n", index); - break; - - case UHF_PORT_INDICATOR: - DPRINTFN(3, "set port ind %d\n", index); - SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp | SOTG_PORTSC1_PIC); - break; - default: - err = USB_ERR_IOERROR; - goto tr_valid; - } - goto tr_valid; - -tr_handle_get_port_status_device: - - DPRINTFN(9, "UR_GET_PORT_STATUS on port %d\n", index); - - if (sc->sc_flags.status_vbus) { - saf1761_dci_pull_up(sc); - } else { - saf1761_dci_pull_down(sc); - } - - /* Select FULL-speed and Device Side Mode */ - - value = UPS_PORT_MODE_DEVICE; - - if (sc->sc_flags.port_powered) - value |= UPS_PORT_POWER; - - if (sc->sc_flags.port_enabled) - value |= UPS_PORT_ENABLED; - - if (sc->sc_flags.status_vbus && - sc->sc_flags.status_bus_reset) - value |= UPS_CURRENT_CONNECT_STATUS; - - if (sc->sc_flags.status_suspend) - value |= UPS_SUSPEND; - - USETW(sc->sc_hub_temp.ps.wPortStatus, value); - - value = 0; - - if (sc->sc_flags.change_connect) - value |= UPS_C_CONNECT_STATUS; - - if (sc->sc_flags.change_suspend) - value |= UPS_C_SUSPEND; - - USETW(sc->sc_hub_temp.ps.wPortChange, value); - len = sizeof(sc->sc_hub_temp.ps); - goto tr_valid; - -tr_handle_get_port_status_host: - - temp = SAF1761_READ_4(sc, SOTG_PORTSC1); - - DPRINTFN(9, "port status=0x%04x\n", temp); - i = UPS_HIGH_SPEED; - - if (temp & SOTG_PORTSC1_ECCS) - i |= UPS_CURRENT_CONNECT_STATUS; - if (temp & SOTG_PORTSC1_PED) - i |= UPS_PORT_ENABLED; - if ((temp & SOTG_PORTSC1_SUSP) && !(temp & SOTG_PORTSC1_FPR)) - i |= UPS_SUSPEND; - if (temp & SOTG_PORTSC1_PR) - i |= UPS_RESET; - if (temp & SOTG_PORTSC1_PP) - i |= UPS_PORT_POWER; - - USETW(sc->sc_hub_temp.ps.wPortStatus, i); - i = 0; - - if (temp & SOTG_PORTSC1_ECSC) - i |= UPS_C_CONNECT_STATUS; - if (temp & SOTG_PORTSC1_FPR) - i |= UPS_C_SUSPEND; - if (sc->sc_isreset) - i |= UPS_C_PORT_RESET; - USETW(sc->sc_hub_temp.ps.wPortChange, i); - len = sizeof(sc->sc_hub_temp.ps); - goto tr_valid; - -tr_handle_get_class_descriptor: - if (value & 0xFF) - goto tr_stalled; - ptr = (const void *)&saf1761_dci_hubd; - len = sizeof(saf1761_dci_hubd); - goto tr_valid; - -tr_stalled: - err = USB_ERR_STALLED; -tr_valid: - *plength = len; - *pptr = ptr; - return (err); -} - -static void -saf1761_dci_xfer_setup(struct usb_setup_params *parm) -{ - struct saf1761_dci_softc *sc; - struct usb_xfer *xfer; - void *last_obj; - uint32_t dw1; - uint32_t ntd; - uint32_t n; - uint8_t ep_no; - uint8_t ep_type; - - sc = SAF1761_DCI_BUS2SC(parm->udev->bus); - xfer = parm->curr_xfer; - - /* - * NOTE: This driver does not use any of the parameters that - * are computed from the following values. Just set some - * reasonable dummies: - */ - parm->hc_max_packet_size = 0x500; - parm->hc_max_packet_count = 1; - parm->hc_max_frame_size = 0x500; - - usbd_transfer_setup_sub(parm); - - /* - * Compute maximum number of TDs: - */ - ep_type = (xfer->endpoint->edesc->bmAttributes & UE_XFERTYPE); - - if (ep_type == UE_CONTROL) { - - ntd = xfer->nframes + 1 /* STATUS */ + 1 /* SYNC */ ; - - } else { - ntd = xfer->nframes + 1 /* SYNC */ ; - } - - /* - * check if "usbd_transfer_setup_sub" set an error - */ - if (parm->err) - return; - - /* - * allocate transfer descriptors - */ - last_obj = NULL; - - ep_no = xfer->endpointno & UE_ADDR; - - /* - * Check profile stuff - */ - if (parm->udev->flags.usb_mode == USB_MODE_DEVICE) { - const struct usb_hw_ep_profile *pf; - - saf1761_dci_get_hw_ep_profile(parm->udev, &pf, ep_no); - - if (pf == NULL) { - /* should not happen */ - parm->err = USB_ERR_INVAL; - return; - } - } - - dw1 = (xfer->address << 3) | (ep_type << 12); - - switch (parm->udev->speed) { - case USB_SPEED_FULL: - case USB_SPEED_LOW: - /* check if root HUB port is running High Speed */ - if (parm->udev->parent_hs_hub != NULL) { - dw1 |= (1 << 14); - dw1 |= (parm->udev->hs_port_no << 18); - dw1 |= (parm->udev->hs_hub_addr << 25); - if (parm->udev->speed == USB_SPEED_LOW) - dw1 |= (1 << 17); - } - break; - default: - break; - } - - /* align data */ - parm->size[0] += ((-parm->size[0]) & (USB_HOST_ALIGN - 1)); - - for (n = 0; n != ntd; n++) { - - struct saf1761_dci_td *td; - - if (parm->buf) { - - td = USB_ADD_BYTES(parm->buf, parm->size[0]); - - /* init TD */ - td->max_packet_size = xfer->max_packet_size; - td->ep_index = ep_no; - td->ep_type = ep_type; - td->dw1_value = dw1; - - td->obj_next = last_obj; - - last_obj = td; - } - parm->size[0] += sizeof(*td); - } - - xfer->td_start[0] = last_obj; -} - -static void -saf1761_dci_xfer_unsetup(struct usb_xfer *xfer) -{ -} - -static void -saf1761_dci_ep_init(struct usb_device *udev, struct usb_endpoint_descriptor *edesc, - struct usb_endpoint *ep) -{ - struct saf1761_dci_softc *sc = SAF1761_DCI_BUS2SC(udev->bus); - - DPRINTFN(2, "endpoint=%p, addr=%d, endpt=%d, mode=%d (%d)\n", - ep, udev->address, - edesc->bEndpointAddress, udev->flags.usb_mode, - sc->sc_rt_addr); - - if (udev->parent_hub == NULL) { - /* root HUB has special endpoint handling */ - return; - } - - if (udev->flags.usb_mode == USB_MODE_DEVICE) { - if (udev->speed != USB_SPEED_FULL && - udev->speed != USB_SPEED_HIGH) { - /* not supported */ - return; - } - switch (edesc->bmAttributes & UE_XFERTYPE) { - case UE_ISOCHRONOUS: - ep->methods = &saf1761_dci_device_isoc_methods; - break; - default: - ep->methods = &saf1761_otg_non_isoc_methods; - break; - } - } else { - switch (edesc->bmAttributes & UE_XFERTYPE) { - case UE_CONTROL: - case UE_BULK: - ep->methods = &saf1761_otg_non_isoc_methods; - break; - default: - /* TODO */ - break; - } - } -} - -static void -saf1761_dci_set_hw_power_sleep(struct usb_bus *bus, uint32_t state) -{ - struct saf1761_dci_softc *sc = SAF1761_DCI_BUS2SC(bus); - - switch (state) { - case USB_HW_POWER_SUSPEND: - saf1761_dci_suspend(sc); - break; - case USB_HW_POWER_SHUTDOWN: - saf1761_dci_uninit(sc); - break; - case USB_HW_POWER_RESUME: - saf1761_dci_resume(sc); - break; - default: - break; - } -} - -static const struct usb_bus_methods saf1761_dci_bus_methods = -{ - .endpoint_init = &saf1761_dci_ep_init, - .xfer_setup = &saf1761_dci_xfer_setup, - .xfer_unsetup = &saf1761_dci_xfer_unsetup, - .get_hw_ep_profile = &saf1761_dci_get_hw_ep_profile, - .xfer_stall = &saf1761_dci_xfer_stall, - .set_stall = &saf1761_dci_set_stall, - .clear_stall = &saf1761_dci_clear_stall, - .roothub_exec = &saf1761_dci_roothub_exec, - .xfer_poll = &saf1761_dci_do_poll, - .set_hw_power_sleep = saf1761_dci_set_hw_power_sleep, -}; diff --git a/sys/dev/usb/controller/saf1761_dci.h b/sys/dev/usb/controller/saf1761_dci.h deleted file mode 100644 index 0fde2f58443bd..0000000000000 --- a/sys/dev/usb/controller/saf1761_dci.h +++ /dev/null @@ -1,157 +0,0 @@ -/* $FreeBSD$ */ -/*- - * Copyright (c) 2014 Hans Petter Selasky - * All rights reserved. - * - * This software was developed by SRI International and the University of - * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) - * ("CTSRD"), as part of the DARPA CRASH research programme. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _SAF1761_DCI_H_ -#define _SAF1761_DCI_H_ - -#define SOTG_MAX_DEVICES (USB_MIN_DEVICES + 1) -#define SOTG_FS_MAX_PACKET_SIZE 64 -#define SOTG_HS_MAX_PACKET_SIZE 512 -#define SOTG_NUM_PORTS 2 /* one Device and one Host port */ -#define SOTG_HOST_PORT_NUM 1 -#define SOTG_DEVICE_PORT_NUM 2 -#define SOTG_HOST_CHANNEL_MAX (3 * 32) - -#define SAF1761_READ_1(sc, reg) \ - bus_space_read_1((sc)->sc_io_tag, (sc)->sc_io_hdl, reg) -#define SAF1761_READ_2(sc, reg) \ - bus_space_read_2((sc)->sc_io_tag, (sc)->sc_io_hdl, reg) -#define SAF1761_READ_4(sc, reg) \ - bus_space_read_4((sc)->sc_io_tag, (sc)->sc_io_hdl, reg) - -#define SAF1761_WRITE_1(sc, reg, data) \ - bus_space_write_1((sc)->sc_io_tag, (sc)->sc_io_hdl, reg, data) -#define SAF1761_WRITE_2(sc, reg, data) \ - bus_space_write_2((sc)->sc_io_tag, (sc)->sc_io_hdl, reg, data) -#define SAF1761_WRITE_4(sc, reg, data) \ - bus_space_write_4((sc)->sc_io_tag, (sc)->sc_io_hdl, reg, data) - -struct saf1761_dci_softc; -struct saf1761_dci_td; - -typedef uint8_t (saf1761_dci_cmd_t)(struct saf1761_dci_softc *, struct saf1761_dci_td *td); - -struct saf1761_dci_td { - struct saf1761_dci_td *obj_next; - saf1761_dci_cmd_t *func; - struct usb_page_cache *pc; - uint32_t offset; - uint32_t remainder; - uint32_t dw1_value; - uint16_t max_packet_size; - uint8_t ep_index; - uint8_t ep_type; - uint8_t channel; - uint8_t error_any:1; - uint8_t error_stall:1; - uint8_t alt_next:1; - uint8_t short_pkt:1; - uint8_t did_stall:1; - uint8_t toggle:1; - uint8_t set_toggle:1; -}; - -struct saf1761_dci_std_temp { - saf1761_dci_cmd_t *func; - struct usb_page_cache *pc; - struct saf1761_dci_td *td; - struct saf1761_dci_td *td_next; - uint32_t len; - uint32_t offset; - uint16_t max_frame_size; - uint8_t short_pkt; - /* - * short_pkt = 0: transfer should be short terminated - * short_pkt = 1: transfer should not be short terminated - */ - uint8_t setup_alt_next; - uint8_t did_stall; -}; - -struct saf1761_dci_config_desc { - struct usb_config_descriptor confd; - struct usb_interface_descriptor ifcd; - struct usb_endpoint_descriptor endpd; -} __packed; - -union saf1761_dci_hub_temp { - uWord wValue; - struct usb_port_status ps; -}; - -struct saf1761_dci_flags { - uint8_t change_connect:1; - uint8_t change_suspend:1; - uint8_t status_suspend:1; /* set if suspended */ - uint8_t status_vbus:1; /* set if present */ - uint8_t status_bus_reset:1; /* set if reset complete */ - uint8_t clocks_off:1; - uint8_t port_powered:1; - uint8_t port_enabled:1; - uint8_t d_pulled_up:1; -}; - -struct saf1761_dci_softc { - struct usb_bus sc_bus; - union saf1761_dci_hub_temp sc_hub_temp; - - struct usb_device *sc_devices[SOTG_MAX_DEVICES]; - struct resource *sc_io_res; - struct resource *sc_irq_res; - void *sc_intr_hdl; - bus_size_t sc_io_size; - bus_space_tag_t sc_io_tag; - bus_space_handle_t sc_io_hdl; - - uint32_t sc_host_async_map; - uint32_t sc_host_intr_map; - uint32_t sc_host_isoc_map; - uint32_t sc_intr_enable; /* enabled interrupts */ - uint32_t sc_hw_mode; /* hardware mode */ - - uint8_t sc_bounce_buffer[1024] __aligned(4); - uint8_t sc_rt_addr; /* root HUB address */ - uint8_t sc_dv_addr; /* device address */ - uint8_t sc_conf; /* root HUB config */ - uint8_t sc_isreset; /* host mode */ - - uint8_t sc_hub_idata[1]; - - struct saf1761_dci_flags sc_flags; -}; - -/* prototypes */ - -usb_error_t saf1761_dci_init(struct saf1761_dci_softc *sc); -void saf1761_dci_uninit(struct saf1761_dci_softc *sc); -void saf1761_dci_interrupt(struct saf1761_dci_softc *sc); - -#endif /* _SAF1761_DCI_H_ */ diff --git a/sys/dev/usb/controller/saf1761_dci_fdt.c b/sys/dev/usb/controller/saf1761_dci_fdt.c deleted file mode 100644 index 3927c7358b3d5..0000000000000 --- a/sys/dev/usb/controller/saf1761_dci_fdt.c +++ /dev/null @@ -1,253 +0,0 @@ -/* $FreeBSD$ */ -/*- - * Copyright (c) 2014 Hans Petter Selasky - * All rights reserved. - * - * This software was developed by SRI International and the University of - * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) - * ("CTSRD"), as part of the DARPA CRASH research programme. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifdef USB_GLOBAL_INCLUDE_FILE -#include USB_GLOBAL_INCLUDE_FILE -#else -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#endif /* USB_GLOBAL_INCLUDE_FILE */ - -#include -#include - -static device_probe_t saf1761_dci_fdt_probe; -static device_attach_t saf1761_dci_fdt_attach; -static device_detach_t saf1761_dci_fdt_detach; - -static device_method_t saf1761_dci_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, saf1761_dci_fdt_probe), - DEVMETHOD(device_attach, saf1761_dci_fdt_attach), - DEVMETHOD(device_detach, saf1761_dci_fdt_detach), - DEVMETHOD(device_suspend, bus_generic_suspend), - DEVMETHOD(device_resume, bus_generic_resume), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - - DEVMETHOD_END -}; - -static driver_t saf1761_dci_driver = { - .name = "saf1761", - .methods = saf1761_dci_methods, - .size = sizeof(struct saf1761_dci_softc), -}; - -static devclass_t saf1761_dci_devclass; - -DRIVER_MODULE(saf1761, simplebus, saf1761_dci_driver, saf1761_dci_devclass, 0, 0); -MODULE_DEPEND(saf1761, usb, 1, 1, 1); - -static int -saf1761_dci_fdt_probe(device_t dev) -{ - if (!ofw_bus_status_okay(dev)) - return (ENXIO); - - if (!ofw_bus_is_compatible(dev, "nxp,usb-isp1761")) - return (ENXIO); - - device_set_desc(dev, "ISP1761/SAF1761 DCI USB 2.0 Device Controller"); - - return (0); -} - -static int -saf1761_dci_fdt_attach(device_t dev) -{ - struct saf1761_dci_softc *sc = device_get_softc(dev); - char param[24]; - int err; - int rid; - - /* get configuration from FDT */ - - /* get bus-width, if any */ - if (OF_getprop(ofw_bus_get_node(dev), "bus-width", - ¶m, sizeof(param)) > 0) { - param[sizeof(param) - 1] = 0; - if (strcmp(param, "32") == 0) - sc->sc_hw_mode |= SOTG_HW_MODE_CTRL_DATA_BUS_WIDTH; - } else { - /* assume 32-bit data bus */ - sc->sc_hw_mode |= SOTG_HW_MODE_CTRL_DATA_BUS_WIDTH; - } - - /* get analog over-current setting */ - if (OF_getprop(ofw_bus_get_node(dev), "analog-oc", - ¶m, sizeof(param)) > 0) { - sc->sc_hw_mode |= SOTG_HW_MODE_CTRL_ANA_DIGI_OC; - } - - /* get DACK polarity */ - if (OF_getprop(ofw_bus_get_node(dev), "dack-polarity", - ¶m, sizeof(param)) > 0) { - sc->sc_hw_mode |= SOTG_HW_MODE_CTRL_DACK_POL; - } - - /* get DREQ polarity */ - if (OF_getprop(ofw_bus_get_node(dev), "dreq-polarity", - ¶m, sizeof(param)) > 0) { - sc->sc_hw_mode |= SOTG_HW_MODE_CTRL_DREQ_POL; - } - - /* initialise some bus fields */ - sc->sc_bus.parent = dev; - sc->sc_bus.devices = sc->sc_devices; - sc->sc_bus.devices_max = SOTG_MAX_DEVICES; - - /* get all DMA memory */ - if (usb_bus_mem_alloc_all(&sc->sc_bus, - USB_GET_DMA_TAG(dev), NULL)) { - return (ENOMEM); - } - rid = 0; - sc->sc_io_res = - bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, RF_ACTIVE); - - if (!sc->sc_io_res) { - goto error; - } - sc->sc_io_tag = rman_get_bustag(sc->sc_io_res); - sc->sc_io_hdl = rman_get_bushandle(sc->sc_io_res); - sc->sc_io_size = rman_get_size(sc->sc_io_res); - - rid = 0; - sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, - RF_SHAREABLE | RF_ACTIVE); - if (sc->sc_irq_res == NULL) { - goto error; - } - sc->sc_bus.bdev = device_add_child(dev, "usbus", -1); - if (!(sc->sc_bus.bdev)) { - goto error; - } - device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus); - - err = bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE, - NULL, (driver_intr_t *)saf1761_dci_interrupt, sc, &sc->sc_intr_hdl); - if (err) { - sc->sc_intr_hdl = NULL; - goto error; - } - err = saf1761_dci_init(sc); - if (err) { - device_printf(dev, "Init failed\n"); - goto error; - } - err = device_probe_and_attach(sc->sc_bus.bdev); - if (err) { - device_printf(dev, "USB probe and attach failed\n"); - goto error; - } - return (0); - -error: - saf1761_dci_fdt_detach(dev); - return (ENXIO); -} - -static int -saf1761_dci_fdt_detach(device_t dev) -{ - struct saf1761_dci_softc *sc = device_get_softc(dev); - device_t bdev; - int err; - - if (sc->sc_bus.bdev) { - bdev = sc->sc_bus.bdev; - device_detach(bdev); - device_delete_child(dev, bdev); - } - /* during module unload there are lots of children leftover */ - device_delete_children(dev); - - if (sc->sc_irq_res && sc->sc_intr_hdl) { - /* - * Only call uninit() after init() - */ - saf1761_dci_uninit(sc); - - err = bus_teardown_intr(dev, sc->sc_irq_res, - sc->sc_intr_hdl); - sc->sc_intr_hdl = NULL; - } - if (sc->sc_irq_res) { - bus_release_resource(dev, SYS_RES_IRQ, 0, - sc->sc_irq_res); - sc->sc_irq_res = NULL; - } - if (sc->sc_io_res) { - bus_release_resource(dev, SYS_RES_IOPORT, 0, - sc->sc_io_res); - sc->sc_io_res = NULL; - } - usb_bus_mem_free_all(&sc->sc_bus, NULL); - - return (0); -} diff --git a/sys/dev/usb/controller/saf1761_dci_reg.h b/sys/dev/usb/controller/saf1761_dci_reg.h deleted file mode 100644 index 4d4dd8611f2d8..0000000000000 --- a/sys/dev/usb/controller/saf1761_dci_reg.h +++ /dev/null @@ -1,214 +0,0 @@ -/* $FreeBSD$ */ -/*- - * Copyright (c) 2014 Hans Petter Selasky - * All rights reserved. - * - * This software was developed by SRI International and the University of - * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) - * ("CTSRD"), as part of the DARPA CRASH research programme. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _SAF1761_DCI_REG_H_ -#define _SAF1761_DCI_REG_H_ - -/* Global registers */ - -#define SOTG_VEND_ID 0x370 -#define SOTG_PROD_ID 0x372 -#define SOTG_CTRL_SET 0x374 -#define SOTG_CTRL_CLR 0x376 -#define SOTG_CTRL_OTG_DISABLE (1 << 10) -#define SOTG_CTRL_OTG_SE0_EN (1 << 9) -#define SOTG_CTRL_BDIS_ACON_EN (1 << 8) -#define SOTG_CTRL_SW_SEL_HC_DC (1 << 7) -#define SOTG_CTRL_VBUS_CHRG (1 << 6) -#define SOTG_CTRL_VBUS_DISCHRG (1 << 5) -#define SOTG_CTRL_VBUS_DRV (1 << 4) -#define SOTG_CTRL_SEL_CP_EXT (1 << 3) -#define SOTG_CTRL_DM_PULL_DOWN (1 << 2) -#define SOTG_CTRL_DP_PULL_DOWN (1 << 1) -#define SOTG_CTRL_DP_PULL_UP (1 << 0) -#define SOTG_STATUS 0x378 -#define SOTG_STATUS_B_SE0_SRP (1 << 8) -#define SOTG_STATUS_B_SESS_END (1 << 7) -#define SOTG_STATUS_RMT_CONN (1 << 4) -#define SOTG_STATUS_ID (1 << 3) -#define SOTG_STATUS_DP_SRP (1 << 2) -#define SOTG_STATUS_A_B_SESS_VLD (1 << 1) -#define SOTG_STATUS_VBUS_VLD (1 << 0) -#define SOTG_IRQ_LATCH_SET 0x37C -#define SOTG_IRQ_LATCH_CLR 0x37E -#define SOTG_IRQ_ENABLE_SET 0x380 -#define SOTG_IRQ_ENABLE_CLR 0x382 -#define SOTG_IRQ_RISE_SET 0x384 -#define SOTG_IRQ_RISE_CLR 0x386 -#define SOTG_IRQ_OTG_TMR_TIMEOUT (1 << 9) -#define SOTG_IRQ_B_SE0_SRP (1 << 8) -#define SOTG_IRQ_B_SESS_END (1 << 7) -#define SOTG_IRQ_BDIS_ACON (1 << 6) -#define SOTG_IRQ_OTG_RESUME (1 << 5) -#define SOTG_IRQ_RMT_CONN (1 << 4) -#define SOTG_IRQ_ID (1 << 3) -#define SOTG_IRQ_DP_SRP (1 << 2) -#define SOTG_IRQ_A_B_SESS_VLD (1 << 1) -#define SOTG_IRQ_VBUS_VLD (1 << 0) -#define SOTG_TIMER_LOW_SET 0x388 -#define SOTG_TIMER_LOW_CLR 0x38A -#define SOTG_TIMER_HIGH_SET 0x38C -#define SOTG_TIMER_HIGH_CLR 0x38E -#define SOTG_TIMER_START_TMR (1U << 15) - -/* Peripheral controller specific registers */ - -#define SOTG_ADDRESS 0x200 -#define SOTG_ADDRESS_ENABLE (1 << 7) -#define SOTG_MODE 0x20C -#define SOTG_MODE_DMACLK_ON (1 << 9) -#define SOTG_MODE_VBUSSTAT (1 << 8) -#define SOTG_MODE_CLKAON (1 << 7) -#define SOTG_MODE_SNDRSU (1 << 6) -#define SOTG_MODE_GOSUSP (1 << 5) -#define SOTG_MODE_SFRESET (1 << 4) -#define SOTG_MODE_GLINTENA (1 << 3) -#define SOTG_MODE_WKUPCS (1 << 2) -#define SOTG_INTERRUPT_CFG 0x210 -#define SOTG_INTERRUPT_CFG_CDBGMOD (3 << 6) -#define SOTG_INTERRUPT_CFG_DDBGMODIN (3 << 4) -#define SOTG_INTERRUPT_CFG_DDBGMODOUT (3 << 2) -#define SOTG_INTERRUPT_CFG_INTLVL (1 << 1) -#define SOTG_INTERRUPT_CFG_INTPOL (1 << 0) -#define SOTG_DEBUG 0x212 -#define SOTG_DEBUG_SET (1 << 0) -#define SOTG_DCINTERRUPT_EN 0x214 -#define SOTG_HW_MODE_CTRL 0x300 -#define SOTG_HW_MODE_CTRL_ALL_ATX_RESET (1 << 31) -#define SOTG_HW_MODE_CTRL_ANA_DIGI_OC (1 << 15) -#define SOTG_HW_MODE_CTRL_DEV_DMA (1 << 11) -#define SOTG_HW_MODE_CTRL_COMN_INT (1 << 10) -#define SOTG_HW_MODE_CTRL_COMN_DMA (1 << 9) -#define SOTG_HW_MODE_CTRL_DATA_BUS_WIDTH (1 << 8) -#define SOTG_HW_MODE_CTRL_DACK_POL (1 << 6) -#define SOTG_HW_MODE_CTRL_DREQ_POL (1 << 5) -#define SOTG_HW_MODE_CTRL_INTR_POL (1 << 2) -#define SOTG_HW_MODE_CTRL_INTR_LEVEL (1 << 1) -#define SOTG_HW_MODE_CTRL_GLOBAL_INTR_EN (1 << 0) -#define SOTG_OTG_CTRL 0x374 -#define SOTG_EP_INDEX 0x22c -#define SOTG_EP_INDEX_EP0SETUP (1 << 5) -#define SOTG_EP_INDEX_ENDP_INDEX_MASK (15 << 1) -#define SOTG_EP_INDEX_ENDP_INDEX_SHIFT 1 -#define SOTG_EP_INDEX_DIR_IN (1 << 0) -#define SOTG_EP_INDEX_DIR_OUT 0 -#define SOTG_CTRL_FUNC 0x228 -#define SOTG_CTRL_FUNC_CLBUF (1 << 4) -#define SOTG_CTRL_FUNC_VENDP (1 << 3) -#define SOTG_CTRL_FUNC_DSEN (1 << 2) -#define SOTG_CTRL_FUNC_STATUS (1 << 1) -#define SOTG_CTRL_FUNC_STALL (1 << 0) -#define SOTG_DATA_PORT 0x220 -#define SOTG_BUF_LENGTH 0x21C -#define SOTG_DCBUFFERSTATUS 0x21E -#define SOTG_DCBUFFERSTATUS_FILLED_MASK (3 << 0) -#define SOTG_EP_MAXPACKET 0x204 -#define SOTG_EP_TYPE 0x208 -#define SOTG_EP_TYPE_NOEMPPKT (1 << 4) -#define SOTG_EP_TYPE_ENABLE (1 << 3) -#define SOTG_EP_TYPE_DBLBUF (1 << 2) -#define SOTG_EP_TYPE_EP_TYPE (3 << 0) -#define SOTG_DMA_CMD 0x230 -#define SOTG_DMA_XFER_COUNT 0x234 -#define SOTG_DCDMA_CFG 0x238 -#define SOTG_DMA_HW 0x23C -#define SOTG_DMA_IRQ_REASON 0x250 -#define SOTG_DMA_IRQ_ENABLE 0x254 -#define SOTG_DMA_EP 0x258 -#define SOTG_BURST_COUNTER 0x264 -#define SOTG_DCINTERRUPT 0x218 -#define SOTG_DCINTERRUPT_IEPRX(n) (1 << (10 + (2*(n)))) -#define SOTG_DCINTERRUPT_IEPTX(n) (1 << (11 + (2*(n)))) -#define SOTG_DCINTERRUPT_IEP0SETUP (1 << 8) -#define SOTG_DCINTERRUPT_IEVBUS (1 << 7) -#define SOTG_DCINTERRUPT_IEDMA (1 << 6) -#define SOTG_DCINTERRUPT_IEHS_STA (1 << 5) -#define SOTG_DCINTERRUPT_IERESM (1 << 4) -#define SOTG_DCINTERRUPT_IESUSP (1 << 3) -#define SOTG_DCINTERRUPT_IEPSOF (1 << 2) -#define SOTG_DCINTERRUPT_IESOF (1 << 1) -#define SOTG_DCINTERRUPT_IEBRST (1 << 0) -#define SOTG_DCCHIP_ID 0x270 -#define SOTG_FRAME_NUM 0x274 -#define SOTG_FRAME_NUM_MICROSOFR_MASK 0x3800 -#define SOTG_FRAME_NUM_MICROSOFR_SHIFT 11 -#define SOTG_FRAME_NUM_SOFR_MASK 0x7FF -#define SOTG_DCSCRATCH 0x278 -#define SOTG_UNLOCK_DEVICE 0x27C -#define SOTG_UNLOCK_DEVICE_CODE 0xAA37 -#define SOTG_IRQ_PULSE_WIDTH 0x280 -#define SOTG_TEST_MODE 0x284 -#define SOTG_TEST_MODE_FORCEHS (1 << 7) -#define SOTG_TEST_MODE_FORCEFS (1 << 4) -#define SOTG_TEST_MODE_PRBS (1 << 3) -#define SOTG_TEST_MODE_KSTATE (1 << 2) -#define SOTG_TEST_MODE_JSTATE (1 << 1) -#define SOTG_TEST_MODE_SE0_NAK (1 << 0) - -/* Host controller specific registers */ - -#define SOTG_CONFIGFLAG 0x0060 -#define SOTG_CONFIGFLAG_ENABLE (1 << 0) -#define SOTG_PORTSC1 0x0064 -#define SOTG_PORTSC1_PIC (3 << 14) -#define SOTG_PORTSC1_PO (1 << 13) -#define SOTG_PORTSC1_PP (1 << 12) -#define SOTG_PORTSC1_LS (3 << 10) -#define SOTG_PORTSC1_PR (1 << 8) -#define SOTG_PORTSC1_SUSP (1 << 7) -#define SOTG_PORTSC1_FPR (1 << 6) -#define SOTG_PORTSC1_PED (1 << 2) -#define SOTG_PORTSC1_ECSC (1 << 1) -#define SOTG_PORTSC1_ECCS (1 << 0) -#define SOTG_DATA_ADDR(x) (0x400 + (512 * (x))) -#define SOTG_ASYNC_PDT(x) (0x400 + (60 * 1024) + ((x) * 32)) -#define SOTG_INTR_PDT(x) (0x400 + (61 * 1024) + ((x) * 32)) -#define SOTG_ISOC_PDT(x) (0x400 + (62 * 1024) + ((x) * 32)) -#define SOTG_HC_MEMORY_ADDR(x) (((x) - 0x400) >> 3) -#define SOTG_SW_RESET 0x30C -#define SOTG_SW_RESET_HC (1 << 1) -#define SOTG_SW_RESET_ALL (1 << 0) -#define SOTG_POWER_DOWN 0x354 -#define SOTG_POWER_DOWN_PORT3_PD (1 << 12) -#define SOTG_POWER_DOWN_PORT2_PD (1 << 11) -#define SOTG_POWER_DOWN_VBATDET_PWR (1 << 10) -#define SOTG_POWER_DOWN_BIAS_EN (1 << 5) -#define SOTG_POWER_DOWN_VREG_ON (1 << 4) -#define SOTG_POWER_DOWN_OC3_PWR (1 << 3) -#define SOTG_POWER_DOWN_OC2_PWR (1 << 2) -#define SOTG_POWER_DOWN_OC1_PWR (1 << 1) -#define SOTG_POWER_DOWN_HC_CLK_EN (1 << 0) -#define SOTG_USBCMD 0x20 -#define SOTG_USBCMD_LHCR (1 << 7) -#define SOTG_USBCMD_HCRESET (1 << 1) -#define SOTG_USBCMD_RS (1 << 0) - -#endif /* _SAF1761_DCI_REG_H_ */ -- cgit v1.3 From dfe11c139540229835bcc6e5e813bd59d06cadb7 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Fri, 16 May 2014 16:36:07 +0000 Subject: Enable host controller interrupts. Sponsored by: DARPA, AFRL --- sys/dev/usb/controller/saf1761_otg.c | 19 +++++++++++++++---- sys/dev/usb/controller/saf1761_otg_reg.h | 10 ++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/saf1761_otg.c b/sys/dev/usb/controller/saf1761_otg.c index 080e5ed6cf66c..81821f47a31be 100644 --- a/sys/dev/usb/controller/saf1761_otg.c +++ b/sys/dev/usb/controller/saf1761_otg.c @@ -971,16 +971,20 @@ void saf1761_otg_interrupt(struct saf1761_otg_softc *sc) { uint32_t status; + uint32_t hcstat; USB_BUS_LOCK(&sc->sc_bus); - status = SAF1761_READ_4(sc, SOTG_DCINTERRUPT); + hcstat = SAF1761_READ_4(sc, SOTG_HCINTERRUPT); + /* acknowledge all host controller interrupts */ + SAF1761_WRITE_4(sc, SOTG_HCINTERRUPT, hcstat); - /* acknowledge all interrupts */ + status = SAF1761_READ_4(sc, SOTG_DCINTERRUPT); + /* acknowledge all device controller interrupts */ SAF1761_WRITE_4(sc, SOTG_DCINTERRUPT, status); - DPRINTF("DCINTERRUPT=0x%08x SOF=0x%04x\n", status, - SAF1761_READ_2(sc, SOTG_FRAME_NUM)); + DPRINTF("DCINTERRUPT=0x%08x HCINTERRUPT=0x%08x SOF=0x%04x\n", + status, hcstat, SAF1761_READ_2(sc, SOTG_FRAME_NUM)); /* update VBUS and ID bits, if any */ if (status & SOTG_DCINTERRUPT_IEVBUS) { @@ -1716,6 +1720,13 @@ saf1761_otg_init(struct saf1761_otg_softc *sc) /* start the HC */ SAF1761_WRITE_4(sc, SOTG_USBCMD, SOTG_USBCMD_RS); + /* enable HC interrupts */ + SAF1761_WRITE_4(sc, SOTG_HCINTERRUPT_ENABLE, + SOTG_HCINTERRUPT_OTG_IRQ | + SOTG_HCINTERRUPT_ISO_IRQ | + SOTG_HCINTERRUPT_ALT_IRQ | + SOTG_HCINTERRUPT_INT_IRQ); + /* poll initial VBUS status */ saf1761_otg_update_vbus(sc); diff --git a/sys/dev/usb/controller/saf1761_otg_reg.h b/sys/dev/usb/controller/saf1761_otg_reg.h index 2b74866b919cf..a4efe0129429b 100644 --- a/sys/dev/usb/controller/saf1761_otg_reg.h +++ b/sys/dev/usb/controller/saf1761_otg_reg.h @@ -210,5 +210,15 @@ #define SOTG_USBCMD_LHCR (1 << 7) #define SOTG_USBCMD_HCRESET (1 << 1) #define SOTG_USBCMD_RS (1 << 0) +#define SOTG_HCINTERRUPT 0x310 +#define SOTG_HCINTERRUPT_OTG_IRQ (1 << 10) +#define SOTG_HCINTERRUPT_ISO_IRQ (1 << 9) +#define SOTG_HCINTERRUPT_ALT_IRQ (1 << 8) +#define SOTG_HCINTERRUPT_INT_IRQ (1 << 7) +#define SOTG_HCINTERRUPT_CLKREADY (1 << 6) +#define SOTG_HCINTERRUPT_HCSUSP (1 << 5) +#define SOTG_HCINTERRUPT_DMAEOTINT (1 << 3) +#define SOTG_HCINTERRUPT_SOFITLINT (1 << 1) +#define SOTG_HCINTERRUPT_ENABLE 0x314 #endif /* _SAF1761_OTG_REG_H_ */ -- cgit v1.3 From 2fe7ad87e9116f13fd8660084be4c8d323f4228f Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Sun, 18 May 2014 09:13:29 +0000 Subject: - Add softc pointer argument to FIFO functions as an optimisation. - Implement support for interrupt filters in the DWC OTG driver, to reduce the amount of CPU task switching when only feeding the FIFOs. - Add common spinlock to the USB bus structure. MFC after: 2 weeks --- sys/dev/usb/controller/dwc_otg.c | 276 ++++++++++++++++++------------ sys/dev/usb/controller/dwc_otg.h | 6 +- sys/dev/usb/controller/dwc_otg_atmelarm.c | 2 +- sys/dev/usb/controller/dwc_otg_fdt.c | 2 +- sys/dev/usb/controller/usb_controller.c | 4 + sys/dev/usb/usb_bus.h | 1 + sys/dev/usb/usb_core.h | 3 + 7 files changed, 178 insertions(+), 116 deletions(-) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/dwc_otg.c b/sys/dev/usb/controller/dwc_otg.c index 06727d1691a0c..f5af1f7a55f09 100644 --- a/sys/dev/usb/controller/dwc_otg.c +++ b/sys/dev/usb/controller/dwc_otg.c @@ -89,9 +89,6 @@ ((struct dwc_otg_softc *)(((uint8_t *)(bus)) - \ ((uint8_t *)&(((struct dwc_otg_softc *)0)->sc_bus)))) -#define DWC_OTG_PC2SC(pc) \ - DWC_OTG_BUS2SC(USB_DMATAG_TO_XROOT((pc)->tag_parent)->bus) - #define DWC_OTG_PC2UDEV(pc) \ (USB_DMATAG_TO_XROOT((pc)->tag_parent)->udev) @@ -104,6 +101,11 @@ GINTMSK_OTGINTMSK | \ GINTMSK_PRTINTMSK) +#define DWC_OTG_MSK_GINT_THREAD_IRQ \ + (GINTSTS_USBRST | GINTSTS_ENUMDONE | GINTSTS_PRTINT | \ + GINTSTS_WKUPINT | GINTSTS_USBSUSP | GINTMSK_OTGINTMSK | \ + GINTSTS_SESSREQINT) + static int dwc_otg_use_hsic; static SYSCTL_NODE(_hw_usb, OID_AUTO, dwc_otg, CTLFLAG_RW, 0, "USB DWC OTG"); @@ -590,9 +592,8 @@ dwc_otg_clear_hcint(struct dwc_otg_softc *sc, uint8_t x) } static uint8_t -dwc_otg_host_channel_alloc(struct dwc_otg_td *td, uint8_t which, uint8_t is_out) +dwc_otg_host_channel_alloc(struct dwc_otg_softc *sc, struct dwc_otg_td *td, uint8_t which, uint8_t is_out) { - struct dwc_otg_softc *sc; uint32_t tx_p_size; uint32_t tx_np_size; uint8_t x; @@ -604,9 +605,6 @@ dwc_otg_host_channel_alloc(struct dwc_otg_td *td, uint8_t which, uint8_t is_out) if (DWC_OTG_PC2UDEV(td->pc)->flags.self_suspended != 0) return (1); /* busy - cannot transfer data */ - /* get pointer to softc */ - sc = DWC_OTG_PC2SC(td->pc); - /* compute needed TX FIFO size */ if (is_out != 0) { if (td->ep_type == UE_INTERRUPT || @@ -670,9 +668,8 @@ dwc_otg_host_channel_alloc(struct dwc_otg_td *td, uint8_t which, uint8_t is_out) } static void -dwc_otg_host_channel_free(struct dwc_otg_td *td, uint8_t which) +dwc_otg_host_channel_free(struct dwc_otg_softc *sc, struct dwc_otg_td *td, uint8_t which) { - struct dwc_otg_softc *sc; uint8_t x; if (td->channel[which] >= DWC_OTG_MAX_CHANNELS) @@ -684,9 +681,6 @@ dwc_otg_host_channel_free(struct dwc_otg_td *td, uint8_t which) DPRINTF("CH=%d\n", x); - /* get pointer to softc */ - sc = DWC_OTG_PC2SC(td->pc); - /* * We need to let programmed host channels run till complete * else the host channel will stop functioning. Assume that @@ -714,17 +708,13 @@ dwc_otg_host_channel_free(struct dwc_otg_td *td, uint8_t which) } static uint8_t -dwc_otg_host_setup_tx(struct dwc_otg_td *td) +dwc_otg_host_setup_tx(struct dwc_otg_softc *sc, struct dwc_otg_td *td) { struct usb_device_request req __aligned(4); - struct dwc_otg_softc *sc; uint32_t hcint; uint32_t hcchar; uint8_t delta; - /* get pointer to softc */ - sc = DWC_OTG_PC2SC(td->pc); - if (td->channel[0] < DWC_OTG_MAX_CHANNELS) { hcint = sc->sc_chan_state[td->channel[0]].hcint; @@ -814,7 +804,7 @@ check_state: send_pkt: /* free existing channel, if any */ - dwc_otg_host_channel_free(td, 0); + dwc_otg_host_channel_free(sc, td, 0); if (sizeof(req) != td->remainder) { td->error_any = 1; @@ -837,7 +827,7 @@ send_pkt: } /* allocate a new channel */ - if (dwc_otg_host_channel_alloc(td, 0, 1)) { + if (dwc_otg_host_channel_alloc(sc, td, 0, 1)) { td->state = DWC_CHAN_ST_START; goto busy; } @@ -875,7 +865,7 @@ send_pkt: send_cpkt: /* free existing channel, if any */ - dwc_otg_host_channel_free(td, 0); + dwc_otg_host_channel_free(sc, td, 0); delta = td->tt_complete_slot - sc->sc_last_frame_num - 1; if (td->tt_scheduled == 0 || delta < DWC_OTG_TT_SLOT_MAX) { @@ -890,7 +880,7 @@ send_cpkt: goto complete; } /* allocate a new channel */ - if (dwc_otg_host_channel_alloc(td, 0, 0)) { + if (dwc_otg_host_channel_alloc(sc, td, 0, 0)) { td->state = DWC_CHAN_ST_WAIT_C_PKT; goto busy; } @@ -917,21 +907,17 @@ busy: return (1); /* busy */ complete: - dwc_otg_host_channel_free(td, 0); + dwc_otg_host_channel_free(sc, td, 0); return (0); /* complete */ } static uint8_t -dwc_otg_setup_rx(struct dwc_otg_td *td) +dwc_otg_setup_rx(struct dwc_otg_softc *sc, struct dwc_otg_td *td) { - struct dwc_otg_softc *sc; struct usb_device_request req __aligned(4); uint32_t temp; uint16_t count; - /* get pointer to softc */ - sc = DWC_OTG_PC2SC(td->pc); - /* check endpoint status */ if (sc->sc_last_rx_status == 0) @@ -1072,13 +1058,8 @@ dwc_otg_host_rate_check_interrupt(struct dwc_otg_softc *sc, struct dwc_otg_td *t } static uint8_t -dwc_otg_host_rate_check(struct dwc_otg_td *td) +dwc_otg_host_rate_check(struct dwc_otg_softc *sc, struct dwc_otg_td *td) { - struct dwc_otg_softc *sc; - - /* get pointer to softc */ - sc = DWC_OTG_PC2SC(td->pc); - if (td->ep_type == UE_ISOCHRONOUS) { /* non TT isochronous traffic */ if ((td->tmr_val != 0) || @@ -1104,17 +1085,14 @@ busy: } static uint8_t -dwc_otg_host_data_rx(struct dwc_otg_td *td) +dwc_otg_host_data_rx(struct dwc_otg_softc *sc, struct dwc_otg_td *td) { - struct dwc_otg_softc *sc; uint32_t hcint; uint32_t hcchar; uint32_t count; uint8_t delta; uint8_t channel; - /* get pointer to softc */ - sc = DWC_OTG_PC2SC(td->pc); channel = td->channel[td->tt_channel_tog]; if (channel < DWC_OTG_MAX_CHANNELS) { @@ -1328,7 +1306,7 @@ check_state: receive_pkt: /* free existing channel, if any */ - dwc_otg_host_channel_free(td, td->tt_channel_tog); + dwc_otg_host_channel_free(sc, td, td->tt_channel_tog); if (td->hcsplt != 0) { delta = td->tt_complete_slot - sc->sc_last_frame_num - 1; @@ -1346,13 +1324,13 @@ receive_pkt: /* complete split */ td->hcsplt |= HCSPLT_COMPSPLT; } else if (td->tt_xactpos == HCSPLT_XACTPOS_BEGIN && - dwc_otg_host_rate_check(td)) { + dwc_otg_host_rate_check(sc, td)) { td->state = DWC_CHAN_ST_WAIT_C_PKT; goto busy; } /* allocate a new channel */ - if (dwc_otg_host_channel_alloc(td, td->tt_channel_tog, 0)) { + if (dwc_otg_host_channel_alloc(sc, td, td->tt_channel_tog, 0)) { td->state = DWC_CHAN_ST_WAIT_C_PKT; goto busy; } @@ -1417,8 +1395,8 @@ receive_pkt: receive_spkt: /* free existing channel(s), if any */ - dwc_otg_host_channel_free(td, 0); - dwc_otg_host_channel_free(td, 1); + dwc_otg_host_channel_free(sc, td, 0); + dwc_otg_host_channel_free(sc, td, 1); delta = td->tt_start_slot - sc->sc_last_frame_num - 1; if (td->tt_scheduled == 0 || delta < DWC_OTG_TT_SLOT_MAX) { @@ -1434,7 +1412,7 @@ receive_spkt: } /* allocate a new channel */ - if (dwc_otg_host_channel_alloc(td, 0, 0)) { + if (dwc_otg_host_channel_alloc(sc, td, 0, 0)) { td->state = DWC_CHAN_ST_START; goto busy; } @@ -1468,24 +1446,20 @@ busy: return (1); /* busy */ complete: - dwc_otg_host_channel_free(td, 0); - dwc_otg_host_channel_free(td, 1); + dwc_otg_host_channel_free(sc, td, 0); + dwc_otg_host_channel_free(sc, td, 1); return (0); /* complete */ } static uint8_t -dwc_otg_data_rx(struct dwc_otg_td *td) +dwc_otg_data_rx(struct dwc_otg_softc *sc, struct dwc_otg_td *td) { - struct dwc_otg_softc *sc; uint32_t temp; uint16_t count; uint8_t got_short; got_short = 0; - /* get pointer to softc */ - sc = DWC_OTG_PC2SC(td->pc); - /* check endpoint status */ if (sc->sc_last_rx_status == 0) goto not_complete; @@ -1587,17 +1561,14 @@ not_complete: } static uint8_t -dwc_otg_host_data_tx(struct dwc_otg_td *td) +dwc_otg_host_data_tx(struct dwc_otg_softc *sc, struct dwc_otg_td *td) { - struct dwc_otg_softc *sc; uint32_t count; uint32_t hcint; uint32_t hcchar; uint8_t delta; uint8_t channel; - /* get pointer to softc */ - sc = DWC_OTG_PC2SC(td->pc); channel = td->channel[td->tt_channel_tog]; if (channel < DWC_OTG_MAX_CHANNELS) { @@ -1723,14 +1694,14 @@ check_state: td->tt_xactpos++; /* free existing channel, if any */ - dwc_otg_host_channel_free(td, td->tt_channel_tog); + dwc_otg_host_channel_free(sc, td, td->tt_channel_tog); td->state = DWC_CHAN_ST_TX_PKT_ISOC; /* FALLTHROUGH */ case DWC_CHAN_ST_TX_PKT_ISOC: - if (dwc_otg_host_channel_alloc(td, 0, 1)) + if (dwc_otg_host_channel_alloc(sc, td, 0, 1)) break; channel = td->channel[0]; goto send_isoc_pkt; @@ -1741,8 +1712,8 @@ check_state: send_pkt: /* free existing channel(s), if any */ - dwc_otg_host_channel_free(td, 0); - dwc_otg_host_channel_free(td, 1); + dwc_otg_host_channel_free(sc, td, 0); + dwc_otg_host_channel_free(sc, td, 1); if (td->hcsplt != 0) { delta = td->tt_start_slot - sc->sc_last_frame_num - 1; @@ -1757,13 +1728,13 @@ send_pkt: td->state = DWC_CHAN_ST_START; goto busy; } - } else if (dwc_otg_host_rate_check(td)) { + } else if (dwc_otg_host_rate_check(sc, td)) { td->state = DWC_CHAN_ST_START; goto busy; } /* allocate a new channel */ - if (dwc_otg_host_channel_alloc(td, 0, 1)) { + if (dwc_otg_host_channel_alloc(sc, td, 0, 1)) { td->state = DWC_CHAN_ST_START; goto busy; } @@ -1912,7 +1883,7 @@ send_isoc_pkt: send_cpkt: /* free existing channel, if any */ - dwc_otg_host_channel_free(td, td->tt_channel_tog); + dwc_otg_host_channel_free(sc, td, td->tt_channel_tog); delta = td->tt_complete_slot - sc->sc_last_frame_num - 1; if (td->tt_scheduled == 0 || delta < DWC_OTG_TT_SLOT_MAX) { @@ -1928,7 +1899,7 @@ send_cpkt: } /* allocate a new channel */ - if (dwc_otg_host_channel_alloc(td, td->tt_channel_tog, 0)) { + if (dwc_otg_host_channel_alloc(sc, td, td->tt_channel_tog, 0)) { td->state = DWC_CHAN_ST_WAIT_C_PKT; goto busy; } @@ -1986,15 +1957,14 @@ busy: return (1); /* busy */ complete: - dwc_otg_host_channel_free(td, 0); - dwc_otg_host_channel_free(td, 1); + dwc_otg_host_channel_free(sc, td, 0); + dwc_otg_host_channel_free(sc, td, 1); return (0); /* complete */ } static uint8_t -dwc_otg_data_tx(struct dwc_otg_td *td) +dwc_otg_data_tx(struct dwc_otg_softc *sc, struct dwc_otg_td *td) { - struct dwc_otg_softc *sc; uint32_t max_buffer; uint32_t count; uint32_t fifo_left; @@ -2004,9 +1974,6 @@ dwc_otg_data_tx(struct dwc_otg_td *td) to = 3; /* don't loop forever! */ - /* get pointer to softc */ - sc = DWC_OTG_PC2SC(td->pc); - max_buffer = sc->sc_hw_ep_profile[td->ep_no].max_buffer; repeat: @@ -2184,14 +2151,10 @@ not_complete: } static uint8_t -dwc_otg_data_tx_sync(struct dwc_otg_td *td) +dwc_otg_data_tx_sync(struct dwc_otg_softc *sc, struct dwc_otg_td *td) { - struct dwc_otg_softc *sc; uint32_t temp; - /* get pointer to softc */ - sc = DWC_OTG_PC2SC(td->pc); - /* * If all packets are transferred we are complete: */ @@ -2228,8 +2191,8 @@ not_complete: return (1); /* not complete */ } -static uint8_t -dwc_otg_xfer_do_fifo(struct usb_xfer *xfer) +static void +dwc_otg_xfer_do_fifo(struct dwc_otg_softc *sc, struct usb_xfer *xfer) { struct dwc_otg_td *td; uint8_t toggle; @@ -2239,9 +2202,11 @@ dwc_otg_xfer_do_fifo(struct usb_xfer *xfer) DPRINTFN(9, "\n"); td = xfer->td_transfer_cache; + if (td == NULL) + return; while (1) { - if ((td->func) (td)) { + if ((td->func) (sc, td)) { /* operation in progress */ break; } @@ -2272,13 +2237,27 @@ dwc_otg_xfer_do_fifo(struct usb_xfer *xfer) td->tmr_res = tmr_res; td->tmr_val = tmr_val; } - return (1); /* not complete */ + return; done: - /* compute all actual lengths */ + xfer->td_transfer_cache = NULL; + sc->sc_xfer_complete = 1; +} - dwc_otg_standard_done(xfer); - return (0); /* complete */ +static uint8_t +dwc_otg_xfer_do_complete(struct dwc_otg_softc *sc, struct usb_xfer *xfer) +{ + struct dwc_otg_td *td; + + DPRINTFN(9, "\n"); + + td = xfer->td_transfer_cache; + if (td == NULL) { + /* compute all actual lengths */ + dwc_otg_standard_done(xfer); + return (1); + } + return (0); } static void @@ -2292,6 +2271,8 @@ dwc_otg_timer(void *_sc) DPRINTF("\n"); + USB_BUS_SPIN_LOCK(&sc->sc_bus); + /* increment timer value */ sc->sc_tmr_val++; @@ -2306,6 +2287,8 @@ dwc_otg_timer(void *_sc) /* enable SOF interrupt, which will poll jobs */ dwc_otg_enable_sof_irq(sc); + USB_BUS_SPIN_UNLOCK(&sc->sc_bus); + if (sc->sc_timer_active) { /* restart timer */ usb_callout_reset(&sc->sc_timer, @@ -2621,13 +2604,9 @@ repeat: got_rx_status = 1; } - /* scan for completion events first */ - TAILQ_FOREACH(xfer, &sc->sc_bus.intr_q.head, wait_entry) { - if (!dwc_otg_xfer_do_fifo(xfer)) { - /* queue has been modified */ - goto repeat; - } - } + /* execute FIFOs */ + TAILQ_FOREACH(xfer, &sc->sc_bus.intr_q.head, wait_entry) + dwc_otg_xfer_do_fifo(sc, xfer); if (got_rx_status) { /* check if data was consumed */ @@ -2639,13 +2618,25 @@ repeat: DWC_OTG_WRITE_4(sc, DOTG_GINTMSK, sc->sc_irq_mask); } - if (sc->sc_flags.status_device_mode == 0) { + if (sc->sc_flags.status_device_mode == 0 && sc->sc_xfer_complete == 0) { /* update host transfer schedule, so that new transfers can be issued */ if (dwc_otg_update_host_transfer_schedule(sc)) goto repeat; } } +static void +dwc_otg_interrupt_complete(struct dwc_otg_softc *sc) +{ + struct usb_xfer *xfer; +repeat: + /* scan for completion events */ + TAILQ_FOREACH(xfer, &sc->sc_bus.intr_q.head, wait_entry) { + if (dwc_otg_xfer_do_complete(sc, xfer)) + goto repeat; + } +} + static void dwc_otg_vbus_interrupt(struct dwc_otg_softc *sc, uint8_t is_on) { @@ -2679,16 +2670,64 @@ dwc_otg_vbus_interrupt(struct dwc_otg_softc *sc, uint8_t is_on) } } +int +dwc_otg_filter_interrupt(void *arg) +{ + struct dwc_otg_softc *sc = arg; + int retval = FILTER_HANDLED; + uint32_t status; + + /* read and clear interrupt status */ + status = DWC_OTG_READ_4(sc, DOTG_GINTSTS); + + /* clear interrupts we are handling here */ + DWC_OTG_WRITE_4(sc, DOTG_GINTSTS, status & ~DWC_OTG_MSK_GINT_THREAD_IRQ); + + /* check for USB state change interrupts */ + if ((status & DWC_OTG_MSK_GINT_THREAD_IRQ) != 0) + retval = FILTER_SCHEDULE_THREAD; + + /* clear all IN endpoint interrupts */ + if (status & GINTSTS_IEPINT) { + uint32_t temp; + uint8_t x; + + for (x = 0; x != sc->sc_dev_in_ep_max; x++) { + temp = DWC_OTG_READ_4(sc, DOTG_DIEPINT(x)); + if (temp & DIEPMSK_XFERCOMPLMSK) { + DWC_OTG_WRITE_4(sc, DOTG_DIEPINT(x), + DIEPMSK_XFERCOMPLMSK); + } + } + } + + USB_BUS_SPIN_LOCK(&sc->sc_bus); + + /* poll FIFOs, if any */ + dwc_otg_interrupt_poll(sc); + + if (sc->sc_xfer_complete != 0) + retval = FILTER_SCHEDULE_THREAD; + + USB_BUS_SPIN_UNLOCK(&sc->sc_bus); + + return (retval); +} + void -dwc_otg_interrupt(struct dwc_otg_softc *sc) +dwc_otg_interrupt(void *arg) { + struct dwc_otg_softc *sc = arg; uint32_t status; USB_BUS_LOCK(&sc->sc_bus); + USB_BUS_SPIN_LOCK(&sc->sc_bus); /* read and clear interrupt status */ status = DWC_OTG_READ_4(sc, DOTG_GINTSTS); - DWC_OTG_WRITE_4(sc, DOTG_GINTSTS, status); + + /* clear interrupts we are handling here */ + DWC_OTG_WRITE_4(sc, DOTG_GINTSTS, status & DWC_OTG_MSK_GINT_THREAD_IRQ); DPRINTFN(14, "GINTSTS=0x%08x HAINT=0x%08x HFNUM=0x%08x\n", status, DWC_OTG_READ_4(sc, DOTG_HAINT), @@ -2858,23 +2897,20 @@ dwc_otg_interrupt(struct dwc_otg_softc *sc) (temp & (GOTGCTL_ASESVLD | GOTGCTL_BSESVLD)) ? 1 : 0); } - /* clear all IN endpoint interrupts */ - if (status & GINTSTS_IEPINT) { - uint32_t temp; - uint8_t x; + if (sc->sc_xfer_complete != 0) { + sc->sc_xfer_complete = 0; - for (x = 0; x != sc->sc_dev_in_ep_max; x++) { - temp = DWC_OTG_READ_4(sc, DOTG_DIEPINT(x)); - if (temp & DIEPMSK_XFERCOMPLMSK) { - DWC_OTG_WRITE_4(sc, DOTG_DIEPINT(x), - DIEPMSK_XFERCOMPLMSK); - } + /* complete FIFOs, if any */ + dwc_otg_interrupt_complete(sc); + + if (sc->sc_flags.status_device_mode == 0) { + /* update host transfer schedule, so that new transfers can be issued */ + if (dwc_otg_update_host_transfer_schedule(sc)) + dwc_otg_interrupt_poll(sc); } } - /* poll FIFO(s) */ - dwc_otg_interrupt_poll(sc); - + USB_BUS_SPIN_UNLOCK(&sc->sc_bus); USB_BUS_UNLOCK(&sc->sc_bus); } @@ -3238,9 +3274,12 @@ dwc_otg_start_standard_chain(struct usb_xfer *xfer) * endpoint interrupts. Else wait for SOF interrupt in host * mode. */ - if (sc->sc_flags.status_device_mode != 0 && - dwc_otg_xfer_do_fifo(xfer) == 0) - goto done; + if (sc->sc_flags.status_device_mode != 0) { + dwc_otg_xfer_do_fifo(sc, xfer); + if (dwc_otg_xfer_do_complete(sc, xfer)) + return; + } + USB_BUS_SPIN_LOCK(&sc->sc_bus); /* put transfer on interrupt queue */ usbd_transfer_enqueue(&xfer->xroot->bus->intr_q, xfer); @@ -3274,7 +3313,8 @@ dwc_otg_start_standard_chain(struct usb_xfer *xfer) /* reset NAK counter */ td->did_nak = 0; } -done:; +done: + USB_BUS_SPIN_UNLOCK(&sc->sc_bus); } static void @@ -3411,19 +3451,21 @@ done: static void dwc_otg_device_done(struct usb_xfer *xfer, usb_error_t error) { + struct dwc_otg_softc *sc = DWC_OTG_BUS2SC(xfer->xroot->bus); + DPRINTFN(9, "xfer=%p, endpoint=%p, error=%d\n", xfer, xfer->endpoint, error); if (xfer->flags_int.usb_mode == USB_MODE_DEVICE) { - DPRINTFN(15, "disabled interrupts!\n"); + /* Interrupts are cleared by the interrupt handler */ } else { struct dwc_otg_td *td; td = xfer->td_transfer_first; if (td != NULL) { - dwc_otg_host_channel_free(td, 0); - dwc_otg_host_channel_free(td, 1); + dwc_otg_host_channel_free(sc, td, 0); + dwc_otg_host_channel_free(sc, td, 1); } } /* dequeue transfer and start next transfer */ @@ -3484,6 +3526,7 @@ dwc_otg_set_stall(struct usb_device *udev, dwc_otg_common_rx_ack(sc); /* poll interrupt */ dwc_otg_interrupt_poll(sc); + dwc_otg_interrupt_complete(sc); } } } @@ -3548,6 +3591,7 @@ dwc_otg_clear_stall_sub(struct dwc_otg_softc *sc, uint32_t mps, /* poll interrupt */ dwc_otg_interrupt_poll(sc); + dwc_otg_interrupt_complete(sc); } static void @@ -3846,7 +3890,15 @@ dwc_otg_do_poll(struct usb_bus *bus) struct dwc_otg_softc *sc = DWC_OTG_BUS2SC(bus); USB_BUS_LOCK(&sc->sc_bus); + USB_BUS_SPIN_LOCK(&sc->sc_bus); dwc_otg_interrupt_poll(sc); + dwc_otg_interrupt_complete(sc); + if (sc->sc_flags.status_device_mode == 0) { + /* update host transfer schedule, so that new transfers can be issued */ + if (dwc_otg_update_host_transfer_schedule(sc)) + dwc_otg_interrupt_poll(sc); + } + USB_BUS_SPIN_UNLOCK(&sc->sc_bus); USB_BUS_UNLOCK(&sc->sc_bus); } diff --git a/sys/dev/usb/controller/dwc_otg.h b/sys/dev/usb/controller/dwc_otg.h index 7c46b75494e01..6b6976f850c37 100644 --- a/sys/dev/usb/controller/dwc_otg.h +++ b/sys/dev/usb/controller/dwc_otg.h @@ -48,7 +48,7 @@ struct dwc_otg_td; struct dwc_otg_softc; -typedef uint8_t (dwc_otg_cmd_t)(struct dwc_otg_td *td); +typedef uint8_t (dwc_otg_cmd_t)(struct dwc_otg_softc *sc, struct dwc_otg_td *td); struct dwc_otg_td { struct dwc_otg_td *obj_next; @@ -184,6 +184,7 @@ struct dwc_otg_softc { struct dwc_otg_chan_state sc_chan_state[DWC_OTG_MAX_CHANNELS]; uint32_t sc_tmr_val; uint32_t sc_hprt_val; + uint32_t sc_xfer_complete; uint16_t sc_active_rx_ep; uint16_t sc_last_frame_num; @@ -207,7 +208,8 @@ struct dwc_otg_softc { /* prototypes */ -void dwc_otg_interrupt(struct dwc_otg_softc *); +driver_filter_t dwc_otg_filter_interrupt; +driver_intr_t dwc_otg_interrupt; int dwc_otg_init(struct dwc_otg_softc *); void dwc_otg_uninit(struct dwc_otg_softc *); diff --git a/sys/dev/usb/controller/dwc_otg_atmelarm.c b/sys/dev/usb/controller/dwc_otg_atmelarm.c index 9dc072d82a248..33c5beca7f10e 100644 --- a/sys/dev/usb/controller/dwc_otg_atmelarm.c +++ b/sys/dev/usb/controller/dwc_otg_atmelarm.c @@ -116,7 +116,7 @@ dwc_otg_attach(device_t dev) device_set_ivars(sc->sc_otg.sc_bus.bdev, &sc->sc_otg.sc_bus); err = bus_setup_intr(dev, sc->sc_otg.sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE, - NULL, (driver_intr_t *)dwc_otg_interrupt, sc, &sc->sc_otg.sc_intr_hdl); + &dwc_otg_filter_interrupt, &dwc_otg_interrupt, sc, &sc->sc_otg.sc_intr_hdl); if (err) { sc->sc_otg.sc_intr_hdl = NULL; goto error; diff --git a/sys/dev/usb/controller/dwc_otg_fdt.c b/sys/dev/usb/controller/dwc_otg_fdt.c index d7de56799a884..938ef35546aaa 100644 --- a/sys/dev/usb/controller/dwc_otg_fdt.c +++ b/sys/dev/usb/controller/dwc_otg_fdt.c @@ -147,7 +147,7 @@ dwc_otg_attach(device_t dev) device_set_ivars(sc->sc_otg.sc_bus.bdev, &sc->sc_otg.sc_bus); err = bus_setup_intr(dev, sc->sc_otg.sc_irq_res, INTR_TYPE_TTY | INTR_MPSAFE, - NULL, (driver_intr_t *)dwc_otg_interrupt, sc, &sc->sc_otg.sc_intr_hdl); + &dwc_otg_filter_interrupt, &dwc_otg_interrupt, sc, &sc->sc_otg.sc_intr_hdl); if (err) { sc->sc_otg.sc_intr_hdl = NULL; goto error; diff --git a/sys/dev/usb/controller/usb_controller.c b/sys/dev/usb/controller/usb_controller.c index ee13a3524e726..d62acd2e0665f 100644 --- a/sys/dev/usb/controller/usb_controller.c +++ b/sys/dev/usb/controller/usb_controller.c @@ -901,6 +901,9 @@ usb_bus_mem_alloc_all(struct usb_bus *bus, bus_dma_tag_t dmat, mtx_init(&bus->bus_mtx, device_get_nameunit(bus->parent), NULL, MTX_DEF | MTX_RECURSE); + mtx_init(&bus->bus_spin_lock, device_get_nameunit(bus->parent), + NULL, MTX_SPIN | MTX_RECURSE); + usb_callout_init_mtx(&bus->power_wdog, &bus->bus_mtx, 0); @@ -954,6 +957,7 @@ usb_bus_mem_free_all(struct usb_bus *bus, usb_bus_mem_cb_t *cb) #endif mtx_destroy(&bus->bus_mtx); + mtx_destroy(&bus->bus_spin_lock); } /* convenience wrappers */ diff --git a/sys/dev/usb/usb_bus.h b/sys/dev/usb/usb_bus.h index 064a5534ed0eb..29167cf7ac162 100644 --- a/sys/dev/usb/usb_bus.h +++ b/sys/dev/usb/usb_bus.h @@ -87,6 +87,7 @@ struct usb_bus { * This mutex protects the USB hardware: */ struct mtx bus_mtx; + struct mtx bus_spin_lock; struct usb_xfer_queue intr_q; struct usb_callout power_wdog; /* power management */ diff --git a/sys/dev/usb/usb_core.h b/sys/dev/usb/usb_core.h index bea7c2c1c5a1a..dc514646fb66f 100644 --- a/sys/dev/usb/usb_core.h +++ b/sys/dev/usb/usb_core.h @@ -44,6 +44,9 @@ #define USB_BUS_LOCK(_b) mtx_lock(&(_b)->bus_mtx) #define USB_BUS_UNLOCK(_b) mtx_unlock(&(_b)->bus_mtx) #define USB_BUS_LOCK_ASSERT(_b, _t) mtx_assert(&(_b)->bus_mtx, _t) +#define USB_BUS_SPIN_LOCK(_b) mtx_lock_spin(&(_b)->bus_spin_lock) +#define USB_BUS_SPIN_UNLOCK(_b) mtx_unlock_spin(&(_b)->bus_spin_lock) +#define USB_BUS_SPIN_LOCK_ASSERT(_b, _t) mtx_assert(&(_b)->bus_spin_lock, _t) #define USB_XFER_LOCK(_x) mtx_lock((_x)->xroot->xfer_mtx) #define USB_XFER_UNLOCK(_x) mtx_unlock((_x)->xroot->xfer_mtx) #define USB_XFER_LOCK_ASSERT(_x, _t) mtx_assert((_x)->xroot->xfer_mtx, _t) -- cgit v1.3 From e85f0d314170d4749c4ccc23af54053968aec79b Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Sun, 18 May 2014 09:19:13 +0000 Subject: - Remove no longer used file. FDT is used to attach device drivers. --- sys/dev/usb/controller/dwc_otg_atmelarm.c | 200 ------------------------------ sys/modules/usb/dwc_otg/Makefile | 4 - 2 files changed, 204 deletions(-) delete mode 100644 sys/dev/usb/controller/dwc_otg_atmelarm.c (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/dwc_otg_atmelarm.c b/sys/dev/usb/controller/dwc_otg_atmelarm.c deleted file mode 100644 index 33c5beca7f10e..0000000000000 --- a/sys/dev/usb/controller/dwc_otg_atmelarm.c +++ /dev/null @@ -1,200 +0,0 @@ -/*- - * Copyright (c) 2012 Hans Petter Selasky. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include - -static device_probe_t dwc_otg_probe; -static device_attach_t dwc_otg_attach; -static device_detach_t dwc_otg_detach; - -struct dwc_otg_super_softc { - struct dwc_otg_softc sc_otg; /* must be first */ -}; - -static int -dwc_otg_probe(device_t dev) -{ - device_set_desc(dev, "DWC OTG 2.0 integrated USB controller"); - return (0); -} - -static int -dwc_otg_attach(device_t dev) -{ - struct dwc_otg_super_softc *sc = device_get_softc(dev); - int err; - int rid; - - /* initialise some bus fields */ - sc->sc_otg.sc_bus.parent = dev; - sc->sc_otg.sc_bus.devices = sc->sc_otg.sc_devices; - sc->sc_otg.sc_bus.devices_max = DWC_OTG_MAX_DEVICES; - - /* get all DMA memory */ - if (usb_bus_mem_alloc_all(&sc->sc_otg.sc_bus, - USB_GET_DMA_TAG(dev), NULL)) { - return (ENOMEM); - } - rid = 0; - sc->sc_otg.sc_io_res = - bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); - - if (!(sc->sc_otg.sc_io_res)) { - err = ENOMEM; - goto error; - } - sc->sc_otg.sc_io_tag = rman_get_bustag(sc->sc_otg.sc_io_res); - sc->sc_otg.sc_io_hdl = rman_get_bushandle(sc->sc_otg.sc_io_res); - sc->sc_otg.sc_io_size = rman_get_size(sc->sc_otg.sc_io_res); - - rid = 0; - sc->sc_otg.sc_irq_res = - bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE); - if (sc->sc_otg.sc_irq_res == NULL) - goto error; - - sc->sc_otg.sc_bus.bdev = device_add_child(dev, "usbus", -1); - if (sc->sc_otg.sc_bus.bdev == NULL) - goto error; - - device_set_ivars(sc->sc_otg.sc_bus.bdev, &sc->sc_otg.sc_bus); - - err = bus_setup_intr(dev, sc->sc_otg.sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE, - &dwc_otg_filter_interrupt, &dwc_otg_interrupt, sc, &sc->sc_otg.sc_intr_hdl); - if (err) { - sc->sc_otg.sc_intr_hdl = NULL; - goto error; - } - err = dwc_otg_init(&sc->sc_otg); - if (err == 0) { - err = device_probe_and_attach(sc->sc_otg.sc_bus.bdev); - } - if (err) - goto error; - return (0); - -error: - dwc_otg_detach(dev); - return (ENXIO); -} - -static int -dwc_otg_detach(device_t dev) -{ - struct dwc_otg_super_softc *sc = device_get_softc(dev); - device_t bdev; - int err; - - if (sc->sc_otg.sc_bus.bdev) { - bdev = sc->sc_otg.sc_bus.bdev; - device_detach(bdev); - device_delete_child(dev, bdev); - } - /* during module unload there are lots of children leftover */ - device_delete_children(dev); - - if (sc->sc_otg.sc_irq_res && sc->sc_otg.sc_intr_hdl) { - /* - * only call dwc_otg_uninit() after dwc_otg_init() - */ - dwc_otg_uninit(&sc->sc_otg); - - err = bus_teardown_intr(dev, sc->sc_otg.sc_irq_res, - sc->sc_otg.sc_intr_hdl); - sc->sc_otg.sc_intr_hdl = NULL; - } - /* free IRQ channel, if any */ - if (sc->sc_otg.sc_irq_res) { - bus_release_resource(dev, SYS_RES_IRQ, 0, - sc->sc_otg.sc_irq_res); - sc->sc_otg.sc_irq_res = NULL; - } - /* free memory resource, if any */ - if (sc->sc_otg.sc_io_res) { - bus_release_resource(dev, SYS_RES_MEMORY, 0, - sc->sc_otg.sc_io_res); - sc->sc_otg.sc_io_res = NULL; - } - usb_bus_mem_free_all(&sc->sc_otg.sc_bus, NULL); - - return (0); -} - -static device_method_t dwc_otg_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, dwc_otg_probe), - DEVMETHOD(device_attach, dwc_otg_attach), - DEVMETHOD(device_detach, dwc_otg_detach), - DEVMETHOD(device_suspend, bus_generic_suspend), - DEVMETHOD(device_resume, bus_generic_resume), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - - DEVMETHOD_END -}; - -static driver_t dwc_otg_driver = { - .name = "dwc_otg", - .methods = dwc_otg_methods, - .size = sizeof(struct dwc_otg_super_softc), -}; - -static devclass_t dwc_otg_devclass; - -DRIVER_MODULE(dwcotg, atmelarm, dwc_otg_driver, dwc_otg_devclass, 0, 0); -MODULE_DEPEND(dwcotg, usb, 1, 1, 1); diff --git a/sys/modules/usb/dwc_otg/Makefile b/sys/modules/usb/dwc_otg/Makefile index 61e5e78ea5bd5..6ab1bfcb09fd9 100644 --- a/sys/modules/usb/dwc_otg/Makefile +++ b/sys/modules/usb/dwc_otg/Makefile @@ -35,8 +35,4 @@ SRCS= bus_if.h device_if.h usb_if.h \ dwc_otg.c dwc_otg_fdt.c \ pci_if.h -.if defined(HAS_ATMELARM) -SRCS+= dwc_otg_atmelarm.c -.endif - .include -- cgit v1.3 From 6804df87a9daa6e007d2da853e3f9ca4b609877c Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Tue, 20 May 2014 14:15:03 +0000 Subject: Correct some programming details. The layout of the PDTs were different from what was initially thought. Fix re-programming of hardware mode register after reset. Sponsored by: DARPA, AFRL --- sys/dev/usb/controller/saf1761_otg.c | 154 +++++++++++++++++++++---------- sys/dev/usb/controller/saf1761_otg_reg.h | 10 +- 2 files changed, 109 insertions(+), 55 deletions(-) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/saf1761_otg.c b/sys/dev/usb/controller/saf1761_otg.c index 81821f47a31be..516188fdd76ac 100644 --- a/sys/dev/usb/controller/saf1761_otg.c +++ b/sys/dev/usb/controller/saf1761_otg.c @@ -227,7 +227,7 @@ saf1761_host_channel_alloc(struct saf1761_otg_softc *sc, struct saf1761_otg_td * if (sc->sc_host_isoc_map & (1 << x)) continue; sc->sc_host_isoc_map |= (1 << x); - td->channel = 64 + x; + td->channel = x; return (0); } break; @@ -236,7 +236,7 @@ saf1761_host_channel_alloc(struct saf1761_otg_softc *sc, struct saf1761_otg_td * if (sc->sc_host_async_map & (1 << x)) continue; sc->sc_host_async_map |= (1 << x); - td->channel = x; + td->channel = 64 + x; return (0); } break; @@ -253,8 +253,8 @@ saf1761_host_channel_free(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t return; /* disable channel */ - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 3), 0); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 0), 0); + SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 3), 0); + SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 0), 0); switch (td->ep_type) { case UE_INTERRUPT: @@ -263,7 +263,7 @@ saf1761_host_channel_free(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t td->channel = SOTG_HOST_CHANNEL_MAX; break; case UE_ISOCHRONOUS: - x = td->channel - 64; + x = td->channel; sc->sc_host_isoc_map &= ~(1 << x); td->channel = SOTG_HOST_CHANNEL_MAX; break; @@ -276,19 +276,23 @@ saf1761_host_channel_free(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t } static void -saf1761_read_host_fifo_1(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td, - void *buf, uint32_t len) +saf1761_read_host_memory_4(struct saf1761_otg_softc *sc, uint32_t offset, + void *buf, uint32_t count) { - bus_space_read_region_1((sc)->sc_io_tag, (sc)->sc_io_hdl, - SOTG_DATA_ADDR(td->channel), buf, len); + if (count == 0) + return; + SAF1761_WRITE_4(sc, SOTG_MEMORY_REG, SOTG_HC_MEMORY_ADDR(offset)); + DELAY(1); /* read prefetch time is 90ns */ + bus_space_read_region_4((sc)->sc_io_tag, (sc)->sc_io_hdl, offset, buf, count); } static void -saf1761_write_host_fifo_1(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td, - void *buf, uint32_t len) +saf1761_write_host_memory_4(struct saf1761_otg_softc *sc, uint32_t offset, + void *buf, uint32_t count) { - bus_space_write_region_1((sc)->sc_io_tag, (sc)->sc_io_hdl, - SOTG_DATA_ADDR(td->channel), buf, len); + if (count == 0) + return; + bus_space_write_region_4((sc)->sc_io_tag, (sc)->sc_io_hdl, offset, buf, count); } static uint8_t @@ -299,7 +303,7 @@ saf1761_host_setup_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) uint32_t count; if (td->channel < SOTG_HOST_CHANNEL_MAX) { - status = SAF1761_READ_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 3)); + status = SAF1761_READ_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 3)); if (status & (1 << 31)) { goto busy; } else if (status & (1 << 30)) { @@ -325,23 +329,24 @@ saf1761_host_setup_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) usbd_copy_out(td->pc, 0, &req, count); - saf1761_write_host_fifo_1(sc, td, &req, count); + saf1761_write_host_memory_4(sc, SOTG_DATA_ADDR(td->channel), + &req, (count + 3) / 4); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 7), 0); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 6), 0); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 5), 0); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 4), 0); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 3), + SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 7), 0); + SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 6), 0); + SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 5), 0); + SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 4), 0); + SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 3), (1 << 31) | (td->toggle << 25) | (3 << 23)); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 2), + SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 2), SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 1), + SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 1), td->dw1_value | (2 << 10) /* SETUP PID */ | (td->ep_index >> 1)); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 0), + SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 0), (td->ep_index << 31) | (1 << 29) /* pkt-multiplier */ | (td->max_packet_size << 18) /* wMaxPacketSize */ | @@ -365,7 +370,7 @@ saf1761_host_bulk_data_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t uint32_t count; uint8_t got_short; - status = SAF1761_READ_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 3)); + status = SAF1761_READ_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 3)); if (status & (1 << 31)) { goto busy; @@ -401,8 +406,9 @@ saf1761_host_bulk_data_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t goto complete; } - saf1761_read_host_fifo_1(sc, td, - sc->sc_bounce_buffer, count); + saf1761_read_host_memory_4(sc, SOTG_DATA_ADDR(td->channel), + sc->sc_bounce_buffer, (count + 3) / 4); + usbd_copy_in(td->pc, td->offset, sc->sc_bounce_buffer, count); @@ -429,21 +435,21 @@ saf1761_host_bulk_data_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t /* receive one more packet */ - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 7), 0); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 6), 0); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 5), 0); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 4), 0); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 3), + SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 7), 0); + SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 6), 0); + SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 5), 0); + SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 4), 0); + SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 3), (1 << 31) | (td->toggle << 25) | (3 << 23)); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 2), + SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 2), SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 1), + SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 1), td->dw1_value | (1 << 10) /* IN-PID */ | (td->ep_index >> 1)); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 0), + SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 0), (td->ep_index << 31) | (1 << 29) /* pkt-multiplier */ | (td->max_packet_size << 18) /* wMaxPacketSize */ | @@ -463,7 +469,7 @@ saf1761_host_bulk_data_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t if (td->channel < SOTG_HOST_CHANNEL_MAX) { uint32_t status; - status = SAF1761_READ_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 3)); + status = SAF1761_READ_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 3)); if (status & (1 << 31)) { goto busy; } else if (status & (1 << 30)) { @@ -493,7 +499,8 @@ saf1761_host_bulk_data_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t } usbd_copy_out(td->pc, td->offset, sc->sc_bounce_buffer, count); - saf1761_write_host_fifo_1(sc, td, sc->sc_bounce_buffer, count); + saf1761_write_host_memory_4(sc, SOTG_DATA_ADDR(td->channel), + sc->sc_bounce_buffer, (count + 3) / 4); /* set toggle, if any */ if (td->set_toggle) { @@ -501,21 +508,21 @@ saf1761_host_bulk_data_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t td->toggle = 1; } - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 7), 0); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 6), 0); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 5), 0); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 4), 0); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 3), + SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 7), 0); + SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 6), 0); + SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 5), 0); + SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 4), 0); + SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 3), (1 << 31) | (td->toggle << 25) | (3 << 23)); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 2), + SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 2), SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 1), + SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 1), td->dw1_value | (0 << 10) /* OUT-PID */ | (td->ep_index >> 1)); - SAF1761_WRITE_4(sc, SOTG_ASYNC_PDT(td->channel) + (4 * 0), + SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 0), (td->ep_index << 31) | (1 << 29) /* pkt-multiplier */ | (td->max_packet_size << 18) /* wMaxPacketSize */ | @@ -566,6 +573,8 @@ saf1761_otg_set_address(struct saf1761_otg_softc *sc, uint8_t addr) static void saf1761_read_device_fifo_1(struct saf1761_otg_softc *sc, void *buf, uint32_t len) { + if (len == 0) + return; bus_space_read_multi_1((sc)->sc_io_tag, (sc)->sc_io_hdl, SOTG_DATA_PORT, buf, len); } @@ -573,6 +582,8 @@ saf1761_read_device_fifo_1(struct saf1761_otg_softc *sc, void *buf, uint32_t len static void saf1761_write_device_fifo_1(struct saf1761_otg_softc *sc, void *buf, uint32_t len) { + if (len == 0) + return; bus_space_write_multi_1((sc)->sc_io_tag, (sc)->sc_io_hdl, SOTG_DATA_PORT, buf, len); } @@ -1614,10 +1625,29 @@ saf1761_otg_init(struct saf1761_otg_softc *sc) USB_BUS_LOCK(&sc->sc_bus); + /* Reset Host controller, including HW mode */ + SAF1761_WRITE_2(sc, SOTG_SW_RESET, SOTG_SW_RESET_ALL); + + DELAY(1000); + + /* Reset Host controller, including HW mode */ + SAF1761_WRITE_2(sc, SOTG_SW_RESET, SOTG_SW_RESET_HC); + + /* wait a bit */ + DELAY(1000); + + SAF1761_WRITE_2(sc, SOTG_SW_RESET, 0); + + /* wait a bit */ + DELAY(1000); + /* Enable interrupts */ sc->sc_hw_mode |= SOTG_HW_MODE_CTRL_GLOBAL_INTR_EN | SOTG_HW_MODE_CTRL_COMN_INT; + /* unlock device */ + SAF1761_WRITE_2(sc, SOTG_UNLOCK_DEVICE, SOTG_UNLOCK_DEVICE_CODE); + /* * Set correct hardware mode, must be written twice if bus * width is changed: @@ -1625,7 +1655,14 @@ saf1761_otg_init(struct saf1761_otg_softc *sc) SAF1761_WRITE_2(sc, SOTG_HW_MODE_CTRL, sc->sc_hw_mode); SAF1761_WRITE_4(sc, SOTG_HW_MODE_CTRL, sc->sc_hw_mode); - DPRINTF("DCID=0x%08x\n", SAF1761_READ_4(sc, SOTG_DCCHIP_ID)); + SAF1761_WRITE_4(sc, SOTG_DCSCRATCH, 0xdeadbeef); + + DPRINTF("DCID=0x%08x VEND=0x%04x PROD=0x%04x HWMODE=0x%08x SCRATCH=0x%08x\n", + SAF1761_READ_4(sc, SOTG_DCCHIP_ID), + SAF1761_READ_2(sc, SOTG_VEND_ID), + SAF1761_READ_2(sc, SOTG_PROD_ID), + SAF1761_READ_4(sc, SOTG_HW_MODE_CTRL), + SAF1761_READ_4(sc, SOTG_DCSCRATCH)); /* reset device controller */ SAF1761_WRITE_2(sc, SOTG_MODE, SOTG_MODE_SFRESET); @@ -1635,14 +1672,22 @@ saf1761_otg_init(struct saf1761_otg_softc *sc) DELAY(1000); /* reset host controller */ - SAF1761_WRITE_4(sc, SOTG_SW_RESET, SOTG_SW_RESET_HC); SAF1761_WRITE_4(sc, SOTG_USBCMD, SOTG_USBCMD_HCRESET); + /* wait for reset to clear */ + for (x = 0; x != 10; x++) { + if ((SAF1761_READ_4(sc, SOTG_USBCMD) & SOTG_USBCMD_HCRESET) == 0) + break; + usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 10); + } + + SAF1761_WRITE_4(sc, SOTG_HW_MODE_CTRL, sc->sc_hw_mode | + SOTG_HW_MODE_CTRL_ALL_ATX_RESET); + /* wait a bit */ DELAY(1000); - SAF1761_WRITE_4(sc, SOTG_SW_RESET, 0); - SAF1761_WRITE_4(sc, SOTG_USBCMD, 0); + SAF1761_WRITE_4(sc, SOTG_HW_MODE_CTRL, sc->sc_hw_mode); /* wait a bit */ DELAY(1000); @@ -1696,10 +1741,14 @@ saf1761_otg_init(struct saf1761_otg_softc *sc) SOTG_DCINTERRUPT_IEBRST | SOTG_DCINTERRUPT_IESUSP; SAF1761_WRITE_4(sc, SOTG_DCINTERRUPT_EN, sc->sc_intr_enable); - /* connect ATX port 1 to device controller */ + /* + * Connect ATX port 1 to device controller, select external + * charge pump and driver VBUS to +5V: + */ SAF1761_WRITE_2(sc, SOTG_CTRL_CLR, 0xFFFF); SAF1761_WRITE_2(sc, SOTG_CTRL_SET, SOTG_CTRL_SW_SEL_HC_DC | - SOTG_CTRL_BDIS_ACON_EN); + SOTG_CTRL_BDIS_ACON_EN | SOTG_CTRL_SEL_CP_EXT | + SOTG_CTRL_VBUS_DRV); /* disable device address */ SAF1761_WRITE_1(sc, SOTG_ADDRESS, 0); @@ -1720,6 +1769,8 @@ saf1761_otg_init(struct saf1761_otg_softc *sc) /* start the HC */ SAF1761_WRITE_4(sc, SOTG_USBCMD, SOTG_USBCMD_RS); + DPRINTF("USBCMD=0x%08x\n", SAF1761_READ_4(sc, SOTG_USBCMD)); + /* enable HC interrupts */ SAF1761_WRITE_4(sc, SOTG_HCINTERRUPT_ENABLE, SOTG_HCINTERRUPT_OTG_IRQ | @@ -2477,7 +2528,8 @@ tr_handle_get_port_status_host: temp = SAF1761_READ_4(sc, SOTG_PORTSC1); - DPRINTFN(9, "port status=0x%04x\n", temp); + DPRINTFN(9, "UR_GET_PORT_STATUS on port %d = 0x%08x\n", index, temp); + i = UPS_HIGH_SPEED; if (temp & SOTG_PORTSC1_ECCS) diff --git a/sys/dev/usb/controller/saf1761_otg_reg.h b/sys/dev/usb/controller/saf1761_otg_reg.h index a4efe0129429b..565c3acc5ba1e 100644 --- a/sys/dev/usb/controller/saf1761_otg_reg.h +++ b/sys/dev/usb/controller/saf1761_otg_reg.h @@ -78,6 +78,7 @@ #define SOTG_TIMER_HIGH_SET 0x38C #define SOTG_TIMER_HIGH_CLR 0x38E #define SOTG_TIMER_START_TMR (1U << 15) +#define SOTG_MEMORY_REG 0x33c /* Peripheral controller specific registers */ @@ -188,10 +189,10 @@ #define SOTG_PORTSC1_PED (1 << 2) #define SOTG_PORTSC1_ECSC (1 << 1) #define SOTG_PORTSC1_ECCS (1 << 0) -#define SOTG_DATA_ADDR(x) (0x400 + (512 * (x))) -#define SOTG_ASYNC_PDT(x) (0x400 + (60 * 1024) + ((x) * 32)) -#define SOTG_INTR_PDT(x) (0x400 + (61 * 1024) + ((x) * 32)) -#define SOTG_ISOC_PDT(x) (0x400 + (62 * 1024) + ((x) * 32)) +#define SOTG_DATA_ADDR(x) (0x1000 + (512 * (x))) +#define SOTG_ASYNC_PDT(x) (0xC00 + ((x) * 32)) +#define SOTG_INTR_PDT(x) (0x800 + ((x) * 32)) +#define SOTG_ISOC_PDT(x) (0x400 + ((x) * 32)) #define SOTG_HC_MEMORY_ADDR(x) (((x) - 0x400) >> 3) #define SOTG_SW_RESET 0x30C #define SOTG_SW_RESET_HC (1 << 1) @@ -210,6 +211,7 @@ #define SOTG_USBCMD_LHCR (1 << 7) #define SOTG_USBCMD_HCRESET (1 << 1) #define SOTG_USBCMD_RS (1 << 0) +#define SOTG_HCSCRATCH 0x308 #define SOTG_HCINTERRUPT 0x310 #define SOTG_HCINTERRUPT_OTG_IRQ (1 << 10) #define SOTG_HCINTERRUPT_ISO_IRQ (1 << 9) -- cgit v1.3 From c13c64fa63702e9722a6f7dab50b21ba8800686d Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Wed, 21 May 2014 09:26:02 +0000 Subject: - Replace some constants with macros. - Need to set the pre-fetch memory address when reading the host memory. - We currently assume that no endianness conversion is needed. Sponsored by: DARPA, AFRL --- sys/dev/usb/controller/saf1761_otg.c | 156 +++++++++++++++++-------------- sys/dev/usb/controller/saf1761_otg_reg.h | 15 +++ 2 files changed, 103 insertions(+), 68 deletions(-) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/saf1761_otg.c b/sys/dev/usb/controller/saf1761_otg.c index 516188fdd76ac..531477fc77d23 100644 --- a/sys/dev/usb/controller/saf1761_otg.c +++ b/sys/dev/usb/controller/saf1761_otg.c @@ -253,8 +253,8 @@ saf1761_host_channel_free(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t return; /* disable channel */ - SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 3), 0); - SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 0), 0); + SAF1761_WRITE_4(sc, SOTG_PDT(td->channel) + SOTG_PDT_DW3, 0); + SAF1761_WRITE_4(sc, SOTG_PDT(td->channel) + SOTG_PDT_DW0, 0); switch (td->ep_type) { case UE_INTERRUPT: @@ -299,20 +299,25 @@ static uint8_t saf1761_host_setup_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) { struct usb_device_request req __aligned(4); + uint32_t pdt_addr; uint32_t status; uint32_t count; + uint32_t temp; if (td->channel < SOTG_HOST_CHANNEL_MAX) { - status = SAF1761_READ_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 3)); - if (status & (1 << 31)) { + pdt_addr = SOTG_PDT(td->channel); + + saf1761_read_host_memory_4(sc, pdt_addr + SOTG_PDT_DW3, &status, 1); + + if (status & SOTG_PDT_DW3_ACTIVE) { goto busy; - } else if (status & (1 << 30)) { + } else if (status & SOTG_PDT_DW3_HALTED) { td->error_stall = 1; td->error_any = 1; - } else if (status & (3 << 28)) { + } else if (status & SOTG_PDT_DW3_ERRORS) { td->error_any = 1; } - count = (status & 0x7FFF); + count = (status & SOTG_PDT_DW3_XFER_COUNT); saf1761_host_channel_free(sc, td); goto complete; @@ -332,26 +337,27 @@ saf1761_host_setup_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) saf1761_write_host_memory_4(sc, SOTG_DATA_ADDR(td->channel), &req, (count + 3) / 4); - SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 7), 0); - SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 6), 0); - SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 5), 0); - SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 4), 0); - SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 3), - (1 << 31) | (td->toggle << 25) | (3 << 23)); - SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 2), - SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8); - - SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 1), - td->dw1_value | - (2 << 10) /* SETUP PID */ | - (td->ep_index >> 1)); - - SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 0), - (td->ep_index << 31) | - (1 << 29) /* pkt-multiplier */ | + pdt_addr = SOTG_PDT(td->channel); + + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW7, 0); + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW6, 0); + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW5, 0); + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW4, 0); + + temp = SOTG_PDT_DW3_ACTIVE | (td->toggle << 25) | SOTG_PDT_DW3_CERR; + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW3, temp); + + temp = SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8; + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW2, temp); + + temp = td->dw1_value | (2 << 10) /* SETUP PID */ | (td->ep_index >> 1); + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW1, temp); + + temp = (td->ep_index << 31) | (1 << 29) /* pkt-multiplier */ | (td->max_packet_size << 18) /* wMaxPacketSize */ | (count << 3) /* transfer count */ | - 1 /* valid */); + SOTG_PDT_DW0_VALID; + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW0, temp); td->offset += count; td->remainder -= count; @@ -365,24 +371,29 @@ complete: static uint8_t saf1761_host_bulk_data_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) { + uint32_t pdt_addr; + uint32_t temp; + if (td->channel < SOTG_HOST_CHANNEL_MAX) { uint32_t status; uint32_t count; uint8_t got_short; - status = SAF1761_READ_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 3)); + pdt_addr = SOTG_PDT(td->channel); - if (status & (1 << 31)) { + saf1761_read_host_memory_4(sc, pdt_addr + SOTG_PDT_DW3, &status, 1); + + if (status & SOTG_PDT_DW3_ACTIVE) { goto busy; - } else if (status & (1 << 30)) { + } else if (status & SOTG_PDT_DW3_HALTED) { td->error_stall = 1; td->error_any = 1; goto complete; - } else if (status & (3 << 28)) { + } else if (status & SOTG_PDT_DW3_ERRORS) { td->error_any = 1; goto complete; } - count = (status & 0x7FFF); + count = (status & SOTG_PDT_DW3_XFER_COUNT); got_short = 0; /* verify the packet byte count */ @@ -435,26 +446,27 @@ saf1761_host_bulk_data_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t /* receive one more packet */ - SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 7), 0); - SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 6), 0); - SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 5), 0); - SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 4), 0); - SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 3), - (1 << 31) | (td->toggle << 25) | (3 << 23)); - SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 2), - SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8); - - SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 1), - td->dw1_value | - (1 << 10) /* IN-PID */ | - (td->ep_index >> 1)); - - SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 0), - (td->ep_index << 31) | - (1 << 29) /* pkt-multiplier */ | + pdt_addr = SOTG_PDT(td->channel); + + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW7, 0); + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW6, 0); + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW5, 0); + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW4, 0); + + temp = SOTG_PDT_DW3_ACTIVE | (td->toggle << 25) | SOTG_PDT_DW3_CERR; + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW3, temp); + + temp = SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8; + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW2, temp); + + temp = td->dw1_value | (1 << 10) /* IN-PID */ | (td->ep_index >> 1); + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW1, temp); + + temp = (td->ep_index << 31) | (1 << 29) /* pkt-multiplier */ | (td->max_packet_size << 18) /* wMaxPacketSize */ | (td->max_packet_size << 3) /* transfer count */ | - 1 /* valid */); + SOTG_PDT_DW0_VALID; + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW0, temp); busy: return (1); /* busy */ complete: @@ -464,18 +476,23 @@ complete: static uint8_t saf1761_host_bulk_data_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) { + uint32_t pdt_addr; + uint32_t temp; uint32_t count; if (td->channel < SOTG_HOST_CHANNEL_MAX) { uint32_t status; - status = SAF1761_READ_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 3)); - if (status & (1 << 31)) { + pdt_addr = SOTG_PDT(td->channel); + + saf1761_read_host_memory_4(sc, pdt_addr + SOTG_PDT_DW3, &status, 1); + + if (status & SOTG_PDT_DW3_ACTIVE) { goto busy; - } else if (status & (1 << 30)) { + } else if (status & SOTG_PDT_DW3_HALTED) { td->error_stall = 1; td->error_any = 1; - } else if (status & (3 << 28)) { + } else if (status & SOTG_PDT_DW3_ERRORS) { td->error_any = 1; } @@ -508,26 +525,29 @@ saf1761_host_bulk_data_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t td->toggle = 1; } - SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 7), 0); - SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 6), 0); - SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 5), 0); - SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 4), 0); - SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 3), - (1 << 31) | (td->toggle << 25) | (3 << 23)); - SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 2), - SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8); + /* send one more packet */ + + pdt_addr = SOTG_PDT(td->channel); + + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW7, 0); + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW6, 0); + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW5, 0); + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW4, 0); + + temp = SOTG_PDT_DW3_ACTIVE | (td->toggle << 25) | SOTG_PDT_DW3_CERR; + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW3, temp); + + temp = SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8; + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW2, temp); - SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 1), - td->dw1_value | - (0 << 10) /* OUT-PID */ | - (td->ep_index >> 1)); + temp = td->dw1_value | (0 << 10) /* OUT-PID */ | (td->ep_index >> 1); + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW1, temp); - SAF1761_WRITE_4(sc, SOTG_ISOC_PDT(td->channel) + (4 * 0), - (td->ep_index << 31) | - (1 << 29) /* pkt-multiplier */ | + temp = (td->ep_index << 31) | (1 << 29) /* pkt-multiplier */ | (td->max_packet_size << 18) /* wMaxPacketSize */ | (count << 3) /* transfer count */ | - 1 /* valid */); + SOTG_PDT_DW0_VALID; + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW0, temp); td->offset += count; td->remainder -= count; diff --git a/sys/dev/usb/controller/saf1761_otg_reg.h b/sys/dev/usb/controller/saf1761_otg_reg.h index 565c3acc5ba1e..6e104bcf16420 100644 --- a/sys/dev/usb/controller/saf1761_otg_reg.h +++ b/sys/dev/usb/controller/saf1761_otg_reg.h @@ -189,10 +189,25 @@ #define SOTG_PORTSC1_PED (1 << 2) #define SOTG_PORTSC1_ECSC (1 << 1) #define SOTG_PORTSC1_ECCS (1 << 0) +#define SOTG_PDT_DW0 0 +#define SOTG_PDT_DW0_VALID 1U +#define SOTG_PDT_DW1 4 +#define SOTG_PDT_DW2 8 +#define SOTG_PDT_DW3 12 +#define SOTG_PDT_DW3_ACTIVE (1U << 31) +#define SOTG_PDT_DW3_HALTED (1U << 30) +#define SOTG_PDT_DW3_ERRORS (3U << 28) +#define SOTG_PDT_DW3_CERR (3U << 23) +#define SOTG_PDT_DW3_XFER_COUNT 0x7FFF +#define SOTG_PDT_DW4 16 +#define SOTG_PDT_DW5 20 +#define SOTG_PDT_DW6 24 +#define SOTG_PDT_DW7 28 #define SOTG_DATA_ADDR(x) (0x1000 + (512 * (x))) #define SOTG_ASYNC_PDT(x) (0xC00 + ((x) * 32)) #define SOTG_INTR_PDT(x) (0x800 + ((x) * 32)) #define SOTG_ISOC_PDT(x) (0x400 + ((x) * 32)) +#define SOTG_PDT(x) (0x400 + ((x) * 32)) #define SOTG_HC_MEMORY_ADDR(x) (((x) - 0x400) >> 3) #define SOTG_SW_RESET 0x30C #define SOTG_SW_RESET_HC (1 << 1) -- cgit v1.3 From 8e14e4a03aeb907798b24c7de6cb07080663387c Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Wed, 21 May 2014 17:22:41 +0000 Subject: Implement interrupt endpoint methods for host mode transfers. Sponsored by: DARPA, AFRL --- sys/dev/usb/controller/saf1761_otg.c | 193 ++++++++++++++++++++++++++++++++++- sys/dev/usb/controller/saf1761_otg.h | 2 + 2 files changed, 194 insertions(+), 1 deletion(-) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/saf1761_otg.c b/sys/dev/usb/controller/saf1761_otg.c index 531477fc77d23..083fb09dda7a9 100644 --- a/sys/dev/usb/controller/saf1761_otg.c +++ b/sys/dev/usb/controller/saf1761_otg.c @@ -561,13 +561,195 @@ complete: static uint8_t saf1761_host_intr_data_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) { + uint32_t pdt_addr; + uint32_t temp; + + if (td->channel < SOTG_HOST_CHANNEL_MAX) { + uint32_t status; + uint32_t count; + uint8_t got_short; + + pdt_addr = SOTG_PDT(td->channel); + + saf1761_read_host_memory_4(sc, pdt_addr + SOTG_PDT_DW3, &status, 1); + + if (status & SOTG_PDT_DW3_ACTIVE) { + goto busy; + } else if (status & SOTG_PDT_DW3_HALTED) { + td->error_stall = 1; + td->error_any = 1; + goto complete; + } + + count = (status & SOTG_PDT_DW3_XFER_COUNT); + got_short = 0; + + /* verify the packet byte count */ + if (count != td->max_packet_size) { + if (count < td->max_packet_size) { + /* we have a short packet */ + td->short_pkt = 1; + got_short = 1; + } else { + /* invalid USB packet */ + td->error_any = 1; + goto complete; + } + } + td->toggle ^= 1; + + /* verify the packet byte count */ + if (count > td->remainder) { + /* invalid USB packet */ + td->error_any = 1; + goto complete; + } + + saf1761_read_host_memory_4(sc, SOTG_DATA_ADDR(td->channel), + sc->sc_bounce_buffer, (count + 3) / 4); + + usbd_copy_in(td->pc, td->offset, + sc->sc_bounce_buffer, count); + + td->remainder -= count; + td->offset += count; + + saf1761_host_channel_free(sc, td); + + /* check if we are complete */ + if ((td->remainder == 0) || got_short) { + if (td->short_pkt) + goto complete; + /* else need to receive a zero length packet */ + } + } + if (saf1761_host_channel_alloc(sc, td)) + goto busy; + + /* set toggle, if any */ + if (td->set_toggle) { + td->set_toggle = 0; + td->toggle = 1; + } + + /* receive one more packet */ + + pdt_addr = SOTG_PDT(td->channel); + + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW7, 0); + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW6, 0); + + temp = (0xFC << td->uframe) & 0xFF; /* complete split */ + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW5, temp); + + temp = (1U << td->uframe); /* start split */ + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW4, temp); + + temp = SOTG_PDT_DW3_ACTIVE | (td->toggle << 25) | SOTG_PDT_DW3_CERR; + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW3, temp); + + temp = (SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8) | td->interval; + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW2, temp); + + temp = td->dw1_value | (1 << 10) /* IN-PID */ | (td->ep_index >> 1); + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW1, temp); + + temp = (td->ep_index << 31) | (1 << 29) /* pkt-multiplier */ | + (td->max_packet_size << 18) /* wMaxPacketSize */ | + (td->max_packet_size << 3) /* transfer count */ | + SOTG_PDT_DW0_VALID; + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW0, temp); +busy: return (1); /* busy */ +complete: + return (0); /* complete */ } static uint8_t saf1761_host_intr_data_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) { + uint32_t pdt_addr; + uint32_t temp; + uint32_t count; + + if (td->channel < SOTG_HOST_CHANNEL_MAX) { + uint32_t status; + + pdt_addr = SOTG_PDT(td->channel); + + saf1761_read_host_memory_4(sc, pdt_addr + SOTG_PDT_DW3, &status, 1); + + if (status & SOTG_PDT_DW3_ACTIVE) { + goto busy; + } else if (status & SOTG_PDT_DW3_HALTED) { + td->error_stall = 1; + td->error_any = 1; + } + + saf1761_host_channel_free(sc, td); + + /* check remainder */ + if (td->remainder == 0) { + if (td->short_pkt) + goto complete; + /* else we need to transmit a short packet */ + } + } + if (saf1761_host_channel_alloc(sc, td)) + goto busy; + + count = td->max_packet_size; + if (td->remainder < count) { + /* we have a short packet */ + td->short_pkt = 1; + count = td->remainder; + } + + usbd_copy_out(td->pc, td->offset, sc->sc_bounce_buffer, count); + saf1761_write_host_memory_4(sc, SOTG_DATA_ADDR(td->channel), + sc->sc_bounce_buffer, (count + 3) / 4); + + /* set toggle, if any */ + if (td->set_toggle) { + td->set_toggle = 0; + td->toggle = 1; + } + + /* send one more packet */ + + pdt_addr = SOTG_PDT(td->channel); + + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW7, 0); + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW6, 0); + + temp = (0xFC << td->uframe) & 0xFF; /* complete split */ + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW5, temp); + + temp = (1U << td->uframe); /* start split */ + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW4, temp); + + temp = SOTG_PDT_DW3_ACTIVE | (td->toggle << 25) | SOTG_PDT_DW3_CERR; + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW3, temp); + + temp = (SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8) | td->interval; + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW2, temp); + + temp = td->dw1_value | (0 << 10) /* OUT-PID */ | (td->ep_index >> 1); + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW1, temp); + + temp = (td->ep_index << 31) | (1 << 29) /* pkt-multiplier */ | + (td->max_packet_size << 18) /* wMaxPacketSize */ | + (count << 3) /* transfer count */ | + SOTG_PDT_DW0_VALID; + SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW0, temp); + + td->offset += count; + td->remainder -= count; + td->toggle ^= 1; +busy: return (1); /* busy */ +complete: + return (0); /* complete */ } static uint8_t @@ -2692,7 +2874,15 @@ saf1761_otg_xfer_setup(struct usb_setup_params *parm) td->ep_index = ep_no; td->ep_type = ep_type; td->dw1_value = dw1; - + td->uframe = 0; + if (ep_type == UE_INTERRUPT) { + if (xfer->interval > 32) + td->interval = 32 / 2; + else + td->interval = xfer->interval / 2; + } else { + td->interval = 0; + } td->obj_next = last_obj; last_obj = td; @@ -2739,6 +2929,7 @@ saf1761_otg_ep_init(struct usb_device *udev, struct usb_endpoint_descriptor *ede switch (edesc->bmAttributes & UE_XFERTYPE) { case UE_CONTROL: case UE_BULK: + case UE_INTERRUPT: ep->methods = &saf1761_otg_non_isoc_methods; break; default: diff --git a/sys/dev/usb/controller/saf1761_otg.h b/sys/dev/usb/controller/saf1761_otg.h index 55c454274cf1d..de3d51ffb2808 100644 --- a/sys/dev/usb/controller/saf1761_otg.h +++ b/sys/dev/usb/controller/saf1761_otg.h @@ -70,6 +70,8 @@ struct saf1761_otg_td { uint8_t ep_index; uint8_t ep_type; uint8_t channel; + uint8_t uframe; + uint8_t interval; uint8_t error_any:1; uint8_t error_stall:1; uint8_t alt_next:1; -- cgit v1.3 From c73bbf989dfa062d2d0246d14c93f86b4ee2fd96 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Thu, 22 May 2014 11:58:15 +0000 Subject: - Fix a bug where the TLBPC value was forced to being odd for IN direction isochronous transfers. - Remove setting of fields which does not belong to the respective TRBs. These fields are currently set as zero and this is more a cosmetic change. MFC after: 3 days Submitted by: Horse Ma --- sys/dev/usb/controller/xhci.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/xhci.c b/sys/dev/usb/controller/xhci.c index 5092cc962727e..4570ad2aab840 100644 --- a/sys/dev/usb/controller/xhci.c +++ b/sys/dev/usb/controller/xhci.c @@ -1849,31 +1849,25 @@ restart: XHCI_TRB_3_ISO_SIA_BIT; } if (temp->direction == UE_DIR_IN) - dword |= XHCI_TRB_3_DIR_IN | XHCI_TRB_3_ISP_BIT; + dword |= XHCI_TRB_3_ISP_BIT; break; case XHCI_TRB_TYPE_DATA_STAGE: dword = XHCI_TRB_3_CHAIN_BIT | XHCI_TRB_3_CYCLE_BIT | - XHCI_TRB_3_TYPE_SET(XHCI_TRB_TYPE_DATA_STAGE) | - XHCI_TRB_3_TBC_SET(temp->tbc) | - XHCI_TRB_3_TLBPC_SET(temp->tlbpc); + XHCI_TRB_3_TYPE_SET(XHCI_TRB_TYPE_DATA_STAGE); if (temp->direction == UE_DIR_IN) dword |= XHCI_TRB_3_DIR_IN | XHCI_TRB_3_ISP_BIT; break; case XHCI_TRB_TYPE_STATUS_STAGE: dword = XHCI_TRB_3_CHAIN_BIT | XHCI_TRB_3_CYCLE_BIT | - XHCI_TRB_3_TYPE_SET(XHCI_TRB_TYPE_STATUS_STAGE) | - XHCI_TRB_3_TBC_SET(temp->tbc) | - XHCI_TRB_3_TLBPC_SET(temp->tlbpc); + XHCI_TRB_3_TYPE_SET(XHCI_TRB_TYPE_STATUS_STAGE); if (temp->direction == UE_DIR_IN) dword |= XHCI_TRB_3_DIR_IN; break; default: /* XHCI_TRB_TYPE_NORMAL */ dword = XHCI_TRB_3_CHAIN_BIT | XHCI_TRB_3_CYCLE_BIT | - XHCI_TRB_3_TYPE_SET(XHCI_TRB_TYPE_NORMAL) | - XHCI_TRB_3_TBC_SET(temp->tbc) | - XHCI_TRB_3_TLBPC_SET(temp->tlbpc); + XHCI_TRB_3_TYPE_SET(XHCI_TRB_TYPE_NORMAL); if (temp->direction == UE_DIR_IN) - dword |= XHCI_TRB_3_DIR_IN | XHCI_TRB_3_ISP_BIT; + dword |= XHCI_TRB_3_ISP_BIT; break; } td->td_trb[x].dwTrb3 = htole32(dword); -- cgit v1.3 From 3bee4e7bdbd998cb439e71902f199e79706e0e22 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Sun, 25 May 2014 06:42:43 +0000 Subject: Make SAF1761 driver endian safe. Sponsored by: DARPA, AFRL --- sys/dev/usb/controller/saf1761_otg.h | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/saf1761_otg.h b/sys/dev/usb/controller/saf1761_otg.h index de3d51ffb2808..9b19d3c965c3f 100644 --- a/sys/dev/usb/controller/saf1761_otg.h +++ b/sys/dev/usb/controller/saf1761_otg.h @@ -40,19 +40,27 @@ #define SOTG_DEVICE_PORT_NUM 2 #define SOTG_HOST_CHANNEL_MAX (3 * 32) -#define SAF1761_READ_1(sc, reg) \ - bus_space_read_1((sc)->sc_io_tag, (sc)->sc_io_hdl, reg) -#define SAF1761_READ_2(sc, reg) \ - bus_space_read_2((sc)->sc_io_tag, (sc)->sc_io_hdl, reg) -#define SAF1761_READ_4(sc, reg) \ - bus_space_read_4((sc)->sc_io_tag, (sc)->sc_io_hdl, reg) +/* Macros used for reading and writing registers */ + +#define SAF1761_READ_1(sc, reg) \ + bus_space_read_1((sc)->sc_io_tag, (sc)->sc_io_hdl, (reg)) +#define SAF1761_READ_2(sc, reg) ({ uint16_t _temp; \ + _temp = bus_space_read_2((sc)->sc_io_tag, (sc)->sc_io_hdl, (reg)); \ + le16toh(_temp); }) +#define SAF1761_READ_4(sc, reg) ({ uint32_t _temp; \ + _temp = bus_space_read_4((sc)->sc_io_tag, (sc)->sc_io_hdl, (reg)); \ + le32toh(_temp); }) #define SAF1761_WRITE_1(sc, reg, data) \ - bus_space_write_1((sc)->sc_io_tag, (sc)->sc_io_hdl, reg, data) -#define SAF1761_WRITE_2(sc, reg, data) \ - bus_space_write_2((sc)->sc_io_tag, (sc)->sc_io_hdl, reg, data) -#define SAF1761_WRITE_4(sc, reg, data) \ - bus_space_write_4((sc)->sc_io_tag, (sc)->sc_io_hdl, reg, data) + bus_space_write_1((sc)->sc_io_tag, (sc)->sc_io_hdl, (reg), data) +#define SAF1761_WRITE_2(sc, reg, data) do { \ + uint16_t _temp = (data); \ + bus_space_write_2((sc)->sc_io_tag, (sc)->sc_io_hdl, (reg), htole16(_temp)); \ +} while (0) +#define SAF1761_WRITE_4(sc, reg, data) do { \ + uint32_t _temp = (data); \ + bus_space_write_4((sc)->sc_io_tag, (sc)->sc_io_hdl, (reg), htole32(_temp)); \ +} while (0) struct saf1761_otg_softc; struct saf1761_otg_td; -- cgit v1.3 From 21c85d9d3b050ad5ab343d0c2e4dcec9fa3579ff Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Tue, 27 May 2014 10:01:19 +0000 Subject: Multiple fixes and improvements: - Put "_LE_" into the register access macros to indicate little endian byte order is expected by the hardware. - Avoid using the bounce buffer when not strictly needed. Try to move data directly using bus-space functions first. - Ensure we preserve the reserved bits in the power down mode register. Else the hardware goes into a non-recoverable state. - Always use 32-bit access when writing or reading registers or FIFOs, because the hardware is 32-bit oriented and don't really understand 8- and 16-bit access. - Correct writes to the memory address register. There is no need to shift the register offset. - Correct interval for interrupt endpoints. - Optimise 90ns internal memory buffer read delay. - Rename PDT into PTD, which is how the datasheet writes it. - Add missing programming for activating host controller PTDs. Sponsored by: DARPA, AFRL --- sys/dev/usb/controller/saf1761_otg.c | 759 ++++++++++++++++++------------- sys/dev/usb/controller/saf1761_otg.h | 31 +- sys/dev/usb/controller/saf1761_otg_reg.h | 90 ++-- 3 files changed, 520 insertions(+), 360 deletions(-) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/saf1761_otg.c b/sys/dev/usb/controller/saf1761_otg.c index 083fb09dda7a9..888face0f3a18 100644 --- a/sys/dev/usb/controller/saf1761_otg.c +++ b/sys/dev/usb/controller/saf1761_otg.c @@ -195,9 +195,9 @@ saf1761_otg_wakeup_peer(struct saf1761_otg_softc *sc) DPRINTFN(5, "\n"); - temp = SAF1761_READ_2(sc, SOTG_MODE); - SAF1761_WRITE_2(sc, SOTG_MODE, temp | SOTG_MODE_SNDRSU); - SAF1761_WRITE_2(sc, SOTG_MODE, temp & ~SOTG_MODE_SNDRSU); + temp = SAF1761_READ_LE_4(sc, SOTG_MODE); + SAF1761_WRITE_LE_4(sc, SOTG_MODE, temp | SOTG_MODE_SNDRSU); + SAF1761_WRITE_LE_4(sc, SOTG_MODE, temp & ~SOTG_MODE_SNDRSU); /* Wait 8ms for remote wakeup to complete. */ usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 125); @@ -253,8 +253,8 @@ saf1761_host_channel_free(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t return; /* disable channel */ - SAF1761_WRITE_4(sc, SOTG_PDT(td->channel) + SOTG_PDT_DW3, 0); - SAF1761_WRITE_4(sc, SOTG_PDT(td->channel) + SOTG_PDT_DW0, 0); + SAF1761_WRITE_LE_4(sc, SOTG_PTD(td->channel) + SOTG_PTD_DW3, 0); + SAF1761_WRITE_LE_4(sc, SOTG_PTD(td->channel) + SOTG_PTD_DW0, 0); switch (td->ep_type) { case UE_INTERRUPT: @@ -275,49 +275,143 @@ saf1761_host_channel_free(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t } } +static uint32_t +saf1761_peek_host_memory_le_4(struct saf1761_otg_softc *sc, uint32_t offset) +{ + SAF1761_WRITE_LE_4(sc, SOTG_MEMORY_REG, offset); + SAF1761_90NS_DELAY(sc); /* read prefetch time is 90ns */ + return (SAF1761_READ_LE_4(sc, offset)); +} + static void -saf1761_read_host_memory_4(struct saf1761_otg_softc *sc, uint32_t offset, - void *buf, uint32_t count) +saf1761_read_host_memory(struct saf1761_otg_softc *sc, + struct saf1761_otg_td *td, uint32_t len) { - if (count == 0) + struct usb_page_search buf_res; + uint32_t offset; + uint32_t count; + + if (len == 0) return; - SAF1761_WRITE_4(sc, SOTG_MEMORY_REG, SOTG_HC_MEMORY_ADDR(offset)); - DELAY(1); /* read prefetch time is 90ns */ - bus_space_read_region_4((sc)->sc_io_tag, (sc)->sc_io_hdl, offset, buf, count); + + offset = SOTG_DATA_ADDR(td->channel); + SAF1761_WRITE_LE_4(sc, SOTG_MEMORY_REG, offset); + SAF1761_90NS_DELAY(sc); /* read prefetch time is 90ns */ + + /* optimised read first */ + while (len > 0) { + usbd_get_page(td->pc, td->offset, &buf_res); + + /* get correct length */ + if (buf_res.length > len) + buf_res.length = len; + + /* check buffer alignment */ + if (((uintptr_t)buf_res.buffer) & 3) + break; + + count = buf_res.length & ~3; + if (count == 0) + break; + + bus_space_read_region_4((sc)->sc_io_tag, (sc)->sc_io_hdl, + offset, buf_res.buffer, count / 4); + + len -= count; + offset += count; + + /* update remainder and offset */ + td->remainder -= count; + td->offset += count; + } + + if (len > 0) { + /* use bounce buffer */ + bus_space_read_region_4((sc)->sc_io_tag, (sc)->sc_io_hdl, + offset, sc->sc_bounce_buffer, (len + 3) / 4); + usbd_copy_in(td->pc, td->offset, + sc->sc_bounce_buffer, len); + + /* update remainder and offset */ + td->remainder -= len; + td->offset += len; + } } static void -saf1761_write_host_memory_4(struct saf1761_otg_softc *sc, uint32_t offset, - void *buf, uint32_t count) +saf1761_write_host_memory(struct saf1761_otg_softc *sc, + struct saf1761_otg_td *td, uint32_t len) { - if (count == 0) + struct usb_page_search buf_res; + uint32_t offset; + uint32_t count; + + if (len == 0) return; - bus_space_write_region_4((sc)->sc_io_tag, (sc)->sc_io_hdl, offset, buf, count); + + offset = SOTG_DATA_ADDR(td->channel); + + /* optimised write first */ + while (len > 0) { + usbd_get_page(td->pc, td->offset, &buf_res); + + /* get correct length */ + if (buf_res.length > len) + buf_res.length = len; + + /* check buffer alignment */ + if (((uintptr_t)buf_res.buffer) & 3) + break; + + count = buf_res.length & ~3; + if (count == 0) + break; + + bus_space_write_region_4((sc)->sc_io_tag, (sc)->sc_io_hdl, + offset, buf_res.buffer, count / 4); + + len -= count; + offset += count; + + /* update remainder and offset */ + td->remainder -= count; + td->offset += count; + } + if (len > 0) { + /* use bounce buffer */ + usbd_copy_out(td->pc, td->offset, sc->sc_bounce_buffer, len); + bus_space_write_region_4((sc)->sc_io_tag, (sc)->sc_io_hdl, + offset, sc->sc_bounce_buffer, (len + 3) / 4); + + /* update remainder and offset */ + td->remainder -= len; + td->offset += len; + } } static uint8_t saf1761_host_setup_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) { - struct usb_device_request req __aligned(4); uint32_t pdt_addr; uint32_t status; uint32_t count; uint32_t temp; if (td->channel < SOTG_HOST_CHANNEL_MAX) { - pdt_addr = SOTG_PDT(td->channel); + pdt_addr = SOTG_PTD(td->channel); - saf1761_read_host_memory_4(sc, pdt_addr + SOTG_PDT_DW3, &status, 1); + status = saf1761_peek_host_memory_le_4(sc, pdt_addr + SOTG_PTD_DW3); + DPRINTFN(5, "STATUS=0x%08x\n", status); - if (status & SOTG_PDT_DW3_ACTIVE) { + if (status & SOTG_PTD_DW3_ACTIVE) { goto busy; - } else if (status & SOTG_PDT_DW3_HALTED) { + } else if (status & SOTG_PTD_DW3_HALTED) { td->error_stall = 1; td->error_any = 1; - } else if (status & SOTG_PDT_DW3_ERRORS) { + } else if (status & SOTG_PTD_DW3_ERRORS) { td->error_any = 1; } - count = (status & SOTG_PDT_DW3_XFER_COUNT); + count = (status & SOTG_PTD_DW3_XFER_COUNT); saf1761_host_channel_free(sc, td); goto complete; @@ -325,42 +419,37 @@ saf1761_host_setup_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) if (saf1761_host_channel_alloc(sc, td)) goto busy; - if (sizeof(req) != td->remainder) { + count = 8; + + if (count != td->remainder) { td->error_any = 1; goto complete; } - count = sizeof(req); - - usbd_copy_out(td->pc, 0, &req, count); + saf1761_write_host_memory(sc, td, count); - saf1761_write_host_memory_4(sc, SOTG_DATA_ADDR(td->channel), - &req, (count + 3) / 4); + pdt_addr = SOTG_PTD(td->channel); - pdt_addr = SOTG_PDT(td->channel); + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW7, 0); + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW6, 0); + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW5, 0); + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW4, 0); - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW7, 0); - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW6, 0); - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW5, 0); - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW4, 0); - - temp = SOTG_PDT_DW3_ACTIVE | (td->toggle << 25) | SOTG_PDT_DW3_CERR; - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW3, temp); + temp = SOTG_PTD_DW3_ACTIVE | (td->toggle << 25) | SOTG_PTD_DW3_CERR; + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW3, temp); temp = SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8; - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW2, temp); + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW2, temp); temp = td->dw1_value | (2 << 10) /* SETUP PID */ | (td->ep_index >> 1); - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW1, temp); + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW1, temp); temp = (td->ep_index << 31) | (1 << 29) /* pkt-multiplier */ | (td->max_packet_size << 18) /* wMaxPacketSize */ | (count << 3) /* transfer count */ | - SOTG_PDT_DW0_VALID; - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW0, temp); + SOTG_PTD_DW0_VALID; + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW0, temp); - td->offset += count; - td->remainder -= count; td->toggle = 1; busy: return (1); /* busy */ @@ -379,21 +468,22 @@ saf1761_host_bulk_data_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t uint32_t count; uint8_t got_short; - pdt_addr = SOTG_PDT(td->channel); + pdt_addr = SOTG_PTD(td->channel); - saf1761_read_host_memory_4(sc, pdt_addr + SOTG_PDT_DW3, &status, 1); + status = saf1761_peek_host_memory_le_4(sc, pdt_addr + SOTG_PTD_DW3); + DPRINTFN(5, "STATUS=0x%08x\n", status); - if (status & SOTG_PDT_DW3_ACTIVE) { + if (status & SOTG_PTD_DW3_ACTIVE) { goto busy; - } else if (status & SOTG_PDT_DW3_HALTED) { + } else if (status & SOTG_PTD_DW3_HALTED) { td->error_stall = 1; td->error_any = 1; goto complete; - } else if (status & SOTG_PDT_DW3_ERRORS) { + } else if (status & SOTG_PTD_DW3_ERRORS) { td->error_any = 1; goto complete; } - count = (status & SOTG_PDT_DW3_XFER_COUNT); + count = (status & SOTG_PTD_DW3_XFER_COUNT); got_short = 0; /* verify the packet byte count */ @@ -417,14 +507,7 @@ saf1761_host_bulk_data_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t goto complete; } - saf1761_read_host_memory_4(sc, SOTG_DATA_ADDR(td->channel), - sc->sc_bounce_buffer, (count + 3) / 4); - - usbd_copy_in(td->pc, td->offset, - sc->sc_bounce_buffer, count); - - td->remainder -= count; - td->offset += count; + saf1761_read_host_memory(sc, td, count); saf1761_host_channel_free(sc, td); @@ -446,27 +529,27 @@ saf1761_host_bulk_data_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t /* receive one more packet */ - pdt_addr = SOTG_PDT(td->channel); + pdt_addr = SOTG_PTD(td->channel); - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW7, 0); - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW6, 0); - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW5, 0); - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW4, 0); + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW7, 0); + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW6, 0); + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW5, 0); + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW4, 0); - temp = SOTG_PDT_DW3_ACTIVE | (td->toggle << 25) | SOTG_PDT_DW3_CERR; - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW3, temp); + temp = SOTG_PTD_DW3_ACTIVE | (td->toggle << 25) | SOTG_PTD_DW3_CERR; + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW3, temp); temp = SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8; - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW2, temp); + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW2, temp); temp = td->dw1_value | (1 << 10) /* IN-PID */ | (td->ep_index >> 1); - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW1, temp); + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW1, temp); temp = (td->ep_index << 31) | (1 << 29) /* pkt-multiplier */ | (td->max_packet_size << 18) /* wMaxPacketSize */ | (td->max_packet_size << 3) /* transfer count */ | - SOTG_PDT_DW0_VALID; - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW0, temp); + SOTG_PTD_DW0_VALID; + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW0, temp); busy: return (1); /* busy */ complete: @@ -483,16 +566,17 @@ saf1761_host_bulk_data_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t if (td->channel < SOTG_HOST_CHANNEL_MAX) { uint32_t status; - pdt_addr = SOTG_PDT(td->channel); + pdt_addr = SOTG_PTD(td->channel); - saf1761_read_host_memory_4(sc, pdt_addr + SOTG_PDT_DW3, &status, 1); + status = saf1761_peek_host_memory_le_4(sc, pdt_addr + SOTG_PTD_DW3); + DPRINTFN(5, "STATUS=0x%08x\n", status); - if (status & SOTG_PDT_DW3_ACTIVE) { + if (status & SOTG_PTD_DW3_ACTIVE) { goto busy; - } else if (status & SOTG_PDT_DW3_HALTED) { + } else if (status & SOTG_PTD_DW3_HALTED) { td->error_stall = 1; td->error_any = 1; - } else if (status & SOTG_PDT_DW3_ERRORS) { + } else if (status & SOTG_PTD_DW3_ERRORS) { td->error_any = 1; } @@ -515,9 +599,7 @@ saf1761_host_bulk_data_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t count = td->remainder; } - usbd_copy_out(td->pc, td->offset, sc->sc_bounce_buffer, count); - saf1761_write_host_memory_4(sc, SOTG_DATA_ADDR(td->channel), - sc->sc_bounce_buffer, (count + 3) / 4); + saf1761_write_host_memory(sc, td, count); /* set toggle, if any */ if (td->set_toggle) { @@ -527,30 +609,28 @@ saf1761_host_bulk_data_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t /* send one more packet */ - pdt_addr = SOTG_PDT(td->channel); + pdt_addr = SOTG_PTD(td->channel); - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW7, 0); - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW6, 0); - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW5, 0); - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW4, 0); + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW7, 0); + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW6, 0); + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW5, 0); + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW4, 0); - temp = SOTG_PDT_DW3_ACTIVE | (td->toggle << 25) | SOTG_PDT_DW3_CERR; - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW3, temp); + temp = SOTG_PTD_DW3_ACTIVE | (td->toggle << 25) | SOTG_PTD_DW3_CERR; + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW3, temp); temp = SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8; - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW2, temp); + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW2, temp); temp = td->dw1_value | (0 << 10) /* OUT-PID */ | (td->ep_index >> 1); - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW1, temp); + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW1, temp); temp = (td->ep_index << 31) | (1 << 29) /* pkt-multiplier */ | (td->max_packet_size << 18) /* wMaxPacketSize */ | (count << 3) /* transfer count */ | - SOTG_PDT_DW0_VALID; - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW0, temp); + SOTG_PTD_DW0_VALID; + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW0, temp); - td->offset += count; - td->remainder -= count; td->toggle ^= 1; busy: return (1); /* busy */ @@ -569,19 +649,20 @@ saf1761_host_intr_data_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t uint32_t count; uint8_t got_short; - pdt_addr = SOTG_PDT(td->channel); + pdt_addr = SOTG_PTD(td->channel); - saf1761_read_host_memory_4(sc, pdt_addr + SOTG_PDT_DW3, &status, 1); + status = saf1761_peek_host_memory_le_4(sc, pdt_addr + SOTG_PTD_DW3); + DPRINTFN(5, "STATUS=0x%08x\n", status); - if (status & SOTG_PDT_DW3_ACTIVE) { + if (status & SOTG_PTD_DW3_ACTIVE) { goto busy; - } else if (status & SOTG_PDT_DW3_HALTED) { + } else if (status & SOTG_PTD_DW3_HALTED) { td->error_stall = 1; td->error_any = 1; goto complete; } - count = (status & SOTG_PDT_DW3_XFER_COUNT); + count = (status & SOTG_PTD_DW3_XFER_COUNT); got_short = 0; /* verify the packet byte count */ @@ -605,14 +686,7 @@ saf1761_host_intr_data_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t goto complete; } - saf1761_read_host_memory_4(sc, SOTG_DATA_ADDR(td->channel), - sc->sc_bounce_buffer, (count + 3) / 4); - - usbd_copy_in(td->pc, td->offset, - sc->sc_bounce_buffer, count); - - td->remainder -= count; - td->offset += count; + saf1761_read_host_memory(sc, td, count); saf1761_host_channel_free(sc, td); @@ -634,31 +708,31 @@ saf1761_host_intr_data_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t /* receive one more packet */ - pdt_addr = SOTG_PDT(td->channel); + pdt_addr = SOTG_PTD(td->channel); - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW7, 0); - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW6, 0); + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW7, 0); + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW6, 0); temp = (0xFC << td->uframe) & 0xFF; /* complete split */ - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW5, temp); + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW5, temp); temp = (1U << td->uframe); /* start split */ - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW4, temp); + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW4, temp); - temp = SOTG_PDT_DW3_ACTIVE | (td->toggle << 25) | SOTG_PDT_DW3_CERR; - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW3, temp); + temp = SOTG_PTD_DW3_ACTIVE | (td->toggle << 25) | SOTG_PTD_DW3_CERR; + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW3, temp); - temp = (SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8) | td->interval; - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW2, temp); + temp = (SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8) | (td->interval & 0xF8); + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW2, temp); temp = td->dw1_value | (1 << 10) /* IN-PID */ | (td->ep_index >> 1); - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW1, temp); + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW1, temp); temp = (td->ep_index << 31) | (1 << 29) /* pkt-multiplier */ | (td->max_packet_size << 18) /* wMaxPacketSize */ | (td->max_packet_size << 3) /* transfer count */ | - SOTG_PDT_DW0_VALID; - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW0, temp); + SOTG_PTD_DW0_VALID; + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW0, temp); busy: return (1); /* busy */ complete: @@ -675,13 +749,14 @@ saf1761_host_intr_data_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t if (td->channel < SOTG_HOST_CHANNEL_MAX) { uint32_t status; - pdt_addr = SOTG_PDT(td->channel); + pdt_addr = SOTG_PTD(td->channel); - saf1761_read_host_memory_4(sc, pdt_addr + SOTG_PDT_DW3, &status, 1); + status = saf1761_peek_host_memory_le_4(sc, pdt_addr + SOTG_PTD_DW3); + DPRINTFN(5, "STATUS=0x%08x\n", status); - if (status & SOTG_PDT_DW3_ACTIVE) { + if (status & SOTG_PTD_DW3_ACTIVE) { goto busy; - } else if (status & SOTG_PDT_DW3_HALTED) { + } else if (status & SOTG_PTD_DW3_HALTED) { td->error_stall = 1; td->error_any = 1; } @@ -705,9 +780,7 @@ saf1761_host_intr_data_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t count = td->remainder; } - usbd_copy_out(td->pc, td->offset, sc->sc_bounce_buffer, count); - saf1761_write_host_memory_4(sc, SOTG_DATA_ADDR(td->channel), - sc->sc_bounce_buffer, (count + 3) / 4); + saf1761_write_host_memory(sc, td, count); /* set toggle, if any */ if (td->set_toggle) { @@ -717,34 +790,32 @@ saf1761_host_intr_data_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t /* send one more packet */ - pdt_addr = SOTG_PDT(td->channel); + pdt_addr = SOTG_PTD(td->channel); - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW7, 0); - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW6, 0); + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW7, 0); + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW6, 0); temp = (0xFC << td->uframe) & 0xFF; /* complete split */ - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW5, temp); + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW5, temp); temp = (1U << td->uframe); /* start split */ - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW4, temp); + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW4, temp); - temp = SOTG_PDT_DW3_ACTIVE | (td->toggle << 25) | SOTG_PDT_DW3_CERR; - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW3, temp); + temp = SOTG_PTD_DW3_ACTIVE | (td->toggle << 25) | SOTG_PTD_DW3_CERR; + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW3, temp); - temp = (SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8) | td->interval; - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW2, temp); + temp = (SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8) | (td->interval & 0xF8); + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW2, temp); temp = td->dw1_value | (0 << 10) /* OUT-PID */ | (td->ep_index >> 1); - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW1, temp); + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW1, temp); temp = (td->ep_index << 31) | (1 << 29) /* pkt-multiplier */ | (td->max_packet_size << 18) /* wMaxPacketSize */ | (count << 3) /* transfer count */ | - SOTG_PDT_DW0_VALID; - SAF1761_WRITE_4(sc, pdt_addr + SOTG_PDT_DW0, temp); + SOTG_PTD_DW0_VALID; + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW0, temp); - td->offset += count; - td->remainder -= count; td->toggle ^= 1; busy: return (1); /* busy */ @@ -769,43 +840,117 @@ saf1761_otg_set_address(struct saf1761_otg_softc *sc, uint8_t addr) { DPRINTFN(5, "addr=%d\n", addr); - SAF1761_WRITE_1(sc, SOTG_ADDRESS, addr | SOTG_ADDRESS_ENABLE); + SAF1761_WRITE_LE_4(sc, SOTG_ADDRESS, addr | SOTG_ADDRESS_ENABLE); } + static void -saf1761_read_device_fifo_1(struct saf1761_otg_softc *sc, void *buf, uint32_t len) +saf1761_read_device_fifo(struct saf1761_otg_softc *sc, + struct saf1761_otg_td *td, uint32_t len) { - if (len == 0) - return; - bus_space_read_multi_1((sc)->sc_io_tag, (sc)->sc_io_hdl, - SOTG_DATA_PORT, buf, len); + struct usb_page_search buf_res; + uint32_t count; + + /* optimised read first */ + while (len > 0) { + usbd_get_page(td->pc, td->offset, &buf_res); + + /* get correct length */ + if (buf_res.length > len) + buf_res.length = len; + + /* check buffer alignment */ + if (((uintptr_t)buf_res.buffer) & 3) + break; + + count = buf_res.length & ~3; + if (count == 0) + break; + + bus_space_read_multi_4((sc)->sc_io_tag, (sc)->sc_io_hdl, + SOTG_DATA_PORT, buf_res.buffer, count / 4); + + len -= count; + + /* update remainder and offset */ + td->remainder -= count; + td->offset += count; + } + + if (len > 0) { + /* use bounce buffer */ + bus_space_read_multi_4((sc)->sc_io_tag, (sc)->sc_io_hdl, + SOTG_DATA_PORT, sc->sc_bounce_buffer, (len + 3) / 4); + usbd_copy_in(td->pc, td->offset, + sc->sc_bounce_buffer, len); + + /* update remainder and offset */ + td->remainder -= len; + td->offset += len; + } } static void -saf1761_write_device_fifo_1(struct saf1761_otg_softc *sc, void *buf, uint32_t len) +saf1761_write_device_fifo(struct saf1761_otg_softc *sc, + struct saf1761_otg_td *td, uint32_t len) { - if (len == 0) - return; - bus_space_write_multi_1((sc)->sc_io_tag, (sc)->sc_io_hdl, - SOTG_DATA_PORT, buf, len); + struct usb_page_search buf_res; + uint32_t count; + + /* optimised write first */ + while (len > 0) { + usbd_get_page(td->pc, td->offset, &buf_res); + + /* get correct length */ + if (buf_res.length > len) + buf_res.length = len; + + /* check buffer alignment */ + if (((uintptr_t)buf_res.buffer) & 3) + break; + + count = buf_res.length & ~3; + if (count == 0) + break; + + bus_space_write_multi_4((sc)->sc_io_tag, (sc)->sc_io_hdl, + SOTG_DATA_PORT, buf_res.buffer, count / 4); + + len -= count; + + /* update remainder and offset */ + td->remainder -= count; + td->offset += count; + } + if (len > 0) { + /* use bounce buffer */ + usbd_copy_out(td->pc, td->offset, sc->sc_bounce_buffer, len); + bus_space_write_multi_4((sc)->sc_io_tag, (sc)->sc_io_hdl, + SOTG_DATA_PORT, sc->sc_bounce_buffer, (len + 3) / 4); + + /* update remainder and offset */ + td->remainder -= len; + td->offset += len; + } } static uint8_t saf1761_device_setup_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) { struct usb_device_request req; - uint16_t count; + uint32_t count; /* select the correct endpoint */ - SAF1761_WRITE_1(sc, SOTG_EP_INDEX, SOTG_EP_INDEX_EP0SETUP); + SAF1761_WRITE_LE_4(sc, SOTG_EP_INDEX, SOTG_EP_INDEX_EP0SETUP); + + count = SAF1761_READ_LE_4(sc, SOTG_BUF_LENGTH); /* check buffer status */ - if ((SAF1761_READ_1(sc, SOTG_DCBUFFERSTATUS) & - SOTG_DCBUFFERSTATUS_FILLED_MASK) == 0) + if ((count & SOTG_BUF_LENGTH_FILLED_MASK) == 0) goto busy; - /* read buffer length */ - count = SAF1761_READ_2(sc, SOTG_BUF_LENGTH); + /* get buffer length */ + count &= SOTG_BUF_LENGTH_BUFLEN_MASK; DPRINTFN(5, "count=%u rem=%u\n", count, td->remainder); @@ -813,7 +958,7 @@ saf1761_device_setup_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) td->did_stall = 0; /* clear stall */ - SAF1761_WRITE_1(sc, SOTG_CTRL_FUNC, 0); + SAF1761_WRITE_LE_4(sc, SOTG_CTRL_FUNC, 0); /* verify data length */ if (count != td->remainder) { @@ -827,15 +972,12 @@ saf1761_device_setup_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) goto busy; } /* receive data */ - saf1761_read_device_fifo_1(sc, &req, sizeof(req)); + saf1761_read_device_fifo(sc, td, sizeof(req)); - /* copy data into real buffer */ - usbd_copy_in(td->pc, 0, &req, sizeof(req)); + /* extract SETUP packet again */ + usbd_copy_out(td->pc, 0, &req, sizeof(req)); - td->offset = sizeof(req); - td->remainder = 0; - - /* sneak peek the set address */ + /* sneak peek the set address request */ if ((req.bmRequestType == UT_WRITE_DEVICE) && (req.bRequest == UR_SET_ADDRESS)) { sc->sc_dv_addr = req.wValue[0] & 0x7F; @@ -851,7 +993,7 @@ busy: DPRINTFN(5, "stalling\n"); /* set stall */ - SAF1761_WRITE_1(sc, SOTG_CTRL_FUNC, SOTG_CTRL_FUNC_STALL); + SAF1761_WRITE_LE_4(sc, SOTG_CTRL_FUNC, SOTG_CTRL_FUNC_STALL); td->did_stall = 1; } @@ -861,17 +1003,17 @@ busy: static uint8_t saf1761_device_data_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) { - struct usb_page_search buf_res; - uint16_t count; + uint32_t count; uint8_t got_short = 0; if (td->ep_index == 0) { /* select the correct endpoint */ - SAF1761_WRITE_1(sc, SOTG_EP_INDEX, SOTG_EP_INDEX_EP0SETUP); + SAF1761_WRITE_LE_4(sc, SOTG_EP_INDEX, SOTG_EP_INDEX_EP0SETUP); + + count = SAF1761_READ_LE_4(sc, SOTG_BUF_LENGTH); /* check buffer status */ - if ((SAF1761_READ_1(sc, SOTG_DCBUFFERSTATUS) & - SOTG_DCBUFFERSTATUS_FILLED_MASK) != 0) { + if ((count & SOTG_BUF_LENGTH_FILLED_MASK) != 0) { if (td->remainder == 0) { /* @@ -890,23 +1032,24 @@ saf1761_device_data_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) } } /* select the correct endpoint */ - SAF1761_WRITE_1(sc, SOTG_EP_INDEX, + SAF1761_WRITE_LE_4(sc, SOTG_EP_INDEX, (td->ep_index << SOTG_EP_INDEX_ENDP_INDEX_SHIFT) | SOTG_EP_INDEX_DIR_OUT); /* enable data stage */ if (td->set_toggle) { td->set_toggle = 0; - SAF1761_WRITE_1(sc, SOTG_CTRL_FUNC, SOTG_CTRL_FUNC_DSEN); + SAF1761_WRITE_LE_4(sc, SOTG_CTRL_FUNC, SOTG_CTRL_FUNC_DSEN); } + count = SAF1761_READ_LE_4(sc, SOTG_BUF_LENGTH); + /* check buffer status */ - if ((SAF1761_READ_1(sc, SOTG_DCBUFFERSTATUS) & - SOTG_DCBUFFERSTATUS_FILLED_MASK) == 0) { + if ((count & SOTG_BUF_LENGTH_FILLED_MASK) == 0) return (1); /* not complete */ - } - /* read buffer length */ - count = SAF1761_READ_2(sc, SOTG_BUF_LENGTH); + + /* get buffer length */ + count &= SOTG_BUF_LENGTH_BUFLEN_MASK; DPRINTFN(5, "rem=%u count=0x%04x\n", td->remainder, count); @@ -928,21 +1071,9 @@ saf1761_device_data_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) td->error_any = 1; return (0); /* we are complete */ } - while (count > 0) { - usbd_get_page(td->pc, td->offset, &buf_res); - - /* get correct length */ - if (buf_res.length > count) - buf_res.length = count; - - /* receive data */ - saf1761_read_device_fifo_1(sc, buf_res.buffer, buf_res.length); + /* receive data */ + saf1761_read_device_fifo(sc, td, count); - /* update counters */ - count -= buf_res.length; - td->offset += buf_res.length; - td->remainder -= buf_res.length; - } /* check if we are complete */ if ((td->remainder == 0) || got_short) { if (td->short_pkt) { @@ -957,17 +1088,16 @@ saf1761_device_data_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) static uint8_t saf1761_device_data_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) { - struct usb_page_search buf_res; - uint16_t count; - uint16_t count_old; + uint32_t count; if (td->ep_index == 0) { /* select the correct endpoint */ - SAF1761_WRITE_1(sc, SOTG_EP_INDEX, SOTG_EP_INDEX_EP0SETUP); + SAF1761_WRITE_LE_4(sc, SOTG_EP_INDEX, SOTG_EP_INDEX_EP0SETUP); + + count = SAF1761_READ_LE_4(sc, SOTG_BUF_LENGTH); /* check buffer status */ - if ((SAF1761_READ_1(sc, SOTG_DCBUFFERSTATUS) & - SOTG_DCBUFFERSTATUS_FILLED_MASK) != 0) { + if ((count & SOTG_BUF_LENGTH_FILLED_MASK) != 0) { DPRINTFN(5, "SETUP abort\n"); /* * USB Host Aborted the transfer. @@ -977,20 +1107,20 @@ saf1761_device_data_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) } } /* select the correct endpoint */ - SAF1761_WRITE_1(sc, SOTG_EP_INDEX, + SAF1761_WRITE_LE_4(sc, SOTG_EP_INDEX, (td->ep_index << SOTG_EP_INDEX_ENDP_INDEX_SHIFT) | SOTG_EP_INDEX_DIR_IN); + count = SAF1761_READ_LE_4(sc, SOTG_BUF_LENGTH); + /* check buffer status */ - if ((SAF1761_READ_1(sc, SOTG_DCBUFFERSTATUS) & - SOTG_DCBUFFERSTATUS_FILLED_MASK) != 0) { + if ((count & SOTG_BUF_LENGTH_FILLED_MASK) != 0) return (1); /* not complete */ - } /* enable data stage */ if (td->set_toggle) { td->set_toggle = 0; - SAF1761_WRITE_1(sc, SOTG_CTRL_FUNC, SOTG_CTRL_FUNC_DSEN); + SAF1761_WRITE_LE_4(sc, SOTG_CTRL_FUNC, SOTG_CTRL_FUNC_DSEN); } DPRINTFN(5, "rem=%u\n", td->remainder); @@ -1001,34 +1131,18 @@ saf1761_device_data_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) td->short_pkt = 1; count = td->remainder; } - count_old = count; - - while (count > 0) { - - usbd_get_page(td->pc, td->offset, &buf_res); - - /* get correct length */ - if (buf_res.length > count) - buf_res.length = count; - - /* transmit data */ - saf1761_write_device_fifo_1(sc, buf_res.buffer, buf_res.length); - - /* update counters */ - count -= buf_res.length; - td->offset += buf_res.length; - td->remainder -= buf_res.length; - } + /* transmit data */ + saf1761_write_device_fifo(sc, td, count); if (td->ep_index == 0) { - if (count_old < SOTG_FS_MAX_PACKET_SIZE) { + if (count < SOTG_FS_MAX_PACKET_SIZE) { /* set end of packet */ - SAF1761_WRITE_1(sc, SOTG_CTRL_FUNC, SOTG_CTRL_FUNC_VENDP); + SAF1761_WRITE_LE_4(sc, SOTG_CTRL_FUNC, SOTG_CTRL_FUNC_VENDP); } } else { - if (count_old < SOTG_HS_MAX_PACKET_SIZE) { + if (count < SOTG_HS_MAX_PACKET_SIZE) { /* set end of packet */ - SAF1761_WRITE_1(sc, SOTG_CTRL_FUNC, SOTG_CTRL_FUNC_VENDP); + SAF1761_WRITE_LE_4(sc, SOTG_CTRL_FUNC, SOTG_CTRL_FUNC_VENDP); } } @@ -1045,25 +1159,29 @@ saf1761_device_data_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) static uint8_t saf1761_device_data_tx_sync(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) { + uint32_t count; + if (td->ep_index == 0) { /* select the correct endpoint */ - SAF1761_WRITE_1(sc, SOTG_EP_INDEX, SOTG_EP_INDEX_EP0SETUP); + SAF1761_WRITE_LE_4(sc, SOTG_EP_INDEX, SOTG_EP_INDEX_EP0SETUP); + + count = SAF1761_READ_LE_4(sc, SOTG_BUF_LENGTH); /* check buffer status */ - if ((SAF1761_READ_1(sc, SOTG_DCBUFFERSTATUS) & - SOTG_DCBUFFERSTATUS_FILLED_MASK) != 0) { + if ((count & SOTG_BUF_LENGTH_FILLED_MASK) != 0) { DPRINTFN(5, "Faking complete\n"); return (0); /* complete */ } } /* select the correct endpoint */ - SAF1761_WRITE_1(sc, SOTG_EP_INDEX, + SAF1761_WRITE_LE_4(sc, SOTG_EP_INDEX, (td->ep_index << SOTG_EP_INDEX_ENDP_INDEX_SHIFT) | SOTG_EP_INDEX_DIR_IN); + count = SAF1761_READ_LE_4(sc, SOTG_BUF_LENGTH); + /* check buffer status */ - if ((SAF1761_READ_1(sc, SOTG_DCBUFFERSTATUS) & - SOTG_DCBUFFERSTATUS_FILLED_MASK) != 0) + if ((count & SOTG_BUF_LENGTH_FILLED_MASK) != 0) return (1); /* busy */ if (sc->sc_dv_addr != 0xFF) { @@ -1143,7 +1261,7 @@ saf1761_otg_wait_suspend(struct saf1761_otg_softc *sc, uint8_t on) sc->sc_intr_enable &= ~SOTG_DCINTERRUPT_IESUSP; sc->sc_intr_enable |= SOTG_DCINTERRUPT_IERESM; } - SAF1761_WRITE_4(sc, SOTG_DCINTERRUPT_EN, sc->sc_intr_enable); + SAF1761_WRITE_LE_4(sc, SOTG_DCINTERRUPT_EN, sc->sc_intr_enable); } static void @@ -1152,7 +1270,7 @@ saf1761_otg_update_vbus(struct saf1761_otg_softc *sc) uint16_t status; /* read fresh status */ - status = SAF1761_READ_2(sc, SOTG_STATUS); + status = SAF1761_READ_LE_4(sc, SOTG_STATUS); DPRINTFN(4, "STATUS=0x%04x\n", status); @@ -1188,16 +1306,18 @@ saf1761_otg_interrupt(struct saf1761_otg_softc *sc) USB_BUS_LOCK(&sc->sc_bus); - hcstat = SAF1761_READ_4(sc, SOTG_HCINTERRUPT); + hcstat = SAF1761_READ_LE_4(sc, SOTG_HCINTERRUPT); /* acknowledge all host controller interrupts */ - SAF1761_WRITE_4(sc, SOTG_HCINTERRUPT, hcstat); + SAF1761_WRITE_LE_4(sc, SOTG_HCINTERRUPT, hcstat); - status = SAF1761_READ_4(sc, SOTG_DCINTERRUPT); + status = SAF1761_READ_LE_4(sc, SOTG_DCINTERRUPT); /* acknowledge all device controller interrupts */ - SAF1761_WRITE_4(sc, SOTG_DCINTERRUPT, status); + SAF1761_WRITE_LE_4(sc, SOTG_DCINTERRUPT, status); - DPRINTF("DCINTERRUPT=0x%08x HCINTERRUPT=0x%08x SOF=0x%04x\n", - status, hcstat, SAF1761_READ_2(sc, SOTG_FRAME_NUM)); + DPRINTF("DCINTERRUPT=0x%08x HCINTERRUPT=0x%08x SOF=0x%08x " + "FRINDEX=0x%08x\n", status, hcstat, + SAF1761_READ_LE_4(sc, SOTG_FRAME_NUM), + SAF1761_READ_LE_4(sc, SOTG_FRINDEX)); /* update VBUS and ID bits, if any */ if (status & SOTG_DCINTERRUPT_IEVBUS) { @@ -1206,11 +1326,11 @@ saf1761_otg_interrupt(struct saf1761_otg_softc *sc) if (status & SOTG_DCINTERRUPT_IEBRST) { /* unlock device */ - SAF1761_WRITE_2(sc, SOTG_UNLOCK_DEVICE, + SAF1761_WRITE_LE_4(sc, SOTG_UNLOCK_DEVICE, SOTG_UNLOCK_DEVICE_CODE); /* Enable device address */ - SAF1761_WRITE_1(sc, SOTG_ADDRESS, + SAF1761_WRITE_LE_4(sc, SOTG_ADDRESS, SOTG_ADDRESS_ENABLE); sc->sc_flags.status_bus_reset = 1; @@ -1230,7 +1350,7 @@ saf1761_otg_interrupt(struct saf1761_otg_softc *sc) */ if (status & SOTG_DCINTERRUPT_IERESM) { /* unlock device */ - SAF1761_WRITE_2(sc, SOTG_UNLOCK_DEVICE, + SAF1761_WRITE_LE_4(sc, SOTG_UNLOCK_DEVICE, SOTG_UNLOCK_DEVICE_CODE); if (sc->sc_flags.status_suspend) { @@ -1529,7 +1649,7 @@ saf1761_otg_intr_set(struct usb_xfer *xfer, uint8_t set) else sc->sc_intr_enable &= ~mask; - SAF1761_WRITE_4(sc, SOTG_DCINTERRUPT_EN, sc->sc_intr_enable); + SAF1761_WRITE_LE_4(sc, SOTG_DCINTERRUPT_EN, sc->sc_intr_enable); } static void @@ -1751,13 +1871,13 @@ saf1761_otg_set_stall(struct usb_device *udev, return; } /* select the correct endpoint */ - SAF1761_WRITE_1(sc, SOTG_EP_INDEX, + SAF1761_WRITE_LE_4(sc, SOTG_EP_INDEX, (ep_no << SOTG_EP_INDEX_ENDP_INDEX_SHIFT) | ((ep_dir == UE_DIR_IN) ? SOTG_EP_INDEX_DIR_IN : SOTG_EP_INDEX_DIR_OUT)); /* set stall */ - SAF1761_WRITE_1(sc, SOTG_CTRL_FUNC, SOTG_CTRL_FUNC_STALL); + SAF1761_WRITE_LE_4(sc, SOTG_CTRL_FUNC, SOTG_CTRL_FUNC_STALL); } static void @@ -1769,20 +1889,20 @@ saf1761_otg_clear_stall_sub(struct saf1761_otg_softc *sc, return; } /* select the correct endpoint */ - SAF1761_WRITE_1(sc, SOTG_EP_INDEX, + SAF1761_WRITE_LE_4(sc, SOTG_EP_INDEX, (ep_no << SOTG_EP_INDEX_ENDP_INDEX_SHIFT) | ((ep_dir == UE_DIR_IN) ? SOTG_EP_INDEX_DIR_IN : SOTG_EP_INDEX_DIR_OUT)); /* disable endpoint */ - SAF1761_WRITE_2(sc, SOTG_EP_TYPE, 0); + SAF1761_WRITE_LE_4(sc, SOTG_EP_TYPE, 0); /* enable endpoint again - will clear data toggle */ - SAF1761_WRITE_2(sc, SOTG_EP_TYPE, ep_type | SOTG_EP_TYPE_ENABLE); + SAF1761_WRITE_LE_4(sc, SOTG_EP_TYPE, ep_type | SOTG_EP_TYPE_ENABLE); /* clear buffer */ - SAF1761_WRITE_1(sc, SOTG_CTRL_FUNC, SOTG_CTRL_FUNC_CLBUF); + SAF1761_WRITE_LE_4(sc, SOTG_CTRL_FUNC, SOTG_CTRL_FUNC_CLBUF); /* clear stall */ - SAF1761_WRITE_1(sc, SOTG_CTRL_FUNC, 0); + SAF1761_WRITE_LE_4(sc, SOTG_CTRL_FUNC, 0); } static void @@ -1828,17 +1948,17 @@ saf1761_otg_init(struct saf1761_otg_softc *sc) USB_BUS_LOCK(&sc->sc_bus); /* Reset Host controller, including HW mode */ - SAF1761_WRITE_2(sc, SOTG_SW_RESET, SOTG_SW_RESET_ALL); + SAF1761_WRITE_LE_4(sc, SOTG_SW_RESET, SOTG_SW_RESET_ALL); DELAY(1000); /* Reset Host controller, including HW mode */ - SAF1761_WRITE_2(sc, SOTG_SW_RESET, SOTG_SW_RESET_HC); + SAF1761_WRITE_LE_4(sc, SOTG_SW_RESET, SOTG_SW_RESET_HC); /* wait a bit */ DELAY(1000); - SAF1761_WRITE_2(sc, SOTG_SW_RESET, 0); + SAF1761_WRITE_LE_4(sc, SOTG_SW_RESET, 0); /* wait a bit */ DELAY(1000); @@ -1848,48 +1968,49 @@ saf1761_otg_init(struct saf1761_otg_softc *sc) SOTG_HW_MODE_CTRL_COMN_INT; /* unlock device */ - SAF1761_WRITE_2(sc, SOTG_UNLOCK_DEVICE, SOTG_UNLOCK_DEVICE_CODE); + SAF1761_WRITE_LE_4(sc, SOTG_UNLOCK_DEVICE, SOTG_UNLOCK_DEVICE_CODE); /* * Set correct hardware mode, must be written twice if bus * width is changed: */ - SAF1761_WRITE_2(sc, SOTG_HW_MODE_CTRL, sc->sc_hw_mode); - SAF1761_WRITE_4(sc, SOTG_HW_MODE_CTRL, sc->sc_hw_mode); + SAF1761_WRITE_LE_4(sc, SOTG_HW_MODE_CTRL, sc->sc_hw_mode); + SAF1761_WRITE_LE_4(sc, SOTG_HW_MODE_CTRL, sc->sc_hw_mode); - SAF1761_WRITE_4(sc, SOTG_DCSCRATCH, 0xdeadbeef); + SAF1761_WRITE_LE_4(sc, SOTG_DCSCRATCH, 0xdeadbeef); + SAF1761_WRITE_LE_4(sc, SOTG_HCSCRATCH, 0xdeadbeef); - DPRINTF("DCID=0x%08x VEND=0x%04x PROD=0x%04x HWMODE=0x%08x SCRATCH=0x%08x\n", - SAF1761_READ_4(sc, SOTG_DCCHIP_ID), - SAF1761_READ_2(sc, SOTG_VEND_ID), - SAF1761_READ_2(sc, SOTG_PROD_ID), - SAF1761_READ_4(sc, SOTG_HW_MODE_CTRL), - SAF1761_READ_4(sc, SOTG_DCSCRATCH)); + DPRINTF("DCID=0x%08x VEND_PROD=0x%08x HWMODE=0x%08x SCRATCH=0x%08x,0x%08x\n", + SAF1761_READ_LE_4(sc, SOTG_DCCHIP_ID), + SAF1761_READ_LE_4(sc, SOTG_VEND_PROD_ID), + SAF1761_READ_LE_4(sc, SOTG_HW_MODE_CTRL), + SAF1761_READ_LE_4(sc, SOTG_DCSCRATCH), + SAF1761_READ_LE_4(sc, SOTG_HCSCRATCH)); /* reset device controller */ - SAF1761_WRITE_2(sc, SOTG_MODE, SOTG_MODE_SFRESET); - SAF1761_WRITE_2(sc, SOTG_MODE, 0); + SAF1761_WRITE_LE_4(sc, SOTG_MODE, SOTG_MODE_SFRESET); + SAF1761_WRITE_LE_4(sc, SOTG_MODE, 0); /* wait a bit */ DELAY(1000); /* reset host controller */ - SAF1761_WRITE_4(sc, SOTG_USBCMD, SOTG_USBCMD_HCRESET); + SAF1761_WRITE_LE_4(sc, SOTG_USBCMD, SOTG_USBCMD_HCRESET); /* wait for reset to clear */ for (x = 0; x != 10; x++) { - if ((SAF1761_READ_4(sc, SOTG_USBCMD) & SOTG_USBCMD_HCRESET) == 0) + if ((SAF1761_READ_LE_4(sc, SOTG_USBCMD) & SOTG_USBCMD_HCRESET) == 0) break; usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 10); } - SAF1761_WRITE_4(sc, SOTG_HW_MODE_CTRL, sc->sc_hw_mode | + SAF1761_WRITE_LE_4(sc, SOTG_HW_MODE_CTRL, sc->sc_hw_mode | SOTG_HW_MODE_CTRL_ALL_ATX_RESET); /* wait a bit */ DELAY(1000); - SAF1761_WRITE_4(sc, SOTG_HW_MODE_CTRL, sc->sc_hw_mode); + SAF1761_WRITE_LE_4(sc, SOTG_HW_MODE_CTRL, sc->sc_hw_mode); /* wait a bit */ DELAY(1000); @@ -1907,74 +2028,94 @@ saf1761_otg_init(struct saf1761_otg_softc *sc) break; /* select the correct endpoint */ - SAF1761_WRITE_1(sc, SOTG_EP_INDEX, + SAF1761_WRITE_LE_4(sc, SOTG_EP_INDEX, (x << SOTG_EP_INDEX_ENDP_INDEX_SHIFT) | SOTG_EP_INDEX_DIR_IN); /* select the maximum packet size */ - SAF1761_WRITE_2(sc, SOTG_EP_MAXPACKET, pf->max_in_frame_size); + SAF1761_WRITE_LE_4(sc, SOTG_EP_MAXPACKET, pf->max_in_frame_size); /* select the correct endpoint */ - SAF1761_WRITE_1(sc, SOTG_EP_INDEX, + SAF1761_WRITE_LE_4(sc, SOTG_EP_INDEX, (x << SOTG_EP_INDEX_ENDP_INDEX_SHIFT) | SOTG_EP_INDEX_DIR_OUT); /* select the maximum packet size */ - SAF1761_WRITE_2(sc, SOTG_EP_MAXPACKET, pf->max_out_frame_size); + SAF1761_WRITE_LE_4(sc, SOTG_EP_MAXPACKET, pf->max_out_frame_size); } /* enable interrupts */ - SAF1761_WRITE_2(sc, SOTG_MODE, SOTG_MODE_GLINTENA | + SAF1761_WRITE_LE_4(sc, SOTG_MODE, SOTG_MODE_GLINTENA | SOTG_MODE_CLKAON | SOTG_MODE_WKUPCS); /* set default values */ - SAF1761_WRITE_1(sc, SOTG_INTERRUPT_CFG, + SAF1761_WRITE_LE_4(sc, SOTG_INTERRUPT_CFG, SOTG_INTERRUPT_CFG_CDBGMOD | SOTG_INTERRUPT_CFG_DDBGMODIN | SOTG_INTERRUPT_CFG_DDBGMODOUT); /* enable VBUS and ID interrupt */ - SAF1761_WRITE_2(sc, SOTG_IRQ_ENABLE_CLR, 0xFFFF); - SAF1761_WRITE_2(sc, SOTG_IRQ_ENABLE_SET, - SOTG_IRQ_ID | SOTG_IRQ_VBUS_VLD); + SAF1761_WRITE_LE_4(sc, SOTG_IRQ_ENABLE_SET_CLR, + SOTG_IRQ_ENABLE_CLR(0xFFFF)); + SAF1761_WRITE_LE_4(sc, SOTG_IRQ_ENABLE_SET_CLR, + SOTG_IRQ_ENABLE_SET(SOTG_IRQ_ID | SOTG_IRQ_VBUS_VLD)); /* enable interrupts */ sc->sc_intr_enable = SOTG_DCINTERRUPT_IEVBUS | SOTG_DCINTERRUPT_IEBRST | SOTG_DCINTERRUPT_IESUSP; - SAF1761_WRITE_4(sc, SOTG_DCINTERRUPT_EN, sc->sc_intr_enable); + SAF1761_WRITE_LE_4(sc, SOTG_DCINTERRUPT_EN, sc->sc_intr_enable); /* * Connect ATX port 1 to device controller, select external * charge pump and driver VBUS to +5V: */ - SAF1761_WRITE_2(sc, SOTG_CTRL_CLR, 0xFFFF); - SAF1761_WRITE_2(sc, SOTG_CTRL_SET, SOTG_CTRL_SW_SEL_HC_DC | + SAF1761_WRITE_LE_4(sc, SOTG_CTRL_SET_CLR, + SOTG_CTRL_CLR(0xFFFF)); + SAF1761_WRITE_LE_4(sc, SOTG_CTRL_SET_CLR, + SOTG_CTRL_SET(SOTG_CTRL_SW_SEL_HC_DC | SOTG_CTRL_BDIS_ACON_EN | SOTG_CTRL_SEL_CP_EXT | - SOTG_CTRL_VBUS_DRV); + SOTG_CTRL_VBUS_DRV)); /* disable device address */ - SAF1761_WRITE_1(sc, SOTG_ADDRESS, 0); + SAF1761_WRITE_LE_4(sc, SOTG_ADDRESS, 0); - /* enable host controller clock */ - SAF1761_WRITE_4(sc, SOTG_POWER_DOWN, SOTG_POWER_DOWN_HC_CLK_EN); + /* enable host controller clock and preserve reserved bits */ + x = SAF1761_READ_LE_4(sc, SOTG_POWER_DOWN); + SAF1761_WRITE_LE_4(sc, SOTG_POWER_DOWN, x | SOTG_POWER_DOWN_HC_CLK_EN); /* wait 10ms for clock */ usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 100); /* enable configuration flag */ - SAF1761_WRITE_4(sc, SOTG_CONFIGFLAG, SOTG_CONFIGFLAG_ENABLE); + SAF1761_WRITE_LE_4(sc, SOTG_CONFIGFLAG, SOTG_CONFIGFLAG_ENABLE); /* clear RAM block */ for (x = 0x400; x != 0x10000; x += 4) - SAF1761_WRITE_4(sc, x, 0); + SAF1761_WRITE_LE_4(sc, x, 0); /* start the HC */ - SAF1761_WRITE_4(sc, SOTG_USBCMD, SOTG_USBCMD_RS); + SAF1761_WRITE_LE_4(sc, SOTG_USBCMD, SOTG_USBCMD_RS); + + DPRINTF("USBCMD=0x%08x\n", SAF1761_READ_LE_4(sc, SOTG_USBCMD)); + + /* activate all PTDs */ + SAF1761_WRITE_LE_4(sc, SOTG_ATL_PTD_LAST_PTD, (1 << 31)); + SAF1761_WRITE_LE_4(sc, SOTG_INT_PTD_LAST_PTD, (1 << 31)); + SAF1761_WRITE_LE_4(sc, SOTG_ISO_PTD_LAST_PTD, (1 << 31)); + + /* skip no PTDs */ + SAF1761_WRITE_LE_4(sc, SOTG_ATL_PTD_SKIP_PTD, 0); + SAF1761_WRITE_LE_4(sc, SOTG_INT_PTD_SKIP_PTD, 0); + SAF1761_WRITE_LE_4(sc, SOTG_ISO_PTD_SKIP_PTD, 0); - DPRINTF("USBCMD=0x%08x\n", SAF1761_READ_4(sc, SOTG_USBCMD)); + /* activate all PTD types */ + SAF1761_WRITE_LE_4(sc, SOTG_HCBUFFERSTATUS, + SOTG_HCBUFFERSTATUS_ISO_BUF_FILL | + SOTG_HCBUFFERSTATUS_INT_BUF_FILL | + SOTG_HCBUFFERSTATUS_ATL_BUF_FILL); /* enable HC interrupts */ - SAF1761_WRITE_4(sc, SOTG_HCINTERRUPT_ENABLE, + SAF1761_WRITE_LE_4(sc, SOTG_HCINTERRUPT_ENABLE, SOTG_HCINTERRUPT_OTG_IRQ | SOTG_HCINTERRUPT_ISO_IRQ | SOTG_HCINTERRUPT_ALT_IRQ | @@ -1998,7 +2139,7 @@ saf1761_otg_uninit(struct saf1761_otg_softc *sc) USB_BUS_LOCK(&sc->sc_bus); /* disable all interrupts */ - SAF1761_WRITE_2(sc, SOTG_MODE, 0); + SAF1761_WRITE_LE_4(sc, SOTG_MODE, 0); sc->sc_flags.port_powered = 0; sc->sc_flags.status_vbus = 0; @@ -2099,7 +2240,7 @@ saf1761_otg_device_isoc_enter(struct usb_xfer *xfer) /* get the current frame index - we don't need the high bits */ - nframes = SAF1761_READ_2(sc, SOTG_FRAME_NUM); + nframes = SAF1761_READ_LE_4(sc, SOTG_FRAME_NUM); /* * check if the frame index is within the window where the @@ -2160,9 +2301,13 @@ static const struct usb_pipe_methods saf1761_otg_device_isoc_methods = * Simulate a hardware HUB by handling all the necessary requests. *------------------------------------------------------------------------*/ +#define HSETW(ptr, val) ptr = { (uint8_t)(val), (uint8_t)((val) >> 8) } + static const struct usb_device_descriptor saf1761_otg_devd = { .bLength = sizeof(struct usb_device_descriptor), .bDescriptorType = UDESC_DEVICE, + HSETW(.idVendor, 0x04cc), + HSETW(.idProduct, 0x1761), .bcdUSB = {0x00, 0x02}, .bDeviceClass = UDCLASS_HUB, .bDeviceSubClass = UDSUBCLASS_HUB, @@ -2215,8 +2360,6 @@ static const struct saf1761_otg_config_desc saf1761_otg_confd = { }, }; -#define HSETW(ptr, val) ptr = { (uint8_t)(val), (uint8_t)((val) >> 8) } - static const struct usb_hub_descriptor_min saf1761_otg_hubd = { .bDescLength = sizeof(saf1761_otg_hubd), .bDescriptorType = UDESC_HUB, @@ -2558,27 +2701,27 @@ tr_handle_clear_port_feature_device: tr_handle_clear_port_feature_host: DPRINTFN(9, "UR_CLEAR_FEATURE on port %d\n", index); - temp = SAF1761_READ_4(sc, SOTG_PORTSC1); + temp = SAF1761_READ_LE_4(sc, SOTG_PORTSC1); switch (value) { case UHF_PORT_ENABLE: - SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp & ~SOTG_PORTSC1_PED); + SAF1761_WRITE_LE_4(sc, SOTG_PORTSC1, temp & ~SOTG_PORTSC1_PED); break; case UHF_PORT_SUSPEND: if ((temp & SOTG_PORTSC1_SUSP) && (!(temp & SOTG_PORTSC1_FPR))) - SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp | SOTG_PORTSC1_FPR); + SAF1761_WRITE_LE_4(sc, SOTG_PORTSC1, temp | SOTG_PORTSC1_FPR); /* wait 20ms for resume sequence to complete */ usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 50); - SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp & ~(SOTG_PORTSC1_SUSP | + SAF1761_WRITE_LE_4(sc, SOTG_PORTSC1, temp & ~(SOTG_PORTSC1_SUSP | SOTG_PORTSC1_FPR | SOTG_PORTSC1_LS /* High Speed */ )); /* 4ms settle time */ usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 250); break; case UHF_PORT_INDICATOR: - SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp & ~SOTG_PORTSC1_PIC); + SAF1761_WRITE_LE_4(sc, SOTG_PORTSC1, temp & ~SOTG_PORTSC1_PIC); break; case UHF_PORT_TEST: case UHF_C_PORT_ENABLE: @@ -2588,10 +2731,10 @@ tr_handle_clear_port_feature_host: /* NOPs */ break; case UHF_PORT_POWER: - SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp & ~SOTG_PORTSC1_PP); + SAF1761_WRITE_LE_4(sc, SOTG_PORTSC1, temp & ~SOTG_PORTSC1_PP); break; case UHF_C_PORT_CONNECTION: - SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp & ~SOTG_PORTSC1_ECSC); + SAF1761_WRITE_LE_4(sc, SOTG_PORTSC1, temp & ~SOTG_PORTSC1_ECSC); break; default: err = USB_ERR_IOERROR; @@ -2624,14 +2767,14 @@ tr_handle_set_port_feature_device: tr_handle_set_port_feature_host: DPRINTFN(9, "UR_SET_FEATURE on port %d\n", index); - temp = SAF1761_READ_4(sc, SOTG_PORTSC1); + temp = SAF1761_READ_LE_4(sc, SOTG_PORTSC1); switch (value) { case UHF_PORT_ENABLE: - SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp | SOTG_PORTSC1_PED); + SAF1761_WRITE_LE_4(sc, SOTG_PORTSC1, temp | SOTG_PORTSC1_PED); break; case UHF_PORT_SUSPEND: - SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp | SOTG_PORTSC1_SUSP); + SAF1761_WRITE_LE_4(sc, SOTG_PORTSC1, temp | SOTG_PORTSC1_SUSP); break; case UHF_PORT_RESET: DPRINTFN(6, "reset port %d\n", index); @@ -2639,18 +2782,18 @@ tr_handle_set_port_feature_host: /* Start reset sequence. */ temp &= ~(SOTG_PORTSC1_PED | SOTG_PORTSC1_PR); - SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp | SOTG_PORTSC1_PR); + SAF1761_WRITE_LE_4(sc, SOTG_PORTSC1, temp | SOTG_PORTSC1_PR); /* Wait for reset to complete. */ usb_pause_mtx(&sc->sc_bus.bus_mtx, USB_MS_TO_TICKS(usb_port_root_reset_delay)); - SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp); + SAF1761_WRITE_LE_4(sc, SOTG_PORTSC1, temp); /* Wait for HC to complete reset. */ usb_pause_mtx(&sc->sc_bus.bus_mtx, USB_MS_TO_TICKS(2)); - temp = SAF1761_READ_4(sc, SOTG_PORTSC1); + temp = SAF1761_READ_LE_4(sc, SOTG_PORTSC1); DPRINTF("After reset, status=0x%08x\n", temp); if (temp & SOTG_PORTSC1_PR) { @@ -2660,7 +2803,7 @@ tr_handle_set_port_feature_host: } if (!(temp & SOTG_PORTSC1_PED)) { /* Not a high speed device, give up ownership.*/ - SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp | SOTG_PORTSC1_PO); + SAF1761_WRITE_LE_4(sc, SOTG_PORTSC1, temp | SOTG_PORTSC1_PO); break; } sc->sc_isreset = 1; @@ -2668,7 +2811,7 @@ tr_handle_set_port_feature_host: break; case UHF_PORT_POWER: DPRINTFN(3, "set port power %d\n", index); - SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp | SOTG_PORTSC1_PP); + SAF1761_WRITE_LE_4(sc, SOTG_PORTSC1, temp | SOTG_PORTSC1_PP); break; case UHF_PORT_TEST: @@ -2677,7 +2820,7 @@ tr_handle_set_port_feature_host: case UHF_PORT_INDICATOR: DPRINTFN(3, "set port ind %d\n", index); - SAF1761_WRITE_4(sc, SOTG_PORTSC1, temp | SOTG_PORTSC1_PIC); + SAF1761_WRITE_LE_4(sc, SOTG_PORTSC1, temp | SOTG_PORTSC1_PIC); break; default: err = USB_ERR_IOERROR; @@ -2728,7 +2871,7 @@ tr_handle_get_port_status_device: tr_handle_get_port_status_host: - temp = SAF1761_READ_4(sc, SOTG_PORTSC1); + temp = SAF1761_READ_LE_4(sc, SOTG_PORTSC1); DPRINTFN(9, "UR_GET_PORT_STATUS on port %d = 0x%08x\n", index, temp); @@ -2847,7 +2990,7 @@ saf1761_otg_xfer_setup(struct usb_setup_params *parm) case USB_SPEED_LOW: /* check if root HUB port is running High Speed */ if (parm->udev->parent_hs_hub != NULL) { - dw1 |= (1 << 14); + dw1 |= SOTG_PTD_DW1_ENABLE_SPLIT; dw1 |= (parm->udev->hs_port_no << 18); dw1 |= (parm->udev->hs_hub_addr << 25); if (parm->udev->speed == USB_SPEED_LOW) @@ -2877,9 +3020,9 @@ saf1761_otg_xfer_setup(struct usb_setup_params *parm) td->uframe = 0; if (ep_type == UE_INTERRUPT) { if (xfer->interval > 32) - td->interval = 32 / 2; + td->interval = (32 / 2) << 3; else - td->interval = xfer->interval / 2; + td->interval = (xfer->interval / 2) << 3; } else { td->interval = 0; } diff --git a/sys/dev/usb/controller/saf1761_otg.h b/sys/dev/usb/controller/saf1761_otg.h index 9b19d3c965c3f..6b7697255ea65 100644 --- a/sys/dev/usb/controller/saf1761_otg.h +++ b/sys/dev/usb/controller/saf1761_otg.h @@ -32,7 +32,7 @@ #ifndef _SAF1761_OTG_H_ #define _SAF1761_OTG_H_ -#define SOTG_MAX_DEVICES (USB_MIN_DEVICES + 1) +#define SOTG_MAX_DEVICES MIN(USB_MAX_DEVICES, 32) #define SOTG_FS_MAX_PACKET_SIZE 64 #define SOTG_HS_MAX_PACKET_SIZE 512 #define SOTG_NUM_PORTS 2 /* one Device and one Host port */ @@ -40,28 +40,26 @@ #define SOTG_DEVICE_PORT_NUM 2 #define SOTG_HOST_CHANNEL_MAX (3 * 32) -/* Macros used for reading and writing registers */ +/* Macros used for reading and writing little endian registers */ -#define SAF1761_READ_1(sc, reg) \ - bus_space_read_1((sc)->sc_io_tag, (sc)->sc_io_hdl, (reg)) -#define SAF1761_READ_2(sc, reg) ({ uint16_t _temp; \ - _temp = bus_space_read_2((sc)->sc_io_tag, (sc)->sc_io_hdl, (reg)); \ - le16toh(_temp); }) -#define SAF1761_READ_4(sc, reg) ({ uint32_t _temp; \ +#define SAF1761_READ_LE_4(sc, reg) ({ uint32_t _temp; \ _temp = bus_space_read_4((sc)->sc_io_tag, (sc)->sc_io_hdl, (reg)); \ le32toh(_temp); }) -#define SAF1761_WRITE_1(sc, reg, data) \ - bus_space_write_1((sc)->sc_io_tag, (sc)->sc_io_hdl, (reg), data) -#define SAF1761_WRITE_2(sc, reg, data) do { \ - uint16_t _temp = (data); \ - bus_space_write_2((sc)->sc_io_tag, (sc)->sc_io_hdl, (reg), htole16(_temp)); \ -} while (0) -#define SAF1761_WRITE_4(sc, reg, data) do { \ +#define SAF1761_WRITE_LE_4(sc, reg, data) do { \ uint32_t _temp = (data); \ bus_space_write_4((sc)->sc_io_tag, (sc)->sc_io_hdl, (reg), htole32(_temp)); \ } while (0) +/* 90ns delay macro */ + +#define SAF1761_90NS_DELAY(sc) do { \ + (void) SAF1761_READ_LE_4(sc, SOTG_VEND_PROD_ID); \ + (void) SAF1761_READ_LE_4(sc, SOTG_VEND_PROD_ID); \ + (void) SAF1761_READ_LE_4(sc, SOTG_VEND_PROD_ID); \ + (void) SAF1761_READ_LE_4(sc, SOTG_VEND_PROD_ID); \ +} while (0) + struct saf1761_otg_softc; struct saf1761_otg_td; @@ -147,7 +145,8 @@ struct saf1761_otg_softc { uint32_t sc_intr_enable; /* enabled interrupts */ uint32_t sc_hw_mode; /* hardware mode */ - uint8_t sc_bounce_buffer[1024] __aligned(4); + uint32_t sc_bounce_buffer[1024 / 4]; + uint8_t sc_rt_addr; /* root HUB address */ uint8_t sc_dv_addr; /* device address */ uint8_t sc_conf; /* root HUB config */ diff --git a/sys/dev/usb/controller/saf1761_otg_reg.h b/sys/dev/usb/controller/saf1761_otg_reg.h index 6e104bcf16420..bfed688bf28ba 100644 --- a/sys/dev/usb/controller/saf1761_otg_reg.h +++ b/sys/dev/usb/controller/saf1761_otg_reg.h @@ -34,10 +34,12 @@ /* Global registers */ -#define SOTG_VEND_ID 0x370 -#define SOTG_PROD_ID 0x372 -#define SOTG_CTRL_SET 0x374 -#define SOTG_CTRL_CLR 0x376 +#define SOTG_VEND_PROD_ID 0x370 +#define SOTG_VEND_ID(x) ((x) & 0xFFFF) +#define SOTG_PROD_ID(x) (((x) >> 16) & 0xFFFF) +#define SOTG_CTRL_SET_CLR 0x374 +#define SOTG_CTRL_SET(x) ((x) & 0xFFFF) +#define SOTG_CTRL_CLR(x) (((x) << 16) & 0xFFFF0000) #define SOTG_CTRL_OTG_DISABLE (1 << 10) #define SOTG_CTRL_OTG_SE0_EN (1 << 9) #define SOTG_CTRL_BDIS_ACON_EN (1 << 8) @@ -57,12 +59,15 @@ #define SOTG_STATUS_DP_SRP (1 << 2) #define SOTG_STATUS_A_B_SESS_VLD (1 << 1) #define SOTG_STATUS_VBUS_VLD (1 << 0) -#define SOTG_IRQ_LATCH_SET 0x37C -#define SOTG_IRQ_LATCH_CLR 0x37E -#define SOTG_IRQ_ENABLE_SET 0x380 -#define SOTG_IRQ_ENABLE_CLR 0x382 -#define SOTG_IRQ_RISE_SET 0x384 -#define SOTG_IRQ_RISE_CLR 0x386 +#define SOTG_IRQ_LATCH_SET_CLR 0x37C +#define SOTG_IRQ_LATCH_SET(x) ((x) & 0xFFFF) +#define SOTG_IRQ_LATCH_CLR(x) (((x) << 16) & 0xFFFF0000) +#define SOTG_IRQ_ENABLE_SET_CLR 0x380 +#define SOTG_IRQ_ENABLE_SET(x) ((x) & 0xFFFF) +#define SOTG_IRQ_ENABLE_CLR(x) (((x) << 16) & 0xFFFF0000) +#define SOTG_IRQ_RISE_SET_CLR 0x384 +#define SOTG_IRQ_RISE_SET(x) ((x) & 0xFFFF) +#define SOTG_IRQ_RISE_CLR(x) (((x) << 16) & 0xFFFF0000) #define SOTG_IRQ_OTG_TMR_TIMEOUT (1 << 9) #define SOTG_IRQ_B_SE0_SRP (1 << 8) #define SOTG_IRQ_B_SESS_END (1 << 7) @@ -73,10 +78,12 @@ #define SOTG_IRQ_DP_SRP (1 << 2) #define SOTG_IRQ_A_B_SESS_VLD (1 << 1) #define SOTG_IRQ_VBUS_VLD (1 << 0) -#define SOTG_TIMER_LOW_SET 0x388 -#define SOTG_TIMER_LOW_CLR 0x38A -#define SOTG_TIMER_HIGH_SET 0x38C -#define SOTG_TIMER_HIGH_CLR 0x38E +#define SOTG_TIMER_LOW_SET_CLR 0x388 +#define SOTG_TIMER_LOW_SET(x) ((x) & 0xFFFF) +#define SOTG_TIMER_LOW_CLR(x) (((x) << 16) & 0xFFFF0000) +#define SOTG_TIMER_HIGH_SET_CLR 0x38C +#define SOTG_TIMER_HIGH_SET(x) ((x) & 0xFFFF) +#define SOTG_TIMER_HIGH_CLR(x) (((x) << 16) & 0xFFFF0000) #define SOTG_TIMER_START_TMR (1U << 15) #define SOTG_MEMORY_REG 0x33c @@ -94,13 +101,12 @@ #define SOTG_MODE_GLINTENA (1 << 3) #define SOTG_MODE_WKUPCS (1 << 2) #define SOTG_INTERRUPT_CFG 0x210 +#define SOTG_INTERRUPT_CFG_DEBUG_SET (1 << 16) #define SOTG_INTERRUPT_CFG_CDBGMOD (3 << 6) #define SOTG_INTERRUPT_CFG_DDBGMODIN (3 << 4) #define SOTG_INTERRUPT_CFG_DDBGMODOUT (3 << 2) #define SOTG_INTERRUPT_CFG_INTLVL (1 << 1) #define SOTG_INTERRUPT_CFG_INTPOL (1 << 0) -#define SOTG_DEBUG 0x212 -#define SOTG_DEBUG_SET (1 << 0) #define SOTG_DCINTERRUPT_EN 0x214 #define SOTG_HW_MODE_CTRL 0x300 #define SOTG_HW_MODE_CTRL_ALL_ATX_RESET (1 << 31) @@ -129,8 +135,8 @@ #define SOTG_CTRL_FUNC_STALL (1 << 0) #define SOTG_DATA_PORT 0x220 #define SOTG_BUF_LENGTH 0x21C -#define SOTG_DCBUFFERSTATUS 0x21E -#define SOTG_DCBUFFERSTATUS_FILLED_MASK (3 << 0) +#define SOTG_BUF_LENGTH_BUFLEN_MASK 0xFFFF +#define SOTG_BUF_LENGTH_FILLED_MASK (3 << 16) #define SOTG_EP_MAXPACKET 0x204 #define SOTG_EP_TYPE 0x208 #define SOTG_EP_TYPE_NOEMPPKT (1 << 4) @@ -176,6 +182,7 @@ /* Host controller specific registers */ +#define SOTG_FRINDEX 0x002c #define SOTG_CONFIGFLAG 0x0060 #define SOTG_CONFIGFLAG_ENABLE (1 << 0) #define SOTG_PORTSC1 0x0064 @@ -189,25 +196,26 @@ #define SOTG_PORTSC1_PED (1 << 2) #define SOTG_PORTSC1_ECSC (1 << 1) #define SOTG_PORTSC1_ECCS (1 << 0) -#define SOTG_PDT_DW0 0 -#define SOTG_PDT_DW0_VALID 1U -#define SOTG_PDT_DW1 4 -#define SOTG_PDT_DW2 8 -#define SOTG_PDT_DW3 12 -#define SOTG_PDT_DW3_ACTIVE (1U << 31) -#define SOTG_PDT_DW3_HALTED (1U << 30) -#define SOTG_PDT_DW3_ERRORS (3U << 28) -#define SOTG_PDT_DW3_CERR (3U << 23) -#define SOTG_PDT_DW3_XFER_COUNT 0x7FFF -#define SOTG_PDT_DW4 16 -#define SOTG_PDT_DW5 20 -#define SOTG_PDT_DW6 24 -#define SOTG_PDT_DW7 28 +#define SOTG_PTD_DW0 0 +#define SOTG_PTD_DW0_VALID 1U +#define SOTG_PTD_DW1 4 +#define SOTG_PTD_DW1_ENABLE_SPLIT (1 << 14) +#define SOTG_PTD_DW2 8 +#define SOTG_PTD_DW3 12 +#define SOTG_PTD_DW3_ACTIVE (1U << 31) +#define SOTG_PTD_DW3_HALTED (1U << 30) +#define SOTG_PTD_DW3_ERRORS (3U << 28) +#define SOTG_PTD_DW3_CERR (3U << 23) +#define SOTG_PTD_DW3_XFER_COUNT 0x7FFF +#define SOTG_PTD_DW4 16 +#define SOTG_PTD_DW5 20 +#define SOTG_PTD_DW6 24 +#define SOTG_PTD_DW7 28 #define SOTG_DATA_ADDR(x) (0x1000 + (512 * (x))) -#define SOTG_ASYNC_PDT(x) (0xC00 + ((x) * 32)) -#define SOTG_INTR_PDT(x) (0x800 + ((x) * 32)) -#define SOTG_ISOC_PDT(x) (0x400 + ((x) * 32)) -#define SOTG_PDT(x) (0x400 + ((x) * 32)) +#define SOTG_ASYNC_PTD(x) (0xC00 + ((x) * 32)) +#define SOTG_INTR_PTD(x) (0x800 + ((x) * 32)) +#define SOTG_ISOC_PTD(x) (0x400 + ((x) * 32)) +#define SOTG_PTD(x) (0x400 + ((x) * 32)) #define SOTG_HC_MEMORY_ADDR(x) (((x) - 0x400) >> 3) #define SOTG_SW_RESET 0x30C #define SOTG_SW_RESET_HC (1 << 1) @@ -237,5 +245,15 @@ #define SOTG_HCINTERRUPT_DMAEOTINT (1 << 3) #define SOTG_HCINTERRUPT_SOFITLINT (1 << 1) #define SOTG_HCINTERRUPT_ENABLE 0x314 +#define SOTG_ATL_PTD_SKIP_PTD 0x154 +#define SOTG_ATL_PTD_LAST_PTD 0x158 +#define SOTG_INT_PTD_SKIP_PTD 0x144 +#define SOTG_INT_PTD_LAST_PTD 0x148 +#define SOTG_ISO_PTD_SKIP_PTD 0x134 +#define SOTG_ISO_PTD_LAST_PTD 0x138 +#define SOTG_HCBUFFERSTATUS 0x334 +#define SOTG_HCBUFFERSTATUS_ISO_BUF_FILL (1 << 2) +#define SOTG_HCBUFFERSTATUS_INT_BUF_FILL (1 << 1) +#define SOTG_HCBUFFERSTATUS_ATL_BUF_FILL (1 << 0) #endif /* _SAF1761_OTG_REG_H_ */ -- cgit v1.3 From 6df8a79713cac3def690fb02ec3507dfdded592b Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Tue, 27 May 2014 10:12:16 +0000 Subject: - Correct bus space resource type for register access. - Add configuration of interrupt type and polarity via FDT. Sponsored by: DARPA, AFRL --- sys/dev/usb/controller/saf1761_otg.c | 3 ++- sys/dev/usb/controller/saf1761_otg.h | 1 + sys/dev/usb/controller/saf1761_otg_fdt.c | 16 ++++++++++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/saf1761_otg.c b/sys/dev/usb/controller/saf1761_otg.c index 888face0f3a18..f57dbd0398701 100644 --- a/sys/dev/usb/controller/saf1761_otg.c +++ b/sys/dev/usb/controller/saf1761_otg.c @@ -2052,7 +2052,8 @@ saf1761_otg_init(struct saf1761_otg_softc *sc) SAF1761_WRITE_LE_4(sc, SOTG_INTERRUPT_CFG, SOTG_INTERRUPT_CFG_CDBGMOD | SOTG_INTERRUPT_CFG_DDBGMODIN | - SOTG_INTERRUPT_CFG_DDBGMODOUT); + SOTG_INTERRUPT_CFG_DDBGMODOUT | + sc->sc_interrupt_cfg); /* enable VBUS and ID interrupt */ SAF1761_WRITE_LE_4(sc, SOTG_IRQ_ENABLE_SET_CLR, diff --git a/sys/dev/usb/controller/saf1761_otg.h b/sys/dev/usb/controller/saf1761_otg.h index 6b7697255ea65..de5e7c9743b9c 100644 --- a/sys/dev/usb/controller/saf1761_otg.h +++ b/sys/dev/usb/controller/saf1761_otg.h @@ -144,6 +144,7 @@ struct saf1761_otg_softc { uint32_t sc_host_isoc_map; uint32_t sc_intr_enable; /* enabled interrupts */ uint32_t sc_hw_mode; /* hardware mode */ + uint32_t sc_interrupt_cfg; /* interrupt configuration */ uint32_t sc_bounce_buffer[1024 / 4]; diff --git a/sys/dev/usb/controller/saf1761_otg_fdt.c b/sys/dev/usb/controller/saf1761_otg_fdt.c index b0119d9342112..ab64341f6af8c 100644 --- a/sys/dev/usb/controller/saf1761_otg_fdt.c +++ b/sys/dev/usb/controller/saf1761_otg_fdt.c @@ -156,6 +156,18 @@ saf1761_otg_fdt_attach(device_t dev) sc->sc_hw_mode |= SOTG_HW_MODE_CTRL_DREQ_POL; } + /* get IRQ polarity */ + if (OF_getprop(ofw_bus_get_node(dev), "int-polarity", + ¶m, sizeof(param)) > 0) { + sc->sc_interrupt_cfg |= SOTG_INTERRUPT_CFG_INTPOL; + } + + /* get IRQ level triggering */ + if (OF_getprop(ofw_bus_get_node(dev), "int-level", + ¶m, sizeof(param)) > 0) { + sc->sc_interrupt_cfg |= SOTG_INTERRUPT_CFG_INTLVL; + } + /* initialise some bus fields */ sc->sc_bus.parent = dev; sc->sc_bus.devices = sc->sc_devices; @@ -168,7 +180,7 @@ saf1761_otg_fdt_attach(device_t dev) } rid = 0; sc->sc_io_res = - bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, RF_ACTIVE); + bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); if (!sc->sc_io_res) { goto error; @@ -243,7 +255,7 @@ saf1761_otg_fdt_detach(device_t dev) sc->sc_irq_res = NULL; } if (sc->sc_io_res) { - bus_release_resource(dev, SYS_RES_IOPORT, 0, + bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->sc_io_res); sc->sc_io_res = NULL; } -- cgit v1.3 From 4272b846633f932245eff40c38093edb1b908243 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Wed, 28 May 2014 16:28:22 +0000 Subject: Fixes for ISP/SAF1761 host mode: - Make the USB hardware skip PTDs which are not allocated. - Peek host memory twice. Sometimes the PTD status is incorrectly returned as zero. - Ensure the host channel is always freed when software TD is completing. - Add correct configuration of interrupt polarity and type. - Set CERR to 2 for asynchronous traffic to avoid having to reactivate the PTD when a NAK token is received. - Fix detection of STALL PID. Sponsored by: DARPA, AFRL --- sys/dev/usb/controller/saf1761_otg.c | 153 ++++++++++++++++++++----------- sys/dev/usb/controller/saf1761_otg_fdt.c | 21 +++-- sys/dev/usb/controller/saf1761_otg_reg.h | 23 ++++- 3 files changed, 133 insertions(+), 64 deletions(-) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/saf1761_otg.c b/sys/dev/usb/controller/saf1761_otg.c index f57dbd0398701..4a68fb95b1cd0 100644 --- a/sys/dev/usb/controller/saf1761_otg.c +++ b/sys/dev/usb/controller/saf1761_otg.c @@ -252,25 +252,24 @@ saf1761_host_channel_free(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t if (td->channel >= SOTG_HOST_CHANNEL_MAX) return; - /* disable channel */ - SAF1761_WRITE_LE_4(sc, SOTG_PTD(td->channel) + SOTG_PTD_DW3, 0); - SAF1761_WRITE_LE_4(sc, SOTG_PTD(td->channel) + SOTG_PTD_DW0, 0); - switch (td->ep_type) { case UE_INTERRUPT: x = td->channel - 32; - sc->sc_host_intr_map &= ~(1 << x); td->channel = SOTG_HOST_CHANNEL_MAX; + sc->sc_host_intr_map &= ~(1 << x); + SAF1761_WRITE_LE_4(sc, SOTG_INT_PTD_SKIP_PTD, ~sc->sc_host_intr_map); break; case UE_ISOCHRONOUS: x = td->channel; - sc->sc_host_isoc_map &= ~(1 << x); td->channel = SOTG_HOST_CHANNEL_MAX; + sc->sc_host_isoc_map &= ~(1 << x); + SAF1761_WRITE_LE_4(sc, SOTG_ISO_PTD_SKIP_PTD, ~sc->sc_host_isoc_map); break; default: x = td->channel - 64; - sc->sc_host_async_map &= ~(1 << x); td->channel = SOTG_HOST_CHANNEL_MAX; + sc->sc_host_async_map &= ~(1 << x); + SAF1761_WRITE_LE_4(sc, SOTG_ATL_PTD_SKIP_PTD, ~sc->sc_host_async_map); break; } } @@ -401,19 +400,16 @@ saf1761_host_setup_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) pdt_addr = SOTG_PTD(td->channel); status = saf1761_peek_host_memory_le_4(sc, pdt_addr + SOTG_PTD_DW3); + if (status == 0) + status = saf1761_peek_host_memory_le_4(sc, pdt_addr + SOTG_PTD_DW3); + DPRINTFN(5, "STATUS=0x%08x\n", status); if (status & SOTG_PTD_DW3_ACTIVE) { goto busy; } else if (status & SOTG_PTD_DW3_HALTED) { - td->error_stall = 1; - td->error_any = 1; - } else if (status & SOTG_PTD_DW3_ERRORS) { td->error_any = 1; } - count = (status & SOTG_PTD_DW3_XFER_COUNT); - - saf1761_host_channel_free(sc, td); goto complete; } if (saf1761_host_channel_alloc(sc, td)) @@ -435,7 +431,7 @@ saf1761_host_setup_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW5, 0); SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW4, 0); - temp = SOTG_PTD_DW3_ACTIVE | (td->toggle << 25) | SOTG_PTD_DW3_CERR; + temp = SOTG_PTD_DW3_ACTIVE | (td->toggle << 25) | SOTG_PTD_DW3_CERR_3; SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW3, temp); temp = SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8; @@ -450,10 +446,14 @@ saf1761_host_setup_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) SOTG_PTD_DW0_VALID; SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW0, temp); + /* activate PTD */ + SAF1761_WRITE_LE_4(sc, SOTG_ATL_PTD_SKIP_PTD, ~sc->sc_host_async_map); + td->toggle = 1; busy: return (1); /* busy */ complete: + saf1761_host_channel_free(sc, td); return (0); /* complete */ } @@ -471,15 +471,16 @@ saf1761_host_bulk_data_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t pdt_addr = SOTG_PTD(td->channel); status = saf1761_peek_host_memory_le_4(sc, pdt_addr + SOTG_PTD_DW3); + if (status == 0) + status = saf1761_peek_host_memory_le_4(sc, pdt_addr + SOTG_PTD_DW3); + DPRINTFN(5, "STATUS=0x%08x\n", status); if (status & SOTG_PTD_DW3_ACTIVE) { goto busy; } else if (status & SOTG_PTD_DW3_HALTED) { - td->error_stall = 1; - td->error_any = 1; - goto complete; - } else if (status & SOTG_PTD_DW3_ERRORS) { + if (!(status & SOTG_PTD_DW3_ERRORS)) + td->error_stall = 1; td->error_any = 1; goto complete; } @@ -509,14 +510,13 @@ saf1761_host_bulk_data_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t saf1761_read_host_memory(sc, td, count); - saf1761_host_channel_free(sc, td); - /* check if we are complete */ if ((td->remainder == 0) || got_short) { if (td->short_pkt) goto complete; /* else need to receive a zero length packet */ } + saf1761_host_channel_free(sc, td); } if (saf1761_host_channel_alloc(sc, td)) goto busy; @@ -536,10 +536,11 @@ saf1761_host_bulk_data_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW5, 0); SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW4, 0); - temp = SOTG_PTD_DW3_ACTIVE | (td->toggle << 25) | SOTG_PTD_DW3_CERR; + temp = SOTG_PTD_DW3_ACTIVE | (td->toggle << 25) | + SOTG_PTD_DW3_CERR_2; SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW3, temp); - temp = SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8; + temp = (SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8); SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW2, temp); temp = td->dw1_value | (1 << 10) /* IN-PID */ | (td->ep_index >> 1); @@ -550,9 +551,13 @@ saf1761_host_bulk_data_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t (td->max_packet_size << 3) /* transfer count */ | SOTG_PTD_DW0_VALID; SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW0, temp); + + /* activate PTD */ + SAF1761_WRITE_LE_4(sc, SOTG_ATL_PTD_SKIP_PTD, ~sc->sc_host_async_map); busy: return (1); /* busy */ complete: + saf1761_host_channel_free(sc, td); return (0); /* complete */ } @@ -569,25 +574,26 @@ saf1761_host_bulk_data_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t pdt_addr = SOTG_PTD(td->channel); status = saf1761_peek_host_memory_le_4(sc, pdt_addr + SOTG_PTD_DW3); + if (status == 0) + status = saf1761_peek_host_memory_le_4(sc, pdt_addr + SOTG_PTD_DW3); + DPRINTFN(5, "STATUS=0x%08x\n", status); if (status & SOTG_PTD_DW3_ACTIVE) { goto busy; } else if (status & SOTG_PTD_DW3_HALTED) { - td->error_stall = 1; - td->error_any = 1; - } else if (status & SOTG_PTD_DW3_ERRORS) { + if (!(status & SOTG_PTD_DW3_ERRORS)) + td->error_stall = 1; td->error_any = 1; + goto complete; } - - saf1761_host_channel_free(sc, td); - /* check remainder */ if (td->remainder == 0) { if (td->short_pkt) goto complete; /* else we need to transmit a short packet */ } + saf1761_host_channel_free(sc, td); } if (saf1761_host_channel_alloc(sc, td)) goto busy; @@ -616,10 +622,11 @@ saf1761_host_bulk_data_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW5, 0); SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW4, 0); - temp = SOTG_PTD_DW3_ACTIVE | (td->toggle << 25) | SOTG_PTD_DW3_CERR; + temp = SOTG_PTD_DW3_ACTIVE | (td->toggle << 25) | + SOTG_PTD_DW3_CERR_2; SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW3, temp); - temp = SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8; + temp = (SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8); SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW2, temp); temp = td->dw1_value | (0 << 10) /* OUT-PID */ | (td->ep_index >> 1); @@ -631,10 +638,14 @@ saf1761_host_bulk_data_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t SOTG_PTD_DW0_VALID; SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW0, temp); + /* activate PTD */ + SAF1761_WRITE_LE_4(sc, SOTG_ATL_PTD_SKIP_PTD, ~sc->sc_host_async_map); + td->toggle ^= 1; busy: return (1); /* busy */ complete: + saf1761_host_channel_free(sc, td); return (0); /* complete */ } @@ -652,16 +663,19 @@ saf1761_host_intr_data_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t pdt_addr = SOTG_PTD(td->channel); status = saf1761_peek_host_memory_le_4(sc, pdt_addr + SOTG_PTD_DW3); + if (status == 0) + status = saf1761_peek_host_memory_le_4(sc, pdt_addr + SOTG_PTD_DW3); + DPRINTFN(5, "STATUS=0x%08x\n", status); if (status & SOTG_PTD_DW3_ACTIVE) { goto busy; } else if (status & SOTG_PTD_DW3_HALTED) { - td->error_stall = 1; + if (!(status & SOTG_PTD_DW3_ERRORS)) + td->error_stall = 1; td->error_any = 1; goto complete; } - count = (status & SOTG_PTD_DW3_XFER_COUNT); got_short = 0; @@ -688,14 +702,13 @@ saf1761_host_intr_data_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t saf1761_read_host_memory(sc, td, count); - saf1761_host_channel_free(sc, td); - /* check if we are complete */ if ((td->remainder == 0) || got_short) { if (td->short_pkt) goto complete; /* else need to receive a zero length packet */ } + saf1761_host_channel_free(sc, td); } if (saf1761_host_channel_alloc(sc, td)) goto busy; @@ -719,7 +732,7 @@ saf1761_host_intr_data_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t temp = (1U << td->uframe); /* start split */ SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW4, temp); - temp = SOTG_PTD_DW3_ACTIVE | (td->toggle << 25) | SOTG_PTD_DW3_CERR; + temp = SOTG_PTD_DW3_ACTIVE | (td->toggle << 25) | SOTG_PTD_DW3_CERR_3; SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW3, temp); temp = (SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8) | (td->interval & 0xF8); @@ -733,9 +746,13 @@ saf1761_host_intr_data_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t (td->max_packet_size << 3) /* transfer count */ | SOTG_PTD_DW0_VALID; SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW0, temp); + + /* activate PTD */ + SAF1761_WRITE_LE_4(sc, SOTG_INT_PTD_SKIP_PTD, ~sc->sc_host_intr_map); busy: return (1); /* busy */ complete: + saf1761_host_channel_free(sc, td); return (0); /* complete */ } @@ -752,23 +769,27 @@ saf1761_host_intr_data_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t pdt_addr = SOTG_PTD(td->channel); status = saf1761_peek_host_memory_le_4(sc, pdt_addr + SOTG_PTD_DW3); + if (status == 0) + status = saf1761_peek_host_memory_le_4(sc, pdt_addr + SOTG_PTD_DW3); + DPRINTFN(5, "STATUS=0x%08x\n", status); if (status & SOTG_PTD_DW3_ACTIVE) { goto busy; } else if (status & SOTG_PTD_DW3_HALTED) { - td->error_stall = 1; + if (!(status & SOTG_PTD_DW3_ERRORS)) + td->error_stall = 1; td->error_any = 1; + goto complete; } - saf1761_host_channel_free(sc, td); - /* check remainder */ if (td->remainder == 0) { if (td->short_pkt) goto complete; /* else we need to transmit a short packet */ } + saf1761_host_channel_free(sc, td); } if (saf1761_host_channel_alloc(sc, td)) goto busy; @@ -801,7 +822,7 @@ saf1761_host_intr_data_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t temp = (1U << td->uframe); /* start split */ SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW4, temp); - temp = SOTG_PTD_DW3_ACTIVE | (td->toggle << 25) | SOTG_PTD_DW3_CERR; + temp = SOTG_PTD_DW3_ACTIVE | (td->toggle << 25) | SOTG_PTD_DW3_CERR_3; SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW3, temp); temp = (SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8) | (td->interval & 0xF8); @@ -816,22 +837,32 @@ saf1761_host_intr_data_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t SOTG_PTD_DW0_VALID; SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW0, temp); + /* activate PTD */ + SAF1761_WRITE_LE_4(sc, SOTG_INT_PTD_SKIP_PTD, ~sc->sc_host_intr_map); + td->toggle ^= 1; busy: return (1); /* busy */ complete: + saf1761_host_channel_free(sc, td); return (0); /* complete */ } static uint8_t saf1761_host_isoc_data_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) { + /* activate PTD */ + SAF1761_WRITE_LE_4(sc, SOTG_ISO_PTD_SKIP_PTD, ~sc->sc_host_isoc_map); + return (1); /* busy */ } static uint8_t saf1761_host_isoc_data_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) { + /* activate PTD */ + SAF1761_WRITE_LE_4(sc, SOTG_ISO_PTD_SKIP_PTD, ~sc->sc_host_isoc_map); + return (1); /* busy */ } @@ -1319,10 +1350,13 @@ saf1761_otg_interrupt(struct saf1761_otg_softc *sc) SAF1761_READ_LE_4(sc, SOTG_FRAME_NUM), SAF1761_READ_LE_4(sc, SOTG_FRINDEX)); + (void) SAF1761_READ_LE_4(sc, SOTG_ATL_PTD_DONE_PTD); + (void) SAF1761_READ_LE_4(sc, SOTG_INT_PTD_DONE_PTD); + (void) SAF1761_READ_LE_4(sc, SOTG_ISO_PTD_DONE_PTD); + /* update VBUS and ID bits, if any */ - if (status & SOTG_DCINTERRUPT_IEVBUS) { + if (status & SOTG_DCINTERRUPT_IEVBUS) saf1761_otg_update_vbus(sc); - } if (status & SOTG_DCINTERRUPT_IEBRST) { /* unlock device */ @@ -1431,7 +1465,8 @@ saf1761_otg_setup_standard_chain(struct usb_xfer *xfer) temp.td = NULL; temp.td_next = xfer->td_start[0]; temp.offset = 0; - temp.setup_alt_next = xfer->flags_int.short_frames_ok; + temp.setup_alt_next = xfer->flags_int.short_frames_ok || + xfer->flags_int.isochronous_xfr; temp.did_stall = !xfer->flags_int.control_stall; is_host = (xfer->xroot->udev->flags.usb_mode == USB_MODE_HOST); @@ -1732,7 +1767,8 @@ saf1761_otg_standard_done_sub(struct usb_xfer *xfer) } /* Check for short transfer */ if (len > 0) { - if (xfer->flags_int.short_frames_ok) { + if (xfer->flags_int.short_frames_ok || + xfer->flags_int.isochronous_xfr) { /* follow alt next */ if (td->alt_next) { td = td->obj_next; @@ -2048,12 +2084,13 @@ saf1761_otg_init(struct saf1761_otg_softc *sc) SAF1761_WRITE_LE_4(sc, SOTG_MODE, SOTG_MODE_GLINTENA | SOTG_MODE_CLKAON | SOTG_MODE_WKUPCS); + sc->sc_interrupt_cfg |= + SOTG_INTERRUPT_CFG_CDBGMOD | + SOTG_INTERRUPT_CFG_DDBGMODIN | + SOTG_INTERRUPT_CFG_DDBGMODOUT; + /* set default values */ - SAF1761_WRITE_LE_4(sc, SOTG_INTERRUPT_CFG, - SOTG_INTERRUPT_CFG_CDBGMOD | - SOTG_INTERRUPT_CFG_DDBGMODIN | - SOTG_INTERRUPT_CFG_DDBGMODOUT | - sc->sc_interrupt_cfg); + SAF1761_WRITE_LE_4(sc, SOTG_INTERRUPT_CFG, sc->sc_interrupt_cfg); /* enable VBUS and ID interrupt */ SAF1761_WRITE_LE_4(sc, SOTG_IRQ_ENABLE_SET_CLR, @@ -2099,15 +2136,15 @@ saf1761_otg_init(struct saf1761_otg_softc *sc) DPRINTF("USBCMD=0x%08x\n", SAF1761_READ_LE_4(sc, SOTG_USBCMD)); - /* activate all PTDs */ + /* make HC scan all PTDs */ SAF1761_WRITE_LE_4(sc, SOTG_ATL_PTD_LAST_PTD, (1 << 31)); SAF1761_WRITE_LE_4(sc, SOTG_INT_PTD_LAST_PTD, (1 << 31)); SAF1761_WRITE_LE_4(sc, SOTG_ISO_PTD_LAST_PTD, (1 << 31)); - /* skip no PTDs */ - SAF1761_WRITE_LE_4(sc, SOTG_ATL_PTD_SKIP_PTD, 0); - SAF1761_WRITE_LE_4(sc, SOTG_INT_PTD_SKIP_PTD, 0); - SAF1761_WRITE_LE_4(sc, SOTG_ISO_PTD_SKIP_PTD, 0); + /* skip all PTDs by default */ + SAF1761_WRITE_LE_4(sc, SOTG_ATL_PTD_SKIP_PTD, -1U); + SAF1761_WRITE_LE_4(sc, SOTG_INT_PTD_SKIP_PTD, -1U); + SAF1761_WRITE_LE_4(sc, SOTG_ISO_PTD_SKIP_PTD, -1U); /* activate all PTD types */ SAF1761_WRITE_LE_4(sc, SOTG_HCBUFFERSTATUS, @@ -2115,6 +2152,16 @@ saf1761_otg_init(struct saf1761_otg_softc *sc) SOTG_HCBUFFERSTATUS_INT_BUF_FILL | SOTG_HCBUFFERSTATUS_ATL_BUF_FILL); + /* we don't use the AND mask */ + SAF1761_WRITE_LE_4(sc, SOTG_ISO_IRQ_MASK_AND, 0); + SAF1761_WRITE_LE_4(sc, SOTG_INT_IRQ_MASK_AND, 0); + SAF1761_WRITE_LE_4(sc, SOTG_ATL_IRQ_MASK_AND, 0); + + /* enable all PTD OR interrupts by default */ + SAF1761_WRITE_LE_4(sc, SOTG_ISO_IRQ_MASK_OR, -1U); + SAF1761_WRITE_LE_4(sc, SOTG_INT_IRQ_MASK_OR, -1U); + SAF1761_WRITE_LE_4(sc, SOTG_ATL_IRQ_MASK_OR, -1U); + /* enable HC interrupts */ SAF1761_WRITE_LE_4(sc, SOTG_HCINTERRUPT_ENABLE, SOTG_HCINTERRUPT_OTG_IRQ | diff --git a/sys/dev/usb/controller/saf1761_otg_fdt.c b/sys/dev/usb/controller/saf1761_otg_fdt.c index ab64341f6af8c..786976badd2f1 100644 --- a/sys/dev/usb/controller/saf1761_otg_fdt.c +++ b/sys/dev/usb/controller/saf1761_otg_fdt.c @@ -160,12 +160,14 @@ saf1761_otg_fdt_attach(device_t dev) if (OF_getprop(ofw_bus_get_node(dev), "int-polarity", ¶m, sizeof(param)) > 0) { sc->sc_interrupt_cfg |= SOTG_INTERRUPT_CFG_INTPOL; + sc->sc_hw_mode |= SOTG_HW_MODE_CTRL_INTR_POL; } /* get IRQ level triggering */ if (OF_getprop(ofw_bus_get_node(dev), "int-level", ¶m, sizeof(param)) > 0) { sc->sc_interrupt_cfg |= SOTG_INTERRUPT_CFG_INTLVL; + sc->sc_hw_mode |= SOTG_HW_MODE_CTRL_INTR_LEVEL; } /* initialise some bus fields */ @@ -182,23 +184,30 @@ saf1761_otg_fdt_attach(device_t dev) sc->sc_io_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); - if (!sc->sc_io_res) { + if (sc->sc_io_res == NULL) goto error; - } + sc->sc_io_tag = rman_get_bustag(sc->sc_io_res); sc->sc_io_hdl = rman_get_bushandle(sc->sc_io_res); sc->sc_io_size = rman_get_size(sc->sc_io_res); - rid = 0; + /* try to allocate the HC interrupt first */ + rid = 1; sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_SHAREABLE | RF_ACTIVE); if (sc->sc_irq_res == NULL) { - goto error; + /* try to allocate a common IRQ second */ + rid = 0; + sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, + RF_SHAREABLE | RF_ACTIVE); + if (sc->sc_irq_res == NULL) + goto error; } + sc->sc_bus.bdev = device_add_child(dev, "usbus", -1); - if (!(sc->sc_bus.bdev)) { + if (sc->sc_bus.bdev == NULL) goto error; - } + device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus); err = bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE, diff --git a/sys/dev/usb/controller/saf1761_otg_reg.h b/sys/dev/usb/controller/saf1761_otg_reg.h index bfed688bf28ba..74346e557ce18 100644 --- a/sys/dev/usb/controller/saf1761_otg_reg.h +++ b/sys/dev/usb/controller/saf1761_otg_reg.h @@ -84,7 +84,7 @@ #define SOTG_TIMER_HIGH_SET_CLR 0x38C #define SOTG_TIMER_HIGH_SET(x) ((x) & 0xFFFF) #define SOTG_TIMER_HIGH_CLR(x) (((x) << 16) & 0xFFFF0000) -#define SOTG_TIMER_START_TMR (1U << 15) +#define SOTG_TIMER_HIGH_START (1U << 15) #define SOTG_MEMORY_REG 0x33c /* Peripheral controller specific registers */ @@ -102,9 +102,9 @@ #define SOTG_MODE_WKUPCS (1 << 2) #define SOTG_INTERRUPT_CFG 0x210 #define SOTG_INTERRUPT_CFG_DEBUG_SET (1 << 16) -#define SOTG_INTERRUPT_CFG_CDBGMOD (3 << 6) -#define SOTG_INTERRUPT_CFG_DDBGMODIN (3 << 4) -#define SOTG_INTERRUPT_CFG_DDBGMODOUT (3 << 2) +#define SOTG_INTERRUPT_CFG_CDBGMOD (1 << 6) /* ACK only */ +#define SOTG_INTERRUPT_CFG_DDBGMODIN (1 << 4) /* ACK only */ +#define SOTG_INTERRUPT_CFG_DDBGMODOUT (1 << 2) /* ACK and NYET only */ #define SOTG_INTERRUPT_CFG_INTLVL (1 << 1) #define SOTG_INTERRUPT_CFG_INTPOL (1 << 0) #define SOTG_DCINTERRUPT_EN 0x214 @@ -201,11 +201,15 @@ #define SOTG_PTD_DW1 4 #define SOTG_PTD_DW1_ENABLE_SPLIT (1 << 14) #define SOTG_PTD_DW2 8 +#define SOTG_PTD_DW2_RL (0xf << 25) #define SOTG_PTD_DW3 12 +#define SOTG_PTD_DW3_NRL (0xf << 19) #define SOTG_PTD_DW3_ACTIVE (1U << 31) #define SOTG_PTD_DW3_HALTED (1U << 30) #define SOTG_PTD_DW3_ERRORS (3U << 28) -#define SOTG_PTD_DW3_CERR (3U << 23) +#define SOTG_PTD_DW3_CERR_3 (3U << 23) +#define SOTG_PTD_DW3_CERR_2 (2U << 23) /* infinite NAKs */ +#define SOTG_PTD_DW3_CERR_1 (1U << 23) #define SOTG_PTD_DW3_XFER_COUNT 0x7FFF #define SOTG_PTD_DW4 16 #define SOTG_PTD_DW5 20 @@ -245,15 +249,24 @@ #define SOTG_HCINTERRUPT_DMAEOTINT (1 << 3) #define SOTG_HCINTERRUPT_SOFITLINT (1 << 1) #define SOTG_HCINTERRUPT_ENABLE 0x314 +#define SOTG_ATL_PTD_DONE_PTD 0x150 #define SOTG_ATL_PTD_SKIP_PTD 0x154 #define SOTG_ATL_PTD_LAST_PTD 0x158 +#define SOTG_INT_PTD_DONE_PTD 0x140 #define SOTG_INT_PTD_SKIP_PTD 0x144 #define SOTG_INT_PTD_LAST_PTD 0x148 +#define SOTG_ISO_PTD_DONE_PTD 0x130 #define SOTG_ISO_PTD_SKIP_PTD 0x134 #define SOTG_ISO_PTD_LAST_PTD 0x138 #define SOTG_HCBUFFERSTATUS 0x334 #define SOTG_HCBUFFERSTATUS_ISO_BUF_FILL (1 << 2) #define SOTG_HCBUFFERSTATUS_INT_BUF_FILL (1 << 1) #define SOTG_HCBUFFERSTATUS_ATL_BUF_FILL (1 << 0) +#define SOTG_ISO_IRQ_MASK_OR 0x318 +#define SOTG_INT_IRQ_MASK_OR 0x31C +#define SOTG_ATL_IRQ_MASK_OR 0x320 +#define SOTG_ISO_IRQ_MASK_AND 0x324 +#define SOTG_INT_IRQ_MASK_AND 0x328 +#define SOTG_ATL_IRQ_MASK_AND 0x32C #endif /* _SAF1761_OTG_REG_H_ */ -- cgit v1.3 From 580bc2220a4a666fb0ac2a2a3c1c3182859280cb Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Thu, 29 May 2014 10:06:18 +0000 Subject: Optimise the ISP/SAF1761 driver: - Use an interrupt filter for handling the data path interrupts. This increases the throughput significantly. - Implement support for USB suspend and resume in USB host mode. Sponsored by: DARPA, AFRL --- sys/dev/usb/controller/saf1761_otg.c | 298 ++++++++++++++++++++++++++----- sys/dev/usb/controller/saf1761_otg.h | 7 +- sys/dev/usb/controller/saf1761_otg_fdt.c | 4 +- 3 files changed, 266 insertions(+), 43 deletions(-) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/saf1761_otg.c b/sys/dev/usb/controller/saf1761_otg.c index 4a68fb95b1cd0..012f9fd101765 100644 --- a/sys/dev/usb/controller/saf1761_otg.c +++ b/sys/dev/usb/controller/saf1761_otg.c @@ -84,6 +84,13 @@ ((struct saf1761_otg_softc *)(((uint8_t *)(bus)) - \ ((uint8_t *)&(((struct saf1761_otg_softc *)0)->sc_bus)))) +#define SAF1761_OTG_PC2UDEV(pc) \ + (USB_DMATAG_TO_XROOT((pc)->tag_parent)->udev) + +#define SAF1761_DCINTERRUPT_THREAD_IRQ \ + (SOTG_DCINTERRUPT_IEVBUS | SOTG_DCINTERRUPT_IEBRST | \ + SOTG_DCINTERRUPT_IERESM | SOTG_DCINTERRUPT_IESUSP) + #ifdef USB_DEBUG static int saf1761_otg_debug = 0; static int saf1761_otg_forcefs = 0; @@ -201,7 +208,6 @@ saf1761_otg_wakeup_peer(struct saf1761_otg_softc *sc) /* Wait 8ms for remote wakeup to complete. */ usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 125); - } static uint8_t @@ -212,6 +218,10 @@ saf1761_host_channel_alloc(struct saf1761_otg_softc *sc, struct saf1761_otg_td * if (td->channel < SOTG_HOST_CHANNEL_MAX) return (0); + /* check if device is suspended */ + if (SAF1761_OTG_PC2UDEV(td->pc)->flags.self_suspended != 0) + return (1); /* busy - cannot transfer data */ + switch (td->ep_type) { case UE_INTERRUPT: for (x = 0; x != 32; x++) { @@ -257,19 +267,25 @@ saf1761_host_channel_free(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t x = td->channel - 32; td->channel = SOTG_HOST_CHANNEL_MAX; sc->sc_host_intr_map &= ~(1 << x); - SAF1761_WRITE_LE_4(sc, SOTG_INT_PTD_SKIP_PTD, ~sc->sc_host_intr_map); + sc->sc_host_intr_suspend_map &= ~(1 << x); + SAF1761_WRITE_LE_4(sc, SOTG_INT_PTD_SKIP_PTD, + (~sc->sc_host_intr_map) | sc->sc_host_intr_suspend_map); break; case UE_ISOCHRONOUS: x = td->channel; td->channel = SOTG_HOST_CHANNEL_MAX; sc->sc_host_isoc_map &= ~(1 << x); - SAF1761_WRITE_LE_4(sc, SOTG_ISO_PTD_SKIP_PTD, ~sc->sc_host_isoc_map); + sc->sc_host_isoc_suspend_map &= ~(1 << x); + SAF1761_WRITE_LE_4(sc, SOTG_ISO_PTD_SKIP_PTD, + (~sc->sc_host_isoc_map) | sc->sc_host_isoc_suspend_map); break; default: x = td->channel - 64; td->channel = SOTG_HOST_CHANNEL_MAX; sc->sc_host_async_map &= ~(1 << x); - SAF1761_WRITE_LE_4(sc, SOTG_ATL_PTD_SKIP_PTD, ~sc->sc_host_async_map); + sc->sc_host_async_suspend_map &= ~(1 << x); + SAF1761_WRITE_LE_4(sc, SOTG_ATL_PTD_SKIP_PTD, + (~sc->sc_host_async_map) | sc->sc_host_async_suspend_map); break; } } @@ -447,7 +463,8 @@ saf1761_host_setup_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW0, temp); /* activate PTD */ - SAF1761_WRITE_LE_4(sc, SOTG_ATL_PTD_SKIP_PTD, ~sc->sc_host_async_map); + SAF1761_WRITE_LE_4(sc, SOTG_ATL_PTD_SKIP_PTD, + (~sc->sc_host_async_map) | sc->sc_host_async_suspend_map); td->toggle = 1; busy: @@ -553,7 +570,8 @@ saf1761_host_bulk_data_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW0, temp); /* activate PTD */ - SAF1761_WRITE_LE_4(sc, SOTG_ATL_PTD_SKIP_PTD, ~sc->sc_host_async_map); + SAF1761_WRITE_LE_4(sc, SOTG_ATL_PTD_SKIP_PTD, + (~sc->sc_host_async_map) | sc->sc_host_async_suspend_map); busy: return (1); /* busy */ complete: @@ -639,7 +657,8 @@ saf1761_host_bulk_data_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW0, temp); /* activate PTD */ - SAF1761_WRITE_LE_4(sc, SOTG_ATL_PTD_SKIP_PTD, ~sc->sc_host_async_map); + SAF1761_WRITE_LE_4(sc, SOTG_ATL_PTD_SKIP_PTD, + (~sc->sc_host_async_map) | sc->sc_host_async_suspend_map); td->toggle ^= 1; busy: @@ -748,7 +767,8 @@ saf1761_host_intr_data_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW0, temp); /* activate PTD */ - SAF1761_WRITE_LE_4(sc, SOTG_INT_PTD_SKIP_PTD, ~sc->sc_host_intr_map); + SAF1761_WRITE_LE_4(sc, SOTG_INT_PTD_SKIP_PTD, + (~sc->sc_host_intr_map) | sc->sc_host_intr_suspend_map); busy: return (1); /* busy */ complete: @@ -838,7 +858,8 @@ saf1761_host_intr_data_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW0, temp); /* activate PTD */ - SAF1761_WRITE_LE_4(sc, SOTG_INT_PTD_SKIP_PTD, ~sc->sc_host_intr_map); + SAF1761_WRITE_LE_4(sc, SOTG_INT_PTD_SKIP_PTD, + (~sc->sc_host_intr_map) | sc->sc_host_intr_suspend_map); td->toggle ^= 1; busy: @@ -852,7 +873,8 @@ static uint8_t saf1761_host_isoc_data_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) { /* activate PTD */ - SAF1761_WRITE_LE_4(sc, SOTG_ISO_PTD_SKIP_PTD, ~sc->sc_host_isoc_map); + SAF1761_WRITE_LE_4(sc, SOTG_ISO_PTD_SKIP_PTD, + (~sc->sc_host_isoc_map) | sc->sc_host_isoc_suspend_map); return (1); /* busy */ } @@ -861,7 +883,8 @@ static uint8_t saf1761_host_isoc_data_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) { /* activate PTD */ - SAF1761_WRITE_LE_4(sc, SOTG_ISO_PTD_SKIP_PTD, ~sc->sc_host_isoc_map); + SAF1761_WRITE_LE_4(sc, SOTG_ISO_PTD_SKIP_PTD, + (~sc->sc_host_isoc_map) | sc->sc_host_isoc_suspend_map); return (1); /* busy */ } @@ -1222,7 +1245,7 @@ saf1761_device_data_tx_sync(struct saf1761_otg_softc *sc, struct saf1761_otg_td return (0); /* complete */ } -static uint8_t +static void saf1761_otg_xfer_do_fifo(struct saf1761_otg_softc *sc, struct usb_xfer *xfer) { struct saf1761_otg_td *td; @@ -1231,6 +1254,9 @@ saf1761_otg_xfer_do_fifo(struct saf1761_otg_softc *sc, struct usb_xfer *xfer) DPRINTFN(9, "\n"); td = xfer->td_transfer_cache; + if (td == NULL) + return; + while (1) { if ((td->func) (sc, td)) { /* operation in progress */ @@ -1258,28 +1284,37 @@ saf1761_otg_xfer_do_fifo(struct saf1761_otg_softc *sc, struct usb_xfer *xfer) td->toggle = toggle; xfer->td_transfer_cache = td; } - return (1); /* not complete */ + return; done: /* compute all actual lengths */ + xfer->td_transfer_cache = NULL; + sc->sc_xfer_complete = 1; +} + +static uint8_t +saf1761_otg_xfer_do_complete(struct saf1761_otg_softc *sc, struct usb_xfer *xfer) +{ + struct saf1761_otg_td *td; - saf1761_otg_standard_done(xfer); + DPRINTFN(9, "\n"); - return (0); /* complete */ + td = xfer->td_transfer_cache; + if (td == NULL) { + /* compute all actual lengths */ + saf1761_otg_standard_done(xfer); + return (1); + } + return (0); } static void -saf1761_otg_interrupt_poll(struct saf1761_otg_softc *sc) +saf1761_otg_interrupt_poll_locked(struct saf1761_otg_softc *sc) { struct usb_xfer *xfer; -repeat: - TAILQ_FOREACH(xfer, &sc->sc_bus.intr_q.head, wait_entry) { - if (!saf1761_otg_xfer_do_fifo(sc, xfer)) { - /* queue has been modified */ - goto repeat; - } - } + TAILQ_FOREACH(xfer, &sc->sc_bus.intr_q.head, wait_entry) + saf1761_otg_xfer_do_fifo(sc, xfer); } static void @@ -1329,13 +1364,27 @@ saf1761_otg_update_vbus(struct saf1761_otg_softc *sc) } } -void -saf1761_otg_interrupt(struct saf1761_otg_softc *sc) +static void +saf1761_otg_interrupt_complete_locked(struct saf1761_otg_softc *sc) { - uint32_t status; + struct usb_xfer *xfer; +repeat: + /* scan for completion events */ + TAILQ_FOREACH(xfer, &sc->sc_bus.intr_q.head, wait_entry) { + if (saf1761_otg_xfer_do_complete(sc, xfer)) + goto repeat; + } +} + +int +saf1761_otg_filter_interrupt(void *arg) +{ + struct saf1761_otg_softc *sc = arg; + int retval = FILTER_HANDLED; uint32_t hcstat; + uint32_t status; - USB_BUS_LOCK(&sc->sc_bus); + USB_BUS_SPIN_LOCK(&sc->sc_bus); hcstat = SAF1761_READ_LE_4(sc, SOTG_HCINTERRUPT); /* acknowledge all host controller interrupts */ @@ -1343,17 +1392,47 @@ saf1761_otg_interrupt(struct saf1761_otg_softc *sc) status = SAF1761_READ_LE_4(sc, SOTG_DCINTERRUPT); /* acknowledge all device controller interrupts */ - SAF1761_WRITE_LE_4(sc, SOTG_DCINTERRUPT, status); - - DPRINTF("DCINTERRUPT=0x%08x HCINTERRUPT=0x%08x SOF=0x%08x " - "FRINDEX=0x%08x\n", status, hcstat, - SAF1761_READ_LE_4(sc, SOTG_FRAME_NUM), - SAF1761_READ_LE_4(sc, SOTG_FRINDEX)); + SAF1761_WRITE_LE_4(sc, SOTG_DCINTERRUPT, + status & ~SAF1761_DCINTERRUPT_THREAD_IRQ); (void) SAF1761_READ_LE_4(sc, SOTG_ATL_PTD_DONE_PTD); (void) SAF1761_READ_LE_4(sc, SOTG_INT_PTD_DONE_PTD); (void) SAF1761_READ_LE_4(sc, SOTG_ISO_PTD_DONE_PTD); + if (status & SAF1761_DCINTERRUPT_THREAD_IRQ) + retval = FILTER_SCHEDULE_THREAD; + + /* poll FIFOs, if any */ + saf1761_otg_interrupt_poll_locked(sc); + + if (sc->sc_xfer_complete != 0) + retval = FILTER_SCHEDULE_THREAD; + + USB_BUS_SPIN_UNLOCK(&sc->sc_bus); + + return (retval); +} + +void +saf1761_otg_interrupt(void *arg) +{ + struct saf1761_otg_softc *sc = arg; + uint32_t status; + + USB_BUS_LOCK(&sc->sc_bus); + USB_BUS_SPIN_LOCK(&sc->sc_bus); + + status = SAF1761_READ_LE_4(sc, SOTG_DCINTERRUPT) & + SAF1761_DCINTERRUPT_THREAD_IRQ; + + /* acknowledge all device controller interrupts */ + SAF1761_WRITE_LE_4(sc, SOTG_DCINTERRUPT, status); + + DPRINTF("DCINTERRUPT=0x%08x SOF=0x%08x " + "FRINDEX=0x%08x\n", status, + SAF1761_READ_LE_4(sc, SOTG_FRAME_NUM), + SAF1761_READ_LE_4(sc, SOTG_FRINDEX)); + /* update VBUS and ID bits, if any */ if (status & SOTG_DCINTERRUPT_IEVBUS) saf1761_otg_update_vbus(sc); @@ -1405,9 +1484,14 @@ saf1761_otg_interrupt(struct saf1761_otg_softc *sc) saf1761_otg_root_intr(sc); } } - /* poll all active transfers */ - saf1761_otg_interrupt_poll(sc); + if (sc->sc_xfer_complete != 0) { + sc->sc_xfer_complete = 0; + + /* complete FIFOs, if any */ + saf1761_otg_interrupt_complete_locked(sc); + } + USB_BUS_SPIN_UNLOCK(&sc->sc_bus); USB_BUS_UNLOCK(&sc->sc_bus); } @@ -1694,9 +1778,12 @@ saf1761_otg_start_standard_chain(struct usb_xfer *xfer) DPRINTFN(9, "\n"); + USB_BUS_SPIN_LOCK(&sc->sc_bus); + /* poll one time */ - if (saf1761_otg_xfer_do_fifo(sc, xfer)) { + saf1761_otg_xfer_do_fifo(sc, xfer); + if (xfer->td_transfer_cache != NULL) { /* * Only enable the endpoint interrupt when we are * actually waiting for data, hence we are dealing @@ -1712,7 +1799,11 @@ saf1761_otg_start_standard_chain(struct usb_xfer *xfer) usbd_transfer_timeout_ms(xfer, &saf1761_otg_timeout, xfer->timeout); } + } else { + /* catch completion, if any */ + saf1761_otg_interrupt_complete_locked(sc); } + USB_BUS_SPIN_UNLOCK(&sc->sc_bus); } static void @@ -1856,6 +1947,8 @@ saf1761_otg_device_done(struct usb_xfer *xfer, usb_error_t error) DPRINTFN(2, "xfer=%p, endpoint=%p, error=%d\n", xfer, xfer->endpoint, error); + USB_BUS_SPIN_LOCK(&sc->sc_bus); + if (xfer->flags_int.usb_mode == USB_MODE_DEVICE) { saf1761_otg_intr_set(xfer, 0); } else { @@ -1869,6 +1962,8 @@ saf1761_otg_device_done(struct usb_xfer *xfer, usb_error_t error) /* dequeue transfer and start next transfer */ usbd_transfer_done(xfer, error); + + USB_BUS_SPIN_UNLOCK(&sc->sc_bus); } static void @@ -1896,8 +1991,9 @@ saf1761_otg_set_stall(struct usb_device *udev, DPRINTFN(5, "endpoint=%p\n", ep); - /* set FORCESTALL */ + /* set STALL bit */ sc = SAF1761_OTG_BUS2SC(udev->bus); + ep_no = (ep->edesc->bEndpointAddress & UE_ADDR); ep_dir = (ep->edesc->bEndpointAddress & (UE_DIR_IN | UE_DIR_OUT)); ep_type = (ep->edesc->bmAttributes & UE_XFERTYPE); @@ -1906,6 +2002,8 @@ saf1761_otg_set_stall(struct usb_device *udev, /* should not happen */ return; } + USB_BUS_SPIN_LOCK(&sc->sc_bus); + /* select the correct endpoint */ SAF1761_WRITE_LE_4(sc, SOTG_EP_INDEX, (ep_no << SOTG_EP_INDEX_ENDP_INDEX_SHIFT) | @@ -1914,10 +2012,12 @@ saf1761_otg_set_stall(struct usb_device *udev, /* set stall */ SAF1761_WRITE_LE_4(sc, SOTG_CTRL_FUNC, SOTG_CTRL_FUNC_STALL); + + USB_BUS_SPIN_UNLOCK(&sc->sc_bus); } static void -saf1761_otg_clear_stall_sub(struct saf1761_otg_softc *sc, +saf1761_otg_clear_stall_sub_locked(struct saf1761_otg_softc *sc, uint8_t ep_no, uint8_t ep_type, uint8_t ep_dir) { if (ep_type == UE_CONTROL) { @@ -1959,14 +2059,18 @@ saf1761_otg_clear_stall(struct usb_device *udev, struct usb_endpoint *ep) /* get softc */ sc = SAF1761_OTG_BUS2SC(udev->bus); + USB_BUS_SPIN_LOCK(&sc->sc_bus); + /* get endpoint descriptor */ ed = ep->edesc; /* reset endpoint */ - saf1761_otg_clear_stall_sub(sc, + saf1761_otg_clear_stall_sub_locked(sc, (ed->bEndpointAddress & UE_ADDR), (ed->bmAttributes & UE_XFERTYPE), (ed->bEndpointAddress & (UE_DIR_IN | UE_DIR_OUT))); + + USB_BUS_SPIN_UNLOCK(&sc->sc_bus); } usb_error_t @@ -2218,7 +2322,10 @@ saf1761_otg_do_poll(struct usb_bus *bus) struct saf1761_otg_softc *sc = SAF1761_OTG_BUS2SC(bus); USB_BUS_LOCK(&sc->sc_bus); - saf1761_otg_interrupt_poll(sc); + USB_BUS_SPIN_LOCK(&sc->sc_bus); + saf1761_otg_interrupt_poll_locked(sc); + saf1761_otg_interrupt_complete_locked(sc); + USB_BUS_SPIN_UNLOCK(&sc->sc_bus); USB_BUS_UNLOCK(&sc->sc_bus); } @@ -3150,6 +3257,115 @@ saf1761_otg_set_hw_power_sleep(struct usb_bus *bus, uint32_t state) } } +static void +saf1761_otg_device_resume(struct usb_device *udev) +{ + struct saf1761_otg_softc *sc; + struct saf1761_otg_td *td; + struct usb_xfer *xfer; + uint8_t x; + + DPRINTF("\n"); + + if (udev->flags.usb_mode != USB_MODE_HOST) + return; + + sc = SAF1761_OTG_BUS2SC(udev->bus); + + USB_BUS_LOCK(&sc->sc_bus); + USB_BUS_SPIN_LOCK(&sc->sc_bus); + + TAILQ_FOREACH(xfer, &sc->sc_bus.intr_q.head, wait_entry) { + + if (xfer->xroot->udev != udev) + continue; + + td = xfer->td_transfer_cache; + if (td == NULL || td->channel >= SOTG_HOST_CHANNEL_MAX) + continue; + + switch (td->ep_type) { + case UE_INTERRUPT: + x = td->channel - 32; + sc->sc_host_intr_suspend_map &= ~(1 << x); + SAF1761_WRITE_LE_4(sc, SOTG_INT_PTD_SKIP_PTD, + (~sc->sc_host_intr_map) | sc->sc_host_intr_suspend_map); + break; + case UE_ISOCHRONOUS: + x = td->channel; + sc->sc_host_isoc_suspend_map &= ~(1 << x); + SAF1761_WRITE_LE_4(sc, SOTG_ISO_PTD_SKIP_PTD, + (~sc->sc_host_isoc_map) | sc->sc_host_isoc_suspend_map); + break; + default: + x = td->channel - 64; + sc->sc_host_async_suspend_map &= ~(1 << x); + SAF1761_WRITE_LE_4(sc, SOTG_ATL_PTD_SKIP_PTD, + (~sc->sc_host_async_map) | sc->sc_host_async_suspend_map); + break; + } + } + + USB_BUS_SPIN_UNLOCK(&sc->sc_bus); + USB_BUS_UNLOCK(&sc->sc_bus); + + /* poll all transfers again to restart resumed ones */ + saf1761_otg_do_poll(&sc->sc_bus); +} + +static void +saf1761_otg_device_suspend(struct usb_device *udev) +{ + struct saf1761_otg_softc *sc; + struct saf1761_otg_td *td; + struct usb_xfer *xfer; + uint8_t x; + + DPRINTF("\n"); + + if (udev->flags.usb_mode != USB_MODE_HOST) + return; + + sc = SAF1761_OTG_BUS2SC(udev->bus); + + USB_BUS_LOCK(&sc->sc_bus); + USB_BUS_SPIN_LOCK(&sc->sc_bus); + + TAILQ_FOREACH(xfer, &sc->sc_bus.intr_q.head, wait_entry) { + + if (xfer->xroot->udev != udev) + continue; + + td = xfer->td_transfer_cache; + if (td == NULL || td->channel >= SOTG_HOST_CHANNEL_MAX) + continue; + + switch (td->ep_type) { + case UE_INTERRUPT: + x = td->channel - 32; + sc->sc_host_intr_suspend_map |= (1 << x); + SAF1761_WRITE_LE_4(sc, SOTG_INT_PTD_SKIP_PTD, + (~sc->sc_host_intr_map) | sc->sc_host_intr_suspend_map); + break; + case UE_ISOCHRONOUS: + x = td->channel; + sc->sc_host_isoc_suspend_map |= (1 << x); + SAF1761_WRITE_LE_4(sc, SOTG_ISO_PTD_SKIP_PTD, + (~sc->sc_host_isoc_map) | sc->sc_host_isoc_suspend_map); + break; + default: + x = td->channel - 64; + sc->sc_host_async_suspend_map |= (1 << x); + SAF1761_WRITE_LE_4(sc, SOTG_ATL_PTD_SKIP_PTD, + (~sc->sc_host_async_map) | sc->sc_host_async_suspend_map); + break; + } + } + + USB_BUS_SPIN_UNLOCK(&sc->sc_bus); + USB_BUS_UNLOCK(&sc->sc_bus); +} + static const struct usb_bus_methods saf1761_otg_bus_methods = { .endpoint_init = &saf1761_otg_ep_init, @@ -3162,4 +3378,6 @@ static const struct usb_bus_methods saf1761_otg_bus_methods = .roothub_exec = &saf1761_otg_roothub_exec, .xfer_poll = &saf1761_otg_do_poll, .set_hw_power_sleep = saf1761_otg_set_hw_power_sleep, + .device_resume = &saf1761_otg_device_resume, + .device_suspend = &saf1761_otg_device_suspend, }; diff --git a/sys/dev/usb/controller/saf1761_otg.h b/sys/dev/usb/controller/saf1761_otg.h index de5e7c9743b9c..6d68e3e1bb233 100644 --- a/sys/dev/usb/controller/saf1761_otg.h +++ b/sys/dev/usb/controller/saf1761_otg.h @@ -140,11 +140,15 @@ struct saf1761_otg_softc { bus_space_handle_t sc_io_hdl; uint32_t sc_host_async_map; + uint32_t sc_host_async_suspend_map; uint32_t sc_host_intr_map; + uint32_t sc_host_intr_suspend_map; uint32_t sc_host_isoc_map; + uint32_t sc_host_isoc_suspend_map; uint32_t sc_intr_enable; /* enabled interrupts */ uint32_t sc_hw_mode; /* hardware mode */ uint32_t sc_interrupt_cfg; /* interrupt configuration */ + uint32_t sc_xfer_complete; uint32_t sc_bounce_buffer[1024 / 4]; @@ -162,6 +166,7 @@ struct saf1761_otg_softc { usb_error_t saf1761_otg_init(struct saf1761_otg_softc *sc); void saf1761_otg_uninit(struct saf1761_otg_softc *sc); -void saf1761_otg_interrupt(struct saf1761_otg_softc *sc); +driver_filter_t saf1761_otg_filter_interrupt; +driver_intr_t saf1761_otg_interrupt; #endif /* _SAF1761_OTG_H_ */ diff --git a/sys/dev/usb/controller/saf1761_otg_fdt.c b/sys/dev/usb/controller/saf1761_otg_fdt.c index 786976badd2f1..3e5b5da629ac9 100644 --- a/sys/dev/usb/controller/saf1761_otg_fdt.c +++ b/sys/dev/usb/controller/saf1761_otg_fdt.c @@ -210,8 +210,8 @@ saf1761_otg_fdt_attach(device_t dev) device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus); - err = bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE, - NULL, (driver_intr_t *)saf1761_otg_interrupt, sc, &sc->sc_intr_hdl); + err = bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_TTY | INTR_MPSAFE, + &saf1761_otg_filter_interrupt, &saf1761_otg_interrupt, sc, &sc->sc_intr_hdl); if (err) { sc->sc_intr_hdl = NULL; goto error; -- cgit v1.3 From 0b4dc07df8748d8db2c2feff89212409c1b38967 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Thu, 29 May 2014 10:46:09 +0000 Subject: Hook the ISP/SAF1761 driver into MIPS kernel builds. - Update FDT file for BERI DE4 boards. - Add needed kernel configuration keywords. - Rename module to saf1761otg so that the device unit number does not interfere with the hardware ID in dmesg. Sponsored by: DARPA, AFRL --- sys/boot/fdt/dts/mips/beripad-de4.dts | 11 +-------- sys/conf/files | 2 ++ sys/dev/usb/controller/saf1761_otg_fdt.c | 6 ++--- sys/dev/usb/controller/usb_controller.c | 2 +- sys/mips/conf/BERI_DE4_BASE | 9 +++++++ sys/modules/usb/Makefile | 6 ++++- sys/modules/usb/saf1761/Makefile | 42 -------------------------------- sys/modules/usb/saf1761otg/Makefile | 42 ++++++++++++++++++++++++++++++++ 8 files changed, 63 insertions(+), 57 deletions(-) delete mode 100644 sys/modules/usb/saf1761/Makefile create mode 100644 sys/modules/usb/saf1761otg/Makefile (limited to 'sys/dev/usb/controller') diff --git a/sys/boot/fdt/dts/mips/beripad-de4.dts b/sys/boot/fdt/dts/mips/beripad-de4.dts index 4a13622b00af5..e98f5e65945d5 100644 --- a/sys/boot/fdt/dts/mips/beripad-de4.dts +++ b/sys/boot/fdt/dts/mips/beripad-de4.dts @@ -222,7 +222,7 @@ }; usb@0x7f100000 { - compatible = "philips,isp1761"; + compatible = "nxp,usb-isp1761"; reg = <0x7f100000 0x40000 0x7f140000 0x4>; // IRQ 4 is DC, IRQ 5 is HC. @@ -253,14 +253,5 @@ sri-cambridge,fileio = "rw"; sri-cambridge,devname = "de4tempfan"; }; - - avgen@0x7f100000 { - compatible = "sri-cambridge,avgen"; - reg = <0x7f100000 0x40000>; - sri-cambridge,width = <4>; - sri-cambridge,fileio = "r"; - sri-cambridge,devname = "usbmem"; - }; - }; }; diff --git a/sys/conf/files b/sys/conf/files index 1c447e185221c..3dd585a173589 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -2314,6 +2314,8 @@ dev/usb/controller/uhci.c optional uhci dev/usb/controller/uhci_pci.c optional uhci pci dev/usb/controller/xhci.c optional xhci dev/usb/controller/xhci_pci.c optional xhci pci +dev/usb/controller/saf1761_otg.c optional saf1761otg +dev/usb/controller/saf1761_otg_fdt.c optional saf1761otg fdt dev/usb/controller/uss820dci.c optional uss820dci dev/usb/controller/uss820dci_atmelarm.c optional uss820dci at91rm9200 dev/usb/controller/usb_controller.c optional usb diff --git a/sys/dev/usb/controller/saf1761_otg_fdt.c b/sys/dev/usb/controller/saf1761_otg_fdt.c index 3e5b5da629ac9..1b18aea33c4db 100644 --- a/sys/dev/usb/controller/saf1761_otg_fdt.c +++ b/sys/dev/usb/controller/saf1761_otg_fdt.c @@ -93,15 +93,15 @@ static device_method_t saf1761_otg_methods[] = { }; static driver_t saf1761_otg_driver = { - .name = "saf1761", + .name = "saf1761otg", .methods = saf1761_otg_methods, .size = sizeof(struct saf1761_otg_softc), }; static devclass_t saf1761_otg_devclass; -DRIVER_MODULE(saf1761, simplebus, saf1761_otg_driver, saf1761_otg_devclass, 0, 0); -MODULE_DEPEND(saf1761, usb, 1, 1, 1); +DRIVER_MODULE(saf1761otg, simplebus, saf1761_otg_driver, saf1761_otg_devclass, 0, 0); +MODULE_DEPEND(saf1761otg, usb, 1, 1, 1); static int saf1761_otg_fdt_probe(device_t dev) diff --git a/sys/dev/usb/controller/usb_controller.c b/sys/dev/usb/controller/usb_controller.c index d62acd2e0665f..9f0e1162cb906 100644 --- a/sys/dev/usb/controller/usb_controller.c +++ b/sys/dev/usb/controller/usb_controller.c @@ -138,7 +138,7 @@ DRIVER_MODULE(usbus, octusb, usb_driver, usb_devclass, 0, 0); /* Dual Mode Drivers */ DRIVER_MODULE(usbus, dwcotg, usb_driver, usb_devclass, 0, 0); -DRIVER_MODULE(usbus, saf1761, usb_driver, usb_devclass, 0, 0); +DRIVER_MODULE(usbus, saf1761otg, usb_driver, usb_devclass, 0, 0); /*------------------------------------------------------------------------* * usb_probe diff --git a/sys/mips/conf/BERI_DE4_BASE b/sys/mips/conf/BERI_DE4_BASE index 801c8d30ada8e..d24a41f702eb5 100644 --- a/sys/mips/conf/BERI_DE4_BASE +++ b/sys/mips/conf/BERI_DE4_BASE @@ -40,3 +40,12 @@ device uart device miibus options DEVICE_POLLING +# +# USB support +# +#options USB_DEBUG +#options USB_REQ_DEBUG +#options USB_VERBOSE +device usb +device saf1761otg + diff --git a/sys/modules/usb/Makefile b/sys/modules/usb/Makefile index 6b3c9d4540e35..8dccf38749996 100644 --- a/sys/modules/usb/Makefile +++ b/sys/modules/usb/Makefile @@ -44,7 +44,7 @@ MAKE+=" DEBUG_FLAGS+=-DUSB_REQ_DEBUG" SUBDIR = usb SUBDIR += ${_dwc_otg} ehci ${_musb} ohci uhci xhci ${_uss820dci} ${_at91dci} \ - ${_atmegadci} ${_avr32dci} ${_rsu} ${_rsufw} + ${_atmegadci} ${_avr32dci} ${_rsu} ${_rsufw} ${_saf1761otg} SUBDIR += ${_rum} ${_run} ${_runfw} ${_uath} upgt usie ural ${_zyd} ${_urtw} SUBDIR += ${_urtwn} ${_urtwnfw} SUBDIR += atp uhid ukbd ums udbp ufm uep wsp @@ -96,4 +96,8 @@ _urtw= urtw _avr32dci= avr32dci .endif +.if ${MACHINE_CPUARCH} == "mips" +_saf1761otg= saf1761otg +.endif + .include diff --git a/sys/modules/usb/saf1761/Makefile b/sys/modules/usb/saf1761/Makefile deleted file mode 100644 index 5610a38737350..0000000000000 --- a/sys/modules/usb/saf1761/Makefile +++ /dev/null @@ -1,42 +0,0 @@ -# -# $FreeBSD$ -# -# Copyright (c) 2014 Hans Petter Selasky. All rights reserved. -# -# This software was developed by SRI International and the University of -# Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) -# ("CTSRD"), as part of the DARPA CRASH research programme. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# - -S= ${.CURDIR}/../../.. - -.PATH: $S/dev/usb/controller - -KMOD= saf1761 -SRCS= bus_if.h device_if.h usb_if.h \ - opt_bus.h opt_usb.h ofw_bus_if.h \ - saf1761_otg.c saf1761_otg_fdt.c \ - pci_if.h - -.include diff --git a/sys/modules/usb/saf1761otg/Makefile b/sys/modules/usb/saf1761otg/Makefile new file mode 100644 index 0000000000000..f9d0e6f9e1317 --- /dev/null +++ b/sys/modules/usb/saf1761otg/Makefile @@ -0,0 +1,42 @@ +# +# $FreeBSD$ +# +# Copyright (c) 2014 Hans Petter Selasky. All rights reserved. +# +# This software was developed by SRI International and the University of +# Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) +# ("CTSRD"), as part of the DARPA CRASH research programme. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# + +S= ${.CURDIR}/../../.. + +.PATH: $S/dev/usb/controller + +KMOD= saf1761otg +SRCS= bus_if.h device_if.h usb_if.h \ + opt_bus.h opt_usb.h ofw_bus_if.h \ + saf1761_otg.c saf1761_otg_fdt.c \ + pci_if.h + +.include -- cgit v1.3 From 2994bac4bafdb167149d9a05666ff6c7665e4a24 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Thu, 29 May 2014 11:11:19 +0000 Subject: Add some more spinlocks to protect the state of the USB transfer queue. Rename some functions to indicate locking requirements. MFC after: 1 week --- sys/dev/usb/controller/dwc_otg.c | 65 +++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 27 deletions(-) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/dwc_otg.c b/sys/dev/usb/controller/dwc_otg.c index f5af1f7a55f09..525261b46476e 100644 --- a/sys/dev/usb/controller/dwc_otg.c +++ b/sys/dev/usb/controller/dwc_otg.c @@ -142,7 +142,7 @@ static void dwc_otg_device_done(struct usb_xfer *, usb_error_t); static void dwc_otg_do_poll(struct usb_bus *); static void dwc_otg_standard_done(struct usb_xfer *); static void dwc_otg_root_intr(struct dwc_otg_softc *); -static void dwc_otg_interrupt_poll(struct dwc_otg_softc *); +static void dwc_otg_interrupt_poll_locked(struct dwc_otg_softc *); static void dwc_otg_host_channel_disable(struct dwc_otg_softc *, uint8_t); /* @@ -2245,7 +2245,7 @@ done: } static uint8_t -dwc_otg_xfer_do_complete(struct dwc_otg_softc *sc, struct usb_xfer *xfer) +dwc_otg_xfer_do_complete_locked(struct dwc_otg_softc *sc, struct usb_xfer *xfer) { struct dwc_otg_td *td; @@ -2349,7 +2349,7 @@ dwc_otg_host_channel_disable(struct dwc_otg_softc *sc, uint8_t x) } static uint8_t -dwc_otg_update_host_transfer_schedule(struct dwc_otg_softc *sc) +dwc_otg_update_host_transfer_schedule_locked(struct dwc_otg_softc *sc) { TAILQ_HEAD(, usb_xfer) head; struct usb_xfer *xfer; @@ -2519,7 +2519,7 @@ dwc_otg_update_host_transfer_schedule(struct dwc_otg_softc *sc) } static void -dwc_otg_interrupt_poll(struct dwc_otg_softc *sc) +dwc_otg_interrupt_poll_locked(struct dwc_otg_softc *sc) { struct usb_xfer *xfer; uint32_t temp; @@ -2620,19 +2620,19 @@ repeat: if (sc->sc_flags.status_device_mode == 0 && sc->sc_xfer_complete == 0) { /* update host transfer schedule, so that new transfers can be issued */ - if (dwc_otg_update_host_transfer_schedule(sc)) + if (dwc_otg_update_host_transfer_schedule_locked(sc)) goto repeat; } } static void -dwc_otg_interrupt_complete(struct dwc_otg_softc *sc) +dwc_otg_interrupt_complete_locked(struct dwc_otg_softc *sc) { struct usb_xfer *xfer; repeat: /* scan for completion events */ TAILQ_FOREACH(xfer, &sc->sc_bus.intr_q.head, wait_entry) { - if (dwc_otg_xfer_do_complete(sc, xfer)) + if (dwc_otg_xfer_do_complete_locked(sc, xfer)) goto repeat; } } @@ -2677,6 +2677,8 @@ dwc_otg_filter_interrupt(void *arg) int retval = FILTER_HANDLED; uint32_t status; + USB_BUS_SPIN_LOCK(&sc->sc_bus); + /* read and clear interrupt status */ status = DWC_OTG_READ_4(sc, DOTG_GINTSTS); @@ -2701,10 +2703,8 @@ dwc_otg_filter_interrupt(void *arg) } } - USB_BUS_SPIN_LOCK(&sc->sc_bus); - /* poll FIFOs, if any */ - dwc_otg_interrupt_poll(sc); + dwc_otg_interrupt_poll_locked(sc); if (sc->sc_xfer_complete != 0) retval = FILTER_SCHEDULE_THREAD; @@ -2901,15 +2901,14 @@ dwc_otg_interrupt(void *arg) sc->sc_xfer_complete = 0; /* complete FIFOs, if any */ - dwc_otg_interrupt_complete(sc); + dwc_otg_interrupt_complete_locked(sc); if (sc->sc_flags.status_device_mode == 0) { /* update host transfer schedule, so that new transfers can be issued */ - if (dwc_otg_update_host_transfer_schedule(sc)) - dwc_otg_interrupt_poll(sc); + if (dwc_otg_update_host_transfer_schedule_locked(sc)) + dwc_otg_interrupt_poll_locked(sc); } } - USB_BUS_SPIN_UNLOCK(&sc->sc_bus); USB_BUS_UNLOCK(&sc->sc_bus); } @@ -3274,12 +3273,13 @@ dwc_otg_start_standard_chain(struct usb_xfer *xfer) * endpoint interrupts. Else wait for SOF interrupt in host * mode. */ + USB_BUS_SPIN_LOCK(&sc->sc_bus); + if (sc->sc_flags.status_device_mode != 0) { dwc_otg_xfer_do_fifo(sc, xfer); - if (dwc_otg_xfer_do_complete(sc, xfer)) - return; + if (dwc_otg_xfer_do_complete_locked(sc, xfer)) + goto done; } - USB_BUS_SPIN_LOCK(&sc->sc_bus); /* put transfer on interrupt queue */ usbd_transfer_enqueue(&xfer->xroot->bus->intr_q, xfer); @@ -3456,6 +3456,8 @@ dwc_otg_device_done(struct usb_xfer *xfer, usb_error_t error) DPRINTFN(9, "xfer=%p, endpoint=%p, error=%d\n", xfer, xfer->endpoint, error); + USB_BUS_SPIN_LOCK(&sc->sc_bus); + if (xfer->flags_int.usb_mode == USB_MODE_DEVICE) { /* Interrupts are cleared by the interrupt handler */ } else { @@ -3470,6 +3472,8 @@ dwc_otg_device_done(struct usb_xfer *xfer, usb_error_t error) } /* dequeue transfer and start next transfer */ usbd_transfer_done(xfer, error); + + USB_BUS_SPIN_UNLOCK(&sc->sc_bus); } static void @@ -3497,6 +3501,8 @@ dwc_otg_set_stall(struct usb_device *udev, sc = DWC_OTG_BUS2SC(udev->bus); + USB_BUS_SPIN_LOCK(&sc->sc_bus); + /* get endpoint address */ ep_no = ep->edesc->bEndpointAddress; @@ -3525,14 +3531,15 @@ dwc_otg_set_stall(struct usb_device *udev, /* dump data */ dwc_otg_common_rx_ack(sc); /* poll interrupt */ - dwc_otg_interrupt_poll(sc); - dwc_otg_interrupt_complete(sc); + dwc_otg_interrupt_poll_locked(sc); + dwc_otg_interrupt_complete_locked(sc); } } + USB_BUS_SPIN_UNLOCK(&sc->sc_bus); } static void -dwc_otg_clear_stall_sub(struct dwc_otg_softc *sc, uint32_t mps, +dwc_otg_clear_stall_sub_locked(struct dwc_otg_softc *sc, uint32_t mps, uint8_t ep_no, uint8_t ep_type, uint8_t ep_dir) { uint32_t reg; @@ -3590,8 +3597,8 @@ dwc_otg_clear_stall_sub(struct dwc_otg_softc *sc, uint32_t mps, } /* poll interrupt */ - dwc_otg_interrupt_poll(sc); - dwc_otg_interrupt_complete(sc); + dwc_otg_interrupt_poll_locked(sc); + dwc_otg_interrupt_complete_locked(sc); } static void @@ -3612,15 +3619,19 @@ dwc_otg_clear_stall(struct usb_device *udev, struct usb_endpoint *ep) /* get softc */ sc = DWC_OTG_BUS2SC(udev->bus); + USB_BUS_SPIN_LOCK(&sc->sc_bus); + /* get endpoint descriptor */ ed = ep->edesc; /* reset endpoint */ - dwc_otg_clear_stall_sub(sc, + dwc_otg_clear_stall_sub_locked(sc, UGETW(ed->wMaxPacketSize), (ed->bEndpointAddress & UE_ADDR), (ed->bmAttributes & UE_XFERTYPE), (ed->bEndpointAddress & (UE_DIR_IN | UE_DIR_OUT))); + + USB_BUS_SPIN_UNLOCK(&sc->sc_bus); } static void @@ -3891,12 +3902,12 @@ dwc_otg_do_poll(struct usb_bus *bus) USB_BUS_LOCK(&sc->sc_bus); USB_BUS_SPIN_LOCK(&sc->sc_bus); - dwc_otg_interrupt_poll(sc); - dwc_otg_interrupt_complete(sc); + dwc_otg_interrupt_poll_locked(sc); + dwc_otg_interrupt_complete_locked(sc); if (sc->sc_flags.status_device_mode == 0) { /* update host transfer schedule, so that new transfers can be issued */ - if (dwc_otg_update_host_transfer_schedule(sc)) - dwc_otg_interrupt_poll(sc); + if (dwc_otg_update_host_transfer_schedule_locked(sc)) + dwc_otg_interrupt_poll_locked(sc); } USB_BUS_SPIN_UNLOCK(&sc->sc_bus); USB_BUS_UNLOCK(&sc->sc_bus); -- cgit v1.3 From 74c1f36628642437020cd7dc422b7a572f0c5ca0 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Fri, 30 May 2014 13:42:11 +0000 Subject: Add ISP/SAF1761 bootloader bus interface file. Sponsored by: DARPA, AFRL --- sys/dev/usb/controller/saf1761_otg_boot.c | 146 ++++++++++++++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 sys/dev/usb/controller/saf1761_otg_boot.c (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/saf1761_otg_boot.c b/sys/dev/usb/controller/saf1761_otg_boot.c new file mode 100644 index 0000000000000..ead8de30e5543 --- /dev/null +++ b/sys/dev/usb/controller/saf1761_otg_boot.c @@ -0,0 +1,146 @@ +/* $FreeBSD$ */ +/*- + * Copyright (c) 2014 Hans Petter Selasky + * All rights reserved. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include USB_GLOBAL_INCLUDE_FILE + +#include +#include + +static device_probe_t saf1761_otg_fdt_probe; +static device_attach_t saf1761_otg_fdt_attach; +static device_detach_t saf1761_otg_fdt_detach; + +static device_method_t saf1761_otg_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, saf1761_otg_fdt_probe), + DEVMETHOD(device_attach, saf1761_otg_fdt_attach), + DEVMETHOD(device_detach, saf1761_otg_fdt_detach), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + + DEVMETHOD_END +}; + +static driver_t saf1761_otg_driver = { + .name = "saf1761otg", + .methods = saf1761_otg_methods, + .size = sizeof(struct saf1761_otg_softc), +}; + +static devclass_t saf1761_otg_devclass; + +DRIVER_MODULE(saf1761otg, pci, saf1761_otg_driver, saf1761_otg_devclass, 0, 0); +MODULE_DEPEND(saf1761otg, usb, 1, 1, 1); + +static int +saf1761_otg_fdt_probe(device_t dev) +{ + if (device_get_unit(dev) != 0) + return (ENXIO); + + device_set_desc(dev, "ISP1761/SAF1761 DCI USB 2.0 Device Controller"); + + return (0); +} + +static int +saf1761_otg_fdt_attach(device_t dev) +{ + struct saf1761_otg_softc *sc = device_get_softc(dev); + int err; + + /* 32-bit data bus */ + sc->sc_hw_mode |= SOTG_HW_MODE_CTRL_DATA_BUS_WIDTH; + + /* initialise some bus fields */ + sc->sc_bus.parent = dev; + sc->sc_bus.devices = sc->sc_devices; + sc->sc_bus.devices_max = SOTG_MAX_DEVICES; + + /* get all DMA memory */ + if (usb_bus_mem_alloc_all(&sc->sc_bus, USB_GET_DMA_TAG(dev), NULL)) + return (ENOMEM); + + sc->sc_io_res = (void *)1; + sc->sc_io_tag = (void *)1; + sc->sc_io_hdl = (void *)USB_PCI_MEMORY_ADDRESS; + sc->sc_io_size = USB_PCI_MEMORY_SIZE; + + sc->sc_bus.bdev = device_add_child(dev, "usbus", -1); + if (sc->sc_bus.bdev == NULL) + goto error; + + device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus); + device_set_interrupt(dev, &saf1761_otg_filter_interrupt, &saf1761_otg_interrupt, sc); + + err = saf1761_otg_init(sc); + if (err) { + device_printf(dev, "Init failed\n"); + goto error; + } + err = device_probe_and_attach(sc->sc_bus.bdev); + if (err) { + device_printf(dev, "USB probe and attach failed\n"); + goto error; + } + return (0); + +error: + saf1761_otg_fdt_detach(dev); + return (ENXIO); +} + +static int +saf1761_otg_fdt_detach(device_t dev) +{ + struct saf1761_otg_softc *sc = device_get_softc(dev); + device_t bdev; + + if (sc->sc_bus.bdev) { + bdev = sc->sc_bus.bdev; + device_detach(bdev); + device_delete_child(dev, bdev); + } + + /* during module unload there are lots of children leftover */ + device_delete_children(dev); + + if (sc->sc_irq_res) { + /* + * Only call uninit() after init() + */ + saf1761_otg_uninit(sc); + } + usb_bus_mem_free_all(&sc->sc_bus, NULL); + + return (0); +} -- cgit v1.3 From 4be86ee126a8a10a10f9b2181bf3f35a9d44cda8 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Fri, 30 May 2014 16:44:03 +0000 Subject: It appears the ISP/SAF1761 sometimes is busy when reading the status word of the PTD and simply returns a value of zero. Retry a few times before giving up. Sponsored by: DARPA, AFRL --- sys/dev/usb/controller/saf1761_otg.c | 40 +++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 19 deletions(-) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/saf1761_otg.c b/sys/dev/usb/controller/saf1761_otg.c index 012f9fd101765..d837593ece02e 100644 --- a/sys/dev/usb/controller/saf1761_otg.c +++ b/sys/dev/usb/controller/saf1761_otg.c @@ -291,11 +291,23 @@ saf1761_host_channel_free(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t } static uint32_t -saf1761_peek_host_memory_le_4(struct saf1761_otg_softc *sc, uint32_t offset) +saf1761_peek_host_status_le_4(struct saf1761_otg_softc *sc, uint32_t offset) { - SAF1761_WRITE_LE_4(sc, SOTG_MEMORY_REG, offset); - SAF1761_90NS_DELAY(sc); /* read prefetch time is 90ns */ - return (SAF1761_READ_LE_4(sc, offset)); + uint32_t x = 0; + while (1) { + uint32_t retval; + + SAF1761_WRITE_LE_4(sc, SOTG_MEMORY_REG, offset); + SAF1761_90NS_DELAY(sc); /* read prefetch time is 90ns */ + retval = SAF1761_READ_LE_4(sc, offset); + if (retval != 0) + return (retval); + if (++x == 8) { + DPRINTF("STAUS is zero at offset 0x%x\n", offset); + break; + } + } + return (0); } static void @@ -415,9 +427,7 @@ saf1761_host_setup_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) if (td->channel < SOTG_HOST_CHANNEL_MAX) { pdt_addr = SOTG_PTD(td->channel); - status = saf1761_peek_host_memory_le_4(sc, pdt_addr + SOTG_PTD_DW3); - if (status == 0) - status = saf1761_peek_host_memory_le_4(sc, pdt_addr + SOTG_PTD_DW3); + status = saf1761_peek_host_status_le_4(sc, pdt_addr + SOTG_PTD_DW3); DPRINTFN(5, "STATUS=0x%08x\n", status); @@ -487,9 +497,7 @@ saf1761_host_bulk_data_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t pdt_addr = SOTG_PTD(td->channel); - status = saf1761_peek_host_memory_le_4(sc, pdt_addr + SOTG_PTD_DW3); - if (status == 0) - status = saf1761_peek_host_memory_le_4(sc, pdt_addr + SOTG_PTD_DW3); + status = saf1761_peek_host_status_le_4(sc, pdt_addr + SOTG_PTD_DW3); DPRINTFN(5, "STATUS=0x%08x\n", status); @@ -591,9 +599,7 @@ saf1761_host_bulk_data_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t pdt_addr = SOTG_PTD(td->channel); - status = saf1761_peek_host_memory_le_4(sc, pdt_addr + SOTG_PTD_DW3); - if (status == 0) - status = saf1761_peek_host_memory_le_4(sc, pdt_addr + SOTG_PTD_DW3); + status = saf1761_peek_host_status_le_4(sc, pdt_addr + SOTG_PTD_DW3); DPRINTFN(5, "STATUS=0x%08x\n", status); @@ -681,9 +687,7 @@ saf1761_host_intr_data_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t pdt_addr = SOTG_PTD(td->channel); - status = saf1761_peek_host_memory_le_4(sc, pdt_addr + SOTG_PTD_DW3); - if (status == 0) - status = saf1761_peek_host_memory_le_4(sc, pdt_addr + SOTG_PTD_DW3); + status = saf1761_peek_host_status_le_4(sc, pdt_addr + SOTG_PTD_DW3); DPRINTFN(5, "STATUS=0x%08x\n", status); @@ -788,9 +792,7 @@ saf1761_host_intr_data_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t pdt_addr = SOTG_PTD(td->channel); - status = saf1761_peek_host_memory_le_4(sc, pdt_addr + SOTG_PTD_DW3); - if (status == 0) - status = saf1761_peek_host_memory_le_4(sc, pdt_addr + SOTG_PTD_DW3); + status = saf1761_peek_host_status_le_4(sc, pdt_addr + SOTG_PTD_DW3); DPRINTFN(5, "STATUS=0x%08x\n", status); -- cgit v1.3 From dd5a01badc566fc3b5cd152c7558b08635b52dcc Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Sun, 1 Jun 2014 10:22:18 +0000 Subject: Add basic support for isochronous transfers in host mode to the ISP/SAF1761 driver. Sponsored by: DARPA, AFRL --- sys/dev/usb/controller/saf1761_otg.c | 270 +++++++++++++++++++++++++++++-- sys/dev/usb/controller/saf1761_otg_reg.h | 1 + 2 files changed, 260 insertions(+), 11 deletions(-) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/saf1761_otg.c b/sys/dev/usb/controller/saf1761_otg.c index d837593ece02e..b9ae393312945 100644 --- a/sys/dev/usb/controller/saf1761_otg.c +++ b/sys/dev/usb/controller/saf1761_otg.c @@ -112,6 +112,7 @@ SYSCTL_INT(_hw_usb_saf1761_otg, OID_AUTO, forcefs, CTLFLAG_RW, static const struct usb_bus_methods saf1761_otg_bus_methods; static const struct usb_pipe_methods saf1761_otg_non_isoc_methods; static const struct usb_pipe_methods saf1761_otg_device_isoc_methods; +static const struct usb_pipe_methods saf1761_otg_host_isoc_methods; static saf1761_otg_cmd_t saf1761_host_setup_tx; static saf1761_otg_cmd_t saf1761_host_bulk_data_rx; @@ -758,7 +759,8 @@ saf1761_host_intr_data_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t temp = SOTG_PTD_DW3_ACTIVE | (td->toggle << 25) | SOTG_PTD_DW3_CERR_3; SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW3, temp); - temp = (SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8) | (td->interval & 0xF8); + temp = (SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8) | + (td->interval & 0xF8); SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW2, temp); temp = td->dw1_value | (1 << 10) /* IN-PID */ | (td->ep_index >> 1); @@ -847,7 +849,8 @@ saf1761_host_intr_data_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *t temp = SOTG_PTD_DW3_ACTIVE | (td->toggle << 25) | SOTG_PTD_DW3_CERR_3; SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW3, temp); - temp = (SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8) | (td->interval & 0xF8); + temp = (SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8) | + (td->interval & 0xF8); SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW2, temp); temp = td->dw1_value | (0 << 10) /* OUT-PID */ | (td->ep_index >> 1); @@ -874,21 +877,160 @@ complete: static uint8_t saf1761_host_isoc_data_rx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) { + uint32_t pdt_addr; + uint32_t temp; + + if (td->channel < SOTG_HOST_CHANNEL_MAX) { + uint32_t status; + uint32_t count; + + pdt_addr = SOTG_PTD(td->channel); + + status = saf1761_peek_host_status_le_4(sc, pdt_addr + SOTG_PTD_DW3); + + DPRINTFN(5, "STATUS=0x%08x\n", status); + + if (status & SOTG_PTD_DW3_ACTIVE) { + goto busy; + } else if (status & SOTG_PTD_DW3_HALTED) { + goto complete; + } + count = (status & SOTG_PTD_DW3_XFER_COUNT); + + /* verify the packet byte count */ + if (count != td->max_packet_size) { + if (count < td->max_packet_size) { + /* we have a short packet */ + td->short_pkt = 1; + } else { + /* invalid USB packet */ + td->error_any = 1; + goto complete; + } + } + + /* verify the packet byte count */ + if (count > td->remainder) { + /* invalid USB packet */ + td->error_any = 1; + goto complete; + } + + saf1761_read_host_memory(sc, td, count); + goto complete; + } + + if (saf1761_host_channel_alloc(sc, td)) + goto busy; + + /* receive one more packet */ + + pdt_addr = SOTG_PTD(td->channel); + + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW7, 0); + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW6, 0); + + temp = (0xFC << td->uframe) & 0xFF; /* complete split */ + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW5, temp); + + temp = (1U << td->uframe); /* start split */ + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW4, temp); + + temp = SOTG_PTD_DW3_ACTIVE | SOTG_PTD_DW3_CERR_3; + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW3, temp); + + temp = (SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8); + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW2, temp); + + temp = td->dw1_value | (1 << 10) /* IN-PID */ | (td->ep_index >> 1); + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW1, temp); + + temp = (td->ep_index << 31) | (1 << 29) /* pkt-multiplier */ | + (td->max_packet_size << 18) /* wMaxPacketSize */ | + (td->max_packet_size << 3) /* transfer count */ | + SOTG_PTD_DW0_VALID; + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW0, temp); + /* activate PTD */ SAF1761_WRITE_LE_4(sc, SOTG_ISO_PTD_SKIP_PTD, (~sc->sc_host_isoc_map) | sc->sc_host_isoc_suspend_map); - +busy: return (1); /* busy */ +complete: + saf1761_host_channel_free(sc, td); + return (0); /* complete */ } static uint8_t saf1761_host_isoc_data_tx(struct saf1761_otg_softc *sc, struct saf1761_otg_td *td) { + uint32_t pdt_addr; + uint32_t temp; + uint32_t count; + + if (td->channel < SOTG_HOST_CHANNEL_MAX) { + uint32_t status; + + pdt_addr = SOTG_PTD(td->channel); + + status = saf1761_peek_host_status_le_4(sc, pdt_addr + SOTG_PTD_DW3); + + DPRINTFN(5, "STATUS=0x%08x\n", status); + + if (status & SOTG_PTD_DW3_ACTIVE) { + goto busy; + } else if (status & SOTG_PTD_DW3_HALTED) { + goto complete; + } + + goto complete; + } + if (saf1761_host_channel_alloc(sc, td)) + goto busy; + + count = td->max_packet_size; + if (td->remainder < count) { + /* we have a short packet */ + td->short_pkt = 1; + count = td->remainder; + } + + saf1761_write_host_memory(sc, td, count); + + /* send one more packet */ + + pdt_addr = SOTG_PTD(td->channel); + + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW7, 0); + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW6, 0); + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW5, 0); + + temp = (1U << td->uframe); /* start split */ + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW4, temp); + + temp = SOTG_PTD_DW3_ACTIVE | SOTG_PTD_DW3_CERR_3; + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW3, temp); + + temp = (SOTG_HC_MEMORY_ADDR(SOTG_DATA_ADDR(td->channel)) << 8); + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW2, temp); + + temp = td->dw1_value | (0 << 10) /* OUT-PID */ | (td->ep_index >> 1); + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW1, temp); + + temp = (td->ep_index << 31) | (1 << 29) /* pkt-multiplier */ | + (count << 18) /* wMaxPacketSize */ | + (count << 3) /* transfer count */ | + SOTG_PTD_DW0_VALID; + SAF1761_WRITE_LE_4(sc, pdt_addr + SOTG_PTD_DW0, temp); + /* activate PTD */ SAF1761_WRITE_LE_4(sc, SOTG_ISO_PTD_SKIP_PTD, (~sc->sc_host_isoc_map) | sc->sc_host_isoc_suspend_map); - +busy: return (1); /* busy */ +complete: + saf1761_host_channel_free(sc, td); + return (0); /* complete */ } static void @@ -2371,7 +2513,7 @@ static const struct usb_pipe_methods saf1761_otg_non_isoc_methods = }; /*------------------------------------------------------------------------* - * saf1761_otg isochronous support + * saf1761_otg device side isochronous support *------------------------------------------------------------------------*/ static void saf1761_otg_device_isoc_open(struct usb_xfer *xfer) @@ -2452,6 +2594,88 @@ static const struct usb_pipe_methods saf1761_otg_device_isoc_methods = .start = saf1761_otg_device_isoc_start, }; +/*------------------------------------------------------------------------* + * saf1761_otg host side isochronous support + *------------------------------------------------------------------------*/ +static void +saf1761_otg_host_isoc_open(struct usb_xfer *xfer) +{ + return; +} + +static void +saf1761_otg_host_isoc_close(struct usb_xfer *xfer) +{ + saf1761_otg_device_done(xfer, USB_ERR_CANCELLED); +} + +static void +saf1761_otg_host_isoc_enter(struct usb_xfer *xfer) +{ + struct saf1761_otg_softc *sc = SAF1761_OTG_BUS2SC(xfer->xroot->bus); + uint32_t temp; + uint32_t nframes; + + DPRINTFN(6, "xfer=%p next=%d nframes=%d\n", + xfer, xfer->endpoint->isoc_next, xfer->nframes); + + /* get the current frame index - we don't need the high bits */ + + nframes = (SAF1761_READ_LE_4(sc, SOTG_FRINDEX) & SOTG_FRINDEX_MASK) >> 3; + + /* + * check if the frame index is within the window where the + * frames will be inserted + */ + temp = (nframes - xfer->endpoint->isoc_next) & (SOTG_FRINDEX_MASK >> 3); + + if ((xfer->endpoint->is_synced == 0) || + (temp < xfer->nframes)) { + /* + * If there is data underflow or the pipe queue is + * empty we schedule the transfer a few frames ahead + * of the current frame position. Else two isochronous + * transfers might overlap. + */ + xfer->endpoint->isoc_next = (nframes + 3) & (SOTG_FRINDEX_MASK >> 3); + xfer->endpoint->is_synced = 1; + DPRINTFN(3, "start next=%d\n", xfer->endpoint->isoc_next); + } + /* + * compute how many milliseconds the insertion is ahead of the + * current frame position: + */ + temp = (xfer->endpoint->isoc_next - nframes) & (SOTG_FRINDEX_MASK >> 3); + + /* + * pre-compute when the isochronous transfer will be finished: + */ + xfer->isoc_time_complete = + usb_isoc_time_expand(&sc->sc_bus, nframes) + temp + + xfer->nframes; + + /* compute frame number for next insertion */ + xfer->endpoint->isoc_next += xfer->nframes; + + /* setup TDs */ + saf1761_otg_setup_standard_chain(xfer); +} + +static void +saf1761_otg_host_isoc_start(struct usb_xfer *xfer) +{ + /* start TD chain */ + saf1761_otg_start_standard_chain(xfer); +} + +static const struct usb_pipe_methods saf1761_otg_host_isoc_methods = +{ + .open = saf1761_otg_host_isoc_open, + .close = saf1761_otg_host_isoc_close, + .enter = saf1761_otg_host_isoc_enter, + .start = saf1761_otg_host_isoc_start, +}; + /*------------------------------------------------------------------------* * saf1761_otg root control support *------------------------------------------------------------------------* @@ -3174,7 +3398,17 @@ saf1761_otg_xfer_setup(struct usb_setup_params *parm) td->ep_index = ep_no; td->ep_type = ep_type; td->dw1_value = dw1; - td->uframe = 0; + if (ep_type == UE_ISOCHRONOUS) { + if (parm->udev->speed == USB_SPEED_HIGH) { + uint8_t uframe_index = (ntd - 1 - n); + uframe_index <<= usbd_xfer_get_fps_shift(xfer); + td->uframe = (uframe_index & 7); + } else { + td->uframe = 0; + } + } else { + td->uframe = 0; + } if (ep_type == UE_INTERRUPT) { if (xfer->interval > 32) td->interval = (32 / 2) << 3; @@ -3202,6 +3436,8 @@ static void saf1761_otg_ep_init(struct usb_device *udev, struct usb_endpoint_descriptor *edesc, struct usb_endpoint *ep) { + uint16_t mps; + DPRINTFN(2, "endpoint=%p, addr=%d, endpt=%d, mode=%d\n", ep, udev->address, edesc->bEndpointAddress, udev->flags.usb_mode); @@ -3211,6 +3447,20 @@ saf1761_otg_ep_init(struct usb_device *udev, struct usb_endpoint_descriptor *ede return; } + /* Verify wMaxPacketSize */ + mps = UGETW(edesc->wMaxPacketSize); + if (udev->speed == USB_SPEED_HIGH) { + if ((mps >> 11) & 3) { + DPRINTF("A packet multiplier different from " + "1 is not supported\n"); + return; + } + } + if (mps > SOTG_HS_MAX_PACKET_SIZE) { + DPRINTF("Packet size %d bigger than %d\n", + (int)mps, SOTG_HS_MAX_PACKET_SIZE); + return; + } if (udev->flags.usb_mode == USB_MODE_DEVICE) { if (udev->speed != USB_SPEED_FULL && udev->speed != USB_SPEED_HIGH) { @@ -3227,13 +3477,11 @@ saf1761_otg_ep_init(struct usb_device *udev, struct usb_endpoint_descriptor *ede } } else { switch (edesc->bmAttributes & UE_XFERTYPE) { - case UE_CONTROL: - case UE_BULK: - case UE_INTERRUPT: - ep->methods = &saf1761_otg_non_isoc_methods; + case UE_ISOCHRONOUS: + ep->methods = &saf1761_otg_host_isoc_methods; break; default: - /* TODO */ + ep->methods = &saf1761_otg_non_isoc_methods; break; } } diff --git a/sys/dev/usb/controller/saf1761_otg_reg.h b/sys/dev/usb/controller/saf1761_otg_reg.h index 74346e557ce18..d73718f20ddcf 100644 --- a/sys/dev/usb/controller/saf1761_otg_reg.h +++ b/sys/dev/usb/controller/saf1761_otg_reg.h @@ -183,6 +183,7 @@ /* Host controller specific registers */ #define SOTG_FRINDEX 0x002c +#define SOTG_FRINDEX_MASK 0x3fff #define SOTG_CONFIGFLAG 0x0060 #define SOTG_CONFIGFLAG_ENABLE (1 << 0) #define SOTG_PORTSC1 0x0064 -- cgit v1.3 From a31f80290e314ab67a347d4cb772a5d3e85cb56b Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Wed, 4 Jun 2014 10:29:01 +0000 Subject: The external USB HUB in the RPI-B rejects control endpoint traffic using the BULK endpoint type, while other USB HUBs do not. Disable endpoint type workaround for TT traffic. MFC after: 3 days --- sys/dev/usb/controller/dwc_otg.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/dwc_otg.c b/sys/dev/usb/controller/dwc_otg.c index 525261b46476e..04055ace92014 100644 --- a/sys/dev/usb/controller/dwc_otg.c +++ b/sys/dev/usb/controller/dwc_otg.c @@ -3161,11 +3161,20 @@ dwc_otg_setup_standard_chain(struct usb_xfer *xfer) (xfer->max_packet_size << HCCHAR_MPS_SHIFT) | HCCHAR_CHENA; - /* XXX stability hack - possible HW issue */ - if (td->ep_type == UE_CONTROL) + /* + * XXX stability hack - possible HW issue + * + * Disable workaround when using a transaction + * translator, hence some TTs reject control endpoint + * traffic using BULK endpoint type: + */ + if (td->ep_type == UE_CONTROL && + (xfer->xroot->udev->speed == USB_SPEED_HIGH || + xfer->xroot->udev->parent_hs_hub == NULL)) { hcchar |= (UE_BULK << HCCHAR_EPTYPE_SHIFT); - else + } else { hcchar |= (td->ep_type << HCCHAR_EPTYPE_SHIFT); + } if (usbd_get_speed(xfer->xroot->udev) == USB_SPEED_LOW) hcchar |= HCCHAR_LSPDDEV; -- cgit v1.3 From 08aa4c94b80fd64f51bad7ed72ad0c56edd2afa5 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Thu, 5 Jun 2014 18:17:40 +0000 Subject: Try to fix DWC OTG regression issues with full and low speed devices: - Remove double buffering interrupt and isochronous traffic via the transaction translator. It can be avoided because the DWC OTG will always delay the start split transactions for interrupt and isochronous traffic, but will not delay the complete split transactions, if we set the odd frame bit correctly. - Need to check the transfer cache field in the device done function to be sure all allocated channels are freed and not the transfer first one. This seems to resolve the control endpoint transfer type quirk which is now removed. - Make sure any received data upon TX is dumped else RX path will stop. - Transmit isochronous data before receiving isochronous data as a means to optimise the TT schedule. - Implement a simple TT bandwidth scheduler. - Cleanup use of old "td->error" variable. - On interrupt IN traffic via the transaction translator we simply ignore missed transfer opportunities and silently retry the transaction upon next available time slot. MFC after: 3 days --- sys/dev/usb/controller/dwc_otg.c | 506 ++++++++++++++++++++++----------------- sys/dev/usb/controller/dwc_otg.h | 12 +- 2 files changed, 290 insertions(+), 228 deletions(-) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/dwc_otg.c b/sys/dev/usb/controller/dwc_otg.c index 04055ace92014..c96b308335295 100644 --- a/sys/dev/usb/controller/dwc_otg.c +++ b/sys/dev/usb/controller/dwc_otg.c @@ -592,13 +592,13 @@ dwc_otg_clear_hcint(struct dwc_otg_softc *sc, uint8_t x) } static uint8_t -dwc_otg_host_channel_alloc(struct dwc_otg_softc *sc, struct dwc_otg_td *td, uint8_t which, uint8_t is_out) +dwc_otg_host_channel_alloc(struct dwc_otg_softc *sc, struct dwc_otg_td *td, uint8_t is_out) { uint32_t tx_p_size; uint32_t tx_np_size; uint8_t x; - if (td->channel[which] < DWC_OTG_MAX_CHANNELS) + if (td->channel < DWC_OTG_MAX_CHANNELS) return (0); /* already allocated */ /* check if device is suspended */ @@ -658,7 +658,7 @@ dwc_otg_host_channel_alloc(struct dwc_otg_softc *sc, struct dwc_otg_td *td, uint sc->sc_active_rx_ep |= (1 << x); /* set channel */ - td->channel[which] = x; + td->channel = x; return (0); /* allocated */ } @@ -668,16 +668,16 @@ dwc_otg_host_channel_alloc(struct dwc_otg_softc *sc, struct dwc_otg_td *td, uint } static void -dwc_otg_host_channel_free(struct dwc_otg_softc *sc, struct dwc_otg_td *td, uint8_t which) +dwc_otg_host_channel_free(struct dwc_otg_softc *sc, struct dwc_otg_td *td) { uint8_t x; - if (td->channel[which] >= DWC_OTG_MAX_CHANNELS) + if (td->channel >= DWC_OTG_MAX_CHANNELS) return; /* already freed */ /* free channel */ - x = td->channel[which]; - td->channel[which] = DWC_OTG_MAX_CHANNELS; + x = td->channel; + td->channel = DWC_OTG_MAX_CHANNELS; DPRINTF("CH=%d\n", x); @@ -707,6 +707,18 @@ dwc_otg_host_channel_free(struct dwc_otg_softc *sc, struct dwc_otg_td *td, uint8 sc->sc_active_rx_ep &= ~(1 << x); } +static void +dwc_otg_host_dump_rx(struct dwc_otg_softc *sc, struct dwc_otg_td *td) +{ + /* dump any pending messages */ + if (sc->sc_last_rx_status != 0) { + if (td->channel < DWC_OTG_MAX_CHANNELS && + td->channel == GRXSTSRD_CHNUM_GET(sc->sc_last_rx_status)) { + dwc_otg_common_rx_ack(sc); + } + } +} + static uint8_t dwc_otg_host_setup_tx(struct dwc_otg_softc *sc, struct dwc_otg_td *td) { @@ -715,13 +727,15 @@ dwc_otg_host_setup_tx(struct dwc_otg_softc *sc, struct dwc_otg_td *td) uint32_t hcchar; uint8_t delta; - if (td->channel[0] < DWC_OTG_MAX_CHANNELS) { - hcint = sc->sc_chan_state[td->channel[0]].hcint; + dwc_otg_host_dump_rx(sc, td); + + if (td->channel < DWC_OTG_MAX_CHANNELS) { + hcint = sc->sc_chan_state[td->channel].hcint; DPRINTF("CH=%d ST=%d HCINT=0x%08x HCCHAR=0x%08x HCTSIZ=0x%08x\n", - td->channel[0], td->state, hcint, - DWC_OTG_READ_4(sc, DOTG_HCCHAR(td->channel[0])), - DWC_OTG_READ_4(sc, DOTG_HCTSIZ(td->channel[0]))); + td->channel, td->state, hcint, + DWC_OTG_READ_4(sc, DOTG_HCCHAR(td->channel)), + DWC_OTG_READ_4(sc, DOTG_HCTSIZ(td->channel))); } else { hcint = 0; goto check_state; @@ -731,12 +745,12 @@ dwc_otg_host_setup_tx(struct dwc_otg_softc *sc, struct dwc_otg_td *td) HCINT_ACK | HCINT_NYET)) { /* give success bits priority over failure bits */ } else if (hcint & HCINT_STALL) { - DPRINTF("CH=%d STALL\n", td->channel[0]); + DPRINTF("CH=%d STALL\n", td->channel); td->error_stall = 1; td->error_any = 1; goto complete; } else if (hcint & HCINT_ERRORS) { - DPRINTF("CH=%d ERROR\n", td->channel[0]); + DPRINTF("CH=%d ERROR\n", td->channel); td->errcnt++; if (td->hcsplt != 0 || td->errcnt >= 3) { td->error_any = 1; @@ -804,7 +818,7 @@ check_state: send_pkt: /* free existing channel, if any */ - dwc_otg_host_channel_free(sc, td, 0); + dwc_otg_host_channel_free(sc, td); if (sizeof(req) != td->remainder) { td->error_any = 1; @@ -827,7 +841,7 @@ send_pkt: } /* allocate a new channel */ - if (dwc_otg_host_channel_alloc(sc, td, 0, 1)) { + if (dwc_otg_host_channel_alloc(sc, td, 1)) { td->state = DWC_CHAN_ST_START; goto busy; } @@ -841,23 +855,29 @@ send_pkt: usbd_copy_out(td->pc, 0, &req, sizeof(req)); - DWC_OTG_WRITE_4(sc, DOTG_HCTSIZ(td->channel[0]), + DWC_OTG_WRITE_4(sc, DOTG_HCTSIZ(td->channel), (sizeof(req) << HCTSIZ_XFERSIZE_SHIFT) | (1 << HCTSIZ_PKTCNT_SHIFT) | (HCTSIZ_PID_SETUP << HCTSIZ_PID_SHIFT)); - DWC_OTG_WRITE_4(sc, DOTG_HCSPLT(td->channel[0]), td->hcsplt); + DWC_OTG_WRITE_4(sc, DOTG_HCSPLT(td->channel), td->hcsplt); hcchar = td->hcchar; hcchar &= ~(HCCHAR_EPDIR_IN | HCCHAR_EPTYPE_MASK); hcchar |= UE_CONTROL << HCCHAR_EPTYPE_SHIFT; /* must enable channel before writing data to FIFO */ - DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(td->channel[0]), hcchar); + DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(td->channel), hcchar); /* transfer data into FIFO */ bus_space_write_region_4(sc->sc_io_tag, sc->sc_io_hdl, - DOTG_DFIFO(td->channel[0]), (uint32_t *)&req, sizeof(req) / 4); + DOTG_DFIFO(td->channel), (uint32_t *)&req, sizeof(req) / 4); + + /* wait until next slot before trying complete split */ + if (td->ep_type == UE_INTERRUPT || td->ep_type == UE_ISOCHRONOUS) + td->tt_complete_slot = sc->sc_last_frame_num + 2; + else + td->tt_complete_slot = sc->sc_last_frame_num + 1; /* store number of bytes transmitted */ td->tx_bytes = sizeof(req); @@ -865,7 +885,7 @@ send_pkt: send_cpkt: /* free existing channel, if any */ - dwc_otg_host_channel_free(sc, td, 0); + dwc_otg_host_channel_free(sc, td); delta = td->tt_complete_slot - sc->sc_last_frame_num - 1; if (td->tt_scheduled == 0 || delta < DWC_OTG_TT_SLOT_MAX) { @@ -880,34 +900,34 @@ send_cpkt: goto complete; } /* allocate a new channel */ - if (dwc_otg_host_channel_alloc(sc, td, 0, 0)) { + if (dwc_otg_host_channel_alloc(sc, td, 0)) { td->state = DWC_CHAN_ST_WAIT_C_PKT; goto busy; } - /* wait until next slot before trying again */ - td->tt_complete_slot++; + /* wait until next slot before trying complete split */ + td->tt_complete_slot = sc->sc_last_frame_num + 1; td->hcsplt |= HCSPLT_COMPSPLT; td->state = DWC_CHAN_ST_WAIT_C_ANE; - DWC_OTG_WRITE_4(sc, DOTG_HCTSIZ(td->channel[0]), + DWC_OTG_WRITE_4(sc, DOTG_HCTSIZ(td->channel), (HCTSIZ_PID_SETUP << HCTSIZ_PID_SHIFT)); - DWC_OTG_WRITE_4(sc, DOTG_HCSPLT(td->channel[0]), td->hcsplt); + DWC_OTG_WRITE_4(sc, DOTG_HCSPLT(td->channel), td->hcsplt); hcchar = td->hcchar; hcchar &= ~(HCCHAR_EPDIR_IN | HCCHAR_EPTYPE_MASK); hcchar |= UE_CONTROL << HCCHAR_EPTYPE_SHIFT; /* must enable channel before writing data to FIFO */ - DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(td->channel[0]), hcchar); + DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(td->channel), hcchar); busy: return (1); /* busy */ complete: - dwc_otg_host_channel_free(sc, td, 0); + dwc_otg_host_channel_free(sc, td); return (0); /* complete */ } @@ -1085,55 +1105,21 @@ busy: } static uint8_t -dwc_otg_host_data_rx(struct dwc_otg_softc *sc, struct dwc_otg_td *td) +dwc_otg_host_data_rx_sub(struct dwc_otg_softc *sc, struct dwc_otg_td *td) { - uint32_t hcint; - uint32_t hcchar; uint32_t count; - uint8_t delta; uint8_t channel; - channel = td->channel[td->tt_channel_tog]; - - if (channel < DWC_OTG_MAX_CHANNELS) { - hcint = sc->sc_chan_state[channel].hcint; - - DPRINTF("CH=%d ST=%d HCINT=0x%08x HCCHAR=0x%08x HCTSIZ=0x%08x\n", - channel, td->state, hcint, - DWC_OTG_READ_4(sc, DOTG_HCCHAR(channel)), - DWC_OTG_READ_4(sc, DOTG_HCTSIZ(channel))); - } else { - hcint = 0; - goto check_state; - } - - /* check interrupt bits */ - - if (hcint & (HCINT_RETRY | - HCINT_ACK | HCINT_NYET)) { - /* give success bits priority over failure bits */ - } else if (hcint & HCINT_STALL) { - DPRINTF("CH=%d STALL\n", channel); - td->error_stall = 1; - td->error_any = 1; - goto complete; - } else if (hcint & HCINT_ERRORS) { - DPRINTF("CH=%d ERROR\n", channel); - td->errcnt++; - if (td->hcsplt != 0 || td->errcnt >= 3) { - if (td->ep_type != UE_ISOCHRONOUS) { - td->error_any = 1; - goto complete; - } - } - } - /* check endpoint status */ if (sc->sc_last_rx_status == 0) - goto check_state; + goto busy; + + channel = td->channel; + if (channel >= DWC_OTG_MAX_CHANNELS) + goto busy; if (GRXSTSRD_CHNUM_GET(sc->sc_last_rx_status) != channel) - goto check_state; + goto busy; switch (sc->sc_last_rx_status & GRXSTSRD_PKTSTS_MASK) { case GRXSTSRH_IN_DATA: @@ -1141,7 +1127,7 @@ dwc_otg_host_data_rx(struct dwc_otg_softc *sc, struct dwc_otg_td *td) DPRINTF("DATA ST=%d STATUS=0x%08x\n", (int)td->state, (int)sc->sc_last_rx_status); - if (hcint & HCINT_SOFTWARE_ONLY) { + if (sc->sc_chan_state[channel].hcint & HCINT_SOFTWARE_ONLY) { /* * When using SPLIT transactions on interrupt * endpoints, sometimes data occurs twice. @@ -1203,21 +1189,71 @@ dwc_otg_host_data_rx(struct dwc_otg_softc *sc, struct dwc_otg_td *td) td->remainder -= count; td->offset += count; - hcint |= HCINT_SOFTWARE_ONLY; - sc->sc_chan_state[channel].hcint = hcint; + sc->sc_chan_state[channel].hcint |= HCINT_SOFTWARE_ONLY; break; - default: break; } /* release FIFO */ dwc_otg_common_rx_ack(sc); +busy: + return (0); +complete: + return (1); +} -check_state: - if (hcint & (HCINT_ERRORS | HCINT_RETRY | - HCINT_ACK | HCINT_NYET)) { - if (!(hcint & HCINT_ERRORS)) - td->errcnt = 0; +static uint8_t +dwc_otg_host_data_rx(struct dwc_otg_softc *sc, struct dwc_otg_td *td) +{ + uint32_t hcint; + uint32_t hcchar; + uint8_t delta; + uint8_t channel; + + channel = td->channel; + + if (channel < DWC_OTG_MAX_CHANNELS) { + hcint = sc->sc_chan_state[channel].hcint; + + DPRINTF("CH=%d ST=%d HCINT=0x%08x HCCHAR=0x%08x HCTSIZ=0x%08x\n", + channel, td->state, hcint, + DWC_OTG_READ_4(sc, DOTG_HCCHAR(channel)), + DWC_OTG_READ_4(sc, DOTG_HCTSIZ(channel))); + + /* check interrupt bits */ + if (hcint & (HCINT_RETRY | + HCINT_ACK | HCINT_NYET)) { + /* give success bits priority over failure bits */ + } else if (hcint & HCINT_STALL) { + DPRINTF("CH=%d STALL\n", channel); + td->error_stall = 1; + td->error_any = 1; + goto complete; + } else if (hcint & HCINT_ERRORS) { + DPRINTF("CH=%d ERROR\n", channel); + td->errcnt++; + if (td->hcsplt != 0 || td->errcnt >= 3) { + if (td->ep_type != UE_ISOCHRONOUS) { + td->error_any = 1; + goto complete; + } + } + } + + /* check channels for data, if any */ + if (dwc_otg_host_data_rx_sub(sc, td)) + goto complete; + + /* refresh interrupt status */ + hcint = sc->sc_chan_state[channel].hcint; + + if (hcint & (HCINT_ERRORS | HCINT_RETRY | + HCINT_ACK | HCINT_NYET)) { + if (!(hcint & HCINT_ERRORS)) + td->errcnt = 0; + } + } else { + hcint = 0; } switch (td->state) { @@ -1306,7 +1342,7 @@ check_state: receive_pkt: /* free existing channel, if any */ - dwc_otg_host_channel_free(sc, td, td->tt_channel_tog); + dwc_otg_host_channel_free(sc, td); if (td->hcsplt != 0) { delta = td->tt_complete_slot - sc->sc_last_frame_num - 1; @@ -1316,9 +1352,18 @@ receive_pkt: } delta = sc->sc_last_frame_num - td->tt_start_slot; if (delta > DWC_OTG_TT_SLOT_MAX) { - /* we missed the service interval */ - if (td->ep_type != UE_ISOCHRONOUS) + if (td->ep_type == UE_INTERRUPT) { + /* + * Happens from time to time avoid + * posting an error, instead retry + * the start split packet: + */ + td->tt_scheduled = 0; + goto receive_spkt; + } else if (td->ep_type != UE_ISOCHRONOUS) { + /* we missed the service interval */ td->error_any = 1; + } goto complete; } /* complete split */ @@ -1330,12 +1375,12 @@ receive_pkt: } /* allocate a new channel */ - if (dwc_otg_host_channel_alloc(sc, td, td->tt_channel_tog, 0)) { + if (dwc_otg_host_channel_alloc(sc, td, 0)) { td->state = DWC_CHAN_ST_WAIT_C_PKT; goto busy; } - channel = td->channel[td->tt_channel_tog]; + channel = td->channel; /* set toggle, if any */ if (td->set_toggle) { @@ -1357,46 +1402,23 @@ receive_pkt: hcchar = td->hcchar; hcchar |= HCCHAR_EPDIR_IN; - /* check if other channel is allocated */ - if (td->channel[td->tt_channel_tog ^ 1] < DWC_OTG_MAX_CHANNELS) { - /* second - receive after next SOF event */ - if ((sc->sc_last_frame_num & 1) != 0) - hcchar |= HCCHAR_ODDFRM; - else - hcchar &= ~HCCHAR_ODDFRM; - - /* other channel is next */ - td->tt_channel_tog ^= 1; - td->tt_complete_slot++; + /* receive complete split ASAP */ + if ((sc->sc_last_frame_num & 1) != 0) + hcchar |= HCCHAR_ODDFRM; + else + hcchar &= ~HCCHAR_ODDFRM; - /* must enable channel before data can be received */ - DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(channel), hcchar); - } else { - /* first - receive after second next SOF event */ - if ((sc->sc_last_frame_num & 1) == 0) - hcchar |= HCCHAR_ODDFRM; - else - hcchar &= ~HCCHAR_ODDFRM; + /* must enable channel before data can be received */ + DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(channel), hcchar); - /* must enable channel before data can be received */ - DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(channel), hcchar); + /* wait until next slot before trying complete split */ + td->tt_complete_slot = sc->sc_last_frame_num + 1; - if (td->hcsplt != 0) { - if (td->ep_type == UE_ISOCHRONOUS || td->ep_type == UE_INTERRUPT) { - /* allocate a second channel */ - td->tt_channel_tog ^= 1; - goto receive_pkt; - } else { - td->tt_complete_slot++; - } - } - } goto busy; receive_spkt: /* free existing channel(s), if any */ - dwc_otg_host_channel_free(sc, td, 0); - dwc_otg_host_channel_free(sc, td, 1); + dwc_otg_host_channel_free(sc, td); delta = td->tt_start_slot - sc->sc_last_frame_num - 1; if (td->tt_scheduled == 0 || delta < DWC_OTG_TT_SLOT_MAX) { @@ -1412,19 +1434,16 @@ receive_spkt: } /* allocate a new channel */ - if (dwc_otg_host_channel_alloc(sc, td, 0, 0)) { + if (dwc_otg_host_channel_alloc(sc, td, 0)) { td->state = DWC_CHAN_ST_START; goto busy; } - channel = td->channel[0]; + channel = td->channel; td->hcsplt &= ~HCSPLT_COMPSPLT; td->state = DWC_CHAN_ST_WAIT_S_ANE; - /* reset channel toggle */ - td->tt_channel_tog = 0; - /* receive one packet */ DWC_OTG_WRITE_4(sc, DOTG_HCTSIZ(channel), (HCTSIZ_PID_DATA0 << HCTSIZ_PID_SHIFT)); @@ -1440,14 +1459,19 @@ receive_spkt: hcchar = td->hcchar; hcchar |= HCCHAR_EPDIR_IN; + /* wait until next slot before trying complete split */ + if (td->ep_type == UE_INTERRUPT || td->ep_type == UE_ISOCHRONOUS) + td->tt_complete_slot = sc->sc_last_frame_num + 2; + else + td->tt_complete_slot = sc->sc_last_frame_num + 1; + /* must enable channel before data can be received */ DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(channel), hcchar); busy: return (1); /* busy */ complete: - dwc_otg_host_channel_free(sc, td, 0); - dwc_otg_host_channel_free(sc, td, 1); + dwc_otg_host_channel_free(sc, td); return (0); /* complete */ } @@ -1569,7 +1593,9 @@ dwc_otg_host_data_tx(struct dwc_otg_softc *sc, struct dwc_otg_td *td) uint8_t delta; uint8_t channel; - channel = td->channel[td->tt_channel_tog]; + dwc_otg_host_dump_rx(sc, td); + + channel = td->channel; if (channel < DWC_OTG_MAX_CHANNELS) { hcint = sc->sc_chan_state[channel].hcint; @@ -1578,36 +1604,34 @@ dwc_otg_host_data_tx(struct dwc_otg_softc *sc, struct dwc_otg_td *td) channel, td->state, hcint, DWC_OTG_READ_4(sc, DOTG_HCCHAR(channel)), DWC_OTG_READ_4(sc, DOTG_HCTSIZ(channel))); - } else { - hcint = 0; - goto check_state; - } - if (hcint & (HCINT_RETRY | - HCINT_ACK | HCINT_NYET)) { - /* give success bits priority over failure bits */ - } else if (hcint & HCINT_STALL) { - DPRINTF("CH=%d STALL\n", channel); - td->error_stall = 1; - td->error_any = 1; - goto complete; - } else if (hcint & HCINT_ERRORS) { - DPRINTF("CH=%d ERROR\n", channel); - td->errcnt++; - if (td->hcsplt != 0 || td->errcnt >= 3) { + if (hcint & (HCINT_RETRY | + HCINT_ACK | HCINT_NYET)) { + /* give success bits priority over failure bits */ + } else if (hcint & HCINT_STALL) { + DPRINTF("CH=%d STALL\n", channel); + td->error_stall = 1; td->error_any = 1; goto complete; + } else if (hcint & HCINT_ERRORS) { + DPRINTF("CH=%d ERROR\n", channel); + td->errcnt++; + if (td->hcsplt != 0 || td->errcnt >= 3) { + td->error_any = 1; + goto complete; + } } - } - if (hcint & (HCINT_ERRORS | HCINT_RETRY | - HCINT_ACK | HCINT_NYET)) { + if (hcint & (HCINT_ERRORS | HCINT_RETRY | + HCINT_ACK | HCINT_NYET)) { - if (!(hcint & HCINT_ERRORS)) - td->errcnt = 0; + if (!(hcint & HCINT_ERRORS)) + td->errcnt = 0; + } + } else { + hcint = 0; } -check_state: switch (td->state) { case DWC_CHAN_ST_START: goto send_pkt; @@ -1694,16 +1718,16 @@ check_state: td->tt_xactpos++; /* free existing channel, if any */ - dwc_otg_host_channel_free(sc, td, td->tt_channel_tog); + dwc_otg_host_channel_free(sc, td); td->state = DWC_CHAN_ST_TX_PKT_ISOC; /* FALLTHROUGH */ case DWC_CHAN_ST_TX_PKT_ISOC: - if (dwc_otg_host_channel_alloc(sc, td, 0, 1)) + if (dwc_otg_host_channel_alloc(sc, td, 1)) break; - channel = td->channel[0]; + channel = td->channel; goto send_isoc_pkt; default: break; @@ -1712,8 +1736,7 @@ check_state: send_pkt: /* free existing channel(s), if any */ - dwc_otg_host_channel_free(sc, td, 0); - dwc_otg_host_channel_free(sc, td, 1); + dwc_otg_host_channel_free(sc, td); if (td->hcsplt != 0) { delta = td->tt_start_slot - sc->sc_last_frame_num - 1; @@ -1734,12 +1757,12 @@ send_pkt: } /* allocate a new channel */ - if (dwc_otg_host_channel_alloc(sc, td, 0, 1)) { + if (dwc_otg_host_channel_alloc(sc, td, 1)) { td->state = DWC_CHAN_ST_START; goto busy; } - channel = td->channel[0]; + channel = td->channel; /* set toggle, if any */ if (td->set_toggle) { @@ -1757,7 +1780,7 @@ send_isoc_pkt: count = td->remainder; if (count > HCSPLT_XACTLEN_BURST) { DPRINTF("TT overflow\n"); - td->error = 1; + td->error_any = 1; goto complete; } /* Update transaction position */ @@ -1883,7 +1906,7 @@ send_isoc_pkt: send_cpkt: /* free existing channel, if any */ - dwc_otg_host_channel_free(sc, td, td->tt_channel_tog); + dwc_otg_host_channel_free(sc, td); delta = td->tt_complete_slot - sc->sc_last_frame_num - 1; if (td->tt_scheduled == 0 || delta < DWC_OTG_TT_SLOT_MAX) { @@ -1899,12 +1922,12 @@ send_cpkt: } /* allocate a new channel */ - if (dwc_otg_host_channel_alloc(sc, td, td->tt_channel_tog, 0)) { + if (dwc_otg_host_channel_alloc(sc, td, 0)) { td->state = DWC_CHAN_ST_WAIT_C_PKT; goto busy; } - channel = td->channel[td->tt_channel_tog]; + channel = td->channel; td->hcsplt |= HCSPLT_COMPSPLT; td->state = DWC_CHAN_ST_WAIT_C_ANE; @@ -1917,48 +1940,22 @@ send_cpkt: hcchar = td->hcchar; hcchar &= ~HCCHAR_EPDIR_IN; - /* check if other channel is allocated */ - if (td->channel[td->tt_channel_tog ^ 1] < DWC_OTG_MAX_CHANNELS) { - /* second - receive after next SOF event */ - if ((sc->sc_last_frame_num & 1) != 0) - hcchar |= HCCHAR_ODDFRM; - else - hcchar &= ~HCCHAR_ODDFRM; - - /* other channel is next */ - td->tt_channel_tog ^= 1; - /* wait until next slot before trying again */ - td->tt_complete_slot++; - - /* must enable channel before data can be received */ - DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(channel), hcchar); - } else { - /* first - receive after second next SOF event */ - if ((sc->sc_last_frame_num & 1) == 0) - hcchar |= HCCHAR_ODDFRM; - else - hcchar &= ~HCCHAR_ODDFRM; + /* receive complete split ASAP */ + if ((sc->sc_last_frame_num & 1) != 0) + hcchar |= HCCHAR_ODDFRM; + else + hcchar &= ~HCCHAR_ODDFRM; - /* must enable channel before data can be received */ - DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(channel), hcchar); + /* must enable channel before data can be received */ + DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(channel), hcchar); - if (td->hcsplt != 0) { - if (td->ep_type == UE_ISOCHRONOUS || td->ep_type == UE_INTERRUPT) { - /* allocate a second channel */ - td->tt_channel_tog ^= 1; - goto send_cpkt; - } else { - /* wait until next slot before trying again */ - td->tt_complete_slot++; - } - } - } + /* wait until next slot before trying complete split */ + td->tt_complete_slot = sc->sc_last_frame_num + 1; busy: return (1); /* busy */ complete: - dwc_otg_host_channel_free(sc, td, 0); - dwc_otg_host_channel_free(sc, td, 1); + dwc_otg_host_channel_free(sc, td); return (0); /* complete */ } @@ -2348,6 +2345,21 @@ dwc_otg_host_channel_disable(struct dwc_otg_softc *sc, uint8_t x) sc->sc_chan_state[x].tx_np_size = 0; } +static uint16_t +dwc_otg_compute_tt_slot(struct dwc_otg_tt_info *pinfo, uint16_t io_bytes) +{ + const uint16_t limit = (188 * 5) / 6; /* includes bit-stuffing */ + uint16_t retval = pinfo->slot_index; + + pinfo->bytes_used += io_bytes; + while (pinfo->slot_index < 6 && + pinfo->bytes_used >= limit) { + pinfo->bytes_used -= limit; + pinfo->slot_index++; + } + return (retval); +} + static uint8_t dwc_otg_update_host_transfer_schedule_locked(struct dwc_otg_softc *sc) { @@ -2356,6 +2368,7 @@ dwc_otg_update_host_transfer_schedule_locked(struct dwc_otg_softc *sc) struct usb_xfer *xfer_next; struct dwc_otg_td *td; uint16_t temp; + uint16_t slot; uint8_t x; temp = DWC_OTG_READ_4(sc, DOTG_HFNUM) & DWC_OTG_FRAME_MASK; @@ -2377,11 +2390,19 @@ dwc_otg_update_host_transfer_schedule_locked(struct dwc_otg_softc *sc) } if ((temp & 7) == 0) { + + /* reset the schedule */ + memset(sc->sc_tt_info, 0, sizeof(sc->sc_tt_info)); + TAILQ_FOREACH_SAFE(xfer, &sc->sc_bus.intr_q.head, wait_entry, xfer_next) { td = xfer->td_transfer_cache; if (td == NULL || td->ep_type != UE_ISOCHRONOUS) continue; + /* check for IN direction */ + if ((td->hcchar & HCCHAR_EPDIR_IN) != 0) + continue; + /* execute more frames */ td->tmr_val = 0; @@ -2390,9 +2411,40 @@ dwc_otg_update_host_transfer_schedule_locked(struct dwc_otg_softc *sc) if (td->hcsplt == 0 || td->tt_scheduled != 0) continue; + /* compute slot */ + slot = temp + dwc_otg_compute_tt_slot( + sc->sc_tt_info + td->tt_index, td->remainder); + /* Start ASAP */ - td->tt_start_slot = temp + 0; - td->tt_complete_slot = temp + 2; + td->tt_start_slot = slot + 0; + td->tt_scheduled = 1; + TAILQ_REMOVE(&sc->sc_bus.intr_q.head, xfer, wait_entry); + TAILQ_INSERT_TAIL(&head, xfer, wait_entry); + } + + TAILQ_FOREACH_SAFE(xfer, &sc->sc_bus.intr_q.head, wait_entry, xfer_next) { + td = xfer->td_transfer_cache; + if (td == NULL || td->ep_type != UE_ISOCHRONOUS) + continue; + + /* check for OUT direction */ + if ((td->hcchar & HCCHAR_EPDIR_IN) == 0) + continue; + + /* execute more frames */ + td->tmr_val = 0; + + sc->sc_needsof = 1; + + if (td->hcsplt == 0 || td->tt_scheduled != 0) + continue; + + /* compute slot */ + slot = temp + dwc_otg_compute_tt_slot( + sc->sc_tt_info + td->tt_index, td->remainder); + + /* Start ASAP */ + td->tt_start_slot = slot + 0; td->tt_scheduled = 1; TAILQ_REMOVE(&sc->sc_bus.intr_q.head, xfer, wait_entry); TAILQ_INSERT_TAIL(&head, xfer, wait_entry); @@ -2417,9 +2469,12 @@ dwc_otg_update_host_transfer_schedule_locked(struct dwc_otg_softc *sc) continue; } + /* compute slot */ + slot = temp + dwc_otg_compute_tt_slot(sc->sc_tt_info + td->tt_index, + td->max_packet_size); + /* start ASAP */ - td->tt_start_slot = temp + 0; - td->tt_complete_slot = temp + 2; + td->tt_start_slot = slot + 0; sc->sc_needsof = 1; td->tt_scheduled = 1; TAILQ_REMOVE(&sc->sc_bus.intr_q.head, xfer, wait_entry); @@ -2439,9 +2494,11 @@ dwc_otg_update_host_transfer_schedule_locked(struct dwc_otg_softc *sc) if (td->hcsplt == 0 || td->tt_scheduled != 0) continue; + /* compute slot */ + slot = temp + dwc_otg_compute_tt_slot(sc->sc_tt_info + td->tt_index, 0); + /* start ASAP */ - td->tt_start_slot = temp + 0; - td->tt_complete_slot = temp + 1; + td->tt_start_slot = slot + 0; td->tt_scheduled = 1; TAILQ_REMOVE(&sc->sc_bus.intr_q.head, xfer, wait_entry); TAILQ_INSERT_TAIL(&head, xfer, wait_entry); @@ -2461,9 +2518,17 @@ dwc_otg_update_host_transfer_schedule_locked(struct dwc_otg_softc *sc) if (td->hcsplt == 0 || td->tt_scheduled != 0) continue; + /* compute slot */ + slot = dwc_otg_compute_tt_slot(sc->sc_tt_info + td->tt_index, 0); + + /* figure out highest slot number */ + if (slot < (temp & 7)) + slot = temp; + else + slot += (temp & ~7); + /* start ASAP */ - td->tt_start_slot = temp + 0; - td->tt_complete_slot = temp + 1; + td->tt_start_slot = slot + 0; td->tt_scheduled = 1; TAILQ_REMOVE(&sc->sc_bus.intr_q.head, xfer, wait_entry); TAILQ_INSERT_TAIL(&head, xfer, wait_entry); @@ -2940,12 +3005,10 @@ dwc_otg_setup_standard_chain_sub(struct dwc_otg_std_temp *temp) td->set_toggle = 0; td->got_short = 0; td->did_nak = 0; - td->channel[0] = DWC_OTG_MAX_CHANNELS; - td->channel[1] = DWC_OTG_MAX_CHANNELS; + td->channel = DWC_OTG_MAX_CHANNELS; td->state = 0; td->errcnt = 0; td->tt_scheduled = 0; - td->tt_channel_tog = 0; td->tt_xactpos = HCSPLT_XACTPOS_BEGIN; } @@ -3159,23 +3222,9 @@ dwc_otg_setup_standard_chain(struct usb_xfer *xfer) (xfer->address << HCCHAR_DEVADDR_SHIFT) | ((xfer->endpointno & UE_ADDR) << HCCHAR_EPNUM_SHIFT) | (xfer->max_packet_size << HCCHAR_MPS_SHIFT) | + (td->ep_type << HCCHAR_EPTYPE_SHIFT) | HCCHAR_CHENA; - /* - * XXX stability hack - possible HW issue - * - * Disable workaround when using a transaction - * translator, hence some TTs reject control endpoint - * traffic using BULK endpoint type: - */ - if (td->ep_type == UE_CONTROL && - (xfer->xroot->udev->speed == USB_SPEED_HIGH || - xfer->xroot->udev->parent_hs_hub == NULL)) { - hcchar |= (UE_BULK << HCCHAR_EPTYPE_SHIFT); - } else { - hcchar |= (td->ep_type << HCCHAR_EPTYPE_SHIFT); - } - if (usbd_get_speed(xfer->xroot->udev) == USB_SPEED_LOW) hcchar |= HCCHAR_LSPDDEV; if (UE_GET_DIR(xfer->endpointno) == UE_DIR_IN) @@ -3472,12 +3521,9 @@ dwc_otg_device_done(struct usb_xfer *xfer, usb_error_t error) } else { struct dwc_otg_td *td; - td = xfer->td_transfer_first; - - if (td != NULL) { - dwc_otg_host_channel_free(sc, td, 0); - dwc_otg_host_channel_free(sc, td, 1); - } + td = xfer->td_transfer_cache; + if (td != NULL) + dwc_otg_host_channel_free(sc, td); } /* dequeue transfer and start next transfer */ usbd_transfer_done(xfer, error); @@ -4674,6 +4720,16 @@ dwc_otg_xfer_setup(struct usb_setup_params *parm) td = USB_ADD_BYTES(parm->buf, parm->size[0]); + /* compute shared bandwidth resource index for TT */ + if (parm->udev->parent_hs_hub != NULL && parm->udev->speed != USB_SPEED_HIGH) { + if (parm->udev->parent_hs_hub->ddesc.bDeviceProtocol == UDPROTO_HSHUBMTT) + td->tt_index = parm->udev->device_index; + else + td->tt_index = parm->udev->parent_hs_hub->device_index; + } else { + td->tt_index = parm->udev->device_index; + } + /* init TD */ td->max_packet_size = xfer->max_packet_size; td->max_packet_count = xfer->max_packet_count; diff --git a/sys/dev/usb/controller/dwc_otg.h b/sys/dev/usb/controller/dwc_otg.h index 6b6976f850c37..f8403a1689b22 100644 --- a/sys/dev/usb/controller/dwc_otg.h +++ b/sys/dev/usb/controller/dwc_otg.h @@ -68,7 +68,8 @@ struct dwc_otg_td { uint8_t did_nak; /* NAK counter */ uint8_t ep_no; uint8_t ep_type; - uint8_t channel[2]; + uint8_t channel; + uint8_t tt_index; /* TT data */ uint8_t tt_start_slot; /* TT data */ uint8_t tt_complete_slot; /* TT data */ uint8_t tt_xactpos; /* TT data */ @@ -80,7 +81,6 @@ struct dwc_otg_td { #define DWC_CHAN_ST_WAIT_C_PKT 4 #define DWC_CHAN_ST_TX_PKT_ISOC 5 #define DWC_CHAN_ST_TX_WAIT_ISOC 6 - uint8_t error:1; uint8_t error_any:1; uint8_t error_stall:1; uint8_t alt_next:1; @@ -90,7 +90,12 @@ struct dwc_otg_td { uint8_t set_toggle:1; uint8_t got_short:1; uint8_t tt_scheduled:1; - uint8_t tt_channel_tog:1; +}; + +struct dwc_otg_tt_info { + uint16_t bytes_used; + uint8_t slot_index; + uint8_t dummy; }; struct dwc_otg_std_temp { @@ -160,6 +165,7 @@ struct dwc_otg_softc { struct usb_bus sc_bus; union dwc_otg_hub_temp sc_hub_temp; struct dwc_otg_profile sc_hw_ep_profile[DWC_OTG_MAX_ENDPOINTS]; + struct dwc_otg_tt_info sc_tt_info[DWC_OTG_MAX_DEVICES]; struct usb_callout sc_timer; struct usb_device *sc_devices[DWC_OTG_MAX_DEVICES]; -- cgit v1.3 From 1b1df1a91fe8d2202dedea1784934a2455b09917 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Thu, 5 Jun 2014 18:19:48 +0000 Subject: Need to check the transfer cache field in the device done function to be sure all allocated channels are freed and not the transfer first one. --- sys/dev/usb/controller/saf1761_otg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/saf1761_otg.c b/sys/dev/usb/controller/saf1761_otg.c index b9ae393312945..0f5b4741d7531 100644 --- a/sys/dev/usb/controller/saf1761_otg.c +++ b/sys/dev/usb/controller/saf1761_otg.c @@ -2098,7 +2098,7 @@ saf1761_otg_device_done(struct usb_xfer *xfer, usb_error_t error) } else { struct saf1761_otg_td *td; - td = xfer->td_transfer_first; + td = xfer->td_transfer_cache; if (td != NULL) saf1761_host_channel_free(sc, td); -- cgit v1.3 From 408b9d7cfb4905f14db06b6b07ece35b445d0856 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Thu, 5 Jun 2014 18:23:51 +0000 Subject: - Verify that we don't load more data into a FIFO than it is configured to handle. - Add code to handle suspend and resume. MFC after: 3 days --- sys/dev/usb/controller/musb_otg.c | 63 ++++++++++++++++++++------------------- sys/dev/usb/controller/musb_otg.h | 2 +- 2 files changed, 33 insertions(+), 32 deletions(-) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/musb_otg.c b/sys/dev/usb/controller/musb_otg.c index 289ba56df5607..89de3d582b6c6 100644 --- a/sys/dev/usb/controller/musb_otg.c +++ b/sys/dev/usb/controller/musb_otg.c @@ -131,7 +131,7 @@ static void musbotg_do_poll(struct usb_bus *); static void musbotg_standard_done(struct usb_xfer *); static void musbotg_interrupt_poll(struct musbotg_softc *); static void musbotg_root_intr(struct musbotg_softc *); -static int musbotg_channel_alloc(struct musbotg_softc *, struct musbotg_td *td); +static int musbotg_channel_alloc(struct musbotg_softc *, struct musbotg_td *td, uint8_t); static void musbotg_channel_free(struct musbotg_softc *, struct musbotg_td *td); static void musbotg_ep_int_set(struct musbotg_softc *sc, int channel, int on); @@ -149,7 +149,7 @@ static const struct usb_hw_ep_profile musbotg_ep_profile[1] = { }; static int -musbotg_channel_alloc(struct musbotg_softc *sc, struct musbotg_td *td) +musbotg_channel_alloc(struct musbotg_softc *sc, struct musbotg_td *td, uint8_t is_tx) { int ch; int ep; @@ -173,12 +173,23 @@ musbotg_channel_alloc(struct musbotg_softc *sc, struct musbotg_td *td) return (0); } - for (ch = 1; ch < MUSB2_EP_MAX; ch++) { - if (!(sc->sc_channel_mask & (1 << ch))) { - sc->sc_channel_mask |= (1 << ch); - musbotg_ep_int_set(sc, ch, 1); - return (ch); + for (ch = sc->sc_ep_max; ch != 0; ch--) { + if (sc->sc_channel_mask & (1 << ch)) + continue; + + /* check FIFO size requirement */ + if (is_tx) { + if (td->max_frame_size > + sc->sc_hw_ep_profile[ch].max_in_frame_size) + continue; + } else { + if (td->max_frame_size > + sc->sc_hw_ep_profile[ch].max_out_frame_size) + continue; } + sc->sc_channel_mask |= (1 << ch); + musbotg_ep_int_set(sc, ch, 1); + return (ch); } DPRINTFN(-1, "No available channels. Mask: %04x\n", sc->sc_channel_mask); @@ -377,7 +388,7 @@ musbotg_dev_ctrl_setup_rx(struct musbotg_td *td) sc = MUSBOTG_PC2SC(td->pc); if (td->channel == -1) - td->channel = musbotg_channel_alloc(sc, td); + td->channel = musbotg_channel_alloc(sc, td, 0); /* EP0 is busy, wait */ if (td->channel == -1) @@ -498,7 +509,7 @@ musbotg_host_ctrl_setup_tx(struct musbotg_td *td) sc = MUSBOTG_PC2SC(td->pc); if (td->channel == -1) - td->channel = musbotg_channel_alloc(sc, td); + td->channel = musbotg_channel_alloc(sc, td, 1); /* EP0 is busy, wait */ if (td->channel == -1) @@ -870,7 +881,7 @@ musbotg_host_ctrl_data_rx(struct musbotg_td *td) sc = MUSBOTG_PC2SC(td->pc); if (td->channel == -1) - td->channel = musbotg_channel_alloc(sc, td); + td->channel = musbotg_channel_alloc(sc, td, 0); /* EP0 is busy, wait */ if (td->channel == -1) @@ -1049,7 +1060,7 @@ musbotg_host_ctrl_data_tx(struct musbotg_td *td) sc = MUSBOTG_PC2SC(td->pc); if (td->channel == -1) - td->channel = musbotg_channel_alloc(sc, td); + td->channel = musbotg_channel_alloc(sc, td, 1); /* No free EPs */ if (td->channel == -1) @@ -1259,7 +1270,7 @@ musbotg_host_ctrl_status_rx(struct musbotg_td *td) sc = MUSBOTG_PC2SC(td->pc); if (td->channel == -1) - td->channel = musbotg_channel_alloc(sc, td); + td->channel = musbotg_channel_alloc(sc, td, 0); /* EP0 is busy, wait */ if (td->channel == -1) @@ -1346,7 +1357,7 @@ musbotg_host_ctrl_status_tx(struct musbotg_td *td) sc = MUSBOTG_PC2SC(td->pc); if (td->channel == -1) - td->channel = musbotg_channel_alloc(sc, td); + td->channel = musbotg_channel_alloc(sc, td, 1); /* EP0 is busy, wait */ if (td->channel == -1) @@ -1419,7 +1430,7 @@ musbotg_dev_data_rx(struct musbotg_td *td) sc = MUSBOTG_PC2SC(td->pc); if (td->channel == -1) - td->channel = musbotg_channel_alloc(sc, td); + td->channel = musbotg_channel_alloc(sc, td, 0); /* EP0 is busy, wait */ if (td->channel == -1) @@ -1567,7 +1578,7 @@ musbotg_dev_data_tx(struct musbotg_td *td) sc = MUSBOTG_PC2SC(td->pc); if (td->channel == -1) - td->channel = musbotg_channel_alloc(sc, td); + td->channel = musbotg_channel_alloc(sc, td, 1); /* EP0 is busy, wait */ if (td->channel == -1) @@ -1695,7 +1706,7 @@ musbotg_host_data_rx(struct musbotg_td *td) sc = MUSBOTG_PC2SC(td->pc); if (td->channel == -1) - td->channel = musbotg_channel_alloc(sc, td); + td->channel = musbotg_channel_alloc(sc, td, 0); /* No free EPs */ if (td->channel == -1) @@ -1917,7 +1928,7 @@ musbotg_host_data_tx(struct musbotg_td *td) sc = MUSBOTG_PC2SC(td->pc); if (td->channel == -1) - td->channel = musbotg_channel_alloc(sc, td); + td->channel = musbotg_channel_alloc(sc, td, 1); /* No free EPs */ if (td->channel == -1) @@ -3226,6 +3237,7 @@ musbotg_init(struct musbotg_softc *sc) pf->support_out = 1; } else if (frx && (temp <= nrx)) { pf->max_out_frame_size = 1 << frx; + pf->max_in_frame_size = 0; pf->is_simplex = 1; /* simplex */ pf->support_multi_buffer = 1; pf->support_bulk = 1; @@ -3234,6 +3246,7 @@ musbotg_init(struct musbotg_softc *sc) pf->support_out = 1; } else if (ftx && (temp <= ntx)) { pf->max_in_frame_size = 1 << ftx; + pf->max_out_frame_size = 0; pf->is_simplex = 1; /* simplex */ pf->support_multi_buffer = 1; pf->support_bulk = 1; @@ -3286,18 +3299,6 @@ musbotg_uninit(struct musbotg_softc *sc) USB_BUS_UNLOCK(&sc->sc_bus); } -static void -musbotg_suspend(struct musbotg_softc *sc) -{ - /* TODO */ -} - -static void -musbotg_resume(struct musbotg_softc *sc) -{ - /* TODO */ -} - static void musbotg_do_poll(struct usb_bus *bus) { @@ -4214,13 +4215,13 @@ musbotg_set_hw_power_sleep(struct usb_bus *bus, uint32_t state) switch (state) { case USB_HW_POWER_SUSPEND: - musbotg_suspend(sc); + musbotg_uninit(sc); break; case USB_HW_POWER_SHUTDOWN: musbotg_uninit(sc); break; case USB_HW_POWER_RESUME: - musbotg_resume(sc); + musbotg_init(sc); break; default: break; diff --git a/sys/dev/usb/controller/musb_otg.h b/sys/dev/usb/controller/musb_otg.h index f8f3470dd9dab..7fe19a7ce6541 100644 --- a/sys/dev/usb/controller/musb_otg.h +++ b/sys/dev/usb/controller/musb_otg.h @@ -388,7 +388,7 @@ struct musbotg_flags { struct musbotg_softc { struct usb_bus sc_bus; union musbotg_hub_temp sc_hub_temp; - struct usb_hw_ep_profile sc_hw_ep_profile[16]; + struct usb_hw_ep_profile sc_hw_ep_profile[MUSB2_EP_MAX]; struct usb_device *sc_devices[MUSB2_MAX_DEVICES]; struct resource *sc_io_res; -- cgit v1.3 From dea9afcfae0569819a401ae90b19c787f794cca4 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Sat, 7 Jun 2014 07:23:17 +0000 Subject: Some further DWC OTG improvements for full speed and low speed devices: - Revert r265427. It appears we are halting the DWC OTG host controller schedule if we process events only at every SOF. When doing split transactions we rely on that events are processed quickly and waiting too long might cause data loss. - We are not always able to meet the timing requirements of interrupt endpoint split transactions. Switch from INTERRUPT to CONTROL endpoint type for interrupt endpoint events until further, hence CONTROL endpoint events are more relaxed, reducing the chance of data loss. See comment in code for more in-depth explanation. - Simplify TT scheduling. MFC after: 3 days --- sys/dev/usb/controller/dwc_otg.c | 138 ++++++++++++++++----------------------- sys/dev/usb/controller/dwc_otg.h | 4 +- 2 files changed, 59 insertions(+), 83 deletions(-) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/dwc_otg.c b/sys/dev/usb/controller/dwc_otg.c index c96b308335295..6183b6e55cfd0 100644 --- a/sys/dev/usb/controller/dwc_otg.c +++ b/sys/dev/usb/controller/dwc_otg.c @@ -98,6 +98,8 @@ GINTMSK_USBSUSPMSK | \ GINTMSK_IEPINTMSK | \ GINTMSK_SESSREQINTMSK | \ + GINTMSK_RXFLVLMSK | \ + GINTMSK_HCHINTMSK | \ GINTMSK_OTGINTMSK | \ GINTMSK_PRTINTMSK) @@ -239,7 +241,8 @@ dwc_otg_init_fifo(struct dwc_otg_softc *sc, uint8_t mode) for (x = 0; x != sc->sc_host_ch_max; x++) { /* disable all host interrupts */ - DWC_OTG_WRITE_4(sc, DOTG_HCINTMSK(x), 0); + DWC_OTG_WRITE_4(sc, DOTG_HCINTMSK(x), + HCINT_DEFAULT_MASK); } DWC_OTG_WRITE_4(sc, DOTG_HPTXFSIZ, @@ -256,8 +259,9 @@ dwc_otg_init_fifo(struct dwc_otg_softc *sc, uint8_t mode) /* store maximum periodic and non-periodic FIFO TX size */ sc->sc_tx_max_size = fifo_size; - /* disable all host channel interrupts */ - DWC_OTG_WRITE_4(sc, DOTG_HAINTMSK, 0); + /* enable all host channel interrupts */ + DWC_OTG_WRITE_4(sc, DOTG_HAINTMSK, + (1U << sc->sc_host_ch_max) - 1U); } if (mode == DWC_MODE_DEVICE) { @@ -568,11 +572,9 @@ dwc_otg_common_rx_ack(struct dwc_otg_softc *sc) { DPRINTFN(5, "RX status clear\n"); - if (sc->sc_flags.status_device_mode != 0) { - /* enable RX FIFO level interrupt */ - sc->sc_irq_mask |= GINTMSK_RXFLVLMSK; - DWC_OTG_WRITE_4(sc, DOTG_GINTMSK, sc->sc_irq_mask); - } + /* enable RX FIFO level interrupt */ + sc->sc_irq_mask |= GINTMSK_RXFLVLMSK; + DWC_OTG_WRITE_4(sc, DOTG_GINTMSK, sc->sc_irq_mask); /* clear cached status */ sc->sc_last_rx_status = 0; @@ -607,8 +609,7 @@ dwc_otg_host_channel_alloc(struct dwc_otg_softc *sc, struct dwc_otg_td *td, uint /* compute needed TX FIFO size */ if (is_out != 0) { - if (td->ep_type == UE_INTERRUPT || - td->ep_type == UE_ISOCHRONOUS) { + if (td->ep_type == UE_ISOCHRONOUS) { tx_p_size = td->max_packet_size; tx_np_size = 0; if (td->hcsplt != 0 && tx_p_size > HCSPLT_XACTLEN_BURST) @@ -687,7 +688,7 @@ dwc_otg_host_channel_free(struct dwc_otg_softc *sc, struct dwc_otg_td *td) * after a fixed given amount of time the host channel is no * longer doing any USB traffic: */ - if (td->ep_type == UE_ISOCHRONOUS || td->ep_type == UE_INTERRUPT) { + if (td->ep_type == UE_ISOCHRONOUS) { /* double buffered */ sc->sc_chan_state[x].wait_sof = DWC_OTG_SLOT_IDLE_MAX; } else { @@ -874,10 +875,7 @@ send_pkt: DOTG_DFIFO(td->channel), (uint32_t *)&req, sizeof(req) / 4); /* wait until next slot before trying complete split */ - if (td->ep_type == UE_INTERRUPT || td->ep_type == UE_ISOCHRONOUS) - td->tt_complete_slot = sc->sc_last_frame_num + 2; - else - td->tt_complete_slot = sc->sc_last_frame_num + 1; + td->tt_complete_slot = sc->sc_last_frame_num + 1; /* store number of bytes transmitted */ td->tx_bytes = sizeof(req); @@ -1352,15 +1350,7 @@ receive_pkt: } delta = sc->sc_last_frame_num - td->tt_start_slot; if (delta > DWC_OTG_TT_SLOT_MAX) { - if (td->ep_type == UE_INTERRUPT) { - /* - * Happens from time to time avoid - * posting an error, instead retry - * the start split packet: - */ - td->tt_scheduled = 0; - goto receive_spkt; - } else if (td->ep_type != UE_ISOCHRONOUS) { + if (td->ep_type != UE_ISOCHRONOUS) { /* we missed the service interval */ td->error_any = 1; } @@ -1460,10 +1450,7 @@ receive_spkt: hcchar |= HCCHAR_EPDIR_IN; /* wait until next slot before trying complete split */ - if (td->ep_type == UE_INTERRUPT || td->ep_type == UE_ISOCHRONOUS) - td->tt_complete_slot = sc->sc_last_frame_num + 2; - else - td->tt_complete_slot = sc->sc_last_frame_num + 1; + td->tt_complete_slot = sc->sc_last_frame_num + 1; /* must enable channel before data can be received */ DWC_OTG_WRITE_4(sc, DOTG_HCCHAR(channel), hcchar); @@ -2346,18 +2333,11 @@ dwc_otg_host_channel_disable(struct dwc_otg_softc *sc, uint8_t x) } static uint16_t -dwc_otg_compute_tt_slot(struct dwc_otg_tt_info *pinfo, uint16_t io_bytes) +dwc_otg_compute_isoc_rx_tt_slot(struct dwc_otg_tt_info *pinfo) { - const uint16_t limit = (188 * 5) / 6; /* includes bit-stuffing */ - uint16_t retval = pinfo->slot_index; - - pinfo->bytes_used += io_bytes; - while (pinfo->slot_index < 6 && - pinfo->bytes_used >= limit) { - pinfo->bytes_used -= limit; + if (pinfo->slot_index < DWC_OTG_TT_SLOT_MAX) pinfo->slot_index++; - } - return (retval); + return (pinfo->slot_index); } static uint8_t @@ -2412,11 +2392,17 @@ dwc_otg_update_host_transfer_schedule_locked(struct dwc_otg_softc *sc) continue; /* compute slot */ - slot = temp + dwc_otg_compute_tt_slot( - sc->sc_tt_info + td->tt_index, td->remainder); - - /* Start ASAP */ - td->tt_start_slot = slot + 0; + slot = dwc_otg_compute_isoc_rx_tt_slot( + sc->sc_tt_info + td->tt_index); + if (slot > 3) { + /* + * Not enough time to get complete + * split executed. + */ + continue; + } + /* Delayed start */ + td->tt_start_slot = temp + slot; td->tt_scheduled = 1; TAILQ_REMOVE(&sc->sc_bus.intr_q.head, xfer, wait_entry); TAILQ_INSERT_TAIL(&head, xfer, wait_entry); @@ -2439,12 +2425,8 @@ dwc_otg_update_host_transfer_schedule_locked(struct dwc_otg_softc *sc) if (td->hcsplt == 0 || td->tt_scheduled != 0) continue; - /* compute slot */ - slot = temp + dwc_otg_compute_tt_slot( - sc->sc_tt_info + td->tt_index, td->remainder); - /* Start ASAP */ - td->tt_start_slot = slot + 0; + td->tt_start_slot = temp; td->tt_scheduled = 1; TAILQ_REMOVE(&sc->sc_bus.intr_q.head, xfer, wait_entry); TAILQ_INSERT_TAIL(&head, xfer, wait_entry); @@ -2469,12 +2451,8 @@ dwc_otg_update_host_transfer_schedule_locked(struct dwc_otg_softc *sc) continue; } - /* compute slot */ - slot = temp + dwc_otg_compute_tt_slot(sc->sc_tt_info + td->tt_index, - td->max_packet_size); - /* start ASAP */ - td->tt_start_slot = slot + 0; + td->tt_start_slot = temp; sc->sc_needsof = 1; td->tt_scheduled = 1; TAILQ_REMOVE(&sc->sc_bus.intr_q.head, xfer, wait_entry); @@ -2494,11 +2472,8 @@ dwc_otg_update_host_transfer_schedule_locked(struct dwc_otg_softc *sc) if (td->hcsplt == 0 || td->tt_scheduled != 0) continue; - /* compute slot */ - slot = temp + dwc_otg_compute_tt_slot(sc->sc_tt_info + td->tt_index, 0); - /* start ASAP */ - td->tt_start_slot = slot + 0; + td->tt_start_slot = temp; td->tt_scheduled = 1; TAILQ_REMOVE(&sc->sc_bus.intr_q.head, xfer, wait_entry); TAILQ_INSERT_TAIL(&head, xfer, wait_entry); @@ -2518,17 +2493,8 @@ dwc_otg_update_host_transfer_schedule_locked(struct dwc_otg_softc *sc) if (td->hcsplt == 0 || td->tt_scheduled != 0) continue; - /* compute slot */ - slot = dwc_otg_compute_tt_slot(sc->sc_tt_info + td->tt_index, 0); - - /* figure out highest slot number */ - if (slot < (temp & 7)) - slot = temp; - else - slot += (temp & ~7); - /* start ASAP */ - td->tt_start_slot = slot + 0; + td->tt_start_slot = temp; td->tt_scheduled = 1; TAILQ_REMOVE(&sc->sc_bus.intr_q.head, xfer, wait_entry); TAILQ_INSERT_TAIL(&head, xfer, wait_entry); @@ -2809,8 +2775,6 @@ dwc_otg_interrupt(void *arg) /* Disable SOF interrupt */ sc->sc_irq_mask &= ~GINTMSK_SOFMSK; - /* Enable RX frame interrupt */ - sc->sc_irq_mask |= GINTMSK_RXFLVLMSK; DWC_OTG_WRITE_4(sc, DOTG_GINTMSK, sc->sc_irq_mask); /* complete root HUB interrupt endpoint */ @@ -2851,7 +2815,7 @@ dwc_otg_interrupt(void *arg) * suspend and RX frame interrupt: */ sc->sc_irq_mask &= ~(GINTMSK_WKUPINTMSK | GINTMSK_SOFMSK); - sc->sc_irq_mask |= (GINTMSK_USBSUSPMSK | GINTMSK_RXFLVLMSK); + sc->sc_irq_mask |= GINTMSK_USBSUSPMSK; DWC_OTG_WRITE_4(sc, DOTG_GINTMSK, sc->sc_irq_mask); /* complete root HUB interrupt endpoint */ @@ -2922,10 +2886,6 @@ dwc_otg_interrupt(void *arg) /* complete root HUB interrupt endpoint */ dwc_otg_root_intr(sc); - /* disable RX FIFO level interrupt */ - sc->sc_irq_mask &= ~GINTMSK_RXFLVLMSK; - DWC_OTG_WRITE_4(sc, DOTG_GINTMSK, sc->sc_irq_mask); - /* update host frame interval */ dwc_otg_update_host_frame_interval(sc); } @@ -3222,9 +3182,26 @@ dwc_otg_setup_standard_chain(struct usb_xfer *xfer) (xfer->address << HCCHAR_DEVADDR_SHIFT) | ((xfer->endpointno & UE_ADDR) << HCCHAR_EPNUM_SHIFT) | (xfer->max_packet_size << HCCHAR_MPS_SHIFT) | - (td->ep_type << HCCHAR_EPTYPE_SHIFT) | HCCHAR_CHENA; + /* + * We are not always able to meet the timing + * requirements of the USB interrupt endpoint's + * complete split token, when doing transfers going + * via a transaction translator. Use the CONTROL + * transfer type instead of the INTERRUPT transfer + * type in general, as a means to workaround + * that. This trick should work for both FULL and LOW + * speed USB traffic going through a TT. For non-TT + * traffic it works aswell. The reason for using + * CONTROL type instead of BULK is that some TTs might + * reject LOW speed BULK traffic. + */ + if (td->ep_type == UE_INTERRUPT) + hcchar |= (UE_CONTROL << HCCHAR_EPTYPE_SHIFT); + else + hcchar |= (td->ep_type << HCCHAR_EPTYPE_SHIFT); + if (usbd_get_speed(xfer->xroot->udev) == USB_SPEED_LOW) hcchar |= HCCHAR_LSPDDEV; if (UE_GET_DIR(xfer->endpointno) == UE_DIR_IN) @@ -3262,13 +3239,12 @@ dwc_otg_setup_standard_chain(struct usb_xfer *xfer) break; case USB_SPEED_HIGH: hcsplt = 0; - if (td->ep_type == UE_ISOCHRONOUS || - td->ep_type == UE_INTERRUPT) { - hcchar |= ((xfer->max_packet_count & 3) - << HCCHAR_MC_SHIFT); - } if (td->ep_type == UE_INTERRUPT) { uint32_t ival; +#if 0 + hcchar |= ((xfer->max_packet_count & 3) + << HCCHAR_MC_SHIFT); +#endif ival = xfer->interval / DWC_OTG_HOST_TIMER_RATE; if (ival == 0) ival = 1; @@ -3277,6 +3253,8 @@ dwc_otg_setup_standard_chain(struct usb_xfer *xfer) td->tmr_val = sc->sc_tmr_val + ival; td->tmr_res = ival; } else if (td->ep_type == UE_ISOCHRONOUS) { + hcchar |= ((xfer->max_packet_count & 3) + << HCCHAR_MC_SHIFT); td->tmr_val = 0; td->tmr_res = 1 << usbd_xfer_get_fps_shift(xfer); } else { diff --git a/sys/dev/usb/controller/dwc_otg.h b/sys/dev/usb/controller/dwc_otg.h index f8403a1689b22..1fa1bbf670511 100644 --- a/sys/dev/usb/controller/dwc_otg.h +++ b/sys/dev/usb/controller/dwc_otg.h @@ -35,7 +35,7 @@ #define DWC_OTG_MAX_ENDPOINTS 16 #define DWC_OTG_HOST_TIMER_RATE 10 /* ms */ #define DWC_OTG_TT_SLOT_MAX 8 -#define DWC_OTG_SLOT_IDLE_MAX 4 +#define DWC_OTG_SLOT_IDLE_MAX 3 #define DWC_OTG_SLOT_IDLE_MIN 2 #define DWC_OTG_NAK_MAX 8 /* 1 ms */ @@ -93,9 +93,7 @@ struct dwc_otg_td { }; struct dwc_otg_tt_info { - uint16_t bytes_used; uint8_t slot_index; - uint8_t dummy; }; struct dwc_otg_std_temp { -- cgit v1.3 From 2c9288df898ce0eaf747ef0b39e7f2d8c7b915e8 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Sat, 7 Jun 2014 10:13:45 +0000 Subject: Fix for USB specification compliance. We need to accept both DATA0 and DATA1 for INTERRUPT endpoints. MFC after: 3 days --- sys/dev/usb/controller/dwc_otg.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/dwc_otg.c b/sys/dev/usb/controller/dwc_otg.c index 6183b6e55cfd0..ed88caa42b7e2 100644 --- a/sys/dev/usb/controller/dwc_otg.c +++ b/sys/dev/usb/controller/dwc_otg.c @@ -1263,6 +1263,22 @@ dwc_otg_host_data_rx(struct dwc_otg_softc *sc, struct dwc_otg_td *td) case DWC_CHAN_ST_WAIT_ANE: if (hcint & (HCINT_RETRY | HCINT_ERRORS)) { + if (td->ep_type == UE_INTERRUPT) { + /* + * The USB specification does not + * mandate a particular data toggle + * value for USB INTERRUPT + * transfers. Switch the data toggle + * value to receive the packet + * correctly: + */ + if (hcint & HCINT_DATATGLERR) { + DPRINTF("Retrying packet due to " + "data toggle error\n"); + td->toggle ^= 1; + goto receive_pkt; + } + } td->did_nak++; td->tt_scheduled = 0; if (td->hcsplt != 0) -- cgit v1.3 From 4a4da38fcfa055a69584afd6bbac398b9c250660 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Sat, 7 Jun 2014 15:51:29 +0000 Subject: Make WITNESS happy by giving USB mutexes different names. Reported by: trociny @ MFC after: 3 days --- sys/dev/usb/controller/usb_controller.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/usb_controller.c b/sys/dev/usb/controller/usb_controller.c index 9f0e1162cb906..58b121bcddd78 100644 --- a/sys/dev/usb/controller/usb_controller.c +++ b/sys/dev/usb/controller/usb_controller.c @@ -899,10 +899,10 @@ usb_bus_mem_alloc_all(struct usb_bus *bus, bus_dma_tag_t dmat, bus->alloc_failed = 0; mtx_init(&bus->bus_mtx, device_get_nameunit(bus->parent), - NULL, MTX_DEF | MTX_RECURSE); + "usb_def_mtx", MTX_DEF | MTX_RECURSE); mtx_init(&bus->bus_spin_lock, device_get_nameunit(bus->parent), - NULL, MTX_SPIN | MTX_RECURSE); + "usb_spin_mtx", MTX_SPIN | MTX_RECURSE); usb_callout_init_mtx(&bus->power_wdog, &bus->bus_mtx, 0); -- cgit v1.3 From d64e9217c40746d8e4f8172457226b9abfe11be5 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Sun, 8 Jun 2014 20:10:29 +0000 Subject: Resolve a deadlock setting the USB configuration index from userspace on USB HUBs by moving the code into the USB explore threads. The deadlock happens because child devices of the USB HUB don't have the expected reference count when called from outside the explore thread. Only the HUB device itself, which the IOCTL interface locks, gets the correct reference count. MFC after: 3 days --- sys/dev/usb/controller/usb_controller.c | 8 +- sys/dev/usb/usb_dev.c | 11 ++- sys/dev/usb/usb_device.h | 2 + sys/dev/usb/usb_generic.c | 20 +--- sys/dev/usb/usb_hub.c | 162 +++++++++++++++++++++----------- sys/dev/usb/usb_hub.h | 1 + sys/dev/usb/usbdi.h | 2 + 7 files changed, 133 insertions(+), 73 deletions(-) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/usb_controller.c b/sys/dev/usb/controller/usb_controller.c index 58b121bcddd78..6df543030d942 100644 --- a/sys/dev/usb/controller/usb_controller.c +++ b/sys/dev/usb/controller/usb_controller.c @@ -367,7 +367,13 @@ usb_bus_explore(struct usb_proc_msg *pm) if (bus->no_explore != 0) return; - if (udev && udev->hub) { + if (udev != NULL) { + USB_BUS_UNLOCK(bus); + uhub_explore_handle_re_enumerate(udev); + USB_BUS_LOCK(bus); + } + + if (udev != NULL && udev->hub != NULL) { if (bus->do_probe) { bus->do_probe = 0; diff --git a/sys/dev/usb/usb_dev.c b/sys/dev/usb/usb_dev.c index e4471aee0b74a..6ad02a7d035dd 100644 --- a/sys/dev/usb/usb_dev.c +++ b/sys/dev/usb/usb_dev.c @@ -1116,9 +1116,14 @@ usb_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int fflag, struct thread* usb_pause_mtx(NULL, hz / 128); - if (usb_ref_device(cpd, &refs, 1 /* need uref */)) { - err = ENXIO; - goto done; + while (usb_ref_device(cpd, &refs, 1 /* need uref */)) { + if (usb_ref_device(cpd, &refs, 0)) { + /* device no longer exits */ + err = ENXIO; + goto done; + } + usb_unref_device(cpd, &refs); + usb_pause_mtx(NULL, hz / 128); } } diff --git a/sys/dev/usb/usb_device.h b/sys/dev/usb/usb_device.h index 0763663fec6fa..4bda2a476abab 100644 --- a/sys/dev/usb/usb_device.h +++ b/sys/dev/usb/usb_device.h @@ -228,6 +228,7 @@ struct usb_device { uint8_t address; /* device addess */ uint8_t device_index; /* device index in "bus->devices" */ uint8_t controller_slot_id; /* controller specific value */ + uint8_t next_config_index; /* used by USB_RE_ENUM_SET_CONFIG */ uint8_t curr_config_index; /* current configuration index */ uint8_t curr_config_no; /* current configuration number */ uint8_t depth; /* distance from root HUB */ @@ -241,6 +242,7 @@ struct usb_device { #define USB_RE_ENUM_DONE 0 #define USB_RE_ENUM_START 1 #define USB_RE_ENUM_PWR_OFF 2 +#define USB_RE_ENUM_SET_CONFIG 3 uint8_t ifaces_max; /* number of interfaces present */ uint8_t endpoints_max; /* number of endpoints present */ diff --git a/sys/dev/usb/usb_generic.c b/sys/dev/usb/usb_generic.c index 6d8b0f5bfce37..4ebd557a51821 100644 --- a/sys/dev/usb/usb_generic.c +++ b/sys/dev/usb/usb_generic.c @@ -616,24 +616,17 @@ ugen_set_config(struct usb_fifo *f, uint8_t index) /* not possible in device side mode */ return (ENOTTY); } - if (f->udev->curr_config_index == index) { - /* no change needed */ - return (0); - } + /* make sure all FIFO's are gone */ /* else there can be a deadlock */ if (ugen_fs_uninit(f)) { /* ignore any errors */ DPRINTFN(6, "no FIFOs\n"); } - /* change setting - will free generic FIFOs, if any */ - if (usbd_set_config_index(f->udev, index)) { - return (EIO); - } - /* probe and attach */ - if (usb_probe_and_attach(f->udev, USB_IFACE_INDEX_ANY)) { + + if (usbd_start_set_config(f->udev, index) != 0) return (EIO); - } + return (0); } @@ -970,11 +963,6 @@ ugen_re_enumerate(struct usb_fifo *f) DPRINTFN(6, "device mode\n"); return (ENOTTY); } - if (udev->parent_hub == NULL) { - /* the root HUB cannot be re-enumerated */ - DPRINTFN(6, "cannot reset root HUB\n"); - return (EINVAL); - } /* make sure all FIFO's are gone */ /* else there can be a deadlock */ if (ugen_fs_uninit(f)) { diff --git a/sys/dev/usb/usb_hub.c b/sys/dev/usb/usb_hub.c index 912723b003099..e9c9a42c39142 100644 --- a/sys/dev/usb/usb_hub.c +++ b/sys/dev/usb/usb_hub.c @@ -427,6 +427,86 @@ done: return (retval); } +void +uhub_explore_handle_re_enumerate(struct usb_device *child) +{ + uint8_t do_unlock; + usb_error_t err; + + /* check if device should be re-enumerated */ + if (child->flags.usb_mode != USB_MODE_HOST) + return; + + do_unlock = usbd_enum_lock(child); + switch (child->re_enumerate_wait) { + case USB_RE_ENUM_START: + err = usbd_set_config_index(child, + USB_UNCONFIG_INDEX); + if (err != 0) { + DPRINTF("Unconfigure failed: %s: Ignored.\n", + usbd_errstr(err)); + } + if (child->parent_hub == NULL) { + /* the root HUB cannot be re-enumerated */ + DPRINTFN(6, "cannot reset root HUB\n"); + err = 0; + } else { + err = usbd_req_re_enumerate(child, NULL); + } + if (err == 0) + err = usbd_set_config_index(child, 0); + if (err == 0) { + err = usb_probe_and_attach(child, + USB_IFACE_INDEX_ANY); + } + child->re_enumerate_wait = USB_RE_ENUM_DONE; + break; + + case USB_RE_ENUM_PWR_OFF: + /* get the device unconfigured */ + err = usbd_set_config_index(child, + USB_UNCONFIG_INDEX); + if (err) { + DPRINTFN(0, "Could not unconfigure " + "device (ignored)\n"); + } + if (child->parent_hub == NULL) { + /* the root HUB cannot be re-enumerated */ + DPRINTFN(6, "cannot set port feature\n"); + err = 0; + } else { + /* clear port enable */ + err = usbd_req_clear_port_feature(child->parent_hub, + NULL, child->port_no, UHF_PORT_ENABLE); + if (err) { + DPRINTFN(0, "Could not disable port " + "(ignored)\n"); + } + } + child->re_enumerate_wait = USB_RE_ENUM_DONE; + break; + + case USB_RE_ENUM_SET_CONFIG: + err = usbd_set_config_index(child, + child->next_config_index); + if (err != 0) { + DPRINTF("Configure failed: %s: Ignored.\n", + usbd_errstr(err)); + } else { + err = usb_probe_and_attach(child, + USB_IFACE_INDEX_ANY); + } + child->re_enumerate_wait = USB_RE_ENUM_DONE; + break; + + default: + child->re_enumerate_wait = USB_RE_ENUM_DONE; + break; + } + if (do_unlock) + usbd_enum_unlock(child); +} + /*------------------------------------------------------------------------* * uhub_explore_sub - subroutine * @@ -455,59 +535,7 @@ uhub_explore_sub(struct uhub_softc *sc, struct usb_port *up) goto done; } - /* check if device should be re-enumerated */ - - if (child->flags.usb_mode == USB_MODE_HOST) { - uint8_t do_unlock; - - do_unlock = usbd_enum_lock(child); - switch (child->re_enumerate_wait) { - case USB_RE_ENUM_START: - err = usbd_set_config_index(child, - USB_UNCONFIG_INDEX); - if (err != 0) { - DPRINTF("Unconfigure failed: " - "%s: Ignored.\n", - usbd_errstr(err)); - } - err = usbd_req_re_enumerate(child, NULL); - if (err == 0) - err = usbd_set_config_index(child, 0); - if (err == 0) { - err = usb_probe_and_attach(child, - USB_IFACE_INDEX_ANY); - } - child->re_enumerate_wait = USB_RE_ENUM_DONE; - err = 0; - break; - - case USB_RE_ENUM_PWR_OFF: - /* get the device unconfigured */ - err = usbd_set_config_index(child, - USB_UNCONFIG_INDEX); - if (err) { - DPRINTFN(0, "Could not unconfigure " - "device (ignored)\n"); - } - - /* clear port enable */ - err = usbd_req_clear_port_feature(child->parent_hub, - NULL, child->port_no, UHF_PORT_ENABLE); - if (err) { - DPRINTFN(0, "Could not disable port " - "(ignored)\n"); - } - child->re_enumerate_wait = USB_RE_ENUM_DONE; - err = 0; - break; - - default: - child->re_enumerate_wait = USB_RE_ENUM_DONE; - break; - } - if (do_unlock) - usbd_enum_unlock(child); - } + uhub_explore_handle_re_enumerate(child); /* check if probe and attach should be done */ @@ -2799,3 +2827,31 @@ usbd_start_re_enumerate(struct usb_device *udev) usb_needs_explore(udev->bus, 0); } } + +/*-----------------------------------------------------------------------* + * usbd_start_set_config + * + * This function starts setting a USB configuration. This function + * does not need to be called BUS-locked. This function does not wait + * until the set USB configuratino is completed. + *------------------------------------------------------------------------*/ +usb_error_t +usbd_start_set_config(struct usb_device *udev, uint8_t index) +{ + if (udev->re_enumerate_wait == USB_RE_ENUM_DONE) { + if (udev->curr_config_index == index) { + /* no change needed */ + return (0); + } + udev->next_config_index = index; + udev->re_enumerate_wait = USB_RE_ENUM_SET_CONFIG; + usb_needs_explore(udev->bus, 0); + return (0); + } else if (udev->re_enumerate_wait == USB_RE_ENUM_SET_CONFIG) { + if (udev->next_config_index == index) { + /* no change needed */ + return (0); + } + } + return (USB_ERR_PENDING_REQUESTS); +} diff --git a/sys/dev/usb/usb_hub.h b/sys/dev/usb/usb_hub.h index dc8705a6b481c..16430d9b29a78 100644 --- a/sys/dev/usb/usb_hub.h +++ b/sys/dev/usb/usb_hub.h @@ -75,5 +75,6 @@ void usb_bus_power_update(struct usb_bus *bus); void usb_bus_powerd(struct usb_bus *bus); void uhub_root_intr(struct usb_bus *, const uint8_t *, uint8_t); usb_error_t uhub_query_info(struct usb_device *, uint8_t *, uint8_t *); +void uhub_explore_handle_re_enumerate(struct usb_device *); #endif /* _USB_HUB_H_ */ diff --git a/sys/dev/usb/usbdi.h b/sys/dev/usb/usbdi.h index f4c6cf9ec9410..09b0ca7b1b522 100644 --- a/sys/dev/usb/usbdi.h +++ b/sys/dev/usb/usbdi.h @@ -586,6 +586,8 @@ void usbd_m_copy_in(struct usb_page_cache *cache, usb_frlength_t dst_offset, void usbd_frame_zero(struct usb_page_cache *cache, usb_frlength_t offset, usb_frlength_t len); void usbd_start_re_enumerate(struct usb_device *udev); +usb_error_t + usbd_start_set_config(struct usb_device *, uint8_t); int usb_fifo_attach(struct usb_device *udev, void *priv_sc, struct mtx *priv_mtx, struct usb_fifo_methods *pm, -- cgit v1.3 From cabe79d9d8aa1a19816cf70f8a3c75ba1283d8d8 Mon Sep 17 00:00:00 2001 From: Marius Strobl Date: Tue, 10 Jun 2014 08:20:00 +0000 Subject: Avoid the USB device disconnected and controller shutdown clutter on system shutdown by putting the former under !rebooting and turning the latter into debug messages. Reviewed by: hps MFC after: 1 week Sponsored by: Bally Wulff Games & Entertainment GmbH --- sys/dev/usb/controller/usb_controller.c | 5 +++-- sys/dev/usb/usb_device.c | 16 ++++++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/usb_controller.c b/sys/dev/usb/controller/usb_controller.c index 6df543030d942..c2cafecf61d40 100644 --- a/sys/dev/usb/controller/usb_controller.c +++ b/sys/dev/usb/controller/usb_controller.c @@ -333,7 +333,7 @@ usb_shutdown(device_t dev) return (0); } - device_printf(bus->bdev, "Controller shutdown\n"); + DPRINTF("%s: Controller shutdown\n", device_get_nameunit(bus->bdev)); USB_BUS_LOCK(bus); usb_proc_msignal(USB_BUS_EXPLORE_PROC(bus), @@ -345,7 +345,8 @@ usb_shutdown(device_t dev) } USB_BUS_UNLOCK(bus); - device_printf(bus->bdev, "Controller shutdown complete\n"); + DPRINTF("%s: Controller shutdown complete\n", + device_get_nameunit(bus->bdev)); return (0); } diff --git a/sys/dev/usb/usb_device.c b/sys/dev/usb/usb_device.c index 8f7b3127e473c..7acb5cbc4f7d0 100644 --- a/sys/dev/usb/usb_device.c +++ b/sys/dev/usb/usb_device.c @@ -1124,10 +1124,12 @@ usb_detach_device_sub(struct usb_device *udev, device_t *ppdev, */ *ppdev = NULL; - device_printf(dev, "at %s, port %d, addr %d " - "(disconnected)\n", - device_get_nameunit(udev->parent_dev), - udev->port_no, udev->address); + if (!rebooting) { + device_printf(dev, "at %s, port %d, addr %d " + "(disconnected)\n", + device_get_nameunit(udev->parent_dev), + udev->port_no, udev->address); + } if (device_is_attached(dev)) { if (udev->flags.peer_suspended) { @@ -2143,8 +2145,10 @@ usb_free_device(struct usb_device *udev, uint8_t flag) #endif #if USB_HAVE_UGEN - printf("%s: <%s> at %s (disconnected)\n", udev->ugen_name, - usb_get_manufacturer(udev), device_get_nameunit(bus->bdev)); + if (!rebooting) { + printf("%s: <%s> at %s (disconnected)\n", udev->ugen_name, + usb_get_manufacturer(udev), device_get_nameunit(bus->bdev)); + } /* Destroy UGEN symlink, if any */ if (udev->ugen_symlink) { -- cgit v1.3 From 3da1cf1e88f8448bb10c5f778ab56ff65c7a6938 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Fri, 27 Jun 2014 16:33:43 +0000 Subject: Extend the meaning of the CTLFLAG_TUN flag to automatically check if there is an environment variable which shall initialize the SYSCTL during early boot. This works for all SYSCTL types both statically and dynamically created ones, except for the SYSCTL NODE type and SYSCTLs which belong to VNETs. A new flag, CTLFLAG_NOFETCH, has been added to be used in the case a tunable sysctl has a custom initialisation function allowing the sysctl to still be marked as a tunable. The kernel SYSCTL API is mostly the same, with a few exceptions for some special operations like iterating childrens of a static/extern SYSCTL node. This operation should probably be made into a factored out common macro, hence some device drivers use this. The reason for changing the SYSCTL API was the need for a SYSCTL parent OID pointer and not only the SYSCTL parent OID list pointer in order to quickly generate the sysctl path. The motivation behind this patch is to avoid parameter loading cludges inside the OFED driver subsystem. Instead of adding special code to the OFED driver subsystem to post-load tunables into dynamically created sysctls, we generalize this in the kernel. Other changes: - Corrected a possibly incorrect sysctl name from "hw.cbb.intr_mask" to "hw.pcic.intr_mask". - Removed redundant TUNABLE statements throughout the kernel. - Some minor code rewrites in connection to removing not needed TUNABLE statements. - Added a missing SYSCTL_DECL(). - Wrapped two very long lines. - Avoid malloc()/free() inside sysctl string handling, in case it is called to initialize a sysctl from a tunable, hence malloc()/free() is not ready when sysctls from the sysctl dataset are registered. - Bumped FreeBSD version to indicate SYSCTL API change. MFC after: 2 weeks Sponsored by: Mellanox Technologies --- sys/amd64/acpica/acpi_machdep.c | 5 +- sys/amd64/amd64/amd64_mem.c | 1 - sys/amd64/amd64/machdep.c | 3 +- sys/amd64/amd64/mp_watchdog.c | 3 +- sys/amd64/amd64/pmap.c | 8 +- sys/amd64/amd64/sys_machdep.c | 1 - sys/amd64/amd64/trap.c | 10 +- sys/amd64/pci/pci_cfgreg.c | 1 - sys/amd64/vmm/vmm.c | 1 - sys/arm/arm/busdma_machdep-v6.c | 6 +- sys/arm/arm/busdma_machdep.c | 6 +- sys/arm/arm/dump_machdep.c | 3 +- sys/arm/arm/platform.c | 4 +- sys/arm/arm/pmap-v6.c | 2 +- sys/arm/freescale/imx/imx6_anatop.c | 11 +- sys/arm/xscale/ixp425/if_npe.c | 12 +- sys/arm/xscale/ixp425/ixp425_npe.c | 3 +- sys/arm/xscale/ixp425/ixp425_qmgr.c | 5 +- sys/cam/ata/ata_da.c | 24 +-- sys/cam/ata/ata_pmp.c | 9 +- sys/cam/cam.c | 1 - sys/cam/cam_xpt.c | 8 +- sys/cam/ctl/ctl.c | 2 - sys/cam/ctl/ctl_backend_block.c | 3 +- sys/cam/ctl/ctl_frontend_iscsi.c | 4 - sys/cam/scsi/scsi_cd.c | 9 +- sys/cam/scsi/scsi_da.c | 12 +- sys/cam/scsi/scsi_enc_safte.c | 3 +- sys/cam/scsi/scsi_sa.c | 5 +- sys/cam/scsi/scsi_xpt.c | 3 +- .../compat/opensolaris/kern/opensolaris_kstat.c | 2 +- .../contrib/opensolaris/uts/common/fs/zfs/arc.c | 2 - .../contrib/opensolaris/uts/common/fs/zfs/ddt.c | 3 +- .../contrib/opensolaris/uts/common/fs/zfs/dmu.c | 4 +- .../opensolaris/uts/common/fs/zfs/dmu_zfetch.c | 6 +- .../opensolaris/uts/common/fs/zfs/dsl_pool.c | 4 - .../opensolaris/uts/common/fs/zfs/dsl_scan.c | 27 +-- .../opensolaris/uts/common/fs/zfs/metaslab.c | 23 +-- .../contrib/opensolaris/uts/common/fs/zfs/spa.c | 3 +- .../opensolaris/uts/common/fs/zfs/spa_misc.c | 6 - .../opensolaris/uts/common/fs/zfs/trim_map.c | 9 - .../contrib/opensolaris/uts/common/fs/zfs/txg.c | 3 +- .../opensolaris/uts/common/fs/zfs/vdev_cache.c | 3 - .../opensolaris/uts/common/fs/zfs/vdev_geom.c | 10 +- .../opensolaris/uts/common/fs/zfs/vdev_mirror.c | 16 +- .../opensolaris/uts/common/fs/zfs/vdev_queue.c | 20 +-- .../opensolaris/uts/common/fs/zfs/zfs_ioctl.c | 3 +- .../opensolaris/uts/common/fs/zfs/zfs_vfsops.c | 3 +- .../contrib/opensolaris/uts/common/fs/zfs/zil.c | 5 +- .../contrib/opensolaris/uts/common/fs/zfs/zio.c | 5 - .../contrib/opensolaris/uts/common/fs/zfs/zvol.c | 1 - sys/cddl/dev/dtrace/dtrace_sysctl.c | 3 +- sys/compat/ia32/ia32_sysvec.c | 9 +- sys/compat/x86bios/x86bios.c | 6 +- sys/dev/aac/aac_pci.c | 1 - sys/dev/acpica/Osd/OsdSchedule.c | 2 - sys/dev/acpica/acpi_cpu.c | 1 - sys/dev/acpica/acpi_ec.c | 9 +- sys/dev/amr/amr_pci.c | 1 - sys/dev/ata/ata-all.c | 3 +- sys/dev/ath/ah_osdep.c | 3 +- sys/dev/ath/if_ath.c | 9 +- sys/dev/ath/if_ath_debug.c | 3 +- sys/dev/bce/if_bce.c | 15 -- sys/dev/bge/if_bge.c | 17 +- sys/dev/bwn/if_bwn.c | 3 +- sys/dev/bxe/bxe.c | 13 +- sys/dev/cardbus/cardbus.c | 12 +- sys/dev/cs/if_cs.c | 6 +- sys/dev/cxgb/cxgb_include.h | 3 + sys/dev/cxgb/cxgb_main.c | 5 - sys/dev/cxgb/cxgb_sge.c | 14 +- sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c | 24 +-- sys/dev/cxgbe/iw_cxgbe/cm.c | 50 ++---- sys/dev/drm/drm_drv.c | 1 - sys/dev/drm/drm_sysctl.c | 2 +- sys/dev/drm2/drm_drv.c | 1 - sys/dev/drm2/drm_sysctl.c | 2 +- sys/dev/e1000/if_em.c | 11 -- sys/dev/e1000/if_igb.c | 11 +- sys/dev/fb/vesa.c | 1 - sys/dev/firewire/fwohci.c | 11 +- sys/dev/firewire/if_fwe.c | 12 +- sys/dev/firewire/if_fwip.c | 4 +- sys/dev/firewire/sbp.c | 24 +-- sys/dev/glxiic/glxiic.c | 5 +- sys/dev/hptmv/hptproc.c | 2 +- sys/dev/hwpmc/hwpmc_logging.c | 6 +- sys/dev/hwpmc/hwpmc_mod.c | 17 +- sys/dev/iscsi/icl.c | 5 - sys/dev/iscsi/iscsi.c | 6 - sys/dev/iscsi_initiator/iscsi.c | 11 +- sys/dev/ixgbe/ixgbe.c | 10 +- sys/dev/malo/if_malo.c | 15 +- sys/dev/malo/if_malo_pci.c | 3 +- sys/dev/mfi/mfi.c | 6 - sys/dev/mfi/mfi_cam.c | 3 +- sys/dev/mfi/mfi_pci.c | 5 +- sys/dev/mfi/mfi_tbolt.c | 1 - sys/dev/mwl/if_mwl.c | 18 +- sys/dev/nand/nand.c | 11 +- sys/dev/pccard/pccard.c | 6 +- sys/dev/pccbb/pccbb.c | 12 +- sys/dev/pccbb/pccbb_isa.c | 4 +- sys/dev/pci/pci.c | 31 ++-- sys/dev/pci/pci_pci.c | 1 - sys/dev/pci/vga_pci.c | 1 - sys/dev/puc/puc_pci.c | 3 +- sys/dev/rt/if_rt.c | 3 +- sys/dev/sdhci/sdhci.c | 3 +- sys/dev/sdhci/sdhci_pci.c | 3 +- sys/dev/si/si.c | 3 +- sys/dev/sio/sio.c | 2 +- sys/dev/sis/if_sis.c | 5 +- sys/dev/sound/pcm/channel.c | 3 +- sys/dev/sound/pcm/feeder_chain.c | 3 +- sys/dev/sound/pcm/feeder_eq.c | 3 +- sys/dev/sound/pcm/feeder_rate.c | 3 +- sys/dev/sound/pcm/mixer.c | 3 +- sys/dev/sound/pcm/sound.c | 3 +- sys/dev/sound/usb/uaudio.c | 12 +- sys/dev/syscons/syscons.c | 3 +- sys/dev/uart/uart_dev_ns8250.c | 3 +- sys/dev/usb/controller/dwc_otg.c | 5 +- sys/dev/usb/controller/ehci.c | 13 +- sys/dev/usb/controller/ohci.c | 3 +- sys/dev/usb/controller/uhci.c | 6 +- sys/dev/usb/controller/usb_controller.c | 9 +- sys/dev/usb/controller/xhci.c | 12 +- sys/dev/usb/input/ukbd.c | 9 +- sys/dev/usb/serial/uftdi.c | 1 - sys/dev/usb/serial/usb_serial.c | 9 +- sys/dev/usb/storage/umass.c | 6 +- sys/dev/usb/usb_debug.c | 33 ++-- sys/dev/usb/usb_dev.c | 3 +- sys/dev/usb/usb_device.c | 9 +- sys/dev/usb/usb_generic.c | 3 +- sys/dev/usb/usb_hub.c | 3 +- sys/dev/usb/usb_process.c | 3 +- sys/dev/usb/wlan/if_uath.c | 6 +- sys/dev/usb/wlan/if_upgt.c | 3 +- sys/dev/usb/wlan/if_urtw.c | 6 +- sys/dev/vt/vt.h | 5 +- sys/dev/wpi/if_wpi.c | 5 +- sys/gdb/gdb_cons.c | 5 +- sys/geom/concat/g_concat.c | 3 +- sys/geom/eli/g_eli.c | 18 +- sys/geom/eli/g_eli_key_cache.c | 1 - sys/geom/gate/g_gate.c | 4 +- sys/geom/geom_disk.c | 5 +- sys/geom/geom_kern.c | 3 +- sys/geom/journal/g_journal.c | 7 +- sys/geom/label/g_label.c | 3 +- sys/geom/label/g_label.h | 4 +- sys/geom/linux_lvm/g_linux_lvm.c | 3 +- sys/geom/mirror/g_mirror.c | 14 +- sys/geom/part/g_part.c | 3 +- sys/geom/part/g_part_ldm.c | 6 +- sys/geom/raid/g_raid.c | 31 ++-- sys/geom/raid/g_raid.h | 12 +- sys/geom/raid/tr_raid1.c | 16 +- sys/geom/raid/tr_raid1e.c | 16 +- sys/geom/raid3/g_raid3.c | 24 +-- sys/geom/shsec/g_shsec.c | 6 +- sys/geom/stripe/g_stripe.c | 9 +- sys/geom/vinum/geom_vinum.c | 3 +- sys/geom/virstor/g_virstor.c | 10 +- sys/i386/acpica/acpi_machdep.c | 3 +- sys/i386/bios/apm.c | 3 +- sys/i386/i386/i686_mem.c | 1 - sys/i386/i386/machdep.c | 3 +- sys/i386/i386/mp_watchdog.c | 3 +- sys/i386/i386/pmap.c | 4 +- sys/i386/i386/trap.c | 6 +- sys/i386/pci/pci_cfgreg.c | 1 - sys/i386/pci/pci_pir.c | 1 - sys/ia64/ia64/dump_machdep.c | 3 +- sys/ia64/ia64/pmap.c | 5 +- sys/kern/imgact_elf.c | 4 +- sys/kern/kern_clocksource.c | 16 +- sys/kern/kern_cpu.c | 6 +- sys/kern/kern_exec.c | 3 +- sys/kern/kern_intr.c | 3 +- sys/kern/kern_ktr.c | 24 +-- sys/kern/kern_ktrace.c | 3 +- sys/kern/kern_linker.c | 5 +- sys/kern/kern_malloc.c | 57 +++--- sys/kern/kern_mbuf.c | 2 +- sys/kern/kern_mib.c | 40 ++--- sys/kern/kern_ntptime.c | 6 +- sys/kern/kern_osd.c | 3 +- sys/kern/kern_pmc.c | 3 +- sys/kern/kern_priv.c | 6 +- sys/kern/kern_shutdown.c | 36 ++-- sys/kern/kern_sig.c | 12 +- sys/kern/kern_sysctl.c | 193 ++++++++++++++++----- sys/kern/kern_tc.c | 6 +- sys/kern/kern_timeout.c | 6 +- sys/kern/subr_bus.c | 27 +-- sys/kern/subr_kdb.c | 6 +- sys/kern/subr_msgbuf.c | 3 +- sys/kern/subr_param.c | 26 +-- sys/kern/subr_prf.c | 23 ++- sys/kern/subr_rman.c | 3 +- sys/kern/subr_smp.c | 4 +- sys/kern/subr_witness.c | 13 +- sys/kern/sys_pipe.c | 2 +- sys/kern/sysv_msg.c | 6 - sys/kern/sysv_sem.c | 16 +- sys/kern/sysv_shm.c | 32 ++-- sys/kern/vfs_init.c | 3 +- sys/kern/vfs_lookup.c | 3 +- sys/mips/cavium/usb/octusb.c | 5 +- sys/mips/mips/dump_machdep.c | 3 +- sys/mips/rt305x/uart_dev_rt305x.c | 6 +- sys/net/ieee8023ad_lacp.c | 3 +- sys/net/if.c | 1 - sys/net/if_bridge.c | 21 +-- sys/net/if_lagg.c | 6 +- sys/net/if_stf.c | 3 +- sys/net/if_tap.c | 4 +- sys/net/if_tun.c | 4 +- sys/net/netisr.c | 26 +-- sys/net/route.c | 7 +- sys/netgraph/ng_base.c | 3 - sys/netgraph/ng_mppc.c | 9 +- sys/netinet/in_mcast.c | 9 +- sys/netinet/in_rss.c | 6 +- sys/netinet/tcp_subr.c | 7 +- sys/netinet6/in6_mcast.c | 9 +- sys/netinet6/mld6.c | 6 +- sys/netpfil/ipfw/ip_fw2.c | 1 - sys/netpfil/pf/pf.c | 2 - sys/pc98/cbus/sio.c | 2 +- sys/pc98/pc98/machdep.c | 3 +- sys/pc98/pc98/pc98_machdep.c | 3 +- sys/security/mac_biba/mac_biba.c | 19 +- sys/security/mac_bsdextended/mac_bsdextended.c | 3 +- sys/security/mac_ifoff/mac_ifoff.c | 12 +- sys/security/mac_lomac/mac_lomac.c | 16 +- sys/security/mac_mls/mac_mls.c | 9 +- sys/security/mac_portacl/mac_portacl.c | 14 +- sys/sparc64/pci/psycho.c | 1 - sys/sys/malloc.h | 2 +- sys/sys/param.h | 2 +- sys/sys/sysctl.h | 56 ++++-- sys/vm/memguard.c | 8 +- sys/vm/redzone.c | 3 +- sys/vm/uma_core.c | 3 +- sys/vm/vm_init.c | 3 +- sys/vm/vm_map.c | 3 +- sys/vm/vm_mmap.c | 3 +- sys/vm/vm_page.c | 3 +- sys/vm/vm_radix.c | 2 +- sys/vm/vm_zeroidle.c | 3 +- sys/x86/cpufreq/hwpstate.c | 3 +- sys/x86/iommu/intel_utils.c | 9 +- sys/x86/pci/pci_bus.c | 1 - sys/x86/x86/dump_machdep.c | 3 +- sys/x86/x86/io_apic.c | 1 - sys/x86/x86/mca.c | 2 - sys/x86/x86/tsc.c | 6 - 262 files changed, 800 insertions(+), 1386 deletions(-) (limited to 'sys/dev/usb/controller') diff --git a/sys/amd64/acpica/acpi_machdep.c b/sys/amd64/acpica/acpi_machdep.c index e5dd4c306d14d..049b51bb4e9f4 100644 --- a/sys/amd64/acpica/acpi_machdep.c +++ b/sys/amd64/acpica/acpi_machdep.c @@ -45,9 +45,8 @@ __FBSDID("$FreeBSD$"); #include int acpi_resume_beep; -TUNABLE_INT("debug.acpi.resume_beep", &acpi_resume_beep); -SYSCTL_INT(_debug_acpi, OID_AUTO, resume_beep, CTLFLAG_RW, &acpi_resume_beep, - 0, "Beep the PC speaker when resuming"); +SYSCTL_INT(_debug_acpi, OID_AUTO, resume_beep, CTLFLAG_RWTUN, + &acpi_resume_beep, 0, "Beep the PC speaker when resuming"); int acpi_reset_video; TUNABLE_INT("hw.acpi.reset_video", &acpi_reset_video); diff --git a/sys/amd64/amd64/amd64_mem.c b/sys/amd64/amd64/amd64_mem.c index e77a96f3f5541..29cf2c03d8288 100644 --- a/sys/amd64/amd64/amd64_mem.c +++ b/sys/amd64/amd64/amd64_mem.c @@ -69,7 +69,6 @@ static char *mem_owner_bios = "BIOS"; (((curr) & ~MDF_ATTRMASK) | ((new) & MDF_ATTRMASK)) static int mtrrs_disabled; -TUNABLE_INT("machdep.disable_mtrrs", &mtrrs_disabled); SYSCTL_INT(_machdep, OID_AUTO, disable_mtrrs, CTLFLAG_RDTUN, &mtrrs_disabled, 0, "Disable amd64 MTRRs."); diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index 14cb1373d12ab..b8999bd30076b 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -675,8 +675,7 @@ cpu_halt(void) void (*cpu_idle_hook)(sbintime_t) = NULL; /* ACPI idle hook. */ static int cpu_ident_amdc1e = 0; /* AMD C1E supported. */ static int idle_mwait = 1; /* Use MONITOR/MWAIT for short idle. */ -TUNABLE_INT("machdep.idle_mwait", &idle_mwait); -SYSCTL_INT(_machdep, OID_AUTO, idle_mwait, CTLFLAG_RW, &idle_mwait, +SYSCTL_INT(_machdep, OID_AUTO, idle_mwait, CTLFLAG_RWTUN, &idle_mwait, 0, "Use MONITOR/MWAIT for short idle"); #define STATE_RUNNING 0x0 diff --git a/sys/amd64/amd64/mp_watchdog.c b/sys/amd64/amd64/mp_watchdog.c index b1799a20b3db5..b03d2614d9b54 100644 --- a/sys/amd64/amd64/mp_watchdog.c +++ b/sys/amd64/amd64/mp_watchdog.c @@ -68,8 +68,7 @@ static int watchdog_dontfire = 1; static int watchdog_timer = -1; static int watchdog_nmi = 1; -TUNABLE_INT("debug.watchdog", &watchdog_cpu); -SYSCTL_INT(_debug, OID_AUTO, watchdog_nmi, CTLFLAG_RW, &watchdog_nmi, 0, +SYSCTL_INT(_debug, OID_AUTO, watchdog_nmi, CTLFLAG_RWTUN, &watchdog_nmi, 0, "IPI the boot processor with an NMI to enter the debugger"); static struct callout watchdog_callout; diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index ae0041f5048bb..74929606ac13c 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -332,8 +332,8 @@ SYSCTL_INT(_vm_pmap, OID_AUTO, pat_works, CTLFLAG_RD, &pat_works, 1, "Is page attribute table fully functional?"); static int pg_ps_enabled = 1; -SYSCTL_INT(_vm_pmap, OID_AUTO, pg_ps_enabled, CTLFLAG_RDTUN, &pg_ps_enabled, 0, - "Are large page mappings enabled?"); +SYSCTL_INT(_vm_pmap, OID_AUTO, pg_ps_enabled, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, + &pg_ps_enabled, 0, "Are large page mappings enabled?"); #define PAT_INDEX_SIZE 8 static int pat_index[PAT_INDEX_SIZE]; /* cache mode to PAT index conversion */ @@ -368,8 +368,8 @@ static int pmap_flags = PMAP_PDE_SUPERPAGE; /* flags for x86 pmaps */ static struct unrhdr pcid_unr; static struct mtx pcid_mtx; int pmap_pcid_enabled = 0; -SYSCTL_INT(_vm_pmap, OID_AUTO, pcid_enabled, CTLFLAG_RDTUN, &pmap_pcid_enabled, - 0, "Is TLB Context ID enabled ?"); +SYSCTL_INT(_vm_pmap, OID_AUTO, pcid_enabled, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, + &pmap_pcid_enabled, 0, "Is TLB Context ID enabled ?"); int invpcid_works = 0; SYSCTL_INT(_vm_pmap, OID_AUTO, invpcid_works, CTLFLAG_RD, &invpcid_works, 0, "Is the invpcid instruction available ?"); diff --git a/sys/amd64/amd64/sys_machdep.c b/sys/amd64/amd64/sys_machdep.c index 41709c2aa9290..37935cffb057c 100644 --- a/sys/amd64/amd64/sys_machdep.c +++ b/sys/amd64/amd64/sys_machdep.c @@ -73,7 +73,6 @@ static void max_ldt_segment_init(void *arg __unused) { - TUNABLE_INT_FETCH("machdep.max_ldt_segment", &max_ldt_segment); if (max_ldt_segment <= 0) max_ldt_segment = 1; if (max_ldt_segment > MAX_LD) diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c index ce0ab6a51ca65..0e5766678f6d1 100644 --- a/sys/amd64/amd64/trap.c +++ b/sys/amd64/amd64/trap.c @@ -143,20 +143,18 @@ static char *trap_msg[] = { #ifdef KDB static int kdb_on_nmi = 1; -SYSCTL_INT(_machdep, OID_AUTO, kdb_on_nmi, CTLFLAG_RW, +SYSCTL_INT(_machdep, OID_AUTO, kdb_on_nmi, CTLFLAG_RWTUN, &kdb_on_nmi, 0, "Go to KDB on NMI"); -TUNABLE_INT("machdep.kdb_on_nmi", &kdb_on_nmi); #endif static int panic_on_nmi = 1; -SYSCTL_INT(_machdep, OID_AUTO, panic_on_nmi, CTLFLAG_RW, +SYSCTL_INT(_machdep, OID_AUTO, panic_on_nmi, CTLFLAG_RWTUN, &panic_on_nmi, 0, "Panic on NMI"); -TUNABLE_INT("machdep.panic_on_nmi", &panic_on_nmi); static int prot_fault_translation; -SYSCTL_INT(_machdep, OID_AUTO, prot_fault_translation, CTLFLAG_RW, +SYSCTL_INT(_machdep, OID_AUTO, prot_fault_translation, CTLFLAG_RWTUN, &prot_fault_translation, 0, "Select signal to deliver on protection fault"); static int uprintf_signal; -SYSCTL_INT(_machdep, OID_AUTO, uprintf_signal, CTLFLAG_RW, +SYSCTL_INT(_machdep, OID_AUTO, uprintf_signal, CTLFLAG_RWTUN, &uprintf_signal, 0, "Print debugging information on trap signal to ctty"); diff --git a/sys/amd64/pci/pci_cfgreg.c b/sys/amd64/pci/pci_cfgreg.c index 706fdd381ace6..0039008b34522 100644 --- a/sys/amd64/pci/pci_cfgreg.c +++ b/sys/amd64/pci/pci_cfgreg.c @@ -65,7 +65,6 @@ static int pcie_minbus, pcie_maxbus; static uint32_t pcie_badslots; static struct mtx pcicfg_mtx; static int mcfg_enable = 1; -TUNABLE_INT("hw.pci.mcfg", &mcfg_enable); SYSCTL_INT(_hw_pci, OID_AUTO, mcfg, CTLFLAG_RDTUN, &mcfg_enable, 0, "Enable support for PCI-e memory mapped config access"); diff --git a/sys/amd64/vmm/vmm.c b/sys/amd64/vmm/vmm.c index c2a9fd1e117e7..e4c82a1c12a11 100644 --- a/sys/amd64/vmm/vmm.c +++ b/sys/amd64/vmm/vmm.c @@ -199,7 +199,6 @@ SYSCTL_NODE(_hw, OID_AUTO, vmm, CTLFLAG_RW, NULL, NULL); * interrupts disabled. */ static int halt_detection_enabled = 1; -TUNABLE_INT("hw.vmm.halt_detection", &halt_detection_enabled); SYSCTL_INT(_hw_vmm, OID_AUTO, halt_detection, CTLFLAG_RDTUN, &halt_detection_enabled, 0, "Halt VM if all vcpus execute HLT with interrupts disabled"); diff --git a/sys/arm/arm/busdma_machdep-v6.c b/sys/arm/arm/busdma_machdep-v6.c index 6cbcae439c593..f45a5d1e03a09 100644 --- a/sys/arm/arm/busdma_machdep-v6.c +++ b/sys/arm/arm/busdma_machdep-v6.c @@ -224,10 +224,10 @@ busdma_init(void *dummy) /* * This init historically used SI_SUB_VM, but now the init code requires * malloc(9) using M_DEVBUF memory, which is set up later than SI_SUB_VM, by - * SI_SUB_KMEM and SI_ORDER_SECOND, so we'll go right after that by using - * SI_SUB_KMEM and SI_ORDER_THIRD. + * SI_SUB_KMEM and SI_ORDER_THIRD, so we'll go right after that by using + * SI_SUB_KMEM and SI_ORDER_FOURTH. */ -SYSINIT(busdma, SI_SUB_KMEM, SI_ORDER_THIRD, busdma_init, NULL); +SYSINIT(busdma, SI_SUB_KMEM, SI_ORDER_FOURTH, busdma_init, NULL); static __inline int _bus_dma_can_bounce(vm_offset_t lowaddr, vm_offset_t highaddr) diff --git a/sys/arm/arm/busdma_machdep.c b/sys/arm/arm/busdma_machdep.c index 8ef8e03e7d8ad..57b58fcfa75ca 100644 --- a/sys/arm/arm/busdma_machdep.c +++ b/sys/arm/arm/busdma_machdep.c @@ -276,10 +276,10 @@ busdma_init(void *dummy) /* * This init historically used SI_SUB_VM, but now the init code requires * malloc(9) using M_DEVBUF memory, which is set up later than SI_SUB_VM, by - * SI_SUB_KMEM and SI_ORDER_SECOND, so we'll go right after that by using - * SI_SUB_KMEM and SI_ORDER_THIRD. + * SI_SUB_KMEM and SI_ORDER_THIRD, so we'll go right after that by using + * SI_SUB_KMEM and SI_ORDER_FOURTH. */ -SYSINIT(busdma, SI_SUB_KMEM, SI_ORDER_THIRD, busdma_init, NULL); +SYSINIT(busdma, SI_SUB_KMEM, SI_ORDER_FOURTH, busdma_init, NULL); /* * End block of code useful to transplant to other implementations. diff --git a/sys/arm/arm/dump_machdep.c b/sys/arm/arm/dump_machdep.c index f37346c3d0084..5056a33e28031 100644 --- a/sys/arm/arm/dump_machdep.c +++ b/sys/arm/arm/dump_machdep.c @@ -50,8 +50,7 @@ __FBSDID("$FreeBSD$"); CTASSERT(sizeof(struct kerneldumpheader) == 512); int do_minidump = 1; -TUNABLE_INT("debug.minidump", &do_minidump); -SYSCTL_INT(_debug, OID_AUTO, minidump, CTLFLAG_RW, &do_minidump, 0, +SYSCTL_INT(_debug, OID_AUTO, minidump, CTLFLAG_RWTUN, &do_minidump, 0, "Enable mini crash dumps"); /* diff --git a/sys/arm/arm/platform.c b/sys/arm/arm/platform.c index c744d7ec654e8..8dcccc7714ad3 100644 --- a/sys/arm/arm/platform.c +++ b/sys/arm/arm/platform.c @@ -65,8 +65,8 @@ static platform_t plat_obj; static struct kobj_ops plat_kernel_kops; static struct platform_kobj plat_kernel_obj; -static char plat_name[64] = ""; -SYSCTL_STRING(_hw, OID_AUTO, platform, CTLFLAG_RDTUN, plat_name, 0, +static char plat_name[64]; +SYSCTL_STRING(_hw, OID_AUTO, platform, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, plat_name, 0, "Platform currently in use"); /* diff --git a/sys/arm/arm/pmap-v6.c b/sys/arm/arm/pmap-v6.c index 67ae8ddb2b040..804469eef22d3 100644 --- a/sys/arm/arm/pmap-v6.c +++ b/sys/arm/arm/pmap-v6.c @@ -465,7 +465,7 @@ static SYSCTL_NODE(_vm, OID_AUTO, pmap, CTLFLAG_RD, 0, "VM/pmap parameters"); /* Superpages utilization enabled = 1 / disabled = 0 */ static int sp_enabled = 1; -SYSCTL_INT(_vm_pmap, OID_AUTO, sp_enabled, CTLFLAG_RDTUN, &sp_enabled, 0, +SYSCTL_INT(_vm_pmap, OID_AUTO, sp_enabled, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &sp_enabled, 0, "Are large page mappings enabled?"); SYSCTL_INT(_vm_pmap, OID_AUTO, pv_entry_count, CTLFLAG_RD, &pv_entry_count, 0, diff --git a/sys/arm/freescale/imx/imx6_anatop.c b/sys/arm/freescale/imx/imx6_anatop.c index b1757fbdf1a8c..30978381b8f05 100644 --- a/sys/arm/freescale/imx/imx6_anatop.c +++ b/sys/arm/freescale/imx/imx6_anatop.c @@ -375,12 +375,12 @@ cpufreq_initialize(struct imx6_anatop_softc *sc) "CPU frequency"); SYSCTL_ADD_PROC(NULL, SYSCTL_STATIC_CHILDREN(_hw_imx6), - OID_AUTO, "cpu_minmhz", CTLTYPE_INT | CTLFLAG_RWTUN, sc, 0, - cpufreq_sysctl_minmhz, "IU", "Minimum CPU frequency"); + OID_AUTO, "cpu_minmhz", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NOFETCH, + sc, 0, cpufreq_sysctl_minmhz, "IU", "Minimum CPU frequency"); SYSCTL_ADD_PROC(NULL, SYSCTL_STATIC_CHILDREN(_hw_imx6), - OID_AUTO, "cpu_maxmhz", CTLTYPE_INT | CTLFLAG_RWTUN, sc, 0, - cpufreq_sysctl_maxmhz, "IU", "Maximum CPU frequency"); + OID_AUTO, "cpu_maxmhz", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NOFETCH, + sc, 0, cpufreq_sysctl_maxmhz, "IU", "Maximum CPU frequency"); SYSCTL_ADD_INT(NULL, SYSCTL_STATIC_CHILDREN(_hw_imx6), OID_AUTO, "cpu_maxmhz_hw", CTLFLAG_RD, &sc->cpu_maxmhz_hw, 0, @@ -413,9 +413,6 @@ cpufreq_initialize(struct imx6_anatop_softc *sc) sc->cpu_maxmhz_hw = imx6_ocotp_mhz_tab[cfg3speed]; sc->cpu_maxmhz = sc->cpu_maxmhz_hw; - TUNABLE_INT_FETCH("hw.imx6.cpu_overclock_enable", - &sc->cpu_overclock_enable); - TUNABLE_INT_FETCH("hw.imx6.cpu_minmhz", &sc->cpu_minmhz); op = cpufreq_nearest_oppt(sc, sc->cpu_minmhz); sc->cpu_minmhz = op->mhz; diff --git a/sys/arm/xscale/ixp425/if_npe.c b/sys/arm/xscale/ixp425/if_npe.c index aae31a009ebaf..d1ef51cf812b8 100644 --- a/sys/arm/xscale/ixp425/if_npe.c +++ b/sys/arm/xscale/ixp425/if_npe.c @@ -255,9 +255,8 @@ static SYSCTL_NODE(_hw, OID_AUTO, npe, CTLFLAG_RD, 0, "IXP4XX NPE driver parameters"); static int npe_debug = 0; -SYSCTL_INT(_hw_npe, OID_AUTO, debug, CTLFLAG_RW, &npe_debug, +SYSCTL_INT(_hw_npe, OID_AUTO, debug, CTLFLAG_RWTUN, &npe_debug, 0, "IXP4XX NPE network interface debug msgs"); -TUNABLE_INT("hw.npe.debug", &npe_debug); #define DPRINTF(sc, fmt, ...) do { \ if (sc->sc_debug) device_printf(sc->sc_dev, fmt, __VA_ARGS__); \ } while (0) @@ -265,18 +264,15 @@ TUNABLE_INT("hw.npe.debug", &npe_debug); if (sc->sc_debug >= n) device_printf(sc->sc_dev, fmt, __VA_ARGS__);\ } while (0) static int npe_tickinterval = 3; /* npe_tick frequency (secs) */ -SYSCTL_INT(_hw_npe, OID_AUTO, tickinterval, CTLFLAG_RD, &npe_tickinterval, +SYSCTL_INT(_hw_npe, OID_AUTO, tickinterval, CTLFLAG_RDTUN, &npe_tickinterval, 0, "periodic work interval (secs)"); -TUNABLE_INT("hw.npe.tickinterval", &npe_tickinterval); static int npe_rxbuf = 64; /* # rx buffers to allocate */ -SYSCTL_INT(_hw_npe, OID_AUTO, rxbuf, CTLFLAG_RD, &npe_rxbuf, +SYSCTL_INT(_hw_npe, OID_AUTO, rxbuf, CTLFLAG_RDTUN, &npe_rxbuf, 0, "rx buffers allocated"); -TUNABLE_INT("hw.npe.rxbuf", &npe_rxbuf); static int npe_txbuf = 128; /* # tx buffers to allocate */ -SYSCTL_INT(_hw_npe, OID_AUTO, txbuf, CTLFLAG_RD, &npe_txbuf, +SYSCTL_INT(_hw_npe, OID_AUTO, txbuf, CTLFLAG_RDTUN, &npe_txbuf, 0, "tx buffers allocated"); -TUNABLE_INT("hw.npe.txbuf", &npe_txbuf); static int unit2npeid(int unit) diff --git a/sys/arm/xscale/ixp425/ixp425_npe.c b/sys/arm/xscale/ixp425/ixp425_npe.c index 0ccc7d0cb7f94..6dbce4ccb9548 100644 --- a/sys/arm/xscale/ixp425/ixp425_npe.c +++ b/sys/arm/xscale/ixp425/ixp425_npe.c @@ -181,9 +181,8 @@ typedef struct { } IxNpeDlNpeMgrStateInfoBlock; static int npe_debug = 0; -SYSCTL_INT(_debug, OID_AUTO, ixp425npe, CTLFLAG_RW, &npe_debug, +SYSCTL_INT(_debug, OID_AUTO, ixp425npe, CTLFLAG_RWTUN, &npe_debug, 0, "IXP4XX NPE debug msgs"); -TUNABLE_INT("debug.ixp425npe", &npe_debug); #define DPRINTF(dev, fmt, ...) do { \ if (npe_debug) device_printf(dev, fmt, __VA_ARGS__); \ } while (0) diff --git a/sys/arm/xscale/ixp425/ixp425_qmgr.c b/sys/arm/xscale/ixp425/ixp425_qmgr.c index b6fe434564e84..cb6c8defc948a 100644 --- a/sys/arm/xscale/ixp425/ixp425_qmgr.c +++ b/sys/arm/xscale/ixp425/ixp425_qmgr.c @@ -159,10 +159,9 @@ struct ixpqmgr_softc { uint32_t aqmFreeSramAddress; /* SRAM free space */ }; -static int qmgr_debug = 0; -SYSCTL_INT(_debug, OID_AUTO, qmgr, CTLFLAG_RW, &qmgr_debug, +static int qmgr_debug; +SYSCTL_INT(_debug, OID_AUTO, qmgr, CTLFLAG_RWTUN, &qmgr_debug, 0, "IXP4XX Q-Manager debug msgs"); -TUNABLE_INT("debug.qmgr", &qmgr_debug); #define DPRINTF(dev, fmt, ...) do { \ if (qmgr_debug) printf(fmt, __VA_ARGS__); \ } while (0) diff --git a/sys/cam/ata/ata_da.c b/sys/cam/ata/ata_da.c index 7d0d272c0d632..5ea981ce71e0f 100644 --- a/sys/cam/ata/ata_da.c +++ b/sys/cam/ata/ata_da.c @@ -546,30 +546,22 @@ static int ada_write_cache = ADA_DEFAULT_WRITE_CACHE; static SYSCTL_NODE(_kern_cam, OID_AUTO, ada, CTLFLAG_RD, 0, "CAM Direct Access Disk driver"); -SYSCTL_INT(_kern_cam_ada, OID_AUTO, legacy_aliases, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_ada, OID_AUTO, legacy_aliases, CTLFLAG_RWTUN, &ada_legacy_aliases, 0, "Create legacy-like device aliases"); -TUNABLE_INT("kern.cam.ada.legacy_aliases", &ada_legacy_aliases); -SYSCTL_INT(_kern_cam_ada, OID_AUTO, retry_count, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_ada, OID_AUTO, retry_count, CTLFLAG_RWTUN, &ada_retry_count, 0, "Normal I/O retry count"); -TUNABLE_INT("kern.cam.ada.retry_count", &ada_retry_count); -SYSCTL_INT(_kern_cam_ada, OID_AUTO, default_timeout, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_ada, OID_AUTO, default_timeout, CTLFLAG_RWTUN, &ada_default_timeout, 0, "Normal I/O timeout (in seconds)"); -TUNABLE_INT("kern.cam.ada.default_timeout", &ada_default_timeout); -SYSCTL_INT(_kern_cam_ada, OID_AUTO, send_ordered, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_ada, OID_AUTO, send_ordered, CTLFLAG_RWTUN, &ada_send_ordered, 0, "Send Ordered Tags"); -TUNABLE_INT("kern.cam.ada.send_ordered", &ada_send_ordered); -SYSCTL_INT(_kern_cam_ada, OID_AUTO, spindown_shutdown, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_ada, OID_AUTO, spindown_shutdown, CTLFLAG_RWTUN, &ada_spindown_shutdown, 0, "Spin down upon shutdown"); -TUNABLE_INT("kern.cam.ada.spindown_shutdown", &ada_spindown_shutdown); -SYSCTL_INT(_kern_cam_ada, OID_AUTO, spindown_suspend, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_ada, OID_AUTO, spindown_suspend, CTLFLAG_RWTUN, &ada_spindown_suspend, 0, "Spin down upon suspend"); -TUNABLE_INT("kern.cam.ada.spindown_suspend", &ada_spindown_suspend); -SYSCTL_INT(_kern_cam_ada, OID_AUTO, read_ahead, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_ada, OID_AUTO, read_ahead, CTLFLAG_RWTUN, &ada_read_ahead, 0, "Enable disk read-ahead"); -TUNABLE_INT("kern.cam.ada.read_ahead", &ada_read_ahead); -SYSCTL_INT(_kern_cam_ada, OID_AUTO, write_cache, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_ada, OID_AUTO, write_cache, CTLFLAG_RWTUN, &ada_write_cache, 0, "Enable disk write cache"); -TUNABLE_INT("kern.cam.ada.write_cache", &ada_write_cache); /* * ADA_ORDEREDTAG_INTERVAL determines how often, relative diff --git a/sys/cam/ata/ata_pmp.c b/sys/cam/ata/ata_pmp.c index bd4d25a67defd..fab0e6f1f5743 100644 --- a/sys/cam/ata/ata_pmp.c +++ b/sys/cam/ata/ata_pmp.c @@ -139,15 +139,12 @@ static int pmp_hide_special = PMP_DEFAULT_HIDE_SPECIAL; static SYSCTL_NODE(_kern_cam, OID_AUTO, pmp, CTLFLAG_RD, 0, "CAM Direct Access Disk driver"); -SYSCTL_INT(_kern_cam_pmp, OID_AUTO, retry_count, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_pmp, OID_AUTO, retry_count, CTLFLAG_RWTUN, &pmp_retry_count, 0, "Normal I/O retry count"); -TUNABLE_INT("kern.cam.pmp.retry_count", &pmp_retry_count); -SYSCTL_INT(_kern_cam_pmp, OID_AUTO, default_timeout, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_pmp, OID_AUTO, default_timeout, CTLFLAG_RWTUN, &pmp_default_timeout, 0, "Normal I/O timeout (in seconds)"); -TUNABLE_INT("kern.cam.pmp.default_timeout", &pmp_default_timeout); -SYSCTL_INT(_kern_cam_pmp, OID_AUTO, hide_special, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_pmp, OID_AUTO, hide_special, CTLFLAG_RWTUN, &pmp_hide_special, 0, "Hide extra ports"); -TUNABLE_INT("kern.cam.pmp.hide_special", &pmp_hide_special); static struct periph_driver pmpdriver = { diff --git a/sys/cam/cam.c b/sys/cam/cam.c index f608d6f887290..939dd76c30689 100644 --- a/sys/cam/cam.c +++ b/sys/cam/cam.c @@ -116,7 +116,6 @@ SYSCTL_NODE(_kern, OID_AUTO, cam, CTLFLAG_RD, 0, "CAM Subsystem"); #endif int cam_sort_io_queues = CAM_DEFAULT_SORT_IO_QUEUES; -TUNABLE_INT("kern.cam.sort_io_queues", &cam_sort_io_queues); SYSCTL_INT(_kern_cam, OID_AUTO, sort_io_queues, CTLFLAG_RWTUN, &cam_sort_io_queues, 0, "Sort IO queues to try and optimise disk access patterns"); #endif diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c index bfad6dd95cbd6..4a8f14b0f7324 100644 --- a/sys/cam/cam_xpt.c +++ b/sys/cam/cam_xpt.c @@ -149,7 +149,6 @@ typedef int xpt_pdrvfunc_t (struct periph_driver **pdrv, void *arg); /* Transport layer configuration information */ static struct xpt_softc xsoftc; -TUNABLE_INT("kern.cam.boot_delay", &xsoftc.boot_delay); SYSCTL_INT(_kern_cam, OID_AUTO, boot_delay, CTLFLAG_RDTUN, &xsoftc.boot_delay, 0, "Bus registration wait time"); @@ -163,7 +162,6 @@ static struct cam_doneq cam_doneqs[MAXCPU]; static int cam_num_doneqs; static struct proc *cam_proc; -TUNABLE_INT("kern.cam.num_doneqs", &cam_num_doneqs); SYSCTL_INT(_kern_cam, OID_AUTO, num_doneqs, CTLFLAG_RDTUN, &cam_num_doneqs, 0, "Number of completion queues/threads"); @@ -197,12 +195,10 @@ static struct cdevsw xpt_cdevsw = { /* Storage for debugging datastructures */ struct cam_path *cam_dpath; u_int32_t cam_dflags = CAM_DEBUG_FLAGS; -TUNABLE_INT("kern.cam.dflags", &cam_dflags); -SYSCTL_UINT(_kern_cam, OID_AUTO, dflags, CTLFLAG_RW, +SYSCTL_UINT(_kern_cam, OID_AUTO, dflags, CTLFLAG_RWTUN, &cam_dflags, 0, "Enabled debug flags"); u_int32_t cam_debug_delay = CAM_DEBUG_DELAY; -TUNABLE_INT("kern.cam.debug_delay", &cam_debug_delay); -SYSCTL_UINT(_kern_cam, OID_AUTO, debug_delay, CTLFLAG_RW, +SYSCTL_UINT(_kern_cam, OID_AUTO, debug_delay, CTLFLAG_RWTUN, &cam_debug_delay, 0, "Delay in us after each debug message"); /* Our boot-time initialization hook */ diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c index 7378f6525eaee..4245e4ee25515 100644 --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -308,11 +308,9 @@ static int index_to_aps_page; SYSCTL_NODE(_kern_cam, OID_AUTO, ctl, CTLFLAG_RD, 0, "CAM Target Layer"); static int worker_threads = -1; -TUNABLE_INT("kern.cam.ctl.worker_threads", &worker_threads); SYSCTL_INT(_kern_cam_ctl, OID_AUTO, worker_threads, CTLFLAG_RDTUN, &worker_threads, 1, "Number of worker threads"); static int verbose = 0; -TUNABLE_INT("kern.cam.ctl.verbose", &verbose); SYSCTL_INT(_kern_cam_ctl, OID_AUTO, verbose, CTLFLAG_RWTUN, &verbose, 0, "Show SCSI errors returned to initiator"); diff --git a/sys/cam/ctl/ctl_backend_block.c b/sys/cam/ctl/ctl_backend_block.c index 95c6788120eb7..c7ec8999b4775 100644 --- a/sys/cam/ctl/ctl_backend_block.c +++ b/sys/cam/ctl/ctl_backend_block.c @@ -220,10 +220,9 @@ struct ctl_be_block_io { }; static int cbb_num_threads = 14; -TUNABLE_INT("kern.cam.ctl.block.num_threads", &cbb_num_threads); SYSCTL_NODE(_kern_cam_ctl, OID_AUTO, block, CTLFLAG_RD, 0, "CAM Target Layer Block Backend"); -SYSCTL_INT(_kern_cam_ctl_block, OID_AUTO, num_threads, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_ctl_block, OID_AUTO, num_threads, CTLFLAG_RWTUN, &cbb_num_threads, 0, "Number of threads per backing file"); static struct ctl_be_block_io *ctl_alloc_beio(struct ctl_be_block_softc *softc); diff --git a/sys/cam/ctl/ctl_frontend_iscsi.c b/sys/cam/ctl/ctl_frontend_iscsi.c index 62840811bc32f..233433784c456 100644 --- a/sys/cam/ctl/ctl_frontend_iscsi.c +++ b/sys/cam/ctl/ctl_frontend_iscsi.c @@ -85,19 +85,15 @@ static uma_zone_t cfiscsi_data_wait_zone; SYSCTL_NODE(_kern_cam_ctl, OID_AUTO, iscsi, CTLFLAG_RD, 0, "CAM Target Layer iSCSI Frontend"); static int debug = 3; -TUNABLE_INT("kern.cam.ctl.iscsi.debug", &debug); SYSCTL_INT(_kern_cam_ctl_iscsi, OID_AUTO, debug, CTLFLAG_RWTUN, &debug, 1, "Enable debug messages"); static int ping_timeout = 5; -TUNABLE_INT("kern.cam.ctl.iscsi.ping_timeout", &ping_timeout); SYSCTL_INT(_kern_cam_ctl_iscsi, OID_AUTO, ping_timeout, CTLFLAG_RWTUN, &ping_timeout, 5, "Interval between ping (NOP-Out) requests, in seconds"); static int login_timeout = 60; -TUNABLE_INT("kern.cam.ctl.iscsi.login_timeout", &login_timeout); SYSCTL_INT(_kern_cam_ctl_iscsi, OID_AUTO, login_timeout, CTLFLAG_RWTUN, &login_timeout, 60, "Time to wait for ctld(8) to finish Login Phase, in seconds"); static int maxcmdsn_delta = 256; -TUNABLE_INT("kern.cam.ctl.iscsi.maxcmdsn_delta", &maxcmdsn_delta); SYSCTL_INT(_kern_cam_ctl_iscsi, OID_AUTO, maxcmdsn_delta, CTLFLAG_RWTUN, &maxcmdsn_delta, 256, "Number of commands the initiator can send " "without confirmation"); diff --git a/sys/cam/scsi/scsi_cd.c b/sys/cam/scsi/scsi_cd.c index 81c29a6fb54cd..47a5a438d2942 100644 --- a/sys/cam/scsi/scsi_cd.c +++ b/sys/cam/scsi/scsi_cd.c @@ -277,15 +277,12 @@ static int cd_retry_count = CD_DEFAULT_RETRY; static int cd_timeout = CD_DEFAULT_TIMEOUT; static SYSCTL_NODE(_kern_cam, OID_AUTO, cd, CTLFLAG_RD, 0, "CAM CDROM driver"); -SYSCTL_INT(_kern_cam_cd, OID_AUTO, poll_period, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_cd, OID_AUTO, poll_period, CTLFLAG_RWTUN, &cd_poll_period, 0, "Media polling period in seconds"); -TUNABLE_INT("kern.cam.cd.poll_period", &cd_poll_period); -SYSCTL_INT(_kern_cam_cd, OID_AUTO, retry_count, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_cd, OID_AUTO, retry_count, CTLFLAG_RWTUN, &cd_retry_count, 0, "Normal I/O retry count"); -TUNABLE_INT("kern.cam.cd.retry_count", &cd_retry_count); -SYSCTL_INT(_kern_cam_cd, OID_AUTO, timeout, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_cd, OID_AUTO, timeout, CTLFLAG_RWTUN, &cd_timeout, 0, "Timeout, in us, for read operations"); -TUNABLE_INT("kern.cam.cd.timeout", &cd_timeout); static MALLOC_DEFINE(M_SCSICD, "scsi_cd", "scsi_cd buffers"); diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c index 1a07577020356..0b1f8d595e366 100644 --- a/sys/cam/scsi/scsi_da.c +++ b/sys/cam/scsi/scsi_da.c @@ -1188,18 +1188,14 @@ static int da_send_ordered = DA_DEFAULT_SEND_ORDERED; static SYSCTL_NODE(_kern_cam, OID_AUTO, da, CTLFLAG_RD, 0, "CAM Direct Access Disk driver"); -SYSCTL_INT(_kern_cam_da, OID_AUTO, poll_period, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_da, OID_AUTO, poll_period, CTLFLAG_RWTUN, &da_poll_period, 0, "Media polling period in seconds"); -TUNABLE_INT("kern.cam.da.poll_period", &da_poll_period); -SYSCTL_INT(_kern_cam_da, OID_AUTO, retry_count, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_da, OID_AUTO, retry_count, CTLFLAG_RWTUN, &da_retry_count, 0, "Normal I/O retry count"); -TUNABLE_INT("kern.cam.da.retry_count", &da_retry_count); -SYSCTL_INT(_kern_cam_da, OID_AUTO, default_timeout, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_da, OID_AUTO, default_timeout, CTLFLAG_RWTUN, &da_default_timeout, 0, "Normal I/O timeout (in seconds)"); -TUNABLE_INT("kern.cam.da.default_timeout", &da_default_timeout); -SYSCTL_INT(_kern_cam_da, OID_AUTO, send_ordered, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_da, OID_AUTO, send_ordered, CTLFLAG_RWTUN, &da_send_ordered, 0, "Send Ordered Tags"); -TUNABLE_INT("kern.cam.da.send_ordered", &da_send_ordered); /* * DA_ORDEREDTAG_INTERVAL determines how often, relative diff --git a/sys/cam/scsi/scsi_enc_safte.c b/sys/cam/scsi/scsi_enc_safte.c index 8282d013bb584..89f70a5ada232 100644 --- a/sys/cam/scsi/scsi_enc_safte.c +++ b/sys/cam/scsi/scsi_enc_safte.c @@ -226,9 +226,8 @@ static char *safte_2little = "Too Little Data Returned (%d) at line %d\n"; int emulate_array_devices = 1; SYSCTL_DECL(_kern_cam_enc); -SYSCTL_INT(_kern_cam_enc, OID_AUTO, emulate_array_devices, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_enc, OID_AUTO, emulate_array_devices, CTLFLAG_RWTUN, &emulate_array_devices, 0, "Emulate Array Devices for SAF-TE"); -TUNABLE_INT("kern.cam.enc.emulate_array_devices", &emulate_array_devices); static int safte_fill_read_buf_io(enc_softc_t *enc, struct enc_fsm_state *state, diff --git a/sys/cam/scsi/scsi_sa.c b/sys/cam/scsi/scsi_sa.c index c1cd0f0bfdf60..16b7b149036f3 100644 --- a/sys/cam/scsi/scsi_sa.c +++ b/sys/cam/scsi/scsi_sa.c @@ -445,9 +445,10 @@ static int sa_allow_io_split = SA_DEFAULT_IO_SPLIT; * is bad behavior, because it hides the true tape block size from the * application. */ -TUNABLE_INT("kern.cam.sa.allow_io_split", &sa_allow_io_split); static SYSCTL_NODE(_kern_cam, OID_AUTO, sa, CTLFLAG_RD, 0, "CAM Sequential Access Tape Driver"); +SYSCTL_INT(_kern_cam_sa, OID_AUTO, allow_io_split, CTLFLAG_RDTUN, + &sa_allow_io_split, 0, "Default I/O split value"); static struct periph_driver sadriver = { @@ -1494,7 +1495,7 @@ sasysctlinit(void *context, int pending) goto bailout; SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), - OID_AUTO, "allow_io_split", CTLTYPE_INT | CTLFLAG_RDTUN, + OID_AUTO, "allow_io_split", CTLTYPE_INT | CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &softc->allow_io_split, 0, "Allow Splitting I/O"); SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "maxio", CTLTYPE_INT | CTLFLAG_RD, diff --git a/sys/cam/scsi/scsi_xpt.c b/sys/cam/scsi/scsi_xpt.c index 942f7121cf5a1..42b8774fd88ad 100644 --- a/sys/cam/scsi/scsi_xpt.c +++ b/sys/cam/scsi/scsi_xpt.c @@ -78,9 +78,8 @@ struct scsi_quirk_entry { #define SCSI_QUIRK(dev) ((struct scsi_quirk_entry *)((dev)->quirk)) static int cam_srch_hi = 0; -TUNABLE_INT("kern.cam.cam_srch_hi", &cam_srch_hi); static int sysctl_cam_search_luns(SYSCTL_HANDLER_ARGS); -SYSCTL_PROC(_kern_cam, OID_AUTO, cam_srch_hi, CTLTYPE_INT|CTLFLAG_RW, 0, 0, +SYSCTL_PROC(_kern_cam, OID_AUTO, cam_srch_hi, CTLTYPE_INT | CTLFLAG_RWTUN, 0, 0, sysctl_cam_search_luns, "I", "allow search above LUN 7 for SCSI3 and greater devices"); diff --git a/sys/cddl/compat/opensolaris/kern/opensolaris_kstat.c b/sys/cddl/compat/opensolaris/kern/opensolaris_kstat.c index ba6510992688a..03993553f6aa5 100644 --- a/sys/cddl/compat/opensolaris/kern/opensolaris_kstat.c +++ b/sys/cddl/compat/opensolaris/kern/opensolaris_kstat.c @@ -36,7 +36,7 @@ __FBSDID("$FreeBSD$"); static MALLOC_DEFINE(M_KSTAT, "kstat_data", "Kernel statistics"); -SYSCTL_NODE(, OID_AUTO, kstat, CTLFLAG_RW, 0, "Kernel statistics"); +SYSCTL_ROOT_NODE(OID_AUTO, kstat, CTLFLAG_RW, 0, "Kernel statistics"); kstat_t * kstat_create(char *module, int instance, char *name, char *class, uchar_t type, diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c index bc4989e32bded..b31d94818fde7 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c @@ -204,8 +204,6 @@ int zfs_arc_shrink_shift = 0; int zfs_arc_p_min_shift = 0; int zfs_disable_dup_eviction = 0; -TUNABLE_QUAD("vfs.zfs.arc_max", &zfs_arc_max); -TUNABLE_QUAD("vfs.zfs.arc_min", &zfs_arc_min); TUNABLE_QUAD("vfs.zfs.arc_meta_limit", &zfs_arc_meta_limit); SYSCTL_DECL(_vfs_zfs); SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, arc_max, CTLFLAG_RDTUN, &zfs_arc_max, 0, diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/ddt.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/ddt.c index 7863e6a660162..df5b77e14e898 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/ddt.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/ddt.c @@ -44,8 +44,7 @@ int zfs_dedup_prefetch = 1; SYSCTL_DECL(_vfs_zfs); SYSCTL_NODE(_vfs_zfs, OID_AUTO, dedup, CTLFLAG_RW, 0, "ZFS DEDUP"); -TUNABLE_INT("vfs.zfs.dedup.prefetch", &zfs_dedup_prefetch); -SYSCTL_INT(_vfs_zfs_dedup, OID_AUTO, prefetch, CTLFLAG_RW, &zfs_dedup_prefetch, +SYSCTL_INT(_vfs_zfs_dedup, OID_AUTO, prefetch, CTLFLAG_RWTUN, &zfs_dedup_prefetch, 0, "Enable/disable prefetching of dedup-ed blocks which are going to be freed"); static const ddt_ops_t *ddt_ops[DDT_TYPES] = { diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c index 4aa1c88d0a1d3..1b222b601889c 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c @@ -54,7 +54,6 @@ */ int zfs_nopwrite_enabled = 1; SYSCTL_DECL(_vfs_zfs); -TUNABLE_INT("vfs.zfs.nopwrite_enabled", &zfs_nopwrite_enabled); SYSCTL_INT(_vfs_zfs, OID_AUTO, nopwrite_enabled, CTLFLAG_RDTUN, &zfs_nopwrite_enabled, 0, "Enable nopwrite feature"); @@ -1626,8 +1625,7 @@ dmu_object_set_compress(objset_t *os, uint64_t object, uint8_t compress, } int zfs_mdcomp_disable = 0; -TUNABLE_INT("vfs.zfs.mdcomp_disable", &zfs_mdcomp_disable); -SYSCTL_INT(_vfs_zfs, OID_AUTO, mdcomp_disable, CTLFLAG_RW, +SYSCTL_INT(_vfs_zfs, OID_AUTO, mdcomp_disable, CTLFLAG_RWTUN, &zfs_mdcomp_disable, 0, "Disable metadata compression"); /* diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_zfetch.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_zfetch.c index d51a981c12733..0290b2815d833 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_zfetch.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_zfetch.c @@ -55,16 +55,12 @@ SYSCTL_DECL(_vfs_zfs); SYSCTL_INT(_vfs_zfs, OID_AUTO, prefetch_disable, CTLFLAG_RW, &zfs_prefetch_disable, 0, "Disable prefetch"); SYSCTL_NODE(_vfs_zfs, OID_AUTO, zfetch, CTLFLAG_RW, 0, "ZFS ZFETCH"); -TUNABLE_INT("vfs.zfs.zfetch.max_streams", &zfetch_max_streams); -SYSCTL_UINT(_vfs_zfs_zfetch, OID_AUTO, max_streams, CTLFLAG_RW, +SYSCTL_UINT(_vfs_zfs_zfetch, OID_AUTO, max_streams, CTLFLAG_RWTUN, &zfetch_max_streams, 0, "Max # of streams per zfetch"); -TUNABLE_INT("vfs.zfs.zfetch.min_sec_reap", &zfetch_min_sec_reap); SYSCTL_UINT(_vfs_zfs_zfetch, OID_AUTO, min_sec_reap, CTLFLAG_RDTUN, &zfetch_min_sec_reap, 0, "Min time before stream reclaim"); -TUNABLE_INT("vfs.zfs.zfetch.block_cap", &zfetch_block_cap); SYSCTL_UINT(_vfs_zfs_zfetch, OID_AUTO, block_cap, CTLFLAG_RDTUN, &zfetch_block_cap, 0, "Max number of blocks to fetch at a time"); -TUNABLE_QUAD("vfs.zfs.zfetch.array_rd_sz", &zfetch_array_rd_sz); SYSCTL_UQUAD(_vfs_zfs_zfetch, OID_AUTO, array_rd_sz, CTLFLAG_RDTUN, &zfetch_array_rd_sz, 0, "Number of bytes in a array_read at which we stop prefetching"); diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c index 213c2f2ca82e5..3ed8735338f39 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c @@ -141,23 +141,19 @@ extern int zfs_vdev_async_write_active_max_dirty_percent; SYSCTL_DECL(_vfs_zfs); -TUNABLE_QUAD("vfs.zfs.dirty_data_max", &zfs_dirty_data_max); SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, dirty_data_max, CTLFLAG_RWTUN, &zfs_dirty_data_max, 0, "The maximum amount of dirty data in bytes after which new writes are " "halted until space becomes available"); -TUNABLE_QUAD("vfs.zfs.dirty_data_max_max", &zfs_dirty_data_max_max); SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, dirty_data_max_max, CTLFLAG_RDTUN, &zfs_dirty_data_max_max, 0, "The absolute cap on dirty_data_max when auto calculating"); -TUNABLE_INT("vfs.zfs.dirty_data_max_percent", &zfs_dirty_data_max_percent); SYSCTL_INT(_vfs_zfs, OID_AUTO, dirty_data_max_percent, CTLFLAG_RDTUN, &zfs_dirty_data_max_percent, 0, "The percent of physical memory used to auto calculate dirty_data_max"); -TUNABLE_QUAD("vfs.zfs.dirty_data_sync", &zfs_dirty_data_sync); SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, dirty_data_sync, CTLFLAG_RWTUN, &zfs_dirty_data_sync, 0, "Force a txg if the number of dirty buffer bytes exceed this value"); diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c index c62be1adda89a..c78a1112639f5 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c @@ -71,32 +71,23 @@ boolean_t zfs_no_scrub_io = B_FALSE; /* set to disable scrub i/o */ boolean_t zfs_no_scrub_prefetch = B_FALSE; /* set to disable srub prefetching */ SYSCTL_DECL(_vfs_zfs); -TUNABLE_INT("vfs.zfs.top_maxinflight", &zfs_top_maxinflight); -SYSCTL_UINT(_vfs_zfs, OID_AUTO, top_maxinflight, CTLFLAG_RW, +SYSCTL_UINT(_vfs_zfs, OID_AUTO, top_maxinflight, CTLFLAG_RWTUN, &zfs_top_maxinflight, 0, "Maximum I/Os per top-level vdev"); -TUNABLE_INT("vfs.zfs.resilver_delay", &zfs_resilver_delay); -SYSCTL_UINT(_vfs_zfs, OID_AUTO, resilver_delay, CTLFLAG_RW, +SYSCTL_UINT(_vfs_zfs, OID_AUTO, resilver_delay, CTLFLAG_RWTUN, &zfs_resilver_delay, 0, "Number of ticks to delay resilver"); -TUNABLE_INT("vfs.zfs.scrub_delay", &zfs_scrub_delay); -SYSCTL_UINT(_vfs_zfs, OID_AUTO, scrub_delay, CTLFLAG_RW, +SYSCTL_UINT(_vfs_zfs, OID_AUTO, scrub_delay, CTLFLAG_RWTUN, &zfs_scrub_delay, 0, "Number of ticks to delay scrub"); -TUNABLE_INT("vfs.zfs.scan_idle", &zfs_scan_idle); -SYSCTL_UINT(_vfs_zfs, OID_AUTO, scan_idle, CTLFLAG_RW, +SYSCTL_UINT(_vfs_zfs, OID_AUTO, scan_idle, CTLFLAG_RWTUN, &zfs_scan_idle, 0, "Idle scan window in clock ticks"); -TUNABLE_INT("vfs.zfs.scan_min_time_ms", &zfs_scan_min_time_ms); -SYSCTL_UINT(_vfs_zfs, OID_AUTO, scan_min_time_ms, CTLFLAG_RW, +SYSCTL_UINT(_vfs_zfs, OID_AUTO, scan_min_time_ms, CTLFLAG_RWTUN, &zfs_scan_min_time_ms, 0, "Min millisecs to scrub per txg"); -TUNABLE_INT("vfs.zfs.free_min_time_ms", &zfs_free_min_time_ms); -SYSCTL_UINT(_vfs_zfs, OID_AUTO, free_min_time_ms, CTLFLAG_RW, +SYSCTL_UINT(_vfs_zfs, OID_AUTO, free_min_time_ms, CTLFLAG_RWTUN, &zfs_free_min_time_ms, 0, "Min millisecs to free per txg"); -TUNABLE_INT("vfs.zfs.resilver_min_time_ms", &zfs_resilver_min_time_ms); -SYSCTL_UINT(_vfs_zfs, OID_AUTO, resilver_min_time_ms, CTLFLAG_RW, +SYSCTL_UINT(_vfs_zfs, OID_AUTO, resilver_min_time_ms, CTLFLAG_RWTUN, &zfs_resilver_min_time_ms, 0, "Min millisecs to resilver per txg"); -TUNABLE_INT("vfs.zfs.no_scrub_io", &zfs_no_scrub_io); -SYSCTL_INT(_vfs_zfs, OID_AUTO, no_scrub_io, CTLFLAG_RW, +SYSCTL_INT(_vfs_zfs, OID_AUTO, no_scrub_io, CTLFLAG_RWTUN, &zfs_no_scrub_io, 0, "Disable scrub I/O"); -TUNABLE_INT("vfs.zfs.no_scrub_prefetch", &zfs_no_scrub_prefetch); -SYSCTL_INT(_vfs_zfs, OID_AUTO, no_scrub_prefetch, CTLFLAG_RW, +SYSCTL_INT(_vfs_zfs, OID_AUTO, no_scrub_prefetch, CTLFLAG_RWTUN, &zfs_no_scrub_prefetch, 0, "Disable scrub prefetching"); enum ddt_class zfs_scrub_ddt_class_max = DDT_CLASS_DUPLICATE; diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c index 407c6eaf429f5..93fd28edded8c 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c @@ -55,7 +55,6 @@ SYSCTL_NODE(_vfs_zfs, OID_AUTO, metaslab, CTLFLAG_RW, 0, "ZFS metaslab"); uint64_t metaslab_aliquot = 512ULL << 10; uint64_t metaslab_gang_bang = SPA_MAXBLOCKSIZE + 1; /* force gang blocks */ -TUNABLE_QUAD("vfs.zfs.metaslab.gang_bang", &metaslab_gang_bang); SYSCTL_QUAD(_vfs_zfs_metaslab, OID_AUTO, gang_bang, CTLFLAG_RWTUN, &metaslab_gang_bang, 0, "Force gang block allocation for blocks larger than or equal to this value"); @@ -67,7 +66,6 @@ SYSCTL_QUAD(_vfs_zfs_metaslab, OID_AUTO, gang_bang, CTLFLAG_RWTUN, * Values should be greater than or equal to 100. */ int zfs_condense_pct = 200; -TUNABLE_INT("vfs.zfs.condense_pct", &zfs_condense_pct); SYSCTL_INT(_vfs_zfs, OID_AUTO, condense_pct, CTLFLAG_RWTUN, &zfs_condense_pct, 0, "Condense on-disk spacemap when it is more than this many percents" @@ -87,7 +85,6 @@ SYSCTL_INT(_vfs_zfs, OID_AUTO, condense_pct, CTLFLAG_RWTUN, * no metaslab group will be excluded based on this criterion. */ int zfs_mg_noalloc_threshold = 0; -TUNABLE_INT("vfs.zfs.mg_noalloc_threshold", &zfs_mg_noalloc_threshold); SYSCTL_INT(_vfs_zfs, OID_AUTO, mg_noalloc_threshold, CTLFLAG_RWTUN, &zfs_mg_noalloc_threshold, 0, "Percentage of metaslab group size that should be free" @@ -97,7 +94,6 @@ SYSCTL_INT(_vfs_zfs, OID_AUTO, mg_noalloc_threshold, CTLFLAG_RWTUN, * When set will load all metaslabs when pool is first opened. */ int metaslab_debug_load = 0; -TUNABLE_INT("vfs.zfs.metaslab.debug_load", &metaslab_debug_load); SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, debug_load, CTLFLAG_RWTUN, &metaslab_debug_load, 0, "Load all metaslabs when pool is first opened"); @@ -106,7 +102,6 @@ SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, debug_load, CTLFLAG_RWTUN, * When set will prevent metaslabs from being unloaded. */ int metaslab_debug_unload = 0; -TUNABLE_INT("vfs.zfs.metaslab.debug_unload", &metaslab_debug_unload); SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, debug_unload, CTLFLAG_RWTUN, &metaslab_debug_unload, 0, "Prevent metaslabs from being unloaded"); @@ -118,8 +113,6 @@ SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, debug_unload, CTLFLAG_RWTUN, * aggressive strategy (i.e search by size rather than offset). */ uint64_t metaslab_df_alloc_threshold = SPA_MAXBLOCKSIZE; -TUNABLE_QUAD("vfs.zfs.metaslab.df_alloc_threshold", - &metaslab_df_alloc_threshold); SYSCTL_QUAD(_vfs_zfs_metaslab, OID_AUTO, df_alloc_threshold, CTLFLAG_RWTUN, &metaslab_df_alloc_threshold, 0, "Minimum size which forces the dynamic allocator to change it's allocation strategy"); @@ -131,27 +124,25 @@ SYSCTL_QUAD(_vfs_zfs_metaslab, OID_AUTO, df_alloc_threshold, CTLFLAG_RWTUN, * switch to using best-fit allocations. */ int metaslab_df_free_pct = 4; -TUNABLE_INT("vfs.zfs.metaslab.df_free_pct", &metaslab_df_free_pct); SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, df_free_pct, CTLFLAG_RWTUN, &metaslab_df_free_pct, 0, - "The minimum free space, in percent, which must be available in a space map to continue allocations in a first-fit fashion"); + "The minimum free space, in percent, which must be available in a " + "space map to continue allocations in a first-fit fashion"); /* * A metaslab is considered "free" if it contains a contiguous * segment which is greater than metaslab_min_alloc_size. */ uint64_t metaslab_min_alloc_size = DMU_MAX_ACCESS; -TUNABLE_QUAD("vfs.zfs.metaslab.min_alloc_size", - &metaslab_min_alloc_size); SYSCTL_QUAD(_vfs_zfs_metaslab, OID_AUTO, min_alloc_size, CTLFLAG_RWTUN, &metaslab_min_alloc_size, 0, - "A metaslab is considered \"free\" if it contains a contiguous segment which is greater than vfs.zfs.metaslab.min_alloc_size"); + "A metaslab is considered \"free\" if it contains a contiguous " + "segment which is greater than vfs.zfs.metaslab.min_alloc_size"); /* * Percentage of all cpus that can be used by the metaslab taskq. */ int metaslab_load_pct = 50; -TUNABLE_INT("vfs.zfs.metaslab.load_pct", &metaslab_load_pct); SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, load_pct, CTLFLAG_RWTUN, &metaslab_load_pct, 0, "Percentage of cpus that can be used by the metaslab taskq"); @@ -162,7 +153,6 @@ SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, load_pct, CTLFLAG_RWTUN, * keep it loaded. */ int metaslab_unload_delay = TXG_SIZE * 2; -TUNABLE_INT("vfs.zfs.metaslab.unload_delay", &metaslab_unload_delay); SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, unload_delay, CTLFLAG_RWTUN, &metaslab_unload_delay, 0, "Number of TXGs that an unused metaslab can be kept in memory"); @@ -173,13 +163,11 @@ SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, unload_delay, CTLFLAG_RWTUN, boolean_t zfs_write_to_degraded = B_FALSE; SYSCTL_INT(_vfs_zfs, OID_AUTO, write_to_degraded, CTLFLAG_RWTUN, &zfs_write_to_degraded, 0, "Allow writing data to degraded vdevs"); -TUNABLE_INT("vfs.zfs.write_to_degraded", &zfs_write_to_degraded); /* * Max number of metaslabs per group to preload. */ int metaslab_preload_limit = SPA_DVAS_PER_BP; -TUNABLE_INT("vfs.zfs.metaslab.preload_limit", &metaslab_preload_limit); SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, preload_limit, CTLFLAG_RWTUN, &metaslab_preload_limit, 0, "Max number of metaslabs per group to preload"); @@ -188,7 +176,6 @@ SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, preload_limit, CTLFLAG_RWTUN, * Enable/disable preloading of metaslab. */ boolean_t metaslab_preload_enabled = B_TRUE; -TUNABLE_INT("vfs.zfs.metaslab.preload_enabled", &metaslab_preload_enabled); SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, preload_enabled, CTLFLAG_RWTUN, &metaslab_preload_enabled, 0, "Max number of metaslabs per group to preload"); @@ -197,8 +184,6 @@ SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, preload_enabled, CTLFLAG_RWTUN, * Enable/disable additional weight factor for each metaslab. */ boolean_t metaslab_weight_factor_enable = B_FALSE; -TUNABLE_INT("vfs.zfs.metaslab.weight_factor_enable", - &metaslab_weight_factor_enable); SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, weight_factor_enable, CTLFLAG_RWTUN, &metaslab_weight_factor_enable, 0, "Enable additional weight factor for each metaslab"); diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c index 6c79a3083e2b2..097dc8635988b 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c @@ -84,8 +84,7 @@ static int check_hostid = 1; SYSCTL_DECL(_vfs_zfs); -TUNABLE_INT("vfs.zfs.check_hostid", &check_hostid); -SYSCTL_INT(_vfs_zfs, OID_AUTO, check_hostid, CTLFLAG_RW, &check_hostid, 0, +SYSCTL_INT(_vfs_zfs, OID_AUTO, check_hostid, CTLFLAG_RWTUN, &check_hostid, 0, "Check hostid on import?"); /* diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c index dbcb72916f0f3..0588fbda2d60d 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c @@ -244,7 +244,6 @@ int zfs_flags = ~(ZFS_DEBUG_DPRINTF | ZFS_DEBUG_SPA); int zfs_flags = 0; #endif SYSCTL_DECL(_debug); -TUNABLE_INT("debug.zfs_flags", &zfs_flags); SYSCTL_INT(_debug, OID_AUTO, zfs_flags, CTLFLAG_RWTUN, &zfs_flags, 0, "ZFS debug flags."); @@ -257,7 +256,6 @@ SYSCTL_INT(_debug, OID_AUTO, zfs_flags, CTLFLAG_RWTUN, &zfs_flags, 0, */ int zfs_recover = 0; SYSCTL_DECL(_vfs_zfs); -TUNABLE_INT("vfs.zfs.recover", &zfs_recover); SYSCTL_INT(_vfs_zfs, OID_AUTO, recover, CTLFLAG_RDTUN, &zfs_recover, 0, "Try to recover from otherwise-fatal errors."); @@ -270,7 +268,6 @@ SYSCTL_INT(_vfs_zfs, OID_AUTO, recover, CTLFLAG_RDTUN, &zfs_recover, 0, * in a system panic. */ uint64_t zfs_deadman_synctime_ms = 1000000ULL; -TUNABLE_QUAD("vfs.zfs.deadman_synctime_ms", &zfs_deadman_synctime_ms); SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, deadman_synctime_ms, CTLFLAG_RDTUN, &zfs_deadman_synctime_ms, 0, "Stalled ZFS I/O expiration time in milliseconds"); @@ -280,7 +277,6 @@ SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, deadman_synctime_ms, CTLFLAG_RDTUN, * for hung I/O. */ uint64_t zfs_deadman_checktime_ms = 5000ULL; -TUNABLE_QUAD("vfs.zfs.deadman_checktime_ms", &zfs_deadman_checktime_ms); SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, deadman_checktime_ms, CTLFLAG_RDTUN, &zfs_deadman_checktime_ms, 0, "Period of checks for stalled ZFS I/O in milliseconds"); @@ -290,7 +286,6 @@ SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, deadman_checktime_ms, CTLFLAG_RDTUN, * zfs_deadman_init() */ int zfs_deadman_enabled = -1; -TUNABLE_INT("vfs.zfs.deadman_enabled", &zfs_deadman_enabled); SYSCTL_INT(_vfs_zfs, OID_AUTO, deadman_enabled, CTLFLAG_RDTUN, &zfs_deadman_enabled, 0, "Kernel panic on stalled ZFS I/O"); @@ -304,7 +299,6 @@ SYSCTL_INT(_vfs_zfs, OID_AUTO, deadman_enabled, CTLFLAG_RDTUN, * (VDEV_RAIDZ_MAXPARITY + 1) * SPA_DVAS_PER_BP * 2 == 24 */ int spa_asize_inflation = 24; -TUNABLE_INT("vfs.zfs.spa_asize_inflation", &spa_asize_inflation); SYSCTL_INT(_vfs_zfs, OID_AUTO, spa_asize_inflation, CTLFLAG_RWTUN, &spa_asize_inflation, 0, "Worst case inflation factor for single sector writes"); diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c index 7e981993ca468..5c52042a0149b 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c @@ -85,31 +85,22 @@ static u_int trim_vdev_max_pending = 64; SYSCTL_DECL(_vfs_zfs); SYSCTL_NODE(_vfs_zfs, OID_AUTO, trim, CTLFLAG_RD, 0, "ZFS TRIM"); -TUNABLE_INT("vfs.zfs.trim.txg_delay", &trim_txg_delay); SYSCTL_UINT(_vfs_zfs_trim, OID_AUTO, txg_delay, CTLFLAG_RWTUN, &trim_txg_delay, 0, "Delay TRIMs by up to this many TXGs"); - -TUNABLE_INT("vfs.zfs.trim.timeout", &trim_timeout); SYSCTL_UINT(_vfs_zfs_trim, OID_AUTO, timeout, CTLFLAG_RWTUN, &trim_timeout, 0, "Delay TRIMs by up to this many seconds"); - -TUNABLE_INT("vfs.zfs.trim.max_interval", &trim_max_interval); SYSCTL_UINT(_vfs_zfs_trim, OID_AUTO, max_interval, CTLFLAG_RWTUN, &trim_max_interval, 0, "Maximum interval between TRIM queue processing (seconds)"); SYSCTL_DECL(_vfs_zfs_vdev); -TUNABLE_QUAD("vfs.zfs.vdev.trim_max_bytes", &trim_vdev_max_bytes); SYSCTL_QUAD(_vfs_zfs_vdev, OID_AUTO, trim_max_bytes, CTLFLAG_RWTUN, &trim_vdev_max_bytes, 0, "Maximum pending TRIM bytes for a vdev"); - -TUNABLE_INT("vfs.zfs.vdev.trim_max_pending", &trim_vdev_max_pending); SYSCTL_UINT(_vfs_zfs_vdev, OID_AUTO, trim_max_pending, CTLFLAG_RWTUN, &trim_vdev_max_pending, 0, "Maximum pending TRIM segments for a vdev"); - static void trim_map_vdev_commit_done(spa_t *spa, vdev_t *vd); static int diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/txg.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/txg.c index 0201bef3ae9d5..6f52266d1a2d1 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/txg.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/txg.c @@ -112,8 +112,7 @@ int zfs_txg_timeout = 5; /* max seconds worth of delta per txg */ SYSCTL_DECL(_vfs_zfs); SYSCTL_NODE(_vfs_zfs, OID_AUTO, txg, CTLFLAG_RW, 0, "ZFS TXG"); -TUNABLE_INT("vfs.zfs.txg.timeout", &zfs_txg_timeout); -SYSCTL_INT(_vfs_zfs_txg, OID_AUTO, timeout, CTLFLAG_RW, &zfs_txg_timeout, 0, +SYSCTL_INT(_vfs_zfs_txg, OID_AUTO, timeout, CTLFLAG_RWTUN, &zfs_txg_timeout, 0, "Maximum seconds worth of delta per txg"); /* diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_cache.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_cache.c index 2ad15fe8227e2..a3e9b02a71ce9 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_cache.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_cache.c @@ -90,13 +90,10 @@ int zfs_vdev_cache_bshift = 16; SYSCTL_DECL(_vfs_zfs_vdev); SYSCTL_NODE(_vfs_zfs_vdev, OID_AUTO, cache, CTLFLAG_RW, 0, "ZFS VDEV Cache"); -TUNABLE_INT("vfs.zfs.vdev.cache.max", &zfs_vdev_cache_max); SYSCTL_INT(_vfs_zfs_vdev_cache, OID_AUTO, max, CTLFLAG_RDTUN, &zfs_vdev_cache_max, 0, "Maximum I/O request size that increase read size"); -TUNABLE_INT("vfs.zfs.vdev.cache.size", &zfs_vdev_cache_size); SYSCTL_INT(_vfs_zfs_vdev_cache, OID_AUTO, size, CTLFLAG_RDTUN, &zfs_vdev_cache_size, 0, "Size of VDEV cache"); -TUNABLE_INT("vfs.zfs.vdev.cache.bshift", &zfs_vdev_cache_bshift); SYSCTL_INT(_vfs_zfs_vdev_cache, OID_AUTO, bshift, CTLFLAG_RDTUN, &zfs_vdev_cache_bshift, 0, "Turn too small requests into 1 << this value"); diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c index b64ebddbcb1a7..c38a2fc869ccb 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c @@ -53,14 +53,12 @@ DECLARE_GEOM_CLASS(zfs_vdev_class, zfs_vdev); SYSCTL_DECL(_vfs_zfs_vdev); /* Don't send BIO_FLUSH. */ -static int vdev_geom_bio_flush_disable = 0; -TUNABLE_INT("vfs.zfs.vdev.bio_flush_disable", &vdev_geom_bio_flush_disable); -SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, bio_flush_disable, CTLFLAG_RW, +static int vdev_geom_bio_flush_disable; +SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, bio_flush_disable, CTLFLAG_RWTUN, &vdev_geom_bio_flush_disable, 0, "Disable BIO_FLUSH"); /* Don't send BIO_DELETE. */ -static int vdev_geom_bio_delete_disable = 0; -TUNABLE_INT("vfs.zfs.vdev.bio_delete_disable", &vdev_geom_bio_delete_disable); -SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, bio_delete_disable, CTLFLAG_RW, +static int vdev_geom_bio_delete_disable; +SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, bio_delete_disable, CTLFLAG_RWTUN, &vdev_geom_bio_delete_disable, 0, "Disable BIO_DELETE"); static void diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_mirror.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_mirror.c index 0b8d449f4aa15..d9b15db400feb 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_mirror.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_mirror.c @@ -74,32 +74,26 @@ static SYSCTL_NODE(_vfs_zfs_vdev, OID_AUTO, mirror, CTLFLAG_RD, 0, /* Rotating media load calculation configuration. */ static int rotating_inc = 0; -TUNABLE_INT("vfs.zfs.vdev.mirror.rotating_inc", &rotating_inc); -SYSCTL_INT(_vfs_zfs_vdev_mirror, OID_AUTO, rotating_inc, CTLFLAG_RW, +SYSCTL_INT(_vfs_zfs_vdev_mirror, OID_AUTO, rotating_inc, CTLFLAG_RWTUN, &rotating_inc, 0, "Rotating media load increment for non-seeking I/O's"); static int rotating_seek_inc = 5; -TUNABLE_INT("vfs.zfs.vdev.mirror.rotating_seek_inc", &rotating_seek_inc); -SYSCTL_INT(_vfs_zfs_vdev_mirror, OID_AUTO, rotating_seek_inc, CTLFLAG_RW, +SYSCTL_INT(_vfs_zfs_vdev_mirror, OID_AUTO, rotating_seek_inc, CTLFLAG_RWTUN, &rotating_seek_inc, 0, "Rotating media load increment for seeking I/O's"); static int rotating_seek_offset = 1 * 1024 * 1024; -TUNABLE_INT("vfs.zfs.vdev.mirror.rotating_seek_offset", &rotating_seek_offset); -SYSCTL_INT(_vfs_zfs_vdev_mirror, OID_AUTO, rotating_seek_offset, CTLFLAG_RW, +SYSCTL_INT(_vfs_zfs_vdev_mirror, OID_AUTO, rotating_seek_offset, CTLFLAG_RWTUN, &rotating_seek_offset, 0, "Offset in bytes from the last I/O which " "triggers a reduced rotating media seek increment"); /* Non-rotating media load calculation configuration. */ static int non_rotating_inc = 0; -TUNABLE_INT("vfs.zfs.vdev.mirror.non_rotating_inc", &non_rotating_inc); -SYSCTL_INT(_vfs_zfs_vdev_mirror, OID_AUTO, non_rotating_inc, CTLFLAG_RW, +SYSCTL_INT(_vfs_zfs_vdev_mirror, OID_AUTO, non_rotating_inc, CTLFLAG_RWTUN, &non_rotating_inc, 0, "Non-rotating media load increment for non-seeking I/O's"); static int non_rotating_seek_inc = 1; -TUNABLE_INT("vfs.zfs.vdev.mirror.non_rotating_seek_inc", - &non_rotating_seek_inc); -SYSCTL_INT(_vfs_zfs_vdev_mirror, OID_AUTO, non_rotating_seek_inc, CTLFLAG_RW, +SYSCTL_INT(_vfs_zfs_vdev_mirror, OID_AUTO, non_rotating_seek_inc, CTLFLAG_RWTUN, &non_rotating_seek_inc, 0, "Non-rotating media load increment for seeking I/O's"); diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c index 60fd4c3eedf2f..b2e10c1105825 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c @@ -176,23 +176,18 @@ int zfs_vdev_write_gap_limit = 4 << 10; #ifdef __FreeBSD__ SYSCTL_DECL(_vfs_zfs_vdev); -TUNABLE_INT("vfs.zfs.vdev.max_active", &zfs_vdev_max_active); -SYSCTL_UINT(_vfs_zfs_vdev, OID_AUTO, max_active, CTLFLAG_RW, +SYSCTL_UINT(_vfs_zfs_vdev, OID_AUTO, max_active, CTLFLAG_RWTUN, &zfs_vdev_max_active, 0, "The maximum number of I/Os of all types active for each device."); #define ZFS_VDEV_QUEUE_KNOB_MIN(name) \ -TUNABLE_INT("vfs.zfs.vdev." #name "_min_active", \ - &zfs_vdev_ ## name ## _min_active); \ -SYSCTL_UINT(_vfs_zfs_vdev, OID_AUTO, name ## _min_active, CTLFLAG_RW, \ +SYSCTL_UINT(_vfs_zfs_vdev, OID_AUTO, name ## _min_active, CTLFLAG_RWTUN,\ &zfs_vdev_ ## name ## _min_active, 0, \ "Initial number of I/O requests of type " #name \ " active for each device"); #define ZFS_VDEV_QUEUE_KNOB_MAX(name) \ -TUNABLE_INT("vfs.zfs.vdev." #name "_max_active", \ - &zfs_vdev_ ## name ## _max_active); \ -SYSCTL_UINT(_vfs_zfs_vdev, OID_AUTO, name ## _max_active, CTLFLAG_RW, \ +SYSCTL_UINT(_vfs_zfs_vdev, OID_AUTO, name ## _max_active, CTLFLAG_RWTUN,\ &zfs_vdev_ ## name ## _max_active, 0, \ "Maximum number of I/O requests of type " #name \ " active for each device"); @@ -212,16 +207,13 @@ ZFS_VDEV_QUEUE_KNOB_MAX(trim); #undef ZFS_VDEV_QUEUE_KNOB -TUNABLE_INT("vfs.zfs.vdev.aggregation_limit", &zfs_vdev_aggregation_limit); -SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, aggregation_limit, CTLFLAG_RW, +SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, aggregation_limit, CTLFLAG_RWTUN, &zfs_vdev_aggregation_limit, 0, "I/O requests are aggregated up to this size"); -TUNABLE_INT("vfs.zfs.vdev.read_gap_limit", &zfs_vdev_read_gap_limit); -SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, read_gap_limit, CTLFLAG_RW, +SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, read_gap_limit, CTLFLAG_RWTUN, &zfs_vdev_read_gap_limit, 0, "Acceptable gap between two reads being aggregated"); -TUNABLE_INT("vfs.zfs.vdev.write_gap_limit", &zfs_vdev_write_gap_limit); -SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, write_gap_limit, CTLFLAG_RW, +SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, write_gap_limit, CTLFLAG_RWTUN, &zfs_vdev_write_gap_limit, 0, "Acceptable gap between two writes being aggregated"); #endif diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c index 4f7c082cbefe0..6b5b86de737dc 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c @@ -195,8 +195,7 @@ CTASSERT(sizeof(zfs_cmd_t) < IOCPARM_MAX); static int snapshot_list_prefetch; SYSCTL_DECL(_vfs_zfs); -TUNABLE_INT("vfs.zfs.snapshot_list_prefetch", &snapshot_list_prefetch); -SYSCTL_INT(_vfs_zfs, OID_AUTO, snapshot_list_prefetch, CTLFLAG_RW, +SYSCTL_INT(_vfs_zfs, OID_AUTO, snapshot_list_prefetch, CTLFLAG_RWTUN, &snapshot_list_prefetch, 0, "Prefetch data when listing snapshots"); static struct cdev *zfsdev; diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c index 7ce41a137a199..5f2cf3f142033 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c @@ -74,8 +74,7 @@ SYSCTL_INT(_vfs_zfs, OID_AUTO, super_owner, CTLFLAG_RW, &zfs_super_owner, 0, "File system owner can perform privileged operation on his file systems"); int zfs_debug_level; -TUNABLE_INT("vfs.zfs.debug", &zfs_debug_level); -SYSCTL_INT(_vfs_zfs, OID_AUTO, debug, CTLFLAG_RW, &zfs_debug_level, 0, +SYSCTL_INT(_vfs_zfs, OID_AUTO, debug, CTLFLAG_RWTUN, &zfs_debug_level, 0, "Debug level"); SYSCTL_NODE(_vfs_zfs, OID_AUTO, version, CTLFLAG_RD, 0, "ZFS versions"); diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c index ea5bb13a77791..c17c96fbba584 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c @@ -70,8 +70,7 @@ */ int zil_replay_disable = 0; SYSCTL_DECL(_vfs_zfs); -TUNABLE_INT("vfs.zfs.zil_replay_disable", &zil_replay_disable); -SYSCTL_INT(_vfs_zfs, OID_AUTO, zil_replay_disable, CTLFLAG_RW, +SYSCTL_INT(_vfs_zfs, OID_AUTO, zil_replay_disable, CTLFLAG_RWTUN, &zil_replay_disable, 0, "Disable intent logging replay"); /* @@ -80,12 +79,10 @@ SYSCTL_INT(_vfs_zfs, OID_AUTO, zil_replay_disable, CTLFLAG_RW, * out-of-order write cache is enabled. */ boolean_t zfs_nocacheflush = B_FALSE; -TUNABLE_INT("vfs.zfs.cache_flush_disable", &zfs_nocacheflush); SYSCTL_INT(_vfs_zfs, OID_AUTO, cache_flush_disable, CTLFLAG_RDTUN, &zfs_nocacheflush, 0, "Disable cache flush"); boolean_t zfs_trim_enabled = B_TRUE; SYSCTL_DECL(_vfs_zfs_trim); -TUNABLE_INT("vfs.zfs.trim.enabled", &zfs_trim_enabled); SYSCTL_INT(_vfs_zfs_trim, OID_AUTO, enabled, CTLFLAG_RDTUN, &zfs_trim_enabled, 0, "Enable ZFS TRIM"); diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c index 01946fb2b553d..ba326489ce69d 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c @@ -46,11 +46,9 @@ static int zio_use_uma = 1; #else static int zio_use_uma = 0; #endif -TUNABLE_INT("vfs.zfs.zio.use_uma", &zio_use_uma); SYSCTL_INT(_vfs_zfs_zio, OID_AUTO, use_uma, CTLFLAG_RDTUN, &zio_use_uma, 0, "Use uma(9) for ZIO allocations"); static int zio_exclude_metadata = 0; -TUNABLE_INT("vfs.zfs.zio.exclude_metadata", &zio_exclude_metadata); SYSCTL_INT(_vfs_zfs_zio, OID_AUTO, exclude_metadata, CTLFLAG_RDTUN, &zio_exclude_metadata, 0, "Exclude metadata buffers from dumps as well"); @@ -104,15 +102,12 @@ extern vmem_t *zio_alloc_arena; * regular blocks are not deferred. */ int zfs_sync_pass_deferred_free = 2; /* defer frees starting in this pass */ -TUNABLE_INT("vfs.zfs.sync_pass_deferred_free", &zfs_sync_pass_deferred_free); SYSCTL_INT(_vfs_zfs, OID_AUTO, sync_pass_deferred_free, CTLFLAG_RDTUN, &zfs_sync_pass_deferred_free, 0, "defer frees starting in this pass"); int zfs_sync_pass_dont_compress = 5; /* don't compress starting in this pass */ -TUNABLE_INT("vfs.zfs.sync_pass_dont_compress", &zfs_sync_pass_dont_compress); SYSCTL_INT(_vfs_zfs, OID_AUTO, sync_pass_dont_compress, CTLFLAG_RDTUN, &zfs_sync_pass_dont_compress, 0, "don't compress starting in this pass"); int zfs_sync_pass_rewrite = 2; /* rewrite new bps starting in this pass */ -TUNABLE_INT("vfs.zfs.sync_pass_rewrite", &zfs_sync_pass_rewrite); SYSCTL_INT(_vfs_zfs, OID_AUTO, sync_pass_rewrite, CTLFLAG_RDTUN, &zfs_sync_pass_rewrite, 0, "rewrite new bps starting in this pass"); diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c index fb3789f45b119..53877d7a6b26b 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c @@ -119,7 +119,6 @@ static uint32_t zvol_minors; SYSCTL_DECL(_vfs_zfs); SYSCTL_NODE(_vfs_zfs, OID_AUTO, vol, CTLFLAG_RW, 0, "ZFS VOLUME"); static int volmode = ZFS_VOLMODE_GEOM; -TUNABLE_INT("vfs.zfs.vol.mode", &volmode); SYSCTL_INT(_vfs_zfs_vol, OID_AUTO, mode, CTLFLAG_RWTUN, &volmode, 0, "Expose as GEOM providers (1), device files (2) or neither"); diff --git a/sys/cddl/dev/dtrace/dtrace_sysctl.c b/sys/cddl/dev/dtrace/dtrace_sysctl.c index d98111d4184b2..9f8b14fd1c661 100644 --- a/sys/cddl/dev/dtrace/dtrace_sysctl.c +++ b/sys/cddl/dev/dtrace/dtrace_sysctl.c @@ -25,8 +25,7 @@ SYSCTL_NODE(_debug, OID_AUTO, dtrace, CTLFLAG_RD, 0, "DTrace debug parameters"); int dtrace_debug = 0; -TUNABLE_INT("debug.dtrace.debug", &dtrace_debug); -SYSCTL_INT(_debug_dtrace, OID_AUTO, debug, CTLFLAG_RW, &dtrace_debug, 0, ""); +SYSCTL_INT(_debug_dtrace, OID_AUTO, debug, CTLFLAG_RWTUN, &dtrace_debug, 0, ""); /* Report registered DTrace providers. */ static int diff --git a/sys/compat/ia32/ia32_sysvec.c b/sys/compat/ia32/ia32_sysvec.c index a8e52e82eefa4..770bbbf9e4623 100644 --- a/sys/compat/ia32/ia32_sysvec.c +++ b/sys/compat/ia32/ia32_sysvec.c @@ -89,14 +89,11 @@ extern const char *freebsd32_syscallnames[]; static SYSCTL_NODE(_compat, OID_AUTO, ia32, CTLFLAG_RW, 0, "ia32 mode"); static u_long ia32_maxdsiz = IA32_MAXDSIZ; -SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxdsiz, CTLFLAG_RW, &ia32_maxdsiz, 0, ""); -TUNABLE_ULONG("compat.ia32.maxdsiz", &ia32_maxdsiz); +SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxdsiz, CTLFLAG_RWTUN, &ia32_maxdsiz, 0, ""); u_long ia32_maxssiz = IA32_MAXSSIZ; -SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxssiz, CTLFLAG_RW, &ia32_maxssiz, 0, ""); -TUNABLE_ULONG("compat.ia32.maxssiz", &ia32_maxssiz); +SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxssiz, CTLFLAG_RWTUN, &ia32_maxssiz, 0, ""); static u_long ia32_maxvmem = IA32_MAXVMEM; -SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxvmem, CTLFLAG_RW, &ia32_maxvmem, 0, ""); -TUNABLE_ULONG("compat.ia32.maxvmem", &ia32_maxvmem); +SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxvmem, CTLFLAG_RWTUN, &ia32_maxvmem, 0, ""); struct sysentvec ia32_freebsd_sysvec = { .sv_size = FREEBSD32_SYS_MAXSYSCALL, diff --git a/sys/compat/x86bios/x86bios.c b/sys/compat/x86bios/x86bios.c index 32b992974c9de..5cd31e8a71bb2 100644 --- a/sys/compat/x86bios/x86bios.c +++ b/sys/compat/x86bios/x86bios.c @@ -70,12 +70,10 @@ static struct mtx x86bios_lock; static SYSCTL_NODE(_debug, OID_AUTO, x86bios, CTLFLAG_RD, NULL, "x86bios debugging"); static int x86bios_trace_call; -TUNABLE_INT("debug.x86bios.call", &x86bios_trace_call); -SYSCTL_INT(_debug_x86bios, OID_AUTO, call, CTLFLAG_RW, &x86bios_trace_call, 0, +SYSCTL_INT(_debug_x86bios, OID_AUTO, call, CTLFLAG_RWTUN, &x86bios_trace_call, 0, "Trace far function calls"); static int x86bios_trace_int; -TUNABLE_INT("debug.x86bios.int", &x86bios_trace_int); -SYSCTL_INT(_debug_x86bios, OID_AUTO, int, CTLFLAG_RW, &x86bios_trace_int, 0, +SYSCTL_INT(_debug_x86bios, OID_AUTO, int, CTLFLAG_RWTUN, &x86bios_trace_int, 0, "Trace software interrupt handlers"); #ifdef X86BIOS_NATIVE_VM86 diff --git a/sys/dev/aac/aac_pci.c b/sys/dev/aac/aac_pci.c index ccf537ed31f65..83e7e63fda8e0 100644 --- a/sys/dev/aac/aac_pci.c +++ b/sys/dev/aac/aac_pci.c @@ -61,7 +61,6 @@ static int aac_pci_probe(device_t dev); static int aac_pci_attach(device_t dev); static int aac_enable_msi = 1; -TUNABLE_INT("hw.aac.enable_msi", &aac_enable_msi); SYSCTL_INT(_hw_aac, OID_AUTO, enable_msi, CTLFLAG_RDTUN, &aac_enable_msi, 0, "Enable MSI interrupts"); diff --git a/sys/dev/acpica/Osd/OsdSchedule.c b/sys/dev/acpica/Osd/OsdSchedule.c index e5d3d51d19fea..d49f886c9b8b4 100644 --- a/sys/dev/acpica/Osd/OsdSchedule.c +++ b/sys/dev/acpica/Osd/OsdSchedule.c @@ -56,7 +56,6 @@ ACPI_MODULE_NAME("SCHEDULE") * Allow the user to tune the maximum number of tasks we may enqueue. */ static int acpi_max_tasks = ACPI_MAX_TASKS; -TUNABLE_INT("debug.acpi.max_tasks", &acpi_max_tasks); SYSCTL_INT(_debug_acpi, OID_AUTO, max_tasks, CTLFLAG_RDTUN, &acpi_max_tasks, 0, "Maximum acpi tasks"); @@ -65,7 +64,6 @@ SYSCTL_INT(_debug_acpi, OID_AUTO, max_tasks, CTLFLAG_RDTUN, &acpi_max_tasks, * some systems have problems with increased parallelism. */ static int acpi_max_threads = ACPI_MAX_THREADS; -TUNABLE_INT("debug.acpi.max_threads", &acpi_max_threads); SYSCTL_INT(_debug_acpi, OID_AUTO, max_threads, CTLFLAG_RDTUN, &acpi_max_threads, 0, "Maximum acpi threads"); diff --git a/sys/dev/acpica/acpi_cpu.c b/sys/dev/acpica/acpi_cpu.c index f95510cf69019..5cb22a9fbc1a1 100644 --- a/sys/dev/acpica/acpi_cpu.c +++ b/sys/dev/acpica/acpi_cpu.c @@ -129,7 +129,6 @@ struct acpi_cpu_device { /* Allow users to ignore processor orders in MADT. */ static int cpu_unordered; -TUNABLE_INT("debug.acpi.cpu_unordered", &cpu_unordered); SYSCTL_INT(_debug_acpi, OID_AUTO, cpu_unordered, CTLFLAG_RDTUN, &cpu_unordered, 0, "Do not use the MADT to match ACPI Processor objects to CPUs."); diff --git a/sys/dev/acpica/acpi_ec.c b/sys/dev/acpica/acpi_ec.c index 6e2f0dd284634..6537e4062b4d3 100644 --- a/sys/dev/acpica/acpi_ec.c +++ b/sys/dev/acpica/acpi_ec.c @@ -181,16 +181,13 @@ ACPI_SERIAL_DECL(ec, "ACPI embedded controller"); static SYSCTL_NODE(_debug_acpi, OID_AUTO, ec, CTLFLAG_RD, NULL, "EC debugging"); static int ec_burst_mode; -TUNABLE_INT("debug.acpi.ec.burst", &ec_burst_mode); -SYSCTL_INT(_debug_acpi_ec, OID_AUTO, burst, CTLFLAG_RW, &ec_burst_mode, 0, +SYSCTL_INT(_debug_acpi_ec, OID_AUTO, burst, CTLFLAG_RWTUN, &ec_burst_mode, 0, "Enable use of burst mode (faster for nearly all systems)"); static int ec_polled_mode; -TUNABLE_INT("debug.acpi.ec.polled", &ec_polled_mode); -SYSCTL_INT(_debug_acpi_ec, OID_AUTO, polled, CTLFLAG_RW, &ec_polled_mode, 0, +SYSCTL_INT(_debug_acpi_ec, OID_AUTO, polled, CTLFLAG_RWTUN, &ec_polled_mode, 0, "Force use of polled mode (only if interrupt mode doesn't work)"); static int ec_timeout = EC_TIMEOUT; -TUNABLE_INT("debug.acpi.ec.timeout", &ec_timeout); -SYSCTL_INT(_debug_acpi_ec, OID_AUTO, timeout, CTLFLAG_RW, &ec_timeout, +SYSCTL_INT(_debug_acpi_ec, OID_AUTO, timeout, CTLFLAG_RWTUN, &ec_timeout, EC_TIMEOUT, "Total time spent waiting for a response (poll+sleep)"); static ACPI_STATUS diff --git a/sys/dev/amr/amr_pci.c b/sys/dev/amr/amr_pci.c index 81ddc32c7cdec..9346e8c5090b5 100644 --- a/sys/dev/amr/amr_pci.c +++ b/sys/dev/amr/amr_pci.c @@ -92,7 +92,6 @@ static int amr_setup_mbox(struct amr_softc *sc); static int amr_ccb_map(struct amr_softc *sc); static u_int amr_force_sg32 = 0; -TUNABLE_INT("hw.amr.force_sg32", &amr_force_sg32); SYSCTL_DECL(_hw_amr); SYSCTL_UINT(_hw_amr, OID_AUTO, force_sg32, CTLFLAG_RDTUN, &amr_force_sg32, 0, "Force the AMR driver to use 32bit scatter gather"); diff --git a/sys/dev/ata/ata-all.c b/sys/dev/ata/ata-all.c index b45c868d63f70..579a2c5e6f7aa 100644 --- a/sys/dev/ata/ata-all.c +++ b/sys/dev/ata/ata-all.c @@ -80,9 +80,8 @@ int ata_dma_check_80pin = 1; /* sysctl vars */ static SYSCTL_NODE(_hw, OID_AUTO, ata, CTLFLAG_RD, 0, "ATA driver parameters"); -TUNABLE_INT("hw.ata.ata_dma_check_80pin", &ata_dma_check_80pin); SYSCTL_INT(_hw_ata, OID_AUTO, ata_dma_check_80pin, - CTLFLAG_RW, &ata_dma_check_80pin, 1, + CTLFLAG_RWTUN, &ata_dma_check_80pin, 0, "Check for 80pin cable before setting ATA DMA mode"); FEATURE(ata_cam, "ATA devices are accessed through the cam(4) driver"); diff --git a/sys/dev/ath/ah_osdep.c b/sys/dev/ath/ah_osdep.c index 8e9edd139be47..fe4a657c98c85 100644 --- a/sys/dev/ath/ah_osdep.c +++ b/sys/dev/ath/ah_osdep.c @@ -96,9 +96,8 @@ static SYSCTL_NODE(_hw_ath, OID_AUTO, hal, CTLFLAG_RD, 0, #ifdef AH_DEBUG int ath_hal_debug = 0; -SYSCTL_INT(_hw_ath_hal, OID_AUTO, debug, CTLFLAG_RW, &ath_hal_debug, +SYSCTL_INT(_hw_ath_hal, OID_AUTO, debug, CTLFLAG_RWTUN, &ath_hal_debug, 0, "Atheros HAL debugging printfs"); -TUNABLE_INT("hw.ath.hal.debug", &ath_hal_debug); #endif /* AH_DEBUG */ static MALLOC_DEFINE(M_ATH_HAL, "ath_hal", "ath hal data"); diff --git a/sys/dev/ath/if_ath.c b/sys/dev/ath/if_ath.c index a3ab2f61dbfa3..f176b6391b63f 100644 --- a/sys/dev/ath/if_ath.c +++ b/sys/dev/ath/if_ath.c @@ -240,17 +240,14 @@ SYSCTL_INT(_hw_ath, OID_AUTO, anical, CTLFLAG_RW, &ath_anicalinterval, 0, "ANI calibration (msecs)"); int ath_rxbuf = ATH_RXBUF; /* # rx buffers to allocate */ -SYSCTL_INT(_hw_ath, OID_AUTO, rxbuf, CTLFLAG_RW, &ath_rxbuf, +SYSCTL_INT(_hw_ath, OID_AUTO, rxbuf, CTLFLAG_RWTUN, &ath_rxbuf, 0, "rx buffers allocated"); -TUNABLE_INT("hw.ath.rxbuf", &ath_rxbuf); int ath_txbuf = ATH_TXBUF; /* # tx buffers to allocate */ -SYSCTL_INT(_hw_ath, OID_AUTO, txbuf, CTLFLAG_RW, &ath_txbuf, +SYSCTL_INT(_hw_ath, OID_AUTO, txbuf, CTLFLAG_RWTUN, &ath_txbuf, 0, "tx buffers allocated"); -TUNABLE_INT("hw.ath.txbuf", &ath_txbuf); int ath_txbuf_mgmt = ATH_MGMT_TXBUF; /* # mgmt tx buffers to allocate */ -SYSCTL_INT(_hw_ath, OID_AUTO, txbuf_mgmt, CTLFLAG_RW, &ath_txbuf_mgmt, +SYSCTL_INT(_hw_ath, OID_AUTO, txbuf_mgmt, CTLFLAG_RWTUN, &ath_txbuf_mgmt, 0, "tx (mgmt) buffers allocated"); -TUNABLE_INT("hw.ath.txbuf_mgmt", &ath_txbuf_mgmt); int ath_bstuck_threshold = 4; /* max missed beacons */ SYSCTL_INT(_hw_ath, OID_AUTO, bstuck, CTLFLAG_RW, &ath_bstuck_threshold, diff --git a/sys/dev/ath/if_ath_debug.c b/sys/dev/ath/if_ath_debug.c index e3c73f561b8bc..d21ad6fea6f02 100644 --- a/sys/dev/ath/if_ath_debug.c +++ b/sys/dev/ath/if_ath_debug.c @@ -92,9 +92,8 @@ __FBSDID("$FreeBSD$"); uint64_t ath_debug = 0; SYSCTL_DECL(_hw_ath); -SYSCTL_QUAD(_hw_ath, OID_AUTO, debug, CTLFLAG_RW, &ath_debug, +SYSCTL_QUAD(_hw_ath, OID_AUTO, debug, CTLFLAG_RWTUN, &ath_debug, 0, "control debugging printfs"); -TUNABLE_QUAD("hw.ath.debug", &ath_debug); void ath_printrxbuf(struct ath_softc *sc, const struct ath_buf *bf, diff --git a/sys/dev/bce/if_bce.c b/sys/dev/bce/if_bce.c index c888b499b19f9..dfb1dc4a52493 100644 --- a/sys/dev/bce/if_bce.c +++ b/sys/dev/bce/if_bce.c @@ -535,44 +535,37 @@ static SYSCTL_NODE(_hw, OID_AUTO, bce, CTLFLAG_RD, 0, "bce driver parameters"); /* Allowable values are TRUE or FALSE */ static int bce_verbose = TRUE; -TUNABLE_INT("hw.bce.verbose", &bce_verbose); SYSCTL_INT(_hw_bce, OID_AUTO, verbose, CTLFLAG_RDTUN, &bce_verbose, 0, "Verbose output enable/disable"); /* Allowable values are TRUE or FALSE */ static int bce_tso_enable = TRUE; -TUNABLE_INT("hw.bce.tso_enable", &bce_tso_enable); SYSCTL_INT(_hw_bce, OID_AUTO, tso_enable, CTLFLAG_RDTUN, &bce_tso_enable, 0, "TSO Enable/Disable"); /* Allowable values are 0 (IRQ), 1 (MSI/IRQ), and 2 (MSI-X/MSI/IRQ) */ /* ToDo: Add MSI-X support. */ static int bce_msi_enable = 1; -TUNABLE_INT("hw.bce.msi_enable", &bce_msi_enable); SYSCTL_INT(_hw_bce, OID_AUTO, msi_enable, CTLFLAG_RDTUN, &bce_msi_enable, 0, "MSI-X|MSI|INTx selector"); /* Allowable values are 1, 2, 4, 8. */ static int bce_rx_pages = DEFAULT_RX_PAGES; -TUNABLE_INT("hw.bce.rx_pages", &bce_rx_pages); SYSCTL_UINT(_hw_bce, OID_AUTO, rx_pages, CTLFLAG_RDTUN, &bce_rx_pages, 0, "Receive buffer descriptor pages (1 page = 255 buffer descriptors)"); /* Allowable values are 1, 2, 4, 8. */ static int bce_tx_pages = DEFAULT_TX_PAGES; -TUNABLE_INT("hw.bce.tx_pages", &bce_tx_pages); SYSCTL_UINT(_hw_bce, OID_AUTO, tx_pages, CTLFLAG_RDTUN, &bce_tx_pages, 0, "Transmit buffer descriptor pages (1 page = 255 buffer descriptors)"); /* Allowable values are TRUE or FALSE. */ static int bce_hdr_split = TRUE; -TUNABLE_INT("hw.bce.hdr_split", &bce_hdr_split); SYSCTL_UINT(_hw_bce, OID_AUTO, hdr_split, CTLFLAG_RDTUN, &bce_hdr_split, 0, "Frame header/payload splitting Enable/Disable"); /* Allowable values are TRUE or FALSE. */ static int bce_strict_rx_mtu = FALSE; -TUNABLE_INT("hw.bce.strict_rx_mtu", &bce_strict_rx_mtu); SYSCTL_UINT(_hw_bce, OID_AUTO, strict_rx_mtu, CTLFLAG_RDTUN, &bce_strict_rx_mtu, 0, "Enable/Disable strict RX frame size checking"); @@ -585,7 +578,6 @@ static int bce_tx_quick_cons_trip_int = 1; /* Generate 1 interrupt for every 20 transmit completions. */ static int bce_tx_quick_cons_trip_int = DEFAULT_TX_QUICK_CONS_TRIP_INT; #endif -TUNABLE_INT("hw.bce.tx_quick_cons_trip_int", &bce_tx_quick_cons_trip_int); SYSCTL_UINT(_hw_bce, OID_AUTO, tx_quick_cons_trip_int, CTLFLAG_RDTUN, &bce_tx_quick_cons_trip_int, 0, "Transmit BD trip point during interrupts"); @@ -598,7 +590,6 @@ static int bce_tx_quick_cons_trip = 1; /* Generate 1 interrupt for every 20 transmit completions. */ static int bce_tx_quick_cons_trip = DEFAULT_TX_QUICK_CONS_TRIP; #endif -TUNABLE_INT("hw.bce.tx_quick_cons_trip", &bce_tx_quick_cons_trip); SYSCTL_UINT(_hw_bce, OID_AUTO, tx_quick_cons_trip, CTLFLAG_RDTUN, &bce_tx_quick_cons_trip, 0, "Transmit BD trip point"); @@ -611,7 +602,6 @@ static int bce_tx_ticks_int = 0; /* Generate an interrupt if 80us have elapsed since the last TX completion. */ static int bce_tx_ticks_int = DEFAULT_TX_TICKS_INT; #endif -TUNABLE_INT("hw.bce.tx_ticks_int", &bce_tx_ticks_int); SYSCTL_UINT(_hw_bce, OID_AUTO, tx_ticks_int, CTLFLAG_RDTUN, &bce_tx_ticks_int, 0, "Transmit ticks count during interrupt"); @@ -623,7 +613,6 @@ static int bce_tx_ticks = 0; /* Generate an interrupt if 80us have elapsed since the last TX completion. */ static int bce_tx_ticks = DEFAULT_TX_TICKS; #endif -TUNABLE_INT("hw.bce.tx_ticks", &bce_tx_ticks); SYSCTL_UINT(_hw_bce, OID_AUTO, tx_ticks, CTLFLAG_RDTUN, &bce_tx_ticks, 0, "Transmit ticks count"); @@ -635,7 +624,6 @@ static int bce_rx_quick_cons_trip_int = 1; /* Generate 1 interrupt for every 6 received frames. */ static int bce_rx_quick_cons_trip_int = DEFAULT_RX_QUICK_CONS_TRIP_INT; #endif -TUNABLE_INT("hw.bce.rx_quick_cons_trip_int", &bce_rx_quick_cons_trip_int); SYSCTL_UINT(_hw_bce, OID_AUTO, rx_quick_cons_trip_int, CTLFLAG_RDTUN, &bce_rx_quick_cons_trip_int, 0, "Receive BD trip point duirng interrupts"); @@ -648,7 +636,6 @@ static int bce_rx_quick_cons_trip = 1; /* Generate 1 interrupt for every 6 received frames. */ static int bce_rx_quick_cons_trip = DEFAULT_RX_QUICK_CONS_TRIP; #endif -TUNABLE_INT("hw.bce.rx_quick_cons_trip", &bce_rx_quick_cons_trip); SYSCTL_UINT(_hw_bce, OID_AUTO, rx_quick_cons_trip, CTLFLAG_RDTUN, &bce_rx_quick_cons_trip, 0, "Receive BD trip point"); @@ -661,7 +648,6 @@ static int bce_rx_ticks_int = 0; /* Generate an int. if 18us have elapsed since the last received frame. */ static int bce_rx_ticks_int = DEFAULT_RX_TICKS_INT; #endif -TUNABLE_INT("hw.bce.rx_ticks_int", &bce_rx_ticks_int); SYSCTL_UINT(_hw_bce, OID_AUTO, rx_ticks_int, CTLFLAG_RDTUN, &bce_rx_ticks_int, 0, "Receive ticks count during interrupt"); @@ -673,7 +659,6 @@ static int bce_rx_ticks = 0; /* Generate an int. if 18us have elapsed since the last received frame. */ static int bce_rx_ticks = DEFAULT_RX_TICKS; #endif -TUNABLE_INT("hw.bce.rx_ticks", &bce_rx_ticks); SYSCTL_UINT(_hw_bce, OID_AUTO, rx_ticks, CTLFLAG_RDTUN, &bce_rx_ticks, 0, "Receive ticks count"); diff --git a/sys/dev/bge/if_bge.c b/sys/dev/bge/if_bge.c index 40f562ede6de2..e236771bcaa92 100644 --- a/sys/dev/bge/if_bge.c +++ b/sys/dev/bge/if_bge.c @@ -542,10 +542,8 @@ DRIVER_MODULE(miibus, bge, miibus_driver, miibus_devclass, 0, 0); static int bge_allow_asf = 1; -TUNABLE_INT("hw.bge.allow_asf", &bge_allow_asf); - static SYSCTL_NODE(_hw, OID_AUTO, bge, CTLFLAG_RD, 0, "BGE driver parameters"); -SYSCTL_INT(_hw_bge, OID_AUTO, allow_asf, CTLFLAG_RD, &bge_allow_asf, 0, +SYSCTL_INT(_hw_bge, OID_AUTO, allow_asf, CTLFLAG_RDTUN, &bge_allow_asf, 0, "Allow ASF mode if available"); #define SPARC64_BLADE_1500_MODEL "SUNW,Sun-Blade-1500" @@ -6237,7 +6235,6 @@ bge_add_sysctls(struct bge_softc *sc) { struct sysctl_ctx_list *ctx; struct sysctl_oid_list *children; - char tn[32]; int unit; ctx = device_get_sysctl_ctx(sc->bge_dev); @@ -6276,18 +6273,14 @@ bge_add_sysctls(struct bge_softc *sc) * consumes a lot of CPU cycles, so leave it off by default. */ sc->bge_forced_collapse = 0; - snprintf(tn, sizeof(tn), "dev.bge.%d.forced_collapse", unit); - TUNABLE_INT_FETCH(tn, &sc->bge_forced_collapse); SYSCTL_ADD_INT(ctx, children, OID_AUTO, "forced_collapse", - CTLFLAG_RW, &sc->bge_forced_collapse, 0, + CTLFLAG_RWTUN, &sc->bge_forced_collapse, 0, "Number of fragmented TX buffers of a frame allowed before " "forced collapsing"); sc->bge_msi = 1; - snprintf(tn, sizeof(tn), "dev.bge.%d.msi", unit); - TUNABLE_INT_FETCH(tn, &sc->bge_msi); SYSCTL_ADD_INT(ctx, children, OID_AUTO, "msi", - CTLFLAG_RD, &sc->bge_msi, 0, "Enable MSI"); + CTLFLAG_RDTUN, &sc->bge_msi, 0, "Enable MSI"); /* * It seems all Broadcom controllers have a bug that can generate UDP @@ -6300,10 +6293,8 @@ bge_add_sysctls(struct bge_softc *sc) * dev.bge.0.forced_udpcsum. */ sc->bge_forced_udpcsum = 0; - snprintf(tn, sizeof(tn), "dev.bge.%d.bge_forced_udpcsum", unit); - TUNABLE_INT_FETCH(tn, &sc->bge_forced_udpcsum); SYSCTL_ADD_INT(ctx, children, OID_AUTO, "forced_udpcsum", - CTLFLAG_RW, &sc->bge_forced_udpcsum, 0, + CTLFLAG_RWTUN, &sc->bge_forced_udpcsum, 0, "Enable UDP checksum offloading even if controller can " "generate UDP checksum value 0"); diff --git a/sys/dev/bwn/if_bwn.c b/sys/dev/bwn/if_bwn.c index cc34b12095e0a..4e9a8d9ba36c8 100644 --- a/sys/dev/bwn/if_bwn.c +++ b/sys/dev/bwn/if_bwn.c @@ -83,9 +83,8 @@ static SYSCTL_NODE(_hw, OID_AUTO, bwn, CTLFLAG_RD, 0, #ifdef BWN_DEBUG static int bwn_debug = 0; -SYSCTL_INT(_hw_bwn, OID_AUTO, debug, CTLFLAG_RW, &bwn_debug, 0, +SYSCTL_INT(_hw_bwn, OID_AUTO, debug, CTLFLAG_RWTUN, &bwn_debug, 0, "Broadcom debugging printfs"); -TUNABLE_INT("hw.bwn.debug", &bwn_debug); enum { BWN_DEBUG_XMIT = 0x00000001, /* basic xmit operation */ BWN_DEBUG_RECV = 0x00000002, /* basic recv operation */ diff --git a/sys/dev/bxe/bxe.c b/sys/dev/bxe/bxe.c index feae5bcf78c7e..974852bce47e3 100644 --- a/sys/dev/bxe/bxe.c +++ b/sys/dev/bxe/bxe.c @@ -297,67 +297,56 @@ SYSCTL_NODE(_hw, OID_AUTO, bxe, CTLFLAG_RD, 0, "bxe driver parameters"); /* Debug */ unsigned long bxe_debug = 0; -TUNABLE_ULONG("hw.bxe.debug", &bxe_debug); -SYSCTL_ULONG(_hw_bxe, OID_AUTO, debug, (CTLFLAG_RDTUN), +SYSCTL_ULONG(_hw_bxe, OID_AUTO, debug, CTLFLAG_RDTUN, &bxe_debug, 0, "Debug logging mode"); /* Interrupt Mode: 0 (IRQ), 1 (MSI/IRQ), and 2 (MSI-X/MSI/IRQ) */ static int bxe_interrupt_mode = INTR_MODE_MSIX; -TUNABLE_INT("hw.bxe.interrupt_mode", &bxe_interrupt_mode); SYSCTL_INT(_hw_bxe, OID_AUTO, interrupt_mode, CTLFLAG_RDTUN, &bxe_interrupt_mode, 0, "Interrupt (MSI-X/MSI/INTx) mode"); /* Number of Queues: 0 (Auto) or 1 to 16 (fixed queue number) */ static int bxe_queue_count = 4; -TUNABLE_INT("hw.bxe.queue_count", &bxe_queue_count); SYSCTL_INT(_hw_bxe, OID_AUTO, queue_count, CTLFLAG_RDTUN, &bxe_queue_count, 0, "Multi-Queue queue count"); /* max number of buffers per queue (default RX_BD_USABLE) */ static int bxe_max_rx_bufs = 0; -TUNABLE_INT("hw.bxe.max_rx_bufs", &bxe_max_rx_bufs); SYSCTL_INT(_hw_bxe, OID_AUTO, max_rx_bufs, CTLFLAG_RDTUN, &bxe_max_rx_bufs, 0, "Maximum Number of Rx Buffers Per Queue"); /* Host interrupt coalescing RX tick timer (usecs) */ static int bxe_hc_rx_ticks = 25; -TUNABLE_INT("hw.bxe.hc_rx_ticks", &bxe_hc_rx_ticks); SYSCTL_INT(_hw_bxe, OID_AUTO, hc_rx_ticks, CTLFLAG_RDTUN, &bxe_hc_rx_ticks, 0, "Host Coalescing Rx ticks"); /* Host interrupt coalescing TX tick timer (usecs) */ static int bxe_hc_tx_ticks = 50; -TUNABLE_INT("hw.bxe.hc_tx_ticks", &bxe_hc_tx_ticks); SYSCTL_INT(_hw_bxe, OID_AUTO, hc_tx_ticks, CTLFLAG_RDTUN, &bxe_hc_tx_ticks, 0, "Host Coalescing Tx ticks"); /* Maximum number of Rx packets to process at a time */ static int bxe_rx_budget = 0xffffffff; -TUNABLE_INT("hw.bxe.rx_budget", &bxe_rx_budget); SYSCTL_INT(_hw_bxe, OID_AUTO, rx_budget, CTLFLAG_TUN, &bxe_rx_budget, 0, "Rx processing budget"); /* Maximum LRO aggregation size */ static int bxe_max_aggregation_size = 0; -TUNABLE_INT("hw.bxe.max_aggregation_size", &bxe_max_aggregation_size); SYSCTL_INT(_hw_bxe, OID_AUTO, max_aggregation_size, CTLFLAG_TUN, &bxe_max_aggregation_size, 0, "max aggregation size"); /* PCI MRRS: -1 (Auto), 0 (128B), 1 (256B), 2 (512B), 3 (1KB) */ static int bxe_mrrs = -1; -TUNABLE_INT("hw.bxe.mrrs", &bxe_mrrs); SYSCTL_INT(_hw_bxe, OID_AUTO, mrrs, CTLFLAG_RDTUN, &bxe_mrrs, 0, "PCIe maximum read request size"); /* AutoGrEEEn: 0 (hardware default), 1 (force on), 2 (force off) */ static int bxe_autogreeen = 0; -TUNABLE_INT("hw.bxe.autogreeen", &bxe_autogreeen); SYSCTL_INT(_hw_bxe, OID_AUTO, autogreeen, CTLFLAG_RDTUN, &bxe_autogreeen, 0, "AutoGrEEEn support"); /* 4-tuple RSS support for UDP: 0 (disabled), 1 (enabled) */ static int bxe_udp_rss = 0; -TUNABLE_INT("hw.bxe.udp_rss", &bxe_udp_rss); SYSCTL_INT(_hw_bxe, OID_AUTO, udp_rss, CTLFLAG_RDTUN, &bxe_udp_rss, 0, "UDP RSS support"); diff --git a/sys/dev/cardbus/cardbus.c b/sys/dev/cardbus/cardbus.c index 00d4a19e8cf67..c591fe98042e7 100644 --- a/sys/dev/cardbus/cardbus.c +++ b/sys/dev/cardbus/cardbus.c @@ -57,16 +57,12 @@ __FBSDID("$FreeBSD$"); static SYSCTL_NODE(_hw, OID_AUTO, cardbus, CTLFLAG_RD, 0, "CardBus parameters"); int cardbus_debug = 0; -TUNABLE_INT("hw.cardbus.debug", &cardbus_debug); -SYSCTL_INT(_hw_cardbus, OID_AUTO, debug, CTLFLAG_RW, - &cardbus_debug, 0, - "CardBus debug"); +SYSCTL_INT(_hw_cardbus, OID_AUTO, debug, CTLFLAG_RWTUN, + &cardbus_debug, 0, "CardBus debug"); int cardbus_cis_debug = 0; -TUNABLE_INT("hw.cardbus.cis_debug", &cardbus_cis_debug); -SYSCTL_INT(_hw_cardbus, OID_AUTO, cis_debug, CTLFLAG_RW, - &cardbus_cis_debug, 0, - "CardBus CIS debug"); +SYSCTL_INT(_hw_cardbus, OID_AUTO, cis_debug, CTLFLAG_RWTUN, + &cardbus_cis_debug, 0, "CardBus CIS debug"); #define DPRINTF(a) if (cardbus_debug) printf a #define DEVPRINTF(x) if (cardbus_debug) device_printf x diff --git a/sys/dev/cs/if_cs.c b/sys/dev/cs/if_cs.c index b6a3d3b91f637..502c2b34be734 100644 --- a/sys/dev/cs/if_cs.c +++ b/sys/dev/cs/if_cs.c @@ -107,14 +107,12 @@ driver_intr_t csintr; static SYSCTL_NODE(_hw, OID_AUTO, cs, CTLFLAG_RD, 0, "cs device parameters"); int cs_ignore_cksum_failure = 0; -TUNABLE_INT("hw.cs.ignore_checksum_failure", &cs_ignore_cksum_failure); -SYSCTL_INT(_hw_cs, OID_AUTO, ignore_checksum_failure, CTLFLAG_RW, +SYSCTL_INT(_hw_cs, OID_AUTO, ignore_checksum_failure, CTLFLAG_RWTUN, &cs_ignore_cksum_failure, 0, "ignore checksum errors in cs card EEPROM"); static int cs_recv_delay = 570; -TUNABLE_INT("hw.cs.recv_delay", &cs_recv_delay); -SYSCTL_INT(_hw_cs, OID_AUTO, recv_delay, CTLFLAG_RW, &cs_recv_delay, 570, ""); +SYSCTL_INT(_hw_cs, OID_AUTO, recv_delay, CTLFLAG_RWTUN, &cs_recv_delay, 570, ""); static int cs8900_eeint2irq[16] = { 10, 11, 12, 5, 255, 255, 255, 255, diff --git a/sys/dev/cxgb/cxgb_include.h b/sys/dev/cxgb/cxgb_include.h index 90080b5313179..d98ef5771baac 100644 --- a/sys/dev/cxgb/cxgb_include.h +++ b/sys/dev/cxgb/cxgb_include.h @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -16,3 +17,5 @@ #include #include #include + +SYSCTL_DECL(_hw_cxgb); diff --git a/sys/dev/cxgb/cxgb_main.c b/sys/dev/cxgb/cxgb_main.c index 6ccf6e3774a38..30001293b2bb4 100644 --- a/sys/dev/cxgb/cxgb_main.c +++ b/sys/dev/cxgb/cxgb_main.c @@ -208,7 +208,6 @@ static SLIST_HEAD(, uld_info) t3_uld_list; */ static int msi_allowed = 2; -TUNABLE_INT("hw.cxgb.msi_allowed", &msi_allowed); SYSCTL_NODE(_hw, OID_AUTO, cxgb, CTLFLAG_RD, 0, "CXGB driver parameters"); SYSCTL_INT(_hw_cxgb, OID_AUTO, msi_allowed, CTLFLAG_RDTUN, &msi_allowed, 0, "MSI-X, MSI, INTx selector"); @@ -218,7 +217,6 @@ SYSCTL_INT(_hw_cxgb, OID_AUTO, msi_allowed, CTLFLAG_RDTUN, &msi_allowed, 0, * To disable it and force a single queue-set per port, use multiq = 0 */ static int multiq = 1; -TUNABLE_INT("hw.cxgb.multiq", &multiq); SYSCTL_INT(_hw_cxgb, OID_AUTO, multiq, CTLFLAG_RDTUN, &multiq, 0, "use min(ncpus/ports, 8) queue-sets per port"); @@ -228,17 +226,14 @@ SYSCTL_INT(_hw_cxgb, OID_AUTO, multiq, CTLFLAG_RDTUN, &multiq, 0, * */ static int force_fw_update = 0; -TUNABLE_INT("hw.cxgb.force_fw_update", &force_fw_update); SYSCTL_INT(_hw_cxgb, OID_AUTO, force_fw_update, CTLFLAG_RDTUN, &force_fw_update, 0, "update firmware even if up to date"); int cxgb_use_16k_clusters = -1; -TUNABLE_INT("hw.cxgb.use_16k_clusters", &cxgb_use_16k_clusters); SYSCTL_INT(_hw_cxgb, OID_AUTO, use_16k_clusters, CTLFLAG_RDTUN, &cxgb_use_16k_clusters, 0, "use 16kB clusters for the jumbo queue "); static int nfilters = -1; -TUNABLE_INT("hw.cxgb.nfilters", &nfilters); SYSCTL_INT(_hw_cxgb, OID_AUTO, nfilters, CTLFLAG_RDTUN, &nfilters, 0, "max number of entries in the filter table"); diff --git a/sys/dev/cxgb/cxgb_sge.c b/sys/dev/cxgb/cxgb_sge.c index 42744faa44ded..fcc0376fab763 100644 --- a/sys/dev/cxgb/cxgb_sge.c +++ b/sys/dev/cxgb/cxgb_sge.c @@ -86,13 +86,11 @@ CTASSERT(NUM_CPL_HANDLERS >= NUM_CPL_CMDS); extern struct sysctl_oid_list sysctl__hw_cxgb_children; int cxgb_txq_buf_ring_size = TX_ETH_Q_SIZE; -TUNABLE_INT("hw.cxgb.txq_mr_size", &cxgb_txq_buf_ring_size); SYSCTL_INT(_hw_cxgb, OID_AUTO, txq_mr_size, CTLFLAG_RDTUN, &cxgb_txq_buf_ring_size, 0, "size of per-queue mbuf ring"); static int cxgb_tx_coalesce_force = 0; -TUNABLE_INT("hw.cxgb.tx_coalesce_force", &cxgb_tx_coalesce_force); -SYSCTL_INT(_hw_cxgb, OID_AUTO, tx_coalesce_force, CTLFLAG_RW, +SYSCTL_INT(_hw_cxgb, OID_AUTO, tx_coalesce_force, CTLFLAG_RWTUN, &cxgb_tx_coalesce_force, 0, "coalesce small packets into a single work request regardless of ring state"); @@ -106,19 +104,15 @@ SYSCTL_INT(_hw_cxgb, OID_AUTO, tx_coalesce_force, CTLFLAG_RW, static int cxgb_tx_coalesce_enable_start = COALESCE_START_DEFAULT; -TUNABLE_INT("hw.cxgb.tx_coalesce_enable_start", - &cxgb_tx_coalesce_enable_start); -SYSCTL_INT(_hw_cxgb, OID_AUTO, tx_coalesce_enable_start, CTLFLAG_RW, +SYSCTL_INT(_hw_cxgb, OID_AUTO, tx_coalesce_enable_start, CTLFLAG_RWTUN, &cxgb_tx_coalesce_enable_start, 0, "coalesce enable threshold"); static int cxgb_tx_coalesce_enable_stop = COALESCE_STOP_DEFAULT; -TUNABLE_INT("hw.cxgb.tx_coalesce_enable_stop", &cxgb_tx_coalesce_enable_stop); -SYSCTL_INT(_hw_cxgb, OID_AUTO, tx_coalesce_enable_stop, CTLFLAG_RW, +SYSCTL_INT(_hw_cxgb, OID_AUTO, tx_coalesce_enable_stop, CTLFLAG_RWTUN, &cxgb_tx_coalesce_enable_stop, 0, "coalesce disable threshold"); static int cxgb_tx_reclaim_threshold = TX_RECLAIM_DEFAULT; -TUNABLE_INT("hw.cxgb.tx_reclaim_threshold", &cxgb_tx_reclaim_threshold); -SYSCTL_INT(_hw_cxgb, OID_AUTO, tx_reclaim_threshold, CTLFLAG_RW, +SYSCTL_INT(_hw_cxgb, OID_AUTO, tx_reclaim_threshold, CTLFLAG_RWTUN, &cxgb_tx_reclaim_threshold, 0, "tx cleaning minimum threshold"); diff --git a/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c b/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c index 9afad627d5aed..fea86eba709de 100644 --- a/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c +++ b/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c @@ -106,43 +106,35 @@ static char *states[] = { SYSCTL_NODE(_hw, OID_AUTO, iw_cxgb, CTLFLAG_RD, 0, "iw_cxgb driver parameters"); static int ep_timeout_secs = 60; -TUNABLE_INT("hw.iw_cxgb.ep_timeout_secs", &ep_timeout_secs); -SYSCTL_INT(_hw_iw_cxgb, OID_AUTO, ep_timeout_secs, CTLFLAG_RW, &ep_timeout_secs, 0, +SYSCTL_INT(_hw_iw_cxgb, OID_AUTO, ep_timeout_secs, CTLFLAG_RWTUN, &ep_timeout_secs, 0, "CM Endpoint operation timeout in seconds (default=60)"); static int mpa_rev = 1; -TUNABLE_INT("hw.iw_cxgb.mpa_rev", &mpa_rev); -SYSCTL_INT(_hw_iw_cxgb, OID_AUTO, mpa_rev, CTLFLAG_RW, &mpa_rev, 0, +SYSCTL_INT(_hw_iw_cxgb, OID_AUTO, mpa_rev, CTLFLAG_RWTUN, &mpa_rev, 0, "MPA Revision, 0 supports amso1100, 1 is spec compliant. (default=1)"); static int markers_enabled = 0; -TUNABLE_INT("hw.iw_cxgb.markers_enabled", &markers_enabled); -SYSCTL_INT(_hw_iw_cxgb, OID_AUTO, markers_enabled, CTLFLAG_RW, &markers_enabled, 0, +SYSCTL_INT(_hw_iw_cxgb, OID_AUTO, markers_enabled, CTLFLAG_RWTUN, &markers_enabled, 0, "Enable MPA MARKERS (default(0)=disabled)"); static int crc_enabled = 1; -TUNABLE_INT("hw.iw_cxgb.crc_enabled", &crc_enabled); -SYSCTL_INT(_hw_iw_cxgb, OID_AUTO, crc_enabled, CTLFLAG_RW, &crc_enabled, 0, +SYSCTL_INT(_hw_iw_cxgb, OID_AUTO, crc_enabled, CTLFLAG_RWTUN, &crc_enabled, 0, "Enable MPA CRC (default(1)=enabled)"); static int rcv_win = 256 * 1024; -TUNABLE_INT("hw.iw_cxgb.rcv_win", &rcv_win); -SYSCTL_INT(_hw_iw_cxgb, OID_AUTO, rcv_win, CTLFLAG_RW, &rcv_win, 0, +SYSCTL_INT(_hw_iw_cxgb, OID_AUTO, rcv_win, CTLFLAG_RWTUN, &rcv_win, 0, "TCP receive window in bytes (default=256KB)"); static int snd_win = 32 * 1024; -TUNABLE_INT("hw.iw_cxgb.snd_win", &snd_win); -SYSCTL_INT(_hw_iw_cxgb, OID_AUTO, snd_win, CTLFLAG_RW, &snd_win, 0, +SYSCTL_INT(_hw_iw_cxgb, OID_AUTO, snd_win, CTLFLAG_RWTUN, &snd_win, 0, "TCP send window in bytes (default=32KB)"); static unsigned int nocong = 0; -TUNABLE_INT("hw.iw_cxgb.nocong", &nocong); -SYSCTL_UINT(_hw_iw_cxgb, OID_AUTO, nocong, CTLFLAG_RW, &nocong, 0, +SYSCTL_UINT(_hw_iw_cxgb, OID_AUTO, nocong, CTLFLAG_RWTUN, &nocong, 0, "Turn off congestion control (default=0)"); static unsigned int cong_flavor = 1; -TUNABLE_INT("hw.iw_cxgb.cong_flavor", &cong_flavor); -SYSCTL_UINT(_hw_iw_cxgb, OID_AUTO, cong_flavor, CTLFLAG_RW, &cong_flavor, 0, +SYSCTL_UINT(_hw_iw_cxgb, OID_AUTO, cong_flavor, CTLFLAG_RWTUN, &cong_flavor, 0, "TCP Congestion control flavor (default=1)"); static void ep_timeout(void *arg); diff --git a/sys/dev/cxgbe/iw_cxgbe/cm.c b/sys/dev/cxgbe/iw_cxgbe/cm.c index 03652a396a31c..fb93a9b2b287a 100644 --- a/sys/dev/cxgbe/iw_cxgbe/cm.c +++ b/sys/dev/cxgbe/iw_cxgbe/cm.c @@ -769,88 +769,72 @@ process_socket_event(struct c4iw_ep *ep) SYSCTL_NODE(_hw, OID_AUTO, iw_cxgbe, CTLFLAG_RD, 0, "iw_cxgbe driver parameters"); int db_delay_usecs = 1; -TUNABLE_INT("hw.iw_cxgbe.db_delay_usecs", &db_delay_usecs); -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, db_delay_usecs, CTLFLAG_RW, &db_delay_usecs, 0, +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, db_delay_usecs, CTLFLAG_RWTUN, &db_delay_usecs, 0, "Usecs to delay awaiting db fifo to drain"); static int dack_mode = 1; -TUNABLE_INT("hw.iw_cxgbe.dack_mode", &dack_mode); -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, dack_mode, CTLFLAG_RW, &dack_mode, 0, +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, dack_mode, CTLFLAG_RWTUN, &dack_mode, 0, "Delayed ack mode (default = 1)"); int c4iw_max_read_depth = 8; -TUNABLE_INT("hw.iw_cxgbe.c4iw_max_read_depth", &c4iw_max_read_depth); -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, c4iw_max_read_depth, CTLFLAG_RW, &c4iw_max_read_depth, 0, +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, c4iw_max_read_depth, CTLFLAG_RWTUN, &c4iw_max_read_depth, 0, "Per-connection max ORD/IRD (default = 8)"); static int enable_tcp_timestamps; -TUNABLE_INT("hw.iw_cxgbe.enable_tcp_timestamps", &enable_tcp_timestamps); -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, enable_tcp_timestamps, CTLFLAG_RW, &enable_tcp_timestamps, 0, +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, enable_tcp_timestamps, CTLFLAG_RWTUN, &enable_tcp_timestamps, 0, "Enable tcp timestamps (default = 0)"); static int enable_tcp_sack; -TUNABLE_INT("hw.iw_cxgbe.enable_tcp_sack", &enable_tcp_sack); -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, enable_tcp_sack, CTLFLAG_RW, &enable_tcp_sack, 0, +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, enable_tcp_sack, CTLFLAG_RWTUN, &enable_tcp_sack, 0, "Enable tcp SACK (default = 0)"); static int enable_tcp_window_scaling = 1; -TUNABLE_INT("hw.iw_cxgbe.enable_tcp_window_scaling", &enable_tcp_window_scaling); -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, enable_tcp_window_scaling, CTLFLAG_RW, &enable_tcp_window_scaling, 0, +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, enable_tcp_window_scaling, CTLFLAG_RWTUN, &enable_tcp_window_scaling, 0, "Enable tcp window scaling (default = 1)"); int c4iw_debug = 1; -TUNABLE_INT("hw.iw_cxgbe.c4iw_debug", &c4iw_debug); -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, c4iw_debug, CTLFLAG_RW, &c4iw_debug, 0, +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, c4iw_debug, CTLFLAG_RWTUN, &c4iw_debug, 0, "Enable debug logging (default = 0)"); static int peer2peer; -TUNABLE_INT("hw.iw_cxgbe.peer2peer", &peer2peer); -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, peer2peer, CTLFLAG_RW, &peer2peer, 0, +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, peer2peer, CTLFLAG_RWTUN, &peer2peer, 0, "Support peer2peer ULPs (default = 0)"); static int p2p_type = FW_RI_INIT_P2PTYPE_READ_REQ; -TUNABLE_INT("hw.iw_cxgbe.p2p_type", &p2p_type); -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, p2p_type, CTLFLAG_RW, &p2p_type, 0, +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, p2p_type, CTLFLAG_RWTUN, &p2p_type, 0, "RDMAP opcode to use for the RTR message: 1 = RDMA_READ 0 = RDMA_WRITE (default 1)"); static int ep_timeout_secs = 60; -TUNABLE_INT("hw.iw_cxgbe.ep_timeout_secs", &ep_timeout_secs); -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, ep_timeout_secs, CTLFLAG_RW, &ep_timeout_secs, 0, +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, ep_timeout_secs, CTLFLAG_RWTUN, &ep_timeout_secs, 0, "CM Endpoint operation timeout in seconds (default = 60)"); static int mpa_rev = 1; -TUNABLE_INT("hw.iw_cxgbe.mpa_rev", &mpa_rev); #ifdef IW_CM_MPAV2 -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, mpa_rev, CTLFLAG_RW, &mpa_rev, 0, +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, mpa_rev, CTLFLAG_RWTUN, &mpa_rev, 0, "MPA Revision, 0 supports amso1100, 1 is RFC0544 spec compliant, 2 is IETF MPA Peer Connect Draft compliant (default = 1)"); #else -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, mpa_rev, CTLFLAG_RW, &mpa_rev, 0, +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, mpa_rev, CTLFLAG_RWTUN, &mpa_rev, 0, "MPA Revision, 0 supports amso1100, 1 is RFC0544 spec compliant (default = 1)"); #endif static int markers_enabled; -TUNABLE_INT("hw.iw_cxgbe.markers_enabled", &markers_enabled); -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, markers_enabled, CTLFLAG_RW, &markers_enabled, 0, +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, markers_enabled, CTLFLAG_RWTUN, &markers_enabled, 0, "Enable MPA MARKERS (default(0) = disabled)"); static int crc_enabled = 1; -TUNABLE_INT("hw.iw_cxgbe.crc_enabled", &crc_enabled); -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, crc_enabled, CTLFLAG_RW, &crc_enabled, 0, +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, crc_enabled, CTLFLAG_RWTUN, &crc_enabled, 0, "Enable MPA CRC (default(1) = enabled)"); static int rcv_win = 256 * 1024; -TUNABLE_INT("hw.iw_cxgbe.rcv_win", &rcv_win); -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, rcv_win, CTLFLAG_RW, &rcv_win, 0, +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, rcv_win, CTLFLAG_RWTUN, &rcv_win, 0, "TCP receive window in bytes (default = 256KB)"); static int snd_win = 128 * 1024; -TUNABLE_INT("hw.iw_cxgbe.snd_win", &snd_win); -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, snd_win, CTLFLAG_RW, &snd_win, 0, +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, snd_win, CTLFLAG_RWTUN, &snd_win, 0, "TCP send window in bytes (default = 128KB)"); int db_fc_threshold = 2000; -TUNABLE_INT("hw.iw_cxgbe.db_fc_threshold", &db_fc_threshold); -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, db_fc_threshold, CTLFLAG_RW, &db_fc_threshold, 0, +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, db_fc_threshold, CTLFLAG_RWTUN, &db_fc_threshold, 0, "QP count/threshold that triggers automatic"); static void diff --git a/sys/dev/drm/drm_drv.c b/sys/dev/drm/drm_drv.c index 75902a7711dbe..75983766f3799 100644 --- a/sys/dev/drm/drm_drv.c +++ b/sys/dev/drm/drm_drv.c @@ -132,7 +132,6 @@ static struct cdevsw drm_cdevsw = { }; static int drm_msi = 1; /* Enable by default. */ -TUNABLE_INT("hw.drm.msi", &drm_msi); SYSCTL_NODE(_hw, OID_AUTO, drm, CTLFLAG_RW, NULL, "DRM device"); SYSCTL_INT(_hw_drm, OID_AUTO, msi, CTLFLAG_RDTUN, &drm_msi, 1, "Enable MSI interrupts for drm devices"); diff --git a/sys/dev/drm/drm_sysctl.c b/sys/dev/drm/drm_sysctl.c index ce3e5b4c7ce84..75d8306c8405b 100644 --- a/sys/dev/drm/drm_sysctl.c +++ b/sys/dev/drm/drm_sysctl.c @@ -70,7 +70,7 @@ int drm_sysctl_init(struct drm_device *dev) dev->sysctl = info; /* Add the sysctl node for DRI if it doesn't already exist */ - drioid = SYSCTL_ADD_NODE( &info->ctx, &sysctl__hw_children, OID_AUTO, "dri", CTLFLAG_RW, NULL, "DRI Graphics"); + drioid = SYSCTL_ADD_NODE(&info->ctx, SYSCTL_CHILDREN(&sysctl___hw), OID_AUTO, "dri", CTLFLAG_RW, NULL, "DRI Graphics"); if (!drioid) return 1; diff --git a/sys/dev/drm2/drm_drv.c b/sys/dev/drm2/drm_drv.c index 7b00bcf8cf433..81fcee3dbe7cc 100644 --- a/sys/dev/drm2/drm_drv.c +++ b/sys/dev/drm2/drm_drv.c @@ -203,7 +203,6 @@ static struct cdevsw drm_cdevsw = { }; static int drm_msi = 1; /* Enable by default. */ -TUNABLE_INT("hw.drm.msi", &drm_msi); SYSCTL_NODE(_hw, OID_AUTO, drm, CTLFLAG_RW, NULL, "DRM device"); SYSCTL_INT(_hw_drm, OID_AUTO, msi, CTLFLAG_RDTUN, &drm_msi, 1, "Enable MSI interrupts for drm devices"); diff --git a/sys/dev/drm2/drm_sysctl.c b/sys/dev/drm2/drm_sysctl.c index a30c7ab237a6b..aac21e6a486ed 100644 --- a/sys/dev/drm2/drm_sysctl.c +++ b/sys/dev/drm2/drm_sysctl.c @@ -68,7 +68,7 @@ int drm_sysctl_init(struct drm_device *dev) dev->sysctl = info; /* Add the sysctl node for DRI if it doesn't already exist */ - drioid = SYSCTL_ADD_NODE(&info->ctx, &sysctl__hw_children, OID_AUTO, + drioid = SYSCTL_ADD_NODE(&info->ctx, SYSCTL_CHILDREN(&sysctl___hw), OID_AUTO, "dri", CTLFLAG_RW, NULL, "DRI Graphics"); if (!drioid) return 1; diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c index d44ad37bee7c9..d2872cb0a95c2 100644 --- a/sys/dev/e1000/if_em.c +++ b/sys/dev/e1000/if_em.c @@ -353,8 +353,6 @@ static SYSCTL_NODE(_hw, OID_AUTO, em, CTLFLAG_RD, 0, "EM driver parameters"); static int em_tx_int_delay_dflt = EM_TICKS_TO_USECS(EM_TIDV); static int em_rx_int_delay_dflt = EM_TICKS_TO_USECS(EM_RDTR); -TUNABLE_INT("hw.em.tx_int_delay", &em_tx_int_delay_dflt); -TUNABLE_INT("hw.em.rx_int_delay", &em_rx_int_delay_dflt); SYSCTL_INT(_hw_em, OID_AUTO, tx_int_delay, CTLFLAG_RDTUN, &em_tx_int_delay_dflt, 0, "Default transmit interrupt delay in usecs"); SYSCTL_INT(_hw_em, OID_AUTO, rx_int_delay, CTLFLAG_RDTUN, &em_rx_int_delay_dflt, @@ -362,8 +360,6 @@ SYSCTL_INT(_hw_em, OID_AUTO, rx_int_delay, CTLFLAG_RDTUN, &em_rx_int_delay_dflt, static int em_tx_abs_int_delay_dflt = EM_TICKS_TO_USECS(EM_TADV); static int em_rx_abs_int_delay_dflt = EM_TICKS_TO_USECS(EM_RADV); -TUNABLE_INT("hw.em.tx_abs_int_delay", &em_tx_abs_int_delay_dflt); -TUNABLE_INT("hw.em.rx_abs_int_delay", &em_rx_abs_int_delay_dflt); SYSCTL_INT(_hw_em, OID_AUTO, tx_abs_int_delay, CTLFLAG_RDTUN, &em_tx_abs_int_delay_dflt, 0, "Default transmit interrupt delay limit in usecs"); @@ -373,32 +369,26 @@ SYSCTL_INT(_hw_em, OID_AUTO, rx_abs_int_delay, CTLFLAG_RDTUN, static int em_rxd = EM_DEFAULT_RXD; static int em_txd = EM_DEFAULT_TXD; -TUNABLE_INT("hw.em.rxd", &em_rxd); -TUNABLE_INT("hw.em.txd", &em_txd); SYSCTL_INT(_hw_em, OID_AUTO, rxd, CTLFLAG_RDTUN, &em_rxd, 0, "Number of receive descriptors per queue"); SYSCTL_INT(_hw_em, OID_AUTO, txd, CTLFLAG_RDTUN, &em_txd, 0, "Number of transmit descriptors per queue"); static int em_smart_pwr_down = FALSE; -TUNABLE_INT("hw.em.smart_pwr_down", &em_smart_pwr_down); SYSCTL_INT(_hw_em, OID_AUTO, smart_pwr_down, CTLFLAG_RDTUN, &em_smart_pwr_down, 0, "Set to true to leave smart power down enabled on newer adapters"); /* Controls whether promiscuous also shows bad packets */ static int em_debug_sbp = FALSE; -TUNABLE_INT("hw.em.sbp", &em_debug_sbp); SYSCTL_INT(_hw_em, OID_AUTO, sbp, CTLFLAG_RDTUN, &em_debug_sbp, 0, "Show bad packets in promiscuous mode"); static int em_enable_msix = TRUE; -TUNABLE_INT("hw.em.enable_msix", &em_enable_msix); SYSCTL_INT(_hw_em, OID_AUTO, enable_msix, CTLFLAG_RDTUN, &em_enable_msix, 0, "Enable MSI-X interrupts"); /* How many packets rxeof tries to clean at a time */ static int em_rx_process_limit = 100; -TUNABLE_INT("hw.em.rx_process_limit", &em_rx_process_limit); SYSCTL_INT(_hw_em, OID_AUTO, rx_process_limit, CTLFLAG_RDTUN, &em_rx_process_limit, 0, "Maximum number of received packets to process " @@ -406,7 +396,6 @@ SYSCTL_INT(_hw_em, OID_AUTO, rx_process_limit, CTLFLAG_RDTUN, /* Energy efficient ethernet - default to OFF */ static int eee_setting = 1; -TUNABLE_INT("hw.em.eee_setting", &eee_setting); SYSCTL_INT(_hw_em, OID_AUTO, eee_setting, CTLFLAG_RDTUN, &eee_setting, 0, "Enable Energy Efficient Ethernet"); diff --git a/sys/dev/e1000/if_igb.c b/sys/dev/e1000/if_igb.c index 38153f4d3afc9..5c54c8400f4c6 100644 --- a/sys/dev/e1000/if_igb.c +++ b/sys/dev/e1000/if_igb.c @@ -327,8 +327,6 @@ static SYSCTL_NODE(_hw, OID_AUTO, igb, CTLFLAG_RD, 0, "IGB driver parameters"); /* Descriptor defaults */ static int igb_rxd = IGB_DEFAULT_RXD; static int igb_txd = IGB_DEFAULT_TXD; -TUNABLE_INT("hw.igb.rxd", &igb_rxd); -TUNABLE_INT("hw.igb.txd", &igb_txd); SYSCTL_INT(_hw_igb, OID_AUTO, rxd, CTLFLAG_RDTUN, &igb_rxd, 0, "Number of receive descriptors per queue"); SYSCTL_INT(_hw_igb, OID_AUTO, txd, CTLFLAG_RDTUN, &igb_txd, 0, @@ -341,8 +339,7 @@ SYSCTL_INT(_hw_igb, OID_AUTO, txd, CTLFLAG_RDTUN, &igb_txd, 0, ** traffic for that interrupt vector */ static int igb_enable_aim = TRUE; -TUNABLE_INT("hw.igb.enable_aim", &igb_enable_aim); -SYSCTL_INT(_hw_igb, OID_AUTO, enable_aim, CTLFLAG_RW, &igb_enable_aim, 0, +SYSCTL_INT(_hw_igb, OID_AUTO, enable_aim, CTLFLAG_RWTUN, &igb_enable_aim, 0, "Enable adaptive interrupt moderation"); /* @@ -350,7 +347,6 @@ SYSCTL_INT(_hw_igb, OID_AUTO, enable_aim, CTLFLAG_RW, &igb_enable_aim, 0, * but this allows it to be forced off for testing. */ static int igb_enable_msix = 1; -TUNABLE_INT("hw.igb.enable_msix", &igb_enable_msix); SYSCTL_INT(_hw_igb, OID_AUTO, enable_msix, CTLFLAG_RDTUN, &igb_enable_msix, 0, "Enable MSI-X interrupts"); @@ -358,7 +354,6 @@ SYSCTL_INT(_hw_igb, OID_AUTO, enable_msix, CTLFLAG_RDTUN, &igb_enable_msix, 0, ** Tuneable Interrupt rate */ static int igb_max_interrupt_rate = 8000; -TUNABLE_INT("hw.igb.max_interrupt_rate", &igb_max_interrupt_rate); SYSCTL_INT(_hw_igb, OID_AUTO, max_interrupt_rate, CTLFLAG_RDTUN, &igb_max_interrupt_rate, 0, "Maximum interrupts per second"); @@ -367,7 +362,6 @@ SYSCTL_INT(_hw_igb, OID_AUTO, max_interrupt_rate, CTLFLAG_RDTUN, ** Tuneable number of buffers in the buf-ring (drbr_xxx) */ static int igb_buf_ring_size = IGB_BR_SIZE; -TUNABLE_INT("hw.igb.buf_ring_size", &igb_buf_ring_size); SYSCTL_INT(_hw_igb, OID_AUTO, buf_ring_size, CTLFLAG_RDTUN, &igb_buf_ring_size, 0, "Size of the bufring"); #endif @@ -381,7 +375,6 @@ SYSCTL_INT(_hw_igb, OID_AUTO, buf_ring_size, CTLFLAG_RDTUN, ** a very workload dependent type feature. */ static int igb_header_split = FALSE; -TUNABLE_INT("hw.igb.hdr_split", &igb_header_split); SYSCTL_INT(_hw_igb, OID_AUTO, header_split, CTLFLAG_RDTUN, &igb_header_split, 0, "Enable receive mbuf header split"); @@ -391,7 +384,6 @@ SYSCTL_INT(_hw_igb, OID_AUTO, header_split, CTLFLAG_RDTUN, &igb_header_split, 0, ** MSIX messages if left at 0. */ static int igb_num_queues = 0; -TUNABLE_INT("hw.igb.num_queues", &igb_num_queues); SYSCTL_INT(_hw_igb, OID_AUTO, num_queues, CTLFLAG_RDTUN, &igb_num_queues, 0, "Number of queues to configure, 0 indicates autoconfigure"); @@ -404,7 +396,6 @@ static int igb_last_bind_cpu = -1; /* How many packets rxeof tries to clean at a time */ static int igb_rx_process_limit = 100; -TUNABLE_INT("hw.igb.rx_process_limit", &igb_rx_process_limit); SYSCTL_INT(_hw_igb, OID_AUTO, rx_process_limit, CTLFLAG_RDTUN, &igb_rx_process_limit, 0, "Maximum number of received packets to process at a time, -1 means unlimited"); diff --git a/sys/dev/fb/vesa.c b/sys/dev/fb/vesa.c index 48067b6401fe6..c7c2d641cdf47 100644 --- a/sys/dev/fb/vesa.c +++ b/sys/dev/fb/vesa.c @@ -101,7 +101,6 @@ static video_adapter_t *vesa_adp; static SYSCTL_NODE(_debug, OID_AUTO, vesa, CTLFLAG_RD, NULL, "VESA debugging"); static int vesa_shadow_rom; -TUNABLE_INT("debug.vesa.shadow_rom", &vesa_shadow_rom); SYSCTL_INT(_debug_vesa, OID_AUTO, shadow_rom, CTLFLAG_RDTUN, &vesa_shadow_rom, 0, "Enable video BIOS shadow"); diff --git a/sys/dev/firewire/fwohci.c b/sys/dev/firewire/fwohci.c index ae753d53d30ca..4ac43027bd405 100644 --- a/sys/dev/firewire/fwohci.c +++ b/sys/dev/firewire/fwohci.c @@ -78,14 +78,13 @@ #undef OHCI_DEBUG -static int nocyclemaster = 0; +static int nocyclemaster; int firewire_phydma_enable = 1; SYSCTL_DECL(_hw_firewire); -SYSCTL_INT(_hw_firewire, OID_AUTO, nocyclemaster, CTLFLAG_RW, &nocyclemaster, 0, - "Do not send cycle start packets"); -SYSCTL_INT(_hw_firewire, OID_AUTO, phydma_enable, CTLFLAG_RW, - &firewire_phydma_enable, 1, "Allow physical request DMA from firewire"); -TUNABLE_INT("hw.firewire.phydma_enable", &firewire_phydma_enable); +SYSCTL_INT(_hw_firewire, OID_AUTO, nocyclemaster, CTLFLAG_RWTUN, + &nocyclemaster, 0, "Do not send cycle start packets"); +SYSCTL_INT(_hw_firewire, OID_AUTO, phydma_enable, CTLFLAG_RWTUN, + &firewire_phydma_enable, 0, "Allow physical request DMA from firewire"); static char dbcode[16][0x10]={"OUTM", "OUTL","INPM","INPL", "STOR","LOAD","NOP ","STOP",}; diff --git a/sys/dev/firewire/if_fwe.c b/sys/dev/firewire/if_fwe.c index a7d9bc35d4945..cb21cf61d4285 100644 --- a/sys/dev/firewire/if_fwe.c +++ b/sys/dev/firewire/if_fwe.c @@ -88,21 +88,17 @@ static int tx_speed = 2; static int rx_queue_len = FWMAXQUEUE; static MALLOC_DEFINE(M_FWE, "if_fwe", "Ethernet over FireWire interface"); -SYSCTL_INT(_debug, OID_AUTO, if_fwe_debug, CTLFLAG_RW, &fwedebug, 0, ""); +SYSCTL_INT(_debug, OID_AUTO, if_fwe_debug, CTLFLAG_RWTUN, &fwedebug, 0, ""); SYSCTL_DECL(_hw_firewire); static SYSCTL_NODE(_hw_firewire, OID_AUTO, fwe, CTLFLAG_RD, 0, "Ethernet emulation subsystem"); -SYSCTL_INT(_hw_firewire_fwe, OID_AUTO, stream_ch, CTLFLAG_RW, &stream_ch, 0, +SYSCTL_INT(_hw_firewire_fwe, OID_AUTO, stream_ch, CTLFLAG_RWTUN, &stream_ch, 0, "Stream channel to use"); -SYSCTL_INT(_hw_firewire_fwe, OID_AUTO, tx_speed, CTLFLAG_RW, &tx_speed, 0, +SYSCTL_INT(_hw_firewire_fwe, OID_AUTO, tx_speed, CTLFLAG_RWTUN, &tx_speed, 0, "Transmission speed"); -SYSCTL_INT(_hw_firewire_fwe, OID_AUTO, rx_queue_len, CTLFLAG_RW, &rx_queue_len, +SYSCTL_INT(_hw_firewire_fwe, OID_AUTO, rx_queue_len, CTLFLAG_RWTUN, &rx_queue_len, 0, "Length of the receive queue"); -TUNABLE_INT("hw.firewire.fwe.stream_ch", &stream_ch); -TUNABLE_INT("hw.firewire.fwe.tx_speed", &tx_speed); -TUNABLE_INT("hw.firewire.fwe.rx_queue_len", &rx_queue_len); - #ifdef DEVICE_POLLING static poll_handler_t fwe_poll; diff --git a/sys/dev/firewire/if_fwip.c b/sys/dev/firewire/if_fwip.c index e98f44e237a3d..df3e1f6446d37 100644 --- a/sys/dev/firewire/if_fwip.c +++ b/sys/dev/firewire/if_fwip.c @@ -105,11 +105,9 @@ SYSCTL_INT(_debug, OID_AUTO, if_fwip_debug, CTLFLAG_RW, &fwipdebug, 0, ""); SYSCTL_DECL(_hw_firewire); static SYSCTL_NODE(_hw_firewire, OID_AUTO, fwip, CTLFLAG_RD, 0, "Firewire ip subsystem"); -SYSCTL_INT(_hw_firewire_fwip, OID_AUTO, rx_queue_len, CTLFLAG_RW, &rx_queue_len, +SYSCTL_INT(_hw_firewire_fwip, OID_AUTO, rx_queue_len, CTLFLAG_RWTUN, &rx_queue_len, 0, "Length of the receive queue"); -TUNABLE_INT("hw.firewire.fwip.rx_queue_len", &rx_queue_len); - #ifdef DEVICE_POLLING static poll_handler_t fwip_poll; diff --git a/sys/dev/firewire/sbp.c b/sys/dev/firewire/sbp.c index 10e8c60eea674..eeca4c77b4e70 100644 --- a/sys/dev/firewire/sbp.c +++ b/sys/dev/firewire/sbp.c @@ -134,31 +134,23 @@ static int sbp_tags = 0; SYSCTL_DECL(_hw_firewire); static SYSCTL_NODE(_hw_firewire, OID_AUTO, sbp, CTLFLAG_RD, 0, "SBP-II Subsystem"); -SYSCTL_INT(_debug, OID_AUTO, sbp_debug, CTLFLAG_RW, &debug, 0, +SYSCTL_INT(_debug, OID_AUTO, sbp_debug, CTLFLAG_RWTUN, &debug, 0, "SBP debug flag"); -SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, auto_login, CTLFLAG_RW, &auto_login, 0, +SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, auto_login, CTLFLAG_RWTUN, &auto_login, 0, "SBP perform login automatically"); -SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, max_speed, CTLFLAG_RW, &max_speed, 0, +SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, max_speed, CTLFLAG_RWTUN, &max_speed, 0, "SBP transfer max speed"); -SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, exclusive_login, CTLFLAG_RW, +SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, exclusive_login, CTLFLAG_RWTUN, &ex_login, 0, "SBP enable exclusive login"); -SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, login_delay, CTLFLAG_RW, +SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, login_delay, CTLFLAG_RWTUN, &login_delay, 0, "SBP login delay in msec"); -SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, scan_delay, CTLFLAG_RW, +SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, scan_delay, CTLFLAG_RWTUN, &scan_delay, 0, "SBP scan delay in msec"); -SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, use_doorbell, CTLFLAG_RW, +SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, use_doorbell, CTLFLAG_RWTUN, &use_doorbell, 0, "SBP use doorbell request"); -SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, tags, CTLFLAG_RW, &sbp_tags, 0, +SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, tags, CTLFLAG_RWTUN, &sbp_tags, 0, "SBP tagged queuing support"); -TUNABLE_INT("hw.firewire.sbp.auto_login", &auto_login); -TUNABLE_INT("hw.firewire.sbp.max_speed", &max_speed); -TUNABLE_INT("hw.firewire.sbp.exclusive_login", &ex_login); -TUNABLE_INT("hw.firewire.sbp.login_delay", &login_delay); -TUNABLE_INT("hw.firewire.sbp.scan_delay", &scan_delay); -TUNABLE_INT("hw.firewire.sbp.use_doorbell", &use_doorbell); -TUNABLE_INT("hw.firewire.sbp.tags", &sbp_tags); - #define NEED_RESPONSE 0 #define SBP_SEG_MAX rounddown(0xffff, PAGE_SIZE) diff --git a/sys/dev/glxiic/glxiic.c b/sys/dev/glxiic/glxiic.c index 939c32db07df5..95d8602703f8f 100644 --- a/sys/dev/glxiic/glxiic.c +++ b/sys/dev/glxiic/glxiic.c @@ -314,7 +314,6 @@ glxiic_attach(device_t dev) struct sysctl_oid *tree; int error, irq, unit; uint32_t irq_map; - char tn[32]; sc = device_get_softc(dev); sc->dev = dev; @@ -402,10 +401,8 @@ glxiic_attach(device_t dev) tree = device_get_sysctl_tree(dev); sc->timeout = GLXIIC_DEFAULT_TIMEOUT; - snprintf(tn, sizeof(tn), "dev.glxiic.%d.timeout", unit); - TUNABLE_INT_FETCH(tn, &sc->timeout); SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "timeout", CTLFLAG_RW | CTLFLAG_TUN, &sc->timeout, 0, + "timeout", CTLFLAG_RWTUN, &sc->timeout, 0, "activity timeout in ms"); glxiic_gpio_enable(sc); diff --git a/sys/dev/hptmv/hptproc.c b/sys/dev/hptmv/hptproc.c index 93eff51d8dcb6..1141edc06c632 100644 --- a/sys/dev/hptmv/hptproc.c +++ b/sys/dev/hptmv/hptproc.c @@ -617,7 +617,7 @@ out: NULL, 0, hpt_status, "A", "Get/Set " #name " state") #else #define hptregister_node(name) \ - SYSCTL_NODE(, OID_AUTO, name, CTLFLAG_RW, 0, "Get/Set " #name " state root node"); \ + SYSCTL_ROOT_NODE(OID_AUTO, name, CTLFLAG_RW, 0, "Get/Set " #name " state root node"); \ SYSCTL_OID(_ ## name, OID_AUTO, status, CTLTYPE_STRING|CTLFLAG_RW, \ NULL, 0, hpt_status, "A", "Get/Set " #name " state"); #endif diff --git a/sys/dev/hwpmc/hwpmc_logging.c b/sys/dev/hwpmc/hwpmc_logging.c index c9b8aeaf5af13..ee5b89771f7b0 100644 --- a/sys/dev/hwpmc/hwpmc_logging.c +++ b/sys/dev/hwpmc/hwpmc_logging.c @@ -66,8 +66,7 @@ SYSCTL_DECL(_kern_hwpmc); */ static int pmclog_buffer_size = PMC_LOG_BUFFER_SIZE; -TUNABLE_INT(PMC_SYSCTL_NAME_PREFIX "logbuffersize", &pmclog_buffer_size); -SYSCTL_INT(_kern_hwpmc, OID_AUTO, logbuffersize, CTLFLAG_TUN|CTLFLAG_RD, +SYSCTL_INT(_kern_hwpmc, OID_AUTO, logbuffersize, CTLFLAG_RDTUN, &pmclog_buffer_size, 0, "size of log buffers in kilobytes"); /* @@ -75,8 +74,7 @@ SYSCTL_INT(_kern_hwpmc, OID_AUTO, logbuffersize, CTLFLAG_TUN|CTLFLAG_RD, */ static int pmc_nlogbuffers = PMC_NLOGBUFFERS; -TUNABLE_INT(PMC_SYSCTL_NAME_PREFIX "nbuffers", &pmc_nlogbuffers); -SYSCTL_INT(_kern_hwpmc, OID_AUTO, nbuffers, CTLFLAG_TUN|CTLFLAG_RD, +SYSCTL_INT(_kern_hwpmc, OID_AUTO, nbuffers, CTLFLAG_RDTUN, &pmc_nlogbuffers, 0, "number of global log buffers"); /* diff --git a/sys/dev/hwpmc/hwpmc_mod.c b/sys/dev/hwpmc/hwpmc_mod.c index 8e5eac879d24a..6241638d13b03 100644 --- a/sys/dev/hwpmc/hwpmc_mod.c +++ b/sys/dev/hwpmc/hwpmc_mod.c @@ -234,8 +234,7 @@ static void pmc_generic_cpu_finalize(struct pmc_mdep *md); SYSCTL_DECL(_kern_hwpmc); static int pmc_callchaindepth = PMC_CALLCHAIN_DEPTH; -TUNABLE_INT(PMC_SYSCTL_NAME_PREFIX "callchaindepth", &pmc_callchaindepth); -SYSCTL_INT(_kern_hwpmc, OID_AUTO, callchaindepth, CTLFLAG_TUN|CTLFLAG_RD, +SYSCTL_INT(_kern_hwpmc, OID_AUTO, callchaindepth, CTLFLAG_RDTUN, &pmc_callchaindepth, 0, "depth of call chain records"); #ifdef DEBUG @@ -244,7 +243,7 @@ char pmc_debugstr[PMC_DEBUG_STRSIZE]; TUNABLE_STR(PMC_SYSCTL_NAME_PREFIX "debugflags", pmc_debugstr, sizeof(pmc_debugstr)); SYSCTL_PROC(_kern_hwpmc, OID_AUTO, debugflags, - CTLTYPE_STRING|CTLFLAG_RW|CTLFLAG_TUN, + CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_NOFETCH, 0, 0, pmc_debugflags_sysctl_handler, "A", "debug flags"); #endif @@ -254,8 +253,7 @@ SYSCTL_PROC(_kern_hwpmc, OID_AUTO, debugflags, */ static int pmc_hashsize = PMC_HASH_SIZE; -TUNABLE_INT(PMC_SYSCTL_NAME_PREFIX "hashsize", &pmc_hashsize); -SYSCTL_INT(_kern_hwpmc, OID_AUTO, hashsize, CTLFLAG_TUN|CTLFLAG_RD, +SYSCTL_INT(_kern_hwpmc, OID_AUTO, hashsize, CTLFLAG_RDTUN, &pmc_hashsize, 0, "rows in hash tables"); /* @@ -263,8 +261,7 @@ SYSCTL_INT(_kern_hwpmc, OID_AUTO, hashsize, CTLFLAG_TUN|CTLFLAG_RD, */ static int pmc_nsamples = PMC_NSAMPLES; -TUNABLE_INT(PMC_SYSCTL_NAME_PREFIX "nsamples", &pmc_nsamples); -SYSCTL_INT(_kern_hwpmc, OID_AUTO, nsamples, CTLFLAG_TUN|CTLFLAG_RD, +SYSCTL_INT(_kern_hwpmc, OID_AUTO, nsamples, CTLFLAG_RDTUN, &pmc_nsamples, 0, "number of PC samples per CPU"); @@ -273,8 +270,7 @@ SYSCTL_INT(_kern_hwpmc, OID_AUTO, nsamples, CTLFLAG_TUN|CTLFLAG_RD, */ static int pmc_mtxpool_size = PMC_MTXPOOL_SIZE; -TUNABLE_INT(PMC_SYSCTL_NAME_PREFIX "mtxpoolsize", &pmc_mtxpool_size); -SYSCTL_INT(_kern_hwpmc, OID_AUTO, mtxpoolsize, CTLFLAG_TUN|CTLFLAG_RD, +SYSCTL_INT(_kern_hwpmc, OID_AUTO, mtxpoolsize, CTLFLAG_RDTUN, &pmc_mtxpool_size, 0, "size of spin mutex pool"); @@ -288,8 +284,7 @@ SYSCTL_INT(_kern_hwpmc, OID_AUTO, mtxpoolsize, CTLFLAG_TUN|CTLFLAG_RD, */ static int pmc_unprivileged_syspmcs = 0; -TUNABLE_INT("security.bsd.unprivileged_syspmcs", &pmc_unprivileged_syspmcs); -SYSCTL_INT(_security_bsd, OID_AUTO, unprivileged_syspmcs, CTLFLAG_RW, +SYSCTL_INT(_security_bsd, OID_AUTO, unprivileged_syspmcs, CTLFLAG_RWTUN, &pmc_unprivileged_syspmcs, 0, "allow unprivileged process to allocate system PMCs"); diff --git a/sys/dev/iscsi/icl.c b/sys/dev/iscsi/icl.c index 2b5e4d0dba6d0..a22dd7980fd96 100644 --- a/sys/dev/iscsi/icl.c +++ b/sys/dev/iscsi/icl.c @@ -61,24 +61,19 @@ SYSCTL_NODE(_kern, OID_AUTO, icl, CTLFLAG_RD, 0, "iSCSI Common Layer"); static int debug = 1; -TUNABLE_INT("kern.icl.debug", &debug); SYSCTL_INT(_kern_icl, OID_AUTO, debug, CTLFLAG_RWTUN, &debug, 0, "Enable debug messages"); static int coalesce = 1; -TUNABLE_INT("kern.icl.coalesce", &coalesce); SYSCTL_INT(_kern_icl, OID_AUTO, coalesce, CTLFLAG_RWTUN, &coalesce, 0, "Try to coalesce PDUs before sending"); static int partial_receive_len = 128 * 1024; -TUNABLE_INT("kern.icl.partial_receive_len", &partial_receive_len); SYSCTL_INT(_kern_icl, OID_AUTO, partial_receive_len, CTLFLAG_RWTUN, &partial_receive_len, 0, "Minimum read size for partially received " "data segment"); static int sendspace = 1048576; -TUNABLE_INT("kern.icl.sendspace", &sendspace); SYSCTL_INT(_kern_icl, OID_AUTO, sendspace, CTLFLAG_RWTUN, &sendspace, 0, "Default send socket buffer size"); static int recvspace = 1048576; -TUNABLE_INT("kern.icl.recvspace", &recvspace); SYSCTL_INT(_kern_icl, OID_AUTO, recvspace, CTLFLAG_RWTUN, &recvspace, 0, "Default receive socket buffer size"); diff --git a/sys/dev/iscsi/iscsi.c b/sys/dev/iscsi/iscsi.c index ad9ec7a218a4a..22f84623c9803 100644 --- a/sys/dev/iscsi/iscsi.c +++ b/sys/dev/iscsi/iscsi.c @@ -78,27 +78,21 @@ static struct iscsi_softc *sc; SYSCTL_NODE(_kern, OID_AUTO, iscsi, CTLFLAG_RD, 0, "iSCSI initiator"); static int debug = 1; -TUNABLE_INT("kern.iscsi.debug", &debug); SYSCTL_INT(_kern_iscsi, OID_AUTO, debug, CTLFLAG_RWTUN, &debug, 0, "Enable debug messages"); static int ping_timeout = 5; -TUNABLE_INT("kern.iscsi.ping_timeout", &ping_timeout); SYSCTL_INT(_kern_iscsi, OID_AUTO, ping_timeout, CTLFLAG_RWTUN, &ping_timeout, 0, "Timeout for ping (NOP-Out) requests, in seconds"); static int iscsid_timeout = 60; -TUNABLE_INT("kern.iscsi.iscsid_timeout", &iscsid_timeout); SYSCTL_INT(_kern_iscsi, OID_AUTO, iscsid_timeout, CTLFLAG_RWTUN, &iscsid_timeout, 0, "Time to wait for iscsid(8) to handle reconnection, in seconds"); static int login_timeout = 60; -TUNABLE_INT("kern.iscsi.login_timeout", &login_timeout); SYSCTL_INT(_kern_iscsi, OID_AUTO, login_timeout, CTLFLAG_RWTUN, &login_timeout, 0, "Time to wait for iscsid(8) to finish Login Phase, in seconds"); static int maxtags = 255; -TUNABLE_INT("kern.iscsi.maxtags", &maxtags); SYSCTL_INT(_kern_iscsi, OID_AUTO, maxtags, CTLFLAG_RWTUN, &maxtags, 0, "Max number of IO requests queued"); static int fail_on_disconnection = 0; -TUNABLE_INT("kern.iscsi.fail_on_disconnection", &fail_on_disconnection); SYSCTL_INT(_kern_iscsi, OID_AUTO, fail_on_disconnection, CTLFLAG_RWTUN, &fail_on_disconnection, 0, "Destroy CAM SIM on connection failure"); diff --git a/sys/dev/iscsi_initiator/iscsi.c b/sys/dev/iscsi_initiator/iscsi.c index cd66a369fa749..049c1112d6c86 100644 --- a/sys/dev/iscsi_initiator/iscsi.c +++ b/sys/dev/iscsi_initiator/iscsi.c @@ -77,11 +77,11 @@ struct mtx iscsi_dbg_mtx; #endif static int max_sessions = MAX_SESSIONS; -SYSCTL_INT(_net, OID_AUTO, iscsi_initiator_max_sessions, CTLFLAG_RDTUN, &max_sessions, MAX_SESSIONS, - "Max sessions allowed"); +SYSCTL_INT(_net, OID_AUTO, iscsi_initiator_max_sessions, CTLFLAG_RDTUN, + &max_sessions, 0, "Max sessions allowed"); static int max_pdus = MAX_PDUS; -SYSCTL_INT(_net, OID_AUTO, iscsi_initiator_max_pdus, CTLFLAG_RDTUN, &max_pdus, MAX_PDUS, - "Max pdu pool"); +SYSCTL_INT(_net, OID_AUTO, iscsi_initiator_max_pdus, CTLFLAG_RDTUN, + &max_pdus, 0, "Max PDU pool"); static char isid[6+1] = { 0x80, @@ -711,9 +711,6 @@ iscsi_start(void) { debug_called(8); - TUNABLE_INT_FETCH("net.iscsi_initiator.max_sessions", &max_sessions); - TUNABLE_INT_FETCH("net.iscsi_initiator.max_pdus", &max_pdus); - isc = malloc(sizeof(struct isc_softc), M_ISCSI, M_ZERO|M_WAITOK); mtx_init(&isc->isc_mtx, "iscsi-isc", NULL, MTX_DEF); diff --git a/sys/dev/ixgbe/ixgbe.c b/sys/dev/ixgbe/ixgbe.c index fb0daa1921ba6..0eb334a11675c 100644 --- a/sys/dev/ixgbe/ixgbe.c +++ b/sys/dev/ixgbe/ixgbe.c @@ -244,18 +244,15 @@ static SYSCTL_NODE(_hw, OID_AUTO, ix, CTLFLAG_RD, 0, ** traffic for that interrupt vector */ static int ixgbe_enable_aim = TRUE; -TUNABLE_INT("hw.ixgbe.enable_aim", &ixgbe_enable_aim); -SYSCTL_INT(_hw_ix, OID_AUTO, enable_aim, CTLFLAG_RW, &ixgbe_enable_aim, 0, +SYSCTL_INT(_hw_ix, OID_AUTO, enable_aim, CTLFLAG_RWTUN, &ixgbe_enable_aim, 0, "Enable adaptive interrupt moderation"); static int ixgbe_max_interrupt_rate = (4000000 / IXGBE_LOW_LATENCY); -TUNABLE_INT("hw.ixgbe.max_interrupt_rate", &ixgbe_max_interrupt_rate); SYSCTL_INT(_hw_ix, OID_AUTO, max_interrupt_rate, CTLFLAG_RDTUN, &ixgbe_max_interrupt_rate, 0, "Maximum interrupts per second"); /* How many packets rxeof tries to clean at a time */ static int ixgbe_rx_process_limit = 256; -TUNABLE_INT("hw.ixgbe.rx_process_limit", &ixgbe_rx_process_limit); SYSCTL_INT(_hw_ix, OID_AUTO, rx_process_limit, CTLFLAG_RDTUN, &ixgbe_rx_process_limit, 0, "Maximum number of received packets to process at a time," @@ -263,7 +260,6 @@ SYSCTL_INT(_hw_ix, OID_AUTO, rx_process_limit, CTLFLAG_RDTUN, /* How many packets txeof tries to clean at a time */ static int ixgbe_tx_process_limit = 256; -TUNABLE_INT("hw.ixgbe.tx_process_limit", &ixgbe_tx_process_limit); SYSCTL_INT(_hw_ix, OID_AUTO, tx_process_limit, CTLFLAG_RDTUN, &ixgbe_tx_process_limit, 0, "Maximum number of sent packets to process at a time," @@ -283,7 +279,6 @@ static int ixgbe_smart_speed = ixgbe_smart_speed_on; * but this allows it to be forced off for testing. */ static int ixgbe_enable_msix = 1; -TUNABLE_INT("hw.ixgbe.enable_msix", &ixgbe_enable_msix); SYSCTL_INT(_hw_ix, OID_AUTO, enable_msix, CTLFLAG_RDTUN, &ixgbe_enable_msix, 0, "Enable MSI-X interrupts"); @@ -294,7 +289,6 @@ SYSCTL_INT(_hw_ix, OID_AUTO, enable_msix, CTLFLAG_RDTUN, &ixgbe_enable_msix, 0, * can be overriden manually here. */ static int ixgbe_num_queues = 0; -TUNABLE_INT("hw.ixgbe.num_queues", &ixgbe_num_queues); SYSCTL_INT(_hw_ix, OID_AUTO, num_queues, CTLFLAG_RDTUN, &ixgbe_num_queues, 0, "Number of queues to configure, 0 indicates autoconfigure"); @@ -304,13 +298,11 @@ SYSCTL_INT(_hw_ix, OID_AUTO, num_queues, CTLFLAG_RDTUN, &ixgbe_num_queues, 0, ** the better performing choice. */ static int ixgbe_txd = PERFORM_TXD; -TUNABLE_INT("hw.ixgbe.txd", &ixgbe_txd); SYSCTL_INT(_hw_ix, OID_AUTO, txd, CTLFLAG_RDTUN, &ixgbe_txd, 0, "Number of receive descriptors per queue"); /* Number of RX descriptors per ring */ static int ixgbe_rxd = PERFORM_RXD; -TUNABLE_INT("hw.ixgbe.rxd", &ixgbe_rxd); SYSCTL_INT(_hw_ix, OID_AUTO, rxd, CTLFLAG_RDTUN, &ixgbe_rxd, 0, "Number of receive descriptors per queue"); diff --git a/sys/dev/malo/if_malo.c b/sys/dev/malo/if_malo.c index db8f61d7437b2..1e879ba9459fb 100644 --- a/sys/dev/malo/if_malo.c +++ b/sys/dev/malo/if_malo.c @@ -65,27 +65,22 @@ SYSCTL_NODE(_hw, OID_AUTO, malo, CTLFLAG_RD, 0, "Marvell 88w8335 driver parameters"); static int malo_txcoalesce = 8; /* # tx pkts to q before poking f/w*/ -SYSCTL_INT(_hw_malo, OID_AUTO, txcoalesce, CTLFLAG_RW, &malo_txcoalesce, +SYSCTL_INT(_hw_malo, OID_AUTO, txcoalesce, CTLFLAG_RWTUN, &malo_txcoalesce, 0, "tx buffers to send at once"); -TUNABLE_INT("hw.malo.txcoalesce", &malo_txcoalesce); static int malo_rxbuf = MALO_RXBUF; /* # rx buffers to allocate */ -SYSCTL_INT(_hw_malo, OID_AUTO, rxbuf, CTLFLAG_RW, &malo_rxbuf, +SYSCTL_INT(_hw_malo, OID_AUTO, rxbuf, CTLFLAG_RWTUN, &malo_rxbuf, 0, "rx buffers allocated"); -TUNABLE_INT("hw.malo.rxbuf", &malo_rxbuf); static int malo_rxquota = MALO_RXBUF; /* # max buffers to process */ -SYSCTL_INT(_hw_malo, OID_AUTO, rxquota, CTLFLAG_RW, &malo_rxquota, +SYSCTL_INT(_hw_malo, OID_AUTO, rxquota, CTLFLAG_RWTUN, &malo_rxquota, 0, "max rx buffers to process per interrupt"); -TUNABLE_INT("hw.malo.rxquota", &malo_rxquota); static int malo_txbuf = MALO_TXBUF; /* # tx buffers to allocate */ -SYSCTL_INT(_hw_malo, OID_AUTO, txbuf, CTLFLAG_RW, &malo_txbuf, +SYSCTL_INT(_hw_malo, OID_AUTO, txbuf, CTLFLAG_RWTUN, &malo_txbuf, 0, "tx buffers allocated"); -TUNABLE_INT("hw.malo.txbuf", &malo_txbuf); #ifdef MALO_DEBUG static int malo_debug = 0; -SYSCTL_INT(_hw_malo, OID_AUTO, debug, CTLFLAG_RW, &malo_debug, +SYSCTL_INT(_hw_malo, OID_AUTO, debug, CTLFLAG_RWTUN, &malo_debug, 0, "control debugging printfs"); -TUNABLE_INT("hw.malo.debug", &malo_debug); enum { MALO_DEBUG_XMIT = 0x00000001, /* basic xmit operation */ MALO_DEBUG_XMIT_DESC = 0x00000002, /* xmit descriptors */ diff --git a/sys/dev/malo/if_malo_pci.c b/sys/dev/malo/if_malo_pci.c index 71ba3c0543c5d..c9e6b20703805 100644 --- a/sys/dev/malo/if_malo_pci.c +++ b/sys/dev/malo/if_malo_pci.c @@ -86,9 +86,8 @@ static SYSCTL_NODE(_hw_malo, OID_AUTO, pci, CTLFLAG_RD, 0, "Marvell 88W8335 driver PCI parameters"); static int msi_disable = 0; /* MSI disabled */ -SYSCTL_INT(_hw_malo_pci, OID_AUTO, msi_disable, CTLFLAG_RW, &msi_disable, +SYSCTL_INT(_hw_malo_pci, OID_AUTO, msi_disable, CTLFLAG_RWTUN, &msi_disable, 0, "MSI disabled"); -TUNABLE_INT("hw.malo.pci.msi_disable", &msi_disable); /* * Devices supported by this driver. diff --git a/sys/dev/mfi/mfi.c b/sys/dev/mfi/mfi.c index 1a618ce0b176c..5ec813eafaee4 100644 --- a/sys/dev/mfi/mfi.c +++ b/sys/dev/mfi/mfi.c @@ -132,33 +132,27 @@ static int mfi_check_for_sscd(struct mfi_softc *sc, struct mfi_command *cm); SYSCTL_NODE(_hw, OID_AUTO, mfi, CTLFLAG_RD, 0, "MFI driver parameters"); static int mfi_event_locale = MFI_EVT_LOCALE_ALL; -TUNABLE_INT("hw.mfi.event_locale", &mfi_event_locale); SYSCTL_INT(_hw_mfi, OID_AUTO, event_locale, CTLFLAG_RWTUN, &mfi_event_locale, 0, "event message locale"); static int mfi_event_class = MFI_EVT_CLASS_INFO; -TUNABLE_INT("hw.mfi.event_class", &mfi_event_class); SYSCTL_INT(_hw_mfi, OID_AUTO, event_class, CTLFLAG_RWTUN, &mfi_event_class, 0, "event message class"); static int mfi_max_cmds = 128; -TUNABLE_INT("hw.mfi.max_cmds", &mfi_max_cmds); SYSCTL_INT(_hw_mfi, OID_AUTO, max_cmds, CTLFLAG_RDTUN, &mfi_max_cmds, 0, "Max commands limit (-1 = controller limit)"); static int mfi_detect_jbod_change = 1; -TUNABLE_INT("hw.mfi.detect_jbod_change", &mfi_detect_jbod_change); SYSCTL_INT(_hw_mfi, OID_AUTO, detect_jbod_change, CTLFLAG_RWTUN, &mfi_detect_jbod_change, 0, "Detect a change to a JBOD"); int mfi_polled_cmd_timeout = MFI_POLL_TIMEOUT_SECS; -TUNABLE_INT("hw.mfi.polled_cmd_timeout", &mfi_polled_cmd_timeout); SYSCTL_INT(_hw_mfi, OID_AUTO, polled_cmd_timeout, CTLFLAG_RWTUN, &mfi_polled_cmd_timeout, 0, "Polled command timeout - used for firmware flash etc (in seconds)"); static int mfi_cmd_timeout = MFI_CMD_TIMEOUT; -TUNABLE_INT("hw.mfi.cmd_timeout", &mfi_cmd_timeout); SYSCTL_INT(_hw_mfi, OID_AUTO, cmd_timeout, CTLFLAG_RWTUN, &mfi_cmd_timeout, 0, "Command timeout (in seconds)"); diff --git a/sys/dev/mfi/mfi_cam.c b/sys/dev/mfi/mfi_cam.c index 4fd6198a8a851..87f854c3f33e6 100644 --- a/sys/dev/mfi/mfi_cam.c +++ b/sys/dev/mfi/mfi_cam.c @@ -90,8 +90,7 @@ static struct mfi_command * mfip_start(void *); static void mfip_done(struct mfi_command *cm); static int mfi_allow_disks = 0; -TUNABLE_INT("hw.mfi.allow_cam_disk_passthrough", &mfi_allow_disks); -SYSCTL_INT(_hw_mfi, OID_AUTO, allow_cam_disk_passthrough, CTLFLAG_RD, +SYSCTL_INT(_hw_mfi, OID_AUTO, allow_cam_disk_passthrough, CTLFLAG_RDTUN, &mfi_allow_disks, 0, "event message locale"); static devclass_t mfip_devclass; diff --git a/sys/dev/mfi/mfi_pci.c b/sys/dev/mfi/mfi_pci.c index 803584e439a1a..80d655cf1b02d 100644 --- a/sys/dev/mfi/mfi_pci.c +++ b/sys/dev/mfi/mfi_pci.c @@ -108,12 +108,10 @@ DRIVER_MODULE(mfi, pci, mfi_pci_driver, mfi_devclass, 0, 0); MODULE_VERSION(mfi, 1); static int mfi_msi = 1; -TUNABLE_INT("hw.mfi.msi", &mfi_msi); SYSCTL_INT(_hw_mfi, OID_AUTO, msi, CTLFLAG_RDTUN, &mfi_msi, 0, "Enable use of MSI interrupts"); -static int mfi_mrsas_enable = 0; -TUNABLE_INT("hw.mfi.mrsas_enable", &mfi_mrsas_enable); +static int mfi_mrsas_enable; SYSCTL_INT(_hw_mfi, OID_AUTO, mrsas_enable, CTLFLAG_RDTUN, &mfi_mrsas_enable, 0, "Allow mrasas to take newer cards"); @@ -186,7 +184,6 @@ mfi_pci_probe(device_t dev) device_set_desc(dev, id->desc); /* give priority to mrsas if tunable set */ - TUNABLE_INT_FETCH("hw.mfi.mrsas_enable", &mfi_mrsas_enable); if ((id->flags & MFI_FLAGS_MRSAS) && mfi_mrsas_enable) return (BUS_PROBE_LOW_PRIORITY); else diff --git a/sys/dev/mfi/mfi_tbolt.c b/sys/dev/mfi/mfi_tbolt.c index 2d27534062c3e..984c355321e7f 100644 --- a/sys/dev/mfi/mfi_tbolt.c +++ b/sys/dev/mfi/mfi_tbolt.c @@ -86,7 +86,6 @@ static void mfi_queue_map_sync(struct mfi_softc *sc); extern int mfi_polled_cmd_timeout; static int mfi_fw_reset_test = 0; #ifdef MFI_DEBUG -TUNABLE_INT("hw.mfi.fw_reset_test", &mfi_fw_reset_test); SYSCTL_INT(_hw_mfi, OID_AUTO, fw_reset_test, CTLFLAG_RWTUN, &mfi_fw_reset_test, 0, "Force a firmware reset condition"); #endif diff --git a/sys/dev/mwl/if_mwl.c b/sys/dev/mwl/if_mwl.c index b50e1a9379076..b5bd9bd5003d6 100644 --- a/sys/dev/mwl/if_mwl.c +++ b/sys/dev/mwl/if_mwl.c @@ -188,31 +188,25 @@ static int mwl_rxdesc = MWL_RXDESC; /* # rx desc's to allocate */ SYSCTL_INT(_hw_mwl, OID_AUTO, rxdesc, CTLFLAG_RW, &mwl_rxdesc, 0, "rx descriptors allocated"); static int mwl_rxbuf = MWL_RXBUF; /* # rx buffers to allocate */ -SYSCTL_INT(_hw_mwl, OID_AUTO, rxbuf, CTLFLAG_RW, &mwl_rxbuf, +SYSCTL_INT(_hw_mwl, OID_AUTO, rxbuf, CTLFLAG_RWTUN, &mwl_rxbuf, 0, "rx buffers allocated"); -TUNABLE_INT("hw.mwl.rxbuf", &mwl_rxbuf); static int mwl_txbuf = MWL_TXBUF; /* # tx buffers to allocate */ -SYSCTL_INT(_hw_mwl, OID_AUTO, txbuf, CTLFLAG_RW, &mwl_txbuf, +SYSCTL_INT(_hw_mwl, OID_AUTO, txbuf, CTLFLAG_RWTUN, &mwl_txbuf, 0, "tx buffers allocated"); -TUNABLE_INT("hw.mwl.txbuf", &mwl_txbuf); static int mwl_txcoalesce = 8; /* # tx packets to q before poking f/w*/ -SYSCTL_INT(_hw_mwl, OID_AUTO, txcoalesce, CTLFLAG_RW, &mwl_txcoalesce, +SYSCTL_INT(_hw_mwl, OID_AUTO, txcoalesce, CTLFLAG_RWTUN, &mwl_txcoalesce, 0, "tx buffers to send at once"); -TUNABLE_INT("hw.mwl.txcoalesce", &mwl_txcoalesce); static int mwl_rxquota = MWL_RXBUF; /* # max buffers to process */ -SYSCTL_INT(_hw_mwl, OID_AUTO, rxquota, CTLFLAG_RW, &mwl_rxquota, +SYSCTL_INT(_hw_mwl, OID_AUTO, rxquota, CTLFLAG_RWTUN, &mwl_rxquota, 0, "max rx buffers to process per interrupt"); -TUNABLE_INT("hw.mwl.rxquota", &mwl_rxquota); static int mwl_rxdmalow = 3; /* # min buffers for wakeup */ -SYSCTL_INT(_hw_mwl, OID_AUTO, rxdmalow, CTLFLAG_RW, &mwl_rxdmalow, +SYSCTL_INT(_hw_mwl, OID_AUTO, rxdmalow, CTLFLAG_RWTUN, &mwl_rxdmalow, 0, "min free rx buffers before restarting traffic"); -TUNABLE_INT("hw.mwl.rxdmalow", &mwl_rxdmalow); #ifdef MWL_DEBUG static int mwl_debug = 0; -SYSCTL_INT(_hw_mwl, OID_AUTO, debug, CTLFLAG_RW, &mwl_debug, +SYSCTL_INT(_hw_mwl, OID_AUTO, debug, CTLFLAG_RWTUN, &mwl_debug, 0, "control debugging printfs"); -TUNABLE_INT("hw.mwl.debug", &mwl_debug); enum { MWL_DEBUG_XMIT = 0x00000001, /* basic xmit operation */ MWL_DEBUG_XMIT_DESC = 0x00000002, /* xmit descriptors */ diff --git a/sys/dev/nand/nand.c b/sys/dev/nand/nand.c index fb83e673861b5..113953ef8f375 100644 --- a/sys/dev/nand/nand.c +++ b/sys/dev/nand/nand.c @@ -65,18 +65,9 @@ __FBSDID("$FreeBSD$"); #define SOFTECC_BYTES 3 int nand_debug_flag = 0; -SYSCTL_INT(_debug, OID_AUTO, nand_debug, CTLFLAG_RW, &nand_debug_flag, 0, +SYSCTL_INT(_debug, OID_AUTO, nand_debug, CTLFLAG_RWTUN, &nand_debug_flag, 0, "NAND subsystem debug flag"); -static void -nand_tunable_init(void *arg) -{ - - TUNABLE_INT_FETCH("debug.nand", &nand_debug_flag); -} - -SYSINIT(nand_tunables, SI_SUB_VFS, SI_ORDER_ANY, nand_tunable_init, NULL); - MALLOC_DEFINE(M_NAND, "NAND", "NAND dynamic data"); static void calculate_ecc(const uint8_t *, uint8_t *); diff --git a/sys/dev/pccard/pccard.c b/sys/dev/pccard/pccard.c index 0c49d2f38a7ff..87ab53abcf4a3 100644 --- a/sys/dev/pccard/pccard.c +++ b/sys/dev/pccard/pccard.c @@ -62,14 +62,12 @@ __FBSDID("$FreeBSD$"); static SYSCTL_NODE(_hw, OID_AUTO, pccard, CTLFLAG_RD, 0, "PCCARD parameters"); int pccard_debug = 0; -TUNABLE_INT("hw.pccard.debug", &pccard_debug); -SYSCTL_INT(_hw_pccard, OID_AUTO, debug, CTLFLAG_RW, +SYSCTL_INT(_hw_pccard, OID_AUTO, debug, CTLFLAG_RWTUN, &pccard_debug, 0, "pccard debug"); int pccard_cis_debug = 0; -TUNABLE_INT("hw.pccard.cis_debug", &pccard_cis_debug); -SYSCTL_INT(_hw_pccard, OID_AUTO, cis_debug, CTLFLAG_RW, +SYSCTL_INT(_hw_pccard, OID_AUTO, cis_debug, CTLFLAG_RWTUN, &pccard_cis_debug, 0, "pccard CIS debug"); #ifdef PCCARDDEBUG diff --git a/sys/dev/pccbb/pccbb.c b/sys/dev/pccbb/pccbb.c index 092d3efae773b..b724d05e04231 100644 --- a/sys/dev/pccbb/pccbb.c +++ b/sys/dev/pccbb/pccbb.c @@ -134,26 +134,22 @@ static SYSCTL_NODE(_hw, OID_AUTO, cbb, CTLFLAG_RD, 0, "CBB parameters"); /* There's no way to say TUNEABLE_LONG to get the right types */ u_long cbb_start_mem = CBB_START_MEM; -TUNABLE_ULONG("hw.cbb.start_memory", &cbb_start_mem); -SYSCTL_ULONG(_hw_cbb, OID_AUTO, start_memory, CTLFLAG_RW, +SYSCTL_ULONG(_hw_cbb, OID_AUTO, start_memory, CTLFLAG_RWTUN, &cbb_start_mem, CBB_START_MEM, "Starting address for memory allocations"); u_long cbb_start_16_io = CBB_START_16_IO; -TUNABLE_ULONG("hw.cbb.start_16_io", &cbb_start_16_io); -SYSCTL_ULONG(_hw_cbb, OID_AUTO, start_16_io, CTLFLAG_RW, +SYSCTL_ULONG(_hw_cbb, OID_AUTO, start_16_io, CTLFLAG_RWTUN, &cbb_start_16_io, CBB_START_16_IO, "Starting ioport for 16-bit cards"); u_long cbb_start_32_io = CBB_START_32_IO; -TUNABLE_ULONG("hw.cbb.start_32_io", &cbb_start_32_io); -SYSCTL_ULONG(_hw_cbb, OID_AUTO, start_32_io, CTLFLAG_RW, +SYSCTL_ULONG(_hw_cbb, OID_AUTO, start_32_io, CTLFLAG_RWTUN, &cbb_start_32_io, CBB_START_32_IO, "Starting ioport for 32-bit cards"); int cbb_debug = 0; -TUNABLE_INT("hw.cbb.debug", &cbb_debug); -SYSCTL_INT(_hw_cbb, OID_AUTO, debug, CTLFLAG_RW, &cbb_debug, 0, +SYSCTL_INT(_hw_cbb, OID_AUTO, debug, CTLFLAG_RWTUN, &cbb_debug, 0, "Verbose cardbus bridge debugging"); static void cbb_insert(struct cbb_softc *sc); diff --git a/sys/dev/pccbb/pccbb_isa.c b/sys/dev/pccbb/pccbb_isa.c index 1d0a698da78b0..c511062510556 100644 --- a/sys/dev/pccbb/pccbb_isa.c +++ b/sys/dev/pccbb/pccbb_isa.c @@ -74,8 +74,7 @@ __FBSDID("$FreeBSD$"); static SYSCTL_NODE(_hw, OID_AUTO, pcic, CTLFLAG_RD, 0, "PCIC parameters"); static int isa_intr_mask = EXCA_INT_MASK_ALLOWED; -TUNABLE_INT("hw.cbb.intr_mask", &isa_intr_mask); -SYSCTL_INT(_hw_pcic, OID_AUTO, intr_mask, CTLFLAG_RD, &isa_intr_mask, 0, +SYSCTL_INT(_hw_pcic, OID_AUTO, intr_mask, CTLFLAG_RDTUN, &isa_intr_mask, 0, "Mask of allowable interrupts for this laptop. The default is generally\n\ correct, but some laptops do not route all the IRQ pins to the bridge to\n\ save wires. Sometimes you need a more restrictive mask because some of the\n\ @@ -89,7 +88,6 @@ allocated."); * 2: 6729's method */ int pcic_pd6722_vsense = 1; -TUNABLE_INT("hw.pcic.pd6722_vsense", &pcic_pd6722_vsense); SYSCTL_INT(_hw_pcic, OID_AUTO, pd6722_vsense, CTLFLAG_RDTUN, &pcic_pd6722_vsense, 1, "Select CL-PD6722's VSENSE method. VSENSE is used to determine the\n\ diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index b2b5ff80d0d54..9733841803ab6 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -282,22 +282,20 @@ static int pcie_chipset, pcix_chipset; SYSCTL_NODE(_hw, OID_AUTO, pci, CTLFLAG_RD, 0, "PCI bus tuning parameters"); static int pci_enable_io_modes = 1; -TUNABLE_INT("hw.pci.enable_io_modes", &pci_enable_io_modes); -SYSCTL_INT(_hw_pci, OID_AUTO, enable_io_modes, CTLFLAG_RW, +SYSCTL_INT(_hw_pci, OID_AUTO, enable_io_modes, CTLFLAG_RWTUN, &pci_enable_io_modes, 1, "Enable I/O and memory bits in the config register. Some BIOSes do not\n\ enable these bits correctly. We'd like to do this all the time, but there\n\ are some peripherals that this causes problems with."); static int pci_do_realloc_bars = 0; -TUNABLE_INT("hw.pci.realloc_bars", &pci_do_realloc_bars); -SYSCTL_INT(_hw_pci, OID_AUTO, realloc_bars, CTLFLAG_RW, +SYSCTL_INT(_hw_pci, OID_AUTO, realloc_bars, CTLFLAG_RWTUN, &pci_do_realloc_bars, 0, - "Attempt to allocate a new range for any BARs whose original firmware-assigned ranges fail to allocate during the initial device scan."); + "Attempt to allocate a new range for any BARs whose original " + "firmware-assigned ranges fail to allocate during the initial device scan."); static int pci_do_power_nodriver = 0; -TUNABLE_INT("hw.pci.do_power_nodriver", &pci_do_power_nodriver); -SYSCTL_INT(_hw_pci, OID_AUTO, do_power_nodriver, CTLFLAG_RW, +SYSCTL_INT(_hw_pci, OID_AUTO, do_power_nodriver, CTLFLAG_RWTUN, &pci_do_power_nodriver, 0, "Place a function into D3 state when no driver attaches to it. 0 means\n\ disable. 1 means conservatively place devices into D3 state. 2 means\n\ @@ -305,30 +303,25 @@ agressively place devices into D3 state. 3 means put absolutely everything\n\ in D3 state."); int pci_do_power_resume = 1; -TUNABLE_INT("hw.pci.do_power_resume", &pci_do_power_resume); -SYSCTL_INT(_hw_pci, OID_AUTO, do_power_resume, CTLFLAG_RW, +SYSCTL_INT(_hw_pci, OID_AUTO, do_power_resume, CTLFLAG_RWTUN, &pci_do_power_resume, 1, "Transition from D3 -> D0 on resume."); int pci_do_power_suspend = 1; -TUNABLE_INT("hw.pci.do_power_suspend", &pci_do_power_suspend); -SYSCTL_INT(_hw_pci, OID_AUTO, do_power_suspend, CTLFLAG_RW, +SYSCTL_INT(_hw_pci, OID_AUTO, do_power_suspend, CTLFLAG_RWTUN, &pci_do_power_suspend, 1, "Transition from D0 -> D3 on suspend."); static int pci_do_msi = 1; -TUNABLE_INT("hw.pci.enable_msi", &pci_do_msi); -SYSCTL_INT(_hw_pci, OID_AUTO, enable_msi, CTLFLAG_RW, &pci_do_msi, 1, +SYSCTL_INT(_hw_pci, OID_AUTO, enable_msi, CTLFLAG_RWTUN, &pci_do_msi, 1, "Enable support for MSI interrupts"); static int pci_do_msix = 1; -TUNABLE_INT("hw.pci.enable_msix", &pci_do_msix); -SYSCTL_INT(_hw_pci, OID_AUTO, enable_msix, CTLFLAG_RW, &pci_do_msix, 1, +SYSCTL_INT(_hw_pci, OID_AUTO, enable_msix, CTLFLAG_RWTUN, &pci_do_msix, 1, "Enable support for MSI-X interrupts"); static int pci_honor_msi_blacklist = 1; -TUNABLE_INT("hw.pci.honor_msi_blacklist", &pci_honor_msi_blacklist); -SYSCTL_INT(_hw_pci, OID_AUTO, honor_msi_blacklist, CTLFLAG_RD, +SYSCTL_INT(_hw_pci, OID_AUTO, honor_msi_blacklist, CTLFLAG_RDTUN, &pci_honor_msi_blacklist, 1, "Honor chipset blacklist for MSI/MSI-X"); #if defined(__i386__) || defined(__amd64__) @@ -336,26 +329,22 @@ static int pci_usb_takeover = 1; #else static int pci_usb_takeover = 0; #endif -TUNABLE_INT("hw.pci.usb_early_takeover", &pci_usb_takeover); SYSCTL_INT(_hw_pci, OID_AUTO, usb_early_takeover, CTLFLAG_RDTUN, &pci_usb_takeover, 1, "Enable early takeover of USB controllers.\n\ Disable this if you depend on BIOS emulation of USB devices, that is\n\ you use USB devices (like keyboard or mouse) but do not load USB drivers"); static int pci_clear_bars; -TUNABLE_INT("hw.pci.clear_bars", &pci_clear_bars); SYSCTL_INT(_hw_pci, OID_AUTO, clear_bars, CTLFLAG_RDTUN, &pci_clear_bars, 0, "Ignore firmware-assigned resources for BARs."); #if defined(NEW_PCIB) && defined(PCI_RES_BUS) static int pci_clear_buses; -TUNABLE_INT("hw.pci.clear_buses", &pci_clear_buses); SYSCTL_INT(_hw_pci, OID_AUTO, clear_buses, CTLFLAG_RDTUN, &pci_clear_buses, 0, "Ignore firmware-assigned bus numbers."); #endif static int pci_enable_ari = 1; -TUNABLE_INT("hw.pci.enable_ari", &pci_enable_ari); SYSCTL_INT(_hw_pci, OID_AUTO, enable_ari, CTLFLAG_RDTUN, &pci_enable_ari, 0, "Enable support for PCIe Alternative RID Interpretation"); diff --git a/sys/dev/pci/pci_pci.c b/sys/dev/pci/pci_pci.c index 8b5021974c750..3c5842be44c6d 100644 --- a/sys/dev/pci/pci_pci.c +++ b/sys/dev/pci/pci_pci.c @@ -117,7 +117,6 @@ DRIVER_MODULE(pcib, pci, pcib_driver, pcib_devclass, NULL, NULL); SYSCTL_DECL(_hw_pci); static int pci_clear_pcib; -TUNABLE_INT("hw.pci.clear_pcib", &pci_clear_pcib); SYSCTL_INT(_hw_pci, OID_AUTO, clear_pcib, CTLFLAG_RDTUN, &pci_clear_pcib, 0, "Clear firmware-assigned resources for PCI-PCI bridge I/O windows."); diff --git a/sys/dev/pci/vga_pci.c b/sys/dev/pci/vga_pci.c index 6e733f588d5ed..46f32505c36e1 100644 --- a/sys/dev/pci/vga_pci.c +++ b/sys/dev/pci/vga_pci.c @@ -71,7 +71,6 @@ static int vga_pci_release_resource(device_t dev, device_t child, int type, int rid, struct resource *r); int vga_pci_default_unit = -1; -TUNABLE_INT("hw.pci.default_vgapci_unit", &vga_pci_default_unit); SYSCTL_INT(_hw_pci, OID_AUTO, default_vgapci_unit, CTLFLAG_RDTUN, &vga_pci_default_unit, -1, "Default VGA-compatible display"); diff --git a/sys/dev/puc/puc_pci.c b/sys/dev/puc/puc_pci.c index d6d5509050c3b..618a3ae036911 100644 --- a/sys/dev/puc/puc_pci.c +++ b/sys/dev/puc/puc_pci.c @@ -80,8 +80,7 @@ __FBSDID("$FreeBSD$"); #include static int puc_msi_disable; -TUNABLE_INT("hw.puc.msi_disable", &puc_msi_disable); -SYSCTL_INT(_hw_puc, OID_AUTO, msi_disable, CTLFLAG_RD | CTLFLAG_TUN, +SYSCTL_INT(_hw_puc, OID_AUTO, msi_disable, CTLFLAG_RDTUN, &puc_msi_disable, 0, "Disable use of MSI interrupts by puc(9)"); static const struct puc_cfg * diff --git a/sys/dev/rt/if_rt.c b/sys/dev/rt/if_rt.c index 5f62fec6920df..aaf84f3829689 100644 --- a/sys/dev/rt/if_rt.c +++ b/sys/dev/rt/if_rt.c @@ -140,9 +140,8 @@ static void rt_ifmedia_sts(struct ifnet *, struct ifmediareq *); static SYSCTL_NODE(_hw, OID_AUTO, rt, CTLFLAG_RD, 0, "RT driver parameters"); #ifdef IF_RT_DEBUG static int rt_debug = 0; -SYSCTL_INT(_hw_rt, OID_AUTO, debug, CTLFLAG_RW, &rt_debug, 0, +SYSCTL_INT(_hw_rt, OID_AUTO, debug, CTLFLAG_RWTUN, &rt_debug, 0, "RT debug level"); -TUNABLE_INT("hw.rt.debug", &rt_debug); #endif static int diff --git a/sys/dev/sdhci/sdhci.c b/sys/dev/sdhci/sdhci.c index b8e03bed3409e..18fbf1e83fbb4 100644 --- a/sys/dev/sdhci/sdhci.c +++ b/sys/dev/sdhci/sdhci.c @@ -67,8 +67,7 @@ struct sdhci_softc { static SYSCTL_NODE(_hw, OID_AUTO, sdhci, CTLFLAG_RD, 0, "sdhci driver"); int sdhci_debug = 0; -TUNABLE_INT("hw.sdhci.debug", &sdhci_debug); -SYSCTL_INT(_hw_sdhci, OID_AUTO, debug, CTLFLAG_RW, &sdhci_debug, 0, "Debug level"); +SYSCTL_INT(_hw_sdhci, OID_AUTO, debug, CTLFLAG_RWTUN, &sdhci_debug, 0, "Debug level"); #define RD1(slot, off) SDHCI_READ_1((slot)->bus, (slot), (off)) #define RD2(slot, off) SDHCI_READ_2((slot)->bus, (slot), (off)) diff --git a/sys/dev/sdhci/sdhci_pci.c b/sys/dev/sdhci/sdhci_pci.c index b8d85306d8f4c..9e7e471818885 100644 --- a/sys/dev/sdhci/sdhci_pci.c +++ b/sys/dev/sdhci/sdhci_pci.c @@ -124,8 +124,7 @@ struct sdhci_pci_softc { static SYSCTL_NODE(_hw, OID_AUTO, sdhci_pci, CTLFLAG_RD, 0, "sdhci PCI driver"); int sdhci_pci_debug; -TUNABLE_INT("hw.sdhci_pci.debug", &sdhci_pci_debug); -SYSCTL_INT(_hw_sdhci_pci, OID_AUTO, debug, CTLFLAG_RW, &sdhci_pci_debug, 0, "Debug level"); +SYSCTL_INT(_hw_sdhci_pci, OID_AUTO, debug, CTLFLAG_RWTUN, &sdhci_pci_debug, 0, "Debug level"); static uint8_t sdhci_pci_read_1(device_t dev, struct sdhci_slot *slot, bus_size_t off) diff --git a/sys/dev/si/si.c b/sys/dev/si/si.c index c9d1c83114881..de3eadf583ee7 100644 --- a/sys/dev/si/si.c +++ b/sys/dev/si/si.c @@ -119,8 +119,7 @@ static int si_Nports; static int si_Nmodules; static int si_debug; -SYSCTL_INT(_machdep, OID_AUTO, si_debug, CTLFLAG_RW, &si_debug, 0, ""); -TUNABLE_INT("machdep.si_debug", &si_debug); +SYSCTL_INT(_machdep, OID_AUTO, si_debug, CTLFLAG_RWTUN, &si_debug, 0, ""); static int si_numunits; diff --git a/sys/dev/sio/sio.c b/sys/dev/sio/sio.c index d187a2bab31f7..324a80be0829a 100644 --- a/sys/dev/sio/sio.c +++ b/sys/dev/sio/sio.c @@ -372,7 +372,7 @@ sysctl_machdep_comdefaultrate(SYSCTL_HANDLER_ARGS) return error; } -SYSCTL_PROC(_machdep, OID_AUTO, conspeed, CTLTYPE_INT | CTLFLAG_RW, +SYSCTL_PROC(_machdep, OID_AUTO, conspeed, CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NOFETCH, 0, 0, sysctl_machdep_comdefaultrate, "I", ""); TUNABLE_INT("machdep.conspeed", __DEVOLATILE(int *, &comdefaultrate)); diff --git a/sys/dev/sis/if_sis.c b/sys/dev/sis/if_sis.c index 09e2242065b0f..4a95af63d8a6b 100644 --- a/sys/dev/sis/if_sis.c +++ b/sys/dev/sis/if_sis.c @@ -2361,7 +2361,6 @@ sis_add_sysctls(struct sis_softc *sc) { struct sysctl_ctx_list *ctx; struct sysctl_oid_list *children; - char tn[32]; int unit; ctx = device_get_sysctl_ctx(sc->sis_dev); @@ -2376,10 +2375,8 @@ sis_add_sysctls(struct sis_softc *sc) * because it will consume extra CPU cycles for short frames. */ sc->sis_manual_pad = 0; - snprintf(tn, sizeof(tn), "dev.sis.%d.manual_pad", unit); - TUNABLE_INT_FETCH(tn, &sc->sis_manual_pad); SYSCTL_ADD_INT(ctx, children, OID_AUTO, "manual_pad", - CTLFLAG_RW, &sc->sis_manual_pad, 0, "Manually pad short frames"); + CTLFLAG_RWTUN, &sc->sis_manual_pad, 0, "Manually pad short frames"); } static device_method_t sis_methods[] = { diff --git a/sys/dev/sound/pcm/channel.c b/sys/dev/sound/pcm/channel.c index 75b02d00e3110..41fbee2e75ae5 100644 --- a/sys/dev/sound/pcm/channel.c +++ b/sys/dev/sound/pcm/channel.c @@ -119,8 +119,7 @@ SYSCTL_PROC(_hw_snd, OID_AUTO, timeout, CTLTYPE_INT | CTLFLAG_RW, #endif static int chn_vpc_autoreset = 1; -TUNABLE_INT("hw.snd.vpc_autoreset", &chn_vpc_autoreset); -SYSCTL_INT(_hw_snd, OID_AUTO, vpc_autoreset, CTLFLAG_RW, +SYSCTL_INT(_hw_snd, OID_AUTO, vpc_autoreset, CTLFLAG_RWTUN, &chn_vpc_autoreset, 0, "automatically reset channels volume to 0db"); static int chn_vol_0db_pcm = SND_VOL_0DB_PCM; diff --git a/sys/dev/sound/pcm/feeder_chain.c b/sys/dev/sound/pcm/feeder_chain.c index 92a1cf539024f..a647269dba6d5 100644 --- a/sys/dev/sound/pcm/feeder_chain.c +++ b/sys/dev/sound/pcm/feeder_chain.c @@ -125,8 +125,7 @@ static uint32_t *feeder_chain_formats[FEEDER_CHAIN_LAST] = { static int feeder_chain_mode = FEEDER_CHAIN_DEFAULT; #if defined(_KERNEL) && defined(SND_DEBUG) && defined(SND_FEEDER_FULL_MULTIFORMAT) -TUNABLE_INT("hw.snd.feeder_chain_mode", &feeder_chain_mode); -SYSCTL_INT(_hw_snd, OID_AUTO, feeder_chain_mode, CTLFLAG_RW, +SYSCTL_INT(_hw_snd, OID_AUTO, feeder_chain_mode, CTLFLAG_RWTUN, &feeder_chain_mode, 0, "feeder chain mode " "(0=lean, 1=16bit, 2=32bit, 3=multiformat, 4=fullmultiformat)"); diff --git a/sys/dev/sound/pcm/feeder_eq.c b/sys/dev/sound/pcm/feeder_eq.c index dee38a386e51e..b4a92c986a606 100644 --- a/sys/dev/sound/pcm/feeder_eq.c +++ b/sys/dev/sound/pcm/feeder_eq.c @@ -97,8 +97,7 @@ static char feeder_eq_presets[] = FEEDER_EQ_PRESETS; SYSCTL_STRING(_hw_snd, OID_AUTO, feeder_eq_presets, CTLFLAG_RD, &feeder_eq_presets, 0, "compile-time eq presets"); -TUNABLE_INT("hw.snd.feeder_eq_exact_rate", &feeder_eq_exact_rate); -SYSCTL_INT(_hw_snd, OID_AUTO, feeder_eq_exact_rate, CTLFLAG_RW, +SYSCTL_INT(_hw_snd, OID_AUTO, feeder_eq_exact_rate, CTLFLAG_RWTUN, &feeder_eq_exact_rate, 0, "force exact rate validation"); #endif diff --git a/sys/dev/sound/pcm/feeder_rate.c b/sys/dev/sound/pcm/feeder_rate.c index cb30dd93149a9..d521fd16f1c1b 100644 --- a/sys/dev/sound/pcm/feeder_rate.c +++ b/sys/dev/sound/pcm/feeder_rate.c @@ -168,8 +168,7 @@ TUNABLE_INT("hw.snd.feeder_rate_max", &feeder_rate_max); TUNABLE_INT("hw.snd.feeder_rate_round", &feeder_rate_round); TUNABLE_INT("hw.snd.feeder_rate_quality", &feeder_rate_quality); -TUNABLE_INT("hw.snd.feeder_rate_polyphase_max", &feeder_rate_polyphase_max); -SYSCTL_INT(_hw_snd, OID_AUTO, feeder_rate_polyphase_max, CTLFLAG_RW, +SYSCTL_INT(_hw_snd, OID_AUTO, feeder_rate_polyphase_max, CTLFLAG_RWTUN, &feeder_rate_polyphase_max, 0, "maximum allowable polyphase entries"); static int diff --git a/sys/dev/sound/pcm/mixer.c b/sys/dev/sound/pcm/mixer.c index 8f9a5fb3a7f31..42ddd11bbbb04 100644 --- a/sys/dev/sound/pcm/mixer.c +++ b/sys/dev/sound/pcm/mixer.c @@ -40,8 +40,7 @@ SND_DECLARE_FILE("$FreeBSD$"); static MALLOC_DEFINE(M_MIXER, "mixer", "mixer"); static int mixer_bypass = 1; -TUNABLE_INT("hw.snd.vpc_mixer_bypass", &mixer_bypass); -SYSCTL_INT(_hw_snd, OID_AUTO, vpc_mixer_bypass, CTLFLAG_RW, +SYSCTL_INT(_hw_snd, OID_AUTO, vpc_mixer_bypass, CTLFLAG_RWTUN, &mixer_bypass, 0, "control channel pcm/rec volume, bypassing real mixer device"); diff --git a/sys/dev/sound/pcm/sound.c b/sys/dev/sound/pcm/sound.c index a7edad5246c70..8b43879470e50 100644 --- a/sys/dev/sound/pcm/sound.c +++ b/sys/dev/sound/pcm/sound.c @@ -52,8 +52,7 @@ int snd_unit = -1; TUNABLE_INT("hw.snd.default_unit", &snd_unit); static int snd_unit_auto = -1; -TUNABLE_INT("hw.snd.default_auto", &snd_unit_auto); -SYSCTL_INT(_hw_snd, OID_AUTO, default_auto, CTLFLAG_RW, +SYSCTL_INT(_hw_snd, OID_AUTO, default_auto, CTLFLAG_RWTUN, &snd_unit_auto, 0, "assign default unit to a newly attached device"); int snd_maxautovchans = 16; diff --git a/sys/dev/sound/usb/uaudio.c b/sys/dev/sound/usb/uaudio.c index 1af8cb2c4ecf4..6c798cc0e0961 100644 --- a/sys/dev/sound/usb/uaudio.c +++ b/sys/dev/sound/usb/uaudio.c @@ -103,17 +103,11 @@ static SYSCTL_NODE(_hw_usb, OID_AUTO, uaudio, CTLFLAG_RW, 0, "USB uaudio"); SYSCTL_INT(_hw_usb_uaudio, OID_AUTO, debug, CTLFLAG_RW, &uaudio_debug, 0, "uaudio debug level"); - -TUNABLE_INT("hw.usb.uaudio.default_rate", &uaudio_default_rate); -SYSCTL_INT(_hw_usb_uaudio, OID_AUTO, default_rate, CTLFLAG_RW, +SYSCTL_INT(_hw_usb_uaudio, OID_AUTO, default_rate, CTLFLAG_RWTUN, &uaudio_default_rate, 0, "uaudio default sample rate"); - -TUNABLE_INT("hw.usb.uaudio.default_bits", &uaudio_default_bits); -SYSCTL_INT(_hw_usb_uaudio, OID_AUTO, default_bits, CTLFLAG_RW, +SYSCTL_INT(_hw_usb_uaudio, OID_AUTO, default_bits, CTLFLAG_RWTUN, &uaudio_default_bits, 0, "uaudio default sample bits"); - -TUNABLE_INT("hw.usb.uaudio.default_channels", &uaudio_default_channels); -SYSCTL_INT(_hw_usb_uaudio, OID_AUTO, default_channels, CTLFLAG_RW, +SYSCTL_INT(_hw_usb_uaudio, OID_AUTO, default_channels, CTLFLAG_RWTUN, &uaudio_default_channels, 0, "uaudio default sample channels"); #endif diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c index 1160f73097727..59b16af026df3 100644 --- a/sys/dev/syscons/syscons.c +++ b/sys/dev/syscons/syscons.c @@ -154,8 +154,7 @@ SYSCTL_INT(_hw_syscons, OID_AUTO, kbd_reboot, CTLFLAG_RW|CTLFLAG_SECURE, &enable SYSCTL_INT(_hw_syscons, OID_AUTO, kbd_debug, CTLFLAG_RW|CTLFLAG_SECURE, &enable_kdbkey, 0, "enable keyboard debug"); #endif -TUNABLE_INT("hw.syscons.sc_no_suspend_vtswitch", &sc_no_suspend_vtswitch); -SYSCTL_INT(_hw_syscons, OID_AUTO, sc_no_suspend_vtswitch, CTLFLAG_RW, +SYSCTL_INT(_hw_syscons, OID_AUTO, sc_no_suspend_vtswitch, CTLFLAG_RWTUN, &sc_no_suspend_vtswitch, 0, "Disable VT switch before suspend."); #if !defined(SC_NO_FONT_LOADING) && defined(SC_DFLT_FONT) #include "font.h" diff --git a/sys/dev/uart/uart_dev_ns8250.c b/sys/dev/uart/uart_dev_ns8250.c index 773cb442c8978..89f78402746b6 100644 --- a/sys/dev/uart/uart_dev_ns8250.c +++ b/sys/dev/uart/uart_dev_ns8250.c @@ -55,9 +55,8 @@ __FBSDID("$FreeBSD$"); #define DEFAULT_RCLK 1843200 static int broken_txfifo = 0; -SYSCTL_INT(_hw, OID_AUTO, broken_txfifo, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw, OID_AUTO, broken_txfifo, CTLFLAG_RWTUN, &broken_txfifo, 0, "UART FIFO has QEMU emulation bug"); -TUNABLE_INT("hw.broken_txfifo", &broken_txfifo); /* * Clear pending interrupts. THRE is cleared by reading IIR. Data diff --git a/sys/dev/usb/controller/dwc_otg.c b/sys/dev/usb/controller/dwc_otg.c index ed88caa42b7e2..b90fbf56022d5 100644 --- a/sys/dev/usb/controller/dwc_otg.c +++ b/sys/dev/usb/controller/dwc_otg.c @@ -112,14 +112,13 @@ static int dwc_otg_use_hsic; static SYSCTL_NODE(_hw_usb, OID_AUTO, dwc_otg, CTLFLAG_RW, 0, "USB DWC OTG"); -SYSCTL_INT(_hw_usb_dwc_otg, OID_AUTO, use_hsic, CTLFLAG_RD | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_dwc_otg, OID_AUTO, use_hsic, CTLFLAG_RDTUN, &dwc_otg_use_hsic, 0, "DWC OTG uses HSIC interface"); -TUNABLE_INT("hw.usb.dwc_otg.use_hsic", &dwc_otg_use_hsic); #ifdef USB_DEBUG static int dwc_otg_debug; -SYSCTL_INT(_hw_usb_dwc_otg, OID_AUTO, debug, CTLFLAG_RW, +SYSCTL_INT(_hw_usb_dwc_otg, OID_AUTO, debug, CTLFLAG_RWTUN, &dwc_otg_debug, 0, "DWC OTG debug level"); #endif diff --git a/sys/dev/usb/controller/ehci.c b/sys/dev/usb/controller/ehci.c index ad3a3fc55d2b1..7d0d5ab6d2099 100644 --- a/sys/dev/usb/controller/ehci.c +++ b/sys/dev/usb/controller/ehci.c @@ -98,19 +98,14 @@ static int ehciiaadbug = 0; static int ehcilostintrbug = 0; static SYSCTL_NODE(_hw_usb, OID_AUTO, ehci, CTLFLAG_RW, 0, "USB ehci"); -SYSCTL_INT(_hw_usb_ehci, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_ehci, OID_AUTO, debug, CTLFLAG_RWTUN, &ehcidebug, 0, "Debug level"); -TUNABLE_INT("hw.usb.ehci.debug", &ehcidebug); -SYSCTL_INT(_hw_usb_ehci, OID_AUTO, no_hs, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_ehci, OID_AUTO, no_hs, CTLFLAG_RWTUN, &ehcinohighspeed, 0, "Disable High Speed USB"); -TUNABLE_INT("hw.usb.ehci.no_hs", &ehcinohighspeed); -SYSCTL_INT(_hw_usb_ehci, OID_AUTO, iaadbug, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_ehci, OID_AUTO, iaadbug, CTLFLAG_RWTUN, &ehciiaadbug, 0, "Enable doorbell bug workaround"); -TUNABLE_INT("hw.usb.ehci.iaadbug", &ehciiaadbug); -SYSCTL_INT(_hw_usb_ehci, OID_AUTO, lostintrbug, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_ehci, OID_AUTO, lostintrbug, CTLFLAG_RWTUN, &ehcilostintrbug, 0, "Enable lost interrupt bug workaround"); -TUNABLE_INT("hw.usb.ehci.lostintrbug", &ehcilostintrbug); - static void ehci_dump_regs(ehci_softc_t *sc); static void ehci_dump_sqh(ehci_softc_t *sc, ehci_qh_t *sqh); diff --git a/sys/dev/usb/controller/ohci.c b/sys/dev/usb/controller/ohci.c index 86fca1eeaa3b6..206c75314d0c5 100644 --- a/sys/dev/usb/controller/ohci.c +++ b/sys/dev/usb/controller/ohci.c @@ -84,9 +84,8 @@ static int ohcidebug = 0; static SYSCTL_NODE(_hw_usb, OID_AUTO, ohci, CTLFLAG_RW, 0, "USB ohci"); -SYSCTL_INT(_hw_usb_ohci, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_ohci, OID_AUTO, debug, CTLFLAG_RWTUN, &ohcidebug, 0, "ohci debug level"); -TUNABLE_INT("hw.usb.ohci.debug", &ohcidebug); static void ohci_dumpregs(ohci_softc_t *); static void ohci_dump_tds(ohci_td_t *); diff --git a/sys/dev/usb/controller/uhci.c b/sys/dev/usb/controller/uhci.c index 134a4472363ac..00776154447c0 100644 --- a/sys/dev/usb/controller/uhci.c +++ b/sys/dev/usb/controller/uhci.c @@ -89,12 +89,10 @@ static int uhcidebug = 0; static int uhcinoloop = 0; static SYSCTL_NODE(_hw_usb, OID_AUTO, uhci, CTLFLAG_RW, 0, "USB uhci"); -SYSCTL_INT(_hw_usb_uhci, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_uhci, OID_AUTO, debug, CTLFLAG_RWTUN, &uhcidebug, 0, "uhci debug level"); -TUNABLE_INT("hw.usb.uhci.debug", &uhcidebug); -SYSCTL_INT(_hw_usb_uhci, OID_AUTO, loop, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_uhci, OID_AUTO, loop, CTLFLAG_RWTUN, &uhcinoloop, 0, "uhci noloop"); -TUNABLE_INT("hw.usb.uhci.loop", &uhcinoloop); static void uhci_dumpregs(uhci_softc_t *sc); static void uhci_dump_tds(uhci_td_t *td); diff --git a/sys/dev/usb/controller/usb_controller.c b/sys/dev/usb/controller/usb_controller.c index c2cafecf61d40..dd75ba7a5aa24 100644 --- a/sys/dev/usb/controller/usb_controller.c +++ b/sys/dev/usb/controller/usb_controller.c @@ -90,19 +90,16 @@ SYSCTL_INT(_hw_usb_ctrl, OID_AUTO, debug, CTLFLAG_RW, &usb_ctrl_debug, 0, #if USB_HAVE_ROOT_MOUNT_HOLD static int usb_no_boot_wait = 0; -TUNABLE_INT("hw.usb.no_boot_wait", &usb_no_boot_wait); -SYSCTL_INT(_hw_usb, OID_AUTO, no_boot_wait, CTLFLAG_RD|CTLFLAG_TUN, &usb_no_boot_wait, 0, +SYSCTL_INT(_hw_usb, OID_AUTO, no_boot_wait, CTLFLAG_RDTUN, &usb_no_boot_wait, 0, "No USB device enumerate waiting at boot."); #endif static int usb_no_suspend_wait = 0; -TUNABLE_INT("hw.usb.no_suspend_wait", &usb_no_suspend_wait); -SYSCTL_INT(_hw_usb, OID_AUTO, no_suspend_wait, CTLFLAG_RW|CTLFLAG_TUN, +SYSCTL_INT(_hw_usb, OID_AUTO, no_suspend_wait, CTLFLAG_RWTUN, &usb_no_suspend_wait, 0, "No USB device waiting at system suspend."); static int usb_no_shutdown_wait = 0; -TUNABLE_INT("hw.usb.no_shutdown_wait", &usb_no_shutdown_wait); -SYSCTL_INT(_hw_usb, OID_AUTO, no_shutdown_wait, CTLFLAG_RW|CTLFLAG_TUN, +SYSCTL_INT(_hw_usb, OID_AUTO, no_shutdown_wait, CTLFLAG_RWTUN, &usb_no_shutdown_wait, 0, "No USB device waiting at system shutdown."); static devclass_t usb_devclass; diff --git a/sys/dev/usb/controller/xhci.c b/sys/dev/usb/controller/xhci.c index 4570ad2aab840..cdfa7d4062883 100644 --- a/sys/dev/usb/controller/xhci.c +++ b/sys/dev/usb/controller/xhci.c @@ -90,24 +90,20 @@ static SYSCTL_NODE(_hw_usb, OID_AUTO, xhci, CTLFLAG_RW, 0, "USB XHCI"); static int xhcistreams; -SYSCTL_INT(_hw_usb_xhci, OID_AUTO, streams, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_xhci, OID_AUTO, streams, CTLFLAG_RWTUN, &xhcistreams, 0, "Set to enable streams mode support"); -TUNABLE_INT("hw.usb.xhci.streams", &xhcistreams); #ifdef USB_DEBUG static int xhcidebug; static int xhciroute; static int xhcipolling; -SYSCTL_INT(_hw_usb_xhci, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_xhci, OID_AUTO, debug, CTLFLAG_RWTUN, &xhcidebug, 0, "Debug level"); -TUNABLE_INT("hw.usb.xhci.debug", &xhcidebug); -SYSCTL_INT(_hw_usb_xhci, OID_AUTO, xhci_port_route, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_xhci, OID_AUTO, xhci_port_route, CTLFLAG_RWTUN, &xhciroute, 0, "Routing bitmap for switching EHCI ports to XHCI controller"); -TUNABLE_INT("hw.usb.xhci.xhci_port_route", &xhciroute); -SYSCTL_INT(_hw_usb_xhci, OID_AUTO, use_polling, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_xhci, OID_AUTO, use_polling, CTLFLAG_RWTUN, &xhcipolling, 0, "Set to enable software interrupt polling for XHCI controller"); -TUNABLE_INT("hw.usb.xhci.use_polling", &xhcipolling); #else #define xhciroute 0 #endif diff --git a/sys/dev/usb/input/ukbd.c b/sys/dev/usb/input/ukbd.c index ede27f726cabd..0e56d9643a0f5 100644 --- a/sys/dev/usb/input/ukbd.c +++ b/sys/dev/usb/input/ukbd.c @@ -95,15 +95,12 @@ static int ukbd_no_leds = 0; static int ukbd_pollrate = 0; static SYSCTL_NODE(_hw_usb, OID_AUTO, ukbd, CTLFLAG_RW, 0, "USB keyboard"); -SYSCTL_INT(_hw_usb_ukbd, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_ukbd, OID_AUTO, debug, CTLFLAG_RWTUN, &ukbd_debug, 0, "Debug level"); -TUNABLE_INT("hw.usb.ukbd.debug", &ukbd_debug); -SYSCTL_INT(_hw_usb_ukbd, OID_AUTO, no_leds, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_ukbd, OID_AUTO, no_leds, CTLFLAG_RWTUN, &ukbd_no_leds, 0, "Disables setting of keyboard leds"); -TUNABLE_INT("hw.usb.ukbd.no_leds", &ukbd_no_leds); -SYSCTL_INT(_hw_usb_ukbd, OID_AUTO, pollrate, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_ukbd, OID_AUTO, pollrate, CTLFLAG_RWTUN, &ukbd_pollrate, 0, "Force this polling rate, 1-1000Hz"); -TUNABLE_INT("hw.usb.ukbd.pollrate", &ukbd_pollrate); #endif #define UKBD_EMULATE_ATSCANCODE 1 diff --git a/sys/dev/usb/serial/uftdi.c b/sys/dev/usb/serial/uftdi.c index 25da9b892f408..74e11dda1771a 100644 --- a/sys/dev/usb/serial/uftdi.c +++ b/sys/dev/usb/serial/uftdi.c @@ -932,7 +932,6 @@ static const struct jtag_by_name { * creation of tty devices for jtag interfaces. Enabled by default. */ static int skip_jtag_interfaces = 1; -TUNABLE_INT("hw.usb.uftdi.skip_jtag_interfaces", &skip_jtag_interfaces); SYSCTL_INT(_hw_usb_uftdi, OID_AUTO, skip_jtag_interfaces, CTLFLAG_RWTUN, &skip_jtag_interfaces, 1, "Skip creating tty devices for jtag interfaces"); diff --git a/sys/dev/usb/serial/usb_serial.c b/sys/dev/usb/serial/usb_serial.c index 2945415bbe99a..53c0594b41a72 100644 --- a/sys/dev/usb/serial/usb_serial.c +++ b/sys/dev/usb/serial/usb_serial.c @@ -119,14 +119,11 @@ static int ucom_cons_subunit = 0; static int ucom_cons_baud = 9600; static struct ucom_softc *ucom_cons_softc = NULL; -TUNABLE_INT("hw.usb.ucom.cons_unit", &ucom_cons_unit); -SYSCTL_INT(_hw_usb_ucom, OID_AUTO, cons_unit, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_ucom, OID_AUTO, cons_unit, CTLFLAG_RWTUN, &ucom_cons_unit, 0, "console unit number"); -TUNABLE_INT("hw.usb.ucom.cons_subunit", &ucom_cons_subunit); -SYSCTL_INT(_hw_usb_ucom, OID_AUTO, cons_subunit, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_ucom, OID_AUTO, cons_subunit, CTLFLAG_RWTUN, &ucom_cons_subunit, 0, "console subunit number"); -TUNABLE_INT("hw.usb.ucom.cons_baud", &ucom_cons_baud); -SYSCTL_INT(_hw_usb_ucom, OID_AUTO, cons_baud, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_ucom, OID_AUTO, cons_baud, CTLFLAG_RWTUN, &ucom_cons_baud, 0, "console baud rate"); static usb_proc_callback_t ucom_cfg_start_transfers; diff --git a/sys/dev/usb/storage/umass.c b/sys/dev/usb/storage/umass.c index f3a51b313ff4a..e169abbfb53e1 100644 --- a/sys/dev/usb/storage/umass.c +++ b/sys/dev/usb/storage/umass.c @@ -167,12 +167,10 @@ static int umass_debug; static int umass_throttle; static SYSCTL_NODE(_hw_usb, OID_AUTO, umass, CTLFLAG_RW, 0, "USB umass"); -SYSCTL_INT(_hw_usb_umass, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_umass, OID_AUTO, debug, CTLFLAG_RWTUN, &umass_debug, 0, "umass debug level"); -TUNABLE_INT("hw.usb.umass.debug", &umass_debug); -SYSCTL_INT(_hw_usb_umass, OID_AUTO, throttle, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_umass, OID_AUTO, throttle, CTLFLAG_RWTUN, &umass_throttle, 0, "Forced delay between commands in milliseconds"); -TUNABLE_INT("hw.usb.umass.throttle", &umass_throttle); #else #define DIF(...) do { } while (0) #define DPRINTF(...) do { } while (0) diff --git a/sys/dev/usb/usb_debug.c b/sys/dev/usb/usb_debug.c index 338298835b806..9c7fa6e1d062f 100644 --- a/sys/dev/usb/usb_debug.c +++ b/sys/dev/usb/usb_debug.c @@ -67,9 +67,8 @@ int usb_debug = 0; SYSCTL_NODE(_hw, OID_AUTO, usb, CTLFLAG_RW, 0, "USB debugging"); -SYSCTL_INT(_hw_usb, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb, OID_AUTO, debug, CTLFLAG_RWTUN, &usb_debug, 0, "Debug level"); -TUNABLE_INT("hw.usb.debug", &usb_debug); #ifdef USB_DEBUG /* @@ -78,44 +77,34 @@ TUNABLE_INT("hw.usb.debug", &usb_debug); static SYSCTL_NODE(_hw_usb, OID_AUTO, timings, CTLFLAG_RW, 0, "Timings"); static int usb_timings_sysctl_handler(SYSCTL_HANDLER_ARGS); -TUNABLE_INT("hw.usb.timings.port_reset_delay", (int *)&usb_port_reset_delay); -SYSCTL_PROC(_hw_usb_timings, OID_AUTO, port_reset_delay, CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_PROC(_hw_usb_timings, OID_AUTO, port_reset_delay, CTLTYPE_UINT | CTLFLAG_RWTUN, &usb_port_reset_delay, sizeof(usb_port_reset_delay), usb_timings_sysctl_handler, "IU", "Port Reset Delay"); -TUNABLE_INT("hw.usb.timings.port_root_reset_delay", (int *)&usb_port_root_reset_delay); -SYSCTL_PROC(_hw_usb_timings, OID_AUTO, port_root_reset_delay, CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_PROC(_hw_usb_timings, OID_AUTO, port_root_reset_delay, CTLTYPE_UINT | CTLFLAG_RWTUN, &usb_port_root_reset_delay, sizeof(usb_port_root_reset_delay), usb_timings_sysctl_handler, "IU", "Root Port Reset Delay"); -TUNABLE_INT("hw.usb.timings.port_reset_recovery", (int *)&usb_port_reset_recovery); -SYSCTL_PROC(_hw_usb_timings, OID_AUTO, port_reset_recovery, CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_PROC(_hw_usb_timings, OID_AUTO, port_reset_recovery, CTLTYPE_UINT | CTLFLAG_RWTUN, &usb_port_reset_recovery, sizeof(usb_port_reset_recovery), usb_timings_sysctl_handler, "IU", "Port Reset Recovery"); -TUNABLE_INT("hw.usb.timings.port_powerup_delay", (int *)&usb_port_powerup_delay); -SYSCTL_PROC(_hw_usb_timings, OID_AUTO, port_powerup_delay, CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_PROC(_hw_usb_timings, OID_AUTO, port_powerup_delay, CTLTYPE_UINT | CTLFLAG_RWTUN, &usb_port_powerup_delay, sizeof(usb_port_powerup_delay), usb_timings_sysctl_handler, "IU", "Port PowerUp Delay"); -TUNABLE_INT("hw.usb.timings.port_resume_delay", (int *)&usb_port_resume_delay); -SYSCTL_PROC(_hw_usb_timings, OID_AUTO, port_resume_delay, CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_PROC(_hw_usb_timings, OID_AUTO, port_resume_delay, CTLTYPE_UINT | CTLFLAG_RWTUN, &usb_port_resume_delay, sizeof(usb_port_resume_delay), usb_timings_sysctl_handler, "IU", "Port Resume Delay"); -TUNABLE_INT("hw.usb.timings.set_address_settle", (int *)&usb_set_address_settle); -SYSCTL_PROC(_hw_usb_timings, OID_AUTO, set_address_settle, CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_PROC(_hw_usb_timings, OID_AUTO, set_address_settle, CTLTYPE_UINT | CTLFLAG_RWTUN, &usb_set_address_settle, sizeof(usb_set_address_settle), usb_timings_sysctl_handler, "IU", "Set Address Settle"); -TUNABLE_INT("hw.usb.timings.resume_delay", (int *)&usb_resume_delay); -SYSCTL_PROC(_hw_usb_timings, OID_AUTO, resume_delay, CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_PROC(_hw_usb_timings, OID_AUTO, resume_delay, CTLTYPE_UINT | CTLFLAG_RWTUN, &usb_resume_delay, sizeof(usb_resume_delay), usb_timings_sysctl_handler, "IU", "Resume Delay"); -TUNABLE_INT("hw.usb.timings.resume_wait", (int *)&usb_resume_wait); -SYSCTL_PROC(_hw_usb_timings, OID_AUTO, resume_wait, CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_PROC(_hw_usb_timings, OID_AUTO, resume_wait, CTLTYPE_UINT | CTLFLAG_RWTUN, &usb_resume_wait, sizeof(usb_resume_wait), usb_timings_sysctl_handler, "IU", "Resume Wait"); -TUNABLE_INT("hw.usb.timings.resume_recovery", (int *)&usb_resume_recovery); -SYSCTL_PROC(_hw_usb_timings, OID_AUTO, resume_recovery, CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_PROC(_hw_usb_timings, OID_AUTO, resume_recovery, CTLTYPE_UINT | CTLFLAG_RWTUN, &usb_resume_recovery, sizeof(usb_resume_recovery), usb_timings_sysctl_handler, "IU", "Resume Recovery"); -TUNABLE_INT("hw.usb.timings.extra_power_up_time", (int *)&usb_extra_power_up_time); -SYSCTL_PROC(_hw_usb_timings, OID_AUTO, extra_power_up_time, CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_PROC(_hw_usb_timings, OID_AUTO, extra_power_up_time, CTLTYPE_UINT | CTLFLAG_RWTUN, &usb_extra_power_up_time, sizeof(usb_extra_power_up_time), usb_timings_sysctl_handler, "IU", "Extra PowerUp Time"); #endif diff --git a/sys/dev/usb/usb_dev.c b/sys/dev/usb/usb_dev.c index 6ad02a7d035dd..396067309ac4d 100644 --- a/sys/dev/usb/usb_dev.c +++ b/sys/dev/usb/usb_dev.c @@ -86,9 +86,8 @@ static int usb_fifo_debug = 0; static SYSCTL_NODE(_hw_usb, OID_AUTO, dev, CTLFLAG_RW, 0, "USB device"); -SYSCTL_INT(_hw_usb_dev, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_dev, OID_AUTO, debug, CTLFLAG_RWTUN, &usb_fifo_debug, 0, "Debug Level"); -TUNABLE_INT("hw.usb.dev.debug", &usb_fifo_debug); #endif #if ((__FreeBSD_version >= 700001) || (__FreeBSD_version == 0) || \ diff --git a/sys/dev/usb/usb_device.c b/sys/dev/usb/usb_device.c index 7acb5cbc4f7d0..1acfd1eee95cb 100644 --- a/sys/dev/usb/usb_device.c +++ b/sys/dev/usb/usb_device.c @@ -118,8 +118,7 @@ int usb_template = USB_TEMPLATE; int usb_template; #endif -TUNABLE_INT("hw.usb.usb_template", &usb_template); -SYSCTL_INT(_hw_usb, OID_AUTO, template, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb, OID_AUTO, template, CTLFLAG_RWTUN, &usb_template, 0, "Selected USB device side template"); /* English is default language */ @@ -127,12 +126,10 @@ SYSCTL_INT(_hw_usb, OID_AUTO, template, CTLFLAG_RW | CTLFLAG_TUN, static int usb_lang_id = 0x0009; static int usb_lang_mask = 0x00FF; -TUNABLE_INT("hw.usb.usb_lang_id", &usb_lang_id); -SYSCTL_INT(_hw_usb, OID_AUTO, usb_lang_id, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb, OID_AUTO, usb_lang_id, CTLFLAG_RWTUN, &usb_lang_id, 0, "Preferred USB language ID"); -TUNABLE_INT("hw.usb.usb_lang_mask", &usb_lang_mask); -SYSCTL_INT(_hw_usb, OID_AUTO, usb_lang_mask, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb, OID_AUTO, usb_lang_mask, CTLFLAG_RWTUN, &usb_lang_mask, 0, "Preferred USB language mask"); static const char* statestr[USB_STATE_MAX] = { diff --git a/sys/dev/usb/usb_generic.c b/sys/dev/usb/usb_generic.c index 4ebd557a51821..96dfe8bceb872 100644 --- a/sys/dev/usb/usb_generic.c +++ b/sys/dev/usb/usb_generic.c @@ -131,9 +131,8 @@ struct usb_fifo_methods usb_ugen_methods = { static int ugen_debug = 0; static SYSCTL_NODE(_hw_usb, OID_AUTO, ugen, CTLFLAG_RW, 0, "USB generic"); -SYSCTL_INT(_hw_usb_ugen, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, &ugen_debug, +SYSCTL_INT(_hw_usb_ugen, OID_AUTO, debug, CTLFLAG_RWTUN, &ugen_debug, 0, "Debug level"); -TUNABLE_INT("hw.usb.ugen.debug", &ugen_debug); #endif diff --git a/sys/dev/usb/usb_hub.c b/sys/dev/usb/usb_hub.c index e9c9a42c39142..8e0d557a9c5f7 100644 --- a/sys/dev/usb/usb_hub.c +++ b/sys/dev/usb/usb_hub.c @@ -86,9 +86,8 @@ enum { static int uhub_debug = 0; static SYSCTL_NODE(_hw_usb, OID_AUTO, uhub, CTLFLAG_RW, 0, "USB HUB"); -SYSCTL_INT(_hw_usb_uhub, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, &uhub_debug, 0, +SYSCTL_INT(_hw_usb_uhub, OID_AUTO, debug, CTLFLAG_RWTUN, &uhub_debug, 0, "Debug level"); -TUNABLE_INT("hw.usb.uhub.debug", &uhub_debug); #endif #if USB_HAVE_POWERD diff --git a/sys/dev/usb/usb_process.c b/sys/dev/usb/usb_process.c index e70166ca4f2c4..683c700d2472d 100644 --- a/sys/dev/usb/usb_process.c +++ b/sys/dev/usb/usb_process.c @@ -90,9 +90,8 @@ static int usb_pcount; static int usb_proc_debug; static SYSCTL_NODE(_hw_usb, OID_AUTO, proc, CTLFLAG_RW, 0, "USB process"); -SYSCTL_INT(_hw_usb_proc, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, &usb_proc_debug, 0, +SYSCTL_INT(_hw_usb_proc, OID_AUTO, debug, CTLFLAG_RWTUN, &usb_proc_debug, 0, "Debug level"); -TUNABLE_INT("hw.usb.proc.debug", &usb_proc_debug); #endif /*------------------------------------------------------------------------* diff --git a/sys/dev/usb/wlan/if_uath.c b/sys/dev/usb/wlan/if_uath.c index 9db1e04ce3de5..b8e886388f72f 100644 --- a/sys/dev/usb/wlan/if_uath.c +++ b/sys/dev/usb/wlan/if_uath.c @@ -115,18 +115,16 @@ __FBSDID("$FreeBSD$"); static SYSCTL_NODE(_hw_usb, OID_AUTO, uath, CTLFLAG_RW, 0, "USB Atheros"); static int uath_countrycode = CTRY_DEFAULT; /* country code */ -SYSCTL_INT(_hw_usb_uath, OID_AUTO, countrycode, CTLFLAG_RW | CTLFLAG_TUN, &uath_countrycode, +SYSCTL_INT(_hw_usb_uath, OID_AUTO, countrycode, CTLFLAG_RWTUN, &uath_countrycode, 0, "country code"); -TUNABLE_INT("hw.usb.uath.countrycode", &uath_countrycode); static int uath_regdomain = 0; /* regulatory domain */ SYSCTL_INT(_hw_usb_uath, OID_AUTO, regdomain, CTLFLAG_RD, &uath_regdomain, 0, "regulatory domain"); #ifdef UATH_DEBUG int uath_debug = 0; -SYSCTL_INT(_hw_usb_uath, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, &uath_debug, 0, +SYSCTL_INT(_hw_usb_uath, OID_AUTO, debug, CTLFLAG_RWTUN, &uath_debug, 0, "uath debug level"); -TUNABLE_INT("hw.usb.uath.debug", &uath_debug); enum { UATH_DEBUG_XMIT = 0x00000001, /* basic xmit operation */ UATH_DEBUG_XMIT_DUMP = 0x00000002, /* xmit dump */ diff --git a/sys/dev/usb/wlan/if_upgt.c b/sys/dev/usb/wlan/if_upgt.c index a860a2b6910bd..51f4ed98c3be7 100644 --- a/sys/dev/usb/wlan/if_upgt.c +++ b/sys/dev/usb/wlan/if_upgt.c @@ -76,9 +76,8 @@ static SYSCTL_NODE(_hw, OID_AUTO, upgt, CTLFLAG_RD, 0, #ifdef UPGT_DEBUG int upgt_debug = 0; -SYSCTL_INT(_hw_upgt, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, &upgt_debug, +SYSCTL_INT(_hw_upgt, OID_AUTO, debug, CTLFLAG_RWTUN, &upgt_debug, 0, "control debugging printfs"); -TUNABLE_INT("hw.upgt.debug", &upgt_debug); enum { UPGT_DEBUG_XMIT = 0x00000001, /* basic xmit operation */ UPGT_DEBUG_RECV = 0x00000002, /* basic recv operation */ diff --git a/sys/dev/usb/wlan/if_urtw.c b/sys/dev/usb/wlan/if_urtw.c index a5516339fb41b..d2837324b63f3 100644 --- a/sys/dev/usb/wlan/if_urtw.c +++ b/sys/dev/usb/wlan/if_urtw.c @@ -65,9 +65,8 @@ __FBSDID("$FreeBSD$"); static SYSCTL_NODE(_hw_usb, OID_AUTO, urtw, CTLFLAG_RW, 0, "USB Realtek 8187L"); #ifdef URTW_DEBUG int urtw_debug = 0; -SYSCTL_INT(_hw_usb_urtw, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, &urtw_debug, 0, +SYSCTL_INT(_hw_usb_urtw, OID_AUTO, debug, CTLFLAG_RWTUN, &urtw_debug, 0, "control debugging printfs"); -TUNABLE_INT("hw.usb.urtw.debug", &urtw_debug); enum { URTW_DEBUG_XMIT = 0x00000001, /* basic xmit operation */ URTW_DEBUG_RECV = 0x00000002, /* basic recv operation */ @@ -90,9 +89,8 @@ enum { } while (0) #endif static int urtw_preamble_mode = URTW_PREAMBLE_MODE_LONG; -SYSCTL_INT(_hw_usb_urtw, OID_AUTO, preamble_mode, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_urtw, OID_AUTO, preamble_mode, CTLFLAG_RWTUN, &urtw_preamble_mode, 0, "set the preable mode (long or short)"); -TUNABLE_INT("hw.usb.urtw.preamble_mode", &urtw_preamble_mode); /* recognized device vendors/products */ #define urtw_lookup(v, p) \ diff --git a/sys/dev/vt/vt.h b/sys/dev/vt/vt.h index 67f22012ad72b..9728946de10c9 100644 --- a/sys/dev/vt/vt.h +++ b/sys/dev/vt/vt.h @@ -84,9 +84,8 @@ #define VT_SYSCTL_INT(_name, _default, _descr) \ static int vt_##_name = _default; \ -SYSCTL_INT(_kern_vt, OID_AUTO, _name, CTLFLAG_RW, &vt_##_name, _default,\ - _descr); \ -TUNABLE_INT("kern.vt." #_name, &vt_##_name); +SYSCTL_INT(_kern_vt, OID_AUTO, _name, CTLFLAG_RWTUN, &vt_##_name, _default,\ + _descr); struct vt_driver; diff --git a/sys/dev/wpi/if_wpi.c b/sys/dev/wpi/if_wpi.c index efbcb298e9619..6e4428bef5163 100644 --- a/sys/dev/wpi/if_wpi.c +++ b/sys/dev/wpi/if_wpi.c @@ -130,9 +130,8 @@ enum { WPI_DEBUG_ANY = 0xffffffff }; -static int wpi_debug = 0; -SYSCTL_INT(_debug, OID_AUTO, wpi, CTLFLAG_RW, &wpi_debug, 0, "wpi debug level"); -TUNABLE_INT("debug.wpi", &wpi_debug); +static int wpi_debug; +SYSCTL_INT(_debug, OID_AUTO, wpi, CTLFLAG_RWTUN, &wpi_debug, 0, "wpi debug level"); #else #define DPRINTF(x) diff --git a/sys/gdb/gdb_cons.c b/sys/gdb/gdb_cons.c index ff746658601f0..47f453fc3eea2 100644 --- a/sys/gdb/gdb_cons.c +++ b/sys/gdb/gdb_cons.c @@ -58,9 +58,8 @@ struct gdbcons { static struct gdbcons state = { -1 }; static int gdbcons_enable = 0; -SYSCTL_INT(_debug, OID_AUTO, gdbcons, CTLFLAG_RW, &gdbcons_enable, - 0, "copy console messages to gdb"); -TUNABLE_INT("debug.gdbcons", &gdbcons_enable); +SYSCTL_INT(_debug, OID_AUTO, gdbcons, CTLFLAG_RWTUN, &gdbcons_enable, + 0, "copy console messages to GDB"); static void gdb_cnprobe(struct consdev *cp) diff --git a/sys/geom/concat/g_concat.c b/sys/geom/concat/g_concat.c index 2efc1b53fd616..4627ff9fa2ca7 100644 --- a/sys/geom/concat/g_concat.c +++ b/sys/geom/concat/g_concat.c @@ -48,8 +48,7 @@ SYSCTL_DECL(_kern_geom); static SYSCTL_NODE(_kern_geom, OID_AUTO, concat, CTLFLAG_RW, 0, "GEOM_CONCAT stuff"); static u_int g_concat_debug = 0; -TUNABLE_INT("kern.geom.concat.debug", &g_concat_debug); -SYSCTL_UINT(_kern_geom_concat, OID_AUTO, debug, CTLFLAG_RW, &g_concat_debug, 0, +SYSCTL_UINT(_kern_geom_concat, OID_AUTO, debug, CTLFLAG_RWTUN, &g_concat_debug, 0, "Debug level"); static int g_concat_destroy(struct g_concat_softc *sc, boolean_t force); diff --git a/sys/geom/eli/g_eli.c b/sys/geom/eli/g_eli.c index d1f3cd25a0fb4..2c4dc2c41ae50 100644 --- a/sys/geom/eli/g_eli.c +++ b/sys/geom/eli/g_eli.c @@ -63,29 +63,23 @@ static int g_eli_version = G_ELI_VERSION; SYSCTL_INT(_kern_geom_eli, OID_AUTO, version, CTLFLAG_RD, &g_eli_version, 0, "GELI version"); int g_eli_debug = 0; -TUNABLE_INT("kern.geom.eli.debug", &g_eli_debug); -SYSCTL_INT(_kern_geom_eli, OID_AUTO, debug, CTLFLAG_RW, &g_eli_debug, 0, +SYSCTL_INT(_kern_geom_eli, OID_AUTO, debug, CTLFLAG_RWTUN, &g_eli_debug, 0, "Debug level"); static u_int g_eli_tries = 3; -TUNABLE_INT("kern.geom.eli.tries", &g_eli_tries); -SYSCTL_UINT(_kern_geom_eli, OID_AUTO, tries, CTLFLAG_RW, &g_eli_tries, 0, +SYSCTL_UINT(_kern_geom_eli, OID_AUTO, tries, CTLFLAG_RWTUN, &g_eli_tries, 0, "Number of tries for entering the passphrase"); static u_int g_eli_visible_passphrase = GETS_NOECHO; -TUNABLE_INT("kern.geom.eli.visible_passphrase", &g_eli_visible_passphrase); -SYSCTL_UINT(_kern_geom_eli, OID_AUTO, visible_passphrase, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_eli, OID_AUTO, visible_passphrase, CTLFLAG_RWTUN, &g_eli_visible_passphrase, 0, "Visibility of passphrase prompt (0 = invisible, 1 = visible, 2 = asterisk)"); u_int g_eli_overwrites = G_ELI_OVERWRITES; -TUNABLE_INT("kern.geom.eli.overwrites", &g_eli_overwrites); -SYSCTL_UINT(_kern_geom_eli, OID_AUTO, overwrites, CTLFLAG_RW, &g_eli_overwrites, +SYSCTL_UINT(_kern_geom_eli, OID_AUTO, overwrites, CTLFLAG_RWTUN, &g_eli_overwrites, 0, "Number of times on-disk keys should be overwritten when destroying them"); static u_int g_eli_threads = 0; -TUNABLE_INT("kern.geom.eli.threads", &g_eli_threads); -SYSCTL_UINT(_kern_geom_eli, OID_AUTO, threads, CTLFLAG_RW, &g_eli_threads, 0, +SYSCTL_UINT(_kern_geom_eli, OID_AUTO, threads, CTLFLAG_RWTUN, &g_eli_threads, 0, "Number of threads doing crypto work"); u_int g_eli_batch = 0; -TUNABLE_INT("kern.geom.eli.batch", &g_eli_batch); -SYSCTL_UINT(_kern_geom_eli, OID_AUTO, batch, CTLFLAG_RW, &g_eli_batch, 0, +SYSCTL_UINT(_kern_geom_eli, OID_AUTO, batch, CTLFLAG_RWTUN, &g_eli_batch, 0, "Use crypto operations batching"); static eventhandler_tag g_eli_pre_sync = NULL; diff --git a/sys/geom/eli/g_eli_key_cache.c b/sys/geom/eli/g_eli_key_cache.c index 9530495050ec5..cb867166cee39 100644 --- a/sys/geom/eli/g_eli_key_cache.c +++ b/sys/geom/eli/g_eli_key_cache.c @@ -47,7 +47,6 @@ SYSCTL_DECL(_kern_geom_eli); * provider with 512 bytes sectors and will take around 1MB of memory. */ static u_int g_eli_key_cache_limit = 8192; -TUNABLE_INT("kern.geom.eli.key_cache_limit", &g_eli_key_cache_limit); SYSCTL_UINT(_kern_geom_eli, OID_AUTO, key_cache_limit, CTLFLAG_RDTUN, &g_eli_key_cache_limit, 0, "Maximum number of encryption keys to cache"); static uint64_t g_eli_key_cache_hits; diff --git a/sys/geom/gate/g_gate.c b/sys/geom/gate/g_gate.c index eed4abbc54a23..ae0d7b094a5f2 100644 --- a/sys/geom/gate/g_gate.c +++ b/sys/geom/gate/g_gate.c @@ -62,11 +62,9 @@ SYSCTL_DECL(_kern_geom); static SYSCTL_NODE(_kern_geom, OID_AUTO, gate, CTLFLAG_RW, 0, "GEOM_GATE configuration"); static int g_gate_debug = 0; -TUNABLE_INT("kern.geom.gate.debug", &g_gate_debug); -SYSCTL_INT(_kern_geom_gate, OID_AUTO, debug, CTLFLAG_RW, &g_gate_debug, 0, +SYSCTL_INT(_kern_geom_gate, OID_AUTO, debug, CTLFLAG_RWTUN, &g_gate_debug, 0, "Debug level"); static u_int g_gate_maxunits = 256; -TUNABLE_INT("kern.geom.gate.maxunits", &g_gate_maxunits); SYSCTL_UINT(_kern_geom_gate, OID_AUTO, maxunits, CTLFLAG_RDTUN, &g_gate_maxunits, 0, "Maximum number of ggate devices"); diff --git a/sys/geom/geom_disk.c b/sys/geom/geom_disk.c index eb72597dbe345..5cfdaf0af3698 100644 --- a/sys/geom/geom_disk.c +++ b/sys/geom/geom_disk.c @@ -561,12 +561,9 @@ g_disk_create(void *arg, int flag) SYSCTL_STATIC_CHILDREN(_kern_geom_disk), OID_AUTO, gp->name, CTLFLAG_RD, 0, tmpstr); if (sc->sysctl_tree != NULL) { - snprintf(tmpstr, sizeof(tmpstr), - "kern.geom.disk.%s.led", gp->name); - TUNABLE_STR_FETCH(tmpstr, sc->led, sizeof(sc->led)); SYSCTL_ADD_STRING(&sc->sysctl_ctx, SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, "led", - CTLFLAG_RW | CTLFLAG_TUN, sc->led, sizeof(sc->led), + CTLFLAG_RWTUN, sc->led, sizeof(sc->led), "LED name"); } pp->private = sc; diff --git a/sys/geom/geom_kern.c b/sys/geom/geom_kern.c index 79afb14abe9e2..3559daf5fcab6 100644 --- a/sys/geom/geom_kern.c +++ b/sys/geom/geom_kern.c @@ -212,8 +212,7 @@ SYSCTL_PROC(_kern_geom, OID_AUTO, conftxt, CTLTYPE_STRING|CTLFLAG_RD, 0, 0, sysctl_kern_geom_conftxt, "", "Dump the GEOM config in txt"); -TUNABLE_INT("kern.geom.debugflags", &g_debugflags); -SYSCTL_INT(_kern_geom, OID_AUTO, debugflags, CTLFLAG_RW, +SYSCTL_INT(_kern_geom, OID_AUTO, debugflags, CTLFLAG_RWTUN, &g_debugflags, 0, "Set various trace levels for GEOM debugging"); SYSCTL_INT(_kern_geom, OID_AUTO, notaste, CTLFLAG_RW, diff --git a/sys/geom/journal/g_journal.c b/sys/geom/journal/g_journal.c index 390847864812e..52dbc36e73365 100644 --- a/sys/geom/journal/g_journal.c +++ b/sys/geom/journal/g_journal.c @@ -84,7 +84,6 @@ const struct g_journal_desc *g_journal_filesystems[] = { SYSCTL_DECL(_kern_geom); int g_journal_debug = 0; -TUNABLE_INT("kern.geom.journal.debug", &g_journal_debug); static u_int g_journal_switch_time = 10; static u_int g_journal_force_switch = 70; static u_int g_journal_parallel_flushes = 16; @@ -95,7 +94,7 @@ static u_int g_journal_do_optimize = 1; static SYSCTL_NODE(_kern_geom, OID_AUTO, journal, CTLFLAG_RW, 0, "GEOM_JOURNAL stuff"); -SYSCTL_INT(_kern_geom_journal, OID_AUTO, debug, CTLFLAG_RW, &g_journal_debug, 0, +SYSCTL_INT(_kern_geom_journal, OID_AUTO, debug, CTLFLAG_RWTUN, &g_journal_debug, 0, "Debug level"); SYSCTL_UINT(_kern_geom_journal, OID_AUTO, switch_time, CTLFLAG_RW, &g_journal_switch_time, 0, "Switch journals every N seconds"); @@ -133,9 +132,7 @@ SYSCTL_UINT(_kern_geom_journal, OID_AUTO, optimize, CTLFLAG_RW, static u_int g_journal_cache_used = 0; static u_int g_journal_cache_limit = 64 * 1024 * 1024; -TUNABLE_INT("kern.geom.journal.cache.limit", &g_journal_cache_limit); static u_int g_journal_cache_divisor = 2; -TUNABLE_INT("kern.geom.journal.cache.divisor", &g_journal_cache_divisor); static u_int g_journal_cache_switch = 90; static u_int g_journal_cache_misses = 0; static u_int g_journal_cache_alloc_failures = 0; @@ -160,7 +157,7 @@ g_journal_cache_limit_sysctl(SYSCTL_HANDLER_ARGS) return (0); } SYSCTL_PROC(_kern_geom_journal_cache, OID_AUTO, limit, - CTLTYPE_UINT | CTLFLAG_RW, NULL, 0, g_journal_cache_limit_sysctl, "I", + CTLTYPE_UINT | CTLFLAG_RWTUN, NULL, 0, g_journal_cache_limit_sysctl, "I", "Maximum number of allocated bytes"); SYSCTL_UINT(_kern_geom_journal_cache, OID_AUTO, divisor, CTLFLAG_RDTUN, &g_journal_cache_divisor, 0, diff --git a/sys/geom/label/g_label.c b/sys/geom/label/g_label.c index ce1376e269ca7..36498e1c3b1ef 100644 --- a/sys/geom/label/g_label.c +++ b/sys/geom/label/g_label.c @@ -50,8 +50,7 @@ FEATURE(geom_label, "GEOM labeling support"); SYSCTL_DECL(_kern_geom); SYSCTL_NODE(_kern_geom, OID_AUTO, label, CTLFLAG_RW, 0, "GEOM_LABEL stuff"); u_int g_label_debug = 0; -TUNABLE_INT("kern.geom.label.debug", &g_label_debug); -SYSCTL_UINT(_kern_geom_label, OID_AUTO, debug, CTLFLAG_RW, &g_label_debug, 0, +SYSCTL_UINT(_kern_geom_label, OID_AUTO, debug, CTLFLAG_RWTUN, &g_label_debug, 0, "Debug level"); static int g_label_destroy_geom(struct gctl_req *req, struct g_class *mp, diff --git a/sys/geom/label/g_label.h b/sys/geom/label/g_label.h index eca31264ec16f..66b762c6f920f 100644 --- a/sys/geom/label/g_label.h +++ b/sys/geom/label/g_label.h @@ -65,9 +65,7 @@ SYSCTL_DECL(_kern_geom_label); SYSCTL_NODE(_kern_geom_label, OID_AUTO, kind, CTLFLAG_RD, \ NULL, ""); \ SYSCTL_INT(_kern_geom_label_##kind, OID_AUTO, enable, \ - CTLFLAG_RW, &label.ld_enabled, 1, descr); \ - TUNABLE_INT("kern.geom.label." __XSTRING(kind) ".enable", \ - &label.ld_enabled) + CTLFLAG_RWTUN, &label.ld_enabled, 1, descr) typedef void g_label_taste_t (struct g_consumer *cp, char *label, size_t size); diff --git a/sys/geom/linux_lvm/g_linux_lvm.c b/sys/geom/linux_lvm/g_linux_lvm.c index 2ac19e06958f3..bf2f1e795f3b7 100644 --- a/sys/geom/linux_lvm/g_linux_lvm.c +++ b/sys/geom/linux_lvm/g_linux_lvm.c @@ -79,8 +79,7 @@ SYSCTL_DECL(_kern_geom); SYSCTL_NODE(_kern_geom, OID_AUTO, linux_lvm, CTLFLAG_RW, 0, "GEOM_LINUX_LVM stuff"); static u_int g_llvm_debug = 0; -TUNABLE_INT("kern.geom.linux_lvm.debug", &g_llvm_debug); -SYSCTL_UINT(_kern_geom_linux_lvm, OID_AUTO, debug, CTLFLAG_RW, &g_llvm_debug, 0, +SYSCTL_UINT(_kern_geom_linux_lvm, OID_AUTO, debug, CTLFLAG_RWTUN, &g_llvm_debug, 0, "Debug level"); LIST_HEAD(, g_llvm_vg) vg_list; diff --git a/sys/geom/mirror/g_mirror.c b/sys/geom/mirror/g_mirror.c index e4dffdcae2c12..2fae439c99f65 100644 --- a/sys/geom/mirror/g_mirror.c +++ b/sys/geom/mirror/g_mirror.c @@ -54,24 +54,18 @@ SYSCTL_DECL(_kern_geom); static SYSCTL_NODE(_kern_geom, OID_AUTO, mirror, CTLFLAG_RW, 0, "GEOM_MIRROR stuff"); u_int g_mirror_debug = 0; -TUNABLE_INT("kern.geom.mirror.debug", &g_mirror_debug); -SYSCTL_UINT(_kern_geom_mirror, OID_AUTO, debug, CTLFLAG_RW, &g_mirror_debug, 0, +SYSCTL_UINT(_kern_geom_mirror, OID_AUTO, debug, CTLFLAG_RWTUN, &g_mirror_debug, 0, "Debug level"); static u_int g_mirror_timeout = 4; -TUNABLE_INT("kern.geom.mirror.timeout", &g_mirror_timeout); -SYSCTL_UINT(_kern_geom_mirror, OID_AUTO, timeout, CTLFLAG_RW, &g_mirror_timeout, +SYSCTL_UINT(_kern_geom_mirror, OID_AUTO, timeout, CTLFLAG_RWTUN, &g_mirror_timeout, 0, "Time to wait on all mirror components"); static u_int g_mirror_idletime = 5; -TUNABLE_INT("kern.geom.mirror.idletime", &g_mirror_idletime); -SYSCTL_UINT(_kern_geom_mirror, OID_AUTO, idletime, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_mirror, OID_AUTO, idletime, CTLFLAG_RWTUN, &g_mirror_idletime, 0, "Mark components as clean when idling"); static u_int g_mirror_disconnect_on_failure = 1; -TUNABLE_INT("kern.geom.mirror.disconnect_on_failure", - &g_mirror_disconnect_on_failure); -SYSCTL_UINT(_kern_geom_mirror, OID_AUTO, disconnect_on_failure, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_mirror, OID_AUTO, disconnect_on_failure, CTLFLAG_RWTUN, &g_mirror_disconnect_on_failure, 0, "Disconnect component on I/O failure."); static u_int g_mirror_syncreqs = 2; -TUNABLE_INT("kern.geom.mirror.sync_requests", &g_mirror_syncreqs); SYSCTL_UINT(_kern_geom_mirror, OID_AUTO, sync_requests, CTLFLAG_RDTUN, &g_mirror_syncreqs, 0, "Parallel synchronization I/O requests."); diff --git a/sys/geom/part/g_part.c b/sys/geom/part/g_part.c index 8429fa06a26bf..2a04ba315673c 100644 --- a/sys/geom/part/g_part.c +++ b/sys/geom/part/g_part.c @@ -123,9 +123,8 @@ SYSCTL_DECL(_kern_geom); SYSCTL_NODE(_kern_geom, OID_AUTO, part, CTLFLAG_RW, 0, "GEOM_PART stuff"); static u_int check_integrity = 1; -TUNABLE_INT("kern.geom.part.check_integrity", &check_integrity); SYSCTL_UINT(_kern_geom_part, OID_AUTO, check_integrity, - CTLFLAG_RW | CTLFLAG_TUN, &check_integrity, 1, + CTLFLAG_RWTUN, &check_integrity, 1, "Enable integrity checking"); /* diff --git a/sys/geom/part/g_part_ldm.c b/sys/geom/part/g_part_ldm.c index 40c2eb877b07e..82bf76dad5224 100644 --- a/sys/geom/part/g_part_ldm.c +++ b/sys/geom/part/g_part_ldm.c @@ -55,18 +55,16 @@ static SYSCTL_NODE(_kern_geom_part, OID_AUTO, ldm, CTLFLAG_RW, 0, "GEOM_PART_LDM Logical Disk Manager"); static u_int ldm_debug = 0; -TUNABLE_INT("kern.geom.part.ldm.debug", &ldm_debug); SYSCTL_UINT(_kern_geom_part_ldm, OID_AUTO, debug, - CTLFLAG_RW | CTLFLAG_TUN, &ldm_debug, 0, "Debug level"); + CTLFLAG_RWTUN, &ldm_debug, 0, "Debug level"); /* * This allows access to mirrored LDM volumes. Since we do not * doing mirroring here, it is not enabled by default. */ static u_int show_mirrors = 0; -TUNABLE_INT("kern.geom.part.ldm.show_mirrors", &show_mirrors); SYSCTL_UINT(_kern_geom_part_ldm, OID_AUTO, show_mirrors, - CTLFLAG_RW | CTLFLAG_TUN, &show_mirrors, 0, "Show mirrored volumes"); + CTLFLAG_RWTUN, &show_mirrors, 0, "Show mirrored volumes"); #define LDM_DEBUG(lvl, fmt, ...) do { \ if (ldm_debug >= (lvl)) { \ diff --git a/sys/geom/raid/g_raid.c b/sys/geom/raid/g_raid.c index 858cf4c75b271..db9cf445ecb2f 100644 --- a/sys/geom/raid/g_raid.c +++ b/sys/geom/raid/g_raid.c @@ -53,49 +53,38 @@ static MALLOC_DEFINE(M_RAID, "raid_data", "GEOM_RAID Data"); SYSCTL_DECL(_kern_geom); SYSCTL_NODE(_kern_geom, OID_AUTO, raid, CTLFLAG_RW, 0, "GEOM_RAID stuff"); int g_raid_enable = 1; -TUNABLE_INT("kern.geom.raid.enable", &g_raid_enable); -SYSCTL_INT(_kern_geom_raid, OID_AUTO, enable, CTLFLAG_RW, +SYSCTL_INT(_kern_geom_raid, OID_AUTO, enable, CTLFLAG_RWTUN, &g_raid_enable, 0, "Enable on-disk metadata taste"); u_int g_raid_aggressive_spare = 0; -TUNABLE_INT("kern.geom.raid.aggressive_spare", &g_raid_aggressive_spare); -SYSCTL_UINT(_kern_geom_raid, OID_AUTO, aggressive_spare, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_raid, OID_AUTO, aggressive_spare, CTLFLAG_RWTUN, &g_raid_aggressive_spare, 0, "Use disks without metadata as spare"); u_int g_raid_debug = 0; -TUNABLE_INT("kern.geom.raid.debug", &g_raid_debug); -SYSCTL_UINT(_kern_geom_raid, OID_AUTO, debug, CTLFLAG_RW, &g_raid_debug, 0, +SYSCTL_UINT(_kern_geom_raid, OID_AUTO, debug, CTLFLAG_RWTUN, &g_raid_debug, 0, "Debug level"); int g_raid_read_err_thresh = 10; -TUNABLE_INT("kern.geom.raid.read_err_thresh", &g_raid_read_err_thresh); -SYSCTL_UINT(_kern_geom_raid, OID_AUTO, read_err_thresh, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_raid, OID_AUTO, read_err_thresh, CTLFLAG_RWTUN, &g_raid_read_err_thresh, 0, "Number of read errors equated to disk failure"); u_int g_raid_start_timeout = 30; -TUNABLE_INT("kern.geom.raid.start_timeout", &g_raid_start_timeout); -SYSCTL_UINT(_kern_geom_raid, OID_AUTO, start_timeout, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_raid, OID_AUTO, start_timeout, CTLFLAG_RWTUN, &g_raid_start_timeout, 0, "Time to wait for all array components"); static u_int g_raid_clean_time = 5; -TUNABLE_INT("kern.geom.raid.clean_time", &g_raid_clean_time); -SYSCTL_UINT(_kern_geom_raid, OID_AUTO, clean_time, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_raid, OID_AUTO, clean_time, CTLFLAG_RWTUN, &g_raid_clean_time, 0, "Mark volume as clean when idling"); static u_int g_raid_disconnect_on_failure = 1; -TUNABLE_INT("kern.geom.raid.disconnect_on_failure", - &g_raid_disconnect_on_failure); -SYSCTL_UINT(_kern_geom_raid, OID_AUTO, disconnect_on_failure, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_raid, OID_AUTO, disconnect_on_failure, CTLFLAG_RWTUN, &g_raid_disconnect_on_failure, 0, "Disconnect component on I/O failure."); static u_int g_raid_name_format = 0; -TUNABLE_INT("kern.geom.raid.name_format", &g_raid_name_format); -SYSCTL_UINT(_kern_geom_raid, OID_AUTO, name_format, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_raid, OID_AUTO, name_format, CTLFLAG_RWTUN, &g_raid_name_format, 0, "Providers name format."); static u_int g_raid_idle_threshold = 1000000; -TUNABLE_INT("kern.geom.raid.idle_threshold", &g_raid_idle_threshold); -SYSCTL_UINT(_kern_geom_raid, OID_AUTO, idle_threshold, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_raid, OID_AUTO, idle_threshold, CTLFLAG_RWTUN, &g_raid_idle_threshold, 1000000, "Time in microseconds to consider a volume idle."); static u_int ar_legacy_aliases = 1; -SYSCTL_INT(_kern_geom_raid, OID_AUTO, legacy_aliases, CTLFLAG_RW, +SYSCTL_INT(_kern_geom_raid, OID_AUTO, legacy_aliases, CTLFLAG_RWTUN, &ar_legacy_aliases, 0, "Create aliases named as the legacy ataraid style."); -TUNABLE_INT("kern.geom_raid.legacy_aliases", &ar_legacy_aliases); #define MSLEEP(rv, ident, mtx, priority, wmesg, timeout) do { \ diff --git a/sys/geom/raid/g_raid.h b/sys/geom/raid/g_raid.h index 8a96fa9f4698d..f6aa6dbb98d0b 100644 --- a/sys/geom/raid/g_raid.h +++ b/sys/geom/raid/g_raid.h @@ -364,10 +364,8 @@ int g_raid_md_modevent(module_t, int, void *); SYSCTL_NODE(_kern_geom_raid, OID_AUTO, name, CTLFLAG_RD, \ NULL, label " metadata module"); \ SYSCTL_INT(_kern_geom_raid_##name, OID_AUTO, enable, \ - CTLFLAG_RW, &g_raid_md_##name##_class.mdc_enable, 0, \ - "Enable " label " metadata format taste"); \ - TUNABLE_INT("kern.geom.raid." __XSTRING(name) ".enable", \ - &g_raid_md_##name##_class.mdc_enable) + CTLFLAG_RWTUN, &g_raid_md_##name##_class.mdc_enable, 0, \ + "Enable " label " metadata format taste") /* * KOBJ parent class of data transformation modules. @@ -403,10 +401,8 @@ int g_raid_tr_modevent(module_t, int, void *); SYSCTL_NODE(_kern_geom_raid, OID_AUTO, name, CTLFLAG_RD, \ NULL, label " transformation module"); \ SYSCTL_INT(_kern_geom_raid_##name, OID_AUTO, enable, \ - CTLFLAG_RW, &g_raid_tr_##name##_class.trc_enable, 0, \ - "Enable " label " transformation module taste"); \ - TUNABLE_INT("kern.geom.raid." __XSTRING(name) ".enable", \ - &g_raid_tr_##name##_class.trc_enable) + CTLFLAG_RWTUN, &g_raid_tr_##name##_class.trc_enable, 0, \ + "Enable " label " transformation module taste") const char * g_raid_volume_level2str(int level, int qual); int g_raid_volume_str2level(const char *str, int *level, int *qual); diff --git a/sys/geom/raid/tr_raid1.c b/sys/geom/raid/tr_raid1.c index 833655bb854fc..17c7a25997445 100644 --- a/sys/geom/raid/tr_raid1.c +++ b/sys/geom/raid/tr_raid1.c @@ -46,33 +46,25 @@ SYSCTL_DECL(_kern_geom_raid_raid1); #define RAID1_REBUILD_SLAB (1 << 20) /* One transation in a rebuild */ static int g_raid1_rebuild_slab = RAID1_REBUILD_SLAB; -TUNABLE_INT("kern.geom.raid.raid1.rebuild_slab_size", - &g_raid1_rebuild_slab); -SYSCTL_UINT(_kern_geom_raid_raid1, OID_AUTO, rebuild_slab_size, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_raid_raid1, OID_AUTO, rebuild_slab_size, CTLFLAG_RWTUN, &g_raid1_rebuild_slab, 0, "Amount of the disk to rebuild each read/write cycle of the rebuild."); #define RAID1_REBUILD_FAIR_IO 20 /* use 1/x of the available I/O */ static int g_raid1_rebuild_fair_io = RAID1_REBUILD_FAIR_IO; -TUNABLE_INT("kern.geom.raid.raid1.rebuild_fair_io", - &g_raid1_rebuild_fair_io); -SYSCTL_UINT(_kern_geom_raid_raid1, OID_AUTO, rebuild_fair_io, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_raid_raid1, OID_AUTO, rebuild_fair_io, CTLFLAG_RWTUN, &g_raid1_rebuild_fair_io, 0, "Fraction of the I/O bandwidth to use when disk busy for rebuild."); #define RAID1_REBUILD_CLUSTER_IDLE 100 static int g_raid1_rebuild_cluster_idle = RAID1_REBUILD_CLUSTER_IDLE; -TUNABLE_INT("kern.geom.raid.raid1.rebuild_cluster_idle", - &g_raid1_rebuild_cluster_idle); -SYSCTL_UINT(_kern_geom_raid_raid1, OID_AUTO, rebuild_cluster_idle, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_raid_raid1, OID_AUTO, rebuild_cluster_idle, CTLFLAG_RWTUN, &g_raid1_rebuild_cluster_idle, 0, "Number of slabs to do each time we trigger a rebuild cycle"); #define RAID1_REBUILD_META_UPDATE 1024 /* update meta data every 1GB or so */ static int g_raid1_rebuild_meta_update = RAID1_REBUILD_META_UPDATE; -TUNABLE_INT("kern.geom.raid.raid1.rebuild_meta_update", - &g_raid1_rebuild_meta_update); -SYSCTL_UINT(_kern_geom_raid_raid1, OID_AUTO, rebuild_meta_update, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_raid_raid1, OID_AUTO, rebuild_meta_update, CTLFLAG_RWTUN, &g_raid1_rebuild_meta_update, 0, "When to update the meta data."); diff --git a/sys/geom/raid/tr_raid1e.c b/sys/geom/raid/tr_raid1e.c index 404b9e6093443..b3577429daca6 100644 --- a/sys/geom/raid/tr_raid1e.c +++ b/sys/geom/raid/tr_raid1e.c @@ -48,33 +48,25 @@ SYSCTL_DECL(_kern_geom_raid_raid1e); #define RAID1E_REBUILD_SLAB (1 << 20) /* One transation in a rebuild */ static int g_raid1e_rebuild_slab = RAID1E_REBUILD_SLAB; -TUNABLE_INT("kern.geom.raid.raid1e.rebuild_slab_size", - &g_raid1e_rebuild_slab); -SYSCTL_UINT(_kern_geom_raid_raid1e, OID_AUTO, rebuild_slab_size, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_raid_raid1e, OID_AUTO, rebuild_slab_size, CTLFLAG_RWTUN, &g_raid1e_rebuild_slab, 0, "Amount of the disk to rebuild each read/write cycle of the rebuild."); #define RAID1E_REBUILD_FAIR_IO 20 /* use 1/x of the available I/O */ static int g_raid1e_rebuild_fair_io = RAID1E_REBUILD_FAIR_IO; -TUNABLE_INT("kern.geom.raid.raid1e.rebuild_fair_io", - &g_raid1e_rebuild_fair_io); -SYSCTL_UINT(_kern_geom_raid_raid1e, OID_AUTO, rebuild_fair_io, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_raid_raid1e, OID_AUTO, rebuild_fair_io, CTLFLAG_RWTUN, &g_raid1e_rebuild_fair_io, 0, "Fraction of the I/O bandwidth to use when disk busy for rebuild."); #define RAID1E_REBUILD_CLUSTER_IDLE 100 static int g_raid1e_rebuild_cluster_idle = RAID1E_REBUILD_CLUSTER_IDLE; -TUNABLE_INT("kern.geom.raid.raid1e.rebuild_cluster_idle", - &g_raid1e_rebuild_cluster_idle); -SYSCTL_UINT(_kern_geom_raid_raid1e, OID_AUTO, rebuild_cluster_idle, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_raid_raid1e, OID_AUTO, rebuild_cluster_idle, CTLFLAG_RWTUN, &g_raid1e_rebuild_cluster_idle, 0, "Number of slabs to do each time we trigger a rebuild cycle"); #define RAID1E_REBUILD_META_UPDATE 1024 /* update meta data every 1GB or so */ static int g_raid1e_rebuild_meta_update = RAID1E_REBUILD_META_UPDATE; -TUNABLE_INT("kern.geom.raid.raid1e.rebuild_meta_update", - &g_raid1e_rebuild_meta_update); -SYSCTL_UINT(_kern_geom_raid_raid1e, OID_AUTO, rebuild_meta_update, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_raid_raid1e, OID_AUTO, rebuild_meta_update, CTLFLAG_RWTUN, &g_raid1e_rebuild_meta_update, 0, "When to update the meta data."); diff --git a/sys/geom/raid3/g_raid3.c b/sys/geom/raid3/g_raid3.c index 927cb3173e712..f935f788a937b 100644 --- a/sys/geom/raid3/g_raid3.c +++ b/sys/geom/raid3/g_raid3.c @@ -54,42 +54,32 @@ SYSCTL_DECL(_kern_geom); static SYSCTL_NODE(_kern_geom, OID_AUTO, raid3, CTLFLAG_RW, 0, "GEOM_RAID3 stuff"); u_int g_raid3_debug = 0; -TUNABLE_INT("kern.geom.raid3.debug", &g_raid3_debug); -SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, debug, CTLFLAG_RW, &g_raid3_debug, 0, +SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, debug, CTLFLAG_RWTUN, &g_raid3_debug, 0, "Debug level"); static u_int g_raid3_timeout = 4; -TUNABLE_INT("kern.geom.raid3.timeout", &g_raid3_timeout); -SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, timeout, CTLFLAG_RW, &g_raid3_timeout, +SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, timeout, CTLFLAG_RWTUN, &g_raid3_timeout, 0, "Time to wait on all raid3 components"); static u_int g_raid3_idletime = 5; -TUNABLE_INT("kern.geom.raid3.idletime", &g_raid3_idletime); -SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, idletime, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, idletime, CTLFLAG_RWTUN, &g_raid3_idletime, 0, "Mark components as clean when idling"); static u_int g_raid3_disconnect_on_failure = 1; -TUNABLE_INT("kern.geom.raid3.disconnect_on_failure", - &g_raid3_disconnect_on_failure); -SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, disconnect_on_failure, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, disconnect_on_failure, CTLFLAG_RWTUN, &g_raid3_disconnect_on_failure, 0, "Disconnect component on I/O failure."); static u_int g_raid3_syncreqs = 2; -TUNABLE_INT("kern.geom.raid3.sync_requests", &g_raid3_syncreqs); SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, sync_requests, CTLFLAG_RDTUN, &g_raid3_syncreqs, 0, "Parallel synchronization I/O requests."); static u_int g_raid3_use_malloc = 0; -TUNABLE_INT("kern.geom.raid3.use_malloc", &g_raid3_use_malloc); SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, use_malloc, CTLFLAG_RDTUN, &g_raid3_use_malloc, 0, "Use malloc(9) instead of uma(9)."); static u_int g_raid3_n64k = 50; -TUNABLE_INT("kern.geom.raid3.n64k", &g_raid3_n64k); -SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, n64k, CTLFLAG_RD, &g_raid3_n64k, 0, +SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, n64k, CTLFLAG_RDTUN, &g_raid3_n64k, 0, "Maximum number of 64kB allocations"); static u_int g_raid3_n16k = 200; -TUNABLE_INT("kern.geom.raid3.n16k", &g_raid3_n16k); -SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, n16k, CTLFLAG_RD, &g_raid3_n16k, 0, +SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, n16k, CTLFLAG_RDTUN, &g_raid3_n16k, 0, "Maximum number of 16kB allocations"); static u_int g_raid3_n4k = 1200; -TUNABLE_INT("kern.geom.raid3.n4k", &g_raid3_n4k); -SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, n4k, CTLFLAG_RD, &g_raid3_n4k, 0, +SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, n4k, CTLFLAG_RDTUN, &g_raid3_n4k, 0, "Maximum number of 4kB allocations"); static SYSCTL_NODE(_kern_geom_raid3, OID_AUTO, stat, CTLFLAG_RW, 0, diff --git a/sys/geom/shsec/g_shsec.c b/sys/geom/shsec/g_shsec.c index 9f8723f619c8a..bfdc8fdc16720 100644 --- a/sys/geom/shsec/g_shsec.c +++ b/sys/geom/shsec/g_shsec.c @@ -71,12 +71,10 @@ SYSCTL_DECL(_kern_geom); static SYSCTL_NODE(_kern_geom, OID_AUTO, shsec, CTLFLAG_RW, 0, "GEOM_SHSEC stuff"); static u_int g_shsec_debug = 0; -TUNABLE_INT("kern.geom.shsec.debug", &g_shsec_debug); -SYSCTL_UINT(_kern_geom_shsec, OID_AUTO, debug, CTLFLAG_RW, &g_shsec_debug, 0, +SYSCTL_UINT(_kern_geom_shsec, OID_AUTO, debug, CTLFLAG_RWTUN, &g_shsec_debug, 0, "Debug level"); static u_int g_shsec_maxmem = MAXPHYS * 100; -TUNABLE_INT("kern.geom.shsec.maxmem", &g_shsec_maxmem); -SYSCTL_UINT(_kern_geom_shsec, OID_AUTO, maxmem, CTLFLAG_RD, &g_shsec_maxmem, +SYSCTL_UINT(_kern_geom_shsec, OID_AUTO, maxmem, CTLFLAG_RDTUN, &g_shsec_maxmem, 0, "Maximum memory that can be allocated for I/O (in bytes)"); static u_int g_shsec_alloc_failed = 0; SYSCTL_UINT(_kern_geom_shsec, OID_AUTO, alloc_failed, CTLFLAG_RD, diff --git a/sys/geom/stripe/g_stripe.c b/sys/geom/stripe/g_stripe.c index 474d888b4b679..1e88e6d606f06 100644 --- a/sys/geom/stripe/g_stripe.c +++ b/sys/geom/stripe/g_stripe.c @@ -71,11 +71,9 @@ SYSCTL_DECL(_kern_geom); static SYSCTL_NODE(_kern_geom, OID_AUTO, stripe, CTLFLAG_RW, 0, "GEOM_STRIPE stuff"); static u_int g_stripe_debug = 0; -TUNABLE_INT("kern.geom.stripe.debug", &g_stripe_debug); -SYSCTL_UINT(_kern_geom_stripe, OID_AUTO, debug, CTLFLAG_RW, &g_stripe_debug, 0, +SYSCTL_UINT(_kern_geom_stripe, OID_AUTO, debug, CTLFLAG_RWTUN, &g_stripe_debug, 0, "Debug level"); static int g_stripe_fast = 0; -TUNABLE_INT("kern.geom.stripe.fast", &g_stripe_fast); static int g_sysctl_stripe_fast(SYSCTL_HANDLER_ARGS) { @@ -87,11 +85,10 @@ g_sysctl_stripe_fast(SYSCTL_HANDLER_ARGS) g_stripe_fast = fast; return (error); } -SYSCTL_PROC(_kern_geom_stripe, OID_AUTO, fast, CTLTYPE_INT | CTLFLAG_RW, +SYSCTL_PROC(_kern_geom_stripe, OID_AUTO, fast, CTLTYPE_INT | CTLFLAG_RWTUN, NULL, 0, g_sysctl_stripe_fast, "I", "Fast, but memory-consuming, mode"); static u_int g_stripe_maxmem = MAXPHYS * 100; -TUNABLE_INT("kern.geom.stripe.maxmem", &g_stripe_maxmem); -SYSCTL_UINT(_kern_geom_stripe, OID_AUTO, maxmem, CTLFLAG_RD, &g_stripe_maxmem, +SYSCTL_UINT(_kern_geom_stripe, OID_AUTO, maxmem, CTLFLAG_RDTUN, &g_stripe_maxmem, 0, "Maximum memory that can be allocated in \"fast\" mode (in bytes)"); static u_int g_stripe_fast_failed = 0; SYSCTL_UINT(_kern_geom_stripe, OID_AUTO, fast_failed, CTLFLAG_RD, diff --git a/sys/geom/vinum/geom_vinum.c b/sys/geom/vinum/geom_vinum.c index 15a62a1d1704d..84d10a51fc868 100644 --- a/sys/geom/vinum/geom_vinum.c +++ b/sys/geom/vinum/geom_vinum.c @@ -50,8 +50,7 @@ SYSCTL_DECL(_kern_geom); static SYSCTL_NODE(_kern_geom, OID_AUTO, vinum, CTLFLAG_RW, 0, "GEOM_VINUM stuff"); u_int g_vinum_debug = 0; -TUNABLE_INT("kern.geom.vinum.debug", &g_vinum_debug); -SYSCTL_UINT(_kern_geom_vinum, OID_AUTO, debug, CTLFLAG_RW, &g_vinum_debug, 0, +SYSCTL_UINT(_kern_geom_vinum, OID_AUTO, debug, CTLFLAG_RWTUN, &g_vinum_debug, 0, "Debug level"); static int gv_create(struct g_geom *, struct gctl_req *); diff --git a/sys/geom/virstor/g_virstor.c b/sys/geom/virstor/g_virstor.c index 40e25d15a1ec0..a1774a9c4984e 100644 --- a/sys/geom/virstor/g_virstor.c +++ b/sys/geom/virstor/g_virstor.c @@ -84,20 +84,16 @@ static SYSCTL_NODE(_kern_geom, OID_AUTO, virstor, CTLFLAG_RW, 0, "GEOM_GVIRSTOR information"); static u_int g_virstor_debug = 2; /* XXX: lower to 2 when released to public */ -TUNABLE_INT("kern.geom.virstor.debug", &g_virstor_debug); -SYSCTL_UINT(_kern_geom_virstor, OID_AUTO, debug, CTLFLAG_RW, &g_virstor_debug, +SYSCTL_UINT(_kern_geom_virstor, OID_AUTO, debug, CTLFLAG_RWTUN, &g_virstor_debug, 0, "Debug level (2=production, 5=normal, 15=excessive)"); static u_int g_virstor_chunk_watermark = 100; -TUNABLE_INT("kern.geom.virstor.chunk_watermark", &g_virstor_chunk_watermark); -SYSCTL_UINT(_kern_geom_virstor, OID_AUTO, chunk_watermark, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_virstor, OID_AUTO, chunk_watermark, CTLFLAG_RWTUN, &g_virstor_chunk_watermark, 0, "Minimum number of free chunks before issuing administrative warning"); static u_int g_virstor_component_watermark = 1; -TUNABLE_INT("kern.geom.virstor.component_watermark", - &g_virstor_component_watermark); -SYSCTL_UINT(_kern_geom_virstor, OID_AUTO, component_watermark, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_virstor, OID_AUTO, component_watermark, CTLFLAG_RWTUN, &g_virstor_component_watermark, 0, "Minimum number of free components before issuing administrative warning"); diff --git a/sys/i386/acpica/acpi_machdep.c b/sys/i386/acpica/acpi_machdep.c index a244e7377c954..049354b0c2133 100644 --- a/sys/i386/acpica/acpi_machdep.c +++ b/sys/i386/acpica/acpi_machdep.c @@ -45,8 +45,7 @@ __FBSDID("$FreeBSD$"); #include uint32_t acpi_resume_beep; -TUNABLE_INT("debug.acpi.resume_beep", &acpi_resume_beep); -SYSCTL_UINT(_debug_acpi, OID_AUTO, resume_beep, CTLFLAG_RW, &acpi_resume_beep, +SYSCTL_UINT(_debug_acpi, OID_AUTO, resume_beep, CTLFLAG_RWTUN, &acpi_resume_beep, 0, "Beep the PC speaker when resuming"); uint32_t acpi_reset_video; diff --git a/sys/i386/bios/apm.c b/sys/i386/bios/apm.c index bf5071f0deddc..a4d3bd79ee39b 100644 --- a/sys/i386/bios/apm.c +++ b/sys/i386/bios/apm.c @@ -134,8 +134,7 @@ SYSCTL_INT(_machdep, OID_AUTO, apm_suspend_delay, CTLFLAG_RW, &apm_suspend_delay SYSCTL_INT(_machdep, OID_AUTO, apm_standby_delay, CTLFLAG_RW, &apm_standby_delay, 1, ""); SYSCTL_INT(_debug, OID_AUTO, apm_debug, CTLFLAG_RW, &apm_debug, 0, ""); -TUNABLE_INT("machdep.apm_swab_batt_minutes", &apm_swab_batt_minutes); -SYSCTL_INT(_machdep, OID_AUTO, apm_swab_batt_minutes, CTLFLAG_RW, +SYSCTL_INT(_machdep, OID_AUTO, apm_swab_batt_minutes, CTLFLAG_RWTUN, &apm_swab_batt_minutes, 0, "Byte swap battery time value."); #ifdef PC98 diff --git a/sys/i386/i386/i686_mem.c b/sys/i386/i386/i686_mem.c index 84db1ec0d02c9..2721cfb35aaab 100644 --- a/sys/i386/i386/i686_mem.c +++ b/sys/i386/i386/i686_mem.c @@ -65,7 +65,6 @@ static char *mem_owner_bios = "BIOS"; (((curr) & ~MDF_ATTRMASK) | ((new) & MDF_ATTRMASK)) static int mtrrs_disabled; -TUNABLE_INT("machdep.disable_mtrrs", &mtrrs_disabled); SYSCTL_INT(_machdep, OID_AUTO, disable_mtrrs, CTLFLAG_RDTUN, &mtrrs_disabled, 0, "Disable i686 MTRRs."); diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index 3d92e6e56f4b3..ac41c2796237f 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -1231,8 +1231,7 @@ cpu_halt(void) void (*cpu_idle_hook)(sbintime_t) = NULL; /* ACPI idle hook. */ static int cpu_ident_amdc1e = 0; /* AMD C1E supported. */ static int idle_mwait = 1; /* Use MONITOR/MWAIT for short idle. */ -TUNABLE_INT("machdep.idle_mwait", &idle_mwait); -SYSCTL_INT(_machdep, OID_AUTO, idle_mwait, CTLFLAG_RW, &idle_mwait, +SYSCTL_INT(_machdep, OID_AUTO, idle_mwait, CTLFLAG_RWTUN, &idle_mwait, 0, "Use MONITOR/MWAIT for short idle"); #define STATE_RUNNING 0x0 diff --git a/sys/i386/i386/mp_watchdog.c b/sys/i386/i386/mp_watchdog.c index b1799a20b3db5..b03d2614d9b54 100644 --- a/sys/i386/i386/mp_watchdog.c +++ b/sys/i386/i386/mp_watchdog.c @@ -68,8 +68,7 @@ static int watchdog_dontfire = 1; static int watchdog_timer = -1; static int watchdog_nmi = 1; -TUNABLE_INT("debug.watchdog", &watchdog_cpu); -SYSCTL_INT(_debug, OID_AUTO, watchdog_nmi, CTLFLAG_RW, &watchdog_nmi, 0, +SYSCTL_INT(_debug, OID_AUTO, watchdog_nmi, CTLFLAG_RWTUN, &watchdog_nmi, 0, "IPI the boot processor with an NMI to enter the debugger"); static struct callout watchdog_callout; diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c index af8c9ff0f983d..3085157dbb95a 100644 --- a/sys/i386/i386/pmap.c +++ b/sys/i386/i386/pmap.c @@ -225,8 +225,8 @@ SYSCTL_INT(_vm_pmap, OID_AUTO, pat_works, CTLFLAG_RD, &pat_works, 1, "Is page attribute table fully functional?"); static int pg_ps_enabled = 1; -SYSCTL_INT(_vm_pmap, OID_AUTO, pg_ps_enabled, CTLFLAG_RDTUN, &pg_ps_enabled, 0, - "Are large page mappings enabled?"); +SYSCTL_INT(_vm_pmap, OID_AUTO, pg_ps_enabled, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, + &pg_ps_enabled, 0, "Are large page mappings enabled?"); #define PAT_INDEX_SIZE 8 static int pat_index[PAT_INDEX_SIZE]; /* cache mode to PAT index conversion */ diff --git a/sys/i386/i386/trap.c b/sys/i386/i386/trap.c index 97254f25bde41..6e4aba2a21331 100644 --- a/sys/i386/i386/trap.c +++ b/sys/i386/i386/trap.c @@ -158,14 +158,12 @@ extern int has_f00f_bug; #ifdef KDB static int kdb_on_nmi = 1; -SYSCTL_INT(_machdep, OID_AUTO, kdb_on_nmi, CTLFLAG_RW, +SYSCTL_INT(_machdep, OID_AUTO, kdb_on_nmi, CTLFLAG_RWTUN, &kdb_on_nmi, 0, "Go to KDB on NMI"); -TUNABLE_INT("machdep.kdb_on_nmi", &kdb_on_nmi); #endif static int panic_on_nmi = 1; -SYSCTL_INT(_machdep, OID_AUTO, panic_on_nmi, CTLFLAG_RW, +SYSCTL_INT(_machdep, OID_AUTO, panic_on_nmi, CTLFLAG_RWTUN, &panic_on_nmi, 0, "Panic on NMI"); -TUNABLE_INT("machdep.panic_on_nmi", &panic_on_nmi); static int prot_fault_translation = 0; SYSCTL_INT(_machdep, OID_AUTO, prot_fault_translation, CTLFLAG_RW, &prot_fault_translation, 0, "Select signal to deliver on protection fault"); diff --git a/sys/i386/pci/pci_cfgreg.c b/sys/i386/pci/pci_cfgreg.c index cce4981d9c9d5..5d57e89334a18 100644 --- a/sys/i386/pci/pci_cfgreg.c +++ b/sys/i386/pci/pci_cfgreg.c @@ -86,7 +86,6 @@ static int cfgmech; static int devmax; static struct mtx pcicfg_mtx; static int mcfg_enable = 1; -TUNABLE_INT("hw.pci.mcfg", &mcfg_enable); SYSCTL_INT(_hw_pci, OID_AUTO, mcfg, CTLFLAG_RDTUN, &mcfg_enable, 0, "Enable support for PCI-e memory mapped config access"); diff --git a/sys/i386/pci/pci_pir.c b/sys/i386/pci/pci_pir.c index c275de094f5cf..0d64cabf4aab2 100644 --- a/sys/i386/pci/pci_pir.c +++ b/sys/i386/pci/pci_pir.c @@ -117,7 +117,6 @@ SYSCTL_DECL(_hw_pci); #endif static uint32_t pci_irq_override_mask = PCI_IRQ_OVERRIDE_MASK; -TUNABLE_INT("hw.pci.irq_override_mask", &pci_irq_override_mask); SYSCTL_INT(_hw_pci, OID_AUTO, irq_override_mask, CTLFLAG_RDTUN, &pci_irq_override_mask, PCI_IRQ_OVERRIDE_MASK, "Mask of allowed irqs to try to route when it has no good clue about\n" diff --git a/sys/ia64/ia64/dump_machdep.c b/sys/ia64/ia64/dump_machdep.c index 9a058bb1f4baf..d6d9d0487a49d 100644 --- a/sys/ia64/ia64/dump_machdep.c +++ b/sys/ia64/ia64/dump_machdep.c @@ -57,8 +57,7 @@ CTASSERT(sizeof(struct kerneldumpheader) == 512); #define DEV_ALIGN(x) (((off_t)(x) + (DEV_BSIZE-1)) & ~(DEV_BSIZE-1)) static int minidump = 0; -TUNABLE_INT("debug.minidump", &minidump); -SYSCTL_INT(_debug, OID_AUTO, minidump, CTLFLAG_RW, &minidump, 0, +SYSCTL_INT(_debug, OID_AUTO, minidump, CTLFLAG_RWTUN, &minidump, 0, "Enable mini crash dumps"); static struct kerneldumpheader kdh; diff --git a/sys/ia64/ia64/pmap.c b/sys/ia64/ia64/pmap.c index 9f642970fcb9a..1ed35c3ffcb21 100644 --- a/sys/ia64/ia64/pmap.c +++ b/sys/ia64/ia64/pmap.c @@ -240,9 +240,8 @@ int pmap_vhpt_nbuckets; SYSCTL_INT(_machdep_vhpt, OID_AUTO, nbuckets, CTLFLAG_RD, &pmap_vhpt_nbuckets, 0, ""); -int pmap_vhpt_log2size = 0; -TUNABLE_INT("machdep.vhpt.log2size", &pmap_vhpt_log2size); -SYSCTL_INT(_machdep_vhpt, OID_AUTO, log2size, CTLFLAG_RD, +int pmap_vhpt_log2size; +SYSCTL_INT(_machdep_vhpt, OID_AUTO, log2size, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &pmap_vhpt_log2size, 0, ""); static int pmap_vhpt_inserts; diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index 591094e5af968..b085a708b57f5 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -112,10 +112,8 @@ static int compress_core(gzFile, char *, char *, unsigned int, int __elfN(fallback_brand) = -1; SYSCTL_INT(__CONCAT(_kern_elf, __ELF_WORD_SIZE), OID_AUTO, - fallback_brand, CTLFLAG_RW, &__elfN(fallback_brand), 0, + fallback_brand, CTLFLAG_RWTUN, &__elfN(fallback_brand), 0, __XSTRING(__CONCAT(ELF, __ELF_WORD_SIZE)) " brand of last resort"); -TUNABLE_INT("kern.elf" __XSTRING(__ELF_WORD_SIZE) ".fallback_brand", - &__elfN(fallback_brand)); static int elf_legacy_coredump = 0; SYSCTL_INT(_debug, OID_AUTO, __elfN(legacy_coredump), CTLFLAG_RW, diff --git a/sys/kern/kern_clocksource.c b/sys/kern/kern_clocksource.c index ae64c616c1f66..092c81807b173 100644 --- a/sys/kern/kern_clocksource.c +++ b/sys/kern/kern_clocksource.c @@ -96,23 +96,21 @@ static sbintime_t statperiod; /* statclock() events period. */ static sbintime_t profperiod; /* profclock() events period. */ static sbintime_t nexttick; /* Next global timer tick time. */ static u_int busy = 1; /* Reconfiguration is in progress. */ -static int profiling = 0; /* Profiling events enabled. */ +static int profiling; /* Profiling events enabled. */ static char timername[32]; /* Wanted timer. */ TUNABLE_STR("kern.eventtimer.timer", timername, sizeof(timername)); -static int singlemul = 0; /* Multiplier for periodic mode. */ -TUNABLE_INT("kern.eventtimer.singlemul", &singlemul); -SYSCTL_INT(_kern_eventtimer, OID_AUTO, singlemul, CTLFLAG_RW, &singlemul, +static int singlemul; /* Multiplier for periodic mode. */ +SYSCTL_INT(_kern_eventtimer, OID_AUTO, singlemul, CTLFLAG_RWTUN, &singlemul, 0, "Multiplier for periodic mode"); -static u_int idletick = 0; /* Run periodic events when idle. */ -TUNABLE_INT("kern.eventtimer.idletick", &idletick); -SYSCTL_UINT(_kern_eventtimer, OID_AUTO, idletick, CTLFLAG_RW, &idletick, +static u_int idletick; /* Run periodic events when idle. */ +SYSCTL_UINT(_kern_eventtimer, OID_AUTO, idletick, CTLFLAG_RWTUN, &idletick, 0, "Run periodic events when idle"); -static int periodic = 0; /* Periodic or one-shot mode. */ -static int want_periodic = 0; /* What mode to prefer. */ +static int periodic; /* Periodic or one-shot mode. */ +static int want_periodic; /* What mode to prefer. */ TUNABLE_INT("kern.eventtimer.periodic", &want_periodic); struct pcpu_state { diff --git a/sys/kern/kern_cpu.c b/sys/kern/kern_cpu.c index 7206c388f76a8..293b940683ba5 100644 --- a/sys/kern/kern_cpu.c +++ b/sys/kern/kern_cpu.c @@ -133,13 +133,11 @@ DRIVER_MODULE(cpufreq, cpu, cpufreq_driver, cpufreq_dc, 0, 0); static int cf_lowest_freq; static int cf_verbose; -TUNABLE_INT("debug.cpufreq.lowest", &cf_lowest_freq); -TUNABLE_INT("debug.cpufreq.verbose", &cf_verbose); static SYSCTL_NODE(_debug, OID_AUTO, cpufreq, CTLFLAG_RD, NULL, "cpufreq debugging"); -SYSCTL_INT(_debug_cpufreq, OID_AUTO, lowest, CTLFLAG_RW, &cf_lowest_freq, 1, +SYSCTL_INT(_debug_cpufreq, OID_AUTO, lowest, CTLFLAG_RWTUN, &cf_lowest_freq, 1, "Don't provide levels below this frequency."); -SYSCTL_INT(_debug_cpufreq, OID_AUTO, verbose, CTLFLAG_RW, &cf_verbose, 1, +SYSCTL_INT(_debug_cpufreq, OID_AUTO, verbose, CTLFLAG_RWTUN, &cf_verbose, 1, "Print verbose debugging messages"); static int diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 078cd383bae0d..7d3bad9d50c43 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -127,8 +127,7 @@ SYSCTL_INT(_kern, OID_AUTO, disallow_high_osrel, CTLFLAG_RW, "Disallow execution of binaries built for higher version of the world"); static int map_at_zero = 0; -TUNABLE_INT("security.bsd.map_at_zero", &map_at_zero); -SYSCTL_INT(_security_bsd, OID_AUTO, map_at_zero, CTLFLAG_RW, &map_at_zero, 0, +SYSCTL_INT(_security_bsd, OID_AUTO, map_at_zero, CTLFLAG_RWTUN, &map_at_zero, 0, "Permit processes to map an object at virtual address 0."); static int diff --git a/sys/kern/kern_intr.c b/sys/kern/kern_intr.c index 5555d6858f9ac..25032f278c1d7 100644 --- a/sys/kern/kern_intr.c +++ b/sys/kern/kern_intr.c @@ -89,8 +89,7 @@ struct proc *intrproc; static MALLOC_DEFINE(M_ITHREAD, "ithread", "Interrupt Threads"); static int intr_storm_threshold = 1000; -TUNABLE_INT("hw.intr_storm_threshold", &intr_storm_threshold); -SYSCTL_INT(_hw, OID_AUTO, intr_storm_threshold, CTLFLAG_RW, +SYSCTL_INT(_hw, OID_AUTO, intr_storm_threshold, CTLFLAG_RWTUN, &intr_storm_threshold, 0, "Number of consecutive interrupts before storm protection is enabled"); static TAILQ_HEAD(, intr_event) event_list = diff --git a/sys/kern/kern_ktr.c b/sys/kern/kern_ktr.c index e302ae228d458..c377f36e09a74 100644 --- a/sys/kern/kern_ktr.c +++ b/sys/kern/kern_ktr.c @@ -104,33 +104,17 @@ struct ktr_entry *ktr_buf = ktr_buf_init; cpuset_t ktr_cpumask = CPUSET_T_INITIALIZER(KTR_CPUMASK); static char ktr_cpumask_str[CPUSETBUFSIZ]; -TUNABLE_INT("debug.ktr.mask", &ktr_mask); - -TUNABLE_STR("debug.ktr.cpumask", ktr_cpumask_str, sizeof(ktr_cpumask_str)); - static SYSCTL_NODE(_debug, OID_AUTO, ktr, CTLFLAG_RD, 0, "KTR options"); +SYSCTL_INT(_debug_ktr, OID_AUTO, mask, CTLFLAG_RDTUN, + &ktr_mask, 0, "KTR mask"); + SYSCTL_INT(_debug_ktr, OID_AUTO, version, CTLFLAG_RD, &ktr_version, 0, "Version of the KTR interface"); SYSCTL_UINT(_debug_ktr, OID_AUTO, compile, CTLFLAG_RD, &ktr_compile, 0, "Bitmask of KTR event classes compiled into the kernel"); -static void -ktr_cpumask_initializer(void *dummy __unused) -{ - - /* - * TUNABLE_STR() runs with SI_ORDER_MIDDLE priority, thus it must be - * already set, if necessary. - */ - if (ktr_cpumask_str[0] != '\0' && - cpusetobj_strscan(&ktr_cpumask, ktr_cpumask_str) == -1) - CPU_FILL(&ktr_cpumask); -} -SYSINIT(ktr_cpumask_initializer, SI_SUB_TUNABLES, SI_ORDER_ANY, - ktr_cpumask_initializer, NULL); - static int sysctl_debug_ktr_cpumask(SYSCTL_HANDLER_ARGS) { @@ -150,7 +134,7 @@ sysctl_debug_ktr_cpumask(SYSCTL_HANDLER_ARGS) return (error); } SYSCTL_PROC(_debug_ktr, OID_AUTO, cpumask, - CTLFLAG_RW | CTLFLAG_MPSAFE | CTLTYPE_STRING, NULL, 0, + CTLFLAG_RWTUN | CTLFLAG_MPSAFE | CTLTYPE_STRING, NULL, 0, sysctl_debug_ktr_cpumask, "S", "Bitmask of CPUs on which KTR logging is enabled"); diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c index b74d48ecffb8f..367610b34a3a5 100644 --- a/sys/kern/kern_ktrace.c +++ b/sys/kern/kern_ktrace.c @@ -133,8 +133,7 @@ static u_int ktr_requestpool = KTRACE_REQUEST_POOL; TUNABLE_INT("kern.ktrace.request_pool", &ktr_requestpool); static u_int ktr_geniosize = PAGE_SIZE; -TUNABLE_INT("kern.ktrace.genio_size", &ktr_geniosize); -SYSCTL_UINT(_kern_ktrace, OID_AUTO, genio_size, CTLFLAG_RW, &ktr_geniosize, +SYSCTL_UINT(_kern_ktrace, OID_AUTO, genio_size, CTLFLAG_RWTUN, &ktr_geniosize, 0, "Maximum size of genio event payload"); static int print_message = 1; diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c index e379f5f89f959..dbc0fb30974d8 100644 --- a/sys/kern/kern_linker.c +++ b/sys/kern/kern_linker.c @@ -66,9 +66,8 @@ __FBSDID("$FreeBSD$"); #ifdef KLD_DEBUG int kld_debug = 0; -SYSCTL_INT(_debug, OID_AUTO, kld_debug, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_debug, OID_AUTO, kld_debug, CTLFLAG_RWTUN, &kld_debug, 0, "Set various levels of KLD debug"); -TUNABLE_INT("debug.kld_debug", &kld_debug); #endif /* @@ -1643,7 +1642,7 @@ SYSINIT(preload, SI_SUB_KLD, SI_ORDER_MIDDLE, linker_preload, 0); static char linker_hintfile[] = "linker.hints"; static char linker_path[MAXPATHLEN] = "/boot/kernel;/boot/modules"; -SYSCTL_STRING(_kern, OID_AUTO, module_path, CTLFLAG_RW, linker_path, +SYSCTL_STRING(_kern, OID_AUTO, module_path, CTLFLAG_RWTUN, linker_path, sizeof(linker_path), "module load search path"); TUNABLE_STR("module_path", linker_path, sizeof(linker_path)); diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c index 658908c65634b..f16d4d5008199 100644 --- a/sys/kern/kern_malloc.c +++ b/sys/kern/kern_malloc.c @@ -191,7 +191,7 @@ static u_long vm_kmem_size_max; SYSCTL_ULONG(_vm, OID_AUTO, kmem_size_max, CTLFLAG_RDTUN, &vm_kmem_size_max, 0, "Maximum size of kernel memory"); -static u_int vm_kmem_size_scale; +static u_int vm_kmem_size_scale = VM_KMEM_SIZE_SCALE; SYSCTL_UINT(_vm, OID_AUTO, kmem_size_scale, CTLFLAG_RDTUN, &vm_kmem_size_scale, 0, "Scale factor for kernel memory size"); @@ -236,9 +236,8 @@ static SYSCTL_NODE(_debug, OID_AUTO, malloc, CTLFLAG_RD, 0, static int malloc_failure_rate; static int malloc_nowait_count; static int malloc_failure_count; -SYSCTL_INT(_debug_malloc, OID_AUTO, failure_rate, CTLFLAG_RW, +SYSCTL_INT(_debug_malloc, OID_AUTO, failure_rate, CTLFLAG_RWTUN, &malloc_failure_rate, 0, "Every (n) mallocs with M_NOWAIT will fail"); -TUNABLE_INT("debug.malloc.failure_rate", &malloc_failure_rate); SYSCTL_INT(_debug_malloc, OID_AUTO, failure_count, CTLFLAG_RD, &malloc_failure_count, 0, "Number of imposed M_NOWAIT malloc failures"); #endif @@ -280,7 +279,7 @@ tunable_set_numzones(void) numzones = MALLOC_DEBUG_MAXZONES; } SYSINIT(numzones, SI_SUB_TUNABLES, SI_ORDER_ANY, tunable_set_numzones, NULL); -SYSCTL_INT(_debug_malloc, OID_AUTO, numzones, CTLFLAG_RDTUN, +SYSCTL_INT(_debug_malloc, OID_AUTO, numzones, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &numzones, 0, "Number of malloc uma subzones"); /* @@ -693,8 +692,21 @@ CTASSERT(VM_KMEM_SIZE_SCALE >= 1); void kmeminit(void) { - u_long mem_size, tmp; + u_long mem_size; + u_long tmp; +#ifdef VM_KMEM_SIZE + if (vm_kmem_size == 0) + vm_kmem_size = VM_KMEM_SIZE; +#endif +#ifdef VM_KMEM_SIZE_MIN + if (vm_kmem_size_min == 0) + vm_kmem_size_min = VM_KMEM_SIZE_MIN; +#endif +#ifdef VM_KMEM_SIZE_MAX + if (vm_kmem_size_max == 0) + vm_kmem_size_max = VM_KMEM_SIZE_MAX; +#endif /* * Calculate the amount of kernel virtual address (KVA) space that is * preallocated to the kmem arena. In order to support a wide range @@ -713,38 +725,29 @@ kmeminit(void) */ mem_size = vm_cnt.v_page_count; - vm_kmem_size_scale = VM_KMEM_SIZE_SCALE; - TUNABLE_INT_FETCH("vm.kmem_size_scale", &vm_kmem_size_scale); if (vm_kmem_size_scale < 1) vm_kmem_size_scale = VM_KMEM_SIZE_SCALE; - vm_kmem_size = (mem_size / vm_kmem_size_scale) * PAGE_SIZE; - -#if defined(VM_KMEM_SIZE_MIN) - vm_kmem_size_min = VM_KMEM_SIZE_MIN; -#endif - TUNABLE_ULONG_FETCH("vm.kmem_size_min", &vm_kmem_size_min); - if (vm_kmem_size_min > 0 && vm_kmem_size < vm_kmem_size_min) - vm_kmem_size = vm_kmem_size_min; + /* + * Check if we should use defaults for the "vm_kmem_size" + * variable: + */ + if (vm_kmem_size == 0) { + vm_kmem_size = (mem_size / vm_kmem_size_scale) * PAGE_SIZE; -#if defined(VM_KMEM_SIZE_MAX) - vm_kmem_size_max = VM_KMEM_SIZE_MAX; -#endif - TUNABLE_ULONG_FETCH("vm.kmem_size_max", &vm_kmem_size_max); - if (vm_kmem_size_max > 0 && vm_kmem_size >= vm_kmem_size_max) - vm_kmem_size = vm_kmem_size_max; + if (vm_kmem_size_min > 0 && vm_kmem_size < vm_kmem_size_min) + vm_kmem_size = vm_kmem_size_min; + if (vm_kmem_size_max > 0 && vm_kmem_size >= vm_kmem_size_max) + vm_kmem_size = vm_kmem_size_max; + } /* - * Alternatively, the amount of KVA space that is preallocated to the + * The amount of KVA space that is preallocated to the * kmem arena can be set statically at compile-time or manually * through the kernel environment. However, it is still limited to * twice the physical memory size, which has been sufficient to handle * the most severe cases of external fragmentation in the kmem arena. */ -#if defined(VM_KMEM_SIZE) - vm_kmem_size = VM_KMEM_SIZE; -#endif - TUNABLE_ULONG_FETCH("vm.kmem_size", &vm_kmem_size); if (vm_kmem_size / 2 / PAGE_SIZE > mem_size) vm_kmem_size = 2 * mem_size * PAGE_SIZE; @@ -811,7 +814,7 @@ mallocinit(void *dummy) } } -SYSINIT(kmem, SI_SUB_KMEM, SI_ORDER_FIRST, mallocinit, NULL); +SYSINIT(kmem, SI_SUB_KMEM, SI_ORDER_SECOND, mallocinit, NULL); void malloc_init(void *data) diff --git a/sys/kern/kern_mbuf.c b/sys/kern/kern_mbuf.c index 119e4b8325253..63d5d5523368b 100644 --- a/sys/kern/kern_mbuf.c +++ b/sys/kern/kern_mbuf.c @@ -105,7 +105,7 @@ int nmbjumbo16; /* limits number of 16k jumbo clusters */ static quad_t maxmbufmem; /* overall real memory limit for all mbufs */ -SYSCTL_QUAD(_kern_ipc, OID_AUTO, maxmbufmem, CTLFLAG_RDTUN, &maxmbufmem, 0, +SYSCTL_QUAD(_kern_ipc, OID_AUTO, maxmbufmem, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &maxmbufmem, 0, "Maximum real memory allocatable to various mbuf types"); /* diff --git a/sys/kern/kern_mib.c b/sys/kern/kern_mib.c index 213482b42c913..9d3153b4a5bbf 100644 --- a/sys/kern/kern_mib.c +++ b/sys/kern/kern_mib.c @@ -55,35 +55,35 @@ __FBSDID("$FreeBSD$"); #include #include -SYSCTL_NODE(, 0, sysctl, CTLFLAG_RW, 0, +SYSCTL_ROOT_NODE(0, sysctl, CTLFLAG_RW, 0, "Sysctl internal magic"); -SYSCTL_NODE(, CTL_KERN, kern, CTLFLAG_RW|CTLFLAG_CAPRD, 0, +SYSCTL_ROOT_NODE(CTL_KERN, kern, CTLFLAG_RW|CTLFLAG_CAPRD, 0, "High kernel, proc, limits &c"); -SYSCTL_NODE(, CTL_VM, vm, CTLFLAG_RW, 0, +SYSCTL_ROOT_NODE(CTL_VM, vm, CTLFLAG_RW, 0, "Virtual memory"); -SYSCTL_NODE(, CTL_VFS, vfs, CTLFLAG_RW, 0, +SYSCTL_ROOT_NODE(CTL_VFS, vfs, CTLFLAG_RW, 0, "File system"); -SYSCTL_NODE(, CTL_NET, net, CTLFLAG_RW, 0, +SYSCTL_ROOT_NODE(CTL_NET, net, CTLFLAG_RW, 0, "Network, (see socket.h)"); -SYSCTL_NODE(, CTL_DEBUG, debug, CTLFLAG_RW, 0, +SYSCTL_ROOT_NODE(CTL_DEBUG, debug, CTLFLAG_RW, 0, "Debugging"); SYSCTL_NODE(_debug, OID_AUTO, sizeof, CTLFLAG_RW, 0, "Sizeof various things"); -SYSCTL_NODE(, CTL_HW, hw, CTLFLAG_RW, 0, +SYSCTL_ROOT_NODE(CTL_HW, hw, CTLFLAG_RW, 0, "hardware"); -SYSCTL_NODE(, CTL_MACHDEP, machdep, CTLFLAG_RW, 0, +SYSCTL_ROOT_NODE(CTL_MACHDEP, machdep, CTLFLAG_RW, 0, "machine dependent"); -SYSCTL_NODE(, CTL_USER, user, CTLFLAG_RW, 0, +SYSCTL_ROOT_NODE(CTL_USER, user, CTLFLAG_RW, 0, "user-level"); -SYSCTL_NODE(, CTL_P1003_1B, p1003_1b, CTLFLAG_RW, 0, +SYSCTL_ROOT_NODE(CTL_P1003_1B, p1003_1b, CTLFLAG_RW, 0, "p1003_1b, (see p1003_1b.h)"); -SYSCTL_NODE(, OID_AUTO, compat, CTLFLAG_RW, 0, +SYSCTL_ROOT_NODE(OID_AUTO, compat, CTLFLAG_RW, 0, "Compatibility code"); -SYSCTL_NODE(, OID_AUTO, security, CTLFLAG_RW, 0, +SYSCTL_ROOT_NODE(OID_AUTO, security, CTLFLAG_RW, 0, "Security"); #ifdef REGRESSION -SYSCTL_NODE(, OID_AUTO, regression, CTLFLAG_RW, 0, +SYSCTL_ROOT_NODE(OID_AUTO, regression, CTLFLAG_RW, 0, "Regression test MIB"); #endif @@ -112,13 +112,13 @@ SYSCTL_STRING(_kern, KERN_OSTYPE, ostype, CTLFLAG_RD|CTLFLAG_MPSAFE| SYSCTL_INT(_kern, KERN_OSRELDATE, osreldate, CTLFLAG_RD|CTLFLAG_CAPRD, &osreldate, 0, "Kernel release date"); -SYSCTL_INT(_kern, KERN_MAXPROC, maxproc, CTLFLAG_RDTUN, +SYSCTL_INT(_kern, KERN_MAXPROC, maxproc, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &maxproc, 0, "Maximum number of processes"); SYSCTL_INT(_kern, KERN_MAXPROCPERUID, maxprocperuid, CTLFLAG_RW, &maxprocperuid, 0, "Maximum processes allowed per userid"); -SYSCTL_INT(_kern, OID_AUTO, maxusers, CTLFLAG_RDTUN, +SYSCTL_INT(_kern, OID_AUTO, maxusers, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &maxusers, 0, "Hint for kernel tuning"); SYSCTL_INT(_kern, KERN_ARGMAX, argmax, CTLFLAG_RD|CTLFLAG_CAPRD, @@ -127,8 +127,8 @@ SYSCTL_INT(_kern, KERN_ARGMAX, argmax, CTLFLAG_RD|CTLFLAG_CAPRD, SYSCTL_INT(_kern, KERN_POSIX1, posix1version, CTLFLAG_RD|CTLFLAG_CAPRD, 0, _POSIX_VERSION, "Version of POSIX attempting to comply to"); -SYSCTL_INT(_kern, KERN_NGROUPS, ngroups, CTLFLAG_RDTUN|CTLFLAG_CAPRD, - &ngroups_max, 0, +SYSCTL_INT(_kern, KERN_NGROUPS, ngroups, CTLFLAG_RDTUN | + CTLFLAG_NOFETCH | CTLFLAG_CAPRD, &ngroups_max, 0, "Maximum number of supplemental groups a user can belong to"); SYSCTL_INT(_kern, KERN_JOB_CONTROL, job_control, CTLFLAG_RD|CTLFLAG_CAPRD, @@ -526,9 +526,9 @@ sysctl_kern_pid_max(SYSCTL_HANDLER_ARGS) sx_xunlock(&proctree_lock); return (error); } -SYSCTL_PROC(_kern, OID_AUTO, pid_max, CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_TUN | - CTLFLAG_MPSAFE, 0, 0, sysctl_kern_pid_max, "I", - "Maximum allowed pid"); +SYSCTL_PROC(_kern, OID_AUTO, pid_max, CTLTYPE_INT | + CTLFLAG_RWTUN | CTLFLAG_NOFETCH | CTLFLAG_MPSAFE, + 0, 0, sysctl_kern_pid_max, "I", "Maximum allowed pid"); #include #include diff --git a/sys/kern/kern_ntptime.c b/sys/kern/kern_ntptime.c index 7c95575293d4b..638cd53332aa6 100644 --- a/sys/kern/kern_ntptime.c +++ b/sys/kern/kern_ntptime.c @@ -1025,18 +1025,20 @@ sysctl_resettodr_period(SYSCTL_HANDLER_ARGS) error = sysctl_handle_int(oidp, oidp->oid_arg1, oidp->oid_arg2, req); if (error || !req->newptr) return (error); + if (cold) + goto done; if (resettodr_period == 0) callout_stop(&resettodr_callout); else callout_reset(&resettodr_callout, resettodr_period * hz, periodic_resettodr, NULL); +done: return (0); } -SYSCTL_PROC(_machdep, OID_AUTO, rtc_save_period, CTLTYPE_INT|CTLFLAG_RW, +SYSCTL_PROC(_machdep, OID_AUTO, rtc_save_period, CTLTYPE_INT|CTLFLAG_RWTUN, &resettodr_period, 1800, sysctl_resettodr_period, "I", "Save system time to RTC with this period (in seconds)"); -TUNABLE_INT("machdep.rtc_save_period", &resettodr_period); static void start_periodic_resettodr(void *arg __unused) diff --git a/sys/kern/kern_osd.c b/sys/kern/kern_osd.c index 184c4f00ba08f..cc9bed1fab3dd 100644 --- a/sys/kern/kern_osd.c +++ b/sys/kern/kern_osd.c @@ -47,8 +47,7 @@ __FBSDID("$FreeBSD$"); static MALLOC_DEFINE(M_OSD, "osd", "Object Specific Data"); static int osd_debug = 0; -TUNABLE_INT("debug.osd", &osd_debug); -SYSCTL_INT(_debug, OID_AUTO, osd, CTLFLAG_RW, &osd_debug, 0, "OSD debug level"); +SYSCTL_INT(_debug, OID_AUTO, osd, CTLFLAG_RWTUN, &osd_debug, 0, "OSD debug level"); #define OSD_DEBUG(...) do { \ if (osd_debug) { \ diff --git a/sys/kern/kern_pmc.c b/sys/kern/kern_pmc.c index 2b50be0343fca..09dc6edbcffeb 100644 --- a/sys/kern/kern_pmc.c +++ b/sys/kern/kern_pmc.c @@ -96,8 +96,7 @@ struct trapframe pmc_tf[MAXCPU]; SYSCTL_NODE(_kern, OID_AUTO, hwpmc, CTLFLAG_RW, 0, "HWPMC parameters"); static int pmc_softevents = 16; -TUNABLE_INT(PMC_SYSCTL_NAME_PREFIX "softevents", &pmc_softevents); -SYSCTL_INT(_kern_hwpmc, OID_AUTO, softevents, CTLFLAG_TUN|CTLFLAG_RD, +SYSCTL_INT(_kern_hwpmc, OID_AUTO, softevents, CTLFLAG_RDTUN, &pmc_softevents, 0, "maximum number of soft events"); struct mtx pmc_softs_mtx; diff --git a/sys/kern/kern_priv.c b/sys/kern/kern_priv.c index 2daa5c29fe420..4b9a4443de3ac 100644 --- a/sys/kern/kern_priv.c +++ b/sys/kern/kern_priv.c @@ -53,14 +53,12 @@ __FBSDID("$FreeBSD$"); * the consequences. */ static int suser_enabled = 1; -SYSCTL_INT(_security_bsd, OID_AUTO, suser_enabled, CTLFLAG_RW, +SYSCTL_INT(_security_bsd, OID_AUTO, suser_enabled, CTLFLAG_RWTUN, &suser_enabled, 0, "processes with uid 0 have privilege"); -TUNABLE_INT("security.bsd.suser_enabled", &suser_enabled); static int unprivileged_mlock = 1; -SYSCTL_INT(_security_bsd, OID_AUTO, unprivileged_mlock, CTLFLAG_RW|CTLFLAG_TUN, +SYSCTL_INT(_security_bsd, OID_AUTO, unprivileged_mlock, CTLFLAG_RWTUN, &unprivileged_mlock, 0, "Allow non-root users to call mlock(2)"); -TUNABLE_INT("security.bsd.unprivileged_mlock", &unprivileged_mlock); SDT_PROVIDER_DEFINE(priv); SDT_PROBE_DEFINE1(priv, kernel, priv_check, priv__ok, "int"); diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c index 4700e68e53c32..dba6a43150484 100644 --- a/sys/kern/kern_shutdown.c +++ b/sys/kern/kern_shutdown.c @@ -90,10 +90,9 @@ __FBSDID("$FreeBSD$"); #define PANIC_REBOOT_WAIT_TIME 15 /* default to 15 seconds */ #endif static int panic_reboot_wait_time = PANIC_REBOOT_WAIT_TIME; -SYSCTL_INT(_kern, OID_AUTO, panic_reboot_wait_time, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_kern, OID_AUTO, panic_reboot_wait_time, CTLFLAG_RWTUN, &panic_reboot_wait_time, 0, "Seconds to wait before rebooting after a panic"); -TUNABLE_INT("kern.panic_reboot_wait_time", &panic_reboot_wait_time); /* * Note that stdarg.h and the ANSI style va_start macro is used for both @@ -108,9 +107,8 @@ int debugger_on_panic = 0; int debugger_on_panic = 1; #endif SYSCTL_INT(_debug, OID_AUTO, debugger_on_panic, - CTLFLAG_RW | CTLFLAG_SECURE | CTLFLAG_TUN, + CTLFLAG_RWTUN | CTLFLAG_SECURE, &debugger_on_panic, 0, "Run debugger on kernel panic"); -TUNABLE_INT("debug.debugger_on_panic", &debugger_on_panic); #ifdef KDB_TRACE static int trace_on_panic = 1; @@ -118,15 +116,13 @@ static int trace_on_panic = 1; static int trace_on_panic = 0; #endif SYSCTL_INT(_debug, OID_AUTO, trace_on_panic, - CTLFLAG_RW | CTLFLAG_SECURE | CTLFLAG_TUN, + CTLFLAG_RWTUN | CTLFLAG_SECURE, &trace_on_panic, 0, "Print stack trace on kernel panic"); -TUNABLE_INT("debug.trace_on_panic", &trace_on_panic); #endif /* KDB */ static int sync_on_panic = 0; -SYSCTL_INT(_kern, OID_AUTO, sync_on_panic, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_kern, OID_AUTO, sync_on_panic, CTLFLAG_RWTUN, &sync_on_panic, 0, "Do a sync before rebooting from a panic"); -TUNABLE_INT("kern.sync_on_panic", &sync_on_panic); static SYSCTL_NODE(_kern, OID_AUTO, shutdown, CTLFLAG_RW, 0, "Shutdown environment"); @@ -559,43 +555,35 @@ static int kassert_warnings = 0; SYSCTL_NODE(_debug, OID_AUTO, kassert, CTLFLAG_RW, NULL, "kassert options"); -SYSCTL_INT(_debug_kassert, OID_AUTO, warn_only, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_debug_kassert, OID_AUTO, warn_only, CTLFLAG_RWTUN, &kassert_warn_only, 0, "KASSERT triggers a panic (1) or just a warning (0)"); -TUNABLE_INT("debug.kassert.warn_only", &kassert_warn_only); #ifdef KDB -SYSCTL_INT(_debug_kassert, OID_AUTO, do_kdb, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_debug_kassert, OID_AUTO, do_kdb, CTLFLAG_RWTUN, &kassert_do_kdb, 0, "KASSERT will enter the debugger"); -TUNABLE_INT("debug.kassert.do_kdb", &kassert_do_kdb); #endif #ifdef KTR -SYSCTL_UINT(_debug_kassert, OID_AUTO, do_ktr, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_UINT(_debug_kassert, OID_AUTO, do_ktr, CTLFLAG_RWTUN, &kassert_do_ktr, 0, "KASSERT does a KTR, set this to the KTRMASK you want"); -TUNABLE_INT("debug.kassert.do_ktr", &kassert_do_ktr); #endif -SYSCTL_INT(_debug_kassert, OID_AUTO, do_log, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_debug_kassert, OID_AUTO, do_log, CTLFLAG_RWTUN, &kassert_do_log, 0, "KASSERT triggers a panic (1) or just a warning (0)"); -TUNABLE_INT("debug.kassert.do_log", &kassert_do_log); -SYSCTL_INT(_debug_kassert, OID_AUTO, warnings, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_debug_kassert, OID_AUTO, warnings, CTLFLAG_RWTUN, &kassert_warnings, 0, "number of KASSERTs that have been triggered"); -TUNABLE_INT("debug.kassert.warnings", &kassert_warnings); -SYSCTL_INT(_debug_kassert, OID_AUTO, log_panic_at, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_debug_kassert, OID_AUTO, log_panic_at, CTLFLAG_RWTUN, &kassert_log_panic_at, 0, "max number of KASSERTS before we will panic"); -TUNABLE_INT("debug.kassert.log_panic_at", &kassert_log_panic_at); -SYSCTL_INT(_debug_kassert, OID_AUTO, log_pps_limit, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_debug_kassert, OID_AUTO, log_pps_limit, CTLFLAG_RWTUN, &kassert_log_pps_limit, 0, "limit number of log messages per second"); -TUNABLE_INT("debug.kassert.log_pps_limit", &kassert_log_pps_limit); -SYSCTL_INT(_debug_kassert, OID_AUTO, log_mute_at, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_debug_kassert, OID_AUTO, log_mute_at, CTLFLAG_RWTUN, &kassert_log_mute_at, 0, "max number of KASSERTS to log"); -TUNABLE_INT("debug.kassert.log_mute_at", &kassert_log_mute_at); static int kassert_sysctl_kassert(SYSCTL_HANDLER_ARGS); diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index b405779905f66..67845a25d1b56 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -136,8 +136,7 @@ SYSCTL_INT(_kern_sigqueue, OID_AUTO, max_pending_per_proc, CTLFLAG_RW, &max_pending_per_proc, 0, "Max pending signals per proc"); static int preallocate_siginfo = 1024; -TUNABLE_INT("kern.sigqueue.preallocate", &preallocate_siginfo); -SYSCTL_INT(_kern_sigqueue, OID_AUTO, preallocate, CTLFLAG_RD, +SYSCTL_INT(_kern_sigqueue, OID_AUTO, preallocate, CTLFLAG_RDTUN, &preallocate_siginfo, 0, "Preallocated signal memory size"); static int signal_overflow = 0; @@ -163,13 +162,11 @@ SYSINIT(signal, SI_SUB_P1003_1B, SI_ORDER_FIRST+3, sigqueue_start, NULL); (cr1)->cr_uid == (cr2)->cr_uid) static int sugid_coredump; -TUNABLE_INT("kern.sugid_coredump", &sugid_coredump); -SYSCTL_INT(_kern, OID_AUTO, sugid_coredump, CTLFLAG_RW, +SYSCTL_INT(_kern, OID_AUTO, sugid_coredump, CTLFLAG_RWTUN, &sugid_coredump, 0, "Allow setuid and setgid processes to dump core"); static int capmode_coredump; -TUNABLE_INT("kern.capmode_coredump", &capmode_coredump); -SYSCTL_INT(_kern, OID_AUTO, capmode_coredump, CTLFLAG_RW, +SYSCTL_INT(_kern, OID_AUTO, capmode_coredump, CTLFLAG_RWTUN, &capmode_coredump, 0, "Allow processes in capability mode to dump core"); static int do_coredump = 1; @@ -3052,8 +3049,7 @@ SYSCTL_INT(_kern, OID_AUTO, compress_user_cores_gzlevel, CTLFLAG_RW, #endif static char corefilename[MAXPATHLEN] = {"%N.core"}; -TUNABLE_STR("kern.corefile", corefilename, sizeof(corefilename)); -SYSCTL_STRING(_kern, OID_AUTO, corefile, CTLFLAG_RW, corefilename, +SYSCTL_STRING(_kern, OID_AUTO, corefile, CTLFLAG_RWTUN, corefilename, sizeof(corefilename), "Process corefile name format string"); /* diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index fec4aeabe1f56..cb5a266e4e218 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -98,10 +98,13 @@ static struct sx sysctlmemlock; static int sysctl_root(SYSCTL_HANDLER_ARGS); -struct sysctl_oid_list sysctl__children; /* root list */ +/* Root list */ +struct sysctl_oid_list sysctl__children = SLIST_HEAD_INITIALIZER(&sysctl__children); static int sysctl_remove_oid_locked(struct sysctl_oid *oidp, int del, int recurse); +static int sysctl_old_kernel(struct sysctl_req *, const void *, size_t); +static int sysctl_new_kernel(struct sysctl_req *, void *, size_t); static struct sysctl_oid * sysctl_find_oidname(const char *name, struct sysctl_oid_list *list) @@ -136,6 +139,118 @@ sysctl_unlock(void) SYSCTL_XUNLOCK(); } +static int +sysctl_root_handler_locked(struct sysctl_oid *oid, void *arg1, intptr_t arg2, + struct sysctl_req *req) +{ + int error; + + oid->oid_running++; + SYSCTL_XUNLOCK(); + + if (!(oid->oid_kind & CTLFLAG_MPSAFE)) + mtx_lock(&Giant); + error = oid->oid_handler(oid, arg1, arg2, req); + if (!(oid->oid_kind & CTLFLAG_MPSAFE)) + mtx_unlock(&Giant); + + SYSCTL_XLOCK(); + oid->oid_running--; + if (oid->oid_running == 0 && (oid->oid_kind & CTLFLAG_DYING) != 0) + wakeup(&oid->oid_running); + + return (error); +} + +static void +sysctl_load_tunable_by_oid_locked(struct sysctl_oid *oidp) +{ + struct sysctl_req req; + struct sysctl_oid *curr; + char *penv; + char path[64]; + ssize_t rem = sizeof(path); + ssize_t len; + int val_int; + long val_long; + int64_t val_64; + int error; + + path[--rem] = 0; + + for (curr = oidp; curr != NULL; curr = SYSCTL_PARENT(curr)) { + len = strlen(curr->oid_name); + rem -= len; + if (curr != oidp) + rem -= 1; + if (rem < 0) { + printf("OID path exceeds %d bytes\n", (int)sizeof(path)); + return; + } + memcpy(path + rem, curr->oid_name, len); + if (curr != oidp) + path[rem + len] = '.'; + } + + penv = getenv(path + rem); + if (penv == NULL) + return; + + memset(&req, 0, sizeof(req)); + + req.td = curthread; + req.oldfunc = sysctl_old_kernel; + req.newfunc = sysctl_new_kernel; + req.lock = REQ_UNWIRED; + + switch (oidp->oid_kind & CTLTYPE) { + case CTLTYPE_INT: + val_int = strtoq(penv, NULL, 0); + req.newlen = sizeof(val_int); + req.newptr = &val_int; + break; + case CTLTYPE_UINT: + val_int = strtouq(penv, NULL, 0); + req.newlen = sizeof(val_int); + req.newptr = &val_int; + break; + case CTLTYPE_LONG: + val_long = strtoq(penv, NULL, 0); + req.newlen = sizeof(val_long); + req.newptr = &val_long; + break; + case CTLTYPE_ULONG: + val_long = strtouq(penv, NULL, 0); + req.newlen = sizeof(val_long); + req.newptr = &val_long; + break; + case CTLTYPE_S64: + val_64 = strtoq(penv, NULL, 0); + req.newlen = sizeof(val_64); + req.newptr = &val_64; + break; + case CTLTYPE_U64: + val_64 = strtouq(penv, NULL, 0); + req.newlen = sizeof(val_64); + req.newptr = &val_64; + break; + case CTLTYPE_STRING: + req.newlen = strlen(penv); + req.newptr = penv; + break; + default: + freeenv(penv); + return; + } + error = sysctl_root_handler_locked(oidp, oidp->oid_arg1, + oidp->oid_arg2, &req); + if (error != 0) { + printf("Setting sysctl '%s' to '%s' failed: %d\n", + path, penv, error); + } + freeenv(penv); +} + void sysctl_register_oid(struct sysctl_oid *oidp) { @@ -192,6 +307,15 @@ sysctl_register_oid(struct sysctl_oid *oidp) SLIST_INSERT_AFTER(q, oidp, oid_link); else SLIST_INSERT_HEAD(parent, oidp, oid_link); + + if ((oidp->oid_kind & CTLTYPE) != CTLTYPE_NODE && +#ifdef VIMAGE + (oidp->oid_kind & CTLFLAG_VNET) == 0 && +#endif + (oidp->oid_kind & CTLFLAG_TUN) != 0 && + (oidp->oid_kind & CTLFLAG_NOFETCH) == 0) { + sysctl_load_tunable_by_oid_locked(oidp); + } } void @@ -423,8 +547,6 @@ sysctl_remove_oid_locked(struct sysctl_oid *oidp, int del, int recurse) if (error) return (error); } - if (del) - free(SYSCTL_CHILDREN(oidp), M_SYSCTLOID); } } if (oidp->oid_refcnt > 1 ) { @@ -489,24 +611,16 @@ sysctl_add_oid(struct sysctl_ctx_list *clist, struct sysctl_oid_list *parent, } oidp = malloc(sizeof(struct sysctl_oid), M_SYSCTLOID, M_WAITOK|M_ZERO); oidp->oid_parent = parent; - SLIST_NEXT(oidp, oid_link) = NULL; + SLIST_INIT(&oidp->oid_children); oidp->oid_number = number; oidp->oid_refcnt = 1; oidp->oid_name = strdup(name, M_SYSCTLOID); oidp->oid_handler = handler; oidp->oid_kind = CTLFLAG_DYN | kind; - if ((kind & CTLTYPE) == CTLTYPE_NODE) { - /* Allocate space for children */ - SYSCTL_CHILDREN_SET(oidp, malloc(sizeof(struct sysctl_oid_list), - M_SYSCTLOID, M_WAITOK)); - SLIST_INIT(SYSCTL_CHILDREN(oidp)); - oidp->oid_arg2 = arg2; - } else { - oidp->oid_arg1 = arg1; - oidp->oid_arg2 = arg2; - } + oidp->oid_arg1 = arg1; + oidp->oid_arg2 = arg2; oidp->oid_fmt = fmt; - if (descr) + if (descr != NULL) oidp->oid_descr = strdup(descr, M_SYSCTLOID); /* Update the context, if used */ if (clist != NULL) @@ -577,7 +691,7 @@ sysctl_register_all(void *arg) sysctl_register_oid(*oidp); SYSCTL_XUNLOCK(); } -SYSINIT(sysctl, SI_SUB_KMEM, SI_ORDER_ANY, sysctl_register_all, 0); +SYSINIT(sysctl, SI_SUB_KMEM, SI_ORDER_FIRST, sysctl_register_all, 0); /* * "Staff-functions" @@ -625,7 +739,7 @@ sysctl_sysctl_debug_dump_node(struct sysctl_oid_list *l, int i) printf(" Node\n"); if (!oidp->oid_handler) { sysctl_sysctl_debug_dump_node( - oidp->oid_arg1, i+2); + SYSCTL_CHILDREN(oidp), i + 2); } break; case CTLTYPE_INT: printf(" Int\n"); break; @@ -1093,26 +1207,28 @@ sysctl_handle_64(SYSCTL_HANDLER_ARGS) int sysctl_handle_string(SYSCTL_HANDLER_ARGS) { - int error=0; - char *tmparg; size_t outlen; + int error = 0; - /* - * Attempt to get a coherent snapshot by copying to a - * temporary kernel buffer. - */ -retry: - outlen = strlen((char *)arg1)+1; - tmparg = malloc(outlen, M_SYSCTLTMP, M_WAITOK); + /* check for zero-length buffer */ + if (arg2 == 0) + return (ENOMEM); - if (strlcpy(tmparg, (char *)arg1, outlen) >= outlen) { - free(tmparg, M_SYSCTLTMP); - goto retry; - } + if (req->oldptr != NULL) { + char *tmparg; + + /* try to make a coherent snapshot of the string */ + tmparg = malloc(arg2, M_SYSCTLTMP, M_WAITOK); + memcpy(tmparg, arg1, arg2); - error = SYSCTL_OUT(req, tmparg, outlen); - free(tmparg, M_SYSCTLTMP); + outlen = strnlen(tmparg, arg2 - 1) + 1; + error = SYSCTL_OUT(req, tmparg, outlen); + free(tmparg, M_SYSCTLTMP); + } else { + outlen = strnlen((char *)arg1, arg2 - 1) + 1; + error = SYSCTL_OUT(req, NULL, outlen); + } if (error || !req->newptr) return (error); @@ -1123,7 +1239,6 @@ retry: error = SYSCTL_IN(req, arg1, arg2); ((char *)arg1)[arg2] = '\0'; } - return (error); } @@ -1489,24 +1604,14 @@ sysctl_root(SYSCTL_HANDLER_ARGS) if (error != 0) return (error); #endif - oid->oid_running++; - SYSCTL_XUNLOCK(); #ifdef VIMAGE if ((oid->oid_kind & CTLFLAG_VNET) && arg1 != NULL) arg1 = (void *)(curvnet->vnet_data_base + (uintptr_t)arg1); #endif - if (!(oid->oid_kind & CTLFLAG_MPSAFE)) - mtx_lock(&Giant); - error = oid->oid_handler(oid, arg1, arg2, req); - if (!(oid->oid_kind & CTLFLAG_MPSAFE)) - mtx_unlock(&Giant); + error = sysctl_root_handler_locked(oid, arg1, arg2, req); KFAIL_POINT_ERROR(_debug_fail_point, sysctl_running, error); - SYSCTL_XLOCK(); - oid->oid_running--; - if (oid->oid_running == 0 && (oid->oid_kind & CTLFLAG_DYING) != 0) - wakeup(&oid->oid_running); return (error); } diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index 9fe7ebe6b3610..78ceff2ad5be5 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -128,10 +128,9 @@ struct bintime tc_tick_bt; sbintime_t tc_tick_sbt; int tc_precexp; int tc_timepercentage = TC_DEFAULTPERC; -TUNABLE_INT("kern.timecounter.alloweddeviation", &tc_timepercentage); static int sysctl_kern_timecounter_adjprecision(SYSCTL_HANDLER_ARGS); SYSCTL_PROC(_kern_timecounter, OID_AUTO, alloweddeviation, - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 0, + CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, 0, 0, sysctl_kern_timecounter_adjprecision, "I", "Allowed time interval deviation in percents"); @@ -1794,7 +1793,10 @@ sysctl_kern_timecounter_adjprecision(SYSCTL_HANDLER_ARGS) if (error != 0 || req->newptr == NULL) return (error); tc_timepercentage = val; + if (cold) + goto done; tc_adjprecision(); +done: return (0); } diff --git a/sys/kern/kern_timeout.c b/sys/kern/kern_timeout.c index eee54745aac70..905e24a13819b 100644 --- a/sys/kern/kern_timeout.c +++ b/sys/kern/kern_timeout.c @@ -101,15 +101,15 @@ SYSCTL_INT(_debug, OID_AUTO, to_avg_mpcalls_dir, CTLFLAG_RD, &avg_mpcalls_dir, #endif static int ncallout; -SYSCTL_INT(_kern, OID_AUTO, ncallout, CTLFLAG_RDTUN, &ncallout, 0, +SYSCTL_INT(_kern, OID_AUTO, ncallout, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &ncallout, 0, "Number of entries in callwheel and size of timeout() preallocation"); static int pin_default_swi = 0; static int pin_pcpu_swi = 0; -SYSCTL_INT(_kern, OID_AUTO, pin_default_swi, CTLFLAG_RDTUN, &pin_default_swi, +SYSCTL_INT(_kern, OID_AUTO, pin_default_swi, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &pin_default_swi, 0, "Pin the default (non-per-cpu) swi (shared with PCPU 0 swi)"); -SYSCTL_INT(_kern, OID_AUTO, pin_pcpu_swi, CTLFLAG_RDTUN, &pin_pcpu_swi, +SYSCTL_INT(_kern, OID_AUTO, pin_pcpu_swi, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &pin_pcpu_swi, 0, "Pin the per-CPU swis (except PCPU 0, which is also default"); /* diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index 53b10ec1fa205..eb54445c4c037 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -63,7 +63,7 @@ __FBSDID("$FreeBSD$"); #include SYSCTL_NODE(_hw, OID_AUTO, bus, CTLFLAG_RW, NULL, NULL); -SYSCTL_NODE(, OID_AUTO, dev, CTLFLAG_RW, NULL, NULL); +SYSCTL_ROOT_NODE(OID_AUTO, dev, CTLFLAG_RW, NULL, NULL); /* * Used to attach drivers to devclasses. @@ -149,9 +149,8 @@ static MALLOC_DEFINE(M_BUS_SC, "bus-sc", "Bus data structures, softc"); #ifdef BUS_DEBUG static int bus_debug = 1; -TUNABLE_INT("bus.debug", &bus_debug); -SYSCTL_INT(_debug, OID_AUTO, bus_debug, CTLFLAG_RW, &bus_debug, 0, - "Debug bus code"); +SYSCTL_INT(_debug, OID_AUTO, bus_debug, CTLFLAG_RWTUN, &bus_debug, 0, + "Bus debug level"); #define PDEBUG(a) if (bus_debug) {printf("%s:%d: ", __func__, __LINE__), printf a; printf("\n");} #define DEVICENAME(d) ((d)? device_get_name(d): "no device") @@ -357,16 +356,14 @@ device_sysctl_fini(device_t dev) /* Deprecated way to adjust queue length */ static int sysctl_devctl_disable(SYSCTL_HANDLER_ARGS); -/* XXX Need to support old-style tunable hw.bus.devctl_disable" */ -SYSCTL_PROC(_hw_bus, OID_AUTO, devctl_disable, CTLTYPE_INT | CTLFLAG_RW | +SYSCTL_PROC(_hw_bus, OID_AUTO, devctl_disable, CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, NULL, 0, sysctl_devctl_disable, "I", "devctl disable -- deprecated"); #define DEVCTL_DEFAULT_QUEUE_LEN 1000 static int sysctl_devctl_queue(SYSCTL_HANDLER_ARGS); static int devctl_queue_length = DEVCTL_DEFAULT_QUEUE_LEN; -TUNABLE_INT("hw.bus.devctl_queue", &devctl_queue_length); -SYSCTL_PROC(_hw_bus, OID_AUTO, devctl_queue, CTLTYPE_INT | CTLFLAG_RW | +SYSCTL_PROC(_hw_bus, OID_AUTO, devctl_queue, CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, NULL, 0, sysctl_devctl_queue, "I", "devctl queue length"); static d_open_t devopen; @@ -791,11 +788,12 @@ sysctl_devctl_disable(SYSCTL_HANDLER_ARGS) struct dev_event_info *n1; int dis, error; - dis = devctl_queue_length == 0; + dis = (devctl_queue_length == 0); error = sysctl_handle_int(oidp, &dis, 0, req); if (error || !req->newptr) return (error); - mtx_lock(&devsoftc.mtx); + if (mtx_initialized(&devsoftc.mtx)) + mtx_lock(&devsoftc.mtx); if (dis) { while (!TAILQ_EMPTY(&devsoftc.devq)) { n1 = TAILQ_FIRST(&devsoftc.devq); @@ -808,7 +806,8 @@ sysctl_devctl_disable(SYSCTL_HANDLER_ARGS) } else { devctl_queue_length = DEVCTL_DEFAULT_QUEUE_LEN; } - mtx_unlock(&devsoftc.mtx); + if (mtx_initialized(&devsoftc.mtx)) + mtx_unlock(&devsoftc.mtx); return (0); } @@ -824,7 +823,8 @@ sysctl_devctl_queue(SYSCTL_HANDLER_ARGS) return (error); if (q < 0) return (EINVAL); - mtx_lock(&devsoftc.mtx); + if (mtx_initialized(&devsoftc.mtx)) + mtx_lock(&devsoftc.mtx); devctl_queue_length = q; while (devsoftc.queued > devctl_queue_length) { n1 = TAILQ_FIRST(&devsoftc.devq); @@ -833,7 +833,8 @@ sysctl_devctl_queue(SYSCTL_HANDLER_ARGS) free(n1, M_BUS); devsoftc.queued--; } - mtx_unlock(&devsoftc.mtx); + if (mtx_initialized(&devsoftc.mtx)) + mtx_unlock(&devsoftc.mtx); return (0); } diff --git a/sys/kern/subr_kdb.c b/sys/kern/subr_kdb.c index a7ed944a61fbc..c26d271663f60 100644 --- a/sys/kern/subr_kdb.c +++ b/sys/kern/subr_kdb.c @@ -108,14 +108,12 @@ SYSCTL_PROC(_debug_kdb, OID_AUTO, trap_code, kdb_sysctl_trap_code, "I", "set to cause a page fault via code access"); SYSCTL_INT(_debug_kdb, OID_AUTO, break_to_debugger, - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_TUN | CTLFLAG_SECURE, + CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_SECURE, &kdb_break_to_debugger, 0, "Enable break to debugger"); -TUNABLE_INT("debug.kdb.break_to_debugger", &kdb_break_to_debugger); SYSCTL_INT(_debug_kdb, OID_AUTO, alt_break_to_debugger, - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_TUN | CTLFLAG_SECURE, + CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_SECURE, &kdb_alt_break_to_debugger, 0, "Enable alternative break to debugger"); -TUNABLE_INT("debug.kdb.alt_break_to_debugger", &kdb_alt_break_to_debugger); /* * Flag to indicate to debuggers why the debugger was entered. diff --git a/sys/kern/subr_msgbuf.c b/sys/kern/subr_msgbuf.c index ecdbe722ddc64..fa23c91f658f1 100644 --- a/sys/kern/subr_msgbuf.c +++ b/sys/kern/subr_msgbuf.c @@ -53,9 +53,8 @@ static u_int msgbuf_cksum(struct msgbuf *mbp); * or other actions occured. */ static int msgbuf_show_timestamp = 0; -SYSCTL_INT(_kern, OID_AUTO, msgbuf_show_timestamp, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_kern, OID_AUTO, msgbuf_show_timestamp, CTLFLAG_RWTUN, &msgbuf_show_timestamp, 0, "Show timestamp in msgbuf"); -TUNABLE_INT("kern.msgbuf_show_timestamp", &msgbuf_show_timestamp); /* * Initialize a message buffer of the specified size at the specified diff --git a/sys/kern/subr_param.c b/sys/kern/subr_param.c index afd3eacc71786..f589097ffb74f 100644 --- a/sys/kern/subr_param.c +++ b/sys/kern/subr_param.c @@ -107,32 +107,32 @@ u_long dflssiz; /* initial stack size limit */ u_long maxssiz; /* max stack size */ u_long sgrowsiz; /* amount to grow stack */ -SYSCTL_INT(_kern, OID_AUTO, hz, CTLFLAG_RDTUN, &hz, 0, +SYSCTL_INT(_kern, OID_AUTO, hz, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &hz, 0, "Number of clock ticks per second"); -SYSCTL_INT(_kern, OID_AUTO, nbuf, CTLFLAG_RDTUN, &nbuf, 0, +SYSCTL_INT(_kern, OID_AUTO, nbuf, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &nbuf, 0, "Number of buffers in the buffer cache"); -SYSCTL_INT(_kern, OID_AUTO, nswbuf, CTLFLAG_RDTUN, &nswbuf, 0, +SYSCTL_INT(_kern, OID_AUTO, nswbuf, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &nswbuf, 0, "Number of swap buffers"); -SYSCTL_INT(_kern, OID_AUTO, msgbufsize, CTLFLAG_RDTUN, &msgbufsize, 0, +SYSCTL_INT(_kern, OID_AUTO, msgbufsize, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &msgbufsize, 0, "Size of the kernel message buffer"); -SYSCTL_LONG(_kern, OID_AUTO, maxswzone, CTLFLAG_RDTUN, &maxswzone, 0, +SYSCTL_LONG(_kern, OID_AUTO, maxswzone, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &maxswzone, 0, "Maximum memory for swap metadata"); -SYSCTL_LONG(_kern, OID_AUTO, maxbcache, CTLFLAG_RDTUN, &maxbcache, 0, +SYSCTL_LONG(_kern, OID_AUTO, maxbcache, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &maxbcache, 0, "Maximum value of vfs.maxbufspace"); -SYSCTL_INT(_kern, OID_AUTO, bio_transient_maxcnt, CTLFLAG_RDTUN, +SYSCTL_INT(_kern, OID_AUTO, bio_transient_maxcnt, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &bio_transient_maxcnt, 0, "Maximum number of transient BIOs mappings"); -SYSCTL_ULONG(_kern, OID_AUTO, maxtsiz, CTLFLAG_RW | CTLFLAG_TUN, &maxtsiz, 0, +SYSCTL_ULONG(_kern, OID_AUTO, maxtsiz, CTLFLAG_RWTUN | CTLFLAG_NOFETCH, &maxtsiz, 0, "Maximum text size"); -SYSCTL_ULONG(_kern, OID_AUTO, dfldsiz, CTLFLAG_RW | CTLFLAG_TUN, &dfldsiz, 0, +SYSCTL_ULONG(_kern, OID_AUTO, dfldsiz, CTLFLAG_RWTUN | CTLFLAG_NOFETCH, &dfldsiz, 0, "Initial data size limit"); -SYSCTL_ULONG(_kern, OID_AUTO, maxdsiz, CTLFLAG_RW | CTLFLAG_TUN, &maxdsiz, 0, +SYSCTL_ULONG(_kern, OID_AUTO, maxdsiz, CTLFLAG_RWTUN | CTLFLAG_NOFETCH, &maxdsiz, 0, "Maximum data size"); -SYSCTL_ULONG(_kern, OID_AUTO, dflssiz, CTLFLAG_RW | CTLFLAG_TUN, &dflssiz, 0, +SYSCTL_ULONG(_kern, OID_AUTO, dflssiz, CTLFLAG_RWTUN | CTLFLAG_NOFETCH, &dflssiz, 0, "Initial stack size limit"); -SYSCTL_ULONG(_kern, OID_AUTO, maxssiz, CTLFLAG_RW | CTLFLAG_TUN, &maxssiz, 0, +SYSCTL_ULONG(_kern, OID_AUTO, maxssiz, CTLFLAG_RWTUN | CTLFLAG_NOFETCH, &maxssiz, 0, "Maximum stack size"); -SYSCTL_ULONG(_kern, OID_AUTO, sgrowsiz, CTLFLAG_RW | CTLFLAG_TUN, &sgrowsiz, 0, +SYSCTL_ULONG(_kern, OID_AUTO, sgrowsiz, CTLFLAG_RWTUN | CTLFLAG_NOFETCH, &sgrowsiz, 0, "Amount to grow stack on a stack fault"); SYSCTL_PROC(_kern, OID_AUTO, vm_guest, CTLFLAG_RD | CTLTYPE_STRING, NULL, 0, sysctl_kern_vm_guest, "A", diff --git a/sys/kern/subr_prf.c b/sys/kern/subr_prf.c index 28e33a4b4b2b1..814e57f479474 100644 --- a/sys/kern/subr_prf.c +++ b/sys/kern/subr_prf.c @@ -102,23 +102,20 @@ static void snprintf_func(int ch, void *arg); static int msgbufmapped; /* Set when safe to use msgbuf */ int msgbuftrigger; -static int log_console_output = 1; -TUNABLE_INT("kern.log_console_output", &log_console_output); -SYSCTL_INT(_kern, OID_AUTO, log_console_output, CTLFLAG_RW, - &log_console_output, 0, "Duplicate console output to the syslog."); +static int log_console_output = 1; +SYSCTL_INT(_kern, OID_AUTO, log_console_output, CTLFLAG_RWTUN, + &log_console_output, 0, "Duplicate console output to the syslog"); /* * See the comment in log_console() below for more explanation of this. */ -static int log_console_add_linefeed = 0; -TUNABLE_INT("kern.log_console_add_linefeed", &log_console_add_linefeed); -SYSCTL_INT(_kern, OID_AUTO, log_console_add_linefeed, CTLFLAG_RW, - &log_console_add_linefeed, 0, "log_console() adds extra newlines."); - -static int always_console_output = 0; -TUNABLE_INT("kern.always_console_output", &always_console_output); -SYSCTL_INT(_kern, OID_AUTO, always_console_output, CTLFLAG_RW, - &always_console_output, 0, "Always output to console despite TIOCCONS."); +static int log_console_add_linefeed; +SYSCTL_INT(_kern, OID_AUTO, log_console_add_linefeed, CTLFLAG_RWTUN, + &log_console_add_linefeed, 0, "log_console() adds extra newlines"); + +static int always_console_output; +SYSCTL_INT(_kern, OID_AUTO, always_console_output, CTLFLAG_RWTUN, + &always_console_output, 0, "Always output to console despite TIOCCONS"); /* * Warn that a system table is full. diff --git a/sys/kern/subr_rman.c b/sys/kern/subr_rman.c index c466b44b0fcd4..53480bf31b85f 100644 --- a/sys/kern/subr_rman.c +++ b/sys/kern/subr_rman.c @@ -100,8 +100,7 @@ struct resource_i { }; static int rman_debug = 0; -TUNABLE_INT("debug.rman_debug", &rman_debug); -SYSCTL_INT(_debug, OID_AUTO, rman_debug, CTLFLAG_RW, +SYSCTL_INT(_debug, OID_AUTO, rman_debug, CTLFLAG_RWTUN, &rman_debug, 0, "rman debug"); #define DPRINTF(params) if (rman_debug) printf params diff --git a/sys/kern/subr_smp.c b/sys/kern/subr_smp.c index 122fc4c5fede6..90bbc5fd22a1c 100644 --- a/sys/kern/subr_smp.c +++ b/sys/kern/subr_smp.c @@ -87,16 +87,14 @@ SYSCTL_PROC(_kern_smp, OID_AUTO, active, CTLFLAG_RD | CTLTYPE_INT, NULL, 0, int smp_disabled = 0; /* has smp been disabled? */ SYSCTL_INT(_kern_smp, OID_AUTO, disabled, CTLFLAG_RDTUN|CTLFLAG_CAPRD, &smp_disabled, 0, "SMP has been disabled from the loader"); -TUNABLE_INT("kern.smp.disabled", &smp_disabled); int smp_cpus = 1; /* how many cpu's running */ SYSCTL_INT(_kern_smp, OID_AUTO, cpus, CTLFLAG_RD|CTLFLAG_CAPRD, &smp_cpus, 0, "Number of CPUs online"); int smp_topology = 0; /* Which topology we're using. */ -SYSCTL_INT(_kern_smp, OID_AUTO, topology, CTLFLAG_RD, &smp_topology, 0, +SYSCTL_INT(_kern_smp, OID_AUTO, topology, CTLFLAG_RDTUN, &smp_topology, 0, "Topology override setting; 0 is default provided by hardware."); -TUNABLE_INT("kern.smp.topology", &smp_topology); #ifdef SMP /* Enable forwarding of a signal to a process running on a different CPU */ diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c index 86e1b16015e05..4ba4cf18607e4 100644 --- a/sys/kern/subr_witness.c +++ b/sys/kern/subr_witness.c @@ -380,8 +380,7 @@ static SYSCTL_NODE(_debug, OID_AUTO, witness, CTLFLAG_RW, NULL, * completely disabled. */ static int witness_watch = 1; -TUNABLE_INT("debug.witness.watch", &witness_watch); -SYSCTL_PROC(_debug_witness, OID_AUTO, watch, CTLFLAG_RW | CTLTYPE_INT, NULL, 0, +SYSCTL_PROC(_debug_witness, OID_AUTO, watch, CTLFLAG_RWTUN | CTLTYPE_INT, NULL, 0, sysctl_debug_witness_watch, "I", "witness is watching lock operations"); #ifdef KDB @@ -396,8 +395,7 @@ int witness_kdb = 1; #else int witness_kdb = 0; #endif -TUNABLE_INT("debug.witness.kdb", &witness_kdb); -SYSCTL_INT(_debug_witness, OID_AUTO, kdb, CTLFLAG_RW, &witness_kdb, 0, ""); +SYSCTL_INT(_debug_witness, OID_AUTO, kdb, CTLFLAG_RWTUN, &witness_kdb, 0, ""); /* * When KDB is enabled and witness_trace is 1, it will cause the system @@ -406,8 +404,7 @@ SYSCTL_INT(_debug_witness, OID_AUTO, kdb, CTLFLAG_RW, &witness_kdb, 0, ""); * - locks are held when going to sleep. */ int witness_trace = 1; -TUNABLE_INT("debug.witness.trace", &witness_trace); -SYSCTL_INT(_debug_witness, OID_AUTO, trace, CTLFLAG_RW, &witness_trace, 0, ""); +SYSCTL_INT(_debug_witness, OID_AUTO, trace, CTLFLAG_RWTUN, &witness_trace, 0, ""); #endif /* KDB */ #ifdef WITNESS_SKIPSPIN @@ -415,9 +412,7 @@ int witness_skipspin = 1; #else int witness_skipspin = 0; #endif -TUNABLE_INT("debug.witness.skipspin", &witness_skipspin); -SYSCTL_INT(_debug_witness, OID_AUTO, skipspin, CTLFLAG_RDTUN, &witness_skipspin, - 0, ""); +SYSCTL_INT(_debug_witness, OID_AUTO, skipspin, CTLFLAG_RDTUN, &witness_skipspin, 0, ""); /* * Call this to print out the relations between locks. diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c index f3c3c0e01d611..01cfeb9c1ffdd 100644 --- a/sys/kern/sys_pipe.c +++ b/sys/kern/sys_pipe.c @@ -205,7 +205,7 @@ static int pipeallocfail; static int piperesizefail; static int piperesizeallowed = 1; -SYSCTL_LONG(_kern_ipc, OID_AUTO, maxpipekva, CTLFLAG_RDTUN, +SYSCTL_LONG(_kern_ipc, OID_AUTO, maxpipekva, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &maxpipekva, 0, "Pipe KVA limit"); SYSCTL_LONG(_kern_ipc, OID_AUTO, pipekva, CTLFLAG_RD, &amountpipekva, 0, "Pipe KVA usage"); diff --git a/sys/kern/sysv_msg.c b/sys/kern/sysv_msg.c index d58cb7e791e8f..a572a0e0c1451 100644 --- a/sys/kern/sysv_msg.c +++ b/sys/kern/sysv_msg.c @@ -196,13 +196,7 @@ msginit() { int i, error; - TUNABLE_INT_FETCH("kern.ipc.msgseg", &msginfo.msgseg); - TUNABLE_INT_FETCH("kern.ipc.msgssz", &msginfo.msgssz); msginfo.msgmax = msginfo.msgseg * msginfo.msgssz; - TUNABLE_INT_FETCH("kern.ipc.msgmni", &msginfo.msgmni); - TUNABLE_INT_FETCH("kern.ipc.msgmnb", &msginfo.msgmnb); - TUNABLE_INT_FETCH("kern.ipc.msgtql", &msginfo.msgtql); - msgpool = malloc(msginfo.msgmax, M_MSG, M_WAITOK); msgmaps = malloc(sizeof(struct msgmap) * msginfo.msgseg, M_MSG, M_WAITOK); msghdrs = malloc(sizeof(struct msg) * msginfo.msgtql, M_MSG, M_WAITOK); diff --git a/sys/kern/sysv_sem.c b/sys/kern/sysv_sem.c index f9ff2170dc32f..c63290240799e 100644 --- a/sys/kern/sysv_sem.c +++ b/sys/kern/sysv_sem.c @@ -196,7 +196,7 @@ SYSCTL_INT(_kern_ipc, OID_AUTO, semmns, CTLFLAG_RDTUN, &seminfo.semmns, 0, "Maximum number of semaphores in the system"); SYSCTL_INT(_kern_ipc, OID_AUTO, semmnu, CTLFLAG_RDTUN, &seminfo.semmnu, 0, "Maximum number of undo structures in the system"); -SYSCTL_INT(_kern_ipc, OID_AUTO, semmsl, CTLFLAG_RW, &seminfo.semmsl, 0, +SYSCTL_INT(_kern_ipc, OID_AUTO, semmsl, CTLFLAG_RWTUN, &seminfo.semmsl, 0, "Max semaphores per id"); SYSCTL_INT(_kern_ipc, OID_AUTO, semopm, CTLFLAG_RDTUN, &seminfo.semopm, 0, "Max operations per semop call"); @@ -204,9 +204,9 @@ SYSCTL_INT(_kern_ipc, OID_AUTO, semume, CTLFLAG_RDTUN, &seminfo.semume, 0, "Max undo entries per process"); SYSCTL_INT(_kern_ipc, OID_AUTO, semusz, CTLFLAG_RDTUN, &seminfo.semusz, 0, "Size in bytes of undo structure"); -SYSCTL_INT(_kern_ipc, OID_AUTO, semvmx, CTLFLAG_RW, &seminfo.semvmx, 0, +SYSCTL_INT(_kern_ipc, OID_AUTO, semvmx, CTLFLAG_RWTUN, &seminfo.semvmx, 0, "Semaphore maximum value"); -SYSCTL_INT(_kern_ipc, OID_AUTO, semaem, CTLFLAG_RW, &seminfo.semaem, 0, +SYSCTL_INT(_kern_ipc, OID_AUTO, semaem, CTLFLAG_RWTUN, &seminfo.semaem, 0, "Adjust on exit max value"); SYSCTL_PROC(_kern_ipc, OID_AUTO, sema, CTLTYPE_OPAQUE | CTLFLAG_RD, NULL, 0, sysctl_sema, "", "Semaphore id pool"); @@ -249,16 +249,6 @@ seminit(void) { int i, error; - TUNABLE_INT_FETCH("kern.ipc.semmni", &seminfo.semmni); - TUNABLE_INT_FETCH("kern.ipc.semmns", &seminfo.semmns); - TUNABLE_INT_FETCH("kern.ipc.semmnu", &seminfo.semmnu); - TUNABLE_INT_FETCH("kern.ipc.semmsl", &seminfo.semmsl); - TUNABLE_INT_FETCH("kern.ipc.semopm", &seminfo.semopm); - TUNABLE_INT_FETCH("kern.ipc.semume", &seminfo.semume); - TUNABLE_INT_FETCH("kern.ipc.semusz", &seminfo.semusz); - TUNABLE_INT_FETCH("kern.ipc.semvmx", &seminfo.semvmx); - TUNABLE_INT_FETCH("kern.ipc.semaem", &seminfo.semaem); - sem = malloc(sizeof(struct sem) * seminfo.semmns, M_SEM, M_WAITOK); sema = malloc(sizeof(struct semid_kernel) * seminfo.semmni, M_SEM, M_WAITOK); diff --git a/sys/kern/sysv_shm.c b/sys/kern/sysv_shm.c index 4144d9431f9db..a7a7c167e5500 100644 --- a/sys/kern/sysv_shm.c +++ b/sys/kern/sysv_shm.c @@ -156,29 +156,29 @@ static int sysctl_shmsegs(SYSCTL_HANDLER_ARGS); #endif struct shminfo shminfo = { - SHMMAX, - SHMMIN, - SHMMNI, - SHMSEG, - SHMALL + .shmmax = SHMMAX, + .shmmin = SHMMIN, + .shmmni = SHMMNI, + .shmseg = SHMSEG, + .shmall = SHMALL }; static int shm_use_phys; static int shm_allow_removed; -SYSCTL_ULONG(_kern_ipc, OID_AUTO, shmmax, CTLFLAG_RW, &shminfo.shmmax, 0, +SYSCTL_ULONG(_kern_ipc, OID_AUTO, shmmax, CTLFLAG_RWTUN, &shminfo.shmmax, 0, "Maximum shared memory segment size"); -SYSCTL_ULONG(_kern_ipc, OID_AUTO, shmmin, CTLFLAG_RW, &shminfo.shmmin, 0, +SYSCTL_ULONG(_kern_ipc, OID_AUTO, shmmin, CTLFLAG_RWTUN, &shminfo.shmmin, 0, "Minimum shared memory segment size"); SYSCTL_ULONG(_kern_ipc, OID_AUTO, shmmni, CTLFLAG_RDTUN, &shminfo.shmmni, 0, "Number of shared memory identifiers"); SYSCTL_ULONG(_kern_ipc, OID_AUTO, shmseg, CTLFLAG_RDTUN, &shminfo.shmseg, 0, "Number of segments per process"); -SYSCTL_ULONG(_kern_ipc, OID_AUTO, shmall, CTLFLAG_RW, &shminfo.shmall, 0, +SYSCTL_ULONG(_kern_ipc, OID_AUTO, shmall, CTLFLAG_RWTUN, &shminfo.shmall, 0, "Maximum number of pages available for shared memory"); -SYSCTL_INT(_kern_ipc, OID_AUTO, shm_use_phys, CTLFLAG_RW, +SYSCTL_INT(_kern_ipc, OID_AUTO, shm_use_phys, CTLFLAG_RWTUN, &shm_use_phys, 0, "Enable/Disable locking of shared memory pages in core"); -SYSCTL_INT(_kern_ipc, OID_AUTO, shm_allow_removed, CTLFLAG_RW, +SYSCTL_INT(_kern_ipc, OID_AUTO, shm_allow_removed, CTLFLAG_RWTUN, &shm_allow_removed, 0, "Enable/Disable attachment to attached segments marked for removal"); SYSCTL_PROC(_kern_ipc, OID_AUTO, shmsegs, CTLTYPE_OPAQUE | CTLFLAG_RD, @@ -887,20 +887,14 @@ shminit() if (TUNABLE_ULONG_FETCH("kern.ipc.shmmaxpgs", &shminfo.shmall) != 0) printf("kern.ipc.shmmaxpgs is now called kern.ipc.shmall!\n"); #endif - TUNABLE_ULONG_FETCH("kern.ipc.shmall", &shminfo.shmall); - if (!TUNABLE_ULONG_FETCH("kern.ipc.shmmax", &shminfo.shmmax)) { + if (shminfo.shmmax == SHMMAX) { /* Initialize shmmax dealing with possible overflow. */ - for (i = PAGE_SIZE; i > 0; i--) { + for (i = PAGE_SIZE; i != 0; i--) { shminfo.shmmax = shminfo.shmall * i; - if (shminfo.shmmax >= shminfo.shmall) + if ((shminfo.shmmax / shminfo.shmall) == (u_long)i) break; } } - TUNABLE_ULONG_FETCH("kern.ipc.shmmin", &shminfo.shmmin); - TUNABLE_ULONG_FETCH("kern.ipc.shmmni", &shminfo.shmmni); - TUNABLE_ULONG_FETCH("kern.ipc.shmseg", &shminfo.shmseg); - TUNABLE_INT_FETCH("kern.ipc.shm_use_phys", &shm_use_phys); - shmalloced = shminfo.shmmni; shmsegs = malloc(shmalloced * sizeof(shmsegs[0]), M_SHM, M_WAITOK); for (i = 0; i < shmalloced; i++) { diff --git a/sys/kern/vfs_init.c b/sys/kern/vfs_init.c index eab48fbea7982..66a6b00df0634 100644 --- a/sys/kern/vfs_init.c +++ b/sys/kern/vfs_init.c @@ -72,7 +72,6 @@ struct vfsconfhead vfsconf = TAILQ_HEAD_INITIALIZER(vfsconf); * changing for file systems that use vfc_typenum in their fsid. */ static int vfs_typenumhash = 1; -TUNABLE_INT("vfs.typenumhash", &vfs_typenumhash); SYSCTL_INT(_vfs, OID_AUTO, typenumhash, CTLFLAG_RDTUN, &vfs_typenumhash, 0, "Set vfc_typenum using a hash calculation on vfc_name, so that it does not" "change when file systems are loaded in a different order."); @@ -213,7 +212,7 @@ vfs_register(struct vfsconf *vfc) * number. */ sysctl_lock(); - SLIST_FOREACH(oidp, &sysctl__vfs_children, oid_link) + SLIST_FOREACH(oidp, SYSCTL_CHILDREN(&sysctl___vfs), oid_link) if (strcmp(oidp->oid_name, vfc->vfc_name) == 0) { sysctl_unregister_oid(oidp); oidp->oid_number = vfc->vfc_typenum; diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index 00dd496e9e37f..f466ca4682566 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -96,9 +96,8 @@ nameiinit(void *dummy __unused) SYSINIT(vfs, SI_SUB_VFS, SI_ORDER_SECOND, nameiinit, NULL); static int lookup_shared = 1; -SYSCTL_INT(_vfs, OID_AUTO, lookup_shared, CTLFLAG_RW, &lookup_shared, 0, +SYSCTL_INT(_vfs, OID_AUTO, lookup_shared, CTLFLAG_RWTUN, &lookup_shared, 0, "Enables/Disables shared locks for path name translation"); -TUNABLE_INT("vfs.lookup_shared", &lookup_shared); /* * Convert a pathname into a pointer to a locked vnode. diff --git a/sys/mips/cavium/usb/octusb.c b/sys/mips/cavium/usb/octusb.c index cad3ef5ef2110..c4d4ac76d8ac0 100644 --- a/sys/mips/cavium/usb/octusb.c +++ b/sys/mips/cavium/usb/octusb.c @@ -82,11 +82,8 @@ __FBSDID("$FreeBSD$"); static int octusbdebug = 0; static SYSCTL_NODE(_hw_usb, OID_AUTO, octusb, CTLFLAG_RW, 0, "OCTUSB"); -SYSCTL_INT(_hw_usb_octusb, OID_AUTO, debug, CTLFLAG_RW, +SYSCTL_INT(_hw_usb_octusb, OID_AUTO, debug, CTLFLAG_RWTUN, &octusbdebug, 0, "OCTUSB debug level"); - -TUNABLE_INT("hw.usb.octusb.debug", &octusbdebug); - #endif struct octusb_std_temp { diff --git a/sys/mips/mips/dump_machdep.c b/sys/mips/mips/dump_machdep.c index bf8c4a3152f3d..54224f285ea15 100644 --- a/sys/mips/mips/dump_machdep.c +++ b/sys/mips/mips/dump_machdep.c @@ -50,8 +50,7 @@ __FBSDID("$FreeBSD$"); CTASSERT(sizeof(struct kerneldumpheader) == 512); int do_minidump = 1; -TUNABLE_INT("debug.minidump", &do_minidump); -SYSCTL_INT(_debug, OID_AUTO, minidump, CTLFLAG_RW, &do_minidump, 0, +SYSCTL_INT(_debug, OID_AUTO, minidump, CTLFLAG_RWTUN, &do_minidump, 0, "Enable mini crash dumps"); /* diff --git a/sys/mips/rt305x/uart_dev_rt305x.c b/sys/mips/rt305x/uart_dev_rt305x.c index 3154cb97437ff..d4f23196d0530 100644 --- a/sys/mips/rt305x/uart_dev_rt305x.c +++ b/sys/mips/rt305x/uart_dev_rt305x.c @@ -73,13 +73,9 @@ static struct uart_ops uart_rt305x_uart_ops = { }; static int uart_output = 1; -TUNABLE_INT("kern.uart_output", &uart_output); -SYSCTL_INT(_kern, OID_AUTO, uart_output, CTLFLAG_RW, +SYSCTL_INT(_kern, OID_AUTO, uart_output, CTLFLAG_RWTUN, &uart_output, 0, "UART output enabled."); - - - static int rt305x_uart_probe(struct uart_bas *bas) { diff --git a/sys/net/ieee8023ad_lacp.c b/sys/net/ieee8023ad_lacp.c index aa38efabd50da..12cc721761876 100644 --- a/sys/net/ieee8023ad_lacp.c +++ b/sys/net/ieee8023ad_lacp.c @@ -192,9 +192,8 @@ static void lacp_dprintf(const struct lacp_port *, const char *, ...) static int lacp_debug = 0; SYSCTL_NODE(_net_link_lagg, OID_AUTO, lacp, CTLFLAG_RD, 0, "ieee802.3ad"); -SYSCTL_INT(_net_link_lagg_lacp, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_net_link_lagg_lacp, OID_AUTO, debug, CTLFLAG_RWTUN, &lacp_debug, 0, "Enable LACP debug logging (1=debug, 2=trace)"); -TUNABLE_INT("net.link.lagg.lacp.debug", &lacp_debug); #define LACP_DPRINTF(a) if (lacp_debug & 0x01) { lacp_dprintf a ; } #define LACP_TRACE(a) if (lacp_debug & 0x02) { lacp_dprintf(a,"%s\n",__func__); } diff --git a/sys/net/if.c b/sys/net/if.c index 47b5b9d687a7f..5a05c97af18c7 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -106,7 +106,6 @@ struct ifindex_entry { SYSCTL_NODE(_net, PF_LINK, link, CTLFLAG_RW, 0, "Link layers"); SYSCTL_NODE(_net_link, 0, generic, CTLFLAG_RW, 0, "Generic link-management"); -TUNABLE_INT("net.link.ifqmaxlen", &ifqmaxlen); SYSCTL_INT(_net_link, OID_AUTO, ifqmaxlen, CTLFLAG_RDTUN, &ifqmaxlen, 0, "max send queue size"); diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c index 4e085731feeae..59d63ee4f2278 100644 --- a/sys/net/if_bridge.c +++ b/sys/net/if_bridge.c @@ -359,27 +359,20 @@ static int pfil_local_phys = 0; /* run pfil hooks on the physical interface for locally destined packets */ static int log_stp = 0; /* log STP state changes */ static int bridge_inherit_mac = 0; /* share MAC with first bridge member */ -TUNABLE_INT("net.link.bridge.pfil_onlyip", &pfil_onlyip); -SYSCTL_INT(_net_link_bridge, OID_AUTO, pfil_onlyip, CTLFLAG_RW, +SYSCTL_INT(_net_link_bridge, OID_AUTO, pfil_onlyip, CTLFLAG_RWTUN, &pfil_onlyip, 0, "Only pass IP packets when pfil is enabled"); -TUNABLE_INT("net.link.bridge.ipfw_arp", &pfil_ipfw_arp); -SYSCTL_INT(_net_link_bridge, OID_AUTO, ipfw_arp, CTLFLAG_RW, +SYSCTL_INT(_net_link_bridge, OID_AUTO, ipfw_arp, CTLFLAG_RWTUN, &pfil_ipfw_arp, 0, "Filter ARP packets through IPFW layer2"); -TUNABLE_INT("net.link.bridge.pfil_bridge", &pfil_bridge); -SYSCTL_INT(_net_link_bridge, OID_AUTO, pfil_bridge, CTLFLAG_RW, +SYSCTL_INT(_net_link_bridge, OID_AUTO, pfil_bridge, CTLFLAG_RWTUN, &pfil_bridge, 0, "Packet filter on the bridge interface"); -TUNABLE_INT("net.link.bridge.pfil_member", &pfil_member); -SYSCTL_INT(_net_link_bridge, OID_AUTO, pfil_member, CTLFLAG_RW, +SYSCTL_INT(_net_link_bridge, OID_AUTO, pfil_member, CTLFLAG_RWTUN, &pfil_member, 0, "Packet filter on the member interface"); -TUNABLE_INT("net.link.bridge.pfil_local_phys", &pfil_local_phys); -SYSCTL_INT(_net_link_bridge, OID_AUTO, pfil_local_phys, CTLFLAG_RW, +SYSCTL_INT(_net_link_bridge, OID_AUTO, pfil_local_phys, CTLFLAG_RWTUN, &pfil_local_phys, 0, "Packet filter on the physical interface for locally destined packets"); -TUNABLE_INT("net.link.bridge.log_stp", &log_stp); -SYSCTL_INT(_net_link_bridge, OID_AUTO, log_stp, CTLFLAG_RW, +SYSCTL_INT(_net_link_bridge, OID_AUTO, log_stp, CTLFLAG_RWTUN, &log_stp, 0, "Log STP state changes"); -TUNABLE_INT("net.link.bridge.inherit_mac", &bridge_inherit_mac); -SYSCTL_INT(_net_link_bridge, OID_AUTO, inherit_mac, CTLFLAG_RW, +SYSCTL_INT(_net_link_bridge, OID_AUTO, inherit_mac, CTLFLAG_RWTUN, &bridge_inherit_mac, 0, "Inherit MAC address from the first bridge member"); diff --git a/sys/net/if_lagg.c b/sys/net/if_lagg.c index 1bab4f948e3ba..ec868e1271609 100644 --- a/sys/net/if_lagg.c +++ b/sys/net/if_lagg.c @@ -180,13 +180,11 @@ SYSCTL_INT(_net_link_lagg, OID_AUTO, failover_rx_all, CTLFLAG_RW, &lagg_failover_rx_all, 0, "Accept input from any interface in a failover lagg"); static int def_use_flowid = 1; /* Default value for using M_FLOWID */ -TUNABLE_INT("net.link.lagg.default_use_flowid", &def_use_flowid); -SYSCTL_INT(_net_link_lagg, OID_AUTO, default_use_flowid, CTLFLAG_RW, +SYSCTL_INT(_net_link_lagg, OID_AUTO, default_use_flowid, CTLFLAG_RWTUN, &def_use_flowid, 0, "Default setting for using flow id for load sharing"); static int def_flowid_shift = 16; /* Default value for using M_FLOWID */ -TUNABLE_INT("net.link.lagg.default_flowid_shift", &def_flowid_shift); -SYSCTL_INT(_net_link_lagg, OID_AUTO, default_flowid_shift, CTLFLAG_RW, +SYSCTL_INT(_net_link_lagg, OID_AUTO, default_flowid_shift, CTLFLAG_RWTUN, &def_flowid_shift, 0, "Default setting for flowid shift for load sharing"); diff --git a/sys/net/if_stf.c b/sys/net/if_stf.c index 28888edff5f46..8578818472cfe 100644 --- a/sys/net/if_stf.c +++ b/sys/net/if_stf.c @@ -129,8 +129,7 @@ SYSCTL_INT(_net_link_stf, OID_AUTO, route_cache, CTLFLAG_RW, &stf_route_cache, 0, "Caching of IPv4 routes for 6to4 Output"); static int stf_permit_rfc1918 = 0; -TUNABLE_INT("net.link.stf.permit_rfc1918", &stf_permit_rfc1918); -SYSCTL_INT(_net_link_stf, OID_AUTO, permit_rfc1918, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_net_link_stf, OID_AUTO, permit_rfc1918, CTLFLAG_RWTUN, &stf_permit_rfc1918, 0, "Permit the use of private IPv4 addresses"); #define STFUNIT 0 diff --git a/sys/net/if_tap.c b/sys/net/if_tap.c index d788635a59e14..89cac22f264e8 100644 --- a/sys/net/if_tap.c +++ b/sys/net/if_tap.c @@ -170,12 +170,10 @@ SYSCTL_INT(_net_link_tap, OID_AUTO, user_open, CTLFLAG_RW, &tapuopen, 0, "Allow user to open /dev/tap (based on node permissions)"); SYSCTL_INT(_net_link_tap, OID_AUTO, up_on_open, CTLFLAG_RW, &tapuponopen, 0, "Bring interface up when /dev/tap is opened"); -SYSCTL_INT(_net_link_tap, OID_AUTO, devfs_cloning, CTLFLAG_RW, &tapdclone, 0, +SYSCTL_INT(_net_link_tap, OID_AUTO, devfs_cloning, CTLFLAG_RWTUN, &tapdclone, 0, "Enably legacy devfs interface creation"); SYSCTL_INT(_net_link_tap, OID_AUTO, debug, CTLFLAG_RW, &tapdebug, 0, ""); -TUNABLE_INT("net.link.tap.devfs_cloning", &tapdclone); - DEV_MODULE(if_tap, tapmodevent, NULL); static int diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index 504bab0503671..e4bc2afc7afc1 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -116,11 +116,9 @@ SYSCTL_INT(_debug, OID_AUTO, if_tun_debug, CTLFLAG_RW, &tundebug, 0, ""); SYSCTL_DECL(_net_link); static SYSCTL_NODE(_net_link, OID_AUTO, tun, CTLFLAG_RW, 0, "IP tunnel software network interface."); -SYSCTL_INT(_net_link_tun, OID_AUTO, devfs_cloning, CTLFLAG_RW, &tundclone, 0, +SYSCTL_INT(_net_link_tun, OID_AUTO, devfs_cloning, CTLFLAG_RWTUN, &tundclone, 0, "Enable legacy devfs interface creation."); -TUNABLE_INT("net.link.tun.devfs_cloning", &tundclone); - static void tunclone(void *arg, struct ucred *cred, char *name, int namelen, struct cdev **dev); static void tuncreate(const char *name, struct cdev *dev); diff --git a/sys/net/netisr.c b/sys/net/netisr.c index 7974cc891ea13..049bbf192b538 100644 --- a/sys/net/netisr.c +++ b/sys/net/netisr.c @@ -149,8 +149,8 @@ static SYSCTL_NODE(_net, OID_AUTO, isr, CTLFLAG_RW, 0, "netisr"); #define NETISR_DISPATCH_POLICY_MAXSTR 20 /* Used for temporary buffers. */ static u_int netisr_dispatch_policy = NETISR_DISPATCH_POLICY_DEFAULT; static int sysctl_netisr_dispatch_policy(SYSCTL_HANDLER_ARGS); -SYSCTL_PROC(_net_isr, OID_AUTO, dispatch, CTLTYPE_STRING | CTLFLAG_RW | - CTLFLAG_TUN, 0, 0, sysctl_netisr_dispatch_policy, "A", +SYSCTL_PROC(_net_isr, OID_AUTO, dispatch, CTLTYPE_STRING | CTLFLAG_RWTUN, + 0, 0, sysctl_netisr_dispatch_policy, "A", "netisr dispatch policy"); /* @@ -160,13 +160,11 @@ SYSCTL_PROC(_net_isr, OID_AUTO, dispatch, CTLTYPE_STRING | CTLFLAG_RW | * We will create at most one thread per CPU. */ static int netisr_maxthreads = -1; /* Max number of threads. */ -TUNABLE_INT("net.isr.maxthreads", &netisr_maxthreads); SYSCTL_INT(_net_isr, OID_AUTO, maxthreads, CTLFLAG_RDTUN, &netisr_maxthreads, 0, "Use at most this many CPUs for netisr processing"); static int netisr_bindthreads = 0; /* Bind threads to CPUs. */ -TUNABLE_INT("net.isr.bindthreads", &netisr_bindthreads); SYSCTL_INT(_net_isr, OID_AUTO, bindthreads, CTLFLAG_RDTUN, &netisr_bindthreads, 0, "Bind netisr threads to CPUs."); @@ -177,7 +175,6 @@ SYSCTL_INT(_net_isr, OID_AUTO, bindthreads, CTLFLAG_RDTUN, */ #define NETISR_DEFAULT_MAXQLIMIT 10240 static u_int netisr_maxqlimit = NETISR_DEFAULT_MAXQLIMIT; -TUNABLE_INT("net.isr.maxqlimit", &netisr_maxqlimit); SYSCTL_UINT(_net_isr, OID_AUTO, maxqlimit, CTLFLAG_RDTUN, &netisr_maxqlimit, 0, "Maximum netisr per-protocol, per-CPU queue depth."); @@ -189,7 +186,6 @@ SYSCTL_UINT(_net_isr, OID_AUTO, maxqlimit, CTLFLAG_RDTUN, */ #define NETISR_DEFAULT_DEFAULTQLIMIT 256 static u_int netisr_defaultqlimit = NETISR_DEFAULT_DEFAULTQLIMIT; -TUNABLE_INT("net.isr.defaultqlimit", &netisr_defaultqlimit); SYSCTL_UINT(_net_isr, OID_AUTO, defaultqlimit, CTLFLAG_RDTUN, &netisr_defaultqlimit, 0, "Default netisr per-protocol, per-CPU queue limit if not set by protocol"); @@ -1120,10 +1116,6 @@ netisr_start_swi(u_int cpuid, struct pcpu *pc) static void netisr_init(void *arg) { - char tmp[NETISR_DISPATCH_POLICY_MAXSTR]; - u_int dispatch_policy; - int error; - KASSERT(curcpu == 0, ("%s: not on CPU 0", __func__)); NETISR_LOCK_INIT(); @@ -1152,20 +1144,6 @@ netisr_init(void *arg) netisr_bindthreads = 0; } #endif - - if (TUNABLE_STR_FETCH("net.isr.dispatch", tmp, sizeof(tmp))) { - error = netisr_dispatch_policy_from_str(tmp, - &dispatch_policy); - if (error == 0 && dispatch_policy == NETISR_DISPATCH_DEFAULT) - error = EINVAL; - if (error == 0) - netisr_dispatch_policy = dispatch_policy; - else - printf( - "%s: invalid dispatch policy %s, using default\n", - __func__, tmp); - } - netisr_start_swi(curcpu, pcpu_find(curcpu)); } SYSINIT(netisr_init, SI_SUB_SOFTINTR, SI_ORDER_FIRST, netisr_init, NULL); diff --git a/sys/net/route.c b/sys/net/route.c index 83cc857ef7b28..547418af84b9c 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -96,9 +96,7 @@ extern void sctp_addr_change(struct ifaddr *ifa, int cmd); /* This is read-only.. */ u_int rt_numfibs = RT_NUMFIBS; -SYSCTL_UINT(_net, OID_AUTO, fibs, CTLFLAG_RD, &rt_numfibs, 0, ""); -/* and this can be set too big but will be fixed before it is used */ -TUNABLE_INT("net.fibs", &rt_numfibs); +SYSCTL_UINT(_net, OID_AUTO, fibs, CTLFLAG_RDTUN, &rt_numfibs, 0, ""); /* * By default add routes to all fibs for new interfaces. @@ -111,9 +109,8 @@ TUNABLE_INT("net.fibs", &rt_numfibs); * from the network stack context. */ u_int rt_add_addr_allfibs = 1; -SYSCTL_UINT(_net, OID_AUTO, add_addr_allfibs, CTLFLAG_RW, +SYSCTL_UINT(_net, OID_AUTO, add_addr_allfibs, CTLFLAG_RWTUN, &rt_add_addr_allfibs, 0, ""); -TUNABLE_INT("net.add_addr_allfibs", &rt_add_addr_allfibs); VNET_DEFINE(struct rtstat, rtstat); #define V_rtstat VNET(rtstat) diff --git a/sys/netgraph/ng_base.c b/sys/netgraph/ng_base.c index e83967be8f07a..1970965e2e25c 100644 --- a/sys/netgraph/ng_base.c +++ b/sys/netgraph/ng_base.c @@ -2954,13 +2954,10 @@ static int numthreads = 0; /* number of queue threads */ static int maxalloc = 4096;/* limit the damage of a leak */ static int maxdata = 512; /* limit the damage of a DoS */ -TUNABLE_INT("net.graph.threads", &numthreads); SYSCTL_INT(_net_graph, OID_AUTO, threads, CTLFLAG_RDTUN, &numthreads, 0, "Number of queue processing threads"); -TUNABLE_INT("net.graph.maxalloc", &maxalloc); SYSCTL_INT(_net_graph, OID_AUTO, maxalloc, CTLFLAG_RDTUN, &maxalloc, 0, "Maximum number of non-data queue items to allocate"); -TUNABLE_INT("net.graph.maxdata", &maxdata); SYSCTL_INT(_net_graph, OID_AUTO, maxdata, CTLFLAG_RDTUN, &maxdata, 0, "Maximum number of data queue items to allocate"); diff --git a/sys/netgraph/ng_mppc.c b/sys/netgraph/ng_mppc.c index 14d44de49dc07..76f4c3b89b4fe 100644 --- a/sys/netgraph/ng_mppc.c +++ b/sys/netgraph/ng_mppc.c @@ -111,18 +111,15 @@ static MALLOC_DEFINE(M_NETGRAPH_MPPC, "netgraph_mppc", "netgraph mppc node"); SYSCTL_NODE(_net_graph, OID_AUTO, mppe, CTLFLAG_RW, 0, "MPPE"); static int mppe_block_on_max_rekey = 0; -TUNABLE_INT("net.graph.mppe.block_on_max_rekey", &mppe_block_on_max_rekey); -SYSCTL_INT(_net_graph_mppe, OID_AUTO, block_on_max_rekey, CTLFLAG_RW, +SYSCTL_INT(_net_graph_mppe, OID_AUTO, block_on_max_rekey, CTLFLAG_RWTUN, &mppe_block_on_max_rekey, 0, "Block node on max MPPE key re-calculations"); static int mppe_log_max_rekey = 1; -TUNABLE_INT("net.graph.mppe.log_max_rekey", &mppe_log_max_rekey); -SYSCTL_INT(_net_graph_mppe, OID_AUTO, log_max_rekey, CTLFLAG_RW, +SYSCTL_INT(_net_graph_mppe, OID_AUTO, log_max_rekey, CTLFLAG_RWTUN, &mppe_log_max_rekey, 0, "Log max MPPE key re-calculations event"); static int mppe_max_rekey = MPPE_MAX_REKEY; -TUNABLE_INT("net.graph.mppe.max_rekey", &mppe_max_rekey); -SYSCTL_INT(_net_graph_mppe, OID_AUTO, max_rekey, CTLFLAG_RW, +SYSCTL_INT(_net_graph_mppe, OID_AUTO, max_rekey, CTLFLAG_RWTUN, &mppe_max_rekey, 0, "Maximum number of MPPE key re-calculations"); /* MPPC packet header bits */ diff --git a/sys/netinet/in_mcast.c b/sys/netinet/in_mcast.c index d996bd189281d..26d4e8e3a135b 100644 --- a/sys/netinet/in_mcast.c +++ b/sys/netinet/in_mcast.c @@ -166,20 +166,17 @@ static SYSCTL_NODE(_net_inet_ip, OID_AUTO, mcast, CTLFLAG_RW, 0, static u_long in_mcast_maxgrpsrc = IP_MAX_GROUP_SRC_FILTER; SYSCTL_ULONG(_net_inet_ip_mcast, OID_AUTO, maxgrpsrc, - CTLFLAG_RW | CTLFLAG_TUN, &in_mcast_maxgrpsrc, 0, + CTLFLAG_RWTUN, &in_mcast_maxgrpsrc, 0, "Max source filters per group"); -TUNABLE_ULONG("net.inet.ip.mcast.maxgrpsrc", &in_mcast_maxgrpsrc); static u_long in_mcast_maxsocksrc = IP_MAX_SOCK_SRC_FILTER; SYSCTL_ULONG(_net_inet_ip_mcast, OID_AUTO, maxsocksrc, - CTLFLAG_RW | CTLFLAG_TUN, &in_mcast_maxsocksrc, 0, + CTLFLAG_RWTUN, &in_mcast_maxsocksrc, 0, "Max source filters per socket"); -TUNABLE_ULONG("net.inet.ip.mcast.maxsocksrc", &in_mcast_maxsocksrc); int in_mcast_loop = IP_DEFAULT_MULTICAST_LOOP; -SYSCTL_INT(_net_inet_ip_mcast, OID_AUTO, loop, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_net_inet_ip_mcast, OID_AUTO, loop, CTLFLAG_RWTUN, &in_mcast_loop, 0, "Loopback multicast datagrams by default"); -TUNABLE_INT("net.inet.ip.mcast.loop", &in_mcast_loop); static SYSCTL_NODE(_net_inet_ip_mcast, OID_AUTO, filters, CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_ip_mcast_filters, diff --git a/sys/netinet/in_rss.c b/sys/netinet/in_rss.c index 698373fa7aa24..4e6a454e1319d 100644 --- a/sys/netinet/in_rss.c +++ b/sys/netinet/in_rss.c @@ -91,9 +91,8 @@ SYSCTL_NODE(_net_inet, OID_AUTO, rss, CTLFLAG_RW, 0, "Receive-side steering"); * default. */ static u_int rss_hashalgo = RSS_HASH_TOEPLITZ; -SYSCTL_INT(_net_inet_rss, OID_AUTO, hashalgo, CTLFLAG_RD, &rss_hashalgo, 0, +SYSCTL_INT(_net_inet_rss, OID_AUTO, hashalgo, CTLFLAG_RDTUN, &rss_hashalgo, 0, "RSS hash algorithm"); -TUNABLE_INT("net.inet.rss.hashalgo", &rss_hashalgo); /* * Size of the indirection table; at most 128 entries per the RSS spec. We @@ -104,9 +103,8 @@ TUNABLE_INT("net.inet.rss.hashalgo", &rss_hashalgo); * XXXRW: buckets might be better to use for the tunable than bits. */ static u_int rss_bits; -SYSCTL_INT(_net_inet_rss, OID_AUTO, bits, CTLFLAG_RD, &rss_bits, 0, +SYSCTL_INT(_net_inet_rss, OID_AUTO, bits, CTLFLAG_RDTUN, &rss_bits, 0, "RSS bits"); -TUNABLE_INT("net.inet.rss.bits", &rss_bits); static u_int rss_mask; SYSCTL_INT(_net_inet_rss, OID_AUTO, mask, CTLFLAG_RD, &rss_mask, 0, diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index fb2c415aee986..ac0aad31bc50e 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -188,8 +188,8 @@ static int tcp_log_debug = 0; SYSCTL_INT(_net_inet_tcp, OID_AUTO, log_debug, CTLFLAG_RW, &tcp_log_debug, 0, "Log errors caused by incoming TCP segments"); -static int tcp_tcbhashsize = 0; -SYSCTL_INT(_net_inet_tcp, OID_AUTO, tcbhashsize, CTLFLAG_RDTUN, +static int tcp_tcbhashsize; +SYSCTL_INT(_net_inet_tcp, OID_AUTO, tcbhashsize, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &tcp_tcbhashsize, 0, "Size of TCP control-block hashtable"); static int do_tcpdrain = 1; @@ -211,7 +211,7 @@ SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, isn_reseed_interval, CTLFLAG_RW, &VNET_NAME(tcp_isn_reseed_interval), 0, "Seconds between reseeding of ISN secret"); -static int tcp_soreceive_stream = 0; +static int tcp_soreceive_stream; SYSCTL_INT(_net_inet_tcp, OID_AUTO, soreceive_stream, CTLFLAG_RDTUN, &tcp_soreceive_stream, 0, "Using soreceive_stream for TCP sockets"); @@ -398,7 +398,6 @@ tcp_init(void) tcp_finwait2_timeout = TCPTV_FINWAIT2_TIMEOUT; tcp_tcbhashsize = hashsize; - TUNABLE_INT_FETCH("net.inet.tcp.soreceive_stream", &tcp_soreceive_stream); if (tcp_soreceive_stream) { #ifdef INET tcp_usrreqs.pru_soreceive = soreceive_stream; diff --git a/sys/netinet6/in6_mcast.c b/sys/netinet6/in6_mcast.c index d259997635019..f9ff10a302f30 100644 --- a/sys/netinet6/in6_mcast.c +++ b/sys/netinet6/in6_mcast.c @@ -158,21 +158,18 @@ static SYSCTL_NODE(_net_inet6_ip6, OID_AUTO, mcast, CTLFLAG_RW, 0, static u_long in6_mcast_maxgrpsrc = IPV6_MAX_GROUP_SRC_FILTER; SYSCTL_ULONG(_net_inet6_ip6_mcast, OID_AUTO, maxgrpsrc, - CTLFLAG_RW | CTLFLAG_TUN, &in6_mcast_maxgrpsrc, 0, + CTLFLAG_RWTUN, &in6_mcast_maxgrpsrc, 0, "Max source filters per group"); -TUNABLE_ULONG("net.inet6.ip6.mcast.maxgrpsrc", &in6_mcast_maxgrpsrc); static u_long in6_mcast_maxsocksrc = IPV6_MAX_SOCK_SRC_FILTER; SYSCTL_ULONG(_net_inet6_ip6_mcast, OID_AUTO, maxsocksrc, - CTLFLAG_RW | CTLFLAG_TUN, &in6_mcast_maxsocksrc, 0, + CTLFLAG_RWTUN, &in6_mcast_maxsocksrc, 0, "Max source filters per socket"); -TUNABLE_ULONG("net.inet6.ip6.mcast.maxsocksrc", &in6_mcast_maxsocksrc); /* TODO Virtualize this switch. */ int in6_mcast_loop = IPV6_DEFAULT_MULTICAST_LOOP; -SYSCTL_INT(_net_inet6_ip6_mcast, OID_AUTO, loop, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_net_inet6_ip6_mcast, OID_AUTO, loop, CTLFLAG_RWTUN, &in6_mcast_loop, 0, "Loopback multicast datagrams by default"); -TUNABLE_INT("net.inet6.ip6.mcast.loop", &in6_mcast_loop); static SYSCTL_NODE(_net_inet6_ip6_mcast, OID_AUTO, filters, CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_ip6_mcast_filters, diff --git a/sys/netinet6/mld6.c b/sys/netinet6/mld6.c index c40ef9e3dee56..2e46208ce73b7 100644 --- a/sys/netinet6/mld6.c +++ b/sys/netinet6/mld6.c @@ -238,14 +238,12 @@ static SYSCTL_NODE(_net_inet6_mld, OID_AUTO, ifinfo, "Per-interface MLDv2 state"); static int mld_v1enable = 1; -SYSCTL_INT(_net_inet6_mld, OID_AUTO, v1enable, CTLFLAG_RW, +SYSCTL_INT(_net_inet6_mld, OID_AUTO, v1enable, CTLFLAG_RWTUN, &mld_v1enable, 0, "Enable fallback to MLDv1"); -TUNABLE_INT("net.inet6.mld.v1enable", &mld_v1enable); static int mld_use_allow = 1; -SYSCTL_INT(_net_inet6_mld, OID_AUTO, use_allow, CTLFLAG_RW, +SYSCTL_INT(_net_inet6_mld, OID_AUTO, use_allow, CTLFLAG_RWTUN, &mld_use_allow, 0, "Use ALLOW/BLOCK for RFC 4604 SSM joins/leaves"); -TUNABLE_INT("net.inet6.mld.use_allow", &mld_use_allow); /* * Packed Router Alert option structure declaration. diff --git a/sys/netpfil/ipfw/ip_fw2.c b/sys/netpfil/ipfw/ip_fw2.c index ecb0f2dc8169a..91900919e140e 100644 --- a/sys/netpfil/ipfw/ip_fw2.c +++ b/sys/netpfil/ipfw/ip_fw2.c @@ -181,7 +181,6 @@ SYSCTL_VNET_PROC(_net_inet_ip_fw, OID_AUTO, tables_max, SYSCTL_INT(_net_inet_ip_fw, OID_AUTO, default_to_accept, CTLFLAG_RDTUN, &default_to_accept, 0, "Make the default rule accept all packets."); -TUNABLE_INT("net.inet.ip.fw.default_to_accept", &default_to_accept); TUNABLE_INT("net.inet.ip.fw.tables_max", (int *)&default_fw_tables); SYSCTL_VNET_INT(_net_inet_ip_fw, OID_AUTO, static_count, CTLFLAG_RD, &VNET_NAME(layer3_chain.n_rules), 0, diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index 094520147cd22..6c971516e5601 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -743,10 +743,8 @@ pf_initialize() struct pf_srchash *sh; u_int i; - TUNABLE_ULONG_FETCH("net.pf.states_hashsize", &pf_hashsize); if (pf_hashsize == 0 || !powerof2(pf_hashsize)) pf_hashsize = PF_HASHSIZ; - TUNABLE_ULONG_FETCH("net.pf.source_nodes_hashsize", &pf_srchashsize); if (pf_srchashsize == 0 || !powerof2(pf_srchashsize)) pf_srchashsize = PF_HASHSIZ / 4; diff --git a/sys/pc98/cbus/sio.c b/sys/pc98/cbus/sio.c index 754d4ad12cbb5..d128658bf2224 100644 --- a/sys/pc98/cbus/sio.c +++ b/sys/pc98/cbus/sio.c @@ -704,7 +704,7 @@ sysctl_machdep_comdefaultrate(SYSCTL_HANDLER_ARGS) return error; } -SYSCTL_PROC(_machdep, OID_AUTO, conspeed, CTLTYPE_INT | CTLFLAG_RW, +SYSCTL_PROC(_machdep, OID_AUTO, conspeed, CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NOFETCH, 0, 0, sysctl_machdep_comdefaultrate, "I", ""); TUNABLE_INT("machdep.conspeed", __DEVOLATILE(int *, &comdefaultrate)); diff --git a/sys/pc98/pc98/machdep.c b/sys/pc98/pc98/machdep.c index b9c6a4ef235c9..f7883c4410824 100644 --- a/sys/pc98/pc98/machdep.c +++ b/sys/pc98/pc98/machdep.c @@ -1113,8 +1113,7 @@ cpu_halt(void) } static int idle_mwait = 1; /* Use MONITOR/MWAIT for short idle. */ -TUNABLE_INT("machdep.idle_mwait", &idle_mwait); -SYSCTL_INT(_machdep, OID_AUTO, idle_mwait, CTLFLAG_RW, &idle_mwait, +SYSCTL_INT(_machdep, OID_AUTO, idle_mwait, CTLFLAG_RWTUN, &idle_mwait, 0, "Use MONITOR/MWAIT for short idle"); #define STATE_RUNNING 0x0 diff --git a/sys/pc98/pc98/pc98_machdep.c b/sys/pc98/pc98/pc98_machdep.c index aed4eaa6f1415..9f9fbcc347f27 100644 --- a/sys/pc98/pc98/pc98_machdep.c +++ b/sys/pc98/pc98/pc98_machdep.c @@ -49,8 +49,7 @@ static int ad_geom_method = AD_GEOM_ADJUST_COMPATIDE; -TUNABLE_INT("machdep.ad_geom_method", &ad_geom_method); -SYSCTL_INT(_machdep, OID_AUTO, ad_geom_method, CTLFLAG_RW, &ad_geom_method, 0, +SYSCTL_INT(_machdep, OID_AUTO, ad_geom_method, CTLFLAG_RWTUN, &ad_geom_method, 0, "IDE disk geometry conversion method"); /* diff --git a/sys/security/mac_biba/mac_biba.c b/sys/security/mac_biba/mac_biba.c index 375b8a3eb795e..b5bf8c32dbef4 100644 --- a/sys/security/mac_biba/mac_biba.c +++ b/sys/security/mac_biba/mac_biba.c @@ -100,43 +100,36 @@ SYSCTL_INT(_security_mac_biba, OID_AUTO, label_size, CTLFLAG_RD, &biba_label_size, 0, "Size of struct mac_biba"); static int biba_enabled = 1; -SYSCTL_INT(_security_mac_biba, OID_AUTO, enabled, CTLFLAG_RW, &biba_enabled, +SYSCTL_INT(_security_mac_biba, OID_AUTO, enabled, CTLFLAG_RWTUN, &biba_enabled, 0, "Enforce MAC/Biba policy"); -TUNABLE_INT("security.mac.biba.enabled", &biba_enabled); static int destroyed_not_inited; SYSCTL_INT(_security_mac_biba, OID_AUTO, destroyed_not_inited, CTLFLAG_RD, &destroyed_not_inited, 0, "Count of labels destroyed but not inited"); static int trust_all_interfaces = 0; -SYSCTL_INT(_security_mac_biba, OID_AUTO, trust_all_interfaces, CTLFLAG_RD, +SYSCTL_INT(_security_mac_biba, OID_AUTO, trust_all_interfaces, CTLFLAG_RDTUN, &trust_all_interfaces, 0, "Consider all interfaces 'trusted' by MAC/Biba"); -TUNABLE_INT("security.mac.biba.trust_all_interfaces", &trust_all_interfaces); static char trusted_interfaces[128]; -SYSCTL_STRING(_security_mac_biba, OID_AUTO, trusted_interfaces, CTLFLAG_RD, +SYSCTL_STRING(_security_mac_biba, OID_AUTO, trusted_interfaces, CTLFLAG_RDTUN, trusted_interfaces, 0, "Interfaces considered 'trusted' by MAC/Biba"); -TUNABLE_STR("security.mac.biba.trusted_interfaces", trusted_interfaces, - sizeof(trusted_interfaces)); static int max_compartments = MAC_BIBA_MAX_COMPARTMENTS; SYSCTL_INT(_security_mac_biba, OID_AUTO, max_compartments, CTLFLAG_RD, &max_compartments, 0, "Maximum supported compartments"); static int ptys_equal = 0; -SYSCTL_INT(_security_mac_biba, OID_AUTO, ptys_equal, CTLFLAG_RW, &ptys_equal, +SYSCTL_INT(_security_mac_biba, OID_AUTO, ptys_equal, CTLFLAG_RWTUN, &ptys_equal, 0, "Label pty devices as biba/equal on create"); -TUNABLE_INT("security.mac.biba.ptys_equal", &ptys_equal); static int interfaces_equal = 1; -SYSCTL_INT(_security_mac_biba, OID_AUTO, interfaces_equal, CTLFLAG_RW, +SYSCTL_INT(_security_mac_biba, OID_AUTO, interfaces_equal, CTLFLAG_RWTUN, &interfaces_equal, 0, "Label network interfaces as biba/equal on create"); -TUNABLE_INT("security.mac.biba.interfaces_equal", &interfaces_equal); static int revocation_enabled = 0; -SYSCTL_INT(_security_mac_biba, OID_AUTO, revocation_enabled, CTLFLAG_RW, +SYSCTL_INT(_security_mac_biba, OID_AUTO, revocation_enabled, CTLFLAG_RWTUN, &revocation_enabled, 0, "Revoke access to objects on relabel"); -TUNABLE_INT("security.mac.biba.revocation_enabled", &revocation_enabled); static int biba_slot; #define SLOT(l) ((struct mac_biba *)mac_label_get((l), biba_slot)) diff --git a/sys/security/mac_bsdextended/mac_bsdextended.c b/sys/security/mac_bsdextended/mac_bsdextended.c index ccbc525552f8f..377fd250ad2db 100644 --- a/sys/security/mac_bsdextended/mac_bsdextended.c +++ b/sys/security/mac_bsdextended/mac_bsdextended.c @@ -76,9 +76,8 @@ static SYSCTL_NODE(_security_mac, OID_AUTO, bsdextended, CTLFLAG_RW, 0, "TrustedBSD extended BSD MAC policy controls"); static int ugidfw_enabled = 1; -SYSCTL_INT(_security_mac_bsdextended, OID_AUTO, enabled, CTLFLAG_RW, +SYSCTL_INT(_security_mac_bsdextended, OID_AUTO, enabled, CTLFLAG_RWTUN, &ugidfw_enabled, 0, "Enforce extended BSD policy"); -TUNABLE_INT("security.mac.bsdextended.enabled", &ugidfw_enabled); static MALLOC_DEFINE(M_MACBSDEXTENDED, "mac_bsdextended", "BSD Extended MAC rule"); diff --git a/sys/security/mac_ifoff/mac_ifoff.c b/sys/security/mac_ifoff/mac_ifoff.c index 7165f905c83d0..28097b502989a 100644 --- a/sys/security/mac_ifoff/mac_ifoff.c +++ b/sys/security/mac_ifoff/mac_ifoff.c @@ -66,25 +66,21 @@ static SYSCTL_NODE(_security_mac, OID_AUTO, ifoff, CTLFLAG_RW, 0, "TrustedBSD mac_ifoff policy controls"); static int ifoff_enabled = 1; -SYSCTL_INT(_security_mac_ifoff, OID_AUTO, enabled, CTLFLAG_RW, +SYSCTL_INT(_security_mac_ifoff, OID_AUTO, enabled, CTLFLAG_RWTUN, &ifoff_enabled, 0, "Enforce ifoff policy"); -TUNABLE_INT("security.mac.ifoff.enabled", &ifoff_enabled); static int ifoff_lo_enabled = 1; -SYSCTL_INT(_security_mac_ifoff, OID_AUTO, lo_enabled, CTLFLAG_RW, +SYSCTL_INT(_security_mac_ifoff, OID_AUTO, lo_enabled, CTLFLAG_RWTUN, &ifoff_lo_enabled, 0, "Enable loopback interfaces"); -TUNABLE_INT("security.mac.ifoff.lo_enabled", &ifoff_lo_enabled); static int ifoff_other_enabled = 0; -SYSCTL_INT(_security_mac_ifoff, OID_AUTO, other_enabled, CTLFLAG_RW, +SYSCTL_INT(_security_mac_ifoff, OID_AUTO, other_enabled, CTLFLAG_RWTUN, &ifoff_other_enabled, 0, "Enable other interfaces"); -TUNABLE_INT("security.mac.ifoff.other_enabled", &ifoff_other_enabled); static int ifoff_bpfrecv_enabled = 0; -SYSCTL_INT(_security_mac_ifoff, OID_AUTO, bpfrecv_enabled, CTLFLAG_RW, +SYSCTL_INT(_security_mac_ifoff, OID_AUTO, bpfrecv_enabled, CTLFLAG_RWTUN, &ifoff_bpfrecv_enabled, 0, "Enable BPF reception even when interface " "is disabled"); -TUNABLE_INT("security.mac.ifoff.bpfrecv.enabled", &ifoff_bpfrecv_enabled); static int ifnet_check_outgoing(struct ifnet *ifp) diff --git a/sys/security/mac_lomac/mac_lomac.c b/sys/security/mac_lomac/mac_lomac.c index b2b9f74afb55f..cf66423a91c6f 100644 --- a/sys/security/mac_lomac/mac_lomac.c +++ b/sys/security/mac_lomac/mac_lomac.c @@ -101,34 +101,28 @@ SYSCTL_INT(_security_mac_lomac, OID_AUTO, label_size, CTLFLAG_RD, &lomac_label_size, 0, "Size of struct mac_lomac"); static int lomac_enabled = 1; -SYSCTL_INT(_security_mac_lomac, OID_AUTO, enabled, CTLFLAG_RW, +SYSCTL_INT(_security_mac_lomac, OID_AUTO, enabled, CTLFLAG_RWTUN, &lomac_enabled, 0, "Enforce MAC/LOMAC policy"); -TUNABLE_INT("security.mac.lomac.enabled", &lomac_enabled); static int destroyed_not_inited; SYSCTL_INT(_security_mac_lomac, OID_AUTO, destroyed_not_inited, CTLFLAG_RD, &destroyed_not_inited, 0, "Count of labels destroyed but not inited"); static int trust_all_interfaces = 0; -SYSCTL_INT(_security_mac_lomac, OID_AUTO, trust_all_interfaces, CTLFLAG_RD, +SYSCTL_INT(_security_mac_lomac, OID_AUTO, trust_all_interfaces, CTLFLAG_RDTUN, &trust_all_interfaces, 0, "Consider all interfaces 'trusted' by MAC/LOMAC"); -TUNABLE_INT("security.mac.lomac.trust_all_interfaces", &trust_all_interfaces); static char trusted_interfaces[128]; -SYSCTL_STRING(_security_mac_lomac, OID_AUTO, trusted_interfaces, CTLFLAG_RD, +SYSCTL_STRING(_security_mac_lomac, OID_AUTO, trusted_interfaces, CTLFLAG_RDTUN, trusted_interfaces, 0, "Interfaces considered 'trusted' by MAC/LOMAC"); -TUNABLE_STR("security.mac.lomac.trusted_interfaces", trusted_interfaces, - sizeof(trusted_interfaces)); static int ptys_equal = 0; -SYSCTL_INT(_security_mac_lomac, OID_AUTO, ptys_equal, CTLFLAG_RW, +SYSCTL_INT(_security_mac_lomac, OID_AUTO, ptys_equal, CTLFLAG_RWTUN, &ptys_equal, 0, "Label pty devices as lomac/equal on create"); -TUNABLE_INT("security.mac.lomac.ptys_equal", &ptys_equal); static int revocation_enabled = 1; -SYSCTL_INT(_security_mac_lomac, OID_AUTO, revocation_enabled, CTLFLAG_RW, +SYSCTL_INT(_security_mac_lomac, OID_AUTO, revocation_enabled, CTLFLAG_RWTUN, &revocation_enabled, 0, "Revoke access to objects on relabel"); -TUNABLE_INT("security.mac.lomac.revocation_enabled", &revocation_enabled); static int lomac_slot; #define SLOT(l) ((struct mac_lomac *)mac_label_get((l), lomac_slot)) diff --git a/sys/security/mac_mls/mac_mls.c b/sys/security/mac_mls/mac_mls.c index d7ca5a55362f9..6a074d0279bdb 100644 --- a/sys/security/mac_mls/mac_mls.c +++ b/sys/security/mac_mls/mac_mls.c @@ -101,23 +101,20 @@ SYSCTL_INT(_security_mac_mls, OID_AUTO, label_size, CTLFLAG_RD, &mls_label_size, 0, "Size of struct mac_mls"); static int mls_enabled = 1; -SYSCTL_INT(_security_mac_mls, OID_AUTO, enabled, CTLFLAG_RW, &mls_enabled, 0, +SYSCTL_INT(_security_mac_mls, OID_AUTO, enabled, CTLFLAG_RWTUN, &mls_enabled, 0, "Enforce MAC/MLS policy"); -TUNABLE_INT("security.mac.mls.enabled", &mls_enabled); static int destroyed_not_inited; SYSCTL_INT(_security_mac_mls, OID_AUTO, destroyed_not_inited, CTLFLAG_RD, &destroyed_not_inited, 0, "Count of labels destroyed but not inited"); static int ptys_equal = 0; -SYSCTL_INT(_security_mac_mls, OID_AUTO, ptys_equal, CTLFLAG_RW, +SYSCTL_INT(_security_mac_mls, OID_AUTO, ptys_equal, CTLFLAG_RWTUN, &ptys_equal, 0, "Label pty devices as mls/equal on create"); -TUNABLE_INT("security.mac.mls.ptys_equal", &ptys_equal); static int revocation_enabled = 0; -SYSCTL_INT(_security_mac_mls, OID_AUTO, revocation_enabled, CTLFLAG_RW, +SYSCTL_INT(_security_mac_mls, OID_AUTO, revocation_enabled, CTLFLAG_RWTUN, &revocation_enabled, 0, "Revoke access to objects on relabel"); -TUNABLE_INT("security.mac.mls.revocation_enabled", &revocation_enabled); static int max_compartments = MAC_MLS_MAX_COMPARTMENTS; SYSCTL_INT(_security_mac_mls, OID_AUTO, max_compartments, CTLFLAG_RD, diff --git a/sys/security/mac_portacl/mac_portacl.c b/sys/security/mac_portacl/mac_portacl.c index 1dbd1996e562e..17427ee200f3f 100644 --- a/sys/security/mac_portacl/mac_portacl.c +++ b/sys/security/mac_portacl/mac_portacl.c @@ -87,27 +87,21 @@ static SYSCTL_NODE(_security_mac, OID_AUTO, portacl, CTLFLAG_RW, 0, "TrustedBSD mac_portacl policy controls"); static int portacl_enabled = 1; -SYSCTL_INT(_security_mac_portacl, OID_AUTO, enabled, CTLFLAG_RW, +SYSCTL_INT(_security_mac_portacl, OID_AUTO, enabled, CTLFLAG_RWTUN, &portacl_enabled, 0, "Enforce portacl policy"); -TUNABLE_INT("security.mac.portacl.enabled", &portacl_enabled); static int portacl_suser_exempt = 1; -SYSCTL_INT(_security_mac_portacl, OID_AUTO, suser_exempt, CTLFLAG_RW, +SYSCTL_INT(_security_mac_portacl, OID_AUTO, suser_exempt, CTLFLAG_RWTUN, &portacl_suser_exempt, 0, "Privilege permits binding of any port"); -TUNABLE_INT("security.mac.portacl.suser_exempt", - &portacl_suser_exempt); static int portacl_autoport_exempt = 1; -SYSCTL_INT(_security_mac_portacl, OID_AUTO, autoport_exempt, CTLFLAG_RW, +SYSCTL_INT(_security_mac_portacl, OID_AUTO, autoport_exempt, CTLFLAG_RWTUN, &portacl_autoport_exempt, 0, "Allow automatic allocation through " "binding port 0 if not IP_PORTRANGELOW"); -TUNABLE_INT("security.mac.portacl.autoport_exempt", - &portacl_autoport_exempt); static int portacl_port_high = 1023; -SYSCTL_INT(_security_mac_portacl, OID_AUTO, port_high, CTLFLAG_RW, +SYSCTL_INT(_security_mac_portacl, OID_AUTO, port_high, CTLFLAG_RWTUN, &portacl_port_high, 0, "Highest port to enforce for"); -TUNABLE_INT("security.mac.portacl.port_high", &portacl_port_high); static MALLOC_DEFINE(M_PORTACL, "portacl_rule", "Rules for mac_portacl"); diff --git a/sys/sparc64/pci/psycho.c b/sys/sparc64/pci/psycho.c index ec8d90fe22cb4..57e0f4817b5ae 100644 --- a/sys/sparc64/pci/psycho.c +++ b/sys/sparc64/pci/psycho.c @@ -167,7 +167,6 @@ EARLY_DRIVER_MODULE(psycho, nexus, psycho_driver, psycho_devclass, NULL, NULL, static SYSCTL_NODE(_hw, OID_AUTO, psycho, CTLFLAG_RD, 0, "psycho parameters"); static u_int psycho_powerfail = 1; -TUNABLE_INT("hw.psycho.powerfail", &psycho_powerfail); SYSCTL_UINT(_hw_psycho, OID_AUTO, powerfail, CTLFLAG_RDTUN, &psycho_powerfail, 0, "powerfail action (0: none, 1: shutdown (default), 2: debugger)"); diff --git a/sys/sys/malloc.h b/sys/sys/malloc.h index 8f51606b72ffb..dcb4290a8acb7 100644 --- a/sys/sys/malloc.h +++ b/sys/sys/malloc.h @@ -134,7 +134,7 @@ struct malloc_type_header { struct malloc_type type[1] = { \ { NULL, M_MAGIC, shortdesc, NULL } \ }; \ - SYSINIT(type##_init, SI_SUB_KMEM, SI_ORDER_SECOND, malloc_init, \ + SYSINIT(type##_init, SI_SUB_KMEM, SI_ORDER_THIRD, malloc_init, \ type); \ SYSUNINIT(type##_uninit, SI_SUB_KMEM, SI_ORDER_ANY, \ malloc_uninit, type) diff --git a/sys/sys/param.h b/sys/sys/param.h index 4b487b30e400f..ccbb70ab9cf0f 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1100023 /* Master, propagated to newvers */ +#define __FreeBSD_version 1100024 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h index 02faa934bef2d..0473eb72ebb1c 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -83,7 +83,7 @@ struct ctlname { #define CTLFLAG_DYN 0x02000000 /* Dynamic oid - can be freed */ #define CTLFLAG_SKIP 0x01000000 /* Skip this sysctl when listing */ #define CTLMASK_SECURE 0x00F00000 /* Secure level */ -#define CTLFLAG_TUN 0x00080000 /* Tunable variable */ +#define CTLFLAG_TUN 0x00080000 /* Default value is loaded from getenv() */ #define CTLFLAG_RDTUN (CTLFLAG_RD|CTLFLAG_TUN) #define CTLFLAG_RWTUN (CTLFLAG_RW|CTLFLAG_TUN) #define CTLFLAG_MPSAFE 0x00040000 /* Handler is MP safe */ @@ -92,6 +92,7 @@ struct ctlname { #define CTLFLAG_CAPRD 0x00008000 /* Can be read in capability mode */ #define CTLFLAG_CAPWR 0x00004000 /* Can be written in capability mode */ #define CTLFLAG_STATS 0x00002000 /* Statistics, not a tuneable */ +#define CTLFLAG_NOFETCH 0x00001000 /* Don't fetch tunable from getenv() */ #define CTLFLAG_CAPRW (CTLFLAG_CAPRD|CTLFLAG_CAPWR) /* @@ -161,6 +162,7 @@ SLIST_HEAD(sysctl_oid_list, sysctl_oid); * be hidden behind it, expanded by the handler. */ struct sysctl_oid { + struct sysctl_oid_list oid_children; struct sysctl_oid_list *oid_parent; SLIST_ENTRY(sysctl_oid) oid_link; int oid_number; @@ -200,14 +202,16 @@ void sysctl_register_oid(struct sysctl_oid *oidp); void sysctl_unregister_oid(struct sysctl_oid *oidp); /* Declare a static oid to allow child oids to be added to it. */ -#define SYSCTL_DECL(name) \ - extern struct sysctl_oid_list sysctl_##name##_children +#define SYSCTL_DECL(name) \ + extern struct sysctl_oid sysctl__##name /* Hide these in macros. */ -#define SYSCTL_CHILDREN(oid_ptr) \ - (struct sysctl_oid_list *)(oid_ptr)->oid_arg1 -#define SYSCTL_CHILDREN_SET(oid_ptr, val) (oid_ptr)->oid_arg1 = (val) -#define SYSCTL_STATIC_CHILDREN(oid_name) (&sysctl_##oid_name##_children) +#define SYSCTL_CHILDREN(oid_ptr) (&(oid_ptr)->oid_children) +#define SYSCTL_PARENT(oid_ptr) \ + (((oid_ptr)->oid_parent != &sysctl__children) ? \ + __containerof((oid_ptr)->oid_parent, struct sysctl_oid, \ + oid_children) : (struct sysctl_oid *)NULL) +#define SYSCTL_STATIC_CHILDREN(oid_name) (&sysctl__##oid_name.oid_children) /* === Structs and macros related to context handling. === */ @@ -220,7 +224,7 @@ struct sysctl_ctx_entry { TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); #define SYSCTL_NODE_CHILDREN(parent, name) \ - sysctl_##parent##_##name##_children + sysctl__##parent##_##name.oid_children /* * These macros provide type safety for sysctls. SYSCTL_ALLOWED_TYPES() @@ -275,29 +279,47 @@ SYSCTL_ALLOWED_TYPES(UINT64, uint64_t *a; unsigned long long *b; ); #define __DESCR(d) "" #endif -/* This constructs a "raw" MIB oid. */ -#define SYSCTL_OID(parent, nbr, name, kind, a1, a2, handler, fmt, descr)\ - static struct sysctl_oid sysctl__##parent##_##name = { \ - .oid_parent = &sysctl_##parent##_children, \ +/* This macro is only for internal use */ +#define SYSCTL_OID_RAW(id, parent_child_head, nbr, name, kind, a1, a2, handler, fmt, descr) \ + struct sysctl_oid id = { \ + .oid_parent = (parent_child_head), \ + .oid_children = SLIST_HEAD_INITIALIZER(&id.oid_children), \ .oid_number = (nbr), \ .oid_kind = (kind), \ .oid_arg1 = (a1), \ .oid_arg2 = (a2), \ - .oid_name = #name, \ + .oid_name = (name), \ .oid_handler = (handler), \ .oid_fmt = (fmt), \ .oid_descr = __DESCR(descr) \ }; \ - DATA_SET(sysctl_set, sysctl__##parent##_##name) + DATA_SET(sysctl_set, id) + +/* This constructs a static "raw" MIB oid. */ +#define SYSCTL_OID(parent, nbr, name, kind, a1, a2, handler, fmt, descr) \ + static SYSCTL_OID_RAW(sysctl__##parent##_##name, \ + SYSCTL_CHILDREN(&sysctl__##parent), \ + nbr, #name, kind, a1, a2, handler, fmt, descr) + +/* This constructs a global "raw" MIB oid. */ +#define SYSCTL_OID_GLOBAL(parent, nbr, name, kind, a1, a2, handler, fmt, descr) \ + SYSCTL_OID_RAW(sysctl__##parent##_##name, \ + SYSCTL_CHILDREN(&sysctl__##parent), \ + nbr, #name, kind, a1, a2, handler, fmt, descr) #define SYSCTL_ADD_OID(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, descr) \ sysctl_add_oid(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, __DESCR(descr)) +/* This constructs a root node from which other nodes can hang. */ +#define SYSCTL_ROOT_NODE(nbr, name, access, handler, descr) \ + SYSCTL_OID_RAW(sysctl___##name, &sysctl__children, \ + nbr, #name, CTLTYPE_NODE|(access), NULL, 0, \ + handler, "N", descr) + /* This constructs a node from which other oids can hang. */ #define SYSCTL_NODE(parent, nbr, name, access, handler, descr) \ - struct sysctl_oid_list SYSCTL_NODE_CHILDREN(parent, name); \ - SYSCTL_OID(parent, nbr, name, CTLTYPE_NODE|(access), \ - (void*)&SYSCTL_NODE_CHILDREN(parent, name), 0, handler, "N", descr) + SYSCTL_OID_GLOBAL(parent, nbr, name, CTLTYPE_NODE|(access), \ + NULL, 0, handler, "N", descr) #define SYSCTL_ADD_NODE(ctx, parent, nbr, name, access, handler, descr) \ sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_NODE|(access), \ diff --git a/sys/vm/memguard.c b/sys/vm/memguard.c index 1d3b4125a149c..d502ca569bdec 100644 --- a/sys/vm/memguard.c +++ b/sys/vm/memguard.c @@ -67,7 +67,7 @@ static SYSCTL_NODE(_vm, OID_AUTO, memguard, CTLFLAG_RW, NULL, "MemGuard data"); * reserved for MemGuard. */ static u_int vm_memguard_divisor; -SYSCTL_UINT(_vm_memguard, OID_AUTO, divisor, CTLFLAG_RDTUN, +SYSCTL_UINT(_vm_memguard, OID_AUTO, divisor, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &vm_memguard_divisor, 0, "(kmem_size/memguard_divisor) == memguard submap size"); @@ -132,8 +132,7 @@ SYSCTL_ULONG(_vm_memguard, OID_AUTO, fail_pgs, CTLFLAG_RD, #define MG_GUARD_ALLLARGE 0x002 #define MG_GUARD_NOFREE 0x004 static int memguard_options = MG_GUARD_AROUND; -TUNABLE_INT("vm.memguard.options", &memguard_options); -SYSCTL_INT(_vm_memguard, OID_AUTO, options, CTLFLAG_RW, +SYSCTL_INT(_vm_memguard, OID_AUTO, options, CTLFLAG_RWTUN, &memguard_options, 0, "MemGuard options:\n" "\t0x001 - add guard pages around each allocation\n" @@ -149,8 +148,7 @@ SYSCTL_ULONG(_vm_memguard, OID_AUTO, minsize_reject, CTLFLAG_RD, static u_int memguard_frequency; static u_long memguard_frequency_hits; -TUNABLE_INT("vm.memguard.frequency", &memguard_frequency); -SYSCTL_UINT(_vm_memguard, OID_AUTO, frequency, CTLFLAG_RW, +SYSCTL_UINT(_vm_memguard, OID_AUTO, frequency, CTLFLAG_RWTUN, &memguard_frequency, 0, "Times in 100000 that MemGuard will randomly run"); SYSCTL_ULONG(_vm_memguard, OID_AUTO, frequency_hits, CTLFLAG_RD, &memguard_frequency_hits, 0, "# times MemGuard randomly chose"); diff --git a/sys/vm/redzone.c b/sys/vm/redzone.c index e4b5f6ccc9c0d..a66a793f27f05 100644 --- a/sys/vm/redzone.c +++ b/sys/vm/redzone.c @@ -41,8 +41,7 @@ static u_long redzone_extra_mem = 0; SYSCTL_ULONG(_vm_redzone, OID_AUTO, extra_mem, CTLFLAG_RD, &redzone_extra_mem, 0, "Extra memory allocated by redzone"); static int redzone_panic = 0; -TUNABLE_INT("vm.redzone.panic", &redzone_panic); -SYSCTL_INT(_vm_redzone, OID_AUTO, panic, CTLFLAG_RW, &redzone_panic, 0, +SYSCTL_INT(_vm_redzone, OID_AUTO, panic, CTLFLAG_RWTUN, &redzone_panic, 0, "Panic when buffer corruption is detected"); #define REDZONE_CHSIZE (16) diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c index 62f4912a3dc48..81b714a9f32d0 100644 --- a/sys/vm/uma_core.c +++ b/sys/vm/uma_core.c @@ -281,8 +281,7 @@ SYSCTL_PROC(_vm, OID_AUTO, zone_stats, CTLFLAG_RD|CTLTYPE_STRUCT, 0, 0, sysctl_vm_zone_stats, "s,struct uma_type_header", "Zone Stats"); static int zone_warnings = 1; -TUNABLE_INT("vm.zone_warnings", &zone_warnings); -SYSCTL_INT(_vm, OID_AUTO, zone_warnings, CTLFLAG_RW, &zone_warnings, 0, +SYSCTL_INT(_vm, OID_AUTO, zone_warnings, CTLFLAG_RWTUN, &zone_warnings, 0, "Warn when UMA zones becomes full"); /* diff --git a/sys/vm/vm_init.c b/sys/vm/vm_init.c index 30faa5a2aeb22..be1038758824a 100644 --- a/sys/vm/vm_init.c +++ b/sys/vm/vm_init.c @@ -91,8 +91,7 @@ __FBSDID("$FreeBSD$"); long physmem; static int exec_map_entries = 16; -TUNABLE_INT("vm.exec_map_entries", &exec_map_entries); -SYSCTL_INT(_vm, OID_AUTO, exec_map_entries, CTLFLAG_RD, &exec_map_entries, 0, +SYSCTL_INT(_vm, OID_AUTO, exec_map_entries, CTLFLAG_RDTUN, &exec_map_entries, 0, "Maximum number of simultaneous execs"); /* diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 62eb393144088..b5108e2917563 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -3471,8 +3471,7 @@ vm_map_stack_locked(vm_map_t map, vm_offset_t addrbos, vm_size_t max_ssize, } static int stack_guard_page = 0; -TUNABLE_INT("security.bsd.stack_guard_page", &stack_guard_page); -SYSCTL_INT(_security_bsd, OID_AUTO, stack_guard_page, CTLFLAG_RW, +SYSCTL_INT(_security_bsd, OID_AUTO, stack_guard_page, CTLFLAG_RWTUN, &stack_guard_page, 0, "Insert stack guard page ahead of the growable segments."); diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c index a5248399ab9a2..e94090c53e88e 100644 --- a/sys/vm/vm_mmap.c +++ b/sys/vm/vm_mmap.c @@ -92,9 +92,8 @@ __FBSDID("$FreeBSD$"); #endif int old_mlock = 0; -SYSCTL_INT(_vm, OID_AUTO, old_mlock, CTLFLAG_RW | CTLFLAG_TUN, &old_mlock, 0, +SYSCTL_INT(_vm, OID_AUTO, old_mlock, CTLFLAG_RWTUN, &old_mlock, 0, "Do not apply RLIMIT_MEMLOCK on mlockall"); -TUNABLE_INT("vm.old_mlock", &old_mlock); #ifdef MAP_32BIT #define MAP_32BIT_MAX_ADDR ((vm_offset_t)1 << 31) diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index 49c3edeeacf38..4e30a3f5aded0 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -134,8 +134,7 @@ long first_page; int vm_page_zero_count; static int boot_pages = UMA_BOOT_PAGES; -TUNABLE_INT("vm.boot_pages", &boot_pages); -SYSCTL_INT(_vm, OID_AUTO, boot_pages, CTLFLAG_RD, &boot_pages, 0, +SYSCTL_INT(_vm, OID_AUTO, boot_pages, CTLFLAG_RDTUN, &boot_pages, 0, "number of pages allocated for bootstrapping the VM system"); static int pa_tryrelock_restart; diff --git a/sys/vm/vm_radix.c b/sys/vm/vm_radix.c index bb45ba0d801c3..4f4b6d24d526a 100644 --- a/sys/vm/vm_radix.c +++ b/sys/vm/vm_radix.c @@ -302,7 +302,7 @@ vm_radix_reserve_kva(void *arg __unused) sizeof(struct vm_radix_node)))) panic("%s: unable to reserve KVA", __func__); } -SYSINIT(vm_radix_reserve_kva, SI_SUB_KMEM, SI_ORDER_SECOND, +SYSINIT(vm_radix_reserve_kva, SI_SUB_KMEM, SI_ORDER_THIRD, vm_radix_reserve_kva, NULL); #endif diff --git a/sys/vm/vm_zeroidle.c b/sys/vm/vm_zeroidle.c index 458539eb1782f..dac4abe3a46eb 100644 --- a/sys/vm/vm_zeroidle.c +++ b/sys/vm/vm_zeroidle.c @@ -55,10 +55,9 @@ __FBSDID("$FreeBSD$"); #include static int idlezero_enable_default = 0; -TUNABLE_INT("vm.idlezero_enable", &idlezero_enable_default); /* Defer setting the enable flag until the kthread is running. */ static int idlezero_enable = 0; -SYSCTL_INT(_vm, OID_AUTO, idlezero_enable, CTLFLAG_RW, &idlezero_enable, 0, +SYSCTL_INT(_vm, OID_AUTO, idlezero_enable, CTLFLAG_RWTUN, &idlezero_enable, 0, "Allow the kernel to use idle cpu cycles to zero-out pages"); /* * Implement the pre-zeroed page mechanism. diff --git a/sys/x86/cpufreq/hwpstate.c b/sys/x86/cpufreq/hwpstate.c index e86e31aab4cda..d4c70b773c703 100644 --- a/sys/x86/cpufreq/hwpstate.c +++ b/sys/x86/cpufreq/hwpstate.c @@ -118,9 +118,8 @@ static int hwpstate_get_info_from_msr(device_t dev); static int hwpstate_goto_pstate(device_t dev, int pstate_id); static int hwpstate_verbose = 0; -SYSCTL_INT(_debug, OID_AUTO, hwpstate_verbose, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_debug, OID_AUTO, hwpstate_verbose, CTLFLAG_RWTUN, &hwpstate_verbose, 0, "Debug hwpstate"); -TUNABLE_INT("debug.hwpstate_verbose", &hwpstate_verbose); static device_method_t hwpstate_methods[] = { /* Device interface */ diff --git a/sys/x86/iommu/intel_utils.c b/sys/x86/iommu/intel_utils.c index e221a1e6546bc..444329c581fe2 100644 --- a/sys/x86/iommu/intel_utils.c +++ b/sys/x86/iommu/intel_utils.c @@ -549,17 +549,16 @@ dmar_barrier_exit(struct dmar_unit *dmar, u_int barrier_id) int dmar_match_verbose; -static SYSCTL_NODE(_hw, OID_AUTO, dmar, CTLFLAG_RD, NULL, - ""); -SYSCTL_INT(_hw_dmar, OID_AUTO, tbl_pagecnt, CTLFLAG_RD | CTLFLAG_TUN, +static SYSCTL_NODE(_hw, OID_AUTO, dmar, CTLFLAG_RD, NULL, ""); +SYSCTL_INT(_hw_dmar, OID_AUTO, tbl_pagecnt, CTLFLAG_RD, &dmar_tbl_pagecnt, 0, "Count of pages used for DMAR pagetables"); -SYSCTL_INT(_hw_dmar, OID_AUTO, match_verbose, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_dmar, OID_AUTO, match_verbose, CTLFLAG_RWTUN, &dmar_match_verbose, 0, "Verbose matching of the PCI devices to DMAR paths"); #ifdef INVARIANTS int dmar_check_free; -SYSCTL_INT(_hw_dmar, OID_AUTO, check_free, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_dmar, OID_AUTO, check_free, CTLFLAG_RWTUN, &dmar_check_free, 0, "Check the GPA RBtree for free_down and free_after validity"); #endif diff --git a/sys/x86/pci/pci_bus.c b/sys/x86/pci/pci_bus.c index 88cabc724fe3b..f64659eec2ada 100644 --- a/sys/x86/pci/pci_bus.c +++ b/sys/x86/pci/pci_bus.c @@ -575,7 +575,6 @@ legacy_pcib_write_ivar(device_t dev, device_t child, int which, SYSCTL_DECL(_hw_pci); static unsigned long host_mem_start = 0x80000000; -TUNABLE_ULONG("hw.pci.host_mem_start", &host_mem_start); SYSCTL_ULONG(_hw_pci, OID_AUTO, host_mem_start, CTLFLAG_RDTUN, &host_mem_start, 0, "Limit the host bridge memory to being above this address."); diff --git a/sys/x86/x86/dump_machdep.c b/sys/x86/x86/dump_machdep.c index 5c874f4847b66..30fa719467ffc 100644 --- a/sys/x86/x86/dump_machdep.c +++ b/sys/x86/x86/dump_machdep.c @@ -53,8 +53,7 @@ __FBSDID("$FreeBSD$"); CTASSERT(sizeof(struct kerneldumpheader) == 512); int do_minidump = 1; -TUNABLE_INT("debug.minidump", &do_minidump); -SYSCTL_INT(_debug, OID_AUTO, minidump, CTLFLAG_RW, &do_minidump, 0, +SYSCTL_INT(_debug, OID_AUTO, minidump, CTLFLAG_RWTUN, &do_minidump, 0, "Enable mini crash dumps"); /* diff --git a/sys/x86/x86/io_apic.c b/sys/x86/x86/io_apic.c index ec469ad685e74..5667120661b40 100644 --- a/sys/x86/x86/io_apic.c +++ b/sys/x86/x86/io_apic.c @@ -134,7 +134,6 @@ static SYSCTL_NODE(_hw, OID_AUTO, apic, CTLFLAG_RD, 0, "APIC options"); static int enable_extint; SYSCTL_INT(_hw_apic, OID_AUTO, enable_extint, CTLFLAG_RDTUN, &enable_extint, 0, "Enable the ExtINT pin in the first I/O APIC"); -TUNABLE_INT("hw.apic.enable_extint", &enable_extint); static __inline void _ioapic_eoi_source(struct intsrc *isrc) diff --git a/sys/x86/x86/mca.c b/sys/x86/x86/mca.c index 8a0d2b12e9c6e..347d570a1fa2f 100644 --- a/sys/x86/x86/mca.c +++ b/sys/x86/x86/mca.c @@ -92,12 +92,10 @@ static SYSCTL_NODE(_hw, OID_AUTO, mca, CTLFLAG_RD, NULL, "Machine Check Architecture"); static int mca_enabled = 1; -TUNABLE_INT("hw.mca.enabled", &mca_enabled); SYSCTL_INT(_hw_mca, OID_AUTO, enabled, CTLFLAG_RDTUN, &mca_enabled, 0, "Administrative toggle for machine check support"); static int amd10h_L1TP = 1; -TUNABLE_INT("hw.mca.amd10h_L1TP", &amd10h_L1TP); SYSCTL_INT(_hw_mca, OID_AUTO, amd10h_L1TP, CTLFLAG_RDTUN, &amd10h_L1TP, 0, "Administrative toggle for logging of level one TLB parity (L1TP) errors"); diff --git a/sys/x86/x86/tsc.c b/sys/x86/x86/tsc.c index 2a6c81d786d3f..54c4d02497cf4 100644 --- a/sys/x86/x86/tsc.c +++ b/sys/x86/x86/tsc.c @@ -58,34 +58,28 @@ static eventhandler_tag tsc_levels_tag, tsc_pre_tag, tsc_post_tag; SYSCTL_INT(_kern_timecounter, OID_AUTO, invariant_tsc, CTLFLAG_RDTUN, &tsc_is_invariant, 0, "Indicates whether the TSC is P-state invariant"); -TUNABLE_INT("kern.timecounter.invariant_tsc", &tsc_is_invariant); #ifdef SMP int smp_tsc; SYSCTL_INT(_kern_timecounter, OID_AUTO, smp_tsc, CTLFLAG_RDTUN, &smp_tsc, 0, "Indicates whether the TSC is safe to use in SMP mode"); -TUNABLE_INT("kern.timecounter.smp_tsc", &smp_tsc); int smp_tsc_adjust = 0; SYSCTL_INT(_kern_timecounter, OID_AUTO, smp_tsc_adjust, CTLFLAG_RDTUN, &smp_tsc_adjust, 0, "Try to adjust TSC on APs to match BSP"); -TUNABLE_INT("kern.timecounter.smp_tsc_adjust", &smp_tsc_adjust); #endif static int tsc_shift = 1; SYSCTL_INT(_kern_timecounter, OID_AUTO, tsc_shift, CTLFLAG_RDTUN, &tsc_shift, 0, "Shift to pre-apply for the maximum TSC frequency"); -TUNABLE_INT("kern.timecounter.tsc_shift", &tsc_shift); static int tsc_disabled; SYSCTL_INT(_machdep, OID_AUTO, disable_tsc, CTLFLAG_RDTUN, &tsc_disabled, 0, "Disable x86 Time Stamp Counter"); -TUNABLE_INT("machdep.disable_tsc", &tsc_disabled); static int tsc_skip_calibration; SYSCTL_INT(_machdep, OID_AUTO, disable_tsc_calibration, CTLFLAG_RDTUN, &tsc_skip_calibration, 0, "Disable TSC frequency calibration"); -TUNABLE_INT("machdep.disable_tsc_calibration", &tsc_skip_calibration); static void tsc_freq_changed(void *arg, const struct cf_level *level, int status); -- cgit v1.3 From 37a107a407cdb47ee0f4c4337e369e9973b34076 Mon Sep 17 00:00:00 2001 From: Glen Barber Date: Fri, 27 Jun 2014 22:05:21 +0000 Subject: Revert r267961, r267973: These changes prevent sysctl(8) from returning proper output, such as: 1) no output from sysctl(8) 2) erroneously returning ENOMEM with tools like truss(1) or uname(1) truss: can not get etype: Cannot allocate memory --- sys/amd64/acpica/acpi_machdep.c | 5 +- sys/amd64/amd64/amd64_mem.c | 1 + sys/amd64/amd64/machdep.c | 3 +- sys/amd64/amd64/mp_watchdog.c | 3 +- sys/amd64/amd64/pmap.c | 8 +- sys/amd64/amd64/sys_machdep.c | 1 + sys/amd64/amd64/trap.c | 10 +- sys/amd64/pci/pci_cfgreg.c | 1 + sys/amd64/vmm/vmm.c | 1 + sys/arm/arm/busdma_machdep-v6.c | 6 +- sys/arm/arm/busdma_machdep.c | 6 +- sys/arm/arm/dump_machdep.c | 3 +- sys/arm/arm/platform.c | 4 +- sys/arm/arm/pmap-v6.c | 2 +- sys/arm/freescale/imx/imx6_anatop.c | 11 +- sys/arm/xscale/ixp425/if_npe.c | 12 +- sys/arm/xscale/ixp425/ixp425_npe.c | 3 +- sys/arm/xscale/ixp425/ixp425_qmgr.c | 5 +- sys/cam/ata/ata_da.c | 24 ++- sys/cam/ata/ata_pmp.c | 9 +- sys/cam/cam.c | 1 + sys/cam/cam_xpt.c | 8 +- sys/cam/ctl/ctl.c | 2 + sys/cam/ctl/ctl_backend_block.c | 3 +- sys/cam/ctl/ctl_frontend_iscsi.c | 4 + sys/cam/scsi/scsi_cd.c | 9 +- sys/cam/scsi/scsi_da.c | 12 +- sys/cam/scsi/scsi_enc_safte.c | 3 +- sys/cam/scsi/scsi_sa.c | 5 +- sys/cam/scsi/scsi_xpt.c | 3 +- .../compat/opensolaris/kern/opensolaris_kstat.c | 2 +- .../contrib/opensolaris/uts/common/fs/zfs/arc.c | 2 + .../contrib/opensolaris/uts/common/fs/zfs/ddt.c | 3 +- .../contrib/opensolaris/uts/common/fs/zfs/dmu.c | 4 +- .../opensolaris/uts/common/fs/zfs/dmu_zfetch.c | 6 +- .../opensolaris/uts/common/fs/zfs/dsl_pool.c | 4 + .../opensolaris/uts/common/fs/zfs/dsl_scan.c | 27 ++- .../opensolaris/uts/common/fs/zfs/metaslab.c | 23 ++- .../contrib/opensolaris/uts/common/fs/zfs/spa.c | 3 +- .../opensolaris/uts/common/fs/zfs/spa_misc.c | 6 + .../opensolaris/uts/common/fs/zfs/trim_map.c | 9 + .../contrib/opensolaris/uts/common/fs/zfs/txg.c | 3 +- .../opensolaris/uts/common/fs/zfs/vdev_cache.c | 3 + .../opensolaris/uts/common/fs/zfs/vdev_geom.c | 10 +- .../opensolaris/uts/common/fs/zfs/vdev_mirror.c | 16 +- .../opensolaris/uts/common/fs/zfs/vdev_queue.c | 20 ++- .../opensolaris/uts/common/fs/zfs/zfs_ioctl.c | 3 +- .../opensolaris/uts/common/fs/zfs/zfs_vfsops.c | 3 +- .../contrib/opensolaris/uts/common/fs/zfs/zil.c | 5 +- .../contrib/opensolaris/uts/common/fs/zfs/zio.c | 5 + .../contrib/opensolaris/uts/common/fs/zfs/zvol.c | 1 + sys/cddl/dev/dtrace/dtrace_sysctl.c | 3 +- sys/compat/ia32/ia32_sysvec.c | 9 +- sys/compat/x86bios/x86bios.c | 6 +- sys/dev/aac/aac_pci.c | 1 + sys/dev/acpica/Osd/OsdSchedule.c | 2 + sys/dev/acpica/acpi_cpu.c | 1 + sys/dev/acpica/acpi_ec.c | 9 +- sys/dev/amr/amr_pci.c | 1 + sys/dev/ata/ata-all.c | 3 +- sys/dev/ath/ah_osdep.c | 3 +- sys/dev/ath/if_ath.c | 9 +- sys/dev/ath/if_ath_debug.c | 3 +- sys/dev/bce/if_bce.c | 15 ++ sys/dev/bge/if_bge.c | 17 +- sys/dev/bwn/if_bwn.c | 3 +- sys/dev/bxe/bxe.c | 13 +- sys/dev/cardbus/cardbus.c | 12 +- sys/dev/cs/if_cs.c | 6 +- sys/dev/cxgb/cxgb_include.h | 3 - sys/dev/cxgb/cxgb_main.c | 5 + sys/dev/cxgb/cxgb_sge.c | 14 +- sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c | 24 ++- sys/dev/cxgbe/iw_cxgbe/cm.c | 50 ++++-- sys/dev/drm/drm_drv.c | 1 + sys/dev/drm/drm_sysctl.c | 2 +- sys/dev/drm2/drm_drv.c | 1 + sys/dev/drm2/drm_sysctl.c | 2 +- sys/dev/e1000/if_em.c | 11 ++ sys/dev/e1000/if_igb.c | 11 +- sys/dev/fb/vesa.c | 1 + sys/dev/firewire/fwohci.c | 11 +- sys/dev/firewire/if_fwe.c | 12 +- sys/dev/firewire/if_fwip.c | 4 +- sys/dev/firewire/sbp.c | 24 ++- sys/dev/glxiic/glxiic.c | 5 +- sys/dev/hptmv/hptproc.c | 2 +- sys/dev/hwpmc/hwpmc_logging.c | 6 +- sys/dev/hwpmc/hwpmc_mod.c | 17 +- sys/dev/iscsi/icl.c | 5 + sys/dev/iscsi/iscsi.c | 6 + sys/dev/iscsi_initiator/iscsi.c | 11 +- sys/dev/ixgbe/ixgbe.c | 10 +- sys/dev/malo/if_malo.c | 15 +- sys/dev/malo/if_malo_pci.c | 3 +- sys/dev/mfi/mfi.c | 6 + sys/dev/mfi/mfi_cam.c | 3 +- sys/dev/mfi/mfi_pci.c | 5 +- sys/dev/mfi/mfi_tbolt.c | 1 + sys/dev/mwl/if_mwl.c | 18 +- sys/dev/nand/nand.c | 11 +- sys/dev/pccard/pccard.c | 6 +- sys/dev/pccbb/pccbb.c | 12 +- sys/dev/pccbb/pccbb_isa.c | 4 +- sys/dev/pci/pci.c | 31 ++-- sys/dev/pci/pci_pci.c | 1 + sys/dev/pci/vga_pci.c | 1 + sys/dev/puc/puc_pci.c | 3 +- sys/dev/rt/if_rt.c | 3 +- sys/dev/sdhci/sdhci.c | 3 +- sys/dev/sdhci/sdhci_pci.c | 3 +- sys/dev/si/si.c | 3 +- sys/dev/sio/sio.c | 2 +- sys/dev/sis/if_sis.c | 5 +- sys/dev/sound/pcm/channel.c | 3 +- sys/dev/sound/pcm/feeder_chain.c | 3 +- sys/dev/sound/pcm/feeder_eq.c | 3 +- sys/dev/sound/pcm/feeder_rate.c | 3 +- sys/dev/sound/pcm/mixer.c | 3 +- sys/dev/sound/pcm/sound.c | 3 +- sys/dev/sound/usb/uaudio.c | 12 +- sys/dev/syscons/syscons.c | 3 +- sys/dev/uart/uart_dev_ns8250.c | 3 +- sys/dev/usb/controller/dwc_otg.c | 5 +- sys/dev/usb/controller/ehci.c | 13 +- sys/dev/usb/controller/ohci.c | 3 +- sys/dev/usb/controller/uhci.c | 6 +- sys/dev/usb/controller/usb_controller.c | 9 +- sys/dev/usb/controller/xhci.c | 12 +- sys/dev/usb/input/ukbd.c | 9 +- sys/dev/usb/serial/uftdi.c | 1 + sys/dev/usb/serial/usb_serial.c | 9 +- sys/dev/usb/storage/umass.c | 6 +- sys/dev/usb/usb_debug.c | 33 ++-- sys/dev/usb/usb_dev.c | 3 +- sys/dev/usb/usb_device.c | 9 +- sys/dev/usb/usb_generic.c | 3 +- sys/dev/usb/usb_hub.c | 3 +- sys/dev/usb/usb_process.c | 3 +- sys/dev/usb/wlan/if_uath.c | 6 +- sys/dev/usb/wlan/if_upgt.c | 3 +- sys/dev/usb/wlan/if_urtw.c | 6 +- sys/dev/vt/vt.h | 5 +- sys/dev/wpi/if_wpi.c | 5 +- sys/gdb/gdb_cons.c | 5 +- sys/geom/concat/g_concat.c | 3 +- sys/geom/eli/g_eli.c | 18 +- sys/geom/eli/g_eli_key_cache.c | 1 + sys/geom/gate/g_gate.c | 4 +- sys/geom/geom_disk.c | 5 +- sys/geom/geom_kern.c | 3 +- sys/geom/journal/g_journal.c | 7 +- sys/geom/label/g_label.c | 3 +- sys/geom/label/g_label.h | 4 +- sys/geom/linux_lvm/g_linux_lvm.c | 3 +- sys/geom/mirror/g_mirror.c | 14 +- sys/geom/part/g_part.c | 3 +- sys/geom/part/g_part_ldm.c | 6 +- sys/geom/raid/g_raid.c | 31 ++-- sys/geom/raid/g_raid.h | 12 +- sys/geom/raid/tr_raid1.c | 16 +- sys/geom/raid/tr_raid1e.c | 16 +- sys/geom/raid3/g_raid3.c | 24 ++- sys/geom/shsec/g_shsec.c | 6 +- sys/geom/stripe/g_stripe.c | 9 +- sys/geom/vinum/geom_vinum.c | 3 +- sys/geom/virstor/g_virstor.c | 10 +- sys/i386/acpica/acpi_machdep.c | 3 +- sys/i386/bios/apm.c | 3 +- sys/i386/i386/i686_mem.c | 1 + sys/i386/i386/machdep.c | 3 +- sys/i386/i386/mp_watchdog.c | 3 +- sys/i386/i386/pmap.c | 4 +- sys/i386/i386/trap.c | 6 +- sys/i386/pci/pci_cfgreg.c | 1 + sys/i386/pci/pci_pir.c | 1 + sys/ia64/ia64/dump_machdep.c | 3 +- sys/ia64/ia64/pmap.c | 5 +- sys/kern/imgact_elf.c | 4 +- sys/kern/kern_clocksource.c | 16 +- sys/kern/kern_cons.c | 6 +- sys/kern/kern_cpu.c | 6 +- sys/kern/kern_exec.c | 3 +- sys/kern/kern_intr.c | 3 +- sys/kern/kern_ktr.c | 24 ++- sys/kern/kern_ktrace.c | 3 +- sys/kern/kern_linker.c | 5 +- sys/kern/kern_malloc.c | 57 +++--- sys/kern/kern_mbuf.c | 2 +- sys/kern/kern_mib.c | 40 ++--- sys/kern/kern_ntptime.c | 6 +- sys/kern/kern_osd.c | 3 +- sys/kern/kern_pmc.c | 3 +- sys/kern/kern_priv.c | 6 +- sys/kern/kern_shutdown.c | 36 ++-- sys/kern/kern_sig.c | 12 +- sys/kern/kern_sysctl.c | 193 +++++---------------- sys/kern/kern_tc.c | 6 +- sys/kern/kern_timeout.c | 6 +- sys/kern/subr_bus.c | 27 ++- sys/kern/subr_kdb.c | 6 +- sys/kern/subr_msgbuf.c | 3 +- sys/kern/subr_param.c | 26 +-- sys/kern/subr_prf.c | 23 +-- sys/kern/subr_rman.c | 3 +- sys/kern/subr_smp.c | 4 +- sys/kern/subr_witness.c | 13 +- sys/kern/sys_pipe.c | 2 +- sys/kern/sysv_msg.c | 6 + sys/kern/sysv_sem.c | 16 +- sys/kern/sysv_shm.c | 32 ++-- sys/kern/vfs_init.c | 3 +- sys/kern/vfs_lookup.c | 3 +- sys/mips/cavium/usb/octusb.c | 5 +- sys/mips/mips/dump_machdep.c | 3 +- sys/mips/rt305x/uart_dev_rt305x.c | 6 +- sys/net/ieee8023ad_lacp.c | 3 +- sys/net/if.c | 1 + sys/net/if_bridge.c | 21 ++- sys/net/if_lagg.c | 6 +- sys/net/if_stf.c | 3 +- sys/net/if_tap.c | 4 +- sys/net/if_tun.c | 4 +- sys/net/netisr.c | 26 ++- sys/net/route.c | 7 +- sys/netgraph/ng_base.c | 3 + sys/netgraph/ng_mppc.c | 9 +- sys/netinet/in_mcast.c | 9 +- sys/netinet/in_rss.c | 6 +- sys/netinet/tcp_subr.c | 7 +- sys/netinet6/in6_mcast.c | 9 +- sys/netinet6/mld6.c | 6 +- sys/netpfil/ipfw/ip_fw2.c | 1 + sys/netpfil/pf/pf.c | 2 + sys/pc98/cbus/sio.c | 2 +- sys/pc98/pc98/machdep.c | 3 +- sys/pc98/pc98/pc98_machdep.c | 3 +- sys/security/mac_biba/mac_biba.c | 19 +- sys/security/mac_bsdextended/mac_bsdextended.c | 3 +- sys/security/mac_ifoff/mac_ifoff.c | 12 +- sys/security/mac_lomac/mac_lomac.c | 16 +- sys/security/mac_mls/mac_mls.c | 9 +- sys/security/mac_portacl/mac_portacl.c | 14 +- sys/sparc64/pci/psycho.c | 1 + sys/sys/malloc.h | 2 +- sys/sys/param.h | 2 +- sys/sys/sysctl.h | 56 ++---- sys/vm/memguard.c | 8 +- sys/vm/redzone.c | 3 +- sys/vm/uma_core.c | 3 +- sys/vm/vm_init.c | 3 +- sys/vm/vm_map.c | 3 +- sys/vm/vm_mmap.c | 3 +- sys/vm/vm_page.c | 3 +- sys/vm/vm_radix.c | 2 +- sys/vm/vm_zeroidle.c | 3 +- sys/x86/cpufreq/hwpstate.c | 3 +- sys/x86/iommu/intel_utils.c | 9 +- sys/x86/pci/pci_bus.c | 1 + sys/x86/x86/dump_machdep.c | 3 +- sys/x86/x86/io_apic.c | 1 + sys/x86/x86/mca.c | 2 + sys/x86/x86/tsc.c | 6 + 263 files changed, 1389 insertions(+), 803 deletions(-) (limited to 'sys/dev/usb/controller') diff --git a/sys/amd64/acpica/acpi_machdep.c b/sys/amd64/acpica/acpi_machdep.c index 049b51bb4e9f4..e5dd4c306d14d 100644 --- a/sys/amd64/acpica/acpi_machdep.c +++ b/sys/amd64/acpica/acpi_machdep.c @@ -45,8 +45,9 @@ __FBSDID("$FreeBSD$"); #include int acpi_resume_beep; -SYSCTL_INT(_debug_acpi, OID_AUTO, resume_beep, CTLFLAG_RWTUN, - &acpi_resume_beep, 0, "Beep the PC speaker when resuming"); +TUNABLE_INT("debug.acpi.resume_beep", &acpi_resume_beep); +SYSCTL_INT(_debug_acpi, OID_AUTO, resume_beep, CTLFLAG_RW, &acpi_resume_beep, + 0, "Beep the PC speaker when resuming"); int acpi_reset_video; TUNABLE_INT("hw.acpi.reset_video", &acpi_reset_video); diff --git a/sys/amd64/amd64/amd64_mem.c b/sys/amd64/amd64/amd64_mem.c index 29cf2c03d8288..e77a96f3f5541 100644 --- a/sys/amd64/amd64/amd64_mem.c +++ b/sys/amd64/amd64/amd64_mem.c @@ -69,6 +69,7 @@ static char *mem_owner_bios = "BIOS"; (((curr) & ~MDF_ATTRMASK) | ((new) & MDF_ATTRMASK)) static int mtrrs_disabled; +TUNABLE_INT("machdep.disable_mtrrs", &mtrrs_disabled); SYSCTL_INT(_machdep, OID_AUTO, disable_mtrrs, CTLFLAG_RDTUN, &mtrrs_disabled, 0, "Disable amd64 MTRRs."); diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index b8999bd30076b..14cb1373d12ab 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -675,7 +675,8 @@ cpu_halt(void) void (*cpu_idle_hook)(sbintime_t) = NULL; /* ACPI idle hook. */ static int cpu_ident_amdc1e = 0; /* AMD C1E supported. */ static int idle_mwait = 1; /* Use MONITOR/MWAIT for short idle. */ -SYSCTL_INT(_machdep, OID_AUTO, idle_mwait, CTLFLAG_RWTUN, &idle_mwait, +TUNABLE_INT("machdep.idle_mwait", &idle_mwait); +SYSCTL_INT(_machdep, OID_AUTO, idle_mwait, CTLFLAG_RW, &idle_mwait, 0, "Use MONITOR/MWAIT for short idle"); #define STATE_RUNNING 0x0 diff --git a/sys/amd64/amd64/mp_watchdog.c b/sys/amd64/amd64/mp_watchdog.c index b03d2614d9b54..b1799a20b3db5 100644 --- a/sys/amd64/amd64/mp_watchdog.c +++ b/sys/amd64/amd64/mp_watchdog.c @@ -68,7 +68,8 @@ static int watchdog_dontfire = 1; static int watchdog_timer = -1; static int watchdog_nmi = 1; -SYSCTL_INT(_debug, OID_AUTO, watchdog_nmi, CTLFLAG_RWTUN, &watchdog_nmi, 0, +TUNABLE_INT("debug.watchdog", &watchdog_cpu); +SYSCTL_INT(_debug, OID_AUTO, watchdog_nmi, CTLFLAG_RW, &watchdog_nmi, 0, "IPI the boot processor with an NMI to enter the debugger"); static struct callout watchdog_callout; diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index 74929606ac13c..ae0041f5048bb 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -332,8 +332,8 @@ SYSCTL_INT(_vm_pmap, OID_AUTO, pat_works, CTLFLAG_RD, &pat_works, 1, "Is page attribute table fully functional?"); static int pg_ps_enabled = 1; -SYSCTL_INT(_vm_pmap, OID_AUTO, pg_ps_enabled, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, - &pg_ps_enabled, 0, "Are large page mappings enabled?"); +SYSCTL_INT(_vm_pmap, OID_AUTO, pg_ps_enabled, CTLFLAG_RDTUN, &pg_ps_enabled, 0, + "Are large page mappings enabled?"); #define PAT_INDEX_SIZE 8 static int pat_index[PAT_INDEX_SIZE]; /* cache mode to PAT index conversion */ @@ -368,8 +368,8 @@ static int pmap_flags = PMAP_PDE_SUPERPAGE; /* flags for x86 pmaps */ static struct unrhdr pcid_unr; static struct mtx pcid_mtx; int pmap_pcid_enabled = 0; -SYSCTL_INT(_vm_pmap, OID_AUTO, pcid_enabled, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, - &pmap_pcid_enabled, 0, "Is TLB Context ID enabled ?"); +SYSCTL_INT(_vm_pmap, OID_AUTO, pcid_enabled, CTLFLAG_RDTUN, &pmap_pcid_enabled, + 0, "Is TLB Context ID enabled ?"); int invpcid_works = 0; SYSCTL_INT(_vm_pmap, OID_AUTO, invpcid_works, CTLFLAG_RD, &invpcid_works, 0, "Is the invpcid instruction available ?"); diff --git a/sys/amd64/amd64/sys_machdep.c b/sys/amd64/amd64/sys_machdep.c index 37935cffb057c..41709c2aa9290 100644 --- a/sys/amd64/amd64/sys_machdep.c +++ b/sys/amd64/amd64/sys_machdep.c @@ -73,6 +73,7 @@ static void max_ldt_segment_init(void *arg __unused) { + TUNABLE_INT_FETCH("machdep.max_ldt_segment", &max_ldt_segment); if (max_ldt_segment <= 0) max_ldt_segment = 1; if (max_ldt_segment > MAX_LD) diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c index 0e5766678f6d1..ce0ab6a51ca65 100644 --- a/sys/amd64/amd64/trap.c +++ b/sys/amd64/amd64/trap.c @@ -143,18 +143,20 @@ static char *trap_msg[] = { #ifdef KDB static int kdb_on_nmi = 1; -SYSCTL_INT(_machdep, OID_AUTO, kdb_on_nmi, CTLFLAG_RWTUN, +SYSCTL_INT(_machdep, OID_AUTO, kdb_on_nmi, CTLFLAG_RW, &kdb_on_nmi, 0, "Go to KDB on NMI"); +TUNABLE_INT("machdep.kdb_on_nmi", &kdb_on_nmi); #endif static int panic_on_nmi = 1; -SYSCTL_INT(_machdep, OID_AUTO, panic_on_nmi, CTLFLAG_RWTUN, +SYSCTL_INT(_machdep, OID_AUTO, panic_on_nmi, CTLFLAG_RW, &panic_on_nmi, 0, "Panic on NMI"); +TUNABLE_INT("machdep.panic_on_nmi", &panic_on_nmi); static int prot_fault_translation; -SYSCTL_INT(_machdep, OID_AUTO, prot_fault_translation, CTLFLAG_RWTUN, +SYSCTL_INT(_machdep, OID_AUTO, prot_fault_translation, CTLFLAG_RW, &prot_fault_translation, 0, "Select signal to deliver on protection fault"); static int uprintf_signal; -SYSCTL_INT(_machdep, OID_AUTO, uprintf_signal, CTLFLAG_RWTUN, +SYSCTL_INT(_machdep, OID_AUTO, uprintf_signal, CTLFLAG_RW, &uprintf_signal, 0, "Print debugging information on trap signal to ctty"); diff --git a/sys/amd64/pci/pci_cfgreg.c b/sys/amd64/pci/pci_cfgreg.c index 0039008b34522..706fdd381ace6 100644 --- a/sys/amd64/pci/pci_cfgreg.c +++ b/sys/amd64/pci/pci_cfgreg.c @@ -65,6 +65,7 @@ static int pcie_minbus, pcie_maxbus; static uint32_t pcie_badslots; static struct mtx pcicfg_mtx; static int mcfg_enable = 1; +TUNABLE_INT("hw.pci.mcfg", &mcfg_enable); SYSCTL_INT(_hw_pci, OID_AUTO, mcfg, CTLFLAG_RDTUN, &mcfg_enable, 0, "Enable support for PCI-e memory mapped config access"); diff --git a/sys/amd64/vmm/vmm.c b/sys/amd64/vmm/vmm.c index e4c82a1c12a11..c2a9fd1e117e7 100644 --- a/sys/amd64/vmm/vmm.c +++ b/sys/amd64/vmm/vmm.c @@ -199,6 +199,7 @@ SYSCTL_NODE(_hw, OID_AUTO, vmm, CTLFLAG_RW, NULL, NULL); * interrupts disabled. */ static int halt_detection_enabled = 1; +TUNABLE_INT("hw.vmm.halt_detection", &halt_detection_enabled); SYSCTL_INT(_hw_vmm, OID_AUTO, halt_detection, CTLFLAG_RDTUN, &halt_detection_enabled, 0, "Halt VM if all vcpus execute HLT with interrupts disabled"); diff --git a/sys/arm/arm/busdma_machdep-v6.c b/sys/arm/arm/busdma_machdep-v6.c index f45a5d1e03a09..6cbcae439c593 100644 --- a/sys/arm/arm/busdma_machdep-v6.c +++ b/sys/arm/arm/busdma_machdep-v6.c @@ -224,10 +224,10 @@ busdma_init(void *dummy) /* * This init historically used SI_SUB_VM, but now the init code requires * malloc(9) using M_DEVBUF memory, which is set up later than SI_SUB_VM, by - * SI_SUB_KMEM and SI_ORDER_THIRD, so we'll go right after that by using - * SI_SUB_KMEM and SI_ORDER_FOURTH. + * SI_SUB_KMEM and SI_ORDER_SECOND, so we'll go right after that by using + * SI_SUB_KMEM and SI_ORDER_THIRD. */ -SYSINIT(busdma, SI_SUB_KMEM, SI_ORDER_FOURTH, busdma_init, NULL); +SYSINIT(busdma, SI_SUB_KMEM, SI_ORDER_THIRD, busdma_init, NULL); static __inline int _bus_dma_can_bounce(vm_offset_t lowaddr, vm_offset_t highaddr) diff --git a/sys/arm/arm/busdma_machdep.c b/sys/arm/arm/busdma_machdep.c index 57b58fcfa75ca..8ef8e03e7d8ad 100644 --- a/sys/arm/arm/busdma_machdep.c +++ b/sys/arm/arm/busdma_machdep.c @@ -276,10 +276,10 @@ busdma_init(void *dummy) /* * This init historically used SI_SUB_VM, but now the init code requires * malloc(9) using M_DEVBUF memory, which is set up later than SI_SUB_VM, by - * SI_SUB_KMEM and SI_ORDER_THIRD, so we'll go right after that by using - * SI_SUB_KMEM and SI_ORDER_FOURTH. + * SI_SUB_KMEM and SI_ORDER_SECOND, so we'll go right after that by using + * SI_SUB_KMEM and SI_ORDER_THIRD. */ -SYSINIT(busdma, SI_SUB_KMEM, SI_ORDER_FOURTH, busdma_init, NULL); +SYSINIT(busdma, SI_SUB_KMEM, SI_ORDER_THIRD, busdma_init, NULL); /* * End block of code useful to transplant to other implementations. diff --git a/sys/arm/arm/dump_machdep.c b/sys/arm/arm/dump_machdep.c index 5056a33e28031..f37346c3d0084 100644 --- a/sys/arm/arm/dump_machdep.c +++ b/sys/arm/arm/dump_machdep.c @@ -50,7 +50,8 @@ __FBSDID("$FreeBSD$"); CTASSERT(sizeof(struct kerneldumpheader) == 512); int do_minidump = 1; -SYSCTL_INT(_debug, OID_AUTO, minidump, CTLFLAG_RWTUN, &do_minidump, 0, +TUNABLE_INT("debug.minidump", &do_minidump); +SYSCTL_INT(_debug, OID_AUTO, minidump, CTLFLAG_RW, &do_minidump, 0, "Enable mini crash dumps"); /* diff --git a/sys/arm/arm/platform.c b/sys/arm/arm/platform.c index 8dcccc7714ad3..c744d7ec654e8 100644 --- a/sys/arm/arm/platform.c +++ b/sys/arm/arm/platform.c @@ -65,8 +65,8 @@ static platform_t plat_obj; static struct kobj_ops plat_kernel_kops; static struct platform_kobj plat_kernel_obj; -static char plat_name[64]; -SYSCTL_STRING(_hw, OID_AUTO, platform, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, plat_name, 0, +static char plat_name[64] = ""; +SYSCTL_STRING(_hw, OID_AUTO, platform, CTLFLAG_RDTUN, plat_name, 0, "Platform currently in use"); /* diff --git a/sys/arm/arm/pmap-v6.c b/sys/arm/arm/pmap-v6.c index 804469eef22d3..67ae8ddb2b040 100644 --- a/sys/arm/arm/pmap-v6.c +++ b/sys/arm/arm/pmap-v6.c @@ -465,7 +465,7 @@ static SYSCTL_NODE(_vm, OID_AUTO, pmap, CTLFLAG_RD, 0, "VM/pmap parameters"); /* Superpages utilization enabled = 1 / disabled = 0 */ static int sp_enabled = 1; -SYSCTL_INT(_vm_pmap, OID_AUTO, sp_enabled, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &sp_enabled, 0, +SYSCTL_INT(_vm_pmap, OID_AUTO, sp_enabled, CTLFLAG_RDTUN, &sp_enabled, 0, "Are large page mappings enabled?"); SYSCTL_INT(_vm_pmap, OID_AUTO, pv_entry_count, CTLFLAG_RD, &pv_entry_count, 0, diff --git a/sys/arm/freescale/imx/imx6_anatop.c b/sys/arm/freescale/imx/imx6_anatop.c index 30978381b8f05..b1757fbdf1a8c 100644 --- a/sys/arm/freescale/imx/imx6_anatop.c +++ b/sys/arm/freescale/imx/imx6_anatop.c @@ -375,12 +375,12 @@ cpufreq_initialize(struct imx6_anatop_softc *sc) "CPU frequency"); SYSCTL_ADD_PROC(NULL, SYSCTL_STATIC_CHILDREN(_hw_imx6), - OID_AUTO, "cpu_minmhz", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NOFETCH, - sc, 0, cpufreq_sysctl_minmhz, "IU", "Minimum CPU frequency"); + OID_AUTO, "cpu_minmhz", CTLTYPE_INT | CTLFLAG_RWTUN, sc, 0, + cpufreq_sysctl_minmhz, "IU", "Minimum CPU frequency"); SYSCTL_ADD_PROC(NULL, SYSCTL_STATIC_CHILDREN(_hw_imx6), - OID_AUTO, "cpu_maxmhz", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NOFETCH, - sc, 0, cpufreq_sysctl_maxmhz, "IU", "Maximum CPU frequency"); + OID_AUTO, "cpu_maxmhz", CTLTYPE_INT | CTLFLAG_RWTUN, sc, 0, + cpufreq_sysctl_maxmhz, "IU", "Maximum CPU frequency"); SYSCTL_ADD_INT(NULL, SYSCTL_STATIC_CHILDREN(_hw_imx6), OID_AUTO, "cpu_maxmhz_hw", CTLFLAG_RD, &sc->cpu_maxmhz_hw, 0, @@ -413,6 +413,9 @@ cpufreq_initialize(struct imx6_anatop_softc *sc) sc->cpu_maxmhz_hw = imx6_ocotp_mhz_tab[cfg3speed]; sc->cpu_maxmhz = sc->cpu_maxmhz_hw; + TUNABLE_INT_FETCH("hw.imx6.cpu_overclock_enable", + &sc->cpu_overclock_enable); + TUNABLE_INT_FETCH("hw.imx6.cpu_minmhz", &sc->cpu_minmhz); op = cpufreq_nearest_oppt(sc, sc->cpu_minmhz); sc->cpu_minmhz = op->mhz; diff --git a/sys/arm/xscale/ixp425/if_npe.c b/sys/arm/xscale/ixp425/if_npe.c index d1ef51cf812b8..aae31a009ebaf 100644 --- a/sys/arm/xscale/ixp425/if_npe.c +++ b/sys/arm/xscale/ixp425/if_npe.c @@ -255,8 +255,9 @@ static SYSCTL_NODE(_hw, OID_AUTO, npe, CTLFLAG_RD, 0, "IXP4XX NPE driver parameters"); static int npe_debug = 0; -SYSCTL_INT(_hw_npe, OID_AUTO, debug, CTLFLAG_RWTUN, &npe_debug, +SYSCTL_INT(_hw_npe, OID_AUTO, debug, CTLFLAG_RW, &npe_debug, 0, "IXP4XX NPE network interface debug msgs"); +TUNABLE_INT("hw.npe.debug", &npe_debug); #define DPRINTF(sc, fmt, ...) do { \ if (sc->sc_debug) device_printf(sc->sc_dev, fmt, __VA_ARGS__); \ } while (0) @@ -264,15 +265,18 @@ SYSCTL_INT(_hw_npe, OID_AUTO, debug, CTLFLAG_RWTUN, &npe_debug, if (sc->sc_debug >= n) device_printf(sc->sc_dev, fmt, __VA_ARGS__);\ } while (0) static int npe_tickinterval = 3; /* npe_tick frequency (secs) */ -SYSCTL_INT(_hw_npe, OID_AUTO, tickinterval, CTLFLAG_RDTUN, &npe_tickinterval, +SYSCTL_INT(_hw_npe, OID_AUTO, tickinterval, CTLFLAG_RD, &npe_tickinterval, 0, "periodic work interval (secs)"); +TUNABLE_INT("hw.npe.tickinterval", &npe_tickinterval); static int npe_rxbuf = 64; /* # rx buffers to allocate */ -SYSCTL_INT(_hw_npe, OID_AUTO, rxbuf, CTLFLAG_RDTUN, &npe_rxbuf, +SYSCTL_INT(_hw_npe, OID_AUTO, rxbuf, CTLFLAG_RD, &npe_rxbuf, 0, "rx buffers allocated"); +TUNABLE_INT("hw.npe.rxbuf", &npe_rxbuf); static int npe_txbuf = 128; /* # tx buffers to allocate */ -SYSCTL_INT(_hw_npe, OID_AUTO, txbuf, CTLFLAG_RDTUN, &npe_txbuf, +SYSCTL_INT(_hw_npe, OID_AUTO, txbuf, CTLFLAG_RD, &npe_txbuf, 0, "tx buffers allocated"); +TUNABLE_INT("hw.npe.txbuf", &npe_txbuf); static int unit2npeid(int unit) diff --git a/sys/arm/xscale/ixp425/ixp425_npe.c b/sys/arm/xscale/ixp425/ixp425_npe.c index 6dbce4ccb9548..0ccc7d0cb7f94 100644 --- a/sys/arm/xscale/ixp425/ixp425_npe.c +++ b/sys/arm/xscale/ixp425/ixp425_npe.c @@ -181,8 +181,9 @@ typedef struct { } IxNpeDlNpeMgrStateInfoBlock; static int npe_debug = 0; -SYSCTL_INT(_debug, OID_AUTO, ixp425npe, CTLFLAG_RWTUN, &npe_debug, +SYSCTL_INT(_debug, OID_AUTO, ixp425npe, CTLFLAG_RW, &npe_debug, 0, "IXP4XX NPE debug msgs"); +TUNABLE_INT("debug.ixp425npe", &npe_debug); #define DPRINTF(dev, fmt, ...) do { \ if (npe_debug) device_printf(dev, fmt, __VA_ARGS__); \ } while (0) diff --git a/sys/arm/xscale/ixp425/ixp425_qmgr.c b/sys/arm/xscale/ixp425/ixp425_qmgr.c index cb6c8defc948a..b6fe434564e84 100644 --- a/sys/arm/xscale/ixp425/ixp425_qmgr.c +++ b/sys/arm/xscale/ixp425/ixp425_qmgr.c @@ -159,9 +159,10 @@ struct ixpqmgr_softc { uint32_t aqmFreeSramAddress; /* SRAM free space */ }; -static int qmgr_debug; -SYSCTL_INT(_debug, OID_AUTO, qmgr, CTLFLAG_RWTUN, &qmgr_debug, +static int qmgr_debug = 0; +SYSCTL_INT(_debug, OID_AUTO, qmgr, CTLFLAG_RW, &qmgr_debug, 0, "IXP4XX Q-Manager debug msgs"); +TUNABLE_INT("debug.qmgr", &qmgr_debug); #define DPRINTF(dev, fmt, ...) do { \ if (qmgr_debug) printf(fmt, __VA_ARGS__); \ } while (0) diff --git a/sys/cam/ata/ata_da.c b/sys/cam/ata/ata_da.c index 5ea981ce71e0f..7d0d272c0d632 100644 --- a/sys/cam/ata/ata_da.c +++ b/sys/cam/ata/ata_da.c @@ -546,22 +546,30 @@ static int ada_write_cache = ADA_DEFAULT_WRITE_CACHE; static SYSCTL_NODE(_kern_cam, OID_AUTO, ada, CTLFLAG_RD, 0, "CAM Direct Access Disk driver"); -SYSCTL_INT(_kern_cam_ada, OID_AUTO, legacy_aliases, CTLFLAG_RWTUN, +SYSCTL_INT(_kern_cam_ada, OID_AUTO, legacy_aliases, CTLFLAG_RW, &ada_legacy_aliases, 0, "Create legacy-like device aliases"); -SYSCTL_INT(_kern_cam_ada, OID_AUTO, retry_count, CTLFLAG_RWTUN, +TUNABLE_INT("kern.cam.ada.legacy_aliases", &ada_legacy_aliases); +SYSCTL_INT(_kern_cam_ada, OID_AUTO, retry_count, CTLFLAG_RW, &ada_retry_count, 0, "Normal I/O retry count"); -SYSCTL_INT(_kern_cam_ada, OID_AUTO, default_timeout, CTLFLAG_RWTUN, +TUNABLE_INT("kern.cam.ada.retry_count", &ada_retry_count); +SYSCTL_INT(_kern_cam_ada, OID_AUTO, default_timeout, CTLFLAG_RW, &ada_default_timeout, 0, "Normal I/O timeout (in seconds)"); -SYSCTL_INT(_kern_cam_ada, OID_AUTO, send_ordered, CTLFLAG_RWTUN, +TUNABLE_INT("kern.cam.ada.default_timeout", &ada_default_timeout); +SYSCTL_INT(_kern_cam_ada, OID_AUTO, send_ordered, CTLFLAG_RW, &ada_send_ordered, 0, "Send Ordered Tags"); -SYSCTL_INT(_kern_cam_ada, OID_AUTO, spindown_shutdown, CTLFLAG_RWTUN, +TUNABLE_INT("kern.cam.ada.send_ordered", &ada_send_ordered); +SYSCTL_INT(_kern_cam_ada, OID_AUTO, spindown_shutdown, CTLFLAG_RW, &ada_spindown_shutdown, 0, "Spin down upon shutdown"); -SYSCTL_INT(_kern_cam_ada, OID_AUTO, spindown_suspend, CTLFLAG_RWTUN, +TUNABLE_INT("kern.cam.ada.spindown_shutdown", &ada_spindown_shutdown); +SYSCTL_INT(_kern_cam_ada, OID_AUTO, spindown_suspend, CTLFLAG_RW, &ada_spindown_suspend, 0, "Spin down upon suspend"); -SYSCTL_INT(_kern_cam_ada, OID_AUTO, read_ahead, CTLFLAG_RWTUN, +TUNABLE_INT("kern.cam.ada.spindown_suspend", &ada_spindown_suspend); +SYSCTL_INT(_kern_cam_ada, OID_AUTO, read_ahead, CTLFLAG_RW, &ada_read_ahead, 0, "Enable disk read-ahead"); -SYSCTL_INT(_kern_cam_ada, OID_AUTO, write_cache, CTLFLAG_RWTUN, +TUNABLE_INT("kern.cam.ada.read_ahead", &ada_read_ahead); +SYSCTL_INT(_kern_cam_ada, OID_AUTO, write_cache, CTLFLAG_RW, &ada_write_cache, 0, "Enable disk write cache"); +TUNABLE_INT("kern.cam.ada.write_cache", &ada_write_cache); /* * ADA_ORDEREDTAG_INTERVAL determines how often, relative diff --git a/sys/cam/ata/ata_pmp.c b/sys/cam/ata/ata_pmp.c index fab0e6f1f5743..bd4d25a67defd 100644 --- a/sys/cam/ata/ata_pmp.c +++ b/sys/cam/ata/ata_pmp.c @@ -139,12 +139,15 @@ static int pmp_hide_special = PMP_DEFAULT_HIDE_SPECIAL; static SYSCTL_NODE(_kern_cam, OID_AUTO, pmp, CTLFLAG_RD, 0, "CAM Direct Access Disk driver"); -SYSCTL_INT(_kern_cam_pmp, OID_AUTO, retry_count, CTLFLAG_RWTUN, +SYSCTL_INT(_kern_cam_pmp, OID_AUTO, retry_count, CTLFLAG_RW, &pmp_retry_count, 0, "Normal I/O retry count"); -SYSCTL_INT(_kern_cam_pmp, OID_AUTO, default_timeout, CTLFLAG_RWTUN, +TUNABLE_INT("kern.cam.pmp.retry_count", &pmp_retry_count); +SYSCTL_INT(_kern_cam_pmp, OID_AUTO, default_timeout, CTLFLAG_RW, &pmp_default_timeout, 0, "Normal I/O timeout (in seconds)"); -SYSCTL_INT(_kern_cam_pmp, OID_AUTO, hide_special, CTLFLAG_RWTUN, +TUNABLE_INT("kern.cam.pmp.default_timeout", &pmp_default_timeout); +SYSCTL_INT(_kern_cam_pmp, OID_AUTO, hide_special, CTLFLAG_RW, &pmp_hide_special, 0, "Hide extra ports"); +TUNABLE_INT("kern.cam.pmp.hide_special", &pmp_hide_special); static struct periph_driver pmpdriver = { diff --git a/sys/cam/cam.c b/sys/cam/cam.c index 939dd76c30689..f608d6f887290 100644 --- a/sys/cam/cam.c +++ b/sys/cam/cam.c @@ -116,6 +116,7 @@ SYSCTL_NODE(_kern, OID_AUTO, cam, CTLFLAG_RD, 0, "CAM Subsystem"); #endif int cam_sort_io_queues = CAM_DEFAULT_SORT_IO_QUEUES; +TUNABLE_INT("kern.cam.sort_io_queues", &cam_sort_io_queues); SYSCTL_INT(_kern_cam, OID_AUTO, sort_io_queues, CTLFLAG_RWTUN, &cam_sort_io_queues, 0, "Sort IO queues to try and optimise disk access patterns"); #endif diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c index 4a8f14b0f7324..bfad6dd95cbd6 100644 --- a/sys/cam/cam_xpt.c +++ b/sys/cam/cam_xpt.c @@ -149,6 +149,7 @@ typedef int xpt_pdrvfunc_t (struct periph_driver **pdrv, void *arg); /* Transport layer configuration information */ static struct xpt_softc xsoftc; +TUNABLE_INT("kern.cam.boot_delay", &xsoftc.boot_delay); SYSCTL_INT(_kern_cam, OID_AUTO, boot_delay, CTLFLAG_RDTUN, &xsoftc.boot_delay, 0, "Bus registration wait time"); @@ -162,6 +163,7 @@ static struct cam_doneq cam_doneqs[MAXCPU]; static int cam_num_doneqs; static struct proc *cam_proc; +TUNABLE_INT("kern.cam.num_doneqs", &cam_num_doneqs); SYSCTL_INT(_kern_cam, OID_AUTO, num_doneqs, CTLFLAG_RDTUN, &cam_num_doneqs, 0, "Number of completion queues/threads"); @@ -195,10 +197,12 @@ static struct cdevsw xpt_cdevsw = { /* Storage for debugging datastructures */ struct cam_path *cam_dpath; u_int32_t cam_dflags = CAM_DEBUG_FLAGS; -SYSCTL_UINT(_kern_cam, OID_AUTO, dflags, CTLFLAG_RWTUN, +TUNABLE_INT("kern.cam.dflags", &cam_dflags); +SYSCTL_UINT(_kern_cam, OID_AUTO, dflags, CTLFLAG_RW, &cam_dflags, 0, "Enabled debug flags"); u_int32_t cam_debug_delay = CAM_DEBUG_DELAY; -SYSCTL_UINT(_kern_cam, OID_AUTO, debug_delay, CTLFLAG_RWTUN, +TUNABLE_INT("kern.cam.debug_delay", &cam_debug_delay); +SYSCTL_UINT(_kern_cam, OID_AUTO, debug_delay, CTLFLAG_RW, &cam_debug_delay, 0, "Delay in us after each debug message"); /* Our boot-time initialization hook */ diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c index 4245e4ee25515..7378f6525eaee 100644 --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -308,9 +308,11 @@ static int index_to_aps_page; SYSCTL_NODE(_kern_cam, OID_AUTO, ctl, CTLFLAG_RD, 0, "CAM Target Layer"); static int worker_threads = -1; +TUNABLE_INT("kern.cam.ctl.worker_threads", &worker_threads); SYSCTL_INT(_kern_cam_ctl, OID_AUTO, worker_threads, CTLFLAG_RDTUN, &worker_threads, 1, "Number of worker threads"); static int verbose = 0; +TUNABLE_INT("kern.cam.ctl.verbose", &verbose); SYSCTL_INT(_kern_cam_ctl, OID_AUTO, verbose, CTLFLAG_RWTUN, &verbose, 0, "Show SCSI errors returned to initiator"); diff --git a/sys/cam/ctl/ctl_backend_block.c b/sys/cam/ctl/ctl_backend_block.c index c7ec8999b4775..95c6788120eb7 100644 --- a/sys/cam/ctl/ctl_backend_block.c +++ b/sys/cam/ctl/ctl_backend_block.c @@ -220,9 +220,10 @@ struct ctl_be_block_io { }; static int cbb_num_threads = 14; +TUNABLE_INT("kern.cam.ctl.block.num_threads", &cbb_num_threads); SYSCTL_NODE(_kern_cam_ctl, OID_AUTO, block, CTLFLAG_RD, 0, "CAM Target Layer Block Backend"); -SYSCTL_INT(_kern_cam_ctl_block, OID_AUTO, num_threads, CTLFLAG_RWTUN, +SYSCTL_INT(_kern_cam_ctl_block, OID_AUTO, num_threads, CTLFLAG_RW, &cbb_num_threads, 0, "Number of threads per backing file"); static struct ctl_be_block_io *ctl_alloc_beio(struct ctl_be_block_softc *softc); diff --git a/sys/cam/ctl/ctl_frontend_iscsi.c b/sys/cam/ctl/ctl_frontend_iscsi.c index 233433784c456..62840811bc32f 100644 --- a/sys/cam/ctl/ctl_frontend_iscsi.c +++ b/sys/cam/ctl/ctl_frontend_iscsi.c @@ -85,15 +85,19 @@ static uma_zone_t cfiscsi_data_wait_zone; SYSCTL_NODE(_kern_cam_ctl, OID_AUTO, iscsi, CTLFLAG_RD, 0, "CAM Target Layer iSCSI Frontend"); static int debug = 3; +TUNABLE_INT("kern.cam.ctl.iscsi.debug", &debug); SYSCTL_INT(_kern_cam_ctl_iscsi, OID_AUTO, debug, CTLFLAG_RWTUN, &debug, 1, "Enable debug messages"); static int ping_timeout = 5; +TUNABLE_INT("kern.cam.ctl.iscsi.ping_timeout", &ping_timeout); SYSCTL_INT(_kern_cam_ctl_iscsi, OID_AUTO, ping_timeout, CTLFLAG_RWTUN, &ping_timeout, 5, "Interval between ping (NOP-Out) requests, in seconds"); static int login_timeout = 60; +TUNABLE_INT("kern.cam.ctl.iscsi.login_timeout", &login_timeout); SYSCTL_INT(_kern_cam_ctl_iscsi, OID_AUTO, login_timeout, CTLFLAG_RWTUN, &login_timeout, 60, "Time to wait for ctld(8) to finish Login Phase, in seconds"); static int maxcmdsn_delta = 256; +TUNABLE_INT("kern.cam.ctl.iscsi.maxcmdsn_delta", &maxcmdsn_delta); SYSCTL_INT(_kern_cam_ctl_iscsi, OID_AUTO, maxcmdsn_delta, CTLFLAG_RWTUN, &maxcmdsn_delta, 256, "Number of commands the initiator can send " "without confirmation"); diff --git a/sys/cam/scsi/scsi_cd.c b/sys/cam/scsi/scsi_cd.c index 47a5a438d2942..81c29a6fb54cd 100644 --- a/sys/cam/scsi/scsi_cd.c +++ b/sys/cam/scsi/scsi_cd.c @@ -277,12 +277,15 @@ static int cd_retry_count = CD_DEFAULT_RETRY; static int cd_timeout = CD_DEFAULT_TIMEOUT; static SYSCTL_NODE(_kern_cam, OID_AUTO, cd, CTLFLAG_RD, 0, "CAM CDROM driver"); -SYSCTL_INT(_kern_cam_cd, OID_AUTO, poll_period, CTLFLAG_RWTUN, +SYSCTL_INT(_kern_cam_cd, OID_AUTO, poll_period, CTLFLAG_RW, &cd_poll_period, 0, "Media polling period in seconds"); -SYSCTL_INT(_kern_cam_cd, OID_AUTO, retry_count, CTLFLAG_RWTUN, +TUNABLE_INT("kern.cam.cd.poll_period", &cd_poll_period); +SYSCTL_INT(_kern_cam_cd, OID_AUTO, retry_count, CTLFLAG_RW, &cd_retry_count, 0, "Normal I/O retry count"); -SYSCTL_INT(_kern_cam_cd, OID_AUTO, timeout, CTLFLAG_RWTUN, +TUNABLE_INT("kern.cam.cd.retry_count", &cd_retry_count); +SYSCTL_INT(_kern_cam_cd, OID_AUTO, timeout, CTLFLAG_RW, &cd_timeout, 0, "Timeout, in us, for read operations"); +TUNABLE_INT("kern.cam.cd.timeout", &cd_timeout); static MALLOC_DEFINE(M_SCSICD, "scsi_cd", "scsi_cd buffers"); diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c index 0b1f8d595e366..1a07577020356 100644 --- a/sys/cam/scsi/scsi_da.c +++ b/sys/cam/scsi/scsi_da.c @@ -1188,14 +1188,18 @@ static int da_send_ordered = DA_DEFAULT_SEND_ORDERED; static SYSCTL_NODE(_kern_cam, OID_AUTO, da, CTLFLAG_RD, 0, "CAM Direct Access Disk driver"); -SYSCTL_INT(_kern_cam_da, OID_AUTO, poll_period, CTLFLAG_RWTUN, +SYSCTL_INT(_kern_cam_da, OID_AUTO, poll_period, CTLFLAG_RW, &da_poll_period, 0, "Media polling period in seconds"); -SYSCTL_INT(_kern_cam_da, OID_AUTO, retry_count, CTLFLAG_RWTUN, +TUNABLE_INT("kern.cam.da.poll_period", &da_poll_period); +SYSCTL_INT(_kern_cam_da, OID_AUTO, retry_count, CTLFLAG_RW, &da_retry_count, 0, "Normal I/O retry count"); -SYSCTL_INT(_kern_cam_da, OID_AUTO, default_timeout, CTLFLAG_RWTUN, +TUNABLE_INT("kern.cam.da.retry_count", &da_retry_count); +SYSCTL_INT(_kern_cam_da, OID_AUTO, default_timeout, CTLFLAG_RW, &da_default_timeout, 0, "Normal I/O timeout (in seconds)"); -SYSCTL_INT(_kern_cam_da, OID_AUTO, send_ordered, CTLFLAG_RWTUN, +TUNABLE_INT("kern.cam.da.default_timeout", &da_default_timeout); +SYSCTL_INT(_kern_cam_da, OID_AUTO, send_ordered, CTLFLAG_RW, &da_send_ordered, 0, "Send Ordered Tags"); +TUNABLE_INT("kern.cam.da.send_ordered", &da_send_ordered); /* * DA_ORDEREDTAG_INTERVAL determines how often, relative diff --git a/sys/cam/scsi/scsi_enc_safte.c b/sys/cam/scsi/scsi_enc_safte.c index 89f70a5ada232..8282d013bb584 100644 --- a/sys/cam/scsi/scsi_enc_safte.c +++ b/sys/cam/scsi/scsi_enc_safte.c @@ -226,8 +226,9 @@ static char *safte_2little = "Too Little Data Returned (%d) at line %d\n"; int emulate_array_devices = 1; SYSCTL_DECL(_kern_cam_enc); -SYSCTL_INT(_kern_cam_enc, OID_AUTO, emulate_array_devices, CTLFLAG_RWTUN, +SYSCTL_INT(_kern_cam_enc, OID_AUTO, emulate_array_devices, CTLFLAG_RW, &emulate_array_devices, 0, "Emulate Array Devices for SAF-TE"); +TUNABLE_INT("kern.cam.enc.emulate_array_devices", &emulate_array_devices); static int safte_fill_read_buf_io(enc_softc_t *enc, struct enc_fsm_state *state, diff --git a/sys/cam/scsi/scsi_sa.c b/sys/cam/scsi/scsi_sa.c index 16b7b149036f3..c1cd0f0bfdf60 100644 --- a/sys/cam/scsi/scsi_sa.c +++ b/sys/cam/scsi/scsi_sa.c @@ -445,10 +445,9 @@ static int sa_allow_io_split = SA_DEFAULT_IO_SPLIT; * is bad behavior, because it hides the true tape block size from the * application. */ +TUNABLE_INT("kern.cam.sa.allow_io_split", &sa_allow_io_split); static SYSCTL_NODE(_kern_cam, OID_AUTO, sa, CTLFLAG_RD, 0, "CAM Sequential Access Tape Driver"); -SYSCTL_INT(_kern_cam_sa, OID_AUTO, allow_io_split, CTLFLAG_RDTUN, - &sa_allow_io_split, 0, "Default I/O split value"); static struct periph_driver sadriver = { @@ -1495,7 +1494,7 @@ sasysctlinit(void *context, int pending) goto bailout; SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), - OID_AUTO, "allow_io_split", CTLTYPE_INT | CTLFLAG_RDTUN | CTLFLAG_NOFETCH, + OID_AUTO, "allow_io_split", CTLTYPE_INT | CTLFLAG_RDTUN, &softc->allow_io_split, 0, "Allow Splitting I/O"); SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "maxio", CTLTYPE_INT | CTLFLAG_RD, diff --git a/sys/cam/scsi/scsi_xpt.c b/sys/cam/scsi/scsi_xpt.c index 42b8774fd88ad..942f7121cf5a1 100644 --- a/sys/cam/scsi/scsi_xpt.c +++ b/sys/cam/scsi/scsi_xpt.c @@ -78,8 +78,9 @@ struct scsi_quirk_entry { #define SCSI_QUIRK(dev) ((struct scsi_quirk_entry *)((dev)->quirk)) static int cam_srch_hi = 0; +TUNABLE_INT("kern.cam.cam_srch_hi", &cam_srch_hi); static int sysctl_cam_search_luns(SYSCTL_HANDLER_ARGS); -SYSCTL_PROC(_kern_cam, OID_AUTO, cam_srch_hi, CTLTYPE_INT | CTLFLAG_RWTUN, 0, 0, +SYSCTL_PROC(_kern_cam, OID_AUTO, cam_srch_hi, CTLTYPE_INT|CTLFLAG_RW, 0, 0, sysctl_cam_search_luns, "I", "allow search above LUN 7 for SCSI3 and greater devices"); diff --git a/sys/cddl/compat/opensolaris/kern/opensolaris_kstat.c b/sys/cddl/compat/opensolaris/kern/opensolaris_kstat.c index 03993553f6aa5..ba6510992688a 100644 --- a/sys/cddl/compat/opensolaris/kern/opensolaris_kstat.c +++ b/sys/cddl/compat/opensolaris/kern/opensolaris_kstat.c @@ -36,7 +36,7 @@ __FBSDID("$FreeBSD$"); static MALLOC_DEFINE(M_KSTAT, "kstat_data", "Kernel statistics"); -SYSCTL_ROOT_NODE(OID_AUTO, kstat, CTLFLAG_RW, 0, "Kernel statistics"); +SYSCTL_NODE(, OID_AUTO, kstat, CTLFLAG_RW, 0, "Kernel statistics"); kstat_t * kstat_create(char *module, int instance, char *name, char *class, uchar_t type, diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c index b31d94818fde7..bc4989e32bded 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c @@ -204,6 +204,8 @@ int zfs_arc_shrink_shift = 0; int zfs_arc_p_min_shift = 0; int zfs_disable_dup_eviction = 0; +TUNABLE_QUAD("vfs.zfs.arc_max", &zfs_arc_max); +TUNABLE_QUAD("vfs.zfs.arc_min", &zfs_arc_min); TUNABLE_QUAD("vfs.zfs.arc_meta_limit", &zfs_arc_meta_limit); SYSCTL_DECL(_vfs_zfs); SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, arc_max, CTLFLAG_RDTUN, &zfs_arc_max, 0, diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/ddt.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/ddt.c index df5b77e14e898..7863e6a660162 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/ddt.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/ddt.c @@ -44,7 +44,8 @@ int zfs_dedup_prefetch = 1; SYSCTL_DECL(_vfs_zfs); SYSCTL_NODE(_vfs_zfs, OID_AUTO, dedup, CTLFLAG_RW, 0, "ZFS DEDUP"); -SYSCTL_INT(_vfs_zfs_dedup, OID_AUTO, prefetch, CTLFLAG_RWTUN, &zfs_dedup_prefetch, +TUNABLE_INT("vfs.zfs.dedup.prefetch", &zfs_dedup_prefetch); +SYSCTL_INT(_vfs_zfs_dedup, OID_AUTO, prefetch, CTLFLAG_RW, &zfs_dedup_prefetch, 0, "Enable/disable prefetching of dedup-ed blocks which are going to be freed"); static const ddt_ops_t *ddt_ops[DDT_TYPES] = { diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c index 1b222b601889c..4aa1c88d0a1d3 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c @@ -54,6 +54,7 @@ */ int zfs_nopwrite_enabled = 1; SYSCTL_DECL(_vfs_zfs); +TUNABLE_INT("vfs.zfs.nopwrite_enabled", &zfs_nopwrite_enabled); SYSCTL_INT(_vfs_zfs, OID_AUTO, nopwrite_enabled, CTLFLAG_RDTUN, &zfs_nopwrite_enabled, 0, "Enable nopwrite feature"); @@ -1625,7 +1626,8 @@ dmu_object_set_compress(objset_t *os, uint64_t object, uint8_t compress, } int zfs_mdcomp_disable = 0; -SYSCTL_INT(_vfs_zfs, OID_AUTO, mdcomp_disable, CTLFLAG_RWTUN, +TUNABLE_INT("vfs.zfs.mdcomp_disable", &zfs_mdcomp_disable); +SYSCTL_INT(_vfs_zfs, OID_AUTO, mdcomp_disable, CTLFLAG_RW, &zfs_mdcomp_disable, 0, "Disable metadata compression"); /* diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_zfetch.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_zfetch.c index 0290b2815d833..d51a981c12733 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_zfetch.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_zfetch.c @@ -55,12 +55,16 @@ SYSCTL_DECL(_vfs_zfs); SYSCTL_INT(_vfs_zfs, OID_AUTO, prefetch_disable, CTLFLAG_RW, &zfs_prefetch_disable, 0, "Disable prefetch"); SYSCTL_NODE(_vfs_zfs, OID_AUTO, zfetch, CTLFLAG_RW, 0, "ZFS ZFETCH"); -SYSCTL_UINT(_vfs_zfs_zfetch, OID_AUTO, max_streams, CTLFLAG_RWTUN, +TUNABLE_INT("vfs.zfs.zfetch.max_streams", &zfetch_max_streams); +SYSCTL_UINT(_vfs_zfs_zfetch, OID_AUTO, max_streams, CTLFLAG_RW, &zfetch_max_streams, 0, "Max # of streams per zfetch"); +TUNABLE_INT("vfs.zfs.zfetch.min_sec_reap", &zfetch_min_sec_reap); SYSCTL_UINT(_vfs_zfs_zfetch, OID_AUTO, min_sec_reap, CTLFLAG_RDTUN, &zfetch_min_sec_reap, 0, "Min time before stream reclaim"); +TUNABLE_INT("vfs.zfs.zfetch.block_cap", &zfetch_block_cap); SYSCTL_UINT(_vfs_zfs_zfetch, OID_AUTO, block_cap, CTLFLAG_RDTUN, &zfetch_block_cap, 0, "Max number of blocks to fetch at a time"); +TUNABLE_QUAD("vfs.zfs.zfetch.array_rd_sz", &zfetch_array_rd_sz); SYSCTL_UQUAD(_vfs_zfs_zfetch, OID_AUTO, array_rd_sz, CTLFLAG_RDTUN, &zfetch_array_rd_sz, 0, "Number of bytes in a array_read at which we stop prefetching"); diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c index 3ed8735338f39..213c2f2ca82e5 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c @@ -141,19 +141,23 @@ extern int zfs_vdev_async_write_active_max_dirty_percent; SYSCTL_DECL(_vfs_zfs); +TUNABLE_QUAD("vfs.zfs.dirty_data_max", &zfs_dirty_data_max); SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, dirty_data_max, CTLFLAG_RWTUN, &zfs_dirty_data_max, 0, "The maximum amount of dirty data in bytes after which new writes are " "halted until space becomes available"); +TUNABLE_QUAD("vfs.zfs.dirty_data_max_max", &zfs_dirty_data_max_max); SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, dirty_data_max_max, CTLFLAG_RDTUN, &zfs_dirty_data_max_max, 0, "The absolute cap on dirty_data_max when auto calculating"); +TUNABLE_INT("vfs.zfs.dirty_data_max_percent", &zfs_dirty_data_max_percent); SYSCTL_INT(_vfs_zfs, OID_AUTO, dirty_data_max_percent, CTLFLAG_RDTUN, &zfs_dirty_data_max_percent, 0, "The percent of physical memory used to auto calculate dirty_data_max"); +TUNABLE_QUAD("vfs.zfs.dirty_data_sync", &zfs_dirty_data_sync); SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, dirty_data_sync, CTLFLAG_RWTUN, &zfs_dirty_data_sync, 0, "Force a txg if the number of dirty buffer bytes exceed this value"); diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c index c78a1112639f5..c62be1adda89a 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c @@ -71,23 +71,32 @@ boolean_t zfs_no_scrub_io = B_FALSE; /* set to disable scrub i/o */ boolean_t zfs_no_scrub_prefetch = B_FALSE; /* set to disable srub prefetching */ SYSCTL_DECL(_vfs_zfs); -SYSCTL_UINT(_vfs_zfs, OID_AUTO, top_maxinflight, CTLFLAG_RWTUN, +TUNABLE_INT("vfs.zfs.top_maxinflight", &zfs_top_maxinflight); +SYSCTL_UINT(_vfs_zfs, OID_AUTO, top_maxinflight, CTLFLAG_RW, &zfs_top_maxinflight, 0, "Maximum I/Os per top-level vdev"); -SYSCTL_UINT(_vfs_zfs, OID_AUTO, resilver_delay, CTLFLAG_RWTUN, +TUNABLE_INT("vfs.zfs.resilver_delay", &zfs_resilver_delay); +SYSCTL_UINT(_vfs_zfs, OID_AUTO, resilver_delay, CTLFLAG_RW, &zfs_resilver_delay, 0, "Number of ticks to delay resilver"); -SYSCTL_UINT(_vfs_zfs, OID_AUTO, scrub_delay, CTLFLAG_RWTUN, +TUNABLE_INT("vfs.zfs.scrub_delay", &zfs_scrub_delay); +SYSCTL_UINT(_vfs_zfs, OID_AUTO, scrub_delay, CTLFLAG_RW, &zfs_scrub_delay, 0, "Number of ticks to delay scrub"); -SYSCTL_UINT(_vfs_zfs, OID_AUTO, scan_idle, CTLFLAG_RWTUN, +TUNABLE_INT("vfs.zfs.scan_idle", &zfs_scan_idle); +SYSCTL_UINT(_vfs_zfs, OID_AUTO, scan_idle, CTLFLAG_RW, &zfs_scan_idle, 0, "Idle scan window in clock ticks"); -SYSCTL_UINT(_vfs_zfs, OID_AUTO, scan_min_time_ms, CTLFLAG_RWTUN, +TUNABLE_INT("vfs.zfs.scan_min_time_ms", &zfs_scan_min_time_ms); +SYSCTL_UINT(_vfs_zfs, OID_AUTO, scan_min_time_ms, CTLFLAG_RW, &zfs_scan_min_time_ms, 0, "Min millisecs to scrub per txg"); -SYSCTL_UINT(_vfs_zfs, OID_AUTO, free_min_time_ms, CTLFLAG_RWTUN, +TUNABLE_INT("vfs.zfs.free_min_time_ms", &zfs_free_min_time_ms); +SYSCTL_UINT(_vfs_zfs, OID_AUTO, free_min_time_ms, CTLFLAG_RW, &zfs_free_min_time_ms, 0, "Min millisecs to free per txg"); -SYSCTL_UINT(_vfs_zfs, OID_AUTO, resilver_min_time_ms, CTLFLAG_RWTUN, +TUNABLE_INT("vfs.zfs.resilver_min_time_ms", &zfs_resilver_min_time_ms); +SYSCTL_UINT(_vfs_zfs, OID_AUTO, resilver_min_time_ms, CTLFLAG_RW, &zfs_resilver_min_time_ms, 0, "Min millisecs to resilver per txg"); -SYSCTL_INT(_vfs_zfs, OID_AUTO, no_scrub_io, CTLFLAG_RWTUN, +TUNABLE_INT("vfs.zfs.no_scrub_io", &zfs_no_scrub_io); +SYSCTL_INT(_vfs_zfs, OID_AUTO, no_scrub_io, CTLFLAG_RW, &zfs_no_scrub_io, 0, "Disable scrub I/O"); -SYSCTL_INT(_vfs_zfs, OID_AUTO, no_scrub_prefetch, CTLFLAG_RWTUN, +TUNABLE_INT("vfs.zfs.no_scrub_prefetch", &zfs_no_scrub_prefetch); +SYSCTL_INT(_vfs_zfs, OID_AUTO, no_scrub_prefetch, CTLFLAG_RW, &zfs_no_scrub_prefetch, 0, "Disable scrub prefetching"); enum ddt_class zfs_scrub_ddt_class_max = DDT_CLASS_DUPLICATE; diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c index 93fd28edded8c..407c6eaf429f5 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c @@ -55,6 +55,7 @@ SYSCTL_NODE(_vfs_zfs, OID_AUTO, metaslab, CTLFLAG_RW, 0, "ZFS metaslab"); uint64_t metaslab_aliquot = 512ULL << 10; uint64_t metaslab_gang_bang = SPA_MAXBLOCKSIZE + 1; /* force gang blocks */ +TUNABLE_QUAD("vfs.zfs.metaslab.gang_bang", &metaslab_gang_bang); SYSCTL_QUAD(_vfs_zfs_metaslab, OID_AUTO, gang_bang, CTLFLAG_RWTUN, &metaslab_gang_bang, 0, "Force gang block allocation for blocks larger than or equal to this value"); @@ -66,6 +67,7 @@ SYSCTL_QUAD(_vfs_zfs_metaslab, OID_AUTO, gang_bang, CTLFLAG_RWTUN, * Values should be greater than or equal to 100. */ int zfs_condense_pct = 200; +TUNABLE_INT("vfs.zfs.condense_pct", &zfs_condense_pct); SYSCTL_INT(_vfs_zfs, OID_AUTO, condense_pct, CTLFLAG_RWTUN, &zfs_condense_pct, 0, "Condense on-disk spacemap when it is more than this many percents" @@ -85,6 +87,7 @@ SYSCTL_INT(_vfs_zfs, OID_AUTO, condense_pct, CTLFLAG_RWTUN, * no metaslab group will be excluded based on this criterion. */ int zfs_mg_noalloc_threshold = 0; +TUNABLE_INT("vfs.zfs.mg_noalloc_threshold", &zfs_mg_noalloc_threshold); SYSCTL_INT(_vfs_zfs, OID_AUTO, mg_noalloc_threshold, CTLFLAG_RWTUN, &zfs_mg_noalloc_threshold, 0, "Percentage of metaslab group size that should be free" @@ -94,6 +97,7 @@ SYSCTL_INT(_vfs_zfs, OID_AUTO, mg_noalloc_threshold, CTLFLAG_RWTUN, * When set will load all metaslabs when pool is first opened. */ int metaslab_debug_load = 0; +TUNABLE_INT("vfs.zfs.metaslab.debug_load", &metaslab_debug_load); SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, debug_load, CTLFLAG_RWTUN, &metaslab_debug_load, 0, "Load all metaslabs when pool is first opened"); @@ -102,6 +106,7 @@ SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, debug_load, CTLFLAG_RWTUN, * When set will prevent metaslabs from being unloaded. */ int metaslab_debug_unload = 0; +TUNABLE_INT("vfs.zfs.metaslab.debug_unload", &metaslab_debug_unload); SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, debug_unload, CTLFLAG_RWTUN, &metaslab_debug_unload, 0, "Prevent metaslabs from being unloaded"); @@ -113,6 +118,8 @@ SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, debug_unload, CTLFLAG_RWTUN, * aggressive strategy (i.e search by size rather than offset). */ uint64_t metaslab_df_alloc_threshold = SPA_MAXBLOCKSIZE; +TUNABLE_QUAD("vfs.zfs.metaslab.df_alloc_threshold", + &metaslab_df_alloc_threshold); SYSCTL_QUAD(_vfs_zfs_metaslab, OID_AUTO, df_alloc_threshold, CTLFLAG_RWTUN, &metaslab_df_alloc_threshold, 0, "Minimum size which forces the dynamic allocator to change it's allocation strategy"); @@ -124,25 +131,27 @@ SYSCTL_QUAD(_vfs_zfs_metaslab, OID_AUTO, df_alloc_threshold, CTLFLAG_RWTUN, * switch to using best-fit allocations. */ int metaslab_df_free_pct = 4; +TUNABLE_INT("vfs.zfs.metaslab.df_free_pct", &metaslab_df_free_pct); SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, df_free_pct, CTLFLAG_RWTUN, &metaslab_df_free_pct, 0, - "The minimum free space, in percent, which must be available in a " - "space map to continue allocations in a first-fit fashion"); + "The minimum free space, in percent, which must be available in a space map to continue allocations in a first-fit fashion"); /* * A metaslab is considered "free" if it contains a contiguous * segment which is greater than metaslab_min_alloc_size. */ uint64_t metaslab_min_alloc_size = DMU_MAX_ACCESS; +TUNABLE_QUAD("vfs.zfs.metaslab.min_alloc_size", + &metaslab_min_alloc_size); SYSCTL_QUAD(_vfs_zfs_metaslab, OID_AUTO, min_alloc_size, CTLFLAG_RWTUN, &metaslab_min_alloc_size, 0, - "A metaslab is considered \"free\" if it contains a contiguous " - "segment which is greater than vfs.zfs.metaslab.min_alloc_size"); + "A metaslab is considered \"free\" if it contains a contiguous segment which is greater than vfs.zfs.metaslab.min_alloc_size"); /* * Percentage of all cpus that can be used by the metaslab taskq. */ int metaslab_load_pct = 50; +TUNABLE_INT("vfs.zfs.metaslab.load_pct", &metaslab_load_pct); SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, load_pct, CTLFLAG_RWTUN, &metaslab_load_pct, 0, "Percentage of cpus that can be used by the metaslab taskq"); @@ -153,6 +162,7 @@ SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, load_pct, CTLFLAG_RWTUN, * keep it loaded. */ int metaslab_unload_delay = TXG_SIZE * 2; +TUNABLE_INT("vfs.zfs.metaslab.unload_delay", &metaslab_unload_delay); SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, unload_delay, CTLFLAG_RWTUN, &metaslab_unload_delay, 0, "Number of TXGs that an unused metaslab can be kept in memory"); @@ -163,11 +173,13 @@ SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, unload_delay, CTLFLAG_RWTUN, boolean_t zfs_write_to_degraded = B_FALSE; SYSCTL_INT(_vfs_zfs, OID_AUTO, write_to_degraded, CTLFLAG_RWTUN, &zfs_write_to_degraded, 0, "Allow writing data to degraded vdevs"); +TUNABLE_INT("vfs.zfs.write_to_degraded", &zfs_write_to_degraded); /* * Max number of metaslabs per group to preload. */ int metaslab_preload_limit = SPA_DVAS_PER_BP; +TUNABLE_INT("vfs.zfs.metaslab.preload_limit", &metaslab_preload_limit); SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, preload_limit, CTLFLAG_RWTUN, &metaslab_preload_limit, 0, "Max number of metaslabs per group to preload"); @@ -176,6 +188,7 @@ SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, preload_limit, CTLFLAG_RWTUN, * Enable/disable preloading of metaslab. */ boolean_t metaslab_preload_enabled = B_TRUE; +TUNABLE_INT("vfs.zfs.metaslab.preload_enabled", &metaslab_preload_enabled); SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, preload_enabled, CTLFLAG_RWTUN, &metaslab_preload_enabled, 0, "Max number of metaslabs per group to preload"); @@ -184,6 +197,8 @@ SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, preload_enabled, CTLFLAG_RWTUN, * Enable/disable additional weight factor for each metaslab. */ boolean_t metaslab_weight_factor_enable = B_FALSE; +TUNABLE_INT("vfs.zfs.metaslab.weight_factor_enable", + &metaslab_weight_factor_enable); SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, weight_factor_enable, CTLFLAG_RWTUN, &metaslab_weight_factor_enable, 0, "Enable additional weight factor for each metaslab"); diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c index 097dc8635988b..6c79a3083e2b2 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c @@ -84,7 +84,8 @@ static int check_hostid = 1; SYSCTL_DECL(_vfs_zfs); -SYSCTL_INT(_vfs_zfs, OID_AUTO, check_hostid, CTLFLAG_RWTUN, &check_hostid, 0, +TUNABLE_INT("vfs.zfs.check_hostid", &check_hostid); +SYSCTL_INT(_vfs_zfs, OID_AUTO, check_hostid, CTLFLAG_RW, &check_hostid, 0, "Check hostid on import?"); /* diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c index 0588fbda2d60d..dbcb72916f0f3 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c @@ -244,6 +244,7 @@ int zfs_flags = ~(ZFS_DEBUG_DPRINTF | ZFS_DEBUG_SPA); int zfs_flags = 0; #endif SYSCTL_DECL(_debug); +TUNABLE_INT("debug.zfs_flags", &zfs_flags); SYSCTL_INT(_debug, OID_AUTO, zfs_flags, CTLFLAG_RWTUN, &zfs_flags, 0, "ZFS debug flags."); @@ -256,6 +257,7 @@ SYSCTL_INT(_debug, OID_AUTO, zfs_flags, CTLFLAG_RWTUN, &zfs_flags, 0, */ int zfs_recover = 0; SYSCTL_DECL(_vfs_zfs); +TUNABLE_INT("vfs.zfs.recover", &zfs_recover); SYSCTL_INT(_vfs_zfs, OID_AUTO, recover, CTLFLAG_RDTUN, &zfs_recover, 0, "Try to recover from otherwise-fatal errors."); @@ -268,6 +270,7 @@ SYSCTL_INT(_vfs_zfs, OID_AUTO, recover, CTLFLAG_RDTUN, &zfs_recover, 0, * in a system panic. */ uint64_t zfs_deadman_synctime_ms = 1000000ULL; +TUNABLE_QUAD("vfs.zfs.deadman_synctime_ms", &zfs_deadman_synctime_ms); SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, deadman_synctime_ms, CTLFLAG_RDTUN, &zfs_deadman_synctime_ms, 0, "Stalled ZFS I/O expiration time in milliseconds"); @@ -277,6 +280,7 @@ SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, deadman_synctime_ms, CTLFLAG_RDTUN, * for hung I/O. */ uint64_t zfs_deadman_checktime_ms = 5000ULL; +TUNABLE_QUAD("vfs.zfs.deadman_checktime_ms", &zfs_deadman_checktime_ms); SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, deadman_checktime_ms, CTLFLAG_RDTUN, &zfs_deadman_checktime_ms, 0, "Period of checks for stalled ZFS I/O in milliseconds"); @@ -286,6 +290,7 @@ SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, deadman_checktime_ms, CTLFLAG_RDTUN, * zfs_deadman_init() */ int zfs_deadman_enabled = -1; +TUNABLE_INT("vfs.zfs.deadman_enabled", &zfs_deadman_enabled); SYSCTL_INT(_vfs_zfs, OID_AUTO, deadman_enabled, CTLFLAG_RDTUN, &zfs_deadman_enabled, 0, "Kernel panic on stalled ZFS I/O"); @@ -299,6 +304,7 @@ SYSCTL_INT(_vfs_zfs, OID_AUTO, deadman_enabled, CTLFLAG_RDTUN, * (VDEV_RAIDZ_MAXPARITY + 1) * SPA_DVAS_PER_BP * 2 == 24 */ int spa_asize_inflation = 24; +TUNABLE_INT("vfs.zfs.spa_asize_inflation", &spa_asize_inflation); SYSCTL_INT(_vfs_zfs, OID_AUTO, spa_asize_inflation, CTLFLAG_RWTUN, &spa_asize_inflation, 0, "Worst case inflation factor for single sector writes"); diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c index 5c52042a0149b..7e981993ca468 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c @@ -85,22 +85,31 @@ static u_int trim_vdev_max_pending = 64; SYSCTL_DECL(_vfs_zfs); SYSCTL_NODE(_vfs_zfs, OID_AUTO, trim, CTLFLAG_RD, 0, "ZFS TRIM"); +TUNABLE_INT("vfs.zfs.trim.txg_delay", &trim_txg_delay); SYSCTL_UINT(_vfs_zfs_trim, OID_AUTO, txg_delay, CTLFLAG_RWTUN, &trim_txg_delay, 0, "Delay TRIMs by up to this many TXGs"); + +TUNABLE_INT("vfs.zfs.trim.timeout", &trim_timeout); SYSCTL_UINT(_vfs_zfs_trim, OID_AUTO, timeout, CTLFLAG_RWTUN, &trim_timeout, 0, "Delay TRIMs by up to this many seconds"); + +TUNABLE_INT("vfs.zfs.trim.max_interval", &trim_max_interval); SYSCTL_UINT(_vfs_zfs_trim, OID_AUTO, max_interval, CTLFLAG_RWTUN, &trim_max_interval, 0, "Maximum interval between TRIM queue processing (seconds)"); SYSCTL_DECL(_vfs_zfs_vdev); +TUNABLE_QUAD("vfs.zfs.vdev.trim_max_bytes", &trim_vdev_max_bytes); SYSCTL_QUAD(_vfs_zfs_vdev, OID_AUTO, trim_max_bytes, CTLFLAG_RWTUN, &trim_vdev_max_bytes, 0, "Maximum pending TRIM bytes for a vdev"); + +TUNABLE_INT("vfs.zfs.vdev.trim_max_pending", &trim_vdev_max_pending); SYSCTL_UINT(_vfs_zfs_vdev, OID_AUTO, trim_max_pending, CTLFLAG_RWTUN, &trim_vdev_max_pending, 0, "Maximum pending TRIM segments for a vdev"); + static void trim_map_vdev_commit_done(spa_t *spa, vdev_t *vd); static int diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/txg.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/txg.c index 6f52266d1a2d1..0201bef3ae9d5 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/txg.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/txg.c @@ -112,7 +112,8 @@ int zfs_txg_timeout = 5; /* max seconds worth of delta per txg */ SYSCTL_DECL(_vfs_zfs); SYSCTL_NODE(_vfs_zfs, OID_AUTO, txg, CTLFLAG_RW, 0, "ZFS TXG"); -SYSCTL_INT(_vfs_zfs_txg, OID_AUTO, timeout, CTLFLAG_RWTUN, &zfs_txg_timeout, 0, +TUNABLE_INT("vfs.zfs.txg.timeout", &zfs_txg_timeout); +SYSCTL_INT(_vfs_zfs_txg, OID_AUTO, timeout, CTLFLAG_RW, &zfs_txg_timeout, 0, "Maximum seconds worth of delta per txg"); /* diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_cache.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_cache.c index a3e9b02a71ce9..2ad15fe8227e2 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_cache.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_cache.c @@ -90,10 +90,13 @@ int zfs_vdev_cache_bshift = 16; SYSCTL_DECL(_vfs_zfs_vdev); SYSCTL_NODE(_vfs_zfs_vdev, OID_AUTO, cache, CTLFLAG_RW, 0, "ZFS VDEV Cache"); +TUNABLE_INT("vfs.zfs.vdev.cache.max", &zfs_vdev_cache_max); SYSCTL_INT(_vfs_zfs_vdev_cache, OID_AUTO, max, CTLFLAG_RDTUN, &zfs_vdev_cache_max, 0, "Maximum I/O request size that increase read size"); +TUNABLE_INT("vfs.zfs.vdev.cache.size", &zfs_vdev_cache_size); SYSCTL_INT(_vfs_zfs_vdev_cache, OID_AUTO, size, CTLFLAG_RDTUN, &zfs_vdev_cache_size, 0, "Size of VDEV cache"); +TUNABLE_INT("vfs.zfs.vdev.cache.bshift", &zfs_vdev_cache_bshift); SYSCTL_INT(_vfs_zfs_vdev_cache, OID_AUTO, bshift, CTLFLAG_RDTUN, &zfs_vdev_cache_bshift, 0, "Turn too small requests into 1 << this value"); diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c index c38a2fc869ccb..b64ebddbcb1a7 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c @@ -53,12 +53,14 @@ DECLARE_GEOM_CLASS(zfs_vdev_class, zfs_vdev); SYSCTL_DECL(_vfs_zfs_vdev); /* Don't send BIO_FLUSH. */ -static int vdev_geom_bio_flush_disable; -SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, bio_flush_disable, CTLFLAG_RWTUN, +static int vdev_geom_bio_flush_disable = 0; +TUNABLE_INT("vfs.zfs.vdev.bio_flush_disable", &vdev_geom_bio_flush_disable); +SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, bio_flush_disable, CTLFLAG_RW, &vdev_geom_bio_flush_disable, 0, "Disable BIO_FLUSH"); /* Don't send BIO_DELETE. */ -static int vdev_geom_bio_delete_disable; -SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, bio_delete_disable, CTLFLAG_RWTUN, +static int vdev_geom_bio_delete_disable = 0; +TUNABLE_INT("vfs.zfs.vdev.bio_delete_disable", &vdev_geom_bio_delete_disable); +SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, bio_delete_disable, CTLFLAG_RW, &vdev_geom_bio_delete_disable, 0, "Disable BIO_DELETE"); static void diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_mirror.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_mirror.c index d9b15db400feb..0b8d449f4aa15 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_mirror.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_mirror.c @@ -74,26 +74,32 @@ static SYSCTL_NODE(_vfs_zfs_vdev, OID_AUTO, mirror, CTLFLAG_RD, 0, /* Rotating media load calculation configuration. */ static int rotating_inc = 0; -SYSCTL_INT(_vfs_zfs_vdev_mirror, OID_AUTO, rotating_inc, CTLFLAG_RWTUN, +TUNABLE_INT("vfs.zfs.vdev.mirror.rotating_inc", &rotating_inc); +SYSCTL_INT(_vfs_zfs_vdev_mirror, OID_AUTO, rotating_inc, CTLFLAG_RW, &rotating_inc, 0, "Rotating media load increment for non-seeking I/O's"); static int rotating_seek_inc = 5; -SYSCTL_INT(_vfs_zfs_vdev_mirror, OID_AUTO, rotating_seek_inc, CTLFLAG_RWTUN, +TUNABLE_INT("vfs.zfs.vdev.mirror.rotating_seek_inc", &rotating_seek_inc); +SYSCTL_INT(_vfs_zfs_vdev_mirror, OID_AUTO, rotating_seek_inc, CTLFLAG_RW, &rotating_seek_inc, 0, "Rotating media load increment for seeking I/O's"); static int rotating_seek_offset = 1 * 1024 * 1024; -SYSCTL_INT(_vfs_zfs_vdev_mirror, OID_AUTO, rotating_seek_offset, CTLFLAG_RWTUN, +TUNABLE_INT("vfs.zfs.vdev.mirror.rotating_seek_offset", &rotating_seek_offset); +SYSCTL_INT(_vfs_zfs_vdev_mirror, OID_AUTO, rotating_seek_offset, CTLFLAG_RW, &rotating_seek_offset, 0, "Offset in bytes from the last I/O which " "triggers a reduced rotating media seek increment"); /* Non-rotating media load calculation configuration. */ static int non_rotating_inc = 0; -SYSCTL_INT(_vfs_zfs_vdev_mirror, OID_AUTO, non_rotating_inc, CTLFLAG_RWTUN, +TUNABLE_INT("vfs.zfs.vdev.mirror.non_rotating_inc", &non_rotating_inc); +SYSCTL_INT(_vfs_zfs_vdev_mirror, OID_AUTO, non_rotating_inc, CTLFLAG_RW, &non_rotating_inc, 0, "Non-rotating media load increment for non-seeking I/O's"); static int non_rotating_seek_inc = 1; -SYSCTL_INT(_vfs_zfs_vdev_mirror, OID_AUTO, non_rotating_seek_inc, CTLFLAG_RWTUN, +TUNABLE_INT("vfs.zfs.vdev.mirror.non_rotating_seek_inc", + &non_rotating_seek_inc); +SYSCTL_INT(_vfs_zfs_vdev_mirror, OID_AUTO, non_rotating_seek_inc, CTLFLAG_RW, &non_rotating_seek_inc, 0, "Non-rotating media load increment for seeking I/O's"); diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c index b2e10c1105825..60fd4c3eedf2f 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c @@ -176,18 +176,23 @@ int zfs_vdev_write_gap_limit = 4 << 10; #ifdef __FreeBSD__ SYSCTL_DECL(_vfs_zfs_vdev); -SYSCTL_UINT(_vfs_zfs_vdev, OID_AUTO, max_active, CTLFLAG_RWTUN, +TUNABLE_INT("vfs.zfs.vdev.max_active", &zfs_vdev_max_active); +SYSCTL_UINT(_vfs_zfs_vdev, OID_AUTO, max_active, CTLFLAG_RW, &zfs_vdev_max_active, 0, "The maximum number of I/Os of all types active for each device."); #define ZFS_VDEV_QUEUE_KNOB_MIN(name) \ -SYSCTL_UINT(_vfs_zfs_vdev, OID_AUTO, name ## _min_active, CTLFLAG_RWTUN,\ +TUNABLE_INT("vfs.zfs.vdev." #name "_min_active", \ + &zfs_vdev_ ## name ## _min_active); \ +SYSCTL_UINT(_vfs_zfs_vdev, OID_AUTO, name ## _min_active, CTLFLAG_RW, \ &zfs_vdev_ ## name ## _min_active, 0, \ "Initial number of I/O requests of type " #name \ " active for each device"); #define ZFS_VDEV_QUEUE_KNOB_MAX(name) \ -SYSCTL_UINT(_vfs_zfs_vdev, OID_AUTO, name ## _max_active, CTLFLAG_RWTUN,\ +TUNABLE_INT("vfs.zfs.vdev." #name "_max_active", \ + &zfs_vdev_ ## name ## _max_active); \ +SYSCTL_UINT(_vfs_zfs_vdev, OID_AUTO, name ## _max_active, CTLFLAG_RW, \ &zfs_vdev_ ## name ## _max_active, 0, \ "Maximum number of I/O requests of type " #name \ " active for each device"); @@ -207,13 +212,16 @@ ZFS_VDEV_QUEUE_KNOB_MAX(trim); #undef ZFS_VDEV_QUEUE_KNOB -SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, aggregation_limit, CTLFLAG_RWTUN, +TUNABLE_INT("vfs.zfs.vdev.aggregation_limit", &zfs_vdev_aggregation_limit); +SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, aggregation_limit, CTLFLAG_RW, &zfs_vdev_aggregation_limit, 0, "I/O requests are aggregated up to this size"); -SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, read_gap_limit, CTLFLAG_RWTUN, +TUNABLE_INT("vfs.zfs.vdev.read_gap_limit", &zfs_vdev_read_gap_limit); +SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, read_gap_limit, CTLFLAG_RW, &zfs_vdev_read_gap_limit, 0, "Acceptable gap between two reads being aggregated"); -SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, write_gap_limit, CTLFLAG_RWTUN, +TUNABLE_INT("vfs.zfs.vdev.write_gap_limit", &zfs_vdev_write_gap_limit); +SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, write_gap_limit, CTLFLAG_RW, &zfs_vdev_write_gap_limit, 0, "Acceptable gap between two writes being aggregated"); #endif diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c index 6b5b86de737dc..4f7c082cbefe0 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c @@ -195,7 +195,8 @@ CTASSERT(sizeof(zfs_cmd_t) < IOCPARM_MAX); static int snapshot_list_prefetch; SYSCTL_DECL(_vfs_zfs); -SYSCTL_INT(_vfs_zfs, OID_AUTO, snapshot_list_prefetch, CTLFLAG_RWTUN, +TUNABLE_INT("vfs.zfs.snapshot_list_prefetch", &snapshot_list_prefetch); +SYSCTL_INT(_vfs_zfs, OID_AUTO, snapshot_list_prefetch, CTLFLAG_RW, &snapshot_list_prefetch, 0, "Prefetch data when listing snapshots"); static struct cdev *zfsdev; diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c index 5f2cf3f142033..7ce41a137a199 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c @@ -74,7 +74,8 @@ SYSCTL_INT(_vfs_zfs, OID_AUTO, super_owner, CTLFLAG_RW, &zfs_super_owner, 0, "File system owner can perform privileged operation on his file systems"); int zfs_debug_level; -SYSCTL_INT(_vfs_zfs, OID_AUTO, debug, CTLFLAG_RWTUN, &zfs_debug_level, 0, +TUNABLE_INT("vfs.zfs.debug", &zfs_debug_level); +SYSCTL_INT(_vfs_zfs, OID_AUTO, debug, CTLFLAG_RW, &zfs_debug_level, 0, "Debug level"); SYSCTL_NODE(_vfs_zfs, OID_AUTO, version, CTLFLAG_RD, 0, "ZFS versions"); diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c index c17c96fbba584..ea5bb13a77791 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c @@ -70,7 +70,8 @@ */ int zil_replay_disable = 0; SYSCTL_DECL(_vfs_zfs); -SYSCTL_INT(_vfs_zfs, OID_AUTO, zil_replay_disable, CTLFLAG_RWTUN, +TUNABLE_INT("vfs.zfs.zil_replay_disable", &zil_replay_disable); +SYSCTL_INT(_vfs_zfs, OID_AUTO, zil_replay_disable, CTLFLAG_RW, &zil_replay_disable, 0, "Disable intent logging replay"); /* @@ -79,10 +80,12 @@ SYSCTL_INT(_vfs_zfs, OID_AUTO, zil_replay_disable, CTLFLAG_RWTUN, * out-of-order write cache is enabled. */ boolean_t zfs_nocacheflush = B_FALSE; +TUNABLE_INT("vfs.zfs.cache_flush_disable", &zfs_nocacheflush); SYSCTL_INT(_vfs_zfs, OID_AUTO, cache_flush_disable, CTLFLAG_RDTUN, &zfs_nocacheflush, 0, "Disable cache flush"); boolean_t zfs_trim_enabled = B_TRUE; SYSCTL_DECL(_vfs_zfs_trim); +TUNABLE_INT("vfs.zfs.trim.enabled", &zfs_trim_enabled); SYSCTL_INT(_vfs_zfs_trim, OID_AUTO, enabled, CTLFLAG_RDTUN, &zfs_trim_enabled, 0, "Enable ZFS TRIM"); diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c index ba326489ce69d..01946fb2b553d 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c @@ -46,9 +46,11 @@ static int zio_use_uma = 1; #else static int zio_use_uma = 0; #endif +TUNABLE_INT("vfs.zfs.zio.use_uma", &zio_use_uma); SYSCTL_INT(_vfs_zfs_zio, OID_AUTO, use_uma, CTLFLAG_RDTUN, &zio_use_uma, 0, "Use uma(9) for ZIO allocations"); static int zio_exclude_metadata = 0; +TUNABLE_INT("vfs.zfs.zio.exclude_metadata", &zio_exclude_metadata); SYSCTL_INT(_vfs_zfs_zio, OID_AUTO, exclude_metadata, CTLFLAG_RDTUN, &zio_exclude_metadata, 0, "Exclude metadata buffers from dumps as well"); @@ -102,12 +104,15 @@ extern vmem_t *zio_alloc_arena; * regular blocks are not deferred. */ int zfs_sync_pass_deferred_free = 2; /* defer frees starting in this pass */ +TUNABLE_INT("vfs.zfs.sync_pass_deferred_free", &zfs_sync_pass_deferred_free); SYSCTL_INT(_vfs_zfs, OID_AUTO, sync_pass_deferred_free, CTLFLAG_RDTUN, &zfs_sync_pass_deferred_free, 0, "defer frees starting in this pass"); int zfs_sync_pass_dont_compress = 5; /* don't compress starting in this pass */ +TUNABLE_INT("vfs.zfs.sync_pass_dont_compress", &zfs_sync_pass_dont_compress); SYSCTL_INT(_vfs_zfs, OID_AUTO, sync_pass_dont_compress, CTLFLAG_RDTUN, &zfs_sync_pass_dont_compress, 0, "don't compress starting in this pass"); int zfs_sync_pass_rewrite = 2; /* rewrite new bps starting in this pass */ +TUNABLE_INT("vfs.zfs.sync_pass_rewrite", &zfs_sync_pass_rewrite); SYSCTL_INT(_vfs_zfs, OID_AUTO, sync_pass_rewrite, CTLFLAG_RDTUN, &zfs_sync_pass_rewrite, 0, "rewrite new bps starting in this pass"); diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c index 53877d7a6b26b..fb3789f45b119 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c @@ -119,6 +119,7 @@ static uint32_t zvol_minors; SYSCTL_DECL(_vfs_zfs); SYSCTL_NODE(_vfs_zfs, OID_AUTO, vol, CTLFLAG_RW, 0, "ZFS VOLUME"); static int volmode = ZFS_VOLMODE_GEOM; +TUNABLE_INT("vfs.zfs.vol.mode", &volmode); SYSCTL_INT(_vfs_zfs_vol, OID_AUTO, mode, CTLFLAG_RWTUN, &volmode, 0, "Expose as GEOM providers (1), device files (2) or neither"); diff --git a/sys/cddl/dev/dtrace/dtrace_sysctl.c b/sys/cddl/dev/dtrace/dtrace_sysctl.c index 9f8b14fd1c661..d98111d4184b2 100644 --- a/sys/cddl/dev/dtrace/dtrace_sysctl.c +++ b/sys/cddl/dev/dtrace/dtrace_sysctl.c @@ -25,7 +25,8 @@ SYSCTL_NODE(_debug, OID_AUTO, dtrace, CTLFLAG_RD, 0, "DTrace debug parameters"); int dtrace_debug = 0; -SYSCTL_INT(_debug_dtrace, OID_AUTO, debug, CTLFLAG_RWTUN, &dtrace_debug, 0, ""); +TUNABLE_INT("debug.dtrace.debug", &dtrace_debug); +SYSCTL_INT(_debug_dtrace, OID_AUTO, debug, CTLFLAG_RW, &dtrace_debug, 0, ""); /* Report registered DTrace providers. */ static int diff --git a/sys/compat/ia32/ia32_sysvec.c b/sys/compat/ia32/ia32_sysvec.c index 770bbbf9e4623..a8e52e82eefa4 100644 --- a/sys/compat/ia32/ia32_sysvec.c +++ b/sys/compat/ia32/ia32_sysvec.c @@ -89,11 +89,14 @@ extern const char *freebsd32_syscallnames[]; static SYSCTL_NODE(_compat, OID_AUTO, ia32, CTLFLAG_RW, 0, "ia32 mode"); static u_long ia32_maxdsiz = IA32_MAXDSIZ; -SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxdsiz, CTLFLAG_RWTUN, &ia32_maxdsiz, 0, ""); +SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxdsiz, CTLFLAG_RW, &ia32_maxdsiz, 0, ""); +TUNABLE_ULONG("compat.ia32.maxdsiz", &ia32_maxdsiz); u_long ia32_maxssiz = IA32_MAXSSIZ; -SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxssiz, CTLFLAG_RWTUN, &ia32_maxssiz, 0, ""); +SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxssiz, CTLFLAG_RW, &ia32_maxssiz, 0, ""); +TUNABLE_ULONG("compat.ia32.maxssiz", &ia32_maxssiz); static u_long ia32_maxvmem = IA32_MAXVMEM; -SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxvmem, CTLFLAG_RWTUN, &ia32_maxvmem, 0, ""); +SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxvmem, CTLFLAG_RW, &ia32_maxvmem, 0, ""); +TUNABLE_ULONG("compat.ia32.maxvmem", &ia32_maxvmem); struct sysentvec ia32_freebsd_sysvec = { .sv_size = FREEBSD32_SYS_MAXSYSCALL, diff --git a/sys/compat/x86bios/x86bios.c b/sys/compat/x86bios/x86bios.c index 5cd31e8a71bb2..32b992974c9de 100644 --- a/sys/compat/x86bios/x86bios.c +++ b/sys/compat/x86bios/x86bios.c @@ -70,10 +70,12 @@ static struct mtx x86bios_lock; static SYSCTL_NODE(_debug, OID_AUTO, x86bios, CTLFLAG_RD, NULL, "x86bios debugging"); static int x86bios_trace_call; -SYSCTL_INT(_debug_x86bios, OID_AUTO, call, CTLFLAG_RWTUN, &x86bios_trace_call, 0, +TUNABLE_INT("debug.x86bios.call", &x86bios_trace_call); +SYSCTL_INT(_debug_x86bios, OID_AUTO, call, CTLFLAG_RW, &x86bios_trace_call, 0, "Trace far function calls"); static int x86bios_trace_int; -SYSCTL_INT(_debug_x86bios, OID_AUTO, int, CTLFLAG_RWTUN, &x86bios_trace_int, 0, +TUNABLE_INT("debug.x86bios.int", &x86bios_trace_int); +SYSCTL_INT(_debug_x86bios, OID_AUTO, int, CTLFLAG_RW, &x86bios_trace_int, 0, "Trace software interrupt handlers"); #ifdef X86BIOS_NATIVE_VM86 diff --git a/sys/dev/aac/aac_pci.c b/sys/dev/aac/aac_pci.c index 83e7e63fda8e0..ccf537ed31f65 100644 --- a/sys/dev/aac/aac_pci.c +++ b/sys/dev/aac/aac_pci.c @@ -61,6 +61,7 @@ static int aac_pci_probe(device_t dev); static int aac_pci_attach(device_t dev); static int aac_enable_msi = 1; +TUNABLE_INT("hw.aac.enable_msi", &aac_enable_msi); SYSCTL_INT(_hw_aac, OID_AUTO, enable_msi, CTLFLAG_RDTUN, &aac_enable_msi, 0, "Enable MSI interrupts"); diff --git a/sys/dev/acpica/Osd/OsdSchedule.c b/sys/dev/acpica/Osd/OsdSchedule.c index d49f886c9b8b4..e5d3d51d19fea 100644 --- a/sys/dev/acpica/Osd/OsdSchedule.c +++ b/sys/dev/acpica/Osd/OsdSchedule.c @@ -56,6 +56,7 @@ ACPI_MODULE_NAME("SCHEDULE") * Allow the user to tune the maximum number of tasks we may enqueue. */ static int acpi_max_tasks = ACPI_MAX_TASKS; +TUNABLE_INT("debug.acpi.max_tasks", &acpi_max_tasks); SYSCTL_INT(_debug_acpi, OID_AUTO, max_tasks, CTLFLAG_RDTUN, &acpi_max_tasks, 0, "Maximum acpi tasks"); @@ -64,6 +65,7 @@ SYSCTL_INT(_debug_acpi, OID_AUTO, max_tasks, CTLFLAG_RDTUN, &acpi_max_tasks, * some systems have problems with increased parallelism. */ static int acpi_max_threads = ACPI_MAX_THREADS; +TUNABLE_INT("debug.acpi.max_threads", &acpi_max_threads); SYSCTL_INT(_debug_acpi, OID_AUTO, max_threads, CTLFLAG_RDTUN, &acpi_max_threads, 0, "Maximum acpi threads"); diff --git a/sys/dev/acpica/acpi_cpu.c b/sys/dev/acpica/acpi_cpu.c index 5cb22a9fbc1a1..f95510cf69019 100644 --- a/sys/dev/acpica/acpi_cpu.c +++ b/sys/dev/acpica/acpi_cpu.c @@ -129,6 +129,7 @@ struct acpi_cpu_device { /* Allow users to ignore processor orders in MADT. */ static int cpu_unordered; +TUNABLE_INT("debug.acpi.cpu_unordered", &cpu_unordered); SYSCTL_INT(_debug_acpi, OID_AUTO, cpu_unordered, CTLFLAG_RDTUN, &cpu_unordered, 0, "Do not use the MADT to match ACPI Processor objects to CPUs."); diff --git a/sys/dev/acpica/acpi_ec.c b/sys/dev/acpica/acpi_ec.c index 6537e4062b4d3..6e2f0dd284634 100644 --- a/sys/dev/acpica/acpi_ec.c +++ b/sys/dev/acpica/acpi_ec.c @@ -181,13 +181,16 @@ ACPI_SERIAL_DECL(ec, "ACPI embedded controller"); static SYSCTL_NODE(_debug_acpi, OID_AUTO, ec, CTLFLAG_RD, NULL, "EC debugging"); static int ec_burst_mode; -SYSCTL_INT(_debug_acpi_ec, OID_AUTO, burst, CTLFLAG_RWTUN, &ec_burst_mode, 0, +TUNABLE_INT("debug.acpi.ec.burst", &ec_burst_mode); +SYSCTL_INT(_debug_acpi_ec, OID_AUTO, burst, CTLFLAG_RW, &ec_burst_mode, 0, "Enable use of burst mode (faster for nearly all systems)"); static int ec_polled_mode; -SYSCTL_INT(_debug_acpi_ec, OID_AUTO, polled, CTLFLAG_RWTUN, &ec_polled_mode, 0, +TUNABLE_INT("debug.acpi.ec.polled", &ec_polled_mode); +SYSCTL_INT(_debug_acpi_ec, OID_AUTO, polled, CTLFLAG_RW, &ec_polled_mode, 0, "Force use of polled mode (only if interrupt mode doesn't work)"); static int ec_timeout = EC_TIMEOUT; -SYSCTL_INT(_debug_acpi_ec, OID_AUTO, timeout, CTLFLAG_RWTUN, &ec_timeout, +TUNABLE_INT("debug.acpi.ec.timeout", &ec_timeout); +SYSCTL_INT(_debug_acpi_ec, OID_AUTO, timeout, CTLFLAG_RW, &ec_timeout, EC_TIMEOUT, "Total time spent waiting for a response (poll+sleep)"); static ACPI_STATUS diff --git a/sys/dev/amr/amr_pci.c b/sys/dev/amr/amr_pci.c index 9346e8c5090b5..81ddc32c7cdec 100644 --- a/sys/dev/amr/amr_pci.c +++ b/sys/dev/amr/amr_pci.c @@ -92,6 +92,7 @@ static int amr_setup_mbox(struct amr_softc *sc); static int amr_ccb_map(struct amr_softc *sc); static u_int amr_force_sg32 = 0; +TUNABLE_INT("hw.amr.force_sg32", &amr_force_sg32); SYSCTL_DECL(_hw_amr); SYSCTL_UINT(_hw_amr, OID_AUTO, force_sg32, CTLFLAG_RDTUN, &amr_force_sg32, 0, "Force the AMR driver to use 32bit scatter gather"); diff --git a/sys/dev/ata/ata-all.c b/sys/dev/ata/ata-all.c index 579a2c5e6f7aa..b45c868d63f70 100644 --- a/sys/dev/ata/ata-all.c +++ b/sys/dev/ata/ata-all.c @@ -80,8 +80,9 @@ int ata_dma_check_80pin = 1; /* sysctl vars */ static SYSCTL_NODE(_hw, OID_AUTO, ata, CTLFLAG_RD, 0, "ATA driver parameters"); +TUNABLE_INT("hw.ata.ata_dma_check_80pin", &ata_dma_check_80pin); SYSCTL_INT(_hw_ata, OID_AUTO, ata_dma_check_80pin, - CTLFLAG_RWTUN, &ata_dma_check_80pin, 0, + CTLFLAG_RW, &ata_dma_check_80pin, 1, "Check for 80pin cable before setting ATA DMA mode"); FEATURE(ata_cam, "ATA devices are accessed through the cam(4) driver"); diff --git a/sys/dev/ath/ah_osdep.c b/sys/dev/ath/ah_osdep.c index fe4a657c98c85..8e9edd139be47 100644 --- a/sys/dev/ath/ah_osdep.c +++ b/sys/dev/ath/ah_osdep.c @@ -96,8 +96,9 @@ static SYSCTL_NODE(_hw_ath, OID_AUTO, hal, CTLFLAG_RD, 0, #ifdef AH_DEBUG int ath_hal_debug = 0; -SYSCTL_INT(_hw_ath_hal, OID_AUTO, debug, CTLFLAG_RWTUN, &ath_hal_debug, +SYSCTL_INT(_hw_ath_hal, OID_AUTO, debug, CTLFLAG_RW, &ath_hal_debug, 0, "Atheros HAL debugging printfs"); +TUNABLE_INT("hw.ath.hal.debug", &ath_hal_debug); #endif /* AH_DEBUG */ static MALLOC_DEFINE(M_ATH_HAL, "ath_hal", "ath hal data"); diff --git a/sys/dev/ath/if_ath.c b/sys/dev/ath/if_ath.c index f176b6391b63f..a3ab2f61dbfa3 100644 --- a/sys/dev/ath/if_ath.c +++ b/sys/dev/ath/if_ath.c @@ -240,14 +240,17 @@ SYSCTL_INT(_hw_ath, OID_AUTO, anical, CTLFLAG_RW, &ath_anicalinterval, 0, "ANI calibration (msecs)"); int ath_rxbuf = ATH_RXBUF; /* # rx buffers to allocate */ -SYSCTL_INT(_hw_ath, OID_AUTO, rxbuf, CTLFLAG_RWTUN, &ath_rxbuf, +SYSCTL_INT(_hw_ath, OID_AUTO, rxbuf, CTLFLAG_RW, &ath_rxbuf, 0, "rx buffers allocated"); +TUNABLE_INT("hw.ath.rxbuf", &ath_rxbuf); int ath_txbuf = ATH_TXBUF; /* # tx buffers to allocate */ -SYSCTL_INT(_hw_ath, OID_AUTO, txbuf, CTLFLAG_RWTUN, &ath_txbuf, +SYSCTL_INT(_hw_ath, OID_AUTO, txbuf, CTLFLAG_RW, &ath_txbuf, 0, "tx buffers allocated"); +TUNABLE_INT("hw.ath.txbuf", &ath_txbuf); int ath_txbuf_mgmt = ATH_MGMT_TXBUF; /* # mgmt tx buffers to allocate */ -SYSCTL_INT(_hw_ath, OID_AUTO, txbuf_mgmt, CTLFLAG_RWTUN, &ath_txbuf_mgmt, +SYSCTL_INT(_hw_ath, OID_AUTO, txbuf_mgmt, CTLFLAG_RW, &ath_txbuf_mgmt, 0, "tx (mgmt) buffers allocated"); +TUNABLE_INT("hw.ath.txbuf_mgmt", &ath_txbuf_mgmt); int ath_bstuck_threshold = 4; /* max missed beacons */ SYSCTL_INT(_hw_ath, OID_AUTO, bstuck, CTLFLAG_RW, &ath_bstuck_threshold, diff --git a/sys/dev/ath/if_ath_debug.c b/sys/dev/ath/if_ath_debug.c index d21ad6fea6f02..e3c73f561b8bc 100644 --- a/sys/dev/ath/if_ath_debug.c +++ b/sys/dev/ath/if_ath_debug.c @@ -92,8 +92,9 @@ __FBSDID("$FreeBSD$"); uint64_t ath_debug = 0; SYSCTL_DECL(_hw_ath); -SYSCTL_QUAD(_hw_ath, OID_AUTO, debug, CTLFLAG_RWTUN, &ath_debug, +SYSCTL_QUAD(_hw_ath, OID_AUTO, debug, CTLFLAG_RW, &ath_debug, 0, "control debugging printfs"); +TUNABLE_QUAD("hw.ath.debug", &ath_debug); void ath_printrxbuf(struct ath_softc *sc, const struct ath_buf *bf, diff --git a/sys/dev/bce/if_bce.c b/sys/dev/bce/if_bce.c index dfb1dc4a52493..c888b499b19f9 100644 --- a/sys/dev/bce/if_bce.c +++ b/sys/dev/bce/if_bce.c @@ -535,37 +535,44 @@ static SYSCTL_NODE(_hw, OID_AUTO, bce, CTLFLAG_RD, 0, "bce driver parameters"); /* Allowable values are TRUE or FALSE */ static int bce_verbose = TRUE; +TUNABLE_INT("hw.bce.verbose", &bce_verbose); SYSCTL_INT(_hw_bce, OID_AUTO, verbose, CTLFLAG_RDTUN, &bce_verbose, 0, "Verbose output enable/disable"); /* Allowable values are TRUE or FALSE */ static int bce_tso_enable = TRUE; +TUNABLE_INT("hw.bce.tso_enable", &bce_tso_enable); SYSCTL_INT(_hw_bce, OID_AUTO, tso_enable, CTLFLAG_RDTUN, &bce_tso_enable, 0, "TSO Enable/Disable"); /* Allowable values are 0 (IRQ), 1 (MSI/IRQ), and 2 (MSI-X/MSI/IRQ) */ /* ToDo: Add MSI-X support. */ static int bce_msi_enable = 1; +TUNABLE_INT("hw.bce.msi_enable", &bce_msi_enable); SYSCTL_INT(_hw_bce, OID_AUTO, msi_enable, CTLFLAG_RDTUN, &bce_msi_enable, 0, "MSI-X|MSI|INTx selector"); /* Allowable values are 1, 2, 4, 8. */ static int bce_rx_pages = DEFAULT_RX_PAGES; +TUNABLE_INT("hw.bce.rx_pages", &bce_rx_pages); SYSCTL_UINT(_hw_bce, OID_AUTO, rx_pages, CTLFLAG_RDTUN, &bce_rx_pages, 0, "Receive buffer descriptor pages (1 page = 255 buffer descriptors)"); /* Allowable values are 1, 2, 4, 8. */ static int bce_tx_pages = DEFAULT_TX_PAGES; +TUNABLE_INT("hw.bce.tx_pages", &bce_tx_pages); SYSCTL_UINT(_hw_bce, OID_AUTO, tx_pages, CTLFLAG_RDTUN, &bce_tx_pages, 0, "Transmit buffer descriptor pages (1 page = 255 buffer descriptors)"); /* Allowable values are TRUE or FALSE. */ static int bce_hdr_split = TRUE; +TUNABLE_INT("hw.bce.hdr_split", &bce_hdr_split); SYSCTL_UINT(_hw_bce, OID_AUTO, hdr_split, CTLFLAG_RDTUN, &bce_hdr_split, 0, "Frame header/payload splitting Enable/Disable"); /* Allowable values are TRUE or FALSE. */ static int bce_strict_rx_mtu = FALSE; +TUNABLE_INT("hw.bce.strict_rx_mtu", &bce_strict_rx_mtu); SYSCTL_UINT(_hw_bce, OID_AUTO, strict_rx_mtu, CTLFLAG_RDTUN, &bce_strict_rx_mtu, 0, "Enable/Disable strict RX frame size checking"); @@ -578,6 +585,7 @@ static int bce_tx_quick_cons_trip_int = 1; /* Generate 1 interrupt for every 20 transmit completions. */ static int bce_tx_quick_cons_trip_int = DEFAULT_TX_QUICK_CONS_TRIP_INT; #endif +TUNABLE_INT("hw.bce.tx_quick_cons_trip_int", &bce_tx_quick_cons_trip_int); SYSCTL_UINT(_hw_bce, OID_AUTO, tx_quick_cons_trip_int, CTLFLAG_RDTUN, &bce_tx_quick_cons_trip_int, 0, "Transmit BD trip point during interrupts"); @@ -590,6 +598,7 @@ static int bce_tx_quick_cons_trip = 1; /* Generate 1 interrupt for every 20 transmit completions. */ static int bce_tx_quick_cons_trip = DEFAULT_TX_QUICK_CONS_TRIP; #endif +TUNABLE_INT("hw.bce.tx_quick_cons_trip", &bce_tx_quick_cons_trip); SYSCTL_UINT(_hw_bce, OID_AUTO, tx_quick_cons_trip, CTLFLAG_RDTUN, &bce_tx_quick_cons_trip, 0, "Transmit BD trip point"); @@ -602,6 +611,7 @@ static int bce_tx_ticks_int = 0; /* Generate an interrupt if 80us have elapsed since the last TX completion. */ static int bce_tx_ticks_int = DEFAULT_TX_TICKS_INT; #endif +TUNABLE_INT("hw.bce.tx_ticks_int", &bce_tx_ticks_int); SYSCTL_UINT(_hw_bce, OID_AUTO, tx_ticks_int, CTLFLAG_RDTUN, &bce_tx_ticks_int, 0, "Transmit ticks count during interrupt"); @@ -613,6 +623,7 @@ static int bce_tx_ticks = 0; /* Generate an interrupt if 80us have elapsed since the last TX completion. */ static int bce_tx_ticks = DEFAULT_TX_TICKS; #endif +TUNABLE_INT("hw.bce.tx_ticks", &bce_tx_ticks); SYSCTL_UINT(_hw_bce, OID_AUTO, tx_ticks, CTLFLAG_RDTUN, &bce_tx_ticks, 0, "Transmit ticks count"); @@ -624,6 +635,7 @@ static int bce_rx_quick_cons_trip_int = 1; /* Generate 1 interrupt for every 6 received frames. */ static int bce_rx_quick_cons_trip_int = DEFAULT_RX_QUICK_CONS_TRIP_INT; #endif +TUNABLE_INT("hw.bce.rx_quick_cons_trip_int", &bce_rx_quick_cons_trip_int); SYSCTL_UINT(_hw_bce, OID_AUTO, rx_quick_cons_trip_int, CTLFLAG_RDTUN, &bce_rx_quick_cons_trip_int, 0, "Receive BD trip point duirng interrupts"); @@ -636,6 +648,7 @@ static int bce_rx_quick_cons_trip = 1; /* Generate 1 interrupt for every 6 received frames. */ static int bce_rx_quick_cons_trip = DEFAULT_RX_QUICK_CONS_TRIP; #endif +TUNABLE_INT("hw.bce.rx_quick_cons_trip", &bce_rx_quick_cons_trip); SYSCTL_UINT(_hw_bce, OID_AUTO, rx_quick_cons_trip, CTLFLAG_RDTUN, &bce_rx_quick_cons_trip, 0, "Receive BD trip point"); @@ -648,6 +661,7 @@ static int bce_rx_ticks_int = 0; /* Generate an int. if 18us have elapsed since the last received frame. */ static int bce_rx_ticks_int = DEFAULT_RX_TICKS_INT; #endif +TUNABLE_INT("hw.bce.rx_ticks_int", &bce_rx_ticks_int); SYSCTL_UINT(_hw_bce, OID_AUTO, rx_ticks_int, CTLFLAG_RDTUN, &bce_rx_ticks_int, 0, "Receive ticks count during interrupt"); @@ -659,6 +673,7 @@ static int bce_rx_ticks = 0; /* Generate an int. if 18us have elapsed since the last received frame. */ static int bce_rx_ticks = DEFAULT_RX_TICKS; #endif +TUNABLE_INT("hw.bce.rx_ticks", &bce_rx_ticks); SYSCTL_UINT(_hw_bce, OID_AUTO, rx_ticks, CTLFLAG_RDTUN, &bce_rx_ticks, 0, "Receive ticks count"); diff --git a/sys/dev/bge/if_bge.c b/sys/dev/bge/if_bge.c index e236771bcaa92..40f562ede6de2 100644 --- a/sys/dev/bge/if_bge.c +++ b/sys/dev/bge/if_bge.c @@ -542,8 +542,10 @@ DRIVER_MODULE(miibus, bge, miibus_driver, miibus_devclass, 0, 0); static int bge_allow_asf = 1; +TUNABLE_INT("hw.bge.allow_asf", &bge_allow_asf); + static SYSCTL_NODE(_hw, OID_AUTO, bge, CTLFLAG_RD, 0, "BGE driver parameters"); -SYSCTL_INT(_hw_bge, OID_AUTO, allow_asf, CTLFLAG_RDTUN, &bge_allow_asf, 0, +SYSCTL_INT(_hw_bge, OID_AUTO, allow_asf, CTLFLAG_RD, &bge_allow_asf, 0, "Allow ASF mode if available"); #define SPARC64_BLADE_1500_MODEL "SUNW,Sun-Blade-1500" @@ -6235,6 +6237,7 @@ bge_add_sysctls(struct bge_softc *sc) { struct sysctl_ctx_list *ctx; struct sysctl_oid_list *children; + char tn[32]; int unit; ctx = device_get_sysctl_ctx(sc->bge_dev); @@ -6273,14 +6276,18 @@ bge_add_sysctls(struct bge_softc *sc) * consumes a lot of CPU cycles, so leave it off by default. */ sc->bge_forced_collapse = 0; + snprintf(tn, sizeof(tn), "dev.bge.%d.forced_collapse", unit); + TUNABLE_INT_FETCH(tn, &sc->bge_forced_collapse); SYSCTL_ADD_INT(ctx, children, OID_AUTO, "forced_collapse", - CTLFLAG_RWTUN, &sc->bge_forced_collapse, 0, + CTLFLAG_RW, &sc->bge_forced_collapse, 0, "Number of fragmented TX buffers of a frame allowed before " "forced collapsing"); sc->bge_msi = 1; + snprintf(tn, sizeof(tn), "dev.bge.%d.msi", unit); + TUNABLE_INT_FETCH(tn, &sc->bge_msi); SYSCTL_ADD_INT(ctx, children, OID_AUTO, "msi", - CTLFLAG_RDTUN, &sc->bge_msi, 0, "Enable MSI"); + CTLFLAG_RD, &sc->bge_msi, 0, "Enable MSI"); /* * It seems all Broadcom controllers have a bug that can generate UDP @@ -6293,8 +6300,10 @@ bge_add_sysctls(struct bge_softc *sc) * dev.bge.0.forced_udpcsum. */ sc->bge_forced_udpcsum = 0; + snprintf(tn, sizeof(tn), "dev.bge.%d.bge_forced_udpcsum", unit); + TUNABLE_INT_FETCH(tn, &sc->bge_forced_udpcsum); SYSCTL_ADD_INT(ctx, children, OID_AUTO, "forced_udpcsum", - CTLFLAG_RWTUN, &sc->bge_forced_udpcsum, 0, + CTLFLAG_RW, &sc->bge_forced_udpcsum, 0, "Enable UDP checksum offloading even if controller can " "generate UDP checksum value 0"); diff --git a/sys/dev/bwn/if_bwn.c b/sys/dev/bwn/if_bwn.c index 4e9a8d9ba36c8..cc34b12095e0a 100644 --- a/sys/dev/bwn/if_bwn.c +++ b/sys/dev/bwn/if_bwn.c @@ -83,8 +83,9 @@ static SYSCTL_NODE(_hw, OID_AUTO, bwn, CTLFLAG_RD, 0, #ifdef BWN_DEBUG static int bwn_debug = 0; -SYSCTL_INT(_hw_bwn, OID_AUTO, debug, CTLFLAG_RWTUN, &bwn_debug, 0, +SYSCTL_INT(_hw_bwn, OID_AUTO, debug, CTLFLAG_RW, &bwn_debug, 0, "Broadcom debugging printfs"); +TUNABLE_INT("hw.bwn.debug", &bwn_debug); enum { BWN_DEBUG_XMIT = 0x00000001, /* basic xmit operation */ BWN_DEBUG_RECV = 0x00000002, /* basic recv operation */ diff --git a/sys/dev/bxe/bxe.c b/sys/dev/bxe/bxe.c index 974852bce47e3..feae5bcf78c7e 100644 --- a/sys/dev/bxe/bxe.c +++ b/sys/dev/bxe/bxe.c @@ -297,56 +297,67 @@ SYSCTL_NODE(_hw, OID_AUTO, bxe, CTLFLAG_RD, 0, "bxe driver parameters"); /* Debug */ unsigned long bxe_debug = 0; -SYSCTL_ULONG(_hw_bxe, OID_AUTO, debug, CTLFLAG_RDTUN, +TUNABLE_ULONG("hw.bxe.debug", &bxe_debug); +SYSCTL_ULONG(_hw_bxe, OID_AUTO, debug, (CTLFLAG_RDTUN), &bxe_debug, 0, "Debug logging mode"); /* Interrupt Mode: 0 (IRQ), 1 (MSI/IRQ), and 2 (MSI-X/MSI/IRQ) */ static int bxe_interrupt_mode = INTR_MODE_MSIX; +TUNABLE_INT("hw.bxe.interrupt_mode", &bxe_interrupt_mode); SYSCTL_INT(_hw_bxe, OID_AUTO, interrupt_mode, CTLFLAG_RDTUN, &bxe_interrupt_mode, 0, "Interrupt (MSI-X/MSI/INTx) mode"); /* Number of Queues: 0 (Auto) or 1 to 16 (fixed queue number) */ static int bxe_queue_count = 4; +TUNABLE_INT("hw.bxe.queue_count", &bxe_queue_count); SYSCTL_INT(_hw_bxe, OID_AUTO, queue_count, CTLFLAG_RDTUN, &bxe_queue_count, 0, "Multi-Queue queue count"); /* max number of buffers per queue (default RX_BD_USABLE) */ static int bxe_max_rx_bufs = 0; +TUNABLE_INT("hw.bxe.max_rx_bufs", &bxe_max_rx_bufs); SYSCTL_INT(_hw_bxe, OID_AUTO, max_rx_bufs, CTLFLAG_RDTUN, &bxe_max_rx_bufs, 0, "Maximum Number of Rx Buffers Per Queue"); /* Host interrupt coalescing RX tick timer (usecs) */ static int bxe_hc_rx_ticks = 25; +TUNABLE_INT("hw.bxe.hc_rx_ticks", &bxe_hc_rx_ticks); SYSCTL_INT(_hw_bxe, OID_AUTO, hc_rx_ticks, CTLFLAG_RDTUN, &bxe_hc_rx_ticks, 0, "Host Coalescing Rx ticks"); /* Host interrupt coalescing TX tick timer (usecs) */ static int bxe_hc_tx_ticks = 50; +TUNABLE_INT("hw.bxe.hc_tx_ticks", &bxe_hc_tx_ticks); SYSCTL_INT(_hw_bxe, OID_AUTO, hc_tx_ticks, CTLFLAG_RDTUN, &bxe_hc_tx_ticks, 0, "Host Coalescing Tx ticks"); /* Maximum number of Rx packets to process at a time */ static int bxe_rx_budget = 0xffffffff; +TUNABLE_INT("hw.bxe.rx_budget", &bxe_rx_budget); SYSCTL_INT(_hw_bxe, OID_AUTO, rx_budget, CTLFLAG_TUN, &bxe_rx_budget, 0, "Rx processing budget"); /* Maximum LRO aggregation size */ static int bxe_max_aggregation_size = 0; +TUNABLE_INT("hw.bxe.max_aggregation_size", &bxe_max_aggregation_size); SYSCTL_INT(_hw_bxe, OID_AUTO, max_aggregation_size, CTLFLAG_TUN, &bxe_max_aggregation_size, 0, "max aggregation size"); /* PCI MRRS: -1 (Auto), 0 (128B), 1 (256B), 2 (512B), 3 (1KB) */ static int bxe_mrrs = -1; +TUNABLE_INT("hw.bxe.mrrs", &bxe_mrrs); SYSCTL_INT(_hw_bxe, OID_AUTO, mrrs, CTLFLAG_RDTUN, &bxe_mrrs, 0, "PCIe maximum read request size"); /* AutoGrEEEn: 0 (hardware default), 1 (force on), 2 (force off) */ static int bxe_autogreeen = 0; +TUNABLE_INT("hw.bxe.autogreeen", &bxe_autogreeen); SYSCTL_INT(_hw_bxe, OID_AUTO, autogreeen, CTLFLAG_RDTUN, &bxe_autogreeen, 0, "AutoGrEEEn support"); /* 4-tuple RSS support for UDP: 0 (disabled), 1 (enabled) */ static int bxe_udp_rss = 0; +TUNABLE_INT("hw.bxe.udp_rss", &bxe_udp_rss); SYSCTL_INT(_hw_bxe, OID_AUTO, udp_rss, CTLFLAG_RDTUN, &bxe_udp_rss, 0, "UDP RSS support"); diff --git a/sys/dev/cardbus/cardbus.c b/sys/dev/cardbus/cardbus.c index c591fe98042e7..00d4a19e8cf67 100644 --- a/sys/dev/cardbus/cardbus.c +++ b/sys/dev/cardbus/cardbus.c @@ -57,12 +57,16 @@ __FBSDID("$FreeBSD$"); static SYSCTL_NODE(_hw, OID_AUTO, cardbus, CTLFLAG_RD, 0, "CardBus parameters"); int cardbus_debug = 0; -SYSCTL_INT(_hw_cardbus, OID_AUTO, debug, CTLFLAG_RWTUN, - &cardbus_debug, 0, "CardBus debug"); +TUNABLE_INT("hw.cardbus.debug", &cardbus_debug); +SYSCTL_INT(_hw_cardbus, OID_AUTO, debug, CTLFLAG_RW, + &cardbus_debug, 0, + "CardBus debug"); int cardbus_cis_debug = 0; -SYSCTL_INT(_hw_cardbus, OID_AUTO, cis_debug, CTLFLAG_RWTUN, - &cardbus_cis_debug, 0, "CardBus CIS debug"); +TUNABLE_INT("hw.cardbus.cis_debug", &cardbus_cis_debug); +SYSCTL_INT(_hw_cardbus, OID_AUTO, cis_debug, CTLFLAG_RW, + &cardbus_cis_debug, 0, + "CardBus CIS debug"); #define DPRINTF(a) if (cardbus_debug) printf a #define DEVPRINTF(x) if (cardbus_debug) device_printf x diff --git a/sys/dev/cs/if_cs.c b/sys/dev/cs/if_cs.c index 502c2b34be734..b6a3d3b91f637 100644 --- a/sys/dev/cs/if_cs.c +++ b/sys/dev/cs/if_cs.c @@ -107,12 +107,14 @@ driver_intr_t csintr; static SYSCTL_NODE(_hw, OID_AUTO, cs, CTLFLAG_RD, 0, "cs device parameters"); int cs_ignore_cksum_failure = 0; -SYSCTL_INT(_hw_cs, OID_AUTO, ignore_checksum_failure, CTLFLAG_RWTUN, +TUNABLE_INT("hw.cs.ignore_checksum_failure", &cs_ignore_cksum_failure); +SYSCTL_INT(_hw_cs, OID_AUTO, ignore_checksum_failure, CTLFLAG_RW, &cs_ignore_cksum_failure, 0, "ignore checksum errors in cs card EEPROM"); static int cs_recv_delay = 570; -SYSCTL_INT(_hw_cs, OID_AUTO, recv_delay, CTLFLAG_RWTUN, &cs_recv_delay, 570, ""); +TUNABLE_INT("hw.cs.recv_delay", &cs_recv_delay); +SYSCTL_INT(_hw_cs, OID_AUTO, recv_delay, CTLFLAG_RW, &cs_recv_delay, 570, ""); static int cs8900_eeint2irq[16] = { 10, 11, 12, 5, 255, 255, 255, 255, diff --git a/sys/dev/cxgb/cxgb_include.h b/sys/dev/cxgb/cxgb_include.h index d98ef5771baac..90080b5313179 100644 --- a/sys/dev/cxgb/cxgb_include.h +++ b/sys/dev/cxgb/cxgb_include.h @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include @@ -17,5 +16,3 @@ #include #include #include - -SYSCTL_DECL(_hw_cxgb); diff --git a/sys/dev/cxgb/cxgb_main.c b/sys/dev/cxgb/cxgb_main.c index 30001293b2bb4..6ccf6e3774a38 100644 --- a/sys/dev/cxgb/cxgb_main.c +++ b/sys/dev/cxgb/cxgb_main.c @@ -208,6 +208,7 @@ static SLIST_HEAD(, uld_info) t3_uld_list; */ static int msi_allowed = 2; +TUNABLE_INT("hw.cxgb.msi_allowed", &msi_allowed); SYSCTL_NODE(_hw, OID_AUTO, cxgb, CTLFLAG_RD, 0, "CXGB driver parameters"); SYSCTL_INT(_hw_cxgb, OID_AUTO, msi_allowed, CTLFLAG_RDTUN, &msi_allowed, 0, "MSI-X, MSI, INTx selector"); @@ -217,6 +218,7 @@ SYSCTL_INT(_hw_cxgb, OID_AUTO, msi_allowed, CTLFLAG_RDTUN, &msi_allowed, 0, * To disable it and force a single queue-set per port, use multiq = 0 */ static int multiq = 1; +TUNABLE_INT("hw.cxgb.multiq", &multiq); SYSCTL_INT(_hw_cxgb, OID_AUTO, multiq, CTLFLAG_RDTUN, &multiq, 0, "use min(ncpus/ports, 8) queue-sets per port"); @@ -226,14 +228,17 @@ SYSCTL_INT(_hw_cxgb, OID_AUTO, multiq, CTLFLAG_RDTUN, &multiq, 0, * */ static int force_fw_update = 0; +TUNABLE_INT("hw.cxgb.force_fw_update", &force_fw_update); SYSCTL_INT(_hw_cxgb, OID_AUTO, force_fw_update, CTLFLAG_RDTUN, &force_fw_update, 0, "update firmware even if up to date"); int cxgb_use_16k_clusters = -1; +TUNABLE_INT("hw.cxgb.use_16k_clusters", &cxgb_use_16k_clusters); SYSCTL_INT(_hw_cxgb, OID_AUTO, use_16k_clusters, CTLFLAG_RDTUN, &cxgb_use_16k_clusters, 0, "use 16kB clusters for the jumbo queue "); static int nfilters = -1; +TUNABLE_INT("hw.cxgb.nfilters", &nfilters); SYSCTL_INT(_hw_cxgb, OID_AUTO, nfilters, CTLFLAG_RDTUN, &nfilters, 0, "max number of entries in the filter table"); diff --git a/sys/dev/cxgb/cxgb_sge.c b/sys/dev/cxgb/cxgb_sge.c index fcc0376fab763..42744faa44ded 100644 --- a/sys/dev/cxgb/cxgb_sge.c +++ b/sys/dev/cxgb/cxgb_sge.c @@ -86,11 +86,13 @@ CTASSERT(NUM_CPL_HANDLERS >= NUM_CPL_CMDS); extern struct sysctl_oid_list sysctl__hw_cxgb_children; int cxgb_txq_buf_ring_size = TX_ETH_Q_SIZE; +TUNABLE_INT("hw.cxgb.txq_mr_size", &cxgb_txq_buf_ring_size); SYSCTL_INT(_hw_cxgb, OID_AUTO, txq_mr_size, CTLFLAG_RDTUN, &cxgb_txq_buf_ring_size, 0, "size of per-queue mbuf ring"); static int cxgb_tx_coalesce_force = 0; -SYSCTL_INT(_hw_cxgb, OID_AUTO, tx_coalesce_force, CTLFLAG_RWTUN, +TUNABLE_INT("hw.cxgb.tx_coalesce_force", &cxgb_tx_coalesce_force); +SYSCTL_INT(_hw_cxgb, OID_AUTO, tx_coalesce_force, CTLFLAG_RW, &cxgb_tx_coalesce_force, 0, "coalesce small packets into a single work request regardless of ring state"); @@ -104,15 +106,19 @@ SYSCTL_INT(_hw_cxgb, OID_AUTO, tx_coalesce_force, CTLFLAG_RWTUN, static int cxgb_tx_coalesce_enable_start = COALESCE_START_DEFAULT; -SYSCTL_INT(_hw_cxgb, OID_AUTO, tx_coalesce_enable_start, CTLFLAG_RWTUN, +TUNABLE_INT("hw.cxgb.tx_coalesce_enable_start", + &cxgb_tx_coalesce_enable_start); +SYSCTL_INT(_hw_cxgb, OID_AUTO, tx_coalesce_enable_start, CTLFLAG_RW, &cxgb_tx_coalesce_enable_start, 0, "coalesce enable threshold"); static int cxgb_tx_coalesce_enable_stop = COALESCE_STOP_DEFAULT; -SYSCTL_INT(_hw_cxgb, OID_AUTO, tx_coalesce_enable_stop, CTLFLAG_RWTUN, +TUNABLE_INT("hw.cxgb.tx_coalesce_enable_stop", &cxgb_tx_coalesce_enable_stop); +SYSCTL_INT(_hw_cxgb, OID_AUTO, tx_coalesce_enable_stop, CTLFLAG_RW, &cxgb_tx_coalesce_enable_stop, 0, "coalesce disable threshold"); static int cxgb_tx_reclaim_threshold = TX_RECLAIM_DEFAULT; -SYSCTL_INT(_hw_cxgb, OID_AUTO, tx_reclaim_threshold, CTLFLAG_RWTUN, +TUNABLE_INT("hw.cxgb.tx_reclaim_threshold", &cxgb_tx_reclaim_threshold); +SYSCTL_INT(_hw_cxgb, OID_AUTO, tx_reclaim_threshold, CTLFLAG_RW, &cxgb_tx_reclaim_threshold, 0, "tx cleaning minimum threshold"); diff --git a/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c b/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c index fea86eba709de..9afad627d5aed 100644 --- a/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c +++ b/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c @@ -106,35 +106,43 @@ static char *states[] = { SYSCTL_NODE(_hw, OID_AUTO, iw_cxgb, CTLFLAG_RD, 0, "iw_cxgb driver parameters"); static int ep_timeout_secs = 60; -SYSCTL_INT(_hw_iw_cxgb, OID_AUTO, ep_timeout_secs, CTLFLAG_RWTUN, &ep_timeout_secs, 0, +TUNABLE_INT("hw.iw_cxgb.ep_timeout_secs", &ep_timeout_secs); +SYSCTL_INT(_hw_iw_cxgb, OID_AUTO, ep_timeout_secs, CTLFLAG_RW, &ep_timeout_secs, 0, "CM Endpoint operation timeout in seconds (default=60)"); static int mpa_rev = 1; -SYSCTL_INT(_hw_iw_cxgb, OID_AUTO, mpa_rev, CTLFLAG_RWTUN, &mpa_rev, 0, +TUNABLE_INT("hw.iw_cxgb.mpa_rev", &mpa_rev); +SYSCTL_INT(_hw_iw_cxgb, OID_AUTO, mpa_rev, CTLFLAG_RW, &mpa_rev, 0, "MPA Revision, 0 supports amso1100, 1 is spec compliant. (default=1)"); static int markers_enabled = 0; -SYSCTL_INT(_hw_iw_cxgb, OID_AUTO, markers_enabled, CTLFLAG_RWTUN, &markers_enabled, 0, +TUNABLE_INT("hw.iw_cxgb.markers_enabled", &markers_enabled); +SYSCTL_INT(_hw_iw_cxgb, OID_AUTO, markers_enabled, CTLFLAG_RW, &markers_enabled, 0, "Enable MPA MARKERS (default(0)=disabled)"); static int crc_enabled = 1; -SYSCTL_INT(_hw_iw_cxgb, OID_AUTO, crc_enabled, CTLFLAG_RWTUN, &crc_enabled, 0, +TUNABLE_INT("hw.iw_cxgb.crc_enabled", &crc_enabled); +SYSCTL_INT(_hw_iw_cxgb, OID_AUTO, crc_enabled, CTLFLAG_RW, &crc_enabled, 0, "Enable MPA CRC (default(1)=enabled)"); static int rcv_win = 256 * 1024; -SYSCTL_INT(_hw_iw_cxgb, OID_AUTO, rcv_win, CTLFLAG_RWTUN, &rcv_win, 0, +TUNABLE_INT("hw.iw_cxgb.rcv_win", &rcv_win); +SYSCTL_INT(_hw_iw_cxgb, OID_AUTO, rcv_win, CTLFLAG_RW, &rcv_win, 0, "TCP receive window in bytes (default=256KB)"); static int snd_win = 32 * 1024; -SYSCTL_INT(_hw_iw_cxgb, OID_AUTO, snd_win, CTLFLAG_RWTUN, &snd_win, 0, +TUNABLE_INT("hw.iw_cxgb.snd_win", &snd_win); +SYSCTL_INT(_hw_iw_cxgb, OID_AUTO, snd_win, CTLFLAG_RW, &snd_win, 0, "TCP send window in bytes (default=32KB)"); static unsigned int nocong = 0; -SYSCTL_UINT(_hw_iw_cxgb, OID_AUTO, nocong, CTLFLAG_RWTUN, &nocong, 0, +TUNABLE_INT("hw.iw_cxgb.nocong", &nocong); +SYSCTL_UINT(_hw_iw_cxgb, OID_AUTO, nocong, CTLFLAG_RW, &nocong, 0, "Turn off congestion control (default=0)"); static unsigned int cong_flavor = 1; -SYSCTL_UINT(_hw_iw_cxgb, OID_AUTO, cong_flavor, CTLFLAG_RWTUN, &cong_flavor, 0, +TUNABLE_INT("hw.iw_cxgb.cong_flavor", &cong_flavor); +SYSCTL_UINT(_hw_iw_cxgb, OID_AUTO, cong_flavor, CTLFLAG_RW, &cong_flavor, 0, "TCP Congestion control flavor (default=1)"); static void ep_timeout(void *arg); diff --git a/sys/dev/cxgbe/iw_cxgbe/cm.c b/sys/dev/cxgbe/iw_cxgbe/cm.c index fb93a9b2b287a..03652a396a31c 100644 --- a/sys/dev/cxgbe/iw_cxgbe/cm.c +++ b/sys/dev/cxgbe/iw_cxgbe/cm.c @@ -769,72 +769,88 @@ process_socket_event(struct c4iw_ep *ep) SYSCTL_NODE(_hw, OID_AUTO, iw_cxgbe, CTLFLAG_RD, 0, "iw_cxgbe driver parameters"); int db_delay_usecs = 1; -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, db_delay_usecs, CTLFLAG_RWTUN, &db_delay_usecs, 0, +TUNABLE_INT("hw.iw_cxgbe.db_delay_usecs", &db_delay_usecs); +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, db_delay_usecs, CTLFLAG_RW, &db_delay_usecs, 0, "Usecs to delay awaiting db fifo to drain"); static int dack_mode = 1; -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, dack_mode, CTLFLAG_RWTUN, &dack_mode, 0, +TUNABLE_INT("hw.iw_cxgbe.dack_mode", &dack_mode); +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, dack_mode, CTLFLAG_RW, &dack_mode, 0, "Delayed ack mode (default = 1)"); int c4iw_max_read_depth = 8; -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, c4iw_max_read_depth, CTLFLAG_RWTUN, &c4iw_max_read_depth, 0, +TUNABLE_INT("hw.iw_cxgbe.c4iw_max_read_depth", &c4iw_max_read_depth); +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, c4iw_max_read_depth, CTLFLAG_RW, &c4iw_max_read_depth, 0, "Per-connection max ORD/IRD (default = 8)"); static int enable_tcp_timestamps; -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, enable_tcp_timestamps, CTLFLAG_RWTUN, &enable_tcp_timestamps, 0, +TUNABLE_INT("hw.iw_cxgbe.enable_tcp_timestamps", &enable_tcp_timestamps); +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, enable_tcp_timestamps, CTLFLAG_RW, &enable_tcp_timestamps, 0, "Enable tcp timestamps (default = 0)"); static int enable_tcp_sack; -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, enable_tcp_sack, CTLFLAG_RWTUN, &enable_tcp_sack, 0, +TUNABLE_INT("hw.iw_cxgbe.enable_tcp_sack", &enable_tcp_sack); +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, enable_tcp_sack, CTLFLAG_RW, &enable_tcp_sack, 0, "Enable tcp SACK (default = 0)"); static int enable_tcp_window_scaling = 1; -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, enable_tcp_window_scaling, CTLFLAG_RWTUN, &enable_tcp_window_scaling, 0, +TUNABLE_INT("hw.iw_cxgbe.enable_tcp_window_scaling", &enable_tcp_window_scaling); +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, enable_tcp_window_scaling, CTLFLAG_RW, &enable_tcp_window_scaling, 0, "Enable tcp window scaling (default = 1)"); int c4iw_debug = 1; -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, c4iw_debug, CTLFLAG_RWTUN, &c4iw_debug, 0, +TUNABLE_INT("hw.iw_cxgbe.c4iw_debug", &c4iw_debug); +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, c4iw_debug, CTLFLAG_RW, &c4iw_debug, 0, "Enable debug logging (default = 0)"); static int peer2peer; -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, peer2peer, CTLFLAG_RWTUN, &peer2peer, 0, +TUNABLE_INT("hw.iw_cxgbe.peer2peer", &peer2peer); +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, peer2peer, CTLFLAG_RW, &peer2peer, 0, "Support peer2peer ULPs (default = 0)"); static int p2p_type = FW_RI_INIT_P2PTYPE_READ_REQ; -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, p2p_type, CTLFLAG_RWTUN, &p2p_type, 0, +TUNABLE_INT("hw.iw_cxgbe.p2p_type", &p2p_type); +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, p2p_type, CTLFLAG_RW, &p2p_type, 0, "RDMAP opcode to use for the RTR message: 1 = RDMA_READ 0 = RDMA_WRITE (default 1)"); static int ep_timeout_secs = 60; -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, ep_timeout_secs, CTLFLAG_RWTUN, &ep_timeout_secs, 0, +TUNABLE_INT("hw.iw_cxgbe.ep_timeout_secs", &ep_timeout_secs); +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, ep_timeout_secs, CTLFLAG_RW, &ep_timeout_secs, 0, "CM Endpoint operation timeout in seconds (default = 60)"); static int mpa_rev = 1; +TUNABLE_INT("hw.iw_cxgbe.mpa_rev", &mpa_rev); #ifdef IW_CM_MPAV2 -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, mpa_rev, CTLFLAG_RWTUN, &mpa_rev, 0, +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, mpa_rev, CTLFLAG_RW, &mpa_rev, 0, "MPA Revision, 0 supports amso1100, 1 is RFC0544 spec compliant, 2 is IETF MPA Peer Connect Draft compliant (default = 1)"); #else -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, mpa_rev, CTLFLAG_RWTUN, &mpa_rev, 0, +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, mpa_rev, CTLFLAG_RW, &mpa_rev, 0, "MPA Revision, 0 supports amso1100, 1 is RFC0544 spec compliant (default = 1)"); #endif static int markers_enabled; -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, markers_enabled, CTLFLAG_RWTUN, &markers_enabled, 0, +TUNABLE_INT("hw.iw_cxgbe.markers_enabled", &markers_enabled); +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, markers_enabled, CTLFLAG_RW, &markers_enabled, 0, "Enable MPA MARKERS (default(0) = disabled)"); static int crc_enabled = 1; -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, crc_enabled, CTLFLAG_RWTUN, &crc_enabled, 0, +TUNABLE_INT("hw.iw_cxgbe.crc_enabled", &crc_enabled); +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, crc_enabled, CTLFLAG_RW, &crc_enabled, 0, "Enable MPA CRC (default(1) = enabled)"); static int rcv_win = 256 * 1024; -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, rcv_win, CTLFLAG_RWTUN, &rcv_win, 0, +TUNABLE_INT("hw.iw_cxgbe.rcv_win", &rcv_win); +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, rcv_win, CTLFLAG_RW, &rcv_win, 0, "TCP receive window in bytes (default = 256KB)"); static int snd_win = 128 * 1024; -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, snd_win, CTLFLAG_RWTUN, &snd_win, 0, +TUNABLE_INT("hw.iw_cxgbe.snd_win", &snd_win); +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, snd_win, CTLFLAG_RW, &snd_win, 0, "TCP send window in bytes (default = 128KB)"); int db_fc_threshold = 2000; -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, db_fc_threshold, CTLFLAG_RWTUN, &db_fc_threshold, 0, +TUNABLE_INT("hw.iw_cxgbe.db_fc_threshold", &db_fc_threshold); +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, db_fc_threshold, CTLFLAG_RW, &db_fc_threshold, 0, "QP count/threshold that triggers automatic"); static void diff --git a/sys/dev/drm/drm_drv.c b/sys/dev/drm/drm_drv.c index 75983766f3799..75902a7711dbe 100644 --- a/sys/dev/drm/drm_drv.c +++ b/sys/dev/drm/drm_drv.c @@ -132,6 +132,7 @@ static struct cdevsw drm_cdevsw = { }; static int drm_msi = 1; /* Enable by default. */ +TUNABLE_INT("hw.drm.msi", &drm_msi); SYSCTL_NODE(_hw, OID_AUTO, drm, CTLFLAG_RW, NULL, "DRM device"); SYSCTL_INT(_hw_drm, OID_AUTO, msi, CTLFLAG_RDTUN, &drm_msi, 1, "Enable MSI interrupts for drm devices"); diff --git a/sys/dev/drm/drm_sysctl.c b/sys/dev/drm/drm_sysctl.c index 75d8306c8405b..ce3e5b4c7ce84 100644 --- a/sys/dev/drm/drm_sysctl.c +++ b/sys/dev/drm/drm_sysctl.c @@ -70,7 +70,7 @@ int drm_sysctl_init(struct drm_device *dev) dev->sysctl = info; /* Add the sysctl node for DRI if it doesn't already exist */ - drioid = SYSCTL_ADD_NODE(&info->ctx, SYSCTL_CHILDREN(&sysctl___hw), OID_AUTO, "dri", CTLFLAG_RW, NULL, "DRI Graphics"); + drioid = SYSCTL_ADD_NODE( &info->ctx, &sysctl__hw_children, OID_AUTO, "dri", CTLFLAG_RW, NULL, "DRI Graphics"); if (!drioid) return 1; diff --git a/sys/dev/drm2/drm_drv.c b/sys/dev/drm2/drm_drv.c index 81fcee3dbe7cc..7b00bcf8cf433 100644 --- a/sys/dev/drm2/drm_drv.c +++ b/sys/dev/drm2/drm_drv.c @@ -203,6 +203,7 @@ static struct cdevsw drm_cdevsw = { }; static int drm_msi = 1; /* Enable by default. */ +TUNABLE_INT("hw.drm.msi", &drm_msi); SYSCTL_NODE(_hw, OID_AUTO, drm, CTLFLAG_RW, NULL, "DRM device"); SYSCTL_INT(_hw_drm, OID_AUTO, msi, CTLFLAG_RDTUN, &drm_msi, 1, "Enable MSI interrupts for drm devices"); diff --git a/sys/dev/drm2/drm_sysctl.c b/sys/dev/drm2/drm_sysctl.c index aac21e6a486ed..a30c7ab237a6b 100644 --- a/sys/dev/drm2/drm_sysctl.c +++ b/sys/dev/drm2/drm_sysctl.c @@ -68,7 +68,7 @@ int drm_sysctl_init(struct drm_device *dev) dev->sysctl = info; /* Add the sysctl node for DRI if it doesn't already exist */ - drioid = SYSCTL_ADD_NODE(&info->ctx, SYSCTL_CHILDREN(&sysctl___hw), OID_AUTO, + drioid = SYSCTL_ADD_NODE(&info->ctx, &sysctl__hw_children, OID_AUTO, "dri", CTLFLAG_RW, NULL, "DRI Graphics"); if (!drioid) return 1; diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c index d2872cb0a95c2..d44ad37bee7c9 100644 --- a/sys/dev/e1000/if_em.c +++ b/sys/dev/e1000/if_em.c @@ -353,6 +353,8 @@ static SYSCTL_NODE(_hw, OID_AUTO, em, CTLFLAG_RD, 0, "EM driver parameters"); static int em_tx_int_delay_dflt = EM_TICKS_TO_USECS(EM_TIDV); static int em_rx_int_delay_dflt = EM_TICKS_TO_USECS(EM_RDTR); +TUNABLE_INT("hw.em.tx_int_delay", &em_tx_int_delay_dflt); +TUNABLE_INT("hw.em.rx_int_delay", &em_rx_int_delay_dflt); SYSCTL_INT(_hw_em, OID_AUTO, tx_int_delay, CTLFLAG_RDTUN, &em_tx_int_delay_dflt, 0, "Default transmit interrupt delay in usecs"); SYSCTL_INT(_hw_em, OID_AUTO, rx_int_delay, CTLFLAG_RDTUN, &em_rx_int_delay_dflt, @@ -360,6 +362,8 @@ SYSCTL_INT(_hw_em, OID_AUTO, rx_int_delay, CTLFLAG_RDTUN, &em_rx_int_delay_dflt, static int em_tx_abs_int_delay_dflt = EM_TICKS_TO_USECS(EM_TADV); static int em_rx_abs_int_delay_dflt = EM_TICKS_TO_USECS(EM_RADV); +TUNABLE_INT("hw.em.tx_abs_int_delay", &em_tx_abs_int_delay_dflt); +TUNABLE_INT("hw.em.rx_abs_int_delay", &em_rx_abs_int_delay_dflt); SYSCTL_INT(_hw_em, OID_AUTO, tx_abs_int_delay, CTLFLAG_RDTUN, &em_tx_abs_int_delay_dflt, 0, "Default transmit interrupt delay limit in usecs"); @@ -369,26 +373,32 @@ SYSCTL_INT(_hw_em, OID_AUTO, rx_abs_int_delay, CTLFLAG_RDTUN, static int em_rxd = EM_DEFAULT_RXD; static int em_txd = EM_DEFAULT_TXD; +TUNABLE_INT("hw.em.rxd", &em_rxd); +TUNABLE_INT("hw.em.txd", &em_txd); SYSCTL_INT(_hw_em, OID_AUTO, rxd, CTLFLAG_RDTUN, &em_rxd, 0, "Number of receive descriptors per queue"); SYSCTL_INT(_hw_em, OID_AUTO, txd, CTLFLAG_RDTUN, &em_txd, 0, "Number of transmit descriptors per queue"); static int em_smart_pwr_down = FALSE; +TUNABLE_INT("hw.em.smart_pwr_down", &em_smart_pwr_down); SYSCTL_INT(_hw_em, OID_AUTO, smart_pwr_down, CTLFLAG_RDTUN, &em_smart_pwr_down, 0, "Set to true to leave smart power down enabled on newer adapters"); /* Controls whether promiscuous also shows bad packets */ static int em_debug_sbp = FALSE; +TUNABLE_INT("hw.em.sbp", &em_debug_sbp); SYSCTL_INT(_hw_em, OID_AUTO, sbp, CTLFLAG_RDTUN, &em_debug_sbp, 0, "Show bad packets in promiscuous mode"); static int em_enable_msix = TRUE; +TUNABLE_INT("hw.em.enable_msix", &em_enable_msix); SYSCTL_INT(_hw_em, OID_AUTO, enable_msix, CTLFLAG_RDTUN, &em_enable_msix, 0, "Enable MSI-X interrupts"); /* How many packets rxeof tries to clean at a time */ static int em_rx_process_limit = 100; +TUNABLE_INT("hw.em.rx_process_limit", &em_rx_process_limit); SYSCTL_INT(_hw_em, OID_AUTO, rx_process_limit, CTLFLAG_RDTUN, &em_rx_process_limit, 0, "Maximum number of received packets to process " @@ -396,6 +406,7 @@ SYSCTL_INT(_hw_em, OID_AUTO, rx_process_limit, CTLFLAG_RDTUN, /* Energy efficient ethernet - default to OFF */ static int eee_setting = 1; +TUNABLE_INT("hw.em.eee_setting", &eee_setting); SYSCTL_INT(_hw_em, OID_AUTO, eee_setting, CTLFLAG_RDTUN, &eee_setting, 0, "Enable Energy Efficient Ethernet"); diff --git a/sys/dev/e1000/if_igb.c b/sys/dev/e1000/if_igb.c index 5c54c8400f4c6..38153f4d3afc9 100644 --- a/sys/dev/e1000/if_igb.c +++ b/sys/dev/e1000/if_igb.c @@ -327,6 +327,8 @@ static SYSCTL_NODE(_hw, OID_AUTO, igb, CTLFLAG_RD, 0, "IGB driver parameters"); /* Descriptor defaults */ static int igb_rxd = IGB_DEFAULT_RXD; static int igb_txd = IGB_DEFAULT_TXD; +TUNABLE_INT("hw.igb.rxd", &igb_rxd); +TUNABLE_INT("hw.igb.txd", &igb_txd); SYSCTL_INT(_hw_igb, OID_AUTO, rxd, CTLFLAG_RDTUN, &igb_rxd, 0, "Number of receive descriptors per queue"); SYSCTL_INT(_hw_igb, OID_AUTO, txd, CTLFLAG_RDTUN, &igb_txd, 0, @@ -339,7 +341,8 @@ SYSCTL_INT(_hw_igb, OID_AUTO, txd, CTLFLAG_RDTUN, &igb_txd, 0, ** traffic for that interrupt vector */ static int igb_enable_aim = TRUE; -SYSCTL_INT(_hw_igb, OID_AUTO, enable_aim, CTLFLAG_RWTUN, &igb_enable_aim, 0, +TUNABLE_INT("hw.igb.enable_aim", &igb_enable_aim); +SYSCTL_INT(_hw_igb, OID_AUTO, enable_aim, CTLFLAG_RW, &igb_enable_aim, 0, "Enable adaptive interrupt moderation"); /* @@ -347,6 +350,7 @@ SYSCTL_INT(_hw_igb, OID_AUTO, enable_aim, CTLFLAG_RWTUN, &igb_enable_aim, 0, * but this allows it to be forced off for testing. */ static int igb_enable_msix = 1; +TUNABLE_INT("hw.igb.enable_msix", &igb_enable_msix); SYSCTL_INT(_hw_igb, OID_AUTO, enable_msix, CTLFLAG_RDTUN, &igb_enable_msix, 0, "Enable MSI-X interrupts"); @@ -354,6 +358,7 @@ SYSCTL_INT(_hw_igb, OID_AUTO, enable_msix, CTLFLAG_RDTUN, &igb_enable_msix, 0, ** Tuneable Interrupt rate */ static int igb_max_interrupt_rate = 8000; +TUNABLE_INT("hw.igb.max_interrupt_rate", &igb_max_interrupt_rate); SYSCTL_INT(_hw_igb, OID_AUTO, max_interrupt_rate, CTLFLAG_RDTUN, &igb_max_interrupt_rate, 0, "Maximum interrupts per second"); @@ -362,6 +367,7 @@ SYSCTL_INT(_hw_igb, OID_AUTO, max_interrupt_rate, CTLFLAG_RDTUN, ** Tuneable number of buffers in the buf-ring (drbr_xxx) */ static int igb_buf_ring_size = IGB_BR_SIZE; +TUNABLE_INT("hw.igb.buf_ring_size", &igb_buf_ring_size); SYSCTL_INT(_hw_igb, OID_AUTO, buf_ring_size, CTLFLAG_RDTUN, &igb_buf_ring_size, 0, "Size of the bufring"); #endif @@ -375,6 +381,7 @@ SYSCTL_INT(_hw_igb, OID_AUTO, buf_ring_size, CTLFLAG_RDTUN, ** a very workload dependent type feature. */ static int igb_header_split = FALSE; +TUNABLE_INT("hw.igb.hdr_split", &igb_header_split); SYSCTL_INT(_hw_igb, OID_AUTO, header_split, CTLFLAG_RDTUN, &igb_header_split, 0, "Enable receive mbuf header split"); @@ -384,6 +391,7 @@ SYSCTL_INT(_hw_igb, OID_AUTO, header_split, CTLFLAG_RDTUN, &igb_header_split, 0, ** MSIX messages if left at 0. */ static int igb_num_queues = 0; +TUNABLE_INT("hw.igb.num_queues", &igb_num_queues); SYSCTL_INT(_hw_igb, OID_AUTO, num_queues, CTLFLAG_RDTUN, &igb_num_queues, 0, "Number of queues to configure, 0 indicates autoconfigure"); @@ -396,6 +404,7 @@ static int igb_last_bind_cpu = -1; /* How many packets rxeof tries to clean at a time */ static int igb_rx_process_limit = 100; +TUNABLE_INT("hw.igb.rx_process_limit", &igb_rx_process_limit); SYSCTL_INT(_hw_igb, OID_AUTO, rx_process_limit, CTLFLAG_RDTUN, &igb_rx_process_limit, 0, "Maximum number of received packets to process at a time, -1 means unlimited"); diff --git a/sys/dev/fb/vesa.c b/sys/dev/fb/vesa.c index c7c2d641cdf47..48067b6401fe6 100644 --- a/sys/dev/fb/vesa.c +++ b/sys/dev/fb/vesa.c @@ -101,6 +101,7 @@ static video_adapter_t *vesa_adp; static SYSCTL_NODE(_debug, OID_AUTO, vesa, CTLFLAG_RD, NULL, "VESA debugging"); static int vesa_shadow_rom; +TUNABLE_INT("debug.vesa.shadow_rom", &vesa_shadow_rom); SYSCTL_INT(_debug_vesa, OID_AUTO, shadow_rom, CTLFLAG_RDTUN, &vesa_shadow_rom, 0, "Enable video BIOS shadow"); diff --git a/sys/dev/firewire/fwohci.c b/sys/dev/firewire/fwohci.c index 4ac43027bd405..ae753d53d30ca 100644 --- a/sys/dev/firewire/fwohci.c +++ b/sys/dev/firewire/fwohci.c @@ -78,13 +78,14 @@ #undef OHCI_DEBUG -static int nocyclemaster; +static int nocyclemaster = 0; int firewire_phydma_enable = 1; SYSCTL_DECL(_hw_firewire); -SYSCTL_INT(_hw_firewire, OID_AUTO, nocyclemaster, CTLFLAG_RWTUN, - &nocyclemaster, 0, "Do not send cycle start packets"); -SYSCTL_INT(_hw_firewire, OID_AUTO, phydma_enable, CTLFLAG_RWTUN, - &firewire_phydma_enable, 0, "Allow physical request DMA from firewire"); +SYSCTL_INT(_hw_firewire, OID_AUTO, nocyclemaster, CTLFLAG_RW, &nocyclemaster, 0, + "Do not send cycle start packets"); +SYSCTL_INT(_hw_firewire, OID_AUTO, phydma_enable, CTLFLAG_RW, + &firewire_phydma_enable, 1, "Allow physical request DMA from firewire"); +TUNABLE_INT("hw.firewire.phydma_enable", &firewire_phydma_enable); static char dbcode[16][0x10]={"OUTM", "OUTL","INPM","INPL", "STOR","LOAD","NOP ","STOP",}; diff --git a/sys/dev/firewire/if_fwe.c b/sys/dev/firewire/if_fwe.c index cb21cf61d4285..a7d9bc35d4945 100644 --- a/sys/dev/firewire/if_fwe.c +++ b/sys/dev/firewire/if_fwe.c @@ -88,17 +88,21 @@ static int tx_speed = 2; static int rx_queue_len = FWMAXQUEUE; static MALLOC_DEFINE(M_FWE, "if_fwe", "Ethernet over FireWire interface"); -SYSCTL_INT(_debug, OID_AUTO, if_fwe_debug, CTLFLAG_RWTUN, &fwedebug, 0, ""); +SYSCTL_INT(_debug, OID_AUTO, if_fwe_debug, CTLFLAG_RW, &fwedebug, 0, ""); SYSCTL_DECL(_hw_firewire); static SYSCTL_NODE(_hw_firewire, OID_AUTO, fwe, CTLFLAG_RD, 0, "Ethernet emulation subsystem"); -SYSCTL_INT(_hw_firewire_fwe, OID_AUTO, stream_ch, CTLFLAG_RWTUN, &stream_ch, 0, +SYSCTL_INT(_hw_firewire_fwe, OID_AUTO, stream_ch, CTLFLAG_RW, &stream_ch, 0, "Stream channel to use"); -SYSCTL_INT(_hw_firewire_fwe, OID_AUTO, tx_speed, CTLFLAG_RWTUN, &tx_speed, 0, +SYSCTL_INT(_hw_firewire_fwe, OID_AUTO, tx_speed, CTLFLAG_RW, &tx_speed, 0, "Transmission speed"); -SYSCTL_INT(_hw_firewire_fwe, OID_AUTO, rx_queue_len, CTLFLAG_RWTUN, &rx_queue_len, +SYSCTL_INT(_hw_firewire_fwe, OID_AUTO, rx_queue_len, CTLFLAG_RW, &rx_queue_len, 0, "Length of the receive queue"); +TUNABLE_INT("hw.firewire.fwe.stream_ch", &stream_ch); +TUNABLE_INT("hw.firewire.fwe.tx_speed", &tx_speed); +TUNABLE_INT("hw.firewire.fwe.rx_queue_len", &rx_queue_len); + #ifdef DEVICE_POLLING static poll_handler_t fwe_poll; diff --git a/sys/dev/firewire/if_fwip.c b/sys/dev/firewire/if_fwip.c index df3e1f6446d37..e98f44e237a3d 100644 --- a/sys/dev/firewire/if_fwip.c +++ b/sys/dev/firewire/if_fwip.c @@ -105,9 +105,11 @@ SYSCTL_INT(_debug, OID_AUTO, if_fwip_debug, CTLFLAG_RW, &fwipdebug, 0, ""); SYSCTL_DECL(_hw_firewire); static SYSCTL_NODE(_hw_firewire, OID_AUTO, fwip, CTLFLAG_RD, 0, "Firewire ip subsystem"); -SYSCTL_INT(_hw_firewire_fwip, OID_AUTO, rx_queue_len, CTLFLAG_RWTUN, &rx_queue_len, +SYSCTL_INT(_hw_firewire_fwip, OID_AUTO, rx_queue_len, CTLFLAG_RW, &rx_queue_len, 0, "Length of the receive queue"); +TUNABLE_INT("hw.firewire.fwip.rx_queue_len", &rx_queue_len); + #ifdef DEVICE_POLLING static poll_handler_t fwip_poll; diff --git a/sys/dev/firewire/sbp.c b/sys/dev/firewire/sbp.c index eeca4c77b4e70..10e8c60eea674 100644 --- a/sys/dev/firewire/sbp.c +++ b/sys/dev/firewire/sbp.c @@ -134,23 +134,31 @@ static int sbp_tags = 0; SYSCTL_DECL(_hw_firewire); static SYSCTL_NODE(_hw_firewire, OID_AUTO, sbp, CTLFLAG_RD, 0, "SBP-II Subsystem"); -SYSCTL_INT(_debug, OID_AUTO, sbp_debug, CTLFLAG_RWTUN, &debug, 0, +SYSCTL_INT(_debug, OID_AUTO, sbp_debug, CTLFLAG_RW, &debug, 0, "SBP debug flag"); -SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, auto_login, CTLFLAG_RWTUN, &auto_login, 0, +SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, auto_login, CTLFLAG_RW, &auto_login, 0, "SBP perform login automatically"); -SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, max_speed, CTLFLAG_RWTUN, &max_speed, 0, +SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, max_speed, CTLFLAG_RW, &max_speed, 0, "SBP transfer max speed"); -SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, exclusive_login, CTLFLAG_RWTUN, +SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, exclusive_login, CTLFLAG_RW, &ex_login, 0, "SBP enable exclusive login"); -SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, login_delay, CTLFLAG_RWTUN, +SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, login_delay, CTLFLAG_RW, &login_delay, 0, "SBP login delay in msec"); -SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, scan_delay, CTLFLAG_RWTUN, +SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, scan_delay, CTLFLAG_RW, &scan_delay, 0, "SBP scan delay in msec"); -SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, use_doorbell, CTLFLAG_RWTUN, +SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, use_doorbell, CTLFLAG_RW, &use_doorbell, 0, "SBP use doorbell request"); -SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, tags, CTLFLAG_RWTUN, &sbp_tags, 0, +SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, tags, CTLFLAG_RW, &sbp_tags, 0, "SBP tagged queuing support"); +TUNABLE_INT("hw.firewire.sbp.auto_login", &auto_login); +TUNABLE_INT("hw.firewire.sbp.max_speed", &max_speed); +TUNABLE_INT("hw.firewire.sbp.exclusive_login", &ex_login); +TUNABLE_INT("hw.firewire.sbp.login_delay", &login_delay); +TUNABLE_INT("hw.firewire.sbp.scan_delay", &scan_delay); +TUNABLE_INT("hw.firewire.sbp.use_doorbell", &use_doorbell); +TUNABLE_INT("hw.firewire.sbp.tags", &sbp_tags); + #define NEED_RESPONSE 0 #define SBP_SEG_MAX rounddown(0xffff, PAGE_SIZE) diff --git a/sys/dev/glxiic/glxiic.c b/sys/dev/glxiic/glxiic.c index 95d8602703f8f..939c32db07df5 100644 --- a/sys/dev/glxiic/glxiic.c +++ b/sys/dev/glxiic/glxiic.c @@ -314,6 +314,7 @@ glxiic_attach(device_t dev) struct sysctl_oid *tree; int error, irq, unit; uint32_t irq_map; + char tn[32]; sc = device_get_softc(dev); sc->dev = dev; @@ -401,8 +402,10 @@ glxiic_attach(device_t dev) tree = device_get_sysctl_tree(dev); sc->timeout = GLXIIC_DEFAULT_TIMEOUT; + snprintf(tn, sizeof(tn), "dev.glxiic.%d.timeout", unit); + TUNABLE_INT_FETCH(tn, &sc->timeout); SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "timeout", CTLFLAG_RWTUN, &sc->timeout, 0, + "timeout", CTLFLAG_RW | CTLFLAG_TUN, &sc->timeout, 0, "activity timeout in ms"); glxiic_gpio_enable(sc); diff --git a/sys/dev/hptmv/hptproc.c b/sys/dev/hptmv/hptproc.c index 1141edc06c632..93eff51d8dcb6 100644 --- a/sys/dev/hptmv/hptproc.c +++ b/sys/dev/hptmv/hptproc.c @@ -617,7 +617,7 @@ out: NULL, 0, hpt_status, "A", "Get/Set " #name " state") #else #define hptregister_node(name) \ - SYSCTL_ROOT_NODE(OID_AUTO, name, CTLFLAG_RW, 0, "Get/Set " #name " state root node"); \ + SYSCTL_NODE(, OID_AUTO, name, CTLFLAG_RW, 0, "Get/Set " #name " state root node"); \ SYSCTL_OID(_ ## name, OID_AUTO, status, CTLTYPE_STRING|CTLFLAG_RW, \ NULL, 0, hpt_status, "A", "Get/Set " #name " state"); #endif diff --git a/sys/dev/hwpmc/hwpmc_logging.c b/sys/dev/hwpmc/hwpmc_logging.c index ee5b89771f7b0..c9b8aeaf5af13 100644 --- a/sys/dev/hwpmc/hwpmc_logging.c +++ b/sys/dev/hwpmc/hwpmc_logging.c @@ -66,7 +66,8 @@ SYSCTL_DECL(_kern_hwpmc); */ static int pmclog_buffer_size = PMC_LOG_BUFFER_SIZE; -SYSCTL_INT(_kern_hwpmc, OID_AUTO, logbuffersize, CTLFLAG_RDTUN, +TUNABLE_INT(PMC_SYSCTL_NAME_PREFIX "logbuffersize", &pmclog_buffer_size); +SYSCTL_INT(_kern_hwpmc, OID_AUTO, logbuffersize, CTLFLAG_TUN|CTLFLAG_RD, &pmclog_buffer_size, 0, "size of log buffers in kilobytes"); /* @@ -74,7 +75,8 @@ SYSCTL_INT(_kern_hwpmc, OID_AUTO, logbuffersize, CTLFLAG_RDTUN, */ static int pmc_nlogbuffers = PMC_NLOGBUFFERS; -SYSCTL_INT(_kern_hwpmc, OID_AUTO, nbuffers, CTLFLAG_RDTUN, +TUNABLE_INT(PMC_SYSCTL_NAME_PREFIX "nbuffers", &pmc_nlogbuffers); +SYSCTL_INT(_kern_hwpmc, OID_AUTO, nbuffers, CTLFLAG_TUN|CTLFLAG_RD, &pmc_nlogbuffers, 0, "number of global log buffers"); /* diff --git a/sys/dev/hwpmc/hwpmc_mod.c b/sys/dev/hwpmc/hwpmc_mod.c index 6241638d13b03..8e5eac879d24a 100644 --- a/sys/dev/hwpmc/hwpmc_mod.c +++ b/sys/dev/hwpmc/hwpmc_mod.c @@ -234,7 +234,8 @@ static void pmc_generic_cpu_finalize(struct pmc_mdep *md); SYSCTL_DECL(_kern_hwpmc); static int pmc_callchaindepth = PMC_CALLCHAIN_DEPTH; -SYSCTL_INT(_kern_hwpmc, OID_AUTO, callchaindepth, CTLFLAG_RDTUN, +TUNABLE_INT(PMC_SYSCTL_NAME_PREFIX "callchaindepth", &pmc_callchaindepth); +SYSCTL_INT(_kern_hwpmc, OID_AUTO, callchaindepth, CTLFLAG_TUN|CTLFLAG_RD, &pmc_callchaindepth, 0, "depth of call chain records"); #ifdef DEBUG @@ -243,7 +244,7 @@ char pmc_debugstr[PMC_DEBUG_STRSIZE]; TUNABLE_STR(PMC_SYSCTL_NAME_PREFIX "debugflags", pmc_debugstr, sizeof(pmc_debugstr)); SYSCTL_PROC(_kern_hwpmc, OID_AUTO, debugflags, - CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_NOFETCH, + CTLTYPE_STRING|CTLFLAG_RW|CTLFLAG_TUN, 0, 0, pmc_debugflags_sysctl_handler, "A", "debug flags"); #endif @@ -253,7 +254,8 @@ SYSCTL_PROC(_kern_hwpmc, OID_AUTO, debugflags, */ static int pmc_hashsize = PMC_HASH_SIZE; -SYSCTL_INT(_kern_hwpmc, OID_AUTO, hashsize, CTLFLAG_RDTUN, +TUNABLE_INT(PMC_SYSCTL_NAME_PREFIX "hashsize", &pmc_hashsize); +SYSCTL_INT(_kern_hwpmc, OID_AUTO, hashsize, CTLFLAG_TUN|CTLFLAG_RD, &pmc_hashsize, 0, "rows in hash tables"); /* @@ -261,7 +263,8 @@ SYSCTL_INT(_kern_hwpmc, OID_AUTO, hashsize, CTLFLAG_RDTUN, */ static int pmc_nsamples = PMC_NSAMPLES; -SYSCTL_INT(_kern_hwpmc, OID_AUTO, nsamples, CTLFLAG_RDTUN, +TUNABLE_INT(PMC_SYSCTL_NAME_PREFIX "nsamples", &pmc_nsamples); +SYSCTL_INT(_kern_hwpmc, OID_AUTO, nsamples, CTLFLAG_TUN|CTLFLAG_RD, &pmc_nsamples, 0, "number of PC samples per CPU"); @@ -270,7 +273,8 @@ SYSCTL_INT(_kern_hwpmc, OID_AUTO, nsamples, CTLFLAG_RDTUN, */ static int pmc_mtxpool_size = PMC_MTXPOOL_SIZE; -SYSCTL_INT(_kern_hwpmc, OID_AUTO, mtxpoolsize, CTLFLAG_RDTUN, +TUNABLE_INT(PMC_SYSCTL_NAME_PREFIX "mtxpoolsize", &pmc_mtxpool_size); +SYSCTL_INT(_kern_hwpmc, OID_AUTO, mtxpoolsize, CTLFLAG_TUN|CTLFLAG_RD, &pmc_mtxpool_size, 0, "size of spin mutex pool"); @@ -284,7 +288,8 @@ SYSCTL_INT(_kern_hwpmc, OID_AUTO, mtxpoolsize, CTLFLAG_RDTUN, */ static int pmc_unprivileged_syspmcs = 0; -SYSCTL_INT(_security_bsd, OID_AUTO, unprivileged_syspmcs, CTLFLAG_RWTUN, +TUNABLE_INT("security.bsd.unprivileged_syspmcs", &pmc_unprivileged_syspmcs); +SYSCTL_INT(_security_bsd, OID_AUTO, unprivileged_syspmcs, CTLFLAG_RW, &pmc_unprivileged_syspmcs, 0, "allow unprivileged process to allocate system PMCs"); diff --git a/sys/dev/iscsi/icl.c b/sys/dev/iscsi/icl.c index a22dd7980fd96..2b5e4d0dba6d0 100644 --- a/sys/dev/iscsi/icl.c +++ b/sys/dev/iscsi/icl.c @@ -61,19 +61,24 @@ SYSCTL_NODE(_kern, OID_AUTO, icl, CTLFLAG_RD, 0, "iSCSI Common Layer"); static int debug = 1; +TUNABLE_INT("kern.icl.debug", &debug); SYSCTL_INT(_kern_icl, OID_AUTO, debug, CTLFLAG_RWTUN, &debug, 0, "Enable debug messages"); static int coalesce = 1; +TUNABLE_INT("kern.icl.coalesce", &coalesce); SYSCTL_INT(_kern_icl, OID_AUTO, coalesce, CTLFLAG_RWTUN, &coalesce, 0, "Try to coalesce PDUs before sending"); static int partial_receive_len = 128 * 1024; +TUNABLE_INT("kern.icl.partial_receive_len", &partial_receive_len); SYSCTL_INT(_kern_icl, OID_AUTO, partial_receive_len, CTLFLAG_RWTUN, &partial_receive_len, 0, "Minimum read size for partially received " "data segment"); static int sendspace = 1048576; +TUNABLE_INT("kern.icl.sendspace", &sendspace); SYSCTL_INT(_kern_icl, OID_AUTO, sendspace, CTLFLAG_RWTUN, &sendspace, 0, "Default send socket buffer size"); static int recvspace = 1048576; +TUNABLE_INT("kern.icl.recvspace", &recvspace); SYSCTL_INT(_kern_icl, OID_AUTO, recvspace, CTLFLAG_RWTUN, &recvspace, 0, "Default receive socket buffer size"); diff --git a/sys/dev/iscsi/iscsi.c b/sys/dev/iscsi/iscsi.c index 22f84623c9803..ad9ec7a218a4a 100644 --- a/sys/dev/iscsi/iscsi.c +++ b/sys/dev/iscsi/iscsi.c @@ -78,21 +78,27 @@ static struct iscsi_softc *sc; SYSCTL_NODE(_kern, OID_AUTO, iscsi, CTLFLAG_RD, 0, "iSCSI initiator"); static int debug = 1; +TUNABLE_INT("kern.iscsi.debug", &debug); SYSCTL_INT(_kern_iscsi, OID_AUTO, debug, CTLFLAG_RWTUN, &debug, 0, "Enable debug messages"); static int ping_timeout = 5; +TUNABLE_INT("kern.iscsi.ping_timeout", &ping_timeout); SYSCTL_INT(_kern_iscsi, OID_AUTO, ping_timeout, CTLFLAG_RWTUN, &ping_timeout, 0, "Timeout for ping (NOP-Out) requests, in seconds"); static int iscsid_timeout = 60; +TUNABLE_INT("kern.iscsi.iscsid_timeout", &iscsid_timeout); SYSCTL_INT(_kern_iscsi, OID_AUTO, iscsid_timeout, CTLFLAG_RWTUN, &iscsid_timeout, 0, "Time to wait for iscsid(8) to handle reconnection, in seconds"); static int login_timeout = 60; +TUNABLE_INT("kern.iscsi.login_timeout", &login_timeout); SYSCTL_INT(_kern_iscsi, OID_AUTO, login_timeout, CTLFLAG_RWTUN, &login_timeout, 0, "Time to wait for iscsid(8) to finish Login Phase, in seconds"); static int maxtags = 255; +TUNABLE_INT("kern.iscsi.maxtags", &maxtags); SYSCTL_INT(_kern_iscsi, OID_AUTO, maxtags, CTLFLAG_RWTUN, &maxtags, 0, "Max number of IO requests queued"); static int fail_on_disconnection = 0; +TUNABLE_INT("kern.iscsi.fail_on_disconnection", &fail_on_disconnection); SYSCTL_INT(_kern_iscsi, OID_AUTO, fail_on_disconnection, CTLFLAG_RWTUN, &fail_on_disconnection, 0, "Destroy CAM SIM on connection failure"); diff --git a/sys/dev/iscsi_initiator/iscsi.c b/sys/dev/iscsi_initiator/iscsi.c index 049c1112d6c86..cd66a369fa749 100644 --- a/sys/dev/iscsi_initiator/iscsi.c +++ b/sys/dev/iscsi_initiator/iscsi.c @@ -77,11 +77,11 @@ struct mtx iscsi_dbg_mtx; #endif static int max_sessions = MAX_SESSIONS; -SYSCTL_INT(_net, OID_AUTO, iscsi_initiator_max_sessions, CTLFLAG_RDTUN, - &max_sessions, 0, "Max sessions allowed"); +SYSCTL_INT(_net, OID_AUTO, iscsi_initiator_max_sessions, CTLFLAG_RDTUN, &max_sessions, MAX_SESSIONS, + "Max sessions allowed"); static int max_pdus = MAX_PDUS; -SYSCTL_INT(_net, OID_AUTO, iscsi_initiator_max_pdus, CTLFLAG_RDTUN, - &max_pdus, 0, "Max PDU pool"); +SYSCTL_INT(_net, OID_AUTO, iscsi_initiator_max_pdus, CTLFLAG_RDTUN, &max_pdus, MAX_PDUS, + "Max pdu pool"); static char isid[6+1] = { 0x80, @@ -711,6 +711,9 @@ iscsi_start(void) { debug_called(8); + TUNABLE_INT_FETCH("net.iscsi_initiator.max_sessions", &max_sessions); + TUNABLE_INT_FETCH("net.iscsi_initiator.max_pdus", &max_pdus); + isc = malloc(sizeof(struct isc_softc), M_ISCSI, M_ZERO|M_WAITOK); mtx_init(&isc->isc_mtx, "iscsi-isc", NULL, MTX_DEF); diff --git a/sys/dev/ixgbe/ixgbe.c b/sys/dev/ixgbe/ixgbe.c index 0eb334a11675c..fb0daa1921ba6 100644 --- a/sys/dev/ixgbe/ixgbe.c +++ b/sys/dev/ixgbe/ixgbe.c @@ -244,15 +244,18 @@ static SYSCTL_NODE(_hw, OID_AUTO, ix, CTLFLAG_RD, 0, ** traffic for that interrupt vector */ static int ixgbe_enable_aim = TRUE; -SYSCTL_INT(_hw_ix, OID_AUTO, enable_aim, CTLFLAG_RWTUN, &ixgbe_enable_aim, 0, +TUNABLE_INT("hw.ixgbe.enable_aim", &ixgbe_enable_aim); +SYSCTL_INT(_hw_ix, OID_AUTO, enable_aim, CTLFLAG_RW, &ixgbe_enable_aim, 0, "Enable adaptive interrupt moderation"); static int ixgbe_max_interrupt_rate = (4000000 / IXGBE_LOW_LATENCY); +TUNABLE_INT("hw.ixgbe.max_interrupt_rate", &ixgbe_max_interrupt_rate); SYSCTL_INT(_hw_ix, OID_AUTO, max_interrupt_rate, CTLFLAG_RDTUN, &ixgbe_max_interrupt_rate, 0, "Maximum interrupts per second"); /* How many packets rxeof tries to clean at a time */ static int ixgbe_rx_process_limit = 256; +TUNABLE_INT("hw.ixgbe.rx_process_limit", &ixgbe_rx_process_limit); SYSCTL_INT(_hw_ix, OID_AUTO, rx_process_limit, CTLFLAG_RDTUN, &ixgbe_rx_process_limit, 0, "Maximum number of received packets to process at a time," @@ -260,6 +263,7 @@ SYSCTL_INT(_hw_ix, OID_AUTO, rx_process_limit, CTLFLAG_RDTUN, /* How many packets txeof tries to clean at a time */ static int ixgbe_tx_process_limit = 256; +TUNABLE_INT("hw.ixgbe.tx_process_limit", &ixgbe_tx_process_limit); SYSCTL_INT(_hw_ix, OID_AUTO, tx_process_limit, CTLFLAG_RDTUN, &ixgbe_tx_process_limit, 0, "Maximum number of sent packets to process at a time," @@ -279,6 +283,7 @@ static int ixgbe_smart_speed = ixgbe_smart_speed_on; * but this allows it to be forced off for testing. */ static int ixgbe_enable_msix = 1; +TUNABLE_INT("hw.ixgbe.enable_msix", &ixgbe_enable_msix); SYSCTL_INT(_hw_ix, OID_AUTO, enable_msix, CTLFLAG_RDTUN, &ixgbe_enable_msix, 0, "Enable MSI-X interrupts"); @@ -289,6 +294,7 @@ SYSCTL_INT(_hw_ix, OID_AUTO, enable_msix, CTLFLAG_RDTUN, &ixgbe_enable_msix, 0, * can be overriden manually here. */ static int ixgbe_num_queues = 0; +TUNABLE_INT("hw.ixgbe.num_queues", &ixgbe_num_queues); SYSCTL_INT(_hw_ix, OID_AUTO, num_queues, CTLFLAG_RDTUN, &ixgbe_num_queues, 0, "Number of queues to configure, 0 indicates autoconfigure"); @@ -298,11 +304,13 @@ SYSCTL_INT(_hw_ix, OID_AUTO, num_queues, CTLFLAG_RDTUN, &ixgbe_num_queues, 0, ** the better performing choice. */ static int ixgbe_txd = PERFORM_TXD; +TUNABLE_INT("hw.ixgbe.txd", &ixgbe_txd); SYSCTL_INT(_hw_ix, OID_AUTO, txd, CTLFLAG_RDTUN, &ixgbe_txd, 0, "Number of receive descriptors per queue"); /* Number of RX descriptors per ring */ static int ixgbe_rxd = PERFORM_RXD; +TUNABLE_INT("hw.ixgbe.rxd", &ixgbe_rxd); SYSCTL_INT(_hw_ix, OID_AUTO, rxd, CTLFLAG_RDTUN, &ixgbe_rxd, 0, "Number of receive descriptors per queue"); diff --git a/sys/dev/malo/if_malo.c b/sys/dev/malo/if_malo.c index 1e879ba9459fb..db8f61d7437b2 100644 --- a/sys/dev/malo/if_malo.c +++ b/sys/dev/malo/if_malo.c @@ -65,22 +65,27 @@ SYSCTL_NODE(_hw, OID_AUTO, malo, CTLFLAG_RD, 0, "Marvell 88w8335 driver parameters"); static int malo_txcoalesce = 8; /* # tx pkts to q before poking f/w*/ -SYSCTL_INT(_hw_malo, OID_AUTO, txcoalesce, CTLFLAG_RWTUN, &malo_txcoalesce, +SYSCTL_INT(_hw_malo, OID_AUTO, txcoalesce, CTLFLAG_RW, &malo_txcoalesce, 0, "tx buffers to send at once"); +TUNABLE_INT("hw.malo.txcoalesce", &malo_txcoalesce); static int malo_rxbuf = MALO_RXBUF; /* # rx buffers to allocate */ -SYSCTL_INT(_hw_malo, OID_AUTO, rxbuf, CTLFLAG_RWTUN, &malo_rxbuf, +SYSCTL_INT(_hw_malo, OID_AUTO, rxbuf, CTLFLAG_RW, &malo_rxbuf, 0, "rx buffers allocated"); +TUNABLE_INT("hw.malo.rxbuf", &malo_rxbuf); static int malo_rxquota = MALO_RXBUF; /* # max buffers to process */ -SYSCTL_INT(_hw_malo, OID_AUTO, rxquota, CTLFLAG_RWTUN, &malo_rxquota, +SYSCTL_INT(_hw_malo, OID_AUTO, rxquota, CTLFLAG_RW, &malo_rxquota, 0, "max rx buffers to process per interrupt"); +TUNABLE_INT("hw.malo.rxquota", &malo_rxquota); static int malo_txbuf = MALO_TXBUF; /* # tx buffers to allocate */ -SYSCTL_INT(_hw_malo, OID_AUTO, txbuf, CTLFLAG_RWTUN, &malo_txbuf, +SYSCTL_INT(_hw_malo, OID_AUTO, txbuf, CTLFLAG_RW, &malo_txbuf, 0, "tx buffers allocated"); +TUNABLE_INT("hw.malo.txbuf", &malo_txbuf); #ifdef MALO_DEBUG static int malo_debug = 0; -SYSCTL_INT(_hw_malo, OID_AUTO, debug, CTLFLAG_RWTUN, &malo_debug, +SYSCTL_INT(_hw_malo, OID_AUTO, debug, CTLFLAG_RW, &malo_debug, 0, "control debugging printfs"); +TUNABLE_INT("hw.malo.debug", &malo_debug); enum { MALO_DEBUG_XMIT = 0x00000001, /* basic xmit operation */ MALO_DEBUG_XMIT_DESC = 0x00000002, /* xmit descriptors */ diff --git a/sys/dev/malo/if_malo_pci.c b/sys/dev/malo/if_malo_pci.c index c9e6b20703805..71ba3c0543c5d 100644 --- a/sys/dev/malo/if_malo_pci.c +++ b/sys/dev/malo/if_malo_pci.c @@ -86,8 +86,9 @@ static SYSCTL_NODE(_hw_malo, OID_AUTO, pci, CTLFLAG_RD, 0, "Marvell 88W8335 driver PCI parameters"); static int msi_disable = 0; /* MSI disabled */ -SYSCTL_INT(_hw_malo_pci, OID_AUTO, msi_disable, CTLFLAG_RWTUN, &msi_disable, +SYSCTL_INT(_hw_malo_pci, OID_AUTO, msi_disable, CTLFLAG_RW, &msi_disable, 0, "MSI disabled"); +TUNABLE_INT("hw.malo.pci.msi_disable", &msi_disable); /* * Devices supported by this driver. diff --git a/sys/dev/mfi/mfi.c b/sys/dev/mfi/mfi.c index 5ec813eafaee4..1a618ce0b176c 100644 --- a/sys/dev/mfi/mfi.c +++ b/sys/dev/mfi/mfi.c @@ -132,27 +132,33 @@ static int mfi_check_for_sscd(struct mfi_softc *sc, struct mfi_command *cm); SYSCTL_NODE(_hw, OID_AUTO, mfi, CTLFLAG_RD, 0, "MFI driver parameters"); static int mfi_event_locale = MFI_EVT_LOCALE_ALL; +TUNABLE_INT("hw.mfi.event_locale", &mfi_event_locale); SYSCTL_INT(_hw_mfi, OID_AUTO, event_locale, CTLFLAG_RWTUN, &mfi_event_locale, 0, "event message locale"); static int mfi_event_class = MFI_EVT_CLASS_INFO; +TUNABLE_INT("hw.mfi.event_class", &mfi_event_class); SYSCTL_INT(_hw_mfi, OID_AUTO, event_class, CTLFLAG_RWTUN, &mfi_event_class, 0, "event message class"); static int mfi_max_cmds = 128; +TUNABLE_INT("hw.mfi.max_cmds", &mfi_max_cmds); SYSCTL_INT(_hw_mfi, OID_AUTO, max_cmds, CTLFLAG_RDTUN, &mfi_max_cmds, 0, "Max commands limit (-1 = controller limit)"); static int mfi_detect_jbod_change = 1; +TUNABLE_INT("hw.mfi.detect_jbod_change", &mfi_detect_jbod_change); SYSCTL_INT(_hw_mfi, OID_AUTO, detect_jbod_change, CTLFLAG_RWTUN, &mfi_detect_jbod_change, 0, "Detect a change to a JBOD"); int mfi_polled_cmd_timeout = MFI_POLL_TIMEOUT_SECS; +TUNABLE_INT("hw.mfi.polled_cmd_timeout", &mfi_polled_cmd_timeout); SYSCTL_INT(_hw_mfi, OID_AUTO, polled_cmd_timeout, CTLFLAG_RWTUN, &mfi_polled_cmd_timeout, 0, "Polled command timeout - used for firmware flash etc (in seconds)"); static int mfi_cmd_timeout = MFI_CMD_TIMEOUT; +TUNABLE_INT("hw.mfi.cmd_timeout", &mfi_cmd_timeout); SYSCTL_INT(_hw_mfi, OID_AUTO, cmd_timeout, CTLFLAG_RWTUN, &mfi_cmd_timeout, 0, "Command timeout (in seconds)"); diff --git a/sys/dev/mfi/mfi_cam.c b/sys/dev/mfi/mfi_cam.c index 87f854c3f33e6..4fd6198a8a851 100644 --- a/sys/dev/mfi/mfi_cam.c +++ b/sys/dev/mfi/mfi_cam.c @@ -90,7 +90,8 @@ static struct mfi_command * mfip_start(void *); static void mfip_done(struct mfi_command *cm); static int mfi_allow_disks = 0; -SYSCTL_INT(_hw_mfi, OID_AUTO, allow_cam_disk_passthrough, CTLFLAG_RDTUN, +TUNABLE_INT("hw.mfi.allow_cam_disk_passthrough", &mfi_allow_disks); +SYSCTL_INT(_hw_mfi, OID_AUTO, allow_cam_disk_passthrough, CTLFLAG_RD, &mfi_allow_disks, 0, "event message locale"); static devclass_t mfip_devclass; diff --git a/sys/dev/mfi/mfi_pci.c b/sys/dev/mfi/mfi_pci.c index 80d655cf1b02d..803584e439a1a 100644 --- a/sys/dev/mfi/mfi_pci.c +++ b/sys/dev/mfi/mfi_pci.c @@ -108,10 +108,12 @@ DRIVER_MODULE(mfi, pci, mfi_pci_driver, mfi_devclass, 0, 0); MODULE_VERSION(mfi, 1); static int mfi_msi = 1; +TUNABLE_INT("hw.mfi.msi", &mfi_msi); SYSCTL_INT(_hw_mfi, OID_AUTO, msi, CTLFLAG_RDTUN, &mfi_msi, 0, "Enable use of MSI interrupts"); -static int mfi_mrsas_enable; +static int mfi_mrsas_enable = 0; +TUNABLE_INT("hw.mfi.mrsas_enable", &mfi_mrsas_enable); SYSCTL_INT(_hw_mfi, OID_AUTO, mrsas_enable, CTLFLAG_RDTUN, &mfi_mrsas_enable, 0, "Allow mrasas to take newer cards"); @@ -184,6 +186,7 @@ mfi_pci_probe(device_t dev) device_set_desc(dev, id->desc); /* give priority to mrsas if tunable set */ + TUNABLE_INT_FETCH("hw.mfi.mrsas_enable", &mfi_mrsas_enable); if ((id->flags & MFI_FLAGS_MRSAS) && mfi_mrsas_enable) return (BUS_PROBE_LOW_PRIORITY); else diff --git a/sys/dev/mfi/mfi_tbolt.c b/sys/dev/mfi/mfi_tbolt.c index 984c355321e7f..2d27534062c3e 100644 --- a/sys/dev/mfi/mfi_tbolt.c +++ b/sys/dev/mfi/mfi_tbolt.c @@ -86,6 +86,7 @@ static void mfi_queue_map_sync(struct mfi_softc *sc); extern int mfi_polled_cmd_timeout; static int mfi_fw_reset_test = 0; #ifdef MFI_DEBUG +TUNABLE_INT("hw.mfi.fw_reset_test", &mfi_fw_reset_test); SYSCTL_INT(_hw_mfi, OID_AUTO, fw_reset_test, CTLFLAG_RWTUN, &mfi_fw_reset_test, 0, "Force a firmware reset condition"); #endif diff --git a/sys/dev/mwl/if_mwl.c b/sys/dev/mwl/if_mwl.c index b5bd9bd5003d6..b50e1a9379076 100644 --- a/sys/dev/mwl/if_mwl.c +++ b/sys/dev/mwl/if_mwl.c @@ -188,25 +188,31 @@ static int mwl_rxdesc = MWL_RXDESC; /* # rx desc's to allocate */ SYSCTL_INT(_hw_mwl, OID_AUTO, rxdesc, CTLFLAG_RW, &mwl_rxdesc, 0, "rx descriptors allocated"); static int mwl_rxbuf = MWL_RXBUF; /* # rx buffers to allocate */ -SYSCTL_INT(_hw_mwl, OID_AUTO, rxbuf, CTLFLAG_RWTUN, &mwl_rxbuf, +SYSCTL_INT(_hw_mwl, OID_AUTO, rxbuf, CTLFLAG_RW, &mwl_rxbuf, 0, "rx buffers allocated"); +TUNABLE_INT("hw.mwl.rxbuf", &mwl_rxbuf); static int mwl_txbuf = MWL_TXBUF; /* # tx buffers to allocate */ -SYSCTL_INT(_hw_mwl, OID_AUTO, txbuf, CTLFLAG_RWTUN, &mwl_txbuf, +SYSCTL_INT(_hw_mwl, OID_AUTO, txbuf, CTLFLAG_RW, &mwl_txbuf, 0, "tx buffers allocated"); +TUNABLE_INT("hw.mwl.txbuf", &mwl_txbuf); static int mwl_txcoalesce = 8; /* # tx packets to q before poking f/w*/ -SYSCTL_INT(_hw_mwl, OID_AUTO, txcoalesce, CTLFLAG_RWTUN, &mwl_txcoalesce, +SYSCTL_INT(_hw_mwl, OID_AUTO, txcoalesce, CTLFLAG_RW, &mwl_txcoalesce, 0, "tx buffers to send at once"); +TUNABLE_INT("hw.mwl.txcoalesce", &mwl_txcoalesce); static int mwl_rxquota = MWL_RXBUF; /* # max buffers to process */ -SYSCTL_INT(_hw_mwl, OID_AUTO, rxquota, CTLFLAG_RWTUN, &mwl_rxquota, +SYSCTL_INT(_hw_mwl, OID_AUTO, rxquota, CTLFLAG_RW, &mwl_rxquota, 0, "max rx buffers to process per interrupt"); +TUNABLE_INT("hw.mwl.rxquota", &mwl_rxquota); static int mwl_rxdmalow = 3; /* # min buffers for wakeup */ -SYSCTL_INT(_hw_mwl, OID_AUTO, rxdmalow, CTLFLAG_RWTUN, &mwl_rxdmalow, +SYSCTL_INT(_hw_mwl, OID_AUTO, rxdmalow, CTLFLAG_RW, &mwl_rxdmalow, 0, "min free rx buffers before restarting traffic"); +TUNABLE_INT("hw.mwl.rxdmalow", &mwl_rxdmalow); #ifdef MWL_DEBUG static int mwl_debug = 0; -SYSCTL_INT(_hw_mwl, OID_AUTO, debug, CTLFLAG_RWTUN, &mwl_debug, +SYSCTL_INT(_hw_mwl, OID_AUTO, debug, CTLFLAG_RW, &mwl_debug, 0, "control debugging printfs"); +TUNABLE_INT("hw.mwl.debug", &mwl_debug); enum { MWL_DEBUG_XMIT = 0x00000001, /* basic xmit operation */ MWL_DEBUG_XMIT_DESC = 0x00000002, /* xmit descriptors */ diff --git a/sys/dev/nand/nand.c b/sys/dev/nand/nand.c index 113953ef8f375..fb83e673861b5 100644 --- a/sys/dev/nand/nand.c +++ b/sys/dev/nand/nand.c @@ -65,9 +65,18 @@ __FBSDID("$FreeBSD$"); #define SOFTECC_BYTES 3 int nand_debug_flag = 0; -SYSCTL_INT(_debug, OID_AUTO, nand_debug, CTLFLAG_RWTUN, &nand_debug_flag, 0, +SYSCTL_INT(_debug, OID_AUTO, nand_debug, CTLFLAG_RW, &nand_debug_flag, 0, "NAND subsystem debug flag"); +static void +nand_tunable_init(void *arg) +{ + + TUNABLE_INT_FETCH("debug.nand", &nand_debug_flag); +} + +SYSINIT(nand_tunables, SI_SUB_VFS, SI_ORDER_ANY, nand_tunable_init, NULL); + MALLOC_DEFINE(M_NAND, "NAND", "NAND dynamic data"); static void calculate_ecc(const uint8_t *, uint8_t *); diff --git a/sys/dev/pccard/pccard.c b/sys/dev/pccard/pccard.c index 87ab53abcf4a3..0c49d2f38a7ff 100644 --- a/sys/dev/pccard/pccard.c +++ b/sys/dev/pccard/pccard.c @@ -62,12 +62,14 @@ __FBSDID("$FreeBSD$"); static SYSCTL_NODE(_hw, OID_AUTO, pccard, CTLFLAG_RD, 0, "PCCARD parameters"); int pccard_debug = 0; -SYSCTL_INT(_hw_pccard, OID_AUTO, debug, CTLFLAG_RWTUN, +TUNABLE_INT("hw.pccard.debug", &pccard_debug); +SYSCTL_INT(_hw_pccard, OID_AUTO, debug, CTLFLAG_RW, &pccard_debug, 0, "pccard debug"); int pccard_cis_debug = 0; -SYSCTL_INT(_hw_pccard, OID_AUTO, cis_debug, CTLFLAG_RWTUN, +TUNABLE_INT("hw.pccard.cis_debug", &pccard_cis_debug); +SYSCTL_INT(_hw_pccard, OID_AUTO, cis_debug, CTLFLAG_RW, &pccard_cis_debug, 0, "pccard CIS debug"); #ifdef PCCARDDEBUG diff --git a/sys/dev/pccbb/pccbb.c b/sys/dev/pccbb/pccbb.c index b724d05e04231..092d3efae773b 100644 --- a/sys/dev/pccbb/pccbb.c +++ b/sys/dev/pccbb/pccbb.c @@ -134,22 +134,26 @@ static SYSCTL_NODE(_hw, OID_AUTO, cbb, CTLFLAG_RD, 0, "CBB parameters"); /* There's no way to say TUNEABLE_LONG to get the right types */ u_long cbb_start_mem = CBB_START_MEM; -SYSCTL_ULONG(_hw_cbb, OID_AUTO, start_memory, CTLFLAG_RWTUN, +TUNABLE_ULONG("hw.cbb.start_memory", &cbb_start_mem); +SYSCTL_ULONG(_hw_cbb, OID_AUTO, start_memory, CTLFLAG_RW, &cbb_start_mem, CBB_START_MEM, "Starting address for memory allocations"); u_long cbb_start_16_io = CBB_START_16_IO; -SYSCTL_ULONG(_hw_cbb, OID_AUTO, start_16_io, CTLFLAG_RWTUN, +TUNABLE_ULONG("hw.cbb.start_16_io", &cbb_start_16_io); +SYSCTL_ULONG(_hw_cbb, OID_AUTO, start_16_io, CTLFLAG_RW, &cbb_start_16_io, CBB_START_16_IO, "Starting ioport for 16-bit cards"); u_long cbb_start_32_io = CBB_START_32_IO; -SYSCTL_ULONG(_hw_cbb, OID_AUTO, start_32_io, CTLFLAG_RWTUN, +TUNABLE_ULONG("hw.cbb.start_32_io", &cbb_start_32_io); +SYSCTL_ULONG(_hw_cbb, OID_AUTO, start_32_io, CTLFLAG_RW, &cbb_start_32_io, CBB_START_32_IO, "Starting ioport for 32-bit cards"); int cbb_debug = 0; -SYSCTL_INT(_hw_cbb, OID_AUTO, debug, CTLFLAG_RWTUN, &cbb_debug, 0, +TUNABLE_INT("hw.cbb.debug", &cbb_debug); +SYSCTL_INT(_hw_cbb, OID_AUTO, debug, CTLFLAG_RW, &cbb_debug, 0, "Verbose cardbus bridge debugging"); static void cbb_insert(struct cbb_softc *sc); diff --git a/sys/dev/pccbb/pccbb_isa.c b/sys/dev/pccbb/pccbb_isa.c index c511062510556..1d0a698da78b0 100644 --- a/sys/dev/pccbb/pccbb_isa.c +++ b/sys/dev/pccbb/pccbb_isa.c @@ -74,7 +74,8 @@ __FBSDID("$FreeBSD$"); static SYSCTL_NODE(_hw, OID_AUTO, pcic, CTLFLAG_RD, 0, "PCIC parameters"); static int isa_intr_mask = EXCA_INT_MASK_ALLOWED; -SYSCTL_INT(_hw_pcic, OID_AUTO, intr_mask, CTLFLAG_RDTUN, &isa_intr_mask, 0, +TUNABLE_INT("hw.cbb.intr_mask", &isa_intr_mask); +SYSCTL_INT(_hw_pcic, OID_AUTO, intr_mask, CTLFLAG_RD, &isa_intr_mask, 0, "Mask of allowable interrupts for this laptop. The default is generally\n\ correct, but some laptops do not route all the IRQ pins to the bridge to\n\ save wires. Sometimes you need a more restrictive mask because some of the\n\ @@ -88,6 +89,7 @@ allocated."); * 2: 6729's method */ int pcic_pd6722_vsense = 1; +TUNABLE_INT("hw.pcic.pd6722_vsense", &pcic_pd6722_vsense); SYSCTL_INT(_hw_pcic, OID_AUTO, pd6722_vsense, CTLFLAG_RDTUN, &pcic_pd6722_vsense, 1, "Select CL-PD6722's VSENSE method. VSENSE is used to determine the\n\ diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index 9733841803ab6..b2b5ff80d0d54 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -282,20 +282,22 @@ static int pcie_chipset, pcix_chipset; SYSCTL_NODE(_hw, OID_AUTO, pci, CTLFLAG_RD, 0, "PCI bus tuning parameters"); static int pci_enable_io_modes = 1; -SYSCTL_INT(_hw_pci, OID_AUTO, enable_io_modes, CTLFLAG_RWTUN, +TUNABLE_INT("hw.pci.enable_io_modes", &pci_enable_io_modes); +SYSCTL_INT(_hw_pci, OID_AUTO, enable_io_modes, CTLFLAG_RW, &pci_enable_io_modes, 1, "Enable I/O and memory bits in the config register. Some BIOSes do not\n\ enable these bits correctly. We'd like to do this all the time, but there\n\ are some peripherals that this causes problems with."); static int pci_do_realloc_bars = 0; -SYSCTL_INT(_hw_pci, OID_AUTO, realloc_bars, CTLFLAG_RWTUN, +TUNABLE_INT("hw.pci.realloc_bars", &pci_do_realloc_bars); +SYSCTL_INT(_hw_pci, OID_AUTO, realloc_bars, CTLFLAG_RW, &pci_do_realloc_bars, 0, - "Attempt to allocate a new range for any BARs whose original " - "firmware-assigned ranges fail to allocate during the initial device scan."); + "Attempt to allocate a new range for any BARs whose original firmware-assigned ranges fail to allocate during the initial device scan."); static int pci_do_power_nodriver = 0; -SYSCTL_INT(_hw_pci, OID_AUTO, do_power_nodriver, CTLFLAG_RWTUN, +TUNABLE_INT("hw.pci.do_power_nodriver", &pci_do_power_nodriver); +SYSCTL_INT(_hw_pci, OID_AUTO, do_power_nodriver, CTLFLAG_RW, &pci_do_power_nodriver, 0, "Place a function into D3 state when no driver attaches to it. 0 means\n\ disable. 1 means conservatively place devices into D3 state. 2 means\n\ @@ -303,25 +305,30 @@ agressively place devices into D3 state. 3 means put absolutely everything\n\ in D3 state."); int pci_do_power_resume = 1; -SYSCTL_INT(_hw_pci, OID_AUTO, do_power_resume, CTLFLAG_RWTUN, +TUNABLE_INT("hw.pci.do_power_resume", &pci_do_power_resume); +SYSCTL_INT(_hw_pci, OID_AUTO, do_power_resume, CTLFLAG_RW, &pci_do_power_resume, 1, "Transition from D3 -> D0 on resume."); int pci_do_power_suspend = 1; -SYSCTL_INT(_hw_pci, OID_AUTO, do_power_suspend, CTLFLAG_RWTUN, +TUNABLE_INT("hw.pci.do_power_suspend", &pci_do_power_suspend); +SYSCTL_INT(_hw_pci, OID_AUTO, do_power_suspend, CTLFLAG_RW, &pci_do_power_suspend, 1, "Transition from D0 -> D3 on suspend."); static int pci_do_msi = 1; -SYSCTL_INT(_hw_pci, OID_AUTO, enable_msi, CTLFLAG_RWTUN, &pci_do_msi, 1, +TUNABLE_INT("hw.pci.enable_msi", &pci_do_msi); +SYSCTL_INT(_hw_pci, OID_AUTO, enable_msi, CTLFLAG_RW, &pci_do_msi, 1, "Enable support for MSI interrupts"); static int pci_do_msix = 1; -SYSCTL_INT(_hw_pci, OID_AUTO, enable_msix, CTLFLAG_RWTUN, &pci_do_msix, 1, +TUNABLE_INT("hw.pci.enable_msix", &pci_do_msix); +SYSCTL_INT(_hw_pci, OID_AUTO, enable_msix, CTLFLAG_RW, &pci_do_msix, 1, "Enable support for MSI-X interrupts"); static int pci_honor_msi_blacklist = 1; -SYSCTL_INT(_hw_pci, OID_AUTO, honor_msi_blacklist, CTLFLAG_RDTUN, +TUNABLE_INT("hw.pci.honor_msi_blacklist", &pci_honor_msi_blacklist); +SYSCTL_INT(_hw_pci, OID_AUTO, honor_msi_blacklist, CTLFLAG_RD, &pci_honor_msi_blacklist, 1, "Honor chipset blacklist for MSI/MSI-X"); #if defined(__i386__) || defined(__amd64__) @@ -329,22 +336,26 @@ static int pci_usb_takeover = 1; #else static int pci_usb_takeover = 0; #endif +TUNABLE_INT("hw.pci.usb_early_takeover", &pci_usb_takeover); SYSCTL_INT(_hw_pci, OID_AUTO, usb_early_takeover, CTLFLAG_RDTUN, &pci_usb_takeover, 1, "Enable early takeover of USB controllers.\n\ Disable this if you depend on BIOS emulation of USB devices, that is\n\ you use USB devices (like keyboard or mouse) but do not load USB drivers"); static int pci_clear_bars; +TUNABLE_INT("hw.pci.clear_bars", &pci_clear_bars); SYSCTL_INT(_hw_pci, OID_AUTO, clear_bars, CTLFLAG_RDTUN, &pci_clear_bars, 0, "Ignore firmware-assigned resources for BARs."); #if defined(NEW_PCIB) && defined(PCI_RES_BUS) static int pci_clear_buses; +TUNABLE_INT("hw.pci.clear_buses", &pci_clear_buses); SYSCTL_INT(_hw_pci, OID_AUTO, clear_buses, CTLFLAG_RDTUN, &pci_clear_buses, 0, "Ignore firmware-assigned bus numbers."); #endif static int pci_enable_ari = 1; +TUNABLE_INT("hw.pci.enable_ari", &pci_enable_ari); SYSCTL_INT(_hw_pci, OID_AUTO, enable_ari, CTLFLAG_RDTUN, &pci_enable_ari, 0, "Enable support for PCIe Alternative RID Interpretation"); diff --git a/sys/dev/pci/pci_pci.c b/sys/dev/pci/pci_pci.c index 3c5842be44c6d..8b5021974c750 100644 --- a/sys/dev/pci/pci_pci.c +++ b/sys/dev/pci/pci_pci.c @@ -117,6 +117,7 @@ DRIVER_MODULE(pcib, pci, pcib_driver, pcib_devclass, NULL, NULL); SYSCTL_DECL(_hw_pci); static int pci_clear_pcib; +TUNABLE_INT("hw.pci.clear_pcib", &pci_clear_pcib); SYSCTL_INT(_hw_pci, OID_AUTO, clear_pcib, CTLFLAG_RDTUN, &pci_clear_pcib, 0, "Clear firmware-assigned resources for PCI-PCI bridge I/O windows."); diff --git a/sys/dev/pci/vga_pci.c b/sys/dev/pci/vga_pci.c index 46f32505c36e1..6e733f588d5ed 100644 --- a/sys/dev/pci/vga_pci.c +++ b/sys/dev/pci/vga_pci.c @@ -71,6 +71,7 @@ static int vga_pci_release_resource(device_t dev, device_t child, int type, int rid, struct resource *r); int vga_pci_default_unit = -1; +TUNABLE_INT("hw.pci.default_vgapci_unit", &vga_pci_default_unit); SYSCTL_INT(_hw_pci, OID_AUTO, default_vgapci_unit, CTLFLAG_RDTUN, &vga_pci_default_unit, -1, "Default VGA-compatible display"); diff --git a/sys/dev/puc/puc_pci.c b/sys/dev/puc/puc_pci.c index 618a3ae036911..d6d5509050c3b 100644 --- a/sys/dev/puc/puc_pci.c +++ b/sys/dev/puc/puc_pci.c @@ -80,7 +80,8 @@ __FBSDID("$FreeBSD$"); #include static int puc_msi_disable; -SYSCTL_INT(_hw_puc, OID_AUTO, msi_disable, CTLFLAG_RDTUN, +TUNABLE_INT("hw.puc.msi_disable", &puc_msi_disable); +SYSCTL_INT(_hw_puc, OID_AUTO, msi_disable, CTLFLAG_RD | CTLFLAG_TUN, &puc_msi_disable, 0, "Disable use of MSI interrupts by puc(9)"); static const struct puc_cfg * diff --git a/sys/dev/rt/if_rt.c b/sys/dev/rt/if_rt.c index aaf84f3829689..5f62fec6920df 100644 --- a/sys/dev/rt/if_rt.c +++ b/sys/dev/rt/if_rt.c @@ -140,8 +140,9 @@ static void rt_ifmedia_sts(struct ifnet *, struct ifmediareq *); static SYSCTL_NODE(_hw, OID_AUTO, rt, CTLFLAG_RD, 0, "RT driver parameters"); #ifdef IF_RT_DEBUG static int rt_debug = 0; -SYSCTL_INT(_hw_rt, OID_AUTO, debug, CTLFLAG_RWTUN, &rt_debug, 0, +SYSCTL_INT(_hw_rt, OID_AUTO, debug, CTLFLAG_RW, &rt_debug, 0, "RT debug level"); +TUNABLE_INT("hw.rt.debug", &rt_debug); #endif static int diff --git a/sys/dev/sdhci/sdhci.c b/sys/dev/sdhci/sdhci.c index 18fbf1e83fbb4..b8e03bed3409e 100644 --- a/sys/dev/sdhci/sdhci.c +++ b/sys/dev/sdhci/sdhci.c @@ -67,7 +67,8 @@ struct sdhci_softc { static SYSCTL_NODE(_hw, OID_AUTO, sdhci, CTLFLAG_RD, 0, "sdhci driver"); int sdhci_debug = 0; -SYSCTL_INT(_hw_sdhci, OID_AUTO, debug, CTLFLAG_RWTUN, &sdhci_debug, 0, "Debug level"); +TUNABLE_INT("hw.sdhci.debug", &sdhci_debug); +SYSCTL_INT(_hw_sdhci, OID_AUTO, debug, CTLFLAG_RW, &sdhci_debug, 0, "Debug level"); #define RD1(slot, off) SDHCI_READ_1((slot)->bus, (slot), (off)) #define RD2(slot, off) SDHCI_READ_2((slot)->bus, (slot), (off)) diff --git a/sys/dev/sdhci/sdhci_pci.c b/sys/dev/sdhci/sdhci_pci.c index 9e7e471818885..b8d85306d8f4c 100644 --- a/sys/dev/sdhci/sdhci_pci.c +++ b/sys/dev/sdhci/sdhci_pci.c @@ -124,7 +124,8 @@ struct sdhci_pci_softc { static SYSCTL_NODE(_hw, OID_AUTO, sdhci_pci, CTLFLAG_RD, 0, "sdhci PCI driver"); int sdhci_pci_debug; -SYSCTL_INT(_hw_sdhci_pci, OID_AUTO, debug, CTLFLAG_RWTUN, &sdhci_pci_debug, 0, "Debug level"); +TUNABLE_INT("hw.sdhci_pci.debug", &sdhci_pci_debug); +SYSCTL_INT(_hw_sdhci_pci, OID_AUTO, debug, CTLFLAG_RW, &sdhci_pci_debug, 0, "Debug level"); static uint8_t sdhci_pci_read_1(device_t dev, struct sdhci_slot *slot, bus_size_t off) diff --git a/sys/dev/si/si.c b/sys/dev/si/si.c index de3eadf583ee7..c9d1c83114881 100644 --- a/sys/dev/si/si.c +++ b/sys/dev/si/si.c @@ -119,7 +119,8 @@ static int si_Nports; static int si_Nmodules; static int si_debug; -SYSCTL_INT(_machdep, OID_AUTO, si_debug, CTLFLAG_RWTUN, &si_debug, 0, ""); +SYSCTL_INT(_machdep, OID_AUTO, si_debug, CTLFLAG_RW, &si_debug, 0, ""); +TUNABLE_INT("machdep.si_debug", &si_debug); static int si_numunits; diff --git a/sys/dev/sio/sio.c b/sys/dev/sio/sio.c index 324a80be0829a..d187a2bab31f7 100644 --- a/sys/dev/sio/sio.c +++ b/sys/dev/sio/sio.c @@ -372,7 +372,7 @@ sysctl_machdep_comdefaultrate(SYSCTL_HANDLER_ARGS) return error; } -SYSCTL_PROC(_machdep, OID_AUTO, conspeed, CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NOFETCH, +SYSCTL_PROC(_machdep, OID_AUTO, conspeed, CTLTYPE_INT | CTLFLAG_RW, 0, 0, sysctl_machdep_comdefaultrate, "I", ""); TUNABLE_INT("machdep.conspeed", __DEVOLATILE(int *, &comdefaultrate)); diff --git a/sys/dev/sis/if_sis.c b/sys/dev/sis/if_sis.c index 4a95af63d8a6b..09e2242065b0f 100644 --- a/sys/dev/sis/if_sis.c +++ b/sys/dev/sis/if_sis.c @@ -2361,6 +2361,7 @@ sis_add_sysctls(struct sis_softc *sc) { struct sysctl_ctx_list *ctx; struct sysctl_oid_list *children; + char tn[32]; int unit; ctx = device_get_sysctl_ctx(sc->sis_dev); @@ -2375,8 +2376,10 @@ sis_add_sysctls(struct sis_softc *sc) * because it will consume extra CPU cycles for short frames. */ sc->sis_manual_pad = 0; + snprintf(tn, sizeof(tn), "dev.sis.%d.manual_pad", unit); + TUNABLE_INT_FETCH(tn, &sc->sis_manual_pad); SYSCTL_ADD_INT(ctx, children, OID_AUTO, "manual_pad", - CTLFLAG_RWTUN, &sc->sis_manual_pad, 0, "Manually pad short frames"); + CTLFLAG_RW, &sc->sis_manual_pad, 0, "Manually pad short frames"); } static device_method_t sis_methods[] = { diff --git a/sys/dev/sound/pcm/channel.c b/sys/dev/sound/pcm/channel.c index 41fbee2e75ae5..75b02d00e3110 100644 --- a/sys/dev/sound/pcm/channel.c +++ b/sys/dev/sound/pcm/channel.c @@ -119,7 +119,8 @@ SYSCTL_PROC(_hw_snd, OID_AUTO, timeout, CTLTYPE_INT | CTLFLAG_RW, #endif static int chn_vpc_autoreset = 1; -SYSCTL_INT(_hw_snd, OID_AUTO, vpc_autoreset, CTLFLAG_RWTUN, +TUNABLE_INT("hw.snd.vpc_autoreset", &chn_vpc_autoreset); +SYSCTL_INT(_hw_snd, OID_AUTO, vpc_autoreset, CTLFLAG_RW, &chn_vpc_autoreset, 0, "automatically reset channels volume to 0db"); static int chn_vol_0db_pcm = SND_VOL_0DB_PCM; diff --git a/sys/dev/sound/pcm/feeder_chain.c b/sys/dev/sound/pcm/feeder_chain.c index a647269dba6d5..92a1cf539024f 100644 --- a/sys/dev/sound/pcm/feeder_chain.c +++ b/sys/dev/sound/pcm/feeder_chain.c @@ -125,7 +125,8 @@ static uint32_t *feeder_chain_formats[FEEDER_CHAIN_LAST] = { static int feeder_chain_mode = FEEDER_CHAIN_DEFAULT; #if defined(_KERNEL) && defined(SND_DEBUG) && defined(SND_FEEDER_FULL_MULTIFORMAT) -SYSCTL_INT(_hw_snd, OID_AUTO, feeder_chain_mode, CTLFLAG_RWTUN, +TUNABLE_INT("hw.snd.feeder_chain_mode", &feeder_chain_mode); +SYSCTL_INT(_hw_snd, OID_AUTO, feeder_chain_mode, CTLFLAG_RW, &feeder_chain_mode, 0, "feeder chain mode " "(0=lean, 1=16bit, 2=32bit, 3=multiformat, 4=fullmultiformat)"); diff --git a/sys/dev/sound/pcm/feeder_eq.c b/sys/dev/sound/pcm/feeder_eq.c index b4a92c986a606..dee38a386e51e 100644 --- a/sys/dev/sound/pcm/feeder_eq.c +++ b/sys/dev/sound/pcm/feeder_eq.c @@ -97,7 +97,8 @@ static char feeder_eq_presets[] = FEEDER_EQ_PRESETS; SYSCTL_STRING(_hw_snd, OID_AUTO, feeder_eq_presets, CTLFLAG_RD, &feeder_eq_presets, 0, "compile-time eq presets"); -SYSCTL_INT(_hw_snd, OID_AUTO, feeder_eq_exact_rate, CTLFLAG_RWTUN, +TUNABLE_INT("hw.snd.feeder_eq_exact_rate", &feeder_eq_exact_rate); +SYSCTL_INT(_hw_snd, OID_AUTO, feeder_eq_exact_rate, CTLFLAG_RW, &feeder_eq_exact_rate, 0, "force exact rate validation"); #endif diff --git a/sys/dev/sound/pcm/feeder_rate.c b/sys/dev/sound/pcm/feeder_rate.c index d521fd16f1c1b..cb30dd93149a9 100644 --- a/sys/dev/sound/pcm/feeder_rate.c +++ b/sys/dev/sound/pcm/feeder_rate.c @@ -168,7 +168,8 @@ TUNABLE_INT("hw.snd.feeder_rate_max", &feeder_rate_max); TUNABLE_INT("hw.snd.feeder_rate_round", &feeder_rate_round); TUNABLE_INT("hw.snd.feeder_rate_quality", &feeder_rate_quality); -SYSCTL_INT(_hw_snd, OID_AUTO, feeder_rate_polyphase_max, CTLFLAG_RWTUN, +TUNABLE_INT("hw.snd.feeder_rate_polyphase_max", &feeder_rate_polyphase_max); +SYSCTL_INT(_hw_snd, OID_AUTO, feeder_rate_polyphase_max, CTLFLAG_RW, &feeder_rate_polyphase_max, 0, "maximum allowable polyphase entries"); static int diff --git a/sys/dev/sound/pcm/mixer.c b/sys/dev/sound/pcm/mixer.c index 42ddd11bbbb04..8f9a5fb3a7f31 100644 --- a/sys/dev/sound/pcm/mixer.c +++ b/sys/dev/sound/pcm/mixer.c @@ -40,7 +40,8 @@ SND_DECLARE_FILE("$FreeBSD$"); static MALLOC_DEFINE(M_MIXER, "mixer", "mixer"); static int mixer_bypass = 1; -SYSCTL_INT(_hw_snd, OID_AUTO, vpc_mixer_bypass, CTLFLAG_RWTUN, +TUNABLE_INT("hw.snd.vpc_mixer_bypass", &mixer_bypass); +SYSCTL_INT(_hw_snd, OID_AUTO, vpc_mixer_bypass, CTLFLAG_RW, &mixer_bypass, 0, "control channel pcm/rec volume, bypassing real mixer device"); diff --git a/sys/dev/sound/pcm/sound.c b/sys/dev/sound/pcm/sound.c index 8b43879470e50..a7edad5246c70 100644 --- a/sys/dev/sound/pcm/sound.c +++ b/sys/dev/sound/pcm/sound.c @@ -52,7 +52,8 @@ int snd_unit = -1; TUNABLE_INT("hw.snd.default_unit", &snd_unit); static int snd_unit_auto = -1; -SYSCTL_INT(_hw_snd, OID_AUTO, default_auto, CTLFLAG_RWTUN, +TUNABLE_INT("hw.snd.default_auto", &snd_unit_auto); +SYSCTL_INT(_hw_snd, OID_AUTO, default_auto, CTLFLAG_RW, &snd_unit_auto, 0, "assign default unit to a newly attached device"); int snd_maxautovchans = 16; diff --git a/sys/dev/sound/usb/uaudio.c b/sys/dev/sound/usb/uaudio.c index 6c798cc0e0961..1af8cb2c4ecf4 100644 --- a/sys/dev/sound/usb/uaudio.c +++ b/sys/dev/sound/usb/uaudio.c @@ -103,11 +103,17 @@ static SYSCTL_NODE(_hw_usb, OID_AUTO, uaudio, CTLFLAG_RW, 0, "USB uaudio"); SYSCTL_INT(_hw_usb_uaudio, OID_AUTO, debug, CTLFLAG_RW, &uaudio_debug, 0, "uaudio debug level"); -SYSCTL_INT(_hw_usb_uaudio, OID_AUTO, default_rate, CTLFLAG_RWTUN, + +TUNABLE_INT("hw.usb.uaudio.default_rate", &uaudio_default_rate); +SYSCTL_INT(_hw_usb_uaudio, OID_AUTO, default_rate, CTLFLAG_RW, &uaudio_default_rate, 0, "uaudio default sample rate"); -SYSCTL_INT(_hw_usb_uaudio, OID_AUTO, default_bits, CTLFLAG_RWTUN, + +TUNABLE_INT("hw.usb.uaudio.default_bits", &uaudio_default_bits); +SYSCTL_INT(_hw_usb_uaudio, OID_AUTO, default_bits, CTLFLAG_RW, &uaudio_default_bits, 0, "uaudio default sample bits"); -SYSCTL_INT(_hw_usb_uaudio, OID_AUTO, default_channels, CTLFLAG_RWTUN, + +TUNABLE_INT("hw.usb.uaudio.default_channels", &uaudio_default_channels); +SYSCTL_INT(_hw_usb_uaudio, OID_AUTO, default_channels, CTLFLAG_RW, &uaudio_default_channels, 0, "uaudio default sample channels"); #endif diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c index 6a19523ee2ea5..35b3ca8d80781 100644 --- a/sys/dev/syscons/syscons.c +++ b/sys/dev/syscons/syscons.c @@ -154,7 +154,8 @@ SYSCTL_INT(_hw_syscons, OID_AUTO, kbd_reboot, CTLFLAG_RW|CTLFLAG_SECURE, &enable SYSCTL_INT(_hw_syscons, OID_AUTO, kbd_debug, CTLFLAG_RW|CTLFLAG_SECURE, &enable_kdbkey, 0, "enable keyboard debug"); #endif -SYSCTL_INT(_hw_syscons, OID_AUTO, sc_no_suspend_vtswitch, CTLFLAG_RWTUN, +TUNABLE_INT("hw.syscons.sc_no_suspend_vtswitch", &sc_no_suspend_vtswitch); +SYSCTL_INT(_hw_syscons, OID_AUTO, sc_no_suspend_vtswitch, CTLFLAG_RW, &sc_no_suspend_vtswitch, 0, "Disable VT switch before suspend."); #if !defined(SC_NO_FONT_LOADING) && defined(SC_DFLT_FONT) #include "font.h" diff --git a/sys/dev/uart/uart_dev_ns8250.c b/sys/dev/uart/uart_dev_ns8250.c index 89f78402746b6..773cb442c8978 100644 --- a/sys/dev/uart/uart_dev_ns8250.c +++ b/sys/dev/uart/uart_dev_ns8250.c @@ -55,8 +55,9 @@ __FBSDID("$FreeBSD$"); #define DEFAULT_RCLK 1843200 static int broken_txfifo = 0; -SYSCTL_INT(_hw, OID_AUTO, broken_txfifo, CTLFLAG_RWTUN, +SYSCTL_INT(_hw, OID_AUTO, broken_txfifo, CTLFLAG_RW | CTLFLAG_TUN, &broken_txfifo, 0, "UART FIFO has QEMU emulation bug"); +TUNABLE_INT("hw.broken_txfifo", &broken_txfifo); /* * Clear pending interrupts. THRE is cleared by reading IIR. Data diff --git a/sys/dev/usb/controller/dwc_otg.c b/sys/dev/usb/controller/dwc_otg.c index b90fbf56022d5..ed88caa42b7e2 100644 --- a/sys/dev/usb/controller/dwc_otg.c +++ b/sys/dev/usb/controller/dwc_otg.c @@ -112,13 +112,14 @@ static int dwc_otg_use_hsic; static SYSCTL_NODE(_hw_usb, OID_AUTO, dwc_otg, CTLFLAG_RW, 0, "USB DWC OTG"); -SYSCTL_INT(_hw_usb_dwc_otg, OID_AUTO, use_hsic, CTLFLAG_RDTUN, +SYSCTL_INT(_hw_usb_dwc_otg, OID_AUTO, use_hsic, CTLFLAG_RD | CTLFLAG_TUN, &dwc_otg_use_hsic, 0, "DWC OTG uses HSIC interface"); +TUNABLE_INT("hw.usb.dwc_otg.use_hsic", &dwc_otg_use_hsic); #ifdef USB_DEBUG static int dwc_otg_debug; -SYSCTL_INT(_hw_usb_dwc_otg, OID_AUTO, debug, CTLFLAG_RWTUN, +SYSCTL_INT(_hw_usb_dwc_otg, OID_AUTO, debug, CTLFLAG_RW, &dwc_otg_debug, 0, "DWC OTG debug level"); #endif diff --git a/sys/dev/usb/controller/ehci.c b/sys/dev/usb/controller/ehci.c index 7d0d5ab6d2099..ad3a3fc55d2b1 100644 --- a/sys/dev/usb/controller/ehci.c +++ b/sys/dev/usb/controller/ehci.c @@ -98,14 +98,19 @@ static int ehciiaadbug = 0; static int ehcilostintrbug = 0; static SYSCTL_NODE(_hw_usb, OID_AUTO, ehci, CTLFLAG_RW, 0, "USB ehci"); -SYSCTL_INT(_hw_usb_ehci, OID_AUTO, debug, CTLFLAG_RWTUN, +SYSCTL_INT(_hw_usb_ehci, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, &ehcidebug, 0, "Debug level"); -SYSCTL_INT(_hw_usb_ehci, OID_AUTO, no_hs, CTLFLAG_RWTUN, +TUNABLE_INT("hw.usb.ehci.debug", &ehcidebug); +SYSCTL_INT(_hw_usb_ehci, OID_AUTO, no_hs, CTLFLAG_RW | CTLFLAG_TUN, &ehcinohighspeed, 0, "Disable High Speed USB"); -SYSCTL_INT(_hw_usb_ehci, OID_AUTO, iaadbug, CTLFLAG_RWTUN, +TUNABLE_INT("hw.usb.ehci.no_hs", &ehcinohighspeed); +SYSCTL_INT(_hw_usb_ehci, OID_AUTO, iaadbug, CTLFLAG_RW | CTLFLAG_TUN, &ehciiaadbug, 0, "Enable doorbell bug workaround"); -SYSCTL_INT(_hw_usb_ehci, OID_AUTO, lostintrbug, CTLFLAG_RWTUN, +TUNABLE_INT("hw.usb.ehci.iaadbug", &ehciiaadbug); +SYSCTL_INT(_hw_usb_ehci, OID_AUTO, lostintrbug, CTLFLAG_RW | CTLFLAG_TUN, &ehcilostintrbug, 0, "Enable lost interrupt bug workaround"); +TUNABLE_INT("hw.usb.ehci.lostintrbug", &ehcilostintrbug); + static void ehci_dump_regs(ehci_softc_t *sc); static void ehci_dump_sqh(ehci_softc_t *sc, ehci_qh_t *sqh); diff --git a/sys/dev/usb/controller/ohci.c b/sys/dev/usb/controller/ohci.c index 206c75314d0c5..86fca1eeaa3b6 100644 --- a/sys/dev/usb/controller/ohci.c +++ b/sys/dev/usb/controller/ohci.c @@ -84,8 +84,9 @@ static int ohcidebug = 0; static SYSCTL_NODE(_hw_usb, OID_AUTO, ohci, CTLFLAG_RW, 0, "USB ohci"); -SYSCTL_INT(_hw_usb_ohci, OID_AUTO, debug, CTLFLAG_RWTUN, +SYSCTL_INT(_hw_usb_ohci, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, &ohcidebug, 0, "ohci debug level"); +TUNABLE_INT("hw.usb.ohci.debug", &ohcidebug); static void ohci_dumpregs(ohci_softc_t *); static void ohci_dump_tds(ohci_td_t *); diff --git a/sys/dev/usb/controller/uhci.c b/sys/dev/usb/controller/uhci.c index 00776154447c0..134a4472363ac 100644 --- a/sys/dev/usb/controller/uhci.c +++ b/sys/dev/usb/controller/uhci.c @@ -89,10 +89,12 @@ static int uhcidebug = 0; static int uhcinoloop = 0; static SYSCTL_NODE(_hw_usb, OID_AUTO, uhci, CTLFLAG_RW, 0, "USB uhci"); -SYSCTL_INT(_hw_usb_uhci, OID_AUTO, debug, CTLFLAG_RWTUN, +SYSCTL_INT(_hw_usb_uhci, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, &uhcidebug, 0, "uhci debug level"); -SYSCTL_INT(_hw_usb_uhci, OID_AUTO, loop, CTLFLAG_RWTUN, +TUNABLE_INT("hw.usb.uhci.debug", &uhcidebug); +SYSCTL_INT(_hw_usb_uhci, OID_AUTO, loop, CTLFLAG_RW | CTLFLAG_TUN, &uhcinoloop, 0, "uhci noloop"); +TUNABLE_INT("hw.usb.uhci.loop", &uhcinoloop); static void uhci_dumpregs(uhci_softc_t *sc); static void uhci_dump_tds(uhci_td_t *td); diff --git a/sys/dev/usb/controller/usb_controller.c b/sys/dev/usb/controller/usb_controller.c index dd75ba7a5aa24..c2cafecf61d40 100644 --- a/sys/dev/usb/controller/usb_controller.c +++ b/sys/dev/usb/controller/usb_controller.c @@ -90,16 +90,19 @@ SYSCTL_INT(_hw_usb_ctrl, OID_AUTO, debug, CTLFLAG_RW, &usb_ctrl_debug, 0, #if USB_HAVE_ROOT_MOUNT_HOLD static int usb_no_boot_wait = 0; -SYSCTL_INT(_hw_usb, OID_AUTO, no_boot_wait, CTLFLAG_RDTUN, &usb_no_boot_wait, 0, +TUNABLE_INT("hw.usb.no_boot_wait", &usb_no_boot_wait); +SYSCTL_INT(_hw_usb, OID_AUTO, no_boot_wait, CTLFLAG_RD|CTLFLAG_TUN, &usb_no_boot_wait, 0, "No USB device enumerate waiting at boot."); #endif static int usb_no_suspend_wait = 0; -SYSCTL_INT(_hw_usb, OID_AUTO, no_suspend_wait, CTLFLAG_RWTUN, +TUNABLE_INT("hw.usb.no_suspend_wait", &usb_no_suspend_wait); +SYSCTL_INT(_hw_usb, OID_AUTO, no_suspend_wait, CTLFLAG_RW|CTLFLAG_TUN, &usb_no_suspend_wait, 0, "No USB device waiting at system suspend."); static int usb_no_shutdown_wait = 0; -SYSCTL_INT(_hw_usb, OID_AUTO, no_shutdown_wait, CTLFLAG_RWTUN, +TUNABLE_INT("hw.usb.no_shutdown_wait", &usb_no_shutdown_wait); +SYSCTL_INT(_hw_usb, OID_AUTO, no_shutdown_wait, CTLFLAG_RW|CTLFLAG_TUN, &usb_no_shutdown_wait, 0, "No USB device waiting at system shutdown."); static devclass_t usb_devclass; diff --git a/sys/dev/usb/controller/xhci.c b/sys/dev/usb/controller/xhci.c index cdfa7d4062883..4570ad2aab840 100644 --- a/sys/dev/usb/controller/xhci.c +++ b/sys/dev/usb/controller/xhci.c @@ -90,20 +90,24 @@ static SYSCTL_NODE(_hw_usb, OID_AUTO, xhci, CTLFLAG_RW, 0, "USB XHCI"); static int xhcistreams; -SYSCTL_INT(_hw_usb_xhci, OID_AUTO, streams, CTLFLAG_RWTUN, +SYSCTL_INT(_hw_usb_xhci, OID_AUTO, streams, CTLFLAG_RW | CTLFLAG_TUN, &xhcistreams, 0, "Set to enable streams mode support"); +TUNABLE_INT("hw.usb.xhci.streams", &xhcistreams); #ifdef USB_DEBUG static int xhcidebug; static int xhciroute; static int xhcipolling; -SYSCTL_INT(_hw_usb_xhci, OID_AUTO, debug, CTLFLAG_RWTUN, +SYSCTL_INT(_hw_usb_xhci, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, &xhcidebug, 0, "Debug level"); -SYSCTL_INT(_hw_usb_xhci, OID_AUTO, xhci_port_route, CTLFLAG_RWTUN, +TUNABLE_INT("hw.usb.xhci.debug", &xhcidebug); +SYSCTL_INT(_hw_usb_xhci, OID_AUTO, xhci_port_route, CTLFLAG_RW | CTLFLAG_TUN, &xhciroute, 0, "Routing bitmap for switching EHCI ports to XHCI controller"); -SYSCTL_INT(_hw_usb_xhci, OID_AUTO, use_polling, CTLFLAG_RWTUN, +TUNABLE_INT("hw.usb.xhci.xhci_port_route", &xhciroute); +SYSCTL_INT(_hw_usb_xhci, OID_AUTO, use_polling, CTLFLAG_RW | CTLFLAG_TUN, &xhcipolling, 0, "Set to enable software interrupt polling for XHCI controller"); +TUNABLE_INT("hw.usb.xhci.use_polling", &xhcipolling); #else #define xhciroute 0 #endif diff --git a/sys/dev/usb/input/ukbd.c b/sys/dev/usb/input/ukbd.c index 0e56d9643a0f5..ede27f726cabd 100644 --- a/sys/dev/usb/input/ukbd.c +++ b/sys/dev/usb/input/ukbd.c @@ -95,12 +95,15 @@ static int ukbd_no_leds = 0; static int ukbd_pollrate = 0; static SYSCTL_NODE(_hw_usb, OID_AUTO, ukbd, CTLFLAG_RW, 0, "USB keyboard"); -SYSCTL_INT(_hw_usb_ukbd, OID_AUTO, debug, CTLFLAG_RWTUN, +SYSCTL_INT(_hw_usb_ukbd, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, &ukbd_debug, 0, "Debug level"); -SYSCTL_INT(_hw_usb_ukbd, OID_AUTO, no_leds, CTLFLAG_RWTUN, +TUNABLE_INT("hw.usb.ukbd.debug", &ukbd_debug); +SYSCTL_INT(_hw_usb_ukbd, OID_AUTO, no_leds, CTLFLAG_RW | CTLFLAG_TUN, &ukbd_no_leds, 0, "Disables setting of keyboard leds"); -SYSCTL_INT(_hw_usb_ukbd, OID_AUTO, pollrate, CTLFLAG_RWTUN, +TUNABLE_INT("hw.usb.ukbd.no_leds", &ukbd_no_leds); +SYSCTL_INT(_hw_usb_ukbd, OID_AUTO, pollrate, CTLFLAG_RW | CTLFLAG_TUN, &ukbd_pollrate, 0, "Force this polling rate, 1-1000Hz"); +TUNABLE_INT("hw.usb.ukbd.pollrate", &ukbd_pollrate); #endif #define UKBD_EMULATE_ATSCANCODE 1 diff --git a/sys/dev/usb/serial/uftdi.c b/sys/dev/usb/serial/uftdi.c index 74e11dda1771a..25da9b892f408 100644 --- a/sys/dev/usb/serial/uftdi.c +++ b/sys/dev/usb/serial/uftdi.c @@ -932,6 +932,7 @@ static const struct jtag_by_name { * creation of tty devices for jtag interfaces. Enabled by default. */ static int skip_jtag_interfaces = 1; +TUNABLE_INT("hw.usb.uftdi.skip_jtag_interfaces", &skip_jtag_interfaces); SYSCTL_INT(_hw_usb_uftdi, OID_AUTO, skip_jtag_interfaces, CTLFLAG_RWTUN, &skip_jtag_interfaces, 1, "Skip creating tty devices for jtag interfaces"); diff --git a/sys/dev/usb/serial/usb_serial.c b/sys/dev/usb/serial/usb_serial.c index 53c0594b41a72..2945415bbe99a 100644 --- a/sys/dev/usb/serial/usb_serial.c +++ b/sys/dev/usb/serial/usb_serial.c @@ -119,11 +119,14 @@ static int ucom_cons_subunit = 0; static int ucom_cons_baud = 9600; static struct ucom_softc *ucom_cons_softc = NULL; -SYSCTL_INT(_hw_usb_ucom, OID_AUTO, cons_unit, CTLFLAG_RWTUN, +TUNABLE_INT("hw.usb.ucom.cons_unit", &ucom_cons_unit); +SYSCTL_INT(_hw_usb_ucom, OID_AUTO, cons_unit, CTLFLAG_RW | CTLFLAG_TUN, &ucom_cons_unit, 0, "console unit number"); -SYSCTL_INT(_hw_usb_ucom, OID_AUTO, cons_subunit, CTLFLAG_RWTUN, +TUNABLE_INT("hw.usb.ucom.cons_subunit", &ucom_cons_subunit); +SYSCTL_INT(_hw_usb_ucom, OID_AUTO, cons_subunit, CTLFLAG_RW | CTLFLAG_TUN, &ucom_cons_subunit, 0, "console subunit number"); -SYSCTL_INT(_hw_usb_ucom, OID_AUTO, cons_baud, CTLFLAG_RWTUN, +TUNABLE_INT("hw.usb.ucom.cons_baud", &ucom_cons_baud); +SYSCTL_INT(_hw_usb_ucom, OID_AUTO, cons_baud, CTLFLAG_RW | CTLFLAG_TUN, &ucom_cons_baud, 0, "console baud rate"); static usb_proc_callback_t ucom_cfg_start_transfers; diff --git a/sys/dev/usb/storage/umass.c b/sys/dev/usb/storage/umass.c index e169abbfb53e1..f3a51b313ff4a 100644 --- a/sys/dev/usb/storage/umass.c +++ b/sys/dev/usb/storage/umass.c @@ -167,10 +167,12 @@ static int umass_debug; static int umass_throttle; static SYSCTL_NODE(_hw_usb, OID_AUTO, umass, CTLFLAG_RW, 0, "USB umass"); -SYSCTL_INT(_hw_usb_umass, OID_AUTO, debug, CTLFLAG_RWTUN, +SYSCTL_INT(_hw_usb_umass, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, &umass_debug, 0, "umass debug level"); -SYSCTL_INT(_hw_usb_umass, OID_AUTO, throttle, CTLFLAG_RWTUN, +TUNABLE_INT("hw.usb.umass.debug", &umass_debug); +SYSCTL_INT(_hw_usb_umass, OID_AUTO, throttle, CTLFLAG_RW | CTLFLAG_TUN, &umass_throttle, 0, "Forced delay between commands in milliseconds"); +TUNABLE_INT("hw.usb.umass.throttle", &umass_throttle); #else #define DIF(...) do { } while (0) #define DPRINTF(...) do { } while (0) diff --git a/sys/dev/usb/usb_debug.c b/sys/dev/usb/usb_debug.c index 9c7fa6e1d062f..338298835b806 100644 --- a/sys/dev/usb/usb_debug.c +++ b/sys/dev/usb/usb_debug.c @@ -67,8 +67,9 @@ int usb_debug = 0; SYSCTL_NODE(_hw, OID_AUTO, usb, CTLFLAG_RW, 0, "USB debugging"); -SYSCTL_INT(_hw_usb, OID_AUTO, debug, CTLFLAG_RWTUN, +SYSCTL_INT(_hw_usb, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, &usb_debug, 0, "Debug level"); +TUNABLE_INT("hw.usb.debug", &usb_debug); #ifdef USB_DEBUG /* @@ -77,34 +78,44 @@ SYSCTL_INT(_hw_usb, OID_AUTO, debug, CTLFLAG_RWTUN, static SYSCTL_NODE(_hw_usb, OID_AUTO, timings, CTLFLAG_RW, 0, "Timings"); static int usb_timings_sysctl_handler(SYSCTL_HANDLER_ARGS); -SYSCTL_PROC(_hw_usb_timings, OID_AUTO, port_reset_delay, CTLTYPE_UINT | CTLFLAG_RWTUN, +TUNABLE_INT("hw.usb.timings.port_reset_delay", (int *)&usb_port_reset_delay); +SYSCTL_PROC(_hw_usb_timings, OID_AUTO, port_reset_delay, CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_TUN, &usb_port_reset_delay, sizeof(usb_port_reset_delay), usb_timings_sysctl_handler, "IU", "Port Reset Delay"); -SYSCTL_PROC(_hw_usb_timings, OID_AUTO, port_root_reset_delay, CTLTYPE_UINT | CTLFLAG_RWTUN, +TUNABLE_INT("hw.usb.timings.port_root_reset_delay", (int *)&usb_port_root_reset_delay); +SYSCTL_PROC(_hw_usb_timings, OID_AUTO, port_root_reset_delay, CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_TUN, &usb_port_root_reset_delay, sizeof(usb_port_root_reset_delay), usb_timings_sysctl_handler, "IU", "Root Port Reset Delay"); -SYSCTL_PROC(_hw_usb_timings, OID_AUTO, port_reset_recovery, CTLTYPE_UINT | CTLFLAG_RWTUN, +TUNABLE_INT("hw.usb.timings.port_reset_recovery", (int *)&usb_port_reset_recovery); +SYSCTL_PROC(_hw_usb_timings, OID_AUTO, port_reset_recovery, CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_TUN, &usb_port_reset_recovery, sizeof(usb_port_reset_recovery), usb_timings_sysctl_handler, "IU", "Port Reset Recovery"); -SYSCTL_PROC(_hw_usb_timings, OID_AUTO, port_powerup_delay, CTLTYPE_UINT | CTLFLAG_RWTUN, +TUNABLE_INT("hw.usb.timings.port_powerup_delay", (int *)&usb_port_powerup_delay); +SYSCTL_PROC(_hw_usb_timings, OID_AUTO, port_powerup_delay, CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_TUN, &usb_port_powerup_delay, sizeof(usb_port_powerup_delay), usb_timings_sysctl_handler, "IU", "Port PowerUp Delay"); -SYSCTL_PROC(_hw_usb_timings, OID_AUTO, port_resume_delay, CTLTYPE_UINT | CTLFLAG_RWTUN, +TUNABLE_INT("hw.usb.timings.port_resume_delay", (int *)&usb_port_resume_delay); +SYSCTL_PROC(_hw_usb_timings, OID_AUTO, port_resume_delay, CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_TUN, &usb_port_resume_delay, sizeof(usb_port_resume_delay), usb_timings_sysctl_handler, "IU", "Port Resume Delay"); -SYSCTL_PROC(_hw_usb_timings, OID_AUTO, set_address_settle, CTLTYPE_UINT | CTLFLAG_RWTUN, +TUNABLE_INT("hw.usb.timings.set_address_settle", (int *)&usb_set_address_settle); +SYSCTL_PROC(_hw_usb_timings, OID_AUTO, set_address_settle, CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_TUN, &usb_set_address_settle, sizeof(usb_set_address_settle), usb_timings_sysctl_handler, "IU", "Set Address Settle"); -SYSCTL_PROC(_hw_usb_timings, OID_AUTO, resume_delay, CTLTYPE_UINT | CTLFLAG_RWTUN, +TUNABLE_INT("hw.usb.timings.resume_delay", (int *)&usb_resume_delay); +SYSCTL_PROC(_hw_usb_timings, OID_AUTO, resume_delay, CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_TUN, &usb_resume_delay, sizeof(usb_resume_delay), usb_timings_sysctl_handler, "IU", "Resume Delay"); -SYSCTL_PROC(_hw_usb_timings, OID_AUTO, resume_wait, CTLTYPE_UINT | CTLFLAG_RWTUN, +TUNABLE_INT("hw.usb.timings.resume_wait", (int *)&usb_resume_wait); +SYSCTL_PROC(_hw_usb_timings, OID_AUTO, resume_wait, CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_TUN, &usb_resume_wait, sizeof(usb_resume_wait), usb_timings_sysctl_handler, "IU", "Resume Wait"); -SYSCTL_PROC(_hw_usb_timings, OID_AUTO, resume_recovery, CTLTYPE_UINT | CTLFLAG_RWTUN, +TUNABLE_INT("hw.usb.timings.resume_recovery", (int *)&usb_resume_recovery); +SYSCTL_PROC(_hw_usb_timings, OID_AUTO, resume_recovery, CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_TUN, &usb_resume_recovery, sizeof(usb_resume_recovery), usb_timings_sysctl_handler, "IU", "Resume Recovery"); -SYSCTL_PROC(_hw_usb_timings, OID_AUTO, extra_power_up_time, CTLTYPE_UINT | CTLFLAG_RWTUN, +TUNABLE_INT("hw.usb.timings.extra_power_up_time", (int *)&usb_extra_power_up_time); +SYSCTL_PROC(_hw_usb_timings, OID_AUTO, extra_power_up_time, CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_TUN, &usb_extra_power_up_time, sizeof(usb_extra_power_up_time), usb_timings_sysctl_handler, "IU", "Extra PowerUp Time"); #endif diff --git a/sys/dev/usb/usb_dev.c b/sys/dev/usb/usb_dev.c index 396067309ac4d..6ad02a7d035dd 100644 --- a/sys/dev/usb/usb_dev.c +++ b/sys/dev/usb/usb_dev.c @@ -86,8 +86,9 @@ static int usb_fifo_debug = 0; static SYSCTL_NODE(_hw_usb, OID_AUTO, dev, CTLFLAG_RW, 0, "USB device"); -SYSCTL_INT(_hw_usb_dev, OID_AUTO, debug, CTLFLAG_RWTUN, +SYSCTL_INT(_hw_usb_dev, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, &usb_fifo_debug, 0, "Debug Level"); +TUNABLE_INT("hw.usb.dev.debug", &usb_fifo_debug); #endif #if ((__FreeBSD_version >= 700001) || (__FreeBSD_version == 0) || \ diff --git a/sys/dev/usb/usb_device.c b/sys/dev/usb/usb_device.c index 1acfd1eee95cb..7acb5cbc4f7d0 100644 --- a/sys/dev/usb/usb_device.c +++ b/sys/dev/usb/usb_device.c @@ -118,7 +118,8 @@ int usb_template = USB_TEMPLATE; int usb_template; #endif -SYSCTL_INT(_hw_usb, OID_AUTO, template, CTLFLAG_RWTUN, +TUNABLE_INT("hw.usb.usb_template", &usb_template); +SYSCTL_INT(_hw_usb, OID_AUTO, template, CTLFLAG_RW | CTLFLAG_TUN, &usb_template, 0, "Selected USB device side template"); /* English is default language */ @@ -126,10 +127,12 @@ SYSCTL_INT(_hw_usb, OID_AUTO, template, CTLFLAG_RWTUN, static int usb_lang_id = 0x0009; static int usb_lang_mask = 0x00FF; -SYSCTL_INT(_hw_usb, OID_AUTO, usb_lang_id, CTLFLAG_RWTUN, +TUNABLE_INT("hw.usb.usb_lang_id", &usb_lang_id); +SYSCTL_INT(_hw_usb, OID_AUTO, usb_lang_id, CTLFLAG_RW | CTLFLAG_TUN, &usb_lang_id, 0, "Preferred USB language ID"); -SYSCTL_INT(_hw_usb, OID_AUTO, usb_lang_mask, CTLFLAG_RWTUN, +TUNABLE_INT("hw.usb.usb_lang_mask", &usb_lang_mask); +SYSCTL_INT(_hw_usb, OID_AUTO, usb_lang_mask, CTLFLAG_RW | CTLFLAG_TUN, &usb_lang_mask, 0, "Preferred USB language mask"); static const char* statestr[USB_STATE_MAX] = { diff --git a/sys/dev/usb/usb_generic.c b/sys/dev/usb/usb_generic.c index 96dfe8bceb872..4ebd557a51821 100644 --- a/sys/dev/usb/usb_generic.c +++ b/sys/dev/usb/usb_generic.c @@ -131,8 +131,9 @@ struct usb_fifo_methods usb_ugen_methods = { static int ugen_debug = 0; static SYSCTL_NODE(_hw_usb, OID_AUTO, ugen, CTLFLAG_RW, 0, "USB generic"); -SYSCTL_INT(_hw_usb_ugen, OID_AUTO, debug, CTLFLAG_RWTUN, &ugen_debug, +SYSCTL_INT(_hw_usb_ugen, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, &ugen_debug, 0, "Debug level"); +TUNABLE_INT("hw.usb.ugen.debug", &ugen_debug); #endif diff --git a/sys/dev/usb/usb_hub.c b/sys/dev/usb/usb_hub.c index 8e0d557a9c5f7..e9c9a42c39142 100644 --- a/sys/dev/usb/usb_hub.c +++ b/sys/dev/usb/usb_hub.c @@ -86,8 +86,9 @@ enum { static int uhub_debug = 0; static SYSCTL_NODE(_hw_usb, OID_AUTO, uhub, CTLFLAG_RW, 0, "USB HUB"); -SYSCTL_INT(_hw_usb_uhub, OID_AUTO, debug, CTLFLAG_RWTUN, &uhub_debug, 0, +SYSCTL_INT(_hw_usb_uhub, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, &uhub_debug, 0, "Debug level"); +TUNABLE_INT("hw.usb.uhub.debug", &uhub_debug); #endif #if USB_HAVE_POWERD diff --git a/sys/dev/usb/usb_process.c b/sys/dev/usb/usb_process.c index 683c700d2472d..e70166ca4f2c4 100644 --- a/sys/dev/usb/usb_process.c +++ b/sys/dev/usb/usb_process.c @@ -90,8 +90,9 @@ static int usb_pcount; static int usb_proc_debug; static SYSCTL_NODE(_hw_usb, OID_AUTO, proc, CTLFLAG_RW, 0, "USB process"); -SYSCTL_INT(_hw_usb_proc, OID_AUTO, debug, CTLFLAG_RWTUN, &usb_proc_debug, 0, +SYSCTL_INT(_hw_usb_proc, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, &usb_proc_debug, 0, "Debug level"); +TUNABLE_INT("hw.usb.proc.debug", &usb_proc_debug); #endif /*------------------------------------------------------------------------* diff --git a/sys/dev/usb/wlan/if_uath.c b/sys/dev/usb/wlan/if_uath.c index b8e886388f72f..9db1e04ce3de5 100644 --- a/sys/dev/usb/wlan/if_uath.c +++ b/sys/dev/usb/wlan/if_uath.c @@ -115,16 +115,18 @@ __FBSDID("$FreeBSD$"); static SYSCTL_NODE(_hw_usb, OID_AUTO, uath, CTLFLAG_RW, 0, "USB Atheros"); static int uath_countrycode = CTRY_DEFAULT; /* country code */ -SYSCTL_INT(_hw_usb_uath, OID_AUTO, countrycode, CTLFLAG_RWTUN, &uath_countrycode, +SYSCTL_INT(_hw_usb_uath, OID_AUTO, countrycode, CTLFLAG_RW | CTLFLAG_TUN, &uath_countrycode, 0, "country code"); +TUNABLE_INT("hw.usb.uath.countrycode", &uath_countrycode); static int uath_regdomain = 0; /* regulatory domain */ SYSCTL_INT(_hw_usb_uath, OID_AUTO, regdomain, CTLFLAG_RD, &uath_regdomain, 0, "regulatory domain"); #ifdef UATH_DEBUG int uath_debug = 0; -SYSCTL_INT(_hw_usb_uath, OID_AUTO, debug, CTLFLAG_RWTUN, &uath_debug, 0, +SYSCTL_INT(_hw_usb_uath, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, &uath_debug, 0, "uath debug level"); +TUNABLE_INT("hw.usb.uath.debug", &uath_debug); enum { UATH_DEBUG_XMIT = 0x00000001, /* basic xmit operation */ UATH_DEBUG_XMIT_DUMP = 0x00000002, /* xmit dump */ diff --git a/sys/dev/usb/wlan/if_upgt.c b/sys/dev/usb/wlan/if_upgt.c index 51f4ed98c3be7..a860a2b6910bd 100644 --- a/sys/dev/usb/wlan/if_upgt.c +++ b/sys/dev/usb/wlan/if_upgt.c @@ -76,8 +76,9 @@ static SYSCTL_NODE(_hw, OID_AUTO, upgt, CTLFLAG_RD, 0, #ifdef UPGT_DEBUG int upgt_debug = 0; -SYSCTL_INT(_hw_upgt, OID_AUTO, debug, CTLFLAG_RWTUN, &upgt_debug, +SYSCTL_INT(_hw_upgt, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, &upgt_debug, 0, "control debugging printfs"); +TUNABLE_INT("hw.upgt.debug", &upgt_debug); enum { UPGT_DEBUG_XMIT = 0x00000001, /* basic xmit operation */ UPGT_DEBUG_RECV = 0x00000002, /* basic recv operation */ diff --git a/sys/dev/usb/wlan/if_urtw.c b/sys/dev/usb/wlan/if_urtw.c index d2837324b63f3..a5516339fb41b 100644 --- a/sys/dev/usb/wlan/if_urtw.c +++ b/sys/dev/usb/wlan/if_urtw.c @@ -65,8 +65,9 @@ __FBSDID("$FreeBSD$"); static SYSCTL_NODE(_hw_usb, OID_AUTO, urtw, CTLFLAG_RW, 0, "USB Realtek 8187L"); #ifdef URTW_DEBUG int urtw_debug = 0; -SYSCTL_INT(_hw_usb_urtw, OID_AUTO, debug, CTLFLAG_RWTUN, &urtw_debug, 0, +SYSCTL_INT(_hw_usb_urtw, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, &urtw_debug, 0, "control debugging printfs"); +TUNABLE_INT("hw.usb.urtw.debug", &urtw_debug); enum { URTW_DEBUG_XMIT = 0x00000001, /* basic xmit operation */ URTW_DEBUG_RECV = 0x00000002, /* basic recv operation */ @@ -89,8 +90,9 @@ enum { } while (0) #endif static int urtw_preamble_mode = URTW_PREAMBLE_MODE_LONG; -SYSCTL_INT(_hw_usb_urtw, OID_AUTO, preamble_mode, CTLFLAG_RWTUN, +SYSCTL_INT(_hw_usb_urtw, OID_AUTO, preamble_mode, CTLFLAG_RW | CTLFLAG_TUN, &urtw_preamble_mode, 0, "set the preable mode (long or short)"); +TUNABLE_INT("hw.usb.urtw.preamble_mode", &urtw_preamble_mode); /* recognized device vendors/products */ #define urtw_lookup(v, p) \ diff --git a/sys/dev/vt/vt.h b/sys/dev/vt/vt.h index cd6aa5ba4db2a..b216499b735f1 100644 --- a/sys/dev/vt/vt.h +++ b/sys/dev/vt/vt.h @@ -84,8 +84,9 @@ #define VT_SYSCTL_INT(_name, _default, _descr) \ static int vt_##_name = _default; \ -SYSCTL_INT(_kern_vt, OID_AUTO, _name, CTLFLAG_RWTUN, &vt_##_name, _default,\ - _descr); +SYSCTL_INT(_kern_vt, OID_AUTO, _name, CTLFLAG_RW, &vt_##_name, _default,\ + _descr); \ +TUNABLE_INT("kern.vt." #_name, &vt_##_name); struct vt_driver; diff --git a/sys/dev/wpi/if_wpi.c b/sys/dev/wpi/if_wpi.c index 6e4428bef5163..efbcb298e9619 100644 --- a/sys/dev/wpi/if_wpi.c +++ b/sys/dev/wpi/if_wpi.c @@ -130,8 +130,9 @@ enum { WPI_DEBUG_ANY = 0xffffffff }; -static int wpi_debug; -SYSCTL_INT(_debug, OID_AUTO, wpi, CTLFLAG_RWTUN, &wpi_debug, 0, "wpi debug level"); +static int wpi_debug = 0; +SYSCTL_INT(_debug, OID_AUTO, wpi, CTLFLAG_RW, &wpi_debug, 0, "wpi debug level"); +TUNABLE_INT("debug.wpi", &wpi_debug); #else #define DPRINTF(x) diff --git a/sys/gdb/gdb_cons.c b/sys/gdb/gdb_cons.c index 47f453fc3eea2..ff746658601f0 100644 --- a/sys/gdb/gdb_cons.c +++ b/sys/gdb/gdb_cons.c @@ -58,8 +58,9 @@ struct gdbcons { static struct gdbcons state = { -1 }; static int gdbcons_enable = 0; -SYSCTL_INT(_debug, OID_AUTO, gdbcons, CTLFLAG_RWTUN, &gdbcons_enable, - 0, "copy console messages to GDB"); +SYSCTL_INT(_debug, OID_AUTO, gdbcons, CTLFLAG_RW, &gdbcons_enable, + 0, "copy console messages to gdb"); +TUNABLE_INT("debug.gdbcons", &gdbcons_enable); static void gdb_cnprobe(struct consdev *cp) diff --git a/sys/geom/concat/g_concat.c b/sys/geom/concat/g_concat.c index 4627ff9fa2ca7..2efc1b53fd616 100644 --- a/sys/geom/concat/g_concat.c +++ b/sys/geom/concat/g_concat.c @@ -48,7 +48,8 @@ SYSCTL_DECL(_kern_geom); static SYSCTL_NODE(_kern_geom, OID_AUTO, concat, CTLFLAG_RW, 0, "GEOM_CONCAT stuff"); static u_int g_concat_debug = 0; -SYSCTL_UINT(_kern_geom_concat, OID_AUTO, debug, CTLFLAG_RWTUN, &g_concat_debug, 0, +TUNABLE_INT("kern.geom.concat.debug", &g_concat_debug); +SYSCTL_UINT(_kern_geom_concat, OID_AUTO, debug, CTLFLAG_RW, &g_concat_debug, 0, "Debug level"); static int g_concat_destroy(struct g_concat_softc *sc, boolean_t force); diff --git a/sys/geom/eli/g_eli.c b/sys/geom/eli/g_eli.c index 2c4dc2c41ae50..d1f3cd25a0fb4 100644 --- a/sys/geom/eli/g_eli.c +++ b/sys/geom/eli/g_eli.c @@ -63,23 +63,29 @@ static int g_eli_version = G_ELI_VERSION; SYSCTL_INT(_kern_geom_eli, OID_AUTO, version, CTLFLAG_RD, &g_eli_version, 0, "GELI version"); int g_eli_debug = 0; -SYSCTL_INT(_kern_geom_eli, OID_AUTO, debug, CTLFLAG_RWTUN, &g_eli_debug, 0, +TUNABLE_INT("kern.geom.eli.debug", &g_eli_debug); +SYSCTL_INT(_kern_geom_eli, OID_AUTO, debug, CTLFLAG_RW, &g_eli_debug, 0, "Debug level"); static u_int g_eli_tries = 3; -SYSCTL_UINT(_kern_geom_eli, OID_AUTO, tries, CTLFLAG_RWTUN, &g_eli_tries, 0, +TUNABLE_INT("kern.geom.eli.tries", &g_eli_tries); +SYSCTL_UINT(_kern_geom_eli, OID_AUTO, tries, CTLFLAG_RW, &g_eli_tries, 0, "Number of tries for entering the passphrase"); static u_int g_eli_visible_passphrase = GETS_NOECHO; -SYSCTL_UINT(_kern_geom_eli, OID_AUTO, visible_passphrase, CTLFLAG_RWTUN, +TUNABLE_INT("kern.geom.eli.visible_passphrase", &g_eli_visible_passphrase); +SYSCTL_UINT(_kern_geom_eli, OID_AUTO, visible_passphrase, CTLFLAG_RW, &g_eli_visible_passphrase, 0, "Visibility of passphrase prompt (0 = invisible, 1 = visible, 2 = asterisk)"); u_int g_eli_overwrites = G_ELI_OVERWRITES; -SYSCTL_UINT(_kern_geom_eli, OID_AUTO, overwrites, CTLFLAG_RWTUN, &g_eli_overwrites, +TUNABLE_INT("kern.geom.eli.overwrites", &g_eli_overwrites); +SYSCTL_UINT(_kern_geom_eli, OID_AUTO, overwrites, CTLFLAG_RW, &g_eli_overwrites, 0, "Number of times on-disk keys should be overwritten when destroying them"); static u_int g_eli_threads = 0; -SYSCTL_UINT(_kern_geom_eli, OID_AUTO, threads, CTLFLAG_RWTUN, &g_eli_threads, 0, +TUNABLE_INT("kern.geom.eli.threads", &g_eli_threads); +SYSCTL_UINT(_kern_geom_eli, OID_AUTO, threads, CTLFLAG_RW, &g_eli_threads, 0, "Number of threads doing crypto work"); u_int g_eli_batch = 0; -SYSCTL_UINT(_kern_geom_eli, OID_AUTO, batch, CTLFLAG_RWTUN, &g_eli_batch, 0, +TUNABLE_INT("kern.geom.eli.batch", &g_eli_batch); +SYSCTL_UINT(_kern_geom_eli, OID_AUTO, batch, CTLFLAG_RW, &g_eli_batch, 0, "Use crypto operations batching"); static eventhandler_tag g_eli_pre_sync = NULL; diff --git a/sys/geom/eli/g_eli_key_cache.c b/sys/geom/eli/g_eli_key_cache.c index cb867166cee39..9530495050ec5 100644 --- a/sys/geom/eli/g_eli_key_cache.c +++ b/sys/geom/eli/g_eli_key_cache.c @@ -47,6 +47,7 @@ SYSCTL_DECL(_kern_geom_eli); * provider with 512 bytes sectors and will take around 1MB of memory. */ static u_int g_eli_key_cache_limit = 8192; +TUNABLE_INT("kern.geom.eli.key_cache_limit", &g_eli_key_cache_limit); SYSCTL_UINT(_kern_geom_eli, OID_AUTO, key_cache_limit, CTLFLAG_RDTUN, &g_eli_key_cache_limit, 0, "Maximum number of encryption keys to cache"); static uint64_t g_eli_key_cache_hits; diff --git a/sys/geom/gate/g_gate.c b/sys/geom/gate/g_gate.c index ae0d7b094a5f2..eed4abbc54a23 100644 --- a/sys/geom/gate/g_gate.c +++ b/sys/geom/gate/g_gate.c @@ -62,9 +62,11 @@ SYSCTL_DECL(_kern_geom); static SYSCTL_NODE(_kern_geom, OID_AUTO, gate, CTLFLAG_RW, 0, "GEOM_GATE configuration"); static int g_gate_debug = 0; -SYSCTL_INT(_kern_geom_gate, OID_AUTO, debug, CTLFLAG_RWTUN, &g_gate_debug, 0, +TUNABLE_INT("kern.geom.gate.debug", &g_gate_debug); +SYSCTL_INT(_kern_geom_gate, OID_AUTO, debug, CTLFLAG_RW, &g_gate_debug, 0, "Debug level"); static u_int g_gate_maxunits = 256; +TUNABLE_INT("kern.geom.gate.maxunits", &g_gate_maxunits); SYSCTL_UINT(_kern_geom_gate, OID_AUTO, maxunits, CTLFLAG_RDTUN, &g_gate_maxunits, 0, "Maximum number of ggate devices"); diff --git a/sys/geom/geom_disk.c b/sys/geom/geom_disk.c index 5cfdaf0af3698..eb72597dbe345 100644 --- a/sys/geom/geom_disk.c +++ b/sys/geom/geom_disk.c @@ -561,9 +561,12 @@ g_disk_create(void *arg, int flag) SYSCTL_STATIC_CHILDREN(_kern_geom_disk), OID_AUTO, gp->name, CTLFLAG_RD, 0, tmpstr); if (sc->sysctl_tree != NULL) { + snprintf(tmpstr, sizeof(tmpstr), + "kern.geom.disk.%s.led", gp->name); + TUNABLE_STR_FETCH(tmpstr, sc->led, sizeof(sc->led)); SYSCTL_ADD_STRING(&sc->sysctl_ctx, SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, "led", - CTLFLAG_RWTUN, sc->led, sizeof(sc->led), + CTLFLAG_RW | CTLFLAG_TUN, sc->led, sizeof(sc->led), "LED name"); } pp->private = sc; diff --git a/sys/geom/geom_kern.c b/sys/geom/geom_kern.c index 3559daf5fcab6..79afb14abe9e2 100644 --- a/sys/geom/geom_kern.c +++ b/sys/geom/geom_kern.c @@ -212,7 +212,8 @@ SYSCTL_PROC(_kern_geom, OID_AUTO, conftxt, CTLTYPE_STRING|CTLFLAG_RD, 0, 0, sysctl_kern_geom_conftxt, "", "Dump the GEOM config in txt"); -SYSCTL_INT(_kern_geom, OID_AUTO, debugflags, CTLFLAG_RWTUN, +TUNABLE_INT("kern.geom.debugflags", &g_debugflags); +SYSCTL_INT(_kern_geom, OID_AUTO, debugflags, CTLFLAG_RW, &g_debugflags, 0, "Set various trace levels for GEOM debugging"); SYSCTL_INT(_kern_geom, OID_AUTO, notaste, CTLFLAG_RW, diff --git a/sys/geom/journal/g_journal.c b/sys/geom/journal/g_journal.c index 52dbc36e73365..390847864812e 100644 --- a/sys/geom/journal/g_journal.c +++ b/sys/geom/journal/g_journal.c @@ -84,6 +84,7 @@ const struct g_journal_desc *g_journal_filesystems[] = { SYSCTL_DECL(_kern_geom); int g_journal_debug = 0; +TUNABLE_INT("kern.geom.journal.debug", &g_journal_debug); static u_int g_journal_switch_time = 10; static u_int g_journal_force_switch = 70; static u_int g_journal_parallel_flushes = 16; @@ -94,7 +95,7 @@ static u_int g_journal_do_optimize = 1; static SYSCTL_NODE(_kern_geom, OID_AUTO, journal, CTLFLAG_RW, 0, "GEOM_JOURNAL stuff"); -SYSCTL_INT(_kern_geom_journal, OID_AUTO, debug, CTLFLAG_RWTUN, &g_journal_debug, 0, +SYSCTL_INT(_kern_geom_journal, OID_AUTO, debug, CTLFLAG_RW, &g_journal_debug, 0, "Debug level"); SYSCTL_UINT(_kern_geom_journal, OID_AUTO, switch_time, CTLFLAG_RW, &g_journal_switch_time, 0, "Switch journals every N seconds"); @@ -132,7 +133,9 @@ SYSCTL_UINT(_kern_geom_journal, OID_AUTO, optimize, CTLFLAG_RW, static u_int g_journal_cache_used = 0; static u_int g_journal_cache_limit = 64 * 1024 * 1024; +TUNABLE_INT("kern.geom.journal.cache.limit", &g_journal_cache_limit); static u_int g_journal_cache_divisor = 2; +TUNABLE_INT("kern.geom.journal.cache.divisor", &g_journal_cache_divisor); static u_int g_journal_cache_switch = 90; static u_int g_journal_cache_misses = 0; static u_int g_journal_cache_alloc_failures = 0; @@ -157,7 +160,7 @@ g_journal_cache_limit_sysctl(SYSCTL_HANDLER_ARGS) return (0); } SYSCTL_PROC(_kern_geom_journal_cache, OID_AUTO, limit, - CTLTYPE_UINT | CTLFLAG_RWTUN, NULL, 0, g_journal_cache_limit_sysctl, "I", + CTLTYPE_UINT | CTLFLAG_RW, NULL, 0, g_journal_cache_limit_sysctl, "I", "Maximum number of allocated bytes"); SYSCTL_UINT(_kern_geom_journal_cache, OID_AUTO, divisor, CTLFLAG_RDTUN, &g_journal_cache_divisor, 0, diff --git a/sys/geom/label/g_label.c b/sys/geom/label/g_label.c index 36498e1c3b1ef..ce1376e269ca7 100644 --- a/sys/geom/label/g_label.c +++ b/sys/geom/label/g_label.c @@ -50,7 +50,8 @@ FEATURE(geom_label, "GEOM labeling support"); SYSCTL_DECL(_kern_geom); SYSCTL_NODE(_kern_geom, OID_AUTO, label, CTLFLAG_RW, 0, "GEOM_LABEL stuff"); u_int g_label_debug = 0; -SYSCTL_UINT(_kern_geom_label, OID_AUTO, debug, CTLFLAG_RWTUN, &g_label_debug, 0, +TUNABLE_INT("kern.geom.label.debug", &g_label_debug); +SYSCTL_UINT(_kern_geom_label, OID_AUTO, debug, CTLFLAG_RW, &g_label_debug, 0, "Debug level"); static int g_label_destroy_geom(struct gctl_req *req, struct g_class *mp, diff --git a/sys/geom/label/g_label.h b/sys/geom/label/g_label.h index 66b762c6f920f..eca31264ec16f 100644 --- a/sys/geom/label/g_label.h +++ b/sys/geom/label/g_label.h @@ -65,7 +65,9 @@ SYSCTL_DECL(_kern_geom_label); SYSCTL_NODE(_kern_geom_label, OID_AUTO, kind, CTLFLAG_RD, \ NULL, ""); \ SYSCTL_INT(_kern_geom_label_##kind, OID_AUTO, enable, \ - CTLFLAG_RWTUN, &label.ld_enabled, 1, descr) + CTLFLAG_RW, &label.ld_enabled, 1, descr); \ + TUNABLE_INT("kern.geom.label." __XSTRING(kind) ".enable", \ + &label.ld_enabled) typedef void g_label_taste_t (struct g_consumer *cp, char *label, size_t size); diff --git a/sys/geom/linux_lvm/g_linux_lvm.c b/sys/geom/linux_lvm/g_linux_lvm.c index bf2f1e795f3b7..2ac19e06958f3 100644 --- a/sys/geom/linux_lvm/g_linux_lvm.c +++ b/sys/geom/linux_lvm/g_linux_lvm.c @@ -79,7 +79,8 @@ SYSCTL_DECL(_kern_geom); SYSCTL_NODE(_kern_geom, OID_AUTO, linux_lvm, CTLFLAG_RW, 0, "GEOM_LINUX_LVM stuff"); static u_int g_llvm_debug = 0; -SYSCTL_UINT(_kern_geom_linux_lvm, OID_AUTO, debug, CTLFLAG_RWTUN, &g_llvm_debug, 0, +TUNABLE_INT("kern.geom.linux_lvm.debug", &g_llvm_debug); +SYSCTL_UINT(_kern_geom_linux_lvm, OID_AUTO, debug, CTLFLAG_RW, &g_llvm_debug, 0, "Debug level"); LIST_HEAD(, g_llvm_vg) vg_list; diff --git a/sys/geom/mirror/g_mirror.c b/sys/geom/mirror/g_mirror.c index 2fae439c99f65..e4dffdcae2c12 100644 --- a/sys/geom/mirror/g_mirror.c +++ b/sys/geom/mirror/g_mirror.c @@ -54,18 +54,24 @@ SYSCTL_DECL(_kern_geom); static SYSCTL_NODE(_kern_geom, OID_AUTO, mirror, CTLFLAG_RW, 0, "GEOM_MIRROR stuff"); u_int g_mirror_debug = 0; -SYSCTL_UINT(_kern_geom_mirror, OID_AUTO, debug, CTLFLAG_RWTUN, &g_mirror_debug, 0, +TUNABLE_INT("kern.geom.mirror.debug", &g_mirror_debug); +SYSCTL_UINT(_kern_geom_mirror, OID_AUTO, debug, CTLFLAG_RW, &g_mirror_debug, 0, "Debug level"); static u_int g_mirror_timeout = 4; -SYSCTL_UINT(_kern_geom_mirror, OID_AUTO, timeout, CTLFLAG_RWTUN, &g_mirror_timeout, +TUNABLE_INT("kern.geom.mirror.timeout", &g_mirror_timeout); +SYSCTL_UINT(_kern_geom_mirror, OID_AUTO, timeout, CTLFLAG_RW, &g_mirror_timeout, 0, "Time to wait on all mirror components"); static u_int g_mirror_idletime = 5; -SYSCTL_UINT(_kern_geom_mirror, OID_AUTO, idletime, CTLFLAG_RWTUN, +TUNABLE_INT("kern.geom.mirror.idletime", &g_mirror_idletime); +SYSCTL_UINT(_kern_geom_mirror, OID_AUTO, idletime, CTLFLAG_RW, &g_mirror_idletime, 0, "Mark components as clean when idling"); static u_int g_mirror_disconnect_on_failure = 1; -SYSCTL_UINT(_kern_geom_mirror, OID_AUTO, disconnect_on_failure, CTLFLAG_RWTUN, +TUNABLE_INT("kern.geom.mirror.disconnect_on_failure", + &g_mirror_disconnect_on_failure); +SYSCTL_UINT(_kern_geom_mirror, OID_AUTO, disconnect_on_failure, CTLFLAG_RW, &g_mirror_disconnect_on_failure, 0, "Disconnect component on I/O failure."); static u_int g_mirror_syncreqs = 2; +TUNABLE_INT("kern.geom.mirror.sync_requests", &g_mirror_syncreqs); SYSCTL_UINT(_kern_geom_mirror, OID_AUTO, sync_requests, CTLFLAG_RDTUN, &g_mirror_syncreqs, 0, "Parallel synchronization I/O requests."); diff --git a/sys/geom/part/g_part.c b/sys/geom/part/g_part.c index 2a04ba315673c..8429fa06a26bf 100644 --- a/sys/geom/part/g_part.c +++ b/sys/geom/part/g_part.c @@ -123,8 +123,9 @@ SYSCTL_DECL(_kern_geom); SYSCTL_NODE(_kern_geom, OID_AUTO, part, CTLFLAG_RW, 0, "GEOM_PART stuff"); static u_int check_integrity = 1; +TUNABLE_INT("kern.geom.part.check_integrity", &check_integrity); SYSCTL_UINT(_kern_geom_part, OID_AUTO, check_integrity, - CTLFLAG_RWTUN, &check_integrity, 1, + CTLFLAG_RW | CTLFLAG_TUN, &check_integrity, 1, "Enable integrity checking"); /* diff --git a/sys/geom/part/g_part_ldm.c b/sys/geom/part/g_part_ldm.c index 82bf76dad5224..40c2eb877b07e 100644 --- a/sys/geom/part/g_part_ldm.c +++ b/sys/geom/part/g_part_ldm.c @@ -55,16 +55,18 @@ static SYSCTL_NODE(_kern_geom_part, OID_AUTO, ldm, CTLFLAG_RW, 0, "GEOM_PART_LDM Logical Disk Manager"); static u_int ldm_debug = 0; +TUNABLE_INT("kern.geom.part.ldm.debug", &ldm_debug); SYSCTL_UINT(_kern_geom_part_ldm, OID_AUTO, debug, - CTLFLAG_RWTUN, &ldm_debug, 0, "Debug level"); + CTLFLAG_RW | CTLFLAG_TUN, &ldm_debug, 0, "Debug level"); /* * This allows access to mirrored LDM volumes. Since we do not * doing mirroring here, it is not enabled by default. */ static u_int show_mirrors = 0; +TUNABLE_INT("kern.geom.part.ldm.show_mirrors", &show_mirrors); SYSCTL_UINT(_kern_geom_part_ldm, OID_AUTO, show_mirrors, - CTLFLAG_RWTUN, &show_mirrors, 0, "Show mirrored volumes"); + CTLFLAG_RW | CTLFLAG_TUN, &show_mirrors, 0, "Show mirrored volumes"); #define LDM_DEBUG(lvl, fmt, ...) do { \ if (ldm_debug >= (lvl)) { \ diff --git a/sys/geom/raid/g_raid.c b/sys/geom/raid/g_raid.c index db9cf445ecb2f..858cf4c75b271 100644 --- a/sys/geom/raid/g_raid.c +++ b/sys/geom/raid/g_raid.c @@ -53,38 +53,49 @@ static MALLOC_DEFINE(M_RAID, "raid_data", "GEOM_RAID Data"); SYSCTL_DECL(_kern_geom); SYSCTL_NODE(_kern_geom, OID_AUTO, raid, CTLFLAG_RW, 0, "GEOM_RAID stuff"); int g_raid_enable = 1; -SYSCTL_INT(_kern_geom_raid, OID_AUTO, enable, CTLFLAG_RWTUN, +TUNABLE_INT("kern.geom.raid.enable", &g_raid_enable); +SYSCTL_INT(_kern_geom_raid, OID_AUTO, enable, CTLFLAG_RW, &g_raid_enable, 0, "Enable on-disk metadata taste"); u_int g_raid_aggressive_spare = 0; -SYSCTL_UINT(_kern_geom_raid, OID_AUTO, aggressive_spare, CTLFLAG_RWTUN, +TUNABLE_INT("kern.geom.raid.aggressive_spare", &g_raid_aggressive_spare); +SYSCTL_UINT(_kern_geom_raid, OID_AUTO, aggressive_spare, CTLFLAG_RW, &g_raid_aggressive_spare, 0, "Use disks without metadata as spare"); u_int g_raid_debug = 0; -SYSCTL_UINT(_kern_geom_raid, OID_AUTO, debug, CTLFLAG_RWTUN, &g_raid_debug, 0, +TUNABLE_INT("kern.geom.raid.debug", &g_raid_debug); +SYSCTL_UINT(_kern_geom_raid, OID_AUTO, debug, CTLFLAG_RW, &g_raid_debug, 0, "Debug level"); int g_raid_read_err_thresh = 10; -SYSCTL_UINT(_kern_geom_raid, OID_AUTO, read_err_thresh, CTLFLAG_RWTUN, +TUNABLE_INT("kern.geom.raid.read_err_thresh", &g_raid_read_err_thresh); +SYSCTL_UINT(_kern_geom_raid, OID_AUTO, read_err_thresh, CTLFLAG_RW, &g_raid_read_err_thresh, 0, "Number of read errors equated to disk failure"); u_int g_raid_start_timeout = 30; -SYSCTL_UINT(_kern_geom_raid, OID_AUTO, start_timeout, CTLFLAG_RWTUN, +TUNABLE_INT("kern.geom.raid.start_timeout", &g_raid_start_timeout); +SYSCTL_UINT(_kern_geom_raid, OID_AUTO, start_timeout, CTLFLAG_RW, &g_raid_start_timeout, 0, "Time to wait for all array components"); static u_int g_raid_clean_time = 5; -SYSCTL_UINT(_kern_geom_raid, OID_AUTO, clean_time, CTLFLAG_RWTUN, +TUNABLE_INT("kern.geom.raid.clean_time", &g_raid_clean_time); +SYSCTL_UINT(_kern_geom_raid, OID_AUTO, clean_time, CTLFLAG_RW, &g_raid_clean_time, 0, "Mark volume as clean when idling"); static u_int g_raid_disconnect_on_failure = 1; -SYSCTL_UINT(_kern_geom_raid, OID_AUTO, disconnect_on_failure, CTLFLAG_RWTUN, +TUNABLE_INT("kern.geom.raid.disconnect_on_failure", + &g_raid_disconnect_on_failure); +SYSCTL_UINT(_kern_geom_raid, OID_AUTO, disconnect_on_failure, CTLFLAG_RW, &g_raid_disconnect_on_failure, 0, "Disconnect component on I/O failure."); static u_int g_raid_name_format = 0; -SYSCTL_UINT(_kern_geom_raid, OID_AUTO, name_format, CTLFLAG_RWTUN, +TUNABLE_INT("kern.geom.raid.name_format", &g_raid_name_format); +SYSCTL_UINT(_kern_geom_raid, OID_AUTO, name_format, CTLFLAG_RW, &g_raid_name_format, 0, "Providers name format."); static u_int g_raid_idle_threshold = 1000000; -SYSCTL_UINT(_kern_geom_raid, OID_AUTO, idle_threshold, CTLFLAG_RWTUN, +TUNABLE_INT("kern.geom.raid.idle_threshold", &g_raid_idle_threshold); +SYSCTL_UINT(_kern_geom_raid, OID_AUTO, idle_threshold, CTLFLAG_RW, &g_raid_idle_threshold, 1000000, "Time in microseconds to consider a volume idle."); static u_int ar_legacy_aliases = 1; -SYSCTL_INT(_kern_geom_raid, OID_AUTO, legacy_aliases, CTLFLAG_RWTUN, +SYSCTL_INT(_kern_geom_raid, OID_AUTO, legacy_aliases, CTLFLAG_RW, &ar_legacy_aliases, 0, "Create aliases named as the legacy ataraid style."); +TUNABLE_INT("kern.geom_raid.legacy_aliases", &ar_legacy_aliases); #define MSLEEP(rv, ident, mtx, priority, wmesg, timeout) do { \ diff --git a/sys/geom/raid/g_raid.h b/sys/geom/raid/g_raid.h index f6aa6dbb98d0b..8a96fa9f4698d 100644 --- a/sys/geom/raid/g_raid.h +++ b/sys/geom/raid/g_raid.h @@ -364,8 +364,10 @@ int g_raid_md_modevent(module_t, int, void *); SYSCTL_NODE(_kern_geom_raid, OID_AUTO, name, CTLFLAG_RD, \ NULL, label " metadata module"); \ SYSCTL_INT(_kern_geom_raid_##name, OID_AUTO, enable, \ - CTLFLAG_RWTUN, &g_raid_md_##name##_class.mdc_enable, 0, \ - "Enable " label " metadata format taste") + CTLFLAG_RW, &g_raid_md_##name##_class.mdc_enable, 0, \ + "Enable " label " metadata format taste"); \ + TUNABLE_INT("kern.geom.raid." __XSTRING(name) ".enable", \ + &g_raid_md_##name##_class.mdc_enable) /* * KOBJ parent class of data transformation modules. @@ -401,8 +403,10 @@ int g_raid_tr_modevent(module_t, int, void *); SYSCTL_NODE(_kern_geom_raid, OID_AUTO, name, CTLFLAG_RD, \ NULL, label " transformation module"); \ SYSCTL_INT(_kern_geom_raid_##name, OID_AUTO, enable, \ - CTLFLAG_RWTUN, &g_raid_tr_##name##_class.trc_enable, 0, \ - "Enable " label " transformation module taste") + CTLFLAG_RW, &g_raid_tr_##name##_class.trc_enable, 0, \ + "Enable " label " transformation module taste"); \ + TUNABLE_INT("kern.geom.raid." __XSTRING(name) ".enable", \ + &g_raid_tr_##name##_class.trc_enable) const char * g_raid_volume_level2str(int level, int qual); int g_raid_volume_str2level(const char *str, int *level, int *qual); diff --git a/sys/geom/raid/tr_raid1.c b/sys/geom/raid/tr_raid1.c index 17c7a25997445..833655bb854fc 100644 --- a/sys/geom/raid/tr_raid1.c +++ b/sys/geom/raid/tr_raid1.c @@ -46,25 +46,33 @@ SYSCTL_DECL(_kern_geom_raid_raid1); #define RAID1_REBUILD_SLAB (1 << 20) /* One transation in a rebuild */ static int g_raid1_rebuild_slab = RAID1_REBUILD_SLAB; -SYSCTL_UINT(_kern_geom_raid_raid1, OID_AUTO, rebuild_slab_size, CTLFLAG_RWTUN, +TUNABLE_INT("kern.geom.raid.raid1.rebuild_slab_size", + &g_raid1_rebuild_slab); +SYSCTL_UINT(_kern_geom_raid_raid1, OID_AUTO, rebuild_slab_size, CTLFLAG_RW, &g_raid1_rebuild_slab, 0, "Amount of the disk to rebuild each read/write cycle of the rebuild."); #define RAID1_REBUILD_FAIR_IO 20 /* use 1/x of the available I/O */ static int g_raid1_rebuild_fair_io = RAID1_REBUILD_FAIR_IO; -SYSCTL_UINT(_kern_geom_raid_raid1, OID_AUTO, rebuild_fair_io, CTLFLAG_RWTUN, +TUNABLE_INT("kern.geom.raid.raid1.rebuild_fair_io", + &g_raid1_rebuild_fair_io); +SYSCTL_UINT(_kern_geom_raid_raid1, OID_AUTO, rebuild_fair_io, CTLFLAG_RW, &g_raid1_rebuild_fair_io, 0, "Fraction of the I/O bandwidth to use when disk busy for rebuild."); #define RAID1_REBUILD_CLUSTER_IDLE 100 static int g_raid1_rebuild_cluster_idle = RAID1_REBUILD_CLUSTER_IDLE; -SYSCTL_UINT(_kern_geom_raid_raid1, OID_AUTO, rebuild_cluster_idle, CTLFLAG_RWTUN, +TUNABLE_INT("kern.geom.raid.raid1.rebuild_cluster_idle", + &g_raid1_rebuild_cluster_idle); +SYSCTL_UINT(_kern_geom_raid_raid1, OID_AUTO, rebuild_cluster_idle, CTLFLAG_RW, &g_raid1_rebuild_cluster_idle, 0, "Number of slabs to do each time we trigger a rebuild cycle"); #define RAID1_REBUILD_META_UPDATE 1024 /* update meta data every 1GB or so */ static int g_raid1_rebuild_meta_update = RAID1_REBUILD_META_UPDATE; -SYSCTL_UINT(_kern_geom_raid_raid1, OID_AUTO, rebuild_meta_update, CTLFLAG_RWTUN, +TUNABLE_INT("kern.geom.raid.raid1.rebuild_meta_update", + &g_raid1_rebuild_meta_update); +SYSCTL_UINT(_kern_geom_raid_raid1, OID_AUTO, rebuild_meta_update, CTLFLAG_RW, &g_raid1_rebuild_meta_update, 0, "When to update the meta data."); diff --git a/sys/geom/raid/tr_raid1e.c b/sys/geom/raid/tr_raid1e.c index b3577429daca6..404b9e6093443 100644 --- a/sys/geom/raid/tr_raid1e.c +++ b/sys/geom/raid/tr_raid1e.c @@ -48,25 +48,33 @@ SYSCTL_DECL(_kern_geom_raid_raid1e); #define RAID1E_REBUILD_SLAB (1 << 20) /* One transation in a rebuild */ static int g_raid1e_rebuild_slab = RAID1E_REBUILD_SLAB; -SYSCTL_UINT(_kern_geom_raid_raid1e, OID_AUTO, rebuild_slab_size, CTLFLAG_RWTUN, +TUNABLE_INT("kern.geom.raid.raid1e.rebuild_slab_size", + &g_raid1e_rebuild_slab); +SYSCTL_UINT(_kern_geom_raid_raid1e, OID_AUTO, rebuild_slab_size, CTLFLAG_RW, &g_raid1e_rebuild_slab, 0, "Amount of the disk to rebuild each read/write cycle of the rebuild."); #define RAID1E_REBUILD_FAIR_IO 20 /* use 1/x of the available I/O */ static int g_raid1e_rebuild_fair_io = RAID1E_REBUILD_FAIR_IO; -SYSCTL_UINT(_kern_geom_raid_raid1e, OID_AUTO, rebuild_fair_io, CTLFLAG_RWTUN, +TUNABLE_INT("kern.geom.raid.raid1e.rebuild_fair_io", + &g_raid1e_rebuild_fair_io); +SYSCTL_UINT(_kern_geom_raid_raid1e, OID_AUTO, rebuild_fair_io, CTLFLAG_RW, &g_raid1e_rebuild_fair_io, 0, "Fraction of the I/O bandwidth to use when disk busy for rebuild."); #define RAID1E_REBUILD_CLUSTER_IDLE 100 static int g_raid1e_rebuild_cluster_idle = RAID1E_REBUILD_CLUSTER_IDLE; -SYSCTL_UINT(_kern_geom_raid_raid1e, OID_AUTO, rebuild_cluster_idle, CTLFLAG_RWTUN, +TUNABLE_INT("kern.geom.raid.raid1e.rebuild_cluster_idle", + &g_raid1e_rebuild_cluster_idle); +SYSCTL_UINT(_kern_geom_raid_raid1e, OID_AUTO, rebuild_cluster_idle, CTLFLAG_RW, &g_raid1e_rebuild_cluster_idle, 0, "Number of slabs to do each time we trigger a rebuild cycle"); #define RAID1E_REBUILD_META_UPDATE 1024 /* update meta data every 1GB or so */ static int g_raid1e_rebuild_meta_update = RAID1E_REBUILD_META_UPDATE; -SYSCTL_UINT(_kern_geom_raid_raid1e, OID_AUTO, rebuild_meta_update, CTLFLAG_RWTUN, +TUNABLE_INT("kern.geom.raid.raid1e.rebuild_meta_update", + &g_raid1e_rebuild_meta_update); +SYSCTL_UINT(_kern_geom_raid_raid1e, OID_AUTO, rebuild_meta_update, CTLFLAG_RW, &g_raid1e_rebuild_meta_update, 0, "When to update the meta data."); diff --git a/sys/geom/raid3/g_raid3.c b/sys/geom/raid3/g_raid3.c index f935f788a937b..927cb3173e712 100644 --- a/sys/geom/raid3/g_raid3.c +++ b/sys/geom/raid3/g_raid3.c @@ -54,32 +54,42 @@ SYSCTL_DECL(_kern_geom); static SYSCTL_NODE(_kern_geom, OID_AUTO, raid3, CTLFLAG_RW, 0, "GEOM_RAID3 stuff"); u_int g_raid3_debug = 0; -SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, debug, CTLFLAG_RWTUN, &g_raid3_debug, 0, +TUNABLE_INT("kern.geom.raid3.debug", &g_raid3_debug); +SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, debug, CTLFLAG_RW, &g_raid3_debug, 0, "Debug level"); static u_int g_raid3_timeout = 4; -SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, timeout, CTLFLAG_RWTUN, &g_raid3_timeout, +TUNABLE_INT("kern.geom.raid3.timeout", &g_raid3_timeout); +SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, timeout, CTLFLAG_RW, &g_raid3_timeout, 0, "Time to wait on all raid3 components"); static u_int g_raid3_idletime = 5; -SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, idletime, CTLFLAG_RWTUN, +TUNABLE_INT("kern.geom.raid3.idletime", &g_raid3_idletime); +SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, idletime, CTLFLAG_RW, &g_raid3_idletime, 0, "Mark components as clean when idling"); static u_int g_raid3_disconnect_on_failure = 1; -SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, disconnect_on_failure, CTLFLAG_RWTUN, +TUNABLE_INT("kern.geom.raid3.disconnect_on_failure", + &g_raid3_disconnect_on_failure); +SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, disconnect_on_failure, CTLFLAG_RW, &g_raid3_disconnect_on_failure, 0, "Disconnect component on I/O failure."); static u_int g_raid3_syncreqs = 2; +TUNABLE_INT("kern.geom.raid3.sync_requests", &g_raid3_syncreqs); SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, sync_requests, CTLFLAG_RDTUN, &g_raid3_syncreqs, 0, "Parallel synchronization I/O requests."); static u_int g_raid3_use_malloc = 0; +TUNABLE_INT("kern.geom.raid3.use_malloc", &g_raid3_use_malloc); SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, use_malloc, CTLFLAG_RDTUN, &g_raid3_use_malloc, 0, "Use malloc(9) instead of uma(9)."); static u_int g_raid3_n64k = 50; -SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, n64k, CTLFLAG_RDTUN, &g_raid3_n64k, 0, +TUNABLE_INT("kern.geom.raid3.n64k", &g_raid3_n64k); +SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, n64k, CTLFLAG_RD, &g_raid3_n64k, 0, "Maximum number of 64kB allocations"); static u_int g_raid3_n16k = 200; -SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, n16k, CTLFLAG_RDTUN, &g_raid3_n16k, 0, +TUNABLE_INT("kern.geom.raid3.n16k", &g_raid3_n16k); +SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, n16k, CTLFLAG_RD, &g_raid3_n16k, 0, "Maximum number of 16kB allocations"); static u_int g_raid3_n4k = 1200; -SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, n4k, CTLFLAG_RDTUN, &g_raid3_n4k, 0, +TUNABLE_INT("kern.geom.raid3.n4k", &g_raid3_n4k); +SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, n4k, CTLFLAG_RD, &g_raid3_n4k, 0, "Maximum number of 4kB allocations"); static SYSCTL_NODE(_kern_geom_raid3, OID_AUTO, stat, CTLFLAG_RW, 0, diff --git a/sys/geom/shsec/g_shsec.c b/sys/geom/shsec/g_shsec.c index bfdc8fdc16720..9f8723f619c8a 100644 --- a/sys/geom/shsec/g_shsec.c +++ b/sys/geom/shsec/g_shsec.c @@ -71,10 +71,12 @@ SYSCTL_DECL(_kern_geom); static SYSCTL_NODE(_kern_geom, OID_AUTO, shsec, CTLFLAG_RW, 0, "GEOM_SHSEC stuff"); static u_int g_shsec_debug = 0; -SYSCTL_UINT(_kern_geom_shsec, OID_AUTO, debug, CTLFLAG_RWTUN, &g_shsec_debug, 0, +TUNABLE_INT("kern.geom.shsec.debug", &g_shsec_debug); +SYSCTL_UINT(_kern_geom_shsec, OID_AUTO, debug, CTLFLAG_RW, &g_shsec_debug, 0, "Debug level"); static u_int g_shsec_maxmem = MAXPHYS * 100; -SYSCTL_UINT(_kern_geom_shsec, OID_AUTO, maxmem, CTLFLAG_RDTUN, &g_shsec_maxmem, +TUNABLE_INT("kern.geom.shsec.maxmem", &g_shsec_maxmem); +SYSCTL_UINT(_kern_geom_shsec, OID_AUTO, maxmem, CTLFLAG_RD, &g_shsec_maxmem, 0, "Maximum memory that can be allocated for I/O (in bytes)"); static u_int g_shsec_alloc_failed = 0; SYSCTL_UINT(_kern_geom_shsec, OID_AUTO, alloc_failed, CTLFLAG_RD, diff --git a/sys/geom/stripe/g_stripe.c b/sys/geom/stripe/g_stripe.c index 1e88e6d606f06..474d888b4b679 100644 --- a/sys/geom/stripe/g_stripe.c +++ b/sys/geom/stripe/g_stripe.c @@ -71,9 +71,11 @@ SYSCTL_DECL(_kern_geom); static SYSCTL_NODE(_kern_geom, OID_AUTO, stripe, CTLFLAG_RW, 0, "GEOM_STRIPE stuff"); static u_int g_stripe_debug = 0; -SYSCTL_UINT(_kern_geom_stripe, OID_AUTO, debug, CTLFLAG_RWTUN, &g_stripe_debug, 0, +TUNABLE_INT("kern.geom.stripe.debug", &g_stripe_debug); +SYSCTL_UINT(_kern_geom_stripe, OID_AUTO, debug, CTLFLAG_RW, &g_stripe_debug, 0, "Debug level"); static int g_stripe_fast = 0; +TUNABLE_INT("kern.geom.stripe.fast", &g_stripe_fast); static int g_sysctl_stripe_fast(SYSCTL_HANDLER_ARGS) { @@ -85,10 +87,11 @@ g_sysctl_stripe_fast(SYSCTL_HANDLER_ARGS) g_stripe_fast = fast; return (error); } -SYSCTL_PROC(_kern_geom_stripe, OID_AUTO, fast, CTLTYPE_INT | CTLFLAG_RWTUN, +SYSCTL_PROC(_kern_geom_stripe, OID_AUTO, fast, CTLTYPE_INT | CTLFLAG_RW, NULL, 0, g_sysctl_stripe_fast, "I", "Fast, but memory-consuming, mode"); static u_int g_stripe_maxmem = MAXPHYS * 100; -SYSCTL_UINT(_kern_geom_stripe, OID_AUTO, maxmem, CTLFLAG_RDTUN, &g_stripe_maxmem, +TUNABLE_INT("kern.geom.stripe.maxmem", &g_stripe_maxmem); +SYSCTL_UINT(_kern_geom_stripe, OID_AUTO, maxmem, CTLFLAG_RD, &g_stripe_maxmem, 0, "Maximum memory that can be allocated in \"fast\" mode (in bytes)"); static u_int g_stripe_fast_failed = 0; SYSCTL_UINT(_kern_geom_stripe, OID_AUTO, fast_failed, CTLFLAG_RD, diff --git a/sys/geom/vinum/geom_vinum.c b/sys/geom/vinum/geom_vinum.c index 84d10a51fc868..15a62a1d1704d 100644 --- a/sys/geom/vinum/geom_vinum.c +++ b/sys/geom/vinum/geom_vinum.c @@ -50,7 +50,8 @@ SYSCTL_DECL(_kern_geom); static SYSCTL_NODE(_kern_geom, OID_AUTO, vinum, CTLFLAG_RW, 0, "GEOM_VINUM stuff"); u_int g_vinum_debug = 0; -SYSCTL_UINT(_kern_geom_vinum, OID_AUTO, debug, CTLFLAG_RWTUN, &g_vinum_debug, 0, +TUNABLE_INT("kern.geom.vinum.debug", &g_vinum_debug); +SYSCTL_UINT(_kern_geom_vinum, OID_AUTO, debug, CTLFLAG_RW, &g_vinum_debug, 0, "Debug level"); static int gv_create(struct g_geom *, struct gctl_req *); diff --git a/sys/geom/virstor/g_virstor.c b/sys/geom/virstor/g_virstor.c index a1774a9c4984e..40e25d15a1ec0 100644 --- a/sys/geom/virstor/g_virstor.c +++ b/sys/geom/virstor/g_virstor.c @@ -84,16 +84,20 @@ static SYSCTL_NODE(_kern_geom, OID_AUTO, virstor, CTLFLAG_RW, 0, "GEOM_GVIRSTOR information"); static u_int g_virstor_debug = 2; /* XXX: lower to 2 when released to public */ -SYSCTL_UINT(_kern_geom_virstor, OID_AUTO, debug, CTLFLAG_RWTUN, &g_virstor_debug, +TUNABLE_INT("kern.geom.virstor.debug", &g_virstor_debug); +SYSCTL_UINT(_kern_geom_virstor, OID_AUTO, debug, CTLFLAG_RW, &g_virstor_debug, 0, "Debug level (2=production, 5=normal, 15=excessive)"); static u_int g_virstor_chunk_watermark = 100; -SYSCTL_UINT(_kern_geom_virstor, OID_AUTO, chunk_watermark, CTLFLAG_RWTUN, +TUNABLE_INT("kern.geom.virstor.chunk_watermark", &g_virstor_chunk_watermark); +SYSCTL_UINT(_kern_geom_virstor, OID_AUTO, chunk_watermark, CTLFLAG_RW, &g_virstor_chunk_watermark, 0, "Minimum number of free chunks before issuing administrative warning"); static u_int g_virstor_component_watermark = 1; -SYSCTL_UINT(_kern_geom_virstor, OID_AUTO, component_watermark, CTLFLAG_RWTUN, +TUNABLE_INT("kern.geom.virstor.component_watermark", + &g_virstor_component_watermark); +SYSCTL_UINT(_kern_geom_virstor, OID_AUTO, component_watermark, CTLFLAG_RW, &g_virstor_component_watermark, 0, "Minimum number of free components before issuing administrative warning"); diff --git a/sys/i386/acpica/acpi_machdep.c b/sys/i386/acpica/acpi_machdep.c index 049354b0c2133..a244e7377c954 100644 --- a/sys/i386/acpica/acpi_machdep.c +++ b/sys/i386/acpica/acpi_machdep.c @@ -45,7 +45,8 @@ __FBSDID("$FreeBSD$"); #include uint32_t acpi_resume_beep; -SYSCTL_UINT(_debug_acpi, OID_AUTO, resume_beep, CTLFLAG_RWTUN, &acpi_resume_beep, +TUNABLE_INT("debug.acpi.resume_beep", &acpi_resume_beep); +SYSCTL_UINT(_debug_acpi, OID_AUTO, resume_beep, CTLFLAG_RW, &acpi_resume_beep, 0, "Beep the PC speaker when resuming"); uint32_t acpi_reset_video; diff --git a/sys/i386/bios/apm.c b/sys/i386/bios/apm.c index a4d3bd79ee39b..bf5071f0deddc 100644 --- a/sys/i386/bios/apm.c +++ b/sys/i386/bios/apm.c @@ -134,7 +134,8 @@ SYSCTL_INT(_machdep, OID_AUTO, apm_suspend_delay, CTLFLAG_RW, &apm_suspend_delay SYSCTL_INT(_machdep, OID_AUTO, apm_standby_delay, CTLFLAG_RW, &apm_standby_delay, 1, ""); SYSCTL_INT(_debug, OID_AUTO, apm_debug, CTLFLAG_RW, &apm_debug, 0, ""); -SYSCTL_INT(_machdep, OID_AUTO, apm_swab_batt_minutes, CTLFLAG_RWTUN, +TUNABLE_INT("machdep.apm_swab_batt_minutes", &apm_swab_batt_minutes); +SYSCTL_INT(_machdep, OID_AUTO, apm_swab_batt_minutes, CTLFLAG_RW, &apm_swab_batt_minutes, 0, "Byte swap battery time value."); #ifdef PC98 diff --git a/sys/i386/i386/i686_mem.c b/sys/i386/i386/i686_mem.c index 2721cfb35aaab..84db1ec0d02c9 100644 --- a/sys/i386/i386/i686_mem.c +++ b/sys/i386/i386/i686_mem.c @@ -65,6 +65,7 @@ static char *mem_owner_bios = "BIOS"; (((curr) & ~MDF_ATTRMASK) | ((new) & MDF_ATTRMASK)) static int mtrrs_disabled; +TUNABLE_INT("machdep.disable_mtrrs", &mtrrs_disabled); SYSCTL_INT(_machdep, OID_AUTO, disable_mtrrs, CTLFLAG_RDTUN, &mtrrs_disabled, 0, "Disable i686 MTRRs."); diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index ac41c2796237f..3d92e6e56f4b3 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -1231,7 +1231,8 @@ cpu_halt(void) void (*cpu_idle_hook)(sbintime_t) = NULL; /* ACPI idle hook. */ static int cpu_ident_amdc1e = 0; /* AMD C1E supported. */ static int idle_mwait = 1; /* Use MONITOR/MWAIT for short idle. */ -SYSCTL_INT(_machdep, OID_AUTO, idle_mwait, CTLFLAG_RWTUN, &idle_mwait, +TUNABLE_INT("machdep.idle_mwait", &idle_mwait); +SYSCTL_INT(_machdep, OID_AUTO, idle_mwait, CTLFLAG_RW, &idle_mwait, 0, "Use MONITOR/MWAIT for short idle"); #define STATE_RUNNING 0x0 diff --git a/sys/i386/i386/mp_watchdog.c b/sys/i386/i386/mp_watchdog.c index b03d2614d9b54..b1799a20b3db5 100644 --- a/sys/i386/i386/mp_watchdog.c +++ b/sys/i386/i386/mp_watchdog.c @@ -68,7 +68,8 @@ static int watchdog_dontfire = 1; static int watchdog_timer = -1; static int watchdog_nmi = 1; -SYSCTL_INT(_debug, OID_AUTO, watchdog_nmi, CTLFLAG_RWTUN, &watchdog_nmi, 0, +TUNABLE_INT("debug.watchdog", &watchdog_cpu); +SYSCTL_INT(_debug, OID_AUTO, watchdog_nmi, CTLFLAG_RW, &watchdog_nmi, 0, "IPI the boot processor with an NMI to enter the debugger"); static struct callout watchdog_callout; diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c index 3085157dbb95a..af8c9ff0f983d 100644 --- a/sys/i386/i386/pmap.c +++ b/sys/i386/i386/pmap.c @@ -225,8 +225,8 @@ SYSCTL_INT(_vm_pmap, OID_AUTO, pat_works, CTLFLAG_RD, &pat_works, 1, "Is page attribute table fully functional?"); static int pg_ps_enabled = 1; -SYSCTL_INT(_vm_pmap, OID_AUTO, pg_ps_enabled, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, - &pg_ps_enabled, 0, "Are large page mappings enabled?"); +SYSCTL_INT(_vm_pmap, OID_AUTO, pg_ps_enabled, CTLFLAG_RDTUN, &pg_ps_enabled, 0, + "Are large page mappings enabled?"); #define PAT_INDEX_SIZE 8 static int pat_index[PAT_INDEX_SIZE]; /* cache mode to PAT index conversion */ diff --git a/sys/i386/i386/trap.c b/sys/i386/i386/trap.c index 6e4aba2a21331..97254f25bde41 100644 --- a/sys/i386/i386/trap.c +++ b/sys/i386/i386/trap.c @@ -158,12 +158,14 @@ extern int has_f00f_bug; #ifdef KDB static int kdb_on_nmi = 1; -SYSCTL_INT(_machdep, OID_AUTO, kdb_on_nmi, CTLFLAG_RWTUN, +SYSCTL_INT(_machdep, OID_AUTO, kdb_on_nmi, CTLFLAG_RW, &kdb_on_nmi, 0, "Go to KDB on NMI"); +TUNABLE_INT("machdep.kdb_on_nmi", &kdb_on_nmi); #endif static int panic_on_nmi = 1; -SYSCTL_INT(_machdep, OID_AUTO, panic_on_nmi, CTLFLAG_RWTUN, +SYSCTL_INT(_machdep, OID_AUTO, panic_on_nmi, CTLFLAG_RW, &panic_on_nmi, 0, "Panic on NMI"); +TUNABLE_INT("machdep.panic_on_nmi", &panic_on_nmi); static int prot_fault_translation = 0; SYSCTL_INT(_machdep, OID_AUTO, prot_fault_translation, CTLFLAG_RW, &prot_fault_translation, 0, "Select signal to deliver on protection fault"); diff --git a/sys/i386/pci/pci_cfgreg.c b/sys/i386/pci/pci_cfgreg.c index 5d57e89334a18..cce4981d9c9d5 100644 --- a/sys/i386/pci/pci_cfgreg.c +++ b/sys/i386/pci/pci_cfgreg.c @@ -86,6 +86,7 @@ static int cfgmech; static int devmax; static struct mtx pcicfg_mtx; static int mcfg_enable = 1; +TUNABLE_INT("hw.pci.mcfg", &mcfg_enable); SYSCTL_INT(_hw_pci, OID_AUTO, mcfg, CTLFLAG_RDTUN, &mcfg_enable, 0, "Enable support for PCI-e memory mapped config access"); diff --git a/sys/i386/pci/pci_pir.c b/sys/i386/pci/pci_pir.c index 0d64cabf4aab2..c275de094f5cf 100644 --- a/sys/i386/pci/pci_pir.c +++ b/sys/i386/pci/pci_pir.c @@ -117,6 +117,7 @@ SYSCTL_DECL(_hw_pci); #endif static uint32_t pci_irq_override_mask = PCI_IRQ_OVERRIDE_MASK; +TUNABLE_INT("hw.pci.irq_override_mask", &pci_irq_override_mask); SYSCTL_INT(_hw_pci, OID_AUTO, irq_override_mask, CTLFLAG_RDTUN, &pci_irq_override_mask, PCI_IRQ_OVERRIDE_MASK, "Mask of allowed irqs to try to route when it has no good clue about\n" diff --git a/sys/ia64/ia64/dump_machdep.c b/sys/ia64/ia64/dump_machdep.c index d6d9d0487a49d..9a058bb1f4baf 100644 --- a/sys/ia64/ia64/dump_machdep.c +++ b/sys/ia64/ia64/dump_machdep.c @@ -57,7 +57,8 @@ CTASSERT(sizeof(struct kerneldumpheader) == 512); #define DEV_ALIGN(x) (((off_t)(x) + (DEV_BSIZE-1)) & ~(DEV_BSIZE-1)) static int minidump = 0; -SYSCTL_INT(_debug, OID_AUTO, minidump, CTLFLAG_RWTUN, &minidump, 0, +TUNABLE_INT("debug.minidump", &minidump); +SYSCTL_INT(_debug, OID_AUTO, minidump, CTLFLAG_RW, &minidump, 0, "Enable mini crash dumps"); static struct kerneldumpheader kdh; diff --git a/sys/ia64/ia64/pmap.c b/sys/ia64/ia64/pmap.c index 1ed35c3ffcb21..9f642970fcb9a 100644 --- a/sys/ia64/ia64/pmap.c +++ b/sys/ia64/ia64/pmap.c @@ -240,8 +240,9 @@ int pmap_vhpt_nbuckets; SYSCTL_INT(_machdep_vhpt, OID_AUTO, nbuckets, CTLFLAG_RD, &pmap_vhpt_nbuckets, 0, ""); -int pmap_vhpt_log2size; -SYSCTL_INT(_machdep_vhpt, OID_AUTO, log2size, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, +int pmap_vhpt_log2size = 0; +TUNABLE_INT("machdep.vhpt.log2size", &pmap_vhpt_log2size); +SYSCTL_INT(_machdep_vhpt, OID_AUTO, log2size, CTLFLAG_RD, &pmap_vhpt_log2size, 0, ""); static int pmap_vhpt_inserts; diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index b085a708b57f5..591094e5af968 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -112,8 +112,10 @@ static int compress_core(gzFile, char *, char *, unsigned int, int __elfN(fallback_brand) = -1; SYSCTL_INT(__CONCAT(_kern_elf, __ELF_WORD_SIZE), OID_AUTO, - fallback_brand, CTLFLAG_RWTUN, &__elfN(fallback_brand), 0, + fallback_brand, CTLFLAG_RW, &__elfN(fallback_brand), 0, __XSTRING(__CONCAT(ELF, __ELF_WORD_SIZE)) " brand of last resort"); +TUNABLE_INT("kern.elf" __XSTRING(__ELF_WORD_SIZE) ".fallback_brand", + &__elfN(fallback_brand)); static int elf_legacy_coredump = 0; SYSCTL_INT(_debug, OID_AUTO, __elfN(legacy_coredump), CTLFLAG_RW, diff --git a/sys/kern/kern_clocksource.c b/sys/kern/kern_clocksource.c index 092c81807b173..ae64c616c1f66 100644 --- a/sys/kern/kern_clocksource.c +++ b/sys/kern/kern_clocksource.c @@ -96,21 +96,23 @@ static sbintime_t statperiod; /* statclock() events period. */ static sbintime_t profperiod; /* profclock() events period. */ static sbintime_t nexttick; /* Next global timer tick time. */ static u_int busy = 1; /* Reconfiguration is in progress. */ -static int profiling; /* Profiling events enabled. */ +static int profiling = 0; /* Profiling events enabled. */ static char timername[32]; /* Wanted timer. */ TUNABLE_STR("kern.eventtimer.timer", timername, sizeof(timername)); -static int singlemul; /* Multiplier for periodic mode. */ -SYSCTL_INT(_kern_eventtimer, OID_AUTO, singlemul, CTLFLAG_RWTUN, &singlemul, +static int singlemul = 0; /* Multiplier for periodic mode. */ +TUNABLE_INT("kern.eventtimer.singlemul", &singlemul); +SYSCTL_INT(_kern_eventtimer, OID_AUTO, singlemul, CTLFLAG_RW, &singlemul, 0, "Multiplier for periodic mode"); -static u_int idletick; /* Run periodic events when idle. */ -SYSCTL_UINT(_kern_eventtimer, OID_AUTO, idletick, CTLFLAG_RWTUN, &idletick, +static u_int idletick = 0; /* Run periodic events when idle. */ +TUNABLE_INT("kern.eventtimer.idletick", &idletick); +SYSCTL_UINT(_kern_eventtimer, OID_AUTO, idletick, CTLFLAG_RW, &idletick, 0, "Run periodic events when idle"); -static int periodic; /* Periodic or one-shot mode. */ -static int want_periodic; /* What mode to prefer. */ +static int periodic = 0; /* Periodic or one-shot mode. */ +static int want_periodic = 0; /* What mode to prefer. */ TUNABLE_INT("kern.eventtimer.periodic", &want_periodic); struct pcpu_state { diff --git a/sys/kern/kern_cons.c b/sys/kern/kern_cons.c index 1d5ac0e38a699..8d23befd05779 100644 --- a/sys/kern/kern_cons.c +++ b/sys/kern/kern_cons.c @@ -652,9 +652,9 @@ sysbeep(int pitch __unused, int period __unused) /* * Temporary support for sc(4) to vt(4) transition. */ -static char vty_name[16]; -SYSCTL_STRING(_kern, OID_AUTO, vty, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, vty_name, - 0, "Console vty driver"); +static char vty_name[16] = ""; +SYSCTL_STRING(_kern, OID_AUTO, vty, CTLFLAG_RDTUN, vty_name, 0, + "Console vty driver"); int vty_enabled(unsigned vty) diff --git a/sys/kern/kern_cpu.c b/sys/kern/kern_cpu.c index 293b940683ba5..7206c388f76a8 100644 --- a/sys/kern/kern_cpu.c +++ b/sys/kern/kern_cpu.c @@ -133,11 +133,13 @@ DRIVER_MODULE(cpufreq, cpu, cpufreq_driver, cpufreq_dc, 0, 0); static int cf_lowest_freq; static int cf_verbose; +TUNABLE_INT("debug.cpufreq.lowest", &cf_lowest_freq); +TUNABLE_INT("debug.cpufreq.verbose", &cf_verbose); static SYSCTL_NODE(_debug, OID_AUTO, cpufreq, CTLFLAG_RD, NULL, "cpufreq debugging"); -SYSCTL_INT(_debug_cpufreq, OID_AUTO, lowest, CTLFLAG_RWTUN, &cf_lowest_freq, 1, +SYSCTL_INT(_debug_cpufreq, OID_AUTO, lowest, CTLFLAG_RW, &cf_lowest_freq, 1, "Don't provide levels below this frequency."); -SYSCTL_INT(_debug_cpufreq, OID_AUTO, verbose, CTLFLAG_RWTUN, &cf_verbose, 1, +SYSCTL_INT(_debug_cpufreq, OID_AUTO, verbose, CTLFLAG_RW, &cf_verbose, 1, "Print verbose debugging messages"); static int diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 7d3bad9d50c43..078cd383bae0d 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -127,7 +127,8 @@ SYSCTL_INT(_kern, OID_AUTO, disallow_high_osrel, CTLFLAG_RW, "Disallow execution of binaries built for higher version of the world"); static int map_at_zero = 0; -SYSCTL_INT(_security_bsd, OID_AUTO, map_at_zero, CTLFLAG_RWTUN, &map_at_zero, 0, +TUNABLE_INT("security.bsd.map_at_zero", &map_at_zero); +SYSCTL_INT(_security_bsd, OID_AUTO, map_at_zero, CTLFLAG_RW, &map_at_zero, 0, "Permit processes to map an object at virtual address 0."); static int diff --git a/sys/kern/kern_intr.c b/sys/kern/kern_intr.c index 25032f278c1d7..5555d6858f9ac 100644 --- a/sys/kern/kern_intr.c +++ b/sys/kern/kern_intr.c @@ -89,7 +89,8 @@ struct proc *intrproc; static MALLOC_DEFINE(M_ITHREAD, "ithread", "Interrupt Threads"); static int intr_storm_threshold = 1000; -SYSCTL_INT(_hw, OID_AUTO, intr_storm_threshold, CTLFLAG_RWTUN, +TUNABLE_INT("hw.intr_storm_threshold", &intr_storm_threshold); +SYSCTL_INT(_hw, OID_AUTO, intr_storm_threshold, CTLFLAG_RW, &intr_storm_threshold, 0, "Number of consecutive interrupts before storm protection is enabled"); static TAILQ_HEAD(, intr_event) event_list = diff --git a/sys/kern/kern_ktr.c b/sys/kern/kern_ktr.c index c377f36e09a74..e302ae228d458 100644 --- a/sys/kern/kern_ktr.c +++ b/sys/kern/kern_ktr.c @@ -104,10 +104,11 @@ struct ktr_entry *ktr_buf = ktr_buf_init; cpuset_t ktr_cpumask = CPUSET_T_INITIALIZER(KTR_CPUMASK); static char ktr_cpumask_str[CPUSETBUFSIZ]; -static SYSCTL_NODE(_debug, OID_AUTO, ktr, CTLFLAG_RD, 0, "KTR options"); +TUNABLE_INT("debug.ktr.mask", &ktr_mask); + +TUNABLE_STR("debug.ktr.cpumask", ktr_cpumask_str, sizeof(ktr_cpumask_str)); -SYSCTL_INT(_debug_ktr, OID_AUTO, mask, CTLFLAG_RDTUN, - &ktr_mask, 0, "KTR mask"); +static SYSCTL_NODE(_debug, OID_AUTO, ktr, CTLFLAG_RD, 0, "KTR options"); SYSCTL_INT(_debug_ktr, OID_AUTO, version, CTLFLAG_RD, &ktr_version, 0, "Version of the KTR interface"); @@ -115,6 +116,21 @@ SYSCTL_INT(_debug_ktr, OID_AUTO, version, CTLFLAG_RD, SYSCTL_UINT(_debug_ktr, OID_AUTO, compile, CTLFLAG_RD, &ktr_compile, 0, "Bitmask of KTR event classes compiled into the kernel"); +static void +ktr_cpumask_initializer(void *dummy __unused) +{ + + /* + * TUNABLE_STR() runs with SI_ORDER_MIDDLE priority, thus it must be + * already set, if necessary. + */ + if (ktr_cpumask_str[0] != '\0' && + cpusetobj_strscan(&ktr_cpumask, ktr_cpumask_str) == -1) + CPU_FILL(&ktr_cpumask); +} +SYSINIT(ktr_cpumask_initializer, SI_SUB_TUNABLES, SI_ORDER_ANY, + ktr_cpumask_initializer, NULL); + static int sysctl_debug_ktr_cpumask(SYSCTL_HANDLER_ARGS) { @@ -134,7 +150,7 @@ sysctl_debug_ktr_cpumask(SYSCTL_HANDLER_ARGS) return (error); } SYSCTL_PROC(_debug_ktr, OID_AUTO, cpumask, - CTLFLAG_RWTUN | CTLFLAG_MPSAFE | CTLTYPE_STRING, NULL, 0, + CTLFLAG_RW | CTLFLAG_MPSAFE | CTLTYPE_STRING, NULL, 0, sysctl_debug_ktr_cpumask, "S", "Bitmask of CPUs on which KTR logging is enabled"); diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c index 367610b34a3a5..b74d48ecffb8f 100644 --- a/sys/kern/kern_ktrace.c +++ b/sys/kern/kern_ktrace.c @@ -133,7 +133,8 @@ static u_int ktr_requestpool = KTRACE_REQUEST_POOL; TUNABLE_INT("kern.ktrace.request_pool", &ktr_requestpool); static u_int ktr_geniosize = PAGE_SIZE; -SYSCTL_UINT(_kern_ktrace, OID_AUTO, genio_size, CTLFLAG_RWTUN, &ktr_geniosize, +TUNABLE_INT("kern.ktrace.genio_size", &ktr_geniosize); +SYSCTL_UINT(_kern_ktrace, OID_AUTO, genio_size, CTLFLAG_RW, &ktr_geniosize, 0, "Maximum size of genio event payload"); static int print_message = 1; diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c index dbc0fb30974d8..e379f5f89f959 100644 --- a/sys/kern/kern_linker.c +++ b/sys/kern/kern_linker.c @@ -66,8 +66,9 @@ __FBSDID("$FreeBSD$"); #ifdef KLD_DEBUG int kld_debug = 0; -SYSCTL_INT(_debug, OID_AUTO, kld_debug, CTLFLAG_RWTUN, +SYSCTL_INT(_debug, OID_AUTO, kld_debug, CTLFLAG_RW | CTLFLAG_TUN, &kld_debug, 0, "Set various levels of KLD debug"); +TUNABLE_INT("debug.kld_debug", &kld_debug); #endif /* @@ -1642,7 +1643,7 @@ SYSINIT(preload, SI_SUB_KLD, SI_ORDER_MIDDLE, linker_preload, 0); static char linker_hintfile[] = "linker.hints"; static char linker_path[MAXPATHLEN] = "/boot/kernel;/boot/modules"; -SYSCTL_STRING(_kern, OID_AUTO, module_path, CTLFLAG_RWTUN, linker_path, +SYSCTL_STRING(_kern, OID_AUTO, module_path, CTLFLAG_RW, linker_path, sizeof(linker_path), "module load search path"); TUNABLE_STR("module_path", linker_path, sizeof(linker_path)); diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c index f16d4d5008199..658908c65634b 100644 --- a/sys/kern/kern_malloc.c +++ b/sys/kern/kern_malloc.c @@ -191,7 +191,7 @@ static u_long vm_kmem_size_max; SYSCTL_ULONG(_vm, OID_AUTO, kmem_size_max, CTLFLAG_RDTUN, &vm_kmem_size_max, 0, "Maximum size of kernel memory"); -static u_int vm_kmem_size_scale = VM_KMEM_SIZE_SCALE; +static u_int vm_kmem_size_scale; SYSCTL_UINT(_vm, OID_AUTO, kmem_size_scale, CTLFLAG_RDTUN, &vm_kmem_size_scale, 0, "Scale factor for kernel memory size"); @@ -236,8 +236,9 @@ static SYSCTL_NODE(_debug, OID_AUTO, malloc, CTLFLAG_RD, 0, static int malloc_failure_rate; static int malloc_nowait_count; static int malloc_failure_count; -SYSCTL_INT(_debug_malloc, OID_AUTO, failure_rate, CTLFLAG_RWTUN, +SYSCTL_INT(_debug_malloc, OID_AUTO, failure_rate, CTLFLAG_RW, &malloc_failure_rate, 0, "Every (n) mallocs with M_NOWAIT will fail"); +TUNABLE_INT("debug.malloc.failure_rate", &malloc_failure_rate); SYSCTL_INT(_debug_malloc, OID_AUTO, failure_count, CTLFLAG_RD, &malloc_failure_count, 0, "Number of imposed M_NOWAIT malloc failures"); #endif @@ -279,7 +280,7 @@ tunable_set_numzones(void) numzones = MALLOC_DEBUG_MAXZONES; } SYSINIT(numzones, SI_SUB_TUNABLES, SI_ORDER_ANY, tunable_set_numzones, NULL); -SYSCTL_INT(_debug_malloc, OID_AUTO, numzones, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, +SYSCTL_INT(_debug_malloc, OID_AUTO, numzones, CTLFLAG_RDTUN, &numzones, 0, "Number of malloc uma subzones"); /* @@ -692,21 +693,8 @@ CTASSERT(VM_KMEM_SIZE_SCALE >= 1); void kmeminit(void) { - u_long mem_size; - u_long tmp; + u_long mem_size, tmp; -#ifdef VM_KMEM_SIZE - if (vm_kmem_size == 0) - vm_kmem_size = VM_KMEM_SIZE; -#endif -#ifdef VM_KMEM_SIZE_MIN - if (vm_kmem_size_min == 0) - vm_kmem_size_min = VM_KMEM_SIZE_MIN; -#endif -#ifdef VM_KMEM_SIZE_MAX - if (vm_kmem_size_max == 0) - vm_kmem_size_max = VM_KMEM_SIZE_MAX; -#endif /* * Calculate the amount of kernel virtual address (KVA) space that is * preallocated to the kmem arena. In order to support a wide range @@ -725,29 +713,38 @@ kmeminit(void) */ mem_size = vm_cnt.v_page_count; + vm_kmem_size_scale = VM_KMEM_SIZE_SCALE; + TUNABLE_INT_FETCH("vm.kmem_size_scale", &vm_kmem_size_scale); if (vm_kmem_size_scale < 1) vm_kmem_size_scale = VM_KMEM_SIZE_SCALE; - /* - * Check if we should use defaults for the "vm_kmem_size" - * variable: - */ - if (vm_kmem_size == 0) { - vm_kmem_size = (mem_size / vm_kmem_size_scale) * PAGE_SIZE; + vm_kmem_size = (mem_size / vm_kmem_size_scale) * PAGE_SIZE; - if (vm_kmem_size_min > 0 && vm_kmem_size < vm_kmem_size_min) - vm_kmem_size = vm_kmem_size_min; - if (vm_kmem_size_max > 0 && vm_kmem_size >= vm_kmem_size_max) - vm_kmem_size = vm_kmem_size_max; - } +#if defined(VM_KMEM_SIZE_MIN) + vm_kmem_size_min = VM_KMEM_SIZE_MIN; +#endif + TUNABLE_ULONG_FETCH("vm.kmem_size_min", &vm_kmem_size_min); + if (vm_kmem_size_min > 0 && vm_kmem_size < vm_kmem_size_min) + vm_kmem_size = vm_kmem_size_min; + +#if defined(VM_KMEM_SIZE_MAX) + vm_kmem_size_max = VM_KMEM_SIZE_MAX; +#endif + TUNABLE_ULONG_FETCH("vm.kmem_size_max", &vm_kmem_size_max); + if (vm_kmem_size_max > 0 && vm_kmem_size >= vm_kmem_size_max) + vm_kmem_size = vm_kmem_size_max; /* - * The amount of KVA space that is preallocated to the + * Alternatively, the amount of KVA space that is preallocated to the * kmem arena can be set statically at compile-time or manually * through the kernel environment. However, it is still limited to * twice the physical memory size, which has been sufficient to handle * the most severe cases of external fragmentation in the kmem arena. */ +#if defined(VM_KMEM_SIZE) + vm_kmem_size = VM_KMEM_SIZE; +#endif + TUNABLE_ULONG_FETCH("vm.kmem_size", &vm_kmem_size); if (vm_kmem_size / 2 / PAGE_SIZE > mem_size) vm_kmem_size = 2 * mem_size * PAGE_SIZE; @@ -814,7 +811,7 @@ mallocinit(void *dummy) } } -SYSINIT(kmem, SI_SUB_KMEM, SI_ORDER_SECOND, mallocinit, NULL); +SYSINIT(kmem, SI_SUB_KMEM, SI_ORDER_FIRST, mallocinit, NULL); void malloc_init(void *data) diff --git a/sys/kern/kern_mbuf.c b/sys/kern/kern_mbuf.c index 63d5d5523368b..119e4b8325253 100644 --- a/sys/kern/kern_mbuf.c +++ b/sys/kern/kern_mbuf.c @@ -105,7 +105,7 @@ int nmbjumbo16; /* limits number of 16k jumbo clusters */ static quad_t maxmbufmem; /* overall real memory limit for all mbufs */ -SYSCTL_QUAD(_kern_ipc, OID_AUTO, maxmbufmem, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &maxmbufmem, 0, +SYSCTL_QUAD(_kern_ipc, OID_AUTO, maxmbufmem, CTLFLAG_RDTUN, &maxmbufmem, 0, "Maximum real memory allocatable to various mbuf types"); /* diff --git a/sys/kern/kern_mib.c b/sys/kern/kern_mib.c index 9d3153b4a5bbf..213482b42c913 100644 --- a/sys/kern/kern_mib.c +++ b/sys/kern/kern_mib.c @@ -55,35 +55,35 @@ __FBSDID("$FreeBSD$"); #include #include -SYSCTL_ROOT_NODE(0, sysctl, CTLFLAG_RW, 0, +SYSCTL_NODE(, 0, sysctl, CTLFLAG_RW, 0, "Sysctl internal magic"); -SYSCTL_ROOT_NODE(CTL_KERN, kern, CTLFLAG_RW|CTLFLAG_CAPRD, 0, +SYSCTL_NODE(, CTL_KERN, kern, CTLFLAG_RW|CTLFLAG_CAPRD, 0, "High kernel, proc, limits &c"); -SYSCTL_ROOT_NODE(CTL_VM, vm, CTLFLAG_RW, 0, +SYSCTL_NODE(, CTL_VM, vm, CTLFLAG_RW, 0, "Virtual memory"); -SYSCTL_ROOT_NODE(CTL_VFS, vfs, CTLFLAG_RW, 0, +SYSCTL_NODE(, CTL_VFS, vfs, CTLFLAG_RW, 0, "File system"); -SYSCTL_ROOT_NODE(CTL_NET, net, CTLFLAG_RW, 0, +SYSCTL_NODE(, CTL_NET, net, CTLFLAG_RW, 0, "Network, (see socket.h)"); -SYSCTL_ROOT_NODE(CTL_DEBUG, debug, CTLFLAG_RW, 0, +SYSCTL_NODE(, CTL_DEBUG, debug, CTLFLAG_RW, 0, "Debugging"); SYSCTL_NODE(_debug, OID_AUTO, sizeof, CTLFLAG_RW, 0, "Sizeof various things"); -SYSCTL_ROOT_NODE(CTL_HW, hw, CTLFLAG_RW, 0, +SYSCTL_NODE(, CTL_HW, hw, CTLFLAG_RW, 0, "hardware"); -SYSCTL_ROOT_NODE(CTL_MACHDEP, machdep, CTLFLAG_RW, 0, +SYSCTL_NODE(, CTL_MACHDEP, machdep, CTLFLAG_RW, 0, "machine dependent"); -SYSCTL_ROOT_NODE(CTL_USER, user, CTLFLAG_RW, 0, +SYSCTL_NODE(, CTL_USER, user, CTLFLAG_RW, 0, "user-level"); -SYSCTL_ROOT_NODE(CTL_P1003_1B, p1003_1b, CTLFLAG_RW, 0, +SYSCTL_NODE(, CTL_P1003_1B, p1003_1b, CTLFLAG_RW, 0, "p1003_1b, (see p1003_1b.h)"); -SYSCTL_ROOT_NODE(OID_AUTO, compat, CTLFLAG_RW, 0, +SYSCTL_NODE(, OID_AUTO, compat, CTLFLAG_RW, 0, "Compatibility code"); -SYSCTL_ROOT_NODE(OID_AUTO, security, CTLFLAG_RW, 0, +SYSCTL_NODE(, OID_AUTO, security, CTLFLAG_RW, 0, "Security"); #ifdef REGRESSION -SYSCTL_ROOT_NODE(OID_AUTO, regression, CTLFLAG_RW, 0, +SYSCTL_NODE(, OID_AUTO, regression, CTLFLAG_RW, 0, "Regression test MIB"); #endif @@ -112,13 +112,13 @@ SYSCTL_STRING(_kern, KERN_OSTYPE, ostype, CTLFLAG_RD|CTLFLAG_MPSAFE| SYSCTL_INT(_kern, KERN_OSRELDATE, osreldate, CTLFLAG_RD|CTLFLAG_CAPRD, &osreldate, 0, "Kernel release date"); -SYSCTL_INT(_kern, KERN_MAXPROC, maxproc, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, +SYSCTL_INT(_kern, KERN_MAXPROC, maxproc, CTLFLAG_RDTUN, &maxproc, 0, "Maximum number of processes"); SYSCTL_INT(_kern, KERN_MAXPROCPERUID, maxprocperuid, CTLFLAG_RW, &maxprocperuid, 0, "Maximum processes allowed per userid"); -SYSCTL_INT(_kern, OID_AUTO, maxusers, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, +SYSCTL_INT(_kern, OID_AUTO, maxusers, CTLFLAG_RDTUN, &maxusers, 0, "Hint for kernel tuning"); SYSCTL_INT(_kern, KERN_ARGMAX, argmax, CTLFLAG_RD|CTLFLAG_CAPRD, @@ -127,8 +127,8 @@ SYSCTL_INT(_kern, KERN_ARGMAX, argmax, CTLFLAG_RD|CTLFLAG_CAPRD, SYSCTL_INT(_kern, KERN_POSIX1, posix1version, CTLFLAG_RD|CTLFLAG_CAPRD, 0, _POSIX_VERSION, "Version of POSIX attempting to comply to"); -SYSCTL_INT(_kern, KERN_NGROUPS, ngroups, CTLFLAG_RDTUN | - CTLFLAG_NOFETCH | CTLFLAG_CAPRD, &ngroups_max, 0, +SYSCTL_INT(_kern, KERN_NGROUPS, ngroups, CTLFLAG_RDTUN|CTLFLAG_CAPRD, + &ngroups_max, 0, "Maximum number of supplemental groups a user can belong to"); SYSCTL_INT(_kern, KERN_JOB_CONTROL, job_control, CTLFLAG_RD|CTLFLAG_CAPRD, @@ -526,9 +526,9 @@ sysctl_kern_pid_max(SYSCTL_HANDLER_ARGS) sx_xunlock(&proctree_lock); return (error); } -SYSCTL_PROC(_kern, OID_AUTO, pid_max, CTLTYPE_INT | - CTLFLAG_RWTUN | CTLFLAG_NOFETCH | CTLFLAG_MPSAFE, - 0, 0, sysctl_kern_pid_max, "I", "Maximum allowed pid"); +SYSCTL_PROC(_kern, OID_AUTO, pid_max, CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_TUN | + CTLFLAG_MPSAFE, 0, 0, sysctl_kern_pid_max, "I", + "Maximum allowed pid"); #include #include diff --git a/sys/kern/kern_ntptime.c b/sys/kern/kern_ntptime.c index 638cd53332aa6..7c95575293d4b 100644 --- a/sys/kern/kern_ntptime.c +++ b/sys/kern/kern_ntptime.c @@ -1025,20 +1025,18 @@ sysctl_resettodr_period(SYSCTL_HANDLER_ARGS) error = sysctl_handle_int(oidp, oidp->oid_arg1, oidp->oid_arg2, req); if (error || !req->newptr) return (error); - if (cold) - goto done; if (resettodr_period == 0) callout_stop(&resettodr_callout); else callout_reset(&resettodr_callout, resettodr_period * hz, periodic_resettodr, NULL); -done: return (0); } -SYSCTL_PROC(_machdep, OID_AUTO, rtc_save_period, CTLTYPE_INT|CTLFLAG_RWTUN, +SYSCTL_PROC(_machdep, OID_AUTO, rtc_save_period, CTLTYPE_INT|CTLFLAG_RW, &resettodr_period, 1800, sysctl_resettodr_period, "I", "Save system time to RTC with this period (in seconds)"); +TUNABLE_INT("machdep.rtc_save_period", &resettodr_period); static void start_periodic_resettodr(void *arg __unused) diff --git a/sys/kern/kern_osd.c b/sys/kern/kern_osd.c index cc9bed1fab3dd..184c4f00ba08f 100644 --- a/sys/kern/kern_osd.c +++ b/sys/kern/kern_osd.c @@ -47,7 +47,8 @@ __FBSDID("$FreeBSD$"); static MALLOC_DEFINE(M_OSD, "osd", "Object Specific Data"); static int osd_debug = 0; -SYSCTL_INT(_debug, OID_AUTO, osd, CTLFLAG_RWTUN, &osd_debug, 0, "OSD debug level"); +TUNABLE_INT("debug.osd", &osd_debug); +SYSCTL_INT(_debug, OID_AUTO, osd, CTLFLAG_RW, &osd_debug, 0, "OSD debug level"); #define OSD_DEBUG(...) do { \ if (osd_debug) { \ diff --git a/sys/kern/kern_pmc.c b/sys/kern/kern_pmc.c index 09dc6edbcffeb..2b50be0343fca 100644 --- a/sys/kern/kern_pmc.c +++ b/sys/kern/kern_pmc.c @@ -96,7 +96,8 @@ struct trapframe pmc_tf[MAXCPU]; SYSCTL_NODE(_kern, OID_AUTO, hwpmc, CTLFLAG_RW, 0, "HWPMC parameters"); static int pmc_softevents = 16; -SYSCTL_INT(_kern_hwpmc, OID_AUTO, softevents, CTLFLAG_RDTUN, +TUNABLE_INT(PMC_SYSCTL_NAME_PREFIX "softevents", &pmc_softevents); +SYSCTL_INT(_kern_hwpmc, OID_AUTO, softevents, CTLFLAG_TUN|CTLFLAG_RD, &pmc_softevents, 0, "maximum number of soft events"); struct mtx pmc_softs_mtx; diff --git a/sys/kern/kern_priv.c b/sys/kern/kern_priv.c index 4b9a4443de3ac..2daa5c29fe420 100644 --- a/sys/kern/kern_priv.c +++ b/sys/kern/kern_priv.c @@ -53,12 +53,14 @@ __FBSDID("$FreeBSD$"); * the consequences. */ static int suser_enabled = 1; -SYSCTL_INT(_security_bsd, OID_AUTO, suser_enabled, CTLFLAG_RWTUN, +SYSCTL_INT(_security_bsd, OID_AUTO, suser_enabled, CTLFLAG_RW, &suser_enabled, 0, "processes with uid 0 have privilege"); +TUNABLE_INT("security.bsd.suser_enabled", &suser_enabled); static int unprivileged_mlock = 1; -SYSCTL_INT(_security_bsd, OID_AUTO, unprivileged_mlock, CTLFLAG_RWTUN, +SYSCTL_INT(_security_bsd, OID_AUTO, unprivileged_mlock, CTLFLAG_RW|CTLFLAG_TUN, &unprivileged_mlock, 0, "Allow non-root users to call mlock(2)"); +TUNABLE_INT("security.bsd.unprivileged_mlock", &unprivileged_mlock); SDT_PROVIDER_DEFINE(priv); SDT_PROBE_DEFINE1(priv, kernel, priv_check, priv__ok, "int"); diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c index dba6a43150484..4700e68e53c32 100644 --- a/sys/kern/kern_shutdown.c +++ b/sys/kern/kern_shutdown.c @@ -90,9 +90,10 @@ __FBSDID("$FreeBSD$"); #define PANIC_REBOOT_WAIT_TIME 15 /* default to 15 seconds */ #endif static int panic_reboot_wait_time = PANIC_REBOOT_WAIT_TIME; -SYSCTL_INT(_kern, OID_AUTO, panic_reboot_wait_time, CTLFLAG_RWTUN, +SYSCTL_INT(_kern, OID_AUTO, panic_reboot_wait_time, CTLFLAG_RW | CTLFLAG_TUN, &panic_reboot_wait_time, 0, "Seconds to wait before rebooting after a panic"); +TUNABLE_INT("kern.panic_reboot_wait_time", &panic_reboot_wait_time); /* * Note that stdarg.h and the ANSI style va_start macro is used for both @@ -107,8 +108,9 @@ int debugger_on_panic = 0; int debugger_on_panic = 1; #endif SYSCTL_INT(_debug, OID_AUTO, debugger_on_panic, - CTLFLAG_RWTUN | CTLFLAG_SECURE, + CTLFLAG_RW | CTLFLAG_SECURE | CTLFLAG_TUN, &debugger_on_panic, 0, "Run debugger on kernel panic"); +TUNABLE_INT("debug.debugger_on_panic", &debugger_on_panic); #ifdef KDB_TRACE static int trace_on_panic = 1; @@ -116,13 +118,15 @@ static int trace_on_panic = 1; static int trace_on_panic = 0; #endif SYSCTL_INT(_debug, OID_AUTO, trace_on_panic, - CTLFLAG_RWTUN | CTLFLAG_SECURE, + CTLFLAG_RW | CTLFLAG_SECURE | CTLFLAG_TUN, &trace_on_panic, 0, "Print stack trace on kernel panic"); +TUNABLE_INT("debug.trace_on_panic", &trace_on_panic); #endif /* KDB */ static int sync_on_panic = 0; -SYSCTL_INT(_kern, OID_AUTO, sync_on_panic, CTLFLAG_RWTUN, +SYSCTL_INT(_kern, OID_AUTO, sync_on_panic, CTLFLAG_RW | CTLFLAG_TUN, &sync_on_panic, 0, "Do a sync before rebooting from a panic"); +TUNABLE_INT("kern.sync_on_panic", &sync_on_panic); static SYSCTL_NODE(_kern, OID_AUTO, shutdown, CTLFLAG_RW, 0, "Shutdown environment"); @@ -555,35 +559,43 @@ static int kassert_warnings = 0; SYSCTL_NODE(_debug, OID_AUTO, kassert, CTLFLAG_RW, NULL, "kassert options"); -SYSCTL_INT(_debug_kassert, OID_AUTO, warn_only, CTLFLAG_RWTUN, +SYSCTL_INT(_debug_kassert, OID_AUTO, warn_only, CTLFLAG_RW | CTLFLAG_TUN, &kassert_warn_only, 0, "KASSERT triggers a panic (1) or just a warning (0)"); +TUNABLE_INT("debug.kassert.warn_only", &kassert_warn_only); #ifdef KDB -SYSCTL_INT(_debug_kassert, OID_AUTO, do_kdb, CTLFLAG_RWTUN, +SYSCTL_INT(_debug_kassert, OID_AUTO, do_kdb, CTLFLAG_RW | CTLFLAG_TUN, &kassert_do_kdb, 0, "KASSERT will enter the debugger"); +TUNABLE_INT("debug.kassert.do_kdb", &kassert_do_kdb); #endif #ifdef KTR -SYSCTL_UINT(_debug_kassert, OID_AUTO, do_ktr, CTLFLAG_RWTUN, +SYSCTL_UINT(_debug_kassert, OID_AUTO, do_ktr, CTLFLAG_RW | CTLFLAG_TUN, &kassert_do_ktr, 0, "KASSERT does a KTR, set this to the KTRMASK you want"); +TUNABLE_INT("debug.kassert.do_ktr", &kassert_do_ktr); #endif -SYSCTL_INT(_debug_kassert, OID_AUTO, do_log, CTLFLAG_RWTUN, +SYSCTL_INT(_debug_kassert, OID_AUTO, do_log, CTLFLAG_RW | CTLFLAG_TUN, &kassert_do_log, 0, "KASSERT triggers a panic (1) or just a warning (0)"); +TUNABLE_INT("debug.kassert.do_log", &kassert_do_log); -SYSCTL_INT(_debug_kassert, OID_AUTO, warnings, CTLFLAG_RWTUN, +SYSCTL_INT(_debug_kassert, OID_AUTO, warnings, CTLFLAG_RW | CTLFLAG_TUN, &kassert_warnings, 0, "number of KASSERTs that have been triggered"); +TUNABLE_INT("debug.kassert.warnings", &kassert_warnings); -SYSCTL_INT(_debug_kassert, OID_AUTO, log_panic_at, CTLFLAG_RWTUN, +SYSCTL_INT(_debug_kassert, OID_AUTO, log_panic_at, CTLFLAG_RW | CTLFLAG_TUN, &kassert_log_panic_at, 0, "max number of KASSERTS before we will panic"); +TUNABLE_INT("debug.kassert.log_panic_at", &kassert_log_panic_at); -SYSCTL_INT(_debug_kassert, OID_AUTO, log_pps_limit, CTLFLAG_RWTUN, +SYSCTL_INT(_debug_kassert, OID_AUTO, log_pps_limit, CTLFLAG_RW | CTLFLAG_TUN, &kassert_log_pps_limit, 0, "limit number of log messages per second"); +TUNABLE_INT("debug.kassert.log_pps_limit", &kassert_log_pps_limit); -SYSCTL_INT(_debug_kassert, OID_AUTO, log_mute_at, CTLFLAG_RWTUN, +SYSCTL_INT(_debug_kassert, OID_AUTO, log_mute_at, CTLFLAG_RW | CTLFLAG_TUN, &kassert_log_mute_at, 0, "max number of KASSERTS to log"); +TUNABLE_INT("debug.kassert.log_mute_at", &kassert_log_mute_at); static int kassert_sysctl_kassert(SYSCTL_HANDLER_ARGS); diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 67845a25d1b56..b405779905f66 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -136,7 +136,8 @@ SYSCTL_INT(_kern_sigqueue, OID_AUTO, max_pending_per_proc, CTLFLAG_RW, &max_pending_per_proc, 0, "Max pending signals per proc"); static int preallocate_siginfo = 1024; -SYSCTL_INT(_kern_sigqueue, OID_AUTO, preallocate, CTLFLAG_RDTUN, +TUNABLE_INT("kern.sigqueue.preallocate", &preallocate_siginfo); +SYSCTL_INT(_kern_sigqueue, OID_AUTO, preallocate, CTLFLAG_RD, &preallocate_siginfo, 0, "Preallocated signal memory size"); static int signal_overflow = 0; @@ -162,11 +163,13 @@ SYSINIT(signal, SI_SUB_P1003_1B, SI_ORDER_FIRST+3, sigqueue_start, NULL); (cr1)->cr_uid == (cr2)->cr_uid) static int sugid_coredump; -SYSCTL_INT(_kern, OID_AUTO, sugid_coredump, CTLFLAG_RWTUN, +TUNABLE_INT("kern.sugid_coredump", &sugid_coredump); +SYSCTL_INT(_kern, OID_AUTO, sugid_coredump, CTLFLAG_RW, &sugid_coredump, 0, "Allow setuid and setgid processes to dump core"); static int capmode_coredump; -SYSCTL_INT(_kern, OID_AUTO, capmode_coredump, CTLFLAG_RWTUN, +TUNABLE_INT("kern.capmode_coredump", &capmode_coredump); +SYSCTL_INT(_kern, OID_AUTO, capmode_coredump, CTLFLAG_RW, &capmode_coredump, 0, "Allow processes in capability mode to dump core"); static int do_coredump = 1; @@ -3049,7 +3052,8 @@ SYSCTL_INT(_kern, OID_AUTO, compress_user_cores_gzlevel, CTLFLAG_RW, #endif static char corefilename[MAXPATHLEN] = {"%N.core"}; -SYSCTL_STRING(_kern, OID_AUTO, corefile, CTLFLAG_RWTUN, corefilename, +TUNABLE_STR("kern.corefile", corefilename, sizeof(corefilename)); +SYSCTL_STRING(_kern, OID_AUTO, corefile, CTLFLAG_RW, corefilename, sizeof(corefilename), "Process corefile name format string"); /* diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index cb5a266e4e218..fec4aeabe1f56 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -98,13 +98,10 @@ static struct sx sysctlmemlock; static int sysctl_root(SYSCTL_HANDLER_ARGS); -/* Root list */ -struct sysctl_oid_list sysctl__children = SLIST_HEAD_INITIALIZER(&sysctl__children); +struct sysctl_oid_list sysctl__children; /* root list */ static int sysctl_remove_oid_locked(struct sysctl_oid *oidp, int del, int recurse); -static int sysctl_old_kernel(struct sysctl_req *, const void *, size_t); -static int sysctl_new_kernel(struct sysctl_req *, void *, size_t); static struct sysctl_oid * sysctl_find_oidname(const char *name, struct sysctl_oid_list *list) @@ -139,118 +136,6 @@ sysctl_unlock(void) SYSCTL_XUNLOCK(); } -static int -sysctl_root_handler_locked(struct sysctl_oid *oid, void *arg1, intptr_t arg2, - struct sysctl_req *req) -{ - int error; - - oid->oid_running++; - SYSCTL_XUNLOCK(); - - if (!(oid->oid_kind & CTLFLAG_MPSAFE)) - mtx_lock(&Giant); - error = oid->oid_handler(oid, arg1, arg2, req); - if (!(oid->oid_kind & CTLFLAG_MPSAFE)) - mtx_unlock(&Giant); - - SYSCTL_XLOCK(); - oid->oid_running--; - if (oid->oid_running == 0 && (oid->oid_kind & CTLFLAG_DYING) != 0) - wakeup(&oid->oid_running); - - return (error); -} - -static void -sysctl_load_tunable_by_oid_locked(struct sysctl_oid *oidp) -{ - struct sysctl_req req; - struct sysctl_oid *curr; - char *penv; - char path[64]; - ssize_t rem = sizeof(path); - ssize_t len; - int val_int; - long val_long; - int64_t val_64; - int error; - - path[--rem] = 0; - - for (curr = oidp; curr != NULL; curr = SYSCTL_PARENT(curr)) { - len = strlen(curr->oid_name); - rem -= len; - if (curr != oidp) - rem -= 1; - if (rem < 0) { - printf("OID path exceeds %d bytes\n", (int)sizeof(path)); - return; - } - memcpy(path + rem, curr->oid_name, len); - if (curr != oidp) - path[rem + len] = '.'; - } - - penv = getenv(path + rem); - if (penv == NULL) - return; - - memset(&req, 0, sizeof(req)); - - req.td = curthread; - req.oldfunc = sysctl_old_kernel; - req.newfunc = sysctl_new_kernel; - req.lock = REQ_UNWIRED; - - switch (oidp->oid_kind & CTLTYPE) { - case CTLTYPE_INT: - val_int = strtoq(penv, NULL, 0); - req.newlen = sizeof(val_int); - req.newptr = &val_int; - break; - case CTLTYPE_UINT: - val_int = strtouq(penv, NULL, 0); - req.newlen = sizeof(val_int); - req.newptr = &val_int; - break; - case CTLTYPE_LONG: - val_long = strtoq(penv, NULL, 0); - req.newlen = sizeof(val_long); - req.newptr = &val_long; - break; - case CTLTYPE_ULONG: - val_long = strtouq(penv, NULL, 0); - req.newlen = sizeof(val_long); - req.newptr = &val_long; - break; - case CTLTYPE_S64: - val_64 = strtoq(penv, NULL, 0); - req.newlen = sizeof(val_64); - req.newptr = &val_64; - break; - case CTLTYPE_U64: - val_64 = strtouq(penv, NULL, 0); - req.newlen = sizeof(val_64); - req.newptr = &val_64; - break; - case CTLTYPE_STRING: - req.newlen = strlen(penv); - req.newptr = penv; - break; - default: - freeenv(penv); - return; - } - error = sysctl_root_handler_locked(oidp, oidp->oid_arg1, - oidp->oid_arg2, &req); - if (error != 0) { - printf("Setting sysctl '%s' to '%s' failed: %d\n", - path, penv, error); - } - freeenv(penv); -} - void sysctl_register_oid(struct sysctl_oid *oidp) { @@ -307,15 +192,6 @@ sysctl_register_oid(struct sysctl_oid *oidp) SLIST_INSERT_AFTER(q, oidp, oid_link); else SLIST_INSERT_HEAD(parent, oidp, oid_link); - - if ((oidp->oid_kind & CTLTYPE) != CTLTYPE_NODE && -#ifdef VIMAGE - (oidp->oid_kind & CTLFLAG_VNET) == 0 && -#endif - (oidp->oid_kind & CTLFLAG_TUN) != 0 && - (oidp->oid_kind & CTLFLAG_NOFETCH) == 0) { - sysctl_load_tunable_by_oid_locked(oidp); - } } void @@ -547,6 +423,8 @@ sysctl_remove_oid_locked(struct sysctl_oid *oidp, int del, int recurse) if (error) return (error); } + if (del) + free(SYSCTL_CHILDREN(oidp), M_SYSCTLOID); } } if (oidp->oid_refcnt > 1 ) { @@ -611,16 +489,24 @@ sysctl_add_oid(struct sysctl_ctx_list *clist, struct sysctl_oid_list *parent, } oidp = malloc(sizeof(struct sysctl_oid), M_SYSCTLOID, M_WAITOK|M_ZERO); oidp->oid_parent = parent; - SLIST_INIT(&oidp->oid_children); + SLIST_NEXT(oidp, oid_link) = NULL; oidp->oid_number = number; oidp->oid_refcnt = 1; oidp->oid_name = strdup(name, M_SYSCTLOID); oidp->oid_handler = handler; oidp->oid_kind = CTLFLAG_DYN | kind; - oidp->oid_arg1 = arg1; - oidp->oid_arg2 = arg2; + if ((kind & CTLTYPE) == CTLTYPE_NODE) { + /* Allocate space for children */ + SYSCTL_CHILDREN_SET(oidp, malloc(sizeof(struct sysctl_oid_list), + M_SYSCTLOID, M_WAITOK)); + SLIST_INIT(SYSCTL_CHILDREN(oidp)); + oidp->oid_arg2 = arg2; + } else { + oidp->oid_arg1 = arg1; + oidp->oid_arg2 = arg2; + } oidp->oid_fmt = fmt; - if (descr != NULL) + if (descr) oidp->oid_descr = strdup(descr, M_SYSCTLOID); /* Update the context, if used */ if (clist != NULL) @@ -691,7 +577,7 @@ sysctl_register_all(void *arg) sysctl_register_oid(*oidp); SYSCTL_XUNLOCK(); } -SYSINIT(sysctl, SI_SUB_KMEM, SI_ORDER_FIRST, sysctl_register_all, 0); +SYSINIT(sysctl, SI_SUB_KMEM, SI_ORDER_ANY, sysctl_register_all, 0); /* * "Staff-functions" @@ -739,7 +625,7 @@ sysctl_sysctl_debug_dump_node(struct sysctl_oid_list *l, int i) printf(" Node\n"); if (!oidp->oid_handler) { sysctl_sysctl_debug_dump_node( - SYSCTL_CHILDREN(oidp), i + 2); + oidp->oid_arg1, i+2); } break; case CTLTYPE_INT: printf(" Int\n"); break; @@ -1207,28 +1093,26 @@ sysctl_handle_64(SYSCTL_HANDLER_ARGS) int sysctl_handle_string(SYSCTL_HANDLER_ARGS) { + int error=0; + char *tmparg; size_t outlen; - int error = 0; - /* check for zero-length buffer */ - if (arg2 == 0) - return (ENOMEM); - - if (req->oldptr != NULL) { - char *tmparg; - - /* try to make a coherent snapshot of the string */ - tmparg = malloc(arg2, M_SYSCTLTMP, M_WAITOK); - memcpy(tmparg, arg1, arg2); - - outlen = strnlen(tmparg, arg2 - 1) + 1; - error = SYSCTL_OUT(req, tmparg, outlen); + /* + * Attempt to get a coherent snapshot by copying to a + * temporary kernel buffer. + */ +retry: + outlen = strlen((char *)arg1)+1; + tmparg = malloc(outlen, M_SYSCTLTMP, M_WAITOK); + if (strlcpy(tmparg, (char *)arg1, outlen) >= outlen) { free(tmparg, M_SYSCTLTMP); - } else { - outlen = strnlen((char *)arg1, arg2 - 1) + 1; - error = SYSCTL_OUT(req, NULL, outlen); + goto retry; } + + error = SYSCTL_OUT(req, tmparg, outlen); + free(tmparg, M_SYSCTLTMP); + if (error || !req->newptr) return (error); @@ -1239,6 +1123,7 @@ sysctl_handle_string(SYSCTL_HANDLER_ARGS) error = SYSCTL_IN(req, arg1, arg2); ((char *)arg1)[arg2] = '\0'; } + return (error); } @@ -1604,14 +1489,24 @@ sysctl_root(SYSCTL_HANDLER_ARGS) if (error != 0) return (error); #endif + oid->oid_running++; + SYSCTL_XUNLOCK(); #ifdef VIMAGE if ((oid->oid_kind & CTLFLAG_VNET) && arg1 != NULL) arg1 = (void *)(curvnet->vnet_data_base + (uintptr_t)arg1); #endif - error = sysctl_root_handler_locked(oid, arg1, arg2, req); + if (!(oid->oid_kind & CTLFLAG_MPSAFE)) + mtx_lock(&Giant); + error = oid->oid_handler(oid, arg1, arg2, req); + if (!(oid->oid_kind & CTLFLAG_MPSAFE)) + mtx_unlock(&Giant); KFAIL_POINT_ERROR(_debug_fail_point, sysctl_running, error); + SYSCTL_XLOCK(); + oid->oid_running--; + if (oid->oid_running == 0 && (oid->oid_kind & CTLFLAG_DYING) != 0) + wakeup(&oid->oid_running); return (error); } diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index 78ceff2ad5be5..9fe7ebe6b3610 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -128,9 +128,10 @@ struct bintime tc_tick_bt; sbintime_t tc_tick_sbt; int tc_precexp; int tc_timepercentage = TC_DEFAULTPERC; +TUNABLE_INT("kern.timecounter.alloweddeviation", &tc_timepercentage); static int sysctl_kern_timecounter_adjprecision(SYSCTL_HANDLER_ARGS); SYSCTL_PROC(_kern_timecounter, OID_AUTO, alloweddeviation, - CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, 0, 0, + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 0, sysctl_kern_timecounter_adjprecision, "I", "Allowed time interval deviation in percents"); @@ -1793,10 +1794,7 @@ sysctl_kern_timecounter_adjprecision(SYSCTL_HANDLER_ARGS) if (error != 0 || req->newptr == NULL) return (error); tc_timepercentage = val; - if (cold) - goto done; tc_adjprecision(); -done: return (0); } diff --git a/sys/kern/kern_timeout.c b/sys/kern/kern_timeout.c index 905e24a13819b..eee54745aac70 100644 --- a/sys/kern/kern_timeout.c +++ b/sys/kern/kern_timeout.c @@ -101,15 +101,15 @@ SYSCTL_INT(_debug, OID_AUTO, to_avg_mpcalls_dir, CTLFLAG_RD, &avg_mpcalls_dir, #endif static int ncallout; -SYSCTL_INT(_kern, OID_AUTO, ncallout, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &ncallout, 0, +SYSCTL_INT(_kern, OID_AUTO, ncallout, CTLFLAG_RDTUN, &ncallout, 0, "Number of entries in callwheel and size of timeout() preallocation"); static int pin_default_swi = 0; static int pin_pcpu_swi = 0; -SYSCTL_INT(_kern, OID_AUTO, pin_default_swi, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &pin_default_swi, +SYSCTL_INT(_kern, OID_AUTO, pin_default_swi, CTLFLAG_RDTUN, &pin_default_swi, 0, "Pin the default (non-per-cpu) swi (shared with PCPU 0 swi)"); -SYSCTL_INT(_kern, OID_AUTO, pin_pcpu_swi, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &pin_pcpu_swi, +SYSCTL_INT(_kern, OID_AUTO, pin_pcpu_swi, CTLFLAG_RDTUN, &pin_pcpu_swi, 0, "Pin the per-CPU swis (except PCPU 0, which is also default"); /* diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index eb54445c4c037..53b10ec1fa205 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -63,7 +63,7 @@ __FBSDID("$FreeBSD$"); #include SYSCTL_NODE(_hw, OID_AUTO, bus, CTLFLAG_RW, NULL, NULL); -SYSCTL_ROOT_NODE(OID_AUTO, dev, CTLFLAG_RW, NULL, NULL); +SYSCTL_NODE(, OID_AUTO, dev, CTLFLAG_RW, NULL, NULL); /* * Used to attach drivers to devclasses. @@ -149,8 +149,9 @@ static MALLOC_DEFINE(M_BUS_SC, "bus-sc", "Bus data structures, softc"); #ifdef BUS_DEBUG static int bus_debug = 1; -SYSCTL_INT(_debug, OID_AUTO, bus_debug, CTLFLAG_RWTUN, &bus_debug, 0, - "Bus debug level"); +TUNABLE_INT("bus.debug", &bus_debug); +SYSCTL_INT(_debug, OID_AUTO, bus_debug, CTLFLAG_RW, &bus_debug, 0, + "Debug bus code"); #define PDEBUG(a) if (bus_debug) {printf("%s:%d: ", __func__, __LINE__), printf a; printf("\n");} #define DEVICENAME(d) ((d)? device_get_name(d): "no device") @@ -356,14 +357,16 @@ device_sysctl_fini(device_t dev) /* Deprecated way to adjust queue length */ static int sysctl_devctl_disable(SYSCTL_HANDLER_ARGS); -SYSCTL_PROC(_hw_bus, OID_AUTO, devctl_disable, CTLTYPE_INT | CTLFLAG_RWTUN | +/* XXX Need to support old-style tunable hw.bus.devctl_disable" */ +SYSCTL_PROC(_hw_bus, OID_AUTO, devctl_disable, CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, NULL, 0, sysctl_devctl_disable, "I", "devctl disable -- deprecated"); #define DEVCTL_DEFAULT_QUEUE_LEN 1000 static int sysctl_devctl_queue(SYSCTL_HANDLER_ARGS); static int devctl_queue_length = DEVCTL_DEFAULT_QUEUE_LEN; -SYSCTL_PROC(_hw_bus, OID_AUTO, devctl_queue, CTLTYPE_INT | CTLFLAG_RWTUN | +TUNABLE_INT("hw.bus.devctl_queue", &devctl_queue_length); +SYSCTL_PROC(_hw_bus, OID_AUTO, devctl_queue, CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, NULL, 0, sysctl_devctl_queue, "I", "devctl queue length"); static d_open_t devopen; @@ -788,12 +791,11 @@ sysctl_devctl_disable(SYSCTL_HANDLER_ARGS) struct dev_event_info *n1; int dis, error; - dis = (devctl_queue_length == 0); + dis = devctl_queue_length == 0; error = sysctl_handle_int(oidp, &dis, 0, req); if (error || !req->newptr) return (error); - if (mtx_initialized(&devsoftc.mtx)) - mtx_lock(&devsoftc.mtx); + mtx_lock(&devsoftc.mtx); if (dis) { while (!TAILQ_EMPTY(&devsoftc.devq)) { n1 = TAILQ_FIRST(&devsoftc.devq); @@ -806,8 +808,7 @@ sysctl_devctl_disable(SYSCTL_HANDLER_ARGS) } else { devctl_queue_length = DEVCTL_DEFAULT_QUEUE_LEN; } - if (mtx_initialized(&devsoftc.mtx)) - mtx_unlock(&devsoftc.mtx); + mtx_unlock(&devsoftc.mtx); return (0); } @@ -823,8 +824,7 @@ sysctl_devctl_queue(SYSCTL_HANDLER_ARGS) return (error); if (q < 0) return (EINVAL); - if (mtx_initialized(&devsoftc.mtx)) - mtx_lock(&devsoftc.mtx); + mtx_lock(&devsoftc.mtx); devctl_queue_length = q; while (devsoftc.queued > devctl_queue_length) { n1 = TAILQ_FIRST(&devsoftc.devq); @@ -833,8 +833,7 @@ sysctl_devctl_queue(SYSCTL_HANDLER_ARGS) free(n1, M_BUS); devsoftc.queued--; } - if (mtx_initialized(&devsoftc.mtx)) - mtx_unlock(&devsoftc.mtx); + mtx_unlock(&devsoftc.mtx); return (0); } diff --git a/sys/kern/subr_kdb.c b/sys/kern/subr_kdb.c index c26d271663f60..a7ed944a61fbc 100644 --- a/sys/kern/subr_kdb.c +++ b/sys/kern/subr_kdb.c @@ -108,12 +108,14 @@ SYSCTL_PROC(_debug_kdb, OID_AUTO, trap_code, kdb_sysctl_trap_code, "I", "set to cause a page fault via code access"); SYSCTL_INT(_debug_kdb, OID_AUTO, break_to_debugger, - CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_SECURE, + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_TUN | CTLFLAG_SECURE, &kdb_break_to_debugger, 0, "Enable break to debugger"); +TUNABLE_INT("debug.kdb.break_to_debugger", &kdb_break_to_debugger); SYSCTL_INT(_debug_kdb, OID_AUTO, alt_break_to_debugger, - CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_SECURE, + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_TUN | CTLFLAG_SECURE, &kdb_alt_break_to_debugger, 0, "Enable alternative break to debugger"); +TUNABLE_INT("debug.kdb.alt_break_to_debugger", &kdb_alt_break_to_debugger); /* * Flag to indicate to debuggers why the debugger was entered. diff --git a/sys/kern/subr_msgbuf.c b/sys/kern/subr_msgbuf.c index fa23c91f658f1..ecdbe722ddc64 100644 --- a/sys/kern/subr_msgbuf.c +++ b/sys/kern/subr_msgbuf.c @@ -53,8 +53,9 @@ static u_int msgbuf_cksum(struct msgbuf *mbp); * or other actions occured. */ static int msgbuf_show_timestamp = 0; -SYSCTL_INT(_kern, OID_AUTO, msgbuf_show_timestamp, CTLFLAG_RWTUN, +SYSCTL_INT(_kern, OID_AUTO, msgbuf_show_timestamp, CTLFLAG_RW | CTLFLAG_TUN, &msgbuf_show_timestamp, 0, "Show timestamp in msgbuf"); +TUNABLE_INT("kern.msgbuf_show_timestamp", &msgbuf_show_timestamp); /* * Initialize a message buffer of the specified size at the specified diff --git a/sys/kern/subr_param.c b/sys/kern/subr_param.c index f589097ffb74f..afd3eacc71786 100644 --- a/sys/kern/subr_param.c +++ b/sys/kern/subr_param.c @@ -107,32 +107,32 @@ u_long dflssiz; /* initial stack size limit */ u_long maxssiz; /* max stack size */ u_long sgrowsiz; /* amount to grow stack */ -SYSCTL_INT(_kern, OID_AUTO, hz, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &hz, 0, +SYSCTL_INT(_kern, OID_AUTO, hz, CTLFLAG_RDTUN, &hz, 0, "Number of clock ticks per second"); -SYSCTL_INT(_kern, OID_AUTO, nbuf, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &nbuf, 0, +SYSCTL_INT(_kern, OID_AUTO, nbuf, CTLFLAG_RDTUN, &nbuf, 0, "Number of buffers in the buffer cache"); -SYSCTL_INT(_kern, OID_AUTO, nswbuf, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &nswbuf, 0, +SYSCTL_INT(_kern, OID_AUTO, nswbuf, CTLFLAG_RDTUN, &nswbuf, 0, "Number of swap buffers"); -SYSCTL_INT(_kern, OID_AUTO, msgbufsize, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &msgbufsize, 0, +SYSCTL_INT(_kern, OID_AUTO, msgbufsize, CTLFLAG_RDTUN, &msgbufsize, 0, "Size of the kernel message buffer"); -SYSCTL_LONG(_kern, OID_AUTO, maxswzone, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &maxswzone, 0, +SYSCTL_LONG(_kern, OID_AUTO, maxswzone, CTLFLAG_RDTUN, &maxswzone, 0, "Maximum memory for swap metadata"); -SYSCTL_LONG(_kern, OID_AUTO, maxbcache, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &maxbcache, 0, +SYSCTL_LONG(_kern, OID_AUTO, maxbcache, CTLFLAG_RDTUN, &maxbcache, 0, "Maximum value of vfs.maxbufspace"); -SYSCTL_INT(_kern, OID_AUTO, bio_transient_maxcnt, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, +SYSCTL_INT(_kern, OID_AUTO, bio_transient_maxcnt, CTLFLAG_RDTUN, &bio_transient_maxcnt, 0, "Maximum number of transient BIOs mappings"); -SYSCTL_ULONG(_kern, OID_AUTO, maxtsiz, CTLFLAG_RWTUN | CTLFLAG_NOFETCH, &maxtsiz, 0, +SYSCTL_ULONG(_kern, OID_AUTO, maxtsiz, CTLFLAG_RW | CTLFLAG_TUN, &maxtsiz, 0, "Maximum text size"); -SYSCTL_ULONG(_kern, OID_AUTO, dfldsiz, CTLFLAG_RWTUN | CTLFLAG_NOFETCH, &dfldsiz, 0, +SYSCTL_ULONG(_kern, OID_AUTO, dfldsiz, CTLFLAG_RW | CTLFLAG_TUN, &dfldsiz, 0, "Initial data size limit"); -SYSCTL_ULONG(_kern, OID_AUTO, maxdsiz, CTLFLAG_RWTUN | CTLFLAG_NOFETCH, &maxdsiz, 0, +SYSCTL_ULONG(_kern, OID_AUTO, maxdsiz, CTLFLAG_RW | CTLFLAG_TUN, &maxdsiz, 0, "Maximum data size"); -SYSCTL_ULONG(_kern, OID_AUTO, dflssiz, CTLFLAG_RWTUN | CTLFLAG_NOFETCH, &dflssiz, 0, +SYSCTL_ULONG(_kern, OID_AUTO, dflssiz, CTLFLAG_RW | CTLFLAG_TUN, &dflssiz, 0, "Initial stack size limit"); -SYSCTL_ULONG(_kern, OID_AUTO, maxssiz, CTLFLAG_RWTUN | CTLFLAG_NOFETCH, &maxssiz, 0, +SYSCTL_ULONG(_kern, OID_AUTO, maxssiz, CTLFLAG_RW | CTLFLAG_TUN, &maxssiz, 0, "Maximum stack size"); -SYSCTL_ULONG(_kern, OID_AUTO, sgrowsiz, CTLFLAG_RWTUN | CTLFLAG_NOFETCH, &sgrowsiz, 0, +SYSCTL_ULONG(_kern, OID_AUTO, sgrowsiz, CTLFLAG_RW | CTLFLAG_TUN, &sgrowsiz, 0, "Amount to grow stack on a stack fault"); SYSCTL_PROC(_kern, OID_AUTO, vm_guest, CTLFLAG_RD | CTLTYPE_STRING, NULL, 0, sysctl_kern_vm_guest, "A", diff --git a/sys/kern/subr_prf.c b/sys/kern/subr_prf.c index 814e57f479474..28e33a4b4b2b1 100644 --- a/sys/kern/subr_prf.c +++ b/sys/kern/subr_prf.c @@ -102,20 +102,23 @@ static void snprintf_func(int ch, void *arg); static int msgbufmapped; /* Set when safe to use msgbuf */ int msgbuftrigger; -static int log_console_output = 1; -SYSCTL_INT(_kern, OID_AUTO, log_console_output, CTLFLAG_RWTUN, - &log_console_output, 0, "Duplicate console output to the syslog"); +static int log_console_output = 1; +TUNABLE_INT("kern.log_console_output", &log_console_output); +SYSCTL_INT(_kern, OID_AUTO, log_console_output, CTLFLAG_RW, + &log_console_output, 0, "Duplicate console output to the syslog."); /* * See the comment in log_console() below for more explanation of this. */ -static int log_console_add_linefeed; -SYSCTL_INT(_kern, OID_AUTO, log_console_add_linefeed, CTLFLAG_RWTUN, - &log_console_add_linefeed, 0, "log_console() adds extra newlines"); - -static int always_console_output; -SYSCTL_INT(_kern, OID_AUTO, always_console_output, CTLFLAG_RWTUN, - &always_console_output, 0, "Always output to console despite TIOCCONS"); +static int log_console_add_linefeed = 0; +TUNABLE_INT("kern.log_console_add_linefeed", &log_console_add_linefeed); +SYSCTL_INT(_kern, OID_AUTO, log_console_add_linefeed, CTLFLAG_RW, + &log_console_add_linefeed, 0, "log_console() adds extra newlines."); + +static int always_console_output = 0; +TUNABLE_INT("kern.always_console_output", &always_console_output); +SYSCTL_INT(_kern, OID_AUTO, always_console_output, CTLFLAG_RW, + &always_console_output, 0, "Always output to console despite TIOCCONS."); /* * Warn that a system table is full. diff --git a/sys/kern/subr_rman.c b/sys/kern/subr_rman.c index 53480bf31b85f..c466b44b0fcd4 100644 --- a/sys/kern/subr_rman.c +++ b/sys/kern/subr_rman.c @@ -100,7 +100,8 @@ struct resource_i { }; static int rman_debug = 0; -SYSCTL_INT(_debug, OID_AUTO, rman_debug, CTLFLAG_RWTUN, +TUNABLE_INT("debug.rman_debug", &rman_debug); +SYSCTL_INT(_debug, OID_AUTO, rman_debug, CTLFLAG_RW, &rman_debug, 0, "rman debug"); #define DPRINTF(params) if (rman_debug) printf params diff --git a/sys/kern/subr_smp.c b/sys/kern/subr_smp.c index 90bbc5fd22a1c..122fc4c5fede6 100644 --- a/sys/kern/subr_smp.c +++ b/sys/kern/subr_smp.c @@ -87,14 +87,16 @@ SYSCTL_PROC(_kern_smp, OID_AUTO, active, CTLFLAG_RD | CTLTYPE_INT, NULL, 0, int smp_disabled = 0; /* has smp been disabled? */ SYSCTL_INT(_kern_smp, OID_AUTO, disabled, CTLFLAG_RDTUN|CTLFLAG_CAPRD, &smp_disabled, 0, "SMP has been disabled from the loader"); +TUNABLE_INT("kern.smp.disabled", &smp_disabled); int smp_cpus = 1; /* how many cpu's running */ SYSCTL_INT(_kern_smp, OID_AUTO, cpus, CTLFLAG_RD|CTLFLAG_CAPRD, &smp_cpus, 0, "Number of CPUs online"); int smp_topology = 0; /* Which topology we're using. */ -SYSCTL_INT(_kern_smp, OID_AUTO, topology, CTLFLAG_RDTUN, &smp_topology, 0, +SYSCTL_INT(_kern_smp, OID_AUTO, topology, CTLFLAG_RD, &smp_topology, 0, "Topology override setting; 0 is default provided by hardware."); +TUNABLE_INT("kern.smp.topology", &smp_topology); #ifdef SMP /* Enable forwarding of a signal to a process running on a different CPU */ diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c index 4ba4cf18607e4..86e1b16015e05 100644 --- a/sys/kern/subr_witness.c +++ b/sys/kern/subr_witness.c @@ -380,7 +380,8 @@ static SYSCTL_NODE(_debug, OID_AUTO, witness, CTLFLAG_RW, NULL, * completely disabled. */ static int witness_watch = 1; -SYSCTL_PROC(_debug_witness, OID_AUTO, watch, CTLFLAG_RWTUN | CTLTYPE_INT, NULL, 0, +TUNABLE_INT("debug.witness.watch", &witness_watch); +SYSCTL_PROC(_debug_witness, OID_AUTO, watch, CTLFLAG_RW | CTLTYPE_INT, NULL, 0, sysctl_debug_witness_watch, "I", "witness is watching lock operations"); #ifdef KDB @@ -395,7 +396,8 @@ int witness_kdb = 1; #else int witness_kdb = 0; #endif -SYSCTL_INT(_debug_witness, OID_AUTO, kdb, CTLFLAG_RWTUN, &witness_kdb, 0, ""); +TUNABLE_INT("debug.witness.kdb", &witness_kdb); +SYSCTL_INT(_debug_witness, OID_AUTO, kdb, CTLFLAG_RW, &witness_kdb, 0, ""); /* * When KDB is enabled and witness_trace is 1, it will cause the system @@ -404,7 +406,8 @@ SYSCTL_INT(_debug_witness, OID_AUTO, kdb, CTLFLAG_RWTUN, &witness_kdb, 0, ""); * - locks are held when going to sleep. */ int witness_trace = 1; -SYSCTL_INT(_debug_witness, OID_AUTO, trace, CTLFLAG_RWTUN, &witness_trace, 0, ""); +TUNABLE_INT("debug.witness.trace", &witness_trace); +SYSCTL_INT(_debug_witness, OID_AUTO, trace, CTLFLAG_RW, &witness_trace, 0, ""); #endif /* KDB */ #ifdef WITNESS_SKIPSPIN @@ -412,7 +415,9 @@ int witness_skipspin = 1; #else int witness_skipspin = 0; #endif -SYSCTL_INT(_debug_witness, OID_AUTO, skipspin, CTLFLAG_RDTUN, &witness_skipspin, 0, ""); +TUNABLE_INT("debug.witness.skipspin", &witness_skipspin); +SYSCTL_INT(_debug_witness, OID_AUTO, skipspin, CTLFLAG_RDTUN, &witness_skipspin, + 0, ""); /* * Call this to print out the relations between locks. diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c index 01cfeb9c1ffdd..f3c3c0e01d611 100644 --- a/sys/kern/sys_pipe.c +++ b/sys/kern/sys_pipe.c @@ -205,7 +205,7 @@ static int pipeallocfail; static int piperesizefail; static int piperesizeallowed = 1; -SYSCTL_LONG(_kern_ipc, OID_AUTO, maxpipekva, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, +SYSCTL_LONG(_kern_ipc, OID_AUTO, maxpipekva, CTLFLAG_RDTUN, &maxpipekva, 0, "Pipe KVA limit"); SYSCTL_LONG(_kern_ipc, OID_AUTO, pipekva, CTLFLAG_RD, &amountpipekva, 0, "Pipe KVA usage"); diff --git a/sys/kern/sysv_msg.c b/sys/kern/sysv_msg.c index a572a0e0c1451..d58cb7e791e8f 100644 --- a/sys/kern/sysv_msg.c +++ b/sys/kern/sysv_msg.c @@ -196,7 +196,13 @@ msginit() { int i, error; + TUNABLE_INT_FETCH("kern.ipc.msgseg", &msginfo.msgseg); + TUNABLE_INT_FETCH("kern.ipc.msgssz", &msginfo.msgssz); msginfo.msgmax = msginfo.msgseg * msginfo.msgssz; + TUNABLE_INT_FETCH("kern.ipc.msgmni", &msginfo.msgmni); + TUNABLE_INT_FETCH("kern.ipc.msgmnb", &msginfo.msgmnb); + TUNABLE_INT_FETCH("kern.ipc.msgtql", &msginfo.msgtql); + msgpool = malloc(msginfo.msgmax, M_MSG, M_WAITOK); msgmaps = malloc(sizeof(struct msgmap) * msginfo.msgseg, M_MSG, M_WAITOK); msghdrs = malloc(sizeof(struct msg) * msginfo.msgtql, M_MSG, M_WAITOK); diff --git a/sys/kern/sysv_sem.c b/sys/kern/sysv_sem.c index c63290240799e..f9ff2170dc32f 100644 --- a/sys/kern/sysv_sem.c +++ b/sys/kern/sysv_sem.c @@ -196,7 +196,7 @@ SYSCTL_INT(_kern_ipc, OID_AUTO, semmns, CTLFLAG_RDTUN, &seminfo.semmns, 0, "Maximum number of semaphores in the system"); SYSCTL_INT(_kern_ipc, OID_AUTO, semmnu, CTLFLAG_RDTUN, &seminfo.semmnu, 0, "Maximum number of undo structures in the system"); -SYSCTL_INT(_kern_ipc, OID_AUTO, semmsl, CTLFLAG_RWTUN, &seminfo.semmsl, 0, +SYSCTL_INT(_kern_ipc, OID_AUTO, semmsl, CTLFLAG_RW, &seminfo.semmsl, 0, "Max semaphores per id"); SYSCTL_INT(_kern_ipc, OID_AUTO, semopm, CTLFLAG_RDTUN, &seminfo.semopm, 0, "Max operations per semop call"); @@ -204,9 +204,9 @@ SYSCTL_INT(_kern_ipc, OID_AUTO, semume, CTLFLAG_RDTUN, &seminfo.semume, 0, "Max undo entries per process"); SYSCTL_INT(_kern_ipc, OID_AUTO, semusz, CTLFLAG_RDTUN, &seminfo.semusz, 0, "Size in bytes of undo structure"); -SYSCTL_INT(_kern_ipc, OID_AUTO, semvmx, CTLFLAG_RWTUN, &seminfo.semvmx, 0, +SYSCTL_INT(_kern_ipc, OID_AUTO, semvmx, CTLFLAG_RW, &seminfo.semvmx, 0, "Semaphore maximum value"); -SYSCTL_INT(_kern_ipc, OID_AUTO, semaem, CTLFLAG_RWTUN, &seminfo.semaem, 0, +SYSCTL_INT(_kern_ipc, OID_AUTO, semaem, CTLFLAG_RW, &seminfo.semaem, 0, "Adjust on exit max value"); SYSCTL_PROC(_kern_ipc, OID_AUTO, sema, CTLTYPE_OPAQUE | CTLFLAG_RD, NULL, 0, sysctl_sema, "", "Semaphore id pool"); @@ -249,6 +249,16 @@ seminit(void) { int i, error; + TUNABLE_INT_FETCH("kern.ipc.semmni", &seminfo.semmni); + TUNABLE_INT_FETCH("kern.ipc.semmns", &seminfo.semmns); + TUNABLE_INT_FETCH("kern.ipc.semmnu", &seminfo.semmnu); + TUNABLE_INT_FETCH("kern.ipc.semmsl", &seminfo.semmsl); + TUNABLE_INT_FETCH("kern.ipc.semopm", &seminfo.semopm); + TUNABLE_INT_FETCH("kern.ipc.semume", &seminfo.semume); + TUNABLE_INT_FETCH("kern.ipc.semusz", &seminfo.semusz); + TUNABLE_INT_FETCH("kern.ipc.semvmx", &seminfo.semvmx); + TUNABLE_INT_FETCH("kern.ipc.semaem", &seminfo.semaem); + sem = malloc(sizeof(struct sem) * seminfo.semmns, M_SEM, M_WAITOK); sema = malloc(sizeof(struct semid_kernel) * seminfo.semmni, M_SEM, M_WAITOK); diff --git a/sys/kern/sysv_shm.c b/sys/kern/sysv_shm.c index a7a7c167e5500..4144d9431f9db 100644 --- a/sys/kern/sysv_shm.c +++ b/sys/kern/sysv_shm.c @@ -156,29 +156,29 @@ static int sysctl_shmsegs(SYSCTL_HANDLER_ARGS); #endif struct shminfo shminfo = { - .shmmax = SHMMAX, - .shmmin = SHMMIN, - .shmmni = SHMMNI, - .shmseg = SHMSEG, - .shmall = SHMALL + SHMMAX, + SHMMIN, + SHMMNI, + SHMSEG, + SHMALL }; static int shm_use_phys; static int shm_allow_removed; -SYSCTL_ULONG(_kern_ipc, OID_AUTO, shmmax, CTLFLAG_RWTUN, &shminfo.shmmax, 0, +SYSCTL_ULONG(_kern_ipc, OID_AUTO, shmmax, CTLFLAG_RW, &shminfo.shmmax, 0, "Maximum shared memory segment size"); -SYSCTL_ULONG(_kern_ipc, OID_AUTO, shmmin, CTLFLAG_RWTUN, &shminfo.shmmin, 0, +SYSCTL_ULONG(_kern_ipc, OID_AUTO, shmmin, CTLFLAG_RW, &shminfo.shmmin, 0, "Minimum shared memory segment size"); SYSCTL_ULONG(_kern_ipc, OID_AUTO, shmmni, CTLFLAG_RDTUN, &shminfo.shmmni, 0, "Number of shared memory identifiers"); SYSCTL_ULONG(_kern_ipc, OID_AUTO, shmseg, CTLFLAG_RDTUN, &shminfo.shmseg, 0, "Number of segments per process"); -SYSCTL_ULONG(_kern_ipc, OID_AUTO, shmall, CTLFLAG_RWTUN, &shminfo.shmall, 0, +SYSCTL_ULONG(_kern_ipc, OID_AUTO, shmall, CTLFLAG_RW, &shminfo.shmall, 0, "Maximum number of pages available for shared memory"); -SYSCTL_INT(_kern_ipc, OID_AUTO, shm_use_phys, CTLFLAG_RWTUN, +SYSCTL_INT(_kern_ipc, OID_AUTO, shm_use_phys, CTLFLAG_RW, &shm_use_phys, 0, "Enable/Disable locking of shared memory pages in core"); -SYSCTL_INT(_kern_ipc, OID_AUTO, shm_allow_removed, CTLFLAG_RWTUN, +SYSCTL_INT(_kern_ipc, OID_AUTO, shm_allow_removed, CTLFLAG_RW, &shm_allow_removed, 0, "Enable/Disable attachment to attached segments marked for removal"); SYSCTL_PROC(_kern_ipc, OID_AUTO, shmsegs, CTLTYPE_OPAQUE | CTLFLAG_RD, @@ -887,14 +887,20 @@ shminit() if (TUNABLE_ULONG_FETCH("kern.ipc.shmmaxpgs", &shminfo.shmall) != 0) printf("kern.ipc.shmmaxpgs is now called kern.ipc.shmall!\n"); #endif - if (shminfo.shmmax == SHMMAX) { + TUNABLE_ULONG_FETCH("kern.ipc.shmall", &shminfo.shmall); + if (!TUNABLE_ULONG_FETCH("kern.ipc.shmmax", &shminfo.shmmax)) { /* Initialize shmmax dealing with possible overflow. */ - for (i = PAGE_SIZE; i != 0; i--) { + for (i = PAGE_SIZE; i > 0; i--) { shminfo.shmmax = shminfo.shmall * i; - if ((shminfo.shmmax / shminfo.shmall) == (u_long)i) + if (shminfo.shmmax >= shminfo.shmall) break; } } + TUNABLE_ULONG_FETCH("kern.ipc.shmmin", &shminfo.shmmin); + TUNABLE_ULONG_FETCH("kern.ipc.shmmni", &shminfo.shmmni); + TUNABLE_ULONG_FETCH("kern.ipc.shmseg", &shminfo.shmseg); + TUNABLE_INT_FETCH("kern.ipc.shm_use_phys", &shm_use_phys); + shmalloced = shminfo.shmmni; shmsegs = malloc(shmalloced * sizeof(shmsegs[0]), M_SHM, M_WAITOK); for (i = 0; i < shmalloced; i++) { diff --git a/sys/kern/vfs_init.c b/sys/kern/vfs_init.c index 66a6b00df0634..eab48fbea7982 100644 --- a/sys/kern/vfs_init.c +++ b/sys/kern/vfs_init.c @@ -72,6 +72,7 @@ struct vfsconfhead vfsconf = TAILQ_HEAD_INITIALIZER(vfsconf); * changing for file systems that use vfc_typenum in their fsid. */ static int vfs_typenumhash = 1; +TUNABLE_INT("vfs.typenumhash", &vfs_typenumhash); SYSCTL_INT(_vfs, OID_AUTO, typenumhash, CTLFLAG_RDTUN, &vfs_typenumhash, 0, "Set vfc_typenum using a hash calculation on vfc_name, so that it does not" "change when file systems are loaded in a different order."); @@ -212,7 +213,7 @@ vfs_register(struct vfsconf *vfc) * number. */ sysctl_lock(); - SLIST_FOREACH(oidp, SYSCTL_CHILDREN(&sysctl___vfs), oid_link) + SLIST_FOREACH(oidp, &sysctl__vfs_children, oid_link) if (strcmp(oidp->oid_name, vfc->vfc_name) == 0) { sysctl_unregister_oid(oidp); oidp->oid_number = vfc->vfc_typenum; diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index f466ca4682566..00dd496e9e37f 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -96,8 +96,9 @@ nameiinit(void *dummy __unused) SYSINIT(vfs, SI_SUB_VFS, SI_ORDER_SECOND, nameiinit, NULL); static int lookup_shared = 1; -SYSCTL_INT(_vfs, OID_AUTO, lookup_shared, CTLFLAG_RWTUN, &lookup_shared, 0, +SYSCTL_INT(_vfs, OID_AUTO, lookup_shared, CTLFLAG_RW, &lookup_shared, 0, "Enables/Disables shared locks for path name translation"); +TUNABLE_INT("vfs.lookup_shared", &lookup_shared); /* * Convert a pathname into a pointer to a locked vnode. diff --git a/sys/mips/cavium/usb/octusb.c b/sys/mips/cavium/usb/octusb.c index c4d4ac76d8ac0..cad3ef5ef2110 100644 --- a/sys/mips/cavium/usb/octusb.c +++ b/sys/mips/cavium/usb/octusb.c @@ -82,8 +82,11 @@ __FBSDID("$FreeBSD$"); static int octusbdebug = 0; static SYSCTL_NODE(_hw_usb, OID_AUTO, octusb, CTLFLAG_RW, 0, "OCTUSB"); -SYSCTL_INT(_hw_usb_octusb, OID_AUTO, debug, CTLFLAG_RWTUN, +SYSCTL_INT(_hw_usb_octusb, OID_AUTO, debug, CTLFLAG_RW, &octusbdebug, 0, "OCTUSB debug level"); + +TUNABLE_INT("hw.usb.octusb.debug", &octusbdebug); + #endif struct octusb_std_temp { diff --git a/sys/mips/mips/dump_machdep.c b/sys/mips/mips/dump_machdep.c index 54224f285ea15..bf8c4a3152f3d 100644 --- a/sys/mips/mips/dump_machdep.c +++ b/sys/mips/mips/dump_machdep.c @@ -50,7 +50,8 @@ __FBSDID("$FreeBSD$"); CTASSERT(sizeof(struct kerneldumpheader) == 512); int do_minidump = 1; -SYSCTL_INT(_debug, OID_AUTO, minidump, CTLFLAG_RWTUN, &do_minidump, 0, +TUNABLE_INT("debug.minidump", &do_minidump); +SYSCTL_INT(_debug, OID_AUTO, minidump, CTLFLAG_RW, &do_minidump, 0, "Enable mini crash dumps"); /* diff --git a/sys/mips/rt305x/uart_dev_rt305x.c b/sys/mips/rt305x/uart_dev_rt305x.c index d4f23196d0530..3154cb97437ff 100644 --- a/sys/mips/rt305x/uart_dev_rt305x.c +++ b/sys/mips/rt305x/uart_dev_rt305x.c @@ -73,9 +73,13 @@ static struct uart_ops uart_rt305x_uart_ops = { }; static int uart_output = 1; -SYSCTL_INT(_kern, OID_AUTO, uart_output, CTLFLAG_RWTUN, +TUNABLE_INT("kern.uart_output", &uart_output); +SYSCTL_INT(_kern, OID_AUTO, uart_output, CTLFLAG_RW, &uart_output, 0, "UART output enabled."); + + + static int rt305x_uart_probe(struct uart_bas *bas) { diff --git a/sys/net/ieee8023ad_lacp.c b/sys/net/ieee8023ad_lacp.c index 12cc721761876..aa38efabd50da 100644 --- a/sys/net/ieee8023ad_lacp.c +++ b/sys/net/ieee8023ad_lacp.c @@ -192,8 +192,9 @@ static void lacp_dprintf(const struct lacp_port *, const char *, ...) static int lacp_debug = 0; SYSCTL_NODE(_net_link_lagg, OID_AUTO, lacp, CTLFLAG_RD, 0, "ieee802.3ad"); -SYSCTL_INT(_net_link_lagg_lacp, OID_AUTO, debug, CTLFLAG_RWTUN, +SYSCTL_INT(_net_link_lagg_lacp, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, &lacp_debug, 0, "Enable LACP debug logging (1=debug, 2=trace)"); +TUNABLE_INT("net.link.lagg.lacp.debug", &lacp_debug); #define LACP_DPRINTF(a) if (lacp_debug & 0x01) { lacp_dprintf a ; } #define LACP_TRACE(a) if (lacp_debug & 0x02) { lacp_dprintf(a,"%s\n",__func__); } diff --git a/sys/net/if.c b/sys/net/if.c index 5a05c97af18c7..47b5b9d687a7f 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -106,6 +106,7 @@ struct ifindex_entry { SYSCTL_NODE(_net, PF_LINK, link, CTLFLAG_RW, 0, "Link layers"); SYSCTL_NODE(_net_link, 0, generic, CTLFLAG_RW, 0, "Generic link-management"); +TUNABLE_INT("net.link.ifqmaxlen", &ifqmaxlen); SYSCTL_INT(_net_link, OID_AUTO, ifqmaxlen, CTLFLAG_RDTUN, &ifqmaxlen, 0, "max send queue size"); diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c index 59d63ee4f2278..4e085731feeae 100644 --- a/sys/net/if_bridge.c +++ b/sys/net/if_bridge.c @@ -359,20 +359,27 @@ static int pfil_local_phys = 0; /* run pfil hooks on the physical interface for locally destined packets */ static int log_stp = 0; /* log STP state changes */ static int bridge_inherit_mac = 0; /* share MAC with first bridge member */ -SYSCTL_INT(_net_link_bridge, OID_AUTO, pfil_onlyip, CTLFLAG_RWTUN, +TUNABLE_INT("net.link.bridge.pfil_onlyip", &pfil_onlyip); +SYSCTL_INT(_net_link_bridge, OID_AUTO, pfil_onlyip, CTLFLAG_RW, &pfil_onlyip, 0, "Only pass IP packets when pfil is enabled"); -SYSCTL_INT(_net_link_bridge, OID_AUTO, ipfw_arp, CTLFLAG_RWTUN, +TUNABLE_INT("net.link.bridge.ipfw_arp", &pfil_ipfw_arp); +SYSCTL_INT(_net_link_bridge, OID_AUTO, ipfw_arp, CTLFLAG_RW, &pfil_ipfw_arp, 0, "Filter ARP packets through IPFW layer2"); -SYSCTL_INT(_net_link_bridge, OID_AUTO, pfil_bridge, CTLFLAG_RWTUN, +TUNABLE_INT("net.link.bridge.pfil_bridge", &pfil_bridge); +SYSCTL_INT(_net_link_bridge, OID_AUTO, pfil_bridge, CTLFLAG_RW, &pfil_bridge, 0, "Packet filter on the bridge interface"); -SYSCTL_INT(_net_link_bridge, OID_AUTO, pfil_member, CTLFLAG_RWTUN, +TUNABLE_INT("net.link.bridge.pfil_member", &pfil_member); +SYSCTL_INT(_net_link_bridge, OID_AUTO, pfil_member, CTLFLAG_RW, &pfil_member, 0, "Packet filter on the member interface"); -SYSCTL_INT(_net_link_bridge, OID_AUTO, pfil_local_phys, CTLFLAG_RWTUN, +TUNABLE_INT("net.link.bridge.pfil_local_phys", &pfil_local_phys); +SYSCTL_INT(_net_link_bridge, OID_AUTO, pfil_local_phys, CTLFLAG_RW, &pfil_local_phys, 0, "Packet filter on the physical interface for locally destined packets"); -SYSCTL_INT(_net_link_bridge, OID_AUTO, log_stp, CTLFLAG_RWTUN, +TUNABLE_INT("net.link.bridge.log_stp", &log_stp); +SYSCTL_INT(_net_link_bridge, OID_AUTO, log_stp, CTLFLAG_RW, &log_stp, 0, "Log STP state changes"); -SYSCTL_INT(_net_link_bridge, OID_AUTO, inherit_mac, CTLFLAG_RWTUN, +TUNABLE_INT("net.link.bridge.inherit_mac", &bridge_inherit_mac); +SYSCTL_INT(_net_link_bridge, OID_AUTO, inherit_mac, CTLFLAG_RW, &bridge_inherit_mac, 0, "Inherit MAC address from the first bridge member"); diff --git a/sys/net/if_lagg.c b/sys/net/if_lagg.c index ec868e1271609..1bab4f948e3ba 100644 --- a/sys/net/if_lagg.c +++ b/sys/net/if_lagg.c @@ -180,11 +180,13 @@ SYSCTL_INT(_net_link_lagg, OID_AUTO, failover_rx_all, CTLFLAG_RW, &lagg_failover_rx_all, 0, "Accept input from any interface in a failover lagg"); static int def_use_flowid = 1; /* Default value for using M_FLOWID */ -SYSCTL_INT(_net_link_lagg, OID_AUTO, default_use_flowid, CTLFLAG_RWTUN, +TUNABLE_INT("net.link.lagg.default_use_flowid", &def_use_flowid); +SYSCTL_INT(_net_link_lagg, OID_AUTO, default_use_flowid, CTLFLAG_RW, &def_use_flowid, 0, "Default setting for using flow id for load sharing"); static int def_flowid_shift = 16; /* Default value for using M_FLOWID */ -SYSCTL_INT(_net_link_lagg, OID_AUTO, default_flowid_shift, CTLFLAG_RWTUN, +TUNABLE_INT("net.link.lagg.default_flowid_shift", &def_flowid_shift); +SYSCTL_INT(_net_link_lagg, OID_AUTO, default_flowid_shift, CTLFLAG_RW, &def_flowid_shift, 0, "Default setting for flowid shift for load sharing"); diff --git a/sys/net/if_stf.c b/sys/net/if_stf.c index 8578818472cfe..28888edff5f46 100644 --- a/sys/net/if_stf.c +++ b/sys/net/if_stf.c @@ -129,7 +129,8 @@ SYSCTL_INT(_net_link_stf, OID_AUTO, route_cache, CTLFLAG_RW, &stf_route_cache, 0, "Caching of IPv4 routes for 6to4 Output"); static int stf_permit_rfc1918 = 0; -SYSCTL_INT(_net_link_stf, OID_AUTO, permit_rfc1918, CTLFLAG_RWTUN, +TUNABLE_INT("net.link.stf.permit_rfc1918", &stf_permit_rfc1918); +SYSCTL_INT(_net_link_stf, OID_AUTO, permit_rfc1918, CTLFLAG_RW | CTLFLAG_TUN, &stf_permit_rfc1918, 0, "Permit the use of private IPv4 addresses"); #define STFUNIT 0 diff --git a/sys/net/if_tap.c b/sys/net/if_tap.c index 89cac22f264e8..d788635a59e14 100644 --- a/sys/net/if_tap.c +++ b/sys/net/if_tap.c @@ -170,10 +170,12 @@ SYSCTL_INT(_net_link_tap, OID_AUTO, user_open, CTLFLAG_RW, &tapuopen, 0, "Allow user to open /dev/tap (based on node permissions)"); SYSCTL_INT(_net_link_tap, OID_AUTO, up_on_open, CTLFLAG_RW, &tapuponopen, 0, "Bring interface up when /dev/tap is opened"); -SYSCTL_INT(_net_link_tap, OID_AUTO, devfs_cloning, CTLFLAG_RWTUN, &tapdclone, 0, +SYSCTL_INT(_net_link_tap, OID_AUTO, devfs_cloning, CTLFLAG_RW, &tapdclone, 0, "Enably legacy devfs interface creation"); SYSCTL_INT(_net_link_tap, OID_AUTO, debug, CTLFLAG_RW, &tapdebug, 0, ""); +TUNABLE_INT("net.link.tap.devfs_cloning", &tapdclone); + DEV_MODULE(if_tap, tapmodevent, NULL); static int diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index e4bc2afc7afc1..504bab0503671 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -116,9 +116,11 @@ SYSCTL_INT(_debug, OID_AUTO, if_tun_debug, CTLFLAG_RW, &tundebug, 0, ""); SYSCTL_DECL(_net_link); static SYSCTL_NODE(_net_link, OID_AUTO, tun, CTLFLAG_RW, 0, "IP tunnel software network interface."); -SYSCTL_INT(_net_link_tun, OID_AUTO, devfs_cloning, CTLFLAG_RWTUN, &tundclone, 0, +SYSCTL_INT(_net_link_tun, OID_AUTO, devfs_cloning, CTLFLAG_RW, &tundclone, 0, "Enable legacy devfs interface creation."); +TUNABLE_INT("net.link.tun.devfs_cloning", &tundclone); + static void tunclone(void *arg, struct ucred *cred, char *name, int namelen, struct cdev **dev); static void tuncreate(const char *name, struct cdev *dev); diff --git a/sys/net/netisr.c b/sys/net/netisr.c index 049bbf192b538..7974cc891ea13 100644 --- a/sys/net/netisr.c +++ b/sys/net/netisr.c @@ -149,8 +149,8 @@ static SYSCTL_NODE(_net, OID_AUTO, isr, CTLFLAG_RW, 0, "netisr"); #define NETISR_DISPATCH_POLICY_MAXSTR 20 /* Used for temporary buffers. */ static u_int netisr_dispatch_policy = NETISR_DISPATCH_POLICY_DEFAULT; static int sysctl_netisr_dispatch_policy(SYSCTL_HANDLER_ARGS); -SYSCTL_PROC(_net_isr, OID_AUTO, dispatch, CTLTYPE_STRING | CTLFLAG_RWTUN, - 0, 0, sysctl_netisr_dispatch_policy, "A", +SYSCTL_PROC(_net_isr, OID_AUTO, dispatch, CTLTYPE_STRING | CTLFLAG_RW | + CTLFLAG_TUN, 0, 0, sysctl_netisr_dispatch_policy, "A", "netisr dispatch policy"); /* @@ -160,11 +160,13 @@ SYSCTL_PROC(_net_isr, OID_AUTO, dispatch, CTLTYPE_STRING | CTLFLAG_RWTUN, * We will create at most one thread per CPU. */ static int netisr_maxthreads = -1; /* Max number of threads. */ +TUNABLE_INT("net.isr.maxthreads", &netisr_maxthreads); SYSCTL_INT(_net_isr, OID_AUTO, maxthreads, CTLFLAG_RDTUN, &netisr_maxthreads, 0, "Use at most this many CPUs for netisr processing"); static int netisr_bindthreads = 0; /* Bind threads to CPUs. */ +TUNABLE_INT("net.isr.bindthreads", &netisr_bindthreads); SYSCTL_INT(_net_isr, OID_AUTO, bindthreads, CTLFLAG_RDTUN, &netisr_bindthreads, 0, "Bind netisr threads to CPUs."); @@ -175,6 +177,7 @@ SYSCTL_INT(_net_isr, OID_AUTO, bindthreads, CTLFLAG_RDTUN, */ #define NETISR_DEFAULT_MAXQLIMIT 10240 static u_int netisr_maxqlimit = NETISR_DEFAULT_MAXQLIMIT; +TUNABLE_INT("net.isr.maxqlimit", &netisr_maxqlimit); SYSCTL_UINT(_net_isr, OID_AUTO, maxqlimit, CTLFLAG_RDTUN, &netisr_maxqlimit, 0, "Maximum netisr per-protocol, per-CPU queue depth."); @@ -186,6 +189,7 @@ SYSCTL_UINT(_net_isr, OID_AUTO, maxqlimit, CTLFLAG_RDTUN, */ #define NETISR_DEFAULT_DEFAULTQLIMIT 256 static u_int netisr_defaultqlimit = NETISR_DEFAULT_DEFAULTQLIMIT; +TUNABLE_INT("net.isr.defaultqlimit", &netisr_defaultqlimit); SYSCTL_UINT(_net_isr, OID_AUTO, defaultqlimit, CTLFLAG_RDTUN, &netisr_defaultqlimit, 0, "Default netisr per-protocol, per-CPU queue limit if not set by protocol"); @@ -1116,6 +1120,10 @@ netisr_start_swi(u_int cpuid, struct pcpu *pc) static void netisr_init(void *arg) { + char tmp[NETISR_DISPATCH_POLICY_MAXSTR]; + u_int dispatch_policy; + int error; + KASSERT(curcpu == 0, ("%s: not on CPU 0", __func__)); NETISR_LOCK_INIT(); @@ -1144,6 +1152,20 @@ netisr_init(void *arg) netisr_bindthreads = 0; } #endif + + if (TUNABLE_STR_FETCH("net.isr.dispatch", tmp, sizeof(tmp))) { + error = netisr_dispatch_policy_from_str(tmp, + &dispatch_policy); + if (error == 0 && dispatch_policy == NETISR_DISPATCH_DEFAULT) + error = EINVAL; + if (error == 0) + netisr_dispatch_policy = dispatch_policy; + else + printf( + "%s: invalid dispatch policy %s, using default\n", + __func__, tmp); + } + netisr_start_swi(curcpu, pcpu_find(curcpu)); } SYSINIT(netisr_init, SI_SUB_SOFTINTR, SI_ORDER_FIRST, netisr_init, NULL); diff --git a/sys/net/route.c b/sys/net/route.c index 547418af84b9c..83cc857ef7b28 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -96,7 +96,9 @@ extern void sctp_addr_change(struct ifaddr *ifa, int cmd); /* This is read-only.. */ u_int rt_numfibs = RT_NUMFIBS; -SYSCTL_UINT(_net, OID_AUTO, fibs, CTLFLAG_RDTUN, &rt_numfibs, 0, ""); +SYSCTL_UINT(_net, OID_AUTO, fibs, CTLFLAG_RD, &rt_numfibs, 0, ""); +/* and this can be set too big but will be fixed before it is used */ +TUNABLE_INT("net.fibs", &rt_numfibs); /* * By default add routes to all fibs for new interfaces. @@ -109,8 +111,9 @@ SYSCTL_UINT(_net, OID_AUTO, fibs, CTLFLAG_RDTUN, &rt_numfibs, 0, ""); * from the network stack context. */ u_int rt_add_addr_allfibs = 1; -SYSCTL_UINT(_net, OID_AUTO, add_addr_allfibs, CTLFLAG_RWTUN, +SYSCTL_UINT(_net, OID_AUTO, add_addr_allfibs, CTLFLAG_RW, &rt_add_addr_allfibs, 0, ""); +TUNABLE_INT("net.add_addr_allfibs", &rt_add_addr_allfibs); VNET_DEFINE(struct rtstat, rtstat); #define V_rtstat VNET(rtstat) diff --git a/sys/netgraph/ng_base.c b/sys/netgraph/ng_base.c index 1970965e2e25c..e83967be8f07a 100644 --- a/sys/netgraph/ng_base.c +++ b/sys/netgraph/ng_base.c @@ -2954,10 +2954,13 @@ static int numthreads = 0; /* number of queue threads */ static int maxalloc = 4096;/* limit the damage of a leak */ static int maxdata = 512; /* limit the damage of a DoS */ +TUNABLE_INT("net.graph.threads", &numthreads); SYSCTL_INT(_net_graph, OID_AUTO, threads, CTLFLAG_RDTUN, &numthreads, 0, "Number of queue processing threads"); +TUNABLE_INT("net.graph.maxalloc", &maxalloc); SYSCTL_INT(_net_graph, OID_AUTO, maxalloc, CTLFLAG_RDTUN, &maxalloc, 0, "Maximum number of non-data queue items to allocate"); +TUNABLE_INT("net.graph.maxdata", &maxdata); SYSCTL_INT(_net_graph, OID_AUTO, maxdata, CTLFLAG_RDTUN, &maxdata, 0, "Maximum number of data queue items to allocate"); diff --git a/sys/netgraph/ng_mppc.c b/sys/netgraph/ng_mppc.c index 76f4c3b89b4fe..14d44de49dc07 100644 --- a/sys/netgraph/ng_mppc.c +++ b/sys/netgraph/ng_mppc.c @@ -111,15 +111,18 @@ static MALLOC_DEFINE(M_NETGRAPH_MPPC, "netgraph_mppc", "netgraph mppc node"); SYSCTL_NODE(_net_graph, OID_AUTO, mppe, CTLFLAG_RW, 0, "MPPE"); static int mppe_block_on_max_rekey = 0; -SYSCTL_INT(_net_graph_mppe, OID_AUTO, block_on_max_rekey, CTLFLAG_RWTUN, +TUNABLE_INT("net.graph.mppe.block_on_max_rekey", &mppe_block_on_max_rekey); +SYSCTL_INT(_net_graph_mppe, OID_AUTO, block_on_max_rekey, CTLFLAG_RW, &mppe_block_on_max_rekey, 0, "Block node on max MPPE key re-calculations"); static int mppe_log_max_rekey = 1; -SYSCTL_INT(_net_graph_mppe, OID_AUTO, log_max_rekey, CTLFLAG_RWTUN, +TUNABLE_INT("net.graph.mppe.log_max_rekey", &mppe_log_max_rekey); +SYSCTL_INT(_net_graph_mppe, OID_AUTO, log_max_rekey, CTLFLAG_RW, &mppe_log_max_rekey, 0, "Log max MPPE key re-calculations event"); static int mppe_max_rekey = MPPE_MAX_REKEY; -SYSCTL_INT(_net_graph_mppe, OID_AUTO, max_rekey, CTLFLAG_RWTUN, +TUNABLE_INT("net.graph.mppe.max_rekey", &mppe_max_rekey); +SYSCTL_INT(_net_graph_mppe, OID_AUTO, max_rekey, CTLFLAG_RW, &mppe_max_rekey, 0, "Maximum number of MPPE key re-calculations"); /* MPPC packet header bits */ diff --git a/sys/netinet/in_mcast.c b/sys/netinet/in_mcast.c index 26d4e8e3a135b..d996bd189281d 100644 --- a/sys/netinet/in_mcast.c +++ b/sys/netinet/in_mcast.c @@ -166,17 +166,20 @@ static SYSCTL_NODE(_net_inet_ip, OID_AUTO, mcast, CTLFLAG_RW, 0, static u_long in_mcast_maxgrpsrc = IP_MAX_GROUP_SRC_FILTER; SYSCTL_ULONG(_net_inet_ip_mcast, OID_AUTO, maxgrpsrc, - CTLFLAG_RWTUN, &in_mcast_maxgrpsrc, 0, + CTLFLAG_RW | CTLFLAG_TUN, &in_mcast_maxgrpsrc, 0, "Max source filters per group"); +TUNABLE_ULONG("net.inet.ip.mcast.maxgrpsrc", &in_mcast_maxgrpsrc); static u_long in_mcast_maxsocksrc = IP_MAX_SOCK_SRC_FILTER; SYSCTL_ULONG(_net_inet_ip_mcast, OID_AUTO, maxsocksrc, - CTLFLAG_RWTUN, &in_mcast_maxsocksrc, 0, + CTLFLAG_RW | CTLFLAG_TUN, &in_mcast_maxsocksrc, 0, "Max source filters per socket"); +TUNABLE_ULONG("net.inet.ip.mcast.maxsocksrc", &in_mcast_maxsocksrc); int in_mcast_loop = IP_DEFAULT_MULTICAST_LOOP; -SYSCTL_INT(_net_inet_ip_mcast, OID_AUTO, loop, CTLFLAG_RWTUN, +SYSCTL_INT(_net_inet_ip_mcast, OID_AUTO, loop, CTLFLAG_RW | CTLFLAG_TUN, &in_mcast_loop, 0, "Loopback multicast datagrams by default"); +TUNABLE_INT("net.inet.ip.mcast.loop", &in_mcast_loop); static SYSCTL_NODE(_net_inet_ip_mcast, OID_AUTO, filters, CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_ip_mcast_filters, diff --git a/sys/netinet/in_rss.c b/sys/netinet/in_rss.c index 4e6a454e1319d..698373fa7aa24 100644 --- a/sys/netinet/in_rss.c +++ b/sys/netinet/in_rss.c @@ -91,8 +91,9 @@ SYSCTL_NODE(_net_inet, OID_AUTO, rss, CTLFLAG_RW, 0, "Receive-side steering"); * default. */ static u_int rss_hashalgo = RSS_HASH_TOEPLITZ; -SYSCTL_INT(_net_inet_rss, OID_AUTO, hashalgo, CTLFLAG_RDTUN, &rss_hashalgo, 0, +SYSCTL_INT(_net_inet_rss, OID_AUTO, hashalgo, CTLFLAG_RD, &rss_hashalgo, 0, "RSS hash algorithm"); +TUNABLE_INT("net.inet.rss.hashalgo", &rss_hashalgo); /* * Size of the indirection table; at most 128 entries per the RSS spec. We @@ -103,8 +104,9 @@ SYSCTL_INT(_net_inet_rss, OID_AUTO, hashalgo, CTLFLAG_RDTUN, &rss_hashalgo, 0, * XXXRW: buckets might be better to use for the tunable than bits. */ static u_int rss_bits; -SYSCTL_INT(_net_inet_rss, OID_AUTO, bits, CTLFLAG_RDTUN, &rss_bits, 0, +SYSCTL_INT(_net_inet_rss, OID_AUTO, bits, CTLFLAG_RD, &rss_bits, 0, "RSS bits"); +TUNABLE_INT("net.inet.rss.bits", &rss_bits); static u_int rss_mask; SYSCTL_INT(_net_inet_rss, OID_AUTO, mask, CTLFLAG_RD, &rss_mask, 0, diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index ac0aad31bc50e..fb2c415aee986 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -188,8 +188,8 @@ static int tcp_log_debug = 0; SYSCTL_INT(_net_inet_tcp, OID_AUTO, log_debug, CTLFLAG_RW, &tcp_log_debug, 0, "Log errors caused by incoming TCP segments"); -static int tcp_tcbhashsize; -SYSCTL_INT(_net_inet_tcp, OID_AUTO, tcbhashsize, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, +static int tcp_tcbhashsize = 0; +SYSCTL_INT(_net_inet_tcp, OID_AUTO, tcbhashsize, CTLFLAG_RDTUN, &tcp_tcbhashsize, 0, "Size of TCP control-block hashtable"); static int do_tcpdrain = 1; @@ -211,7 +211,7 @@ SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, isn_reseed_interval, CTLFLAG_RW, &VNET_NAME(tcp_isn_reseed_interval), 0, "Seconds between reseeding of ISN secret"); -static int tcp_soreceive_stream; +static int tcp_soreceive_stream = 0; SYSCTL_INT(_net_inet_tcp, OID_AUTO, soreceive_stream, CTLFLAG_RDTUN, &tcp_soreceive_stream, 0, "Using soreceive_stream for TCP sockets"); @@ -398,6 +398,7 @@ tcp_init(void) tcp_finwait2_timeout = TCPTV_FINWAIT2_TIMEOUT; tcp_tcbhashsize = hashsize; + TUNABLE_INT_FETCH("net.inet.tcp.soreceive_stream", &tcp_soreceive_stream); if (tcp_soreceive_stream) { #ifdef INET tcp_usrreqs.pru_soreceive = soreceive_stream; diff --git a/sys/netinet6/in6_mcast.c b/sys/netinet6/in6_mcast.c index f9ff10a302f30..d259997635019 100644 --- a/sys/netinet6/in6_mcast.c +++ b/sys/netinet6/in6_mcast.c @@ -158,18 +158,21 @@ static SYSCTL_NODE(_net_inet6_ip6, OID_AUTO, mcast, CTLFLAG_RW, 0, static u_long in6_mcast_maxgrpsrc = IPV6_MAX_GROUP_SRC_FILTER; SYSCTL_ULONG(_net_inet6_ip6_mcast, OID_AUTO, maxgrpsrc, - CTLFLAG_RWTUN, &in6_mcast_maxgrpsrc, 0, + CTLFLAG_RW | CTLFLAG_TUN, &in6_mcast_maxgrpsrc, 0, "Max source filters per group"); +TUNABLE_ULONG("net.inet6.ip6.mcast.maxgrpsrc", &in6_mcast_maxgrpsrc); static u_long in6_mcast_maxsocksrc = IPV6_MAX_SOCK_SRC_FILTER; SYSCTL_ULONG(_net_inet6_ip6_mcast, OID_AUTO, maxsocksrc, - CTLFLAG_RWTUN, &in6_mcast_maxsocksrc, 0, + CTLFLAG_RW | CTLFLAG_TUN, &in6_mcast_maxsocksrc, 0, "Max source filters per socket"); +TUNABLE_ULONG("net.inet6.ip6.mcast.maxsocksrc", &in6_mcast_maxsocksrc); /* TODO Virtualize this switch. */ int in6_mcast_loop = IPV6_DEFAULT_MULTICAST_LOOP; -SYSCTL_INT(_net_inet6_ip6_mcast, OID_AUTO, loop, CTLFLAG_RWTUN, +SYSCTL_INT(_net_inet6_ip6_mcast, OID_AUTO, loop, CTLFLAG_RW | CTLFLAG_TUN, &in6_mcast_loop, 0, "Loopback multicast datagrams by default"); +TUNABLE_INT("net.inet6.ip6.mcast.loop", &in6_mcast_loop); static SYSCTL_NODE(_net_inet6_ip6_mcast, OID_AUTO, filters, CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_ip6_mcast_filters, diff --git a/sys/netinet6/mld6.c b/sys/netinet6/mld6.c index 2e46208ce73b7..c40ef9e3dee56 100644 --- a/sys/netinet6/mld6.c +++ b/sys/netinet6/mld6.c @@ -238,12 +238,14 @@ static SYSCTL_NODE(_net_inet6_mld, OID_AUTO, ifinfo, "Per-interface MLDv2 state"); static int mld_v1enable = 1; -SYSCTL_INT(_net_inet6_mld, OID_AUTO, v1enable, CTLFLAG_RWTUN, +SYSCTL_INT(_net_inet6_mld, OID_AUTO, v1enable, CTLFLAG_RW, &mld_v1enable, 0, "Enable fallback to MLDv1"); +TUNABLE_INT("net.inet6.mld.v1enable", &mld_v1enable); static int mld_use_allow = 1; -SYSCTL_INT(_net_inet6_mld, OID_AUTO, use_allow, CTLFLAG_RWTUN, +SYSCTL_INT(_net_inet6_mld, OID_AUTO, use_allow, CTLFLAG_RW, &mld_use_allow, 0, "Use ALLOW/BLOCK for RFC 4604 SSM joins/leaves"); +TUNABLE_INT("net.inet6.mld.use_allow", &mld_use_allow); /* * Packed Router Alert option structure declaration. diff --git a/sys/netpfil/ipfw/ip_fw2.c b/sys/netpfil/ipfw/ip_fw2.c index 91900919e140e..ecb0f2dc8169a 100644 --- a/sys/netpfil/ipfw/ip_fw2.c +++ b/sys/netpfil/ipfw/ip_fw2.c @@ -181,6 +181,7 @@ SYSCTL_VNET_PROC(_net_inet_ip_fw, OID_AUTO, tables_max, SYSCTL_INT(_net_inet_ip_fw, OID_AUTO, default_to_accept, CTLFLAG_RDTUN, &default_to_accept, 0, "Make the default rule accept all packets."); +TUNABLE_INT("net.inet.ip.fw.default_to_accept", &default_to_accept); TUNABLE_INT("net.inet.ip.fw.tables_max", (int *)&default_fw_tables); SYSCTL_VNET_INT(_net_inet_ip_fw, OID_AUTO, static_count, CTLFLAG_RD, &VNET_NAME(layer3_chain.n_rules), 0, diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index 6c971516e5601..094520147cd22 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -743,8 +743,10 @@ pf_initialize() struct pf_srchash *sh; u_int i; + TUNABLE_ULONG_FETCH("net.pf.states_hashsize", &pf_hashsize); if (pf_hashsize == 0 || !powerof2(pf_hashsize)) pf_hashsize = PF_HASHSIZ; + TUNABLE_ULONG_FETCH("net.pf.source_nodes_hashsize", &pf_srchashsize); if (pf_srchashsize == 0 || !powerof2(pf_srchashsize)) pf_srchashsize = PF_HASHSIZ / 4; diff --git a/sys/pc98/cbus/sio.c b/sys/pc98/cbus/sio.c index d128658bf2224..754d4ad12cbb5 100644 --- a/sys/pc98/cbus/sio.c +++ b/sys/pc98/cbus/sio.c @@ -704,7 +704,7 @@ sysctl_machdep_comdefaultrate(SYSCTL_HANDLER_ARGS) return error; } -SYSCTL_PROC(_machdep, OID_AUTO, conspeed, CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NOFETCH, +SYSCTL_PROC(_machdep, OID_AUTO, conspeed, CTLTYPE_INT | CTLFLAG_RW, 0, 0, sysctl_machdep_comdefaultrate, "I", ""); TUNABLE_INT("machdep.conspeed", __DEVOLATILE(int *, &comdefaultrate)); diff --git a/sys/pc98/pc98/machdep.c b/sys/pc98/pc98/machdep.c index f7883c4410824..b9c6a4ef235c9 100644 --- a/sys/pc98/pc98/machdep.c +++ b/sys/pc98/pc98/machdep.c @@ -1113,7 +1113,8 @@ cpu_halt(void) } static int idle_mwait = 1; /* Use MONITOR/MWAIT for short idle. */ -SYSCTL_INT(_machdep, OID_AUTO, idle_mwait, CTLFLAG_RWTUN, &idle_mwait, +TUNABLE_INT("machdep.idle_mwait", &idle_mwait); +SYSCTL_INT(_machdep, OID_AUTO, idle_mwait, CTLFLAG_RW, &idle_mwait, 0, "Use MONITOR/MWAIT for short idle"); #define STATE_RUNNING 0x0 diff --git a/sys/pc98/pc98/pc98_machdep.c b/sys/pc98/pc98/pc98_machdep.c index 9f9fbcc347f27..aed4eaa6f1415 100644 --- a/sys/pc98/pc98/pc98_machdep.c +++ b/sys/pc98/pc98/pc98_machdep.c @@ -49,7 +49,8 @@ static int ad_geom_method = AD_GEOM_ADJUST_COMPATIDE; -SYSCTL_INT(_machdep, OID_AUTO, ad_geom_method, CTLFLAG_RWTUN, &ad_geom_method, 0, +TUNABLE_INT("machdep.ad_geom_method", &ad_geom_method); +SYSCTL_INT(_machdep, OID_AUTO, ad_geom_method, CTLFLAG_RW, &ad_geom_method, 0, "IDE disk geometry conversion method"); /* diff --git a/sys/security/mac_biba/mac_biba.c b/sys/security/mac_biba/mac_biba.c index b5bf8c32dbef4..375b8a3eb795e 100644 --- a/sys/security/mac_biba/mac_biba.c +++ b/sys/security/mac_biba/mac_biba.c @@ -100,36 +100,43 @@ SYSCTL_INT(_security_mac_biba, OID_AUTO, label_size, CTLFLAG_RD, &biba_label_size, 0, "Size of struct mac_biba"); static int biba_enabled = 1; -SYSCTL_INT(_security_mac_biba, OID_AUTO, enabled, CTLFLAG_RWTUN, &biba_enabled, +SYSCTL_INT(_security_mac_biba, OID_AUTO, enabled, CTLFLAG_RW, &biba_enabled, 0, "Enforce MAC/Biba policy"); +TUNABLE_INT("security.mac.biba.enabled", &biba_enabled); static int destroyed_not_inited; SYSCTL_INT(_security_mac_biba, OID_AUTO, destroyed_not_inited, CTLFLAG_RD, &destroyed_not_inited, 0, "Count of labels destroyed but not inited"); static int trust_all_interfaces = 0; -SYSCTL_INT(_security_mac_biba, OID_AUTO, trust_all_interfaces, CTLFLAG_RDTUN, +SYSCTL_INT(_security_mac_biba, OID_AUTO, trust_all_interfaces, CTLFLAG_RD, &trust_all_interfaces, 0, "Consider all interfaces 'trusted' by MAC/Biba"); +TUNABLE_INT("security.mac.biba.trust_all_interfaces", &trust_all_interfaces); static char trusted_interfaces[128]; -SYSCTL_STRING(_security_mac_biba, OID_AUTO, trusted_interfaces, CTLFLAG_RDTUN, +SYSCTL_STRING(_security_mac_biba, OID_AUTO, trusted_interfaces, CTLFLAG_RD, trusted_interfaces, 0, "Interfaces considered 'trusted' by MAC/Biba"); +TUNABLE_STR("security.mac.biba.trusted_interfaces", trusted_interfaces, + sizeof(trusted_interfaces)); static int max_compartments = MAC_BIBA_MAX_COMPARTMENTS; SYSCTL_INT(_security_mac_biba, OID_AUTO, max_compartments, CTLFLAG_RD, &max_compartments, 0, "Maximum supported compartments"); static int ptys_equal = 0; -SYSCTL_INT(_security_mac_biba, OID_AUTO, ptys_equal, CTLFLAG_RWTUN, &ptys_equal, +SYSCTL_INT(_security_mac_biba, OID_AUTO, ptys_equal, CTLFLAG_RW, &ptys_equal, 0, "Label pty devices as biba/equal on create"); +TUNABLE_INT("security.mac.biba.ptys_equal", &ptys_equal); static int interfaces_equal = 1; -SYSCTL_INT(_security_mac_biba, OID_AUTO, interfaces_equal, CTLFLAG_RWTUN, +SYSCTL_INT(_security_mac_biba, OID_AUTO, interfaces_equal, CTLFLAG_RW, &interfaces_equal, 0, "Label network interfaces as biba/equal on create"); +TUNABLE_INT("security.mac.biba.interfaces_equal", &interfaces_equal); static int revocation_enabled = 0; -SYSCTL_INT(_security_mac_biba, OID_AUTO, revocation_enabled, CTLFLAG_RWTUN, +SYSCTL_INT(_security_mac_biba, OID_AUTO, revocation_enabled, CTLFLAG_RW, &revocation_enabled, 0, "Revoke access to objects on relabel"); +TUNABLE_INT("security.mac.biba.revocation_enabled", &revocation_enabled); static int biba_slot; #define SLOT(l) ((struct mac_biba *)mac_label_get((l), biba_slot)) diff --git a/sys/security/mac_bsdextended/mac_bsdextended.c b/sys/security/mac_bsdextended/mac_bsdextended.c index 377fd250ad2db..ccbc525552f8f 100644 --- a/sys/security/mac_bsdextended/mac_bsdextended.c +++ b/sys/security/mac_bsdextended/mac_bsdextended.c @@ -76,8 +76,9 @@ static SYSCTL_NODE(_security_mac, OID_AUTO, bsdextended, CTLFLAG_RW, 0, "TrustedBSD extended BSD MAC policy controls"); static int ugidfw_enabled = 1; -SYSCTL_INT(_security_mac_bsdextended, OID_AUTO, enabled, CTLFLAG_RWTUN, +SYSCTL_INT(_security_mac_bsdextended, OID_AUTO, enabled, CTLFLAG_RW, &ugidfw_enabled, 0, "Enforce extended BSD policy"); +TUNABLE_INT("security.mac.bsdextended.enabled", &ugidfw_enabled); static MALLOC_DEFINE(M_MACBSDEXTENDED, "mac_bsdextended", "BSD Extended MAC rule"); diff --git a/sys/security/mac_ifoff/mac_ifoff.c b/sys/security/mac_ifoff/mac_ifoff.c index 28097b502989a..7165f905c83d0 100644 --- a/sys/security/mac_ifoff/mac_ifoff.c +++ b/sys/security/mac_ifoff/mac_ifoff.c @@ -66,21 +66,25 @@ static SYSCTL_NODE(_security_mac, OID_AUTO, ifoff, CTLFLAG_RW, 0, "TrustedBSD mac_ifoff policy controls"); static int ifoff_enabled = 1; -SYSCTL_INT(_security_mac_ifoff, OID_AUTO, enabled, CTLFLAG_RWTUN, +SYSCTL_INT(_security_mac_ifoff, OID_AUTO, enabled, CTLFLAG_RW, &ifoff_enabled, 0, "Enforce ifoff policy"); +TUNABLE_INT("security.mac.ifoff.enabled", &ifoff_enabled); static int ifoff_lo_enabled = 1; -SYSCTL_INT(_security_mac_ifoff, OID_AUTO, lo_enabled, CTLFLAG_RWTUN, +SYSCTL_INT(_security_mac_ifoff, OID_AUTO, lo_enabled, CTLFLAG_RW, &ifoff_lo_enabled, 0, "Enable loopback interfaces"); +TUNABLE_INT("security.mac.ifoff.lo_enabled", &ifoff_lo_enabled); static int ifoff_other_enabled = 0; -SYSCTL_INT(_security_mac_ifoff, OID_AUTO, other_enabled, CTLFLAG_RWTUN, +SYSCTL_INT(_security_mac_ifoff, OID_AUTO, other_enabled, CTLFLAG_RW, &ifoff_other_enabled, 0, "Enable other interfaces"); +TUNABLE_INT("security.mac.ifoff.other_enabled", &ifoff_other_enabled); static int ifoff_bpfrecv_enabled = 0; -SYSCTL_INT(_security_mac_ifoff, OID_AUTO, bpfrecv_enabled, CTLFLAG_RWTUN, +SYSCTL_INT(_security_mac_ifoff, OID_AUTO, bpfrecv_enabled, CTLFLAG_RW, &ifoff_bpfrecv_enabled, 0, "Enable BPF reception even when interface " "is disabled"); +TUNABLE_INT("security.mac.ifoff.bpfrecv.enabled", &ifoff_bpfrecv_enabled); static int ifnet_check_outgoing(struct ifnet *ifp) diff --git a/sys/security/mac_lomac/mac_lomac.c b/sys/security/mac_lomac/mac_lomac.c index cf66423a91c6f..b2b9f74afb55f 100644 --- a/sys/security/mac_lomac/mac_lomac.c +++ b/sys/security/mac_lomac/mac_lomac.c @@ -101,28 +101,34 @@ SYSCTL_INT(_security_mac_lomac, OID_AUTO, label_size, CTLFLAG_RD, &lomac_label_size, 0, "Size of struct mac_lomac"); static int lomac_enabled = 1; -SYSCTL_INT(_security_mac_lomac, OID_AUTO, enabled, CTLFLAG_RWTUN, +SYSCTL_INT(_security_mac_lomac, OID_AUTO, enabled, CTLFLAG_RW, &lomac_enabled, 0, "Enforce MAC/LOMAC policy"); +TUNABLE_INT("security.mac.lomac.enabled", &lomac_enabled); static int destroyed_not_inited; SYSCTL_INT(_security_mac_lomac, OID_AUTO, destroyed_not_inited, CTLFLAG_RD, &destroyed_not_inited, 0, "Count of labels destroyed but not inited"); static int trust_all_interfaces = 0; -SYSCTL_INT(_security_mac_lomac, OID_AUTO, trust_all_interfaces, CTLFLAG_RDTUN, +SYSCTL_INT(_security_mac_lomac, OID_AUTO, trust_all_interfaces, CTLFLAG_RD, &trust_all_interfaces, 0, "Consider all interfaces 'trusted' by MAC/LOMAC"); +TUNABLE_INT("security.mac.lomac.trust_all_interfaces", &trust_all_interfaces); static char trusted_interfaces[128]; -SYSCTL_STRING(_security_mac_lomac, OID_AUTO, trusted_interfaces, CTLFLAG_RDTUN, +SYSCTL_STRING(_security_mac_lomac, OID_AUTO, trusted_interfaces, CTLFLAG_RD, trusted_interfaces, 0, "Interfaces considered 'trusted' by MAC/LOMAC"); +TUNABLE_STR("security.mac.lomac.trusted_interfaces", trusted_interfaces, + sizeof(trusted_interfaces)); static int ptys_equal = 0; -SYSCTL_INT(_security_mac_lomac, OID_AUTO, ptys_equal, CTLFLAG_RWTUN, +SYSCTL_INT(_security_mac_lomac, OID_AUTO, ptys_equal, CTLFLAG_RW, &ptys_equal, 0, "Label pty devices as lomac/equal on create"); +TUNABLE_INT("security.mac.lomac.ptys_equal", &ptys_equal); static int revocation_enabled = 1; -SYSCTL_INT(_security_mac_lomac, OID_AUTO, revocation_enabled, CTLFLAG_RWTUN, +SYSCTL_INT(_security_mac_lomac, OID_AUTO, revocation_enabled, CTLFLAG_RW, &revocation_enabled, 0, "Revoke access to objects on relabel"); +TUNABLE_INT("security.mac.lomac.revocation_enabled", &revocation_enabled); static int lomac_slot; #define SLOT(l) ((struct mac_lomac *)mac_label_get((l), lomac_slot)) diff --git a/sys/security/mac_mls/mac_mls.c b/sys/security/mac_mls/mac_mls.c index 6a074d0279bdb..d7ca5a55362f9 100644 --- a/sys/security/mac_mls/mac_mls.c +++ b/sys/security/mac_mls/mac_mls.c @@ -101,20 +101,23 @@ SYSCTL_INT(_security_mac_mls, OID_AUTO, label_size, CTLFLAG_RD, &mls_label_size, 0, "Size of struct mac_mls"); static int mls_enabled = 1; -SYSCTL_INT(_security_mac_mls, OID_AUTO, enabled, CTLFLAG_RWTUN, &mls_enabled, 0, +SYSCTL_INT(_security_mac_mls, OID_AUTO, enabled, CTLFLAG_RW, &mls_enabled, 0, "Enforce MAC/MLS policy"); +TUNABLE_INT("security.mac.mls.enabled", &mls_enabled); static int destroyed_not_inited; SYSCTL_INT(_security_mac_mls, OID_AUTO, destroyed_not_inited, CTLFLAG_RD, &destroyed_not_inited, 0, "Count of labels destroyed but not inited"); static int ptys_equal = 0; -SYSCTL_INT(_security_mac_mls, OID_AUTO, ptys_equal, CTLFLAG_RWTUN, +SYSCTL_INT(_security_mac_mls, OID_AUTO, ptys_equal, CTLFLAG_RW, &ptys_equal, 0, "Label pty devices as mls/equal on create"); +TUNABLE_INT("security.mac.mls.ptys_equal", &ptys_equal); static int revocation_enabled = 0; -SYSCTL_INT(_security_mac_mls, OID_AUTO, revocation_enabled, CTLFLAG_RWTUN, +SYSCTL_INT(_security_mac_mls, OID_AUTO, revocation_enabled, CTLFLAG_RW, &revocation_enabled, 0, "Revoke access to objects on relabel"); +TUNABLE_INT("security.mac.mls.revocation_enabled", &revocation_enabled); static int max_compartments = MAC_MLS_MAX_COMPARTMENTS; SYSCTL_INT(_security_mac_mls, OID_AUTO, max_compartments, CTLFLAG_RD, diff --git a/sys/security/mac_portacl/mac_portacl.c b/sys/security/mac_portacl/mac_portacl.c index 17427ee200f3f..1dbd1996e562e 100644 --- a/sys/security/mac_portacl/mac_portacl.c +++ b/sys/security/mac_portacl/mac_portacl.c @@ -87,21 +87,27 @@ static SYSCTL_NODE(_security_mac, OID_AUTO, portacl, CTLFLAG_RW, 0, "TrustedBSD mac_portacl policy controls"); static int portacl_enabled = 1; -SYSCTL_INT(_security_mac_portacl, OID_AUTO, enabled, CTLFLAG_RWTUN, +SYSCTL_INT(_security_mac_portacl, OID_AUTO, enabled, CTLFLAG_RW, &portacl_enabled, 0, "Enforce portacl policy"); +TUNABLE_INT("security.mac.portacl.enabled", &portacl_enabled); static int portacl_suser_exempt = 1; -SYSCTL_INT(_security_mac_portacl, OID_AUTO, suser_exempt, CTLFLAG_RWTUN, +SYSCTL_INT(_security_mac_portacl, OID_AUTO, suser_exempt, CTLFLAG_RW, &portacl_suser_exempt, 0, "Privilege permits binding of any port"); +TUNABLE_INT("security.mac.portacl.suser_exempt", + &portacl_suser_exempt); static int portacl_autoport_exempt = 1; -SYSCTL_INT(_security_mac_portacl, OID_AUTO, autoport_exempt, CTLFLAG_RWTUN, +SYSCTL_INT(_security_mac_portacl, OID_AUTO, autoport_exempt, CTLFLAG_RW, &portacl_autoport_exempt, 0, "Allow automatic allocation through " "binding port 0 if not IP_PORTRANGELOW"); +TUNABLE_INT("security.mac.portacl.autoport_exempt", + &portacl_autoport_exempt); static int portacl_port_high = 1023; -SYSCTL_INT(_security_mac_portacl, OID_AUTO, port_high, CTLFLAG_RWTUN, +SYSCTL_INT(_security_mac_portacl, OID_AUTO, port_high, CTLFLAG_RW, &portacl_port_high, 0, "Highest port to enforce for"); +TUNABLE_INT("security.mac.portacl.port_high", &portacl_port_high); static MALLOC_DEFINE(M_PORTACL, "portacl_rule", "Rules for mac_portacl"); diff --git a/sys/sparc64/pci/psycho.c b/sys/sparc64/pci/psycho.c index 57e0f4817b5ae..ec8d90fe22cb4 100644 --- a/sys/sparc64/pci/psycho.c +++ b/sys/sparc64/pci/psycho.c @@ -167,6 +167,7 @@ EARLY_DRIVER_MODULE(psycho, nexus, psycho_driver, psycho_devclass, NULL, NULL, static SYSCTL_NODE(_hw, OID_AUTO, psycho, CTLFLAG_RD, 0, "psycho parameters"); static u_int psycho_powerfail = 1; +TUNABLE_INT("hw.psycho.powerfail", &psycho_powerfail); SYSCTL_UINT(_hw_psycho, OID_AUTO, powerfail, CTLFLAG_RDTUN, &psycho_powerfail, 0, "powerfail action (0: none, 1: shutdown (default), 2: debugger)"); diff --git a/sys/sys/malloc.h b/sys/sys/malloc.h index dcb4290a8acb7..8f51606b72ffb 100644 --- a/sys/sys/malloc.h +++ b/sys/sys/malloc.h @@ -134,7 +134,7 @@ struct malloc_type_header { struct malloc_type type[1] = { \ { NULL, M_MAGIC, shortdesc, NULL } \ }; \ - SYSINIT(type##_init, SI_SUB_KMEM, SI_ORDER_THIRD, malloc_init, \ + SYSINIT(type##_init, SI_SUB_KMEM, SI_ORDER_SECOND, malloc_init, \ type); \ SYSUNINIT(type##_uninit, SI_SUB_KMEM, SI_ORDER_ANY, \ malloc_uninit, type) diff --git a/sys/sys/param.h b/sys/sys/param.h index ccbb70ab9cf0f..4b487b30e400f 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1100024 /* Master, propagated to newvers */ +#define __FreeBSD_version 1100023 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h index 0473eb72ebb1c..02faa934bef2d 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -83,7 +83,7 @@ struct ctlname { #define CTLFLAG_DYN 0x02000000 /* Dynamic oid - can be freed */ #define CTLFLAG_SKIP 0x01000000 /* Skip this sysctl when listing */ #define CTLMASK_SECURE 0x00F00000 /* Secure level */ -#define CTLFLAG_TUN 0x00080000 /* Default value is loaded from getenv() */ +#define CTLFLAG_TUN 0x00080000 /* Tunable variable */ #define CTLFLAG_RDTUN (CTLFLAG_RD|CTLFLAG_TUN) #define CTLFLAG_RWTUN (CTLFLAG_RW|CTLFLAG_TUN) #define CTLFLAG_MPSAFE 0x00040000 /* Handler is MP safe */ @@ -92,7 +92,6 @@ struct ctlname { #define CTLFLAG_CAPRD 0x00008000 /* Can be read in capability mode */ #define CTLFLAG_CAPWR 0x00004000 /* Can be written in capability mode */ #define CTLFLAG_STATS 0x00002000 /* Statistics, not a tuneable */ -#define CTLFLAG_NOFETCH 0x00001000 /* Don't fetch tunable from getenv() */ #define CTLFLAG_CAPRW (CTLFLAG_CAPRD|CTLFLAG_CAPWR) /* @@ -162,7 +161,6 @@ SLIST_HEAD(sysctl_oid_list, sysctl_oid); * be hidden behind it, expanded by the handler. */ struct sysctl_oid { - struct sysctl_oid_list oid_children; struct sysctl_oid_list *oid_parent; SLIST_ENTRY(sysctl_oid) oid_link; int oid_number; @@ -202,16 +200,14 @@ void sysctl_register_oid(struct sysctl_oid *oidp); void sysctl_unregister_oid(struct sysctl_oid *oidp); /* Declare a static oid to allow child oids to be added to it. */ -#define SYSCTL_DECL(name) \ - extern struct sysctl_oid sysctl__##name +#define SYSCTL_DECL(name) \ + extern struct sysctl_oid_list sysctl_##name##_children /* Hide these in macros. */ -#define SYSCTL_CHILDREN(oid_ptr) (&(oid_ptr)->oid_children) -#define SYSCTL_PARENT(oid_ptr) \ - (((oid_ptr)->oid_parent != &sysctl__children) ? \ - __containerof((oid_ptr)->oid_parent, struct sysctl_oid, \ - oid_children) : (struct sysctl_oid *)NULL) -#define SYSCTL_STATIC_CHILDREN(oid_name) (&sysctl__##oid_name.oid_children) +#define SYSCTL_CHILDREN(oid_ptr) \ + (struct sysctl_oid_list *)(oid_ptr)->oid_arg1 +#define SYSCTL_CHILDREN_SET(oid_ptr, val) (oid_ptr)->oid_arg1 = (val) +#define SYSCTL_STATIC_CHILDREN(oid_name) (&sysctl_##oid_name##_children) /* === Structs and macros related to context handling. === */ @@ -224,7 +220,7 @@ struct sysctl_ctx_entry { TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); #define SYSCTL_NODE_CHILDREN(parent, name) \ - sysctl__##parent##_##name.oid_children + sysctl_##parent##_##name##_children /* * These macros provide type safety for sysctls. SYSCTL_ALLOWED_TYPES() @@ -279,47 +275,29 @@ SYSCTL_ALLOWED_TYPES(UINT64, uint64_t *a; unsigned long long *b; ); #define __DESCR(d) "" #endif -/* This macro is only for internal use */ -#define SYSCTL_OID_RAW(id, parent_child_head, nbr, name, kind, a1, a2, handler, fmt, descr) \ - struct sysctl_oid id = { \ - .oid_parent = (parent_child_head), \ - .oid_children = SLIST_HEAD_INITIALIZER(&id.oid_children), \ +/* This constructs a "raw" MIB oid. */ +#define SYSCTL_OID(parent, nbr, name, kind, a1, a2, handler, fmt, descr)\ + static struct sysctl_oid sysctl__##parent##_##name = { \ + .oid_parent = &sysctl_##parent##_children, \ .oid_number = (nbr), \ .oid_kind = (kind), \ .oid_arg1 = (a1), \ .oid_arg2 = (a2), \ - .oid_name = (name), \ + .oid_name = #name, \ .oid_handler = (handler), \ .oid_fmt = (fmt), \ .oid_descr = __DESCR(descr) \ }; \ - DATA_SET(sysctl_set, id) - -/* This constructs a static "raw" MIB oid. */ -#define SYSCTL_OID(parent, nbr, name, kind, a1, a2, handler, fmt, descr) \ - static SYSCTL_OID_RAW(sysctl__##parent##_##name, \ - SYSCTL_CHILDREN(&sysctl__##parent), \ - nbr, #name, kind, a1, a2, handler, fmt, descr) - -/* This constructs a global "raw" MIB oid. */ -#define SYSCTL_OID_GLOBAL(parent, nbr, name, kind, a1, a2, handler, fmt, descr) \ - SYSCTL_OID_RAW(sysctl__##parent##_##name, \ - SYSCTL_CHILDREN(&sysctl__##parent), \ - nbr, #name, kind, a1, a2, handler, fmt, descr) + DATA_SET(sysctl_set, sysctl__##parent##_##name) #define SYSCTL_ADD_OID(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, descr) \ sysctl_add_oid(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, __DESCR(descr)) -/* This constructs a root node from which other nodes can hang. */ -#define SYSCTL_ROOT_NODE(nbr, name, access, handler, descr) \ - SYSCTL_OID_RAW(sysctl___##name, &sysctl__children, \ - nbr, #name, CTLTYPE_NODE|(access), NULL, 0, \ - handler, "N", descr) - /* This constructs a node from which other oids can hang. */ #define SYSCTL_NODE(parent, nbr, name, access, handler, descr) \ - SYSCTL_OID_GLOBAL(parent, nbr, name, CTLTYPE_NODE|(access), \ - NULL, 0, handler, "N", descr) + struct sysctl_oid_list SYSCTL_NODE_CHILDREN(parent, name); \ + SYSCTL_OID(parent, nbr, name, CTLTYPE_NODE|(access), \ + (void*)&SYSCTL_NODE_CHILDREN(parent, name), 0, handler, "N", descr) #define SYSCTL_ADD_NODE(ctx, parent, nbr, name, access, handler, descr) \ sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_NODE|(access), \ diff --git a/sys/vm/memguard.c b/sys/vm/memguard.c index d502ca569bdec..1d3b4125a149c 100644 --- a/sys/vm/memguard.c +++ b/sys/vm/memguard.c @@ -67,7 +67,7 @@ static SYSCTL_NODE(_vm, OID_AUTO, memguard, CTLFLAG_RW, NULL, "MemGuard data"); * reserved for MemGuard. */ static u_int vm_memguard_divisor; -SYSCTL_UINT(_vm_memguard, OID_AUTO, divisor, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, +SYSCTL_UINT(_vm_memguard, OID_AUTO, divisor, CTLFLAG_RDTUN, &vm_memguard_divisor, 0, "(kmem_size/memguard_divisor) == memguard submap size"); @@ -132,7 +132,8 @@ SYSCTL_ULONG(_vm_memguard, OID_AUTO, fail_pgs, CTLFLAG_RD, #define MG_GUARD_ALLLARGE 0x002 #define MG_GUARD_NOFREE 0x004 static int memguard_options = MG_GUARD_AROUND; -SYSCTL_INT(_vm_memguard, OID_AUTO, options, CTLFLAG_RWTUN, +TUNABLE_INT("vm.memguard.options", &memguard_options); +SYSCTL_INT(_vm_memguard, OID_AUTO, options, CTLFLAG_RW, &memguard_options, 0, "MemGuard options:\n" "\t0x001 - add guard pages around each allocation\n" @@ -148,7 +149,8 @@ SYSCTL_ULONG(_vm_memguard, OID_AUTO, minsize_reject, CTLFLAG_RD, static u_int memguard_frequency; static u_long memguard_frequency_hits; -SYSCTL_UINT(_vm_memguard, OID_AUTO, frequency, CTLFLAG_RWTUN, +TUNABLE_INT("vm.memguard.frequency", &memguard_frequency); +SYSCTL_UINT(_vm_memguard, OID_AUTO, frequency, CTLFLAG_RW, &memguard_frequency, 0, "Times in 100000 that MemGuard will randomly run"); SYSCTL_ULONG(_vm_memguard, OID_AUTO, frequency_hits, CTLFLAG_RD, &memguard_frequency_hits, 0, "# times MemGuard randomly chose"); diff --git a/sys/vm/redzone.c b/sys/vm/redzone.c index a66a793f27f05..e4b5f6ccc9c0d 100644 --- a/sys/vm/redzone.c +++ b/sys/vm/redzone.c @@ -41,7 +41,8 @@ static u_long redzone_extra_mem = 0; SYSCTL_ULONG(_vm_redzone, OID_AUTO, extra_mem, CTLFLAG_RD, &redzone_extra_mem, 0, "Extra memory allocated by redzone"); static int redzone_panic = 0; -SYSCTL_INT(_vm_redzone, OID_AUTO, panic, CTLFLAG_RWTUN, &redzone_panic, 0, +TUNABLE_INT("vm.redzone.panic", &redzone_panic); +SYSCTL_INT(_vm_redzone, OID_AUTO, panic, CTLFLAG_RW, &redzone_panic, 0, "Panic when buffer corruption is detected"); #define REDZONE_CHSIZE (16) diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c index 81b714a9f32d0..62f4912a3dc48 100644 --- a/sys/vm/uma_core.c +++ b/sys/vm/uma_core.c @@ -281,7 +281,8 @@ SYSCTL_PROC(_vm, OID_AUTO, zone_stats, CTLFLAG_RD|CTLTYPE_STRUCT, 0, 0, sysctl_vm_zone_stats, "s,struct uma_type_header", "Zone Stats"); static int zone_warnings = 1; -SYSCTL_INT(_vm, OID_AUTO, zone_warnings, CTLFLAG_RWTUN, &zone_warnings, 0, +TUNABLE_INT("vm.zone_warnings", &zone_warnings); +SYSCTL_INT(_vm, OID_AUTO, zone_warnings, CTLFLAG_RW, &zone_warnings, 0, "Warn when UMA zones becomes full"); /* diff --git a/sys/vm/vm_init.c b/sys/vm/vm_init.c index be1038758824a..30faa5a2aeb22 100644 --- a/sys/vm/vm_init.c +++ b/sys/vm/vm_init.c @@ -91,7 +91,8 @@ __FBSDID("$FreeBSD$"); long physmem; static int exec_map_entries = 16; -SYSCTL_INT(_vm, OID_AUTO, exec_map_entries, CTLFLAG_RDTUN, &exec_map_entries, 0, +TUNABLE_INT("vm.exec_map_entries", &exec_map_entries); +SYSCTL_INT(_vm, OID_AUTO, exec_map_entries, CTLFLAG_RD, &exec_map_entries, 0, "Maximum number of simultaneous execs"); /* diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index b5108e2917563..62eb393144088 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -3471,7 +3471,8 @@ vm_map_stack_locked(vm_map_t map, vm_offset_t addrbos, vm_size_t max_ssize, } static int stack_guard_page = 0; -SYSCTL_INT(_security_bsd, OID_AUTO, stack_guard_page, CTLFLAG_RWTUN, +TUNABLE_INT("security.bsd.stack_guard_page", &stack_guard_page); +SYSCTL_INT(_security_bsd, OID_AUTO, stack_guard_page, CTLFLAG_RW, &stack_guard_page, 0, "Insert stack guard page ahead of the growable segments."); diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c index e94090c53e88e..a5248399ab9a2 100644 --- a/sys/vm/vm_mmap.c +++ b/sys/vm/vm_mmap.c @@ -92,8 +92,9 @@ __FBSDID("$FreeBSD$"); #endif int old_mlock = 0; -SYSCTL_INT(_vm, OID_AUTO, old_mlock, CTLFLAG_RWTUN, &old_mlock, 0, +SYSCTL_INT(_vm, OID_AUTO, old_mlock, CTLFLAG_RW | CTLFLAG_TUN, &old_mlock, 0, "Do not apply RLIMIT_MEMLOCK on mlockall"); +TUNABLE_INT("vm.old_mlock", &old_mlock); #ifdef MAP_32BIT #define MAP_32BIT_MAX_ADDR ((vm_offset_t)1 << 31) diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index 4e30a3f5aded0..49c3edeeacf38 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -134,7 +134,8 @@ long first_page; int vm_page_zero_count; static int boot_pages = UMA_BOOT_PAGES; -SYSCTL_INT(_vm, OID_AUTO, boot_pages, CTLFLAG_RDTUN, &boot_pages, 0, +TUNABLE_INT("vm.boot_pages", &boot_pages); +SYSCTL_INT(_vm, OID_AUTO, boot_pages, CTLFLAG_RD, &boot_pages, 0, "number of pages allocated for bootstrapping the VM system"); static int pa_tryrelock_restart; diff --git a/sys/vm/vm_radix.c b/sys/vm/vm_radix.c index 4f4b6d24d526a..bb45ba0d801c3 100644 --- a/sys/vm/vm_radix.c +++ b/sys/vm/vm_radix.c @@ -302,7 +302,7 @@ vm_radix_reserve_kva(void *arg __unused) sizeof(struct vm_radix_node)))) panic("%s: unable to reserve KVA", __func__); } -SYSINIT(vm_radix_reserve_kva, SI_SUB_KMEM, SI_ORDER_THIRD, +SYSINIT(vm_radix_reserve_kva, SI_SUB_KMEM, SI_ORDER_SECOND, vm_radix_reserve_kva, NULL); #endif diff --git a/sys/vm/vm_zeroidle.c b/sys/vm/vm_zeroidle.c index dac4abe3a46eb..458539eb1782f 100644 --- a/sys/vm/vm_zeroidle.c +++ b/sys/vm/vm_zeroidle.c @@ -55,9 +55,10 @@ __FBSDID("$FreeBSD$"); #include static int idlezero_enable_default = 0; +TUNABLE_INT("vm.idlezero_enable", &idlezero_enable_default); /* Defer setting the enable flag until the kthread is running. */ static int idlezero_enable = 0; -SYSCTL_INT(_vm, OID_AUTO, idlezero_enable, CTLFLAG_RWTUN, &idlezero_enable, 0, +SYSCTL_INT(_vm, OID_AUTO, idlezero_enable, CTLFLAG_RW, &idlezero_enable, 0, "Allow the kernel to use idle cpu cycles to zero-out pages"); /* * Implement the pre-zeroed page mechanism. diff --git a/sys/x86/cpufreq/hwpstate.c b/sys/x86/cpufreq/hwpstate.c index d4c70b773c703..e86e31aab4cda 100644 --- a/sys/x86/cpufreq/hwpstate.c +++ b/sys/x86/cpufreq/hwpstate.c @@ -118,8 +118,9 @@ static int hwpstate_get_info_from_msr(device_t dev); static int hwpstate_goto_pstate(device_t dev, int pstate_id); static int hwpstate_verbose = 0; -SYSCTL_INT(_debug, OID_AUTO, hwpstate_verbose, CTLFLAG_RWTUN, +SYSCTL_INT(_debug, OID_AUTO, hwpstate_verbose, CTLFLAG_RW | CTLFLAG_TUN, &hwpstate_verbose, 0, "Debug hwpstate"); +TUNABLE_INT("debug.hwpstate_verbose", &hwpstate_verbose); static device_method_t hwpstate_methods[] = { /* Device interface */ diff --git a/sys/x86/iommu/intel_utils.c b/sys/x86/iommu/intel_utils.c index 444329c581fe2..e221a1e6546bc 100644 --- a/sys/x86/iommu/intel_utils.c +++ b/sys/x86/iommu/intel_utils.c @@ -549,16 +549,17 @@ dmar_barrier_exit(struct dmar_unit *dmar, u_int barrier_id) int dmar_match_verbose; -static SYSCTL_NODE(_hw, OID_AUTO, dmar, CTLFLAG_RD, NULL, ""); -SYSCTL_INT(_hw_dmar, OID_AUTO, tbl_pagecnt, CTLFLAG_RD, +static SYSCTL_NODE(_hw, OID_AUTO, dmar, CTLFLAG_RD, NULL, + ""); +SYSCTL_INT(_hw_dmar, OID_AUTO, tbl_pagecnt, CTLFLAG_RD | CTLFLAG_TUN, &dmar_tbl_pagecnt, 0, "Count of pages used for DMAR pagetables"); -SYSCTL_INT(_hw_dmar, OID_AUTO, match_verbose, CTLFLAG_RWTUN, +SYSCTL_INT(_hw_dmar, OID_AUTO, match_verbose, CTLFLAG_RW | CTLFLAG_TUN, &dmar_match_verbose, 0, "Verbose matching of the PCI devices to DMAR paths"); #ifdef INVARIANTS int dmar_check_free; -SYSCTL_INT(_hw_dmar, OID_AUTO, check_free, CTLFLAG_RWTUN, +SYSCTL_INT(_hw_dmar, OID_AUTO, check_free, CTLFLAG_RW | CTLFLAG_TUN, &dmar_check_free, 0, "Check the GPA RBtree for free_down and free_after validity"); #endif diff --git a/sys/x86/pci/pci_bus.c b/sys/x86/pci/pci_bus.c index f64659eec2ada..88cabc724fe3b 100644 --- a/sys/x86/pci/pci_bus.c +++ b/sys/x86/pci/pci_bus.c @@ -575,6 +575,7 @@ legacy_pcib_write_ivar(device_t dev, device_t child, int which, SYSCTL_DECL(_hw_pci); static unsigned long host_mem_start = 0x80000000; +TUNABLE_ULONG("hw.pci.host_mem_start", &host_mem_start); SYSCTL_ULONG(_hw_pci, OID_AUTO, host_mem_start, CTLFLAG_RDTUN, &host_mem_start, 0, "Limit the host bridge memory to being above this address."); diff --git a/sys/x86/x86/dump_machdep.c b/sys/x86/x86/dump_machdep.c index 30fa719467ffc..5c874f4847b66 100644 --- a/sys/x86/x86/dump_machdep.c +++ b/sys/x86/x86/dump_machdep.c @@ -53,7 +53,8 @@ __FBSDID("$FreeBSD$"); CTASSERT(sizeof(struct kerneldumpheader) == 512); int do_minidump = 1; -SYSCTL_INT(_debug, OID_AUTO, minidump, CTLFLAG_RWTUN, &do_minidump, 0, +TUNABLE_INT("debug.minidump", &do_minidump); +SYSCTL_INT(_debug, OID_AUTO, minidump, CTLFLAG_RW, &do_minidump, 0, "Enable mini crash dumps"); /* diff --git a/sys/x86/x86/io_apic.c b/sys/x86/x86/io_apic.c index 5667120661b40..ec469ad685e74 100644 --- a/sys/x86/x86/io_apic.c +++ b/sys/x86/x86/io_apic.c @@ -134,6 +134,7 @@ static SYSCTL_NODE(_hw, OID_AUTO, apic, CTLFLAG_RD, 0, "APIC options"); static int enable_extint; SYSCTL_INT(_hw_apic, OID_AUTO, enable_extint, CTLFLAG_RDTUN, &enable_extint, 0, "Enable the ExtINT pin in the first I/O APIC"); +TUNABLE_INT("hw.apic.enable_extint", &enable_extint); static __inline void _ioapic_eoi_source(struct intsrc *isrc) diff --git a/sys/x86/x86/mca.c b/sys/x86/x86/mca.c index 347d570a1fa2f..8a0d2b12e9c6e 100644 --- a/sys/x86/x86/mca.c +++ b/sys/x86/x86/mca.c @@ -92,10 +92,12 @@ static SYSCTL_NODE(_hw, OID_AUTO, mca, CTLFLAG_RD, NULL, "Machine Check Architecture"); static int mca_enabled = 1; +TUNABLE_INT("hw.mca.enabled", &mca_enabled); SYSCTL_INT(_hw_mca, OID_AUTO, enabled, CTLFLAG_RDTUN, &mca_enabled, 0, "Administrative toggle for machine check support"); static int amd10h_L1TP = 1; +TUNABLE_INT("hw.mca.amd10h_L1TP", &amd10h_L1TP); SYSCTL_INT(_hw_mca, OID_AUTO, amd10h_L1TP, CTLFLAG_RDTUN, &amd10h_L1TP, 0, "Administrative toggle for logging of level one TLB parity (L1TP) errors"); diff --git a/sys/x86/x86/tsc.c b/sys/x86/x86/tsc.c index 54c4d02497cf4..2a6c81d786d3f 100644 --- a/sys/x86/x86/tsc.c +++ b/sys/x86/x86/tsc.c @@ -58,28 +58,34 @@ static eventhandler_tag tsc_levels_tag, tsc_pre_tag, tsc_post_tag; SYSCTL_INT(_kern_timecounter, OID_AUTO, invariant_tsc, CTLFLAG_RDTUN, &tsc_is_invariant, 0, "Indicates whether the TSC is P-state invariant"); +TUNABLE_INT("kern.timecounter.invariant_tsc", &tsc_is_invariant); #ifdef SMP int smp_tsc; SYSCTL_INT(_kern_timecounter, OID_AUTO, smp_tsc, CTLFLAG_RDTUN, &smp_tsc, 0, "Indicates whether the TSC is safe to use in SMP mode"); +TUNABLE_INT("kern.timecounter.smp_tsc", &smp_tsc); int smp_tsc_adjust = 0; SYSCTL_INT(_kern_timecounter, OID_AUTO, smp_tsc_adjust, CTLFLAG_RDTUN, &smp_tsc_adjust, 0, "Try to adjust TSC on APs to match BSP"); +TUNABLE_INT("kern.timecounter.smp_tsc_adjust", &smp_tsc_adjust); #endif static int tsc_shift = 1; SYSCTL_INT(_kern_timecounter, OID_AUTO, tsc_shift, CTLFLAG_RDTUN, &tsc_shift, 0, "Shift to pre-apply for the maximum TSC frequency"); +TUNABLE_INT("kern.timecounter.tsc_shift", &tsc_shift); static int tsc_disabled; SYSCTL_INT(_machdep, OID_AUTO, disable_tsc, CTLFLAG_RDTUN, &tsc_disabled, 0, "Disable x86 Time Stamp Counter"); +TUNABLE_INT("machdep.disable_tsc", &tsc_disabled); static int tsc_skip_calibration; SYSCTL_INT(_machdep, OID_AUTO, disable_tsc_calibration, CTLFLAG_RDTUN, &tsc_skip_calibration, 0, "Disable TSC frequency calibration"); +TUNABLE_INT("machdep.disable_tsc_calibration", &tsc_skip_calibration); static void tsc_freq_changed(void *arg, const struct cf_level *level, int status); -- cgit v1.3 From af3b2549c4ba2ef00a7cbb4cb6836598bf0aefbe Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Sat, 28 Jun 2014 03:56:17 +0000 Subject: Pull in r267961 and r267973 again. Fix for issues reported will follow. --- sys/amd64/acpica/acpi_machdep.c | 5 +- sys/amd64/amd64/amd64_mem.c | 1 - sys/amd64/amd64/machdep.c | 3 +- sys/amd64/amd64/mp_watchdog.c | 3 +- sys/amd64/amd64/pmap.c | 8 +- sys/amd64/amd64/sys_machdep.c | 1 - sys/amd64/amd64/trap.c | 10 +- sys/amd64/pci/pci_cfgreg.c | 1 - sys/amd64/vmm/vmm.c | 1 - sys/arm/arm/busdma_machdep-v6.c | 6 +- sys/arm/arm/busdma_machdep.c | 6 +- sys/arm/arm/dump_machdep.c | 3 +- sys/arm/arm/platform.c | 4 +- sys/arm/arm/pmap-v6.c | 2 +- sys/arm/freescale/imx/imx6_anatop.c | 11 +- sys/arm/xscale/ixp425/if_npe.c | 12 +- sys/arm/xscale/ixp425/ixp425_npe.c | 3 +- sys/arm/xscale/ixp425/ixp425_qmgr.c | 5 +- sys/cam/ata/ata_da.c | 24 +-- sys/cam/ata/ata_pmp.c | 9 +- sys/cam/cam.c | 1 - sys/cam/cam_xpt.c | 8 +- sys/cam/ctl/ctl.c | 2 - sys/cam/ctl/ctl_backend_block.c | 3 +- sys/cam/ctl/ctl_frontend_iscsi.c | 4 - sys/cam/scsi/scsi_cd.c | 9 +- sys/cam/scsi/scsi_da.c | 12 +- sys/cam/scsi/scsi_enc_safte.c | 3 +- sys/cam/scsi/scsi_sa.c | 5 +- sys/cam/scsi/scsi_xpt.c | 3 +- .../compat/opensolaris/kern/opensolaris_kstat.c | 2 +- .../contrib/opensolaris/uts/common/fs/zfs/arc.c | 2 - .../contrib/opensolaris/uts/common/fs/zfs/ddt.c | 3 +- .../contrib/opensolaris/uts/common/fs/zfs/dmu.c | 4 +- .../opensolaris/uts/common/fs/zfs/dmu_zfetch.c | 6 +- .../opensolaris/uts/common/fs/zfs/dsl_pool.c | 4 - .../opensolaris/uts/common/fs/zfs/dsl_scan.c | 27 +-- .../opensolaris/uts/common/fs/zfs/metaslab.c | 23 +-- .../contrib/opensolaris/uts/common/fs/zfs/spa.c | 3 +- .../opensolaris/uts/common/fs/zfs/spa_misc.c | 6 - .../opensolaris/uts/common/fs/zfs/trim_map.c | 9 - .../contrib/opensolaris/uts/common/fs/zfs/txg.c | 3 +- .../opensolaris/uts/common/fs/zfs/vdev_cache.c | 3 - .../opensolaris/uts/common/fs/zfs/vdev_geom.c | 10 +- .../opensolaris/uts/common/fs/zfs/vdev_mirror.c | 16 +- .../opensolaris/uts/common/fs/zfs/vdev_queue.c | 20 +-- .../opensolaris/uts/common/fs/zfs/zfs_ioctl.c | 3 +- .../opensolaris/uts/common/fs/zfs/zfs_vfsops.c | 3 +- .../contrib/opensolaris/uts/common/fs/zfs/zil.c | 5 +- .../contrib/opensolaris/uts/common/fs/zfs/zio.c | 5 - .../contrib/opensolaris/uts/common/fs/zfs/zvol.c | 1 - sys/cddl/dev/dtrace/dtrace_sysctl.c | 3 +- sys/compat/ia32/ia32_sysvec.c | 9 +- sys/compat/x86bios/x86bios.c | 6 +- sys/dev/aac/aac_pci.c | 1 - sys/dev/acpica/Osd/OsdSchedule.c | 2 - sys/dev/acpica/acpi_cpu.c | 1 - sys/dev/acpica/acpi_ec.c | 9 +- sys/dev/amr/amr_pci.c | 1 - sys/dev/ata/ata-all.c | 3 +- sys/dev/ath/ah_osdep.c | 3 +- sys/dev/ath/if_ath.c | 9 +- sys/dev/ath/if_ath_debug.c | 3 +- sys/dev/bce/if_bce.c | 15 -- sys/dev/bge/if_bge.c | 17 +- sys/dev/bwn/if_bwn.c | 3 +- sys/dev/bxe/bxe.c | 13 +- sys/dev/cardbus/cardbus.c | 12 +- sys/dev/cs/if_cs.c | 6 +- sys/dev/cxgb/cxgb_include.h | 3 + sys/dev/cxgb/cxgb_main.c | 5 - sys/dev/cxgb/cxgb_sge.c | 14 +- sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c | 24 +-- sys/dev/cxgbe/iw_cxgbe/cm.c | 50 ++---- sys/dev/drm/drm_drv.c | 1 - sys/dev/drm/drm_sysctl.c | 2 +- sys/dev/drm2/drm_drv.c | 1 - sys/dev/drm2/drm_sysctl.c | 2 +- sys/dev/e1000/if_em.c | 11 -- sys/dev/e1000/if_igb.c | 11 +- sys/dev/fb/vesa.c | 1 - sys/dev/firewire/fwohci.c | 11 +- sys/dev/firewire/if_fwe.c | 12 +- sys/dev/firewire/if_fwip.c | 4 +- sys/dev/firewire/sbp.c | 24 +-- sys/dev/glxiic/glxiic.c | 5 +- sys/dev/hptmv/hptproc.c | 2 +- sys/dev/hwpmc/hwpmc_logging.c | 6 +- sys/dev/hwpmc/hwpmc_mod.c | 17 +- sys/dev/iscsi/icl.c | 5 - sys/dev/iscsi/iscsi.c | 6 - sys/dev/iscsi_initiator/iscsi.c | 11 +- sys/dev/ixgbe/ixgbe.c | 10 +- sys/dev/malo/if_malo.c | 15 +- sys/dev/malo/if_malo_pci.c | 3 +- sys/dev/mfi/mfi.c | 6 - sys/dev/mfi/mfi_cam.c | 3 +- sys/dev/mfi/mfi_pci.c | 5 +- sys/dev/mfi/mfi_tbolt.c | 1 - sys/dev/mwl/if_mwl.c | 18 +- sys/dev/nand/nand.c | 11 +- sys/dev/pccard/pccard.c | 6 +- sys/dev/pccbb/pccbb.c | 12 +- sys/dev/pccbb/pccbb_isa.c | 4 +- sys/dev/pci/pci.c | 31 ++-- sys/dev/pci/pci_pci.c | 1 - sys/dev/pci/vga_pci.c | 1 - sys/dev/puc/puc_pci.c | 3 +- sys/dev/rt/if_rt.c | 3 +- sys/dev/sdhci/sdhci.c | 3 +- sys/dev/sdhci/sdhci_pci.c | 3 +- sys/dev/si/si.c | 3 +- sys/dev/sio/sio.c | 2 +- sys/dev/sis/if_sis.c | 5 +- sys/dev/sound/pcm/channel.c | 3 +- sys/dev/sound/pcm/feeder_chain.c | 3 +- sys/dev/sound/pcm/feeder_eq.c | 3 +- sys/dev/sound/pcm/feeder_rate.c | 3 +- sys/dev/sound/pcm/mixer.c | 3 +- sys/dev/sound/pcm/sound.c | 3 +- sys/dev/sound/usb/uaudio.c | 12 +- sys/dev/syscons/syscons.c | 3 +- sys/dev/uart/uart_dev_ns8250.c | 3 +- sys/dev/usb/controller/dwc_otg.c | 5 +- sys/dev/usb/controller/ehci.c | 13 +- sys/dev/usb/controller/ohci.c | 3 +- sys/dev/usb/controller/uhci.c | 6 +- sys/dev/usb/controller/usb_controller.c | 9 +- sys/dev/usb/controller/xhci.c | 12 +- sys/dev/usb/input/ukbd.c | 9 +- sys/dev/usb/serial/uftdi.c | 1 - sys/dev/usb/serial/usb_serial.c | 9 +- sys/dev/usb/storage/umass.c | 6 +- sys/dev/usb/usb_debug.c | 33 ++-- sys/dev/usb/usb_dev.c | 3 +- sys/dev/usb/usb_device.c | 9 +- sys/dev/usb/usb_generic.c | 3 +- sys/dev/usb/usb_hub.c | 3 +- sys/dev/usb/usb_process.c | 3 +- sys/dev/usb/wlan/if_uath.c | 6 +- sys/dev/usb/wlan/if_upgt.c | 3 +- sys/dev/usb/wlan/if_urtw.c | 6 +- sys/dev/vt/vt.h | 5 +- sys/dev/wpi/if_wpi.c | 5 +- sys/gdb/gdb_cons.c | 5 +- sys/geom/concat/g_concat.c | 3 +- sys/geom/eli/g_eli.c | 18 +- sys/geom/eli/g_eli_key_cache.c | 1 - sys/geom/gate/g_gate.c | 4 +- sys/geom/geom_disk.c | 5 +- sys/geom/geom_kern.c | 3 +- sys/geom/journal/g_journal.c | 7 +- sys/geom/label/g_label.c | 3 +- sys/geom/label/g_label.h | 4 +- sys/geom/linux_lvm/g_linux_lvm.c | 3 +- sys/geom/mirror/g_mirror.c | 14 +- sys/geom/part/g_part.c | 3 +- sys/geom/part/g_part_ldm.c | 6 +- sys/geom/raid/g_raid.c | 31 ++-- sys/geom/raid/g_raid.h | 12 +- sys/geom/raid/tr_raid1.c | 16 +- sys/geom/raid/tr_raid1e.c | 16 +- sys/geom/raid3/g_raid3.c | 24 +-- sys/geom/shsec/g_shsec.c | 6 +- sys/geom/stripe/g_stripe.c | 9 +- sys/geom/vinum/geom_vinum.c | 3 +- sys/geom/virstor/g_virstor.c | 10 +- sys/i386/acpica/acpi_machdep.c | 3 +- sys/i386/bios/apm.c | 3 +- sys/i386/i386/i686_mem.c | 1 - sys/i386/i386/machdep.c | 3 +- sys/i386/i386/mp_watchdog.c | 3 +- sys/i386/i386/pmap.c | 4 +- sys/i386/i386/trap.c | 6 +- sys/i386/pci/pci_cfgreg.c | 1 - sys/i386/pci/pci_pir.c | 1 - sys/ia64/ia64/dump_machdep.c | 3 +- sys/ia64/ia64/pmap.c | 5 +- sys/kern/imgact_elf.c | 4 +- sys/kern/kern_clocksource.c | 16 +- sys/kern/kern_cons.c | 6 +- sys/kern/kern_cpu.c | 6 +- sys/kern/kern_exec.c | 3 +- sys/kern/kern_intr.c | 3 +- sys/kern/kern_ktr.c | 24 +-- sys/kern/kern_ktrace.c | 3 +- sys/kern/kern_linker.c | 5 +- sys/kern/kern_malloc.c | 57 +++--- sys/kern/kern_mbuf.c | 2 +- sys/kern/kern_mib.c | 40 ++--- sys/kern/kern_ntptime.c | 6 +- sys/kern/kern_osd.c | 3 +- sys/kern/kern_pmc.c | 3 +- sys/kern/kern_priv.c | 6 +- sys/kern/kern_shutdown.c | 36 ++-- sys/kern/kern_sig.c | 12 +- sys/kern/kern_sysctl.c | 193 ++++++++++++++++----- sys/kern/kern_tc.c | 6 +- sys/kern/kern_timeout.c | 6 +- sys/kern/subr_bus.c | 27 +-- sys/kern/subr_kdb.c | 6 +- sys/kern/subr_msgbuf.c | 3 +- sys/kern/subr_param.c | 26 +-- sys/kern/subr_prf.c | 23 ++- sys/kern/subr_rman.c | 3 +- sys/kern/subr_smp.c | 4 +- sys/kern/subr_witness.c | 13 +- sys/kern/sys_pipe.c | 2 +- sys/kern/sysv_msg.c | 6 - sys/kern/sysv_sem.c | 16 +- sys/kern/sysv_shm.c | 32 ++-- sys/kern/vfs_init.c | 3 +- sys/kern/vfs_lookup.c | 3 +- sys/mips/cavium/usb/octusb.c | 5 +- sys/mips/mips/dump_machdep.c | 3 +- sys/mips/rt305x/uart_dev_rt305x.c | 6 +- sys/net/ieee8023ad_lacp.c | 3 +- sys/net/if.c | 1 - sys/net/if_bridge.c | 21 +-- sys/net/if_lagg.c | 6 +- sys/net/if_stf.c | 3 +- sys/net/if_tap.c | 4 +- sys/net/if_tun.c | 4 +- sys/net/netisr.c | 26 +-- sys/net/route.c | 7 +- sys/netgraph/ng_base.c | 3 - sys/netgraph/ng_mppc.c | 9 +- sys/netinet/in_mcast.c | 9 +- sys/netinet/in_rss.c | 6 +- sys/netinet/tcp_subr.c | 7 +- sys/netinet6/in6_mcast.c | 9 +- sys/netinet6/mld6.c | 6 +- sys/netpfil/ipfw/ip_fw2.c | 1 - sys/netpfil/pf/pf.c | 2 - sys/pc98/cbus/sio.c | 2 +- sys/pc98/pc98/machdep.c | 3 +- sys/pc98/pc98/pc98_machdep.c | 3 +- sys/security/mac_biba/mac_biba.c | 19 +- sys/security/mac_bsdextended/mac_bsdextended.c | 3 +- sys/security/mac_ifoff/mac_ifoff.c | 12 +- sys/security/mac_lomac/mac_lomac.c | 16 +- sys/security/mac_mls/mac_mls.c | 9 +- sys/security/mac_portacl/mac_portacl.c | 14 +- sys/sparc64/pci/psycho.c | 1 - sys/sys/malloc.h | 2 +- sys/sys/param.h | 2 +- sys/sys/sysctl.h | 56 ++++-- sys/vm/memguard.c | 8 +- sys/vm/redzone.c | 3 +- sys/vm/uma_core.c | 3 +- sys/vm/vm_init.c | 3 +- sys/vm/vm_map.c | 3 +- sys/vm/vm_mmap.c | 3 +- sys/vm/vm_page.c | 3 +- sys/vm/vm_radix.c | 2 +- sys/vm/vm_zeroidle.c | 3 +- sys/x86/cpufreq/hwpstate.c | 3 +- sys/x86/iommu/intel_utils.c | 9 +- sys/x86/pci/pci_bus.c | 1 - sys/x86/x86/dump_machdep.c | 3 +- sys/x86/x86/io_apic.c | 1 - sys/x86/x86/mca.c | 2 - sys/x86/x86/tsc.c | 6 - 263 files changed, 803 insertions(+), 1389 deletions(-) (limited to 'sys/dev/usb/controller') diff --git a/sys/amd64/acpica/acpi_machdep.c b/sys/amd64/acpica/acpi_machdep.c index e5dd4c306d14d..049b51bb4e9f4 100644 --- a/sys/amd64/acpica/acpi_machdep.c +++ b/sys/amd64/acpica/acpi_machdep.c @@ -45,9 +45,8 @@ __FBSDID("$FreeBSD$"); #include int acpi_resume_beep; -TUNABLE_INT("debug.acpi.resume_beep", &acpi_resume_beep); -SYSCTL_INT(_debug_acpi, OID_AUTO, resume_beep, CTLFLAG_RW, &acpi_resume_beep, - 0, "Beep the PC speaker when resuming"); +SYSCTL_INT(_debug_acpi, OID_AUTO, resume_beep, CTLFLAG_RWTUN, + &acpi_resume_beep, 0, "Beep the PC speaker when resuming"); int acpi_reset_video; TUNABLE_INT("hw.acpi.reset_video", &acpi_reset_video); diff --git a/sys/amd64/amd64/amd64_mem.c b/sys/amd64/amd64/amd64_mem.c index e77a96f3f5541..29cf2c03d8288 100644 --- a/sys/amd64/amd64/amd64_mem.c +++ b/sys/amd64/amd64/amd64_mem.c @@ -69,7 +69,6 @@ static char *mem_owner_bios = "BIOS"; (((curr) & ~MDF_ATTRMASK) | ((new) & MDF_ATTRMASK)) static int mtrrs_disabled; -TUNABLE_INT("machdep.disable_mtrrs", &mtrrs_disabled); SYSCTL_INT(_machdep, OID_AUTO, disable_mtrrs, CTLFLAG_RDTUN, &mtrrs_disabled, 0, "Disable amd64 MTRRs."); diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index 14cb1373d12ab..b8999bd30076b 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -675,8 +675,7 @@ cpu_halt(void) void (*cpu_idle_hook)(sbintime_t) = NULL; /* ACPI idle hook. */ static int cpu_ident_amdc1e = 0; /* AMD C1E supported. */ static int idle_mwait = 1; /* Use MONITOR/MWAIT for short idle. */ -TUNABLE_INT("machdep.idle_mwait", &idle_mwait); -SYSCTL_INT(_machdep, OID_AUTO, idle_mwait, CTLFLAG_RW, &idle_mwait, +SYSCTL_INT(_machdep, OID_AUTO, idle_mwait, CTLFLAG_RWTUN, &idle_mwait, 0, "Use MONITOR/MWAIT for short idle"); #define STATE_RUNNING 0x0 diff --git a/sys/amd64/amd64/mp_watchdog.c b/sys/amd64/amd64/mp_watchdog.c index b1799a20b3db5..b03d2614d9b54 100644 --- a/sys/amd64/amd64/mp_watchdog.c +++ b/sys/amd64/amd64/mp_watchdog.c @@ -68,8 +68,7 @@ static int watchdog_dontfire = 1; static int watchdog_timer = -1; static int watchdog_nmi = 1; -TUNABLE_INT("debug.watchdog", &watchdog_cpu); -SYSCTL_INT(_debug, OID_AUTO, watchdog_nmi, CTLFLAG_RW, &watchdog_nmi, 0, +SYSCTL_INT(_debug, OID_AUTO, watchdog_nmi, CTLFLAG_RWTUN, &watchdog_nmi, 0, "IPI the boot processor with an NMI to enter the debugger"); static struct callout watchdog_callout; diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index ae0041f5048bb..74929606ac13c 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -332,8 +332,8 @@ SYSCTL_INT(_vm_pmap, OID_AUTO, pat_works, CTLFLAG_RD, &pat_works, 1, "Is page attribute table fully functional?"); static int pg_ps_enabled = 1; -SYSCTL_INT(_vm_pmap, OID_AUTO, pg_ps_enabled, CTLFLAG_RDTUN, &pg_ps_enabled, 0, - "Are large page mappings enabled?"); +SYSCTL_INT(_vm_pmap, OID_AUTO, pg_ps_enabled, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, + &pg_ps_enabled, 0, "Are large page mappings enabled?"); #define PAT_INDEX_SIZE 8 static int pat_index[PAT_INDEX_SIZE]; /* cache mode to PAT index conversion */ @@ -368,8 +368,8 @@ static int pmap_flags = PMAP_PDE_SUPERPAGE; /* flags for x86 pmaps */ static struct unrhdr pcid_unr; static struct mtx pcid_mtx; int pmap_pcid_enabled = 0; -SYSCTL_INT(_vm_pmap, OID_AUTO, pcid_enabled, CTLFLAG_RDTUN, &pmap_pcid_enabled, - 0, "Is TLB Context ID enabled ?"); +SYSCTL_INT(_vm_pmap, OID_AUTO, pcid_enabled, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, + &pmap_pcid_enabled, 0, "Is TLB Context ID enabled ?"); int invpcid_works = 0; SYSCTL_INT(_vm_pmap, OID_AUTO, invpcid_works, CTLFLAG_RD, &invpcid_works, 0, "Is the invpcid instruction available ?"); diff --git a/sys/amd64/amd64/sys_machdep.c b/sys/amd64/amd64/sys_machdep.c index 41709c2aa9290..37935cffb057c 100644 --- a/sys/amd64/amd64/sys_machdep.c +++ b/sys/amd64/amd64/sys_machdep.c @@ -73,7 +73,6 @@ static void max_ldt_segment_init(void *arg __unused) { - TUNABLE_INT_FETCH("machdep.max_ldt_segment", &max_ldt_segment); if (max_ldt_segment <= 0) max_ldt_segment = 1; if (max_ldt_segment > MAX_LD) diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c index ce0ab6a51ca65..0e5766678f6d1 100644 --- a/sys/amd64/amd64/trap.c +++ b/sys/amd64/amd64/trap.c @@ -143,20 +143,18 @@ static char *trap_msg[] = { #ifdef KDB static int kdb_on_nmi = 1; -SYSCTL_INT(_machdep, OID_AUTO, kdb_on_nmi, CTLFLAG_RW, +SYSCTL_INT(_machdep, OID_AUTO, kdb_on_nmi, CTLFLAG_RWTUN, &kdb_on_nmi, 0, "Go to KDB on NMI"); -TUNABLE_INT("machdep.kdb_on_nmi", &kdb_on_nmi); #endif static int panic_on_nmi = 1; -SYSCTL_INT(_machdep, OID_AUTO, panic_on_nmi, CTLFLAG_RW, +SYSCTL_INT(_machdep, OID_AUTO, panic_on_nmi, CTLFLAG_RWTUN, &panic_on_nmi, 0, "Panic on NMI"); -TUNABLE_INT("machdep.panic_on_nmi", &panic_on_nmi); static int prot_fault_translation; -SYSCTL_INT(_machdep, OID_AUTO, prot_fault_translation, CTLFLAG_RW, +SYSCTL_INT(_machdep, OID_AUTO, prot_fault_translation, CTLFLAG_RWTUN, &prot_fault_translation, 0, "Select signal to deliver on protection fault"); static int uprintf_signal; -SYSCTL_INT(_machdep, OID_AUTO, uprintf_signal, CTLFLAG_RW, +SYSCTL_INT(_machdep, OID_AUTO, uprintf_signal, CTLFLAG_RWTUN, &uprintf_signal, 0, "Print debugging information on trap signal to ctty"); diff --git a/sys/amd64/pci/pci_cfgreg.c b/sys/amd64/pci/pci_cfgreg.c index 706fdd381ace6..0039008b34522 100644 --- a/sys/amd64/pci/pci_cfgreg.c +++ b/sys/amd64/pci/pci_cfgreg.c @@ -65,7 +65,6 @@ static int pcie_minbus, pcie_maxbus; static uint32_t pcie_badslots; static struct mtx pcicfg_mtx; static int mcfg_enable = 1; -TUNABLE_INT("hw.pci.mcfg", &mcfg_enable); SYSCTL_INT(_hw_pci, OID_AUTO, mcfg, CTLFLAG_RDTUN, &mcfg_enable, 0, "Enable support for PCI-e memory mapped config access"); diff --git a/sys/amd64/vmm/vmm.c b/sys/amd64/vmm/vmm.c index c2a9fd1e117e7..e4c82a1c12a11 100644 --- a/sys/amd64/vmm/vmm.c +++ b/sys/amd64/vmm/vmm.c @@ -199,7 +199,6 @@ SYSCTL_NODE(_hw, OID_AUTO, vmm, CTLFLAG_RW, NULL, NULL); * interrupts disabled. */ static int halt_detection_enabled = 1; -TUNABLE_INT("hw.vmm.halt_detection", &halt_detection_enabled); SYSCTL_INT(_hw_vmm, OID_AUTO, halt_detection, CTLFLAG_RDTUN, &halt_detection_enabled, 0, "Halt VM if all vcpus execute HLT with interrupts disabled"); diff --git a/sys/arm/arm/busdma_machdep-v6.c b/sys/arm/arm/busdma_machdep-v6.c index 6cbcae439c593..f45a5d1e03a09 100644 --- a/sys/arm/arm/busdma_machdep-v6.c +++ b/sys/arm/arm/busdma_machdep-v6.c @@ -224,10 +224,10 @@ busdma_init(void *dummy) /* * This init historically used SI_SUB_VM, but now the init code requires * malloc(9) using M_DEVBUF memory, which is set up later than SI_SUB_VM, by - * SI_SUB_KMEM and SI_ORDER_SECOND, so we'll go right after that by using - * SI_SUB_KMEM and SI_ORDER_THIRD. + * SI_SUB_KMEM and SI_ORDER_THIRD, so we'll go right after that by using + * SI_SUB_KMEM and SI_ORDER_FOURTH. */ -SYSINIT(busdma, SI_SUB_KMEM, SI_ORDER_THIRD, busdma_init, NULL); +SYSINIT(busdma, SI_SUB_KMEM, SI_ORDER_FOURTH, busdma_init, NULL); static __inline int _bus_dma_can_bounce(vm_offset_t lowaddr, vm_offset_t highaddr) diff --git a/sys/arm/arm/busdma_machdep.c b/sys/arm/arm/busdma_machdep.c index 8ef8e03e7d8ad..57b58fcfa75ca 100644 --- a/sys/arm/arm/busdma_machdep.c +++ b/sys/arm/arm/busdma_machdep.c @@ -276,10 +276,10 @@ busdma_init(void *dummy) /* * This init historically used SI_SUB_VM, but now the init code requires * malloc(9) using M_DEVBUF memory, which is set up later than SI_SUB_VM, by - * SI_SUB_KMEM and SI_ORDER_SECOND, so we'll go right after that by using - * SI_SUB_KMEM and SI_ORDER_THIRD. + * SI_SUB_KMEM and SI_ORDER_THIRD, so we'll go right after that by using + * SI_SUB_KMEM and SI_ORDER_FOURTH. */ -SYSINIT(busdma, SI_SUB_KMEM, SI_ORDER_THIRD, busdma_init, NULL); +SYSINIT(busdma, SI_SUB_KMEM, SI_ORDER_FOURTH, busdma_init, NULL); /* * End block of code useful to transplant to other implementations. diff --git a/sys/arm/arm/dump_machdep.c b/sys/arm/arm/dump_machdep.c index f37346c3d0084..5056a33e28031 100644 --- a/sys/arm/arm/dump_machdep.c +++ b/sys/arm/arm/dump_machdep.c @@ -50,8 +50,7 @@ __FBSDID("$FreeBSD$"); CTASSERT(sizeof(struct kerneldumpheader) == 512); int do_minidump = 1; -TUNABLE_INT("debug.minidump", &do_minidump); -SYSCTL_INT(_debug, OID_AUTO, minidump, CTLFLAG_RW, &do_minidump, 0, +SYSCTL_INT(_debug, OID_AUTO, minidump, CTLFLAG_RWTUN, &do_minidump, 0, "Enable mini crash dumps"); /* diff --git a/sys/arm/arm/platform.c b/sys/arm/arm/platform.c index c744d7ec654e8..8dcccc7714ad3 100644 --- a/sys/arm/arm/platform.c +++ b/sys/arm/arm/platform.c @@ -65,8 +65,8 @@ static platform_t plat_obj; static struct kobj_ops plat_kernel_kops; static struct platform_kobj plat_kernel_obj; -static char plat_name[64] = ""; -SYSCTL_STRING(_hw, OID_AUTO, platform, CTLFLAG_RDTUN, plat_name, 0, +static char plat_name[64]; +SYSCTL_STRING(_hw, OID_AUTO, platform, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, plat_name, 0, "Platform currently in use"); /* diff --git a/sys/arm/arm/pmap-v6.c b/sys/arm/arm/pmap-v6.c index 67ae8ddb2b040..804469eef22d3 100644 --- a/sys/arm/arm/pmap-v6.c +++ b/sys/arm/arm/pmap-v6.c @@ -465,7 +465,7 @@ static SYSCTL_NODE(_vm, OID_AUTO, pmap, CTLFLAG_RD, 0, "VM/pmap parameters"); /* Superpages utilization enabled = 1 / disabled = 0 */ static int sp_enabled = 1; -SYSCTL_INT(_vm_pmap, OID_AUTO, sp_enabled, CTLFLAG_RDTUN, &sp_enabled, 0, +SYSCTL_INT(_vm_pmap, OID_AUTO, sp_enabled, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &sp_enabled, 0, "Are large page mappings enabled?"); SYSCTL_INT(_vm_pmap, OID_AUTO, pv_entry_count, CTLFLAG_RD, &pv_entry_count, 0, diff --git a/sys/arm/freescale/imx/imx6_anatop.c b/sys/arm/freescale/imx/imx6_anatop.c index b1757fbdf1a8c..30978381b8f05 100644 --- a/sys/arm/freescale/imx/imx6_anatop.c +++ b/sys/arm/freescale/imx/imx6_anatop.c @@ -375,12 +375,12 @@ cpufreq_initialize(struct imx6_anatop_softc *sc) "CPU frequency"); SYSCTL_ADD_PROC(NULL, SYSCTL_STATIC_CHILDREN(_hw_imx6), - OID_AUTO, "cpu_minmhz", CTLTYPE_INT | CTLFLAG_RWTUN, sc, 0, - cpufreq_sysctl_minmhz, "IU", "Minimum CPU frequency"); + OID_AUTO, "cpu_minmhz", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NOFETCH, + sc, 0, cpufreq_sysctl_minmhz, "IU", "Minimum CPU frequency"); SYSCTL_ADD_PROC(NULL, SYSCTL_STATIC_CHILDREN(_hw_imx6), - OID_AUTO, "cpu_maxmhz", CTLTYPE_INT | CTLFLAG_RWTUN, sc, 0, - cpufreq_sysctl_maxmhz, "IU", "Maximum CPU frequency"); + OID_AUTO, "cpu_maxmhz", CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NOFETCH, + sc, 0, cpufreq_sysctl_maxmhz, "IU", "Maximum CPU frequency"); SYSCTL_ADD_INT(NULL, SYSCTL_STATIC_CHILDREN(_hw_imx6), OID_AUTO, "cpu_maxmhz_hw", CTLFLAG_RD, &sc->cpu_maxmhz_hw, 0, @@ -413,9 +413,6 @@ cpufreq_initialize(struct imx6_anatop_softc *sc) sc->cpu_maxmhz_hw = imx6_ocotp_mhz_tab[cfg3speed]; sc->cpu_maxmhz = sc->cpu_maxmhz_hw; - TUNABLE_INT_FETCH("hw.imx6.cpu_overclock_enable", - &sc->cpu_overclock_enable); - TUNABLE_INT_FETCH("hw.imx6.cpu_minmhz", &sc->cpu_minmhz); op = cpufreq_nearest_oppt(sc, sc->cpu_minmhz); sc->cpu_minmhz = op->mhz; diff --git a/sys/arm/xscale/ixp425/if_npe.c b/sys/arm/xscale/ixp425/if_npe.c index aae31a009ebaf..d1ef51cf812b8 100644 --- a/sys/arm/xscale/ixp425/if_npe.c +++ b/sys/arm/xscale/ixp425/if_npe.c @@ -255,9 +255,8 @@ static SYSCTL_NODE(_hw, OID_AUTO, npe, CTLFLAG_RD, 0, "IXP4XX NPE driver parameters"); static int npe_debug = 0; -SYSCTL_INT(_hw_npe, OID_AUTO, debug, CTLFLAG_RW, &npe_debug, +SYSCTL_INT(_hw_npe, OID_AUTO, debug, CTLFLAG_RWTUN, &npe_debug, 0, "IXP4XX NPE network interface debug msgs"); -TUNABLE_INT("hw.npe.debug", &npe_debug); #define DPRINTF(sc, fmt, ...) do { \ if (sc->sc_debug) device_printf(sc->sc_dev, fmt, __VA_ARGS__); \ } while (0) @@ -265,18 +264,15 @@ TUNABLE_INT("hw.npe.debug", &npe_debug); if (sc->sc_debug >= n) device_printf(sc->sc_dev, fmt, __VA_ARGS__);\ } while (0) static int npe_tickinterval = 3; /* npe_tick frequency (secs) */ -SYSCTL_INT(_hw_npe, OID_AUTO, tickinterval, CTLFLAG_RD, &npe_tickinterval, +SYSCTL_INT(_hw_npe, OID_AUTO, tickinterval, CTLFLAG_RDTUN, &npe_tickinterval, 0, "periodic work interval (secs)"); -TUNABLE_INT("hw.npe.tickinterval", &npe_tickinterval); static int npe_rxbuf = 64; /* # rx buffers to allocate */ -SYSCTL_INT(_hw_npe, OID_AUTO, rxbuf, CTLFLAG_RD, &npe_rxbuf, +SYSCTL_INT(_hw_npe, OID_AUTO, rxbuf, CTLFLAG_RDTUN, &npe_rxbuf, 0, "rx buffers allocated"); -TUNABLE_INT("hw.npe.rxbuf", &npe_rxbuf); static int npe_txbuf = 128; /* # tx buffers to allocate */ -SYSCTL_INT(_hw_npe, OID_AUTO, txbuf, CTLFLAG_RD, &npe_txbuf, +SYSCTL_INT(_hw_npe, OID_AUTO, txbuf, CTLFLAG_RDTUN, &npe_txbuf, 0, "tx buffers allocated"); -TUNABLE_INT("hw.npe.txbuf", &npe_txbuf); static int unit2npeid(int unit) diff --git a/sys/arm/xscale/ixp425/ixp425_npe.c b/sys/arm/xscale/ixp425/ixp425_npe.c index 0ccc7d0cb7f94..6dbce4ccb9548 100644 --- a/sys/arm/xscale/ixp425/ixp425_npe.c +++ b/sys/arm/xscale/ixp425/ixp425_npe.c @@ -181,9 +181,8 @@ typedef struct { } IxNpeDlNpeMgrStateInfoBlock; static int npe_debug = 0; -SYSCTL_INT(_debug, OID_AUTO, ixp425npe, CTLFLAG_RW, &npe_debug, +SYSCTL_INT(_debug, OID_AUTO, ixp425npe, CTLFLAG_RWTUN, &npe_debug, 0, "IXP4XX NPE debug msgs"); -TUNABLE_INT("debug.ixp425npe", &npe_debug); #define DPRINTF(dev, fmt, ...) do { \ if (npe_debug) device_printf(dev, fmt, __VA_ARGS__); \ } while (0) diff --git a/sys/arm/xscale/ixp425/ixp425_qmgr.c b/sys/arm/xscale/ixp425/ixp425_qmgr.c index b6fe434564e84..cb6c8defc948a 100644 --- a/sys/arm/xscale/ixp425/ixp425_qmgr.c +++ b/sys/arm/xscale/ixp425/ixp425_qmgr.c @@ -159,10 +159,9 @@ struct ixpqmgr_softc { uint32_t aqmFreeSramAddress; /* SRAM free space */ }; -static int qmgr_debug = 0; -SYSCTL_INT(_debug, OID_AUTO, qmgr, CTLFLAG_RW, &qmgr_debug, +static int qmgr_debug; +SYSCTL_INT(_debug, OID_AUTO, qmgr, CTLFLAG_RWTUN, &qmgr_debug, 0, "IXP4XX Q-Manager debug msgs"); -TUNABLE_INT("debug.qmgr", &qmgr_debug); #define DPRINTF(dev, fmt, ...) do { \ if (qmgr_debug) printf(fmt, __VA_ARGS__); \ } while (0) diff --git a/sys/cam/ata/ata_da.c b/sys/cam/ata/ata_da.c index 7d0d272c0d632..5ea981ce71e0f 100644 --- a/sys/cam/ata/ata_da.c +++ b/sys/cam/ata/ata_da.c @@ -546,30 +546,22 @@ static int ada_write_cache = ADA_DEFAULT_WRITE_CACHE; static SYSCTL_NODE(_kern_cam, OID_AUTO, ada, CTLFLAG_RD, 0, "CAM Direct Access Disk driver"); -SYSCTL_INT(_kern_cam_ada, OID_AUTO, legacy_aliases, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_ada, OID_AUTO, legacy_aliases, CTLFLAG_RWTUN, &ada_legacy_aliases, 0, "Create legacy-like device aliases"); -TUNABLE_INT("kern.cam.ada.legacy_aliases", &ada_legacy_aliases); -SYSCTL_INT(_kern_cam_ada, OID_AUTO, retry_count, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_ada, OID_AUTO, retry_count, CTLFLAG_RWTUN, &ada_retry_count, 0, "Normal I/O retry count"); -TUNABLE_INT("kern.cam.ada.retry_count", &ada_retry_count); -SYSCTL_INT(_kern_cam_ada, OID_AUTO, default_timeout, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_ada, OID_AUTO, default_timeout, CTLFLAG_RWTUN, &ada_default_timeout, 0, "Normal I/O timeout (in seconds)"); -TUNABLE_INT("kern.cam.ada.default_timeout", &ada_default_timeout); -SYSCTL_INT(_kern_cam_ada, OID_AUTO, send_ordered, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_ada, OID_AUTO, send_ordered, CTLFLAG_RWTUN, &ada_send_ordered, 0, "Send Ordered Tags"); -TUNABLE_INT("kern.cam.ada.send_ordered", &ada_send_ordered); -SYSCTL_INT(_kern_cam_ada, OID_AUTO, spindown_shutdown, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_ada, OID_AUTO, spindown_shutdown, CTLFLAG_RWTUN, &ada_spindown_shutdown, 0, "Spin down upon shutdown"); -TUNABLE_INT("kern.cam.ada.spindown_shutdown", &ada_spindown_shutdown); -SYSCTL_INT(_kern_cam_ada, OID_AUTO, spindown_suspend, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_ada, OID_AUTO, spindown_suspend, CTLFLAG_RWTUN, &ada_spindown_suspend, 0, "Spin down upon suspend"); -TUNABLE_INT("kern.cam.ada.spindown_suspend", &ada_spindown_suspend); -SYSCTL_INT(_kern_cam_ada, OID_AUTO, read_ahead, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_ada, OID_AUTO, read_ahead, CTLFLAG_RWTUN, &ada_read_ahead, 0, "Enable disk read-ahead"); -TUNABLE_INT("kern.cam.ada.read_ahead", &ada_read_ahead); -SYSCTL_INT(_kern_cam_ada, OID_AUTO, write_cache, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_ada, OID_AUTO, write_cache, CTLFLAG_RWTUN, &ada_write_cache, 0, "Enable disk write cache"); -TUNABLE_INT("kern.cam.ada.write_cache", &ada_write_cache); /* * ADA_ORDEREDTAG_INTERVAL determines how often, relative diff --git a/sys/cam/ata/ata_pmp.c b/sys/cam/ata/ata_pmp.c index bd4d25a67defd..fab0e6f1f5743 100644 --- a/sys/cam/ata/ata_pmp.c +++ b/sys/cam/ata/ata_pmp.c @@ -139,15 +139,12 @@ static int pmp_hide_special = PMP_DEFAULT_HIDE_SPECIAL; static SYSCTL_NODE(_kern_cam, OID_AUTO, pmp, CTLFLAG_RD, 0, "CAM Direct Access Disk driver"); -SYSCTL_INT(_kern_cam_pmp, OID_AUTO, retry_count, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_pmp, OID_AUTO, retry_count, CTLFLAG_RWTUN, &pmp_retry_count, 0, "Normal I/O retry count"); -TUNABLE_INT("kern.cam.pmp.retry_count", &pmp_retry_count); -SYSCTL_INT(_kern_cam_pmp, OID_AUTO, default_timeout, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_pmp, OID_AUTO, default_timeout, CTLFLAG_RWTUN, &pmp_default_timeout, 0, "Normal I/O timeout (in seconds)"); -TUNABLE_INT("kern.cam.pmp.default_timeout", &pmp_default_timeout); -SYSCTL_INT(_kern_cam_pmp, OID_AUTO, hide_special, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_pmp, OID_AUTO, hide_special, CTLFLAG_RWTUN, &pmp_hide_special, 0, "Hide extra ports"); -TUNABLE_INT("kern.cam.pmp.hide_special", &pmp_hide_special); static struct periph_driver pmpdriver = { diff --git a/sys/cam/cam.c b/sys/cam/cam.c index f608d6f887290..939dd76c30689 100644 --- a/sys/cam/cam.c +++ b/sys/cam/cam.c @@ -116,7 +116,6 @@ SYSCTL_NODE(_kern, OID_AUTO, cam, CTLFLAG_RD, 0, "CAM Subsystem"); #endif int cam_sort_io_queues = CAM_DEFAULT_SORT_IO_QUEUES; -TUNABLE_INT("kern.cam.sort_io_queues", &cam_sort_io_queues); SYSCTL_INT(_kern_cam, OID_AUTO, sort_io_queues, CTLFLAG_RWTUN, &cam_sort_io_queues, 0, "Sort IO queues to try and optimise disk access patterns"); #endif diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c index bfad6dd95cbd6..4a8f14b0f7324 100644 --- a/sys/cam/cam_xpt.c +++ b/sys/cam/cam_xpt.c @@ -149,7 +149,6 @@ typedef int xpt_pdrvfunc_t (struct periph_driver **pdrv, void *arg); /* Transport layer configuration information */ static struct xpt_softc xsoftc; -TUNABLE_INT("kern.cam.boot_delay", &xsoftc.boot_delay); SYSCTL_INT(_kern_cam, OID_AUTO, boot_delay, CTLFLAG_RDTUN, &xsoftc.boot_delay, 0, "Bus registration wait time"); @@ -163,7 +162,6 @@ static struct cam_doneq cam_doneqs[MAXCPU]; static int cam_num_doneqs; static struct proc *cam_proc; -TUNABLE_INT("kern.cam.num_doneqs", &cam_num_doneqs); SYSCTL_INT(_kern_cam, OID_AUTO, num_doneqs, CTLFLAG_RDTUN, &cam_num_doneqs, 0, "Number of completion queues/threads"); @@ -197,12 +195,10 @@ static struct cdevsw xpt_cdevsw = { /* Storage for debugging datastructures */ struct cam_path *cam_dpath; u_int32_t cam_dflags = CAM_DEBUG_FLAGS; -TUNABLE_INT("kern.cam.dflags", &cam_dflags); -SYSCTL_UINT(_kern_cam, OID_AUTO, dflags, CTLFLAG_RW, +SYSCTL_UINT(_kern_cam, OID_AUTO, dflags, CTLFLAG_RWTUN, &cam_dflags, 0, "Enabled debug flags"); u_int32_t cam_debug_delay = CAM_DEBUG_DELAY; -TUNABLE_INT("kern.cam.debug_delay", &cam_debug_delay); -SYSCTL_UINT(_kern_cam, OID_AUTO, debug_delay, CTLFLAG_RW, +SYSCTL_UINT(_kern_cam, OID_AUTO, debug_delay, CTLFLAG_RWTUN, &cam_debug_delay, 0, "Delay in us after each debug message"); /* Our boot-time initialization hook */ diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c index 38de0c2214645..957614279e748 100644 --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -308,11 +308,9 @@ static int index_to_aps_page; SYSCTL_NODE(_kern_cam, OID_AUTO, ctl, CTLFLAG_RD, 0, "CAM Target Layer"); static int worker_threads = -1; -TUNABLE_INT("kern.cam.ctl.worker_threads", &worker_threads); SYSCTL_INT(_kern_cam_ctl, OID_AUTO, worker_threads, CTLFLAG_RDTUN, &worker_threads, 1, "Number of worker threads"); static int verbose = 0; -TUNABLE_INT("kern.cam.ctl.verbose", &verbose); SYSCTL_INT(_kern_cam_ctl, OID_AUTO, verbose, CTLFLAG_RWTUN, &verbose, 0, "Show SCSI errors returned to initiator"); diff --git a/sys/cam/ctl/ctl_backend_block.c b/sys/cam/ctl/ctl_backend_block.c index 95c6788120eb7..c7ec8999b4775 100644 --- a/sys/cam/ctl/ctl_backend_block.c +++ b/sys/cam/ctl/ctl_backend_block.c @@ -220,10 +220,9 @@ struct ctl_be_block_io { }; static int cbb_num_threads = 14; -TUNABLE_INT("kern.cam.ctl.block.num_threads", &cbb_num_threads); SYSCTL_NODE(_kern_cam_ctl, OID_AUTO, block, CTLFLAG_RD, 0, "CAM Target Layer Block Backend"); -SYSCTL_INT(_kern_cam_ctl_block, OID_AUTO, num_threads, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_ctl_block, OID_AUTO, num_threads, CTLFLAG_RWTUN, &cbb_num_threads, 0, "Number of threads per backing file"); static struct ctl_be_block_io *ctl_alloc_beio(struct ctl_be_block_softc *softc); diff --git a/sys/cam/ctl/ctl_frontend_iscsi.c b/sys/cam/ctl/ctl_frontend_iscsi.c index 62840811bc32f..233433784c456 100644 --- a/sys/cam/ctl/ctl_frontend_iscsi.c +++ b/sys/cam/ctl/ctl_frontend_iscsi.c @@ -85,19 +85,15 @@ static uma_zone_t cfiscsi_data_wait_zone; SYSCTL_NODE(_kern_cam_ctl, OID_AUTO, iscsi, CTLFLAG_RD, 0, "CAM Target Layer iSCSI Frontend"); static int debug = 3; -TUNABLE_INT("kern.cam.ctl.iscsi.debug", &debug); SYSCTL_INT(_kern_cam_ctl_iscsi, OID_AUTO, debug, CTLFLAG_RWTUN, &debug, 1, "Enable debug messages"); static int ping_timeout = 5; -TUNABLE_INT("kern.cam.ctl.iscsi.ping_timeout", &ping_timeout); SYSCTL_INT(_kern_cam_ctl_iscsi, OID_AUTO, ping_timeout, CTLFLAG_RWTUN, &ping_timeout, 5, "Interval between ping (NOP-Out) requests, in seconds"); static int login_timeout = 60; -TUNABLE_INT("kern.cam.ctl.iscsi.login_timeout", &login_timeout); SYSCTL_INT(_kern_cam_ctl_iscsi, OID_AUTO, login_timeout, CTLFLAG_RWTUN, &login_timeout, 60, "Time to wait for ctld(8) to finish Login Phase, in seconds"); static int maxcmdsn_delta = 256; -TUNABLE_INT("kern.cam.ctl.iscsi.maxcmdsn_delta", &maxcmdsn_delta); SYSCTL_INT(_kern_cam_ctl_iscsi, OID_AUTO, maxcmdsn_delta, CTLFLAG_RWTUN, &maxcmdsn_delta, 256, "Number of commands the initiator can send " "without confirmation"); diff --git a/sys/cam/scsi/scsi_cd.c b/sys/cam/scsi/scsi_cd.c index 81c29a6fb54cd..47a5a438d2942 100644 --- a/sys/cam/scsi/scsi_cd.c +++ b/sys/cam/scsi/scsi_cd.c @@ -277,15 +277,12 @@ static int cd_retry_count = CD_DEFAULT_RETRY; static int cd_timeout = CD_DEFAULT_TIMEOUT; static SYSCTL_NODE(_kern_cam, OID_AUTO, cd, CTLFLAG_RD, 0, "CAM CDROM driver"); -SYSCTL_INT(_kern_cam_cd, OID_AUTO, poll_period, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_cd, OID_AUTO, poll_period, CTLFLAG_RWTUN, &cd_poll_period, 0, "Media polling period in seconds"); -TUNABLE_INT("kern.cam.cd.poll_period", &cd_poll_period); -SYSCTL_INT(_kern_cam_cd, OID_AUTO, retry_count, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_cd, OID_AUTO, retry_count, CTLFLAG_RWTUN, &cd_retry_count, 0, "Normal I/O retry count"); -TUNABLE_INT("kern.cam.cd.retry_count", &cd_retry_count); -SYSCTL_INT(_kern_cam_cd, OID_AUTO, timeout, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_cd, OID_AUTO, timeout, CTLFLAG_RWTUN, &cd_timeout, 0, "Timeout, in us, for read operations"); -TUNABLE_INT("kern.cam.cd.timeout", &cd_timeout); static MALLOC_DEFINE(M_SCSICD, "scsi_cd", "scsi_cd buffers"); diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c index 1a07577020356..0b1f8d595e366 100644 --- a/sys/cam/scsi/scsi_da.c +++ b/sys/cam/scsi/scsi_da.c @@ -1188,18 +1188,14 @@ static int da_send_ordered = DA_DEFAULT_SEND_ORDERED; static SYSCTL_NODE(_kern_cam, OID_AUTO, da, CTLFLAG_RD, 0, "CAM Direct Access Disk driver"); -SYSCTL_INT(_kern_cam_da, OID_AUTO, poll_period, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_da, OID_AUTO, poll_period, CTLFLAG_RWTUN, &da_poll_period, 0, "Media polling period in seconds"); -TUNABLE_INT("kern.cam.da.poll_period", &da_poll_period); -SYSCTL_INT(_kern_cam_da, OID_AUTO, retry_count, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_da, OID_AUTO, retry_count, CTLFLAG_RWTUN, &da_retry_count, 0, "Normal I/O retry count"); -TUNABLE_INT("kern.cam.da.retry_count", &da_retry_count); -SYSCTL_INT(_kern_cam_da, OID_AUTO, default_timeout, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_da, OID_AUTO, default_timeout, CTLFLAG_RWTUN, &da_default_timeout, 0, "Normal I/O timeout (in seconds)"); -TUNABLE_INT("kern.cam.da.default_timeout", &da_default_timeout); -SYSCTL_INT(_kern_cam_da, OID_AUTO, send_ordered, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_da, OID_AUTO, send_ordered, CTLFLAG_RWTUN, &da_send_ordered, 0, "Send Ordered Tags"); -TUNABLE_INT("kern.cam.da.send_ordered", &da_send_ordered); /* * DA_ORDEREDTAG_INTERVAL determines how often, relative diff --git a/sys/cam/scsi/scsi_enc_safte.c b/sys/cam/scsi/scsi_enc_safte.c index 8282d013bb584..89f70a5ada232 100644 --- a/sys/cam/scsi/scsi_enc_safte.c +++ b/sys/cam/scsi/scsi_enc_safte.c @@ -226,9 +226,8 @@ static char *safte_2little = "Too Little Data Returned (%d) at line %d\n"; int emulate_array_devices = 1; SYSCTL_DECL(_kern_cam_enc); -SYSCTL_INT(_kern_cam_enc, OID_AUTO, emulate_array_devices, CTLFLAG_RW, +SYSCTL_INT(_kern_cam_enc, OID_AUTO, emulate_array_devices, CTLFLAG_RWTUN, &emulate_array_devices, 0, "Emulate Array Devices for SAF-TE"); -TUNABLE_INT("kern.cam.enc.emulate_array_devices", &emulate_array_devices); static int safte_fill_read_buf_io(enc_softc_t *enc, struct enc_fsm_state *state, diff --git a/sys/cam/scsi/scsi_sa.c b/sys/cam/scsi/scsi_sa.c index c1cd0f0bfdf60..16b7b149036f3 100644 --- a/sys/cam/scsi/scsi_sa.c +++ b/sys/cam/scsi/scsi_sa.c @@ -445,9 +445,10 @@ static int sa_allow_io_split = SA_DEFAULT_IO_SPLIT; * is bad behavior, because it hides the true tape block size from the * application. */ -TUNABLE_INT("kern.cam.sa.allow_io_split", &sa_allow_io_split); static SYSCTL_NODE(_kern_cam, OID_AUTO, sa, CTLFLAG_RD, 0, "CAM Sequential Access Tape Driver"); +SYSCTL_INT(_kern_cam_sa, OID_AUTO, allow_io_split, CTLFLAG_RDTUN, + &sa_allow_io_split, 0, "Default I/O split value"); static struct periph_driver sadriver = { @@ -1494,7 +1495,7 @@ sasysctlinit(void *context, int pending) goto bailout; SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), - OID_AUTO, "allow_io_split", CTLTYPE_INT | CTLFLAG_RDTUN, + OID_AUTO, "allow_io_split", CTLTYPE_INT | CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &softc->allow_io_split, 0, "Allow Splitting I/O"); SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "maxio", CTLTYPE_INT | CTLFLAG_RD, diff --git a/sys/cam/scsi/scsi_xpt.c b/sys/cam/scsi/scsi_xpt.c index 942f7121cf5a1..42b8774fd88ad 100644 --- a/sys/cam/scsi/scsi_xpt.c +++ b/sys/cam/scsi/scsi_xpt.c @@ -78,9 +78,8 @@ struct scsi_quirk_entry { #define SCSI_QUIRK(dev) ((struct scsi_quirk_entry *)((dev)->quirk)) static int cam_srch_hi = 0; -TUNABLE_INT("kern.cam.cam_srch_hi", &cam_srch_hi); static int sysctl_cam_search_luns(SYSCTL_HANDLER_ARGS); -SYSCTL_PROC(_kern_cam, OID_AUTO, cam_srch_hi, CTLTYPE_INT|CTLFLAG_RW, 0, 0, +SYSCTL_PROC(_kern_cam, OID_AUTO, cam_srch_hi, CTLTYPE_INT | CTLFLAG_RWTUN, 0, 0, sysctl_cam_search_luns, "I", "allow search above LUN 7 for SCSI3 and greater devices"); diff --git a/sys/cddl/compat/opensolaris/kern/opensolaris_kstat.c b/sys/cddl/compat/opensolaris/kern/opensolaris_kstat.c index ba6510992688a..03993553f6aa5 100644 --- a/sys/cddl/compat/opensolaris/kern/opensolaris_kstat.c +++ b/sys/cddl/compat/opensolaris/kern/opensolaris_kstat.c @@ -36,7 +36,7 @@ __FBSDID("$FreeBSD$"); static MALLOC_DEFINE(M_KSTAT, "kstat_data", "Kernel statistics"); -SYSCTL_NODE(, OID_AUTO, kstat, CTLFLAG_RW, 0, "Kernel statistics"); +SYSCTL_ROOT_NODE(OID_AUTO, kstat, CTLFLAG_RW, 0, "Kernel statistics"); kstat_t * kstat_create(char *module, int instance, char *name, char *class, uchar_t type, diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c index bc4989e32bded..b31d94818fde7 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c @@ -204,8 +204,6 @@ int zfs_arc_shrink_shift = 0; int zfs_arc_p_min_shift = 0; int zfs_disable_dup_eviction = 0; -TUNABLE_QUAD("vfs.zfs.arc_max", &zfs_arc_max); -TUNABLE_QUAD("vfs.zfs.arc_min", &zfs_arc_min); TUNABLE_QUAD("vfs.zfs.arc_meta_limit", &zfs_arc_meta_limit); SYSCTL_DECL(_vfs_zfs); SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, arc_max, CTLFLAG_RDTUN, &zfs_arc_max, 0, diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/ddt.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/ddt.c index 7863e6a660162..df5b77e14e898 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/ddt.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/ddt.c @@ -44,8 +44,7 @@ int zfs_dedup_prefetch = 1; SYSCTL_DECL(_vfs_zfs); SYSCTL_NODE(_vfs_zfs, OID_AUTO, dedup, CTLFLAG_RW, 0, "ZFS DEDUP"); -TUNABLE_INT("vfs.zfs.dedup.prefetch", &zfs_dedup_prefetch); -SYSCTL_INT(_vfs_zfs_dedup, OID_AUTO, prefetch, CTLFLAG_RW, &zfs_dedup_prefetch, +SYSCTL_INT(_vfs_zfs_dedup, OID_AUTO, prefetch, CTLFLAG_RWTUN, &zfs_dedup_prefetch, 0, "Enable/disable prefetching of dedup-ed blocks which are going to be freed"); static const ddt_ops_t *ddt_ops[DDT_TYPES] = { diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c index 4aa1c88d0a1d3..1b222b601889c 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c @@ -54,7 +54,6 @@ */ int zfs_nopwrite_enabled = 1; SYSCTL_DECL(_vfs_zfs); -TUNABLE_INT("vfs.zfs.nopwrite_enabled", &zfs_nopwrite_enabled); SYSCTL_INT(_vfs_zfs, OID_AUTO, nopwrite_enabled, CTLFLAG_RDTUN, &zfs_nopwrite_enabled, 0, "Enable nopwrite feature"); @@ -1626,8 +1625,7 @@ dmu_object_set_compress(objset_t *os, uint64_t object, uint8_t compress, } int zfs_mdcomp_disable = 0; -TUNABLE_INT("vfs.zfs.mdcomp_disable", &zfs_mdcomp_disable); -SYSCTL_INT(_vfs_zfs, OID_AUTO, mdcomp_disable, CTLFLAG_RW, +SYSCTL_INT(_vfs_zfs, OID_AUTO, mdcomp_disable, CTLFLAG_RWTUN, &zfs_mdcomp_disable, 0, "Disable metadata compression"); /* diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_zfetch.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_zfetch.c index d51a981c12733..0290b2815d833 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_zfetch.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_zfetch.c @@ -55,16 +55,12 @@ SYSCTL_DECL(_vfs_zfs); SYSCTL_INT(_vfs_zfs, OID_AUTO, prefetch_disable, CTLFLAG_RW, &zfs_prefetch_disable, 0, "Disable prefetch"); SYSCTL_NODE(_vfs_zfs, OID_AUTO, zfetch, CTLFLAG_RW, 0, "ZFS ZFETCH"); -TUNABLE_INT("vfs.zfs.zfetch.max_streams", &zfetch_max_streams); -SYSCTL_UINT(_vfs_zfs_zfetch, OID_AUTO, max_streams, CTLFLAG_RW, +SYSCTL_UINT(_vfs_zfs_zfetch, OID_AUTO, max_streams, CTLFLAG_RWTUN, &zfetch_max_streams, 0, "Max # of streams per zfetch"); -TUNABLE_INT("vfs.zfs.zfetch.min_sec_reap", &zfetch_min_sec_reap); SYSCTL_UINT(_vfs_zfs_zfetch, OID_AUTO, min_sec_reap, CTLFLAG_RDTUN, &zfetch_min_sec_reap, 0, "Min time before stream reclaim"); -TUNABLE_INT("vfs.zfs.zfetch.block_cap", &zfetch_block_cap); SYSCTL_UINT(_vfs_zfs_zfetch, OID_AUTO, block_cap, CTLFLAG_RDTUN, &zfetch_block_cap, 0, "Max number of blocks to fetch at a time"); -TUNABLE_QUAD("vfs.zfs.zfetch.array_rd_sz", &zfetch_array_rd_sz); SYSCTL_UQUAD(_vfs_zfs_zfetch, OID_AUTO, array_rd_sz, CTLFLAG_RDTUN, &zfetch_array_rd_sz, 0, "Number of bytes in a array_read at which we stop prefetching"); diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c index 213c2f2ca82e5..3ed8735338f39 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c @@ -141,23 +141,19 @@ extern int zfs_vdev_async_write_active_max_dirty_percent; SYSCTL_DECL(_vfs_zfs); -TUNABLE_QUAD("vfs.zfs.dirty_data_max", &zfs_dirty_data_max); SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, dirty_data_max, CTLFLAG_RWTUN, &zfs_dirty_data_max, 0, "The maximum amount of dirty data in bytes after which new writes are " "halted until space becomes available"); -TUNABLE_QUAD("vfs.zfs.dirty_data_max_max", &zfs_dirty_data_max_max); SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, dirty_data_max_max, CTLFLAG_RDTUN, &zfs_dirty_data_max_max, 0, "The absolute cap on dirty_data_max when auto calculating"); -TUNABLE_INT("vfs.zfs.dirty_data_max_percent", &zfs_dirty_data_max_percent); SYSCTL_INT(_vfs_zfs, OID_AUTO, dirty_data_max_percent, CTLFLAG_RDTUN, &zfs_dirty_data_max_percent, 0, "The percent of physical memory used to auto calculate dirty_data_max"); -TUNABLE_QUAD("vfs.zfs.dirty_data_sync", &zfs_dirty_data_sync); SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, dirty_data_sync, CTLFLAG_RWTUN, &zfs_dirty_data_sync, 0, "Force a txg if the number of dirty buffer bytes exceed this value"); diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c index c62be1adda89a..c78a1112639f5 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c @@ -71,32 +71,23 @@ boolean_t zfs_no_scrub_io = B_FALSE; /* set to disable scrub i/o */ boolean_t zfs_no_scrub_prefetch = B_FALSE; /* set to disable srub prefetching */ SYSCTL_DECL(_vfs_zfs); -TUNABLE_INT("vfs.zfs.top_maxinflight", &zfs_top_maxinflight); -SYSCTL_UINT(_vfs_zfs, OID_AUTO, top_maxinflight, CTLFLAG_RW, +SYSCTL_UINT(_vfs_zfs, OID_AUTO, top_maxinflight, CTLFLAG_RWTUN, &zfs_top_maxinflight, 0, "Maximum I/Os per top-level vdev"); -TUNABLE_INT("vfs.zfs.resilver_delay", &zfs_resilver_delay); -SYSCTL_UINT(_vfs_zfs, OID_AUTO, resilver_delay, CTLFLAG_RW, +SYSCTL_UINT(_vfs_zfs, OID_AUTO, resilver_delay, CTLFLAG_RWTUN, &zfs_resilver_delay, 0, "Number of ticks to delay resilver"); -TUNABLE_INT("vfs.zfs.scrub_delay", &zfs_scrub_delay); -SYSCTL_UINT(_vfs_zfs, OID_AUTO, scrub_delay, CTLFLAG_RW, +SYSCTL_UINT(_vfs_zfs, OID_AUTO, scrub_delay, CTLFLAG_RWTUN, &zfs_scrub_delay, 0, "Number of ticks to delay scrub"); -TUNABLE_INT("vfs.zfs.scan_idle", &zfs_scan_idle); -SYSCTL_UINT(_vfs_zfs, OID_AUTO, scan_idle, CTLFLAG_RW, +SYSCTL_UINT(_vfs_zfs, OID_AUTO, scan_idle, CTLFLAG_RWTUN, &zfs_scan_idle, 0, "Idle scan window in clock ticks"); -TUNABLE_INT("vfs.zfs.scan_min_time_ms", &zfs_scan_min_time_ms); -SYSCTL_UINT(_vfs_zfs, OID_AUTO, scan_min_time_ms, CTLFLAG_RW, +SYSCTL_UINT(_vfs_zfs, OID_AUTO, scan_min_time_ms, CTLFLAG_RWTUN, &zfs_scan_min_time_ms, 0, "Min millisecs to scrub per txg"); -TUNABLE_INT("vfs.zfs.free_min_time_ms", &zfs_free_min_time_ms); -SYSCTL_UINT(_vfs_zfs, OID_AUTO, free_min_time_ms, CTLFLAG_RW, +SYSCTL_UINT(_vfs_zfs, OID_AUTO, free_min_time_ms, CTLFLAG_RWTUN, &zfs_free_min_time_ms, 0, "Min millisecs to free per txg"); -TUNABLE_INT("vfs.zfs.resilver_min_time_ms", &zfs_resilver_min_time_ms); -SYSCTL_UINT(_vfs_zfs, OID_AUTO, resilver_min_time_ms, CTLFLAG_RW, +SYSCTL_UINT(_vfs_zfs, OID_AUTO, resilver_min_time_ms, CTLFLAG_RWTUN, &zfs_resilver_min_time_ms, 0, "Min millisecs to resilver per txg"); -TUNABLE_INT("vfs.zfs.no_scrub_io", &zfs_no_scrub_io); -SYSCTL_INT(_vfs_zfs, OID_AUTO, no_scrub_io, CTLFLAG_RW, +SYSCTL_INT(_vfs_zfs, OID_AUTO, no_scrub_io, CTLFLAG_RWTUN, &zfs_no_scrub_io, 0, "Disable scrub I/O"); -TUNABLE_INT("vfs.zfs.no_scrub_prefetch", &zfs_no_scrub_prefetch); -SYSCTL_INT(_vfs_zfs, OID_AUTO, no_scrub_prefetch, CTLFLAG_RW, +SYSCTL_INT(_vfs_zfs, OID_AUTO, no_scrub_prefetch, CTLFLAG_RWTUN, &zfs_no_scrub_prefetch, 0, "Disable scrub prefetching"); enum ddt_class zfs_scrub_ddt_class_max = DDT_CLASS_DUPLICATE; diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c index 407c6eaf429f5..93fd28edded8c 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c @@ -55,7 +55,6 @@ SYSCTL_NODE(_vfs_zfs, OID_AUTO, metaslab, CTLFLAG_RW, 0, "ZFS metaslab"); uint64_t metaslab_aliquot = 512ULL << 10; uint64_t metaslab_gang_bang = SPA_MAXBLOCKSIZE + 1; /* force gang blocks */ -TUNABLE_QUAD("vfs.zfs.metaslab.gang_bang", &metaslab_gang_bang); SYSCTL_QUAD(_vfs_zfs_metaslab, OID_AUTO, gang_bang, CTLFLAG_RWTUN, &metaslab_gang_bang, 0, "Force gang block allocation for blocks larger than or equal to this value"); @@ -67,7 +66,6 @@ SYSCTL_QUAD(_vfs_zfs_metaslab, OID_AUTO, gang_bang, CTLFLAG_RWTUN, * Values should be greater than or equal to 100. */ int zfs_condense_pct = 200; -TUNABLE_INT("vfs.zfs.condense_pct", &zfs_condense_pct); SYSCTL_INT(_vfs_zfs, OID_AUTO, condense_pct, CTLFLAG_RWTUN, &zfs_condense_pct, 0, "Condense on-disk spacemap when it is more than this many percents" @@ -87,7 +85,6 @@ SYSCTL_INT(_vfs_zfs, OID_AUTO, condense_pct, CTLFLAG_RWTUN, * no metaslab group will be excluded based on this criterion. */ int zfs_mg_noalloc_threshold = 0; -TUNABLE_INT("vfs.zfs.mg_noalloc_threshold", &zfs_mg_noalloc_threshold); SYSCTL_INT(_vfs_zfs, OID_AUTO, mg_noalloc_threshold, CTLFLAG_RWTUN, &zfs_mg_noalloc_threshold, 0, "Percentage of metaslab group size that should be free" @@ -97,7 +94,6 @@ SYSCTL_INT(_vfs_zfs, OID_AUTO, mg_noalloc_threshold, CTLFLAG_RWTUN, * When set will load all metaslabs when pool is first opened. */ int metaslab_debug_load = 0; -TUNABLE_INT("vfs.zfs.metaslab.debug_load", &metaslab_debug_load); SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, debug_load, CTLFLAG_RWTUN, &metaslab_debug_load, 0, "Load all metaslabs when pool is first opened"); @@ -106,7 +102,6 @@ SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, debug_load, CTLFLAG_RWTUN, * When set will prevent metaslabs from being unloaded. */ int metaslab_debug_unload = 0; -TUNABLE_INT("vfs.zfs.metaslab.debug_unload", &metaslab_debug_unload); SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, debug_unload, CTLFLAG_RWTUN, &metaslab_debug_unload, 0, "Prevent metaslabs from being unloaded"); @@ -118,8 +113,6 @@ SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, debug_unload, CTLFLAG_RWTUN, * aggressive strategy (i.e search by size rather than offset). */ uint64_t metaslab_df_alloc_threshold = SPA_MAXBLOCKSIZE; -TUNABLE_QUAD("vfs.zfs.metaslab.df_alloc_threshold", - &metaslab_df_alloc_threshold); SYSCTL_QUAD(_vfs_zfs_metaslab, OID_AUTO, df_alloc_threshold, CTLFLAG_RWTUN, &metaslab_df_alloc_threshold, 0, "Minimum size which forces the dynamic allocator to change it's allocation strategy"); @@ -131,27 +124,25 @@ SYSCTL_QUAD(_vfs_zfs_metaslab, OID_AUTO, df_alloc_threshold, CTLFLAG_RWTUN, * switch to using best-fit allocations. */ int metaslab_df_free_pct = 4; -TUNABLE_INT("vfs.zfs.metaslab.df_free_pct", &metaslab_df_free_pct); SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, df_free_pct, CTLFLAG_RWTUN, &metaslab_df_free_pct, 0, - "The minimum free space, in percent, which must be available in a space map to continue allocations in a first-fit fashion"); + "The minimum free space, in percent, which must be available in a " + "space map to continue allocations in a first-fit fashion"); /* * A metaslab is considered "free" if it contains a contiguous * segment which is greater than metaslab_min_alloc_size. */ uint64_t metaslab_min_alloc_size = DMU_MAX_ACCESS; -TUNABLE_QUAD("vfs.zfs.metaslab.min_alloc_size", - &metaslab_min_alloc_size); SYSCTL_QUAD(_vfs_zfs_metaslab, OID_AUTO, min_alloc_size, CTLFLAG_RWTUN, &metaslab_min_alloc_size, 0, - "A metaslab is considered \"free\" if it contains a contiguous segment which is greater than vfs.zfs.metaslab.min_alloc_size"); + "A metaslab is considered \"free\" if it contains a contiguous " + "segment which is greater than vfs.zfs.metaslab.min_alloc_size"); /* * Percentage of all cpus that can be used by the metaslab taskq. */ int metaslab_load_pct = 50; -TUNABLE_INT("vfs.zfs.metaslab.load_pct", &metaslab_load_pct); SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, load_pct, CTLFLAG_RWTUN, &metaslab_load_pct, 0, "Percentage of cpus that can be used by the metaslab taskq"); @@ -162,7 +153,6 @@ SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, load_pct, CTLFLAG_RWTUN, * keep it loaded. */ int metaslab_unload_delay = TXG_SIZE * 2; -TUNABLE_INT("vfs.zfs.metaslab.unload_delay", &metaslab_unload_delay); SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, unload_delay, CTLFLAG_RWTUN, &metaslab_unload_delay, 0, "Number of TXGs that an unused metaslab can be kept in memory"); @@ -173,13 +163,11 @@ SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, unload_delay, CTLFLAG_RWTUN, boolean_t zfs_write_to_degraded = B_FALSE; SYSCTL_INT(_vfs_zfs, OID_AUTO, write_to_degraded, CTLFLAG_RWTUN, &zfs_write_to_degraded, 0, "Allow writing data to degraded vdevs"); -TUNABLE_INT("vfs.zfs.write_to_degraded", &zfs_write_to_degraded); /* * Max number of metaslabs per group to preload. */ int metaslab_preload_limit = SPA_DVAS_PER_BP; -TUNABLE_INT("vfs.zfs.metaslab.preload_limit", &metaslab_preload_limit); SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, preload_limit, CTLFLAG_RWTUN, &metaslab_preload_limit, 0, "Max number of metaslabs per group to preload"); @@ -188,7 +176,6 @@ SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, preload_limit, CTLFLAG_RWTUN, * Enable/disable preloading of metaslab. */ boolean_t metaslab_preload_enabled = B_TRUE; -TUNABLE_INT("vfs.zfs.metaslab.preload_enabled", &metaslab_preload_enabled); SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, preload_enabled, CTLFLAG_RWTUN, &metaslab_preload_enabled, 0, "Max number of metaslabs per group to preload"); @@ -197,8 +184,6 @@ SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, preload_enabled, CTLFLAG_RWTUN, * Enable/disable additional weight factor for each metaslab. */ boolean_t metaslab_weight_factor_enable = B_FALSE; -TUNABLE_INT("vfs.zfs.metaslab.weight_factor_enable", - &metaslab_weight_factor_enable); SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, weight_factor_enable, CTLFLAG_RWTUN, &metaslab_weight_factor_enable, 0, "Enable additional weight factor for each metaslab"); diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c index 6c79a3083e2b2..097dc8635988b 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c @@ -84,8 +84,7 @@ static int check_hostid = 1; SYSCTL_DECL(_vfs_zfs); -TUNABLE_INT("vfs.zfs.check_hostid", &check_hostid); -SYSCTL_INT(_vfs_zfs, OID_AUTO, check_hostid, CTLFLAG_RW, &check_hostid, 0, +SYSCTL_INT(_vfs_zfs, OID_AUTO, check_hostid, CTLFLAG_RWTUN, &check_hostid, 0, "Check hostid on import?"); /* diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c index dbcb72916f0f3..0588fbda2d60d 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c @@ -244,7 +244,6 @@ int zfs_flags = ~(ZFS_DEBUG_DPRINTF | ZFS_DEBUG_SPA); int zfs_flags = 0; #endif SYSCTL_DECL(_debug); -TUNABLE_INT("debug.zfs_flags", &zfs_flags); SYSCTL_INT(_debug, OID_AUTO, zfs_flags, CTLFLAG_RWTUN, &zfs_flags, 0, "ZFS debug flags."); @@ -257,7 +256,6 @@ SYSCTL_INT(_debug, OID_AUTO, zfs_flags, CTLFLAG_RWTUN, &zfs_flags, 0, */ int zfs_recover = 0; SYSCTL_DECL(_vfs_zfs); -TUNABLE_INT("vfs.zfs.recover", &zfs_recover); SYSCTL_INT(_vfs_zfs, OID_AUTO, recover, CTLFLAG_RDTUN, &zfs_recover, 0, "Try to recover from otherwise-fatal errors."); @@ -270,7 +268,6 @@ SYSCTL_INT(_vfs_zfs, OID_AUTO, recover, CTLFLAG_RDTUN, &zfs_recover, 0, * in a system panic. */ uint64_t zfs_deadman_synctime_ms = 1000000ULL; -TUNABLE_QUAD("vfs.zfs.deadman_synctime_ms", &zfs_deadman_synctime_ms); SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, deadman_synctime_ms, CTLFLAG_RDTUN, &zfs_deadman_synctime_ms, 0, "Stalled ZFS I/O expiration time in milliseconds"); @@ -280,7 +277,6 @@ SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, deadman_synctime_ms, CTLFLAG_RDTUN, * for hung I/O. */ uint64_t zfs_deadman_checktime_ms = 5000ULL; -TUNABLE_QUAD("vfs.zfs.deadman_checktime_ms", &zfs_deadman_checktime_ms); SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, deadman_checktime_ms, CTLFLAG_RDTUN, &zfs_deadman_checktime_ms, 0, "Period of checks for stalled ZFS I/O in milliseconds"); @@ -290,7 +286,6 @@ SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, deadman_checktime_ms, CTLFLAG_RDTUN, * zfs_deadman_init() */ int zfs_deadman_enabled = -1; -TUNABLE_INT("vfs.zfs.deadman_enabled", &zfs_deadman_enabled); SYSCTL_INT(_vfs_zfs, OID_AUTO, deadman_enabled, CTLFLAG_RDTUN, &zfs_deadman_enabled, 0, "Kernel panic on stalled ZFS I/O"); @@ -304,7 +299,6 @@ SYSCTL_INT(_vfs_zfs, OID_AUTO, deadman_enabled, CTLFLAG_RDTUN, * (VDEV_RAIDZ_MAXPARITY + 1) * SPA_DVAS_PER_BP * 2 == 24 */ int spa_asize_inflation = 24; -TUNABLE_INT("vfs.zfs.spa_asize_inflation", &spa_asize_inflation); SYSCTL_INT(_vfs_zfs, OID_AUTO, spa_asize_inflation, CTLFLAG_RWTUN, &spa_asize_inflation, 0, "Worst case inflation factor for single sector writes"); diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c index 7e981993ca468..5c52042a0149b 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c @@ -85,31 +85,22 @@ static u_int trim_vdev_max_pending = 64; SYSCTL_DECL(_vfs_zfs); SYSCTL_NODE(_vfs_zfs, OID_AUTO, trim, CTLFLAG_RD, 0, "ZFS TRIM"); -TUNABLE_INT("vfs.zfs.trim.txg_delay", &trim_txg_delay); SYSCTL_UINT(_vfs_zfs_trim, OID_AUTO, txg_delay, CTLFLAG_RWTUN, &trim_txg_delay, 0, "Delay TRIMs by up to this many TXGs"); - -TUNABLE_INT("vfs.zfs.trim.timeout", &trim_timeout); SYSCTL_UINT(_vfs_zfs_trim, OID_AUTO, timeout, CTLFLAG_RWTUN, &trim_timeout, 0, "Delay TRIMs by up to this many seconds"); - -TUNABLE_INT("vfs.zfs.trim.max_interval", &trim_max_interval); SYSCTL_UINT(_vfs_zfs_trim, OID_AUTO, max_interval, CTLFLAG_RWTUN, &trim_max_interval, 0, "Maximum interval between TRIM queue processing (seconds)"); SYSCTL_DECL(_vfs_zfs_vdev); -TUNABLE_QUAD("vfs.zfs.vdev.trim_max_bytes", &trim_vdev_max_bytes); SYSCTL_QUAD(_vfs_zfs_vdev, OID_AUTO, trim_max_bytes, CTLFLAG_RWTUN, &trim_vdev_max_bytes, 0, "Maximum pending TRIM bytes for a vdev"); - -TUNABLE_INT("vfs.zfs.vdev.trim_max_pending", &trim_vdev_max_pending); SYSCTL_UINT(_vfs_zfs_vdev, OID_AUTO, trim_max_pending, CTLFLAG_RWTUN, &trim_vdev_max_pending, 0, "Maximum pending TRIM segments for a vdev"); - static void trim_map_vdev_commit_done(spa_t *spa, vdev_t *vd); static int diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/txg.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/txg.c index 0201bef3ae9d5..6f52266d1a2d1 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/txg.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/txg.c @@ -112,8 +112,7 @@ int zfs_txg_timeout = 5; /* max seconds worth of delta per txg */ SYSCTL_DECL(_vfs_zfs); SYSCTL_NODE(_vfs_zfs, OID_AUTO, txg, CTLFLAG_RW, 0, "ZFS TXG"); -TUNABLE_INT("vfs.zfs.txg.timeout", &zfs_txg_timeout); -SYSCTL_INT(_vfs_zfs_txg, OID_AUTO, timeout, CTLFLAG_RW, &zfs_txg_timeout, 0, +SYSCTL_INT(_vfs_zfs_txg, OID_AUTO, timeout, CTLFLAG_RWTUN, &zfs_txg_timeout, 0, "Maximum seconds worth of delta per txg"); /* diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_cache.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_cache.c index 2ad15fe8227e2..a3e9b02a71ce9 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_cache.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_cache.c @@ -90,13 +90,10 @@ int zfs_vdev_cache_bshift = 16; SYSCTL_DECL(_vfs_zfs_vdev); SYSCTL_NODE(_vfs_zfs_vdev, OID_AUTO, cache, CTLFLAG_RW, 0, "ZFS VDEV Cache"); -TUNABLE_INT("vfs.zfs.vdev.cache.max", &zfs_vdev_cache_max); SYSCTL_INT(_vfs_zfs_vdev_cache, OID_AUTO, max, CTLFLAG_RDTUN, &zfs_vdev_cache_max, 0, "Maximum I/O request size that increase read size"); -TUNABLE_INT("vfs.zfs.vdev.cache.size", &zfs_vdev_cache_size); SYSCTL_INT(_vfs_zfs_vdev_cache, OID_AUTO, size, CTLFLAG_RDTUN, &zfs_vdev_cache_size, 0, "Size of VDEV cache"); -TUNABLE_INT("vfs.zfs.vdev.cache.bshift", &zfs_vdev_cache_bshift); SYSCTL_INT(_vfs_zfs_vdev_cache, OID_AUTO, bshift, CTLFLAG_RDTUN, &zfs_vdev_cache_bshift, 0, "Turn too small requests into 1 << this value"); diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c index b64ebddbcb1a7..c38a2fc869ccb 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c @@ -53,14 +53,12 @@ DECLARE_GEOM_CLASS(zfs_vdev_class, zfs_vdev); SYSCTL_DECL(_vfs_zfs_vdev); /* Don't send BIO_FLUSH. */ -static int vdev_geom_bio_flush_disable = 0; -TUNABLE_INT("vfs.zfs.vdev.bio_flush_disable", &vdev_geom_bio_flush_disable); -SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, bio_flush_disable, CTLFLAG_RW, +static int vdev_geom_bio_flush_disable; +SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, bio_flush_disable, CTLFLAG_RWTUN, &vdev_geom_bio_flush_disable, 0, "Disable BIO_FLUSH"); /* Don't send BIO_DELETE. */ -static int vdev_geom_bio_delete_disable = 0; -TUNABLE_INT("vfs.zfs.vdev.bio_delete_disable", &vdev_geom_bio_delete_disable); -SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, bio_delete_disable, CTLFLAG_RW, +static int vdev_geom_bio_delete_disable; +SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, bio_delete_disable, CTLFLAG_RWTUN, &vdev_geom_bio_delete_disable, 0, "Disable BIO_DELETE"); static void diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_mirror.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_mirror.c index 0b8d449f4aa15..d9b15db400feb 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_mirror.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_mirror.c @@ -74,32 +74,26 @@ static SYSCTL_NODE(_vfs_zfs_vdev, OID_AUTO, mirror, CTLFLAG_RD, 0, /* Rotating media load calculation configuration. */ static int rotating_inc = 0; -TUNABLE_INT("vfs.zfs.vdev.mirror.rotating_inc", &rotating_inc); -SYSCTL_INT(_vfs_zfs_vdev_mirror, OID_AUTO, rotating_inc, CTLFLAG_RW, +SYSCTL_INT(_vfs_zfs_vdev_mirror, OID_AUTO, rotating_inc, CTLFLAG_RWTUN, &rotating_inc, 0, "Rotating media load increment for non-seeking I/O's"); static int rotating_seek_inc = 5; -TUNABLE_INT("vfs.zfs.vdev.mirror.rotating_seek_inc", &rotating_seek_inc); -SYSCTL_INT(_vfs_zfs_vdev_mirror, OID_AUTO, rotating_seek_inc, CTLFLAG_RW, +SYSCTL_INT(_vfs_zfs_vdev_mirror, OID_AUTO, rotating_seek_inc, CTLFLAG_RWTUN, &rotating_seek_inc, 0, "Rotating media load increment for seeking I/O's"); static int rotating_seek_offset = 1 * 1024 * 1024; -TUNABLE_INT("vfs.zfs.vdev.mirror.rotating_seek_offset", &rotating_seek_offset); -SYSCTL_INT(_vfs_zfs_vdev_mirror, OID_AUTO, rotating_seek_offset, CTLFLAG_RW, +SYSCTL_INT(_vfs_zfs_vdev_mirror, OID_AUTO, rotating_seek_offset, CTLFLAG_RWTUN, &rotating_seek_offset, 0, "Offset in bytes from the last I/O which " "triggers a reduced rotating media seek increment"); /* Non-rotating media load calculation configuration. */ static int non_rotating_inc = 0; -TUNABLE_INT("vfs.zfs.vdev.mirror.non_rotating_inc", &non_rotating_inc); -SYSCTL_INT(_vfs_zfs_vdev_mirror, OID_AUTO, non_rotating_inc, CTLFLAG_RW, +SYSCTL_INT(_vfs_zfs_vdev_mirror, OID_AUTO, non_rotating_inc, CTLFLAG_RWTUN, &non_rotating_inc, 0, "Non-rotating media load increment for non-seeking I/O's"); static int non_rotating_seek_inc = 1; -TUNABLE_INT("vfs.zfs.vdev.mirror.non_rotating_seek_inc", - &non_rotating_seek_inc); -SYSCTL_INT(_vfs_zfs_vdev_mirror, OID_AUTO, non_rotating_seek_inc, CTLFLAG_RW, +SYSCTL_INT(_vfs_zfs_vdev_mirror, OID_AUTO, non_rotating_seek_inc, CTLFLAG_RWTUN, &non_rotating_seek_inc, 0, "Non-rotating media load increment for seeking I/O's"); diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c index 60fd4c3eedf2f..b2e10c1105825 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c @@ -176,23 +176,18 @@ int zfs_vdev_write_gap_limit = 4 << 10; #ifdef __FreeBSD__ SYSCTL_DECL(_vfs_zfs_vdev); -TUNABLE_INT("vfs.zfs.vdev.max_active", &zfs_vdev_max_active); -SYSCTL_UINT(_vfs_zfs_vdev, OID_AUTO, max_active, CTLFLAG_RW, +SYSCTL_UINT(_vfs_zfs_vdev, OID_AUTO, max_active, CTLFLAG_RWTUN, &zfs_vdev_max_active, 0, "The maximum number of I/Os of all types active for each device."); #define ZFS_VDEV_QUEUE_KNOB_MIN(name) \ -TUNABLE_INT("vfs.zfs.vdev." #name "_min_active", \ - &zfs_vdev_ ## name ## _min_active); \ -SYSCTL_UINT(_vfs_zfs_vdev, OID_AUTO, name ## _min_active, CTLFLAG_RW, \ +SYSCTL_UINT(_vfs_zfs_vdev, OID_AUTO, name ## _min_active, CTLFLAG_RWTUN,\ &zfs_vdev_ ## name ## _min_active, 0, \ "Initial number of I/O requests of type " #name \ " active for each device"); #define ZFS_VDEV_QUEUE_KNOB_MAX(name) \ -TUNABLE_INT("vfs.zfs.vdev." #name "_max_active", \ - &zfs_vdev_ ## name ## _max_active); \ -SYSCTL_UINT(_vfs_zfs_vdev, OID_AUTO, name ## _max_active, CTLFLAG_RW, \ +SYSCTL_UINT(_vfs_zfs_vdev, OID_AUTO, name ## _max_active, CTLFLAG_RWTUN,\ &zfs_vdev_ ## name ## _max_active, 0, \ "Maximum number of I/O requests of type " #name \ " active for each device"); @@ -212,16 +207,13 @@ ZFS_VDEV_QUEUE_KNOB_MAX(trim); #undef ZFS_VDEV_QUEUE_KNOB -TUNABLE_INT("vfs.zfs.vdev.aggregation_limit", &zfs_vdev_aggregation_limit); -SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, aggregation_limit, CTLFLAG_RW, +SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, aggregation_limit, CTLFLAG_RWTUN, &zfs_vdev_aggregation_limit, 0, "I/O requests are aggregated up to this size"); -TUNABLE_INT("vfs.zfs.vdev.read_gap_limit", &zfs_vdev_read_gap_limit); -SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, read_gap_limit, CTLFLAG_RW, +SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, read_gap_limit, CTLFLAG_RWTUN, &zfs_vdev_read_gap_limit, 0, "Acceptable gap between two reads being aggregated"); -TUNABLE_INT("vfs.zfs.vdev.write_gap_limit", &zfs_vdev_write_gap_limit); -SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, write_gap_limit, CTLFLAG_RW, +SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, write_gap_limit, CTLFLAG_RWTUN, &zfs_vdev_write_gap_limit, 0, "Acceptable gap between two writes being aggregated"); #endif diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c index 4f7c082cbefe0..6b5b86de737dc 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c @@ -195,8 +195,7 @@ CTASSERT(sizeof(zfs_cmd_t) < IOCPARM_MAX); static int snapshot_list_prefetch; SYSCTL_DECL(_vfs_zfs); -TUNABLE_INT("vfs.zfs.snapshot_list_prefetch", &snapshot_list_prefetch); -SYSCTL_INT(_vfs_zfs, OID_AUTO, snapshot_list_prefetch, CTLFLAG_RW, +SYSCTL_INT(_vfs_zfs, OID_AUTO, snapshot_list_prefetch, CTLFLAG_RWTUN, &snapshot_list_prefetch, 0, "Prefetch data when listing snapshots"); static struct cdev *zfsdev; diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c index 7ce41a137a199..5f2cf3f142033 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c @@ -74,8 +74,7 @@ SYSCTL_INT(_vfs_zfs, OID_AUTO, super_owner, CTLFLAG_RW, &zfs_super_owner, 0, "File system owner can perform privileged operation on his file systems"); int zfs_debug_level; -TUNABLE_INT("vfs.zfs.debug", &zfs_debug_level); -SYSCTL_INT(_vfs_zfs, OID_AUTO, debug, CTLFLAG_RW, &zfs_debug_level, 0, +SYSCTL_INT(_vfs_zfs, OID_AUTO, debug, CTLFLAG_RWTUN, &zfs_debug_level, 0, "Debug level"); SYSCTL_NODE(_vfs_zfs, OID_AUTO, version, CTLFLAG_RD, 0, "ZFS versions"); diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c index ea5bb13a77791..c17c96fbba584 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c @@ -70,8 +70,7 @@ */ int zil_replay_disable = 0; SYSCTL_DECL(_vfs_zfs); -TUNABLE_INT("vfs.zfs.zil_replay_disable", &zil_replay_disable); -SYSCTL_INT(_vfs_zfs, OID_AUTO, zil_replay_disable, CTLFLAG_RW, +SYSCTL_INT(_vfs_zfs, OID_AUTO, zil_replay_disable, CTLFLAG_RWTUN, &zil_replay_disable, 0, "Disable intent logging replay"); /* @@ -80,12 +79,10 @@ SYSCTL_INT(_vfs_zfs, OID_AUTO, zil_replay_disable, CTLFLAG_RW, * out-of-order write cache is enabled. */ boolean_t zfs_nocacheflush = B_FALSE; -TUNABLE_INT("vfs.zfs.cache_flush_disable", &zfs_nocacheflush); SYSCTL_INT(_vfs_zfs, OID_AUTO, cache_flush_disable, CTLFLAG_RDTUN, &zfs_nocacheflush, 0, "Disable cache flush"); boolean_t zfs_trim_enabled = B_TRUE; SYSCTL_DECL(_vfs_zfs_trim); -TUNABLE_INT("vfs.zfs.trim.enabled", &zfs_trim_enabled); SYSCTL_INT(_vfs_zfs_trim, OID_AUTO, enabled, CTLFLAG_RDTUN, &zfs_trim_enabled, 0, "Enable ZFS TRIM"); diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c index 01946fb2b553d..ba326489ce69d 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c @@ -46,11 +46,9 @@ static int zio_use_uma = 1; #else static int zio_use_uma = 0; #endif -TUNABLE_INT("vfs.zfs.zio.use_uma", &zio_use_uma); SYSCTL_INT(_vfs_zfs_zio, OID_AUTO, use_uma, CTLFLAG_RDTUN, &zio_use_uma, 0, "Use uma(9) for ZIO allocations"); static int zio_exclude_metadata = 0; -TUNABLE_INT("vfs.zfs.zio.exclude_metadata", &zio_exclude_metadata); SYSCTL_INT(_vfs_zfs_zio, OID_AUTO, exclude_metadata, CTLFLAG_RDTUN, &zio_exclude_metadata, 0, "Exclude metadata buffers from dumps as well"); @@ -104,15 +102,12 @@ extern vmem_t *zio_alloc_arena; * regular blocks are not deferred. */ int zfs_sync_pass_deferred_free = 2; /* defer frees starting in this pass */ -TUNABLE_INT("vfs.zfs.sync_pass_deferred_free", &zfs_sync_pass_deferred_free); SYSCTL_INT(_vfs_zfs, OID_AUTO, sync_pass_deferred_free, CTLFLAG_RDTUN, &zfs_sync_pass_deferred_free, 0, "defer frees starting in this pass"); int zfs_sync_pass_dont_compress = 5; /* don't compress starting in this pass */ -TUNABLE_INT("vfs.zfs.sync_pass_dont_compress", &zfs_sync_pass_dont_compress); SYSCTL_INT(_vfs_zfs, OID_AUTO, sync_pass_dont_compress, CTLFLAG_RDTUN, &zfs_sync_pass_dont_compress, 0, "don't compress starting in this pass"); int zfs_sync_pass_rewrite = 2; /* rewrite new bps starting in this pass */ -TUNABLE_INT("vfs.zfs.sync_pass_rewrite", &zfs_sync_pass_rewrite); SYSCTL_INT(_vfs_zfs, OID_AUTO, sync_pass_rewrite, CTLFLAG_RDTUN, &zfs_sync_pass_rewrite, 0, "rewrite new bps starting in this pass"); diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c index fb3789f45b119..53877d7a6b26b 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c @@ -119,7 +119,6 @@ static uint32_t zvol_minors; SYSCTL_DECL(_vfs_zfs); SYSCTL_NODE(_vfs_zfs, OID_AUTO, vol, CTLFLAG_RW, 0, "ZFS VOLUME"); static int volmode = ZFS_VOLMODE_GEOM; -TUNABLE_INT("vfs.zfs.vol.mode", &volmode); SYSCTL_INT(_vfs_zfs_vol, OID_AUTO, mode, CTLFLAG_RWTUN, &volmode, 0, "Expose as GEOM providers (1), device files (2) or neither"); diff --git a/sys/cddl/dev/dtrace/dtrace_sysctl.c b/sys/cddl/dev/dtrace/dtrace_sysctl.c index d98111d4184b2..9f8b14fd1c661 100644 --- a/sys/cddl/dev/dtrace/dtrace_sysctl.c +++ b/sys/cddl/dev/dtrace/dtrace_sysctl.c @@ -25,8 +25,7 @@ SYSCTL_NODE(_debug, OID_AUTO, dtrace, CTLFLAG_RD, 0, "DTrace debug parameters"); int dtrace_debug = 0; -TUNABLE_INT("debug.dtrace.debug", &dtrace_debug); -SYSCTL_INT(_debug_dtrace, OID_AUTO, debug, CTLFLAG_RW, &dtrace_debug, 0, ""); +SYSCTL_INT(_debug_dtrace, OID_AUTO, debug, CTLFLAG_RWTUN, &dtrace_debug, 0, ""); /* Report registered DTrace providers. */ static int diff --git a/sys/compat/ia32/ia32_sysvec.c b/sys/compat/ia32/ia32_sysvec.c index a8e52e82eefa4..770bbbf9e4623 100644 --- a/sys/compat/ia32/ia32_sysvec.c +++ b/sys/compat/ia32/ia32_sysvec.c @@ -89,14 +89,11 @@ extern const char *freebsd32_syscallnames[]; static SYSCTL_NODE(_compat, OID_AUTO, ia32, CTLFLAG_RW, 0, "ia32 mode"); static u_long ia32_maxdsiz = IA32_MAXDSIZ; -SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxdsiz, CTLFLAG_RW, &ia32_maxdsiz, 0, ""); -TUNABLE_ULONG("compat.ia32.maxdsiz", &ia32_maxdsiz); +SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxdsiz, CTLFLAG_RWTUN, &ia32_maxdsiz, 0, ""); u_long ia32_maxssiz = IA32_MAXSSIZ; -SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxssiz, CTLFLAG_RW, &ia32_maxssiz, 0, ""); -TUNABLE_ULONG("compat.ia32.maxssiz", &ia32_maxssiz); +SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxssiz, CTLFLAG_RWTUN, &ia32_maxssiz, 0, ""); static u_long ia32_maxvmem = IA32_MAXVMEM; -SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxvmem, CTLFLAG_RW, &ia32_maxvmem, 0, ""); -TUNABLE_ULONG("compat.ia32.maxvmem", &ia32_maxvmem); +SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxvmem, CTLFLAG_RWTUN, &ia32_maxvmem, 0, ""); struct sysentvec ia32_freebsd_sysvec = { .sv_size = FREEBSD32_SYS_MAXSYSCALL, diff --git a/sys/compat/x86bios/x86bios.c b/sys/compat/x86bios/x86bios.c index 32b992974c9de..5cd31e8a71bb2 100644 --- a/sys/compat/x86bios/x86bios.c +++ b/sys/compat/x86bios/x86bios.c @@ -70,12 +70,10 @@ static struct mtx x86bios_lock; static SYSCTL_NODE(_debug, OID_AUTO, x86bios, CTLFLAG_RD, NULL, "x86bios debugging"); static int x86bios_trace_call; -TUNABLE_INT("debug.x86bios.call", &x86bios_trace_call); -SYSCTL_INT(_debug_x86bios, OID_AUTO, call, CTLFLAG_RW, &x86bios_trace_call, 0, +SYSCTL_INT(_debug_x86bios, OID_AUTO, call, CTLFLAG_RWTUN, &x86bios_trace_call, 0, "Trace far function calls"); static int x86bios_trace_int; -TUNABLE_INT("debug.x86bios.int", &x86bios_trace_int); -SYSCTL_INT(_debug_x86bios, OID_AUTO, int, CTLFLAG_RW, &x86bios_trace_int, 0, +SYSCTL_INT(_debug_x86bios, OID_AUTO, int, CTLFLAG_RWTUN, &x86bios_trace_int, 0, "Trace software interrupt handlers"); #ifdef X86BIOS_NATIVE_VM86 diff --git a/sys/dev/aac/aac_pci.c b/sys/dev/aac/aac_pci.c index ccf537ed31f65..83e7e63fda8e0 100644 --- a/sys/dev/aac/aac_pci.c +++ b/sys/dev/aac/aac_pci.c @@ -61,7 +61,6 @@ static int aac_pci_probe(device_t dev); static int aac_pci_attach(device_t dev); static int aac_enable_msi = 1; -TUNABLE_INT("hw.aac.enable_msi", &aac_enable_msi); SYSCTL_INT(_hw_aac, OID_AUTO, enable_msi, CTLFLAG_RDTUN, &aac_enable_msi, 0, "Enable MSI interrupts"); diff --git a/sys/dev/acpica/Osd/OsdSchedule.c b/sys/dev/acpica/Osd/OsdSchedule.c index e5d3d51d19fea..d49f886c9b8b4 100644 --- a/sys/dev/acpica/Osd/OsdSchedule.c +++ b/sys/dev/acpica/Osd/OsdSchedule.c @@ -56,7 +56,6 @@ ACPI_MODULE_NAME("SCHEDULE") * Allow the user to tune the maximum number of tasks we may enqueue. */ static int acpi_max_tasks = ACPI_MAX_TASKS; -TUNABLE_INT("debug.acpi.max_tasks", &acpi_max_tasks); SYSCTL_INT(_debug_acpi, OID_AUTO, max_tasks, CTLFLAG_RDTUN, &acpi_max_tasks, 0, "Maximum acpi tasks"); @@ -65,7 +64,6 @@ SYSCTL_INT(_debug_acpi, OID_AUTO, max_tasks, CTLFLAG_RDTUN, &acpi_max_tasks, * some systems have problems with increased parallelism. */ static int acpi_max_threads = ACPI_MAX_THREADS; -TUNABLE_INT("debug.acpi.max_threads", &acpi_max_threads); SYSCTL_INT(_debug_acpi, OID_AUTO, max_threads, CTLFLAG_RDTUN, &acpi_max_threads, 0, "Maximum acpi threads"); diff --git a/sys/dev/acpica/acpi_cpu.c b/sys/dev/acpica/acpi_cpu.c index f95510cf69019..5cb22a9fbc1a1 100644 --- a/sys/dev/acpica/acpi_cpu.c +++ b/sys/dev/acpica/acpi_cpu.c @@ -129,7 +129,6 @@ struct acpi_cpu_device { /* Allow users to ignore processor orders in MADT. */ static int cpu_unordered; -TUNABLE_INT("debug.acpi.cpu_unordered", &cpu_unordered); SYSCTL_INT(_debug_acpi, OID_AUTO, cpu_unordered, CTLFLAG_RDTUN, &cpu_unordered, 0, "Do not use the MADT to match ACPI Processor objects to CPUs."); diff --git a/sys/dev/acpica/acpi_ec.c b/sys/dev/acpica/acpi_ec.c index 6e2f0dd284634..6537e4062b4d3 100644 --- a/sys/dev/acpica/acpi_ec.c +++ b/sys/dev/acpica/acpi_ec.c @@ -181,16 +181,13 @@ ACPI_SERIAL_DECL(ec, "ACPI embedded controller"); static SYSCTL_NODE(_debug_acpi, OID_AUTO, ec, CTLFLAG_RD, NULL, "EC debugging"); static int ec_burst_mode; -TUNABLE_INT("debug.acpi.ec.burst", &ec_burst_mode); -SYSCTL_INT(_debug_acpi_ec, OID_AUTO, burst, CTLFLAG_RW, &ec_burst_mode, 0, +SYSCTL_INT(_debug_acpi_ec, OID_AUTO, burst, CTLFLAG_RWTUN, &ec_burst_mode, 0, "Enable use of burst mode (faster for nearly all systems)"); static int ec_polled_mode; -TUNABLE_INT("debug.acpi.ec.polled", &ec_polled_mode); -SYSCTL_INT(_debug_acpi_ec, OID_AUTO, polled, CTLFLAG_RW, &ec_polled_mode, 0, +SYSCTL_INT(_debug_acpi_ec, OID_AUTO, polled, CTLFLAG_RWTUN, &ec_polled_mode, 0, "Force use of polled mode (only if interrupt mode doesn't work)"); static int ec_timeout = EC_TIMEOUT; -TUNABLE_INT("debug.acpi.ec.timeout", &ec_timeout); -SYSCTL_INT(_debug_acpi_ec, OID_AUTO, timeout, CTLFLAG_RW, &ec_timeout, +SYSCTL_INT(_debug_acpi_ec, OID_AUTO, timeout, CTLFLAG_RWTUN, &ec_timeout, EC_TIMEOUT, "Total time spent waiting for a response (poll+sleep)"); static ACPI_STATUS diff --git a/sys/dev/amr/amr_pci.c b/sys/dev/amr/amr_pci.c index 81ddc32c7cdec..9346e8c5090b5 100644 --- a/sys/dev/amr/amr_pci.c +++ b/sys/dev/amr/amr_pci.c @@ -92,7 +92,6 @@ static int amr_setup_mbox(struct amr_softc *sc); static int amr_ccb_map(struct amr_softc *sc); static u_int amr_force_sg32 = 0; -TUNABLE_INT("hw.amr.force_sg32", &amr_force_sg32); SYSCTL_DECL(_hw_amr); SYSCTL_UINT(_hw_amr, OID_AUTO, force_sg32, CTLFLAG_RDTUN, &amr_force_sg32, 0, "Force the AMR driver to use 32bit scatter gather"); diff --git a/sys/dev/ata/ata-all.c b/sys/dev/ata/ata-all.c index b45c868d63f70..579a2c5e6f7aa 100644 --- a/sys/dev/ata/ata-all.c +++ b/sys/dev/ata/ata-all.c @@ -80,9 +80,8 @@ int ata_dma_check_80pin = 1; /* sysctl vars */ static SYSCTL_NODE(_hw, OID_AUTO, ata, CTLFLAG_RD, 0, "ATA driver parameters"); -TUNABLE_INT("hw.ata.ata_dma_check_80pin", &ata_dma_check_80pin); SYSCTL_INT(_hw_ata, OID_AUTO, ata_dma_check_80pin, - CTLFLAG_RW, &ata_dma_check_80pin, 1, + CTLFLAG_RWTUN, &ata_dma_check_80pin, 0, "Check for 80pin cable before setting ATA DMA mode"); FEATURE(ata_cam, "ATA devices are accessed through the cam(4) driver"); diff --git a/sys/dev/ath/ah_osdep.c b/sys/dev/ath/ah_osdep.c index 8e9edd139be47..fe4a657c98c85 100644 --- a/sys/dev/ath/ah_osdep.c +++ b/sys/dev/ath/ah_osdep.c @@ -96,9 +96,8 @@ static SYSCTL_NODE(_hw_ath, OID_AUTO, hal, CTLFLAG_RD, 0, #ifdef AH_DEBUG int ath_hal_debug = 0; -SYSCTL_INT(_hw_ath_hal, OID_AUTO, debug, CTLFLAG_RW, &ath_hal_debug, +SYSCTL_INT(_hw_ath_hal, OID_AUTO, debug, CTLFLAG_RWTUN, &ath_hal_debug, 0, "Atheros HAL debugging printfs"); -TUNABLE_INT("hw.ath.hal.debug", &ath_hal_debug); #endif /* AH_DEBUG */ static MALLOC_DEFINE(M_ATH_HAL, "ath_hal", "ath hal data"); diff --git a/sys/dev/ath/if_ath.c b/sys/dev/ath/if_ath.c index a3ab2f61dbfa3..f176b6391b63f 100644 --- a/sys/dev/ath/if_ath.c +++ b/sys/dev/ath/if_ath.c @@ -240,17 +240,14 @@ SYSCTL_INT(_hw_ath, OID_AUTO, anical, CTLFLAG_RW, &ath_anicalinterval, 0, "ANI calibration (msecs)"); int ath_rxbuf = ATH_RXBUF; /* # rx buffers to allocate */ -SYSCTL_INT(_hw_ath, OID_AUTO, rxbuf, CTLFLAG_RW, &ath_rxbuf, +SYSCTL_INT(_hw_ath, OID_AUTO, rxbuf, CTLFLAG_RWTUN, &ath_rxbuf, 0, "rx buffers allocated"); -TUNABLE_INT("hw.ath.rxbuf", &ath_rxbuf); int ath_txbuf = ATH_TXBUF; /* # tx buffers to allocate */ -SYSCTL_INT(_hw_ath, OID_AUTO, txbuf, CTLFLAG_RW, &ath_txbuf, +SYSCTL_INT(_hw_ath, OID_AUTO, txbuf, CTLFLAG_RWTUN, &ath_txbuf, 0, "tx buffers allocated"); -TUNABLE_INT("hw.ath.txbuf", &ath_txbuf); int ath_txbuf_mgmt = ATH_MGMT_TXBUF; /* # mgmt tx buffers to allocate */ -SYSCTL_INT(_hw_ath, OID_AUTO, txbuf_mgmt, CTLFLAG_RW, &ath_txbuf_mgmt, +SYSCTL_INT(_hw_ath, OID_AUTO, txbuf_mgmt, CTLFLAG_RWTUN, &ath_txbuf_mgmt, 0, "tx (mgmt) buffers allocated"); -TUNABLE_INT("hw.ath.txbuf_mgmt", &ath_txbuf_mgmt); int ath_bstuck_threshold = 4; /* max missed beacons */ SYSCTL_INT(_hw_ath, OID_AUTO, bstuck, CTLFLAG_RW, &ath_bstuck_threshold, diff --git a/sys/dev/ath/if_ath_debug.c b/sys/dev/ath/if_ath_debug.c index e3c73f561b8bc..d21ad6fea6f02 100644 --- a/sys/dev/ath/if_ath_debug.c +++ b/sys/dev/ath/if_ath_debug.c @@ -92,9 +92,8 @@ __FBSDID("$FreeBSD$"); uint64_t ath_debug = 0; SYSCTL_DECL(_hw_ath); -SYSCTL_QUAD(_hw_ath, OID_AUTO, debug, CTLFLAG_RW, &ath_debug, +SYSCTL_QUAD(_hw_ath, OID_AUTO, debug, CTLFLAG_RWTUN, &ath_debug, 0, "control debugging printfs"); -TUNABLE_QUAD("hw.ath.debug", &ath_debug); void ath_printrxbuf(struct ath_softc *sc, const struct ath_buf *bf, diff --git a/sys/dev/bce/if_bce.c b/sys/dev/bce/if_bce.c index c888b499b19f9..dfb1dc4a52493 100644 --- a/sys/dev/bce/if_bce.c +++ b/sys/dev/bce/if_bce.c @@ -535,44 +535,37 @@ static SYSCTL_NODE(_hw, OID_AUTO, bce, CTLFLAG_RD, 0, "bce driver parameters"); /* Allowable values are TRUE or FALSE */ static int bce_verbose = TRUE; -TUNABLE_INT("hw.bce.verbose", &bce_verbose); SYSCTL_INT(_hw_bce, OID_AUTO, verbose, CTLFLAG_RDTUN, &bce_verbose, 0, "Verbose output enable/disable"); /* Allowable values are TRUE or FALSE */ static int bce_tso_enable = TRUE; -TUNABLE_INT("hw.bce.tso_enable", &bce_tso_enable); SYSCTL_INT(_hw_bce, OID_AUTO, tso_enable, CTLFLAG_RDTUN, &bce_tso_enable, 0, "TSO Enable/Disable"); /* Allowable values are 0 (IRQ), 1 (MSI/IRQ), and 2 (MSI-X/MSI/IRQ) */ /* ToDo: Add MSI-X support. */ static int bce_msi_enable = 1; -TUNABLE_INT("hw.bce.msi_enable", &bce_msi_enable); SYSCTL_INT(_hw_bce, OID_AUTO, msi_enable, CTLFLAG_RDTUN, &bce_msi_enable, 0, "MSI-X|MSI|INTx selector"); /* Allowable values are 1, 2, 4, 8. */ static int bce_rx_pages = DEFAULT_RX_PAGES; -TUNABLE_INT("hw.bce.rx_pages", &bce_rx_pages); SYSCTL_UINT(_hw_bce, OID_AUTO, rx_pages, CTLFLAG_RDTUN, &bce_rx_pages, 0, "Receive buffer descriptor pages (1 page = 255 buffer descriptors)"); /* Allowable values are 1, 2, 4, 8. */ static int bce_tx_pages = DEFAULT_TX_PAGES; -TUNABLE_INT("hw.bce.tx_pages", &bce_tx_pages); SYSCTL_UINT(_hw_bce, OID_AUTO, tx_pages, CTLFLAG_RDTUN, &bce_tx_pages, 0, "Transmit buffer descriptor pages (1 page = 255 buffer descriptors)"); /* Allowable values are TRUE or FALSE. */ static int bce_hdr_split = TRUE; -TUNABLE_INT("hw.bce.hdr_split", &bce_hdr_split); SYSCTL_UINT(_hw_bce, OID_AUTO, hdr_split, CTLFLAG_RDTUN, &bce_hdr_split, 0, "Frame header/payload splitting Enable/Disable"); /* Allowable values are TRUE or FALSE. */ static int bce_strict_rx_mtu = FALSE; -TUNABLE_INT("hw.bce.strict_rx_mtu", &bce_strict_rx_mtu); SYSCTL_UINT(_hw_bce, OID_AUTO, strict_rx_mtu, CTLFLAG_RDTUN, &bce_strict_rx_mtu, 0, "Enable/Disable strict RX frame size checking"); @@ -585,7 +578,6 @@ static int bce_tx_quick_cons_trip_int = 1; /* Generate 1 interrupt for every 20 transmit completions. */ static int bce_tx_quick_cons_trip_int = DEFAULT_TX_QUICK_CONS_TRIP_INT; #endif -TUNABLE_INT("hw.bce.tx_quick_cons_trip_int", &bce_tx_quick_cons_trip_int); SYSCTL_UINT(_hw_bce, OID_AUTO, tx_quick_cons_trip_int, CTLFLAG_RDTUN, &bce_tx_quick_cons_trip_int, 0, "Transmit BD trip point during interrupts"); @@ -598,7 +590,6 @@ static int bce_tx_quick_cons_trip = 1; /* Generate 1 interrupt for every 20 transmit completions. */ static int bce_tx_quick_cons_trip = DEFAULT_TX_QUICK_CONS_TRIP; #endif -TUNABLE_INT("hw.bce.tx_quick_cons_trip", &bce_tx_quick_cons_trip); SYSCTL_UINT(_hw_bce, OID_AUTO, tx_quick_cons_trip, CTLFLAG_RDTUN, &bce_tx_quick_cons_trip, 0, "Transmit BD trip point"); @@ -611,7 +602,6 @@ static int bce_tx_ticks_int = 0; /* Generate an interrupt if 80us have elapsed since the last TX completion. */ static int bce_tx_ticks_int = DEFAULT_TX_TICKS_INT; #endif -TUNABLE_INT("hw.bce.tx_ticks_int", &bce_tx_ticks_int); SYSCTL_UINT(_hw_bce, OID_AUTO, tx_ticks_int, CTLFLAG_RDTUN, &bce_tx_ticks_int, 0, "Transmit ticks count during interrupt"); @@ -623,7 +613,6 @@ static int bce_tx_ticks = 0; /* Generate an interrupt if 80us have elapsed since the last TX completion. */ static int bce_tx_ticks = DEFAULT_TX_TICKS; #endif -TUNABLE_INT("hw.bce.tx_ticks", &bce_tx_ticks); SYSCTL_UINT(_hw_bce, OID_AUTO, tx_ticks, CTLFLAG_RDTUN, &bce_tx_ticks, 0, "Transmit ticks count"); @@ -635,7 +624,6 @@ static int bce_rx_quick_cons_trip_int = 1; /* Generate 1 interrupt for every 6 received frames. */ static int bce_rx_quick_cons_trip_int = DEFAULT_RX_QUICK_CONS_TRIP_INT; #endif -TUNABLE_INT("hw.bce.rx_quick_cons_trip_int", &bce_rx_quick_cons_trip_int); SYSCTL_UINT(_hw_bce, OID_AUTO, rx_quick_cons_trip_int, CTLFLAG_RDTUN, &bce_rx_quick_cons_trip_int, 0, "Receive BD trip point duirng interrupts"); @@ -648,7 +636,6 @@ static int bce_rx_quick_cons_trip = 1; /* Generate 1 interrupt for every 6 received frames. */ static int bce_rx_quick_cons_trip = DEFAULT_RX_QUICK_CONS_TRIP; #endif -TUNABLE_INT("hw.bce.rx_quick_cons_trip", &bce_rx_quick_cons_trip); SYSCTL_UINT(_hw_bce, OID_AUTO, rx_quick_cons_trip, CTLFLAG_RDTUN, &bce_rx_quick_cons_trip, 0, "Receive BD trip point"); @@ -661,7 +648,6 @@ static int bce_rx_ticks_int = 0; /* Generate an int. if 18us have elapsed since the last received frame. */ static int bce_rx_ticks_int = DEFAULT_RX_TICKS_INT; #endif -TUNABLE_INT("hw.bce.rx_ticks_int", &bce_rx_ticks_int); SYSCTL_UINT(_hw_bce, OID_AUTO, rx_ticks_int, CTLFLAG_RDTUN, &bce_rx_ticks_int, 0, "Receive ticks count during interrupt"); @@ -673,7 +659,6 @@ static int bce_rx_ticks = 0; /* Generate an int. if 18us have elapsed since the last received frame. */ static int bce_rx_ticks = DEFAULT_RX_TICKS; #endif -TUNABLE_INT("hw.bce.rx_ticks", &bce_rx_ticks); SYSCTL_UINT(_hw_bce, OID_AUTO, rx_ticks, CTLFLAG_RDTUN, &bce_rx_ticks, 0, "Receive ticks count"); diff --git a/sys/dev/bge/if_bge.c b/sys/dev/bge/if_bge.c index 40f562ede6de2..e236771bcaa92 100644 --- a/sys/dev/bge/if_bge.c +++ b/sys/dev/bge/if_bge.c @@ -542,10 +542,8 @@ DRIVER_MODULE(miibus, bge, miibus_driver, miibus_devclass, 0, 0); static int bge_allow_asf = 1; -TUNABLE_INT("hw.bge.allow_asf", &bge_allow_asf); - static SYSCTL_NODE(_hw, OID_AUTO, bge, CTLFLAG_RD, 0, "BGE driver parameters"); -SYSCTL_INT(_hw_bge, OID_AUTO, allow_asf, CTLFLAG_RD, &bge_allow_asf, 0, +SYSCTL_INT(_hw_bge, OID_AUTO, allow_asf, CTLFLAG_RDTUN, &bge_allow_asf, 0, "Allow ASF mode if available"); #define SPARC64_BLADE_1500_MODEL "SUNW,Sun-Blade-1500" @@ -6237,7 +6235,6 @@ bge_add_sysctls(struct bge_softc *sc) { struct sysctl_ctx_list *ctx; struct sysctl_oid_list *children; - char tn[32]; int unit; ctx = device_get_sysctl_ctx(sc->bge_dev); @@ -6276,18 +6273,14 @@ bge_add_sysctls(struct bge_softc *sc) * consumes a lot of CPU cycles, so leave it off by default. */ sc->bge_forced_collapse = 0; - snprintf(tn, sizeof(tn), "dev.bge.%d.forced_collapse", unit); - TUNABLE_INT_FETCH(tn, &sc->bge_forced_collapse); SYSCTL_ADD_INT(ctx, children, OID_AUTO, "forced_collapse", - CTLFLAG_RW, &sc->bge_forced_collapse, 0, + CTLFLAG_RWTUN, &sc->bge_forced_collapse, 0, "Number of fragmented TX buffers of a frame allowed before " "forced collapsing"); sc->bge_msi = 1; - snprintf(tn, sizeof(tn), "dev.bge.%d.msi", unit); - TUNABLE_INT_FETCH(tn, &sc->bge_msi); SYSCTL_ADD_INT(ctx, children, OID_AUTO, "msi", - CTLFLAG_RD, &sc->bge_msi, 0, "Enable MSI"); + CTLFLAG_RDTUN, &sc->bge_msi, 0, "Enable MSI"); /* * It seems all Broadcom controllers have a bug that can generate UDP @@ -6300,10 +6293,8 @@ bge_add_sysctls(struct bge_softc *sc) * dev.bge.0.forced_udpcsum. */ sc->bge_forced_udpcsum = 0; - snprintf(tn, sizeof(tn), "dev.bge.%d.bge_forced_udpcsum", unit); - TUNABLE_INT_FETCH(tn, &sc->bge_forced_udpcsum); SYSCTL_ADD_INT(ctx, children, OID_AUTO, "forced_udpcsum", - CTLFLAG_RW, &sc->bge_forced_udpcsum, 0, + CTLFLAG_RWTUN, &sc->bge_forced_udpcsum, 0, "Enable UDP checksum offloading even if controller can " "generate UDP checksum value 0"); diff --git a/sys/dev/bwn/if_bwn.c b/sys/dev/bwn/if_bwn.c index cc34b12095e0a..4e9a8d9ba36c8 100644 --- a/sys/dev/bwn/if_bwn.c +++ b/sys/dev/bwn/if_bwn.c @@ -83,9 +83,8 @@ static SYSCTL_NODE(_hw, OID_AUTO, bwn, CTLFLAG_RD, 0, #ifdef BWN_DEBUG static int bwn_debug = 0; -SYSCTL_INT(_hw_bwn, OID_AUTO, debug, CTLFLAG_RW, &bwn_debug, 0, +SYSCTL_INT(_hw_bwn, OID_AUTO, debug, CTLFLAG_RWTUN, &bwn_debug, 0, "Broadcom debugging printfs"); -TUNABLE_INT("hw.bwn.debug", &bwn_debug); enum { BWN_DEBUG_XMIT = 0x00000001, /* basic xmit operation */ BWN_DEBUG_RECV = 0x00000002, /* basic recv operation */ diff --git a/sys/dev/bxe/bxe.c b/sys/dev/bxe/bxe.c index feae5bcf78c7e..974852bce47e3 100644 --- a/sys/dev/bxe/bxe.c +++ b/sys/dev/bxe/bxe.c @@ -297,67 +297,56 @@ SYSCTL_NODE(_hw, OID_AUTO, bxe, CTLFLAG_RD, 0, "bxe driver parameters"); /* Debug */ unsigned long bxe_debug = 0; -TUNABLE_ULONG("hw.bxe.debug", &bxe_debug); -SYSCTL_ULONG(_hw_bxe, OID_AUTO, debug, (CTLFLAG_RDTUN), +SYSCTL_ULONG(_hw_bxe, OID_AUTO, debug, CTLFLAG_RDTUN, &bxe_debug, 0, "Debug logging mode"); /* Interrupt Mode: 0 (IRQ), 1 (MSI/IRQ), and 2 (MSI-X/MSI/IRQ) */ static int bxe_interrupt_mode = INTR_MODE_MSIX; -TUNABLE_INT("hw.bxe.interrupt_mode", &bxe_interrupt_mode); SYSCTL_INT(_hw_bxe, OID_AUTO, interrupt_mode, CTLFLAG_RDTUN, &bxe_interrupt_mode, 0, "Interrupt (MSI-X/MSI/INTx) mode"); /* Number of Queues: 0 (Auto) or 1 to 16 (fixed queue number) */ static int bxe_queue_count = 4; -TUNABLE_INT("hw.bxe.queue_count", &bxe_queue_count); SYSCTL_INT(_hw_bxe, OID_AUTO, queue_count, CTLFLAG_RDTUN, &bxe_queue_count, 0, "Multi-Queue queue count"); /* max number of buffers per queue (default RX_BD_USABLE) */ static int bxe_max_rx_bufs = 0; -TUNABLE_INT("hw.bxe.max_rx_bufs", &bxe_max_rx_bufs); SYSCTL_INT(_hw_bxe, OID_AUTO, max_rx_bufs, CTLFLAG_RDTUN, &bxe_max_rx_bufs, 0, "Maximum Number of Rx Buffers Per Queue"); /* Host interrupt coalescing RX tick timer (usecs) */ static int bxe_hc_rx_ticks = 25; -TUNABLE_INT("hw.bxe.hc_rx_ticks", &bxe_hc_rx_ticks); SYSCTL_INT(_hw_bxe, OID_AUTO, hc_rx_ticks, CTLFLAG_RDTUN, &bxe_hc_rx_ticks, 0, "Host Coalescing Rx ticks"); /* Host interrupt coalescing TX tick timer (usecs) */ static int bxe_hc_tx_ticks = 50; -TUNABLE_INT("hw.bxe.hc_tx_ticks", &bxe_hc_tx_ticks); SYSCTL_INT(_hw_bxe, OID_AUTO, hc_tx_ticks, CTLFLAG_RDTUN, &bxe_hc_tx_ticks, 0, "Host Coalescing Tx ticks"); /* Maximum number of Rx packets to process at a time */ static int bxe_rx_budget = 0xffffffff; -TUNABLE_INT("hw.bxe.rx_budget", &bxe_rx_budget); SYSCTL_INT(_hw_bxe, OID_AUTO, rx_budget, CTLFLAG_TUN, &bxe_rx_budget, 0, "Rx processing budget"); /* Maximum LRO aggregation size */ static int bxe_max_aggregation_size = 0; -TUNABLE_INT("hw.bxe.max_aggregation_size", &bxe_max_aggregation_size); SYSCTL_INT(_hw_bxe, OID_AUTO, max_aggregation_size, CTLFLAG_TUN, &bxe_max_aggregation_size, 0, "max aggregation size"); /* PCI MRRS: -1 (Auto), 0 (128B), 1 (256B), 2 (512B), 3 (1KB) */ static int bxe_mrrs = -1; -TUNABLE_INT("hw.bxe.mrrs", &bxe_mrrs); SYSCTL_INT(_hw_bxe, OID_AUTO, mrrs, CTLFLAG_RDTUN, &bxe_mrrs, 0, "PCIe maximum read request size"); /* AutoGrEEEn: 0 (hardware default), 1 (force on), 2 (force off) */ static int bxe_autogreeen = 0; -TUNABLE_INT("hw.bxe.autogreeen", &bxe_autogreeen); SYSCTL_INT(_hw_bxe, OID_AUTO, autogreeen, CTLFLAG_RDTUN, &bxe_autogreeen, 0, "AutoGrEEEn support"); /* 4-tuple RSS support for UDP: 0 (disabled), 1 (enabled) */ static int bxe_udp_rss = 0; -TUNABLE_INT("hw.bxe.udp_rss", &bxe_udp_rss); SYSCTL_INT(_hw_bxe, OID_AUTO, udp_rss, CTLFLAG_RDTUN, &bxe_udp_rss, 0, "UDP RSS support"); diff --git a/sys/dev/cardbus/cardbus.c b/sys/dev/cardbus/cardbus.c index 00d4a19e8cf67..c591fe98042e7 100644 --- a/sys/dev/cardbus/cardbus.c +++ b/sys/dev/cardbus/cardbus.c @@ -57,16 +57,12 @@ __FBSDID("$FreeBSD$"); static SYSCTL_NODE(_hw, OID_AUTO, cardbus, CTLFLAG_RD, 0, "CardBus parameters"); int cardbus_debug = 0; -TUNABLE_INT("hw.cardbus.debug", &cardbus_debug); -SYSCTL_INT(_hw_cardbus, OID_AUTO, debug, CTLFLAG_RW, - &cardbus_debug, 0, - "CardBus debug"); +SYSCTL_INT(_hw_cardbus, OID_AUTO, debug, CTLFLAG_RWTUN, + &cardbus_debug, 0, "CardBus debug"); int cardbus_cis_debug = 0; -TUNABLE_INT("hw.cardbus.cis_debug", &cardbus_cis_debug); -SYSCTL_INT(_hw_cardbus, OID_AUTO, cis_debug, CTLFLAG_RW, - &cardbus_cis_debug, 0, - "CardBus CIS debug"); +SYSCTL_INT(_hw_cardbus, OID_AUTO, cis_debug, CTLFLAG_RWTUN, + &cardbus_cis_debug, 0, "CardBus CIS debug"); #define DPRINTF(a) if (cardbus_debug) printf a #define DEVPRINTF(x) if (cardbus_debug) device_printf x diff --git a/sys/dev/cs/if_cs.c b/sys/dev/cs/if_cs.c index b6a3d3b91f637..502c2b34be734 100644 --- a/sys/dev/cs/if_cs.c +++ b/sys/dev/cs/if_cs.c @@ -107,14 +107,12 @@ driver_intr_t csintr; static SYSCTL_NODE(_hw, OID_AUTO, cs, CTLFLAG_RD, 0, "cs device parameters"); int cs_ignore_cksum_failure = 0; -TUNABLE_INT("hw.cs.ignore_checksum_failure", &cs_ignore_cksum_failure); -SYSCTL_INT(_hw_cs, OID_AUTO, ignore_checksum_failure, CTLFLAG_RW, +SYSCTL_INT(_hw_cs, OID_AUTO, ignore_checksum_failure, CTLFLAG_RWTUN, &cs_ignore_cksum_failure, 0, "ignore checksum errors in cs card EEPROM"); static int cs_recv_delay = 570; -TUNABLE_INT("hw.cs.recv_delay", &cs_recv_delay); -SYSCTL_INT(_hw_cs, OID_AUTO, recv_delay, CTLFLAG_RW, &cs_recv_delay, 570, ""); +SYSCTL_INT(_hw_cs, OID_AUTO, recv_delay, CTLFLAG_RWTUN, &cs_recv_delay, 570, ""); static int cs8900_eeint2irq[16] = { 10, 11, 12, 5, 255, 255, 255, 255, diff --git a/sys/dev/cxgb/cxgb_include.h b/sys/dev/cxgb/cxgb_include.h index 90080b5313179..d98ef5771baac 100644 --- a/sys/dev/cxgb/cxgb_include.h +++ b/sys/dev/cxgb/cxgb_include.h @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -16,3 +17,5 @@ #include #include #include + +SYSCTL_DECL(_hw_cxgb); diff --git a/sys/dev/cxgb/cxgb_main.c b/sys/dev/cxgb/cxgb_main.c index 6ccf6e3774a38..30001293b2bb4 100644 --- a/sys/dev/cxgb/cxgb_main.c +++ b/sys/dev/cxgb/cxgb_main.c @@ -208,7 +208,6 @@ static SLIST_HEAD(, uld_info) t3_uld_list; */ static int msi_allowed = 2; -TUNABLE_INT("hw.cxgb.msi_allowed", &msi_allowed); SYSCTL_NODE(_hw, OID_AUTO, cxgb, CTLFLAG_RD, 0, "CXGB driver parameters"); SYSCTL_INT(_hw_cxgb, OID_AUTO, msi_allowed, CTLFLAG_RDTUN, &msi_allowed, 0, "MSI-X, MSI, INTx selector"); @@ -218,7 +217,6 @@ SYSCTL_INT(_hw_cxgb, OID_AUTO, msi_allowed, CTLFLAG_RDTUN, &msi_allowed, 0, * To disable it and force a single queue-set per port, use multiq = 0 */ static int multiq = 1; -TUNABLE_INT("hw.cxgb.multiq", &multiq); SYSCTL_INT(_hw_cxgb, OID_AUTO, multiq, CTLFLAG_RDTUN, &multiq, 0, "use min(ncpus/ports, 8) queue-sets per port"); @@ -228,17 +226,14 @@ SYSCTL_INT(_hw_cxgb, OID_AUTO, multiq, CTLFLAG_RDTUN, &multiq, 0, * */ static int force_fw_update = 0; -TUNABLE_INT("hw.cxgb.force_fw_update", &force_fw_update); SYSCTL_INT(_hw_cxgb, OID_AUTO, force_fw_update, CTLFLAG_RDTUN, &force_fw_update, 0, "update firmware even if up to date"); int cxgb_use_16k_clusters = -1; -TUNABLE_INT("hw.cxgb.use_16k_clusters", &cxgb_use_16k_clusters); SYSCTL_INT(_hw_cxgb, OID_AUTO, use_16k_clusters, CTLFLAG_RDTUN, &cxgb_use_16k_clusters, 0, "use 16kB clusters for the jumbo queue "); static int nfilters = -1; -TUNABLE_INT("hw.cxgb.nfilters", &nfilters); SYSCTL_INT(_hw_cxgb, OID_AUTO, nfilters, CTLFLAG_RDTUN, &nfilters, 0, "max number of entries in the filter table"); diff --git a/sys/dev/cxgb/cxgb_sge.c b/sys/dev/cxgb/cxgb_sge.c index 42744faa44ded..fcc0376fab763 100644 --- a/sys/dev/cxgb/cxgb_sge.c +++ b/sys/dev/cxgb/cxgb_sge.c @@ -86,13 +86,11 @@ CTASSERT(NUM_CPL_HANDLERS >= NUM_CPL_CMDS); extern struct sysctl_oid_list sysctl__hw_cxgb_children; int cxgb_txq_buf_ring_size = TX_ETH_Q_SIZE; -TUNABLE_INT("hw.cxgb.txq_mr_size", &cxgb_txq_buf_ring_size); SYSCTL_INT(_hw_cxgb, OID_AUTO, txq_mr_size, CTLFLAG_RDTUN, &cxgb_txq_buf_ring_size, 0, "size of per-queue mbuf ring"); static int cxgb_tx_coalesce_force = 0; -TUNABLE_INT("hw.cxgb.tx_coalesce_force", &cxgb_tx_coalesce_force); -SYSCTL_INT(_hw_cxgb, OID_AUTO, tx_coalesce_force, CTLFLAG_RW, +SYSCTL_INT(_hw_cxgb, OID_AUTO, tx_coalesce_force, CTLFLAG_RWTUN, &cxgb_tx_coalesce_force, 0, "coalesce small packets into a single work request regardless of ring state"); @@ -106,19 +104,15 @@ SYSCTL_INT(_hw_cxgb, OID_AUTO, tx_coalesce_force, CTLFLAG_RW, static int cxgb_tx_coalesce_enable_start = COALESCE_START_DEFAULT; -TUNABLE_INT("hw.cxgb.tx_coalesce_enable_start", - &cxgb_tx_coalesce_enable_start); -SYSCTL_INT(_hw_cxgb, OID_AUTO, tx_coalesce_enable_start, CTLFLAG_RW, +SYSCTL_INT(_hw_cxgb, OID_AUTO, tx_coalesce_enable_start, CTLFLAG_RWTUN, &cxgb_tx_coalesce_enable_start, 0, "coalesce enable threshold"); static int cxgb_tx_coalesce_enable_stop = COALESCE_STOP_DEFAULT; -TUNABLE_INT("hw.cxgb.tx_coalesce_enable_stop", &cxgb_tx_coalesce_enable_stop); -SYSCTL_INT(_hw_cxgb, OID_AUTO, tx_coalesce_enable_stop, CTLFLAG_RW, +SYSCTL_INT(_hw_cxgb, OID_AUTO, tx_coalesce_enable_stop, CTLFLAG_RWTUN, &cxgb_tx_coalesce_enable_stop, 0, "coalesce disable threshold"); static int cxgb_tx_reclaim_threshold = TX_RECLAIM_DEFAULT; -TUNABLE_INT("hw.cxgb.tx_reclaim_threshold", &cxgb_tx_reclaim_threshold); -SYSCTL_INT(_hw_cxgb, OID_AUTO, tx_reclaim_threshold, CTLFLAG_RW, +SYSCTL_INT(_hw_cxgb, OID_AUTO, tx_reclaim_threshold, CTLFLAG_RWTUN, &cxgb_tx_reclaim_threshold, 0, "tx cleaning minimum threshold"); diff --git a/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c b/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c index 9afad627d5aed..fea86eba709de 100644 --- a/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c +++ b/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c @@ -106,43 +106,35 @@ static char *states[] = { SYSCTL_NODE(_hw, OID_AUTO, iw_cxgb, CTLFLAG_RD, 0, "iw_cxgb driver parameters"); static int ep_timeout_secs = 60; -TUNABLE_INT("hw.iw_cxgb.ep_timeout_secs", &ep_timeout_secs); -SYSCTL_INT(_hw_iw_cxgb, OID_AUTO, ep_timeout_secs, CTLFLAG_RW, &ep_timeout_secs, 0, +SYSCTL_INT(_hw_iw_cxgb, OID_AUTO, ep_timeout_secs, CTLFLAG_RWTUN, &ep_timeout_secs, 0, "CM Endpoint operation timeout in seconds (default=60)"); static int mpa_rev = 1; -TUNABLE_INT("hw.iw_cxgb.mpa_rev", &mpa_rev); -SYSCTL_INT(_hw_iw_cxgb, OID_AUTO, mpa_rev, CTLFLAG_RW, &mpa_rev, 0, +SYSCTL_INT(_hw_iw_cxgb, OID_AUTO, mpa_rev, CTLFLAG_RWTUN, &mpa_rev, 0, "MPA Revision, 0 supports amso1100, 1 is spec compliant. (default=1)"); static int markers_enabled = 0; -TUNABLE_INT("hw.iw_cxgb.markers_enabled", &markers_enabled); -SYSCTL_INT(_hw_iw_cxgb, OID_AUTO, markers_enabled, CTLFLAG_RW, &markers_enabled, 0, +SYSCTL_INT(_hw_iw_cxgb, OID_AUTO, markers_enabled, CTLFLAG_RWTUN, &markers_enabled, 0, "Enable MPA MARKERS (default(0)=disabled)"); static int crc_enabled = 1; -TUNABLE_INT("hw.iw_cxgb.crc_enabled", &crc_enabled); -SYSCTL_INT(_hw_iw_cxgb, OID_AUTO, crc_enabled, CTLFLAG_RW, &crc_enabled, 0, +SYSCTL_INT(_hw_iw_cxgb, OID_AUTO, crc_enabled, CTLFLAG_RWTUN, &crc_enabled, 0, "Enable MPA CRC (default(1)=enabled)"); static int rcv_win = 256 * 1024; -TUNABLE_INT("hw.iw_cxgb.rcv_win", &rcv_win); -SYSCTL_INT(_hw_iw_cxgb, OID_AUTO, rcv_win, CTLFLAG_RW, &rcv_win, 0, +SYSCTL_INT(_hw_iw_cxgb, OID_AUTO, rcv_win, CTLFLAG_RWTUN, &rcv_win, 0, "TCP receive window in bytes (default=256KB)"); static int snd_win = 32 * 1024; -TUNABLE_INT("hw.iw_cxgb.snd_win", &snd_win); -SYSCTL_INT(_hw_iw_cxgb, OID_AUTO, snd_win, CTLFLAG_RW, &snd_win, 0, +SYSCTL_INT(_hw_iw_cxgb, OID_AUTO, snd_win, CTLFLAG_RWTUN, &snd_win, 0, "TCP send window in bytes (default=32KB)"); static unsigned int nocong = 0; -TUNABLE_INT("hw.iw_cxgb.nocong", &nocong); -SYSCTL_UINT(_hw_iw_cxgb, OID_AUTO, nocong, CTLFLAG_RW, &nocong, 0, +SYSCTL_UINT(_hw_iw_cxgb, OID_AUTO, nocong, CTLFLAG_RWTUN, &nocong, 0, "Turn off congestion control (default=0)"); static unsigned int cong_flavor = 1; -TUNABLE_INT("hw.iw_cxgb.cong_flavor", &cong_flavor); -SYSCTL_UINT(_hw_iw_cxgb, OID_AUTO, cong_flavor, CTLFLAG_RW, &cong_flavor, 0, +SYSCTL_UINT(_hw_iw_cxgb, OID_AUTO, cong_flavor, CTLFLAG_RWTUN, &cong_flavor, 0, "TCP Congestion control flavor (default=1)"); static void ep_timeout(void *arg); diff --git a/sys/dev/cxgbe/iw_cxgbe/cm.c b/sys/dev/cxgbe/iw_cxgbe/cm.c index 03652a396a31c..fb93a9b2b287a 100644 --- a/sys/dev/cxgbe/iw_cxgbe/cm.c +++ b/sys/dev/cxgbe/iw_cxgbe/cm.c @@ -769,88 +769,72 @@ process_socket_event(struct c4iw_ep *ep) SYSCTL_NODE(_hw, OID_AUTO, iw_cxgbe, CTLFLAG_RD, 0, "iw_cxgbe driver parameters"); int db_delay_usecs = 1; -TUNABLE_INT("hw.iw_cxgbe.db_delay_usecs", &db_delay_usecs); -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, db_delay_usecs, CTLFLAG_RW, &db_delay_usecs, 0, +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, db_delay_usecs, CTLFLAG_RWTUN, &db_delay_usecs, 0, "Usecs to delay awaiting db fifo to drain"); static int dack_mode = 1; -TUNABLE_INT("hw.iw_cxgbe.dack_mode", &dack_mode); -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, dack_mode, CTLFLAG_RW, &dack_mode, 0, +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, dack_mode, CTLFLAG_RWTUN, &dack_mode, 0, "Delayed ack mode (default = 1)"); int c4iw_max_read_depth = 8; -TUNABLE_INT("hw.iw_cxgbe.c4iw_max_read_depth", &c4iw_max_read_depth); -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, c4iw_max_read_depth, CTLFLAG_RW, &c4iw_max_read_depth, 0, +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, c4iw_max_read_depth, CTLFLAG_RWTUN, &c4iw_max_read_depth, 0, "Per-connection max ORD/IRD (default = 8)"); static int enable_tcp_timestamps; -TUNABLE_INT("hw.iw_cxgbe.enable_tcp_timestamps", &enable_tcp_timestamps); -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, enable_tcp_timestamps, CTLFLAG_RW, &enable_tcp_timestamps, 0, +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, enable_tcp_timestamps, CTLFLAG_RWTUN, &enable_tcp_timestamps, 0, "Enable tcp timestamps (default = 0)"); static int enable_tcp_sack; -TUNABLE_INT("hw.iw_cxgbe.enable_tcp_sack", &enable_tcp_sack); -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, enable_tcp_sack, CTLFLAG_RW, &enable_tcp_sack, 0, +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, enable_tcp_sack, CTLFLAG_RWTUN, &enable_tcp_sack, 0, "Enable tcp SACK (default = 0)"); static int enable_tcp_window_scaling = 1; -TUNABLE_INT("hw.iw_cxgbe.enable_tcp_window_scaling", &enable_tcp_window_scaling); -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, enable_tcp_window_scaling, CTLFLAG_RW, &enable_tcp_window_scaling, 0, +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, enable_tcp_window_scaling, CTLFLAG_RWTUN, &enable_tcp_window_scaling, 0, "Enable tcp window scaling (default = 1)"); int c4iw_debug = 1; -TUNABLE_INT("hw.iw_cxgbe.c4iw_debug", &c4iw_debug); -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, c4iw_debug, CTLFLAG_RW, &c4iw_debug, 0, +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, c4iw_debug, CTLFLAG_RWTUN, &c4iw_debug, 0, "Enable debug logging (default = 0)"); static int peer2peer; -TUNABLE_INT("hw.iw_cxgbe.peer2peer", &peer2peer); -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, peer2peer, CTLFLAG_RW, &peer2peer, 0, +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, peer2peer, CTLFLAG_RWTUN, &peer2peer, 0, "Support peer2peer ULPs (default = 0)"); static int p2p_type = FW_RI_INIT_P2PTYPE_READ_REQ; -TUNABLE_INT("hw.iw_cxgbe.p2p_type", &p2p_type); -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, p2p_type, CTLFLAG_RW, &p2p_type, 0, +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, p2p_type, CTLFLAG_RWTUN, &p2p_type, 0, "RDMAP opcode to use for the RTR message: 1 = RDMA_READ 0 = RDMA_WRITE (default 1)"); static int ep_timeout_secs = 60; -TUNABLE_INT("hw.iw_cxgbe.ep_timeout_secs", &ep_timeout_secs); -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, ep_timeout_secs, CTLFLAG_RW, &ep_timeout_secs, 0, +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, ep_timeout_secs, CTLFLAG_RWTUN, &ep_timeout_secs, 0, "CM Endpoint operation timeout in seconds (default = 60)"); static int mpa_rev = 1; -TUNABLE_INT("hw.iw_cxgbe.mpa_rev", &mpa_rev); #ifdef IW_CM_MPAV2 -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, mpa_rev, CTLFLAG_RW, &mpa_rev, 0, +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, mpa_rev, CTLFLAG_RWTUN, &mpa_rev, 0, "MPA Revision, 0 supports amso1100, 1 is RFC0544 spec compliant, 2 is IETF MPA Peer Connect Draft compliant (default = 1)"); #else -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, mpa_rev, CTLFLAG_RW, &mpa_rev, 0, +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, mpa_rev, CTLFLAG_RWTUN, &mpa_rev, 0, "MPA Revision, 0 supports amso1100, 1 is RFC0544 spec compliant (default = 1)"); #endif static int markers_enabled; -TUNABLE_INT("hw.iw_cxgbe.markers_enabled", &markers_enabled); -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, markers_enabled, CTLFLAG_RW, &markers_enabled, 0, +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, markers_enabled, CTLFLAG_RWTUN, &markers_enabled, 0, "Enable MPA MARKERS (default(0) = disabled)"); static int crc_enabled = 1; -TUNABLE_INT("hw.iw_cxgbe.crc_enabled", &crc_enabled); -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, crc_enabled, CTLFLAG_RW, &crc_enabled, 0, +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, crc_enabled, CTLFLAG_RWTUN, &crc_enabled, 0, "Enable MPA CRC (default(1) = enabled)"); static int rcv_win = 256 * 1024; -TUNABLE_INT("hw.iw_cxgbe.rcv_win", &rcv_win); -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, rcv_win, CTLFLAG_RW, &rcv_win, 0, +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, rcv_win, CTLFLAG_RWTUN, &rcv_win, 0, "TCP receive window in bytes (default = 256KB)"); static int snd_win = 128 * 1024; -TUNABLE_INT("hw.iw_cxgbe.snd_win", &snd_win); -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, snd_win, CTLFLAG_RW, &snd_win, 0, +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, snd_win, CTLFLAG_RWTUN, &snd_win, 0, "TCP send window in bytes (default = 128KB)"); int db_fc_threshold = 2000; -TUNABLE_INT("hw.iw_cxgbe.db_fc_threshold", &db_fc_threshold); -SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, db_fc_threshold, CTLFLAG_RW, &db_fc_threshold, 0, +SYSCTL_INT(_hw_iw_cxgbe, OID_AUTO, db_fc_threshold, CTLFLAG_RWTUN, &db_fc_threshold, 0, "QP count/threshold that triggers automatic"); static void diff --git a/sys/dev/drm/drm_drv.c b/sys/dev/drm/drm_drv.c index 75902a7711dbe..75983766f3799 100644 --- a/sys/dev/drm/drm_drv.c +++ b/sys/dev/drm/drm_drv.c @@ -132,7 +132,6 @@ static struct cdevsw drm_cdevsw = { }; static int drm_msi = 1; /* Enable by default. */ -TUNABLE_INT("hw.drm.msi", &drm_msi); SYSCTL_NODE(_hw, OID_AUTO, drm, CTLFLAG_RW, NULL, "DRM device"); SYSCTL_INT(_hw_drm, OID_AUTO, msi, CTLFLAG_RDTUN, &drm_msi, 1, "Enable MSI interrupts for drm devices"); diff --git a/sys/dev/drm/drm_sysctl.c b/sys/dev/drm/drm_sysctl.c index ce3e5b4c7ce84..75d8306c8405b 100644 --- a/sys/dev/drm/drm_sysctl.c +++ b/sys/dev/drm/drm_sysctl.c @@ -70,7 +70,7 @@ int drm_sysctl_init(struct drm_device *dev) dev->sysctl = info; /* Add the sysctl node for DRI if it doesn't already exist */ - drioid = SYSCTL_ADD_NODE( &info->ctx, &sysctl__hw_children, OID_AUTO, "dri", CTLFLAG_RW, NULL, "DRI Graphics"); + drioid = SYSCTL_ADD_NODE(&info->ctx, SYSCTL_CHILDREN(&sysctl___hw), OID_AUTO, "dri", CTLFLAG_RW, NULL, "DRI Graphics"); if (!drioid) return 1; diff --git a/sys/dev/drm2/drm_drv.c b/sys/dev/drm2/drm_drv.c index 7b00bcf8cf433..81fcee3dbe7cc 100644 --- a/sys/dev/drm2/drm_drv.c +++ b/sys/dev/drm2/drm_drv.c @@ -203,7 +203,6 @@ static struct cdevsw drm_cdevsw = { }; static int drm_msi = 1; /* Enable by default. */ -TUNABLE_INT("hw.drm.msi", &drm_msi); SYSCTL_NODE(_hw, OID_AUTO, drm, CTLFLAG_RW, NULL, "DRM device"); SYSCTL_INT(_hw_drm, OID_AUTO, msi, CTLFLAG_RDTUN, &drm_msi, 1, "Enable MSI interrupts for drm devices"); diff --git a/sys/dev/drm2/drm_sysctl.c b/sys/dev/drm2/drm_sysctl.c index a30c7ab237a6b..aac21e6a486ed 100644 --- a/sys/dev/drm2/drm_sysctl.c +++ b/sys/dev/drm2/drm_sysctl.c @@ -68,7 +68,7 @@ int drm_sysctl_init(struct drm_device *dev) dev->sysctl = info; /* Add the sysctl node for DRI if it doesn't already exist */ - drioid = SYSCTL_ADD_NODE(&info->ctx, &sysctl__hw_children, OID_AUTO, + drioid = SYSCTL_ADD_NODE(&info->ctx, SYSCTL_CHILDREN(&sysctl___hw), OID_AUTO, "dri", CTLFLAG_RW, NULL, "DRI Graphics"); if (!drioid) return 1; diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c index d44ad37bee7c9..d2872cb0a95c2 100644 --- a/sys/dev/e1000/if_em.c +++ b/sys/dev/e1000/if_em.c @@ -353,8 +353,6 @@ static SYSCTL_NODE(_hw, OID_AUTO, em, CTLFLAG_RD, 0, "EM driver parameters"); static int em_tx_int_delay_dflt = EM_TICKS_TO_USECS(EM_TIDV); static int em_rx_int_delay_dflt = EM_TICKS_TO_USECS(EM_RDTR); -TUNABLE_INT("hw.em.tx_int_delay", &em_tx_int_delay_dflt); -TUNABLE_INT("hw.em.rx_int_delay", &em_rx_int_delay_dflt); SYSCTL_INT(_hw_em, OID_AUTO, tx_int_delay, CTLFLAG_RDTUN, &em_tx_int_delay_dflt, 0, "Default transmit interrupt delay in usecs"); SYSCTL_INT(_hw_em, OID_AUTO, rx_int_delay, CTLFLAG_RDTUN, &em_rx_int_delay_dflt, @@ -362,8 +360,6 @@ SYSCTL_INT(_hw_em, OID_AUTO, rx_int_delay, CTLFLAG_RDTUN, &em_rx_int_delay_dflt, static int em_tx_abs_int_delay_dflt = EM_TICKS_TO_USECS(EM_TADV); static int em_rx_abs_int_delay_dflt = EM_TICKS_TO_USECS(EM_RADV); -TUNABLE_INT("hw.em.tx_abs_int_delay", &em_tx_abs_int_delay_dflt); -TUNABLE_INT("hw.em.rx_abs_int_delay", &em_rx_abs_int_delay_dflt); SYSCTL_INT(_hw_em, OID_AUTO, tx_abs_int_delay, CTLFLAG_RDTUN, &em_tx_abs_int_delay_dflt, 0, "Default transmit interrupt delay limit in usecs"); @@ -373,32 +369,26 @@ SYSCTL_INT(_hw_em, OID_AUTO, rx_abs_int_delay, CTLFLAG_RDTUN, static int em_rxd = EM_DEFAULT_RXD; static int em_txd = EM_DEFAULT_TXD; -TUNABLE_INT("hw.em.rxd", &em_rxd); -TUNABLE_INT("hw.em.txd", &em_txd); SYSCTL_INT(_hw_em, OID_AUTO, rxd, CTLFLAG_RDTUN, &em_rxd, 0, "Number of receive descriptors per queue"); SYSCTL_INT(_hw_em, OID_AUTO, txd, CTLFLAG_RDTUN, &em_txd, 0, "Number of transmit descriptors per queue"); static int em_smart_pwr_down = FALSE; -TUNABLE_INT("hw.em.smart_pwr_down", &em_smart_pwr_down); SYSCTL_INT(_hw_em, OID_AUTO, smart_pwr_down, CTLFLAG_RDTUN, &em_smart_pwr_down, 0, "Set to true to leave smart power down enabled on newer adapters"); /* Controls whether promiscuous also shows bad packets */ static int em_debug_sbp = FALSE; -TUNABLE_INT("hw.em.sbp", &em_debug_sbp); SYSCTL_INT(_hw_em, OID_AUTO, sbp, CTLFLAG_RDTUN, &em_debug_sbp, 0, "Show bad packets in promiscuous mode"); static int em_enable_msix = TRUE; -TUNABLE_INT("hw.em.enable_msix", &em_enable_msix); SYSCTL_INT(_hw_em, OID_AUTO, enable_msix, CTLFLAG_RDTUN, &em_enable_msix, 0, "Enable MSI-X interrupts"); /* How many packets rxeof tries to clean at a time */ static int em_rx_process_limit = 100; -TUNABLE_INT("hw.em.rx_process_limit", &em_rx_process_limit); SYSCTL_INT(_hw_em, OID_AUTO, rx_process_limit, CTLFLAG_RDTUN, &em_rx_process_limit, 0, "Maximum number of received packets to process " @@ -406,7 +396,6 @@ SYSCTL_INT(_hw_em, OID_AUTO, rx_process_limit, CTLFLAG_RDTUN, /* Energy efficient ethernet - default to OFF */ static int eee_setting = 1; -TUNABLE_INT("hw.em.eee_setting", &eee_setting); SYSCTL_INT(_hw_em, OID_AUTO, eee_setting, CTLFLAG_RDTUN, &eee_setting, 0, "Enable Energy Efficient Ethernet"); diff --git a/sys/dev/e1000/if_igb.c b/sys/dev/e1000/if_igb.c index 38153f4d3afc9..5c54c8400f4c6 100644 --- a/sys/dev/e1000/if_igb.c +++ b/sys/dev/e1000/if_igb.c @@ -327,8 +327,6 @@ static SYSCTL_NODE(_hw, OID_AUTO, igb, CTLFLAG_RD, 0, "IGB driver parameters"); /* Descriptor defaults */ static int igb_rxd = IGB_DEFAULT_RXD; static int igb_txd = IGB_DEFAULT_TXD; -TUNABLE_INT("hw.igb.rxd", &igb_rxd); -TUNABLE_INT("hw.igb.txd", &igb_txd); SYSCTL_INT(_hw_igb, OID_AUTO, rxd, CTLFLAG_RDTUN, &igb_rxd, 0, "Number of receive descriptors per queue"); SYSCTL_INT(_hw_igb, OID_AUTO, txd, CTLFLAG_RDTUN, &igb_txd, 0, @@ -341,8 +339,7 @@ SYSCTL_INT(_hw_igb, OID_AUTO, txd, CTLFLAG_RDTUN, &igb_txd, 0, ** traffic for that interrupt vector */ static int igb_enable_aim = TRUE; -TUNABLE_INT("hw.igb.enable_aim", &igb_enable_aim); -SYSCTL_INT(_hw_igb, OID_AUTO, enable_aim, CTLFLAG_RW, &igb_enable_aim, 0, +SYSCTL_INT(_hw_igb, OID_AUTO, enable_aim, CTLFLAG_RWTUN, &igb_enable_aim, 0, "Enable adaptive interrupt moderation"); /* @@ -350,7 +347,6 @@ SYSCTL_INT(_hw_igb, OID_AUTO, enable_aim, CTLFLAG_RW, &igb_enable_aim, 0, * but this allows it to be forced off for testing. */ static int igb_enable_msix = 1; -TUNABLE_INT("hw.igb.enable_msix", &igb_enable_msix); SYSCTL_INT(_hw_igb, OID_AUTO, enable_msix, CTLFLAG_RDTUN, &igb_enable_msix, 0, "Enable MSI-X interrupts"); @@ -358,7 +354,6 @@ SYSCTL_INT(_hw_igb, OID_AUTO, enable_msix, CTLFLAG_RDTUN, &igb_enable_msix, 0, ** Tuneable Interrupt rate */ static int igb_max_interrupt_rate = 8000; -TUNABLE_INT("hw.igb.max_interrupt_rate", &igb_max_interrupt_rate); SYSCTL_INT(_hw_igb, OID_AUTO, max_interrupt_rate, CTLFLAG_RDTUN, &igb_max_interrupt_rate, 0, "Maximum interrupts per second"); @@ -367,7 +362,6 @@ SYSCTL_INT(_hw_igb, OID_AUTO, max_interrupt_rate, CTLFLAG_RDTUN, ** Tuneable number of buffers in the buf-ring (drbr_xxx) */ static int igb_buf_ring_size = IGB_BR_SIZE; -TUNABLE_INT("hw.igb.buf_ring_size", &igb_buf_ring_size); SYSCTL_INT(_hw_igb, OID_AUTO, buf_ring_size, CTLFLAG_RDTUN, &igb_buf_ring_size, 0, "Size of the bufring"); #endif @@ -381,7 +375,6 @@ SYSCTL_INT(_hw_igb, OID_AUTO, buf_ring_size, CTLFLAG_RDTUN, ** a very workload dependent type feature. */ static int igb_header_split = FALSE; -TUNABLE_INT("hw.igb.hdr_split", &igb_header_split); SYSCTL_INT(_hw_igb, OID_AUTO, header_split, CTLFLAG_RDTUN, &igb_header_split, 0, "Enable receive mbuf header split"); @@ -391,7 +384,6 @@ SYSCTL_INT(_hw_igb, OID_AUTO, header_split, CTLFLAG_RDTUN, &igb_header_split, 0, ** MSIX messages if left at 0. */ static int igb_num_queues = 0; -TUNABLE_INT("hw.igb.num_queues", &igb_num_queues); SYSCTL_INT(_hw_igb, OID_AUTO, num_queues, CTLFLAG_RDTUN, &igb_num_queues, 0, "Number of queues to configure, 0 indicates autoconfigure"); @@ -404,7 +396,6 @@ static int igb_last_bind_cpu = -1; /* How many packets rxeof tries to clean at a time */ static int igb_rx_process_limit = 100; -TUNABLE_INT("hw.igb.rx_process_limit", &igb_rx_process_limit); SYSCTL_INT(_hw_igb, OID_AUTO, rx_process_limit, CTLFLAG_RDTUN, &igb_rx_process_limit, 0, "Maximum number of received packets to process at a time, -1 means unlimited"); diff --git a/sys/dev/fb/vesa.c b/sys/dev/fb/vesa.c index 48067b6401fe6..c7c2d641cdf47 100644 --- a/sys/dev/fb/vesa.c +++ b/sys/dev/fb/vesa.c @@ -101,7 +101,6 @@ static video_adapter_t *vesa_adp; static SYSCTL_NODE(_debug, OID_AUTO, vesa, CTLFLAG_RD, NULL, "VESA debugging"); static int vesa_shadow_rom; -TUNABLE_INT("debug.vesa.shadow_rom", &vesa_shadow_rom); SYSCTL_INT(_debug_vesa, OID_AUTO, shadow_rom, CTLFLAG_RDTUN, &vesa_shadow_rom, 0, "Enable video BIOS shadow"); diff --git a/sys/dev/firewire/fwohci.c b/sys/dev/firewire/fwohci.c index ae753d53d30ca..4ac43027bd405 100644 --- a/sys/dev/firewire/fwohci.c +++ b/sys/dev/firewire/fwohci.c @@ -78,14 +78,13 @@ #undef OHCI_DEBUG -static int nocyclemaster = 0; +static int nocyclemaster; int firewire_phydma_enable = 1; SYSCTL_DECL(_hw_firewire); -SYSCTL_INT(_hw_firewire, OID_AUTO, nocyclemaster, CTLFLAG_RW, &nocyclemaster, 0, - "Do not send cycle start packets"); -SYSCTL_INT(_hw_firewire, OID_AUTO, phydma_enable, CTLFLAG_RW, - &firewire_phydma_enable, 1, "Allow physical request DMA from firewire"); -TUNABLE_INT("hw.firewire.phydma_enable", &firewire_phydma_enable); +SYSCTL_INT(_hw_firewire, OID_AUTO, nocyclemaster, CTLFLAG_RWTUN, + &nocyclemaster, 0, "Do not send cycle start packets"); +SYSCTL_INT(_hw_firewire, OID_AUTO, phydma_enable, CTLFLAG_RWTUN, + &firewire_phydma_enable, 0, "Allow physical request DMA from firewire"); static char dbcode[16][0x10]={"OUTM", "OUTL","INPM","INPL", "STOR","LOAD","NOP ","STOP",}; diff --git a/sys/dev/firewire/if_fwe.c b/sys/dev/firewire/if_fwe.c index a7d9bc35d4945..cb21cf61d4285 100644 --- a/sys/dev/firewire/if_fwe.c +++ b/sys/dev/firewire/if_fwe.c @@ -88,21 +88,17 @@ static int tx_speed = 2; static int rx_queue_len = FWMAXQUEUE; static MALLOC_DEFINE(M_FWE, "if_fwe", "Ethernet over FireWire interface"); -SYSCTL_INT(_debug, OID_AUTO, if_fwe_debug, CTLFLAG_RW, &fwedebug, 0, ""); +SYSCTL_INT(_debug, OID_AUTO, if_fwe_debug, CTLFLAG_RWTUN, &fwedebug, 0, ""); SYSCTL_DECL(_hw_firewire); static SYSCTL_NODE(_hw_firewire, OID_AUTO, fwe, CTLFLAG_RD, 0, "Ethernet emulation subsystem"); -SYSCTL_INT(_hw_firewire_fwe, OID_AUTO, stream_ch, CTLFLAG_RW, &stream_ch, 0, +SYSCTL_INT(_hw_firewire_fwe, OID_AUTO, stream_ch, CTLFLAG_RWTUN, &stream_ch, 0, "Stream channel to use"); -SYSCTL_INT(_hw_firewire_fwe, OID_AUTO, tx_speed, CTLFLAG_RW, &tx_speed, 0, +SYSCTL_INT(_hw_firewire_fwe, OID_AUTO, tx_speed, CTLFLAG_RWTUN, &tx_speed, 0, "Transmission speed"); -SYSCTL_INT(_hw_firewire_fwe, OID_AUTO, rx_queue_len, CTLFLAG_RW, &rx_queue_len, +SYSCTL_INT(_hw_firewire_fwe, OID_AUTO, rx_queue_len, CTLFLAG_RWTUN, &rx_queue_len, 0, "Length of the receive queue"); -TUNABLE_INT("hw.firewire.fwe.stream_ch", &stream_ch); -TUNABLE_INT("hw.firewire.fwe.tx_speed", &tx_speed); -TUNABLE_INT("hw.firewire.fwe.rx_queue_len", &rx_queue_len); - #ifdef DEVICE_POLLING static poll_handler_t fwe_poll; diff --git a/sys/dev/firewire/if_fwip.c b/sys/dev/firewire/if_fwip.c index e98f44e237a3d..df3e1f6446d37 100644 --- a/sys/dev/firewire/if_fwip.c +++ b/sys/dev/firewire/if_fwip.c @@ -105,11 +105,9 @@ SYSCTL_INT(_debug, OID_AUTO, if_fwip_debug, CTLFLAG_RW, &fwipdebug, 0, ""); SYSCTL_DECL(_hw_firewire); static SYSCTL_NODE(_hw_firewire, OID_AUTO, fwip, CTLFLAG_RD, 0, "Firewire ip subsystem"); -SYSCTL_INT(_hw_firewire_fwip, OID_AUTO, rx_queue_len, CTLFLAG_RW, &rx_queue_len, +SYSCTL_INT(_hw_firewire_fwip, OID_AUTO, rx_queue_len, CTLFLAG_RWTUN, &rx_queue_len, 0, "Length of the receive queue"); -TUNABLE_INT("hw.firewire.fwip.rx_queue_len", &rx_queue_len); - #ifdef DEVICE_POLLING static poll_handler_t fwip_poll; diff --git a/sys/dev/firewire/sbp.c b/sys/dev/firewire/sbp.c index 10e8c60eea674..eeca4c77b4e70 100644 --- a/sys/dev/firewire/sbp.c +++ b/sys/dev/firewire/sbp.c @@ -134,31 +134,23 @@ static int sbp_tags = 0; SYSCTL_DECL(_hw_firewire); static SYSCTL_NODE(_hw_firewire, OID_AUTO, sbp, CTLFLAG_RD, 0, "SBP-II Subsystem"); -SYSCTL_INT(_debug, OID_AUTO, sbp_debug, CTLFLAG_RW, &debug, 0, +SYSCTL_INT(_debug, OID_AUTO, sbp_debug, CTLFLAG_RWTUN, &debug, 0, "SBP debug flag"); -SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, auto_login, CTLFLAG_RW, &auto_login, 0, +SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, auto_login, CTLFLAG_RWTUN, &auto_login, 0, "SBP perform login automatically"); -SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, max_speed, CTLFLAG_RW, &max_speed, 0, +SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, max_speed, CTLFLAG_RWTUN, &max_speed, 0, "SBP transfer max speed"); -SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, exclusive_login, CTLFLAG_RW, +SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, exclusive_login, CTLFLAG_RWTUN, &ex_login, 0, "SBP enable exclusive login"); -SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, login_delay, CTLFLAG_RW, +SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, login_delay, CTLFLAG_RWTUN, &login_delay, 0, "SBP login delay in msec"); -SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, scan_delay, CTLFLAG_RW, +SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, scan_delay, CTLFLAG_RWTUN, &scan_delay, 0, "SBP scan delay in msec"); -SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, use_doorbell, CTLFLAG_RW, +SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, use_doorbell, CTLFLAG_RWTUN, &use_doorbell, 0, "SBP use doorbell request"); -SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, tags, CTLFLAG_RW, &sbp_tags, 0, +SYSCTL_INT(_hw_firewire_sbp, OID_AUTO, tags, CTLFLAG_RWTUN, &sbp_tags, 0, "SBP tagged queuing support"); -TUNABLE_INT("hw.firewire.sbp.auto_login", &auto_login); -TUNABLE_INT("hw.firewire.sbp.max_speed", &max_speed); -TUNABLE_INT("hw.firewire.sbp.exclusive_login", &ex_login); -TUNABLE_INT("hw.firewire.sbp.login_delay", &login_delay); -TUNABLE_INT("hw.firewire.sbp.scan_delay", &scan_delay); -TUNABLE_INT("hw.firewire.sbp.use_doorbell", &use_doorbell); -TUNABLE_INT("hw.firewire.sbp.tags", &sbp_tags); - #define NEED_RESPONSE 0 #define SBP_SEG_MAX rounddown(0xffff, PAGE_SIZE) diff --git a/sys/dev/glxiic/glxiic.c b/sys/dev/glxiic/glxiic.c index 939c32db07df5..95d8602703f8f 100644 --- a/sys/dev/glxiic/glxiic.c +++ b/sys/dev/glxiic/glxiic.c @@ -314,7 +314,6 @@ glxiic_attach(device_t dev) struct sysctl_oid *tree; int error, irq, unit; uint32_t irq_map; - char tn[32]; sc = device_get_softc(dev); sc->dev = dev; @@ -402,10 +401,8 @@ glxiic_attach(device_t dev) tree = device_get_sysctl_tree(dev); sc->timeout = GLXIIC_DEFAULT_TIMEOUT; - snprintf(tn, sizeof(tn), "dev.glxiic.%d.timeout", unit); - TUNABLE_INT_FETCH(tn, &sc->timeout); SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "timeout", CTLFLAG_RW | CTLFLAG_TUN, &sc->timeout, 0, + "timeout", CTLFLAG_RWTUN, &sc->timeout, 0, "activity timeout in ms"); glxiic_gpio_enable(sc); diff --git a/sys/dev/hptmv/hptproc.c b/sys/dev/hptmv/hptproc.c index 93eff51d8dcb6..1141edc06c632 100644 --- a/sys/dev/hptmv/hptproc.c +++ b/sys/dev/hptmv/hptproc.c @@ -617,7 +617,7 @@ out: NULL, 0, hpt_status, "A", "Get/Set " #name " state") #else #define hptregister_node(name) \ - SYSCTL_NODE(, OID_AUTO, name, CTLFLAG_RW, 0, "Get/Set " #name " state root node"); \ + SYSCTL_ROOT_NODE(OID_AUTO, name, CTLFLAG_RW, 0, "Get/Set " #name " state root node"); \ SYSCTL_OID(_ ## name, OID_AUTO, status, CTLTYPE_STRING|CTLFLAG_RW, \ NULL, 0, hpt_status, "A", "Get/Set " #name " state"); #endif diff --git a/sys/dev/hwpmc/hwpmc_logging.c b/sys/dev/hwpmc/hwpmc_logging.c index c9b8aeaf5af13..ee5b89771f7b0 100644 --- a/sys/dev/hwpmc/hwpmc_logging.c +++ b/sys/dev/hwpmc/hwpmc_logging.c @@ -66,8 +66,7 @@ SYSCTL_DECL(_kern_hwpmc); */ static int pmclog_buffer_size = PMC_LOG_BUFFER_SIZE; -TUNABLE_INT(PMC_SYSCTL_NAME_PREFIX "logbuffersize", &pmclog_buffer_size); -SYSCTL_INT(_kern_hwpmc, OID_AUTO, logbuffersize, CTLFLAG_TUN|CTLFLAG_RD, +SYSCTL_INT(_kern_hwpmc, OID_AUTO, logbuffersize, CTLFLAG_RDTUN, &pmclog_buffer_size, 0, "size of log buffers in kilobytes"); /* @@ -75,8 +74,7 @@ SYSCTL_INT(_kern_hwpmc, OID_AUTO, logbuffersize, CTLFLAG_TUN|CTLFLAG_RD, */ static int pmc_nlogbuffers = PMC_NLOGBUFFERS; -TUNABLE_INT(PMC_SYSCTL_NAME_PREFIX "nbuffers", &pmc_nlogbuffers); -SYSCTL_INT(_kern_hwpmc, OID_AUTO, nbuffers, CTLFLAG_TUN|CTLFLAG_RD, +SYSCTL_INT(_kern_hwpmc, OID_AUTO, nbuffers, CTLFLAG_RDTUN, &pmc_nlogbuffers, 0, "number of global log buffers"); /* diff --git a/sys/dev/hwpmc/hwpmc_mod.c b/sys/dev/hwpmc/hwpmc_mod.c index 8e5eac879d24a..6241638d13b03 100644 --- a/sys/dev/hwpmc/hwpmc_mod.c +++ b/sys/dev/hwpmc/hwpmc_mod.c @@ -234,8 +234,7 @@ static void pmc_generic_cpu_finalize(struct pmc_mdep *md); SYSCTL_DECL(_kern_hwpmc); static int pmc_callchaindepth = PMC_CALLCHAIN_DEPTH; -TUNABLE_INT(PMC_SYSCTL_NAME_PREFIX "callchaindepth", &pmc_callchaindepth); -SYSCTL_INT(_kern_hwpmc, OID_AUTO, callchaindepth, CTLFLAG_TUN|CTLFLAG_RD, +SYSCTL_INT(_kern_hwpmc, OID_AUTO, callchaindepth, CTLFLAG_RDTUN, &pmc_callchaindepth, 0, "depth of call chain records"); #ifdef DEBUG @@ -244,7 +243,7 @@ char pmc_debugstr[PMC_DEBUG_STRSIZE]; TUNABLE_STR(PMC_SYSCTL_NAME_PREFIX "debugflags", pmc_debugstr, sizeof(pmc_debugstr)); SYSCTL_PROC(_kern_hwpmc, OID_AUTO, debugflags, - CTLTYPE_STRING|CTLFLAG_RW|CTLFLAG_TUN, + CTLTYPE_STRING | CTLFLAG_RWTUN | CTLFLAG_NOFETCH, 0, 0, pmc_debugflags_sysctl_handler, "A", "debug flags"); #endif @@ -254,8 +253,7 @@ SYSCTL_PROC(_kern_hwpmc, OID_AUTO, debugflags, */ static int pmc_hashsize = PMC_HASH_SIZE; -TUNABLE_INT(PMC_SYSCTL_NAME_PREFIX "hashsize", &pmc_hashsize); -SYSCTL_INT(_kern_hwpmc, OID_AUTO, hashsize, CTLFLAG_TUN|CTLFLAG_RD, +SYSCTL_INT(_kern_hwpmc, OID_AUTO, hashsize, CTLFLAG_RDTUN, &pmc_hashsize, 0, "rows in hash tables"); /* @@ -263,8 +261,7 @@ SYSCTL_INT(_kern_hwpmc, OID_AUTO, hashsize, CTLFLAG_TUN|CTLFLAG_RD, */ static int pmc_nsamples = PMC_NSAMPLES; -TUNABLE_INT(PMC_SYSCTL_NAME_PREFIX "nsamples", &pmc_nsamples); -SYSCTL_INT(_kern_hwpmc, OID_AUTO, nsamples, CTLFLAG_TUN|CTLFLAG_RD, +SYSCTL_INT(_kern_hwpmc, OID_AUTO, nsamples, CTLFLAG_RDTUN, &pmc_nsamples, 0, "number of PC samples per CPU"); @@ -273,8 +270,7 @@ SYSCTL_INT(_kern_hwpmc, OID_AUTO, nsamples, CTLFLAG_TUN|CTLFLAG_RD, */ static int pmc_mtxpool_size = PMC_MTXPOOL_SIZE; -TUNABLE_INT(PMC_SYSCTL_NAME_PREFIX "mtxpoolsize", &pmc_mtxpool_size); -SYSCTL_INT(_kern_hwpmc, OID_AUTO, mtxpoolsize, CTLFLAG_TUN|CTLFLAG_RD, +SYSCTL_INT(_kern_hwpmc, OID_AUTO, mtxpoolsize, CTLFLAG_RDTUN, &pmc_mtxpool_size, 0, "size of spin mutex pool"); @@ -288,8 +284,7 @@ SYSCTL_INT(_kern_hwpmc, OID_AUTO, mtxpoolsize, CTLFLAG_TUN|CTLFLAG_RD, */ static int pmc_unprivileged_syspmcs = 0; -TUNABLE_INT("security.bsd.unprivileged_syspmcs", &pmc_unprivileged_syspmcs); -SYSCTL_INT(_security_bsd, OID_AUTO, unprivileged_syspmcs, CTLFLAG_RW, +SYSCTL_INT(_security_bsd, OID_AUTO, unprivileged_syspmcs, CTLFLAG_RWTUN, &pmc_unprivileged_syspmcs, 0, "allow unprivileged process to allocate system PMCs"); diff --git a/sys/dev/iscsi/icl.c b/sys/dev/iscsi/icl.c index 2b5e4d0dba6d0..a22dd7980fd96 100644 --- a/sys/dev/iscsi/icl.c +++ b/sys/dev/iscsi/icl.c @@ -61,24 +61,19 @@ SYSCTL_NODE(_kern, OID_AUTO, icl, CTLFLAG_RD, 0, "iSCSI Common Layer"); static int debug = 1; -TUNABLE_INT("kern.icl.debug", &debug); SYSCTL_INT(_kern_icl, OID_AUTO, debug, CTLFLAG_RWTUN, &debug, 0, "Enable debug messages"); static int coalesce = 1; -TUNABLE_INT("kern.icl.coalesce", &coalesce); SYSCTL_INT(_kern_icl, OID_AUTO, coalesce, CTLFLAG_RWTUN, &coalesce, 0, "Try to coalesce PDUs before sending"); static int partial_receive_len = 128 * 1024; -TUNABLE_INT("kern.icl.partial_receive_len", &partial_receive_len); SYSCTL_INT(_kern_icl, OID_AUTO, partial_receive_len, CTLFLAG_RWTUN, &partial_receive_len, 0, "Minimum read size for partially received " "data segment"); static int sendspace = 1048576; -TUNABLE_INT("kern.icl.sendspace", &sendspace); SYSCTL_INT(_kern_icl, OID_AUTO, sendspace, CTLFLAG_RWTUN, &sendspace, 0, "Default send socket buffer size"); static int recvspace = 1048576; -TUNABLE_INT("kern.icl.recvspace", &recvspace); SYSCTL_INT(_kern_icl, OID_AUTO, recvspace, CTLFLAG_RWTUN, &recvspace, 0, "Default receive socket buffer size"); diff --git a/sys/dev/iscsi/iscsi.c b/sys/dev/iscsi/iscsi.c index ad9ec7a218a4a..22f84623c9803 100644 --- a/sys/dev/iscsi/iscsi.c +++ b/sys/dev/iscsi/iscsi.c @@ -78,27 +78,21 @@ static struct iscsi_softc *sc; SYSCTL_NODE(_kern, OID_AUTO, iscsi, CTLFLAG_RD, 0, "iSCSI initiator"); static int debug = 1; -TUNABLE_INT("kern.iscsi.debug", &debug); SYSCTL_INT(_kern_iscsi, OID_AUTO, debug, CTLFLAG_RWTUN, &debug, 0, "Enable debug messages"); static int ping_timeout = 5; -TUNABLE_INT("kern.iscsi.ping_timeout", &ping_timeout); SYSCTL_INT(_kern_iscsi, OID_AUTO, ping_timeout, CTLFLAG_RWTUN, &ping_timeout, 0, "Timeout for ping (NOP-Out) requests, in seconds"); static int iscsid_timeout = 60; -TUNABLE_INT("kern.iscsi.iscsid_timeout", &iscsid_timeout); SYSCTL_INT(_kern_iscsi, OID_AUTO, iscsid_timeout, CTLFLAG_RWTUN, &iscsid_timeout, 0, "Time to wait for iscsid(8) to handle reconnection, in seconds"); static int login_timeout = 60; -TUNABLE_INT("kern.iscsi.login_timeout", &login_timeout); SYSCTL_INT(_kern_iscsi, OID_AUTO, login_timeout, CTLFLAG_RWTUN, &login_timeout, 0, "Time to wait for iscsid(8) to finish Login Phase, in seconds"); static int maxtags = 255; -TUNABLE_INT("kern.iscsi.maxtags", &maxtags); SYSCTL_INT(_kern_iscsi, OID_AUTO, maxtags, CTLFLAG_RWTUN, &maxtags, 0, "Max number of IO requests queued"); static int fail_on_disconnection = 0; -TUNABLE_INT("kern.iscsi.fail_on_disconnection", &fail_on_disconnection); SYSCTL_INT(_kern_iscsi, OID_AUTO, fail_on_disconnection, CTLFLAG_RWTUN, &fail_on_disconnection, 0, "Destroy CAM SIM on connection failure"); diff --git a/sys/dev/iscsi_initiator/iscsi.c b/sys/dev/iscsi_initiator/iscsi.c index cd66a369fa749..049c1112d6c86 100644 --- a/sys/dev/iscsi_initiator/iscsi.c +++ b/sys/dev/iscsi_initiator/iscsi.c @@ -77,11 +77,11 @@ struct mtx iscsi_dbg_mtx; #endif static int max_sessions = MAX_SESSIONS; -SYSCTL_INT(_net, OID_AUTO, iscsi_initiator_max_sessions, CTLFLAG_RDTUN, &max_sessions, MAX_SESSIONS, - "Max sessions allowed"); +SYSCTL_INT(_net, OID_AUTO, iscsi_initiator_max_sessions, CTLFLAG_RDTUN, + &max_sessions, 0, "Max sessions allowed"); static int max_pdus = MAX_PDUS; -SYSCTL_INT(_net, OID_AUTO, iscsi_initiator_max_pdus, CTLFLAG_RDTUN, &max_pdus, MAX_PDUS, - "Max pdu pool"); +SYSCTL_INT(_net, OID_AUTO, iscsi_initiator_max_pdus, CTLFLAG_RDTUN, + &max_pdus, 0, "Max PDU pool"); static char isid[6+1] = { 0x80, @@ -711,9 +711,6 @@ iscsi_start(void) { debug_called(8); - TUNABLE_INT_FETCH("net.iscsi_initiator.max_sessions", &max_sessions); - TUNABLE_INT_FETCH("net.iscsi_initiator.max_pdus", &max_pdus); - isc = malloc(sizeof(struct isc_softc), M_ISCSI, M_ZERO|M_WAITOK); mtx_init(&isc->isc_mtx, "iscsi-isc", NULL, MTX_DEF); diff --git a/sys/dev/ixgbe/ixgbe.c b/sys/dev/ixgbe/ixgbe.c index fb0daa1921ba6..0eb334a11675c 100644 --- a/sys/dev/ixgbe/ixgbe.c +++ b/sys/dev/ixgbe/ixgbe.c @@ -244,18 +244,15 @@ static SYSCTL_NODE(_hw, OID_AUTO, ix, CTLFLAG_RD, 0, ** traffic for that interrupt vector */ static int ixgbe_enable_aim = TRUE; -TUNABLE_INT("hw.ixgbe.enable_aim", &ixgbe_enable_aim); -SYSCTL_INT(_hw_ix, OID_AUTO, enable_aim, CTLFLAG_RW, &ixgbe_enable_aim, 0, +SYSCTL_INT(_hw_ix, OID_AUTO, enable_aim, CTLFLAG_RWTUN, &ixgbe_enable_aim, 0, "Enable adaptive interrupt moderation"); static int ixgbe_max_interrupt_rate = (4000000 / IXGBE_LOW_LATENCY); -TUNABLE_INT("hw.ixgbe.max_interrupt_rate", &ixgbe_max_interrupt_rate); SYSCTL_INT(_hw_ix, OID_AUTO, max_interrupt_rate, CTLFLAG_RDTUN, &ixgbe_max_interrupt_rate, 0, "Maximum interrupts per second"); /* How many packets rxeof tries to clean at a time */ static int ixgbe_rx_process_limit = 256; -TUNABLE_INT("hw.ixgbe.rx_process_limit", &ixgbe_rx_process_limit); SYSCTL_INT(_hw_ix, OID_AUTO, rx_process_limit, CTLFLAG_RDTUN, &ixgbe_rx_process_limit, 0, "Maximum number of received packets to process at a time," @@ -263,7 +260,6 @@ SYSCTL_INT(_hw_ix, OID_AUTO, rx_process_limit, CTLFLAG_RDTUN, /* How many packets txeof tries to clean at a time */ static int ixgbe_tx_process_limit = 256; -TUNABLE_INT("hw.ixgbe.tx_process_limit", &ixgbe_tx_process_limit); SYSCTL_INT(_hw_ix, OID_AUTO, tx_process_limit, CTLFLAG_RDTUN, &ixgbe_tx_process_limit, 0, "Maximum number of sent packets to process at a time," @@ -283,7 +279,6 @@ static int ixgbe_smart_speed = ixgbe_smart_speed_on; * but this allows it to be forced off for testing. */ static int ixgbe_enable_msix = 1; -TUNABLE_INT("hw.ixgbe.enable_msix", &ixgbe_enable_msix); SYSCTL_INT(_hw_ix, OID_AUTO, enable_msix, CTLFLAG_RDTUN, &ixgbe_enable_msix, 0, "Enable MSI-X interrupts"); @@ -294,7 +289,6 @@ SYSCTL_INT(_hw_ix, OID_AUTO, enable_msix, CTLFLAG_RDTUN, &ixgbe_enable_msix, 0, * can be overriden manually here. */ static int ixgbe_num_queues = 0; -TUNABLE_INT("hw.ixgbe.num_queues", &ixgbe_num_queues); SYSCTL_INT(_hw_ix, OID_AUTO, num_queues, CTLFLAG_RDTUN, &ixgbe_num_queues, 0, "Number of queues to configure, 0 indicates autoconfigure"); @@ -304,13 +298,11 @@ SYSCTL_INT(_hw_ix, OID_AUTO, num_queues, CTLFLAG_RDTUN, &ixgbe_num_queues, 0, ** the better performing choice. */ static int ixgbe_txd = PERFORM_TXD; -TUNABLE_INT("hw.ixgbe.txd", &ixgbe_txd); SYSCTL_INT(_hw_ix, OID_AUTO, txd, CTLFLAG_RDTUN, &ixgbe_txd, 0, "Number of receive descriptors per queue"); /* Number of RX descriptors per ring */ static int ixgbe_rxd = PERFORM_RXD; -TUNABLE_INT("hw.ixgbe.rxd", &ixgbe_rxd); SYSCTL_INT(_hw_ix, OID_AUTO, rxd, CTLFLAG_RDTUN, &ixgbe_rxd, 0, "Number of receive descriptors per queue"); diff --git a/sys/dev/malo/if_malo.c b/sys/dev/malo/if_malo.c index db8f61d7437b2..1e879ba9459fb 100644 --- a/sys/dev/malo/if_malo.c +++ b/sys/dev/malo/if_malo.c @@ -65,27 +65,22 @@ SYSCTL_NODE(_hw, OID_AUTO, malo, CTLFLAG_RD, 0, "Marvell 88w8335 driver parameters"); static int malo_txcoalesce = 8; /* # tx pkts to q before poking f/w*/ -SYSCTL_INT(_hw_malo, OID_AUTO, txcoalesce, CTLFLAG_RW, &malo_txcoalesce, +SYSCTL_INT(_hw_malo, OID_AUTO, txcoalesce, CTLFLAG_RWTUN, &malo_txcoalesce, 0, "tx buffers to send at once"); -TUNABLE_INT("hw.malo.txcoalesce", &malo_txcoalesce); static int malo_rxbuf = MALO_RXBUF; /* # rx buffers to allocate */ -SYSCTL_INT(_hw_malo, OID_AUTO, rxbuf, CTLFLAG_RW, &malo_rxbuf, +SYSCTL_INT(_hw_malo, OID_AUTO, rxbuf, CTLFLAG_RWTUN, &malo_rxbuf, 0, "rx buffers allocated"); -TUNABLE_INT("hw.malo.rxbuf", &malo_rxbuf); static int malo_rxquota = MALO_RXBUF; /* # max buffers to process */ -SYSCTL_INT(_hw_malo, OID_AUTO, rxquota, CTLFLAG_RW, &malo_rxquota, +SYSCTL_INT(_hw_malo, OID_AUTO, rxquota, CTLFLAG_RWTUN, &malo_rxquota, 0, "max rx buffers to process per interrupt"); -TUNABLE_INT("hw.malo.rxquota", &malo_rxquota); static int malo_txbuf = MALO_TXBUF; /* # tx buffers to allocate */ -SYSCTL_INT(_hw_malo, OID_AUTO, txbuf, CTLFLAG_RW, &malo_txbuf, +SYSCTL_INT(_hw_malo, OID_AUTO, txbuf, CTLFLAG_RWTUN, &malo_txbuf, 0, "tx buffers allocated"); -TUNABLE_INT("hw.malo.txbuf", &malo_txbuf); #ifdef MALO_DEBUG static int malo_debug = 0; -SYSCTL_INT(_hw_malo, OID_AUTO, debug, CTLFLAG_RW, &malo_debug, +SYSCTL_INT(_hw_malo, OID_AUTO, debug, CTLFLAG_RWTUN, &malo_debug, 0, "control debugging printfs"); -TUNABLE_INT("hw.malo.debug", &malo_debug); enum { MALO_DEBUG_XMIT = 0x00000001, /* basic xmit operation */ MALO_DEBUG_XMIT_DESC = 0x00000002, /* xmit descriptors */ diff --git a/sys/dev/malo/if_malo_pci.c b/sys/dev/malo/if_malo_pci.c index 71ba3c0543c5d..c9e6b20703805 100644 --- a/sys/dev/malo/if_malo_pci.c +++ b/sys/dev/malo/if_malo_pci.c @@ -86,9 +86,8 @@ static SYSCTL_NODE(_hw_malo, OID_AUTO, pci, CTLFLAG_RD, 0, "Marvell 88W8335 driver PCI parameters"); static int msi_disable = 0; /* MSI disabled */ -SYSCTL_INT(_hw_malo_pci, OID_AUTO, msi_disable, CTLFLAG_RW, &msi_disable, +SYSCTL_INT(_hw_malo_pci, OID_AUTO, msi_disable, CTLFLAG_RWTUN, &msi_disable, 0, "MSI disabled"); -TUNABLE_INT("hw.malo.pci.msi_disable", &msi_disable); /* * Devices supported by this driver. diff --git a/sys/dev/mfi/mfi.c b/sys/dev/mfi/mfi.c index 1a618ce0b176c..5ec813eafaee4 100644 --- a/sys/dev/mfi/mfi.c +++ b/sys/dev/mfi/mfi.c @@ -132,33 +132,27 @@ static int mfi_check_for_sscd(struct mfi_softc *sc, struct mfi_command *cm); SYSCTL_NODE(_hw, OID_AUTO, mfi, CTLFLAG_RD, 0, "MFI driver parameters"); static int mfi_event_locale = MFI_EVT_LOCALE_ALL; -TUNABLE_INT("hw.mfi.event_locale", &mfi_event_locale); SYSCTL_INT(_hw_mfi, OID_AUTO, event_locale, CTLFLAG_RWTUN, &mfi_event_locale, 0, "event message locale"); static int mfi_event_class = MFI_EVT_CLASS_INFO; -TUNABLE_INT("hw.mfi.event_class", &mfi_event_class); SYSCTL_INT(_hw_mfi, OID_AUTO, event_class, CTLFLAG_RWTUN, &mfi_event_class, 0, "event message class"); static int mfi_max_cmds = 128; -TUNABLE_INT("hw.mfi.max_cmds", &mfi_max_cmds); SYSCTL_INT(_hw_mfi, OID_AUTO, max_cmds, CTLFLAG_RDTUN, &mfi_max_cmds, 0, "Max commands limit (-1 = controller limit)"); static int mfi_detect_jbod_change = 1; -TUNABLE_INT("hw.mfi.detect_jbod_change", &mfi_detect_jbod_change); SYSCTL_INT(_hw_mfi, OID_AUTO, detect_jbod_change, CTLFLAG_RWTUN, &mfi_detect_jbod_change, 0, "Detect a change to a JBOD"); int mfi_polled_cmd_timeout = MFI_POLL_TIMEOUT_SECS; -TUNABLE_INT("hw.mfi.polled_cmd_timeout", &mfi_polled_cmd_timeout); SYSCTL_INT(_hw_mfi, OID_AUTO, polled_cmd_timeout, CTLFLAG_RWTUN, &mfi_polled_cmd_timeout, 0, "Polled command timeout - used for firmware flash etc (in seconds)"); static int mfi_cmd_timeout = MFI_CMD_TIMEOUT; -TUNABLE_INT("hw.mfi.cmd_timeout", &mfi_cmd_timeout); SYSCTL_INT(_hw_mfi, OID_AUTO, cmd_timeout, CTLFLAG_RWTUN, &mfi_cmd_timeout, 0, "Command timeout (in seconds)"); diff --git a/sys/dev/mfi/mfi_cam.c b/sys/dev/mfi/mfi_cam.c index 4fd6198a8a851..87f854c3f33e6 100644 --- a/sys/dev/mfi/mfi_cam.c +++ b/sys/dev/mfi/mfi_cam.c @@ -90,8 +90,7 @@ static struct mfi_command * mfip_start(void *); static void mfip_done(struct mfi_command *cm); static int mfi_allow_disks = 0; -TUNABLE_INT("hw.mfi.allow_cam_disk_passthrough", &mfi_allow_disks); -SYSCTL_INT(_hw_mfi, OID_AUTO, allow_cam_disk_passthrough, CTLFLAG_RD, +SYSCTL_INT(_hw_mfi, OID_AUTO, allow_cam_disk_passthrough, CTLFLAG_RDTUN, &mfi_allow_disks, 0, "event message locale"); static devclass_t mfip_devclass; diff --git a/sys/dev/mfi/mfi_pci.c b/sys/dev/mfi/mfi_pci.c index 803584e439a1a..80d655cf1b02d 100644 --- a/sys/dev/mfi/mfi_pci.c +++ b/sys/dev/mfi/mfi_pci.c @@ -108,12 +108,10 @@ DRIVER_MODULE(mfi, pci, mfi_pci_driver, mfi_devclass, 0, 0); MODULE_VERSION(mfi, 1); static int mfi_msi = 1; -TUNABLE_INT("hw.mfi.msi", &mfi_msi); SYSCTL_INT(_hw_mfi, OID_AUTO, msi, CTLFLAG_RDTUN, &mfi_msi, 0, "Enable use of MSI interrupts"); -static int mfi_mrsas_enable = 0; -TUNABLE_INT("hw.mfi.mrsas_enable", &mfi_mrsas_enable); +static int mfi_mrsas_enable; SYSCTL_INT(_hw_mfi, OID_AUTO, mrsas_enable, CTLFLAG_RDTUN, &mfi_mrsas_enable, 0, "Allow mrasas to take newer cards"); @@ -186,7 +184,6 @@ mfi_pci_probe(device_t dev) device_set_desc(dev, id->desc); /* give priority to mrsas if tunable set */ - TUNABLE_INT_FETCH("hw.mfi.mrsas_enable", &mfi_mrsas_enable); if ((id->flags & MFI_FLAGS_MRSAS) && mfi_mrsas_enable) return (BUS_PROBE_LOW_PRIORITY); else diff --git a/sys/dev/mfi/mfi_tbolt.c b/sys/dev/mfi/mfi_tbolt.c index 2d27534062c3e..984c355321e7f 100644 --- a/sys/dev/mfi/mfi_tbolt.c +++ b/sys/dev/mfi/mfi_tbolt.c @@ -86,7 +86,6 @@ static void mfi_queue_map_sync(struct mfi_softc *sc); extern int mfi_polled_cmd_timeout; static int mfi_fw_reset_test = 0; #ifdef MFI_DEBUG -TUNABLE_INT("hw.mfi.fw_reset_test", &mfi_fw_reset_test); SYSCTL_INT(_hw_mfi, OID_AUTO, fw_reset_test, CTLFLAG_RWTUN, &mfi_fw_reset_test, 0, "Force a firmware reset condition"); #endif diff --git a/sys/dev/mwl/if_mwl.c b/sys/dev/mwl/if_mwl.c index b50e1a9379076..b5bd9bd5003d6 100644 --- a/sys/dev/mwl/if_mwl.c +++ b/sys/dev/mwl/if_mwl.c @@ -188,31 +188,25 @@ static int mwl_rxdesc = MWL_RXDESC; /* # rx desc's to allocate */ SYSCTL_INT(_hw_mwl, OID_AUTO, rxdesc, CTLFLAG_RW, &mwl_rxdesc, 0, "rx descriptors allocated"); static int mwl_rxbuf = MWL_RXBUF; /* # rx buffers to allocate */ -SYSCTL_INT(_hw_mwl, OID_AUTO, rxbuf, CTLFLAG_RW, &mwl_rxbuf, +SYSCTL_INT(_hw_mwl, OID_AUTO, rxbuf, CTLFLAG_RWTUN, &mwl_rxbuf, 0, "rx buffers allocated"); -TUNABLE_INT("hw.mwl.rxbuf", &mwl_rxbuf); static int mwl_txbuf = MWL_TXBUF; /* # tx buffers to allocate */ -SYSCTL_INT(_hw_mwl, OID_AUTO, txbuf, CTLFLAG_RW, &mwl_txbuf, +SYSCTL_INT(_hw_mwl, OID_AUTO, txbuf, CTLFLAG_RWTUN, &mwl_txbuf, 0, "tx buffers allocated"); -TUNABLE_INT("hw.mwl.txbuf", &mwl_txbuf); static int mwl_txcoalesce = 8; /* # tx packets to q before poking f/w*/ -SYSCTL_INT(_hw_mwl, OID_AUTO, txcoalesce, CTLFLAG_RW, &mwl_txcoalesce, +SYSCTL_INT(_hw_mwl, OID_AUTO, txcoalesce, CTLFLAG_RWTUN, &mwl_txcoalesce, 0, "tx buffers to send at once"); -TUNABLE_INT("hw.mwl.txcoalesce", &mwl_txcoalesce); static int mwl_rxquota = MWL_RXBUF; /* # max buffers to process */ -SYSCTL_INT(_hw_mwl, OID_AUTO, rxquota, CTLFLAG_RW, &mwl_rxquota, +SYSCTL_INT(_hw_mwl, OID_AUTO, rxquota, CTLFLAG_RWTUN, &mwl_rxquota, 0, "max rx buffers to process per interrupt"); -TUNABLE_INT("hw.mwl.rxquota", &mwl_rxquota); static int mwl_rxdmalow = 3; /* # min buffers for wakeup */ -SYSCTL_INT(_hw_mwl, OID_AUTO, rxdmalow, CTLFLAG_RW, &mwl_rxdmalow, +SYSCTL_INT(_hw_mwl, OID_AUTO, rxdmalow, CTLFLAG_RWTUN, &mwl_rxdmalow, 0, "min free rx buffers before restarting traffic"); -TUNABLE_INT("hw.mwl.rxdmalow", &mwl_rxdmalow); #ifdef MWL_DEBUG static int mwl_debug = 0; -SYSCTL_INT(_hw_mwl, OID_AUTO, debug, CTLFLAG_RW, &mwl_debug, +SYSCTL_INT(_hw_mwl, OID_AUTO, debug, CTLFLAG_RWTUN, &mwl_debug, 0, "control debugging printfs"); -TUNABLE_INT("hw.mwl.debug", &mwl_debug); enum { MWL_DEBUG_XMIT = 0x00000001, /* basic xmit operation */ MWL_DEBUG_XMIT_DESC = 0x00000002, /* xmit descriptors */ diff --git a/sys/dev/nand/nand.c b/sys/dev/nand/nand.c index fb83e673861b5..113953ef8f375 100644 --- a/sys/dev/nand/nand.c +++ b/sys/dev/nand/nand.c @@ -65,18 +65,9 @@ __FBSDID("$FreeBSD$"); #define SOFTECC_BYTES 3 int nand_debug_flag = 0; -SYSCTL_INT(_debug, OID_AUTO, nand_debug, CTLFLAG_RW, &nand_debug_flag, 0, +SYSCTL_INT(_debug, OID_AUTO, nand_debug, CTLFLAG_RWTUN, &nand_debug_flag, 0, "NAND subsystem debug flag"); -static void -nand_tunable_init(void *arg) -{ - - TUNABLE_INT_FETCH("debug.nand", &nand_debug_flag); -} - -SYSINIT(nand_tunables, SI_SUB_VFS, SI_ORDER_ANY, nand_tunable_init, NULL); - MALLOC_DEFINE(M_NAND, "NAND", "NAND dynamic data"); static void calculate_ecc(const uint8_t *, uint8_t *); diff --git a/sys/dev/pccard/pccard.c b/sys/dev/pccard/pccard.c index 0c49d2f38a7ff..87ab53abcf4a3 100644 --- a/sys/dev/pccard/pccard.c +++ b/sys/dev/pccard/pccard.c @@ -62,14 +62,12 @@ __FBSDID("$FreeBSD$"); static SYSCTL_NODE(_hw, OID_AUTO, pccard, CTLFLAG_RD, 0, "PCCARD parameters"); int pccard_debug = 0; -TUNABLE_INT("hw.pccard.debug", &pccard_debug); -SYSCTL_INT(_hw_pccard, OID_AUTO, debug, CTLFLAG_RW, +SYSCTL_INT(_hw_pccard, OID_AUTO, debug, CTLFLAG_RWTUN, &pccard_debug, 0, "pccard debug"); int pccard_cis_debug = 0; -TUNABLE_INT("hw.pccard.cis_debug", &pccard_cis_debug); -SYSCTL_INT(_hw_pccard, OID_AUTO, cis_debug, CTLFLAG_RW, +SYSCTL_INT(_hw_pccard, OID_AUTO, cis_debug, CTLFLAG_RWTUN, &pccard_cis_debug, 0, "pccard CIS debug"); #ifdef PCCARDDEBUG diff --git a/sys/dev/pccbb/pccbb.c b/sys/dev/pccbb/pccbb.c index 092d3efae773b..b724d05e04231 100644 --- a/sys/dev/pccbb/pccbb.c +++ b/sys/dev/pccbb/pccbb.c @@ -134,26 +134,22 @@ static SYSCTL_NODE(_hw, OID_AUTO, cbb, CTLFLAG_RD, 0, "CBB parameters"); /* There's no way to say TUNEABLE_LONG to get the right types */ u_long cbb_start_mem = CBB_START_MEM; -TUNABLE_ULONG("hw.cbb.start_memory", &cbb_start_mem); -SYSCTL_ULONG(_hw_cbb, OID_AUTO, start_memory, CTLFLAG_RW, +SYSCTL_ULONG(_hw_cbb, OID_AUTO, start_memory, CTLFLAG_RWTUN, &cbb_start_mem, CBB_START_MEM, "Starting address for memory allocations"); u_long cbb_start_16_io = CBB_START_16_IO; -TUNABLE_ULONG("hw.cbb.start_16_io", &cbb_start_16_io); -SYSCTL_ULONG(_hw_cbb, OID_AUTO, start_16_io, CTLFLAG_RW, +SYSCTL_ULONG(_hw_cbb, OID_AUTO, start_16_io, CTLFLAG_RWTUN, &cbb_start_16_io, CBB_START_16_IO, "Starting ioport for 16-bit cards"); u_long cbb_start_32_io = CBB_START_32_IO; -TUNABLE_ULONG("hw.cbb.start_32_io", &cbb_start_32_io); -SYSCTL_ULONG(_hw_cbb, OID_AUTO, start_32_io, CTLFLAG_RW, +SYSCTL_ULONG(_hw_cbb, OID_AUTO, start_32_io, CTLFLAG_RWTUN, &cbb_start_32_io, CBB_START_32_IO, "Starting ioport for 32-bit cards"); int cbb_debug = 0; -TUNABLE_INT("hw.cbb.debug", &cbb_debug); -SYSCTL_INT(_hw_cbb, OID_AUTO, debug, CTLFLAG_RW, &cbb_debug, 0, +SYSCTL_INT(_hw_cbb, OID_AUTO, debug, CTLFLAG_RWTUN, &cbb_debug, 0, "Verbose cardbus bridge debugging"); static void cbb_insert(struct cbb_softc *sc); diff --git a/sys/dev/pccbb/pccbb_isa.c b/sys/dev/pccbb/pccbb_isa.c index 1d0a698da78b0..c511062510556 100644 --- a/sys/dev/pccbb/pccbb_isa.c +++ b/sys/dev/pccbb/pccbb_isa.c @@ -74,8 +74,7 @@ __FBSDID("$FreeBSD$"); static SYSCTL_NODE(_hw, OID_AUTO, pcic, CTLFLAG_RD, 0, "PCIC parameters"); static int isa_intr_mask = EXCA_INT_MASK_ALLOWED; -TUNABLE_INT("hw.cbb.intr_mask", &isa_intr_mask); -SYSCTL_INT(_hw_pcic, OID_AUTO, intr_mask, CTLFLAG_RD, &isa_intr_mask, 0, +SYSCTL_INT(_hw_pcic, OID_AUTO, intr_mask, CTLFLAG_RDTUN, &isa_intr_mask, 0, "Mask of allowable interrupts for this laptop. The default is generally\n\ correct, but some laptops do not route all the IRQ pins to the bridge to\n\ save wires. Sometimes you need a more restrictive mask because some of the\n\ @@ -89,7 +88,6 @@ allocated."); * 2: 6729's method */ int pcic_pd6722_vsense = 1; -TUNABLE_INT("hw.pcic.pd6722_vsense", &pcic_pd6722_vsense); SYSCTL_INT(_hw_pcic, OID_AUTO, pd6722_vsense, CTLFLAG_RDTUN, &pcic_pd6722_vsense, 1, "Select CL-PD6722's VSENSE method. VSENSE is used to determine the\n\ diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index b2b5ff80d0d54..9733841803ab6 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -282,22 +282,20 @@ static int pcie_chipset, pcix_chipset; SYSCTL_NODE(_hw, OID_AUTO, pci, CTLFLAG_RD, 0, "PCI bus tuning parameters"); static int pci_enable_io_modes = 1; -TUNABLE_INT("hw.pci.enable_io_modes", &pci_enable_io_modes); -SYSCTL_INT(_hw_pci, OID_AUTO, enable_io_modes, CTLFLAG_RW, +SYSCTL_INT(_hw_pci, OID_AUTO, enable_io_modes, CTLFLAG_RWTUN, &pci_enable_io_modes, 1, "Enable I/O and memory bits in the config register. Some BIOSes do not\n\ enable these bits correctly. We'd like to do this all the time, but there\n\ are some peripherals that this causes problems with."); static int pci_do_realloc_bars = 0; -TUNABLE_INT("hw.pci.realloc_bars", &pci_do_realloc_bars); -SYSCTL_INT(_hw_pci, OID_AUTO, realloc_bars, CTLFLAG_RW, +SYSCTL_INT(_hw_pci, OID_AUTO, realloc_bars, CTLFLAG_RWTUN, &pci_do_realloc_bars, 0, - "Attempt to allocate a new range for any BARs whose original firmware-assigned ranges fail to allocate during the initial device scan."); + "Attempt to allocate a new range for any BARs whose original " + "firmware-assigned ranges fail to allocate during the initial device scan."); static int pci_do_power_nodriver = 0; -TUNABLE_INT("hw.pci.do_power_nodriver", &pci_do_power_nodriver); -SYSCTL_INT(_hw_pci, OID_AUTO, do_power_nodriver, CTLFLAG_RW, +SYSCTL_INT(_hw_pci, OID_AUTO, do_power_nodriver, CTLFLAG_RWTUN, &pci_do_power_nodriver, 0, "Place a function into D3 state when no driver attaches to it. 0 means\n\ disable. 1 means conservatively place devices into D3 state. 2 means\n\ @@ -305,30 +303,25 @@ agressively place devices into D3 state. 3 means put absolutely everything\n\ in D3 state."); int pci_do_power_resume = 1; -TUNABLE_INT("hw.pci.do_power_resume", &pci_do_power_resume); -SYSCTL_INT(_hw_pci, OID_AUTO, do_power_resume, CTLFLAG_RW, +SYSCTL_INT(_hw_pci, OID_AUTO, do_power_resume, CTLFLAG_RWTUN, &pci_do_power_resume, 1, "Transition from D3 -> D0 on resume."); int pci_do_power_suspend = 1; -TUNABLE_INT("hw.pci.do_power_suspend", &pci_do_power_suspend); -SYSCTL_INT(_hw_pci, OID_AUTO, do_power_suspend, CTLFLAG_RW, +SYSCTL_INT(_hw_pci, OID_AUTO, do_power_suspend, CTLFLAG_RWTUN, &pci_do_power_suspend, 1, "Transition from D0 -> D3 on suspend."); static int pci_do_msi = 1; -TUNABLE_INT("hw.pci.enable_msi", &pci_do_msi); -SYSCTL_INT(_hw_pci, OID_AUTO, enable_msi, CTLFLAG_RW, &pci_do_msi, 1, +SYSCTL_INT(_hw_pci, OID_AUTO, enable_msi, CTLFLAG_RWTUN, &pci_do_msi, 1, "Enable support for MSI interrupts"); static int pci_do_msix = 1; -TUNABLE_INT("hw.pci.enable_msix", &pci_do_msix); -SYSCTL_INT(_hw_pci, OID_AUTO, enable_msix, CTLFLAG_RW, &pci_do_msix, 1, +SYSCTL_INT(_hw_pci, OID_AUTO, enable_msix, CTLFLAG_RWTUN, &pci_do_msix, 1, "Enable support for MSI-X interrupts"); static int pci_honor_msi_blacklist = 1; -TUNABLE_INT("hw.pci.honor_msi_blacklist", &pci_honor_msi_blacklist); -SYSCTL_INT(_hw_pci, OID_AUTO, honor_msi_blacklist, CTLFLAG_RD, +SYSCTL_INT(_hw_pci, OID_AUTO, honor_msi_blacklist, CTLFLAG_RDTUN, &pci_honor_msi_blacklist, 1, "Honor chipset blacklist for MSI/MSI-X"); #if defined(__i386__) || defined(__amd64__) @@ -336,26 +329,22 @@ static int pci_usb_takeover = 1; #else static int pci_usb_takeover = 0; #endif -TUNABLE_INT("hw.pci.usb_early_takeover", &pci_usb_takeover); SYSCTL_INT(_hw_pci, OID_AUTO, usb_early_takeover, CTLFLAG_RDTUN, &pci_usb_takeover, 1, "Enable early takeover of USB controllers.\n\ Disable this if you depend on BIOS emulation of USB devices, that is\n\ you use USB devices (like keyboard or mouse) but do not load USB drivers"); static int pci_clear_bars; -TUNABLE_INT("hw.pci.clear_bars", &pci_clear_bars); SYSCTL_INT(_hw_pci, OID_AUTO, clear_bars, CTLFLAG_RDTUN, &pci_clear_bars, 0, "Ignore firmware-assigned resources for BARs."); #if defined(NEW_PCIB) && defined(PCI_RES_BUS) static int pci_clear_buses; -TUNABLE_INT("hw.pci.clear_buses", &pci_clear_buses); SYSCTL_INT(_hw_pci, OID_AUTO, clear_buses, CTLFLAG_RDTUN, &pci_clear_buses, 0, "Ignore firmware-assigned bus numbers."); #endif static int pci_enable_ari = 1; -TUNABLE_INT("hw.pci.enable_ari", &pci_enable_ari); SYSCTL_INT(_hw_pci, OID_AUTO, enable_ari, CTLFLAG_RDTUN, &pci_enable_ari, 0, "Enable support for PCIe Alternative RID Interpretation"); diff --git a/sys/dev/pci/pci_pci.c b/sys/dev/pci/pci_pci.c index 8b5021974c750..3c5842be44c6d 100644 --- a/sys/dev/pci/pci_pci.c +++ b/sys/dev/pci/pci_pci.c @@ -117,7 +117,6 @@ DRIVER_MODULE(pcib, pci, pcib_driver, pcib_devclass, NULL, NULL); SYSCTL_DECL(_hw_pci); static int pci_clear_pcib; -TUNABLE_INT("hw.pci.clear_pcib", &pci_clear_pcib); SYSCTL_INT(_hw_pci, OID_AUTO, clear_pcib, CTLFLAG_RDTUN, &pci_clear_pcib, 0, "Clear firmware-assigned resources for PCI-PCI bridge I/O windows."); diff --git a/sys/dev/pci/vga_pci.c b/sys/dev/pci/vga_pci.c index 6e733f588d5ed..46f32505c36e1 100644 --- a/sys/dev/pci/vga_pci.c +++ b/sys/dev/pci/vga_pci.c @@ -71,7 +71,6 @@ static int vga_pci_release_resource(device_t dev, device_t child, int type, int rid, struct resource *r); int vga_pci_default_unit = -1; -TUNABLE_INT("hw.pci.default_vgapci_unit", &vga_pci_default_unit); SYSCTL_INT(_hw_pci, OID_AUTO, default_vgapci_unit, CTLFLAG_RDTUN, &vga_pci_default_unit, -1, "Default VGA-compatible display"); diff --git a/sys/dev/puc/puc_pci.c b/sys/dev/puc/puc_pci.c index d6d5509050c3b..618a3ae036911 100644 --- a/sys/dev/puc/puc_pci.c +++ b/sys/dev/puc/puc_pci.c @@ -80,8 +80,7 @@ __FBSDID("$FreeBSD$"); #include static int puc_msi_disable; -TUNABLE_INT("hw.puc.msi_disable", &puc_msi_disable); -SYSCTL_INT(_hw_puc, OID_AUTO, msi_disable, CTLFLAG_RD | CTLFLAG_TUN, +SYSCTL_INT(_hw_puc, OID_AUTO, msi_disable, CTLFLAG_RDTUN, &puc_msi_disable, 0, "Disable use of MSI interrupts by puc(9)"); static const struct puc_cfg * diff --git a/sys/dev/rt/if_rt.c b/sys/dev/rt/if_rt.c index 5f62fec6920df..aaf84f3829689 100644 --- a/sys/dev/rt/if_rt.c +++ b/sys/dev/rt/if_rt.c @@ -140,9 +140,8 @@ static void rt_ifmedia_sts(struct ifnet *, struct ifmediareq *); static SYSCTL_NODE(_hw, OID_AUTO, rt, CTLFLAG_RD, 0, "RT driver parameters"); #ifdef IF_RT_DEBUG static int rt_debug = 0; -SYSCTL_INT(_hw_rt, OID_AUTO, debug, CTLFLAG_RW, &rt_debug, 0, +SYSCTL_INT(_hw_rt, OID_AUTO, debug, CTLFLAG_RWTUN, &rt_debug, 0, "RT debug level"); -TUNABLE_INT("hw.rt.debug", &rt_debug); #endif static int diff --git a/sys/dev/sdhci/sdhci.c b/sys/dev/sdhci/sdhci.c index b8e03bed3409e..18fbf1e83fbb4 100644 --- a/sys/dev/sdhci/sdhci.c +++ b/sys/dev/sdhci/sdhci.c @@ -67,8 +67,7 @@ struct sdhci_softc { static SYSCTL_NODE(_hw, OID_AUTO, sdhci, CTLFLAG_RD, 0, "sdhci driver"); int sdhci_debug = 0; -TUNABLE_INT("hw.sdhci.debug", &sdhci_debug); -SYSCTL_INT(_hw_sdhci, OID_AUTO, debug, CTLFLAG_RW, &sdhci_debug, 0, "Debug level"); +SYSCTL_INT(_hw_sdhci, OID_AUTO, debug, CTLFLAG_RWTUN, &sdhci_debug, 0, "Debug level"); #define RD1(slot, off) SDHCI_READ_1((slot)->bus, (slot), (off)) #define RD2(slot, off) SDHCI_READ_2((slot)->bus, (slot), (off)) diff --git a/sys/dev/sdhci/sdhci_pci.c b/sys/dev/sdhci/sdhci_pci.c index b8d85306d8f4c..9e7e471818885 100644 --- a/sys/dev/sdhci/sdhci_pci.c +++ b/sys/dev/sdhci/sdhci_pci.c @@ -124,8 +124,7 @@ struct sdhci_pci_softc { static SYSCTL_NODE(_hw, OID_AUTO, sdhci_pci, CTLFLAG_RD, 0, "sdhci PCI driver"); int sdhci_pci_debug; -TUNABLE_INT("hw.sdhci_pci.debug", &sdhci_pci_debug); -SYSCTL_INT(_hw_sdhci_pci, OID_AUTO, debug, CTLFLAG_RW, &sdhci_pci_debug, 0, "Debug level"); +SYSCTL_INT(_hw_sdhci_pci, OID_AUTO, debug, CTLFLAG_RWTUN, &sdhci_pci_debug, 0, "Debug level"); static uint8_t sdhci_pci_read_1(device_t dev, struct sdhci_slot *slot, bus_size_t off) diff --git a/sys/dev/si/si.c b/sys/dev/si/si.c index c9d1c83114881..de3eadf583ee7 100644 --- a/sys/dev/si/si.c +++ b/sys/dev/si/si.c @@ -119,8 +119,7 @@ static int si_Nports; static int si_Nmodules; static int si_debug; -SYSCTL_INT(_machdep, OID_AUTO, si_debug, CTLFLAG_RW, &si_debug, 0, ""); -TUNABLE_INT("machdep.si_debug", &si_debug); +SYSCTL_INT(_machdep, OID_AUTO, si_debug, CTLFLAG_RWTUN, &si_debug, 0, ""); static int si_numunits; diff --git a/sys/dev/sio/sio.c b/sys/dev/sio/sio.c index d187a2bab31f7..324a80be0829a 100644 --- a/sys/dev/sio/sio.c +++ b/sys/dev/sio/sio.c @@ -372,7 +372,7 @@ sysctl_machdep_comdefaultrate(SYSCTL_HANDLER_ARGS) return error; } -SYSCTL_PROC(_machdep, OID_AUTO, conspeed, CTLTYPE_INT | CTLFLAG_RW, +SYSCTL_PROC(_machdep, OID_AUTO, conspeed, CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_NOFETCH, 0, 0, sysctl_machdep_comdefaultrate, "I", ""); TUNABLE_INT("machdep.conspeed", __DEVOLATILE(int *, &comdefaultrate)); diff --git a/sys/dev/sis/if_sis.c b/sys/dev/sis/if_sis.c index 09e2242065b0f..4a95af63d8a6b 100644 --- a/sys/dev/sis/if_sis.c +++ b/sys/dev/sis/if_sis.c @@ -2361,7 +2361,6 @@ sis_add_sysctls(struct sis_softc *sc) { struct sysctl_ctx_list *ctx; struct sysctl_oid_list *children; - char tn[32]; int unit; ctx = device_get_sysctl_ctx(sc->sis_dev); @@ -2376,10 +2375,8 @@ sis_add_sysctls(struct sis_softc *sc) * because it will consume extra CPU cycles for short frames. */ sc->sis_manual_pad = 0; - snprintf(tn, sizeof(tn), "dev.sis.%d.manual_pad", unit); - TUNABLE_INT_FETCH(tn, &sc->sis_manual_pad); SYSCTL_ADD_INT(ctx, children, OID_AUTO, "manual_pad", - CTLFLAG_RW, &sc->sis_manual_pad, 0, "Manually pad short frames"); + CTLFLAG_RWTUN, &sc->sis_manual_pad, 0, "Manually pad short frames"); } static device_method_t sis_methods[] = { diff --git a/sys/dev/sound/pcm/channel.c b/sys/dev/sound/pcm/channel.c index 75b02d00e3110..41fbee2e75ae5 100644 --- a/sys/dev/sound/pcm/channel.c +++ b/sys/dev/sound/pcm/channel.c @@ -119,8 +119,7 @@ SYSCTL_PROC(_hw_snd, OID_AUTO, timeout, CTLTYPE_INT | CTLFLAG_RW, #endif static int chn_vpc_autoreset = 1; -TUNABLE_INT("hw.snd.vpc_autoreset", &chn_vpc_autoreset); -SYSCTL_INT(_hw_snd, OID_AUTO, vpc_autoreset, CTLFLAG_RW, +SYSCTL_INT(_hw_snd, OID_AUTO, vpc_autoreset, CTLFLAG_RWTUN, &chn_vpc_autoreset, 0, "automatically reset channels volume to 0db"); static int chn_vol_0db_pcm = SND_VOL_0DB_PCM; diff --git a/sys/dev/sound/pcm/feeder_chain.c b/sys/dev/sound/pcm/feeder_chain.c index 92a1cf539024f..a647269dba6d5 100644 --- a/sys/dev/sound/pcm/feeder_chain.c +++ b/sys/dev/sound/pcm/feeder_chain.c @@ -125,8 +125,7 @@ static uint32_t *feeder_chain_formats[FEEDER_CHAIN_LAST] = { static int feeder_chain_mode = FEEDER_CHAIN_DEFAULT; #if defined(_KERNEL) && defined(SND_DEBUG) && defined(SND_FEEDER_FULL_MULTIFORMAT) -TUNABLE_INT("hw.snd.feeder_chain_mode", &feeder_chain_mode); -SYSCTL_INT(_hw_snd, OID_AUTO, feeder_chain_mode, CTLFLAG_RW, +SYSCTL_INT(_hw_snd, OID_AUTO, feeder_chain_mode, CTLFLAG_RWTUN, &feeder_chain_mode, 0, "feeder chain mode " "(0=lean, 1=16bit, 2=32bit, 3=multiformat, 4=fullmultiformat)"); diff --git a/sys/dev/sound/pcm/feeder_eq.c b/sys/dev/sound/pcm/feeder_eq.c index dee38a386e51e..b4a92c986a606 100644 --- a/sys/dev/sound/pcm/feeder_eq.c +++ b/sys/dev/sound/pcm/feeder_eq.c @@ -97,8 +97,7 @@ static char feeder_eq_presets[] = FEEDER_EQ_PRESETS; SYSCTL_STRING(_hw_snd, OID_AUTO, feeder_eq_presets, CTLFLAG_RD, &feeder_eq_presets, 0, "compile-time eq presets"); -TUNABLE_INT("hw.snd.feeder_eq_exact_rate", &feeder_eq_exact_rate); -SYSCTL_INT(_hw_snd, OID_AUTO, feeder_eq_exact_rate, CTLFLAG_RW, +SYSCTL_INT(_hw_snd, OID_AUTO, feeder_eq_exact_rate, CTLFLAG_RWTUN, &feeder_eq_exact_rate, 0, "force exact rate validation"); #endif diff --git a/sys/dev/sound/pcm/feeder_rate.c b/sys/dev/sound/pcm/feeder_rate.c index cb30dd93149a9..d521fd16f1c1b 100644 --- a/sys/dev/sound/pcm/feeder_rate.c +++ b/sys/dev/sound/pcm/feeder_rate.c @@ -168,8 +168,7 @@ TUNABLE_INT("hw.snd.feeder_rate_max", &feeder_rate_max); TUNABLE_INT("hw.snd.feeder_rate_round", &feeder_rate_round); TUNABLE_INT("hw.snd.feeder_rate_quality", &feeder_rate_quality); -TUNABLE_INT("hw.snd.feeder_rate_polyphase_max", &feeder_rate_polyphase_max); -SYSCTL_INT(_hw_snd, OID_AUTO, feeder_rate_polyphase_max, CTLFLAG_RW, +SYSCTL_INT(_hw_snd, OID_AUTO, feeder_rate_polyphase_max, CTLFLAG_RWTUN, &feeder_rate_polyphase_max, 0, "maximum allowable polyphase entries"); static int diff --git a/sys/dev/sound/pcm/mixer.c b/sys/dev/sound/pcm/mixer.c index 8f9a5fb3a7f31..42ddd11bbbb04 100644 --- a/sys/dev/sound/pcm/mixer.c +++ b/sys/dev/sound/pcm/mixer.c @@ -40,8 +40,7 @@ SND_DECLARE_FILE("$FreeBSD$"); static MALLOC_DEFINE(M_MIXER, "mixer", "mixer"); static int mixer_bypass = 1; -TUNABLE_INT("hw.snd.vpc_mixer_bypass", &mixer_bypass); -SYSCTL_INT(_hw_snd, OID_AUTO, vpc_mixer_bypass, CTLFLAG_RW, +SYSCTL_INT(_hw_snd, OID_AUTO, vpc_mixer_bypass, CTLFLAG_RWTUN, &mixer_bypass, 0, "control channel pcm/rec volume, bypassing real mixer device"); diff --git a/sys/dev/sound/pcm/sound.c b/sys/dev/sound/pcm/sound.c index a7edad5246c70..8b43879470e50 100644 --- a/sys/dev/sound/pcm/sound.c +++ b/sys/dev/sound/pcm/sound.c @@ -52,8 +52,7 @@ int snd_unit = -1; TUNABLE_INT("hw.snd.default_unit", &snd_unit); static int snd_unit_auto = -1; -TUNABLE_INT("hw.snd.default_auto", &snd_unit_auto); -SYSCTL_INT(_hw_snd, OID_AUTO, default_auto, CTLFLAG_RW, +SYSCTL_INT(_hw_snd, OID_AUTO, default_auto, CTLFLAG_RWTUN, &snd_unit_auto, 0, "assign default unit to a newly attached device"); int snd_maxautovchans = 16; diff --git a/sys/dev/sound/usb/uaudio.c b/sys/dev/sound/usb/uaudio.c index 1af8cb2c4ecf4..6c798cc0e0961 100644 --- a/sys/dev/sound/usb/uaudio.c +++ b/sys/dev/sound/usb/uaudio.c @@ -103,17 +103,11 @@ static SYSCTL_NODE(_hw_usb, OID_AUTO, uaudio, CTLFLAG_RW, 0, "USB uaudio"); SYSCTL_INT(_hw_usb_uaudio, OID_AUTO, debug, CTLFLAG_RW, &uaudio_debug, 0, "uaudio debug level"); - -TUNABLE_INT("hw.usb.uaudio.default_rate", &uaudio_default_rate); -SYSCTL_INT(_hw_usb_uaudio, OID_AUTO, default_rate, CTLFLAG_RW, +SYSCTL_INT(_hw_usb_uaudio, OID_AUTO, default_rate, CTLFLAG_RWTUN, &uaudio_default_rate, 0, "uaudio default sample rate"); - -TUNABLE_INT("hw.usb.uaudio.default_bits", &uaudio_default_bits); -SYSCTL_INT(_hw_usb_uaudio, OID_AUTO, default_bits, CTLFLAG_RW, +SYSCTL_INT(_hw_usb_uaudio, OID_AUTO, default_bits, CTLFLAG_RWTUN, &uaudio_default_bits, 0, "uaudio default sample bits"); - -TUNABLE_INT("hw.usb.uaudio.default_channels", &uaudio_default_channels); -SYSCTL_INT(_hw_usb_uaudio, OID_AUTO, default_channels, CTLFLAG_RW, +SYSCTL_INT(_hw_usb_uaudio, OID_AUTO, default_channels, CTLFLAG_RWTUN, &uaudio_default_channels, 0, "uaudio default sample channels"); #endif diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c index 35b3ca8d80781..6a19523ee2ea5 100644 --- a/sys/dev/syscons/syscons.c +++ b/sys/dev/syscons/syscons.c @@ -154,8 +154,7 @@ SYSCTL_INT(_hw_syscons, OID_AUTO, kbd_reboot, CTLFLAG_RW|CTLFLAG_SECURE, &enable SYSCTL_INT(_hw_syscons, OID_AUTO, kbd_debug, CTLFLAG_RW|CTLFLAG_SECURE, &enable_kdbkey, 0, "enable keyboard debug"); #endif -TUNABLE_INT("hw.syscons.sc_no_suspend_vtswitch", &sc_no_suspend_vtswitch); -SYSCTL_INT(_hw_syscons, OID_AUTO, sc_no_suspend_vtswitch, CTLFLAG_RW, +SYSCTL_INT(_hw_syscons, OID_AUTO, sc_no_suspend_vtswitch, CTLFLAG_RWTUN, &sc_no_suspend_vtswitch, 0, "Disable VT switch before suspend."); #if !defined(SC_NO_FONT_LOADING) && defined(SC_DFLT_FONT) #include "font.h" diff --git a/sys/dev/uart/uart_dev_ns8250.c b/sys/dev/uart/uart_dev_ns8250.c index 773cb442c8978..89f78402746b6 100644 --- a/sys/dev/uart/uart_dev_ns8250.c +++ b/sys/dev/uart/uart_dev_ns8250.c @@ -55,9 +55,8 @@ __FBSDID("$FreeBSD$"); #define DEFAULT_RCLK 1843200 static int broken_txfifo = 0; -SYSCTL_INT(_hw, OID_AUTO, broken_txfifo, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw, OID_AUTO, broken_txfifo, CTLFLAG_RWTUN, &broken_txfifo, 0, "UART FIFO has QEMU emulation bug"); -TUNABLE_INT("hw.broken_txfifo", &broken_txfifo); /* * Clear pending interrupts. THRE is cleared by reading IIR. Data diff --git a/sys/dev/usb/controller/dwc_otg.c b/sys/dev/usb/controller/dwc_otg.c index ed88caa42b7e2..b90fbf56022d5 100644 --- a/sys/dev/usb/controller/dwc_otg.c +++ b/sys/dev/usb/controller/dwc_otg.c @@ -112,14 +112,13 @@ static int dwc_otg_use_hsic; static SYSCTL_NODE(_hw_usb, OID_AUTO, dwc_otg, CTLFLAG_RW, 0, "USB DWC OTG"); -SYSCTL_INT(_hw_usb_dwc_otg, OID_AUTO, use_hsic, CTLFLAG_RD | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_dwc_otg, OID_AUTO, use_hsic, CTLFLAG_RDTUN, &dwc_otg_use_hsic, 0, "DWC OTG uses HSIC interface"); -TUNABLE_INT("hw.usb.dwc_otg.use_hsic", &dwc_otg_use_hsic); #ifdef USB_DEBUG static int dwc_otg_debug; -SYSCTL_INT(_hw_usb_dwc_otg, OID_AUTO, debug, CTLFLAG_RW, +SYSCTL_INT(_hw_usb_dwc_otg, OID_AUTO, debug, CTLFLAG_RWTUN, &dwc_otg_debug, 0, "DWC OTG debug level"); #endif diff --git a/sys/dev/usb/controller/ehci.c b/sys/dev/usb/controller/ehci.c index ad3a3fc55d2b1..7d0d5ab6d2099 100644 --- a/sys/dev/usb/controller/ehci.c +++ b/sys/dev/usb/controller/ehci.c @@ -98,19 +98,14 @@ static int ehciiaadbug = 0; static int ehcilostintrbug = 0; static SYSCTL_NODE(_hw_usb, OID_AUTO, ehci, CTLFLAG_RW, 0, "USB ehci"); -SYSCTL_INT(_hw_usb_ehci, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_ehci, OID_AUTO, debug, CTLFLAG_RWTUN, &ehcidebug, 0, "Debug level"); -TUNABLE_INT("hw.usb.ehci.debug", &ehcidebug); -SYSCTL_INT(_hw_usb_ehci, OID_AUTO, no_hs, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_ehci, OID_AUTO, no_hs, CTLFLAG_RWTUN, &ehcinohighspeed, 0, "Disable High Speed USB"); -TUNABLE_INT("hw.usb.ehci.no_hs", &ehcinohighspeed); -SYSCTL_INT(_hw_usb_ehci, OID_AUTO, iaadbug, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_ehci, OID_AUTO, iaadbug, CTLFLAG_RWTUN, &ehciiaadbug, 0, "Enable doorbell bug workaround"); -TUNABLE_INT("hw.usb.ehci.iaadbug", &ehciiaadbug); -SYSCTL_INT(_hw_usb_ehci, OID_AUTO, lostintrbug, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_ehci, OID_AUTO, lostintrbug, CTLFLAG_RWTUN, &ehcilostintrbug, 0, "Enable lost interrupt bug workaround"); -TUNABLE_INT("hw.usb.ehci.lostintrbug", &ehcilostintrbug); - static void ehci_dump_regs(ehci_softc_t *sc); static void ehci_dump_sqh(ehci_softc_t *sc, ehci_qh_t *sqh); diff --git a/sys/dev/usb/controller/ohci.c b/sys/dev/usb/controller/ohci.c index 86fca1eeaa3b6..206c75314d0c5 100644 --- a/sys/dev/usb/controller/ohci.c +++ b/sys/dev/usb/controller/ohci.c @@ -84,9 +84,8 @@ static int ohcidebug = 0; static SYSCTL_NODE(_hw_usb, OID_AUTO, ohci, CTLFLAG_RW, 0, "USB ohci"); -SYSCTL_INT(_hw_usb_ohci, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_ohci, OID_AUTO, debug, CTLFLAG_RWTUN, &ohcidebug, 0, "ohci debug level"); -TUNABLE_INT("hw.usb.ohci.debug", &ohcidebug); static void ohci_dumpregs(ohci_softc_t *); static void ohci_dump_tds(ohci_td_t *); diff --git a/sys/dev/usb/controller/uhci.c b/sys/dev/usb/controller/uhci.c index 134a4472363ac..00776154447c0 100644 --- a/sys/dev/usb/controller/uhci.c +++ b/sys/dev/usb/controller/uhci.c @@ -89,12 +89,10 @@ static int uhcidebug = 0; static int uhcinoloop = 0; static SYSCTL_NODE(_hw_usb, OID_AUTO, uhci, CTLFLAG_RW, 0, "USB uhci"); -SYSCTL_INT(_hw_usb_uhci, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_uhci, OID_AUTO, debug, CTLFLAG_RWTUN, &uhcidebug, 0, "uhci debug level"); -TUNABLE_INT("hw.usb.uhci.debug", &uhcidebug); -SYSCTL_INT(_hw_usb_uhci, OID_AUTO, loop, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_uhci, OID_AUTO, loop, CTLFLAG_RWTUN, &uhcinoloop, 0, "uhci noloop"); -TUNABLE_INT("hw.usb.uhci.loop", &uhcinoloop); static void uhci_dumpregs(uhci_softc_t *sc); static void uhci_dump_tds(uhci_td_t *td); diff --git a/sys/dev/usb/controller/usb_controller.c b/sys/dev/usb/controller/usb_controller.c index c2cafecf61d40..dd75ba7a5aa24 100644 --- a/sys/dev/usb/controller/usb_controller.c +++ b/sys/dev/usb/controller/usb_controller.c @@ -90,19 +90,16 @@ SYSCTL_INT(_hw_usb_ctrl, OID_AUTO, debug, CTLFLAG_RW, &usb_ctrl_debug, 0, #if USB_HAVE_ROOT_MOUNT_HOLD static int usb_no_boot_wait = 0; -TUNABLE_INT("hw.usb.no_boot_wait", &usb_no_boot_wait); -SYSCTL_INT(_hw_usb, OID_AUTO, no_boot_wait, CTLFLAG_RD|CTLFLAG_TUN, &usb_no_boot_wait, 0, +SYSCTL_INT(_hw_usb, OID_AUTO, no_boot_wait, CTLFLAG_RDTUN, &usb_no_boot_wait, 0, "No USB device enumerate waiting at boot."); #endif static int usb_no_suspend_wait = 0; -TUNABLE_INT("hw.usb.no_suspend_wait", &usb_no_suspend_wait); -SYSCTL_INT(_hw_usb, OID_AUTO, no_suspend_wait, CTLFLAG_RW|CTLFLAG_TUN, +SYSCTL_INT(_hw_usb, OID_AUTO, no_suspend_wait, CTLFLAG_RWTUN, &usb_no_suspend_wait, 0, "No USB device waiting at system suspend."); static int usb_no_shutdown_wait = 0; -TUNABLE_INT("hw.usb.no_shutdown_wait", &usb_no_shutdown_wait); -SYSCTL_INT(_hw_usb, OID_AUTO, no_shutdown_wait, CTLFLAG_RW|CTLFLAG_TUN, +SYSCTL_INT(_hw_usb, OID_AUTO, no_shutdown_wait, CTLFLAG_RWTUN, &usb_no_shutdown_wait, 0, "No USB device waiting at system shutdown."); static devclass_t usb_devclass; diff --git a/sys/dev/usb/controller/xhci.c b/sys/dev/usb/controller/xhci.c index 4570ad2aab840..cdfa7d4062883 100644 --- a/sys/dev/usb/controller/xhci.c +++ b/sys/dev/usb/controller/xhci.c @@ -90,24 +90,20 @@ static SYSCTL_NODE(_hw_usb, OID_AUTO, xhci, CTLFLAG_RW, 0, "USB XHCI"); static int xhcistreams; -SYSCTL_INT(_hw_usb_xhci, OID_AUTO, streams, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_xhci, OID_AUTO, streams, CTLFLAG_RWTUN, &xhcistreams, 0, "Set to enable streams mode support"); -TUNABLE_INT("hw.usb.xhci.streams", &xhcistreams); #ifdef USB_DEBUG static int xhcidebug; static int xhciroute; static int xhcipolling; -SYSCTL_INT(_hw_usb_xhci, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_xhci, OID_AUTO, debug, CTLFLAG_RWTUN, &xhcidebug, 0, "Debug level"); -TUNABLE_INT("hw.usb.xhci.debug", &xhcidebug); -SYSCTL_INT(_hw_usb_xhci, OID_AUTO, xhci_port_route, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_xhci, OID_AUTO, xhci_port_route, CTLFLAG_RWTUN, &xhciroute, 0, "Routing bitmap for switching EHCI ports to XHCI controller"); -TUNABLE_INT("hw.usb.xhci.xhci_port_route", &xhciroute); -SYSCTL_INT(_hw_usb_xhci, OID_AUTO, use_polling, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_xhci, OID_AUTO, use_polling, CTLFLAG_RWTUN, &xhcipolling, 0, "Set to enable software interrupt polling for XHCI controller"); -TUNABLE_INT("hw.usb.xhci.use_polling", &xhcipolling); #else #define xhciroute 0 #endif diff --git a/sys/dev/usb/input/ukbd.c b/sys/dev/usb/input/ukbd.c index ede27f726cabd..0e56d9643a0f5 100644 --- a/sys/dev/usb/input/ukbd.c +++ b/sys/dev/usb/input/ukbd.c @@ -95,15 +95,12 @@ static int ukbd_no_leds = 0; static int ukbd_pollrate = 0; static SYSCTL_NODE(_hw_usb, OID_AUTO, ukbd, CTLFLAG_RW, 0, "USB keyboard"); -SYSCTL_INT(_hw_usb_ukbd, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_ukbd, OID_AUTO, debug, CTLFLAG_RWTUN, &ukbd_debug, 0, "Debug level"); -TUNABLE_INT("hw.usb.ukbd.debug", &ukbd_debug); -SYSCTL_INT(_hw_usb_ukbd, OID_AUTO, no_leds, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_ukbd, OID_AUTO, no_leds, CTLFLAG_RWTUN, &ukbd_no_leds, 0, "Disables setting of keyboard leds"); -TUNABLE_INT("hw.usb.ukbd.no_leds", &ukbd_no_leds); -SYSCTL_INT(_hw_usb_ukbd, OID_AUTO, pollrate, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_ukbd, OID_AUTO, pollrate, CTLFLAG_RWTUN, &ukbd_pollrate, 0, "Force this polling rate, 1-1000Hz"); -TUNABLE_INT("hw.usb.ukbd.pollrate", &ukbd_pollrate); #endif #define UKBD_EMULATE_ATSCANCODE 1 diff --git a/sys/dev/usb/serial/uftdi.c b/sys/dev/usb/serial/uftdi.c index 25da9b892f408..74e11dda1771a 100644 --- a/sys/dev/usb/serial/uftdi.c +++ b/sys/dev/usb/serial/uftdi.c @@ -932,7 +932,6 @@ static const struct jtag_by_name { * creation of tty devices for jtag interfaces. Enabled by default. */ static int skip_jtag_interfaces = 1; -TUNABLE_INT("hw.usb.uftdi.skip_jtag_interfaces", &skip_jtag_interfaces); SYSCTL_INT(_hw_usb_uftdi, OID_AUTO, skip_jtag_interfaces, CTLFLAG_RWTUN, &skip_jtag_interfaces, 1, "Skip creating tty devices for jtag interfaces"); diff --git a/sys/dev/usb/serial/usb_serial.c b/sys/dev/usb/serial/usb_serial.c index 2945415bbe99a..53c0594b41a72 100644 --- a/sys/dev/usb/serial/usb_serial.c +++ b/sys/dev/usb/serial/usb_serial.c @@ -119,14 +119,11 @@ static int ucom_cons_subunit = 0; static int ucom_cons_baud = 9600; static struct ucom_softc *ucom_cons_softc = NULL; -TUNABLE_INT("hw.usb.ucom.cons_unit", &ucom_cons_unit); -SYSCTL_INT(_hw_usb_ucom, OID_AUTO, cons_unit, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_ucom, OID_AUTO, cons_unit, CTLFLAG_RWTUN, &ucom_cons_unit, 0, "console unit number"); -TUNABLE_INT("hw.usb.ucom.cons_subunit", &ucom_cons_subunit); -SYSCTL_INT(_hw_usb_ucom, OID_AUTO, cons_subunit, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_ucom, OID_AUTO, cons_subunit, CTLFLAG_RWTUN, &ucom_cons_subunit, 0, "console subunit number"); -TUNABLE_INT("hw.usb.ucom.cons_baud", &ucom_cons_baud); -SYSCTL_INT(_hw_usb_ucom, OID_AUTO, cons_baud, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_ucom, OID_AUTO, cons_baud, CTLFLAG_RWTUN, &ucom_cons_baud, 0, "console baud rate"); static usb_proc_callback_t ucom_cfg_start_transfers; diff --git a/sys/dev/usb/storage/umass.c b/sys/dev/usb/storage/umass.c index f3a51b313ff4a..e169abbfb53e1 100644 --- a/sys/dev/usb/storage/umass.c +++ b/sys/dev/usb/storage/umass.c @@ -167,12 +167,10 @@ static int umass_debug; static int umass_throttle; static SYSCTL_NODE(_hw_usb, OID_AUTO, umass, CTLFLAG_RW, 0, "USB umass"); -SYSCTL_INT(_hw_usb_umass, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_umass, OID_AUTO, debug, CTLFLAG_RWTUN, &umass_debug, 0, "umass debug level"); -TUNABLE_INT("hw.usb.umass.debug", &umass_debug); -SYSCTL_INT(_hw_usb_umass, OID_AUTO, throttle, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_umass, OID_AUTO, throttle, CTLFLAG_RWTUN, &umass_throttle, 0, "Forced delay between commands in milliseconds"); -TUNABLE_INT("hw.usb.umass.throttle", &umass_throttle); #else #define DIF(...) do { } while (0) #define DPRINTF(...) do { } while (0) diff --git a/sys/dev/usb/usb_debug.c b/sys/dev/usb/usb_debug.c index 338298835b806..9c7fa6e1d062f 100644 --- a/sys/dev/usb/usb_debug.c +++ b/sys/dev/usb/usb_debug.c @@ -67,9 +67,8 @@ int usb_debug = 0; SYSCTL_NODE(_hw, OID_AUTO, usb, CTLFLAG_RW, 0, "USB debugging"); -SYSCTL_INT(_hw_usb, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb, OID_AUTO, debug, CTLFLAG_RWTUN, &usb_debug, 0, "Debug level"); -TUNABLE_INT("hw.usb.debug", &usb_debug); #ifdef USB_DEBUG /* @@ -78,44 +77,34 @@ TUNABLE_INT("hw.usb.debug", &usb_debug); static SYSCTL_NODE(_hw_usb, OID_AUTO, timings, CTLFLAG_RW, 0, "Timings"); static int usb_timings_sysctl_handler(SYSCTL_HANDLER_ARGS); -TUNABLE_INT("hw.usb.timings.port_reset_delay", (int *)&usb_port_reset_delay); -SYSCTL_PROC(_hw_usb_timings, OID_AUTO, port_reset_delay, CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_PROC(_hw_usb_timings, OID_AUTO, port_reset_delay, CTLTYPE_UINT | CTLFLAG_RWTUN, &usb_port_reset_delay, sizeof(usb_port_reset_delay), usb_timings_sysctl_handler, "IU", "Port Reset Delay"); -TUNABLE_INT("hw.usb.timings.port_root_reset_delay", (int *)&usb_port_root_reset_delay); -SYSCTL_PROC(_hw_usb_timings, OID_AUTO, port_root_reset_delay, CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_PROC(_hw_usb_timings, OID_AUTO, port_root_reset_delay, CTLTYPE_UINT | CTLFLAG_RWTUN, &usb_port_root_reset_delay, sizeof(usb_port_root_reset_delay), usb_timings_sysctl_handler, "IU", "Root Port Reset Delay"); -TUNABLE_INT("hw.usb.timings.port_reset_recovery", (int *)&usb_port_reset_recovery); -SYSCTL_PROC(_hw_usb_timings, OID_AUTO, port_reset_recovery, CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_PROC(_hw_usb_timings, OID_AUTO, port_reset_recovery, CTLTYPE_UINT | CTLFLAG_RWTUN, &usb_port_reset_recovery, sizeof(usb_port_reset_recovery), usb_timings_sysctl_handler, "IU", "Port Reset Recovery"); -TUNABLE_INT("hw.usb.timings.port_powerup_delay", (int *)&usb_port_powerup_delay); -SYSCTL_PROC(_hw_usb_timings, OID_AUTO, port_powerup_delay, CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_PROC(_hw_usb_timings, OID_AUTO, port_powerup_delay, CTLTYPE_UINT | CTLFLAG_RWTUN, &usb_port_powerup_delay, sizeof(usb_port_powerup_delay), usb_timings_sysctl_handler, "IU", "Port PowerUp Delay"); -TUNABLE_INT("hw.usb.timings.port_resume_delay", (int *)&usb_port_resume_delay); -SYSCTL_PROC(_hw_usb_timings, OID_AUTO, port_resume_delay, CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_PROC(_hw_usb_timings, OID_AUTO, port_resume_delay, CTLTYPE_UINT | CTLFLAG_RWTUN, &usb_port_resume_delay, sizeof(usb_port_resume_delay), usb_timings_sysctl_handler, "IU", "Port Resume Delay"); -TUNABLE_INT("hw.usb.timings.set_address_settle", (int *)&usb_set_address_settle); -SYSCTL_PROC(_hw_usb_timings, OID_AUTO, set_address_settle, CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_PROC(_hw_usb_timings, OID_AUTO, set_address_settle, CTLTYPE_UINT | CTLFLAG_RWTUN, &usb_set_address_settle, sizeof(usb_set_address_settle), usb_timings_sysctl_handler, "IU", "Set Address Settle"); -TUNABLE_INT("hw.usb.timings.resume_delay", (int *)&usb_resume_delay); -SYSCTL_PROC(_hw_usb_timings, OID_AUTO, resume_delay, CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_PROC(_hw_usb_timings, OID_AUTO, resume_delay, CTLTYPE_UINT | CTLFLAG_RWTUN, &usb_resume_delay, sizeof(usb_resume_delay), usb_timings_sysctl_handler, "IU", "Resume Delay"); -TUNABLE_INT("hw.usb.timings.resume_wait", (int *)&usb_resume_wait); -SYSCTL_PROC(_hw_usb_timings, OID_AUTO, resume_wait, CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_PROC(_hw_usb_timings, OID_AUTO, resume_wait, CTLTYPE_UINT | CTLFLAG_RWTUN, &usb_resume_wait, sizeof(usb_resume_wait), usb_timings_sysctl_handler, "IU", "Resume Wait"); -TUNABLE_INT("hw.usb.timings.resume_recovery", (int *)&usb_resume_recovery); -SYSCTL_PROC(_hw_usb_timings, OID_AUTO, resume_recovery, CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_PROC(_hw_usb_timings, OID_AUTO, resume_recovery, CTLTYPE_UINT | CTLFLAG_RWTUN, &usb_resume_recovery, sizeof(usb_resume_recovery), usb_timings_sysctl_handler, "IU", "Resume Recovery"); -TUNABLE_INT("hw.usb.timings.extra_power_up_time", (int *)&usb_extra_power_up_time); -SYSCTL_PROC(_hw_usb_timings, OID_AUTO, extra_power_up_time, CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_PROC(_hw_usb_timings, OID_AUTO, extra_power_up_time, CTLTYPE_UINT | CTLFLAG_RWTUN, &usb_extra_power_up_time, sizeof(usb_extra_power_up_time), usb_timings_sysctl_handler, "IU", "Extra PowerUp Time"); #endif diff --git a/sys/dev/usb/usb_dev.c b/sys/dev/usb/usb_dev.c index 6ad02a7d035dd..396067309ac4d 100644 --- a/sys/dev/usb/usb_dev.c +++ b/sys/dev/usb/usb_dev.c @@ -86,9 +86,8 @@ static int usb_fifo_debug = 0; static SYSCTL_NODE(_hw_usb, OID_AUTO, dev, CTLFLAG_RW, 0, "USB device"); -SYSCTL_INT(_hw_usb_dev, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_dev, OID_AUTO, debug, CTLFLAG_RWTUN, &usb_fifo_debug, 0, "Debug Level"); -TUNABLE_INT("hw.usb.dev.debug", &usb_fifo_debug); #endif #if ((__FreeBSD_version >= 700001) || (__FreeBSD_version == 0) || \ diff --git a/sys/dev/usb/usb_device.c b/sys/dev/usb/usb_device.c index 7acb5cbc4f7d0..1acfd1eee95cb 100644 --- a/sys/dev/usb/usb_device.c +++ b/sys/dev/usb/usb_device.c @@ -118,8 +118,7 @@ int usb_template = USB_TEMPLATE; int usb_template; #endif -TUNABLE_INT("hw.usb.usb_template", &usb_template); -SYSCTL_INT(_hw_usb, OID_AUTO, template, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb, OID_AUTO, template, CTLFLAG_RWTUN, &usb_template, 0, "Selected USB device side template"); /* English is default language */ @@ -127,12 +126,10 @@ SYSCTL_INT(_hw_usb, OID_AUTO, template, CTLFLAG_RW | CTLFLAG_TUN, static int usb_lang_id = 0x0009; static int usb_lang_mask = 0x00FF; -TUNABLE_INT("hw.usb.usb_lang_id", &usb_lang_id); -SYSCTL_INT(_hw_usb, OID_AUTO, usb_lang_id, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb, OID_AUTO, usb_lang_id, CTLFLAG_RWTUN, &usb_lang_id, 0, "Preferred USB language ID"); -TUNABLE_INT("hw.usb.usb_lang_mask", &usb_lang_mask); -SYSCTL_INT(_hw_usb, OID_AUTO, usb_lang_mask, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb, OID_AUTO, usb_lang_mask, CTLFLAG_RWTUN, &usb_lang_mask, 0, "Preferred USB language mask"); static const char* statestr[USB_STATE_MAX] = { diff --git a/sys/dev/usb/usb_generic.c b/sys/dev/usb/usb_generic.c index 4ebd557a51821..96dfe8bceb872 100644 --- a/sys/dev/usb/usb_generic.c +++ b/sys/dev/usb/usb_generic.c @@ -131,9 +131,8 @@ struct usb_fifo_methods usb_ugen_methods = { static int ugen_debug = 0; static SYSCTL_NODE(_hw_usb, OID_AUTO, ugen, CTLFLAG_RW, 0, "USB generic"); -SYSCTL_INT(_hw_usb_ugen, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, &ugen_debug, +SYSCTL_INT(_hw_usb_ugen, OID_AUTO, debug, CTLFLAG_RWTUN, &ugen_debug, 0, "Debug level"); -TUNABLE_INT("hw.usb.ugen.debug", &ugen_debug); #endif diff --git a/sys/dev/usb/usb_hub.c b/sys/dev/usb/usb_hub.c index e9c9a42c39142..8e0d557a9c5f7 100644 --- a/sys/dev/usb/usb_hub.c +++ b/sys/dev/usb/usb_hub.c @@ -86,9 +86,8 @@ enum { static int uhub_debug = 0; static SYSCTL_NODE(_hw_usb, OID_AUTO, uhub, CTLFLAG_RW, 0, "USB HUB"); -SYSCTL_INT(_hw_usb_uhub, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, &uhub_debug, 0, +SYSCTL_INT(_hw_usb_uhub, OID_AUTO, debug, CTLFLAG_RWTUN, &uhub_debug, 0, "Debug level"); -TUNABLE_INT("hw.usb.uhub.debug", &uhub_debug); #endif #if USB_HAVE_POWERD diff --git a/sys/dev/usb/usb_process.c b/sys/dev/usb/usb_process.c index e70166ca4f2c4..683c700d2472d 100644 --- a/sys/dev/usb/usb_process.c +++ b/sys/dev/usb/usb_process.c @@ -90,9 +90,8 @@ static int usb_pcount; static int usb_proc_debug; static SYSCTL_NODE(_hw_usb, OID_AUTO, proc, CTLFLAG_RW, 0, "USB process"); -SYSCTL_INT(_hw_usb_proc, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, &usb_proc_debug, 0, +SYSCTL_INT(_hw_usb_proc, OID_AUTO, debug, CTLFLAG_RWTUN, &usb_proc_debug, 0, "Debug level"); -TUNABLE_INT("hw.usb.proc.debug", &usb_proc_debug); #endif /*------------------------------------------------------------------------* diff --git a/sys/dev/usb/wlan/if_uath.c b/sys/dev/usb/wlan/if_uath.c index 9db1e04ce3de5..b8e886388f72f 100644 --- a/sys/dev/usb/wlan/if_uath.c +++ b/sys/dev/usb/wlan/if_uath.c @@ -115,18 +115,16 @@ __FBSDID("$FreeBSD$"); static SYSCTL_NODE(_hw_usb, OID_AUTO, uath, CTLFLAG_RW, 0, "USB Atheros"); static int uath_countrycode = CTRY_DEFAULT; /* country code */ -SYSCTL_INT(_hw_usb_uath, OID_AUTO, countrycode, CTLFLAG_RW | CTLFLAG_TUN, &uath_countrycode, +SYSCTL_INT(_hw_usb_uath, OID_AUTO, countrycode, CTLFLAG_RWTUN, &uath_countrycode, 0, "country code"); -TUNABLE_INT("hw.usb.uath.countrycode", &uath_countrycode); static int uath_regdomain = 0; /* regulatory domain */ SYSCTL_INT(_hw_usb_uath, OID_AUTO, regdomain, CTLFLAG_RD, &uath_regdomain, 0, "regulatory domain"); #ifdef UATH_DEBUG int uath_debug = 0; -SYSCTL_INT(_hw_usb_uath, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, &uath_debug, 0, +SYSCTL_INT(_hw_usb_uath, OID_AUTO, debug, CTLFLAG_RWTUN, &uath_debug, 0, "uath debug level"); -TUNABLE_INT("hw.usb.uath.debug", &uath_debug); enum { UATH_DEBUG_XMIT = 0x00000001, /* basic xmit operation */ UATH_DEBUG_XMIT_DUMP = 0x00000002, /* xmit dump */ diff --git a/sys/dev/usb/wlan/if_upgt.c b/sys/dev/usb/wlan/if_upgt.c index a860a2b6910bd..51f4ed98c3be7 100644 --- a/sys/dev/usb/wlan/if_upgt.c +++ b/sys/dev/usb/wlan/if_upgt.c @@ -76,9 +76,8 @@ static SYSCTL_NODE(_hw, OID_AUTO, upgt, CTLFLAG_RD, 0, #ifdef UPGT_DEBUG int upgt_debug = 0; -SYSCTL_INT(_hw_upgt, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, &upgt_debug, +SYSCTL_INT(_hw_upgt, OID_AUTO, debug, CTLFLAG_RWTUN, &upgt_debug, 0, "control debugging printfs"); -TUNABLE_INT("hw.upgt.debug", &upgt_debug); enum { UPGT_DEBUG_XMIT = 0x00000001, /* basic xmit operation */ UPGT_DEBUG_RECV = 0x00000002, /* basic recv operation */ diff --git a/sys/dev/usb/wlan/if_urtw.c b/sys/dev/usb/wlan/if_urtw.c index a5516339fb41b..d2837324b63f3 100644 --- a/sys/dev/usb/wlan/if_urtw.c +++ b/sys/dev/usb/wlan/if_urtw.c @@ -65,9 +65,8 @@ __FBSDID("$FreeBSD$"); static SYSCTL_NODE(_hw_usb, OID_AUTO, urtw, CTLFLAG_RW, 0, "USB Realtek 8187L"); #ifdef URTW_DEBUG int urtw_debug = 0; -SYSCTL_INT(_hw_usb_urtw, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, &urtw_debug, 0, +SYSCTL_INT(_hw_usb_urtw, OID_AUTO, debug, CTLFLAG_RWTUN, &urtw_debug, 0, "control debugging printfs"); -TUNABLE_INT("hw.usb.urtw.debug", &urtw_debug); enum { URTW_DEBUG_XMIT = 0x00000001, /* basic xmit operation */ URTW_DEBUG_RECV = 0x00000002, /* basic recv operation */ @@ -90,9 +89,8 @@ enum { } while (0) #endif static int urtw_preamble_mode = URTW_PREAMBLE_MODE_LONG; -SYSCTL_INT(_hw_usb_urtw, OID_AUTO, preamble_mode, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_usb_urtw, OID_AUTO, preamble_mode, CTLFLAG_RWTUN, &urtw_preamble_mode, 0, "set the preable mode (long or short)"); -TUNABLE_INT("hw.usb.urtw.preamble_mode", &urtw_preamble_mode); /* recognized device vendors/products */ #define urtw_lookup(v, p) \ diff --git a/sys/dev/vt/vt.h b/sys/dev/vt/vt.h index b216499b735f1..cd6aa5ba4db2a 100644 --- a/sys/dev/vt/vt.h +++ b/sys/dev/vt/vt.h @@ -84,9 +84,8 @@ #define VT_SYSCTL_INT(_name, _default, _descr) \ static int vt_##_name = _default; \ -SYSCTL_INT(_kern_vt, OID_AUTO, _name, CTLFLAG_RW, &vt_##_name, _default,\ - _descr); \ -TUNABLE_INT("kern.vt." #_name, &vt_##_name); +SYSCTL_INT(_kern_vt, OID_AUTO, _name, CTLFLAG_RWTUN, &vt_##_name, _default,\ + _descr); struct vt_driver; diff --git a/sys/dev/wpi/if_wpi.c b/sys/dev/wpi/if_wpi.c index efbcb298e9619..6e4428bef5163 100644 --- a/sys/dev/wpi/if_wpi.c +++ b/sys/dev/wpi/if_wpi.c @@ -130,9 +130,8 @@ enum { WPI_DEBUG_ANY = 0xffffffff }; -static int wpi_debug = 0; -SYSCTL_INT(_debug, OID_AUTO, wpi, CTLFLAG_RW, &wpi_debug, 0, "wpi debug level"); -TUNABLE_INT("debug.wpi", &wpi_debug); +static int wpi_debug; +SYSCTL_INT(_debug, OID_AUTO, wpi, CTLFLAG_RWTUN, &wpi_debug, 0, "wpi debug level"); #else #define DPRINTF(x) diff --git a/sys/gdb/gdb_cons.c b/sys/gdb/gdb_cons.c index ff746658601f0..47f453fc3eea2 100644 --- a/sys/gdb/gdb_cons.c +++ b/sys/gdb/gdb_cons.c @@ -58,9 +58,8 @@ struct gdbcons { static struct gdbcons state = { -1 }; static int gdbcons_enable = 0; -SYSCTL_INT(_debug, OID_AUTO, gdbcons, CTLFLAG_RW, &gdbcons_enable, - 0, "copy console messages to gdb"); -TUNABLE_INT("debug.gdbcons", &gdbcons_enable); +SYSCTL_INT(_debug, OID_AUTO, gdbcons, CTLFLAG_RWTUN, &gdbcons_enable, + 0, "copy console messages to GDB"); static void gdb_cnprobe(struct consdev *cp) diff --git a/sys/geom/concat/g_concat.c b/sys/geom/concat/g_concat.c index 2efc1b53fd616..4627ff9fa2ca7 100644 --- a/sys/geom/concat/g_concat.c +++ b/sys/geom/concat/g_concat.c @@ -48,8 +48,7 @@ SYSCTL_DECL(_kern_geom); static SYSCTL_NODE(_kern_geom, OID_AUTO, concat, CTLFLAG_RW, 0, "GEOM_CONCAT stuff"); static u_int g_concat_debug = 0; -TUNABLE_INT("kern.geom.concat.debug", &g_concat_debug); -SYSCTL_UINT(_kern_geom_concat, OID_AUTO, debug, CTLFLAG_RW, &g_concat_debug, 0, +SYSCTL_UINT(_kern_geom_concat, OID_AUTO, debug, CTLFLAG_RWTUN, &g_concat_debug, 0, "Debug level"); static int g_concat_destroy(struct g_concat_softc *sc, boolean_t force); diff --git a/sys/geom/eli/g_eli.c b/sys/geom/eli/g_eli.c index d1f3cd25a0fb4..2c4dc2c41ae50 100644 --- a/sys/geom/eli/g_eli.c +++ b/sys/geom/eli/g_eli.c @@ -63,29 +63,23 @@ static int g_eli_version = G_ELI_VERSION; SYSCTL_INT(_kern_geom_eli, OID_AUTO, version, CTLFLAG_RD, &g_eli_version, 0, "GELI version"); int g_eli_debug = 0; -TUNABLE_INT("kern.geom.eli.debug", &g_eli_debug); -SYSCTL_INT(_kern_geom_eli, OID_AUTO, debug, CTLFLAG_RW, &g_eli_debug, 0, +SYSCTL_INT(_kern_geom_eli, OID_AUTO, debug, CTLFLAG_RWTUN, &g_eli_debug, 0, "Debug level"); static u_int g_eli_tries = 3; -TUNABLE_INT("kern.geom.eli.tries", &g_eli_tries); -SYSCTL_UINT(_kern_geom_eli, OID_AUTO, tries, CTLFLAG_RW, &g_eli_tries, 0, +SYSCTL_UINT(_kern_geom_eli, OID_AUTO, tries, CTLFLAG_RWTUN, &g_eli_tries, 0, "Number of tries for entering the passphrase"); static u_int g_eli_visible_passphrase = GETS_NOECHO; -TUNABLE_INT("kern.geom.eli.visible_passphrase", &g_eli_visible_passphrase); -SYSCTL_UINT(_kern_geom_eli, OID_AUTO, visible_passphrase, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_eli, OID_AUTO, visible_passphrase, CTLFLAG_RWTUN, &g_eli_visible_passphrase, 0, "Visibility of passphrase prompt (0 = invisible, 1 = visible, 2 = asterisk)"); u_int g_eli_overwrites = G_ELI_OVERWRITES; -TUNABLE_INT("kern.geom.eli.overwrites", &g_eli_overwrites); -SYSCTL_UINT(_kern_geom_eli, OID_AUTO, overwrites, CTLFLAG_RW, &g_eli_overwrites, +SYSCTL_UINT(_kern_geom_eli, OID_AUTO, overwrites, CTLFLAG_RWTUN, &g_eli_overwrites, 0, "Number of times on-disk keys should be overwritten when destroying them"); static u_int g_eli_threads = 0; -TUNABLE_INT("kern.geom.eli.threads", &g_eli_threads); -SYSCTL_UINT(_kern_geom_eli, OID_AUTO, threads, CTLFLAG_RW, &g_eli_threads, 0, +SYSCTL_UINT(_kern_geom_eli, OID_AUTO, threads, CTLFLAG_RWTUN, &g_eli_threads, 0, "Number of threads doing crypto work"); u_int g_eli_batch = 0; -TUNABLE_INT("kern.geom.eli.batch", &g_eli_batch); -SYSCTL_UINT(_kern_geom_eli, OID_AUTO, batch, CTLFLAG_RW, &g_eli_batch, 0, +SYSCTL_UINT(_kern_geom_eli, OID_AUTO, batch, CTLFLAG_RWTUN, &g_eli_batch, 0, "Use crypto operations batching"); static eventhandler_tag g_eli_pre_sync = NULL; diff --git a/sys/geom/eli/g_eli_key_cache.c b/sys/geom/eli/g_eli_key_cache.c index 9530495050ec5..cb867166cee39 100644 --- a/sys/geom/eli/g_eli_key_cache.c +++ b/sys/geom/eli/g_eli_key_cache.c @@ -47,7 +47,6 @@ SYSCTL_DECL(_kern_geom_eli); * provider with 512 bytes sectors and will take around 1MB of memory. */ static u_int g_eli_key_cache_limit = 8192; -TUNABLE_INT("kern.geom.eli.key_cache_limit", &g_eli_key_cache_limit); SYSCTL_UINT(_kern_geom_eli, OID_AUTO, key_cache_limit, CTLFLAG_RDTUN, &g_eli_key_cache_limit, 0, "Maximum number of encryption keys to cache"); static uint64_t g_eli_key_cache_hits; diff --git a/sys/geom/gate/g_gate.c b/sys/geom/gate/g_gate.c index eed4abbc54a23..ae0d7b094a5f2 100644 --- a/sys/geom/gate/g_gate.c +++ b/sys/geom/gate/g_gate.c @@ -62,11 +62,9 @@ SYSCTL_DECL(_kern_geom); static SYSCTL_NODE(_kern_geom, OID_AUTO, gate, CTLFLAG_RW, 0, "GEOM_GATE configuration"); static int g_gate_debug = 0; -TUNABLE_INT("kern.geom.gate.debug", &g_gate_debug); -SYSCTL_INT(_kern_geom_gate, OID_AUTO, debug, CTLFLAG_RW, &g_gate_debug, 0, +SYSCTL_INT(_kern_geom_gate, OID_AUTO, debug, CTLFLAG_RWTUN, &g_gate_debug, 0, "Debug level"); static u_int g_gate_maxunits = 256; -TUNABLE_INT("kern.geom.gate.maxunits", &g_gate_maxunits); SYSCTL_UINT(_kern_geom_gate, OID_AUTO, maxunits, CTLFLAG_RDTUN, &g_gate_maxunits, 0, "Maximum number of ggate devices"); diff --git a/sys/geom/geom_disk.c b/sys/geom/geom_disk.c index eb72597dbe345..5cfdaf0af3698 100644 --- a/sys/geom/geom_disk.c +++ b/sys/geom/geom_disk.c @@ -561,12 +561,9 @@ g_disk_create(void *arg, int flag) SYSCTL_STATIC_CHILDREN(_kern_geom_disk), OID_AUTO, gp->name, CTLFLAG_RD, 0, tmpstr); if (sc->sysctl_tree != NULL) { - snprintf(tmpstr, sizeof(tmpstr), - "kern.geom.disk.%s.led", gp->name); - TUNABLE_STR_FETCH(tmpstr, sc->led, sizeof(sc->led)); SYSCTL_ADD_STRING(&sc->sysctl_ctx, SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, "led", - CTLFLAG_RW | CTLFLAG_TUN, sc->led, sizeof(sc->led), + CTLFLAG_RWTUN, sc->led, sizeof(sc->led), "LED name"); } pp->private = sc; diff --git a/sys/geom/geom_kern.c b/sys/geom/geom_kern.c index 79afb14abe9e2..3559daf5fcab6 100644 --- a/sys/geom/geom_kern.c +++ b/sys/geom/geom_kern.c @@ -212,8 +212,7 @@ SYSCTL_PROC(_kern_geom, OID_AUTO, conftxt, CTLTYPE_STRING|CTLFLAG_RD, 0, 0, sysctl_kern_geom_conftxt, "", "Dump the GEOM config in txt"); -TUNABLE_INT("kern.geom.debugflags", &g_debugflags); -SYSCTL_INT(_kern_geom, OID_AUTO, debugflags, CTLFLAG_RW, +SYSCTL_INT(_kern_geom, OID_AUTO, debugflags, CTLFLAG_RWTUN, &g_debugflags, 0, "Set various trace levels for GEOM debugging"); SYSCTL_INT(_kern_geom, OID_AUTO, notaste, CTLFLAG_RW, diff --git a/sys/geom/journal/g_journal.c b/sys/geom/journal/g_journal.c index 390847864812e..52dbc36e73365 100644 --- a/sys/geom/journal/g_journal.c +++ b/sys/geom/journal/g_journal.c @@ -84,7 +84,6 @@ const struct g_journal_desc *g_journal_filesystems[] = { SYSCTL_DECL(_kern_geom); int g_journal_debug = 0; -TUNABLE_INT("kern.geom.journal.debug", &g_journal_debug); static u_int g_journal_switch_time = 10; static u_int g_journal_force_switch = 70; static u_int g_journal_parallel_flushes = 16; @@ -95,7 +94,7 @@ static u_int g_journal_do_optimize = 1; static SYSCTL_NODE(_kern_geom, OID_AUTO, journal, CTLFLAG_RW, 0, "GEOM_JOURNAL stuff"); -SYSCTL_INT(_kern_geom_journal, OID_AUTO, debug, CTLFLAG_RW, &g_journal_debug, 0, +SYSCTL_INT(_kern_geom_journal, OID_AUTO, debug, CTLFLAG_RWTUN, &g_journal_debug, 0, "Debug level"); SYSCTL_UINT(_kern_geom_journal, OID_AUTO, switch_time, CTLFLAG_RW, &g_journal_switch_time, 0, "Switch journals every N seconds"); @@ -133,9 +132,7 @@ SYSCTL_UINT(_kern_geom_journal, OID_AUTO, optimize, CTLFLAG_RW, static u_int g_journal_cache_used = 0; static u_int g_journal_cache_limit = 64 * 1024 * 1024; -TUNABLE_INT("kern.geom.journal.cache.limit", &g_journal_cache_limit); static u_int g_journal_cache_divisor = 2; -TUNABLE_INT("kern.geom.journal.cache.divisor", &g_journal_cache_divisor); static u_int g_journal_cache_switch = 90; static u_int g_journal_cache_misses = 0; static u_int g_journal_cache_alloc_failures = 0; @@ -160,7 +157,7 @@ g_journal_cache_limit_sysctl(SYSCTL_HANDLER_ARGS) return (0); } SYSCTL_PROC(_kern_geom_journal_cache, OID_AUTO, limit, - CTLTYPE_UINT | CTLFLAG_RW, NULL, 0, g_journal_cache_limit_sysctl, "I", + CTLTYPE_UINT | CTLFLAG_RWTUN, NULL, 0, g_journal_cache_limit_sysctl, "I", "Maximum number of allocated bytes"); SYSCTL_UINT(_kern_geom_journal_cache, OID_AUTO, divisor, CTLFLAG_RDTUN, &g_journal_cache_divisor, 0, diff --git a/sys/geom/label/g_label.c b/sys/geom/label/g_label.c index ce1376e269ca7..36498e1c3b1ef 100644 --- a/sys/geom/label/g_label.c +++ b/sys/geom/label/g_label.c @@ -50,8 +50,7 @@ FEATURE(geom_label, "GEOM labeling support"); SYSCTL_DECL(_kern_geom); SYSCTL_NODE(_kern_geom, OID_AUTO, label, CTLFLAG_RW, 0, "GEOM_LABEL stuff"); u_int g_label_debug = 0; -TUNABLE_INT("kern.geom.label.debug", &g_label_debug); -SYSCTL_UINT(_kern_geom_label, OID_AUTO, debug, CTLFLAG_RW, &g_label_debug, 0, +SYSCTL_UINT(_kern_geom_label, OID_AUTO, debug, CTLFLAG_RWTUN, &g_label_debug, 0, "Debug level"); static int g_label_destroy_geom(struct gctl_req *req, struct g_class *mp, diff --git a/sys/geom/label/g_label.h b/sys/geom/label/g_label.h index eca31264ec16f..66b762c6f920f 100644 --- a/sys/geom/label/g_label.h +++ b/sys/geom/label/g_label.h @@ -65,9 +65,7 @@ SYSCTL_DECL(_kern_geom_label); SYSCTL_NODE(_kern_geom_label, OID_AUTO, kind, CTLFLAG_RD, \ NULL, ""); \ SYSCTL_INT(_kern_geom_label_##kind, OID_AUTO, enable, \ - CTLFLAG_RW, &label.ld_enabled, 1, descr); \ - TUNABLE_INT("kern.geom.label." __XSTRING(kind) ".enable", \ - &label.ld_enabled) + CTLFLAG_RWTUN, &label.ld_enabled, 1, descr) typedef void g_label_taste_t (struct g_consumer *cp, char *label, size_t size); diff --git a/sys/geom/linux_lvm/g_linux_lvm.c b/sys/geom/linux_lvm/g_linux_lvm.c index 2ac19e06958f3..bf2f1e795f3b7 100644 --- a/sys/geom/linux_lvm/g_linux_lvm.c +++ b/sys/geom/linux_lvm/g_linux_lvm.c @@ -79,8 +79,7 @@ SYSCTL_DECL(_kern_geom); SYSCTL_NODE(_kern_geom, OID_AUTO, linux_lvm, CTLFLAG_RW, 0, "GEOM_LINUX_LVM stuff"); static u_int g_llvm_debug = 0; -TUNABLE_INT("kern.geom.linux_lvm.debug", &g_llvm_debug); -SYSCTL_UINT(_kern_geom_linux_lvm, OID_AUTO, debug, CTLFLAG_RW, &g_llvm_debug, 0, +SYSCTL_UINT(_kern_geom_linux_lvm, OID_AUTO, debug, CTLFLAG_RWTUN, &g_llvm_debug, 0, "Debug level"); LIST_HEAD(, g_llvm_vg) vg_list; diff --git a/sys/geom/mirror/g_mirror.c b/sys/geom/mirror/g_mirror.c index e4dffdcae2c12..2fae439c99f65 100644 --- a/sys/geom/mirror/g_mirror.c +++ b/sys/geom/mirror/g_mirror.c @@ -54,24 +54,18 @@ SYSCTL_DECL(_kern_geom); static SYSCTL_NODE(_kern_geom, OID_AUTO, mirror, CTLFLAG_RW, 0, "GEOM_MIRROR stuff"); u_int g_mirror_debug = 0; -TUNABLE_INT("kern.geom.mirror.debug", &g_mirror_debug); -SYSCTL_UINT(_kern_geom_mirror, OID_AUTO, debug, CTLFLAG_RW, &g_mirror_debug, 0, +SYSCTL_UINT(_kern_geom_mirror, OID_AUTO, debug, CTLFLAG_RWTUN, &g_mirror_debug, 0, "Debug level"); static u_int g_mirror_timeout = 4; -TUNABLE_INT("kern.geom.mirror.timeout", &g_mirror_timeout); -SYSCTL_UINT(_kern_geom_mirror, OID_AUTO, timeout, CTLFLAG_RW, &g_mirror_timeout, +SYSCTL_UINT(_kern_geom_mirror, OID_AUTO, timeout, CTLFLAG_RWTUN, &g_mirror_timeout, 0, "Time to wait on all mirror components"); static u_int g_mirror_idletime = 5; -TUNABLE_INT("kern.geom.mirror.idletime", &g_mirror_idletime); -SYSCTL_UINT(_kern_geom_mirror, OID_AUTO, idletime, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_mirror, OID_AUTO, idletime, CTLFLAG_RWTUN, &g_mirror_idletime, 0, "Mark components as clean when idling"); static u_int g_mirror_disconnect_on_failure = 1; -TUNABLE_INT("kern.geom.mirror.disconnect_on_failure", - &g_mirror_disconnect_on_failure); -SYSCTL_UINT(_kern_geom_mirror, OID_AUTO, disconnect_on_failure, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_mirror, OID_AUTO, disconnect_on_failure, CTLFLAG_RWTUN, &g_mirror_disconnect_on_failure, 0, "Disconnect component on I/O failure."); static u_int g_mirror_syncreqs = 2; -TUNABLE_INT("kern.geom.mirror.sync_requests", &g_mirror_syncreqs); SYSCTL_UINT(_kern_geom_mirror, OID_AUTO, sync_requests, CTLFLAG_RDTUN, &g_mirror_syncreqs, 0, "Parallel synchronization I/O requests."); diff --git a/sys/geom/part/g_part.c b/sys/geom/part/g_part.c index 8429fa06a26bf..2a04ba315673c 100644 --- a/sys/geom/part/g_part.c +++ b/sys/geom/part/g_part.c @@ -123,9 +123,8 @@ SYSCTL_DECL(_kern_geom); SYSCTL_NODE(_kern_geom, OID_AUTO, part, CTLFLAG_RW, 0, "GEOM_PART stuff"); static u_int check_integrity = 1; -TUNABLE_INT("kern.geom.part.check_integrity", &check_integrity); SYSCTL_UINT(_kern_geom_part, OID_AUTO, check_integrity, - CTLFLAG_RW | CTLFLAG_TUN, &check_integrity, 1, + CTLFLAG_RWTUN, &check_integrity, 1, "Enable integrity checking"); /* diff --git a/sys/geom/part/g_part_ldm.c b/sys/geom/part/g_part_ldm.c index 40c2eb877b07e..82bf76dad5224 100644 --- a/sys/geom/part/g_part_ldm.c +++ b/sys/geom/part/g_part_ldm.c @@ -55,18 +55,16 @@ static SYSCTL_NODE(_kern_geom_part, OID_AUTO, ldm, CTLFLAG_RW, 0, "GEOM_PART_LDM Logical Disk Manager"); static u_int ldm_debug = 0; -TUNABLE_INT("kern.geom.part.ldm.debug", &ldm_debug); SYSCTL_UINT(_kern_geom_part_ldm, OID_AUTO, debug, - CTLFLAG_RW | CTLFLAG_TUN, &ldm_debug, 0, "Debug level"); + CTLFLAG_RWTUN, &ldm_debug, 0, "Debug level"); /* * This allows access to mirrored LDM volumes. Since we do not * doing mirroring here, it is not enabled by default. */ static u_int show_mirrors = 0; -TUNABLE_INT("kern.geom.part.ldm.show_mirrors", &show_mirrors); SYSCTL_UINT(_kern_geom_part_ldm, OID_AUTO, show_mirrors, - CTLFLAG_RW | CTLFLAG_TUN, &show_mirrors, 0, "Show mirrored volumes"); + CTLFLAG_RWTUN, &show_mirrors, 0, "Show mirrored volumes"); #define LDM_DEBUG(lvl, fmt, ...) do { \ if (ldm_debug >= (lvl)) { \ diff --git a/sys/geom/raid/g_raid.c b/sys/geom/raid/g_raid.c index 858cf4c75b271..db9cf445ecb2f 100644 --- a/sys/geom/raid/g_raid.c +++ b/sys/geom/raid/g_raid.c @@ -53,49 +53,38 @@ static MALLOC_DEFINE(M_RAID, "raid_data", "GEOM_RAID Data"); SYSCTL_DECL(_kern_geom); SYSCTL_NODE(_kern_geom, OID_AUTO, raid, CTLFLAG_RW, 0, "GEOM_RAID stuff"); int g_raid_enable = 1; -TUNABLE_INT("kern.geom.raid.enable", &g_raid_enable); -SYSCTL_INT(_kern_geom_raid, OID_AUTO, enable, CTLFLAG_RW, +SYSCTL_INT(_kern_geom_raid, OID_AUTO, enable, CTLFLAG_RWTUN, &g_raid_enable, 0, "Enable on-disk metadata taste"); u_int g_raid_aggressive_spare = 0; -TUNABLE_INT("kern.geom.raid.aggressive_spare", &g_raid_aggressive_spare); -SYSCTL_UINT(_kern_geom_raid, OID_AUTO, aggressive_spare, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_raid, OID_AUTO, aggressive_spare, CTLFLAG_RWTUN, &g_raid_aggressive_spare, 0, "Use disks without metadata as spare"); u_int g_raid_debug = 0; -TUNABLE_INT("kern.geom.raid.debug", &g_raid_debug); -SYSCTL_UINT(_kern_geom_raid, OID_AUTO, debug, CTLFLAG_RW, &g_raid_debug, 0, +SYSCTL_UINT(_kern_geom_raid, OID_AUTO, debug, CTLFLAG_RWTUN, &g_raid_debug, 0, "Debug level"); int g_raid_read_err_thresh = 10; -TUNABLE_INT("kern.geom.raid.read_err_thresh", &g_raid_read_err_thresh); -SYSCTL_UINT(_kern_geom_raid, OID_AUTO, read_err_thresh, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_raid, OID_AUTO, read_err_thresh, CTLFLAG_RWTUN, &g_raid_read_err_thresh, 0, "Number of read errors equated to disk failure"); u_int g_raid_start_timeout = 30; -TUNABLE_INT("kern.geom.raid.start_timeout", &g_raid_start_timeout); -SYSCTL_UINT(_kern_geom_raid, OID_AUTO, start_timeout, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_raid, OID_AUTO, start_timeout, CTLFLAG_RWTUN, &g_raid_start_timeout, 0, "Time to wait for all array components"); static u_int g_raid_clean_time = 5; -TUNABLE_INT("kern.geom.raid.clean_time", &g_raid_clean_time); -SYSCTL_UINT(_kern_geom_raid, OID_AUTO, clean_time, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_raid, OID_AUTO, clean_time, CTLFLAG_RWTUN, &g_raid_clean_time, 0, "Mark volume as clean when idling"); static u_int g_raid_disconnect_on_failure = 1; -TUNABLE_INT("kern.geom.raid.disconnect_on_failure", - &g_raid_disconnect_on_failure); -SYSCTL_UINT(_kern_geom_raid, OID_AUTO, disconnect_on_failure, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_raid, OID_AUTO, disconnect_on_failure, CTLFLAG_RWTUN, &g_raid_disconnect_on_failure, 0, "Disconnect component on I/O failure."); static u_int g_raid_name_format = 0; -TUNABLE_INT("kern.geom.raid.name_format", &g_raid_name_format); -SYSCTL_UINT(_kern_geom_raid, OID_AUTO, name_format, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_raid, OID_AUTO, name_format, CTLFLAG_RWTUN, &g_raid_name_format, 0, "Providers name format."); static u_int g_raid_idle_threshold = 1000000; -TUNABLE_INT("kern.geom.raid.idle_threshold", &g_raid_idle_threshold); -SYSCTL_UINT(_kern_geom_raid, OID_AUTO, idle_threshold, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_raid, OID_AUTO, idle_threshold, CTLFLAG_RWTUN, &g_raid_idle_threshold, 1000000, "Time in microseconds to consider a volume idle."); static u_int ar_legacy_aliases = 1; -SYSCTL_INT(_kern_geom_raid, OID_AUTO, legacy_aliases, CTLFLAG_RW, +SYSCTL_INT(_kern_geom_raid, OID_AUTO, legacy_aliases, CTLFLAG_RWTUN, &ar_legacy_aliases, 0, "Create aliases named as the legacy ataraid style."); -TUNABLE_INT("kern.geom_raid.legacy_aliases", &ar_legacy_aliases); #define MSLEEP(rv, ident, mtx, priority, wmesg, timeout) do { \ diff --git a/sys/geom/raid/g_raid.h b/sys/geom/raid/g_raid.h index 8a96fa9f4698d..f6aa6dbb98d0b 100644 --- a/sys/geom/raid/g_raid.h +++ b/sys/geom/raid/g_raid.h @@ -364,10 +364,8 @@ int g_raid_md_modevent(module_t, int, void *); SYSCTL_NODE(_kern_geom_raid, OID_AUTO, name, CTLFLAG_RD, \ NULL, label " metadata module"); \ SYSCTL_INT(_kern_geom_raid_##name, OID_AUTO, enable, \ - CTLFLAG_RW, &g_raid_md_##name##_class.mdc_enable, 0, \ - "Enable " label " metadata format taste"); \ - TUNABLE_INT("kern.geom.raid." __XSTRING(name) ".enable", \ - &g_raid_md_##name##_class.mdc_enable) + CTLFLAG_RWTUN, &g_raid_md_##name##_class.mdc_enable, 0, \ + "Enable " label " metadata format taste") /* * KOBJ parent class of data transformation modules. @@ -403,10 +401,8 @@ int g_raid_tr_modevent(module_t, int, void *); SYSCTL_NODE(_kern_geom_raid, OID_AUTO, name, CTLFLAG_RD, \ NULL, label " transformation module"); \ SYSCTL_INT(_kern_geom_raid_##name, OID_AUTO, enable, \ - CTLFLAG_RW, &g_raid_tr_##name##_class.trc_enable, 0, \ - "Enable " label " transformation module taste"); \ - TUNABLE_INT("kern.geom.raid." __XSTRING(name) ".enable", \ - &g_raid_tr_##name##_class.trc_enable) + CTLFLAG_RWTUN, &g_raid_tr_##name##_class.trc_enable, 0, \ + "Enable " label " transformation module taste") const char * g_raid_volume_level2str(int level, int qual); int g_raid_volume_str2level(const char *str, int *level, int *qual); diff --git a/sys/geom/raid/tr_raid1.c b/sys/geom/raid/tr_raid1.c index 833655bb854fc..17c7a25997445 100644 --- a/sys/geom/raid/tr_raid1.c +++ b/sys/geom/raid/tr_raid1.c @@ -46,33 +46,25 @@ SYSCTL_DECL(_kern_geom_raid_raid1); #define RAID1_REBUILD_SLAB (1 << 20) /* One transation in a rebuild */ static int g_raid1_rebuild_slab = RAID1_REBUILD_SLAB; -TUNABLE_INT("kern.geom.raid.raid1.rebuild_slab_size", - &g_raid1_rebuild_slab); -SYSCTL_UINT(_kern_geom_raid_raid1, OID_AUTO, rebuild_slab_size, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_raid_raid1, OID_AUTO, rebuild_slab_size, CTLFLAG_RWTUN, &g_raid1_rebuild_slab, 0, "Amount of the disk to rebuild each read/write cycle of the rebuild."); #define RAID1_REBUILD_FAIR_IO 20 /* use 1/x of the available I/O */ static int g_raid1_rebuild_fair_io = RAID1_REBUILD_FAIR_IO; -TUNABLE_INT("kern.geom.raid.raid1.rebuild_fair_io", - &g_raid1_rebuild_fair_io); -SYSCTL_UINT(_kern_geom_raid_raid1, OID_AUTO, rebuild_fair_io, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_raid_raid1, OID_AUTO, rebuild_fair_io, CTLFLAG_RWTUN, &g_raid1_rebuild_fair_io, 0, "Fraction of the I/O bandwidth to use when disk busy for rebuild."); #define RAID1_REBUILD_CLUSTER_IDLE 100 static int g_raid1_rebuild_cluster_idle = RAID1_REBUILD_CLUSTER_IDLE; -TUNABLE_INT("kern.geom.raid.raid1.rebuild_cluster_idle", - &g_raid1_rebuild_cluster_idle); -SYSCTL_UINT(_kern_geom_raid_raid1, OID_AUTO, rebuild_cluster_idle, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_raid_raid1, OID_AUTO, rebuild_cluster_idle, CTLFLAG_RWTUN, &g_raid1_rebuild_cluster_idle, 0, "Number of slabs to do each time we trigger a rebuild cycle"); #define RAID1_REBUILD_META_UPDATE 1024 /* update meta data every 1GB or so */ static int g_raid1_rebuild_meta_update = RAID1_REBUILD_META_UPDATE; -TUNABLE_INT("kern.geom.raid.raid1.rebuild_meta_update", - &g_raid1_rebuild_meta_update); -SYSCTL_UINT(_kern_geom_raid_raid1, OID_AUTO, rebuild_meta_update, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_raid_raid1, OID_AUTO, rebuild_meta_update, CTLFLAG_RWTUN, &g_raid1_rebuild_meta_update, 0, "When to update the meta data."); diff --git a/sys/geom/raid/tr_raid1e.c b/sys/geom/raid/tr_raid1e.c index 404b9e6093443..b3577429daca6 100644 --- a/sys/geom/raid/tr_raid1e.c +++ b/sys/geom/raid/tr_raid1e.c @@ -48,33 +48,25 @@ SYSCTL_DECL(_kern_geom_raid_raid1e); #define RAID1E_REBUILD_SLAB (1 << 20) /* One transation in a rebuild */ static int g_raid1e_rebuild_slab = RAID1E_REBUILD_SLAB; -TUNABLE_INT("kern.geom.raid.raid1e.rebuild_slab_size", - &g_raid1e_rebuild_slab); -SYSCTL_UINT(_kern_geom_raid_raid1e, OID_AUTO, rebuild_slab_size, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_raid_raid1e, OID_AUTO, rebuild_slab_size, CTLFLAG_RWTUN, &g_raid1e_rebuild_slab, 0, "Amount of the disk to rebuild each read/write cycle of the rebuild."); #define RAID1E_REBUILD_FAIR_IO 20 /* use 1/x of the available I/O */ static int g_raid1e_rebuild_fair_io = RAID1E_REBUILD_FAIR_IO; -TUNABLE_INT("kern.geom.raid.raid1e.rebuild_fair_io", - &g_raid1e_rebuild_fair_io); -SYSCTL_UINT(_kern_geom_raid_raid1e, OID_AUTO, rebuild_fair_io, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_raid_raid1e, OID_AUTO, rebuild_fair_io, CTLFLAG_RWTUN, &g_raid1e_rebuild_fair_io, 0, "Fraction of the I/O bandwidth to use when disk busy for rebuild."); #define RAID1E_REBUILD_CLUSTER_IDLE 100 static int g_raid1e_rebuild_cluster_idle = RAID1E_REBUILD_CLUSTER_IDLE; -TUNABLE_INT("kern.geom.raid.raid1e.rebuild_cluster_idle", - &g_raid1e_rebuild_cluster_idle); -SYSCTL_UINT(_kern_geom_raid_raid1e, OID_AUTO, rebuild_cluster_idle, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_raid_raid1e, OID_AUTO, rebuild_cluster_idle, CTLFLAG_RWTUN, &g_raid1e_rebuild_cluster_idle, 0, "Number of slabs to do each time we trigger a rebuild cycle"); #define RAID1E_REBUILD_META_UPDATE 1024 /* update meta data every 1GB or so */ static int g_raid1e_rebuild_meta_update = RAID1E_REBUILD_META_UPDATE; -TUNABLE_INT("kern.geom.raid.raid1e.rebuild_meta_update", - &g_raid1e_rebuild_meta_update); -SYSCTL_UINT(_kern_geom_raid_raid1e, OID_AUTO, rebuild_meta_update, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_raid_raid1e, OID_AUTO, rebuild_meta_update, CTLFLAG_RWTUN, &g_raid1e_rebuild_meta_update, 0, "When to update the meta data."); diff --git a/sys/geom/raid3/g_raid3.c b/sys/geom/raid3/g_raid3.c index 927cb3173e712..f935f788a937b 100644 --- a/sys/geom/raid3/g_raid3.c +++ b/sys/geom/raid3/g_raid3.c @@ -54,42 +54,32 @@ SYSCTL_DECL(_kern_geom); static SYSCTL_NODE(_kern_geom, OID_AUTO, raid3, CTLFLAG_RW, 0, "GEOM_RAID3 stuff"); u_int g_raid3_debug = 0; -TUNABLE_INT("kern.geom.raid3.debug", &g_raid3_debug); -SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, debug, CTLFLAG_RW, &g_raid3_debug, 0, +SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, debug, CTLFLAG_RWTUN, &g_raid3_debug, 0, "Debug level"); static u_int g_raid3_timeout = 4; -TUNABLE_INT("kern.geom.raid3.timeout", &g_raid3_timeout); -SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, timeout, CTLFLAG_RW, &g_raid3_timeout, +SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, timeout, CTLFLAG_RWTUN, &g_raid3_timeout, 0, "Time to wait on all raid3 components"); static u_int g_raid3_idletime = 5; -TUNABLE_INT("kern.geom.raid3.idletime", &g_raid3_idletime); -SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, idletime, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, idletime, CTLFLAG_RWTUN, &g_raid3_idletime, 0, "Mark components as clean when idling"); static u_int g_raid3_disconnect_on_failure = 1; -TUNABLE_INT("kern.geom.raid3.disconnect_on_failure", - &g_raid3_disconnect_on_failure); -SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, disconnect_on_failure, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, disconnect_on_failure, CTLFLAG_RWTUN, &g_raid3_disconnect_on_failure, 0, "Disconnect component on I/O failure."); static u_int g_raid3_syncreqs = 2; -TUNABLE_INT("kern.geom.raid3.sync_requests", &g_raid3_syncreqs); SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, sync_requests, CTLFLAG_RDTUN, &g_raid3_syncreqs, 0, "Parallel synchronization I/O requests."); static u_int g_raid3_use_malloc = 0; -TUNABLE_INT("kern.geom.raid3.use_malloc", &g_raid3_use_malloc); SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, use_malloc, CTLFLAG_RDTUN, &g_raid3_use_malloc, 0, "Use malloc(9) instead of uma(9)."); static u_int g_raid3_n64k = 50; -TUNABLE_INT("kern.geom.raid3.n64k", &g_raid3_n64k); -SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, n64k, CTLFLAG_RD, &g_raid3_n64k, 0, +SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, n64k, CTLFLAG_RDTUN, &g_raid3_n64k, 0, "Maximum number of 64kB allocations"); static u_int g_raid3_n16k = 200; -TUNABLE_INT("kern.geom.raid3.n16k", &g_raid3_n16k); -SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, n16k, CTLFLAG_RD, &g_raid3_n16k, 0, +SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, n16k, CTLFLAG_RDTUN, &g_raid3_n16k, 0, "Maximum number of 16kB allocations"); static u_int g_raid3_n4k = 1200; -TUNABLE_INT("kern.geom.raid3.n4k", &g_raid3_n4k); -SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, n4k, CTLFLAG_RD, &g_raid3_n4k, 0, +SYSCTL_UINT(_kern_geom_raid3, OID_AUTO, n4k, CTLFLAG_RDTUN, &g_raid3_n4k, 0, "Maximum number of 4kB allocations"); static SYSCTL_NODE(_kern_geom_raid3, OID_AUTO, stat, CTLFLAG_RW, 0, diff --git a/sys/geom/shsec/g_shsec.c b/sys/geom/shsec/g_shsec.c index 9f8723f619c8a..bfdc8fdc16720 100644 --- a/sys/geom/shsec/g_shsec.c +++ b/sys/geom/shsec/g_shsec.c @@ -71,12 +71,10 @@ SYSCTL_DECL(_kern_geom); static SYSCTL_NODE(_kern_geom, OID_AUTO, shsec, CTLFLAG_RW, 0, "GEOM_SHSEC stuff"); static u_int g_shsec_debug = 0; -TUNABLE_INT("kern.geom.shsec.debug", &g_shsec_debug); -SYSCTL_UINT(_kern_geom_shsec, OID_AUTO, debug, CTLFLAG_RW, &g_shsec_debug, 0, +SYSCTL_UINT(_kern_geom_shsec, OID_AUTO, debug, CTLFLAG_RWTUN, &g_shsec_debug, 0, "Debug level"); static u_int g_shsec_maxmem = MAXPHYS * 100; -TUNABLE_INT("kern.geom.shsec.maxmem", &g_shsec_maxmem); -SYSCTL_UINT(_kern_geom_shsec, OID_AUTO, maxmem, CTLFLAG_RD, &g_shsec_maxmem, +SYSCTL_UINT(_kern_geom_shsec, OID_AUTO, maxmem, CTLFLAG_RDTUN, &g_shsec_maxmem, 0, "Maximum memory that can be allocated for I/O (in bytes)"); static u_int g_shsec_alloc_failed = 0; SYSCTL_UINT(_kern_geom_shsec, OID_AUTO, alloc_failed, CTLFLAG_RD, diff --git a/sys/geom/stripe/g_stripe.c b/sys/geom/stripe/g_stripe.c index 474d888b4b679..1e88e6d606f06 100644 --- a/sys/geom/stripe/g_stripe.c +++ b/sys/geom/stripe/g_stripe.c @@ -71,11 +71,9 @@ SYSCTL_DECL(_kern_geom); static SYSCTL_NODE(_kern_geom, OID_AUTO, stripe, CTLFLAG_RW, 0, "GEOM_STRIPE stuff"); static u_int g_stripe_debug = 0; -TUNABLE_INT("kern.geom.stripe.debug", &g_stripe_debug); -SYSCTL_UINT(_kern_geom_stripe, OID_AUTO, debug, CTLFLAG_RW, &g_stripe_debug, 0, +SYSCTL_UINT(_kern_geom_stripe, OID_AUTO, debug, CTLFLAG_RWTUN, &g_stripe_debug, 0, "Debug level"); static int g_stripe_fast = 0; -TUNABLE_INT("kern.geom.stripe.fast", &g_stripe_fast); static int g_sysctl_stripe_fast(SYSCTL_HANDLER_ARGS) { @@ -87,11 +85,10 @@ g_sysctl_stripe_fast(SYSCTL_HANDLER_ARGS) g_stripe_fast = fast; return (error); } -SYSCTL_PROC(_kern_geom_stripe, OID_AUTO, fast, CTLTYPE_INT | CTLFLAG_RW, +SYSCTL_PROC(_kern_geom_stripe, OID_AUTO, fast, CTLTYPE_INT | CTLFLAG_RWTUN, NULL, 0, g_sysctl_stripe_fast, "I", "Fast, but memory-consuming, mode"); static u_int g_stripe_maxmem = MAXPHYS * 100; -TUNABLE_INT("kern.geom.stripe.maxmem", &g_stripe_maxmem); -SYSCTL_UINT(_kern_geom_stripe, OID_AUTO, maxmem, CTLFLAG_RD, &g_stripe_maxmem, +SYSCTL_UINT(_kern_geom_stripe, OID_AUTO, maxmem, CTLFLAG_RDTUN, &g_stripe_maxmem, 0, "Maximum memory that can be allocated in \"fast\" mode (in bytes)"); static u_int g_stripe_fast_failed = 0; SYSCTL_UINT(_kern_geom_stripe, OID_AUTO, fast_failed, CTLFLAG_RD, diff --git a/sys/geom/vinum/geom_vinum.c b/sys/geom/vinum/geom_vinum.c index 15a62a1d1704d..84d10a51fc868 100644 --- a/sys/geom/vinum/geom_vinum.c +++ b/sys/geom/vinum/geom_vinum.c @@ -50,8 +50,7 @@ SYSCTL_DECL(_kern_geom); static SYSCTL_NODE(_kern_geom, OID_AUTO, vinum, CTLFLAG_RW, 0, "GEOM_VINUM stuff"); u_int g_vinum_debug = 0; -TUNABLE_INT("kern.geom.vinum.debug", &g_vinum_debug); -SYSCTL_UINT(_kern_geom_vinum, OID_AUTO, debug, CTLFLAG_RW, &g_vinum_debug, 0, +SYSCTL_UINT(_kern_geom_vinum, OID_AUTO, debug, CTLFLAG_RWTUN, &g_vinum_debug, 0, "Debug level"); static int gv_create(struct g_geom *, struct gctl_req *); diff --git a/sys/geom/virstor/g_virstor.c b/sys/geom/virstor/g_virstor.c index 40e25d15a1ec0..a1774a9c4984e 100644 --- a/sys/geom/virstor/g_virstor.c +++ b/sys/geom/virstor/g_virstor.c @@ -84,20 +84,16 @@ static SYSCTL_NODE(_kern_geom, OID_AUTO, virstor, CTLFLAG_RW, 0, "GEOM_GVIRSTOR information"); static u_int g_virstor_debug = 2; /* XXX: lower to 2 when released to public */ -TUNABLE_INT("kern.geom.virstor.debug", &g_virstor_debug); -SYSCTL_UINT(_kern_geom_virstor, OID_AUTO, debug, CTLFLAG_RW, &g_virstor_debug, +SYSCTL_UINT(_kern_geom_virstor, OID_AUTO, debug, CTLFLAG_RWTUN, &g_virstor_debug, 0, "Debug level (2=production, 5=normal, 15=excessive)"); static u_int g_virstor_chunk_watermark = 100; -TUNABLE_INT("kern.geom.virstor.chunk_watermark", &g_virstor_chunk_watermark); -SYSCTL_UINT(_kern_geom_virstor, OID_AUTO, chunk_watermark, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_virstor, OID_AUTO, chunk_watermark, CTLFLAG_RWTUN, &g_virstor_chunk_watermark, 0, "Minimum number of free chunks before issuing administrative warning"); static u_int g_virstor_component_watermark = 1; -TUNABLE_INT("kern.geom.virstor.component_watermark", - &g_virstor_component_watermark); -SYSCTL_UINT(_kern_geom_virstor, OID_AUTO, component_watermark, CTLFLAG_RW, +SYSCTL_UINT(_kern_geom_virstor, OID_AUTO, component_watermark, CTLFLAG_RWTUN, &g_virstor_component_watermark, 0, "Minimum number of free components before issuing administrative warning"); diff --git a/sys/i386/acpica/acpi_machdep.c b/sys/i386/acpica/acpi_machdep.c index a244e7377c954..049354b0c2133 100644 --- a/sys/i386/acpica/acpi_machdep.c +++ b/sys/i386/acpica/acpi_machdep.c @@ -45,8 +45,7 @@ __FBSDID("$FreeBSD$"); #include uint32_t acpi_resume_beep; -TUNABLE_INT("debug.acpi.resume_beep", &acpi_resume_beep); -SYSCTL_UINT(_debug_acpi, OID_AUTO, resume_beep, CTLFLAG_RW, &acpi_resume_beep, +SYSCTL_UINT(_debug_acpi, OID_AUTO, resume_beep, CTLFLAG_RWTUN, &acpi_resume_beep, 0, "Beep the PC speaker when resuming"); uint32_t acpi_reset_video; diff --git a/sys/i386/bios/apm.c b/sys/i386/bios/apm.c index bf5071f0deddc..a4d3bd79ee39b 100644 --- a/sys/i386/bios/apm.c +++ b/sys/i386/bios/apm.c @@ -134,8 +134,7 @@ SYSCTL_INT(_machdep, OID_AUTO, apm_suspend_delay, CTLFLAG_RW, &apm_suspend_delay SYSCTL_INT(_machdep, OID_AUTO, apm_standby_delay, CTLFLAG_RW, &apm_standby_delay, 1, ""); SYSCTL_INT(_debug, OID_AUTO, apm_debug, CTLFLAG_RW, &apm_debug, 0, ""); -TUNABLE_INT("machdep.apm_swab_batt_minutes", &apm_swab_batt_minutes); -SYSCTL_INT(_machdep, OID_AUTO, apm_swab_batt_minutes, CTLFLAG_RW, +SYSCTL_INT(_machdep, OID_AUTO, apm_swab_batt_minutes, CTLFLAG_RWTUN, &apm_swab_batt_minutes, 0, "Byte swap battery time value."); #ifdef PC98 diff --git a/sys/i386/i386/i686_mem.c b/sys/i386/i386/i686_mem.c index 84db1ec0d02c9..2721cfb35aaab 100644 --- a/sys/i386/i386/i686_mem.c +++ b/sys/i386/i386/i686_mem.c @@ -65,7 +65,6 @@ static char *mem_owner_bios = "BIOS"; (((curr) & ~MDF_ATTRMASK) | ((new) & MDF_ATTRMASK)) static int mtrrs_disabled; -TUNABLE_INT("machdep.disable_mtrrs", &mtrrs_disabled); SYSCTL_INT(_machdep, OID_AUTO, disable_mtrrs, CTLFLAG_RDTUN, &mtrrs_disabled, 0, "Disable i686 MTRRs."); diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index 3d92e6e56f4b3..ac41c2796237f 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -1231,8 +1231,7 @@ cpu_halt(void) void (*cpu_idle_hook)(sbintime_t) = NULL; /* ACPI idle hook. */ static int cpu_ident_amdc1e = 0; /* AMD C1E supported. */ static int idle_mwait = 1; /* Use MONITOR/MWAIT for short idle. */ -TUNABLE_INT("machdep.idle_mwait", &idle_mwait); -SYSCTL_INT(_machdep, OID_AUTO, idle_mwait, CTLFLAG_RW, &idle_mwait, +SYSCTL_INT(_machdep, OID_AUTO, idle_mwait, CTLFLAG_RWTUN, &idle_mwait, 0, "Use MONITOR/MWAIT for short idle"); #define STATE_RUNNING 0x0 diff --git a/sys/i386/i386/mp_watchdog.c b/sys/i386/i386/mp_watchdog.c index b1799a20b3db5..b03d2614d9b54 100644 --- a/sys/i386/i386/mp_watchdog.c +++ b/sys/i386/i386/mp_watchdog.c @@ -68,8 +68,7 @@ static int watchdog_dontfire = 1; static int watchdog_timer = -1; static int watchdog_nmi = 1; -TUNABLE_INT("debug.watchdog", &watchdog_cpu); -SYSCTL_INT(_debug, OID_AUTO, watchdog_nmi, CTLFLAG_RW, &watchdog_nmi, 0, +SYSCTL_INT(_debug, OID_AUTO, watchdog_nmi, CTLFLAG_RWTUN, &watchdog_nmi, 0, "IPI the boot processor with an NMI to enter the debugger"); static struct callout watchdog_callout; diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c index af8c9ff0f983d..3085157dbb95a 100644 --- a/sys/i386/i386/pmap.c +++ b/sys/i386/i386/pmap.c @@ -225,8 +225,8 @@ SYSCTL_INT(_vm_pmap, OID_AUTO, pat_works, CTLFLAG_RD, &pat_works, 1, "Is page attribute table fully functional?"); static int pg_ps_enabled = 1; -SYSCTL_INT(_vm_pmap, OID_AUTO, pg_ps_enabled, CTLFLAG_RDTUN, &pg_ps_enabled, 0, - "Are large page mappings enabled?"); +SYSCTL_INT(_vm_pmap, OID_AUTO, pg_ps_enabled, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, + &pg_ps_enabled, 0, "Are large page mappings enabled?"); #define PAT_INDEX_SIZE 8 static int pat_index[PAT_INDEX_SIZE]; /* cache mode to PAT index conversion */ diff --git a/sys/i386/i386/trap.c b/sys/i386/i386/trap.c index 97254f25bde41..6e4aba2a21331 100644 --- a/sys/i386/i386/trap.c +++ b/sys/i386/i386/trap.c @@ -158,14 +158,12 @@ extern int has_f00f_bug; #ifdef KDB static int kdb_on_nmi = 1; -SYSCTL_INT(_machdep, OID_AUTO, kdb_on_nmi, CTLFLAG_RW, +SYSCTL_INT(_machdep, OID_AUTO, kdb_on_nmi, CTLFLAG_RWTUN, &kdb_on_nmi, 0, "Go to KDB on NMI"); -TUNABLE_INT("machdep.kdb_on_nmi", &kdb_on_nmi); #endif static int panic_on_nmi = 1; -SYSCTL_INT(_machdep, OID_AUTO, panic_on_nmi, CTLFLAG_RW, +SYSCTL_INT(_machdep, OID_AUTO, panic_on_nmi, CTLFLAG_RWTUN, &panic_on_nmi, 0, "Panic on NMI"); -TUNABLE_INT("machdep.panic_on_nmi", &panic_on_nmi); static int prot_fault_translation = 0; SYSCTL_INT(_machdep, OID_AUTO, prot_fault_translation, CTLFLAG_RW, &prot_fault_translation, 0, "Select signal to deliver on protection fault"); diff --git a/sys/i386/pci/pci_cfgreg.c b/sys/i386/pci/pci_cfgreg.c index cce4981d9c9d5..5d57e89334a18 100644 --- a/sys/i386/pci/pci_cfgreg.c +++ b/sys/i386/pci/pci_cfgreg.c @@ -86,7 +86,6 @@ static int cfgmech; static int devmax; static struct mtx pcicfg_mtx; static int mcfg_enable = 1; -TUNABLE_INT("hw.pci.mcfg", &mcfg_enable); SYSCTL_INT(_hw_pci, OID_AUTO, mcfg, CTLFLAG_RDTUN, &mcfg_enable, 0, "Enable support for PCI-e memory mapped config access"); diff --git a/sys/i386/pci/pci_pir.c b/sys/i386/pci/pci_pir.c index c275de094f5cf..0d64cabf4aab2 100644 --- a/sys/i386/pci/pci_pir.c +++ b/sys/i386/pci/pci_pir.c @@ -117,7 +117,6 @@ SYSCTL_DECL(_hw_pci); #endif static uint32_t pci_irq_override_mask = PCI_IRQ_OVERRIDE_MASK; -TUNABLE_INT("hw.pci.irq_override_mask", &pci_irq_override_mask); SYSCTL_INT(_hw_pci, OID_AUTO, irq_override_mask, CTLFLAG_RDTUN, &pci_irq_override_mask, PCI_IRQ_OVERRIDE_MASK, "Mask of allowed irqs to try to route when it has no good clue about\n" diff --git a/sys/ia64/ia64/dump_machdep.c b/sys/ia64/ia64/dump_machdep.c index 9a058bb1f4baf..d6d9d0487a49d 100644 --- a/sys/ia64/ia64/dump_machdep.c +++ b/sys/ia64/ia64/dump_machdep.c @@ -57,8 +57,7 @@ CTASSERT(sizeof(struct kerneldumpheader) == 512); #define DEV_ALIGN(x) (((off_t)(x) + (DEV_BSIZE-1)) & ~(DEV_BSIZE-1)) static int minidump = 0; -TUNABLE_INT("debug.minidump", &minidump); -SYSCTL_INT(_debug, OID_AUTO, minidump, CTLFLAG_RW, &minidump, 0, +SYSCTL_INT(_debug, OID_AUTO, minidump, CTLFLAG_RWTUN, &minidump, 0, "Enable mini crash dumps"); static struct kerneldumpheader kdh; diff --git a/sys/ia64/ia64/pmap.c b/sys/ia64/ia64/pmap.c index 9f642970fcb9a..1ed35c3ffcb21 100644 --- a/sys/ia64/ia64/pmap.c +++ b/sys/ia64/ia64/pmap.c @@ -240,9 +240,8 @@ int pmap_vhpt_nbuckets; SYSCTL_INT(_machdep_vhpt, OID_AUTO, nbuckets, CTLFLAG_RD, &pmap_vhpt_nbuckets, 0, ""); -int pmap_vhpt_log2size = 0; -TUNABLE_INT("machdep.vhpt.log2size", &pmap_vhpt_log2size); -SYSCTL_INT(_machdep_vhpt, OID_AUTO, log2size, CTLFLAG_RD, +int pmap_vhpt_log2size; +SYSCTL_INT(_machdep_vhpt, OID_AUTO, log2size, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &pmap_vhpt_log2size, 0, ""); static int pmap_vhpt_inserts; diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index 591094e5af968..b085a708b57f5 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -112,10 +112,8 @@ static int compress_core(gzFile, char *, char *, unsigned int, int __elfN(fallback_brand) = -1; SYSCTL_INT(__CONCAT(_kern_elf, __ELF_WORD_SIZE), OID_AUTO, - fallback_brand, CTLFLAG_RW, &__elfN(fallback_brand), 0, + fallback_brand, CTLFLAG_RWTUN, &__elfN(fallback_brand), 0, __XSTRING(__CONCAT(ELF, __ELF_WORD_SIZE)) " brand of last resort"); -TUNABLE_INT("kern.elf" __XSTRING(__ELF_WORD_SIZE) ".fallback_brand", - &__elfN(fallback_brand)); static int elf_legacy_coredump = 0; SYSCTL_INT(_debug, OID_AUTO, __elfN(legacy_coredump), CTLFLAG_RW, diff --git a/sys/kern/kern_clocksource.c b/sys/kern/kern_clocksource.c index ae64c616c1f66..092c81807b173 100644 --- a/sys/kern/kern_clocksource.c +++ b/sys/kern/kern_clocksource.c @@ -96,23 +96,21 @@ static sbintime_t statperiod; /* statclock() events period. */ static sbintime_t profperiod; /* profclock() events period. */ static sbintime_t nexttick; /* Next global timer tick time. */ static u_int busy = 1; /* Reconfiguration is in progress. */ -static int profiling = 0; /* Profiling events enabled. */ +static int profiling; /* Profiling events enabled. */ static char timername[32]; /* Wanted timer. */ TUNABLE_STR("kern.eventtimer.timer", timername, sizeof(timername)); -static int singlemul = 0; /* Multiplier for periodic mode. */ -TUNABLE_INT("kern.eventtimer.singlemul", &singlemul); -SYSCTL_INT(_kern_eventtimer, OID_AUTO, singlemul, CTLFLAG_RW, &singlemul, +static int singlemul; /* Multiplier for periodic mode. */ +SYSCTL_INT(_kern_eventtimer, OID_AUTO, singlemul, CTLFLAG_RWTUN, &singlemul, 0, "Multiplier for periodic mode"); -static u_int idletick = 0; /* Run periodic events when idle. */ -TUNABLE_INT("kern.eventtimer.idletick", &idletick); -SYSCTL_UINT(_kern_eventtimer, OID_AUTO, idletick, CTLFLAG_RW, &idletick, +static u_int idletick; /* Run periodic events when idle. */ +SYSCTL_UINT(_kern_eventtimer, OID_AUTO, idletick, CTLFLAG_RWTUN, &idletick, 0, "Run periodic events when idle"); -static int periodic = 0; /* Periodic or one-shot mode. */ -static int want_periodic = 0; /* What mode to prefer. */ +static int periodic; /* Periodic or one-shot mode. */ +static int want_periodic; /* What mode to prefer. */ TUNABLE_INT("kern.eventtimer.periodic", &want_periodic); struct pcpu_state { diff --git a/sys/kern/kern_cons.c b/sys/kern/kern_cons.c index 8d23befd05779..1d5ac0e38a699 100644 --- a/sys/kern/kern_cons.c +++ b/sys/kern/kern_cons.c @@ -652,9 +652,9 @@ sysbeep(int pitch __unused, int period __unused) /* * Temporary support for sc(4) to vt(4) transition. */ -static char vty_name[16] = ""; -SYSCTL_STRING(_kern, OID_AUTO, vty, CTLFLAG_RDTUN, vty_name, 0, - "Console vty driver"); +static char vty_name[16]; +SYSCTL_STRING(_kern, OID_AUTO, vty, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, vty_name, + 0, "Console vty driver"); int vty_enabled(unsigned vty) diff --git a/sys/kern/kern_cpu.c b/sys/kern/kern_cpu.c index 7206c388f76a8..293b940683ba5 100644 --- a/sys/kern/kern_cpu.c +++ b/sys/kern/kern_cpu.c @@ -133,13 +133,11 @@ DRIVER_MODULE(cpufreq, cpu, cpufreq_driver, cpufreq_dc, 0, 0); static int cf_lowest_freq; static int cf_verbose; -TUNABLE_INT("debug.cpufreq.lowest", &cf_lowest_freq); -TUNABLE_INT("debug.cpufreq.verbose", &cf_verbose); static SYSCTL_NODE(_debug, OID_AUTO, cpufreq, CTLFLAG_RD, NULL, "cpufreq debugging"); -SYSCTL_INT(_debug_cpufreq, OID_AUTO, lowest, CTLFLAG_RW, &cf_lowest_freq, 1, +SYSCTL_INT(_debug_cpufreq, OID_AUTO, lowest, CTLFLAG_RWTUN, &cf_lowest_freq, 1, "Don't provide levels below this frequency."); -SYSCTL_INT(_debug_cpufreq, OID_AUTO, verbose, CTLFLAG_RW, &cf_verbose, 1, +SYSCTL_INT(_debug_cpufreq, OID_AUTO, verbose, CTLFLAG_RWTUN, &cf_verbose, 1, "Print verbose debugging messages"); static int diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 078cd383bae0d..7d3bad9d50c43 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -127,8 +127,7 @@ SYSCTL_INT(_kern, OID_AUTO, disallow_high_osrel, CTLFLAG_RW, "Disallow execution of binaries built for higher version of the world"); static int map_at_zero = 0; -TUNABLE_INT("security.bsd.map_at_zero", &map_at_zero); -SYSCTL_INT(_security_bsd, OID_AUTO, map_at_zero, CTLFLAG_RW, &map_at_zero, 0, +SYSCTL_INT(_security_bsd, OID_AUTO, map_at_zero, CTLFLAG_RWTUN, &map_at_zero, 0, "Permit processes to map an object at virtual address 0."); static int diff --git a/sys/kern/kern_intr.c b/sys/kern/kern_intr.c index 5555d6858f9ac..25032f278c1d7 100644 --- a/sys/kern/kern_intr.c +++ b/sys/kern/kern_intr.c @@ -89,8 +89,7 @@ struct proc *intrproc; static MALLOC_DEFINE(M_ITHREAD, "ithread", "Interrupt Threads"); static int intr_storm_threshold = 1000; -TUNABLE_INT("hw.intr_storm_threshold", &intr_storm_threshold); -SYSCTL_INT(_hw, OID_AUTO, intr_storm_threshold, CTLFLAG_RW, +SYSCTL_INT(_hw, OID_AUTO, intr_storm_threshold, CTLFLAG_RWTUN, &intr_storm_threshold, 0, "Number of consecutive interrupts before storm protection is enabled"); static TAILQ_HEAD(, intr_event) event_list = diff --git a/sys/kern/kern_ktr.c b/sys/kern/kern_ktr.c index e302ae228d458..c377f36e09a74 100644 --- a/sys/kern/kern_ktr.c +++ b/sys/kern/kern_ktr.c @@ -104,33 +104,17 @@ struct ktr_entry *ktr_buf = ktr_buf_init; cpuset_t ktr_cpumask = CPUSET_T_INITIALIZER(KTR_CPUMASK); static char ktr_cpumask_str[CPUSETBUFSIZ]; -TUNABLE_INT("debug.ktr.mask", &ktr_mask); - -TUNABLE_STR("debug.ktr.cpumask", ktr_cpumask_str, sizeof(ktr_cpumask_str)); - static SYSCTL_NODE(_debug, OID_AUTO, ktr, CTLFLAG_RD, 0, "KTR options"); +SYSCTL_INT(_debug_ktr, OID_AUTO, mask, CTLFLAG_RDTUN, + &ktr_mask, 0, "KTR mask"); + SYSCTL_INT(_debug_ktr, OID_AUTO, version, CTLFLAG_RD, &ktr_version, 0, "Version of the KTR interface"); SYSCTL_UINT(_debug_ktr, OID_AUTO, compile, CTLFLAG_RD, &ktr_compile, 0, "Bitmask of KTR event classes compiled into the kernel"); -static void -ktr_cpumask_initializer(void *dummy __unused) -{ - - /* - * TUNABLE_STR() runs with SI_ORDER_MIDDLE priority, thus it must be - * already set, if necessary. - */ - if (ktr_cpumask_str[0] != '\0' && - cpusetobj_strscan(&ktr_cpumask, ktr_cpumask_str) == -1) - CPU_FILL(&ktr_cpumask); -} -SYSINIT(ktr_cpumask_initializer, SI_SUB_TUNABLES, SI_ORDER_ANY, - ktr_cpumask_initializer, NULL); - static int sysctl_debug_ktr_cpumask(SYSCTL_HANDLER_ARGS) { @@ -150,7 +134,7 @@ sysctl_debug_ktr_cpumask(SYSCTL_HANDLER_ARGS) return (error); } SYSCTL_PROC(_debug_ktr, OID_AUTO, cpumask, - CTLFLAG_RW | CTLFLAG_MPSAFE | CTLTYPE_STRING, NULL, 0, + CTLFLAG_RWTUN | CTLFLAG_MPSAFE | CTLTYPE_STRING, NULL, 0, sysctl_debug_ktr_cpumask, "S", "Bitmask of CPUs on which KTR logging is enabled"); diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c index b74d48ecffb8f..367610b34a3a5 100644 --- a/sys/kern/kern_ktrace.c +++ b/sys/kern/kern_ktrace.c @@ -133,8 +133,7 @@ static u_int ktr_requestpool = KTRACE_REQUEST_POOL; TUNABLE_INT("kern.ktrace.request_pool", &ktr_requestpool); static u_int ktr_geniosize = PAGE_SIZE; -TUNABLE_INT("kern.ktrace.genio_size", &ktr_geniosize); -SYSCTL_UINT(_kern_ktrace, OID_AUTO, genio_size, CTLFLAG_RW, &ktr_geniosize, +SYSCTL_UINT(_kern_ktrace, OID_AUTO, genio_size, CTLFLAG_RWTUN, &ktr_geniosize, 0, "Maximum size of genio event payload"); static int print_message = 1; diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c index e379f5f89f959..dbc0fb30974d8 100644 --- a/sys/kern/kern_linker.c +++ b/sys/kern/kern_linker.c @@ -66,9 +66,8 @@ __FBSDID("$FreeBSD$"); #ifdef KLD_DEBUG int kld_debug = 0; -SYSCTL_INT(_debug, OID_AUTO, kld_debug, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_debug, OID_AUTO, kld_debug, CTLFLAG_RWTUN, &kld_debug, 0, "Set various levels of KLD debug"); -TUNABLE_INT("debug.kld_debug", &kld_debug); #endif /* @@ -1643,7 +1642,7 @@ SYSINIT(preload, SI_SUB_KLD, SI_ORDER_MIDDLE, linker_preload, 0); static char linker_hintfile[] = "linker.hints"; static char linker_path[MAXPATHLEN] = "/boot/kernel;/boot/modules"; -SYSCTL_STRING(_kern, OID_AUTO, module_path, CTLFLAG_RW, linker_path, +SYSCTL_STRING(_kern, OID_AUTO, module_path, CTLFLAG_RWTUN, linker_path, sizeof(linker_path), "module load search path"); TUNABLE_STR("module_path", linker_path, sizeof(linker_path)); diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c index 658908c65634b..f16d4d5008199 100644 --- a/sys/kern/kern_malloc.c +++ b/sys/kern/kern_malloc.c @@ -191,7 +191,7 @@ static u_long vm_kmem_size_max; SYSCTL_ULONG(_vm, OID_AUTO, kmem_size_max, CTLFLAG_RDTUN, &vm_kmem_size_max, 0, "Maximum size of kernel memory"); -static u_int vm_kmem_size_scale; +static u_int vm_kmem_size_scale = VM_KMEM_SIZE_SCALE; SYSCTL_UINT(_vm, OID_AUTO, kmem_size_scale, CTLFLAG_RDTUN, &vm_kmem_size_scale, 0, "Scale factor for kernel memory size"); @@ -236,9 +236,8 @@ static SYSCTL_NODE(_debug, OID_AUTO, malloc, CTLFLAG_RD, 0, static int malloc_failure_rate; static int malloc_nowait_count; static int malloc_failure_count; -SYSCTL_INT(_debug_malloc, OID_AUTO, failure_rate, CTLFLAG_RW, +SYSCTL_INT(_debug_malloc, OID_AUTO, failure_rate, CTLFLAG_RWTUN, &malloc_failure_rate, 0, "Every (n) mallocs with M_NOWAIT will fail"); -TUNABLE_INT("debug.malloc.failure_rate", &malloc_failure_rate); SYSCTL_INT(_debug_malloc, OID_AUTO, failure_count, CTLFLAG_RD, &malloc_failure_count, 0, "Number of imposed M_NOWAIT malloc failures"); #endif @@ -280,7 +279,7 @@ tunable_set_numzones(void) numzones = MALLOC_DEBUG_MAXZONES; } SYSINIT(numzones, SI_SUB_TUNABLES, SI_ORDER_ANY, tunable_set_numzones, NULL); -SYSCTL_INT(_debug_malloc, OID_AUTO, numzones, CTLFLAG_RDTUN, +SYSCTL_INT(_debug_malloc, OID_AUTO, numzones, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &numzones, 0, "Number of malloc uma subzones"); /* @@ -693,8 +692,21 @@ CTASSERT(VM_KMEM_SIZE_SCALE >= 1); void kmeminit(void) { - u_long mem_size, tmp; + u_long mem_size; + u_long tmp; +#ifdef VM_KMEM_SIZE + if (vm_kmem_size == 0) + vm_kmem_size = VM_KMEM_SIZE; +#endif +#ifdef VM_KMEM_SIZE_MIN + if (vm_kmem_size_min == 0) + vm_kmem_size_min = VM_KMEM_SIZE_MIN; +#endif +#ifdef VM_KMEM_SIZE_MAX + if (vm_kmem_size_max == 0) + vm_kmem_size_max = VM_KMEM_SIZE_MAX; +#endif /* * Calculate the amount of kernel virtual address (KVA) space that is * preallocated to the kmem arena. In order to support a wide range @@ -713,38 +725,29 @@ kmeminit(void) */ mem_size = vm_cnt.v_page_count; - vm_kmem_size_scale = VM_KMEM_SIZE_SCALE; - TUNABLE_INT_FETCH("vm.kmem_size_scale", &vm_kmem_size_scale); if (vm_kmem_size_scale < 1) vm_kmem_size_scale = VM_KMEM_SIZE_SCALE; - vm_kmem_size = (mem_size / vm_kmem_size_scale) * PAGE_SIZE; - -#if defined(VM_KMEM_SIZE_MIN) - vm_kmem_size_min = VM_KMEM_SIZE_MIN; -#endif - TUNABLE_ULONG_FETCH("vm.kmem_size_min", &vm_kmem_size_min); - if (vm_kmem_size_min > 0 && vm_kmem_size < vm_kmem_size_min) - vm_kmem_size = vm_kmem_size_min; + /* + * Check if we should use defaults for the "vm_kmem_size" + * variable: + */ + if (vm_kmem_size == 0) { + vm_kmem_size = (mem_size / vm_kmem_size_scale) * PAGE_SIZE; -#if defined(VM_KMEM_SIZE_MAX) - vm_kmem_size_max = VM_KMEM_SIZE_MAX; -#endif - TUNABLE_ULONG_FETCH("vm.kmem_size_max", &vm_kmem_size_max); - if (vm_kmem_size_max > 0 && vm_kmem_size >= vm_kmem_size_max) - vm_kmem_size = vm_kmem_size_max; + if (vm_kmem_size_min > 0 && vm_kmem_size < vm_kmem_size_min) + vm_kmem_size = vm_kmem_size_min; + if (vm_kmem_size_max > 0 && vm_kmem_size >= vm_kmem_size_max) + vm_kmem_size = vm_kmem_size_max; + } /* - * Alternatively, the amount of KVA space that is preallocated to the + * The amount of KVA space that is preallocated to the * kmem arena can be set statically at compile-time or manually * through the kernel environment. However, it is still limited to * twice the physical memory size, which has been sufficient to handle * the most severe cases of external fragmentation in the kmem arena. */ -#if defined(VM_KMEM_SIZE) - vm_kmem_size = VM_KMEM_SIZE; -#endif - TUNABLE_ULONG_FETCH("vm.kmem_size", &vm_kmem_size); if (vm_kmem_size / 2 / PAGE_SIZE > mem_size) vm_kmem_size = 2 * mem_size * PAGE_SIZE; @@ -811,7 +814,7 @@ mallocinit(void *dummy) } } -SYSINIT(kmem, SI_SUB_KMEM, SI_ORDER_FIRST, mallocinit, NULL); +SYSINIT(kmem, SI_SUB_KMEM, SI_ORDER_SECOND, mallocinit, NULL); void malloc_init(void *data) diff --git a/sys/kern/kern_mbuf.c b/sys/kern/kern_mbuf.c index 119e4b8325253..63d5d5523368b 100644 --- a/sys/kern/kern_mbuf.c +++ b/sys/kern/kern_mbuf.c @@ -105,7 +105,7 @@ int nmbjumbo16; /* limits number of 16k jumbo clusters */ static quad_t maxmbufmem; /* overall real memory limit for all mbufs */ -SYSCTL_QUAD(_kern_ipc, OID_AUTO, maxmbufmem, CTLFLAG_RDTUN, &maxmbufmem, 0, +SYSCTL_QUAD(_kern_ipc, OID_AUTO, maxmbufmem, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &maxmbufmem, 0, "Maximum real memory allocatable to various mbuf types"); /* diff --git a/sys/kern/kern_mib.c b/sys/kern/kern_mib.c index 213482b42c913..9d3153b4a5bbf 100644 --- a/sys/kern/kern_mib.c +++ b/sys/kern/kern_mib.c @@ -55,35 +55,35 @@ __FBSDID("$FreeBSD$"); #include #include -SYSCTL_NODE(, 0, sysctl, CTLFLAG_RW, 0, +SYSCTL_ROOT_NODE(0, sysctl, CTLFLAG_RW, 0, "Sysctl internal magic"); -SYSCTL_NODE(, CTL_KERN, kern, CTLFLAG_RW|CTLFLAG_CAPRD, 0, +SYSCTL_ROOT_NODE(CTL_KERN, kern, CTLFLAG_RW|CTLFLAG_CAPRD, 0, "High kernel, proc, limits &c"); -SYSCTL_NODE(, CTL_VM, vm, CTLFLAG_RW, 0, +SYSCTL_ROOT_NODE(CTL_VM, vm, CTLFLAG_RW, 0, "Virtual memory"); -SYSCTL_NODE(, CTL_VFS, vfs, CTLFLAG_RW, 0, +SYSCTL_ROOT_NODE(CTL_VFS, vfs, CTLFLAG_RW, 0, "File system"); -SYSCTL_NODE(, CTL_NET, net, CTLFLAG_RW, 0, +SYSCTL_ROOT_NODE(CTL_NET, net, CTLFLAG_RW, 0, "Network, (see socket.h)"); -SYSCTL_NODE(, CTL_DEBUG, debug, CTLFLAG_RW, 0, +SYSCTL_ROOT_NODE(CTL_DEBUG, debug, CTLFLAG_RW, 0, "Debugging"); SYSCTL_NODE(_debug, OID_AUTO, sizeof, CTLFLAG_RW, 0, "Sizeof various things"); -SYSCTL_NODE(, CTL_HW, hw, CTLFLAG_RW, 0, +SYSCTL_ROOT_NODE(CTL_HW, hw, CTLFLAG_RW, 0, "hardware"); -SYSCTL_NODE(, CTL_MACHDEP, machdep, CTLFLAG_RW, 0, +SYSCTL_ROOT_NODE(CTL_MACHDEP, machdep, CTLFLAG_RW, 0, "machine dependent"); -SYSCTL_NODE(, CTL_USER, user, CTLFLAG_RW, 0, +SYSCTL_ROOT_NODE(CTL_USER, user, CTLFLAG_RW, 0, "user-level"); -SYSCTL_NODE(, CTL_P1003_1B, p1003_1b, CTLFLAG_RW, 0, +SYSCTL_ROOT_NODE(CTL_P1003_1B, p1003_1b, CTLFLAG_RW, 0, "p1003_1b, (see p1003_1b.h)"); -SYSCTL_NODE(, OID_AUTO, compat, CTLFLAG_RW, 0, +SYSCTL_ROOT_NODE(OID_AUTO, compat, CTLFLAG_RW, 0, "Compatibility code"); -SYSCTL_NODE(, OID_AUTO, security, CTLFLAG_RW, 0, +SYSCTL_ROOT_NODE(OID_AUTO, security, CTLFLAG_RW, 0, "Security"); #ifdef REGRESSION -SYSCTL_NODE(, OID_AUTO, regression, CTLFLAG_RW, 0, +SYSCTL_ROOT_NODE(OID_AUTO, regression, CTLFLAG_RW, 0, "Regression test MIB"); #endif @@ -112,13 +112,13 @@ SYSCTL_STRING(_kern, KERN_OSTYPE, ostype, CTLFLAG_RD|CTLFLAG_MPSAFE| SYSCTL_INT(_kern, KERN_OSRELDATE, osreldate, CTLFLAG_RD|CTLFLAG_CAPRD, &osreldate, 0, "Kernel release date"); -SYSCTL_INT(_kern, KERN_MAXPROC, maxproc, CTLFLAG_RDTUN, +SYSCTL_INT(_kern, KERN_MAXPROC, maxproc, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &maxproc, 0, "Maximum number of processes"); SYSCTL_INT(_kern, KERN_MAXPROCPERUID, maxprocperuid, CTLFLAG_RW, &maxprocperuid, 0, "Maximum processes allowed per userid"); -SYSCTL_INT(_kern, OID_AUTO, maxusers, CTLFLAG_RDTUN, +SYSCTL_INT(_kern, OID_AUTO, maxusers, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &maxusers, 0, "Hint for kernel tuning"); SYSCTL_INT(_kern, KERN_ARGMAX, argmax, CTLFLAG_RD|CTLFLAG_CAPRD, @@ -127,8 +127,8 @@ SYSCTL_INT(_kern, KERN_ARGMAX, argmax, CTLFLAG_RD|CTLFLAG_CAPRD, SYSCTL_INT(_kern, KERN_POSIX1, posix1version, CTLFLAG_RD|CTLFLAG_CAPRD, 0, _POSIX_VERSION, "Version of POSIX attempting to comply to"); -SYSCTL_INT(_kern, KERN_NGROUPS, ngroups, CTLFLAG_RDTUN|CTLFLAG_CAPRD, - &ngroups_max, 0, +SYSCTL_INT(_kern, KERN_NGROUPS, ngroups, CTLFLAG_RDTUN | + CTLFLAG_NOFETCH | CTLFLAG_CAPRD, &ngroups_max, 0, "Maximum number of supplemental groups a user can belong to"); SYSCTL_INT(_kern, KERN_JOB_CONTROL, job_control, CTLFLAG_RD|CTLFLAG_CAPRD, @@ -526,9 +526,9 @@ sysctl_kern_pid_max(SYSCTL_HANDLER_ARGS) sx_xunlock(&proctree_lock); return (error); } -SYSCTL_PROC(_kern, OID_AUTO, pid_max, CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_TUN | - CTLFLAG_MPSAFE, 0, 0, sysctl_kern_pid_max, "I", - "Maximum allowed pid"); +SYSCTL_PROC(_kern, OID_AUTO, pid_max, CTLTYPE_INT | + CTLFLAG_RWTUN | CTLFLAG_NOFETCH | CTLFLAG_MPSAFE, + 0, 0, sysctl_kern_pid_max, "I", "Maximum allowed pid"); #include #include diff --git a/sys/kern/kern_ntptime.c b/sys/kern/kern_ntptime.c index 7c95575293d4b..638cd53332aa6 100644 --- a/sys/kern/kern_ntptime.c +++ b/sys/kern/kern_ntptime.c @@ -1025,18 +1025,20 @@ sysctl_resettodr_period(SYSCTL_HANDLER_ARGS) error = sysctl_handle_int(oidp, oidp->oid_arg1, oidp->oid_arg2, req); if (error || !req->newptr) return (error); + if (cold) + goto done; if (resettodr_period == 0) callout_stop(&resettodr_callout); else callout_reset(&resettodr_callout, resettodr_period * hz, periodic_resettodr, NULL); +done: return (0); } -SYSCTL_PROC(_machdep, OID_AUTO, rtc_save_period, CTLTYPE_INT|CTLFLAG_RW, +SYSCTL_PROC(_machdep, OID_AUTO, rtc_save_period, CTLTYPE_INT|CTLFLAG_RWTUN, &resettodr_period, 1800, sysctl_resettodr_period, "I", "Save system time to RTC with this period (in seconds)"); -TUNABLE_INT("machdep.rtc_save_period", &resettodr_period); static void start_periodic_resettodr(void *arg __unused) diff --git a/sys/kern/kern_osd.c b/sys/kern/kern_osd.c index 184c4f00ba08f..cc9bed1fab3dd 100644 --- a/sys/kern/kern_osd.c +++ b/sys/kern/kern_osd.c @@ -47,8 +47,7 @@ __FBSDID("$FreeBSD$"); static MALLOC_DEFINE(M_OSD, "osd", "Object Specific Data"); static int osd_debug = 0; -TUNABLE_INT("debug.osd", &osd_debug); -SYSCTL_INT(_debug, OID_AUTO, osd, CTLFLAG_RW, &osd_debug, 0, "OSD debug level"); +SYSCTL_INT(_debug, OID_AUTO, osd, CTLFLAG_RWTUN, &osd_debug, 0, "OSD debug level"); #define OSD_DEBUG(...) do { \ if (osd_debug) { \ diff --git a/sys/kern/kern_pmc.c b/sys/kern/kern_pmc.c index 2b50be0343fca..09dc6edbcffeb 100644 --- a/sys/kern/kern_pmc.c +++ b/sys/kern/kern_pmc.c @@ -96,8 +96,7 @@ struct trapframe pmc_tf[MAXCPU]; SYSCTL_NODE(_kern, OID_AUTO, hwpmc, CTLFLAG_RW, 0, "HWPMC parameters"); static int pmc_softevents = 16; -TUNABLE_INT(PMC_SYSCTL_NAME_PREFIX "softevents", &pmc_softevents); -SYSCTL_INT(_kern_hwpmc, OID_AUTO, softevents, CTLFLAG_TUN|CTLFLAG_RD, +SYSCTL_INT(_kern_hwpmc, OID_AUTO, softevents, CTLFLAG_RDTUN, &pmc_softevents, 0, "maximum number of soft events"); struct mtx pmc_softs_mtx; diff --git a/sys/kern/kern_priv.c b/sys/kern/kern_priv.c index 2daa5c29fe420..4b9a4443de3ac 100644 --- a/sys/kern/kern_priv.c +++ b/sys/kern/kern_priv.c @@ -53,14 +53,12 @@ __FBSDID("$FreeBSD$"); * the consequences. */ static int suser_enabled = 1; -SYSCTL_INT(_security_bsd, OID_AUTO, suser_enabled, CTLFLAG_RW, +SYSCTL_INT(_security_bsd, OID_AUTO, suser_enabled, CTLFLAG_RWTUN, &suser_enabled, 0, "processes with uid 0 have privilege"); -TUNABLE_INT("security.bsd.suser_enabled", &suser_enabled); static int unprivileged_mlock = 1; -SYSCTL_INT(_security_bsd, OID_AUTO, unprivileged_mlock, CTLFLAG_RW|CTLFLAG_TUN, +SYSCTL_INT(_security_bsd, OID_AUTO, unprivileged_mlock, CTLFLAG_RWTUN, &unprivileged_mlock, 0, "Allow non-root users to call mlock(2)"); -TUNABLE_INT("security.bsd.unprivileged_mlock", &unprivileged_mlock); SDT_PROVIDER_DEFINE(priv); SDT_PROBE_DEFINE1(priv, kernel, priv_check, priv__ok, "int"); diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c index 4700e68e53c32..dba6a43150484 100644 --- a/sys/kern/kern_shutdown.c +++ b/sys/kern/kern_shutdown.c @@ -90,10 +90,9 @@ __FBSDID("$FreeBSD$"); #define PANIC_REBOOT_WAIT_TIME 15 /* default to 15 seconds */ #endif static int panic_reboot_wait_time = PANIC_REBOOT_WAIT_TIME; -SYSCTL_INT(_kern, OID_AUTO, panic_reboot_wait_time, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_kern, OID_AUTO, panic_reboot_wait_time, CTLFLAG_RWTUN, &panic_reboot_wait_time, 0, "Seconds to wait before rebooting after a panic"); -TUNABLE_INT("kern.panic_reboot_wait_time", &panic_reboot_wait_time); /* * Note that stdarg.h and the ANSI style va_start macro is used for both @@ -108,9 +107,8 @@ int debugger_on_panic = 0; int debugger_on_panic = 1; #endif SYSCTL_INT(_debug, OID_AUTO, debugger_on_panic, - CTLFLAG_RW | CTLFLAG_SECURE | CTLFLAG_TUN, + CTLFLAG_RWTUN | CTLFLAG_SECURE, &debugger_on_panic, 0, "Run debugger on kernel panic"); -TUNABLE_INT("debug.debugger_on_panic", &debugger_on_panic); #ifdef KDB_TRACE static int trace_on_panic = 1; @@ -118,15 +116,13 @@ static int trace_on_panic = 1; static int trace_on_panic = 0; #endif SYSCTL_INT(_debug, OID_AUTO, trace_on_panic, - CTLFLAG_RW | CTLFLAG_SECURE | CTLFLAG_TUN, + CTLFLAG_RWTUN | CTLFLAG_SECURE, &trace_on_panic, 0, "Print stack trace on kernel panic"); -TUNABLE_INT("debug.trace_on_panic", &trace_on_panic); #endif /* KDB */ static int sync_on_panic = 0; -SYSCTL_INT(_kern, OID_AUTO, sync_on_panic, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_kern, OID_AUTO, sync_on_panic, CTLFLAG_RWTUN, &sync_on_panic, 0, "Do a sync before rebooting from a panic"); -TUNABLE_INT("kern.sync_on_panic", &sync_on_panic); static SYSCTL_NODE(_kern, OID_AUTO, shutdown, CTLFLAG_RW, 0, "Shutdown environment"); @@ -559,43 +555,35 @@ static int kassert_warnings = 0; SYSCTL_NODE(_debug, OID_AUTO, kassert, CTLFLAG_RW, NULL, "kassert options"); -SYSCTL_INT(_debug_kassert, OID_AUTO, warn_only, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_debug_kassert, OID_AUTO, warn_only, CTLFLAG_RWTUN, &kassert_warn_only, 0, "KASSERT triggers a panic (1) or just a warning (0)"); -TUNABLE_INT("debug.kassert.warn_only", &kassert_warn_only); #ifdef KDB -SYSCTL_INT(_debug_kassert, OID_AUTO, do_kdb, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_debug_kassert, OID_AUTO, do_kdb, CTLFLAG_RWTUN, &kassert_do_kdb, 0, "KASSERT will enter the debugger"); -TUNABLE_INT("debug.kassert.do_kdb", &kassert_do_kdb); #endif #ifdef KTR -SYSCTL_UINT(_debug_kassert, OID_AUTO, do_ktr, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_UINT(_debug_kassert, OID_AUTO, do_ktr, CTLFLAG_RWTUN, &kassert_do_ktr, 0, "KASSERT does a KTR, set this to the KTRMASK you want"); -TUNABLE_INT("debug.kassert.do_ktr", &kassert_do_ktr); #endif -SYSCTL_INT(_debug_kassert, OID_AUTO, do_log, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_debug_kassert, OID_AUTO, do_log, CTLFLAG_RWTUN, &kassert_do_log, 0, "KASSERT triggers a panic (1) or just a warning (0)"); -TUNABLE_INT("debug.kassert.do_log", &kassert_do_log); -SYSCTL_INT(_debug_kassert, OID_AUTO, warnings, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_debug_kassert, OID_AUTO, warnings, CTLFLAG_RWTUN, &kassert_warnings, 0, "number of KASSERTs that have been triggered"); -TUNABLE_INT("debug.kassert.warnings", &kassert_warnings); -SYSCTL_INT(_debug_kassert, OID_AUTO, log_panic_at, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_debug_kassert, OID_AUTO, log_panic_at, CTLFLAG_RWTUN, &kassert_log_panic_at, 0, "max number of KASSERTS before we will panic"); -TUNABLE_INT("debug.kassert.log_panic_at", &kassert_log_panic_at); -SYSCTL_INT(_debug_kassert, OID_AUTO, log_pps_limit, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_debug_kassert, OID_AUTO, log_pps_limit, CTLFLAG_RWTUN, &kassert_log_pps_limit, 0, "limit number of log messages per second"); -TUNABLE_INT("debug.kassert.log_pps_limit", &kassert_log_pps_limit); -SYSCTL_INT(_debug_kassert, OID_AUTO, log_mute_at, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_debug_kassert, OID_AUTO, log_mute_at, CTLFLAG_RWTUN, &kassert_log_mute_at, 0, "max number of KASSERTS to log"); -TUNABLE_INT("debug.kassert.log_mute_at", &kassert_log_mute_at); static int kassert_sysctl_kassert(SYSCTL_HANDLER_ARGS); diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index b405779905f66..67845a25d1b56 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -136,8 +136,7 @@ SYSCTL_INT(_kern_sigqueue, OID_AUTO, max_pending_per_proc, CTLFLAG_RW, &max_pending_per_proc, 0, "Max pending signals per proc"); static int preallocate_siginfo = 1024; -TUNABLE_INT("kern.sigqueue.preallocate", &preallocate_siginfo); -SYSCTL_INT(_kern_sigqueue, OID_AUTO, preallocate, CTLFLAG_RD, +SYSCTL_INT(_kern_sigqueue, OID_AUTO, preallocate, CTLFLAG_RDTUN, &preallocate_siginfo, 0, "Preallocated signal memory size"); static int signal_overflow = 0; @@ -163,13 +162,11 @@ SYSINIT(signal, SI_SUB_P1003_1B, SI_ORDER_FIRST+3, sigqueue_start, NULL); (cr1)->cr_uid == (cr2)->cr_uid) static int sugid_coredump; -TUNABLE_INT("kern.sugid_coredump", &sugid_coredump); -SYSCTL_INT(_kern, OID_AUTO, sugid_coredump, CTLFLAG_RW, +SYSCTL_INT(_kern, OID_AUTO, sugid_coredump, CTLFLAG_RWTUN, &sugid_coredump, 0, "Allow setuid and setgid processes to dump core"); static int capmode_coredump; -TUNABLE_INT("kern.capmode_coredump", &capmode_coredump); -SYSCTL_INT(_kern, OID_AUTO, capmode_coredump, CTLFLAG_RW, +SYSCTL_INT(_kern, OID_AUTO, capmode_coredump, CTLFLAG_RWTUN, &capmode_coredump, 0, "Allow processes in capability mode to dump core"); static int do_coredump = 1; @@ -3052,8 +3049,7 @@ SYSCTL_INT(_kern, OID_AUTO, compress_user_cores_gzlevel, CTLFLAG_RW, #endif static char corefilename[MAXPATHLEN] = {"%N.core"}; -TUNABLE_STR("kern.corefile", corefilename, sizeof(corefilename)); -SYSCTL_STRING(_kern, OID_AUTO, corefile, CTLFLAG_RW, corefilename, +SYSCTL_STRING(_kern, OID_AUTO, corefile, CTLFLAG_RWTUN, corefilename, sizeof(corefilename), "Process corefile name format string"); /* diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index fec4aeabe1f56..cb5a266e4e218 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -98,10 +98,13 @@ static struct sx sysctlmemlock; static int sysctl_root(SYSCTL_HANDLER_ARGS); -struct sysctl_oid_list sysctl__children; /* root list */ +/* Root list */ +struct sysctl_oid_list sysctl__children = SLIST_HEAD_INITIALIZER(&sysctl__children); static int sysctl_remove_oid_locked(struct sysctl_oid *oidp, int del, int recurse); +static int sysctl_old_kernel(struct sysctl_req *, const void *, size_t); +static int sysctl_new_kernel(struct sysctl_req *, void *, size_t); static struct sysctl_oid * sysctl_find_oidname(const char *name, struct sysctl_oid_list *list) @@ -136,6 +139,118 @@ sysctl_unlock(void) SYSCTL_XUNLOCK(); } +static int +sysctl_root_handler_locked(struct sysctl_oid *oid, void *arg1, intptr_t arg2, + struct sysctl_req *req) +{ + int error; + + oid->oid_running++; + SYSCTL_XUNLOCK(); + + if (!(oid->oid_kind & CTLFLAG_MPSAFE)) + mtx_lock(&Giant); + error = oid->oid_handler(oid, arg1, arg2, req); + if (!(oid->oid_kind & CTLFLAG_MPSAFE)) + mtx_unlock(&Giant); + + SYSCTL_XLOCK(); + oid->oid_running--; + if (oid->oid_running == 0 && (oid->oid_kind & CTLFLAG_DYING) != 0) + wakeup(&oid->oid_running); + + return (error); +} + +static void +sysctl_load_tunable_by_oid_locked(struct sysctl_oid *oidp) +{ + struct sysctl_req req; + struct sysctl_oid *curr; + char *penv; + char path[64]; + ssize_t rem = sizeof(path); + ssize_t len; + int val_int; + long val_long; + int64_t val_64; + int error; + + path[--rem] = 0; + + for (curr = oidp; curr != NULL; curr = SYSCTL_PARENT(curr)) { + len = strlen(curr->oid_name); + rem -= len; + if (curr != oidp) + rem -= 1; + if (rem < 0) { + printf("OID path exceeds %d bytes\n", (int)sizeof(path)); + return; + } + memcpy(path + rem, curr->oid_name, len); + if (curr != oidp) + path[rem + len] = '.'; + } + + penv = getenv(path + rem); + if (penv == NULL) + return; + + memset(&req, 0, sizeof(req)); + + req.td = curthread; + req.oldfunc = sysctl_old_kernel; + req.newfunc = sysctl_new_kernel; + req.lock = REQ_UNWIRED; + + switch (oidp->oid_kind & CTLTYPE) { + case CTLTYPE_INT: + val_int = strtoq(penv, NULL, 0); + req.newlen = sizeof(val_int); + req.newptr = &val_int; + break; + case CTLTYPE_UINT: + val_int = strtouq(penv, NULL, 0); + req.newlen = sizeof(val_int); + req.newptr = &val_int; + break; + case CTLTYPE_LONG: + val_long = strtoq(penv, NULL, 0); + req.newlen = sizeof(val_long); + req.newptr = &val_long; + break; + case CTLTYPE_ULONG: + val_long = strtouq(penv, NULL, 0); + req.newlen = sizeof(val_long); + req.newptr = &val_long; + break; + case CTLTYPE_S64: + val_64 = strtoq(penv, NULL, 0); + req.newlen = sizeof(val_64); + req.newptr = &val_64; + break; + case CTLTYPE_U64: + val_64 = strtouq(penv, NULL, 0); + req.newlen = sizeof(val_64); + req.newptr = &val_64; + break; + case CTLTYPE_STRING: + req.newlen = strlen(penv); + req.newptr = penv; + break; + default: + freeenv(penv); + return; + } + error = sysctl_root_handler_locked(oidp, oidp->oid_arg1, + oidp->oid_arg2, &req); + if (error != 0) { + printf("Setting sysctl '%s' to '%s' failed: %d\n", + path, penv, error); + } + freeenv(penv); +} + void sysctl_register_oid(struct sysctl_oid *oidp) { @@ -192,6 +307,15 @@ sysctl_register_oid(struct sysctl_oid *oidp) SLIST_INSERT_AFTER(q, oidp, oid_link); else SLIST_INSERT_HEAD(parent, oidp, oid_link); + + if ((oidp->oid_kind & CTLTYPE) != CTLTYPE_NODE && +#ifdef VIMAGE + (oidp->oid_kind & CTLFLAG_VNET) == 0 && +#endif + (oidp->oid_kind & CTLFLAG_TUN) != 0 && + (oidp->oid_kind & CTLFLAG_NOFETCH) == 0) { + sysctl_load_tunable_by_oid_locked(oidp); + } } void @@ -423,8 +547,6 @@ sysctl_remove_oid_locked(struct sysctl_oid *oidp, int del, int recurse) if (error) return (error); } - if (del) - free(SYSCTL_CHILDREN(oidp), M_SYSCTLOID); } } if (oidp->oid_refcnt > 1 ) { @@ -489,24 +611,16 @@ sysctl_add_oid(struct sysctl_ctx_list *clist, struct sysctl_oid_list *parent, } oidp = malloc(sizeof(struct sysctl_oid), M_SYSCTLOID, M_WAITOK|M_ZERO); oidp->oid_parent = parent; - SLIST_NEXT(oidp, oid_link) = NULL; + SLIST_INIT(&oidp->oid_children); oidp->oid_number = number; oidp->oid_refcnt = 1; oidp->oid_name = strdup(name, M_SYSCTLOID); oidp->oid_handler = handler; oidp->oid_kind = CTLFLAG_DYN | kind; - if ((kind & CTLTYPE) == CTLTYPE_NODE) { - /* Allocate space for children */ - SYSCTL_CHILDREN_SET(oidp, malloc(sizeof(struct sysctl_oid_list), - M_SYSCTLOID, M_WAITOK)); - SLIST_INIT(SYSCTL_CHILDREN(oidp)); - oidp->oid_arg2 = arg2; - } else { - oidp->oid_arg1 = arg1; - oidp->oid_arg2 = arg2; - } + oidp->oid_arg1 = arg1; + oidp->oid_arg2 = arg2; oidp->oid_fmt = fmt; - if (descr) + if (descr != NULL) oidp->oid_descr = strdup(descr, M_SYSCTLOID); /* Update the context, if used */ if (clist != NULL) @@ -577,7 +691,7 @@ sysctl_register_all(void *arg) sysctl_register_oid(*oidp); SYSCTL_XUNLOCK(); } -SYSINIT(sysctl, SI_SUB_KMEM, SI_ORDER_ANY, sysctl_register_all, 0); +SYSINIT(sysctl, SI_SUB_KMEM, SI_ORDER_FIRST, sysctl_register_all, 0); /* * "Staff-functions" @@ -625,7 +739,7 @@ sysctl_sysctl_debug_dump_node(struct sysctl_oid_list *l, int i) printf(" Node\n"); if (!oidp->oid_handler) { sysctl_sysctl_debug_dump_node( - oidp->oid_arg1, i+2); + SYSCTL_CHILDREN(oidp), i + 2); } break; case CTLTYPE_INT: printf(" Int\n"); break; @@ -1093,26 +1207,28 @@ sysctl_handle_64(SYSCTL_HANDLER_ARGS) int sysctl_handle_string(SYSCTL_HANDLER_ARGS) { - int error=0; - char *tmparg; size_t outlen; + int error = 0; - /* - * Attempt to get a coherent snapshot by copying to a - * temporary kernel buffer. - */ -retry: - outlen = strlen((char *)arg1)+1; - tmparg = malloc(outlen, M_SYSCTLTMP, M_WAITOK); + /* check for zero-length buffer */ + if (arg2 == 0) + return (ENOMEM); - if (strlcpy(tmparg, (char *)arg1, outlen) >= outlen) { - free(tmparg, M_SYSCTLTMP); - goto retry; - } + if (req->oldptr != NULL) { + char *tmparg; + + /* try to make a coherent snapshot of the string */ + tmparg = malloc(arg2, M_SYSCTLTMP, M_WAITOK); + memcpy(tmparg, arg1, arg2); - error = SYSCTL_OUT(req, tmparg, outlen); - free(tmparg, M_SYSCTLTMP); + outlen = strnlen(tmparg, arg2 - 1) + 1; + error = SYSCTL_OUT(req, tmparg, outlen); + free(tmparg, M_SYSCTLTMP); + } else { + outlen = strnlen((char *)arg1, arg2 - 1) + 1; + error = SYSCTL_OUT(req, NULL, outlen); + } if (error || !req->newptr) return (error); @@ -1123,7 +1239,6 @@ retry: error = SYSCTL_IN(req, arg1, arg2); ((char *)arg1)[arg2] = '\0'; } - return (error); } @@ -1489,24 +1604,14 @@ sysctl_root(SYSCTL_HANDLER_ARGS) if (error != 0) return (error); #endif - oid->oid_running++; - SYSCTL_XUNLOCK(); #ifdef VIMAGE if ((oid->oid_kind & CTLFLAG_VNET) && arg1 != NULL) arg1 = (void *)(curvnet->vnet_data_base + (uintptr_t)arg1); #endif - if (!(oid->oid_kind & CTLFLAG_MPSAFE)) - mtx_lock(&Giant); - error = oid->oid_handler(oid, arg1, arg2, req); - if (!(oid->oid_kind & CTLFLAG_MPSAFE)) - mtx_unlock(&Giant); + error = sysctl_root_handler_locked(oid, arg1, arg2, req); KFAIL_POINT_ERROR(_debug_fail_point, sysctl_running, error); - SYSCTL_XLOCK(); - oid->oid_running--; - if (oid->oid_running == 0 && (oid->oid_kind & CTLFLAG_DYING) != 0) - wakeup(&oid->oid_running); return (error); } diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index 9fe7ebe6b3610..78ceff2ad5be5 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -128,10 +128,9 @@ struct bintime tc_tick_bt; sbintime_t tc_tick_sbt; int tc_precexp; int tc_timepercentage = TC_DEFAULTPERC; -TUNABLE_INT("kern.timecounter.alloweddeviation", &tc_timepercentage); static int sysctl_kern_timecounter_adjprecision(SYSCTL_HANDLER_ARGS); SYSCTL_PROC(_kern_timecounter, OID_AUTO, alloweddeviation, - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 0, + CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, 0, 0, sysctl_kern_timecounter_adjprecision, "I", "Allowed time interval deviation in percents"); @@ -1794,7 +1793,10 @@ sysctl_kern_timecounter_adjprecision(SYSCTL_HANDLER_ARGS) if (error != 0 || req->newptr == NULL) return (error); tc_timepercentage = val; + if (cold) + goto done; tc_adjprecision(); +done: return (0); } diff --git a/sys/kern/kern_timeout.c b/sys/kern/kern_timeout.c index eee54745aac70..905e24a13819b 100644 --- a/sys/kern/kern_timeout.c +++ b/sys/kern/kern_timeout.c @@ -101,15 +101,15 @@ SYSCTL_INT(_debug, OID_AUTO, to_avg_mpcalls_dir, CTLFLAG_RD, &avg_mpcalls_dir, #endif static int ncallout; -SYSCTL_INT(_kern, OID_AUTO, ncallout, CTLFLAG_RDTUN, &ncallout, 0, +SYSCTL_INT(_kern, OID_AUTO, ncallout, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &ncallout, 0, "Number of entries in callwheel and size of timeout() preallocation"); static int pin_default_swi = 0; static int pin_pcpu_swi = 0; -SYSCTL_INT(_kern, OID_AUTO, pin_default_swi, CTLFLAG_RDTUN, &pin_default_swi, +SYSCTL_INT(_kern, OID_AUTO, pin_default_swi, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &pin_default_swi, 0, "Pin the default (non-per-cpu) swi (shared with PCPU 0 swi)"); -SYSCTL_INT(_kern, OID_AUTO, pin_pcpu_swi, CTLFLAG_RDTUN, &pin_pcpu_swi, +SYSCTL_INT(_kern, OID_AUTO, pin_pcpu_swi, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &pin_pcpu_swi, 0, "Pin the per-CPU swis (except PCPU 0, which is also default"); /* diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index 53b10ec1fa205..eb54445c4c037 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -63,7 +63,7 @@ __FBSDID("$FreeBSD$"); #include SYSCTL_NODE(_hw, OID_AUTO, bus, CTLFLAG_RW, NULL, NULL); -SYSCTL_NODE(, OID_AUTO, dev, CTLFLAG_RW, NULL, NULL); +SYSCTL_ROOT_NODE(OID_AUTO, dev, CTLFLAG_RW, NULL, NULL); /* * Used to attach drivers to devclasses. @@ -149,9 +149,8 @@ static MALLOC_DEFINE(M_BUS_SC, "bus-sc", "Bus data structures, softc"); #ifdef BUS_DEBUG static int bus_debug = 1; -TUNABLE_INT("bus.debug", &bus_debug); -SYSCTL_INT(_debug, OID_AUTO, bus_debug, CTLFLAG_RW, &bus_debug, 0, - "Debug bus code"); +SYSCTL_INT(_debug, OID_AUTO, bus_debug, CTLFLAG_RWTUN, &bus_debug, 0, + "Bus debug level"); #define PDEBUG(a) if (bus_debug) {printf("%s:%d: ", __func__, __LINE__), printf a; printf("\n");} #define DEVICENAME(d) ((d)? device_get_name(d): "no device") @@ -357,16 +356,14 @@ device_sysctl_fini(device_t dev) /* Deprecated way to adjust queue length */ static int sysctl_devctl_disable(SYSCTL_HANDLER_ARGS); -/* XXX Need to support old-style tunable hw.bus.devctl_disable" */ -SYSCTL_PROC(_hw_bus, OID_AUTO, devctl_disable, CTLTYPE_INT | CTLFLAG_RW | +SYSCTL_PROC(_hw_bus, OID_AUTO, devctl_disable, CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, NULL, 0, sysctl_devctl_disable, "I", "devctl disable -- deprecated"); #define DEVCTL_DEFAULT_QUEUE_LEN 1000 static int sysctl_devctl_queue(SYSCTL_HANDLER_ARGS); static int devctl_queue_length = DEVCTL_DEFAULT_QUEUE_LEN; -TUNABLE_INT("hw.bus.devctl_queue", &devctl_queue_length); -SYSCTL_PROC(_hw_bus, OID_AUTO, devctl_queue, CTLTYPE_INT | CTLFLAG_RW | +SYSCTL_PROC(_hw_bus, OID_AUTO, devctl_queue, CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, NULL, 0, sysctl_devctl_queue, "I", "devctl queue length"); static d_open_t devopen; @@ -791,11 +788,12 @@ sysctl_devctl_disable(SYSCTL_HANDLER_ARGS) struct dev_event_info *n1; int dis, error; - dis = devctl_queue_length == 0; + dis = (devctl_queue_length == 0); error = sysctl_handle_int(oidp, &dis, 0, req); if (error || !req->newptr) return (error); - mtx_lock(&devsoftc.mtx); + if (mtx_initialized(&devsoftc.mtx)) + mtx_lock(&devsoftc.mtx); if (dis) { while (!TAILQ_EMPTY(&devsoftc.devq)) { n1 = TAILQ_FIRST(&devsoftc.devq); @@ -808,7 +806,8 @@ sysctl_devctl_disable(SYSCTL_HANDLER_ARGS) } else { devctl_queue_length = DEVCTL_DEFAULT_QUEUE_LEN; } - mtx_unlock(&devsoftc.mtx); + if (mtx_initialized(&devsoftc.mtx)) + mtx_unlock(&devsoftc.mtx); return (0); } @@ -824,7 +823,8 @@ sysctl_devctl_queue(SYSCTL_HANDLER_ARGS) return (error); if (q < 0) return (EINVAL); - mtx_lock(&devsoftc.mtx); + if (mtx_initialized(&devsoftc.mtx)) + mtx_lock(&devsoftc.mtx); devctl_queue_length = q; while (devsoftc.queued > devctl_queue_length) { n1 = TAILQ_FIRST(&devsoftc.devq); @@ -833,7 +833,8 @@ sysctl_devctl_queue(SYSCTL_HANDLER_ARGS) free(n1, M_BUS); devsoftc.queued--; } - mtx_unlock(&devsoftc.mtx); + if (mtx_initialized(&devsoftc.mtx)) + mtx_unlock(&devsoftc.mtx); return (0); } diff --git a/sys/kern/subr_kdb.c b/sys/kern/subr_kdb.c index a7ed944a61fbc..c26d271663f60 100644 --- a/sys/kern/subr_kdb.c +++ b/sys/kern/subr_kdb.c @@ -108,14 +108,12 @@ SYSCTL_PROC(_debug_kdb, OID_AUTO, trap_code, kdb_sysctl_trap_code, "I", "set to cause a page fault via code access"); SYSCTL_INT(_debug_kdb, OID_AUTO, break_to_debugger, - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_TUN | CTLFLAG_SECURE, + CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_SECURE, &kdb_break_to_debugger, 0, "Enable break to debugger"); -TUNABLE_INT("debug.kdb.break_to_debugger", &kdb_break_to_debugger); SYSCTL_INT(_debug_kdb, OID_AUTO, alt_break_to_debugger, - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_TUN | CTLFLAG_SECURE, + CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_SECURE, &kdb_alt_break_to_debugger, 0, "Enable alternative break to debugger"); -TUNABLE_INT("debug.kdb.alt_break_to_debugger", &kdb_alt_break_to_debugger); /* * Flag to indicate to debuggers why the debugger was entered. diff --git a/sys/kern/subr_msgbuf.c b/sys/kern/subr_msgbuf.c index ecdbe722ddc64..fa23c91f658f1 100644 --- a/sys/kern/subr_msgbuf.c +++ b/sys/kern/subr_msgbuf.c @@ -53,9 +53,8 @@ static u_int msgbuf_cksum(struct msgbuf *mbp); * or other actions occured. */ static int msgbuf_show_timestamp = 0; -SYSCTL_INT(_kern, OID_AUTO, msgbuf_show_timestamp, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_kern, OID_AUTO, msgbuf_show_timestamp, CTLFLAG_RWTUN, &msgbuf_show_timestamp, 0, "Show timestamp in msgbuf"); -TUNABLE_INT("kern.msgbuf_show_timestamp", &msgbuf_show_timestamp); /* * Initialize a message buffer of the specified size at the specified diff --git a/sys/kern/subr_param.c b/sys/kern/subr_param.c index afd3eacc71786..f589097ffb74f 100644 --- a/sys/kern/subr_param.c +++ b/sys/kern/subr_param.c @@ -107,32 +107,32 @@ u_long dflssiz; /* initial stack size limit */ u_long maxssiz; /* max stack size */ u_long sgrowsiz; /* amount to grow stack */ -SYSCTL_INT(_kern, OID_AUTO, hz, CTLFLAG_RDTUN, &hz, 0, +SYSCTL_INT(_kern, OID_AUTO, hz, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &hz, 0, "Number of clock ticks per second"); -SYSCTL_INT(_kern, OID_AUTO, nbuf, CTLFLAG_RDTUN, &nbuf, 0, +SYSCTL_INT(_kern, OID_AUTO, nbuf, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &nbuf, 0, "Number of buffers in the buffer cache"); -SYSCTL_INT(_kern, OID_AUTO, nswbuf, CTLFLAG_RDTUN, &nswbuf, 0, +SYSCTL_INT(_kern, OID_AUTO, nswbuf, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &nswbuf, 0, "Number of swap buffers"); -SYSCTL_INT(_kern, OID_AUTO, msgbufsize, CTLFLAG_RDTUN, &msgbufsize, 0, +SYSCTL_INT(_kern, OID_AUTO, msgbufsize, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &msgbufsize, 0, "Size of the kernel message buffer"); -SYSCTL_LONG(_kern, OID_AUTO, maxswzone, CTLFLAG_RDTUN, &maxswzone, 0, +SYSCTL_LONG(_kern, OID_AUTO, maxswzone, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &maxswzone, 0, "Maximum memory for swap metadata"); -SYSCTL_LONG(_kern, OID_AUTO, maxbcache, CTLFLAG_RDTUN, &maxbcache, 0, +SYSCTL_LONG(_kern, OID_AUTO, maxbcache, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &maxbcache, 0, "Maximum value of vfs.maxbufspace"); -SYSCTL_INT(_kern, OID_AUTO, bio_transient_maxcnt, CTLFLAG_RDTUN, +SYSCTL_INT(_kern, OID_AUTO, bio_transient_maxcnt, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &bio_transient_maxcnt, 0, "Maximum number of transient BIOs mappings"); -SYSCTL_ULONG(_kern, OID_AUTO, maxtsiz, CTLFLAG_RW | CTLFLAG_TUN, &maxtsiz, 0, +SYSCTL_ULONG(_kern, OID_AUTO, maxtsiz, CTLFLAG_RWTUN | CTLFLAG_NOFETCH, &maxtsiz, 0, "Maximum text size"); -SYSCTL_ULONG(_kern, OID_AUTO, dfldsiz, CTLFLAG_RW | CTLFLAG_TUN, &dfldsiz, 0, +SYSCTL_ULONG(_kern, OID_AUTO, dfldsiz, CTLFLAG_RWTUN | CTLFLAG_NOFETCH, &dfldsiz, 0, "Initial data size limit"); -SYSCTL_ULONG(_kern, OID_AUTO, maxdsiz, CTLFLAG_RW | CTLFLAG_TUN, &maxdsiz, 0, +SYSCTL_ULONG(_kern, OID_AUTO, maxdsiz, CTLFLAG_RWTUN | CTLFLAG_NOFETCH, &maxdsiz, 0, "Maximum data size"); -SYSCTL_ULONG(_kern, OID_AUTO, dflssiz, CTLFLAG_RW | CTLFLAG_TUN, &dflssiz, 0, +SYSCTL_ULONG(_kern, OID_AUTO, dflssiz, CTLFLAG_RWTUN | CTLFLAG_NOFETCH, &dflssiz, 0, "Initial stack size limit"); -SYSCTL_ULONG(_kern, OID_AUTO, maxssiz, CTLFLAG_RW | CTLFLAG_TUN, &maxssiz, 0, +SYSCTL_ULONG(_kern, OID_AUTO, maxssiz, CTLFLAG_RWTUN | CTLFLAG_NOFETCH, &maxssiz, 0, "Maximum stack size"); -SYSCTL_ULONG(_kern, OID_AUTO, sgrowsiz, CTLFLAG_RW | CTLFLAG_TUN, &sgrowsiz, 0, +SYSCTL_ULONG(_kern, OID_AUTO, sgrowsiz, CTLFLAG_RWTUN | CTLFLAG_NOFETCH, &sgrowsiz, 0, "Amount to grow stack on a stack fault"); SYSCTL_PROC(_kern, OID_AUTO, vm_guest, CTLFLAG_RD | CTLTYPE_STRING, NULL, 0, sysctl_kern_vm_guest, "A", diff --git a/sys/kern/subr_prf.c b/sys/kern/subr_prf.c index 28e33a4b4b2b1..814e57f479474 100644 --- a/sys/kern/subr_prf.c +++ b/sys/kern/subr_prf.c @@ -102,23 +102,20 @@ static void snprintf_func(int ch, void *arg); static int msgbufmapped; /* Set when safe to use msgbuf */ int msgbuftrigger; -static int log_console_output = 1; -TUNABLE_INT("kern.log_console_output", &log_console_output); -SYSCTL_INT(_kern, OID_AUTO, log_console_output, CTLFLAG_RW, - &log_console_output, 0, "Duplicate console output to the syslog."); +static int log_console_output = 1; +SYSCTL_INT(_kern, OID_AUTO, log_console_output, CTLFLAG_RWTUN, + &log_console_output, 0, "Duplicate console output to the syslog"); /* * See the comment in log_console() below for more explanation of this. */ -static int log_console_add_linefeed = 0; -TUNABLE_INT("kern.log_console_add_linefeed", &log_console_add_linefeed); -SYSCTL_INT(_kern, OID_AUTO, log_console_add_linefeed, CTLFLAG_RW, - &log_console_add_linefeed, 0, "log_console() adds extra newlines."); - -static int always_console_output = 0; -TUNABLE_INT("kern.always_console_output", &always_console_output); -SYSCTL_INT(_kern, OID_AUTO, always_console_output, CTLFLAG_RW, - &always_console_output, 0, "Always output to console despite TIOCCONS."); +static int log_console_add_linefeed; +SYSCTL_INT(_kern, OID_AUTO, log_console_add_linefeed, CTLFLAG_RWTUN, + &log_console_add_linefeed, 0, "log_console() adds extra newlines"); + +static int always_console_output; +SYSCTL_INT(_kern, OID_AUTO, always_console_output, CTLFLAG_RWTUN, + &always_console_output, 0, "Always output to console despite TIOCCONS"); /* * Warn that a system table is full. diff --git a/sys/kern/subr_rman.c b/sys/kern/subr_rman.c index c466b44b0fcd4..53480bf31b85f 100644 --- a/sys/kern/subr_rman.c +++ b/sys/kern/subr_rman.c @@ -100,8 +100,7 @@ struct resource_i { }; static int rman_debug = 0; -TUNABLE_INT("debug.rman_debug", &rman_debug); -SYSCTL_INT(_debug, OID_AUTO, rman_debug, CTLFLAG_RW, +SYSCTL_INT(_debug, OID_AUTO, rman_debug, CTLFLAG_RWTUN, &rman_debug, 0, "rman debug"); #define DPRINTF(params) if (rman_debug) printf params diff --git a/sys/kern/subr_smp.c b/sys/kern/subr_smp.c index 122fc4c5fede6..90bbc5fd22a1c 100644 --- a/sys/kern/subr_smp.c +++ b/sys/kern/subr_smp.c @@ -87,16 +87,14 @@ SYSCTL_PROC(_kern_smp, OID_AUTO, active, CTLFLAG_RD | CTLTYPE_INT, NULL, 0, int smp_disabled = 0; /* has smp been disabled? */ SYSCTL_INT(_kern_smp, OID_AUTO, disabled, CTLFLAG_RDTUN|CTLFLAG_CAPRD, &smp_disabled, 0, "SMP has been disabled from the loader"); -TUNABLE_INT("kern.smp.disabled", &smp_disabled); int smp_cpus = 1; /* how many cpu's running */ SYSCTL_INT(_kern_smp, OID_AUTO, cpus, CTLFLAG_RD|CTLFLAG_CAPRD, &smp_cpus, 0, "Number of CPUs online"); int smp_topology = 0; /* Which topology we're using. */ -SYSCTL_INT(_kern_smp, OID_AUTO, topology, CTLFLAG_RD, &smp_topology, 0, +SYSCTL_INT(_kern_smp, OID_AUTO, topology, CTLFLAG_RDTUN, &smp_topology, 0, "Topology override setting; 0 is default provided by hardware."); -TUNABLE_INT("kern.smp.topology", &smp_topology); #ifdef SMP /* Enable forwarding of a signal to a process running on a different CPU */ diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c index 86e1b16015e05..4ba4cf18607e4 100644 --- a/sys/kern/subr_witness.c +++ b/sys/kern/subr_witness.c @@ -380,8 +380,7 @@ static SYSCTL_NODE(_debug, OID_AUTO, witness, CTLFLAG_RW, NULL, * completely disabled. */ static int witness_watch = 1; -TUNABLE_INT("debug.witness.watch", &witness_watch); -SYSCTL_PROC(_debug_witness, OID_AUTO, watch, CTLFLAG_RW | CTLTYPE_INT, NULL, 0, +SYSCTL_PROC(_debug_witness, OID_AUTO, watch, CTLFLAG_RWTUN | CTLTYPE_INT, NULL, 0, sysctl_debug_witness_watch, "I", "witness is watching lock operations"); #ifdef KDB @@ -396,8 +395,7 @@ int witness_kdb = 1; #else int witness_kdb = 0; #endif -TUNABLE_INT("debug.witness.kdb", &witness_kdb); -SYSCTL_INT(_debug_witness, OID_AUTO, kdb, CTLFLAG_RW, &witness_kdb, 0, ""); +SYSCTL_INT(_debug_witness, OID_AUTO, kdb, CTLFLAG_RWTUN, &witness_kdb, 0, ""); /* * When KDB is enabled and witness_trace is 1, it will cause the system @@ -406,8 +404,7 @@ SYSCTL_INT(_debug_witness, OID_AUTO, kdb, CTLFLAG_RW, &witness_kdb, 0, ""); * - locks are held when going to sleep. */ int witness_trace = 1; -TUNABLE_INT("debug.witness.trace", &witness_trace); -SYSCTL_INT(_debug_witness, OID_AUTO, trace, CTLFLAG_RW, &witness_trace, 0, ""); +SYSCTL_INT(_debug_witness, OID_AUTO, trace, CTLFLAG_RWTUN, &witness_trace, 0, ""); #endif /* KDB */ #ifdef WITNESS_SKIPSPIN @@ -415,9 +412,7 @@ int witness_skipspin = 1; #else int witness_skipspin = 0; #endif -TUNABLE_INT("debug.witness.skipspin", &witness_skipspin); -SYSCTL_INT(_debug_witness, OID_AUTO, skipspin, CTLFLAG_RDTUN, &witness_skipspin, - 0, ""); +SYSCTL_INT(_debug_witness, OID_AUTO, skipspin, CTLFLAG_RDTUN, &witness_skipspin, 0, ""); /* * Call this to print out the relations between locks. diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c index f3c3c0e01d611..01cfeb9c1ffdd 100644 --- a/sys/kern/sys_pipe.c +++ b/sys/kern/sys_pipe.c @@ -205,7 +205,7 @@ static int pipeallocfail; static int piperesizefail; static int piperesizeallowed = 1; -SYSCTL_LONG(_kern_ipc, OID_AUTO, maxpipekva, CTLFLAG_RDTUN, +SYSCTL_LONG(_kern_ipc, OID_AUTO, maxpipekva, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &maxpipekva, 0, "Pipe KVA limit"); SYSCTL_LONG(_kern_ipc, OID_AUTO, pipekva, CTLFLAG_RD, &amountpipekva, 0, "Pipe KVA usage"); diff --git a/sys/kern/sysv_msg.c b/sys/kern/sysv_msg.c index d58cb7e791e8f..a572a0e0c1451 100644 --- a/sys/kern/sysv_msg.c +++ b/sys/kern/sysv_msg.c @@ -196,13 +196,7 @@ msginit() { int i, error; - TUNABLE_INT_FETCH("kern.ipc.msgseg", &msginfo.msgseg); - TUNABLE_INT_FETCH("kern.ipc.msgssz", &msginfo.msgssz); msginfo.msgmax = msginfo.msgseg * msginfo.msgssz; - TUNABLE_INT_FETCH("kern.ipc.msgmni", &msginfo.msgmni); - TUNABLE_INT_FETCH("kern.ipc.msgmnb", &msginfo.msgmnb); - TUNABLE_INT_FETCH("kern.ipc.msgtql", &msginfo.msgtql); - msgpool = malloc(msginfo.msgmax, M_MSG, M_WAITOK); msgmaps = malloc(sizeof(struct msgmap) * msginfo.msgseg, M_MSG, M_WAITOK); msghdrs = malloc(sizeof(struct msg) * msginfo.msgtql, M_MSG, M_WAITOK); diff --git a/sys/kern/sysv_sem.c b/sys/kern/sysv_sem.c index f9ff2170dc32f..c63290240799e 100644 --- a/sys/kern/sysv_sem.c +++ b/sys/kern/sysv_sem.c @@ -196,7 +196,7 @@ SYSCTL_INT(_kern_ipc, OID_AUTO, semmns, CTLFLAG_RDTUN, &seminfo.semmns, 0, "Maximum number of semaphores in the system"); SYSCTL_INT(_kern_ipc, OID_AUTO, semmnu, CTLFLAG_RDTUN, &seminfo.semmnu, 0, "Maximum number of undo structures in the system"); -SYSCTL_INT(_kern_ipc, OID_AUTO, semmsl, CTLFLAG_RW, &seminfo.semmsl, 0, +SYSCTL_INT(_kern_ipc, OID_AUTO, semmsl, CTLFLAG_RWTUN, &seminfo.semmsl, 0, "Max semaphores per id"); SYSCTL_INT(_kern_ipc, OID_AUTO, semopm, CTLFLAG_RDTUN, &seminfo.semopm, 0, "Max operations per semop call"); @@ -204,9 +204,9 @@ SYSCTL_INT(_kern_ipc, OID_AUTO, semume, CTLFLAG_RDTUN, &seminfo.semume, 0, "Max undo entries per process"); SYSCTL_INT(_kern_ipc, OID_AUTO, semusz, CTLFLAG_RDTUN, &seminfo.semusz, 0, "Size in bytes of undo structure"); -SYSCTL_INT(_kern_ipc, OID_AUTO, semvmx, CTLFLAG_RW, &seminfo.semvmx, 0, +SYSCTL_INT(_kern_ipc, OID_AUTO, semvmx, CTLFLAG_RWTUN, &seminfo.semvmx, 0, "Semaphore maximum value"); -SYSCTL_INT(_kern_ipc, OID_AUTO, semaem, CTLFLAG_RW, &seminfo.semaem, 0, +SYSCTL_INT(_kern_ipc, OID_AUTO, semaem, CTLFLAG_RWTUN, &seminfo.semaem, 0, "Adjust on exit max value"); SYSCTL_PROC(_kern_ipc, OID_AUTO, sema, CTLTYPE_OPAQUE | CTLFLAG_RD, NULL, 0, sysctl_sema, "", "Semaphore id pool"); @@ -249,16 +249,6 @@ seminit(void) { int i, error; - TUNABLE_INT_FETCH("kern.ipc.semmni", &seminfo.semmni); - TUNABLE_INT_FETCH("kern.ipc.semmns", &seminfo.semmns); - TUNABLE_INT_FETCH("kern.ipc.semmnu", &seminfo.semmnu); - TUNABLE_INT_FETCH("kern.ipc.semmsl", &seminfo.semmsl); - TUNABLE_INT_FETCH("kern.ipc.semopm", &seminfo.semopm); - TUNABLE_INT_FETCH("kern.ipc.semume", &seminfo.semume); - TUNABLE_INT_FETCH("kern.ipc.semusz", &seminfo.semusz); - TUNABLE_INT_FETCH("kern.ipc.semvmx", &seminfo.semvmx); - TUNABLE_INT_FETCH("kern.ipc.semaem", &seminfo.semaem); - sem = malloc(sizeof(struct sem) * seminfo.semmns, M_SEM, M_WAITOK); sema = malloc(sizeof(struct semid_kernel) * seminfo.semmni, M_SEM, M_WAITOK); diff --git a/sys/kern/sysv_shm.c b/sys/kern/sysv_shm.c index 4144d9431f9db..a7a7c167e5500 100644 --- a/sys/kern/sysv_shm.c +++ b/sys/kern/sysv_shm.c @@ -156,29 +156,29 @@ static int sysctl_shmsegs(SYSCTL_HANDLER_ARGS); #endif struct shminfo shminfo = { - SHMMAX, - SHMMIN, - SHMMNI, - SHMSEG, - SHMALL + .shmmax = SHMMAX, + .shmmin = SHMMIN, + .shmmni = SHMMNI, + .shmseg = SHMSEG, + .shmall = SHMALL }; static int shm_use_phys; static int shm_allow_removed; -SYSCTL_ULONG(_kern_ipc, OID_AUTO, shmmax, CTLFLAG_RW, &shminfo.shmmax, 0, +SYSCTL_ULONG(_kern_ipc, OID_AUTO, shmmax, CTLFLAG_RWTUN, &shminfo.shmmax, 0, "Maximum shared memory segment size"); -SYSCTL_ULONG(_kern_ipc, OID_AUTO, shmmin, CTLFLAG_RW, &shminfo.shmmin, 0, +SYSCTL_ULONG(_kern_ipc, OID_AUTO, shmmin, CTLFLAG_RWTUN, &shminfo.shmmin, 0, "Minimum shared memory segment size"); SYSCTL_ULONG(_kern_ipc, OID_AUTO, shmmni, CTLFLAG_RDTUN, &shminfo.shmmni, 0, "Number of shared memory identifiers"); SYSCTL_ULONG(_kern_ipc, OID_AUTO, shmseg, CTLFLAG_RDTUN, &shminfo.shmseg, 0, "Number of segments per process"); -SYSCTL_ULONG(_kern_ipc, OID_AUTO, shmall, CTLFLAG_RW, &shminfo.shmall, 0, +SYSCTL_ULONG(_kern_ipc, OID_AUTO, shmall, CTLFLAG_RWTUN, &shminfo.shmall, 0, "Maximum number of pages available for shared memory"); -SYSCTL_INT(_kern_ipc, OID_AUTO, shm_use_phys, CTLFLAG_RW, +SYSCTL_INT(_kern_ipc, OID_AUTO, shm_use_phys, CTLFLAG_RWTUN, &shm_use_phys, 0, "Enable/Disable locking of shared memory pages in core"); -SYSCTL_INT(_kern_ipc, OID_AUTO, shm_allow_removed, CTLFLAG_RW, +SYSCTL_INT(_kern_ipc, OID_AUTO, shm_allow_removed, CTLFLAG_RWTUN, &shm_allow_removed, 0, "Enable/Disable attachment to attached segments marked for removal"); SYSCTL_PROC(_kern_ipc, OID_AUTO, shmsegs, CTLTYPE_OPAQUE | CTLFLAG_RD, @@ -887,20 +887,14 @@ shminit() if (TUNABLE_ULONG_FETCH("kern.ipc.shmmaxpgs", &shminfo.shmall) != 0) printf("kern.ipc.shmmaxpgs is now called kern.ipc.shmall!\n"); #endif - TUNABLE_ULONG_FETCH("kern.ipc.shmall", &shminfo.shmall); - if (!TUNABLE_ULONG_FETCH("kern.ipc.shmmax", &shminfo.shmmax)) { + if (shminfo.shmmax == SHMMAX) { /* Initialize shmmax dealing with possible overflow. */ - for (i = PAGE_SIZE; i > 0; i--) { + for (i = PAGE_SIZE; i != 0; i--) { shminfo.shmmax = shminfo.shmall * i; - if (shminfo.shmmax >= shminfo.shmall) + if ((shminfo.shmmax / shminfo.shmall) == (u_long)i) break; } } - TUNABLE_ULONG_FETCH("kern.ipc.shmmin", &shminfo.shmmin); - TUNABLE_ULONG_FETCH("kern.ipc.shmmni", &shminfo.shmmni); - TUNABLE_ULONG_FETCH("kern.ipc.shmseg", &shminfo.shmseg); - TUNABLE_INT_FETCH("kern.ipc.shm_use_phys", &shm_use_phys); - shmalloced = shminfo.shmmni; shmsegs = malloc(shmalloced * sizeof(shmsegs[0]), M_SHM, M_WAITOK); for (i = 0; i < shmalloced; i++) { diff --git a/sys/kern/vfs_init.c b/sys/kern/vfs_init.c index eab48fbea7982..66a6b00df0634 100644 --- a/sys/kern/vfs_init.c +++ b/sys/kern/vfs_init.c @@ -72,7 +72,6 @@ struct vfsconfhead vfsconf = TAILQ_HEAD_INITIALIZER(vfsconf); * changing for file systems that use vfc_typenum in their fsid. */ static int vfs_typenumhash = 1; -TUNABLE_INT("vfs.typenumhash", &vfs_typenumhash); SYSCTL_INT(_vfs, OID_AUTO, typenumhash, CTLFLAG_RDTUN, &vfs_typenumhash, 0, "Set vfc_typenum using a hash calculation on vfc_name, so that it does not" "change when file systems are loaded in a different order."); @@ -213,7 +212,7 @@ vfs_register(struct vfsconf *vfc) * number. */ sysctl_lock(); - SLIST_FOREACH(oidp, &sysctl__vfs_children, oid_link) + SLIST_FOREACH(oidp, SYSCTL_CHILDREN(&sysctl___vfs), oid_link) if (strcmp(oidp->oid_name, vfc->vfc_name) == 0) { sysctl_unregister_oid(oidp); oidp->oid_number = vfc->vfc_typenum; diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index 00dd496e9e37f..f466ca4682566 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -96,9 +96,8 @@ nameiinit(void *dummy __unused) SYSINIT(vfs, SI_SUB_VFS, SI_ORDER_SECOND, nameiinit, NULL); static int lookup_shared = 1; -SYSCTL_INT(_vfs, OID_AUTO, lookup_shared, CTLFLAG_RW, &lookup_shared, 0, +SYSCTL_INT(_vfs, OID_AUTO, lookup_shared, CTLFLAG_RWTUN, &lookup_shared, 0, "Enables/Disables shared locks for path name translation"); -TUNABLE_INT("vfs.lookup_shared", &lookup_shared); /* * Convert a pathname into a pointer to a locked vnode. diff --git a/sys/mips/cavium/usb/octusb.c b/sys/mips/cavium/usb/octusb.c index cad3ef5ef2110..c4d4ac76d8ac0 100644 --- a/sys/mips/cavium/usb/octusb.c +++ b/sys/mips/cavium/usb/octusb.c @@ -82,11 +82,8 @@ __FBSDID("$FreeBSD$"); static int octusbdebug = 0; static SYSCTL_NODE(_hw_usb, OID_AUTO, octusb, CTLFLAG_RW, 0, "OCTUSB"); -SYSCTL_INT(_hw_usb_octusb, OID_AUTO, debug, CTLFLAG_RW, +SYSCTL_INT(_hw_usb_octusb, OID_AUTO, debug, CTLFLAG_RWTUN, &octusbdebug, 0, "OCTUSB debug level"); - -TUNABLE_INT("hw.usb.octusb.debug", &octusbdebug); - #endif struct octusb_std_temp { diff --git a/sys/mips/mips/dump_machdep.c b/sys/mips/mips/dump_machdep.c index bf8c4a3152f3d..54224f285ea15 100644 --- a/sys/mips/mips/dump_machdep.c +++ b/sys/mips/mips/dump_machdep.c @@ -50,8 +50,7 @@ __FBSDID("$FreeBSD$"); CTASSERT(sizeof(struct kerneldumpheader) == 512); int do_minidump = 1; -TUNABLE_INT("debug.minidump", &do_minidump); -SYSCTL_INT(_debug, OID_AUTO, minidump, CTLFLAG_RW, &do_minidump, 0, +SYSCTL_INT(_debug, OID_AUTO, minidump, CTLFLAG_RWTUN, &do_minidump, 0, "Enable mini crash dumps"); /* diff --git a/sys/mips/rt305x/uart_dev_rt305x.c b/sys/mips/rt305x/uart_dev_rt305x.c index 3154cb97437ff..d4f23196d0530 100644 --- a/sys/mips/rt305x/uart_dev_rt305x.c +++ b/sys/mips/rt305x/uart_dev_rt305x.c @@ -73,13 +73,9 @@ static struct uart_ops uart_rt305x_uart_ops = { }; static int uart_output = 1; -TUNABLE_INT("kern.uart_output", &uart_output); -SYSCTL_INT(_kern, OID_AUTO, uart_output, CTLFLAG_RW, +SYSCTL_INT(_kern, OID_AUTO, uart_output, CTLFLAG_RWTUN, &uart_output, 0, "UART output enabled."); - - - static int rt305x_uart_probe(struct uart_bas *bas) { diff --git a/sys/net/ieee8023ad_lacp.c b/sys/net/ieee8023ad_lacp.c index aa38efabd50da..12cc721761876 100644 --- a/sys/net/ieee8023ad_lacp.c +++ b/sys/net/ieee8023ad_lacp.c @@ -192,9 +192,8 @@ static void lacp_dprintf(const struct lacp_port *, const char *, ...) static int lacp_debug = 0; SYSCTL_NODE(_net_link_lagg, OID_AUTO, lacp, CTLFLAG_RD, 0, "ieee802.3ad"); -SYSCTL_INT(_net_link_lagg_lacp, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_net_link_lagg_lacp, OID_AUTO, debug, CTLFLAG_RWTUN, &lacp_debug, 0, "Enable LACP debug logging (1=debug, 2=trace)"); -TUNABLE_INT("net.link.lagg.lacp.debug", &lacp_debug); #define LACP_DPRINTF(a) if (lacp_debug & 0x01) { lacp_dprintf a ; } #define LACP_TRACE(a) if (lacp_debug & 0x02) { lacp_dprintf(a,"%s\n",__func__); } diff --git a/sys/net/if.c b/sys/net/if.c index 47b5b9d687a7f..5a05c97af18c7 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -106,7 +106,6 @@ struct ifindex_entry { SYSCTL_NODE(_net, PF_LINK, link, CTLFLAG_RW, 0, "Link layers"); SYSCTL_NODE(_net_link, 0, generic, CTLFLAG_RW, 0, "Generic link-management"); -TUNABLE_INT("net.link.ifqmaxlen", &ifqmaxlen); SYSCTL_INT(_net_link, OID_AUTO, ifqmaxlen, CTLFLAG_RDTUN, &ifqmaxlen, 0, "max send queue size"); diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c index 4e085731feeae..59d63ee4f2278 100644 --- a/sys/net/if_bridge.c +++ b/sys/net/if_bridge.c @@ -359,27 +359,20 @@ static int pfil_local_phys = 0; /* run pfil hooks on the physical interface for locally destined packets */ static int log_stp = 0; /* log STP state changes */ static int bridge_inherit_mac = 0; /* share MAC with first bridge member */ -TUNABLE_INT("net.link.bridge.pfil_onlyip", &pfil_onlyip); -SYSCTL_INT(_net_link_bridge, OID_AUTO, pfil_onlyip, CTLFLAG_RW, +SYSCTL_INT(_net_link_bridge, OID_AUTO, pfil_onlyip, CTLFLAG_RWTUN, &pfil_onlyip, 0, "Only pass IP packets when pfil is enabled"); -TUNABLE_INT("net.link.bridge.ipfw_arp", &pfil_ipfw_arp); -SYSCTL_INT(_net_link_bridge, OID_AUTO, ipfw_arp, CTLFLAG_RW, +SYSCTL_INT(_net_link_bridge, OID_AUTO, ipfw_arp, CTLFLAG_RWTUN, &pfil_ipfw_arp, 0, "Filter ARP packets through IPFW layer2"); -TUNABLE_INT("net.link.bridge.pfil_bridge", &pfil_bridge); -SYSCTL_INT(_net_link_bridge, OID_AUTO, pfil_bridge, CTLFLAG_RW, +SYSCTL_INT(_net_link_bridge, OID_AUTO, pfil_bridge, CTLFLAG_RWTUN, &pfil_bridge, 0, "Packet filter on the bridge interface"); -TUNABLE_INT("net.link.bridge.pfil_member", &pfil_member); -SYSCTL_INT(_net_link_bridge, OID_AUTO, pfil_member, CTLFLAG_RW, +SYSCTL_INT(_net_link_bridge, OID_AUTO, pfil_member, CTLFLAG_RWTUN, &pfil_member, 0, "Packet filter on the member interface"); -TUNABLE_INT("net.link.bridge.pfil_local_phys", &pfil_local_phys); -SYSCTL_INT(_net_link_bridge, OID_AUTO, pfil_local_phys, CTLFLAG_RW, +SYSCTL_INT(_net_link_bridge, OID_AUTO, pfil_local_phys, CTLFLAG_RWTUN, &pfil_local_phys, 0, "Packet filter on the physical interface for locally destined packets"); -TUNABLE_INT("net.link.bridge.log_stp", &log_stp); -SYSCTL_INT(_net_link_bridge, OID_AUTO, log_stp, CTLFLAG_RW, +SYSCTL_INT(_net_link_bridge, OID_AUTO, log_stp, CTLFLAG_RWTUN, &log_stp, 0, "Log STP state changes"); -TUNABLE_INT("net.link.bridge.inherit_mac", &bridge_inherit_mac); -SYSCTL_INT(_net_link_bridge, OID_AUTO, inherit_mac, CTLFLAG_RW, +SYSCTL_INT(_net_link_bridge, OID_AUTO, inherit_mac, CTLFLAG_RWTUN, &bridge_inherit_mac, 0, "Inherit MAC address from the first bridge member"); diff --git a/sys/net/if_lagg.c b/sys/net/if_lagg.c index 1bab4f948e3ba..ec868e1271609 100644 --- a/sys/net/if_lagg.c +++ b/sys/net/if_lagg.c @@ -180,13 +180,11 @@ SYSCTL_INT(_net_link_lagg, OID_AUTO, failover_rx_all, CTLFLAG_RW, &lagg_failover_rx_all, 0, "Accept input from any interface in a failover lagg"); static int def_use_flowid = 1; /* Default value for using M_FLOWID */ -TUNABLE_INT("net.link.lagg.default_use_flowid", &def_use_flowid); -SYSCTL_INT(_net_link_lagg, OID_AUTO, default_use_flowid, CTLFLAG_RW, +SYSCTL_INT(_net_link_lagg, OID_AUTO, default_use_flowid, CTLFLAG_RWTUN, &def_use_flowid, 0, "Default setting for using flow id for load sharing"); static int def_flowid_shift = 16; /* Default value for using M_FLOWID */ -TUNABLE_INT("net.link.lagg.default_flowid_shift", &def_flowid_shift); -SYSCTL_INT(_net_link_lagg, OID_AUTO, default_flowid_shift, CTLFLAG_RW, +SYSCTL_INT(_net_link_lagg, OID_AUTO, default_flowid_shift, CTLFLAG_RWTUN, &def_flowid_shift, 0, "Default setting for flowid shift for load sharing"); diff --git a/sys/net/if_stf.c b/sys/net/if_stf.c index 28888edff5f46..8578818472cfe 100644 --- a/sys/net/if_stf.c +++ b/sys/net/if_stf.c @@ -129,8 +129,7 @@ SYSCTL_INT(_net_link_stf, OID_AUTO, route_cache, CTLFLAG_RW, &stf_route_cache, 0, "Caching of IPv4 routes for 6to4 Output"); static int stf_permit_rfc1918 = 0; -TUNABLE_INT("net.link.stf.permit_rfc1918", &stf_permit_rfc1918); -SYSCTL_INT(_net_link_stf, OID_AUTO, permit_rfc1918, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_net_link_stf, OID_AUTO, permit_rfc1918, CTLFLAG_RWTUN, &stf_permit_rfc1918, 0, "Permit the use of private IPv4 addresses"); #define STFUNIT 0 diff --git a/sys/net/if_tap.c b/sys/net/if_tap.c index d788635a59e14..89cac22f264e8 100644 --- a/sys/net/if_tap.c +++ b/sys/net/if_tap.c @@ -170,12 +170,10 @@ SYSCTL_INT(_net_link_tap, OID_AUTO, user_open, CTLFLAG_RW, &tapuopen, 0, "Allow user to open /dev/tap (based on node permissions)"); SYSCTL_INT(_net_link_tap, OID_AUTO, up_on_open, CTLFLAG_RW, &tapuponopen, 0, "Bring interface up when /dev/tap is opened"); -SYSCTL_INT(_net_link_tap, OID_AUTO, devfs_cloning, CTLFLAG_RW, &tapdclone, 0, +SYSCTL_INT(_net_link_tap, OID_AUTO, devfs_cloning, CTLFLAG_RWTUN, &tapdclone, 0, "Enably legacy devfs interface creation"); SYSCTL_INT(_net_link_tap, OID_AUTO, debug, CTLFLAG_RW, &tapdebug, 0, ""); -TUNABLE_INT("net.link.tap.devfs_cloning", &tapdclone); - DEV_MODULE(if_tap, tapmodevent, NULL); static int diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index 504bab0503671..e4bc2afc7afc1 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -116,11 +116,9 @@ SYSCTL_INT(_debug, OID_AUTO, if_tun_debug, CTLFLAG_RW, &tundebug, 0, ""); SYSCTL_DECL(_net_link); static SYSCTL_NODE(_net_link, OID_AUTO, tun, CTLFLAG_RW, 0, "IP tunnel software network interface."); -SYSCTL_INT(_net_link_tun, OID_AUTO, devfs_cloning, CTLFLAG_RW, &tundclone, 0, +SYSCTL_INT(_net_link_tun, OID_AUTO, devfs_cloning, CTLFLAG_RWTUN, &tundclone, 0, "Enable legacy devfs interface creation."); -TUNABLE_INT("net.link.tun.devfs_cloning", &tundclone); - static void tunclone(void *arg, struct ucred *cred, char *name, int namelen, struct cdev **dev); static void tuncreate(const char *name, struct cdev *dev); diff --git a/sys/net/netisr.c b/sys/net/netisr.c index 7974cc891ea13..049bbf192b538 100644 --- a/sys/net/netisr.c +++ b/sys/net/netisr.c @@ -149,8 +149,8 @@ static SYSCTL_NODE(_net, OID_AUTO, isr, CTLFLAG_RW, 0, "netisr"); #define NETISR_DISPATCH_POLICY_MAXSTR 20 /* Used for temporary buffers. */ static u_int netisr_dispatch_policy = NETISR_DISPATCH_POLICY_DEFAULT; static int sysctl_netisr_dispatch_policy(SYSCTL_HANDLER_ARGS); -SYSCTL_PROC(_net_isr, OID_AUTO, dispatch, CTLTYPE_STRING | CTLFLAG_RW | - CTLFLAG_TUN, 0, 0, sysctl_netisr_dispatch_policy, "A", +SYSCTL_PROC(_net_isr, OID_AUTO, dispatch, CTLTYPE_STRING | CTLFLAG_RWTUN, + 0, 0, sysctl_netisr_dispatch_policy, "A", "netisr dispatch policy"); /* @@ -160,13 +160,11 @@ SYSCTL_PROC(_net_isr, OID_AUTO, dispatch, CTLTYPE_STRING | CTLFLAG_RW | * We will create at most one thread per CPU. */ static int netisr_maxthreads = -1; /* Max number of threads. */ -TUNABLE_INT("net.isr.maxthreads", &netisr_maxthreads); SYSCTL_INT(_net_isr, OID_AUTO, maxthreads, CTLFLAG_RDTUN, &netisr_maxthreads, 0, "Use at most this many CPUs for netisr processing"); static int netisr_bindthreads = 0; /* Bind threads to CPUs. */ -TUNABLE_INT("net.isr.bindthreads", &netisr_bindthreads); SYSCTL_INT(_net_isr, OID_AUTO, bindthreads, CTLFLAG_RDTUN, &netisr_bindthreads, 0, "Bind netisr threads to CPUs."); @@ -177,7 +175,6 @@ SYSCTL_INT(_net_isr, OID_AUTO, bindthreads, CTLFLAG_RDTUN, */ #define NETISR_DEFAULT_MAXQLIMIT 10240 static u_int netisr_maxqlimit = NETISR_DEFAULT_MAXQLIMIT; -TUNABLE_INT("net.isr.maxqlimit", &netisr_maxqlimit); SYSCTL_UINT(_net_isr, OID_AUTO, maxqlimit, CTLFLAG_RDTUN, &netisr_maxqlimit, 0, "Maximum netisr per-protocol, per-CPU queue depth."); @@ -189,7 +186,6 @@ SYSCTL_UINT(_net_isr, OID_AUTO, maxqlimit, CTLFLAG_RDTUN, */ #define NETISR_DEFAULT_DEFAULTQLIMIT 256 static u_int netisr_defaultqlimit = NETISR_DEFAULT_DEFAULTQLIMIT; -TUNABLE_INT("net.isr.defaultqlimit", &netisr_defaultqlimit); SYSCTL_UINT(_net_isr, OID_AUTO, defaultqlimit, CTLFLAG_RDTUN, &netisr_defaultqlimit, 0, "Default netisr per-protocol, per-CPU queue limit if not set by protocol"); @@ -1120,10 +1116,6 @@ netisr_start_swi(u_int cpuid, struct pcpu *pc) static void netisr_init(void *arg) { - char tmp[NETISR_DISPATCH_POLICY_MAXSTR]; - u_int dispatch_policy; - int error; - KASSERT(curcpu == 0, ("%s: not on CPU 0", __func__)); NETISR_LOCK_INIT(); @@ -1152,20 +1144,6 @@ netisr_init(void *arg) netisr_bindthreads = 0; } #endif - - if (TUNABLE_STR_FETCH("net.isr.dispatch", tmp, sizeof(tmp))) { - error = netisr_dispatch_policy_from_str(tmp, - &dispatch_policy); - if (error == 0 && dispatch_policy == NETISR_DISPATCH_DEFAULT) - error = EINVAL; - if (error == 0) - netisr_dispatch_policy = dispatch_policy; - else - printf( - "%s: invalid dispatch policy %s, using default\n", - __func__, tmp); - } - netisr_start_swi(curcpu, pcpu_find(curcpu)); } SYSINIT(netisr_init, SI_SUB_SOFTINTR, SI_ORDER_FIRST, netisr_init, NULL); diff --git a/sys/net/route.c b/sys/net/route.c index 83cc857ef7b28..547418af84b9c 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -96,9 +96,7 @@ extern void sctp_addr_change(struct ifaddr *ifa, int cmd); /* This is read-only.. */ u_int rt_numfibs = RT_NUMFIBS; -SYSCTL_UINT(_net, OID_AUTO, fibs, CTLFLAG_RD, &rt_numfibs, 0, ""); -/* and this can be set too big but will be fixed before it is used */ -TUNABLE_INT("net.fibs", &rt_numfibs); +SYSCTL_UINT(_net, OID_AUTO, fibs, CTLFLAG_RDTUN, &rt_numfibs, 0, ""); /* * By default add routes to all fibs for new interfaces. @@ -111,9 +109,8 @@ TUNABLE_INT("net.fibs", &rt_numfibs); * from the network stack context. */ u_int rt_add_addr_allfibs = 1; -SYSCTL_UINT(_net, OID_AUTO, add_addr_allfibs, CTLFLAG_RW, +SYSCTL_UINT(_net, OID_AUTO, add_addr_allfibs, CTLFLAG_RWTUN, &rt_add_addr_allfibs, 0, ""); -TUNABLE_INT("net.add_addr_allfibs", &rt_add_addr_allfibs); VNET_DEFINE(struct rtstat, rtstat); #define V_rtstat VNET(rtstat) diff --git a/sys/netgraph/ng_base.c b/sys/netgraph/ng_base.c index e83967be8f07a..1970965e2e25c 100644 --- a/sys/netgraph/ng_base.c +++ b/sys/netgraph/ng_base.c @@ -2954,13 +2954,10 @@ static int numthreads = 0; /* number of queue threads */ static int maxalloc = 4096;/* limit the damage of a leak */ static int maxdata = 512; /* limit the damage of a DoS */ -TUNABLE_INT("net.graph.threads", &numthreads); SYSCTL_INT(_net_graph, OID_AUTO, threads, CTLFLAG_RDTUN, &numthreads, 0, "Number of queue processing threads"); -TUNABLE_INT("net.graph.maxalloc", &maxalloc); SYSCTL_INT(_net_graph, OID_AUTO, maxalloc, CTLFLAG_RDTUN, &maxalloc, 0, "Maximum number of non-data queue items to allocate"); -TUNABLE_INT("net.graph.maxdata", &maxdata); SYSCTL_INT(_net_graph, OID_AUTO, maxdata, CTLFLAG_RDTUN, &maxdata, 0, "Maximum number of data queue items to allocate"); diff --git a/sys/netgraph/ng_mppc.c b/sys/netgraph/ng_mppc.c index 14d44de49dc07..76f4c3b89b4fe 100644 --- a/sys/netgraph/ng_mppc.c +++ b/sys/netgraph/ng_mppc.c @@ -111,18 +111,15 @@ static MALLOC_DEFINE(M_NETGRAPH_MPPC, "netgraph_mppc", "netgraph mppc node"); SYSCTL_NODE(_net_graph, OID_AUTO, mppe, CTLFLAG_RW, 0, "MPPE"); static int mppe_block_on_max_rekey = 0; -TUNABLE_INT("net.graph.mppe.block_on_max_rekey", &mppe_block_on_max_rekey); -SYSCTL_INT(_net_graph_mppe, OID_AUTO, block_on_max_rekey, CTLFLAG_RW, +SYSCTL_INT(_net_graph_mppe, OID_AUTO, block_on_max_rekey, CTLFLAG_RWTUN, &mppe_block_on_max_rekey, 0, "Block node on max MPPE key re-calculations"); static int mppe_log_max_rekey = 1; -TUNABLE_INT("net.graph.mppe.log_max_rekey", &mppe_log_max_rekey); -SYSCTL_INT(_net_graph_mppe, OID_AUTO, log_max_rekey, CTLFLAG_RW, +SYSCTL_INT(_net_graph_mppe, OID_AUTO, log_max_rekey, CTLFLAG_RWTUN, &mppe_log_max_rekey, 0, "Log max MPPE key re-calculations event"); static int mppe_max_rekey = MPPE_MAX_REKEY; -TUNABLE_INT("net.graph.mppe.max_rekey", &mppe_max_rekey); -SYSCTL_INT(_net_graph_mppe, OID_AUTO, max_rekey, CTLFLAG_RW, +SYSCTL_INT(_net_graph_mppe, OID_AUTO, max_rekey, CTLFLAG_RWTUN, &mppe_max_rekey, 0, "Maximum number of MPPE key re-calculations"); /* MPPC packet header bits */ diff --git a/sys/netinet/in_mcast.c b/sys/netinet/in_mcast.c index d996bd189281d..26d4e8e3a135b 100644 --- a/sys/netinet/in_mcast.c +++ b/sys/netinet/in_mcast.c @@ -166,20 +166,17 @@ static SYSCTL_NODE(_net_inet_ip, OID_AUTO, mcast, CTLFLAG_RW, 0, static u_long in_mcast_maxgrpsrc = IP_MAX_GROUP_SRC_FILTER; SYSCTL_ULONG(_net_inet_ip_mcast, OID_AUTO, maxgrpsrc, - CTLFLAG_RW | CTLFLAG_TUN, &in_mcast_maxgrpsrc, 0, + CTLFLAG_RWTUN, &in_mcast_maxgrpsrc, 0, "Max source filters per group"); -TUNABLE_ULONG("net.inet.ip.mcast.maxgrpsrc", &in_mcast_maxgrpsrc); static u_long in_mcast_maxsocksrc = IP_MAX_SOCK_SRC_FILTER; SYSCTL_ULONG(_net_inet_ip_mcast, OID_AUTO, maxsocksrc, - CTLFLAG_RW | CTLFLAG_TUN, &in_mcast_maxsocksrc, 0, + CTLFLAG_RWTUN, &in_mcast_maxsocksrc, 0, "Max source filters per socket"); -TUNABLE_ULONG("net.inet.ip.mcast.maxsocksrc", &in_mcast_maxsocksrc); int in_mcast_loop = IP_DEFAULT_MULTICAST_LOOP; -SYSCTL_INT(_net_inet_ip_mcast, OID_AUTO, loop, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_net_inet_ip_mcast, OID_AUTO, loop, CTLFLAG_RWTUN, &in_mcast_loop, 0, "Loopback multicast datagrams by default"); -TUNABLE_INT("net.inet.ip.mcast.loop", &in_mcast_loop); static SYSCTL_NODE(_net_inet_ip_mcast, OID_AUTO, filters, CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_ip_mcast_filters, diff --git a/sys/netinet/in_rss.c b/sys/netinet/in_rss.c index 698373fa7aa24..4e6a454e1319d 100644 --- a/sys/netinet/in_rss.c +++ b/sys/netinet/in_rss.c @@ -91,9 +91,8 @@ SYSCTL_NODE(_net_inet, OID_AUTO, rss, CTLFLAG_RW, 0, "Receive-side steering"); * default. */ static u_int rss_hashalgo = RSS_HASH_TOEPLITZ; -SYSCTL_INT(_net_inet_rss, OID_AUTO, hashalgo, CTLFLAG_RD, &rss_hashalgo, 0, +SYSCTL_INT(_net_inet_rss, OID_AUTO, hashalgo, CTLFLAG_RDTUN, &rss_hashalgo, 0, "RSS hash algorithm"); -TUNABLE_INT("net.inet.rss.hashalgo", &rss_hashalgo); /* * Size of the indirection table; at most 128 entries per the RSS spec. We @@ -104,9 +103,8 @@ TUNABLE_INT("net.inet.rss.hashalgo", &rss_hashalgo); * XXXRW: buckets might be better to use for the tunable than bits. */ static u_int rss_bits; -SYSCTL_INT(_net_inet_rss, OID_AUTO, bits, CTLFLAG_RD, &rss_bits, 0, +SYSCTL_INT(_net_inet_rss, OID_AUTO, bits, CTLFLAG_RDTUN, &rss_bits, 0, "RSS bits"); -TUNABLE_INT("net.inet.rss.bits", &rss_bits); static u_int rss_mask; SYSCTL_INT(_net_inet_rss, OID_AUTO, mask, CTLFLAG_RD, &rss_mask, 0, diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index fb2c415aee986..ac0aad31bc50e 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -188,8 +188,8 @@ static int tcp_log_debug = 0; SYSCTL_INT(_net_inet_tcp, OID_AUTO, log_debug, CTLFLAG_RW, &tcp_log_debug, 0, "Log errors caused by incoming TCP segments"); -static int tcp_tcbhashsize = 0; -SYSCTL_INT(_net_inet_tcp, OID_AUTO, tcbhashsize, CTLFLAG_RDTUN, +static int tcp_tcbhashsize; +SYSCTL_INT(_net_inet_tcp, OID_AUTO, tcbhashsize, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &tcp_tcbhashsize, 0, "Size of TCP control-block hashtable"); static int do_tcpdrain = 1; @@ -211,7 +211,7 @@ SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, isn_reseed_interval, CTLFLAG_RW, &VNET_NAME(tcp_isn_reseed_interval), 0, "Seconds between reseeding of ISN secret"); -static int tcp_soreceive_stream = 0; +static int tcp_soreceive_stream; SYSCTL_INT(_net_inet_tcp, OID_AUTO, soreceive_stream, CTLFLAG_RDTUN, &tcp_soreceive_stream, 0, "Using soreceive_stream for TCP sockets"); @@ -398,7 +398,6 @@ tcp_init(void) tcp_finwait2_timeout = TCPTV_FINWAIT2_TIMEOUT; tcp_tcbhashsize = hashsize; - TUNABLE_INT_FETCH("net.inet.tcp.soreceive_stream", &tcp_soreceive_stream); if (tcp_soreceive_stream) { #ifdef INET tcp_usrreqs.pru_soreceive = soreceive_stream; diff --git a/sys/netinet6/in6_mcast.c b/sys/netinet6/in6_mcast.c index d259997635019..f9ff10a302f30 100644 --- a/sys/netinet6/in6_mcast.c +++ b/sys/netinet6/in6_mcast.c @@ -158,21 +158,18 @@ static SYSCTL_NODE(_net_inet6_ip6, OID_AUTO, mcast, CTLFLAG_RW, 0, static u_long in6_mcast_maxgrpsrc = IPV6_MAX_GROUP_SRC_FILTER; SYSCTL_ULONG(_net_inet6_ip6_mcast, OID_AUTO, maxgrpsrc, - CTLFLAG_RW | CTLFLAG_TUN, &in6_mcast_maxgrpsrc, 0, + CTLFLAG_RWTUN, &in6_mcast_maxgrpsrc, 0, "Max source filters per group"); -TUNABLE_ULONG("net.inet6.ip6.mcast.maxgrpsrc", &in6_mcast_maxgrpsrc); static u_long in6_mcast_maxsocksrc = IPV6_MAX_SOCK_SRC_FILTER; SYSCTL_ULONG(_net_inet6_ip6_mcast, OID_AUTO, maxsocksrc, - CTLFLAG_RW | CTLFLAG_TUN, &in6_mcast_maxsocksrc, 0, + CTLFLAG_RWTUN, &in6_mcast_maxsocksrc, 0, "Max source filters per socket"); -TUNABLE_ULONG("net.inet6.ip6.mcast.maxsocksrc", &in6_mcast_maxsocksrc); /* TODO Virtualize this switch. */ int in6_mcast_loop = IPV6_DEFAULT_MULTICAST_LOOP; -SYSCTL_INT(_net_inet6_ip6_mcast, OID_AUTO, loop, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_net_inet6_ip6_mcast, OID_AUTO, loop, CTLFLAG_RWTUN, &in6_mcast_loop, 0, "Loopback multicast datagrams by default"); -TUNABLE_INT("net.inet6.ip6.mcast.loop", &in6_mcast_loop); static SYSCTL_NODE(_net_inet6_ip6_mcast, OID_AUTO, filters, CTLFLAG_RD | CTLFLAG_MPSAFE, sysctl_ip6_mcast_filters, diff --git a/sys/netinet6/mld6.c b/sys/netinet6/mld6.c index c40ef9e3dee56..2e46208ce73b7 100644 --- a/sys/netinet6/mld6.c +++ b/sys/netinet6/mld6.c @@ -238,14 +238,12 @@ static SYSCTL_NODE(_net_inet6_mld, OID_AUTO, ifinfo, "Per-interface MLDv2 state"); static int mld_v1enable = 1; -SYSCTL_INT(_net_inet6_mld, OID_AUTO, v1enable, CTLFLAG_RW, +SYSCTL_INT(_net_inet6_mld, OID_AUTO, v1enable, CTLFLAG_RWTUN, &mld_v1enable, 0, "Enable fallback to MLDv1"); -TUNABLE_INT("net.inet6.mld.v1enable", &mld_v1enable); static int mld_use_allow = 1; -SYSCTL_INT(_net_inet6_mld, OID_AUTO, use_allow, CTLFLAG_RW, +SYSCTL_INT(_net_inet6_mld, OID_AUTO, use_allow, CTLFLAG_RWTUN, &mld_use_allow, 0, "Use ALLOW/BLOCK for RFC 4604 SSM joins/leaves"); -TUNABLE_INT("net.inet6.mld.use_allow", &mld_use_allow); /* * Packed Router Alert option structure declaration. diff --git a/sys/netpfil/ipfw/ip_fw2.c b/sys/netpfil/ipfw/ip_fw2.c index ecb0f2dc8169a..91900919e140e 100644 --- a/sys/netpfil/ipfw/ip_fw2.c +++ b/sys/netpfil/ipfw/ip_fw2.c @@ -181,7 +181,6 @@ SYSCTL_VNET_PROC(_net_inet_ip_fw, OID_AUTO, tables_max, SYSCTL_INT(_net_inet_ip_fw, OID_AUTO, default_to_accept, CTLFLAG_RDTUN, &default_to_accept, 0, "Make the default rule accept all packets."); -TUNABLE_INT("net.inet.ip.fw.default_to_accept", &default_to_accept); TUNABLE_INT("net.inet.ip.fw.tables_max", (int *)&default_fw_tables); SYSCTL_VNET_INT(_net_inet_ip_fw, OID_AUTO, static_count, CTLFLAG_RD, &VNET_NAME(layer3_chain.n_rules), 0, diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index 094520147cd22..6c971516e5601 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -743,10 +743,8 @@ pf_initialize() struct pf_srchash *sh; u_int i; - TUNABLE_ULONG_FETCH("net.pf.states_hashsize", &pf_hashsize); if (pf_hashsize == 0 || !powerof2(pf_hashsize)) pf_hashsize = PF_HASHSIZ; - TUNABLE_ULONG_FETCH("net.pf.source_nodes_hashsize", &pf_srchashsize); if (pf_srchashsize == 0 || !powerof2(pf_srchashsize)) pf_srchashsize = PF_HASHSIZ / 4; diff --git a/sys/pc98/cbus/sio.c b/sys/pc98/cbus/sio.c index 754d4ad12cbb5..d128658bf2224 100644 --- a/sys/pc98/cbus/sio.c +++ b/sys/pc98/cbus/sio.c @@ -704,7 +704,7 @@ sysctl_machdep_comdefaultrate(SYSCTL_HANDLER_ARGS) return error; } -SYSCTL_PROC(_machdep, OID_AUTO, conspeed, CTLTYPE_INT | CTLFLAG_RW, +SYSCTL_PROC(_machdep, OID_AUTO, conspeed, CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NOFETCH, 0, 0, sysctl_machdep_comdefaultrate, "I", ""); TUNABLE_INT("machdep.conspeed", __DEVOLATILE(int *, &comdefaultrate)); diff --git a/sys/pc98/pc98/machdep.c b/sys/pc98/pc98/machdep.c index b9c6a4ef235c9..f7883c4410824 100644 --- a/sys/pc98/pc98/machdep.c +++ b/sys/pc98/pc98/machdep.c @@ -1113,8 +1113,7 @@ cpu_halt(void) } static int idle_mwait = 1; /* Use MONITOR/MWAIT for short idle. */ -TUNABLE_INT("machdep.idle_mwait", &idle_mwait); -SYSCTL_INT(_machdep, OID_AUTO, idle_mwait, CTLFLAG_RW, &idle_mwait, +SYSCTL_INT(_machdep, OID_AUTO, idle_mwait, CTLFLAG_RWTUN, &idle_mwait, 0, "Use MONITOR/MWAIT for short idle"); #define STATE_RUNNING 0x0 diff --git a/sys/pc98/pc98/pc98_machdep.c b/sys/pc98/pc98/pc98_machdep.c index aed4eaa6f1415..9f9fbcc347f27 100644 --- a/sys/pc98/pc98/pc98_machdep.c +++ b/sys/pc98/pc98/pc98_machdep.c @@ -49,8 +49,7 @@ static int ad_geom_method = AD_GEOM_ADJUST_COMPATIDE; -TUNABLE_INT("machdep.ad_geom_method", &ad_geom_method); -SYSCTL_INT(_machdep, OID_AUTO, ad_geom_method, CTLFLAG_RW, &ad_geom_method, 0, +SYSCTL_INT(_machdep, OID_AUTO, ad_geom_method, CTLFLAG_RWTUN, &ad_geom_method, 0, "IDE disk geometry conversion method"); /* diff --git a/sys/security/mac_biba/mac_biba.c b/sys/security/mac_biba/mac_biba.c index 375b8a3eb795e..b5bf8c32dbef4 100644 --- a/sys/security/mac_biba/mac_biba.c +++ b/sys/security/mac_biba/mac_biba.c @@ -100,43 +100,36 @@ SYSCTL_INT(_security_mac_biba, OID_AUTO, label_size, CTLFLAG_RD, &biba_label_size, 0, "Size of struct mac_biba"); static int biba_enabled = 1; -SYSCTL_INT(_security_mac_biba, OID_AUTO, enabled, CTLFLAG_RW, &biba_enabled, +SYSCTL_INT(_security_mac_biba, OID_AUTO, enabled, CTLFLAG_RWTUN, &biba_enabled, 0, "Enforce MAC/Biba policy"); -TUNABLE_INT("security.mac.biba.enabled", &biba_enabled); static int destroyed_not_inited; SYSCTL_INT(_security_mac_biba, OID_AUTO, destroyed_not_inited, CTLFLAG_RD, &destroyed_not_inited, 0, "Count of labels destroyed but not inited"); static int trust_all_interfaces = 0; -SYSCTL_INT(_security_mac_biba, OID_AUTO, trust_all_interfaces, CTLFLAG_RD, +SYSCTL_INT(_security_mac_biba, OID_AUTO, trust_all_interfaces, CTLFLAG_RDTUN, &trust_all_interfaces, 0, "Consider all interfaces 'trusted' by MAC/Biba"); -TUNABLE_INT("security.mac.biba.trust_all_interfaces", &trust_all_interfaces); static char trusted_interfaces[128]; -SYSCTL_STRING(_security_mac_biba, OID_AUTO, trusted_interfaces, CTLFLAG_RD, +SYSCTL_STRING(_security_mac_biba, OID_AUTO, trusted_interfaces, CTLFLAG_RDTUN, trusted_interfaces, 0, "Interfaces considered 'trusted' by MAC/Biba"); -TUNABLE_STR("security.mac.biba.trusted_interfaces", trusted_interfaces, - sizeof(trusted_interfaces)); static int max_compartments = MAC_BIBA_MAX_COMPARTMENTS; SYSCTL_INT(_security_mac_biba, OID_AUTO, max_compartments, CTLFLAG_RD, &max_compartments, 0, "Maximum supported compartments"); static int ptys_equal = 0; -SYSCTL_INT(_security_mac_biba, OID_AUTO, ptys_equal, CTLFLAG_RW, &ptys_equal, +SYSCTL_INT(_security_mac_biba, OID_AUTO, ptys_equal, CTLFLAG_RWTUN, &ptys_equal, 0, "Label pty devices as biba/equal on create"); -TUNABLE_INT("security.mac.biba.ptys_equal", &ptys_equal); static int interfaces_equal = 1; -SYSCTL_INT(_security_mac_biba, OID_AUTO, interfaces_equal, CTLFLAG_RW, +SYSCTL_INT(_security_mac_biba, OID_AUTO, interfaces_equal, CTLFLAG_RWTUN, &interfaces_equal, 0, "Label network interfaces as biba/equal on create"); -TUNABLE_INT("security.mac.biba.interfaces_equal", &interfaces_equal); static int revocation_enabled = 0; -SYSCTL_INT(_security_mac_biba, OID_AUTO, revocation_enabled, CTLFLAG_RW, +SYSCTL_INT(_security_mac_biba, OID_AUTO, revocation_enabled, CTLFLAG_RWTUN, &revocation_enabled, 0, "Revoke access to objects on relabel"); -TUNABLE_INT("security.mac.biba.revocation_enabled", &revocation_enabled); static int biba_slot; #define SLOT(l) ((struct mac_biba *)mac_label_get((l), biba_slot)) diff --git a/sys/security/mac_bsdextended/mac_bsdextended.c b/sys/security/mac_bsdextended/mac_bsdextended.c index ccbc525552f8f..377fd250ad2db 100644 --- a/sys/security/mac_bsdextended/mac_bsdextended.c +++ b/sys/security/mac_bsdextended/mac_bsdextended.c @@ -76,9 +76,8 @@ static SYSCTL_NODE(_security_mac, OID_AUTO, bsdextended, CTLFLAG_RW, 0, "TrustedBSD extended BSD MAC policy controls"); static int ugidfw_enabled = 1; -SYSCTL_INT(_security_mac_bsdextended, OID_AUTO, enabled, CTLFLAG_RW, +SYSCTL_INT(_security_mac_bsdextended, OID_AUTO, enabled, CTLFLAG_RWTUN, &ugidfw_enabled, 0, "Enforce extended BSD policy"); -TUNABLE_INT("security.mac.bsdextended.enabled", &ugidfw_enabled); static MALLOC_DEFINE(M_MACBSDEXTENDED, "mac_bsdextended", "BSD Extended MAC rule"); diff --git a/sys/security/mac_ifoff/mac_ifoff.c b/sys/security/mac_ifoff/mac_ifoff.c index 7165f905c83d0..28097b502989a 100644 --- a/sys/security/mac_ifoff/mac_ifoff.c +++ b/sys/security/mac_ifoff/mac_ifoff.c @@ -66,25 +66,21 @@ static SYSCTL_NODE(_security_mac, OID_AUTO, ifoff, CTLFLAG_RW, 0, "TrustedBSD mac_ifoff policy controls"); static int ifoff_enabled = 1; -SYSCTL_INT(_security_mac_ifoff, OID_AUTO, enabled, CTLFLAG_RW, +SYSCTL_INT(_security_mac_ifoff, OID_AUTO, enabled, CTLFLAG_RWTUN, &ifoff_enabled, 0, "Enforce ifoff policy"); -TUNABLE_INT("security.mac.ifoff.enabled", &ifoff_enabled); static int ifoff_lo_enabled = 1; -SYSCTL_INT(_security_mac_ifoff, OID_AUTO, lo_enabled, CTLFLAG_RW, +SYSCTL_INT(_security_mac_ifoff, OID_AUTO, lo_enabled, CTLFLAG_RWTUN, &ifoff_lo_enabled, 0, "Enable loopback interfaces"); -TUNABLE_INT("security.mac.ifoff.lo_enabled", &ifoff_lo_enabled); static int ifoff_other_enabled = 0; -SYSCTL_INT(_security_mac_ifoff, OID_AUTO, other_enabled, CTLFLAG_RW, +SYSCTL_INT(_security_mac_ifoff, OID_AUTO, other_enabled, CTLFLAG_RWTUN, &ifoff_other_enabled, 0, "Enable other interfaces"); -TUNABLE_INT("security.mac.ifoff.other_enabled", &ifoff_other_enabled); static int ifoff_bpfrecv_enabled = 0; -SYSCTL_INT(_security_mac_ifoff, OID_AUTO, bpfrecv_enabled, CTLFLAG_RW, +SYSCTL_INT(_security_mac_ifoff, OID_AUTO, bpfrecv_enabled, CTLFLAG_RWTUN, &ifoff_bpfrecv_enabled, 0, "Enable BPF reception even when interface " "is disabled"); -TUNABLE_INT("security.mac.ifoff.bpfrecv.enabled", &ifoff_bpfrecv_enabled); static int ifnet_check_outgoing(struct ifnet *ifp) diff --git a/sys/security/mac_lomac/mac_lomac.c b/sys/security/mac_lomac/mac_lomac.c index b2b9f74afb55f..cf66423a91c6f 100644 --- a/sys/security/mac_lomac/mac_lomac.c +++ b/sys/security/mac_lomac/mac_lomac.c @@ -101,34 +101,28 @@ SYSCTL_INT(_security_mac_lomac, OID_AUTO, label_size, CTLFLAG_RD, &lomac_label_size, 0, "Size of struct mac_lomac"); static int lomac_enabled = 1; -SYSCTL_INT(_security_mac_lomac, OID_AUTO, enabled, CTLFLAG_RW, +SYSCTL_INT(_security_mac_lomac, OID_AUTO, enabled, CTLFLAG_RWTUN, &lomac_enabled, 0, "Enforce MAC/LOMAC policy"); -TUNABLE_INT("security.mac.lomac.enabled", &lomac_enabled); static int destroyed_not_inited; SYSCTL_INT(_security_mac_lomac, OID_AUTO, destroyed_not_inited, CTLFLAG_RD, &destroyed_not_inited, 0, "Count of labels destroyed but not inited"); static int trust_all_interfaces = 0; -SYSCTL_INT(_security_mac_lomac, OID_AUTO, trust_all_interfaces, CTLFLAG_RD, +SYSCTL_INT(_security_mac_lomac, OID_AUTO, trust_all_interfaces, CTLFLAG_RDTUN, &trust_all_interfaces, 0, "Consider all interfaces 'trusted' by MAC/LOMAC"); -TUNABLE_INT("security.mac.lomac.trust_all_interfaces", &trust_all_interfaces); static char trusted_interfaces[128]; -SYSCTL_STRING(_security_mac_lomac, OID_AUTO, trusted_interfaces, CTLFLAG_RD, +SYSCTL_STRING(_security_mac_lomac, OID_AUTO, trusted_interfaces, CTLFLAG_RDTUN, trusted_interfaces, 0, "Interfaces considered 'trusted' by MAC/LOMAC"); -TUNABLE_STR("security.mac.lomac.trusted_interfaces", trusted_interfaces, - sizeof(trusted_interfaces)); static int ptys_equal = 0; -SYSCTL_INT(_security_mac_lomac, OID_AUTO, ptys_equal, CTLFLAG_RW, +SYSCTL_INT(_security_mac_lomac, OID_AUTO, ptys_equal, CTLFLAG_RWTUN, &ptys_equal, 0, "Label pty devices as lomac/equal on create"); -TUNABLE_INT("security.mac.lomac.ptys_equal", &ptys_equal); static int revocation_enabled = 1; -SYSCTL_INT(_security_mac_lomac, OID_AUTO, revocation_enabled, CTLFLAG_RW, +SYSCTL_INT(_security_mac_lomac, OID_AUTO, revocation_enabled, CTLFLAG_RWTUN, &revocation_enabled, 0, "Revoke access to objects on relabel"); -TUNABLE_INT("security.mac.lomac.revocation_enabled", &revocation_enabled); static int lomac_slot; #define SLOT(l) ((struct mac_lomac *)mac_label_get((l), lomac_slot)) diff --git a/sys/security/mac_mls/mac_mls.c b/sys/security/mac_mls/mac_mls.c index d7ca5a55362f9..6a074d0279bdb 100644 --- a/sys/security/mac_mls/mac_mls.c +++ b/sys/security/mac_mls/mac_mls.c @@ -101,23 +101,20 @@ SYSCTL_INT(_security_mac_mls, OID_AUTO, label_size, CTLFLAG_RD, &mls_label_size, 0, "Size of struct mac_mls"); static int mls_enabled = 1; -SYSCTL_INT(_security_mac_mls, OID_AUTO, enabled, CTLFLAG_RW, &mls_enabled, 0, +SYSCTL_INT(_security_mac_mls, OID_AUTO, enabled, CTLFLAG_RWTUN, &mls_enabled, 0, "Enforce MAC/MLS policy"); -TUNABLE_INT("security.mac.mls.enabled", &mls_enabled); static int destroyed_not_inited; SYSCTL_INT(_security_mac_mls, OID_AUTO, destroyed_not_inited, CTLFLAG_RD, &destroyed_not_inited, 0, "Count of labels destroyed but not inited"); static int ptys_equal = 0; -SYSCTL_INT(_security_mac_mls, OID_AUTO, ptys_equal, CTLFLAG_RW, +SYSCTL_INT(_security_mac_mls, OID_AUTO, ptys_equal, CTLFLAG_RWTUN, &ptys_equal, 0, "Label pty devices as mls/equal on create"); -TUNABLE_INT("security.mac.mls.ptys_equal", &ptys_equal); static int revocation_enabled = 0; -SYSCTL_INT(_security_mac_mls, OID_AUTO, revocation_enabled, CTLFLAG_RW, +SYSCTL_INT(_security_mac_mls, OID_AUTO, revocation_enabled, CTLFLAG_RWTUN, &revocation_enabled, 0, "Revoke access to objects on relabel"); -TUNABLE_INT("security.mac.mls.revocation_enabled", &revocation_enabled); static int max_compartments = MAC_MLS_MAX_COMPARTMENTS; SYSCTL_INT(_security_mac_mls, OID_AUTO, max_compartments, CTLFLAG_RD, diff --git a/sys/security/mac_portacl/mac_portacl.c b/sys/security/mac_portacl/mac_portacl.c index 1dbd1996e562e..17427ee200f3f 100644 --- a/sys/security/mac_portacl/mac_portacl.c +++ b/sys/security/mac_portacl/mac_portacl.c @@ -87,27 +87,21 @@ static SYSCTL_NODE(_security_mac, OID_AUTO, portacl, CTLFLAG_RW, 0, "TrustedBSD mac_portacl policy controls"); static int portacl_enabled = 1; -SYSCTL_INT(_security_mac_portacl, OID_AUTO, enabled, CTLFLAG_RW, +SYSCTL_INT(_security_mac_portacl, OID_AUTO, enabled, CTLFLAG_RWTUN, &portacl_enabled, 0, "Enforce portacl policy"); -TUNABLE_INT("security.mac.portacl.enabled", &portacl_enabled); static int portacl_suser_exempt = 1; -SYSCTL_INT(_security_mac_portacl, OID_AUTO, suser_exempt, CTLFLAG_RW, +SYSCTL_INT(_security_mac_portacl, OID_AUTO, suser_exempt, CTLFLAG_RWTUN, &portacl_suser_exempt, 0, "Privilege permits binding of any port"); -TUNABLE_INT("security.mac.portacl.suser_exempt", - &portacl_suser_exempt); static int portacl_autoport_exempt = 1; -SYSCTL_INT(_security_mac_portacl, OID_AUTO, autoport_exempt, CTLFLAG_RW, +SYSCTL_INT(_security_mac_portacl, OID_AUTO, autoport_exempt, CTLFLAG_RWTUN, &portacl_autoport_exempt, 0, "Allow automatic allocation through " "binding port 0 if not IP_PORTRANGELOW"); -TUNABLE_INT("security.mac.portacl.autoport_exempt", - &portacl_autoport_exempt); static int portacl_port_high = 1023; -SYSCTL_INT(_security_mac_portacl, OID_AUTO, port_high, CTLFLAG_RW, +SYSCTL_INT(_security_mac_portacl, OID_AUTO, port_high, CTLFLAG_RWTUN, &portacl_port_high, 0, "Highest port to enforce for"); -TUNABLE_INT("security.mac.portacl.port_high", &portacl_port_high); static MALLOC_DEFINE(M_PORTACL, "portacl_rule", "Rules for mac_portacl"); diff --git a/sys/sparc64/pci/psycho.c b/sys/sparc64/pci/psycho.c index ec8d90fe22cb4..57e0f4817b5ae 100644 --- a/sys/sparc64/pci/psycho.c +++ b/sys/sparc64/pci/psycho.c @@ -167,7 +167,6 @@ EARLY_DRIVER_MODULE(psycho, nexus, psycho_driver, psycho_devclass, NULL, NULL, static SYSCTL_NODE(_hw, OID_AUTO, psycho, CTLFLAG_RD, 0, "psycho parameters"); static u_int psycho_powerfail = 1; -TUNABLE_INT("hw.psycho.powerfail", &psycho_powerfail); SYSCTL_UINT(_hw_psycho, OID_AUTO, powerfail, CTLFLAG_RDTUN, &psycho_powerfail, 0, "powerfail action (0: none, 1: shutdown (default), 2: debugger)"); diff --git a/sys/sys/malloc.h b/sys/sys/malloc.h index 8f51606b72ffb..dcb4290a8acb7 100644 --- a/sys/sys/malloc.h +++ b/sys/sys/malloc.h @@ -134,7 +134,7 @@ struct malloc_type_header { struct malloc_type type[1] = { \ { NULL, M_MAGIC, shortdesc, NULL } \ }; \ - SYSINIT(type##_init, SI_SUB_KMEM, SI_ORDER_SECOND, malloc_init, \ + SYSINIT(type##_init, SI_SUB_KMEM, SI_ORDER_THIRD, malloc_init, \ type); \ SYSUNINIT(type##_uninit, SI_SUB_KMEM, SI_ORDER_ANY, \ malloc_uninit, type) diff --git a/sys/sys/param.h b/sys/sys/param.h index 4b487b30e400f..ccbb70ab9cf0f 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1100023 /* Master, propagated to newvers */ +#define __FreeBSD_version 1100024 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h index 02faa934bef2d..0473eb72ebb1c 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -83,7 +83,7 @@ struct ctlname { #define CTLFLAG_DYN 0x02000000 /* Dynamic oid - can be freed */ #define CTLFLAG_SKIP 0x01000000 /* Skip this sysctl when listing */ #define CTLMASK_SECURE 0x00F00000 /* Secure level */ -#define CTLFLAG_TUN 0x00080000 /* Tunable variable */ +#define CTLFLAG_TUN 0x00080000 /* Default value is loaded from getenv() */ #define CTLFLAG_RDTUN (CTLFLAG_RD|CTLFLAG_TUN) #define CTLFLAG_RWTUN (CTLFLAG_RW|CTLFLAG_TUN) #define CTLFLAG_MPSAFE 0x00040000 /* Handler is MP safe */ @@ -92,6 +92,7 @@ struct ctlname { #define CTLFLAG_CAPRD 0x00008000 /* Can be read in capability mode */ #define CTLFLAG_CAPWR 0x00004000 /* Can be written in capability mode */ #define CTLFLAG_STATS 0x00002000 /* Statistics, not a tuneable */ +#define CTLFLAG_NOFETCH 0x00001000 /* Don't fetch tunable from getenv() */ #define CTLFLAG_CAPRW (CTLFLAG_CAPRD|CTLFLAG_CAPWR) /* @@ -161,6 +162,7 @@ SLIST_HEAD(sysctl_oid_list, sysctl_oid); * be hidden behind it, expanded by the handler. */ struct sysctl_oid { + struct sysctl_oid_list oid_children; struct sysctl_oid_list *oid_parent; SLIST_ENTRY(sysctl_oid) oid_link; int oid_number; @@ -200,14 +202,16 @@ void sysctl_register_oid(struct sysctl_oid *oidp); void sysctl_unregister_oid(struct sysctl_oid *oidp); /* Declare a static oid to allow child oids to be added to it. */ -#define SYSCTL_DECL(name) \ - extern struct sysctl_oid_list sysctl_##name##_children +#define SYSCTL_DECL(name) \ + extern struct sysctl_oid sysctl__##name /* Hide these in macros. */ -#define SYSCTL_CHILDREN(oid_ptr) \ - (struct sysctl_oid_list *)(oid_ptr)->oid_arg1 -#define SYSCTL_CHILDREN_SET(oid_ptr, val) (oid_ptr)->oid_arg1 = (val) -#define SYSCTL_STATIC_CHILDREN(oid_name) (&sysctl_##oid_name##_children) +#define SYSCTL_CHILDREN(oid_ptr) (&(oid_ptr)->oid_children) +#define SYSCTL_PARENT(oid_ptr) \ + (((oid_ptr)->oid_parent != &sysctl__children) ? \ + __containerof((oid_ptr)->oid_parent, struct sysctl_oid, \ + oid_children) : (struct sysctl_oid *)NULL) +#define SYSCTL_STATIC_CHILDREN(oid_name) (&sysctl__##oid_name.oid_children) /* === Structs and macros related to context handling. === */ @@ -220,7 +224,7 @@ struct sysctl_ctx_entry { TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); #define SYSCTL_NODE_CHILDREN(parent, name) \ - sysctl_##parent##_##name##_children + sysctl__##parent##_##name.oid_children /* * These macros provide type safety for sysctls. SYSCTL_ALLOWED_TYPES() @@ -275,29 +279,47 @@ SYSCTL_ALLOWED_TYPES(UINT64, uint64_t *a; unsigned long long *b; ); #define __DESCR(d) "" #endif -/* This constructs a "raw" MIB oid. */ -#define SYSCTL_OID(parent, nbr, name, kind, a1, a2, handler, fmt, descr)\ - static struct sysctl_oid sysctl__##parent##_##name = { \ - .oid_parent = &sysctl_##parent##_children, \ +/* This macro is only for internal use */ +#define SYSCTL_OID_RAW(id, parent_child_head, nbr, name, kind, a1, a2, handler, fmt, descr) \ + struct sysctl_oid id = { \ + .oid_parent = (parent_child_head), \ + .oid_children = SLIST_HEAD_INITIALIZER(&id.oid_children), \ .oid_number = (nbr), \ .oid_kind = (kind), \ .oid_arg1 = (a1), \ .oid_arg2 = (a2), \ - .oid_name = #name, \ + .oid_name = (name), \ .oid_handler = (handler), \ .oid_fmt = (fmt), \ .oid_descr = __DESCR(descr) \ }; \ - DATA_SET(sysctl_set, sysctl__##parent##_##name) + DATA_SET(sysctl_set, id) + +/* This constructs a static "raw" MIB oid. */ +#define SYSCTL_OID(parent, nbr, name, kind, a1, a2, handler, fmt, descr) \ + static SYSCTL_OID_RAW(sysctl__##parent##_##name, \ + SYSCTL_CHILDREN(&sysctl__##parent), \ + nbr, #name, kind, a1, a2, handler, fmt, descr) + +/* This constructs a global "raw" MIB oid. */ +#define SYSCTL_OID_GLOBAL(parent, nbr, name, kind, a1, a2, handler, fmt, descr) \ + SYSCTL_OID_RAW(sysctl__##parent##_##name, \ + SYSCTL_CHILDREN(&sysctl__##parent), \ + nbr, #name, kind, a1, a2, handler, fmt, descr) #define SYSCTL_ADD_OID(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, descr) \ sysctl_add_oid(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, __DESCR(descr)) +/* This constructs a root node from which other nodes can hang. */ +#define SYSCTL_ROOT_NODE(nbr, name, access, handler, descr) \ + SYSCTL_OID_RAW(sysctl___##name, &sysctl__children, \ + nbr, #name, CTLTYPE_NODE|(access), NULL, 0, \ + handler, "N", descr) + /* This constructs a node from which other oids can hang. */ #define SYSCTL_NODE(parent, nbr, name, access, handler, descr) \ - struct sysctl_oid_list SYSCTL_NODE_CHILDREN(parent, name); \ - SYSCTL_OID(parent, nbr, name, CTLTYPE_NODE|(access), \ - (void*)&SYSCTL_NODE_CHILDREN(parent, name), 0, handler, "N", descr) + SYSCTL_OID_GLOBAL(parent, nbr, name, CTLTYPE_NODE|(access), \ + NULL, 0, handler, "N", descr) #define SYSCTL_ADD_NODE(ctx, parent, nbr, name, access, handler, descr) \ sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_NODE|(access), \ diff --git a/sys/vm/memguard.c b/sys/vm/memguard.c index 1d3b4125a149c..d502ca569bdec 100644 --- a/sys/vm/memguard.c +++ b/sys/vm/memguard.c @@ -67,7 +67,7 @@ static SYSCTL_NODE(_vm, OID_AUTO, memguard, CTLFLAG_RW, NULL, "MemGuard data"); * reserved for MemGuard. */ static u_int vm_memguard_divisor; -SYSCTL_UINT(_vm_memguard, OID_AUTO, divisor, CTLFLAG_RDTUN, +SYSCTL_UINT(_vm_memguard, OID_AUTO, divisor, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &vm_memguard_divisor, 0, "(kmem_size/memguard_divisor) == memguard submap size"); @@ -132,8 +132,7 @@ SYSCTL_ULONG(_vm_memguard, OID_AUTO, fail_pgs, CTLFLAG_RD, #define MG_GUARD_ALLLARGE 0x002 #define MG_GUARD_NOFREE 0x004 static int memguard_options = MG_GUARD_AROUND; -TUNABLE_INT("vm.memguard.options", &memguard_options); -SYSCTL_INT(_vm_memguard, OID_AUTO, options, CTLFLAG_RW, +SYSCTL_INT(_vm_memguard, OID_AUTO, options, CTLFLAG_RWTUN, &memguard_options, 0, "MemGuard options:\n" "\t0x001 - add guard pages around each allocation\n" @@ -149,8 +148,7 @@ SYSCTL_ULONG(_vm_memguard, OID_AUTO, minsize_reject, CTLFLAG_RD, static u_int memguard_frequency; static u_long memguard_frequency_hits; -TUNABLE_INT("vm.memguard.frequency", &memguard_frequency); -SYSCTL_UINT(_vm_memguard, OID_AUTO, frequency, CTLFLAG_RW, +SYSCTL_UINT(_vm_memguard, OID_AUTO, frequency, CTLFLAG_RWTUN, &memguard_frequency, 0, "Times in 100000 that MemGuard will randomly run"); SYSCTL_ULONG(_vm_memguard, OID_AUTO, frequency_hits, CTLFLAG_RD, &memguard_frequency_hits, 0, "# times MemGuard randomly chose"); diff --git a/sys/vm/redzone.c b/sys/vm/redzone.c index e4b5f6ccc9c0d..a66a793f27f05 100644 --- a/sys/vm/redzone.c +++ b/sys/vm/redzone.c @@ -41,8 +41,7 @@ static u_long redzone_extra_mem = 0; SYSCTL_ULONG(_vm_redzone, OID_AUTO, extra_mem, CTLFLAG_RD, &redzone_extra_mem, 0, "Extra memory allocated by redzone"); static int redzone_panic = 0; -TUNABLE_INT("vm.redzone.panic", &redzone_panic); -SYSCTL_INT(_vm_redzone, OID_AUTO, panic, CTLFLAG_RW, &redzone_panic, 0, +SYSCTL_INT(_vm_redzone, OID_AUTO, panic, CTLFLAG_RWTUN, &redzone_panic, 0, "Panic when buffer corruption is detected"); #define REDZONE_CHSIZE (16) diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c index 62f4912a3dc48..81b714a9f32d0 100644 --- a/sys/vm/uma_core.c +++ b/sys/vm/uma_core.c @@ -281,8 +281,7 @@ SYSCTL_PROC(_vm, OID_AUTO, zone_stats, CTLFLAG_RD|CTLTYPE_STRUCT, 0, 0, sysctl_vm_zone_stats, "s,struct uma_type_header", "Zone Stats"); static int zone_warnings = 1; -TUNABLE_INT("vm.zone_warnings", &zone_warnings); -SYSCTL_INT(_vm, OID_AUTO, zone_warnings, CTLFLAG_RW, &zone_warnings, 0, +SYSCTL_INT(_vm, OID_AUTO, zone_warnings, CTLFLAG_RWTUN, &zone_warnings, 0, "Warn when UMA zones becomes full"); /* diff --git a/sys/vm/vm_init.c b/sys/vm/vm_init.c index 30faa5a2aeb22..be1038758824a 100644 --- a/sys/vm/vm_init.c +++ b/sys/vm/vm_init.c @@ -91,8 +91,7 @@ __FBSDID("$FreeBSD$"); long physmem; static int exec_map_entries = 16; -TUNABLE_INT("vm.exec_map_entries", &exec_map_entries); -SYSCTL_INT(_vm, OID_AUTO, exec_map_entries, CTLFLAG_RD, &exec_map_entries, 0, +SYSCTL_INT(_vm, OID_AUTO, exec_map_entries, CTLFLAG_RDTUN, &exec_map_entries, 0, "Maximum number of simultaneous execs"); /* diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 62eb393144088..b5108e2917563 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -3471,8 +3471,7 @@ vm_map_stack_locked(vm_map_t map, vm_offset_t addrbos, vm_size_t max_ssize, } static int stack_guard_page = 0; -TUNABLE_INT("security.bsd.stack_guard_page", &stack_guard_page); -SYSCTL_INT(_security_bsd, OID_AUTO, stack_guard_page, CTLFLAG_RW, +SYSCTL_INT(_security_bsd, OID_AUTO, stack_guard_page, CTLFLAG_RWTUN, &stack_guard_page, 0, "Insert stack guard page ahead of the growable segments."); diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c index a5248399ab9a2..e94090c53e88e 100644 --- a/sys/vm/vm_mmap.c +++ b/sys/vm/vm_mmap.c @@ -92,9 +92,8 @@ __FBSDID("$FreeBSD$"); #endif int old_mlock = 0; -SYSCTL_INT(_vm, OID_AUTO, old_mlock, CTLFLAG_RW | CTLFLAG_TUN, &old_mlock, 0, +SYSCTL_INT(_vm, OID_AUTO, old_mlock, CTLFLAG_RWTUN, &old_mlock, 0, "Do not apply RLIMIT_MEMLOCK on mlockall"); -TUNABLE_INT("vm.old_mlock", &old_mlock); #ifdef MAP_32BIT #define MAP_32BIT_MAX_ADDR ((vm_offset_t)1 << 31) diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index 49c3edeeacf38..4e30a3f5aded0 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -134,8 +134,7 @@ long first_page; int vm_page_zero_count; static int boot_pages = UMA_BOOT_PAGES; -TUNABLE_INT("vm.boot_pages", &boot_pages); -SYSCTL_INT(_vm, OID_AUTO, boot_pages, CTLFLAG_RD, &boot_pages, 0, +SYSCTL_INT(_vm, OID_AUTO, boot_pages, CTLFLAG_RDTUN, &boot_pages, 0, "number of pages allocated for bootstrapping the VM system"); static int pa_tryrelock_restart; diff --git a/sys/vm/vm_radix.c b/sys/vm/vm_radix.c index bb45ba0d801c3..4f4b6d24d526a 100644 --- a/sys/vm/vm_radix.c +++ b/sys/vm/vm_radix.c @@ -302,7 +302,7 @@ vm_radix_reserve_kva(void *arg __unused) sizeof(struct vm_radix_node)))) panic("%s: unable to reserve KVA", __func__); } -SYSINIT(vm_radix_reserve_kva, SI_SUB_KMEM, SI_ORDER_SECOND, +SYSINIT(vm_radix_reserve_kva, SI_SUB_KMEM, SI_ORDER_THIRD, vm_radix_reserve_kva, NULL); #endif diff --git a/sys/vm/vm_zeroidle.c b/sys/vm/vm_zeroidle.c index 458539eb1782f..dac4abe3a46eb 100644 --- a/sys/vm/vm_zeroidle.c +++ b/sys/vm/vm_zeroidle.c @@ -55,10 +55,9 @@ __FBSDID("$FreeBSD$"); #include static int idlezero_enable_default = 0; -TUNABLE_INT("vm.idlezero_enable", &idlezero_enable_default); /* Defer setting the enable flag until the kthread is running. */ static int idlezero_enable = 0; -SYSCTL_INT(_vm, OID_AUTO, idlezero_enable, CTLFLAG_RW, &idlezero_enable, 0, +SYSCTL_INT(_vm, OID_AUTO, idlezero_enable, CTLFLAG_RWTUN, &idlezero_enable, 0, "Allow the kernel to use idle cpu cycles to zero-out pages"); /* * Implement the pre-zeroed page mechanism. diff --git a/sys/x86/cpufreq/hwpstate.c b/sys/x86/cpufreq/hwpstate.c index e86e31aab4cda..d4c70b773c703 100644 --- a/sys/x86/cpufreq/hwpstate.c +++ b/sys/x86/cpufreq/hwpstate.c @@ -118,9 +118,8 @@ static int hwpstate_get_info_from_msr(device_t dev); static int hwpstate_goto_pstate(device_t dev, int pstate_id); static int hwpstate_verbose = 0; -SYSCTL_INT(_debug, OID_AUTO, hwpstate_verbose, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_debug, OID_AUTO, hwpstate_verbose, CTLFLAG_RWTUN, &hwpstate_verbose, 0, "Debug hwpstate"); -TUNABLE_INT("debug.hwpstate_verbose", &hwpstate_verbose); static device_method_t hwpstate_methods[] = { /* Device interface */ diff --git a/sys/x86/iommu/intel_utils.c b/sys/x86/iommu/intel_utils.c index e221a1e6546bc..444329c581fe2 100644 --- a/sys/x86/iommu/intel_utils.c +++ b/sys/x86/iommu/intel_utils.c @@ -549,17 +549,16 @@ dmar_barrier_exit(struct dmar_unit *dmar, u_int barrier_id) int dmar_match_verbose; -static SYSCTL_NODE(_hw, OID_AUTO, dmar, CTLFLAG_RD, NULL, - ""); -SYSCTL_INT(_hw_dmar, OID_AUTO, tbl_pagecnt, CTLFLAG_RD | CTLFLAG_TUN, +static SYSCTL_NODE(_hw, OID_AUTO, dmar, CTLFLAG_RD, NULL, ""); +SYSCTL_INT(_hw_dmar, OID_AUTO, tbl_pagecnt, CTLFLAG_RD, &dmar_tbl_pagecnt, 0, "Count of pages used for DMAR pagetables"); -SYSCTL_INT(_hw_dmar, OID_AUTO, match_verbose, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_dmar, OID_AUTO, match_verbose, CTLFLAG_RWTUN, &dmar_match_verbose, 0, "Verbose matching of the PCI devices to DMAR paths"); #ifdef INVARIANTS int dmar_check_free; -SYSCTL_INT(_hw_dmar, OID_AUTO, check_free, CTLFLAG_RW | CTLFLAG_TUN, +SYSCTL_INT(_hw_dmar, OID_AUTO, check_free, CTLFLAG_RWTUN, &dmar_check_free, 0, "Check the GPA RBtree for free_down and free_after validity"); #endif diff --git a/sys/x86/pci/pci_bus.c b/sys/x86/pci/pci_bus.c index 88cabc724fe3b..f64659eec2ada 100644 --- a/sys/x86/pci/pci_bus.c +++ b/sys/x86/pci/pci_bus.c @@ -575,7 +575,6 @@ legacy_pcib_write_ivar(device_t dev, device_t child, int which, SYSCTL_DECL(_hw_pci); static unsigned long host_mem_start = 0x80000000; -TUNABLE_ULONG("hw.pci.host_mem_start", &host_mem_start); SYSCTL_ULONG(_hw_pci, OID_AUTO, host_mem_start, CTLFLAG_RDTUN, &host_mem_start, 0, "Limit the host bridge memory to being above this address."); diff --git a/sys/x86/x86/dump_machdep.c b/sys/x86/x86/dump_machdep.c index 5c874f4847b66..30fa719467ffc 100644 --- a/sys/x86/x86/dump_machdep.c +++ b/sys/x86/x86/dump_machdep.c @@ -53,8 +53,7 @@ __FBSDID("$FreeBSD$"); CTASSERT(sizeof(struct kerneldumpheader) == 512); int do_minidump = 1; -TUNABLE_INT("debug.minidump", &do_minidump); -SYSCTL_INT(_debug, OID_AUTO, minidump, CTLFLAG_RW, &do_minidump, 0, +SYSCTL_INT(_debug, OID_AUTO, minidump, CTLFLAG_RWTUN, &do_minidump, 0, "Enable mini crash dumps"); /* diff --git a/sys/x86/x86/io_apic.c b/sys/x86/x86/io_apic.c index ec469ad685e74..5667120661b40 100644 --- a/sys/x86/x86/io_apic.c +++ b/sys/x86/x86/io_apic.c @@ -134,7 +134,6 @@ static SYSCTL_NODE(_hw, OID_AUTO, apic, CTLFLAG_RD, 0, "APIC options"); static int enable_extint; SYSCTL_INT(_hw_apic, OID_AUTO, enable_extint, CTLFLAG_RDTUN, &enable_extint, 0, "Enable the ExtINT pin in the first I/O APIC"); -TUNABLE_INT("hw.apic.enable_extint", &enable_extint); static __inline void _ioapic_eoi_source(struct intsrc *isrc) diff --git a/sys/x86/x86/mca.c b/sys/x86/x86/mca.c index 8a0d2b12e9c6e..347d570a1fa2f 100644 --- a/sys/x86/x86/mca.c +++ b/sys/x86/x86/mca.c @@ -92,12 +92,10 @@ static SYSCTL_NODE(_hw, OID_AUTO, mca, CTLFLAG_RD, NULL, "Machine Check Architecture"); static int mca_enabled = 1; -TUNABLE_INT("hw.mca.enabled", &mca_enabled); SYSCTL_INT(_hw_mca, OID_AUTO, enabled, CTLFLAG_RDTUN, &mca_enabled, 0, "Administrative toggle for machine check support"); static int amd10h_L1TP = 1; -TUNABLE_INT("hw.mca.amd10h_L1TP", &amd10h_L1TP); SYSCTL_INT(_hw_mca, OID_AUTO, amd10h_L1TP, CTLFLAG_RDTUN, &amd10h_L1TP, 0, "Administrative toggle for logging of level one TLB parity (L1TP) errors"); diff --git a/sys/x86/x86/tsc.c b/sys/x86/x86/tsc.c index 2a6c81d786d3f..54c4d02497cf4 100644 --- a/sys/x86/x86/tsc.c +++ b/sys/x86/x86/tsc.c @@ -58,34 +58,28 @@ static eventhandler_tag tsc_levels_tag, tsc_pre_tag, tsc_post_tag; SYSCTL_INT(_kern_timecounter, OID_AUTO, invariant_tsc, CTLFLAG_RDTUN, &tsc_is_invariant, 0, "Indicates whether the TSC is P-state invariant"); -TUNABLE_INT("kern.timecounter.invariant_tsc", &tsc_is_invariant); #ifdef SMP int smp_tsc; SYSCTL_INT(_kern_timecounter, OID_AUTO, smp_tsc, CTLFLAG_RDTUN, &smp_tsc, 0, "Indicates whether the TSC is safe to use in SMP mode"); -TUNABLE_INT("kern.timecounter.smp_tsc", &smp_tsc); int smp_tsc_adjust = 0; SYSCTL_INT(_kern_timecounter, OID_AUTO, smp_tsc_adjust, CTLFLAG_RDTUN, &smp_tsc_adjust, 0, "Try to adjust TSC on APs to match BSP"); -TUNABLE_INT("kern.timecounter.smp_tsc_adjust", &smp_tsc_adjust); #endif static int tsc_shift = 1; SYSCTL_INT(_kern_timecounter, OID_AUTO, tsc_shift, CTLFLAG_RDTUN, &tsc_shift, 0, "Shift to pre-apply for the maximum TSC frequency"); -TUNABLE_INT("kern.timecounter.tsc_shift", &tsc_shift); static int tsc_disabled; SYSCTL_INT(_machdep, OID_AUTO, disable_tsc, CTLFLAG_RDTUN, &tsc_disabled, 0, "Disable x86 Time Stamp Counter"); -TUNABLE_INT("machdep.disable_tsc", &tsc_disabled); static int tsc_skip_calibration; SYSCTL_INT(_machdep, OID_AUTO, disable_tsc_calibration, CTLFLAG_RDTUN, &tsc_skip_calibration, 0, "Disable TSC frequency calibration"); -TUNABLE_INT("machdep.disable_tsc_calibration", &tsc_skip_calibration); static void tsc_freq_changed(void *arg, const struct cf_level *level, int status); -- cgit v1.3 From 88e0a63961159e9bbd326b6270efe8fb74d13eb7 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Mon, 7 Jul 2014 05:17:16 +0000 Subject: Improve support for Intel Lynx Point USB 3.0 controllers by masking the port routing bits like done in Linux. MFC after: 1 week Tested by: Tur-Wei Chan --- sys/dev/usb/controller/xhci_pci.c | 3 +++ sys/dev/usb/controller/xhcireg.h | 2 ++ 2 files changed, 5 insertions(+) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/xhci_pci.c b/sys/dev/usb/controller/xhci_pci.c index dc5a6e9dd445a..3d18d34c0a087 100644 --- a/sys/dev/usb/controller/xhci_pci.c +++ b/sys/dev/usb/controller/xhci_pci.c @@ -157,6 +157,9 @@ xhci_pci_port_route(device_t self, uint32_t set, uint32_t clear) temp |= set; temp &= ~clear; + /* Don't set bits which the hardware doesn't support */ + temp &= pci_read_config(self, PCI_XHCI_INTEL_USB3PRM, 4); + pci_write_config(self, PCI_XHCI_INTEL_USB3_PSSEN, temp, 4); pci_write_config(self, PCI_XHCI_INTEL_XUSB2PR, temp, 4); diff --git a/sys/dev/usb/controller/xhcireg.h b/sys/dev/usb/controller/xhcireg.h index bd1d635cff778..a0b7397110811 100644 --- a/sys/dev/usb/controller/xhcireg.h +++ b/sys/dev/usb/controller/xhcireg.h @@ -35,7 +35,9 @@ #define PCI_XHCI_FLADJ 0x61 /* RW frame length adjust */ #define PCI_XHCI_INTEL_XUSB2PR 0xD0 /* Intel USB2 Port Routing */ +#define PCI_XHCI_INTEL_USB2PRM 0xD4 /* Intel USB2 Port Routing Mask */ #define PCI_XHCI_INTEL_USB3_PSSEN 0xD8 /* Intel USB3 Port SuperSpeed Enable */ +#define PCI_XHCI_INTEL_USB3PRM 0xDC /* Intel USB3 Port Routing Mask */ /* XHCI capability registers */ #define XHCI_CAPLENGTH 0x00 /* RO capability */ -- cgit v1.3 From 0a54509ff96034fc3a2fdebfa17223d6eab6cf75 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Wed, 16 Jul 2014 06:14:41 +0000 Subject: Improve support for Intel Lynx Point USB 3.0 controllers by using the USB 2.0 port mask in addition to the USB 3.0 port mask. The hardware does not always accept when writing -1U to the port switching registers. MFC after: 3 days Tested by: Huang Wen Hui --- sys/dev/usb/controller/xhci_pci.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/xhci_pci.c b/sys/dev/usb/controller/xhci_pci.c index 3d18d34c0a087..f0b789a3d66b2 100644 --- a/sys/dev/usb/controller/xhci_pci.c +++ b/sys/dev/usb/controller/xhci_pci.c @@ -150,6 +150,8 @@ static int xhci_pci_port_route(device_t self, uint32_t set, uint32_t clear) { uint32_t temp; + uint32_t usb3_mask; + uint32_t usb2_mask; temp = pci_read_config(self, PCI_XHCI_INTEL_USB3_PSSEN, 4) | pci_read_config(self, PCI_XHCI_INTEL_XUSB2PR, 4); @@ -158,10 +160,11 @@ xhci_pci_port_route(device_t self, uint32_t set, uint32_t clear) temp &= ~clear; /* Don't set bits which the hardware doesn't support */ - temp &= pci_read_config(self, PCI_XHCI_INTEL_USB3PRM, 4); + usb3_mask = pci_read_config(self, PCI_XHCI_INTEL_USB3PRM, 4); + usb2_mask = pci_read_config(self, PCI_XHCI_INTEL_USB2PRM, 4); - pci_write_config(self, PCI_XHCI_INTEL_USB3_PSSEN, temp, 4); - pci_write_config(self, PCI_XHCI_INTEL_XUSB2PR, temp, 4); + pci_write_config(self, PCI_XHCI_INTEL_USB3_PSSEN, temp & usb3_mask, 4); + pci_write_config(self, PCI_XHCI_INTEL_XUSB2PR, temp & usb2_mask, 4); device_printf(self, "Port routing mask set to 0x%08x\n", temp); -- cgit v1.3 From 0722247439b4e2c9aa9342dc59b93a9bffb18c5a Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Sat, 26 Jul 2014 19:08:52 +0000 Subject: Split the XHCI TRB allocations into smaller parts, so that we don't end up allocating contiguous busdma buffers above PAGE_SIZE bytes. MFC after: 1 week Tested by: Ruslan Bukin --- sys/dev/usb/controller/xhci.c | 36 ++++++++++++++++++------------------ sys/dev/usb/controller/xhci.h | 8 ++++---- 2 files changed, 22 insertions(+), 22 deletions(-) (limited to 'sys/dev/usb/controller') diff --git a/sys/dev/usb/controller/xhci.c b/sys/dev/usb/controller/xhci.c index cdfa7d4062883..5e9029c5abe9e 100644 --- a/sys/dev/usb/controller/xhci.c +++ b/sys/dev/usb/controller/xhci.c @@ -2678,24 +2678,23 @@ xhci_alloc_device_ext(struct usb_device *udev) goto error; } - pc = &sc->sc_hw.devs[index].endpoint_pc; - pg = &sc->sc_hw.devs[index].endpoint_pg; + /* initialise all endpoint LINK TRBs */ - /* need to initialize the page cache */ - pc->tag_parent = sc->sc_bus.dma_parent_tag; + for (i = 0; i != XHCI_MAX_ENDPOINTS; i++) { - if (usb_pc_alloc_mem(pc, pg, - sizeof(struct xhci_dev_endpoint_trbs), XHCI_PAGE_SIZE)) { - goto error; - } + pc = &sc->sc_hw.devs[index].endpoint_pc[i]; + pg = &sc->sc_hw.devs[index].endpoint_pg[i]; - /* initialise all endpoint LINK TRBs */ + /* need to initialize the page cache */ + pc->tag_parent = sc->sc_bus.dma_parent_tag; - for (i = 0; i != XHCI_MAX_ENDPOINTS; i++) { + if (usb_pc_alloc_mem(pc, pg, + sizeof(struct xhci_dev_endpoint_trbs), XHCI_TRB_ALIGN)) { + goto error; + } /* lookup endpoint TRB ring */ - usbd_get_page(pc, (uintptr_t)& - ((struct xhci_dev_endpoint_trbs *)0)->trb[i][0], &buf_ep); + usbd_get_page(pc, 0, &buf_ep); /* get TRB pointer */ trb = buf_ep.buffer; @@ -2709,9 +2708,9 @@ xhci_alloc_device_ext(struct usb_device *udev) trb->dwTrb2 = htole32(XHCI_TRB_2_IRQ_SET(0)); trb->dwTrb3 = htole32(XHCI_TRB_3_CYCLE_BIT | XHCI_TRB_3_TYPE_SET(XHCI_TRB_TYPE_LINK)); - } - usb_pc_cpu_flush(pc); + usb_pc_cpu_flush(pc); + } xhci_set_slot_pointer(sc, index, buf_dev.physaddr); @@ -2728,13 +2727,15 @@ xhci_free_device_ext(struct usb_device *udev) { struct xhci_softc *sc = XHCI_BUS2SC(udev->bus); uint8_t index; + uint8_t i; index = udev->controller_slot_id; xhci_set_slot_pointer(sc, index, 0); usb_pc_free_mem(&sc->sc_hw.devs[index].device_pc); usb_pc_free_mem(&sc->sc_hw.devs[index].input_pc); - usb_pc_free_mem(&sc->sc_hw.devs[index].endpoint_pc); + for (i = 0; i != XHCI_MAX_ENDPOINTS; i++) + usb_pc_free_mem(&sc->sc_hw.devs[index].endpoint_pc[i]); } static struct xhci_endpoint_ext * @@ -2755,10 +2756,9 @@ xhci_get_endpoint_ext(struct usb_device *udev, struct usb_endpoint_descriptor *e index = udev->controller_slot_id; - pc = &sc->sc_hw.devs[index].endpoint_pc; + pc = &sc->sc_hw.devs[index].endpoint_pc[epno]; - usbd_get_page(pc, (uintptr_t)&((struct xhci_dev_endpoint_trbs *)0)-> - trb[epno][0], &buf_ep); + usbd_get_page(pc, 0, &buf_ep); pepext = &sc->sc_hw.devs[index].endp[epno]; pepext->page_cache = pc; diff --git a/sys/dev/usb/controller/xhci.h b/sys/dev/usb/controller/xhci.h index b000e4f11dd6c..408b429dff0ab 100644 --- a/sys/dev/usb/controller/xhci.h +++ b/sys/dev/usb/controller/xhci.h @@ -316,8 +316,8 @@ struct xhci_trb { } __aligned(4); struct xhci_dev_endpoint_trbs { - struct xhci_trb trb[XHCI_MAX_ENDPOINTS] - [(XHCI_MAX_STREAMS * XHCI_MAX_TRANSFERS) + XHCI_MAX_STREAMS]; + struct xhci_trb trb[(XHCI_MAX_STREAMS * + XHCI_MAX_TRANSFERS) + XHCI_MAX_STREAMS]; }; #define XHCI_TD_PAGE_NBUF 17 /* units, room enough for 64Kbytes */ @@ -385,11 +385,11 @@ enum { struct xhci_hw_dev { struct usb_page_cache device_pc; struct usb_page_cache input_pc; - struct usb_page_cache endpoint_pc; + struct usb_page_cache endpoint_pc[XHCI_MAX_ENDPOINTS]; struct usb_page device_pg; struct usb_page input_pg; - struct usb_page endpoint_pg; + struct usb_page endpoint_pg[XHCI_MAX_ENDPOINTS]; struct xhci_endpoint_ext endp[XHCI_MAX_ENDPOINTS]; -- cgit v1.3