Page MenuHomeFreeBSD

D4852.id.diff
No OneTemporary

D4852.id.diff

Index: sys/dev/hyperv/netvsc/hv_net_vsc.h
===================================================================
--- sys/dev/hyperv/netvsc/hv_net_vsc.h
+++ sys/dev/hyperv/netvsc/hv_net_vsc.h
@@ -43,9 +43,13 @@
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/sx.h>
+
#include <netinet/in.h>
#include <netinet/tcp_lro.h>
+#include <net/if.h>
+#include <net/if_media.h>
+
#include <dev/hyperv/include/hyperv.h>
MALLOC_DECLARE(M_NETVSC);
@@ -985,6 +989,7 @@
*/
typedef struct hn_softc {
struct ifnet *hn_ifp;
+ struct ifmedia hn_media;
device_t hn_dev;
uint8_t hn_unit;
int hn_carrier;
Index: sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
===================================================================
--- sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
+++ sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
@@ -194,6 +194,8 @@
static int hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data);
static int hn_start_locked(struct ifnet *ifp);
static void hn_start(struct ifnet *ifp);
+static int hn_ifmedia_upd(struct ifnet *ifp);
+static void hn_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr);
#ifdef HN_LRO_HIWAT
static int hn_lro_hiwat_sysctl(SYSCTL_HANDLER_ARGS);
#endif
@@ -264,6 +266,30 @@
return (ret_val);
}
+static int
+hn_ifmedia_upd(struct ifnet *ifp __unused)
+{
+
+ return EOPNOTSUPP;
+}
+
+static void
+hn_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
+{
+ struct hn_softc *sc = ifp->if_softc;
+
+ ifmr->ifm_status = IFM_AVALID;
+ ifmr->ifm_active = IFM_ETHER;
+
+ if (!sc->hn_carrier) {
+ ifmr->ifm_active |= IFM_NONE;
+ return;
+ }
+ ifmr->ifm_status |= IFM_ACTIVE;
+ /* NOTE: we could use KVP for this later. */
+ ifmr->ifm_active |= IFM_10G_T | IFM_FDX;
+}
+
/*
* NetVsc driver initialization
* Note: Filter init is no longer required
@@ -374,6 +400,13 @@
ifp->if_snd.ifq_drv_maxlen = 511;
IFQ_SET_READY(&ifp->if_snd);
+ ifmedia_init(&sc->hn_media, 0, hn_ifmedia_upd, hn_ifmedia_sts);
+ /* NOTE: we could use KVP for this later. */
+ ifmedia_add(&sc->hn_media, IFM_ETHER | IFM_AUTO, 0, NULL);
+ ifmedia_set(&sc->hn_media, IFM_ETHER | IFM_AUTO);
+ /* XXX ifmedia_set really should do this for us */
+ sc->hn_media.ifm_media = sc->hn_media.ifm_cur->ifm_media;
+
/*
* Tell upper layers that we support full VLAN capability.
*/
@@ -485,6 +518,7 @@
hv_rf_on_device_remove(hv_device, HV_RF_NV_DESTROY_CHANNEL);
+ ifmedia_removeall(&sc->hn_media);
tcp_lro_free(&sc->hn_lro);
return (0);
@@ -1332,10 +1366,11 @@
error = 0;
}
#endif
- /* FALLTHROUGH */
+ error = EINVAL;
+ break;
case SIOCSIFMEDIA:
case SIOCGIFMEDIA:
- error = EINVAL;
+ error = ifmedia_ioctl(ifp, ifr, &sc->hn_media, cmd);
break;
default:
error = ether_ioctl(ifp, cmd, data);

File Metadata

Mime Type
text/plain
Expires
Thu, Apr 9, 8:56 PM (4 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31171131
Default Alt Text
D4852.id.diff (2 KB)

Event Timeline