Deleted Added
full compact
if_arge.c (209802) if_arge.c (209807)
1/*-
2 * Copyright (c) 2009, Oleksandr Tymoshenko
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

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

21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2009, Oleksandr Tymoshenko
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

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

21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
29__FBSDID("$FreeBSD: head/sys/mips/atheros/if_arge.c 209802 2010-07-08 14:34:15Z adrian $");
29__FBSDID("$FreeBSD: head/sys/mips/atheros/if_arge.c 209807 2010-07-08 14:59:32Z adrian $");
30
31/*
32 * AR71XX gigabit ethernet driver
33 */
34#ifdef HAVE_KERNEL_OPTION_HEADERS
35#include "opt_device_polling.h"
36#endif
37

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

829 /* Start listening */
830 ARGE_WRITE(sc, AR71XX_DMA_RX_CONTROL, DMA_RX_CONTROL_EN);
831
832 /* Enable interrupts */
833 ARGE_WRITE(sc, AR71XX_DMA_INTR, DMA_INTR_ALL);
834}
835
836/*
30
31/*
32 * AR71XX gigabit ethernet driver
33 */
34#ifdef HAVE_KERNEL_OPTION_HEADERS
35#include "opt_device_polling.h"
36#endif
37

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

829 /* Start listening */
830 ARGE_WRITE(sc, AR71XX_DMA_RX_CONTROL, DMA_RX_CONTROL_EN);
831
832 /* Enable interrupts */
833 ARGE_WRITE(sc, AR71XX_DMA_INTR, DMA_INTR_ALL);
834}
835
836/*
837 * Return whether the mbuf chain is correctly aligned
838 * for the arge TX engine.
839 *
840 * The TX engine requires each fragment to be aligned to a
841 * 4 byte boundary and the size of each fragment except
842 * the last to be a multiple of 4 bytes.
843 */
844static int
845arge_mbuf_chain_is_tx_aligned(struct mbuf *m0)
846{
847 struct mbuf *m;
848
849 for (m = m0; m != NULL; m = m->m_next) {
850 if((mtod(m, intptr_t) & 3) != 0)
851 return 0;
852 if ((m->m_next != NULL) && ((m->m_len & 0x03) != 0))
853 return 0;
854 }
855 return 1;
856}
857
858/*
837 * Encapsulate an mbuf chain in a descriptor by coupling the mbuf data
838 * pointers to the fragment pointers.
839 */
840static int
841arge_encap(struct arge_softc *sc, struct mbuf **m_head)
842{
843 struct arge_txdesc *txd;
844 struct arge_desc *desc, *prev_desc;
845 bus_dma_segment_t txsegs[ARGE_MAXFRAGS];
846 int error, i, nsegs, prod, prev_prod;
847 struct mbuf *m;
848
849 ARGE_LOCK_ASSERT(sc);
850
851 /*
852 * Fix mbuf chain, all fragments should be 4 bytes aligned and
853 * even 4 bytes
854 */
855 m = *m_head;
859 * Encapsulate an mbuf chain in a descriptor by coupling the mbuf data
860 * pointers to the fragment pointers.
861 */
862static int
863arge_encap(struct arge_softc *sc, struct mbuf **m_head)
864{
865 struct arge_txdesc *txd;
866 struct arge_desc *desc, *prev_desc;
867 bus_dma_segment_t txsegs[ARGE_MAXFRAGS];
868 int error, i, nsegs, prod, prev_prod;
869 struct mbuf *m;
870
871 ARGE_LOCK_ASSERT(sc);
872
873 /*
874 * Fix mbuf chain, all fragments should be 4 bytes aligned and
875 * even 4 bytes
876 */
877 m = *m_head;
856 if((mtod(m, intptr_t) & 3) != 0) {
878 if (! arge_mbuf_chain_is_tx_aligned(m)) {
857 m = m_defrag(*m_head, M_DONTWAIT);
858 if (m == NULL) {
859 *m_head = NULL;
860 return (ENOBUFS);
861 }
862 *m_head = m;
863 }
864

--- 963 unchanged lines hidden ---
879 m = m_defrag(*m_head, M_DONTWAIT);
880 if (m == NULL) {
881 *m_head = NULL;
882 return (ENOBUFS);
883 }
884 *m_head = m;
885 }
886

--- 963 unchanged lines hidden ---