hyperv/hn: Shuffle chimney sending buffer alloc/free around.
This paves way for more chimney sending buffer reorganization. MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8343
This commit is contained in:
parent
d031f86f85
commit
1759ebe452
@ -73,33 +73,6 @@ static const uint32_t hn_nvs_version[] = {
|
||||
HN_NVS_VERSION_1
|
||||
};
|
||||
|
||||
uint32_t
|
||||
hn_chim_alloc(struct hn_softc *sc)
|
||||
{
|
||||
int i, bmap_cnt = sc->hn_chim_bmap_cnt;
|
||||
u_long *bmap = sc->hn_chim_bmap;
|
||||
uint32_t ret = HN_NVS_CHIM_IDX_INVALID;
|
||||
|
||||
for (i = 0; i < bmap_cnt; ++i) {
|
||||
int idx;
|
||||
|
||||
idx = ffsl(~bmap[i]);
|
||||
if (idx == 0)
|
||||
continue;
|
||||
|
||||
--idx; /* ffsl is 1-based */
|
||||
KASSERT(i * LONG_BIT + idx < sc->hn_chim_cnt,
|
||||
("invalid i %d and idx %d", i, idx));
|
||||
|
||||
if (atomic_testandset_long(&bmap[i], idx))
|
||||
continue;
|
||||
|
||||
ret = i * LONG_BIT + idx;
|
||||
break;
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static const void *
|
||||
hn_nvs_xact_execute(struct hn_softc *sc, struct vmbus_xact *xact,
|
||||
void *req, int reqlen, size_t *resplen0, uint32_t type)
|
||||
@ -648,25 +621,6 @@ hn_nvs_sent_none(struct hn_send_ctx *sndc __unused,
|
||||
/* EMPTY */
|
||||
}
|
||||
|
||||
void
|
||||
hn_chim_free(struct hn_softc *sc, uint32_t chim_idx)
|
||||
{
|
||||
u_long mask;
|
||||
uint32_t idx;
|
||||
|
||||
idx = chim_idx / LONG_BIT;
|
||||
KASSERT(idx < sc->hn_chim_bmap_cnt,
|
||||
("invalid chimney index 0x%x", chim_idx));
|
||||
|
||||
mask = 1UL << (chim_idx % LONG_BIT);
|
||||
KASSERT(sc->hn_chim_bmap[idx] & mask,
|
||||
("index bitmap 0x%lx, chimney index %u, "
|
||||
"bitmap idx %d, bitmask 0x%lx",
|
||||
sc->hn_chim_bmap[idx], chim_idx, idx, mask));
|
||||
|
||||
atomic_clear_long(&sc->hn_chim_bmap[idx], mask);
|
||||
}
|
||||
|
||||
int
|
||||
hn_nvs_alloc_subchans(struct hn_softc *sc, int *nsubch0)
|
||||
{
|
||||
|
@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/sockio.h>
|
||||
#include <sys/limits.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/module.h>
|
||||
@ -457,6 +458,52 @@ hn_sendpkt_rndis_chim(struct hn_tx_ring *txr, struct hn_txdesc *txd)
|
||||
&rndis, sizeof(rndis), &txd->send_ctx));
|
||||
}
|
||||
|
||||
static __inline uint32_t
|
||||
hn_chim_alloc(struct hn_softc *sc)
|
||||
{
|
||||
int i, bmap_cnt = sc->hn_chim_bmap_cnt;
|
||||
u_long *bmap = sc->hn_chim_bmap;
|
||||
uint32_t ret = HN_NVS_CHIM_IDX_INVALID;
|
||||
|
||||
for (i = 0; i < bmap_cnt; ++i) {
|
||||
int idx;
|
||||
|
||||
idx = ffsl(~bmap[i]);
|
||||
if (idx == 0)
|
||||
continue;
|
||||
|
||||
--idx; /* ffsl is 1-based */
|
||||
KASSERT(i * LONG_BIT + idx < sc->hn_chim_cnt,
|
||||
("invalid i %d and idx %d", i, idx));
|
||||
|
||||
if (atomic_testandset_long(&bmap[i], idx))
|
||||
continue;
|
||||
|
||||
ret = i * LONG_BIT + idx;
|
||||
break;
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static __inline void
|
||||
hn_chim_free(struct hn_softc *sc, uint32_t chim_idx)
|
||||
{
|
||||
u_long mask;
|
||||
uint32_t idx;
|
||||
|
||||
idx = chim_idx / LONG_BIT;
|
||||
KASSERT(idx < sc->hn_chim_bmap_cnt,
|
||||
("invalid chimney index 0x%x", chim_idx));
|
||||
|
||||
mask = 1UL << (chim_idx % LONG_BIT);
|
||||
KASSERT(sc->hn_chim_bmap[idx] & mask,
|
||||
("index bitmap 0x%lx, chimney index %u, "
|
||||
"bitmap idx %d, bitmask 0x%lx",
|
||||
sc->hn_chim_bmap[idx], chim_idx, idx, mask));
|
||||
|
||||
atomic_clear_long(&sc->hn_chim_bmap[idx], mask);
|
||||
}
|
||||
|
||||
static int
|
||||
hn_set_rxfilter(struct hn_softc *sc)
|
||||
{
|
||||
|
@ -94,9 +94,6 @@ hn_nvs_send_sglist(struct vmbus_channel *chan, struct vmbus_gpa sg[], int sglen,
|
||||
struct vmbus_xact;
|
||||
struct rndis_packet_msg;
|
||||
|
||||
uint32_t hn_chim_alloc(struct hn_softc *sc);
|
||||
void hn_chim_free(struct hn_softc *sc, uint32_t chim_idx);
|
||||
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user