Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F148854506
D7469.id19219.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
6 KB
Referenced Files
None
Subscribers
None
D7469.id19219.diff
View Options
Index: head/sys/dev/hyperv/netvsc/hv_net_vsc.h
===================================================================
--- head/sys/dev/hyperv/netvsc/hv_net_vsc.h
+++ head/sys/dev/hyperv/netvsc/hv_net_vsc.h
@@ -1060,7 +1060,6 @@
uint32_t rx_buf_size;
uint32_t rx_buf_gpadl_handle;
uint32_t rx_section_count;
- nvsp_1_rx_buf_section *rx_sections;
/* Used for NetVSP initialization protocol */
struct sema channel_init_sema;
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
@@ -152,10 +152,14 @@
static int
hv_nv_init_rx_buffer_with_net_vsp(struct hn_softc *sc)
{
+ struct vmbus_xact *xact;
+ struct hn_nvs_rxbuf_conn *conn;
+ const struct hn_nvs_rxbuf_connresp *resp;
+ size_t resp_len;
struct hn_send_ctx sndc;
netvsc_dev *net_dev;
- nvsp_msg *init_pkt;
- int ret = 0;
+ uint32_t status;
+ int error;
net_dev = hv_nv_get_outbound_net_device(sc);
if (!net_dev) {
@@ -167,7 +171,7 @@
BUS_DMA_WAITOK | BUS_DMA_ZERO);
if (net_dev->rx_buf == NULL) {
device_printf(sc->hn_dev, "allocate rxbuf failed\n");
- return ENOMEM;
+ return (ENOMEM);
}
/*
@@ -177,74 +181,76 @@
* Only primary channel has RXBUF connected to it. Sub-channels
* just share this RXBUF.
*/
- ret = vmbus_chan_gpadl_connect(sc->hn_prichan,
+ error = vmbus_chan_gpadl_connect(sc->hn_prichan,
net_dev->rxbuf_dma.hv_paddr, net_dev->rx_buf_size,
&net_dev->rx_buf_gpadl_handle);
- if (ret != 0) {
- device_printf(sc->hn_dev, "rxbuf gpadl connect failed: %d\n",
- ret);
+ if (error) {
+ if_printf(sc->hn_ifp, "rxbuf gpadl connect failed: %d\n",
+ error);
goto cleanup;
}
-
- /* sema_wait(&ext->channel_init_sema); KYS CHECK */
- /* Notify the NetVsp of the gpadl handle */
- init_pkt = &net_dev->channel_init_packet;
+ /*
+ * Connect RXBUF to NVS.
+ */
- memset(init_pkt, 0, sizeof(nvsp_msg));
+ xact = vmbus_xact_get(sc->hn_xact, sizeof(*conn));
+ if (xact == NULL) {
+ if_printf(sc->hn_ifp, "no xact for nvs rxbuf conn\n");
+ error = ENXIO;
+ goto cleanup;
+ }
- init_pkt->hdr.msg_type = nvsp_msg_1_type_send_rx_buf;
- init_pkt->msgs.vers_1_msgs.send_rx_buf.gpadl_handle =
- net_dev->rx_buf_gpadl_handle;
- init_pkt->msgs.vers_1_msgs.send_rx_buf.id =
- NETVSC_RECEIVE_BUFFER_ID;
+ conn = vmbus_xact_req_data(xact);
+ conn->nvs_type = HN_NVS_TYPE_RXBUF_CONN;
+ conn->nvs_gpadl = net_dev->rx_buf_gpadl_handle;
+ conn->nvs_sig = HN_NVS_RXBUF_SIG;
- /* Send the gpadl notification request */
+ hn_send_ctx_init_simple(&sndc, hn_nvs_sent_xact, xact);
+ vmbus_xact_activate(xact);
- hn_send_ctx_init_simple(&sndc, hn_nvs_sent_wakeup, NULL);
- ret = vmbus_chan_send(sc->hn_prichan,
+ error = vmbus_chan_send(sc->hn_prichan,
VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC,
- init_pkt, sizeof(nvsp_msg), (uint64_t)(uintptr_t)&sndc);
- if (ret != 0) {
+ conn, sizeof(*conn), (uint64_t)(uintptr_t)&sndc);
+ if (error != 0) {
+ if_printf(sc->hn_ifp, "send nvs rxbuf conn failed: %d\n",
+ error);
+ vmbus_xact_deactivate(xact);
+ vmbus_xact_put(xact);
goto cleanup;
}
- sema_wait(&net_dev->channel_init_sema);
-
- /* Check the response */
- if (init_pkt->msgs.vers_1_msgs.send_rx_buf_complete.status
- != nvsp_status_success) {
- ret = EINVAL;
+ resp = vmbus_xact_wait(xact, &resp_len);
+ if (resp_len < sizeof(*resp)) {
+ if_printf(sc->hn_ifp, "invalid rxbuf conn resp length %zu\n",
+ resp_len);
+ vmbus_xact_put(xact);
+ error = EINVAL;
+ goto cleanup;
+ }
+ if (resp->nvs_type != HN_NVS_TYPE_RXBUF_CONNRESP) {
+ if_printf(sc->hn_ifp, "not rxbuf conn resp, type %u\n",
+ resp->nvs_type);
+ vmbus_xact_put(xact);
+ error = EINVAL;
goto cleanup;
}
- net_dev->rx_section_count =
- init_pkt->msgs.vers_1_msgs.send_rx_buf_complete.num_sections;
-
- net_dev->rx_sections = malloc(net_dev->rx_section_count *
- sizeof(nvsp_1_rx_buf_section), M_NETVSC, M_WAITOK);
- memcpy(net_dev->rx_sections,
- init_pkt->msgs.vers_1_msgs.send_rx_buf_complete.sections,
- net_dev->rx_section_count * sizeof(nvsp_1_rx_buf_section));
-
+ status = resp->nvs_status;
+ vmbus_xact_put(xact);
- /*
- * For first release, there should only be 1 section that represents
- * the entire receive buffer
- */
- if (net_dev->rx_section_count != 1
- || net_dev->rx_sections->offset != 0) {
- ret = EINVAL;
+ if (status != HN_NVS_STATUS_OK) {
+ if_printf(sc->hn_ifp, "rxbuf conn failed: %x\n", status);
+ error = EINVAL;
goto cleanup;
}
+ net_dev->rx_section_count = 1;
- goto exit;
+ return (0);
cleanup:
hv_nv_destroy_rx_buffer(net_dev);
-
-exit:
- return (ret);
+ return (error);
}
/*
@@ -371,6 +377,7 @@
if (ret != 0) {
return (ret);
}
+ net_dev->rx_section_count = 0;
}
/* Tear down the gpadl on the vsp end */
@@ -393,12 +400,6 @@
net_dev->rx_buf = NULL;
}
- if (net_dev->rx_sections) {
- free(net_dev->rx_sections, M_NETVSC);
- net_dev->rx_sections = NULL;
- net_dev->rx_section_count = 0;
- }
-
return (ret);
}
Index: head/sys/dev/hyperv/netvsc/if_hnreg.h
===================================================================
--- head/sys/dev/hyperv/netvsc/if_hnreg.h
+++ head/sys/dev/hyperv/netvsc/if_hnreg.h
@@ -32,11 +32,15 @@
#include <sys/param.h>
#include <sys/systm.h>
+#define HN_NVS_RXBUF_SIG 0xcafe
+
#define HN_NVS_STATUS_OK 1
#define HN_NVS_TYPE_INIT 1
#define HN_NVS_TYPE_INIT_RESP 2
#define HN_NVS_TYPE_NDIS_INIT 100
+#define HN_NVS_TYPE_RXBUF_CONN 101
+#define HN_NVS_TYPE_RXBUF_CONNRESP 102
#define HN_NVS_TYPE_NDIS_CONF 125
/*
@@ -83,4 +87,26 @@
} __packed;
CTASSERT(sizeof(struct hn_nvs_ndis_init) >= HN_NVS_REQSIZE_MIN);
+struct hn_nvs_rxbuf_conn {
+ uint32_t nvs_type; /* HN_NVS_TYPE_RXBUF_CONN */
+ uint32_t nvs_gpadl; /* RXBUF vmbus GPADL */
+ uint16_t nvs_sig; /* HN_NVS_RXBUF_SIG */
+ uint8_t nvs_rsvd[22];
+} __packed;
+CTASSERT(sizeof(struct hn_nvs_rxbuf_conn) >= HN_NVS_REQSIZE_MIN);
+
+struct hn_nvs_rxbuf_sect {
+ uint32_t nvs_start;
+ uint32_t nvs_slotsz;
+ uint32_t nvs_slotcnt;
+ uint32_t nvs_end;
+} __packed;
+
+struct hn_nvs_rxbuf_connresp {
+ uint32_t nvs_type; /* HN_NVS_TYPE_RXBUF_CONNRESP */
+ uint32_t nvs_status; /* HN_NVS_STATUS_ */
+ uint32_t nvs_nsect; /* # of elem in nvs_sect */
+ struct hn_nvs_rxbuf_sect nvs_sect[];
+} __packed;
+
#endif /* !_IF_HNREG_H_ */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 21, 1:40 PM (3 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30040794
Default Alt Text
D7469.id19219.diff (6 KB)
Attached To
Mode
D7469: hyperv/hn: Switch to vmbus xact APIs for NVS RXBUF connection.
Attached
Detach File
Event Timeline
Log In to Comment