hyperv/hn: Pull data path code up.
MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8357
This commit is contained in:
parent
963767d43e
commit
f9a861bf79
@ -1244,6 +1244,42 @@ hn_rndis_pktmsg_offset(uint32_t ofs)
|
||||
return (ofs - __offsetof(struct rndis_packet_msg, rm_dataoffset));
|
||||
}
|
||||
|
||||
static __inline void *
|
||||
hn_rndis_pktinfo_append(struct rndis_packet_msg *pkt, size_t pktsize,
|
||||
size_t pi_dlen, uint32_t pi_type)
|
||||
{
|
||||
const size_t pi_size = HN_RNDIS_PKTINFO_SIZE(pi_dlen);
|
||||
struct rndis_pktinfo *pi;
|
||||
|
||||
KASSERT((pi_size & RNDIS_PACKET_MSG_OFFSET_ALIGNMASK) == 0,
|
||||
("unaligned pktinfo size %zu, pktinfo dlen %zu", pi_size, pi_dlen));
|
||||
|
||||
/*
|
||||
* Per-packet-info does not move; it only grows.
|
||||
*
|
||||
* NOTE:
|
||||
* rm_pktinfooffset in this phase counts from the beginning
|
||||
* of rndis_packet_msg.
|
||||
*/
|
||||
KASSERT(pkt->rm_pktinfooffset + pkt->rm_pktinfolen + pi_size <= pktsize,
|
||||
("%u pktinfo overflows RNDIS packet msg", pi_type));
|
||||
pi = (struct rndis_pktinfo *)((uint8_t *)pkt + pkt->rm_pktinfooffset +
|
||||
pkt->rm_pktinfolen);
|
||||
pkt->rm_pktinfolen += pi_size;
|
||||
|
||||
pi->rm_size = pi_size;
|
||||
pi->rm_type = pi_type;
|
||||
pi->rm_pktinfooffset = RNDIS_PKTINFO_OFFSET;
|
||||
|
||||
/* Data immediately follow per-packet-info. */
|
||||
pkt->rm_dataoffset += pi_size;
|
||||
|
||||
/* Update RNDIS packet msg length */
|
||||
pkt->rm_len += pi_size;
|
||||
|
||||
return (pi->rm_data);
|
||||
}
|
||||
|
||||
/*
|
||||
* NOTE:
|
||||
* If this function fails, then both txd and m_head0 will be freed.
|
||||
|
@ -104,42 +104,6 @@ hn_rndis_rid(struct hn_softc *sc)
|
||||
return ((rid & 0xffff) << 16);
|
||||
}
|
||||
|
||||
void *
|
||||
hn_rndis_pktinfo_append(struct rndis_packet_msg *pkt, size_t pktsize,
|
||||
size_t pi_dlen, uint32_t pi_type)
|
||||
{
|
||||
const size_t pi_size = HN_RNDIS_PKTINFO_SIZE(pi_dlen);
|
||||
struct rndis_pktinfo *pi;
|
||||
|
||||
KASSERT((pi_size & RNDIS_PACKET_MSG_OFFSET_ALIGNMASK) == 0,
|
||||
("unaligned pktinfo size %zu, pktinfo dlen %zu", pi_size, pi_dlen));
|
||||
|
||||
/*
|
||||
* Per-packet-info does not move; it only grows.
|
||||
*
|
||||
* NOTE:
|
||||
* rm_pktinfooffset in this phase counts from the beginning
|
||||
* of rndis_packet_msg.
|
||||
*/
|
||||
KASSERT(pkt->rm_pktinfooffset + pkt->rm_pktinfolen + pi_size <= pktsize,
|
||||
("%u pktinfo overflows RNDIS packet msg", pi_type));
|
||||
pi = (struct rndis_pktinfo *)((uint8_t *)pkt + pkt->rm_pktinfooffset +
|
||||
pkt->rm_pktinfolen);
|
||||
pkt->rm_pktinfolen += pi_size;
|
||||
|
||||
pi->rm_size = pi_size;
|
||||
pi->rm_type = pi_type;
|
||||
pi->rm_pktinfooffset = RNDIS_PKTINFO_OFFSET;
|
||||
|
||||
/* Data immediately follow per-packet-info. */
|
||||
pkt->rm_dataoffset += pi_size;
|
||||
|
||||
/* Update RNDIS packet msg length */
|
||||
pkt->rm_len += pi_size;
|
||||
|
||||
return (pi->rm_data);
|
||||
}
|
||||
|
||||
void
|
||||
hn_rndis_rx_ctrl(struct hn_softc *sc, const void *data, int dlen)
|
||||
{
|
||||
|
@ -231,13 +231,9 @@ struct hn_softc {
|
||||
#define HN_LINK_FLAG_LINKUP 0x0001
|
||||
#define HN_LINK_FLAG_NETCHG 0x0002
|
||||
|
||||
struct rndis_packet_msg;
|
||||
|
||||
int hn_rndis_attach(struct hn_softc *sc, int mtu);
|
||||
void hn_rndis_detach(struct hn_softc *sc);
|
||||
int hn_rndis_conf_rss(struct hn_softc *sc, uint16_t flags);
|
||||
void *hn_rndis_pktinfo_append(struct rndis_packet_msg *,
|
||||
size_t pktsize, size_t pi_dlen, uint32_t pi_type);
|
||||
int hn_rndis_query_rsscaps(struct hn_softc *sc, int *rxr_cnt);
|
||||
int hn_rndis_get_eaddr(struct hn_softc *sc, uint8_t *eaddr);
|
||||
int hn_rndis_get_linkstatus(struct hn_softc *sc,
|
||||
|
Loading…
Reference in New Issue
Block a user