hyperv/hn: Reorganize sub-channel allocation.
MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7829
This commit is contained in:
parent
b5f59ae0e2
commit
2cd02514a1
@ -102,7 +102,7 @@ hn_chim_alloc(struct hn_softc *sc)
|
|||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
const void *
|
static const void *
|
||||||
hn_nvs_xact_execute(struct hn_softc *sc, struct vmbus_xact *xact,
|
hn_nvs_xact_execute(struct hn_softc *sc, struct vmbus_xact *xact,
|
||||||
void *req, int reqlen, size_t *resplen0, uint32_t type)
|
void *req, int reqlen, size_t *resplen0, uint32_t type)
|
||||||
{
|
{
|
||||||
@ -653,3 +653,54 @@ hv_nv_on_send(struct vmbus_channel *chan, uint32_t rndis_mtype,
|
|||||||
|
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
hn_nvs_alloc_subchans(struct hn_softc *sc, int *nsubch0)
|
||||||
|
{
|
||||||
|
struct vmbus_xact *xact;
|
||||||
|
struct hn_nvs_subch_req *req;
|
||||||
|
const struct hn_nvs_subch_resp *resp;
|
||||||
|
int error, nsubch_req;
|
||||||
|
uint32_t nsubch;
|
||||||
|
size_t resp_len;
|
||||||
|
|
||||||
|
nsubch_req = *nsubch0;
|
||||||
|
KASSERT(nsubch_req > 0, ("invalid # of sub-channels %d", nsubch_req));
|
||||||
|
|
||||||
|
xact = vmbus_xact_get(sc->hn_xact, sizeof(*req));
|
||||||
|
if (xact == NULL) {
|
||||||
|
if_printf(sc->hn_ifp, "no xact for nvs subch alloc\n");
|
||||||
|
return (ENXIO);
|
||||||
|
}
|
||||||
|
req = vmbus_xact_req_data(xact);
|
||||||
|
req->nvs_type = HN_NVS_TYPE_SUBCH_REQ;
|
||||||
|
req->nvs_op = HN_NVS_SUBCH_OP_ALLOC;
|
||||||
|
req->nvs_nsubch = nsubch_req;
|
||||||
|
|
||||||
|
resp_len = sizeof(*resp);
|
||||||
|
resp = hn_nvs_xact_execute(sc, xact, req, sizeof(*req), &resp_len,
|
||||||
|
HN_NVS_TYPE_SUBCH_RESP);
|
||||||
|
if (resp == NULL) {
|
||||||
|
if_printf(sc->hn_ifp, "exec nvs subch alloc failed\n");
|
||||||
|
error = EIO;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
if (resp->nvs_status != HN_NVS_STATUS_OK) {
|
||||||
|
if_printf(sc->hn_ifp, "nvs subch alloc failed: %x\n",
|
||||||
|
resp->nvs_status);
|
||||||
|
error = EIO;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsubch = resp->nvs_nsubch;
|
||||||
|
if (nsubch > nsubch_req) {
|
||||||
|
if_printf(sc->hn_ifp, "%u subchans are allocated, "
|
||||||
|
"requested %d\n", nsubch, nsubch_req);
|
||||||
|
nsubch = nsubch_req;
|
||||||
|
}
|
||||||
|
*nsubch0 = nsubch;
|
||||||
|
error = 0;
|
||||||
|
done:
|
||||||
|
vmbus_xact_put(xact);
|
||||||
|
return (error);
|
||||||
|
}
|
||||||
|
@ -1017,13 +1017,7 @@ hv_rf_on_device_add(struct hn_softc *sc, void *additl_info,
|
|||||||
int ret;
|
int ret;
|
||||||
netvsc_device_info *dev_info = (netvsc_device_info *)additl_info;
|
netvsc_device_info *dev_info = (netvsc_device_info *)additl_info;
|
||||||
device_t dev = sc->hn_dev;
|
device_t dev = sc->hn_dev;
|
||||||
struct hn_nvs_subch_req *req;
|
int nchan = *nchan0, rxr_cnt, nsubch;
|
||||||
const struct hn_nvs_subch_resp *resp;
|
|
||||||
size_t resp_len;
|
|
||||||
struct vmbus_xact *xact = NULL;
|
|
||||||
uint32_t status, nsubch;
|
|
||||||
int nchan = *nchan0;
|
|
||||||
int rxr_cnt;
|
|
||||||
|
|
||||||
ret = hn_nvs_attach(sc, mtu);
|
ret = hn_nvs_attach(sc, mtu);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
@ -1072,65 +1066,40 @@ hv_rf_on_device_add(struct hn_softc *sc, void *additl_info,
|
|||||||
*nchan0 = 1;
|
*nchan0 = 1;
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
if (nchan > rxr_cnt)
|
|
||||||
nchan = rxr_cnt;
|
|
||||||
if_printf(sc->hn_ifp, "RX rings offered %u, requested %d\n",
|
if_printf(sc->hn_ifp, "RX rings offered %u, requested %d\n",
|
||||||
rxr_cnt, nchan);
|
rxr_cnt, nchan);
|
||||||
|
|
||||||
|
if (nchan > rxr_cnt)
|
||||||
|
nchan = rxr_cnt;
|
||||||
if (nchan == 1) {
|
if (nchan == 1) {
|
||||||
device_printf(dev, "only 1 channel is supported, no vRSS\n");
|
device_printf(dev, "only 1 channel is supported, no vRSS\n");
|
||||||
goto out;
|
*nchan0 = 1;
|
||||||
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ask NVS to allocate sub-channels.
|
* Allocate sub-channels from NVS.
|
||||||
*/
|
*/
|
||||||
xact = vmbus_xact_get(sc->hn_xact, sizeof(*req));
|
nsubch = nchan - 1;
|
||||||
if (xact == NULL) {
|
ret = hn_nvs_alloc_subchans(sc, &nsubch);
|
||||||
if_printf(sc->hn_ifp, "no xact for nvs subch req\n");
|
if (ret || nsubch == 0) {
|
||||||
ret = ENXIO;
|
/* Failed to allocate sub-channels. */
|
||||||
goto out;
|
*nchan0 = 1;
|
||||||
}
|
return (0);
|
||||||
req = vmbus_xact_req_data(xact);
|
|
||||||
req->nvs_type = HN_NVS_TYPE_SUBCH_REQ;
|
|
||||||
req->nvs_op = HN_NVS_SUBCH_OP_ALLOC;
|
|
||||||
req->nvs_nsubch = nchan - 1;
|
|
||||||
|
|
||||||
resp_len = sizeof(*resp);
|
|
||||||
resp = hn_nvs_xact_execute(sc, xact, req, sizeof(*req), &resp_len,
|
|
||||||
HN_NVS_TYPE_SUBCH_RESP);
|
|
||||||
if (resp == NULL) {
|
|
||||||
if_printf(sc->hn_ifp, "exec subch failed\n");
|
|
||||||
ret = EIO;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
status = resp->nvs_status;
|
|
||||||
nsubch = resp->nvs_nsubch;
|
|
||||||
vmbus_xact_put(xact);
|
|
||||||
xact = NULL;
|
|
||||||
|
|
||||||
if (status != HN_NVS_STATUS_OK) {
|
|
||||||
if_printf(sc->hn_ifp, "subch req failed: %x\n", status);
|
|
||||||
ret = EIO;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
if (nsubch > nchan - 1) {
|
|
||||||
if_printf(sc->hn_ifp, "%u subchans are allocated, requested %u\n",
|
|
||||||
nsubch, nchan - 1);
|
|
||||||
nsubch = nchan - 1;
|
|
||||||
}
|
}
|
||||||
nchan = nsubch + 1;
|
nchan = nsubch + 1;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Configure RSS key and indirect table after all sub-channels
|
||||||
|
* are allocated.
|
||||||
|
*/
|
||||||
ret = hn_rndis_conf_rss(sc, nchan);
|
ret = hn_rndis_conf_rss(sc, nchan);
|
||||||
if (ret != 0)
|
if (ret != 0) {
|
||||||
*nchan0 = 1;
|
/* Failed to configure RSS key or indirect table. */
|
||||||
else
|
nchan = 1;
|
||||||
*nchan0 = nchan;
|
}
|
||||||
out:
|
*nchan0 = nchan;
|
||||||
if (xact != NULL)
|
return (0);
|
||||||
vmbus_xact_put(xact);
|
|
||||||
return (ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -114,9 +114,6 @@ hn_nvs_send_sglist(struct vmbus_channel *chan, struct vmbus_gpa sg[], int sglen,
|
|||||||
struct vmbus_xact;
|
struct vmbus_xact;
|
||||||
struct rndis_packet_msg;
|
struct rndis_packet_msg;
|
||||||
|
|
||||||
const void *hn_nvs_xact_execute(struct hn_softc *sc,
|
|
||||||
struct vmbus_xact *xact, void *req, int reqlen,
|
|
||||||
size_t *resp_len, uint32_t type);
|
|
||||||
void hn_nvs_sent_xact(struct hn_send_ctx *sndc, struct hn_softc *sc,
|
void hn_nvs_sent_xact(struct hn_send_ctx *sndc, struct hn_softc *sc,
|
||||||
struct vmbus_channel *chan, const void *data, int dlen);
|
struct vmbus_channel *chan, const void *data, int dlen);
|
||||||
uint32_t hn_chim_alloc(struct hn_softc *sc);
|
uint32_t hn_chim_alloc(struct hn_softc *sc);
|
||||||
@ -125,6 +122,7 @@ void hn_chim_free(struct hn_softc *sc, uint32_t chim_idx);
|
|||||||
void *hn_rndis_pktinfo_append(struct rndis_packet_msg *,
|
void *hn_rndis_pktinfo_append(struct rndis_packet_msg *,
|
||||||
size_t pktsize, size_t pi_dlen, uint32_t pi_type);
|
size_t pktsize, size_t pi_dlen, uint32_t pi_type);
|
||||||
|
|
||||||
|
int hn_nvs_alloc_subchans(struct hn_softc *sc, int *nsubch);
|
||||||
int hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int dlen,
|
int hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int dlen,
|
||||||
const struct hn_recvinfo *info);
|
const struct hn_recvinfo *info);
|
||||||
void hn_chan_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr);
|
void hn_chan_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user