Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/hyperv/netvsc/hv_net_vsc.c
Show First 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | |||||
static int hv_nv_init_send_buffer_with_net_vsp(struct hn_softc *sc); | static int hv_nv_init_send_buffer_with_net_vsp(struct hn_softc *sc); | ||||
static int hv_nv_init_rx_buffer_with_net_vsp(struct hn_softc *); | static int hv_nv_init_rx_buffer_with_net_vsp(struct hn_softc *); | ||||
static int hv_nv_destroy_send_buffer(netvsc_dev *net_dev); | static int hv_nv_destroy_send_buffer(netvsc_dev *net_dev); | ||||
static int hv_nv_destroy_rx_buffer(netvsc_dev *net_dev); | static int hv_nv_destroy_rx_buffer(netvsc_dev *net_dev); | ||||
static int hv_nv_connect_to_vsp(struct hn_softc *sc); | static int hv_nv_connect_to_vsp(struct hn_softc *sc); | ||||
static void hv_nv_on_send_completion(netvsc_dev *net_dev, | static void hv_nv_on_send_completion(netvsc_dev *net_dev, | ||||
struct vmbus_channel *, const struct vmbus_chanpkt_hdr *pkt); | struct vmbus_channel *, const struct vmbus_chanpkt_hdr *pkt); | ||||
static void hv_nv_on_receive_completion(struct vmbus_channel *chan, | static void hv_nv_on_receive_completion(struct vmbus_channel *chan, | ||||
uint64_t tid, uint32_t status); | uint64_t tid); | ||||
static void hv_nv_on_receive(netvsc_dev *net_dev, | static void hv_nv_on_receive(netvsc_dev *net_dev, | ||||
struct hn_rx_ring *rxr, struct vmbus_channel *chan, | struct hn_rx_ring *rxr, struct vmbus_channel *chan, | ||||
const struct vmbus_chanpkt_hdr *pkt); | const struct vmbus_chanpkt_hdr *pkt); | ||||
static void hn_nvs_sent_none(struct hn_send_ctx *sndc, | static void hn_nvs_sent_none(struct hn_send_ctx *sndc, | ||||
struct netvsc_dev_ *net_dev, struct vmbus_channel *chan, | struct netvsc_dev_ *net_dev, struct vmbus_channel *chan, | ||||
const void *, int); | const void *, int); | ||||
static struct hn_send_ctx hn_send_ctx_none = | static struct hn_send_ctx hn_send_ctx_none = | ||||
▲ Show 20 Lines • Show All 761 Lines • ▼ Show 20 Lines | |||||
* with virtual addresses. | * with virtual addresses. | ||||
*/ | */ | ||||
static void | static void | ||||
hv_nv_on_receive(netvsc_dev *net_dev, struct hn_rx_ring *rxr, | hv_nv_on_receive(netvsc_dev *net_dev, struct hn_rx_ring *rxr, | ||||
struct vmbus_channel *chan, const struct vmbus_chanpkt_hdr *pkthdr) | struct vmbus_channel *chan, const struct vmbus_chanpkt_hdr *pkthdr) | ||||
{ | { | ||||
const struct vmbus_chanpkt_rxbuf *pkt; | const struct vmbus_chanpkt_rxbuf *pkt; | ||||
const struct hn_nvs_hdr *nvs_hdr; | const struct hn_nvs_hdr *nvs_hdr; | ||||
netvsc_packet vsc_pkt; | |||||
netvsc_packet *net_vsc_pkt = &vsc_pkt; | |||||
int count = 0; | int count = 0; | ||||
int i = 0; | int i = 0; | ||||
int status = HN_NVS_STATUS_OK; | |||||
/* Make sure that this is a RNDIS message. */ | /* Make sure that this is a RNDIS message. */ | ||||
nvs_hdr = VMBUS_CHANPKT_CONST_DATA(pkthdr); | nvs_hdr = VMBUS_CHANPKT_CONST_DATA(pkthdr); | ||||
if (__predict_false(nvs_hdr->nvs_type != HN_NVS_TYPE_RNDIS)) { | if (__predict_false(nvs_hdr->nvs_type != HN_NVS_TYPE_RNDIS)) { | ||||
if_printf(rxr->hn_ifp, "nvs type %u, not RNDIS\n", | if_printf(rxr->hn_ifp, "nvs type %u, not RNDIS\n", | ||||
nvs_hdr->nvs_type); | nvs_hdr->nvs_type); | ||||
return; | return; | ||||
} | } | ||||
pkt = (const struct vmbus_chanpkt_rxbuf *)pkthdr; | pkt = (const struct vmbus_chanpkt_rxbuf *)pkthdr; | ||||
if (pkt->cp_rxbuf_id != NETVSC_RECEIVE_BUFFER_ID) { | if (pkt->cp_rxbuf_id != NETVSC_RECEIVE_BUFFER_ID) { | ||||
if_printf(rxr->hn_ifp, "rxbuf_id %d is invalid!\n", | if_printf(rxr->hn_ifp, "rxbuf_id %d is invalid!\n", | ||||
pkt->cp_rxbuf_id); | pkt->cp_rxbuf_id); | ||||
return; | return; | ||||
} | } | ||||
count = pkt->cp_rxbuf_cnt; | count = pkt->cp_rxbuf_cnt; | ||||
/* Each range represents 1 RNDIS pkt that contains 1 Ethernet frame */ | /* Each range represents 1 RNDIS pkt that contains 1 Ethernet frame */ | ||||
for (i = 0; i < count; i++) { | for (i = 0; i < count; i++) { | ||||
net_vsc_pkt->status = HN_NVS_STATUS_OK; | hv_rf_on_receive(net_dev, rxr, | ||||
net_vsc_pkt->data = ((uint8_t *)net_dev->rx_buf + | (const uint8_t *)net_dev->rx_buf + pkt->cp_rxbuf[i].rb_ofs, | ||||
pkt->cp_rxbuf[i].rb_ofs); | pkt->cp_rxbuf[i].rb_len); | ||||
net_vsc_pkt->tot_data_buf_len = pkt->cp_rxbuf[i].rb_len; | |||||
hv_rf_on_receive(net_dev, rxr, net_vsc_pkt); | |||||
/* XXX pretty broken; whack it */ | |||||
if (net_vsc_pkt->status != HN_NVS_STATUS_OK) | |||||
status = HN_NVS_STATUS_FAILED; | |||||
} | } | ||||
/* | /* | ||||
* Moved completion call back here so that all received | * Moved completion call back here so that all received | ||||
* messages (not just data messages) will trigger a response | * messages (not just data messages) will trigger a response | ||||
* message back to the host. | * message back to the host. | ||||
*/ | */ | ||||
hv_nv_on_receive_completion(chan, pkt->cp_hdr.cph_xactid, status); | hv_nv_on_receive_completion(chan, pkt->cp_hdr.cph_xactid); | ||||
} | } | ||||
/* | /* | ||||
* Net VSC on receive completion | * Net VSC on receive completion | ||||
* | * | ||||
* Send a receive completion packet to RNDIS device (ie NetVsp) | * Send a receive completion packet to RNDIS device (ie NetVsp) | ||||
*/ | */ | ||||
static void | static void | ||||
hv_nv_on_receive_completion(struct vmbus_channel *chan, uint64_t tid, | hv_nv_on_receive_completion(struct vmbus_channel *chan, uint64_t tid) | ||||
uint32_t status) | |||||
{ | { | ||||
struct hn_nvs_rndis_ack ack; | struct hn_nvs_rndis_ack ack; | ||||
int retries = 0; | int retries = 0; | ||||
int ret = 0; | int ret = 0; | ||||
ack.nvs_type = HN_NVS_TYPE_RNDIS_ACK; | ack.nvs_type = HN_NVS_TYPE_RNDIS_ACK; | ||||
ack.nvs_status = status; | ack.nvs_status = HN_NVS_STATUS_OK; | ||||
retry_send_cmplt: | retry_send_cmplt: | ||||
/* Send the completion */ | /* Send the completion */ | ||||
ret = vmbus_chan_send(chan, VMBUS_CHANPKT_TYPE_COMP, | ret = vmbus_chan_send(chan, VMBUS_CHANPKT_TYPE_COMP, | ||||
VMBUS_CHANPKT_FLAG_NONE, &ack, sizeof(ack), tid); | VMBUS_CHANPKT_FLAG_NONE, &ack, sizeof(ack), tid); | ||||
if (ret == 0) { | if (ret == 0) { | ||||
/* success */ | /* success */ | ||||
/* no-op */ | /* no-op */ | ||||
▲ Show 20 Lines • Show All 96 Lines • Show Last 20 Lines |