Date: Mon, 22 Mar 2021 19:07:23 GMT From: Ed Maste <emaste@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 0cff00ae682a - main - retire obsolete mn(4) sync serial driver Message-ID: <202103221907.12MJ7NJq051686@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=0cff00ae682a032dec29494f88c76d78a08edfa1 commit 0cff00ae682a032dec29494f88c76d78a08edfa1 Author: Ed Maste <emaste@FreeBSD.org> AuthorDate: 2021-03-22 19:06:51 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2021-03-22 19:06:51 +0000 retire obsolete mn(4) sync serial driver Approved by: phk Relnotes: yes --- ObsoleteFiles.inc | 4 + share/man/man4/Makefile | 2 - share/man/man4/mn.4 | 61 -- sys/conf/NOTES | 2 - sys/conf/files | 1 - sys/dev/mn/if_mn.c | 1431 ----------------------------------------------- 6 files changed, 4 insertions(+), 1497 deletions(-) diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc index 2132dc4289b4..f4c6909cc10a 100644 --- a/ObsoleteFiles.inc +++ b/ObsoleteFiles.inc @@ -36,6 +36,10 @@ # xargs -n1 | sort | uniq -d; # done +# 20210322: retire mn(4) sync serial driver +OLD_FILES+=usr/share/man/man4/if_mn.4.gz +OLD_FILES+=usr/share/man/man4/mn.4.gz + # 20210318: remove the terminfo database OLD_FILES+=usr/share/terminfo/1/1178 OLD_FILES+=usr/share/terminfo/1/1730-lm diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile index c29bb80c7a58..f5a8f98b5bab 100644 --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -307,7 +307,6 @@ MAN= aac.4 \ mly.4 \ mmc.4 \ mmcsd.4 \ - mn.4 \ mod_cc.4 \ mos.4 \ mouse.4 \ @@ -710,7 +709,6 @@ MLINKS+=mem.4 kmem.4 MLINKS+=mfi.4 mfi_linux.4 \ mfi.4 mfip.4 MLINKS+=mlx5en.4 mce.4 -MLINKS+=mn.4 if_mn.4 MLINKS+=mos.4 if_mos.4 MLINKS+=msk.4 if_msk.4 MLINKS+=mwl.4 if_mwl.4 diff --git a/share/man/man4/mn.4 b/share/man/man4/mn.4 deleted file mode 100644 index f034a1b10d45..000000000000 --- a/share/man/man4/mn.4 +++ /dev/null @@ -1,61 +0,0 @@ -.\" Copyright (c) 2005 Christian Brueffer -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND ITS AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR THE CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.\" -.Dd December 6, 2020 -.Dt MN 4 -.Os -.Sh NAME -.Nm mn -.Nd "Siemens Easy321-R1 E1/T1 device driver" -.Sh SYNOPSIS -.Cd "device mn" -.Cd "options NETGRAPH" -.Sh DEPRECATION NOTICE -The -.Nm -driver is not present in -.Fx 13.0 -and later. -.Sh HARDWARE -The -.Nm -driver provides support for the Siemens Easy321-R1 E1/T1 reference -design card. -.Sh SEE ALSO -.Xr netgraph 4 , -.Xr netintro 4 , -.Xr pci 4 , -.Xr ifconfig 8 -.Sh HISTORY -The -.Nm -driver first appeared in -.Fx 4.0 . -.Sh AUTHORS -The -.Nm -driver was written by -.An Poul-Henning Kamp Aq Mt phk@FreeBSD.org . diff --git a/sys/conf/NOTES b/sys/conf/NOTES index f73b5a466366..0d9a64a88b0f 100644 --- a/sys/conf/NOTES +++ b/sys/conf/NOTES @@ -824,8 +824,6 @@ options NGATM_SSCFU options NGATM_UNI options NGATM_CCATM -device mn # Munich32x/Falc54 Nx64kbit/sec cards. - # Network stack virtualization. options VIMAGE options VNET_DEBUG # debug for VIMAGE diff --git a/sys/conf/files b/sys/conf/files index ea2bd6db4ab0..c3f36ca07022 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -2475,7 +2475,6 @@ dev/mmc/mmcbus_if.m standard dev/mmc/mmcsd.c optional mmcsd !mmccam dev/mmc/mmc_fdt_helpers.c optional mmc fdt | mmccam fdt dev/mmcnull/mmcnull.c optional mmcnull -dev/mn/if_mn.c optional mn pci dev/mpr/mpr.c optional mpr dev/mpr/mpr_config.c optional mpr # XXX Work around clang warning, until maintainer approves fix. diff --git a/sys/dev/mn/if_mn.c b/sys/dev/mn/if_mn.c deleted file mode 100644 index bb329b24c24e..000000000000 --- a/sys/dev/mn/if_mn.c +++ /dev/null @@ -1,1431 +0,0 @@ -/*- - * SPDX-License-Identifier: Beerware - * - * ---------------------------------------------------------------------------- - * "THE BEER-WARE LICENSE" (Revision 42): - * <phk@FreeBSD.org> wrote this file. As long as you retain this notice you - * can do whatever you want with this stuff. If we meet some day, and you think - * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp - * ---------------------------------------------------------------------------- - */ - -/* - * Driver for Siemens reference design card "Easy321-R1". - * - * This card contains a FALC54 E1/T1 framer and a MUNICH32X 32-channel HDLC - * controller. - * - * The driver supports E1 mode with up to 31 channels. We send CRC4 but don't - * check it coming in. - * - * The FALC54 and MUNICH32X have far too many registers and weird modes for - * comfort, so I have not bothered typing it all into a "fooreg.h" file, - * you will (badly!) need the documentation anyway if you want to mess with - * this gadget. - */ - -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -/* - * Stuff to describe the MUNIC32X and FALC54 chips. - */ - -#define M32_CHAN 32 /* We have 32 channels */ -#define M32_TS 32 /* We have 32 timeslots */ - -#define NG_MN_NODE_TYPE "mn" - -#include <sys/param.h> -#include <sys/kernel.h> -#include <sys/sysctl.h> -#include <sys/bus.h> -#include <sys/mbuf.h> -#include <sys/systm.h> -#include <sys/malloc.h> - -#include <dev/pci/pcireg.h> -#include <dev/pci/pcivar.h> -#include "pci_if.h" - -#include <machine/bus.h> -#include <machine/resource.h> - -#include <sys/rman.h> - -#include <vm/vm.h> -#include <vm/pmap.h> - -#include <netgraph/ng_message.h> -#include <netgraph/netgraph.h> - - -static int mn_maxlatency = 1000; -SYSCTL_INT(_debug, OID_AUTO, mn_maxlatency, CTLFLAG_RW, - &mn_maxlatency, 0, - "The number of milliseconds a packet is allowed to spend in the output queue. " - "If the output queue is longer than this number of milliseconds when the packet " - "arrives for output, the packet will be dropped." -); - -#ifndef NMN -/* Most machines don't support more than 4 busmaster PCI slots, if even that many */ -#define NMN 4 -#endif - -/* From: PEB 20321 data sheet, p187, table 22 */ -struct m32xreg { - u_int32_t conf, cmd, stat, imask; - u_int32_t fill10, piqba, piql, fill1c; - u_int32_t mode1, mode2, ccba, txpoll; - u_int32_t tiqba, tiql, riqba, riql; - u_int32_t lconf, lccba, fill48, ltran; - u_int32_t ltiqba, ltiql, lriqba, lriql; - u_int32_t lreg0, lreg1, lreg2, lreg3; - u_int32_t lreg4, lreg5, lre6, lstat; - u_int32_t gpdir, gpdata, gpod, fill8c; - u_int32_t ssccon, sscbr, ssctb, sscrb; - u_int32_t ssccse, sscim, fillab, fillac; - u_int32_t iomcon1, iomcon2, iomstat, fillbc; - u_int32_t iomcit0, iomcit1, iomcir0, iomcir1; - u_int32_t iomtmo, iomrmo, filld8, filldc; - u_int32_t mbcmd, mbdata1, mbdata2, mbdata3; - u_int32_t mbdata4, mbdata5, mbdata6, mbdata7; -}; - -/* From: PEB 2254 data sheet, p80, table 10 */ -struct f54wreg { - u_int16_t xfifo; - u_int8_t cmdr, mode, rah1, rah2, ral1, ral2; - u_int8_t ipc, ccr1, ccr3, pre, rtr1, rtr2, rtr3, rtr4; - u_int8_t ttr1, ttr2, ttr3, ttr4, imr0, imr1, imr2, imr3; - u_int8_t imr4, fill19, fmr0, fmr1, fmr2, loop, xsw, xsp; - u_int8_t xc0, xc1, rc0, rc1, xpm0, xpm1, xpm2, tswm; - u_int8_t test1, idle, xsa4, xsa5, xsa6, xsa7, xsa8, fmr3; - u_int8_t icb1, icb2, icb3, icb4, lim0, lim1, pcd, pcr; - u_int8_t lim2, fill39[7]; - u_int8_t fill40[8]; - u_int8_t fill48[8]; - u_int8_t fill50[8]; - u_int8_t fill58[8]; - u_int8_t dec, fill61, test2, fill63[5]; - u_int8_t fill68[8]; - u_int8_t xs[16]; -}; - -/* From: PEB 2254 data sheet, p117, table 10 */ -struct f54rreg { - u_int16_t rfifo; - u_int8_t fill2, mode, rah1, rah2, ral1, ral2; - u_int8_t ipc, ccr1, ccr3, pre, rtr1, rtr2, rtr3, rtr4; - u_int8_t ttr1, ttr2, ttr3, ttr4, imr0, imr1, imr2, imr3; - u_int8_t imr4, fill19, fmr0, fmr1, fmr2, loop, xsw, xsp; - u_int8_t xc0, xc1, rc0, rc1, xpm0, xpm1, xpm2, tswm; - u_int8_t test, idle, xsa4, xsa5, xsa6, xsa7, xsa8, fmr13; - u_int8_t icb1, icb2, icb3, icb4, lim0, lim1, pcd, pcr; - u_int8_t lim2, fill39[7]; - u_int8_t fill40[8]; - u_int8_t fill48[4], frs0, frs1, rsw, rsp; - u_int16_t fec, cvc, cec1, ebc; - u_int16_t cec2, cec3; - u_int8_t rsa4, rsa5, rsa6, rsa7; - u_int8_t rsa8, rsa6s, tsr0, tsr1, sis, rsis; - u_int16_t rbc; - u_int8_t isr0, isr1, isr2, isr3, fill6c, fill6d, gis, vstr; - u_int8_t rs[16]; -}; - -/* Transmit & receive descriptors */ -struct trxd { - u_int32_t flags; - vm_offset_t next; - vm_offset_t data; - u_int32_t status; /* only used for receive */ - struct mbuf *m; /* software use only */ - struct trxd *vnext; /* software use only */ -}; - -/* Channel specification */ -struct cspec { - u_int32_t flags; - vm_offset_t rdesc; - vm_offset_t tdesc; - u_int32_t itbs; -}; - -struct m32_mem { - vm_offset_t csa; - u_int32_t ccb; - u_int32_t reserve1[2]; - u_int32_t ts[M32_TS]; - struct cspec cs[M32_CHAN]; - vm_offset_t crxd[M32_CHAN]; - vm_offset_t ctxd[M32_CHAN]; -}; - -struct mn_softc; -struct sockaddr; - -static int mn_probe(device_t self); -static int mn_attach(device_t self); -static void mn_create_channel(struct mn_softc *sc, int chan); -static int mn_reset(struct mn_softc *sc); -static struct trxd * mn_alloc_desc(void); -static void mn_free_desc(struct trxd *dp); -static void mn_intr(void *xsc); -static u_int32_t mn_parse_ts(const char *s, int *nbit); -#ifdef notyet -static void m32_dump(struct mn_softc *sc); -static void f54_dump(struct mn_softc *sc); -static void mn_fmt_ts(char *p, u_int32_t ts); -#endif /* notyet */ -static void f54_init(struct mn_softc *sc); - -static ng_constructor_t ngmn_constructor; -static ng_rcvmsg_t ngmn_rcvmsg; -static ng_shutdown_t ngmn_shutdown; -static ng_newhook_t ngmn_newhook; -static ng_connect_t ngmn_connect; -static ng_rcvdata_t ngmn_rcvdata; -static ng_disconnect_t ngmn_disconnect; - -static struct ng_type mntypestruct = { - .version = NG_ABI_VERSION, - .name = NG_MN_NODE_TYPE, - .constructor = ngmn_constructor, - .rcvmsg = ngmn_rcvmsg, - .shutdown = ngmn_shutdown, - .newhook = ngmn_newhook, - .connect = ngmn_connect, - .rcvdata = ngmn_rcvdata, - .disconnect = ngmn_disconnect, -}; - -static MALLOC_DEFINE(M_MN, "mn", "Mx driver related"); - -#define NIQB 64 - -struct schan { - enum {DOWN, UP} state; - struct mn_softc *sc; - int chan; - u_int32_t ts; - char name[8]; - struct trxd *r1, *rl; - struct trxd *x1, *xl; - hook_p hook; - - time_t last_recv; - time_t last_rxerr; - time_t last_xmit; - - u_long rx_error; - - u_long short_error; - u_long crc_error; - u_long dribble_error; - u_long long_error; - u_long abort_error; - u_long overflow_error; - - int last_error; - int prev_error; - - u_long tx_pending; - u_long tx_limit; -}; - -enum framing {WHOKNOWS, E1, E1U, T1, T1U}; - -struct mn_softc { - int unit; - device_t dev; - struct resource *irq; - void *intrhand; - enum framing framing; - int nhooks; - void *m0v, *m1v; - vm_offset_t m0p, m1p; - struct m32xreg *m32x; - struct f54wreg *f54w; - struct f54rreg *f54r; - struct m32_mem m32_mem; - u_int32_t tiqb[NIQB]; - u_int32_t riqb[NIQB]; - u_int32_t piqb[NIQB]; - u_int32_t ltiqb[NIQB]; - u_int32_t lriqb[NIQB]; - char name[8]; - u_int32_t falc_irq, falc_state, framer_state; - struct schan *ch[M32_CHAN]; - char nodename[NG_NODESIZ]; - node_p node; - - u_long cnt_fec; - u_long cnt_cvc; - u_long cnt_cec1; - u_long cnt_ebc; - u_long cnt_cec2; - u_long cnt_cec3; - u_long cnt_rbc; -}; - -static int -ngmn_constructor(node_p node) -{ - - return (EINVAL); -} - -static int -ngmn_shutdown(node_p nodep) -{ - - return (EINVAL); -} - -static void -ngmn_config(node_p node, char *set, char *ret) -{ - struct mn_softc *sc; - enum framing wframing; - - sc = NG_NODE_PRIVATE(node); - - if (set != NULL) { - if (!strncmp(set, "line ", 5)) { - wframing = sc->framing; - if (!strcmp(set, "line e1")) { - wframing = E1; - } else if (!strcmp(set, "line e1u")) { - wframing = E1U; - } else { - strcat(ret, "ENOGROK\n"); - return; - } - if (wframing == sc->framing) - return; - if (sc->nhooks > 0) { - sprintf(ret, "Cannot change line when %d hooks open\n", sc->nhooks); - return; - } - sc->framing = wframing; -#if 1 - f54_init(sc); -#else - mn_reset(sc); -#endif - } else { - printf("%s CONFIG SET [%s]\n", sc->nodename, set); - strcat(ret, "ENOGROK\n"); - return; - } - } - -} - -static int -ngmn_rcvmsg(node_p node, item_p item, hook_p lasthook) -{ - struct mn_softc *sc; - struct ng_mesg *resp = NULL; - struct schan *sch; - char *s, *r; - int pos, i; - struct ng_mesg *msg; - - NGI_GET_MSG(item, msg); - sc = NG_NODE_PRIVATE(node); - - if (msg->header.typecookie != NGM_GENERIC_COOKIE) { - NG_FREE_ITEM(item); - NG_FREE_MSG(msg); - return (EINVAL); - } - - if (msg->header.cmd != NGM_TEXT_CONFIG && - msg->header.cmd != NGM_TEXT_STATUS) { - NG_FREE_ITEM(item); - NG_FREE_MSG(msg); - return (EINVAL); - } - - NG_MKRESPONSE(resp, msg, sizeof(struct ng_mesg) + NG_TEXTRESPONSE, - M_NOWAIT); - if (resp == NULL) { - NG_FREE_ITEM(item); - NG_FREE_MSG(msg); - return (ENOMEM); - } - - if (msg->header.arglen) - s = (char *)msg->data; - else - s = NULL; - r = (char *)resp->data; - *r = '\0'; - - if (msg->header.cmd == NGM_TEXT_CONFIG) { - ngmn_config(node, s, r); - resp->header.arglen = strlen(r) + 1; - NG_RESPOND_MSG(i, node, item, resp); - NG_FREE_MSG(msg); - return (0); - } - pos = 0; - pos += sprintf(pos + r,"Framer status %b;\n", sc->framer_state, "\20" - "\40LOS\37AIS\36LFA\35RRA" - "\34AUXP\33NMF\32LMFA\31frs0.0" - "\30frs1.7\27TS16RA\26TS16LOS\25TS16AIS" - "\24TS16LFA\23frs1.2\22XLS\21XLO" - "\20RS1\17rsw.6\16RRA\15RY0" - "\14RY1\13RY2\12RY3\11RY4" - "\10SI1\7SI2\6rsp.5\5rsp.4" - "\4rsp.3\3RSIF\2RS13\1RS15"); - pos += sprintf(pos + r," Framing errors: %lu", sc->cnt_fec); - pos += sprintf(pos + r," Code Violations: %lu\n", sc->cnt_cvc); - - pos += sprintf(pos + r," Falc State %b;\n", sc->falc_state, "\20" - "\40LOS\37AIS\36LFA\35RRA" - "\34AUXP\33NMF\32LMFA\31frs0.0" - "\30frs1.7\27TS16RA\26TS16LOS\25TS16AIS" - "\24TS16LFA\23frs1.2\22XLS\21XLO" - "\20RS1\17rsw.6\16RRA\15RY0" - "\14RY1\13RY2\12RY3\11RY4" - "\10SI1\7SI2\6rsp.5\5rsp.4" - "\4rsp.3\3RSIF\2RS13\1RS15"); - pos += sprintf(pos + r, " Falc IRQ %b\n", sc->falc_irq, "\20" - "\40RME\37RFS\36T8MS\35RMB\34CASC\33CRC4\32SA6SC\31RPF" - "\30b27\27RDO\26ALLS\25XDU\24XMB\23b22\22XLSC\21XPR" - "\20FAR\17LFA\16MFAR\15T400MS\14AIS\13LOS\12RAR\11RA" - "\10ES\7SEC\6LMFA16\5AIS16\4RA16\3API\2SLN\1SLP"); - for (i = 0; i < M32_CHAN; i++) { - if (!sc->ch[i]) - continue; - sch = sc->ch[i]; - - pos += sprintf(r + pos, " Chan %d <%s> ", - i, NG_HOOK_NAME(sch->hook)); - - pos += sprintf(r + pos, " Last Rx: "); - if (sch->last_recv) - pos += sprintf(r + pos, "%lu s", - (unsigned long)(time_second - sch->last_recv)); - else - pos += sprintf(r + pos, "never"); - - pos += sprintf(r + pos, ", last RxErr: "); - if (sch->last_rxerr) - pos += sprintf(r + pos, "%lu s", - (unsigned long)(time_second - sch->last_rxerr)); - else - pos += sprintf(r + pos, "never"); - - pos += sprintf(r + pos, ", last Tx: "); - if (sch->last_xmit) - pos += sprintf(r + pos, "%lu s\n", - (unsigned long)(time_second - sch->last_xmit)); - else - pos += sprintf(r + pos, "never\n"); - - pos += sprintf(r + pos, " RX error(s) %lu", sch->rx_error); - pos += sprintf(r + pos, " Short: %lu", sch->short_error); - pos += sprintf(r + pos, " CRC: %lu", sch->crc_error); - pos += sprintf(r + pos, " Mod8: %lu", sch->dribble_error); - pos += sprintf(r + pos, " Long: %lu", sch->long_error); - pos += sprintf(r + pos, " Abort: %lu", sch->abort_error); - pos += sprintf(r + pos, " Overflow: %lu\n", sch->overflow_error); - - pos += sprintf(r + pos, " Last error: %b Prev error: %b\n", - sch->last_error, "\20\7SHORT\5CRC\4MOD8\3LONG\2ABORT\1OVERRUN", - sch->prev_error, "\20\7SHORT\5CRC\4MOD8\3LONG\2ABORT\1OVERRUN"); - pos += sprintf(r + pos, " Xmit bytes pending %ld\n", - sch->tx_pending); - } - resp->header.arglen = pos + 1; - - /* Take care of synchronous response, if any */ - NG_RESPOND_MSG(i, node, item, resp); - NG_FREE_MSG(msg); - return (0); -} - -static int -ngmn_newhook(node_p node, hook_p hook, const char *name) -{ - u_int32_t ts, chan; - struct mn_softc *sc; - int nbit; - - sc = NG_NODE_PRIVATE(node); - - if (name[0] != 't' || name[1] != 's') - return (EINVAL); - - ts = mn_parse_ts(name + 2, &nbit); - printf("%d bits %x\n", nbit, ts); - if (sc->framing == E1 && (ts & 1)) - return (EINVAL); - if (sc->framing == E1U && nbit != 32) - return (EINVAL); - if (ts == 0) - return (EINVAL); - if (sc->framing == E1) - chan = ffs(ts) - 1; - else - chan = 1; - if (!sc->ch[chan]) - mn_create_channel(sc, chan); - else if (sc->ch[chan]->state == UP) - return (EBUSY); - sc->ch[chan]->ts = ts; - sc->ch[chan]->hook = hook; - sc->ch[chan]->tx_limit = nbit * 8; - NG_HOOK_SET_PRIVATE(hook, sc->ch[chan]); - sc->nhooks++; - return(0); -} - - -static struct trxd *mn_desc_free; - -static struct trxd * -mn_alloc_desc(void) -{ - struct trxd *dp; - - dp = mn_desc_free; - if (dp) - mn_desc_free = dp->vnext; - else - dp = (struct trxd *)malloc(sizeof *dp, M_MN, M_NOWAIT); - return (dp); -} - -static void -mn_free_desc(struct trxd *dp) -{ - dp->vnext = mn_desc_free; - mn_desc_free = dp; -} - -static u_int32_t -mn_parse_ts(const char *s, int *nbit) -{ - unsigned r; - int i, j; - char *p; - - r = 0; - j = -1; - *nbit = 0; - while(*s) { - i = strtol(s, &p, 0); - if (i < 0 || i > 31) - return (0); - while (j != -1 && j < i) { - r |= 1 << j++; - (*nbit)++; - } - j = -1; - r |= 1 << i; - (*nbit)++; - if (*p == ',') { - s = p + 1; - continue; - } else if (*p == '-') { - j = i + 1; - s = p + 1; - continue; - } else if (!*p) { - break; - } else { - return (0); - } - } - return (r); -} - -#ifdef notyet -static void -mn_fmt_ts(char *p, u_int32_t ts) -{ - char *s; - int j; - - s = ""; - ts &= 0xffffffff; - for (j = 0; j < 32; j++) { - if (!(ts & (1 << j))) - continue; - sprintf(p, "%s%d", s, j); - p += strlen(p); - s = ","; - if (!(ts & (1 << (j+1)))) - continue; - for (; j < 32; j++) - if (!(ts & (1 << (j+1)))) - break; - sprintf(p, "-%d", j); - p += strlen(p); - s = ","; - } -} -#endif /* notyet */ - -/* - * OUTPUT - */ - -static int -ngmn_rcvdata(hook_p hook, item_p item) -{ - struct mbuf *m2; - struct trxd *dp, *dp2; - struct schan *sch; - struct mn_softc *sc; - int chan, pitch, len; - struct mbuf *m; - - sch = NG_HOOK_PRIVATE(hook); - sc = sch->sc; - chan = sch->chan; - - if (sch->state != UP) { - NG_FREE_ITEM(item); - return (0); - } - NGI_GET_M(item, m); - if (sch->tx_pending + m->m_pkthdr.len > sch->tx_limit * mn_maxlatency) { - NG_FREE_M(m); - NG_FREE_ITEM(item); - return (0); - } - NG_FREE_ITEM(item); - pitch = 0; - m2 = m; - dp2 = sc->ch[chan]->xl; - len = m->m_pkthdr.len; - while (len) { - dp = mn_alloc_desc(); - if (!dp) { - pitch++; - m_freem(m); - sc->ch[chan]->xl = dp2; - dp = dp2->vnext; - while (dp) { - dp2 = dp->vnext; - mn_free_desc(dp); - dp = dp2; - } - sc->ch[chan]->xl->vnext = NULL; - break; - } - dp->data = vtophys(m2->m_data); - dp->flags = m2->m_len << 16; - dp->flags += 1; - len -= m2->m_len; - dp->next = vtophys(dp); - dp->vnext = NULL; - sc->ch[chan]->xl->next = vtophys(dp); - sc->ch[chan]->xl->vnext = dp; - sc->ch[chan]->xl = dp; - if (!len) { - dp->m = m; - dp->flags |= 0xc0000000; - dp2->flags &= ~0x40000000; - } else { - dp->m = NULL; - m2 = m2->m_next; - } - } - if (pitch) - printf("%s%d: Short on mem, pitched %d packets\n", - sc->name, chan, pitch); - else { -#if 0 - printf("%d = %d + %d (%p)\n", - sch->tx_pending + m->m_pkthdr.len, - sch->tx_pending , m->m_pkthdr.len, m); -#endif - sch->tx_pending += m->m_pkthdr.len; - sc->m32x->txpoll &= ~(1 << chan); - } - return (0); -} - -/* - * OPEN - */ -static int -ngmn_connect(hook_p hook) -{ - int i, nts, chan; - struct trxd *dp, *dp2; - struct mbuf *m; - struct mn_softc *sc; - struct schan *sch; - u_int32_t u; - - sch = NG_HOOK_PRIVATE(hook); - chan = sch->chan; - sc = sch->sc; - - if (sch->state == UP) - return (0); - sch->state = UP; - - /* Count and configure the timeslots for this channel */ - for (nts = i = 0; i < 32; i++) - if (sch->ts & (1 << i)) { - sc->m32_mem.ts[i] = 0x00ff00ff | - (chan << 24) | (chan << 8); - nts++; - } - - /* Init the receiver & xmitter to HDLC */ - sc->m32_mem.cs[chan].flags = 0x80e90006; - /* Allocate two buffers per timeslot */ - if (nts == 32) - sc->m32_mem.cs[chan].itbs = 63; - else - sc->m32_mem.cs[chan].itbs = nts * 2; - - /* Setup a transmit chain with one descriptor */ - /* XXX: we actually send a 1 byte packet */ - dp = mn_alloc_desc(); - MGETHDR(m, M_WAITOK, MT_DATA); - m->m_pkthdr.len = 0; - dp->m = m; - dp->flags = 0xc0000000 + (1 << 16); - dp->next = vtophys(dp); - dp->vnext = NULL; - dp->data = vtophys(sc->name); - sc->m32_mem.cs[chan].tdesc = vtophys(dp); - sc->ch[chan]->x1 = dp; - sc->ch[chan]->xl = dp; - - /* Setup a receive chain with 5 + NTS descriptors */ - - dp = mn_alloc_desc(); - m = NULL; - MGETHDR(m, M_WAITOK, MT_DATA); - MCLGET(m, M_WAITOK); - dp->m = m; - dp->data = vtophys(m->m_data); - dp->flags = 0x40000000; - dp->flags += 1600 << 16; - dp->next = vtophys(dp); - dp->vnext = NULL; - sc->ch[chan]->rl = dp; - - for (i = 0; i < (nts + 10); i++) { - dp2 = dp; - dp = mn_alloc_desc(); - m = NULL; - MGETHDR(m, M_WAITOK, MT_DATA); - MCLGET(m, M_WAITOK); - dp->m = m; - dp->data = vtophys(m->m_data); - dp->flags = 0x00000000; - dp->flags += 1600 << 16; - dp->next = vtophys(dp2); - dp->vnext = dp2; - } - sc->m32_mem.cs[chan].rdesc = vtophys(dp); - sc->ch[chan]->r1 = dp; - - /* Initialize this channel */ - sc->m32_mem.ccb = 0x00008000 + (chan << 8); - sc->m32x->cmd = 0x1; - DELAY(1000); - u = sc->m32x->stat; - if (!(u & 1)) - printf("%s: init chan %d stat %08x\n", sc->name, chan, u); - sc->m32x->stat = 1; - - return (0); -} - -/* - * CLOSE - */ -static int -ngmn_disconnect(hook_p hook) -{ - int chan, i; - struct mn_softc *sc; - struct schan *sch; - struct trxd *dp, *dp2; - u_int32_t u; - - sch = NG_HOOK_PRIVATE(hook); - chan = sch->chan; - sc = sch->sc; - - if (sch->state == DOWN) - return (0); - sch->state = DOWN; - - /* Set receiver & transmitter off */ - sc->m32_mem.cs[chan].flags = 0x80920006; - sc->m32_mem.cs[chan].itbs = 0; - - /* free the timeslots */ - for (i = 0; i < 32; i++) - if (sc->ch[chan]->ts & (1 << i)) - sc->m32_mem.ts[i] = 0x20002000; - - /* Initialize this channel */ - sc->m32_mem.ccb = 0x00008000 + (chan << 8); - sc->m32x->cmd = 0x1; - DELAY(30); - u = sc->m32x->stat; - if (!(u & 1)) - printf("%s: zap chan %d stat %08x\n", sc->name, chan, u); - sc->m32x->stat = 1; - - /* Free all receive descriptors and mbufs */ - for (dp = sc->ch[chan]->r1; dp ; dp = dp2) { - if (dp->m) - m_freem(dp->m); - sc->ch[chan]->r1 = dp2 = dp->vnext; - mn_free_desc(dp); - } - - /* Free all transmit descriptors and mbufs */ - for (dp = sc->ch[chan]->x1; dp ; dp = dp2) { - if (dp->m) { - sc->ch[chan]->tx_pending -= dp->m->m_pkthdr.len; - m_freem(dp->m); - } - sc->ch[chan]->x1 = dp2 = dp->vnext; - mn_free_desc(dp); - } - sc->nhooks--; - return(0); -} - -/* - * Create a new channel. - */ -static void -mn_create_channel(struct mn_softc *sc, int chan) -{ - struct schan *sch; - - sch = sc->ch[chan] = (struct schan *)malloc(sizeof *sc->ch[chan], - M_MN, M_WAITOK | M_ZERO); - sch->sc = sc; - sch->state = DOWN; - sch->chan = chan; - sprintf(sch->name, "%s%d", sc->name, chan); - return; -} - -#ifdef notyet -/* - * Dump Munich32x state - */ -static void -m32_dump(struct mn_softc *sc) *** 600 LINES SKIPPED ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202103221907.12MJ7NJq051686>