Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Aug 2016 05:52:03 +0000 (UTC)
From:      Sepherosa Ziehau <sephe@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r304330 - head/sys/dev/hyperv/netvsc
Message-ID:  <201608180552.u7I5q3O0015000@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: sephe
Date: Thu Aug 18 05:52:03 2016
New Revision: 304330
URL: https://svnweb.freebsd.org/changeset/base/304330

Log:
  hyperv/hn: Get rid of the useless netvsc_packet
  
  MFC after:	1 week
  Sponsored by:	Microsoft
  Differential Revision:	https://reviews.freebsd.org/D7544

Modified:
  head/sys/dev/hyperv/netvsc/hv_net_vsc.c
  head/sys/dev/hyperv/netvsc/hv_net_vsc.h
  head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
  head/sys/dev/hyperv/netvsc/hv_rndis.h
  head/sys/dev/hyperv/netvsc/hv_rndis_filter.c
  head/sys/dev/hyperv/netvsc/hv_rndis_filter.h

Modified: head/sys/dev/hyperv/netvsc/hv_net_vsc.c
==============================================================================
--- head/sys/dev/hyperv/netvsc/hv_net_vsc.c	Thu Aug 18 05:44:58 2016	(r304329)
+++ head/sys/dev/hyperv/netvsc/hv_net_vsc.c	Thu Aug 18 05:52:03 2016	(r304330)
@@ -66,7 +66,7 @@ static int  hv_nv_connect_to_vsp(struct 
 static void hv_nv_on_send_completion(netvsc_dev *net_dev,
     struct vmbus_channel *, const struct vmbus_chanpkt_hdr *pkt);
 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,
     struct hn_rx_ring *rxr, struct vmbus_channel *chan,
     const struct vmbus_chanpkt_hdr *pkt);
@@ -844,11 +844,8 @@ hv_nv_on_receive(netvsc_dev *net_dev, st
 {
 	const struct vmbus_chanpkt_rxbuf *pkt;
 	const struct hn_nvs_hdr *nvs_hdr;
-	netvsc_packet vsc_pkt;
-	netvsc_packet *net_vsc_pkt = &vsc_pkt;
 	int count = 0;
 	int i = 0;
-	int status = HN_NVS_STATUS_OK;
 
 	/* Make sure that this is a RNDIS message. */
 	nvs_hdr = VMBUS_CHANPKT_CONST_DATA(pkthdr);
@@ -870,16 +867,9 @@ hv_nv_on_receive(netvsc_dev *net_dev, st
 
 	/* Each range represents 1 RNDIS pkt that contains 1 Ethernet frame */
 	for (i = 0; i < count; i++) {
-		net_vsc_pkt->status = HN_NVS_STATUS_OK;
-		net_vsc_pkt->data = ((uint8_t *)net_dev->rx_buf +
-		    pkt->cp_rxbuf[i].rb_ofs);
-		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;
+		hv_rf_on_receive(net_dev, rxr,
+		    (const uint8_t *)net_dev->rx_buf + pkt->cp_rxbuf[i].rb_ofs,
+		    pkt->cp_rxbuf[i].rb_len);
 	}
 	
 	/*
@@ -887,7 +877,7 @@ hv_nv_on_receive(netvsc_dev *net_dev, st
 	 * messages (not just data messages) will trigger a response
 	 * 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);
 }
 
 /*
@@ -896,15 +886,14 @@ hv_nv_on_receive(netvsc_dev *net_dev, st
  * Send a receive completion packet to RNDIS device (ie NetVsp)
  */
 static void
-hv_nv_on_receive_completion(struct vmbus_channel *chan, uint64_t tid,
-    uint32_t status)
+hv_nv_on_receive_completion(struct vmbus_channel *chan, uint64_t tid)
 {
 	struct hn_nvs_rndis_ack ack;
 	int retries = 0;
 	int ret = 0;
 	
 	ack.nvs_type = HN_NVS_TYPE_RNDIS_ACK;
-	ack.nvs_status = status;
+	ack.nvs_status = HN_NVS_STATUS_OK;
 
 retry_send_cmplt:
 	/* Send the completion */

Modified: head/sys/dev/hyperv/netvsc/hv_net_vsc.h
==============================================================================
--- head/sys/dev/hyperv/netvsc/hv_net_vsc.h	Thu Aug 18 05:44:58 2016	(r304329)
+++ head/sys/dev/hyperv/netvsc/hv_net_vsc.h	Thu Aug 18 05:52:03 2016	(r304330)
@@ -274,12 +274,6 @@ typedef void (*pfn_on_send_rx_completion
 #define BITS_PER_LONG 32
 #endif
 
-typedef struct netvsc_packet_ {
-	uint32_t	status;
-	uint32_t	tot_data_buf_len;
-	void		*data;
-} netvsc_packet;
-
 typedef struct {
 	uint8_t		mac_addr[6];  /* Assumption unsigned long */
 	uint8_t		link_state;

Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
==============================================================================
--- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c	Thu Aug 18 05:44:58 2016	(r304329)
+++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c	Thu Aug 18 05:52:03 2016	(r304330)
@@ -1277,7 +1277,7 @@ hn_lro_rx(struct lro_ctrl *lc, struct mb
  * Note:  This is no longer used as a callback
  */
 int
-netvsc_recv(struct hn_rx_ring *rxr, netvsc_packet *packet,
+netvsc_recv(struct hn_rx_ring *rxr, const void *data, int dlen,
     const struct hn_recvinfo *info)
 {
 	struct ifnet *ifp = rxr->hn_ifp;
@@ -1291,17 +1291,16 @@ netvsc_recv(struct hn_rx_ring *rxr, netv
 	/*
 	 * Bail out if packet contains more data than configured MTU.
 	 */
-	if (packet->tot_data_buf_len > (ifp->if_mtu + ETHER_HDR_LEN)) {
+	if (dlen > (ifp->if_mtu + ETHER_HDR_LEN)) {
 		return (0);
-	} else if (packet->tot_data_buf_len <= MHLEN) {
+	} else if (dlen <= MHLEN) {
 		m_new = m_gethdr(M_NOWAIT, MT_DATA);
 		if (m_new == NULL) {
 			if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1);
 			return (0);
 		}
-		memcpy(mtod(m_new, void *), packet->data,
-		    packet->tot_data_buf_len);
-		m_new->m_pkthdr.len = m_new->m_len = packet->tot_data_buf_len;
+		memcpy(mtod(m_new, void *), data, dlen);
+		m_new->m_pkthdr.len = m_new->m_len = dlen;
 		rxr->hn_small_pkts++;
 	} else {
 		/*
@@ -1311,7 +1310,7 @@ netvsc_recv(struct hn_rx_ring *rxr, netv
 		 * if looped around to the Hyper-V TX channel, so avoid them.
 		 */
 		size = MCLBYTES;
-		if (packet->tot_data_buf_len > MCLBYTES) {
+		if (dlen > MCLBYTES) {
 			/* 4096 */
 			size = MJUMPAGESIZE;
 		}
@@ -1322,7 +1321,7 @@ netvsc_recv(struct hn_rx_ring *rxr, netv
 			return (0);
 		}
 
-		hv_m_append(m_new, packet->tot_data_buf_len, packet->data);
+		hv_m_append(m_new, dlen, data);
 	}
 	m_new->m_pkthdr.rcvif = ifp;
 

Modified: head/sys/dev/hyperv/netvsc/hv_rndis.h
==============================================================================
--- head/sys/dev/hyperv/netvsc/hv_rndis.h	Thu Aug 18 05:44:58 2016	(r304329)
+++ head/sys/dev/hyperv/netvsc/hv_rndis.h	Thu Aug 18 05:52:03 2016	(r304330)
@@ -1090,8 +1090,8 @@ struct hn_rx_ring;
 struct hn_tx_ring;
 struct hn_recvinfo;
 
-int netvsc_recv(struct hn_rx_ring *rxr,
-    netvsc_packet *packet, const struct hn_recvinfo *info);
+int netvsc_recv(struct hn_rx_ring *rxr, const void *data, int dlen,
+    const struct hn_recvinfo *info);
 void netvsc_channel_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr);
 
 void* hv_set_rppi_data(rndis_msg *rndis_mesg,

Modified: head/sys/dev/hyperv/netvsc/hv_rndis_filter.c
==============================================================================
--- head/sys/dev/hyperv/netvsc/hv_rndis_filter.c	Thu Aug 18 05:44:58 2016	(r304329)
+++ head/sys/dev/hyperv/netvsc/hv_rndis_filter.c	Thu Aug 18 05:52:03 2016	(r304330)
@@ -71,8 +71,8 @@ static void hv_rf_receive_response(rndis
     const rndis_msg *response);
 static void hv_rf_receive_indicate_status(rndis_device *device,
     const rndis_msg *response);
-static void hv_rf_receive_data(struct hn_rx_ring *rxr, const rndis_msg *message,
-			       netvsc_packet *pkt);
+static void hv_rf_receive_data(struct hn_rx_ring *rxr,
+    const void *data, int dlen);
 static int  hv_rf_query_device(rndis_device *device, uint32_t oid,
 			       void *result, uint32_t *result_size);
 static inline int hv_rf_query_device_mac(rndis_device *device);
@@ -519,9 +519,9 @@ skip:
  * RNDIS filter receive data
  */
 static void
-hv_rf_receive_data(struct hn_rx_ring *rxr, const rndis_msg *message,
-    netvsc_packet *pkt)
+hv_rf_receive_data(struct hn_rx_ring *rxr, const void *data, int dlen)
 {
+	const rndis_msg *message = data;
 	const rndis_packet *rndis_pkt;
 	uint32_t data_offset;
 	struct hn_recvinfo info;
@@ -536,24 +536,22 @@ hv_rf_receive_data(struct hn_rx_ring *rx
 	/* Remove rndis header, then pass data packet up the stack */
 	data_offset = RNDIS_HEADER_SIZE + rndis_pkt->data_offset;
 
-	pkt->tot_data_buf_len -= data_offset;
-	if (pkt->tot_data_buf_len < rndis_pkt->data_length) {
-		pkt->status = HN_NVS_STATUS_FAILED;
+	dlen -= data_offset;
+	if (dlen < rndis_pkt->data_length) {
 		if_printf(rxr->hn_ifp,
 		    "total length %u is less than data length %u\n",
-		    pkt->tot_data_buf_len, rndis_pkt->data_length);
+		    dlen, rndis_pkt->data_length);
 		return;
 	}
 
-	pkt->tot_data_buf_len = rndis_pkt->data_length;
-	pkt->data = (void *)((unsigned long)pkt->data + data_offset);
+	dlen = rndis_pkt->data_length;
+	data = (const uint8_t *)data + data_offset;
 
 	if (hv_rf_find_recvinfo(rndis_pkt, &info)) {
-		pkt->status = HN_NVS_STATUS_FAILED;
 		if_printf(rxr->hn_ifp, "recvinfo parsing failed\n");
 		return;
 	}
-	netvsc_recv(rxr, pkt, &info);
+	netvsc_recv(rxr, data, dlen, &info);
 }
 
 /*
@@ -561,30 +559,25 @@ hv_rf_receive_data(struct hn_rx_ring *rx
  */
 int
 hv_rf_on_receive(netvsc_dev *net_dev,
-    struct hn_rx_ring *rxr, netvsc_packet *pkt)
+    struct hn_rx_ring *rxr, const void *data, int dlen)
 {
 	rndis_device *rndis_dev;
 	const rndis_msg *rndis_hdr;
 
 	/* Make sure the rndis device state is initialized */
-	if (net_dev->extension == NULL) {
-		pkt->status = HN_NVS_STATUS_FAILED;
+	if (net_dev->extension == NULL)
 		return (ENODEV);
-	}
 
 	rndis_dev = (rndis_device *)net_dev->extension;
-	if (rndis_dev->state == RNDIS_DEV_UNINITIALIZED) {
-		pkt->status = HN_NVS_STATUS_FAILED;
+	if (rndis_dev->state == RNDIS_DEV_UNINITIALIZED)
 		return (EINVAL);
-	}
-
-	rndis_hdr = pkt->data;
 
+	rndis_hdr = data;
 	switch (rndis_hdr->ndis_msg_type) {
 
 	/* data message */
 	case REMOTE_NDIS_PACKET_MSG:
-		hv_rf_receive_data(rxr, rndis_hdr, pkt);
+		hv_rf_receive_data(rxr, data, dlen);
 		break;
 	/* completion messages */
 	case REMOTE_NDIS_INITIALIZE_CMPLT:

Modified: head/sys/dev/hyperv/netvsc/hv_rndis_filter.h
==============================================================================
--- head/sys/dev/hyperv/netvsc/hv_rndis_filter.h	Thu Aug 18 05:44:58 2016	(r304329)
+++ head/sys/dev/hyperv/netvsc/hv_rndis_filter.h	Thu Aug 18 05:52:03 2016	(r304330)
@@ -115,8 +115,8 @@ typedef struct rndis_device_ {
 struct hn_softc;
 struct hn_rx_ring;
 
-int hv_rf_on_receive(netvsc_dev *net_dev,
-    struct hn_rx_ring *rxr, netvsc_packet *pkt);
+int hv_rf_on_receive(netvsc_dev *net_dev, struct hn_rx_ring *rxr,
+    const void *data, int dlen);
 void hv_rf_receive_rollup(netvsc_dev *net_dev);
 void hv_rf_channel_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr);
 int hv_rf_on_device_add(struct hn_softc *sc, void *additl_info, int nchan,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201608180552.u7I5q3O0015000>