[Midnightbsd-cvs] src [8675] trunk/sys/dev/xen/netfront/netfront.c: cleanup

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sun Sep 25 16:41:37 EDT 2016


Revision: 8675
          http://svnweb.midnightbsd.org/src/?rev=8675
Author:   laffer1
Date:     2016-09-25 16:41:37 -0400 (Sun, 25 Sep 2016)
Log Message:
-----------
cleanup

Modified Paths:
--------------
    trunk/sys/dev/xen/netfront/netfront.c

Modified: trunk/sys/dev/xen/netfront/netfront.c
===================================================================
--- trunk/sys/dev/xen/netfront/netfront.c	2016-09-25 20:41:08 UTC (rev 8674)
+++ trunk/sys/dev/xen/netfront/netfront.c	2016-09-25 20:41:37 UTC (rev 8675)
@@ -24,7 +24,6 @@
  * SUCH DAMAGE.
  */
 
-
 #include <sys/cdefs.h>
 __MBSDID("$MidnightBSD$");
 
@@ -208,8 +207,6 @@
 	struct mbuf    *xn_rx_chain[NET_RX_RING_SIZE+1];
 };
 
-#define NUM_ELEMENTS(x) (sizeof(x)/sizeof(*x))
-
 struct net_device_stats
 {
 	u_long	rx_packets;		/* total packets received	*/
@@ -244,7 +241,6 @@
 };
 
 struct netfront_info {
-		
 	struct ifnet *xn_ifp;
 #if __FreeBSD_version >= 700000
 	struct lro_ctrl xn_lro;
@@ -329,12 +325,6 @@
 
 /* Access macros for acquiring freeing slots in xn_free_{tx,rx}_idxs[]. */
 
-
-
-/*
- * Access macros for acquiring freeing slots in tx_skbs[].
- */
-
 static inline void
 add_id_to_freelist(struct mbuf **list, uintptr_t id)
 {
@@ -517,7 +507,6 @@
 	return (0);
 }
 
-
 /* Common code used when first setting up, and when resuming. */
 static int 
 talk_to_backend(device_t dev, struct netfront_info *info)
@@ -605,7 +594,6 @@
 	return err;
 }
 
-
 static int 
 setup_device(device_t dev, struct netfront_info *info)
 {
@@ -794,7 +782,7 @@
 		add_id_to_freelist(np->tx_mbufs, i);
 		np->xn_cdata.xn_tx_chain_cnt--;
 		if (np->xn_cdata.xn_tx_chain_cnt < 0) {
-			panic("netif_release_tx_bufs: tx_chain_cnt must be >= 0");
+			panic("%s: tx_chain_cnt must be >= 0", __func__);
 		}
 		m_free(m);
 	}
@@ -946,7 +934,6 @@
 		reservation.domid        = DOMID_SELF;
 
 		if (!xen_feature(XENFEAT_auto_translated_physmap)) {
-
 			/* After all PTEs have been zapped, flush the TLB. */
 			sc->rx_mcl[i-1].args[MULTI_UVMFLAGS_INDEX] =
 			    UVMF_TLB_FLUSH|UVMF_ALL;
@@ -958,15 +945,11 @@
 			/* Zap PTEs and give away pages in one big multicall. */
 			(void)HYPERVISOR_multicall(sc->rx_mcl, i+1);
 
-			/* Check return status of HYPERVISOR_dom_mem_op(). */
-			if (unlikely(sc->rx_mcl[i].result != i))
-				panic("Unable to reduce memory reservation\n");
-			} else {
-				if (HYPERVISOR_memory_op(
-				    XENMEM_decrease_reservation, &reservation)
-				    != i)
-					panic("Unable to reduce memory "
-					    "reservation\n");
+			if (unlikely(sc->rx_mcl[i].result != i ||
+			    HYPERVISOR_memory_op(XENMEM_decrease_reservation,
+			    &reservation) != i))
+				panic("%s: unable to reduce memory "
+				    "reservation\n", __func__);
 		}
 	} else {
 		wmb();
@@ -1169,8 +1152,8 @@
 				ifp->if_opackets++;
 			if (unlikely(gnttab_query_foreign_access(
 			    np->grant_tx_ref[id]) != 0)) {
-				panic("grant id %u still in use by the backend",
-				      id);
+				panic("%s: grant id %u still in use by the "
+				    "backend", __func__, id);
 			}
 			gnttab_end_foreign_access_ref(
 				np->grant_tx_ref[id]);
@@ -1210,7 +1193,6 @@
 			netif_wake_queue(dev);
 #endif
 	}
-
 }
 
 static void
@@ -1240,7 +1222,6 @@
 		xn_start(ifp);
 }
 
-
 static void
 xennet_move_rx_slot(struct netfront_info *np, struct mbuf *m,
 	grant_ref_t ref)
@@ -1319,17 +1300,15 @@
 
 	m0 = m = m_prev = xennet_get_rx_mbuf(np, *cons);
 
-	
 	if (rx->flags & NETRXF_extra_info) {
 		err = xennet_get_extras(np, extras, rp, cons);
 	}
 
-
 	if (m0 != NULL) {
 		m0->m_pkthdr.len = 0;
 		m0->m_next = NULL;
 	}
-	
+
 	for (;;) {
 		u_long mfn;
 
@@ -1468,10 +1447,8 @@
 	callout_reset(&sc->xn_stat_ch, hz, xn_tick, sc);
 
 	/* XXX placeholder for printing debug information */
-     
 }
 
-
 static void
 xn_tick(void *xsc) 
 {
@@ -1481,7 +1458,6 @@
 	XN_RX_LOCK(sc);
 	xn_tick_locked(sc);
 	XN_RX_UNLOCK(sc);
-     
 }
 
 /**
@@ -1595,10 +1571,12 @@
 		tx = RING_GET_REQUEST(&sc->tx, sc->tx.req_prod_pvt);
 		id = get_id_from_freelist(sc->tx_mbufs);
 		if (id == 0)
-			panic("xn_start_locked: was allocated the freelist head!\n");
+			panic("%s: was allocated the freelist head!\n",
+			    __func__);
 		sc->xn_cdata.xn_tx_chain_cnt++;
 		if (sc->xn_cdata.xn_tx_chain_cnt > NET_TX_RING_SIZE)
-			panic("xn_start_locked: tx_chain_cnt must be <= NET_TX_RING_SIZE\n");
+			panic("%s: tx_chain_cnt must be <= NET_TX_RING_SIZE\n",
+			    __func__);
 		sc->tx_mbufs[id] = m;
 		tx->id = id;
 		ref = gnttab_claim_grant_reference(&sc->gref_tx_head);
@@ -1710,7 +1688,6 @@
 	}
 }
 
-
 static void
 xn_start(struct ifnet *ifp)
 {
@@ -1744,10 +1721,8 @@
 	if_link_state_change(ifp, LINK_STATE_UP);
 	
 	callout_reset(&sc->xn_stat_ch, hz, xn_tick, sc);
-
 }
 
-
 static void 
 xn_ifinit(void *xsc)
 {
@@ -1756,10 +1731,8 @@
 	XN_LOCK(sc);
 	xn_ifinit_locked(sc);
 	XN_UNLOCK(sc);
-
 }
 
-
 static int
 xn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
 {
@@ -2262,7 +2235,7 @@
 	/* Xenbus interface */
 	DEVMETHOD(xenbus_otherend_changed, netfront_backend_changed),
 
-	{ 0, 0 } 
+	DEVMETHOD_END
 }; 
 
 static driver_t netfront_driver = { 
@@ -2272,4 +2245,5 @@
 }; 
 devclass_t netfront_devclass; 
  
-DRIVER_MODULE(xe, xenbusb_front, netfront_driver, netfront_devclass, 0, 0); 
+DRIVER_MODULE(xe, xenbusb_front, netfront_driver, netfront_devclass, NULL,
+    NULL); 



More information about the Midnightbsd-cvs mailing list