svn commit: r343391 - head/tools/tools/tinybsd

2019-01-23 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Thu Jan 24 06:34:29 2019
New Revision: 343391
URL: https://svnweb.freebsd.org/changeset/base/343391

Log:
  Fix prompt for MFSROOT in tinybsd
  
  tinybsd offers two choices when prompting user for MFSROOT: 'YES'
  and 'NO'. Script logic only handles 'yes'. Change offered values
  to lower case.
  
  PR:   131059
  Submitted by: Brock Williams 
  MFC after:1 week

Modified:
  head/tools/tools/tinybsd/tinybsd

Modified: head/tools/tools/tinybsd/tinybsd
==
--- head/tools/tools/tinybsd/tinybsdThu Jan 24 03:50:27 2019
(r343390)
+++ head/tools/tools/tinybsd/tinybsdThu Jan 24 06:34:29 2019
(r343391)
@@ -206,7 +206,7 @@ loadconfig () {
   break
 fi
   done
-  MFSROOT=`confirm_action "$MFSROOT" "Use an MFSROOT? (YES/NO)"`
+  MFSROOT=`confirm_action "$MFSROOT" "Use an MFSROOT? (yes/no)"`
   IMG=`confirm_action "$IMG" "Image file to generate?"`
 
 # example of formatted value (NNN in this case)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r343382 - head/sys/dev/iwm

2019-01-23 Thread Kyle Evans
Author: kevans
Date: Thu Jan 24 03:46:35 2019
New Revision: 343382
URL: https://svnweb.freebsd.org/changeset/base/343382

Log:
  iwm - Avoid Tx watchdog timeout, when dropping a connection.
  
  Submitted by: Augustin Cavalier  (Haiku)
  Obtained from:DragonFlyBSD (3e12596fb5c55351517cdd741d72979388a8c75c)

Modified:
  head/sys/dev/iwm/if_iwm.c

Modified: head/sys/dev/iwm/if_iwm.c
==
--- head/sys/dev/iwm/if_iwm.c   Thu Jan 24 03:45:55 2019(r343381)
+++ head/sys/dev/iwm/if_iwm.c   Thu Jan 24 03:46:35 2019(r343382)
@@ -4329,6 +4329,10 @@ iwm_newstate(struct ieee80211vap *vap, enum ieee80211_
IEEE80211_UNLOCK(ic);
IWM_LOCK(sc);
 
+   /* Avoid Tx watchdog triggering, when a connectionm is dropped. */
+   if (vap->iv_state == IEEE80211_S_RUN && nstate != IEEE80211_S_RUN)
+   sc->sc_tx_timer = 0;
+
if ((sc->sc_flags & IWM_FLAG_SCAN_RUNNING) &&
(nstate == IEEE80211_S_AUTH ||
 nstate == IEEE80211_S_ASSOC ||
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r343385 - head/sys/dev/iwm

2019-01-23 Thread Kyle Evans
Author: kevans
Date: Thu Jan 24 03:48:27 2019
New Revision: 343385
URL: https://svnweb.freebsd.org/changeset/base/343385

Log:
  iwm - Always clear watchdog timer, when bringing down firmware state.
  
  Submitted by: Augustin Cavalier  (Haiku)
  Obtained from:DragonFlyBSD (8abdc2b36a45c4e9c95fc8263ca532ea26633dcb)

Modified:
  head/sys/dev/iwm/if_iwm.c

Modified: head/sys/dev/iwm/if_iwm.c
==
--- head/sys/dev/iwm/if_iwm.c   Thu Jan 24 03:47:47 2019(r343384)
+++ head/sys/dev/iwm/if_iwm.c   Thu Jan 24 03:48:27 2019(r343385)
@@ -4225,6 +4225,9 @@ iwm_bring_down_firmware(struct iwm_softc *sc, struct i
struct iwm_vap *ivp = IWM_VAP(vap);
int error;
 
+   /* Avoid Tx watchdog triggering, when transfers get dropped here. */
+   sc->sc_tx_timer = 0;
+
ivp->iv_auth = 0;
if (sc->sc_firmware_state == 3) {
iwm_xmit_queue_drain(sc);
@@ -4328,10 +4331,6 @@ iwm_newstate(struct ieee80211vap *vap, enum ieee80211_
 
IEEE80211_UNLOCK(ic);
IWM_LOCK(sc);
-
-   /* Avoid Tx watchdog triggering, when a connectionm is dropped. */
-   if (vap->iv_state == IEEE80211_S_RUN && nstate != IEEE80211_S_RUN)
-   sc->sc_tx_timer = 0;
 
if ((sc->sc_flags & IWM_FLAG_SCAN_RUNNING) &&
(nstate == IEEE80211_S_AUTH ||
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r343384 - head/sys/dev/iwm

2019-01-23 Thread Kyle Evans
Author: kevans
Date: Thu Jan 24 03:47:47 2019
New Revision: 343384
URL: https://svnweb.freebsd.org/changeset/base/343384

Log:
  iwm - Clear Time Event active state, when receiving End Notification.
  
  * This hopefully avoids some firmware panics, I was occasionally seeing,
  when iwm disconnects upon losing signal to an access point at some point.
  
  * This is synchronizing the if_iwm_time_event.c file a bit more from the
  corresponding Linux iwlwifi/mvm/time-event.c.
  
  Taken-From: Linux iwlwifi
  
  Submitted by: Augustin Cavalier  (Haiku)
  Obtained from:DragonFlyBSD (e8cb71584a6a72232c13151d60e57f7f229220eb)

Modified:
  head/sys/dev/iwm/if_iwm.c
  head/sys/dev/iwm/if_iwm_time_event.c
  head/sys/dev/iwm/if_iwm_time_event.h
  head/sys/dev/iwm/if_iwmvar.h

Modified: head/sys/dev/iwm/if_iwm.c
==
--- head/sys/dev/iwm/if_iwm.c   Thu Jan 24 03:47:04 2019(r343383)
+++ head/sys/dev/iwm/if_iwm.c   Thu Jan 24 03:47:47 2019(r343384)
@@ -5375,15 +5375,9 @@ iwm_handle_rxb(struct iwm_softc *sc, struct mbuf *m)
break;
}
 
-   case IWM_TIME_EVENT_NOTIFICATION: {
-   struct iwm_time_event_notif *notif;
-   notif = (void *)pkt->data;
-
-   IWM_DPRINTF(sc, IWM_DEBUG_INTR,
-   "TE notif status = 0x%x action = 0x%x\n",
-   notif->status, notif->action);
+   case IWM_TIME_EVENT_NOTIFICATION:
+   iwm_mvm_rx_time_event_notif(sc, pkt);
break;
-   }
 
/*
 * Firmware versions 21 and 22 generate some DEBUG_LOG_MSG

Modified: head/sys/dev/iwm/if_iwm_time_event.c
==
--- head/sys/dev/iwm/if_iwm_time_event.cThu Jan 24 03:47:04 2019
(r343383)
+++ head/sys/dev/iwm/if_iwm_time_event.cThu Jan 24 03:47:47 2019
(r343384)
@@ -159,13 +159,74 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#define TU_TO_HZ(tu)   (((uint64_t)(tu) * 1024 * hz) / 100)
+
+static void
+iwm_mvm_te_clear_data(struct iwm_softc *sc)
+{
+   sc->sc_time_event_uid = 0;
+   sc->sc_time_event_duration = 0;
+   sc->sc_time_event_end_ticks = 0;
+   sc->sc_flags &= ~IWM_FLAG_TE_ACTIVE;
+}
+
 /*
- * For the high priority TE use a time event type that has similar priority to
- * the FW's action scan priority.
+ * Handles a FW notification for an event that is known to the driver.
+ *
+ * @mvm: the mvm component
+ * @te_data: the time event data
+ * @notif: the notification data corresponding the time event data.
  */
-#define IWM_MVM_ROC_TE_TYPE_NORMAL IWM_TE_P2P_DEVICE_DISCOVERABLE
-#define IWM_MVM_ROC_TE_TYPE_MGMT_TX IWM_TE_P2P_CLIENT_ASSOC
+static void
+iwm_mvm_te_handle_notif(struct iwm_softc *sc,
+struct iwm_time_event_notif *notif)
+{
+   IWM_DPRINTF(sc, IWM_DEBUG_TE,
+   "Handle time event notif - UID = 0x%x action %d\n",
+   le32toh(notif->unique_id),
+   le32toh(notif->action));
 
+   if (!le32toh(notif->status)) {
+   const char *msg;
+
+   if (notif->action & htole32(IWM_TE_V2_NOTIF_HOST_EVENT_START))
+   msg = "Time Event start notification failure";
+   else
+   msg = "Time Event end notification failure";
+
+   IWM_DPRINTF(sc, IWM_DEBUG_TE, "%s\n", msg);
+   }
+
+   if (le32toh(notif->action) & IWM_TE_V2_NOTIF_HOST_EVENT_END) {
+   IWM_DPRINTF(sc, IWM_DEBUG_TE,
+   "TE ended - current time %d, estimated end %d\n",
+   ticks, sc->sc_time_event_end_ticks);
+
+   iwm_mvm_te_clear_data(sc);
+   } else if (le32toh(notif->action) & IWM_TE_V2_NOTIF_HOST_EVENT_START) {
+   sc->sc_time_event_end_ticks =
+   ticks + TU_TO_HZ(sc->sc_time_event_duration);
+   } else {
+   device_printf(sc->sc_dev, "Got TE with unknown action\n");
+   }
+}
+
+/*
+ * The Rx handler for time event notifications
+ */
+void
+iwm_mvm_rx_time_event_notif(struct iwm_softc *sc, struct iwm_rx_packet *pkt)
+{
+   struct iwm_time_event_notif *notif = (void *)pkt->data;
+
+   IWM_DPRINTF(sc, IWM_DEBUG_TE,
+   "Time event notification - UID = 0x%x action %d\n",
+   le32toh(notif->unique_id),
+   le32toh(notif->action));
+
+   iwm_mvm_te_handle_notif(sc, notif);
+}
+
 static int
 iwm_mvm_te_notif(struct iwm_softc *sc, struct iwm_rx_packet *pkt,
 void *data)
@@ -241,6 +302,8 @@ iwm_mvm_time_event_send_add(struct iwm_softc *sc, stru
IWM_DPRINTF(sc, IWM_DEBUG_TE,
"Add new TE, duration %d TU\n", le32toh(te_cmd->duration));
 
+   sc->sc_time_event_duration = le32toh(te_cmd->duration);
+
/*
 * Use a 

svn commit: r343378 - head/sys/dev/iwm

2019-01-23 Thread Kyle Evans
Author: kevans
Date: Thu Jan 24 03:44:20 2019
New Revision: 343378
URL: https://svnweb.freebsd.org/changeset/base/343378

Log:
  if_iwm - Update struct iwm_scan_results_notif. Remove old/unused definitions
  
  * Remove outdated notifications IWM_SCAN_ABORT_CMD,
  IWM_SCAN_START_NOTIFICATION and IWM_SCAN_RESULTS_NOTIFICATION.
  
  * Remove unused enum iwm_scan_complete_status.
  
  * Use the updated FW Api version 3 of struct iwm_scan_results_notif.
  
  * No functional change, since struct iwm_scan_results_notif is never
  accessed in iwm at the moment.
  
  Taken-From: Linux iwlwifi commits 1083fd7391e989be52022f0f338e9dadc048b063
and 75118fdb63496e4611ab50380499ddd62b9de69f.
  
  Submitted by: Augustin Cavalier  (Haiku)
  Obtained from:DragonFlyBSD (c947b0b8dc96dabefd63f7b70d53695e36c7b64f)

Modified:
  head/sys/dev/iwm/if_iwmreg.h

Modified: head/sys/dev/iwm/if_iwmreg.h
==
--- head/sys/dev/iwm/if_iwmreg.hThu Jan 24 03:43:45 2019
(r343377)
+++ head/sys/dev/iwm/if_iwmreg.hThu Jan 24 03:44:20 2019
(r343378)
@@ -1794,11 +1794,6 @@ enum {
/* Thermal Throttling*/
IWM_REPLY_THERMAL_MNG_BACKOFF = 0x7e,
 
-   /* Scanning */
-   IWM_SCAN_ABORT_CMD = 0x81,
-   IWM_SCAN_START_NOTIFICATION = 0x82,
-   IWM_SCAN_RESULTS_NOTIFICATION = 0x83,
-
/* NVM */
IWM_NVM_ACCESS_CMD = 0x88,
 
@@ -4952,50 +4947,14 @@ struct iwm_periodic_scan_complete {
uint32_t reserved;
 } __packed;
 
-/* How many statistics are gathered for each channel */
-#define IWM_SCAN_RESULTS_STATISTICS 1
-
 /**
- * enum iwm_scan_complete_status - status codes for scan complete notifications
- * @IWM_SCAN_COMP_STATUS_OK:  scan completed successfully
- * @IWM_SCAN_COMP_STATUS_ABORT: scan was aborted by user
- * @IWM_SCAN_COMP_STATUS_ERR_SLEEP: sending null sleep packet failed
- * @IWM_SCAN_COMP_STATUS_ERR_CHAN_TIMEOUT: timeout before channel is ready
- * @IWM_SCAN_COMP_STATUS_ERR_PROBE: sending probe request failed
- * @IWM_SCAN_COMP_STATUS_ERR_WAKEUP: sending null wakeup packet failed
- * @IWM_SCAN_COMP_STATUS_ERR_ANTENNAS: invalid antennas chosen at scan command
- * @IWM_SCAN_COMP_STATUS_ERR_INTERNAL: internal error caused scan abort
- * @IWM_SCAN_COMP_STATUS_ERR_COEX: medium was lost ot WiMax
- * @IWM_SCAN_COMP_STATUS_P2P_ACTION_OK: P2P public action frame TX was 
successful
- * (not an error!)
- * @IWM_SCAN_COMP_STATUS_ITERATION_END: indicates end of one repeatition the 
driver
- * asked for
- * @IWM_SCAN_COMP_STATUS_ERR_ALLOC_TE: scan could not allocate time events
-*/
-enum iwm_scan_complete_status {
-   IWM_SCAN_COMP_STATUS_OK = 0x1,
-   IWM_SCAN_COMP_STATUS_ABORT = 0x2,
-   IWM_SCAN_COMP_STATUS_ERR_SLEEP = 0x3,
-   IWM_SCAN_COMP_STATUS_ERR_CHAN_TIMEOUT = 0x4,
-   IWM_SCAN_COMP_STATUS_ERR_PROBE = 0x5,
-   IWM_SCAN_COMP_STATUS_ERR_WAKEUP = 0x6,
-   IWM_SCAN_COMP_STATUS_ERR_ANTENNAS = 0x7,
-   IWM_SCAN_COMP_STATUS_ERR_INTERNAL = 0x8,
-   IWM_SCAN_COMP_STATUS_ERR_COEX = 0x9,
-   IWM_SCAN_COMP_STATUS_P2P_ACTION_OK = 0xA,
-   IWM_SCAN_COMP_STATUS_ITERATION_END = 0x0B,
-   IWM_SCAN_COMP_STATUS_ERR_ALLOC_TE = 0x0C,
-};
-
-/**
- * struct iwm_scan_results_notif - scan results for one channel
- * ( IWM_SCAN_RESULTS_NOTIFICATION = 0x83 )
+ * struct iwm_scan_results_notif - scan results for one channel -
+ *  SCAN_RESULT_NTF_API_S_VER_3
  * @channel: which channel the results are from
  * @band: 0 for 5.2 GHz, 1 for 2.4 GHz
  * @probe_status: IWM_SCAN_PROBE_STATUS_*, indicates success of probe request
  * @num_probe_not_sent: # of request that weren't sent due to not enough time
  * @duration: duration spent in channel, in usecs
- * @statistics: statistics gathered for this channel
  */
 struct iwm_scan_results_notif {
uint8_t channel;
@@ -5003,8 +4962,7 @@ struct iwm_scan_results_notif {
uint8_t probe_status;
uint8_t num_probe_not_sent;
uint32_t duration;
-   uint32_t statistics[IWM_SCAN_RESULTS_STATISTICS];
-} __packed; /* IWM_SCAN_RESULT_NTF_API_S_VER_2 */
+} __packed;
 
 enum iwm_scan_framework_client {
IWM_SCAN_CLIENT_SCHED_SCAN  = (1 << 0),
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r343386 - head/sys/dev/iwm

2019-01-23 Thread Kyle Evans
Author: kevans
Date: Thu Jan 24 03:48:50 2019
New Revision: 343386
URL: https://svnweb.freebsd.org/changeset/base/343386

Log:
  if_iwm - Stop iwm_watchdog callout when idle.
  
  Submitted by: Augustin Cavalier  (Haiku)
  Obtained from:DragonFlyBSD (6a8683b0e9d734f23bd9647e117da198c2b9a74e)

Modified:
  head/sys/dev/iwm/if_iwm.c

Modified: head/sys/dev/iwm/if_iwm.c
==
--- head/sys/dev/iwm/if_iwm.c   Thu Jan 24 03:48:27 2019(r343385)
+++ head/sys/dev/iwm/if_iwm.c   Thu Jan 24 03:48:50 2019(r343386)
@@ -3814,6 +3814,8 @@ iwm_raw_xmit(struct ieee80211_node *ni, struct mbuf *m
} else {
error = iwm_tx(sc, m, ni, 0);
}
+   if (sc->sc_tx_timer == 0)
+   callout_reset(>sc_watchdog_to, hz, iwm_watchdog, sc);
sc->sc_tx_timer = 5;
IWM_UNLOCK(sc);
 
@@ -4754,7 +4756,6 @@ iwm_init(struct iwm_softc *sc)
 * Ok, firmware loaded and we are jogging
 */
sc->sc_flags |= IWM_FLAG_HW_INITED;
-   callout_reset(>sc_watchdog_to, hz, iwm_watchdog, sc);
 }
 
 static int
@@ -4800,6 +4801,10 @@ iwm_start(struct iwm_softc *sc)
ieee80211_free_node(ni);
continue;
}
+   if (sc->sc_tx_timer == 0) {
+   callout_reset(>sc_watchdog_to, hz, iwm_watchdog,
+   sc);
+   }
sc->sc_tx_timer = 15;
}
IWM_DPRINTF(sc, IWM_DEBUG_XMIT | IWM_DEBUG_TRACE, "<-%s\n", __func__);
@@ -4834,8 +4839,8 @@ iwm_watchdog(void *arg)
counter_u64_add(sc->sc_ic.ic_oerrors, 1);
return;
}
+   callout_reset(>sc_watchdog_to, hz, iwm_watchdog, sc);
}
-   callout_reset(>sc_watchdog_to, hz, iwm_watchdog, sc);
 }
 
 static void
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r343390 - head/sys/dev/iwm

2019-01-23 Thread Kyle Evans
Author: kevans
Date: Thu Jan 24 03:50:27 2019
New Revision: 343390
URL: https://svnweb.freebsd.org/changeset/base/343390

Log:
  iwm - Remove unused TX_CMD_NEXT_FRAME_*
  
  Taken-From: Linux git b1e06c65fb69c5e3fddcd91987561e225eaa9bfa
  
  Submitted by: Augustin Cavalier  (Haiku)
  Obtained from:DragonFlyBSD (b0c6116f364a121ab6b9d634ca1997d4167fa747)

Modified:
  head/sys/dev/iwm/if_iwmreg.h

Modified: head/sys/dev/iwm/if_iwmreg.h
==
--- head/sys/dev/iwm/if_iwmreg.hThu Jan 24 03:50:03 2019
(r343389)
+++ head/sys/dev/iwm/if_iwmreg.hThu Jan 24 03:50:27 2019
(r343390)
@@ -4283,30 +4283,7 @@ enum iwm_tx_pm_timeouts {
 #define IWM_TX_CMD_SEC_WEP_KEY_IDX_MSK 0xc0
 #define IWM_TX_CMD_SEC_KEY128  0x08
 
-/* TODO: how does these values are OK with only 16 bit variable??? */
 /*
- * TX command next frame info
- *
- * bits 0:2 - security control (IWM_TX_CMD_SEC_*)
- * bit 3 - immediate ACK required
- * bit 4 - rate is taken from STA table
- * bit 5 - frame belongs to BA stream
- * bit 6 - immediate BA response expected
- * bit 7 - unused
- * bits 8:15 - Station ID
- * bits 16:31 - rate
- */
-#define IWM_TX_CMD_NEXT_FRAME_ACK_MSK  (0x8)
-#define IWM_TX_CMD_NEXT_FRAME_STA_RATE_MSK (0x10)
-#define IWM_TX_CMD_NEXT_FRAME_BA_MSK   (0x20)
-#define IWM_TX_CMD_NEXT_FRAME_IMM_BA_RSP_MSK   (0x40)
-#define IWM_TX_CMD_NEXT_FRAME_FLAGS_MSK(0xf8)
-#define IWM_TX_CMD_NEXT_FRAME_STA_ID_MSK   (0xff00)
-#define IWM_TX_CMD_NEXT_FRAME_STA_ID_POS   (8)
-#define IWM_TX_CMD_NEXT_FRAME_RATE_MSK (0x)
-#define IWM_TX_CMD_NEXT_FRAME_RATE_POS (16)
-
-/*
  * TX command Frame life time in us - to be written in pm_frame_timeout
  */
 #define IWM_TX_CMD_LIFE_TIME_INFINITE  0x
@@ -4343,7 +4320,7 @@ enum iwm_tx_pm_timeouts {
  * @initial_rate_index: index into the rate table for initial TX attempt.
  * Applied if IWM_TX_CMD_FLG_STA_RATE_MSK is set, normally 0 for data 
frames.
  * @key: security key
- * @next_frame_flags: IWM_TX_CMD_SEC_* and IWM_TX_CMD_NEXT_FRAME_*
+ * @reserved3: reserved
  * @life_time: frame life time (usecs??)
  * @dram_lsb_ptr: Physical address of scratch area in the command (try_cnt +
  * btkill_cnd + reserved), first 32 bits. "0" disables usage.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r343374 - head/sys/dev/iwm

2019-01-23 Thread Kyle Evans
Author: kevans
Date: Thu Jan 24 03:41:44 2019
New Revision: 343374
URL: https://svnweb.freebsd.org/changeset/base/343374

Log:
  if_iwm - The iwm_prepare_card_hw() in iwm_attach() is only needed on 8K hw.
  
  * Doing the iwm_prepare_card_hw() call in iwm_attach() only on Family 8000
  hardware matches the code in Linux iwlwifi.
  
  * While there remove DEFAULT_MAX_TX_POWER definition which is unused, and
  has a value different from IWL_DEFAULT_MAX_TX_POWER in iwlwifi.
  
  Submitted by: Augustin Cavalier  (Haiku)
  Obtained from:DragonFlyBSD (e8560f8dc58df12a7c79a6bb4e6ccb156e001085)

Modified:
  head/sys/dev/iwm/if_iwm.c

Modified: head/sys/dev/iwm/if_iwm.c
==
--- head/sys/dev/iwm/if_iwm.c   Thu Jan 24 03:41:09 2019(r343373)
+++ head/sys/dev/iwm/if_iwm.c   Thu Jan 24 03:41:44 2019(r343374)
@@ -1912,8 +1912,6 @@ enum nvm_sku_bits {
 #define IWM_NVM_RF_CFG_TX_ANT_MSK_8000(x)  ((x >> 24) & 0xF)
 #define IWM_NVM_RF_CFG_RX_ANT_MSK_8000(x)  ((x >> 28) & 0xF)
 
-#define DEFAULT_MAX_TX_POWER 16
-
 /**
  * enum iwm_nvm_channel_flags - channel flags in NVM
  * @IWM_NVM_CHANNEL_VALID: channel is usable for this SKU/geo
@@ -5863,18 +5861,17 @@ iwm_attach(device_t dev)
 * "dash" value). To keep hw_rev backwards compatible - we'll store it
 * in the old format.
 */
-   if (sc->cfg->device_family == IWM_DEVICE_FAMILY_8000)
-   sc->sc_hw_rev = (sc->sc_hw_rev & 0xfff0) |
-   (IWM_CSR_HW_REV_STEP(sc->sc_hw_rev << 2) << 2);
-
-   if (iwm_prepare_card_hw(sc) != 0) {
-   device_printf(dev, "could not initialize hardware\n");
-   goto fail;
-   }
-
if (sc->cfg->device_family == IWM_DEVICE_FAMILY_8000) {
int ret;
uint32_t hw_step;
+
+   sc->sc_hw_rev = (sc->sc_hw_rev & 0xfff0) |
+   (IWM_CSR_HW_REV_STEP(sc->sc_hw_rev << 2) << 2);
+
+   if (iwm_prepare_card_hw(sc) != 0) {
+   device_printf(dev, "could not initialize hardware\n");
+   goto fail;
+   }
 
/*
 * In order to recognize C step the driver should read the
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r343389 - head/sys/dev/iwm

2019-01-23 Thread Kyle Evans
Author: kevans
Date: Thu Jan 24 03:50:03 2019
New Revision: 343389
URL: https://svnweb.freebsd.org/changeset/base/343389

Log:
  iwm - Remove unused REPLY_MAX
  
  Taken-From: Linux git e4eb275ac5cfe71686612d929a9829345b2a4ada
  
  Submitted by: Augustin Cavalier  (Haiku)
  Obtained from:DragonFlyBSD (92a727c99d6ec5abf14bb6853e95e3a187a0cd4e)

Modified:
  head/sys/dev/iwm/if_iwmreg.h

Modified: head/sys/dev/iwm/if_iwmreg.h
==
--- head/sys/dev/iwm/if_iwmreg.hThu Jan 24 03:49:35 2019
(r343388)
+++ head/sys/dev/iwm/if_iwmreg.hThu Jan 24 03:50:03 2019
(r343389)
@@ -1866,8 +1866,6 @@ enum {
IWM_NET_DETECT_PROFILES_CMD = 0x57,
IWM_NET_DETECT_HOTSPOTS_CMD = 0x58,
IWM_NET_DETECT_HOTSPOTS_QUERY_CMD = 0x59,
-
-   IWM_REPLY_MAX = 0xff,
 };
 
 enum iwm_phy_ops_subcmd_ids {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r343388 - head/sys/dev/iwm

2019-01-23 Thread Kyle Evans
Author: kevans
Date: Thu Jan 24 03:49:35 2019
New Revision: 343388
URL: https://svnweb.freebsd.org/changeset/base/343388

Log:
  iwm - Update alive response handling, add v4 and remove old versions.
  
  Submitted by: Augustin Cavalier  (Haiku)
  Obtained from:DragonFlyBSD (3820e2bf3331ced3541d1811a38c5a5136dfab93)

Modified:
  head/sys/dev/iwm/if_iwm.c
  head/sys/dev/iwm/if_iwmreg.h
  head/sys/dev/iwm/if_iwmvar.h

Modified: head/sys/dev/iwm/if_iwm.c
==
--- head/sys/dev/iwm/if_iwm.c   Thu Jan 24 03:49:11 2019(r343387)
+++ head/sys/dev/iwm/if_iwm.c   Thu Jan 24 03:49:35 2019(r343388)
@@ -2723,75 +2723,48 @@ static int
 iwm_alive_fn(struct iwm_softc *sc, struct iwm_rx_packet *pkt, void *data)
 {
struct iwm_mvm_alive_data *alive_data = data;
-   struct iwm_mvm_alive_resp_ver1 *palive1;
-   struct iwm_mvm_alive_resp_ver2 *palive2;
+   struct iwm_mvm_alive_resp_v3 *palive3;
struct iwm_mvm_alive_resp *palive;
+   struct iwm_umac_alive *umac;
+   struct iwm_lmac_alive *lmac1;
+   struct iwm_lmac_alive *lmac2 = NULL;
+   uint16_t status;
 
-   if (iwm_rx_packet_payload_len(pkt) == sizeof(*palive1)) {
-   palive1 = (void *)pkt->data;
-
-   sc->support_umac_log = FALSE;
-sc->error_event_table =
-le32toh(palive1->error_event_table_ptr);
-sc->log_event_table =
-le32toh(palive1->log_event_table_ptr);
-alive_data->scd_base_addr = le32toh(palive1->scd_base_ptr);
-
-alive_data->valid = le16toh(palive1->status) ==
-IWM_ALIVE_STATUS_OK;
-IWM_DPRINTF(sc, IWM_DEBUG_RESET,
-   "Alive VER1 ucode status 0x%04x revision 0x%01X 
0x%01X flags 0x%01X\n",
-le16toh(palive1->status), palive1->ver_type,
- palive1->ver_subtype, palive1->flags);
-   } else if (iwm_rx_packet_payload_len(pkt) == sizeof(*palive2)) {
-   palive2 = (void *)pkt->data;
-   sc->error_event_table =
-   le32toh(palive2->error_event_table_ptr);
-   sc->log_event_table =
-   le32toh(palive2->log_event_table_ptr);
-   alive_data->scd_base_addr = le32toh(palive2->scd_base_ptr);
-   sc->umac_error_event_table =
-le32toh(palive2->error_info_addr);
-
-   alive_data->valid = le16toh(palive2->status) ==
-   IWM_ALIVE_STATUS_OK;
-   if (sc->umac_error_event_table)
-   sc->support_umac_log = TRUE;
-
-   IWM_DPRINTF(sc, IWM_DEBUG_RESET,
-   "Alive VER2 ucode status 0x%04x revision 0x%01X 
0x%01X flags 0x%01X\n",
-   le16toh(palive2->status), palive2->ver_type,
-   palive2->ver_subtype, palive2->flags);
-
-   IWM_DPRINTF(sc, IWM_DEBUG_RESET,
-   "UMAC version: Major - 0x%x, Minor - 0x%x\n",
-   palive2->umac_major, palive2->umac_minor);
-   } else if (iwm_rx_packet_payload_len(pkt) == sizeof(*palive)) {
+   if (iwm_rx_packet_payload_len(pkt) == sizeof(*palive)) {
palive = (void *)pkt->data;
+   umac = >umac_data;
+   lmac1 = >lmac_data[0];
+   lmac2 = >lmac_data[1];
+   status = le16toh(palive->status);
+   } else {
+   palive3 = (void *)pkt->data;
+   umac = >umac_data;
+   lmac1 = >lmac_data;
+   status = le16toh(palive3->status);
+   }
 
-   sc->error_event_table =
-   le32toh(palive->error_event_table_ptr);
-   sc->log_event_table =
-   le32toh(palive->log_event_table_ptr);
-   alive_data->scd_base_addr = le32toh(palive->scd_base_ptr);
-   sc->umac_error_event_table =
-   le32toh(palive->error_info_addr);
+   sc->error_event_table[0] = le32toh(lmac1->error_event_table_ptr);
+   if (lmac2)
+   sc->error_event_table[1] =
+   le32toh(lmac2->error_event_table_ptr);
+   sc->log_event_table = le32toh(lmac1->log_event_table_ptr);
+   sc->umac_error_event_table = le32toh(umac->error_info_addr);
+   alive_data->scd_base_addr = le32toh(lmac1->scd_base_ptr);
+   alive_data->valid = status == IWM_ALIVE_STATUS_OK;
+   if (sc->umac_error_event_table)
+   sc->support_umac_log = TRUE;
 
-   alive_data->valid = le16toh(palive->status) ==
-   IWM_ALIVE_STATUS_OK;
-   if (sc->umac_error_event_table)
-   sc->support_umac_log = TRUE;
+   IWM_DPRINTF(sc, 

svn commit: r343387 - head/sys/dev/iwm

2019-01-23 Thread Kyle Evans
Author: kevans
Date: Thu Jan 24 03:49:11 2019
New Revision: 343387
URL: https://svnweb.freebsd.org/changeset/base/343387

Log:
  iwm - Fix race during detach, where a callout is left after driver is gone.
  
  Submitted by: Augustin Cavalier  (Haiku)
  Obtained from:DragonFlyBSD (ba3b4ff9a1fc04a349df05d6d3449f4d9b15c4be)

Modified:
  head/sys/dev/iwm/if_iwm.c
  head/sys/dev/iwm/if_iwm_led.c

Modified: head/sys/dev/iwm/if_iwm.c
==
--- head/sys/dev/iwm/if_iwm.c   Thu Jan 24 03:48:50 2019(r343386)
+++ head/sys/dev/iwm/if_iwm.c   Thu Jan 24 03:49:11 2019(r343387)
@@ -4829,6 +4829,9 @@ iwm_watchdog(void *arg)
struct iwm_softc *sc = arg;
struct ieee80211com *ic = >sc_ic;
 
+   if (sc->sc_attached == 0)
+   return;
+
if (sc->sc_tx_timer > 0) {
if (--sc->sc_tx_timer == 0) {
device_printf(sc->sc_dev, "device timeout\n");

Modified: head/sys/dev/iwm/if_iwm_led.c
==
--- head/sys/dev/iwm/if_iwm_led.c   Thu Jan 24 03:48:50 2019
(r343386)
+++ head/sys/dev/iwm/if_iwm_led.c   Thu Jan 24 03:49:11 2019
(r343387)
@@ -162,6 +162,9 @@ iwm_led_blink_timeout(void *arg)
 {
struct iwm_softc *sc = arg;
 
+   if (sc->sc_attached == 0)
+   return;
+
if (iwm_mvm_led_is_enabled(sc))
iwm_mvm_led_disable(sc);
else
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r343383 - head/sys/dev/iwm

2019-01-23 Thread Kyle Evans
Author: kevans
Date: Thu Jan 24 03:47:04 2019
New Revision: 343383
URL: https://svnweb.freebsd.org/changeset/base/343383

Log:
  iwm - Improve firmware Time Event handling.
  
  * This is a mix of the OpenBSD Git 7fd9664469d1b717a307eebd74aeececbd3c41cc
  change, and syncing with the Linux iwlwifi code.
  
  Taken-From: Linux iwlwifi, and OpenBSD
  
  Submitted by: Augustin Cavalier  (Haiku)
  Obtained from:DragonFlyBSD (706a3044afd27c3fecfdf57bec1695310e53e228)

Modified:
  head/sys/dev/iwm/if_iwm.c
  head/sys/dev/iwm/if_iwm_debug.h
  head/sys/dev/iwm/if_iwm_time_event.c
  head/sys/dev/iwm/if_iwm_time_event.h
  head/sys/dev/iwm/if_iwmvar.h

Modified: head/sys/dev/iwm/if_iwm.c
==
--- head/sys/dev/iwm/if_iwm.c   Thu Jan 24 03:46:35 2019(r343382)
+++ head/sys/dev/iwm/if_iwm.c   Thu Jan 24 03:47:04 2019(r343383)
@@ -1263,6 +1263,7 @@ iwm_stop_device(struct iwm_softc *sc)
iv->is_uploaded = 0;
}
sc->sc_firmware_state = 0;
+   sc->sc_flags &= ~IWM_FLAG_TE_ACTIVE;
 
/* device going down, Stop using ICT table */
sc->sc_flags &= ~IWM_FLAG_USE_ICT;
@@ -4050,8 +4051,7 @@ iwm_auth(struct ieee80211vap *vap, struct iwm_softc *s
 */
/* XXX duration is in units of TU, not MS */
duration = IWM_MVM_TE_SESSION_PROTECTION_MAX_TIME_MS;
-   iwm_mvm_protect_session(sc, iv, duration, 500 /* XXX magic number */);
-   DELAY(100);
+   iwm_mvm_protect_session(sc, iv, duration, 500 /* XXX magic number */, 
TRUE);
 
error = 0;
 out:
@@ -4347,6 +4347,15 @@ iwm_newstate(struct ieee80211vap *vap, enum ieee80211_
iwm_mvm_disable_beacon_filter(sc);
if (((in = IWM_NODE(vap->iv_bss)) != NULL))
in->in_assoc = 0;
+   }
+
+   if ((vap->iv_state == IEEE80211_S_AUTH ||
+vap->iv_state == IEEE80211_S_ASSOC ||
+vap->iv_state == IEEE80211_S_RUN) &&
+   (nstate == IEEE80211_S_INIT ||
+nstate == IEEE80211_S_SCAN ||
+nstate == IEEE80211_S_AUTH)) {
+   iwm_mvm_stop_session_protection(sc, ivp);
}
 
if ((vap->iv_state == IEEE80211_S_RUN ||

Modified: head/sys/dev/iwm/if_iwm_debug.h
==
--- head/sys/dev/iwm/if_iwm_debug.h Thu Jan 24 03:46:35 2019
(r343382)
+++ head/sys/dev/iwm/if_iwm_debug.h Thu Jan 24 03:47:04 2019
(r343383)
@@ -44,6 +44,7 @@ enum {
IWM_DEBUG_TEMP  = 0x0010,   /* Thermal Sensor handling */
IWM_DEBUG_FW= 0x0020,   /* Firmware management */
IWM_DEBUG_LAR   = 0x0040,   /* Location Aware Regulatory */
+   IWM_DEBUG_TE= 0x0080,   /* Time Event handling */
IWM_DEBUG_REGISTER  = 0x2000,   /* print chipset register */
IWM_DEBUG_TRACE = 0x4000,   /* Print begin and start driver 
function */
IWM_DEBUG_FATAL = 0x8000,   /* fatal errors */

Modified: head/sys/dev/iwm/if_iwm_time_event.c
==
--- head/sys/dev/iwm/if_iwm_time_event.cThu Jan 24 03:46:35 2019
(r343382)
+++ head/sys/dev/iwm/if_iwm_time_event.cThu Jan 24 03:47:04 2019
(r343383)
@@ -155,6 +155,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -166,31 +167,132 @@ __FBSDID("$FreeBSD$");
 #define IWM_MVM_ROC_TE_TYPE_MGMT_TX IWM_TE_P2P_CLIENT_ASSOC
 
 static int
+iwm_mvm_te_notif(struct iwm_softc *sc, struct iwm_rx_packet *pkt,
+void *data)
+{
+   struct iwm_time_event_notif *resp;
+   int resp_len = iwm_rx_packet_payload_len(pkt);
+
+   if (pkt->hdr.code != IWM_TIME_EVENT_NOTIFICATION ||
+   resp_len != sizeof(*resp)) {
+   IWM_DPRINTF(sc, IWM_DEBUG_TE,
+   "Invalid TIME_EVENT_NOTIFICATION response\n");
+   return 1;
+   }
+
+   resp = (void *)pkt->data;
+
+   /* te_data->uid is already set in the TIME_EVENT_CMD response */
+   if (le32toh(resp->unique_id) != sc->sc_time_event_uid)
+   return false;
+
+   IWM_DPRINTF(sc, IWM_DEBUG_TE,
+   "TIME_EVENT_NOTIFICATION response - UID = 0x%x\n",
+   sc->sc_time_event_uid);
+   if (!resp->status) {
+   IWM_DPRINTF(sc, IWM_DEBUG_TE,
+   "TIME_EVENT_NOTIFICATION received but not executed\n");
+   }
+
+   return 1;
+}
+
+static int
+iwm_mvm_time_event_response(struct iwm_softc *sc, struct iwm_rx_packet *pkt,
+void *data)
+{
+   struct iwm_time_event_resp *resp;
+   int resp_len = iwm_rx_packet_payload_len(pkt);
+
+   if (pkt->hdr.code != IWM_TIME_EVENT_CMD ||
+   resp_len != sizeof(*resp)) {
+   IWM_DPRINTF(sc, IWM_DEBUG_TE,
+   

svn commit: r343379 - head/sys/dev/iwm

2019-01-23 Thread Kyle Evans
Author: kevans
Date: Thu Jan 24 03:44:48 2019
New Revision: 343379
URL: https://svnweb.freebsd.org/changeset/base/343379

Log:
  if_iwm - Configure the PCIe LTR, fix PCI express capability accesses.
  
  Taken-From: Linux iwlwifi
  
  Submitted by: Augustin Cavalier  (Haiku)
  Obtained from:DragonFlyBSD (08a7ad5a5ff65aaaf2df6a609be7a4e1df43efc3)

Modified:
  head/sys/dev/iwm/if_iwm.c
  head/sys/dev/iwm/if_iwm_pcie_trans.c
  head/sys/dev/iwm/if_iwmreg.h
  head/sys/dev/iwm/if_iwmvar.h

Modified: head/sys/dev/iwm/if_iwm.c
==
--- head/sys/dev/iwm/if_iwm.c   Thu Jan 24 03:44:20 2019(r343378)
+++ head/sys/dev/iwm/if_iwm.c   Thu Jan 24 03:44:48 2019(r343379)
@@ -320,6 +320,7 @@ static int  iwm_send_phy_cfg_cmd(struct iwm_softc *);
 static int iwm_mvm_load_ucode_wait_alive(struct iwm_softc *,
   enum iwm_ucode_type);
 static int iwm_run_init_mvm_ucode(struct iwm_softc *, int);
+static int iwm_mvm_config_ltr(struct iwm_softc *sc);
 static int iwm_rx_addbuf(struct iwm_softc *, int, int);
 static int iwm_mvm_get_signal_strength(struct iwm_softc *,
struct iwm_rx_phy_info *);
@@ -3000,6 +3001,19 @@ out:
return ret;
 }
 
+static int
+iwm_mvm_config_ltr(struct iwm_softc *sc)
+{
+   struct iwm_ltr_config_cmd cmd = {
+   .flags = htole32(IWM_LTR_CFG_FLAG_FEATURE_ENABLE),
+   };
+
+   if (!sc->sc_ltr_enabled)
+   return 0;
+
+   return iwm_mvm_send_cmd_pdu(sc, IWM_LTR_CONFIG, 0, sizeof(cmd), );
+}
+
 /*
  * receive side
  */
@@ -4665,6 +4679,9 @@ iwm_init_hw(struct iwm_softc *sc)
if (sc->cfg->device_family == IWM_DEVICE_FAMILY_7000)
iwm_mvm_tt_tx_backoff(sc, 0);
 
+   if (iwm_mvm_config_ltr(sc) != 0)
+   device_printf(sc->sc_dev, "PCIe LTR configuration failed\n");
+
error = iwm_mvm_power_update_device(sc);
if (error)
goto error;
@@ -5292,6 +5309,7 @@ iwm_handle_rxb(struct iwm_softc *sc, struct mbuf *m)
case IWM_MAC_CONTEXT_CMD:
case IWM_REPLY_SF_CFG_CMD:
case IWM_POWER_TABLE_CMD:
+   case IWM_LTR_CONFIG:
case IWM_PHY_CONTEXT_CMD:
case IWM_BINDING_CONTEXT_CMD:
case IWM_TIME_EVENT_CMD:

Modified: head/sys/dev/iwm/if_iwm_pcie_trans.c
==
--- head/sys/dev/iwm/if_iwm_pcie_trans.cThu Jan 24 03:44:20 2019
(r343378)
+++ head/sys/dev/iwm/if_iwm_pcie_trans.cThu Jan 24 03:44:48 2019
(r343379)
@@ -406,18 +406,39 @@ iwm_prepare_card_hw(struct iwm_softc *sc)
 void
 iwm_apm_config(struct iwm_softc *sc)
 {
-   uint16_t reg;
+   uint16_t lctl, cap;
+   int pcie_ptr;
 
-   reg = pci_read_config(sc->sc_dev, PCIER_LINK_CTL, sizeof(reg));
-   if (reg & PCIEM_LINK_CTL_ASPMC_L1)  {
-   /* Um the Linux driver prints "Disabling L0S for this one ... */
+   /*
+* HW bug W/A for instability in PCIe bus L0S->L1 transition.
+* Check if BIOS (or OS) enabled L1-ASPM on this device.
+* If so (likely), disable L0S, so device moves directly L0->L1;
+*costs negligible amount of power savings.
+* If not (unlikely), enable L0S, so there is at least some
+*power savings, even without L1.
+*/
+   int error;
+
+   error = pci_find_cap(sc->sc_dev, PCIY_EXPRESS, _ptr);
+   if (error != 0)
+   return;
+   lctl = pci_read_config(sc->sc_dev, pcie_ptr + PCIER_LINK_CTL,
+   sizeof(lctl));
+   if (lctl & PCIEM_LINK_CTL_ASPMC_L1)  {
IWM_SETBITS(sc, IWM_CSR_GIO_REG,
IWM_CSR_GIO_REG_VAL_L0S_ENABLED);
} else {
-   /* ... and "Enabling" here */
IWM_CLRBITS(sc, IWM_CSR_GIO_REG,
IWM_CSR_GIO_REG_VAL_L0S_ENABLED);
}
+
+   cap = pci_read_config(sc->sc_dev, pcie_ptr + PCIER_DEVICE_CTL2,
+   sizeof(cap));
+   sc->sc_ltr_enabled = (cap & PCIEM_CTL2_LTR_ENABLE) ? 1 : 0;
+   IWM_DPRINTF(sc, IWM_DEBUG_RESET | IWM_DEBUG_PWRSAVE,
+   "L1 %sabled - LTR %sabled\n",
+   (lctl & PCIEM_LINK_CTL_ASPMC_L1) ? "En" : "Dis",
+   sc->sc_ltr_enabled ? "En" : "Dis");
 }
 
 /*

Modified: head/sys/dev/iwm/if_iwmreg.h
==
--- head/sys/dev/iwm/if_iwmreg.hThu Jan 24 03:44:20 2019
(r343378)
+++ head/sys/dev/iwm/if_iwmreg.hThu Jan 24 03:44:48 2019
(r343379)
@@ -1790,6 +1790,7 @@ enum {
/* Power - legacy power table command */
IWM_POWER_TABLE_CMD = 0x77,
IWM_PSM_UAPSD_AP_MISBEHAVING_NOTIFICATION = 0x78,
+   IWM_LTR_CONFIG = 0xee,
 
/* Thermal Throttling*/
  

svn commit: r343380 - head/sys/dev/iwm

2019-01-23 Thread Kyle Evans
Author: kevans
Date: Thu Jan 24 03:45:24 2019
New Revision: 343380
URL: https://svnweb.freebsd.org/changeset/base/343380

Log:
  if_iwm - Add firmware API definitions for TX power commands.
  
  * While there remove unused IWM_UCODE_TLV_CAPA_LMAC_UPLOAD definition,
  which isn't defined in iwlwifi.
  
  Taken-From: Linux iwlwifi
  
  Submitted by: Augustin Cavalier  (Haiku)
  Obtained from:DragonFlyBSD (fd4f9de8bc72ea961e50829b45b59d0549040b7d)

Modified:
  head/sys/dev/iwm/if_iwm_config.h
  head/sys/dev/iwm/if_iwmreg.h

Modified: head/sys/dev/iwm/if_iwm_config.h
==
--- head/sys/dev/iwm/if_iwm_config.hThu Jan 24 03:44:48 2019
(r343379)
+++ head/sys/dev/iwm/if_iwm_config.hThu Jan 24 03:45:24 2019
(r343380)
@@ -80,6 +80,8 @@ enum iwm_device_family {
IWM_DEVICE_FAMILY_8000,
 };
 
+#define IWM_DEFAULT_MAX_TX_POWER   22
+
 /* Antenna presence definitions */
 #defineIWM_ANT_NONE0x0
 #defineIWM_ANT_A   (1 << 0)

Modified: head/sys/dev/iwm/if_iwmreg.h
==
--- head/sys/dev/iwm/if_iwmreg.hThu Jan 24 03:44:48 2019
(r343379)
+++ head/sys/dev/iwm/if_iwmreg.hThu Jan 24 03:45:24 2019
(r343380)
@@ -702,8 +702,9 @@ enum iwm_ucode_tlv_api {
  * @IWM_UCODE_TLV_CAPA_EXTEND_SHARED_MEM_CFG: support getting more shared
  * memory addresses from the firmware.
  * @IWM_UCODE_TLV_CAPA_LQM_SUPPORT: supports Link Quality Measurement
- * @IWM_UCODE_TLV_CAPA_LMAC_UPLOAD: supports upload mode in lmac (1=supported,
- * 0=no support)
+ * @IWM_UCODE_TLV_CAPA_TX_POWER_ACK: reduced TX power API has larger
+ *  command size (command version 4) that supports toggling ACK TX
+ *  power reduction.
  *
  * @IWM_NUM_UCODE_TLV_CAPA: number of bits used
  */
@@ -744,9 +745,9 @@ enum iwm_ucode_tlv_capa {
IWM_UCODE_TLV_CAPA_TEMP_THS_REPORT_SUPPORT  = 75,
IWM_UCODE_TLV_CAPA_CTDP_SUPPORT = 76,
IWM_UCODE_TLV_CAPA_USNIFFER_UNIFIED = 77,
-   IWM_UCODE_TLV_CAPA_LMAC_UPLOAD  = 79,
IWM_UCODE_TLV_CAPA_EXTEND_SHARED_MEM_CFG= 80,
IWM_UCODE_TLV_CAPA_LQM_SUPPORT  = 81,
+   IWM_UCODE_TLV_CAPA_TX_POWER_ACK = 84,
 
IWM_NUM_UCODE_TLV_CAPA = 128
 };
@@ -1916,6 +1917,51 @@ struct iwm_reduce_tx_power_cmd {
uint8_t mac_context_id;
uint16_t pwr_restriction;
 } __packed; /* IWM_TX_REDUCED_POWER_API_S_VER_1 */
+
+enum iwm_dev_tx_power_cmd_mode {
+   IWM_TX_POWER_MODE_SET_MAC = 0,
+   IWM_TX_POWER_MODE_SET_DEVICE = 1,
+   IWM_TX_POWER_MODE_SET_CHAINS = 2,
+   IWM_TX_POWER_MODE_SET_ACK = 3,
+}; /* TX_POWER_REDUCED_FLAGS_TYPE_API_E_VER_4 */;
+
+#define IWM_NUM_CHAIN_LIMITS   2
+#define IWM_NUM_SUB_BANDS  5
+
+/**
+ * struct iwm_dev_tx_power_cmd - TX power reduction command
+ * @set_mode: see  iwl_dev_tx_power_cmd_mode
+ * @mac_context_id: id of the mac ctx for which we are reducing TX power.
+ * @pwr_restriction: TX power restriction in 1/8 dBms.
+ * @dev_24: device TX power restriction in 1/8 dBms
+ * @dev_52_low: device TX power restriction upper band - low
+ * @dev_52_high: device TX power restriction upper band - high
+ * @per_chain_restriction: per chain restrictions
+ */
+struct iwm_dev_tx_power_cmd_v3 {
+   uint32_t set_mode;
+   uint32_t mac_context_id;
+   uint16_t pwr_restriction;
+   uint16_t dev_24;
+   uint16_t dev_52_low;
+   uint16_t dev_52_high;
+   uint16_t per_chain_restriction[IWM_NUM_CHAIN_LIMITS][IWM_NUM_SUB_BANDS];
+} __packed; /* TX_REDUCED_POWER_API_S_VER_3 */
+
+#define IWM_DEV_MAX_TX_POWER 0x7FFF
+
+/**
+ * struct iwm_dev_tx_power_cmd - TX power reduction command
+ * @v3: version 3 of the command, embedded here for easier software handling
+ * @enable_ack_reduction: enable or disable close range ack TX power
+ *  reduction.
+ */
+struct iwm_dev_tx_power_cmd {
+   /* v4 is just an extension of v3 - keep this here */
+   struct iwm_dev_tx_power_cmd_v3 v3;
+   uint8_t enable_ack_reduction;
+   uint8_t reserved[3];
+} __packed; /* TX_REDUCED_POWER_API_S_VER_4 */
 
 /*
  * Calibration control struct.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r343381 - head/sys/dev/iwm

2019-01-23 Thread Kyle Evans
Author: kevans
Date: Thu Jan 24 03:45:55 2019
New Revision: 343381
URL: https://svnweb.freebsd.org/changeset/base/343381

Log:
  iwm - Track firmware state better, and improve handling in iwm_newstate().
  
  * This avoids firmware resets in all the cases in iwm_newstate(). Instead
  iwm_bring_down_firmware() is called, which tears down all the STA
  connection state, according to the sc->sc_firmware_state value.
  
  * Improve the behaviour of the LED blinking a bit, so it only blinks when
  there really is a wireless scan going on.
  
  * Print the newstate arg in debug output of iwm_newstate(), to help in
  debugging.
  
  This is inspired by the firmware state maintaining change in OpenBSD's iwm,
  by s...@openbsd.org (OpenBSD Git 0ddb056fb7370664b1d4b84392697cb17d1a414a).
  
  Submitted by: Augustin Cavalier  (Haiku)
  Obtained from:DragonFlyBSD (8a41b10ac639d0609878696808387a6799d39b57)

Modified:
  head/sys/dev/iwm/if_iwm.c
  head/sys/dev/iwm/if_iwm_mac_ctxt.c
  head/sys/dev/iwm/if_iwm_sta.c
  head/sys/dev/iwm/if_iwmvar.h

Modified: head/sys/dev/iwm/if_iwm.c
==
--- head/sys/dev/iwm/if_iwm.c   Thu Jan 24 03:45:24 2019(r343380)
+++ head/sys/dev/iwm/if_iwm.c   Thu Jan 24 03:45:55 2019(r343381)
@@ -350,7 +350,6 @@ static int  iwm_raw_xmit(struct ieee80211_node *, struc
 const struct ieee80211_bpf_params *);
 static int iwm_mvm_update_quotas(struct iwm_softc *, struct iwm_vap *);
 static int iwm_auth(struct ieee80211vap *, struct iwm_softc *);
-static int iwm_release(struct iwm_softc *, struct iwm_node *);
 static struct ieee80211_node *
iwm_node_alloc(struct ieee80211vap *,
   const uint8_t[IEEE80211_ADDR_LEN]);
@@ -1263,6 +1262,7 @@ iwm_stop_device(struct iwm_softc *sc)
iv->phy_ctxt = NULL;
iv->is_uploaded = 0;
}
+   sc->sc_firmware_state = 0;
 
/* device going down, Stop using ICT table */
sc->sc_flags &= ~IWM_FLAG_USE_ICT;
@@ -3951,8 +3951,11 @@ iwm_auth(struct ieee80211vap *vap, struct iwm_softc *s
__func__,
vap,
ni);
+   IWM_DPRINTF(sc, IWM_DEBUG_STATE, "%s: Current node bssid: %s\n",
+   __func__, ether_sprintf(ni->ni_bssid));
 
in->in_assoc = 0;
+   iv->iv_auth = 1;
 
/*
 * Firmware bug - it'll crash if the beacon interval is less
@@ -4004,6 +4007,7 @@ iwm_auth(struct ieee80211vap *vap, struct iwm_softc *s
goto out;
}
}
+   sc->sc_firmware_state = 1;
 
if ((error = iwm_mvm_phy_ctxt_changed(sc, >sc_phyctxt[0],
in->in_ni.ni_chan, 1, 1)) != 0) {
@@ -4018,6 +4022,7 @@ iwm_auth(struct ieee80211vap *vap, struct iwm_softc *s
"%s: binding update cmd\n", __func__);
goto out;
}
+   sc->sc_firmware_state = 2;
/*
 * Authentication becomes unreliable when powersaving is left enabled
 * here. Powersaving will be activated again when association has
@@ -4037,6 +4042,7 @@ iwm_auth(struct ieee80211vap *vap, struct iwm_softc *s
"%s: failed to add sta\n", __func__);
goto out;
}
+   sc->sc_firmware_state = 3;
 
/*
 * Prevent the FW from wandering off channel during association
@@ -4049,81 +4055,12 @@ iwm_auth(struct ieee80211vap *vap, struct iwm_softc *s
 
error = 0;
 out:
+   if (error != 0)
+   iv->iv_auth = 0;
ieee80211_free_node(ni);
return (error);
 }
 
-static int
-iwm_release(struct iwm_softc *sc, struct iwm_node *in)
-{
-   uint32_t tfd_msk;
-
-   /*
-* Ok, so *technically* the proper set of calls for going
-* from RUN back to SCAN is:
-*
-* iwm_mvm_power_mac_disable(sc, in);
-* iwm_mvm_mac_ctxt_changed(sc, vap);
-* iwm_mvm_rm_sta(sc, in);
-* iwm_mvm_update_quotas(sc, NULL);
-* iwm_mvm_mac_ctxt_changed(sc, in);
-* iwm_mvm_binding_remove_vif(sc, IWM_VAP(in->in_ni.ni_vap));
-* iwm_mvm_mac_ctxt_remove(sc, in);
-*
-* However, that freezes the device not matter which permutations
-* and modifications are attempted.  Obviously, this driver is missing
-* something since it works in the Linux driver, but figuring out what
-* is missing is a little more complicated.  Now, since we're going
-* back to nothing anyway, we'll just do a complete device reset.
-* Up your's, device!
-*/
-   /*
-* Just using 0xf for the queues mask is fine as long as we only
-* get here from RUN state.
-*/
-   tfd_msk = 0xf;
-   iwm_xmit_queue_drain(sc);
-   iwm_mvm_flush_tx_path(sc, tfd_msk, IWM_CMD_SYNC);
-   /*
-* We seem to get away with just synchronously sending the
-* 

svn commit: r343377 - head/sys/dev/iwm

2019-01-23 Thread Kyle Evans
Author: kevans
Date: Thu Jan 24 03:43:45 2019
New Revision: 343377
URL: https://svnweb.freebsd.org/changeset/base/343377

Log:
  iwm - Reduce gratuitous differences with Linux iwlwifi in struct naming.
  
  * Rename some structs and struct members for firmware handling.
  
  Submitted by: Augustin Cavalier  (Haiku)
  Obtained from:DragonFlyBSD (4b1006a6e4d0f61d48c67b46e1f791e30837db67)

Modified:
  head/sys/dev/iwm/if_iwm.c
  head/sys/dev/iwm/if_iwm_fw.c
  head/sys/dev/iwm/if_iwm_fw.h
  head/sys/dev/iwm/if_iwm_phy_db.c
  head/sys/dev/iwm/if_iwm_scan.c
  head/sys/dev/iwm/if_iwmvar.h

Modified: head/sys/dev/iwm/if_iwm.c
==
--- head/sys/dev/iwm/if_iwm.c   Thu Jan 24 03:42:59 2019(r343376)
+++ head/sys/dev/iwm/if_iwm.c   Thu Jan 24 03:43:45 2019(r343377)
@@ -305,16 +305,16 @@ static intiwm_pcie_load_section(struct iwm_softc 
*, u
 static int iwm_pcie_load_firmware_chunk(struct iwm_softc *, uint32_t,
 bus_addr_t, uint32_t);
 static int iwm_pcie_load_cpu_sections_8000(struct iwm_softc *sc,
-   const struct iwm_fw_sects *,
+   const struct iwm_fw_img *,
int, int *);
 static int iwm_pcie_load_cpu_sections(struct iwm_softc *,
-  const struct iwm_fw_sects *,
+  const struct iwm_fw_img *,
   int, int *);
 static int iwm_pcie_load_given_ucode_8000(struct iwm_softc *,
-  const struct iwm_fw_sects *);
+  const struct iwm_fw_img *);
 static int iwm_pcie_load_given_ucode(struct iwm_softc *,
- const struct iwm_fw_sects *);
-static int iwm_start_fw(struct iwm_softc *, const struct iwm_fw_sects *);
+ const struct iwm_fw_img *);
+static int iwm_start_fw(struct iwm_softc *, const struct iwm_fw_img *);
 static int iwm_send_tx_ant_cfg(struct iwm_softc *, uint8_t);
 static int iwm_send_phy_cfg_cmd(struct iwm_softc *);
 static int iwm_mvm_load_ucode_wait_alive(struct iwm_softc *,
@@ -426,7 +426,7 @@ static int
 iwm_firmware_store_section(struct iwm_softc *sc,
 enum iwm_ucode_type type, const uint8_t *data, size_t dlen)
 {
-   struct iwm_fw_sects *fws;
+   struct iwm_fw_img *fws;
struct iwm_fw_desc *fwone;
 
if (type >= IWM_UCODE_TYPE_MAX)
@@ -434,11 +434,11 @@ iwm_firmware_store_section(struct iwm_softc *sc,
if (dlen < sizeof(uint32_t))
return EINVAL;
 
-   fws = >sc_fw.fw_sects[type];
+   fws = >sc_fw.img[type];
if (fws->fw_count >= IWM_UCODE_SECTION_MAX)
return EINVAL;
 
-   fwone = >fw_sect[fws->fw_count];
+   fwone = >sec[fws->fw_count];
 
/* first 32bit are device load offset */
memcpy(>offset, data, sizeof(uint32_t));
@@ -536,7 +536,7 @@ iwm_fw_info_free(struct iwm_fw_info *fw)
 {
firmware_put(fw->fw_fp, FIRMWARE_UNLOAD);
fw->fw_fp = NULL;
-   memset(fw->fw_sects, 0, sizeof(fw->fw_sects));
+   memset(fw->img, 0, sizeof(fw->img));
 }
 
 static int
@@ -545,7 +545,7 @@ iwm_read_firmware(struct iwm_softc *sc)
struct iwm_fw_info *fw = >sc_fw;
const struct iwm_tlv_ucode_header *uhdr;
const struct iwm_ucode_tlv *tlv;
-   struct iwm_ucode_capabilities *capa = >ucode_capa;
+   struct iwm_ucode_capabilities *capa = >sc_fw.ucode_capa;
enum iwm_ucode_tlv_type tlv_type;
const struct firmware *fwp;
const uint8_t *data;
@@ -694,11 +694,11 @@ iwm_read_firmware(struct iwm_softc *sc)
}
num_of_cpus = le32_to_cpup((const uint32_t *)tlv_data);
if (num_of_cpus == 2) {
-   fw->fw_sects[IWM_UCODE_REGULAR].is_dual_cpus =
+   fw->img[IWM_UCODE_REGULAR].is_dual_cpus =
TRUE;
-   fw->fw_sects[IWM_UCODE_INIT].is_dual_cpus =
+   fw->img[IWM_UCODE_INIT].is_dual_cpus =
TRUE;
-   fw->fw_sects[IWM_UCODE_WOWLAN].is_dual_cpus =
+   fw->img[IWM_UCODE_WOWLAN].is_dual_cpus =
TRUE;
} else if ((num_of_cpus > 2) || (num_of_cpus < 1)) {
device_printf(sc->sc_dev,
@@ -831,10 +831,10 @@ iwm_read_firmware(struct iwm_softc *sc)
goto out;
}
 
-   sc->sc_fw.fw_sects[IWM_UCODE_REGULAR].paging_mem_size =

svn commit: r343376 - head/sys/dev/iwm

2019-01-23 Thread Kyle Evans
Author: kevans
Date: Thu Jan 24 03:42:59 2019
New Revision: 343376
URL: https://svnweb.freebsd.org/changeset/base/343376

Log:
  if_iwm - Check sc->sc_attached flag in suspend/resume callbacks.
  
  * There is (almost) nothing to do in suspend/resume if if_iwm has failed
  during initialization (e.g. because of firmware load failure) and was
  already uninitialized by iwm_detach_local().
  
  Submitted by: Augustin Cavalier  (Haiku)
  Obtained from:DragonFlyBSD (67b5e090efb225654815fed91020db6cfc16bb19)

Modified:
  head/sys/dev/iwm/if_iwm.c

Modified: head/sys/dev/iwm/if_iwm.c
==
--- head/sys/dev/iwm/if_iwm.c   Thu Jan 24 03:42:23 2019(r343375)
+++ head/sys/dev/iwm/if_iwm.c   Thu Jan 24 03:42:59 2019(r343376)
@@ -6301,6 +6301,10 @@ iwm_resume(device_t dev)
 * PCI Tx retries from interfering with C3 CPU state.
 */
pci_write_config(dev, PCI_CFG_RETRY_TIMEOUT, 0x00, 1);
+
+   if (!sc->sc_attached)
+   return 0;
+
iwm_init_task(device_get_softc(dev));
 
IWM_LOCK(sc);
@@ -6323,6 +6327,9 @@ iwm_suspend(device_t dev)
struct iwm_softc *sc = device_get_softc(dev);
 
do_stop = !! (sc->sc_ic.ic_nrunning > 0);
+
+   if (!sc->sc_attached)
+   return (0);
 
ieee80211_suspend_all(>sc_ic);
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r343373 - head/sys/dev/iwm

2019-01-23 Thread Kyle Evans
Author: kevans
Date: Thu Jan 24 03:41:09 2019
New Revision: 343373
URL: https://svnweb.freebsd.org/changeset/base/343373

Log:
  if_iwm - Update firmware rs table, instead of indexing the table in tx cmds.
  
  * Rather than providing a non-zero index into the firmware RS table,
  we should always use index 0 and update the firmware RS table whenever
  our chosen tx rate for data-frames changes.
  
  * Send IWM_LQ_CMD updates when the tx rate gets updated by the net80211
  rate control (which is after we tell the tx status to the net80211
  rate-control in iwm_mvm_rx_tx_cmd_single()).
  
  * Disregard frames transferred with a different tx rate than the currently
  selected rate for the rate-control calculations. This way we avoid
  counting management frames (which are sent at a slow, and fixed rate),
  as well as frames we added to the tx queue just before a new IWM_LQ_CMD
  update took effect.
  
  Submitted by: Augustin Cavalier  (Haiku)
  Obtained from:DragonFlyBSD (5d6b465e288ac5b52d7115688d4e6516acbbea1c)

Modified:
  head/sys/dev/iwm/if_iwm.c
  head/sys/dev/iwm/if_iwmvar.h

Modified: head/sys/dev/iwm/if_iwm.c
==
--- head/sys/dev/iwm/if_iwm.c   Thu Jan 24 01:08:37 2019(r343372)
+++ head/sys/dev/iwm/if_iwm.c   Thu Jan 24 03:41:09 2019(r343373)
@@ -353,7 +353,9 @@ static int  iwm_release(struct iwm_softc *, struct iwm_
 static struct ieee80211_node *
iwm_node_alloc(struct ieee80211vap *,
   const uint8_t[IEEE80211_ADDR_LEN]);
-static voidiwm_setrates(struct iwm_softc *, struct iwm_node *);
+static uint8_t iwm_rate_from_ucode_rate(uint32_t);
+static int iwm_rate2ridx(struct iwm_softc *, uint8_t);
+static voidiwm_setrates(struct iwm_softc *, struct iwm_node *, int);
 static int iwm_media_change(struct ifnet *);
 static int iwm_newstate(struct ieee80211vap *, enum ieee80211_state, int);
 static voidiwm_endscan_cb(void *, int);
@@ -3317,7 +3319,11 @@ iwm_mvm_rx_tx_cmd_single(struct iwm_softc *sc, struct 
struct iwm_mvm_tx_resp *tx_resp = (void *)pkt->data;
struct ieee80211_ratectl_tx_status *txs = >sc_txs;
struct ieee80211_node *ni = >in_ni;
+   struct ieee80211vap *vap = ni->ni_vap;
int status = le16toh(tx_resp->status.status) & IWM_TX_STATUS_MSK;
+   int new_rate, cur_rate = vap->iv_bss->ni_txrate;
+   boolean_t rate_matched;
+   uint8_t tx_resp_rate;
 
KASSERT(tx_resp->frame_count == 1, ("too many frames"));
 
@@ -,6 +3339,17 @@ iwm_mvm_rx_tx_cmd_single(struct iwm_softc *sc, struct 
le32toh(tx_resp->initial_rate),
(int) le16toh(tx_resp->wireless_media_time));
 
+   tx_resp_rate = iwm_rate_from_ucode_rate(le32toh(tx_resp->initial_rate));
+
+   /* For rate control, ignore frames sent at different initial rate */
+   rate_matched = (tx_resp_rate != 0 && tx_resp_rate == cur_rate);
+
+   if (tx_resp_rate != 0 && cur_rate != 0 && !rate_matched) {
+   IWM_DPRINTF(sc, IWM_DEBUG_TXRATE,
+   "tx_resp_rate doesn't match ni_txrate (tx_resp_rate=%u "
+   "ni_txrate=%d)\n", tx_resp_rate, cur_rate);
+   }
+
txs->flags = IEEE80211_RATECTL_STATUS_SHORT_RETRY |
 IEEE80211_RATECTL_STATUS_LONG_RETRY;
txs->short_retries = tx_resp->failure_rts;
@@ -3356,8 +3373,19 @@ iwm_mvm_rx_tx_cmd_single(struct iwm_softc *sc, struct 
} else {
txs->status = IEEE80211_RATECTL_TX_SUCCESS;
}
-   ieee80211_ratectl_tx_complete(ni, txs);
 
+   if (rate_matched) {
+   ieee80211_ratectl_tx_complete(ni, txs);
+
+   int rix = ieee80211_ratectl_rate(vap->iv_bss, NULL, 0);
+   new_rate = vap->iv_bss->ni_txrate;
+   if (new_rate != 0 && new_rate != cur_rate) {
+   struct iwm_node *in = IWM_NODE(vap->iv_bss);
+   iwm_setrates(sc, in, rix);
+   iwm_mvm_send_lq_cmd(sc, >in_lq, FALSE);
+   }
+   }
+
return (txs->status != IEEE80211_RATECTL_TX_SUCCESS);
 }
 
@@ -3482,38 +3510,7 @@ iwm_update_sched(struct iwm_softc *sc, int qid, int id
 }
 #endif
 
-/*
- * Take an 802.11 (non-n) rate, find the relevant rate
- * table entry.  return the index into in_ridx[].
- *
- * The caller then uses that index back into in_ridx
- * to figure out the rate index programmed /into/
- * the firmware for this given node.
- */
 static int
-iwm_tx_rateidx_lookup(struct iwm_softc *sc, struct iwm_node *in,
-uint8_t rate)
-{
-   int i;
-   uint8_t r;
-
-   for (i = 0; i < nitems(in->in_ridx); i++) {
-   r = iwm_rates[in->in_ridx[i]].rate;
-   if (rate == r)
-   return (i);
-   }
-
-   IWM_DPRINTF(sc, IWM_DEBUG_XMIT | IWM_DEBUG_TXRATE,
-   "%s: couldn't find an entry for rate=%d\n",
- 

svn commit: r343375 - head/sys/dev/iwm

2019-01-23 Thread Kyle Evans
Author: kevans
Date: Thu Jan 24 03:42:23 2019
New Revision: 343375
URL: https://svnweb.freebsd.org/changeset/base/343375

Log:
  if_iwm - Move iwm_read_firmware() call into iwm_attach().
  
  * We should load the firmware exactly once before the driver really
  initializes the hardware the first time, and unload it at detach time.
  There is no need to retrieve the firmware during execution of
  iwm_mvm_load_ucode_wait_alive(), we should make sure we already have the
  firmware data at hand before that.
  
  * The existing sc_preinit_hook code fails to deal with the case where
  if_iwm is loaded by the loader (or is statically linked) and the
  firmware needs to be loaded from disk. So we can just call
  iwm_read_firmware() from iwm_attach() directly.
  
  * A separate solution will have to be added to properly defer the firmware
  loading during bootup, until the necessary filesystem is mounted.
  
  Submitted by: Augustin Cavalier  (Haiku)
  Obtained from:DragonFlyBSD (0104ee1f4cb6a2313c00c2526c6ae98d42e5041d)

Modified:
  head/sys/dev/iwm/if_iwm.c
  head/sys/dev/iwm/if_iwmvar.h

Modified: head/sys/dev/iwm/if_iwm.c
==
--- head/sys/dev/iwm/if_iwm.c   Thu Jan 24 03:41:44 2019(r343374)
+++ head/sys/dev/iwm/if_iwm.c   Thu Jan 24 03:42:23 2019(r343375)
@@ -245,7 +245,7 @@ static int  iwm_firmware_store_section(struct iwm_softc
const uint8_t *, size_t);
 static int iwm_set_default_calib(struct iwm_softc *, const void *);
 static voidiwm_fw_info_free(struct iwm_fw_info *);
-static int iwm_read_firmware(struct iwm_softc *, enum iwm_ucode_type);
+static int iwm_read_firmware(struct iwm_softc *);
 static int iwm_alloc_fwmem(struct iwm_softc *);
 static int iwm_alloc_sched(struct iwm_softc *);
 static int iwm_alloc_kw(struct iwm_softc *);
@@ -536,12 +536,11 @@ iwm_fw_info_free(struct iwm_fw_info *fw)
 {
firmware_put(fw->fw_fp, FIRMWARE_UNLOAD);
fw->fw_fp = NULL;
-   /* don't touch fw->fw_status */
memset(fw->fw_sects, 0, sizeof(fw->fw_sects));
 }
 
 static int
-iwm_read_firmware(struct iwm_softc *sc, enum iwm_ucode_type ucode_type)
+iwm_read_firmware(struct iwm_softc *sc)
 {
struct iwm_fw_info *fw = >sc_fw;
const struct iwm_tlv_ucode_header *uhdr;
@@ -558,24 +557,11 @@ iwm_read_firmware(struct iwm_softc *sc, enum iwm_ucode
int error = 0;
size_t len;
 
-   if (fw->fw_status == IWM_FW_STATUS_DONE &&
-   ucode_type != IWM_UCODE_INIT)
-   return 0;
-
-   while (fw->fw_status == IWM_FW_STATUS_INPROGRESS)
-   msleep(>sc_fw, >sc_mtx, 0, "iwmfwp", 0);
-   fw->fw_status = IWM_FW_STATUS_INPROGRESS;
-
-   if (fw->fw_fp != NULL)
-   iwm_fw_info_free(fw);
-
/*
 * Load firmware into driver memory.
 * fw_fp will be set.
 */
-   IWM_UNLOCK(sc);
fwp = firmware_get(sc->cfg->fw_name);
-   IWM_LOCK(sc);
if (fwp == NULL) {
device_printf(sc->sc_dev,
"could not read firmware %s (error %d)\n",
@@ -634,9 +620,8 @@ iwm_read_firmware(struct iwm_softc *sc, enum iwm_ucode
case IWM_UCODE_TLV_PROBE_MAX_LEN:
if (tlv_len != sizeof(uint32_t)) {
device_printf(sc->sc_dev,
-   "%s: PROBE_MAX_LEN (%d) != 
sizeof(uint32_t)\n",
-   __func__,
-   (int) tlv_len);
+   "%s: PROBE_MAX_LEN (%u) != 
sizeof(uint32_t)\n",
+   __func__, tlv_len);
error = EINVAL;
goto parse_out;
}
@@ -655,9 +640,8 @@ iwm_read_firmware(struct iwm_softc *sc, enum iwm_ucode
case IWM_UCODE_TLV_PAN:
if (tlv_len) {
device_printf(sc->sc_dev,
-   "%s: IWM_UCODE_TLV_PAN: tlv_len (%d) > 0\n",
-   __func__,
-   (int) tlv_len);
+   "%s: IWM_UCODE_TLV_PAN: tlv_len (%u) > 0\n",
+   __func__, tlv_len);
error = EINVAL;
goto parse_out;
}
@@ -666,17 +650,15 @@ iwm_read_firmware(struct iwm_softc *sc, enum iwm_ucode
case IWM_UCODE_TLV_FLAGS:
if (tlv_len < sizeof(uint32_t)) {
device_printf(sc->sc_dev,
-   "%s: IWM_UCODE_TLV_FLAGS: tlv_len (%d) < 
sizeof(uint32_t)\n",
-   __func__,
-   (int) tlv_len);
+

svn commit: r343372 - head/sys/dev/ixl

2019-01-23 Thread Eric Joyner
Author: erj
Date: Thu Jan 24 01:08:37 2019
New Revision: 343372
URL: https://svnweb.freebsd.org/changeset/base/343372

Log:
  ixl(4): Fix handling data passed with ioctl from NVM update tool
  
  From Krzysztof:
  
  Ensure that the entire data buffer passed from the NVM update tool is copied 
in
  to kernel space and copied back out to user space using copyin() and 
copyout().
  
  PR:   234104
  Submitted by: Krzysztof Galazka 
  Reported by:  Finn 
  MFC after:5 days
  Sponsored by: Intel Corporation
  Differential Revision:https://reviews.freebsd.org/D18817

Modified:
  head/sys/dev/ixl/ixl_pf_main.c

Modified: head/sys/dev/ixl/ixl_pf_main.c
==
--- head/sys/dev/ixl/ixl_pf_main.c  Thu Jan 24 01:04:23 2019
(r343371)
+++ head/sys/dev/ixl/ixl_pf_main.c  Thu Jan 24 01:08:37 2019
(r343372)
@@ -3663,23 +3663,34 @@ ixl_handle_nvmupd_cmd(struct ixl_pf *pf, struct ifdrv 
struct i40e_nvm_access *nvma;
device_t dev = pf->dev;
enum i40e_status_code status = 0;
-   int perrno;
+   size_t nvma_size, ifd_len, exp_len;
+   int err, perrno;
 
DEBUGFUNC("ixl_handle_nvmupd_cmd");
 
/* Sanity checks */
-   if (ifd->ifd_len < sizeof(struct i40e_nvm_access) ||
+   nvma_size = sizeof(struct i40e_nvm_access);
+   ifd_len = ifd->ifd_len;
+
+   if (ifd_len < nvma_size ||
ifd->ifd_data == NULL) {
device_printf(dev, "%s: incorrect ifdrv length or data 
pointer\n",
__func__);
device_printf(dev, "%s: ifdrv length: %zu, sizeof(struct 
i40e_nvm_access): %zu\n",
-   __func__, ifd->ifd_len, sizeof(struct i40e_nvm_access));
+   __func__, ifd_len, nvma_size);
device_printf(dev, "%s: data pointer: %p\n", __func__,
ifd->ifd_data);
return (EINVAL);
}
 
-   nvma = (struct i40e_nvm_access *)ifd->ifd_data;
+   nvma = malloc(ifd_len, M_DEVBUF, M_WAITOK);
+   err = copyin(ifd->ifd_data, nvma, ifd_len);
+   if (err) {
+   device_printf(dev, "%s: Cannot get request from user space\n",
+   __func__);
+   free(nvma, M_DEVBUF);
+   return (err);
+   }
 
if (pf->dbg_mask & IXL_DBG_NVMUPD)
ixl_print_nvm_cmd(dev, nvma);
@@ -3693,13 +3704,49 @@ ixl_handle_nvmupd_cmd(struct ixl_pf *pf, struct ifdrv 
}
}
 
-   if (!(pf->state & IXL_PF_STATE_ADAPTER_RESETTING)) {
-   // TODO: Might need a different lock here
-   // IXL_PF_LOCK(pf);
-   status = i40e_nvmupd_command(hw, nvma, nvma->data, );
-   // IXL_PF_UNLOCK(pf);
-   } else {
-   perrno = -EBUSY;
+   if (pf->state & IXL_PF_STATE_ADAPTER_RESETTING) {
+   free(nvma, M_DEVBUF);
+   return (-EBUSY);
+   }
+
+   if (nvma->data_size < 1 || nvma->data_size > 4096) {
+   device_printf(dev, "%s: invalid request, data size not in 
supported range\n",
+   __func__);
+   free(nvma, M_DEVBUF);
+   return (EINVAL);
+   }
+
+   /*
+* Older versions of the NVM update tool don't set ifd_len to the size
+* of the entire buffer passed to the ioctl. Check the data_size field
+* in the contained i40e_nvm_access struct and ensure everything is
+* copied in from userspace.
+*/
+   exp_len = nvma_size + nvma->data_size - 1; /* One byte is kept in 
struct */
+
+   if (ifd_len < exp_len) {
+   ifd_len = exp_len;
+   nvma = realloc(nvma, ifd_len, M_DEVBUF, M_WAITOK);
+   err = copyin(ifd->ifd_data, nvma, ifd_len);
+   if (err) {
+   device_printf(dev, "%s: Cannot get request from user 
space\n",
+   __func__);
+   free(nvma, M_DEVBUF);
+   return (err);
+   }
+   }
+
+   // TODO: Might need a different lock here
+   // IXL_PF_LOCK(pf);
+   status = i40e_nvmupd_command(hw, nvma, nvma->data, );
+   // IXL_PF_UNLOCK(pf);
+
+   err = copyout(nvma, ifd->ifd_data, ifd_len);
+   free(nvma, M_DEVBUF);
+   if (err) {
+   device_printf(dev, "%s: Cannot return data to user space\n",
+   __func__);
+   return (err);
}
 
/* Let the nvmupdate report errors, show them only when debug is 
enabled */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r343371 - stable/11/sys/dev/ocs_fc

2019-01-23 Thread Mark Johnston
Author: markj
Date: Thu Jan 24 01:04:23 2019
New Revision: 343371
URL: https://svnweb.freebsd.org/changeset/base/343371

Log:
  MFC r343348:
  ocs_fc: Ensure that we zero-initialize memory before copying it out.
  
  admbugs:  765

Modified:
  stable/11/sys/dev/ocs_fc/ocs_mgmt.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/ocs_fc/ocs_mgmt.c
==
--- stable/11/sys/dev/ocs_fc/ocs_mgmt.c Thu Jan 24 01:03:12 2019
(r343370)
+++ stable/11/sys/dev/ocs_fc/ocs_mgmt.c Thu Jan 24 01:04:23 2019
(r343371)
@@ -851,6 +851,7 @@ ocs_mgmt_firmware_write(ocs_t *ocs, char *name, void *
if (arg_out_length > sizeof(status_str)) {
arg_out_length = sizeof(status_str);
}
+   ocs_memset(status_str, 0, sizeof(status_str));
ocs_snprintf(status_str, arg_out_length, "%d", change_status);
if (ocs_copy_to_user(arg_out, status_str, arg_out_length)) {
ocs_log_test(ocs, "copy to user failed for 
change_status\n");
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r343369 - in head/sys/dev: e1000 ixgbe ixl

2019-01-23 Thread Eric Joyner
Author: erj
Date: Thu Jan 24 01:03:00 2019
New Revision: 343369
URL: https://svnweb.freebsd.org/changeset/base/343369

Log:
  intel iflib drivers: correct initialization of tx_cidx_processed
  
  From Jake:
  
  In r341156 ("Fix first-packet completion", 2018-11-28) a hack to work
  around a delta calculation determining how many descriptors were used
  was added to ixl_isc_tx_credits_update_dwb.
  
  The same fix was also applied to the em and igb drivers in r340310, and
  to ix in r341156.
  
  The hack checked the case where prev and cur were equal, and then added
  one. This works, because by the time we do the delta check, we already
  know there is at least one packet available, so the delta should be at
  least one.
  
  However, it's not a complete fix, and as indicated by the comment is
  really a hack to work around the real bug.
  
  The real problem is that the first time that we transmit a packet,
  tx_cidx_processed will be set to point to the start of the ring.
  Ultimately, the credits_update function expects it to point to the
  *last* descriptor that was processed. Since we haven't yet processed any
  descriptors, pointing it to 0 results in this incorrect calculation.
  
  Fix the initialization code to have it point to the end of the ring
  instead. One way to think about this, is that we are setting the value
  to be one prior to the first available descriptor.
  
  Doing so, corrects the delta calculation in all cases. The original fix
  only works if the first packet has exactly one descriptor. Otherwise, we
  will report 1 less than the correct value.
  
  As part of this fix, also update the MPASS assertions to match the real
  expectations. First, ensure that prev is not equal to cur, since this
  should never happen. Second, remove the assertion about prev==0 || delta
  != 0. It looks like that originated from when the em driver was
  converted to iflib. It seems like it was supposed to ensure that delta
  was non-zero. However, because we originally returned 0 delta for the
  first calculation, the "prev == 0" was tacked on.
  
  Instead, replace this with a check that delta is greater than zero,
  after the correction necessary when the ring pointers wrap around.
  
  This new solution should fix the same bug as r341156 did, but in a more
  robust way.
  
  Submitted by: Jacob Keller 
  Reviewed by:  shurd@
  Sponsored by: Intel Corporation
  Differential Revision:https://reviews.freebsd.org/D18545

Modified:
  head/sys/dev/e1000/em_txrx.c
  head/sys/dev/e1000/if_em.c
  head/sys/dev/e1000/igb_txrx.c
  head/sys/dev/ixgbe/if_ix.c
  head/sys/dev/ixgbe/if_ixv.c
  head/sys/dev/ixgbe/ix_txrx.c
  head/sys/dev/ixl/ixl_txrx.c

Modified: head/sys/dev/e1000/em_txrx.c
==
--- head/sys/dev/e1000/em_txrx.cWed Jan 23 23:48:57 2019
(r343368)
+++ head/sys/dev/e1000/em_txrx.cThu Jan 24 01:03:00 2019
(r343369)
@@ -457,16 +457,11 @@ em_isc_txd_credits_update(void *arg, uint16_t txqid, b
prev = txr->tx_cidx_processed;
ntxd = scctx->isc_ntxd[0];
do {
+   MPASS(prev != cur);
delta = (int32_t)cur - (int32_t)prev;
-   /*
-* XXX This appears to be a hack for first-packet.
-* A correct fix would prevent prev == cur in the first place.
-*/
-   MPASS(prev == 0 || delta != 0);
-   if (prev == 0 && cur == 0)
-   delta += 1;
if (delta < 0)
delta += ntxd;
+   MPASS(delta > 0);
DPRINTF(iflib_get_dev(adapter->ctx),
  "%s: cidx_processed=%u cur=%u clear=%d 
delta=%d\n",
  __FUNCTION__, prev, cur, clear, delta);

Modified: head/sys/dev/e1000/if_em.c
==
--- head/sys/dev/e1000/if_em.c  Wed Jan 23 23:48:57 2019(r343368)
+++ head/sys/dev/e1000/if_em.c  Thu Jan 24 01:03:00 2019(r343369)
@@ -1208,6 +1208,7 @@ static void
 em_if_init(if_ctx_t ctx)
 {
struct adapter *adapter = iflib_get_softc(ctx);
+   if_softc_ctx_t scctx = adapter->shared;
struct ifnet *ifp = iflib_get_ifp(ctx);
struct em_tx_queue *tx_que;
int i;
@@ -1240,7 +1241,14 @@ em_if_init(if_ctx_t ctx)
for (i = 0, tx_que = adapter->tx_queues; i < adapter->tx_num_queues; 
i++, tx_que++) {
struct tx_ring *txr = _que->txr;
 
-   txr->tx_rs_cidx = txr->tx_rs_pidx = txr->tx_cidx_processed = 0;
+   txr->tx_rs_cidx = txr->tx_rs_pidx;
+
+   /* Initialize the last processed descriptor to be the end of
+* the ring, rather than the start, so that we avoid an
+* off-by-one error when calculating how many descriptors are
+* done in the credits_update 

svn commit: r343370 - stable/12/sys/dev/ocs_fc

2019-01-23 Thread Mark Johnston
Author: markj
Date: Thu Jan 24 01:03:12 2019
New Revision: 343370
URL: https://svnweb.freebsd.org/changeset/base/343370

Log:
  MFC r343348:
  ocs_fc: Ensure that we zero-initialize memory before copying it out.
  
  admbugs:  765

Modified:
  stable/12/sys/dev/ocs_fc/ocs_mgmt.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/ocs_fc/ocs_mgmt.c
==
--- stable/12/sys/dev/ocs_fc/ocs_mgmt.c Thu Jan 24 01:03:00 2019
(r343369)
+++ stable/12/sys/dev/ocs_fc/ocs_mgmt.c Thu Jan 24 01:03:12 2019
(r343370)
@@ -851,6 +851,7 @@ ocs_mgmt_firmware_write(ocs_t *ocs, char *name, void *
if (arg_out_length > sizeof(status_str)) {
arg_out_length = sizeof(status_str);
}
+   ocs_memset(status_str, 0, sizeof(status_str));
ocs_snprintf(status_str, arg_out_length, "%d", change_status);
if (ocs_copy_to_user(arg_out, status_str, arg_out_length)) {
ocs_log_test(ocs, "copy to user failed for 
change_status\n");
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r343368 - head/lib/libc/tests/sys

2019-01-23 Thread Enji Cooper

> On Jan 23, 2019, at 3:48 PM, Enji Cooper  wrote:
> 
> Author: ngie
> Date: Wed Jan 23 23:48:57 2019
> New Revision: 343368
> URL: https://svnweb.freebsd.org/changeset/base/343368
> 
> Log:
>  Fix up r343367
> 
>  I should have only changed the format qualifier with the `size_t` value,
>  `length`, not the other [`off_t`] value, `dest_file_size`.
> 
>  MFC after:   1 month
>  MFC with:r343362, r343365, r343367
>  Approved by: emaste (mentor; implicit)
>  Reported by: gcc 8.x

Lessons to learn from this: is, again, always run “make universe” 
beforehand on the releng machines. I swore I did this before, but I can’t 
remember (and I didn’t run it before committing the code).
Trying to figure out a reasonable way to use my GitHub fork and do work 
with svn — the workflow is extremely error prone right now (this is just one 
symptom of that issue).
Thank you for your patience, everyone. It’s been far too long since 
I’ve earned pointyhats :/.
Cheers,
-Enji
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r343368 - head/lib/libc/tests/sys

2019-01-23 Thread Enji Cooper
Author: ngie
Date: Wed Jan 23 23:48:57 2019
New Revision: 343368
URL: https://svnweb.freebsd.org/changeset/base/343368

Log:
  Fix up r343367
  
  I should have only changed the format qualifier with the `size_t` value,
  `length`, not the other [`off_t`] value, `dest_file_size`.
  
  MFC after:1 month
  MFC with: r343362, r343365, r343367
  Approved by:  emaste (mentor; implicit)
  Reported by:  gcc 8.x

Modified:
  head/lib/libc/tests/sys/sendfile_test.c

Modified: head/lib/libc/tests/sys/sendfile_test.c
==
--- head/lib/libc/tests/sys/sendfile_test.c Wed Jan 23 23:30:55 2019
(r343367)
+++ head/lib/libc/tests/sys/sendfile_test.c Wed Jan 23 23:48:57 2019
(r343368)
@@ -289,7 +289,7 @@ verify_source_and_dest(const char* dest_filename, int 
length = (nbytes == 0) ? (size_t)(src_file_size - offset) : nbytes;
 
ATF_REQUIRE_EQ_MSG(dest_file_size, length,
-   "number of bytes written out to %s (%zu) doesn't match the "
+   "number of bytes written out to %s (%ju) doesn't match the "
"expected number of bytes (%zu)", dest_filename, dest_file_size,
length);
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r343367 - head/lib/libc/tests/sys

2019-01-23 Thread Enji Cooper

> On Jan 23, 2019, at 3:30 PM, Enji Cooper  wrote:
> 
> Author: ngie
> Date: Wed Jan 23 23:30:55 2019
> New Revision: 343367
> URL: https://svnweb.freebsd.org/changeset/base/343367
> 
> Log:
>  Unbreak the build on architectures where size_t isn't synonymous with 
> uintmax_t
> 
>  I should have used `%zu` instead of `%ju` with `size_t` types.

https://reviews.freebsd.org/file/data/2cgpmriicvbknz4wmobq/PHID-FILE-boydxwdwmlcyuxwurofm/bart-simpson-run-make-universe.gif
 

 (caption: Bart Simpson against chalkboard with 'I will run "make universe” 
before committing to src’ written repeatedly on the chalkboard).
-Enji
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r343367 - head/lib/libc/tests/sys

2019-01-23 Thread Enji Cooper
Author: ngie
Date: Wed Jan 23 23:30:55 2019
New Revision: 343367
URL: https://svnweb.freebsd.org/changeset/base/343367

Log:
  Unbreak the build on architectures where size_t isn't synonymous with 
uintmax_t
  
  I should have used `%zu` instead of `%ju` with `size_t` types.
  
  MFC after:1 month
  MFC with: r343362, r343365
  Approved by:  emaste (mentor; implicit)
  Reviewed by:  asomers
  Pointyhat to: ngie
  Submitted by: asomers
  Differential Revision: https://reviews.freebsd.org/D18935

Modified:
  head/lib/libc/tests/sys/sendfile_test.c

Modified: head/lib/libc/tests/sys/sendfile_test.c
==
--- head/lib/libc/tests/sys/sendfile_test.c Wed Jan 23 23:25:42 2019
(r343366)
+++ head/lib/libc/tests/sys/sendfile_test.c Wed Jan 23 23:30:55 2019
(r343367)
@@ -289,8 +289,8 @@ verify_source_and_dest(const char* dest_filename, int 
length = (nbytes == 0) ? (size_t)(src_file_size - offset) : nbytes;
 
ATF_REQUIRE_EQ_MSG(dest_file_size, length,
-   "number of bytes written out to %s (%ju) doesn't match the "
-   "expected number of bytes (%ju)", dest_filename, dest_file_size,
+   "number of bytes written out to %s (%zu) doesn't match the "
+   "expected number of bytes (%zu)", dest_filename, dest_file_size,
length);
 
ATF_REQUIRE_EQ_MSG(0, lseek(src_fd, offset, SEEK_SET),
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r343366 - head/share/man/man9

2019-01-23 Thread Brooks Davis
Author: brooks
Date: Wed Jan 23 23:25:42 2019
New Revision: 343366
URL: https://svnweb.freebsd.org/changeset/base/343366

Log:
  Remove documentation for the nonexistant cred_update_thread(9).
  
  This was a tangential change submitted as part of D18930.
  
  Submitted by: j...@gandi.net

Modified:
  head/share/man/man9/Makefile
  head/share/man/man9/ucred.9

Modified: head/share/man/man9/Makefile
==
--- head/share/man/man9/MakefileWed Jan 23 23:06:39 2019
(r343365)
+++ head/share/man/man9/MakefileWed Jan 23 23:25:42 2019
(r343366)
@@ -2095,8 +2095,7 @@ MLINKS+=timeout.9 callout.9 \
timeout.9 callout_stop.9 \
timeout.9 callout_when.9 \
timeout.9 untimeout.9
-MLINKS+=ucred.9 cred_update_thread.9 \
-   ucred.9 crcopy.9 \
+MLINKS+=ucred.9 crcopy.9 \
ucred.9 crcopysafe.9 \
ucred.9 crdup.9 \
ucred.9 crfree.9 \

Modified: head/share/man/man9/ucred.9
==
--- head/share/man/man9/ucred.9 Wed Jan 23 23:06:39 2019(r343365)
+++ head/share/man/man9/ucred.9 Wed Jan 23 23:25:42 2019(r343366)
@@ -26,7 +26,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd September 27, 2017
+.Dd January 23, 2019
 .Dt UCRED 9
 .Os
 .Sh NAME
@@ -36,8 +36,7 @@
 .Nm crfree ,
 .Nm crcopy ,
 .Nm crdup ,
-.Nm cru2x ,
-.Nm cred_update_thread
+.Nm cru2x
 .Nd "functions related to user credentials"
 .Sh SYNOPSIS
 .In sys/param.h
@@ -58,8 +57,6 @@
 .Fn crsetgroups "struct ucred *cr" "int ngrp" "gid_t *groups"
 .Ft void
 .Fn cru2x "struct ucred *cr" "struct xucred *xcr"
-.Ft void
-.Fn cred_update_thread "struct thread *td"
 .Sh DESCRIPTION
 The
 .Nm
@@ -147,11 +144,6 @@ the former
 (e.g.,
 .Va cr_version ) .
 .Pp
-The
-.Fn cred_update_thread
-function sets the credentials of
-.Fa td
-to that of its process, freeing its old credential if required.
 .Sh RETURN VALUES
 .Fn crget ,
 .Fn crhold ,
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r343365 - head/lib/libc/tests/sys

2019-01-23 Thread Enji Cooper
Author: ngie
Date: Wed Jan 23 23:06:39 2019
New Revision: 343365
URL: https://svnweb.freebsd.org/changeset/base/343365

Log:
  Unbreak the gcc build with sendfile_test after r343362
  
  gcc 8.x is more pedantic than clang 7.x with format strings and the tests
  passed `void*` variables while supplying `%s` (which is technically
  incorrect).
  
  Make the affected `void*` variables use `char*` storage instead to address
  this issue, as the compiler will upcast the values to `char*`.
  
  MFC after:1 month
  MFC with: r343362
  Approved by:  emaste (mentor; implicit)
  Reviewed by:  asomers
  Differential Revision: https://reviews.freebsd.org/D18934

Modified:
  head/lib/libc/tests/sys/sendfile_test.c

Modified: head/lib/libc/tests/sys/sendfile_test.c
==
--- head/lib/libc/tests/sys/sendfile_test.c Wed Jan 23 22:19:49 2019
(r343364)
+++ head/lib/libc/tests/sys/sendfile_test.c Wed Jan 23 23:06:39 2019
(r343365)
@@ -195,7 +195,7 @@ setup_server(int domain, int type, int port)
 static void
 server_cat(const char *dest_filename, int server_sock, size_t len)
 {
-   void *buffer;
+   char *buffer;
int recv_sock;
ssize_t received_bytes;
 
@@ -268,7 +268,7 @@ static void
 verify_source_and_dest(const char* dest_filename, int src_fd, off_t offset,
 size_t nbytes)
 {
-   void *dest_pointer, *src_pointer;
+   char *dest_pointer, *src_pointer;
off_t dest_file_size, src_file_size;
size_t length;
int dest_fd;
@@ -384,7 +384,7 @@ ATF_TC_BODY(fd_positive_file_v6, tc)
 static void
 fd_positive_shm_test(int domain)
 {
-   void *shm_pointer;
+   char *shm_pointer;
off_t offset;
size_t nbytes, pattern_size;
pid_t server_pid;
@@ -687,9 +687,9 @@ hdtr_positive_test(int domain)
client_sock = setup_tcp_client(domain, port);
 
rc = asprintf(, "%s%s%s",
-   testcases[i].include_headers ? headers[0].iov_base : "",
+   testcases[i].include_headers ? (char *)headers[0].iov_base 
: "",
DETERMINISTIC_PATTERN,
-   testcases[i].include_trailers ? trailers[0].iov_base : "");
+   testcases[i].include_trailers ? (char 
*)trailers[0].iov_base : "");
ATF_REQUIRE_MSG(rc != -1, "asprintf failed: %s", 
strerror(errno));
 
atf_utils_create_file(SOURCE_FILE ".full", "%s", pattern);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r343363 - in head/sys: netinet netinet6

2019-01-23 Thread Mark Johnston
Author: markj
Date: Wed Jan 23 22:18:23 2019
New Revision: 343363
URL: https://svnweb.freebsd.org/changeset/base/343363

Log:
  Fix an LLE lookup race.
  
  After the afdata read lock was converted to epoch(9), readers could
  observe a linked LLE and block on the LLE while a thread was
  unlinking the LLE.  The writer would then release the lock and schedule
  the LLE for deferred free, allowing readers to continue and potentially
  schedule the LLE timer.  By the point the timer fires, the structure is
  freed, typically resulting in a crash in the callout subsystem.
  
  Fix the problem by modifying the lookup path to check for the LLE_LINKED
  flag upon acquiring the LLE lock.  If it's not set, the lookup fails.
  
  PR:   234296
  Reviewed by:  bz
  Tested by:sbruno, Victor ,
Mike Andrews 
  MFC after:3 days
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D18906

Modified:
  head/sys/netinet/in.c
  head/sys/netinet6/in6.c

Modified: head/sys/netinet/in.c
==
--- head/sys/netinet/in.c   Wed Jan 23 22:00:17 2019(r343362)
+++ head/sys/netinet/in.c   Wed Jan 23 22:18:23 2019(r343363)
@@ -1399,6 +1399,17 @@ in_lltable_lookup(struct lltable *llt, u_int flags, co
else
LLE_RLOCK(lle);
 
+   /*
+* If the afdata lock is not held, the LLE may have been unlinked while
+* we were blocked on the LLE lock.  Check for this case.
+*/
+   if (__predict_false((lle->la_flags & LLE_LINKED) == 0)) {
+   if (flags & LLE_EXCLUSIVE)
+   LLE_WUNLOCK(lle);
+   else
+   LLE_RUNLOCK(lle);
+   return (NULL);
+   }
return (lle);
 }
 

Modified: head/sys/netinet6/in6.c
==
--- head/sys/netinet6/in6.c Wed Jan 23 22:00:17 2019(r343362)
+++ head/sys/netinet6/in6.c Wed Jan 23 22:18:23 2019(r343363)
@@ -2342,6 +2342,18 @@ in6_lltable_lookup(struct lltable *llt, u_int flags,
LLE_WLOCK(lle);
else
LLE_RLOCK(lle);
+
+   /*
+* If the afdata lock is not held, the LLE may have been unlinked while
+* we were blocked on the LLE lock.  Check for this case.
+*/
+   if (__predict_false((lle->la_flags & LLE_LINKED) == 0)) {
+   if (flags & LLE_EXCLUSIVE)
+   LLE_WUNLOCK(lle);
+   else
+   LLE_RUNLOCK(lle);
+   return (NULL);
+   }
return (lle);
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r343364 - in head/sys: netinet netinet6

2019-01-23 Thread Mark Johnston
Author: markj
Date: Wed Jan 23 22:19:49 2019
New Revision: 343364
URL: https://svnweb.freebsd.org/changeset/base/343364

Log:
  Style.
  
  Reviewed by:  bz
  MFC after:3 days
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/netinet/in.c
  head/sys/netinet6/in6.c

Modified: head/sys/netinet/in.c
==
--- head/sys/netinet/in.c   Wed Jan 23 22:18:23 2019(r343363)
+++ head/sys/netinet/in.c   Wed Jan 23 22:19:49 2019(r343364)
@@ -1382,15 +1382,13 @@ in_lltable_lookup(struct lltable *llt, u_int flags, co
IF_AFDATA_LOCK_ASSERT(llt->llt_ifp);
KASSERT(l3addr->sa_family == AF_INET,
("sin_family %d", l3addr->sa_family));
-   lle = in_lltable_find_dst(llt, sin->sin_addr);
+   KASSERT((flags & (LLE_UNLOCKED | LLE_EXCLUSIVE)) !=
+   (LLE_UNLOCKED | LLE_EXCLUSIVE),
+   ("wrong lle request flags: %#x", flags));
 
+   lle = in_lltable_find_dst(llt, sin->sin_addr);
if (lle == NULL)
return (NULL);
-
-   KASSERT((flags & (LLE_UNLOCKED|LLE_EXCLUSIVE)) !=
-   (LLE_UNLOCKED|LLE_EXCLUSIVE),("wrong lle request flags: 0x%X",
-   flags));
-
if (flags & LLE_UNLOCKED)
return (lle);
 

Modified: head/sys/netinet6/in6.c
==
--- head/sys/netinet6/in6.c Wed Jan 23 22:18:23 2019(r343363)
+++ head/sys/netinet6/in6.c Wed Jan 23 22:19:49 2019(r343364)
@@ -2325,16 +2325,13 @@ in6_lltable_lookup(struct lltable *llt, u_int flags,
IF_AFDATA_LOCK_ASSERT(llt->llt_ifp);
KASSERT(l3addr->sa_family == AF_INET6,
("sin_family %d", l3addr->sa_family));
+   KASSERT((flags & (LLE_UNLOCKED | LLE_EXCLUSIVE)) !=
+   (LLE_UNLOCKED | LLE_EXCLUSIVE),
+   ("wrong lle request flags: %#x", flags));
 
lle = in6_lltable_find_dst(llt, >sin6_addr);
-
if (lle == NULL)
return (NULL);
-
-   KASSERT((flags & (LLE_UNLOCKED|LLE_EXCLUSIVE)) !=
-   (LLE_UNLOCKED|LLE_EXCLUSIVE),("wrong lle request flags: 0x%X",
-   flags));
-
if (flags & LLE_UNLOCKED)
return (lle);
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r343362 - head/lib/libc/tests/sys

2019-01-23 Thread Enji Cooper
Author: ngie
Date: Wed Jan 23 22:00:17 2019
New Revision: 343362
URL: https://svnweb.freebsd.org/changeset/base/343362

Log:
  Add [initial] functional tests for sendfile(2) as lib/libc/sys/sendfile
  
  These testcases exercise a number of functional requirements for sendfile(2).
  
  The testcases use IPv4 and IPv6 domain sockets with TCP, and were confirmed
  functional on UFS and ZFS. UDP address family sockets cannot be used per the
  sendfile(2) contract, thus using UDP sockets is outside the scope of
  testing the syscall in positive cases. As seen in
  `:s_negative_udp_socket_test`, UDP is used to test the sendfile(2) contract
  to ensure that EINVAL is returned by sendfile(2).
  
  The testcases added explicitly avoid testing out `SF_SYNC` due to the
  complexity of verifying that support. However, this is a good next logical
  item to verify.
  
  The `hdtr_positive*` testcases work to a certain degree (the header
  testcases pass), but the trailer testcases do not work (it is an expected
  failure). In particular, the value received by the mock server doesn't match
  the expected value, and instead looks something like the following (using
  python array notation):
  
  `trailer[:]message[1:]`
  
  instead of:
  
  `message[:]trailer[:]`
  
  This makes me think there's a buffer overrun issue or problem with the
  offset somewhere in the sendfile(2) system call, but I need to do some
  other testing first to verify that the code is indeed sane, and my
  assumptions/code isn't buggy.
  
  The `sbytes_negative` testcases that check `sbytes` being set to an
  invalid value resulting in `EFAULT` fails today as the other change
  (which checks `copyout(9)`) has not been committed [1]. Thus, it
  should remain an expected failure (see bug 232210 for more details
  on this item).
  
  Next steps for testing sendfile(2):
  1. Fix the header/trailer testcases so that they pass.
  2. Setup if_tap interface and test with it, instead of using "localhost", per
 @asomers's suggestion.
  3. Handle short recv(2)'s in `server_cat(..)`.
  4. Add `SF_SYNC` support.
  5. Add some more negative tests outside the scope of the functional contract.
  
  MFC after:1 month
  Reviewed by:  asomers
  Approved by:  emaste (mentor)
  PR:   232210
  Sponsored by:   Netflix, Inc
  Differential Revision: https://reviews.freebsd.org/D18625

Added:
  head/lib/libc/tests/sys/sendfile_test.c   (contents, props changed)
Modified:
  head/lib/libc/tests/sys/Makefile

Modified: head/lib/libc/tests/sys/Makefile
==
--- head/lib/libc/tests/sys/MakefileWed Jan 23 20:49:14 2019
(r343361)
+++ head/lib/libc/tests/sys/MakefileWed Jan 23 22:00:17 2019
(r343362)
@@ -8,6 +8,7 @@ PACKAGE=tests
 ATF_TESTS_C+=  brk_test
 .endif
 ATF_TESTS_C+=  queue_test
+ATF_TESTS_C+=  sendfile_test
 
 # TODO: clone, lwp_create, lwp_ctl, posix_fadvise, recvmmsg,
 # swapcontext

Added: head/lib/libc/tests/sys/sendfile_test.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/lib/libc/tests/sys/sendfile_test.c Wed Jan 23 22:00:17 2019
(r343362)
@@ -0,0 +1,1146 @@
+/*-
+ * Copyright (c) 2018 Enji Cooper.
+ * 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 
+
+const char DETERMINISTIC_PATTERN[] 

svn commit: r343361 - stable/11/sys/x86/x86

2019-01-23 Thread Konstantin Belousov
Author: kib
Date: Wed Jan 23 20:49:14 2019
New Revision: 343361
URL: https://svnweb.freebsd.org/changeset/base/343361

Log:
  MFC r343086:
  Remove unused prototype.

Modified:
  stable/11/sys/x86/x86/busdma_bounce.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/x86/x86/busdma_bounce.c
==
--- stable/11/sys/x86/x86/busdma_bounce.c   Wed Jan 23 20:47:31 2019
(r343360)
+++ stable/11/sys/x86/x86/busdma_bounce.c   Wed Jan 23 20:49:14 2019
(r343361)
@@ -138,7 +138,6 @@ static bus_addr_t add_bounce_page(bus_dma_tag_t dmat, 
  vm_offset_t vaddr, bus_addr_t addr1,
  bus_addr_t addr2, bus_size_t size);
 static void free_bounce_page(bus_dma_tag_t dmat, struct bounce_page *bpage);
-int run_filter(bus_dma_tag_t dmat, bus_addr_t paddr);
 static void _bus_dmamap_count_pages(bus_dma_tag_t dmat, bus_dmamap_t map,
pmap_t pmap, void *buf, bus_size_t buflen,
int flags);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r343360 - stable/12/sys/x86/x86

2019-01-23 Thread Konstantin Belousov
Author: kib
Date: Wed Jan 23 20:47:31 2019
New Revision: 343360
URL: https://svnweb.freebsd.org/changeset/base/343360

Log:
  MFC r343087:
  Style(9) fixes for x86/busdma_bounce.c.

Modified:
  stable/12/sys/x86/x86/busdma_bounce.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/x86/x86/busdma_bounce.c
==
--- stable/12/sys/x86/x86/busdma_bounce.c   Wed Jan 23 20:44:51 2019
(r343359)
+++ stable/12/sys/x86/x86/busdma_bounce.c   Wed Jan 23 20:47:31 2019
(r343360)
@@ -137,19 +137,16 @@ static void init_bounce_pages(void *dummy);
 static int alloc_bounce_zone(bus_dma_tag_t dmat);
 static int alloc_bounce_pages(bus_dma_tag_t dmat, u_int numpages);
 static int reserve_bounce_pages(bus_dma_tag_t dmat, bus_dmamap_t map,
-   int commit);
+int commit);
 static bus_addr_t add_bounce_page(bus_dma_tag_t dmat, bus_dmamap_t map,
- vm_offset_t vaddr, bus_addr_t addr1,
- bus_addr_t addr2, bus_size_t size);
+vm_offset_t vaddr, bus_addr_t addr1, bus_addr_t addr2, bus_size_t size);
 static void free_bounce_page(bus_dma_tag_t dmat, struct bounce_page *bpage);
 static void _bus_dmamap_count_pages(bus_dma_tag_t dmat, bus_dmamap_t map,
-   pmap_t pmap, void *buf, bus_size_t buflen,
-   int flags);
+pmap_t pmap, void *buf, bus_size_t buflen, int flags);
 static void _bus_dmamap_count_phys(bus_dma_tag_t dmat, bus_dmamap_t map,
-  vm_paddr_t buf, bus_size_t buflen,
-  int flags);
+vm_paddr_t buf, bus_size_t buflen, int flags);
 static int _bus_dmamap_reserve_pages(bus_dma_tag_t dmat, bus_dmamap_t map,
-int flags);
+int flags);
 
 static int
 bounce_bus_dma_zone_setup(bus_dma_tag_t dmat)
@@ -202,15 +199,15 @@ bounce_bus_dma_tag_create(bus_dma_tag_t parent, bus_si
newtag->map_count = 0;
newtag->segments = NULL;
 
-   if (parent != NULL && ((newtag->common.filter != NULL) ||
-   ((parent->bounce_flags & BUS_DMA_COULD_BOUNCE) != 0)))
+   if (parent != NULL && (newtag->common.filter != NULL ||
+   (parent->bounce_flags & BUS_DMA_COULD_BOUNCE) != 0))
newtag->bounce_flags |= BUS_DMA_COULD_BOUNCE;
 
if (newtag->common.lowaddr < ptoa((vm_paddr_t)Maxmem) ||
newtag->common.alignment > 1)
newtag->bounce_flags |= BUS_DMA_COULD_BOUNCE;
 
-   if (((newtag->bounce_flags & BUS_DMA_COULD_BOUNCE) != 0) &&
+   if ((newtag->bounce_flags & BUS_DMA_COULD_BOUNCE) != 0 &&
(flags & BUS_DMA_ALLOCNOW) != 0)
error = bounce_bus_dma_zone_setup(newtag);
else
@@ -309,7 +306,7 @@ bounce_bus_dmamap_create(bus_dma_tag_t dmat, int flags
 * exclusion region, a data alignment that is stricter than 1, and/or
 * an active address boundary.
 */
-   if (dmat->bounce_flags & BUS_DMA_COULD_BOUNCE) {
+   if ((dmat->bounce_flags & BUS_DMA_COULD_BOUNCE) != 0) {
/* Must bounce */
if (dmat->bounce_zone == NULL) {
if ((error = alloc_bounce_zone(dmat)) != 0)
@@ -448,14 +445,15 @@ bounce_bus_dmamem_alloc(bus_dma_tag_t dmat, void** vad
 *
 * In the meantime warn the user if malloc gets it wrong.
 */
-   if ((dmat->common.maxsize <= PAGE_SIZE) &&
-  (dmat->common.alignment <= dmat->common.maxsize) &&
+   if (dmat->common.maxsize <= PAGE_SIZE &&
+   dmat->common.alignment <= dmat->common.maxsize &&
dmat->common.lowaddr >= ptoa((vm_paddr_t)Maxmem) &&
attr == VM_MEMATTR_DEFAULT) {
*vaddr = malloc_domainset(dmat->common.maxsize, M_DEVBUF,
DOMAINSET_PREF(dmat->common.domain), mflags);
} else if (dmat->common.nsegments >=
-   howmany(dmat->common.maxsize, MIN(dmat->common.maxsegsz, 
PAGE_SIZE)) &&
+   howmany(dmat->common.maxsize, MIN(dmat->common.maxsegsz,
+   PAGE_SIZE)) &&
dmat->common.alignment <= PAGE_SIZE &&
(dmat->common.boundary % PAGE_SIZE) == 0) {
/* Page-based multi-segment allocations allowed */
@@ -512,7 +510,7 @@ _bus_dmamap_count_phys(bus_dma_tag_t dmat, bus_dmamap_
bus_addr_t curaddr;
bus_size_t sgsize;
 
-   if ((map != _dmamap && map->pagesneeded == 0)) {
+   if (map != _dmamap && map->pagesneeded == 0) {
/*
 * Count the number of bounce pages
 * needed in order to complete this transfer
@@ -541,7 +539,7 @@ _bus_dmamap_count_pages(bus_dma_tag_t dmat, bus_dmamap
bus_addr_t paddr;
bus_size_t sg_len;
 
-   if ((map != _dmamap && map->pagesneeded == 0)) {
+   if (map != _dmamap && 

svn commit: r343359 - stable/12/sys/x86/x86

2019-01-23 Thread Konstantin Belousov
Author: kib
Date: Wed Jan 23 20:44:51 2019
New Revision: 343359
URL: https://svnweb.freebsd.org/changeset/base/343359

Log:
  MFC r343086:
  Remove unused prototype.

Modified:
  stable/12/sys/x86/x86/busdma_bounce.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/x86/x86/busdma_bounce.c
==
--- stable/12/sys/x86/x86/busdma_bounce.c   Wed Jan 23 20:43:42 2019
(r343358)
+++ stable/12/sys/x86/x86/busdma_bounce.c   Wed Jan 23 20:44:51 2019
(r343359)
@@ -142,7 +142,6 @@ static bus_addr_t add_bounce_page(bus_dma_tag_t dmat, 
  vm_offset_t vaddr, bus_addr_t addr1,
  bus_addr_t addr2, bus_size_t size);
 static void free_bounce_page(bus_dma_tag_t dmat, struct bounce_page *bpage);
-int run_filter(bus_dma_tag_t dmat, bus_addr_t paddr);
 static void _bus_dmamap_count_pages(bus_dma_tag_t dmat, bus_dmamap_t map,
pmap_t pmap, void *buf, bus_size_t buflen,
int flags);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r343358 - stable/12/sys/net

2019-01-23 Thread Konstantin Belousov
Author: kib
Date: Wed Jan 23 20:43:42 2019
New Revision: 343358
URL: https://svnweb.freebsd.org/changeset/base/343358

Log:
  MFC r343085:
  Improve iflib busdma(9) KPI use.

Modified:
  stable/12/sys/net/iflib.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/net/iflib.c
==
--- stable/12/sys/net/iflib.c   Wed Jan 23 20:38:01 2019(r343357)
+++ stable/12/sys/net/iflib.c   Wed Jan 23 20:43:42 2019(r343358)
@@ -282,6 +282,7 @@ typedef struct iflib_sw_rx_desc_array {
 
 typedef struct iflib_sw_tx_desc_array {
bus_dmamap_t*ifsd_map; /* bus_dma maps for packet */
+   bus_dmamap_t*ifsd_tso_map; /* bus_dma maps for TSO packet */
struct mbuf**ifsd_m;   /* pkthdr mbufs */
 } if_txsd_vec_t;
 
@@ -1491,6 +1492,8 @@ iflib_fast_intr_rxtx(void *arg)
 
ctx = rxq->ifr_ctx;
 
+   bus_dmamap_sync(rxq->ifr_ifdi->idi_tag, rxq->ifr_ifdi->idi_map,
+   BUS_DMASYNC_POSTREAD);
if (!ctx->isc_txd_credits_update(ctx->ifc_softc, txqid, false)) 
{
IFDI_TX_QUEUE_INTR_ENABLE(ctx, txqid);
continue;
@@ -1583,6 +1586,7 @@ iflib_txsd_alloc(iflib_txq_t txq)
device_t dev = ctx->ifc_dev;
bus_size_t tsomaxsize;
int err, nsegments, ntsosegments;
+   bool tso;
 
nsegments = scctx->isc_tx_nsegments;
ntsosegments = scctx->isc_tx_tso_segments_max;
@@ -1617,8 +1621,8 @@ iflib_txsd_alloc(iflib_txq_t txq)
(uintmax_t)sctx->isc_tx_maxsize, nsegments, 
(uintmax_t)sctx->isc_tx_maxsegsize);
goto fail;
}
-   if ((if_getcapabilities(ctx->ifc_ifp) & IFCAP_TSO) &&
-   (err = bus_dma_tag_create(bus_get_dma_tag(dev),
+   tso = (if_getcapabilities(ctx->ifc_ifp) & IFCAP_TSO) != 0;
+   if (tso && (err = bus_dma_tag_create(bus_get_dma_tag(dev),
   1, 0,/* alignment, bounds */
   BUS_SPACE_MAXADDR,   /* lowaddr */
   BUS_SPACE_MAXADDR,   /* highaddr */
@@ -1631,7 +1635,6 @@ iflib_txsd_alloc(iflib_txq_t txq)
   NULL,/* lockfuncarg */
   >ift_tso_desc_tag))) {
device_printf(dev,"Unable to allocate TX TSO DMA tag: %d\n", 
err);
-
goto fail;
}
if (!(txq->ift_sds.ifsd_m =
@@ -1643,19 +1646,38 @@ iflib_txsd_alloc(iflib_txq_t txq)
}
 
 /* Create the descriptor buffer dma maps */
-   if (!(txq->ift_sds.ifsd_map =
-   (bus_dmamap_t *) malloc(sizeof(bus_dmamap_t) * 
scctx->isc_ntxd[txq->ift_br_offset], M_IFLIB, M_NOWAIT | M_ZERO))) {
+   if ((txq->ift_sds.ifsd_map = (bus_dmamap_t *)malloc(
+   sizeof(bus_dmamap_t) * scctx->isc_ntxd[txq->ift_br_offset],
+   M_IFLIB, M_NOWAIT | M_ZERO)) == NULL) {
device_printf(dev, "Unable to allocate tx_buffer map memory\n");
err = ENOMEM;
goto fail;
}
 
+   if (tso && (txq->ift_sds.ifsd_tso_map = (bus_dmamap_t *)malloc(
+   sizeof(bus_dmamap_t) * scctx->isc_ntxd[txq->ift_br_offset],
+   M_IFLIB, M_NOWAIT | M_ZERO)) == NULL) {
+   device_printf(dev, "Unable to allocate TSO tx_buffer "
+   "map memory\n");
+   err = ENOMEM;
+   goto fail;
+   }
+
for (int i = 0; i < scctx->isc_ntxd[txq->ift_br_offset]; i++) {
-   err = bus_dmamap_create(txq->ift_desc_tag, 0, 
>ift_sds.ifsd_map[i]);
+   err = bus_dmamap_create(txq->ift_desc_tag, 0,
+   >ift_sds.ifsd_map[i]);
if (err != 0) {
device_printf(dev, "Unable to create TX DMA map\n");
goto fail;
}
+   if (!tso)
+   continue;
+   err = bus_dmamap_create(txq->ift_tso_desc_tag, 0,
+   >ift_sds.ifsd_tso_map[i]);
+   if (err != 0) {
+   device_printf(dev, "Unable to create TSO TX DMA map\n");
+   goto fail;
+   }
}
return (0);
 fail:
@@ -1673,10 +1695,22 @@ iflib_txsd_destroy(if_ctx_t ctx, iflib_txq_t txq, int 
if (txq->ift_sds.ifsd_map != NULL)
map = txq->ift_sds.ifsd_map[i];
if (map != NULL) {
+   bus_dmamap_sync(txq->ift_desc_tag, map, BUS_DMASYNC_POSTWRITE);
bus_dmamap_unload(txq->ift_desc_tag, map);
bus_dmamap_destroy(txq->ift_desc_tag, map);
txq->ift_sds.ifsd_map[i] = NULL;
}
+
+   map = NULL;
+   if (txq->ift_sds.ifsd_tso_map != NULL)
+   map = txq->ift_sds.ifsd_tso_map[i];
+   if (map != NULL) {
+   

svn commit: r343357 - stable/11/contrib/netbsd-tests/kernel

2019-01-23 Thread Konstantin Belousov
Author: kib
Date: Wed Jan 23 20:38:01 2019
New Revision: 343357
URL: https://svnweb.freebsd.org/changeset/base/343357

Log:
  MFC r343081:
  Trim spaces at the end of lines.

Modified:
  stable/11/contrib/netbsd-tests/kernel/t_sysv.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/contrib/netbsd-tests/kernel/t_sysv.c
==
--- stable/11/contrib/netbsd-tests/kernel/t_sysv.c  Wed Jan 23 20:34:22 
2019(r343356)
+++ stable/11/contrib/netbsd-tests/kernel/t_sysv.c  Wed Jan 23 20:38:01 
2019(r343357)
@@ -842,9 +842,9 @@ sharer(void)
 ATF_TP_ADD_TCS(tp)
 {
 
-   ATF_TP_ADD_TC(tp, msg); 
-   ATF_TP_ADD_TC(tp, sem); 
-   ATF_TP_ADD_TC(tp, shm); 
+   ATF_TP_ADD_TC(tp, msg);
+   ATF_TP_ADD_TC(tp, sem);
+   ATF_TP_ADD_TC(tp, shm);
 
return atf_no_error();
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r343356 - in stable/12: contrib/netbsd-tests/kernel lib/libc/sys sys/kern sys/sys sys/vm

2019-01-23 Thread Konstantin Belousov
Author: kib
Date: Wed Jan 23 20:34:22 2019
New Revision: 343356
URL: https://svnweb.freebsd.org/changeset/base/343356

Log:
  MFC r343082:
  Implement shmat(2) flag SHM_REMAP.

Modified:
  stable/12/contrib/netbsd-tests/kernel/t_sysv.c
  stable/12/lib/libc/sys/shmat.2
  stable/12/sys/kern/sysv_shm.c
  stable/12/sys/sys/shm.h
  stable/12/sys/vm/vm_map.c
  stable/12/sys/vm/vm_map.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/contrib/netbsd-tests/kernel/t_sysv.c
==
--- stable/12/contrib/netbsd-tests/kernel/t_sysv.c  Wed Jan 23 20:31:24 
2019(r343355)
+++ stable/12/contrib/netbsd-tests/kernel/t_sysv.c  Wed Jan 23 20:34:22 
2019(r343356)
@@ -47,6 +47,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -772,19 +773,27 @@ ATF_TC_BODY(shm, tc)
atf_tc_fail("sender: received unexpected signal");
 }
 
-ATF_TC_CLEANUP(shm, tc)
+static void
+shmid_cleanup(const char *name)
 {
-   int sender_shmid;
+   int shmid;
 
/*
 * Remove the shared memory area if it exists.
 */
-   sender_shmid = read_int("sender_shmid");
-   if (sender_shmid != -1)
-   if (shmctl(sender_shmid, IPC_RMID, NULL) == -1)
+   shmid = read_int(name);
+   if (shmid != -1) {
+   if (shmctl(shmid, IPC_RMID, NULL) == -1)
err(1, "shmctl IPC_RMID");
+   }
 }
 
+ATF_TC_CLEANUP(shm, tc)
+{
+
+   shmid_cleanup("sender_shmid");
+}
+
 void
 print_shmid_ds(struct shmid_ds *sp, mode_t mode)
 {
@@ -837,12 +846,53 @@ sharer(void)
exit(0);
 }
 
+#ifdef SHM_REMAP
+ATF_TC_WITH_CLEANUP(shm_remap);
+ATF_TC_HEAD(shm_remap, tc)
+{
+
+   atf_tc_set_md_var(tc, "descr", "Checks SHM_REMAP");
+}
+
+ATF_TC_BODY(shm_remap, tc)
+{
+   char *shm_buf;
+   int shmid_remap;
+
+   pgsize = sysconf(_SC_PAGESIZE);
+
+   shmkey = get_ftok(4160);
+   ATF_REQUIRE_MSG(shmkey != (key_t)-1, "get_ftok failed");
+
+   ATF_REQUIRE_MSG((shmid_remap = shmget(shmkey, pgsize,
+   IPC_CREAT | 0640)) != -1, "shmget: %d", errno);
+   write_int("shmid_remap", shmid_remap);
+
+   ATF_REQUIRE_MSG((shm_buf = mmap(NULL, pgsize, PROT_READ | PROT_WRITE,
+   MAP_ANON | MAP_PRIVATE, -1, 0)) != MAP_FAILED, "mmap: %d", errno);
+
+   ATF_REQUIRE_MSG(shmat(shmid_remap, shm_buf, 0) == (void *)-1,
+   "shmat without MAP_REMAP succeeded");
+   ATF_REQUIRE_MSG(shmat(shmid_remap, shm_buf, SHM_REMAP) == shm_buf,
+   "shmat(SHM_REMAP): %d", errno);
+}
+
+ATF_TC_CLEANUP(shm_remap, tc)
+{
+
+   shmid_cleanup("shmid_remap");
+}
+#endif /* SHM_REMAP */
+
 ATF_TP_ADD_TCS(tp)
 {
 
ATF_TP_ADD_TC(tp, msg);
ATF_TP_ADD_TC(tp, sem);
ATF_TP_ADD_TC(tp, shm);
+#ifdef SHM_REMAP
+   ATF_TP_ADD_TC(tp, shm_remap);
+#endif
 
return atf_no_error();
 }

Modified: stable/12/lib/libc/sys/shmat.2
==
--- stable/12/lib/libc/sys/shmat.2  Wed Jan 23 20:31:24 2019
(r343355)
+++ stable/12/lib/libc/sys/shmat.2  Wed Jan 23 20:34:22 2019
(r343356)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd January 25, 2018
+.Dd January 14, 2019
 .Dt SHMAT 2
 .Os
 .Sh NAME
@@ -64,17 +64,38 @@ kernel.
 .It
 If
 .Fa addr
-is nonzero and SHM_RND is not specified in
+is nonzero and
+.Va SHM_RND
+is not specified in
 .Fa flag ,
 the segment is attached the specified address.
 .It
 If
 .Fa addr
-is specified and SHM_RND is specified,
+is specified and
+.Va SHM_RND
+is specified,
 .Fa addr
 is rounded down to the nearest multiple of SHMLBA.
 .El
 .Pp
+If the
+.Va SHM_REMAP
+flag is specified and the passed
+.Fa addr
+is not
+.Dv NULL ,
+any existing mappings in the virtual addresses range are
+cleared before the segment is attached.
+If the flag is not specified,
+.Fa addr
+is not
+.Dv NULL ,
+and the virtual address range contains
+some pre-existing mappings, the
+.Fn shmat
+call fails.
+.Pp
 The
 .Fn shmdt
 system call
@@ -104,6 +125,14 @@ The
 .Fa addr
 argument
 was not an acceptable address.
+.It Bq Er ENOMEM
+The specified
+.Fa addr
+cannot be used for mapping, for instance due to the amount of available
+space being smaller than the segment size,
+or because pre-existing mappings are in the range and no
+.Va SHM_REMAP
+flag was provided.
 .It Bq Er EMFILE
 Failed to attach the shared memory segment because the per-process
 .Va kern.ipc.shmseg

Modified: stable/12/sys/kern/sysv_shm.c
==
--- stable/12/sys/kern/sysv_shm.c   Wed Jan 23 20:31:24 2019
(r343355)
+++ stable/12/sys/kern/sysv_shm.c   Wed Jan 23 20:34:22 2019
(r343356)
@@ -388,7 +388,7 @@ kern_shmat_locked(struct thread *td, int shmid, const 
vm_offset_t attach_va;
vm_prot_t prot;
vm_size_t size;
- 

svn commit: r343355 - stable/12/contrib/netbsd-tests/kernel

2019-01-23 Thread Konstantin Belousov
Author: kib
Date: Wed Jan 23 20:31:24 2019
New Revision: 343355
URL: https://svnweb.freebsd.org/changeset/base/343355

Log:
  MFC r343081:
  Trim spaces at the end of lines.

Modified:
  stable/12/contrib/netbsd-tests/kernel/t_sysv.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/contrib/netbsd-tests/kernel/t_sysv.c
==
--- stable/12/contrib/netbsd-tests/kernel/t_sysv.c  Wed Jan 23 20:02:17 
2019(r343354)
+++ stable/12/contrib/netbsd-tests/kernel/t_sysv.c  Wed Jan 23 20:31:24 
2019(r343355)
@@ -840,9 +840,9 @@ sharer(void)
 ATF_TP_ADD_TCS(tp)
 {
 
-   ATF_TP_ADD_TC(tp, msg); 
-   ATF_TP_ADD_TC(tp, sem); 
-   ATF_TP_ADD_TC(tp, shm); 
+   ATF_TP_ADD_TC(tp, msg);
+   ATF_TP_ADD_TC(tp, sem);
+   ATF_TP_ADD_TC(tp, shm);
 
return atf_no_error();
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r343354 - head/usr.bin/write

2019-01-23 Thread Mark Johnston
Author: markj
Date: Wed Jan 23 20:02:17 2019
New Revision: 343354
URL: https://svnweb.freebsd.org/changeset/base/343354

Log:
  Remove extraneous setutxent() calls in write(1).
  
  We already call setutxent() once during initialization.  Furthermore,
  the subsequent calls occur after the process has entered capability
  mode, so they fail, and attempts to fetch database entries fail as
  a result.
  
  PR:   235096
  Submitted by: fulle...@over-yonder.net
  MFC after:3 days

Modified:
  head/usr.bin/write/write.c

Modified: head/usr.bin/write/write.c
==
--- head/usr.bin/write/write.c  Wed Jan 23 18:58:15 2019(r343353)
+++ head/usr.bin/write/write.c  Wed Jan 23 20:02:17 2019(r343354)
@@ -204,7 +204,6 @@ utmp_chk(char *user, char *tty)
struct utmpx lu, *u;
 
strncpy(lu.ut_line, tty, sizeof lu.ut_line);
-   setutxent();
while ((u = getutxline()) != NULL)
if (u->ut_type == USER_PROCESS &&
strcmp(user, u->ut_user) == 0) {
@@ -237,7 +236,6 @@ search_utmp(int devfd, char *user, char *tty, char *my
bestatime = 0;
user_is_me = 0;
 
-   setutxent();
while ((u = getutxent()) != NULL)
if (u->ut_type == USER_PROCESS &&
strcmp(user, u->ut_user) == 0) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r343353 - head/sys/vm

2019-01-23 Thread Mark Johnston
Author: markj
Date: Wed Jan 23 18:58:15 2019
New Revision: 343353
URL: https://svnweb.freebsd.org/changeset/base/343353

Log:
  Correct uma_prealloc()'s use of domainset iterators after r339925.
  
  The iterator should be reinitialized after every successful slab
  allocation.  A request to advance the iterator is interpreted as
  an allocation failure, so a sufficiently large preallocation would
  cause the iterator to believe that all domains were exhausted,
  resulting in a sleep with the keg lock held. [1]
  
  Also, keg_alloc_slab() should pass the unmodified wait flag to the
  item initialization routine, which may use it to perform allocations
  from other zones.
  
  Reported and tested by:   slavah
  Diagnosed by: kib [1]
  Reviewed by:  kib
  MFC after:1 week
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/vm/uma_core.c

Modified: head/sys/vm/uma_core.c
==
--- head/sys/vm/uma_core.c  Wed Jan 23 18:53:13 2019(r343352)
+++ head/sys/vm/uma_core.c  Wed Jan 23 18:58:15 2019(r343353)
@@ -241,7 +241,7 @@ static void *pcpu_page_alloc(uma_zone_t, vm_size_t, in
 static void *startup_alloc(uma_zone_t, vm_size_t, int, uint8_t *, int);
 static void page_free(void *, vm_size_t, uint8_t);
 static void pcpu_page_free(void *, vm_size_t, uint8_t);
-static uma_slab_t keg_alloc_slab(uma_keg_t, uma_zone_t, int, int);
+static uma_slab_t keg_alloc_slab(uma_keg_t, uma_zone_t, int, int, int);
 static void cache_drain(uma_zone_t);
 static void bucket_drain(uma_zone_t, uma_bucket_t);
 static void bucket_cache_drain(uma_zone_t zone);
@@ -1049,20 +1049,22 @@ zone_drain(uma_zone_t zone)
  * otherwise the keg will be left unlocked.
  *
  * Arguments:
- * wait  Shall we wait?
+ * flags   Wait flags for the item initialization routine
+ * aflags  Wait flags for the slab allocation
  *
  * Returns:
  * The slab that was allocated or NULL if there is no memory and the
  * caller specified M_NOWAIT.
  */
 static uma_slab_t
-keg_alloc_slab(uma_keg_t keg, uma_zone_t zone, int domain, int wait)
+keg_alloc_slab(uma_keg_t keg, uma_zone_t zone, int domain, int flags,
+int aflags)
 {
uma_alloc allocf;
uma_slab_t slab;
unsigned long size;
uint8_t *mem;
-   uint8_t flags;
+   uint8_t sflags;
int i;
 
KASSERT(domain >= 0 && domain < vm_ndomains,
@@ -1076,7 +1078,7 @@ keg_alloc_slab(uma_keg_t keg, uma_zone_t zone, int dom
slab = NULL;
mem = NULL;
if (keg->uk_flags & UMA_ZONE_OFFPAGE) {
-   slab = zone_alloc_item(keg->uk_slabzone, NULL, domain, wait);
+   slab = zone_alloc_item(keg->uk_slabzone, NULL, domain, aflags);
if (slab == NULL)
goto out;
}
@@ -1089,16 +1091,16 @@ keg_alloc_slab(uma_keg_t keg, uma_zone_t zone, int dom
 */
 
if ((keg->uk_flags & UMA_ZONE_MALLOC) == 0)
-   wait |= M_ZERO;
+   aflags |= M_ZERO;
else
-   wait &= ~M_ZERO;
+   aflags &= ~M_ZERO;
 
if (keg->uk_flags & UMA_ZONE_NODUMP)
-   wait |= M_NODUMP;
+   aflags |= M_NODUMP;
 
/* zone is passed for legacy reasons. */
size = keg->uk_ppera * PAGE_SIZE;
-   mem = allocf(zone, size, domain, , wait);
+   mem = allocf(zone, size, domain, , aflags);
if (mem == NULL) {
if (keg->uk_flags & UMA_ZONE_OFFPAGE)
zone_free_item(keg->uk_slabzone, slab, NULL, SKIP_NONE);
@@ -1118,7 +1120,7 @@ keg_alloc_slab(uma_keg_t keg, uma_zone_t zone, int dom
slab->us_keg = keg;
slab->us_data = mem;
slab->us_freecount = keg->uk_ipers;
-   slab->us_flags = flags;
+   slab->us_flags = sflags;
slab->us_domain = domain;
BIT_FILL(SLAB_SETSIZE, >us_free);
 #ifdef INVARIANTS
@@ -1128,7 +1130,7 @@ keg_alloc_slab(uma_keg_t keg, uma_zone_t zone, int dom
if (keg->uk_init != NULL) {
for (i = 0; i < keg->uk_ipers; i++)
if (keg->uk_init(slab->us_data + (keg->uk_rsize * i),
-   keg->uk_size, wait) != 0)
+   keg->uk_size, flags) != 0)
break;
if (i != keg->uk_ipers) {
keg_free_slab(keg, slab, i);
@@ -2698,7 +2700,7 @@ restart:
zone->uz_items <= zone->uz_max_items,
("%s: zone %p overflow", __func__, zone));
 
-   slab = keg_alloc_slab(keg, zone, domain, aflags);
+   slab = keg_alloc_slab(keg, zone, domain, flags, aflags);
/*
 * If we got a slab here it's safe to mark it partially used
 * and return.  We assume that the caller is going to remove
@@ -3548,24 +3550,34 @@ uma_prealloc(uma_zone_t zone, int items)
uma_domain_t 

Re: svn commit: r343349 - head/sys/dev/ocs_fc

2019-01-23 Thread Rodney W. Grimes
> Author: ram
> Date: Wed Jan 23 17:34:01 2019
> New Revision: 343349
> URL: https://svnweb.freebsd.org/changeset/base/343349
> 
> Log:
>   Fixed issues reported by coverity scan.

The quality of this commit message is rather low,
it should of at least included some details about
what was wrong, why it was wrong, and how it was
fixed.

Thanks,
Rod
>   
>   Approved by: mav
>   MFC after: 3 weeks
> 
> Modified:
>   head/sys/dev/ocs_fc/ocs_cam.c
>   head/sys/dev/ocs_fc/ocs_hw.c
>   head/sys/dev/ocs_fc/ocs_hw_queues.c
>   head/sys/dev/ocs_fc/ocs_ioctl.c
>   head/sys/dev/ocs_fc/ocs_mgmt.c
>   head/sys/dev/ocs_fc/ocs_node.c
>   head/sys/dev/ocs_fc/ocs_pci.c
>   head/sys/dev/ocs_fc/ocs_xport.c
>   head/sys/dev/ocs_fc/sli4.c
> 
> Modified: head/sys/dev/ocs_fc/ocs_cam.c
> ==
> --- head/sys/dev/ocs_fc/ocs_cam.c Wed Jan 23 17:28:39 2019
> (r343348)
> +++ head/sys/dev/ocs_fc/ocs_cam.c Wed Jan 23 17:34:01 2019
> (r343349)
> @@ -1164,15 +1164,24 @@ ocs_scsi_del_target(ocs_node_t *node, ocs_scsi_del_tar
>   struct ocs_softc *ocs = node->ocs;
>   ocs_fcport  *fcp = NULL;
>   ocs_fc_target_t *tgt = NULL;
> - uint32_ttgt_id;
> + int32_t tgt_id;
>  
> + if (ocs == NULL) {
> + ocs_log_err(ocs,"OCS is NULL \n");
> + return -1;
> + }
> +
>   fcp = node->sport->tgt_data;
>   if (fcp == NULL) {
>   ocs_log_err(ocs,"FCP is NULL \n");
> - return 0;
> + return -1;
>   }
>  
>   tgt_id = ocs_tgt_find(fcp, node);
> + if (tgt_id == -1) {
> + ocs_log_err(ocs,"target is invalid\n");
> + return -1;
> + }
>  
>   tgt = >tgt[tgt_id];
>  
> @@ -1781,13 +1790,9 @@ ocs_initiator_io(struct ocs_softc *ocs, union ccb *ccb
>   ocs_io_t *io = NULL;
>   ocs_scsi_sgl_t sgl[OCS_FC_MAX_SGL];
>   int32_t sgl_count;
> + ocs_fcport  *fcp;
>  
> - ocs_fcport  *fcp = NULL;
>   fcp = FCPORT(ocs, cam_sim_bus(xpt_path_sim((ccb)->ccb_h.path)));
> - if (fcp == NULL) {
> - device_printf(ocs->dev, "%s: fcp is NULL\n", __func__);
> - return -1;
> - }
>  
>   if (fcp->tgt[ccb_h->target_id].state == OCS_TGT_STATE_LOST) {
>   device_printf(ocs->dev, "%s: device LOST %d\n", __func__,
> @@ -2250,8 +2255,11 @@ ocs_action(struct cam_sim *sim, union ccb *ccb)
>   }
>   case XPT_RESET_BUS:
>   if (ocs_xport_control(ocs->xport, OCS_XPORT_PORT_OFFLINE) == 0) 
> {
> - ocs_xport_control(ocs->xport, OCS_XPORT_PORT_ONLINE);
> -
> + rc = ocs_xport_control(ocs->xport, 
> OCS_XPORT_PORT_ONLINE);
> + if (rc) {
> + ocs_log_debug(ocs, "Failed to bring port online"
> + " : %d\n", rc);
> + }
>   ocs_set_ccb_status(ccb, CAM_REQ_CMP);
>   } else {
>   ocs_set_ccb_status(ccb, CAM_REQ_CMP_ERR);
> 
> Modified: head/sys/dev/ocs_fc/ocs_hw.c
> ==
> --- head/sys/dev/ocs_fc/ocs_hw.c  Wed Jan 23 17:28:39 2019
> (r343348)
> +++ head/sys/dev/ocs_fc/ocs_hw.c  Wed Jan 23 17:34:01 2019
> (r343349)
> @@ -242,10 +242,7 @@ ocs_hw_get_num_chutes(ocs_hw_t *hw)
>  static ocs_hw_rtn_e
>  ocs_hw_link_event_init(ocs_hw_t *hw)
>  {
> - if (hw == NULL) {
> - ocs_log_err(hw->os, "bad parameter hw=%p\n", hw);
> - return OCS_HW_RTN_ERROR;
> - }
> + ocs_hw_assert(hw);
>  
>   hw->link.status = SLI_LINK_STATUS_MAX;
>   hw->link.topology = SLI_LINK_TOPO_NONE;
> @@ -1757,6 +1754,7 @@ ocs_hw_get(ocs_hw_t *hw, ocs_hw_property_e prop, uint3
>   break;
>   case OCS_HW_MAX_VPORTS:
>   *value = sli_get_max_rsrc(>sli, SLI_RSRC_FCOE_VPI);
> + break;
>   default:
>   ocs_log_test(hw->os, "unsupported property %#x\n", prop);
>   rc = OCS_HW_RTN_ERROR;
> @@ -1996,6 +1994,7 @@ ocs_hw_set(ocs_hw_t *hw, ocs_hw_property_e prop, uint3
>   break;
>   case OCS_ESOC:
>   hw->config.esoc = value;
> + break;
>   case OCS_HW_HIGH_LOGIN_MODE:
>   rc = sli_set_hlm(>sli, value);
>   break;
> @@ -4395,7 +4394,7 @@ ocs_hw_send_frame(ocs_hw_t *hw, fc_header_le_t *hdr, u
>  
>   OCS_STAT(wq->use_count++);
>  
> - return rc ? OCS_HW_RTN_ERROR : OCS_HW_RTN_SUCCESS;
> + return OCS_HW_RTN_SUCCESS;
>  }
>  
>  ocs_hw_rtn_e
> @@ -4696,7 +4695,7 @@ ocs_hw_io_overflow_sgl(ocs_hw_t *hw, ocs_hw_io_t *io)
>   }
>  
>   /* fail if we don't have an overflow SGL registered */
> - if (io->ovfl_sgl == NULL) {
> + if (io->ovfl_io == NULL || io->ovfl_sgl == NULL) {
>   return 

svn commit: r343352 - in head/sys/dev/usb: . quirk

2019-01-23 Thread Hans Petter Selasky
Author: hselasky
Date: Wed Jan 23 18:53:13 2019
New Revision: 343352
URL: https://svnweb.freebsd.org/changeset/base/343352

Log:
  Add USB quirk.
  
  Submitted by: Gary Jennejohn 
  MFC after:1 week
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/dev/usb/quirk/usb_quirk.c
  head/sys/dev/usb/usbdevs

Modified: head/sys/dev/usb/quirk/usb_quirk.c
==
--- head/sys/dev/usb/quirk/usb_quirk.c  Wed Jan 23 17:40:12 2019
(r343351)
+++ head/sys/dev/usb/quirk/usb_quirk.c  Wed Jan 23 18:53:13 2019
(r343352)
@@ -278,6 +278,7 @@ static struct usb_quirk_entry usb_quirks[USB_DEV_QUIRK
USB_QUIRK(IOMEGA, ZIP100, 0x, 0x, UQ_MSC_FORCE_WIRE_BBB,
UQ_MSC_FORCE_PROTO_SCSI,
UQ_MSC_NO_TEST_UNIT_READY), /* XXX ZIP drives can also use ATAPI */
+   USB_QUIRK(JMICRON, JMS566, 0x, 0x, UQ_MSC_NO_GETMAXLUN),
USB_QUIRK(JMICRON, JMS567, 0x, 0x, UQ_MSC_NO_GETMAXLUN),
USB_QUIRK(JMICRON, JM20337, 0x, 0x, UQ_MSC_FORCE_WIRE_BBB,
UQ_MSC_FORCE_PROTO_SCSI,

Modified: head/sys/dev/usb/usbdevs
==
--- head/sys/dev/usb/usbdevsWed Jan 23 17:40:12 2019(r343351)
+++ head/sys/dev/usb/usbdevsWed Jan 23 18:53:13 2019(r343352)
@@ -2646,6 +2646,7 @@ product JATON EDA 0x5704  Ethernet
 product JETI SPC1201   0x04b2  FTDI compatible adapter
 
 /* JMicron products */
+product JMICRON JMS566 0x3569  USB to SATA 3.0Gb/s bridge 
 product JMICRON JMS567 0x0567  USB to SATA 6.0Gb/s bridge 
 product JMICRON JM203360x2336  USB to SATA Bridge
 product JMICRON JM203370x2338  USB to ATA/ATAPI Bridge
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r343351 - in stable: 11/sys/fs/nfsserver 12/sys/fs/nfsserver

2019-01-23 Thread Mark Johnston
Author: markj
Date: Wed Jan 23 17:40:12 2019
New Revision: 343351
URL: https://svnweb.freebsd.org/changeset/base/343351

Log:
  MFC r343286:
  nfs: Zero the buffers exported by NFSSVC_DUMPCLIENTS and DUMPLOCKS.
  
  admbugs:  765

Modified:
  stable/12/sys/fs/nfsserver/nfs_nfsdport.c
Directory Properties:
  stable/12/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/11/sys/fs/nfsserver/nfs_nfsdport.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/12/sys/fs/nfsserver/nfs_nfsdport.c
==
--- stable/12/sys/fs/nfsserver/nfs_nfsdport.c   Wed Jan 23 17:36:58 2019
(r343350)
+++ stable/12/sys/fs/nfsserver/nfs_nfsdport.c   Wed Jan 23 17:40:12 2019
(r343351)
@@ -3615,8 +3615,7 @@ nfssvc_srvcall(struct thread *p, struct nfssvc_args *u
error = EPERM;
if (!error) {
len = sizeof (struct nfsd_dumpclients) * dumplist.ndl_size;
-   dumpclients = (struct nfsd_dumpclients *)malloc(len,
-   M_TEMP, M_WAITOK);
+   dumpclients = malloc(len, M_TEMP, M_WAITOK | M_ZERO);
nfsrv_dumpclients(dumpclients, dumplist.ndl_size);
error = copyout(dumpclients,
CAST_USER_ADDR_T(dumplist.ndl_list), len);
@@ -3634,8 +3633,7 @@ nfssvc_srvcall(struct thread *p, struct nfssvc_args *u
if (!error) {
len = sizeof (struct nfsd_dumplocks) *
dumplocklist.ndllck_size;
-   dumplocks = (struct nfsd_dumplocks *)malloc(len,
-   M_TEMP, M_WAITOK);
+   dumplocks = malloc(len, M_TEMP, M_WAITOK | M_ZERO);
nfsrv_dumplocks(nd.ni_vp, dumplocks,
dumplocklist.ndllck_size, p);
vput(nd.ni_vp);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r343351 - in stable: 11/sys/fs/nfsserver 12/sys/fs/nfsserver

2019-01-23 Thread Mark Johnston
Author: markj
Date: Wed Jan 23 17:40:12 2019
New Revision: 343351
URL: https://svnweb.freebsd.org/changeset/base/343351

Log:
  MFC r343286:
  nfs: Zero the buffers exported by NFSSVC_DUMPCLIENTS and DUMPLOCKS.
  
  admbugs:  765

Modified:
  stable/11/sys/fs/nfsserver/nfs_nfsdport.c
Directory Properties:
  stable/11/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/12/sys/fs/nfsserver/nfs_nfsdport.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/11/sys/fs/nfsserver/nfs_nfsdport.c
==
--- stable/11/sys/fs/nfsserver/nfs_nfsdport.c   Wed Jan 23 17:36:58 2019
(r343350)
+++ stable/11/sys/fs/nfsserver/nfs_nfsdport.c   Wed Jan 23 17:40:12 2019
(r343351)
@@ -3192,8 +3192,7 @@ nfssvc_srvcall(struct thread *p, struct nfssvc_args *u
error = EPERM;
if (!error) {
len = sizeof (struct nfsd_dumpclients) * dumplist.ndl_size;
-   dumpclients = (struct nfsd_dumpclients *)malloc(len,
-   M_TEMP, M_WAITOK);
+   dumpclients = malloc(len, M_TEMP, M_WAITOK | M_ZERO);
nfsrv_dumpclients(dumpclients, dumplist.ndl_size);
error = copyout(dumpclients,
CAST_USER_ADDR_T(dumplist.ndl_list), len);
@@ -3211,8 +3210,7 @@ nfssvc_srvcall(struct thread *p, struct nfssvc_args *u
if (!error) {
len = sizeof (struct nfsd_dumplocks) *
dumplocklist.ndllck_size;
-   dumplocks = (struct nfsd_dumplocks *)malloc(len,
-   M_TEMP, M_WAITOK);
+   dumplocks = malloc(len, M_TEMP, M_WAITOK | M_ZERO);
nfsrv_dumplocks(nd.ni_vp, dumplocks,
dumplocklist.ndllck_size, p);
vput(nd.ni_vp);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r343350 - in stable: 11/sys/dev/hwpmc 12/sys/dev/hwpmc

2019-01-23 Thread Mark Johnston
Author: markj
Date: Wed Jan 23 17:36:58 2019
New Revision: 343350
URL: https://svnweb.freebsd.org/changeset/base/343350

Log:
  MFC r343265:
  hwpmc: Plug memory disclosures from PMC_OP_{GETPMCINFO,GETCPUINFO}.
  
  admbugs:  765

Modified:
  stable/11/sys/dev/hwpmc/hwpmc_mod.c
Directory Properties:
  stable/11/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/12/sys/dev/hwpmc/hwpmc_mod.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/11/sys/dev/hwpmc/hwpmc_mod.c
==
--- stable/11/sys/dev/hwpmc/hwpmc_mod.c Wed Jan 23 17:34:01 2019
(r343349)
+++ stable/11/sys/dev/hwpmc/hwpmc_mod.c Wed Jan 23 17:36:58 2019
(r343350)
@@ -2990,6 +2990,7 @@ pmc_syscall_handler(struct thread *td, void *syscall_a
struct pmc_classdep *pcd;
int cl;
 
+   memset(, 0, sizeof(gci));
gci.pm_cputype = md->pmd_cputype;
gci.pm_ncpu= pmc_cpu_max();
gci.pm_npmc= md->pmd_npmc;
@@ -3131,7 +3132,7 @@ pmc_syscall_handler(struct thread *td, void *syscall_a
npmc = md->pmd_npmc;
 
pmcinfo_size = npmc * sizeof(struct pmc_info);
-   pmcinfo = malloc(pmcinfo_size, M_PMC, M_WAITOK);
+   pmcinfo = malloc(pmcinfo_size, M_PMC, M_WAITOK | M_ZERO);
 
p = pmcinfo;
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r343350 - in stable: 11/sys/dev/hwpmc 12/sys/dev/hwpmc

2019-01-23 Thread Mark Johnston
Author: markj
Date: Wed Jan 23 17:36:58 2019
New Revision: 343350
URL: https://svnweb.freebsd.org/changeset/base/343350

Log:
  MFC r343265:
  hwpmc: Plug memory disclosures from PMC_OP_{GETPMCINFO,GETCPUINFO}.
  
  admbugs:  765

Modified:
  stable/12/sys/dev/hwpmc/hwpmc_mod.c
Directory Properties:
  stable/12/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/11/sys/dev/hwpmc/hwpmc_mod.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/12/sys/dev/hwpmc/hwpmc_mod.c
==
--- stable/12/sys/dev/hwpmc/hwpmc_mod.c Wed Jan 23 17:34:01 2019
(r343349)
+++ stable/12/sys/dev/hwpmc/hwpmc_mod.c Wed Jan 23 17:36:58 2019
(r343350)
@@ -3512,6 +3512,7 @@ pmc_syscall_handler(struct thread *td, void *syscall_a
struct pmc_classdep *pcd;
int cl;
 
+   memset(, 0, sizeof(gci));
gci.pm_cputype = md->pmd_cputype;
gci.pm_ncpu= pmc_cpu_max();
gci.pm_npmc= md->pmd_npmc;
@@ -3661,7 +3662,7 @@ pmc_syscall_handler(struct thread *td, void *syscall_a
npmc = md->pmd_npmc;
 
pmcinfo_size = npmc * sizeof(struct pmc_info);
-   pmcinfo = malloc(pmcinfo_size, M_PMC, M_WAITOK);
+   pmcinfo = malloc(pmcinfo_size, M_PMC, M_WAITOK | M_ZERO);
 
p = pmcinfo;
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r343349 - head/sys/dev/ocs_fc

2019-01-23 Thread Ram Kishore Vegesna
Author: ram
Date: Wed Jan 23 17:34:01 2019
New Revision: 343349
URL: https://svnweb.freebsd.org/changeset/base/343349

Log:
  Fixed issues reported by coverity scan.
  
  Approved by: mav
  MFC after: 3 weeks

Modified:
  head/sys/dev/ocs_fc/ocs_cam.c
  head/sys/dev/ocs_fc/ocs_hw.c
  head/sys/dev/ocs_fc/ocs_hw_queues.c
  head/sys/dev/ocs_fc/ocs_ioctl.c
  head/sys/dev/ocs_fc/ocs_mgmt.c
  head/sys/dev/ocs_fc/ocs_node.c
  head/sys/dev/ocs_fc/ocs_pci.c
  head/sys/dev/ocs_fc/ocs_xport.c
  head/sys/dev/ocs_fc/sli4.c

Modified: head/sys/dev/ocs_fc/ocs_cam.c
==
--- head/sys/dev/ocs_fc/ocs_cam.c   Wed Jan 23 17:28:39 2019
(r343348)
+++ head/sys/dev/ocs_fc/ocs_cam.c   Wed Jan 23 17:34:01 2019
(r343349)
@@ -1164,15 +1164,24 @@ ocs_scsi_del_target(ocs_node_t *node, ocs_scsi_del_tar
struct ocs_softc *ocs = node->ocs;
ocs_fcport  *fcp = NULL;
ocs_fc_target_t *tgt = NULL;
-   uint32_ttgt_id;
+   int32_t tgt_id;
 
+   if (ocs == NULL) {
+   ocs_log_err(ocs,"OCS is NULL \n");
+   return -1;
+   }
+
fcp = node->sport->tgt_data;
if (fcp == NULL) {
ocs_log_err(ocs,"FCP is NULL \n");
-   return 0;
+   return -1;
}
 
tgt_id = ocs_tgt_find(fcp, node);
+   if (tgt_id == -1) {
+   ocs_log_err(ocs,"target is invalid\n");
+   return -1;
+   }
 
tgt = >tgt[tgt_id];
 
@@ -1781,13 +1790,9 @@ ocs_initiator_io(struct ocs_softc *ocs, union ccb *ccb
ocs_io_t *io = NULL;
ocs_scsi_sgl_t sgl[OCS_FC_MAX_SGL];
int32_t sgl_count;
+   ocs_fcport  *fcp;
 
-   ocs_fcport  *fcp = NULL;
fcp = FCPORT(ocs, cam_sim_bus(xpt_path_sim((ccb)->ccb_h.path)));
-   if (fcp == NULL) {
-   device_printf(ocs->dev, "%s: fcp is NULL\n", __func__);
-   return -1;
-   }
 
if (fcp->tgt[ccb_h->target_id].state == OCS_TGT_STATE_LOST) {
device_printf(ocs->dev, "%s: device LOST %d\n", __func__,
@@ -2250,8 +2255,11 @@ ocs_action(struct cam_sim *sim, union ccb *ccb)
}
case XPT_RESET_BUS:
if (ocs_xport_control(ocs->xport, OCS_XPORT_PORT_OFFLINE) == 0) 
{
-   ocs_xport_control(ocs->xport, OCS_XPORT_PORT_ONLINE);
-
+   rc = ocs_xport_control(ocs->xport, 
OCS_XPORT_PORT_ONLINE);
+   if (rc) {
+   ocs_log_debug(ocs, "Failed to bring port online"
+   " : %d\n", rc);
+   }
ocs_set_ccb_status(ccb, CAM_REQ_CMP);
} else {
ocs_set_ccb_status(ccb, CAM_REQ_CMP_ERR);

Modified: head/sys/dev/ocs_fc/ocs_hw.c
==
--- head/sys/dev/ocs_fc/ocs_hw.cWed Jan 23 17:28:39 2019
(r343348)
+++ head/sys/dev/ocs_fc/ocs_hw.cWed Jan 23 17:34:01 2019
(r343349)
@@ -242,10 +242,7 @@ ocs_hw_get_num_chutes(ocs_hw_t *hw)
 static ocs_hw_rtn_e
 ocs_hw_link_event_init(ocs_hw_t *hw)
 {
-   if (hw == NULL) {
-   ocs_log_err(hw->os, "bad parameter hw=%p\n", hw);
-   return OCS_HW_RTN_ERROR;
-   }
+   ocs_hw_assert(hw);
 
hw->link.status = SLI_LINK_STATUS_MAX;
hw->link.topology = SLI_LINK_TOPO_NONE;
@@ -1757,6 +1754,7 @@ ocs_hw_get(ocs_hw_t *hw, ocs_hw_property_e prop, uint3
break;
case OCS_HW_MAX_VPORTS:
*value = sli_get_max_rsrc(>sli, SLI_RSRC_FCOE_VPI);
+   break;
default:
ocs_log_test(hw->os, "unsupported property %#x\n", prop);
rc = OCS_HW_RTN_ERROR;
@@ -1996,6 +1994,7 @@ ocs_hw_set(ocs_hw_t *hw, ocs_hw_property_e prop, uint3
break;
case OCS_ESOC:
hw->config.esoc = value;
+   break;
case OCS_HW_HIGH_LOGIN_MODE:
rc = sli_set_hlm(>sli, value);
break;
@@ -4395,7 +4394,7 @@ ocs_hw_send_frame(ocs_hw_t *hw, fc_header_le_t *hdr, u
 
OCS_STAT(wq->use_count++);
 
-   return rc ? OCS_HW_RTN_ERROR : OCS_HW_RTN_SUCCESS;
+   return OCS_HW_RTN_SUCCESS;
 }
 
 ocs_hw_rtn_e
@@ -4696,7 +4695,7 @@ ocs_hw_io_overflow_sgl(ocs_hw_t *hw, ocs_hw_io_t *io)
}
 
/* fail if we don't have an overflow SGL registered */
-   if (io->ovfl_sgl == NULL) {
+   if (io->ovfl_io == NULL || io->ovfl_sgl == NULL) {
return OCS_HW_RTN_ERROR;
}
 
@@ -6321,6 +6320,11 @@ ocs_hw_config_watchdog_timer(ocs_hw_t *hw)
ocs_hw_rtn_e rc = OCS_HW_RTN_SUCCESS;
uint8_t *buf = ocs_malloc(hw->os, SLI4_BMBX_SIZE, OCS_M_NOWAIT);
 
+   if (!buf) {
+   ocs_log_err(hw->os, "no buffer for command\n");
+ 

svn commit: r343348 - head/sys/dev/ocs_fc

2019-01-23 Thread Mark Johnston
Author: markj
Date: Wed Jan 23 17:28:39 2019
New Revision: 343348
URL: https://svnweb.freebsd.org/changeset/base/343348

Log:
  ocs_fc: Ensure that we zero-initialize memory before copying it out.
  
  Note that the affected interface is available only to root.
  
  admbugs:  765
  Reported by:  Vlad Tsyrklevich 
  Reviewed by:  emaste, ram
  MFC after:1 day
  Security: Kernel memory disclosure
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D18914

Modified:
  head/sys/dev/ocs_fc/ocs_mgmt.c

Modified: head/sys/dev/ocs_fc/ocs_mgmt.c
==
--- head/sys/dev/ocs_fc/ocs_mgmt.c  Wed Jan 23 16:44:21 2019
(r343347)
+++ head/sys/dev/ocs_fc/ocs_mgmt.c  Wed Jan 23 17:28:39 2019
(r343348)
@@ -851,6 +851,7 @@ ocs_mgmt_firmware_write(ocs_t *ocs, char *name, void *
if (arg_out_length > sizeof(status_str)) {
arg_out_length = sizeof(status_str);
}
+   ocs_memset(status_str, 0, sizeof(status_str));
ocs_snprintf(status_str, arg_out_length, "%d", change_status);
if (ocs_copy_to_user(arg_out, status_str, arg_out_length)) {
ocs_log_test(ocs, "copy to user failed for 
change_status\n");
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r343347 - head/sys/geom/mirror

2019-01-23 Thread Conrad Meyer
Author: cem
Date: Wed Jan 23 16:44:21 2019
New Revision: 343347
URL: https://svnweb.freebsd.org/changeset/base/343347

Log:
  gmirror: Relocate DEVICE_FLAGS to adjacent lines
  
  gmirror's sc_flags is shared between some on-disk state and some runtime
  only state.  There's no real reason for that and they could probably be
  split up.  Until they are, locate all of the flags for the same field
  nearby each other in the source, for clarity.
  
  No functional change.
  
  Sponsored by: Dell EMC Isilon

Modified:
  head/sys/geom/mirror/g_mirror.h

Modified: head/sys/geom/mirror/g_mirror.h
==
--- head/sys/geom/mirror/g_mirror.h Wed Jan 23 14:51:36 2019
(r343346)
+++ head/sys/geom/mirror/g_mirror.h Wed Jan 23 16:44:21 2019
(r343347)
@@ -78,6 +78,12 @@
 G_MIRROR_DEVICE_FLAG_NOFAILSYNC)
 
 #ifdef _KERNEL
+#defineG_MIRROR_DEVICE_FLAG_DESTROY0x0100ULL
+#defineG_MIRROR_DEVICE_FLAG_DRAIN  0x0200ULL
+#defineG_MIRROR_DEVICE_FLAG_CLOSEWAIT  0x0400ULL
+#defineG_MIRROR_DEVICE_FLAG_TASTING0x0800ULL
+#defineG_MIRROR_DEVICE_FLAG_WIPE   0x1000ULL
+
 extern int g_mirror_debug;
 
 #defineG_MIRROR_DEBUG(lvl, ...)do {
\
@@ -166,12 +172,6 @@ struct g_mirror_event {
int  e_error;
TAILQ_ENTRY(g_mirror_event) e_next;
 };
-
-#defineG_MIRROR_DEVICE_FLAG_DESTROY0x0100ULL
-#defineG_MIRROR_DEVICE_FLAG_DRAIN  0x0200ULL
-#defineG_MIRROR_DEVICE_FLAG_CLOSEWAIT  0x0400ULL
-#defineG_MIRROR_DEVICE_FLAG_TASTING0x0800ULL
-#defineG_MIRROR_DEVICE_FLAG_WIPE   0x1000ULL
 
 #defineG_MIRROR_DEVICE_STATE_STARTING  0
 #defineG_MIRROR_DEVICE_STATE_RUNNING   1
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r343346 - in head/sys: dev/netmap net

2019-01-23 Thread Vincenzo Maffione
Author: vmaffione
Date: Wed Jan 23 14:51:36 2019
New Revision: 343346
URL: https://svnweb.freebsd.org/changeset/base/343346

Log:
  netmap: improvements to the netmap kloop (CSB mode)
  
  Changelist:
  - Add the proper memory barriers in the kloop ring processing
functions.
  - Fix memory barriers usage in the user helpers (nm_sync_kloop_appl_write,
nm_sync_kloop_appl_read).
  - Fix nm_kr_txempty() helper to look at rhead rather than rcur. This
is important since the kloop can read a value of rcur which is ahead
of the value of rhead (see explanation in nm_sync_kloop_appl_write)
  - Remove obsolete ptnetmap_guest_write_kring_csb() and
ptnet_guest_read_kring_csb(), and update if_ptnet(4) to use those.
  - Prepare in advance the arguments for netmap_sync_kloop_[tr]x_ring(),
to make the kloop faster.
  - Provide kernel and user implementation for nm_ldld_barrier() and
nm_ldst_barrier()
  
  MFC after:2 weeks

Modified:
  head/sys/dev/netmap/if_ptnet.c
  head/sys/dev/netmap/netmap_kern.h
  head/sys/dev/netmap/netmap_kloop.c
  head/sys/net/netmap.h

Modified: head/sys/dev/netmap/if_ptnet.c
==
--- head/sys/dev/netmap/if_ptnet.c  Wed Jan 23 14:22:21 2019
(r343345)
+++ head/sys/dev/netmap/if_ptnet.c  Wed Jan 23 14:51:36 2019
(r343346)
@@ -1688,7 +1688,7 @@ ptnet_ring_update(struct ptnet_queue *pq, struct netma
/* Mimic nm_txsync_prologue/nm_rxsync_prologue. */
kring->rcur = kring->rhead = head;
 
-   ptnetmap_guest_write_kring_csb(atok, kring->rcur, kring->rhead);
+   nm_sync_kloop_appl_write(atok, kring->rcur, kring->rhead);
 
/* Kick the host if needed. */
if (NM_ACCESS_ONCE(ktoa->kern_need_kick)) {
@@ -1764,7 +1764,12 @@ ptnet_drain_transmit_queue(struct ptnet_queue *pq, uns
 * the host. */
atok->appl_need_kick = 1;
 
-   /* Double-check. */
+   /* Double check. We need a full barrier to
+* prevent the store to atok->appl_need_kick
+* to be reordered with the load from
+* ktoa->hwcur and ktoa->hwtail (store-load
+* barrier). */
+   nm_stld_barrier();
ptnet_sync_tail(ktoa, kring);
if (likely(PTNET_TX_NOSPACE(head, kring,
minspace))) {
@@ -2046,7 +2051,12 @@ host_sync:
 * last interrupt. */
atok->appl_need_kick = 1;
 
-   /* Double-check. */
+   /* Double check for more completed RX slots.
+* We need a full barrier to prevent the store
+* to atok->appl_need_kick to be reordered with
+* the load from ktoa->hwcur and ktoa->hwtail
+* (store-load barrier). */
+   nm_stld_barrier();
ptnet_sync_tail(ktoa, kring);
if (likely(head == ring->tail)) {
break;

Modified: head/sys/dev/netmap/netmap_kern.h
==
--- head/sys/dev/netmap/netmap_kern.h   Wed Jan 23 14:22:21 2019
(r343345)
+++ head/sys/dev/netmap/netmap_kern.h   Wed Jan 23 14:51:36 2019
(r343346)
@@ -1159,7 +1159,7 @@ nm_kr_rxspace(struct netmap_kring *k)
 static inline int
 nm_kr_txempty(struct netmap_kring *kring)
 {
-   return kring->rcur == kring->nr_hwtail;
+   return kring->rhead == kring->nr_hwtail;
 }
 
 /* True if no more completed slots in the rx ring, only valid after
@@ -2245,61 +2245,14 @@ int ptnet_nm_krings_create(struct netmap_adapter *na);
 void ptnet_nm_krings_delete(struct netmap_adapter *na);
 void ptnet_nm_dtor(struct netmap_adapter *na);
 
-/* Guest driver: Write kring pointers (cur, head) to the CSB.
- * This routine is coupled with ptnetmap_host_read_kring_csb(). */
+/* Helper function wrapping nm_sync_kloop_appl_read(). */
 static inline void
-ptnetmap_guest_write_kring_csb(struct nm_csb_atok *atok, uint32_t cur,
-  uint32_t head)
-{
-/*
- * We need to write cur and head to the CSB but we cannot do it atomically.
- * There is no way we can prevent the host from reading the updated value
- * of one of the two and the old value of the other. However, if we make
- * sure that the host never reads a value of head more recent than the
- * value of cur we are safe. We can allow the host to read a value of cur
-

svn commit: r343345 - in stable/11/sys: amd64/linux compat/linux

2019-01-23 Thread Ed Maste
Author: emaste
Date: Wed Jan 23 14:22:21 2019
New Revision: 343345
URL: https://svnweb.freebsd.org/changeset/base/343345

Log:
  MFC linuxulator stack memory disclosure fixes
  
  r343260 linuxulator: fix stack memory disclosure in linux_ioctl_v4l
  r343261 linuxulator: fix stack memory disclosure in linux_ioctl_termio
  r343262 linuxulator: fix stack memory disclosure in linux_sigaltstack
  r343263 linuxulator: fix stack memory disclosure in linux_sigaltstack
  
  admbugs:  765
  Reported by:  Vlad Tsyrklevich 
  Security: Kernel stack memory disclosure
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/11/sys/amd64/linux/linux_machdep.c
  stable/11/sys/compat/linux/linux_ioctl.c
  stable/11/sys/compat/linux/linux_misc.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/amd64/linux/linux_machdep.c
==
--- stable/11/sys/amd64/linux/linux_machdep.c   Wed Jan 23 14:21:23 2019
(r343344)
+++ stable/11/sys/amd64/linux/linux_machdep.c   Wed Jan 23 14:22:21 2019
(r343345)
@@ -200,6 +200,7 @@ linux_sigaltstack(struct thread *td, struct linux_siga
l_stack_t lss;
int error;
 
+   memset(, 0, sizeof(lss));
LINUX_CTR2(sigaltstack, "%p, %p", uap->uss, uap->uoss);
 
if (uap->uss != NULL) {

Modified: stable/11/sys/compat/linux/linux_ioctl.c
==
--- stable/11/sys/compat/linux/linux_ioctl.cWed Jan 23 14:21:23 2019
(r343344)
+++ stable/11/sys/compat/linux/linux_ioctl.cWed Jan 23 14:22:21 2019
(r343345)
@@ -688,6 +688,7 @@ bsd_to_linux_termio(struct termios *bios, struct linux
 {
struct linux_termios lios;
 
+   memset(lio, 0, sizeof(*lio));
bsd_to_linux_termios(bios, );
lio->c_iflag = lios.c_iflag;
lio->c_oflag = lios.c_oflag;
@@ -2851,6 +2852,8 @@ linux_to_bsd_v4l_window(struct l_video_window *lvw, st
 static int
 bsd_to_linux_v4l_window(struct video_window *vw, struct l_video_window *lvw)
 {
+   memset(lvw, 0, sizeof(*lvw));
+
lvw->x = vw->x;
lvw->y = vw->y;
lvw->width = vw->width;

Modified: stable/11/sys/compat/linux/linux_misc.c
==
--- stable/11/sys/compat/linux/linux_misc.c Wed Jan 23 14:21:23 2019
(r343344)
+++ stable/11/sys/compat/linux/linux_misc.c Wed Jan 23 14:22:21 2019
(r343345)
@@ -1079,9 +1079,8 @@ linux_waitid(struct thread *td, struct linux_waitid_ar
}
if (args->info != NULL) {
p = td->td_proc;
-   if (td->td_retval[0] == 0)
-   bzero(, sizeof(lsi));
-   else {
+   bzero(, sizeof(lsi));
+   if (td->td_retval[0] != 0) {
sig = bsd_to_linux_signal(siginfo.si_signo);
siginfo_to_lsiginfo(, , sig);
}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r343344 - head/sys/dev/netmap

2019-01-23 Thread Vincenzo Maffione
Author: vmaffione
Date: Wed Jan 23 14:21:23 2019
New Revision: 343344
URL: https://svnweb.freebsd.org/changeset/base/343344

Log:
  netmap: fix knote() argument to match the mutex state
  
  The nm_os_selwakeup function needs to call knote() to wake up kqueue(9)
  users. However, this function can be called from different code paths,
  with different lock requirements.
  This patch fixes the knote() call argument to match the relavant lock state.
  Also, comments have been updated to reflect current code.
  
  PR:   https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=219846
  Reported by:  Aleksandr Fedorov 
  Reviewed by:  markj
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D18876

Modified:
  head/sys/dev/netmap/netmap.c
  head/sys/dev/netmap/netmap_freebsd.c
  head/sys/dev/netmap/netmap_kern.h

Modified: head/sys/dev/netmap/netmap.c
==
--- head/sys/dev/netmap/netmap.cWed Jan 23 14:19:40 2019
(r343343)
+++ head/sys/dev/netmap/netmap.cWed Jan 23 14:21:23 2019
(r343344)
@@ -2531,7 +2531,6 @@ netmap_ioctl(struct netmap_priv_d *priv, u_long cmd, c
}
 
nifp = priv->np_nifp;
-   priv->np_td = td; /* for debugging purposes */
 
/* return the offset of the netmap_if object */
req->nr_rx_rings = na->num_rx_rings;
@@ -3207,8 +3206,8 @@ nmreq_checkoptions(struct nmreq_header *hdr)
  *
  * Can be called for one or more queues.
  * Return true the event mask corresponding to ready events.
- * If there are no ready events, do a selrecord on either individual
- * selinfo or on the global one.
+ * If there are no ready events (and 'sr' is not NULL), do a
+ * selrecord on either individual selinfo or on the global one.
  * Device-dependent parts (locking and sync of tx/rx rings)
  * are done through callbacks.
  *

Modified: head/sys/dev/netmap/netmap_freebsd.c
==
--- head/sys/dev/netmap/netmap_freebsd.cWed Jan 23 14:19:40 2019
(r343343)
+++ head/sys/dev/netmap/netmap_freebsd.cWed Jan 23 14:21:23 2019
(r343344)
@@ -85,7 +85,7 @@ void
 nm_os_selinfo_uninit(NM_SELINFO_T *si)
 {
/* XXX kqueue(9) needed; these will mirror knlist_init. */
-   knlist_delete(>si.si_note, curthread, 0 /* not locked */ );
+   knlist_delete(>si.si_note, curthread, /*islocked=*/0);
knlist_destroy(>si.si_note);
/* now we don't need the mutex anymore */
mtx_destroy(>m);
@@ -1294,21 +1294,21 @@ nm_os_kctx_destroy(struct nm_kctx *nmk)
 / kqueue support /
 
 /*
- * nm_os_selwakeup also needs to issue a KNOTE_UNLOCKED.
- * We use a non-zero argument to distinguish the call from the one
- * in kevent_scan() which instead also needs to run netmap_poll().
- * The knote uses a global mutex for the time being. We might
- * try to reuse the one in the si, but it is not allocated
- * permanently so it might be a bit tricky.
+ * In addition to calling selwakeuppri(), nm_os_selwakeup() also
+ * needs to call KNOTE to wake up kqueue listeners.
+ * We use a non-zero 'hint' argument to inform the netmap_knrw()
+ * function that it is being called from 'nm_os_selwakeup'; this
+ * is necessary because when netmap_knrw() is called by the kevent
+ * subsystem (i.e. kevent_scan()) we also need to call netmap_poll().
+ * The knote uses a private mutex associated to the 'si' (see struct
+ * selinfo, struct nm_selinfo, and nm_os_selinfo_init).
  *
- * The *kqfilter function registers one or another f_event
- * depending on read or write mode.
- * In the call to f_event() td_fpop is NULL so any child function
- * calling devfs_get_cdevpriv() would fail - and we need it in
- * netmap_poll(). As a workaround we store priv into kn->kn_hook
- * and pass it as first argument to netmap_poll(), which then
- * uses the failure to tell that we are called from f_event()
- * and do not need the selrecord().
+ * The netmap_kqfilter() function registers one or another f_event
+ * depending on read or write mode. A pointer to the struct
+ * 'netmap_priv_d' is stored into kn->kn_hook, so that it can later
+ * be passed to netmap_poll(). We pass NULL as a third argument to
+ * netmap_poll(), so that the latter only runs the txsync/rxsync
+ * (if necessary), and skips the nm_os_selrecord() calls.
  */
 
 
@@ -1316,12 +1316,13 @@ void
 nm_os_selwakeup(struct nm_selinfo *si)
 {
if (netmap_verbose)
-   D("on knote %p", >si.si_note);
+   nm_prinf("on knote %p", >si.si_note);
selwakeuppri(>si, PI_NET);
-   /* use a non-zero hint to tell the notification from the
-* call done in kqueue_scan() which uses 0
+   /* We use a non-zero hint to distinguish this notification 

svn commit: r343343 - in stable/12/sys: amd64/linux compat/linux

2019-01-23 Thread Ed Maste
Author: emaste
Date: Wed Jan 23 14:19:40 2019
New Revision: 343343
URL: https://svnweb.freebsd.org/changeset/base/343343

Log:
  MFC linuxulator stack memory disclosure fixes
  
  r343260 linuxulator: fix stack memory disclosure in linux_ioctl_v4l
  r343261 linuxulator: fix stack memory disclosure in linux_ioctl_termio
  r343262 linuxulator: fix stack memory disclosure in linux_sigaltstack
  r343263 linuxulator: fix stack memory disclosure in linux_sigaltstack
  
  admbugs:  765
  Reported by:  Vlad Tsyrklevich 
  Security: Kernel stack memory disclosure
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/12/sys/amd64/linux/linux_machdep.c
  stable/12/sys/compat/linux/linux_ioctl.c
  stable/12/sys/compat/linux/linux_misc.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/amd64/linux/linux_machdep.c
==
--- stable/12/sys/amd64/linux/linux_machdep.c   Wed Jan 23 13:17:03 2019
(r343342)
+++ stable/12/sys/amd64/linux/linux_machdep.c   Wed Jan 23 14:19:40 2019
(r343343)
@@ -201,6 +201,7 @@ linux_sigaltstack(struct thread *td, struct linux_siga
l_stack_t lss;
int error;
 
+   memset(, 0, sizeof(lss));
LINUX_CTR2(sigaltstack, "%p, %p", uap->uss, uap->uoss);
 
if (uap->uss != NULL) {

Modified: stable/12/sys/compat/linux/linux_ioctl.c
==
--- stable/12/sys/compat/linux/linux_ioctl.cWed Jan 23 13:17:03 2019
(r343342)
+++ stable/12/sys/compat/linux/linux_ioctl.cWed Jan 23 14:19:40 2019
(r343343)
@@ -686,6 +686,7 @@ bsd_to_linux_termio(struct termios *bios, struct linux
 {
struct linux_termios lios;
 
+   memset(lio, 0, sizeof(*lio));
bsd_to_linux_termios(bios, );
lio->c_iflag = lios.c_iflag;
lio->c_oflag = lios.c_oflag;
@@ -2843,6 +2844,8 @@ linux_to_bsd_v4l_window(struct l_video_window *lvw, st
 static int
 bsd_to_linux_v4l_window(struct video_window *vw, struct l_video_window *lvw)
 {
+   memset(lvw, 0, sizeof(*lvw));
+
lvw->x = vw->x;
lvw->y = vw->y;
lvw->width = vw->width;

Modified: stable/12/sys/compat/linux/linux_misc.c
==
--- stable/12/sys/compat/linux/linux_misc.c Wed Jan 23 13:17:03 2019
(r343342)
+++ stable/12/sys/compat/linux/linux_misc.c Wed Jan 23 14:19:40 2019
(r343343)
@@ -1089,9 +1089,8 @@ linux_waitid(struct thread *td, struct linux_waitid_ar
}
if (args->info != NULL) {
p = td->td_proc;
-   if (td->td_retval[0] == 0)
-   bzero(, sizeof(lsi));
-   else {
+   bzero(, sizeof(lsi));
+   if (td->td_retval[0] != 0) {
sig = bsd_to_linux_signal(siginfo.si_signo);
siginfo_to_lsiginfo(, , sig);
}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r343342 - head/sys/net80211

2019-01-23 Thread Andriy Voskoboinyk
Wed, 23 Jan 2019 15:17:03 +0200 було написано Andriy Voskoboinyk  
:



Author: avos
Date: Wed Jan 23 13:17:03 2019
New Revision: 343342
URL: https://svnweb.freebsd.org/changeset/base/343342

Log:
  net80211: turn channel mode check into assertion.
 There is may be only 11b channel (since chanflags[] table
  maps MODE_AUTO to the corresponding 11b channel flags).
 Checked with RTL8812AU, STA mode.


Typo: this should be RTL8821AU
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r343342 - head/sys/net80211

2019-01-23 Thread Andriy Voskoboinyk
Author: avos
Date: Wed Jan 23 13:17:03 2019
New Revision: 343342
URL: https://svnweb.freebsd.org/changeset/base/343342

Log:
  net80211: turn channel mode check into assertion.
  
  There is may be only 11b channel (since chanflags[] table
  maps MODE_AUTO to the corresponding 11b channel flags).
  
  Checked with RTL8812AU, STA mode.
  
  MFC after:5 days

Modified:
  head/sys/net80211/ieee80211_scan_sta.c

Modified: head/sys/net80211/ieee80211_scan_sta.c
==
--- head/sys/net80211/ieee80211_scan_sta.c  Wed Jan 23 13:07:05 2019
(r343341)
+++ head/sys/net80211/ieee80211_scan_sta.c  Wed Jan 23 13:17:03 2019
(r343342)
@@ -496,12 +496,15 @@ add_channels(struct ieee80211vap *vap,
if (c == NULL || isexcluded(vap, c))
continue;
if (mode == IEEE80211_MODE_AUTO) {
+   KASSERT(IEEE80211_IS_CHAN_B(c),
+   ("%s: wrong channel for 'auto' mode %u / %u\n",
+   __func__, c->ic_freq, c->ic_flags));
+
/*
 * XXX special-case 11b/g channels so we select
 * the g channel if both are present.
 */
-   if (IEEE80211_IS_CHAN_B(c) &&
-   (cg = find11gchannel(ic, i, c->ic_freq)) != NULL)
+   if ((cg = find11gchannel(ic, i, c->ic_freq)) != NULL)
c = cg;
}
ss->ss_chans[ss->ss_last++] = c;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r343341 - head/sbin/ifconfig

2019-01-23 Thread Andriy Voskoboinyk
Author: avos
Date: Wed Jan 23 13:07:05 2019
New Revision: 343341
URL: https://svnweb.freebsd.org/changeset/base/343341

Log:
  ifconfig: drop unused macros from ifieee80211.c
  
  MFC after:5 days

Modified:
  head/sbin/ifconfig/ifieee80211.c

Modified: head/sbin/ifconfig/ifieee80211.c
==
--- head/sbin/ifconfig/ifieee80211.cWed Jan 23 12:43:46 2019
(r343340)
+++ head/sbin/ifconfig/ifieee80211.cWed Jan 23 13:07:05 2019
(r343341)
@@ -1528,9 +1528,6 @@ getmodeflags(const char *val)
return flags;
 }
 
-#defineIEEE80211_CHAN_HTA  (IEEE80211_CHAN_HT|IEEE80211_CHAN_5GHZ)
-#defineIEEE80211_CHAN_HTG  (IEEE80211_CHAN_HT|IEEE80211_CHAN_2GHZ)
-
 #define_APPLY(_flags, _base, _param, _v) do {  
\
 if (_flags & IEEE80211_CHAN_HT) {  \
if ((_flags & (IEEE80211_CHAN_5GHZ|IEEE80211_CHAN_2GHZ)) == 0) {\
@@ -1720,8 +1717,6 @@ DECL_CMD_FUNC(set80211maxretry, val, d)
 }
 #undef _APPLY_RATE
 #undef _APPLY
-#undef IEEE80211_CHAN_HTA
-#undef IEEE80211_CHAN_HTG
 
 static
 DECL_CMD_FUNC(set80211fragthreshold, val, d)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r343340 - head/sys/net80211

2019-01-23 Thread Andriy Voskoboinyk
Author: avos
Date: Wed Jan 23 12:43:46 2019
New Revision: 343340
URL: https://svnweb.freebsd.org/changeset/base/343340

Log:
  net80211: fix channel list construction for non-auto operating mode.
  
  Change the way how channel list mode <-> desired mode match is done:
  - Match channel list mode for next non-auto desired modes:
   * 11b: 11g, 11ng, 11acg;
   * 11a: 11na, 11ac
  - Add pre-defined channels only when one of the next conditions met:
   * the desired channel mode is 'auto' or
   * the desired channel and selected channel list modes are exactly
  the same or
   * the previous rule (11g / 11n / 11ac promotion) applies.
  
  Before r275875 construction work properly for all except
  11ng / 11na / 11acg / 11ac modes - these were broken at all
  (i.e., the scan list was empty); after r275875 all checks were removed,
  so scan table was populated by all device-compatible channels
  (desired mode was ignored).
  
  For example, if I will set 'ifconfig wlan0 mode 11ng' for RTL8821AU:
  - pre-r275875: nothing, scan will not work;
  - after r275875: both 11ng and 11na bands were scanned; also, since 11b
  channel list was used, 14th channel was scanned too.
  - after this change: only 11ng - 1-13 channels - are used for scanning.
  
  Tested with:
   * RTL8188EE, STA mode.
   * RTL8821AU, STA mode.
  
  MFC after:5 days

Modified:
  head/sys/net80211/ieee80211_scan_sta.c

Modified: head/sys/net80211/ieee80211_scan_sta.c
==
--- head/sys/net80211/ieee80211_scan_sta.c  Wed Jan 23 10:05:27 2019
(r343339)
+++ head/sys/net80211/ieee80211_scan_sta.c  Wed Jan 23 12:43:46 2019
(r343340)
@@ -472,6 +472,8 @@ static const u_int chanflags[IEEE80211_MODE_MAX] = {
/* check legacy */
[IEEE80211_MODE_11NA] = IEEE80211_CHAN_A,
[IEEE80211_MODE_11NG] = IEEE80211_CHAN_G,
+   [IEEE80211_MODE_VHT_5GHZ] = IEEE80211_CHAN_A,
+   [IEEE80211_MODE_VHT_2GHZ] = IEEE80211_CHAN_G,
 };
 
 static void
@@ -618,32 +620,48 @@ makescanlist(struct ieee80211_scan_state *ss, struct i
 */
for (scan = table; scan->list != NULL; scan++) {
mode = scan->mode;
-   if (vap->iv_des_mode != IEEE80211_MODE_AUTO) {
+
+   switch (mode) {
+   case IEEE80211_MODE_11B:
+   if (vap->iv_des_mode == IEEE80211_MODE_11B)
+   break;
+
/*
-* If a desired mode was specified, scan only 
-* channels that satisfy that constraint.
+* The scan table marks 2.4Ghz channels as b
+* so if the desired mode is 11g / 11ng / 11acg,
+* then use the 11b channel list but upgrade the mode.
+*
+* NB: 11b -> AUTO lets add_channels upgrade an
+* 11b channel to 11g if available.
 */
-   if (vap->iv_des_mode != mode) {
-   /*
-* The scan table marks 2.4Ghz channels as b
-* so if the desired mode is 11g, then use
-* the 11b channel list but upgrade the mode.
-*/
-   if (vap->iv_des_mode == IEEE80211_MODE_11G) {
-   if (mode == IEEE80211_MODE_11G) /* Skip 
the G check */
-   continue;
-   else if (mode == IEEE80211_MODE_11B)
-   mode = IEEE80211_MODE_11G;  
/* upgrade */
-   }
+   if (vap->iv_des_mode == IEEE80211_MODE_AUTO ||
+   vap->iv_des_mode == IEEE80211_MODE_11G ||
+   vap->iv_des_mode == IEEE80211_MODE_11NG ||
+   vap->iv_des_mode == IEEE80211_MODE_VHT_2GHZ) {
+   mode = vap->iv_des_mode;
+   break;
}
-   } else {
+
+   continue;
+   case IEEE80211_MODE_11A:
+   /* Use 11a channel list for 11na / 11ac modes */
+   if (vap->iv_des_mode == IEEE80211_MODE_11NA ||
+   vap->iv_des_mode == IEEE80211_MODE_VHT_5GHZ) {
+   mode = vap->iv_des_mode;
+   break;
+   }
+
+   /* FALLTHROUGH */
+   default:
/*
-* This lets add_channels upgrade an 11b channel
-* to 11g if available.
+* If a desired mode was specified, scan only
+ 

svn commit: r343339 - head/usr.sbin/kbdcontrol

2019-01-23 Thread Stefan Esser
Author: se
Date: Wed Jan 23 10:05:27 2019
New Revision: 343339
URL: https://svnweb.freebsd.org/changeset/base/343339

Log:
  Silence Clang Scan warning about use of unitialized variable.
  
  While the warning is a false positive, it is possible to clarify the code by
  always initializing the variable. This does also allow to make the sending
  of the "beep" control sequence depend on the validity of its parameters.
  
  I have left the redundant assignment of 0 to the now initialized variables
  in place since this makes the code simpler to understand and does not add
  any run-time overhead (the compiler completely removes the "else if" test
  and the assignments).
  
  There was an embedded literal escape character in a string, which messes up
  diplaying the source code on a terminal that interprets ANSI sequences. The
  literal escape has been replaced by \e (non-standard, but supported by all
  relevant compilers, and already used in other source files in base).
  
  MFC after:2 weeks

Modified:
  head/usr.sbin/kbdcontrol/kbdcontrol.c

Modified: head/usr.sbin/kbdcontrol/kbdcontrol.c
==
--- head/usr.sbin/kbdcontrol/kbdcontrol.c   Wed Jan 23 02:46:35 2019
(r343338)
+++ head/usr.sbin/kbdcontrol/kbdcontrol.c   Wed Jan 23 10:05:27 2019
(r343339)
@@ -961,6 +961,8 @@ set_bell_values(char *opt)
int bell, duration, pitch;
 
bell = 0;
+   duration = 0;
+   pitch = 0;
if (!strncmp(opt, "quiet.", 6)) {
bell = CONS_QUIET_BELL;
opt += 6;
@@ -991,8 +993,8 @@ badopt:
}
 
ioctl(0, CONS_BELLTYPE, );
-   if (!(bell & CONS_VISUAL_BELL))
-   fprintf(stderr, "[=%d;%dB", pitch, duration);
+   if (duration > 0 && pitch > 0)
+   fprintf(stderr, "\e[=%d;%dB", pitch, duration);
 }
 
 static void
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"