hyperv/hn: Pull ether address and link status extraction up.
MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7831
This commit is contained in:
parent
ffce674242
commit
684e8a79fe
@ -99,11 +99,6 @@ struct vmbus_channel;
|
||||
#define NETVSC_DEVICE_RING_BUFFER_SIZE (128 * PAGE_SIZE)
|
||||
#define NETVSC_PACKET_MAXPAGE 32
|
||||
|
||||
typedef struct {
|
||||
uint8_t mac_addr[ETHER_ADDR_LEN];
|
||||
uint32_t link_state;
|
||||
} netvsc_device_info;
|
||||
|
||||
#define HN_XACT_REQ_PGCNT 2
|
||||
#define HN_XACT_RESP_PGCNT 2
|
||||
#define HN_XACT_REQ_SIZE (HN_XACT_REQ_PGCNT * PAGE_SIZE)
|
||||
|
@ -440,7 +440,8 @@ netvsc_attach(device_t dev)
|
||||
{
|
||||
struct sysctl_oid_list *child;
|
||||
struct sysctl_ctx_list *ctx;
|
||||
netvsc_device_info device_info;
|
||||
uint8_t eaddr[ETHER_ADDR_LEN];
|
||||
uint32_t link_status;
|
||||
hn_softc_t *sc;
|
||||
int unit = device_get_unit(dev);
|
||||
struct ifnet *ifp = NULL;
|
||||
@ -564,7 +565,7 @@ netvsc_attach(device_t dev)
|
||||
if (sc->hn_xact == NULL)
|
||||
goto failed;
|
||||
|
||||
error = hv_rf_on_device_add(sc, &device_info, &ring_cnt, ETHERMTU);
|
||||
error = hv_rf_on_device_add(sc, &ring_cnt, ETHERMTU);
|
||||
if (error)
|
||||
goto failed;
|
||||
KASSERT(ring_cnt > 0 && ring_cnt <= sc->hn_rx_ring_inuse,
|
||||
@ -597,9 +598,11 @@ netvsc_attach(device_t dev)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (device_info.link_state == NDIS_MEDIA_STATE_CONNECTED) {
|
||||
error = hn_rndis_get_linkstatus(sc, &link_status);
|
||||
if (error)
|
||||
goto failed;
|
||||
if (link_status == NDIS_MEDIA_STATE_CONNECTED)
|
||||
sc->hn_carrier = 1;
|
||||
}
|
||||
|
||||
#if __FreeBSD_version >= 1100045
|
||||
tso_maxlen = hn_tso_maxlen;
|
||||
@ -612,7 +615,10 @@ netvsc_attach(device_t dev)
|
||||
(ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN);
|
||||
#endif
|
||||
|
||||
ether_ifattach(ifp, device_info.mac_addr);
|
||||
error = hn_rndis_get_eaddr(sc, eaddr);
|
||||
if (error)
|
||||
goto failed;
|
||||
ether_ifattach(ifp, eaddr);
|
||||
|
||||
#if __FreeBSD_version >= 1100045
|
||||
if_printf(ifp, "TSO: %u/%u/%u\n", ifp->if_hw_tsomax,
|
||||
@ -1503,7 +1509,6 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||
#ifdef INET
|
||||
struct ifaddr *ifa = (struct ifaddr *)data;
|
||||
#endif
|
||||
netvsc_device_info device_info;
|
||||
int mask, error = 0, ring_cnt;
|
||||
int retry_cnt = 500;
|
||||
|
||||
@ -1583,8 +1588,7 @@ hn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
||||
hn_chan_attach(sc, sc->hn_prichan); /* XXX check error */
|
||||
|
||||
ring_cnt = sc->hn_rx_ring_inuse;
|
||||
error = hv_rf_on_device_add(sc, &device_info, &ring_cnt,
|
||||
ifr->ifr_mtu);
|
||||
error = hv_rf_on_device_add(sc, &ring_cnt, ifr->ifr_mtu);
|
||||
if (error) {
|
||||
NV_LOCK(sc);
|
||||
sc->temp_unusable = FALSE;
|
||||
|
@ -75,9 +75,6 @@ static void hv_rf_receive_indicate_status(struct hn_softc *sc,
|
||||
const void *data, int dlen);
|
||||
static void hv_rf_receive_data(struct hn_rx_ring *rxr,
|
||||
const void *data, int dlen);
|
||||
static int hv_rf_query_device_mac(struct hn_softc *sc, uint8_t *eaddr);
|
||||
static int hv_rf_query_device_link_status(struct hn_softc *sc,
|
||||
uint32_t *link_status);
|
||||
|
||||
static int hn_rndis_query(struct hn_softc *sc, uint32_t oid,
|
||||
const void *idata, size_t idlen, void *odata, size_t *odlen0);
|
||||
@ -479,11 +476,8 @@ hv_rf_on_receive(struct hn_softc *sc, struct hn_rx_ring *rxr,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* RNDIS filter query device MAC address
|
||||
*/
|
||||
static int
|
||||
hv_rf_query_device_mac(struct hn_softc *sc, uint8_t *eaddr)
|
||||
int
|
||||
hn_rndis_get_eaddr(struct hn_softc *sc, uint8_t *eaddr)
|
||||
{
|
||||
size_t eaddr_len;
|
||||
int error;
|
||||
@ -500,11 +494,8 @@ hv_rf_query_device_mac(struct hn_softc *sc, uint8_t *eaddr)
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* RNDIS filter query device link status
|
||||
*/
|
||||
static int
|
||||
hv_rf_query_device_link_status(struct hn_softc *sc, uint32_t *link_status)
|
||||
int
|
||||
hn_rndis_get_linkstatus(struct hn_softc *sc, uint32_t *link_status)
|
||||
{
|
||||
size_t size;
|
||||
int error;
|
||||
@ -1024,11 +1015,9 @@ hn_rndis_attach(struct hn_softc *sc)
|
||||
}
|
||||
|
||||
int
|
||||
hv_rf_on_device_add(struct hn_softc *sc, void *additl_info,
|
||||
int *nchan0, int mtu)
|
||||
hv_rf_on_device_add(struct hn_softc *sc, int *nchan0, int mtu)
|
||||
{
|
||||
int ret;
|
||||
netvsc_device_info *dev_info = (netvsc_device_info *)additl_info;
|
||||
device_t dev = sc->hn_dev;
|
||||
int nchan = *nchan0, rxr_cnt, nsubch;
|
||||
|
||||
@ -1040,13 +1029,6 @@ hv_rf_on_device_add(struct hn_softc *sc, void *additl_info,
|
||||
if (ret != 0)
|
||||
return (ret);
|
||||
|
||||
/* Get the mac address */
|
||||
ret = hv_rf_query_device_mac(sc, dev_info->mac_addr);
|
||||
if (ret != 0) {
|
||||
/* TODO: shut down rndis device and the channel */
|
||||
}
|
||||
hv_rf_query_device_link_status(sc, &dev_info->link_state);
|
||||
|
||||
if (sc->hn_ndis_ver < HN_NDIS_VERSION_6_30 || nchan == 1) {
|
||||
/*
|
||||
* Either RSS is not supported, or multiple RX/TX rings
|
||||
|
@ -43,8 +43,7 @@ struct hn_rx_ring;
|
||||
void hv_rf_on_receive(struct hn_softc *sc, struct hn_rx_ring *rxr,
|
||||
const void *data, int dlen);
|
||||
void hv_rf_channel_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr);
|
||||
int hv_rf_on_device_add(struct hn_softc *sc, void *additl_info, int *nchan,
|
||||
int mtu);
|
||||
int hv_rf_on_device_add(struct hn_softc *sc, int *nchan, int mtu);
|
||||
int hv_rf_on_device_remove(struct hn_softc *sc);
|
||||
int hv_rf_on_open(struct hn_softc *sc);
|
||||
int hv_rf_on_close(struct hn_softc *sc);
|
||||
|
@ -122,6 +122,9 @@ void hn_chim_free(struct hn_softc *sc, uint32_t chim_idx);
|
||||
void *hn_rndis_pktinfo_append(struct rndis_packet_msg *,
|
||||
size_t pktsize, size_t pi_dlen, uint32_t pi_type);
|
||||
|
||||
int hn_rndis_get_eaddr(struct hn_softc *sc, uint8_t *eaddr);
|
||||
int hn_rndis_get_linkstatus(struct hn_softc *sc,
|
||||
uint32_t *link_status);
|
||||
int hn_nvs_alloc_subchans(struct hn_softc *sc, int *nsubch);
|
||||
int hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int dlen,
|
||||
const struct hn_recvinfo *info);
|
||||
|
Loading…
Reference in New Issue
Block a user