Deleted Added
full compact
if_ath.c (172211) if_ath.c (175414)
1/*-
2 * Copyright (c) 2002-2007 Sam Leffler, Errno Consulting
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 14 unchanged lines hidden (view full) ---

23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27 * THE POSSIBILITY OF SUCH DAMAGES.
28 */
29
30#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2002-2007 Sam Leffler, Errno Consulting
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 14 unchanged lines hidden (view full) ---

23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27 * THE POSSIBILITY OF SUCH DAMAGES.
28 */
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/dev/ath/if_ath.c 172211 2007-09-17 19:07:24Z sam $");
31__FBSDID("$FreeBSD: head/sys/dev/ath/if_ath.c 175414 2008-01-17 21:25:09Z sam $");
32
33/*
34 * Driver for the Atheros Wireless LAN controller.
35 *
36 * This software is derived from work of Atsushi Onoe; his contribution
37 * is greatly appreciated.
38 */
39

--- 3847 unchanged lines hidden (view full) ---

3887 ATH_TXBUF_LOCK_DESTROY(sc);
3888 for (i = 0; i < HAL_NUM_TX_QUEUES; i++)
3889 if (ATH_TXQ_SETUP(sc, i))
3890 ath_tx_cleanupq(sc, &sc->sc_txq[i]);
3891 ATH_TXQ_LOCK_DESTROY(&sc->sc_mcastq);
3892}
3893
3894/*
32
33/*
34 * Driver for the Atheros Wireless LAN controller.
35 *
36 * This software is derived from work of Atsushi Onoe; his contribution
37 * is greatly appreciated.
38 */
39

--- 3847 unchanged lines hidden (view full) ---

3887 ATH_TXBUF_LOCK_DESTROY(sc);
3888 for (i = 0; i < HAL_NUM_TX_QUEUES; i++)
3889 if (ATH_TXQ_SETUP(sc, i))
3890 ath_tx_cleanupq(sc, &sc->sc_txq[i]);
3891 ATH_TXQ_LOCK_DESTROY(&sc->sc_mcastq);
3892}
3893
3894/*
3895 * Defragment an mbuf chain, returning at most maxfrags separate
3896 * mbufs+clusters. If this is not possible NULL is returned and
3897 * the original mbuf chain is left in it's present (potentially
3898 * modified) state. We use two techniques: collapsing consecutive
3899 * mbufs and replacing consecutive mbufs by a cluster.
3900 */
3901static struct mbuf *
3902ath_defrag(struct mbuf *m0, int how, int maxfrags)
3903{
3904 struct mbuf *m, *n, *n2, **prev;
3905 u_int curfrags;
3906
3907 /*
3908 * Calculate the current number of frags.
3909 */
3910 curfrags = 0;
3911 for (m = m0; m != NULL; m = m->m_next)
3912 curfrags++;
3913 /*
3914 * First, try to collapse mbufs. Note that we always collapse
3915 * towards the front so we don't need to deal with moving the
3916 * pkthdr. This may be suboptimal if the first mbuf has much
3917 * less data than the following.
3918 */
3919 m = m0;
3920again:
3921 for (;;) {
3922 n = m->m_next;
3923 if (n == NULL)
3924 break;
3925 if ((m->m_flags & M_RDONLY) == 0 &&
3926 n->m_len < M_TRAILINGSPACE(m)) {
3927 bcopy(mtod(n, void *), mtod(m, char *) + m->m_len,
3928 n->m_len);
3929 m->m_len += n->m_len;
3930 m->m_next = n->m_next;
3931 m_free(n);
3932 if (--curfrags <= maxfrags)
3933 return m0;
3934 } else
3935 m = n;
3936 }
3937 KASSERT(maxfrags > 1,
3938 ("maxfrags %u, but normal collapse failed", maxfrags));
3939 /*
3940 * Collapse consecutive mbufs to a cluster.
3941 */
3942 prev = &m0->m_next; /* NB: not the first mbuf */
3943 while ((n = *prev) != NULL) {
3944 if ((n2 = n->m_next) != NULL &&
3945 n->m_len + n2->m_len < MCLBYTES) {
3946 m = m_getcl(how, MT_DATA, 0);
3947 if (m == NULL)
3948 goto bad;
3949 bcopy(mtod(n, void *), mtod(m, void *), n->m_len);
3950 bcopy(mtod(n2, void *), mtod(m, char *) + n->m_len,
3951 n2->m_len);
3952 m->m_len = n->m_len + n2->m_len;
3953 m->m_next = n2->m_next;
3954 *prev = m;
3955 m_free(n);
3956 m_free(n2);
3957 if (--curfrags <= maxfrags) /* +1 cl -2 mbufs */
3958 return m0;
3959 /*
3960 * Still not there, try the normal collapse
3961 * again before we allocate another cluster.
3962 */
3963 goto again;
3964 }
3965 prev = &n->m_next;
3966 }
3967 /*
3968 * No place where we can collapse to a cluster; punt.
3969 * This can occur if, for example, you request 2 frags
3970 * but the packet requires that both be clusters (we
3971 * never reallocate the first mbuf to avoid moving the
3972 * packet header).
3973 */
3974bad:
3975 return NULL;
3976}
3977
3978/*
3979 * Return h/w rate index for an IEEE rate (w/o basic rate bit).
3980 */
3981static int
3982ath_tx_findrix(const HAL_RATE_TABLE *rt, int rate)
3983{
3984 int i;
3985
3986 for (i = 0; i < rt->rateCount; i++)

--- 41 unchanged lines hidden (view full) ---

4028 }
4029 /*
4030 * Discard null packets and check for packets that
4031 * require too many TX descriptors. We try to convert
4032 * the latter to a cluster.
4033 */
4034 if (bf->bf_nseg > ATH_TXDESC) { /* too many desc's, linearize */
4035 sc->sc_stats.ast_tx_linear++;
3895 * Return h/w rate index for an IEEE rate (w/o basic rate bit).
3896 */
3897static int
3898ath_tx_findrix(const HAL_RATE_TABLE *rt, int rate)
3899{
3900 int i;
3901
3902 for (i = 0; i < rt->rateCount; i++)

--- 41 unchanged lines hidden (view full) ---

3944 }
3945 /*
3946 * Discard null packets and check for packets that
3947 * require too many TX descriptors. We try to convert
3948 * the latter to a cluster.
3949 */
3950 if (bf->bf_nseg > ATH_TXDESC) { /* too many desc's, linearize */
3951 sc->sc_stats.ast_tx_linear++;
4036 m = ath_defrag(m0, M_DONTWAIT, ATH_TXDESC);
3952 m = m_collapse(m0, M_DONTWAIT, ATH_TXDESC);
4037 if (m == NULL) {
4038 ath_freetx(m0);
4039 sc->sc_stats.ast_tx_nombuf++;
4040 return ENOMEM;
4041 }
4042 m0 = m;
4043 error = bus_dmamap_load_mbuf_sg(sc->sc_dmat, bf->bf_dmamap, m0,
4044 bf->bf_segs, &bf->bf_nseg,

--- 2570 unchanged lines hidden ---
3953 if (m == NULL) {
3954 ath_freetx(m0);
3955 sc->sc_stats.ast_tx_nombuf++;
3956 return ENOMEM;
3957 }
3958 m0 = m;
3959 error = bus_dmamap_load_mbuf_sg(sc->sc_dmat, bf->bf_dmamap, m0,
3960 bf->bf_segs, &bf->bf_nseg,

--- 2570 unchanged lines hidden ---