Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src-draft/trunk]: src/sys/net80211 Add an easy method for drivers to overrid...
details: https://anonhg.NetBSD.org/src-all/rev/81970f56e02f
branches: trunk
changeset: 375813:81970f56e02f
user: Martin Husemann <martin%NetBSD.org@localhost>
date: Tue Sep 20 19:57:57 2022 +0200
description:
Add an easy method for drivers to override the size of the node structure
Drivers that use a custom node type (starting with ieee80211_node) can
simply set the desired size in the ic structure and do not have to
deal with allocation (and the more complex cleanup and deallocation).
diffstat:
sys/net80211/ieee80211_node.c | 10 ++++++++++
sys/net80211/ieee80211_var.h | 3 +++
2 files changed, 13 insertions(+), 0 deletions(-)
diffs (51 lines):
diff -r 6ea228804fb5 -r 81970f56e02f sys/net80211/ieee80211_node.c
--- a/sys/net80211/ieee80211_node.c Tue Sep 20 18:47:53 2022 +0200
+++ b/sys/net80211/ieee80211_node.c Tue Sep 20 19:57:57 2022 +0200
@@ -136,6 +136,7 @@ ieee80211_node_attach(struct ieee80211co
taskqueue_enqueue_timeout(ic->ic_tq, &ic->ic_inact_task,
IEEE80211_INACT_WAIT*hz);
+ ic->ic_node_size = sizeof(struct ieee80211_node);
ic->ic_node_alloc = node_alloc;
ic->ic_node_init = node_init;
ic->ic_node_free = node_free;
@@ -1137,9 +1138,14 @@ static struct ieee80211_node *
node_alloc(struct ieee80211vap *vap, const uint8_t macaddr[IEEE80211_ADDR_LEN])
{
struct ieee80211_node *ni;
+ struct ieee80211com *ic = vap->iv_ic;
ni = (struct ieee80211_node *) IEEE80211_MZALLOC(
+#ifdef __NetBSD__
+ ic->ic_node_size,
+#else
sizeof(struct ieee80211_node),
+#endif
M_80211_NODE, IEEE80211_M_NOWAIT);
return ni;
}
@@ -1353,7 +1359,11 @@ node_free(struct ieee80211_node *ni)
ic->ic_node_cleanup(ni);
ieee80211_ies_cleanup(&ni->ni_ies);
ieee80211_psq_cleanup(&ni->ni_psq);
+#ifdef __NetBSD__
+ IEEE80211_MFREE(ni, M_80211_NODE, ic->ic_node_size);
+#else
IEEE80211_MFREE(ni, M_80211_NODE, sizeof(*ni));
+#endif
ni = NULL;
}
diff -r 6ea228804fb5 -r 81970f56e02f sys/net80211/ieee80211_var.h
--- a/sys/net80211/ieee80211_var.h Tue Sep 20 18:47:53 2022 +0200
+++ b/sys/net80211/ieee80211_var.h Tue Sep 20 19:57:57 2022 +0200
@@ -315,6 +315,9 @@ struct ieee80211com {
/* Node state management */
+ /* Size of driver specific node type when using common alloc */
+ size_t ic_node_size;
+
/* Allocate a new node */
struct ieee80211_node* (*ic_node_alloc)(struct ieee80211vap *,
const uint8_t [IEEE80211_ADDR_LEN]);
Home |
Main Index |
Thread Index |
Old Index