From owner-svn-src-all@freebsd.org Thu Jan 24 03:47:48 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9264F14C0529; Thu, 24 Jan 2019 03:47:48 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3A62E76564; Thu, 24 Jan 2019 03:47:48 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2D83822C3B; Thu, 24 Jan 2019 03:47:48 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x0O3lmHU026078; Thu, 24 Jan 2019 03:47:48 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x0O3llKV026073; Thu, 24 Jan 2019 03:47:47 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201901240347.x0O3llKV026073@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Jan 2019 03:47:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r343384 - head/sys/dev/iwm X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/sys/dev/iwm X-SVN-Commit-Revision: 343384 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 3A62E76564 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.96)[-0.958,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Jan 2019 03:47:48 -0000 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.c Thu Jan 24 03:47:04 2019 (r343383) +++ head/sys/dev/iwm/if_iwm_time_event.c Thu 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) / 1000000) + +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 notification wait, which really just processes the * command response and doesn't wait for anything, in order @@ -279,8 +342,6 @@ iwm_mvm_time_event_send_add(struct iwm_softc *sc, stru return ret; } -#define TU_TO_HZ(tu) (((uint64_t)(tu) * 1024 * hz) / 1000000) - void iwm_mvm_protect_session(struct iwm_softc *sc, struct iwm_vap *ivp, uint32_t duration, uint32_t max_delay, boolean_t wait_for_notif) @@ -362,7 +423,7 @@ iwm_mvm_stop_session_protection(struct iwm_softc *sc, "%s: Removing TE 0x%x\n", __func__, le32toh(time_cmd.id)); if (iwm_mvm_send_cmd_pdu(sc, IWM_TIME_EVENT_CMD, 0, sizeof(time_cmd), &time_cmd) == 0) - sc->sc_flags &= ~IWM_FLAG_TE_ACTIVE; + iwm_mvm_te_clear_data(sc); DELAY(100); } Modified: head/sys/dev/iwm/if_iwm_time_event.h ============================================================================== --- head/sys/dev/iwm/if_iwm_time_event.h Thu Jan 24 03:47:04 2019 (r343383) +++ head/sys/dev/iwm/if_iwm_time_event.h Thu Jan 24 03:47:47 2019 (r343384) @@ -107,6 +107,8 @@ #ifndef __IF_IWM_TIME_EVENT_H__ #define __IF_IWM_TIME_EVENT_H__ +extern void iwm_mvm_rx_time_event_notif(struct iwm_softc *sc, + struct iwm_rx_packet *pkt); extern void iwm_mvm_protect_session(struct iwm_softc *sc, struct iwm_vap *ivp, uint32_t duration, uint32_t max_delay, boolean_t wait_for_notif); extern void iwm_mvm_stop_session_protection(struct iwm_softc *sc, Modified: head/sys/dev/iwm/if_iwmvar.h ============================================================================== --- head/sys/dev/iwm/if_iwmvar.h Thu Jan 24 03:47:04 2019 (r343383) +++ head/sys/dev/iwm/if_iwmvar.h Thu Jan 24 03:47:47 2019 (r343384) @@ -566,6 +566,12 @@ struct iwm_softc { /* Unique ID (assigned by the firmware) of the current Time Event. */ uint32_t sc_time_event_uid; + + /* Duration of the Time Event in TU. */ + uint32_t sc_time_event_duration; + + /* Expected end of the Time Event in HZ ticks. */ + int sc_time_event_end_ticks; }; #define IWM_LOCK_INIT(_sc) \