Even if we don't use MII(4), use the common path of SIOC[GS]IFMEDIA in

sys/net/if_ethersubr.c if we can.
 - Add ec_ifmedia into struct ethercom.
 - ec_mii in struct ethercom is kept and used as it is. It might be used in
   future. Note that some Ethernet drivers which _DOESN'T_ use mii(4) use
   ec_mii for keeping the if_media. Those should be changed in future.
This commit is contained in:
msaitoh 2019-05-29 10:07:28 +00:00
parent 247e44acfe
commit b9958efe6c
37 changed files with 135 additions and 267 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_es.c,v 1.63 2019/05/29 06:21:56 msaitoh Exp $ */
/* $NetBSD: if_es.c,v 1.64 2019/05/29 10:07:28 msaitoh Exp $ */
/*
* Copyright (c) 1995 Michael L. Hitch
@ -33,7 +33,7 @@
#include "opt_ns.h"
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_es.c,v 1.63 2019/05/29 06:21:56 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_es.c,v 1.64 2019/05/29 10:07:28 msaitoh Exp $");
#include <sys/param.h>
@ -176,6 +176,8 @@ esattach(device_t parent, device_t self, void *aux)
ifp->if_watchdog = eswatchdog;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
/* Setup ifmedia interface */
sc->sc_ethercom.ec_ifmedia = &sc->sc_media;
ifmedia_init(&sc->sc_media, 0, esmediachange, esmediastatus);
ifmedia_add(&sc->sc_media, IFM_ETHER | IFM_MANUAL, 0, NULL);
ifmedia_set(&sc->sc_media, IFM_ETHER | IFM_MANUAL);
@ -943,7 +945,6 @@ esioctl(struct ifnet *ifp, u_long cmd, void *data)
{
struct es_softc *sc = ifp->if_softc;
register struct ifaddr *ifa = (struct ifaddr *)data;
struct ifreq *ifr = (struct ifreq *)data;
int s, error = 0;
s = splnet();
@ -1018,11 +1019,6 @@ esioctl(struct ifnet *ifp, u_long cmd, void *data)
}
break;
case SIOCGIFMEDIA:
case SIOCSIFMEDIA:
error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd);
break;
default:
error = ether_ioctl(ifp, cmd, data);
break;

View File

@ -35,7 +35,7 @@
#include <sys/cdefs.h>
__KERNEL_RCSID(1, "$NetBSD: bcm53xx_eth.c,v 1.36 2019/05/29 06:21:56 msaitoh Exp $");
__KERNEL_RCSID(1, "$NetBSD: bcm53xx_eth.c,v 1.37 2019/05/29 10:07:28 msaitoh Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@ -379,6 +379,7 @@ bcmeth_ccb_attach(device_t parent, device_t self, void *aux)
*/
int ifmedia = IFM_ETHER | IFM_1000_T | IFM_FDX;
//ifmedia |= IFM_FLOW | IFM_ETH_TXPAUSE | IFM_ETH_RXPAUSE;
ec->ec_ifmedia = &sc->sc_media;
ifmedia_init(&sc->sc_media, IFM_IMASK, bcmeth_mediachange,
bcmeth_mediastatus);
ifmedia_add(&sc->sc_media, ifmedia, 0, NULL);
@ -686,16 +687,10 @@ static int
bcmeth_ifioctl(struct ifnet *ifp, u_long cmd, void *data)
{
struct bcmeth_softc *sc = ifp->if_softc;
struct ifreq * const ifr = data;
const int s = splnet();
int error;
switch (cmd) {
case SIOCSIFMEDIA:
case SIOCGIFMEDIA:
error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd);
break;
default:
error = ether_ioctl(ifp, cmd, data);
if (error != ENETRESET)

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_gpn.c,v 1.11 2019/05/29 06:21:56 msaitoh Exp $ */
/* $NetBSD: if_gpn.c,v 1.12 2019/05/29 10:07:28 msaitoh Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
@ -32,7 +32,7 @@
#include "opt_gemini.h"
__KERNEL_RCSID(0, "$NetBSD: if_gpn.c,v 1.11 2019/05/29 06:21:56 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_gpn.c,v 1.12 2019/05/29 10:07:28 msaitoh Exp $");
#include <sys/param.h>
#include <sys/device.h>
@ -617,10 +617,6 @@ gpn_ifioctl(struct ifnet *ifp, u_long cmd, void *data)
s = splnet();
switch (cmd) {
case SIOCSIFMEDIA:
case SIOCGIFMEDIA:
error = ifmedia_ioctl(ifp, ifr, &sc->sc_im, cmd);
break;
case SIOCSIFPHYADDR: {
const struct sockaddr_dl *sdl = satosdl(&ifra->ifra_addr);
@ -688,10 +684,10 @@ gpn_attach(device_t parent, device_t self, void *aux)
sc->sc_dev = self;
sc->sc_dmat = &gemini_bus_dma_tag;
/*
* Pretend we are full-duplex gigabit ethernet.
*/
/* Setup ifmedia interface */
sc->sc_ec.ec_ifmedia = &sc->sc_im;
ifmedia_init(&sc->sc_im, 0, gpn_mediachange, gpn_mediastatus);
/* Pretend we are full-duplex gigabit ethernet. */
ifmedia_add(&sc->sc_im, IFM_ETHER | IFM_1000_T | IFM_FDX, 0, NULL);
ifmedia_add(&sc->sc_im, IFM_ETHER | IFM_NONE, 0, NULL);
ifmedia_set(&sc->sc_im, IFM_ETHER | IFM_NONE);

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_le_ebus.c,v 1.19 2019/05/29 06:21:57 msaitoh Exp $ */
/* $NetBSD: if_le_ebus.c,v 1.20 2019/05/29 10:07:28 msaitoh Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_le_ebus.c,v 1.19 2019/05/29 06:21:57 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_le_ebus.c,v 1.20 2019/05/29 10:07:28 msaitoh Exp $");
#include "opt_inet.h"
@ -194,6 +194,7 @@ enic_attach(device_t parent, device_t self, void *aux)
IFQ_SET_READY(&ifp->if_snd);
/* Initialize ifmedia structures. */
sc->sc_ethercom.ec_ifmedia = &sc->sc_media;
ifmedia_init(&sc->sc_media, 0, enic_mediachange, enic_mediastatus);
ifmedia_add(&sc->sc_media, IFM_ETHER | IFM_MANUAL, 0, NULL);
ifmedia_set(&sc->sc_media, IFM_ETHER | IFM_MANUAL);
@ -597,7 +598,6 @@ enic_ioctl(struct ifnet *ifp, u_long cmd, void *data)
s = splnet();
switch (cmd) {
case SIOCGIFMEDIA:
case SIOCSIFMEDIA:
#if 0 /*DEBUG*/
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: am79c950.c,v 1.45 2019/05/28 07:41:47 msaitoh Exp $ */
/* $NetBSD: am79c950.c,v 1.46 2019/05/29 10:07:28 msaitoh Exp $ */
/*-
* Copyright (c) 1997 David Huang <khym@bga.com>
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: am79c950.c,v 1.45 2019/05/28 07:41:47 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: am79c950.c,v 1.46 2019/05/29 10:07:28 msaitoh Exp $");
#include "opt_inet.h"
@ -154,6 +154,7 @@ mcsetup(struct mc_softc *sc, uint8_t *lladdr)
ifp->if_watchdog = mcwatchdog;
/* Initialize ifmedia structures */
sc->sc_ethercom.ec_ifmedia = &sc->sc_media;
ifmedia_init(&sc->sc_media, 0, mc_mediachange, mc_mediastatus);
ifmedia_add(&sc->sc_media, IFM_ETHER | IFM_MANUAL, 0, NULL);
ifmedia_set(&sc->sc_media, IFM_ETHER | IFM_MANUAL);
@ -170,7 +171,6 @@ mcioctl(struct ifnet *ifp, u_long cmd, void *data)
{
struct mc_softc *sc = ifp->if_softc;
struct ifaddr *ifa;
struct ifreq *ifr;
int s = splnet(), err = 0;
@ -233,12 +233,6 @@ mcioctl(struct ifnet *ifp, u_long cmd, void *data)
}
break;
case SIOCGIFMEDIA:
case SIOCSIFMEDIA:
ifr = (struct ifreq *) data;
err = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd);
break;
default:
err = ether_ioctl(ifp, cmd, data);
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: mb8795.c,v 1.64 2019/05/29 06:21:57 msaitoh Exp $ */
/* $NetBSD: mb8795.c,v 1.65 2019/05/29 10:07:29 msaitoh Exp $ */
/*
* Copyright (c) 1998 Darrin B. Jewell
* All rights reserved.
@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mb8795.c,v 1.64 2019/05/29 06:21:57 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: mb8795.c,v 1.65 2019/05/29 10:07:29 msaitoh Exp $");
#include "opt_inet.h"
@ -111,8 +111,8 @@ mb8795_config(struct mb8795_softc *sc, int *media, int nmedia, int defmedia)
ifp->if_flags = IFF_BROADCAST;
/* Initialize media goo. */
ifmedia_init(&sc->sc_media, 0, mb8795_mediachange,
mb8795_mediastatus);
sc->sc_ethercom.ec_ifmedia = &sc->sc_media;
ifmedia_init(&sc->sc_media, 0, mb8795_mediachange, mb8795_mediastatus);
if (media != NULL) {
int i;
for (i = 0; i < nmedia; i++)
@ -561,7 +561,6 @@ mb8795_ioctl(struct ifnet *ifp, u_long cmd, void *data)
{
struct mb8795_softc *sc = ifp->if_softc;
struct ifaddr *ifa = (struct ifaddr *)data;
struct ifreq *ifr = (struct ifreq *)data;
int s, error = 0;
s = splnet();
@ -642,13 +641,6 @@ mb8795_ioctl(struct ifnet *ifp, u_long cmd, void *data)
}
break;
case SIOCGIFMEDIA:
case SIOCSIFMEDIA:
DPRINTF(("%s: mb8795_ioctl() SIOCSIFMEDIA\n",
device_xname(sc->sc_dev)));
error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd);
break;
default:
error = ether_ioctl(ifp, cmd, data);
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ec.c,v 1.33 2019/05/29 06:21:57 msaitoh Exp $ */
/* $NetBSD: if_ec.c,v 1.34 2019/05/29 10:07:29 msaitoh Exp $ */
/*
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_ec.c,v 1.33 2019/05/29 06:21:57 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_ec.c,v 1.34 2019/05/29 10:07:29 msaitoh Exp $");
#include "opt_inet.h"
#include "opt_ns.h"
@ -223,6 +223,7 @@ ec_attach(device_t parent, device_t self, void *aux)
IFQ_SET_READY(&ifp->if_snd);
/* Initialize ifmedia structures. */
sc->sc_ethercom.ec_ifmedia = &sc->sc_media;
ifmedia_init(&sc->sc_media, 0, ec_mediachange, ec_mediastatus);
ifmedia_add(&sc->sc_media, IFM_ETHER | IFM_MANUAL, 0, NULL);
ifmedia_set(&sc->sc_media, IFM_ETHER | IFM_MANUAL);
@ -559,8 +560,6 @@ int
ec_ioctl(struct ifnet *ifp, u_long cmd, void *data)
{
struct ifaddr *ifa = (struct ifaddr *)data;
struct ifreq *ifr = (struct ifreq *)data;
struct ec_softc *sc = ifp->if_softc;
int s, error = 0;
s = splnet();
@ -611,11 +610,6 @@ ec_ioctl(struct ifnet *ifp, u_long cmd, void *data)
}
break;
case SIOCGIFMEDIA:
case SIOCSIFMEDIA:
error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd);
break;
default:
error = ether_ioctl(ifp, cmd, data);
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_veth.c,v 1.12 2019/05/29 06:21:57 msaitoh Exp $ */
/* $NetBSD: if_veth.c,v 1.13 2019/05/29 10:07:29 msaitoh Exp $ */
/*-
* Copyright (c) 2011 Jared D. McNeill <jmcneill@invisible.ca>
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_veth.c,v 1.12 2019/05/29 06:21:57 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_veth.c,v 1.13 2019/05/29 10:07:29 msaitoh Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@ -148,9 +148,10 @@ veth_attach(device_t parent, device_t self, void *opaque)
ether_ifattach(ifp, sc->sc_eaddr);
if_register(ifp);
/* Initialize ifmedia structures. */
sc->sc_ec.ec_ifmedia = &sc->sc_ifmedia;
ifmedia_init(&sc->sc_ifmedia, 0,
veth_ifmedia_change,
veth_ifmedia_status);
veth_ifmedia_change, veth_ifmedia_status);
ifmedia_add(&sc->sc_ifmedia, IFM_ETHER | IFM_100_TX, 0, NULL);
ifmedia_set(&sc->sc_ifmedia, IFM_ETHER | IFM_100_TX);
@ -322,8 +323,6 @@ veth_watchdog(struct ifnet *ifp)
static int
veth_ioctl(struct ifnet *ifp, u_long cmd, void *data)
{
struct veth_softc *sc = ifp->if_softc;
struct ifreq *ifr;
int s, error;
vethprintf("%s: %s flags=%x\n", __func__, ifp->if_xname, ifp->if_flags);
@ -331,11 +330,6 @@ veth_ioctl(struct ifnet *ifp, u_long cmd, void *data)
s = splnet();
switch (cmd) {
case SIOCSIFMEDIA:
case SIOCGIFMEDIA:
ifr = data;
error = ifmedia_ioctl(ifp, ifr, &sc->sc_ifmedia, cmd);
break;
case SIOCADDMULTI:
case SIOCDELMULTI:
if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_vmx.c,v 1.28 2019/05/23 10:57:27 msaitoh Exp $ */
/* $NetBSD: if_vmx.c,v 1.29 2019/05/29 10:07:29 msaitoh Exp $ */
/* $OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $ */
/*
@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.28 2019/05/23 10:57:27 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.29 2019/05/29 10:07:29 msaitoh Exp $");
#include <sys/param.h>
#include <sys/cpu.h>
@ -1726,6 +1726,8 @@ vmxnet3_setup_interface(struct vmxnet3_softc *sc)
IFQ_SET_MAXLEN(&ifp->if_snd, sc->vmx_ntxdescs);
IFQ_SET_READY(&ifp->if_snd);
/* Initialize ifmedia structures. */
sc->vmx_ethercom.ec_ifmedia = &sc->vmx_media;
ifmedia_init(&sc->vmx_media, IFM_IMASK, vmxnet3_media_change,
vmxnet3_media_status);
ifmedia_add(&sc->vmx_media, IFM_ETHER | IFM_AUTO, 0, NULL);
@ -2910,12 +2912,6 @@ vmxnet3_ioctl(struct ifnet *ifp, u_long cmd, void *data)
VMXNET3_CORE_UNLOCK(sc);
}
break;
case SIOCSIFMEDIA:
case SIOCGIFMEDIA:
s = splnet();
error = ifmedia_ioctl(ifp, ifr, &sc->vmx_media, cmd);
splx(s);
break;
case SIOCGIFDATA:
case SIOCZIFDATA:
ifp->if_ipackets = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_hvn.c,v 1.2 2019/03/05 08:25:02 msaitoh Exp $ */
/* $NetBSD: if_hvn.c,v 1.3 2019/05/29 10:07:29 msaitoh Exp $ */
/* $OpenBSD: if_hvn.c,v 1.39 2018/03/11 14:31:34 mikeb Exp $ */
/*-
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.2 2019/03/05 08:25:02 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.3 2019/05/29 10:07:29 msaitoh Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@ -289,6 +289,8 @@ hvn_attach(device_t parent, device_t self, void *aux)
IFQ_SET_MAXLEN(&ifp->if_snd, HVN_TX_DESC - 1);
IFQ_SET_READY(&ifp->if_snd);
/* Initialize ifmedia structures. */
sc->sc_ec.ec_ifmedia = &sc->sc_media;
ifmedia_init(&sc->sc_media, IFM_IMASK, hvn_media_change,
hvn_media_status);
ifmedia_add(&sc->sc_media, IFM_ETHER | IFM_MANUAL, 0, NULL);
@ -369,7 +371,6 @@ static int
hvn_ioctl(struct ifnet *ifp, u_long command, void * data)
{
struct hvn_softc *sc = IFP2SC(ifp);
struct ifreq *ifr = (struct ifreq *)data;
int s, error = 0;
s = splnet();
@ -389,10 +390,6 @@ hvn_ioctl(struct ifnet *ifp, u_long command, void * data)
hvn_stop(ifp, 1);
}
break;
case SIOCGIFMEDIA:
case SIOCSIFMEDIA:
error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, command);
break;
default:
error = ether_ioctl(ifp, command, data);
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: cs89x0.c,v 1.46 2019/05/28 07:41:48 msaitoh Exp $ */
/* $NetBSD: cs89x0.c,v 1.47 2019/05/29 10:07:29 msaitoh Exp $ */
/*
* Copyright (c) 2004 Christopher Gilbert
@ -212,7 +212,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: cs89x0.c,v 1.46 2019/05/28 07:41:48 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: cs89x0.c,v 1.47 2019/05/29 10:07:29 msaitoh Exp $");
#include "opt_inet.h"
@ -399,6 +399,7 @@ cs_attach(struct cs_softc *sc, uint8_t *enaddr, int *media,
IFQ_SET_READY(&ifp->if_snd);
/* Initialize ifmedia structures. */
sc->sc_ethercom.ec_ifmedia = &sc->sc_media;
ifmedia_init(&sc->sc_media, 0, cs_mediachange, cs_mediastatus);
if (media != NULL) {
@ -1318,7 +1319,6 @@ int
cs_ioctl(struct ifnet *ifp, u_long cmd, void *data)
{
struct cs_softc *sc = ifp->if_softc;
struct ifreq *ifr = data;
int state;
int result;
@ -1327,11 +1327,6 @@ cs_ioctl(struct ifnet *ifp, u_long cmd, void *data)
result = 0; /* Only set if something goes wrong */
switch (cmd) {
case SIOCGIFMEDIA:
case SIOCSIFMEDIA:
result = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd);
break;
default:
result = ether_ioctl(ifp, cmd, data);
if (result == ENETRESET) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: dm9000.c,v 1.20 2019/05/28 07:41:48 msaitoh Exp $ */
/* $NetBSD: dm9000.c,v 1.21 2019/05/29 10:07:29 msaitoh Exp $ */
/*
* Copyright (c) 2009 Paul Fleischer
@ -437,6 +437,7 @@ dme_attach(struct dme_softc *sc, const uint8_t *enaddr)
IFQ_SET_READY(&ifp->if_snd);
/* Initialize ifmedia structures. */
sc->sc_ethercom.ec_ifmedia = &sc->sc_media;
ifmedia_init(&sc->sc_media, 0, dme_mediachange, dme_mediastatus);
ifmedia_add(&sc->sc_media, IFM_ETHER | IFM_AUTO, 0, NULL);
ifmedia_add(&sc->sc_media, IFM_ETHER | IFM_10_T | IFM_FDX, 0, NULL);
@ -693,16 +694,11 @@ int
dme_ioctl(struct ifnet *ifp, u_long cmd, void *data)
{
struct dme_softc *sc = ifp->if_softc;
struct ifreq *ifr = data;
int s, error = 0;
s = splnet();
switch (cmd) {
case SIOCGIFMEDIA:
case SIOCSIFMEDIA:
error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd);
break;
default:
error = ether_ioctl(ifp, cmd, data);
if (error == ENETRESET) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: dp8390.c,v 1.94 2019/05/28 07:41:48 msaitoh Exp $ */
/* $NetBSD: dp8390.c,v 1.95 2019/05/29 10:07:29 msaitoh Exp $ */
/*
* Device driver for National Semiconductor DS8390/WD83C690 based ethernet
@ -14,7 +14,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: dp8390.c,v 1.94 2019/05/28 07:41:48 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: dp8390.c,v 1.95 2019/05/29 10:07:29 msaitoh Exp $");
#include "opt_inet.h"
@ -66,6 +66,7 @@ void
dp8390_media_init(struct dp8390_softc *sc)
{
sc->sc_ec.ec_ifmedia = &sc->sc_media;
ifmedia_init(&sc->sc_media, 0, dp8390_mediachange, dp8390_mediastatus);
ifmedia_add(&sc->sc_media, IFM_ETHER | IFM_MANUAL, 0, NULL);
ifmedia_set(&sc->sc_media, IFM_ETHER | IFM_MANUAL);
@ -812,7 +813,6 @@ dp8390_ioctl(struct ifnet *ifp, u_long cmd, void *data)
{
struct dp8390_softc *sc = ifp->if_softc;
struct ifaddr *ifa = data;
struct ifreq *ifr = data;
int s, error = 0;
s = splnet();
@ -892,11 +892,6 @@ dp8390_ioctl(struct ifnet *ifp, u_long cmd, void *data)
}
break;
case SIOCGIFMEDIA:
case SIOCSIFMEDIA:
error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd);
break;
default:
error = ether_ioctl(ifp, cmd, data);
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: i82586.c,v 1.84 2019/05/28 07:41:48 msaitoh Exp $ */
/* $NetBSD: i82586.c,v 1.85 2019/05/29 10:07:29 msaitoh Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -137,7 +137,7 @@ Mode of operation:
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: i82586.c,v 1.84 2019/05/28 07:41:48 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: i82586.c,v 1.85 2019/05/29 10:07:29 msaitoh Exp $");
#include <sys/param.h>
@ -245,6 +245,7 @@ i82586_attach(struct ie_softc *sc, const char *name, uint8_t *etheraddr,
IFQ_SET_READY(&ifp->if_snd);
/* Initialize media goo. */
sc->sc_ethercom.ec_ifmedia = &sc->sc_media;
ifmedia_init(&sc->sc_media, 0, i82586_mediachange, i82586_mediastatus);
if (media != NULL) {
for (i = 0; i < nmedia; i++)
@ -1725,15 +1726,10 @@ int
i82586_ioctl(struct ifnet *ifp, unsigned long cmd, void *data)
{
struct ie_softc *sc = ifp->if_softc;
struct ifreq *ifr = (struct ifreq *)data;
int s, error = 0;
s = splnet();
switch (cmd) {
case SIOCGIFMEDIA:
case SIOCSIFMEDIA:
error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd);
break;
default:
error = ether_ioctl(ifp, cmd, data);
if (error == ENETRESET) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: i82596.c,v 1.41 2019/05/28 07:41:48 msaitoh Exp $ */
/* $NetBSD: i82596.c,v 1.42 2019/05/29 10:07:29 msaitoh Exp $ */
/*
* Copyright (c) 2003 Jochen Kunz.
@ -43,7 +43,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: i82596.c,v 1.41 2019/05/28 07:41:48 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: i82596.c,v 1.42 2019/05/29 10:07:29 msaitoh Exp $");
/* autoconfig and device stuff */
#include <sys/param.h>
@ -646,6 +646,8 @@ iee_attach(struct iee_softc *sc, uint8_t *eth_addr, int *media, int nmedia,
bus_dmamap_sync(sc->sc_dmat, sc->sc_shmem_map, 0, sc->sc_shmem_sz,
BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
/* Initialize ifmedia structures. */
sc->sc_ethercom.ec_ifmedia = &sc->sc_ifmedia;
ifmedia_init(&sc->sc_ifmedia, 0, iee_mediachange, iee_mediastatus);
if (media != NULL) {
for (n = 0 ; n < nmedia ; n++)
@ -833,12 +835,6 @@ iee_ioctl(struct ifnet *ifp, u_long cmd, void *data)
s = splnet();
switch (cmd) {
case SIOCSIFMEDIA:
case SIOCGIFMEDIA:
err = ifmedia_ioctl(ifp, (struct ifreq *)data,
&sc->sc_ifmedia, cmd);
break;
default:
err = ether_ioctl(ifp, cmd, data);
if (err == ENETRESET) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: lance.c,v 1.57 2019/05/28 07:41:48 msaitoh Exp $ */
/* $NetBSD: lance.c,v 1.58 2019/05/29 10:07:29 msaitoh Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: lance.c,v 1.57 2019/05/28 07:41:48 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: lance.c,v 1.58 2019/05/29 10:07:29 msaitoh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -182,6 +182,7 @@ lance_config(struct lance_softc *sc)
IFQ_SET_READY(&ifp->if_snd);
/* Initialize ifmedia structures. */
sc->sc_ethercom.ec_ifmedia = &sc->sc_media;
ifmedia_init(&sc->sc_media, 0, lance_mediachange, lance_mediastatus);
if (sc->sc_supmedia != NULL) {
for (i = 0; i < sc->sc_nsupmedia; i++)
@ -516,16 +517,11 @@ int
lance_ioctl(struct ifnet *ifp, u_long cmd, void *data)
{
struct lance_softc *sc = ifp->if_softc;
struct ifreq *ifr = (struct ifreq *)data;
int s, error = 0;
s = splnet();
switch (cmd) {
case SIOCGIFMEDIA:
case SIOCSIFMEDIA:
error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd);
break;
default:
if ((error = ether_ioctl(ifp, cmd, data)) != ENETRESET)
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: lemac.c,v 1.53 2019/05/28 07:41:48 msaitoh Exp $ */
/* $NetBSD: lemac.c,v 1.54 2019/05/29 10:07:29 msaitoh Exp $ */
/*-
* Copyright (c) 1994, 1995, 1997 Matt Thomas <matt@3am-software.com>
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: lemac.c,v 1.53 2019/05/28 07:41:48 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: lemac.c,v 1.54 2019/05/29 10:07:29 msaitoh Exp $");
#include "opt_inet.h"
@ -771,12 +771,6 @@ lemac_ifioctl(
}
break;
case SIOCSIFMEDIA:
case SIOCGIFMEDIA:
error = ifmedia_ioctl(ifp, (struct ifreq *)data,
&sc->sc_ifmedia, cmd);
break;
default:
error = ether_ioctl(ifp, cmd, data);
break;
@ -981,9 +975,10 @@ lemac_ifattach(lemac_softc_t *sc)
rnd_attach_source(&sc->rnd_source, device_xname(sc->sc_dev),
RND_TYPE_NET, RND_FLAG_DEFAULT);
/* Initialize ifmedia structures. */
sc->sc_ec.ec_ifmedia = &sc->sc_ifmedia;
ifmedia_init(&sc->sc_ifmedia, 0,
lemac_ifmedia_change,
lemac_ifmedia_status);
lemac_ifmedia_change, lemac_ifmedia_status);
if (sc->sc_prodname[4] == '5') /* DE205 is UTP/AUI */
ifmedia_add(&sc->sc_ifmedia, IFM_ETHER | IFM_AUTO,
0, 0);

View File

@ -1,4 +1,4 @@
/* $NetBSD: mb86950.c,v 1.31 2019/05/23 13:10:51 msaitoh Exp $ */
/* $NetBSD: mb86950.c,v 1.32 2019/05/29 10:07:29 msaitoh Exp $ */
/*
* All Rights Reserved, Copyright (C) Fujitsu Limited 1995
@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mb86950.c,v 1.31 2019/05/23 13:10:51 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: mb86950.c,v 1.32 2019/05/29 10:07:29 msaitoh Exp $");
/*
* Device driver for Fujitsu mb86950 based Ethernet cards.
@ -276,6 +276,7 @@ mb86950_config(struct mb86950_softc *sc, int *media, int nmedia, int defmedia)
/* XXX The Tiara LANCard uses board jumpers to change media.
* This code may have to be changed for other cards.
*/
sc->sc_ec.ec_ifmedia = &sc->sc_media;
ifmedia_init(&sc->sc_media, 0, mb86950_mediachange,
mb86950_mediastatus);
ifmedia_add(&sc->sc_media, IFM_ETHER | IFM_MANUAL, 0, NULL);
@ -428,7 +429,6 @@ mb86950_ioctl(struct ifnet *ifp, unsigned long cmd, void *data)
{
struct mb86950_softc *sc = ifp->if_softc;
struct ifaddr *ifa = (struct ifaddr *)data;
struct ifreq *ifr = (struct ifreq *)data;
int s, error = 0;
@ -504,11 +504,6 @@ mb86950_ioctl(struct ifnet *ifp, unsigned long cmd, void *data)
#endif
break;
case SIOCGIFMEDIA:
case SIOCSIFMEDIA:
error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd);
break;
default:
error = ether_ioctl(ifp, cmd, data);
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: mb86960.c,v 1.92 2019/05/28 07:41:48 msaitoh Exp $ */
/* $NetBSD: mb86960.c,v 1.93 2019/05/29 10:07:29 msaitoh Exp $ */
/*
* All Rights Reserved, Copyright (C) Fujitsu Limited 1995
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mb86960.c,v 1.92 2019/05/28 07:41:48 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: mb86960.c,v 1.93 2019/05/29 10:07:29 msaitoh Exp $");
/*
* Device driver for Fujitsu MB86960A/MB86965A based Ethernet cards.
@ -229,6 +229,7 @@ mb86960_config(struct mb86960_softc *sc, int *media, int nmedia, int defmedia)
}
/* Initialize media goo. */
sc->sc_ec.ec_ifmedia = &sc->sc_media;
ifmedia_init(&sc->sc_media, 0, mb86960_mediachange,
mb86960_mediastatus);
if (media != NULL) {
@ -1159,7 +1160,6 @@ mb86960_ioctl(struct ifnet *ifp, u_long cmd, void *data)
{
struct mb86960_softc *sc = ifp->if_softc;
struct ifaddr *ifa = (struct ifaddr *)data;
struct ifreq *ifr = (struct ifreq *)data;
int s, error = 0;
#if FE_DEBUG >= 3
@ -1248,11 +1248,6 @@ mb86960_ioctl(struct ifnet *ifp, u_long cmd, void *data)
}
break;
case SIOCGIFMEDIA:
case SIOCSIFMEDIA:
error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd);
break;
default:
error = ether_ioctl(ifp, cmd, data);
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: pdq_ifsubr.c,v 1.66 2019/05/28 07:41:48 msaitoh Exp $ */
/* $NetBSD: pdq_ifsubr.c,v 1.67 2019/05/29 10:07:29 msaitoh Exp $ */
/*-
* Copyright (c) 1995, 1996 Matt Thomas <matt@3am-software.com>
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pdq_ifsubr.c,v 1.66 2019/05/28 07:41:48 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: pdq_ifsubr.c,v 1.67 2019/05/29 10:07:29 msaitoh Exp $");
#ifdef __NetBSD__
#include "opt_inet.h"
@ -436,15 +436,6 @@ pdq_ifioctl(struct ifnet *ifp, ioctl_cmd_t cmd, void *data)
}
#endif /* SIOCSIFMTU */
#if defined(IFM_FDDI) && defined(SIOCSIFMEDIA)
case SIOCSIFMEDIA:
case SIOCGIFMEDIA: {
struct ifreq *ifr = (struct ifreq *)data;
error = ifmedia_ioctl(ifp, ifr, &sc->sc_ifmedia, cmd);
break;
}
#endif
default: {
error = ether_ioctl(ifp, cmd, data);
break;
@ -479,6 +470,9 @@ pdq_ifattach(pdq_softc_t *sc, ifnet_ret_t (*ifwatchdog)(int unit))
#if defined(IFM_FDDI)
{
const int media = sc->sc_ifmedia.ifm_media;
/* Initialize ifmedia structures. */
PDQ_FDDICOM(sc)->ec_ifmedia = &sc->sc_ifmedia;
ifmedia_init(&sc->sc_ifmedia, IFM_FDX,
pdq_ifmedia_change, pdq_ifmedia_status);
ifmedia_add(&sc->sc_ifmedia, media, 0, 0);

View File

@ -1,4 +1,4 @@
/* $NetBSD: tropic.c,v 1.52 2019/02/05 06:17:02 msaitoh Exp $ */
/* $NetBSD: tropic.c,v 1.53 2019/05/29 10:07:29 msaitoh Exp $ */
/*
* Ported to NetBSD by Onno van der Linden
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: tropic.c,v 1.52 2019/02/05 06:17:02 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: tropic.c,v 1.53 2019/05/29 10:07:29 msaitoh Exp $");
#include "opt_inet.h"
@ -396,6 +396,8 @@ tr_attach(struct tr_softc *sc)
}
}
/* Initialize ifmedia structures. */
sc->sc_ethercom.ec_ifmedia = &sc->sc_media;
ifmedia_init(&sc->sc_media, 0, tr_mediachange, tr_mediastatus);
if (mediaptr != NULL) {
for (i = 0; i < nmedia; i++)
@ -1547,10 +1549,6 @@ tr_ioctl(struct ifnet *ifp, u_long cmd, void *data)
break;
}
break;
case SIOCGIFMEDIA:
case SIOCSIFMEDIA:
error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd);
break;
case SIOCSIFMTU:
if (ifr->ifr_mtu > sc->sc_maxmtu)
error = EINVAL;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_iy.c,v 1.108 2019/05/28 07:41:49 msaitoh Exp $ */
/* $NetBSD: if_iy.c,v 1.109 2019/05/29 10:07:29 msaitoh Exp $ */
/* #define IYDEBUG */
/* #define IYMEMDEBUG */
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_iy.c,v 1.108 2019/05/28 07:41:49 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_iy.c,v 1.109 2019/05/29 10:07:29 msaitoh Exp $");
#include "opt_inet.h"
@ -334,6 +334,8 @@ iyattach(device_t parent, device_t self, void *aux)
myaddr[5] = eaddr[EEPPEther2] & 0xFF;
myaddr[4] = eaddr[EEPPEther2] >> 8;
/* Initialize ifmedia structures. */
sc->sc_ethercom.ec_ifmedia = &sc->iy_ifmedia;
ifmedia_init(&sc->iy_ifmedia, 0, iy_mediachange, iy_mediastatus);
ifmedia_add(&sc->iy_ifmedia, IFM_ETHER | IFM_10_2, 0, NULL);
ifmedia_add(&sc->iy_ifmedia, IFM_ETHER | IFM_10_5, 0, NULL);
@ -1161,12 +1163,10 @@ iyioctl(struct ifnet *ifp, u_long cmd, void *data)
{
struct iy_softc *sc;
struct ifaddr *ifa;
struct ifreq *ifr;
int s, error = 0;
sc = ifp->if_softc;
ifa = (struct ifaddr *)data;
ifr = (struct ifreq *)data;
#ifdef IYDEBUG
printf("iyioctl called with ifp %p (%s) cmd 0x%lx data %p\n",
@ -1246,10 +1246,6 @@ iyioctl(struct ifnet *ifp, u_long cmd, void *data)
}
break;
case SIOCSIFMEDIA:
case SIOCGIFMEDIA:
error = ifmedia_ioctl(ifp, ifr, &sc->iy_ifmedia, cmd);
break;
default:
error = ether_ioctl(ifp, cmd, data);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_bge.c,v 1.333 2019/05/28 07:41:49 msaitoh Exp $ */
/* $NetBSD: if_bge.c,v 1.334 2019/05/29 10:07:29 msaitoh Exp $ */
/*
* Copyright (c) 2001 Wind River Systems
@ -79,7 +79,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.333 2019/05/28 07:41:49 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.334 2019/05/29 10:07:29 msaitoh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -3870,7 +3870,9 @@ bge_attach(device_t parent, device_t self, void *aux)
prop_dictionary_set_uint32(dict, "phyflags", sc->bge_phy_flags);
prop_dictionary_set_uint32(dict, "chipid", sc->bge_chipid);
/* Initialize ifmedia structures. */
if (sc->bge_flags & BGEF_FIBER_TBI) {
sc->ethercom.ec_ifmedia = &sc->bge_ifmedia;
ifmedia_init(&sc->bge_ifmedia, IFM_IMASK, bge_ifmedia_upd,
bge_ifmedia_sts);
ifmedia_add(&sc->bge_ifmedia, IFM_ETHER |IFM_1000_SX, 0, NULL);
@ -3891,6 +3893,7 @@ bge_attach(device_t parent, device_t self, void *aux)
BGE_CLRBIT(sc, BGE_MODE_CTL, BGE_MODECTL_STACKUP);
bge_asf_driver_up(sc);
sc->ethercom.ec_mii = mii;
ifmedia_init(&mii->mii_media, 0, bge_ifmedia_upd,
bge_ifmedia_sts);
mii_flags = MIIF_DOPAUSE;
@ -5814,8 +5817,7 @@ bge_ioctl(struct ifnet *ifp, u_long command, void *data)
}
sc->bge_flowflags = ifr->ifr_media & IFM_ETH_FMASK;
}
/* FALLTHROUGH */
case SIOCGIFMEDIA:
if (sc->bge_flags & BGEF_FIBER_TBI) {
error = ifmedia_ioctl(ifp, ifr, &sc->bge_ifmedia,
command);

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_de.c,v 1.162 2019/05/28 07:41:49 msaitoh Exp $ */
/* $NetBSD: if_de.c,v 1.163 2019/05/29 10:07:29 msaitoh Exp $ */
/*-
* Copyright (c) 1994-1997 Matt Thomas (matt@3am-software.com)
@ -37,7 +37,7 @@
* board which support 21040, 21041, or 21140 (mostly).
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_de.c,v 1.162 2019/05/28 07:41:49 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_de.c,v 1.163 2019/05/29 10:07:29 msaitoh Exp $");
#define TULIP_HDR_DATA
@ -4821,11 +4821,6 @@ tulip_ifioctl(struct ifnet *ifp, unsigned long cmd, void *data)
break;
tulip_init(sc);
break;
case SIOCSIFMEDIA:
case SIOCGIFMEDIA:
error = ifmedia_ioctl(ifp, ifr, &sc->tulip_ifmedia, cmd);
break;
case SIOCADDMULTI:
case SIOCDELMULTI:
/*
@ -5089,6 +5084,9 @@ tulip_attach(tulip_softc_t * const sc)
#endif
(*sc->tulip_boardsw->bd_media_probe)(sc);
/* Initialize ifmedia structures. */
TULIP_ETHERCOM(sc)->ec_ifmedia = &sc->tulip_ifmedia;
ifmedia_init(&sc->tulip_ifmedia, 0,
tulip_ifmedia_change, tulip_ifmedia_status);
sc->tulip_flags &= ~TULIP_DEVICEPROBE;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_dge.c,v 1.54 2019/05/28 07:41:49 msaitoh Exp $ */
/* $NetBSD: if_dge.c,v 1.55 2019/05/29 10:07:29 msaitoh Exp $ */
/*
* Copyright (c) 2004, SUNET, Swedish University Computer Network.
@ -80,7 +80,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_dge.c,v 1.54 2019/05/28 07:41:49 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_dge.c,v 1.55 2019/05/29 10:07:29 msaitoh Exp $");
@ -908,6 +908,7 @@ dge_attach(device_t parent, device_t self, void *aux)
/*
* Setup media stuff.
*/
sc->sc_ethercom.ec_ifmedia = &sc->sc_media;
ifmedia_init(&sc->sc_media, IFM_IMASK, dge_xgmii_mediachange,
dge_xgmii_mediastatus);
if (dgep->dgep_flags & DGEP_F_10G_SR) {
@ -1454,11 +1455,6 @@ dge_ioctl(struct ifnet *ifp, u_long cmd, void *data)
s = splnet();
switch (cmd) {
case SIOCSIFMEDIA:
case SIOCGIFMEDIA:
error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd);
break;
case SIOCSIFMTU:
if (ifr->ifr_mtu < ETHERMIN || ifr->ifr_mtu > DGE_MAX_MTU)
error = EINVAL;

View File

@ -31,7 +31,7 @@
#if 0
__FBSDID("$FreeBSD: head/sys/dev/ena/ena.c 333456 2018-05-10 09:37:54Z mw $");
#endif
__KERNEL_RCSID(0, "$NetBSD: if_ena.c,v 1.14 2019/04/26 04:33:00 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_ena.c,v 1.15 2019/05/29 10:07:29 msaitoh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -2371,11 +2371,6 @@ ena_ioctl(struct ifnet *ifp, u_long command, void *data)
case SIOCDELMULTI:
break;
case SIOCSIFMEDIA:
case SIOCGIFMEDIA:
rc = ifmedia_ioctl(ifp, ifr, &adapter->media, command);
break;
case SIOCSIFCAP:
{
struct ifcapreq *ifcr = data;
@ -2542,6 +2537,7 @@ ena_setup_ifnet(device_t pdev, struct ena_adapter *adapter,
* Specify the media types supported by this adapter and register
* callbacks to update media and link information
*/
adapter->sc_ec.ec_ifmedia = &adapter->media;
ifmedia_init(&adapter->media, IFM_IMASK,
ena_media_change, ena_media_status);
ifmedia_add(&adapter->media, IFM_ETHER | IFM_AUTO, 0, NULL);

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_kse.c,v 1.37 2019/05/28 07:41:49 msaitoh Exp $ */
/* $NetBSD: if_kse.c,v 1.38 2019/05/29 10:07:29 msaitoh Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_kse.c,v 1.37 2019/05/28 07:41:49 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_kse.c,v 1.38 2019/05/29 10:07:29 msaitoh Exp $");
#include <sys/param.h>
@ -490,7 +490,9 @@ kse_attach(device_t parent, device_t self, void *aux)
callout_init(&sc->sc_callout, 0);
callout_init(&sc->sc_stat_ch, 0);
/* Initialize ifmedia structures. */
ifm = &sc->sc_media;
sc->sc_ethercom.ec_ifmedia = ifm;
if (sc->sc_chip == 0x8841) {
ifmedia_init(ifm, 0, ifmedia_upd, ifmedia_sts);
ifmedia_add(ifm, IFM_ETHER | IFM_10_T, 0, NULL);
@ -638,17 +640,11 @@ static int
kse_ioctl(struct ifnet *ifp, u_long cmd, void *data)
{
struct kse_softc *sc = ifp->if_softc;
struct ifreq *ifr = (struct ifreq *)data;
int s, error;
s = splnet();
switch (cmd) {
case SIOCSIFMEDIA:
case SIOCGIFMEDIA:
error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd);
break;
default:
if ((error = ether_ioctl(ifp, cmd, data)) != ENETRESET)
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ti.c,v 1.110 2019/05/28 07:41:49 msaitoh Exp $ */
/* $NetBSD: if_ti.c,v 1.111 2019/05/29 10:07:29 msaitoh Exp $ */
/*
* Copyright (c) 1997, 1998, 1999
@ -81,7 +81,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_ti.c,v 1.110 2019/05/28 07:41:49 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_ti.c,v 1.111 2019/05/29 10:07:29 msaitoh Exp $");
#include "opt_inet.h"
@ -1841,6 +1841,7 @@ ti_attach(device_t parent, device_t self, void *aux)
IFCAP_CSUM_UDPv4_Tx | IFCAP_CSUM_UDPv4_Rx;
/* Set up ifmedia support. */
sc->ethercom.ec_ifmedia = &sc->ifmedia;
ifmedia_init(&sc->ifmedia, IFM_IMASK, ti_ifmedia_upd, ti_ifmedia_sts);
if (sc->ti_copper) {
/*
@ -2766,10 +2767,6 @@ ti_ioctl(struct ifnet *ifp, u_long command, void *data)
sc->ti_if_flags = ifp->if_flags;
error = 0;
break;
case SIOCSIFMEDIA:
case SIOCGIFMEDIA:
error = ifmedia_ioctl(ifp, ifr, &sc->ifmedia, command);
break;
default:
if ((error = ether_ioctl(ifp, command, data)) != ENETRESET)
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_txp.c,v 1.56 2019/05/28 07:41:49 msaitoh Exp $ */
/* $NetBSD: if_txp.c,v 1.57 2019/05/29 10:07:29 msaitoh Exp $ */
/*
* Copyright (c) 2001
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_txp.c,v 1.56 2019/05/28 07:41:49 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_txp.c,v 1.57 2019/05/29 10:07:29 msaitoh Exp $");
#include "opt_inet.h"
@ -291,6 +291,8 @@ txp_attach(device_t parent, device_t self, void *aux)
ether_sprintf(enaddr));
sc->sc_cold = 0;
/* Initialize ifmedia structures. */
sc->sc_arpcom.ec_ifmedia = &sc->sc_ifmedia;
ifmedia_init(&sc->sc_ifmedia, 0, txp_ifmedia_upd, txp_ifmedia_sts);
if (flags & TXP_FIBER) {
ifmedia_add(&sc->sc_ifmedia, IFM_ETHER | IFM_100_FX,
@ -1249,7 +1251,6 @@ int
txp_ioctl(struct ifnet *ifp, u_long command, void *data)
{
struct txp_softc *sc = ifp->if_softc;
struct ifreq *ifr = (struct ifreq *)data;
struct ifaddr *ifa = (struct ifaddr *)data;
int s, error = 0;
@ -1303,10 +1304,6 @@ txp_ioctl(struct ifnet *ifp, u_long command, void *data)
txp_set_filter(sc);
}
break;
case SIOCGIFMEDIA:
case SIOCSIFMEDIA:
error = ifmedia_ioctl(ifp, ifr, &sc->sc_ifmedia, command);
break;
default:
error = ether_ioctl(ifp, command, data);
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_xge.c,v 1.31 2019/05/28 07:41:49 msaitoh Exp $ */
/* $NetBSD: if_xge.c,v 1.32 2019/05/29 10:07:29 msaitoh Exp $ */
/*
* Copyright (c) 2004, SUNET, Swedish University Computer Network.
@ -43,7 +43,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_xge.c,v 1.31 2019/05/28 07:41:49 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_xge.c,v 1.32 2019/05/29 10:07:29 msaitoh Exp $");
#include <sys/param.h>
@ -517,6 +517,7 @@ xge_attach(device_t parent, device_t self, void *aux)
/*
* Setup media stuff.
*/
sc->sc_ethercom.ec_ifmedia = &sc->xena_media;
ifmedia_init(&sc->xena_media, IFM_IMASK, xge_xgmii_mediachange,
xge_ifmedia_status);
ifmedia_add(&sc->xena_media, IFM_ETHER | IFM_10G_LR, 0, NULL);
@ -853,11 +854,6 @@ xge_ioctl(struct ifnet *ifp, u_long cmd, void *data)
}
break;
case SIOCGIFMEDIA:
case SIOCSIFMEDIA:
error = ifmedia_ioctl(ifp, ifr, &sc->xena_media, cmd);
break;
default:
if ((error = ether_ioctl(ifp, cmd, data)) != ENETRESET)
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ixgbe.c,v 1.186 2019/05/23 13:10:52 msaitoh Exp $ */
/* $NetBSD: ixgbe.c,v 1.187 2019/05/29 10:07:30 msaitoh Exp $ */
/******************************************************************************
@ -1372,6 +1372,7 @@ ixgbe_setup_interface(device_t dev, struct adapter *adapter)
* Specify the media types supported by this adapter and register
* callbacks to update media and link information
*/
ec->ec_ifmedia = &adapter->media;
ifmedia_init(&adapter->media, IFM_IMASK, ixgbe_media_change,
ixgbe_media_status);
@ -6231,9 +6232,6 @@ ixgbe_ioctl(struct ifnet * ifp, u_long command, void *data)
}
switch (command) {
case SIOCSIFMEDIA:
case SIOCGIFMEDIA:
return ifmedia_ioctl(ifp, ifr, &adapter->media, command);
case SIOCGI2C:
{
struct ixgbe_i2c_req i2c;

View File

@ -1,4 +1,4 @@
/*$NetBSD: ixv.c,v 1.114 2019/05/23 13:10:52 msaitoh Exp $*/
/*$NetBSD: ixv.c,v 1.115 2019/05/29 10:07:30 msaitoh Exp $*/
/******************************************************************************
@ -1572,6 +1572,7 @@ ixv_setup_interface(device_t dev, struct adapter *adapter)
* Specify the media types supported by this adapter and register
* callbacks to update media and link information
*/
ec->ec_ifmedia = &adapter->media;
ifmedia_init(&adapter->media, IFM_IMASK, ixv_media_change,
ixv_media_status);
ifmedia_add(&adapter->media, IFM_ETHER | IFM_AUTO, 0, NULL);
@ -2776,7 +2777,6 @@ ixv_ioctl(struct ifnet *ifp, u_long command, void *data)
{
struct adapter *adapter = ifp->if_softc;
struct ifcapreq *ifcr = data;
struct ifreq *ifr = data;
int error = 0;
int l4csum_en;
const int l4csum = IFCAP_CSUM_TCPv4_Rx | IFCAP_CSUM_UDPv4_Rx |
@ -2806,9 +2806,6 @@ ixv_ioctl(struct ifnet *ifp, u_long command, void *data)
}
switch (command) {
case SIOCSIFMEDIA:
case SIOCGIFMEDIA:
return ifmedia_ioctl(ifp, ifr, &adapter->media, command);
case SIOCSIFCAP:
/* Layer-4 Rx checksum offload has to be turned on and
* off as a unit.

View File

@ -1,4 +1,4 @@
/* $NetBSD: be.c,v 1.93 2019/05/28 07:41:49 msaitoh Exp $ */
/* $NetBSD: be.c,v 1.94 2019/05/29 10:07:30 msaitoh Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -57,7 +57,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: be.c,v 1.93 2019/05/28 07:41:49 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: be.c,v 1.94 2019/05/29 10:07:30 msaitoh Exp $");
#include "opt_ddb.h"
#include "opt_inet.h"
@ -337,6 +337,7 @@ beattach(device_t parent, device_t self, void *aux)
mii->mii_writereg = be_mii_writereg;
mii->mii_statchg = be_mii_statchg;
sc->sc_ethercom.ec_mii = mii;
ifmedia_init(&mii->mii_media, 0, be_ifmedia_upd, be_ifmedia_sts);
/*
@ -932,9 +933,10 @@ berint(struct be_softc *sc)
int
beioctl(struct ifnet *ifp, u_long cmd, void *data)
{
#ifdef BEDEBUG
struct be_softc *sc = ifp->if_softc;
#endif
struct ifaddr *ifa = data;
struct ifreq *ifr = data;
int s, error = 0;
s = splnet();
@ -991,10 +993,6 @@ beioctl(struct ifnet *ifp, u_long cmd, void *data)
#endif
break;
case SIOCGIFMEDIA:
case SIOCSIFMEDIA:
error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd);
break;
default:
if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) {
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: qe.c,v 1.74 2019/05/28 07:41:49 msaitoh Exp $ */
/* $NetBSD: qe.c,v 1.75 2019/05/29 10:07:30 msaitoh Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: qe.c,v 1.74 2019/05/28 07:41:49 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: qe.c,v 1.75 2019/05/29 10:07:30 msaitoh Exp $");
#define QEDEBUG
@ -283,6 +283,7 @@ qeattach(device_t parent, device_t self, void *aux)
sc->sc_rb.rb_dmabase = sc->sc_dmamap->dm_segs[0].ds_addr;
/* Initialize media properties */
sc->sc_ethercom.ec_ifmedia = &sc->sc_ifmedia;
ifmedia_init(&sc->sc_ifmedia, 0, qe_ifmedia_upd, qe_ifmedia_sts);
ifmedia_add(&sc->sc_ifmedia,
IFM_MAKEWORD(IFM_ETHER, IFM_10_T, 0, 0),
@ -872,7 +873,6 @@ qeioctl(struct ifnet *ifp, u_long cmd, void *data)
{
struct qe_softc *sc = ifp->if_softc;
struct ifaddr *ifa = data;
struct ifreq *ifr = data;
int s, error = 0;
s = splnet();
@ -939,11 +939,6 @@ qeioctl(struct ifnet *ifp, u_long cmd, void *data)
}
break;
case SIOCGIFMEDIA:
case SIOCSIFMEDIA:
error = ifmedia_ioctl(ifp, ifr, &sc->sc_ifmedia, cmd);
break;
default:
error = ether_ioctl(ifp, cmd, data);
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ether.h,v 1.78 2019/05/15 02:56:48 ozaki-r Exp $ */
/* $NetBSD: if_ether.h,v 1.79 2019/05/29 10:07:30 msaitoh Exp $ */
/*
* Copyright (c) 1982, 1986, 1993
@ -183,6 +183,7 @@ struct ethercom {
int ec_nvlans; /* # VLANs on this interface */
/* The device handle for the MII bus child device. */
struct mii_data *ec_mii;
struct ifmedia *ec_ifmedia;
/* Called after a change to ec_if.if_flags. Returns
* ENETRESET if the device should be reinitialized with
* ec_if.if_init, 0 on success, not 0 on failure.

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ethersubr.c,v 1.274 2019/05/15 02:56:48 ozaki-r Exp $ */
/* $NetBSD: if_ethersubr.c,v 1.275 2019/05/29 10:07:30 msaitoh Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.274 2019/05/15 02:56:48 ozaki-r Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.275 2019/05/29 10:07:30 msaitoh Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@ -1503,9 +1503,14 @@ ether_ioctl(struct ifnet *ifp, u_long cmd, void *data)
return ether_delmulti(ifreq_getaddr(cmd, ifr), ec);
case SIOCSIFMEDIA:
case SIOCGIFMEDIA:
if (ec->ec_mii == NULL)
if (ec->ec_mii != NULL)
return ifmedia_ioctl(ifp, ifr, &ec->ec_mii->mii_media,
cmd);
else if (ec->ec_ifmedia != NULL)
return ifmedia_ioctl(ifp, ifr, ec->ec_ifmedia, cmd);
else
return ENOTTY;
return ifmedia_ioctl(ifp, ifr, &ec->ec_mii->mii_media, cmd);
break;
case SIOCALIFADDR:
sdl = satocsdl(sstocsa(&iflr->addr));
if (sdl->sdl_family != AF_LINK)

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_tap.c,v 1.112 2019/05/21 09:18:37 msaitoh Exp $ */
/* $NetBSD: if_tap.c,v 1.113 2019/05/29 10:07:30 msaitoh Exp $ */
/*
* Copyright (c) 2003, 2004, 2008, 2009 The NetBSD Foundation.
@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.112 2019/05/21 09:18:37 msaitoh Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.113 2019/05/29 10:07:30 msaitoh Exp $");
#if defined(_KERNEL_OPT)
@ -350,6 +350,7 @@ tap_attach(device_t parent, device_t self, void *aux)
* list of supported media, and in the end, the selection of one
* of them.
*/
sc->sc_ec.ec_ifmedia = &sc->sc_im;
ifmedia_init(&sc->sc_im, 0, tap_mediachange, tap_mediastatus);
ifmedia_add(&sc->sc_im, IFM_ETHER | IFM_1000_T, 0, NULL);
ifmedia_add(&sc->sc_im, IFM_ETHER | IFM_1000_T | IFM_FDX, 0, NULL);
@ -573,17 +574,11 @@ tap_softintr(void *cookie)
static int
tap_ioctl(struct ifnet *ifp, u_long cmd, void *data)
{
struct tap_softc *sc = (struct tap_softc *)ifp->if_softc;
struct ifreq *ifr = (struct ifreq *)data;
int s, error;
s = splnet();
switch (cmd) {
case SIOCSIFMEDIA:
case SIOCGIFMEDIA:
error = ifmedia_ioctl(ifp, ifr, &sc->sc_im, cmd);
break;
case SIOCSIFPHYADDR:
error = tap_lifaddr(ifp, cmd, (struct ifaliasreq *)data);
break;