Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F150377811
D7829.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D7829.diff
View Options
Index: head/sys/dev/hyperv/netvsc/hv_net_vsc.c
===================================================================
--- head/sys/dev/hyperv/netvsc/hv_net_vsc.c
+++ head/sys/dev/hyperv/netvsc/hv_net_vsc.c
@@ -102,7 +102,7 @@
return (ret);
}
-const void *
+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)
{
@@ -653,3 +653,54 @@
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);
+}
Index: head/sys/dev/hyperv/netvsc/hv_rndis_filter.c
===================================================================
--- head/sys/dev/hyperv/netvsc/hv_rndis_filter.c
+++ head/sys/dev/hyperv/netvsc/hv_rndis_filter.c
@@ -1017,13 +1017,7 @@
int ret;
netvsc_device_info *dev_info = (netvsc_device_info *)additl_info;
device_t dev = sc->hn_dev;
- struct hn_nvs_subch_req *req;
- 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;
+ int nchan = *nchan0, rxr_cnt, nsubch;
ret = hn_nvs_attach(sc, mtu);
if (ret != 0)
@@ -1072,65 +1066,40 @@
*nchan0 = 1;
return (0);
}
- if (nchan > rxr_cnt)
- nchan = rxr_cnt;
if_printf(sc->hn_ifp, "RX rings offered %u, requested %d\n",
rxr_cnt, nchan);
+ if (nchan > rxr_cnt)
+ nchan = rxr_cnt;
if (nchan == 1) {
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));
- if (xact == NULL) {
- if_printf(sc->hn_ifp, "no xact for nvs subch req\n");
- ret = ENXIO;
- goto out;
- }
- 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;
+ nsubch = nchan - 1;
+ ret = hn_nvs_alloc_subchans(sc, &nsubch);
+ if (ret || nsubch == 0) {
+ /* Failed to allocate sub-channels. */
+ *nchan0 = 1;
+ return (0);
}
nchan = nsubch + 1;
+ /*
+ * Configure RSS key and indirect table after all sub-channels
+ * are allocated.
+ */
ret = hn_rndis_conf_rss(sc, nchan);
- if (ret != 0)
- *nchan0 = 1;
- else
- *nchan0 = nchan;
-out:
- if (xact != NULL)
- vmbus_xact_put(xact);
- return (ret);
+ if (ret != 0) {
+ /* Failed to configure RSS key or indirect table. */
+ nchan = 1;
+ }
+ *nchan0 = nchan;
+ return (0);
}
/*
Index: head/sys/dev/hyperv/netvsc/if_hnvar.h
===================================================================
--- head/sys/dev/hyperv/netvsc/if_hnvar.h
+++ head/sys/dev/hyperv/netvsc/if_hnvar.h
@@ -114,9 +114,6 @@
struct vmbus_xact;
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,
struct vmbus_channel *chan, const void *data, int dlen);
uint32_t hn_chim_alloc(struct hn_softc *sc);
@@ -125,6 +122,7 @@
void *hn_rndis_pktinfo_append(struct rndis_packet_msg *,
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,
const struct hn_recvinfo *info);
void hn_chan_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Apr 1, 5:01 PM (6 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30683321
Default Alt Text
D7829.diff (5 KB)
Attached To
Mode
D7829: hyperv/hn: Reorganize sub-channel allocation.
Attached
Detach File
Event Timeline
Log In to Comment