if_mn.c (106626) | if_mn.c (109623) |
---|---|
1/* 2 * ---------------------------------------------------------------------------- 3 * "THE BEER-WARE LICENSE" (Revision 42): 4 * <phk@FreeBSD.org> wrote this file. As long as you retain this notice you 5 * can do whatever you want with this stuff. If we meet some day, and you think 6 * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp 7 * ---------------------------------------------------------------------------- 8 * --- 7 unchanged lines hidden (view full) --- 16 * The driver supports E1 mode with up to 31 channels. We send CRC4 but don't 17 * check it coming in. 18 * 19 * The FALC54 and MUNICH32X have far too many registers and weird modes for 20 * comfort, so I have not bothered typing it all into a "fooreg.h" file, 21 * you will (badly!) need the documentation anyway if you want to mess with 22 * this gadget. 23 * | 1/* 2 * ---------------------------------------------------------------------------- 3 * "THE BEER-WARE LICENSE" (Revision 42): 4 * <phk@FreeBSD.org> wrote this file. As long as you retain this notice you 5 * can do whatever you want with this stuff. If we meet some day, and you think 6 * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp 7 * ---------------------------------------------------------------------------- 8 * --- 7 unchanged lines hidden (view full) --- 16 * The driver supports E1 mode with up to 31 channels. We send CRC4 but don't 17 * check it coming in. 18 * 19 * The FALC54 and MUNICH32X have far too many registers and weird modes for 20 * comfort, so I have not bothered typing it all into a "fooreg.h" file, 21 * you will (badly!) need the documentation anyway if you want to mess with 22 * this gadget. 23 * |
24 * $FreeBSD: head/sys/pci/if_mn.c 106626 2002-11-08 14:57:18Z jhb $ | 24 * $FreeBSD: head/sys/pci/if_mn.c 109623 2003-01-21 08:56:16Z alfred $ |
25 */ 26 27/* 28 * Stuff to describe the MUNIC32X and FALC54 chips. 29 */ 30 31#define M32_CHAN 32 /* We have 32 channels */ 32#define M32_TS 32 /* We have 32 timeslots */ --- 657 unchanged lines hidden (view full) --- 690 if (nts == 32) 691 sc->m32_mem.cs[chan].itbs = 63; 692 else 693 sc->m32_mem.cs[chan].itbs = nts * 2; 694 695 /* Setup a transmit chain with one descriptor */ 696 /* XXX: we actually send a 1 byte packet */ 697 dp = mn_alloc_desc(); | 25 */ 26 27/* 28 * Stuff to describe the MUNIC32X and FALC54 chips. 29 */ 30 31#define M32_CHAN 32 /* We have 32 channels */ 32#define M32_TS 32 /* We have 32 timeslots */ --- 657 unchanged lines hidden (view full) --- 690 if (nts == 32) 691 sc->m32_mem.cs[chan].itbs = 63; 692 else 693 sc->m32_mem.cs[chan].itbs = nts * 2; 694 695 /* Setup a transmit chain with one descriptor */ 696 /* XXX: we actually send a 1 byte packet */ 697 dp = mn_alloc_desc(); |
698 MGETHDR(m, M_TRYWAIT, MT_DATA); | 698 MGETHDR(m, 0, MT_DATA); |
699 if (m == NULL) 700 return ENOBUFS; 701 m->m_pkthdr.len = 0; 702 dp->m = m; 703 dp->flags = 0xc0000000 + (1 << 16); 704 dp->next = vtophys(dp); 705 dp->vnext = 0; 706 dp->data = vtophys(sc->name); 707 sc->m32_mem.cs[chan].tdesc = vtophys(dp); 708 sc->ch[chan]->x1 = dp; 709 sc->ch[chan]->xl = dp; 710 711 /* Setup a receive chain with 5 + NTS descriptors */ 712 713 dp = mn_alloc_desc(); 714 m = NULL; | 699 if (m == NULL) 700 return ENOBUFS; 701 m->m_pkthdr.len = 0; 702 dp->m = m; 703 dp->flags = 0xc0000000 + (1 << 16); 704 dp->next = vtophys(dp); 705 dp->vnext = 0; 706 dp->data = vtophys(sc->name); 707 sc->m32_mem.cs[chan].tdesc = vtophys(dp); 708 sc->ch[chan]->x1 = dp; 709 sc->ch[chan]->xl = dp; 710 711 /* Setup a receive chain with 5 + NTS descriptors */ 712 713 dp = mn_alloc_desc(); 714 m = NULL; |
715 MGETHDR(m, M_TRYWAIT, MT_DATA); | 715 MGETHDR(m, 0, MT_DATA); |
716 if (m == NULL) { 717 mn_free_desc(dp); 718 return (ENOBUFS); 719 } | 716 if (m == NULL) { 717 mn_free_desc(dp); 718 return (ENOBUFS); 719 } |
720 MCLGET(m, M_TRYWAIT); | 720 MCLGET(m, 0); |
721 if ((m->m_flags & M_EXT) == 0) { 722 mn_free_desc(dp); 723 m_freem(m); 724 return (ENOBUFS); 725 } 726 dp->m = m; 727 dp->data = vtophys(m->m_data); 728 dp->flags = 0x40000000; 729 dp->flags += 1600 << 16; 730 dp->next = vtophys(dp); 731 dp->vnext = 0; 732 sc->ch[chan]->rl = dp; 733 734 for (i = 0; i < (nts + 10); i++) { 735 dp2 = dp; 736 dp = mn_alloc_desc(); 737 m = NULL; | 721 if ((m->m_flags & M_EXT) == 0) { 722 mn_free_desc(dp); 723 m_freem(m); 724 return (ENOBUFS); 725 } 726 dp->m = m; 727 dp->data = vtophys(m->m_data); 728 dp->flags = 0x40000000; 729 dp->flags += 1600 << 16; 730 dp->next = vtophys(dp); 731 dp->vnext = 0; 732 sc->ch[chan]->rl = dp; 733 734 for (i = 0; i < (nts + 10); i++) { 735 dp2 = dp; 736 dp = mn_alloc_desc(); 737 m = NULL; |
738 MGETHDR(m, M_TRYWAIT, MT_DATA); | 738 MGETHDR(m, 0, MT_DATA); |
739 if (m == NULL) { 740 mn_free_desc(dp); 741 m_freem(m); 742 return (ENOBUFS); 743 } | 739 if (m == NULL) { 740 mn_free_desc(dp); 741 m_freem(m); 742 return (ENOBUFS); 743 } |
744 MCLGET(m, M_TRYWAIT); | 744 MCLGET(m, 0); |
745 if ((m->m_flags & M_EXT) == 0) { 746 mn_free_desc(dp); 747 m_freem(m); 748 return (ENOBUFS); 749 } 750 dp->m = m; 751 dp->data = vtophys(m->m_data); 752 dp->flags = 0x00000000; --- 81 unchanged lines hidden (view full) --- 834 * Create a new channel. 835 */ 836static void 837mn_create_channel(struct mn_softc *sc, int chan) 838{ 839 struct schan *sch; 840 841 sch = sc->ch[chan] = (struct schan *)malloc(sizeof *sc->ch[chan], | 745 if ((m->m_flags & M_EXT) == 0) { 746 mn_free_desc(dp); 747 m_freem(m); 748 return (ENOBUFS); 749 } 750 dp->m = m; 751 dp->data = vtophys(m->m_data); 752 dp->flags = 0x00000000; --- 81 unchanged lines hidden (view full) --- 834 * Create a new channel. 835 */ 836static void 837mn_create_channel(struct mn_softc *sc, int chan) 838{ 839 struct schan *sch; 840 841 sch = sc->ch[chan] = (struct schan *)malloc(sizeof *sc->ch[chan], |
842 M_MN, M_WAITOK | M_ZERO); | 842 M_MN, M_ZERO); |
843 sch->sc = sc; 844 sch->state = DOWN; 845 sch->chan = chan; 846 sprintf(sch->name, "%s%d", sc->name, chan); 847 return; 848} 849 850#ifdef notyet --- 327 unchanged lines hidden (view full) --- 1178 sch->prev_error = sch->last_error; 1179 sch->last_error = err; 1180 } 1181 1182 sc->ch[chan]->r1 = dp->vnext; 1183 1184 /* Replenish desc + mbuf supplies */ 1185 if (!m) { | 843 sch->sc = sc; 844 sch->state = DOWN; 845 sch->chan = chan; 846 sprintf(sch->name, "%s%d", sc->name, chan); 847 return; 848} 849 850#ifdef notyet --- 327 unchanged lines hidden (view full) --- 1178 sch->prev_error = sch->last_error; 1179 sch->last_error = err; 1180 } 1181 1182 sc->ch[chan]->r1 = dp->vnext; 1183 1184 /* Replenish desc + mbuf supplies */ 1185 if (!m) { |
1186 MGETHDR(m, M_DONTWAIT, MT_DATA); | 1186 MGETHDR(m, M_NOWAIT, MT_DATA); |
1187 if (m == NULL) { 1188 mn_free_desc(dp); 1189 return; /* ENOBUFS */ 1190 } | 1187 if (m == NULL) { 1188 mn_free_desc(dp); 1189 return; /* ENOBUFS */ 1190 } |
1191 MCLGET(m, M_DONTWAIT); | 1191 MCLGET(m, M_NOWAIT); |
1192 if((m->m_flags & M_EXT) == 0) { 1193 mn_free_desc(dp); 1194 m_freem(m); 1195 return; /* ENOBUFS */ 1196 } 1197 } 1198 dp->m = m; 1199 dp->data = vtophys(m->m_data); --- 135 unchanged lines hidden (view full) --- 1335 struct resource *res; 1336 1337 if (!once) { 1338 if (ng_newtype(&mntypestruct)) 1339 printf("ng_newtype failed\n"); 1340 once++; 1341 } 1342 | 1192 if((m->m_flags & M_EXT) == 0) { 1193 mn_free_desc(dp); 1194 m_freem(m); 1195 return; /* ENOBUFS */ 1196 } 1197 } 1198 dp->m = m; 1199 dp->data = vtophys(m->m_data); --- 135 unchanged lines hidden (view full) --- 1335 struct resource *res; 1336 1337 if (!once) { 1338 if (ng_newtype(&mntypestruct)) 1339 printf("ng_newtype failed\n"); 1340 once++; 1341 } 1342 |
1343 sc = (struct mn_softc *)malloc(sizeof *sc, M_MN, M_WAITOK | M_ZERO); | 1343 sc = (struct mn_softc *)malloc(sizeof *sc, M_MN, M_ZERO); |
1344 device_set_softc(self, sc); 1345 1346 sc->dev = self; 1347 sc->unit = device_get_unit(self); 1348 sc->framing = E1; 1349 sprintf(sc->name, "mn%d", sc->unit); 1350 1351 rid = PCIR_MAPS; --- 124 unchanged lines hidden --- | 1344 device_set_softc(self, sc); 1345 1346 sc->dev = self; 1347 sc->unit = device_get_unit(self); 1348 sc->framing = E1; 1349 sprintf(sc->name, "mn%d", sc->unit); 1350 1351 rid = PCIR_MAPS; --- 124 unchanged lines hidden --- |