Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/hyperv/netvsc/hv_rndis_filter.c
Show First 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | |||||
static int hv_rf_init_device(rndis_device *device); | static int hv_rf_init_device(rndis_device *device); | ||||
static int hv_rf_open_device(rndis_device *device); | static int hv_rf_open_device(rndis_device *device); | ||||
static int hv_rf_close_device(rndis_device *device); | static int hv_rf_close_device(rndis_device *device); | ||||
int | int | ||||
hv_rf_send_offload_request(struct hn_softc *sc, | hv_rf_send_offload_request(struct hn_softc *sc, | ||||
rndis_offload_params *offloads); | rndis_offload_params *offloads); | ||||
static void hn_rndis_sent_halt(struct hn_send_ctx *sndc, | static void hn_rndis_sent_halt(struct hn_send_ctx *sndc, | ||||
struct netvsc_dev_ *net_dev, struct vmbus_channel *chan, | struct hn_softc *sc, struct vmbus_channel *chan, | ||||
const void *data, int dlen); | const void *data, int dlen); | ||||
static void hn_rndis_sent_cb(struct hn_send_ctx *sndc, | static void hn_rndis_sent_cb(struct hn_send_ctx *sndc, | ||||
struct netvsc_dev_ *net_dev, struct vmbus_channel *chan, | struct hn_softc *sc, struct vmbus_channel *chan, | ||||
const void *data, int dlen); | const void *data, int dlen); | ||||
/* | /* | ||||
* Set the Per-Packet-Info with the specified type | * Set the Per-Packet-Info with the specified type | ||||
*/ | */ | ||||
void * | void * | ||||
hv_set_rppi_data(rndis_msg *rndis_mesg, uint32_t rppi_size, | hv_set_rppi_data(rndis_msg *rndis_mesg, uint32_t rppi_size, | ||||
int pkt_type) | int pkt_type) | ||||
▲ Show 20 Lines • Show All 134 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* | * | ||||
*/ | */ | ||||
static int | static int | ||||
hv_rf_send_request(rndis_device *device, rndis_request *request, | hv_rf_send_request(rndis_device *device, rndis_request *request, | ||||
uint32_t message_type) | uint32_t message_type) | ||||
{ | { | ||||
netvsc_dev *net_dev = device->net_dev; | struct hn_softc *sc = device->net_dev->sc; | ||||
uint32_t send_buf_section_idx, tot_data_buf_len; | uint32_t send_buf_section_idx, tot_data_buf_len; | ||||
struct vmbus_gpa gpa[2]; | struct vmbus_gpa gpa[2]; | ||||
int gpa_cnt, send_buf_section_size; | int gpa_cnt, send_buf_section_size; | ||||
hn_sent_callback_t cb; | hn_sent_callback_t cb; | ||||
/* Set up the packet to send it */ | /* Set up the packet to send it */ | ||||
tot_data_buf_len = request->request_msg.msg_len; | tot_data_buf_len = request->request_msg.msg_len; | ||||
Show All 12 Lines | if (gpa[0].gpa_ofs + gpa[0].gpa_len > PAGE_SIZE) { | ||||
gpa[1].gpa_len = request->request_msg.msg_len - gpa[0].gpa_len; | gpa[1].gpa_len = request->request_msg.msg_len - gpa[0].gpa_len; | ||||
} | } | ||||
if (message_type != REMOTE_NDIS_HALT_MSG) | if (message_type != REMOTE_NDIS_HALT_MSG) | ||||
cb = hn_rndis_sent_cb; | cb = hn_rndis_sent_cb; | ||||
else | else | ||||
cb = hn_rndis_sent_halt; | cb = hn_rndis_sent_halt; | ||||
if (tot_data_buf_len < net_dev->send_section_size) { | if (tot_data_buf_len < sc->hn_chim_szmax) { | ||||
send_buf_section_idx = hv_nv_get_next_send_section(net_dev); | send_buf_section_idx = hn_chim_alloc(sc); | ||||
if (send_buf_section_idx != HN_NVS_CHIM_IDX_INVALID) { | if (send_buf_section_idx != HN_NVS_CHIM_IDX_INVALID) { | ||||
char *dest = ((char *)net_dev->send_buf + | uint8_t *dest = sc->hn_chim + | ||||
send_buf_section_idx * net_dev->send_section_size); | (send_buf_section_idx * sc->hn_chim_szmax); | ||||
memcpy(dest, &request->request_msg, request->request_msg.msg_len); | memcpy(dest, &request->request_msg, request->request_msg.msg_len); | ||||
send_buf_section_size = tot_data_buf_len; | send_buf_section_size = tot_data_buf_len; | ||||
gpa_cnt = 0; | gpa_cnt = 0; | ||||
goto sendit; | goto sendit; | ||||
} | } | ||||
/* Failed to allocate chimney send buffer; move on */ | /* Failed to allocate chimney send buffer; move on */ | ||||
} | } | ||||
send_buf_section_idx = HN_NVS_CHIM_IDX_INVALID; | send_buf_section_idx = HN_NVS_CHIM_IDX_INVALID; | ||||
send_buf_section_size = 0; | send_buf_section_size = 0; | ||||
sendit: | sendit: | ||||
hn_send_ctx_init(&request->send_ctx, cb, request, | hn_send_ctx_init(&request->send_ctx, cb, request, | ||||
send_buf_section_idx, send_buf_section_size); | send_buf_section_idx, send_buf_section_size); | ||||
return hv_nv_on_send(device->net_dev->sc->hn_prichan, | return hv_nv_on_send(sc->hn_prichan, HN_NVS_RNDIS_MTYPE_CTRL, | ||||
HN_NVS_RNDIS_MTYPE_CTRL, &request->send_ctx, gpa, gpa_cnt); | &request->send_ctx, gpa, gpa_cnt); | ||||
} | } | ||||
/* | /* | ||||
* RNDIS filter receive response | * RNDIS filter receive response | ||||
*/ | */ | ||||
static void | static void | ||||
hv_rf_receive_response(rndis_device *device, const rndis_msg *response) | hv_rf_receive_response(rndis_device *device, const rndis_msg *response) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 941 Lines • ▼ Show 20 Lines | |||||
hv_rf_on_close(struct hn_softc *sc) | hv_rf_on_close(struct hn_softc *sc) | ||||
{ | { | ||||
netvsc_dev *net_dev = sc->net_dev; | netvsc_dev *net_dev = sc->net_dev; | ||||
return (hv_rf_close_device((rndis_device *)net_dev->extension)); | return (hv_rf_close_device((rndis_device *)net_dev->extension)); | ||||
} | } | ||||
static void | static void | ||||
hn_rndis_sent_cb(struct hn_send_ctx *sndc, struct netvsc_dev_ *net_dev, | hn_rndis_sent_cb(struct hn_send_ctx *sndc, struct hn_softc *sc, | ||||
struct vmbus_channel *chan __unused, const void *data __unused, | struct vmbus_channel *chan __unused, const void *data __unused, | ||||
int dlen __unused) | int dlen __unused) | ||||
{ | { | ||||
if (sndc->hn_chim_idx != HN_NVS_CHIM_IDX_INVALID) | if (sndc->hn_chim_idx != HN_NVS_CHIM_IDX_INVALID) | ||||
hn_chim_free(net_dev, sndc->hn_chim_idx); | hn_chim_free(sc, sndc->hn_chim_idx); | ||||
} | } | ||||
static void | static void | ||||
hn_rndis_sent_halt(struct hn_send_ctx *sndc, struct netvsc_dev_ *net_dev, | hn_rndis_sent_halt(struct hn_send_ctx *sndc, struct hn_softc *sc, | ||||
struct vmbus_channel *chan __unused, const void *data __unused, | struct vmbus_channel *chan __unused, const void *data __unused, | ||||
int dlen __unused) | int dlen __unused) | ||||
{ | { | ||||
rndis_request *request = sndc->hn_cbarg; | rndis_request *request = sndc->hn_cbarg; | ||||
if (sndc->hn_chim_idx != HN_NVS_CHIM_IDX_INVALID) | if (sndc->hn_chim_idx != HN_NVS_CHIM_IDX_INVALID) | ||||
hn_chim_free(net_dev, sndc->hn_chim_idx); | hn_chim_free(sc, sndc->hn_chim_idx); | ||||
/* | /* | ||||
* Notify hv_rf_halt_device() about halt completion. | * Notify hv_rf_halt_device() about halt completion. | ||||
* The halt code must wait for completion before freeing | * The halt code must wait for completion before freeing | ||||
* the transaction resources. | * the transaction resources. | ||||
*/ | */ | ||||
request->halt_complete_flag = 1; | request->halt_complete_flag = 1; | ||||
} | } | ||||
void | void | ||||
hv_rf_channel_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr) | hv_rf_channel_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr) | ||||
{ | { | ||||
netvsc_channel_rollup(rxr, txr); | netvsc_channel_rollup(rxr, txr); | ||||
} | } |