PERFORCE change 67802 for review
Sam Leffler
sam at FreeBSD.org
Tue Dec 28 08:36:08 PST 2004
http://perforce.freebsd.org/chv.cgi?CH=67802
Change 67802 by sam at sam_ebb on 2004/12/28 16:35:41
move a routine so related code is kept together
Affected files ...
.. //depot/projects/wifi/sys/net80211/ieee80211_output.c#28 edit
Differences ...
==== //depot/projects/wifi/sys/net80211/ieee80211_output.c#28 (text+ko) ====
@@ -203,74 +203,6 @@
return 0;
}
-/*
- * Insure there is sufficient contiguous space to encapsulate the
- * 802.11 data frame. If room isn't already there, arrange for it.
- * Drivers and cipher modules assume we have done the necessary work
- * and fail rudely if they don't find the space they need.
- */
-static struct mbuf *
-ieee80211_mbuf_adjust(struct ieee80211com *ic, int hdrsize,
- struct ieee80211_key *key, struct mbuf *m)
-{
-#define TO_BE_RECLAIMED (sizeof(struct ether_header) - sizeof(struct llc))
- int needed_space = hdrsize;
-
- if (key != NULL) {
- /* XXX belongs in crypto code? */
- needed_space += key->wk_cipher->ic_header;
- /* XXX frags */
- }
- /*
- * We know we are called just before stripping an Ethernet
- * header and prepending an LLC header. This means we know
- * there will be
- * sizeof(struct ether_header) - sizeof(struct llc)
- * bytes recovered to which we need additional space for the
- * 802.11 header and any crypto header.
- */
- /* XXX check trailing space and copy instead? */
- if (M_LEADINGSPACE(m) < needed_space - TO_BE_RECLAIMED) {
- struct mbuf *n = m_gethdr(M_NOWAIT, m->m_type);
- if (n == NULL) {
- IEEE80211_DPRINTF(ic, IEEE80211_MSG_OUTPUT,
- "%s: cannot expand storage\n", __func__);
- ic->ic_stats.is_tx_nobuf++;
- m_freem(m);
- return NULL;
- }
- KASSERT(needed_space <= MHLEN,
- ("not enough room, need %u got %zu\n", needed_space, MHLEN));
- /*
- * Setup new mbuf to have leading space to prepend the
- * 802.11 header and any crypto header bits that are
- * required (the latter are added when the driver calls
- * back to ieee80211_crypto_encap to do crypto encapsulation).
- */
- /* NB: must be first 'cuz it clobbers m_data */
- m_move_pkthdr(n, m);
- n->m_len = 0; /* NB: m_gethdr does not set */
- n->m_data += needed_space;
- /*
- * Pull up Ethernet header to create the expected layout.
- * We could use m_pullup but that's overkill (i.e. we don't
- * need the actual data) and it cannot fail so do it inline
- * for speed.
- */
- /* NB: struct ether_header is known to be contiguous */
- n->m_len += sizeof(struct ether_header);
- m->m_len -= sizeof(struct ether_header);
- m->m_data += sizeof(struct ether_header);
- /*
- * Replace the head of the chain.
- */
- n->m_next = m;
- m = n;
- }
- return m;
-#undef TO_BE_RECLAIMED
-}
-
/*
* Assign priority to a frame based on any vlan tag assigned
* to the station and/or any Diffserv setting in an IP header.
@@ -387,6 +319,74 @@
return 0;
}
+/*
+ * Insure there is sufficient contiguous space to encapsulate the
+ * 802.11 data frame. If room isn't already there, arrange for it.
+ * Drivers and cipher modules assume we have done the necessary work
+ * and fail rudely if they don't find the space they need.
+ */
+static struct mbuf *
+ieee80211_mbuf_adjust(struct ieee80211com *ic, int hdrsize,
+ struct ieee80211_key *key, struct mbuf *m)
+{
+#define TO_BE_RECLAIMED (sizeof(struct ether_header) - sizeof(struct llc))
+ int needed_space = hdrsize;
+
+ if (key != NULL) {
+ /* XXX belongs in crypto code? */
+ needed_space += key->wk_cipher->ic_header;
+ /* XXX frags */
+ }
+ /*
+ * We know we are called just before stripping an Ethernet
+ * header and prepending an LLC header. This means we know
+ * there will be
+ * sizeof(struct ether_header) - sizeof(struct llc)
+ * bytes recovered to which we need additional space for the
+ * 802.11 header and any crypto header.
+ */
+ /* XXX check trailing space and copy instead? */
+ if (M_LEADINGSPACE(m) < needed_space - TO_BE_RECLAIMED) {
+ struct mbuf *n = m_gethdr(M_NOWAIT, m->m_type);
+ if (n == NULL) {
+ IEEE80211_DPRINTF(ic, IEEE80211_MSG_OUTPUT,
+ "%s: cannot expand storage\n", __func__);
+ ic->ic_stats.is_tx_nobuf++;
+ m_freem(m);
+ return NULL;
+ }
+ KASSERT(needed_space <= MHLEN,
+ ("not enough room, need %u got %zu\n", needed_space, MHLEN));
+ /*
+ * Setup new mbuf to have leading space to prepend the
+ * 802.11 header and any crypto header bits that are
+ * required (the latter are added when the driver calls
+ * back to ieee80211_crypto_encap to do crypto encapsulation).
+ */
+ /* NB: must be first 'cuz it clobbers m_data */
+ m_move_pkthdr(n, m);
+ n->m_len = 0; /* NB: m_gethdr does not set */
+ n->m_data += needed_space;
+ /*
+ * Pull up Ethernet header to create the expected layout.
+ * We could use m_pullup but that's overkill (i.e. we don't
+ * need the actual data) and it cannot fail so do it inline
+ * for speed.
+ */
+ /* NB: struct ether_header is known to be contiguous */
+ n->m_len += sizeof(struct ether_header);
+ m->m_len -= sizeof(struct ether_header);
+ m->m_data += sizeof(struct ether_header);
+ /*
+ * Replace the head of the chain.
+ */
+ n->m_next = m;
+ m = n;
+ }
+ return m;
+#undef TO_BE_RECLAIMED
+}
+
#define KEY_UNDEFINED(k) ((k).wk_cipher == &ieee80211_cipher_none)
/*
* Return the transmit key to use in sending a unicast frame.
More information about the p4-projects
mailing list