1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-10-18 02:19:39 +00:00

Do not set IFF_DEBUG directly from the driver.

MFC after:	1 month.
This commit is contained in:
Roman Kurakin 2008-06-30 21:18:27 +00:00
parent 2a61d63038
commit 259edd2800
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=180132
9 changed files with 84 additions and 30 deletions

View File

@ -276,6 +276,15 @@ print_ifconfig (int fd __unused)
system (buf);
}
static void
set_debug_ifconfig (int on)
{
char buf [64];
sprintf (buf, "ifconfig %s %sdebug 2>/dev/null", chan_name,
on ? "" : "-");
system (buf);
}
static char *
format_long (unsigned long val)
{
@ -724,6 +733,7 @@ setup_chan (int fd, int argc, char **argv)
int i, mode, loop, nrzi, dpll, invclk, phony, use16, crc4, unfram, ami;
int higain, clk, keepalive, debug, port, dlci, invrclk, invtclk;
int monitor, dir, scrambler, rloop, cablen;
int mode_valid;
long baud, timeslots, mtu, rqlen;
for (i=0; i<argc; ++i) {
@ -792,7 +802,17 @@ setup_chan (int fd, int argc, char **argv)
ioctl (fd, SERIAL_SETPROTO, "zaptel\0");
} else if (strncasecmp ("debug=", argv[i], 6) == 0) {
debug = strtol (argv[i]+6, 0, 10);
ioctl (fd, SERIAL_SETDEBUG, &debug);
mode_valid = ioctl (fd, SERIAL_GETMODE, &mode) >= 0;
if (!mode_valid || mode != SERIAL_ASYNC) {
if (debug == 0) {
set_debug_ifconfig(0);
} else {
ioctl (fd, SERIAL_SETDEBUG, &debug);
set_debug_ifconfig(1);
}
} else {
ioctl (fd, SERIAL_SETDEBUG, &debug);
}
} else if (strncasecmp ("loop=", argv[i], 5) == 0) {
loop = (strcasecmp ("on", argv[i] + 5) == 0);
ioctl (fd, SERIAL_SETLOOP, &loop);

View File

@ -72,6 +72,7 @@ typedef struct _ce_chan_t {
TAU32_UserRequest *rx_queue;
TAU32_UserRequest *tx_queue;
unsigned char debug;
unsigned char debug_shadow;
void (*transmit) (struct _ce_chan_t*, void*, int);
void (*receive) (struct _ce_chan_t*, unsigned char*, int);
void (*error) (struct _ce_chan_t*, int);

View File

@ -962,8 +962,8 @@ static int ce_sioctl (struct ifnet *ifp, u_long cmd, caddr_t data)
if (! (ifp->if_flags & IFF_DEBUG))
d->chan->debug = 0;
else if (! d->chan->debug)
d->chan->debug = 1;
else
d->chan->debug = d->chan->debug_shadow;
switch (cmd) {
default: CE_DEBUG2 (d, ("ioctl 0x%lx\n", cmd)); return 0;
@ -1621,12 +1621,17 @@ static int ce_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struc
#endif
if (error)
return error;
d->chan->debug = *(int*)data;
#ifndef NETGRAPH
if (d->chan->debug)
d->ifp->if_flags |= IFF_DEBUG;
else
d->ifp->if_flags &= ~IFF_DEBUG;
/*
* The debug_shadow is always greater than zero for logic
* simplicity. For switching debug off the IFF_DEBUG is
* responsible.
*/
d->chan->debug_shadow = (*(int*)data) ? (*(int*)data) : 1;
if (d->ifp->if_flags & IFF_DEBUG)
d->chan->debug = d->chan->debug_shadow;
#else
d->chan->debug = *(int*)data;
#endif
return 0;

View File

@ -205,6 +205,7 @@ typedef struct _cp_chan_t {
void *tag [NTBUF]; /* system dependent data per buffer */
void *sys; /* system dependent data per channel */
unsigned char debug; /* debug level, 0..2 */
unsigned char debug_shadow; /* debug shadow */
void (*transmit) (struct _cp_chan_t *c, void *tag, int len);
void (*receive) (struct _cp_chan_t *c, unsigned char *data, int len);

View File

@ -733,8 +733,8 @@ static int cp_sioctl (struct ifnet *ifp, u_long cmd, caddr_t data)
if (! (ifp->if_flags & IFF_DEBUG))
d->chan->debug = 0;
else if (! d->chan->debug)
d->chan->debug = 1;
else
d->chan->debug = d->chan->debug_shadow;
switch (cmd) {
default: CP_DEBUG2 (d, ("ioctl 0x%lx\n", cmd)); return 0;
@ -1349,12 +1349,17 @@ static int cp_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struc
error = priv_check (td, PRIV_DRIVER);
if (error)
return error;
d->chan->debug = *(int*)data;
#ifndef NETGRAPH
if (d->chan->debug)
d->ifp->if_flags |= IFF_DEBUG;
else
d->ifp->if_flags &= ~IFF_DEBUG;
/*
* The debug_shadow is always greater than zero for logic
* simplicity. For switching debug off the IFF_DEBUG is
* responsible.
*/
d->chan->debug_shadow = (*(int*)data) ? (*(int*)data) : 1;
if (d->ifp->if_flags & IFF_DEBUG)
d->chan->debug = d->chan->debug_shadow;
#else
d->chan->debug = *(int*)data;
#endif
return 0;

View File

@ -412,6 +412,7 @@ typedef struct _ct_chan_t {
void *attach [NBUF]; /* system dependent data per buffer */
void *sys; /* system dependent data per channel */
int debug;
int debug_shadow;
int e1_first_int;
unsigned char *sccrx, *scctx; /* pointers to SCC rx and tx buffers */

View File

@ -949,8 +949,8 @@ static int ct_sioctl (struct ifnet *ifp, u_long cmd, caddr_t data)
if (! (ifp->if_flags & IFF_DEBUG))
d->chan->debug = 0;
else if (! d->chan->debug)
d->chan->debug = 1;
else
d->chan->debug = d->chan->debug_shadow;
switch (cmd) {
default: CT_DEBUG2 (d, ("ioctl 0x%lx\n", cmd)); return 0;
@ -1529,12 +1529,17 @@ static int ct_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struc
error = priv_check (td, PRIV_DRIVER);
if (error)
return error;
c->debug = *(int*)data;
#ifndef NETGRAPH
if (d->chan->debug)
d->ifp->if_flags |= IFF_DEBUG;
else
d->ifp->if_flags &= (~IFF_DEBUG);
/*
* The debug_shadow is always greater than zero for logic
* simplicity. For switching debug off the IFF_DEBUG is
* responsible.
*/
c->debug_shadow = (*(int*)data) ? (*(int*)data) : 1;
if (d->ifp->if_flags & IFF_DEBUG)
c->debug = c->debug_shadow;
#else
c->debug = *(int*)data;
#endif
return 0;

View File

@ -337,6 +337,7 @@ typedef struct _cx_chan_t {
void *sys;
int debug;
int debug_shadow;
void *attach [2];
char *received_data;
int received_len;

View File

@ -1102,10 +1102,14 @@ static int cx_sioctl (struct ifnet *ifp, u_long cmd, caddr_t data)
if (error)
return error;
s = splhigh ();
CX_LOCK (bd);
if (! (ifp->if_flags & IFF_DEBUG))
d->chan->debug = 0;
else if (! d->chan->debug)
d->chan->debug = 1;
else
d->chan->debug = d->chan->debug_shadow;
CX_UNLOCK (bd);
splx (s);
switch (cmd) {
default: CX_DEBUG2 (d, ("ioctl 0x%lx\n", cmd)); return 0;
@ -1745,6 +1749,8 @@ static int cx_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struc
cx_enable_receive (c, 0);
cx_enable_transmit (c, 0);
} else if (c->mode == M_ASYNC && *(int*)data == SERIAL_HDLC) {
if (d->ifp->if_flags & IFF_DEBUG)
c->debug = c->debug_shadow;
cx_set_mode (c, M_HDLC);
cx_enable_receive (c, 1);
cx_enable_transmit (c, 1);
@ -1913,15 +1919,24 @@ static int cx_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struc
return error;
s = splhigh ();
CX_LOCK (bd);
#ifndef NETGRAPH
if (c->mode == M_ASYNC) {
c->debug = *(int*)data;
} else {
/*
* The debug_shadow is always greater than zero for
* logic simplicity. For switching debug off the
* IFF_DEBUG is responsible (for !M_ASYNC mode).
*/
c->debug_shadow = (*(int*)data) ? (*(int*)data) : 1;
if (d->ifp->if_flags & IFF_DEBUG)
c->debug = c->debug_shadow;
}
#else
c->debug = *(int*)data;
#endif
CX_UNLOCK (bd);
splx (s);
#ifndef NETGRAPH
if (d->chan->debug)
d->ifp->if_flags |= IFF_DEBUG;
else
d->ifp->if_flags &= (~IFF_DEBUG);
#endif
return 0;
}