Deleted Added
full compact
if_ti.c (64139) if_ti.c (64837)
1/*
2 * Copyright (c) 1997, 1998, 1999
3 * Bill Paul <wpaul@ctr.columbia.edu>. 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

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

24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 *
1/*
2 * Copyright (c) 1997, 1998, 1999
3 * Bill Paul <wpaul@ctr.columbia.edu>. 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

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

24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 * $FreeBSD: head/sys/dev/ti/if_ti.c 64139 2000-08-02 18:49:17Z wpaul $
32 * $FreeBSD: head/sys/dev/ti/if_ti.c 64837 2000-08-19 08:32:59Z dwmalone $
33 */
34
35/*
36 * Alteon Networks Tigon PCI gigabit ethernet driver for FreeBSD.
37 * Manuals, sample driver and firmware source kits are available
38 * from http://www.alteon.com/support/openkits.
39 *
40 * Written by Bill Paul <wpaul@ctr.columbia.edu>

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

121#include <pci/if_tireg.h>
122#include <pci/ti_fw.h>
123#include <pci/ti_fw2.h>
124
125#define TI_CSUM_FEATURES (CSUM_IP | CSUM_TCP | CSUM_UDP | CSUM_IP_FRAGS)
126
127#if !defined(lint)
128static const char rcsid[] =
33 */
34
35/*
36 * Alteon Networks Tigon PCI gigabit ethernet driver for FreeBSD.
37 * Manuals, sample driver and firmware source kits are available
38 * from http://www.alteon.com/support/openkits.
39 *
40 * Written by Bill Paul <wpaul@ctr.columbia.edu>

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

121#include <pci/if_tireg.h>
122#include <pci/ti_fw.h>
123#include <pci/ti_fw2.h>
124
125#define TI_CSUM_FEATURES (CSUM_IP | CSUM_TCP | CSUM_UDP | CSUM_IP_FRAGS)
126
127#if !defined(lint)
128static const char rcsid[] =
129 "$FreeBSD: head/sys/dev/ti/if_ti.c 64139 2000-08-02 18:49:17Z wpaul $";
129 "$FreeBSD: head/sys/dev/ti/if_ti.c 64837 2000-08-19 08:32:59Z dwmalone $";
130#endif
131
132/*
133 * Various supported device vendors/types and their names.
134 */
135
136static struct ti_type ti_devs[] = {
137 { ALT_VENDORID, ALT_DEVICEID_ACENIC,

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

185 u_int32_t, caddr_t));
186static void ti_loadfw __P((struct ti_softc *));
187static void ti_cmd __P((struct ti_softc *, struct ti_cmd_desc *));
188static void ti_cmd_ext __P((struct ti_softc *, struct ti_cmd_desc *,
189 caddr_t, int));
190static void ti_handle_events __P((struct ti_softc *));
191static int ti_alloc_jumbo_mem __P((struct ti_softc *));
192static void *ti_jalloc __P((struct ti_softc *));
130#endif
131
132/*
133 * Various supported device vendors/types and their names.
134 */
135
136static struct ti_type ti_devs[] = {
137 { ALT_VENDORID, ALT_DEVICEID_ACENIC,

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

185 u_int32_t, caddr_t));
186static void ti_loadfw __P((struct ti_softc *));
187static void ti_cmd __P((struct ti_softc *, struct ti_cmd_desc *));
188static void ti_cmd_ext __P((struct ti_softc *, struct ti_cmd_desc *,
189 caddr_t, int));
190static void ti_handle_events __P((struct ti_softc *));
191static int ti_alloc_jumbo_mem __P((struct ti_softc *));
192static void *ti_jalloc __P((struct ti_softc *));
193static void ti_jfree __P((caddr_t, u_int));
194static void ti_jref __P((caddr_t, u_int));
193static void ti_jfree __P((caddr_t, void *));
195static int ti_newbuf_std __P((struct ti_softc *, int, struct mbuf *));
196static int ti_newbuf_mini __P((struct ti_softc *, int, struct mbuf *));
197static int ti_newbuf_jumbo __P((struct ti_softc *, int, struct mbuf *));
198static int ti_init_rx_ring_std __P((struct ti_softc *));
199static void ti_free_rx_ring_std __P((struct ti_softc *));
200static int ti_init_rx_ring_jumbo __P((struct ti_softc *));
201static void ti_free_rx_ring_jumbo __P((struct ti_softc *));
202static int ti_init_rx_ring_mini __P((struct ti_softc *));

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

624 */
625 ptr = sc->ti_cdata.ti_jumbo_buf;
626 for (i = 0; i < TI_JSLOTS; i++) {
627 u_int64_t **aptr;
628 aptr = (u_int64_t **)ptr;
629 aptr[0] = (u_int64_t *)sc;
630 ptr += sizeof(u_int64_t);
631 sc->ti_cdata.ti_jslots[i].ti_buf = ptr;
194static int ti_newbuf_std __P((struct ti_softc *, int, struct mbuf *));
195static int ti_newbuf_mini __P((struct ti_softc *, int, struct mbuf *));
196static int ti_newbuf_jumbo __P((struct ti_softc *, int, struct mbuf *));
197static int ti_init_rx_ring_std __P((struct ti_softc *));
198static void ti_free_rx_ring_std __P((struct ti_softc *));
199static int ti_init_rx_ring_jumbo __P((struct ti_softc *));
200static void ti_free_rx_ring_jumbo __P((struct ti_softc *));
201static int ti_init_rx_ring_mini __P((struct ti_softc *));

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

623 */
624 ptr = sc->ti_cdata.ti_jumbo_buf;
625 for (i = 0; i < TI_JSLOTS; i++) {
626 u_int64_t **aptr;
627 aptr = (u_int64_t **)ptr;
628 aptr[0] = (u_int64_t *)sc;
629 ptr += sizeof(u_int64_t);
630 sc->ti_cdata.ti_jslots[i].ti_buf = ptr;
632 sc->ti_cdata.ti_jslots[i].ti_inuse = 0;
633 ptr += (TI_JLEN - sizeof(u_int64_t));
634 entry = malloc(sizeof(struct ti_jpool_entry),
635 M_DEVBUF, M_NOWAIT);
636 if (entry == NULL) {
637 contigfree(sc->ti_cdata.ti_jumbo_buf, TI_JMEM,
638 M_DEVBUF);
639 sc->ti_cdata.ti_jumbo_buf = NULL;
640 printf("ti%d: no memory for jumbo "

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

660
661 if (entry == NULL) {
662 printf("ti%d: no free jumbo buffers\n", sc->ti_unit);
663 return(NULL);
664 }
665
666 SLIST_REMOVE_HEAD(&sc->ti_jfree_listhead, jpool_entries);
667 SLIST_INSERT_HEAD(&sc->ti_jinuse_listhead, entry, jpool_entries);
631 ptr += (TI_JLEN - sizeof(u_int64_t));
632 entry = malloc(sizeof(struct ti_jpool_entry),
633 M_DEVBUF, M_NOWAIT);
634 if (entry == NULL) {
635 contigfree(sc->ti_cdata.ti_jumbo_buf, TI_JMEM,
636 M_DEVBUF);
637 sc->ti_cdata.ti_jumbo_buf = NULL;
638 printf("ti%d: no memory for jumbo "

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

658
659 if (entry == NULL) {
660 printf("ti%d: no free jumbo buffers\n", sc->ti_unit);
661 return(NULL);
662 }
663
664 SLIST_REMOVE_HEAD(&sc->ti_jfree_listhead, jpool_entries);
665 SLIST_INSERT_HEAD(&sc->ti_jinuse_listhead, entry, jpool_entries);
668 sc->ti_cdata.ti_jslots[entry->slot].ti_inuse = 1;
669 return(sc->ti_cdata.ti_jslots[entry->slot].ti_buf);
670}
671
672/*
666 return(sc->ti_cdata.ti_jslots[entry->slot].ti_buf);
667}
668
669/*
673 * Adjust usage count on a jumbo buffer. In general this doesn't
674 * get used much because our jumbo buffers don't get passed around
675 * too much, but it's implemented for correctness.
676 */
677static void ti_jref(buf, size)
678 caddr_t buf;
679 u_int size;
680{
681 struct ti_softc *sc;
682 u_int64_t **aptr;
683 register int i;
684
685 /* Extract the softc struct pointer. */
686 aptr = (u_int64_t **)(buf - sizeof(u_int64_t));
687 sc = (struct ti_softc *)(aptr[0]);
688
689 if (sc == NULL)
690 panic("ti_jref: can't find softc pointer!");
691
692 if (size != TI_JUMBO_FRAMELEN)
693 panic("ti_jref: adjusting refcount of buf of wrong size!");
694
695 /* calculate the slot this buffer belongs to */
696
697 i = ((vm_offset_t)aptr
698 - (vm_offset_t)sc->ti_cdata.ti_jumbo_buf) / TI_JLEN;
699
700 if ((i < 0) || (i >= TI_JSLOTS))
701 panic("ti_jref: asked to reference buffer "
702 "that we don't manage!");
703 else if (sc->ti_cdata.ti_jslots[i].ti_inuse == 0)
704 panic("ti_jref: buffer already free!");
705 else
706 sc->ti_cdata.ti_jslots[i].ti_inuse++;
707
708 return;
709}
710
711/*
712 * Release a jumbo buffer.
713 */
670 * Release a jumbo buffer.
671 */
714static void ti_jfree(buf, size)
672static void ti_jfree(buf, args)
715 caddr_t buf;
673 caddr_t buf;
716 u_int size;
674 void *args;
717{
718 struct ti_softc *sc;
719 u_int64_t **aptr;
720 int i;
721 struct ti_jpool_entry *entry;
722
723 /* Extract the softc struct pointer. */
724 aptr = (u_int64_t **)(buf - sizeof(u_int64_t));
725 sc = (struct ti_softc *)(aptr[0]);
726
727 if (sc == NULL)
728 panic("ti_jfree: can't find softc pointer!");
729
675{
676 struct ti_softc *sc;
677 u_int64_t **aptr;
678 int i;
679 struct ti_jpool_entry *entry;
680
681 /* Extract the softc struct pointer. */
682 aptr = (u_int64_t **)(buf - sizeof(u_int64_t));
683 sc = (struct ti_softc *)(aptr[0]);
684
685 if (sc == NULL)
686 panic("ti_jfree: can't find softc pointer!");
687
730 if (size != TI_JUMBO_FRAMELEN)
731 panic("ti_jfree: freeing buffer of wrong size!");
732
733 /* calculate the slot this buffer belongs to */
688 /* calculate the slot this buffer belongs to */
734
735 i = ((vm_offset_t)aptr
736 - (vm_offset_t)sc->ti_cdata.ti_jumbo_buf) / TI_JLEN;
737
738 if ((i < 0) || (i >= TI_JSLOTS))
739 panic("ti_jfree: asked to free buffer that we don't manage!");
689 i = ((vm_offset_t)aptr
690 - (vm_offset_t)sc->ti_cdata.ti_jumbo_buf) / TI_JLEN;
691
692 if ((i < 0) || (i >= TI_JSLOTS))
693 panic("ti_jfree: asked to free buffer that we don't manage!");
740 else if (sc->ti_cdata.ti_jslots[i].ti_inuse == 0)
741 panic("ti_jfree: buffer already free!");
742 else {
743 sc->ti_cdata.ti_jslots[i].ti_inuse--;
744 if(sc->ti_cdata.ti_jslots[i].ti_inuse == 0) {
745 entry = SLIST_FIRST(&sc->ti_jinuse_listhead);
746 if (entry == NULL)
747 panic("ti_jfree: buffer not in use!");
748 entry->slot = i;
749 SLIST_REMOVE_HEAD(&sc->ti_jinuse_listhead,
750 jpool_entries);
751 SLIST_INSERT_HEAD(&sc->ti_jfree_listhead,
752 entry, jpool_entries);
753 }
754 }
755
694
695 entry = SLIST_FIRST(&sc->ti_jinuse_listhead);
696 if (entry == NULL)
697 panic("ti_jfree: buffer not in use!");
698 entry->slot = i;
699 SLIST_REMOVE_HEAD(&sc->ti_jinuse_listhead, jpool_entries);
700 SLIST_INSERT_HEAD(&sc->ti_jfree_listhead, entry, jpool_entries);
701
756 return;
757}
758
759
760/*
761 * Intialize a standard receive ring descriptor.
762 */
763static int ti_newbuf_std(sc, i, m)

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

872 if (buf == NULL) {
873 m_freem(m_new);
874 printf("ti%d: jumbo allocation failed "
875 "-- packet dropped!\n", sc->ti_unit);
876 return(ENOBUFS);
877 }
878
879 /* Attach the buffer to the mbuf. */
702 return;
703}
704
705
706/*
707 * Intialize a standard receive ring descriptor.
708 */
709static int ti_newbuf_std(sc, i, m)

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

818 if (buf == NULL) {
819 m_freem(m_new);
820 printf("ti%d: jumbo allocation failed "
821 "-- packet dropped!\n", sc->ti_unit);
822 return(ENOBUFS);
823 }
824
825 /* Attach the buffer to the mbuf. */
880 m_new->m_data = m_new->m_ext.ext_buf = (void *)buf;
881 m_new->m_flags |= M_EXT;
882 m_new->m_len = m_new->m_pkthdr.len =
883 m_new->m_ext.ext_size = TI_JUMBO_FRAMELEN;
884 m_new->m_ext.ext_free = ti_jfree;
885 m_new->m_ext.ext_ref = ti_jref;
826 m_new->m_data = (void *) buf;
827 m_new->m_len = m_new->m_pkthdr.len = TI_JUMBO_FRAMELEN;
828 MEXTADD(m_new, buf, TI_JUMBO_FRAMELEN, ti_jfree, NULL);
886 } else {
887 m_new = m;
888 m_new->m_data = m_new->m_ext.ext_buf;
889 m_new->m_ext.ext_size = TI_JUMBO_FRAMELEN;
890 }
891
892 m_adj(m_new, ETHER_ALIGN);
893 /* Set up the descriptor. */

--- 1683 unchanged lines hidden ---
829 } else {
830 m_new = m;
831 m_new->m_data = m_new->m_ext.ext_buf;
832 m_new->m_ext.ext_size = TI_JUMBO_FRAMELEN;
833 }
834
835 m_adj(m_new, ETHER_ALIGN);
836 /* Set up the descriptor. */

--- 1683 unchanged lines hidden ---