hyperv/hn: Pass channel to TX/RX done

This is preamble to associate the TX/RX rings to their channel.

While I'm here, revoke unused netvsc_recv_rollup.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D5453
This commit is contained in:
Sepherosa Ziehau 2016-02-26 09:35:45 +00:00
parent 654bf1ec96
commit 6619838c04
5 changed files with 28 additions and 50 deletions

View File

@ -63,7 +63,8 @@ static int hv_nv_connect_to_vsp(struct hv_device *device);
static void hv_nv_on_send_completion(netvsc_dev *net_dev, static void hv_nv_on_send_completion(netvsc_dev *net_dev,
struct hv_device *device, hv_vm_packet_descriptor *pkt); struct hv_device *device, hv_vm_packet_descriptor *pkt);
static void hv_nv_on_receive(netvsc_dev *net_dev, static void hv_nv_on_receive(netvsc_dev *net_dev,
struct hv_device *device, hv_vm_packet_descriptor *pkt); struct hv_device *device, struct hv_vmbus_channel *chan,
hv_vm_packet_descriptor *pkt);
/* /*
* *
@ -865,7 +866,7 @@ hv_nv_on_send(struct hv_device *device, netvsc_packet *pkt)
*/ */
static void static void
hv_nv_on_receive(netvsc_dev *net_dev, struct hv_device *device, hv_nv_on_receive(netvsc_dev *net_dev, struct hv_device *device,
hv_vm_packet_descriptor *pkt) struct hv_vmbus_channel *chan, hv_vm_packet_descriptor *pkt)
{ {
hv_vm_transfer_page_packet_header *vm_xfer_page_pkt; hv_vm_transfer_page_packet_header *vm_xfer_page_pkt;
nvsp_msg *nvsp_msg_pkt; nvsp_msg *nvsp_msg_pkt;
@ -915,7 +916,7 @@ hv_nv_on_receive(netvsc_dev *net_dev, struct hv_device *device,
net_vsc_pkt->tot_data_buf_len = net_vsc_pkt->tot_data_buf_len =
vm_xfer_page_pkt->ranges[i].byte_count; vm_xfer_page_pkt->ranges[i].byte_count;
hv_rf_on_receive(net_dev, device, net_vsc_pkt); hv_rf_on_receive(net_dev, device, chan, net_vsc_pkt);
if (net_vsc_pkt->status != nvsp_status_success) { if (net_vsc_pkt->status != nvsp_status_success) {
status = nvsp_status_failure; status = nvsp_status_failure;
} }
@ -928,7 +929,6 @@ hv_nv_on_receive(netvsc_dev *net_dev, struct hv_device *device,
*/ */
hv_nv_on_receive_completion(device, vm_xfer_page_pkt->d.transaction_id, hv_nv_on_receive_completion(device, vm_xfer_page_pkt->d.transaction_id,
status); status);
hv_rf_receive_rollup(net_dev);
} }
/* /*
@ -1002,7 +1002,7 @@ hv_nv_on_channel_callback(void *xchan)
hv_nv_on_send_completion(net_dev, device, desc); hv_nv_on_send_completion(net_dev, device, desc);
break; break;
case HV_VMBUS_PACKET_TYPE_DATA_USING_TRANSFER_PAGES: case HV_VMBUS_PACKET_TYPE_DATA_USING_TRANSFER_PAGES:
hv_nv_on_receive(net_dev, device, desc); hv_nv_on_receive(net_dev, device, chan, desc);
break; break;
default: default:
device_printf(dev, device_printf(dev,
@ -1036,5 +1036,5 @@ hv_nv_on_channel_callback(void *xchan)
if (bufferlen > NETVSC_PACKET_SIZE) if (bufferlen > NETVSC_PACKET_SIZE)
free(buffer, M_NETVSC); free(buffer, M_NETVSC);
hv_rf_channel_rollup(net_dev); hv_rf_channel_rollup(chan);
} }

View File

@ -684,8 +684,9 @@ hn_tx_done(void *xpkt)
} }
void void
netvsc_channel_rollup(struct hv_device *device_ctx) netvsc_channel_rollup(struct hv_vmbus_channel *chan)
{ {
struct hv_device *device_ctx = chan->device;
struct hn_softc *sc = device_get_softc(device_ctx->device); struct hn_softc *sc = device_get_softc(device_ctx->device);
struct hn_tx_ring *txr = &sc->hn_tx_ring[0]; /* TODO: vRSS */ struct hn_tx_ring *txr = &sc->hn_tx_ring[0]; /* TODO: vRSS */
#if defined(INET) || defined(INET6) #if defined(INET) || defined(INET6)
@ -1135,9 +1136,10 @@ hv_m_append(struct mbuf *m0, int len, c_caddr_t cp)
* Note: This is no longer used as a callback * Note: This is no longer used as a callback
*/ */
int int
netvsc_recv(struct hv_device *device_ctx, netvsc_packet *packet, netvsc_recv(struct hv_vmbus_channel *chan, netvsc_packet *packet,
rndis_tcp_ip_csum_info *csum_info) rndis_tcp_ip_csum_info *csum_info)
{ {
struct hv_device *device_ctx = chan->device;
struct hn_softc *sc = device_get_softc(device_ctx->device); struct hn_softc *sc = device_get_softc(device_ctx->device);
struct hn_rx_ring *rxr = &sc->hn_rx_ring[0]; /* TODO: vRSS */ struct hn_rx_ring *rxr = &sc->hn_rx_ring[0]; /* TODO: vRSS */
struct mbuf *m_new; struct mbuf *m_new;
@ -1305,11 +1307,6 @@ skip:
return (0); return (0);
} }
void
netvsc_recv_rollup(struct hv_device *device_ctx __unused)
{
}
/* /*
* Rules for using sc->temp_unusable: * Rules for using sc->temp_unusable:
* 1. sc->temp_unusable can only be read or written while holding NV_LOCK() * 1. sc->temp_unusable can only be read or written while holding NV_LOCK()

View File

@ -1046,11 +1046,11 @@ typedef struct rndismp_rx_bufs_info_ {
/* /*
* Externs * Externs
*/ */
int netvsc_recv(struct hv_device *device_ctx, struct hv_vmbus_channel;
netvsc_packet *packet,
rndis_tcp_ip_csum_info *csum_info); int netvsc_recv(struct hv_vmbus_channel *chan,
void netvsc_recv_rollup(struct hv_device *device_ctx); netvsc_packet *packet, rndis_tcp_ip_csum_info *csum_info);
void netvsc_channel_rollup(struct hv_device *device_ctx); void netvsc_channel_rollup(struct hv_vmbus_channel *chan);
void* hv_set_rppi_data(rndis_msg *rndis_mesg, void* hv_set_rppi_data(rndis_msg *rndis_mesg,
uint32_t rppi_size, uint32_t rppi_size,

View File

@ -58,6 +58,7 @@ static void hv_rf_receive_response(rndis_device *device, rndis_msg *response);
static void hv_rf_receive_indicate_status(rndis_device *device, static void hv_rf_receive_indicate_status(rndis_device *device,
rndis_msg *response); rndis_msg *response);
static void hv_rf_receive_data(rndis_device *device, rndis_msg *message, static void hv_rf_receive_data(rndis_device *device, rndis_msg *message,
struct hv_vmbus_channel *chan,
netvsc_packet *pkt); netvsc_packet *pkt);
static int hv_rf_query_device(rndis_device *device, uint32_t oid, static int hv_rf_query_device(rndis_device *device, uint32_t oid,
void *result, uint32_t *result_size); void *result, uint32_t *result_size);
@ -405,7 +406,8 @@ hv_rf_receive_indicate_status(rndis_device *device, rndis_msg *response)
* RNDIS filter receive data * RNDIS filter receive data
*/ */
static void static void
hv_rf_receive_data(rndis_device *device, rndis_msg *message, netvsc_packet *pkt) hv_rf_receive_data(rndis_device *device, rndis_msg *message,
struct hv_vmbus_channel *chan, netvsc_packet *pkt)
{ {
rndis_packet *rndis_pkt; rndis_packet *rndis_pkt;
ndis_8021q_info *rppi_vlan_info; ndis_8021q_info *rppi_vlan_info;
@ -443,14 +445,15 @@ hv_rf_receive_data(rndis_device *device, rndis_msg *message, netvsc_packet *pkt)
} }
csum_info = hv_get_ppi_data(rndis_pkt, tcpip_chksum_info); csum_info = hv_get_ppi_data(rndis_pkt, tcpip_chksum_info);
netvsc_recv(device->net_dev->dev, pkt, csum_info); netvsc_recv(chan, pkt, csum_info);
} }
/* /*
* RNDIS filter on receive * RNDIS filter on receive
*/ */
int int
hv_rf_on_receive(netvsc_dev *net_dev, struct hv_device *device, netvsc_packet *pkt) hv_rf_on_receive(netvsc_dev *net_dev, struct hv_device *device,
struct hv_vmbus_channel *chan, netvsc_packet *pkt)
{ {
rndis_device *rndis_dev; rndis_device *rndis_dev;
rndis_msg *rndis_hdr; rndis_msg *rndis_hdr;
@ -473,7 +476,7 @@ hv_rf_on_receive(netvsc_dev *net_dev, struct hv_device *device, netvsc_packet *p
/* data message */ /* data message */
case REMOTE_NDIS_PACKET_MSG: case REMOTE_NDIS_PACKET_MSG:
hv_rf_receive_data(rndis_dev, rndis_hdr, pkt); hv_rf_receive_data(rndis_dev, rndis_hdr, chan, pkt);
break; break;
/* completion messages */ /* completion messages */
case REMOTE_NDIS_INITIALIZE_CMPLT: case REMOTE_NDIS_INITIALIZE_CMPLT:
@ -957,32 +960,9 @@ hv_rf_on_send_request_halt_completion(void *context)
request->halt_complete_flag = 1; request->halt_complete_flag = 1;
} }
/*
* RNDIS filter when "all" reception is done
*/
void void
hv_rf_receive_rollup(netvsc_dev *net_dev) hv_rf_channel_rollup(struct hv_vmbus_channel *chan)
{ {
rndis_device *rndis_dev;
rndis_dev = (rndis_device *)net_dev->extension; netvsc_channel_rollup(chan);
netvsc_recv_rollup(rndis_dev->net_dev->dev);
}
void
hv_rf_channel_rollup(netvsc_dev *net_dev)
{
rndis_device *rndis_dev;
rndis_dev = (rndis_device *)net_dev->extension;
/*
* This could be called pretty early, so we need
* to make sure everything has been setup.
*/
if (rndis_dev == NULL ||
rndis_dev->net_dev == NULL ||
rndis_dev->net_dev->dev == NULL)
return;
netvsc_channel_rollup(rndis_dev->net_dev->dev);
} }

View File

@ -95,11 +95,12 @@ typedef struct rndis_device_ {
/* /*
* Externs * Externs
*/ */
struct hv_vmbus_channel;
int hv_rf_on_receive(netvsc_dev *net_dev, int hv_rf_on_receive(netvsc_dev *net_dev, struct hv_device *device,
struct hv_device *device, netvsc_packet *pkt); struct hv_vmbus_channel *chan, netvsc_packet *pkt);
void hv_rf_receive_rollup(netvsc_dev *net_dev); void hv_rf_receive_rollup(netvsc_dev *net_dev);
void hv_rf_channel_rollup(netvsc_dev *net_dev); void hv_rf_channel_rollup(struct hv_vmbus_channel *chan);
int hv_rf_on_device_add(struct hv_device *device, void *additl_info); int hv_rf_on_device_add(struct hv_device *device, void *additl_info);
int hv_rf_on_device_remove(struct hv_device *device, boolean_t destroy_channel); int hv_rf_on_device_remove(struct hv_device *device, boolean_t destroy_channel);
int hv_rf_on_open(struct hv_device *device); int hv_rf_on_open(struct hv_device *device);