From owner-svn-src-all@freebsd.org Sat Jun 13 22:20:03 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3D1A5343FFD; Sat, 13 Jun 2020 22:20:03 +0000 (UTC) (envelope-from adrian@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 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 49ksTv0sFgz4YJG; Sat, 13 Jun 2020 22:20:03 +0000 (UTC) (envelope-from adrian@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 F33912204A; Sat, 13 Jun 2020 22:20:02 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 05DMK2BX097594; Sat, 13 Jun 2020 22:20:02 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 05DMK2ux097593; Sat, 13 Jun 2020 22:20:02 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <202006132220.05DMK2ux097593@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Sat, 13 Jun 2020 22:20:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r362156 - head/sys/net80211 X-SVN-Group: head X-SVN-Commit-Author: adrian X-SVN-Commit-Paths: head/sys/net80211 X-SVN-Commit-Revision: 362156 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 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: Sat, 13 Jun 2020 22:20:03 -0000 Author: adrian Date: Sat Jun 13 22:20:02 2020 New Revision: 362156 URL: https://svnweb.freebsd.org/changeset/base/362156 Log: [net80211] separate out node allocation and node initialisation. This is a new, optional (for now!) method that drivers can use to separate node allocation and node initialisation. Right now they're the same, and drivers that need to do node allocation via firmware commands need to sleep and thus they need to defer node allocation into an internal taskqueue. Right now they're just separate but not deferred. Later on if I get the time we'll start deferring the node and key related operations but that requires making a bunch of other stuff (notably things that generate frames!) also async/deferred. Tested: * RT3593, STA/DWDS mode * AR9380, STA/AP modes * QCA9880 (athp) - STA/AP modes Modified: head/sys/net80211/ieee80211_node.c head/sys/net80211/ieee80211_var.h Modified: head/sys/net80211/ieee80211_node.c ============================================================================== --- head/sys/net80211/ieee80211_node.c Sat Jun 13 21:23:26 2020 (r362155) +++ head/sys/net80211/ieee80211_node.c Sat Jun 13 22:20:02 2020 (r362156) @@ -80,6 +80,7 @@ static int ieee80211_sta_join1(struct ieee80211_node * static struct ieee80211_node *node_alloc(struct ieee80211vap *, const uint8_t [IEEE80211_ADDR_LEN]); +static int node_init(struct ieee80211_node *); static void node_cleanup(struct ieee80211_node *); static void node_free(struct ieee80211_node *); static void node_age(struct ieee80211_node *); @@ -116,6 +117,7 @@ ieee80211_node_attach(struct ieee80211com *ic) ieee80211_node_timeout, ic); ic->ic_node_alloc = node_alloc; + ic->ic_node_init = node_init; ic->ic_node_free = node_free; ic->ic_node_cleanup = node_cleanup; ic->ic_node_age = node_age; @@ -1074,6 +1076,12 @@ node_alloc(struct ieee80211vap *vap, const uint8_t mac return ni; } +static int +node_init(struct ieee80211_node *ni) +{ + return 0; +} + /* * Initialize an ie blob with the specified data. If previous * data exists re-use the data block. As a side effect we clear @@ -1414,6 +1422,15 @@ ieee80211_alloc_node(struct ieee80211_node_table *nt, ni->ni_ic = ic; IEEE80211_NODE_UNLOCK(nt); + /* handle failure; free node state */ + if (ic->ic_node_init(ni) != 0) { + vap->iv_stats.is_rx_nodealloc++; + ieee80211_psq_cleanup(&ni->ni_psq); + ieee80211_ratectl_node_deinit(ni); + _ieee80211_free_node(ni); + return NULL; + } + IEEE80211_NOTE(vap, IEEE80211_MSG_INACT, ni, "%s: inact_reload %u", __func__, ni->ni_inact_reload); @@ -1456,6 +1473,16 @@ ieee80211_tmp_node(struct ieee80211vap *vap, ieee80211_psq_init(&ni->ni_psq, "unknown"); ieee80211_ratectl_node_init(ni); + + /* handle failure; free node state */ + if (ic->ic_node_init(ni) != 0) { + vap->iv_stats.is_rx_nodealloc++; + ieee80211_psq_cleanup(&ni->ni_psq); + ieee80211_ratectl_node_deinit(ni); + _ieee80211_free_node(ni); + return NULL; + } + } else { /* XXX msg */ vap->iv_stats.is_rx_nodealloc++; Modified: head/sys/net80211/ieee80211_var.h ============================================================================== --- head/sys/net80211/ieee80211_var.h Sat Jun 13 21:23:26 2020 (r362155) +++ head/sys/net80211/ieee80211_var.h Sat Jun 13 22:20:02 2020 (r362156) @@ -310,11 +310,22 @@ struct ieee80211com { /* TDMA update notification */ void (*ic_tdma_update)(struct ieee80211_node *, const struct ieee80211_tdma_param *, int); - /* node state management */ + + /* Node state management */ + + /* Allocate a new node */ struct ieee80211_node* (*ic_node_alloc)(struct ieee80211vap *, const uint8_t [IEEE80211_ADDR_LEN]); + + /* Driver node initialisation after net80211 setup */ + int (*ic_node_init)(struct ieee80211_node *); + + /* Driver node deallocation */ void (*ic_node_free)(struct ieee80211_node *); + + /* Driver node state cleanup before deallocation */ void (*ic_node_cleanup)(struct ieee80211_node *); + void (*ic_node_age)(struct ieee80211_node *); void (*ic_node_drain)(struct ieee80211_node *); int8_t (*ic_node_getrssi)(const struct ieee80211_node*);